From 1de137839bea5b185730b03d5a94da95d9054ce6 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:26 +0100 Subject: [PATCH 0001/1519] staging: et131x: Converting et1310_mac.c function and local names from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 210 ++++++++++++------------ drivers/staging/et131x/et1310_phy.c | 4 +- drivers/staging/et131x/et131x.h | 20 +-- drivers/staging/et131x/et131x_initpci.c | 12 +- drivers/staging/et131x/et131x_isr.c | 2 +- drivers/staging/et131x/et131x_netdev.c | 4 +- 6 files changed, 126 insertions(+), 126 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 656be4b99cf..db34c7951fc 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -99,12 +99,12 @@ #define COUNTER_MASK_12_BIT (COUNTER_WRAP_12_BIT - 1) /** - * ConfigMacRegs1 - Initialize the first part of MAC regs - * @pAdpater: pointer to our adapter structure + * config_mac_regs1 - Initialize the first part of MAC regs + * @etdev: pointer to our adapter structure */ -void ConfigMACRegs1(struct et131x_adapter *etdev) +void config_mac_regs1(struct et131x_adapter *etdev) { - struct mac_regs __iomem *pMac = &etdev->regs->mac; + struct mac_regs __iomem *macregs = &etdev->regs->mac; u32 station1; u32 station2; u32 ipg; @@ -112,22 +112,22 @@ void ConfigMACRegs1(struct et131x_adapter *etdev) /* First we need to reset everything. Write to MAC configuration * register 1 to perform reset. */ - writel(0xC00F0000, &pMac->cfg1); + writel(0xC00F0000, ¯egs->cfg1); /* Next lets configure the MAC Inter-packet gap register */ ipg = 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */ ipg |= 0x50 << 8; /* ifg enforce 0x50 */ - writel(ipg, &pMac->ipg); + writel(ipg, ¯egs->ipg); /* Next lets configure the MAC Half Duplex register */ /* BEB trunc 0xA, Ex Defer, Rexmit 0xF Coll 0x37 */ - writel(0x00A1F037, &pMac->hfdp); + writel(0x00A1F037, ¯egs->hfdp); /* Next lets configure the MAC Interface Control register */ - writel(0, &pMac->if_ctrl); + writel(0, ¯egs->if_ctrl); /* Let's move on to setting up the mii management configuration */ - writel(0x07, &pMac->mii_mgmt_cfg); /* Clock reset 0x7 */ + writel(0x07, ¯egs->mii_mgmt_cfg); /* Clock reset 0x7 */ /* Next lets configure the MAC Station Address register. These * values are read from the EEPROM during initialization and stored @@ -142,8 +142,8 @@ void ConfigMACRegs1(struct et131x_adapter *etdev) (etdev->addr[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT) | (etdev->addr[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT) | etdev->addr[2]; - writel(station1, &pMac->station_addr_1); - writel(station2, &pMac->station_addr_2); + writel(station1, ¯egs->station_addr_1); + writel(station2, ¯egs->station_addr_2); /* Max ethernet packet in bytes that will passed by the mac without * being truncated. Allow the MAC to pass 4 more than our max packet @@ -152,29 +152,29 @@ void ConfigMACRegs1(struct et131x_adapter *etdev) * Packets larger than (RegistryJumboPacket) that do not contain a * VLAN ID will be dropped by the Rx function. */ - writel(etdev->RegistryJumboPacket + 4, &pMac->max_fm_len); + writel(etdev->RegistryJumboPacket + 4, ¯egs->max_fm_len); /* clear out MAC config reset */ - writel(0, &pMac->cfg1); + writel(0, ¯egs->cfg1); } /** - * ConfigMacRegs2 - Initialize the second part of MAC regs - * @pAdpater: pointer to our adapter structure + * config_mac_regs2 - Initialize the second part of MAC regs + * @etdev: pointer to our adapter structure */ -void ConfigMACRegs2(struct et131x_adapter *etdev) +void config_mac_regs2(struct et131x_adapter *etdev) { int32_t delay = 0; - struct mac_regs __iomem *pMac = &etdev->regs->mac; + struct mac_regs __iomem *mac = &etdev->regs->mac; u32 cfg1; u32 cfg2; u32 ifctrl; u32 ctl; ctl = readl(&etdev->regs->txmac.ctl); - cfg1 = readl(&pMac->cfg1); - cfg2 = readl(&pMac->cfg2); - ifctrl = readl(&pMac->if_ctrl); + cfg1 = readl(&mac->cfg1); + cfg2 = readl(&mac->cfg2); + ifctrl = readl(&mac->if_ctrl); /* Set up the if mode bits */ cfg2 &= ~0x300; @@ -188,12 +188,12 @@ void ConfigMACRegs2(struct et131x_adapter *etdev) } /* We need to enable Rx/Tx */ - cfg1 |= CFG1_RX_ENABLE|CFG1_TX_ENABLE|CFG1_TX_FLOW; + cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; /* Initialize loop back to off */ - cfg1 &= ~(CFG1_LOOPBACK|CFG1_RX_FLOW); + cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); if (etdev->flowcontrol == FLOW_RXONLY || etdev->flowcontrol == FLOW_BOTH) cfg1 |= CFG1_RX_FLOW; - writel(cfg1, &pMac->cfg1); + writel(cfg1, &mac->cfg1); /* Now we need to initialize the MAC Configuration 2 register */ /* preamble 7, check length, huge frame off, pad crc, crc enable @@ -209,13 +209,13 @@ void ConfigMACRegs2(struct et131x_adapter *etdev) if (!etdev->duplex_mode) ifctrl |= (1<<26); /* Enable ghd */ - writel(ifctrl, &pMac->if_ctrl); - writel(cfg2, &pMac->cfg2); + writel(ifctrl, &mac->if_ctrl); + writel(cfg2, &mac->cfg2); do { udelay(10); delay++; - cfg1 = readl(&pMac->cfg1); + cfg1 = readl(&mac->cfg1); } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100); if (delay == 100) { @@ -224,7 +224,7 @@ void ConfigMACRegs2(struct et131x_adapter *etdev) cfg1); } - /* Enable TXMAC */ + /* Enable txmac */ ctl |= 0x09; /* TX mac enable, FC disable */ writel(ctl, &etdev->regs->txmac.ctl); @@ -235,78 +235,78 @@ void ConfigMACRegs2(struct et131x_adapter *etdev) } } -void ConfigRxMacRegs(struct et131x_adapter *etdev) +void config_rxmac_regs(struct et131x_adapter *etdev) { - struct rxmac_regs __iomem *pRxMac = &etdev->regs->rxmac; + struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; u32 sa_lo; u32 sa_hi = 0; u32 pf_ctrl = 0; /* Disable the MAC while it is being configured (also disable WOL) */ - writel(0x8, &pRxMac->ctrl); + writel(0x8, &rxmac->ctrl); /* Initialize WOL to disabled. */ - writel(0, &pRxMac->crc0); - writel(0, &pRxMac->crc12); - writel(0, &pRxMac->crc34); + writel(0, &rxmac->crc0); + writel(0, &rxmac->crc12); + writel(0, &rxmac->crc34); /* We need to set the WOL mask0 - mask4 next. We initialize it to * its default Values of 0x00000000 because there are not WOL masks * as of this time. */ - writel(0, &pRxMac->mask0_word0); - writel(0, &pRxMac->mask0_word1); - writel(0, &pRxMac->mask0_word2); - writel(0, &pRxMac->mask0_word3); + writel(0, &rxmac->mask0_word0); + writel(0, &rxmac->mask0_word1); + writel(0, &rxmac->mask0_word2); + writel(0, &rxmac->mask0_word3); - writel(0, &pRxMac->mask1_word0); - writel(0, &pRxMac->mask1_word1); - writel(0, &pRxMac->mask1_word2); - writel(0, &pRxMac->mask1_word3); + writel(0, &rxmac->mask1_word0); + writel(0, &rxmac->mask1_word1); + writel(0, &rxmac->mask1_word2); + writel(0, &rxmac->mask1_word3); - writel(0, &pRxMac->mask2_word0); - writel(0, &pRxMac->mask2_word1); - writel(0, &pRxMac->mask2_word2); - writel(0, &pRxMac->mask2_word3); + writel(0, &rxmac->mask2_word0); + writel(0, &rxmac->mask2_word1); + writel(0, &rxmac->mask2_word2); + writel(0, &rxmac->mask2_word3); - writel(0, &pRxMac->mask3_word0); - writel(0, &pRxMac->mask3_word1); - writel(0, &pRxMac->mask3_word2); - writel(0, &pRxMac->mask3_word3); + writel(0, &rxmac->mask3_word0); + writel(0, &rxmac->mask3_word1); + writel(0, &rxmac->mask3_word2); + writel(0, &rxmac->mask3_word3); - writel(0, &pRxMac->mask4_word0); - writel(0, &pRxMac->mask4_word1); - writel(0, &pRxMac->mask4_word2); - writel(0, &pRxMac->mask4_word3); + writel(0, &rxmac->mask4_word0); + writel(0, &rxmac->mask4_word1); + writel(0, &rxmac->mask4_word2); + writel(0, &rxmac->mask4_word3); /* Lets setup the WOL Source Address */ sa_lo = (etdev->addr[2] << ET_WOL_LO_SA3_SHIFT) | (etdev->addr[3] << ET_WOL_LO_SA4_SHIFT) | (etdev->addr[4] << ET_WOL_LO_SA5_SHIFT) | etdev->addr[5]; - writel(sa_lo, &pRxMac->sa_lo); + writel(sa_lo, &rxmac->sa_lo); sa_hi = (u32) (etdev->addr[0] << ET_WOL_HI_SA1_SHIFT) | etdev->addr[1]; - writel(sa_hi, &pRxMac->sa_hi); + writel(sa_hi, &rxmac->sa_hi); /* Disable all Packet Filtering */ - writel(0, &pRxMac->pf_ctrl); + writel(0, &rxmac->pf_ctrl); /* Let's initialize the Unicast Packet filtering address */ if (etdev->PacketFilter & ET131X_PACKET_TYPE_DIRECTED) { - SetupDeviceForUnicast(etdev); + setup_device_for_unicast(etdev); pf_ctrl |= 4; /* Unicast filter */ } else { - writel(0, &pRxMac->uni_pf_addr1); - writel(0, &pRxMac->uni_pf_addr2); - writel(0, &pRxMac->uni_pf_addr3); + writel(0, &rxmac->uni_pf_addr1); + writel(0, &rxmac->uni_pf_addr2); + writel(0, &rxmac->uni_pf_addr3); } /* Let's initialize the Multicast hash */ if (!(etdev->PacketFilter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { pf_ctrl |= 2; /* Multicast filter */ - SetupDeviceForMulticast(etdev); + setup_device_for_multicast(etdev); } /* Runt packet filtering. Didn't work in version A silicon. */ @@ -324,18 +324,18 @@ void ConfigRxMacRegs(struct et131x_adapter *etdev) * * seg_en on, fc_en off, size 0x10 */ - writel(0x41, &pRxMac->mcif_ctrl_max_seg); + writel(0x41, &rxmac->mcif_ctrl_max_seg); else - writel(0, &pRxMac->mcif_ctrl_max_seg); + writel(0, &rxmac->mcif_ctrl_max_seg); /* Initialize the MCIF water marks */ - writel(0, &pRxMac->mcif_water_mark); + writel(0, &rxmac->mcif_water_mark); /* Initialize the MIF control */ - writel(0, &pRxMac->mif_ctrl); + writel(0, &rxmac->mif_ctrl); /* Initialize the Space Available Register */ - writel(0, &pRxMac->space_avail); + writel(0, &rxmac->space_avail); /* Initialize the the mif_ctrl register * bit 3: Receive code error. One or more nibbles were signaled as @@ -351,9 +351,9 @@ void ConfigRxMacRegs(struct et131x_adapter *etdev) * bit 17: Drop packet enable */ if (etdev->linkspeed == TRUEPHY_SPEED_100MBPS) - writel(0x30038, &pRxMac->mif_ctrl); + writel(0x30038, &rxmac->mif_ctrl); else - writel(0x30030, &pRxMac->mif_ctrl); + writel(0x30030, &rxmac->mif_ctrl); /* Finally we initialize RxMac to be enabled & WOL disabled. Packet * filter is always enabled since it is where the runt packets are @@ -361,11 +361,11 @@ void ConfigRxMacRegs(struct et131x_adapter *etdev) * dropping doesn't work, so it is disabled in the pf_ctrl register, * but we still leave the packet filter on. */ - writel(pf_ctrl, &pRxMac->pf_ctrl); - writel(0x9, &pRxMac->ctrl); + writel(pf_ctrl, &rxmac->pf_ctrl); + writel(0x9, &rxmac->ctrl); } -void ConfigTxMacRegs(struct et131x_adapter *etdev) +void config_txmac_regs(struct et131x_adapter *etdev) { struct txmac_regs *txmac = &etdev->regs->txmac; @@ -379,7 +379,7 @@ void ConfigTxMacRegs(struct et131x_adapter *etdev) writel(0x40, &txmac->cf_param); } -void ConfigMacStatRegs(struct et131x_adapter *etdev) +void config_macstat_regs(struct et131x_adapter *etdev) { struct macstat_regs __iomem *macstat = &etdev->regs->macstat; @@ -444,7 +444,7 @@ void ConfigMacStatRegs(struct et131x_adapter *etdev) writel(0xFFFE7E8B, &macstat->carry_reg2_mask); } -void ConfigFlowControl(struct et131x_adapter *etdev) +void config_flow_control(struct et131x_adapter *etdev) { if (etdev->duplex_mode == 0) { etdev->flowcontrol = FLOW_NONE; @@ -480,42 +480,42 @@ void ConfigFlowControl(struct et131x_adapter *etdev) } /** - * UpdateMacStatHostCounters - Update the local copy of the statistics + * update_macstat_host_counters - Update the local copy of the statistics * @etdev: pointer to the adapter structure */ -void UpdateMacStatHostCounters(struct et131x_adapter *etdev) +void update_macstat_host_counters(struct et131x_adapter *etdev) { struct ce_stats *stats = &etdev->stats; struct macstat_regs __iomem *macstat = &etdev->regs->macstat; - stats->collisions += readl(&macstat->tx_total_collisions); - stats->first_collision += readl(&macstat->tx_single_collisions); - stats->tx_deferred += readl(&macstat->tx_deferred); + stats->collisions += readl(&macstat->tx_total_collisions); + stats->first_collision += readl(&macstat->tx_single_collisions); + stats->tx_deferred += readl(&macstat->tx_deferred); stats->excessive_collisions += readl(&macstat->tx_multiple_collisions); - stats->late_collisions += readl(&macstat->tx_late_collisions); - stats->tx_uflo += readl(&macstat->tx_undersize_frames); - stats->max_pkt_error += readl(&macstat->tx_oversize_frames); + stats->late_collisions += readl(&macstat->tx_late_collisions); + stats->tx_uflo += readl(&macstat->tx_undersize_frames); + stats->max_pkt_error += readl(&macstat->tx_oversize_frames); - stats->alignment_err += readl(&macstat->rx_align_errs); - stats->crc_err += readl(&macstat->rx_code_errs); - stats->norcvbuf += readl(&macstat->rx_drops); - stats->rx_ov_flow += readl(&macstat->rx_oversize_packets); - stats->code_violations += readl(&macstat->rx_fcs_errs); - stats->length_err += readl(&macstat->rx_frame_len_errs); + stats->alignment_err += readl(&macstat->rx_align_errs); + stats->crc_err += readl(&macstat->rx_code_errs); + stats->norcvbuf += readl(&macstat->rx_drops); + stats->rx_ov_flow += readl(&macstat->rx_oversize_packets); + stats->code_violations += readl(&macstat->rx_fcs_errs); + stats->length_err += readl(&macstat->rx_frame_len_errs); - stats->other_errors += readl(&macstat->rx_fragment_packets); + stats->other_errors += readl(&macstat->rx_fragment_packets); } /** - * HandleMacStatInterrupt + * handle_macstat_interrupt * @etdev: pointer to the adapter structure * * One of the MACSTAT counters has wrapped. Update the local copy of * the statistics held in the adapter structure, checking the "wrap" * bit for each counter. */ -void HandleMacStatInterrupt(struct et131x_adapter *etdev) +void handle_macstat_interrupt(struct et131x_adapter *etdev) { u32 carry_reg1; u32 carry_reg2; @@ -536,36 +536,36 @@ void HandleMacStatInterrupt(struct et131x_adapter *etdev) * block indicates that one of the counters has wrapped. */ if (carry_reg1 & (1 << 14)) - etdev->stats.code_violations += COUNTER_WRAP_16_BIT; + etdev->stats.code_violations += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 8)) - etdev->stats.alignment_err += COUNTER_WRAP_12_BIT; + etdev->stats.alignment_err += COUNTER_WRAP_12_BIT; if (carry_reg1 & (1 << 7)) - etdev->stats.length_err += COUNTER_WRAP_16_BIT; + etdev->stats.length_err += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 2)) - etdev->stats.other_errors += COUNTER_WRAP_16_BIT; + etdev->stats.other_errors += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 6)) - etdev->stats.crc_err += COUNTER_WRAP_16_BIT; + etdev->stats.crc_err += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 3)) - etdev->stats.rx_ov_flow += COUNTER_WRAP_16_BIT; + etdev->stats.rx_ov_flow += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 0)) - etdev->stats.norcvbuf += COUNTER_WRAP_16_BIT; + etdev->stats.norcvbuf += COUNTER_WRAP_16_BIT; if (carry_reg2 & (1 << 16)) - etdev->stats.max_pkt_error += COUNTER_WRAP_12_BIT; + etdev->stats.max_pkt_error += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 15)) - etdev->stats.tx_uflo += COUNTER_WRAP_12_BIT; + etdev->stats.tx_uflo += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 6)) - etdev->stats.first_collision += COUNTER_WRAP_12_BIT; + etdev->stats.first_collision += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 8)) - etdev->stats.tx_deferred += COUNTER_WRAP_12_BIT; + etdev->stats.tx_deferred += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 5)) etdev->stats.excessive_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 4)) - etdev->stats.late_collisions += COUNTER_WRAP_12_BIT; + etdev->stats.late_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 2)) - etdev->stats.collisions += COUNTER_WRAP_12_BIT; + etdev->stats.collisions += COUNTER_WRAP_12_BIT; } -void SetupDeviceForMulticast(struct et131x_adapter *etdev) +void setup_device_for_multicast(struct et131x_adapter *etdev) { struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; uint32_t nIndex; @@ -613,7 +613,7 @@ void SetupDeviceForMulticast(struct et131x_adapter *etdev) } } -void SetupDeviceForUnicast(struct et131x_adapter *etdev) +void setup_device_for_unicast(struct et131x_adapter *etdev) { struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; u32 uni_pf1; diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 0bcb7fb6e2c..d5b02a8e2b1 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -850,7 +850,7 @@ void et131x_Mii_check(struct et131x_adapter *etdev, MiWrite(etdev, 0x12, Register18); } - ConfigFlowControl(etdev); + config_flow_control(etdev); if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && etdev->RegistryJumboPacket > 2048) @@ -858,7 +858,7 @@ void et131x_Mii_check(struct et131x_adapter *etdev, 0x2000); SetRxDmaTimer(etdev); - ConfigMACRegs2(etdev); + config_mac_regs2(etdev); } } } diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 48ebac0e55c..289d511f64d 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -71,16 +71,16 @@ irqreturn_t et131x_isr(int irq, void *dev_id); void et131x_isr_handler(struct work_struct *work); /* et1310_mac.c */ -void ConfigMACRegs1(struct et131x_adapter *adapter); -void ConfigMACRegs2(struct et131x_adapter *adapter); -void ConfigRxMacRegs(struct et131x_adapter *adapter); -void ConfigTxMacRegs(struct et131x_adapter *adapter); -void ConfigMacStatRegs(struct et131x_adapter *adapter); -void ConfigFlowControl(struct et131x_adapter *adapter); -void UpdateMacStatHostCounters(struct et131x_adapter *adapter); -void HandleMacStatInterrupt(struct et131x_adapter *adapter); -void SetupDeviceForMulticast(struct et131x_adapter *adapter); -void SetupDeviceForUnicast(struct et131x_adapter *adapter); +void config_mac_regs1(struct et131x_adapter *adapter); +void config_mac_regs2(struct et131x_adapter *adapter); +void config_rxmac_regs(struct et131x_adapter *adapter); +void config_txmac_regs(struct et131x_adapter *adapter); +void config_macstat_regs(struct et131x_adapter *adapter); +void config_flow_control(struct et131x_adapter *adapter); +void update_macstat_host_counters(struct et131x_adapter *adapter); +void handle_macstat_interrupt(struct et131x_adapter *adapter); +void setup_device_for_multicast(struct et131x_adapter *adapter); +void setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ struct net_device *et131x_device_alloc(void); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 8c8d6b87a25..d98db859f7c 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -269,7 +269,7 @@ void et131x_error_timer_handler(unsigned long data) pm_csr = readl(&etdev->regs->global.pm_csr); if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) - UpdateMacStatHostCounters(etdev); + update_macstat_host_counters(etdev); else dev_err(&etdev->pdev->dev, "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); @@ -369,7 +369,7 @@ void ConfigGlobalRegs(struct et131x_adapter *etdev) /** * et131x_adapter_setup - Set the adapter up as per cassini+ documentation - * @adapter: pointer to our private adapter structure + * @etdev: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h) */ @@ -380,19 +380,19 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) /* Configure the JAGCore */ ConfigGlobalRegs(etdev); - ConfigMACRegs1(etdev); + config_mac_regs1(etdev); /* Configure the MMC registers */ /* All we need to do is initialize the Memory Control Register */ writel(ET_MMC_ENABLE, &etdev->regs->mmc.mmc_ctrl); - ConfigRxMacRegs(etdev); - ConfigTxMacRegs(etdev); + config_rxmac_regs(etdev); + config_txmac_regs(etdev); ConfigRxDmaRegs(etdev); ConfigTxDmaRegs(etdev); - ConfigMacStatRegs(etdev); + config_macstat_regs(etdev); /* Move the following code to Timer function?? */ status = et131x_xcvr_find(etdev); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 9c33209c840..48b4d785e11 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -460,7 +460,7 @@ void et131x_isr_handler(struct work_struct *work) * to maintain the top, software managed bits of the * counter(s). */ - HandleMacStatInterrupt(etdev); + handle_macstat_interrupt(etdev); } /* Handle SLV Timeout Interrupt */ diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 5f25bbad36b..4e9e1766ba6 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -301,14 +301,14 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter) if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) pf_ctrl &= ~2; /* Multicast filter bit */ else { - SetupDeviceForMulticast(adapter); + setup_device_for_multicast(adapter); pf_ctrl |= 2; ctrl &= ~0x04; } /* Set us up with Unicast packet filtering */ if (filter & ET131X_PACKET_TYPE_DIRECTED) { - SetupDeviceForUnicast(adapter); + setup_device_for_unicast(adapter); pf_ctrl |= 4; ctrl &= ~0x04; } From 99fa7e1492cb328f72ac8e231cec61b5e60666dc Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:27 +0100 Subject: [PATCH 0002/1519] staging: et131x: Converting et1310_phy.c function and local names from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 10 +- drivers/staging/et131x/et1310_phy.c | 398 ++++++++++++------------ drivers/staging/et131x/et131x.h | 35 +-- drivers/staging/et131x/et131x_initpci.c | 14 +- drivers/staging/et131x/et131x_isr.c | 9 +- drivers/staging/et131x/et131x_netdev.c | 4 +- 6 files changed, 232 insertions(+), 238 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index db34c7951fc..21b615381bd 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -451,11 +451,11 @@ void config_flow_control(struct et131x_adapter *etdev) } else { char remote_pause, remote_async_pause; - ET1310_PhyAccessMiBit(etdev, - TRUEPHY_BIT_READ, 5, 10, &remote_pause); - ET1310_PhyAccessMiBit(etdev, - TRUEPHY_BIT_READ, 5, 11, - &remote_async_pause); + et1310_phy_access_mii_bit(etdev, + TRUEPHY_BIT_READ, 5, 10, &remote_pause); + et1310_phy_access_mii_bit(etdev, + TRUEPHY_BIT_READ, 5, 11, + &remote_async_pause); if ((remote_pause == TRUEPHY_BIT_SET) && (remote_async_pause == TRUEPHY_BIT_SET)) { diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index d5b02a8e2b1..d53656bae84 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -93,39 +93,36 @@ #include "et131x.h" -/* Prototypes for functions with local scope */ -static void et131x_xcvr_init(struct et131x_adapter *etdev); - /** - * PhyMiRead - Read from the PHY through the MII Interface on the MAC + * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC * @etdev: pointer to our private adapter structure - * @xcvrAddr: the address of the transceiver - * @xcvrReg: the register to read + * @xcvr_addr: the address of the transceiver + * @xcvr_reg: the register to read * @value: pointer to a 16-bit value in which the value will be stored * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int PhyMiRead(struct et131x_adapter *etdev, u8 xcvrAddr, - u8 xcvrReg, u16 *value) +int et131x_phy_mii_read(struct et131x_adapter *etdev, u8 xcvr_addr, + u8 xcvr_reg, u16 *value) { struct mac_regs __iomem *mac = &etdev->regs->mac; int status = 0; u32 delay; - u32 miiAddr; - u32 miiCmd; - u32 miiIndicator; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; /* Save a local copy of the registers we are dealing with so we can * set them back */ - miiAddr = readl(&mac->mii_mgmt_addr); - miiCmd = readl(&mac->mii_mgmt_cmd); + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); /* Stop the current operation */ writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to read from on the correct PHY */ - writel(MII_ADDR(xcvrAddr, xcvrReg), &mac->mii_mgmt_addr); + writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); /* Kick the read cycle off */ delay = 0; @@ -135,15 +132,15 @@ int PhyMiRead(struct et131x_adapter *etdev, u8 xcvrAddr, do { udelay(50); delay++; - miiIndicator = readl(&mac->mii_mgmt_indicator); - } while ((miiIndicator & MGMT_WAIT) && delay < 50); + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_WAIT) && delay < 50); /* If we hit the max delay, we could not read the register */ if (delay == 50) { dev_warn(&etdev->pdev->dev, - "xcvrReg 0x%08x could not be read\n", xcvrReg); + "xcvrReg 0x%08x could not be read\n", xcvr_reg); dev_warn(&etdev->pdev->dev, "status is 0x%08x\n", - miiIndicator); + mii_indicator); status = -EIO; } @@ -158,43 +155,43 @@ int PhyMiRead(struct et131x_adapter *etdev, u8 xcvrAddr, /* set the registers we touched back to the state at which we entered * this function */ - writel(miiAddr, &mac->mii_mgmt_addr); - writel(miiCmd, &mac->mii_mgmt_cmd); + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); return status; } /** - * MiWrite - Write to a PHY register through the MII interface of the MAC + * et131x_mii_write - Write to a PHY register through the MII interface of the MAC * @etdev: pointer to our private adapter structure - * @xcvrReg: the register to read + * @xcvr_reg: the register to read * @value: 16-bit value to write * * FIXME: one caller in netdev still * * Return 0 on success, errno on failure (as defined in errno.h) */ -int MiWrite(struct et131x_adapter *etdev, u8 xcvrReg, u16 value) +int et131x_mii_write(struct et131x_adapter *etdev, u8 xcvr_reg, u16 value) { struct mac_regs __iomem *mac = &etdev->regs->mac; int status = 0; - u8 xcvrAddr = etdev->stats.xcvr_addr; + u8 xcvr_addr = etdev->stats.xcvr_addr; u32 delay; - u32 miiAddr; - u32 miiCmd; - u32 miiIndicator; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; /* Save a local copy of the registers we are dealing with so we can * set them back */ - miiAddr = readl(&mac->mii_mgmt_addr); - miiCmd = readl(&mac->mii_mgmt_cmd); + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); /* Stop the current operation */ writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to write to on the correct PHY */ - writel(MII_ADDR(xcvrAddr, xcvrReg), &mac->mii_mgmt_addr); + writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); /* Add the value to write to the registers to the mac */ writel(value, &mac->mii_mgmt_ctrl); @@ -203,32 +200,33 @@ int MiWrite(struct et131x_adapter *etdev, u8 xcvrReg, u16 value) do { udelay(50); delay++; - miiIndicator = readl(&mac->mii_mgmt_indicator); - } while ((miiIndicator & MGMT_BUSY) && delay < 100); + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_BUSY) && delay < 100); /* If we hit the max delay, we could not write the register */ if (delay == 100) { - u16 TempValue; + u16 tmp; dev_warn(&etdev->pdev->dev, - "xcvrReg 0x%08x could not be written", xcvrReg); + "xcvrReg 0x%08x could not be written", xcvr_reg); dev_warn(&etdev->pdev->dev, "status is 0x%08x\n", - miiIndicator); + mii_indicator); dev_warn(&etdev->pdev->dev, "command is 0x%08x\n", readl(&mac->mii_mgmt_cmd)); - MiRead(etdev, xcvrReg, &TempValue); + et131x_mii_read(etdev, xcvr_reg, &tmp); status = -EIO; } /* Stop the write operation */ writel(0, &mac->mii_mgmt_cmd); - /* set the registers we touched back to the state at which we entered + /* + * set the registers we touched back to the state at which we entered * this function */ - writel(miiAddr, &mac->mii_mgmt_addr); - writel(miiCmd, &mac->mii_mgmt_cmd); + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); return status; } @@ -249,12 +247,12 @@ int et131x_xcvr_find(struct et131x_adapter *etdev) /* We need to get xcvr id and address we just get the first one */ for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) { /* Read the ID from the PHY */ - PhyMiRead(etdev, xcvr_addr, - (u8) offsetof(struct mi_regs, idr1), - &idr1); - PhyMiRead(etdev, xcvr_addr, - (u8) offsetof(struct mi_regs, idr2), - &idr2); + et131x_phy_mii_read(etdev, xcvr_addr, + (u8) offsetof(struct mi_regs, idr1), + &idr1); + et131x_phy_mii_read(etdev, xcvr_addr, + (u8) offsetof(struct mi_regs, idr2), + &idr2); xcvr_id = (u32) ((idr1 << 16) | idr2); @@ -267,13 +265,13 @@ int et131x_xcvr_find(struct et131x_adapter *etdev) return -ENODEV; } -void ET1310_PhyReset(struct et131x_adapter *etdev) +void et1310_phy_reset(struct et131x_adapter *etdev) { - MiWrite(etdev, PHY_CONTROL, 0x8000); + et131x_mii_write(etdev, PHY_CONTROL, 0x8000); } /** - * ET1310_PhyPowerDown - PHY power control + * et1310_phy_power_down - PHY power control * @etdev: device to control * @down: true for off/false for back on * @@ -282,80 +280,76 @@ void ET1310_PhyReset(struct et131x_adapter *etdev) * Can't you see that this code processed * Phy power, phy power.. */ - -void ET1310_PhyPowerDown(struct et131x_adapter *etdev, bool down) +void et1310_phy_power_down(struct et131x_adapter *etdev, bool down) { u16 data; - MiRead(etdev, PHY_CONTROL, &data); + et131x_mii_read(etdev, PHY_CONTROL, &data); data &= ~0x0800; /* Power UP */ if (down) /* Power DOWN */ data |= 0x0800; - MiWrite(etdev, PHY_CONTROL, data); + et131x_mii_write(etdev, PHY_CONTROL, data); } /** - * ET130_PhyAutoNEg - autonegotiate control + * et1310_phy_auto_neg - autonegotiate control * @etdev: device to control * @enabe: autoneg on/off * * Set up the autonegotiation state according to whether we will be * negotiating the state or forcing a speed. */ - -static void ET1310_PhyAutoNeg(struct et131x_adapter *etdev, bool enable) +static void et1310_phy_auto_neg(struct et131x_adapter *etdev, bool enable) { u16 data; - MiRead(etdev, PHY_CONTROL, &data); + et131x_mii_read(etdev, PHY_CONTROL, &data); data &= ~0x1000; /* Autonegotiation OFF */ if (enable) data |= 0x1000; /* Autonegotiation ON */ - MiWrite(etdev, PHY_CONTROL, data); + et131x_mii_write(etdev, PHY_CONTROL, data); } /** - * ET130_PhyDuplexMode - duplex control + * et1310_phy_duplex_mode - duplex control * @etdev: device to control * @duplex: duplex on/off * * Set up the duplex state on the PHY */ - -static void ET1310_PhyDuplexMode(struct et131x_adapter *etdev, u16 duplex) +static void et1310_phy_duplex_mode(struct et131x_adapter *etdev, u16 duplex) { u16 data; - MiRead(etdev, PHY_CONTROL, &data); + et131x_mii_read(etdev, PHY_CONTROL, &data); data &= ~0x100; /* Set Half Duplex */ if (duplex == TRUEPHY_DUPLEX_FULL) data |= 0x100; /* Set Full Duplex */ - MiWrite(etdev, PHY_CONTROL, data); + et131x_mii_write(etdev, PHY_CONTROL, data); } /** - * ET130_PhySpeedSelect - speed control + * et1310_phy_speed_select - speed control * @etdev: device to control * @duplex: duplex on/off * * Set the speed of our PHY. */ - -static void ET1310_PhySpeedSelect(struct et131x_adapter *etdev, u16 speed) +static void et1310_phy_speed_select(struct et131x_adapter *etdev, u16 speed) { u16 data; static const u16 bits[3] = {0x0000, 0x2000, 0x0040}; /* Read the PHY control register */ - MiRead(etdev, PHY_CONTROL, &data); + et131x_mii_read(etdev, PHY_CONTROL, &data); /* Clear all Speed settings (Bits 6, 13) */ data &= ~0x2040; /* Write back the new speed */ - MiWrite(etdev, PHY_CONTROL, data | bits[speed]); + et131x_mii_write(etdev, PHY_CONTROL, data | bits[speed]); } /** - * ET1310_PhyLinkStatus - read link state + * et1310_phy_link_status - read link state * @etdev: device to read * @link_status: reported link state * @autoneg: reported autonegotiation state (complete/incomplete/disabled) @@ -370,8 +364,7 @@ static void ET1310_PhySpeedSelect(struct et131x_adapter *etdev, u16 speed) * I know your link speed * I see all the setting that you'd rather keep */ - -static void ET1310_PhyLinkStatus(struct et131x_adapter *etdev, +static void et1310_phy_link_status(struct et131x_adapter *etdev, u8 *link_status, u32 *autoneg, u32 *linkspeed, @@ -384,10 +377,10 @@ static void ET1310_PhyLinkStatus(struct et131x_adapter *etdev, u16 vmi_phystatus = 0; u16 control = 0; - MiRead(etdev, PHY_STATUS, &mistatus); - MiRead(etdev, PHY_1000_STATUS, &is1000BaseT); - MiRead(etdev, PHY_PHY_STATUS, &vmi_phystatus); - MiRead(etdev, PHY_CONTROL, &control); + et131x_mii_read(etdev, PHY_STATUS, &mistatus); + et131x_mii_read(etdev, PHY_1000_STATUS, &is1000BaseT); + et131x_mii_read(etdev, PHY_PHY_STATUS, &vmi_phystatus); + et131x_mii_read(etdev, PHY_CONTROL, &control); *link_status = (vmi_phystatus & 0x0040) ? 1 : 0; *autoneg = (control & 0x1000) ? ((vmi_phystatus & 0x0020) ? @@ -405,26 +398,26 @@ static void ET1310_PhyLinkStatus(struct et131x_adapter *etdev, TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL; } -static void ET1310_PhyAndOrReg(struct et131x_adapter *etdev, - u16 regnum, u16 andMask, u16 orMask) +static void et1310_phy_and_or_reg(struct et131x_adapter *etdev, + u16 regnum, u16 and_mask, u16 or_mask) { u16 reg; - MiRead(etdev, regnum, ®); - reg &= andMask; - reg |= orMask; - MiWrite(etdev, regnum, reg); + et131x_mii_read(etdev, regnum, ®); + reg &= and_mask; + reg |= or_mask; + et131x_mii_write(etdev, regnum, reg); } -/* Still used from _mac for BIT_READ */ -void ET1310_PhyAccessMiBit(struct et131x_adapter *etdev, u16 action, - u16 regnum, u16 bitnum, u8 *value) +/* Still used from _mac for BIT_READ */ +void et1310_phy_access_mii_bit(struct et131x_adapter *etdev, u16 action, + u16 regnum, u16 bitnum, u8 *value) { u16 reg; u16 mask = 0x0001 << bitnum; /* Read the requested register */ - MiRead(etdev, regnum, ®); + et131x_mii_read(etdev, regnum, ®); switch (action) { case TRUEPHY_BIT_READ: @@ -432,11 +425,11 @@ void ET1310_PhyAccessMiBit(struct et131x_adapter *etdev, u16 action, break; case TRUEPHY_BIT_SET: - MiWrite(etdev, regnum, reg | mask); + et131x_mii_write(etdev, regnum, reg | mask); break; case TRUEPHY_BIT_CLEAR: - MiWrite(etdev, regnum, reg & ~mask); + et131x_mii_write(etdev, regnum, reg & ~mask); break; default: @@ -444,13 +437,13 @@ void ET1310_PhyAccessMiBit(struct et131x_adapter *etdev, u16 action, } } -void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *etdev, +void et1310_phy_advertise_1000BaseT(struct et131x_adapter *etdev, u16 duplex) { u16 data; /* Read the PHY 1000 Base-T Control Register */ - MiRead(etdev, PHY_1000_CONTROL, &data); + et131x_mii_read(etdev, PHY_1000_CONTROL, &data); /* Clear Bits 8,9 */ data &= ~0x0300; @@ -477,16 +470,16 @@ void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - MiWrite(etdev, PHY_1000_CONTROL, data); + et131x_mii_write(etdev, PHY_1000_CONTROL, data); } -static void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *etdev, - u16 duplex) +static void et1310_phy_advertise_100BaseT(struct et131x_adapter *etdev, + u16 duplex) { u16 data; /* Read the Autonegotiation Register (10/100) */ - MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data); + et131x_mii_read(etdev, PHY_AUTO_ADVERTISEMENT, &data); /* Clear bits 7,8 */ data &= ~0x0180; @@ -514,16 +507,16 @@ static void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data); + et131x_mii_write(etdev, PHY_AUTO_ADVERTISEMENT, data); } -static void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *etdev, +static void et1310_phy_advertise_10BaseT(struct et131x_adapter *etdev, u16 duplex) { u16 data; /* Read the Autonegotiation Register (10/100) */ - MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data); + et131x_mii_read(etdev, PHY_AUTO_ADVERTISEMENT, &data); /* Clear bits 5,6 */ data &= ~0x0060; @@ -551,25 +544,9 @@ static void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data); + et131x_mii_write(etdev, PHY_AUTO_ADVERTISEMENT, data); } -/** - * et131x_setphy_normal - Set PHY for normal operation. - * @etdev: pointer to our private adapter structure - * - * Used by Power Management to force the PHY into 10 Base T half-duplex mode, - * when going to D3 in WOL mode. Also used during initialization to set the - * PHY for normal operation. - */ -void et131x_setphy_normal(struct et131x_adapter *etdev) -{ - /* Make sure the PHY is powered up */ - ET1310_PhyPowerDown(etdev, 0); - et131x_xcvr_init(etdev); -} - - /** * et131x_xcvr_init - Init the phy if we are setting it into force mode * @etdev: pointer to our private adapter structure @@ -584,15 +561,15 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) /* Zero out the adapter structure variable representing BMSR */ etdev->bmsr = 0; - MiRead(etdev, (u8) offsetof(struct mi_regs, isr), &isr); - MiRead(etdev, (u8) offsetof(struct mi_regs, imr), &imr); + et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, isr), &isr); + et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, imr), &imr); /* Set the link status interrupt only. Bad behavior when link status * and auto neg are set, we run into a nested interrupt problem */ imr |= 0x0105; - MiWrite(etdev, (u8) offsetof(struct mi_regs, imr), imr); + et131x_mii_write(etdev, (u8) offsetof(struct mi_regs, imr), imr); /* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates @@ -603,7 +580,7 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) * EEPROM. However, the above description is the default. */ if ((etdev->eeprom_data[1] & 0x4) == 0) { - MiRead(etdev, (u8) offsetof(struct mi_regs, lcr2), + et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, lcr2), &lcr2); lcr2 &= 0x00FF; @@ -614,7 +591,7 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) else lcr2 |= 0x0400; - MiWrite(etdev, (u8) offsetof(struct mi_regs, lcr2), + et131x_mii_write(etdev, (u8) offsetof(struct mi_regs, lcr2), lcr2); } @@ -622,113 +599,130 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) if (etdev->AiForceSpeed == 0 && etdev->AiForceDpx == 0) { if (etdev->wanted_flow == FLOW_TXONLY || etdev->wanted_flow == FLOW_BOTH) - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 4, 11, NULL); else - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, 4, 11, NULL); if (etdev->wanted_flow == FLOW_BOTH) - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 4, 10, NULL); else - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, 4, 10, NULL); /* Set the phy to autonegotiation */ - ET1310_PhyAutoNeg(etdev, true); + et1310_phy_auto_neg(etdev, true); /* NOTE - Do we need this? */ - ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_SET, 0, 9, NULL); + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 0, 9, NULL); return; } - ET1310_PhyAutoNeg(etdev, false); + et1310_phy_auto_neg(etdev, false); /* Set to the correct force mode. */ if (etdev->AiForceDpx != 1) { if (etdev->wanted_flow == FLOW_TXONLY || etdev->wanted_flow == FLOW_BOTH) - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 4, 11, NULL); else - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, 4, 11, NULL); if (etdev->wanted_flow == FLOW_BOTH) - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 4, 10, NULL); else - ET1310_PhyAccessMiBit(etdev, + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } else { - ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_CLEAR, 4, 10, NULL); - ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_CLEAR, 4, 11, NULL); + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, + 4, 10, NULL); + et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, + 4, 11, NULL); } - ET1310_PhyPowerDown(etdev, 1); + et1310_phy_power_down(etdev, 1); switch (etdev->AiForceSpeed) { case 10: /* First we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); if (etdev->AiForceDpx == 1) { /* Set our advertise values accordingly */ - ET1310_PhyAdvertise10BaseT(etdev, + et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); } else if (etdev->AiForceDpx == 2) { /* Set our advertise values accordingly */ - ET1310_PhyAdvertise10BaseT(etdev, + et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); } else { /* Disable autoneg */ - ET1310_PhyAutoNeg(etdev, false); + et1310_phy_auto_neg(etdev, false); /* Disable rest of the advertisements */ - ET1310_PhyAdvertise10BaseT(etdev, + et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Force 10 Mbps */ - ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_10MBPS); + et1310_phy_speed_select(etdev, TRUEPHY_SPEED_10MBPS); /* Force Full duplex */ - ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL); + et1310_phy_duplex_mode(etdev, TRUEPHY_DUPLEX_FULL); } break; case 100: /* first we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); if (etdev->AiForceDpx == 1) { /* Set our advertise values accordingly */ - ET1310_PhyAdvertise100BaseT(etdev, + et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); /* Set speed */ - ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS); + et1310_phy_speed_select(etdev, TRUEPHY_SPEED_100MBPS); } else if (etdev->AiForceDpx == 2) { /* Set our advertise values accordingly */ - ET1310_PhyAdvertise100BaseT(etdev, + et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); } else { /* Disable autoneg */ - ET1310_PhyAutoNeg(etdev, false); + et1310_phy_auto_neg(etdev, false); /* Disable other advertisement */ - ET1310_PhyAdvertise100BaseT(etdev, + et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Force 100 Mbps */ - ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS); + et1310_phy_speed_select(etdev, TRUEPHY_SPEED_100MBPS); /* Force Full duplex */ - ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL); + et1310_phy_duplex_mode(etdev, TRUEPHY_DUPLEX_FULL); } break; case 1000: /* first we need to turn off all other advertisement */ - ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* set our advertise values accordingly */ - ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); + et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); break; } - ET1310_PhyPowerDown(etdev, 0); + et1310_phy_power_down(etdev, 0); } -void et131x_Mii_check(struct et131x_adapter *etdev, +/** + * et131x_setphy_normal - Set PHY for normal operation. + * @etdev: pointer to our private adapter structure + * + * Used by Power Management to force the PHY into 10 Base T half-duplex mode, + * when going to D3 in WOL mode. Also used during initialization to set the + * PHY for normal operation. + */ +void et131x_setphy_normal(struct et131x_adapter *etdev) +{ + /* Make sure the PHY is powered up */ + et1310_phy_power_down(etdev, 0); + et131x_xcvr_init(etdev); +} + +void et131x_mii_check(struct et131x_adapter *etdev, u16 bmsr, u16 bmsr_ints) { u8 link_status; @@ -764,13 +758,14 @@ void et131x_Mii_check(struct et131x_adapter *etdev, * && TRU_QueryCoreType(etdev->hTruePhy, 0) == * EMI_TRUEPHY_A13O) { */ - u16 Register18; + u16 register18; - MiRead(etdev, 0x12, &Register18); - MiWrite(etdev, 0x12, Register18 | 0x4); - MiWrite(etdev, 0x10, Register18 | 0x8402); - MiWrite(etdev, 0x11, Register18 | 511); - MiWrite(etdev, 0x12, Register18); + et131x_mii_read(etdev, 0x12, ®ister18); + et131x_mii_write(etdev, 0x12, register18 | 0x4); + et131x_mii_write(etdev, 0x10, + register18 | 0x8402); + et131x_mii_write(etdev, 0x11, register18 | 511); + et131x_mii_write(etdev, 0x12, register18); } /* For the first N seconds of life, we are in "link @@ -805,7 +800,7 @@ void et131x_Mii_check(struct et131x_adapter *etdev, * Bring the device back to the state it was during * init prior to autonegotiation being complete. This * way, when we get the auto-neg complete interrupt, - * we can complete init by calling ConfigMacREGS2. + * we can complete init by calling config_mac_regs2. */ et131x_soft_reset(etdev); @@ -824,7 +819,7 @@ void et131x_Mii_check(struct et131x_adapter *etdev, (etdev->AiForceDpx == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { if ((bmsr & MI_BMSR_AUTO_NEG_COMPLETE) || etdev->AiForceDpx == 3) { - ET1310_PhyLinkStatus(etdev, + et1310_phy_link_status(etdev, &link_status, &autoneg_status, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); @@ -841,20 +836,21 @@ void et131x_Mii_check(struct et131x_adapter *etdev, * && TRU_QueryCoreType(etdev->hTruePhy, 0)== * EMI_TRUEPHY_A13O) { */ - u16 Register18; + u16 register18; - MiRead(etdev, 0x12, &Register18); - MiWrite(etdev, 0x12, Register18 | 0x4); - MiWrite(etdev, 0x10, Register18 | 0x8402); - MiWrite(etdev, 0x11, Register18 | 511); - MiWrite(etdev, 0x12, Register18); + et131x_mii_read(etdev, 0x12, ®ister18); + et131x_mii_write(etdev, 0x12, register18 | 0x4); + et131x_mii_write(etdev, 0x10, + register18 | 0x8402); + et131x_mii_write(etdev, 0x11, register18 | 511); + et131x_mii_write(etdev, 0x12, register18); } config_flow_control(etdev); if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && etdev->RegistryJumboPacket > 2048) - ET1310_PhyAndOrReg(etdev, 0x16, 0xcfff, + et1310_phy_and_or_reg(etdev, 0x16, 0xcfff, 0x2000); SetRxDmaTimer(etdev); @@ -868,9 +864,8 @@ void et131x_Mii_check(struct et131x_adapter *etdev, * primarily by the routines above (although there are a few places elsewhere * in the driver where this level of access is required). */ - -static const u16 ConfigPhy[25][2] = { - /* Reg Value Register */ +static const u16 config_phy[25][2] = { + /* Reg Value Register */ /* Addr */ {0x880B, 0x0926}, /* AfeIfCreg4B1000Msbs */ {0x880C, 0x0926}, /* AfeIfCreg4B100Msbs */ @@ -906,11 +901,10 @@ static const u16 ConfigPhy[25][2] = { {0x8010, 46}, /* IdlguardTime */ {0, 0} - }; /* condensed version of the phy initialization routine */ -void ET1310_PhyInit(struct et131x_adapter *etdev) +void et1310_phy_init(struct et131x_adapter *etdev) { u16 data, index; @@ -918,62 +912,66 @@ void ET1310_PhyInit(struct et131x_adapter *etdev) return; /* get the identity (again ?) */ - MiRead(etdev, PHY_ID_1, &data); - MiRead(etdev, PHY_ID_2, &data); + et131x_mii_read(etdev, PHY_ID_1, &data); + et131x_mii_read(etdev, PHY_ID_2, &data); /* what does this do/achieve ? */ - MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006); + /* should read 0002 */ + et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0006); /* read modem register 0402, should I do something with the return data ? */ - MiWrite(etdev, PHY_INDEX_REG, 0x0402); - MiRead(etdev, PHY_DATA_REG, &data); + et131x_mii_write(etdev, PHY_INDEX_REG, 0x0402); + et131x_mii_read(etdev, PHY_DATA_REG, &data); /* what does this do/achieve ? */ - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); /* get the identity (again ?) */ - MiRead(etdev, PHY_ID_1, &data); - MiRead(etdev, PHY_ID_2, &data); + et131x_mii_read(etdev, PHY_ID_1, &data); + et131x_mii_read(etdev, PHY_ID_2, &data); /* what does this achieve ? */ - MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006); + /* should read 0002 */ + et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0006); /* read modem register 0402, should I do something with the return data? */ - MiWrite(etdev, PHY_INDEX_REG, 0x0402); - MiRead(etdev, PHY_DATA_REG, &data); + et131x_mii_write(etdev, PHY_INDEX_REG, 0x0402); + et131x_mii_read(etdev, PHY_DATA_REG, &data); - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); /* what does this achieve (should return 0x1040) */ - MiRead(etdev, PHY_CONTROL, &data); - MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ - MiWrite(etdev, PHY_CONTROL, 0x1840); + et131x_mii_read(etdev, PHY_CONTROL, &data); + /* should read 0002 */ + et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(etdev, PHY_CONTROL, 0x1840); - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0007); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0007); /* here the writing of the array starts.... */ index = 0; - while (ConfigPhy[index][0] != 0x0000) { + while (config_phy[index][0] != 0x0000) { /* write value */ - MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]); - MiWrite(etdev, PHY_DATA_REG, ConfigPhy[index][1]); + et131x_mii_write(etdev, PHY_INDEX_REG, config_phy[index][0]); + et131x_mii_write(etdev, PHY_DATA_REG, config_phy[index][1]); /* read it back */ - MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]); - MiRead(etdev, PHY_DATA_REG, &data); + et131x_mii_write(etdev, PHY_INDEX_REG, config_phy[index][0]); + et131x_mii_read(etdev, PHY_DATA_REG, &data); /* do a check on the value read back ? */ index++; } /* here the writing of the array ends... */ - MiRead(etdev, PHY_CONTROL, &data); /* 0x1840 */ - MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);/* should read 0007 */ - MiWrite(etdev, PHY_CONTROL, 0x1040); - MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_read(etdev, PHY_CONTROL, &data); /* 0x1840 */ + /* should read 0007 */ + et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(etdev, PHY_CONTROL, 0x1040); + et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); } diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 289d511f64d..c4f9032d6a1 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -90,14 +90,14 @@ void EnablePhyComa(struct et131x_adapter *adapter); void DisablePhyComa(struct et131x_adapter *adapter); /* et131x_phy.c */ -void ET1310_PhyInit(struct et131x_adapter *adapter); -void ET1310_PhyReset(struct et131x_adapter *adapter); -void ET1310_PhyPowerDown(struct et131x_adapter *adapter, bool down); -void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *adapter, - u16 duplex); -void ET1310_PhyAccessMiBit(struct et131x_adapter *adapter, - u16 action, - u16 regnum, u16 bitnum, u8 *value); +void et1310_phy_init(struct et131x_adapter *adapter); +void et1310_phy_reset(struct et131x_adapter *adapter); +void et1310_phy_power_down(struct et131x_adapter *adapter, bool down); +void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter, + u16 duplex); +void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, + u16 action, + u16 regnum, u16 bitnum, u8 *value); int et131x_xcvr_find(struct et131x_adapter *adapter); void et131x_setphy_normal(struct et131x_adapter *adapter); @@ -105,23 +105,18 @@ void et131x_setphy_normal(struct et131x_adapter *adapter); /* static inline function does not work because et131x_adapter is not always * defined */ -int PhyMiRead(struct et131x_adapter *adapter, u8 xcvrAddr, +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvrAddr, u8 xcvrReg, u16 *value); -#define MiRead(adapter, xcvrReg, value) \ - PhyMiRead((adapter), (adapter)->stats.xcvr_addr, (xcvrReg), (value)) +#define et131x_mii_read(adapter, xcvrReg, value) \ + et131x_phy_mii_read((adapter), \ + (adapter)->stats.xcvr_addr, \ + (xcvrReg), (value)) -int32_t MiWrite(struct et131x_adapter *adapter, +int32_t et131x_mii_write(struct et131x_adapter *adapter, u8 xcvReg, u16 value); -void et131x_Mii_check(struct et131x_adapter *pAdapter, +void et131x_mii_check(struct et131x_adapter *pAdapter, u16 bmsr, u16 bmsr_ints); -/* This last is not strictly required (the driver could call the TPAL - * version instead), but this sets the adapter up correctly, and calls the - * access routine indirectly. This protects the driver from changes in TPAL. - */ -void SetPhy_10BaseTHalfDuplex(struct et131x_adapter *adapter); - - /* et1310_rx.c */ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter); void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index d98db859f7c..9b01f22c18b 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -401,28 +401,28 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) dev_warn(&etdev->pdev->dev, "Could not find the xcvr\n"); /* Prepare the TRUEPHY library. */ - ET1310_PhyInit(etdev); + et1310_phy_init(etdev); /* Reset the phy now so changes take place */ - ET1310_PhyReset(etdev); + et1310_phy_reset(etdev); /* Power down PHY */ - ET1310_PhyPowerDown(etdev, 1); + et1310_phy_power_down(etdev, 1); /* * We need to turn off 1000 base half dulplex, the mac does not * support it. For the 10/100 part, turn off all gig advertisement */ if (etdev->pdev->device != ET131X_PCI_DEVICE_ID_FAST) - ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); + et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); else - ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Power up PHY */ - ET1310_PhyPowerDown(etdev, 0); + et1310_phy_power_down(etdev, 0); et131x_setphy_normal(etdev); -; return status; + return status; } /** diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 48b4d785e11..0a810cce631 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -385,11 +385,12 @@ void et131x_isr_handler(struct work_struct *work) /* Read the PHY ISR to clear the reason for the * interrupt. */ - MiRead(etdev, (uint8_t) offsetof(struct mi_regs, isr), - &myisr); + et131x_mii_read(etdev, + (uint8_t) offsetof(struct mi_regs, isr), + &myisr); if (!etdev->ReplicaPhyLoopbk) { - MiRead(etdev, + et131x_mii_read(etdev, (uint8_t) offsetof(struct mi_regs, bmsr), &bmsr_data); @@ -397,7 +398,7 @@ void et131x_isr_handler(struct work_struct *work) etdev->bmsr = bmsr_data; /* Do all the cable in / cable out stuff */ - et131x_Mii_check(etdev, bmsr_data, bmsr_ints); + et131x_mii_check(etdev, bmsr_data, bmsr_ints); } } diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 4e9e1766ba6..0f12b584c44 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -221,7 +221,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) if (!capable(CAP_NET_ADMIN)) status = -EPERM; else - status = MiRead(etdev, + status = et131x_mii_read(etdev, data->reg_num, &data->val_out); break; @@ -229,7 +229,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) if (!capable(CAP_NET_ADMIN)) status = -EPERM; else - status = MiWrite(etdev, data->reg_num, + status = et131x_mii_write(etdev, data->reg_num, data->val_in); break; From c2329af4b9abe91218c07c3ed4897d48eca4b918 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:28 +0100 Subject: [PATCH 0003/1519] staging: et131x: Converting et1310_pm.c function and local names from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 2 +- drivers/staging/et131x/et1310_pm.c | 8 ++++---- drivers/staging/et131x/et131x.h | 8 ++++---- drivers/staging/et131x/et131x_initpci.c | 2 +- drivers/staging/et131x/et131x_isr.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index d53656bae84..72892e06199 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -811,7 +811,7 @@ void et131x_mii_check(struct et131x_adapter *etdev, * plugged back in */ if (etdev->RegistryPhyComa == 1) - EnablePhyComa(etdev); + et1310_enable_phy_coma(etdev); } } diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index 29d4d66d345..1bfcc670501 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -87,7 +87,7 @@ #include "et131x.h" /** - * EnablePhyComa - called when network cable is unplugged + * et1310_enable_phy_coma - called when network cable is unplugged * @etdev: pointer to our adapter structure * * driver receive an phy status change interrupt while in D0 and check that @@ -106,7 +106,7 @@ * indicating linkup status, call the MPDisablePhyComa routine to * restore JAGCore and gigE PHY */ -void EnablePhyComa(struct et131x_adapter *etdev) +void et1310_enable_phy_coma(struct et131x_adapter *etdev) { unsigned long flags; u32 pmcsr; @@ -136,10 +136,10 @@ void EnablePhyComa(struct et131x_adapter *etdev) } /** - * DisablePhyComa - Disable the Phy Coma Mode + * et1310_disable_phy_coma - Disable the Phy Coma Mode * @etdev: pointer to our adapter structure */ -void DisablePhyComa(struct et131x_adapter *etdev) +void et1310_disable_phy_coma(struct et131x_adapter *etdev) { u32 pmcsr; diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index c4f9032d6a1..240305e74c4 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -85,11 +85,11 @@ void setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ struct net_device *et131x_device_alloc(void); -/* et131x_pm.c */ -void EnablePhyComa(struct et131x_adapter *adapter); -void DisablePhyComa(struct et131x_adapter *adapter); +/* et1310_pm.c */ +void et1310_enable_phy_coma(struct et131x_adapter *adapter); +void et1310_disable_phy_coma(struct et131x_adapter *adapter); -/* et131x_phy.c */ +/* et1310_phy.c */ void et1310_phy_init(struct et131x_adapter *adapter); void et1310_phy_reset(struct et131x_adapter *adapter); void et1310_phy_power_down(struct et131x_adapter *adapter, bool down); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 9b01f22c18b..c39f5f046a0 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -288,7 +288,7 @@ void et131x_error_timer_handler(unsigned long data) * interrupt'. How to do that under Linux? */ et131x_enable_interrupts(etdev); - EnablePhyComa(etdev); + et1310_enable_phy_coma(etdev); } } } diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 0a810cce631..dd952f07e5e 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -379,7 +379,7 @@ void et131x_isr_handler(struct work_struct *work) * so, disable it because we will not be able * to read PHY values until we are out. */ - DisablePhyComa(etdev); + et1310_disable_phy_coma(etdev); } /* Read the PHY ISR to clear the reason for the From 9590e93c79073fc1e36e18fd79ca870fc710c129 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:30 +0100 Subject: [PATCH 0004/1519] staging: et131x: Converting et1310_rx.c function and local names from CamelCase Also renamed some items to improve readability, and other minor tidy-ups. Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 2 +- drivers/staging/et131x/et1310_rx.c | 191 ++++++++++++------------ drivers/staging/et131x/et131x.h | 4 +- drivers/staging/et131x/et131x_initpci.c | 2 +- 4 files changed, 97 insertions(+), 102 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 72892e06199..d3d3b463742 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -853,7 +853,7 @@ void et131x_mii_check(struct et131x_adapter *etdev, et1310_phy_and_or_reg(etdev, 0x16, 0xcfff, 0x2000); - SetRxDmaTimer(etdev); + et131x_set_rx_dma_timer(etdev); config_mac_regs2(etdev); } } diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 7e386e07ff9..e5bafc8f570 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -88,22 +88,22 @@ #include "et1310_rx.h" #include "et131x.h" -static inline u32 bump_fbr(u32 *fbr, u32 limit) +static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) { - u32 v = *fbr; - v++; + u32 tmp_free_buff_ring = *free_buff_ring; + tmp_free_buff_ring++; /* This works for all cases where limit < 1024. The 1023 case works because 1023++ is 1024 which means the if condition is not taken but the carry of the bit into the wrap bit toggles the wrap value correctly */ - if ((v & ET_DMA10_MASK) > limit) { - v &= ~ET_DMA10_MASK; - v ^= ET_DMA10_WRAP; + if ((tmp_free_buff_ring & ET_DMA10_MASK) > limit) { + tmp_free_buff_ring &= ~ET_DMA10_MASK; + tmp_free_buff_ring ^= ET_DMA10_WRAP; } /* For the 1023 case */ - v &= (ET_DMA10_MASK|ET_DMA10_WRAP); - *fbr = v; - return v; + tmp_free_buff_ring &= (ET_DMA10_MASK|ET_DMA10_WRAP); + *free_buff_ring = tmp_free_buff_ring; + return tmp_free_buff_ring; } /** @@ -119,7 +119,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) { u32 i, j; u32 bufsize; - u32 pktStatRingSize, FBRChunkSize; + u32 pktstat_ringsize, fbr_chunksize; struct rx_ring *rx_ring; /* Setup some convenience pointers */ @@ -239,9 +239,9 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) for (i = 0; i < (rx_ring->Fbr1NumEntries / FBR_CHUNKS); i++) { - u64 Fbr1Offset; - u64 Fbr1TempPa; - u32 Fbr1Align; + u64 fbr1_offset; + u64 fbr1_tmp_physaddr; + u32 fbr1_align; /* This code allocates an area of memory big enough for N * free buffers + (buffer_size - 1) so that the buffers can @@ -251,14 +251,14 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * reduce this overhead. */ if (rx_ring->Fbr1BufferSize > 4096) - Fbr1Align = 4096; + fbr1_align = 4096; else - Fbr1Align = rx_ring->Fbr1BufferSize; + fbr1_align = rx_ring->Fbr1BufferSize; - FBRChunkSize = - (FBR_CHUNKS * rx_ring->Fbr1BufferSize) + Fbr1Align - 1; + fbr_chunksize = + (FBR_CHUNKS * rx_ring->Fbr1BufferSize) + fbr1_align - 1; rx_ring->Fbr1MemVa[i] = - pci_alloc_consistent(adapter->pdev, FBRChunkSize, + pci_alloc_consistent(adapter->pdev, fbr_chunksize, &rx_ring->Fbr1MemPa[i]); if (!rx_ring->Fbr1MemVa[i]) { @@ -268,11 +268,11 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) } /* See NOTE in "Save Physical Address" comment above */ - Fbr1TempPa = rx_ring->Fbr1MemPa[i]; + fbr1_tmp_physaddr = rx_ring->Fbr1MemPa[i]; et131x_align_allocated_memory(adapter, - &Fbr1TempPa, - &Fbr1Offset, (Fbr1Align - 1)); + &fbr1_tmp_physaddr, + &fbr1_offset, (fbr1_align - 1)); for (j = 0; j < FBR_CHUNKS; j++) { u32 index = (i * FBR_CHUNKS) + j; @@ -282,16 +282,17 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) */ rx_ring->fbr[1]->virt[index] = (u8 *) rx_ring->Fbr1MemVa[i] + - (j * rx_ring->Fbr1BufferSize) + Fbr1Offset; + (j * rx_ring->Fbr1BufferSize) + fbr1_offset; /* now store the physical address in the descriptor * so the device can access it */ rx_ring->fbr[1]->bus_high[index] = - (u32) (Fbr1TempPa >> 32); - rx_ring->fbr[1]->bus_low[index] = (u32) Fbr1TempPa; + (u32) (fbr1_tmp_physaddr >> 32); + rx_ring->fbr[1]->bus_low[index] = + (u32) fbr1_tmp_physaddr; - Fbr1TempPa += rx_ring->Fbr1BufferSize; + fbr1_tmp_physaddr += rx_ring->Fbr1BufferSize; rx_ring->fbr[1]->buffer1[index] = rx_ring->fbr[1]->virt[index]; @@ -304,12 +305,13 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Same for FBR0 (if in use) */ for (i = 0; i < (rx_ring->Fbr0NumEntries / FBR_CHUNKS); i++) { - u64 Fbr0Offset; - u64 Fbr0TempPa; + u64 fbr0_offset; + u64 fbr0_tmp_physaddr; - FBRChunkSize = ((FBR_CHUNKS + 1) * rx_ring->Fbr0BufferSize) - 1; + fbr_chunksize = + ((FBR_CHUNKS + 1) * rx_ring->Fbr0BufferSize) - 1; rx_ring->Fbr0MemVa[i] = - pci_alloc_consistent(adapter->pdev, FBRChunkSize, + pci_alloc_consistent(adapter->pdev, fbr_chunksize, &rx_ring->Fbr0MemPa[i]); if (!rx_ring->Fbr0MemVa[i]) { @@ -319,11 +321,11 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) } /* See NOTE in "Save Physical Address" comment above */ - Fbr0TempPa = rx_ring->Fbr0MemPa[i]; + fbr0_tmp_physaddr = rx_ring->Fbr0MemPa[i]; et131x_align_allocated_memory(adapter, - &Fbr0TempPa, - &Fbr0Offset, + &fbr0_tmp_physaddr, + &fbr0_offset, rx_ring->Fbr0BufferSize - 1); for (j = 0; j < FBR_CHUNKS; j++) { @@ -331,13 +333,14 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) rx_ring->fbr[0]->virt[index] = (u8 *) rx_ring->Fbr0MemVa[i] + - (j * rx_ring->Fbr0BufferSize) + Fbr0Offset; + (j * rx_ring->Fbr0BufferSize) + fbr0_offset; rx_ring->fbr[0]->bus_high[index] = - (u32) (Fbr0TempPa >> 32); - rx_ring->fbr[0]->bus_low[index] = (u32) Fbr0TempPa; + (u32) (fbr0_tmp_physaddr >> 32); + rx_ring->fbr[0]->bus_low[index] = + (u32) fbr0_tmp_physaddr; - Fbr0TempPa += rx_ring->Fbr0BufferSize; + fbr0_tmp_physaddr += rx_ring->Fbr0BufferSize; rx_ring->fbr[0]->buffer1[index] = rx_ring->fbr[0]->virt[index]; @@ -348,11 +351,11 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) #endif /* Allocate an area of memory for FIFO of Packet Status ring entries */ - pktStatRingSize = + pktstat_ringsize = sizeof(struct pkt_stat_desc) * adapter->rx_ring.PsrNumEntries; rx_ring->pPSRingVa = pci_alloc_consistent(adapter->pdev, - pktStatRingSize, + pktstat_ringsize, &rx_ring->pPSRingPa); if (!rx_ring->pPSRingVa) { @@ -360,7 +363,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) "Cannot alloc memory for Packet Status Ring\n"); return -ENOMEM; } - printk(KERN_INFO "PSR %lx\n", (unsigned long) rx_ring->pPSRingPa); + printk(KERN_INFO "Packet Status Ring %lx\n", + (unsigned long) rx_ring->pPSRingPa); /* * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, @@ -411,7 +415,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) { u32 index; u32 bufsize; - u32 pktStatRingSize; + u32 pktstat_ringsize; struct rfd *rfd; struct rx_ring *rx_ring; @@ -436,16 +440,16 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) for (index = 0; index < (rx_ring->Fbr1NumEntries / FBR_CHUNKS); index++) { if (rx_ring->Fbr1MemVa[index]) { - u32 Fbr1Align; + u32 fbr1_align; if (rx_ring->Fbr1BufferSize > 4096) - Fbr1Align = 4096; + fbr1_align = 4096; else - Fbr1Align = rx_ring->Fbr1BufferSize; + fbr1_align = rx_ring->Fbr1BufferSize; bufsize = (rx_ring->Fbr1BufferSize * FBR_CHUNKS) + - Fbr1Align - 1; + fbr1_align - 1; pci_free_consistent(adapter->pdev, bufsize, @@ -506,10 +510,10 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Free Packet Status Ring */ if (rx_ring->pPSRingVa) { - pktStatRingSize = + pktstat_ringsize = sizeof(struct pkt_stat_desc) * adapter->rx_ring.PsrNumEntries; - pci_free_consistent(adapter->pdev, pktStatRingSize, + pci_free_consistent(adapter->pdev, pktstat_ringsize, rx_ring->pPSRingVa, rx_ring->pPSRingPa); rx_ring->pPSRingVa = NULL; @@ -597,10 +601,10 @@ int et131x_init_recv(struct et131x_adapter *adapter) } /** - * ConfigRxDmaRegs - Start of Rx_DMA init sequence + * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence * @etdev: pointer to our adapter structure */ -void ConfigRxDmaRegs(struct et131x_adapter *etdev) +void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) { struct rxdma_regs __iomem *rx_dma = &etdev->regs->rxdma; struct rx_ring *rx_local = &etdev->rx_ring; @@ -708,10 +712,10 @@ void ConfigRxDmaRegs(struct et131x_adapter *etdev) } /** - * SetRxDmaTimer - Set the heartbeat timer according to line rate. + * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. * @etdev: pointer to our adapter structure */ -void SetRxDmaTimer(struct et131x_adapter *etdev) +void et131x_set_rx_dma_timer(struct et131x_adapter *etdev) { /* For version B silicon, we do not use the RxDMA timer for 10 and 100 * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. @@ -732,8 +736,8 @@ void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) { struct rx_ring *rx_local = &etdev->rx_ring; struct rxdma_regs __iomem *rx_dma = &etdev->regs->rxdma; - u16 bi = rfd->bufferindex; - u8 ri = rfd->ringindex; + u16 buff_index = rfd->bufferindex; + u8 ring_index = rfd->ringindex; unsigned long flags; /* We don't use any of the OOB data besides status. Otherwise, we @@ -741,12 +745,12 @@ void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) */ if ( #ifdef USE_FBR0 - (ri == 0 && bi < rx_local->Fbr0NumEntries) || + (ring_index == 0 && buff_index < rx_local->Fbr0NumEntries) || #endif - (ri == 1 && bi < rx_local->Fbr1NumEntries)) { + (ring_index == 1 && buff_index < rx_local->Fbr1NumEntries)) { spin_lock_irqsave(&etdev->FbrLock, flags); - if (ri == 1) { + if (ring_index == 1) { struct fbr_desc *next = (struct fbr_desc *) (rx_local->pFbr1RingVa) + INDEX10(rx_local->local_Fbr1_full); @@ -755,11 +759,11 @@ void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) * the PA / Buffer Index for the returned buffer into * the oldest (next to be freed)FBR entry */ - next->addr_hi = rx_local->fbr[1]->bus_high[bi]; - next->addr_lo = rx_local->fbr[1]->bus_low[bi]; - next->word2 = bi; + next->addr_hi = rx_local->fbr[1]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; + next->word2 = buff_index; - writel(bump_fbr(&rx_local->local_Fbr1_full, + writel(bump_free_buff_ring(&rx_local->local_Fbr1_full, rx_local->Fbr1NumEntries - 1), &rx_dma->fbr1_full_offset); } @@ -773,11 +777,11 @@ void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) * the PA / Buffer Index for the returned buffer into * the oldest (next to be freed) FBR entry */ - next->addr_hi = rx_local->fbr[0]->bus_high[bi]; - next->addr_lo = rx_local->fbr[0]->bus_low[bi]; - next->word2 = bi; + next->addr_hi = rx_local->fbr[0]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; + next->word2 = buff_index; - writel(bump_fbr(&rx_local->local_Fbr0_full, + writel(bump_free_buff_ring(&rx_local->local_Fbr0_full, rx_local->Fbr0NumEntries - 1), &rx_dma->fbr0_full_offset); } @@ -785,7 +789,7 @@ void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) spin_unlock_irqrestore(&etdev->FbrLock, flags); } else { dev_err(&etdev->pdev->dev, - "NICReturnRFD illegal Buffer Index returned\n"); + "%s illegal Buffer Index returned\n", __func__); } /* The processing on this RFD is done, so put it back on the tail of @@ -878,8 +882,8 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) u8 *buf; unsigned long flags; struct list_head *element; - u8 rindex; - u16 bindex; + u8 ring_index; + u16 buff_index; u32 len; u32 word0; u32 word1; @@ -905,8 +909,8 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * accurate */ len = psr->word1 & 0xFFFF; - rindex = (psr->word1 >> 26) & 0x03; - bindex = (psr->word1 >> 16) & 0x3FF; + ring_index = (psr->word1 >> 26) & 0x03; + buff_index = (psr->word1 >> 16) & 0x3FF; word0 = psr->word0; /* Indicate that we have used this PSR entry. */ @@ -922,18 +926,18 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) &etdev->regs->rxdma.psr_full_offset); #ifndef USE_FBR0 - if (rindex != 1) + if (ring_index != 1) return NULL; #endif #ifdef USE_FBR0 - if (rindex > 1 || - (rindex == 0 && - bindex > rx_local->Fbr0NumEntries - 1) || - (rindex == 1 && - bindex > rx_local->Fbr1NumEntries - 1)) + if (ring_index > 1 || + (ring_index == 0 && + buff_index > rx_local->Fbr0NumEntries - 1) || + (ring_index == 1 && + buff_index > rx_local->Fbr1NumEntries - 1)) #else - if (rindex != 1 || bindex > rx_local->Fbr1NumEntries - 1) + if (ring_index != 1 || buff_index > rx_local->Fbr1NumEntries - 1) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ @@ -941,7 +945,7 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) "NICRxPkts PSR Entry %d indicates " "length of %d and/or bad bi(%d)\n", rx_local->local_psr_full & 0xFFF, - len, bindex); + len, buff_index); return NULL; } @@ -962,8 +966,8 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) spin_unlock_irqrestore(&etdev->rcv_lock, flags); - rfd->bufferindex = bindex; - rfd->ringindex = rindex; + rfd->bufferindex = buff_index; + rfd->ringindex = ring_index; /* In V1 silicon, there is a bug which screws up filtering of * runt packets. Therefore runt packet filtering is disabled @@ -977,7 +981,7 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) if (len) { if (etdev->ReplicaPhyLoopbk == 1) { - buf = rx_local->fbr[rindex]->virt[bindex]; + buf = rx_local->fbr[ring_index]->virt[buff_index]; if (memcmp(&buf[6], etdev->addr, ETH_ALEN) == 0) { if (memcmp(&buf[42], "Replica packet", @@ -1000,28 +1004,20 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) if ((etdev->PacketFilter & ET131X_PACKET_TYPE_MULTICAST) && !(etdev->PacketFilter & ET131X_PACKET_TYPE_PROMISCUOUS) && !(etdev->PacketFilter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { - buf = rx_local->fbr[rindex]-> - virt[bindex]; + buf = rx_local->fbr[ring_index]-> + virt[buff_index]; /* Loop through our list to see if the * destination address of this packet * matches one in our list. */ - for (i = 0; - i < etdev->MCAddressCount; - i++) { - if (buf[0] == - etdev->MCList[i][0] - && buf[1] == - etdev->MCList[i][1] - && buf[2] == - etdev->MCList[i][2] - && buf[3] == - etdev->MCList[i][3] - && buf[4] == - etdev->MCList[i][4] - && buf[5] == - etdev->MCList[i][5]) { + for (i = 0; i < etdev->MCAddressCount; i++) { + if (buf[0] == etdev->MCList[i][0] + && buf[1] == etdev->MCList[i][1] + && buf[2] == etdev->MCList[i][2] + && buf[3] == etdev->MCList[i][3] + && buf[4] == etdev->MCList[i][4] + && buf[5] == etdev->MCList[i][5]) { break; } } @@ -1067,7 +1063,7 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) etdev->net_stats.rx_bytes += rfd->len; memcpy(skb_put(skb, rfd->len), - rx_local->fbr[rindex]->virt[bindex], + rx_local->fbr[ring_index]->virt[buff_index], rfd->len); skb->dev = etdev->netdev; @@ -1092,7 +1088,6 @@ struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) void et131x_reset_recv(struct et131x_adapter *etdev) { WARN_ON(list_empty(&etdev->rx_ring.RecvList)); - } /** diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 240305e74c4..c33594ba744 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -126,8 +126,8 @@ void et131x_rfd_resources_free(struct et131x_adapter *adapter, struct rfd *rfd); int et131x_init_recv(struct et131x_adapter *adapter); -void ConfigRxDmaRegs(struct et131x_adapter *adapter); -void SetRxDmaTimer(struct et131x_adapter *adapter); +void et131x_config_rx_dma_regs(struct et131x_adapter *adapter); +void et131x_set_rx_dma_timer(struct et131x_adapter *adapter); void et131x_rx_dma_disable(struct et131x_adapter *adapter); void et131x_rx_dma_enable(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index c39f5f046a0..75b2c485112 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -389,7 +389,7 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) config_rxmac_regs(etdev); config_txmac_regs(etdev); - ConfigRxDmaRegs(etdev); + et131x_config_rx_dma_regs(etdev); ConfigTxDmaRegs(etdev); config_macstat_regs(etdev); From 42e26f343b405c1cb60c7a2f1d39c006b845beb7 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:31 +0100 Subject: [PATCH 0005/1519] staging: et131x: Make static some local functions in et1310_rx.c Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index e5bafc8f570..926ea660094 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -732,7 +732,7 @@ void et131x_set_rx_dma_timer(struct et131x_adapter *etdev) * @etdev: pointer to our adapter * @rfd: pointer to the RFD */ -void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) +static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) { struct rx_ring *rx_local = &etdev->rx_ring; struct rxdma_regs __iomem *rx_dma = &etdev->regs->rxdma; @@ -872,7 +872,7 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) * the packet to it, puts the RFD in the RecvPendList, and also returns * the pointer to the RFD. */ -struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) +static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) { struct rx_ring *rx_local = &etdev->rx_ring; struct rx_status_block *status; From 22592afa20dfcef415463253d84a1eed4bc6140d Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:32 +0100 Subject: [PATCH 0006/1519] staging: et131x: Converting et1310_rx.h variable names from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_rx.c | 338 ++++++++++++++-------------- drivers/staging/et131x/et1310_rx.h | 62 ++--- drivers/staging/et131x/et131x_isr.c | 2 +- 3 files changed, 205 insertions(+), 197 deletions(-) diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 926ea660094..694bb028477 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -151,40 +151,40 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) if (adapter->RegistryJumboPacket < 2048) { #ifdef USE_FBR0 - rx_ring->Fbr0BufferSize = 256; - rx_ring->Fbr0NumEntries = 512; + rx_ring->fbr0_buffsize = 256; + rx_ring->fbr0_num_entries = 512; #endif - rx_ring->Fbr1BufferSize = 2048; - rx_ring->Fbr1NumEntries = 512; + rx_ring->fbr1_buffsize = 2048; + rx_ring->fbr1_num_entries = 512; } else if (adapter->RegistryJumboPacket < 4096) { #ifdef USE_FBR0 - rx_ring->Fbr0BufferSize = 512; - rx_ring->Fbr0NumEntries = 1024; + rx_ring->fbr0_buffsize = 512; + rx_ring->fbr0_num_entries = 1024; #endif - rx_ring->Fbr1BufferSize = 4096; - rx_ring->Fbr1NumEntries = 512; + rx_ring->fbr1_buffsize = 4096; + rx_ring->fbr1_num_entries = 512; } else { #ifdef USE_FBR0 - rx_ring->Fbr0BufferSize = 1024; - rx_ring->Fbr0NumEntries = 768; + rx_ring->fbr0_buffsize = 1024; + rx_ring->fbr0_num_entries = 768; #endif - rx_ring->Fbr1BufferSize = 16384; - rx_ring->Fbr1NumEntries = 128; + rx_ring->fbr1_buffsize = 16384; + rx_ring->fbr1_num_entries = 128; } #ifdef USE_FBR0 - adapter->rx_ring.PsrNumEntries = adapter->rx_ring.Fbr0NumEntries + - adapter->rx_ring.Fbr1NumEntries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr0_num_entries + + adapter->rx_ring.fbr1_num_entries; #else - adapter->rx_ring.PsrNumEntries = adapter->rx_ring.Fbr1NumEntries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr1_num_entries; #endif /* Allocate an area of memory for Free Buffer Ring 1 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr1NumEntries) + 0xfff; - rx_ring->pFbr1RingVa = pci_alloc_consistent(adapter->pdev, - bufsize, - &rx_ring->pFbr1RingPa); - if (!rx_ring->pFbr1RingVa) { + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff; + rx_ring->fbr1_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize, + &rx_ring->fbr1_ring_physaddr); + if (!rx_ring->fbr1_ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 1\n"); return -ENOMEM; @@ -197,23 +197,24 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here * before storing the adjusted address. */ - rx_ring->Fbr1Realpa = rx_ring->pFbr1RingPa; + rx_ring->fbr1_real_physaddr = rx_ring->fbr1_ring_physaddr; /* Align Free Buffer Ring 1 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->Fbr1Realpa, - &rx_ring->Fbr1offset, 0x0FFF); + &rx_ring->fbr1_real_physaddr, + &rx_ring->fbr1_offset, 0x0FFF); - rx_ring->pFbr1RingVa = (void *)((u8 *) rx_ring->pFbr1RingVa + - rx_ring->Fbr1offset); + rx_ring->fbr1_ring_virtaddr = + (void *)((u8 *) rx_ring->fbr1_ring_virtaddr + + rx_ring->fbr1_offset); #ifdef USE_FBR0 /* Allocate an area of memory for Free Buffer Ring 0 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr0NumEntries) + 0xfff; - rx_ring->pFbr0RingVa = pci_alloc_consistent(adapter->pdev, - bufsize, - &rx_ring->pFbr0RingPa); - if (!rx_ring->pFbr0RingVa) { + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff; + rx_ring->fbr0_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize, + &rx_ring->fbr0_ring_physaddr); + if (!rx_ring->fbr0_ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 0\n"); return -ENOMEM; @@ -226,19 +227,18 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. */ - rx_ring->Fbr0Realpa = rx_ring->pFbr0RingPa; + rx_ring->fbr0_real_physaddr = rx_ring->fbr0_ring_physaddr; /* Align Free Buffer Ring 0 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->Fbr0Realpa, - &rx_ring->Fbr0offset, 0x0FFF); + &rx_ring->fbr0_real_physaddr, + &rx_ring->fbr0_offset, 0x0FFF); - rx_ring->pFbr0RingVa = (void *)((u8 *) rx_ring->pFbr0RingVa + - rx_ring->Fbr0offset); + rx_ring->fbr0_ring_virtaddr = + (void *)((u8 *) rx_ring->fbr0_ring_virtaddr + + rx_ring->fbr0_offset); #endif - - for (i = 0; i < (rx_ring->Fbr1NumEntries / FBR_CHUNKS); - i++) { + for (i = 0; i < (rx_ring->fbr1_num_entries / FBR_CHUNKS); i++) { u64 fbr1_offset; u64 fbr1_tmp_physaddr; u32 fbr1_align; @@ -250,25 +250,25 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * the size of FBR0. By allocating N buffers at once, we * reduce this overhead. */ - if (rx_ring->Fbr1BufferSize > 4096) + if (rx_ring->fbr1_buffsize > 4096) fbr1_align = 4096; else - fbr1_align = rx_ring->Fbr1BufferSize; + fbr1_align = rx_ring->fbr1_buffsize; fbr_chunksize = - (FBR_CHUNKS * rx_ring->Fbr1BufferSize) + fbr1_align - 1; - rx_ring->Fbr1MemVa[i] = + (FBR_CHUNKS * rx_ring->fbr1_buffsize) + fbr1_align - 1; + rx_ring->fbr1_mem_virtaddrs[i] = pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->Fbr1MemPa[i]); + &rx_ring->fbr1_mem_physaddrs[i]); - if (!rx_ring->Fbr1MemVa[i]) { + if (!rx_ring->fbr1_mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, "Could not alloc memory\n"); return -ENOMEM; } /* See NOTE in "Save Physical Address" comment above */ - fbr1_tmp_physaddr = rx_ring->Fbr1MemPa[i]; + fbr1_tmp_physaddr = rx_ring->fbr1_mem_physaddrs[i]; et131x_align_allocated_memory(adapter, &fbr1_tmp_physaddr, @@ -281,8 +281,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * access later */ rx_ring->fbr[1]->virt[index] = - (u8 *) rx_ring->Fbr1MemVa[i] + - (j * rx_ring->Fbr1BufferSize) + fbr1_offset; + (u8 *) rx_ring->fbr1_mem_virtaddrs[i] + + (j * rx_ring->fbr1_buffsize) + fbr1_offset; /* now store the physical address in the descriptor * so the device can access it @@ -292,7 +292,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) rx_ring->fbr[1]->bus_low[index] = (u32) fbr1_tmp_physaddr; - fbr1_tmp_physaddr += rx_ring->Fbr1BufferSize; + fbr1_tmp_physaddr += rx_ring->fbr1_buffsize; rx_ring->fbr[1]->buffer1[index] = rx_ring->fbr[1]->virt[index]; @@ -303,44 +303,43 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) #ifdef USE_FBR0 /* Same for FBR0 (if in use) */ - for (i = 0; i < (rx_ring->Fbr0NumEntries / FBR_CHUNKS); - i++) { + for (i = 0; i < (rx_ring->fbr0_num_entries / FBR_CHUNKS); i++) { u64 fbr0_offset; u64 fbr0_tmp_physaddr; fbr_chunksize = - ((FBR_CHUNKS + 1) * rx_ring->Fbr0BufferSize) - 1; - rx_ring->Fbr0MemVa[i] = + ((FBR_CHUNKS + 1) * rx_ring->fbr0_buffsize) - 1; + rx_ring->fbr0_mem_virtaddrs[i] = pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->Fbr0MemPa[i]); + &rx_ring->fbr0_mem_physaddrs[i]); - if (!rx_ring->Fbr0MemVa[i]) { + if (!rx_ring->fbr0_mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, "Could not alloc memory\n"); return -ENOMEM; } /* See NOTE in "Save Physical Address" comment above */ - fbr0_tmp_physaddr = rx_ring->Fbr0MemPa[i]; + fbr0_tmp_physaddr = rx_ring->fbr0_mem_physaddrs[i]; et131x_align_allocated_memory(adapter, &fbr0_tmp_physaddr, &fbr0_offset, - rx_ring->Fbr0BufferSize - 1); + rx_ring->fbr0_buffsize - 1); for (j = 0; j < FBR_CHUNKS; j++) { u32 index = (i * FBR_CHUNKS) + j; rx_ring->fbr[0]->virt[index] = - (u8 *) rx_ring->Fbr0MemVa[i] + - (j * rx_ring->Fbr0BufferSize) + fbr0_offset; + (u8 *) rx_ring->fbr0_mem_virtaddrs[i] + + (j * rx_ring->fbr0_buffsize) + fbr0_offset; rx_ring->fbr[0]->bus_high[index] = (u32) (fbr0_tmp_physaddr >> 32); rx_ring->fbr[0]->bus_low[index] = (u32) fbr0_tmp_physaddr; - fbr0_tmp_physaddr += rx_ring->Fbr0BufferSize; + fbr0_tmp_physaddr += rx_ring->fbr0_buffsize; rx_ring->fbr[0]->buffer1[index] = rx_ring->fbr[0]->virt[index]; @@ -352,19 +351,19 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Allocate an area of memory for FIFO of Packet Status ring entries */ pktstat_ringsize = - sizeof(struct pkt_stat_desc) * adapter->rx_ring.PsrNumEntries; + sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries; - rx_ring->pPSRingVa = pci_alloc_consistent(adapter->pdev, + rx_ring->ps_ring_virtaddr = pci_alloc_consistent(adapter->pdev, pktstat_ringsize, - &rx_ring->pPSRingPa); + &rx_ring->ps_ring_physaddr); - if (!rx_ring->pPSRingVa) { + if (!rx_ring->ps_ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Packet Status Ring\n"); return -ENOMEM; } printk(KERN_INFO "Packet Status Ring %lx\n", - (unsigned long) rx_ring->pPSRingPa); + (unsigned long) rx_ring->ps_ring_physaddr); /* * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, @@ -382,7 +381,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) "Cannot alloc memory for Status Block\n"); return -ENOMEM; } - rx_ring->NumRfd = NIC_DEFAULT_NUM_RFD; + rx_ring->num_rfd = NIC_DEFAULT_NUM_RFD; printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); /* Recv @@ -391,7 +390,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * freed to the lookaside list. * RFDs will be allocated from this pool. */ - rx_ring->RecvLookaside = kmem_cache_create(adapter->netdev->name, + rx_ring->recv_lookaside = kmem_cache_create(adapter->netdev->name, sizeof(struct rfd), 0, SLAB_CACHE_DMA | @@ -403,7 +402,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* The RFDs are going to be put on lists later on, so initialize the * lists now. */ - INIT_LIST_HEAD(&rx_ring->RecvList); + INIT_LIST_HEAD(&rx_ring->recv_list); return 0; } @@ -423,100 +422,104 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) rx_ring = &adapter->rx_ring; /* Free RFDs and associated packet descriptors */ - WARN_ON(rx_ring->nReadyRecv != rx_ring->NumRfd); + WARN_ON(rx_ring->num_ready_recv != rx_ring->num_rfd); - while (!list_empty(&rx_ring->RecvList)) { - rfd = (struct rfd *) list_entry(rx_ring->RecvList.next, + while (!list_empty(&rx_ring->recv_list)) { + rfd = (struct rfd *) list_entry(rx_ring->recv_list.next, struct rfd, list_node); list_del(&rfd->list_node); rfd->skb = NULL; - kmem_cache_free(adapter->rx_ring.RecvLookaside, rfd); + kmem_cache_free(adapter->rx_ring.recv_lookaside, rfd); } /* Free Free Buffer Ring 1 */ - if (rx_ring->pFbr1RingVa) { + if (rx_ring->fbr1_ring_virtaddr) { /* First the packet memory */ for (index = 0; index < - (rx_ring->Fbr1NumEntries / FBR_CHUNKS); index++) { - if (rx_ring->Fbr1MemVa[index]) { + (rx_ring->fbr1_num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr1_mem_virtaddrs[index]) { u32 fbr1_align; - if (rx_ring->Fbr1BufferSize > 4096) + if (rx_ring->fbr1_buffsize > 4096) fbr1_align = 4096; else - fbr1_align = rx_ring->Fbr1BufferSize; + fbr1_align = rx_ring->fbr1_buffsize; bufsize = - (rx_ring->Fbr1BufferSize * FBR_CHUNKS) + + (rx_ring->fbr1_buffsize * FBR_CHUNKS) + fbr1_align - 1; pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->Fbr1MemVa[index], - rx_ring->Fbr1MemPa[index]); + bufsize, + rx_ring->fbr1_mem_virtaddrs[index], + rx_ring->fbr1_mem_physaddrs[index]); - rx_ring->Fbr1MemVa[index] = NULL; + rx_ring->fbr1_mem_virtaddrs[index] = NULL; } } /* Now the FIFO itself */ - rx_ring->pFbr1RingVa = (void *)((u8 *) - rx_ring->pFbr1RingVa - rx_ring->Fbr1offset); + rx_ring->fbr1_ring_virtaddr = (void *)((u8 *) + rx_ring->fbr1_ring_virtaddr - rx_ring->fbr1_offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr1NumEntries) + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->pFbr1RingVa, rx_ring->pFbr1RingPa); + rx_ring->fbr1_ring_virtaddr, + rx_ring->fbr1_ring_physaddr); - rx_ring->pFbr1RingVa = NULL; + rx_ring->fbr1_ring_virtaddr = NULL; } #ifdef USE_FBR0 /* Now the same for Free Buffer Ring 0 */ - if (rx_ring->pFbr0RingVa) { + if (rx_ring->fbr0_ring_virtaddr) { /* First the packet memory */ for (index = 0; index < - (rx_ring->Fbr0NumEntries / FBR_CHUNKS); index++) { - if (rx_ring->Fbr0MemVa[index]) { + (rx_ring->fbr0_num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr0_mem_virtaddrs[index]) { bufsize = - (rx_ring->Fbr0BufferSize * + (rx_ring->fbr0_buffsize * (FBR_CHUNKS + 1)) - 1; pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->Fbr0MemVa[index], - rx_ring->Fbr0MemPa[index]); + bufsize, + rx_ring->fbr0_mem_virtaddrs[index], + rx_ring->fbr0_mem_physaddrs[index]); - rx_ring->Fbr0MemVa[index] = NULL; + rx_ring->fbr0_mem_virtaddrs[index] = NULL; } } /* Now the FIFO itself */ - rx_ring->pFbr0RingVa = (void *)((u8 *) - rx_ring->pFbr0RingVa - rx_ring->Fbr0offset); + rx_ring->fbr0_ring_virtaddr = (void *)((u8 *) + rx_ring->fbr0_ring_virtaddr - rx_ring->fbr0_offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr0NumEntries) + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->pFbr0RingVa, rx_ring->pFbr0RingPa); + rx_ring->fbr0_ring_virtaddr, + rx_ring->fbr0_ring_physaddr); - rx_ring->pFbr0RingVa = NULL; + rx_ring->fbr0_ring_virtaddr = NULL; } #endif /* Free Packet Status Ring */ - if (rx_ring->pPSRingVa) { + if (rx_ring->ps_ring_virtaddr) { pktstat_ringsize = - sizeof(struct pkt_stat_desc) * adapter->rx_ring.PsrNumEntries; + sizeof(struct pkt_stat_desc) * + adapter->rx_ring.psr_num_entries; pci_free_consistent(adapter->pdev, pktstat_ringsize, - rx_ring->pPSRingVa, rx_ring->pPSRingPa); + rx_ring->ps_ring_virtaddr, + rx_ring->ps_ring_physaddr); - rx_ring->pPSRingVa = NULL; + rx_ring->ps_ring_virtaddr = NULL; } /* Free area of memory for the writeback of status information */ @@ -533,7 +536,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Destroy the lookaside (RFD) pool */ if (adapter->flags & fMP_ADAPTER_RECV_LOOKASIDE) { - kmem_cache_destroy(rx_ring->RecvLookaside); + kmem_cache_destroy(rx_ring->recv_lookaside); adapter->flags &= ~fMP_ADAPTER_RECV_LOOKASIDE; } @@ -545,7 +548,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) kfree(rx_ring->fbr[1]); /* Reset Counters */ - rx_ring->nReadyRecv = 0; + rx_ring->num_ready_recv = 0; } /** @@ -566,8 +569,8 @@ int et131x_init_recv(struct et131x_adapter *adapter) rx_ring = &adapter->rx_ring; /* Setup each RFD */ - for (rfdct = 0; rfdct < rx_ring->NumRfd; rfdct++) { - rfd = kmem_cache_alloc(rx_ring->RecvLookaside, + for (rfdct = 0; rfdct < rx_ring->num_rfd; rfdct++) { + rfd = kmem_cache_alloc(rx_ring->recv_lookaside, GFP_ATOMIC | GFP_DMA); if (!rfd) { @@ -579,21 +582,21 @@ int et131x_init_recv(struct et131x_adapter *adapter) rfd->skb = NULL; - /* Add this RFD to the RecvList */ - list_add_tail(&rfd->list_node, &rx_ring->RecvList); + /* Add this RFD to the recv_list */ + list_add_tail(&rfd->list_node, &rx_ring->recv_list); /* Increment both the available RFD's, and the total RFD's. */ - rx_ring->nReadyRecv++; + rx_ring->num_ready_recv++; numrfd++; } if (numrfd > NIC_MIN_NUM_RFD) status = 0; - rx_ring->NumRfd = numrfd; + rx_ring->num_rfd = numrfd; if (status != 0) { - kmem_cache_free(rx_ring->RecvLookaside, rfd); + kmem_cache_free(rx_ring->recv_lookaside, rfd); dev_err(&adapter->pdev->dev, "Allocation problems in et131x_init_recv\n"); } @@ -632,10 +635,10 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) /* Set the address and parameters of the packet status ring into the * 1310's registers */ - writel((u32) ((u64)rx_local->pPSRingPa >> 32), + writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32), &rx_dma->psr_base_hi); - writel((u32) rx_local->pPSRingPa, &rx_dma->psr_base_lo); - writel(rx_local->PsrNumEntries - 1, &rx_dma->psr_num_des); + writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo); + writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); writel(0, &rx_dma->psr_full_offset); psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; @@ -648,8 +651,8 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) rx_local->local_psr_full = 0; /* Now's the best time to initialize FBR1 contents */ - fbr_entry = (struct fbr_desc *) rx_local->pFbr1RingVa; - for (entry = 0; entry < rx_local->Fbr1NumEntries; entry++) { + fbr_entry = (struct fbr_desc *) rx_local->fbr1_ring_virtaddr; + for (entry = 0; entry < rx_local->fbr1_num_entries; entry++) { fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; fbr_entry->word2 = entry; @@ -659,39 +662,43 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) /* Set the address and parameters of Free buffer ring 1 (and 0 if * required) into the 1310's registers */ - writel((u32) (rx_local->Fbr1Realpa >> 32), &rx_dma->fbr1_base_hi); - writel((u32) rx_local->Fbr1Realpa, &rx_dma->fbr1_base_lo); - writel(rx_local->Fbr1NumEntries - 1, &rx_dma->fbr1_num_des); + writel((u32) (rx_local->fbr1_real_physaddr >> 32), + &rx_dma->fbr1_base_hi); + writel((u32) rx_local->fbr1_real_physaddr, &rx_dma->fbr1_base_lo); + writel(rx_local->fbr1_num_entries - 1, &rx_dma->fbr1_num_des); writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); /* This variable tracks the free buffer ring 1 full position, so it * has to match the above. */ - rx_local->local_Fbr1_full = ET_DMA10_WRAP; - writel(((rx_local->Fbr1NumEntries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr1_min_des); + rx_local->local_fbr1_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr1_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr1_min_des); #ifdef USE_FBR0 /* Now's the best time to initialize FBR0 contents */ - fbr_entry = (struct fbr_desc *) rx_local->pFbr0RingVa; - for (entry = 0; entry < rx_local->Fbr0NumEntries; entry++) { + fbr_entry = (struct fbr_desc *) rx_local->fbr0_ring_virtaddr; + for (entry = 0; entry < rx_local->fbr0_num_entries; entry++) { fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; fbr_entry->word2 = entry; fbr_entry++; } - writel((u32) (rx_local->Fbr0Realpa >> 32), &rx_dma->fbr0_base_hi); - writel((u32) rx_local->Fbr0Realpa, &rx_dma->fbr0_base_lo); - writel(rx_local->Fbr0NumEntries - 1, &rx_dma->fbr0_num_des); + writel((u32) (rx_local->fbr0_real_physaddr >> 32), + &rx_dma->fbr0_base_hi); + writel((u32) rx_local->fbr0_real_physaddr, &rx_dma->fbr0_base_lo); + writel(rx_local->fbr0_num_entries - 1, &rx_dma->fbr0_num_des); writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); /* This variable tracks the free buffer ring 0 full position, so it * has to match the above. */ - rx_local->local_Fbr0_full = ET_DMA10_WRAP; - writel(((rx_local->Fbr0NumEntries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr0_min_des); + rx_local->local_fbr0_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr0_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr0_min_des); #endif /* Program the number of packets we will receive before generating an @@ -745,15 +752,15 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) */ if ( #ifdef USE_FBR0 - (ring_index == 0 && buff_index < rx_local->Fbr0NumEntries) || + (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || #endif - (ring_index == 1 && buff_index < rx_local->Fbr1NumEntries)) { + (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { spin_lock_irqsave(&etdev->FbrLock, flags); if (ring_index == 1) { struct fbr_desc *next = - (struct fbr_desc *) (rx_local->pFbr1RingVa) + - INDEX10(rx_local->local_Fbr1_full); + (struct fbr_desc *) (rx_local->fbr1_ring_virtaddr) + + INDEX10(rx_local->local_fbr1_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into @@ -763,15 +770,15 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->local_Fbr1_full, - rx_local->Fbr1NumEntries - 1), + writel(bump_free_buff_ring(&rx_local->local_fbr1_full, + rx_local->fbr1_num_entries - 1), &rx_dma->fbr1_full_offset); } #ifdef USE_FBR0 else { struct fbr_desc *next = (struct fbr_desc *) - rx_local->pFbr0RingVa + - INDEX10(rx_local->local_Fbr0_full); + rx_local->fbr0_ring_virtaddr + + INDEX10(rx_local->local_fbr0_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into @@ -781,8 +788,8 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->local_Fbr0_full, - rx_local->Fbr0NumEntries - 1), + writel(bump_free_buff_ring(&rx_local->local_fbr0_full, + rx_local->fbr0_num_entries - 1), &rx_dma->fbr0_full_offset); } #endif @@ -796,11 +803,11 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) * our list */ spin_lock_irqsave(&etdev->rcv_lock, flags); - list_add_tail(&rfd->list_node, &rx_local->RecvList); - rx_local->nReadyRecv++; + list_add_tail(&rfd->list_node, &rx_local->recv_list); + rx_local->num_ready_recv++; spin_unlock_irqrestore(&etdev->rcv_lock, flags); - WARN_ON(rx_local->nReadyRecv > rx_local->NumRfd); + WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); } /** @@ -832,19 +839,19 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) /* Setup the receive dma configuration register for normal operation */ u32 csr = 0x2000; /* FBR1 enable */ - if (etdev->rx_ring.Fbr1BufferSize == 4096) + if (etdev->rx_ring.fbr1_buffsize == 4096) csr |= 0x0800; - else if (etdev->rx_ring.Fbr1BufferSize == 8192) + else if (etdev->rx_ring.fbr1_buffsize == 8192) csr |= 0x1000; - else if (etdev->rx_ring.Fbr1BufferSize == 16384) + else if (etdev->rx_ring.fbr1_buffsize == 16384) csr |= 0x1800; #ifdef USE_FBR0 csr |= 0x0400; /* FBR0 enable */ - if (etdev->rx_ring.Fbr0BufferSize == 256) + if (etdev->rx_ring.fbr0_buffsize == 256) csr |= 0x0100; - else if (etdev->rx_ring.Fbr0BufferSize == 512) + else if (etdev->rx_ring.fbr0_buffsize == 512) csr |= 0x0200; - else if (etdev->rx_ring.Fbr0BufferSize == 1024) + else if (etdev->rx_ring.fbr0_buffsize == 1024) csr |= 0x0300; #endif writel(csr, &etdev->regs->rxdma.csr); @@ -868,7 +875,7 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) * Returns rfd, a pointer to our MPRFD. * * Checks the hardware for available packets, using completion ring - * If packets are available, it gets an RFD from the RecvList, attaches + * If packets are available, it gets an RFD from the recv_list, attaches * the packet to it, puts the RFD in the RecvPendList, and also returns * the pointer to the RFD. */ @@ -893,7 +900,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * Status Ring, and also the two Free Buffer rings. */ status = rx_local->rx_status_block; - word1 = status->Word1 >> 16; /* Get the useful bits */ + word1 = status->word1 >> 16; /* Get the useful bits */ /* Check the PSR and wrap bits do not match */ if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF)) @@ -901,7 +908,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) return NULL; /* The packet status ring indicates that data is available. */ - psr = (struct pkt_stat_desc *) (rx_local->pPSRingVa) + + psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) + (rx_local->local_psr_full & 0xFFF); /* Grab any information that is required once the PSR is @@ -916,7 +923,8 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) /* Indicate that we have used this PSR entry. */ /* FIXME wrap 12 */ add_12bit(&rx_local->local_psr_full, 1); - if ((rx_local->local_psr_full & 0xFFF) > rx_local->PsrNumEntries - 1) { + if ( + (rx_local->local_psr_full & 0xFFF) > rx_local->psr_num_entries - 1) { /* Clear psr full and toggle the wrap bit */ rx_local->local_psr_full &= ~0xFFF; rx_local->local_psr_full ^= 0x1000; @@ -933,11 +941,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) #ifdef USE_FBR0 if (ring_index > 1 || (ring_index == 0 && - buff_index > rx_local->Fbr0NumEntries - 1) || + buff_index > rx_local->fbr0_num_entries - 1) || (ring_index == 1 && - buff_index > rx_local->Fbr1NumEntries - 1)) + buff_index > rx_local->fbr1_num_entries - 1)) #else - if (ring_index != 1 || buff_index > rx_local->Fbr1NumEntries - 1) + if (ring_index != 1 || buff_index > rx_local->fbr1_num_entries - 1) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ @@ -953,7 +961,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) spin_lock_irqsave(&etdev->rcv_lock, flags); rfd = NULL; - element = rx_local->RecvList.next; + element = rx_local->recv_list.next; rfd = (struct rfd *) list_entry(element, struct rfd, list_node); if (rfd == NULL) { @@ -962,7 +970,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) } list_del(&rfd->list_node); - rx_local->nReadyRecv--; + rx_local->num_ready_recv--; spin_unlock_irqrestore(&etdev->rcv_lock, flags); @@ -1087,7 +1095,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) */ void et131x_reset_recv(struct et131x_adapter *etdev) { - WARN_ON(list_empty(&etdev->rx_ring.RecvList)); + WARN_ON(list_empty(&etdev->rx_ring.recv_list)); } /** @@ -1104,8 +1112,8 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) /* Process up to available RFD's */ while (count < NUM_PACKETS_HANDLED) { - if (list_empty(&etdev->rx_ring.RecvList)) { - WARN_ON(etdev->rx_ring.nReadyRecv != 0); + if (list_empty(&etdev->rx_ring.recv_list)) { + WARN_ON(etdev->rx_ring.num_ready_recv != 0); done = false; break; } @@ -1129,7 +1137,7 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) etdev->net_stats.rx_packets++; /* Set the status on the packet, either resources or success */ - if (etdev->rx_ring.nReadyRecv < RFD_LOW_WATER_MARK) { + if (etdev->rx_ring.num_ready_recv < RFD_LOW_WATER_MARK) { dev_warn(&etdev->pdev->dev, "RFD's are running out\n"); } @@ -1137,11 +1145,11 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) } if (count == NUM_PACKETS_HANDLED || !done) { - etdev->rx_ring.UnfinishedReceives = true; + etdev->rx_ring.unfinished_receives = true; writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, &etdev->regs->global.watchdog_timer); } else /* Watchdog timer will disable itself if appropriate. */ - etdev->rx_ring.UnfinishedReceives = false; + etdev->rx_ring.unfinished_receives = false; } diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h index e8c653d37a7..1448aa90996 100644 --- a/drivers/staging/et131x/et1310_rx.h +++ b/drivers/staging/et131x/et1310_rx.h @@ -174,8 +174,8 @@ struct pkt_stat_desc { * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020 */ struct rx_status_block { - u32 Word0; - u32 Word1; + u32 word0; + u32 word1; }; /* @@ -190,54 +190,54 @@ struct fbr_lookup { }; /* - * struct rx_ring is the ssructure representing the adaptor's local + * struct rx_ring is the sructure representing the adaptor's local * reference(s) to the rings */ struct rx_ring { #ifdef USE_FBR0 - void *pFbr0RingVa; - dma_addr_t pFbr0RingPa; - void *Fbr0MemVa[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t Fbr0MemPa[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t Fbr0Realpa; - uint64_t Fbr0offset; - u32 local_Fbr0_full; - u32 Fbr0NumEntries; - u32 Fbr0BufferSize; + void *fbr0_ring_virtaddr; + dma_addr_t fbr0_ring_physaddr; + void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + uint64_t fbr0_real_physaddr; + uint64_t fbr0_offset; + u32 local_fbr0_full; + u32 fbr0_num_entries; + u32 fbr0_buffsize; #endif - void *pFbr1RingVa; - dma_addr_t pFbr1RingPa; - void *Fbr1MemVa[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t Fbr1MemPa[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t Fbr1Realpa; - uint64_t Fbr1offset; + void *fbr1_ring_virtaddr; + dma_addr_t fbr1_ring_physaddr; + void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + uint64_t fbr1_real_physaddr; + uint64_t fbr1_offset; struct fbr_lookup *fbr[2]; /* One per ring */ - u32 local_Fbr1_full; - u32 Fbr1NumEntries; - u32 Fbr1BufferSize; + u32 local_fbr1_full; + u32 fbr1_num_entries; + u32 fbr1_buffsize; - void *pPSRingVa; - dma_addr_t pPSRingPa; + void *ps_ring_virtaddr; + dma_addr_t ps_ring_physaddr; u32 local_psr_full; - u32 PsrNumEntries; + u32 psr_num_entries; struct rx_status_block *rx_status_block; dma_addr_t rx_status_bus; - struct list_head RecvBufferPool; + struct list_head recv_buff_pool; /* RECV */ - struct list_head RecvList; - u32 nReadyRecv; + struct list_head recv_list; + u32 num_ready_recv; - u32 NumRfd; + u32 num_rfd; - bool UnfinishedReceives; + bool unfinished_receives; - struct list_head RecvPacketPool; + struct list_head recv_packet_pool; /* lookaside lists */ - struct kmem_cache *RecvLookaside; + struct kmem_cache *recv_lookaside; }; #endif /* __ET1310_RX_H__ */ diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index dd952f07e5e..33d432fe7ce 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -200,7 +200,7 @@ irqreturn_t et131x_isr(int irq, void *dev_id) if (++tcb->stale > 1) status |= ET_INTR_TXDMA_ISR; - if (adapter->rx_ring.UnfinishedReceives) + if (adapter->rx_ring.unfinished_receives) status |= ET_INTR_RXDMA_XFR_DONE; else if (tcb == NULL) writel(0, &adapter->regs->global.watchdog_timer); From e6cbda294ad1be1db08c747dfa1a5a9cb6f8c41a Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 10 Jul 2011 16:35:33 +0100 Subject: [PATCH 0007/1519] staging: et131x: add et1310_ prefix to et1310_mac.c functions Making finger pointing that bit easier. Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 32 ++++++++++++------------- drivers/staging/et131x/et1310_phy.c | 4 ++-- drivers/staging/et131x/et131x.h | 20 ++++++++-------- drivers/staging/et131x/et131x_initpci.c | 10 ++++---- drivers/staging/et131x/et131x_isr.c | 2 +- drivers/staging/et131x/et131x_netdev.c | 4 ++-- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 21b615381bd..8d8bc8bbabf 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -99,10 +99,10 @@ #define COUNTER_MASK_12_BIT (COUNTER_WRAP_12_BIT - 1) /** - * config_mac_regs1 - Initialize the first part of MAC regs + * et1310_config_mac_regs1 - Initialize the first part of MAC regs * @etdev: pointer to our adapter structure */ -void config_mac_regs1(struct et131x_adapter *etdev) +void et1310_config_mac_regs1(struct et131x_adapter *etdev) { struct mac_regs __iomem *macregs = &etdev->regs->mac; u32 station1; @@ -159,10 +159,10 @@ void config_mac_regs1(struct et131x_adapter *etdev) } /** - * config_mac_regs2 - Initialize the second part of MAC regs + * et1310_config_mac_regs2 - Initialize the second part of MAC regs * @etdev: pointer to our adapter structure */ -void config_mac_regs2(struct et131x_adapter *etdev) +void et1310_config_mac_regs2(struct et131x_adapter *etdev) { int32_t delay = 0; struct mac_regs __iomem *mac = &etdev->regs->mac; @@ -235,7 +235,7 @@ void config_mac_regs2(struct et131x_adapter *etdev) } } -void config_rxmac_regs(struct et131x_adapter *etdev) +void et1310_config_rxmac_regs(struct et131x_adapter *etdev) { struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; u32 sa_lo; @@ -295,7 +295,7 @@ void config_rxmac_regs(struct et131x_adapter *etdev) /* Let's initialize the Unicast Packet filtering address */ if (etdev->PacketFilter & ET131X_PACKET_TYPE_DIRECTED) { - setup_device_for_unicast(etdev); + et1310_setup_device_for_unicast(etdev); pf_ctrl |= 4; /* Unicast filter */ } else { writel(0, &rxmac->uni_pf_addr1); @@ -306,7 +306,7 @@ void config_rxmac_regs(struct et131x_adapter *etdev) /* Let's initialize the Multicast hash */ if (!(etdev->PacketFilter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { pf_ctrl |= 2; /* Multicast filter */ - setup_device_for_multicast(etdev); + et1310_setup_device_for_multicast(etdev); } /* Runt packet filtering. Didn't work in version A silicon. */ @@ -365,7 +365,7 @@ void config_rxmac_regs(struct et131x_adapter *etdev) writel(0x9, &rxmac->ctrl); } -void config_txmac_regs(struct et131x_adapter *etdev) +void et1310_config_txmac_regs(struct et131x_adapter *etdev) { struct txmac_regs *txmac = &etdev->regs->txmac; @@ -379,7 +379,7 @@ void config_txmac_regs(struct et131x_adapter *etdev) writel(0x40, &txmac->cf_param); } -void config_macstat_regs(struct et131x_adapter *etdev) +void et1310_config_macstat_regs(struct et131x_adapter *etdev) { struct macstat_regs __iomem *macstat = &etdev->regs->macstat; @@ -444,7 +444,7 @@ void config_macstat_regs(struct et131x_adapter *etdev) writel(0xFFFE7E8B, &macstat->carry_reg2_mask); } -void config_flow_control(struct et131x_adapter *etdev) +void et1310_config_flow_control(struct et131x_adapter *etdev) { if (etdev->duplex_mode == 0) { etdev->flowcontrol = FLOW_NONE; @@ -480,10 +480,10 @@ void config_flow_control(struct et131x_adapter *etdev) } /** - * update_macstat_host_counters - Update the local copy of the statistics + * et1310_update_macstat_host_counters - Update the local copy of the statistics * @etdev: pointer to the adapter structure */ -void update_macstat_host_counters(struct et131x_adapter *etdev) +void et1310_update_macstat_host_counters(struct et131x_adapter *etdev) { struct ce_stats *stats = &etdev->stats; struct macstat_regs __iomem *macstat = @@ -508,14 +508,14 @@ void update_macstat_host_counters(struct et131x_adapter *etdev) } /** - * handle_macstat_interrupt + * et1310_handle_macstat_interrupt * @etdev: pointer to the adapter structure * * One of the MACSTAT counters has wrapped. Update the local copy of * the statistics held in the adapter structure, checking the "wrap" * bit for each counter. */ -void handle_macstat_interrupt(struct et131x_adapter *etdev) +void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) { u32 carry_reg1; u32 carry_reg2; @@ -565,7 +565,7 @@ void handle_macstat_interrupt(struct et131x_adapter *etdev) etdev->stats.collisions += COUNTER_WRAP_12_BIT; } -void setup_device_for_multicast(struct et131x_adapter *etdev) +void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) { struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; uint32_t nIndex; @@ -613,7 +613,7 @@ void setup_device_for_multicast(struct et131x_adapter *etdev) } } -void setup_device_for_unicast(struct et131x_adapter *etdev) +void et1310_setup_device_for_unicast(struct et131x_adapter *etdev) { struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; u32 uni_pf1; diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index d3d3b463742..2385d04e748 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -846,7 +846,7 @@ void et131x_mii_check(struct et131x_adapter *etdev, et131x_mii_write(etdev, 0x12, register18); } - config_flow_control(etdev); + et1310_config_flow_control(etdev); if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && etdev->RegistryJumboPacket > 2048) @@ -854,7 +854,7 @@ void et131x_mii_check(struct et131x_adapter *etdev, 0x2000); et131x_set_rx_dma_timer(etdev); - config_mac_regs2(etdev); + et1310_config_mac_regs2(etdev); } } } diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index c33594ba744..b201136e502 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -71,16 +71,16 @@ irqreturn_t et131x_isr(int irq, void *dev_id); void et131x_isr_handler(struct work_struct *work); /* et1310_mac.c */ -void config_mac_regs1(struct et131x_adapter *adapter); -void config_mac_regs2(struct et131x_adapter *adapter); -void config_rxmac_regs(struct et131x_adapter *adapter); -void config_txmac_regs(struct et131x_adapter *adapter); -void config_macstat_regs(struct et131x_adapter *adapter); -void config_flow_control(struct et131x_adapter *adapter); -void update_macstat_host_counters(struct et131x_adapter *adapter); -void handle_macstat_interrupt(struct et131x_adapter *adapter); -void setup_device_for_multicast(struct et131x_adapter *adapter); -void setup_device_for_unicast(struct et131x_adapter *adapter); +void et1310_config_mac_regs1(struct et131x_adapter *adapter); +void et1310_config_mac_regs2(struct et131x_adapter *adapter); +void et1310_config_rxmac_regs(struct et131x_adapter *adapter); +void et1310_config_txmac_regs(struct et131x_adapter *adapter); +void et1310_config_macstat_regs(struct et131x_adapter *adapter); +void et1310_config_flow_control(struct et131x_adapter *adapter); +void et1310_update_macstat_host_counters(struct et131x_adapter *adapter); +void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter); +void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); +void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ struct net_device *et131x_device_alloc(void); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 75b2c485112..a8700b6de29 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -269,7 +269,7 @@ void et131x_error_timer_handler(unsigned long data) pm_csr = readl(&etdev->regs->global.pm_csr); if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) - update_macstat_host_counters(etdev); + et1310_update_macstat_host_counters(etdev); else dev_err(&etdev->pdev->dev, "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); @@ -380,19 +380,19 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) /* Configure the JAGCore */ ConfigGlobalRegs(etdev); - config_mac_regs1(etdev); + et1310_config_mac_regs1(etdev); /* Configure the MMC registers */ /* All we need to do is initialize the Memory Control Register */ writel(ET_MMC_ENABLE, &etdev->regs->mmc.mmc_ctrl); - config_rxmac_regs(etdev); - config_txmac_regs(etdev); + et1310_config_rxmac_regs(etdev); + et1310_config_txmac_regs(etdev); et131x_config_rx_dma_regs(etdev); ConfigTxDmaRegs(etdev); - config_macstat_regs(etdev); + et1310_config_macstat_regs(etdev); /* Move the following code to Timer function?? */ status = et131x_xcvr_find(etdev); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 33d432fe7ce..9b316bed074 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -461,7 +461,7 @@ void et131x_isr_handler(struct work_struct *work) * to maintain the top, software managed bits of the * counter(s). */ - handle_macstat_interrupt(etdev); + et1310_handle_macstat_interrupt(etdev); } /* Handle SLV Timeout Interrupt */ diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 0f12b584c44..546acb35b01 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -301,14 +301,14 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter) if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) pf_ctrl &= ~2; /* Multicast filter bit */ else { - setup_device_for_multicast(adapter); + et1310_setup_device_for_multicast(adapter); pf_ctrl |= 2; ctrl &= ~0x04; } /* Set us up with Unicast packet filtering */ if (filter & ET131X_PACKET_TYPE_DIRECTED) { - setup_device_for_unicast(adapter); + et1310_setup_device_for_unicast(adapter); pf_ctrl |= 4; ctrl &= ~0x04; } From fc78050f67fb662395180296ac7132dab256245e Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 18 Jul 2011 23:38:45 +0100 Subject: [PATCH 0008/1519] staging: et131x: Convert et1310_tx.c function name from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.h | 3 +-- drivers/staging/et131x/et131x_initpci.c | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index b201136e502..050eb773f50 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -52,8 +52,7 @@ int et131x_init_eeprom(struct et131x_adapter *etdev); /* et131x_initpci.c */ -void ConfigGlobalRegs(struct et131x_adapter *pAdapter); -void ConfigMMCRegs(struct et131x_adapter *pAdapter); +void et131x_config_global_regs(struct et131x_adapter *pAdapter); void et131x_enable_interrupts(struct et131x_adapter *adapter); void et131x_disable_interrupts(struct et131x_adapter *adapter); void et131x_align_allocated_memory(struct et131x_adapter *adapter, diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index a8700b6de29..09285b92d09 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -325,7 +325,7 @@ void et131x_link_detection_handler(unsigned long data) * * Used to configure the global registers on the JAGCore */ -void ConfigGlobalRegs(struct et131x_adapter *etdev) +void et131x_configure_global_regs(struct et131x_adapter *etdev) { struct global_regs __iomem *regs = &etdev->regs->global; @@ -366,7 +366,6 @@ void ConfigGlobalRegs(struct et131x_adapter *etdev) writel(0, ®s->watchdog_timer); } - /** * et131x_adapter_setup - Set the adapter up as per cassini+ documentation * @etdev: pointer to our private adapter structure @@ -378,7 +377,7 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) int status = 0; /* Configure the JAGCore */ - ConfigGlobalRegs(etdev); + et131x_configure_global_regs(etdev); et1310_config_mac_regs1(etdev); @@ -517,8 +516,6 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) et131x_rx_dma_memory_free(adapter); } - - /** * et131x_adapter_init * @etdev: pointer to the private adapter struct @@ -527,8 +524,6 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) * Initialize the data structures for the et131x_adapter object and link * them together with the platform provided device structures. */ - - static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, struct pci_dev *pdev) { @@ -602,7 +597,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, * contained in the pci_device_id table. This routine is the equivalent to * a device insertion routine. */ - static int __devinit et131x_pci_setup(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -774,7 +768,6 @@ err_disable: * PCI subsystem detects that a PCI device which matches the information * contained in the pci_device_id table has been removed. */ - static void __devexit et131x_pci_remove(struct pci_dev *pdev) { struct net_device *netdev; @@ -815,7 +808,6 @@ static struct pci_driver et131x_driver = { .resume = NULL, /* et131x_pci_resume */ }; - /** * et131x_init_module - The "main" entry point called on driver initialization * From 6a342657982209a8982981f8d38366adac2b9f15 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 18 Jul 2011 23:38:47 +0100 Subject: [PATCH 0009/1519] staging: et131x: Fix variable typo carry_reg1 -> carry_reg2 This mistake was introduced in the patch 'staging: et131x: Convert et1310_address_map.h names from camel case' Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 8d8bc8bbabf..d1847c1614b 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -526,7 +526,7 @@ void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) carry_reg1 = readl(&etdev->regs->macstat.carry_reg1); carry_reg2 = readl(&etdev->regs->macstat.carry_reg2); - writel(carry_reg2, &etdev->regs->macstat.carry_reg1); + writel(carry_reg1, &etdev->regs->macstat.carry_reg1); writel(carry_reg2, &etdev->regs->macstat.carry_reg2); /* We need to do update the host copy of all the MAC_STAT counters. From 3e8543618757ef2cb31a677a131027261a9b7251 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 2 Aug 2011 20:17:49 +0100 Subject: [PATCH 0010/1519] staging: et131x: Remove redundant commented out code Removed commented out calls that no longer exist in the net_device struct. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_netdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 546acb35b01..6eef4be69e2 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -671,8 +671,7 @@ struct net_device *et131x_device_alloc(void) /* Setup the function registration table (and other data) for a * net_device */ - /* netdev->init = &et131x_init; */ - /* netdev->set_config = &et131x_config; */ + netdev->watchdog_timeo = ET131X_TX_TIMEOUT; netdev->netdev_ops = &et131x_netdev_ops; From 5cf51e8aadfc81b9cec827565a6eaa4a0ad8dd5b Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 2 Aug 2011 20:17:50 +0100 Subject: [PATCH 0011/1519] staging: et131x: Rename et131x_config_global_regs > et131x_configure_global_regs Typo in header file. Also renaming a few adapter references to fit in with the rest of the file. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 050eb773f50..fa42d94d408 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -49,10 +49,10 @@ */ /* et131x_eeprom.c */ -int et131x_init_eeprom(struct et131x_adapter *etdev); +int et131x_init_eeprom(struct et131x_adapter *adapter); /* et131x_initpci.c */ -void et131x_config_global_regs(struct et131x_adapter *pAdapter); +void et131x_configure_global_regs(struct et131x_adapter *adapter); void et131x_enable_interrupts(struct et131x_adapter *adapter); void et131x_disable_interrupts(struct et131x_adapter *adapter); void et131x_align_allocated_memory(struct et131x_adapter *adapter, From f5283a4bb8f5ef274e9de58c751edb2a2d66bef4 Mon Sep 17 00:00:00 2001 From: Mark Pearson Date: Sun, 10 Jul 2011 21:16:38 +0200 Subject: [PATCH 0012/1519] Staging: comedi: Fixed coding style issues. comedi_fops.c : A forward decleration was declared as extern although it is a function private to this file. Changed the decleration to static. Signed-off-by: Mark Pearson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index e90e3cceb5f..21d8c1c16cd 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -101,7 +101,7 @@ static int do_insn_ioctl(struct comedi_device *dev, static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd, void *file); -extern void do_become_nonbusy(struct comedi_device *dev, +static void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s); static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s); From 654e8fb522b3c8af3c5b35d6f474e51218ef8f9a Mon Sep 17 00:00:00 2001 From: Mariano Guerra Date: Sat, 16 Jul 2011 02:11:23 +0100 Subject: [PATCH 0013/1519] Staging: comedi: do not initialise statics to 0 or NULL This is a patch to adv_pci_dio.c that fixes an error initializing static struct pci_dio_private *pci_priv to NULL removed the initialization. found by the checkpatch.pl tool. Signed-off-by: Mariano Guerra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index d23799be7ce..69334f6f64e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -422,7 +422,7 @@ struct pci_dio_private { unsigned short IDIFiltrHigh[8]; /* IDI's filter value high signal */ }; -static struct pci_dio_private *pci_priv = NULL; /* list of allocated cards */ +static struct pci_dio_private *pci_priv; /* list of allocated cards */ #define devpriv ((struct pci_dio_private *)dev->private) #define this_board ((const struct dio_boardtype *)dev->board_ptr) From 13a9e03c0c209b59f07b72c5388845a5f55eda2a Mon Sep 17 00:00:00 2001 From: Bojan Prtvar Date: Tue, 19 Jul 2011 20:19:39 +0200 Subject: [PATCH 0014/1519] Staging: comedi: fix initialization of static to 0 in ni_pcidio.c This patch removes initialization of static to 0 or NULL error found by checkpatch.pl tool Signed-off-by: Bojan Prtvar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 8dd3a01d48d..045a4c00f34 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -688,7 +688,7 @@ static void ni_pcidio_print_status(unsigned int flags) static void debug_int(struct comedi_device *dev) { int a, b; - static int n_int = 0; + static int n_int; struct timeval tv; do_gettimeofday(&tv); From d6aa8366dde1656f859b6ebf5face1718793a467 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 8 Aug 2011 16:32:12 -0700 Subject: [PATCH 0015/1519] staging: fix comedi build errors Fix build errors when CONFIG_COMEDI_PCI_DRIVERS is not enabled and CONFIG_COMEDI_PCI_DRIVERS was used where CONFIG_ISA_DMA_API should have been used. drivers/staging/comedi/drivers/ni_labpc.c: In function 'labpc_ai_cmd': drivers/staging/comedi/drivers/ni_labpc.c:1351: error: implicit declaration of function 'labpc_suggest_transfer_size' drivers/staging/comedi/drivers/ni_labpc.c: At top level: drivers/staging/comedi/drivers/ni_labpc.c:1802: error: conflicting types for 'labpc_suggest_transfer_size' drivers/staging/comedi/drivers/ni_labpc.c:1351: note: previous implicit declaration of 'labpc_suggest_transfer_size' was here Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 6859af0778c..721b2be2250 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -241,8 +241,10 @@ static int labpc_eeprom_write_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data); static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd); -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_ISA_DMA_API static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd); +#endif +#ifdef CONFIG_COMEDI_PCI_DRIVERS static int labpc_find_device(struct comedi_device *dev, int bus, int slot); #endif static int labpc_dio_mem_callback(int dir, int port, int data, @@ -459,7 +461,7 @@ static const struct labpc_board_struct labpc_boards[] = { .ai_scan_up = 0, .memory_mapped_io = 0, }, -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS { .name = "pci-1200", .device_id = 0x161, @@ -503,14 +505,14 @@ static struct comedi_driver driver_labpc = { .offset = sizeof(struct labpc_board_struct), }; -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = { {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x161)}, {0} }; MODULE_DEVICE_TABLE(pci, labpc_pci_table); -#endif /* CONFIG_COMEDI_PCI */ +#endif /* CONFIG_COMEDI_PCI_DRIVERS */ static inline int labpc_counter_load(struct comedi_device *dev, unsigned long base_address, @@ -720,7 +722,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) unsigned long iobase = 0; unsigned int irq = 0; unsigned int dma_chan = 0; -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS int retval; #endif @@ -742,7 +744,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) #endif break; case pci_bustype: -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS retval = labpc_find_device(dev, it->options[0], it->options[1]); if (retval < 0) return retval; @@ -772,7 +774,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* adapted from ni_pcimio for finding mite based boards (pc-1200) */ -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS static int labpc_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; @@ -820,7 +822,7 @@ int labpc_common_detach(struct comedi_device *dev) free_irq(dev->irq, dev); if (thisboard->bustype == isa_bustype && dev->iobase) release_region(dev->iobase, LABPC_SIZE); -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS if (devpriv->mite) mite_unsetup(devpriv->mite); #endif @@ -2135,7 +2137,7 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); } -#ifdef CONFIG_COMEDI_PCI +#ifdef CONFIG_COMEDI_PCI_DRIVERS static int __devinit driver_labpc_pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { From dd89e20d7e9d507b3122de2f79661b5fc2c2198e Mon Sep 17 00:00:00 2001 From: Bernd Porr Date: Sat, 30 Jul 2011 11:15:02 +0100 Subject: [PATCH 0016/1519] staging: comedi: new driver usbduxsigma This adds a new driver file usbduxsigma which is the driver for a new board by ITL. The driver has been tested and is working fine. Signed-off-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 18 +- drivers/staging/comedi/drivers/Makefile | 1 + drivers/staging/comedi/drivers/usbduxsigma.c | 2880 ++++++++++++++++++ 3 files changed, 2894 insertions(+), 5 deletions(-) create mode 100644 drivers/staging/comedi/drivers/usbduxsigma.c diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 5e65dde5845..4c77e508066 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1244,11 +1244,10 @@ config COMEDI_DT9812 called dt9812. config COMEDI_USBDUX - tristate "ITL USBDUX support" + tristate "ITL USB-DUX-D support" default N ---help--- - Enable support for the University of Stirling USB DAQ and INCITE - Technology Limited driver + Enable support for the Incite Technology Ltd USB-DUX-D Board To compile this driver as a module, choose M here: the module will be called usbdux. @@ -1258,12 +1257,21 @@ config COMEDI_USBDUXFAST select COMEDI_FC default N ---help--- - Enable support for the University of Stirling USB-DUXfast and INCITE - Technology Limited driver + Enable support for the Incite Technology Ltd USB-DUXfast Board To compile this driver as a module, choose M here: the module will be called usbduxfast. +config COMEDI_USBDUXSIGMA + tristate "ITL USB-DUXsigma support" + select COMEDI_FC + default N + ---help--- + Enable support for the Incite Technology Ltd USB-DUXsigma Board + + To compile this driver as a module, choose M here: the module will be + called usbduxsigma. + config COMEDI_VMK80XX tristate "Velleman VM110/VM140 USB Board support" default N diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 33bf1f5aad4..170da609195 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -126,6 +126,7 @@ obj-$(CONFIG_COMEDI_QUATECH_DAQP_CS) += quatech_daqp_cs.o obj-$(CONFIG_COMEDI_DT9812) += dt9812.o obj-$(CONFIG_COMEDI_USBDUX) += usbdux.o obj-$(CONFIG_COMEDI_USBDUXFAST) += usbduxfast.o +obj-$(CONFIG_COMEDI_USBDUXSIGMA) += usbduxsigma.o obj-$(CONFIG_COMEDI_VMK80XX) += vmk80xx.o # Comedi NI drivers diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c new file mode 100644 index 00000000000..a8fea9a9173 --- /dev/null +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -0,0 +1,2880 @@ +#define DRIVER_VERSION "v0.5" +#define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com" +#define DRIVER_DESC "Stirling/ITL USB-DUX SIGMA -- Bernd.Porr@f2s.com" +/* + comedi/drivers/usbdux.c + Copyright (C) 2011 Bernd Porr, Bernd.Porr@f2s.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + */ +/* +Driver: usbduxsigma +Description: University of Stirling USB DAQ & INCITE Technology Limited +Devices: [ITL] USB-DUX (usbduxsigma.o) +Author: Bernd Porr +Updated: 21 Jul 2011 +Status: testing +*/ +/* + * I must give credit here to Chris Baugher who + * wrote the driver for AT-MIO-16d. I used some parts of this + * driver. I also must give credits to David Brownell + * who supported me with the USB development. + * + * Note: the raw data from the A/D converter is 24 bit big endian + * anything else is little endian to/from the dux board + * + * + * Revision history: + * 0.1: inital version + * 0.2: all basic functions implemented, digital I/O only for one port + * 0.3: proper vendor ID and driver name + * 0.4: fixed D/A voltage range + * 0.5: various bug fixes, health check at startup + */ + +/* generates loads of debug info */ +/* #define NOISY_DUX_DEBUGBUG */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "comedi_fc.h" +#include "../comedidev.h" + +#define BOARDNAME "usbduxsigma" + +/* timeout for the USB-transfer in ms*/ +#define BULK_TIMEOUT 1000 + +/* constants for "firmware" upload and download */ +#define USBDUXSUB_FIRMWARE 0xA0 +#define VENDOR_DIR_IN 0xC0 +#define VENDOR_DIR_OUT 0x40 + +/* internal addresses of the 8051 processor */ +#define USBDUXSUB_CPUCS 0xE600 + +/* + * the minor device number, major is 180 only for debugging purposes and to + * upload special firmware (programming the eeprom etc) which is not + * compatible with the comedi framwork + */ +#define USBDUXSUB_MINOR 32 + +/* max lenghth of the transfer-buffer for software upload */ +#define TB_LEN 0x2000 + +/* Input endpoint number: ISO/IRQ */ +#define ISOINEP 6 + +/* Output endpoint number: ISO/IRQ */ +#define ISOOUTEP 2 + +/* This EP sends DUX commands to USBDUX */ +#define COMMAND_OUT_EP 1 + +/* This EP receives the DUX commands from USBDUX */ +#define COMMAND_IN_EP 8 + +/* Output endpoint for PWM */ +#define PWM_EP 4 + +/* 300Hz max frequ under PWM */ +#define MIN_PWM_PERIOD ((long)(1E9/300)) + +/* Default PWM frequency */ +#define PWM_DEFAULT_PERIOD ((long)(1E9/100)) + +/* Number of channels (16 AD and offset)*/ +#define NUMCHANNELS 16 + +/* Size of one A/D value */ +#define SIZEADIN ((sizeof(int32_t))) + +/* + * Size of the async input-buffer IN BYTES, the DIO state is transmitted + * as the first byte. + */ +#define SIZEINBUF (((NUMCHANNELS+1)*SIZEADIN)) + +/* 16 bytes. */ +#define SIZEINSNBUF 16 + +/* Number of DA channels */ +#define NUMOUTCHANNELS 8 + +/* size of one value for the D/A converter: channel and value */ +#define SIZEDAOUT ((sizeof(uint8_t)+sizeof(int16_t))) + +/* + * Size of the output-buffer in bytes + * Actually only the first 4 triplets are used but for the + * high speed mode we need to pad it to 8 (microframes). + */ +#define SIZEOUTBUF ((8*SIZEDAOUT)) + +/* + * Size of the buffer for the dux commands: just now max size is determined + * by the analogue out + command byte + panic bytes... + */ +#define SIZEOFDUXBUFFER ((8*SIZEDAOUT+2)) + +/* Number of in-URBs which receive the data: min=2 */ +#define NUMOFINBUFFERSFULL 5 + +/* Number of out-URBs which send the data: min=2 */ +#define NUMOFOUTBUFFERSFULL 5 + +/* Number of in-URBs which receive the data: min=5 */ +/* must have more buffers due to buggy USB ctr */ +#define NUMOFINBUFFERSHIGH 10 + +/* Number of out-URBs which send the data: min=5 */ +/* must have more buffers due to buggy USB ctr */ +#define NUMOFOUTBUFFERSHIGH 10 + +/* Total number of usbdux devices */ +#define NUMUSBDUX 16 + +/* Analogue in subdevice */ +#define SUBDEV_AD 0 + +/* Analogue out subdevice */ +#define SUBDEV_DA 1 + +/* Digital I/O */ +#define SUBDEV_DIO 2 + +/* timer aka pwm output */ +#define SUBDEV_PWM 3 + +/* number of retries to get the right dux command */ +#define RETRIES 10 + +/**************************************************/ +/* comedi constants */ +static const struct comedi_lrange range_usbdux_ai_range = { 1, { + BIP_RANGE + (2.65) + } +}; + +static const struct comedi_lrange range_usbdux_ao_range = { 1, { + UNI_RANGE + (2.5), + } +}; + +/* + * private structure of one subdevice + */ + +/* + * This is the structure which holds all the data of + * this driver one sub device just now: A/D + */ +struct usbduxsub { + /* attached? */ + int attached; + /* is it associated with a subdevice? */ + int probed; + /* pointer to the usb-device */ + struct usb_device *usbdev; + /* actual number of in-buffers */ + int numOfInBuffers; + /* actual number of out-buffers */ + int numOfOutBuffers; + /* ISO-transfer handling: buffers */ + struct urb **urbIn; + struct urb **urbOut; + /* pwm-transfer handling */ + struct urb *urbPwm; + /* PWM period */ + unsigned int pwmPeriod; + /* PWM internal delay for the GPIF in the FX2 */ + uint8_t pwmDelay; + /* size of the PWM buffer which holds the bit pattern */ + int sizePwmBuf; + /* input buffer for the ISO-transfer */ + int32_t *inBuffer; + /* input buffer for single insn */ + int8_t *insnBuffer; + /* output buffer for single DA outputs */ + int16_t *outBuffer; + /* interface number */ + int ifnum; + /* interface structure in 2.6 */ + struct usb_interface *interface; + /* comedi device for the interrupt context */ + struct comedi_device *comedidev; + /* is it USB_SPEED_HIGH or not? */ + short int high_speed; + /* asynchronous command is running */ + short int ai_cmd_running; + short int ao_cmd_running; + /* pwm is running */ + short int pwm_cmd_running; + /* continous aquisition */ + short int ai_continous; + short int ao_continous; + /* number of samples to acquire */ + int ai_sample_count; + int ao_sample_count; + /* time between samples in units of the timer */ + unsigned int ai_timer; + unsigned int ao_timer; + /* counter between aquisitions */ + unsigned int ai_counter; + unsigned int ao_counter; + /* interval in frames/uframes */ + unsigned int ai_interval; + /* D/A commands */ + uint8_t *dac_commands; + /* commands */ + uint8_t *dux_commands; + struct semaphore sem; +}; + +/* + * The pointer to the private usb-data of the driver is also the private data + * for the comedi-device. This has to be global as the usb subsystem needs + * global variables. The other reason is that this structure must be there + * _before_ any comedi command is issued. The usb subsystem must be initialised + * before comedi can access it. + */ +static struct usbduxsub usbduxsub[NUMUSBDUX]; + +static DEFINE_SEMAPHORE(start_stop_sem); + +/* + * Stops the data acquision + * It should be safe to call this function from any context + */ +static int usbduxsub_unlink_InURBs(struct usbduxsub *usbduxsub_tmp) +{ + int i = 0; + int err = 0; + + if (usbduxsub_tmp && usbduxsub_tmp->urbIn) { + for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) { + if (usbduxsub_tmp->urbIn[i]) { + /* We wait here until all transfers have been + * cancelled. */ + usb_kill_urb(usbduxsub_tmp->urbIn[i]); + } + dev_dbg(&usbduxsub_tmp->interface->dev, + "comedi: usbdux: unlinked InURB %d, err=%d\n", + i, err); + } + } + return err; +} + +/* + * This will stop a running acquisition operation + * Is called from within this driver from both the + * interrupt context and from comedi + */ +static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +{ + int ret = 0; + + if (!this_usbduxsub) { + pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n"); + return -EFAULT; + } + dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_stop\n"); + + if (do_unlink) { + /* stop aquistion */ + ret = usbduxsub_unlink_InURBs(this_usbduxsub); + } + + this_usbduxsub->ai_cmd_running = 0; + + return ret; +} + +/* + * This will cancel a running acquisition operation. + * This is called by comedi but never from inside the driver. + */ +static int usbdux_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct usbduxsub *this_usbduxsub; + int res = 0; + + /* force unlink of all urbs */ + this_usbduxsub = dev->private; + if (!this_usbduxsub) + return -EFAULT; + + dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_cancel\n"); + + /* prevent other CPUs from submitting new commands just now */ + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + /* unlink only if the urb really has been submitted */ + res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); + up(&this_usbduxsub->sem); + return res; +} + +/* analogue IN - interrupt service routine */ +static void usbduxsub_ai_IsocIrq(struct urb *urb) +{ + int i, err, n; + struct usbduxsub *this_usbduxsub; + struct comedi_device *this_comedidev; + struct comedi_subdevice *s; + int32_t v; + unsigned int dio_state; + + /* the context variable points to the comedi device */ + this_comedidev = urb->context; + /* the private structure of the subdevice is struct usbduxsub */ + this_usbduxsub = this_comedidev->private; + /* subdevice which is the AD converter */ + s = this_comedidev->subdevices + SUBDEV_AD; + + /* first we test if something unusual has just happened */ + switch (urb->status) { + case 0: + /* copy the result in the transfer buffer */ + memcpy(this_usbduxsub->inBuffer, + urb->transfer_buffer, SIZEINBUF); + break; + case -EILSEQ: + /* error in the ISOchronous data */ + /* we don't copy the data into the transfer buffer */ + /* and recycle the last data byte */ + dev_dbg(&urb->dev->dev, + "comedi%d: usbdux: CRC error in ISO IN stream.\n", + this_usbduxsub->comedidev->minor); + + break; + + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -ECONNABORTED: + /* happens after an unlink command */ + if (this_usbduxsub->ai_cmd_running) { + /* we are still running a command */ + /* tell this comedi */ + s->async->events |= COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_ERROR; + comedi_event(this_usbduxsub->comedidev, s); + /* stop the transfer w/o unlink */ + usbdux_ai_stop(this_usbduxsub, 0); + } + return; + + default: + /* a real error on the bus */ + /* pass error to comedi if we are really running a command */ + if (this_usbduxsub->ai_cmd_running) { + dev_err(&urb->dev->dev, + "Non-zero urb status received in ai intr " + "context: %d\n", urb->status); + s->async->events |= COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_ERROR; + comedi_event(this_usbduxsub->comedidev, s); + /* don't do an unlink here */ + usbdux_ai_stop(this_usbduxsub, 0); + } + return; + } + + /* + * at this point we are reasonably sure that nothing dodgy has happened + * are we running a command? + */ + if (unlikely((!(this_usbduxsub->ai_cmd_running)))) { + /* + * not running a command, do not continue execution if no + * asynchronous command is running in particular not resubmit + */ + return; + } + + urb->dev = this_usbduxsub->usbdev; + + /* resubmit the urb */ + err = usb_submit_urb(urb, GFP_ATOMIC); + if (unlikely(err < 0)) { + dev_err(&urb->dev->dev, + "comedi_: urb resubmit failed in int-context!" + "err=%d\n", + err); + if (err == -EL2NSYNC) + dev_err(&urb->dev->dev, + "buggy USB host controller or bug in IRQ " + "handler!\n"); + s->async->events |= COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_ERROR; + comedi_event(this_usbduxsub->comedidev, s); + /* don't do an unlink here */ + usbdux_ai_stop(this_usbduxsub, 0); + return; + } + + /* get the state of the dio pins to allow external trigger */ + dio_state = be32_to_cpu(this_usbduxsub->inBuffer[0]); + + this_usbduxsub->ai_counter--; + if (likely(this_usbduxsub->ai_counter > 0)) + return; + + /* timer zero, transfer measurements to comedi */ + this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; + + /* test, if we transmit only a fixed number of samples */ + if (!(this_usbduxsub->ai_continous)) { + /* not continous, fixed number of samples */ + this_usbduxsub->ai_sample_count--; + /* all samples received? */ + if (this_usbduxsub->ai_sample_count < 0) { + /* prevent a resubmit next time */ + usbdux_ai_stop(this_usbduxsub, 0); + /* say comedi that the acquistion is over */ + s->async->events |= COMEDI_CB_EOA; + comedi_event(this_usbduxsub->comedidev, s); + return; + } + } + /* get the data from the USB bus and hand it over to comedi */ + n = s->async->cmd.chanlist_len; + for (i = 0; i < n; i++) { + /* transfer data, note first byte is the DIO state */ + v = be32_to_cpu(this_usbduxsub->inBuffer[i+1]); + /* strip status byte */ + v = v & 0x00ffffff; + /* convert to unsigned */ + v = v ^ 0x00800000; + /* write the byte to the buffer */ + err = cfc_write_array_to_buffer(s, &v, sizeof(uint32_t)); + if (unlikely(err == 0)) { + /* buffer overflow */ + usbdux_ai_stop(this_usbduxsub, 0); + return; + } + } + /* tell comedi that data is there */ + s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + comedi_event(this_usbduxsub->comedidev, s); +} + +static int usbduxsub_unlink_OutURBs(struct usbduxsub *usbduxsub_tmp) +{ + int i = 0; + int err = 0; + + if (usbduxsub_tmp && usbduxsub_tmp->urbOut) { + for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) { + if (usbduxsub_tmp->urbOut[i]) + usb_kill_urb(usbduxsub_tmp->urbOut[i]); + + dev_dbg(&usbduxsub_tmp->interface->dev, + "comedi: usbdux: unlinked OutURB %d: res=%d\n", + i, err); + } + } + return err; +} + +/* This will cancel a running acquisition operation + * in any context. + */ +static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +{ + int ret = 0; + + if (!this_usbduxsub) + return -EFAULT; + dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ao_cancel\n"); + + if (do_unlink) + ret = usbduxsub_unlink_OutURBs(this_usbduxsub); + + this_usbduxsub->ao_cmd_running = 0; + + return ret; +} + +/* force unlink, is called by comedi */ +static int usbdux_ao_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct usbduxsub *this_usbduxsub = dev->private; + int res = 0; + + if (!this_usbduxsub) + return -EFAULT; + + /* prevent other CPUs from submitting a command just now */ + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + /* unlink only if it is really running */ + res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running); + up(&this_usbduxsub->sem); + return res; +} + +static void usbduxsub_ao_IsocIrq(struct urb *urb) +{ + int i, ret; + uint8_t *datap; + struct usbduxsub *this_usbduxsub; + struct comedi_device *this_comedidev; + struct comedi_subdevice *s; + + /* the context variable points to the subdevice */ + this_comedidev = urb->context; + /* the private structure of the subdevice is struct usbduxsub */ + this_usbduxsub = this_comedidev->private; + + s = this_comedidev->subdevices + SUBDEV_DA; + + switch (urb->status) { + case 0: + /* success */ + break; + + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -ECONNABORTED: + /* after an unlink command, unplug, ... etc */ + /* no unlink needed here. Already shutting down. */ + if (this_usbduxsub->ao_cmd_running) { + s->async->events |= COMEDI_CB_EOA; + comedi_event(this_usbduxsub->comedidev, s); + usbdux_ao_stop(this_usbduxsub, 0); + } + return; + + default: + /* a real error */ + if (this_usbduxsub->ao_cmd_running) { + dev_err(&urb->dev->dev, + "comedi_: Non-zero urb status received in ao " + "intr context: %d\n", urb->status); + s->async->events |= COMEDI_CB_ERROR; + s->async->events |= COMEDI_CB_EOA; + comedi_event(this_usbduxsub->comedidev, s); + /* we do an unlink if we are in the high speed mode */ + usbdux_ao_stop(this_usbduxsub, 0); + } + return; + } + + /* are we actually running? */ + if (!(this_usbduxsub->ao_cmd_running)) + return; + + /* normal operation: executing a command in this subdevice */ + this_usbduxsub->ao_counter--; + if ((int)this_usbduxsub->ao_counter <= 0) { + /* timer zero */ + this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; + + /* handle non continous aquisition */ + if (!(this_usbduxsub->ao_continous)) { + /* fixed number of samples */ + this_usbduxsub->ao_sample_count--; + if (this_usbduxsub->ao_sample_count < 0) { + /* all samples transmitted */ + usbdux_ao_stop(this_usbduxsub, 0); + s->async->events |= COMEDI_CB_EOA; + comedi_event(this_usbduxsub->comedidev, s); + /* no resubmit of the urb */ + return; + } + } + /* transmit data to the USB bus */ + ((uint8_t *) (urb->transfer_buffer))[0] = + s->async->cmd.chanlist_len; + for (i = 0; i < s->async->cmd.chanlist_len; i++) { + short temp; + if (i >= NUMOUTCHANNELS) + break; + + /* pointer to the DA */ + datap = + (&(((uint8_t *) urb->transfer_buffer)[i * 2 + 1])); + /* get the data from comedi */ + ret = comedi_buf_get(s->async, &temp); + datap[0] = temp; + datap[1] = this_usbduxsub->dac_commands[i]; + /* printk("data[0]=%x, data[1]=%x, data[2]=%x\n", */ + /* datap[0],datap[1],datap[2]); */ + if (ret < 0) { + dev_err(&urb->dev->dev, + "comedi: buffer underflow\n"); + s->async->events |= COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_OVERFLOW; + } + /* transmit data to comedi */ + s->async->events |= COMEDI_CB_BLOCK; + comedi_event(this_usbduxsub->comedidev, s); + } + } + urb->transfer_buffer_length = SIZEOUTBUF; + urb->dev = this_usbduxsub->usbdev; + urb->status = 0; + if (this_usbduxsub->ao_cmd_running) { + if (this_usbduxsub->high_speed) { + /* uframes */ + urb->interval = 8; + } else { + /* frames */ + urb->interval = 1; + } + urb->number_of_packets = 1; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEOUTBUF; + urb->iso_frame_desc[0].status = 0; + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { + dev_err(&urb->dev->dev, + "comedi_: ao urb resubm failed in int-cont. " + "ret=%d", ret); + if (ret == EL2NSYNC) + dev_err(&urb->dev->dev, + "buggy USB host controller or bug in " + "IRQ handling!\n"); + + s->async->events |= COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_ERROR; + comedi_event(this_usbduxsub->comedidev, s); + /* don't do an unlink here */ + usbdux_ao_stop(this_usbduxsub, 0); + } + } +} + +static int usbduxsub_start(struct usbduxsub *usbduxsub) +{ + int errcode = 0; + uint8_t local_transfer_buffer[16]; + + /* 7f92 to zero */ + local_transfer_buffer[0] = 0; + errcode = usb_control_msg(usbduxsub->usbdev, + /* create a pipe for a control transfer */ + usb_sndctrlpipe(usbduxsub->usbdev, 0), + /* bRequest, "Firmware" */ + USBDUXSUB_FIRMWARE, + /* bmRequestType */ + VENDOR_DIR_OUT, + /* Value */ + USBDUXSUB_CPUCS, + /* Index */ + 0x0000, + /* address of the transfer buffer */ + local_transfer_buffer, + /* Length */ + 1, + /* Timeout */ + BULK_TIMEOUT); + if (errcode < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: control msg failed (start)\n"); + return errcode; + } + return 0; +} + +static int usbduxsub_stop(struct usbduxsub *usbduxsub) +{ + int errcode = 0; + + uint8_t local_transfer_buffer[16]; + + /* 7f92 to one */ + local_transfer_buffer[0] = 1; + errcode = usb_control_msg(usbduxsub->usbdev, + usb_sndctrlpipe(usbduxsub->usbdev, 0), + /* bRequest, "Firmware" */ + USBDUXSUB_FIRMWARE, + /* bmRequestType */ + VENDOR_DIR_OUT, + /* Value */ + USBDUXSUB_CPUCS, + /* Index */ + 0x0000, local_transfer_buffer, + /* Length */ + 1, + /* Timeout */ + BULK_TIMEOUT); + if (errcode < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: control msg failed (stop)\n"); + return errcode; + } + return 0; +} + +static int usbduxsub_upload(struct usbduxsub *usbduxsub, + uint8_t *local_transfer_buffer, + unsigned int startAddr, unsigned int len) +{ + int errcode; + + errcode = usb_control_msg(usbduxsub->usbdev, + usb_sndctrlpipe(usbduxsub->usbdev, 0), + /* brequest, firmware */ + USBDUXSUB_FIRMWARE, + /* bmRequestType */ + VENDOR_DIR_OUT, + /* value */ + startAddr, + /* index */ + 0x0000, + /* our local safe buffer */ + local_transfer_buffer, + /* length */ + len, + /* timeout */ + BULK_TIMEOUT); + dev_dbg(&usbduxsub->interface->dev, "comedi_: result=%d\n", errcode); + if (errcode < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: upload failed\n"); + return errcode; + } + return 0; +} + +/* the FX2LP has twice as much as the standard FX2 */ +#define FIRMWARE_MAX_LEN 0x4000 + +static int firmwareUpload(struct usbduxsub *usbduxsub, + const u8 *firmwareBinary, int sizeFirmware) +{ + int ret; + uint8_t *fwBuf; + + if (!firmwareBinary) + return 0; + + if (sizeFirmware > FIRMWARE_MAX_LEN) { + dev_err(&usbduxsub->interface->dev, + "usbduxsigma firmware binary it too large for FX2.\n"); + return -ENOMEM; + } + + /* we generate a local buffer for the firmware */ + fwBuf = kmemdup(firmwareBinary, sizeFirmware, GFP_KERNEL); + if (!fwBuf) { + dev_err(&usbduxsub->interface->dev, + "comedi_: mem alloc for firmware failed\n"); + return -ENOMEM; + } + + ret = usbduxsub_stop(usbduxsub); + if (ret < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: can not stop firmware\n"); + kfree(fwBuf); + return ret; + } + + ret = usbduxsub_upload(usbduxsub, fwBuf, 0, sizeFirmware); + if (ret < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: firmware upload failed\n"); + kfree(fwBuf); + return ret; + } + ret = usbduxsub_start(usbduxsub); + if (ret < 0) { + dev_err(&usbduxsub->interface->dev, + "comedi_: can not start firmware\n"); + kfree(fwBuf); + return ret; + } + kfree(fwBuf); + return 0; +} + +static int usbduxsub_submit_InURBs(struct usbduxsub *usbduxsub) +{ + int i, errFlag; + + if (!usbduxsub) + return -EFAULT; + + /* Submit all URBs and start the transfer on the bus */ + for (i = 0; i < usbduxsub->numOfInBuffers; i++) { + /* in case of a resubmission after an unlink... */ + usbduxsub->urbIn[i]->interval = usbduxsub->ai_interval; + usbduxsub->urbIn[i]->context = usbduxsub->comedidev; + usbduxsub->urbIn[i]->dev = usbduxsub->usbdev; + usbduxsub->urbIn[i]->status = 0; + usbduxsub->urbIn[i]->transfer_flags = URB_ISO_ASAP; + dev_dbg(&usbduxsub->interface->dev, + "comedi%d: submitting in-urb[%d]: %p,%p intv=%d\n", + usbduxsub->comedidev->minor, i, + (usbduxsub->urbIn[i]->context), + (usbduxsub->urbIn[i]->dev), + (usbduxsub->urbIn[i]->interval)); + errFlag = usb_submit_urb(usbduxsub->urbIn[i], GFP_ATOMIC); + if (errFlag) { + dev_err(&usbduxsub->interface->dev, + "comedi_: ai: usb_submit_urb(%d) error %d\n", + i, errFlag); + return errFlag; + } + } + return 0; +} + +static int usbduxsub_submit_OutURBs(struct usbduxsub *usbduxsub) +{ + int i, errFlag; + + if (!usbduxsub) + return -EFAULT; + + for (i = 0; i < usbduxsub->numOfOutBuffers; i++) { + dev_dbg(&usbduxsub->interface->dev, + "comedi_: submitting out-urb[%d]\n", i); + /* in case of a resubmission after an unlink... */ + usbduxsub->urbOut[i]->context = usbduxsub->comedidev; + usbduxsub->urbOut[i]->dev = usbduxsub->usbdev; + usbduxsub->urbOut[i]->status = 0; + usbduxsub->urbOut[i]->transfer_flags = URB_ISO_ASAP; + errFlag = usb_submit_urb(usbduxsub->urbOut[i], GFP_ATOMIC); + if (errFlag) { + dev_err(&usbduxsub->interface->dev, + "comedi_: ao: usb_submit_urb(%d) error %d\n", + i, errFlag); + return errFlag; + } + } + return 0; +} + +static int chanToInterval(int nChannels) +{ + if (nChannels <= 2) + /* 4kHz */ + return 2; + if (nChannels <= 8) + /* 2kHz */ + return 4; + /* 1kHz */ + return 8; +} + +static int usbdux_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + int err = 0, tmp, i; + unsigned int tmpTimer; + struct usbduxsub *this_usbduxsub = dev->private; + + if (!(this_usbduxsub->probed)) + return -ENODEV; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ai_cmdtest\n", dev->minor); + + /* make sure triggers are valid */ + /* Only immediate triggers are allowed */ + tmp = cmd->start_src; + cmd->start_src &= TRIG_NOW | TRIG_INT; + if (!cmd->start_src || tmp != cmd->start_src) + err++; + + /* trigger should happen timed */ + tmp = cmd->scan_begin_src; + /* start a new _scan_ with a timer */ + cmd->scan_begin_src &= TRIG_TIMER; + if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) + err++; + + /* scanning is continous */ + tmp = cmd->convert_src; + cmd->convert_src &= TRIG_NOW; + if (!cmd->convert_src || tmp != cmd->convert_src) + err++; + + /* issue a trigger when scan is finished and start a new scan */ + tmp = cmd->scan_end_src; + cmd->scan_end_src &= TRIG_COUNT; + if (!cmd->scan_end_src || tmp != cmd->scan_end_src) + err++; + + /* trigger at the end of count events or not, stop condition or not */ + tmp = cmd->stop_src; + cmd->stop_src &= TRIG_COUNT | TRIG_NONE; + if (!cmd->stop_src || tmp != cmd->stop_src) + err++; + + if (err) + return 1; + + /* + * step 2: make sure trigger sources are unique and mutually compatible + * note that mutual compatibility is not an issue here + */ + if (cmd->scan_begin_src != TRIG_FOLLOW && + cmd->scan_begin_src != TRIG_EXT && + cmd->scan_begin_src != TRIG_TIMER) + err++; + if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) + err++; + + if (err) + return 2; + + /* step 3: make sure arguments are trivially compatible */ + if (cmd->start_arg != 0) { + cmd->start_arg = 0; + err++; + } + + if (cmd->scan_begin_src == TRIG_FOLLOW) { + /* internal trigger */ + if (cmd->scan_begin_arg != 0) { + cmd->scan_begin_arg = 0; + err++; + } + } + + if (cmd->scan_begin_src == TRIG_TIMER) { + if (this_usbduxsub->high_speed) { + /* + * In high speed mode microframes are possible. + * However, during one microframe we can roughly + * sample two channels. Thus, the more channels + * are in the channel list the more time we need. + */ + i = chanToInterval(cmd->chanlist_len); + if (cmd->scan_begin_arg < (1000000 / 8 * i)) { + cmd->scan_begin_arg = 1000000 / 8 * i; + err++; + } + /* now calc the real sampling rate with all the + * rounding errors */ + tmpTimer = + ((unsigned int)(cmd->scan_begin_arg / 125000)) * + 125000; + if (cmd->scan_begin_arg != tmpTimer) { + cmd->scan_begin_arg = tmpTimer; + err++; + } + } else { + /* full speed */ + /* 1kHz scans every USB frame */ + if (cmd->scan_begin_arg < 1000000) { + cmd->scan_begin_arg = 1000000; + err++; + } + /* + * calc the real sampling rate with the rounding errors + */ + tmpTimer = ((unsigned int)(cmd->scan_begin_arg / + 1000000)) * 1000000; + if (cmd->scan_begin_arg != tmpTimer) { + cmd->scan_begin_arg = tmpTimer; + err++; + } + } + } + /* the same argument */ + if (cmd->scan_end_arg != cmd->chanlist_len) { + cmd->scan_end_arg = cmd->chanlist_len; + err++; + } + + if (cmd->stop_src == TRIG_COUNT) { + /* any count is allowed */ + } else { + /* TRIG_NONE */ + if (cmd->stop_arg != 0) { + cmd->stop_arg = 0; + err++; + } + } + + if (err) + return 3; + + return 0; +} + +/* + * creates the ADC command for the MAX1271 + * range is the range value from comedi + */ +static void create_adc_command(unsigned int chan, + uint8_t *muxsg0, + uint8_t *muxsg1) +{ + if (chan < 8) + (*muxsg0) = (*muxsg0) | (1 << chan); + else if (chan < 16) + (*muxsg1) = (*muxsg1) | (1 << (chan-8)); +} + + +/* bulk transfers to usbdux */ + +#define SENDADCOMMANDS 0 +#define SENDDACOMMANDS 1 +#define SENDDIOCONFIGCOMMAND 2 +#define SENDDIOBITSCOMMAND 3 +#define SENDSINGLEAD 4 +#define SENDPWMON 7 +#define SENDPWMOFF 8 + +static int send_dux_commands(struct usbduxsub *this_usbduxsub, int cmd_type) +{ + int result, nsent; + + this_usbduxsub->dux_commands[0] = cmd_type; +#ifdef NOISY_DUX_DEBUGBUG + printk(KERN_DEBUG "comedi%d: usbdux: dux_commands: ", + this_usbduxsub->comedidev->minor); + for (result = 0; result < SIZEOFDUXBUFFER; result++) + printk(" %02x", this_usbduxsub->dux_commands[result]); + printk("\n"); +#endif + result = usb_bulk_msg(this_usbduxsub->usbdev, + usb_sndbulkpipe(this_usbduxsub->usbdev, + COMMAND_OUT_EP), + this_usbduxsub->dux_commands, SIZEOFDUXBUFFER, + &nsent, BULK_TIMEOUT); + if (result < 0) + dev_err(&this_usbduxsub->interface->dev, "comedi%d: " + "could not transmit dux_command to the usb-device, " + "err=%d\n", this_usbduxsub->comedidev->minor, result); + + return result; +} + +static int receive_dux_commands(struct usbduxsub *this_usbduxsub, int command) +{ + int result = (-EFAULT); + int nrec; + int i; + + for (i = 0; i < RETRIES; i++) { + result = usb_bulk_msg(this_usbduxsub->usbdev, + usb_rcvbulkpipe(this_usbduxsub->usbdev, + COMMAND_IN_EP), + this_usbduxsub->insnBuffer, SIZEINSNBUF, + &nrec, BULK_TIMEOUT); + if (result < 0) { + dev_err(&this_usbduxsub->interface->dev, "comedi%d: " + "insn: USB error %d " + "while receiving DUX command" + "\n", this_usbduxsub->comedidev->minor, + result); + return result; + } + if (this_usbduxsub->insnBuffer[0] == command) + return result; + } + /* this is only reached if the data has been requested a couple of + * times */ + dev_err(&this_usbduxsub->interface->dev, "comedi%d: insn: " + "wrong data returned from firmware: want %d, got %d.\n", + this_usbduxsub->comedidev->minor, command, + this_usbduxsub->insnBuffer[0]); + return -EFAULT; +} + +static int usbdux_ai_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int trignum) +{ + int ret; + struct usbduxsub *this_usbduxsub = dev->private; + if (!this_usbduxsub) + return -EFAULT; + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ai_inttrig\n", dev->minor); + + if (trignum != 0) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ai_inttrig: invalid trignum\n", + dev->minor); + up(&this_usbduxsub->sem); + return -EINVAL; + } + if (!(this_usbduxsub->ai_cmd_running)) { + this_usbduxsub->ai_cmd_running = 1; + ret = usbduxsub_submit_InURBs(this_usbduxsub); + if (ret < 0) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ai_inttrig: " + "urbSubmit: err=%d\n", dev->minor, ret); + this_usbduxsub->ai_cmd_running = 0; + up(&this_usbduxsub->sem); + return ret; + } + s->async->inttrig = NULL; + } else { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: ai_inttrig but acqu is already running\n", + dev->minor); + } + up(&this_usbduxsub->sem); + return 1; +} + +static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) +{ + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int chan; + int i, ret; + struct usbduxsub *this_usbduxsub = dev->private; + int result; + uint8_t muxsg0 = 0; + uint8_t muxsg1 = 0; + uint8_t sysred = 0; + + if (!this_usbduxsub) + return -EFAULT; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ai_cmd\n", dev->minor); + + /* block other CPUs from starting an ai_cmd */ + down(&this_usbduxsub->sem); + + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + if (this_usbduxsub->ai_cmd_running) { + dev_err(&this_usbduxsub->interface->dev, "comedi%d: " + "ai_cmd not possible. Another ai_cmd is running.\n", + dev->minor); + up(&this_usbduxsub->sem); + return -EBUSY; + } + /* set current channel of the running aquisition to zero */ + s->async->cur_chan = 0; + + /* first the number of channels per time step */ + this_usbduxsub->dux_commands[1] = cmd->chanlist_len; + + /* CONFIG0 */ + this_usbduxsub->dux_commands[2] = 0x12; + + /* CONFIG1: 23kHz sampling rate, delay = 0us, */ + this_usbduxsub->dux_commands[3] = 0x03; + + /* CONFIG3: differential channels off */ + this_usbduxsub->dux_commands[4] = 0x00; + + for (i = 0; i < cmd->chanlist_len; i++) { + chan = CR_CHAN(cmd->chanlist[i]); + create_adc_command(chan, &muxsg0, &muxsg1); + if (i >= NUMCHANNELS) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: channel list too long\n", + dev->minor); + break; + } + } + this_usbduxsub->dux_commands[5] = muxsg0; + this_usbduxsub->dux_commands[6] = muxsg1; + this_usbduxsub->dux_commands[7] = sysred; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi %d: sending commands to the usb device: size=%u\n", + dev->minor, NUMCHANNELS); + + result = send_dux_commands(this_usbduxsub, SENDADCOMMANDS); + if (result < 0) { + up(&this_usbduxsub->sem); + return result; + } + + if (this_usbduxsub->high_speed) { + /* + * every 2 channels get a time window of 125us. Thus, if we + * sample all 16 channels we need 1ms. If we sample only one + * channel we need only 125us + */ + this_usbduxsub->ai_interval = + chanToInterval(cmd->chanlist_len); + this_usbduxsub->ai_timer = cmd->scan_begin_arg / (125000 * + (this_usbduxsub-> + ai_interval)); + } else { + /* interval always 1ms */ + this_usbduxsub->ai_interval = 1; + this_usbduxsub->ai_timer = cmd->scan_begin_arg / 1000000; + } + if (this_usbduxsub->ai_timer < 1) { + dev_err(&this_usbduxsub->interface->dev, "comedi%d: ai_cmd: " + "timer=%d, scan_begin_arg=%d. " + "Not properly tested by cmdtest?\n", dev->minor, + this_usbduxsub->ai_timer, cmd->scan_begin_arg); + up(&this_usbduxsub->sem); + return -EINVAL; + } + this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; + + if (cmd->stop_src == TRIG_COUNT) { + /* data arrives as one packet */ + this_usbduxsub->ai_sample_count = cmd->stop_arg; + this_usbduxsub->ai_continous = 0; + } else { + /* continous aquisition */ + this_usbduxsub->ai_continous = 1; + this_usbduxsub->ai_sample_count = 0; + } + + if (cmd->start_src == TRIG_NOW) { + /* enable this acquisition operation */ + this_usbduxsub->ai_cmd_running = 1; + ret = usbduxsub_submit_InURBs(this_usbduxsub); + if (ret < 0) { + this_usbduxsub->ai_cmd_running = 0; + /* fixme: unlink here?? */ + up(&this_usbduxsub->sem); + return ret; + } + s->async->inttrig = NULL; + } else { + /* TRIG_INT */ + /* don't enable the acquision operation */ + /* wait for an internal signal */ + s->async->inttrig = usbdux_ai_inttrig; + } + up(&this_usbduxsub->sem); + return 0; +} + +/* Mode 0 is used to get a single conversion on demand */ +static int usbdux_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + int i; + int32_t one = 0; + int chan; + int err; + struct usbduxsub *this_usbduxsub = dev->private; + uint8_t muxsg0 = 0; + uint8_t muxsg1 = 0; + uint8_t sysred = 0; + + if (!this_usbduxsub) + return 0; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: ai_insn_read, insn->n=%d, insn->subdev=%d\n", + dev->minor, insn->n, insn->subdev); + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + if (this_usbduxsub->ai_cmd_running) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: ai_insn_read not possible. " + "Async Command is running.\n", dev->minor); + up(&this_usbduxsub->sem); + return 0; + } + + /* sample one channel */ + /* CONFIG0: chopper on */ + this_usbduxsub->dux_commands[1] = 0x16; + + /* CONFIG1: 2kHz sampling rate */ + this_usbduxsub->dux_commands[2] = 0x80; + + /* CONFIG3: differential channels off */ + this_usbduxsub->dux_commands[3] = 0x00; + + chan = CR_CHAN(insn->chanspec); + create_adc_command(chan, &muxsg0, &muxsg1); + + this_usbduxsub->dux_commands[4] = muxsg0; + this_usbduxsub->dux_commands[5] = muxsg1; + this_usbduxsub->dux_commands[6] = sysred; + + /* adc commands */ + err = send_dux_commands(this_usbduxsub, SENDSINGLEAD); + if (err < 0) { + up(&this_usbduxsub->sem); + return err; + } + + for (i = 0; i < insn->n; i++) { + err = receive_dux_commands(this_usbduxsub, SENDSINGLEAD); + if (err < 0) { + up(&this_usbduxsub->sem); + return 0; + } + /* 32 bits big endian from the A/D converter */ + one = be32_to_cpu(*((int32_t *) + ((this_usbduxsub->insnBuffer)+1))); + /* mask out the staus byte */ + one = one & 0x00ffffff; + /* turn it into an unsigned integer */ + one = one ^ 0x00800000; + data[i] = one; + } + up(&this_usbduxsub->sem); + return i; +} + + + + +static int usbdux_getstatusinfo(struct comedi_device *dev, int chan) +{ + struct usbduxsub *this_usbduxsub = dev->private; + uint8_t sysred = 0; + uint32_t one; + int err; + + if (!this_usbduxsub) + return 0; + + if (this_usbduxsub->ai_cmd_running) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: status read not possible. " + "Async Command is running.\n", dev->minor); + return 0; + } + + /* CONFIG0 */ + this_usbduxsub->dux_commands[1] = 0x12; + + /* CONFIG1: 2kHz sampling rate */ + this_usbduxsub->dux_commands[2] = 0x80; + + /* CONFIG3: differential channels off */ + this_usbduxsub->dux_commands[3] = 0x00; + + if (chan == 1) { + /* ADC offset */ + sysred = sysred | 1; + } else if (chan == 2) { + /* VCC */ + sysred = sysred | 4; + } else if (chan == 3) { + /* temperature */ + sysred = sysred | 8; + } else if (chan == 4) { + /* gain */ + sysred = sysred | 16; + } else if (chan == 5) { + /* ref */ + sysred = sysred | 32; + } + + this_usbduxsub->dux_commands[4] = 0; + this_usbduxsub->dux_commands[5] = 0; + this_usbduxsub->dux_commands[6] = sysred; + + /* adc commands */ + err = send_dux_commands(this_usbduxsub, SENDSINGLEAD); + if (err < 0) + return err; + + err = receive_dux_commands(this_usbduxsub, SENDSINGLEAD); + if (err < 0) + return err; + + /* 32 bits big endian from the A/D converter */ + one = be32_to_cpu(*((int32_t *)((this_usbduxsub->insnBuffer)+1))); + /* mask out the staus byte */ + one = one & 0x00ffffff; + one = one ^ 0x00800000; + + return (int)one; +} + + + + + + +/************************************/ +/* analog out */ + +static int usbdux_ao_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + int i; + int chan = CR_CHAN(insn->chanspec); + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + for (i = 0; i < insn->n; i++) + data[i] = this_usbduxsub->outBuffer[chan]; + + up(&this_usbduxsub->sem); + return i; +} + +static int usbdux_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + int i, err; + int chan = CR_CHAN(insn->chanspec); + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: ao_insn_write\n", dev->minor); + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + if (this_usbduxsub->ao_cmd_running) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: ao_insn_write: " + "ERROR: asynchronous ao_cmd is running\n", dev->minor); + up(&this_usbduxsub->sem); + return 0; + } + + for (i = 0; i < insn->n; i++) { + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: ao_insn_write: data[chan=%d,i=%d]=%d\n", + dev->minor, chan, i, data[i]); + + /* number of channels: 1 */ + this_usbduxsub->dux_commands[1] = 1; + /* channel number */ + this_usbduxsub->dux_commands[2] = data[i]; + this_usbduxsub->outBuffer[chan] = data[i]; + this_usbduxsub->dux_commands[3] = chan; + err = send_dux_commands(this_usbduxsub, SENDDACOMMANDS); + if (err < 0) { + up(&this_usbduxsub->sem); + return err; + } + } + up(&this_usbduxsub->sem); + + return i; +} + +static int usbdux_ao_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int trignum) +{ + int ret; + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + if (trignum != 0) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ao_inttrig: invalid trignum\n", + dev->minor); + return -EINVAL; + } + if (!(this_usbduxsub->ao_cmd_running)) { + this_usbduxsub->ao_cmd_running = 1; + ret = usbduxsub_submit_OutURBs(this_usbduxsub); + if (ret < 0) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ao_inttrig: submitURB: " + "err=%d\n", dev->minor, ret); + this_usbduxsub->ao_cmd_running = 0; + up(&this_usbduxsub->sem); + return ret; + } + s->async->inttrig = NULL; + } else { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: ao_inttrig but acqu is already running.\n", + dev->minor); + } + up(&this_usbduxsub->sem); + return 1; +} + +static int usbdux_ao_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + int err = 0, tmp; + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + if (!(this_usbduxsub->probed)) + return -ENODEV; + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: usbdux_ao_cmdtest\n", dev->minor); + + /* make sure triggers are valid */ + /* Only immediate triggers are allowed */ + tmp = cmd->start_src; + cmd->start_src &= TRIG_NOW | TRIG_INT; + if (!cmd->start_src || tmp != cmd->start_src) + err++; + + /* trigger should happen timed */ + tmp = cmd->scan_begin_src; + /* just now we scan also in the high speed mode every frame */ + /* this is due to ehci driver limitations */ + if (0) { /* (this_usbduxsub->high_speed) */ + /* start immidiately a new scan */ + /* the sampling rate is set by the coversion rate */ + cmd->scan_begin_src &= TRIG_FOLLOW; + } else { + /* start a new scan (output at once) with a timer */ + cmd->scan_begin_src &= TRIG_TIMER; + } + if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) + err++; + + /* scanning is continous */ + tmp = cmd->convert_src; + + /* all conversion events happen simultaneously */ + cmd->convert_src &= TRIG_NOW; + + if (!cmd->convert_src || tmp != cmd->convert_src) + err++; + + /* issue a trigger when scan is finished and start a new scan */ + tmp = cmd->scan_end_src; + cmd->scan_end_src &= TRIG_COUNT; + if (!cmd->scan_end_src || tmp != cmd->scan_end_src) + err++; + + /* trigger at the end of count events or not, stop condition or not */ + tmp = cmd->stop_src; + cmd->stop_src &= TRIG_COUNT | TRIG_NONE; + if (!cmd->stop_src || tmp != cmd->stop_src) + err++; + + if (err) + return 1; + + /* + * step 2: make sure trigger sources + * are unique and mutually compatible + * note that mutual compatibility is not an issue here + */ + if (cmd->scan_begin_src != TRIG_FOLLOW && + cmd->scan_begin_src != TRIG_EXT && + cmd->scan_begin_src != TRIG_TIMER) + err++; + if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) + err++; + + if (err) + return 2; + + /* step 3: make sure arguments are trivially compatible */ + + if (cmd->start_arg != 0) { + cmd->start_arg = 0; + err++; + } + + if (cmd->scan_begin_src == TRIG_FOLLOW) { + /* internal trigger */ + if (cmd->scan_begin_arg != 0) { + cmd->scan_begin_arg = 0; + err++; + } + } + + if (cmd->scan_begin_src == TRIG_TIMER) { + /* timer */ + if (cmd->scan_begin_arg < 1000000) { + cmd->scan_begin_arg = 1000000; + err++; + } + } + /* not used now, is for later use */ + if (cmd->convert_src == TRIG_TIMER) { + if (cmd->convert_arg < 125000) { + cmd->convert_arg = 125000; + err++; + } + } + + /* the same argument */ + if (cmd->scan_end_arg != cmd->chanlist_len) { + cmd->scan_end_arg = cmd->chanlist_len; + err++; + } + + if (cmd->stop_src == TRIG_COUNT) { + /* any count is allowed */ + } else { + /* TRIG_NONE */ + if (cmd->stop_arg != 0) { + cmd->stop_arg = 0; + err++; + } + } + + dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: err=%d, " + "scan_begin_src=%d, scan_begin_arg=%d, convert_src=%d, " + "convert_arg=%d\n", dev->minor, err, cmd->scan_begin_src, + cmd->scan_begin_arg, cmd->convert_src, cmd->convert_arg); + + if (err) + return 3; + + return 0; +} + +static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) +{ + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int chan, gain; + int i, ret; + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + down(&this_usbduxsub->sem); + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: %s\n", dev->minor, __func__); + + /* set current channel of the running aquisition to zero */ + s->async->cur_chan = 0; + for (i = 0; i < cmd->chanlist_len; ++i) { + chan = CR_CHAN(cmd->chanlist[i]); + gain = CR_RANGE(cmd->chanlist[i]); + if (i >= NUMOUTCHANNELS) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: %s: channel list too long\n", + dev->minor, __func__); + break; + } + this_usbduxsub->dac_commands[i] = chan; + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: dac command for ch %d is %x\n", + dev->minor, i, this_usbduxsub->dac_commands[i]); + } + + /* we count in steps of 1ms (125us) */ + /* 125us mode not used yet */ + if (0) { /* (this_usbduxsub->high_speed) */ + /* 125us */ + /* timing of the conversion itself: every 125 us */ + this_usbduxsub->ao_timer = cmd->convert_arg / 125000; + } else { + /* 1ms */ + /* timing of the scan: we get all channels at once */ + this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000; + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: scan_begin_src=%d, scan_begin_arg=%d, " + "convert_src=%d, convert_arg=%d\n", dev->minor, + cmd->scan_begin_src, cmd->scan_begin_arg, + cmd->convert_src, cmd->convert_arg); + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: ao_timer=%d (ms)\n", + dev->minor, this_usbduxsub->ao_timer); + if (this_usbduxsub->ao_timer < 1) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: usbdux: ao_timer=%d, " + "scan_begin_arg=%d. " + "Not properly tested by cmdtest?\n", + dev->minor, this_usbduxsub->ao_timer, + cmd->scan_begin_arg); + up(&this_usbduxsub->sem); + return -EINVAL; + } + } + this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; + + if (cmd->stop_src == TRIG_COUNT) { + /* not continous */ + /* counter */ + /* high speed also scans everything at once */ + if (0) { /* (this_usbduxsub->high_speed) */ + this_usbduxsub->ao_sample_count = + (cmd->stop_arg) * (cmd->scan_end_arg); + } else { + /* there's no scan as the scan has been */ + /* perf inside the FX2 */ + /* data arrives as one packet */ + this_usbduxsub->ao_sample_count = cmd->stop_arg; + } + this_usbduxsub->ao_continous = 0; + } else { + /* continous aquisition */ + this_usbduxsub->ao_continous = 1; + this_usbduxsub->ao_sample_count = 0; + } + + if (cmd->start_src == TRIG_NOW) { + /* enable this acquisition operation */ + this_usbduxsub->ao_cmd_running = 1; + ret = usbduxsub_submit_OutURBs(this_usbduxsub); + if (ret < 0) { + this_usbduxsub->ao_cmd_running = 0; + /* fixme: unlink here?? */ + up(&this_usbduxsub->sem); + return ret; + } + s->async->inttrig = NULL; + } else { + /* TRIG_INT */ + /* submit the urbs later */ + /* wait for an internal signal */ + s->async->inttrig = usbdux_ao_inttrig; + } + + up(&this_usbduxsub->sem); + return 0; +} + +static int usbdux_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + int chan = CR_CHAN(insn->chanspec); + + /* The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value COMEDI_INPUT or COMEDI_OUTPUT. */ + + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= 1 << chan; /* 1 means Out */ + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~(1 << chan); + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + break; + default: + return -EINVAL; + break; + } + /* we don't tell the firmware here as it would take 8 frames */ + /* to submit the information. We do it in the insn_bits. */ + return insn->n; +} + +static int usbdux_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + + struct usbduxsub *this_usbduxsub = dev->private; + int err; + + if (!this_usbduxsub) + return -EFAULT; + + if (insn->n != 2) + return -EINVAL; + + down(&this_usbduxsub->sem); + + if (!(this_usbduxsub->probed)) { + up(&this_usbduxsub->sem); + return -ENODEV; + } + + /* The insn data is a mask in data[0] and the new data + * in data[1], each channel cooresponding to a bit. */ + s->state &= ~data[0]; + s->state |= data[0] & data[1]; + /* The commands are 8 bits wide */ + this_usbduxsub->dux_commands[1] = (s->io_bits) & 0x000000FF; + this_usbduxsub->dux_commands[4] = (s->state) & 0x000000FF; + this_usbduxsub->dux_commands[2] = ((s->io_bits) & 0x0000FF00) >> 8; + this_usbduxsub->dux_commands[5] = ((s->state) & 0x0000FF00) >> 8; + this_usbduxsub->dux_commands[3] = ((s->io_bits) & 0x00FF0000) >> 16; + this_usbduxsub->dux_commands[6] = ((s->state) & 0x00FF0000) >> 16; + + /* This command also tells the firmware to return */ + /* the digital input lines */ + err = send_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND); + if (err < 0) { + up(&this_usbduxsub->sem); + return err; + } + err = receive_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND); + if (err < 0) { + up(&this_usbduxsub->sem); + return err; + } + + data[1] = (((unsigned int)(this_usbduxsub->insnBuffer[1]))&0xff) | + ((((unsigned int)(this_usbduxsub->insnBuffer[2]))&0xff) << 8) | + ((((unsigned int)(this_usbduxsub->insnBuffer[3]))&0xff) << 16); + + s->state = data[1]; + + up(&this_usbduxsub->sem); + return 2; +} + +/***********************************/ +/* PWM */ + +static int usbduxsub_unlink_PwmURBs(struct usbduxsub *usbduxsub_tmp) +{ + int err = 0; + + if (usbduxsub_tmp && usbduxsub_tmp->urbPwm) { + if (usbduxsub_tmp->urbPwm) + usb_kill_urb(usbduxsub_tmp->urbPwm); + dev_dbg(&usbduxsub_tmp->interface->dev, + "comedi: unlinked PwmURB: res=%d\n", err); + } + return err; +} + +/* This cancels a running acquisition operation + * in any context. + */ +static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +{ + int ret = 0; + + if (!this_usbduxsub) + return -EFAULT; + + dev_dbg(&this_usbduxsub->interface->dev, "comedi: %s\n", __func__); + if (do_unlink) + ret = usbduxsub_unlink_PwmURBs(this_usbduxsub); + + this_usbduxsub->pwm_cmd_running = 0; + + return ret; +} + +/* force unlink - is called by comedi */ +static int usbdux_pwm_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct usbduxsub *this_usbduxsub = dev->private; + int res = 0; + + /* unlink only if it is really running */ + res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running); + + dev_dbg(&this_usbduxsub->interface->dev, + "comedi %d: sending pwm off command to the usb device.\n", + dev->minor); + res = send_dux_commands(this_usbduxsub, SENDPWMOFF); + if (res < 0) + return res; + + return res; +} + +static void usbduxsub_pwm_irq(struct urb *urb) +{ + int ret; + struct usbduxsub *this_usbduxsub; + struct comedi_device *this_comedidev; + struct comedi_subdevice *s; + + /* printk(KERN_DEBUG "PWM: IRQ\n"); */ + + /* the context variable points to the subdevice */ + this_comedidev = urb->context; + /* the private structure of the subdevice is struct usbduxsub */ + this_usbduxsub = this_comedidev->private; + + s = this_comedidev->subdevices + SUBDEV_DA; + + switch (urb->status) { + case 0: + /* success */ + break; + + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -ECONNABORTED: + /* + * after an unlink command, unplug, ... etc + * no unlink needed here. Already shutting down. + */ + if (this_usbduxsub->pwm_cmd_running) + usbdux_pwm_stop(this_usbduxsub, 0); + + return; + + default: + /* a real error */ + if (this_usbduxsub->pwm_cmd_running) { + dev_err(&this_usbduxsub->interface->dev, + "comedi_: Non-zero urb status received in " + "pwm intr context: %d\n", urb->status); + usbdux_pwm_stop(this_usbduxsub, 0); + } + return; + } + + /* are we actually running? */ + if (!(this_usbduxsub->pwm_cmd_running)) + return; + + urb->transfer_buffer_length = this_usbduxsub->sizePwmBuf; + urb->dev = this_usbduxsub->usbdev; + urb->status = 0; + if (this_usbduxsub->pwm_cmd_running) { + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { + dev_err(&this_usbduxsub->interface->dev, + "comedi_: pwm urb resubm failed in int-cont. " + "ret=%d", ret); + if (ret == EL2NSYNC) + dev_err(&this_usbduxsub->interface->dev, + "buggy USB host controller or bug in " + "IRQ handling!\n"); + + /* don't do an unlink here */ + usbdux_pwm_stop(this_usbduxsub, 0); + } + } +} + +static int usbduxsub_submit_PwmURBs(struct usbduxsub *usbduxsub) +{ + int errFlag; + + if (!usbduxsub) + return -EFAULT; + + dev_dbg(&usbduxsub->interface->dev, "comedi_: submitting pwm-urb\n"); + + /* in case of a resubmission after an unlink... */ + usb_fill_bulk_urb(usbduxsub->urbPwm, + usbduxsub->usbdev, + usb_sndbulkpipe(usbduxsub->usbdev, PWM_EP), + usbduxsub->urbPwm->transfer_buffer, + usbduxsub->sizePwmBuf, usbduxsub_pwm_irq, + usbduxsub->comedidev); + + errFlag = usb_submit_urb(usbduxsub->urbPwm, GFP_ATOMIC); + if (errFlag) { + dev_err(&usbduxsub->interface->dev, + "comedi_: usbduxsigma: pwm: usb_submit_urb error %d\n", + errFlag); + return errFlag; + } + return 0; +} + +static int usbdux_pwm_period(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int period) +{ + struct usbduxsub *this_usbduxsub = dev->private; + int fx2delay = 255; + + if (period < MIN_PWM_PERIOD) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: illegal period setting for pwm.\n", + dev->minor); + return -EAGAIN; + } else { + fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6; + if (fx2delay > 255) { + dev_err(&this_usbduxsub->interface->dev, + "comedi%d: period %d for pwm is too low.\n", + dev->minor, period); + return -EAGAIN; + } + } + this_usbduxsub->pwmDelay = fx2delay; + this_usbduxsub->pwmPeriod = period; + dev_dbg(&this_usbduxsub->interface->dev, "%s: frequ=%d, period=%d\n", + __func__, period, fx2delay); + return 0; +} + +/* is called from insn so there's no need to do all the sanity checks */ +static int usbdux_pwm_start(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + int ret, i; + struct usbduxsub *this_usbduxsub = dev->private; + + dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: %s\n", + dev->minor, __func__); + + if (this_usbduxsub->pwm_cmd_running) { + /* already running */ + return 0; + } + + this_usbduxsub->dux_commands[1] = ((uint8_t) this_usbduxsub->pwmDelay); + ret = send_dux_commands(this_usbduxsub, SENDPWMON); + if (ret < 0) + return ret; + + /* initialise the buffer */ + for (i = 0; i < this_usbduxsub->sizePwmBuf; i++) + ((char *)(this_usbduxsub->urbPwm->transfer_buffer))[i] = 0; + + this_usbduxsub->pwm_cmd_running = 1; + ret = usbduxsub_submit_PwmURBs(this_usbduxsub); + if (ret < 0) { + this_usbduxsub->pwm_cmd_running = 0; + return ret; + } + return 0; +} + +/* generates the bit pattern for PWM with the optional sign bit */ +static int usbdux_pwm_pattern(struct comedi_device *dev, + struct comedi_subdevice *s, int channel, + unsigned int value, unsigned int sign) +{ + struct usbduxsub *this_usbduxsub = dev->private; + int i, szbuf; + char *pBuf; + char pwm_mask; + char sgn_mask; + char c; + + if (!this_usbduxsub) + return -EFAULT; + + /* this is the DIO bit which carries the PWM data */ + pwm_mask = (1 << channel); + /* this is the DIO bit which carries the optional direction bit */ + sgn_mask = (16 << channel); + /* this is the buffer which will be filled with the with bit */ + /* pattern for one period */ + szbuf = this_usbduxsub->sizePwmBuf; + pBuf = (char *)(this_usbduxsub->urbPwm->transfer_buffer); + for (i = 0; i < szbuf; i++) { + c = *pBuf; + /* reset bits */ + c = c & (~pwm_mask); + /* set the bit as long as the index is lower than the value */ + if (i < value) + c = c | pwm_mask; + /* set the optional sign bit for a relay */ + if (!sign) { + /* positive value */ + c = c & (~sgn_mask); + } else { + /* negative value */ + c = c | sgn_mask; + } + *(pBuf++) = c; + } + return 1; +} + +static int usbdux_pwm_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct usbduxsub *this_usbduxsub = dev->private; + + if (!this_usbduxsub) + return -EFAULT; + + if ((insn->n) != 1) { + /* + * doesn't make sense to have more than one value here because + * it would just overwrite the PWM buffer a couple of times + */ + return -EINVAL; + } + + /* + * the sign is set via a special INSN only, this gives us 8 bits for + * normal operation + * relay sign 0 by default + */ + return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec), data[0], 0); +} + +static int usbdux_pwm_read(struct comedi_device *x1, + struct comedi_subdevice *x2, struct comedi_insn *x3, + unsigned int *x4) +{ + /* not needed */ + return -EINVAL; +}; + +/* switches on/off PWM */ +static int usbdux_pwm_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct usbduxsub *this_usbduxsub = dev->private; + switch (data[0]) { + case INSN_CONFIG_ARM: + /* switch it on */ + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: %s: pwm on\n", dev->minor, __func__); + /* + * if not zero the PWM is limited to a certain time which is + * not supported here + */ + if (data[1] != 0) + return -EINVAL; + return usbdux_pwm_start(dev, s); + case INSN_CONFIG_DISARM: + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: %s: pwm off\n", dev->minor, __func__); + return usbdux_pwm_cancel(dev, s); + case INSN_CONFIG_GET_PWM_STATUS: + /* + * to check if the USB transmission has failed or in case PWM + * was limited to n cycles to check if it has terminated + */ + data[1] = this_usbduxsub->pwm_cmd_running; + return 0; + case INSN_CONFIG_PWM_SET_PERIOD: + dev_dbg(&this_usbduxsub->interface->dev, + "comedi%d: %s: setting period\n", dev->minor, + __func__); + return usbdux_pwm_period(dev, s, data[1]); + case INSN_CONFIG_PWM_GET_PERIOD: + data[1] = this_usbduxsub->pwmPeriod; + return 0; + case INSN_CONFIG_PWM_SET_H_BRIDGE: + /* value in the first byte and the sign in the second for a + relay */ + return usbdux_pwm_pattern(dev, s, + /* the channel number */ + CR_CHAN(insn->chanspec), + /* actual PWM data */ + data[1], + /* just a sign */ + (data[2] != 0)); + case INSN_CONFIG_PWM_GET_H_BRIDGE: + /* values are not kept in this driver, nothing to return */ + return -EINVAL; + } + return -EINVAL; +} + +/* end of PWM */ +/*****************************************************************/ + +static void tidy_up(struct usbduxsub *usbduxsub_tmp) +{ + int i; + + if (!usbduxsub_tmp) + return; + dev_dbg(&usbduxsub_tmp->interface->dev, "comedi_: tiding up\n"); + + /* shows the usb subsystem that the driver is down */ + if (usbduxsub_tmp->interface) + usb_set_intfdata(usbduxsub_tmp->interface, NULL); + + usbduxsub_tmp->probed = 0; + + if (usbduxsub_tmp->urbIn) { + if (usbduxsub_tmp->ai_cmd_running) { + usbduxsub_tmp->ai_cmd_running = 0; + usbduxsub_unlink_InURBs(usbduxsub_tmp); + } + for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) { + kfree(usbduxsub_tmp->urbIn[i]->transfer_buffer); + usbduxsub_tmp->urbIn[i]->transfer_buffer = NULL; + usb_kill_urb(usbduxsub_tmp->urbIn[i]); + usb_free_urb(usbduxsub_tmp->urbIn[i]); + usbduxsub_tmp->urbIn[i] = NULL; + } + kfree(usbduxsub_tmp->urbIn); + usbduxsub_tmp->urbIn = NULL; + } + if (usbduxsub_tmp->urbOut) { + if (usbduxsub_tmp->ao_cmd_running) { + usbduxsub_tmp->ao_cmd_running = 0; + usbduxsub_unlink_OutURBs(usbduxsub_tmp); + } + for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) { + if (usbduxsub_tmp->urbOut[i]->transfer_buffer) { + kfree(usbduxsub_tmp-> + urbOut[i]->transfer_buffer); + usbduxsub_tmp->urbOut[i]->transfer_buffer = + NULL; + } + if (usbduxsub_tmp->urbOut[i]) { + usb_kill_urb(usbduxsub_tmp->urbOut[i]); + usb_free_urb(usbduxsub_tmp->urbOut[i]); + usbduxsub_tmp->urbOut[i] = NULL; + } + } + kfree(usbduxsub_tmp->urbOut); + usbduxsub_tmp->urbOut = NULL; + } + if (usbduxsub_tmp->urbPwm) { + if (usbduxsub_tmp->pwm_cmd_running) { + usbduxsub_tmp->pwm_cmd_running = 0; + usbduxsub_unlink_PwmURBs(usbduxsub_tmp); + } + kfree(usbduxsub_tmp->urbPwm->transfer_buffer); + usbduxsub_tmp->urbPwm->transfer_buffer = NULL; + usb_kill_urb(usbduxsub_tmp->urbPwm); + usb_free_urb(usbduxsub_tmp->urbPwm); + usbduxsub_tmp->urbPwm = NULL; + } + kfree(usbduxsub_tmp->inBuffer); + usbduxsub_tmp->inBuffer = NULL; + kfree(usbduxsub_tmp->insnBuffer); + usbduxsub_tmp->insnBuffer = NULL; + kfree(usbduxsub_tmp->outBuffer); + usbduxsub_tmp->outBuffer = NULL; + kfree(usbduxsub_tmp->dac_commands); + usbduxsub_tmp->dac_commands = NULL; + kfree(usbduxsub_tmp->dux_commands); + usbduxsub_tmp->dux_commands = NULL; + usbduxsub_tmp->ai_cmd_running = 0; + usbduxsub_tmp->ao_cmd_running = 0; + usbduxsub_tmp->pwm_cmd_running = 0; +} + +static void usbdux_firmware_request_complete_handler(const struct firmware *fw, + void *context) +{ + struct usbduxsub *usbduxsub_tmp = context; + struct usb_device *usbdev = usbduxsub_tmp->usbdev; + int ret; + + if (fw == NULL) { + dev_err(&usbdev->dev, + "Firmware complete handler without firmware!\n"); + return; + } + + /* + * we need to upload the firmware here because fw will be + * freed once we've left this function + */ + ret = firmwareUpload(usbduxsub_tmp, fw->data, fw->size); + + if (ret) { + dev_err(&usbdev->dev, + "Could not upload firmware (err=%d)\n", ret); + goto out; + } + comedi_usb_auto_config(usbdev, BOARDNAME); +out: + release_firmware(fw); +} + +/* allocate memory for the urbs and initialise them */ +static int usbduxsigma_probe(struct usb_interface *uinterf, + const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev(uinterf); + struct device *dev = &uinterf->dev; + int i; + int index; + int ret; + + dev_dbg(dev, "comedi_: usbdux_: " + "finding a free structure for the usb-device\n"); + + down(&start_stop_sem); + /* look for a free place in the usbdux array */ + index = -1; + for (i = 0; i < NUMUSBDUX; i++) { + if (!(usbduxsub[i].probed)) { + index = i; + break; + } + } + + /* no more space */ + if (index == -1) { + dev_err(dev, "Too many usbduxsigma-devices connected.\n"); + up(&start_stop_sem); + return -EMFILE; + } + dev_dbg(dev, "comedi_: usbdux: " + "usbduxsub[%d] is ready to connect to comedi.\n", index); + + sema_init(&(usbduxsub[index].sem), 1); + /* save a pointer to the usb device */ + usbduxsub[index].usbdev = udev; + + /* save the interface itself */ + usbduxsub[index].interface = uinterf; + /* get the interface number from the interface */ + usbduxsub[index].ifnum = uinterf->altsetting->desc.bInterfaceNumber; + /* hand the private data over to the usb subsystem */ + /* will be needed for disconnect */ + usb_set_intfdata(uinterf, &(usbduxsub[index])); + + dev_dbg(dev, "comedi_: usbdux: ifnum=%d\n", usbduxsub[index].ifnum); + + /* test if it is high speed (USB 2.0) */ + usbduxsub[index].high_speed = + (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH); + + /* create space for the commands of the DA converter */ + usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); + if (!usbduxsub[index].dac_commands) { + dev_err(dev, "comedi_: usbduxsigma: " + "error alloc space for dac commands\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + /* create space for the commands going to the usb device */ + usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); + if (!usbduxsub[index].dux_commands) { + dev_err(dev, "comedi_: usbduxsigma: " + "error alloc space for dux commands\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + /* create space for the in buffer and set it to zero */ + usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!(usbduxsub[index].inBuffer)) { + dev_err(dev, "comedi_: usbduxsigma: " + "could not alloc space for inBuffer\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + /* create space of the instruction buffer */ + usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); + if (!(usbduxsub[index].insnBuffer)) { + dev_err(dev, "comedi_: usbduxsigma: " + "could not alloc space for insnBuffer\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + /* create space for the outbuffer */ + usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!(usbduxsub[index].outBuffer)) { + dev_err(dev, "comedi_: usbduxsigma: " + "could not alloc space for outBuffer\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + /* setting to alternate setting 3: enabling iso ep and bulk ep. */ + i = usb_set_interface(usbduxsub[index].usbdev, + usbduxsub[index].ifnum, 3); + if (i < 0) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "could not set alternate setting 3 in high speed.\n", + index); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENODEV; + } + if (usbduxsub[index].high_speed) + usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSHIGH; + else + usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL; + + usbduxsub[index].urbIn = + kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers, + GFP_KERNEL); + if (!(usbduxsub[index].urbIn)) { + dev_err(dev, "comedi_: usbduxsigma: " + "Could not alloc. urbIn array\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + for (i = 0; i < usbduxsub[index].numOfInBuffers; i++) { + /* one frame: 1ms */ + usbduxsub[index].urbIn[i] = usb_alloc_urb(1, GFP_KERNEL); + if (usbduxsub[index].urbIn[i] == NULL) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "Could not alloc. urb(%d)\n", index, i); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + usbduxsub[index].urbIn[i]->dev = usbduxsub[index].usbdev; + /* will be filled later with a pointer to the comedi-device */ + /* and ONLY then the urb should be submitted */ + usbduxsub[index].urbIn[i]->context = NULL; + usbduxsub[index].urbIn[i]->pipe = + usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP); + usbduxsub[index].urbIn[i]->transfer_flags = URB_ISO_ASAP; + usbduxsub[index].urbIn[i]->transfer_buffer = + kzalloc(SIZEINBUF, GFP_KERNEL); + if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "could not alloc. transb.\n", index); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + usbduxsub[index].urbIn[i]->complete = usbduxsub_ai_IsocIrq; + usbduxsub[index].urbIn[i]->number_of_packets = 1; + usbduxsub[index].urbIn[i]->transfer_buffer_length = SIZEINBUF; + usbduxsub[index].urbIn[i]->iso_frame_desc[0].offset = 0; + usbduxsub[index].urbIn[i]->iso_frame_desc[0].length = + SIZEINBUF; + } + + /* out */ + if (usbduxsub[index].high_speed) + usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSHIGH; + else + usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL; + + usbduxsub[index].urbOut = + kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers, + GFP_KERNEL); + if (!(usbduxsub[index].urbOut)) { + dev_err(dev, "comedi_: usbduxsigma: " + "Could not alloc. urbOut array\n"); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + for (i = 0; i < usbduxsub[index].numOfOutBuffers; i++) { + /* one frame: 1ms */ + usbduxsub[index].urbOut[i] = usb_alloc_urb(1, GFP_KERNEL); + if (usbduxsub[index].urbOut[i] == NULL) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "Could not alloc. urb(%d)\n", index, i); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + usbduxsub[index].urbOut[i]->dev = usbduxsub[index].usbdev; + /* will be filled later with a pointer to the comedi-device */ + /* and ONLY then the urb should be submitted */ + usbduxsub[index].urbOut[i]->context = NULL; + usbduxsub[index].urbOut[i]->pipe = + usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP); + usbduxsub[index].urbOut[i]->transfer_flags = URB_ISO_ASAP; + usbduxsub[index].urbOut[i]->transfer_buffer = + kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "could not alloc. transb.\n", index); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + usbduxsub[index].urbOut[i]->complete = usbduxsub_ao_IsocIrq; + usbduxsub[index].urbOut[i]->number_of_packets = 1; + usbduxsub[index].urbOut[i]->transfer_buffer_length = + SIZEOUTBUF; + usbduxsub[index].urbOut[i]->iso_frame_desc[0].offset = 0; + usbduxsub[index].urbOut[i]->iso_frame_desc[0].length = + SIZEOUTBUF; + if (usbduxsub[index].high_speed) { + /* uframes */ + usbduxsub[index].urbOut[i]->interval = 8; + } else { + /* frames */ + usbduxsub[index].urbOut[i]->interval = 1; + } + } + + /* pwm */ + if (usbduxsub[index].high_speed) { + /* max bulk ep size in high speed */ + usbduxsub[index].sizePwmBuf = 512; + usbduxsub[index].urbPwm = usb_alloc_urb(0, GFP_KERNEL); + if (usbduxsub[index].urbPwm == NULL) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "Could not alloc. pwm urb\n", index); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + usbduxsub[index].urbPwm->transfer_buffer = + kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL); + if (!(usbduxsub[index].urbPwm->transfer_buffer)) { + dev_err(dev, "comedi_: usbduxsigma%d: " + "could not alloc. transb. for pwm\n", index); + tidy_up(&(usbduxsub[index])); + up(&start_stop_sem); + return -ENOMEM; + } + } else { + usbduxsub[index].urbPwm = NULL; + usbduxsub[index].sizePwmBuf = 0; + } + + usbduxsub[index].ai_cmd_running = 0; + usbduxsub[index].ao_cmd_running = 0; + usbduxsub[index].pwm_cmd_running = 0; + + /* we've reached the bottom of the function */ + usbduxsub[index].probed = 1; + up(&start_stop_sem); + + ret = request_firmware_nowait(THIS_MODULE, + FW_ACTION_HOTPLUG, + "usbduxsigma_firmware.bin", + &udev->dev, + GFP_KERNEL, + usbduxsub + index, + usbdux_firmware_request_complete_handler + ); + + if (ret) { + dev_err(dev, "Could not load firmware (err=%d)\n", ret); + return ret; + } + + dev_info(dev, "comedi_: successfully initialised.\n"); + /* success */ + return 0; +} + +static void usbduxsigma_disconnect(struct usb_interface *intf) +{ + struct usbduxsub *usbduxsub_tmp = usb_get_intfdata(intf); + struct usb_device *udev = interface_to_usbdev(intf); + + if (!usbduxsub_tmp) { + dev_err(&intf->dev, + "comedi_: disconnect called with null pointer.\n"); + return; + } + if (usbduxsub_tmp->usbdev != udev) { + dev_err(&intf->dev, "comedi_: BUG! wrong ptr!\n"); + return; + } + if (usbduxsub_tmp->ai_cmd_running) + /* we are still running a command */ + usbdux_ai_stop(usbduxsub_tmp, 1); + if (usbduxsub_tmp->ao_cmd_running) + /* we are still running a command */ + usbdux_ao_stop(usbduxsub_tmp, 1); + comedi_usb_auto_unconfig(udev); + down(&start_stop_sem); + down(&usbduxsub_tmp->sem); + tidy_up(usbduxsub_tmp); + up(&usbduxsub_tmp->sem); + up(&start_stop_sem); + dev_info(&intf->dev, "comedi_: disconnected from the usb\n"); +} + +/* is called when comedi-config is called */ +static int usbduxsigma_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + int ret; + int index; + int i; + struct usbduxsub *udev; + + int offset; + + struct comedi_subdevice *s = NULL; + dev->private = NULL; + + down(&start_stop_sem); + /* find a valid device which has been detected by the probe function of + * the usb */ + index = -1; + for (i = 0; i < NUMUSBDUX; i++) { + if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) { + index = i; + break; + } + } + + if (index < 0) { + printk(KERN_ERR "comedi%d: usbduxsigma: error: attach failed," + "dev not connected to the usb bus.\n", dev->minor); + up(&start_stop_sem); + return -ENODEV; + } + + udev = &usbduxsub[index]; + down(&udev->sem); + /* pointer back to the corresponding comedi device */ + udev->comedidev = dev; + + /* trying to upload the firmware into the FX2 */ + if (comedi_aux_data(it->options, 0) && + it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { + firmwareUpload(udev, comedi_aux_data(it->options, 0), + it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]); + } + + dev->board_name = BOARDNAME; + + /* set number of subdevices */ + if (udev->high_speed) { + /* with pwm */ + dev->n_subdevices = 4; + } else { + /* without pwm */ + dev->n_subdevices = 3; + } + + /* allocate space for the subdevices */ + ret = alloc_subdevices(dev, dev->n_subdevices); + if (ret < 0) { + dev_err(&udev->interface->dev, + "comedi%d: no space for subdev\n", dev->minor); + up(&start_stop_sem); + return ret; + } + + /* private structure is also simply the usb-structure */ + dev->private = udev; + + /* the first subdevice is the A/D converter */ + s = dev->subdevices + SUBDEV_AD; + /* the URBs get the comedi subdevice */ + /* which is responsible for reading */ + /* this is the subdevice which reads data */ + dev->read_subdev = s; + /* the subdevice receives as private structure the */ + /* usb-structure */ + s->private = NULL; + /* analog input */ + s->type = COMEDI_SUBD_AI; + /* readable and ref is to ground, 32 bit wide data! */ + s->subdev_flags = SDF_READABLE | SDF_GROUND | + SDF_CMD_READ | SDF_LSAMPL; + /* 16 A/D channels */ + s->n_chan = NUMCHANNELS; + /* length of the channellist */ + s->len_chanlist = NUMCHANNELS; + /* callback functions */ + s->insn_read = usbdux_ai_insn_read; + s->do_cmdtest = usbdux_ai_cmdtest; + s->do_cmd = usbdux_ai_cmd; + s->cancel = usbdux_ai_cancel; + /* max value from the A/D converter (24bit) */ + s->maxdata = 0x00FFFFFF; + /* range table to convert to physical units */ + s->range_table = (&range_usbdux_ai_range); + + /* analog out */ + s = dev->subdevices + SUBDEV_DA; + /* analog out */ + s->type = COMEDI_SUBD_AO; + /* backward pointer */ + dev->write_subdev = s; + /* the subdevice receives as private structure the */ + /* usb-structure */ + s->private = NULL; + /* are writable */ + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; + /* 4 channels */ + s->n_chan = 4; + /* length of the channellist */ + s->len_chanlist = 4; + /* 8 bit resolution */ + s->maxdata = 0x00ff; + /* unipolar range */ + s->range_table = (&range_usbdux_ao_range); + /* callback */ + s->do_cmdtest = usbdux_ao_cmdtest; + s->do_cmd = usbdux_ao_cmd; + s->cancel = usbdux_ao_cancel; + s->insn_read = usbdux_ao_insn_read; + s->insn_write = usbdux_ao_insn_write; + + /* digital I/O */ + s = dev->subdevices + SUBDEV_DIO; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + /* 8 external and 16 internal channels */ + s->n_chan = 24; + s->maxdata = 1; + s->range_table = (&range_digital); + s->insn_bits = usbdux_dio_insn_bits; + s->insn_config = usbdux_dio_insn_config; + /* we don't use it */ + s->private = NULL; + + if (udev->high_speed) { + /* timer / pwm */ + s = dev->subdevices + SUBDEV_PWM; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; + s->n_chan = 8; + /* this defines the max duty cycle resolution */ + s->maxdata = udev->sizePwmBuf; + s->insn_write = usbdux_pwm_write; + s->insn_read = usbdux_pwm_read; + s->insn_config = usbdux_pwm_config; + usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); + } + /* finally decide that it's attached */ + udev->attached = 1; + + up(&udev->sem); + + up(&start_stop_sem); + + offset = usbdux_getstatusinfo(dev, 0); + if (offset < 0) + dev_err(&udev->interface->dev, + "Communication to USBDUXSIGMA failed!" + "Check firmware and cabling."); + + dev_info(&udev->interface->dev, + "comedi%d: attached, ADC_zero = %x", dev->minor, offset); + + return 0; +} + +static int usbduxsigma_detach(struct comedi_device *dev) +{ + struct usbduxsub *usbduxsub_tmp; + + if (!dev) { + printk(KERN_ERR + "comedi? usbduxsigma detach: dev=NULL\n"); + return -EFAULT; + } + + usbduxsub_tmp = dev->private; + if (!usbduxsub_tmp) { + printk(KERN_ERR + "comedi?: usbduxsigma detach: private=NULL\n"); + return -EFAULT; + } + + dev_dbg(&usbduxsub_tmp->interface->dev, + "comedi%d: detach usb device\n", + dev->minor); + + down(&usbduxsub_tmp->sem); + /* Don't allow detach to free the private structure */ + /* It's one entry of of usbduxsub[] */ + dev->private = NULL; + usbduxsub_tmp->attached = 0; + usbduxsub_tmp->comedidev = NULL; + dev_info(&usbduxsub_tmp->interface->dev, + "comedi%d: successfully detached.\n", dev->minor); + up(&usbduxsub_tmp->sem); + return 0; +} + +/* main driver struct */ +static struct comedi_driver driver_usbduxsigma = { + .driver_name = "usbduxsigma", + .module = THIS_MODULE, + .attach = usbduxsigma_attach, + .detach = usbduxsigma_detach, +}; + +/* Table with the USB-devices */ +static const struct usb_device_id usbduxsigma_table[] = { + {USB_DEVICE(0x13d8, 0x0020)}, + {USB_DEVICE(0x13d8, 0x0021)}, + {USB_DEVICE(0x13d8, 0x0022)}, + {} /* Terminating entry */ +}; + +MODULE_DEVICE_TABLE(usb, usbduxsigma_table); + +/* The usbduxsub-driver */ +static struct usb_driver usbduxsigma_driver = { + .name = BOARDNAME, + .probe = usbduxsigma_probe, + .disconnect = usbduxsigma_disconnect, + .id_table = usbduxsigma_table, +}; + +/* Can't use the nice macro as I have also to initialise the USB */ +/* subsystem: */ +/* registering the usb-system _and_ the comedi-driver */ +static int __init init_usbduxsigma(void) +{ + printk(KERN_INFO KBUILD_MODNAME ": " + DRIVER_VERSION ":" DRIVER_DESC "\n"); + usb_register(&usbduxsigma_driver); + comedi_driver_register(&driver_usbduxsigma); + return 0; +} + +/* deregistering the comedi driver and the usb-subsystem */ +static void __exit exit_usbduxsigma(void) +{ + comedi_driver_unregister(&driver_usbduxsigma); + usb_deregister(&usbduxsigma_driver); +} + +module_init(init_usbduxsigma); +module_exit(exit_usbduxsigma); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); From 1dac4186bcc663cb8c2bcc59481aea8fe9124a6c Mon Sep 17 00:00:00 2001 From: edwin_rong Date: Tue, 19 Jul 2011 17:10:35 +0800 Subject: [PATCH 0017/1519] Staging: add driver for Realtek RTS5139 cardreader This driver is used for Realtek RTS5139 USB cardreader, which supports many cards, such as SD, MS, XD series cards. Signed-off-by: edwin_rong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/rts5139/Kconfig | 16 + drivers/staging/rts5139/Makefile | 37 + drivers/staging/rts5139/TODO | 5 + drivers/staging/rts5139/debug.h | 46 + drivers/staging/rts5139/ms.c | 4190 ++++++++++++++++++++ drivers/staging/rts5139/ms.h | 263 ++ drivers/staging/rts5139/ms_mg.c | 642 +++ drivers/staging/rts5139/ms_mg.h | 41 + drivers/staging/rts5139/rts51x.c | 967 +++++ drivers/staging/rts5139/rts51x.h | 205 + drivers/staging/rts5139/rts51x_card.c | 986 +++++ drivers/staging/rts5139/rts51x_card.h | 881 ++++ drivers/staging/rts5139/rts51x_chip.c | 1167 ++++++ drivers/staging/rts5139/rts51x_chip.h | 904 +++++ drivers/staging/rts5139/rts51x_fop.c | 298 ++ drivers/staging/rts5139/rts51x_fop.h | 62 + drivers/staging/rts5139/rts51x_scsi.c | 2233 +++++++++++ drivers/staging/rts5139/rts51x_scsi.h | 162 + drivers/staging/rts5139/rts51x_sys.h | 54 + drivers/staging/rts5139/rts51x_transport.c | 1000 +++++ drivers/staging/rts5139/rts51x_transport.h | 80 + drivers/staging/rts5139/sd.c | 3400 ++++++++++++++++ drivers/staging/rts5139/sd.h | 304 ++ drivers/staging/rts5139/sd_cprm.c | 1215 ++++++ drivers/staging/rts5139/sd_cprm.h | 54 + drivers/staging/rts5139/trace.h | 137 + drivers/staging/rts5139/xd.c | 2254 +++++++++++ drivers/staging/rts5139/xd.h | 193 + 30 files changed, 21799 insertions(+) create mode 100644 drivers/staging/rts5139/Kconfig create mode 100644 drivers/staging/rts5139/Makefile create mode 100644 drivers/staging/rts5139/TODO create mode 100644 drivers/staging/rts5139/debug.h create mode 100644 drivers/staging/rts5139/ms.c create mode 100644 drivers/staging/rts5139/ms.h create mode 100644 drivers/staging/rts5139/ms_mg.c create mode 100644 drivers/staging/rts5139/ms_mg.h create mode 100644 drivers/staging/rts5139/rts51x.c create mode 100644 drivers/staging/rts5139/rts51x.h create mode 100644 drivers/staging/rts5139/rts51x_card.c create mode 100644 drivers/staging/rts5139/rts51x_card.h create mode 100644 drivers/staging/rts5139/rts51x_chip.c create mode 100644 drivers/staging/rts5139/rts51x_chip.h create mode 100644 drivers/staging/rts5139/rts51x_fop.c create mode 100644 drivers/staging/rts5139/rts51x_fop.h create mode 100644 drivers/staging/rts5139/rts51x_scsi.c create mode 100644 drivers/staging/rts5139/rts51x_scsi.h create mode 100644 drivers/staging/rts5139/rts51x_sys.h create mode 100644 drivers/staging/rts5139/rts51x_transport.c create mode 100644 drivers/staging/rts5139/rts51x_transport.h create mode 100644 drivers/staging/rts5139/sd.c create mode 100644 drivers/staging/rts5139/sd.h create mode 100644 drivers/staging/rts5139/sd_cprm.c create mode 100644 drivers/staging/rts5139/sd_cprm.h create mode 100644 drivers/staging/rts5139/trace.h create mode 100644 drivers/staging/rts5139/xd.c create mode 100644 drivers/staging/rts5139/xd.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 06c9081d596..a097763529f 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -64,6 +64,8 @@ source "drivers/staging/rtl8712/Kconfig" source "drivers/staging/rts_pstor/Kconfig" +source "drivers/staging/rts5139/Kconfig" + source "drivers/staging/frontier/Kconfig" source "drivers/staging/pohmelfs/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index f3c5e33bb26..a84a6b331b3 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_R8712U) += rtl8712/ obj-$(CONFIG_RTS_PSTOR) += rts_pstor/ +obj-$(CONFIG_RTS5139) += rts5139/ obj-$(CONFIG_SPECTRA) += spectra/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_POHMELFS) += pohmelfs/ diff --git a/drivers/staging/rts5139/Kconfig b/drivers/staging/rts5139/Kconfig new file mode 100644 index 00000000000..f940e516945 --- /dev/null +++ b/drivers/staging/rts5139/Kconfig @@ -0,0 +1,16 @@ +config RTS5139 + tristate "Realtek RTS5139 USB card reader support" + depends on USB_SUPPORT && SCSI + help + Say Y here to include driver code to support the Realtek + RTS5139 USB card readers. + + If this driver is compiled as a module, it will be named rts5139. + +config RTS5139_DEBUG + bool "Realtek RTS5139 Card Reader verbose debug" + depends on RTS5139 + help + Say Y here in order to have the rts5139 code generate + verbose debugging messages. + diff --git a/drivers/staging/rts5139/Makefile b/drivers/staging/rts5139/Makefile new file mode 100644 index 00000000000..82b8958e8d3 --- /dev/null +++ b/drivers/staging/rts5139/Makefile @@ -0,0 +1,37 @@ +# Driver for Realtek RTS51xx USB card reader +# +# Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, see . +# +# Author: +# wwang (wei_wang@realsil.com.cn) +# No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China +# Maintainer: +# Edwin Rong (edwin_rong@realsil.com.cn) +# No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China +# +# Makefile for the RTS51xx USB Card Reader drivers. +# + +TARGET_MODULE := rts5139 + +EXTRA_CFLAGS := -Idrivers/scsi -I$(PWD) + +obj-m += $(TARGET_MODULE).o + +common-obj := rts51x_transport.o rts51x_scsi.o rts51x_fop.o + +$(TARGET_MODULE)-objs := $(common-obj) rts51x.o rts51x_chip.o rts51x_card.o \ + xd.o sd.o ms.o sd_cprm.o ms_mg.o diff --git a/drivers/staging/rts5139/TODO b/drivers/staging/rts5139/TODO new file mode 100644 index 00000000000..4bde726ea5f --- /dev/null +++ b/drivers/staging/rts5139/TODO @@ -0,0 +1,5 @@ +TODO: +- support more USB card reader of Realtek family +- use kernel coding style +- checkpatch.pl fixes + diff --git a/drivers/staging/rts5139/debug.h b/drivers/staging/rts5139/debug.h new file mode 100644 index 00000000000..73dec133a1b --- /dev/null +++ b/drivers/staging/rts5139/debug.h @@ -0,0 +1,46 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_DEBUG_H +#define __RTS51X_DEBUG_H + +#include + +#define RTS51X_TIP "rts51x: " + +#ifdef CONFIG_RTS5139_DEBUG +#define RTS51X_DEBUGP(x...) printk(KERN_DEBUG RTS51X_TIP x) +#define RTS51X_DEBUGPN(x...) printk(KERN_DEBUG x) +#define RTS51X_DEBUGPX(x...) printk(x) +#define RTS51X_DEBUG(x) x +#else +#define RTS51X_DEBUGP(x...) +#define RTS51X_DEBUGPN(x...) +#define RTS51X_DEBUGPX(x...) +#define RTS51X_DEBUG(x) +#endif + +#endif /* __RTS51X_DEBUG_H */ diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c new file mode 100644 index 00000000000..63f191dd031 --- /dev/null +++ b/drivers/staging/rts5139/ms.c @@ -0,0 +1,4190 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_transport.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "ms.h" + +static inline void ms_set_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct ms_info *ms_card = &(chip->ms_card); + + ms_card->err_code = err_code; +} + +static inline int ms_check_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct ms_info *ms_card = &(chip->ms_card); + + return (ms_card->err_code == err_code); +} + +static int ms_parse_err_code(struct rts51x_chip *chip) +{ + TRACE_RET(chip, STATUS_FAIL); +} + +static int ms_transfer_tpc(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, + u8 cnt, u8 cfg) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + RTS51X_DEBUGP("ms_transfer_tpc: tpc = 0x%x\n", tpc); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | trans_mode); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + rts51x_add_cmd(chip, READ_REG_CMD, MS_TRANS_CFG, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 2, 5000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + rts51x_clear_ms_error(chip); + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + if (!(tpc & 0x08)) { /* Read Packet */ + /* Check CRC16 & Ready Timeout */ + if (chip->rsp_buf[1] & MS_CRC16_ERR) { + ms_set_err_code(chip, MS_CRC16_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + } else { /* Write Packet */ + if (CHK_MSPRO(ms_card) && !(chip->rsp_buf[1] & 0x80)) { + if (chip->rsp_buf[1] & (MS_INT_ERR | MS_INT_CMDNK)) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + } + } + + /* Check Timeout of Ready Signal */ + if (chip->rsp_buf[1] & MS_RDY_TIMEOUT) { + rts51x_clear_ms_error(chip); + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + return STATUS_SUCCESS; +} + +int ms_transfer_data(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, + u16 sec_cnt, u8 cfg, int mode_2k, int use_sg, void *buf, + int buf_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 val, err_code = 0, flag = 0; + enum dma_data_direction dir; + unsigned int pipe; + + if (!buf || !buf_len) + TRACE_RET(chip, STATUS_FAIL); + + if (trans_mode == MS_TM_AUTO_READ) { + pipe = RCV_BULK_PIPE(chip); + dir = DMA_FROM_DEVICE; + flag = MODE_CDIR; + err_code = MS_FLASH_READ_ERROR; + } else if (trans_mode == MS_TM_AUTO_WRITE) { + pipe = SND_BULK_PIPE(chip); + dir = DMA_TO_DEVICE; + flag = MODE_CDOR; + err_code = MS_FLASH_WRITE_ERROR; + } else { + TRACE_RET(chip, STATUS_FAIL); + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, + (u8) (sec_cnt >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, + (u8) sec_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + + if (mode_2k) + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, MS_2K_SECTOR_MODE, + MS_2K_SECTOR_MODE); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, MS_2K_SECTOR_MODE, + 0); + + trans_dma_enable(dir, chip, sec_cnt * 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | trans_mode); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, flag | STAGE_MS_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_rcc(chip, pipe, buf, buf_len, use_sg, NULL, + 15000, flag); + if (retval != STATUS_SUCCESS) { + ms_set_err_code(chip, err_code); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + + retval = rts51x_get_rsp(chip, 3, 15000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + ms_set_err_code(chip, err_code); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + ms_card->last_rw_int = val = chip->rsp_buf[1]; + if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +int ms_write_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, + int data_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + + if (!data || (data_len < cnt)) + TRACE_RET(chip, STATUS_ERROR); + + rts51x_init_cmd(chip); + + for (i = 0; i < cnt; i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, 0xFF, + data[i]); + } + if (cnt % 2) + rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, + 0xFF, 0xFF); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_WRITE_BYTES); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, 5000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + u8 val = 0; + + rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); + RTS51X_DEBUGP("MS_TRANS_CFG: 0x%02x\n", val); + + rts51x_clear_ms_error(chip); + + if (!(tpc & 0x08)) { /* Read Packet */ + /* Check CRC16 & Ready Timeout */ + if (val & MS_CRC16_ERR) { + ms_set_err_code(chip, MS_CRC16_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + } else { /* Write Packet */ + if (CHK_MSPRO(ms_card) && !(val & 0x80)) { + if (val & (MS_INT_ERR | MS_INT_CMDNK)) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, + ms_parse_err_code(chip)); + } + } + } + + /* Check Timeout of Ready Signal */ + if (val & MS_RDY_TIMEOUT) { + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + return STATUS_SUCCESS; +} + +int ms_read_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, + int data_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + + if (!data) + TRACE_RET(chip, STATUS_ERROR); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_READ_BYTES); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + for (i = 0; i < data_len - 1; i++) + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + i, 0, 0); + + if (data_len % 2) + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + data_len, 0, + 0); + else + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + data_len - 1, + 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, data_len + 1, 5000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + u8 val = 0; + + rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); + RTS51X_DEBUGP("MS_TRANS_CFG: 0x%02x\n", val); + + rts51x_clear_ms_error(chip); + + if (!(tpc & 0x08)) { /* Read Packet */ + /* Check CRC16 & Ready Timeout */ + if (val & MS_CRC16_ERR) { + ms_set_err_code(chip, MS_CRC16_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + } else { /* Write Packet */ + if (CHK_MSPRO(ms_card) && !(val & 0x80)) { + if (val & (MS_INT_ERR | MS_INT_CMDNK)) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, + ms_parse_err_code(chip)); + } + } + } + + /* Check Timeout of Ready Signal */ + if (val & MS_RDY_TIMEOUT) { + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + ms_set_err_code(chip, MS_TO_ERROR); + TRACE_RET(chip, ms_parse_err_code(chip)); + } + + rts51x_read_rsp_buf(chip, 1, data, data_len); + + return STATUS_SUCCESS; +} + +int ms_set_rw_reg_addr(struct rts51x_chip *chip, + u8 read_start, u8 read_cnt, u8 write_start, u8 write_cnt) +{ + int retval, i; + u8 data[4]; + + data[0] = read_start; + data[1] = read_cnt; + data[2] = write_start; + data[3] = write_cnt; + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, SET_RW_REG_ADRS, 4, NO_WAIT_INT, data, + 4); + if (retval == STATUS_SUCCESS) + return STATUS_SUCCESS; + rts51x_clear_ms_error(chip); + } + + TRACE_RET(chip, STATUS_FAIL); +} + +static int ms_send_cmd(struct rts51x_chip *chip, u8 cmd, u8 cfg) +{ + u8 data[2]; + + data[0] = cmd; + data[1] = 0; + + return ms_write_bytes(chip, PRO_SET_CMD, 1, cfg, data, 1); +} + +static int ms_set_cmd(struct rts51x_chip *chip, + u8 read_start, u8 read_count, + u8 write_start, u8 write_count, + u8 cmd, u8 cfg, u8 *data, int data_len, u8 *int_stat) +{ + int retval, i; + u8 val; + + if (!data || (data_len <= 0) || (data_len > 128)) { + RTS51X_DEBUGP("ms_set_cmd (data_len = %d)\n", data_len); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = + ms_set_rw_reg_addr(chip, read_start, read_count, write_start, + write_count); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, WRITE_REG, write_count, NO_WAIT_INT, + data, data_len); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + ms_set_err_code(chip, MS_NO_ERROR); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = ms_send_cmd(chip, cmd, WAIT_INT); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + /* GET_INT Register */ + ms_set_err_code(chip, MS_NO_ERROR); + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (int_stat) + *int_stat = val; + + return STATUS_SUCCESS; +} + +#ifdef MS_SPEEDUP +static int ms_auto_set_cmd(struct rts51x_chip *chip, + u8 read_start, u8 read_count, + u8 write_start, u8 write_count, + u8 cmd, u8 cfg, u8 *data, int data_len, + u8 *int_stat) +{ + int retval; + int i; + + if (!data || (data_len <= 0) || (data_len > 128)) { + RTS51X_DEBUGP("ms_auto_set_cmd (data_len = %d)\n", data_len); + TRACE_RET(chip, STATUS_FAIL); + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_READ_START, 0xFF, read_start); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_READ_COUNT, 0xFF, read_count); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_WRITE_START, 0xFF, write_start); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_WRITE_COUNT, 0xFF, write_count); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_COMMAND, 0xFF, cmd); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + for (i = 0; i < data_len; i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, 0xFF, + data[i]); + } + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_SET_CMD); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR | STAGE_MS_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 3, 5000); + + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + if (int_stat) + *int_stat = chip->rsp_buf[2]; + + return STATUS_SUCCESS; +} +#endif + +static int ms_set_init_para(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + if (CHK_HG8BIT(ms_card)) { + if (chip->asic_code) + ms_card->ms_clock = chip->option.asic_ms_hg_clk; + else + ms_card->ms_clock = chip->option.fpga_ms_hg_clk; + } else if (CHK_MSPRO(ms_card) || CHK_MS4BIT(ms_card)) { + if (chip->asic_code) + ms_card->ms_clock = chip->option.asic_ms_4bit_clk; + else + ms_card->ms_clock = chip->option.fpga_ms_4bit_clk; + } else { + if (chip->asic_code) + ms_card->ms_clock = 38; + else + ms_card->ms_clock = CLK_40; + } + + retval = switch_clock(chip, ms_card->ms_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_select_card(chip, MS_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int ms_switch_clock(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + retval = rts51x_select_card(chip, MS_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = switch_clock(chip, ms_card->ms_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static void ms_pull_ctl_disable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); + } +} + +static void ms_pull_ctl_enable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); + } +} + +static int ms_prepare_reset(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + ms_card->ms_type = 0; + ms_card->check_ms_flow = 0; + ms_card->switch_8bit_fail = 0; + ms_card->delay_write.delay_write_flag = 0; + + ms_card->pro_under_formatting = 0; + + rts51x_init_cmd(chip); + + if (chip->asic_code) { + ms_pull_ctl_enable(chip); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, + FPGA_MS_PULL_CTL_BIT | 0x20, 0); + } + /* Tri-state MS output */ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); + + if (!chip->option.FT2_fast_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + } + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!chip->option.FT2_fast_mode) { + wait_timeout(250); + + card_power_on(chip, MS_CARD); + wait_timeout(150); + +#ifdef SUPPORT_OCP + rts51x_get_card_status(chip, &(chip->card_status)); + /* get OCP status */ + chip->ocp_stat = (chip->card_status >> 4) & 0x03; + + if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { + RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", + chip->ocp_stat); + TRACE_RET(chip, STATUS_FAIL); + } +#endif + } + + rts51x_init_cmd(chip); + + /* Enable MS Output */ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, + MS_OUTPUT_EN); + + /* Reset Registers */ + if (chip->asic_code) + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, 0xFF, + SAMPLE_TIME_RISING | PUSH_TIME_DEFAULT | + NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, 0xFF, + SAMPLE_TIME_FALLING | PUSH_TIME_DEFAULT | + NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, + NO_WAIT_INT | NO_AUTO_READ_INT_REG); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return ms_set_init_para(chip); +} + +static int ms_identify_media_type(struct rts51x_chip *chip, int switch_8bit_bus) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 val; + + retval = ms_set_rw_reg_addr(chip, Pro_StatusReg, 6, SystemParm, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* Get Register form MS-PRO card */ + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_transfer_tpc(chip, MS_TM_READ_BYTES, READ_REG, 6, + NO_WAIT_INT); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_READ_REG(chip, PPBUF_BASE2 + 2, &val); + RTS51X_DEBUGP("Type register: 0x%x\n", val); + if (val != 0x01) { + if (val != 0x02) + ms_card->check_ms_flow = 1; + TRACE_RET(chip, STATUS_FAIL); + } + /* Category Register */ + RTS51X_READ_REG(chip, PPBUF_BASE2 + 4, &val); + RTS51X_DEBUGP("Category register: 0x%x\n", val); + if (val != 0) { + ms_card->check_ms_flow = 1; + TRACE_RET(chip, STATUS_FAIL); + } + /* Class Register */ + RTS51X_READ_REG(chip, PPBUF_BASE2 + 5, &val); + RTS51X_DEBUGP("Class register: 0x%x\n", val); + if (val == 0) { + RTS51X_READ_REG(chip, PPBUF_BASE2, &val); + if (val & WRT_PRTCT) + chip->card_wp |= MS_CARD; + else + chip->card_wp &= ~MS_CARD; + } else if ((val == 0x01) || (val == 0x02) || (val == 0x03)) { + chip->card_wp |= MS_CARD; + } else { + ms_card->check_ms_flow = 1; + TRACE_RET(chip, STATUS_FAIL); + } + + ms_card->ms_type |= TYPE_MSPRO; + + /* Check MSPro-HG Card, use IF Mode Register to distinguish */ + RTS51X_READ_REG(chip, PPBUF_BASE2 + 3, &val); + RTS51X_DEBUGP("IF Mode register: 0x%x\n", val); + if (val == 0) { + ms_card->ms_type &= 0x0F; + } else if (val == 7) { + if (switch_8bit_bus) + ms_card->ms_type |= MS_HG; + else + ms_card->ms_type &= 0x0F; + } else { + TRACE_RET(chip, STATUS_FAIL); + } + + /* end Procedure to identify Media Type */ + return STATUS_SUCCESS; +} + +static int ms_confirm_cpu_startup(struct rts51x_chip *chip) +{ + int retval, i, k; + u8 val; + + /* Confirm CPU StartUp */ + k = 0; + do { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, + 1); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + if (k > 100) + TRACE_RET(chip, STATUS_FAIL); + k++; + wait_timeout(100); + } while (!(val & INT_REG_CED)); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + if (val & INT_REG_ERR) { + if (val & INT_REG_CMDNK) { /* CMDNK = 1 */ + chip->card_wp |= (MS_CARD); + } else { /* CMDNK = 0 */ + TRACE_RET(chip, STATUS_FAIL); + } + } + /*-- end confirm CPU startup */ + + return STATUS_SUCCESS; +} + +static int ms_switch_parallel_bus(struct rts51x_chip *chip) +{ + int retval, i; + u8 data[2]; + + data[0] = PARALLEL_4BIT_IF; + data[1] = 0; + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, WRITE_REG, 1, NO_WAIT_INT, data, 2); + if (retval == STATUS_SUCCESS) + break; + } + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int ms_switch_8bit_bus(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 data[2]; + + data[0] = PARALLEL_8BIT_IF; + data[1] = 0; + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, WRITE_REG, 1, NO_WAIT_INT, data, 2); + if (retval == STATUS_SUCCESS) + break; + } + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_WRITE_REG(chip, MS_CFG, 0x98, + MS_BUS_WIDTH_8 | SAMPLE_TIME_FALLING); + ms_card->ms_type |= MS_8BIT; + + retval = ms_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, + NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int ms_pro_reset_flow(struct rts51x_chip *chip, int switch_8bit_bus) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + + for (i = 0; i < 3; i++) { + retval = ms_prepare_reset(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_identify_media_type(chip, switch_8bit_bus); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_confirm_cpu_startup(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_switch_parallel_bus(chip); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + continue; + } else { + break; + } + } + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_WRITE_REG(chip, MS_CFG, 0x18, MS_BUS_WIDTH_4); + + RTS51X_WRITE_REG(chip, MS_CFG, PUSH_TIME_ODD, PUSH_TIME_ODD); + + retval = ms_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_MSHG(ms_card) && switch_8bit_bus) { + retval = ms_switch_8bit_bus(chip); + if (retval != STATUS_SUCCESS) { + ms_card->switch_8bit_fail = 1; + TRACE_RET(chip, retval); + } + } + + return STATUS_SUCCESS; +} + +#ifdef XC_POWERCLASS +static int msxc_change_power(struct rts51x_chip *chip, u8 mode) +{ + int retval; + u8 buf[6]; + + ms_cleanup_work(chip); + + /* Set Parameter Register */ + retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf[0] = 0; + buf[1] = mode; + buf[2] = 0; + buf[3] = 0; + buf[4] = 0; + buf[5] = 0; + + retval = ms_write_bytes(chip, PRO_WRITE_REG, 6, NO_WAIT_INT, buf, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_send_cmd(chip, XC_CHG_POWER, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, MS_TRANS_CFG, buf); + if (buf[0] & (MS_INT_CMDNK | MS_INT_ERR)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} +#endif + +static int ms_read_attribute_info(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 val, *buf, class_code, device_type, sub_class, data[16]; + u16 total_blk = 0, blk_size = 0; +#ifdef SUPPORT_MSXC + u32 xc_total_blk = 0, xc_blk_size = 0; +#endif + u32 sys_info_addr = 0, sys_info_size; +#ifdef SUPPORT_PCGL_1P18 + u32 model_name_addr = 0, model_name_size; + int found_sys_info = 0, found_model_name = 0; +#endif + + retval = ms_set_rw_reg_addr(chip, Pro_IntReg, 2, Pro_SystemParm, 7); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_MS8BIT(ms_card)) + data[0] = PARALLEL_8BIT_IF; + else + data[0] = PARALLEL_4BIT_IF; + data[1] = 0; + + data[2] = 0x40; + data[3] = 0; + data[4] = 0; + data[5] = 0; + /* Start address 0 */ + data[6] = 0; + data[7] = 0; + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, PRO_WRITE_REG, 7, NO_WAIT_INT, data, + 8); + if (retval == STATUS_SUCCESS) + break; + } + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf = kmalloc(64 * 512, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, STATUS_NOMEM); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = ms_send_cmd(chip, PRO_READ_ATRB, WAIT_INT); + if (retval != STATUS_SUCCESS) + continue; + + retval = rts51x_read_register(chip, MS_TRANS_CFG, &val); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + if (!(val & MS_INT_BREQ)) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = + ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, + 0x40, WAIT_INT, 0, 0, buf, 64 * 512); + if (retval == STATUS_SUCCESS) + break; + else + rts51x_clear_ms_error(chip); + } + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_RET(chip, retval); + } + + i = 0; + do { + retval = rts51x_read_register(chip, MS_TRANS_CFG, &val); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_RET(chip, retval); + } + + if ((val & MS_INT_CED) || !(val & MS_INT_BREQ)) + break; + + retval = + ms_transfer_tpc(chip, MS_TM_NORMAL_READ, PRO_READ_LONG_DATA, + 0, WAIT_INT); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_RET(chip, retval); + } + + i++; + } while (i < 1024); + + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_RET(chip, retval); + } + + if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) { + /* Signature code is wrong */ + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + if ((buf[4] < 1) || (buf[4] > 12)) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + for (i = 0; i < buf[4]; i++) { + int cur_addr_off = 16 + i * 12; + +#ifdef SUPPORT_MSXC + if ((buf[cur_addr_off + 8] == 0x10) + || (buf[cur_addr_off + 8] == 0x13)) { +#else + if (buf[cur_addr_off + 8] == 0x10) { +#endif + sys_info_addr = ((u32) buf[cur_addr_off + 0] << 24) | + ((u32) buf[cur_addr_off + 1] << 16) | + ((u32) buf[cur_addr_off + 2] << 8) | + buf[cur_addr_off + 3]; + sys_info_size = + ((u32) buf[cur_addr_off + 4] << 24) | + ((u32) buf[cur_addr_off + 5] << 16) | + ((u32) buf[cur_addr_off + 6] << 8) | + buf[cur_addr_off + 7]; + RTS51X_DEBUGP("sys_info_addr = 0x%x," + "sys_info_size = 0x%x\n", + sys_info_addr, sys_info_size); + if (sys_info_size != 96) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + if (sys_info_addr < 0x1A0) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + if ((sys_info_size + sys_info_addr) > 0x8000) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } +#ifdef SUPPORT_MSXC + if (buf[cur_addr_off + 8] == 0x13) + ms_card->ms_type |= MS_XC; +#endif +#ifdef SUPPORT_PCGL_1P18 + found_sys_info = 1; +#else + break; +#endif + } +#ifdef SUPPORT_PCGL_1P18 + if (buf[cur_addr_off + 8] == 0x15) { + model_name_addr = ((u32) buf[cur_addr_off + 0] << 24) | + ((u32) buf[cur_addr_off + 1] << 16) | + ((u32) buf[cur_addr_off + 2] << 8) | + buf[cur_addr_off + 3]; + model_name_size = + ((u32) buf[cur_addr_off + 4] << 24) | + ((u32) buf[cur_addr_off + 5] << 16) | + ((u32) buf[cur_addr_off + 6] << 8) | + buf[cur_addr_off + 7]; + RTS51X_DEBUGP("model_name_addr = 0x%x," + "model_name_size = 0x%x\n", + model_name_addr, model_name_size); + if (model_name_size != 48) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + if (model_name_addr < 0x1A0) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + if ((model_name_size + model_name_addr) > 0x8000) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + found_model_name = 1; + } + + if (found_sys_info && found_model_name) + break; +#endif + } + + if (i == buf[4]) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + class_code = buf[sys_info_addr + 0]; + device_type = buf[sys_info_addr + 56]; + sub_class = buf[sys_info_addr + 46]; +#ifdef SUPPORT_MSXC + if (CHK_MSXC(ms_card)) { + xc_total_blk = ((u32) buf[sys_info_addr + 6] << 24) | + ((u32) buf[sys_info_addr + 7] << 16) | + ((u32) buf[sys_info_addr + 8] << 8) | + buf[sys_info_addr + 9]; + xc_blk_size = ((u32) buf[sys_info_addr + 32] << 24) | + ((u32) buf[sys_info_addr + 33] << 16) | + ((u32) buf[sys_info_addr + 34] << 8) | + buf[sys_info_addr + 35]; + RTS51X_DEBUGP("xc_total_blk = 0x%x, xc_blk_size = 0x%x\n", + xc_total_blk, xc_blk_size); + } else { + total_blk = + ((u16) buf[sys_info_addr + 6] << 8) | buf[sys_info_addr + + 7]; + blk_size = + ((u16) buf[sys_info_addr + 2] << 8) | buf[sys_info_addr + + 3]; + RTS51X_DEBUGP("total_blk = 0x%x, blk_size = 0x%x\n", total_blk, + blk_size); + } +#else + total_blk = + ((u16) buf[sys_info_addr + 6] << 8) | buf[sys_info_addr + 7]; + blk_size = ((u16) buf[sys_info_addr + 2] << 8) | buf[sys_info_addr + 3]; + RTS51X_DEBUGP("total_blk = 0x%x, blk_size = 0x%x\n", total_blk, + blk_size); +#endif + + RTS51X_DEBUGP("class_code = 0x%x, device_type = 0x%x," + "sub_class = 0x%x\n", + class_code, device_type, sub_class); + + memcpy(ms_card->raw_sys_info, buf + sys_info_addr, 96); +#ifdef SUPPORT_PCGL_1P18 + memcpy(ms_card->raw_model_name, buf + model_name_addr, 48); +#endif + + kfree(buf); + + /* Confirm System Information */ +#ifdef SUPPORT_MSXC + if (CHK_MSXC(ms_card)) { + if (class_code != 0x03) + TRACE_RET(chip, STATUS_FAIL); + } else { + if (class_code != 0x02) + TRACE_RET(chip, STATUS_FAIL); + } +#else + if (class_code != 0x02) + TRACE_RET(chip, STATUS_FAIL); +#endif + + if (device_type != 0x00) { + if ((device_type == 0x01) || (device_type == 0x02) + || (device_type == 0x03)) + chip->card_wp |= MS_CARD; + else + TRACE_RET(chip, STATUS_FAIL); + } + if (sub_class & 0xC0) + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_DEBUGP("class_code: 0x%x, device_type: 0x%x, sub_class: 0x%x\n", + class_code, device_type, sub_class); + +#ifdef SUPPORT_MSXC + if (CHK_MSXC(ms_card)) { + chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = + xc_total_blk * xc_blk_size; + } else { + chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = + total_blk * blk_size; + } +#else + chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = + total_blk * blk_size; +#endif + + return STATUS_SUCCESS; +} + +#ifdef SUPPORT_MAGIC_GATE +int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num); +#endif + +static int reset_ms_pro(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; +#ifdef XC_POWERCLASS + u8 change_power_class = 2; +#endif + +#ifdef XC_POWERCLASS +Retry: +#endif + retval = ms_pro_reset_flow(chip, 1); + if (retval != STATUS_SUCCESS) { + if (ms_card->switch_8bit_fail) { + retval = ms_pro_reset_flow(chip, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + TRACE_RET(chip, retval); + } + } + + retval = ms_read_attribute_info(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef XC_POWERCLASS + if (CHK_HG8BIT(ms_card)) + change_power_class = 0; + + if (change_power_class && CHK_MSXC(ms_card)) { + u8 power_class_mode = (ms_card->raw_sys_info[46] & 0x18) >> 3; + RTS51X_DEBUGP("power_class_mode = 0x%x", power_class_mode); + if (change_power_class > power_class_mode) + change_power_class = power_class_mode; + if (change_power_class) { + retval = msxc_change_power(chip, change_power_class); + if (retval != STATUS_SUCCESS) { + change_power_class--; + goto Retry; + } + } + } +#endif + +#ifdef SUPPORT_MAGIC_GATE + retval = mg_set_tpc_para_sub(chip, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#endif + + if (CHK_HG8BIT(ms_card)) + chip->card_bus_width[chip->card2lun[MS_CARD]] = 8; + else + chip->card_bus_width[chip->card2lun[MS_CARD]] = 4; + + return STATUS_SUCCESS; +} + +static int ms_read_status_reg(struct rts51x_chip *chip) +{ + int retval; + u8 val[2]; + + retval = ms_set_rw_reg_addr(chip, StatusReg0, 2, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_read_bytes(chip, READ_REG, 2, NO_WAIT_INT, val, 2); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (val[1] & (STS_UCDT | STS_UCEX | STS_UCFG)) { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int ms_check_boot_block(struct rts51x_chip *chip, u16 block_addr) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 extra[MS_EXTRA_SIZE], data[10], val = 0; + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (block_addr >> 8); + data[3] = (u8) block_addr; + /* Page Number + * Extra data access mode */ + data[4] = 0x40; + data[5] = 0; + + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_READ, WAIT_INT, data, 6, &val); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, + MS_EXTRA_SIZE, SystemParm, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + } + + retval = + ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT, extra, + MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!(extra[0] & BLOCK_OK) || (extra[1] & NOT_BOOT_BLOCK)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int ms_read_extra_data(struct rts51x_chip *chip, + u16 block_addr, u8 page_num, u8 *buf, + int buf_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 val = 0, data[10]; + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (block_addr >> 8); + data[3] = (u8) block_addr; + /* Page Number + * Extra data access mode */ + data[4] = 0x40; + data[5] = page_num; + +#ifdef MS_SPEEDUP + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_READ, WAIT_INT, data, 6, &val); +#else + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_READ, WAIT_INT, data, 6, &val); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, + MS_EXTRA_SIZE, SystemParm, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + } + + retval = + ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT, data, + MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (buf && buf_len) { + if (buf_len > MS_EXTRA_SIZE) + buf_len = MS_EXTRA_SIZE; + memcpy(buf, data, buf_len); + } + + return STATUS_SUCCESS; +} + +static int ms_write_extra_data(struct rts51x_chip *chip, + u16 block_addr, u8 page_num, u8 *buf, + int buf_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 val = 0, data[16]; + + if (!buf || (buf_len < MS_EXTRA_SIZE)) + TRACE_RET(chip, STATUS_FAIL); + /* Write REG */ + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (block_addr >> 8); + data[3] = (u8) block_addr; + /* Page Number + * Extra data access mode */ + data[4] = 0x40; + data[5] = page_num; + + for (i = 6; i < MS_EXTRA_SIZE + 6; i++) + data[i] = buf[i - 6]; + +#ifdef MS_SPEEDUP + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + 6 + MS_EXTRA_SIZE, BLOCK_WRITE, WAIT_INT, data, 16, + &val); +#else + retval = + ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + 6 + MS_EXTRA_SIZE, BLOCK_WRITE, WAIT_INT, data, 16, + &val); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + return STATUS_SUCCESS; +} + +static int ms_read_page(struct rts51x_chip *chip, u16 block_addr, u8 page_num) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 val = 0, data[6]; + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (block_addr >> 8); + data[3] = (u8) block_addr; + /* Page Number + * Single page access mode */ + data[4] = 0x20; + data[5] = page_num; + + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_READ, WAIT_INT, data, 6, &val); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + if (!(val & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + } else { + if (!(val & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + retval = + ms_transfer_tpc(chip, MS_TM_NORMAL_READ, READ_PAGE_DATA, 0, + NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int ms_set_bad_block(struct rts51x_chip *chip, u16 phy_blk) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 val = 0, data[8], extra[MS_EXTRA_SIZE]; + + retval = ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (phy_blk >> 8); + data[3] = (u8) phy_blk; + data[4] = 0x80; + data[5] = 0; + data[6] = extra[0] & 0x7F; + data[7] = 0xFF; + +#ifdef MS_SPEEDUP + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7, + BLOCK_WRITE, WAIT_INT, data, 7, &val); +#else + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7, + BLOCK_WRITE, WAIT_INT, data, 7, &val); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + return STATUS_SUCCESS; +} + +static int ms_erase_block(struct rts51x_chip *chip, u16 phy_blk) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i = 0; + u8 val = 0, data[6]; + + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (phy_blk >> 8); + data[3] = (u8) phy_blk; + data[4] = 0; + data[5] = 0; + +ERASE_RTY: +#ifdef MS_SPEEDUP + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_ERASE, WAIT_INT, data, 6, &val); +#else + retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_ERASE, WAIT_INT, data, 6, &val); +#endif + + if (val & INT_REG_CMDNK) { + if (i < 3) { + i++; + goto ERASE_RTY; + } + ms_set_err_code(chip, MS_CMD_NK); + ms_set_bad_block(chip, phy_blk); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + return STATUS_SUCCESS; +} + +static void ms_set_page_status(u16 log_blk, u8 type, u8 *extra, int extra_len) +{ + if (!extra || (extra_len < MS_EXTRA_SIZE)) + return; + + memset(extra, 0xFF, MS_EXTRA_SIZE); + + if (type == setPS_NG) + extra[0] = 0xB8; + else + extra[0] = 0x98; + + extra[2] = (u8) (log_blk >> 8); + extra[3] = (u8) log_blk; +} + +static int ms_init_page(struct rts51x_chip *chip, u16 phy_blk, u16 log_blk, + u8 start_page, u8 end_page) +{ + int retval; + u8 extra[MS_EXTRA_SIZE], i; + + memset(extra, 0xff, MS_EXTRA_SIZE); + + extra[0] = 0xf8; /* Block, page OK, data erased */ + extra[1] = 0xff; + extra[2] = (u8) (log_blk >> 8); + extra[3] = (u8) log_blk; + + for (i = start_page; i < end_page; i++) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + retval = + ms_write_extra_data(chip, phy_blk, i, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int ms_copy_page(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, + u16 log_blk, u8 start_page, u8 end_page) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, rty_cnt, uncorrect_flag = 0; + u8 extra[MS_EXTRA_SIZE], val, i, j, data[16]; + + RTS51X_DEBUGP("Copy page from 0x%x to 0x%x, logical block is 0x%x\n", + old_blk, new_blk, log_blk); + RTS51X_DEBUGP("start_page = %d, end_page = %d\n", start_page, + end_page); + + retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, PPBUF_BASE2, &val); + + if (val & BUF_FULL) { + /* Clear Buffer */ + retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* GET_INT Register */ + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!(val & INT_REG_CED)) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + for (i = start_page; i < end_page; i++) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + ms_read_extra_data(chip, old_blk, i, extra, MS_EXTRA_SIZE); + + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, + SystemParm, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Write REG */ + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (old_blk >> 8); + data[3] = (u8) old_blk; + data[4] = 0x20; + data[5] = i; + + retval = + ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) { + uncorrect_flag = 1; + RTS51X_DEBUGP("Uncorrectable" + "error\n"); + } else { + uncorrect_flag = 0; + } + + retval = + ms_transfer_tpc(chip, MS_TM_NORMAL_READ, + READ_PAGE_DATA, 0, NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (uncorrect_flag) { + ms_set_page_status(log_blk, setPS_NG, + extra, MS_EXTRA_SIZE); + if (i == 0) + extra[0] &= 0xEF; + ms_write_extra_data(chip, old_blk, i, + extra, + MS_EXTRA_SIZE); + RTS51X_DEBUGP("page %d :" + "extra[0] = 0x%x\n", + i, extra[0]); + MS_SET_BAD_BLOCK_FLG(ms_card); + + ms_set_page_status(log_blk, setPS_Error, + extra, MS_EXTRA_SIZE); + ms_write_extra_data(chip, new_blk, i, + extra, MS_EXTRA_SIZE); + continue; + } + + for (rty_cnt = 0; rty_cnt < MS_MAX_RETRY_COUNT; + rty_cnt++) { + retval = + ms_transfer_tpc(chip, + MS_TM_NORMAL_WRITE, + WRITE_PAGE_DATA, 0, + NO_WAIT_INT); + if (retval == STATUS_SUCCESS) + break; + } + if (rty_cnt == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + } + + if (!(val & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + retval = ms_set_rw_reg_addr(chip, OverwriteFlag, + MS_EXTRA_SIZE, SystemParm, + (6 + MS_EXTRA_SIZE)); + + /* Write REG */ + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (new_blk >> 8); + data[3] = (u8) new_blk; + data[4] = 0x20; + data[5] = i; + + /* for MS check procedure */ + if ((extra[0] & 0x60) != 0x60) + data[6] = extra[0]; + else + data[6] = 0xF8; + + data[6 + 1] = 0xFF; + data[6 + 2] = (u8) (log_blk >> 8); + data[6 + 3] = (u8) log_blk; + + for (j = 4; j <= MS_EXTRA_SIZE; j++) + data[6 + j] = 0xFF; + + retval = + ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE), + NO_WAIT_INT, data, 16); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* GET_INT Register */ + ms_set_err_code(chip, MS_NO_ERROR); + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + if (i == 0) { + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, + MS_EXTRA_SIZE, SystemParm, 7); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (old_blk >> 8); + data[3] = (u8) old_blk; + data[4] = 0x80; + data[5] = 0; + data[6] = 0xEF; + data[7] = 0xFF; + + retval = + ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, + data, 8); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + retval = + ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, + 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CED) { + if (val & INT_REG_ERR) { + ms_set_err_code(chip, + MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + } + + return STATUS_SUCCESS; +} + +#ifdef MS_SPEEDUP +static int ms_auto_copy_page(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, + u16 log_blk, u8 start_page, u8 end_page) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 page_len, bus_width, val = 0; + u8 extra[MS_EXTRA_SIZE]; + + RTS51X_DEBUGP("Auto copy page from 0x%x to 0x%x," + "logical block is 0x%x\n", + old_blk, new_blk, log_blk); + RTS51X_DEBUGP("start_page = %d, end_page = %d\n", start_page, + end_page); + + page_len = end_page - start_page; + + retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, PPBUF_BASE2, &val); + + if (val & BUF_FULL) { + retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!(val & INT_REG_CED)) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + bus_width = 0x88; + } else { + /* Serial interface */ + bus_width = 0x80; + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_OLD_BLOCK_0, 0xFF, (u8) old_blk); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_OLD_BLOCK_1, 0xFF, + (u8) (old_blk >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_NEW_BLOCK_0, 0xFF, (u8) new_blk); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_NEW_BLOCK_1, 0xFF, + (u8) (new_blk >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_LOG_BLOCK_0, 0xFF, (u8) log_blk); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_LOG_BLOCK_1, 0xFF, + (u8) (log_blk >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_PAGE_START, 0xFF, start_page); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_PAGE_LENGTH, 0xFF, page_len); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BUS_WIDTH, 0xFF, bus_width); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_COPY_PAGE); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + + retval = rts51x_get_rsp(chip, 1, 5000); + + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + rts51x_clear_ms_error(chip); + if (retval == STATUS_TIMEDOUT) + TRACE_RET(chip, retval); + TRACE_GOTO(chip, Fail); + } + + return STATUS_SUCCESS; + +Fail: + retval = ms_erase_block(chip, new_blk); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + ms_copy_page(chip, old_blk, new_blk, log_blk, start_page, end_page); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} +#endif + +static int reset_ms(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u16 i, reg_addr, block_size; + u8 val, j, *ptr; +#ifndef SUPPORT_MAGIC_GATE + u16 eblock_cnt; +#endif + + retval = ms_prepare_reset(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_card->ms_type |= TYPE_MS; + + retval = ms_send_cmd(chip, MS_RESET, NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, PPBUF_BASE2, &val); + if (val & WRT_PRTCT) + chip->card_wp |= MS_CARD; + else + chip->card_wp &= ~MS_CARD; + + i = 0; + +RE_SEARCH: + /* Search For Boot Block */ + while (i < (MAX_DEFECTIVE_BLOCK + 2)) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + retval = ms_check_boot_block(chip, i); + if (retval != STATUS_SUCCESS) { + i++; + continue; + } + + ms_card->boot_block = i; + break; + } + + if (i == (MAX_DEFECTIVE_BLOCK + 2)) { + RTS51X_DEBUGP("No boot block found!"); + TRACE_RET(chip, STATUS_FAIL); + } + for (j = 0; j < 3; j++) { + retval = ms_read_page(chip, ms_card->boot_block, j); + if (retval != STATUS_SUCCESS) { + if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) { + i = ms_card->boot_block + 1; + ms_set_err_code(chip, MS_NO_ERROR); + goto RE_SEARCH; + } + } + } + + /* Read boot block contents */ + retval = ms_read_page(chip, ms_card->boot_block, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Read MS system information as sys_info */ + retval = + rts51x_seq_read_register(chip, PPBUF_BASE2 + 0x1A0, 96, + ms_card->raw_sys_info); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Read useful block contents */ + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, READ_REG_CMD, HEADER_ID0, 0, 0); + rts51x_add_cmd(chip, READ_REG_CMD, HEADER_ID1, 0, 0); + + for (reg_addr = DISABLED_BLOCK0; reg_addr <= DISABLED_BLOCK3; + reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); + } + + for (reg_addr = BLOCK_SIZE_0; reg_addr <= PAGE_SIZE_1; reg_addr++) + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); + + rts51x_add_cmd(chip, READ_REG_CMD, MS_Device_Type, 0, 0); + rts51x_add_cmd(chip, READ_REG_CMD, MS_4bit_Support, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 16, 100); + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ptr = rts51x_get_rsp_data(chip); + + RTS51X_DEBUGP("Boot block data:\n"); + RTS51X_DUMP(ptr, 16); + + if (ptr[0] != 0x00 || ptr[1] != 0x01) { + i = ms_card->boot_block + 1; + goto RE_SEARCH; + } + if (ptr[12] != 0x02 || ptr[13] != 0x00) { + i = ms_card->boot_block + 1; + goto RE_SEARCH; + } + if ((ptr[14] == 1) || (ptr[14] == 3)) + chip->card_wp |= MS_CARD; + block_size = ((u16) ptr[6] << 8) | ptr[7]; + if (block_size == 0x0010) { + ms_card->block_shift = 5; + ms_card->page_off = 0x1F; + } else if (block_size == 0x0008) { + ms_card->block_shift = 4; + ms_card->page_off = 0x0F; + } + ms_card->total_block = ((u16) ptr[8] << 8) | ptr[9]; + +#ifdef SUPPORT_MAGIC_GATE + j = ptr[10]; + + if (ms_card->block_shift == 4) { + if (j < 2) + ms_card->capacity = 0x1EE0; + else + ms_card->capacity = 0x3DE0; + } else { + if (j < 5) + ms_card->capacity = 0x7BC0; + else if (j < 0xA) + ms_card->capacity = 0xF7C0; + else if (j < 0x11) + ms_card->capacity = 0x1EF80; + else + ms_card->capacity = 0x3DF00; + } +#else + eblock_cnt = ((u16) ptr[10] << 8) | ptr[11]; + + ms_card->capacity = ((u32) eblock_cnt - 2) << ms_card->block_shift; +#endif + + chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity; + + if (ptr[15]) { + retval = ms_set_rw_reg_addr(chip, 0, 0, SystemParm, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + RTS51X_WRITE_REG(chip, PPBUF_BASE2, 0xFF, 0x88); + RTS51X_WRITE_REG(chip, PPBUF_BASE2 + 1, 0xFF, 0); + + retval = + ms_transfer_tpc(chip, MS_TM_WRITE_BYTES, WRITE_REG, 1, + NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + RTS51X_WRITE_REG(chip, MS_CFG, 0x58 | MS_NO_CHECK_INT, + MS_BUS_WIDTH_4 | PUSH_TIME_ODD | + MS_NO_CHECK_INT); + + ms_card->ms_type |= MS_4BIT; + } + + if (CHK_MS4BIT(ms_card)) + chip->card_bus_width[chip->card2lun[MS_CARD]] = 4; + else + chip->card_bus_width[chip->card2lun[MS_CARD]] = 1; + + return STATUS_SUCCESS; +} + +static int ms_init_l2p_tbl(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int size, i, seg_no, retval; + u16 defect_block, reg_addr; + u8 val1, val2; + + ms_card->segment_cnt = ms_card->total_block >> 9; + RTS51X_DEBUGP("ms_card->segment_cnt = %d\n", ms_card->segment_cnt); + + size = ms_card->segment_cnt * sizeof(struct zone_entry); + ms_card->segment = vmalloc(size); + if (ms_card->segment == NULL) + TRACE_RET(chip, STATUS_FAIL); + memset(ms_card->segment, 0, size); + + retval = ms_read_page(chip, ms_card->boot_block, 1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, INIT_FAIL); + + reg_addr = PPBUF_BASE2; + for (i = 0; i < (((ms_card->total_block >> 9) * 10) + 1); i++) { + retval = rts51x_read_register(chip, reg_addr++, &val1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, INIT_FAIL); + retval = rts51x_read_register(chip, reg_addr++, &val2); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, INIT_FAIL); + + defect_block = ((u16) val1 << 8) | val2; + if (defect_block == 0xFFFF) + break; + seg_no = defect_block / 512; + ms_card->segment[seg_no].defect_list[ms_card->segment[seg_no]. + disable_count++] = + defect_block; + } + + for (i = 0; i < ms_card->segment_cnt; i++) { + ms_card->segment[i].build_flag = 0; + ms_card->segment[i].l2p_table = NULL; + ms_card->segment[i].free_table = NULL; + ms_card->segment[i].get_index = 0; + ms_card->segment[i].set_index = 0; + ms_card->segment[i].unused_blk_cnt = 0; + + RTS51X_DEBUGP("defective block count of segment %d is %d\n", + i, ms_card->segment[i].disable_count); + } + + return STATUS_SUCCESS; + +INIT_FAIL: + if (ms_card->segment) { + vfree(ms_card->segment); + ms_card->segment = NULL; + } + + return STATUS_FAIL; +} + +static u16 ms_get_l2p_tbl(struct rts51x_chip *chip, int seg_no, u16 log_off) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + + if (ms_card->segment == NULL) + return 0xFFFF; + + segment = &(ms_card->segment[seg_no]); + + if (segment->l2p_table) + return segment->l2p_table[log_off]; + + return 0xFFFF; +} + +static void ms_set_l2p_tbl(struct rts51x_chip *chip, int seg_no, u16 log_off, + u16 phy_blk) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + + if (ms_card->segment == NULL) + return; + + segment = &(ms_card->segment[seg_no]); + if (segment->l2p_table) + segment->l2p_table[log_off] = phy_blk; +} + +static void ms_set_unused_block(struct rts51x_chip *chip, u16 phy_blk) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + int seg_no; + + seg_no = (int)phy_blk >> 9; + segment = &(ms_card->segment[seg_no]); + + segment->free_table[segment->set_index++] = phy_blk; + if (segment->set_index >= MS_FREE_TABLE_CNT) + segment->set_index = 0; + segment->unused_blk_cnt++; +} + +static u16 ms_get_unused_block(struct rts51x_chip *chip, int seg_no) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + u16 phy_blk; + + segment = &(ms_card->segment[seg_no]); + + if (segment->unused_blk_cnt <= 0) + return 0xFFFF; + + phy_blk = segment->free_table[segment->get_index]; + segment->free_table[segment->get_index++] = 0xFFFF; + if (segment->get_index >= MS_FREE_TABLE_CNT) + segment->get_index = 0; + segment->unused_blk_cnt--; + + return phy_blk; +} + +static const unsigned short ms_start_idx[] = { + 0, 494, 990, 1486, 1982, 2478, 2974, 3470, + 3966, 4462, 4958, 5454, 5950, 6446, 6942, 7438, 7934 +}; + +static int ms_arbitrate_l2p(struct rts51x_chip *chip, u16 phy_blk, u16 log_off, + u8 us1, u8 us2) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + int seg_no; + u16 tmp_blk; + + seg_no = (int)phy_blk >> 9; + segment = &(ms_card->segment[seg_no]); + tmp_blk = segment->l2p_table[log_off]; + + if (us1 != us2) { + if (us1 == 0) { + if (!(chip->card_wp & MS_CARD)) + ms_erase_block(chip, tmp_blk); + ms_set_unused_block(chip, tmp_blk); + segment->l2p_table[log_off] = phy_blk; + } else { + if (!(chip->card_wp & MS_CARD)) + ms_erase_block(chip, phy_blk); + ms_set_unused_block(chip, phy_blk); + } + } else { + if (phy_blk < tmp_blk) { + if (!(chip->card_wp & MS_CARD)) + ms_erase_block(chip, phy_blk); + ms_set_unused_block(chip, phy_blk); + } else { + if (!(chip->card_wp & MS_CARD)) + ms_erase_block(chip, tmp_blk); + ms_set_unused_block(chip, tmp_blk); + segment->l2p_table[log_off] = phy_blk; + } + } + + return STATUS_SUCCESS; +} + +static int ms_build_l2p_tbl(struct rts51x_chip *chip, int seg_no) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct zone_entry *segment; + int retval, table_size, disable_cnt, defect_flag, i; + u16 start, end, phy_blk, log_blk, tmp_blk; + u8 extra[MS_EXTRA_SIZE], us1, us2; + + RTS51X_DEBUGP("ms_build_l2p_tbl: %d\n", seg_no); + + if (ms_card->segment == NULL) { + retval = ms_init_l2p_tbl(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + if (ms_card->segment[seg_no].build_flag) { + RTS51X_DEBUGP("l2p table of segment %d has been built\n", + seg_no); + return STATUS_SUCCESS; + } + + if (seg_no == 0) + table_size = 494; + else + table_size = 496; + + segment = &(ms_card->segment[seg_no]); + + if (segment->l2p_table == NULL) { + segment->l2p_table = vmalloc(table_size * 2); + if (segment->l2p_table == NULL) + TRACE_GOTO(chip, BUILD_FAIL); + } + memset((u8 *) (segment->l2p_table), 0xff, table_size * 2); + + if (segment->free_table == NULL) { + segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2); + if (segment->free_table == NULL) + TRACE_GOTO(chip, BUILD_FAIL); + } + memset((u8 *) (segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2); + + start = (u16) seg_no << 9; + end = (u16) (seg_no + 1) << 9; + + disable_cnt = segment->disable_count; + + segment->get_index = segment->set_index = 0; + segment->unused_blk_cnt = 0; + + for (phy_blk = start; phy_blk < end; phy_blk++) { + if (disable_cnt) { + defect_flag = 0; + for (i = 0; i < segment->disable_count; i++) { + if (phy_blk == segment->defect_list[i]) { + defect_flag = 1; + break; + } + } + if (defect_flag) { + disable_cnt--; + continue; + } + } + + retval = + ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) { + RTS51X_DEBUGP("read extra data fail\n"); + ms_set_bad_block(chip, phy_blk); + continue; + } + + if (seg_no == ms_card->segment_cnt - 1) { + if (!(extra[1] & NOT_TRANSLATION_TABLE)) { + if (!(chip->card_wp & MS_CARD)) { + retval = ms_erase_block(chip, phy_blk); + if (retval != STATUS_SUCCESS) + continue; + extra[2] = 0xff; + extra[3] = 0xff; + } + } + } + + if (!(extra[0] & BLOCK_OK)) + continue; + if (!(extra[1] & NOT_BOOT_BLOCK)) + continue; + if ((extra[0] & PAGE_OK) != PAGE_OK) + continue; + + log_blk = ((u16) extra[2] << 8) | extra[3]; + + if (log_blk == 0xFFFF) { + if (!(chip->card_wp & MS_CARD)) { + retval = ms_erase_block(chip, phy_blk); + if (retval != STATUS_SUCCESS) + continue; + } + ms_set_unused_block(chip, phy_blk); + continue; + } + + if ((log_blk < ms_start_idx[seg_no]) || + (log_blk >= ms_start_idx[seg_no + 1])) { + if (!(chip->card_wp & MS_CARD)) { + retval = ms_erase_block(chip, phy_blk); + if (retval != STATUS_SUCCESS) + continue; + } + ms_set_unused_block(chip, phy_blk); + continue; + } + + if (segment->l2p_table[log_blk - ms_start_idx[seg_no]] == + 0xFFFF) { + segment->l2p_table[log_blk - ms_start_idx[seg_no]] = + phy_blk; + continue; + } + + us1 = extra[0] & 0x10; + tmp_blk = segment->l2p_table[log_blk - ms_start_idx[seg_no]]; + retval = + ms_read_extra_data(chip, tmp_blk, 0, extra, MS_EXTRA_SIZE); + if (retval != STATUS_SUCCESS) + continue; + us2 = extra[0] & 0x10; + + (void)ms_arbitrate_l2p(chip, phy_blk, + log_blk - ms_start_idx[seg_no], us1, + us2); + continue; + } + + segment->build_flag = 1; + + RTS51X_DEBUGP("unused block count: %d\n", segment->unused_blk_cnt); + + if (seg_no == ms_card->segment_cnt - 1) { + if (segment->unused_blk_cnt < 2) + chip->card_wp |= MS_CARD; + } else { + if (segment->unused_blk_cnt < 1) + chip->card_wp |= MS_CARD; + } + + if (chip->card_wp & MS_CARD) + return STATUS_SUCCESS; + + for (log_blk = ms_start_idx[seg_no]; log_blk < ms_start_idx[seg_no + 1]; + log_blk++) { + if (segment->l2p_table[log_blk - ms_start_idx[seg_no]] == + 0xFFFF) { + phy_blk = ms_get_unused_block(chip, seg_no); + if (phy_blk == 0xFFFF) { + chip->card_wp |= MS_CARD; + return STATUS_SUCCESS; + } + retval = ms_init_page(chip, phy_blk, log_blk, 0, 1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, BUILD_FAIL); + segment->l2p_table[log_blk - ms_start_idx[seg_no]] = + phy_blk; + if (seg_no == ms_card->segment_cnt - 1) { + if (segment->unused_blk_cnt < 2) { + chip->card_wp |= MS_CARD; + return STATUS_SUCCESS; + } + } else { + if (segment->unused_blk_cnt < 1) { + chip->card_wp |= MS_CARD; + return STATUS_SUCCESS; + } + } + } + } + + if (seg_no == 0) { + for (log_blk = 0; log_blk < 494; log_blk++) { + tmp_blk = segment->l2p_table[log_blk]; + if (tmp_blk < ms_card->boot_block) { + RTS51X_DEBUGP("Boot block is not the first" + "normal block.\n"); + + if (chip->card_wp & MS_CARD) + break; + + phy_blk = ms_get_unused_block(chip, 0); +#ifdef MS_SPEEDUP + retval = + ms_auto_copy_page(chip, tmp_blk, phy_blk, + log_blk, 0, + ms_card->page_off + 1); +#else + retval = ms_copy_page(chip, tmp_blk, phy_blk, + log_blk, 0, + ms_card->page_off + 1); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + segment->l2p_table[log_blk] = phy_blk; + + retval = ms_set_bad_block(chip, tmp_blk); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + } + } + + return STATUS_SUCCESS; + +BUILD_FAIL: + segment->build_flag = 0; + if (segment->l2p_table) { + vfree(segment->l2p_table); + segment->l2p_table = NULL; + } + if (segment->free_table) { + vfree(segment->free_table); + segment->free_table = NULL; + } + + return STATUS_FAIL; +} + +int reset_ms_card(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + memset(ms_card, 0, sizeof(struct ms_info)); + + enable_card_clock(chip, MS_CARD); + + retval = rts51x_select_card(chip, MS_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_card->ms_type = 0; + ms_card->last_rw_int = 0; + + retval = reset_ms_pro(chip); + if (retval != STATUS_SUCCESS) { + if (ms_card->check_ms_flow) { + retval = reset_ms(chip); + if (retval != STATUS_SUCCESS) { + if (chip->option.reset_or_rw_fail_set_pad_drive) { + rts51x_write_register(chip, + CARD_DRIVE_SEL, SD20_DRIVE_MASK, + DRIVE_8mA); + } + TRACE_RET(chip, retval); + } + } else { + if (chip->option.reset_or_rw_fail_set_pad_drive) { + rts51x_write_register(chip, CARD_DRIVE_SEL, + SD20_DRIVE_MASK, + DRIVE_8mA); + } + TRACE_RET(chip, retval); + } + } + + retval = ms_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!CHK_MSPRO(ms_card)) { + retval = ms_build_l2p_tbl(chip, ms_card->total_block / 512 - 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + RTS51X_DEBUGP("ms_card->ms_type = 0x%x\n", ms_card->ms_type); + + return STATUS_SUCCESS; +} + +static int mspro_set_rw_cmd(struct rts51x_chip *chip, u32 start_sec, + u16 sec_cnt, u8 cmd) +{ + int retval, i; + u8 data[8]; + + data[0] = cmd; + data[1] = (u8) (sec_cnt >> 8); + data[2] = (u8) sec_cnt; + data[3] = (u8) (start_sec >> 24); + data[4] = (u8) (start_sec >> 16); + data[5] = (u8) (start_sec >> 8); + data[6] = (u8) start_sec; + data[7] = 0; + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, PRO_EX_SET_CMD, 7, WAIT_INT, data, 8); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +void mspro_stop_seq_mode(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + if (ms_card->seq_mode) { + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + return; + + ms_card->seq_mode = 0; + ms_card->total_sec_cnt = 0; + ms_card->last_rw_int = 0; + ms_send_cmd(chip, PRO_STOP, WAIT_INT); + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, + FIFO_FLUSH); + } +} + +static inline int ms_auto_tune_clock(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + if (chip->asic_code) { + if (ms_card->ms_clock > 30) + ms_card->ms_clock -= 20; + } else { + if (ms_card->ms_clock == CLK_80) + ms_card->ms_clock = CLK_60; + else if (ms_card->ms_clock == CLK_60) + ms_card->ms_clock = CLK_40; + } + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int mspro_rw_multi_sector(struct scsi_cmnd *srb, + struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, mode_2k = 0; + u16 count; + u8 val, trans_mode, rw_tpc, rw_cmd; + + ms_set_err_code(chip, MS_NO_ERROR); + + ms_card->counter = 0; + + if (CHK_MSHG(ms_card)) { + if ((start_sector % 4) || (sector_cnt % 4)) { + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + rw_tpc = PRO_READ_LONG_DATA; + rw_cmd = PRO_READ_DATA; + } else { + rw_tpc = PRO_WRITE_LONG_DATA; + rw_cmd = PRO_WRITE_DATA; + } + } else { + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + rw_tpc = PRO_READ_QUAD_DATA; + rw_cmd = PRO_READ_2K_DATA; + } else { + rw_tpc = PRO_WRITE_QUAD_DATA; + rw_cmd = PRO_WRITE_2K_DATA; + } + mode_2k = 1; + } + } else { + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + rw_tpc = PRO_READ_LONG_DATA; + rw_cmd = PRO_READ_DATA; + } else { + rw_tpc = PRO_WRITE_LONG_DATA; + rw_cmd = PRO_WRITE_DATA; + } + } + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (srb->sc_data_direction == DMA_FROM_DEVICE) + trans_mode = MS_TM_AUTO_READ; + else + trans_mode = MS_TM_AUTO_WRITE; + + val = ms_card->last_rw_int; + + if (ms_card->seq_mode) { + if ((ms_card->pre_dir != srb->sc_data_direction) + || ((ms_card->pre_sec_addr + ms_card->pre_sec_cnt) != + start_sector) + || (mode_2k && (ms_card->seq_mode & MODE_512_SEQ)) + || (!mode_2k && (ms_card->seq_mode & MODE_2K_SEQ)) + || !(val & MS_INT_BREQ) + || ((ms_card->total_sec_cnt + sector_cnt) > 0xFE00)) { + ms_card->seq_mode = 0; + ms_card->total_sec_cnt = 0; + ms_card->last_rw_int = 0; + if (val & MS_INT_BREQ) { + retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, + FIFO_FLUSH, FIFO_FLUSH); + } + } + } + + if (!ms_card->seq_mode) { + ms_card->total_sec_cnt = 0; + if (sector_cnt >= 0x80) { + if ((ms_card->capacity - start_sector) > 0xFE00) + count = 0xFE00; + else + count = + (u16) (ms_card->capacity - start_sector); + if (count > sector_cnt) { + if (mode_2k) + ms_card->seq_mode |= MODE_2K_SEQ; + else + ms_card->seq_mode |= MODE_512_SEQ; + } + } else { + count = sector_cnt; + } + retval = mspro_set_rw_cmd(chip, start_sector, count, rw_cmd); + if (retval != STATUS_SUCCESS) { + ms_card->seq_mode = 0; + TRACE_RET(chip, retval); + } + } + + retval = + ms_transfer_data(chip, trans_mode, rw_tpc, sector_cnt, WAIT_INT, + mode_2k, scsi_sg_count(srb), scsi_sglist(srb), + scsi_bufflen(srb)); + if (retval != STATUS_SUCCESS) { + ms_card->seq_mode = 0; + rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); + rts51x_clear_ms_error(chip); + if (val & MS_INT_BREQ) + ms_send_cmd(chip, PRO_STOP, WAIT_INT); + if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { + RTS51X_DEBUGP("MSPro CRC error, tune clock!\n"); + ms_auto_tune_clock(chip); + } + + TRACE_RET(chip, retval); + } + + ms_card->pre_sec_addr = start_sector; + ms_card->pre_sec_cnt = sector_cnt; + ms_card->pre_dir = srb->sc_data_direction; + ms_card->total_sec_cnt += sector_cnt; + + return STATUS_SUCCESS; +} + +static int mspro_read_format_progress(struct rts51x_chip *chip, + const int short_data_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u32 total_progress, cur_progress; + u8 cnt, tmp; + u8 data[8]; + + ms_card->format_status = FORMAT_FAIL; + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); + + if ((tmp & (MS_INT_CED | MS_INT_CMDNK | MS_INT_ERR)) == MS_INT_CED) { + ms_card->format_status = FORMAT_SUCCESS; + ms_card->pro_under_formatting = 0; + return STATUS_SUCCESS; + } + if (! + ((tmp & (MS_INT_BREQ | MS_INT_CED | MS_INT_CMDNK | MS_INT_ERR)) == + MS_INT_BREQ)) { + ms_card->pro_under_formatting = 0; + TRACE_RET(chip, STATUS_FAIL); + } + + if (short_data_len >= 256) + cnt = 0; + else + cnt = (u8) short_data_len; + + retval = + ms_read_bytes(chip, PRO_READ_SHORT_DATA, cnt, WAIT_INT, data, 8); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + total_progress = + (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; + cur_progress = + (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7]; + + RTS51X_DEBUGP("total_progress = %d, cur_progress = %d\n", + total_progress, cur_progress); + + if (total_progress == 0) { + ms_card->progress = 0; + } else { + u64 ulltmp = (u64) cur_progress * (u64) 65535; + do_div(ulltmp, total_progress); + ms_card->progress = (u16) ulltmp; + } + RTS51X_DEBUGP("progress = %d\n", ms_card->progress); + + for (i = 0; i < 2500; i++) { + RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); + if (tmp & + (MS_INT_CED | MS_INT_CMDNK | MS_INT_BREQ | MS_INT_ERR)) + break; + + wait_timeout(1); + } + + if (i == 2500) + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_DEBUGP("MSPro format tmp:%d\n", tmp); + + if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) + TRACE_RET(chip, STATUS_FAIL); + if (tmp & MS_INT_CED) { + ms_card->format_status = FORMAT_SUCCESS; + ms_card->pro_under_formatting = 0; + } else if (tmp & MS_INT_BREQ) { + ms_card->format_status = FORMAT_IN_PROGRESS; + } else { + ms_card->format_status = FORMAT_FAIL; + ms_card->pro_under_formatting = 0; + TRACE_RET(chip, STATUS_FAIL); + } + + RTS51X_DEBUGP("MSPro format format_status:%d\n", + ms_card->format_status); + + return STATUS_SUCCESS; +} + +void mspro_polling_format_status(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int i; + + if (ms_card->pro_under_formatting) { + for (i = 0; i < 65535; i++) { + mspro_read_format_progress(chip, MS_SHORT_DATA_LEN); + if (ms_card->format_status != FORMAT_IN_PROGRESS) + break; + } + } + + return; +} + +void mspro_format_sense(struct rts51x_chip *chip, unsigned int lun) +{ + struct ms_info *ms_card = &(chip->ms_card); + + if (CHK_FORMAT_STATUS(ms_card, FORMAT_SUCCESS)) { + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + ms_card->pro_under_formatting = 0; + ms_card->progress = 0; + } else if (CHK_FORMAT_STATUS(ms_card, FORMAT_IN_PROGRESS)) { + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, + 0, (u16) (ms_card->progress)); + } else { + set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED); + ms_card->pro_under_formatting = 0; + ms_card->progress = 0; + } +} + +int mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip, + int short_data_len, int quick_format) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 buf[8], tmp; + u16 para; + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, Pro_TPCParm, 0x01); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + memset(buf, 0, 2); + switch (short_data_len) { + case 32: + buf[0] = 0; + break; + case 64: + buf[0] = 1; + break; + case 128: + buf[0] = 2; + break; + case 256: + default: + buf[0] = 3; + break; + } + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, PRO_WRITE_REG, 1, NO_WAIT_INT, buf, 2); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + /* Format command */ + if (quick_format) + para = 0x0000; + else + para = 0x0001; + retval = mspro_set_rw_cmd(chip, 0, para, PRO_FORMAT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Check INT */ + RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); + if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) + TRACE_RET(chip, STATUS_FAIL); + + if ((tmp & (MS_INT_BREQ | MS_INT_CED)) == MS_INT_BREQ) { + ms_card->pro_under_formatting = 1; + ms_card->progress = 0; + ms_card->format_status = FORMAT_IN_PROGRESS; + return STATUS_SUCCESS; + } + + if (tmp & MS_INT_CED) { + ms_card->pro_under_formatting = 0; + ms_card->progress = 0; + ms_card->format_status = FORMAT_SUCCESS; + set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_NO_SENSE); + return STATUS_SUCCESS; + } + + TRACE_RET(chip, STATUS_FAIL); +} + +#ifdef MS_SPEEDUP +static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk, + u16 log_blk, u8 start_page, u8 end_page, + u8 *buf, void **ptr, unsigned int *offset) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + int send_blkend; + u8 extra[MS_EXTRA_SIZE], val1, val2, data[6]; + u8 page_cnt = end_page - start_page, page_addr, sec_cnt; + + if (end_page != (ms_card->page_off + 1)) + send_blkend = 1; + else + send_blkend = 0; + + retval = + ms_read_extra_data(chip, phy_blk, start_page, extra, MS_EXTRA_SIZE); + if (retval == STATUS_SUCCESS) { + if ((extra[1] & 0x30) != 0x30) { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (phy_blk >> 8); + data[3] = (u8) phy_blk; + /* Page Number + * Extra data access mode */ + data[4] = 0; + data[5] = start_page; + + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, + BLOCK_READ, WAIT_INT, data, 6, &val1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_init_cmd(chip); + + if (send_blkend) + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, + SET_BLKEND); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, WAIT_INT, + NO_WAIT_INT); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, + (u8) page_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, READ_PAGE_DATA); + + trans_dma_enable(DMA_FROM_DEVICE, chip, 512 * page_cnt, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_MULTI_READ); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDIR | STAGE_MS_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), (void *)buf, + ptr, offset, 512 * page_cnt, + scsi_sg_count(chip->srb), NULL, 2000); + if (retval != STATUS_SUCCESS) { + rts51x_clear_ms_error(chip); + if (retval == STATUS_TIMEDOUT) + TRACE_RET(chip, retval); + TRACE_GOTO(chip, Fail); + } + retval = rts51x_get_rsp(chip, 3, 200); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + rts51x_clear_ms_error(chip); + if (retval == STATUS_TIMEDOUT) + TRACE_RET(chip, retval); + TRACE_GOTO(chip, Fail); + } + + return STATUS_SUCCESS; + +Fail: + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, READ_REG_CMD, MS_SECTOR_CNT_L, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR | STAGE_MS_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 3, 200); + + if (CHECK_MS_TRANS_FAIL(chip, retval)) + TRACE_RET(chip, STATUS_FAIL); + + sec_cnt = chip->rsp_buf[0]; + RTS51X_DEBUGP("%d pages need be trasferred, %d pages remained\n", + (int)page_cnt, (int)sec_cnt); + page_addr = start_page + (page_cnt - sec_cnt); + + if (CHK_MS4BIT(ms_card)) { + val1 = chip->rsp_buf[1]; + RTS51X_DEBUGP("MS_TRANS_CFG: 0x%x\n", val1); + } else { + val1 = 0; + } + + val2 = chip->rsp_buf[2]; + RTS51X_DEBUGP("GET_INT: 0x%x\n", val2); + + if ((val1 & INT_CMDNK) || (val2 & INT_REG_CMDNK)) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + + if ((val1 & INT_ERR) || (val2 & INT_REG_ERR)) { + if ((val1 & INT_BREQ) || (val2 & INT_REG_BREQ)) { + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) { + if (!(chip->card_wp & MS_CARD)) { + reset_ms(chip); + ms_set_page_status(log_blk, setPS_NG, + extra, MS_EXTRA_SIZE); + ms_write_extra_data(chip, phy_blk, + page_addr, extra, + MS_EXTRA_SIZE); + } + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + if (CHK_MS4BIT(ms_card)) { + if (!(val1 & INT_BREQ) && !(val2 & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + if (!(val2 & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + TRACE_RET(chip, STATUS_FAIL); +} + +static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk, + u16 new_blk, u16 log_blk, u8 start_page, + u8 end_page, u8 *buf, void **ptr, + unsigned int *offset) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + int send_blkend; + u8 val, data[16]; + u8 page_cnt = end_page - start_page; + + if ((end_page == (ms_card->page_off + 1)) || (page_cnt == 1)) + send_blkend = 0; + else + send_blkend = 1; + + if (!start_page) { + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (old_blk >> 8); + data[3] = (u8) old_blk; + data[4] = 0x80; + data[5] = 0; + data[6] = 0xEF; + data[7] = 0xFF; + + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, + SystemParm, 7, BLOCK_WRITE, WAIT_INT, data, + 7, &val); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + (6 + MS_EXTRA_SIZE)); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (new_blk >> 8); + data[3] = (u8) new_blk; + /* Page Number + * Extra data access mode */ + if (page_cnt == 1) { + /* Single page access mode */ + data[4] = 0x20; + } else { + /* Block access mode */ + data[4] = 0; + } + data[5] = start_page; + data[6] = 0xF8; + data[7] = 0xFF; + data[8] = (u8) (log_blk >> 8); + data[9] = (u8) log_blk; + + for (i = 0x0A; i < 0x10; i++) { + /* ECC */ + data[i] = 0xFF; + } + + retval = + ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + (6 + MS_EXTRA_SIZE), BLOCK_WRITE, WAIT_INT, data, + 16, &val); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_init_cmd(chip); + + if (send_blkend) + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, + SET_BLKEND); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, WAIT_INT, + NO_WAIT_INT); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, + (u8) page_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, WRITE_PAGE_DATA); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + + trans_dma_enable(DMA_TO_DEVICE, chip, 512 * page_cnt, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_MULTI_WRITE); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, + MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR | STAGE_MS_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), (void *)buf, + ptr, offset, 512 * page_cnt, + scsi_sg_count(chip->srb), NULL, 2000); + if (retval != STATUS_SUCCESS) { + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + + retval = rts51x_get_rsp(chip, 3, 2000); + + + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +#else + +static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk, + u16 log_blk, u8 start_page, u8 end_page, + u8 *buf, void **ptr, unsigned int *offset) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 extra[MS_EXTRA_SIZE], page_addr, val, trans_cfg, data[6]; + + retval = + ms_read_extra_data(chip, phy_blk, start_page, extra, MS_EXTRA_SIZE); + if (retval == STATUS_SUCCESS) { + if ((extra[1] & 0x30) != 0x30) { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Write REG */ + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (phy_blk >> 8); + data[3] = (u8) phy_blk; + /* Page Number + * Extra data access mode */ + data[4] = 0; + data[5] = start_page; + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + ms_set_err_code(chip, MS_NO_ERROR); + + retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + for (page_addr = start_page; page_addr < end_page; page_addr++) { + ms_set_err_code(chip, MS_NO_ERROR); + + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { + ms_set_err_code(chip, MS_NO_CARD); + chip->card_exist &= ~MS_CARD; + chip->card_ready &= ~MS_CARD; + TRACE_RET(chip, STATUS_FAIL); + } + /* GET_INT Register */ + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & INT_REG_ERR) { + if (val & INT_REG_BREQ) { + retval = ms_read_status_reg(chip); + if (retval != STATUS_SUCCESS) { + if (!(chip->card_wp & MS_CARD)) { + reset_ms(chip); + ms_set_page_status(log_blk, + setPS_NG, extra, + MS_EXTRA_SIZE); + ms_write_extra_data(chip, + phy_blk, page_addr, + extra, MS_EXTRA_SIZE); + } + ms_set_err_code(chip, + MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + if (!(val & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + if (page_addr == (end_page - 1)) { + if (!(val & INT_REG_CED)) { + retval = ms_send_cmd(chip, BLOCK_END, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + retval = + ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, + 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (!(val & INT_REG_CED)) { + ms_set_err_code(chip, MS_FLASH_READ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + + trans_cfg = NO_WAIT_INT; + } else { + trans_cfg = WAIT_INT; + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, + READ_PAGE_DATA); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, + trans_cfg); + + trans_dma_enable(DMA_FROM_DEVICE, chip, 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_NORMAL_READ); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, + MS_TRANSFER_END, MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDIR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), + (void *)buf, ptr, offset, 512, + scsi_sg_count(chip->srb), NULL, + 2000); + if (retval != STATUS_SUCCESS) { + if (retval == STATUS_TIMEDOUT) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + + retval = + rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); + if (retval != STATUS_SUCCESS) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { + ms_set_err_code(chip, MS_CRC16_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + } + + retval = rts51x_get_rsp(chip, 1, 2000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + if (retval == STATUS_TIMEDOUT) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + + retval = + rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); + if (retval != STATUS_SUCCESS) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, retval); + } + if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { + ms_set_err_code(chip, MS_CRC16_ERROR); + rts51x_clear_ms_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + return STATUS_SUCCESS; +} + +static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk, + u16 new_blk, u16 log_blk, u8 start_page, + u8 end_page, u8 *buf, void **ptr, + unsigned int *offset) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + u8 page_addr, val, data[16]; + + if (!start_page) { + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, + SystemParm, 7); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (old_blk >> 8); + data[3] = (u8) old_blk; + data[4] = 0x80; + data[5] = 0; + data[6] = 0xEF; + data[7] = 0xFF; + + retval = + ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 8); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* GET_INT Register */ + ms_set_err_code(chip, MS_NO_ERROR); + retval = + ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, + NO_WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + retval = + ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, + (6 + MS_EXTRA_SIZE)); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + ms_set_err_code(chip, MS_NO_ERROR); + + if (CHK_MS4BIT(ms_card)) { + /* Parallel interface */ + data[0] = 0x88; + } else { + /* Serial interface */ + data[0] = 0x80; + } + /* Block Address */ + data[1] = 0; + data[2] = (u8) (new_blk >> 8); + data[3] = (u8) new_blk; + /* Page Number + * Extra data access mode */ + if ((end_page - start_page) == 1) { + /* Single page access mode */ + data[4] = 0x20; + } else { + /* Block access mode */ + data[4] = 0; + } + data[5] = start_page; + data[6] = 0xF8; + data[7] = 0xFF; + data[8] = (u8) (log_blk >> 8); + data[9] = (u8) log_blk; + + for (i = 0x0A; i < 0x10; i++) { + /* ECC */ + data[i] = 0xFF; + } + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, WRITE_REG, 6 + MS_EXTRA_SIZE, + NO_WAIT_INT, data, 16); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + /* GET_INT Register */ + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + for (page_addr = start_page; page_addr < end_page; page_addr++) { + ms_set_err_code(chip, MS_NO_ERROR); + + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { + ms_set_err_code(chip, MS_NO_CARD); + TRACE_RET(chip, STATUS_FAIL); + } + + if (val & INT_REG_CMDNK) { + ms_set_err_code(chip, MS_CMD_NK); + TRACE_RET(chip, STATUS_FAIL); + } + if (val & INT_REG_ERR) { + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + if (!(val & INT_REG_BREQ)) { + ms_set_err_code(chip, MS_BREQ_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + + udelay(30); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, + WRITE_PAGE_DATA); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, + WAIT_INT); + + trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_NORMAL_WRITE); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, + MS_TRANSFER_END, MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), + (void *)buf, ptr, offset, 512, + scsi_sg_count(chip->srb), NULL, + 2000); + if (retval != STATUS_SUCCESS) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + + if (retval == STATUS_TIMEDOUT) + TRACE_RET(chip, STATUS_TIMEDOUT); + else + TRACE_RET(chip, STATUS_FAIL); + } + + retval = rts51x_get_rsp(chip, 1, 2000); + if (CHECK_MS_TRANS_FAIL(chip, retval)) { + ms_set_err_code(chip, MS_TO_ERROR); + rts51x_clear_ms_error(chip); + + if (retval == STATUS_TIMEDOUT) + TRACE_RET(chip, STATUS_TIMEDOUT); + else + TRACE_RET(chip, STATUS_FAIL); + } + /* GET_INT Register */ + retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if ((end_page - start_page) == 1) { + if (!(val & INT_REG_CED)) { + /* Command can not be executed */ + ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + if (page_addr == (end_page - 1)) { + if (!(val & INT_REG_CED)) { + retval = + ms_send_cmd(chip, BLOCK_END, + WAIT_INT); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + /* GET_INT Register */ + retval = + ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, + &val, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + if ((page_addr == (end_page - 1)) + || (page_addr == ms_card->page_off)) { + if (!(val & INT_REG_CED)) { + ms_set_err_code(chip, + MS_FLASH_WRITE_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + } + + return STATUS_SUCCESS; +} +#endif + +static int ms_finish_write(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, + u16 log_blk, u8 page_off) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, seg_no; + +#ifdef MS_SPEEDUP + retval = ms_auto_copy_page(chip, old_blk, new_blk, log_blk, + page_off, ms_card->page_off + 1); +#else + retval = ms_copy_page(chip, old_blk, new_blk, log_blk, + page_off, ms_card->page_off + 1); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + seg_no = old_blk >> 9; + + if (MS_TST_BAD_BLOCK_FLG(ms_card)) { + MS_CLR_BAD_BLOCK_FLG(ms_card); + ms_set_bad_block(chip, old_blk); + } else { + retval = ms_erase_block(chip, old_blk); + if (retval == STATUS_SUCCESS) + ms_set_unused_block(chip, old_blk); + } + + ms_set_l2p_tbl(chip, seg_no, log_blk - ms_start_idx[seg_no], new_blk); + + return STATUS_SUCCESS; +} + +static int ms_prepare_write(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, + u16 log_blk, u8 start_page) +{ + int retval; + + if (start_page) { +#ifdef MS_SPEEDUP + retval = + ms_auto_copy_page(chip, old_blk, new_blk, log_blk, 0, + start_page); +#else + retval = + ms_copy_page(chip, old_blk, new_blk, log_blk, 0, + start_page); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +int ms_delay_write(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + struct ms_delay_write_tag *delay_write = &(ms_card->delay_write); + int retval; + + if (delay_write->delay_write_flag) { + retval = ms_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + delay_write->delay_write_flag = 0; + retval = ms_finish_write(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + delay_write->logblock, + delay_write->pageoff); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static inline void ms_rw_fail(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + if (srb->sc_data_direction == DMA_FROM_DEVICE) + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + else + set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); +} + +static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip, + u32 start_sector, u16 sector_cnt) +{ + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + int retval, seg_no; + unsigned int offset = 0; + u16 old_blk = 0, new_blk = 0, log_blk, total_sec_cnt = sector_cnt; + u8 start_page, end_page = 0, page_cnt; + u8 *buf; + void *ptr = NULL; + struct ms_delay_write_tag *delay_write = &(ms_card->delay_write); + + ms_set_err_code(chip, MS_NO_ERROR); + + ms_card->counter = 0; + + buf = (u8 *) scsi_sglist(srb); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) { + ms_rw_fail(srb, chip); + TRACE_RET(chip, retval); + } + + log_blk = (u16) (start_sector >> ms_card->block_shift); + start_page = (u8) (start_sector & ms_card->page_off); + + for (seg_no = 0; seg_no < sizeof(ms_start_idx) / 2; seg_no++) { + if (log_blk < ms_start_idx[seg_no + 1]) + break; + } + + if (ms_card->segment[seg_no].build_flag == 0) { + retval = ms_build_l2p_tbl(chip, seg_no); + if (retval != STATUS_SUCCESS) { + chip->card_fail |= MS_CARD; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, retval); + } + } + + if (srb->sc_data_direction == DMA_TO_DEVICE) { + if (delay_write->delay_write_flag && + (delay_write->logblock == log_blk) && + (start_page > delay_write->pageoff)) { + delay_write->delay_write_flag = 0; +#ifdef MS_SPEEDUP + retval = ms_auto_copy_page(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + log_blk, + delay_write->pageoff, + start_page); +#else + retval = ms_copy_page(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + log_blk, delay_write->pageoff, + start_page); +#endif + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + old_blk = delay_write->old_phyblock; + new_blk = delay_write->new_phyblock; + } else if (delay_write->delay_write_flag && + (delay_write->logblock == log_blk) && + (start_page == delay_write->pageoff)) { + delay_write->delay_write_flag = 0; + old_blk = delay_write->old_phyblock; + new_blk = delay_write->new_phyblock; + } else { + retval = ms_delay_write(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + old_blk = + ms_get_l2p_tbl(chip, seg_no, + log_blk - ms_start_idx[seg_no]); + new_blk = ms_get_unused_block(chip, seg_no); + if ((old_blk == 0xFFFF) || (new_blk == 0xFFFF)) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = + ms_prepare_write(chip, old_blk, new_blk, log_blk, + start_page); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, MS_CARD) == + CD_NOT_EXIST) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, STATUS_FAIL); + } + + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + } + } else { + retval = ms_delay_write(chip); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, STATUS_FAIL); + } + + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, retval); + } + old_blk = + ms_get_l2p_tbl(chip, seg_no, + log_blk - ms_start_idx[seg_no]); + if (old_blk == 0xFFFF) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + RTS51X_DEBUGP("seg_no = %d, old_blk = 0x%x, new_blk = 0x%x\n", seg_no, + old_blk, new_blk); + + while (total_sec_cnt) { + if ((start_page + total_sec_cnt) > (ms_card->page_off + 1)) + end_page = ms_card->page_off + 1; + else + end_page = start_page + (u8) total_sec_cnt; + page_cnt = end_page - start_page; + + RTS51X_DEBUGP("start_page = %d, end_page = %d," + "page_cnt = %d\n", + start_page, end_page, page_cnt); + + if (srb->sc_data_direction == DMA_FROM_DEVICE) + retval = ms_read_multiple_pages(chip, + old_blk, log_blk, + start_page, end_page, + buf, &ptr, &offset); + else + retval = ms_write_multiple_pages(chip, old_blk, + new_blk, log_blk, + start_page, end_page, + buf, &ptr, &offset); + + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, STATUS_FAIL); + } + + ms_rw_fail(srb, chip); + TRACE_RET(chip, retval); + } + /* Update L2P table if need */ + if (srb->sc_data_direction == DMA_TO_DEVICE) { + if (end_page == (ms_card->page_off + 1)) { + retval = ms_erase_block(chip, old_blk); + if (retval == STATUS_SUCCESS) + ms_set_unused_block(chip, old_blk); + ms_set_l2p_tbl(chip, seg_no, + log_blk - ms_start_idx[seg_no], + new_blk); + } + } + + total_sec_cnt -= page_cnt; + + if (total_sec_cnt == 0) + break; + + log_blk++; + + for (seg_no = 0; seg_no < sizeof(ms_start_idx) / 2; seg_no++) { + if (log_blk < ms_start_idx[seg_no + 1]) + break; + } + + if (ms_card->segment[seg_no].build_flag == 0) { + retval = ms_build_l2p_tbl(chip, seg_no); + if (retval != STATUS_SUCCESS) { + chip->card_fail |= MS_CARD; + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, retval); + } + } + + old_blk = + ms_get_l2p_tbl(chip, seg_no, + log_blk - ms_start_idx[seg_no]); + if (old_blk == 0xFFFF) { + ms_rw_fail(srb, chip); + TRACE_RET(chip, STATUS_FAIL); + } + + if (srb->sc_data_direction == DMA_TO_DEVICE) { + new_blk = ms_get_unused_block(chip, seg_no); + if (new_blk == 0xFFFF) { + ms_rw_fail(srb, chip); + TRACE_RET(chip, STATUS_FAIL); + } + } + + RTS51X_DEBUGP("seg_no = %d, old_blk = 0x%x, new_blk = 0x%x\n", + seg_no, old_blk, new_blk); + + start_page = 0; + } + + if (srb->sc_data_direction == DMA_TO_DEVICE) { + if (end_page < (ms_card->page_off + 1)) { + delay_write->delay_write_flag = 1; + delay_write->old_phyblock = old_blk; + delay_write->new_phyblock = new_blk; + delay_write->logblock = log_blk; + delay_write->pageoff = end_page; + } + } + + scsi_set_resid(srb, 0); + + return STATUS_SUCCESS; +} + +int ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + if (CHK_MSPRO(ms_card)) + retval = + mspro_rw_multi_sector(srb, chip, start_sector, sector_cnt); + else + retval = + ms_rw_multi_sector(srb, chip, start_sector, sector_cnt); + + return retval; +} + +void ms_free_l2p_tbl(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int i = 0; + + if (ms_card->segment != NULL) { + for (i = 0; i < ms_card->segment_cnt; i++) { + if (ms_card->segment[i].l2p_table != NULL) { + vfree(ms_card->segment[i].l2p_table); + ms_card->segment[i].l2p_table = NULL; + } + if (ms_card->segment[i].free_table != NULL) { + vfree(ms_card->segment[i].free_table); + ms_card->segment[i].free_table = NULL; + } + } + vfree(ms_card->segment); + ms_card->segment = NULL; + } +} + +void ms_cleanup_work(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + + if (CHK_MSPRO(ms_card)) { + if (ms_card->seq_mode) { + RTS51X_DEBUGP("MS Pro: stop transmission\n"); + mspro_stop_seq_mode(chip); + ms_card->counter = 0; + } + if (CHK_MSHG(ms_card)) { + u8 value; + rts51x_read_register(chip, MS_CFG, &value); + if (value & MS_2K_SECTOR_MODE) + rts51x_write_register(chip, MS_CFG, + MS_2K_SECTOR_MODE, 0x00); + } + } else if ((!CHK_MSPRO(ms_card)) + && ms_card->delay_write.delay_write_flag) { + RTS51X_DEBUGP("MS: delay write\n"); + ms_delay_write(chip); + ms_card->counter = 0; + } +} + +int ms_power_off_card3v3(struct rts51x_chip *chip) +{ + int retval; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0); + if (chip->asic_code) + ms_pull_ctl_disable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, + FPGA_MS_PULL_CTL_BIT | 0x20, + FPGA_MS_PULL_CTL_BIT); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); + if (!chip->option.FT2_fast_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + } + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int release_ms_card(struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + + RTS51X_DEBUGP("release_ms_card\n"); + + ms_card->delay_write.delay_write_flag = 0; + ms_card->pro_under_formatting = 0; + + chip->card_ready &= ~MS_CARD; + chip->card_fail &= ~MS_CARD; + chip->card_wp &= ~MS_CARD; + + ms_free_l2p_tbl(chip); + + rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); + + memset(ms_card->raw_sys_info, 0, 96); +#ifdef SUPPORT_PCGL_1P18 + memset(ms_card->raw_model_name, 0, 48); +#endif + + retval = ms_power_off_card3v3(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} diff --git a/drivers/staging/rts5139/ms.h b/drivers/staging/rts5139/ms.h new file mode 100644 index 00000000000..f9d46d210f2 --- /dev/null +++ b/drivers/staging/rts5139/ms.h @@ -0,0 +1,263 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_MS_H +#define __RTS51X_MS_H + +#include "rts51x_chip.h" + +#define MS_MAX_RETRY_COUNT 3 + +#define MS_EXTRA_SIZE 0x9 + +#define WRT_PRTCT 0x01 + +/* Error Code */ +#define MS_NO_ERROR 0x00 +#define MS_CRC16_ERROR 0x80 +#define MS_TO_ERROR 0x40 +#define MS_NO_CARD 0x20 +#define MS_NO_MEMORY 0x10 +#define MS_CMD_NK 0x08 +#define MS_FLASH_READ_ERROR 0x04 +#define MS_FLASH_WRITE_ERROR 0x02 +#define MS_BREQ_ERROR 0x01 +#define MS_NOT_FOUND 0x03 + +/* Transfer Protocol Command */ +#define READ_PAGE_DATA 0x02 +#define READ_REG 0x04 +#define GET_INT 0x07 +#define WRITE_PAGE_DATA 0x0D +#define WRITE_REG 0x0B +#define SET_RW_REG_ADRS 0x08 +#define SET_CMD 0x0E + +#define PRO_READ_LONG_DATA 0x02 +#define PRO_READ_SHORT_DATA 0x03 +#define PRO_READ_REG 0x04 +#define PRO_READ_QUAD_DATA 0x05 +#define PRO_GET_INT 0x07 +#define PRO_WRITE_LONG_DATA 0x0D +#define PRO_WRITE_SHORT_DATA 0x0C +#define PRO_WRITE_QUAD_DATA 0x0A +#define PRO_WRITE_REG 0x0B +#define PRO_SET_RW_REG_ADRS 0x08 +#define PRO_SET_CMD 0x0E +#define PRO_EX_SET_CMD 0x09 + +#ifdef SUPPORT_MAGIC_GATE +#define MG_GET_ID 0x40 +#define MG_SET_LID 0x41 +#define MG_GET_LEKB 0x42 +#define MG_SET_RD 0x43 +#define MG_MAKE_RMS 0x44 +#define MG_MAKE_KSE 0x45 +#define MG_SET_IBD 0x46 +#define MG_GET_IBD 0x47 +#endif + +#ifdef XC_POWERCLASS +#define XC_CHG_POWER 0x16 +#endif + +/* ++ CMD over Memory Stick */ +/* Flash CMD */ +#define BLOCK_READ 0xAA +#define BLOCK_WRITE 0x55 +#define BLOCK_END 0x33 +#define BLOCK_ERASE 0x99 +#define FLASH_STOP 0xCC + +/* Function CMD */ +#define SLEEP 0x5A +#define CLEAR_BUF 0xC3 +#define MS_RESET 0x3C +/* -- CMD over Memory Stick */ + +/* ++ CMD over Memory Stick Pro */ +/* Flash CMD */ +#define PRO_READ_DATA 0x20 +#define PRO_WRITE_DATA 0x21 +#define PRO_READ_ATRB 0x24 +#define PRO_STOP 0x25 +#define PRO_ERASE 0x26 +#define PRO_READ_2K_DATA 0x27 +#define PRO_WRITE_2K_DATA 0x28 + +/* Function CMD */ +#define PRO_FORMAT 0x10 +#define PRO_SLEEP 0x11 +/* -- CMD over Memory Stick Pro */ + +/* register inside memory stick */ +#define IntReg 0x01 +#define StatusReg0 0x02 +#define StatusReg1 0x03 + +#define SystemParm 0x10 +#define BlockAdrs 0x11 +#define CMDParm 0x14 +#define PageAdrs 0x15 + +#define OverwriteFlag 0x16 +#define ManagemenFlag 0x17 +#define LogicalAdrs 0x18 +#define ReserveArea 0x1A + +/* register inside memory pro */ +#define Pro_IntReg 0x01 +#define Pro_StatusReg 0x02 +#define Pro_TypeReg 0x04 +#define Pro_IFModeReg 0x05 +#define Pro_CatagoryReg 0x06 +#define Pro_ClassReg 0x07 + +#define Pro_SystemParm 0x10 +#define Pro_DataCount1 0x11 +#define Pro_DataCount0 0x12 +#define Pro_DataAddr3 0x13 +#define Pro_DataAddr2 0x14 +#define Pro_DataAddr1 0x15 +#define Pro_DataAddr0 0x16 + +#define Pro_TPCParm 0x17 +#define Pro_CMDParm 0x18 + +/* define for INT Register */ +#define INT_REG_CED 0x80 +#define INT_REG_ERR 0x40 +#define INT_REG_BREQ 0x20 +#define INT_REG_CMDNK 0x01 + +/* INT signal */ +#define INT_CED 0x01 +#define INT_ERR 0x02 +#define INT_BREQ 0x04 +#define INT_CMDNK 0x08 + +/* define for OverwriteFlag Register */ +#define BLOCK_BOOT 0xC0 +#define BLOCK_OK 0x80 +#define PAGE_OK 0x60 +#define DATA_COMPL 0x10 + +/* define for ManagemenFlag Register */ +#define NOT_BOOT_BLOCK 0x4 +#define NOT_TRANSLATION_TABLE 0x8 + +/* Header */ +#define HEADER_ID0 (PPBUF_BASE2) /* 0 */ +#define HEADER_ID1 (PPBUF_BASE2 + 1) /* 1 */ +/* System Entry */ +#define DISABLED_BLOCK0 (PPBUF_BASE2 + 0x170 + 4) /* 2 */ +#define DISABLED_BLOCK1 (PPBUF_BASE2 + 0x170 + 5) /* 3 */ +#define DISABLED_BLOCK2 (PPBUF_BASE2 + 0x170 + 6) /* 4 */ +#define DISABLED_BLOCK3 (PPBUF_BASE2 + 0x170 + 7) /* 5 */ +/* Boot & Attribute Information */ +#define BLOCK_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 2) /* 6 */ +#define BLOCK_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 3) /* 7 */ +#define BLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 4) /* 8 */ +#define BLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 5) /* 9 */ +#define EBLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 6) /* 10 */ +#define EBLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 7) /* 11 */ +#define PAGE_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 8) /* 12 */ +#define PAGE_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 9) /* 13 */ + +/* joey 2004-08-07 for MS check Procedure */ +#define MS_Device_Type (PPBUF_BASE2 + 0x1D8) /* 14 */ +/* end */ + +/* joey 2004-05-03 */ +#define MS_4bit_Support (PPBUF_BASE2 + 0x1D3) /* 15 */ +/* end */ + +#define setPS_NG 1 +#define setPS_Error 0 + +/* define for Pro_SystemParm Register */ +#define PARALLEL_8BIT_IF 0x40 +#define PARALLEL_4BIT_IF 0x00 +#define SERIAL_IF 0x80 + +/* define for StatusReg0 Register */ +#define BUF_FULL 0x10 +#define BUF_EMPTY 0x20 + +/* define for StatusReg1 Register */ +#define MEDIA_BUSY 0x80 +#define FLASH_BUSY 0x40 +#define DATA_ERROR 0x20 +#define STS_UCDT 0x10 +#define EXTRA_ERROR 0x08 +#define STS_UCEX 0x04 +#define FLAG_ERROR 0x02 +#define STS_UCFG 0x01 + +#define MS_SHORT_DATA_LEN 32 + +#define FORMAT_SUCCESS 0 +#define FORMAT_FAIL 1 +#define FORMAT_IN_PROGRESS 2 + +#define MS_SET_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag |= 0x80) +#define MS_CLR_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag &= 0x7F) +#define MS_TST_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag & 0x80) + +#define CHECK_MS_TRANS_FAIL(chip, retval) \ + (((retval) != STATUS_SUCCESS) || \ + (chip->rsp_buf[0] & MS_TRANSFER_ERR)) + +void mspro_polling_format_status(struct rts51x_chip *chip); +void mspro_format_sense(struct rts51x_chip *chip, unsigned int lun); + +void mspro_stop_seq_mode(struct rts51x_chip *chip); +int reset_ms_card(struct rts51x_chip *chip); +int ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt); +int mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip, + int short_data_len, int quick_format); +void ms_free_l2p_tbl(struct rts51x_chip *chip); +void ms_cleanup_work(struct rts51x_chip *chip); +int ms_power_off_card3v3(struct rts51x_chip *chip); +int release_ms_card(struct rts51x_chip *chip); +int ms_delay_write(struct rts51x_chip *chip); + +#ifdef SUPPORT_MAGIC_GATE + +int ms_switch_clock(struct rts51x_chip *chip); +int ms_write_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 * data, + int data_len); +int ms_read_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 * data, + int data_len); +int ms_set_rw_reg_addr(struct rts51x_chip *chip, u8 read_start, u8 read_cnt, + u8 write_start, u8 write_cnt); +int ms_transfer_data(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, + u16 sec_cnt, u8 cfg, int mode_2k, int use_sg, void *buf, + int buf_len); +#endif + +#endif /* __RTS51X_MS_H */ diff --git a/drivers/staging/rts5139/ms_mg.c b/drivers/staging/rts5139/ms_mg.c new file mode 100644 index 00000000000..154b5230aa5 --- /dev/null +++ b/drivers/staging/rts5139/ms_mg.c @@ -0,0 +1,642 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_transport.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "ms.h" + +#ifdef SUPPORT_MAGIC_GATE + +int mg_check_int_error(struct rts51x_chip *chip) +{ + u8 value; + + rts51x_read_register(chip, MS_TRANS_CFG, &value); + if (value & (INT_ERR | INT_CMDNK)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int mg_send_ex_cmd(struct rts51x_chip *chip, u8 cmd, u8 entry_num) +{ + int retval, i; + u8 data[8]; + + data[0] = cmd; + data[1] = 0; + data[2] = 0; + data[3] = 0; + data[4] = 0; + data[5] = 0; + data[6] = entry_num; + data[7] = 0; + + for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { + retval = + ms_write_bytes(chip, PRO_EX_SET_CMD, 7, WAIT_INT, data, 8); + if (retval == STATUS_SUCCESS) + break; + } + if (i == MS_MAX_RETRY_COUNT) + TRACE_RET(chip, STATUS_FAIL); + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num) +{ + int retval; + u8 buf[6]; + + RTS51X_DEBUGP("--%s--\n", __func__); + + if (type == 0) + retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_TPCParm, 1); + else + retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf[0] = 0; + buf[1] = 0; + if (type == 1) { + buf[2] = 0; + buf[3] = 0; + buf[4] = 0; + buf[5] = mg_entry_num; + } + retval = + ms_write_bytes(chip, PRO_WRITE_REG, (type == 0) ? 1 : 6, + NO_WAIT_INT, buf, 6); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +/** + * Get MagciGate ID and set Leaf ID to medium. + + * After receiving this SCSI command, adapter shall fulfill 2 tasks + * below in order: + * 1. send GET_ID TPC command to get MagicGate ID and hold it till + * Response&challenge CMD. + * 2. send SET_ID TPC command to medium with Leaf ID released by host + * in this SCSI CMD. + */ +int mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval; + int i; + unsigned int lun = SCSI_LUN(srb); + u8 buf1[32], buf2[12]; + + RTS51X_DEBUGP("--%s--\n", __func__); + + if (scsi_bufflen(srb) < 12) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, STATUS_FAIL); + } + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = mg_send_ex_cmd(chip, MG_SET_LID, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + TRACE_RET(chip, retval); + } + + memset(buf1, 0, 32); + rts51x_get_xfer_buf(buf2, min(12, (int)scsi_bufflen(srb)), srb); + for (i = 0; i < 8; i++) + buf1[8 + i] = buf2[4 + i]; + retval = + ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf1, 32); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + TRACE_RET(chip, retval); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +/** + * Send Local EKB to host. + + * After receiving this SCSI command, adapter shall read the divided + * data(1536 bytes totally) from medium by using READ_LONG_DATA TPC + * for 3 times, and report data to host with data-length is 1052 bytes. + */ +int mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval = STATUS_FAIL; + int bufflen; + unsigned int lun = SCSI_LUN(srb); + u8 *buf = NULL; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf = kmalloc(1540, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, STATUS_NOMEM); + + buf[0] = 0x04; + buf[1] = 0x1A; + buf[2] = 0x00; + buf[3] = 0x00; + + retval = mg_send_ex_cmd(chip, MG_GET_LEKB, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_GOTO(chip, GetEKBFinish); + } + + retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, + 3, WAIT_INT, 0, 0, buf + 4, 1536); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + rts51x_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, + MS_STOP | MS_CLR_ERR); + TRACE_GOTO(chip, GetEKBFinish); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_GOTO(chip, GetEKBFinish); + } + + bufflen = min(1052, (int)scsi_bufflen(srb)); + rts51x_set_xfer_buf(buf, bufflen, srb); + +GetEKBFinish: + kfree(buf); + return retval; +} + +/** + * Send challenge(host) to medium. + + * After receiving this SCSI command, adapter shall sequentially issues + * TPC commands to the medium for writing 8-bytes data as challenge + * by host within a short data packet. + */ +int mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + int bufflen; + int i; + unsigned int lun = SCSI_LUN(srb); + u8 buf[32], tmp; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = mg_send_ex_cmd(chip, MG_GET_ID, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + + retval = + ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT, buf, 32); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + + memcpy(ms_card->magic_gate_id, buf, 16); + + for (i = 0; i < 2500; i++) { + RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); + if (tmp & + (MS_INT_CED | MS_INT_CMDNK | MS_INT_BREQ | MS_INT_ERR)) + break; + + wait_timeout(1); + } + + if (i == 2500) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = mg_send_ex_cmd(chip, MG_SET_RD, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + + bufflen = min(12, (int)scsi_bufflen(srb)); + rts51x_get_xfer_buf(buf, bufflen, srb); + + for (i = 0; i < 8; i++) + buf[i] = buf[4 + i]; + for (i = 0; i < 24; i++) + buf[8 + i] = 0; + retval = + ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf, 32); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, retval); + } + + ms_card->mg_auth = 0; + + return STATUS_SUCCESS; +} + +/** + * Send Response and Challenge data to host. + + * After receiving this SCSI command, adapter shall communicates with + * the medium, get parameters(HRd, Rms, MagicGateID) by using READ_SHORT_DATA + * TPC and send the data to host according to certain format required by + * MG-R specification. + * The paremeter MagicGateID is the one that adapter has obtained from + * the medium by TPC commands in Set Leaf ID command phase previously. + */ +int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval, i; + int bufflen; + unsigned int lun = SCSI_LUN(srb); + u8 buf1[32], buf2[36], tmp; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = mg_send_ex_cmd(chip, MG_MAKE_RMS, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + + retval = + ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT, buf1, 32); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + + buf2[0] = 0x00; + buf2[1] = 0x22; + buf2[2] = 0x00; + buf2[3] = 0x00; + + memcpy(buf2 + 4, ms_card->magic_gate_id, 16); + memcpy(buf2 + 20, buf1, 16); + + bufflen = min(36, (int)scsi_bufflen(srb)); + rts51x_set_xfer_buf(buf2, bufflen, srb); + + for (i = 0; i < 2500; i++) { + RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); + if (tmp & (MS_INT_CED | MS_INT_CMDNK | + MS_INT_BREQ | MS_INT_ERR)) + break; + + wait_timeout(1); + } + + if (i == 2500) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +/** + * Send response(host) to medium. + + * After receiving this SCSI command, adapter shall sequentially + * issues TPC commands to the medium for writing 8-bytes data as + * challenge by host within a short data packet. + */ +int mg_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + int i; + int bufflen; + unsigned int lun = SCSI_LUN(srb); + u8 buf[32]; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = mg_send_ex_cmd(chip, MG_MAKE_KSE, 0); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + + bufflen = min(12, (int)scsi_bufflen(srb)); + rts51x_get_xfer_buf(buf, bufflen, srb); + + for (i = 0; i < 8; i++) + buf[i] = buf[4 + i]; + for (i = 0; i < 24; i++) + buf[8 + i] = 0; + retval = + ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf, 32); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); + TRACE_RET(chip, retval); + } + + ms_card->mg_auth = 1; + + return STATUS_SUCCESS; +} + +/** * Send ICV data to host. + + * After receiving this SCSI command, adapter shall read the divided + * data(1024 bytes totally) from medium by using READ_LONG_DATA TPC + * for 2 times, and report data to host with data-length is 1028 bytes. + * + * Since the extra 4 bytes data is just only a prefix to original data + * that read from medium, so that the 4-byte data pushed into Ring buffer + * precedes data tramsinssion from medium to Ring buffer by DMA mechanisim + * in order to get maximum performance and minimum code size simultaneously. + */ +int mg_get_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + int bufflen; + unsigned int lun = SCSI_LUN(srb); + u8 *buf = NULL; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf = kmalloc(1028, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, STATUS_NOMEM); + + buf[0] = 0x04; + buf[1] = 0x02; + buf[2] = 0x00; + buf[3] = 0x00; + + retval = mg_send_ex_cmd(chip, MG_GET_IBD, ms_card->mg_entry_num); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_GOTO(chip, GetICVFinish); + } + + retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, + 2, WAIT_INT, 0, 0, buf + 4, 1024); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + rts51x_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, + MS_STOP | MS_CLR_ERR); + TRACE_GOTO(chip, GetICVFinish); + } + retval = mg_check_int_error(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_GOTO(chip, GetICVFinish); + } + + bufflen = min(1028, (int)scsi_bufflen(srb)); + rts51x_set_xfer_buf(buf, bufflen, srb); + +GetICVFinish: + kfree(buf); + return retval; +} + +/** + * Send ICV data to medium. + + * After receiving this SCSI command, adapter shall receive 1028 bytes + * and write the later 1024 bytes to medium by WRITE_LONG_DATA TPC + * consecutively. + * + * Since the first 4-bytes data is just only a prefix to original data + * that sent by host, and it should be skipped by shifting DMA pointer + * before writing 1024 bytes to medium. + */ +int mg_set_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + int retval; + int bufflen; +#ifdef MG_SET_ICV_SLOW + int i; +#endif + unsigned int lun = SCSI_LUN(srb); + u8 *buf = NULL; + + RTS51X_DEBUGP("--%s--\n", __func__); + + ms_cleanup_work(chip); + + retval = ms_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + buf = kmalloc(1028, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, STATUS_NOMEM); + + bufflen = min(1028, (int)scsi_bufflen(srb)); + rts51x_get_xfer_buf(buf, bufflen, srb); + + retval = mg_send_ex_cmd(chip, MG_SET_IBD, ms_card->mg_entry_num); + if (retval != STATUS_SUCCESS) { + if (ms_card->mg_auth == 0) { + if ((buf[5] & 0xC0) != 0) + set_sense_type(chip, lun, + SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + else + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } else { + set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); + } + TRACE_GOTO(chip, SetICVFinish); + } + +#ifdef MG_SET_ICV_SLOW + for (i = 0; i < 2; i++) { + udelay(50); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, + PRO_WRITE_LONG_DATA); + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, + WAIT_INT); + + trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, + MS_TRANSFER_START | MS_TM_NORMAL_WRITE); + rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, + MS_TRANSFER_END, MS_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR, 100); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); + TRACE_GOTO(chip, SetICVFinish); + } + + retval = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), + buf + 4 + i * 512, 512, 0, + NULL, 3000, STAGE_DO); + if (retval != STATUS_SUCCESS) { + rts51x_clear_ms_error(chip); + if (ms_card->mg_auth == 0) { + if ((buf[5] & 0xC0) != 0) + set_sense_type(chip, lun, + SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + else + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } + retval = STATUS_FAIL; + TRACE_GOTO(chip, SetICVFinish); + } + + retval = rts51x_get_rsp(chip, 1, 3000); + if (CHECK_MS_TRANS_FAIL(chip, retval) + || mg_check_int_error(chip)) { + rts51x_clear_ms_error(chip); + if (ms_card->mg_auth == 0) { + if ((buf[5] & 0xC0) != 0) + set_sense_type(chip, lun, + SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + else + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } + retval = STATUS_FAIL; + TRACE_GOTO(chip, SetICVFinish); + } + } +#else + retval = ms_transfer_data(chip, MS_TM_AUTO_WRITE, PRO_WRITE_LONG_DATA, + 2, WAIT_INT, 0, 0, buf + 4, 1024); + if (retval != STATUS_SUCCESS) { + rts51x_clear_ms_error(chip); + if (ms_card->mg_auth == 0) { + if ((buf[5] & 0xC0) != 0) + set_sense_type(chip, lun, + SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); + else + set_sense_type(chip, lun, + SENSE_TYPE_MG_WRITE_ERR); + } else { + set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); + } + TRACE_GOTO(chip, SetICVFinish); + } +#endif + +SetICVFinish: + kfree(buf); + return retval; +} + +#endif /* SUPPORT_MAGIC_GATE */ diff --git a/drivers/staging/rts5139/ms_mg.h b/drivers/staging/rts5139/ms_mg.h new file mode 100644 index 00000000000..e2ca55085f9 --- /dev/null +++ b/drivers/staging/rts5139/ms_mg.h @@ -0,0 +1,41 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_MS_MG_H +#define __RTS51X_MS_MG_H + +#include "rts51x_chip.h" +#include "ms.h" + +int mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_get_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int mg_set_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip); + +#endif /* __RTS51X_MS_MG_H */ diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c new file mode 100644 index 00000000000..d9cee6d0b12 --- /dev/null +++ b/drivers/staging/rts5139/rts51x.c @@ -0,0 +1,967 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "ms.h" +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_card.h" +#include "rts51x_scsi.h" +#include "rts51x_transport.h" +#include "rts51x_fop.h" + +MODULE_DESCRIPTION(RTS51X_DESC); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRIVER_VERSION); + +#ifdef SCSI_SCAN_DELAY +static unsigned int delay_use = 5; +module_param(delay_use, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device"); +#endif + +static int auto_delink_en; +module_param(auto_delink_en, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(auto_delink_en, "enable auto delink"); + +static int ss_en; +module_param(ss_en, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(ss_en, "enable selective suspend"); + +static int ss_delay = 50; +module_param(ss_delay, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(ss_delay, + "seconds to delay before entering selective suspend"); + +static int needs_remote_wakeup; +module_param(needs_remote_wakeup, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(needs_remote_wakeup, "ss state needs remote wakeup supported"); + +#ifdef SUPPORT_FILE_OP +static const struct file_operations rts51x_fops = { + .owner = THIS_MODULE, + .read = rts51x_read, + .write = rts51x_write, + .unlocked_ioctl = rts51x_ioctl, + .open = rts51x_open, + .release = rts51x_release, +}; + +/* + * usb class driver info in order to get a minor number from the usb core, + * and to have the device registered with the driver core + */ +static struct usb_class_driver rts51x_class = { + .name = "rts51x%d", + .fops = &rts51x_fops, + .minor_base = 192, +}; +#endif + +#ifdef CONFIG_PM /* Minimal support for suspend and resume */ + +static inline void usb_autopm_enable(struct usb_interface *intf) +{ + atomic_set(&intf->pm_usage_cnt, 1); + usb_autopm_put_interface(intf); +} + +static inline void usb_autopm_disable(struct usb_interface *intf) +{ + atomic_set(&intf->pm_usage_cnt, 0); + usb_autopm_get_interface(intf); +} + +void rts51x_try_to_enter_ss(struct rts51x_chip *chip) +{ + RTS51X_DEBUGP("Ready to enter SS state\n"); + usb_autopm_enable(chip->usb->pusb_intf); +} + +void rts51x_try_to_exit_ss(struct rts51x_chip *chip) +{ + RTS51X_DEBUGP("Exit from SS state\n"); + usb_autopm_disable(chip->usb->pusb_intf); +} + +int rts51x_suspend(struct usb_interface *iface, pm_message_t message) +{ + struct rts51x_chip *chip = usb_get_intfdata(iface); + + RTS51X_DEBUGP("%s, message.event = 0x%x\n", __func__, message.event); + + /* Wait until no command is running */ + mutex_lock(&chip->usb->dev_mutex); + + chip->fake_card_ready = chip->card_ready; + rts51x_do_before_power_down(chip); + + if (message.event == PM_EVENT_AUTO_SUSPEND) { + RTS51X_DEBUGP("Enter SS state"); + chip->resume_from_scsi = 0; + RTS51X_SET_STAT(chip, STAT_SS); + } else { + RTS51X_DEBUGP("Enter SUSPEND state"); + RTS51X_SET_STAT(chip, STAT_SUSPEND); + } + + /* When runtime PM is working, we'll set a flag to indicate + * whether we should autoresume when a SCSI request arrives. */ + + mutex_unlock(&chip->usb->dev_mutex); + return 0; +} + +int rts51x_resume(struct usb_interface *iface) +{ + struct rts51x_chip *chip = usb_get_intfdata(iface); + + RTS51X_DEBUGP("%s\n", __func__); + + if (!RTS51X_CHK_STAT(chip, STAT_SS) || !chip->resume_from_scsi) { + mutex_lock(&chip->usb->dev_mutex); + + if (chip->option.ss_en) { + if (GET_PM_USAGE_CNT(chip) <= 0) { + /* Remote wake up, increase pm_usage_cnt */ + RTS51X_DEBUGP("Incr pm_usage_cnt\n"); + SET_PM_USAGE_CNT(chip, 1); + } + } + + RTS51X_SET_STAT(chip, STAT_RUN); + + rts51x_init_chip(chip); + rts51x_init_cards(chip); + + mutex_unlock(&chip->usb->dev_mutex); + } + + return 0; +} + +int rts51x_reset_resume(struct usb_interface *iface) +{ + struct rts51x_chip *chip = usb_get_intfdata(iface); + + RTS51X_DEBUGP("%s\n", __func__); + + mutex_lock(&chip->usb->dev_mutex); + + RTS51X_SET_STAT(chip, STAT_RUN); + + if (chip->option.ss_en) + SET_PM_USAGE_CNT(chip, 1); + + rts51x_init_chip(chip); + rts51x_init_cards(chip); + + mutex_unlock(&chip->usb->dev_mutex); + + /* FIXME: Notify the subdrivers that they need to reinitialize + * the device */ + return 0; +} + +#else /* CONFIG_PM */ + +void rts51x_try_to_enter_ss(struct rts51x_chip *chip) +{ +} + +void rts51x_try_to_exit_ss(struct rts51x_chip *chip) +{ +} + +#endif /* CONFIG_PM */ + +/* + * The next two routines get called just before and just after + * a USB port reset, whether from this driver or a different one. + */ + +int rts51x_pre_reset(struct usb_interface *iface) +{ + struct rts51x_chip *chip = usb_get_intfdata(iface); + + RTS51X_DEBUGP("%s\n", __func__); + + /* Make sure no command runs during the reset */ + mutex_lock(&chip->usb->dev_mutex); + return 0; +} + +int rts51x_post_reset(struct usb_interface *iface) +{ + struct rts51x_chip *chip = usb_get_intfdata(iface); + + RTS51X_DEBUGP("%s\n", __func__); + + /* Report the reset to the SCSI core */ + /* usb_stor_report_bus_reset(us); */ + + /* FIXME: Notify the subdrivers that they need to reinitialize + * the device */ + + mutex_unlock(&chip->usb->dev_mutex); + return 0; +} + +static int rts51x_control_thread(void *__chip) +{ + struct rts51x_chip *chip = (struct rts51x_chip *)__chip; + struct Scsi_Host *host = rts51x_to_host(chip); + + for (;;) { + if (wait_for_completion_interruptible(&chip->usb->cmnd_ready)) + break; + + if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { + RTS51X_DEBUGP("-- exiting from rts51x-control\n"); + break; + } + + /* lock the device pointers */ + mutex_lock(&(chip->usb->dev_mutex)); + + /* lock access to the state */ + scsi_lock(host); + + /* When we are called with no command pending, we're done */ + if (chip->srb == NULL) { + scsi_unlock(host); + mutex_unlock(&chip->usb->dev_mutex); + RTS51X_DEBUGP("-- exiting from control thread\n"); + break; + } + + /* has the command timed out *already* ? */ + if (test_bit(FLIDX_TIMED_OUT, &chip->usb->dflags)) { + chip->srb->result = DID_ABORT << 16; + goto SkipForAbort; + } + + scsi_unlock(host); + + /* reject the command if the direction indicator + * is UNKNOWN + */ + if (chip->srb->sc_data_direction == DMA_BIDIRECTIONAL) { + RTS51X_DEBUGP("UNKNOWN data direction\n"); + chip->srb->result = DID_ERROR << 16; + } + + /* reject if target != 0 or if LUN is higher than + * the maximum known LUN + */ + else if (chip->srb->device->id) { + RTS51X_DEBUGP("Bad target number (%d:%d)\n", + chip->srb->device->id, + chip->srb->device->lun); + chip->srb->result = DID_BAD_TARGET << 16; + } + + else if (chip->srb->device->lun > chip->max_lun) { + RTS51X_DEBUGP("Bad LUN (%d:%d)\n", + chip->srb->device->id, + chip->srb->device->lun); + chip->srb->result = DID_BAD_TARGET << 16; + } + + /* we've got a command, let's do it! */ + else { + RTS51X_DEBUG(scsi_show_command(chip->srb)); + rts51x_invoke_transport(chip->srb, chip); + } + + /* lock access to the state */ + scsi_lock(host); + + /* indicate that the command is done */ + if (chip->srb->result != DID_ABORT << 16) + chip->srb->scsi_done(chip->srb); + else +SkipForAbort : + RTS51X_DEBUGP("scsi command aborted\n"); + + /* If an abort request was received we need to signal that + * the abort has finished. The proper test for this is + * the TIMED_OUT flag, not srb->result == DID_ABORT, because + * the timeout might have occurred after the command had + * already completed with a different result code. */ + if (test_bit(FLIDX_TIMED_OUT, &chip->usb->dflags)) { + complete(&(chip->usb->notify)); + + /* Allow USB transfers to resume */ + clear_bit(FLIDX_ABORTING, &chip->usb->dflags); + clear_bit(FLIDX_TIMED_OUT, &chip->usb->dflags); + } + + /* finished working on this command */ + chip->srb = NULL; + scsi_unlock(host); + + /* unlock the device pointers */ + mutex_unlock(&chip->usb->dev_mutex); + } /* for (;;) */ + + complete(&chip->usb->control_exit); + + /* Wait until we are told to stop */ +/* for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_stop()) + break; + schedule(); + } + __set_current_state(TASK_RUNNING);*/ + return 0; +} + +static int rts51x_polling_thread(void *__chip) +{ + struct rts51x_chip *chip = (struct rts51x_chip *)__chip; + +#ifdef SCSI_SCAN_DELAY + /* Wait until SCSI scan finished */ + wait_timeout((delay_use + 5) * HZ); +#endif + + for (;;) { + wait_timeout(POLLING_INTERVAL); + + /* if the device has disconnected, we are free to exit */ + if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { + RTS51X_DEBUGP("-- exiting from rts51x-polling\n"); + break; + } + + /* if the device has disconnected, we are free to exit */ + /* if (kthread_should_stop()) { + printk(KERN_INFO "Stop polling thread!\n"); + break; + } */ + +#ifdef CONFIG_PM + if (RTS51X_CHK_STAT(chip, STAT_SS) || + RTS51X_CHK_STAT(chip, STAT_SS_PRE) || + RTS51X_CHK_STAT(chip, STAT_SUSPEND)) { + continue; + } + + if (ss_en) { + if (RTS51X_CHK_STAT(chip, STAT_IDLE)) { + if (chip->ss_counter < + (ss_delay * 1000 / POLLING_INTERVAL)) { + chip->ss_counter++; + } else { + /* Prepare SS state */ + RTS51X_SET_STAT(chip, STAT_SS_PRE); + rts51x_try_to_enter_ss(chip); + continue; + } + } else { + chip->ss_counter = 0; + } + } +#endif + + mspro_polling_format_status(chip); + + /* lock the device pointers */ + mutex_lock(&(chip->usb->dev_mutex)); + + rts51x_polling_func(chip); + + /* unlock the device pointers */ + mutex_unlock(&chip->usb->dev_mutex); + } /* for (;;) */ + + complete(&chip->usb->polling_exit); + + /* Wait until we are told to stop */ + /* for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_stop()) + break; + schedule(); + } + __set_current_state(TASK_RUNNING); */ + return 0; +} + +#ifdef SCSI_SCAN_DELAY +/* Thread to carry out delayed SCSI-device scanning */ +static int rts51x_scan_thread(void *__chip) +{ + struct rts51x_chip *chip = (struct rts51x_chip *)__chip; + + printk(KERN_DEBUG + "rts51x: device found at %d\n", chip->usb->pusb_dev->devnum); + + set_freezable(); + /* Wait for the timeout to expire or for a disconnect */ + if (delay_use > 0) { + printk(KERN_DEBUG "rts51x: waiting for device " + "to settle before scanning\n"); + wait_event_freezable_timeout(chip->usb->delay_wait, + test_bit(FLIDX_DONT_SCAN, + &chip->usb->dflags), + delay_use * HZ); + } + + /* If the device is still connected, perform the scanning */ + if (!test_bit(FLIDX_DONT_SCAN, &chip->usb->dflags)) { + scsi_scan_host(rts51x_to_host(chip)); + printk(KERN_DEBUG "rts51x: device scan complete\n"); + + /* Should we unbind if no devices were detected? */ + } + + complete_and_exit(&chip->usb->scanning_done, 0); +} +#endif + +/* Associate our private data with the USB device */ +static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) +{ + struct rts51x_usb *rts51x = chip->usb; +#ifdef SUPPORT_FILE_OP + int retval; +#endif + + /* Fill in the device-related fields */ + rts51x->pusb_dev = interface_to_usbdev(intf); + rts51x->pusb_intf = intf; + rts51x->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; + RTS51X_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", + le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), + le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), + le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); + RTS51X_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", + intf->cur_altsetting->desc.bInterfaceSubClass, + intf->cur_altsetting->desc.bInterfaceProtocol); + + /* Store our private data in the interface */ + usb_set_intfdata(intf, chip); + +#ifdef SUPPORT_FILE_OP + /* we can register the device now, as it is ready */ + retval = usb_register_dev(intf, &rts51x_class); + if (retval) { + /* something prevented us from registering this driver */ + RTS51X_DEBUGP("Not able to get a minor for this device."); + usb_set_intfdata(intf, NULL); + return -ENOMEM; + } +#endif + + /* Allocate the device-related DMA-mapped buffers */ + rts51x->cr = usb_buffer_alloc(rts51x->pusb_dev, sizeof(*rts51x->cr), + GFP_KERNEL, &rts51x->cr_dma); + if (!rts51x->cr) { + RTS51X_DEBUGP("usb_ctrlrequest allocation failed\n"); + usb_set_intfdata(intf, NULL); + return -ENOMEM; + } + + rts51x->iobuf = usb_buffer_alloc(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, + GFP_KERNEL, &rts51x->iobuf_dma); + if (!rts51x->iobuf) { + RTS51X_DEBUGP("I/O buffer allocation failed\n"); + usb_set_intfdata(intf, NULL); + return -ENOMEM; + } + return 0; +} + +static void rts51x_init_options(struct rts51x_chip *chip) +{ + struct rts51x_option *option = &(chip->option); + + option->led_blink_speed = 7; + option->mspro_formatter_enable = 1; + + option->fpga_sd_sdr104_clk = CLK_100; + option->fpga_sd_sdr50_clk = CLK_100; + option->fpga_sd_ddr50_clk = CLK_100; + option->fpga_sd_hs_clk = CLK_100; + option->fpga_mmc_52m_clk = CLK_80; + option->fpga_ms_hg_clk = CLK_80; + option->fpga_ms_4bit_clk = CLK_80; + + option->asic_sd_sdr104_clk = 98; + option->asic_sd_sdr50_clk = 98; + option->asic_sd_ddr50_clk = 98; + option->asic_sd_hs_clk = 97; + option->asic_mmc_52m_clk = 95; + option->asic_ms_hg_clk = 116; + option->asic_ms_4bit_clk = 77; + + option->sd_ddr_tx_phase = 0; + option->mmc_ddr_tx_phase = 1; + + option->sd_speed_prior = 0; + option->sd_ctl = + SD_PUSH_POINT_AUTO | SD_SAMPLE_POINT_AUTO | SUPPORT_UHS50_MMC44; + + option->ss_en = ss_en; + option->ss_delay = ss_delay; + option->needs_remote_wakeup = needs_remote_wakeup; + + option->auto_delink_en = auto_delink_en; + + option->FT2_fast_mode = 0; + option->pwr_delay = 800; + option->xd_rw_step = 0; + option->D3318_off_delay = 50; + option->delink_delay = 100; + option->rts5129_D3318_off_enable = 0; + option->sd20_pad_drive = 0; + option->reset_or_rw_fail_set_pad_drive = 1; + option->rcc_fail_flag = 0; + option->rcc_bug_fix_en = 1; + option->debounce_num = 2; + option->polling_time = 100; + option->led_toggle_interval = 6; + option->xd_rwn_step = 0; + option->sd_send_status_en = 0; + option->sdr50_tx_phase = 0x01; + option->sdr50_rx_phase = 0x05; + option->ddr50_tx_phase = 0x09; + option->ddr50_rx_phase = 0x06; + option->sdr50_phase_sel = 0; + option->sd30_pad_drive = 1; + option->ms_errreg_fix = 0; + option->reset_mmc_first = 0; + option->speed_mmc = 1; + option->led_always_on = 0; +} + +/* Get the pipe settings */ +static int get_pipes(struct rts51x_chip *chip) +{ + struct rts51x_usb *rts51x = chip->usb; + struct usb_host_interface *altsetting = + rts51x->pusb_intf->cur_altsetting; + int i; + struct usb_endpoint_descriptor *ep; + struct usb_endpoint_descriptor *ep_in = NULL; + struct usb_endpoint_descriptor *ep_out = NULL; + struct usb_endpoint_descriptor *ep_int = NULL; + + /* + * Find the first endpoint of each type we need. + * We are expecting a minimum of 2 endpoints - in and out (bulk). + * An optional interrupt-in is OK (necessary for CBI protocol). + * We will ignore any others. + */ + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { + ep = &altsetting->endpoint[i].desc; + + if (usb_endpoint_xfer_bulk(ep)) { + if (usb_endpoint_dir_in(ep)) { + if (!ep_in) + ep_in = ep; + } else { + if (!ep_out) + ep_out = ep; + } + } + + else if (usb_endpoint_is_int_in(ep)) { + if (!ep_int) + ep_int = ep; + } + } + + if (!ep_in || !ep_out) { + RTS51X_DEBUGP("Endpoint sanity check failed!" + "Rejecting dev.\n"); + return -EIO; + } + + /* Calculate and store the pipe values */ + rts51x->send_ctrl_pipe = usb_sndctrlpipe(rts51x->pusb_dev, 0); + rts51x->recv_ctrl_pipe = usb_rcvctrlpipe(rts51x->pusb_dev, 0); + rts51x->send_bulk_pipe = usb_sndbulkpipe(rts51x->pusb_dev, + usb_endpoint_num(ep_out)); + rts51x->recv_bulk_pipe = usb_rcvbulkpipe(rts51x->pusb_dev, + usb_endpoint_num(ep_in)); + if (ep_int) { + rts51x->recv_intr_pipe = usb_rcvintpipe(rts51x->pusb_dev, + usb_endpoint_num + (ep_int)); + rts51x->ep_bInterval = ep_int->bInterval; + } + return 0; +} + +/* Initialize all the dynamic resources we need */ +static int rts51x_acquire_resources(struct rts51x_chip *chip) +{ + struct rts51x_usb *rts51x = chip->usb; + int retval; + + rts51x->current_urb = usb_alloc_urb(0, GFP_KERNEL); + if (!rts51x->current_urb) { + RTS51X_DEBUGP("URB allocation failed\n"); + return -ENOMEM; + } + + rts51x->intr_urb = usb_alloc_urb(0, GFP_KERNEL); + if (!rts51x->intr_urb) { + RTS51X_DEBUGP("URB allocation failed\n"); + return -ENOMEM; + } + + chip->cmd_buf = chip->rsp_buf = rts51x->iobuf; + + rts51x_init_options(chip); + + /* Init rts51xx device */ + retval = rts51x_init_chip(chip); + if (retval != STATUS_SUCCESS) + return -EIO; + + return 0; +} + +/* Release all our dynamic resources */ +static void rts51x_release_resources(struct rts51x_chip *chip) +{ + RTS51X_DEBUGP("-- %s\n", __func__); + + /* Tell the control thread to exit. The SCSI host must + * already have been removed and the DISCONNECTING flag set + * so that we won't accept any more commands. + */ + RTS51X_DEBUGP("-- sending exit command to thread\n"); + complete(&chip->usb->cmnd_ready); + if (chip->usb->ctl_thread) + wait_for_completion(&chip->usb->control_exit); + /* kthread_stop(chip->usb->ctl_thread); */ + if (chip->usb->polling_thread) + wait_for_completion(&chip->usb->polling_exit); + + /* if (chip->usb->polling_thread) + kthread_stop(chip->usb->polling_thread); */ + + wait_timeout(200); + + /* Release rts51xx device here */ + rts51x_release_chip(chip); + + usb_free_urb(chip->usb->current_urb); + usb_free_urb(chip->usb->intr_urb); +} + +/* Dissociate from the USB device */ +static void dissociate_dev(struct rts51x_chip *chip) +{ + struct rts51x_usb *rts51x = chip->usb; + + RTS51X_DEBUGP("-- %s\n", __func__); + + /* Free the device-related DMA-mapped buffers */ + if (rts51x->cr) + usb_buffer_free(rts51x->pusb_dev, sizeof(*rts51x->cr), + rts51x->cr, rts51x->cr_dma); + if (rts51x->iobuf) + usb_buffer_free(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, + rts51x->iobuf, rts51x->iobuf_dma); + + /* Remove our private data from the interface */ + usb_set_intfdata(rts51x->pusb_intf, NULL); + +#ifdef SUPPORT_FILE_OP + /* give back our minor */ + usb_deregister_dev(rts51x->pusb_intf, &rts51x_class); +#endif + + kfree(rts51x); + chip->usb = NULL; +} + +/* First stage of disconnect processing: stop SCSI scanning, + * remove the host, and stop accepting new commands + */ +static void quiesce_and_remove_host(struct rts51x_chip *chip) +{ + struct rts51x_usb *rts51x = chip->usb; + struct Scsi_Host *host = rts51x_to_host(chip); + + /* If the device is really gone, cut short reset delays */ + if (rts51x->pusb_dev->state == USB_STATE_NOTATTACHED) + set_bit(FLIDX_DISCONNECTING, &rts51x->dflags); + +#ifdef SCSI_SCAN_DELAY + /* Prevent SCSI-scanning (if it hasn't started yet) + * and wait for the SCSI-scanning thread to stop. + */ + set_bit(FLIDX_DONT_SCAN, &rts51x->dflags); + wake_up(&rts51x->delay_wait); + wait_for_completion(&rts51x->scanning_done); +#endif + + /* Removing the host will perform an orderly shutdown: caches + * synchronized, disks spun down, etc. + */ + scsi_remove_host(host); + + /* Prevent any new commands from being accepted and cut short + * reset delays. + */ + scsi_lock(host); + set_bit(FLIDX_DISCONNECTING, &rts51x->dflags); + scsi_unlock(host); +#ifdef SCSI_SCAN_DELAY + wake_up(&rts51x->delay_wait); +#endif +} + +/* Second stage of disconnect processing: deallocate all resources */ +static void release_everything(struct rts51x_chip *chip) +{ + rts51x_release_resources(chip); + dissociate_dev(chip); + + /* Drop our reference to the host; the SCSI core will free it + * (and "chip" along with it) when the refcount becomes 0. */ + scsi_host_put(rts51x_to_host(chip)); +} + +static int rts51x_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + struct Scsi_Host *host; + struct rts51x_chip *chip; + struct rts51x_usb *rts51x; + int result; + struct task_struct *th; + + RTS51X_DEBUGP("%s detected\n", RTS51X_NAME); + + rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL); + if (!rts51x) { + printk(KERN_WARNING RTS51X_TIP + "Unable to allocate rts51x_usb\n"); + return -ENOMEM; + } + + /* + * Ask the SCSI layer to allocate a host structure, with extra + * space at the end for our private us_data structure. + */ + host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip)); + if (!host) { + printk(KERN_WARNING RTS51X_TIP + "Unable to allocate the scsi host\n"); + kfree(rts51x); + return -ENOMEM; + } + + /* + * Allow 16-byte CDBs and thus > 2TB + */ + host->max_cmd_len = 16; + chip = host_to_rts51x(host); + memset(chip, 0, sizeof(struct rts51x_chip)); + + chip->vendor_id = id->idVendor; + chip->product_id = id->idProduct; + + mutex_init(&(rts51x->dev_mutex)); + init_completion(&rts51x->cmnd_ready); + init_completion(&rts51x->control_exit); + init_completion(&rts51x->polling_exit); + init_completion(&(rts51x->notify)); +#ifdef SCSI_SCAN_DELAY + init_waitqueue_head(&rts51x->delay_wait); + init_completion(&rts51x->scanning_done); +#endif + + chip->usb = rts51x; + + /* Associate the us_data structure with the USB device */ + result = associate_dev(chip, intf); + if (result) + goto BadDevice; + + /* Find the endpoints and calculate pipe values */ + result = get_pipes(chip); + if (result) + goto BadDevice; + + /* Acquire all the other resources and add the host */ + result = rts51x_acquire_resources(chip); + if (result) + goto BadDevice; + + /* Start up our control thread */ + th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD); + if (IS_ERR(th)) { + printk(KERN_WARNING RTS51X_TIP + "Unable to start control thread\n"); + result = PTR_ERR(th); + goto BadDevice; + } + rts51x->ctl_thread = th; + + result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev); + if (result) { + printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n"); + goto BadDevice; + } +#ifdef SCSI_SCAN_DELAY + /* Start up the thread for delayed SCSI-device scanning */ + th = kthread_create(rts51x_scan_thread, chip, RTS51X_SCAN_THREAD); + if (IS_ERR(th)) { + printk(KERN_WARNING RTS51X_TIP + "Unable to start the device-scanning thread\n"); + complete(&rts51x->scanning_done); + quiesce_and_remove_host(chip); + result = PTR_ERR(th); + goto BadDevice; + } + + wake_up_process(th); +#else + scsi_scan_host(rts51x_to_host(chip)); +#endif + + /* Start up our polling thread */ + th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD); + if (IS_ERR(th)) { + printk(KERN_WARNING RTS51X_TIP + "Unable to start polling thread\n"); + result = PTR_ERR(th); + goto BadDevice; + } + rts51x->polling_thread = th; + +#ifdef CONFIG_PM + if (ss_en) { + rts51x->pusb_intf->needs_remote_wakeup = needs_remote_wakeup; + SET_PM_USAGE_CNT(chip, 1); + RTS51X_DEBUGP("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip)); + } +#endif + + return 0; + + /* We come here if there are any problems */ +BadDevice: + RTS51X_DEBUGP("rts51x_probe() failed\n"); + release_everything(chip); + return result; +} + +static void rts51x_disconnect(struct usb_interface *intf) +{ + struct rts51x_chip *chip = (struct rts51x_chip *)usb_get_intfdata(intf); + + RTS51X_DEBUGP("rts51x_disconnect() called\n"); + quiesce_and_remove_host(chip); + release_everything(chip); +} + +/*********************************************************************** + * Initialization and registration + ***********************************************************************/ + +struct usb_device_id rts5139_usb_ids[] = { + {USB_DEVICE(0x0BDA, 0x0139)}, + {USB_DEVICE(0x0BDA, 0x0129)}, + {} /* Terminating entry */ +}; +EXPORT_SYMBOL_GPL(rts5139_usb_ids); + +MODULE_DEVICE_TABLE(usb, rts5139_usb_ids); + +struct usb_driver rts51x_driver = { + .name = RTS51X_NAME, + .probe = rts51x_probe, + .disconnect = rts51x_disconnect, + .suspend = rts51x_suspend, + .resume = rts51x_resume, + .reset_resume = rts51x_reset_resume, + .pre_reset = rts51x_pre_reset, + .post_reset = rts51x_post_reset, + .id_table = rts5139_usb_ids, + .soft_unbind = 1, +}; + +static int __init rts51x_init(void) +{ + int retval; + + printk(KERN_INFO "Initializing %s USB card reader driver...\n", + RTS51X_NAME); + + /* register the driver, return usb_register return code if error */ + retval = usb_register(&rts51x_driver); + if (retval == 0) { + printk(KERN_INFO + "Realtek %s USB card reader support registered.\n", + RTS51X_NAME); + } + return retval; +} + +static void __exit rts51x_exit(void) +{ + RTS51X_DEBUGP("rts51x_exit() called\n"); + + /* Deregister the driver + * This will cause disconnect() to be called for each + * attached unit + */ + RTS51X_DEBUGP("-- calling usb_deregister()\n"); + usb_deregister(&rts51x_driver); +} + +module_init(rts51x_init); +module_exit(rts51x_exit); diff --git a/drivers/staging/rts5139/rts51x.h b/drivers/staging/rts5139/rts51x.h new file mode 100644 index 00000000000..9415d5c0550 --- /dev/null +++ b/drivers/staging/rts5139/rts51x.h @@ -0,0 +1,205 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_H +#define __RTS51X_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define DRIVER_VERSION "v1.04" + +#define RTS51X_DESC "Realtek RTS5139/29 USB card reader driver" +#define RTS51X_NAME "rts5139" +#define RTS51X_CTL_THREAD "rts5139-control" +#define RTS51X_SCAN_THREAD "rts5139-scan" +#define RTS51X_POLLING_THREAD "rts5139-polling" + +#define POLLING_IN_THREAD +/* #define SCSI_SCAN_DELAY */ +#define SUPPORT_FILE_OP + +#define wait_timeout_x(task_state, msecs) \ +do { \ + set_current_state((task_state)); \ + schedule_timeout((msecs) * HZ / 1000); \ +} while (0) + +#define wait_timeout(msecs) wait_timeout_x(TASK_INTERRUPTIBLE, (msecs)) + +#define SCSI_LUN(srb) ((srb)->device->lun) + +/* Size of the DMA-mapped I/O buffer */ +#define RTS51X_IOBUF_SIZE 1024 +/* Size of the autosense data buffer */ +#define RTS51X_SENSE_SIZE 18 + +/* Dynamic bitflag definitions (dflags): used in set_bit() etc. */ +#define FLIDX_URB_ACTIVE 0 /* current_urb is in use */ +#define FLIDX_SG_ACTIVE 1 /* current_sg is in use */ +#define FLIDX_ABORTING 2 /* abort is in progress */ +#define FLIDX_DISCONNECTING 3 /* disconnect in progress */ +#define FLIDX_RESETTING 4 /* device reset in progress */ +#define FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */ +#define FLIDX_DONT_SCAN 6 /* don't scan (disconnect) */ + +struct rts51x_chip; + +struct rts51x_usb { + /* The device we're working with + * It's important to note: + * (o) you must hold dev_mutex to change pusb_dev + */ + struct mutex dev_mutex; /* protect pusb_dev */ + struct usb_device *pusb_dev; /* this usb_device */ + struct usb_interface *pusb_intf; /* this interface */ + + unsigned long dflags; /* dynamic atomic bitflags */ + + unsigned int send_bulk_pipe; /* cached pipe values */ + unsigned int recv_bulk_pipe; + unsigned int send_ctrl_pipe; + unsigned int recv_ctrl_pipe; + unsigned int recv_intr_pipe; + + u8 ifnum; /* interface number */ + u8 ep_bInterval; /* interrupt interval */ + + /* control and bulk communications data */ + struct urb *current_urb; /* USB requests */ + struct urb *intr_urb; /* Interrupt USB request */ + struct usb_ctrlrequest *cr; /* control requests */ + struct usb_sg_request current_sg; /* scatter-gather req. */ + unsigned char *iobuf; /* I/O buffer */ + dma_addr_t cr_dma; /* buffer DMA addresses */ + dma_addr_t iobuf_dma; + struct task_struct *ctl_thread; /* the control thread */ + struct task_struct *polling_thread; /* the polling thread */ + + /* mutual exclusion and synchronization structures */ + struct completion cmnd_ready; /* to sleep thread on */ + struct completion control_exit; /* control thread exit */ + struct completion polling_exit; /* polling thread exit */ + struct completion notify; /* thread begin/end */ +#ifdef SCSI_SCAN_DELAY + wait_queue_head_t delay_wait; /* wait during scan, reset */ + struct completion scanning_done; /* wait for scan thread */ +#endif +}; + +extern struct usb_driver rts51x_driver; + +static inline void get_current_time(u8 *timeval_buf, int buf_len) +{ + struct timeval tv; + + if (!timeval_buf || (buf_len < 8)) + return; + + do_gettimeofday(&tv); + + timeval_buf[0] = (u8) (tv.tv_sec >> 24); + timeval_buf[1] = (u8) (tv.tv_sec >> 16); + timeval_buf[2] = (u8) (tv.tv_sec >> 8); + timeval_buf[3] = (u8) (tv.tv_sec); + timeval_buf[4] = (u8) (tv.tv_usec >> 24); + timeval_buf[5] = (u8) (tv.tv_usec >> 16); + timeval_buf[6] = (u8) (tv.tv_usec >> 8); + timeval_buf[7] = (u8) (tv.tv_usec); +} + +#define SND_CTRL_PIPE(chip) ((chip)->usb->send_ctrl_pipe) +#define RCV_CTRL_PIPE(chip) ((chip)->usb->recv_ctrl_pipe) +#define SND_BULK_PIPE(chip) ((chip)->usb->send_bulk_pipe) +#define RCV_BULK_PIPE(chip) ((chip)->usb->recv_bulk_pipe) +#define RCV_INTR_PIPE(chip) ((chip)->usb->recv_intr_pipe) + +/* The scsi_lock() and scsi_unlock() macros protect the sm_state and the + * single queue element srb for write access */ +#define scsi_unlock(host) spin_unlock_irq(host->host_lock) +#define scsi_lock(host) spin_lock_irq(host->host_lock) + +#define GET_PM_USAGE_CNT(chip) \ + atomic_read(&((chip)->usb->pusb_intf->pm_usage_cnt)) +#define SET_PM_USAGE_CNT(chip, cnt) \ + atomic_set(&((chip)->usb->pusb_intf->pm_usage_cnt), (cnt)) + +/* Compatible macros while we switch over */ +static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size, + gfp_t mem_flags, dma_addr_t *dma) +{ + return usb_alloc_coherent(dev, size, mem_flags, dma); +} + +static inline void usb_buffer_free(struct usb_device *dev, size_t size, + void *addr, dma_addr_t dma) +{ + return usb_free_coherent(dev, size, addr, dma); +} + +/* Convert between us_data and the corresponding Scsi_Host */ +static inline struct Scsi_Host *rts51x_to_host(struct rts51x_chip *chip) +{ + return container_of((void *)chip, struct Scsi_Host, hostdata); +} + +static inline struct rts51x_chip *host_to_rts51x(struct Scsi_Host *host) +{ + return (struct rts51x_chip *)(host->hostdata); +} + +/* struct scsi_cmnd transfer buffer access utilities */ +enum xfer_buf_dir { TO_XFER_BUF, FROM_XFER_BUF }; + +/* General routines provided by the usb-storage standard core */ +#ifdef CONFIG_PM +void rts51x_try_to_enter_ss(struct rts51x_chip *chip); +void rts51x_try_to_exit_ss(struct rts51x_chip *chip); +int rts51x_suspend(struct usb_interface *iface, pm_message_t message); +int rts51x_resume(struct usb_interface *iface); +int rts51x_reset_resume(struct usb_interface *iface); +#else +#define rts51x_suspend NULL +#define rts51x_resume NULL +#define rts51x_reset_resume NULL +#endif + +extern struct scsi_host_template rts51x_host_template; + +#endif /* __RTS51X_H */ diff --git a/drivers/staging/rts5139/rts51x_card.c b/drivers/staging/rts5139/rts51x_card.c new file mode 100644 index 00000000000..424a84581b8 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_card.c @@ -0,0 +1,986 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "debug.h" +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_card.h" +#include "rts51x_transport.h" +#include "rts51x_sys.h" +#include "xd.h" +#include "sd.h" +#include "ms.h" + +void do_remaining_work(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + struct xd_info *xd_card = &(chip->xd_card); + struct ms_info *ms_card = &(chip->ms_card); + + if (chip->card_ready & SD_CARD) { + if (sd_card->seq_mode) { + RTS51X_SET_STAT(chip, STAT_RUN); + sd_card->counter++; + } else { + sd_card->counter = 0; + } + } + + if (chip->card_ready & XD_CARD) { + if (xd_card->delay_write.delay_write_flag) { + RTS51X_SET_STAT(chip, STAT_RUN); + xd_card->counter++; + } else { + xd_card->counter = 0; + } + } + + if (chip->card_ready & MS_CARD) { + if (CHK_MSPRO(ms_card)) { + if (ms_card->seq_mode) { + RTS51X_SET_STAT(chip, STAT_RUN); + ms_card->counter++; + } else { + ms_card->counter = 0; + } + } else { + if (ms_card->delay_write.delay_write_flag) { + RTS51X_SET_STAT(chip, STAT_RUN); + ms_card->counter++; + } else { + ms_card->counter = 0; + } + } + } + + if (sd_card->counter > POLLING_WAIT_CNT) + sd_cleanup_work(chip); + + if (xd_card->counter > POLLING_WAIT_CNT) + xd_cleanup_work(chip); + + if (ms_card->counter > POLLING_WAIT_CNT) + ms_cleanup_work(chip); +} + +void do_reset_xd_card(struct rts51x_chip *chip) +{ + int retval; + + if (chip->card2lun[XD_CARD] >= MAX_ALLOWED_LUN_CNT) + return; + + retval = reset_xd_card(chip); + if (retval == STATUS_SUCCESS) { + chip->card_ready |= XD_CARD; + chip->card_fail &= ~XD_CARD; + chip->rw_card[chip->card2lun[XD_CARD]] = xd_rw; + } else { + chip->card_ready &= ~XD_CARD; + chip->card_fail |= XD_CARD; + chip->capacity[chip->card2lun[XD_CARD]] = 0; + chip->rw_card[chip->card2lun[XD_CARD]] = NULL; + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, XD_CLK_EN, 0); + rts51x_send_cmd(chip, MODE_C, 100); + } +} + +void do_reset_sd_card(struct rts51x_chip *chip) +{ + int retval; + + if (chip->card2lun[SD_CARD] >= MAX_ALLOWED_LUN_CNT) + return; + + retval = reset_sd_card(chip); + if (retval == STATUS_SUCCESS) { + chip->card_ready |= SD_CARD; + chip->card_fail &= ~SD_CARD; + chip->rw_card[chip->card2lun[SD_CARD]] = sd_rw; + } else { + chip->card_ready &= ~SD_CARD; + chip->card_fail |= SD_CARD; + chip->capacity[chip->card2lun[SD_CARD]] = 0; + chip->rw_card[chip->card2lun[SD_CARD]] = NULL; + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, SD_CLK_EN, 0); + rts51x_send_cmd(chip, MODE_C, 100); + } +} + +void do_reset_ms_card(struct rts51x_chip *chip) +{ + int retval; + + if (chip->card2lun[MS_CARD] >= MAX_ALLOWED_LUN_CNT) + return; + + retval = reset_ms_card(chip); + if (retval == STATUS_SUCCESS) { + chip->card_ready |= MS_CARD; + chip->card_fail &= ~MS_CARD; + chip->rw_card[chip->card2lun[MS_CARD]] = ms_rw; + } else { + chip->card_ready &= ~MS_CARD; + chip->card_fail |= MS_CARD; + chip->capacity[chip->card2lun[MS_CARD]] = 0; + chip->rw_card[chip->card2lun[MS_CARD]] = NULL; + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0); + rts51x_send_cmd(chip, MODE_C, 100); + } +} + +void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset, + u8 *need_release) +{ + int retval; + u8 release_map = 0, reset_map = 0; + u8 value; + + retval = rts51x_get_card_status(chip, &(chip->card_status)); +#ifdef SUPPORT_OCP + chip->ocp_stat = (chip->card_status >> 4) & 0x03; +#endif + + if (retval != STATUS_SUCCESS) + goto Exit_Debounce; + + if (chip->card_exist) { + rts51x_clear_start_time(chip); + retval = rts51x_read_register(chip, CARD_INT_PEND, &value); + if (retval != STATUS_SUCCESS) { + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, + FIFO_FLUSH); + rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); + value = 0; + } + + if (chip->card_exist & XD_CARD) { + if (!(chip->card_status & XD_CD)) + release_map |= XD_CARD; + } else if (chip->card_exist & SD_CARD) { + /* if (!(chip->card_status & SD_CD)) { */ + if (!(chip->card_status & SD_CD) || (value & SD_INT)) + release_map |= SD_CARD; + } else if (chip->card_exist & MS_CARD) { + /* if (!(chip->card_status & MS_CD)) { */ + if (!(chip->card_status & MS_CD) || (value & MS_INT)) + release_map |= MS_CARD; + } + } else { + if (chip->card_status & XD_CD) { + rts51x_clear_start_time(chip); + reset_map |= XD_CARD; + } else if (chip->card_status & SD_CD) { + rts51x_clear_start_time(chip); + reset_map |= SD_CARD; + } else if (chip->card_status & MS_CD) { + rts51x_clear_start_time(chip); + reset_map |= MS_CARD; + } else { + if (rts51x_check_start_time(chip)) + rts51x_set_start_time(chip); + } + } + + if (CHECK_PKG(chip, QFN24) && reset_map) { + if (chip->card_exist & XD_CARD) { + reset_map = 0; + goto Exit_Debounce; + } + } + + if (reset_map) { + int xd_cnt = 0, sd_cnt = 0, ms_cnt = 0; + int i; + + for (i = 0; i < (chip->option.debounce_num); i++) { + retval = + rts51x_get_card_status(chip, &(chip->card_status)); + if (retval != STATUS_SUCCESS) { + reset_map = release_map = 0; + goto Exit_Debounce; + } + if (chip->card_status & XD_CD) + xd_cnt++; + else + xd_cnt = 0; + if (chip->card_status & SD_CD) + sd_cnt++; + else + sd_cnt = 0; + if (chip->card_status & MS_CD) + ms_cnt++; + else + ms_cnt = 0; + wait_timeout(30); + } + + reset_map = 0; + if (!(chip->card_exist & XD_CARD) + && (xd_cnt > (chip->option.debounce_num - 1))) { + reset_map |= XD_CARD; + } + if (!(chip->card_exist & SD_CARD) + && (sd_cnt > (chip->option.debounce_num - 1))) { + reset_map |= SD_CARD; + } + if (!(chip->card_exist & MS_CARD) + && (ms_cnt > (chip->option.debounce_num - 1))) { + reset_map |= MS_CARD; + } + } + rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, + XD_INT | MS_INT | SD_INT); + +Exit_Debounce: + if (need_reset) + *need_reset = reset_map; + if (need_release) + *need_release = release_map; +} + +void rts51x_init_cards(struct rts51x_chip *chip) +{ + u8 need_reset = 0, need_release = 0; + + card_cd_debounce(chip, &need_reset, &need_release); + + if (need_release) { + RTS51X_DEBUGP("need_release = 0x%x\n", need_release); + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + +#ifdef SUPPORT_OCP + if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { + rts51x_write_register(chip, OCPCTL, MS_OCP_CLEAR, + MS_OCP_CLEAR); + chip->ocp_stat = 0; + RTS51X_DEBUGP("Clear OCP status.\n"); + } +#endif + + if (need_release & XD_CARD) { + chip->card_exist &= ~XD_CARD; + chip->card_ejected = 0; + if (chip->card_ready & XD_CARD) { + release_xd_card(chip); + chip->rw_card[chip->card2lun[XD_CARD]] = NULL; + clear_bit(chip->card2lun[XD_CARD], + &(chip->lun_mc)); + } + } + + if (need_release & SD_CARD) { + chip->card_exist &= ~SD_CARD; + chip->card_ejected = 0; + if (chip->card_ready & SD_CARD) { + release_sd_card(chip); + chip->rw_card[chip->card2lun[SD_CARD]] = NULL; + clear_bit(chip->card2lun[SD_CARD], + &(chip->lun_mc)); + } + } + + if (need_release & MS_CARD) { + chip->card_exist &= ~MS_CARD; + chip->card_ejected = 0; + if (chip->card_ready & MS_CARD) { + release_ms_card(chip); + chip->rw_card[chip->card2lun[MS_CARD]] = NULL; + clear_bit(chip->card2lun[MS_CARD], + &(chip->lun_mc)); + } + } + } + + if (need_reset && !chip->card_ready) { + RTS51X_DEBUGP("need_reset = 0x%x\n", need_reset); + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + if (need_reset & XD_CARD) { + chip->card_exist |= XD_CARD; + do_reset_xd_card(chip); + } else if (need_reset & SD_CARD) { + chip->card_exist |= SD_CARD; + do_reset_sd_card(chip); + } else if (need_reset & MS_CARD) { + chip->card_exist |= MS_CARD; + do_reset_ms_card(chip); + } + } +} + +void rts51x_release_cards(struct rts51x_chip *chip) +{ + if (chip->card_ready & SD_CARD) { + sd_cleanup_work(chip); + release_sd_card(chip); + chip->card_ready &= ~SD_CARD; + } + + if (chip->card_ready & XD_CARD) { + xd_cleanup_work(chip); + release_xd_card(chip); + chip->card_ready &= ~XD_CARD; + } + + if (chip->card_ready & MS_CARD) { + ms_cleanup_work(chip); + release_ms_card(chip); + chip->card_ready &= ~MS_CARD; + } +} + +static inline u8 double_depth(u8 depth) +{ + return ((depth > 1) ? (depth - 1) : depth); +} + +int switch_ssc_clock(struct rts51x_chip *chip, int clk) +{ + struct sd_info *sd_card = &(chip->sd_card); + struct ms_info *ms_card = &(chip->ms_card); + int retval; + u8 N = (u8) (clk - 2), min_N, max_N; + u8 mcu_cnt, div, max_div, ssc_depth; + int sd_vpclk_phase_reset = 0; + + if (chip->cur_clk == clk) + return STATUS_SUCCESS; + + min_N = 60; + max_N = 120; + max_div = CLK_DIV_4; + + RTS51X_DEBUGP("Switch SSC clock to %dMHz\n", clk); + + if ((clk <= 2) || (N > max_N)) + TRACE_RET(chip, STATUS_FAIL); + + mcu_cnt = (u8) (60 / clk + 3); + if (mcu_cnt > 15) + mcu_cnt = 15; + /* To make sure that the SSC clock div_n is + * equal or greater than min_N */ + div = CLK_DIV_1; + while ((N < min_N) && (div < max_div)) { + N = (N + 2) * 2 - 2; + div++; + } + RTS51X_DEBUGP("N = %d, div = %d\n", N, div); + + if (chip->option.ssc_en) { + if (chip->cur_card == SD_CARD) { + if (CHK_SD_SDR104(sd_card)) { + ssc_depth = chip->option.ssc_depth_sd_sdr104; + } else if (CHK_SD_SDR50(sd_card)) { + ssc_depth = chip->option.ssc_depth_sd_sdr50; + } else if (CHK_SD_DDR50(sd_card)) { + ssc_depth = + double_depth(chip->option. + ssc_depth_sd_ddr50); + } else if (CHK_SD_HS(sd_card)) { + ssc_depth = + double_depth(chip->option.ssc_depth_sd_hs); + } else if (CHK_MMC_52M(sd_card) + || CHK_MMC_DDR52(sd_card)) { + ssc_depth = + double_depth(chip->option. + ssc_depth_mmc_52m); + } else { + ssc_depth = + double_depth(chip->option. + ssc_depth_low_speed); + } + } else if (chip->cur_card == MS_CARD) { + if (CHK_MSPRO(ms_card)) { + if (CHK_HG8BIT(ms_card)) { + ssc_depth = + double_depth(chip->option. + ssc_depth_ms_hg); + } else { + ssc_depth = + double_depth(chip->option. + ssc_depth_ms_4bit); + } + } else { + if (CHK_MS4BIT(ms_card)) { + ssc_depth = + double_depth(chip->option. + ssc_depth_ms_4bit); + } else { + ssc_depth = + double_depth(chip->option. + ssc_depth_low_speed); + } + } + } else { + ssc_depth = + double_depth(chip->option.ssc_depth_low_speed); + } + + if (ssc_depth) { + if (div == CLK_DIV_2) { + /* If clock divided by 2, ssc depth must + * be multiplied by 2 */ + if (ssc_depth > 1) + ssc_depth -= 1; + else + ssc_depth = SSC_DEPTH_2M; + } else if (div == CLK_DIV_4) { + /* If clock divided by 4, ssc depth must + * be multiplied by 4 */ + if (ssc_depth > 2) + ssc_depth -= 2; + else + ssc_depth = SSC_DEPTH_2M; + } + } + } else { + /* Disable SSC */ + ssc_depth = 0; + } + + RTS51X_DEBUGP("ssc_depth = %d\n", ssc_depth); + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, CLK_CHANGE); + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, + (div << 4) | mcu_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CTL2, SSC_DEPTH_MASK, + ssc_depth); + rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, N); + if (sd_vpclk_phase_reset) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, + PHASE_NOT_RESET, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, + PHASE_NOT_RESET, PHASE_NOT_RESET); + } + + retval = rts51x_send_cmd(chip, MODE_C, 2000); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (chip->option.ssc_en && ssc_depth) + rts51x_write_register(chip, SSC_CTL1, 0xff, 0xD0); + else + rts51x_write_register(chip, SSC_CTL1, 0xff, 0x50); + udelay(100); + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); + + chip->cur_clk = clk; + + return STATUS_SUCCESS; +} + +int switch_normal_clock(struct rts51x_chip *chip, int clk) +{ + int retval; + u8 sel, div, mcu_cnt; + int sd_vpclk_phase_reset = 0; + + if (chip->cur_clk == clk) + return STATUS_SUCCESS; + + if (chip->cur_card == SD_CARD) { + struct sd_info *sd_card = &(chip->sd_card); + if (CHK_SD30_SPEED(sd_card) || CHK_MMC_DDR52(sd_card)) + sd_vpclk_phase_reset = 1; + } + + switch (clk) { + case CLK_20: + RTS51X_DEBUGP("Switch clock to 20MHz\n"); + sel = SSC_80; + div = CLK_DIV_4; + mcu_cnt = 5; + break; + + case CLK_30: + RTS51X_DEBUGP("Switch clock to 30MHz\n"); + sel = SSC_60; + div = CLK_DIV_2; + mcu_cnt = 4; + break; + + case CLK_40: + RTS51X_DEBUGP("Switch clock to 40MHz\n"); + sel = SSC_80; + div = CLK_DIV_2; + mcu_cnt = 3; + break; + + case CLK_50: + RTS51X_DEBUGP("Switch clock to 50MHz\n"); + sel = SSC_100; + div = CLK_DIV_2; + mcu_cnt = 3; + break; + + case CLK_60: + RTS51X_DEBUGP("Switch clock to 60MHz\n"); + sel = SSC_60; + div = CLK_DIV_1; + mcu_cnt = 3; + break; + + case CLK_80: + RTS51X_DEBUGP("Switch clock to 80MHz\n"); + sel = SSC_80; + div = CLK_DIV_1; + mcu_cnt = 2; + break; + + case CLK_100: + RTS51X_DEBUGP("Switch clock to 100MHz\n"); + sel = SSC_100; + div = CLK_DIV_1; + mcu_cnt = 2; + break; + + /* case CLK_120: + RTS51X_DEBUGP("Switch clock to 120MHz\n"); + sel = SSC_120; + div = CLK_DIV_1; + mcu_cnt = 2; + break; + + case CLK_150: + RTS51X_DEBUGP("Switch clock to 150MHz\n"); + sel = SSC_150; + div = CLK_DIV_1; + mcu_cnt = 2; + break; */ + + default: + RTS51X_DEBUGP("Try to switch to an illegal clock (%d)\n", + clk); + TRACE_RET(chip, STATUS_FAIL); + } + + if (!sd_vpclk_phase_reset) { + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, + CLK_CHANGE); + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, + (div << 4) | mcu_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CLK_FPGA_SEL, 0xFF, + sel); + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, 0); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, + CLK_CHANGE); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, + PHASE_NOT_RESET, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK1_CTL, + PHASE_NOT_RESET, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, + (div << 4) | mcu_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CLK_FPGA_SEL, 0xFF, + sel); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + udelay(200); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, + PHASE_NOT_RESET, PHASE_NOT_RESET); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK1_CTL, + PHASE_NOT_RESET, PHASE_NOT_RESET); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + udelay(200); + + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); + } + + chip->cur_clk = clk; + + return STATUS_SUCCESS; +} + +int card_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 sec_addr, + u16 sec_cnt) +{ + int retval; + unsigned int lun = SCSI_LUN(srb); + int i; + + if (chip->rw_card[lun] == NULL) + return STATUS_FAIL; + + RTS51X_DEBUGP("%s card, sector addr: 0x%x, sector cnt: %d\n", + (srb->sc_data_direction == + DMA_TO_DEVICE) ? "Write" : "Read", sec_addr, sec_cnt); + + chip->rw_need_retry = 0; + for (i = 0; i < 3; i++) { + retval = chip->rw_card[lun] (srb, chip, sec_addr, sec_cnt); + if (retval != STATUS_SUCCESS) { + CATCH_TRIGGER(chip); + if (chip->option.reset_or_rw_fail_set_pad_drive) { + rts51x_write_register(chip, CARD_DRIVE_SEL, + SD20_DRIVE_MASK, + DRIVE_8mA); + } + } + + if (!chip->rw_need_retry) + break; + + RTS51X_DEBUGP("Retry RW, (i = %d\n)", i); + } + + return retval; +} + +u8 get_lun_card(struct rts51x_chip *chip, unsigned int lun) +{ + if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD) + return (u8) XD_CARD; + else if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD) + return (u8) SD_CARD; + else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD) + return (u8) MS_CARD; + + return 0; +} + +int card_share_mode(struct rts51x_chip *chip, int card) +{ + u8 value; + + if (card == SD_CARD) + value = CARD_SHARE_SD; + else if (card == MS_CARD) + value = CARD_SHARE_MS; + else if (card == XD_CARD) + value = CARD_SHARE_XD; + else + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_WRITE_REG(chip, CARD_SHARE_MODE, CARD_SHARE_MASK, value); + + return STATUS_SUCCESS; +} + +int rts51x_select_card(struct rts51x_chip *chip, int card) +{ + int retval; + + if (chip->cur_card != card) { + u8 mod; + + if (card == SD_CARD) + mod = SD_MOD_SEL; + else if (card == MS_CARD) + mod = MS_MOD_SEL; + else if (card == XD_CARD) + mod = XD_MOD_SEL; + else + TRACE_RET(chip, STATUS_FAIL); + RTS51X_WRITE_REG(chip, CARD_SELECT, 0x07, mod); + chip->cur_card = card; + + retval = card_share_mode(chip, card); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +void eject_card(struct rts51x_chip *chip, unsigned int lun) +{ + RTS51X_DEBUGP("eject card\n"); + RTS51X_SET_STAT(chip, STAT_RUN); + do_remaining_work(chip); + + if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD) { + release_sd_card(chip); + chip->card_ejected |= SD_CARD; + chip->card_ready &= ~SD_CARD; + chip->capacity[lun] = 0; + } else if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD) { + release_xd_card(chip); + chip->card_ejected |= XD_CARD; + chip->card_ready &= ~XD_CARD; + chip->capacity[lun] = 0; + } else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD) { + release_ms_card(chip); + chip->card_ejected |= MS_CARD; + chip->card_ready &= ~MS_CARD; + chip->capacity[lun] = 0; + } + rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, + XD_INT | MS_INT | SD_INT); +} + +void trans_dma_enable(enum dma_data_direction dir, struct rts51x_chip *chip, + u32 byte_cnt, u8 pack_size) +{ + if (pack_size > DMA_1024) + pack_size = DMA_512; + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC3, 0xFF, + (u8) (byte_cnt >> 24)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC2, 0xFF, + (u8) (byte_cnt >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC1, 0xFF, + (u8) (byte_cnt >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC0, 0xFF, (u8) byte_cnt); + + if (dir == DMA_FROM_DEVICE) { + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_CTL, + 0x03 | DMA_PACK_SIZE_MASK, + DMA_DIR_FROM_CARD | DMA_EN | pack_size); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_CTL, + 0x03 | DMA_PACK_SIZE_MASK, + DMA_DIR_TO_CARD | DMA_EN | pack_size); + } +} + +int enable_card_clock(struct rts51x_chip *chip, u8 card) +{ + u8 clk_en = 0; + + if (card & XD_CARD) + clk_en |= XD_CLK_EN; + if (card & SD_CARD) + clk_en |= SD_CLK_EN; + if (card & MS_CARD) + clk_en |= MS_CLK_EN; + + RTS51X_WRITE_REG(chip, CARD_CLK_EN, clk_en, clk_en); + + return STATUS_SUCCESS; +} + +int disable_card_clock(struct rts51x_chip *chip, u8 card) +{ + u8 clk_en = 0; + + if (card & XD_CARD) + clk_en |= XD_CLK_EN; + if (card & SD_CARD) + clk_en |= SD_CLK_EN; + if (card & MS_CARD) + clk_en |= MS_CLK_EN; + + RTS51X_WRITE_REG(chip, CARD_CLK_EN, clk_en, 0); + + return STATUS_SUCCESS; +} + +int card_power_on(struct rts51x_chip *chip, u8 card) +{ + u8 mask, val1, val2; + + mask = POWER_MASK; + val1 = PARTIAL_POWER_ON; + val2 = POWER_ON; + +#ifdef SD_XD_IO_FOLLOW_PWR + if ((card == SD_CARD) || (card == XD_CARD)) { + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask | LDO3318_PWR_MASK, + val1 | LDO_SUSPEND); + /* RTS51X_WRITE_REG(chip, CARD_PWR_CTL, + LDO3318_PWR_MASK, LDO_SUSPEND); */ + } + /* else if(card==XD_CARD) + { + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, + mask|LDO3318_PWR_MASK, val1|LDO_SUSPEND); + //RTS51X_WRITE_REG(chip, CARD_PWR_CTL, + // LDO3318_PWR_MASK, LDO_SUSPEND); + } */ + else { +#endif + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val1); +#ifdef SD_XD_IO_FOLLOW_PWR + } +#endif + udelay(chip->option.pwr_delay); + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val2); +#ifdef SD_XD_IO_FOLLOW_PWR + if (card == SD_CARD) { + rts51x_write_register(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, + LDO_ON); + } +#endif + + return STATUS_SUCCESS; +} + +int card_power_off(struct rts51x_chip *chip, u8 card) +{ + u8 mask, val; + + mask = POWER_MASK; + val = POWER_OFF; + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val); + + return STATUS_SUCCESS; +} + +int monitor_card_cd(struct rts51x_chip *chip, u8 card) +{ + int retval; + u8 card_cd[32] = { 0 }; + + card_cd[SD_CARD] = SD_CD; + card_cd[XD_CARD] = XD_CD; + card_cd[MS_CARD] = MS_CD; + + retval = rts51x_get_card_status(chip, &(chip->card_status)); + if (retval != STATUS_SUCCESS) + return CD_NOT_EXIST; + + if (chip->card_status & card_cd[card]) + return CD_EXIST; + + return CD_NOT_EXIST; +} + +int toggle_gpio(struct rts51x_chip *chip, u8 gpio) +{ + int retval; + u8 temp_reg; + u8 gpio_output[4] = { + 0x01, + }; + u8 gpio_oe[4] = { + 0x02, + }; + if (chip->rts5179) { + retval = rts51x_ep0_read_register(chip, CARD_GPIO, &temp_reg); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + temp_reg ^= gpio_oe[gpio]; + temp_reg &= 0xfe; /* bit 0 always set 0 */ + retval = + rts51x_ep0_write_register(chip, CARD_GPIO, 0x03, temp_reg); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + } else { + retval = rts51x_ep0_read_register(chip, CARD_GPIO, &temp_reg); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + temp_reg ^= gpio_output[gpio]; + retval = + rts51x_ep0_write_register(chip, CARD_GPIO, 0xFF, + temp_reg | gpio_oe[gpio]); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +int turn_on_led(struct rts51x_chip *chip, u8 gpio) +{ + int retval; + u8 gpio_oe[4] = { + 0x02, + }; + u8 gpio_mask[4] = { + 0x03, + }; + + retval = + rts51x_ep0_write_register(chip, CARD_GPIO, gpio_mask[gpio], + gpio_oe[gpio]); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +int turn_off_led(struct rts51x_chip *chip, u8 gpio) +{ + int retval; + u8 gpio_output[4] = { + 0x01, + }; + u8 gpio_oe[4] = { + 0x02, + }; + u8 gpio_mask[4] = { + 0x03, + }; + + retval = + rts51x_ep0_write_register(chip, CARD_GPIO, gpio_mask[gpio], + gpio_oe[gpio] | gpio_output[gpio]); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} diff --git a/drivers/staging/rts5139/rts51x_card.h b/drivers/staging/rts5139/rts51x_card.h new file mode 100644 index 00000000000..ac3c1e741ab --- /dev/null +++ b/drivers/staging/rts5139/rts51x_card.h @@ -0,0 +1,881 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_CARD_H +#define __RTS51X_CARD_H + +#include "rts51x_chip.h" + +/* Register bit definition */ + +/* Card Power Control Register */ +#define POWER_OFF 0x03 +#define PARTIAL_POWER_ON 0x02 +#define POWER_ON 0x00 +#define POWER_MASK 0x03 +#define LDO3318_PWR_MASK 0x0C +#define LDO_ON 0x00 +#define LDO_SUSPEND 0x08 +#define LDO_OFF 0x0C +#define DV3318_AUTO_PWR_OFF 0x10 +#define FORCE_LDO_POWERB 0x60 + +/* Card Output Enable Register */ +#define XD_OUTPUT_EN 0x02 +#define SD_OUTPUT_EN 0x04 +#define MS_OUTPUT_EN 0x08 + +/* System Clock Control Register */ + +/* System Clock Divider Register */ +#define CLK_CHANGE 0x80 +#define CLK_DIV_1 0x00 +#define CLK_DIV_2 0x01 +#define CLK_DIV_4 0x02 +#define CLK_DIV_8 0x03 + +/* System Clock Select Register */ +#define SSC_60 0 +#define SSC_80 1 +#define SSC_100 2 +#define SSC_120 3 +#define SSC_150 4 + +/* Card Clock Enable Register */ +#define XD_CLK_EN 0x02 +#define SD_CLK_EN 0x04 +#define MS_CLK_EN 0x08 + +/* Card Select Register */ +#define XD_MOD_SEL 1 +#define SD_MOD_SEL 2 +#define MS_MOD_SEL 3 + +/* Card Transfer Reset Register */ +#define XD_STOP 0x02 +#define SD_STOP 0x04 +#define MS_STOP 0x08 +#define XD_CLR_ERR 0x20 +#define SD_CLR_ERR 0x40 +#define MS_CLR_ERR 0x80 + +/* SD30_drive_sel */ +#define SD30_DRIVE_MASK 0x07 + +/* CARD_DRIVE_SEL */ +#define SD20_DRIVE_MASK 0x03 +#define DRIVE_4mA 0x00 +#define DRIVE_8mA 0x01 +#define DRIVE_12mA 0x02 + +/* FPGA_PULL_CTL */ +#define FPGA_MS_PULL_CTL_EN 0xEF +#define FPGA_SD_PULL_CTL_EN 0xF7 +#define FPGA_XD_PULL_CTL_EN1 0xFE +#define FPGA_XD_PULL_CTL_EN2 0xFD +#define FPGA_XD_PULL_CTL_EN3 0xFB + +#define FPGA_MS_PULL_CTL_BIT 0x10 +#define FPGA_SD_PULL_CTL_BIT 0x08 + +/* Card Data Source Register */ +#define PINGPONG_BUFFER 0x01 +#define RING_BUFFER 0x00 + +/* SFSM_ED */ +#define HW_CMD_STOP 0x80 +#define CLR_STAGE_STALL 0x08 +#define CARD_ERR 0x10 + +/* CARD_SHARE_MODE */ +#define CARD_SHARE_LQFP48 0x04 +#define CARD_SHARE_QFN24 0x00 +#define CARD_SHARE_LQFP_SEL 0x04 +#define CARD_SHARE_XD 0x00 +#define CARD_SHARE_SD 0x01 +#define CARD_SHARE_MS 0x02 +#define CARD_SHARE_MASK 0x03 + +/* CARD_AUTO_BLINK */ +#define BLINK_ENABLE 0x08 +#define BLINK_SPEED_MASK 0x07 + +/* CARD_GPIO */ +#define GPIO_OE 0x02 +#define GPIO_OUTPUT 0x01 + +/* CARD_CLK_SOURCE */ +#define CRC_FIX_CLK (0x00 << 0) +#define CRC_VAR_CLK0 (0x01 << 0) +#define CRC_VAR_CLK1 (0x02 << 0) +#define SD30_FIX_CLK (0x00 << 2) +#define SD30_VAR_CLK0 (0x01 << 2) +#define SD30_VAR_CLK1 (0x02 << 2) +#define SAMPLE_FIX_CLK (0x00 << 4) +#define SAMPLE_VAR_CLK0 (0x01 << 4) +#define SAMPLE_VAR_CLK1 (0x02 << 4) + +/* DCM_DRP_CTL */ +#define DCM_RESET 0x08 +#define DCM_LOCKED 0x04 +#define DCM_208M 0x00 +#define DCM_TX 0x01 +#define DCM_RX 0x02 + +/* DCM_DRP_TRIG */ +#define DRP_START 0x80 +#define DRP_DONE 0x40 + +/* DCM_DRP_CFG */ +#define DRP_WRITE 0x80 +#define DRP_READ 0x00 +#define DCM_WRITE_ADDRESS_50 0x50 +#define DCM_WRITE_ADDRESS_51 0x51 +#define DCM_READ_ADDRESS_00 0x00 +#define DCM_READ_ADDRESS_51 0x51 + +/* HW_VERSION */ +#define FPGA_VER 0x80 +#define HW_VER_MASK 0x0F + +/* CD_DEGLITCH_EN */ +#define DISABLE_SD_CD 0x08 +#define DISABLE_MS_CD 0x10 +#define DISABLE_XD_CD 0x20 +#define SD_CD_DEGLITCH_EN 0x01 +#define MS_CD_DEGLITCH_EN 0x02 +#define XD_CD_DEGLITCH_EN 0x04 + +/* OCPCTL */ +#define CARD_OC_DETECT_EN 0x08 +#define CARD_OC_CLR 0x01 + +/* CARD_DMA1_CTL */ +#define EXTEND_DMA1_ASYNC_SIGNAL 0x02 + +/* HS_USB_STAT */ +#define USB_HI_SPEED 0x01 + +/* CFG_MODE_1 */ +#define RTS5179 0x02 + +/* SYS_DUMMY0 */ +#define NYET_EN 0x01 +#define NYET_MSAK 0x01 + +/* SSC_CTL1 */ +#define SSC_RSTB 0x80 +#define SSC_8X_EN 0x40 +#define SSC_FIX_FRAC 0x20 +#define SSC_SEL_1M 0x00 +#define SSC_SEL_2M 0x08 +#define SSC_SEL_4M 0x10 +#define SSC_SEL_8M 0x18 + +/* SSC_CTL2 */ +#define SSC_DEPTH_MASK 0x03 +#define SSC_DEPTH_DISALBE 0x00 +#define SSC_DEPTH_2M 0x01 +#define SSC_DEPTH_1M 0x02 +#define SSC_DEPTH_512K 0x03 + +/* LDO_POWER_CFG */ +#define TUNE_SD18_MASK 0x1C +#define TUNE_SD18_1V7 0x00 +#define TUNE_SD18_1V8 (0x01 << 2) +#define TUNE_SD18_1V9 (0x02 << 2) +#define TUNE_SD18_2V0 (0x03 << 2) +#define TUNE_SD18_2V7 (0x04 << 2) +#define TUNE_SD18_2V8 (0x05 << 2) +#define TUNE_SD18_2V9 (0x06 << 2) +#define TUNE_SD18_3V3 (0x07 << 2) + +/* XD_CP_WAITTIME */ +#define WAIT_1F 0x00 +#define WAIT_3F 0x01 +#define WAIT_7F 0x02 +#define WAIT_FF 0x03 + +/* XD_INIT */ +#define XD_PWR_OFF_DELAY0 0x00 +#define XD_PWR_OFF_DELAY1 0x02 +#define XD_PWR_OFF_DELAY2 0x04 +#define XD_PWR_OFF_DELAY3 0x06 +#define XD_AUTO_PWR_OFF_EN 0xF7 +#define XD_NO_AUTO_PWR_OFF 0x08 + +/* XD_DTCTL */ +/* XD_CATCTL */ +#define XD_TIME_RWN_1 0x00 +#define XD_TIME_RWN_STEP 0x20 +#define XD_TIME_RW_1 0x00 +#define XD_TIME_RW_STEP 0x04 +#define XD_TIME_SETUP_1 0x00 +#define XD_TIME_SETUP_STEP 0x01 + +/* XD_CTL */ +#define XD_ECC2_UNCORRECTABLE 0x80 +#define XD_ECC2_ERROR 0x40 +#define XD_ECC1_UNCORRECTABLE 0x20 +#define XD_ECC1_ERROR 0x10 +#define XD_RDY 0x04 +#define XD_CE_EN 0xFD +#define XD_CE_DISEN 0x02 +#define XD_WP_EN 0xFE +#define XD_WP_DISEN 0x01 + +/* XD_TRANSFER */ +#define XD_TRANSFER_START 0x80 +#define XD_TRANSFER_END 0x40 +#define XD_PPB_EMPTY 0x20 +#define XD_ERR 0x10 +#define XD_RESET 0x00 +#define XD_ERASE 0x01 +#define XD_READ_STATUS 0x02 +#define XD_READ_ID 0x03 +#define XD_READ_REDUNDANT 0x04 +#define XD_READ_PAGES 0x05 +#define XD_SET_CMD 0x06 +#define XD_NORMAL_READ 0x07 +#define XD_WRITE_PAGES 0x08 +#define XD_NORMAL_WRITE 0x09 +#define XD_WRITE_REDUNDANT 0x0A +#define XD_SET_ADDR 0x0B +#define XD_COPY_PAGES 0x0C + +/* XD_CFG */ +#define XD_PPB_TO_SIE 0x80 +#define XD_TO_PPB_ONLY 0x00 +#define XD_BA_TRANSFORM 0x40 +#define XD_BA_NO_TRANSFORM 0x00 +#define XD_NO_CALC_ECC 0x20 +#define XD_CALC_ECC 0x00 +#define XD_IGNORE_ECC 0x10 +#define XD_CHECK_ECC 0x00 +#define XD_DIRECT_TO_RB 0x08 +#define XD_ADDR_MASK 0x07 +#define XD_ADDR_LENGTH_0 0x00 +#define XD_ADDR_LENGTH_1 0x01 +#define XD_ADDR_LENGTH_2 0x02 +#define XD_ADDR_LENGTH_3 0x03 +#define XD_ADDR_LENGTH_4 0x04 + +/* XD_PAGE_STATUS */ +#define XD_GPG 0xFF +#define XD_BPG 0x00 + +/* XD_BLOCK_STATUS */ +#define XD_GBLK 0xFF +#define XD_LATER_BBLK 0xF0 + +/* XD_PARITY */ +#define XD_ECC2_ALL1 0x80 +#define XD_ECC1_ALL1 0x40 +#define XD_BA2_ALL0 0x20 +#define XD_BA1_ALL0 0x10 +#define XD_BA1_BA2_EQL 0x04 +#define XD_BA2_VALID 0x02 +#define XD_BA1_VALID 0x01 + +/* XD_CHK_DATA_STATUS */ +#define XD_PGSTS_ZEROBIT_OVER4 0x00 +#define XD_PGSTS_NOT_FF 0x02 +#define XD_AUTO_CHK_DATA_STATUS 0x01 + +/* SD_CFG1 */ +#define SD_CLK_DIVIDE_0 0x00 +#define SD_CLK_DIVIDE_256 0xC0 +#define SD_CLK_DIVIDE_128 0x80 +#define SD_CLK_DIVIDE_MASK 0xC0 +#define SD_BUS_WIDTH_1 0x00 +#define SD_BUS_WIDTH_4 0x01 +#define SD_BUS_WIDTH_8 0x02 +#define SD_ASYNC_FIFO_RST 0x10 +#define SD_20_MODE 0x00 +#define SD_DDR_MODE 0x04 +#define SD_30_MODE 0x08 + +/* SD_CFG2 */ +#define SD_CALCULATE_CRC7 0x00 +#define SD_NO_CALCULATE_CRC7 0x80 +#define SD_CHECK_CRC16 0x00 +#define SD_NO_CHECK_CRC16 0x40 +#define SD_WAIT_CRC_TO_EN 0x20 +#define SD_WAIT_BUSY_END 0x08 +#define SD_NO_WAIT_BUSY_END 0x00 +#define SD_CHECK_CRC7 0x00 +#define SD_NO_CHECK_CRC7 0x04 +#define SD_RSP_LEN_0 0x00 +#define SD_RSP_LEN_6 0x01 +#define SD_RSP_LEN_17 0x02 +/* SD/MMC Response Type Definition */ +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, + * SD_RSP_LEN_0 */ +#define SD_RSP_TYPE_R0 0x04 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R1 0x01 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R1b 0x09 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_17 */ +#define SD_RSP_TYPE_R2 0x02 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R3 0x05 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R4 0x05 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R5 0x01 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R6 0x01 +/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, + * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, + * SD_RSP_LEN_6 */ +#define SD_RSP_TYPE_R7 0x01 + +/* SD_CFG3 */ +#define SD_RSP_80CLK_TIMEOUT_EN 0x01 + +/* SD_STAT1 */ +#define SD_CRC7_ERR 0x80 +#define SD_CRC16_ERR 0x40 +#define SD_CRC_WRITE_ERR 0x20 +#define SD_CRC_WRITE_ERR_MASK 0x1C +#define GET_CRC_TIME_OUT 0x02 +#define SD_TUNING_COMPARE_ERR 0x01 + +/* SD_STAT2 */ +#define SD_RSP_80CLK_TIMEOUT 0x01 + +/* SD_BUS_STAT */ +#define SD_CLK_TOGGLE_EN 0x80 +#define SD_CLK_FORCE_STOP 0x40 +#define SD_DAT3_STATUS 0x10 +#define SD_DAT2_STATUS 0x08 +#define SD_DAT1_STATUS 0x04 +#define SD_DAT0_STATUS 0x02 +#define SD_CMD_STATUS 0x01 + +/* SD_PAD_CTL */ +#define SD_IO_USING_1V8 0x80 +#define SD_IO_USING_3V3 0x7F +#define TYPE_A_DRIVING 0x00 +#define TYPE_B_DRIVING 0x01 +#define TYPE_C_DRIVING 0x02 +#define TYPE_D_DRIVING 0x03 + +/* SD_SAMPLE_POINT_CTL */ +#define DDR_FIX_RX_DAT 0x00 +#define DDR_VAR_RX_DAT 0x80 +#define DDR_FIX_RX_DAT_EDGE 0x00 +#define DDR_FIX_RX_DAT_14_DELAY 0x40 +#define DDR_FIX_RX_CMD 0x00 +#define DDR_VAR_RX_CMD 0x20 +#define DDR_FIX_RX_CMD_POS_EDGE 0x00 +#define DDR_FIX_RX_CMD_14_DELAY 0x10 +#define SD20_RX_POS_EDGE 0x00 +#define SD20_RX_14_DELAY 0x08 +#define SD20_RX_SEL_MASK 0x08 + +/* SD_PUSH_POINT_CTL */ +#define DDR_FIX_TX_CMD_DAT 0x00 +#define DDR_VAR_TX_CMD_DAT 0x80 +#define DDR_FIX_TX_DAT_14_TSU 0x00 +#define DDR_FIX_TX_DAT_12_TSU 0x40 +#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 +#define DDR_FIX_TX_CMD_14_AHEAD 0x20 +#define SD20_TX_NEG_EDGE 0x00 +#define SD20_TX_14_AHEAD 0x10 +#define SD20_TX_SEL_MASK 0x10 +#define DDR_VAR_SDCLK_POL_SWAP 0x01 + +/* SD_TRANSFER */ +#define SD_TRANSFER_START 0x80 +#define SD_TRANSFER_END 0x40 +#define SD_STAT_IDLE 0x20 +#define SD_TRANSFER_ERR 0x10 +/* SD Transfer Mode definition */ +#define SD_TM_NORMAL_WRITE 0x00 +#define SD_TM_AUTO_WRITE_3 0x01 +#define SD_TM_AUTO_WRITE_4 0x02 +#define SD_TM_AUTO_READ_3 0x05 +#define SD_TM_AUTO_READ_4 0x06 +#define SD_TM_CMD_RSP 0x08 +#define SD_TM_AUTO_WRITE_1 0x09 +#define SD_TM_AUTO_WRITE_2 0x0A +#define SD_TM_NORMAL_READ 0x0C +#define SD_TM_AUTO_READ_1 0x0D +#define SD_TM_AUTO_READ_2 0x0E +#define SD_TM_AUTO_TUNING 0x0F + +/* SD_VPTX_CTL / SD_VPRX_CTL */ +#define PHASE_CHANGE 0x80 +#define PHASE_NOT_RESET 0x40 + +/* SD_DCMPS_TX_CTL / SD_DCMPS_RX_CTL */ +#define DCMPS_CHANGE 0x80 +#define DCMPS_CHANGE_DONE 0x40 +#define DCMPS_ERROR 0x20 +#define DCMPS_CURRENT_PHASE 0x1F + +/* SD_CMD_STATE */ +#define SD_CMD_IDLE 0x80 + +/* SD_DATA_STATE */ +#define SD_DATA_IDLE 0x80 + +/* MS_BLKEND */ +#define SET_BLKEND 0x01 + +/* MS_CFG */ +#define SAMPLE_TIME_RISING 0x00 +#define SAMPLE_TIME_FALLING 0x80 +#define PUSH_TIME_DEFAULT 0x00 +#define PUSH_TIME_ODD 0x40 +#define NO_EXTEND_TOGGLE 0x00 +#define EXTEND_TOGGLE_CHK 0x20 +#define MS_BUS_WIDTH_1 0x00 +#define MS_BUS_WIDTH_4 0x10 +#define MS_BUS_WIDTH_8 0x18 +#define MS_2K_SECTOR_MODE 0x04 +#define MS_512_SECTOR_MODE 0x00 +#define MS_TOGGLE_TIMEOUT_EN 0x00 +#define MS_TOGGLE_TIMEOUT_DISEN 0x01 +#define MS_NO_CHECK_INT 0x02 + +/* MS_TRANS_CFG */ +#define WAIT_INT 0x80 +#define NO_WAIT_INT 0x00 +#define NO_AUTO_READ_INT_REG 0x00 +#define AUTO_READ_INT_REG 0x40 +#define MS_CRC16_ERR 0x20 +#define MS_RDY_TIMEOUT 0x10 +#define MS_INT_CMDNK 0x08 +#define MS_INT_BREQ 0x04 +#define MS_INT_ERR 0x02 +#define MS_INT_CED 0x01 + +/* MS_TRANSFER */ +#define MS_TRANSFER_START 0x80 +#define MS_TRANSFER_END 0x40 +#define MS_TRANSFER_ERR 0x20 +#define MS_BS_STATE 0x10 +#define MS_TM_READ_BYTES 0x00 +#define MS_TM_NORMAL_READ 0x01 +#define MS_TM_WRITE_BYTES 0x04 +#define MS_TM_NORMAL_WRITE 0x05 +#define MS_TM_AUTO_READ 0x08 +#define MS_TM_AUTO_WRITE 0x0C +#define MS_TM_SET_CMD 0x06 +#define MS_TM_COPY_PAGE 0x07 +#define MS_TM_MULTI_READ 0x02 +#define MS_TM_MULTI_WRITE 0x03 + +/* MC_DMA_CTL */ +#define DMA_TC_EQ_0 0x80 +#define DMA_DIR_TO_CARD 0x00 +#define DMA_DIR_FROM_CARD 0x02 +#define DMA_EN 0x01 +#define DMA_128 (0 << 2) +#define DMA_256 (1 << 2) +#define DMA_512 (2 << 2) +#define DMA_1024 (3 << 2) +#define DMA_PACK_SIZE_MASK 0x0C + +/* CARD_INT_PEND */ +#define XD_INT 0x10 +#define MS_INT 0x08 +#define SD_INT 0x04 + +/* MC_FIFO_CTL */ +#define FIFO_FLUSH 0x01 + +/* AUTO_DELINK_EN */ +#define AUTO_DELINK 0x02 +#define FORCE_DELINK 0x01 + +/* MC_DMA_RST */ +#define DMA_RESET 0x01 + +#define SSC_POWER_MASK 0x01 +#define SSC_POWER_DOWN 0x01 +#define SSC_POWER_ON 0x00 + +/* OCPCTL */ +#define MS_OCP_DETECT_EN 0x08 +#define MS_OCP_INT_EN 0x04 +#define MS_OCP_INT_CLR 0x02 +#define MS_OCP_CLEAR 0x01 + +/* OCPSTAT */ +#define MS_OCP_DETECT 0x80 +#define MS_OCP_NOW 0x02 +#define MS_OCP_EVER 0x01 + +/* MC_FIFO_STAT */ +#define FIFO_FULL 0x01 +#define FIFO_EMPTY 0x02 + +/* RCCTL */ +#define U_HW_CMD_EN_MASK 0x02 +#define U_HW_CMD_EN 0x02 +#define U_HW_CMD_DIS 0x00 + +/* Register address */ +#define FPDCTL 0xFC00 +#define SSC_DIV_N_0 0xFC07 +#define SSC_CTL1 0xFC09 +#define SSC_CTL2 0xFC0A +#define CFG_MODE_1 0xFC0F +#define RCCTL 0xFC14 +#define SYS_DUMMY0 0xFC30 +#define XD_CP_WAITTIME 0xFD00 +#define XD_CP_PAGELEN 0xFD01 +#define XD_CP_READADDR0 0xFD02 +#define XD_CP_READADDR1 0xFD03 +#define XD_CP_READADDR2 0xFD04 +#define XD_CP_READADDR3 0xFD05 +#define XD_CP_READADDR4 0xFD06 +#define XD_CP_WRITEADDR0 0xFD07 +#define XD_CP_WRITEADDR1 0xFD08 +#define XD_CP_WRITEADDR2 0xFD09 +#define XD_CP_WRITEADDR3 0xFD0A +#define XD_CP_WRITEADDR4 0xFD0B +#define XD_INIT 0xFD10 +#define XD_DTCTL 0xFD11 +#define XD_CTL 0xFD12 +#define XD_TRANSFER 0xFD13 +#define XD_CFG 0xFD14 +#define XD_ADDRESS0 0xFD15 +#define XD_ADDRESS1 0xFD16 +#define XD_ADDRESS2 0xFD17 +#define XD_ADDRESS3 0xFD18 +#define XD_ADDRESS4 0xFD19 +#define XD_DAT 0xFD1A +#define XD_PAGE_CNT 0xFD1B +#define XD_PAGE_STATUS 0xFD1C +#define XD_BLOCK_STATUS 0xFD1D +#define XD_BLOCK_ADDR1_L 0xFD1E +#define XD_BLOCK_ADDR1_H 0xFD1F +#define XD_BLOCK_ADDR2_L 0xFD20 +#define XD_BLOCK_ADDR2_H 0xFD21 +#define XD_BYTE_CNT_L 0xFD22 +#define XD_BYTE_CNT_H 0xFD23 +#define XD_PARITY 0xFD24 +#define XD_ECC_BIT1 0xFD25 +#define XD_ECC_BYTE1 0xFD26 +#define XD_ECC_BIT2 0xFD27 +#define XD_ECC_BYTE2 0xFD28 +#define XD_RESERVED0 0xFD29 +#define XD_RESERVED1 0xFD2A +#define XD_RESERVED2 0xFD2B +#define XD_RESERVED3 0xFD2C +#define XD_CHK_DATA_STATUS 0xFD2D +#define XD_CATCTL 0xFD2E + +#define MS_BLKEND 0xFD30 +#define MS_READ_START 0xFD31 +#define MS_READ_COUNT 0xFD32 +#define MS_WRITE_START 0xFD33 +#define MS_WRITE_COUNT 0xFD34 +#define MS_COMMAND 0xFD35 +#define MS_OLD_BLOCK_0 0xFD36 +#define MS_OLD_BLOCK_1 0xFD37 +#define MS_NEW_BLOCK_0 0xFD38 +#define MS_NEW_BLOCK_1 0xFD39 +#define MS_LOG_BLOCK_0 0xFD3A +#define MS_LOG_BLOCK_1 0xFD3B +#define MS_BUS_WIDTH 0xFD3C +#define MS_PAGE_START 0xFD3D +#define MS_PAGE_LENGTH 0xFD3E +#define MS_CFG 0xFD40 +#define MS_TPC 0xFD41 +#define MS_TRANS_CFG 0xFD42 +#define MS_TRANSFER 0xFD43 +#define MS_INT_REG 0xFD44 +#define MS_BYTE_CNT 0xFD45 +#define MS_SECTOR_CNT_L 0xFD46 +#define MS_SECTOR_CNT_H 0xFD47 +#define MS_DBUS_H 0xFD48 + +#define CARD_DMA1_CTL 0xFD5C +#define CARD_PULL_CTL1 0xFD60 +#define CARD_PULL_CTL2 0xFD61 +#define CARD_PULL_CTL3 0xFD62 +#define CARD_PULL_CTL4 0xFD63 +#define CARD_PULL_CTL5 0xFD64 +#define CARD_PULL_CTL6 0xFD65 +#define CARD_EXIST 0xFD6F +#define CARD_INT_PEND 0xFD71 + +#define LDO_POWER_CFG 0xFD7B + +#define SD_CFG1 0xFDA0 +#define SD_CFG2 0xFDA1 +#define SD_CFG3 0xFDA2 +#define SD_STAT1 0xFDA3 +#define SD_STAT2 0xFDA4 +#define SD_BUS_STAT 0xFDA5 +#define SD_PAD_CTL 0xFDA6 +#define SD_SAMPLE_POINT_CTL 0xFDA7 +#define SD_PUSH_POINT_CTL 0xFDA8 +#define SD_CMD0 0xFDA9 +#define SD_CMD1 0xFDAA +#define SD_CMD2 0xFDAB +#define SD_CMD3 0xFDAC +#define SD_CMD4 0xFDAD +#define SD_CMD5 0xFDAE +#define SD_BYTE_CNT_L 0xFDAF +#define SD_BYTE_CNT_H 0xFDB0 +#define SD_BLOCK_CNT_L 0xFDB1 +#define SD_BLOCK_CNT_H 0xFDB2 +#define SD_TRANSFER 0xFDB3 +#define SD_CMD_STATE 0xFDB5 +#define SD_DATA_STATE 0xFDB6 +#define SD_VPCLK0_CTL 0xFC2A +#define SD_VPCLK1_CTL 0xFC2B +#define SD_DCMPS0_CTL 0xFC2C +#define SD_DCMPS1_CTL 0xFC2D + +#define CARD_DMA1_CTL 0xFD5C + +#define HW_VERSION 0xFC01 + +#define SSC_CLK_FPGA_SEL 0xFC02 +#define CLK_DIV 0xFC03 +#define SFSM_ED 0xFC04 + +#define CD_DEGLITCH_WIDTH 0xFC20 +#define CD_DEGLITCH_EN 0xFC21 +#define AUTO_DELINK_EN 0xFC23 + +#define FPGA_PULL_CTL 0xFC1D +#define CARD_CLK_SOURCE 0xFC2E + +#define CARD_SHARE_MODE 0xFD51 +#define CARD_DRIVE_SEL 0xFD52 +#define CARD_STOP 0xFD53 +#define CARD_OE 0xFD54 +#define CARD_AUTO_BLINK 0xFD55 +#define CARD_GPIO 0xFD56 +#define SD30_DRIVE_SEL 0xFD57 + +#define CARD_DATA_SOURCE 0xFD5D +#define CARD_SELECT 0xFD5E + +#define CARD_CLK_EN 0xFD79 +#define CARD_PWR_CTL 0xFD7A + +#define OCPCTL 0xFD80 +#define OCPPARA1 0xFD81 +#define OCPPARA2 0xFD82 +#define OCPSTAT 0xFD83 + +#define HS_USB_STAT 0xFE01 +#define HS_VCONTROL 0xFE26 +#define HS_VSTAIN 0xFE27 +#define HS_VLOADM 0xFE28 +#define HS_VSTAOUT 0xFE29 + +#define MC_IRQ 0xFF00 +#define MC_IRQEN 0xFF01 +#define MC_FIFO_CTL 0xFF02 +#define MC_FIFO_BC0 0xFF03 +#define MC_FIFO_BC1 0xFF04 +#define MC_FIFO_STAT 0xFF05 +#define MC_FIFO_MODE 0xFF06 +#define MC_FIFO_RD_PTR0 0xFF07 +#define MC_FIFO_RD_PTR1 0xFF08 +#define MC_DMA_CTL 0xFF10 +#define MC_DMA_TC0 0xFF11 +#define MC_DMA_TC1 0xFF12 +#define MC_DMA_TC2 0xFF13 +#define MC_DMA_TC3 0xFF14 +#define MC_DMA_RST 0xFF15 + +/* Memory mapping */ +#define RBUF_SIZE_MASK 0xFBFF +#define RBUF_BASE 0xF000 +#define PPBUF_BASE1 0xF800 +#define PPBUF_BASE2 0xFA00 + +/* int monitor_card_cd */ +#define CD_EXIST 0 +#define CD_NOT_EXIST 1 + +#define DEBOUNCE_CNT 5 + +int monitor_card_cd(struct rts51x_chip *chip, u8 card); + +void do_remaining_work(struct rts51x_chip *chip); +void do_reset_xd_card(struct rts51x_chip *chip); +void do_reset_sd_card(struct rts51x_chip *chip); +void do_reset_ms_card(struct rts51x_chip *chip); +void rts51x_init_cards(struct rts51x_chip *chip); +void rts51x_release_cards(struct rts51x_chip *chip); +int switch_ssc_clock(struct rts51x_chip *chip, int clk); +int switch_normal_clock(struct rts51x_chip *chip, int clk); +int card_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 sec_addr, + u16 sec_cnt); +u8 get_lun_card(struct rts51x_chip *chip, unsigned int lun); +int card_share_mode(struct rts51x_chip *chip, int card); +int rts51x_select_card(struct rts51x_chip *chip, int card); +void eject_card(struct rts51x_chip *chip, unsigned int lun); +void trans_dma_enable(enum dma_data_direction dir, struct rts51x_chip *chip, + u32 byte_cnt, u8 pack_size); +int enable_card_clock(struct rts51x_chip *chip, u8 card); +int disable_card_clock(struct rts51x_chip *chip, u8 card); +int card_power_on(struct rts51x_chip *chip, u8 card); +int card_power_off(struct rts51x_chip *chip, u8 card); +int toggle_gpio(struct rts51x_chip *chip, u8 gpio); +int turn_on_led(struct rts51x_chip *chip, u8 gpio); +int turn_off_led(struct rts51x_chip *chip, u8 gpio); + +static inline int check_card_ready(struct rts51x_chip *chip, unsigned int lun) +{ + if (chip->card_ready & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline int check_card_exist(struct rts51x_chip *chip, unsigned int lun) +{ + if (chip->card_exist & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline int check_card_wp(struct rts51x_chip *chip, unsigned int lun) +{ + if (chip->card_wp & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline int check_card_fail(struct rts51x_chip *chip, unsigned int lun) +{ + if (chip->card_fail & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline int check_card_ejected(struct rts51x_chip *chip, unsigned int lun) +{ + if (chip->card_ejected & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline int check_fake_card_ready(struct rts51x_chip *chip, + unsigned int lun) +{ + if (chip->fake_card_ready & chip->lun2card[lun]) + return 1; + + return 0; +} + +static inline u8 get_lun2card(struct rts51x_chip *chip, unsigned int lun) +{ + return chip->lun2card[lun]; +} + +static inline int check_lun_mc(struct rts51x_chip *chip, unsigned int lun) +{ + return CHK_BIT(chip->lun_mc, lun); +} + +static inline void set_lun_mc(struct rts51x_chip *chip, unsigned int lun) +{ + SET_BIT(chip->lun_mc, lun); +} + +static inline void clear_lun_mc(struct rts51x_chip *chip, unsigned int lun) +{ + CLR_BIT(chip->lun_mc, lun); +} + +static inline int switch_clock(struct rts51x_chip *chip, int clk) +{ + int retval = 0; + + if (chip->asic_code) + retval = switch_ssc_clock(chip, clk); + else + retval = switch_normal_clock(chip, clk); + + return retval; +} + +static inline void rts51x_clear_xd_error(struct rts51x_chip *chip) +{ + rts51x_ep0_write_register(chip, CARD_STOP, + XD_STOP | XD_CLR_ERR, XD_STOP | XD_CLR_ERR); + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); + rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); + rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); +} + +static inline void rts51x_clear_sd_error(struct rts51x_chip *chip) +{ + rts51x_ep0_write_register(chip, CARD_STOP, + SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR); + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); + rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); + rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); +} + +static inline void rts51x_clear_ms_error(struct rts51x_chip *chip) +{ + rts51x_ep0_write_register(chip, CARD_STOP, + MS_STOP | MS_CLR_ERR, MS_STOP | MS_CLR_ERR); + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); + rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); + rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); +} + +#endif /* __RTS51X_CARD_H */ diff --git a/drivers/staging/rts5139/rts51x_chip.c b/drivers/staging/rts5139/rts51x_chip.c new file mode 100644 index 00000000000..adc0d000573 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_chip.c @@ -0,0 +1,1167 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_card.h" +#include "rts51x_transport.h" +#include "rts51x_sys.h" +#include "xd.h" +#include "ms.h" +#include "sd.h" + +static int check_sd_speed_prior(u32 sd_speed_prior) +{ + int i, fake_para = 0; + + /* Check the legality of sd_speed_prior */ + for (i = 0; i < 4; i++) { + u8 tmp = (u8) (sd_speed_prior >> (i * 8)); + if ((tmp < 0x01) || (tmp > 0x04)) { + fake_para = 1; + break; + } + } + + return !fake_para; +} + +int rts51x_reset_chip(struct rts51x_chip *chip) +{ + int retval; + + if (CHECK_PKG(chip, LQFP48)) { + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, + LDO_SUSPEND); + RTS51X_WRITE_REG(chip, CARD_PWR_CTL, FORCE_LDO_POWERB, + FORCE_LDO_POWERB); + RTS51X_WRITE_REG(chip, CARD_PULL_CTL1, 0x30, 0x10); + RTS51X_WRITE_REG(chip, CARD_PULL_CTL5, 0x03, 0x01); + RTS51X_WRITE_REG(chip, CARD_PULL_CTL6, 0x0C, 0x04); + } + if (chip->asic_code) { + RTS51X_WRITE_REG(chip, SYS_DUMMY0, NYET_MSAK, NYET_EN); + RTS51X_WRITE_REG(chip, CD_DEGLITCH_WIDTH, 0xFF, 0x08); + rts51x_write_register(chip, CD_DEGLITCH_EN, XD_CD_DEGLITCH_EN, + 0x00); + rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, + chip->option.sd30_pad_drive); + rts51x_write_register(chip, CARD_DRIVE_SEL, SD20_DRIVE_MASK, + chip->option.sd20_pad_drive); + if (chip->rts5179) + rts51x_write_register(chip, CARD_PULL_CTL5, 0x03, 0x01); + if (!chip->option.ww_enable) { + if (CHECK_PKG(chip, LQFP48)) { + rts51x_write_register(chip, CARD_PULL_CTL3, + 0x80, 0x80); + rts51x_write_register(chip, CARD_PULL_CTL6, + 0xf0, 0xA0); + } else { + rts51x_write_register(chip, CARD_PULL_CTL1, + 0x30, 0x20); + rts51x_write_register(chip, CARD_PULL_CTL3, + 0x80, 0x80); + rts51x_write_register(chip, CARD_PULL_CTL6, + 0x0c, 0x08); + } + } + } + if (chip->option.sd_ctl & SUPPORT_UHS50_MMC44) { + SET_UHS50(chip); + RTS51X_DEBUGP("option enable UHS50&MMC44,sd_ctl:0x%x\n", + chip->option.sd_ctl); + } else { + /* if(CHECK_PID(chip, 0x0139)&&CHECK_PKG(chip, LQFP48)) */ + if ((CHECK_PID(chip, 0x0139) && CHECK_PKG(chip, LQFP48)) + || chip->rts5179) { + SET_UHS50(chip); + RTS51X_DEBUGP("PID enable UHS50&MMC44\n"); + } else { + CLEAR_UHS50(chip); + RTS51X_DEBUGP("PID disable UHS50&MMC44\n"); + } + } + + if (chip->option.ms_errreg_fix && (chip->ic_version > 1)) + rts51x_write_register(chip, 0xFD4D, 0x01, 0x01); + retval = rts51x_write_phy_register(chip, 0xC2, 0x7C); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_init_cmd(chip); + + /* GPIO OE */ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_GPIO, GPIO_OE, GPIO_OE); +#ifdef LED_AUTO_BLINK + /* LED autoblink */ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_AUTO_BLINK, + BLINK_ENABLE | BLINK_SPEED_MASK, + BLINK_ENABLE | chip->option.led_blink_speed); +#endif + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, + EXTEND_DMA1_ASYNC_SIGNAL, EXTEND_DMA1_ASYNC_SIGNAL); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SUPPORT_OCP + if (chip->asic_code) { + rts51x_write_register(chip, OCPCTL, MS_OCP_DETECT_EN, + MS_OCP_DETECT_EN); + RTS51X_DEBUGP("Enable OCP detect!\n"); + } +#endif + if (chip->option.FT2_fast_mode) { + card_power_on(chip, SD_CARD | MS_CARD | XD_CARD); + wait_timeout(10); + } + rts51x_clear_start_time(chip); + + return STATUS_SUCCESS; +} + +int rts51x_init_chip(struct rts51x_chip *chip) +{ + int retval; + u8 val; + + chip->max_lun = 0; + chip->cur_clk = 0; + chip->cur_card = 0; + + chip->card2lun[XD_CARD] = 0; + chip->card2lun[SD_CARD] = 0; + chip->card2lun[MS_CARD] = 0; + chip->card_ejected = 0; + + chip->lun2card[0] = XD_CARD | SD_CARD | MS_CARD; +#if 0 + chip->option.sdr50_tx_phase = 0x01; + chip->option.sdr50_rx_phase = 0x05; + chip->option.ddr50_tx_phase = 0x09; + chip->option.ddr50_rx_phase = 0x06; /* add for debug */ +#endif +#ifdef CLOSE_SSC_POWER + rts51x_write_register(chip, FPDCTL, SSC_POWER_MASK, SSC_POWER_ON); + udelay(100); + rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, 0x00); +#endif + RTS51X_SET_STAT(chip, STAT_RUN); + + RTS51X_READ_REG(chip, HW_VERSION, &val); + if ((val & 0x0f) >= 2) + chip->option.rcc_bug_fix_en = 0; + RTS51X_DEBUGP("rcc bug fix enable:%d\n", chip->option.rcc_bug_fix_en); + RTS51X_DEBUGP("HW_VERSION: 0x%x\n", val); + if (val & FPGA_VER) { + chip->asic_code = 0; + RTS51X_DEBUGP("FPGA!\n"); + } else { + chip->asic_code = 1; + RTS51X_DEBUGP("ASIC!\n"); + } + chip->ic_version = val & HW_VER_MASK; + + if (!check_sd_speed_prior(chip->option.sd_speed_prior)) + chip->option.sd_speed_prior = 0x01020403; + RTS51X_DEBUGP("sd_speed_prior = 0x%08x\n", + chip->option.sd_speed_prior); + + RTS51X_READ_REG(chip, CARD_SHARE_MODE, &val); + if (val & CARD_SHARE_LQFP_SEL) { + chip->package = LQFP48; + RTS51X_DEBUGP("Package: LQFP48\n"); + } else { + chip->package = QFN24; + RTS51X_DEBUGP("Package: QFN24\n"); + } + + RTS51X_READ_REG(chip, HS_USB_STAT, &val); + if (val & USB_HI_SPEED) { + chip->usb_speed = USB_20; + RTS51X_DEBUGP("USB High Speed\n"); + } else { + chip->usb_speed = USB_11; + RTS51X_DEBUGP("USB Full Speed\n"); + } + + RTS51X_READ_REG(chip, CFG_MODE_1, &val); + if (val & RTS5179) { + chip->rts5179 = 1; + RTS51X_DEBUGP("device is rts5179\n"); + } else { + chip->rts5179 = 0; + } + + retval = rts51x_reset_chip(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +int rts51x_release_chip(struct rts51x_chip *chip) +{ + xd_free_l2p_tbl(chip); + ms_free_l2p_tbl(chip); + chip->card_ready = 0; + return STATUS_SUCCESS; +} + +#ifndef LED_AUTO_BLINK +static inline void rts51x_blink_led(struct rts51x_chip *chip) +{ + /* Read/Write */ + if (chip->card_ready) { + if (chip->led_toggle_counter < + chip->option.led_toggle_interval) { + chip->led_toggle_counter++; + } else { + chip->led_toggle_counter = 0; + toggle_gpio(chip, LED_GPIO); + } + } +} +#endif + +int rts51x_check_start_time(struct rts51x_chip *chip) +{ + return 0; +} + +void rts51x_set_start_time(struct rts51x_chip *chip) +{ +} + +void rts51x_clear_start_time(struct rts51x_chip *chip) +{ +} + +static void rts51x_auto_delink_cmd(struct rts51x_chip *chip) +{ + rts51x_write_register(chip, AUTO_DELINK_EN, + AUTO_DELINK, AUTO_DELINK); +} + +static void rts51x_auto_delink_force_cmd(struct rts51x_chip *chip) +{ + rts51x_write_register(chip, AUTO_DELINK_EN, + AUTO_DELINK | FORCE_DELINK, + AUTO_DELINK | FORCE_DELINK); +} + +#ifdef USING_POLLING_CYCLE_DELINK +/* using polling cycle as delink time */ +static void rts51x_auto_delink_polling_cycle(struct rts51x_chip *chip) +{ + if (chip->auto_delink_counter <= + chip->option.delink_delay * 2) { + if (chip->auto_delink_counter == + chip->option.delink_delay) { + clear_first_install_mark(chip); + if (chip->card_exist) { + /* False card */ + if (!chip->card_ejected) { + /* if card is not ejected or safely + * remove,then do force delink */ + RTS51X_DEBUGP("False card inserted," + "do force delink\n"); + rts51x_auto_delink_force_cmd(chip); + chip->auto_delink_counter = + chip->option.delink_delay * 2 + 1; + } + } else { + RTS51X_DEBUGP("No card inserted, do delink\n"); + /* rts51x_write_register(chip, CARD_PWR_CTL, + DV3318_AUTO_PWR_OFF, 0); */ + rts51x_auto_delink_cmd(chip); + } + } + if (chip->auto_delink_counter == + chip->option.delink_delay * 2) { + RTS51X_DEBUGP("Try to do force delink\n"); + rts51x_auto_delink_force_cmd(chip); + } + chip->auto_delink_counter++; + } +} + +static void rts51x_auto_delink(struct rts51x_chip *chip) +{ + rts51x_auto_delink_polling_cycle(chip); +} +#else +/* some of called funcs are not implemented, so comment it out */ +#if 0 +/* using precise time as delink time */ +static void rts51x_auto_delink_precise_time(struct rts51x_chip *chip) +{ + int retvalue = 0; + + retvalue = rts51x_get_card_status(chip, &chip->card_status); + /* get card CD status success and card CD not exist, + * then check whether delink */ + if ((retvalue == STATUS_SUCCESS) + && (!(chip->card_status & (SD_CD | MS_CD | XD_CD)))) { + if (rts51x_count_delink_time(chip) >= + chip->option.delink_delay) { + clear_first_install_mark(chip); + RTS51X_DEBUGP("No card inserted, do delink\n"); + /* sangdy2010-05-17:disable because there is error + * after SSC clock closed and card power + * has been closed before */ + /* rts51x_write_register(chip, CARD_PWR_CTL, + DV3318_AUTO_PWR_OFF, 0); */ + rts51x_auto_delink_cmd(chip); + } + /* card CD exist and not ready, then do force delink */ + if ((retvalue == STATUS_SUCCESS) + && (chip->card_status & (SD_CD | MS_CD | XD_CD))) { + /* if card is not ejected or safely remove, + * then do force delink */ + if (!chip->card_ejected) { + /* sangdy2010-11-16:polling at least 2 cycles + * then do force delink for card may force delink + * if card is extracted and insert quickly + * after ready. */ + if (chip->auto_delink_counter > 1) { + if (rts51x_count_delink_time(chip) > + chip->option.delink_delay * 2) { + RTS51X_DEBUGP("Try to do force" + "delink\n"); + rts51x_auto_delink_force_cmd(chip); + } + } + } + } + chip->auto_delink_counter++; +} +#else +static void rts51x_auto_delink_precise_time(struct rts51x_chip *chip) +{ +} +#endif + +static void rts51x_auto_delink(struct rts51x_chip *chip) +{ + rts51x_auto_delink_precise_time(chip); +} +#endif + +void rts51x_polling_func(struct rts51x_chip *chip) +{ +#ifdef SUPPORT_SD_LOCK + struct sd_info *sd_card = &(chip->sd_card); + + if (sd_card->sd_erase_status) { + if (chip->card_exist & SD_CARD) { + u8 val; + rts51x_read_register(chip, SD_BUS_STAT, &val); + if (val & SD_DAT0_STATUS) { + /* Erase completed */ + sd_card->sd_erase_status = SD_NOT_ERASE; + sd_card->sd_lock_notify = 1; + + /* SD card should be reinited, + * so we release it here. */ + sd_cleanup_work(chip); + release_sd_card(chip); + chip->card_ready &= ~SD_CARD; + chip->card_exist &= ~SD_CARD; + chip->rw_card[chip->card2lun[SD_CARD]] = NULL; + clear_bit(chip->card2lun[SD_CARD], + &(chip->lun_mc)); + } + } else { + sd_card->sd_erase_status = SD_NOT_ERASE; + } + } +#endif + + rts51x_init_cards(chip); + +#ifdef SUPPORT_OCP + /* if OCP happen and card exist, then close card OE */ + if ((chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) && + (chip->card_exist)) { + + rts51x_prepare_run(chip); + + if (chip->card_exist & SD_CARD) + rts51x_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0); + else if (chip->card_exist & MS_CARD) + rts51x_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0); + else if (chip->card_exist & XD_CARD) + rts51x_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0); + } +#endif + + if (chip->idle_counter < IDLE_MAX_COUNT) { + chip->idle_counter++; + } else { + if (!RTS51X_CHK_STAT(chip, STAT_IDLE)) { + RTS51X_DEBUGP("Idle state!\n"); + RTS51X_SET_STAT(chip, STAT_IDLE); +#ifndef LED_AUTO_BLINK + chip->led_toggle_counter = 0; +#endif + /* Idle state, turn off LED + * to reduce power consumption */ + if (chip->option.led_always_on + && (chip->card_exist & + (SD_CARD | MS_CARD | XD_CARD)) + && (!chip->card_ejected)) { + turn_on_led(chip, LED_GPIO); + } else { + if (chip->rts5179) { + rts51x_ep0_write_register(chip, + CARD_GPIO, + 0x03, 0x00); + } else { + turn_off_led(chip, LED_GPIO); + } + + } + +#ifdef CLOSE_SSC_POWER + if (!chip->card_ready) { + rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, + CLK_CHANGE); + rts51x_write_register(chip, FPDCTL, + SSC_POWER_MASK, + SSC_POWER_DOWN); + RTS51X_DEBUGP("Close SSC clock power!\n"); + } +#endif + } + } + + switch (RTS51X_GET_STAT(chip)) { + case STAT_RUN: +#ifndef LED_AUTO_BLINK + rts51x_blink_led(chip); +#endif + do_remaining_work(chip); + break; + + case STAT_IDLE: + break; + + default: + break; + } + + if (chip->option.auto_delink_en && !chip->card_ready) { + rts51x_auto_delink(chip); + } else { + chip->auto_delink_counter = 0; + rts51x_clear_start_time(chip); + } +} + +void rts51x_add_cmd(struct rts51x_chip *chip, + u8 cmd_type, u16 reg_addr, u8 mask, u8 data) +{ + int i; + + if (chip->cmd_idx < ((CMD_BUF_LEN - CMD_OFFSET) / 4)) { + i = CMD_OFFSET + chip->cmd_idx * 4; + chip->cmd_buf[i++] = + ((cmd_type & 0x03) << 6) | (u8) ((reg_addr >> 8) & 0x3F); + chip->cmd_buf[i++] = (u8) reg_addr; + chip->cmd_buf[i++] = mask; + chip->cmd_buf[i++] = data; + chip->cmd_idx++; + } +} + +int rts51x_send_cmd(struct rts51x_chip *chip, u8 flag, int timeout) +{ + int result; + + chip->cmd_buf[CNT_H] = (u8) (chip->cmd_idx >> 8); + chip->cmd_buf[CNT_L] = (u8) (chip->cmd_idx); + chip->cmd_buf[STAGE_FLAG] = flag; + + result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), + (void *)(chip->cmd_buf), + chip->cmd_idx * 4 + CMD_OFFSET, + 0, NULL, timeout, MODE_C); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, result); + + return STATUS_SUCCESS; +} + +int rts51x_get_rsp(struct rts51x_chip *chip, int rsp_len, int timeout) +{ + int result; + + if (rsp_len <= 0) + TRACE_RET(chip, STATUS_ERROR); + /* rsp_len must aligned to dword */ + if (rsp_len % 4) + rsp_len += (4 - rsp_len % 4); + + result = rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), + (void *)chip->rsp_buf, rsp_len, + 0, NULL, timeout, STAGE_R); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, result); + + return STATUS_SUCCESS; +} + +int rts51x_get_card_status(struct rts51x_chip *chip, u16 * status) +{ + int retval; + u16 val; + +#ifdef GET_CARD_STATUS_USING_EPC + retval = rts51x_get_epc_status(chip, &val); + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#else + retval = rts51x_ctrl_transfer(chip, RCV_CTRL_PIPE(chip), 0x02, 0xC0, + 0, 0, &val, 2, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#endif + + if (status) + *status = val; + + return STATUS_SUCCESS; +} + +int rts51x_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, u8 data) +{ + int retval; + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, addr, mask, data); + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +int rts51x_read_register(struct rts51x_chip *chip, u16 addr, u8 * data) +{ + int retval; + + if (data) + *data = 0; + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, READ_REG_CMD, addr, 0, 0); + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + retval = rts51x_get_rsp(chip, 1, 100); + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + if (data) + *data = chip->rsp_buf[0]; + + return STATUS_SUCCESS; +} + +int rts51x_ep0_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, + u8 data) +{ + int retval; + u16 value = 0, index = 0; + + value |= (u16) (3 & 0x03) << 14; + value |= (u16) (addr & 0x3FFF); + index |= (u16) mask << 8; + index |= (u16) data; + + retval = rts51x_ctrl_transfer(chip, SND_CTRL_PIPE(chip), 0x00, 0x40, + cpu_to_be16(value), cpu_to_be16(index), + NULL, 0, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int rts51x_ep0_read_register(struct rts51x_chip *chip, u16 addr, u8 * data) +{ + int retval; + u16 value = 0; + u8 val; + + if (data) + *data = 0; + + value |= (u16) (2 & 0x03) << 14; + value |= (u16) (addr & 0x3FFF); + + retval = rts51x_ctrl_transfer(chip, RCV_CTRL_PIPE(chip), 0x00, 0xC0, + cpu_to_be16(value), 0, &val, 1, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (data) + *data = val; + + return STATUS_SUCCESS; +} + +int rts51x_seq_write_register(struct rts51x_chip *chip, u16 addr, u16 len, + u8 *data) +{ + int result; + u16 cmd_len = len + 12; + + if (!data) + TRACE_RET(chip, STATUS_ERROR); + + cmd_len = (cmd_len <= CMD_BUF_LEN) ? cmd_len : CMD_BUF_LEN; + + /* cmd_len must aligned to dword */ + if (cmd_len % 4) + cmd_len += (4 - cmd_len % 4); + + chip->cmd_buf[0] = 'R'; + chip->cmd_buf[1] = 'T'; + chip->cmd_buf[2] = 'C'; + chip->cmd_buf[3] = 'R'; + chip->cmd_buf[PACKET_TYPE] = SEQ_WRITE; + chip->cmd_buf[5] = (u8) (len >> 8); + chip->cmd_buf[6] = (u8) len; + chip->cmd_buf[STAGE_FLAG] = 0; + chip->cmd_buf[8] = (u8) (addr >> 8); + chip->cmd_buf[9] = (u8) addr; + + memcpy(chip->cmd_buf + 12, data, len); + + result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), + (void *)(chip->cmd_buf), cmd_len, 0, + NULL, 100, MODE_C); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, result); + + return STATUS_SUCCESS; +} + +int rts51x_seq_read_register(struct rts51x_chip *chip, u16 addr, u16 len, + u8 *data) +{ + int result; + u16 rsp_len; + + if (!data) + TRACE_RET(chip, STATUS_ERROR); + /* rsp_len must aligned to dword */ + if (len % 4) + rsp_len = len + (4 - len % 4); + else + rsp_len = len; + + chip->cmd_buf[0] = 'R'; + chip->cmd_buf[1] = 'T'; + chip->cmd_buf[2] = 'C'; + chip->cmd_buf[3] = 'R'; + chip->cmd_buf[PACKET_TYPE] = SEQ_READ; + chip->cmd_buf[5] = (u8) (rsp_len >> 8); + chip->cmd_buf[6] = (u8) rsp_len; + chip->cmd_buf[STAGE_FLAG] = STAGE_R; + chip->cmd_buf[8] = (u8) (addr >> 8); + chip->cmd_buf[9] = (u8) addr; + + result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), + (void *)(chip->cmd_buf), 12, 0, NULL, + 100, MODE_C); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, result); + + result = rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), + (void *)data, rsp_len, 0, NULL, 100, + STAGE_DI); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, result); + + return STATUS_SUCCESS; +} + +int rts51x_read_ppbuf(struct rts51x_chip *chip, u8 * buf, int buf_len) +{ + int retval; + + if (!buf) + TRACE_RET(chip, STATUS_ERROR); + + retval = + rts51x_seq_read_register(chip, PPBUF_BASE2, (u16) buf_len, buf); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int rts51x_write_ppbuf(struct rts51x_chip *chip, u8 * buf, int buf_len) +{ + int retval; + + if (!buf) + TRACE_RET(chip, STATUS_ERROR); + + retval = + rts51x_seq_write_register(chip, PPBUF_BASE2, (u16) buf_len, buf); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int rts51x_write_phy_register(struct rts51x_chip *chip, u8 addr, u8 val) +{ + int retval; + + RTS51X_DEBUGP("Write 0x%x to phy register 0x%x\n", val, addr); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VSTAIN, 0xFF, val); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, + (addr >> 4) & 0x0F); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int rts51x_read_phy_register(struct rts51x_chip *chip, u8 addr, u8 * val) +{ + int retval; + + RTS51X_DEBUGP("Read from phy register 0x%x\n", addr); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, 0x07); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, + (addr >> 4) & 0x0F); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); + rts51x_add_cmd(chip, READ_REG_CMD, HS_VSTAOUT, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, 100); + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (val) + *val = chip->rsp_buf[0]; + + RTS51X_DEBUGP("Return value: 0x%x\n", chip->rsp_buf[0]); + + return STATUS_SUCCESS; +} + +void rts51x_do_before_power_down(struct rts51x_chip *chip) +{ + RTS51X_DEBUGP("rts51x_do_before_power_down\n"); + + rts51x_prepare_run(chip); + + rts51x_release_cards(chip); + if (chip->rts5179) + rts51x_ep0_write_register(chip, CARD_GPIO, 0x03, 0x00); + else + turn_off_led(chip, LED_GPIO); + + chip->cur_clk = 0; + chip->card_exist = 0; + chip->cur_card = 0; + if (chip->asic_code && !chip->option.ww_enable) { + if (CHECK_PKG(chip, LQFP48)) { + rts51x_write_register(chip, CARD_PULL_CTL3, 0x80, 0x00); + rts51x_write_register(chip, CARD_PULL_CTL6, 0xf0, 0x50); + } else { + rts51x_write_register(chip, CARD_PULL_CTL1, 0x30, 0x10); + rts51x_write_register(chip, CARD_PULL_CTL3, 0x80, 0x00); + rts51x_write_register(chip, CARD_PULL_CTL6, 0x0c, 0x04); + } + } + if (CHECK_PKG(chip, LQFP48)) + rts51x_write_register(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, + LDO_OFF); +} + +void rts51x_clear_hw_error(struct rts51x_chip *chip) +{ + rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); +} + +void rts51x_prepare_run(struct rts51x_chip *chip) +{ +#ifdef CLOSE_SSC_POWER + if (RTS51X_CHK_STAT(chip, STAT_IDLE) && (!chip->card_ready)) { + rts51x_write_register(chip, FPDCTL, SSC_POWER_MASK, + SSC_POWER_ON); + udelay(100); + RTS51X_DEBUGP("Open SSC clock power.\n"); + + rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, 0x00); + } +#endif +#if 0 + if (chip->option.ss_en && RTS51X_CHK_STAT(chip, STAT_SS)) { + rts51x_try_to_exit_ss(chip); + wait_timeout(100); + rts51x_init_chip(chip); + rts51x_init_cards(chip); + } + + RTS51X_SET_STAT(chip, STAT_RUN); +#endif +} + +#ifdef _MSG_TRACE +void rts51x_trace_msg(struct rts51x_chip *chip, unsigned char *buf, int clear) +{ + unsigned char *ptr; + int i, msg_cnt; + + if (!buf) + return; + + ptr = buf; + + if (chip->trace_msg[chip->msg_idx].valid) + msg_cnt = TRACE_ITEM_CNT; + else + msg_cnt = chip->msg_idx; + *(ptr++) = (u8) (msg_cnt >> 24); + *(ptr++) = (u8) (msg_cnt >> 16); + *(ptr++) = (u8) (msg_cnt >> 8); + *(ptr++) = (u8) msg_cnt; + RTS51X_DEBUGP("Trace message count is %d\n", msg_cnt); + + for (i = 1; i <= msg_cnt; i++) { + int j, idx; + + idx = chip->msg_idx - i; + if (idx < 0) + idx += TRACE_ITEM_CNT; + + *(ptr++) = (u8) (chip->trace_msg[idx].line >> 8); + *(ptr++) = (u8) (chip->trace_msg[idx].line); + for (j = 0; j < MSG_FUNC_LEN; j++) + *(ptr++) = chip->trace_msg[idx].func[j]; + for (j = 0; j < MSG_FILE_LEN; j++) + *(ptr++) = chip->trace_msg[idx].file[j]; + for (j = 0; j < TIME_VAL_LEN; j++) + *(ptr++) = chip->trace_msg[idx].timeval_buf[j]; + } + + if (clear) { + chip->msg_idx = 0; + for (i = 0; i < TRACE_ITEM_CNT; i++) + chip->trace_msg[i].valid = 0; + } +} +#endif + +void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 * status, + u8 status_len) +{ + struct sd_info *sd_card = &(chip->sd_card); + struct ms_info *ms_card = &(chip->ms_card); + u8 card = get_lun_card(chip, lun); +#ifdef SUPPORT_OC + u8 oc_now_mask = 0, oc_ever_mask = 0; +#endif + + if (!status || (status_len < 32)) + return; + /* IC Version */ + status[0] = (u8) RTS51X_GET_PID(chip); + status[1] = (u8) (chip->ic_version); + + /* Auto delink mode */ + if (chip->option.auto_delink_en) + status[2] = 0x10; + else + status[2] = 0x00; + + /* Spec version */ + status[3] = 20; + status[4] = 10; + status[5] = 05; + status[6] = 21; + + /* Card WP */ + if (chip->card_wp) + status[7] = 0x20; + else + status[7] = 0x00; + +#ifdef SUPPORT_OC + /* Over current status */ + status[8] = 0; + oc_now_mask = MS_OCP_NOW; + oc_ever_mask = MS_OCP_EVER; + + if (chip->ocp_stat & oc_now_mask) + status[8] |= 0x02; + if (chip->ocp_stat & oc_ever_mask) + status[8] |= 0x01; +#endif + + if (card == SD_CARD) { + if (CHK_SD(sd_card)) { + if (CHK_SD_HCXC(sd_card)) { + if (sd_card->capacity > 0x4000000) + /* SDXC */ + status[0x0E] = 0x02; + else /* SDHC */ + status[0x0E] = 0x01; + } else { /* SDSC */ + status[0x0E] = 0x00; + } + + if (CHK_SD_SDR104(sd_card)) + status[0x0F] = 0x03; + else if (CHK_SD_DDR50(sd_card)) + status[0x0F] = 0x04; + else if (CHK_SD_SDR50(sd_card)) + status[0x0F] = 0x02; + else if (CHK_SD_HS(sd_card)) + status[0x0F] = 0x01; + else + status[0x0F] = 0x00; /* Normal speed */ + } else { + if (CHK_MMC_SECTOR_MODE(sd_card)) + status[0x0E] = 0x01; /* High capacity */ + else + status[0x0E] = 0x00; /* Normal capacity */ + + if (CHK_MMC_DDR52(sd_card)) + status[0x0F] = 0x03; /* DDR 52M */ + else if (CHK_MMC_52M(sd_card)) + status[0x0F] = 0x02; /* SDR 52M */ + else if (CHK_MMC_26M(sd_card)) + status[0x0F] = 0x01; /* SDR 26M */ + else + status[0x0F] = 0x00; /* Normal speed */ + } + } else if (card == MS_CARD) { + if (CHK_MSPRO(ms_card)) { + if (CHK_MSXC(ms_card)) + status[0x0E] = 0x01; /* XC */ + else + status[0x0E] = 0x00; + + if (CHK_HG8BIT(ms_card)) + status[0x0F] = 0x01; + else + status[0x0F] = 0x00; + } + } +#ifdef SUPPORT_SD_LOCK + /* SD Lock/Unlock */ + if (card == SD_CARD) { + status[0x17] = 0x80; + if (sd_card->sd_erase_status) + status[0x17] |= 0x01; /* Under erasing */ + if (sd_card->sd_lock_status & SD_LOCKED) { + status[0x17] |= 0x02; /* Locked */ + status[0x07] |= 0x40; /* Read protected */ + } + if (sd_card->sd_lock_status & SD_PWD_EXIST) + status[0x17] |= 0x04; /* Contain PWD */ + } else { + status[0x17] = 0x00; + } + + RTS51X_DEBUGP("status[0x17] = 0x%x\n", status[0x17]); +#endif + + /* Function 0 + * Support Magic Gate, CPRM and PhyRegister R/W */ + status[0x18] = 0x8A; + + /* Function 2 + * Support OC LUN status & WP LUN status */ + status[0x1A] = 0x28; + + /* Function 7 */ +#ifdef SUPPORT_SD_LOCK + /* Support SD Lock/Unlock */ + status[0x1F] = 0x01; +#endif + + /* Function 2 + * Support OC LUN status & WP LUN status */ + status[0x1A] = 0x28; +} + +void rts51x_read_status(struct rts51x_chip *chip, unsigned int lun, + u8 *rts51x_status, u8 status_len) +{ + if (!rts51x_status || (status_len < 16)) + return; + /* VID */ + rts51x_status[0] = (u8) (RTS51X_GET_VID(chip) >> 8); + rts51x_status[1] = (u8) RTS51X_GET_VID(chip); + + /* PID */ + rts51x_status[2] = (u8) (RTS51X_GET_PID(chip) >> 8); + rts51x_status[3] = (u8) RTS51X_GET_PID(chip); + + /* gbLUN */ + rts51x_status[4] = (u8) lun; + + /* Lun Card Number */ + if (chip->card_exist) { + if (chip->card_exist & XD_CARD) + rts51x_status[5] = 4; /* xD Card */ + else if (chip->card_exist & SD_CARD) + rts51x_status[5] = 2; /* SD Card */ + else if (chip->card_exist & MS_CARD) + rts51x_status[5] = 3; /* MS Card */ + else + rts51x_status[5] = 7; /* Multi */ + } else { + rts51x_status[5] = 7; /* Multi */ + } + + /* Total LUNs */ + rts51x_status[6] = 1; + + /* IC Version */ + rts51x_status[7] = (u8) RTS51X_GET_PID(chip); + rts51x_status[8] = chip->ic_version; + + /* Physical Exist */ + if (check_card_exist(chip, lun)) + rts51x_status[9] = 1; + else + rts51x_status[9] = 0; + + /* Multi Flag */ + rts51x_status[10] = 1; + + /* LUN Valid Map */ + rts51x_status[11] = XD_CARD | SD_CARD | MS_CARD; + + /* Logical Exist */ + if (check_card_ready(chip, lun)) + rts51x_status[12] = 1; + else + rts51x_status[12] = 0; + + /* Detailed Type */ + if (get_lun_card(chip, lun) == XD_CARD) { + rts51x_status[13] = 0x40; + } else if (get_lun_card(chip, lun) == SD_CARD) { + struct sd_info *sd_card = &(chip->sd_card); + + rts51x_status[13] = 0x20; + if (CHK_SD(sd_card)) { + if (CHK_SD_HCXC(sd_card)) + rts51x_status[13] |= 0x04; /* Hi capacity SD */ + if (CHK_SD_HS(sd_card)) + rts51x_status[13] |= 0x02; /* Hi speed SD */ + } else { + rts51x_status[13] |= 0x08; /* MMC card */ + if (CHK_MMC_52M(sd_card)) + rts51x_status[13] |= 0x02; /* Hi speed */ + if (CHK_MMC_SECTOR_MODE(sd_card)) + rts51x_status[13] |= 0x04; /* Hi capacity */ + } + } else if (get_lun_card(chip, lun) == MS_CARD) { + struct ms_info *ms_card = &(chip->ms_card); + + if (CHK_MSPRO(ms_card)) { + rts51x_status[13] = 0x38; /* MS Pro */ + if (CHK_HG8BIT(ms_card)) + rts51x_status[13] |= 0x04; /* HG */ +#ifdef SUPPORT_MSXC + if (CHK_MSXC(ms_card)) + rts51x_status[13] |= 0x01; /* MSXC */ +#endif + } else { + rts51x_status[13] = 0x30; + } + } else { + rts51x_status[13] = 0x70; + } +/* Support OC, auto delink, vendor r/w, get bus width */ + rts51x_status[14] = 0x78; + + rts51x_status[15] = 0x82; +} + +int rts51x_transfer_data_rcc(struct rts51x_chip *chip, unsigned int pipe, + void *buf, unsigned int len, int use_sg, + unsigned int *act_len, int timeout, u8 stage_flag) +{ + int retval; + + retval = + rts51x_transfer_data(chip, pipe, buf, len, use_sg, act_len, + timeout); + + return retval; + +} diff --git a/drivers/staging/rts5139/rts51x_chip.h b/drivers/staging/rts5139/rts51x_chip.h new file mode 100644 index 00000000000..321ece750ed --- /dev/null +++ b/drivers/staging/rts5139/rts51x_chip.h @@ -0,0 +1,904 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_CHIP_H +#define __RTS51X_CHIP_H + +#include +#include +#include +#include +#include +#include + +#include "trace.h" + +#define SUPPORT_CPRM +#define SUPPORT_MAGIC_GATE +#define SUPPORT_MSXC +/* #define LED_AUTO_BLINK */ + +/* { wwang, 2010-07-26 + * Add support for SD lock/unlock */ +/* #define SUPPORT_SD_LOCK */ +/* } wwang, 2010-07-26 */ + +#ifdef SUPPORT_MAGIC_GA +/* Using NORMAL_WRITE instead of AUTO_WRITE to set ICVTE */ +#define MG_SET_ICV_SLOW +#endif + +#ifdef SUPPORT_MSXC +#define XC_POWERCLASS +#define SUPPORT_PCGL_1P18 +#endif + +#define GET_CARD_STATUS_USING_EPC + +#define CLOSE_SSC_POWER + +#define SUPPORT_OCP + +#define MS_SPEEDUP +/* #define XD_SPEEDUP */ + +#define SD_XD_IO_FOLLOW_PWR + +#define SD_NR 2 +#define MS_NR 3 +#define XD_NR 4 +#define SD_CARD (1 << SD_NR) +#define MS_CARD (1 << MS_NR) +#define XD_CARD (1 << XD_NR) + +#define SD_CD 0x01 +#define MS_CD 0x02 +#define XD_CD 0x04 +#define SD_WP 0x08 + +#define MAX_ALLOWED_LUN_CNT 8 +#define CMD_BUF_LEN 1024 +#define RSP_BUF_LEN 1024 +#define POLLING_INTERVAL 50 /* 50ms */ + +#define XD_FREE_TABLE_CNT 1200 +#define MS_FREE_TABLE_CNT 512 + +/* Bit Operation */ +#define SET_BIT(data, idx) ((data) |= 1 << (idx)) +#define CLR_BIT(data, idx) ((data) &= ~(1 << (idx))) +#define CHK_BIT(data, idx) ((data) & (1 << (idx))) + +/* Command type */ +#define READ_REG_CMD 0 +#define WRITE_REG_CMD 1 +#define CHECK_REG_CMD 2 + +#define PACKET_TYPE 4 +#define CNT_H 5 +#define CNT_L 6 +#define STAGE_FLAG 7 +#define CMD_OFFSET 8 + +/* Packet type */ +#define BATCH_CMD 0 +#define SEQ_READ 1 +#define SEQ_WRITE 2 + +/* Stage flag */ +#define STAGE_R 0x01 +#define STAGE_DI 0x02 +#define STAGE_DO 0x04 +/* Return MS_TRANS_CFG, GET_INT */ +#define STAGE_MS_STATUS 0x08 +/* Return XD_CFG, XD_CTL, XD_PAGE_STATUS */ +#define STAGE_XD_STATUS 0x10 +/* Command stage mode */ +#define MODE_C 0x00 +#define MODE_CR (STAGE_R) +#define MODE_CDIR (STAGE_R | STAGE_DI) +#define MODE_CDOR (STAGE_R | STAGE_DO) + +/* Function return code */ +#ifndef STATUS_SUCCESS +#define STATUS_SUCCESS 0 +#endif + +#define STATUS_FAIL 1 +#define STATUS_READ_FAIL 2 +#define STATUS_WRITE_FAIL 3 +#define STATUS_TIMEDOUT 4 +#define STATUS_NOMEM 5 +#define STATUS_TRANS_SHORT 6 +#define STATUS_TRANS_LONG 7 +#define STATUS_STALLED 8 +#define STATUS_ERROR 10 + +#define IDLE_MAX_COUNT 10 +#define POLLING_WAIT_CNT 1 +#define DELINK_DELAY 100 +#define LED_TOGGLE_INTERVAL 6 +#define LED_GPIO 0 + +/* package */ +#define QFN24 0 +#define LQFP48 1 + +#define USB_11 0 +#define USB_20 1 + +/* + * Transport return codes + */ +/* Transport good, command good */ +#define TRANSPORT_GOOD 0 +/* Transport good, command failed */ +#define TRANSPORT_FAILED 1 +/* Command failed, no auto-sense */ +#define TRANSPORT_NO_SENSE 2 +/* Transport bad (i.e. device dead) */ +#define TRANSPORT_ERROR 3 + +/* Supported Clock */ +enum card_clock { CLK_20 = 1, CLK_30, CLK_40, CLK_50, CLK_60, CLK_80, CLK_100 }; + +#ifdef _MSG_TRACE + +#define TRACE_ITEM_CNT 64 + +struct trace_msg_t { + u16 line; +#define MSG_FUNC_LEN 64 + char func[MSG_FUNC_LEN]; +#define MSG_FILE_LEN 32 + char file[MSG_FILE_LEN]; +#define TIME_VAL_LEN 16 + u8 timeval_buf[TIME_VAL_LEN]; + u8 valid; +}; + +#endif /* _MSG_TRACE */ + +/* Size of the autosense data buffer */ +#define SENSE_SIZE 18 + +/* Sense type */ +#define SENSE_TYPE_NO_SENSE 0 +#define SENSE_TYPE_MEDIA_CHANGE 1 +#define SENSE_TYPE_MEDIA_NOT_PRESENT 2 +#define SENSE_TYPE_MEDIA_LBA_OVER_RANGE 3 +#define SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT 4 +#define SENSE_TYPE_MEDIA_WRITE_PROTECT 5 +#define SENSE_TYPE_MEDIA_INVALID_CMD_FIELD 6 +#define SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR 7 +#define SENSE_TYPE_MEDIA_WRITE_ERR 8 +#define SENSE_TYPE_FORMAT_IN_PROGRESS 9 +#define SENSE_TYPE_FORMAT_CMD_FAILED 10 +#ifdef SUPPORT_MAGIC_GATE +/* COPY PROTECTION KEY EXCHANGE FAILURE - KEY NOT ESTABLISHED */ +#define SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB 0x0b +/* COPY PROTECTION KEY EXCHANGE FAILURE - AUTHENTICATION FAILURE */ +#define SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN 0x0c +/* INCOMPATIBLE MEDIUM INSTALLED */ +#define SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM 0x0d +/* WRITE ERROR */ +#define SENSE_TYPE_MG_WRITE_ERR 0x0e +#endif +#ifdef SUPPORT_SD_LOCK +/* FOR Locked SD card */ +#define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10 +#endif + +/*---- sense key ----*/ +#define ILI 0x20 /* ILI bit is on */ + +#define NO_SENSE 0x00 /* not exist sense key */ +#define RECOVER_ERR 0x01 /* Target/Logical unit is recoverd */ +#define NOT_READY 0x02 /* Logical unit is not ready */ +#define MEDIA_ERR 0x03 /* medium/data error */ +#define HARDWARE_ERR 0x04 /* hardware error */ +#define ILGAL_REQ 0x05 /* CDB/parameter/identify msg error */ +#define UNIT_ATTENTION 0x06 /* unit attention condition occur */ +#define DAT_PRTCT 0x07 /* read/write is desable */ +#define BLNC_CHK 0x08 /* find blank/DOF in read */ + /* write to unblank area */ +#define CPY_ABRT 0x0a /* Copy/Compare/Copy&Verify illgal */ +#define ABRT_CMD 0x0b /* Target make the command in error */ +#define EQUAL 0x0c /* Search Data end with Equal */ +#define VLM_OVRFLW 0x0d /* Some data are left in buffer */ +#define MISCMP 0x0e /* find inequality */ + +/*----------------------------------- + SENSE_DATA +-----------------------------------*/ +/*---- valid ----*/ +#define SENSE_VALID 0x80 /* Sense data is valid as SCSI2 */ +#define SENSE_INVALID 0x00 /* Sense data is invalid as SCSI2 */ + +/*---- error code ----*/ +#define CUR_ERR 0x70 /* current error */ +#define DEF_ERR 0x71 /* specific command error */ + +/*---- sense key Infomation ----*/ +#define SNSKEYINFO_LEN 3 /* length of sense key infomation */ + +#define SKSV 0x80 +#define CDB_ILLEGAL 0x40 +#define DAT_ILLEGAL 0x00 +#define BPV 0x08 +#define BIT_ILLEGAL0 0 /* bit0 is illegal */ +#define BIT_ILLEGAL1 1 /* bit1 is illegal */ +#define BIT_ILLEGAL2 2 /* bit2 is illegal */ +#define BIT_ILLEGAL3 3 /* bit3 is illegal */ +#define BIT_ILLEGAL4 4 /* bit4 is illegal */ +#define BIT_ILLEGAL5 5 /* bit5 is illegal */ +#define BIT_ILLEGAL6 6 /* bit6 is illegal */ +#define BIT_ILLEGAL7 7 /* bit7 is illegal */ + +/*---- ASC ----*/ +#define ASC_NO_INFO 0x00 +#define ASC_MISCMP 0x1d +#define ASC_INVLD_CDB 0x24 +#define ASC_INVLD_PARA 0x26 +#define ASC_LU_NOT_READY 0x04 +#define ASC_WRITE_ERR 0x0c +#define ASC_READ_ERR 0x11 +#define ASC_LOAD_EJCT_ERR 0x53 +#define ASC_MEDIA_NOT_PRESENT 0x3A +#define ASC_MEDIA_CHANGED 0x28 +#define ASC_MEDIA_IN_PROCESS 0x04 +#define ASC_WRITE_PROTECT 0x27 +#define ASC_LUN_NOT_SUPPORTED 0x25 + +/*---- ASQC ----*/ +#define ASCQ_NO_INFO 0x00 +#define ASCQ_MEDIA_IN_PROCESS 0x01 +#define ASCQ_MISCMP 0x00 +#define ASCQ_INVLD_CDB 0x00 +#define ASCQ_INVLD_PARA 0x02 +#define ASCQ_LU_NOT_READY 0x02 +#define ASCQ_WRITE_ERR 0x02 +#define ASCQ_READ_ERR 0x00 +#define ASCQ_LOAD_EJCT_ERR 0x00 +#define ASCQ_WRITE_PROTECT 0x00 + +struct sense_data_t { + unsigned char err_code; /* error code */ + /* bit7 : valid */ + /* (1 : SCSI2) */ + /* (0 : Vendor specific) */ + /* bit6-0 : error code */ + /* (0x70 : current error) */ + /* (0x71 : specific command error) */ + unsigned char seg_no; /* segment No. */ + unsigned char sense_key; /* byte5 : ILI */ + /* bit3-0 : sense key */ + unsigned char info[4]; /* infomation */ + unsigned char ad_sense_len; /* additional sense data length */ + unsigned char cmd_info[4]; /* command specific infomation */ + unsigned char asc; /* ASC */ + unsigned char ascq; /* ASCQ */ + unsigned char rfu; /* FRU */ + unsigned char sns_key_info[3]; /* sense key specific infomation */ +}; + +/* sd_ctl bit map */ +/* SD push point control, bit 0, 1 */ +#define SD_PUSH_POINT_CTL_MASK 0x03 +#define SD_PUSH_POINT_DELAY 0x01 +#define SD_PUSH_POINT_AUTO 0x02 +/* SD sample point control, bit 2, 3 */ +#define SD_SAMPLE_POINT_CTL_MASK 0x0C +#define SD_SAMPLE_POINT_DELAY 0x04 +#define SD_SAMPLE_POINT_AUTO 0x08 +/* SD DDR Tx phase set by user, bit 4 */ +#define SD_DDR_TX_PHASE_SET_BY_USER 0x10 +/* MMC DDR Tx phase set by user, bit 5 */ +#define MMC_DDR_TX_PHASE_SET_BY_USER 0x20 +/* Support MMC DDR mode, bit 6 */ +/*#define SUPPORT_MMC_DDR_MODE 0x40 */ +#define SUPPORT_UHS50_MMC44 0x40 + +struct rts51x_option { + u8 led_blink_speed; + + int mspro_formatter_enable; + + /* card clock expected by user for fpga platform */ + int fpga_sd_sdr104_clk; + int fpga_sd_ddr50_clk; + int fpga_sd_sdr50_clk; + int fpga_sd_hs_clk; + int fpga_mmc_52m_clk; + int fpga_ms_hg_clk; + int fpga_ms_4bit_clk; + + /* card clock expected by user for asic platform */ + int asic_sd_sdr104_clk; + int asic_sd_ddr50_clk; + int asic_sd_sdr50_clk; + int asic_sd_hs_clk; + int asic_mmc_52m_clk; + int asic_ms_hg_clk; + int asic_ms_4bit_clk; + + u8 ssc_depth_sd_sdr104; /* sw */ + u8 ssc_depth_sd_ddr50; /* sw */ + u8 ssc_depth_sd_sdr50; /* sw */ + u8 ssc_depth_sd_hs; /* sw */ + u8 ssc_depth_mmc_52m; /* sw */ + u8 ssc_depth_ms_hg; /* sw */ + u8 ssc_depth_ms_4bit; /* sw */ + u8 ssc_depth_low_speed; /* sw */ + + /* SD/MMC Tx phase */ + int sd_ddr_tx_phase; /* Enabled by bit 4 of sd_ctl */ + int mmc_ddr_tx_phase; /* Enabled by bit 5 of sd_ctl */ + + /* priority of choosing sd speed funciton */ + u32 sd_speed_prior; + + /* sd card control */ + u32 sd_ctl; + + /* Enable Selective Suspend */ + int ss_en; + /* Interval to enter SS from IDLE state (second) */ + int ss_delay; + int needs_remote_wakeup; + u8 ww_enable; /* sangdy2010-08-03:add for remote wakeup */ + + /* Enable SSC clock */ + int ssc_en; + + int auto_delink_en; + + /* sangdy2010-07-13:add FT2 fast mode */ + int FT2_fast_mode; + /* sangdy2010-07-15: + * add for config delay between 1/4 PMOS and 3/4 PMOS */ + int pwr_delay; + + int xd_rw_step; /* add to tune xd tRP */ + int D3318_off_delay; /* add to tune D3318 off delay time */ + int delink_delay; /* add to tune delink delay time */ + /* add for rts5129 to enable/disable D3318 off */ + u8 rts5129_D3318_off_enable; + u8 sd20_pad_drive; /* add to config SD20 PAD drive */ + u8 sd30_pad_drive; /* add to config SD30 pad drive */ + /*if reset or rw fail,then set SD20 pad drive again */ + u8 reset_or_rw_fail_set_pad_drive; + + u8 rcc_fail_flag; /* add to indicate whether rcc bug happen */ + u8 rcc_bug_fix_en; /* if set,then support fixing rcc bug */ + u8 debounce_num; /* debounce number */ + int polling_time; /* polling delay time */ + u8 led_toggle_interval; /* used to control led toggle speed */ + int xd_rwn_step; + u8 sd_send_status_en; + /* used to store default phase which is + * used when phase tune all pass. */ + u8 ddr50_tx_phase; + u8 ddr50_rx_phase; + u8 sdr50_tx_phase; + u8 sdr50_rx_phase; + /* used to enable select sdr50 tx phase according to proportion. */ + u8 sdr50_phase_sel; + u8 ms_errreg_fix; + u8 reset_mmc_first; + u8 speed_mmc; /* when set, then try CMD55 only twice */ + u8 led_always_on; /* if set, then led always on when card exist */ + u8 dv18_voltage; /* add to tune dv18 voltage */ +}; + +#define MS_FORMATTER_ENABLED(chip) ((chip)->option.mspro_formatter_enable) + +struct rts51x_chip; + +typedef int (*card_rw_func) (struct scsi_cmnd *srb, struct rts51x_chip *chip, + u32 sec_addr, u16 sec_cnt); + +/* For MS Card */ +#define MAX_DEFECTIVE_BLOCK 10 + +struct zone_entry { + u16 *l2p_table; + u16 *free_table; + u16 defect_list[MAX_DEFECTIVE_BLOCK]; /* For MS card only */ + int set_index; + int get_index; + int unused_blk_cnt; + int disable_count; + /* To indicate whether the L2P table of this zone has been built. */ + int build_flag; +}; + +struct xd_delay_write_tag { + u32 old_phyblock; + u32 new_phyblock; + u32 logblock; + u8 pageoff; + u8 delay_write_flag; +}; + +struct xd_info { + u8 maker_code; + u8 device_code; + u8 block_shift; + u8 page_off; + u8 addr_cycle; + u16 cis_block; + u8 multi_flag; + u8 err_code; + u32 capacity; + + struct zone_entry *zone; + int zone_cnt; + + struct xd_delay_write_tag delay_write; + + int counter; + + int xd_clock; +}; + +#define TYPE_SD 0x0000 +#define TYPE_MMC 0x0001 + +/* TYPE_SD */ +#define SD_HS 0x0100 +#define SD_SDR50 0x0200 +#define SD_DDR50 0x0400 +#define SD_SDR104 0x0800 +#define SD_HCXC 0x1000 + +/* TYPE_MMC */ +#define MMC_26M 0x0100 +#define MMC_52M 0x0200 +#define MMC_4BIT 0x0400 +#define MMC_8BIT 0x0800 +#define MMC_SECTOR_MODE 0x1000 +#define MMC_DDR52 0x2000 + +/* SD card */ +#define CHK_SD(sd_card) (((sd_card)->sd_type & 0xFF) == TYPE_SD) +#define CHK_SD_HS(sd_card) \ + (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_HS)) +#define CHK_SD_SDR50(sd_card) \ + (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_SDR50)) +#define CHK_SD_DDR50(sd_card) \ + (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_DDR50)) +#define CHK_SD_SDR104(sd_card) \ + (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_SDR104)) +#define CHK_SD_HCXC(sd_card) \ + (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_HCXC)) +#define CHK_SD30_SPEED(sd_card) \ + (CHK_SD_SDR50(sd_card) || CHK_SD_DDR50(sd_card) ||\ + CHK_SD_SDR104(sd_card)) + +#define SET_SD(sd_card) ((sd_card)->sd_type = TYPE_SD) +#define SET_SD_HS(sd_card) ((sd_card)->sd_type |= SD_HS) +#define SET_SD_SDR50(sd_card) ((sd_card)->sd_type |= SD_SDR50) +#define SET_SD_DDR50(sd_card) ((sd_card)->sd_type |= SD_DDR50) +#define SET_SD_SDR104(sd_card) ((sd_card)->sd_type |= SD_SDR104) +#define SET_SD_HCXC(sd_card) ((sd_card)->sd_type |= SD_HCXC) + +#define CLR_SD_HS(sd_card) ((sd_card)->sd_type &= ~SD_HS) +#define CLR_SD_SDR50(sd_card) ((sd_card)->sd_type &= ~SD_SDR50) +#define CLR_SD_DDR50(sd_card) ((sd_card)->sd_type &= ~SD_DDR50) +#define CLR_SD_SDR104(sd_card) ((sd_card)->sd_type &= ~SD_SDR104) +#define CLR_SD_HCXC(sd_card) ((sd_card)->sd_type &= ~SD_HCXC) +#define CLR_SD30_SPEED(sd_card) \ + ((sd_card)->sd_type &= ~(SD_SDR50|SD_DDR50|SD_SDR104)) + +/* MMC card */ +#define CHK_MMC(sd_card) \ + (((sd_card)->sd_type & 0xFF) == TYPE_MMC) +#define CHK_MMC_26M(sd_card) \ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_26M)) +#define CHK_MMC_52M(sd_card) \ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_52M)) +#define CHK_MMC_4BIT(sd_card) \ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_4BIT)) +#define CHK_MMC_8BIT(sd_card) \ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_8BIT)) +#define CHK_MMC_SECTOR_MODE(sd_card)\ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_SECTOR_MODE)) +#define CHK_MMC_DDR52(sd_card) \ + (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_DDR52)) + +#define SET_MMC(sd_card) ((sd_card)->sd_type = TYPE_MMC) +#define SET_MMC_26M(sd_card) ((sd_card)->sd_type |= MMC_26M) +#define SET_MMC_52M(sd_card) ((sd_card)->sd_type |= MMC_52M) +#define SET_MMC_4BIT(sd_card) ((sd_card)->sd_type |= MMC_4BIT) +#define SET_MMC_8BIT(sd_card) ((sd_card)->sd_type |= MMC_8BIT) +#define SET_MMC_SECTOR_MODE(sd_card) ((sd_card)->sd_type |= MMC_SECTOR_MODE) +#define SET_MMC_DDR52(sd_card) ((sd_card)->sd_type |= MMC_DDR52) + +#define CLR_MMC_26M(sd_card) ((sd_card)->sd_type &= ~MMC_26M) +#define CLR_MMC_52M(sd_card) ((sd_card)->sd_type &= ~MMC_52M) +#define CLR_MMC_4BIT(sd_card) ((sd_card)->sd_type &= ~MMC_4BIT) +#define CLR_MMC_8BIT(sd_card) ((sd_card)->sd_type &= ~MMC_8BIT) +#define CLR_MMC_SECTOR_MODE(sd_card) ((sd_card)->sd_type &= ~MMC_SECTOR_MODE) +#define CLR_MMC_DDR52(sd_card) ((sd_card)->sd_type &= ~MMC_DDR52) + +#define CHK_MMC_HS(sd_card) \ + (CHK_MMC_52M(sd_card) && CHK_MMC_26M(sd_card)) +#define CLR_MMC_HS(sd_card) \ +do { \ + CLR_MMC_DDR52(sd_card); \ + CLR_MMC_52M(sd_card); \ + CLR_MMC_26M(sd_card); \ +} while (0) + +#define SD_SUPPORT_CLASS_TEN 0x01 +#define SD_SUPPORT_1V8 0x02 + +#define SD_SET_CLASS_TEN(sd_card) \ + ((sd_card)->sd_setting |= SD_SUPPORT_CLASS_TEN) +#define SD_CHK_CLASS_TEN(sd_card) \ + ((sd_card)->sd_setting & SD_SUPPORT_CLASS_TEN) +#define SD_CLR_CLASS_TEN(sd_card) \ + ((sd_card)->sd_setting &= ~SD_SUPPORT_CLASS_TEN) +#define SD_SET_1V8(sd_card) \ + ((sd_card)->sd_setting |= SD_SUPPORT_1V8) +#define SD_CHK_1V8(sd_card) \ + ((sd_card)->sd_setting & SD_SUPPORT_1V8) +#define SD_CLR_1V8(sd_card) \ + ((sd_card)->sd_setting &= ~SD_SUPPORT_1V8) +#define CLR_RETRY_SD20_MODE(sd_card) \ + ((sd_card)->retry_SD20_mode = 0) +#define SET_RETRY_SD20_MODE(sd_card) \ + ((sd_card)->retry_SD20_mode = 1) +#define CHK_RETRY_SD20_MODE(sd_card) \ + ((sd_card)->retry_SD20_mode == 1) + +struct sd_info { + u16 sd_type; + u8 err_code; + u8 sd_data_buf_ready; + u32 sd_addr; + u32 capacity; + + u8 raw_csd[16]; + u8 raw_scr[8]; + + /* Sequential RW */ + int seq_mode; + enum dma_data_direction pre_dir; + u32 pre_sec_addr; + u16 pre_sec_cnt; + + int counter; + + int sd_clock; + +#ifdef SUPPORT_CPRM + int sd_pass_thru_en; + int pre_cmd_err; + u8 last_rsp_type; + u8 rsp[17]; +#endif + + u8 func_group1_mask; + u8 func_group2_mask; + u8 func_group3_mask; + u8 func_group4_mask; + + u8 sd_switch_fail; + u8 sd_read_phase; + u8 retry_SD20_mode; /* sangdy2010-06-10 */ + u8 sd_reset_fail; /* sangdy2010-07-01 */ + u8 sd_send_status_en; + +#ifdef SUPPORT_SD_LOCK + u8 sd_lock_status; + u8 sd_erase_status; + u8 sd_lock_notify; +#endif +}; + +#define MODE_512_SEQ 0x01 +#define MODE_2K_SEQ 0x02 + +#define TYPE_MS 0x0000 +#define TYPE_MSPRO 0x0001 + +#define MS_4BIT 0x0100 +#define MS_8BIT 0x0200 +#define MS_HG 0x0400 +#define MS_XC 0x0800 + +#define HG8BIT (MS_HG | MS_8BIT) + +#define CHK_MSPRO(ms_card) \ + (((ms_card)->ms_type & 0xFF) == TYPE_MSPRO) +#define CHK_HG8BIT(ms_card) \ + (CHK_MSPRO(ms_card) && (((ms_card)->ms_type & HG8BIT) == HG8BIT)) +#define CHK_MSXC(ms_card) \ + (CHK_MSPRO(ms_card) && ((ms_card)->ms_type & MS_XC)) +#define CHK_MSHG(ms_card) \ + (CHK_MSPRO(ms_card) && ((ms_card)->ms_type & MS_HG)) + +#define CHK_MS8BIT(ms_card) (((ms_card)->ms_type & MS_8BIT)) +#define CHK_MS4BIT(ms_card) (((ms_card)->ms_type & MS_4BIT)) + +struct ms_delay_write_tag { + u16 old_phyblock; + u16 new_phyblock; + u16 logblock; + u8 pageoff; + u8 delay_write_flag; +}; + +struct ms_info { + u16 ms_type; + u8 block_shift; + u8 page_off; + u16 total_block; + u16 boot_block; + u32 capacity; + + u8 check_ms_flow; + u8 switch_8bit_fail; + u8 err_code; + + struct zone_entry *segment; + int segment_cnt; + + int pro_under_formatting; + int format_status; + u16 progress; + u8 raw_sys_info[96]; +#ifdef SUPPORT_PCGL_1P18 + u8 raw_model_name[48]; +#endif + + u8 multi_flag; + + /* Sequential RW */ + u8 seq_mode; + enum dma_data_direction pre_dir; + u32 pre_sec_addr; + u16 pre_sec_cnt; + u32 total_sec_cnt; + u8 last_rw_int; + + struct ms_delay_write_tag delay_write; + + int counter; + + int ms_clock; + +#ifdef SUPPORT_MAGIC_GATE + u8 magic_gate_id[16]; + u8 mg_entry_num; + int mg_auth; /* flag to indicate authentication process */ +#endif +}; + +#define PRO_UNDER_FORMATTING(ms_card) \ + ((ms_card)->pro_under_formatting) +#define SET_FORMAT_STATUS(ms_card, status) \ + ((ms_card)->format_status = (status)) +#define CHK_FORMAT_STATUS(ms_card, status) \ + ((ms_card)->format_status == (status)) + +struct scsi_cmnd; + +enum CHIP_STAT { STAT_INIT, STAT_IDLE, STAT_RUN, STAT_SS_PRE, STAT_SS, + STAT_SUSPEND }; + +struct rts51x_chip { + u16 vendor_id; + u16 product_id; + char max_lun; + + struct scsi_cmnd *srb; + struct sense_data_t sense_buffer[MAX_ALLOWED_LUN_CNT]; + +#ifndef LED_AUTO_BLINK + int led_toggle_counter; +#endif + int ss_counter; + int idle_counter; + int auto_delink_counter; + enum CHIP_STAT chip_stat; + + int resume_from_scsi; + + /* Card information */ + struct xd_info xd_card; + struct sd_info sd_card; + struct ms_info ms_card; + + int cur_clk; /* current card clock */ + int cur_card; /* Current card module */ + + u8 card_exist; /* card exist bit map (physical exist) */ + u8 card_ready; /* card ready bit map (reset successfully) */ + u8 card_fail; /* card reset fail bit map */ + u8 card_ejected; /* card ejected bit map */ + u8 card_wp; /* card write protected bit map */ + + u8 fake_card_ready; + /* flag to indicate whether to answer MediaChange */ + unsigned long lun_mc; + + /* card bus width */ + u8 card_bus_width[MAX_ALLOWED_LUN_CNT]; + /* card capacity */ + u32 capacity[MAX_ALLOWED_LUN_CNT]; + + /* read/write card function pointer */ + card_rw_func rw_card[MAX_ALLOWED_LUN_CNT]; + /* read/write capacity, used for GPIO Toggle */ + u32 rw_cap[MAX_ALLOWED_LUN_CNT]; + /* card to lun mapping table */ + u8 card2lun[32]; + /* lun to card mapping table */ + u8 lun2card[MAX_ALLOWED_LUN_CNT]; + +#ifdef _MSG_TRACE + struct trace_msg_t trace_msg[TRACE_ITEM_CNT]; + int msg_idx; +#endif + + int rw_need_retry; + + /* ASIC or FPGA */ + int asic_code; + + /* QFN24 or LQFP48 */ + int package; + + /* Full Speed or High Speed */ + int usb_speed; + + /*sangdy:enable or disable UHS50 and MMC4.4 */ + int uhs50_mmc44_en; + + u8 ic_version; + + /* Command buffer */ + u8 *cmd_buf; + unsigned int cmd_idx; + /* Response buffer */ + u8 *rsp_buf; + + u16 card_status; + +#ifdef SUPPORT_OCP + u16 ocp_stat; +#endif + + struct rts51x_option option; + struct rts51x_usb *usb; + + u8 rcc_read_response; + int reset_need_retry; + u8 rts5179; +}; + +#define UHS50_EN 0x0001 +#define UHS50_DIS 0x0000 +#define SET_UHS50(chip) ((chip)->uhs50_mmc44_en = UHS50_EN) +#define CLEAR_UHS50(chip) ((chip)->uhs50_mmc44_en = UHS50_DIS) +#define CHECK_UHS50(chip) (((chip)->uhs50_mmc44_en&0xff) == UHS50_EN) + +#define RTS51X_GET_VID(chip) ((chip)->vendor_id) +#define RTS51X_GET_PID(chip) ((chip)->product_id) + +#define RTS51X_SET_STAT(chip, stat) \ +do { \ + if ((stat) != STAT_IDLE) { \ + (chip)->idle_counter = 0; \ + } \ + (chip)->chip_stat = (enum CHIP_STAT)(stat); \ +} while (0) +#define RTS51X_CHK_STAT(chip, stat) ((chip)->chip_stat == (stat)) +#define RTS51X_GET_STAT(chip) ((chip)->chip_stat) + +#define CHECK_PID(chip, pid) (RTS51X_GET_PID(chip) == (pid)) +#define CHECK_PKG(chip, pkg) ((chip)->package == (pkg)) +#define CHECK_USB(chip, speed) ((chip)->usb_speed == (speed)) + +int rts51x_reset_chip(struct rts51x_chip *chip); +int rts51x_init_chip(struct rts51x_chip *chip); +int rts51x_release_chip(struct rts51x_chip *chip); +void rts51x_polling_func(struct rts51x_chip *chip); + +static inline void rts51x_init_cmd(struct rts51x_chip *chip) +{ + chip->cmd_idx = 0; + chip->cmd_buf[0] = 'R'; + chip->cmd_buf[1] = 'T'; + chip->cmd_buf[2] = 'C'; + chip->cmd_buf[3] = 'R'; + chip->cmd_buf[PACKET_TYPE] = BATCH_CMD; +} + +void rts51x_add_cmd(struct rts51x_chip *chip, + u8 cmd_type, u16 reg_addr, u8 mask, u8 data); +int rts51x_send_cmd(struct rts51x_chip *chip, u8 flag, int timeout); +int rts51x_get_rsp(struct rts51x_chip *chip, int rsp_len, int timeout); + +static inline void rts51x_read_rsp_buf(struct rts51x_chip *chip, int offset, + u8 *buf, int buf_len) +{ + memcpy(buf, chip->rsp_buf + offset, buf_len); +} + +static inline u8 *rts51x_get_rsp_data(struct rts51x_chip *chip) +{ + return chip->rsp_buf; +} + +int rts51x_get_card_status(struct rts51x_chip *chip, u16 * status); +int rts51x_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, u8 data); +int rts51x_read_register(struct rts51x_chip *chip, u16 addr, u8 * data); +int rts51x_ep0_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, + u8 data); +int rts51x_ep0_read_register(struct rts51x_chip *chip, u16 addr, u8 * data); +int rts51x_seq_write_register(struct rts51x_chip *chip, u16 addr, u16 len, + u8 *data); +int rts51x_seq_read_register(struct rts51x_chip *chip, u16 addr, u16 len, + u8 *data); +int rts51x_read_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len); +int rts51x_write_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len); +int rts51x_write_phy_register(struct rts51x_chip *chip, u8 addr, u8 val); +int rts51x_read_phy_register(struct rts51x_chip *chip, u8 addr, u8 *val); +void rts51x_do_before_power_down(struct rts51x_chip *chip); +void rts51x_clear_hw_error(struct rts51x_chip *chip); +void rts51x_prepare_run(struct rts51x_chip *chip); +void rts51x_trace_msg(struct rts51x_chip *chip, unsigned char *buf, int clear); +void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, + u8 status_len); +void rts51x_read_status(struct rts51x_chip *chip, unsigned int lun, + u8 *rts51x_status, u8 status_len); +int rts51x_transfer_data_rcc(struct rts51x_chip *chip, unsigned int pipe, + void *buf, unsigned int len, int use_sg, + unsigned int *act_len, int timeout, u8 stage_flag); + +#define RTS51X_WRITE_REG(chip, addr, mask, data) \ +do { \ + int _retval = rts51x_write_register((chip), \ + (addr), (mask), (data)); \ + if (_retval != STATUS_SUCCESS) { \ + TRACE_RET((chip), _retval); \ + } \ +} while (0) + +#define RTS51X_READ_REG(chip, addr, data) \ +do { \ + int _retval = rts51x_read_register((chip), \ + (addr), (data)); \ + if (_retval != STATUS_SUCCESS) { \ + TRACE_RET((chip), _retval); \ + } \ +} while (0) + +#endif /* __RTS51X_CHIP_H */ diff --git a/drivers/staging/rts5139/rts51x_fop.c b/drivers/staging/rts5139/rts51x_fop.c new file mode 100644 index 00000000000..6eaebb6223c --- /dev/null +++ b/drivers/staging/rts5139/rts51x_fop.c @@ -0,0 +1,298 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include "rts51x.h" + +#ifdef SUPPORT_FILE_OP + +#include +#include +#include +#include + +#include "rts51x_chip.h" +#include "rts51x_card.h" +#include "rts51x_fop.h" +#include "sd_cprm.h" +#include "rts51x.h" + +#define RTS5139_IOC_MAGIC 0x39 + +#define RTS5139_IOC_SD_DIRECT _IOWR(RTS5139_IOC_MAGIC, 0xA0, int) +#define RTS5139_IOC_SD_GET_RSP _IOWR(RTS5139_IOC_MAGIC, 0xA1, int) + +static int rts51x_sd_direct_cmnd(struct rts51x_chip *chip, + struct sd_direct_cmnd *cmnd) +{ + int retval; + u8 dir, cmd12, standby, acmd, cmd_idx, rsp_code; + u8 *buf; + u32 arg, len; + + dir = (cmnd->cmnd[0] >> 3) & 0x03; + cmd12 = (cmnd->cmnd[0] >> 2) & 0x01; + standby = (cmnd->cmnd[0] >> 1) & 0x01; + acmd = cmnd->cmnd[0] & 0x01; + cmd_idx = cmnd->cmnd[1]; + arg = ((u32) (cmnd->cmnd[2]) << 24) | ((u32) (cmnd->cmnd[3]) << 16) | + ((u32) (cmnd->cmnd[4]) << 8) | cmnd->cmnd[5]; + len = + ((u32) (cmnd->cmnd[6]) << 16) | ((u32) (cmnd->cmnd[7]) << 8) | + cmnd->cmnd[8]; + rsp_code = cmnd->cmnd[9]; + + if (dir) { + if (!cmnd->buf || (cmnd->buf_len < len)) + TRACE_RET(chip, STATUS_FAIL); + } + + switch (dir) { + case 0: + /* No data */ + retval = ext_sd_execute_no_data(chip, chip->card2lun[SD_CARD], + cmd_idx, standby, acmd, + rsp_code, arg); + if (retval != TRANSPORT_GOOD) + TRACE_RET(chip, STATUS_FAIL); + break; + + case 1: + /* Read from card */ + buf = kmalloc(cmnd->buf_len, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, STATUS_NOMEM); + + retval = ext_sd_execute_read_data(chip, chip->card2lun[SD_CARD], + cmd_idx, cmd12, standby, acmd, + rsp_code, arg, len, buf, + cmnd->buf_len, 0); + if (retval != TRANSPORT_GOOD) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = + copy_to_user((void *)cmnd->buf, (void *)buf, cmnd->buf_len); + if (retval) { + kfree(buf); + TRACE_RET(chip, STATUS_NOMEM); + } + + kfree(buf); + break; + + case 2: + /* Write to card */ + buf = kmalloc(cmnd->buf_len, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, STATUS_NOMEM); + + retval = + copy_from_user((void *)buf, (void *)cmnd->buf, + cmnd->buf_len); + if (retval) { + kfree(buf); + TRACE_RET(chip, STATUS_NOMEM); + } + + retval = + ext_sd_execute_write_data(chip, chip->card2lun[SD_CARD], + cmd_idx, cmd12, standby, acmd, + rsp_code, arg, len, buf, + cmnd->buf_len, 0); + if (retval != TRANSPORT_GOOD) { + kfree(buf); + TRACE_RET(chip, STATUS_FAIL); + } + + kfree(buf); + + break; + + default: + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int rts51x_sd_get_rsp(struct rts51x_chip *chip, struct sd_rsp *rsp) +{ + struct sd_info *sd_card = &(chip->sd_card); + int count = 0, retval; + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + TRACE_RET(chip, STATUS_FAIL); + } + + if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) + TRACE_RET(chip, STATUS_FAIL); + else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) + count = (rsp->rsp_len < 17) ? rsp->rsp_len : 17; + else + count = (rsp->rsp_len < 6) ? rsp->rsp_len : 6; + + retval = copy_to_user((void *)rsp->rsp, (void *)sd_card->rsp, count); + if (retval) + TRACE_RET(chip, STATUS_NOMEM); + + RTS51X_DEBUGP("Response length: %d\n", count); + RTS51X_DEBUGP("Response: 0x%x 0x%x 0x%x 0x%x\n", + sd_card->rsp[0], sd_card->rsp[1], sd_card->rsp[2], + sd_card->rsp[3]); + + return STATUS_SUCCESS; +} + +int rts51x_open(struct inode *inode, struct file *filp) +{ + struct rts51x_chip *chip; + struct usb_interface *interface; + int subminor; + int retval = 0; + + subminor = iminor(inode); + + interface = usb_find_interface(&rts51x_driver, subminor); + if (!interface) { + RTS51X_DEBUGP("%s - error, can't find device for minor %d\n", + __func__, subminor); + retval = -ENODEV; + goto exit; + } + + chip = (struct rts51x_chip *)usb_get_intfdata(interface); + if (!chip) { + RTS51X_DEBUGP("Can't find chip\n"); + retval = -ENODEV; + goto exit; + } + + /* Increase our reference to the host */ + scsi_host_get(rts51x_to_host(chip)); + + /* lock the device pointers */ + mutex_lock(&(chip->usb->dev_mutex)); + + /* save our object in the file's private structure */ + filp->private_data = chip; + + /* unlock the device pointers */ + mutex_unlock(&chip->usb->dev_mutex); + +exit: + return retval; +} + +int rts51x_release(struct inode *inode, struct file *filp) +{ + struct rts51x_chip *chip; + + chip = (struct rts51x_chip *)filp->private_data; + if (chip == NULL) + return -ENODEV; + + /* Drop our reference to the host; the SCSI core will free it + * (and "chip" along with it) when the refcount becomes 0. */ + scsi_host_put(rts51x_to_host(chip)); + + return 0; +} + +ssize_t rts51x_read(struct file *filp, char __user *buf, size_t count, + loff_t *f_pos) +{ + return 0; +} + +ssize_t rts51x_write(struct file *filp, const char __user *buf, size_t count, + loff_t *f_pos) +{ + return 0; +} + +#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */ +int rts51x_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +#else +long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +#endif +{ + struct rts51x_chip *chip; + struct sd_direct_cmnd cmnd; + struct sd_rsp rsp; + int retval = 0; + + chip = (struct rts51x_chip *)filp->private_data; + if (chip == NULL) + return -ENODEV; + + /* lock the device pointers */ + mutex_lock(&(chip->usb->dev_mutex)); + + switch (cmd) { + case RTS5139_IOC_SD_DIRECT: + retval = + copy_from_user((void *)&cmnd, (void *)arg, + sizeof(struct sd_direct_cmnd)); + if (retval) { + retval = -ENOMEM; + TRACE_GOTO(chip, exit); + } + retval = rts51x_sd_direct_cmnd(chip, &cmnd); + if (retval != STATUS_SUCCESS) { + retval = -EIO; + TRACE_GOTO(chip, exit); + } + break; + + case RTS5139_IOC_SD_GET_RSP: + retval = + copy_from_user((void *)&rsp, (void *)arg, + sizeof(struct sd_rsp)); + if (retval) { + retval = -ENOMEM; + TRACE_GOTO(chip, exit); + } + retval = rts51x_sd_get_rsp(chip, &rsp); + if (retval != STATUS_SUCCESS) { + retval = -EIO; + TRACE_GOTO(chip, exit); + } + break; + + default: + break; + } + +exit: + /* unlock the device pointers */ + mutex_unlock(&chip->usb->dev_mutex); + + return retval; +} + +#endif diff --git a/drivers/staging/rts5139/rts51x_fop.h b/drivers/staging/rts5139/rts51x_fop.h new file mode 100644 index 00000000000..0453f57d1a8 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_fop.h @@ -0,0 +1,62 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_FOP_H +#define __RTS51X_FOP_H + +#include "rts51x.h" + +#ifdef SUPPORT_FILE_OP + +#include +#include + +struct sd_direct_cmnd { + u8 cmnd[12]; + void *buf; + int buf_len; +}; + +struct sd_rsp { + void *rsp; + int rsp_len; +}; + +int rts51x_open(struct inode *inode, struct file *filp); +int rts51x_release(struct inode *inode, struct file *filp); +ssize_t rts51x_read(struct file *filp, char __user *buf, size_t count, + loff_t *f_pos); +ssize_t rts51x_write(struct file *filp, const char __user * buf, size_t count, + loff_t *f_pos); +#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */ +int rts51x_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +#else +long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); +#endif + +#endif + +#endif /* __RTS51X_FOP_H */ diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c new file mode 100644 index 00000000000..f6044937e33 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_scsi.c @@ -0,0 +1,2233 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "debug.h" +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "rts51x_transport.h" +#include "rts51x_sys.h" +#include "sd_cprm.h" +#include "ms_mg.h" +#include "trace.h" + +void scsi_show_command(struct scsi_cmnd *srb) +{ + char *what = NULL; + int i, unknown_cmd = 0; + + switch (srb->cmnd[0]) { + case TEST_UNIT_READY: + what = (char *)"TEST_UNIT_READY"; + break; + case REZERO_UNIT: + what = (char *)"REZERO_UNIT"; + break; + case REQUEST_SENSE: + what = (char *)"REQUEST_SENSE"; + break; + case FORMAT_UNIT: + what = (char *)"FORMAT_UNIT"; + break; + case READ_BLOCK_LIMITS: + what = (char *)"READ_BLOCK_LIMITS"; + break; + case 0x07: + what = (char *)"REASSIGN_BLOCKS"; + break; + case READ_6: + what = (char *)"READ_6"; + break; + case WRITE_6: + what = (char *)"WRITE_6"; + break; + case SEEK_6: + what = (char *)"SEEK_6"; + break; + case READ_REVERSE: + what = (char *)"READ_REVERSE"; + break; + case WRITE_FILEMARKS: + what = (char *)"WRITE_FILEMARKS"; + break; + case SPACE: + what = (char *)"SPACE"; + break; + case INQUIRY: + what = (char *)"INQUIRY"; + break; + case RECOVER_BUFFERED_DATA: + what = (char *)"RECOVER_BUFFERED_DATA"; + break; + case MODE_SELECT: + what = (char *)"MODE_SELECT"; + break; + case RESERVE: + what = (char *)"RESERVE"; + break; + case RELEASE: + what = (char *)"RELEASE"; + break; + case COPY: + what = (char *)"COPY"; + break; + case ERASE: + what = (char *)"ERASE"; + break; + case MODE_SENSE: + what = (char *)"MODE_SENSE"; + break; + case START_STOP: + what = (char *)"START_STOP"; + break; + case RECEIVE_DIAGNOSTIC: + what = (char *)"RECEIVE_DIAGNOSTIC"; + break; + case SEND_DIAGNOSTIC: + what = (char *)"SEND_DIAGNOSTIC"; + break; + case ALLOW_MEDIUM_REMOVAL: + what = (char *)"ALLOW_MEDIUM_REMOVAL"; + break; + case SET_WINDOW: + what = (char *)"SET_WINDOW"; + break; + case READ_CAPACITY: + what = (char *)"READ_CAPACITY"; + break; + case READ_10: + what = (char *)"READ_10"; + break; + case WRITE_10: + what = (char *)"WRITE_10"; + break; + case SEEK_10: + what = (char *)"SEEK_10"; + break; + case WRITE_VERIFY: + what = (char *)"WRITE_VERIFY"; + break; + case VERIFY: + what = (char *)"VERIFY"; + break; + case SEARCH_HIGH: + what = (char *)"SEARCH_HIGH"; + break; + case SEARCH_EQUAL: + what = (char *)"SEARCH_EQUAL"; + break; + case SEARCH_LOW: + what = (char *)"SEARCH_LOW"; + break; + case SET_LIMITS: + what = (char *)"SET_LIMITS"; + break; + case READ_POSITION: + what = (char *)"READ_POSITION"; + break; + case SYNCHRONIZE_CACHE: + what = (char *)"SYNCHRONIZE_CACHE"; + break; + case LOCK_UNLOCK_CACHE: + what = (char *)"LOCK_UNLOCK_CACHE"; + break; + case READ_DEFECT_DATA: + what = (char *)"READ_DEFECT_DATA"; + break; + case MEDIUM_SCAN: + what = (char *)"MEDIUM_SCAN"; + break; + case COMPARE: + what = (char *)"COMPARE"; + break; + case COPY_VERIFY: + what = (char *)"COPY_VERIFY"; + break; + case WRITE_BUFFER: + what = (char *)"WRITE_BUFFER"; + break; + case READ_BUFFER: + what = (char *)"READ_BUFFER"; + break; + case UPDATE_BLOCK: + what = (char *)"UPDATE_BLOCK"; + break; + case READ_LONG: + what = (char *)"READ_LONG"; + break; + case WRITE_LONG: + what = (char *)"WRITE_LONG"; + break; + case CHANGE_DEFINITION: + what = (char *)"CHANGE_DEFINITION"; + break; + case WRITE_SAME: + what = (char *)"WRITE_SAME"; + break; + case GPCMD_READ_SUBCHANNEL: + what = (char *)"READ SUBCHANNEL"; + break; + case READ_TOC: + what = (char *)"READ_TOC"; + break; + case GPCMD_READ_HEADER: + what = (char *)"READ HEADER"; + break; + case GPCMD_PLAY_AUDIO_10: + what = (char *)"PLAY AUDIO (10)"; + break; + case GPCMD_PLAY_AUDIO_MSF: + what = (char *)"PLAY AUDIO MSF"; + break; + case GPCMD_GET_EVENT_STATUS_NOTIFICATION: + what = (char *)"GET EVENT/STATUS NOTIFICATION"; + break; + case GPCMD_PAUSE_RESUME: + what = (char *)"PAUSE/RESUME"; + break; + case LOG_SELECT: + what = (char *)"LOG_SELECT"; + break; + case LOG_SENSE: + what = (char *)"LOG_SENSE"; + break; + case GPCMD_STOP_PLAY_SCAN: + what = (char *)"STOP PLAY/SCAN"; + break; + case GPCMD_READ_DISC_INFO: + what = (char *)"READ DISC INFORMATION"; + break; + case GPCMD_READ_TRACK_RZONE_INFO: + what = (char *)"READ TRACK INFORMATION"; + break; + case GPCMD_RESERVE_RZONE_TRACK: + what = (char *)"RESERVE TRACK"; + break; + case GPCMD_SEND_OPC: + what = (char *)"SEND OPC"; + break; + case MODE_SELECT_10: + what = (char *)"MODE_SELECT_10"; + break; + case GPCMD_REPAIR_RZONE_TRACK: + what = (char *)"REPAIR TRACK"; + break; + case 0x59: + what = (char *)"READ MASTER CUE"; + break; + case MODE_SENSE_10: + what = (char *)"MODE_SENSE_10"; + break; + case GPCMD_CLOSE_TRACK: + what = (char *)"CLOSE TRACK/SESSION"; + break; + case 0x5C: + what = (char *)"READ BUFFER CAPACITY"; + break; + case 0x5D: + what = (char *)"SEND CUE SHEET"; + break; + case GPCMD_BLANK: + what = (char *)"BLANK"; + break; + case REPORT_LUNS: + what = (char *)"REPORT LUNS"; + break; + case MOVE_MEDIUM: + what = (char *)"MOVE_MEDIUM or PLAY AUDIO (12)"; + break; + case READ_12: + what = (char *)"READ_12"; + break; + case WRITE_12: + what = (char *)"WRITE_12"; + break; + case WRITE_VERIFY_12: + what = (char *)"WRITE_VERIFY_12"; + break; + case SEARCH_HIGH_12: + what = (char *)"SEARCH_HIGH_12"; + break; + case SEARCH_EQUAL_12: + what = (char *)"SEARCH_EQUAL_12"; + break; + case SEARCH_LOW_12: + what = (char *)"SEARCH_LOW_12"; + break; + case SEND_VOLUME_TAG: + what = (char *)"SEND_VOLUME_TAG"; + break; + case READ_ELEMENT_STATUS: + what = (char *)"READ_ELEMENT_STATUS"; + break; + case GPCMD_READ_CD_MSF: + what = (char *)"READ CD MSF"; + break; + case GPCMD_SCAN: + what = (char *)"SCAN"; + break; + case GPCMD_SET_SPEED: + what = (char *)"SET CD SPEED"; + break; + case GPCMD_MECHANISM_STATUS: + what = (char *)"MECHANISM STATUS"; + break; + case GPCMD_READ_CD: + what = (char *)"READ CD"; + break; + case 0xE1: + what = (char *)"WRITE CONTINUE"; + break; + case WRITE_LONG_2: + what = (char *)"WRITE_LONG_2"; + break; + case VENDOR_CMND: + what = (char *)"Realtek's vendor command"; + break; + default: + what = (char *)"(unknown command)"; + unknown_cmd = 1; + break; + } + + if (srb->cmnd[0] != TEST_UNIT_READY) + RTS51X_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); + if (unknown_cmd) { + RTS51X_DEBUGP(""); + for (i = 0; i < srb->cmd_len && i < 16; i++) + RTS51X_DEBUGPN(" %02x", srb->cmnd[i]); + RTS51X_DEBUGPN("\n"); + } +} + +void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type) +{ + switch (sense_type) { + case SENSE_TYPE_MEDIA_CHANGE: + set_sense_data(chip, lun, CUR_ERR, 0x06, 0, 0x28, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_NOT_PRESENT: + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x3A, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_LBA_OVER_RANGE: + set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x21, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT: + set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x25, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_WRITE_PROTECT: + set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x27, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR: + set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x11, 0, 0, 0); + break; + + case SENSE_TYPE_MEDIA_WRITE_ERR: + set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x0C, 0x02, 0, 0); + break; + + case SENSE_TYPE_MEDIA_INVALID_CMD_FIELD: + set_sense_data(chip, lun, CUR_ERR, ILGAL_REQ, 0, + ASC_INVLD_CDB, ASCQ_INVLD_CDB, CDB_ILLEGAL, 1); + break; + + case SENSE_TYPE_FORMAT_IN_PROGRESS: + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, 0); + break; + + case SENSE_TYPE_FORMAT_CMD_FAILED: + set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x31, 0x01, 0, 0); + break; + +#ifdef SUPPORT_MAGIC_GATE + case SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB: + set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x6F, 0x02, 0, 0); + break; + + case SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN: + set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x6F, 0x00, 0, 0); + break; + + case SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM: + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x30, 0x00, 0, 0); + break; + + case SENSE_TYPE_MG_WRITE_ERR: + set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x0C, 0x00, 0, 0); + break; +#endif + +#ifdef SUPPORT_SD_LOCK + case SENSE_TYPE_MEDIA_READ_FORBIDDEN: + set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x11, 0x13, 0, 0); + break; +#endif + + case SENSE_TYPE_NO_SENSE: + default: + set_sense_data(chip, lun, CUR_ERR, 0, 0, 0, 0, 0, 0); + break; + } +} + +void set_sense_data(struct rts51x_chip *chip, unsigned int lun, u8 err_code, + u8 sense_key, u32 info, u8 asc, u8 ascq, u8 sns_key_info0, + u16 sns_key_info1) +{ + struct sense_data_t *sense = &(chip->sense_buffer[lun]); + + sense->err_code = err_code; + sense->sense_key = sense_key; + sense->info[0] = (u8) (info >> 24); + sense->info[1] = (u8) (info >> 16); + sense->info[2] = (u8) (info >> 8); + sense->info[3] = (u8) info; + + sense->ad_sense_len = sizeof(struct sense_data_t) - 8; + sense->asc = asc; + sense->ascq = ascq; + if (sns_key_info0 != 0) { + sense->sns_key_info[0] = SKSV | sns_key_info0; + sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 8; + sense->sns_key_info[2] = sns_key_info1 & 0x0f; + } +} + +static int test_unit_ready(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + + rts51x_init_cards(chip); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + return TRANSPORT_FAILED; + } + + if (!check_lun_mc(chip, lun)) { + set_lun_mc(chip, lun); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + return TRANSPORT_FAILED; + } +#ifdef SUPPORT_SD_LOCK + if (get_lun_card(chip, SCSI_LUN(srb)) == SD_CARD) { + struct sd_info *sd_card = &(chip->sd_card); + if (sd_card->sd_lock_notify) { + sd_card->sd_lock_notify = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + return TRANSPORT_FAILED; + } else if (sd_card->sd_lock_status & SD_LOCKED) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_READ_FORBIDDEN); + return TRANSPORT_FAILED; + } + } +#endif + + return TRANSPORT_GOOD; +} + +unsigned char formatter_inquiry_str[20] = { + 'M', 'E', 'M', 'O', 'R', 'Y', 'S', 'T', 'I', 'C', 'K', + '-', 'M', 'G', /* Byte[47:49] */ + 0x0B, /* Byte[50]: MG, MS, MSPro, MSXC */ + 0x00, /* Byte[51]: Category Specific Commands */ + 0x00, /* Byte[52]: Access Control and feature */ + 0x20, 0x20, 0x20, /* Byte[53:55] */ +}; + +static int inquiry(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + char *inquiry_default = (char *)"Generic-xD/SD/M.S. 1.00 "; + char *inquiry_string; + unsigned char sendbytes; + unsigned char *buf; + u8 card = get_lun_card(chip, lun); + int pro_formatter_flag = 0; + unsigned char inquiry_buf[] = { + QULIFIRE | DRCT_ACCESS_DEV, + RMB_DISC | 0x0D, + 0x00, + 0x01, + 0x1f, + 0x02, + 0, + REL_ADR | WBUS_32 | WBUS_16 | SYNC | LINKED | CMD_QUE | SFT_RE, + }; + + inquiry_string = inquiry_default; + + buf = vmalloc(scsi_bufflen(srb)); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + if (MS_FORMATTER_ENABLED(chip) && (get_lun2card(chip, lun) & MS_CARD)) { + if (!card || (card == MS_CARD)) + pro_formatter_flag = 1; + } + + if (pro_formatter_flag) { + if (scsi_bufflen(srb) < 56) + sendbytes = (unsigned char)(scsi_bufflen(srb)); + else + sendbytes = 56; + } else { + if (scsi_bufflen(srb) < 36) + sendbytes = (unsigned char)(scsi_bufflen(srb)); + else + sendbytes = 36; + } + + if (sendbytes > 8) { + memcpy(buf, inquiry_buf, 8); + memcpy(buf + 8, inquiry_string, sendbytes - 8); + if (pro_formatter_flag) + buf[4] = 0x33; /* Additional Length */ + } else { + memcpy(buf, inquiry_buf, sendbytes); + } + + if (pro_formatter_flag) { + if (sendbytes > 36) + memcpy(buf + 36, formatter_inquiry_str, sendbytes - 36); + } + + scsi_set_resid(srb, 0); + + rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); + vfree(buf); + + return TRANSPORT_GOOD; +} + +static int start_stop_unit(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + + scsi_set_resid(srb, scsi_bufflen(srb)); + + if (srb->cmnd[1] == 1) + return TRANSPORT_GOOD; + + switch (srb->cmnd[0x4]) { + case STOP_MEDIUM: + /* Media disabled */ + return TRANSPORT_GOOD; + + case UNLOAD_MEDIUM: + /* Media shall be unload */ + if (check_card_ready(chip, lun)) + eject_card(chip, lun); + return TRANSPORT_GOOD; + + case MAKE_MEDIUM_READY: + case LOAD_MEDIUM: + if (check_card_ready(chip, lun)) { + return TRANSPORT_GOOD; + } else { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + break; + } + + TRACE_RET(chip, TRANSPORT_ERROR); +} + +static int allow_medium_removal(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int prevent; + + prevent = srb->cmnd[4] & 0x1; + + scsi_set_resid(srb, 0); + + if (prevent) { + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + return TRANSPORT_GOOD; +} + +static void ms_mode_sense(struct rts51x_chip *chip, u8 cmd, + int lun, u8 *buf, int buf_len) +{ + struct ms_info *ms_card = &(chip->ms_card); + int sys_info_offset; + int data_size = buf_len; + int support_format = 0; + int i = 0; + + if (cmd == MODE_SENSE) { + sys_info_offset = 8; + if (data_size > 0x68) + data_size = 0x68; + buf[i++] = 0x67; /* Mode Data Length */ + } else { + sys_info_offset = 12; + if (data_size > 0x6C) + data_size = 0x6C; + buf[i++] = 0x00; /* Mode Data Length (MSB) */ + buf[i++] = 0x6A; /* Mode Data Length (LSB) */ + } + + /* Medium Type Code */ + if (check_card_ready(chip, lun)) { + if (CHK_MSXC(ms_card)) { + support_format = 1; + buf[i++] = 0x40; + } else if (CHK_MSPRO(ms_card)) { + support_format = 1; + buf[i++] = 0x20; + } else { + buf[i++] = 0x10; + } + + /* WP */ + if (check_card_wp(chip, lun)) + buf[i++] = 0x80; + else + buf[i++] = 0x00; + } else { + buf[i++] = 0x00; /* MediaType */ + buf[i++] = 0x00; /* WP */ + } + + buf[i++] = 0x00; /* Reserved */ + + if (cmd == MODE_SENSE_10) { + buf[i++] = 0x00; /* Reserved */ + buf[i++] = 0x00; /* Block descriptor length(MSB) */ + buf[i++] = 0x00; /* Block descriptor length(LSB) */ + + /* The Following Data is the content of "Page 0x20" */ + if (data_size >= 9) + buf[i++] = 0x20; /* Page Code */ + if (data_size >= 10) + buf[i++] = 0x62; /* Page Length */ + if (data_size >= 11) + buf[i++] = 0x00; /* No Access Control */ + if (data_size >= 12) { + if (support_format) + buf[i++] = 0xC0; /* SF, SGM */ + else + buf[i++] = 0x00; + } + } else { + /* The Following Data is the content of "Page 0x20" */ + if (data_size >= 5) + buf[i++] = 0x20; /* Page Code */ + if (data_size >= 6) + buf[i++] = 0x62; /* Page Length */ + if (data_size >= 7) + buf[i++] = 0x00; /* No Access Control */ + if (data_size >= 8) { + if (support_format) + buf[i++] = 0xC0; /* SF, SGM */ + else + buf[i++] = 0x00; + } + } + + if (data_size > sys_info_offset) { + /* 96 Bytes Attribute Data */ + int len = data_size - sys_info_offset; + len = (len < 96) ? len : 96; + + memcpy(buf + sys_info_offset, ms_card->raw_sys_info, len); + } +} + +static int mode_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + unsigned int dataSize; + int status; + int pro_formatter_flag; + unsigned char pageCode, *buf; + u8 card = get_lun_card(chip, lun); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + scsi_set_resid(srb, scsi_bufflen(srb)); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + pro_formatter_flag = 0; + dataSize = 8; + /* In Combo mode, device responses ModeSense command as a MS LUN + * when no card is inserted */ + if ((get_lun2card(chip, lun) & MS_CARD)) { + if (!card || (card == MS_CARD)) { + dataSize = 108; + if (chip->option.mspro_formatter_enable) + pro_formatter_flag = 1; + } + } + + buf = kmalloc(dataSize, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + pageCode = srb->cmnd[2] & 0x3f; + + if ((pageCode == 0x3F) || (pageCode == 0x1C) || + (pageCode == 0x00) || (pro_formatter_flag && (pageCode == 0x20))) { + if (srb->cmnd[0] == MODE_SENSE) { + if ((pageCode == 0x3F) || (pageCode == 0x20)) { + ms_mode_sense(chip, srb->cmnd[0], lun, buf, + dataSize); + } else { + dataSize = 4; + buf[0] = 0x03; + buf[1] = 0x00; + if (check_card_wp(chip, lun)) + buf[2] = 0x80; + else + buf[3] = 0x00; + } + } else { + if ((pageCode == 0x3F) || (pageCode == 0x20)) { + ms_mode_sense(chip, srb->cmnd[0], lun, buf, + dataSize); + } else { + dataSize = 8; + buf[0] = 0x00; + buf[1] = 0x06; + buf[2] = 0x00; + if (check_card_wp(chip, lun)) + buf[3] = 0x80; + else + buf[3] = 0x00; + buf[4] = 0x00; + buf[5] = 0x00; + buf[6] = 0x00; + buf[7] = 0x00; + } + } + status = TRANSPORT_GOOD; + } else { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + scsi_set_resid(srb, scsi_bufflen(srb)); + status = TRANSPORT_FAILED; + } + + if (status == TRANSPORT_GOOD) { + unsigned int len = min(scsi_bufflen(srb), dataSize); + rts51x_set_xfer_buf(buf, len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - len); + } + kfree(buf); + + return status; +} + +static int request_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sense_data_t *sense; + unsigned int lun = SCSI_LUN(srb); + struct ms_info *ms_card = &(chip->ms_card); + unsigned char *tmp, *buf; + + sense = &(chip->sense_buffer[lun]); + + if ((get_lun_card(chip, lun) == MS_CARD) + && PRO_UNDER_FORMATTING(ms_card)) { + mspro_format_sense(chip, lun); + } + + buf = vmalloc(scsi_bufflen(srb)); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + tmp = (unsigned char *)sense; + memcpy(buf, tmp, scsi_bufflen(srb)); + + rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); + vfree(buf); + + scsi_set_resid(srb, 0); + /* Reset Sense Data */ + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + return TRANSPORT_GOOD; +} + +static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ +#ifdef SUPPORT_SD_LOCK + struct sd_info *sd_card = &(chip->sd_card); +#endif + unsigned int lun = SCSI_LUN(srb); + int retval; + u32 start_sec; + u16 sec_cnt; + + if (!check_card_ready(chip, lun) || (chip->capacity[lun] == 0)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (!check_lun_mc(chip, lun)) { + set_lun_mc(chip, lun); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + return TRANSPORT_FAILED; + } + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_erase_status) { + /* Accessing to any card is forbidden + * until the erase procedure of SD is completed */ + RTS51X_DEBUGP("SD card being erased!\n"); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (get_lun_card(chip, lun) == SD_CARD) { + if (sd_card->sd_lock_status & SD_LOCKED) { + RTS51X_DEBUGP("SD card locked!\n"); + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_READ_FORBIDDEN); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } +#endif + + if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) { + start_sec = + ((u32) srb->cmnd[2] << 24) | + ((u32) srb->cmnd[3] << 16) | + ((u32) srb->cmnd[4] << 8) | + ((u32) srb->cmnd[5]); + sec_cnt = ((u16) (srb->cmnd[7]) << 8) | srb->cmnd[8]; + } else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6)) { + start_sec = ((u32) (srb->cmnd[1] & 0x1F) << 16) | + ((u32) srb->cmnd[2] << 8) | ((u32) srb->cmnd[3]); + sec_cnt = srb->cmnd[4]; + } else if ((srb->cmnd[0] == VENDOR_CMND) && + (srb->cmnd[1] == SCSI_APP_CMD) && + ((srb->cmnd[2] == PP_READ10) || + (srb->cmnd[2] == PP_WRITE10))) { + start_sec = ((u32) srb->cmnd[4] << 24) | + ((u32) srb->cmnd[5] << 16) | + ((u32) srb->cmnd[6] << 8) | + ((u32) srb->cmnd[7]); + sec_cnt = ((u16) (srb->cmnd[9]) << 8) | srb->cmnd[10]; + } else { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if ((start_sec > chip->capacity[lun]) || + ((start_sec + sec_cnt) > chip->capacity[lun])) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LBA_OVER_RANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (sec_cnt == 0) { + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; + } + + if ((srb->sc_data_direction == DMA_TO_DEVICE) + && check_card_wp(chip, lun)) { + RTS51X_DEBUGP("Write protected card!\n"); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + retval = card_rw(srb, chip, start_sec, sec_cnt); + if (retval != STATUS_SUCCESS) { +#if 0 + if (chip->need_release & chip->lun2card[lun]) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + } else { +#endif + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + } else { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); + } +#if 0 + } +#endif + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + + return TRANSPORT_GOOD; +} + +static int read_format_capacity(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned char *buf; + unsigned int lun = SCSI_LUN(srb); + unsigned int buf_len; + u8 card = get_lun_card(chip, lun); + int desc_cnt; + int i = 0; + + if (!check_card_ready(chip, lun)) { + if (!chip->option.mspro_formatter_enable) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12; + + buf = kmalloc(buf_len, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + buf[i++] = 0; + buf[i++] = 0; + buf[i++] = 0; + + /* Capacity List Length */ + if ((buf_len > 12) && chip->option.mspro_formatter_enable && + (chip->lun2card[lun] & MS_CARD) && (!card || (card == MS_CARD))) { + buf[i++] = 0x10; + desc_cnt = 2; + } else { + buf[i++] = 0x08; + desc_cnt = 1; + } + + while (desc_cnt) { + if (check_card_ready(chip, lun)) { + buf[i++] = (unsigned char)((chip->capacity[lun]) >> 24); + buf[i++] = (unsigned char)((chip->capacity[lun]) >> 16); + buf[i++] = (unsigned char)((chip->capacity[lun]) >> 8); + buf[i++] = (unsigned char)(chip->capacity[lun]); + + if (desc_cnt == 2) + /* Byte[8]: Descriptor Type: Formatted medium */ + buf[i++] = 2; + else + buf[i++] = 0; /* Byte[16] */ + } else { + buf[i++] = 0xFF; + buf[i++] = 0xFF; + buf[i++] = 0xFF; + buf[i++] = 0xFF; + + if (desc_cnt == 2) + /* Byte[8]: Descriptor Type: No medium */ + buf[i++] = 3; + else + buf[i++] = 0; /*Byte[16] */ + } + + buf[i++] = 0x00; + buf[i++] = 0x02; + buf[i++] = 0x00; + + desc_cnt--; + } + + buf_len = min(scsi_bufflen(srb), buf_len); + rts51x_set_xfer_buf(buf, buf_len, srb); + kfree(buf); + + scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); + + return TRANSPORT_GOOD; +} + +static int read_capacity(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned char *buf; + unsigned int lun = SCSI_LUN(srb); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (!check_lun_mc(chip, lun)) { + set_lun_mc(chip, lun); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + return TRANSPORT_FAILED; + } + + buf = kmalloc(8, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + buf[0] = (unsigned char)((chip->capacity[lun] - 1) >> 24); + buf[1] = (unsigned char)((chip->capacity[lun] - 1) >> 16); + buf[2] = (unsigned char)((chip->capacity[lun] - 1) >> 8); + buf[3] = (unsigned char)(chip->capacity[lun] - 1); + + buf[4] = 0x00; + buf[5] = 0x00; + buf[6] = 0x02; + buf[7] = 0x00; + + rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); + kfree(buf); + + scsi_set_resid(srb, 0); + + return TRANSPORT_GOOD; +} + +static int get_dev_status(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + unsigned int buf_len; + u8 status[32] = { 0 }; + + rts51x_pp_status(chip, lun, status, 32); + + buf_len = min(scsi_bufflen(srb), (unsigned int)sizeof(status)); + rts51x_set_xfer_buf(status, buf_len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); + + return TRANSPORT_GOOD; +} + +static int read_status(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + u8 rts51x_status[16]; + unsigned int buf_len; + unsigned int lun = SCSI_LUN(srb); + + rts51x_read_status(chip, lun, rts51x_status, 16); + + buf_len = min(scsi_bufflen(srb), (unsigned int)sizeof(rts51x_status)); + rts51x_set_xfer_buf(rts51x_status, buf_len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); + + return TRANSPORT_GOOD; +} + +static int read_mem(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + unsigned short addr, len, i; + int retval; + u8 *buf; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + addr = ((u16) srb->cmnd[2] << 8) | srb->cmnd[3]; + len = ((u16) srb->cmnd[4] << 8) | srb->cmnd[5]; + + if (addr < 0xe000) { + RTS51X_DEBUGP("filter!addr=0x%x\n", addr); + return TRANSPORT_GOOD; + } + + buf = vmalloc(len); + if (!buf) + TRACE_RET(chip, TRANSPORT_ERROR); + + for (i = 0; i < len; i++) { + retval = rts51x_ep0_read_register(chip, addr + i, buf + i); + if (retval != STATUS_SUCCESS) { + vfree(buf); + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + len = (unsigned short)min(scsi_bufflen(srb), (unsigned int)len); + rts51x_set_xfer_buf(buf, len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - len); + + vfree(buf); + + return TRANSPORT_GOOD; +} + +static int write_mem(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + unsigned short addr, len, i; + int retval; + u8 *buf; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + addr = ((u16) srb->cmnd[2] << 8) | srb->cmnd[3]; + len = ((u16) srb->cmnd[4] << 8) | srb->cmnd[5]; + + if (addr < 0xe000) { + RTS51X_DEBUGP("filter!addr=0x%x\n", addr); + return TRANSPORT_GOOD; + } + + len = (unsigned short)min(scsi_bufflen(srb), (unsigned int)len); + buf = vmalloc(len); + if (!buf) + TRACE_RET(chip, TRANSPORT_ERROR); + + rts51x_get_xfer_buf(buf, len, srb); + + for (i = 0; i < len; i++) { + retval = + rts51x_ep0_write_register(chip, addr + i, 0xFF, buf[i]); + if (retval != STATUS_SUCCESS) { + vfree(buf); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + vfree(buf); + scsi_set_resid(srb, scsi_bufflen(srb) - len); + + return TRANSPORT_GOOD; +} + +static int get_sd_csd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + unsigned int lun = SCSI_LUN(srb); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (get_lun_card(chip, lun) != SD_CARD) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + rts51x_set_xfer_buf(sd_card->raw_csd, scsi_bufflen(srb), srb); + + return TRANSPORT_GOOD; +} + +static int read_phy_register(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval; + u8 addr, len, i; + u8 *buf; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + addr = srb->cmnd[5]; + len = srb->cmnd[7]; + + if (len) { + buf = vmalloc(len); + if (!buf) + TRACE_RET(chip, TRANSPORT_ERROR); + + for (i = 0; i < len; i++) { + retval = + rts51x_read_phy_register(chip, addr + i, buf + i); + if (retval != STATUS_SUCCESS) { + vfree(buf); + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + len = min(scsi_bufflen(srb), (unsigned int)len); + rts51x_set_xfer_buf(buf, len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - len); + + vfree(buf); + } + + return TRANSPORT_GOOD; +} + +static int write_phy_register(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval; + u8 addr, len, i; + u8 *buf; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + addr = srb->cmnd[5]; + len = srb->cmnd[7]; + + if (len) { + len = min(scsi_bufflen(srb), (unsigned int)len); + + buf = vmalloc(len); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + rts51x_get_xfer_buf(buf, len, srb); + scsi_set_resid(srb, scsi_bufflen(srb) - len); + + for (i = 0; i < len; i++) { + retval = + rts51x_write_phy_register(chip, addr + i, buf[i]); + if (retval != STATUS_SUCCESS) { + vfree(buf); + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + vfree(buf); + } + + return TRANSPORT_GOOD; +} + +static int get_card_bus_width(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + u8 card, bus_width; + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + card = get_lun_card(chip, lun); + if ((card == SD_CARD) || (card == MS_CARD)) { + bus_width = chip->card_bus_width[lun]; + } else { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + rts51x_set_xfer_buf(&bus_width, scsi_bufflen(srb), srb); + + return TRANSPORT_GOOD; +} + +#ifdef _MSG_TRACE +static int trace_msg_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned char *buf = NULL; + u8 clear; + unsigned int buf_len; + + buf_len = + 4 + + ((2 + MSG_FUNC_LEN + MSG_FILE_LEN + TIME_VAL_LEN) * TRACE_ITEM_CNT); + + if ((scsi_bufflen(srb) < buf_len) || (scsi_sglist(srb) == NULL)) { + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + clear = srb->cmnd[2]; + + buf = vmalloc(scsi_bufflen(srb)); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + rts51x_trace_msg(chip, buf, clear); + + rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); + vfree(buf); + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} +#endif + +static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval = STATUS_SUCCESS; + unsigned int lun = SCSI_LUN(srb); + u8 cmd_type, mask, value, idx, mode, len; + u16 addr; + u32 timeout; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + switch (srb->cmnd[3]) { + case INIT_BATCHCMD: + rts51x_init_cmd(chip); + break; + + case ADD_BATCHCMD: + cmd_type = srb->cmnd[4]; + if (cmd_type > 2) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + addr = (srb->cmnd[5] << 8) | srb->cmnd[6]; + mask = srb->cmnd[7]; + value = srb->cmnd[8]; + rts51x_add_cmd(chip, cmd_type, addr, mask, value); + break; + + case SEND_BATCHCMD: + mode = srb->cmnd[4]; + len = srb->cmnd[5]; + timeout = + ((u32) srb->cmnd[6] << 24) | ((u32) srb-> + cmnd[7] << 16) | ((u32) srb-> + cmnd[8] << + 8) | ((u32) + srb-> + cmnd + [9]); + retval = rts51x_send_cmd(chip, mode, 1000); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if (mode & STAGE_R) { + retval = rts51x_get_rsp(chip, len, timeout); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + break; + + case GET_BATCHRSP: + idx = srb->cmnd[4]; + value = chip->rsp_buf[idx]; + if (scsi_bufflen(srb) < 1) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + rts51x_set_xfer_buf(&value, 1, srb); + scsi_set_resid(srb, 0); + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + return TRANSPORT_GOOD; +} + +static int suit_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int result; + + switch (srb->cmnd[3]) { + case INIT_BATCHCMD: + case ADD_BATCHCMD: + case SEND_BATCHCMD: + case GET_BATCHRSP: + result = rw_mem_cmd_buf(srb, chip); + break; + default: + result = TRANSPORT_ERROR; + } + + return result; +} + +static int app_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int result; + + switch (srb->cmnd[2]) { + case PP_READ10: + case PP_WRITE10: + result = read_write(srb, chip); + break; + + case SUIT_CMD: + result = suit_cmd(srb, chip); + break; + + case READ_PHY: + result = read_phy_register(srb, chip); + break; + + case WRITE_PHY: + result = write_phy_register(srb, chip); + break; + + case GET_DEV_STATUS: + result = get_dev_status(srb, chip); + break; + + default: + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + return result; +} + +static int vendor_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int result = TRANSPORT_GOOD; + + switch (srb->cmnd[1]) { + case READ_STATUS: + result = read_status(srb, chip); + break; + + case READ_MEM: + result = read_mem(srb, chip); + break; + + case WRITE_MEM: + result = write_mem(srb, chip); + break; + + case GET_BUS_WIDTH: + result = get_card_bus_width(srb, chip); + break; + + case GET_SD_CSD: + result = get_sd_csd(srb, chip); + break; + +#ifdef _MSG_TRACE + case TRACE_MSG: + result = trace_msg_cmd(srb, chip); + break; +#endif + + case SCSI_APP_CMD: + result = app_cmd(srb, chip); + break; + + default: + set_sense_type(chip, SCSI_LUN(srb), + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + return result; +} + +static int ms_format_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + int retval, quick_format; + + if (get_lun_card(chip, lun) != MS_CARD) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if ((srb->cmnd[3] != 0x4D) || (srb->cmnd[4] != 0x47) + || (srb->cmnd[5] != 0x66) || (srb->cmnd[6] != 0x6D) + || (srb->cmnd[7] != 0x74)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (srb->cmnd[8] & 0x01) + quick_format = 0; + else + quick_format = 1; + + if (!(chip->card_ready & MS_CARD)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (chip->card_wp & MS_CARD) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (!CHK_MSPRO(ms_card)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + retval = mspro_format(srb, chip, MS_SHORT_DATA_LEN, quick_format); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} + +#ifdef SUPPORT_PCGL_1P18 +int get_ms_information(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + u8 dev_info_id, data_len; + u8 *buf; + unsigned int buf_len; + int i; + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if ((get_lun_card(chip, lun) != MS_CARD)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if ((srb->cmnd[2] != 0xB0) || (srb->cmnd[4] != 0x4D) || + (srb->cmnd[5] != 0x53) || (srb->cmnd[6] != 0x49) || + (srb->cmnd[7] != 0x44)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + dev_info_id = srb->cmnd[3]; + if ((CHK_MSXC(ms_card) && (dev_info_id == 0x10)) || + (!CHK_MSXC(ms_card) && (dev_info_id == 0x13)) || + !CHK_MSPRO(ms_card)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (dev_info_id == 0x15) + buf_len = data_len = 0x3A; + else + buf_len = data_len = 0x6A; + + buf = kmalloc(buf_len, GFP_KERNEL); + if (!buf) + TRACE_RET(chip, TRANSPORT_ERROR); + + i = 0; + /* GET Memory Stick Media Information Response Header */ + buf[i++] = 0x00; /* Data length MSB */ + buf[i++] = data_len; /* Data length LSB */ + /* Device Information Type Code */ + if (CHK_MSXC(ms_card)) + buf[i++] = 0x03; + else + buf[i++] = 0x02; + /* SGM bit */ + buf[i++] = 0x01; + /* Reserved */ + buf[i++] = 0x00; + buf[i++] = 0x00; + buf[i++] = 0x00; + /* Number of Device Information */ + buf[i++] = 0x01; + + /* Device Information Body + * Device Information ID Number */ + buf[i++] = dev_info_id; + /* Device Information Length */ + if (dev_info_id == 0x15) + data_len = 0x31; + else + data_len = 0x61; + buf[i++] = 0x00; /* Data length MSB */ + buf[i++] = data_len; /* Data length LSB */ + /* Valid Bit */ + buf[i++] = 0x80; + if ((dev_info_id == 0x10) || (dev_info_id == 0x13)) { + /* System Information */ + memcpy(buf + i, ms_card->raw_sys_info, 96); + } else { + /* Model Name */ + memcpy(buf + i, ms_card->raw_model_name, 48); + } + + rts51x_set_xfer_buf(buf, buf_len, srb); + + if (dev_info_id == 0x15) + scsi_set_resid(srb, scsi_bufflen(srb) - 0x3C); + else + scsi_set_resid(srb, scsi_bufflen(srb) - 0x6C); + + kfree(buf); + return STATUS_SUCCESS; +} +#endif + +static int ms_sp_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int retval = TRANSPORT_ERROR; + + if (srb->cmnd[2] == MS_FORMAT) + retval = ms_format_cmnd(srb, chip); +#ifdef SUPPORT_PCGL_1P18 + else if (srb->cmnd[2] == GET_MS_INFORMATION) + retval = get_ms_information(srb, chip); +#endif + + return retval; +} + +#ifdef SUPPORT_CPRM +static int sd_extention_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + unsigned int lun = SCSI_LUN(srb); + int result; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + sd_cleanup_work(chip); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if ((get_lun_card(chip, lun) != SD_CARD)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + switch (srb->cmnd[0]) { + case SD_PASS_THRU_MODE: + result = sd_pass_thru_mode(srb, chip); + break; + + case SD_EXECUTE_NO_DATA: + result = sd_execute_no_data(srb, chip); + break; + + case SD_EXECUTE_READ: + result = sd_execute_read_data(srb, chip); + break; + + case SD_EXECUTE_WRITE: + result = sd_execute_write_data(srb, chip); + break; + + case SD_GET_RSP: + result = sd_get_cmd_rsp(srb, chip); + break; + + case SD_HW_RST: + result = sd_hw_rst(srb, chip); + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + return result; +} +#endif + +#ifdef SUPPORT_MAGIC_GATE +int mg_report_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + int retval; + u8 key_format; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + ms_cleanup_work(chip); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if ((get_lun_card(chip, lun) != MS_CARD)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (srb->cmnd[7] != KC_MG_R_PRO) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (!CHK_MSPRO(ms_card)) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + key_format = srb->cmnd[10] & 0x3F; + + switch (key_format) { + case KF_GET_LOC_EKB: + if ((scsi_bufflen(srb) == 0x41C) && + (srb->cmnd[8] == 0x04) && (srb->cmnd[9] == 0x1C)) { + retval = mg_get_local_EKB(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + case KF_RSP_CHG: + if ((scsi_bufflen(srb) == 0x24) && + (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x24)) { + retval = mg_get_rsp_chg(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + case KF_GET_ICV: + ms_card->mg_entry_num = srb->cmnd[5]; + if ((scsi_bufflen(srb) == 0x404) && + (srb->cmnd[8] == 0x04) && + (srb->cmnd[9] == 0x04) && + (srb->cmnd[2] == 0x00) && + (srb->cmnd[3] == 0x00) && + (srb->cmnd[4] == 0x00) && (srb->cmnd[5] < 32)) { + retval = mg_get_ICV(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} + +int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + int retval; + u8 key_format; + + rts51x_prepare_run(chip); + RTS51X_SET_STAT(chip, STAT_RUN); + + ms_cleanup_work(chip); + + if (!check_card_ready(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if (check_card_wp(chip, lun)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + if ((get_lun_card(chip, lun) != MS_CARD)) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (srb->cmnd[7] != KC_MG_R_PRO) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (!CHK_MSPRO(ms_card)) { + set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + key_format = srb->cmnd[10] & 0x3F; + + switch (key_format) { + case KF_SET_LEAF_ID: + if ((scsi_bufflen(srb) == 0x0C) && + (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { + retval = mg_set_leaf_id(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + case KF_CHG_HOST: + if ((scsi_bufflen(srb) == 0x0C) && + (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { + retval = mg_chg(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + case KF_RSP_HOST: + if ((scsi_bufflen(srb) == 0x0C) && + (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { + retval = mg_rsp(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + case KF_SET_ICV: + ms_card->mg_entry_num = srb->cmnd[5]; + if ((scsi_bufflen(srb) == 0x404) && + (srb->cmnd[8] == 0x04) && + (srb->cmnd[9] == 0x04) && + (srb->cmnd[2] == 0x00) && + (srb->cmnd[3] == 0x00) && + (srb->cmnd[4] == 0x00) && (srb->cmnd[5] < 32)) { + retval = mg_set_ICV(srb, chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} +#endif + +int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ +#ifdef SUPPORT_SD_LOCK + struct sd_info *sd_card = &(chip->sd_card); +#endif + struct ms_info *ms_card = &(chip->ms_card); + unsigned int lun = SCSI_LUN(srb); + int result = TRANSPORT_GOOD; + +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_erase_status) { + /* Block all SCSI command except for REQUEST_SENSE + * and rs_ppstatus */ + if (! + ((srb->cmnd[0] == VENDOR_CMND) + && (srb->cmnd[1] == SCSI_APP_CMD) + && (srb->cmnd[2] == GET_DEV_STATUS)) + && (srb->cmnd[0] != REQUEST_SENSE)) { + /* Logical Unit Not Ready Format in Progress */ + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, + 0, 0); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } +#endif + + if ((get_lun_card(chip, lun) == MS_CARD) && + (ms_card->format_status == FORMAT_IN_PROGRESS)) { + if ((srb->cmnd[0] != REQUEST_SENSE) + && (srb->cmnd[0] != INQUIRY)) { + /* Logical Unit Not Ready Format in Progress */ + set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, + 0, (u16) (ms_card->progress)); + TRACE_RET(chip, TRANSPORT_FAILED); + } + } + + switch (srb->cmnd[0]) { + case READ_10: + case WRITE_10: + case READ_6: + case WRITE_6: + result = read_write(srb, chip); + break; + + case TEST_UNIT_READY: + result = test_unit_ready(srb, chip); + break; + + case INQUIRY: + result = inquiry(srb, chip); + break; + + case READ_CAPACITY: + result = read_capacity(srb, chip); + break; + + case START_STOP: + result = start_stop_unit(srb, chip); + break; + + case ALLOW_MEDIUM_REMOVAL: + result = allow_medium_removal(srb, chip); + break; + + case REQUEST_SENSE: + result = request_sense(srb, chip); + break; + + case MODE_SENSE: + case MODE_SENSE_10: + result = mode_sense(srb, chip); + break; + + case 0x23: + result = read_format_capacity(srb, chip); + break; + + case VENDOR_CMND: + result = vendor_cmnd(srb, chip); + break; + + case MS_SP_CMND: + result = ms_sp_cmnd(srb, chip); + break; + +#ifdef SUPPORT_CPRM + case SD_PASS_THRU_MODE: + case SD_EXECUTE_NO_DATA: + case SD_EXECUTE_READ: + case SD_EXECUTE_WRITE: + case SD_GET_RSP: + case SD_HW_RST: + result = sd_extention_cmnd(srb, chip); + break; +#endif + +#ifdef SUPPORT_MAGIC_GATE + case CMD_MSPRO_MG_RKEY: + result = mg_report_key(srb, chip); + break; + + case CMD_MSPRO_MG_SKEY: + result = mg_send_key(srb, chip); + break; +#endif + + case FORMAT_UNIT: + case MODE_SELECT: + case VERIFY: + result = TRANSPORT_GOOD; + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + result = TRANSPORT_FAILED; + } + + return result; +} + +/*********************************************************************** + * Host functions + ***********************************************************************/ + +const char *host_info(struct Scsi_Host *host) +{ + return "SCSI emulation for RTS51xx USB driver-based card reader"; +} + +int slave_alloc(struct scsi_device *sdev) +{ + /* + * Set the INQUIRY transfer length to 36. We don't use any of + * the extra data and many devices choke if asked for more or + * less than 36 bytes. + */ + sdev->inquiry_len = 36; + return 0; +} + +int slave_configure(struct scsi_device *sdev) +{ + /* Scatter-gather buffers (all but the last) must have a length + * divisible by the bulk maxpacket size. Otherwise a data packet + * would end up being short, causing a premature end to the data + * transfer. Since high-speed bulk pipes have a maxpacket size + * of 512, we'll use that as the scsi device queue's DMA alignment + * mask. Guaranteeing proper alignment of the first buffer will + * have the desired effect because, except at the beginning and + * the end, scatter-gather buffers follow page boundaries. */ + blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); + + /* Set the SCSI level to at least 2. We'll leave it at 3 if that's + * what is originally reported. We need this to avoid confusing + * the SCSI layer with devices that report 0 or 1, but need 10-byte + * commands (ala ATAPI devices behind certain bridges, or devices + * which simply have broken INQUIRY data). + * + * NOTE: This means /dev/sg programs (ala cdrecord) will get the + * actual information. This seems to be the preference for + * programs like that. + * + * NOTE: This also means that /proc/scsi/scsi and sysfs may report + * the actual value or the modified one, depending on where the + * data comes from. + */ + if (sdev->scsi_level < SCSI_2) + sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2; + + return 0; +} + +/*********************************************************************** + * /proc/scsi/ functions + ***********************************************************************/ + +/* we use this macro to help us write into the buffer */ +#undef SPRINTF +#define SPRINTF(args...) \ + do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0) + +int proc_info(struct Scsi_Host *host, char *buffer, + char **start, off_t offset, int length, int inout) +{ + char *pos = buffer; + + /* if someone is sending us data, just throw it away */ + if (inout) + return length; + + /* print the controller name */ + SPRINTF(" Host scsi%d: %s\n", host->host_no, RTS51X_NAME); + + /* print product, vendor, and driver version strings */ + SPRINTF(" Vendor: Realtek Corp.\n"); + SPRINTF(" Product: RTS51xx USB Card Reader\n"); + SPRINTF(" Version: %s\n", DRIVER_VERSION); + SPRINTF(" Build: %s\n", __TIME__); + + /* + * Calculate start of next buffer, and return value. + */ + *start = buffer + offset; + + if ((pos - buffer) < offset) + return 0; + else if ((pos - buffer - offset) < length) + return pos - buffer - offset; + else + return length; +} + +/* queue a command */ +/* This is always called with scsi_lock(host) held */ +int queuecommand_lck(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *)) +{ + struct rts51x_chip *chip = host_to_rts51x(srb->device->host); + + /* check for state-transition errors */ + if (chip->srb != NULL) { + RTS51X_DEBUGP("Error in %s: chip->srb = %p\n", + __func__, chip->srb); + return SCSI_MLQUEUE_HOST_BUSY; + } + + /* fail the command if we are disconnecting */ + if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { + RTS51X_DEBUGP("Fail command during disconnect\n"); + srb->result = DID_NO_CONNECT << 16; + done(srb); + return 0; + } + + /* enqueue the command and wake up the control thread */ + srb->scsi_done = done; + chip->srb = srb; + complete(&chip->usb->cmnd_ready); + + return 0; +} + +#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */ +int queuecommand(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *)) +{ + return queuecommand_lck(srb, done); +} +#else +DEF_SCSI_QCMD(queuecommand) +#endif +/*********************************************************************** + * Error handling functions + ***********************************************************************/ +/* Command timeout and abort */ +int command_abort(struct scsi_cmnd *srb) +{ + struct rts51x_chip *chip = host_to_rts51x(srb->device->host); + + RTS51X_DEBUGP("%s called\n", __func__); + + /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING + * bits are protected by the host lock. */ + scsi_lock(rts51x_to_host(chip)); + + /* Is this command still active? */ + if (chip->srb != srb) { + scsi_unlock(rts51x_to_host(chip)); + RTS51X_DEBUGP("-- nothing to abort\n"); + return FAILED; + } + + /* Set the TIMED_OUT bit. Also set the ABORTING bit, but only if + * a device reset isn't already in progress (to avoid interfering + * with the reset). Note that we must retain the host lock while + * calling usb_stor_stop_transport(); otherwise it might interfere + * with an auto-reset that begins as soon as we release the lock. */ + set_bit(FLIDX_TIMED_OUT, &chip->usb->dflags); + if (!test_bit(FLIDX_RESETTING, &chip->usb->dflags)) { + set_bit(FLIDX_ABORTING, &chip->usb->dflags); + /* rts51x_stop_transport(us); */ + } + scsi_unlock(rts51x_to_host(chip)); + + /* Wait for the aborted command to finish */ + wait_for_completion(&chip->usb->notify); + return SUCCESS; +} + +/* This invokes the transport reset mechanism to reset the state of the + * device */ +int device_reset(struct scsi_cmnd *srb) +{ + int result = 0; + + RTS51X_DEBUGP("%s called\n", __func__); + + return result < 0 ? FAILED : SUCCESS; +} + +/* Simulate a SCSI bus reset by resetting the device's USB port. */ +int bus_reset(struct scsi_cmnd *srb) +{ + int result = 0; + + RTS51X_DEBUGP("%s called\n", __func__); + + return result < 0 ? FAILED : SUCCESS; +} + +static const char *rts5139_info(struct Scsi_Host *host) +{ + return "SCSI emulation for RTS5139 USB card reader"; +} + +struct scsi_host_template rts51x_host_template = { + /* basic userland interface stuff */ + .name = RTS51X_NAME, + .proc_name = RTS51X_NAME, + .proc_info = proc_info, + .info = rts5139_info, + + /* command interface -- queued only */ + .queuecommand = queuecommand, + + /* error and abort handlers */ + .eh_abort_handler = command_abort, + .eh_device_reset_handler = device_reset, + .eh_bus_reset_handler = bus_reset, + + /* queue commands only, only one command per LUN */ + .can_queue = 1, + .cmd_per_lun = 1, + + /* unknown initiator id */ + .this_id = -1, + + .slave_alloc = slave_alloc, + .slave_configure = slave_configure, + + /* lots of sg segments can be handled */ + .sg_tablesize = SG_ALL, + + /* limit the total size of a transfer to 120 KB */ + .max_sectors = 240, + + /* merge commands... this seems to help performance, but + * periodically someone should test to see which setting is more + * optimal. + */ + .use_clustering = 1, + + /* emulated HBA */ + .emulated = 1, + + /* we do our own delay after a device or bus reset */ + .skip_settle_delay = 1, + + /* sysfs device attributes */ + /* .sdev_attrs = sysfs_device_attr_list, */ + + /* module management */ + .module = THIS_MODULE +}; + diff --git a/drivers/staging/rts5139/rts51x_scsi.h b/drivers/staging/rts5139/rts51x_scsi.h new file mode 100644 index 00000000000..3a8ca069b27 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_scsi.h @@ -0,0 +1,162 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_SCSI_H +#define __RTS51X_SCSI_H + +#include +#include +#include +#include +#include +#include + +#include "rts51x_chip.h" + +#define MS_SP_CMND 0xFA +#define MS_FORMAT 0xA0 +#define GET_MS_INFORMATION 0xB0 + +#define VENDOR_CMND 0xF0 + +#define READ_STATUS 0x09 + +#define READ_MEM 0x0D +#define WRITE_MEM 0x0E +#define GET_BUS_WIDTH 0x13 +#define GET_SD_CSD 0x14 +#define TOGGLE_GPIO 0x15 +#define TRACE_MSG 0x18 + +#define SCSI_APP_CMD 0x10 + +#define PP_READ10 0x1A +#define PP_WRITE10 0x0A +#define READ_HOST_REG 0x1D +#define WRITE_HOST_REG 0x0D +#define SET_VAR 0x05 +#define GET_VAR 0x15 +#define DMA_READ 0x16 +#define DMA_WRITE 0x06 +#define GET_DEV_STATUS 0x10 +#define SET_CHIP_MODE 0x27 +#define SUIT_CMD 0xE0 +#define WRITE_PHY 0x07 +#define READ_PHY 0x17 + +#define INIT_BATCHCMD 0x41 +#define ADD_BATCHCMD 0x42 +#define SEND_BATCHCMD 0x43 +#define GET_BATCHRSP 0x44 + +#ifdef SUPPORT_CPRM +/* SD Pass Through Command Extention */ +#define SD_PASS_THRU_MODE 0xD0 +#define SD_EXECUTE_NO_DATA 0xD1 +#define SD_EXECUTE_READ 0xD2 +#define SD_EXECUTE_WRITE 0xD3 +#define SD_GET_RSP 0xD4 +#define SD_HW_RST 0xD6 +#endif + +#ifdef SUPPORT_MAGIC_GATE +#define CMD_MSPRO_MG_RKEY 0xA4 /* Report Key Command */ +#define CMD_MSPRO_MG_SKEY 0xA3 /* Send Key Command */ + +/* CBWCB field: key class */ +#define KC_MG_R_PRO 0xBE /* MG-R PRO */ + +/* CBWCB field: key format */ +#define KF_SET_LEAF_ID 0x31 /* Set Leaf ID */ +#define KF_GET_LOC_EKB 0x32 /* Get Local EKB */ +#define KF_CHG_HOST 0x33 /* Challenge (host) */ +#define KF_RSP_CHG 0x34 /* Response and Challenge (device) */ +#define KF_RSP_HOST 0x35 /* Response (host) */ +#define KF_GET_ICV 0x36 /* Get ICV */ +#define KF_SET_ICV 0x37 /* SSet ICV */ +#endif + +struct rts51x_chip; + +/*----------------------------------- + Start-Stop-Unit +-----------------------------------*/ +#define STOP_MEDIUM 0x00 /* access disable */ +#define MAKE_MEDIUM_READY 0x01 /* access enable */ +#define UNLOAD_MEDIUM 0x02 /* unload */ +#define LOAD_MEDIUM 0x03 /* load */ + +/*----------------------------------- + STANDARD_INQUIRY +-----------------------------------*/ +#define QULIFIRE 0x00 +#define AENC_FNC 0x00 +#define TRML_IOP 0x00 +#define REL_ADR 0x00 +#define WBUS_32 0x00 +#define WBUS_16 0x00 +#define SYNC 0x00 +#define LINKED 0x00 +#define CMD_QUE 0x00 +#define SFT_RE 0x00 + +#define VEN_ID_LEN 8 /* Vendor ID Length */ +#define PRDCT_ID_LEN 16 /* Product ID Length */ +#define PRDCT_REV_LEN 4 /* Product LOT Length */ + +#define DRCT_ACCESS_DEV 0x00 /* Direct Access Device */ +#define RMB_DISC 0x80 /* The Device is Removable */ +#define ANSI_SCSI2 0x02 /* Based on ANSI-SCSI2 */ + +#define SCSI 0x00 /* Interface ID */ + +void scsi_show_command(struct scsi_cmnd *srb); +void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type); +void set_sense_data(struct rts51x_chip *chip, unsigned int lun, u8 err_code, + u8 sense_key, u32 info, u8 asc, u8 ascq, u8 sns_key_info0, + u16 sns_key_info1); + +int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip); + +struct Scsi_Host; +struct scsi_device; +struct scsi_cmnd; + +const char *host_info(struct Scsi_Host *host); +int slave_alloc(struct scsi_device *sdev); +int slave_configure(struct scsi_device *sdev); +int proc_info(struct Scsi_Host *host, char *buffer, + char **start, off_t offset, int length, int inout); +#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */ +int queuecommand(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *)); +#else +int queuecommand(struct Scsi_Host *, struct scsi_cmnd *); +#endif +int command_abort(struct scsi_cmnd *srb); +int device_reset(struct scsi_cmnd *srb); +int bus_reset(struct scsi_cmnd *srb); + +#endif /* __RTS51X_SCSI_H */ diff --git a/drivers/staging/rts5139/rts51x_sys.h b/drivers/staging/rts5139/rts51x_sys.h new file mode 100644 index 00000000000..b09cd34a6c0 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_sys.h @@ -0,0 +1,54 @@ +/* Driver for Realtek USB RTS51xx card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_SYS_H +#define __RTS51X_SYS_H + +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_card.h" + +#define USING_POLLING_CYCLE_DELINK + +extern int rts51x_check_start_time(struct rts51x_chip *chip); +extern void rts51x_set_start_time(struct rts51x_chip *chip); +extern void rts51x_clear_start_time(struct rts51x_chip *chip); + +/* typedef dma_addr_t ULONG_PTR; */ + +static inline void rts51x_reset_detected_cards(struct rts51x_chip *chip) +{ +/* rts51x_reset_cards(chip); */ +} + +static inline void clear_first_install_mark(struct rts51x_chip *chip) +{ +} + +void rts51x_enter_ss(struct rts51x_chip *chip); +void rts51x_exit_ss(struct rts51x_chip *chip); + +#endif /* __RTS51X_SYS_H */ diff --git a/drivers/staging/rts5139/rts51x_transport.c b/drivers/staging/rts5139/rts51x_transport.c new file mode 100644 index 00000000000..e11467acc57 --- /dev/null +++ b/drivers/staging/rts5139/rts51x_transport.c @@ -0,0 +1,1000 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "debug.h" +#include "rts51x.h" +#include "rts51x_chip.h" +#include "rts51x_card.h" +#include "rts51x_scsi.h" +#include "rts51x_transport.h" +#include "trace.h" + +/*********************************************************************** + * Scatter-gather transfer buffer access routines + ***********************************************************************/ + +/* Copy a buffer of length buflen to/from the srb's transfer buffer. + * Update the **sgptr and *offset variables so that the next copy will + * pick up from where this one left off. + */ + +unsigned int rts51x_access_sglist(unsigned char *buffer, + unsigned int buflen, void *sglist, + void **sgptr, unsigned int *offset, + enum xfer_buf_dir dir) +{ + unsigned int cnt; + struct scatterlist *sg = (struct scatterlist *)*sgptr; + + /* We have to go through the list one entry + * at a time. Each s-g entry contains some number of pages, and + * each page has to be kmap()'ed separately. If the page is already + * in kernel-addressable memory then kmap() will return its address. + * If the page is not directly accessible -- such as a user buffer + * located in high memory -- then kmap() will map it to a temporary + * position in the kernel's virtual address space. + */ + + if (!sg) + sg = (struct scatterlist *)sglist; + + /* This loop handles a single s-g list entry, which may + * include multiple pages. Find the initial page structure + * and the starting offset within the page, and update + * the *offset and **sgptr values for the next loop. + */ + cnt = 0; + while (cnt < buflen && sg) { + struct page *page = sg_page(sg) + + ((sg->offset + *offset) >> PAGE_SHIFT); + unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE - 1); + unsigned int sglen = sg->length - *offset; + + if (sglen > buflen - cnt) { + + /* Transfer ends within this s-g entry */ + sglen = buflen - cnt; + *offset += sglen; + } else { + + /* Transfer continues to next s-g entry */ + *offset = 0; + sg = sg_next(sg); + } + + /* Transfer the data for all the pages in this + * s-g entry. For each page: call kmap(), do the + * transfer, and call kunmap() immediately after. */ + while (sglen > 0) { + unsigned int plen = min(sglen, (unsigned int) + PAGE_SIZE - poff); + unsigned char *ptr = kmap(page); + + if (dir == TO_XFER_BUF) + memcpy(ptr + poff, buffer + cnt, plen); + else + memcpy(buffer + cnt, ptr + poff, plen); + kunmap(page); + + /* Start at the beginning of the next page */ + poff = 0; + ++page; + cnt += plen; + sglen -= plen; + } + } + *sgptr = sg; + + /* Return the amount actually transferred */ + return cnt; +} + +unsigned int rts51x_access_xfer_buf(unsigned char *buffer, + unsigned int buflen, struct scsi_cmnd *srb, + struct scatterlist **sgptr, + unsigned int *offset, enum xfer_buf_dir dir) +{ + return rts51x_access_sglist(buffer, buflen, (void *)scsi_sglist(srb), + (void **)sgptr, offset, dir); +} + +/* Store the contents of buffer into srb's transfer buffer and set the + * SCSI residue. + */ +void rts51x_set_xfer_buf(unsigned char *buffer, + unsigned int buflen, struct scsi_cmnd *srb) +{ + unsigned int offset = 0; + struct scatterlist *sg = NULL; + + buflen = min(buflen, scsi_bufflen(srb)); + buflen = rts51x_access_xfer_buf(buffer, buflen, srb, &sg, &offset, + TO_XFER_BUF); + if (buflen < scsi_bufflen(srb)) + scsi_set_resid(srb, scsi_bufflen(srb) - buflen); +} + +void rts51x_get_xfer_buf(unsigned char *buffer, + unsigned int buflen, struct scsi_cmnd *srb) +{ + unsigned int offset = 0; + struct scatterlist *sg = NULL; + + buflen = min(buflen, scsi_bufflen(srb)); + buflen = rts51x_access_xfer_buf(buffer, buflen, srb, &sg, &offset, + FROM_XFER_BUF); + if (buflen < scsi_bufflen(srb)) + scsi_set_resid(srb, scsi_bufflen(srb) - buflen); +} + +/* This is the completion handler which will wake us up when an URB + * completes. + */ +static void urb_done_completion(struct urb *urb) +{ + struct completion *urb_done_ptr = urb->context; + + if (urb_done_ptr) + complete(urb_done_ptr); +} + +/* This is the common part of the URB message submission code + * + * All URBs from the driver involved in handling a queued scsi + * command _must_ pass through this function (or something like it) for the + * abort mechanisms to work properly. + */ +static int rts51x_msg_common(struct rts51x_chip *chip, struct urb *urb, + int timeout) +{ + struct rts51x_usb *rts51x = chip->usb; + struct completion urb_done; + long timeleft; + int status; + + /* don't submit URBs during abort processing */ + if (test_bit(FLIDX_ABORTING, &rts51x->dflags)) + TRACE_RET(chip, -EIO); + + /* set up data structures for the wakeup system */ + init_completion(&urb_done); + + /* fill the common fields in the URB */ + urb->context = &urb_done; + urb->actual_length = 0; + urb->error_count = 0; + urb->status = 0; + + /* we assume that if transfer_buffer isn't us->iobuf then it + * hasn't been mapped for DMA. Yes, this is clunky, but it's + * easier than always having the caller tell us whether the + * transfer buffer has already been mapped. */ + urb->transfer_flags = URB_NO_SETUP_DMA_MAP; + if (urb->transfer_buffer == rts51x->iobuf) { + urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + urb->transfer_dma = rts51x->iobuf_dma; + } + urb->setup_dma = rts51x->cr_dma; + + /* submit the URB */ + status = usb_submit_urb(urb, GFP_NOIO); + if (status) { + /* something went wrong */ + TRACE_RET(chip, status); + } + + /* since the URB has been submitted successfully, it's now okay + * to cancel it */ + set_bit(FLIDX_URB_ACTIVE, &rts51x->dflags); + + /* did an abort occur during the submission? */ + if (test_bit(FLIDX_ABORTING, &rts51x->dflags)) { + + /* cancel the URB, if it hasn't been cancelled already */ + if (test_and_clear_bit(FLIDX_URB_ACTIVE, &rts51x->dflags)) { + RTS51X_DEBUGP("-- cancelling URB\n"); + usb_unlink_urb(urb); + } + } + + /* wait for the completion of the URB */ + timeleft = + wait_for_completion_interruptible_timeout(&urb_done, + (timeout * HZ / + 1000) ? : + MAX_SCHEDULE_TIMEOUT); + + clear_bit(FLIDX_URB_ACTIVE, &rts51x->dflags); + + if (timeleft <= 0) { + RTS51X_DEBUGP("%s -- cancelling URB\n", + timeleft == 0 ? "Timeout" : "Signal"); + usb_kill_urb(urb); + if (timeleft == 0) + status = -ETIMEDOUT; + else + status = -EINTR; + } else { + status = urb->status; + } + + return status; +} + +/* + * Interpret the results of a URB transfer + */ +static int interpret_urb_result(struct rts51x_chip *chip, unsigned int pipe, + unsigned int length, int result, + unsigned int partial) +{ + int retval = STATUS_SUCCESS; + + /* RTS51X_DEBUGP("Status code %d; transferred %u/%u\n", + result, partial, length); */ + switch (result) { + /* no error code; did we send all the data? */ + case 0: + if (partial != length) { + RTS51X_DEBUGP("-- short transfer\n"); + TRACE_RET(chip, STATUS_TRANS_SHORT); + } + /* RTS51X_DEBUGP("-- transfer complete\n"); */ + return STATUS_SUCCESS; + /* stalled */ + case -EPIPE: + /* for control endpoints, (used by CB[I]) a stall indicates + * a failed command */ + if (usb_pipecontrol(pipe)) { + RTS51X_DEBUGP("-- stall on control pipe\n"); + TRACE_RET(chip, STATUS_STALLED); + } + /* for other sorts of endpoint, clear the stall */ + RTS51X_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); + if (rts51x_clear_halt(chip, pipe) < 0) + TRACE_RET(chip, STATUS_ERROR); + retval = STATUS_STALLED; + TRACE_GOTO(chip, Exit); + + /* babble - the device tried to send more than + * we wanted to read */ + case -EOVERFLOW: + RTS51X_DEBUGP("-- babble\n"); + retval = STATUS_TRANS_LONG; + TRACE_GOTO(chip, Exit); + + /* the transfer was cancelled by abort, + * disconnect, or timeout */ + case -ECONNRESET: + RTS51X_DEBUGP("-- transfer cancelled\n"); + retval = STATUS_ERROR; + TRACE_GOTO(chip, Exit); + + /* short scatter-gather read transfer */ + case -EREMOTEIO: + RTS51X_DEBUGP("-- short read transfer\n"); + retval = STATUS_TRANS_SHORT; + TRACE_GOTO(chip, Exit); + + /* abort or disconnect in progress */ + case -EIO: + RTS51X_DEBUGP("-- abort or disconnect in progress\n"); + retval = STATUS_ERROR; + TRACE_GOTO(chip, Exit); + + case -ETIMEDOUT: + RTS51X_DEBUGP("-- time out\n"); + retval = STATUS_TIMEDOUT; + TRACE_GOTO(chip, Exit); + + /* the catch-all error case */ + default: + RTS51X_DEBUGP("-- unknown error\n"); + retval = STATUS_ERROR; + TRACE_GOTO(chip, Exit); + } + +Exit: + if ((retval != STATUS_SUCCESS) && !usb_pipecontrol(pipe)) + rts51x_clear_hw_error(chip); + + return retval; +} + +int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe, + u8 request, u8 requesttype, u16 value, u16 index, + void *data, u16 size, int timeout) +{ + struct rts51x_usb *rts51x = chip->usb; + int result; + + RTS51X_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", + __func__, request, requesttype, value, index, size); + + /* fill in the devrequest structure */ + rts51x->cr->bRequestType = requesttype; + rts51x->cr->bRequest = request; + rts51x->cr->wValue = cpu_to_le16(value); + rts51x->cr->wIndex = cpu_to_le16(index); + rts51x->cr->wLength = cpu_to_le16(size); + + /* fill and submit the URB */ + usb_fill_control_urb(rts51x->current_urb, rts51x->pusb_dev, pipe, + (unsigned char *)rts51x->cr, data, size, + urb_done_completion, NULL); + result = rts51x_msg_common(chip, rts51x->current_urb, timeout); + + return interpret_urb_result(chip, pipe, size, result, + rts51x->current_urb->actual_length); +} + +int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe) +{ + int result; + int endp = usb_pipeendpoint(pipe); + + if (usb_pipein(pipe)) + endp |= USB_DIR_IN; + + result = rts51x_ctrl_transfer(chip, SND_CTRL_PIPE(chip), + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, NULL, 0, 3000); + if (result != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + usb_reset_endpoint(chip->usb->pusb_dev, endp); + + return STATUS_SUCCESS; +} + +int rts51x_reset_pipe(struct rts51x_chip *chip, char pipe) +{ + return rts51x_clear_halt(chip, pipe); +} + +static void rts51x_sg_clean(struct usb_sg_request *io) +{ + if (io->urbs) { + while (io->entries--) + usb_free_urb(io->urbs[io->entries]); + kfree(io->urbs); + io->urbs = NULL; + } +#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) */ + if (io->dev->dev.dma_mask != NULL) + usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), + io->sg, io->nents); +#endif + io->dev = NULL; +} +#if 0 +static void rts51x_sg_complete(struct urb *urb) +{ + struct usb_sg_request *io = urb->context; + int status = urb->status; + + spin_lock(&io->lock); + + /* In 2.5 we require hcds' endpoint queues not to progress after fault + * reports, until the completion callback (this!) returns. That lets + * device driver code (like this routine) unlink queued urbs first, + * if it needs to, since the HC won't work on them at all. So it's + * not possible for page N+1 to overwrite page N, and so on. + * + * That's only for "hard" faults; "soft" faults (unlinks) sometimes + * complete before the HCD can get requests away from hardware, + * though never during cleanup after a hard fault. + */ + if (io->status + && (io->status != -ECONNRESET + || status != -ECONNRESET) + && urb->actual_length) { + dev_err(io->dev->bus->controller, + "dev %s ep%d%s scatterlist error %d/%d\n", + io->dev->devpath, + usb_endpoint_num(&urb->ep->desc), + usb_urb_dir_in(urb) ? "in" : "out", + status, io->status); + /* BUG (); */ + } + + if (io->status == 0 && status && status != -ECONNRESET) { + int i, found, retval; + + io->status = status; + + /* the previous urbs, and this one, completed already. + * unlink pending urbs so they won't rx/tx bad data. + * careful: unlink can sometimes be synchronous... + */ + spin_unlock(&io->lock); + for (i = 0, found = 0; i < io->entries; i++) { + if (!io->urbs[i] || !io->urbs[i]->dev) + continue; + if (found) { + retval = usb_unlink_urb(io->urbs[i]); + if (retval != -EINPROGRESS && + retval != -ENODEV && + retval != -EBUSY) + dev_err(&io->dev->dev, + "%s, unlink --> %d\n", + __func__, retval); + } else if (urb == io->urbs[i]) + found = 1; + } + spin_lock(&io->lock); + } + urb->dev = NULL; + + /* on the last completion, signal usb_sg_wait() */ + io->bytes += urb->actual_length; + io->count--; + if (!io->count) + complete(&io->complete); + + spin_unlock(&io->lock); +} + +/* This function is ported from usb_sg_init, which can transfer + * sg list partially */ +int rts51x_sg_init_partial(struct usb_sg_request *io, struct usb_device *dev, + unsigned pipe, unsigned period, void *buf, struct scatterlist **sgptr, + unsigned int *offset, int nents, size_t length, gfp_t mem_flags) +{ + int i; + int urb_flags; + int dma; + struct scatterlist *sg = *sgptr, *first_sg; + + first_sg = (struct scatterlist *)buf; + if (!sg) + sg = first_sg; + + if (!io || !dev || !sg + || usb_pipecontrol(pipe) + || usb_pipeisoc(pipe) + || (nents <= 0)) + return -EINVAL; + + spin_lock_init(&io->lock); + io->dev = dev; + io->pipe = pipe; + io->sg = first_sg; /* used by unmap */ + io->nents = nents; + + RTS51X_DEBUGP("Before map, sg address: 0x%x\n", (unsigned int)sg); + RTS51X_DEBUGP("Before map, dev address: 0x%x\n", (unsigned int)dev); + + /* not all host controllers use DMA (like the mainstream pci ones); + * they can use PIO (sl811) or be software over another transport. + */ + dma = (dev->dev.dma_mask != NULL); + if (dma) { + /* map the whole sg list, because here we only know the + * total nents */ + io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), + first_sg, nents); + } else { + io->entries = nents; + } + + /* initialize all the urbs we'll use */ + if (io->entries <= 0) + return io->entries; + + io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); + if (!io->urbs) + goto nomem; + + urb_flags = URB_NO_INTERRUPT; + if (dma) + urb_flags |= URB_NO_TRANSFER_DMA_MAP; + if (usb_pipein(pipe)) + urb_flags |= URB_SHORT_NOT_OK; + + RTS51X_DEBUGP("io->entries = %d\n", io->entries); + + for (i = 0; (sg != NULL) && (length > 0); i++) { + unsigned len; + + RTS51X_DEBUGP("sg address: 0x%x\n", (unsigned int)sg); + RTS51X_DEBUGP("length = %d, *offset = %d\n", length, *offset); + + io->urbs[i] = usb_alloc_urb(0, mem_flags); + if (!io->urbs[i]) { + io->entries = i; + goto nomem; + } + + io->urbs[i]->dev = NULL; + io->urbs[i]->pipe = pipe; + io->urbs[i]->interval = period; + io->urbs[i]->transfer_flags = urb_flags; + + io->urbs[i]->complete = rts51x_sg_complete; + io->urbs[i]->context = io; + + if (dma) { + io->urbs[i]->transfer_dma = + sg_dma_address(sg) + *offset; + len = sg_dma_len(sg) - *offset; + io->urbs[i]->transfer_buffer = NULL; + RTS51X_DEBUGP(" -- sg entry dma length = %d\n", + sg_dma_len(sg)); + } else { + /* hc may use _only_ transfer_buffer */ + io->urbs[i]->transfer_buffer = sg_virt(sg) + *offset; + len = sg->length - *offset; + RTS51X_DEBUGP(" -- sg entry length = %d\n", + sg->length); + } + + if (length >= len) { + *offset = 0; + io->urbs[i]->transfer_buffer_length = len; + length -= len; + sg = sg_next(sg); + } else { + *offset += length; + io->urbs[i]->transfer_buffer_length = length; + length = 0; + } + if (length == 0) + io->entries = i + 1; +#if 0 + if (length) { + len = min_t(unsigned, len, length); + length -= len; + if (length == 0) { + io->entries = i + 1; + *offset += len; + } else { + *offset = 0; + } + } +#endif + } + RTS51X_DEBUGP("In %s, urb count: %d\n", __func__, i); + io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; + + RTS51X_DEBUGP("sg address stored in sgptr: 0x%x\n", (unsigned int)sg); + *sgptr = sg; + + /* transaction state */ + io->count = io->entries; + io->status = 0; + io->bytes = 0; + init_completion(&io->complete); + return 0; + +nomem: + rts51x_sg_clean(io); + return -ENOMEM; +} +#endif +int rts51x_sg_init(struct usb_sg_request *io, struct usb_device *dev, + unsigned pipe, unsigned period, struct scatterlist *sg, + int nents, size_t length, gfp_t mem_flags) +{ + return usb_sg_init(io, dev, pipe, period, sg, nents, length, mem_flags); +} + +int rts51x_sg_wait(struct usb_sg_request *io, int timeout) +{ + long timeleft; + int i; + int entries = io->entries; + + /* queue the urbs. */ + spin_lock_irq(&io->lock); + i = 0; + while (i < entries && !io->status) { + int retval; + + io->urbs[i]->dev = io->dev; + retval = usb_submit_urb(io->urbs[i], GFP_ATOMIC); + + /* after we submit, let completions or cancelations fire; + * we handshake using io->status. + */ + spin_unlock_irq(&io->lock); + switch (retval) { + /* maybe we retrying will recover */ + case -ENXIO: /* hc didn't queue this one */ + case -EAGAIN: + case -ENOMEM: + io->urbs[i]->dev = NULL; + retval = 0; + yield(); + break; + + /* no error? continue immediately. + * + * NOTE: to work better with UHCI (4K I/O buffer may + * need 3K of TDs) it may be good to limit how many + * URBs are queued at once; N milliseconds? + */ + case 0: + ++i; + cpu_relax(); + break; + + /* fail any uncompleted urbs */ + default: + io->urbs[i]->dev = NULL; + io->urbs[i]->status = retval; + dev_dbg(&io->dev->dev, "%s, submit --> %d\n", + __func__, retval); + usb_sg_cancel(io); + } + spin_lock_irq(&io->lock); + if (retval && (io->status == 0 || io->status == -ECONNRESET)) + io->status = retval; + } + io->count -= entries - i; + if (io->count == 0) + complete(&io->complete); + spin_unlock_irq(&io->lock); + + timeleft = + wait_for_completion_interruptible_timeout(&io->complete, + (timeout * HZ / + 1000) ? : + MAX_SCHEDULE_TIMEOUT); + if (timeleft <= 0) { + RTS51X_DEBUGP("%s -- cancelling SG request\n", + timeleft == 0 ? "Timeout" : "Signal"); + usb_sg_cancel(io); + if (timeleft == 0) + io->status = -ETIMEDOUT; + else + io->status = -EINTR; + } + + rts51x_sg_clean(io); + return io->status; +} + +/* + * Transfer a scatter-gather list via bulk transfer + * + * This function does basically the same thing as usb_stor_bulk_transfer_buf() + * above, but it uses the usbcore scatter-gather library. + */ +static int rts51x_bulk_transfer_sglist(struct rts51x_chip *chip, + unsigned int pipe, + struct scatterlist *sg, int num_sg, + unsigned int length, + unsigned int *act_len, int timeout) +{ + int result; + + /* don't submit s-g requests during abort processing */ + if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) + TRACE_RET(chip, STATUS_ERROR); + + /* initialize the scatter-gather request block */ + RTS51X_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, + length, num_sg); + result = + rts51x_sg_init(&chip->usb->current_sg, chip->usb->pusb_dev, pipe, 0, + sg, num_sg, length, GFP_NOIO); + if (result) { + RTS51X_DEBUGP("rts51x_sg_init returned %d\n", result); + TRACE_RET(chip, STATUS_ERROR); + } + + /* since the block has been initialized successfully, it's now + * okay to cancel it */ + set_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); + + /* did an abort occur during the submission? */ + if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) { + + /* cancel the request, if it hasn't been cancelled already */ + if (test_and_clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags)) { + RTS51X_DEBUGP("-- cancelling sg request\n"); + usb_sg_cancel(&chip->usb->current_sg); + } + } + + /* wait for the completion of the transfer */ + result = rts51x_sg_wait(&chip->usb->current_sg, timeout); + + clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); + + /* result = us->current_sg.status; */ + if (act_len) + *act_len = chip->usb->current_sg.bytes; + return interpret_urb_result(chip, pipe, length, result, + chip->usb->current_sg.bytes); +} +#if 0 +static int rts51x_bulk_transfer_sglist_partial(struct rts51x_chip *chip, + unsigned int pipe, void *buf, struct scatterlist **sgptr, + unsigned int *offset, int num_sg, unsigned int length, + unsigned int *act_len, int timeout) +{ + int result; + + /* don't submit s-g requests during abort processing */ + if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) + TRACE_RET(chip, STATUS_ERROR); + + /* initialize the scatter-gather request block */ + RTS51X_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, + length, num_sg); + result = rts51x_sg_init_partial(&chip->usb->current_sg, + chip->usb->pusb_dev, pipe, 0, buf, sgptr, offset, + num_sg, length, GFP_NOIO); + if (result) { + RTS51X_DEBUGP("rts51x_sg_init_partial returned %d\n", result); + TRACE_RET(chip, STATUS_ERROR); + } + + /* since the block has been initialized successfully, it's now + * okay to cancel it */ + set_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); + + /* did an abort occur during the submission? */ + if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) { + + /* cancel the request, if it hasn't been cancelled already */ + if (test_and_clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags)) { + RTS51X_DEBUGP("-- cancelling sg request\n"); + usb_sg_cancel(&chip->usb->current_sg); + } + } + + /* wait for the completion of the transfer */ + result = rts51x_sg_wait(&chip->usb->current_sg, timeout); + + clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); + + /* result = us->current_sg.status; */ + if (act_len) + *act_len = chip->usb->current_sg.bytes; + return interpret_urb_result(chip, pipe, length, result, + chip->usb->current_sg.bytes); +} +#endif +int rts51x_bulk_transfer_buf(struct rts51x_chip *chip, unsigned int pipe, + void *buf, unsigned int length, + unsigned int *act_len, int timeout) +{ + int result; + + /* fill and submit the URB */ + usb_fill_bulk_urb(chip->usb->current_urb, chip->usb->pusb_dev, pipe, + buf, length, urb_done_completion, NULL); + result = rts51x_msg_common(chip, chip->usb->current_urb, timeout); + + /* store the actual length of the data transferred */ + if (act_len) + *act_len = chip->usb->current_urb->actual_length; + return interpret_urb_result(chip, pipe, length, result, + chip->usb->current_urb->actual_length); +} + +int rts51x_transfer_data(struct rts51x_chip *chip, unsigned int pipe, + void *buf, unsigned int len, int use_sg, + unsigned int *act_len, int timeout) +{ + int result; + + if (timeout < 600) + timeout = 600; + + if (use_sg) { + result = + rts51x_bulk_transfer_sglist(chip, pipe, + (struct scatterlist *)buf, + use_sg, len, act_len, timeout); + } else { + result = + rts51x_bulk_transfer_buf(chip, pipe, buf, len, act_len, + timeout); + } + + return result; +} + +int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe, + void *buf, void **ptr, unsigned int *offset, + unsigned int len, int use_sg, + unsigned int *act_len, int timeout) +{ + int result; + + if (timeout < 600) + timeout = 600; + + if (use_sg) { + void *tmp_buf = kmalloc(len, GFP_KERNEL); + if (!tmp_buf) + TRACE_RET(chip, STATUS_NOMEM); + + if (usb_pipeout(pipe)) { + rts51x_access_sglist(tmp_buf, len, buf, ptr, offset, + FROM_XFER_BUF); + } + result = + rts51x_bulk_transfer_buf(chip, pipe, tmp_buf, len, act_len, + timeout); + if (result == STATUS_SUCCESS) { + if (usb_pipein(pipe)) { + rts51x_access_sglist(tmp_buf, len, buf, ptr, + offset, TO_XFER_BUF); + } + } + + kfree(tmp_buf); +#if 0 + result = rts51x_bulk_transfer_sglist_partial(chip, pipe, buf, + (struct scatterlist **)ptr, offset, + use_sg, len, act_len, timeout); +#endif + } else { + unsigned int step = 0; + if (offset) + step = *offset; + result = + rts51x_bulk_transfer_buf(chip, pipe, buf + step, len, + act_len, timeout); + if (act_len) + step += *act_len; + else + step += len; + if (offset) + *offset = step; + } + + return result; +} + +int rts51x_get_epc_status(struct rts51x_chip *chip, u16 * status) +{ + unsigned int pipe = RCV_INTR_PIPE(chip); + struct usb_host_endpoint *ep; + struct completion urb_done; + int result; + + if (!status) + TRACE_RET(chip, STATUS_ERROR); + + /* set up data structures for the wakeup system */ + init_completion(&urb_done); + + ep = chip->usb->pusb_dev->ep_in[usb_pipeendpoint(pipe)]; + + /* fill and submit the URB */ + /* We set interval to 1 here, so the polling interval is controlled + * by our polling thread */ + usb_fill_int_urb(chip->usb->intr_urb, chip->usb->pusb_dev, pipe, + status, 2, urb_done_completion, &urb_done, 1); + + result = rts51x_msg_common(chip, chip->usb->intr_urb, 50); + + return interpret_urb_result(chip, pipe, 2, result, + chip->usb->intr_urb->actual_length); +} + +u8 media_not_present[] = { + 0x70, 0, 0x02, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x3A, 0, 0, 0, 0, 0 }; +u8 invalid_cmd_field[] = { + 0x70, 0, 0x05, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x24, 0, 0, 0, 0, 0 }; + +void rts51x_invoke_transport(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + int result; + +#ifdef CONFIG_PM + if (chip->option.ss_en) { + if (srb->cmnd[0] == TEST_UNIT_READY) { + if (RTS51X_CHK_STAT(chip, STAT_SS)) { + if (check_fake_card_ready(chip, + SCSI_LUN(srb))) { + srb->result = SAM_STAT_GOOD; + } else { + srb->result = SAM_STAT_CHECK_CONDITION; + memcpy(srb->sense_buffer, + media_not_present, SENSE_SIZE); + } + return; + } + } else if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { + if (RTS51X_CHK_STAT(chip, STAT_SS)) { + int prevent = srb->cmnd[4] & 0x1; + + if (prevent) { + srb->result = SAM_STAT_CHECK_CONDITION; + memcpy(srb->sense_buffer, + invalid_cmd_field, SENSE_SIZE); + } else { + srb->result = SAM_STAT_GOOD; + } + return; + } + } else { + if (RTS51X_CHK_STAT(chip, STAT_SS) + || RTS51X_CHK_STAT(chip, STAT_SS_PRE)) { + /* Wake up device */ + RTS51X_DEBUGP("Try to wake up device\n"); + chip->resume_from_scsi = 1; + + rts51x_try_to_exit_ss(chip); + + if (RTS51X_CHK_STAT(chip, STAT_SS)) { + wait_timeout(3000); + + rts51x_init_chip(chip); + rts51x_init_cards(chip); + } + } + } + } +#endif + + result = rts51x_scsi_handler(srb, chip); + + /* if there is a transport error, reset and don't auto-sense */ + if (result == TRANSPORT_ERROR) { + RTS51X_DEBUGP("-- transport indicates error, resetting\n"); + srb->result = DID_ERROR << 16; + goto Handle_Errors; + } + + srb->result = SAM_STAT_GOOD; + + /* + * If we have a failure, we're going to do a REQUEST_SENSE + * automatically. Note that we differentiate between a command + * "failure" and an "error" in the transport mechanism. + */ + if (result == TRANSPORT_FAILED) { + /* set the result so the higher layers expect this data */ + srb->result = SAM_STAT_CHECK_CONDITION; + memcpy(srb->sense_buffer, + (unsigned char *)&(chip->sense_buffer[SCSI_LUN(srb)]), + sizeof(struct sense_data_t)); + } + + return; + + /* Error and abort processing: try to resynchronize with the device + * by issuing a port reset. If that fails, try a class-specific + * device reset. */ +Handle_Errors: + return; +} diff --git a/drivers/staging/rts5139/rts51x_transport.h b/drivers/staging/rts5139/rts51x_transport.h new file mode 100644 index 00000000000..f7aa87f7f1a --- /dev/null +++ b/drivers/staging/rts5139/rts51x_transport.h @@ -0,0 +1,80 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_TRANSPORT_H +#define __RTS51X_TRANSPORT_H + +#include +#include + +#include "rts51x.h" +#include "rts51x_chip.h" + +#if 1 /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34) */ +#define URB_NO_SETUP_DMA_MAP 0 +#endif + +unsigned int rts51x_access_sglist(unsigned char *buffer, + unsigned int buflen, void *sglist, + void **sgptr, unsigned int *offset, + enum xfer_buf_dir dir); +unsigned int rts51x_access_xfer_buf(unsigned char *buffer, unsigned int buflen, + struct scsi_cmnd *srb, + struct scatterlist **sgptr, + unsigned int *offset, + enum xfer_buf_dir dir); +void rts51x_set_xfer_buf(unsigned char *buffer, unsigned int buflen, + struct scsi_cmnd *srb); +void rts51x_get_xfer_buf(unsigned char *buffer, unsigned int buflen, + struct scsi_cmnd *srb); + +int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe, + u8 request, u8 requesttype, u16 value, u16 index, + void *data, u16 size, int timeout); +int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe); +int rts51x_transfer_data(struct rts51x_chip *chip, unsigned int pipe, + void *buf, unsigned int len, int use_sg, + unsigned int *act_len, int timeout); +int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe, + void *buf, void **ptr, unsigned int *offset, + unsigned int len, int use_sg, + unsigned int *act_len, int timeout); + +/* whichPipe: + * 0: bulk in pipe + * 1: bulk out pipe + * 2: intr in pipe */ +int rts51x_reset_pipe(struct rts51x_chip *chip, char pipe); + +#ifndef POLLING_IN_THREAD +int rts51x_start_epc_transfer(struct rts51x_chip *chip); +void rts51x_cancel_epc_transfer(struct rts51x_chip *chip); +#endif + +int rts51x_get_epc_status(struct rts51x_chip *chip, u16 * status); +void rts51x_invoke_transport(struct scsi_cmnd *srb, struct rts51x_chip *chip); + +#endif /* __RTS51X_TRANSPORT_H */ diff --git a/drivers/staging/rts5139/sd.c b/drivers/staging/rts5139/sd.c new file mode 100644 index 00000000000..d5dd2f926d1 --- /dev/null +++ b/drivers/staging/rts5139/sd.c @@ -0,0 +1,3400 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_transport.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "sd.h" + +static inline void sd_set_reset_fail(struct rts51x_chip *chip, u8 err_code) +{ + struct sd_info *sd_card = &(chip->sd_card); + + sd_card->sd_reset_fail |= err_code; +} + +static inline void sd_clear_reset_fail(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + + sd_card->sd_reset_fail = 0; +} + +static inline int sd_check_reset_fail(struct rts51x_chip *chip, u8 err_code) +{ + struct sd_info *sd_card = &(chip->sd_card); + + return sd_card->sd_reset_fail & err_code; +} + +static inline void sd_set_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct sd_info *sd_card = &(chip->sd_card); + + sd_card->err_code |= err_code; +} + +static inline void sd_clr_err_code(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + + sd_card->err_code = 0; +} + +static inline int sd_check_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct sd_info *sd_card = &(chip->sd_card); + + return sd_card->err_code & err_code; +} + +static int sd_parse_err_code(struct rts51x_chip *chip) +{ + TRACE_RET(chip, STATUS_FAIL); +} + +int sd_check_data0_status(struct rts51x_chip *chip) +{ + int retval; + u8 stat; + + retval = rts51x_ep0_read_register(chip, SD_BUS_STAT, &stat); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (!(stat & SD_DAT0_STATUS)) { + sd_set_err_code(chip, SD_BUSY); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, + u32 arg, u8 rsp_type, u8 *rsp, int rsp_len) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int timeout = 50; + u16 reg_addr; + u8 buf[17], stat; + int len = 2; + int rty_cnt = 0; + + sd_clr_err_code(chip); + + RTS51X_DEBUGP("SD/MMC CMD %d, arg = 0x%08x\n", cmd_idx, arg); + + if (rsp_type == SD_RSP_TYPE_R1b) + timeout = 3000; + +RTY_SEND_CMD: + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | cmd_idx); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, (u8) (arg >> 24)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, (u8) (arg >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, (u8) (arg >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_CMD_RSP | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END | SD_STAT_IDLE, + SD_TRANSFER_END | SD_STAT_IDLE); + + rts51x_add_cmd(chip, READ_REG_CMD, SD_STAT1, 0, 0); + + if (CHECK_USB(chip, USB_20)) { + if (rsp_type == SD_RSP_TYPE_R2) { + /* Read data from ping-pong buffer */ + for (reg_addr = PPBUF_BASE2; + reg_addr < PPBUF_BASE2 + 16; reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, + 0); + } + len = 18; + } else if (rsp_type != SD_RSP_TYPE_R0) { + /* Read data from SD_CMDx registers */ + for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; + reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, + 0); + } + len = 7; + } else { + len = 2; + } + } else { + len = 2; + } + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, len, timeout); + + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + u8 val; + + rts51x_ep0_read_register(chip, SD_STAT1, &val); + RTS51X_DEBUGP("SD_STAT1: 0x%x\n", val); + + rts51x_ep0_read_register(chip, SD_STAT2, &val); + RTS51X_DEBUGP("SD_STAT2: 0x%x\n", val); + + if (val & SD_RSP_80CLK_TIMEOUT) + sd_set_err_code(chip, SD_RSP_TIMEOUT); + + rts51x_ep0_read_register(chip, SD_BUS_STAT, &val); + RTS51X_DEBUGP("SD_BUS_STAT: 0x%x\n", val); + + if (retval == STATUS_TIMEDOUT) { + if (rsp_type & SD_WAIT_BUSY_END) { + retval = sd_check_data0_status(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + sd_set_err_code(chip, SD_TO_ERR); + } + } + rts51x_clear_sd_error(chip); + + TRACE_RET(chip, STATUS_FAIL); + } + + if (rsp_type == SD_RSP_TYPE_R0) + return STATUS_SUCCESS; + + if (CHECK_USB(chip, USB_20)) { + rts51x_read_rsp_buf(chip, 2, buf, len - 2); + } else { + if (rsp_type == SD_RSP_TYPE_R2) { + reg_addr = PPBUF_BASE2; + len = 16; + } else { + reg_addr = SD_CMD0; + len = 5; + } + retval = rts51x_seq_read_register(chip, reg_addr, + (unsigned short)len, buf); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + stat = chip->rsp_buf[1]; + + /* Check (Start,Transmission) bit of Response */ + if ((buf[0] & 0xC0) != 0) { + sd_set_err_code(chip, SD_STS_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + /* Check CRC7 */ + if (!(rsp_type & SD_NO_CHECK_CRC7)) { + if (stat & SD_CRC7_ERR) { + if (cmd_idx == WRITE_MULTIPLE_BLOCK) { + sd_set_err_code(chip, SD_CRC_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + if (rty_cnt < SD_MAX_RETRY_COUNT) { + wait_timeout(20); + rty_cnt++; + goto RTY_SEND_CMD; + } else { + sd_set_err_code(chip, SD_CRC_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + /* Check Status */ + if ((rsp_type == SD_RSP_TYPE_R1) || (rsp_type == SD_RSP_TYPE_R1b)) { + if ((cmd_idx != SEND_RELATIVE_ADDR) + && (cmd_idx != SEND_IF_COND)) { + if (cmd_idx != STOP_TRANSMISSION) { + if (buf[1] & 0x80) + TRACE_RET(chip, STATUS_FAIL); + } +#ifdef SUPPORT_SD_LOCK + /* exclude bit25 CARD_IS_LOCKED */ + if (buf[1] & 0x7D) { +#else + if (buf[1] & 0x7F) { +#endif + RTS51X_DEBUGP("buf[1]: 0x%02x\n", buf[1]); + TRACE_RET(chip, STATUS_FAIL); + } + if (buf[2] & 0xFF) { + RTS51X_DEBUGP("buf[2]: 0x%02x\n", buf[2]); + TRACE_RET(chip, STATUS_FAIL); + } + if (buf[3] & 0x80) { + RTS51X_DEBUGP("buf[3]: 0x%02x\n", buf[3]); + TRACE_RET(chip, STATUS_FAIL); + } + if (buf[3] & 0x01) { + /* Get "READY_FOR_DATA" bit */ + sd_card->sd_data_buf_ready = 1; + } else { + sd_card->sd_data_buf_ready = 0; + } + } + } + + if (rsp && rsp_len) + memcpy(rsp, buf, rsp_len); + + return STATUS_SUCCESS; +} + +static inline void sd_print_debug_reg(struct rts51x_chip *chip) +{ +#ifdef CONFIG_RTS5139_DEBUG + u8 val = 0; + + rts51x_ep0_read_register(chip, SD_STAT1, &val); + RTS51X_DEBUGP("SD_STAT1: 0x%x\n", val); + rts51x_ep0_read_register(chip, SD_STAT2, &val); + RTS51X_DEBUGP("SD_STAT2: 0x%x\n", val); + rts51x_ep0_read_register(chip, SD_BUS_STAT, &val); + RTS51X_DEBUGP("SD_BUS_STAT: 0x%x\n", val); +#endif +} + +int sd_read_data(struct rts51x_chip *chip, u8 trans_mode, u8 *cmd, int cmd_len, + u16 byte_cnt, u16 blk_cnt, u8 bus_width, u8 *buf, int buf_len, + int timeout) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i; + + sd_clr_err_code(chip); + + if (!buf) + buf_len = 0; + + if (buf_len > 512) + /* This function can't read data more than one page */ + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + if (cmd_len) { + RTS51X_DEBUGP("SD/MMC CMD %d\n", cmd[0] - 0x40); + for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0 + i, 0xFF, + cmd[i]); + } + } + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8) byte_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, + (u8) (byte_cnt >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, (u8) blk_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, + (u8) (blk_cnt >> 8)); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | SD_NO_WAIT_BUSY_END + | SD_CHECK_CRC7 | SD_RSP_LEN_6); + if (trans_mode != SD_TM_AUTO_TUNING) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + } + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + trans_mode | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, + SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, timeout); + + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + sd_print_debug_reg(chip); + if (retval == STATUS_TIMEDOUT) { + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + } + + TRACE_RET(chip, STATUS_FAIL); + } + + if (buf && buf_len) { + retval = rts51x_read_ppbuf(chip, buf, buf_len); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int sd_write_data(struct rts51x_chip *chip, u8 trans_mode, + u8 *cmd, int cmd_len, u16 byte_cnt, u16 blk_cnt, + u8 bus_width, u8 *buf, int buf_len, int timeout) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i; + + sd_clr_err_code(chip); + + if (!buf) + buf_len = 0; + + /* This function can't write data more than one page */ + if (buf_len > 512) + TRACE_RET(chip, STATUS_FAIL); + + if (buf && buf_len) { + retval = rts51x_write_ppbuf(chip, buf, buf_len); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + rts51x_init_cmd(chip); + + if (cmd_len) { + RTS51X_DEBUGP("SD/MMC CMD %d\n", cmd[0] - 0x40); + for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0 + i, 0xFF, + cmd[i]); + } + } + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8) byte_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, + (u8) (byte_cnt >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, (u8) blk_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, + (u8) (blk_cnt >> 8)); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); + + if (cmd_len) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | + SD_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6); + + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | + SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | + SD_RSP_LEN_6); + } + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + trans_mode | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, + SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, timeout); + + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + sd_print_debug_reg(chip); + + if (retval == STATUS_TIMEDOUT) + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int sd_check_csd(struct rts51x_chip *chip, char check_wp) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i; + u8 csd_ver, trans_speed; + u8 rsp[16]; + + for (i = 0; i < 6; i++) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = + sd_send_cmd_get_rsp(chip, SEND_CSD, sd_card->sd_addr, + SD_RSP_TYPE_R2, rsp, 16); + if (retval == STATUS_SUCCESS) + break; + } + + if (i == 6) + TRACE_RET(chip, STATUS_FAIL); + memcpy(sd_card->raw_csd, rsp + 1, 15); + /* Get CRC7 */ + RTS51X_READ_REG(chip, SD_CMD5, sd_card->raw_csd + 15); + + RTS51X_DEBUGP("CSD Response:\n"); + RTS51X_DUMP(rsp, 16); + + /* Get CSD Version */ + csd_ver = (rsp[1] & 0xc0) >> 6; + RTS51X_DEBUGP("csd_ver = %d\n", csd_ver); + + trans_speed = rsp[4]; + if ((trans_speed & 0x07) == 0x02) { /* 10Mbits/s */ + if ((trans_speed & 0xf8) >= 0x30) { /* >25Mbits/s */ + if (chip->asic_code) + sd_card->sd_clock = 46; + else + sd_card->sd_clock = CLK_50; + } else if ((trans_speed & 0xf8) == 0x28) { /* 20Mbits/s */ + if (chip->asic_code) + sd_card->sd_clock = 39; + else + sd_card->sd_clock = CLK_40; + } else if ((trans_speed & 0xf8) == 0x20) { /* 15Mbits/s */ + if (chip->asic_code) + sd_card->sd_clock = 29; + else + sd_card->sd_clock = CLK_30; + } else if ((trans_speed & 0xf8) >= 0x10) { /* 12Mbits/s */ + if (chip->asic_code) + sd_card->sd_clock = 23; + else + sd_card->sd_clock = CLK_20; + } else if ((trans_speed & 0x08) >= 0x08) { /* 10Mbits/s */ + if (chip->asic_code) + sd_card->sd_clock = 19; + else + sd_card->sd_clock = CLK_20; + } /*else { */ + /*If this ,then slow card will use 30M clock */ + /* TRACE_RET(chip, STATUS_FAIL); */ + /* } */ + } + /*else { + TRACE_RET(chip, STATUS_FAIL); + } */ + if (CHK_MMC_SECTOR_MODE(sd_card)) { + sd_card->capacity = 0; + } else { + /* For High-Capacity Card, CSD_STRUCTURE always be "0x1" */ + if ((!CHK_SD_HCXC(sd_card)) || (csd_ver == 0)) { + /* Calculate total sector according to C_SIZE, + * C_SIZE_MULT & READ_BL_LEN */ + u8 blk_size, c_size_mult; + u16 c_size; + /* Get READ_BL_LEN */ + blk_size = rsp[6] & 0x0F; + /* Get C_SIZE */ + c_size = ((u16) (rsp[7] & 0x03) << 10) + + ((u16) rsp[8] << 2) + + ((u16) (rsp[9] & 0xC0) >> 6); + /* Get C_SIZE_MUL */ + c_size_mult = (u8) ((rsp[10] & 0x03) << 1); + c_size_mult += (rsp[11] & 0x80) >> 7; + /* Calculate total Capacity */ + sd_card->capacity = + (((u32) (c_size + 1)) * + (1 << (c_size_mult + 2))) << (blk_size - 9); + } else { + /* High Capacity Card and Use CSD2.0 Version */ + u32 total_sector = 0; + total_sector = (((u32) rsp[8] & 0x3f) << 16) | + ((u32) rsp[9] << 8) | (u32) rsp[10]; + /* Total Capacity= (C_SIZE+1) * + * 512K Byte = (C_SIZE+1)K Sector,1K = 1024 Bytes */ + sd_card->capacity = (total_sector + 1) << 10; + } + } + + /* We need check Write-Protected Status by Field PERM WP or TEMP WP */ + if (check_wp) { + if (rsp[15] & 0x30) + chip->card_wp |= SD_CARD; + RTS51X_DEBUGP("CSD WP Status: 0x%x\n", rsp[15]); + } + + return STATUS_SUCCESS; +} + +static int sd_set_sample_push_timing(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + rts51x_init_cmd(chip); + + if (CHK_SD_SDR104(sd_card) || CHK_SD_SDR50(sd_card)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, + 0x0C | SD_ASYNC_FIFO_RST, + SD_30_MODE | SD_ASYNC_FIFO_RST); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, + CRC_VAR_CLK0 | SD30_FIX_CLK | SAMPLE_VAR_CLK1); + } else if (CHK_SD_DDR50(sd_card) || CHK_MMC_DDR52(sd_card)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, + 0x0C | SD_ASYNC_FIFO_RST, + SD_DDR_MODE | SD_ASYNC_FIFO_RST); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, + CRC_VAR_CLK0 | SD30_FIX_CLK | SAMPLE_VAR_CLK1); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, + DDR_VAR_TX_CMD_DAT, DDR_VAR_TX_CMD_DAT); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, + DDR_VAR_RX_DAT | DDR_VAR_RX_CMD, + DDR_VAR_RX_DAT | DDR_VAR_RX_CMD); + } else { + u8 val = 0; + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x0C, SD_20_MODE); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, + CRC_FIX_CLK | SD30_VAR_CLK0 | SAMPLE_VAR_CLK1); + + if ((chip->option.sd_ctl & SD_PUSH_POINT_CTL_MASK) == + SD_PUSH_POINT_AUTO) { + val = SD20_TX_NEG_EDGE; + } else if ((chip->option.sd_ctl & SD_PUSH_POINT_CTL_MASK) == + SD_PUSH_POINT_DELAY) { + val = SD20_TX_14_AHEAD; + } else { + val = SD20_TX_NEG_EDGE; + } + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, + SD20_TX_SEL_MASK, val); + + if ((chip->option.sd_ctl & SD_SAMPLE_POINT_CTL_MASK) == + SD_SAMPLE_POINT_AUTO) { + if (chip->asic_code) { + if (CHK_SD_HS(sd_card) || CHK_MMC_52M(sd_card)) + val = SD20_RX_14_DELAY; + else + val = SD20_RX_POS_EDGE; + } else { + val = SD20_RX_14_DELAY; + } + } else if ((chip->option.sd_ctl & SD_SAMPLE_POINT_CTL_MASK) == + SD_SAMPLE_POINT_DELAY) { + val = SD20_RX_14_DELAY; + } else { + val = SD20_RX_POS_EDGE; + } + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, + SD20_RX_SEL_MASK, val); + } + + if (CHK_MMC_DDR52(sd_card) && CHK_MMC_8BIT(sd_card)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, + EXTEND_DMA1_ASYNC_SIGNAL, 0); + } + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static void sd_choose_proper_clock(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + + if (CHK_SD_SDR104(sd_card)) { + if (chip->asic_code) + sd_card->sd_clock = chip->option.asic_sd_sdr104_clk; + else + sd_card->sd_clock = chip->option.fpga_sd_sdr104_clk; + } else if (CHK_SD_DDR50(sd_card)) { + if (chip->asic_code) + sd_card->sd_clock = chip->option.asic_sd_ddr50_clk; + else + sd_card->sd_clock = chip->option.fpga_sd_ddr50_clk; + } else if (CHK_SD_SDR50(sd_card)) { + if (chip->asic_code) + sd_card->sd_clock = chip->option.asic_sd_sdr50_clk; + else + sd_card->sd_clock = chip->option.fpga_sd_sdr50_clk; + } else if (CHK_SD_HS(sd_card)) { + if (chip->asic_code) + sd_card->sd_clock = chip->option.asic_sd_hs_clk; + else + sd_card->sd_clock = chip->option.fpga_sd_hs_clk; + } else if (CHK_MMC_52M(sd_card) || CHK_MMC_DDR52(sd_card)) { + if (chip->asic_code) + sd_card->sd_clock = chip->option.asic_mmc_52m_clk; + else + sd_card->sd_clock = chip->option.fpga_mmc_52m_clk; + } else if (CHK_MMC_26M(sd_card)) { + if (chip->asic_code) { + sd_card->sd_clock = 46; + RTS51X_DEBUGP("Set MMC clock to 22.5MHz\n"); + } else { + sd_card->sd_clock = CLK_50; + } + } +} + +static int sd_set_init_para(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + retval = sd_set_sample_push_timing(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + sd_choose_proper_clock(chip); + + retval = switch_clock(chip, sd_card->sd_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int sd_select_card(struct rts51x_chip *chip, int select) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd_idx, cmd_type; + u32 addr; + + if (select) { + cmd_idx = SELECT_CARD; + cmd_type = SD_RSP_TYPE_R1; + addr = sd_card->sd_addr; + } else { + cmd_idx = DESELECT_CARD; + cmd_type = SD_RSP_TYPE_R0; + addr = 0; + } + + retval = sd_send_cmd_get_rsp(chip, cmd_idx, addr, cmd_type, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +#ifdef SUPPORT_SD_LOCK +int sd_update_lock_status(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 rsp[5]; + + retval = + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, rsp, 5); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + if (rsp[1] & 0x02) + sd_card->sd_lock_status |= SD_LOCKED; + else + sd_card->sd_lock_status &= ~SD_LOCKED; + + RTS51X_DEBUGP("sd_card->sd_lock_status = 0x%x\n", + sd_card->sd_lock_status); + + if (rsp[1] & 0x01) { + /* LOCK_UNLOCK_FAILED */ + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} +#endif + +int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk, + u8 rdychk, u16 pollingcnt) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 rsp[5]; + u16 i; + + for (i = 0; i < pollingcnt; i++) { + + retval = + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, rsp, 5); + if (retval == STATUS_SUCCESS) { + if (((rsp[3] & 0x1E) == statechk) + && ((rsp[3] & 0x01) == rdychk)) { + return STATUS_SUCCESS; + } + } else { + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + } + + return STATUS_TIMEDOUT; +} + +static int sd_voltage_switch(struct rts51x_chip *chip) +{ + int retval; + u8 stat; + + RTS51X_WRITE_REG(chip, SD_BUS_STAT, + SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, + SD_CLK_TOGGLE_EN); + + retval = + sd_send_cmd_get_rsp(chip, VOLTAGE_SWITCH, 0, SD_RSP_TYPE_R1, NULL, + 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_READ_REG(chip, SD_BUS_STAT, &stat); + if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | + SD_DAT1_STATUS | SD_DAT0_STATUS)) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BUS_STAT, 0xFF, + SD_CLK_FORCE_STOP); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PAD_CTL, SD_IO_USING_1V8, + SD_IO_USING_1V8); + if (chip->asic_code) + rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, + TUNE_SD18_MASK, TUNE_SD18_1V8); + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + wait_timeout(chip->option.D3318_off_delay); + + RTS51X_WRITE_REG(chip, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN); + wait_timeout(10); + + RTS51X_READ_REG(chip, SD_BUS_STAT, &stat); + if ((stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | + SD_DAT1_STATUS | SD_DAT0_STATUS)) != + (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | + SD_DAT1_STATUS | SD_DAT0_STATUS)) { + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BUS_STAT, 0xFF, + SD_CLK_FORCE_STOP); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, 0xFF, 0); + rts51x_send_cmd(chip, MODE_C, 100); + TRACE_RET(chip, STATUS_FAIL); + } + RTS51X_WRITE_REG(chip, SD_BUS_STAT, + SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); + + return STATUS_SUCCESS; +} + +static int sd_change_phase(struct rts51x_chip *chip, u8 sample_point, + u8 tune_dir) +{ + u16 SD_VP_CTL, SD_DCMPS_CTL; + u8 val; + int retval; + + RTS51X_DEBUGP("sd_change_phase (sample_point = %d, tune_dir = %d)\n", + sample_point, tune_dir); + + if (tune_dir == TUNE_RX) { + SD_VP_CTL = SD_VPCLK1_CTL; + SD_DCMPS_CTL = SD_DCMPS1_CTL; + } else { + SD_VP_CTL = SD_VPCLK0_CTL; + SD_DCMPS_CTL = SD_DCMPS0_CTL; + } + + if (chip->asic_code) { + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, CLK_CHANGE); + RTS51X_WRITE_REG(chip, SD_VP_CTL, 0x1F, sample_point); + RTS51X_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); + RTS51X_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, + PHASE_NOT_RESET); + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); + } else { +#ifdef CONFIG_RTS5139_DEBUG + RTS51X_READ_REG(chip, SD_VP_CTL, &val); + RTS51X_DEBUGP("SD_VP_CTL: 0x%x\n", val); + RTS51X_READ_REG(chip, SD_DCMPS_CTL, &val); + RTS51X_DEBUGP("SD_DCMPS_CTL: 0x%x\n", val); +#endif + + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, CLK_CHANGE); + udelay(100); + RTS51X_WRITE_REG(chip, SD_VP_CTL, 0xFF, + PHASE_NOT_RESET | sample_point); + udelay(200); + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_DCMPS_CTL, DCMPS_CHANGE, + DCMPS_CHANGE); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_DCMPS_CTL, + DCMPS_CHANGE_DONE, DCMPS_CHANGE_DONE); + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, Fail); + + retval = rts51x_get_rsp(chip, 1, 500); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, Fail); + + val = chip->rsp_buf[0]; + if (val & DCMPS_ERROR) + TRACE_GOTO(chip, Fail); + if ((val & DCMPS_CURRENT_PHASE) != sample_point) + TRACE_GOTO(chip, Fail); + RTS51X_WRITE_REG(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0); + RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); + udelay(100); + } + + RTS51X_WRITE_REG(chip, SD_CFG1, SD_ASYNC_FIFO_RST, 0); + + return STATUS_SUCCESS; + +Fail: +#ifdef CONFIG_RTS5139_DEBUG + rts51x_ep0_read_register(chip, SD_VP_CTL, &val); + RTS51X_DEBUGP("SD_VP_CTL: 0x%x\n", val); + rts51x_ep0_read_register(chip, SD_DCMPS_CTL, &val); + RTS51X_DEBUGP("SD_DCMPS_CTL: 0x%x\n", val); +#endif + + RTS51X_WRITE_REG(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0); + RTS51X_WRITE_REG(chip, SD_VP_CTL, PHASE_CHANGE, 0); + wait_timeout(10); + + return STATUS_FAIL; +} + +static int sd_check_spec(struct rts51x_chip *chip, u8 bus_width) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd[5], buf[8]; + + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + cmd[0] = 0x40 | SEND_SCR; + cmd[1] = 0; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 8, 1, bus_width, buf, + 8, 250); + if (retval != STATUS_SUCCESS) { + rts51x_clear_sd_error(chip); + TRACE_RET(chip, retval); + } + + memcpy(sd_card->raw_scr, buf, 8); + + if ((buf[0] & 0x0F) == 0) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int sd_query_switch_result(struct rts51x_chip *chip, u8 func_group, + u8 func_to_switch, u8 *buf, int buf_len) +{ + u8 support_mask = 0, query_switch = 0, switch_busy = 0; + int support_offset = 0, query_switch_offset = 0, check_busy_offset = 0; + + if (func_group == SD_FUNC_GROUP_1) { + support_offset = FUNCTION_GROUP1_SUPPORT_OFFSET; + query_switch_offset = FUNCTION_GROUP1_QUERY_SWITCH_OFFSET; + check_busy_offset = FUNCTION_GROUP1_CHECK_BUSY_OFFSET; + + switch (func_to_switch) { + case HS_SUPPORT: + support_mask = HS_SUPPORT_MASK; + query_switch = HS_QUERY_SWITCH_OK; + switch_busy = HS_SWITCH_BUSY; + break; + + case SDR50_SUPPORT: + support_mask = SDR50_SUPPORT_MASK; + query_switch = SDR50_QUERY_SWITCH_OK; + switch_busy = SDR50_SWITCH_BUSY; + break; + + case SDR104_SUPPORT: + support_mask = SDR104_SUPPORT_MASK; + query_switch = SDR104_QUERY_SWITCH_OK; + switch_busy = SDR104_SWITCH_BUSY; + break; + + case DDR50_SUPPORT: + support_mask = DDR50_SUPPORT_MASK; + query_switch = DDR50_QUERY_SWITCH_OK; + switch_busy = DDR50_SWITCH_BUSY; + break; + + default: + TRACE_RET(chip, STATUS_FAIL); + } + } else if (func_group == SD_FUNC_GROUP_3) { + support_offset = FUNCTION_GROUP3_SUPPORT_OFFSET; + query_switch_offset = FUNCTION_GROUP3_QUERY_SWITCH_OFFSET; + check_busy_offset = FUNCTION_GROUP3_CHECK_BUSY_OFFSET; + + switch (func_to_switch) { + case DRIVING_TYPE_A: + support_mask = DRIVING_TYPE_A_MASK; + query_switch = TYPE_A_QUERY_SWITCH_OK; + switch_busy = TYPE_A_SWITCH_BUSY; + break; + + case DRIVING_TYPE_C: + support_mask = DRIVING_TYPE_C_MASK; + query_switch = TYPE_C_QUERY_SWITCH_OK; + switch_busy = TYPE_C_SWITCH_BUSY; + break; + + case DRIVING_TYPE_D: + support_mask = DRIVING_TYPE_D_MASK; + query_switch = TYPE_D_QUERY_SWITCH_OK; + switch_busy = TYPE_D_SWITCH_BUSY; + break; + + default: + TRACE_RET(chip, STATUS_FAIL); + } + } else if (func_group == SD_FUNC_GROUP_4) { + support_offset = FUNCTION_GROUP4_SUPPORT_OFFSET; + query_switch_offset = FUNCTION_GROUP4_QUERY_SWITCH_OFFSET; + check_busy_offset = FUNCTION_GROUP4_CHECK_BUSY_OFFSET; + + switch (func_to_switch) { + case CURRENT_LIMIT_400: + support_mask = CURRENT_LIMIT_400_MASK; + query_switch = CURRENT_LIMIT_400_QUERY_SWITCH_OK; + switch_busy = CURRENT_LIMIT_400_SWITCH_BUSY; + break; + + case CURRENT_LIMIT_600: + support_mask = CURRENT_LIMIT_600_MASK; + query_switch = CURRENT_LIMIT_600_QUERY_SWITCH_OK; + switch_busy = CURRENT_LIMIT_600_SWITCH_BUSY; + break; + + case CURRENT_LIMIT_800: + support_mask = CURRENT_LIMIT_800_MASK; + query_switch = CURRENT_LIMIT_800_QUERY_SWITCH_OK; + switch_busy = CURRENT_LIMIT_800_SWITCH_BUSY; + break; + + default: + TRACE_RET(chip, STATUS_FAIL); + } + } else { + TRACE_RET(chip, STATUS_FAIL); + } + + if (func_group == SD_FUNC_GROUP_4) + buf[query_switch_offset] = + (buf[query_switch_offset] & 0xf0) >> 4; + if (!(buf[support_offset] & support_mask) || + ((buf[query_switch_offset] & 0x0F) != query_switch)) + TRACE_RET(chip, STATUS_FAIL); + + if ((buf[DATA_STRUCTURE_VER_OFFSET] == 0x01) && + ((buf[check_busy_offset] & switch_busy) == switch_busy)) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int sd_check_switch_mode(struct rts51x_chip *chip, u8 mode, + u8 func_group, u8 func_to_switch, u8 bus_width) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd[5], buf[64]; + + RTS51X_DEBUGP("sd_check_switch_mode (mode = %d, func_group = %d," + "func_to_switch = %d)\n", mode, func_group, func_to_switch); + + cmd[0] = 0x40 | SWITCH; + cmd[1] = mode; + + if (func_group == SD_FUNC_GROUP_1) { + cmd[2] = 0xFF; + cmd[3] = 0xFF; + cmd[4] = 0xF0 + func_to_switch; + } else if (func_group == SD_FUNC_GROUP_3) { + cmd[2] = 0xFF; + cmd[3] = 0xF0 + func_to_switch; + cmd[4] = 0xFF; + } else if (func_group == SD_FUNC_GROUP_4) { + cmd[2] = 0xFF; + cmd[3] = 0x0F + (func_to_switch << 4); + cmd[4] = 0xFF; + } else { + cmd[1] = SD_CHECK_MODE; + cmd[2] = 0xFF; + cmd[3] = 0xFF; + cmd[4] = 0xFF; + } + + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 64, 1, bus_width, buf, + 64, 250); + if (retval != STATUS_SUCCESS) { + rts51x_clear_sd_error(chip); + TRACE_RET(chip, retval); + } + + if (func_group == NO_ARGUMENT) { + sd_card->func_group1_mask = buf[0x0D]; + sd_card->func_group2_mask = buf[0x0B]; + sd_card->func_group3_mask = buf[0x09]; + sd_card->func_group4_mask = buf[0x07]; + + RTS51X_DEBUGP("func_group1_mask = 0x%02x\n", buf[0x0D]); + RTS51X_DEBUGP("func_group2_mask = 0x%02x\n", buf[0x0B]); + RTS51X_DEBUGP("func_group3_mask = 0x%02x\n", buf[0x09]); + RTS51X_DEBUGP("func_group4_mask = 0x%02x\n", buf[0x07]); + } else { + if ((buf[0] == 0) && (buf[1] == 0)) + TRACE_RET(chip, STATUS_FAIL); + retval = + sd_query_switch_result(chip, func_group, func_to_switch, + buf, 64); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int sd_check_switch(struct rts51x_chip *chip, + u8 func_group, u8 func_to_switch, u8 bus_width) +{ + int retval; + int i; + int switch_good = 0; + + for (i = 0; i < 3; i++) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = sd_check_switch_mode(chip, SD_CHECK_MODE, func_group, + func_to_switch, bus_width); + if (retval == STATUS_SUCCESS) { + u8 stat; + + retval = sd_check_switch_mode(chip, SD_SWITCH_MODE, + func_group, func_to_switch, bus_width); + if (retval == STATUS_SUCCESS) { + switch_good = 1; + break; + } + + RTS51X_READ_REG(chip, SD_STAT1, &stat); + + if (stat & SD_CRC16_ERR) { + RTS51X_DEBUGP("SD CRC16 error when switching" + "mode\n"); + TRACE_RET(chip, STATUS_FAIL); + } + } + + wait_timeout(20); + } + + if (!switch_good) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; +} + +static int sd_switch_function(struct rts51x_chip *chip, u8 bus_width) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i; + u8 func_to_switch = 0; + + /* Get supported functions */ + retval = sd_check_switch_mode(chip, SD_CHECK_MODE, + NO_ARGUMENT, NO_ARGUMENT, bus_width); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail); + + for (i = 0; i < 4; i++) { + switch ((u8) (chip->option.sd_speed_prior >> (i * 8))) { + case DDR50_SUPPORT: + if ((sd_card->func_group1_mask & DDR50_SUPPORT_MASK) + && (CHECK_UHS50(chip))) + func_to_switch = DDR50_SUPPORT; + break; + + case SDR50_SUPPORT: + if ((sd_card->func_group1_mask & SDR50_SUPPORT_MASK) + && (CHECK_UHS50(chip))) + func_to_switch = SDR50_SUPPORT; + break; + + case HS_SUPPORT: + if (sd_card->func_group1_mask & HS_SUPPORT_MASK) + func_to_switch = HS_SUPPORT; + break; + + default: + continue; + } + + if (func_to_switch) + break; + } + RTS51X_DEBUGP("SD_FUNC_GROUP_1: func_to_switch = 0x%02x", + func_to_switch); + +#ifdef SUPPORT_SD_LOCK + if ((sd_card->sd_lock_status & SD_SDR_RST) + && (DDR50_SUPPORT == func_to_switch) + && (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) { + func_to_switch = SDR50_SUPPORT; + RTS51X_DEBUGP("Using SDR50 instead of DDR50 for SD Lock\n"); + } +#endif + + if (func_to_switch) { + retval = + sd_check_switch(chip, SD_FUNC_GROUP_1, func_to_switch, + bus_width); + if (retval != STATUS_SUCCESS) { + if (func_to_switch == SDR104_SUPPORT) + sd_card->sd_switch_fail = SDR104_SUPPORT_MASK; + else if (func_to_switch == DDR50_SUPPORT) + sd_card->sd_switch_fail = DDR50_SUPPORT_MASK; + else if (func_to_switch == SDR50_SUPPORT) + sd_card->sd_switch_fail = SDR50_SUPPORT_MASK; + else if (func_to_switch == HS_SUPPORT) + sd_card->sd_switch_fail = HS_SUPPORT_MASK; + + TRACE_RET(chip, retval); + } + + if (func_to_switch == SDR104_SUPPORT) + SET_SD_SDR104(sd_card); + else if (func_to_switch == DDR50_SUPPORT) + SET_SD_DDR50(sd_card); + else if (func_to_switch == SDR50_SUPPORT) + SET_SD_SDR50(sd_card); + else + SET_SD_HS(sd_card); + } + + if (CHK_SD_DDR50(sd_card)) + RTS51X_WRITE_REG(chip, SD_CFG1, 0x0C, SD_DDR_MODE); + + func_to_switch = 0; + if (sd_card->func_group4_mask & CURRENT_LIMIT_400_MASK) + func_to_switch = CURRENT_LIMIT_400; + + if (func_to_switch) { + RTS51X_DEBUGP("Try to switch current_limit_400\n"); + retval = + sd_check_switch(chip, SD_FUNC_GROUP_4, func_to_switch, + bus_width); + RTS51X_DEBUGP("Switch current_limit_400 status: (%d)\n", + retval); + } + + return STATUS_SUCCESS; +} + +static int sd_wait_data_idle(struct rts51x_chip *chip) +{ + int retval = STATUS_TIMEDOUT; + int i; + u8 val = 0; + + for (i = 0; i < 100; i++) { + retval = rts51x_ep0_read_register(chip, SD_DATA_STATE, &val); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + if (val & SD_DATA_IDLE) { + retval = STATUS_SUCCESS; + break; + } + udelay(100); + } + RTS51X_DEBUGP("SD_DATA_STATE: 0x%02x\n", val); + + return retval; +} + +static int sd_sdr_tuning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) +{ + int retval; + u8 cmd[5]; + + retval = sd_change_phase(chip, sample_point, TUNE_RX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + cmd[0] = 0x40 | SEND_TUNING_PATTERN; + cmd[1] = 0; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + + retval = sd_read_data(chip, SD_TM_AUTO_TUNING, + cmd, 5, 0x40, 1, SD_BUS_WIDTH_4, NULL, 0, 100); + if (retval != STATUS_SUCCESS) { + /* Wait till SD DATA IDLE */ + (void)sd_wait_data_idle(chip); + + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int sd_ddr_tuning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd[5]; + + retval = sd_change_phase(chip, sample_point, TUNE_RX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_DEBUGP("sd ddr tuning rx\n"); + + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + cmd[0] = 0x40 | SD_STATUS; + cmd[1] = 0; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + + retval = sd_read_data(chip, SD_TM_NORMAL_READ, + cmd, 5, 64, 1, SD_BUS_WIDTH_4, NULL, 0, 100); + if (retval != STATUS_SUCCESS) { + /* Wait till SD DATA IDLE */ + (void)sd_wait_data_idle(chip); + + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int mmc_ddr_tunning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd[5], bus_width; + + if (CHK_MMC_8BIT(sd_card)) + bus_width = SD_BUS_WIDTH_8; + else if (CHK_MMC_4BIT(sd_card)) + bus_width = SD_BUS_WIDTH_4; + else + bus_width = SD_BUS_WIDTH_1; + + retval = sd_change_phase(chip, sample_point, TUNE_RX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_DEBUGP("mmc ddr tuning rx\n"); + + cmd[0] = 0x40 | SEND_EXT_CSD; + cmd[1] = 0; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + + retval = sd_read_data(chip, SD_TM_NORMAL_READ, + cmd, 5, 0x200, 1, bus_width, NULL, 0, 100); + if (retval != STATUS_SUCCESS) { + /* Wait till SD DATA IDLE */ + (void)sd_wait_data_idle(chip); + + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int sd_sdr_tuning_tx_cmd(struct rts51x_chip *chip, u8 sample_point) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + retval = sd_change_phase(chip, sample_point, TUNE_TX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, + SD_RSP_80CLK_TIMEOUT_EN); + + retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + if (retval != STATUS_SUCCESS) { + if (sd_check_err_code(chip, SD_RSP_TIMEOUT)) { + /* Tunning TX fail */ + rts51x_ep0_write_register(chip, SD_CFG3, + SD_RSP_80CLK_TIMEOUT_EN, 0); + TRACE_RET(chip, STATUS_FAIL); + } + } + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); + + return STATUS_SUCCESS; +} + +static int sd_ddr_tuning_tx_cmd(struct rts51x_chip *chip, u8 sample_point) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 cmd[5], bus_width; + + retval = sd_change_phase(chip, sample_point, TUNE_TX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_SD(sd_card)) { + bus_width = SD_BUS_WIDTH_4; + } else { + if (CHK_MMC_8BIT(sd_card)) + bus_width = SD_BUS_WIDTH_8; + else if (CHK_MMC_4BIT(sd_card)) + bus_width = SD_BUS_WIDTH_4; + else + bus_width = SD_BUS_WIDTH_1; + } + retval = sd_wait_currentstate_dataready(chip, 0x08, 1, 20); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, + SD_RSP_80CLK_TIMEOUT_EN); + + cmd[0] = 0x40 | PROGRAM_CSD; + cmd[1] = 0; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + + retval = sd_write_data(chip, SD_TM_AUTO_WRITE_2, + cmd, 5, 16, 1, bus_width, sd_card->raw_csd, 16, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_sd_error(chip); + /* Tunning TX fail */ + rts51x_ep0_write_register(chip, SD_CFG3, + SD_RSP_80CLK_TIMEOUT_EN, 0); + TRACE_RET(chip, STATUS_FAIL); + } + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); + + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + + return STATUS_SUCCESS; +} + +static u8 sd_search_final_phase(struct rts51x_chip *chip, u32 phase_map, + u8 tune_dir) +{ + struct sd_info *sd_card = &(chip->sd_card); + struct timing_phase_path path[MAX_PHASE + 1]; + int i, j, cont_path_cnt; + int new_block, max_len; + u8 final_phase = 0xFF; + int final_path_idx; + + if (phase_map == 0xffff) { + if (CHK_SD_DDR50(sd_card)) { + if (tune_dir == TUNE_TX) + final_phase = chip->option.ddr50_tx_phase; + else + final_phase = chip->option.ddr50_rx_phase; + RTS51X_DEBUGP("DDR50 tuning dir:%d all pass," + "so select default phase:0x%x.\n", + tune_dir, final_phase); + } else { + if (tune_dir == TUNE_TX) + final_phase = chip->option.sdr50_tx_phase; + else + final_phase = chip->option.sdr50_rx_phase; + RTS51X_DEBUGP("SDR50 tuning dir:%d all pass," + "so select default phase:0x%x.\n", + tune_dir, final_phase); + } + goto Search_Finish; + } + + cont_path_cnt = 0; + new_block = 1; + j = 0; + for (i = 0; i < MAX_PHASE + 1; i++) { + if (phase_map & (1 << i)) { + if (new_block) { + new_block = 0; + j = cont_path_cnt++; + path[j].start = i; + path[j].end = i; + } else { + path[j].end = i; + } + } else { + new_block = 1; + if (cont_path_cnt) { + int idx = cont_path_cnt - 1; + path[idx].len = + path[idx].end - path[idx].start + 1; + path[idx].mid = + path[idx].start + path[idx].len / 2; + } + } + } + + if (cont_path_cnt == 0) { + RTS51X_DEBUGP("No continuous phase path\n"); + goto Search_Finish; + } else { + int idx = cont_path_cnt - 1; + path[idx].len = path[idx].end - path[idx].start + 1; + path[idx].mid = path[idx].start + path[idx].len / 2; + } + + if ((path[0].start == 0) && + (path[cont_path_cnt - 1].end == MAX_PHASE)) { + path[0].start = path[cont_path_cnt - 1].start - MAX_PHASE - 1; + path[0].len += path[cont_path_cnt - 1].len; + path[0].mid = path[0].start + path[0].len / 2; + if (path[0].mid < 0) + path[0].mid += MAX_PHASE + 1; + cont_path_cnt--; + } + max_len = 0; + final_phase = 0; + final_path_idx = 0; + for (i = 0; i < cont_path_cnt; i++) { + if (path[i].len > max_len) { + max_len = path[i].len; + final_phase = (u8) path[i].mid; + final_path_idx = i; + } + + RTS51X_DEBUGP("path[%d].start = %d\n", i, path[i].start); + RTS51X_DEBUGP("path[%d].end = %d\n", i, path[i].end); + RTS51X_DEBUGP("path[%d].len = %d\n", i, path[i].len); + RTS51X_DEBUGP("path[%d].mid = %d\n", i, path[i].mid); + RTS51X_DEBUGP("\n"); + } + + if ((tune_dir == TUNE_TX) && (CHK_SD_SDR50(sd_card)) + && chip->option.sdr50_phase_sel) { + if (max_len > 6) { + int temp_mid = (max_len - 6) / 2; + int temp_final_phase = + path[final_path_idx].end - (max_len - + (3 + temp_mid)); + + if (temp_final_phase < 0) + final_phase = temp_final_phase + MAX_PHASE + 1; + else + final_phase = (u8) temp_final_phase; + } + } + +Search_Finish: + RTS51X_DEBUGP("Final choosen phase: %d\n", final_phase); + return final_phase; +} + +static int sd_tuning_rx(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i, j; + u32 raw_phase_map[3], phase_map; + u8 final_phase; + int (*tuning_cmd) (struct rts51x_chip *chip, u8 sample_point); + + if (CHK_SD(sd_card)) { + if (CHK_SD_DDR50(sd_card)) + tuning_cmd = sd_ddr_tuning_rx_cmd; + else + tuning_cmd = sd_sdr_tuning_rx_cmd; + } else { + if (CHK_MMC_DDR52(sd_card)) + tuning_cmd = mmc_ddr_tunning_rx_cmd; + else + TRACE_RET(chip, STATUS_FAIL); + } + + for (i = 0; i < 3; i++) { + raw_phase_map[i] = 0; + for (j = MAX_PHASE; j >= 0; j--) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = tuning_cmd(chip, (u8) j); + if (retval == STATUS_SUCCESS) + raw_phase_map[i] |= 1 << j; + else + RTS51X_DEBUGP("Tuning phase %d fail\n", j); + } + } + + phase_map = raw_phase_map[0] & raw_phase_map[1] & raw_phase_map[2]; + for (i = 0; i < 3; i++) + RTS51X_DEBUGP("RX raw_phase_map[%d] = 0x%04x\n", i, + raw_phase_map[i]); + RTS51X_DEBUGP("RX phase_map = 0x%04x\n", phase_map); + + final_phase = sd_search_final_phase(chip, phase_map, TUNE_RX); + if (final_phase == 0xFF) + TRACE_RET(chip, STATUS_FAIL); + + retval = tuning_cmd(chip, final_phase); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int sd_ddr_pre_tuning_tx(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 i; + u8 pre_tune_tx_phase; + u32 pre_tune_phase_map; + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, + SD_RSP_80CLK_TIMEOUT_EN); + + pre_tune_tx_phase = 0xFF; + pre_tune_phase_map = 0x0000; + for (i = 0; i < MAX_PHASE + 1; i++) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = sd_change_phase(chip, (u8) i, TUNE_TX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + if ((retval == STATUS_SUCCESS) + || !sd_check_err_code(chip, SD_RSP_TIMEOUT)) + pre_tune_phase_map |= (u32) 1 << i; + } + + RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); + + pre_tune_tx_phase = + sd_search_final_phase(chip, pre_tune_phase_map, TUNE_TX); + if (pre_tune_tx_phase == 0xFF) + TRACE_RET(chip, STATUS_FAIL); + + sd_change_phase(chip, pre_tune_tx_phase, TUNE_TX); + RTS51X_DEBUGP("DDR TX pre tune phase: %d\n", (int)pre_tune_tx_phase); + + return STATUS_SUCCESS; +} + +static int sd_tuning_tx(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i, j; + u32 raw_phase_map[3], phase_map; + u8 final_phase; + int (*tuning_cmd) (struct rts51x_chip *chip, u8 sample_point); + + if (CHK_SD(sd_card)) { + if (CHK_SD_DDR50(sd_card)) + tuning_cmd = sd_ddr_tuning_tx_cmd; + else + tuning_cmd = sd_sdr_tuning_tx_cmd; + } else { + if (CHK_MMC_DDR52(sd_card)) + tuning_cmd = sd_ddr_tuning_tx_cmd; + else + TRACE_RET(chip, STATUS_FAIL); + } + + for (i = 0; i < 3; i++) { + raw_phase_map[i] = 0; + for (j = MAX_PHASE; j >= 0; j--) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = tuning_cmd(chip, (u8) j); + if (retval == STATUS_SUCCESS) + raw_phase_map[i] |= 1 << j; + else + RTS51X_DEBUGP("Tuning phase %d fail\n", j); + } + } + + phase_map = raw_phase_map[0] & raw_phase_map[1] & raw_phase_map[2]; + for (i = 0; i < 3; i++) + RTS51X_DEBUGP("TX raw_phase_map[%d] = 0x%04x\n", i, + raw_phase_map[i]); + RTS51X_DEBUGP("TX phase_map = 0x%04x\n", phase_map); + + final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX); + if (final_phase == 0xFF) + TRACE_RET(chip, STATUS_FAIL); + + retval = tuning_cmd(chip, final_phase); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int sd_sdr_tuning(struct rts51x_chip *chip) +{ + int retval; + + retval = sd_tuning_tx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = sd_tuning_rx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int sd_ddr_tuning(struct rts51x_chip *chip) +{ + int retval; + + if (!(chip->option.sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { + retval = sd_ddr_pre_tuning_tx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + retval = + sd_change_phase(chip, (u8) chip->option.sd_ddr_tx_phase, + TUNE_TX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + retval = sd_tuning_rx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!(chip->option.sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { + retval = sd_tuning_tx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int mmc_ddr_tuning(struct rts51x_chip *chip) +{ + int retval; + + if (!(chip->option.sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { + retval = sd_ddr_pre_tuning_tx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + retval = + sd_change_phase(chip, (u8) chip->option.mmc_ddr_tx_phase, + TUNE_TX); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + retval = sd_tuning_rx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (!(chip->option.sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { + retval = sd_tuning_tx(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +int sd_switch_clock(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int re_tuning = 0; + + retval = rts51x_select_card(chip, SD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_SD30_SPEED(sd_card) || CHK_MMC_DDR52(sd_card)) { + if (sd_card->sd_clock != chip->cur_clk) + re_tuning = 1; + } + + retval = switch_clock(chip, sd_card->sd_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (re_tuning) { + if (CHK_SD(sd_card)) { + if (CHK_SD_DDR50(sd_card)) + retval = sd_ddr_tuning(chip); + else + retval = sd_sdr_tuning(chip); + } else { + if (CHK_MMC_DDR52(sd_card)) + retval = mmc_ddr_tuning(chip); + } + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int sd_prepare_reset(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + if (chip->asic_code) + sd_card->sd_clock = 29; + else + sd_card->sd_clock = CLK_30; + + /* Set SD Clocks */ + retval = sd_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0xFF, + SD_CLK_DIVIDE_128 | SD_20_MODE | SD_BUS_WIDTH_1); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, 0xFF, + SD20_RX_POS_EDGE); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, 0xFF, 0); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_select_card(chip, SD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static void sd_pull_ctl_disable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); + } +} + +static void sd_pull_ctl_enable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xAA); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0xAA); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0xA9); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xA5); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x9A); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0xA5); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x9A); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x65); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x5A); + } +} + +static int sd_init_power(struct rts51x_chip *chip) +{ + int retval; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, LDO3318_PWR_MASK, + LDO_ON); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PAD_CTL, SD_IO_USING_1V8, + SD_IO_USING_3V3); + if (chip->asic_code) + rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, + TUNE_SD18_MASK, TUNE_SD18_3V3); + if (chip->asic_code) + sd_pull_ctl_disable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, + FPGA_SD_PULL_CTL_BIT | 0x20, + FPGA_SD_PULL_CTL_BIT); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); + if (!chip->option.FT2_fast_mode) + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (!chip->option.FT2_fast_mode) { +#ifdef SD_XD_IO_FOLLOW_PWR + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) + rts51x_write_register(chip, CARD_PWR_CTL, + LDO_OFF, LDO_OFF); +#endif + wait_timeout(250); + +#ifdef SD_XD_IO_FOLLOW_PWR + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) { + rts51x_init_cmd(chip); + if (chip->asic_code) + sd_pull_ctl_enable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, + FPGA_PULL_CTL, + FPGA_SD_PULL_CTL_BIT | 0x20, 0); + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + if (chip->asic_code) + rts51x_write_register(chip, CARD_PULL_CTL6, + 0x03, 0x00); + } +#endif + + /* Power on card */ + retval = card_power_on(chip, SD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + wait_timeout(260); + +#ifdef SUPPORT_OCP + rts51x_get_card_status(chip, &(chip->card_status)); + chip->ocp_stat = (chip->card_status >> 4) & 0x03; + + if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { + RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", + chip->ocp_stat); + TRACE_RET(chip, STATUS_FAIL); + } +#endif + } + + rts51x_init_cmd(chip); + if (chip->asic_code) { + sd_pull_ctl_enable(chip); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, + FPGA_SD_PULL_CTL_BIT | 0x20, 0); + } + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SD_XD_IO_FOLLOW_PWR + rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, + XD_INT | MS_INT | SD_INT); +#endif + + RTS51X_WRITE_REG(chip, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); + + return STATUS_SUCCESS; +} + +static int sd_dummy_clock(struct rts51x_chip *chip) +{ + RTS51X_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN); + wait_timeout(5); + RTS51X_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0x00); + + return STATUS_SUCCESS; +} + +int reset_sd(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval, i = 0, j = 0, k = 0, hi_cap_flow = 0; + int sd_dont_switch = 0; + int support_1v8 = 0; + u8 rsp[16]; + u8 switch_bus_width; + u32 voltage = 0; + u8 cmd[5], buf[64]; + u16 sd_card_type; + + SET_SD(sd_card); + CLR_RETRY_SD20_MODE(sd_card); +Switch_Fail: + i = 0; + j = 0; + k = 0; + hi_cap_flow = 0; + support_1v8 = 0; +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) + goto SD_UNLOCK_ENTRY; +#endif + + retval = sd_prepare_reset(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + sd_dummy_clock(chip); + + /* Start Initialization Process of SD Card */ +RTY_SD_RST: + retval = + sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, NULL, + 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + wait_timeout(20); + + retval = + sd_send_cmd_get_rsp(chip, SEND_IF_COND, 0x000001AA, SD_RSP_TYPE_R7, + rsp, 5); + if (retval == STATUS_SUCCESS) { + if ((rsp[4] == 0xAA) && ((rsp[3] & 0x0f) == 0x01)) { + hi_cap_flow = 1; + if (CHK_RETRY_SD20_MODE(sd_card)) { + voltage = + SUPPORT_VOLTAGE | + SUPPORT_HIGH_AND_EXTENDED_CAPACITY; + } else { + voltage = + SUPPORT_VOLTAGE | + SUPPORT_HIGH_AND_EXTENDED_CAPACITY | + SUPPORT_MAX_POWER_PERMANCE | SUPPORT_1V8; + } + } + } + + if (!hi_cap_flow) { + voltage = SUPPORT_VOLTAGE; + + retval = + sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + wait_timeout(20); + } + + /* ACMD41 */ + do { + { + u8 temp = 0; + rts51x_read_register(chip, CARD_INT_PEND, &temp); + RTS51X_DEBUGP("CARD_INT_PEND:%x\n", temp); + if (temp & SD_INT) { + chip->reset_need_retry = 1; + rts51x_write_register(chip, CARD_INT_PEND, + XD_INT | SD_INT | MS_INT, + XD_INT | SD_INT | MS_INT); + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + } + +RTY_CMD55: + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, 0, SD_RSP_TYPE_R1, NULL, + 0); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, SD_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + j++; + if (chip->option.speed_mmc) { + if (j < 2) + goto RTY_CMD55; + else + TRACE_RET(chip, STATUS_FAIL); + } else { + if (j < 3) + goto RTY_SD_RST; + else + TRACE_RET(chip, STATUS_FAIL); + } + } + + retval = + sd_send_cmd_get_rsp(chip, SD_APP_OP_COND, voltage, + SD_RSP_TYPE_R3, rsp, 5); + if (retval != STATUS_SUCCESS) { + k++; + if (k < 3) + goto RTY_SD_RST; + else + TRACE_RET(chip, STATUS_FAIL); + } + + i++; + wait_timeout(20); + } while (!(rsp[1] & 0x80) && (i < 255)); /* Not complete power on */ + + if (i == 255) { + /* Time out */ + TRACE_RET(chip, STATUS_FAIL); + } + + if (hi_cap_flow) { + if (rsp[1] & 0x40) + SET_SD_HCXC(sd_card); + else + CLR_SD_HCXC(sd_card); + if (!CHK_RETRY_SD20_MODE(sd_card)) { + if ((CHK_SD_HCXC(sd_card)) && (CHECK_UHS50(chip))) { + support_1v8 = (rsp[1] & 0x01) ? 1 : 0; + RTS51X_DEBUGP("support_1v8 = %d\n", + support_1v8); + } + } + } else { + CLR_SD_HCXC(sd_card); + support_1v8 = 0; + } + + /* CMD11: Switch Voltage */ + if (support_1v8 && CHECK_UHS50(chip) + && !(((u8) chip->option.sd_speed_prior & SDR104_SUPPORT) == + HS_SUPPORT)) { + retval = sd_voltage_switch(chip); + if (retval != STATUS_SUCCESS) { + SET_RETRY_SD20_MODE(sd_card); + sd_init_power(chip); + RTS51X_DEBUGP("1.8v switch fail\n"); + goto Switch_Fail; + } + } + + /* CMD 2 */ + retval = + sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* CMD 3 */ + retval = + sd_send_cmd_get_rsp(chip, SEND_RELATIVE_ADDR, 0, SD_RSP_TYPE_R6, + rsp, 5); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + sd_card->sd_addr = (u32) rsp[1] << 24; + sd_card->sd_addr += (u32) rsp[2] << 16; + + /* Get CSD register for Calculating Timing,Capacity, + * Check CSD to determaine as if this is the SD ROM card */ + retval = sd_check_csd(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Select SD card */ + retval = sd_select_card(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SUPPORT_SD_LOCK +SD_UNLOCK_ENTRY: + /* Get SD lock status */ + retval = sd_update_lock_status(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + if (sd_card->sd_lock_status & SD_LOCKED) { + sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE | SD_PWD_EXIST); + return STATUS_SUCCESS; + } else if (!(sd_card->sd_lock_status & SD_UNLOCK_POW_ON)) { + sd_card->sd_lock_status &= ~SD_PWD_EXIST; + } +#endif + + /* ACMD42 */ + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + sd_send_cmd_get_rsp(chip, SET_CLR_CARD_DETECT, 0, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (support_1v8) { + /* ACMD6 */ + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Enable 4 bit data bus */ + retval = + sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + switch_bus_width = SD_BUS_WIDTH_4; + } else { + switch_bus_width = SD_BUS_WIDTH_1; + } + + /* Set block length 512 bytes for all block commands */ + retval = sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, + 0x200, SD_RSP_TYPE_R1, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); + + if (!(sd_card->raw_csd[4] & 0x40)) { + sd_dont_switch = 1; + RTS51X_DEBUGP("Not support class ten\n"); + } + + if (!sd_dont_switch) { + /* Check the card whether flow SD1.1 spec or higher */ + retval = sd_check_spec(chip, switch_bus_width); + if (retval == STATUS_SUCCESS) { + retval = sd_switch_function(chip, switch_bus_width); + if (retval != STATUS_SUCCESS) { + if ((sd_card->sd_switch_fail == + SDR104_SUPPORT_MASK) + || (sd_card->sd_switch_fail == + DDR50_SUPPORT_MASK) + || (sd_card->sd_switch_fail == + SDR50_SUPPORT_MASK)) { + sd_init_power(chip); + SET_RETRY_SD20_MODE(sd_card); + } else if (sd_card->sd_switch_fail == + HS_SUPPORT_MASK) { + sd_dont_switch = 1; + } + goto Switch_Fail; + } + } else { + if (support_1v8) { + SET_RETRY_SD20_MODE(sd_card); + sd_init_power(chip); + sd_dont_switch = 1; + + goto Switch_Fail; + } + } + } + + if (!support_1v8) { + /* ACMD6 */ + retval = + sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Enable 4 bit data bus */ + retval = + sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } +#ifdef SUPPORT_SD_LOCK + /* clear 1 bit mode status */ + sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; +#endif + + if (CHK_SD30_SPEED(sd_card)) { + rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, + 0x03); + + retval = sd_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (CHK_SD_DDR50(sd_card)) + retval = sd_ddr_tuning(chip); + else + retval = sd_sdr_tuning(chip); + + if (retval != STATUS_SUCCESS) { + SET_RETRY_SD20_MODE(sd_card); + RTS51X_DEBUGP("tuning phase fail,goto SD20 mode\n"); + sd_init_power(chip); + CLR_SD30_SPEED(sd_card); + goto Switch_Fail; + } + if (STATUS_SUCCESS == + sd_wait_currentstate_dataready(chip, 0x08, 1, 20)) { + cmd[0] = 0x40 | READ_SINGLE_BLOCK; + cmd[1] = 0x00; + cmd[2] = 0x00; + cmd[3] = 0x00; + cmd[4] = 0x00; + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 512, + 1, SD_BUS_WIDTH_4, NULL, 0, 600); + if (retval != STATUS_SUCCESS) { + SET_RETRY_SD20_MODE(sd_card); + RTS51X_DEBUGP("read lba0 fail," + "goto SD20 mode\n"); + sd_init_power(chip); + CLR_SD30_SPEED(sd_card); + goto Switch_Fail; + } + } + } + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + + retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + if (retval == STATUS_SUCCESS) { + int ret; + cmd[0] = 0x40 | SEND_STATUS; + cmd[1] = 0x00; + cmd[2] = 0x00; + cmd[3] = 0x00; + cmd[4] = 0x00; + ret = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 64, 1, + SD_BUS_WIDTH_4, buf, 64, 600); + if (ret == STATUS_SUCCESS) { + sd_card_type = ((u16) buf[2] << 8) | (u16) buf[3]; + RTS51X_DEBUGP("sd_card_type:0x%4x\n", sd_card_type); + if ((sd_card_type == 0x0001) + || (sd_card_type == 0x0002)) + chip->card_wp |= SD_CARD; + } else { + rts51x_clear_sd_error(chip); + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + } + } else { + rts51x_clear_sd_error(chip); + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + } + + /* Check SD Machanical Write-Protect Switch */ + retval = rts51x_get_card_status(chip, &(chip->card_status)); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (chip->card_status & SD_WP) + chip->card_wp |= SD_CARD; + + chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; + +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } +#endif + + return STATUS_SUCCESS; +} + +static int mmc_test_switch_bus(struct rts51x_chip *chip, u8 width) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 buf[8] = { 0 }, bus_width; + u16 byte_cnt; + int len; + + retval = + sd_send_cmd_get_rsp(chip, BUSTEST_W, 0, SD_RSP_TYPE_R1, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (width == MMC_8BIT_BUS) { + buf[0] = 0x55; + buf[1] = 0xAA; + len = 8; + byte_cnt = 8; + bus_width = SD_BUS_WIDTH_8; + } else { + buf[0] = 0x5A; + len = 4; + byte_cnt = 4; + bus_width = SD_BUS_WIDTH_4; + } + + retval = sd_write_data(chip, SD_TM_AUTO_WRITE_3, + NULL, 0, byte_cnt, 1, bus_width, buf, len, 100); + if (retval != STATUS_SUCCESS) { + u8 val1 = 0, val2 = 0; + rts51x_ep0_read_register(chip, SD_STAT1, &val1); + rts51x_ep0_read_register(chip, SD_STAT2, &val2); + rts51x_clear_sd_error(chip); + if ((val1 & 0xE0) || val2) + TRACE_RET(chip, STATUS_FAIL); + } + RTS51X_DEBUGP("SD/MMC CMD %d\n", BUSTEST_R); + + rts51x_init_cmd(chip); + + /* CMD14 */ + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | BUSTEST_R); + + if (width == MMC_8BIT_BUS) + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x08); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x04); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_NO_CHECK_CRC16 | + SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_NORMAL_READ | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, + SD_TRANSFER_END); + + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2, 0, 0); + if (width == MMC_8BIT_BUS) { + len = 3; + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 1, 0, 0); + } else { + len = 2; + } + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, len, 100); + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + rts51x_read_rsp_buf(chip, 1, buf, 2); + + if (width == MMC_8BIT_BUS) { + RTS51X_DEBUGP("BUSTEST_R [8bits]: 0x%02x 0x%02x\n", + buf[0], buf[1]); + if ((buf[0] == 0xAA) && (buf[1] == 0x55)) { + u8 rsp[5]; + u32 arg; + + if (CHK_MMC_DDR52(sd_card)) + arg = 0x03B70600; + else + arg = 0x03B70200; + /* Switch MMC to 8-bit mode */ + retval = + sd_send_cmd_get_rsp(chip, SWITCH, arg, + SD_RSP_TYPE_R1b, rsp, 5); + if ((retval == STATUS_SUCCESS) + && !(rsp[4] & MMC_SWITCH_ERR)) + return STATUS_SUCCESS; + } + } else { + RTS51X_DEBUGP("BUSTEST_R [4bits]: 0x%02x\n", buf[0]); + if (buf[0] == 0xA5) { + u8 rsp[5]; + u32 arg; + + if (CHK_MMC_DDR52(sd_card)) + arg = 0x03B70500; + else + arg = 0x03B70100; + /* Switch MMC to 4-bit mode */ + retval = + sd_send_cmd_get_rsp(chip, SWITCH, arg, + SD_RSP_TYPE_R1b, rsp, 5); + if ((retval == STATUS_SUCCESS) + && !(rsp[4] & MMC_SWITCH_ERR)) + return STATUS_SUCCESS; + } + } + + TRACE_RET(chip, STATUS_FAIL); +} + +static int mmc_switch_timing_bus(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + u8 card_type, card_type_mask = 0; + u8 buf[6]; + + CLR_MMC_HS(sd_card); + + RTS51X_DEBUGP("SD/MMC CMD %d\n", SEND_EXT_CSD); + + rts51x_init_cmd(chip); + + /* SEND_EXT_CSD command */ + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, + 0x40 | SEND_EXT_CSD); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 2); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | SD_NO_WAIT_BUSY_END + | SD_CHECK_CRC7 | SD_RSP_LEN_6); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_NORMAL_READ | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, + SD_TRANSFER_END); + + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 196, 0xFF, 0); + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 212, 0xFF, 0); + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 213, 0xFF, 0); + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 214, 0xFF, 0); + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 215, 0xFF, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 6, 1000); + + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + if (retval == STATUS_TIMEDOUT) { + rts51x_clear_sd_error(chip); + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + } + TRACE_RET(chip, STATUS_FAIL); + } + + rts51x_read_rsp_buf(chip, 0, buf, 6); + + if (buf[0] & SD_TRANSFER_ERR) { + sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + TRACE_RET(chip, STATUS_FAIL); + } + if (CHK_MMC_SECTOR_MODE(sd_card)) + sd_card->capacity = + ((u32) buf[5] << 24) | ((u32) buf[4] << 16) | + ((u32) buf[3] << 8) | ((u32) buf[2]); +#ifdef SUPPORT_SD_LOCK + if (!(sd_card->sd_lock_status & SD_SDR_RST) && CHECK_UHS50(chip)) + card_type_mask = 0x07; + else + card_type_mask = 0x03; +#else + if (CHECK_UHS50(chip)) + card_type_mask = 0x07; + else + card_type_mask = 0x03; +#endif + + card_type = buf[1] & card_type_mask; + if (card_type) { + /* CARD TYPE FIELD = DDR52MHz, 52MHz or 26MHz */ + u8 rsp[5]; + + if (card_type & 0x04) + SET_MMC_DDR52(sd_card); + else if (card_type & 0x02) + SET_MMC_52M(sd_card); + else + SET_MMC_26M(sd_card); + + retval = + sd_send_cmd_get_rsp(chip, SWITCH, 0x03B90100, + SD_RSP_TYPE_R1b, rsp, 5); + if ((retval != STATUS_SUCCESS) || (rsp[4] & MMC_SWITCH_ERR)) + CLR_MMC_HS(sd_card); + } + sd_choose_proper_clock(chip); + retval = switch_clock(chip, sd_card->sd_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* Test Bus Procedure */ + if (mmc_test_switch_bus(chip, MMC_8BIT_BUS) == STATUS_SUCCESS) { + SET_MMC_8BIT(sd_card); + chip->card_bus_width[chip->card2lun[SD_CARD]] = 8; +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; +#endif + } else if (mmc_test_switch_bus(chip, MMC_4BIT_BUS) == STATUS_SUCCESS) { + SET_MMC_4BIT(sd_card); + chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; +#endif + } else { + CLR_MMC_8BIT(sd_card); + CLR_MMC_4BIT(sd_card); + } + + return STATUS_SUCCESS; +} + +static int reset_mmc(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval, i = 0, j = 0, k = 0; + u8 rsp[16]; + u8 spec_ver = 0; + u8 change_to_ddr52 = 1; + u8 cmd[5]; + +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) + goto MMC_UNLOCK_ENTRY; +#endif + +MMC_DDR_FAIL: + + retval = sd_prepare_reset(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + SET_MMC(sd_card); + +RTY_MMC_RST: + retval = + sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, NULL, + 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + do { + { + u8 temp = 0; + rts51x_read_register(chip, CARD_INT_PEND, &temp); + if (temp & SD_INT) { + chip->reset_need_retry = 1; + rts51x_write_register(chip, CARD_INT_PEND, + XD_INT | SD_INT | MS_INT, + XD_INT | SD_INT | MS_INT); + sd_set_reset_fail(chip, MMC_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + } + + /* CMD 1 */ + retval = sd_send_cmd_get_rsp(chip, SEND_OP_COND, + (SUPPORT_VOLTAGE | 0x40000000), + SD_RSP_TYPE_R3, rsp, 5); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + sd_set_reset_fail(chip, MMC_RESET_FAIL); + TRACE_RET(chip, STATUS_FAIL); + } + + if (sd_check_err_code(chip, SD_BUSY) + || sd_check_err_code(chip, SD_TO_ERR)) { + k++; + if (k < 20) { + sd_clr_err_code(chip); + goto RTY_MMC_RST; + } else { + TRACE_RET(chip, STATUS_FAIL); + } + } else { + j++; + if (j < 100) { + sd_clr_err_code(chip); + goto RTY_MMC_RST; + } else { + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + wait_timeout(20); + i++; + } while (!(rsp[1] & 0x80) && (i < 100)); /* Not complete power on */ + + if (i == 100) { + /* Time out */ + TRACE_RET(chip, STATUS_FAIL); + } + + if ((rsp[1] & 0x60) == 0x40) + SET_MMC_SECTOR_MODE(sd_card); + else + CLR_MMC_SECTOR_MODE(sd_card); + + /* CMD 2 */ + retval = + sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2, NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* CMD 3 */ + sd_card->sd_addr = 0x00100000; + retval = + sd_send_cmd_get_rsp(chip, SET_RELATIVE_ADDR, sd_card->sd_addr, + SD_RSP_TYPE_R6, rsp, 5); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* Get CSD register for Calculating Timing,Capacity + * Check CSD to determaine as if this is the SD ROM card */ + retval = sd_check_csd(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + /* Get MMC Spec_Ver in the CSD register */ + spec_ver = (sd_card->raw_csd[0] & 0x3C) >> 2; + + /* Select MMC card */ + retval = sd_select_card(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + /* Set block length 512 bytes for all block commands */ + retval = + sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, SD_RSP_TYPE_R1, NULL, + 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SUPPORT_SD_LOCK +MMC_UNLOCK_ENTRY: + /* Get SD lock status */ + retval = sd_update_lock_status(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); +#endif + + RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); + + if (chip->ic_version < 2) + rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, + 0x02); + rts51x_write_register(chip, CARD_DRIVE_SEL, SD20_DRIVE_MASK, DRIVE_8mA); + + chip->card_bus_width[chip->card2lun[SD_CARD]] = 1; + if (spec_ver == 4) { + /* MMC 4.x Cards */ + (void)mmc_switch_timing_bus(chip); + } + + if (CHK_MMC_SECTOR_MODE(sd_card) && (sd_card->capacity == 0)) + TRACE_RET(chip, STATUS_FAIL); + + if (CHK_MMC_DDR52(sd_card) && change_to_ddr52) { + /* Card is extracted while identifying */ + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + retval = sd_set_init_para(chip); + if (retval != STATUS_SUCCESS) { + CLR_MMC_DDR52(sd_card); + sd_init_power(chip); + change_to_ddr52 = 0; + goto MMC_DDR_FAIL; + } + + retval = mmc_ddr_tuning(chip); + if (retval != STATUS_SUCCESS) { + CLR_MMC_DDR52(sd_card); + sd_init_power(chip); + change_to_ddr52 = 0; + goto MMC_DDR_FAIL; + } + + if (STATUS_SUCCESS == + sd_wait_currentstate_dataready(chip, 0x08, 1, 20)) { + cmd[0] = 0x40 | READ_SINGLE_BLOCK; + cmd[1] = 0x00; + cmd[2] = 0x00; + cmd[3] = 0x00; + cmd[4] = 0x00; + if (CHK_MMC_8BIT(sd_card)) { + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, + 5, 512, 1, SD_BUS_WIDTH_8, + NULL, 0, 600); + } else if (CHK_MMC_4BIT(sd_card)) { + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, + 5, 512, 1, SD_BUS_WIDTH_4, + NULL, 0, 600); + } else { + retval = + sd_read_data(chip, SD_TM_NORMAL_READ, cmd, + 5, 512, 1, SD_BUS_WIDTH_1, + NULL, 0, 600); + } + + if (retval != STATUS_SUCCESS) { + CLR_MMC_DDR52(sd_card); + change_to_ddr52 = 0; + RTS51X_DEBUGP("read lba0 fail," + "goto SD20 mode\n"); + sd_init_power(chip); + goto MMC_DDR_FAIL; + } + } + } +#ifdef SUPPORT_SD_LOCK + if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } +#endif + + retval = rts51x_get_card_status(chip, &(chip->card_status)); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (chip->card_status & SD_WP) + chip->card_wp |= SD_CARD; + + return STATUS_SUCCESS; +} + +int reset_sd_card(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + int i; + + memset(sd_card, 0, sizeof(struct sd_info)); + + /* Init variables */ + sd_card->sd_type = 0; + sd_card->seq_mode = 0; + sd_card->sd_data_buf_ready = 0; + sd_card->capacity = 0; + sd_card->sd_switch_fail = 0; + +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status = 0; + sd_card->sd_erase_status = 0; +#endif + + sd_clear_reset_fail(chip); + enable_card_clock(chip, SD_CARD); + + sd_init_power(chip); + + chip->reset_need_retry = 0; + for (i = 0; i < 3; i++) { + if (!chip->option.reset_mmc_first) { /* reset sd first */ + retval = reset_sd(chip); + if (retval != STATUS_SUCCESS) { + /* Switch SD bus to 3V3 signal */ + RTS51X_WRITE_REG(chip, SD_PAD_CTL, + SD_IO_USING_1V8, 0); + if (sd_check_reset_fail(chip, SD_RESET_FAIL)) + sd_clear_reset_fail(chip); + else + retval = reset_mmc(chip); + } + } else { /* reset MMC first */ + retval = reset_mmc(chip); + if (retval != STATUS_SUCCESS) { + if (sd_check_reset_fail(chip, MMC_RESET_FAIL)) { + sd_clear_reset_fail(chip); + } else { + retval = reset_sd(chip); + if (retval != STATUS_SUCCESS) { + /* Switch SD bus to + * 3V3 signal */ + RTS51X_WRITE_REG(chip, + SD_PAD_CTL, + SD_IO_USING_1V8, 0); + } + } + } + } + + if ((retval == STATUS_SUCCESS) || (!chip->reset_need_retry)) { + /* if reset success or don't need retry,then break */ + break; + } + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { + /* card is extracted */ + break; + } + RTS51X_DEBUGP("retry reset sd card,%d\n", i); + chip->reset_need_retry = 0; + } + + sd_clear_reset_fail(chip); + chip->reset_need_retry = 0; + + if (retval == STATUS_SUCCESS) { + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, SD_CLK_DIVIDE_MASK, + SD_CLK_DIVIDE_0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 2); + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity = 0; + if (chip->option.reset_or_rw_fail_set_pad_drive) { + rts51x_write_register(chip, CARD_DRIVE_SEL, + SD20_DRIVE_MASK, DRIVE_8mA); + } + TRACE_RET(chip, STATUS_FAIL); + } + + chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity; + + if (chip->option.sd_send_status_en) { + sd_card->sd_send_status_en = 1; + } else { + if (sd_card->capacity > 0x20000) { /* 64MB */ + sd_card->sd_send_status_en = 0; + } else { + sd_card->sd_send_status_en = 1; + } + } + RTS51X_DEBUGP("sd_card->sd_send_status = %d\n", + sd_card->sd_send_status_en); + + retval = sd_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_DEBUGP("sd_card->sd_type = 0x%x\n", sd_card->sd_type); + + return STATUS_SUCCESS; +} + +#define WAIT_DATA_READY_RTY_CNT 255 + +static int wait_data_buf_ready(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int i, retval; + + for (i = 0; i < WAIT_DATA_READY_RTY_CNT; i++) { + if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + sd_card->sd_data_buf_ready = 0; + + retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, + sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (sd_card->sd_data_buf_ready) + return sd_send_cmd_get_rsp(chip, SEND_STATUS, + sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0); + } + + sd_set_err_code(chip, SD_TO_ERR); + + TRACE_RET(chip, STATUS_FAIL); +} + +void sd_stop_seq_mode(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + if (sd_card->seq_mode) { + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + return; + + retval = sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, + SD_RSP_TYPE_R1b, NULL, 0); + if (retval != STATUS_SUCCESS) + sd_set_err_code(chip, SD_STS_ERR); + sd_card->seq_mode = 0; + + rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, + FIFO_FLUSH); + } +} + +static inline int sd_auto_tune_clock(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + if (chip->asic_code) { + if (sd_card->sd_clock > 30) + sd_card->sd_clock -= 20; + } else { + if (sd_card->sd_clock == CLK_100) + sd_card->sd_clock = CLK_80; + else if (sd_card->sd_clock == CLK_80) + sd_card->sd_clock = CLK_60; + else if (sd_card->sd_clock == CLK_60) + sd_card->sd_clock = CLK_50; + } + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int sd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt) +{ + struct sd_info *sd_card = &(chip->sd_card); + u32 data_addr; + int retval; + u8 flag; + unsigned int pipe; + u8 stageflag; + + sd_card->counter = 0; + + if (!CHK_SD_HCXC(sd_card) && !CHK_MMC_SECTOR_MODE(sd_card)) + data_addr = start_sector << 9; + else + data_addr = start_sector; + + RTS51X_DEBUGP("sd_rw, data_addr = 0x%x\n", data_addr); + + sd_clr_err_code(chip); + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (sd_card->seq_mode && ((sd_card->pre_dir != srb->sc_data_direction) + || + ((sd_card->pre_sec_addr + + sd_card->pre_sec_cnt) != start_sector))) { + if ((sd_card->pre_dir == DMA_FROM_DEVICE) + && !CHK_SD30_SPEED(sd_card) + && !CHK_SD_HS(sd_card) + && !CHK_MMC_HS(sd_card) + && sd_card->sd_send_status_en) { + sd_send_cmd_get_rsp(chip, SEND_STATUS, + sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + } + + retval = + sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, + SD_RSP_TYPE_R1b, NULL, 0); + if (retval != STATUS_SUCCESS) { + sd_set_err_code(chip, SD_STS_ERR); + TRACE_RET(chip, sd_parse_err_code(chip)); + } + + sd_card->seq_mode = 0; + + RTS51X_WRITE_REG(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); + + if (!CHK_SD30_SPEED(sd_card) + && !CHK_SD_HS(sd_card) + && !CHK_MMC_HS(sd_card) + && sd_card->sd_send_status_en) { + /* random rw, so pre_sec_cnt < 0x80 */ + sd_send_cmd_get_rsp(chip, SEND_STATUS, + sd_card->sd_addr, SD_RSP_TYPE_R1, + NULL, 0); + } + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, + (u8) sector_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, + (u8) (sector_cnt >> 8)); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + + if (CHK_MMC_8BIT(sd_card)) + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, + SD_BUS_WIDTH_8); + else if (CHK_MMC_4BIT(sd_card) || CHK_SD(sd_card)) + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, + SD_BUS_WIDTH_4); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, + SD_BUS_WIDTH_1); + + if (sd_card->seq_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_NO_CALCULATE_CRC7 | SD_CHECK_CRC16 | + SD_NO_WAIT_BUSY_END | SD_NO_CHECK_CRC7 | + SD_RSP_LEN_0); + + trans_dma_enable(srb->sc_data_direction, chip, sector_cnt * 512, + DMA_512); + + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + flag = MODE_CDIR; + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_READ_3 | SD_TRANSFER_START); + } else { + flag = MODE_CDOR; + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); + } + + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, flag, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + RTS51X_DEBUGP("SD/MMC CMD %d\n", READ_MULTIPLE_BLOCK); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, + 0x40 | READ_MULTIPLE_BLOCK); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, + (u8) (data_addr >> 24)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, + (u8) (data_addr >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, + (u8) (data_addr >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, + (u8) data_addr); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | + SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | + SD_RSP_LEN_6); + + trans_dma_enable(srb->sc_data_direction, chip, + sector_cnt * 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_READ_2 | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDIR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } else { + retval = rts51x_send_cmd(chip, MODE_C, 50); + if (retval != STATUS_SUCCESS) { + rts51x_clear_sd_error(chip); + + sd_set_err_code(chip, SD_TO_ERR); + TRACE_RET(chip, sd_parse_err_code(chip)); + } + + retval = wait_data_buf_ready(chip); + if (retval != STATUS_SUCCESS) { + sd_set_err_code(chip, SD_TO_ERR); + TRACE_RET(chip, sd_parse_err_code(chip)); + } + + retval = sd_send_cmd_get_rsp(chip, WRITE_MULTIPLE_BLOCK, + data_addr, SD_RSP_TYPE_R1, + NULL, 0); + if (retval != STATUS_SUCCESS) { + sd_set_err_code(chip, SD_CRC_ERR); + TRACE_RET(chip, sd_parse_err_code(chip)); + } + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, + SD_NO_CALCULATE_CRC7 | SD_CHECK_CRC16 | + SD_NO_WAIT_BUSY_END | SD_NO_CHECK_CRC7 | + SD_RSP_LEN_0); + + trans_dma_enable(srb->sc_data_direction, chip, + sector_cnt * 512, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + sd_card->seq_mode = 1; + } + + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + pipe = RCV_BULK_PIPE(chip); + stageflag = STAGE_DI; + } else { + pipe = SND_BULK_PIPE(chip); + stageflag = STAGE_DO; + } + + retval = + rts51x_transfer_data_rcc(chip, pipe, scsi_sglist(srb), + scsi_bufflen(srb), scsi_sg_count(srb), + NULL, 10000, stageflag); + if (retval != STATUS_SUCCESS) { + u8 stat = 0; + int err = retval; + + sd_print_debug_reg(chip); + + rts51x_ep0_read_register(chip, SD_STAT1, &stat); + RTS51X_DEBUGP("SD_STAT1: 0x%x\n", stat); + + rts51x_clear_sd_error(chip); + + retval = + sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, + SD_RSP_TYPE_R1b, NULL, 0); + if (retval != STATUS_SUCCESS) { + sd_set_err_code(chip, SD_STS_ERR); + TRACE_RET(chip, retval); + } + + if (stat & (SD_CRC7_ERR | SD_CRC16_ERR | SD_CRC_WRITE_ERR)) { + RTS51X_DEBUGP("SD CRC error, tune clock!\n"); + sd_auto_tune_clock(chip); + } + + sd_card->seq_mode = 0; + + TRACE_RET(chip, err); + } + retval = rts51x_get_rsp(chip, 1, 2000); + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + rts51x_clear_sd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + sd_card->pre_sec_addr = start_sector; + sd_card->pre_sec_cnt = sector_cnt; + sd_card->pre_dir = srb->sc_data_direction; + + return STATUS_SUCCESS; +} + +void sd_cleanup_work(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + + if (sd_card->seq_mode) { + RTS51X_DEBUGP("SD: stop transmission\n"); + sd_stop_seq_mode(chip); + sd_card->counter = 0; + } +} + +inline void sd_fill_power_off_card3v3(struct rts51x_chip *chip) +{ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, SD_CLK_EN, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); + if (!chip->option.FT2_fast_mode) { +#ifdef SD_XD_IO_FOLLOW_PWR + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, + POWER_MASK | LDO_OFF, + POWER_OFF | LDO_OFF); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, + POWER_MASK, POWER_OFF); +#else + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); +#endif + } +} + +int sd_power_off_card3v3(struct rts51x_chip *chip) +{ + int retval; + + rts51x_init_cmd(chip); + + sd_fill_power_off_card3v3(chip); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SD_XD_IO_FOLLOW_PWR + if (!chip->option.FT2_fast_mode) + wait_timeout(chip->option.D3318_off_delay); +#endif + + return STATUS_SUCCESS; +} + +int release_sd_card(struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + + RTS51X_DEBUGP("elease_sd_card\n"); + + chip->card_ready &= ~SD_CARD; + chip->card_fail &= ~SD_CARD; + chip->card_wp &= ~SD_CARD; + +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status = 0; + sd_card->sd_erase_status = 0; +#endif + + memset(sd_card->raw_csd, 0, 16); + memset(sd_card->raw_scr, 0, 8); + + rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); + rts51x_write_register(chip, SD_PAD_CTL, SD_IO_USING_1V8, 0); + if (CHECK_PKG(chip, LQFP48) || chip->option.rts5129_D3318_off_enable) + sd_power_off_card3v3(chip); + + rts51x_init_cmd(chip); + if (!(CHECK_PKG(chip, LQFP48) || chip->option.rts5129_D3318_off_enable)) + sd_fill_power_off_card3v3(chip); + + if (chip->asic_code) + sd_pull_ctl_disable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, + FPGA_SD_PULL_CTL_BIT | 0x20, + FPGA_SD_PULL_CTL_BIT); + + /* Switch LDO3318 to 3.3V */ + rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, TUNE_SD18_MASK, + TUNE_SD18_3V3); + + if (CHK_MMC_DDR52(sd_card) && CHK_MMC_8BIT(sd_card)) + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, + EXTEND_DMA1_ASYNC_SIGNAL, + EXTEND_DMA1_ASYNC_SIGNAL); + if (CHK_SD30_SPEED(sd_card) || CHK_MMC(sd_card)) + rts51x_add_cmd(chip, WRITE_REG_CMD, SD30_DRIVE_SEL, + SD30_DRIVE_MASK, chip->option.sd30_pad_drive); + /* Suspend LDO3318 */ + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, LDO3318_PWR_MASK, + LDO_SUSPEND); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + wait_timeout(20); + + return STATUS_SUCCESS; +} diff --git a/drivers/staging/rts5139/sd.h b/drivers/staging/rts5139/sd.h new file mode 100644 index 00000000000..0805edcaea8 --- /dev/null +++ b/drivers/staging/rts5139/sd.h @@ -0,0 +1,304 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_SD_H +#define __RTS51X_SD_H + +#include "rts51x_chip.h" + +#define SD_MAX_RETRY_COUNT 3 + +#define SUPPORT_VOLTAGE 0x003C0000 + +#define SD_RESET_FAIL 0x01 +#define MMC_RESET_FAIL 0x02 + +/* Error Code */ +#define SD_NO_ERROR 0x0 +#define SD_CRC_ERR 0x80 +#define SD_TO_ERR 0x40 +#define SD_NO_CARD 0x20 +#define SD_BUSY 0x10 +#define SD_STS_ERR 0x08 +#define SD_RSP_TIMEOUT 0x04 + +/* MMC/SD Command Index */ +/* Basic command (class 0) */ +#define GO_IDLE_STATE 0 +#define SEND_OP_COND 1 /* reserved for SD */ +#define ALL_SEND_CID 2 +#define SET_RELATIVE_ADDR 3 +#define SEND_RELATIVE_ADDR 3 +#define SET_DSR 4 +#define IO_SEND_OP_COND 5 +#define SWITCH 6 +#define SELECT_CARD 7 +#define DESELECT_CARD 7 +/* CMD8 is "SEND_EXT_CSD" for MMC4.x Spec + * while is "SEND_IF_COND" for SD 2.0 */ +#define SEND_EXT_CSD 8 +#define SEND_IF_COND 8 +/* end */ +#define SEND_CSD 9 +#define SEND_CID 10 +#define VOLTAGE_SWITCH 11 +#define READ_DAT_UTIL_STOP 11 /* reserved for SD */ +#define STOP_TRANSMISSION 12 +#define SEND_STATUS 13 +#define GO_INACTIVE_STATE 15 + +/* Block oriented read commands (class 2) */ +#define SET_BLOCKLEN 16 +#define READ_SINGLE_BLOCK 17 +#define READ_MULTIPLE_BLOCK 18 +#define SEND_TUNING_PATTERN 19 + +/* Bus Width Test */ +#define BUSTEST_R 14 +#define BUSTEST_W 19 +/* end */ + +/* Block oriented write commands (class 4) */ +#define WRITE_BLOCK 24 +#define WRITE_MULTIPLE_BLOCK 25 +#define PROGRAM_CSD 27 + +/* Erase commands */ +#define ERASE_WR_BLK_START 32 +#define ERASE_WR_BLK_END 33 +#define ERASE_CMD 38 + +/* Block Oriented Write Protection Commands */ +#define LOCK_UNLOCK 42 + +#define IO_RW_DIRECT 52 + +/* Application specific commands (class 8) */ +#define APP_CMD 55 +#define GEN_CMD 56 + +/* SD Application command Index */ +#define SET_BUS_WIDTH 6 +#define SD_STATUS 13 +#define SEND_NUM_WR_BLOCKS 22 +#define SET_WR_BLK_ERASE_COUNT 23 +#define SD_APP_OP_COND 41 +#define SET_CLR_CARD_DETECT 42 +#define SEND_SCR 51 + +/* SD TIMEOUT function return error */ +#define SD_READ_COMPLETE 0x00 +#define SD_READ_TO 0x01 +#define SD_READ_ADVENCE 0x02 + +/* SD v1.1 CMD6 SWITCH function */ +#define SD_CHECK_MODE 0x00 +#define SD_SWITCH_MODE 0x80 +#define SD_FUNC_GROUP_1 0x01 +#define SD_FUNC_GROUP_2 0x02 +#define SD_FUNC_GROUP_3 0x03 +#define SD_FUNC_GROUP_4 0x04 +#define SD_CHECK_SPEC_V1_1 0xFF + +/* SD Command Argument */ +#define NO_ARGUMENT 0x00 +#define CHECK_PATTERN 0x000000AA +#define VOLTAGE_SUPPLY_RANGE 0x00000100 /* 2.7~3.6V */ +#define SUPPORT_HIGH_AND_EXTENDED_CAPACITY 0x40000000 +#define SUPPORT_MAX_POWER_PERMANCE 0x10000000 +#define SUPPORT_1V8 0x01000000 + +/* Switch Command Error Code */ +#define SWTICH_NO_ERR 0x00 +#define CARD_NOT_EXIST 0x01 +#define SPEC_NOT_SUPPORT 0x02 +#define CHECK_MODE_ERR 0x03 +#define CHECK_NOT_READY 0x04 +#define SWITCH_CRC_ERR 0x05 +#define SWITCH_MODE_ERR 0x06 +#define SWITCH_PASS 0x07 + +#ifdef SUPPORT_SD_LOCK +/* CMD42 Parameter */ +#define SD_ERASE 0x08 +#define SD_LOCK 0x04 +#define SD_UNLOCK 0x00 +#define SD_CLR_PWD 0x02 +#define SD_SET_PWD 0x01 + +#define SD_PWD_LEN 0x10 + +/* SD lock unlock Status */ +#define SD_LOCKED 0x80 /* Global lock status */ +#define SD_LOCK_1BIT_MODE 0x40 /**/ +#define SD_PWD_EXIST 0x20 +#define SD_UNLOCK_POW_ON 0x01 /**/ +#define SD_SDR_RST 0x02 /* Reset SD30 card with current DDR mode to SDR mode. */ +/* g_bySDEraseStatus */ +#define SD_NOT_ERASE 0x00 +#define SD_UNDER_ERASING 0x01 +#define SD_COMPLETE_ERASE 0x02 +/* SD_RW FAIL status */ +#define SD_RW_FORBIDDEN 0x0F /* read/write is forbidden (SD card) */ +#endif +/* Function Group Definition */ +/* Function Group 1 */ +#define HS_SUPPORT 0x01 +#define SDR50_SUPPORT 0x02 +#define SDR104_SUPPORT 0x03 +#define DDR50_SUPPORT 0x04 +#define HS_SUPPORT_MASK 0x02 +#define SDR50_SUPPORT_MASK 0x04 +#define SDR104_SUPPORT_MASK 0x08 +#define DDR50_SUPPORT_MASK 0x10 +#define HS_QUERY_SWITCH_OK 0x01 +#define SDR50_QUERY_SWITCH_OK 0x02 +#define SDR104_QUERY_SWITCH_OK 0x03 +#define DDR50_QUERY_SWITCH_OK 0x04 +#define HS_SWITCH_BUSY 0x02 +#define SDR50_SWITCH_BUSY 0x04 +#define SDR104_SWITCH_BUSY 0x08 +#define DDR50_SWITCH_BUSY 0x10 +#define FUNCTION_GROUP1_SUPPORT_OFFSET 0x0D +#define FUNCTION_GROUP1_QUERY_SWITCH_OFFSET 0x10 +#define FUNCTION_GROUP1_CHECK_BUSY_OFFSET 0x1D +/* Function Group 3 */ +#define DRIVING_TYPE_A 0x01 +#define DRIVING_TYPE_B 0x00 +#define DRIVING_TYPE_C 0x02 +#define DRIVING_TYPE_D 0x03 +#define DRIVING_TYPE_A_MASK 0x02 +#define DRIVING_TYPE_B_MASK 0x01 +#define DRIVING_TYPE_C_MASK 0x04 +#define DRIVING_TYPE_D_MASK 0x08 +#define TYPE_A_QUERY_SWITCH_OK 0x01 +#define TYPE_B_QUERY_SWITCH_OK 0x00 +#define TYPE_C_QUERY_SWITCH_OK 0x02 +#define TYPE_D_QUERY_SWITCH_OK 0x03 +#define TYPE_A_SWITCH_BUSY 0x02 +#define TYPE_B_SWITCH_BUSY 0x01 +#define TYPE_C_SWITCH_BUSY 0x04 +#define TYPE_D_SWITCH_BUSY 0x08 +#define FUNCTION_GROUP3_SUPPORT_OFFSET 0x09 +#define FUNCTION_GROUP3_QUERY_SWITCH_OFFSET 0x0F +#define FUNCTION_GROUP3_CHECK_BUSY_OFFSET 0x19 +/* Function Group 4 */ +#define CURRENT_LIMIT_200 0x00 +#define CURRENT_LIMIT_400 0x01 +#define CURRENT_LIMIT_600 0x02 +#define CURRENT_LIMIT_800 0x03 +#define CURRENT_LIMIT_200_MASK 0x01 +#define CURRENT_LIMIT_400_MASK 0x02 +#define CURRENT_LIMIT_600_MASK 0x04 +#define CURRENT_LIMIT_800_MASK 0x08 +#define CURRENT_LIMIT_200_QUERY_SWITCH_OK 0x00 +#define CURRENT_LIMIT_400_QUERY_SWITCH_OK 0x01 +#define CURRENT_LIMIT_600_QUERY_SWITCH_OK 0x02 +#define CURRENT_LIMIT_800_QUERY_SWITCH_OK 0x03 +#define CURRENT_LIMIT_200_SWITCH_BUSY 0x01 +#define CURRENT_LIMIT_400_SWITCH_BUSY 0x02 +#define CURRENT_LIMIT_600_SWITCH_BUSY 0x04 +#define CURRENT_LIMIT_800_SWITCH_BUSY 0x08 +#define FUNCTION_GROUP4_SUPPORT_OFFSET 0x07 +#define FUNCTION_GROUP4_QUERY_SWITCH_OFFSET 0x0F +#define FUNCTION_GROUP4_CHECK_BUSY_OFFSET 0x17 +/* Switch Function Status Offset */ +#define DATA_STRUCTURE_VER_OFFSET 0x11 /* The high offset */ +#define MAX_PHASE 15 +/* #define TOTAL_READ_PHASE 0x20 */ +/* #define TOTAL_WRITE_PHASE 0x20 */ +/* MMC v4.0 */ +/* #define MMC_52MHZ_SPEED 0x0001 */ +/* #define MMC_26MHZ_SPEED 0x0002 */ +#define MMC_8BIT_BUS 0x0010 +#define MMC_4BIT_BUS 0x0020 +/* #define MMC_SECTOR_MODE 0x0100 */ +#define MMC_SWITCH_ERR 0x80 +/* Tuning direction RX or TX */ +#define TUNE_TX 0x00 +#define TUNE_RX 0x01 +/* For Change_DCM_FreqMode Function */ +#define CHANGE_TX 0x00 +#define CHANGE_RX 0x01 +#define DCM_HIGH_FREQUENCY_MODE 0x00 +#define DCM_LOW_FREQUENCY_MODE 0x01 +#define DCM_HIGH_FREQUENCY_MODE_SET 0x0C +#define DCM_Low_FREQUENCY_MODE_SET 0x00 +/* For Change_FPGA_SSCClock Function */ +#define MULTIPLY_BY_1 0x00 +#define MULTIPLY_BY_2 0x01 +#define MULTIPLY_BY_3 0x02 +#define MULTIPLY_BY_4 0x03 +#define MULTIPLY_BY_5 0x04 +#define MULTIPLY_BY_6 0x05 +#define MULTIPLY_BY_7 0x06 +#define MULTIPLY_BY_8 0x07 +#define MULTIPLY_BY_9 0x08 +#define MULTIPLY_BY_10 0x09 +#define DIVIDE_BY_2 0x01 +#define DIVIDE_BY_3 0x02 +#define DIVIDE_BY_4 0x03 +#define DIVIDE_BY_5 0x04 +#define DIVIDE_BY_6 0x05 +#define DIVIDE_BY_7 0x06 +#define DIVIDE_BY_8 0x07 +#define DIVIDE_BY_9 0x08 +#define DIVIDE_BY_10 0x09 +#define CHECK_SD_TRANS_FAIL(chip, retval) \ + (((retval) != STATUS_SUCCESS) || \ + (chip->rsp_buf[0] & SD_TRANSFER_ERR)) +/* SD Tuning Data Structure */ +/* Record continuous timing phase path */ +struct timing_phase_path { + int start; + int end; + int mid; + int len; +}; + +int sd_select_card(struct rts51x_chip *chip, int select); +int reset_sd_card(struct rts51x_chip *chip); +int sd_switch_clock(struct rts51x_chip *chip); +void sd_stop_seq_mode(struct rts51x_chip *chip); +int sd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt); +void sd_cleanup_work(struct rts51x_chip *chip); +int sd_power_off_card3v3(struct rts51x_chip *chip); +int release_sd_card(struct rts51x_chip *chip); + +#ifdef SUPPORT_SD_LOCK +int sd_update_lock_status(struct rts51x_chip *chip); +#endif + +#ifdef SUPPORT_CPRM +extern int reset_sd(struct rts51x_chip *chip); +extern int sd_check_data0_status(struct rts51x_chip *chip); +extern int sd_read_data(struct rts51x_chip *chip, u8 trans_mode, u8 *cmd, + int cmd_len, u16 byte_cnt, u16 blk_cnt, u8 bus_width, + u8 *buf, int buf_len, int timeout); +#endif + +#endif /* __RTS51X_SD_H */ diff --git a/drivers/staging/rts5139/sd_cprm.c b/drivers/staging/rts5139/sd_cprm.c new file mode 100644 index 00000000000..407cd43ad3b --- /dev/null +++ b/drivers/staging/rts5139/sd_cprm.c @@ -0,0 +1,1215 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_transport.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "rts51x_chip.h" +#include "sd.h" + +#ifdef SUPPORT_CPRM + +static inline int get_rsp_type(u8 rsp_code, u8 *rsp_type, int *rsp_len) +{ + if (!rsp_type || !rsp_len) + return STATUS_FAIL; + + switch (rsp_code) { + case 0x03: + *rsp_type = SD_RSP_TYPE_R0; /* no response */ + *rsp_len = 0; + break; + + case 0x04: + *rsp_type = SD_RSP_TYPE_R1; /* R1,R6(,R4,R5) */ + *rsp_len = 6; + break; + + case 0x05: + *rsp_type = SD_RSP_TYPE_R1b; /* R1b */ + *rsp_len = 6; + break; + + case 0x06: + *rsp_type = SD_RSP_TYPE_R2; /* R2 */ + *rsp_len = 17; + break; + + case 0x07: + *rsp_type = SD_RSP_TYPE_R3; /* R3 */ + *rsp_len = 6; + break; + + default: + return STATUS_FAIL; + } + + return STATUS_SUCCESS; +} + +int soft_reset_sd_card(struct rts51x_chip *chip) +{ + return reset_sd(chip); +} + +int ext_sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, + u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, + int special_check) +{ + int retval; + int timeout = 50; + u16 reg_addr; + u8 buf[17], stat; + int len = 2; + int rty_cnt = 0; + + RTS51X_DEBUGP("EXT SD/MMC CMD %d\n", cmd_idx); + + if (rsp_type == SD_RSP_TYPE_R1b) + timeout = 3000; + +RTY_SEND_CMD: + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | cmd_idx); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, (u8) (arg >> 24)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, (u8) (arg >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, (u8) (arg >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, + 0x01, PINGPONG_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, + 0xFF, SD_TM_CMD_RSP | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, + SD_TRANSFER_END); + + rts51x_add_cmd(chip, READ_REG_CMD, SD_STAT1, 0, 0); + + if (CHECK_USB(chip, USB_20)) { + if (rsp_type == SD_RSP_TYPE_R2) { + for (reg_addr = PPBUF_BASE2; + reg_addr < PPBUF_BASE2 + 16; reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, + 0); + } + len = 19; + } else if (rsp_type != SD_RSP_TYPE_R0) { + /* Read data from SD_CMDx registers */ + for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; + reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, + 0); + } + len = 8; + } else { + len = 3; + } + rts51x_add_cmd(chip, READ_REG_CMD, SD_CMD5, 0, 0); + } else { + len = 2; + } + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, len, timeout); + + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + rts51x_clear_sd_error(chip); + + if (retval == STATUS_TIMEDOUT) { + if (rsp_type & SD_WAIT_BUSY_END) { + retval = sd_check_data0_status(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + } + TRACE_RET(chip, STATUS_FAIL); + } + + if (rsp_type == SD_RSP_TYPE_R0) + return STATUS_SUCCESS; + + if (CHECK_USB(chip, USB_20)) { + rts51x_read_rsp_buf(chip, 2, buf, len - 2); + } else { + if (rsp_type == SD_RSP_TYPE_R2) { + reg_addr = PPBUF_BASE2; + len = 16; + } else { + reg_addr = SD_CMD0; + len = 5; + } + retval = + rts51x_seq_read_register(chip, reg_addr, + (unsigned short)len, buf); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + RTS51X_READ_REG(chip, SD_CMD5, buf + len); + } + stat = chip->rsp_buf[1]; + + if ((buf[0] & 0xC0) != 0) + TRACE_RET(chip, STATUS_FAIL); + + if (!(rsp_type & SD_NO_CHECK_CRC7)) { + if (stat & SD_CRC7_ERR) { + if (cmd_idx == WRITE_MULTIPLE_BLOCK) + TRACE_RET(chip, STATUS_FAIL); + if (rty_cnt < SD_MAX_RETRY_COUNT) { + wait_timeout(20); + rty_cnt++; + goto RTY_SEND_CMD; + } else { + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + if ((cmd_idx == SELECT_CARD) || (cmd_idx == APP_CMD) || + (cmd_idx == SEND_STATUS) || (cmd_idx == STOP_TRANSMISSION)) { + if ((cmd_idx != STOP_TRANSMISSION) && (special_check == 0)) { + if (buf[1] & 0x80) + TRACE_RET(chip, STATUS_FAIL); + } +#ifdef SUPPORT_SD_LOCK + if (buf[1] & 0x7D) { +#else + if (buf[1] & 0x7F) { +#endif + TRACE_RET(chip, STATUS_FAIL); + } + if (buf[2] & 0xF8) + TRACE_RET(chip, STATUS_FAIL); + + if (cmd_idx == SELECT_CARD) { + if (rsp_type == SD_RSP_TYPE_R2) { + if ((buf[3] & 0x1E) != 0x04) + TRACE_RET(chip, STATUS_FAIL); + } else if (rsp_type == SD_RSP_TYPE_R2) { + if ((buf[3] & 0x1E) != 0x03) + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + if (rsp && rsp_len) + memcpy(rsp, buf, rsp_len); + + return STATUS_SUCCESS; +} + +int ext_sd_get_rsp(struct rts51x_chip *chip, int len, u8 * rsp, u8 rsp_type) +{ + int retval, rsp_len; + u16 reg_addr; + + if (rsp_type == SD_RSP_TYPE_R0) + return STATUS_SUCCESS; + + rts51x_init_cmd(chip); + + if (rsp_type == SD_RSP_TYPE_R2) { + for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; + reg_addr++) { + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0xFF, 0); + } + rsp_len = 17; + } else if (rsp_type != SD_RSP_TYPE_R0) { + for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; reg_addr++) + rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0xFF, 0); + rsp_len = 6; + } + rts51x_add_cmd(chip, READ_REG_CMD, SD_CMD5, 0xFF, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, rsp_len, 100); + + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (rsp) { + int min_len = (rsp_len < len) ? rsp_len : len; + + memcpy(rsp, rts51x_get_rsp_data(chip), min_len); + + RTS51X_DEBUGP("min_len = %d\n", min_len); + RTS51X_DEBUGP("Response in cmd buf: 0x%x 0x%x 0x%x 0x%x\n", + rsp[0], rsp[1], rsp[2], rsp[3]); + } + + return STATUS_SUCCESS; +} + +int ext_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 standby, u8 acmd, u8 rsp_code, + u32 arg) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval, rsp_len; + u8 rsp_type; + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + sd_card->last_rsp_type = rsp_type; + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); +#ifdef SUPPORT_SD_LOCK + if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) { + if (CHK_MMC_8BIT(sd_card)) { + retval = + rts51x_write_register(chip, SD_CFG1, 0x03, + SD_BUS_WIDTH_8); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) { + retval = + rts51x_write_register(chip, SD_CFG1, 0x03, + SD_BUS_WIDTH_4); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } + } +#else + /* Set H/W SD/MMC Bus Width */ + rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4); +#endif + + if (standby) { + retval = sd_select_card(chip, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Cmd_Failed); + } + + if (acmd) { + retval = + ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Cmd_Failed); + } + + retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, + sd_card->rsp, rsp_len, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Cmd_Failed); + + if (standby) { + retval = sd_select_card(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Cmd_Failed); + } +#ifdef SUPPORT_SD_LOCK + /* Get SD lock status */ + retval = sd_update_lock_status(chip); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Cmd_Failed); +#endif + + return TRANSPORT_GOOD; + +SD_Execute_Cmd_Failed: + sd_card->pre_cmd_err = 1; + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + release_sd_card(chip); + do_reset_sd_card(chip); + if (!(chip->card_ready & SD_CARD)) + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + + TRACE_RET(chip, TRANSPORT_FAILED); +} + +int ext_sd_execute_read_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 cmd12, u8 standby, + u8 acmd, u8 rsp_code, u32 arg, u32 data_len, + void *data_buf, unsigned int buf_len, int use_sg) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval, rsp_len, i; + int cmd13_checkbit = 0, read_err = 0; + u8 rsp_type, bus_width; + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + sd_card->last_rsp_type = rsp_type; + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); +#ifdef SUPPORT_SD_LOCK + if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) { + if (CHK_MMC_8BIT(sd_card)) + bus_width = SD_BUS_WIDTH_8; + else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) + bus_width = SD_BUS_WIDTH_4; + else + bus_width = SD_BUS_WIDTH_1; + } else { + bus_width = SD_BUS_WIDTH_4; + } + RTS51X_DEBUGP("bus_width = %d\n", bus_width); +#else + bus_width = SD_BUS_WIDTH_4; +#endif + + if (data_len < 512) { + retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + if (standby) { + retval = sd_select_card(chip, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + if (acmd) { + retval = + ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + if (data_len <= 512) { + int min_len; + u8 *buf; + u16 byte_cnt, blk_cnt; + u8 cmd[5]; + unsigned int offset = 0; + void *sg = NULL; + + byte_cnt = (u16) (data_len & 0x3FF); + blk_cnt = 1; + + cmd[0] = 0x40 | cmd_idx; + cmd[1] = (u8) (arg >> 24); + cmd[2] = (u8) (arg >> 16); + cmd[3] = (u8) (arg >> 8); + cmd[4] = (u8) arg; + + buf = kmalloc(data_len, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, byte_cnt, + blk_cnt, bus_width, buf, data_len, 2000); + if (retval != STATUS_SUCCESS) { + read_err = 1; + kfree(buf); + rts51x_write_register(chip, CARD_STOP, + SD_STOP | SD_CLR_ERR, + SD_STOP | SD_CLR_ERR); + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + min_len = min(data_len, buf_len); + if (use_sg) + rts51x_access_sglist(buf, min_len, (void *)data_buf, + &sg, &offset, TO_XFER_BUF); + else + memcpy(data_buf, buf, min_len); + + kfree(buf); + } else if (!(data_len & 0x1FF)) { + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, + 0xFF, (u8) (data_len >> 17)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, + 0xFF, (u8) ((data_len & 0x0001FE00) >> 9)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, + 0x40 | cmd_idx); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, + (u8) (arg >> 24)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, + (u8) (arg >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, + (u8) (arg >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); + trans_dma_enable(DMA_FROM_DEVICE, chip, data_len, DMA_512); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_READ_2 | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + retval = rts51x_send_cmd(chip, MODE_CDIR, 100); + if (retval != STATUS_SUCCESS) { + read_err = 1; + rts51x_ep0_write_register(chip, CARD_STOP, + SD_STOP | SD_CLR_ERR, + SD_STOP | SD_CLR_ERR); + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + retval = + rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), + data_buf, buf_len, use_sg, NULL, + 10000, STAGE_DI); + if (retval != STATUS_SUCCESS) { + read_err = 1; + rts51x_ep0_write_register(chip, CARD_STOP, + SD_STOP | SD_CLR_ERR, + SD_STOP | SD_CLR_ERR); + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + retval = rts51x_get_rsp(chip, 1, 500); + if (CHECK_SD_TRANS_FAIL(chip, retval)) { + read_err = 1; + rts51x_ep0_write_register(chip, CARD_STOP, + SD_STOP | SD_CLR_ERR, + SD_STOP | SD_CLR_ERR); + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + } else { + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + retval = ext_sd_get_rsp(chip, rsp_len, sd_card->rsp, rsp_type); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + + if (standby) { + retval = sd_select_card(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + if (cmd12) { + retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, + 0, SD_RSP_TYPE_R1b, NULL, 0, + 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + } + + if (data_len < 512) { + retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + + rts51x_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); + rts51x_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); + } + + if (standby || cmd12) + cmd13_checkbit = 1; + + for (i = 0; i < 3; i++) { + retval = + ext_sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0, + cmd13_checkbit); + if (retval == STATUS_SUCCESS) + break; + } + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); + + return TRANSPORT_GOOD; + +SD_Execute_Read_Cmd_Failed: + sd_card->pre_cmd_err = 1; + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + if (read_err) + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + release_sd_card(chip); + do_reset_sd_card(chip); + if (!(chip->card_ready & SD_CARD)) + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + + TRACE_RET(chip, TRANSPORT_FAILED); +} + +int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, + u8 rsp_code, u32 arg, u32 data_len, + void *data_buf, unsigned int buf_len, int use_sg) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval, rsp_len; + int cmd13_checkbit = 0, write_err = 0; + u8 rsp_type; + u32 i; +#ifdef SUPPORT_SD_LOCK + int lock_cmd_fail = 0; + u8 sd_lock_state = 0; + u8 lock_cmd_type = 0; +#endif + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); +#ifdef SUPPORT_SD_LOCK + if (cmd_idx == LOCK_UNLOCK) { + sd_lock_state = sd_card->sd_lock_status; + sd_lock_state &= SD_LOCKED; + } +#endif + + retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + sd_card->last_rsp_type = rsp_type; + + retval = sd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); +#ifdef SUPPORT_SD_LOCK + if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) { + if (CHK_MMC_8BIT(sd_card)) { + retval = + rts51x_write_register(chip, SD_CFG1, 0x03, + SD_BUS_WIDTH_8); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) { + retval = + rts51x_write_register(chip, SD_CFG1, 0x03, + SD_BUS_WIDTH_4); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, TRANSPORT_FAILED); + } + } +#else + rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4); +#endif + + if (data_len < 512) { + retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + if (standby) { + retval = sd_select_card(chip, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + if (acmd) { + retval = + ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, + sd_card->rsp, rsp_len, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + if (data_len <= 512) { + u8 *buf; + unsigned int offset = 0; + void *sg = NULL; + + buf = kmalloc(data_len, GFP_KERNEL); + if (buf == NULL) + TRACE_RET(chip, TRANSPORT_ERROR); + + if (use_sg) + rts51x_access_sglist(buf, data_len, (void *)data_buf, + &sg, &offset, FROM_XFER_BUF); + else + memcpy(buf, data_buf, data_len); + +#ifdef SUPPORT_SD_LOCK + if (cmd_idx == LOCK_UNLOCK) + lock_cmd_type = buf[0] & 0x0F; +#endif + + if (data_len > 256) { + rts51x_init_cmd(chip); + for (i = 0; i < 256; i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, + (u16) (PPBUF_BASE2 + i), 0xFF, + buf[i]); + } + retval = rts51x_send_cmd(chip, MODE_C, 250); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + rts51x_init_cmd(chip); + for (i = 256; i < data_len; i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, + (u16) (PPBUF_BASE2 + i), 0xFF, + buf[i]); + } + retval = rts51x_send_cmd(chip, MODE_C, 250); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + } else { + rts51x_init_cmd(chip); + for (i = 0; i < data_len; i++) { + rts51x_add_cmd(chip, WRITE_REG_CMD, + (u16) (PPBUF_BASE2 + i), 0xFF, + buf[i]); + } + retval = rts51x_send_cmd(chip, MODE_C, 250); + if (retval != STATUS_SUCCESS) { + kfree(buf); + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + } + + kfree(buf); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, + (u8) ((data_len >> 8) & 0x03)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, + (u8) data_len); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x01); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + retval = rts51x_get_rsp(chip, 1, 250); + if (CHECK_SD_TRANS_FAIL(chip, retval)) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } else if (!(data_len & 0x1FF)) { + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, + 0xFF, (u8) (data_len >> 17)); + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, + 0xFF, (u8) ((data_len & 0x0001FE00) >> 9)); + + trans_dma_enable(DMA_TO_DEVICE, chip, data_len, DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, + SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, + SD_TRANSFER_END, SD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR, 100); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + retval = + rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), + data_buf, buf_len, use_sg, NULL, + 10000, STAGE_DO); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + retval = rts51x_get_rsp(chip, 1, 10000); + if (CHECK_SD_TRANS_FAIL(chip, retval)) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + } else { + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + if (retval < 0) { + write_err = 1; + rts51x_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, + SD_STOP | SD_CLR_ERR); + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } +#ifdef SUPPORT_SD_LOCK + if (cmd_idx == LOCK_UNLOCK) { + if (lock_cmd_type == SD_ERASE) { + sd_card->sd_erase_status = SD_UNDER_ERASING; + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; + } + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, CHECK_REG_CMD, SD_BUS_STAT, SD_DAT0_STATUS, + SD_DAT0_STATUS); + retval = rts51x_send_cmd(chip, MODE_CR, 250); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + rts51x_get_rsp(chip, 1, 200); /* Don't care return value */ + + retval = sd_update_lock_status(chip); + if (retval != STATUS_SUCCESS) { + RTS51X_DEBUGP("Lock command fail!\n"); + lock_cmd_fail = 1; + } + } +#endif /* SUPPORT_SD_LOCK */ + + if (standby) { + retval = sd_select_card(chip, 1); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + if (cmd12) { + retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, + 0, SD_RSP_TYPE_R1b, NULL, 0, + 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + } + + if (data_len < 512) { + retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, + SD_RSP_TYPE_R1, NULL, 0, 0); + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); + + rts51x_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); + rts51x_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); + } + + if (cmd12 || standby) { + /* There is CMD7 or CMD12 sent before CMD13 */ + cmd13_checkbit = 1; + } + + for (i = 0; i < 3; i++) { + retval = + ext_sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, + SD_RSP_TYPE_R1, NULL, 0, + cmd13_checkbit); + if (retval == STATUS_SUCCESS) + break; + } + if (retval != STATUS_SUCCESS) + TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); +#ifdef SUPPORT_SD_LOCK + if (cmd_idx == LOCK_UNLOCK) { + if (!lock_cmd_fail) { + RTS51X_DEBUGP("lock_cmd_type = 0x%x\n", + lock_cmd_type); + if (lock_cmd_type & SD_CLR_PWD) + sd_card->sd_lock_status &= ~SD_PWD_EXIST; + if (lock_cmd_type & SD_SET_PWD) + sd_card->sd_lock_status |= SD_PWD_EXIST; + } + + RTS51X_DEBUGP("sd_lock_state = 0x%x," + "sd_card->sd_lock_status = 0x%x\n", + sd_lock_state, sd_card->sd_lock_status); + if (sd_lock_state ^ (sd_card->sd_lock_status & SD_LOCKED)) { + sd_card->sd_lock_notify = 1; + if (sd_lock_state) { + if (sd_card->sd_lock_status & + SD_LOCK_1BIT_MODE) { + sd_card->sd_lock_status |= + (SD_UNLOCK_POW_ON | SD_SDR_RST); + if (CHK_SD(sd_card)) { + retval = reset_sd(chip); + if (retval != STATUS_SUCCESS) { + sd_card->sd_lock_status + &= ~(SD_UNLOCK_POW_ON | + SD_SDR_RST); + TRACE_GOTO(chip, + SD_Execute_Write_Cmd_Failed); + } + } + + sd_card->sd_lock_status &= + ~(SD_UNLOCK_POW_ON | SD_SDR_RST); + } + } + } + } + + if (lock_cmd_fail) { + scsi_set_resid(srb, 0); + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + TRACE_RET(chip, TRANSPORT_FAILED); + } +#endif /* SUPPORT_SD_LOCK */ + + return TRANSPORT_GOOD; + +SD_Execute_Write_Cmd_Failed: + sd_card->pre_cmd_err = 1; + set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); + if (write_err) + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); + release_sd_card(chip); + do_reset_sd_card(chip); + if (!(chip->card_ready & SD_CARD)) + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + + TRACE_RET(chip, TRANSPORT_FAILED); +} + +int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + unsigned int lun = SCSI_LUN(srb); + int len; + u8 buf[18] = { + 0x00, + 0x00, + 0x00, + 0x0E, + 0x00, /* Version Number */ + 0x00, /* WP | Media Type */ + 0x00, /* RCA (Low byte) */ + 0x00, /* RCA (High byte) */ + 0x53, /* 'S' */ + 0x44, /* 'D' */ + 0x20, /* ' ' */ + 0x43, /* 'C' */ + 0x61, /* 'a' */ + 0x72, /* 'r' */ + 0x64, /* 'd' */ + 0x00, /* Max LUN Number */ + 0x00, + 0x00, + }; + + sd_card->pre_cmd_err = 0; + + if (!(CHK_BIT(chip->lun_mc, lun))) { + SET_BIT(chip->lun_mc, lun); + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) + || (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) + || (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) + || (0x64 != srb->cmnd[8])) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + switch (srb->cmnd[1] & 0x0F) { + case 0: + sd_card->sd_pass_thru_en = 0; + break; + + case 1: + sd_card->sd_pass_thru_en = 1; + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + /* 0x01:SD Memory Card; 0x02:Other Media; 0x03:Illegal Media; */ + buf[5] = (1 == CHK_SD(sd_card)) ? 0x01 : 0x02; + if (chip->card_wp & SD_CARD) + buf[5] |= 0x80; + + buf[6] = (u8) (sd_card->sd_addr >> 16); + buf[7] = (u8) (sd_card->sd_addr >> 24); + + buf[15] = chip->max_lun; + + len = min(18, (int)scsi_bufflen(srb)); + rts51x_set_xfer_buf(buf, len, srb); + + return TRANSPORT_GOOD; +} + +int sd_execute_no_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + unsigned int lun = SCSI_LUN(srb); + int retval; + u8 cmd_idx, rsp_code; + u8 standby = 0, acmd = 0; + u32 arg; + + if (!sd_card->sd_pass_thru_en) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + cmd_idx = srb->cmnd[2] & 0x3F; + if (srb->cmnd[1] & 0x02) + standby = 1; + if (srb->cmnd[1] & 0x01) + acmd = 1; + + arg = ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | + ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; + + rsp_code = srb->cmnd[10]; + + retval = + ext_sd_execute_no_data(chip, lun, cmd_idx, standby, acmd, rsp_code, + arg); + scsi_set_resid(srb, 0); + return retval; +} + +int sd_execute_read_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + unsigned int lun = SCSI_LUN(srb); + u8 cmd_idx, rsp_code, send_cmd12 = 0, standby = 0, acmd = 0; + u32 arg, data_len; + + if (!sd_card->sd_pass_thru_en) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + cmd_idx = srb->cmnd[2] & 0x3F; + if (srb->cmnd[1] & 0x04) + send_cmd12 = 1; + if (srb->cmnd[1] & 0x02) + standby = 1; + if (srb->cmnd[1] & 0x01) + acmd = 1; + + arg = ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | + ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; + + data_len = + ((u32) srb->cmnd[7] << 16) | ((u32) srb->cmnd[8] << 8) | + srb->cmnd[9]; + rsp_code = srb->cmnd[10]; + + retval = + ext_sd_execute_read_data(chip, lun, cmd_idx, send_cmd12, standby, + acmd, rsp_code, arg, data_len, + scsi_sglist(srb), scsi_bufflen(srb), + scsi_sg_count(srb)); + scsi_set_resid(srb, 0); + return retval; +} + +int sd_execute_write_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + int retval; + unsigned int lun = SCSI_LUN(srb); + u8 cmd_idx, rsp_code, send_cmd12 = 0, standby = 0, acmd = 0; + u32 data_len, arg; + + if (!sd_card->sd_pass_thru_en) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + cmd_idx = srb->cmnd[2] & 0x3F; + if (srb->cmnd[1] & 0x04) + send_cmd12 = 1; + if (srb->cmnd[1] & 0x02) + standby = 1; + if (srb->cmnd[1] & 0x01) + acmd = 1; + + data_len = + ((u32) srb->cmnd[7] << 16) | ((u32) srb->cmnd[8] << 8) | + srb->cmnd[9]; + arg = + ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | + ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; + rsp_code = srb->cmnd[10]; + + retval = + ext_sd_execute_write_data(chip, lun, cmd_idx, send_cmd12, standby, + acmd, rsp_code, arg, data_len, + scsi_sglist(srb), scsi_bufflen(srb), + scsi_sg_count(srb)); + scsi_set_resid(srb, 0); + return retval; +} + +int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + unsigned int lun = SCSI_LUN(srb); + int count; + u16 data_len; + + if (!sd_card->sd_pass_thru_en) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + data_len = ((u16) srb->cmnd[7] << 8) | srb->cmnd[8]; + + if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) { + count = (data_len < 17) ? data_len : 17; + } else { + count = (data_len < 6) ? data_len : 6; + } + rts51x_set_xfer_buf(sd_card->rsp, count, srb); + + RTS51X_DEBUGP("Response length: %d\n", data_len); + RTS51X_DEBUGP("Response: 0x%x 0x%x 0x%x 0x%x\n", + sd_card->rsp[0], sd_card->rsp[1], sd_card->rsp[2], + sd_card->rsp[3]); + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} + +int sd_hw_rst(struct scsi_cmnd *srb, struct rts51x_chip *chip) +{ + struct sd_info *sd_card = &(chip->sd_card); + unsigned int lun = SCSI_LUN(srb); + int retval; + + if (!sd_card->sd_pass_thru_en) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if (sd_card->pre_cmd_err) { + sd_card->pre_cmd_err = 0; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) + || (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) + || (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) + || (0x64 != srb->cmnd[8])) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + switch (srb->cmnd[1] & 0x0F) { + case 0: + /* SD Card Power Off -> ON and Initialization */ +#ifdef SUPPORT_SD_LOCK + if (0x64 == srb->cmnd[9]) { + /* Command Mode */ + sd_card->sd_lock_status |= SD_SDR_RST; + } +#endif /* SUPPORT_SD_LOCK */ + retval = reset_sd_card(chip); + if (retval != STATUS_SUCCESS) { +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status &= ~SD_SDR_RST; +#endif + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + sd_card->pre_cmd_err = 1; + TRACE_RET(chip, TRANSPORT_FAILED); + } +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status &= ~SD_SDR_RST; +#endif + break; + + case 1: + /* reset CMD(CMD0) and Initialization + * (without SD Card Power Off -> ON) */ + retval = soft_reset_sd_card(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + sd_card->pre_cmd_err = 1; + TRACE_RET(chip, TRANSPORT_FAILED); + } + break; + + default: + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); + TRACE_RET(chip, TRANSPORT_FAILED); + } + + scsi_set_resid(srb, 0); + return TRANSPORT_GOOD; +} +#endif diff --git a/drivers/staging/rts5139/sd_cprm.h b/drivers/staging/rts5139/sd_cprm.h new file mode 100644 index 00000000000..75e263b6594 --- /dev/null +++ b/drivers/staging/rts5139/sd_cprm.h @@ -0,0 +1,54 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_SD_CPRM_H +#define __RTS51X_SD_CPRM_H + +#include "rts51x_chip.h" +#include "sd.h" + +#ifdef SUPPORT_CPRM +int ext_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 standby, u8 acmd, u8 rsp_code, + u32 arg); +int ext_sd_execute_read_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, + u8 rsp_code, u32 arg, u32 data_len, void *data_buf, + unsigned int buf_len, int use_sg); +int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun, + u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, + u8 rsp_code, u32 arg, u32 data_len, + void *data_buf, unsigned int buf_len, int use_sg); + +int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int sd_execute_no_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int sd_execute_read_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int sd_execute_write_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip); +int sd_hw_rst(struct scsi_cmnd *srb, struct rts51x_chip *chip); +#endif + +#endif /* __RTS51X_SD_CPRM_H */ diff --git a/drivers/staging/rts5139/trace.h b/drivers/staging/rts5139/trace.h new file mode 100644 index 00000000000..0584b8ab43c --- /dev/null +++ b/drivers/staging/rts5139/trace.h @@ -0,0 +1,137 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_TRACE_H +#define __RTS51X_TRACE_H + +#include "debug.h" + +#define _MSG_TRACE + +#ifdef _MSG_TRACE +static inline char *filename(char *path) +{ + char *ptr; + + if (path == NULL) + return NULL; + + ptr = path; + + while (*ptr != '\0') { + if ((*ptr == '\\') || (*ptr == '/')) + path = ptr + 1; + ptr++; + } + + return path; +} + +#define TRACE_RET(chip, ret) \ +do { \ + char *_file = filename((char *)__FILE__); \ + RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \ + (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \ + strncpy((chip)->trace_msg[(chip)->msg_idx].func, \ + __func__, MSG_FUNC_LEN-1); \ + strncpy((chip)->trace_msg[(chip)->msg_idx].file, \ + _file, MSG_FILE_LEN-1); \ + get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\ + TIME_VAL_LEN); \ + (chip)->trace_msg[(chip)->msg_idx].valid = 1; \ + (chip)->msg_idx++; \ + if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \ + (chip)->msg_idx = 0; \ + } \ + return ret; \ +} while (0) + +#define TRACE_GOTO(chip, label) \ +do { \ + char *_file = filename((char *)__FILE__); \ + RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \ + (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \ + strncpy((chip)->trace_msg[(chip)->msg_idx].func, \ + __func__, MSG_FUNC_LEN-1); \ + strncpy((chip)->trace_msg[(chip)->msg_idx].file, \ + _file, MSG_FILE_LEN-1); \ + get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\ + TIME_VAL_LEN); \ + (chip)->trace_msg[(chip)->msg_idx].valid = 1; \ + (chip)->msg_idx++; \ + if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \ + (chip)->msg_idx = 0; \ + } \ + goto label; \ +} while (0) +#else +#define TRACE_RET(chip, ret) return (ret) +#define TRACE_GOTO(chip, label) goto label +#endif + +#ifdef CONFIG_RTS5139_DEBUG +static inline void rts51x_dump(u8 *buf, int buf_len) +{ + int i; + u8 tmp[16] = { 0 }; + u8 *_ptr = buf; + + for (i = 0; i < ((buf_len) / 16); i++) { + RTS51X_DEBUGP("%02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x\n", + _ptr[0], _ptr[1], _ptr[2], _ptr[3], _ptr[4], + _ptr[5], _ptr[6], _ptr[7], _ptr[8], _ptr[9], + _ptr[10], _ptr[11], _ptr[12], _ptr[13], _ptr[14], + _ptr[15]); + _ptr += 16; + } + if ((buf_len) % 16) { + memcpy(tmp, _ptr, (buf_len) % 16); + _ptr = tmp; + RTS51X_DEBUGP("%02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x\n", + _ptr[0], _ptr[1], _ptr[2], _ptr[3], _ptr[4], + _ptr[5], _ptr[6], _ptr[7], _ptr[8], _ptr[9], + _ptr[10], _ptr[11], _ptr[12], _ptr[13], _ptr[14], + _ptr[15]); + } +} + +#define RTS51X_DUMP(buf, buf_len) \ + rts51x_dump((u8 *)(buf), (buf_len)) + +#define CATCH_TRIGGER(chip) \ +do { \ + rts51x_ep0_write_register((chip), 0xFC31, 0x01, 0x01); \ + RTS51X_DEBUGP("Catch trigger!\n"); \ +} while (0) + +#else +#define RTS51X_DUMP(buf, buf_len) +#define CATCH_TRIGGER(chip) +#endif + +#endif /* __RTS51X_TRACE_H */ diff --git a/drivers/staging/rts5139/xd.c b/drivers/staging/rts5139/xd.c new file mode 100644 index 00000000000..39c45240816 --- /dev/null +++ b/drivers/staging/rts5139/xd.c @@ -0,0 +1,2254 @@ +/* Driver for Realtek RTS51xx USB card reader + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#include +#include +#include + +#include "debug.h" +#include "trace.h" +#include "rts51x.h" +#include "rts51x_transport.h" +#include "rts51x_scsi.h" +#include "rts51x_card.h" +#include "xd.h" + +static int xd_build_l2p_tbl(struct rts51x_chip *chip, int zone_no); +static int xd_init_page(struct rts51x_chip *chip, u32 phy_blk, u16 logoff, + u8 start_page, u8 end_page); + +static inline void xd_set_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct xd_info *xd_card = &(chip->xd_card); + + xd_card->err_code = err_code; +} + +static inline int xd_check_err_code(struct rts51x_chip *chip, u8 err_code) +{ + struct xd_info *xd_card = &(chip->xd_card); + + return (xd_card->err_code == err_code); +} + +static int xd_set_init_para(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + + if (chip->asic_code) + xd_card->xd_clock = 47; + else + xd_card->xd_clock = CLK_50; + + retval = switch_clock(chip, xd_card->xd_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int xd_switch_clock(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + + retval = rts51x_select_card(chip, XD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = switch_clock(chip, xd_card->xd_clock); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int xd_read_id(struct rts51x_chip *chip, u8 id_cmd, u8 *id_buf, + u8 buf_len) +{ + int retval, i; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DAT, 0xFF, id_cmd); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_READ_ID); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + for (i = 0; i < 4; i++) { + rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_ADDRESS1 + i), 0, + 0); + } + + retval = rts51x_send_cmd(chip, MODE_CR, 20); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 5, 20); + + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + if (id_buf && buf_len) { + if (buf_len > 4) + buf_len = 4; + rts51x_read_rsp_buf(chip, 1, id_buf, buf_len); + } + + return STATUS_SUCCESS; +} + +static void xd_assign_phy_addr(struct rts51x_chip *chip, u32 addr, u8 mode) +{ + struct xd_info *xd_card = &(chip->xd_card); + + switch (mode) { + case XD_RW_ADDR: + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS0, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS1, 0xFF, + (u8) addr); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS2, 0xFF, + (u8) (addr >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS3, 0xFF, + (u8) (addr >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, 0xFF, + xd_card->addr_cycle | XD_CALC_ECC | + XD_BA_NO_TRANSFORM); + break; + + case XD_ERASE_ADDR: + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS0, 0xFF, + (u8) addr); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS1, 0xFF, + (u8) (addr >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS2, 0xFF, + (u8) (addr >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, 0xFF, + (xd_card->addr_cycle - 1) | + XD_CALC_ECC | XD_BA_NO_TRANSFORM); + break; + + default: + break; + } +} + +static int xd_read_redundant(struct rts51x_chip *chip, u32 page_addr, u8 *buf, + int buf_len) +{ + int retval, i; + + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_READ_REDUNDANT); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + for (i = 0; i < 6; i++) { + rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_PAGE_STATUS + i), + 0, 0); + } + for (i = 0; i < 4; i++) { + rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_RESERVED0 + i), 0, + 0); + } + rts51x_add_cmd(chip, READ_REG_CMD, XD_PARITY, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 11, 500); + + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + if (buf && buf_len) { + if (buf_len > 11) + buf_len = 11; + rts51x_read_rsp_buf(chip, 1, buf, buf_len); + } + + return STATUS_SUCCESS; +} + +static int xd_read_data_from_ppb(struct rts51x_chip *chip, int offset, u8 *buf, + int buf_len) +{ + int retval, i; + + if (!buf || (buf_len <= 0)) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + for (i = 0; i < buf_len; i++) { + rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + offset + i, 0, + 0); + } + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, buf_len, 200); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_read_rsp_buf(chip, 0, buf, buf_len); + + return STATUS_SUCCESS; +} + +static int xd_read_cis(struct rts51x_chip *chip, u32 page_addr, u8 *buf, + int buf_len) +{ + int retval; + u8 reg; + + if (!buf || (buf_len < 10)) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, + XD_AUTO_CHK_DATA_STATUS, XD_AUTO_CHK_DATA_STATUS); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_READ_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END | XD_PPB_EMPTY, + XD_TRANSFER_END | XD_PPB_EMPTY); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, 500); + if (retval == STATUS_TIMEDOUT) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + RTS51X_READ_REG(chip, XD_PAGE_STATUS, ®); + if (reg != XD_GPG) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + RTS51X_READ_REG(chip, XD_CTL, ®); + + if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) { + retval = xd_read_data_from_ppb(chip, 0, buf, buf_len); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (reg & XD_ECC1_ERROR) { /* correctable error */ + u8 ecc_bit, ecc_byte; + + RTS51X_READ_REG(chip, XD_ECC_BIT1, &ecc_bit); + RTS51X_READ_REG(chip, XD_ECC_BYTE1, &ecc_byte); + + RTS51X_DEBUGP("ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n", + ecc_bit, ecc_byte); + if (ecc_byte < buf_len) { + RTS51X_DEBUGP("Before correct: 0x%x\n", + buf[ecc_byte]); + buf[ecc_byte] ^= (1 << ecc_bit); + RTS51X_DEBUGP("After correct: 0x%x\n", + buf[ecc_byte]); + } + } + } else if (!(reg & XD_ECC2_ERROR) || !(reg & XD_ECC2_UNCORRECTABLE)) { + RTS51X_WRITE_REG(chip, CARD_STOP, XD_STOP | XD_CLR_ERR, + XD_STOP | XD_CLR_ERR); + + retval = xd_read_data_from_ppb(chip, 256, buf, buf_len); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (reg & XD_ECC2_ERROR) { + u8 ecc_bit, ecc_byte; + + RTS51X_READ_REG(chip, XD_ECC_BIT2, &ecc_bit); + RTS51X_READ_REG(chip, XD_ECC_BYTE2, &ecc_byte); + + RTS51X_DEBUGP("ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n", + ecc_bit, ecc_byte); + if (ecc_byte < buf_len) { + RTS51X_DEBUGP("Before correct: 0x%x\n", + buf[ecc_byte]); + buf[ecc_byte] ^= (1 << ecc_bit); + RTS51X_DEBUGP("After correct: 0x%x\n", + buf[ecc_byte]); + } + } + } else { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static void xd_pull_ctl_disable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); + } +} + +static void xd_pull_ctl_enable(struct rts51x_chip *chip) +{ + if (CHECK_PKG(chip, LQFP48)) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xAA); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xA5); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x59); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); + } +} + +static int reset_xd(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval, i, j; + u8 id_buf[4], redunt[11]; + + retval = rts51x_select_card(chip, XD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, 0xFF, + XD_PGSTS_NOT_FF); + if (chip->asic_code) + xd_pull_ctl_disable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, + (FPGA_XD_PULL_CTL_EN1 & FPGA_XD_PULL_CTL_EN3)); + + if (!chip->option.FT2_fast_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_INIT, XD_NO_AUTO_PWR_OFF, + 0); + if (CHECK_PKG(chip, LQFP48) || + chip->option.rts5129_D3318_off_enable) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, + DV3318_AUTO_PWR_OFF, + DV3318_AUTO_PWR_OFF); + } + } + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); + if (!chip->option.FT2_fast_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + } + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + if (!chip->option.FT2_fast_mode) { +#ifdef SD_XD_IO_FOLLOW_PWR + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) { + rts51x_write_register(chip, CARD_PWR_CTL, + LDO_OFF, LDO_OFF); + } +#endif + + wait_timeout(250); + +#ifdef SD_XD_IO_FOLLOW_PWR + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) { + rts51x_init_cmd(chip); + if (chip->asic_code) { + xd_pull_ctl_enable(chip); + } else { + rts51x_add_cmd(chip, WRITE_REG_CMD, + FPGA_PULL_CTL, 0xFF, + (FPGA_XD_PULL_CTL_EN1 & + FPGA_XD_PULL_CTL_EN2)); + } + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + } +#endif + + retval = card_power_on(chip, XD_CARD); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); +#ifdef SUPPORT_OCP + wait_timeout(50); + rts51x_get_card_status(chip, &(chip->card_status)); + chip->ocp_stat = (chip->card_status >> 4) & 0x03; + + if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { + RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", + chip->ocp_stat); + TRACE_RET(chip, STATUS_FAIL); + } +#endif + } + + rts51x_init_cmd(chip); + + if (chip->asic_code) + xd_pull_ctl_enable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, + (FPGA_XD_PULL_CTL_EN1 & FPGA_XD_PULL_CTL_EN2)); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, + XD_OUTPUT_EN); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CTL, XD_CE_DISEN, XD_CE_DISEN); + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + if (!chip->option.FT2_fast_mode) + wait_timeout(200); + + retval = xd_set_init_para(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + /* Read ID to check if the timing setting is right */ + for (i = 0; i < 4; i++) { + u8 xd_dat, xd_ctl; + + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DTCTL, 0xFF, + XD_TIME_SETUP_STEP * 3 + XD_TIME_RW_STEP * + (2 + i + chip->option.xd_rw_step) + + XD_TIME_RWN_STEP * (i + chip->option.xd_rwn_step)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CATCTL, 0xFF, + XD_TIME_SETUP_STEP * 3 + XD_TIME_RW_STEP * (4 + + i) + XD_TIME_RWN_STEP * (3 + i)); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_RESET); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END, XD_TRANSFER_END); + + rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); + rts51x_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + retval = rts51x_get_rsp(chip, 3, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + xd_dat = chip->rsp_buf[1]; + xd_ctl = chip->rsp_buf[2]; + RTS51X_DEBUGP("XD_DAT: 0x%x, XD_CTL: 0x%x\n", xd_dat, xd_ctl); + + if (((xd_dat & READY_FLAG) != READY_STATE) + || !(xd_ctl & XD_RDY)) + continue; + + retval = xd_read_id(chip, READ_ID, id_buf, 4); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + RTS51X_DEBUGP("READ_ID: 0x%x 0x%x 0x%x 0x%x\n", + id_buf[0], id_buf[1], id_buf[2], id_buf[3]); + + xd_card->device_code = id_buf[1]; + + switch (xd_card->device_code) { + case XD_4M_X8_512_1: + case XD_4M_X8_512_2: + xd_card->block_shift = 4; /* 16 pages per block */ + xd_card->page_off = 0x0F; + xd_card->addr_cycle = 3; + xd_card->zone_cnt = 1; + xd_card->capacity = 8000; /* 500 * 2 ^ 4 */ + XD_SET_4MB(xd_card); + break; + case XD_8M_X8_512: + xd_card->block_shift = 4; + xd_card->page_off = 0x0F; + xd_card->addr_cycle = 3; + xd_card->zone_cnt = 1; + xd_card->capacity = 16000; /* 1000 * 2 ^ 4 */ + break; + case XD_16M_X8_512: + XD_PAGE_512(xd_card); /* 32 pages per block */ + xd_card->addr_cycle = 3; + xd_card->zone_cnt = 1; + xd_card->capacity = 32000; /* 1000 * 2 ^ 5 */ + break; + case XD_32M_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 3; + xd_card->zone_cnt = 2; + xd_card->capacity = 64000; /* 2000 * 2 ^ 5 */ + break; + case XD_64M_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 4; + xd_card->capacity = 128000; /* 4000 * 2 ^ 5 */ + break; + case XD_128M_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 8; + xd_card->capacity = 256000; /* 8000 * 2 ^ 5 */ + break; + case XD_256M_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 16; + xd_card->capacity = 512000; /* 16000 * 2 ^ 5 */ + break; + case XD_512M_X8: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 32; + xd_card->capacity = 1024000; /* 32000 * 2 ^ 5 */ + break; + case xD_1G_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 64; + xd_card->capacity = 2048000; /* 64000 * 2 ^ 5 */ + break; + case xD_2G_X8_512: + XD_PAGE_512(xd_card); + xd_card->addr_cycle = 4; + xd_card->zone_cnt = 128; + xd_card->capacity = 4096000; /* 128000 * 2 ^ 5 */ + break; + default: + continue; + } + + /* Confirm timing setting */ + for (j = 0; j < 10; j++) { + retval = xd_read_id(chip, READ_ID, id_buf, 4); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (id_buf[1] != xd_card->device_code) + break; + } + + /* Current timing pass */ + if (j == 10) + break; + } + + if (i == 4) { + xd_card->block_shift = 0; + xd_card->page_off = 0; + xd_card->addr_cycle = 0; + xd_card->capacity = 0; + + TRACE_RET(chip, STATUS_FAIL); + } + + retval = xd_read_id(chip, READ_xD_ID, id_buf, 4); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + RTS51X_DEBUGP("READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n", + id_buf[0], id_buf[1], id_buf[2], id_buf[3]); + if (id_buf[2] != XD_ID_CODE) + TRACE_RET(chip, STATUS_FAIL); + + /* Search CIS block */ + for (i = 0; i < 24; i++) { + u32 page_addr; + + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) + TRACE_RET(chip, STATUS_FAIL); + + page_addr = (u32) i << xd_card->block_shift; + + for (j = 0; j < 3; j++) { + retval = xd_read_redundant(chip, page_addr, redunt, 11); + if (retval == STATUS_SUCCESS) + break; + } + if (j == 3) + continue; + + if (redunt[BLOCK_STATUS] != XD_GBLK) + continue; + + j = 0; + /* Check page status */ + if (redunt[PAGE_STATUS] != XD_GPG) { + for (j = 1; j <= 8; j++) { + retval = + xd_read_redundant(chip, page_addr + j, + redunt, 11); + if (retval == STATUS_SUCCESS) { + if (redunt[PAGE_STATUS] == XD_GPG) + break; + } + } + + if (j == 9) + break; + } + + if ((redunt[BLOCK_STATUS] == XD_GBLK) + && (redunt[PARITY] & XD_BA1_ALL0)) { + u8 buf[10]; + + page_addr += j; + + retval = xd_read_cis(chip, page_addr, buf, 10); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if ((buf[0] == 0x01) && (buf[1] == 0x03) + && (buf[2] == 0xD9) + && (buf[3] == 0x01) && (buf[4] == 0xFF) + && (buf[5] == 0x18) && (buf[6] == 0x02) + && (buf[7] == 0xDF) && (buf[8] == 0x01) + && (buf[9] == 0x20)) { + xd_card->cis_block = (u16) i; + } + } + + break; + } + + RTS51X_DEBUGP("CIS block: 0x%x\n", xd_card->cis_block); + if (xd_card->cis_block == 0xFFFF) + TRACE_RET(chip, STATUS_FAIL); + + chip->capacity[chip->card2lun[XD_CARD]] = xd_card->capacity; + + return STATUS_SUCCESS; +} + +static int xd_check_data_blank(u8 *redunt) +{ + int i; + + for (i = 0; i < 6; i++) { + if (redunt[PAGE_STATUS + i] != 0xFF) + return 0; + } + + if ((redunt[PARITY] & (XD_ECC1_ALL1 | XD_ECC2_ALL1)) != + (XD_ECC1_ALL1 | XD_ECC2_ALL1)) + return 0; + + for (i = 0; i < 4; i++) { + if (redunt[RESERVED0 + i] != 0xFF) + return 0; + } + + return 1; +} + +static u16 xd_load_log_block_addr(u8 *redunt) +{ + u16 addr = 0xFFFF; + + if (redunt[PARITY] & XD_BA1_BA2_EQL) + addr = + ((u16) redunt[BLOCK_ADDR1_H] << 8) | redunt[BLOCK_ADDR1_L]; + else if (redunt[PARITY] & XD_BA1_VALID) + addr = + ((u16) redunt[BLOCK_ADDR1_H] << 8) | redunt[BLOCK_ADDR1_L]; + else if (redunt[PARITY] & XD_BA2_VALID) + addr = + ((u16) redunt[BLOCK_ADDR2_H] << 8) | redunt[BLOCK_ADDR2_L]; + + return addr; +} + +static int xd_init_l2p_tbl(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int size, i; + + RTS51X_DEBUGP("xd_init_l2p_tbl: zone_cnt = %d\n", xd_card->zone_cnt); + + if (xd_card->zone_cnt < 1) + TRACE_RET(chip, STATUS_FAIL); + + size = xd_card->zone_cnt * sizeof(struct zone_entry); + RTS51X_DEBUGP("Buffer size for l2p table is %d\n", size); + + xd_card->zone = vmalloc(size); + if (!xd_card->zone) + TRACE_RET(chip, STATUS_NOMEM); + + for (i = 0; i < xd_card->zone_cnt; i++) { + xd_card->zone[i].build_flag = 0; + xd_card->zone[i].l2p_table = NULL; + xd_card->zone[i].free_table = NULL; + xd_card->zone[i].get_index = 0; + xd_card->zone[i].set_index = 0; + xd_card->zone[i].unused_blk_cnt = 0; + } + + return STATUS_SUCCESS; +} + +static inline void free_zone(struct zone_entry *zone) +{ + RTS51X_DEBUGP("free_zone\n"); + if (!zone) + return; + zone->build_flag = 0; + zone->set_index = 0; + zone->get_index = 0; + zone->unused_blk_cnt = 0; + if (zone->l2p_table) { + vfree(zone->l2p_table); + zone->l2p_table = NULL; + } + if (zone->free_table) { + vfree(zone->free_table); + zone->free_table = NULL; + } +} + +static void xd_set_unused_block(struct rts51x_chip *chip, u32 phy_blk) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct zone_entry *zone; + int zone_no; + + zone_no = (int)phy_blk >> 10; + if (zone_no >= xd_card->zone_cnt) { + RTS51X_DEBUGP("Set unused block to invalid zone" + "(zone_no = %d, zone_cnt = %d)\n", + zone_no, xd_card->zone_cnt); + return; + } + zone = &(xd_card->zone[zone_no]); + + if (zone->free_table == NULL) { + if (xd_build_l2p_tbl(chip, zone_no) != STATUS_SUCCESS) + return; + } + + if ((zone->set_index >= XD_FREE_TABLE_CNT) + || (zone->set_index < 0)) { + free_zone(zone); + RTS51X_DEBUGP("Set unused block fail, invalid set_index\n"); + return; + } + + RTS51X_DEBUGP("Set unused block to index %d\n", zone->set_index); + + zone->free_table[zone->set_index++] = (u16) (phy_blk & 0x3ff); + if (zone->set_index >= XD_FREE_TABLE_CNT) + zone->set_index = 0; + zone->unused_blk_cnt++; +} + +static u32 xd_get_unused_block(struct rts51x_chip *chip, int zone_no) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct zone_entry *zone; + u32 phy_blk; + + if (zone_no >= xd_card->zone_cnt) { + RTS51X_DEBUGP("Get unused block from invalid zone" + "(zone_no = %d, zone_cnt = %d)\n", + zone_no, xd_card->zone_cnt); + TRACE_RET(chip, BLK_NOT_FOUND); + } + zone = &(xd_card->zone[zone_no]); + + if ((zone->unused_blk_cnt == 0) || + (zone->set_index == zone->get_index)) { + free_zone(zone); + RTS51X_DEBUGP("Get unused block fail," + "no unused block available\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + if ((zone->get_index >= XD_FREE_TABLE_CNT) || (zone->get_index < 0)) { + free_zone(zone); + RTS51X_DEBUGP("Get unused block fail, invalid get_index\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + + RTS51X_DEBUGP("Get unused block from index %d\n", zone->get_index); + + phy_blk = zone->free_table[zone->get_index]; + zone->free_table[zone->get_index++] = 0xFFFF; + if (zone->get_index >= XD_FREE_TABLE_CNT) + zone->get_index = 0; + zone->unused_blk_cnt--; + + phy_blk += ((u32) (zone_no) << 10); + return phy_blk; +} + +static void xd_set_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off, + u16 phy_off) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct zone_entry *zone; + + zone = &(xd_card->zone[zone_no]); + zone->l2p_table[log_off] = phy_off; +} + +static u32 xd_get_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct zone_entry *zone; + int retval; + + zone = &(xd_card->zone[zone_no]); + if (zone->l2p_table[log_off] == 0xFFFF) { + u32 phy_blk = 0; + int i; + + retval = xd_delay_write(chip); + if (retval != STATUS_SUCCESS) { + RTS51X_DEBUGP("In xd_get_l2p_tbl," + "delay write fail!\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + + if (zone->unused_blk_cnt <= 0) { + RTS51X_DEBUGP("No unused block!\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + + for (i = 0; i < zone->unused_blk_cnt; i++) { + phy_blk = xd_get_unused_block(chip, zone_no); + if (phy_blk == BLK_NOT_FOUND) { + RTS51X_DEBUGP("No unused block available!\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + + retval = + xd_init_page(chip, phy_blk, log_off, 0, + xd_card->page_off + 1); + if (retval == STATUS_SUCCESS) + break; + } + if (i >= zone->unused_blk_cnt) { + RTS51X_DEBUGP("No good unused block available!\n"); + TRACE_RET(chip, BLK_NOT_FOUND); + } + + xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (phy_blk & 0x3FF)); + return phy_blk; + } + + return (u32) zone->l2p_table[log_off] + ((u32) (zone_no) << 10); +} + +int reset_xd_card(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + + memset(xd_card, 0, sizeof(struct xd_info)); + + xd_card->block_shift = 0; + xd_card->page_off = 0; + xd_card->addr_cycle = 0; + xd_card->capacity = 0; + xd_card->zone_cnt = 0; + xd_card->cis_block = 0xFFFF; + xd_card->delay_write.delay_write_flag = 0; + + enable_card_clock(chip, XD_CARD); + + retval = reset_xd(chip); + if (retval != STATUS_SUCCESS) { + if (chip->option.reset_or_rw_fail_set_pad_drive) { + rts51x_write_register(chip, CARD_DRIVE_SEL, + SD20_DRIVE_MASK, DRIVE_8mA); + } + TRACE_RET(chip, retval); + } + + retval = xd_init_l2p_tbl(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +static int xd_mark_bad_block(struct rts51x_chip *chip, u32 phy_blk) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + u32 page_addr; + u8 reg = 0; + + RTS51X_DEBUGP("mark block 0x%x as bad block\n", phy_blk); + + if (phy_blk == BLK_NOT_FOUND) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, XD_GPG); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, + XD_LATER_BBLK); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR2_H, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR2_L, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED0, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED1, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED2, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED3, 0xFF, 0xFF); + + page_addr = phy_blk << xd_card->block_shift; + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + /* Specify page count */ + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, + xd_card->page_off + 1); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_WRITE_REDUNDANT); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + retval = rts51x_get_rsp(chip, 1, 100); + + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + rts51x_ep0_read_register(chip, XD_DAT, ®); + if (reg & PROGRAM_ERROR) + xd_set_err_code(chip, XD_PRG_ERROR); + else + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int xd_init_page(struct rts51x_chip *chip, u32 phy_blk, u16 logoff, + u8 start_page, u8 end_page) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + u32 page_addr; + u8 reg = 0; + + RTS51X_DEBUGP("Init block 0x%x\n", phy_blk); + + if (start_page > end_page) + TRACE_RET(chip, STATUS_FAIL); + if (phy_blk == BLK_NOT_FOUND) + TRACE_RET(chip, STATUS_FAIL); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, 0xFF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, + (u8) (logoff >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, + (u8) logoff); + + page_addr = (phy_blk << xd_card->block_shift) + start_page; + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_BA_TRANSFORM, + XD_BA_TRANSFORM); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, + (end_page - start_page)); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_WRITE_REDUNDANT); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + retval = rts51x_get_rsp(chip, 1, 500); + + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + rts51x_ep0_read_register(chip, XD_DAT, ®); + if (reg & PROGRAM_ERROR) { + xd_mark_bad_block(chip, phy_blk); + xd_set_err_code(chip, XD_PRG_ERROR); + } else { + xd_set_err_code(chip, XD_TO_ERROR); + } + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; +} + +static int xd_copy_page(struct rts51x_chip *chip, + u32 old_blk, u32 new_blk, u8 start_page, u8 end_page) +{ + struct xd_info *xd_card = &(chip->xd_card); + u32 old_page, new_page; + u8 i, reg = 0; + int retval; + + RTS51X_DEBUGP("Copy page from block 0x%x to block 0x%x\n", old_blk, + new_blk); + + if (start_page > end_page) + TRACE_RET(chip, STATUS_FAIL); + + if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) + TRACE_RET(chip, STATUS_FAIL); + + old_page = (old_blk << xd_card->block_shift) + start_page; + new_page = (new_blk << xd_card->block_shift) + start_page; + + XD_CLR_BAD_NEWBLK(xd_card); + + RTS51X_WRITE_REG(chip, CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER); + + for (i = start_page; i < end_page; i++) { + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { + RTS51X_WRITE_REG(chip, CARD_STOP, XD_STOP | XD_CLR_ERR, + XD_STOP | XD_CLR_ERR); + xd_set_err_code(chip, XD_NO_CARD); + TRACE_RET(chip, STATUS_FAIL); + } + + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, old_page, XD_RW_ADDR); + + /* Single page read */ + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, + XD_AUTO_CHK_DATA_STATUS, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_READ_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END, XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR | STAGE_XD_STATUS, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 4, 500); + if ((retval != STATUS_SUCCESS) || + (chip->rsp_buf[2] & (XD_ECC1_ERROR | XD_ECC2_ERROR))) { + rts51x_clear_xd_error(chip); + reg = 0; + rts51x_ep0_read_register(chip, XD_CTL, ®); + if (reg & (XD_ECC1_ERROR | XD_ECC2_ERROR)) { + wait_timeout(100); + + if (monitor_card_cd(chip, XD_CARD) == + CD_NOT_EXIST) { + xd_set_err_code(chip, XD_NO_CARD); + TRACE_RET(chip, STATUS_FAIL); + } + + if (((reg & + (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) + == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) + || ((reg & (XD_ECC2_ERROR | + XD_ECC2_UNCORRECTABLE)) == + (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE))) { + RTS51X_WRITE_REG(chip, XD_PAGE_STATUS, + 0xFF, XD_BPG); + RTS51X_WRITE_REG(chip, XD_BLOCK_STATUS, + 0xFF, XD_GBLK); + XD_SET_BAD_OLDBLK(xd_card); + RTS51X_DEBUGP("old block 0x%x" + "ecc error\n", old_blk); + } + } else { + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + } + if (XD_CHK_BAD_OLDBLK(xd_card)) + rts51x_clear_xd_error(chip); + + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, new_page, XD_RW_ADDR); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_WRITE_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END, XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, 300); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + reg = 0; + rts51x_ep0_read_register(chip, XD_DAT, ®); + if (reg & PROGRAM_ERROR) { + xd_mark_bad_block(chip, new_blk); + xd_set_err_code(chip, XD_PRG_ERROR); + XD_SET_BAD_NEWBLK(xd_card); + } else { + xd_set_err_code(chip, XD_TO_ERROR); + } + TRACE_RET(chip, retval); + } + + old_page++; + new_page++; + } + + return STATUS_SUCCESS; +} + +#ifdef XD_SPEEDUP +static int xd_auto_copy_page(struct rts51x_chip *chip, + u32 old_blk, u32 new_blk, + u8 start_page, u8 end_page) +{ + struct xd_info *xd_card = &(chip->xd_card); + u32 old_page, new_page; + int retval; + u8 page_count; + + RTS51X_DEBUGP("Auto copy page from block 0x%x to block 0x%x\n", + old_blk, new_blk); + + if (start_page > end_page) + TRACE_RET(chip, STATUS_FAIL); + + page_count = end_page - start_page; + + if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) + TRACE_RET(chip, STATUS_FAIL); + + old_page = (old_blk << xd_card->block_shift) + start_page; + new_page = (new_blk << xd_card->block_shift) + start_page; + + XD_CLR_BAD_NEWBLK(xd_card); + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WAITTIME, 0x03, WAIT_FF); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_PAGELEN, 0xFF, page_count); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR0, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR1, 0xFF, + (u8) old_page); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR2, 0xFF, + (u8) (old_page >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR3, 0xFF, + (u8) (old_page >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR4, 0xFF, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR0, 0xFF, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR1, 0xFF, + (u8) new_page); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR2, 0xFF, + (u8) (new_page >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR3, 0xFF, + (u8) (new_page >> 16)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR4, 0xFF, 0); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + PINGPONG_BUFFER); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, + XD_BA_TRANSFORM | XD_ADDR_MASK, 0 | xd_card->addr_cycle); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, + XD_AUTO_CHK_DATA_STATUS, 0); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_COPY_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_GOTO(chip, Copy_Fail); + } + + retval = rts51x_get_rsp(chip, 1, 800); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_GOTO(chip, Copy_Fail); + } + + return STATUS_SUCCESS; + +Copy_Fail: + retval = xd_copy_page(chip, old_blk, new_blk, start_page, end_page); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} +#endif + +static int xd_reset_cmd(struct rts51x_chip *chip) +{ + int retval; + u8 xd_dat, xd_ctl; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_RESET); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); + rts51x_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 3, 100); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + xd_dat = chip->rsp_buf[1]; + xd_ctl = chip->rsp_buf[2]; + if (((xd_dat & READY_FLAG) == READY_STATE) && (xd_ctl & XD_RDY)) + return STATUS_SUCCESS; + + TRACE_RET(chip, STATUS_FAIL); +} + +static int xd_erase_block(struct rts51x_chip *chip, u32 phy_blk) +{ + struct xd_info *xd_card = &(chip->xd_card); + u32 page_addr; + u8 reg = 0, xd_dat; + int i, retval; + + if (phy_blk == BLK_NOT_FOUND) + TRACE_RET(chip, STATUS_FAIL); + + page_addr = phy_blk << xd_card->block_shift; + + for (i = 0; i < 3; i++) { + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, page_addr, XD_ERASE_ADDR); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_ERASE); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END, XD_TRANSFER_END); + rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 2, 300); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + rts51x_ep0_read_register(chip, XD_DAT, ®); + if (reg & PROGRAM_ERROR) { + xd_mark_bad_block(chip, phy_blk); + xd_set_err_code(chip, XD_PRG_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } else { + xd_set_err_code(chip, XD_ERASE_FAIL); + } + retval = xd_reset_cmd(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + continue; + } + xd_dat = chip->rsp_buf[1]; + if (xd_dat & PROGRAM_ERROR) { + xd_mark_bad_block(chip, phy_blk); + xd_set_err_code(chip, XD_PRG_ERROR); + TRACE_RET(chip, STATUS_FAIL); + } + + return STATUS_SUCCESS; + } + + xd_mark_bad_block(chip, phy_blk); + xd_set_err_code(chip, XD_ERASE_FAIL); + TRACE_RET(chip, STATUS_FAIL); +} + +static int xd_build_l2p_tbl(struct rts51x_chip *chip, int zone_no) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct zone_entry *zone; + int retval; + u32 start, end, i; + u16 max_logoff, cur_fst_page_logoff, cur_lst_page_logoff, + ent_lst_page_logoff; + u8 redunt[11]; + + RTS51X_DEBUGP("xd_build_l2p_tbl: %d\n", zone_no); + + if (xd_card->zone == NULL) { + retval = xd_init_l2p_tbl(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + if (xd_card->zone[zone_no].build_flag) { + RTS51X_DEBUGP("l2p table of zone %d has been built\n", + zone_no); + return STATUS_SUCCESS; + } + + zone = &(xd_card->zone[zone_no]); + + if (zone->l2p_table == NULL) { + zone->l2p_table = vmalloc(2000); + if (zone->l2p_table == NULL) + TRACE_GOTO(chip, Build_Fail); + } + memset((u8 *) (zone->l2p_table), 0xff, 2000); + + if (zone->free_table == NULL) { + zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2); + if (zone->free_table == NULL) + TRACE_GOTO(chip, Build_Fail); + } + memset((u8 *) (zone->free_table), 0xff, XD_FREE_TABLE_CNT * 2); + + if (zone_no == 0) { + if (xd_card->cis_block == 0xFFFF) + start = 0; + else + start = xd_card->cis_block + 1; + if (XD_CHK_4MB(xd_card)) { + end = 0x200; + max_logoff = 499; + } else { + end = 0x400; + max_logoff = 999; + } + } else { + start = (u32) (zone_no) << 10; + end = (u32) (zone_no + 1) << 10; + max_logoff = 999; + } + + RTS51X_DEBUGP("start block 0x%x, end block 0x%x\n", start, end); + + zone->set_index = zone->get_index = 0; + zone->unused_blk_cnt = 0; + + for (i = start; i < end; i++) { + u32 page_addr = i << xd_card->block_shift; + u32 phy_block; + + retval = xd_read_redundant(chip, page_addr, redunt, 11); + if (retval != STATUS_SUCCESS) + continue; + + if (redunt[BLOCK_STATUS] != 0xFF) { + RTS51X_DEBUGP("bad block\n"); + continue; + } + + if (xd_check_data_blank(redunt)) { + RTS51X_DEBUGP("blank block\n"); + xd_set_unused_block(chip, i); + continue; + } + + cur_fst_page_logoff = xd_load_log_block_addr(redunt); + if ((cur_fst_page_logoff == 0xFFFF) + || (cur_fst_page_logoff > max_logoff)) { + retval = xd_erase_block(chip, i); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, i); + continue; + } + if ((zone_no == 0) && (cur_fst_page_logoff == 0) + && (redunt[PAGE_STATUS] != XD_GPG)) + XD_SET_MBR_FAIL(xd_card); + + if (zone->l2p_table[cur_fst_page_logoff] == 0xFFFF) { + zone->l2p_table[cur_fst_page_logoff] = + (u16) (i & 0x3FF); + continue; + } + + phy_block = + zone->l2p_table[cur_fst_page_logoff] + + ((u32) ((zone_no) << 10)); + + page_addr = ((i + 1) << xd_card->block_shift) - 1; + + retval = xd_read_redundant(chip, page_addr, redunt, 11); + if (retval != STATUS_SUCCESS) + continue; + + cur_lst_page_logoff = xd_load_log_block_addr(redunt); + if (cur_lst_page_logoff == cur_fst_page_logoff) { + int m; + + page_addr = + ((phy_block + 1) << xd_card->block_shift) - 1; + + for (m = 0; m < 3; m++) { + retval = + xd_read_redundant(chip, page_addr, redunt, + 11); + if (retval == STATUS_SUCCESS) + break; + } + + if (m == 3) { + zone->l2p_table[cur_fst_page_logoff] = + (u16) (i & 0x3FF); + retval = xd_erase_block(chip, phy_block); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, phy_block); + continue; + } + + ent_lst_page_logoff = xd_load_log_block_addr(redunt); + if (ent_lst_page_logoff != cur_fst_page_logoff) { + zone->l2p_table[cur_fst_page_logoff] = + (u16) (i & 0x3FF); + retval = xd_erase_block(chip, phy_block); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, phy_block); + continue; + } else { + retval = xd_erase_block(chip, i); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, i); + } + } else { + retval = xd_erase_block(chip, i); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, i); + } + } + + if (XD_CHK_4MB(xd_card)) + end = 500; + else + end = 1000; + + i = 0; + for (start = 0; start < end; start++) { + if (zone->l2p_table[start] == 0xFFFF) + i++; + } + + RTS51X_DEBUGP("Block count %d, invalid L2P entry %d\n", end, i); + RTS51X_DEBUGP("Total unused block: %d\n", zone->unused_blk_cnt); + + if ((zone->unused_blk_cnt - i) < 1) + chip->card_wp |= XD_CARD; + + zone->build_flag = 1; + + return STATUS_SUCCESS; + +Build_Fail: + if (zone->l2p_table) { + vfree(zone->l2p_table); + zone->l2p_table = NULL; + } + if (zone->free_table) { + vfree(zone->free_table); + zone->free_table = NULL; + } + + return STATUS_FAIL; +} + +static int xd_send_cmd(struct rts51x_chip *chip, u8 cmd) +{ + int retval; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DAT, 0xFF, cmd); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_SET_CMD); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = rts51x_get_rsp(chip, 1, 200); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int xd_read_multiple_pages(struct rts51x_chip *chip, u32 phy_blk, + u32 log_blk, u8 start_page, u8 end_page, + u8 *buf, void **ptr, unsigned int *offset) +{ + struct xd_info *xd_card = &(chip->xd_card); + u32 page_addr, new_blk; + u16 log_off; + u8 reg_val, page_cnt; + int zone_no, retval, i; + + if (start_page > end_page) + TRACE_RET(chip, STATUS_FAIL); + + page_cnt = end_page - start_page; + zone_no = (int)(log_blk / 1000); + log_off = (u16) (log_blk % 1000); + + if ((phy_blk & 0x3FF) == 0x3FF) { + for (i = 0; i < 256; i++) { + page_addr = ((u32) i) << xd_card->block_shift; + + retval = xd_read_redundant(chip, page_addr, NULL, 0); + if (retval == STATUS_SUCCESS) + break; + + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { + xd_set_err_code(chip, XD_NO_CARD); + TRACE_RET(chip, STATUS_FAIL); + } + } + } + + page_addr = (phy_blk << xd_card->block_shift) + start_page; + + rts51x_init_cmd(chip); + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_PPB_TO_SIE, + XD_PPB_TO_SIE); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, page_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, + XD_AUTO_CHK_DATA_STATUS, XD_AUTO_CHK_DATA_STATUS); + + trans_dma_enable(chip->srb->sc_data_direction, chip, page_cnt * 512, + DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_READ_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, + XD_TRANSFER_END | XD_PPB_EMPTY, + XD_TRANSFER_END | XD_PPB_EMPTY); + + retval = rts51x_send_cmd(chip, MODE_CDIR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), (void *)buf, + ptr, offset, page_cnt * 512, + scsi_sg_count(chip->srb), NULL, 2000); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + + if (retval == STATUS_TIMEDOUT) { + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, retval); + } else { + TRACE_GOTO(chip, Fail); + } + } + retval = rts51x_get_rsp(chip, 1, 200); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + + if (retval == STATUS_TIMEDOUT) { + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, retval); + } else { + TRACE_GOTO(chip, Fail); + } + } + + return STATUS_SUCCESS; + +Fail: + rts51x_ep0_read_register(chip, XD_PAGE_STATUS, ®_val); + RTS51X_DEBUGP("XD_PAGE_STATUS: 0x%x\n", reg_val); + + if (reg_val != XD_GPG) + xd_set_err_code(chip, XD_PRG_ERROR); + + rts51x_ep0_read_register(chip, XD_CTL, ®_val); + RTS51X_DEBUGP("XD_CTL: 0x%x\n", reg_val); + + /* Handle uncorrectable ECC error */ + if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) + == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) + || ((reg_val & (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE)) + == (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE))) { + wait_timeout(100); + + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { + xd_set_err_code(chip, XD_NO_CARD); + TRACE_RET(chip, STATUS_FAIL); + } + + xd_set_err_code(chip, XD_ECC_ERROR); + + new_blk = xd_get_unused_block(chip, zone_no); + if (new_blk == NO_NEW_BLK) { + XD_CLR_BAD_OLDBLK(xd_card); + TRACE_RET(chip, STATUS_FAIL); + } +#ifdef XD_SPEEDUP + retval = + xd_auto_copy_page(chip, phy_blk, new_blk, 0, + xd_card->page_off + 1); +#else + retval = + xd_copy_page(chip, phy_blk, new_blk, 0, + xd_card->page_off + 1); +#endif + if (retval != STATUS_SUCCESS) { + if (!XD_CHK_BAD_NEWBLK(xd_card)) { + retval = xd_erase_block(chip, new_blk); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, new_blk); + } else { + XD_CLR_BAD_NEWBLK(xd_card); + } + XD_CLR_BAD_OLDBLK(xd_card); + TRACE_RET(chip, STATUS_FAIL); + } + xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); + xd_erase_block(chip, phy_blk); + xd_mark_bad_block(chip, phy_blk); + XD_CLR_BAD_OLDBLK(xd_card); + } + + TRACE_RET(chip, STATUS_FAIL); +} + +static int xd_finish_write(struct rts51x_chip *chip, + u32 old_blk, u32 new_blk, u32 log_blk, u8 page_off) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval, zone_no; + u16 log_off; + + RTS51X_DEBUGP("xd_finish_write, old_blk = 0x%x, new_blk = 0x%x," + "log_blk = 0x%x\n", old_blk, new_blk, log_blk); + + if (page_off > xd_card->page_off) + TRACE_RET(chip, STATUS_FAIL); + + zone_no = (int)(log_blk / 1000); + log_off = (u16) (log_blk % 1000); + + if (old_blk == BLK_NOT_FOUND) { + retval = xd_init_page(chip, new_blk, log_off, + page_off, xd_card->page_off + 1); + if (retval != STATUS_SUCCESS) { + retval = xd_erase_block(chip, new_blk); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, new_blk); + TRACE_RET(chip, STATUS_FAIL); + } + } else { +#ifdef XD_SPEEDUP + retval = xd_auto_copy_page(chip, old_blk, new_blk, + page_off, xd_card->page_off + 1); +#else + retval = xd_copy_page(chip, old_blk, new_blk, + page_off, xd_card->page_off + 1); +#endif + if (retval != STATUS_SUCCESS) { + if (!XD_CHK_BAD_NEWBLK(xd_card)) { + retval = xd_erase_block(chip, new_blk); + if (retval == STATUS_SUCCESS) + xd_set_unused_block(chip, new_blk); + } + XD_CLR_BAD_NEWBLK(xd_card); + TRACE_RET(chip, STATUS_FAIL); + } + + retval = xd_erase_block(chip, old_blk); + if (retval == STATUS_SUCCESS) { + if (XD_CHK_BAD_OLDBLK(xd_card)) { + xd_mark_bad_block(chip, old_blk); + XD_CLR_BAD_OLDBLK(xd_card); + } else { + /* Add source block to unused block */ + xd_set_unused_block(chip, old_blk); + } + } else { + xd_set_err_code(chip, XD_NO_ERROR); + XD_CLR_BAD_OLDBLK(xd_card); + } + } + + /* Add target block to L2P table */ + xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); + + return STATUS_SUCCESS; +} + +static int xd_prepare_write(struct rts51x_chip *chip, + u32 old_blk, u32 new_blk, u32 log_blk, u8 page_off) +{ + int retval; + + RTS51X_DEBUGP("xd_prepare_write, old_blk = 0x%x, new_blk = 0x%x," + "log_blk = 0x%x, page_off = %d\n", + old_blk, new_blk, log_blk, (int)page_off); + + if (page_off) { +#ifdef XD_SPEEDUP + retval = xd_auto_copy_page(chip, old_blk, new_blk, 0, page_off); +#else + retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off); +#endif + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +static int xd_write_multiple_pages(struct rts51x_chip *chip, u32 old_blk, + u32 new_blk, u32 log_blk, u8 start_page, + u8 end_page, u8 *buf, void **ptr, + unsigned int *offset) +{ + struct xd_info *xd_card = &(chip->xd_card); + u32 page_addr; + int zone_no, retval; + u16 log_off; + u8 page_cnt, reg_val; + + RTS51X_DEBUGP("xd_write_multiple_pages, old_blk = 0x%x," + "new_blk = 0x%x, log_blk = 0x%x\n", + old_blk, new_blk, log_blk); + + if (start_page > end_page) + TRACE_RET(chip, STATUS_FAIL); + + page_cnt = end_page - start_page; + zone_no = (int)(log_blk / 1000); + log_off = (u16) (log_blk % 1000); + + page_addr = (new_blk << xd_card->block_shift) + start_page; + + /* Send index command */ + retval = xd_send_cmd(chip, READ1_1); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + rts51x_init_cmd(chip); + + /* Prepare redundant field */ + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, + (u8) (log_off >> 8)); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, + (u8) log_off); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, XD_GBLK); + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, XD_GPG); + + xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); + + /* Transform the block address by hardware */ + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_BA_TRANSFORM, + XD_BA_TRANSFORM); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, page_cnt); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, + RING_BUFFER); + + trans_dma_enable(chip->srb->sc_data_direction, chip, page_cnt * 512, + DMA_512); + + rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, + XD_TRANSFER_START | XD_WRITE_PAGES); + rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, + XD_TRANSFER_END); + + retval = rts51x_send_cmd(chip, MODE_CDOR, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + retval = + rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), (void *)buf, + ptr, offset, page_cnt * 512, + scsi_sg_count(chip->srb), NULL, 2000); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + + if (retval == STATUS_TIMEDOUT) { + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, retval); + } else { + TRACE_GOTO(chip, Fail); + } + } + retval = rts51x_get_rsp(chip, 1, 200); + if (retval != STATUS_SUCCESS) { + rts51x_clear_xd_error(chip); + + if (retval == STATUS_TIMEDOUT) { + xd_set_err_code(chip, XD_TO_ERROR); + TRACE_RET(chip, retval); + } else { + TRACE_GOTO(chip, Fail); + } + } + + if (end_page == (xd_card->page_off + 1)) { + xd_card->delay_write.delay_write_flag = 0; + + if (old_blk != BLK_NOT_FOUND) { + retval = xd_erase_block(chip, old_blk); + if (retval == STATUS_SUCCESS) { + if (XD_CHK_BAD_OLDBLK(xd_card)) { + xd_mark_bad_block(chip, old_blk); + XD_CLR_BAD_OLDBLK(xd_card); + } else { + xd_set_unused_block(chip, old_blk); + } + } else { + xd_set_err_code(chip, XD_NO_ERROR); + XD_CLR_BAD_OLDBLK(xd_card); + } + } + xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); + } + + return STATUS_SUCCESS; + +Fail: + rts51x_ep0_read_register(chip, XD_DAT, ®_val); + RTS51X_DEBUGP("XD_DAT: 0x%x\n", reg_val); + + if (reg_val & PROGRAM_ERROR) { + xd_set_err_code(chip, XD_PRG_ERROR); + xd_mark_bad_block(chip, new_blk); + } + + TRACE_RET(chip, STATUS_FAIL); +} + +int xd_delay_write(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + struct xd_delay_write_tag *delay_write = &(xd_card->delay_write); + int retval; + + if (delay_write->delay_write_flag) { + RTS51X_DEBUGP("xd_delay_write\n"); + retval = xd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + delay_write->delay_write_flag = 0; + retval = xd_finish_write(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + delay_write->logblock, + delay_write->pageoff); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + } + + return STATUS_SUCCESS; +} + +int xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt) +{ + struct xd_info *xd_card = &(chip->xd_card); + unsigned int lun = SCSI_LUN(srb); + struct xd_delay_write_tag *delay_write = &(xd_card->delay_write); + int retval, zone_no; + u32 log_blk, old_blk = 0, new_blk = 0; + u16 log_off, total_sec_cnt = sector_cnt; + u8 start_page, end_page = 0, page_cnt; + u8 *buf; + void *ptr = NULL; + unsigned int offset = 0; + + xd_set_err_code(chip, XD_NO_ERROR); + + xd_card->counter = 0; + + RTS51X_DEBUGP("xd_rw: scsi_bufflen = %d, scsi_sg_count = %d\n", + scsi_bufflen(srb), scsi_sg_count(srb)); + RTS51X_DEBUGP("Data direction: %s\n", + (srb->sc_data_direction == + DMA_TO_DEVICE) ? "write" : "read"); + + buf = (u8 *) scsi_sglist(srb); + + retval = xd_switch_clock(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + log_blk = start_sector >> xd_card->block_shift; + start_page = (u8) start_sector & xd_card->page_off; + zone_no = (int)(log_blk / 1000); + log_off = (u16) (log_blk % 1000); + + RTS51X_DEBUGP("log_blk = 0x%x\n", log_blk); + + if (xd_card->zone[zone_no].build_flag == 0) { + retval = xd_build_l2p_tbl(chip, zone_no); + if (retval != STATUS_SUCCESS) { + chip->card_fail |= XD_CARD; + set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, retval); + } + } + + if (srb->sc_data_direction == DMA_TO_DEVICE) { + if (delay_write->delay_write_flag && + (delay_write->logblock == log_blk) && + (start_page > delay_write->pageoff)) { + delay_write->delay_write_flag = 0; + if (delay_write->old_phyblock != BLK_NOT_FOUND) { +#ifdef XD_SPEEDUP + retval = xd_auto_copy_page(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + delay_write->pageoff, start_page); +#else + retval = xd_copy_page(chip, + delay_write->old_phyblock, + delay_write->new_phyblock, + delay_write->pageoff, + start_page); +#endif + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + } + old_blk = delay_write->old_phyblock; + new_blk = delay_write->new_phyblock; + } else if (delay_write->delay_write_flag && + (delay_write->logblock == log_blk) && + (start_page == delay_write->pageoff)) { + delay_write->delay_write_flag = 0; + old_blk = delay_write->old_phyblock; + new_blk = delay_write->new_phyblock; + } else { + retval = xd_delay_write(chip); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); + new_blk = xd_get_unused_block(chip, zone_no); + if ((old_blk == BLK_NOT_FOUND) + || (new_blk == BLK_NOT_FOUND)) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + + retval = + xd_prepare_write(chip, old_blk, new_blk, log_blk, + start_page); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, XD_CARD) == + CD_NOT_EXIST) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, STATUS_FAIL); + } + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, retval); + } + } + } else { + retval = xd_delay_write(chip); + if (retval != STATUS_SUCCESS) { + if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, STATUS_FAIL); + } + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, retval); + } + + old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); + if (old_blk == BLK_NOT_FOUND) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + RTS51X_DEBUGP("old_blk = 0x%x\n", old_blk); + if (srb->sc_data_direction == DMA_TO_DEVICE) + RTS51X_DEBUGP("new_blk = 0x%x\n", new_blk); + + while (total_sec_cnt) { + if ((start_page + total_sec_cnt) > (xd_card->page_off + 1)) + end_page = xd_card->page_off + 1; + else + end_page = start_page + (u8) total_sec_cnt; + page_cnt = end_page - start_page; + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + retval = xd_read_multiple_pages(chip, old_blk, log_blk, + start_page, end_page, + buf, &ptr, &offset); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } else { + retval = + xd_write_multiple_pages(chip, old_blk, new_blk, + log_blk, start_page, + end_page, buf, &ptr, + &offset); + if (retval != STATUS_SUCCESS) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + total_sec_cnt -= page_cnt; + + if (total_sec_cnt == 0) + break; + + log_blk++; + zone_no = (int)(log_blk / 1000); + log_off = (u16) (log_blk % 1000); + + if (xd_card->zone[zone_no].build_flag == 0) { + retval = xd_build_l2p_tbl(chip, zone_no); + if (retval != STATUS_SUCCESS) { + chip->card_fail |= XD_CARD; + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_NOT_PRESENT); + TRACE_RET(chip, retval); + } + } + + old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); + if (old_blk == BLK_NOT_FOUND) { + if (srb->sc_data_direction == DMA_FROM_DEVICE) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); + } else { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + } + TRACE_RET(chip, STATUS_FAIL); + } + + if (srb->sc_data_direction == DMA_TO_DEVICE) { + new_blk = xd_get_unused_block(chip, zone_no); + if (new_blk == BLK_NOT_FOUND) { + set_sense_type(chip, lun, + SENSE_TYPE_MEDIA_WRITE_ERR); + TRACE_RET(chip, STATUS_FAIL); + } + } + + start_page = 0; + } + + if ((srb->sc_data_direction == DMA_TO_DEVICE) && + (end_page != (xd_card->page_off + 1))) { + delay_write->delay_write_flag = 1; + delay_write->old_phyblock = old_blk; + delay_write->new_phyblock = new_blk; + delay_write->logblock = log_blk; + delay_write->pageoff = end_page; + } + + scsi_set_resid(srb, 0); + + return STATUS_SUCCESS; +} + +void xd_free_l2p_tbl(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int i = 0; + + if (xd_card->zone != NULL) { + for (i = 0; i < xd_card->zone_cnt; i++) { + if (xd_card->zone[i].l2p_table != NULL) { + vfree(xd_card->zone[i].l2p_table); + xd_card->zone[i].l2p_table = NULL; + } + if (xd_card->zone[i].free_table != NULL) { + vfree(xd_card->zone[i].free_table); + xd_card->zone[i].free_table = NULL; + } + } + vfree(xd_card->zone); + xd_card->zone = NULL; + } +} + +void xd_cleanup_work(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + + if (xd_card->delay_write.delay_write_flag) { + RTS51X_DEBUGP("xD: delay write\n"); + xd_delay_write(chip); + xd_card->counter = 0; + } +} + +int xd_power_off_card3v3(struct rts51x_chip *chip) +{ + int retval; + + rts51x_init_cmd(chip); + + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, XD_CLK_EN, 0); + + if (chip->asic_code) + xd_pull_ctl_disable(chip); + else + rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, 0xDF); + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); + if (!chip->option.FT2_fast_mode) { + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, + POWER_OFF); + if (CHECK_PKG(chip, LQFP48) + || chip->option.rts5129_D3318_off_enable) + rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, + DV3318_AUTO_PWR_OFF, 0); + } + + retval = rts51x_send_cmd(chip, MODE_C, 100); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + return STATUS_SUCCESS; +} + +int release_xd_card(struct rts51x_chip *chip) +{ + struct xd_info *xd_card = &(chip->xd_card); + int retval; + + RTS51X_DEBUGP("elease_xd_card\n"); + + chip->card_ready &= ~XD_CARD; + chip->card_fail &= ~XD_CARD; + chip->card_wp &= ~XD_CARD; + + xd_card->delay_write.delay_write_flag = 0; + + xd_free_l2p_tbl(chip); + + rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); + + retval = xd_power_off_card3v3(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, retval); + + if (chip->asic_code && CHECK_PKG(chip, QFN24)) + wait_timeout(20); + + return STATUS_SUCCESS; +} diff --git a/drivers/staging/rts5139/xd.h b/drivers/staging/rts5139/xd.h new file mode 100644 index 00000000000..fa695903ba6 --- /dev/null +++ b/drivers/staging/rts5139/xd.h @@ -0,0 +1,193 @@ +/* Driver for Realtek RTS51xx USB card reader + * Header file + * + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + * + * Author: + * wwang (wei_wang@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + * Maintainer: + * Edwin Rong (edwin_rong@realsil.com.cn) + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China + */ + +#ifndef __RTS51X_XD_H +#define __RTS51X_XD_H + +/* Error Codes */ +#define XD_NO_ERROR 0x00 +#define XD_NO_MEMORY 0x80 +#define XD_PRG_ERROR 0x40 +#define XD_NO_CARD 0x20 +#define XD_READ_FAIL 0x10 +#define XD_ERASE_FAIL 0x08 +#define XD_WRITE_FAIL 0x04 +#define XD_ECC_ERROR 0x02 +#define XD_TO_ERROR 0x01 + +/* XD Commands */ +#define READ1_1 0x00 +#define READ1_2 0x01 +#define READ2 0x50 +#define READ_ID 0x90 +#define RESET 0xff +#define PAGE_PRG_1 0x80 +#define PAGE_PRG_2 0x10 +#define BLK_ERASE_1 0x60 +#define BLK_ERASE_2 0xD0 +#define READ_STS 0x70 +#define READ_xD_ID 0x9A +#define COPY_BACK_512 0x8A +#define COPY_BACK_2K 0x85 +#define READ1_1_2 0x30 +#define READ1_1_3 0x35 +#define CHG_DAT_OUT_1 0x05 +#define RDM_DAT_OUT_1 0x05 +#define CHG_DAT_OUT_2 0xE0 +#define RDM_DAT_OUT_2 0xE0 +#define CHG_DAT_OUT_2 0xE0 +#define CHG_DAT_IN_1 0x85 +#define CACHE_PRG 0x15 + +/* Redundant Area Related */ +#define XD_EXTRA_SIZE 0x10 +#define XD_2K_EXTRA_SIZE 0x40 + +/* Define for XD Status */ +#define NOT_WRITE_PROTECTED 0x80 +#define READY_STATE 0x40 +#define PROGRAM_ERROR 0x01 +#define PROGRAM_ERROR_N_1 0x02 +#define INTERNAL_READY 0x20 +#define READY_FLAG 0x5F + +/* Define for device code */ +#define XD_8M_X8_512 0xE6 +#define XD_16M_X8_512 0x73 +#define XD_32M_X8_512 0x75 +#define XD_64M_X8_512 0x76 +#define XD_128M_X8_512 0x79 +#define XD_256M_X8_512 0x71 +#define XD_128M_X8_2048 0xF1 +#define XD_256M_X8_2048 0xDA +#define XD_512M_X8 0xDC +#define XD_128M_X16_2048 0xC1 +#define XD_4M_X8_512_1 0xE3 +#define XD_4M_X8_512_2 0xE5 +#define xD_1G_X8_512 0xD3 +#define xD_2G_X8_512 0xD5 + +#define XD_ID_CODE 0xB5 + +#define VENDOR_BLOCK 0xEFFF +#define CIS_BLOCK 0xDFFF + +#define BLK_NOT_FOUND 0xFFFFFFFF + +#define NO_NEW_BLK 0xFFFFFFFF + +#define PAGE_CORRECTABLE 0x0 +#define PAGE_NOTCORRECTABLE 0x1 + +#define NO_OFFSET 0x0 +#define WITH_OFFSET 0x1 + +#define Sect_Per_Page 4 +#define XD_ADDR_MODE_2C XD_ADDR_MODE_2A + +#define ZONE0_BAD_BLOCK 23 +#define NOT_ZONE0_BAD_BLOCK 24 + +/* Assign address mode */ +#define XD_RW_ADDR 0x01 +#define XD_ERASE_ADDR 0x02 + +/* Macro Definition */ +#define XD_PAGE_512(xd_card) \ + do { \ + (xd_card)->block_shift = 5; \ + (xd_card)->page_off = 0x1F; \ + } while (0) + +#define XD_SET_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag |= 0x01) +#define XD_CLR_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag &= ~0x01) +#define XD_CHK_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag & 0x01) + +#define XD_SET_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag |= 0x02) +#define XD_CLR_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag &= ~0x02) +#define XD_CHK_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag & 0x02) + +#define XD_SET_MBR_FAIL(xd_card) ((xd_card)->multi_flag |= 0x04) +#define XD_CLR_MBR_FAIL(xd_card) ((xd_card)->multi_flag &= ~0x04) +#define XD_CHK_MBR_FAIL(xd_card) ((xd_card)->multi_flag & 0x04) + +#define XD_SET_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag |= 0x08) +#define XD_CLR_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag &= ~0x08) +#define XD_CHK_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag & 0x08) + +#define XD_SET_4MB(xd_card) ((xd_card)->multi_flag |= 0x10) +#define XD_CLR_4MB(xd_card) ((xd_card)->multi_flag &= ~0x10) +#define XD_CHK_4MB(xd_card) ((xd_card)->multi_flag & 0x10) + +#define XD_SET_ECC_ERR(xd_card) ((xd_card)->multi_flag |= 0x40) +#define XD_CLR_ECC_ERR(xd_card) ((xd_card)->multi_flag &= ~0x40) +#define XD_CHK_ECC_ERR(xd_card) ((xd_card)->multi_flag & 0x40) + +/* Offset in xD redundant buffer */ +#define PAGE_STATUS 0 +#define BLOCK_STATUS 1 +#define BLOCK_ADDR1_L 2 +#define BLOCK_ADDR1_H 3 +#define BLOCK_ADDR2_L 4 +#define BLOCK_ADDR2_H 5 +#define RESERVED0 6 +#define RESERVED1 7 +#define RESERVED2 8 +#define RESERVED3 9 +#define PARITY 10 + +/* For CIS block */ +#define CIS0_0 0 +#define CIS0_1 1 +#define CIS0_2 2 +#define CIS0_3 3 +#define CIS0_4 4 +#define CIS0_5 5 +#define CIS0_6 6 +#define CIS0_7 7 +#define CIS0_8 8 +#define CIS0_9 9 +#define CIS1_0 256 +#define CIS1_1 (256 + 1) +#define CIS1_2 (256 + 2) +#define CIS1_3 (256 + 3) +#define CIS1_4 (256 + 4) +#define CIS1_5 (256 + 5) +#define CIS1_6 (256 + 6) +#define CIS1_7 (256 + 7) +#define CIS1_8 (256 + 8) +#define CIS1_9 (256 + 9) + +int reset_xd_card(struct rts51x_chip *chip); +int xd_delay_write(struct rts51x_chip *chip); +int xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, + u16 sector_cnt); +void xd_free_l2p_tbl(struct rts51x_chip *chip); +void xd_cleanup_work(struct rts51x_chip *chip); +int xd_power_off_card3v3(struct rts51x_chip *chip); +int release_xd_card(struct rts51x_chip *chip); + +#endif /* __RTS51X_XD_H */ From d1661dfdb99138eca2d3fbcf9c651ffcaba6f28a Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Tue, 12 Jul 2011 23:10:55 +0800 Subject: [PATCH 0018/1519] staging: r8712u: Sets to SSID, and to AP MAC#, can now be done when the interface is Down. The original Realtek code assumed that ioctl Sets get done after the interface is Up. This included the set to Essid and to the AP MAC#; and it fit Realtek's installation procedure. But there is no such necessity for the adapter, and no stated requirement found elsewhere. Also, wireless drivers typically permit this. A typical error message used to be: Error for wireless request "Set ESSID" (8B1A) : SET failed on device wlan0 ; Operation not permitted. Signed-off-by: Ali Bahar Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 5 ++++ drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 4f380a64aa8..c5303c3fda1 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -117,6 +117,11 @@ struct dvobj_priv { struct usb_device *pusbdev; }; +/** + * struct _adapter - the main adapter structure for this device. + * + * bup: True indicates that the interface is Up. + */ struct _adapter { struct dvobj_priv dvobjpriv; struct mlme_priv mlmepriv; diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 40e6b5cc412..59bdab10533 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -975,6 +975,13 @@ static int r871x_wx_set_priv(struct net_device *dev, * s2. set_802_11_authentication_mode() * s3. set_802_11_encryption_mode() * s4. set_802_11_bssid() + * + * This function intends to handle the Set AP command, which specifies the + * MAC# of a preferred Access Point. + * Currently, the request comes via Wireless Extensions' SIOCSIWAP ioctl. + * + * For this operation to succeed, there is no need for the interface to be Up. + * */ static int r8711_wx_set_wap(struct net_device *dev, struct iw_request_info *info, @@ -992,8 +999,6 @@ static int r8711_wx_set_wap(struct net_device *dev, struct wlan_network *pnetwork = NULL; enum NDIS_802_11_AUTHENTICATION_MODE authmode; - if (padapter->bup == false) - return -1; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) return -1; if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) @@ -1074,6 +1079,14 @@ static int r871x_wx_set_mlme(struct net_device *dev, return ret; } +/** + * + * This function intends to handle the Set Scan command. + * Currently, the request comes via Wireless Extensions' SIOCSIWSCAN ioctl. + * + * For this operation to succeed, the interface is brought Up beforehand. + * + */ static int r8711_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) @@ -1169,6 +1182,12 @@ static int r8711_wx_get_scan(struct net_device *dev, * s2. set_802_11_authenticaion_mode() * s3. set_802_11_encryption_mode() * s4. set_802_11_ssid() + * + * This function intends to handle the Set ESSID command. + * Currently, the request comes via the Wireless Extensions' SIOCSIWESSID ioctl. + * + * For this operation to succeed, there is no need for the interface to be Up. + * */ static int r8711_wx_set_essid(struct net_device *dev, struct iw_request_info *a, @@ -1184,8 +1203,6 @@ static int r8711_wx_set_essid(struct net_device *dev, struct list_head *phead; u32 len; - if (padapter->bup == false) - return -1; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) return -1; if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) From a5ee65290d16c2fe06cecc8d0ed8530ffd8f0f2a Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Tue, 12 Jul 2011 23:10:56 +0800 Subject: [PATCH 0019/1519] staging: r8712u: Interface-state not fully tracked. padapter->bup is True when the interface has been brought Up. But it was not being reset when the interface is taken Down. This has not caused a known problem, as other state variables may be compensating for it. Never the less, it is now properly tracked. Signed-off-by: Ali Bahar Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 3f38e8eca3f..6697941e232 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -375,6 +375,12 @@ static void enable_video_mode(struct _adapter *padapter, int cbw40_value) r8712_fw_cmd(padapter, intcmd); } +/** + * + * This function intends to handle the activation of an interface + * i.e. when it is brought Up/Active from a Down state. + * + */ static int netdev_open(struct net_device *pnetdev) { struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev); @@ -434,6 +440,12 @@ netdev_open_error: return -1; } +/** + * + * This function intends to handle the shutdown of an interface + * i.e. when it is brought Down from an Up/Active state. + * + */ static int netdev_close(struct net_device *pnetdev) { struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev); @@ -458,6 +470,8 @@ static int netdev_close(struct net_device *pnetdev) r8712_free_network_queue(padapter); /*Stop driver mlme relation timer*/ stop_drv_timers(padapter); + /* The interface is no longer Up: */ + padapter->bup = false; return 0; } From 0e54f6090db9eed25a745e5abf45b3c12ce724d1 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Tue, 23 Aug 2011 13:53:37 +0800 Subject: [PATCH 0020/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Added copyright banners. The only changes to these files have been the addition of only copyright banners. Signed-off-by: Ali Bahar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/big_endian.h | 19 +++++++++++++++++ drivers/staging/rtl8712/ethernet.h | 19 +++++++++++++++++ drivers/staging/rtl8712/generic.h | 19 +++++++++++++++++ drivers/staging/rtl8712/if_ether.h | 19 +++++++++++++++++ drivers/staging/rtl8712/little_endian.h | 19 +++++++++++++++++ drivers/staging/rtl8712/mlme_osdep.h | 19 +++++++++++++++++ drivers/staging/rtl8712/mp_custom_oid.h | 19 +++++++++++++++++ drivers/staging/rtl8712/recv_osdep.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_bitdef.h | 21 +++++++++++++++++++ .../staging/rtl8712/rtl8712_cmdctrl_bitdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_cmdctrl_regdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_debugctrl_bitdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_debugctrl_regdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_edcasetting_bitdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_edcasetting_regdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_fifoctrl_bitdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_fifoctrl_regdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_gp_bitdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_gp_regdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_hal.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_interrupt_bitdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_macsetting_bitdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_macsetting_regdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_powersave_bitdef.h | 19 +++++++++++++++++ .../rtl8712/rtl8712_powersave_regdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_ratectrl_bitdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_ratectrl_regdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_regdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_security_bitdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_spec.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_syscfg_bitdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_syscfg_regdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_timectrl_bitdef.h | 19 +++++++++++++++++ .../staging/rtl8712/rtl8712_timectrl_regdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_wmac_bitdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl8712_wmac_regdef.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_byteorder.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_eeprom.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_event.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_ht.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_ioctl_set.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_mp.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_pwrctrl.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_rf.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_security.h | 19 +++++++++++++++++ drivers/staging/rtl8712/rtl871x_wlan_sme.h | 19 +++++++++++++++++ drivers/staging/rtl8712/swab.h | 19 +++++++++++++++++ drivers/staging/rtl8712/usb_ops.h | 19 +++++++++++++++++ drivers/staging/rtl8712/usb_osintf.h | 19 +++++++++++++++++ drivers/staging/rtl8712/usb_vendor_req.h | 19 +++++++++++++++++ 50 files changed, 952 insertions(+) diff --git a/drivers/staging/rtl8712/big_endian.h b/drivers/staging/rtl8712/big_endian.h index 8512d1b5919..0e67a4e50cd 100644 --- a/drivers/staging/rtl8712/big_endian.h +++ b/drivers/staging/rtl8712/big_endian.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H #define _LINUX_BYTEORDER_BIG_ENDIAN_H diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h index ba8d777d8e1..50758c6b05d 100644 --- a/drivers/staging/rtl8712/ethernet.h +++ b/drivers/staging/rtl8712/ethernet.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __INC_ETHERNET_H #define __INC_ETHERNET_H diff --git a/drivers/staging/rtl8712/generic.h b/drivers/staging/rtl8712/generic.h index 742424bdf16..67c9b66e8d3 100644 --- a/drivers/staging/rtl8712/generic.h +++ b/drivers/staging/rtl8712/generic.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _LINUX_BYTEORDER_GENERIC_H #define _LINUX_BYTEORDER_GENERIC_H diff --git a/drivers/staging/rtl8712/if_ether.h b/drivers/staging/rtl8712/if_ether.h index 0e9753b9ed3..7acb2062361 100644 --- a/drivers/staging/rtl8712/if_ether.h +++ b/drivers/staging/rtl8712/if_ether.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ /* * INET An implementation of the TCP/IP protocol suite for the LINUX * operating system. INET is implemented using the BSD Socket diff --git a/drivers/staging/rtl8712/little_endian.h b/drivers/staging/rtl8712/little_endian.h index 0248c143c6d..d01c500a022 100644 --- a/drivers/staging/rtl8712/little_endian.h +++ b/drivers/staging/rtl8712/little_endian.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H #define _LINUX_BYTEORDER_LITTLE_ENDIAN_H diff --git a/drivers/staging/rtl8712/mlme_osdep.h b/drivers/staging/rtl8712/mlme_osdep.h index 968e78765a3..9b3387c8b6e 100644 --- a/drivers/staging/rtl8712/mlme_osdep.h +++ b/drivers/staging/rtl8712/mlme_osdep.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __MLME_OSDEP_H_ #define __MLME_OSDEP_H_ diff --git a/drivers/staging/rtl8712/mp_custom_oid.h b/drivers/staging/rtl8712/mp_custom_oid.h index a9e0b3483e3..09ac9c92b22 100644 --- a/drivers/staging/rtl8712/mp_custom_oid.h +++ b/drivers/staging/rtl8712/mp_custom_oid.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __CUSTOM_OID_H #define __CUSTOM_OID_H diff --git a/drivers/staging/rtl8712/recv_osdep.h b/drivers/staging/rtl8712/recv_osdep.h index 60a54dd90ff..1040f94828c 100644 --- a/drivers/staging/rtl8712/recv_osdep.h +++ b/drivers/staging/rtl8712/recv_osdep.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RECV_OSDEP_H_ #define __RECV_OSDEP_H_ diff --git a/drivers/staging/rtl8712/rtl8712_bitdef.h b/drivers/staging/rtl8712/rtl8712_bitdef.h index 356184fa060..bff57a8eef3 100644 --- a/drivers/staging/rtl8712/rtl8712_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_bitdef.h @@ -1,3 +1,24 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + #ifndef __RTL8712_BITDEF_H__ #define __RTL8712_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h index 6c49903a42f..8dffe101bec 100644 --- a/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_CMDCTRL_BITDEF_H__ #define __RTL8712_CMDCTRL_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h index 5d9a3f20ea6..9374f1c4885 100644 --- a/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_CMDCTRL_REGDEF_H__ #define __RTL8712_CMDCTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h index 7b34d4025e3..8bd483795ca 100644 --- a/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_DEBUGCTRL_BITDEF_H__ #define __RTL8712_DEBUGCTRL_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h index 27cad716868..43630bb068f 100644 --- a/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_DEBUGCTRL_REGDEF_H__ #define __RTL8712_DEBUGCTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h index c69b1b72c28..a5acbdd6747 100644 --- a/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_EDCASETTING_BITDEF_H__ #define __RTL8712_EDCASETTING_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h b/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h index de3d3e23ba9..d992cb8b1c7 100644 --- a/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_EDCASETTING_REGDEF_H__ #define __RTL8712_EDCASETTING_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h index e5df19f4b02..c564dc862d9 100644 --- a/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_FIFOCTRL_BITDEF_H__ #define __RTL8712_FIFOCTRL_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h index c2e3af2c79f..29b89c45c70 100644 --- a/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_FIFOCTRL_REGDEF_H__ #define __RTL8712_FIFOCTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h index 35ca809e179..cb2ed5955c4 100644 --- a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_GP_BITDEF_H__ #define __RTL8712_GP_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_gp_regdef.h b/drivers/staging/rtl8712/rtl8712_gp_regdef.h index 17e72bda617..50f676c9a72 100644 --- a/drivers/staging/rtl8712/rtl8712_gp_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_gp_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_GP_REGDEF_H__ #define __RTL8712_GP_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h index c696dd8a2ea..3019ec69c1c 100644 --- a/drivers/staging/rtl8712/rtl8712_hal.h +++ b/drivers/staging/rtl8712/rtl8712_hal.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_HAL_H__ #define __RTL8712_HAL_H__ diff --git a/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h b/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h index 02f24809814..49598c314f0 100644 --- a/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_INTERRUPT_BITDEF_H__ #define __RTL8712_INTERRUPT_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h b/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h index 74800cd2340..28e0a7ebcad 100644 --- a/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_MACSETTING_BITDEF_H__ #define __RTL8712_MACSETTING_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h b/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h index 00b003bd690..ced0da9332d 100644 --- a/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_MACSETTING_REGDEF_H__ #define __RTL8712_MACSETTING_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h b/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h index 0922a8dc132..8fc68941651 100644 --- a/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_POWERSAVE_BITDEF_H__ #define __RTL8712_POWERSAVE_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_powersave_regdef.h b/drivers/staging/rtl8712/rtl8712_powersave_regdef.h index 72927df3db2..4632ddd5d1f 100644 --- a/drivers/staging/rtl8712/rtl8712_powersave_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_powersave_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_POWERSAVE_REGDEF_H__ #define __RTL8712_POWERSAVE_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h index 87048b3fe04..6d3d6e8522f 100644 --- a/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_RATECTRL_BITDEF_H__ #define __RTL8712_RATECTRL_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h index 31c8363e5bc..2787ad1a932 100644 --- a/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_RATECTRL_REGDEF_H__ #define __RTL8712_RATECTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_regdef.h b/drivers/staging/rtl8712/rtl8712_regdef.h index 5b0de2ab6b6..df2245de1e3 100644 --- a/drivers/staging/rtl8712/rtl8712_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_REGDEF_H__ #define __RTL8712_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_security_bitdef.h b/drivers/staging/rtl8712/rtl8712_security_bitdef.h index 8df4bf4a069..05dafa0c333 100644 --- a/drivers/staging/rtl8712/rtl8712_security_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_security_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_SECURITY_BITDEF_H__ #define __RTL8712_SECURITY_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_spec.h b/drivers/staging/rtl8712/rtl8712_spec.h index 3f181eed4ee..6014fc5dbca 100644 --- a/drivers/staging/rtl8712/rtl8712_spec.h +++ b/drivers/staging/rtl8712/rtl8712_spec.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_SPEC_H__ #define __RTL8712_SPEC_H__ diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h index dce15c2ff50..02c3b85e937 100644 --- a/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_SYSCFG_BITDEF_H__ #define __RTL8712_SYSCFG_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h index 687e1b7a03f..6907eefe534 100644 --- a/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_SYSCFG_REGDEF_H__ #define __RTL8712_SYSCFG_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h index 32ce9fab5db..72442158242 100644 --- a/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_TIMECTRL_BITDEF_H__ #define __RTL8712_TIMECTRL_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h b/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h index 8a3dd562ba8..106916c7e31 100644 --- a/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_TIMECTRL_REGDEF_H__ #define __RTL8712_TIMECTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h index 6d3be2a2422..8457ffc7a32 100644 --- a/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_WMAC_BITDEF_H__ #define __RTL8712_WMAC_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h index ac80dfb317c..4c611af8efb 100644 --- a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL8712_WMAC_REGDEF_H__ #define __RTL8712_WMAC_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl871x_byteorder.h b/drivers/staging/rtl8712/rtl871x_byteorder.h index 07707e23dbe..bd3703b98bc 100644 --- a/drivers/staging/rtl8712/rtl871x_byteorder.h +++ b/drivers/staging/rtl8712/rtl871x_byteorder.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _RTL871X_BYTEORDER_H_ #define _RTL871X_BYTEORDER_H_ diff --git a/drivers/staging/rtl8712/rtl871x_eeprom.h b/drivers/staging/rtl8712/rtl871x_eeprom.h index fb15f5bde42..497276e53bb 100644 --- a/drivers/staging/rtl8712/rtl871x_eeprom.h +++ b/drivers/staging/rtl8712/rtl871x_eeprom.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL871X_EEPROM_H__ #define __RTL871X_EEPROM_H__ diff --git a/drivers/staging/rtl8712/rtl871x_event.h b/drivers/staging/rtl8712/rtl871x_event.h index 6ce06767130..4c64d65aecb 100644 --- a/drivers/staging/rtl8712/rtl871x_event.h +++ b/drivers/staging/rtl8712/rtl871x_event.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _RTL871x_EVENT_H_ #define _RTL871x_EVENT_H_ diff --git a/drivers/staging/rtl8712/rtl871x_ht.h b/drivers/staging/rtl8712/rtl871x_ht.h index 612203deea7..b67fe54a970 100644 --- a/drivers/staging/rtl8712/rtl871x_ht.h +++ b/drivers/staging/rtl8712/rtl871x_ht.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _RTL871X_HT_H_ #define _RTL871X_HT_H_ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.h b/drivers/staging/rtl8712/rtl871x_ioctl_set.h index 8dff2b196ff..6a9c84cc216 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.h +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __IOCTL_SET_H #define __IOCTL_SET_H diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h index 805aba07159..98920993f3b 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.h +++ b/drivers/staging/rtl8712/rtl871x_mp.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL871X_MP_H_ #define __RTL871X_MP_H_ diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.h b/drivers/staging/rtl8712/rtl871x_pwrctrl.h index 34f074aebd6..7fad33e9300 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.h +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL871X_PWRCTRL_H_ #define __RTL871X_PWRCTRL_H_ diff --git a/drivers/staging/rtl8712/rtl871x_rf.h b/drivers/staging/rtl8712/rtl871x_rf.h index 6c54966f13f..d2a914f108e 100644 --- a/drivers/staging/rtl8712/rtl871x_rf.h +++ b/drivers/staging/rtl8712/rtl871x_rf.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL871X_RF_H_ #define __RTL871X_RF_H_ diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h index bff71d2aae9..e5b14d8d28d 100644 --- a/drivers/staging/rtl8712/rtl871x_security.h +++ b/drivers/staging/rtl8712/rtl871x_security.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __RTL871X_SECURITY_H_ #define __RTL871X_SECURITY_H_ diff --git a/drivers/staging/rtl8712/rtl871x_wlan_sme.h b/drivers/staging/rtl8712/rtl871x_wlan_sme.h index d9733ac6a43..a00f6860ee1 100644 --- a/drivers/staging/rtl8712/rtl871x_wlan_sme.h +++ b/drivers/staging/rtl8712/rtl871x_wlan_sme.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _RTL871X_WLAN_SME_H_ #define _RTL871X_WLAN_SME_H_ diff --git a/drivers/staging/rtl8712/swab.h b/drivers/staging/rtl8712/swab.h index 44709a91baf..f53c0b7d9e8 100644 --- a/drivers/staging/rtl8712/swab.h +++ b/drivers/staging/rtl8712/swab.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _LINUX_BYTEORDER_SWAB_H #define _LINUX_BYTEORDER_SWAB_H diff --git a/drivers/staging/rtl8712/usb_ops.h b/drivers/staging/rtl8712/usb_ops.h index dc0611a2a0d..015f1bf173f 100644 --- a/drivers/staging/rtl8712/usb_ops.h +++ b/drivers/staging/rtl8712/usb_ops.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __USB_OPS_H_ #define __USB_OPS_H_ diff --git a/drivers/staging/rtl8712/usb_osintf.h b/drivers/staging/rtl8712/usb_osintf.h index 0da6c1db048..f7da4a03862 100644 --- a/drivers/staging/rtl8712/usb_osintf.h +++ b/drivers/staging/rtl8712/usb_osintf.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef __USB_OSINTF_H #define __USB_OSINTF_H diff --git a/drivers/staging/rtl8712/usb_vendor_req.h b/drivers/staging/rtl8712/usb_vendor_req.h index d35c538c47a..fb17e09da43 100644 --- a/drivers/staging/rtl8712/usb_vendor_req.h +++ b/drivers/staging/rtl8712/usb_vendor_req.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ #ifndef _USB_VENDOR_REQUEST_H_ #define _USB_VENDOR_REQUEST_H_ From b4f6209d733b6570947507a18f76def6e16393cb Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Tue, 23 Aug 2011 13:53:38 +0800 Subject: [PATCH 0021/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Added Larry's copyright. Larry Finger's copyright addendum has now been included in the banners. The files involved in this commit have had only their banners changed; there have been no other mods. Signed-off-by: Ali Bahar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/big_endian.h | 6 ++++++ drivers/staging/rtl8712/ethernet.h | 6 ++++++ drivers/staging/rtl8712/generic.h | 6 ++++++ drivers/staging/rtl8712/if_ether.h | 6 ++++++ drivers/staging/rtl8712/little_endian.h | 6 ++++++ drivers/staging/rtl8712/mlme_osdep.h | 6 ++++++ drivers/staging/rtl8712/mp_custom_oid.h | 6 ++++++ drivers/staging/rtl8712/recv_osdep.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_gp_bitdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_gp_regdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_hal.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_regdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_spec.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_syscfg_regdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_wmac_bitdef.h | 6 ++++++ drivers/staging/rtl8712/rtl8712_wmac_regdef.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_event.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_ht.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_ioctl_set.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_mp.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_pwrctrl.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_rf.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_security.h | 6 ++++++ drivers/staging/rtl8712/rtl871x_wlan_sme.h | 6 ++++++ drivers/staging/rtl8712/swab.h | 6 ++++++ drivers/staging/rtl8712/usb_ops.h | 6 ++++++ drivers/staging/rtl8712/usb_osintf.h | 6 ++++++ drivers/staging/rtl8712/usb_vendor_req.h | 6 ++++++ 31 files changed, 186 insertions(+) diff --git a/drivers/staging/rtl8712/big_endian.h b/drivers/staging/rtl8712/big_endian.h index 0e67a4e50cd..b16f8ecf99c 100644 --- a/drivers/staging/rtl8712/big_endian.h +++ b/drivers/staging/rtl8712/big_endian.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h index 50758c6b05d..882d61b2e95 100644 --- a/drivers/staging/rtl8712/ethernet.h +++ b/drivers/staging/rtl8712/ethernet.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __INC_ETHERNET_H diff --git a/drivers/staging/rtl8712/generic.h b/drivers/staging/rtl8712/generic.h index 67c9b66e8d3..8868c9f4adf 100644 --- a/drivers/staging/rtl8712/generic.h +++ b/drivers/staging/rtl8712/generic.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _LINUX_BYTEORDER_GENERIC_H diff --git a/drivers/staging/rtl8712/if_ether.h b/drivers/staging/rtl8712/if_ether.h index 7acb2062361..2bbe527bcd5 100644 --- a/drivers/staging/rtl8712/if_ether.h +++ b/drivers/staging/rtl8712/if_ether.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ /* diff --git a/drivers/staging/rtl8712/little_endian.h b/drivers/staging/rtl8712/little_endian.h index d01c500a022..cd57d6c2850 100644 --- a/drivers/staging/rtl8712/little_endian.h +++ b/drivers/staging/rtl8712/little_endian.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H diff --git a/drivers/staging/rtl8712/mlme_osdep.h b/drivers/staging/rtl8712/mlme_osdep.h index 9b3387c8b6e..a20fe81f921 100644 --- a/drivers/staging/rtl8712/mlme_osdep.h +++ b/drivers/staging/rtl8712/mlme_osdep.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __MLME_OSDEP_H_ diff --git a/drivers/staging/rtl8712/mp_custom_oid.h b/drivers/staging/rtl8712/mp_custom_oid.h index 09ac9c92b22..40510089b78 100644 --- a/drivers/staging/rtl8712/mp_custom_oid.h +++ b/drivers/staging/rtl8712/mp_custom_oid.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __CUSTOM_OID_H diff --git a/drivers/staging/rtl8712/recv_osdep.h b/drivers/staging/rtl8712/recv_osdep.h index 1040f94828c..f4384ef0086 100644 --- a/drivers/staging/rtl8712/recv_osdep.h +++ b/drivers/staging/rtl8712/recv_osdep.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RECV_OSDEP_H_ diff --git a/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h index a5acbdd6747..32dab81f176 100644 --- a/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_EDCASETTING_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h index cb2ed5955c4..884a8212176 100644 --- a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_GP_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_gp_regdef.h b/drivers/staging/rtl8712/rtl8712_gp_regdef.h index 50f676c9a72..8fc68f6a2c7 100644 --- a/drivers/staging/rtl8712/rtl8712_gp_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_gp_regdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_GP_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h index 3019ec69c1c..665e7183817 100644 --- a/drivers/staging/rtl8712/rtl8712_hal.h +++ b/drivers/staging/rtl8712/rtl8712_hal.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_HAL_H__ diff --git a/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h index 2787ad1a932..73dfc361015 100644 --- a/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_RATECTRL_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_regdef.h b/drivers/staging/rtl8712/rtl8712_regdef.h index df2245de1e3..e7bca55b59d 100644 --- a/drivers/staging/rtl8712/rtl8712_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_regdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_spec.h b/drivers/staging/rtl8712/rtl8712_spec.h index 6014fc5dbca..af11b44b114 100644 --- a/drivers/staging/rtl8712/rtl8712_spec.h +++ b/drivers/staging/rtl8712/rtl8712_spec.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_SPEC_H__ diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h index 02c3b85e937..eed09c872fc 100644 --- a/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_SYSCFG_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h index 6907eefe534..767dfdf8d83 100644 --- a/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_SYSCFG_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h index 8457ffc7a32..61a3603aa58 100644 --- a/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_WMAC_BITDEF_H__ diff --git a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h index 4c611af8efb..d9f8347ab46 100644 --- a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h +++ b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL8712_WMAC_REGDEF_H__ diff --git a/drivers/staging/rtl8712/rtl871x_event.h b/drivers/staging/rtl8712/rtl871x_event.h index 4c64d65aecb..e03ee90d287 100644 --- a/drivers/staging/rtl8712/rtl871x_event.h +++ b/drivers/staging/rtl8712/rtl871x_event.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _RTL871x_EVENT_H_ diff --git a/drivers/staging/rtl8712/rtl871x_ht.h b/drivers/staging/rtl8712/rtl871x_ht.h index b67fe54a970..41872d93740 100644 --- a/drivers/staging/rtl8712/rtl871x_ht.h +++ b/drivers/staging/rtl8712/rtl871x_ht.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _RTL871X_HT_H_ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.h b/drivers/staging/rtl8712/rtl871x_ioctl_set.h index 6a9c84cc216..de0a8482c98 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.h +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __IOCTL_SET_H diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h index 98920993f3b..a42d4f40d14 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.h +++ b/drivers/staging/rtl8712/rtl871x_mp.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL871X_MP_H_ diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.h b/drivers/staging/rtl8712/rtl871x_pwrctrl.h index 7fad33e9300..b41ca2892be 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.h +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL871X_PWRCTRL_H_ diff --git a/drivers/staging/rtl8712/rtl871x_rf.h b/drivers/staging/rtl8712/rtl871x_rf.h index d2a914f108e..133ed646292 100644 --- a/drivers/staging/rtl8712/rtl871x_rf.h +++ b/drivers/staging/rtl8712/rtl871x_rf.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL871X_RF_H_ diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h index e5b14d8d28d..a13395fe21d 100644 --- a/drivers/staging/rtl8712/rtl871x_security.h +++ b/drivers/staging/rtl8712/rtl871x_security.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __RTL871X_SECURITY_H_ diff --git a/drivers/staging/rtl8712/rtl871x_wlan_sme.h b/drivers/staging/rtl8712/rtl871x_wlan_sme.h index a00f6860ee1..44924d5de21 100644 --- a/drivers/staging/rtl8712/rtl871x_wlan_sme.h +++ b/drivers/staging/rtl8712/rtl871x_wlan_sme.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _RTL871X_WLAN_SME_H_ diff --git a/drivers/staging/rtl8712/swab.h b/drivers/staging/rtl8712/swab.h index f53c0b7d9e8..f12781829c1 100644 --- a/drivers/staging/rtl8712/swab.h +++ b/drivers/staging/rtl8712/swab.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _LINUX_BYTEORDER_SWAB_H diff --git a/drivers/staging/rtl8712/usb_ops.h b/drivers/staging/rtl8712/usb_ops.h index 015f1bf173f..78e775a4636 100644 --- a/drivers/staging/rtl8712/usb_ops.h +++ b/drivers/staging/rtl8712/usb_ops.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __USB_OPS_H_ diff --git a/drivers/staging/rtl8712/usb_osintf.h b/drivers/staging/rtl8712/usb_osintf.h index f7da4a03862..d397a82986d 100644 --- a/drivers/staging/rtl8712/usb_osintf.h +++ b/drivers/staging/rtl8712/usb_osintf.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef __USB_OSINTF_H diff --git a/drivers/staging/rtl8712/usb_vendor_req.h b/drivers/staging/rtl8712/usb_vendor_req.h index fb17e09da43..82335a83d0d 100644 --- a/drivers/staging/rtl8712/usb_vendor_req.h +++ b/drivers/staging/rtl8712/usb_vendor_req.h @@ -15,6 +15,12 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger * ******************************************************************************/ #ifndef _USB_VENDOR_REQUEST_H_ From 4f61a7ad939861d540cab6749ba3b84861c34573 Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Thu, 14 Jul 2011 20:11:25 +0300 Subject: [PATCH 0022/1519] staging: mei: enable msi when supported enable msi when supported also in that case we can drop the quick handler from the threaded interrupt that protected us from handling USB interrupts Signed-off-by: Maarten Lankhorst Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/interrupt.c | 6 ++++++ drivers/staging/mei/main.c | 30 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index 9cb186bf187..ca1e0c90a94 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -1540,6 +1540,12 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) mutex_lock(&dev->device_lock); mei_io_list_init(&complete_list); dev->host_hw_state = mei_hcsr_read(dev); + + /* Ack the interrupt here + * In case of MSI we don't go throuhg the quick handler */ + if (pci_dev_msi_enabled(dev->pdev)) + mei_reg_write(dev, H_CSR, dev->host_hw_state); + dev->me_hw_state = mei_mecsr_read(dev); /* check if ME wants a reset */ diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index de8825fcd8c..8d7678569e7 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -151,11 +151,20 @@ static int __devinit mei_probe(struct pci_dev *pdev, err = -ENOMEM; goto free_device; } - /* request and enable interrupt */ - err = request_threaded_irq(pdev->irq, + pci_enable_msi(pdev); + + /* request and enable interrupt */ + if (pci_dev_msi_enabled(pdev)) + err = request_threaded_irq(pdev->irq, + NULL, + mei_interrupt_thread_handler, + 0, mei_driver_name, dev); + else + err = request_threaded_irq(pdev->irq, mei_interrupt_quick_handler, mei_interrupt_thread_handler, IRQF_SHARED, mei_driver_name, dev); + if (err) { printk(KERN_ERR "mei: request_threaded_irq failure. irq = %d\n", pdev->irq); @@ -183,6 +192,7 @@ release_irq: mei_disable_interrupts(dev); flush_scheduled_work(); free_irq(pdev->irq, dev); + pci_disable_msi(pdev); unmap_memory: pci_iounmap(pdev, dev->mem_addr); free_device: @@ -247,6 +257,7 @@ static void __devexit mei_remove(struct pci_dev *pdev) mei_disable_interrupts(dev); free_irq(pdev->irq, dev); + pci_disable_msi(pdev); pci_set_drvdata(pdev, NULL); if (dev->mem_addr) @@ -1096,7 +1107,7 @@ static int mei_pci_suspend(struct device *device) mutex_unlock(&dev->device_lock); free_irq(pdev->irq, dev); - + pci_disable_msi(pdev); return err; } @@ -1111,11 +1122,20 @@ static int mei_pci_resume(struct device *device) if (!dev) return -ENODEV; - /* request and enable interrupt */ - err = request_threaded_irq(pdev->irq, + pci_enable_msi(pdev); + + /* request and enable interrupt */ + if (pci_dev_msi_enabled(pdev)) + err = request_threaded_irq(pdev->irq, + NULL, + mei_interrupt_thread_handler, + 0, mei_driver_name, dev); + else + err = request_threaded_irq(pdev->irq, mei_interrupt_quick_handler, mei_interrupt_thread_handler, IRQF_SHARED, mei_driver_name, dev); + if (err) { printk(KERN_ERR "mei: Request_irq failure. irq = %d\n", pdev->irq); From a9f81a9378d634ad693527939e0e8bfd0665c648 Mon Sep 17 00:00:00 2001 From: Arend Van Spriel Date: Mon, 8 Aug 2011 15:57:45 +0200 Subject: [PATCH 0023/1519] staging: brcm80211: fix compile error on non-x86 archs since 3.0 kernel Since the arrival of kernel version 3.0 in the staging tree it turns out compile error occurs for sparc64, powerpc, and arm platforms. This patch fixes that issue. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index bbf21897ae0..823b5e4672e 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -18,6 +18,7 @@ #define _BRCM_TYPES_H_ #include +#include /* Bus types */ #define SI_BUS 0 /* SOC Interconnect */ From 2c1599cfd6a736e09c29c772fbaf41250646ad42 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:46 +0200 Subject: [PATCH 0024/1519] staging: brcm80211: bugfix for len==0 parameter in 3 fullmac functions Three functions use the same method to check incoming parameters. The 'len' parameter can be equal to 0 in case of a 'set' operation. Currently these functions return an error code under that condition, which is incorrect. The problem was introduced in recent patches in which asserts were removed from the fullmac. Despite this being a bug, my regression testing has not shown any problems. Reported-by: Dan Carpenter Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 38bd9ba3096..e345af7918e 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -407,7 +407,7 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, bool bool_val; u32 actionid; - if (name == NULL || len <= 0) + if (name == NULL || len < 0) return -EINVAL; /* Set does not take qualifiers */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index fdec4683c42..1e757b73b80 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -311,7 +311,7 @@ brcmf_c_iovar_op(struct brcmf_pub *drvr, const char *name, BRCMF_TRACE(("%s: Enter\n", __func__)); - if (name == NULL || len <= 0) + if (name == NULL || len < 0) return -EINVAL; /* Set does not take qualifiers */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 7fa95b6213c..acad298567f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -3123,7 +3123,7 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, BRCMF_TRACE(("%s: Enter\n", __func__)); - if (name == NULL || len <= 0) + if (name == NULL || len < 0) return -EINVAL; /* Set does not take qualifiers */ From 8702fee6460cac456f28117bda19559c57913671 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:47 +0200 Subject: [PATCH 0025/1519] staging: brcm80211: merged bmac.c into main.c Future goal is to merge the bmac layer in the driver with the 'common' layer. A step towards this goal is to have one file containing both bmac and common code. Header files (bmac.h, main.h) were also merged. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/Makefile | 1 - drivers/staging/brcm80211/brcmsmac/antsel.c | 1 - drivers/staging/brcm80211/brcmsmac/bmac.c | 3593 ---------------- drivers/staging/brcm80211/brcmsmac/bmac.h | 174 - drivers/staging/brcm80211/brcmsmac/channel.c | 1 - drivers/staging/brcm80211/brcmsmac/main.c | 3747 ++++++++++++++++- drivers/staging/brcm80211/brcmsmac/main.h | 49 + drivers/staging/brcm80211/brcmsmac/phy_shim.c | 1 - drivers/staging/brcm80211/brcmsmac/stf.c | 1 - 9 files changed, 3736 insertions(+), 3832 deletions(-) delete mode 100644 drivers/staging/brcm80211/brcmsmac/bmac.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/bmac.h diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile index 1ea3e0c48f3..3147c487188 100644 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -33,7 +33,6 @@ BRCMSMAC_OFILES := \ alloc.o \ ampdu.o \ antsel.o \ - bmac.o \ channel.o \ main.o \ phy_shim.o \ diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index c4e76c093ae..1d6c3984bc7 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -18,7 +18,6 @@ #include #include "types.h" -#include "bmac.h" #include "main.h" #include "phy_shim.h" #include "antsel.h" diff --git a/drivers/staging/brcm80211/brcmsmac/bmac.c b/drivers/staging/brcm80211/brcmsmac/bmac.c deleted file mode 100644 index b25c5170556..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/bmac.c +++ /dev/null @@ -1,3593 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include - -#include -#include -#include -#include "types.h" -#include "rate.h" -#include "phy/phy_hal.h" -#include "channel.h" -#include "main.h" -#include "ucode_loader.h" -#include "mac80211_if.h" -#include "bmac.h" - -#define TIMER_INTERVAL_WATCHDOG_BMAC 1000 /* watchdog timer, in unit of ms */ - -#define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ -#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us, default */ -#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us, default */ -#define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ - -#define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ - -#ifndef BMAC_DUP_TO_REMOVE - -#define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ - -#endif /* BMAC_DUP_TO_REMOVE */ - -#define DMAREG(wlc_hw, direction, fifonum) \ - ((direction == DMA_TX) ? \ - (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ - (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) - -#define APHY_SLOT_TIME 9 -#define BPHY_SLOT_TIME 20 - -/* - * The following table lists the buffer memory allocated to xmt fifos in HW. - * the size is in units of 256bytes(one block), total size is HW dependent - * ucode has default fifo partition, sw can overwrite if necessary - * - * This is documented in twiki under the topic UcodeTxFifo. Please ensure - * the twiki is updated before making changes. - */ - -#define XMTFIFOTBL_STARTREV 20 /* Starting corerev for the fifo size table */ - -static u16 xmtfifo_sz[][NFIFO] = { - {20, 192, 192, 21, 17, 5}, /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ - {9, 58, 22, 14, 14, 5}, /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ - {20, 192, 192, 21, 17, 5}, /* corerev 22: 5120, 49152, 49152, 5376, 4352, 1280 */ - {20, 192, 192, 21, 17, 5}, /* corerev 23: 5120, 49152, 49152, 5376, 4352, 1280 */ - {9, 58, 22, 14, 14, 5}, /* corerev 24: 2304, 14848, 5632, 3584, 3584, 1280 */ -}; - -static void brcms_b_clkctl_clk(struct brcms_hardware *wlc, uint mode); -static void brcms_b_coreinit(struct brcms_c_info *wlc); - -/* used by wlc_wakeucode_init() */ -static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, - const struct d11init *inits); -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], - const uint nbytes); -static void brcms_ucode_download(struct brcms_hardware *wlc); -static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw); - -/* used by brcms_c_dpc() */ -static bool brcms_b_dotxstatus(struct brcms_hardware *wlc, - struct tx_status *txs, u32 s2); -static bool brcms_b_txstatus(struct brcms_hardware *wlc, bool bound, - bool *fatal); -static bool brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound); - -/* used by brcms_c_down() */ -static void brcms_c_flushqueues(struct brcms_c_info *wlc); - -static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs); -static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw); -static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw); -static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, - uint tx_fifo); -static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, - uint tx_fifo); -static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, - uint tx_fifo); - -/* Low Level Prototypes */ -static int brcms_b_bandtype(struct brcms_hardware *wlc_hw); -static void brcms_b_info_init(struct brcms_hardware *wlc_hw); -static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want); -static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, - u32 sel); -static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, - u16 v, u32 sel); -static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk); -static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme); -static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw); -static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw); -static bool brcms_c_validboardtype(struct brcms_hardware *wlc); -static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw); -static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw); -static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw); -static void brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init); -static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw); -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool want, - mbool flags); -static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw); -static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw); -static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc); -static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask); -static void brcms_c_gpio_init(struct brcms_c_info *wlc); -static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, - void *bcn, int len); -static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, - void *bcn, int len); -static void brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec); -static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit); -static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - chanspec_t chanspec); -static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, - bool shortslot); -static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw); -static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, - u8 rate); - -/* === Low Level functions === */ - -void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) -{ - wlc_hw->shortslot = shortslot; - - if (BAND_2G(brcms_b_bandtype(wlc_hw)) && wlc_hw->up) { - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - brcms_b_update_slot_timing(wlc_hw, shortslot); - brcms_c_enable_mac(wlc_hw->wlc); - } -} - -/* - * Update the slot timing for standard 11b/g (20us slots) - * or shortslot 11g (9us slots) - * The PSM needs to be suspended for this call. - */ -static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, - bool shortslot) -{ - d11regs_t *regs; - - regs = wlc_hw->regs; - - if (shortslot) { - /* 11g short slot: 11a timing */ - W_REG(®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ - brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); - } else { - /* 11g long slot: 11b timing */ - W_REG(®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ - brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); - } -} - -static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) -{ - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - - /* init microcode host flags */ - brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); - - /* do band-specific ucode IHR, SHM, and SCR inits */ - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) { - brcms_c_write_inits(wlc_hw, d11n0bsinitvals16); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } - } else { - if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_c_write_inits(wlc_hw, - d11lcn0bsinitvals24); - } else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in" - " core rev %d\n", __func__, - wlc_hw->unit, wlc_hw->corerev); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - } -} - -/* switch to new band but leave it inactive */ -static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, - uint bandunit) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintmask; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); - - /* disable interrupts */ - macintmask = brcms_intrsoff(wlc->wl); - - /* radio off */ - wlc_phy_switch_radio(wlc_hw->band->pi, OFF); - - brcms_b_core_phy_clk(wlc_hw, OFF); - - brcms_c_setxband(wlc_hw, bandunit); - - return macintmask; -} - -/* Process received frames */ -/* - * Return true if more frames need to be processed. false otherwise. - * Param 'bound' indicates max. # frames to process before break out. - */ -static bool -brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) -{ - struct sk_buff *p; - struct sk_buff *head = NULL; - struct sk_buff *tail = NULL; - uint n = 0; - uint bound_limit = bound ? wlc_hw->wlc->pub->tunables->rxbnd : -1; - struct brcms_d11rxhdr *wlc_rxhdr = NULL; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - /* gather received frames */ - while ((p = dma_rx(wlc_hw->di[fifo]))) { - - if (!tail) - head = tail = p; - else { - tail->prev = p; - tail = p; - } - - /* !give others some time to run! */ - if (++n >= bound_limit) - break; - } - - /* post more rbufs */ - dma_rxfill(wlc_hw->di[fifo]); - - /* process each frame */ - while ((p = head) != NULL) { - head = head->prev; - p->prev = NULL; - - wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; - - /* compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ - wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr); - - brcms_c_recv(wlc_hw->wlc, p); - } - - return n >= bound_limit; -} - -/* second-level interrupt processing - * Return true if another dpc needs to be re-scheduled. false otherwise. - * Param 'bounded' indicates if applicable loops should be bounded. - */ -bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) -{ - u32 macintstatus; - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; - bool fatal = false; - struct wiphy *wiphy = wlc->wiphy; - - if (DEVICEREMOVED(wlc)) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return false; - } - - /* grab and clear the saved software intstatus bits */ - macintstatus = wlc->macintstatus; - wlc->macintstatus = 0; - - BCMMSG(wlc->wiphy, "wl%d: macintstatus 0x%x\n", - wlc_hw->unit, macintstatus); - - WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ - - /* BCN template is available */ - /* ZZZ: Use AP_ACTIVE ? */ - if (AP_ENAB(wlc->pub) && (!APSTA_ENAB(wlc->pub)) - && (macintstatus & MI_BCNTPL)) { - brcms_c_update_beacon(wlc); - } - - /* tx status */ - if (macintstatus & MI_TFS) { - if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) - wlc->macintstatus |= MI_TFS; - if (fatal) { - wiphy_err(wiphy, "MI_TFS: fatal\n"); - goto fatal; - } - } - - if (macintstatus & (MI_TBTT | MI_DTIM_TBTT)) - brcms_c_tbtt(wlc); - - /* ATIM window end */ - if (macintstatus & MI_ATIMWINEND) { - BCMMSG(wlc->wiphy, "end of ATIM window\n"); - OR_REG(®s->maccommand, wlc->qvalid); - wlc->qvalid = 0; - } - - /* received data or control frame, MI_DMAINT is indication of RX_FIFO interrupt */ - if (macintstatus & MI_DMAINT) - if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) - wlc->macintstatus |= MI_DMAINT; - - /* TX FIFO suspend/flush completion */ - if (macintstatus & MI_TXSTOP) - brcms_b_tx_fifo_suspended(wlc_hw, TX_DATA_FIFO); - - /* noise sample collected */ - if (macintstatus & MI_BG_NOISE) { - wlc_phy_noise_sample_intr(wlc_hw->band->pi); - } - - if (macintstatus & MI_GP0) { - wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " - "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); - - printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", - __func__, wlc_hw->sih->chip, - wlc_hw->sih->chiprev); - /* big hammer */ - brcms_init(wlc->wl); - } - - /* gptimer timeout */ - if (macintstatus & MI_TO) { - W_REG(®s->gptimer, 0); - } - - if (macintstatus & MI_RFDISABLE) { - BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" - " RF Disable Input\n", wlc_hw->unit); - brcms_rfkill_set_hw_state(wlc->wl); - } - - /* send any enq'd tx packets. Just makes sure to jump start tx */ - if (!pktq_empty(&wlc->pkt_queue->q)) - brcms_c_send_q(wlc); - - /* it isn't done and needs to be resched if macintstatus is non-zero */ - return wlc->macintstatus != 0; - - fatal: - brcms_init(wlc->wl); - return wlc->macintstatus != 0; -} - -/* common low-level watchdog code */ -void brcms_b_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return; - - /* increment second count */ - wlc_hw->now++; - - /* Check for FIFO error interrupts */ - brcms_b_fifoerrors(wlc_hw); - - /* make sure RX dma has buffers */ - dma_rxfill(wlc->hw->di[RX_FIFO]); - - wlc_phy_watchdog(wlc_hw->band->pi); -} - -void -brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute, struct txpwr_limits *txpwr) -{ - uint bandunit; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); - - wlc_hw->chanspec = chanspec; - - /* Switch bands if necessary */ - if (NBANDS_HW(wlc_hw) > 1) { - bandunit = CHSPEC_BANDUNIT(chanspec); - if (wlc_hw->band->bandunit != bandunit) { - /* brcms_b_setband disables other bandunit, - * use light band switch if not up yet - */ - if (wlc_hw->up) { - wlc_phy_chanspec_radio_set(wlc_hw-> - bandstate[bandunit]-> - pi, chanspec); - brcms_b_setband(wlc_hw, bandunit, chanspec); - } else { - brcms_c_setxband(wlc_hw, bandunit); - } - } - } - - wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); - - if (!wlc_hw->up) { - if (wlc_hw->clk) - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, - chanspec); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - } else { - wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); - - /* Update muting of the channel */ - brcms_b_mute(wlc_hw, mute, 0); - } -} - -int brcms_b_state_get(struct brcms_hardware *wlc_hw, - struct brcms_b_state *state) -{ - state->machwcap = wlc_hw->machwcap; - - return 0; -} - -static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) -{ - uint i; - char name[8]; - /* ucode host flag 2 needed for pio mode, independent of band and fifo */ - u16 pio_mhf2 = 0; - struct brcms_hardware *wlc_hw = wlc->hw; - uint unit = wlc_hw->unit; - struct brcms_tunables *tune = wlc->pub->tunables; - struct wiphy *wiphy = wlc->wiphy; - - /* name and offsets for dma_attach */ - snprintf(name, sizeof(name), "wl%d", unit); - - if (wlc_hw->di[0] == 0) { /* Init FIFOs */ - uint addrwidth; - int dma_attach_err = 0; - /* Find out the DMA addressing capability and let OS know - * All the channels within one DMA core have 'common-minimum' same - * capability - */ - addrwidth = - dma_addrwidth(wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 0)); - - if (!wl_alloc_dma_resources(wlc_hw->wlc->wl, addrwidth)) { - wiphy_err(wiphy, "wl%d: wlc_attach: alloc_dma_" - "resources failed\n", unit); - return false; - } - - /* - * FIFO 0 - * TX: TX_AC_BK_FIFO (TX AC Background data packets) - * RX: RX_FIFO (RX data packets) - */ - wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, - (wme ? DMAREG(wlc_hw, DMA_TX, 0) : - NULL), DMAREG(wlc_hw, DMA_RX, 0), - (wme ? tune->ntxd : 0), tune->nrxd, - tune->rxbufsz, -1, tune->nrxbufpost, - BRCMS_HWRXOFF, &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[0]); - - /* - * FIFO 1 - * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) - * (legacy) TX_DATA_FIFO (TX data packets) - * RX: UNUSED - */ - wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 1), NULL, - tune->ntxd, 0, 0, -1, 0, 0, - &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[1]); - - /* - * FIFO 2 - * TX: TX_AC_VI_FIFO (TX AC Video data packets) - * RX: UNUSED - */ - wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 2), NULL, - tune->ntxd, 0, 0, -1, 0, 0, - &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[2]); - /* - * FIFO 3 - * TX: TX_AC_VO_FIFO (TX AC Voice data packets) - * (legacy) TX_CTL_FIFO (TX control & mgmt packets) - */ - wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 3), - NULL, tune->ntxd, 0, 0, -1, - 0, 0, &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[3]); -/* Cleaner to leave this as if with AP defined */ - - if (dma_attach_err) { - wiphy_err(wiphy, "wl%d: wlc_attach: dma_attach failed" - "\n", unit); - return false; - } - - /* get pointer to dma engine tx flow control variable */ - for (i = 0; i < NFIFO; i++) - if (wlc_hw->di[i]) - wlc_hw->txavail[i] = - (uint *) dma_getvar(wlc_hw->di[i], - "&txavail"); - } - - /* initial ucode host flags */ - brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); - - return true; -} - -static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw) -{ - uint j; - - for (j = 0; j < NFIFO; j++) { - if (wlc_hw->di[j]) { - dma_detach(wlc_hw->di[j]); - wlc_hw->di[j] = NULL; - } - } -} - -/* low level attach - * run backplane attach, init nvram - * run phy attach - * initialize software state for each core and band - * put the whole chip in reset(driver down state), no clock - */ -int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, uint bustype, void *btparam) -{ - struct brcms_hardware *wlc_hw; - d11regs_t *regs; - char *macaddr = NULL; - char *vars; - uint err = 0; - uint j; - bool wme = false; - struct shared_phy_params sha_params; - struct wiphy *wiphy = wlc->wiphy; - - BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, - device); - - wme = true; - - wlc_hw = wlc->hw; - wlc_hw->wlc = wlc; - wlc_hw->unit = unit; - wlc_hw->band = wlc_hw->bandstate[0]; - wlc_hw->_piomode = piomode; - - /* populate struct brcms_hardware with default values */ - brcms_b_info_init(wlc_hw); - - /* - * Do the hardware portion of the attach. - * Also initialize software state that depends on the particular hardware - * we are running. - */ - wlc_hw->sih = ai_attach(regsva, bustype, btparam, - &wlc_hw->vars, &wlc_hw->vars_size); - if (wlc_hw->sih == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", - unit); - err = 11; - goto fail; - } - vars = wlc_hw->vars; - - /* - * Get vendid/devid nvram overwrites, which could be different - * than those the BIOS recognizes for devices on PCMCIA_BUS, - * SDIO_BUS, and SROMless devices on PCI_BUS. - */ -#ifdef BCMBUSTYPE - bustype = BCMBUSTYPE; -#endif - if (bustype != SI_BUS) { - char *var; - - var = getvar(vars, "vendid"); - if (var) { - vendor = (u16) simple_strtoul(var, NULL, 0); - wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", - vendor); - } - var = getvar(vars, "devid"); - if (var) { - u16 devid = (u16) simple_strtoul(var, NULL, 0); - if (devid != 0xffff) { - device = devid; - wiphy_err(wiphy, "Overriding device id = 0x%x" - "\n", device); - } - } - - /* verify again the device is supported */ - if (!brcms_c_chipmatch(vendor, device)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " - "vendor/device (0x%x/0x%x)\n", - unit, vendor, device); - err = 12; - goto fail; - } - } - - wlc_hw->vendorid = vendor; - wlc_hw->deviceid = device; - - /* set bar0 window to point at D11 core */ - wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - wlc_hw->corerev = ai_corerev(wlc_hw->sih); - - regs = wlc_hw->regs; - - wlc->regs = wlc_hw->regs; - - /* validate chip, chiprev and corerev */ - if (!brcms_c_isgoodchip(wlc_hw)) { - err = 13; - goto fail; - } - - /* initialize power control registers */ - ai_clkctl_init(wlc_hw->sih); - - /* request fastclock and force fastclock for the rest of attach - * bring the d11 core out of reset. - * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk is still false; - * But it will be called again inside wlc_corereset, after d11 is out of reset. - */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - if (!brcms_b_validate_chip_access(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: validate_chip_access " - "failed\n", unit); - err = 14; - goto fail; - } - - /* get the board rev, used just below */ - j = getintvar(vars, "boardrev"); - /* promote srom boardrev of 0xFF to 1 */ - if (j == BOARDREV_PROMOTABLE) - j = BOARDREV_PROMOTED; - wlc_hw->boardrev = (u16) j; - if (!brcms_c_validboardtype(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " - "board type (0x%x)" " or revision level (0x%x)\n", - unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); - err = 15; - goto fail; - } - wlc_hw->sromrev = (u8) getintvar(vars, "sromrev"); - wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); - wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); - - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); - - if ((wlc_hw->sih->bustype == PCI_BUS) - && (ai_pci_war16165(wlc_hw->sih))) - wlc->war16165 = true; - - /* check device id(srom, nvram etc.) to set bands */ - if (wlc_hw->deviceid == BCM43224_D11N_ID || - wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) { - /* Dualband boards */ - wlc_hw->_nbands = 2; - } else - wlc_hw->_nbands = 1; - - if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->_nbands = 1; - - /* BMAC_NOTE: remove init of pub values when brcms_c_attach() - * unconditionally does the init of these values - */ - wlc->vendorid = wlc_hw->vendorid; - wlc->deviceid = wlc_hw->deviceid; - wlc->pub->sih = wlc_hw->sih; - wlc->pub->corerev = wlc_hw->corerev; - wlc->pub->sromrev = wlc_hw->sromrev; - wlc->pub->boardrev = wlc_hw->boardrev; - wlc->pub->boardflags = wlc_hw->boardflags; - wlc->pub->boardflags2 = wlc_hw->boardflags2; - wlc->pub->_nbands = wlc_hw->_nbands; - - wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); - - if (wlc_hw->physhim == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_shim_attach " - "failed\n", unit); - err = 25; - goto fail; - } - - /* pass all the parameters to wlc_phy_shared_attach in one struct */ - sha_params.sih = wlc_hw->sih; - sha_params.physhim = wlc_hw->physhim; - sha_params.unit = unit; - sha_params.corerev = wlc_hw->corerev; - sha_params.vars = vars; - sha_params.vid = wlc_hw->vendorid; - sha_params.did = wlc_hw->deviceid; - sha_params.chip = wlc_hw->sih->chip; - sha_params.chiprev = wlc_hw->sih->chiprev; - sha_params.chippkg = wlc_hw->sih->chippkg; - sha_params.sromrev = wlc_hw->sromrev; - sha_params.boardtype = wlc_hw->sih->boardtype; - sha_params.boardrev = wlc_hw->boardrev; - sha_params.boardvendor = wlc_hw->sih->boardvendor; - sha_params.boardflags = wlc_hw->boardflags; - sha_params.boardflags2 = wlc_hw->boardflags2; - sha_params.bustype = wlc_hw->sih->bustype; - sha_params.buscorerev = wlc_hw->sih->buscorerev; - - /* alloc and save pointer to shared phy state area */ - wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); - if (!wlc_hw->phy_sh) { - err = 16; - goto fail; - } - - /* initialize software state for each core and band */ - for (j = 0; j < NBANDS_HW(wlc_hw); j++) { - /* - * band0 is always 2.4Ghz - * band1, if present, is 5Ghz - */ - - /* So if this is a single band 11a card, use band 1 */ - if (IS_SINGLEBAND_5G(wlc_hw->deviceid)) - j = BAND_5G_INDEX; - - brcms_c_setxband(wlc_hw, j); - - wlc_hw->band->bandunit = j; - wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->band->bandunit = j; - wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->core->coreidx = ai_coreidx(wlc_hw->sih); - - wlc_hw->machwcap = R_REG(®s->machwcap); - wlc_hw->machwcap_backup = wlc_hw->machwcap; - - /* init tx fifo size */ - wlc_hw->xmtfifo_sz = - xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; - - /* Get a phy for this band */ - wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, - (void *)regs, brcms_b_bandtype(wlc_hw), vars, - wlc->wiphy); - if (wlc_hw->band->pi == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" - "attach failed\n", unit); - err = 17; - goto fail; - } - - wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); - - wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, - &wlc_hw->band->phyrev, - &wlc_hw->band->radioid, - &wlc_hw->band->radiorev); - wlc_hw->band->abgphy_encore = - wlc_phy_get_encore(wlc_hw->band->pi); - wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); - wlc_hw->band->core_flags = - wlc_phy_get_coreflags(wlc_hw->band->pi); - - /* verify good phy_type & supported phy revision */ - if (BRCMS_ISNPHY(wlc_hw->band)) { - if (NCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { - if (LCNCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else { - bad_phy: - wiphy_err(wiphy, "wl%d: brcms_b_attach: unsupported " - "phy type/rev (%d/%d)\n", unit, - wlc_hw->band->phytype, wlc_hw->band->phyrev); - err = 18; - goto fail; - } - - good_phy: - /* BMAC_NOTE: wlc->band->pi should not be set below and should be done in the - * high level attach. However we can not make that change until all low level access - * is changed to wlc_hw->band->pi. Instead do the wlc->band->pi init below, keeping - * wlc_hw->band->pi as well for incremental update of low level fns, and cut over - * low only init when all fns updated. - */ - wlc->band->pi = wlc_hw->band->pi; - wlc->band->phytype = wlc_hw->band->phytype; - wlc->band->phyrev = wlc_hw->band->phyrev; - wlc->band->radioid = wlc_hw->band->radioid; - wlc->band->radiorev = wlc_hw->band->radiorev; - - /* default contention windows size limits */ - wlc_hw->band->CWmin = APHY_CWMIN; - wlc_hw->band->CWmax = PHY_CWMAX; - - if (!brcms_b_attach_dmapio(wlc, j, wme)) { - err = 19; - goto fail; - } - } - - /* disable core to match driver "down" state */ - brcms_c_coredisable(wlc_hw); - - /* Match driver "down" state */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - - /* register sb interrupt callback functions */ - ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, - (void *)brcms_c_wlintrsrestore, NULL, wlc); - - /* turn off pll and xtal to match driver "down" state */ - brcms_b_xtal(wlc_hw, OFF); - - /* ********************************************************************* - * The hardware is in the DOWN state at this point. D11 core - * or cores are in reset with clocks off, and the board PLLs - * are off if possible. - * - * Beyond this point, wlc->sbclk == false and chip registers - * should not be touched. - ********************************************************************* - */ - - /* init etheraddr state variables */ - macaddr = brcms_c_get_macaddr(wlc_hw); - if (macaddr == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n", - unit); - err = 21; - goto fail; - } - brcmu_ether_atoe(macaddr, wlc_hw->etheraddr); - if (is_broadcast_ether_addr(wlc_hw->etheraddr) || - is_zero_ether_addr(wlc_hw->etheraddr)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", - unit, macaddr); - err = 22; - goto fail; - } - - BCMMSG(wlc->wiphy, - "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", - wlc_hw->deviceid, wlc_hw->_nbands, - wlc_hw->sih->boardtype, macaddr); - - return err; - - fail: - wiphy_err(wiphy, "wl%d: brcms_b_attach: failed with err %d\n", unit, - err); - return err; -} - -/* - * Initialize brcms_c_info default values ... - * may get overrides later in this function - * BMAC_NOTES, move low out and resolve the dangling ones - */ -static void brcms_b_info_init(struct brcms_hardware *wlc_hw) -{ - struct brcms_c_info *wlc = wlc_hw->wlc; - - /* set default sw macintmask value */ - wlc->defmacintmask = DEF_MACINTMASK; - - /* various 802.11g modes */ - wlc_hw->shortslot = false; - - wlc_hw->SFBL = RETRY_SHORT_FB; - wlc_hw->LFBL = RETRY_LONG_FB; - - /* default mac retry limits */ - wlc_hw->SRL = RETRY_SHORT_DEF; - wlc_hw->LRL = RETRY_LONG_DEF; - wlc_hw->chanspec = CH20MHZ_CHSPEC(1); -} - -/* - * low level detach - */ -int brcms_b_detach(struct brcms_c_info *wlc) -{ - uint i; - struct brcms_hw_band *band; - struct brcms_hardware *wlc_hw = wlc->hw; - int callbacks; - - callbacks = 0; - - if (wlc_hw->sih) { - /* detach interrupt sync mechanism since interrupt is disabled and per-port - * interrupt object may has been freed. this must be done before sb core switch - */ - ai_deregister_intr_callback(wlc_hw->sih); - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_sleep(wlc_hw->sih); - } - - brcms_b_detach_dmapio(wlc_hw); - - band = wlc_hw->band; - for (i = 0; i < NBANDS_HW(wlc_hw); i++) { - if (band->pi) { - /* Detach this band's phy */ - wlc_phy_detach(band->pi); - band->pi = NULL; - } - band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; - } - - /* Free shared phy state */ - kfree(wlc_hw->phy_sh); - - wlc_phy_shim_detach(wlc_hw->physhim); - - /* free vars */ - kfree(wlc_hw->vars); - wlc_hw->vars = NULL; - - if (wlc_hw->sih) { - ai_detach(wlc_hw->sih); - wlc_hw->sih = NULL; - } - - return callbacks; - -} - -void brcms_b_reset(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset the core */ - if (!DEVICEREMOVED(wlc_hw->wlc)) - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - /* purge the dma rings */ - brcms_c_flushqueues(wlc_hw->wlc); - - brcms_c_reset_bmac_done(wlc_hw->wlc); -} - -void -brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute) { - u32 macintmask; - bool fastclk; - struct brcms_c_info *wlc = wlc_hw->wlc; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* disable interrupts */ - macintmask = brcms_intrsoff(wlc->wl); - - /* set up the specified band and chanspec */ - brcms_c_setxband(wlc_hw, CHSPEC_BANDUNIT(chanspec)); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - - /* do one-time phy inits and calibration */ - wlc_phy_cal_init(wlc_hw->band->pi); - - /* core-specific initialization */ - brcms_b_coreinit(wlc); - - /* suspend the tx fifos and mute the phy for preism cac time */ - if (mute) - brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); - - /* band-specific inits */ - brcms_b_bsinit(wlc, chanspec); - - /* restore macintmask */ - brcms_intrsrestore(wlc->wl, macintmask); - - /* seed wake_override with BRCMS_WAKE_OVERRIDE_MACSUSPEND since the mac - * is suspended and brcms_c_enable_mac() will clear this override bit. - */ - mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - - /* - * initialize mac_suspend_depth to 1 to match ucode initial suspended state - */ - wlc_hw->mac_suspend_depth = 1; - - /* restore the clk */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -int brcms_b_up_prep(struct brcms_hardware *wlc_hw) -{ - uint coremask; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* - * Configure pci/pcmcia here instead of in brcms_c_attach() - * to allow mfg hotswap: down, hotswap (chip power cycle), up. - */ - coremask = (1 << wlc_hw->wlc->core->coreidx); - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_setup(wlc_hw->sih, coremask); - - /* - * Need to read the hwradio status here to cover the case where the system - * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. - */ - if (brcms_b_radio_read_hwdisabled(wlc_hw)) { - /* put SB PCI in down state again */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - return -ENOMEDIUM; - } - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_up(wlc_hw->sih); - - /* reset the d11 core */ - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - return 0; -} - -int brcms_b_up_finish(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - wlc_hw->up = true; - wlc_phy_hw_state_upd(wlc_hw->band->pi, true); - - /* FULLY enable dynamic power control and d11 core interrupt */ - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); - brcms_intrson(wlc_hw->wlc->wl); - return 0; -} - -int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) -{ - bool dev_gone; - uint callbacks = 0; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - dev_gone = DEVICEREMOVED(wlc_hw->wlc); - - /* disable interrupts */ - if (dev_gone) - wlc_hw->wlc->macintmask = 0; - else { - /* now disable interrupts */ - brcms_intrsoff(wlc_hw->wlc->wl); - - /* ensure we're running on the pll clock again */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - } - /* down phy at the last of this stage */ - callbacks += wlc_phy_down(wlc_hw->band->pi); - - return callbacks; -} - -int brcms_b_down_finish(struct brcms_hardware *wlc_hw) -{ - uint callbacks = 0; - bool dev_gone; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - wlc_hw->up = false; - wlc_phy_hw_state_upd(wlc_hw->band->pi, false); - - dev_gone = DEVICEREMOVED(wlc_hw->wlc); - - if (dev_gone) { - wlc_hw->sbclk = false; - wlc_hw->clk = false; - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - - /* reclaim any posted packets */ - brcms_c_flushqueues(wlc_hw->wlc); - } else { - - /* Reset and disable the core */ - if (ai_iscoreup(wlc_hw->sih)) { - if (R_REG(&wlc_hw->regs->maccontrol) & - MCTL_EN_MAC) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - callbacks += brcms_reset(wlc_hw->wlc->wl); - brcms_c_coredisable(wlc_hw); - } - - /* turn off primary xtal and pll */ - if (!wlc_hw->noreset) { - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - } - } - - return callbacks; -} - -void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) -{ - /* delay before first read of ucode state */ - udelay(40); - - /* wait until ucode is no longer asleep */ - SPINWAIT((brcms_b_read_shm(wlc_hw, M_UCODE_DBGST) == - DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); -} - -void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea) -{ - memcpy(ea, wlc_hw->etheraddr, ETH_ALEN); -} - -static int brcms_b_bandtype(struct brcms_hardware *wlc_hw) -{ - return wlc_hw->band->bandtype; -} - -/* control chip clock to save power, enable dynamic clock or force fast clock */ -static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) -{ - if (PMUCTL_ENAB(wlc_hw->sih)) { - /* new chips with PMU, CCS_FORCEHT will distribute the HT clock on backplane, - * but mac core will still run on ALP(not HT) when it enters powersave mode, - * which means the FCA bit may not be set. - * should wakeup mac if driver wants it to run on HT. - */ - - if (wlc_hw->clk) { - if (mode == CLK_FAST) { - OR_REG(&wlc_hw->regs->clk_ctl_st, - CCS_FORCEHT); - - udelay(64); - - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) == 0), - PMU_MAX_TRANSITION_DLY); - WARN_ON(!(R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL)); - } else { - if ((wlc_hw->sih->pmurev == 0) && - (R_REG - (&wlc_hw->regs-> - clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) - == 0), - PMU_MAX_TRANSITION_DLY); - AND_REG(&wlc_hw->regs->clk_ctl_st, - ~CCS_FORCEHT); - } - } - wlc_hw->forcefastclk = (mode == CLK_FAST); - } else { - - /* old chips w/o PMU, force HT through cc, - * then use FCA to verify mac is running fast clock - */ - - wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); - - /* check fast clock is available (if core is not in reset) */ - if (wlc_hw->forcefastclk && wlc_hw->clk) - WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) & - SISF_FCLKA)); - - /* keep the ucode wake bit on if forcefastclk is on - * since we do not want ucode to put us back to slow clock - * when it dozes for PM mode. - * Code below matches the wake override bit with current forcefastclk state - * Only setting bit in wake_override instead of waking ucode immediately - * since old code (wlc.c 1.4499) had this behavior. Older code set - * wlc->forcefastclk but only had the wake happen if the wakup_ucode work - * (protected by an up check) was executed just below. - */ - if (wlc_hw->forcefastclk) - mboolset(wlc_hw->wake_override, - BRCMS_WAKE_OVERRIDE_FORCEFAST); - else - mboolclr(wlc_hw->wake_override, - BRCMS_WAKE_OVERRIDE_FORCEFAST); - } -} - -/* set initial host flags value */ -static void -brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - - memset(mhfs, 0, MHFMAX * sizeof(u16)); - - mhfs[MHF2] |= mhf2_init; - - /* prohibit use of slowclock on multifunction boards */ - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - mhfs[MHF1] |= MHF1_FORCEFASTCLK; - - if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { - mhfs[MHF2] |= MHF2_NPHY40MHZ_WAR; - mhfs[MHF1] |= MHF1_IQSWAP_WAR; - } -} - -/* set or clear ucode host flag bits - * it has an optimization for no-change write - * it only writes through shared memory when the core has clock; - * pre-CLK changes should use wlc_write_mhf to get around the optimization - * - * - * bands values are: BRCM_BAND_AUTO <--- Current band only - * BRCM_BAND_5G <--- 5G band only - * BRCM_BAND_2G <--- 2G band only - * BRCM_BAND_ALL <--- All bands - */ -void -brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, - int bands) -{ - u16 save; - u16 addr[MHFMAX] = { - M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, - M_HOST_FLAGS5 - }; - struct brcms_hw_band *band; - - if ((val & ~mask) || idx >= MHFMAX) - return; /* error condition */ - - switch (bands) { - /* Current band only or all bands, - * then set the band to current band - */ - case BRCM_BAND_AUTO: - case BRCM_BAND_ALL: - band = wlc_hw->band; - break; - case BRCM_BAND_5G: - band = wlc_hw->bandstate[BAND_5G_INDEX]; - break; - case BRCM_BAND_2G: - band = wlc_hw->bandstate[BAND_2G_INDEX]; - break; - default: - band = NULL; /* error condition */ - } - - if (band) { - save = band->mhfs[idx]; - band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; - - /* optimization: only write through if changed, and - * changed band is the current band - */ - if (wlc_hw->clk && (band->mhfs[idx] != save) - && (band == wlc_hw->band)) - brcms_b_write_shm(wlc_hw, addr[idx], - (u16) band->mhfs[idx]); - } - - if (bands == BRCM_BAND_ALL) { - wlc_hw->bandstate[0]->mhfs[idx] = - (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; - wlc_hw->bandstate[1]->mhfs[idx] = - (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; - } -} - -u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands) -{ - struct brcms_hw_band *band; - - if (idx >= MHFMAX) - return 0; /* error condition */ - switch (bands) { - case BRCM_BAND_AUTO: - band = wlc_hw->band; - break; - case BRCM_BAND_5G: - band = wlc_hw->bandstate[BAND_5G_INDEX]; - break; - case BRCM_BAND_2G: - band = wlc_hw->bandstate[BAND_2G_INDEX]; - break; - default: - band = NULL; /* error condition */ - } - - if (!band) - return 0; - - return band->mhfs[idx]; -} - -static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) -{ - u8 idx; - u16 addr[] = { - M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, - M_HOST_FLAGS5 - }; - - for (idx = 0; idx < MHFMAX; idx++) { - brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); - } -} - -/* set the maccontrol register to desired reset state and - * initialize the sw cache of the register - */ -static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw) -{ - /* IHR accesses are always enabled, PSM disabled, HPS off and WAKE on */ - wlc_hw->maccontrol = 0; - wlc_hw->suspended_fifos = 0; - wlc_hw->wake_override = 0; - wlc_hw->mute_override = 0; - brcms_b_mctrl(wlc_hw, ~0, MCTL_IHR_EN | MCTL_WAKE); -} - -/* set or clear maccontrol bits */ -void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) -{ - u32 maccontrol; - u32 new_maccontrol; - - if (val & ~mask) - return; /* error condition */ - maccontrol = wlc_hw->maccontrol; - new_maccontrol = (maccontrol & ~mask) | val; - - /* if the new maccontrol value is the same as the old, nothing to do */ - if (new_maccontrol == maccontrol) - return; - - /* something changed, cache the new value */ - wlc_hw->maccontrol = new_maccontrol; - - /* write the new values with overrides applied */ - brcms_c_mctrl_write(wlc_hw); -} - -/* write the software state of maccontrol and overrides to the maccontrol register */ -static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) -{ - u32 maccontrol = wlc_hw->maccontrol; - - /* OR in the wake bit if overridden */ - if (wlc_hw->wake_override) - maccontrol |= MCTL_WAKE; - - /* set AP and INFRA bits for mute if needed */ - if (wlc_hw->mute_override) { - maccontrol &= ~(MCTL_AP); - maccontrol |= MCTL_INFRA; - } - - W_REG(&wlc_hw->regs->maccontrol, maccontrol); -} - -void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, - u32 override_bit) -{ - if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { - mboolset(wlc_hw->wake_override, override_bit); - return; - } - - mboolset(wlc_hw->wake_override, override_bit); - - brcms_c_mctrl_write(wlc_hw); - brcms_b_wait_for_wake(wlc_hw); - - return; -} - -void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, - u32 override_bit) -{ - mboolclr(wlc_hw->wake_override, override_bit); - - if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) - return; - - brcms_c_mctrl_write(wlc_hw); - - return; -} - -/* When driver needs ucode to stop beaconing, it has to make sure that - * MCTL_AP is clear and MCTL_INFRA is set - * Mode MCTL_AP MCTL_INFRA - * AP 1 1 - * STA 0 1 <--- This will ensure no beacons - * IBSS 0 0 - */ -static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw) -{ - wlc_hw->mute_override = 1; - - /* if maccontrol already has AP == 0 and INFRA == 1 without this - * override, then there is no change to write - */ - if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) - return; - - brcms_c_mctrl_write(wlc_hw); - - return; -} - -/* Clear the override on AP and INFRA bits */ -static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw) -{ - if (wlc_hw->mute_override == 0) - return; - - wlc_hw->mute_override = 0; - - /* if maccontrol already has AP == 0 and INFRA == 1 without this - * override, then there is no change to write - */ - if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) - return; - - brcms_c_mctrl_write(wlc_hw); -} - -/* - * Write a MAC address to the given match reg offset in the RXE match engine. - */ -void -brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, - const u8 *addr) -{ - d11regs_t *regs; - u16 mac_l; - u16 mac_m; - u16 mac_h; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", - wlc_hw->unit); - - regs = wlc_hw->regs; - mac_l = addr[0] | (addr[1] << 8); - mac_m = addr[2] | (addr[3] << 8); - mac_h = addr[4] | (addr[5] << 8); - - /* enter the MAC addr into the RXE match registers */ - W_REG(®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); - W_REG(®s->rcm_mat_data, mac_l); - W_REG(®s->rcm_mat_data, mac_m); - W_REG(®s->rcm_mat_data, mac_h); - -} - -void -brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, - void *buf) -{ - d11regs_t *regs; - u32 word; - bool be_bit; - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - W_REG(®s->tplatewrptr, offset); - - /* if MCTL_BIGEND bit set in mac control register, - * the chip swaps data in fifo, as well as data in - * template ram - */ - be_bit = (R_REG(®s->maccontrol) & MCTL_BIGEND) != 0; - - while (len > 0) { - memcpy(&word, buf, sizeof(u32)); - - if (be_bit) - word = cpu_to_be32(word); - else - word = cpu_to_le32(word); - - W_REG(®s->tplatewrdata, word); - - buf = (u8 *) buf + sizeof(u32); - len -= sizeof(u32); - } -} - -void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) -{ - wlc_hw->band->CWmin = newmin; - - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmin); -} - -void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) -{ - wlc_hw->band->CWmax = newmax; - - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmax); -} - -void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) -{ - bool fastclk; - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - wlc_phy_bw_state_set(wlc_hw->band->pi, bw); - - brcms_b_phy_reset(wlc_hw); - wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); - - /* restore the clk */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -static void -brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, - int len) -{ - d11regs_t *regs = wlc_hw->regs; - - brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3, - bcn); - /* write beacon length to SCR */ - brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len); - /* mark beacon0 valid */ - OR_REG(®s->maccommand, MCMD_BCN0VLD); -} - -static void -brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, - int len) -{ - d11regs_t *regs = wlc_hw->regs; - - brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3, - bcn); - /* write beacon length to SCR */ - brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len); - /* mark beacon1 valid */ - OR_REG(®s->maccommand, MCMD_BCN1VLD); -} - -/* mac is assumed to be suspended at this point */ -void -brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, - int len, bool both) -{ - d11regs_t *regs = wlc_hw->regs; - - if (both) { - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } else { - /* bcn 0 */ - if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - /* bcn 1 */ - else if (! - (R_REG(®s->maccommand) & MCMD_BCN1VLD)) - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } -} - -static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) -{ - u16 v; - struct brcms_c_info *wlc = wlc_hw->wlc; - /* update SYNTHPU_DLY */ - - if (BRCMS_ISLCNPHY(wlc->band)) { - v = SYNTHPU_DLY_LPPHY_US; - } else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) { - v = SYNTHPU_DLY_NPHY_US; - } else { - v = SYNTHPU_DLY_BPHY_US; - } - - brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); -} - -/* band-specific init */ -static void -brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc_hw->band->bandunit); - - brcms_c_ucode_bsinit(wlc_hw); - - wlc_phy_init(wlc_hw->band->pi, chanspec); - - brcms_c_ucode_txant_set(wlc_hw); - - /* cwmin is band-specific, update hardware with value for current band */ - brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); - brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); - - brcms_b_update_slot_timing(wlc_hw, - BAND_5G(wlc_hw->band-> - bandtype) ? true : wlc_hw-> - shortslot); - - /* write phytype and phyvers */ - brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); - brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); - - /* initialize the txphyctl1 rate table since shmem is shared between bands */ - brcms_upd_ofdm_pctl1_table(wlc_hw); - - brcms_b_upd_synthpu(wlc_hw); -} - -static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); - - wlc_hw->phyclk = clk; - - if (OFF == clk) { /* clear gmode bit, put phy into reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), - (SICF_PRST | SICF_FGC)); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); - udelay(1); - - } else { /* take phy out of reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); - udelay(1); - - } -} - -/* Perform a soft reset of the PHY PLL */ -void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), ~0, 0); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 4); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); - udelay(1); -} - -/* light way to turn on phy clock without reset for NPHY only - * refer to brcms_b_core_phy_clk for full version - */ -void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk) -{ - /* support(necessary for NPHY and HYPHY) only */ - if (!BRCMS_ISNPHY(wlc_hw->band)) - return; - - if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC); - else - ai_core_cflags(wlc_hw->sih, SICF_FGC, 0); - -} - -void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk) -{ - if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE); - else - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0); -} - -void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) -{ - struct brcms_phy_pub *pih = wlc_hw->band->pi; - u32 phy_bw_clkbits; - bool phy_in_reset = false; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (pih == NULL) - return; - - phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); - - /* Specific reset sequence required for NPHY rev 3 and 4 */ - if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && - NREV_LE(wlc_hw->band->phyrev, 4)) { - /* Set the PHY bandwidth */ - ai_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits); - - udelay(1); - - /* Perform a soft reset of the PHY PLL */ - brcms_b_core_phypll_reset(wlc_hw); - - /* reset the PHY */ - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE), - (SICF_PRST | SICF_PCLKE)); - phy_in_reset = true; - } else { - - ai_core_cflags(wlc_hw->sih, - (SICF_PRST | SICF_PCLKE | SICF_BWMASK), - (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); - } - - udelay(2); - brcms_b_core_phy_clk(wlc_hw, ON); - - if (pih) - wlc_phy_anacore(pih, ON); -} - -/* switch to and initialize new band */ -static void -brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - chanspec_t chanspec) { - struct brcms_c_info *wlc = wlc_hw->wlc; - u32 macintmask; - - /* Enable the d11 core before accessing it */ - if (!ai_iscoreup(wlc_hw->sih)) { - ai_core_reset(wlc_hw->sih, 0, 0); - brcms_c_mctrl_reset(wlc_hw); - } - - macintmask = brcms_c_setband_inact(wlc, bandunit); - - if (!wlc_hw->up) - return; - - brcms_b_core_phy_clk(wlc_hw, ON); - - /* band-specific initializations */ - brcms_b_bsinit(wlc, chanspec); - - /* - * If there are any pending software interrupt bits, - * then replace these with a harmless nonzero value - * so brcms_c_dpc() will re-enable interrupts when done. - */ - if (wlc->macintstatus) - wlc->macintstatus = MI_DMAINT; - - /* restore macintmask */ - brcms_intrsrestore(wlc->wl, macintmask); - - /* ucode should still be suspended.. */ - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); -} - -/* low-level band switch utility routine */ -void brcms_c_setxband(struct brcms_hardware *wlc_hw, - uint bandunit) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - bandunit); - - wlc_hw->band = wlc_hw->bandstate[bandunit]; - - /* BMAC_NOTE: until we eliminate need for wlc->band refs in low level code */ - wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; - - /* set gmode core flag */ - if (wlc_hw->sbclk && !wlc_hw->noreset) { - ai_core_cflags(wlc_hw->sih, SICF_GMODE, - ((bandunit == 0) ? SICF_GMODE : 0)); - } -} - -static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) -{ - - /* reject unsupported corerev */ - if (!VALID_COREREV(wlc_hw->corerev)) { - wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", - wlc_hw->corerev); - return false; - } - - return true; -} - -/* Validate some board info parameters */ -static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) -{ - uint boardrev = wlc_hw->boardrev; - - /* 4 bits each for board type, major, minor, and tiny version */ - uint brt = (boardrev & 0xf000) >> 12; - uint b0 = (boardrev & 0xf00) >> 8; - uint b1 = (boardrev & 0xf0) >> 4; - uint b2 = boardrev & 0xf; - - /* voards from other vendors are always considered valid */ - if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM) - return true; - - /* do some boardrev sanity checks when boardvendor is Broadcom */ - if (boardrev == 0) - return false; - - if (boardrev <= 0xff) - return true; - - if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9) - || (b2 > 9)) - return false; - - return true; -} - -static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) -{ - const char *varname = "macaddr"; - char *macaddr; - - /* If macaddr exists, use it (Sromrev4, CIS, ...). */ - macaddr = getvar(wlc_hw->vars, varname); - if (macaddr != NULL) - return macaddr; - - if (NBANDS_HW(wlc_hw) > 1) - varname = "et1macaddr"; - else - varname = "il0macaddr"; - - macaddr = getvar(wlc_hw->vars, varname); - if (macaddr == NULL) { - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " - "getvar(%s) not found\n", wlc_hw->unit, varname); - } - - return macaddr; -} - -/* - * Return true if radio is disabled, otherwise false. - * hw radio disable signal is an external pin, users activate it asynchronously - * this function could be called when driver is down and w/o clock - * it operates on different registers depending on corerev and boardflag. - */ -bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) -{ - bool v, clk, xtal; - u32 resetbits = 0, flags = 0; - - xtal = wlc_hw->sbclk; - if (!xtal) - brcms_b_xtal(wlc_hw, ON); - - /* may need to take core out of reset first */ - clk = wlc_hw->clk; - if (!clk) { - /* - * mac no longer enables phyclk automatically when driver - * accesses phyreg throughput mac. This can be skipped since - * only mac reg is accessed below - */ - flags |= SICF_PCLKE; - - /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = - (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); - ai_core_reset(wlc_hw->sih, flags, resetbits); - brcms_c_mctrl_reset(wlc_hw); - } - - v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); - - /* put core back into reset */ - if (!clk) - ai_core_disable(wlc_hw->sih, 0); - - if (!xtal) - brcms_b_xtal(wlc_hw, OFF); - - return v; -} - -/* Initialize just the hardware when coming out of POR or S3/S5 system states */ -void brcms_b_hw_up(struct brcms_hardware *wlc_hw) -{ - if (wlc_hw->wlc->pub->hw_up) - return; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - if (wlc_hw->sih->bustype == PCI_BUS) { - ai_pci_fixcfg(wlc_hw->sih); - - /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = - (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); - } - - /* Inform phy that a POR reset has occurred so it does a complete phy init */ - wlc_phy_por_inform(wlc_hw->band->pi); - - wlc_hw->ucode_loaded = false; - wlc_hw->wlc->pub->hw_up = true; - - if ((wlc_hw->boardflags & BFL_FEM) - && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - if (! - (wlc_hw->boardrev >= 0x1250 - && (wlc_hw->boardflags & BFL_FEM_BT))) - ai_epa_4313war(wlc_hw->sih); - } -} - -static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) -{ - struct dma_pub *di = wlc_hw->di[fifo]; - return dma_rxreset(di); -} - -/* d11 core reset - * ensure fask clock during reset - * reset dma - * reset d11(out of reset) - * reset phy(out of reset) - * clear software macintstatus for fresh new start - * one testing hack wlc_hw->noreset will bypass the d11/phy reset - */ -void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) -{ - d11regs_t *regs; - uint i; - bool fastclk; - u32 resetbits = 0; - - if (flags == BRCMS_USE_COREFLAGS) - flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* reset the dma engines except first time thru */ - if (ai_iscoreup(wlc_hw->sih)) { - for (i = 0; i < NFIFO; i++) - if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) { - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " - "dma_txreset[%d]: cannot stop dma\n", - wlc_hw->unit, __func__, i); - } - - if ((wlc_hw->di[RX_FIFO]) - && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) { - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset" - "[%d]: cannot stop dma\n", - wlc_hw->unit, __func__, RX_FIFO); - } - } - /* if noreset, just stop the psm and return */ - if (wlc_hw->noreset) { - wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ - brcms_b_mctrl(wlc_hw, MCTL_PSM_RUN | MCTL_EN_MAC, 0); - return; - } - - /* - * mac no longer enables phyclk automatically when driver accesses - * phyreg throughput mac, AND phy_reset is skipped at early stage when - * band->pi is invalid. need to enable PHY CLK - */ - flags |= SICF_PCLKE; - - /* reset the core - * In chips with PMU, the fastclk request goes through d11 core reg 0x1e0, which - * is cleared by the core_reset. have to re-request it. - * This adds some delay and we can optimize it by also requesting fastclk through - * chipcommon during this period if necessary. But that has to work coordinate - * with other driver like mips/arm since they may touch chipcommon as well. - */ - wlc_hw->clk = false; - ai_core_reset(wlc_hw->sih, flags, resetbits); - wlc_hw->clk = true; - if (wlc_hw->band && wlc_hw->band->pi) - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); - - brcms_c_mctrl_reset(wlc_hw); - - if (PMUCTL_ENAB(wlc_hw->sih)) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - brcms_b_phy_reset(wlc_hw); - - /* turn on PHY_PLL */ - brcms_b_core_phypll_ctl(wlc_hw, true); - - /* clear sw intstatus */ - wlc_hw->wlc->macintstatus = 0; - - /* restore the clk setting */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -/* txfifo sizes needs to be modified(increased) since the newer cores - * have more memory. - */ -static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) -{ - d11regs_t *regs = wlc_hw->regs; - u16 fifo_nu; - u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; - u16 txfifo_def, txfifo_def1; - u16 txfifo_cmd; - - /* tx fifos start at TXFIFO_START_BLK from the Base address */ - txfifo_startblk = TXFIFO_START_BLK; - - /* sequence of operations: reset fifo, set fifo size, reset fifo */ - for (fifo_nu = 0; fifo_nu < NFIFO; fifo_nu++) { - - txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; - txfifo_def = (txfifo_startblk & 0xff) | - (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); - txfifo_def1 = ((txfifo_startblk >> 8) & 0x1) | - ((((txfifo_endblk - - 1) >> 8) & 0x1) << TXFIFO_FIFOTOP_SHIFT); - txfifo_cmd = - TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); - - W_REG(®s->xmtfifocmd, txfifo_cmd); - W_REG(®s->xmtfifodef, txfifo_def); - W_REG(®s->xmtfifodef1, txfifo_def1); - - W_REG(®s->xmtfifocmd, txfifo_cmd); - - txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; - } - /* - * need to propagate to shm location to be in sync since ucode/hw won't - * do this - */ - brcms_b_write_shm(wlc_hw, M_FIFOSIZE0, - wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE1, - wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE2, - ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> - xmtfifo_sz[TX_AC_BK_FIFO])); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE3, - ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> - xmtfifo_sz[TX_BCMC_FIFO])); -} - -/* d11 core init - * reset PSM - * download ucode/PCM - * let ucode run to suspended - * download ucode inits - * config other core registers - * init dma - */ -static void brcms_b_coreinit(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs; - u32 sflags; - uint bcnint_us; - uint i = 0; - bool fifosz_fixup = false; - int err = 0; - u16 buf[NFIFO]; - struct wiphy *wiphy = wlc->wiphy; - - regs = wlc_hw->regs; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset PSM */ - brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); - - brcms_ucode_download(wlc_hw); - /* - * FIFOSZ fixup. driver wants to controls the fifo allocation. - */ - fifosz_fixup = true; - - /* let the PSM run to the suspended state, set mode to BSS STA */ - W_REG(®s->macintstatus, -1); - brcms_b_mctrl(wlc_hw, ~0, - (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); - - /* wait for ucode to self-suspend after auto-init */ - SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), - 1000 * 1000); - if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) - wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" - "suspend!\n", wlc_hw->unit); - - brcms_c_gpio_init(wlc); - - sflags = ai_core_sflags(wlc_hw->sih, 0, 0); - - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, d11n0initvals16); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_c_write_inits(wlc_hw, d11lcn0initvals24); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - - /* For old ucode, txfifo sizes needs to be modified(increased) */ - if (fifosz_fixup == true) { - brcms_b_corerev_fifofixup(wlc_hw); - } - - /* check txfifo allocations match between ucode and driver */ - buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); - if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { - i = TX_AC_BE_FIFO; - err = -1; - } - buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); - if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { - i = TX_AC_VI_FIFO; - err = -1; - } - buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); - buf[TX_AC_VO_FIFO] = (buf[TX_AC_BK_FIFO] >> 8) & 0xff; - buf[TX_AC_BK_FIFO] &= 0xff; - if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { - i = TX_AC_BK_FIFO; - err = -1; - } - if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { - i = TX_AC_VO_FIFO; - err = -1; - } - buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); - buf[TX_ATIM_FIFO] = (buf[TX_BCMC_FIFO] >> 8) & 0xff; - buf[TX_BCMC_FIFO] &= 0xff; - if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { - i = TX_BCMC_FIFO; - err = -1; - } - if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { - i = TX_ATIM_FIFO; - err = -1; - } - if (err != 0) { - wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" - " driver size %d index %d\n", buf[i], - wlc_hw->xmtfifo_sz[i], i); - } - - /* make sure we can still talk to the mac */ - WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); - - /* band-specific inits done by wlc_bsinit() */ - - /* Set up frame burst size and antenna swap threshold init values */ - brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); - brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); - - /* enable one rx interrupt per received frame */ - W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); - - /* set the station mode (BSS STA) */ - brcms_b_mctrl(wlc_hw, - (MCTL_INFRA | MCTL_DISCARD_PMQ | MCTL_AP), - (MCTL_INFRA | MCTL_DISCARD_PMQ)); - - /* set up Beacon interval */ - bcnint_us = 0x8000 << 10; - W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); - W_REG(®s->tsf_cfpstart, bcnint_us); - W_REG(®s->macintstatus, MI_GP1); - - /* write interrupt mask */ - W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); - - /* allow the MAC to control the PHY clock (dynamic on/off) */ - brcms_b_macphyclk_set(wlc_hw, ON); - - /* program dynamic clock control fast powerup delay register */ - wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); - W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); - - /* tell the ucode the corerev */ - brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); - - /* tell the ucode MAC capabilities */ - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, - (u16) (wlc_hw->machwcap & 0xffff)); - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, - (u16) ((wlc_hw-> - machwcap >> 16) & 0xffff)); - - /* write retry limits to SCR, this done after PSM init */ - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->SRL); - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->LRL); - - /* write rate fallback retry limits */ - brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); - brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); - - AND_REG(®s->ifs_ctl, 0x0FFF); - W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); - - /* dma initializations */ - wlc->txpend16165war = 0; - - /* init the tx dma engines */ - for (i = 0; i < NFIFO; i++) { - if (wlc_hw->di[i]) - dma_txinit(wlc_hw->di[i]); - } - - /* init the rx dma engine(s) and post receive buffers */ - dma_rxinit(wlc_hw->di[RX_FIFO]); - dma_rxfill(wlc_hw->di[RX_FIFO]); -} - -/* This function is used for changing the tsf frac register - * If spur avoidance mode is off, the mac freq will be 80/120/160Mhz - * If spur avoidance mode is on1, the mac freq will be 82/123/164Mhz - * If spur avoidance mode is on2, the mac freq will be 84/126/168Mhz - * HTPHY Formula is 2^26/freq(MHz) e.g. - * For spuron2 - 126MHz -> 2^26/126 = 532610.0 - * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082 - * For spuron: 123MHz -> 2^26/123 = 545600.5 - * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341 - * For spur off: 120MHz -> 2^26/120 = 559240.5 - * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889 - */ - -void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) -{ - d11regs_t *regs; - regs = wlc_hw->regs; - - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { - if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x2082); - W_REG(®s->tsf_clk_frac_h, 0x8); - } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x5341); - W_REG(®s->tsf_clk_frac_h, 0x8); - } else { /* 120Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x8889); - W_REG(®s->tsf_clk_frac_h, 0x8); - } - } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { - if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x7CE0); - W_REG(®s->tsf_clk_frac_h, 0xC); - } else { /* 80Mhz */ - W_REG(®s->tsf_clk_frac_l, 0xCCCD); - W_REG(®s->tsf_clk_frac_h, 0xC); - } - } -} - -/* Initialize GPIOs that are controlled by D11 core */ -static void brcms_c_gpio_init(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs; - u32 gc, gm; - - regs = wlc_hw->regs; - - /* use GPIO select 0 to get all gpio signals from the gpio out reg */ - brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); - - /* - * Common GPIO setup: - * G0 = LED 0 = WLAN Activity - * G1 = LED 1 = WLAN 2.4 GHz Radio State - * G2 = LED 2 = WLAN 5 GHz Radio State - * G4 = radio disable input (HI enabled, LO disabled) - */ - - gc = gm = 0; - - /* Allocate GPIOs for mimo antenna diversity feature */ - if (wlc_hw->antsel_type == ANTSEL_2x3) { - /* Enable antenna diversity, use 2x3 mode */ - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, BRCM_BAND_ALL); - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, - MHF3_ANTSEL_MODE, BRCM_BAND_ALL); - - /* init superswitch control */ - wlc_phy_antsel_init(wlc_hw->band->pi, false); - - } else if (wlc_hw->antsel_type == ANTSEL_2x4) { - gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13); - /* - * The board itself is powered by these GPIOs - * (when not sending pattern) so set them high - */ - OR_REG(®s->psm_gpio_oe, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - OR_REG(®s->psm_gpio_out, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - - /* Enable antenna diversity, use 2x4 mode */ - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, BRCM_BAND_ALL); - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, - BRCM_BAND_ALL); - - /* Configure the desired clock to be 4Mhz */ - brcms_b_write_shm(wlc_hw, M_ANTSEL_CLKDIV, - ANTSEL_CLKDIV_4MHZ); - } - - /* gpio 9 controls the PA. ucode is responsible for wiggling out and oe */ - if (wlc_hw->boardflags & BFL_PACTRL) - gm |= gc |= BOARD_GPIO_PACTRL; - - /* apply to gpiocontrol register */ - ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY); -} - -static void brcms_ucode_download(struct brcms_hardware *wlc_hw) -{ - struct brcms_c_info *wlc; - wlc = wlc_hw->wlc; - - if (wlc_hw->ucode_loaded) - return; - - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, bcm43xx_16_mimo, - bcm43xx_16_mimosz); - wlc_hw->ucode_loaded = true; - } else - wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " - "corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, bcm43xx_24_lcn, - bcm43xx_24_lcnsz); - wlc_hw->ucode_loaded = true; - } else { - wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " - "corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - } -} - -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], - const uint nbytes) { - d11regs_t *regs = wlc_hw->regs; - uint i; - uint count; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - count = (nbytes / sizeof(u32)); - - W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); - (void)R_REG(®s->objaddr); - for (i = 0; i < count; i++) - W_REG(®s->objdata, ucode[i]); -} - -static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, - const struct d11init *inits) -{ - int i; - volatile u8 *base; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - base = (volatile u8 *)wlc_hw->regs; - - for (i = 0; inits[i].addr != 0xffff; i++) { - if (inits[i].size == 2) - W_REG((u16 *)(base + inits[i].addr), - inits[i].value); - else if (inits[i].size == 4) - W_REG((u32 *)(base + inits[i].addr), - inits[i].value); - } -} - -static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) -{ - u16 phyctl; - u16 phytxant = wlc_hw->bmac_phytxant; - u16 mask = PHY_TXC_ANT_MASK; - - /* set the Probe Response frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); - - /* set the Response (ACK/CTS) frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); -} - -void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant) -{ - /* update sw state */ - wlc_hw->bmac_phytxant = phytxant; - - /* push to ucode if up */ - if (!wlc_hw->up) - return; - brcms_c_ucode_txant_set(wlc_hw); - -} - -u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw) -{ - return (u16) wlc_hw->wlc->stf->txant; -} - -void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) -{ - wlc_hw->antsel_type = antsel_type; - - /* Update the antsel type for phy module to use */ - wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); -} - -void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) -{ - bool fatal = false; - uint unit; - uint intstatus, idx; - d11regs_t *regs = wlc_hw->regs; - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - - unit = wlc_hw->unit; - - for (idx = 0; idx < NFIFO; idx++) { - /* read intstatus register and ignore any non-error bits */ - intstatus = - R_REG(®s->intctrlregs[idx].intstatus) & I_ERRORS; - if (!intstatus) - continue; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: intstatus%d 0x%x\n", - unit, idx, intstatus); - - if (intstatus & I_RO) { - wiphy_err(wiphy, "wl%d: fifo %d: receive fifo " - "overflow\n", unit, idx); - fatal = true; - } - - if (intstatus & I_PC) { - wiphy_err(wiphy, "wl%d: fifo %d: descriptor error\n", - unit, idx); - fatal = true; - } - - if (intstatus & I_PD) { - wiphy_err(wiphy, "wl%d: fifo %d: data error\n", unit, - idx); - fatal = true; - } - - if (intstatus & I_DE) { - wiphy_err(wiphy, "wl%d: fifo %d: descriptor protocol " - "error\n", unit, idx); - fatal = true; - } - - if (intstatus & I_RU) { - wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor " - "underflow\n", idx, unit); - } - - if (intstatus & I_XU) { - wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo " - "underflow\n", idx, unit); - fatal = true; - } - - if (fatal) { - brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ - break; - } else - W_REG(®s->intctrlregs[idx].intstatus, - intstatus); - } -} - -void brcms_c_intrson(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - wlc->macintmask = wlc->defmacintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); -} - -/* callback for siutils.c, which has only wlc handler, no wl - * they both check up, not only because there is no need to off/restore d11 interrupt - * but also because per-port code may require sync with valid interrupt. - */ - -static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc) -{ - if (!wlc->hw->up) - return 0; - - return brcms_intrsoff(wlc->wl); -} - -static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask) -{ - if (!wlc->hw->up) - return; - - brcms_intrsrestore(wlc->wl, macintmask); -} - -u32 brcms_c_intrsoff(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintmask; - - if (!wlc_hw->clk) - return 0; - - macintmask = wlc->macintmask; /* isr can still happen */ - - W_REG(&wlc_hw->regs->macintmask, 0); - (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ - udelay(1); /* ensure int line is no longer driven */ - wlc->macintmask = 0; - - /* return previous macintmask; resolve race between us and our isr */ - return wlc->macintstatus ? 0 : macintmask; -} - -void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - if (!wlc_hw->clk) - return; - - wlc->macintmask = macintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); -} - -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, mbool flags) -{ - u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; - - if (on) { - /* suspend tx fifos */ - brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_BK_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_VI_FIFO); - - /* zero the address match register so we do not send ACKs */ - brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - null_ether_addr); - } else { - /* resume tx fifos */ - if (!wlc_hw->wlc->tx_suspended) { - brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); - } - brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); - brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); - brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); - - /* Restore address */ - brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - wlc_hw->etheraddr); - } - - wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); - - if (on) - brcms_c_ucode_mute_override_set(wlc_hw); - else - brcms_c_ucode_mute_override_clear(wlc_hw); -} - -int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks) -{ - if (fifo >= NFIFO) - return -EINVAL; - - *blocks = wlc_hw->xmtfifo_sz[fifo]; - - return 0; -} - -/* brcms_b_tx_fifo_suspended: - * Check the MAC's tx suspend status for a tx fifo. - * - * When the MAC acknowledges a tx suspend, it indicates that no more - * packets will be transmitted out the radio. This is independent of - * DMA channel suspension---the DMA may have finished suspending, or may still - * be pulling data into a tx fifo, by the time the MAC acks the suspend - * request. - */ -static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* check that a suspend has been requested and is no longer pending */ - - /* - * for DMA mode, the suspend request is set in xmtcontrol of the DMA engine, - * and the tx fifo suspend at the lower end of the MAC is acknowledged in the - * chnstatus register. - * The tx fifo suspend completion is independent of the DMA suspend completion and - * may be acked before or after the DMA is suspended. - */ - if (dma_txsuspended(wlc_hw->di[tx_fifo]) && - (R_REG(&wlc_hw->regs->chnstatus) & - (1 << tx_fifo)) == 0) - return true; - - return false; -} - -static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - u8 fifo = 1 << tx_fifo; - - /* Two clients of this code, 11h Quiet period and scanning. */ - - /* only suspend if not already suspended */ - if ((wlc_hw->suspended_fifos & fifo) == fifo) - return; - - /* force the core awake only if not already */ - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_set(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - - wlc_hw->suspended_fifos |= fifo; - - if (wlc_hw->di[tx_fifo]) { - /* Suspending AMPDU transmissions in the middle can cause underflow - * which may result in mismatch between ucode and driver - * so suspend the mac before suspending the FIFO - */ - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - - dma_txsuspend(wlc_hw->di[tx_fifo]); - - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_enable_mac(wlc_hw->wlc); - } -} - -static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case - * but need to be done here for PIO otherwise the watchdog will catch - * the inconsistency and fire - */ - /* Two clients of this code, 11h Quiet period and scanning. */ - if (wlc_hw->di[tx_fifo]) - dma_txresume(wlc_hw->di[tx_fifo]); - - /* allow core to sleep again */ - if (wlc_hw->suspended_fifos == 0) - return; - else { - wlc_hw->suspended_fifos &= ~(1 << tx_fifo); - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_clear(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - } -} - -/* - * Read and clear macintmask and macintstatus and intstatus registers. - * This routine should be called with interrupts off - * Return: - * -1 if DEVICEREMOVED(wlc) evaluates to true; - * 0 if the interrupt is not for us, or we are in some special cases; - * device interrupt status bits otherwise. - */ -static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; - u32 macintstatus; - - /* macintstatus includes a DMA interrupt summary bit */ - macintstatus = R_REG(®s->macintstatus); - - BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, - macintstatus); - - /* detect cardbus removed, in power down(suspend) and in reset */ - if (DEVICEREMOVED(wlc)) - return -1; - - /* DEVICEREMOVED succeeds even when the core is still resetting, - * handle that case here. - */ - if (macintstatus == 0xffffffff) - return 0; - - /* defer unsolicited interrupts */ - macintstatus &= (in_isr ? wlc->macintmask : wlc->defmacintmask); - - /* if not for us */ - if (macintstatus == 0) - return 0; - - /* interrupts are already turned off for CFE build - * Caution: For CFE Turning off the interrupts again has some undesired - * consequences - */ - /* turn off the interrupts */ - W_REG(®s->macintmask, 0); - (void)R_REG(®s->macintmask); /* sync readback */ - wlc->macintmask = 0; - - /* clear device interrupts */ - W_REG(®s->macintstatus, macintstatus); - - /* MI_DMAINT is indication of non-zero intstatus */ - if (macintstatus & MI_DMAINT) { - /* - * only fifo interrupt enabled is I_RI in - * RX_FIFO. If MI_DMAINT is set, assume it - * is set and clear the interrupt. - */ - W_REG(®s->intctrlregs[RX_FIFO].intstatus, - DEF_RXINTMASK); - } - - return macintstatus; -} - -/* Update wlc->macintstatus and wlc->intstatus[]. */ -/* Return true if they are updated successfully. false otherwise */ -bool brcms_c_intrsupd(struct brcms_c_info *wlc) -{ - u32 macintstatus; - - /* read and clear macintstatus and intstatus registers */ - macintstatus = wlc_intstatus(wlc, false); - - /* device is removed */ - if (macintstatus == 0xffffffff) - return false; - - /* update interrupt status in software */ - wlc->macintstatus |= macintstatus; - - return true; -} - -/* - * First-level interrupt processing. - * Return true if this was our interrupt, false otherwise. - * *wantdpc will be set to true if further brcms_c_dpc() processing is required, - * false otherwise. - */ -bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintstatus; - - *wantdpc = false; - - if (!wlc_hw->up || !wlc->macintmask) - return false; - - /* read and clear macintstatus and intstatus registers */ - macintstatus = wlc_intstatus(wlc, true); - - if (macintstatus == 0xffffffff) - wiphy_err(wlc->wiphy, "DEVICEREMOVED detected in the ISR code" - " path\n"); - - /* it is not for us */ - if (macintstatus == 0) - return false; - - *wantdpc = true; - - /* save interrupt status bits */ - wlc->macintstatus = macintstatus; - - return true; - -} - -static bool -brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, - u32 s2) -{ - /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent - * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts - * transmission count) - */ - if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) { - return false; - } - - return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); -} - -/* process tx completion events in BMAC - * Return true if more tx status need to be processed. false otherwise. - */ -static bool -brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) -{ - bool morepending = false; - struct brcms_c_info *wlc = wlc_hw->wlc; - d11regs_t *regs; - struct tx_status txstatus, *txs; - u32 s1, s2; - uint n = 0; - /* - * Param 'max_tx_num' indicates max. # tx status to process before - * break out. - */ - uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - txs = &txstatus; - regs = wlc_hw->regs; - while (!(*fatal) - && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { - - if (s1 == 0xffffffff) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", - wlc_hw->unit, __func__); - return morepending; - } - - s2 = R_REG(®s->frmtxstatus2); - - txs->status = s1 & TXS_STATUS_MASK; - txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; - txs->sequence = s2 & TXS_SEQ_MASK; - txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; - txs->lasttxtime = 0; - - *fatal = brcms_b_dotxstatus(wlc_hw, txs, s2); - - /* !give others some time to run! */ - if (++n >= max_tx_num) - break; - } - - if (*fatal) - return 0; - - if (n >= max_tx_num) - morepending = true; - - if (!pktq_empty(&wlc->pkt_queue->q)) - brcms_c_send_q(wlc); - - return morepending; -} - -void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; - u32 mc, mi; - struct wiphy *wiphy = wlc->wiphy; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc_hw->band->bandunit); - - /* - * Track overlapping suspend requests - */ - wlc_hw->mac_suspend_depth++; - if (wlc_hw->mac_suspend_depth > 1) - return; - - /* force the core awake */ - brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - - mc = R_REG(®s->maccontrol); - - if (mc == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_PSM_RUN)); - WARN_ON(!(mc & MCTL_EN_MAC)); - - mi = R_REG(®s->macintstatus); - if (mi == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mi & MI_MACSSPNDD); - - brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); - - SPINWAIT(!(R_REG(®s->macintstatus) & MI_MACSSPNDD), - BRCMS_MAX_MAC_SUSPEND); - - if (!(R_REG(®s->macintstatus) & MI_MACSSPNDD)) { - wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" - " and MI_MACSSPNDD is still not on.\n", - wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); - wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " - "psm_brc 0x%04x\n", wlc_hw->unit, - R_REG(®s->psmdebug), - R_REG(®s->phydebug), - R_REG(®s->psm_brc)); - } - - mc = R_REG(®s->maccontrol); - if (mc == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_PSM_RUN)); - WARN_ON(mc & MCTL_EN_MAC); -} - -void brcms_c_enable_mac(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; - u32 mc, mi; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc->band->bandunit); - - /* - * Track overlapping suspend requests - */ - wlc_hw->mac_suspend_depth--; - if (wlc_hw->mac_suspend_depth > 0) - return; - - mc = R_REG(®s->maccontrol); - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(mc & MCTL_EN_MAC); - WARN_ON(!(mc & MCTL_PSM_RUN)); - - brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); - W_REG(®s->macintstatus, MI_MACSSPNDD); - - mc = R_REG(®s->maccontrol); - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_EN_MAC)); - WARN_ON(!(mc & MCTL_PSM_RUN)); - - mi = R_REG(®s->macintstatus); - WARN_ON(mi & MI_MACSSPNDD); - - brcms_c_ucode_wake_override_clear(wlc_hw, - BRCMS_WAKE_OVERRIDE_MACSUSPEND); -} - -static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) -{ - u8 rate; - u8 rates[8] = { - BRCM_RATE_6M, BRCM_RATE_9M, BRCM_RATE_12M, BRCM_RATE_18M, - BRCM_RATE_24M, BRCM_RATE_36M, BRCM_RATE_48M, BRCM_RATE_54M - }; - u16 entry_ptr; - u16 pctl1; - uint i; - - if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) - return; - - /* walk the phy rate table and update the entries */ - for (i = 0; i < ARRAY_SIZE(rates); i++) { - rate = rates[i]; - - entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); - - /* read the SHM Rate Table entry OFDM PCTL1 values */ - pctl1 = - brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); - - /* modify the value */ - pctl1 &= ~PHY_TXC1_MODE_MASK; - pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); - - /* Update the SHM Rate Table entry OFDM PCTL1 values */ - brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, - pctl1); - } -} - -static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, - u8 rate) -{ - uint i; - u8 plcp_rate = 0; - struct plcp_signal_rate_lookup { - u8 rate; - u8 signal_rate; - }; - /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ - const struct plcp_signal_rate_lookup rate_lookup[] = { - {BRCM_RATE_6M, 0xB}, - {BRCM_RATE_9M, 0xF}, - {BRCM_RATE_12M, 0xA}, - {BRCM_RATE_18M, 0xE}, - {BRCM_RATE_24M, 0x9}, - {BRCM_RATE_36M, 0xD}, - {BRCM_RATE_48M, 0x8}, - {BRCM_RATE_54M, 0xC} - }; - - for (i = 0; i < ARRAY_SIZE(rate_lookup); i++) { - if (rate == rate_lookup[i].rate) { - plcp_rate = rate_lookup[i].signal_rate; - break; - } - } - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); -} - -void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) -{ - wlc_hw->hw_stf_ss_opmode = stf_mode; - - if (wlc_hw->clk) - brcms_upd_ofdm_pctl1_table(wlc_hw); -} - -void -brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, - u32 *tsf_h_ptr) -{ - d11regs_t *regs = wlc_hw->regs; - - /* read the tsf timer low, then high to get an atomic read */ - *tsf_l_ptr = R_REG(®s->tsf_timerlow); - *tsf_h_ptr = R_REG(®s->tsf_timerhigh); - - return; -} - -static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) -{ - d11regs_t *regs; - u32 w, val; - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - - BCMMSG(wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - - /* Validate dchip register access */ - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - w = R_REG(®s->objdata); - - /* Can we write and read back a 32bit register? */ - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0xaa5555aa); - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); - if (val != (u32) 0xaa5555aa) { - wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " - "expected 0xaa5555aa\n", wlc_hw->unit, val); - return false; - } - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0x55aaaa55); - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); - if (val != (u32) 0x55aaaa55) { - wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " - "expected 0x55aaaa55\n", wlc_hw->unit, val); - return false; - } - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, w); - - /* clear CFPStart */ - W_REG(®s->tsf_cfpstart, 0); - - w = R_REG(®s->maccontrol); - if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && - (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { - wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = " - "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, - (MCTL_IHR_EN | MCTL_WAKE), - (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE)); - return false; - } - - return true; -} - -#define PHYPLL_WAIT_US 100000 - -void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) -{ - d11regs_t *regs; - u32 tmp; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - tmp = 0; - regs = wlc_hw->regs; - - if (on) { - if ((wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | - CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & - (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), - PHYPLL_WAIT_US); - - tmp = R_REG(®s->clk_ctl_st); - if ((tmp & (CCS_ERSRC_AVAIL_HT)) != - (CCS_ERSRC_AVAIL_HT)) { - wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" - " PLL failed\n", __func__); - } - } else { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & - (CCS_ERSRC_AVAIL_D11PLL | - CCS_ERSRC_AVAIL_PHYPLL)) != - (CCS_ERSRC_AVAIL_D11PLL | - CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); - - tmp = R_REG(®s->clk_ctl_st); - if ((tmp & - (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) - != - (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) { - wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on " - "PHY PLL failed\n", __func__); - } - } - } else { - /* Since the PLL may be shared, other cores can still be requesting it; - * so we'll deassert the request but not wait for status to comply. - */ - AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); - tmp = R_REG(®s->clk_ctl_st); - } -} - -void brcms_c_coredisable(struct brcms_hardware *wlc_hw) -{ - bool dev_gone; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - dev_gone = DEVICEREMOVED(wlc_hw->wlc); - - if (dev_gone) - return; - - if (wlc_hw->noreset) - return; - - /* radio off */ - wlc_phy_switch_radio(wlc_hw->band->pi, OFF); - - /* turn off analog core */ - wlc_phy_anacore(wlc_hw->band->pi, OFF); - - /* turn off PHYPLL to save power */ - brcms_b_core_phypll_ctl(wlc_hw, false); - - /* No need to set wlc->pub->radio_active = OFF - * because this function needs down capability and - * radio_active is designed for BCMNODOWN. - */ - - /* remove gpio controls */ - if (wlc_hw->ucode_dbgsel) - ai_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY); - - wlc_hw->clk = false; - ai_core_disable(wlc_hw->sih, 0); - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); -} - -/* power both the pll and external oscillator on/off */ -static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); - - /* dont power down if plldown is false or we must poll hw radio disable */ - if (!want && wlc_hw->pllreq) - return; - - if (wlc_hw->sih) - ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want); - - wlc_hw->sbclk = want; - if (!wlc_hw->sbclk) { - wlc_hw->clk = false; - if (wlc_hw->band && wlc_hw->band->pi) - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - } -} - -static void brcms_c_flushqueues(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - uint i; - - wlc->txpend16165war = 0; - - /* free any posted tx packets */ - for (i = 0; i < NFIFO; i++) - if (wlc_hw->di[i]) { - dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); - TXPKTPENDCLR(wlc, i); - BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); - } - - /* free any posted rx packets */ - dma_rxreclaim(wlc_hw->di[RX_FIFO]); -} - -u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) -{ - return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); -} - -void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) -{ - brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); -} - -static u16 -brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) -{ - d11regs_t *regs = wlc_hw->regs; - volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; - volatile u16 *objdata_hi = objdata_lo + 1; - u16 v; - - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); - if (offset & 2) { - v = R_REG(objdata_hi); - } else { - v = R_REG(objdata_lo); - } - - return v; -} - -static void -brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, - u32 sel) -{ - d11regs_t *regs = wlc_hw->regs; - volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; - volatile u16 *objdata_hi = objdata_lo + 1; - - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); - if (offset & 2) { - W_REG(objdata_hi, v); - } else { - W_REG(objdata_lo, v); - } -} - -/* Copy a buffer to shared memory of specified type . - * SHM 'offset' needs to be an even address and - * Buffer length 'len' must be an even number of bytes - * 'sel' selects the type of memory - */ -void -brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset, - const void *buf, int len, u32 sel) -{ - u16 v; - const u8 *p = (const u8 *)buf; - int i; - - if (len <= 0 || (offset & 1) || (len & 1)) - return; - - for (i = 0; i < len; i += 2) { - v = p[i] | (p[i + 1] << 8); - brcms_b_write_objmem(wlc_hw, offset + i, v, sel); - } -} - -/* Copy a piece of shared memory of specified type to a buffer . - * SHM 'offset' needs to be an even address and - * Buffer length 'len' must be an even number of bytes - * 'sel' selects the type of memory - */ -void -brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, - int len, u32 sel) -{ - u16 v; - u8 *p = (u8 *) buf; - int i; - - if (len <= 0 || (offset & 1) || (len & 1)) - return; - - for (i = 0; i < len; i += 2) { - v = brcms_b_read_objmem(wlc_hw, offset + i, sel); - p[i] = v & 0xFF; - p[i + 1] = (v >> 8) & 0xFF; - } -} - -void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, - uint *len) -{ - BCMMSG(wlc_hw->wlc->wiphy, "nvram vars totlen=%d\n", - wlc_hw->vars_size); - - *buf = wlc_hw->vars; - *len = wlc_hw->vars_size; -} - -void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) -{ - wlc_hw->SRL = SRL; - wlc_hw->LRL = LRL; - - /* write retry limit to SCR, shouldn't need to suspend */ - if (wlc_hw->up) { - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); - } -} - -void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, mbool req_bit) -{ - if (set) { - if (mboolisset(wlc_hw->pllreq, req_bit)) - return; - - mboolset(wlc_hw->pllreq, req_bit); - - if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (!wlc_hw->sbclk) { - brcms_b_xtal(wlc_hw, ON); - } - } - } else { - if (!mboolisset(wlc_hw->pllreq, req_bit)) - return; - - mboolclr(wlc_hw->pllreq, req_bit); - - if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (wlc_hw->sbclk) { - brcms_b_xtal(wlc_hw, OFF); - } - } - } - - return; -} - -u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) -{ - u16 table_ptr; - u8 phy_rate, index; - - /* get the phy specific rate encoding for the PLCP SIGNAL field */ - if (IS_OFDM(rate)) - table_ptr = M_RT_DIRMAP_A; - else - table_ptr = M_RT_DIRMAP_B; - - /* for a given rate, the LS-nibble of the PLCP SIGNAL field is - * the index into the rate table. - */ - phy_rate = rate_info[rate] & BRCMS_RATE_MASK; - index = phy_rate & 0xf; - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); -} - -void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) -{ - wlc_hw->antsel_avail = antsel_avail; -} diff --git a/drivers/staging/brcm80211/brcmsmac/bmac.h b/drivers/staging/brcm80211/brcmsmac/bmac.h deleted file mode 100644 index 3c9ad4f3bd2..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/bmac.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#ifndef _BRCM_BOTTOM_MAC_H_ -#define _BRCM_BOTTOM_MAC_H_ - -#include -#include "types.h" - -/* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) - driver */ -struct brcms_b_state { - u32 machwcap; /* mac hw capibility */ - u32 preamble_ovr; /* preamble override */ -}; - -enum { - IOV_BMAC_DIAG, - IOV_BMAC_SBGPIOTIMERVAL, - IOV_BMAC_SBGPIOOUT, - IOV_BMAC_CCGPIOCTRL, /* CC GPIOCTRL REG */ - IOV_BMAC_CCGPIOOUT, /* CC GPIOOUT REG */ - IOV_BMAC_CCGPIOOUTEN, /* CC GPIOOUTEN REG */ - IOV_BMAC_CCGPIOIN, /* CC GPIOIN REG */ - IOV_BMAC_WPSGPIO, /* WPS push button GPIO pin */ - IOV_BMAC_OTPDUMP, - IOV_BMAC_OTPSTAT, - IOV_BMAC_PCIEASPM, /* obfuscation clkreq/aspm control */ - IOV_BMAC_PCIEADVCORRMASK, /* advanced correctable error mask */ - IOV_BMAC_PCIECLKREQ, /* PCIE 1.1 clockreq enab support */ - IOV_BMAC_PCIELCREG, /* PCIE LCREG */ - IOV_BMAC_SBGPIOTIMERMASK, - IOV_BMAC_RFDISABLEDLY, - IOV_BMAC_PCIEREG, /* PCIE REG */ - IOV_BMAC_PCICFGREG, /* PCI Config register */ - IOV_BMAC_PCIESERDESREG, /* PCIE SERDES REG (dev, 0}offset) */ - IOV_BMAC_PCIEGPIOOUT, /* PCIEOUT REG */ - IOV_BMAC_PCIEGPIOOUTEN, /* PCIEOUTEN REG */ - IOV_BMAC_PCIECLKREQENCTRL, /* clkreqenctrl REG (PCIE REV > 6.0 */ - IOV_BMAC_DMALPBK, - IOV_BMAC_CCREG, - IOV_BMAC_COREREG, - IOV_BMAC_SDCIS, - IOV_BMAC_SDIO_DRIVE, - IOV_BMAC_OTPW, - IOV_BMAC_NVOTPW, - IOV_BMAC_SROM, - IOV_BMAC_SRCRC, - IOV_BMAC_CIS_SOURCE, - IOV_BMAC_CISVAR, - IOV_BMAC_OTPLOCK, - IOV_BMAC_OTP_CHIPID, - IOV_BMAC_CUSTOMVAR1, - IOV_BMAC_BOARDFLAGS, - IOV_BMAC_BOARDFLAGS2, - IOV_BMAC_WPSLED, - IOV_BMAC_NVRAM_SOURCE, - IOV_BMAC_OTP_RAW_READ, - IOV_BMAC_LAST -}; - -extern int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, uint bustype, - void *btparam); -extern int brcms_b_detach(struct brcms_c_info *wlc); -extern void brcms_b_watchdog(void *arg); - -/* up/down, reset, clk */ -extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, - uint offset, const void *buf, int len, - u32 sel); -extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, - void *buf, int len, u32 sel); -#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ - brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) -#define brcms_b_copyto_shm(wlc_hw, offset, buf, len) \ - brcms_b_copyto_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) - -extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw); -extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on); -extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk); -extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk); -extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw); -extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags); -extern void brcms_b_reset(struct brcms_hardware *wlc_hw); -extern void brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute); -extern int brcms_b_up_prep(struct brcms_hardware *wlc_hw); -extern int brcms_b_up_finish(struct brcms_hardware *wlc_hw); -extern int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw); -extern int brcms_b_down_finish(struct brcms_hardware *wlc_hw); -extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode); - -/* chanspec, ucode interface */ -extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, - chanspec_t chanspec, - bool mute, struct txpwr_limits *txpwr); - -extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks); -extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, - u16 val, int bands); -extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val); -extern u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands); -extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant); -extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw); -extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, - u8 antsel_type); -extern int brcms_b_state_get(struct brcms_hardware *wlc_hw, - struct brcms_b_state *state); -extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, - u16 v); -extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset); -extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, - int offset, int len, void *buf); -extern void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, - uint *len); - -extern void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, - u8 *ea); - -extern bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw); -extern void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, - bool shortslot); -extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, - u8 stf_mode); - -extern void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw); - -extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, - u32 override_bit); -extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, - u32 override_bit); - -extern void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, - int match_reg_offset, - const u8 *addr); -extern void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, - void *bcn, int len, bool both); - -extern void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, - u32 *tsf_h_ptr); -extern void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin); -extern void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax); - -extern void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, - u16 LRL); - -extern void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); - - -/* API for BMAC driver (e.g. wlc_phy.c etc) */ - -extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw); -extern void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, - mbool req_bit); -extern void brcms_b_hw_up(struct brcms_hardware *wlc_hw); -extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate); -extern void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, - u32 antsel_avail); - -#endif /* _BRCM_BOTTOM_MAC_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index f59693e1d8a..eb61713125b 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -20,7 +20,6 @@ #include #include "pub.h" #include "phy/phy_hal.h" -#include "bmac.h" #include "main.h" #include "stf.h" #include "channel.h" diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 1763c4535cd..8399bf308eb 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -16,21 +16,22 @@ #include #include - #include #include +#include #include "rate.h" #include "scb.h" #include "phy/phy_hal.h" #include "channel.h" -#include "bmac.h" #include "antsel.h" #include "stf.h" #include "ampdu.h" #include "alloc.h" #include "mac80211_if.h" +#include "ucode_loader.h" #include "main.h" + /* * WPA(2) definitions */ @@ -173,14 +174,6 @@ #define BRCMS_WAR16165(wlc) (wlc->pub->sih->bustype == PCI_BUS && \ (!AP_ENAB(wlc->pub)) && (wlc->war16165)) -/* debug/trace */ -uint brcm_msg_level = -#if defined(BCMDBG) - LOG_ERROR_VAL; -#else - 0; -#endif /* BCMDBG */ - /* Find basic rate for a given rate */ #define BRCMS_BASIC_RATE(wlc, rspec) (IS_MCS(rspec) ? \ (wlc)->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK].leg_ofdm] : \ @@ -196,22 +189,6 @@ uint brcm_msg_level = #define EPI_VERSION_NUM 0x054b0b00 -#ifdef BCMDBG -/* pointer to most recently allocated wl/wlc */ -static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); -#endif - -const u8 prio2fifo[NUMPRIO] = { - TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ - TX_AC_BK_FIFO, /* 1 BK AC_BK Background */ - TX_AC_BK_FIFO, /* 2 -- AC_BK Background */ - TX_AC_BE_FIFO, /* 3 EE AC_BE Best Effort */ - TX_AC_VI_FIFO, /* 4 CL AC_VI Video */ - TX_AC_VI_FIFO, /* 5 VI AC_VI Video */ - TX_AC_VO_FIFO, /* 6 VO AC_VO Voice */ - TX_AC_VO_FIFO /* 7 NC AC_VO Voice */ -}; - /* precedences numbers for wlc queues. These are twice as may levels as * 802.1D priorities. * Odd numbers are used for HI priority traffic at same precedence levels @@ -238,17 +215,35 @@ const u8 prio2fifo[NUMPRIO] = { #define MBSS_PRB_ENAB(cfg) 0 #define SOFTBCN_ENAB(pub) (0) -/* 802.1D Priority to precedence queue mapping */ -const u8 wlc_prio2prec_map[] = { - _BRCMS_PREC_BE, /* 0 BE - Best-effort */ - _BRCMS_PREC_BK, /* 1 BK - Background */ - _BRCMS_PREC_NONE, /* 2 None = - */ - _BRCMS_PREC_EE, /* 3 EE - Excellent-effort */ - _BRCMS_PREC_CL, /* 4 CL - Controlled Load */ - _BRCMS_PREC_VI, /* 5 Vi - Video */ - _BRCMS_PREC_VO, /* 6 Vo - Voice */ - _BRCMS_PREC_NC, /* 7 NC - Network Control */ -}; +#define TIMER_INTERVAL_WATCHDOG_BMAC 1000 /* watchdog timer, in unit of ms */ + +#define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ +#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us, default */ +#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us, default */ +#define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ + +#define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ + +#define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ + +#define DMAREG(wlc_hw, direction, fifonum) \ + ((direction == DMA_TX) ? \ + (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ + (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) + +#define APHY_SLOT_TIME 9 +#define BPHY_SLOT_TIME 20 + +/* + * The following table lists the buffer memory allocated to xmt fifos in HW. + * the size is in units of 256bytes(one block), total size is HW dependent + * ucode has default fifo partition, sw can overwrite if necessary + * + * This is documented in twiki under the topic UcodeTxFifo. Please ensure + * the twiki is updated before making changes. + */ + +#define XMTFIFOTBL_STARTREV 20 /* Starting corerev for the fifo size table */ /* Check if a particular BSS config is AP or STA */ #define BSSCFG_AP(cfg) (0) @@ -260,36 +255,154 @@ const u8 wlc_prio2prec_map[] = { for (idx = 0; (int) idx < BRCMS_MAXBSSCFG; idx++) \ if ((cfg = (wlc)->bsscfg[idx])) -/* TX FIFO number to WME/802.1E Access Category */ -const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; - -/* WME/802.1E Access Category to TX FIFO number */ -static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; - -static bool in_send_q; - /* Shared memory location index for various AC params */ #define wme_shmemacindex(ac) wme_ac2fifo[ac] -#ifdef BCMDBG -static const char * const fifo_names[] = { - "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; -#else -static const char fifo_names[6][0]; -#endif - -static const u8 acbitmap2maxprio[] = { - PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, - PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO -}; - /* currently the best mechanism for determining SIFS is the band in use */ #define SIFS(band) ((band)->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : \ BPHY_SIFS_TIME); +/* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) + driver */ +struct brcms_b_state { + u32 machwcap; /* mac hw capibility */ + u32 preamble_ovr; /* preamble override */ +}; + /* local prototypes */ +static void brcms_b_clkctl_clk(struct brcms_hardware *wlc, uint mode); +static void brcms_b_coreinit(struct brcms_c_info *wlc); + +/* used by wlc_wakeucode_init() */ +static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, + const struct d11init *inits); +static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], + const uint nbytes); +static void brcms_ucode_download(struct brcms_hardware *wlc); +static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw); + +/* used by brcms_c_dpc() */ +static bool brcms_b_dotxstatus(struct brcms_hardware *wlc, + struct tx_status *txs, u32 s2); +static bool brcms_b_txstatus(struct brcms_hardware *wlc, bool bound, + bool *fatal); +static bool brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound); + +/* used by brcms_c_down() */ +static void brcms_c_flushqueues(struct brcms_c_info *wlc); + +static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs); +static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw); +static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw); +static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, + uint tx_fifo); +static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, + uint tx_fifo); +static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, + uint tx_fifo); + +/* Low Level Prototypes */ + +struct brcms_b_state; + +extern int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, + uint unit, bool piomode, void *regsva, uint bustype, + void *btparam); +extern int brcms_b_detach(struct brcms_c_info *wlc); +extern void brcms_b_watchdog(void *arg); + +/* up/down, reset, clk */ +extern void brcms_b_reset(struct brcms_hardware *wlc_hw); +extern void brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, + bool mute); +extern int brcms_b_up_prep(struct brcms_hardware *wlc_hw); +extern int brcms_b_up_finish(struct brcms_hardware *wlc_hw); +extern int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw); +extern int brcms_b_down_finish(struct brcms_hardware *wlc_hw); + +extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, + uint *blocks); +extern u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands); +extern int brcms_b_state_get(struct brcms_hardware *wlc_hw, + struct brcms_b_state *state); +extern void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, + uint *len); + +extern void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, + u8 *ea); + +extern bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw); +extern void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, + bool shortslot); + +extern void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw); + +extern void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, + int match_reg_offset, + const u8 *addr); +extern void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, + void *bcn, int len, bool both); + +extern void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, + u32 *tsf_h_ptr); +extern void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin); +extern void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax); + +extern void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, + u16 LRL); + +extern void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); + + +/* API for BMAC driver (e.g. wlc_phy.c etc) */ + +extern void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, + mbool req_bit); +extern void brcms_b_hw_up(struct brcms_hardware *wlc_hw); +extern void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, + u32 antsel_avail); + + + + +static int brcms_b_bandtype(struct brcms_hardware *wlc_hw); +static void brcms_b_info_init(struct brcms_hardware *wlc_hw); +static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want); +static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, + u32 sel); +static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, + u16 v, u32 sel); +static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk); +static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme); +static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw); +static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw); +static bool brcms_c_validboardtype(struct brcms_hardware *wlc); +static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw); +static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw); +static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw); +static void brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init); +static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw); +static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool want, + mbool flags); +static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw); +static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw); +static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc); +static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask); +static void brcms_c_gpio_init(struct brcms_c_info *wlc); +static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, + void *bcn, int len); +static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, + void *bcn, int len); +static void brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec); +static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit); +static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, + chanspec_t chanspec); +static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, + bool shortslot); +static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw); +static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, + u8 rate); + static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct sk_buff *p, @@ -367,6 +480,3520 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc); static int _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, struct brcms_c_if *wlcif); +const u8 prio2fifo[NUMPRIO] = { + TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ + TX_AC_BK_FIFO, /* 1 BK AC_BK Background */ + TX_AC_BK_FIFO, /* 2 -- AC_BK Background */ + TX_AC_BE_FIFO, /* 3 EE AC_BE Best Effort */ + TX_AC_VI_FIFO, /* 4 CL AC_VI Video */ + TX_AC_VI_FIFO, /* 5 VI AC_VI Video */ + TX_AC_VO_FIFO, /* 6 VO AC_VO Voice */ + TX_AC_VO_FIFO /* 7 NC AC_VO Voice */ +}; + +/* debug/trace */ +uint brcm_msg_level = +#if defined(BCMDBG) + LOG_ERROR_VAL; +#else + 0; +#endif /* BCMDBG */ + +/* TX FIFO number to WME/802.1E Access Category */ +const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; + +/* WME/802.1E Access Category to TX FIFO number */ +static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; + +static bool in_send_q; + +/* 802.1D Priority to precedence queue mapping */ +const u8 wlc_prio2prec_map[] = { + _BRCMS_PREC_BE, /* 0 BE - Best-effort */ + _BRCMS_PREC_BK, /* 1 BK - Background */ + _BRCMS_PREC_NONE, /* 2 None = - */ + _BRCMS_PREC_EE, /* 3 EE - Excellent-effort */ + _BRCMS_PREC_CL, /* 4 CL - Controlled Load */ + _BRCMS_PREC_VI, /* 5 Vi - Video */ + _BRCMS_PREC_VO, /* 6 Vo - Voice */ + _BRCMS_PREC_NC, /* 7 NC - Network Control */ +}; + +static u16 xmtfifo_sz[][NFIFO] = { + {20, 192, 192, 21, 17, 5}, /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ + {9, 58, 22, 14, 14, 5}, /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ + {20, 192, 192, 21, 17, 5}, /* corerev 22: 5120, 49152, 49152, 5376, 4352, 1280 */ + {20, 192, 192, 21, 17, 5}, /* corerev 23: 5120, 49152, 49152, 5376, 4352, 1280 */ + {9, 58, 22, 14, 14, 5}, /* corerev 24: 2304, 14848, 5632, 3584, 3584, 1280 */ +}; + +static const u8 acbitmap2maxprio[] = { + PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, + PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, + PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, + PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO +}; + +#ifdef BCMDBG +static const char * const fifo_names[] = { + "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; +#else +static const char fifo_names[6][0]; +#endif + +#ifdef BCMDBG +/* pointer to most recently allocated wl/wlc */ +static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); +#endif + +/* === Low Level functions === */ + +void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) +{ + wlc_hw->shortslot = shortslot; + + if (BAND_2G(brcms_b_bandtype(wlc_hw)) && wlc_hw->up) { + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + brcms_b_update_slot_timing(wlc_hw, shortslot); + brcms_c_enable_mac(wlc_hw->wlc); + } +} + +/* + * Update the slot timing for standard 11b/g (20us slots) + * or shortslot 11g (9us slots) + * The PSM needs to be suspended for this call. + */ +static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, + bool shortslot) +{ + d11regs_t *regs; + + regs = wlc_hw->regs; + + if (shortslot) { + /* 11g short slot: 11a timing */ + W_REG(®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ + brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); + } else { + /* 11g long slot: 11b timing */ + W_REG(®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ + brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); + } +} + +static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) +{ + struct wiphy *wiphy = wlc_hw->wlc->wiphy; + + /* init microcode host flags */ + brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); + + /* do band-specific ucode IHR, SHM, and SCR inits */ + if (D11REV_IS(wlc_hw->corerev, 23)) { + if (BRCMS_ISNPHY(wlc_hw->band)) { + brcms_c_write_inits(wlc_hw, d11n0bsinitvals16); + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" + " %d\n", __func__, wlc_hw->unit, + wlc_hw->corerev); + } + } else { + if (D11REV_IS(wlc_hw->corerev, 24)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) { + brcms_c_write_inits(wlc_hw, + d11lcn0bsinitvals24); + } else + wiphy_err(wiphy, "%s: wl%d: unsupported phy in" + " core rev %d\n", __func__, + wlc_hw->unit, wlc_hw->corerev); + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", + __func__, wlc_hw->unit, wlc_hw->corerev); + } + } +} + +/* switch to new band but leave it inactive */ +static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + u32 macintmask; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); + + /* disable interrupts */ + macintmask = brcms_intrsoff(wlc->wl); + + /* radio off */ + wlc_phy_switch_radio(wlc_hw->band->pi, OFF); + + brcms_b_core_phy_clk(wlc_hw, OFF); + + brcms_c_setxband(wlc_hw, bandunit); + + return macintmask; +} + +/* Process received frames */ +/* + * Return true if more frames need to be processed. false otherwise. + * Param 'bound' indicates max. # frames to process before break out. + */ +static bool +brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) +{ + struct sk_buff *p; + struct sk_buff *head = NULL; + struct sk_buff *tail = NULL; + uint n = 0; + uint bound_limit = bound ? wlc_hw->wlc->pub->tunables->rxbnd : -1; + struct brcms_d11rxhdr *wlc_rxhdr = NULL; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + /* gather received frames */ + while ((p = dma_rx(wlc_hw->di[fifo]))) { + + if (!tail) + head = tail = p; + else { + tail->prev = p; + tail = p; + } + + /* !give others some time to run! */ + if (++n >= bound_limit) + break; + } + + /* post more rbufs */ + dma_rxfill(wlc_hw->di[fifo]); + + /* process each frame */ + while ((p = head) != NULL) { + head = head->prev; + p->prev = NULL; + + wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; + + /* compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ + wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr); + + brcms_c_recv(wlc_hw->wlc, p); + } + + return n >= bound_limit; +} + +/* second-level interrupt processing + * Return true if another dpc needs to be re-scheduled. false otherwise. + * Param 'bounded' indicates if applicable loops should be bounded. + */ +bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) +{ + u32 macintstatus; + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs = wlc_hw->regs; + bool fatal = false; + struct wiphy *wiphy = wlc->wiphy; + + if (DEVICEREMOVED(wlc)) { + wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, + __func__); + brcms_down(wlc->wl); + return false; + } + + /* grab and clear the saved software intstatus bits */ + macintstatus = wlc->macintstatus; + wlc->macintstatus = 0; + + BCMMSG(wlc->wiphy, "wl%d: macintstatus 0x%x\n", + wlc_hw->unit, macintstatus); + + WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ + + /* BCN template is available */ + /* ZZZ: Use AP_ACTIVE ? */ + if (AP_ENAB(wlc->pub) && (!APSTA_ENAB(wlc->pub)) + && (macintstatus & MI_BCNTPL)) { + brcms_c_update_beacon(wlc); + } + + /* tx status */ + if (macintstatus & MI_TFS) { + if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) + wlc->macintstatus |= MI_TFS; + if (fatal) { + wiphy_err(wiphy, "MI_TFS: fatal\n"); + goto fatal; + } + } + + if (macintstatus & (MI_TBTT | MI_DTIM_TBTT)) + brcms_c_tbtt(wlc); + + /* ATIM window end */ + if (macintstatus & MI_ATIMWINEND) { + BCMMSG(wlc->wiphy, "end of ATIM window\n"); + OR_REG(®s->maccommand, wlc->qvalid); + wlc->qvalid = 0; + } + + /* received data or control frame, MI_DMAINT is indication of RX_FIFO interrupt */ + if (macintstatus & MI_DMAINT) + if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) + wlc->macintstatus |= MI_DMAINT; + + /* TX FIFO suspend/flush completion */ + if (macintstatus & MI_TXSTOP) + brcms_b_tx_fifo_suspended(wlc_hw, TX_DATA_FIFO); + + /* noise sample collected */ + if (macintstatus & MI_BG_NOISE) { + wlc_phy_noise_sample_intr(wlc_hw->band->pi); + } + + if (macintstatus & MI_GP0) { + wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " + "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); + + printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", + __func__, wlc_hw->sih->chip, + wlc_hw->sih->chiprev); + /* big hammer */ + brcms_init(wlc->wl); + } + + /* gptimer timeout */ + if (macintstatus & MI_TO) { + W_REG(®s->gptimer, 0); + } + + if (macintstatus & MI_RFDISABLE) { + BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" + " RF Disable Input\n", wlc_hw->unit); + brcms_rfkill_set_hw_state(wlc->wl); + } + + /* send any enq'd tx packets. Just makes sure to jump start tx */ + if (!pktq_empty(&wlc->pkt_queue->q)) + brcms_c_send_q(wlc); + + /* it isn't done and needs to be resched if macintstatus is non-zero */ + return wlc->macintstatus != 0; + + fatal: + brcms_init(wlc->wl); + return wlc->macintstatus != 0; +} + +/* common low-level watchdog code */ +void brcms_b_watchdog(void *arg) +{ + struct brcms_c_info *wlc = (struct brcms_c_info *) arg; + struct brcms_hardware *wlc_hw = wlc->hw; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return; + + /* increment second count */ + wlc_hw->now++; + + /* Check for FIFO error interrupts */ + brcms_b_fifoerrors(wlc_hw); + + /* make sure RX dma has buffers */ + dma_rxfill(wlc->hw->di[RX_FIFO]); + + wlc_phy_watchdog(wlc_hw->band->pi); +} + +void +brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, + bool mute, struct txpwr_limits *txpwr) +{ + uint bandunit; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); + + wlc_hw->chanspec = chanspec; + + /* Switch bands if necessary */ + if (NBANDS_HW(wlc_hw) > 1) { + bandunit = CHSPEC_BANDUNIT(chanspec); + if (wlc_hw->band->bandunit != bandunit) { + /* brcms_b_setband disables other bandunit, + * use light band switch if not up yet + */ + if (wlc_hw->up) { + wlc_phy_chanspec_radio_set(wlc_hw-> + bandstate[bandunit]-> + pi, chanspec); + brcms_b_setband(wlc_hw, bandunit, chanspec); + } else { + brcms_c_setxband(wlc_hw, bandunit); + } + } + } + + wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); + + if (!wlc_hw->up) { + if (wlc_hw->clk) + wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, + chanspec); + wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); + } else { + wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); + wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); + + /* Update muting of the channel */ + brcms_b_mute(wlc_hw, mute, 0); + } +} + +int brcms_b_state_get(struct brcms_hardware *wlc_hw, + struct brcms_b_state *state) +{ + state->machwcap = wlc_hw->machwcap; + + return 0; +} + +static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) +{ + uint i; + char name[8]; + /* ucode host flag 2 needed for pio mode, independent of band and fifo */ + u16 pio_mhf2 = 0; + struct brcms_hardware *wlc_hw = wlc->hw; + uint unit = wlc_hw->unit; + struct brcms_tunables *tune = wlc->pub->tunables; + struct wiphy *wiphy = wlc->wiphy; + + /* name and offsets for dma_attach */ + snprintf(name, sizeof(name), "wl%d", unit); + + if (wlc_hw->di[0] == 0) { /* Init FIFOs */ + uint addrwidth; + int dma_attach_err = 0; + /* Find out the DMA addressing capability and let OS know + * All the channels within one DMA core have 'common-minimum' same + * capability + */ + addrwidth = + dma_addrwidth(wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 0)); + + if (!wl_alloc_dma_resources(wlc_hw->wlc->wl, addrwidth)) { + wiphy_err(wiphy, "wl%d: wlc_attach: alloc_dma_" + "resources failed\n", unit); + return false; + } + + /* + * FIFO 0 + * TX: TX_AC_BK_FIFO (TX AC Background data packets) + * RX: RX_FIFO (RX data packets) + */ + wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, + (wme ? DMAREG(wlc_hw, DMA_TX, 0) : + NULL), DMAREG(wlc_hw, DMA_RX, 0), + (wme ? tune->ntxd : 0), tune->nrxd, + tune->rxbufsz, -1, tune->nrxbufpost, + BRCMS_HWRXOFF, &brcm_msg_level); + dma_attach_err |= (NULL == wlc_hw->di[0]); + + /* + * FIFO 1 + * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) + * (legacy) TX_DATA_FIFO (TX data packets) + * RX: UNUSED + */ + wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, + DMAREG(wlc_hw, DMA_TX, 1), NULL, + tune->ntxd, 0, 0, -1, 0, 0, + &brcm_msg_level); + dma_attach_err |= (NULL == wlc_hw->di[1]); + + /* + * FIFO 2 + * TX: TX_AC_VI_FIFO (TX AC Video data packets) + * RX: UNUSED + */ + wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, + DMAREG(wlc_hw, DMA_TX, 2), NULL, + tune->ntxd, 0, 0, -1, 0, 0, + &brcm_msg_level); + dma_attach_err |= (NULL == wlc_hw->di[2]); + /* + * FIFO 3 + * TX: TX_AC_VO_FIFO (TX AC Voice data packets) + * (legacy) TX_CTL_FIFO (TX control & mgmt packets) + */ + wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, + DMAREG(wlc_hw, DMA_TX, 3), + NULL, tune->ntxd, 0, 0, -1, + 0, 0, &brcm_msg_level); + dma_attach_err |= (NULL == wlc_hw->di[3]); +/* Cleaner to leave this as if with AP defined */ + + if (dma_attach_err) { + wiphy_err(wiphy, "wl%d: wlc_attach: dma_attach failed" + "\n", unit); + return false; + } + + /* get pointer to dma engine tx flow control variable */ + for (i = 0; i < NFIFO; i++) + if (wlc_hw->di[i]) + wlc_hw->txavail[i] = + (uint *) dma_getvar(wlc_hw->di[i], + "&txavail"); + } + + /* initial ucode host flags */ + brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); + + return true; +} + +static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw) +{ + uint j; + + for (j = 0; j < NFIFO; j++) { + if (wlc_hw->di[j]) { + dma_detach(wlc_hw->di[j]); + wlc_hw->di[j] = NULL; + } + } +} + +/* low level attach + * run backplane attach, init nvram + * run phy attach + * initialize software state for each core and band + * put the whole chip in reset(driver down state), no clock + */ +int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, + bool piomode, void *regsva, uint bustype, void *btparam) +{ + struct brcms_hardware *wlc_hw; + d11regs_t *regs; + char *macaddr = NULL; + char *vars; + uint err = 0; + uint j; + bool wme = false; + struct shared_phy_params sha_params; + struct wiphy *wiphy = wlc->wiphy; + + BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, + device); + + wme = true; + + wlc_hw = wlc->hw; + wlc_hw->wlc = wlc; + wlc_hw->unit = unit; + wlc_hw->band = wlc_hw->bandstate[0]; + wlc_hw->_piomode = piomode; + + /* populate struct brcms_hardware with default values */ + brcms_b_info_init(wlc_hw); + + /* + * Do the hardware portion of the attach. + * Also initialize software state that depends on the particular hardware + * we are running. + */ + wlc_hw->sih = ai_attach(regsva, bustype, btparam, + &wlc_hw->vars, &wlc_hw->vars_size); + if (wlc_hw->sih == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", + unit); + err = 11; + goto fail; + } + vars = wlc_hw->vars; + + /* + * Get vendid/devid nvram overwrites, which could be different + * than those the BIOS recognizes for devices on PCMCIA_BUS, + * SDIO_BUS, and SROMless devices on PCI_BUS. + */ +#ifdef BCMBUSTYPE + bustype = BCMBUSTYPE; +#endif + if (bustype != SI_BUS) { + char *var; + + var = getvar(vars, "vendid"); + if (var) { + vendor = (u16) simple_strtoul(var, NULL, 0); + wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", + vendor); + } + var = getvar(vars, "devid"); + if (var) { + u16 devid = (u16) simple_strtoul(var, NULL, 0); + if (devid != 0xffff) { + device = devid; + wiphy_err(wiphy, "Overriding device id = 0x%x" + "\n", device); + } + } + + /* verify again the device is supported */ + if (!brcms_c_chipmatch(vendor, device)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " + "vendor/device (0x%x/0x%x)\n", + unit, vendor, device); + err = 12; + goto fail; + } + } + + wlc_hw->vendorid = vendor; + wlc_hw->deviceid = device; + + /* set bar0 window to point at D11 core */ + wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + wlc_hw->corerev = ai_corerev(wlc_hw->sih); + + regs = wlc_hw->regs; + + wlc->regs = wlc_hw->regs; + + /* validate chip, chiprev and corerev */ + if (!brcms_c_isgoodchip(wlc_hw)) { + err = 13; + goto fail; + } + + /* initialize power control registers */ + ai_clkctl_init(wlc_hw->sih); + + /* request fastclock and force fastclock for the rest of attach + * bring the d11 core out of reset. + * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk is still false; + * But it will be called again inside wlc_corereset, after d11 is out of reset. + */ + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + if (!brcms_b_validate_chip_access(wlc_hw)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: validate_chip_access " + "failed\n", unit); + err = 14; + goto fail; + } + + /* get the board rev, used just below */ + j = getintvar(vars, "boardrev"); + /* promote srom boardrev of 0xFF to 1 */ + if (j == BOARDREV_PROMOTABLE) + j = BOARDREV_PROMOTED; + wlc_hw->boardrev = (u16) j; + if (!brcms_c_validboardtype(wlc_hw)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " + "board type (0x%x)" " or revision level (0x%x)\n", + unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); + err = 15; + goto fail; + } + wlc_hw->sromrev = (u8) getintvar(vars, "sromrev"); + wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); + wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); + + if (wlc_hw->boardflags & BFL_NOPLLDOWN) + brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); + + if ((wlc_hw->sih->bustype == PCI_BUS) + && (ai_pci_war16165(wlc_hw->sih))) + wlc->war16165 = true; + + /* check device id(srom, nvram etc.) to set bands */ + if (wlc_hw->deviceid == BCM43224_D11N_ID || + wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) { + /* Dualband boards */ + wlc_hw->_nbands = 2; + } else + wlc_hw->_nbands = 1; + + if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->_nbands = 1; + + /* BMAC_NOTE: remove init of pub values when brcms_c_attach() + * unconditionally does the init of these values + */ + wlc->vendorid = wlc_hw->vendorid; + wlc->deviceid = wlc_hw->deviceid; + wlc->pub->sih = wlc_hw->sih; + wlc->pub->corerev = wlc_hw->corerev; + wlc->pub->sromrev = wlc_hw->sromrev; + wlc->pub->boardrev = wlc_hw->boardrev; + wlc->pub->boardflags = wlc_hw->boardflags; + wlc->pub->boardflags2 = wlc_hw->boardflags2; + wlc->pub->_nbands = wlc_hw->_nbands; + + wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); + + if (wlc_hw->physhim == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_shim_attach " + "failed\n", unit); + err = 25; + goto fail; + } + + /* pass all the parameters to wlc_phy_shared_attach in one struct */ + sha_params.sih = wlc_hw->sih; + sha_params.physhim = wlc_hw->physhim; + sha_params.unit = unit; + sha_params.corerev = wlc_hw->corerev; + sha_params.vars = vars; + sha_params.vid = wlc_hw->vendorid; + sha_params.did = wlc_hw->deviceid; + sha_params.chip = wlc_hw->sih->chip; + sha_params.chiprev = wlc_hw->sih->chiprev; + sha_params.chippkg = wlc_hw->sih->chippkg; + sha_params.sromrev = wlc_hw->sromrev; + sha_params.boardtype = wlc_hw->sih->boardtype; + sha_params.boardrev = wlc_hw->boardrev; + sha_params.boardvendor = wlc_hw->sih->boardvendor; + sha_params.boardflags = wlc_hw->boardflags; + sha_params.boardflags2 = wlc_hw->boardflags2; + sha_params.bustype = wlc_hw->sih->bustype; + sha_params.buscorerev = wlc_hw->sih->buscorerev; + + /* alloc and save pointer to shared phy state area */ + wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); + if (!wlc_hw->phy_sh) { + err = 16; + goto fail; + } + + /* initialize software state for each core and band */ + for (j = 0; j < NBANDS_HW(wlc_hw); j++) { + /* + * band0 is always 2.4Ghz + * band1, if present, is 5Ghz + */ + + /* So if this is a single band 11a card, use band 1 */ + if (IS_SINGLEBAND_5G(wlc_hw->deviceid)) + j = BAND_5G_INDEX; + + brcms_c_setxband(wlc_hw, j); + + wlc_hw->band->bandunit = j; + wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; + wlc->band->bandunit = j; + wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; + wlc->core->coreidx = ai_coreidx(wlc_hw->sih); + + wlc_hw->machwcap = R_REG(®s->machwcap); + wlc_hw->machwcap_backup = wlc_hw->machwcap; + + /* init tx fifo size */ + wlc_hw->xmtfifo_sz = + xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; + + /* Get a phy for this band */ + wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, + (void *)regs, brcms_b_bandtype(wlc_hw), vars, + wlc->wiphy); + if (wlc_hw->band->pi == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" + "attach failed\n", unit); + err = 17; + goto fail; + } + + wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); + + wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, + &wlc_hw->band->phyrev, + &wlc_hw->band->radioid, + &wlc_hw->band->radiorev); + wlc_hw->band->abgphy_encore = + wlc_phy_get_encore(wlc_hw->band->pi); + wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); + wlc_hw->band->core_flags = + wlc_phy_get_coreflags(wlc_hw->band->pi); + + /* verify good phy_type & supported phy revision */ + if (BRCMS_ISNPHY(wlc_hw->band)) { + if (NCONF_HAS(wlc_hw->band->phyrev)) + goto good_phy; + else + goto bad_phy; + } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { + if (LCNCONF_HAS(wlc_hw->band->phyrev)) + goto good_phy; + else + goto bad_phy; + } else { + bad_phy: + wiphy_err(wiphy, "wl%d: brcms_b_attach: unsupported " + "phy type/rev (%d/%d)\n", unit, + wlc_hw->band->phytype, wlc_hw->band->phyrev); + err = 18; + goto fail; + } + + good_phy: + /* BMAC_NOTE: wlc->band->pi should not be set below and should be done in the + * high level attach. However we can not make that change until all low level access + * is changed to wlc_hw->band->pi. Instead do the wlc->band->pi init below, keeping + * wlc_hw->band->pi as well for incremental update of low level fns, and cut over + * low only init when all fns updated. + */ + wlc->band->pi = wlc_hw->band->pi; + wlc->band->phytype = wlc_hw->band->phytype; + wlc->band->phyrev = wlc_hw->band->phyrev; + wlc->band->radioid = wlc_hw->band->radioid; + wlc->band->radiorev = wlc_hw->band->radiorev; + + /* default contention windows size limits */ + wlc_hw->band->CWmin = APHY_CWMIN; + wlc_hw->band->CWmax = PHY_CWMAX; + + if (!brcms_b_attach_dmapio(wlc, j, wme)) { + err = 19; + goto fail; + } + } + + /* disable core to match driver "down" state */ + brcms_c_coredisable(wlc_hw); + + /* Match driver "down" state */ + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + + /* register sb interrupt callback functions */ + ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, + (void *)brcms_c_wlintrsrestore, NULL, wlc); + + /* turn off pll and xtal to match driver "down" state */ + brcms_b_xtal(wlc_hw, OFF); + + /* ********************************************************************* + * The hardware is in the DOWN state at this point. D11 core + * or cores are in reset with clocks off, and the board PLLs + * are off if possible. + * + * Beyond this point, wlc->sbclk == false and chip registers + * should not be touched. + ********************************************************************* + */ + + /* init etheraddr state variables */ + macaddr = brcms_c_get_macaddr(wlc_hw); + if (macaddr == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n", + unit); + err = 21; + goto fail; + } + brcmu_ether_atoe(macaddr, wlc_hw->etheraddr); + if (is_broadcast_ether_addr(wlc_hw->etheraddr) || + is_zero_ether_addr(wlc_hw->etheraddr)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", + unit, macaddr); + err = 22; + goto fail; + } + + BCMMSG(wlc->wiphy, + "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", + wlc_hw->deviceid, wlc_hw->_nbands, + wlc_hw->sih->boardtype, macaddr); + + return err; + + fail: + wiphy_err(wiphy, "wl%d: brcms_b_attach: failed with err %d\n", unit, + err); + return err; +} + +/* + * Initialize brcms_c_info default values ... + * may get overrides later in this function + * BMAC_NOTES, move low out and resolve the dangling ones + */ +static void brcms_b_info_init(struct brcms_hardware *wlc_hw) +{ + struct brcms_c_info *wlc = wlc_hw->wlc; + + /* set default sw macintmask value */ + wlc->defmacintmask = DEF_MACINTMASK; + + /* various 802.11g modes */ + wlc_hw->shortslot = false; + + wlc_hw->SFBL = RETRY_SHORT_FB; + wlc_hw->LFBL = RETRY_LONG_FB; + + /* default mac retry limits */ + wlc_hw->SRL = RETRY_SHORT_DEF; + wlc_hw->LRL = RETRY_LONG_DEF; + wlc_hw->chanspec = CH20MHZ_CHSPEC(1); +} + +/* + * low level detach + */ +int brcms_b_detach(struct brcms_c_info *wlc) +{ + uint i; + struct brcms_hw_band *band; + struct brcms_hardware *wlc_hw = wlc->hw; + int callbacks; + + callbacks = 0; + + if (wlc_hw->sih) { + /* detach interrupt sync mechanism since interrupt is disabled and per-port + * interrupt object may has been freed. this must be done before sb core switch + */ + ai_deregister_intr_callback(wlc_hw->sih); + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_sleep(wlc_hw->sih); + } + + brcms_b_detach_dmapio(wlc_hw); + + band = wlc_hw->band; + for (i = 0; i < NBANDS_HW(wlc_hw); i++) { + if (band->pi) { + /* Detach this band's phy */ + wlc_phy_detach(band->pi); + band->pi = NULL; + } + band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; + } + + /* Free shared phy state */ + kfree(wlc_hw->phy_sh); + + wlc_phy_shim_detach(wlc_hw->physhim); + + /* free vars */ + kfree(wlc_hw->vars); + wlc_hw->vars = NULL; + + if (wlc_hw->sih) { + ai_detach(wlc_hw->sih); + wlc_hw->sih = NULL; + } + + return callbacks; + +} + +void brcms_b_reset(struct brcms_hardware *wlc_hw) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* reset the core */ + if (!DEVICEREMOVED(wlc_hw->wlc)) + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + /* purge the dma rings */ + brcms_c_flushqueues(wlc_hw->wlc); + + brcms_c_reset_bmac_done(wlc_hw->wlc); +} + +void +brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, + bool mute) { + u32 macintmask; + bool fastclk; + struct brcms_c_info *wlc = wlc_hw->wlc; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* request FAST clock if not on */ + fastclk = wlc_hw->forcefastclk; + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + /* disable interrupts */ + macintmask = brcms_intrsoff(wlc->wl); + + /* set up the specified band and chanspec */ + brcms_c_setxband(wlc_hw, CHSPEC_BANDUNIT(chanspec)); + wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); + + /* do one-time phy inits and calibration */ + wlc_phy_cal_init(wlc_hw->band->pi); + + /* core-specific initialization */ + brcms_b_coreinit(wlc); + + /* suspend the tx fifos and mute the phy for preism cac time */ + if (mute) + brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); + + /* band-specific inits */ + brcms_b_bsinit(wlc, chanspec); + + /* restore macintmask */ + brcms_intrsrestore(wlc->wl, macintmask); + + /* seed wake_override with BRCMS_WAKE_OVERRIDE_MACSUSPEND since the mac + * is suspended and brcms_c_enable_mac() will clear this override bit. + */ + mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); + + /* + * initialize mac_suspend_depth to 1 to match ucode initial suspended state + */ + wlc_hw->mac_suspend_depth = 1; + + /* restore the clk */ + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); +} + +int brcms_b_up_prep(struct brcms_hardware *wlc_hw) +{ + uint coremask; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* + * Enable pll and xtal, initialize the power control registers, + * and force fastclock for the remainder of brcms_c_up(). + */ + brcms_b_xtal(wlc_hw, ON); + ai_clkctl_init(wlc_hw->sih); + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + /* + * Configure pci/pcmcia here instead of in brcms_c_attach() + * to allow mfg hotswap: down, hotswap (chip power cycle), up. + */ + coremask = (1 << wlc_hw->wlc->core->coreidx); + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_setup(wlc_hw->sih, coremask); + + /* + * Need to read the hwradio status here to cover the case where the system + * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. + */ + if (brcms_b_radio_read_hwdisabled(wlc_hw)) { + /* put SB PCI in down state again */ + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + brcms_b_xtal(wlc_hw, OFF); + return -ENOMEDIUM; + } + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_up(wlc_hw->sih); + + /* reset the d11 core */ + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + return 0; +} + +int brcms_b_up_finish(struct brcms_hardware *wlc_hw) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + wlc_hw->up = true; + wlc_phy_hw_state_upd(wlc_hw->band->pi, true); + + /* FULLY enable dynamic power control and d11 core interrupt */ + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); + brcms_intrson(wlc_hw->wlc->wl); + return 0; +} + +int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) +{ + bool dev_gone; + uint callbacks = 0; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return callbacks; + + dev_gone = DEVICEREMOVED(wlc_hw->wlc); + + /* disable interrupts */ + if (dev_gone) + wlc_hw->wlc->macintmask = 0; + else { + /* now disable interrupts */ + brcms_intrsoff(wlc_hw->wlc->wl); + + /* ensure we're running on the pll clock again */ + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + } + /* down phy at the last of this stage */ + callbacks += wlc_phy_down(wlc_hw->band->pi); + + return callbacks; +} + +int brcms_b_down_finish(struct brcms_hardware *wlc_hw) +{ + uint callbacks = 0; + bool dev_gone; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return callbacks; + + wlc_hw->up = false; + wlc_phy_hw_state_upd(wlc_hw->band->pi, false); + + dev_gone = DEVICEREMOVED(wlc_hw->wlc); + + if (dev_gone) { + wlc_hw->sbclk = false; + wlc_hw->clk = false; + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); + + /* reclaim any posted packets */ + brcms_c_flushqueues(wlc_hw->wlc); + } else { + + /* Reset and disable the core */ + if (ai_iscoreup(wlc_hw->sih)) { + if (R_REG(&wlc_hw->regs->maccontrol) & + MCTL_EN_MAC) + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + callbacks += brcms_reset(wlc_hw->wlc->wl); + brcms_c_coredisable(wlc_hw); + } + + /* turn off primary xtal and pll */ + if (!wlc_hw->noreset) { + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + brcms_b_xtal(wlc_hw, OFF); + } + } + + return callbacks; +} + +void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) +{ + /* delay before first read of ucode state */ + udelay(40); + + /* wait until ucode is no longer asleep */ + SPINWAIT((brcms_b_read_shm(wlc_hw, M_UCODE_DBGST) == + DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); +} + +void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea) +{ + memcpy(ea, wlc_hw->etheraddr, ETH_ALEN); +} + +static int brcms_b_bandtype(struct brcms_hardware *wlc_hw) +{ + return wlc_hw->band->bandtype; +} + +/* control chip clock to save power, enable dynamic clock or force fast clock */ +static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) +{ + if (PMUCTL_ENAB(wlc_hw->sih)) { + /* new chips with PMU, CCS_FORCEHT will distribute the HT clock on backplane, + * but mac core will still run on ALP(not HT) when it enters powersave mode, + * which means the FCA bit may not be set. + * should wakeup mac if driver wants it to run on HT. + */ + + if (wlc_hw->clk) { + if (mode == CLK_FAST) { + OR_REG(&wlc_hw->regs->clk_ctl_st, + CCS_FORCEHT); + + udelay(64); + + SPINWAIT(((R_REG + (&wlc_hw->regs-> + clk_ctl_st) & CCS_HTAVAIL) == 0), + PMU_MAX_TRANSITION_DLY); + WARN_ON(!(R_REG + (&wlc_hw->regs-> + clk_ctl_st) & CCS_HTAVAIL)); + } else { + if ((wlc_hw->sih->pmurev == 0) && + (R_REG + (&wlc_hw->regs-> + clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) + SPINWAIT(((R_REG + (&wlc_hw->regs-> + clk_ctl_st) & CCS_HTAVAIL) + == 0), + PMU_MAX_TRANSITION_DLY); + AND_REG(&wlc_hw->regs->clk_ctl_st, + ~CCS_FORCEHT); + } + } + wlc_hw->forcefastclk = (mode == CLK_FAST); + } else { + + /* old chips w/o PMU, force HT through cc, + * then use FCA to verify mac is running fast clock + */ + + wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); + + /* check fast clock is available (if core is not in reset) */ + if (wlc_hw->forcefastclk && wlc_hw->clk) + WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) & + SISF_FCLKA)); + + /* keep the ucode wake bit on if forcefastclk is on + * since we do not want ucode to put us back to slow clock + * when it dozes for PM mode. + * Code below matches the wake override bit with current forcefastclk state + * Only setting bit in wake_override instead of waking ucode immediately + * since old code (wlc.c 1.4499) had this behavior. Older code set + * wlc->forcefastclk but only had the wake happen if the wakup_ucode work + * (protected by an up check) was executed just below. + */ + if (wlc_hw->forcefastclk) + mboolset(wlc_hw->wake_override, + BRCMS_WAKE_OVERRIDE_FORCEFAST); + else + mboolclr(wlc_hw->wake_override, + BRCMS_WAKE_OVERRIDE_FORCEFAST); + } +} + +/* set initial host flags value */ +static void +brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + + memset(mhfs, 0, MHFMAX * sizeof(u16)); + + mhfs[MHF2] |= mhf2_init; + + /* prohibit use of slowclock on multifunction boards */ + if (wlc_hw->boardflags & BFL_NOPLLDOWN) + mhfs[MHF1] |= MHF1_FORCEFASTCLK; + + if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { + mhfs[MHF2] |= MHF2_NPHY40MHZ_WAR; + mhfs[MHF1] |= MHF1_IQSWAP_WAR; + } +} + +/* set or clear ucode host flag bits + * it has an optimization for no-change write + * it only writes through shared memory when the core has clock; + * pre-CLK changes should use wlc_write_mhf to get around the optimization + * + * + * bands values are: BRCM_BAND_AUTO <--- Current band only + * BRCM_BAND_5G <--- 5G band only + * BRCM_BAND_2G <--- 2G band only + * BRCM_BAND_ALL <--- All bands + */ +void +brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, + int bands) +{ + u16 save; + u16 addr[MHFMAX] = { + M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, + M_HOST_FLAGS5 + }; + struct brcms_hw_band *band; + + if ((val & ~mask) || idx >= MHFMAX) + return; /* error condition */ + + switch (bands) { + /* Current band only or all bands, + * then set the band to current band + */ + case BRCM_BAND_AUTO: + case BRCM_BAND_ALL: + band = wlc_hw->band; + break; + case BRCM_BAND_5G: + band = wlc_hw->bandstate[BAND_5G_INDEX]; + break; + case BRCM_BAND_2G: + band = wlc_hw->bandstate[BAND_2G_INDEX]; + break; + default: + band = NULL; /* error condition */ + } + + if (band) { + save = band->mhfs[idx]; + band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; + + /* optimization: only write through if changed, and + * changed band is the current band + */ + if (wlc_hw->clk && (band->mhfs[idx] != save) + && (band == wlc_hw->band)) + brcms_b_write_shm(wlc_hw, addr[idx], + (u16) band->mhfs[idx]); + } + + if (bands == BRCM_BAND_ALL) { + wlc_hw->bandstate[0]->mhfs[idx] = + (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; + wlc_hw->bandstate[1]->mhfs[idx] = + (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; + } +} + +u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands) +{ + struct brcms_hw_band *band; + + if (idx >= MHFMAX) + return 0; /* error condition */ + switch (bands) { + case BRCM_BAND_AUTO: + band = wlc_hw->band; + break; + case BRCM_BAND_5G: + band = wlc_hw->bandstate[BAND_5G_INDEX]; + break; + case BRCM_BAND_2G: + band = wlc_hw->bandstate[BAND_2G_INDEX]; + break; + default: + band = NULL; /* error condition */ + } + + if (!band) + return 0; + + return band->mhfs[idx]; +} + +static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) +{ + u8 idx; + u16 addr[] = { + M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, + M_HOST_FLAGS5 + }; + + for (idx = 0; idx < MHFMAX; idx++) { + brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); + } +} + +/* set the maccontrol register to desired reset state and + * initialize the sw cache of the register + */ +static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw) +{ + /* IHR accesses are always enabled, PSM disabled, HPS off and WAKE on */ + wlc_hw->maccontrol = 0; + wlc_hw->suspended_fifos = 0; + wlc_hw->wake_override = 0; + wlc_hw->mute_override = 0; + brcms_b_mctrl(wlc_hw, ~0, MCTL_IHR_EN | MCTL_WAKE); +} + +/* set or clear maccontrol bits */ +void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) +{ + u32 maccontrol; + u32 new_maccontrol; + + if (val & ~mask) + return; /* error condition */ + maccontrol = wlc_hw->maccontrol; + new_maccontrol = (maccontrol & ~mask) | val; + + /* if the new maccontrol value is the same as the old, nothing to do */ + if (new_maccontrol == maccontrol) + return; + + /* something changed, cache the new value */ + wlc_hw->maccontrol = new_maccontrol; + + /* write the new values with overrides applied */ + brcms_c_mctrl_write(wlc_hw); +} + +/* write the software state of maccontrol and overrides to the maccontrol register */ +static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) +{ + u32 maccontrol = wlc_hw->maccontrol; + + /* OR in the wake bit if overridden */ + if (wlc_hw->wake_override) + maccontrol |= MCTL_WAKE; + + /* set AP and INFRA bits for mute if needed */ + if (wlc_hw->mute_override) { + maccontrol &= ~(MCTL_AP); + maccontrol |= MCTL_INFRA; + } + + W_REG(&wlc_hw->regs->maccontrol, maccontrol); +} + +void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, + u32 override_bit) +{ + if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { + mboolset(wlc_hw->wake_override, override_bit); + return; + } + + mboolset(wlc_hw->wake_override, override_bit); + + brcms_c_mctrl_write(wlc_hw); + brcms_b_wait_for_wake(wlc_hw); + + return; +} + +void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, + u32 override_bit) +{ + mboolclr(wlc_hw->wake_override, override_bit); + + if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) + return; + + brcms_c_mctrl_write(wlc_hw); + + return; +} + +/* When driver needs ucode to stop beaconing, it has to make sure that + * MCTL_AP is clear and MCTL_INFRA is set + * Mode MCTL_AP MCTL_INFRA + * AP 1 1 + * STA 0 1 <--- This will ensure no beacons + * IBSS 0 0 + */ +static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw) +{ + wlc_hw->mute_override = 1; + + /* if maccontrol already has AP == 0 and INFRA == 1 without this + * override, then there is no change to write + */ + if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) + return; + + brcms_c_mctrl_write(wlc_hw); + + return; +} + +/* Clear the override on AP and INFRA bits */ +static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw) +{ + if (wlc_hw->mute_override == 0) + return; + + wlc_hw->mute_override = 0; + + /* if maccontrol already has AP == 0 and INFRA == 1 without this + * override, then there is no change to write + */ + if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) + return; + + brcms_c_mctrl_write(wlc_hw); +} + +/* + * Write a MAC address to the given match reg offset in the RXE match engine. + */ +void +brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, + const u8 *addr) +{ + d11regs_t *regs; + u16 mac_l; + u16 mac_m; + u16 mac_h; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", + wlc_hw->unit); + + regs = wlc_hw->regs; + mac_l = addr[0] | (addr[1] << 8); + mac_m = addr[2] | (addr[3] << 8); + mac_h = addr[4] | (addr[5] << 8); + + /* enter the MAC addr into the RXE match registers */ + W_REG(®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); + W_REG(®s->rcm_mat_data, mac_l); + W_REG(®s->rcm_mat_data, mac_m); + W_REG(®s->rcm_mat_data, mac_h); + +} + +void +brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, + void *buf) +{ + d11regs_t *regs; + u32 word; + bool be_bit; + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + regs = wlc_hw->regs; + W_REG(®s->tplatewrptr, offset); + + /* if MCTL_BIGEND bit set in mac control register, + * the chip swaps data in fifo, as well as data in + * template ram + */ + be_bit = (R_REG(®s->maccontrol) & MCTL_BIGEND) != 0; + + while (len > 0) { + memcpy(&word, buf, sizeof(u32)); + + if (be_bit) + word = cpu_to_be32(word); + else + word = cpu_to_le32(word); + + W_REG(®s->tplatewrdata, word); + + buf = (u8 *) buf + sizeof(u32); + len -= sizeof(u32); + } +} + +void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) +{ + wlc_hw->band->CWmin = newmin; + + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, newmin); +} + +void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) +{ + wlc_hw->band->CWmax = newmax; + + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, newmax); +} + +void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) +{ + bool fastclk; + + /* request FAST clock if not on */ + fastclk = wlc_hw->forcefastclk; + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + wlc_phy_bw_state_set(wlc_hw->band->pi, bw); + + brcms_b_phy_reset(wlc_hw); + wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); + + /* restore the clk */ + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); +} + +static void +brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, + int len) +{ + d11regs_t *regs = wlc_hw->regs; + + brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3, + bcn); + /* write beacon length to SCR */ + brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len); + /* mark beacon0 valid */ + OR_REG(®s->maccommand, MCMD_BCN0VLD); +} + +static void +brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, + int len) +{ + d11regs_t *regs = wlc_hw->regs; + + brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3, + bcn); + /* write beacon length to SCR */ + brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len); + /* mark beacon1 valid */ + OR_REG(®s->maccommand, MCMD_BCN1VLD); +} + +/* mac is assumed to be suspended at this point */ +void +brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, + int len, bool both) +{ + d11regs_t *regs = wlc_hw->regs; + + if (both) { + brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); + brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); + } else { + /* bcn 0 */ + if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) + brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); + /* bcn 1 */ + else if (! + (R_REG(®s->maccommand) & MCMD_BCN1VLD)) + brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); + } +} + +static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) +{ + u16 v; + struct brcms_c_info *wlc = wlc_hw->wlc; + /* update SYNTHPU_DLY */ + + if (BRCMS_ISLCNPHY(wlc->band)) { + v = SYNTHPU_DLY_LPPHY_US; + } else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) { + v = SYNTHPU_DLY_NPHY_US; + } else { + v = SYNTHPU_DLY_BPHY_US; + } + + brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); +} + +/* band-specific init */ +static void brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + + BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, + wlc_hw->band->bandunit); + + brcms_c_ucode_bsinit(wlc_hw); + + wlc_phy_init(wlc_hw->band->pi, chanspec); + + brcms_c_ucode_txant_set(wlc_hw); + + /* cwmin is band-specific, update hardware with value for current band */ + brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); + brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); + + brcms_b_update_slot_timing(wlc_hw, + BAND_5G(wlc_hw->band-> + bandtype) ? true : wlc_hw-> + shortslot); + + /* write phytype and phyvers */ + brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); + brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); + + /* initialize the txphyctl1 rate table since shmem is shared between bands */ + brcms_upd_ofdm_pctl1_table(wlc_hw); + + brcms_b_upd_synthpu(wlc_hw); +} + +static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); + + wlc_hw->phyclk = clk; + + if (OFF == clk) { /* clear gmode bit, put phy into reset */ + + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), + (SICF_PRST | SICF_FGC)); + udelay(1); + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); + udelay(1); + + } else { /* take phy out of reset */ + + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); + udelay(1); + ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); + udelay(1); + + } +} + +/* Perform a soft reset of the PHY PLL */ +void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + ai_corereg(wlc_hw->sih, SI_CC_IDX, + offsetof(chipcregs_t, chipcontrol_addr), ~0, 0); + udelay(1); + ai_corereg(wlc_hw->sih, SI_CC_IDX, + offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); + udelay(1); + ai_corereg(wlc_hw->sih, SI_CC_IDX, + offsetof(chipcregs_t, chipcontrol_data), 0x4, 4); + udelay(1); + ai_corereg(wlc_hw->sih, SI_CC_IDX, + offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); + udelay(1); +} + +/* light way to turn on phy clock without reset for NPHY only + * refer to brcms_b_core_phy_clk for full version + */ +void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk) +{ + /* support(necessary for NPHY and HYPHY) only */ + if (!BRCMS_ISNPHY(wlc_hw->band)) + return; + + if (ON == clk) + ai_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC); + else + ai_core_cflags(wlc_hw->sih, SICF_FGC, 0); + +} + +void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk) +{ + if (ON == clk) + ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE); + else + ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0); +} + +void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) +{ + struct brcms_phy_pub *pih = wlc_hw->band->pi; + u32 phy_bw_clkbits; + bool phy_in_reset = false; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (pih == NULL) + return; + + phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); + + /* Specific reset sequence required for NPHY rev 3 and 4 */ + if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && + NREV_LE(wlc_hw->band->phyrev, 4)) { + /* Set the PHY bandwidth */ + ai_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits); + + udelay(1); + + /* Perform a soft reset of the PHY PLL */ + brcms_b_core_phypll_reset(wlc_hw); + + /* reset the PHY */ + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE), + (SICF_PRST | SICF_PCLKE)); + phy_in_reset = true; + } else { + + ai_core_cflags(wlc_hw->sih, + (SICF_PRST | SICF_PCLKE | SICF_BWMASK), + (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); + } + + udelay(2); + brcms_b_core_phy_clk(wlc_hw, ON); + + if (pih) + wlc_phy_anacore(pih, ON); +} + +/* switch to and initialize new band */ +static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, + chanspec_t chanspec) { + struct brcms_c_info *wlc = wlc_hw->wlc; + u32 macintmask; + + /* Enable the d11 core before accessing it */ + if (!ai_iscoreup(wlc_hw->sih)) { + ai_core_reset(wlc_hw->sih, 0, 0); + brcms_c_mctrl_reset(wlc_hw); + } + + macintmask = brcms_c_setband_inact(wlc, bandunit); + + if (!wlc_hw->up) + return; + + brcms_b_core_phy_clk(wlc_hw, ON); + + /* band-specific initializations */ + brcms_b_bsinit(wlc, chanspec); + + /* + * If there are any pending software interrupt bits, + * then replace these with a harmless nonzero value + * so brcms_c_dpc() will re-enable interrupts when done. + */ + if (wlc->macintstatus) + wlc->macintstatus = MI_DMAINT; + + /* restore macintmask */ + brcms_intrsrestore(wlc->wl, macintmask); + + /* ucode should still be suspended.. */ + WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); +} + +/* low-level band switch utility routine */ +void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, + bandunit); + + wlc_hw->band = wlc_hw->bandstate[bandunit]; + + /* BMAC_NOTE: until we eliminate need for wlc->band refs in low level code */ + wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; + + /* set gmode core flag */ + if (wlc_hw->sbclk && !wlc_hw->noreset) { + ai_core_cflags(wlc_hw->sih, SICF_GMODE, + ((bandunit == 0) ? SICF_GMODE : 0)); + } +} + +static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) +{ + + /* reject unsupported corerev */ + if (!VALID_COREREV(wlc_hw->corerev)) { + wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", + wlc_hw->corerev); + return false; + } + + return true; +} + +/* Validate some board info parameters */ +static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) +{ + uint boardrev = wlc_hw->boardrev; + + /* 4 bits each for board type, major, minor, and tiny version */ + uint brt = (boardrev & 0xf000) >> 12; + uint b0 = (boardrev & 0xf00) >> 8; + uint b1 = (boardrev & 0xf0) >> 4; + uint b2 = boardrev & 0xf; + + /* voards from other vendors are always considered valid */ + if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM) + return true; + + /* do some boardrev sanity checks when boardvendor is Broadcom */ + if (boardrev == 0) + return false; + + if (boardrev <= 0xff) + return true; + + if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9) + || (b2 > 9)) + return false; + + return true; +} + +static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) +{ + const char *varname = "macaddr"; + char *macaddr; + + /* If macaddr exists, use it (Sromrev4, CIS, ...). */ + macaddr = getvar(wlc_hw->vars, varname); + if (macaddr != NULL) + return macaddr; + + if (NBANDS_HW(wlc_hw) > 1) + varname = "et1macaddr"; + else + varname = "il0macaddr"; + + macaddr = getvar(wlc_hw->vars, varname); + if (macaddr == NULL) { + wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " + "getvar(%s) not found\n", wlc_hw->unit, varname); + } + + return macaddr; +} + +/* + * Return true if radio is disabled, otherwise false. + * hw radio disable signal is an external pin, users activate it asynchronously + * this function could be called when driver is down and w/o clock + * it operates on different registers depending on corerev and boardflag. + */ +bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) +{ + bool v, clk, xtal; + u32 resetbits = 0, flags = 0; + + xtal = wlc_hw->sbclk; + if (!xtal) + brcms_b_xtal(wlc_hw, ON); + + /* may need to take core out of reset first */ + clk = wlc_hw->clk; + if (!clk) { + /* + * mac no longer enables phyclk automatically when driver + * accesses phyreg throughput mac. This can be skipped since + * only mac reg is accessed below + */ + flags |= SICF_PCLKE; + + /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ + if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || + (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->regs = + (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, + 0); + ai_core_reset(wlc_hw->sih, flags, resetbits); + brcms_c_mctrl_reset(wlc_hw); + } + + v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); + + /* put core back into reset */ + if (!clk) + ai_core_disable(wlc_hw->sih, 0); + + if (!xtal) + brcms_b_xtal(wlc_hw, OFF); + + return v; +} + +/* Initialize just the hardware when coming out of POR or S3/S5 system states */ +void brcms_b_hw_up(struct brcms_hardware *wlc_hw) +{ + if (wlc_hw->wlc->pub->hw_up) + return; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* + * Enable pll and xtal, initialize the power control registers, + * and force fastclock for the remainder of brcms_c_up(). + */ + brcms_b_xtal(wlc_hw, ON); + ai_clkctl_init(wlc_hw->sih); + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + if (wlc_hw->sih->bustype == PCI_BUS) { + ai_pci_fixcfg(wlc_hw->sih); + + /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ + if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || + (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->regs = + (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, + 0); + } + + /* Inform phy that a POR reset has occurred so it does a complete phy init */ + wlc_phy_por_inform(wlc_hw->band->pi); + + wlc_hw->ucode_loaded = false; + wlc_hw->wlc->pub->hw_up = true; + + if ((wlc_hw->boardflags & BFL_FEM) + && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { + if (! + (wlc_hw->boardrev >= 0x1250 + && (wlc_hw->boardflags & BFL_FEM_BT))) + ai_epa_4313war(wlc_hw->sih); + } +} + +static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) +{ + struct dma_pub *di = wlc_hw->di[fifo]; + return dma_rxreset(di); +} + +/* d11 core reset + * ensure fask clock during reset + * reset dma + * reset d11(out of reset) + * reset phy(out of reset) + * clear software macintstatus for fresh new start + * one testing hack wlc_hw->noreset will bypass the d11/phy reset + */ +void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) +{ + d11regs_t *regs; + uint i; + bool fastclk; + u32 resetbits = 0; + + if (flags == BRCMS_USE_COREFLAGS) + flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + regs = wlc_hw->regs; + + /* request FAST clock if not on */ + fastclk = wlc_hw->forcefastclk; + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + /* reset the dma engines except first time thru */ + if (ai_iscoreup(wlc_hw->sih)) { + for (i = 0; i < NFIFO; i++) + if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) { + wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " + "dma_txreset[%d]: cannot stop dma\n", + wlc_hw->unit, __func__, i); + } + + if ((wlc_hw->di[RX_FIFO]) + && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) { + wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset" + "[%d]: cannot stop dma\n", + wlc_hw->unit, __func__, RX_FIFO); + } + } + /* if noreset, just stop the psm and return */ + if (wlc_hw->noreset) { + wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ + brcms_b_mctrl(wlc_hw, MCTL_PSM_RUN | MCTL_EN_MAC, 0); + return; + } + + /* + * mac no longer enables phyclk automatically when driver accesses + * phyreg throughput mac, AND phy_reset is skipped at early stage when + * band->pi is invalid. need to enable PHY CLK + */ + flags |= SICF_PCLKE; + + /* reset the core + * In chips with PMU, the fastclk request goes through d11 core reg 0x1e0, which + * is cleared by the core_reset. have to re-request it. + * This adds some delay and we can optimize it by also requesting fastclk through + * chipcommon during this period if necessary. But that has to work coordinate + * with other driver like mips/arm since they may touch chipcommon as well. + */ + wlc_hw->clk = false; + ai_core_reset(wlc_hw->sih, flags, resetbits); + wlc_hw->clk = true; + if (wlc_hw->band && wlc_hw->band->pi) + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); + + brcms_c_mctrl_reset(wlc_hw); + + if (PMUCTL_ENAB(wlc_hw->sih)) + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + brcms_b_phy_reset(wlc_hw); + + /* turn on PHY_PLL */ + brcms_b_core_phypll_ctl(wlc_hw, true); + + /* clear sw intstatus */ + wlc_hw->wlc->macintstatus = 0; + + /* restore the clk setting */ + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); +} + +/* txfifo sizes needs to be modified(increased) since the newer cores + * have more memory. + */ +static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) +{ + d11regs_t *regs = wlc_hw->regs; + u16 fifo_nu; + u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; + u16 txfifo_def, txfifo_def1; + u16 txfifo_cmd; + + /* tx fifos start at TXFIFO_START_BLK from the Base address */ + txfifo_startblk = TXFIFO_START_BLK; + + /* sequence of operations: reset fifo, set fifo size, reset fifo */ + for (fifo_nu = 0; fifo_nu < NFIFO; fifo_nu++) { + + txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; + txfifo_def = (txfifo_startblk & 0xff) | + (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); + txfifo_def1 = ((txfifo_startblk >> 8) & 0x1) | + ((((txfifo_endblk - + 1) >> 8) & 0x1) << TXFIFO_FIFOTOP_SHIFT); + txfifo_cmd = + TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); + + W_REG(®s->xmtfifocmd, txfifo_cmd); + W_REG(®s->xmtfifodef, txfifo_def); + W_REG(®s->xmtfifodef1, txfifo_def1); + + W_REG(®s->xmtfifocmd, txfifo_cmd); + + txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; + } + /* + * need to propagate to shm location to be in sync since ucode/hw won't + * do this + */ + brcms_b_write_shm(wlc_hw, M_FIFOSIZE0, + wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); + brcms_b_write_shm(wlc_hw, M_FIFOSIZE1, + wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); + brcms_b_write_shm(wlc_hw, M_FIFOSIZE2, + ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> + xmtfifo_sz[TX_AC_BK_FIFO])); + brcms_b_write_shm(wlc_hw, M_FIFOSIZE3, + ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> + xmtfifo_sz[TX_BCMC_FIFO])); +} + +/* d11 core init + * reset PSM + * download ucode/PCM + * let ucode run to suspended + * download ucode inits + * config other core registers + * init dma + */ +static void brcms_b_coreinit(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs; + u32 sflags; + uint bcnint_us; + uint i = 0; + bool fifosz_fixup = false; + int err = 0; + u16 buf[NFIFO]; + struct wiphy *wiphy = wlc->wiphy; + + regs = wlc_hw->regs; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* reset PSM */ + brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); + + brcms_ucode_download(wlc_hw); + /* + * FIFOSZ fixup. driver wants to controls the fifo allocation. + */ + fifosz_fixup = true; + + /* let the PSM run to the suspended state, set mode to BSS STA */ + W_REG(®s->macintstatus, -1); + brcms_b_mctrl(wlc_hw, ~0, + (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); + + /* wait for ucode to self-suspend after auto-init */ + SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), + 1000 * 1000); + if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) + wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" + "suspend!\n", wlc_hw->unit); + + brcms_c_gpio_init(wlc); + + sflags = ai_core_sflags(wlc_hw->sih, 0, 0); + + if (D11REV_IS(wlc_hw->corerev, 23)) { + if (BRCMS_ISNPHY(wlc_hw->band)) + brcms_c_write_inits(wlc_hw, d11n0initvals16); + else + wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" + " %d\n", __func__, wlc_hw->unit, + wlc_hw->corerev); + } else if (D11REV_IS(wlc_hw->corerev, 24)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) { + brcms_c_write_inits(wlc_hw, d11lcn0initvals24); + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" + " %d\n", __func__, wlc_hw->unit, + wlc_hw->corerev); + } + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", + __func__, wlc_hw->unit, wlc_hw->corerev); + } + + /* For old ucode, txfifo sizes needs to be modified(increased) */ + if (fifosz_fixup == true) { + brcms_b_corerev_fifofixup(wlc_hw); + } + + /* check txfifo allocations match between ucode and driver */ + buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); + if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { + i = TX_AC_BE_FIFO; + err = -1; + } + buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); + if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { + i = TX_AC_VI_FIFO; + err = -1; + } + buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); + buf[TX_AC_VO_FIFO] = (buf[TX_AC_BK_FIFO] >> 8) & 0xff; + buf[TX_AC_BK_FIFO] &= 0xff; + if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { + i = TX_AC_BK_FIFO; + err = -1; + } + if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { + i = TX_AC_VO_FIFO; + err = -1; + } + buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); + buf[TX_ATIM_FIFO] = (buf[TX_BCMC_FIFO] >> 8) & 0xff; + buf[TX_BCMC_FIFO] &= 0xff; + if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { + i = TX_BCMC_FIFO; + err = -1; + } + if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { + i = TX_ATIM_FIFO; + err = -1; + } + if (err != 0) { + wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" + " driver size %d index %d\n", buf[i], + wlc_hw->xmtfifo_sz[i], i); + } + + /* make sure we can still talk to the mac */ + WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); + + /* band-specific inits done by wlc_bsinit() */ + + /* Set up frame burst size and antenna swap threshold init values */ + brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); + brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); + + /* enable one rx interrupt per received frame */ + W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); + + /* set the station mode (BSS STA) */ + brcms_b_mctrl(wlc_hw, + (MCTL_INFRA | MCTL_DISCARD_PMQ | MCTL_AP), + (MCTL_INFRA | MCTL_DISCARD_PMQ)); + + /* set up Beacon interval */ + bcnint_us = 0x8000 << 10; + W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); + W_REG(®s->tsf_cfpstart, bcnint_us); + W_REG(®s->macintstatus, MI_GP1); + + /* write interrupt mask */ + W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); + + /* allow the MAC to control the PHY clock (dynamic on/off) */ + brcms_b_macphyclk_set(wlc_hw, ON); + + /* program dynamic clock control fast powerup delay register */ + wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); + W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); + + /* tell the ucode the corerev */ + brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); + + /* tell the ucode MAC capabilities */ + brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, + (u16) (wlc_hw->machwcap & 0xffff)); + brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, + (u16) ((wlc_hw-> + machwcap >> 16) & 0xffff)); + + /* write retry limits to SCR, this done after PSM init */ + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->SRL); + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->LRL); + + /* write rate fallback retry limits */ + brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); + brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); + + AND_REG(®s->ifs_ctl, 0x0FFF); + W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); + + /* dma initializations */ + wlc->txpend16165war = 0; + + /* init the tx dma engines */ + for (i = 0; i < NFIFO; i++) { + if (wlc_hw->di[i]) + dma_txinit(wlc_hw->di[i]); + } + + /* init the rx dma engine(s) and post receive buffers */ + dma_rxinit(wlc_hw->di[RX_FIFO]); + dma_rxfill(wlc_hw->di[RX_FIFO]); +} + +/* This function is used for changing the tsf frac register + * If spur avoidance mode is off, the mac freq will be 80/120/160Mhz + * If spur avoidance mode is on1, the mac freq will be 82/123/164Mhz + * If spur avoidance mode is on2, the mac freq will be 84/126/168Mhz + * HTPHY Formula is 2^26/freq(MHz) e.g. + * For spuron2 - 126MHz -> 2^26/126 = 532610.0 + * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082 + * For spuron: 123MHz -> 2^26/123 = 545600.5 + * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341 + * For spur off: 120MHz -> 2^26/120 = 559240.5 + * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889 + */ + +void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) +{ + d11regs_t *regs; + regs = wlc_hw->regs; + + if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || + (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { + if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ + W_REG(®s->tsf_clk_frac_l, 0x2082); + W_REG(®s->tsf_clk_frac_h, 0x8); + } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ + W_REG(®s->tsf_clk_frac_l, 0x5341); + W_REG(®s->tsf_clk_frac_h, 0x8); + } else { /* 120Mhz */ + W_REG(®s->tsf_clk_frac_l, 0x8889); + W_REG(®s->tsf_clk_frac_h, 0x8); + } + } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { + if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ + W_REG(®s->tsf_clk_frac_l, 0x7CE0); + W_REG(®s->tsf_clk_frac_h, 0xC); + } else { /* 80Mhz */ + W_REG(®s->tsf_clk_frac_l, 0xCCCD); + W_REG(®s->tsf_clk_frac_h, 0xC); + } + } +} + +/* Initialize GPIOs that are controlled by D11 core */ +static void brcms_c_gpio_init(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs; + u32 gc, gm; + + regs = wlc_hw->regs; + + /* use GPIO select 0 to get all gpio signals from the gpio out reg */ + brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); + + /* + * Common GPIO setup: + * G0 = LED 0 = WLAN Activity + * G1 = LED 1 = WLAN 2.4 GHz Radio State + * G2 = LED 2 = WLAN 5 GHz Radio State + * G4 = radio disable input (HI enabled, LO disabled) + */ + + gc = gm = 0; + + /* Allocate GPIOs for mimo antenna diversity feature */ + if (wlc_hw->antsel_type == ANTSEL_2x3) { + /* Enable antenna diversity, use 2x3 mode */ + brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, + MHF3_ANTSEL_EN, BRCM_BAND_ALL); + brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, + MHF3_ANTSEL_MODE, BRCM_BAND_ALL); + + /* init superswitch control */ + wlc_phy_antsel_init(wlc_hw->band->pi, false); + + } else if (wlc_hw->antsel_type == ANTSEL_2x4) { + gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13); + /* + * The board itself is powered by these GPIOs + * (when not sending pattern) so set them high + */ + OR_REG(®s->psm_gpio_oe, + (BOARD_GPIO_12 | BOARD_GPIO_13)); + OR_REG(®s->psm_gpio_out, + (BOARD_GPIO_12 | BOARD_GPIO_13)); + + /* Enable antenna diversity, use 2x4 mode */ + brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, + MHF3_ANTSEL_EN, BRCM_BAND_ALL); + brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, + BRCM_BAND_ALL); + + /* Configure the desired clock to be 4Mhz */ + brcms_b_write_shm(wlc_hw, M_ANTSEL_CLKDIV, + ANTSEL_CLKDIV_4MHZ); + } + + /* gpio 9 controls the PA. ucode is responsible for wiggling out and oe */ + if (wlc_hw->boardflags & BFL_PACTRL) + gm |= gc |= BOARD_GPIO_PACTRL; + + /* apply to gpiocontrol register */ + ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY); +} + +static void brcms_ucode_download(struct brcms_hardware *wlc_hw) +{ + struct brcms_c_info *wlc; + wlc = wlc_hw->wlc; + + if (wlc_hw->ucode_loaded) + return; + + if (D11REV_IS(wlc_hw->corerev, 23)) { + if (BRCMS_ISNPHY(wlc_hw->band)) { + brcms_ucode_write(wlc_hw, bcm43xx_16_mimo, + bcm43xx_16_mimosz); + wlc_hw->ucode_loaded = true; + } else + wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " + "corerev %d\n", + __func__, wlc_hw->unit, wlc_hw->corerev); + } else if (D11REV_IS(wlc_hw->corerev, 24)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) { + brcms_ucode_write(wlc_hw, bcm43xx_24_lcn, + bcm43xx_24_lcnsz); + wlc_hw->ucode_loaded = true; + } else { + wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " + "corerev %d\n", + __func__, wlc_hw->unit, wlc_hw->corerev); + } + } +} + +static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], + const uint nbytes) { + d11regs_t *regs = wlc_hw->regs; + uint i; + uint count; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + count = (nbytes / sizeof(u32)); + + W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); + (void)R_REG(®s->objaddr); + for (i = 0; i < count; i++) + W_REG(®s->objdata, ucode[i]); +} + +static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, + const struct d11init *inits) +{ + int i; + volatile u8 *base; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + base = (volatile u8 *)wlc_hw->regs; + + for (i = 0; inits[i].addr != 0xffff; i++) { + if (inits[i].size == 2) + W_REG((u16 *)(base + inits[i].addr), + inits[i].value); + else if (inits[i].size == 4) + W_REG((u32 *)(base + inits[i].addr), + inits[i].value); + } +} + +static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) +{ + u16 phyctl; + u16 phytxant = wlc_hw->bmac_phytxant; + u16 mask = PHY_TXC_ANT_MASK; + + /* set the Probe Response frame phy control word */ + phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); + phyctl = (phyctl & ~mask) | phytxant; + brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); + + /* set the Response (ACK/CTS) frame phy control word */ + phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); + phyctl = (phyctl & ~mask) | phytxant; + brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); +} + +void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant) +{ + /* update sw state */ + wlc_hw->bmac_phytxant = phytxant; + + /* push to ucode if up */ + if (!wlc_hw->up) + return; + brcms_c_ucode_txant_set(wlc_hw); + +} + +u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw) +{ + return (u16) wlc_hw->wlc->stf->txant; +} + +void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) +{ + wlc_hw->antsel_type = antsel_type; + + /* Update the antsel type for phy module to use */ + wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); +} + +void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) +{ + bool fatal = false; + uint unit; + uint intstatus, idx; + d11regs_t *regs = wlc_hw->regs; + struct wiphy *wiphy = wlc_hw->wlc->wiphy; + + unit = wlc_hw->unit; + + for (idx = 0; idx < NFIFO; idx++) { + /* read intstatus register and ignore any non-error bits */ + intstatus = + R_REG(®s->intctrlregs[idx].intstatus) & I_ERRORS; + if (!intstatus) + continue; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: intstatus%d 0x%x\n", + unit, idx, intstatus); + + if (intstatus & I_RO) { + wiphy_err(wiphy, "wl%d: fifo %d: receive fifo " + "overflow\n", unit, idx); + fatal = true; + } + + if (intstatus & I_PC) { + wiphy_err(wiphy, "wl%d: fifo %d: descriptor error\n", + unit, idx); + fatal = true; + } + + if (intstatus & I_PD) { + wiphy_err(wiphy, "wl%d: fifo %d: data error\n", unit, + idx); + fatal = true; + } + + if (intstatus & I_DE) { + wiphy_err(wiphy, "wl%d: fifo %d: descriptor protocol " + "error\n", unit, idx); + fatal = true; + } + + if (intstatus & I_RU) { + wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor " + "underflow\n", idx, unit); + } + + if (intstatus & I_XU) { + wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo " + "underflow\n", idx, unit); + fatal = true; + } + + if (fatal) { + brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ + break; + } else + W_REG(®s->intctrlregs[idx].intstatus, + intstatus); + } +} + +void brcms_c_intrson(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + wlc->macintmask = wlc->defmacintmask; + W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); +} + +/* callback for siutils.c, which has only wlc handler, no wl + * they both check up, not only because there is no need to off/restore d11 interrupt + * but also because per-port code may require sync with valid interrupt. + */ + +static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc) +{ + if (!wlc->hw->up) + return 0; + + return brcms_intrsoff(wlc->wl); +} + +static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask) +{ + if (!wlc->hw->up) + return; + + brcms_intrsrestore(wlc->wl, macintmask); +} + +u32 brcms_c_intrsoff(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + u32 macintmask; + + if (!wlc_hw->clk) + return 0; + + macintmask = wlc->macintmask; /* isr can still happen */ + + W_REG(&wlc_hw->regs->macintmask, 0); + (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ + udelay(1); /* ensure int line is no longer driven */ + wlc->macintmask = 0; + + /* return previous macintmask; resolve race between us and our isr */ + return wlc->macintstatus ? 0 : macintmask; +} + +void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + if (!wlc_hw->clk) + return; + + wlc->macintmask = macintmask; + W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); +} + +static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, mbool flags) +{ + u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + + if (on) { + /* suspend tx fifos */ + brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); + brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); + brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_BK_FIFO); + brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_VI_FIFO); + + /* zero the address match register so we do not send ACKs */ + brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, + null_ether_addr); + } else { + /* resume tx fifos */ + if (!wlc_hw->wlc->tx_suspended) { + brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); + } + brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); + brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); + brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); + + /* Restore address */ + brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, + wlc_hw->etheraddr); + } + + wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); + + if (on) + brcms_c_ucode_mute_override_set(wlc_hw); + else + brcms_c_ucode_mute_override_clear(wlc_hw); +} + +int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, + uint *blocks) +{ + if (fifo >= NFIFO) + return -EINVAL; + + *blocks = wlc_hw->xmtfifo_sz[fifo]; + + return 0; +} + +/* brcms_b_tx_fifo_suspended: + * Check the MAC's tx suspend status for a tx fifo. + * + * When the MAC acknowledges a tx suspend, it indicates that no more + * packets will be transmitted out the radio. This is independent of + * DMA channel suspension---the DMA may have finished suspending, or may still + * be pulling data into a tx fifo, by the time the MAC acks the suspend + * request. + */ +static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + /* check that a suspend has been requested and is no longer pending */ + + /* + * for DMA mode, the suspend request is set in xmtcontrol of the DMA engine, + * and the tx fifo suspend at the lower end of the MAC is acknowledged in the + * chnstatus register. + * The tx fifo suspend completion is independent of the DMA suspend completion and + * may be acked before or after the DMA is suspended. + */ + if (dma_txsuspended(wlc_hw->di[tx_fifo]) && + (R_REG(&wlc_hw->regs->chnstatus) & + (1 << tx_fifo)) == 0) + return true; + + return false; +} + +static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + u8 fifo = 1 << tx_fifo; + + /* Two clients of this code, 11h Quiet period and scanning. */ + + /* only suspend if not already suspended */ + if ((wlc_hw->suspended_fifos & fifo) == fifo) + return; + + /* force the core awake only if not already */ + if (wlc_hw->suspended_fifos == 0) + brcms_c_ucode_wake_override_set(wlc_hw, + BRCMS_WAKE_OVERRIDE_TXFIFO); + + wlc_hw->suspended_fifos |= fifo; + + if (wlc_hw->di[tx_fifo]) { + /* Suspending AMPDU transmissions in the middle can cause underflow + * which may result in mismatch between ucode and driver + * so suspend the mac before suspending the FIFO + */ + if (BRCMS_PHY_11N_CAP(wlc_hw->band)) + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + + dma_txsuspend(wlc_hw->di[tx_fifo]); + + if (BRCMS_PHY_11N_CAP(wlc_hw->band)) + brcms_c_enable_mac(wlc_hw->wlc); + } +} + +static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case + * but need to be done here for PIO otherwise the watchdog will catch + * the inconsistency and fire + */ + /* Two clients of this code, 11h Quiet period and scanning. */ + if (wlc_hw->di[tx_fifo]) + dma_txresume(wlc_hw->di[tx_fifo]); + + /* allow core to sleep again */ + if (wlc_hw->suspended_fifos == 0) + return; + else { + wlc_hw->suspended_fifos &= ~(1 << tx_fifo); + if (wlc_hw->suspended_fifos == 0) + brcms_c_ucode_wake_override_clear(wlc_hw, + BRCMS_WAKE_OVERRIDE_TXFIFO); + } +} + +/* + * Read and clear macintmask and macintstatus and intstatus registers. + * This routine should be called with interrupts off + * Return: + * -1 if DEVICEREMOVED(wlc) evaluates to true; + * 0 if the interrupt is not for us, or we are in some special cases; + * device interrupt status bits otherwise. + */ +static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs = wlc_hw->regs; + u32 macintstatus; + + /* macintstatus includes a DMA interrupt summary bit */ + macintstatus = R_REG(®s->macintstatus); + + BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, + macintstatus); + + /* detect cardbus removed, in power down(suspend) and in reset */ + if (DEVICEREMOVED(wlc)) + return -1; + + /* DEVICEREMOVED succeeds even when the core is still resetting, + * handle that case here. + */ + if (macintstatus == 0xffffffff) + return 0; + + /* defer unsolicited interrupts */ + macintstatus &= (in_isr ? wlc->macintmask : wlc->defmacintmask); + + /* if not for us */ + if (macintstatus == 0) + return 0; + + /* interrupts are already turned off for CFE build + * Caution: For CFE Turning off the interrupts again has some undesired + * consequences + */ + /* turn off the interrupts */ + W_REG(®s->macintmask, 0); + (void)R_REG(®s->macintmask); /* sync readback */ + wlc->macintmask = 0; + + /* clear device interrupts */ + W_REG(®s->macintstatus, macintstatus); + + /* MI_DMAINT is indication of non-zero intstatus */ + if (macintstatus & MI_DMAINT) { + /* + * only fifo interrupt enabled is I_RI in + * RX_FIFO. If MI_DMAINT is set, assume it + * is set and clear the interrupt. + */ + W_REG(®s->intctrlregs[RX_FIFO].intstatus, + DEF_RXINTMASK); + } + + return macintstatus; +} + +/* Update wlc->macintstatus and wlc->intstatus[]. */ +/* Return true if they are updated successfully. false otherwise */ +bool brcms_c_intrsupd(struct brcms_c_info *wlc) +{ + u32 macintstatus; + + /* read and clear macintstatus and intstatus registers */ + macintstatus = wlc_intstatus(wlc, false); + + /* device is removed */ + if (macintstatus == 0xffffffff) + return false; + + /* update interrupt status in software */ + wlc->macintstatus |= macintstatus; + + return true; +} + +/* + * First-level interrupt processing. + * Return true if this was our interrupt, false otherwise. + * *wantdpc will be set to true if further brcms_c_dpc() processing is required, + * false otherwise. + */ +bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + u32 macintstatus; + + *wantdpc = false; + + if (!wlc_hw->up || !wlc->macintmask) + return false; + + /* read and clear macintstatus and intstatus registers */ + macintstatus = wlc_intstatus(wlc, true); + + if (macintstatus == 0xffffffff) + wiphy_err(wlc->wiphy, "DEVICEREMOVED detected in the ISR code" + " path\n"); + + /* it is not for us */ + if (macintstatus == 0) + return false; + + *wantdpc = true; + + /* save interrupt status bits */ + wlc->macintstatus = macintstatus; + + return true; + +} + +static bool +brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, + u32 s2) +{ + /* discard intermediate indications for ucode with one legitimate case: + * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent + * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts + * transmission count) + */ + if (!(txs->status & TX_STATUS_AMPDU) + && (txs->status & TX_STATUS_INTERMEDIATE)) { + return false; + } + + return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); +} + +/* process tx completion events in BMAC + * Return true if more tx status need to be processed. false otherwise. + */ +static bool +brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) +{ + bool morepending = false; + struct brcms_c_info *wlc = wlc_hw->wlc; + d11regs_t *regs; + struct tx_status txstatus, *txs; + u32 s1, s2; + uint n = 0; + /* + * Param 'max_tx_num' indicates max. # tx status to process before + * break out. + */ + uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + txs = &txstatus; + regs = wlc_hw->regs; + while (!(*fatal) + && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { + + if (s1 == 0xffffffff) { + wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", + wlc_hw->unit, __func__); + return morepending; + } + + s2 = R_REG(®s->frmtxstatus2); + + txs->status = s1 & TXS_STATUS_MASK; + txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; + txs->sequence = s2 & TXS_SEQ_MASK; + txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; + txs->lasttxtime = 0; + + *fatal = brcms_b_dotxstatus(wlc_hw, txs, s2); + + /* !give others some time to run! */ + if (++n >= max_tx_num) + break; + } + + if (*fatal) + return 0; + + if (n >= max_tx_num) + morepending = true; + + if (!pktq_empty(&wlc->pkt_queue->q)) + brcms_c_send_q(wlc); + + return morepending; +} + +void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs = wlc_hw->regs; + u32 mc, mi; + struct wiphy *wiphy = wlc->wiphy; + + BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, + wlc_hw->band->bandunit); + + /* + * Track overlapping suspend requests + */ + wlc_hw->mac_suspend_depth++; + if (wlc_hw->mac_suspend_depth > 1) + return; + + /* force the core awake */ + brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); + + mc = R_REG(®s->maccontrol); + + if (mc == 0xffffffff) { + wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, + __func__); + brcms_down(wlc->wl); + return; + } + WARN_ON(mc & MCTL_PSM_JMP_0); + WARN_ON(!(mc & MCTL_PSM_RUN)); + WARN_ON(!(mc & MCTL_EN_MAC)); + + mi = R_REG(®s->macintstatus); + if (mi == 0xffffffff) { + wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, + __func__); + brcms_down(wlc->wl); + return; + } + WARN_ON(mi & MI_MACSSPNDD); + + brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); + + SPINWAIT(!(R_REG(®s->macintstatus) & MI_MACSSPNDD), + BRCMS_MAX_MAC_SUSPEND); + + if (!(R_REG(®s->macintstatus) & MI_MACSSPNDD)) { + wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" + " and MI_MACSSPNDD is still not on.\n", + wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); + wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " + "psm_brc 0x%04x\n", wlc_hw->unit, + R_REG(®s->psmdebug), + R_REG(®s->phydebug), + R_REG(®s->psm_brc)); + } + + mc = R_REG(®s->maccontrol); + if (mc == 0xffffffff) { + wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, + __func__); + brcms_down(wlc->wl); + return; + } + WARN_ON(mc & MCTL_PSM_JMP_0); + WARN_ON(!(mc & MCTL_PSM_RUN)); + WARN_ON(mc & MCTL_EN_MAC); +} + +void brcms_c_enable_mac(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs = wlc_hw->regs; + u32 mc, mi; + + BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, + wlc->band->bandunit); + + /* + * Track overlapping suspend requests + */ + wlc_hw->mac_suspend_depth--; + if (wlc_hw->mac_suspend_depth > 0) + return; + + mc = R_REG(®s->maccontrol); + WARN_ON(mc & MCTL_PSM_JMP_0); + WARN_ON(mc & MCTL_EN_MAC); + WARN_ON(!(mc & MCTL_PSM_RUN)); + + brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); + W_REG(®s->macintstatus, MI_MACSSPNDD); + + mc = R_REG(®s->maccontrol); + WARN_ON(mc & MCTL_PSM_JMP_0); + WARN_ON(!(mc & MCTL_EN_MAC)); + WARN_ON(!(mc & MCTL_PSM_RUN)); + + mi = R_REG(®s->macintstatus); + WARN_ON(mi & MI_MACSSPNDD); + + brcms_c_ucode_wake_override_clear(wlc_hw, + BRCMS_WAKE_OVERRIDE_MACSUSPEND); +} + +static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) +{ + u8 rate; + u8 rates[8] = { + BRCM_RATE_6M, BRCM_RATE_9M, BRCM_RATE_12M, BRCM_RATE_18M, + BRCM_RATE_24M, BRCM_RATE_36M, BRCM_RATE_48M, BRCM_RATE_54M + }; + u16 entry_ptr; + u16 pctl1; + uint i; + + if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) + return; + + /* walk the phy rate table and update the entries */ + for (i = 0; i < ARRAY_SIZE(rates); i++) { + rate = rates[i]; + + entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); + + /* read the SHM Rate Table entry OFDM PCTL1 values */ + pctl1 = + brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); + + /* modify the value */ + pctl1 &= ~PHY_TXC1_MODE_MASK; + pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); + + /* Update the SHM Rate Table entry OFDM PCTL1 values */ + brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, + pctl1); + } +} + +static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, + u8 rate) +{ + uint i; + u8 plcp_rate = 0; + struct plcp_signal_rate_lookup { + u8 rate; + u8 signal_rate; + }; + /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ + const struct plcp_signal_rate_lookup rate_lookup[] = { + {BRCM_RATE_6M, 0xB}, + {BRCM_RATE_9M, 0xF}, + {BRCM_RATE_12M, 0xA}, + {BRCM_RATE_18M, 0xE}, + {BRCM_RATE_24M, 0x9}, + {BRCM_RATE_36M, 0xD}, + {BRCM_RATE_48M, 0x8}, + {BRCM_RATE_54M, 0xC} + }; + + for (i = 0; i < ARRAY_SIZE(rate_lookup); i++) { + if (rate == rate_lookup[i].rate) { + plcp_rate = rate_lookup[i].signal_rate; + break; + } + } + + /* Find the SHM pointer to the rate table entry by looking in the + * Direct-map Table + */ + return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); +} + +void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) +{ + wlc_hw->hw_stf_ss_opmode = stf_mode; + + if (wlc_hw->clk) + brcms_upd_ofdm_pctl1_table(wlc_hw); +} + +void +brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, + u32 *tsf_h_ptr) +{ + d11regs_t *regs = wlc_hw->regs; + + /* read the tsf timer low, then high to get an atomic read */ + *tsf_l_ptr = R_REG(®s->tsf_timerlow); + *tsf_h_ptr = R_REG(®s->tsf_timerhigh); + + return; +} + +static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) +{ + d11regs_t *regs; + u32 w, val; + struct wiphy *wiphy = wlc_hw->wlc->wiphy; + + BCMMSG(wiphy, "wl%d\n", wlc_hw->unit); + + regs = wlc_hw->regs; + + /* Validate dchip register access */ + + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + w = R_REG(®s->objdata); + + /* Can we write and read back a 32bit register? */ + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, (u32) 0xaa5555aa); + + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + val = R_REG(®s->objdata); + if (val != (u32) 0xaa5555aa) { + wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " + "expected 0xaa5555aa\n", wlc_hw->unit, val); + return false; + } + + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, (u32) 0x55aaaa55); + + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + val = R_REG(®s->objdata); + if (val != (u32) 0x55aaaa55) { + wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " + "expected 0x55aaaa55\n", wlc_hw->unit, val); + return false; + } + + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, w); + + /* clear CFPStart */ + W_REG(®s->tsf_cfpstart, 0); + + w = R_REG(®s->maccontrol); + if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && + (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { + wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = " + "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, + (MCTL_IHR_EN | MCTL_WAKE), + (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE)); + return false; + } + + return true; +} + +#define PHYPLL_WAIT_US 100000 + +void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) +{ + d11regs_t *regs; + u32 tmp; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + tmp = 0; + regs = wlc_hw->regs; + + if (on) { + if ((wlc_hw->sih->chip == BCM4313_CHIP_ID)) { + OR_REG(®s->clk_ctl_st, + (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | + CCS_ERSRC_REQ_PHYPLL)); + SPINWAIT((R_REG(®s->clk_ctl_st) & + (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), + PHYPLL_WAIT_US); + + tmp = R_REG(®s->clk_ctl_st); + if ((tmp & (CCS_ERSRC_AVAIL_HT)) != + (CCS_ERSRC_AVAIL_HT)) { + wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" + " PLL failed\n", __func__); + } + } else { + OR_REG(®s->clk_ctl_st, + (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); + SPINWAIT((R_REG(®s->clk_ctl_st) & + (CCS_ERSRC_AVAIL_D11PLL | + CCS_ERSRC_AVAIL_PHYPLL)) != + (CCS_ERSRC_AVAIL_D11PLL | + CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); + + tmp = R_REG(®s->clk_ctl_st); + if ((tmp & + (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) + != + (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) { + wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on " + "PHY PLL failed\n", __func__); + } + } + } else { + /* Since the PLL may be shared, other cores can still be requesting it; + * so we'll deassert the request but not wait for status to comply. + */ + AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); + tmp = R_REG(®s->clk_ctl_st); + } +} + +void brcms_c_coredisable(struct brcms_hardware *wlc_hw) +{ + bool dev_gone; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + dev_gone = DEVICEREMOVED(wlc_hw->wlc); + + if (dev_gone) + return; + + if (wlc_hw->noreset) + return; + + /* radio off */ + wlc_phy_switch_radio(wlc_hw->band->pi, OFF); + + /* turn off analog core */ + wlc_phy_anacore(wlc_hw->band->pi, OFF); + + /* turn off PHYPLL to save power */ + brcms_b_core_phypll_ctl(wlc_hw, false); + + /* No need to set wlc->pub->radio_active = OFF + * because this function needs down capability and + * radio_active is designed for BCMNODOWN. + */ + + /* remove gpio controls */ + if (wlc_hw->ucode_dbgsel) + ai_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY); + + wlc_hw->clk = false; + ai_core_disable(wlc_hw->sih, 0); + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); +} + +/* power both the pll and external oscillator on/off */ +static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); + + /* dont power down if plldown is false or we must poll hw radio disable */ + if (!want && wlc_hw->pllreq) + return; + + if (wlc_hw->sih) + ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want); + + wlc_hw->sbclk = want; + if (!wlc_hw->sbclk) { + wlc_hw->clk = false; + if (wlc_hw->band && wlc_hw->band->pi) + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); + } +} + +static void brcms_c_flushqueues(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + uint i; + + wlc->txpend16165war = 0; + + /* free any posted tx packets */ + for (i = 0; i < NFIFO; i++) + if (wlc_hw->di[i]) { + dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); + TXPKTPENDCLR(wlc, i); + BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); + } + + /* free any posted rx packets */ + dma_rxreclaim(wlc_hw->di[RX_FIFO]); +} + +u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) +{ + return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); +} + +void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) +{ + brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); +} + +static u16 +brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) +{ + d11regs_t *regs = wlc_hw->regs; + volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; + volatile u16 *objdata_hi = objdata_lo + 1; + u16 v; + + W_REG(®s->objaddr, sel | (offset >> 2)); + (void)R_REG(®s->objaddr); + if (offset & 2) { + v = R_REG(objdata_hi); + } else { + v = R_REG(objdata_lo); + } + + return v; +} + +static void +brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, + u32 sel) +{ + d11regs_t *regs = wlc_hw->regs; + volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; + volatile u16 *objdata_hi = objdata_lo + 1; + + W_REG(®s->objaddr, sel | (offset >> 2)); + (void)R_REG(®s->objaddr); + if (offset & 2) { + W_REG(objdata_hi, v); + } else { + W_REG(objdata_lo, v); + } +} + +/* Copy a buffer to shared memory of specified type . + * SHM 'offset' needs to be an even address and + * Buffer length 'len' must be an even number of bytes + * 'sel' selects the type of memory + */ +void +brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset, + const void *buf, int len, u32 sel) +{ + u16 v; + const u8 *p = (const u8 *)buf; + int i; + + if (len <= 0 || (offset & 1) || (len & 1)) + return; + + for (i = 0; i < len; i += 2) { + v = p[i] | (p[i + 1] << 8); + brcms_b_write_objmem(wlc_hw, offset + i, v, sel); + } +} + +/* Copy a piece of shared memory of specified type to a buffer . + * SHM 'offset' needs to be an even address and + * Buffer length 'len' must be an even number of bytes + * 'sel' selects the type of memory + */ +void +brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, + int len, u32 sel) +{ + u16 v; + u8 *p = (u8 *) buf; + int i; + + if (len <= 0 || (offset & 1) || (len & 1)) + return; + + for (i = 0; i < len; i += 2) { + v = brcms_b_read_objmem(wlc_hw, offset + i, sel); + p[i] = v & 0xFF; + p[i + 1] = (v >> 8) & 0xFF; + } +} + +void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, + uint *len) +{ + BCMMSG(wlc_hw->wlc->wiphy, "nvram vars totlen=%d\n", + wlc_hw->vars_size); + + *buf = wlc_hw->vars; + *len = wlc_hw->vars_size; +} + +void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) +{ + wlc_hw->SRL = SRL; + wlc_hw->LRL = LRL; + + /* write retry limit to SCR, shouldn't need to suspend */ + if (wlc_hw->up) { + W_REG(&wlc_hw->regs->objaddr, + OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); + W_REG(&wlc_hw->regs->objaddr, + OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); + } +} + +void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, mbool req_bit) +{ + if (set) { + if (mboolisset(wlc_hw->pllreq, req_bit)) + return; + + mboolset(wlc_hw->pllreq, req_bit); + + if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { + if (!wlc_hw->sbclk) { + brcms_b_xtal(wlc_hw, ON); + } + } + } else { + if (!mboolisset(wlc_hw->pllreq, req_bit)) + return; + + mboolclr(wlc_hw->pllreq, req_bit); + + if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { + if (wlc_hw->sbclk) { + brcms_b_xtal(wlc_hw, OFF); + } + } + } + + return; +} + +u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) +{ + u16 table_ptr; + u8 phy_rate, index; + + /* get the phy specific rate encoding for the PLCP SIGNAL field */ + if (IS_OFDM(rate)) + table_ptr = M_RT_DIRMAP_A; + else + table_ptr = M_RT_DIRMAP_B; + + /* for a given rate, the LS-nibble of the PLCP SIGNAL field is + * the index into the rate table. + */ + phy_rate = rate_info[rate] & BRCMS_RATE_MASK; + index = phy_rate & 0xf; + + /* Find the SHM pointer to the rate table entry by looking in the + * Direct-map Table + */ + return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); +} + +void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) +{ + wlc_hw->antsel_avail = antsel_avail; +} + /* conditions under which the PM bit should be set in outgoing frames and STAY_AWAKE is meaningful */ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) @@ -1303,7 +4930,7 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) static bool brcms_c_state_bmac_sync(struct brcms_c_info *wlc) { - struct brcms_b_state state_bmac; + struct brcms_b_state state_bmac = {0}; if (brcms_b_state_get(wlc->hw, &state_bmac) != 0) return false; diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index f204b1f4747..bf36f10998c 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -242,6 +242,12 @@ extern const u8 prio2fifo[]; #define BRCMS_UNIT(wlc) ((wlc)->pub->unit) +#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ + brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) + +#define brcms_b_copyto_shm(wlc_hw, offset, buf, len) \ + brcms_b_copyto_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) + struct brcms_protection { bool _g; /* use g spec protection, driver internal */ s8 g_override; /* override for use of g spec protection */ @@ -1022,4 +1028,47 @@ extern bool brcms_c_stay_awake(struct brcms_c_info *wlc); extern void brcms_c_wme_initparams_sta(struct brcms_c_info *wlc, struct wme_param_ie *pe); +extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, + u8 antsel_type); + +/* chanspec, ucode interface */ +extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, + chanspec_t chanspec, + bool mute, struct txpwr_limits *txpwr); + +extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, + u16 v); +extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset); + +extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, + u16 val, int bands); + +extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags); + +extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val); + +extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw); +extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw); +extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw); +extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, + u32 override_bit); +extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, + u32 override_bit); +extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, + int offset, int len, void *buf); +extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate); +extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, + uint offset, const void *buf, int len, + u32 sel); +extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, + void *buf, int len, u32 sel); +extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode); +extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw); +extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk); +extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk); +extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on); +extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant); +extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, + u8 stf_mode); + #endif /* _BRCM_MAIN_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index 82ecdcda271..56824f43605 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -23,7 +23,6 @@ #include #include -#include "bmac.h" #include "main.h" #include "mac80211_if.h" #include "phy_shim.h" diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index a55ff010178..84fca47438c 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -22,7 +22,6 @@ #include "phy/phy_hal.h" #include "channel.h" #include "main.h" -#include "bmac.h" #include "stf.h" #define MIN_SPATIAL_EXPANSION 0 From 839f9f6202e1d46abd83e54e2572ea5cc7484846 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:48 +0200 Subject: [PATCH 0026/1519] staging: brcm80211: shuffled sections in main.c Moved bmac functions above 'common' functions invoking them. This facilitates merging these functions in a later commit. Also declared locally used functions static. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 2250 ++++++++++----------- 1 file changed, 1092 insertions(+), 1158 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 8399bf308eb..bd3d5f092eb 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -271,7 +271,6 @@ struct brcms_b_state { /* local prototypes */ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc, uint mode); -static void brcms_b_coreinit(struct brcms_c_info *wlc); /* used by wlc_wakeucode_init() */ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, @@ -281,13 +280,6 @@ static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], static void brcms_ucode_download(struct brcms_hardware *wlc); static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw); -/* used by brcms_c_dpc() */ -static bool brcms_b_dotxstatus(struct brcms_hardware *wlc, - struct tx_status *txs, u32 s2); -static bool brcms_b_txstatus(struct brcms_hardware *wlc, bool bound, - bool *fatal); -static bool brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound); - /* used by brcms_c_down() */ static void brcms_c_flushqueues(struct brcms_c_info *wlc); @@ -296,8 +288,6 @@ static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw); static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw); static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, uint tx_fifo); -static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, - uint tx_fifo); static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, uint tx_fifo); @@ -305,66 +295,38 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, struct brcms_b_state; -extern int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, +static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, bool piomode, void *regsva, uint bustype, void *btparam); -extern int brcms_b_detach(struct brcms_c_info *wlc); -extern void brcms_b_watchdog(void *arg); /* up/down, reset, clk */ -extern void brcms_b_reset(struct brcms_hardware *wlc_hw); -extern void brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute); -extern int brcms_b_up_prep(struct brcms_hardware *wlc_hw); -extern int brcms_b_up_finish(struct brcms_hardware *wlc_hw); -extern int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw); -extern int brcms_b_down_finish(struct brcms_hardware *wlc_hw); - -extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks); -extern u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands); -extern int brcms_b_state_get(struct brcms_hardware *wlc_hw, +static void brcms_b_reset(struct brcms_hardware *wlc_hw); +static int brcms_b_state_get(struct brcms_hardware *wlc_hw, struct brcms_b_state *state); -extern void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, +static void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, uint *len); -extern void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, +static void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea); -extern bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw); -extern void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, - bool shortslot); +static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw); +static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw); -extern void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw); - -extern void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, +static void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, const u8 *addr); -extern void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, - void *bcn, int len, bool both); +static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin); +static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax); -extern void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, - u32 *tsf_h_ptr); -extern void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin); -extern void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax); - -extern void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, +static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL); -extern void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); +static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); - -/* API for BMAC driver (e.g. wlc_phy.c etc) */ - -extern void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, +static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, mbool req_bit); -extern void brcms_b_hw_up(struct brcms_hardware *wlc_hw); -extern void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, +static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail); - - - - static int brcms_b_bandtype(struct brcms_hardware *wlc_hw); static void brcms_b_info_init(struct brcms_hardware *wlc_hw); static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want); @@ -546,19 +508,6 @@ static const char fifo_names[6][0]; static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); #endif -/* === Low Level functions === */ - -void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) -{ - wlc_hw->shortslot = shortslot; - - if (BAND_2G(brcms_b_bandtype(wlc_hw)) && wlc_hw->up) { - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - brcms_b_update_slot_timing(wlc_hw, shortslot); - brcms_c_enable_mac(wlc_hw->wlc); - } -} - /* * Update the slot timing for standard 11b/g (20us slots) * or shortslot 11g (9us slots) @@ -687,6 +636,81 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) return n >= bound_limit; } +static bool +brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, + u32 s2) +{ + /* discard intermediate indications for ucode with one legitimate case: + * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent + * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts + * transmission count) + */ + if (!(txs->status & TX_STATUS_AMPDU) + && (txs->status & TX_STATUS_INTERMEDIATE)) { + return false; + } + + return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); +} + +/* process tx completion events in BMAC + * Return true if more tx status need to be processed. false otherwise. + */ +static bool +brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) +{ + bool morepending = false; + struct brcms_c_info *wlc = wlc_hw->wlc; + d11regs_t *regs; + struct tx_status txstatus, *txs; + u32 s1, s2; + uint n = 0; + /* + * Param 'max_tx_num' indicates max. # tx status to process before + * break out. + */ + uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + txs = &txstatus; + regs = wlc_hw->regs; + while (!(*fatal) + && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { + + if (s1 == 0xffffffff) { + wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", + wlc_hw->unit, __func__); + return morepending; + } + + s2 = R_REG(®s->frmtxstatus2); + + txs->status = s1 & TXS_STATUS_MASK; + txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; + txs->sequence = s2 & TXS_SEQ_MASK; + txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; + txs->lasttxtime = 0; + + *fatal = brcms_b_dotxstatus(wlc_hw, txs, s2); + + /* !give others some time to run! */ + if (++n >= max_tx_num) + break; + } + + if (*fatal) + return 0; + + if (n >= max_tx_num) + morepending = true; + + if (!pktq_empty(&wlc->pkt_queue->q)) + brcms_c_send_q(wlc); + + return morepending; +} + /* second-level interrupt processing * Return true if another dpc needs to be re-scheduled. false otherwise. * Param 'bounded' indicates if applicable loops should be bounded. @@ -790,73 +814,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) return wlc->macintstatus != 0; } -/* common low-level watchdog code */ -void brcms_b_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return; - - /* increment second count */ - wlc_hw->now++; - - /* Check for FIFO error interrupts */ - brcms_b_fifoerrors(wlc_hw); - - /* make sure RX dma has buffers */ - dma_rxfill(wlc->hw->di[RX_FIFO]); - - wlc_phy_watchdog(wlc_hw->band->pi); -} - -void -brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute, struct txpwr_limits *txpwr) -{ - uint bandunit; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); - - wlc_hw->chanspec = chanspec; - - /* Switch bands if necessary */ - if (NBANDS_HW(wlc_hw) > 1) { - bandunit = CHSPEC_BANDUNIT(chanspec); - if (wlc_hw->band->bandunit != bandunit) { - /* brcms_b_setband disables other bandunit, - * use light band switch if not up yet - */ - if (wlc_hw->up) { - wlc_phy_chanspec_radio_set(wlc_hw-> - bandstate[bandunit]-> - pi, chanspec); - brcms_b_setband(wlc_hw, bandunit, chanspec); - } else { - brcms_c_setxband(wlc_hw, bandunit); - } - } - } - - wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); - - if (!wlc_hw->up) { - if (wlc_hw->clk) - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, - chanspec); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - } else { - wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); - - /* Update muting of the channel */ - brcms_b_mute(wlc_hw, mute, 0); - } -} - int brcms_b_state_get(struct brcms_hardware *wlc_hw, struct brcms_b_state *state) { @@ -974,356 +931,6 @@ static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw) } } -/* low level attach - * run backplane attach, init nvram - * run phy attach - * initialize software state for each core and band - * put the whole chip in reset(driver down state), no clock - */ -int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, uint bustype, void *btparam) -{ - struct brcms_hardware *wlc_hw; - d11regs_t *regs; - char *macaddr = NULL; - char *vars; - uint err = 0; - uint j; - bool wme = false; - struct shared_phy_params sha_params; - struct wiphy *wiphy = wlc->wiphy; - - BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, - device); - - wme = true; - - wlc_hw = wlc->hw; - wlc_hw->wlc = wlc; - wlc_hw->unit = unit; - wlc_hw->band = wlc_hw->bandstate[0]; - wlc_hw->_piomode = piomode; - - /* populate struct brcms_hardware with default values */ - brcms_b_info_init(wlc_hw); - - /* - * Do the hardware portion of the attach. - * Also initialize software state that depends on the particular hardware - * we are running. - */ - wlc_hw->sih = ai_attach(regsva, bustype, btparam, - &wlc_hw->vars, &wlc_hw->vars_size); - if (wlc_hw->sih == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", - unit); - err = 11; - goto fail; - } - vars = wlc_hw->vars; - - /* - * Get vendid/devid nvram overwrites, which could be different - * than those the BIOS recognizes for devices on PCMCIA_BUS, - * SDIO_BUS, and SROMless devices on PCI_BUS. - */ -#ifdef BCMBUSTYPE - bustype = BCMBUSTYPE; -#endif - if (bustype != SI_BUS) { - char *var; - - var = getvar(vars, "vendid"); - if (var) { - vendor = (u16) simple_strtoul(var, NULL, 0); - wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", - vendor); - } - var = getvar(vars, "devid"); - if (var) { - u16 devid = (u16) simple_strtoul(var, NULL, 0); - if (devid != 0xffff) { - device = devid; - wiphy_err(wiphy, "Overriding device id = 0x%x" - "\n", device); - } - } - - /* verify again the device is supported */ - if (!brcms_c_chipmatch(vendor, device)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " - "vendor/device (0x%x/0x%x)\n", - unit, vendor, device); - err = 12; - goto fail; - } - } - - wlc_hw->vendorid = vendor; - wlc_hw->deviceid = device; - - /* set bar0 window to point at D11 core */ - wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - wlc_hw->corerev = ai_corerev(wlc_hw->sih); - - regs = wlc_hw->regs; - - wlc->regs = wlc_hw->regs; - - /* validate chip, chiprev and corerev */ - if (!brcms_c_isgoodchip(wlc_hw)) { - err = 13; - goto fail; - } - - /* initialize power control registers */ - ai_clkctl_init(wlc_hw->sih); - - /* request fastclock and force fastclock for the rest of attach - * bring the d11 core out of reset. - * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk is still false; - * But it will be called again inside wlc_corereset, after d11 is out of reset. - */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - if (!brcms_b_validate_chip_access(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: validate_chip_access " - "failed\n", unit); - err = 14; - goto fail; - } - - /* get the board rev, used just below */ - j = getintvar(vars, "boardrev"); - /* promote srom boardrev of 0xFF to 1 */ - if (j == BOARDREV_PROMOTABLE) - j = BOARDREV_PROMOTED; - wlc_hw->boardrev = (u16) j; - if (!brcms_c_validboardtype(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " - "board type (0x%x)" " or revision level (0x%x)\n", - unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); - err = 15; - goto fail; - } - wlc_hw->sromrev = (u8) getintvar(vars, "sromrev"); - wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); - wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); - - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); - - if ((wlc_hw->sih->bustype == PCI_BUS) - && (ai_pci_war16165(wlc_hw->sih))) - wlc->war16165 = true; - - /* check device id(srom, nvram etc.) to set bands */ - if (wlc_hw->deviceid == BCM43224_D11N_ID || - wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) { - /* Dualband boards */ - wlc_hw->_nbands = 2; - } else - wlc_hw->_nbands = 1; - - if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->_nbands = 1; - - /* BMAC_NOTE: remove init of pub values when brcms_c_attach() - * unconditionally does the init of these values - */ - wlc->vendorid = wlc_hw->vendorid; - wlc->deviceid = wlc_hw->deviceid; - wlc->pub->sih = wlc_hw->sih; - wlc->pub->corerev = wlc_hw->corerev; - wlc->pub->sromrev = wlc_hw->sromrev; - wlc->pub->boardrev = wlc_hw->boardrev; - wlc->pub->boardflags = wlc_hw->boardflags; - wlc->pub->boardflags2 = wlc_hw->boardflags2; - wlc->pub->_nbands = wlc_hw->_nbands; - - wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); - - if (wlc_hw->physhim == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_shim_attach " - "failed\n", unit); - err = 25; - goto fail; - } - - /* pass all the parameters to wlc_phy_shared_attach in one struct */ - sha_params.sih = wlc_hw->sih; - sha_params.physhim = wlc_hw->physhim; - sha_params.unit = unit; - sha_params.corerev = wlc_hw->corerev; - sha_params.vars = vars; - sha_params.vid = wlc_hw->vendorid; - sha_params.did = wlc_hw->deviceid; - sha_params.chip = wlc_hw->sih->chip; - sha_params.chiprev = wlc_hw->sih->chiprev; - sha_params.chippkg = wlc_hw->sih->chippkg; - sha_params.sromrev = wlc_hw->sromrev; - sha_params.boardtype = wlc_hw->sih->boardtype; - sha_params.boardrev = wlc_hw->boardrev; - sha_params.boardvendor = wlc_hw->sih->boardvendor; - sha_params.boardflags = wlc_hw->boardflags; - sha_params.boardflags2 = wlc_hw->boardflags2; - sha_params.bustype = wlc_hw->sih->bustype; - sha_params.buscorerev = wlc_hw->sih->buscorerev; - - /* alloc and save pointer to shared phy state area */ - wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); - if (!wlc_hw->phy_sh) { - err = 16; - goto fail; - } - - /* initialize software state for each core and band */ - for (j = 0; j < NBANDS_HW(wlc_hw); j++) { - /* - * band0 is always 2.4Ghz - * band1, if present, is 5Ghz - */ - - /* So if this is a single band 11a card, use band 1 */ - if (IS_SINGLEBAND_5G(wlc_hw->deviceid)) - j = BAND_5G_INDEX; - - brcms_c_setxband(wlc_hw, j); - - wlc_hw->band->bandunit = j; - wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->band->bandunit = j; - wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->core->coreidx = ai_coreidx(wlc_hw->sih); - - wlc_hw->machwcap = R_REG(®s->machwcap); - wlc_hw->machwcap_backup = wlc_hw->machwcap; - - /* init tx fifo size */ - wlc_hw->xmtfifo_sz = - xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; - - /* Get a phy for this band */ - wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, - (void *)regs, brcms_b_bandtype(wlc_hw), vars, - wlc->wiphy); - if (wlc_hw->band->pi == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" - "attach failed\n", unit); - err = 17; - goto fail; - } - - wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); - - wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, - &wlc_hw->band->phyrev, - &wlc_hw->band->radioid, - &wlc_hw->band->radiorev); - wlc_hw->band->abgphy_encore = - wlc_phy_get_encore(wlc_hw->band->pi); - wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); - wlc_hw->band->core_flags = - wlc_phy_get_coreflags(wlc_hw->band->pi); - - /* verify good phy_type & supported phy revision */ - if (BRCMS_ISNPHY(wlc_hw->band)) { - if (NCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { - if (LCNCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else { - bad_phy: - wiphy_err(wiphy, "wl%d: brcms_b_attach: unsupported " - "phy type/rev (%d/%d)\n", unit, - wlc_hw->band->phytype, wlc_hw->band->phyrev); - err = 18; - goto fail; - } - - good_phy: - /* BMAC_NOTE: wlc->band->pi should not be set below and should be done in the - * high level attach. However we can not make that change until all low level access - * is changed to wlc_hw->band->pi. Instead do the wlc->band->pi init below, keeping - * wlc_hw->band->pi as well for incremental update of low level fns, and cut over - * low only init when all fns updated. - */ - wlc->band->pi = wlc_hw->band->pi; - wlc->band->phytype = wlc_hw->band->phytype; - wlc->band->phyrev = wlc_hw->band->phyrev; - wlc->band->radioid = wlc_hw->band->radioid; - wlc->band->radiorev = wlc_hw->band->radiorev; - - /* default contention windows size limits */ - wlc_hw->band->CWmin = APHY_CWMIN; - wlc_hw->band->CWmax = PHY_CWMAX; - - if (!brcms_b_attach_dmapio(wlc, j, wme)) { - err = 19; - goto fail; - } - } - - /* disable core to match driver "down" state */ - brcms_c_coredisable(wlc_hw); - - /* Match driver "down" state */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - - /* register sb interrupt callback functions */ - ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, - (void *)brcms_c_wlintrsrestore, NULL, wlc); - - /* turn off pll and xtal to match driver "down" state */ - brcms_b_xtal(wlc_hw, OFF); - - /* ********************************************************************* - * The hardware is in the DOWN state at this point. D11 core - * or cores are in reset with clocks off, and the board PLLs - * are off if possible. - * - * Beyond this point, wlc->sbclk == false and chip registers - * should not be touched. - ********************************************************************* - */ - - /* init etheraddr state variables */ - macaddr = brcms_c_get_macaddr(wlc_hw); - if (macaddr == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n", - unit); - err = 21; - goto fail; - } - brcmu_ether_atoe(macaddr, wlc_hw->etheraddr); - if (is_broadcast_ether_addr(wlc_hw->etheraddr) || - is_zero_ether_addr(wlc_hw->etheraddr)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", - unit, macaddr); - err = 22; - goto fail; - } - - BCMMSG(wlc->wiphy, - "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", - wlc_hw->deviceid, wlc_hw->_nbands, - wlc_hw->sih->boardtype, macaddr); - - return err; - - fail: - wiphy_err(wiphy, "wl%d: brcms_b_attach: failed with err %d\n", unit, - err); - return err; -} - /* * Initialize brcms_c_info default values ... * may get overrides later in this function @@ -1348,253 +955,6 @@ static void brcms_b_info_init(struct brcms_hardware *wlc_hw) wlc_hw->chanspec = CH20MHZ_CHSPEC(1); } -/* - * low level detach - */ -int brcms_b_detach(struct brcms_c_info *wlc) -{ - uint i; - struct brcms_hw_band *band; - struct brcms_hardware *wlc_hw = wlc->hw; - int callbacks; - - callbacks = 0; - - if (wlc_hw->sih) { - /* detach interrupt sync mechanism since interrupt is disabled and per-port - * interrupt object may has been freed. this must be done before sb core switch - */ - ai_deregister_intr_callback(wlc_hw->sih); - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_sleep(wlc_hw->sih); - } - - brcms_b_detach_dmapio(wlc_hw); - - band = wlc_hw->band; - for (i = 0; i < NBANDS_HW(wlc_hw); i++) { - if (band->pi) { - /* Detach this band's phy */ - wlc_phy_detach(band->pi); - band->pi = NULL; - } - band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; - } - - /* Free shared phy state */ - kfree(wlc_hw->phy_sh); - - wlc_phy_shim_detach(wlc_hw->physhim); - - /* free vars */ - kfree(wlc_hw->vars); - wlc_hw->vars = NULL; - - if (wlc_hw->sih) { - ai_detach(wlc_hw->sih); - wlc_hw->sih = NULL; - } - - return callbacks; - -} - -void brcms_b_reset(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset the core */ - if (!DEVICEREMOVED(wlc_hw->wlc)) - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - /* purge the dma rings */ - brcms_c_flushqueues(wlc_hw->wlc); - - brcms_c_reset_bmac_done(wlc_hw->wlc); -} - -void -brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, - bool mute) { - u32 macintmask; - bool fastclk; - struct brcms_c_info *wlc = wlc_hw->wlc; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* disable interrupts */ - macintmask = brcms_intrsoff(wlc->wl); - - /* set up the specified band and chanspec */ - brcms_c_setxband(wlc_hw, CHSPEC_BANDUNIT(chanspec)); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - - /* do one-time phy inits and calibration */ - wlc_phy_cal_init(wlc_hw->band->pi); - - /* core-specific initialization */ - brcms_b_coreinit(wlc); - - /* suspend the tx fifos and mute the phy for preism cac time */ - if (mute) - brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); - - /* band-specific inits */ - brcms_b_bsinit(wlc, chanspec); - - /* restore macintmask */ - brcms_intrsrestore(wlc->wl, macintmask); - - /* seed wake_override with BRCMS_WAKE_OVERRIDE_MACSUSPEND since the mac - * is suspended and brcms_c_enable_mac() will clear this override bit. - */ - mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - - /* - * initialize mac_suspend_depth to 1 to match ucode initial suspended state - */ - wlc_hw->mac_suspend_depth = 1; - - /* restore the clk */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -int brcms_b_up_prep(struct brcms_hardware *wlc_hw) -{ - uint coremask; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* - * Configure pci/pcmcia here instead of in brcms_c_attach() - * to allow mfg hotswap: down, hotswap (chip power cycle), up. - */ - coremask = (1 << wlc_hw->wlc->core->coreidx); - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_setup(wlc_hw->sih, coremask); - - /* - * Need to read the hwradio status here to cover the case where the system - * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. - */ - if (brcms_b_radio_read_hwdisabled(wlc_hw)) { - /* put SB PCI in down state again */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - return -ENOMEDIUM; - } - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_up(wlc_hw->sih); - - /* reset the d11 core */ - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - return 0; -} - -int brcms_b_up_finish(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - wlc_hw->up = true; - wlc_phy_hw_state_upd(wlc_hw->band->pi, true); - - /* FULLY enable dynamic power control and d11 core interrupt */ - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); - brcms_intrson(wlc_hw->wlc->wl); - return 0; -} - -int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) -{ - bool dev_gone; - uint callbacks = 0; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - dev_gone = DEVICEREMOVED(wlc_hw->wlc); - - /* disable interrupts */ - if (dev_gone) - wlc_hw->wlc->macintmask = 0; - else { - /* now disable interrupts */ - brcms_intrsoff(wlc_hw->wlc->wl); - - /* ensure we're running on the pll clock again */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - } - /* down phy at the last of this stage */ - callbacks += wlc_phy_down(wlc_hw->band->pi); - - return callbacks; -} - -int brcms_b_down_finish(struct brcms_hardware *wlc_hw) -{ - uint callbacks = 0; - bool dev_gone; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - wlc_hw->up = false; - wlc_phy_hw_state_upd(wlc_hw->band->pi, false); - - dev_gone = DEVICEREMOVED(wlc_hw->wlc); - - if (dev_gone) { - wlc_hw->sbclk = false; - wlc_hw->clk = false; - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - - /* reclaim any posted packets */ - brcms_c_flushqueues(wlc_hw->wlc); - } else { - - /* Reset and disable the core */ - if (ai_iscoreup(wlc_hw->sih)) { - if (R_REG(&wlc_hw->regs->maccontrol) & - MCTL_EN_MAC) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - callbacks += brcms_reset(wlc_hw->wlc->wl); - brcms_c_coredisable(wlc_hw); - } - - /* turn off primary xtal and pll */ - if (!wlc_hw->noreset) { - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - } - } - - return callbacks; -} - void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) { /* delay before first read of ucode state */ @@ -1769,32 +1129,6 @@ brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, } } -u16 brcms_b_mhf_get(struct brcms_hardware *wlc_hw, u8 idx, int bands) -{ - struct brcms_hw_band *band; - - if (idx >= MHFMAX) - return 0; /* error condition */ - switch (bands) { - case BRCM_BAND_AUTO: - band = wlc_hw->band; - break; - case BRCM_BAND_5G: - band = wlc_hw->bandstate[BAND_5G_INDEX]; - break; - case BRCM_BAND_2G: - band = wlc_hw->bandstate[BAND_2G_INDEX]; - break; - default: - band = NULL; /* error condition */ - } - - if (!band) - return 0; - - return band->mhfs[idx]; -} - static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) { u8 idx; @@ -2055,27 +1389,6 @@ brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, OR_REG(®s->maccommand, MCMD_BCN1VLD); } -/* mac is assumed to be suspended at this point */ -void -brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, - int len, bool both) -{ - d11regs_t *regs = wlc_hw->regs; - - if (both) { - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } else { - /* bcn 0 */ - if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - /* bcn 1 */ - else if (! - (R_REG(®s->maccommand) & MCMD_BCN1VLD)) - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } -} - static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) { u16 v; @@ -2403,48 +1716,6 @@ bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) return v; } -/* Initialize just the hardware when coming out of POR or S3/S5 system states */ -void brcms_b_hw_up(struct brcms_hardware *wlc_hw) -{ - if (wlc_hw->wlc->pub->hw_up) - return; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - if (wlc_hw->sih->bustype == PCI_BUS) { - ai_pci_fixcfg(wlc_hw->sih); - - /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = - (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); - } - - /* Inform phy that a POR reset has occurred so it does a complete phy init */ - wlc_phy_por_inform(wlc_hw->band->pi); - - wlc_hw->ucode_loaded = false; - wlc_hw->wlc->pub->hw_up = true; - - if ((wlc_hw->boardflags & BFL_FEM) - && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - if (! - (wlc_hw->boardrev >= 0x1250 - && (wlc_hw->boardflags & BFL_FEM_BT))) - ai_epa_4313war(wlc_hw->sih); - } -} - static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) { struct dma_pub *di = wlc_hw->di[fifo]; @@ -2589,191 +1860,6 @@ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) xmtfifo_sz[TX_BCMC_FIFO])); } -/* d11 core init - * reset PSM - * download ucode/PCM - * let ucode run to suspended - * download ucode inits - * config other core registers - * init dma - */ -static void brcms_b_coreinit(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs; - u32 sflags; - uint bcnint_us; - uint i = 0; - bool fifosz_fixup = false; - int err = 0; - u16 buf[NFIFO]; - struct wiphy *wiphy = wlc->wiphy; - - regs = wlc_hw->regs; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset PSM */ - brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); - - brcms_ucode_download(wlc_hw); - /* - * FIFOSZ fixup. driver wants to controls the fifo allocation. - */ - fifosz_fixup = true; - - /* let the PSM run to the suspended state, set mode to BSS STA */ - W_REG(®s->macintstatus, -1); - brcms_b_mctrl(wlc_hw, ~0, - (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); - - /* wait for ucode to self-suspend after auto-init */ - SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), - 1000 * 1000); - if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) - wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" - "suspend!\n", wlc_hw->unit); - - brcms_c_gpio_init(wlc); - - sflags = ai_core_sflags(wlc_hw->sih, 0, 0); - - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, d11n0initvals16); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_c_write_inits(wlc_hw, d11lcn0initvals24); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - - /* For old ucode, txfifo sizes needs to be modified(increased) */ - if (fifosz_fixup == true) { - brcms_b_corerev_fifofixup(wlc_hw); - } - - /* check txfifo allocations match between ucode and driver */ - buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); - if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { - i = TX_AC_BE_FIFO; - err = -1; - } - buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); - if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { - i = TX_AC_VI_FIFO; - err = -1; - } - buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); - buf[TX_AC_VO_FIFO] = (buf[TX_AC_BK_FIFO] >> 8) & 0xff; - buf[TX_AC_BK_FIFO] &= 0xff; - if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { - i = TX_AC_BK_FIFO; - err = -1; - } - if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { - i = TX_AC_VO_FIFO; - err = -1; - } - buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); - buf[TX_ATIM_FIFO] = (buf[TX_BCMC_FIFO] >> 8) & 0xff; - buf[TX_BCMC_FIFO] &= 0xff; - if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { - i = TX_BCMC_FIFO; - err = -1; - } - if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { - i = TX_ATIM_FIFO; - err = -1; - } - if (err != 0) { - wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" - " driver size %d index %d\n", buf[i], - wlc_hw->xmtfifo_sz[i], i); - } - - /* make sure we can still talk to the mac */ - WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); - - /* band-specific inits done by wlc_bsinit() */ - - /* Set up frame burst size and antenna swap threshold init values */ - brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); - brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); - - /* enable one rx interrupt per received frame */ - W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); - - /* set the station mode (BSS STA) */ - brcms_b_mctrl(wlc_hw, - (MCTL_INFRA | MCTL_DISCARD_PMQ | MCTL_AP), - (MCTL_INFRA | MCTL_DISCARD_PMQ)); - - /* set up Beacon interval */ - bcnint_us = 0x8000 << 10; - W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); - W_REG(®s->tsf_cfpstart, bcnint_us); - W_REG(®s->macintstatus, MI_GP1); - - /* write interrupt mask */ - W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); - - /* allow the MAC to control the PHY clock (dynamic on/off) */ - brcms_b_macphyclk_set(wlc_hw, ON); - - /* program dynamic clock control fast powerup delay register */ - wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); - W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); - - /* tell the ucode the corerev */ - brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); - - /* tell the ucode MAC capabilities */ - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, - (u16) (wlc_hw->machwcap & 0xffff)); - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, - (u16) ((wlc_hw-> - machwcap >> 16) & 0xffff)); - - /* write retry limits to SCR, this done after PSM init */ - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->SRL); - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->LRL); - - /* write rate fallback retry limits */ - brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); - brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); - - AND_REG(®s->ifs_ctl, 0x0FFF); - W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); - - /* dma initializations */ - wlc->txpend16165war = 0; - - /* init the tx dma engines */ - for (i = 0; i < NFIFO; i++) { - if (wlc_hw->di[i]) - dma_txinit(wlc_hw->di[i]); - } - - /* init the rx dma engine(s) and post receive buffers */ - dma_rxinit(wlc_hw->di[RX_FIFO]); - dma_rxfill(wlc_hw->di[RX_FIFO]); -} - /* This function is used for changing the tsf frac register * If spur avoidance mode is off, the mac freq will be 80/120/160Mhz * If spur avoidance mode is on1, the mac freq will be 82/123/164Mhz @@ -3107,6 +2193,39 @@ void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); } +static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + u8 fifo = 1 << tx_fifo; + + /* Two clients of this code, 11h Quiet period and scanning. */ + + /* only suspend if not already suspended */ + if ((wlc_hw->suspended_fifos & fifo) == fifo) + return; + + /* force the core awake only if not already */ + if (wlc_hw->suspended_fifos == 0) + brcms_c_ucode_wake_override_set(wlc_hw, + BRCMS_WAKE_OVERRIDE_TXFIFO); + + wlc_hw->suspended_fifos |= fifo; + + if (wlc_hw->di[tx_fifo]) { + /* Suspending AMPDU transmissions in the middle can cause underflow + * which may result in mismatch between ucode and driver + * so suspend the mac before suspending the FIFO + */ + if (BRCMS_PHY_11N_CAP(wlc_hw->band)) + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + + dma_txsuspend(wlc_hw->di[tx_fifo]); + + if (BRCMS_PHY_11N_CAP(wlc_hw->band)) + brcms_c_enable_mac(wlc_hw->wlc); + } +} + static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, mbool flags) { u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; @@ -3143,17 +2262,6 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, mbool flags) brcms_c_ucode_mute_override_clear(wlc_hw); } -int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks) -{ - if (fifo >= NFIFO) - return -EINVAL; - - *blocks = wlc_hw->xmtfifo_sz[fifo]; - - return 0; -} - /* brcms_b_tx_fifo_suspended: * Check the MAC's tx suspend status for a tx fifo. * @@ -3183,39 +2291,6 @@ static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, return false; } -static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - u8 fifo = 1 << tx_fifo; - - /* Two clients of this code, 11h Quiet period and scanning. */ - - /* only suspend if not already suspended */ - if ((wlc_hw->suspended_fifos & fifo) == fifo) - return; - - /* force the core awake only if not already */ - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_set(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - - wlc_hw->suspended_fifos |= fifo; - - if (wlc_hw->di[tx_fifo]) { - /* Suspending AMPDU transmissions in the middle can cause underflow - * which may result in mismatch between ucode and driver - * so suspend the mac before suspending the FIFO - */ - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - - dma_txsuspend(wlc_hw->di[tx_fifo]); - - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_enable_mac(wlc_hw->wlc); - } -} - static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, uint tx_fifo) { @@ -3356,81 +2431,6 @@ bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) } -static bool -brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, - u32 s2) -{ - /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent - * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts - * transmission count) - */ - if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) { - return false; - } - - return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); -} - -/* process tx completion events in BMAC - * Return true if more tx status need to be processed. false otherwise. - */ -static bool -brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) -{ - bool morepending = false; - struct brcms_c_info *wlc = wlc_hw->wlc; - d11regs_t *regs; - struct tx_status txstatus, *txs; - u32 s1, s2; - uint n = 0; - /* - * Param 'max_tx_num' indicates max. # tx status to process before - * break out. - */ - uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - txs = &txstatus; - regs = wlc_hw->regs; - while (!(*fatal) - && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { - - if (s1 == 0xffffffff) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", - wlc_hw->unit, __func__); - return morepending; - } - - s2 = R_REG(®s->frmtxstatus2); - - txs->status = s1 & TXS_STATUS_MASK; - txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; - txs->sequence = s2 & TXS_SEQ_MASK; - txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; - txs->lasttxtime = 0; - - *fatal = brcms_b_dotxstatus(wlc_hw, txs, s2); - - /* !give others some time to run! */ - if (++n >= max_tx_num) - break; - } - - if (*fatal) - return 0; - - if (n >= max_tx_num) - morepending = true; - - if (!pktq_empty(&wlc->pkt_queue->q)) - brcms_c_send_q(wlc); - - return morepending; -} - void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; @@ -3612,19 +2612,6 @@ void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) brcms_upd_ofdm_pctl1_table(wlc_hw); } -void -brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, - u32 *tsf_h_ptr) -{ - d11regs_t *regs = wlc_hw->regs; - - /* read the tsf timer low, then high to get an atomic read */ - *tsf_l_ptr = R_REG(®s->tsf_timerlow); - *tsf_h_ptr = R_REG(®s->tsf_timerhigh); - - return; -} - static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) { d11regs_t *regs; @@ -3966,29 +2953,6 @@ void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, mbool req_bit) return; } -u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) -{ - u16 table_ptr; - u8 phy_rate, index; - - /* get the phy specific rate encoding for the PLCP SIGNAL field */ - if (IS_OFDM(rate)) - table_ptr = M_RT_DIRMAP_A; - else - table_ptr = M_RT_DIRMAP_B; - - /* for a given rate, the LS-nibble of the PLCP SIGNAL field is - * the index into the rate table. - */ - phy_rate = rate_info[rate] & BRCMS_RATE_MASK; - index = phy_rate & 0xf; - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); -} - void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) { wlc_hw->antsel_avail = antsel_avail; @@ -4027,6 +2991,20 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) return true; } +void brcms_b_reset(struct brcms_hardware *wlc_hw) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* reset the core */ + if (!DEVICEREMOVED(wlc_hw->wlc)) + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + /* purge the dma rings */ + brcms_c_flushqueues(wlc_hw->wlc); + + brcms_c_reset_bmac_done(wlc_hw->wlc); +} + void brcms_c_reset(struct brcms_c_info *wlc) { BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); @@ -4072,6 +3050,243 @@ static void brcms_c_init_scb(struct brcms_c_info *wlc, struct scb *scb) scb->seqnum[i] = 0; } +/* d11 core init + * reset PSM + * download ucode/PCM + * let ucode run to suspended + * download ucode inits + * config other core registers + * init dma + */ +static void brcms_b_coreinit(struct brcms_c_info *wlc) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + d11regs_t *regs; + u32 sflags; + uint bcnint_us; + uint i = 0; + bool fifosz_fixup = false; + int err = 0; + u16 buf[NFIFO]; + struct wiphy *wiphy = wlc->wiphy; + + regs = wlc_hw->regs; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* reset PSM */ + brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); + + brcms_ucode_download(wlc_hw); + /* + * FIFOSZ fixup. driver wants to controls the fifo allocation. + */ + fifosz_fixup = true; + + /* let the PSM run to the suspended state, set mode to BSS STA */ + W_REG(®s->macintstatus, -1); + brcms_b_mctrl(wlc_hw, ~0, + (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); + + /* wait for ucode to self-suspend after auto-init */ + SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), + 1000 * 1000); + if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) + wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" + "suspend!\n", wlc_hw->unit); + + brcms_c_gpio_init(wlc); + + sflags = ai_core_sflags(wlc_hw->sih, 0, 0); + + if (D11REV_IS(wlc_hw->corerev, 23)) { + if (BRCMS_ISNPHY(wlc_hw->band)) + brcms_c_write_inits(wlc_hw, d11n0initvals16); + else + wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" + " %d\n", __func__, wlc_hw->unit, + wlc_hw->corerev); + } else if (D11REV_IS(wlc_hw->corerev, 24)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) { + brcms_c_write_inits(wlc_hw, d11lcn0initvals24); + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" + " %d\n", __func__, wlc_hw->unit, + wlc_hw->corerev); + } + } else { + wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", + __func__, wlc_hw->unit, wlc_hw->corerev); + } + + /* For old ucode, txfifo sizes needs to be modified(increased) */ + if (fifosz_fixup == true) { + brcms_b_corerev_fifofixup(wlc_hw); + } + + /* check txfifo allocations match between ucode and driver */ + buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); + if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { + i = TX_AC_BE_FIFO; + err = -1; + } + buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); + if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { + i = TX_AC_VI_FIFO; + err = -1; + } + buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); + buf[TX_AC_VO_FIFO] = (buf[TX_AC_BK_FIFO] >> 8) & 0xff; + buf[TX_AC_BK_FIFO] &= 0xff; + if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { + i = TX_AC_BK_FIFO; + err = -1; + } + if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { + i = TX_AC_VO_FIFO; + err = -1; + } + buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); + buf[TX_ATIM_FIFO] = (buf[TX_BCMC_FIFO] >> 8) & 0xff; + buf[TX_BCMC_FIFO] &= 0xff; + if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { + i = TX_BCMC_FIFO; + err = -1; + } + if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { + i = TX_ATIM_FIFO; + err = -1; + } + if (err != 0) { + wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" + " driver size %d index %d\n", buf[i], + wlc_hw->xmtfifo_sz[i], i); + } + + /* make sure we can still talk to the mac */ + WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); + + /* band-specific inits done by wlc_bsinit() */ + + /* Set up frame burst size and antenna swap threshold init values */ + brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); + brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); + + /* enable one rx interrupt per received frame */ + W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); + + /* set the station mode (BSS STA) */ + brcms_b_mctrl(wlc_hw, + (MCTL_INFRA | MCTL_DISCARD_PMQ | MCTL_AP), + (MCTL_INFRA | MCTL_DISCARD_PMQ)); + + /* set up Beacon interval */ + bcnint_us = 0x8000 << 10; + W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); + W_REG(®s->tsf_cfpstart, bcnint_us); + W_REG(®s->macintstatus, MI_GP1); + + /* write interrupt mask */ + W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); + + /* allow the MAC to control the PHY clock (dynamic on/off) */ + brcms_b_macphyclk_set(wlc_hw, ON); + + /* program dynamic clock control fast powerup delay register */ + wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); + W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); + + /* tell the ucode the corerev */ + brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); + + /* tell the ucode MAC capabilities */ + brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, + (u16) (wlc_hw->machwcap & 0xffff)); + brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, + (u16) ((wlc_hw-> + machwcap >> 16) & 0xffff)); + + /* write retry limits to SCR, this done after PSM init */ + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->SRL); + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->LRL); + + /* write rate fallback retry limits */ + brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); + brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); + + AND_REG(®s->ifs_ctl, 0x0FFF); + W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); + + /* dma initializations */ + wlc->txpend16165war = 0; + + /* init the tx dma engines */ + for (i = 0; i < NFIFO; i++) { + if (wlc_hw->di[i]) + dma_txinit(wlc_hw->di[i]); + } + + /* init the rx dma engine(s) and post receive buffers */ + dma_rxinit(wlc_hw->di[RX_FIFO]); + dma_rxfill(wlc_hw->di[RX_FIFO]); +} + +void +brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, + bool mute) { + u32 macintmask; + bool fastclk; + struct brcms_c_info *wlc = wlc_hw->wlc; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* request FAST clock if not on */ + fastclk = wlc_hw->forcefastclk; + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + /* disable interrupts */ + macintmask = brcms_intrsoff(wlc->wl); + + /* set up the specified band and chanspec */ + brcms_c_setxband(wlc_hw, CHSPEC_BANDUNIT(chanspec)); + wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); + + /* do one-time phy inits and calibration */ + wlc_phy_cal_init(wlc_hw->band->pi); + + /* core-specific initialization */ + brcms_b_coreinit(wlc); + + /* suspend the tx fifos and mute the phy for preism cac time */ + if (mute) + brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); + + /* band-specific inits */ + brcms_b_bsinit(wlc, chanspec); + + /* restore macintmask */ + brcms_intrsrestore(wlc->wl, macintmask); + + /* seed wake_override with BRCMS_WAKE_OVERRIDE_MACSUSPEND since the mac + * is suspended and brcms_c_enable_mac() will clear this override bit. + */ + mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); + + /* + * initialize mac_suspend_depth to 1 to match ucode initial suspended state + */ + wlc_hw->mac_suspend_depth = 1; + + /* restore the clk */ + if (!fastclk) + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); +} + void brcms_c_init(struct brcms_c_info *wlc) { d11regs_t *regs; @@ -4296,6 +3511,17 @@ void brcms_c_set_bssid(struct brcms_bss_cfg *cfg) #endif } +void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) +{ + wlc_hw->shortslot = shortslot; + + if (BAND_2G(brcms_b_bandtype(wlc_hw)) && wlc_hw->up) { + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + brcms_b_update_slot_timing(wlc_hw, shortslot); + brcms_c_enable_mac(wlc_hw->wlc); + } +} + /* * Suspend the the MAC and update the slot timing * for standard 11b/g (20us slots) or shortslot 11g (9us slots). @@ -4394,6 +3620,50 @@ static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, } +void +brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, + bool mute, struct txpwr_limits *txpwr) +{ + uint bandunit; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); + + wlc_hw->chanspec = chanspec; + + /* Switch bands if necessary */ + if (NBANDS_HW(wlc_hw) > 1) { + bandunit = CHSPEC_BANDUNIT(chanspec); + if (wlc_hw->band->bandunit != bandunit) { + /* brcms_b_setband disables other bandunit, + * use light band switch if not up yet + */ + if (wlc_hw->up) { + wlc_phy_chanspec_radio_set(wlc_hw-> + bandstate[bandunit]-> + pi, chanspec); + brcms_b_setband(wlc_hw, bandunit, chanspec); + } else { + brcms_c_setxband(wlc_hw, bandunit); + } + } + } + + wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); + + if (!wlc_hw->up) { + if (wlc_hw->clk) + wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, + chanspec); + wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); + } else { + wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); + wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); + + /* Update muting of the channel */ + brcms_b_mute(wlc_hw, mute, 0); + } +} + void brcms_c_set_chanspec(struct brcms_c_info *wlc, chanspec_t chanspec) { uint bandunit; @@ -4981,6 +4251,356 @@ struct brcms_pub *brcms_c_pub(void *wlc) #define CHIP_SUPPORTS_11N(wlc) 1 +/* low level attach + * run backplane attach, init nvram + * run phy attach + * initialize software state for each core and band + * put the whole chip in reset(driver down state), no clock + */ +int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, + bool piomode, void *regsva, uint bustype, void *btparam) +{ + struct brcms_hardware *wlc_hw; + d11regs_t *regs; + char *macaddr = NULL; + char *vars; + uint err = 0; + uint j; + bool wme = false; + struct shared_phy_params sha_params; + struct wiphy *wiphy = wlc->wiphy; + + BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, + device); + + wme = true; + + wlc_hw = wlc->hw; + wlc_hw->wlc = wlc; + wlc_hw->unit = unit; + wlc_hw->band = wlc_hw->bandstate[0]; + wlc_hw->_piomode = piomode; + + /* populate struct brcms_hardware with default values */ + brcms_b_info_init(wlc_hw); + + /* + * Do the hardware portion of the attach. + * Also initialize software state that depends on the particular hardware + * we are running. + */ + wlc_hw->sih = ai_attach(regsva, bustype, btparam, + &wlc_hw->vars, &wlc_hw->vars_size); + if (wlc_hw->sih == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", + unit); + err = 11; + goto fail; + } + vars = wlc_hw->vars; + + /* + * Get vendid/devid nvram overwrites, which could be different + * than those the BIOS recognizes for devices on PCMCIA_BUS, + * SDIO_BUS, and SROMless devices on PCI_BUS. + */ +#ifdef BCMBUSTYPE + bustype = BCMBUSTYPE; +#endif + if (bustype != SI_BUS) { + char *var; + + var = getvar(vars, "vendid"); + if (var) { + vendor = (u16) simple_strtoul(var, NULL, 0); + wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", + vendor); + } + var = getvar(vars, "devid"); + if (var) { + u16 devid = (u16) simple_strtoul(var, NULL, 0); + if (devid != 0xffff) { + device = devid; + wiphy_err(wiphy, "Overriding device id = 0x%x" + "\n", device); + } + } + + /* verify again the device is supported */ + if (!brcms_c_chipmatch(vendor, device)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " + "vendor/device (0x%x/0x%x)\n", + unit, vendor, device); + err = 12; + goto fail; + } + } + + wlc_hw->vendorid = vendor; + wlc_hw->deviceid = device; + + /* set bar0 window to point at D11 core */ + wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + wlc_hw->corerev = ai_corerev(wlc_hw->sih); + + regs = wlc_hw->regs; + + wlc->regs = wlc_hw->regs; + + /* validate chip, chiprev and corerev */ + if (!brcms_c_isgoodchip(wlc_hw)) { + err = 13; + goto fail; + } + + /* initialize power control registers */ + ai_clkctl_init(wlc_hw->sih); + + /* request fastclock and force fastclock for the rest of attach + * bring the d11 core out of reset. + * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk is still false; + * But it will be called again inside wlc_corereset, after d11 is out of reset. + */ + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + if (!brcms_b_validate_chip_access(wlc_hw)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: validate_chip_access " + "failed\n", unit); + err = 14; + goto fail; + } + + /* get the board rev, used just below */ + j = getintvar(vars, "boardrev"); + /* promote srom boardrev of 0xFF to 1 */ + if (j == BOARDREV_PROMOTABLE) + j = BOARDREV_PROMOTED; + wlc_hw->boardrev = (u16) j; + if (!brcms_c_validboardtype(wlc_hw)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " + "board type (0x%x)" " or revision level (0x%x)\n", + unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); + err = 15; + goto fail; + } + wlc_hw->sromrev = (u8) getintvar(vars, "sromrev"); + wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); + wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); + + if (wlc_hw->boardflags & BFL_NOPLLDOWN) + brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); + + if ((wlc_hw->sih->bustype == PCI_BUS) + && (ai_pci_war16165(wlc_hw->sih))) + wlc->war16165 = true; + + /* check device id(srom, nvram etc.) to set bands */ + if (wlc_hw->deviceid == BCM43224_D11N_ID || + wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) { + /* Dualband boards */ + wlc_hw->_nbands = 2; + } else + wlc_hw->_nbands = 1; + + if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->_nbands = 1; + + /* BMAC_NOTE: remove init of pub values when brcms_c_attach() + * unconditionally does the init of these values + */ + wlc->vendorid = wlc_hw->vendorid; + wlc->deviceid = wlc_hw->deviceid; + wlc->pub->sih = wlc_hw->sih; + wlc->pub->corerev = wlc_hw->corerev; + wlc->pub->sromrev = wlc_hw->sromrev; + wlc->pub->boardrev = wlc_hw->boardrev; + wlc->pub->boardflags = wlc_hw->boardflags; + wlc->pub->boardflags2 = wlc_hw->boardflags2; + wlc->pub->_nbands = wlc_hw->_nbands; + + wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); + + if (wlc_hw->physhim == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_shim_attach " + "failed\n", unit); + err = 25; + goto fail; + } + + /* pass all the parameters to wlc_phy_shared_attach in one struct */ + sha_params.sih = wlc_hw->sih; + sha_params.physhim = wlc_hw->physhim; + sha_params.unit = unit; + sha_params.corerev = wlc_hw->corerev; + sha_params.vars = vars; + sha_params.vid = wlc_hw->vendorid; + sha_params.did = wlc_hw->deviceid; + sha_params.chip = wlc_hw->sih->chip; + sha_params.chiprev = wlc_hw->sih->chiprev; + sha_params.chippkg = wlc_hw->sih->chippkg; + sha_params.sromrev = wlc_hw->sromrev; + sha_params.boardtype = wlc_hw->sih->boardtype; + sha_params.boardrev = wlc_hw->boardrev; + sha_params.boardvendor = wlc_hw->sih->boardvendor; + sha_params.boardflags = wlc_hw->boardflags; + sha_params.boardflags2 = wlc_hw->boardflags2; + sha_params.bustype = wlc_hw->sih->bustype; + sha_params.buscorerev = wlc_hw->sih->buscorerev; + + /* alloc and save pointer to shared phy state area */ + wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); + if (!wlc_hw->phy_sh) { + err = 16; + goto fail; + } + + /* initialize software state for each core and band */ + for (j = 0; j < NBANDS_HW(wlc_hw); j++) { + /* + * band0 is always 2.4Ghz + * band1, if present, is 5Ghz + */ + + /* So if this is a single band 11a card, use band 1 */ + if (IS_SINGLEBAND_5G(wlc_hw->deviceid)) + j = BAND_5G_INDEX; + + brcms_c_setxband(wlc_hw, j); + + wlc_hw->band->bandunit = j; + wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; + wlc->band->bandunit = j; + wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; + wlc->core->coreidx = ai_coreidx(wlc_hw->sih); + + wlc_hw->machwcap = R_REG(®s->machwcap); + wlc_hw->machwcap_backup = wlc_hw->machwcap; + + /* init tx fifo size */ + wlc_hw->xmtfifo_sz = + xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; + + /* Get a phy for this band */ + wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, + (void *)regs, brcms_b_bandtype(wlc_hw), vars, + wlc->wiphy); + if (wlc_hw->band->pi == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" + "attach failed\n", unit); + err = 17; + goto fail; + } + + wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); + + wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, + &wlc_hw->band->phyrev, + &wlc_hw->band->radioid, + &wlc_hw->band->radiorev); + wlc_hw->band->abgphy_encore = + wlc_phy_get_encore(wlc_hw->band->pi); + wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); + wlc_hw->band->core_flags = + wlc_phy_get_coreflags(wlc_hw->band->pi); + + /* verify good phy_type & supported phy revision */ + if (BRCMS_ISNPHY(wlc_hw->band)) { + if (NCONF_HAS(wlc_hw->band->phyrev)) + goto good_phy; + else + goto bad_phy; + } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { + if (LCNCONF_HAS(wlc_hw->band->phyrev)) + goto good_phy; + else + goto bad_phy; + } else { + bad_phy: + wiphy_err(wiphy, "wl%d: brcms_b_attach: unsupported " + "phy type/rev (%d/%d)\n", unit, + wlc_hw->band->phytype, wlc_hw->band->phyrev); + err = 18; + goto fail; + } + + good_phy: + /* BMAC_NOTE: wlc->band->pi should not be set below and should be done in the + * high level attach. However we can not make that change until all low level access + * is changed to wlc_hw->band->pi. Instead do the wlc->band->pi init below, keeping + * wlc_hw->band->pi as well for incremental update of low level fns, and cut over + * low only init when all fns updated. + */ + wlc->band->pi = wlc_hw->band->pi; + wlc->band->phytype = wlc_hw->band->phytype; + wlc->band->phyrev = wlc_hw->band->phyrev; + wlc->band->radioid = wlc_hw->band->radioid; + wlc->band->radiorev = wlc_hw->band->radiorev; + + /* default contention windows size limits */ + wlc_hw->band->CWmin = APHY_CWMIN; + wlc_hw->band->CWmax = PHY_CWMAX; + + if (!brcms_b_attach_dmapio(wlc, j, wme)) { + err = 19; + goto fail; + } + } + + /* disable core to match driver "down" state */ + brcms_c_coredisable(wlc_hw); + + /* Match driver "down" state */ + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + + /* register sb interrupt callback functions */ + ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, + (void *)brcms_c_wlintrsrestore, NULL, wlc); + + /* turn off pll and xtal to match driver "down" state */ + brcms_b_xtal(wlc_hw, OFF); + + /* ********************************************************************* + * The hardware is in the DOWN state at this point. D11 core + * or cores are in reset with clocks off, and the board PLLs + * are off if possible. + * + * Beyond this point, wlc->sbclk == false and chip registers + * should not be touched. + ********************************************************************* + */ + + /* init etheraddr state variables */ + macaddr = brcms_c_get_macaddr(wlc_hw); + if (macaddr == NULL) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n", + unit); + err = 21; + goto fail; + } + brcmu_ether_atoe(macaddr, wlc_hw->etheraddr); + if (is_broadcast_ether_addr(wlc_hw->etheraddr) || + is_zero_ether_addr(wlc_hw->etheraddr)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", + unit, macaddr); + err = 22; + goto fail; + } + + BCMMSG(wlc->wiphy, + "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", + wlc_hw->deviceid, wlc_hw->_nbands, + wlc_hw->sih->boardtype, macaddr); + + return err; + + fail: + wiphy_err(wiphy, "wl%d: brcms_b_attach: failed with err %d\n", unit, + err); + return err; +} + /* * The common driver entry routine. Error codes should be unique */ @@ -5333,6 +4953,58 @@ static void brcms_c_detach_module(struct brcms_c_info *wlc) brcms_c_stf_detach(wlc); } +/* + * low level detach + */ +int brcms_b_detach(struct brcms_c_info *wlc) +{ + uint i; + struct brcms_hw_band *band; + struct brcms_hardware *wlc_hw = wlc->hw; + int callbacks; + + callbacks = 0; + + if (wlc_hw->sih) { + /* detach interrupt sync mechanism since interrupt is disabled and per-port + * interrupt object may has been freed. this must be done before sb core switch + */ + ai_deregister_intr_callback(wlc_hw->sih); + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_sleep(wlc_hw->sih); + } + + brcms_b_detach_dmapio(wlc_hw); + + band = wlc_hw->band; + for (i = 0; i < NBANDS_HW(wlc_hw); i++) { + if (band->pi) { + /* Detach this band's phy */ + wlc_phy_detach(band->pi); + band->pi = NULL; + } + band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; + } + + /* Free shared phy state */ + kfree(wlc_hw->phy_sh); + + wlc_phy_shim_detach(wlc_hw->physhim); + + /* free vars */ + kfree(wlc_hw->vars); + wlc_hw->vars = NULL; + + if (wlc_hw->sih) { + ai_detach(wlc_hw->sih); + wlc_hw->sih = NULL; + } + + return callbacks; + +} + /* * Return a count of the number of driver callbacks still pending. * @@ -5560,6 +5232,29 @@ bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) return brcms_del_timer(wlc->wl, wlc->radio_timer); } +/* common low-level watchdog code */ +void brcms_b_watchdog(void *arg) +{ + struct brcms_c_info *wlc = (struct brcms_c_info *) arg; + struct brcms_hardware *wlc_hw = wlc->hw; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return; + + /* increment second count */ + wlc_hw->now++; + + /* Check for FIFO error interrupts */ + brcms_b_fifoerrors(wlc_hw); + + /* make sure RX dma has buffers */ + dma_rxfill(wlc->hw->di[RX_FIFO]); + + wlc_phy_watchdog(wlc_hw->band->pi); +} + static void brcms_c_watchdog_by_timer(void *arg) { brcms_c_watchdog(arg); @@ -5637,6 +5332,105 @@ static void brcms_c_watchdog(void *arg) } } +/* Initialize just the hardware when coming out of POR or S3/S5 system states */ +void brcms_b_hw_up(struct brcms_hardware *wlc_hw) +{ + if (wlc_hw->wlc->pub->hw_up) + return; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* + * Enable pll and xtal, initialize the power control registers, + * and force fastclock for the remainder of brcms_c_up(). + */ + brcms_b_xtal(wlc_hw, ON); + ai_clkctl_init(wlc_hw->sih); + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + if (wlc_hw->sih->bustype == PCI_BUS) { + ai_pci_fixcfg(wlc_hw->sih); + + /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ + if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || + (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->regs = + (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, + 0); + } + + /* Inform phy that a POR reset has occurred so it does a complete phy init */ + wlc_phy_por_inform(wlc_hw->band->pi); + + wlc_hw->ucode_loaded = false; + wlc_hw->wlc->pub->hw_up = true; + + if ((wlc_hw->boardflags & BFL_FEM) + && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { + if (! + (wlc_hw->boardrev >= 0x1250 + && (wlc_hw->boardflags & BFL_FEM_BT))) + ai_epa_4313war(wlc_hw->sih); + } +} + +int brcms_b_up_prep(struct brcms_hardware *wlc_hw) +{ + uint coremask; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + /* + * Enable pll and xtal, initialize the power control registers, + * and force fastclock for the remainder of brcms_c_up(). + */ + brcms_b_xtal(wlc_hw, ON); + ai_clkctl_init(wlc_hw->sih); + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + + /* + * Configure pci/pcmcia here instead of in brcms_c_attach() + * to allow mfg hotswap: down, hotswap (chip power cycle), up. + */ + coremask = (1 << wlc_hw->wlc->core->coreidx); + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_setup(wlc_hw->sih, coremask); + + /* + * Need to read the hwradio status here to cover the case where the system + * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. + */ + if (brcms_b_radio_read_hwdisabled(wlc_hw)) { + /* put SB PCI in down state again */ + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + brcms_b_xtal(wlc_hw, OFF); + return -ENOMEDIUM; + } + + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_up(wlc_hw->sih); + + /* reset the d11 core */ + brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); + + return 0; +} + +int brcms_b_up_finish(struct brcms_hardware *wlc_hw) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + wlc_hw->up = true; + wlc_phy_hw_state_upd(wlc_hw->band->pi, true); + + /* FULLY enable dynamic power control and d11 core interrupt */ + brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); + brcms_intrson(wlc_hw->wlc->wl); + return 0; +} + /* make interface operational */ int brcms_c_up(struct brcms_c_info *wlc) { @@ -5773,6 +5567,78 @@ static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) return callbacks; } +int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) +{ + bool dev_gone; + uint callbacks = 0; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return callbacks; + + dev_gone = DEVICEREMOVED(wlc_hw->wlc); + + /* disable interrupts */ + if (dev_gone) + wlc_hw->wlc->macintmask = 0; + else { + /* now disable interrupts */ + brcms_intrsoff(wlc_hw->wlc->wl); + + /* ensure we're running on the pll clock again */ + brcms_b_clkctl_clk(wlc_hw, CLK_FAST); + } + /* down phy at the last of this stage */ + callbacks += wlc_phy_down(wlc_hw->band->pi); + + return callbacks; +} + +int brcms_b_down_finish(struct brcms_hardware *wlc_hw) +{ + uint callbacks = 0; + bool dev_gone; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return callbacks; + + wlc_hw->up = false; + wlc_phy_hw_state_upd(wlc_hw->band->pi, false); + + dev_gone = DEVICEREMOVED(wlc_hw->wlc); + + if (dev_gone) { + wlc_hw->sbclk = false; + wlc_hw->clk = false; + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); + + /* reclaim any posted packets */ + brcms_c_flushqueues(wlc_hw->wlc); + } else { + + /* Reset and disable the core */ + if (ai_iscoreup(wlc_hw->sih)) { + if (R_REG(&wlc_hw->regs->maccontrol) & + MCTL_EN_MAC) + brcms_c_suspend_mac_and_wait(wlc_hw->wlc); + callbacks += brcms_reset(wlc_hw->wlc->wl); + brcms_c_coredisable(wlc_hw); + } + + /* turn off primary xtal and pll */ + if (!wlc_hw->noreset) { + if (wlc_hw->sih->bustype == PCI_BUS) + ai_pci_down(wlc_hw->sih); + brcms_b_xtal(wlc_hw, OFF); + } + } + + return callbacks; +} + /* * Mark the interface nonoperational, stop the software mechanisms, * disable the hardware, free any transient buffer state. @@ -6709,6 +6575,29 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) } #endif /* defined(BCMDBG) */ +u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) +{ + u16 table_ptr; + u8 phy_rate, index; + + /* get the phy specific rate encoding for the PLCP SIGNAL field */ + if (IS_OFDM(rate)) + table_ptr = M_RT_DIRMAP_A; + else + table_ptr = M_RT_DIRMAP_B; + + /* for a given rate, the LS-nibble of the PLCP SIGNAL field is + * the index into the rate table. + */ + phy_rate = rate_info[rate] & BRCMS_RATE_MASK; + index = phy_rate & 0xf; + + /* Find the SHM pointer to the rate table entry by looking in the + * Direct-map Table + */ + return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); +} + static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate) { return brcms_b_rate_shm_offset(wlc->hw, rate); @@ -8114,6 +8003,19 @@ void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); } +void +brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, + u32 *tsf_h_ptr) +{ + d11regs_t *regs = wlc_hw->regs; + + /* read the tsf timer low, then high to get an atomic read */ + *tsf_l_ptr = R_REG(®s->tsf_timerlow); + *tsf_h_ptr = R_REG(®s->tsf_timerhigh); + + return; +} + /* * recover 64bit TSF value from the 16bit TSF value in the rx header * given the assumption that the TSF passed in header is within 65ms @@ -8933,6 +8835,27 @@ int brcms_c_get_header_len() return TXOFF; } +/* mac is assumed to be suspended at this point */ +void +brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, + int len, bool both) +{ + d11regs_t *regs = wlc_hw->regs; + + if (both) { + brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); + brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); + } else { + /* bcn 0 */ + if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) + brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); + /* bcn 1 */ + else if (! + (R_REG(®s->maccommand) & MCMD_BCN1VLD)) + brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); + } +} + /* Update a beacon for a particular BSS * For MBSS, this updates the software template and sets "latest" to the index of the * template updated. @@ -9341,6 +9264,17 @@ void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, int bands) brcms_b_mhf(wlc->hw, idx, mask, val, bands); } +int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, + uint *blocks) +{ + if (fifo >= NFIFO) + return -EINVAL; + + *blocks = wlc_hw->xmtfifo_sz[fifo]; + + return 0; +} + int brcms_c_xmtfifo_sz_get(struct brcms_c_info *wlc, uint fifo, uint *blocks) { return brcms_b_xmtfifo_sz_get(wlc->hw, fifo, blocks); From 45c05cbd613e87906420aa1d869c167326f5c833 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:49 +0200 Subject: [PATCH 0027/1519] staging: brcm80211: removed function declaration typedefs from phy_int.h Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 9 +++-- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 35 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 17012fbe9c9..f4224efdb3a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -865,7 +865,7 @@ void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate) void wlc_phy_init(struct brcms_phy_pub *pih, chanspec_t chanspec) { u32 mc; - initfn_t phy_init = NULL; + void (*phy_init) (struct brcms_phy *) = NULL; struct brcms_phy *pi = (struct brcms_phy *) pih; if (pi->init_in_progress) @@ -921,7 +921,7 @@ void wlc_phy_init(struct brcms_phy_pub *pih, chanspec_t chanspec) void wlc_phy_cal_init(struct brcms_phy_pub *pih) { struct brcms_phy *pi = (struct brcms_phy *) pih; - initfn_t cal_init = NULL; + void (*cal_init)(struct brcms_phy *) = NULL; if (WARN((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) != 0, "HW error: MAC enabled during phy cal\n")) @@ -1329,8 +1329,7 @@ void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, chanspec_t chanspec) { struct brcms_phy *pi = (struct brcms_phy *) ppi; u16 m_cur_channel; - chansetfn_t chanspec_set = NULL; - + void (*chanspec_set) (struct brcms_phy *, chanspec_t) = NULL; m_cur_channel = CHSPEC_CHANNEL(chanspec); if (CHSPEC_IS5G(chanspec)) m_cur_channel |= D11_CURCHANNEL_5G; @@ -1671,7 +1670,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) u8 start_rate = 0; chanspec_t chspec; u32 band = CHSPEC2BAND(pi->radio_chanspec); - initfn_t txpwr_recalc_fn = NULL; + void (*txpwr_recalc_fn)(struct brcms_phy *) = NULL; chspec = pi->radio_chanspec; if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index a01b01ccd9f..7dae8026348 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -49,17 +49,6 @@ struct brcms_phy_srom_fem { u8 antswctrllut; /* antswctrl lookup table configuration: 32 possible choices */ }; -typedef void (*initfn_t) (struct brcms_phy *); -typedef void (*chansetfn_t) (struct brcms_phy *, chanspec_t); -typedef int (*longtrnfn_t) (struct brcms_phy *, int); -typedef void (*txiqccgetfn_t) (struct brcms_phy *, u16 *, u16 *); -typedef void (*txiqccsetfn_t) (struct brcms_phy *, u16, u16); -typedef u16(*txloccgetfn_t) (struct brcms_phy *); -typedef void (*radioloftgetfn_t) (struct brcms_phy *, u8 *, u8 *, u8 *, - u8 *); -typedef s32(*rxsigpwrfn_t) (struct brcms_phy *, s32); -typedef void (*detachfn_t) (struct brcms_phy *); - #undef ISNPHY #undef ISLCNPHY #define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N) @@ -579,18 +568,18 @@ struct brcms_phy_pub { }; struct phy_func_ptr { - initfn_t init; - initfn_t calinit; - chansetfn_t chanset; - initfn_t txpwrrecalc; - longtrnfn_t longtrn; - txiqccgetfn_t txiqccget; - txiqccsetfn_t txiqccset; - txloccgetfn_t txloccget; - radioloftgetfn_t radioloftget; - initfn_t carrsuppr; - rxsigpwrfn_t rxsigpwr; - detachfn_t detach; + void (*init) (struct brcms_phy *); + void (*calinit) (struct brcms_phy *); + void (*chanset) (struct brcms_phy *, chanspec_t); + void (*txpwrrecalc) (struct brcms_phy *); + int (*longtrn) (struct brcms_phy *, int); + void (*txiqccget) (struct brcms_phy *, u16 *, u16 *); + void (*txiqccset) (struct brcms_phy *, u16, u16); + u16(*txloccget) (struct brcms_phy *); + void (*radioloftget) (struct brcms_phy *, u8 *, u8 *, u8 *, u8 *); + void (*carrsuppr) (struct brcms_phy *); + s32(*rxsigpwr) (struct brcms_phy *, s32); + void (*detach) (struct brcms_phy *); }; struct brcms_phy { From 4da8a876906022190ede46a7562fb4d853b55958 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:50 +0200 Subject: [PATCH 0028/1519] staging: brcm80211: removed function declaration typedefs from aiutils.h Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 6 +++--- drivers/staging/brcm80211/brcmsmac/aiutils.h | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index a25901e9981..5a5fc4b7141 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1279,9 +1279,9 @@ ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, sii = SI_INFO(sih); sii->intr_arg = intr_arg; - sii->intrsoff_fn = (si_intrsoff_t) intrsoff_fn; - sii->intrsrestore_fn = (si_intrsrestore_t) intrsrestore_fn; - sii->intrsenabled_fn = (si_intrsenabled_t) intrsenabled_fn; + sii->intrsoff_fn = (u32 (*)(void *)) intrsoff_fn; + sii->intrsrestore_fn = (void (*) (void *, u32)) intrsrestore_fn; + sii->intrsenabled_fn = (bool (*)(void *)) intrsenabled_fn; /* save current core id. when this function called, the current core * must be the core which provides driver functions(il, et, wl, etc.) */ diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index e245c278beb..f881b449364 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -425,8 +425,6 @@ struct si_pub { #define CCPLL_ENAB(sih) ((sih)->cccaps & CC_CAP_PLL_MASK) #endif -typedef void (*gpio_handler_t) (u32 stat, void *arg); - /* External PA enable mask */ #define GPIO_CTRL_EPA_EN_MASK 0x40 @@ -444,14 +442,10 @@ typedef void (*gpio_handler_t) (u32 stat, void *arg); #define IS_SIM(chippkg) \ ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) -typedef u32(*si_intrsoff_t) (void *intr_arg); -typedef void (*si_intrsrestore_t) (void *intr_arg, u32 arg); -typedef bool(*si_intrsenabled_t) (void *intr_arg); - struct gpioh_item { void *arg; bool level; - gpio_handler_t handler; + void (*handler) (u32 stat, void *arg); u32 event; struct gpioh_item *next; }; @@ -462,9 +456,11 @@ struct si_info { void *pbus; /* handle to bus (pci/sdio/..) */ uint dev_coreid; /* the core provides driver functions */ void *intr_arg; /* interrupt callback function arg */ - si_intrsoff_t intrsoff_fn; /* turns chip interrupts off */ - si_intrsrestore_t intrsrestore_fn; /* restore chip interrupts */ - si_intrsenabled_t intrsenabled_fn; /* check if interrupts are enabled */ + u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */ + /* restore chip interrupts */ + void (*intrsrestore_fn) (void *intr_arg, u32 arg); + /* check if interrupts are enabled */ + bool (*intrsenabled_fn) (void *intr_arg); void *pch; /* PCI/E core handle */ From d47369d40f9deb55a3b49870471c7f5f27962392 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:51 +0200 Subject: [PATCH 0029/1519] staging: brcm80211: removed function declaration typedefs from dma.h part 1 Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 22 ++++++++-------- drivers/staging/brcm80211/brcmsmac/dma.h | 33 ++++++++---------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index ea17671efb6..5fd5e8c3063 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -387,12 +387,12 @@ static bool _dma64_addrext(dma64regs_t *dma64regs); static inline u32 parity32(u32 data); const struct di_fcn_s dma64proc = { - (di_detach_t) _dma_detach, - (di_txinit_t) dma64_txinit, + (void (*)(struct dma_pub *)) _dma_detach, + (void (*)(struct dma_pub *)) dma64_txinit, (di_txreset_t) dma64_txreset, (di_txenabled_t) dma64_txenabled, - (di_txsuspend_t) dma64_txsuspend, - (di_txresume_t) dma64_txresume, + (void (*)(struct dma_pub *)) dma64_txsuspend, + (void (*)(struct dma_pub *)) dma64_txresume, (di_txsuspended_t) dma64_txsuspended, (di_txsuspendedidle_t) dma64_txsuspendedidle, (di_txfast_t) dma64_txfast, @@ -402,12 +402,12 @@ const struct di_fcn_s dma64proc = { (di_txreclaim_t) dma64_txreclaim, (di_getnexttxp_t) dma64_getnexttxp, (di_peeknexttxp_t) _dma_peeknexttxp, - (di_txblock_t) _dma_txblock, - (di_txunblock_t) _dma_txunblock, + (void (*)(struct dma_pub *)) _dma_txblock, + (void (*)(struct dma_pub *)) _dma_txunblock, (di_txactive_t) _dma_txactive, - (di_txrotate_t) dma64_txrotate, + (void (*)(struct dma_pub *)) dma64_txrotate, - (di_rxinit_t) _dma_rxinit, + (void (*)(struct dma_pub *)) _dma_rxinit, (di_rxreset_t) dma64_rxreset, (di_rxidle_t) dma64_rxidle, (di_rxstopped_t) dma64_rxstopped, @@ -415,14 +415,14 @@ const struct di_fcn_s dma64proc = { (di_rxenabled_t) dma64_rxenabled, (di_rx_t) _dma_rx, (di_rxfill_t) _dma_rxfill, - (di_rxreclaim_t) _dma_rxreclaim, + (void (*)(struct dma_pub *)) _dma_rxreclaim, (di_getnextrxp_t) _dma_getnextrxp, (di_peeknextrxp_t) _dma_peeknextrxp, (di_rxparam_get_t) _dma_rx_param_get, - (di_fifoloopbackenable_t) _dma_fifoloopbackenable, + (void (*)(struct dma_pub *)) _dma_fifoloopbackenable, (di_getvar_t) _dma_getvar, - (di_counterreset_t) _dma_counterreset, + (void (*)(struct dma_pub *)) _dma_counterreset, (di_ctrlflags_t) _dma_ctrlflags, NULL, NULL, diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 9c8b9a6a557..69f2e9447b0 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -59,15 +59,10 @@ enum txd_range { }; /* dma function type */ -typedef void (*di_detach_t) (struct dma_pub *dmah); typedef bool(*di_txreset_t) (struct dma_pub *dmah); typedef bool(*di_rxreset_t) (struct dma_pub *dmah); typedef bool(*di_rxidle_t) (struct dma_pub *dmah); -typedef void (*di_txinit_t) (struct dma_pub *dmah); typedef bool(*di_txenabled_t) (struct dma_pub *dmah); -typedef void (*di_rxinit_t) (struct dma_pub *dmah); -typedef void (*di_txsuspend_t) (struct dma_pub *dmah); -typedef void (*di_txresume_t) (struct dma_pub *dmah); typedef bool(*di_txsuspended_t) (struct dma_pub *dmah); typedef bool(*di_txsuspendedidle_t) (struct dma_pub *dmah); typedef int (*di_txfast_t) (struct dma_pub *dmah, struct sk_buff *p, @@ -75,7 +70,6 @@ typedef int (*di_txfast_t) (struct dma_pub *dmah, struct sk_buff *p, typedef int (*di_txunframed_t) (struct dma_pub *dmah, void *p, uint len, bool commit); typedef void *(*di_getpos_t) (struct dma_pub *di, bool direction); -typedef void (*di_fifoloopbackenable_t) (struct dma_pub *dmah); typedef bool(*di_txstopped_t) (struct dma_pub *dmah); typedef bool(*di_rxstopped_t) (struct dma_pub *dmah); typedef bool(*di_rxenable_t) (struct dma_pub *dmah); @@ -83,7 +77,6 @@ typedef bool(*di_rxenabled_t) (struct dma_pub *dmah); typedef void *(*di_rx_t) (struct dma_pub *dmah); typedef bool(*di_rxfill_t) (struct dma_pub *dmah); typedef void (*di_txreclaim_t) (struct dma_pub *dmah, enum txd_range range); -typedef void (*di_rxreclaim_t) (struct dma_pub *dmah); typedef unsigned long (*di_getvar_t) (struct dma_pub *dmah, const char *name); typedef void *(*di_getnexttxp_t) (struct dma_pub *dmah, enum txd_range range); @@ -92,11 +85,7 @@ typedef void *(*di_peeknexttxp_t) (struct dma_pub *dmah); typedef void *(*di_peeknextrxp_t) (struct dma_pub *dmah); typedef void (*di_rxparam_get_t) (struct dma_pub *dmah, u16 *rxoffset, u16 *rxbufsize); -typedef void (*di_txblock_t) (struct dma_pub *dmah); -typedef void (*di_txunblock_t) (struct dma_pub *dmah); typedef uint(*di_txactive_t) (struct dma_pub *dmah); -typedef void (*di_txrotate_t) (struct dma_pub *dmah); -typedef void (*di_counterreset_t) (struct dma_pub *dmah); typedef uint(*di_ctrlflags_t) (struct dma_pub *dmah, uint mask, uint flags); typedef char *(*di_dump_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, bool dumpring); @@ -110,12 +99,12 @@ typedef uint(*di_txcommitted_t) (struct dma_pub *dmah); /* dma opsvec */ struct di_fcn_s { - di_detach_t detach; - di_txinit_t txinit; + void (*detach)(struct dma_pub *dmah); + void (*txinit)(struct dma_pub *dmah); di_txreset_t txreset; di_txenabled_t txenabled; - di_txsuspend_t txsuspend; - di_txresume_t txresume; + void (*txsuspend)(struct dma_pub *dmah); + void (*txresume)(struct dma_pub *dmah); di_txsuspended_t txsuspended; di_txsuspendedidle_t txsuspendedidle; di_txfast_t txfast; @@ -125,12 +114,12 @@ struct di_fcn_s { di_txreclaim_t txreclaim; di_getnexttxp_t getnexttxp; di_peeknexttxp_t peeknexttxp; - di_txblock_t txblock; - di_txunblock_t txunblock; + void (*txblock) (struct dma_pub *dmah); + void (*txunblock) (struct dma_pub *dmah); di_txactive_t txactive; - di_txrotate_t txrotate; + void (*txrotate) (struct dma_pub *dmah); - di_rxinit_t rxinit; + void (*rxinit)(struct dma_pub *dmah); di_rxreset_t rxreset; di_rxidle_t rxidle; di_rxstopped_t rxstopped; @@ -138,14 +127,14 @@ struct di_fcn_s { di_rxenabled_t rxenabled; di_rx_t rx; di_rxfill_t rxfill; - di_rxreclaim_t rxreclaim; + void (*rxreclaim)(struct dma_pub *dmah); di_getnextrxp_t getnextrxp; di_peeknextrxp_t peeknextrxp; di_rxparam_get_t rxparam_get; - di_fifoloopbackenable_t fifoloopbackenable; + void (*fifoloopbackenable)(struct dma_pub *dmah); di_getvar_t d_getvar; - di_counterreset_t counterreset; + void (*counterreset)(struct dma_pub *dmah); di_ctrlflags_t ctrlflags; di_dump_t dump; di_dumptx_t dumptx; From 93682c22c33506631787f9ce9e154976a09481e4 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:52 +0200 Subject: [PATCH 0030/1519] staging: brcm80211: removed function declaration typedefs from dma.h part 2 Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 22 ++++++++-------- drivers/staging/brcm80211/brcmsmac/dma.h | 33 ++++++++---------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 5fd5e8c3063..3e732c8dd5a 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -389,16 +389,16 @@ static inline u32 parity32(u32 data); const struct di_fcn_s dma64proc = { (void (*)(struct dma_pub *)) _dma_detach, (void (*)(struct dma_pub *)) dma64_txinit, - (di_txreset_t) dma64_txreset, - (di_txenabled_t) dma64_txenabled, + (bool(*)(struct dma_pub *)) dma64_txreset, + (bool(*)(struct dma_pub *)) dma64_txenabled, (void (*)(struct dma_pub *)) dma64_txsuspend, (void (*)(struct dma_pub *)) dma64_txresume, - (di_txsuspended_t) dma64_txsuspended, - (di_txsuspendedidle_t) dma64_txsuspendedidle, + (bool(*)(struct dma_pub *)) dma64_txsuspended, + (bool(*)(struct dma_pub *)) dma64_txsuspendedidle, (di_txfast_t) dma64_txfast, (di_txunframed_t) dma64_txunframed, (di_getpos_t) dma64_getpos, - (di_txstopped_t) dma64_txstopped, + (bool(*)(struct dma_pub *)) dma64_txstopped, (di_txreclaim_t) dma64_txreclaim, (di_getnexttxp_t) dma64_getnexttxp, (di_peeknexttxp_t) _dma_peeknexttxp, @@ -408,13 +408,13 @@ const struct di_fcn_s dma64proc = { (void (*)(struct dma_pub *)) dma64_txrotate, (void (*)(struct dma_pub *)) _dma_rxinit, - (di_rxreset_t) dma64_rxreset, - (di_rxidle_t) dma64_rxidle, - (di_rxstopped_t) dma64_rxstopped, - (di_rxenable_t) _dma_rxenable, - (di_rxenabled_t) dma64_rxenabled, + (bool(*)(struct dma_pub *)) dma64_rxreset, + (bool(*)(struct dma_pub *)) dma64_rxidle, + (bool(*)(struct dma_pub *)) dma64_rxstopped, + (bool(*)(struct dma_pub *)) _dma_rxenable, + (bool(*)(struct dma_pub *)) dma64_rxenabled, (di_rx_t) _dma_rx, - (di_rxfill_t) _dma_rxfill, + (bool(*)(struct dma_pub *)) _dma_rxfill, (void (*)(struct dma_pub *)) _dma_rxreclaim, (di_getnextrxp_t) _dma_getnextrxp, (di_peeknextrxp_t) _dma_peeknextrxp, diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 69f2e9447b0..6d6dbd85f3e 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -59,23 +59,12 @@ enum txd_range { }; /* dma function type */ -typedef bool(*di_txreset_t) (struct dma_pub *dmah); -typedef bool(*di_rxreset_t) (struct dma_pub *dmah); -typedef bool(*di_rxidle_t) (struct dma_pub *dmah); -typedef bool(*di_txenabled_t) (struct dma_pub *dmah); -typedef bool(*di_txsuspended_t) (struct dma_pub *dmah); -typedef bool(*di_txsuspendedidle_t) (struct dma_pub *dmah); typedef int (*di_txfast_t) (struct dma_pub *dmah, struct sk_buff *p, bool commit); typedef int (*di_txunframed_t) (struct dma_pub *dmah, void *p, uint len, bool commit); typedef void *(*di_getpos_t) (struct dma_pub *di, bool direction); -typedef bool(*di_txstopped_t) (struct dma_pub *dmah); -typedef bool(*di_rxstopped_t) (struct dma_pub *dmah); -typedef bool(*di_rxenable_t) (struct dma_pub *dmah); -typedef bool(*di_rxenabled_t) (struct dma_pub *dmah); typedef void *(*di_rx_t) (struct dma_pub *dmah); -typedef bool(*di_rxfill_t) (struct dma_pub *dmah); typedef void (*di_txreclaim_t) (struct dma_pub *dmah, enum txd_range range); typedef unsigned long (*di_getvar_t) (struct dma_pub *dmah, const char *name); @@ -101,16 +90,16 @@ typedef uint(*di_txcommitted_t) (struct dma_pub *dmah); struct di_fcn_s { void (*detach)(struct dma_pub *dmah); void (*txinit)(struct dma_pub *dmah); - di_txreset_t txreset; - di_txenabled_t txenabled; + bool (*txreset)(struct dma_pub *dmah); + bool (*txenabled)(struct dma_pub *dmah); void (*txsuspend)(struct dma_pub *dmah); void (*txresume)(struct dma_pub *dmah); - di_txsuspended_t txsuspended; - di_txsuspendedidle_t txsuspendedidle; + bool (*txsuspended)(struct dma_pub *dmah); + bool (*txsuspendedidle)(struct dma_pub *dmah); di_txfast_t txfast; di_txunframed_t txunframed; di_getpos_t getpos; - di_txstopped_t txstopped; + bool (*txstopped)(struct dma_pub *dmah); di_txreclaim_t txreclaim; di_getnexttxp_t getnexttxp; di_peeknexttxp_t peeknexttxp; @@ -120,13 +109,13 @@ struct di_fcn_s { void (*txrotate) (struct dma_pub *dmah); void (*rxinit)(struct dma_pub *dmah); - di_rxreset_t rxreset; - di_rxidle_t rxidle; - di_rxstopped_t rxstopped; - di_rxenable_t rxenable; - di_rxenabled_t rxenabled; + bool (*rxreset)(struct dma_pub *dmah); + bool (*rxidle)(struct dma_pub *dmah); + bool (*rxstopped)(struct dma_pub *dmah); + bool (*rxenable)(struct dma_pub *dmah); + bool (*rxenabled)(struct dma_pub *dmah); di_rx_t rx; - di_rxfill_t rxfill; + bool (*rxfill)(struct dma_pub *dmah); void (*rxreclaim)(struct dma_pub *dmah); di_getnextrxp_t getnextrxp; di_peeknextrxp_t peeknextrxp; From 6fe3c48d3cd9495e9482b80f59255421da94a100 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:53 +0200 Subject: [PATCH 0031/1519] staging: brcm80211: removed function declaration typedefs from dma.h part 3 Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 8 ++++---- drivers/staging/brcm80211/brcmsmac/dma.h | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 3e732c8dd5a..ebc08488f90 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -404,7 +404,7 @@ const struct di_fcn_s dma64proc = { (di_peeknexttxp_t) _dma_peeknexttxp, (void (*)(struct dma_pub *)) _dma_txblock, (void (*)(struct dma_pub *)) _dma_txunblock, - (di_txactive_t) _dma_txactive, + (uint (*)(struct dma_pub *)) _dma_txactive, (void (*)(struct dma_pub *)) dma64_txrotate, (void (*)(struct dma_pub *)) _dma_rxinit, @@ -427,9 +427,9 @@ const struct di_fcn_s dma64proc = { NULL, NULL, NULL, - (di_rxactive_t) _dma_rxactive, - (di_txpending_t) _dma_txpending, - (di_txcommitted_t) _dma_txcommitted, + (uint (*)(struct dma_pub *)) _dma_rxactive, + (uint (*)(struct dma_pub *)) _dma_txpending, + (uint (*)(struct dma_pub *)) _dma_txcommitted, 39 }; diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 6d6dbd85f3e..5dc7e0b6201 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -74,7 +74,6 @@ typedef void *(*di_peeknexttxp_t) (struct dma_pub *dmah); typedef void *(*di_peeknextrxp_t) (struct dma_pub *dmah); typedef void (*di_rxparam_get_t) (struct dma_pub *dmah, u16 *rxoffset, u16 *rxbufsize); -typedef uint(*di_txactive_t) (struct dma_pub *dmah); typedef uint(*di_ctrlflags_t) (struct dma_pub *dmah, uint mask, uint flags); typedef char *(*di_dump_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, bool dumpring); @@ -82,9 +81,6 @@ typedef char *(*di_dumptx_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, bool dumpring); typedef char *(*di_dumprx_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, bool dumpring); -typedef uint(*di_rxactive_t) (struct dma_pub *dmah); -typedef uint(*di_txpending_t) (struct dma_pub *dmah); -typedef uint(*di_txcommitted_t) (struct dma_pub *dmah); /* dma opsvec */ struct di_fcn_s { @@ -105,7 +101,7 @@ struct di_fcn_s { di_peeknexttxp_t peeknexttxp; void (*txblock) (struct dma_pub *dmah); void (*txunblock) (struct dma_pub *dmah); - di_txactive_t txactive; + uint (*txactive)(struct dma_pub *dmah); void (*txrotate) (struct dma_pub *dmah); void (*rxinit)(struct dma_pub *dmah); @@ -128,9 +124,9 @@ struct di_fcn_s { di_dump_t dump; di_dumptx_t dumptx; di_dumprx_t dumprx; - di_rxactive_t rxactive; - di_txpending_t txpending; - di_txcommitted_t txcommitted; + uint (*rxactive)(struct dma_pub *dmah); + uint (*txpending)(struct dma_pub *dmah); + uint (*txcommitted)(struct dma_pub *dmah); uint endnum; }; From bc8adcd5231415e397ae4058ceef030e7be9aff5 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:54 +0200 Subject: [PATCH 0032/1519] staging: brcm80211: removed function declaration typedefs from dma.h part 4 Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 24 +++++----- drivers/staging/brcm80211/brcmsmac/dma.h | 60 +++++++++--------------- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index ebc08488f90..517dc61e115 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -395,13 +395,13 @@ const struct di_fcn_s dma64proc = { (void (*)(struct dma_pub *)) dma64_txresume, (bool(*)(struct dma_pub *)) dma64_txsuspended, (bool(*)(struct dma_pub *)) dma64_txsuspendedidle, - (di_txfast_t) dma64_txfast, - (di_txunframed_t) dma64_txunframed, - (di_getpos_t) dma64_getpos, + (int (*)(struct dma_pub *, struct sk_buff *, bool)) dma64_txfast, + (int (*)(struct dma_pub *, void *, uint, bool)) dma64_txunframed, + (void *(*)(struct dma_pub *, bool)) dma64_getpos, (bool(*)(struct dma_pub *)) dma64_txstopped, - (di_txreclaim_t) dma64_txreclaim, - (di_getnexttxp_t) dma64_getnexttxp, - (di_peeknexttxp_t) _dma_peeknexttxp, + (void (*)(struct dma_pub *, enum txd_range)) dma64_txreclaim, + (void *(*)(struct dma_pub *, enum txd_range)) dma64_getnexttxp, + (void *(*)(struct dma_pub *)) _dma_peeknexttxp, (void (*)(struct dma_pub *)) _dma_txblock, (void (*)(struct dma_pub *)) _dma_txunblock, (uint (*)(struct dma_pub *)) _dma_txactive, @@ -413,17 +413,17 @@ const struct di_fcn_s dma64proc = { (bool(*)(struct dma_pub *)) dma64_rxstopped, (bool(*)(struct dma_pub *)) _dma_rxenable, (bool(*)(struct dma_pub *)) dma64_rxenabled, - (di_rx_t) _dma_rx, + (void *(*)(struct dma_pub *)) _dma_rx, (bool(*)(struct dma_pub *)) _dma_rxfill, (void (*)(struct dma_pub *)) _dma_rxreclaim, - (di_getnextrxp_t) _dma_getnextrxp, - (di_peeknextrxp_t) _dma_peeknextrxp, - (di_rxparam_get_t) _dma_rx_param_get, + (void *(*)(struct dma_pub *, bool)) _dma_getnextrxp, + (void *(*)(struct dma_pub *)) _dma_peeknextrxp, + (void (*)(struct dma_pub *, u16 *, u16 *)) _dma_rx_param_get, (void (*)(struct dma_pub *)) _dma_fifoloopbackenable, - (di_getvar_t) _dma_getvar, + (unsigned long (*)(struct dma_pub *, const char *)) _dma_getvar, (void (*)(struct dma_pub *)) _dma_counterreset, - (di_ctrlflags_t) _dma_ctrlflags, + (uint (*)(struct dma_pub *, uint, uint)) _dma_ctrlflags, NULL, NULL, NULL, diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 5dc7e0b6201..3ff109fa3e7 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -58,30 +58,6 @@ enum txd_range { DMA_RANGE_TRANSFERED }; -/* dma function type */ -typedef int (*di_txfast_t) (struct dma_pub *dmah, struct sk_buff *p, - bool commit); -typedef int (*di_txunframed_t) (struct dma_pub *dmah, void *p, uint len, - bool commit); -typedef void *(*di_getpos_t) (struct dma_pub *di, bool direction); -typedef void *(*di_rx_t) (struct dma_pub *dmah); -typedef void (*di_txreclaim_t) (struct dma_pub *dmah, enum txd_range range); -typedef unsigned long (*di_getvar_t) (struct dma_pub *dmah, - const char *name); -typedef void *(*di_getnexttxp_t) (struct dma_pub *dmah, enum txd_range range); -typedef void *(*di_getnextrxp_t) (struct dma_pub *dmah, bool forceall); -typedef void *(*di_peeknexttxp_t) (struct dma_pub *dmah); -typedef void *(*di_peeknextrxp_t) (struct dma_pub *dmah); -typedef void (*di_rxparam_get_t) (struct dma_pub *dmah, u16 *rxoffset, - u16 *rxbufsize); -typedef uint(*di_ctrlflags_t) (struct dma_pub *dmah, uint mask, uint flags); -typedef char *(*di_dump_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); -typedef char *(*di_dumptx_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); -typedef char *(*di_dumprx_t) (struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); - /* dma opsvec */ struct di_fcn_s { void (*detach)(struct dma_pub *dmah); @@ -92,13 +68,14 @@ struct di_fcn_s { void (*txresume)(struct dma_pub *dmah); bool (*txsuspended)(struct dma_pub *dmah); bool (*txsuspendedidle)(struct dma_pub *dmah); - di_txfast_t txfast; - di_txunframed_t txunframed; - di_getpos_t getpos; + int (*txfast)(struct dma_pub *dmah, struct sk_buff *p, bool commit); + int (*txunframed)(struct dma_pub *dmah, void *p, uint len, bool commit); + + void *(*getpos)(struct dma_pub *di, bool direction); bool (*txstopped)(struct dma_pub *dmah); - di_txreclaim_t txreclaim; - di_getnexttxp_t getnexttxp; - di_peeknexttxp_t peeknexttxp; + void (*txreclaim)(struct dma_pub *dmah, enum txd_range range); + void *(*getnexttxp)(struct dma_pub *dmah, enum txd_range range); + void *(*peeknexttxp) (struct dma_pub *dmah); void (*txblock) (struct dma_pub *dmah); void (*txunblock) (struct dma_pub *dmah); uint (*txactive)(struct dma_pub *dmah); @@ -110,20 +87,25 @@ struct di_fcn_s { bool (*rxstopped)(struct dma_pub *dmah); bool (*rxenable)(struct dma_pub *dmah); bool (*rxenabled)(struct dma_pub *dmah); - di_rx_t rx; + void *(*rx)(struct dma_pub *dmah); bool (*rxfill)(struct dma_pub *dmah); void (*rxreclaim)(struct dma_pub *dmah); - di_getnextrxp_t getnextrxp; - di_peeknextrxp_t peeknextrxp; - di_rxparam_get_t rxparam_get; + void *(*getnextrxp)(struct dma_pub *dmah, bool forceall); + void *(*peeknextrxp)(struct dma_pub *dmah); + void (*rxparam_get)(struct dma_pub *dmah, u16 *rxoffset, + u16 *rxbufsize); void (*fifoloopbackenable)(struct dma_pub *dmah); - di_getvar_t d_getvar; + unsigned long (*d_getvar)(struct dma_pub *dmah, const char *name); + void (*counterreset)(struct dma_pub *dmah); - di_ctrlflags_t ctrlflags; - di_dump_t dump; - di_dumptx_t dumptx; - di_dumprx_t dumprx; + uint (*ctrlflags)(struct dma_pub *dmah, uint mask, uint flags); + char *(*dump)(struct dma_pub *dmah, struct brcmu_strbuf *b, + bool dumpring); + char *(*dumptx)(struct dma_pub *dmah, struct brcmu_strbuf *b, + bool dumpring); + char *(*dumprx)(struct dma_pub *dmah, struct brcmu_strbuf *b, + bool dumpring); uint (*rxactive)(struct dma_pub *dmah); uint (*txpending)(struct dma_pub *dmah); uint (*txcommitted)(struct dma_pub *dmah); From 87c0c569a271d4c7d0844b9da28f0c1fec672330 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:55 +0200 Subject: [PATCH 0033/1519] staging: brcm80211: removed function declaration typedefs from otp.c Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/otp.c | 34 +++++++++--------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 34253cf3781..a257ed86b87 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -59,23 +59,15 @@ #define MAXNUMRDES 9 /* Maximum OTP redundancy entries */ -/* OTP common function type */ -typedef int (*otp_status_t) (void *oh); -typedef int (*otp_size_t) (void *oh); -typedef void *(*otp_init_t) (struct si_pub *sih); -typedef u16(*otp_read_bit_t) (void *oh, chipcregs_t *cc, uint off); -typedef int (*otp_read_region_t) (struct si_pub *sih, int region, u16 *data, - uint *wlen); -typedef int (*otp_nvread_t) (void *oh, char *data, uint *len); - /* OTP function struct */ struct otp_fn_s { - otp_size_t size; - otp_read_bit_t read_bit; - otp_init_t init; - otp_read_region_t read_region; - otp_nvread_t nvread; - otp_status_t status; + int (*size)(void *oh); + u16 (*read_bit)(void *oh, chipcregs_t *cc, uint off); + void *(*init)(struct si_pub *sih); + int (*read_region)(struct si_pub *sih, int region, u16 *data, + uint *wlen); + int (*nvread)(void *oh, char *data, uint *len); + int (*status)(void *oh); }; struct otpinfo { @@ -445,14 +437,14 @@ static int ipxotp_nvread(void *oh, char *data, uint *len) } static struct otp_fn_s ipxotp_fn = { - (otp_size_t) ipxotp_size, - (otp_read_bit_t) ipxotp_read_bit, + (int (*)(void *)) ipxotp_size, + (u16 (*)(void *, chipcregs_t *, uint)) ipxotp_read_bit, - (otp_init_t) ipxotp_init, - (otp_read_region_t) ipxotp_read_region, - (otp_nvread_t) ipxotp_nvread, + (void *(*)(struct si_pub *)) ipxotp_init, + (int (*)(struct si_pub *, int, u16 *, uint *)) ipxotp_read_region, + (int (*)(void *, char *, uint *)) ipxotp_nvread, - (otp_status_t) ipxotp_status + (int (*)(void *)) ipxotp_status }; /* From d119df12b45293366d0f344d6e9335df5d94ae64 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:56 +0200 Subject: [PATCH 0034/1519] staging: brcm80211: removed function declaration typedefs from main.h,pub.h Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 4 +- drivers/staging/brcm80211/brcmsmac/main.h | 46 +++++++++++++++++------ drivers/staging/brcm80211/brcmsmac/pub.h | 27 ++----------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index bd3d5f092eb..66de7ef0481 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6265,8 +6265,8 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, * register watchdog and down handlers. */ int brcms_c_module_register(struct brcms_pub *pub, - const char *name, void *hdl, - watchdog_fn_t w_fn, down_fn_t d_fn) + const char *name, void *hdl, + int (*w_fn)(void *handle), int (*d_fn)(void *handle)) { struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; int i; diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index bf36f10998c..e61f047f3a0 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -408,11 +408,11 @@ struct brcms_band { u16 bcntsfoff; /* beacon tsf offset */ }; -/* tx completion callback takes 3 args */ -typedef void (*pkcb_fn_t) (struct brcms_c_info *wlc, uint txstatus, void *arg); - struct pkt_cb { - pkcb_fn_t fn; /* function to call when tx frame completes */ + /* function to call when tx frame completes */ + /* tx completion callback takes 3 args */ + void (*fn)(struct brcms_c_info *wlc, uint txstatus, void *arg); + void *arg; /* void arg for fn */ u8 nextidx; /* index of next call back if threading */ bool entered; /* recursion check */ @@ -423,19 +423,41 @@ struct modulecb { char name[32]; /* module name : NULL indicates empty array member */ const struct brcmu_iovar *iovars; /* iovar table */ void *hdl; /* handle passed when handler 'doiovar' is called */ - watchdog_fn_t watchdog_fn; /* watchdog handler */ - iovar_fn_t iovar_fn; /* iovar handler */ - down_fn_t down_fn; /* down handler. Note: the int returned - * by the down function is a count of the - * number of timers that could not be - * freed. - */ + int (*watchdog_fn)(void *handle); /* watchdog handler */ + + /* IOVar handler + * + * handle - a pointer value registered with the function + * vi - iovar_info that was looked up + * actionid - action ID, calculated by IOV_GVAL() and IOV_SVAL() + * based on varid. + * name - the actual iovar name + * params/plen - parameters and length for a get, input only. + * arg/len - buffer and length for value to be set or retrieved, + * input or output. + * vsize - value size, valid for integer type only. + * wlcif - interface context (brcms_c_if pointer) + * + * All pointers may point into the same buffer. + */ + int (*iovar_fn)(void *handle, const struct brcmu_iovar *vi, + u32 actionid, const char *name, void *params, + uint plen, void *arg, int alen, int vsize, + struct brcms_c_if *wlcif); + + int (*down_fn)(void *handle); /* down handler. Note: the int returned + * by the down function is a count of the + * number of timers that could not be + * freed. + */ + }; /* dump control blocks */ struct dumpcb_s { const char *name; /* dump name */ - dump_fn_t dump_fn; /* 'wl dump' handler */ + /* 'wl dump' handler */ + int (*dump_fn)(void *handle, struct brcmu_strbuf *b); void *dump_fn_arg; struct dumpcb_s *next; }; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 01d74609560..8ec398a3eb4 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -203,29 +203,6 @@ struct brcms_bss_info { #define IOVF_GET_BAND (1<<13) /* get requires fixed band */ #define IOVF_OPEN_ALLOW (1<<14) /* set allowed iovar for opensrc */ -/* watchdog down and dump callback function proto's */ -typedef int (*watchdog_fn_t) (void *handle); -typedef int (*down_fn_t) (void *handle); -typedef int (*dump_fn_t) (void *handle, struct brcmu_strbuf *b); - -/* IOVar handler - * - * handle - a pointer value registered with the function - * vi - iovar_info that was looked up - * actionid - action ID, calculated by IOV_GVAL() and IOV_SVAL() based on varid. - * name - the actual iovar name - * params/plen - parameters and length for a get, input only. - * arg/len - buffer and length for value to be set or retrieved, input or output. - * vsize - value size, valid for integer type only. - * wlcif - interface context (brcms_c_if pointer) - * - * All pointers may point into the same buffer. - */ -typedef int (*iovar_fn_t) (void *handle, const struct brcmu_iovar *vi, - u32 actionid, const char *name, void *params, - uint plen, void *arg, int alen, int vsize, - struct brcms_c_if *wlcif); - #define MAC80211_PROMISC_BCNS (1 << 0) #define MAC80211_SCAN (1 << 1) @@ -635,7 +612,9 @@ extern void brcms_c_mctrl(struct brcms_c_info *wlc, u32 mask, u32 val); extern int brcms_c_module_register(struct brcms_pub *pub, const char *name, void *hdl, - watchdog_fn_t watchdog_fn, down_fn_t down_fn); + int (*watchdog_fn)(void *handle), + int (*down_fn)(void *handle)); + extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, void *hdl); extern void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc); From 69d90bb0e46a2637a06519cf2909c7c9240c6f0e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:57 +0200 Subject: [PATCH 0035/1519] staging: brcm80211: removed function declaration typedefs from brcmutil Softmac related code cleanup. Typedefs are undesirable according to the CodingStyle document. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmutil/utils.c | 4 ++-- drivers/staging/brcm80211/include/brcmu_utils.h | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 37b6b779779..cad1600e6d4 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -219,7 +219,7 @@ EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); void brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, - ifpkt_cb_t fn, void *arg) + bool (*fn)(struct sk_buff *, void *), void *arg) { struct pktq_prec *q; struct sk_buff *p, *prev = NULL; @@ -251,7 +251,7 @@ brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, EXPORT_SYMBOL(brcmu_pktq_pflush); void brcmu_pktq_flush(struct pktq *pq, bool dir, - ifpkt_cb_t fn, void *arg) + bool (*fn)(struct sk_buff *, void *), void *arg) { int prec; for (prec = 0; prec < pq->num_prec; prec++) diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index 2d54cc5f4b1..8a340f06b50 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -72,9 +72,6 @@ struct pktq { struct pktq_prec q[PKTQ_MAX_PREC]; }; -/* fn(pkt, arg). return true if pkt belongs to if */ -typedef bool(*ifpkt_cb_t) (struct sk_buff *, void *); - /* operations on a specific precedence in packet queue */ #define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max)) @@ -98,8 +95,9 @@ extern struct sk_buff *brcmu_pkt_buf_get_skb(uint len); extern void brcmu_pkt_buf_free_skb(struct sk_buff *skb); /* Empty the queue at particular precedence level */ +/* callback function fn(pkt, arg) returns true if pkt belongs to if */ extern void brcmu_pktq_pflush(struct pktq *pq, int prec, - bool dir, ifpkt_cb_t fn, void *arg); + bool dir, bool (*fn)(struct sk_buff *, void *), void *arg); /* operations on a set of precedences in packet queue */ @@ -127,7 +125,7 @@ extern void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len); /* prec_out may be NULL if caller is not interested in return value */ extern struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out); extern void brcmu_pktq_flush(struct pktq *pq, bool dir, - ifpkt_cb_t fn, void *arg); + bool (*fn)(struct sk_buff *, void *), void *arg); /* externs */ /* packet */ From 6bd20a1b559130444ad4fea03a52e0cb2c347431 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:58 +0200 Subject: [PATCH 0036/1519] staging: brcm80211: replaced various typedefs Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 6 +- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 10 +- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 4 +- drivers/staging/brcm80211/brcmsmac/ampdu.c | 4 +- drivers/staging/brcm80211/brcmsmac/channel.c | 111 ++++++++-------- drivers/staging/brcm80211/brcmsmac/channel.h | 10 +- drivers/staging/brcm80211/brcmsmac/dma.c | 36 ++--- drivers/staging/brcm80211/brcmsmac/main.c | 123 +++++++++--------- drivers/staging/brcm80211/brcmsmac/main.h | 54 ++++---- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 46 +++---- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 26 ++-- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 34 ++--- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 12 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 18 +-- drivers/staging/brcm80211/brcmsmac/pub.h | 4 +- drivers/staging/brcm80211/brcmsmac/rate.c | 4 +- drivers/staging/brcm80211/brcmsmac/rate.h | 4 +- drivers/staging/brcm80211/brcmsmac/stf.c | 10 +- drivers/staging/brcm80211/brcmsmac/stf.h | 6 +- drivers/staging/brcm80211/brcmsmac/types.h | 5 - drivers/staging/brcm80211/brcmutil/wifi.c | 4 +- .../staging/brcm80211/include/brcmu_wifi.h | 36 ++--- 22 files changed, 286 insertions(+), 281 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 82bf04df16d..537eb00cd0c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -376,7 +376,7 @@ struct brcmf_bss_info { uint count; /* # rates in this set */ u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */ } rateset; /* supported rates */ - chanspec_t chanspec; /* chanspec for bss */ + u16 chanspec; /* chanspec for bss */ u16 atim_window; /* units are Kusec */ u8 dtim_period; /* DTIM period */ s16 RSSI; /* receive signal strength (in dBm) */ @@ -464,10 +464,10 @@ struct brcmf_assoc_params { s32 chanspec_num; /* 0: all available channels, * otherwise count of chanspecs in chanspec_list */ - chanspec_t chanspec_list[1]; /* list of chanspecs */ + u16 chanspec_list[1]; /* list of chanspecs */ }; #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ - (sizeof(struct brcmf_assoc_params) - sizeof(chanspec_t)) + (sizeof(struct brcmf_assoc_params) - sizeof(u16)) /* used for join with or without a specific bssid and channel list */ struct brcmf_join_params { diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 821206d3e53..a9494e78193 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2190,7 +2190,7 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_pmksa *pmksa) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct _pmkid_list *pmkids = &cfg_priv->pmk_list->pmkids; + struct pmkid_list *pmkids = &cfg_priv->pmk_list->pmkids; s32 err = 0; int i; @@ -2224,7 +2224,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_pmksa *pmksa) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct _pmkid_list pmkid; + struct pmkid_list pmkid; s32 err = 0; int i; @@ -2247,7 +2247,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, if ((cfg_priv->pmk_list->pmkids.npmkid > 0) && (i < cfg_priv->pmk_list->pmkids.npmkid)) { memset(&cfg_priv->pmk_list->pmkids.pmkid[i], 0, - sizeof(pmkid_t)); + sizeof(struct pmkid)); for (; i < (cfg_priv->pmk_list->pmkids.npmkid - 1); i++) { memcpy(&cfg_priv->pmk_list->pmkids.pmkid[i].BSSID, &cfg_priv->pmk_list->pmkids.pmkid[i + 1].BSSID, @@ -2780,7 +2780,7 @@ static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, size_t *join_params_size) { - chanspec_t chanspec = 0; + u16 chanspec = 0; if (ch != 0) { join_params->params.chanspec_num = 1; @@ -2795,7 +2795,7 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, chanspec |= WL_CHANSPEC_CTL_SB_NONE; *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + - join_params->params.chanspec_num * sizeof(chanspec_t); + join_params->params.chanspec_num * sizeof(u16); join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK; join_params->params.chanspec_list[0] |= chanspec; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index f26d08793ca..48f10d0403a 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -272,8 +272,8 @@ struct brcmf_cfg80211_assoc_ielen { /* wpa2 pmk list */ struct brcmf_cfg80211_pmk_list { - pmkid_list_t pmkids; - pmkid_t foo[MAXPMKID - 1]; + struct pmkid_list pmkids; + struct pmkid foo[MAXPMKID - 1]; }; /* dongle private data of cfg80211 interface */ diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index fcaf61e3b13..5d090385844 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -460,8 +460,8 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, struct scb_ampdu_tid_ini *ini; u8 mcs = 0; bool use_rts = false, use_cts = false; - ratespec_t rspec = 0, rspec_fallback = 0; - ratespec_t rts_rspec = 0, rts_rspec_fallback = 0; + u32 rspec = 0, rspec_fallback = 0; + u32 rts_rspec = 0, rts_rspec_fallback = 0; u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; struct ieee80211_rts *rts; u8 rr_retry_limit; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index eb61713125b..807df6ac61a 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -30,10 +30,14 @@ #define VALID_CHANNEL20(wlc, val) brcms_c_valid_channel20((wlc)->cmi, val) struct brcms_cm_band { - u8 locale_flags; /* struct locale_info flags */ - chanvec_t valid_channels; /* List of valid channels in the country */ - const chanvec_t *restricted_channels; /* List of restricted use channels */ - const chanvec_t *radar_channels; /* List of radar sensitive channels */ + /* struct locale_info flags */ + u8 locale_flags; + /* List of valid channels in the country */ + struct brcms_chanvec valid_channels; + /* List of restricted use channels */ + const struct brcms_chanvec *restricted_channels; + /* List of radar sensitive channels */ + const struct brcms_chanvec *radar_channels; u8 PAD[8]; }; @@ -49,7 +53,8 @@ struct brcms_cm_info { /* per-band state (one per phy/radio) */ struct brcms_cm_band bandstate[MAXBANDS]; /* quiet channels currently for radar sensitivity or 11h support */ - chanvec_t quiet_channels; /* channels on which we cannot transmit */ + /* channels on which we cannot transmit */ + struct brcms_chanvec quiet_channels; }; static int brcms_c_channels_init(struct brcms_cm_info *wlc_cm, @@ -78,7 +83,7 @@ brcms_c_countrycode_map(struct brcms_cm_info *wlc_cm, static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm); static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm); static bool brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, - chanspec_t chspec); + u16 chspec); static bool brcms_c_valid_channel20_db(struct brcms_cm_info *wlc_cm, uint val); static bool brcms_c_valid_channel20_in_band(struct brcms_cm_info *wlc_cm, uint bandunit, uint val); @@ -88,7 +93,7 @@ static const struct country_info * brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode); static void brcms_c_locale_get_channels(const struct locale_info *locale, - chanvec_t *valid_channels); + struct brcms_chanvec *valid_channels); static const struct locale_info *brcms_c_get_locale_2g(u8 locale_idx); static const struct locale_info *brcms_c_get_locale_5g(u8 locale_idx); static bool brcms_c_japan(struct brcms_c_info *wlc); @@ -96,8 +101,8 @@ static bool brcms_c_japan_ccode(const char *ccode); static void brcms_c_channel_min_txpower_limits_with_local_constraint( struct brcms_cm_info *wlc_cm, struct txpwr_limits *txpwr, u8 local_constraint_qdbm); -static void brcms_c_locale_add_channels(chanvec_t *target, - const chanvec_t *channels); +static void brcms_c_locale_add_channels(struct brcms_chanvec *target, + const struct brcms_chanvec *channels); static const struct locale_mimo_info *brcms_c_get_mimo_2g(u8 locale_idx); static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx); @@ -114,7 +119,7 @@ static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx); */ /* No channels */ -static const chanvec_t chanvec_none = { +static const struct brcms_chanvec chanvec_none = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -122,7 +127,7 @@ static const chanvec_t chanvec_none = { }; /* All 2.4 GHz HW channels */ -const chanvec_t chanvec_all_2G = { +const struct brcms_chanvec chanvec_all_2G = { {0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -130,7 +135,7 @@ const chanvec_t chanvec_all_2G = { }; /* All 5 GHz HW channels */ -const chanvec_t chanvec_all_5G = { +const struct brcms_chanvec chanvec_all_5G = { {0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x11, 0x11, 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x20, 0x22, 0x22, 0x00, 0x00, 0x11, @@ -144,7 +149,8 @@ const chanvec_t chanvec_all_5G = { /* No radar */ #define radar_set_none chanvec_none -static const chanvec_t radar_set1 = { /* Channels 52 - 64, 100 - 140 */ +/* Channels 52 - 64, 100 - 140 */ +static const struct brcms_chanvec radar_set1 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, /* 52 - 60 */ 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, /* 64, 100 - 124 */ 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128 - 140 */ @@ -158,7 +164,7 @@ static const chanvec_t radar_set1 = { /* Channels 52 - 64, 100 - 140 */ #define restricted_set_none chanvec_none /* Channels 34, 38, 42, 46 */ -static const chanvec_t restricted_set_japan_legacy = { +static const struct brcms_chanvec restricted_set_japan_legacy = { {0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -166,7 +172,7 @@ static const chanvec_t restricted_set_japan_legacy = { }; /* Channels 12, 13 */ -static const chanvec_t restricted_set_2g_short = { +static const struct brcms_chanvec restricted_set_2g_short = { {0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -174,7 +180,7 @@ static const chanvec_t restricted_set_2g_short = { }; /* Channel 165 */ -static const chanvec_t restricted_chan_165 = { +static const struct brcms_chanvec restricted_chan_165 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, @@ -182,7 +188,7 @@ static const chanvec_t restricted_chan_165 = { }; /* Channels 36 - 48 & 149 - 165 */ -static const chanvec_t restricted_low_hi = { +static const struct brcms_chanvec restricted_low_hi = { {0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x22, 0x22, 0x00, 0x00, 0x00, @@ -190,7 +196,7 @@ static const chanvec_t restricted_low_hi = { }; /* Channels 12 - 14 */ -static const chanvec_t restricted_set_12_13_14 = { +static const struct brcms_chanvec restricted_set_12_13_14 = { {0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -239,12 +245,12 @@ static const chanvec_t restricted_set_12_13_14 = { /* global memory to provide working buffer for expanded locale */ -static const chanvec_t *g_table_radar_set[] = { +static const struct brcms_chanvec *g_table_radar_set[] = { &chanvec_none, &radar_set1 }; -static const chanvec_t *g_table_restricted_chan[] = { +static const struct brcms_chanvec *g_table_restricted_chan[] = { &chanvec_none, /* restricted_set_none */ &restricted_set_2g_short, &restricted_chan_165, @@ -256,119 +262,119 @@ static const chanvec_t *g_table_restricted_chan[] = { &restricted_set_12_13_14 }; -static const chanvec_t locale_2g_01_11 = { +static const struct brcms_chanvec locale_2g_01_11 = { {0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_2g_12_13 = { +static const struct brcms_chanvec locale_2g_12_13 = { {0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_2g_14 = { +static const struct brcms_chanvec locale_2g_14 = { {0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_LOW_JP1 = { +static const struct brcms_chanvec locale_5g_LOW_JP1 = { {0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_LOW_JP2 = { +static const struct brcms_chanvec locale_5g_LOW_JP2 = { {0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_LOW1 = { +static const struct brcms_chanvec locale_5g_LOW1 = { {0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_LOW2 = { +static const struct brcms_chanvec locale_5g_LOW2 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_LOW3 = { +static const struct brcms_chanvec locale_5g_LOW3 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_MID1 = { +static const struct brcms_chanvec locale_5g_MID1 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_MID2 = { +static const struct brcms_chanvec locale_5g_MID2 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_MID3 = { +static const struct brcms_chanvec locale_5g_MID3 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_HIGH1 = { +static const struct brcms_chanvec locale_5g_HIGH1 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_HIGH2 = { +static const struct brcms_chanvec locale_5g_HIGH2 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_HIGH3 = { +static const struct brcms_chanvec locale_5g_HIGH3 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_52_140_ALL = { +static const struct brcms_chanvec locale_5g_52_140_ALL = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const chanvec_t locale_5g_HIGH4 = { +static const struct brcms_chanvec locale_5g_HIGH4 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11} }; -static const chanvec_t *g_table_locale_base[] = { +static const struct brcms_chanvec *g_table_locale_base[] = { &locale_2g_01_11, &locale_2g_12_13, &locale_2g_14, @@ -387,21 +393,20 @@ static const chanvec_t *g_table_locale_base[] = { &locale_5g_HIGH4 }; -static void brcms_c_locale_add_channels(chanvec_t *target, - const chanvec_t *channels) +static void brcms_c_locale_add_channels(struct brcms_chanvec *target, + const struct brcms_chanvec *channels) { u8 i; - for (i = 0; i < sizeof(chanvec_t); i++) { + for (i = 0; i < sizeof(struct brcms_chanvec); i++) target->vec[i] |= channels->vec[i]; - } } static void brcms_c_locale_get_channels(const struct locale_info *locale, - chanvec_t *channels) + struct brcms_chanvec *channels) { u8 i; - memset(channels, 0, sizeof(chanvec_t)); + memset(channels, 0, sizeof(struct brcms_chanvec)); for (i = 0; i < ARRAY_SIZE(g_table_locale_base); i++) { if (locale->valid_channels & (1 << i)) { @@ -870,7 +875,7 @@ brcms_c_channels_init(struct brcms_cm_info *wlc_cm, uint i, j; struct brcms_band *band; const struct locale_info *li; - chanvec_t sup_chan; + struct brcms_chanvec sup_chan; const struct locale_mimo_info *li_mimo; band = wlc->band; @@ -902,7 +907,7 @@ brcms_c_channels_init(struct brcms_cm_info *wlc_cm, brcms_c_locale_get_channels(li, &wlc_cm->bandstate[band->bandunit]. valid_channels); - for (j = 0; j < sizeof(chanvec_t); j++) + for (j = 0; j < sizeof(struct brcms_chanvec); j++) wlc_cm->bandstate[band->bandunit].valid_channels. vec[j] &= sup_chan.vec[j]; } @@ -969,9 +974,9 @@ static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) struct brcms_c_info *wlc = wlc_cm->wlc; uint i, j; struct brcms_band *band; - const chanvec_t *chanvec; + const struct brcms_chanvec *chanvec; - memset(&wlc_cm->quiet_channels, 0, sizeof(chanvec_t)); + memset(&wlc_cm->quiet_channels, 0, sizeof(struct brcms_chanvec)); band = wlc->band; for (i = 0; i < NBANDS(wlc); @@ -979,14 +984,14 @@ static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) /* initialize quiet channels for restricted channels */ chanvec = wlc_cm->bandstate[band->bandunit].restricted_channels; - for (j = 0; j < sizeof(chanvec_t); j++) + for (j = 0; j < sizeof(struct brcms_chanvec); j++) wlc_cm->quiet_channels.vec[j] |= chanvec->vec[j]; } } static bool -brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, chanspec_t chspec) +brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) { return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? (isset @@ -1117,7 +1122,7 @@ brcms_c_channel_min_txpower_limits_with_local_constraint( } void -brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, chanspec_t chanspec, +brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, u8 local_constraint_qdbm) { struct brcms_c_info *wlc = wlc_cm->wlc; @@ -1261,7 +1266,7 @@ static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) #endif /* POWER_DBG */ void -brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, chanspec_t chanspec, +brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, struct txpwr_limits *txpwr) { struct brcms_c_info *wlc = wlc_cm->wlc; @@ -1490,7 +1495,7 @@ static bool brcms_c_japan_ccode(const char *ccode) * are valid 20MZH channels in this locale and they are also a legal HT combination */ static bool -brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, chanspec_t chspec, +brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, bool dualband) { struct brcms_c_info *wlc = wlc_cm->wlc; @@ -1552,7 +1557,7 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, chanspec_t chspec, return false; } -bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, chanspec_t chspec) +bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, u16 chspec) { return brcms_c_valid_chanspec_ext(wlc_cm, chspec, true); } diff --git a/drivers/staging/brcm80211/brcmsmac/channel.h b/drivers/staging/brcm80211/brcmsmac/channel.h index d22f2f5f592..c9452bef647 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.h +++ b/drivers/staging/brcm80211/brcmsmac/channel.h @@ -98,8 +98,8 @@ struct locale_mimo_info { u8 flags; }; -extern const chanvec_t chanvec_all_2G; -extern const chanvec_t chanvec_all_5G; +extern const struct brcms_chanvec chanvec_all_2G; +extern const struct brcms_chanvec chanvec_all_5G; /* * Country names and abbreviations with locale defined from ISO 3166 @@ -120,13 +120,13 @@ extern u8 brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, uint bandunit); extern bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, - chanspec_t chspec); + u16 chspec); extern void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, - chanspec_t chanspec, + u16 chanspec, struct txpwr_limits *txpwr); extern void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, - chanspec_t chanspec, + u16 chanspec, u8 local_constraint_qdbm); #endif /* _WLC_CHANNEL_H */ diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 517dc61e115..84b5d80f9be 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -180,7 +180,6 @@ #define DMA_NONE(args) -typedef unsigned long dmaaddr_t; #define PHYSADDRHI(_pa) (0) #define PHYSADDRHISET(_pa, _val) #define PHYSADDRLO(_pa) ((_pa)) @@ -206,7 +205,7 @@ static uint dma_msg_level; /* One physical DMA segment */ struct dma_seg { - dmaaddr_t addr; + unsigned long addr; u32 length; }; @@ -257,8 +256,10 @@ struct dma_info { u16 txout; /* index of next descriptor to post */ void **txp; /* pointer to parallel array of pointers to packets */ struct dma_seg_map *txp_dmah; /* DMA MAP meta-data handle */ - dmaaddr_t txdpa; /* Aligned physical address of descriptor ring */ - dmaaddr_t txdpaorig; /* Original physical address of descriptor ring */ + /* Aligned physical address of descriptor ring */ + unsigned long txdpa; + /* Original physical address of descriptor ring */ + unsigned long txdpaorig; u16 txdalign; /* #bytes added to alloc'd mem to align txd */ u32 txdalloc; /* #bytes allocated for the ring */ u32 xmtptrbase; /* When using unaligned descriptors, the ptr register @@ -271,8 +272,10 @@ struct dma_info { u16 rxout; /* index of next descriptor to post */ void **rxp; /* pointer to parallel array of pointers to packets */ struct dma_seg_map *rxp_dmah; /* DMA MAP meta-data handle */ - dmaaddr_t rxdpa; /* Aligned physical address of descriptor ring */ - dmaaddr_t rxdpaorig; /* Original physical address of descriptor ring */ + /* Aligned physical address of descriptor ring */ + unsigned long rxdpa; + /* Original physical address of descriptor ring */ + unsigned long rxdpaorig; u16 rxdalign; /* #bytes added to alloc'd mem to align rxd */ u32 rxdalloc; /* #bytes allocated for the ring */ u32 rcvptrbase; /* Base for ptr reg when using unaligned descriptors */ @@ -331,7 +334,7 @@ static bool _dma_descriptor_align(struct dma_info *di); static bool _dma_alloc(struct dma_info *di, uint direction); static void _dma_detach(struct dma_info *di); static void _dma_ddtable_init(struct dma_info *di, uint direction, - dmaaddr_t pa); + unsigned long pa); static void _dma_rxinit(struct dma_info *di); static void *_dma_rx(struct dma_info *di); static bool _dma_rxfill(struct dma_info *di); @@ -357,7 +360,7 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - dmaaddr_t *descpa); + unsigned long *descpa); /* Prototypes for 64-bit routines */ static bool dma64_alloc(struct dma_info *di, uint direction); @@ -623,7 +626,7 @@ static inline u32 parity32(u32 data) static inline void dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, - dmaaddr_t pa, uint outidx, u32 *flags, u32 bufcount) + unsigned long pa, uint outidx, u32 *flags, u32 bufcount) { u32 ctrl2 = bufcount & D64_CTRL2_BC_MASK; @@ -754,7 +757,8 @@ static bool _dma_isaddrext(struct dma_info *di) } /* initialize descriptor table base address */ -static void _dma_ddtable_init(struct dma_info *di, uint direction, dmaaddr_t pa) +static void +_dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa) { if (!di->aligndesc_4k) { if (direction == DMA_TX) @@ -943,7 +947,7 @@ static bool _dma_rxfill(struct dma_info *di) u32 flags = 0; uint n; uint i; - dmaaddr_t pa; + unsigned long pa; uint extra_offset = 0; bool ring_empty; @@ -1194,7 +1198,7 @@ u8 dma_align_sizetobits(uint size) */ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - dmaaddr_t *descpa) + unsigned long *descpa) { void *va; u32 desc_strtaddr; @@ -1487,7 +1491,7 @@ dma64_txunframed(struct dma_info *di, void *buf, uint len, bool commit) { u16 txout; u32 flags = 0; - dmaaddr_t pa; /* phys addr */ + unsigned long pa; /* phys addr */ txout = di->txout; @@ -1544,7 +1548,7 @@ static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, uint len; u16 txout; u32 flags = 0; - dmaaddr_t pa; + unsigned long pa; DMA_TRACE(("%s: dma_txfast\n", di->name)); @@ -1702,7 +1706,7 @@ static void *dma64_getnexttxp(struct dma_info *di, enum txd_range range) goto bogus; for (i = start; i != end && !txp; i = NEXTTXD(i)) { - dmaaddr_t pa; + unsigned long pa; struct dma_seg_map *map = NULL; uint size, j, nsegs; @@ -1753,7 +1757,7 @@ static void *dma64_getnextrxp(struct dma_info *di, bool forceall) { uint i, curr; void *rxp; - dmaaddr_t pa; + unsigned long pa; i = di->rxin; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 66de7ef0481..252cd3b1407 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -324,7 +324,7 @@ static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, - mbool req_bit); + u32 req_bit); static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail); static int brcms_b_bandtype(struct brcms_hardware *wlc_hw); @@ -344,8 +344,7 @@ static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw); static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw); static void brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init); static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw); -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool want, - mbool flags); +static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool want, u32 flags); static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw); static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw); static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc); @@ -355,10 +354,10 @@ static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, int len); static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, int len); -static void brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec); +static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec); static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit); static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - chanspec_t chanspec); + u16 chanspec); static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, bool shortslot); static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw); @@ -372,10 +371,10 @@ static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, uint nfrags, uint queue, uint next_frag_len, struct wsec_key *key, - ratespec_t rspec_override); + u32 rspec_override); static void brcms_c_bss_default_init(struct brcms_c_info *wlc); static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc); -static ratespec_t mac80211_wlc_set_nrate(struct brcms_c_info *wlc, +static u32 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, u32 int_val); static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc); @@ -393,27 +392,27 @@ static void brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, struct brcms_txq_info *qi, bool on, int prio); static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc); -static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, ratespec_t rate, +static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rate, uint length, u8 *plcp); -static void brcms_c_compute_ofdm_plcp(ratespec_t rate, uint length, u8 *plcp); -static void brcms_c_compute_mimo_plcp(ratespec_t rate, uint length, u8 *plcp); -static u16 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, ratespec_t rate, +static void brcms_c_compute_ofdm_plcp(u32 rate, uint length, u8 *plcp); +static void brcms_c_compute_mimo_plcp(u32 rate, uint length, u8 *plcp); +static u16 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, u8 preamble_type, uint next_frag_len); static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, struct brcms_d11rxhdr *rxh); static void brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, struct sk_buff *p); -static uint brcms_c_calc_frame_len(struct brcms_c_info *wlc, ratespec_t rate, +static uint brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 rate, u8 preamble_type, uint dur); -static uint brcms_c_calc_ack_time(struct brcms_c_info *wlc, ratespec_t rate, +static uint brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rate, u8 preamble_type); -static uint brcms_c_calc_cts_time(struct brcms_c_info *wlc, ratespec_t rate, +static uint brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rate, u8 preamble_type); /* interrupt, up/down, band */ static void brcms_c_setband(struct brcms_c_info *wlc, uint bandunit); -static chanspec_t brcms_c_init_chanspec(struct brcms_c_info *wlc); +static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc); static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, - chanspec_t chanspec); + u16 chanspec); static void brcms_c_bsinit(struct brcms_c_info *wlc); static int brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, bool writeToShm); @@ -424,7 +423,7 @@ static void brcms_c_radio_enable(struct brcms_c_info *wlc); static void brcms_c_radio_upd(struct brcms_c_info *wlc); /* scan, association, BSS */ -static uint brcms_c_calc_ba_time(struct brcms_c_info *wlc, ratespec_t rate, +static uint brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rate, u8 preamble_type); static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap); static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val); @@ -1407,7 +1406,7 @@ static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) } /* band-specific init */ -static void brcms_b_bsinit(struct brcms_c_info *wlc, chanspec_t chanspec) +static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) { struct brcms_hardware *wlc_hw = wlc->hw; @@ -1550,7 +1549,7 @@ void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) /* switch to and initialize new band */ static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - chanspec_t chanspec) { + u16 chanspec) { struct brcms_c_info *wlc = wlc_hw->wlc; u32 macintmask; @@ -2226,7 +2225,7 @@ static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, } } -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, mbool flags) +static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) { u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; @@ -2924,7 +2923,7 @@ void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) } } -void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, mbool req_bit) +void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) { if (set) { if (mboolisset(wlc_hw->pllreq, req_bit)) @@ -3031,9 +3030,9 @@ void brcms_c_fatal_error(struct brcms_c_info *wlc) * if other configurations are in conflict (bandlocked, 11n mode disabled, * invalid channel for current country, etc.) */ -static chanspec_t brcms_c_init_chanspec(struct brcms_c_info *wlc) +static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc) { - chanspec_t chanspec = + u16 chanspec = 1 | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE | WL_CHANSPEC_BAND_2G; @@ -3236,7 +3235,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) } void -brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, +brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, bool mute) { u32 macintmask; bool fastclk; @@ -3290,7 +3289,7 @@ brcms_b_init(struct brcms_hardware *wlc_hw, chanspec_t chanspec, void brcms_c_init(struct brcms_c_info *wlc) { d11regs_t *regs; - chanspec_t chanspec; + u16 chanspec; int i; struct brcms_bss_cfg *bsscfg; bool mute = false; @@ -3582,7 +3581,7 @@ static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc) } /* propagate home chanspec to all bsscfgs in case bsscfg->current_bss->chanspec is referenced */ -void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, chanspec_t chanspec) +void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) { if (wlc->home_chanspec != chanspec) { int idx; @@ -3601,7 +3600,7 @@ void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, chanspec_t chanspec) } static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, - chanspec_t chanspec) + u16 chanspec) { /* Save our copy of the chanspec */ wlc->chanspec = chanspec; @@ -3621,7 +3620,7 @@ static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, } void -brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, +brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, bool mute, struct txpwr_limits *txpwr) { uint bandunit; @@ -3664,11 +3663,11 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, chanspec_t chanspec, } } -void brcms_c_set_chanspec(struct brcms_c_info *wlc, chanspec_t chanspec) +void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) { uint bandunit; bool switchband = false; - chanspec_t old_chanspec = wlc->chanspec; + u16 old_chanspec = wlc->chanspec; if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { wiphy_err(wlc->wiphy, "wl%d: %s: Bad channel %d\n", @@ -3720,10 +3719,10 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, chanspec_t chanspec) brcms_c_ucode_mac_upd(wlc); } -ratespec_t brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, +u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, wlc_rateset_t *rs) { - ratespec_t lowest_basic_rspec; + u32 lowest_basic_rspec; uint i; /* Use the lowest basic rate */ @@ -3750,7 +3749,7 @@ ratespec_t brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, * OFDM ant = 3 */ void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, - ratespec_t bcn_rspec) + u32 bcn_rspec) { u16 phyctl; u16 phytxant = wlc->stf->phytxant; @@ -3875,7 +3874,7 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) } static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, - chanspec_t chanspec) + u16 chanspec) { wlc_rateset_t default_rateset; uint parkband; @@ -6068,7 +6067,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, switch (cmd) { case BRCM_SET_CHANNEL:{ - chanspec_t chspec = CH20MHZ_CHSPEC(val); + u16 chspec = CH20MHZ_CHSPEC(val); if (val < 0 || val > MAXCHANNEL) { bcmerror = -EINVAL; @@ -6859,7 +6858,7 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, } void -brcms_c_compute_plcp(struct brcms_c_info *wlc, ratespec_t rspec, +brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, uint length, u8 *plcp) { if (IS_MCS(rspec)) { @@ -6873,7 +6872,7 @@ brcms_c_compute_plcp(struct brcms_c_info *wlc, ratespec_t rspec, } /* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_mimo_plcp(ratespec_t rspec, uint length, u8 *plcp) +static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) { u8 mcs = (u8) (rspec & RSPEC_RATE_MASK); plcp[0] = mcs; @@ -6888,7 +6887,7 @@ static void brcms_c_compute_mimo_plcp(ratespec_t rspec, uint length, u8 *plcp) /* Rate: 802.11 rate code, length: PSDU length in octets */ static void -brcms_c_compute_ofdm_plcp(ratespec_t rspec, u32 length, u8 *plcp) +brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) { u8 rate_signal; u32 tmp = 0; @@ -6961,7 +6960,7 @@ static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, } /* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, ratespec_t rspec, +static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, uint length, u8 *plcp) { int rate = RSPEC2RATE(rspec); @@ -6980,7 +6979,7 @@ static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, ratespec_t rspec, * preamble_type use short/GF or long/MM PLCP header */ static u16 -brcms_c_compute_frame_dur(struct brcms_c_info *wlc, ratespec_t rate, +brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, u8 preamble_type, uint next_frag_len) { u16 dur, sifs; @@ -7015,8 +7014,8 @@ brcms_c_compute_frame_dur(struct brcms_c_info *wlc, ratespec_t rate, */ u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, - ratespec_t rts_rate, - ratespec_t frame_rate, u8 rts_preamble_type, + u32 rts_rate, + u32 frame_rate, u8 rts_preamble_type, u8 frame_preamble_type, uint frame_len, bool ba) { u16 dur, sifs; @@ -7046,7 +7045,7 @@ brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, return dur; } -u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, ratespec_t rspec) +u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) { u16 phyctl1 = 0; u16 bw; @@ -7093,11 +7092,11 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, ratespec_t rspec) return phyctl1; } -ratespec_t -brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, ratespec_t rspec, +u32 +brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, bool use_rspec, u16 mimo_ctlchbw) { - ratespec_t rts_rspec = 0; + u32 rts_rspec = 0; if (use_rspec) { /* use frame rate as rts rate */ @@ -7153,7 +7152,7 @@ static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct sk_buff *p, struct scb *scb, uint frag, uint nfrags, uint queue, uint next_frag_len, - struct wsec_key *key, ratespec_t rspec_override) + struct wsec_key *key, u32 rspec_override) { struct ieee80211_hdr *h; struct d11txh *txh; @@ -7161,7 +7160,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, int len, phylen, rts_phylen; u16 mch, phyctl, xfts, mainrates; u16 seq = 0, mcl = 0, status = 0, frameid = 0; - ratespec_t rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }, rts_rspec[2] = { + u32 rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }, rts_rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M}; bool use_rts = false; bool use_cts = false; @@ -8062,7 +8061,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, struct brcms_d11rxhdr *wlc_rxh = (struct brcms_d11rxhdr *) rxh; int preamble; int channel; - ratespec_t rspec; + u32 rspec; unsigned char *plcp; /* fill in TSF and flag its presence */ @@ -8287,7 +8286,7 @@ void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) * len = 3(nsyms + nstream + 3) - 3 */ u16 -brcms_c_calc_lsig_len(struct brcms_c_info *wlc, ratespec_t ratespec, +brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len) { uint nsyms, len = 0, kNdps; @@ -8328,7 +8327,7 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, ratespec_t ratespec, /* calculate frame duration of a given rate and length, return time in usec unit */ uint -brcms_c_calc_frame_time(struct brcms_c_info *wlc, ratespec_t ratespec, +brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, u8 preamble_type, uint mac_len) { uint nsyms, dur = 0, Ndps, kNdps; @@ -8397,7 +8396,7 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, ratespec_t ratespec, /* The opposite of brcms_c_calc_frame_time */ static uint -brcms_c_calc_frame_len(struct brcms_c_info *wlc, ratespec_t ratespec, +brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, u8 preamble_type, uint dur) { uint nsyms, mac_len, Ndps, kNdps; @@ -8443,7 +8442,7 @@ brcms_c_calc_frame_len(struct brcms_c_info *wlc, ratespec_t ratespec, } static uint -brcms_c_calc_ba_time(struct brcms_c_info *wlc, ratespec_t rspec, +brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, u8 preamble_type) { BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, " @@ -8459,7 +8458,7 @@ brcms_c_calc_ba_time(struct brcms_c_info *wlc, ratespec_t rspec, } static uint -brcms_c_calc_ack_time(struct brcms_c_info *wlc, ratespec_t rspec, +brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, u8 preamble_type) { uint dur = 0; @@ -8478,7 +8477,7 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, ratespec_t rspec, } static uint -brcms_c_calc_cts_time(struct brcms_c_info *wlc, ratespec_t rspec, +brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, u8 preamble_type) { BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n", @@ -8663,7 +8662,7 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc) * Return true if the specified rate is supported by the specified band. * BRCM_BAND_AUTO indicates the current band. */ -bool brcms_c_valid_rate(struct brcms_c_info *wlc, ratespec_t rspec, int band, +bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, bool verbose) { wlc_rateset_t *hw_rateset; @@ -8776,7 +8775,7 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) */ static void brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, - ratespec_t bcn_rspec, + u32 bcn_rspec, struct brcms_bss_cfg *cfg, u16 *buf, int *len) { static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; @@ -9049,7 +9048,7 @@ void brcms_default_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs) static void brcms_c_bss_default_init(struct brcms_c_info *wlc) { - chanspec_t chanspec; + u16 chanspec; struct brcms_band *band; struct brcms_bss_info *bi = wlc->default_bss; @@ -9079,13 +9078,13 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) bi->flags |= BRCMS_BSS_HT; } -static ratespec_t +static u32 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, u32 int_val) { u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT; u8 rate = int_val & NRATE_RATE_MASK; - ratespec_t rspec; + u32 rspec; bool ismcs = ((int_val & NRATE_MCS_INUSE) == NRATE_MCS_INUSE); bool issgi = ((int_val & NRATE_SGI_MASK) >> NRATE_SGI_SHIFT); bool override_mcs_only = ((int_val & NRATE_OVERRIDE_MCS_ONLY) @@ -9093,7 +9092,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, int bcmerror = 0; if (!ismcs) { - return (ratespec_t) rate; + return (u32) rate; } /* validate the combination of rate/mcs/stf is allowed */ @@ -9301,7 +9300,7 @@ brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, memcpy(wlc->cfg->BSSID, addr, ETH_ALEN); } -void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, mbool req_bit) +void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit) { brcms_b_pllreq(wlc->hw, set, req_bit); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index e61f047f3a0..1feefcf7345 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -394,8 +394,8 @@ struct brcms_band { wlc_rateset_t defrateset; /* band-specific copy of default_bss.rateset */ - ratespec_t rspec_override; /* 802.11 rate override */ - ratespec_t mrspec_override; /* multicast rate override */ + u32 rspec_override; /* 802.11 rate override */ + u32 mrspec_override; /* multicast rate override */ u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */ s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */ wlc_rateset_t hw_rateset; /* rates supported by chip (phy-specific) */ @@ -557,12 +557,12 @@ struct brcms_hardware { bool up; /* d11 hardware up and running */ uint now; /* # elapsed seconds */ uint _nbands; /* # bands supported */ - chanspec_t chanspec; /* bmac chanspec shadow */ + u16 chanspec; /* bmac chanspec shadow */ uint *txavail[NFIFO]; /* # tx descriptors available */ u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */ - mbool pllreq; /* pll requests to keep PLL on */ + u32 pllreq; /* pll requests to keep PLL on */ u8 suspended_fifos; /* Which TX fifo to remain awake for */ u32 maccontrol; /* Cached value of maccontrol */ @@ -700,7 +700,7 @@ struct brcms_c_info { u32 WDlast; /* last time wlc_watchdog() was called */ /* WME */ - ac_bitmap_t wme_dp; /* Discard (oldest first) policy per AC */ + u8 wme_dp; /* AC bitmap. Discard (oldest first) policy per AC */ u16 edcf_txop[AC_COUNT]; /* current txop for each ac */ /* @@ -756,10 +756,10 @@ struct brcms_c_info { * specifed */ - chanspec_t home_chanspec; /* shared home chanspec */ + u16 home_chanspec; /* shared home chanspec */ /* PHY parameters */ - chanspec_t chanspec; /* target operational channel */ + u16 chanspec; /* target operational channel */ u16 usr_fragthresh; /* user configured fragmentation threshold */ u16 fragthresh[NFIFO]; /* per-fifo fragmentation thresholds */ u16 RTSThresh; /* 802.11 dot11RTSThreshold */ @@ -778,7 +778,7 @@ struct brcms_c_info { struct brcms_stf *stf; - ratespec_t bcn_rspec; /* save bcn ratespec purpose */ + u32 bcn_rspec; /* save bcn ratespec purpose */ uint tempsense_lasttime; @@ -865,9 +865,9 @@ struct brcms_bss_cfg { int auth_atmptd; /* auth type (open/shared) attempted */ - pmkid_cand_t pmkid_cand[MAXPMKID]; /* PMKID candidate list */ + struct pmkid_cand pmkid_cand[MAXPMKID]; /* PMKID candidate list */ uint npmkid_cand; /* num PMKID candidates */ - pmkid_t pmkid[MAXPMKID]; /* PMKID cache */ + struct pmkid pmkid[MAXPMKID]; /* PMKID cache */ uint npmkid; /* num cached PMKIDs */ struct brcms_bss_info *current_bss; /* BSS parms in ASSOCIATED state */ @@ -886,8 +886,8 @@ struct brcms_bss_cfg { /* 'unique' ID of this bsscfg, assigned at bsscfg allocation */ u16 ID; - uint txrspecidx; /* index into tx rate circular buffer */ - ratespec_t txrspec[NTXRATE][2]; /* circular buffer of prev MPDUs tx rates */ + uint txrspecidx; /* index into tx rate circular buffer */ + u32 txrspec[NTXRATE][2]; /* circular buffer of prev MPDUs tx rates */ }; #define CHANNEL_BANDUNIT(wlc, ch) (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) @@ -932,7 +932,7 @@ extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, void *buf); extern void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, void *bcn, int len, bool both); -extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, mbool req_bit); +extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit); extern void brcms_c_reset_bmac_done(struct brcms_c_info *wlc); #if defined(BCMDBG) @@ -945,7 +945,7 @@ extern void brcms_c_print_txdesc(struct d11txh *txh); extern void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit); extern void brcms_c_coredisable(struct brcms_hardware *wlc_hw); -extern bool brcms_c_valid_rate(struct brcms_c_info *wlc, ratespec_t rate, +extern bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rate, int band, bool verbose); extern void brcms_c_ap_upd(struct brcms_c_info *wlc); @@ -971,14 +971,14 @@ extern void brcms_c_send_q(struct brcms_c_info *wlc); extern int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifo); -extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, ratespec_t ratespec, +extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len); -extern ratespec_t brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, - ratespec_t rspec, +extern u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, + u32 rspec, bool use_rspec, u16 mimo_ctlchbw); extern u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, - ratespec_t rts_rate, - ratespec_t frame_rate, + u32 rts_rate, + u32 frame_rate, u8 rts_preamble_type, u8 frame_preamble_type, uint frame_len, bool ba); @@ -1012,15 +1012,15 @@ extern bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, void *pkt, int prec); extern bool brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, struct sk_buff *pkt, int prec, bool head); -extern u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, ratespec_t rspec); -extern void brcms_c_compute_plcp(struct brcms_c_info *wlc, ratespec_t rate, +extern u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec); +extern void brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rate, uint length, u8 *plcp); extern uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, - ratespec_t ratespec, + u32 ratespec, u8 preamble_type, uint mac_len); extern void brcms_c_set_chanspec(struct brcms_c_info *wlc, - chanspec_t chanspec); + u16 chanspec); extern bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit); @@ -1036,15 +1036,15 @@ extern void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend); extern void brcms_c_set_ratetable(struct brcms_c_info *wlc); extern int brcms_c_set_mac(struct brcms_bss_cfg *cfg); extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, - ratespec_t bcn_rate); + u32 bcn_rate); extern void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len); -extern ratespec_t brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, +extern u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, wlc_rateset_t *rs); extern void brcms_c_radio_disable(struct brcms_c_info *wlc); extern void brcms_c_bcn_li_upd(struct brcms_c_info *wlc); extern void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, - chanspec_t chanspec); + u16 chanspec); extern bool brcms_c_ps_allowed(struct brcms_c_info *wlc); extern bool brcms_c_stay_awake(struct brcms_c_info *wlc); extern void brcms_c_wme_initparams_sta(struct brcms_c_info *wlc, @@ -1055,7 +1055,7 @@ extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, /* chanspec, ucode interface */ extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, - chanspec_t chanspec, + u16 chanspec, bool mute, struct txpwr_limits *txpwr); extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index f4224efdb3a..13a447fea5b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -136,7 +136,9 @@ static void wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch); static void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, - struct txpwr_limits *tp, chanspec_t); + struct txpwr_limits *tp, + u16 chanspec); + static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi); static s8 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, @@ -862,7 +864,7 @@ void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate) pi->sh->up = newstate; } -void wlc_phy_init(struct brcms_phy_pub *pih, chanspec_t chanspec) +void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) { u32 mc; void (*phy_init) (struct brcms_phy *) = NULL; @@ -1207,7 +1209,7 @@ void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) } } -void wlc_phy_hold_upd(struct brcms_phy_pub *pih, mbool id, bool set) +void wlc_phy_hold_upd(struct brcms_phy_pub *pih, u32 id, bool set) { struct brcms_phy *pi = (struct brcms_phy *) pih; @@ -1220,7 +1222,7 @@ void wlc_phy_hold_upd(struct brcms_phy_pub *pih, mbool id, bool set) return; } -void wlc_phy_mute_upd(struct brcms_phy_pub *pih, bool mute, mbool flags) +void wlc_phy_mute_upd(struct brcms_phy_pub *pih, bool mute, u32 flags) { struct brcms_phy *pi = (struct brcms_phy *) pih; @@ -1311,25 +1313,25 @@ void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw) pi->bw = bw; } -void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, chanspec_t newch) +void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch) { struct brcms_phy *pi = (struct brcms_phy *) ppi; pi->radio_chanspec = newch; } -chanspec_t wlc_phy_chanspec_get(struct brcms_phy_pub *ppi) +u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi) { struct brcms_phy *pi = (struct brcms_phy *) ppi; return pi->radio_chanspec; } -void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, chanspec_t chanspec) +void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec) { struct brcms_phy *pi = (struct brcms_phy *) ppi; u16 m_cur_channel; - void (*chanspec_set) (struct brcms_phy *, chanspec_t) = NULL; + void (*chanspec_set) (struct brcms_phy *, u16) = NULL; m_cur_channel = CHSPEC_CHANNEL(chanspec); if (CHSPEC_IS5G(chanspec)) m_cur_channel |= D11_CURCHANNEL_5G; @@ -1359,7 +1361,7 @@ int wlc_phy_chanspec_freq2bandrange_lpssn(uint freq) return range; } -int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, chanspec_t chanspec) +int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, u16 chanspec) { int range = -1; uint channel = CHSPEC_CHANNEL(chanspec); @@ -1395,13 +1397,13 @@ int wlc_phy_channel2freq(uint channel) void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, - chanvec_t *channels) + struct brcms_chanvec *channels) { struct brcms_phy *pi = (struct brcms_phy *) ppi; uint i; uint channel; - memset(channels, 0, sizeof(chanvec_t)); + memset(channels, 0, sizeof(struct brcms_chanvec)); for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { channel = chan_info_all[i].chan; @@ -1416,12 +1418,12 @@ wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, } } -chanspec_t wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) +u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) { struct brcms_phy *pi = (struct brcms_phy *) ppi; uint i; uint channel; - chanspec_t chspec; + u16 chspec; for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { channel = chan_info_all[i].chan; @@ -1458,7 +1460,7 @@ chanspec_t wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) return chspec; } - return (chanspec_t) INVCHANSPEC; + return (u16) INVCHANSPEC; } int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override) @@ -1668,7 +1670,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) u8 tx_pwr_max_rate_ind = 0; u8 max_num_rate; u8 start_rate = 0; - chanspec_t chspec; + u16 chspec; u32 band = CHSPEC2BAND(pi->radio_chanspec); void (*txpwr_recalc_fn)(struct brcms_phy *) = NULL; @@ -1779,7 +1781,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, - chanspec_t chanspec) + u16 chanspec) { u8 tmp_txpwr_limit[2 * BRCMS_NUM_RATES_OFDM]; u8 *txpwr_ptr1 = NULL, *txpwr_ptr2 = NULL; @@ -1974,7 +1976,7 @@ void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end) void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *txpwr, - chanspec_t chanspec) + u16 chanspec) { struct brcms_phy *pi = (struct brcms_phy *) ppi; @@ -2847,7 +2849,7 @@ wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag) *eps_real -= 0x2000; } -static const fixed AtanTbl[] = { +static const s32 AtanTbl[] = { 2949120, 1740967, 919879, @@ -2868,9 +2870,9 @@ static const fixed AtanTbl[] = { 29 }; -void wlc_phy_cordic(fixed theta, cs32 *val) +void wlc_phy_cordic(s32 theta, struct cs32 *val) { - fixed angle, valtmp; + s32 angle, valtmp; unsigned iter; int signx = 1; int signtheta; @@ -3094,7 +3096,7 @@ u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih) return active_bitmap; } -s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, chanspec_t chanspec) +s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec) { struct brcms_phy *pi = (struct brcms_phy *) pih; u8 siso_mcs_id, cdd_mcs_id; @@ -3207,7 +3209,7 @@ wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset) *ofdmoffset = 0; } -s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, chanspec_t chanspec) +s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec) { return rssi; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index e27d9e95a2d..bc0cc59d79b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -126,8 +126,8 @@ struct txpwr_limits { struct tx_power { u32 flags; - chanspec_t chanspec; /* txpwr report for this channel */ - chanspec_t local_chanspec; /* channel on which we are associated */ + u16 chanspec; /* txpwr report for this channel */ + u16 local_chanspec; /* channel on which we are associated */ u8 local_max; /* local max according to the AP */ u8 local_constraint; /* local constraint according to the AP */ s8 antgain[2]; /* Ant gain for each band - from SROM */ @@ -150,7 +150,7 @@ struct tx_inst_power { u8 txpwr_est_Pout_gofdm; /* Pwr estimate for 2.4 OFDM */ }; -struct chanvec { +struct brcms_chanvec { u8 vec[MAXCHANNEL / NBBY]; }; @@ -189,7 +189,7 @@ extern u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih); extern void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate); extern void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate); -extern void wlc_phy_init(struct brcms_phy_pub *ppi, chanspec_t chanspec); +extern void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec); extern void wlc_phy_watchdog(struct brcms_phy_pub *ppi); extern int wlc_phy_down(struct brcms_phy_pub *ppi); extern u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih); @@ -197,10 +197,10 @@ extern void wlc_phy_cal_init(struct brcms_phy_pub *ppi); extern void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init); extern void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, - chanspec_t chanspec); -extern chanspec_t wlc_phy_chanspec_get(struct brcms_phy_pub *ppi); + u16 chanspec); +extern u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi); extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, - chanspec_t newch); + u16 newch); extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi); extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw); @@ -220,8 +220,8 @@ extern void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi); extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi, bool wide_filter); extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, - chanvec_t *channels); -extern chanspec_t wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, + struct brcms_chanvec *channels); +extern u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band); extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, @@ -232,7 +232,7 @@ extern void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, uint band, s32 *, s32 *, u32 *); extern void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *, - chanspec_t chanspec); + u16 chanspec); extern int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override); extern int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, @@ -254,7 +254,7 @@ extern void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain); extern u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih); extern s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, - chanspec_t chanspec); + u16 chanspec); extern void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val); extern void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason); @@ -264,8 +264,8 @@ extern void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi); extern void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val); extern void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi); -extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, mbool id, bool val); -extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, mbool flags); +extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val); +extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags); extern void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 7dae8026348..6d468e7b07e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -570,7 +570,7 @@ struct brcms_phy_pub { struct phy_func_ptr { void (*init) (struct brcms_phy *); void (*calinit) (struct brcms_phy *); - void (*chanset) (struct brcms_phy *, chanspec_t); + void (*chanset) (struct brcms_phy *, u16 chanspec); void (*txpwrrecalc) (struct brcms_phy *); int (*longtrn) (struct brcms_phy *, int); void (*txiqccget) (struct brcms_phy *, u16 *, u16 *); @@ -602,7 +602,7 @@ struct brcms_phy { bool phytest_on; bool ofdm_rateset_war; bool bf_preempt_4306; - chanspec_t radio_chanspec; + u16 radio_chanspec; u8 antsel_type; u16 bw; u8 txpwr_percent; @@ -618,7 +618,7 @@ struct brcms_phy { int phynoise_chan_watchdog; bool phynoise_polling; bool disable_percal; - mbool measure_hold; + u32 measure_hold; s16 txpa_2g[PWRTBL_NUM_COEFF]; s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF]; @@ -829,11 +829,11 @@ struct brcms_phy { u8 mphase_txcal_cmdidx; u8 mphase_txcal_numcmds; u16 mphase_txcal_bestcoeffs[11]; - chanspec_t nphy_txiqlocal_chanspec; - chanspec_t nphy_iqcal_chanspec_2G; - chanspec_t nphy_iqcal_chanspec_5G; - chanspec_t nphy_rssical_chanspec_2G; - chanspec_t nphy_rssical_chanspec_5G; + u16 nphy_txiqlocal_chanspec; + u16 nphy_iqcal_chanspec_2G; + u16 nphy_iqcal_chanspec_5G; + u16 nphy_rssical_chanspec_2G; + u16 nphy_rssical_chanspec_5G; struct wlapi_timer *phycal_timer; bool use_int_tx_iqlo_cal_nphy; bool internal_tx_iqlo_cal_tapoff_intpa_nphy; @@ -926,9 +926,9 @@ struct brcms_phy { struct wiphy *wiphy; }; -struct _cs32 { - fixed q; - fixed i; +struct cs32 { + s32 q; + s32 i; }; struct radio_regs { @@ -1011,7 +1011,7 @@ extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val); extern void write_phy_channel_reg(struct brcms_phy *pi, uint val); extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi); -extern void wlc_phy_cordic(fixed theta, cs32 *val); +extern void wlc_phy_cordic(s32 theta, struct cs32 *val); extern u8 wlc_phy_nbits(s32 value); extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core); @@ -1042,14 +1042,14 @@ extern void wlc_phy_cal_init_nphy(struct brcms_phy *pi); extern void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi); extern void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, - chanspec_t chanspec); + u16 chanspec); extern void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, - chanspec_t chanspec); + u16 chanspec); extern void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, - chanspec_t chanspec); + u16 chanspec); extern int wlc_phy_channel2freq(uint channel); extern int wlc_phy_chanspec_freq2bandrange_lpssn(uint); -extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, chanspec_t); +extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec); extern void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode); extern s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi); @@ -1218,7 +1218,7 @@ extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs); void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset); extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, - chanspec_t chanspec); + u16 chanspec); extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih); #endif /* _BRCM_PHY_INT_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 6a3fbe67302..c232f501610 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -1008,7 +1008,7 @@ static void wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi); static void wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, - chanspec_t chanspec); + u16 chanspec); static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi); static void wlc_lcnphy_temp_adj(struct brcms_phy *pi); static void wlc_lcnphy_clear_papd_comptable(struct brcms_phy *pi); @@ -1200,7 +1200,7 @@ wlc_lcnphy_txrx_spur_avoidance_mode(struct brcms_phy *pi, bool enable) wlapi_switch_macfreq(pi->sh->physhim, enable); } -void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, chanspec_t chanspec) +void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) { u8 channel = CHSPEC_CHANNEL(chanspec); @@ -2714,8 +2714,8 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, u8 phy_bw; u16 num_samps, t, k; u32 bw; - fixed theta = 0, rot = 0; - cs32 tone_samp; + s32 theta = 0, rot = 0; + struct cs32 tone_samp; u32 data_buf[64]; u16 i_samp, q_samp; struct phytbl_info tab; @@ -3592,7 +3592,7 @@ void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi) } static void -wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, chanspec_t chanspec) +wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) { u8 channel = CHSPEC_CHANNEL(chanspec); struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; @@ -4841,7 +4841,7 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) const struct chan_info_2064_lcnphy *ci; u8 rfpll_doubler = 0; u8 pll_pwrup, pll_pwrup_ovr; - fixed qFxtal, qFref, qFvco, qFcal; + s32 qFxtal, qFref, qFvco, qFcal; u8 d15, d16, f16, e44, e45; u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; u16 loop_bw, d30, setCount; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index f8e41923942..b4ac0d1b15c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14090,7 +14090,7 @@ static bool wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, struct chan_info_nphy_radio205x **t1, struct chan_info_nphy_radio2057_rev5 **t2, struct chan_info_nphy_2055 **t3); -static void wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, chanspec_t chans, +static void wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chans, const struct nphy_sfo_cfg *c); static void wlc_phy_adjust_rx_analpfbw_nphy(struct brcms_phy *pi, @@ -14188,8 +14188,8 @@ static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi); static u16 wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 dac_test_mode); -static void wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, cs32 *tone_buf, - u16 num_samps); +static void wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, + struct cs32 *tone_buf, u16 num_samps); static void wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 n, u16 lps, u16 wait, u8 iq, u8 dac_test_mode, bool modify_bbmult); @@ -18912,7 +18912,7 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) } static void -wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, chanspec_t chanspec, +wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, const struct nphy_sfo_cfg *ci) { u16 val; @@ -19047,7 +19047,7 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, chanspec_t chanspec, wlc_phy_spurwar_nphy(pi); } -void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, chanspec_t chanspec) +void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) { int freq; struct chan_info_nphy_radio2057 *t0 = NULL; @@ -22241,9 +22241,9 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, { u8 phy_bw, is_phybw40; u16 num_samps, t, spur; - fixed theta = 0, rot = 0; + s32 theta = 0, rot = 0; u32 tbl_len; - cs32 *tone_buf = NULL; + struct cs32 *tone_buf = NULL; is_phybw40 = CHSPEC_IS40(pi->radio_chanspec); phy_bw = (is_phybw40 == 1) ? 40 : 20; @@ -22258,7 +22258,7 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, tbl_len = (phy_bw << 1); } - tone_buf = kmalloc(sizeof(cs32) * tbl_len, GFP_ATOMIC); + tone_buf = kmalloc(sizeof(struct cs32) * tbl_len, GFP_ATOMIC); if (tone_buf == NULL) { return 0; } @@ -22305,7 +22305,7 @@ wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, } static void -wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, cs32 *tone_buf, +wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cs32 *tone_buf, u16 num_samps) { u16 t; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 8ec398a3eb4..a5d91df396a 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -171,7 +171,7 @@ struct brcms_bss_info { s16 SNR; /* receive signal SNR in dB */ u16 beacon_period; /* units are Kusec */ u16 atim_window; /* units are Kusec */ - chanspec_t chanspec; /* Channel num, bw, ctrl_sb and band */ + u16 chanspec; /* Channel num, bw, ctrl_sb and band */ s8 infra; /* 0=IBSS, 1=infrastructure, 2=unknown */ wlc_rateset_t rateset; /* supported rates */ u8 dtim_period; /* DTIM period */ @@ -265,7 +265,7 @@ struct brcms_pub { int bcmerror; /* last bcm error */ - mbool radio_disabled; /* bit vector for radio disabled reasons */ + u32 radio_disabled; /* bit vector for radio disabled reasons */ bool radio_active; /* radio on/off state */ u16 roam_time_thresh; /* Max. # secs. of not hearing beacons * before roaming. diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index f0e4b99c256..dac285e4c94 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -328,10 +328,10 @@ brcms_c_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs, } /* calculate the rate of a rx'd frame and return it as a ratespec */ -ratespec_t brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) +u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) { int phy_type; - ratespec_t rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT; + u32 rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT; phy_type = ((rxh->RxChan & RXS_CHAN_PHYTYPE_MASK) >> RXS_CHAN_PHYTYPE_SHIFT); diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index dbfd3e5816d..9903bb5ac9f 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -111,7 +111,7 @@ extern const struct brcms_mcs_info mcs_table[]; #define PLCP3_STC_MASK 0x30 #define PLCP3_STC_SHIFT 4 -/* Rate info table; takes a legacy rate or ratespec_t */ +/* Rate info table; takes a legacy rate or u32 */ #define IS_MCS(r) (r & RSPEC_MIMORATE) #define IS_OFDM(r) (!IS_MCS(r) && (rate_info[(r) & RSPEC_RATE_MASK] & \ BRCMS_RATE_FLAG)) @@ -150,7 +150,7 @@ extern void brcms_c_rateset_copy(const struct brcms_rateset *src, struct brcms_rateset *dst); /* would be nice to have these documented ... */ -extern ratespec_t brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp); +extern u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp); extern void brcms_c_rateset_filter(struct brcms_rateset *src, struct brcms_rateset *dst, bool basic_only, u8 rates, uint xmask, diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 84fca47438c..f6a4b66d1e4 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -37,7 +37,7 @@ static void brcms_c_stf_stbc_rx_ht_update(struct brcms_c_info *wlc, int val); static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - ratespec_t rspec); + u32 rspec); #define NSTS_1 1 #define NSTS_2 2 @@ -94,7 +94,7 @@ void brcms_c_tempsense_upd(struct brcms_c_info *wlc) void brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, - chanspec_t chanspec) + u16 chanspec) { struct tx_power power; u8 siso_mcs_id, cdd_mcs_id, stbc_mcs_id; @@ -444,7 +444,7 @@ void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) } static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - ratespec_t rspec) + u32 rspec) { u16 phytxant = wlc->stf->phytxant; @@ -456,12 +456,12 @@ static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, return phytxant; } -u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, ratespec_t rspec) +u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, u32 rspec) { return _brcms_c_stf_phytxchain_sel(wlc, rspec); } -u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, ratespec_t rspec) +u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, u32 rspec) { u16 phytxant = wlc->stf->phytxant; u16 mask = PHY_TXC_ANT_MASK; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.h b/drivers/staging/brcm80211/brcmsmac/stf.h index 06c2a399649..19f6580f69b 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.h +++ b/drivers/staging/brcm80211/brcmsmac/stf.h @@ -25,7 +25,7 @@ extern void brcms_c_stf_detach(struct brcms_c_info *wlc); extern void brcms_c_tempsense_upd(struct brcms_c_info *wlc); extern void brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, - chanspec_t chanspec); + u16 chanspec); extern int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band); extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); @@ -35,8 +35,8 @@ extern bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val); extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); extern void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc); extern u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - ratespec_t rspec); + u32 rspec); extern u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, - ratespec_t rspec); + u32 rspec); #endif /* _BRCM_STF_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 823b5e4672e..23ce168cd22 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -351,7 +351,6 @@ do { \ W_REG((r), ((R_REG(r) & ~(mask)) | (val))) /* multi-bool data type: set of bools, mbool is true if any is set */ -typedef u32 mbool; #define mboolset(mb, bit) ((mb) |= (bit)) /* set one bool */ #define mboolclr(mb, bit) ((mb) &= ~(bit)) /* clear one bool */ #define mboolisset(mb, bit) (((mb) & (bit)) != 0) /* true if one bool is set */ @@ -387,10 +386,6 @@ typedef volatile struct d11regs d11regs_t; typedef volatile struct dma32diag dma32diag_t; typedef volatile struct dma64regs dma64regs_t; typedef struct brcms_rateset wlc_rateset_t; -typedef u32 ratespec_t; -typedef struct chanvec chanvec_t; -typedef s32 fixed; -typedef struct _cs32 cs32; typedef volatile union pmqreg pmqreg_t; /* brcm_msg_level is a bit vector with defs in defs.h */ diff --git a/drivers/staging/brcm80211/brcmutil/wifi.c b/drivers/staging/brcm80211/brcmutil/wifi.c index b9ffe8682a2..e8f7f56add8 100644 --- a/drivers/staging/brcm80211/brcmutil/wifi.c +++ b/drivers/staging/brcm80211/brcmutil/wifi.c @@ -21,7 +21,7 @@ * combination could be legal given any set of circumstances. * RETURNS: true is the chanspec is malformed, false if it looks good. */ -bool brcmu_chspec_malformed(chanspec_t chanspec) +bool brcmu_chspec_malformed(u16 chanspec) { /* must be 2G or 5G band */ if (!CHSPEC_IS5G(chanspec) && !CHSPEC_IS2G(chanspec)) @@ -48,7 +48,7 @@ EXPORT_SYMBOL(brcmu_chspec_malformed); * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ * sideband depending on the chanspec selected */ -u8 brcmu_chspec_ctlchan(chanspec_t chspec) +u8 brcmu_chspec_ctlchan(u16 chspec) { u8 ctl_chan; diff --git a/drivers/staging/brcm80211/include/brcmu_wifi.h b/drivers/staging/brcm80211/include/brcmu_wifi.h index fde592bd917..949349f0bbd 100644 --- a/drivers/staging/brcm80211/include/brcmu_wifi.h +++ b/drivers/staging/brcm80211/include/brcmu_wifi.h @@ -20,8 +20,10 @@ #include /* for ETH_ALEN */ #include /* for WLAN_PMKID_LEN */ -/* A chanspec holds the channel number, band, bandwidth and control sideband */ -typedef u16 chanspec_t; +/* + * A chanspec (u16) holds the channel number, band, bandwidth and control + * sideband + */ /* channel defines */ #define CH_UPPER_SB 0x01 @@ -69,12 +71,12 @@ typedef u16 chanspec_t; ((channel) + CH_10MHZ_APART) : 0) #define CHSPEC_BANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : \ BAND_2G_INDEX) -#define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \ +#define CH20MHZ_CHSPEC(channel) (u16)((u16)(channel) | WL_CHANSPEC_BW_20 | \ WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \ WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ ((channel) + CH_20MHZ_APART) : 0) -#define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \ +#define CH40MHZ_CHSPEC(channel, ctlsb) (u16) \ ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \ WL_CHANSPEC_BAND_5G)) @@ -142,14 +144,14 @@ typedef u16 chanspec_t; * combination could be legal given any set of circumstances. * RETURNS: true is the chanspec is malformed, false if it looks good. */ -extern bool brcmu_chspec_malformed(chanspec_t chanspec); +extern bool brcmu_chspec_malformed(u16 chanspec); /* * This function returns the channel number that control traffic is being sent on, for legacy * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ * sideband depending on the chanspec selected */ -extern u8 brcmu_chspec_ctlchan(chanspec_t chspec); +extern u8 brcmu_chspec_ctlchan(u16 chspec); /* * Return the channel number for a given frequency and base frequency. @@ -218,26 +220,24 @@ extern int brcmu_mhz2channel(uint freq, uint start_factor); #define HT_CAP_RX_STBC_NO 0x0 #define HT_CAP_RX_STBC_ONE_STREAM 0x1 -typedef struct _pmkid { +struct pmkid { u8 BSSID[ETH_ALEN]; u8 PMKID[WLAN_PMKID_LEN]; -} pmkid_t; +}; -typedef struct _pmkid_list { +struct pmkid_list { u32 npmkid; - pmkid_t pmkid[1]; -} pmkid_list_t; + struct pmkid pmkid[1]; +}; -typedef struct _pmkid_cand { +struct pmkid_cand { u8 BSSID[ETH_ALEN]; u8 preauth; -} pmkid_cand_t; +}; -typedef struct _pmkid_cand_list { +struct pmkid_cand_list { u32 npmkid_cand; - pmkid_cand_t pmkid_cand[1]; -} pmkid_cand_list_t; - -typedef u8 ac_bitmap_t; + struct pmkid_cand pmkid_cand[1]; +}; #endif /* _BRCMU_WIFI_H_ */ From fa67ebba7ed550685b5ed12d6f22100081e54ca6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:57:59 +0200 Subject: [PATCH 0037/1519] staging: brcm80211: replaced typedef wlc_rateset_t By struct brcms_c_rateset. Struct brcms_c_rateset was renamed from brcms_rateset, because there will be two rateset related structures that should differ significantly in naming from each other. Struct wl_rateset will be renamed to struct brcm_rateset in the next patch. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 55 ++++++++++++---------- drivers/staging/brcm80211/brcmsmac/main.h | 14 +++--- drivers/staging/brcm80211/brcmsmac/pub.h | 9 ++-- drivers/staging/brcm80211/brcmsmac/rate.c | 50 ++++++++++---------- drivers/staging/brcm80211/brcmsmac/rate.h | 41 ++++++++-------- drivers/staging/brcm80211/brcmsmac/types.h | 1 - 6 files changed, 89 insertions(+), 81 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 252cd3b1407..038115b8ae6 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -381,7 +381,8 @@ static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc); static void brcms_c_watchdog(void *arg); static void brcms_c_watchdog_by_timer(void *arg); static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate); -static int brcms_c_set_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs_arg); +static int brcms_c_set_rateset(struct brcms_c_info *wlc, + struct brcms_c_rateset *rs_arg); static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc); /* send and receive */ @@ -3720,7 +3721,7 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) } u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, - wlc_rateset_t *rs) + struct brcms_c_rateset *rs) { u32 lowest_basic_rspec; uint i; @@ -3876,7 +3877,7 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, u16 chanspec) { - wlc_rateset_t default_rateset; + struct brcms_c_rateset default_rateset; uint parkband; uint i, band_order[2]; @@ -5711,7 +5712,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) { int ret = 0; uint i; - wlc_rateset_t rs; + struct brcms_c_rateset rs; /* Default to 54g Auto */ /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ s8 shortslot = BRCMS_SHORTSLOT_AUTO; @@ -5750,10 +5751,10 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); /* Clear supported rates filter */ - memset(&wlc->sup_rates_override, 0, sizeof(wlc_rateset_t)); + memset(&wlc->sup_rates_override, 0, sizeof(struct brcms_c_rateset)); /* Clear rateset override */ - memset(&rs, 0, sizeof(wlc_rateset_t)); + memset(&rs, 0, sizeof(struct brcms_c_rateset)); switch (gmode) { case GMODE_LEGACY_B: @@ -5938,12 +5939,13 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) return err; } -static int brcms_c_set_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs_arg) +static int +brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs_arg) { - wlc_rateset_t rs, new; + struct brcms_c_rateset rs, new; uint bandunit; - memcpy(&rs, rs_arg, sizeof(wlc_rateset_t)); + memcpy(&rs, rs_arg, sizeof(struct brcms_c_rateset)); /* check for bad count value */ if ((rs.count == 0) || (rs.count > BRCMS_NUMRATES)) @@ -5951,7 +5953,7 @@ static int brcms_c_set_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs_arg) /* try the current band */ bandunit = wlc->band->bandunit; - memcpy(&new, &rs, sizeof(wlc_rateset_t)); + memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); if (brcms_c_rate_hwrs_filter_sort_validate (&new, &wlc->bandstate[bandunit]->hw_rateset, true, wlc->stf->txstreams)) @@ -5960,7 +5962,7 @@ static int brcms_c_set_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs_arg) /* try the other band */ if (IS_MBAND_UNLOCKED(wlc)) { bandunit = OTHERBANDUNIT(wlc); - memcpy(&new, &rs, sizeof(wlc_rateset_t)); + memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); if (brcms_c_rate_hwrs_filter_sort_validate(&new, &wlc-> bandstate[bandunit]-> @@ -5973,9 +5975,10 @@ static int brcms_c_set_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs_arg) good: /* apply new rateset */ - memcpy(&wlc->default_bss->rateset, &new, sizeof(wlc_rateset_t)); + memcpy(&wlc->default_bss->rateset, &new, + sizeof(struct brcms_c_rateset)); memcpy(&wlc->bandstate[bandunit]->defrateset, &new, - sizeof(wlc_rateset_t)); + sizeof(struct brcms_c_rateset)); return 0; } @@ -6132,7 +6135,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, case BRCM_GET_CURR_RATESET:{ wl_rateset_t *ret_rs = (wl_rateset_t *) arg; - wlc_rateset_t *rs; + struct brcms_c_rateset *rs; if (wlc->pub->associated) rs = ¤t_bss->rateset; @@ -6151,7 +6154,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, } case BRCM_SET_RATESET:{ - wlc_rateset_t rs; + struct brcms_c_rateset rs; wl_rateset_t *in_rs = (wl_rateset_t *) arg; if (len < (int)(in_rs->count + sizeof(in_rs->count))) { @@ -6164,7 +6167,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, break; } - memset(&rs, 0, sizeof(wlc_rateset_t)); + memset(&rs, 0, sizeof(struct brcms_c_rateset)); /* Copy only legacy rateset section */ rs.count = in_rs->count; @@ -8486,7 +8489,8 @@ brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, } /* derive wlc->band->basic_rate[] table from 'rateset' */ -void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, wlc_rateset_t *rateset) +void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, + struct brcms_c_rateset *rateset) { u8 rate; u8 mandatory; @@ -8610,9 +8614,10 @@ static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, brcms_c_write_shm(wlc, (basic_table + index * 2), basic_ptr); } -static const wlc_rateset_t *brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) +static const struct brcms_c_rateset * +brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) { - const wlc_rateset_t *rs_dflt; + const struct brcms_c_rateset *rs_dflt; if (BRCMS_PHY_11N_CAP(wlc->band)) { if (BAND_5G(wlc->band->bandtype)) @@ -8629,8 +8634,8 @@ static const wlc_rateset_t *brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) void brcms_c_set_ratetable(struct brcms_c_info *wlc) { - const wlc_rateset_t *rs_dflt; - wlc_rateset_t rs; + const struct brcms_c_rateset *rs_dflt; + struct brcms_c_rateset rs; u8 rate, basic_rate; uint i; @@ -8665,7 +8670,7 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc) bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, bool verbose) { - wlc_rateset_t *hw_rateset; + struct brcms_c_rateset *hw_rateset; uint i; if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) { @@ -8723,8 +8728,8 @@ static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) { - const wlc_rateset_t *rs_dflt; - wlc_rateset_t rs; + const struct brcms_c_rateset *rs_dflt; + struct brcms_c_rateset rs; u8 rate; u16 entry_ptr; u8 plcp[D11_PHY_HDR_LEN]; @@ -9037,7 +9042,7 @@ void brcms_c_bsscfg_reprate_init(struct brcms_bss_cfg *bsscfg) memset((char *)bsscfg->txrspec, 0, sizeof(bsscfg->txrspec)); } -void brcms_default_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs) +void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) { brcms_c_rateset_default(rs, NULL, wlc->band->phytype, wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 1feefcf7345..8cbb2d67222 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -392,13 +392,15 @@ struct brcms_band { struct scb *hwrs_scb; /* permanent scb for hw rateset */ - wlc_rateset_t defrateset; /* band-specific copy of default_bss.rateset */ + /* band-specific copy of default_bss.rateset */ + struct brcms_c_rateset defrateset; u32 rspec_override; /* 802.11 rate override */ u32 mrspec_override; /* multicast rate override */ u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */ s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */ - wlc_rateset_t hw_rateset; /* rates supported by chip (phy-specific) */ + /* rates supported by chip (phy-specific) */ + struct brcms_c_rateset hw_rateset; u8 basic_rate[BRCM_MAXRATE + 1]; /* basic rates indexed by rate */ bool mimo_cap_40; /* 40 MHz cap enabled on this band */ s8 antgain; /* antenna gain from srom */ @@ -751,10 +753,8 @@ struct brcms_c_info { u16 prb_resp_timeout; /* do not send prb resp if request older than this, * 0 = disable */ - - wlc_rateset_t sup_rates_override; /* use only these rates in 11g supported rates if - * specifed - */ + /* use only these rates in 11g supported rates if specified */ + struct brcms_c_rateset sup_rates_override; u16 home_chanspec; /* shared home chanspec */ @@ -1040,7 +1040,7 @@ extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, extern void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len); extern u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, - wlc_rateset_t *rs); + struct brcms_c_rateset *rs); extern void brcms_c_radio_disable(struct brcms_c_info *wlc); extern void brcms_c_bcn_li_upd(struct brcms_c_info *wlc); extern void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index a5d91df396a..9b847b34efa 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -125,7 +125,7 @@ struct brcms_tunables { int memreserved; /* memory reserved for BMAC's USB dma rx */ }; -struct brcms_rateset { +struct brcms_c_rateset { uint count; /* number of rates in rates[] */ /* rates in 500kbps units w/hi bit set if basic */ u8 rates[BRCMS_NUMRATES]; @@ -173,7 +173,7 @@ struct brcms_bss_info { u16 atim_window; /* units are Kusec */ u16 chanspec; /* Channel num, bw, ctrl_sb and band */ s8 infra; /* 0=IBSS, 1=infrastructure, 2=unknown */ - wlc_rateset_t rateset; /* supported rates */ + struct brcms_c_rateset rateset; /* supported rates */ u8 dtim_period; /* DTIM period */ s8 phy_noise; /* noise right after tx (in dBm) */ u16 capability; /* Capability information */ @@ -592,8 +592,9 @@ extern struct brcms_pub *brcms_c_pub(void *wlc); extern void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, int bands); extern void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, - wlc_rateset_t *rateset); -extern void brcms_default_rateset(struct brcms_c_info *wlc, wlc_rateset_t *rs); + struct brcms_c_rateset *rateset); +extern void brcms_default_rateset(struct brcms_c_info *wlc, + struct brcms_c_rateset *rs); extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta, u16 tid); diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index dac285e4c94..86d47c88658 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -179,7 +179,7 @@ legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = { /* Hardware rates (also encodes default basic rates) */ -const wlc_rateset_t cck_ofdm_mimo_rates = { +const struct brcms_c_rateset cck_ofdm_mimo_rates = { 12, { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, @@ -189,7 +189,7 @@ const wlc_rateset_t cck_ofdm_mimo_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t ofdm_mimo_rates = { +const struct brcms_c_rateset ofdm_mimo_rates = { 8, { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, @@ -199,7 +199,7 @@ const wlc_rateset_t ofdm_mimo_rates = { }; /* Default ratesets that include MCS32 for 40BW channels */ -const wlc_rateset_t cck_ofdm_40bw_mimo_rates = { +const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { 12, { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, @@ -209,7 +209,7 @@ const wlc_rateset_t cck_ofdm_40bw_mimo_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t ofdm_40bw_mimo_rates = { +const struct brcms_c_rateset ofdm_40bw_mimo_rates = { 8, { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, @@ -218,7 +218,7 @@ const wlc_rateset_t ofdm_40bw_mimo_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t cck_ofdm_rates = { +const struct brcms_c_rateset cck_ofdm_rates = { 12, { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, @@ -228,7 +228,7 @@ const wlc_rateset_t cck_ofdm_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t gphy_legacy_rates = { +const struct brcms_c_rateset gphy_legacy_rates = { 4, { /* 1b, 2b, 5.5b, 11b Mbps */ 0x82, 0x84, 0x8b, 0x96}, @@ -237,7 +237,7 @@ const wlc_rateset_t gphy_legacy_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t ofdm_rates = { +const struct brcms_c_rateset ofdm_rates = { 8, { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, @@ -246,7 +246,7 @@ const wlc_rateset_t ofdm_rates = { 0x00, 0x00, 0x00, 0x00} }; -const wlc_rateset_t cck_rates = { +const struct brcms_c_rateset cck_rates = { 4, { /* 1b, 2b, 5.5, 11 Mbps */ 0x82, 0x84, 0x0b, 0x16}, @@ -258,7 +258,7 @@ const wlc_rateset_t cck_rates = { /* check if rateset is valid. * if check_brate is true, rateset without a basic rate is considered NOT valid. */ -static bool brcms_c_rateset_valid(wlc_rateset_t *rs, bool check_brate) +static bool brcms_c_rateset_valid(struct brcms_c_rateset *rs, bool check_brate) { uint idx; @@ -276,7 +276,7 @@ static bool brcms_c_rateset_valid(wlc_rateset_t *rs, bool check_brate) return false; } -void brcms_c_rateset_mcs_upd(wlc_rateset_t *rs, u8 txstreams) +void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams) { int i; for (i = txstreams; i < MAX_STREAMS_SUPPORTED; i++) @@ -287,8 +287,8 @@ void brcms_c_rateset_mcs_upd(wlc_rateset_t *rs, u8 txstreams) * and check if resulting rateset is valid. */ bool -brcms_c_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs, - const wlc_rateset_t *hw_rs, +brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, + const struct brcms_c_rateset *hw_rs, bool check_brate, u8 txstreams) { u8 rateset[BRCM_MAXRATE + 1]; @@ -377,9 +377,10 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) } /* copy rateset src to dst as-is (no masking or sorting) */ -void brcms_c_rateset_copy(const wlc_rateset_t *src, wlc_rateset_t *dst) +void brcms_c_rateset_copy(const struct brcms_c_rateset *src, + struct brcms_c_rateset *dst) { - memcpy(dst, src, sizeof(wlc_rateset_t)); + memcpy(dst, src, sizeof(struct brcms_c_rateset)); } /* @@ -392,8 +393,8 @@ void brcms_c_rateset_copy(const wlc_rateset_t *src, wlc_rateset_t *dst) * 'xmask' is the copy mask (typically 0x7f or 0xff). */ void -brcms_c_rateset_filter(wlc_rateset_t *src, wlc_rateset_t *dst, bool basic_only, - u8 rates, uint xmask, bool mcsallow) +brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, + bool basic_only, u8 rates, uint xmask, bool mcsallow) { uint i; uint r; @@ -423,12 +424,13 @@ brcms_c_rateset_filter(wlc_rateset_t *src, wlc_rateset_t *dst, bool basic_only, * and fill rs_tgt with result */ void -brcms_c_rateset_default(wlc_rateset_t *rs_tgt, const wlc_rateset_t *rs_hw, - uint phy_type, int bandtype, bool cck_only, uint rate_mask, - bool mcsallow, u8 bw, u8 txstreams) +brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, + const struct brcms_c_rateset *rs_hw, + uint phy_type, int bandtype, bool cck_only, + uint rate_mask, bool mcsallow, u8 bw, u8 txstreams) { - const wlc_rateset_t *rs_dflt; - wlc_rateset_t rs_sel; + const struct brcms_c_rateset *rs_dflt; + struct brcms_c_rateset rs_sel; if ((PHYTYPE_IS(phy_type, PHY_TYPE_HT)) || (PHYTYPE_IS(phy_type, PHY_TYPE_N)) || (PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) || @@ -475,21 +477,21 @@ s16 brcms_c_rate_legacy_phyctl(uint rate) return -1; } -void brcms_c_rateset_mcs_clear(wlc_rateset_t *rateset) +void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset) { uint i; for (i = 0; i < MCSSET_LEN; i++) rateset->mcs[i] = 0; } -void brcms_c_rateset_mcs_build(wlc_rateset_t *rateset, u8 txstreams) +void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams) { memcpy(&rateset->mcs[0], &cck_ofdm_mimo_rates.mcs[0], MCSSET_LEN); brcms_c_rateset_mcs_upd(rateset, txstreams); } /* Based on bandwidth passed, allow/disallow MCS 32 in the rateset */ -void brcms_c_rateset_bw_mcs_filter(wlc_rateset_t *rateset, u8 bw) +void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw) { if (bw == BRCMS_40_MHZ) setbit(rateset->mcs, 32); diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index 9903bb5ac9f..9fb187e549a 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -20,14 +20,14 @@ #include "types.h" extern const u8 rate_info[]; -extern const struct brcms_rateset cck_ofdm_mimo_rates; -extern const struct brcms_rateset ofdm_mimo_rates; -extern const struct brcms_rateset cck_ofdm_rates; -extern const struct brcms_rateset ofdm_rates; -extern const struct brcms_rateset cck_rates; -extern const struct brcms_rateset gphy_legacy_rates; -extern const struct brcms_rateset wlc_lrs_rates; -extern const struct brcms_rateset rate_limit_1_2; +extern const struct brcms_c_rateset cck_ofdm_mimo_rates; +extern const struct brcms_c_rateset ofdm_mimo_rates; +extern const struct brcms_c_rateset cck_ofdm_rates; +extern const struct brcms_c_rateset ofdm_rates; +extern const struct brcms_c_rateset cck_rates; +extern const struct brcms_c_rateset gphy_legacy_rates; +extern const struct brcms_c_rateset wlc_lrs_rates; +extern const struct brcms_c_rateset rate_limit_1_2; struct brcms_mcs_info { u32 phy_rate_20; /* phy rate in kbps [20Mhz] */ @@ -142,32 +142,33 @@ extern const u8 ofdm_rate_lookup[]; /* sanitize, and sort a rateset with the basic bit(s) preserved, validate rateset */ extern bool -brcms_c_rate_hwrs_filter_sort_validate(struct brcms_rateset *rs, - const struct brcms_rateset *hw_rs, +brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, + const struct brcms_c_rateset *hw_rs, bool check_brate, u8 txstreams); /* copy rateset src to dst as-is (no masking or sorting) */ -extern void brcms_c_rateset_copy(const struct brcms_rateset *src, - struct brcms_rateset *dst); +extern void brcms_c_rateset_copy(const struct brcms_c_rateset *src, + struct brcms_c_rateset *dst); /* would be nice to have these documented ... */ extern u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp); -extern void brcms_c_rateset_filter(struct brcms_rateset *src, - struct brcms_rateset *dst, bool basic_only, u8 rates, uint xmask, +extern void brcms_c_rateset_filter(struct brcms_c_rateset *src, + struct brcms_c_rateset *dst, bool basic_only, u8 rates, uint xmask, bool mcsallow); extern void -brcms_c_rateset_default(struct brcms_rateset *rs_tgt, - const struct brcms_rateset *rs_hw, uint phy_type, +brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, + const struct brcms_c_rateset *rs_hw, uint phy_type, int bandtype, bool cck_only, uint rate_mask, bool mcsallow, u8 bw, u8 txstreams); extern s16 brcms_c_rate_legacy_phyctl(uint rate); -extern void brcms_c_rateset_mcs_upd(struct brcms_rateset *rs, u8 txstreams); -extern void brcms_c_rateset_mcs_clear(struct brcms_rateset *rateset); -extern void brcms_c_rateset_mcs_build(struct brcms_rateset *rateset, +extern void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams); +extern void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset); +extern void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams); -extern void brcms_c_rateset_bw_mcs_filter(struct brcms_rateset *rateset, u8 bw); +extern void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, + u8 bw); #endif /* _BRCM_RATE_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 23ce168cd22..c70c9e6b02d 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -385,7 +385,6 @@ typedef volatile struct fifo64 fifo64_t; typedef volatile struct d11regs d11regs_t; typedef volatile struct dma32diag dma32diag_t; typedef volatile struct dma64regs dma64regs_t; -typedef struct brcms_rateset wlc_rateset_t; typedef volatile union pmqreg pmqreg_t; /* brcm_msg_level is a bit vector with defs in defs.h */ From 786d00f7a0d744d55a211dc0c1f701c2c4e3d6bd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:00 +0200 Subject: [PATCH 0038/1519] staging: brcm80211: replaced typedef wl_rateset_t by struct brcm_rateset Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 7 ++++--- drivers/staging/brcm80211/brcmsmac/main.c | 6 ++++-- drivers/staging/brcm80211/include/defs.h | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index a9494e78193..e9ccf06db8d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2025,7 +2025,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, const u8 *addr, const struct cfg80211_bitrate_mask *mask) { - struct wl_rateset rateset; + struct brcm_rateset rateset; s32 rate; s32 val; s32 err_bg; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index d6de44e430d..d2d2d1b042d 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -85,7 +85,8 @@ static int __devinit brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static void brcms_remove(struct pci_dev *pdev); static void brcms_free(struct brcms_info *wl); -static void brcms_set_basic_rate(struct wl_rateset *rs, u16 rate, bool is_br); +static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, + bool is_br); MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); @@ -377,7 +378,7 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_supported_band *bi; u32 br_mask, i; u16 rate; - struct wl_rateset rs; + struct brcm_rateset rs; int error; /* retrieve the current rates */ @@ -1374,7 +1375,7 @@ static void brcms_free(struct brcms_info *wl) } /* flags the given rate in rateset as requested */ -static void brcms_set_basic_rate(struct wl_rateset *rs, u16 rate, bool is_br) +static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br) { u32 i; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 038115b8ae6..c96f43a54a4 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6134,7 +6134,8 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, break; case BRCM_GET_CURR_RATESET:{ - wl_rateset_t *ret_rs = (wl_rateset_t *) arg; + struct brcm_rateset *ret_rs = + (struct brcm_rateset *) arg; struct brcms_c_rateset *rs; if (wlc->pub->associated) @@ -6155,7 +6156,8 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, case BRCM_SET_RATESET:{ struct brcms_c_rateset rs; - wl_rateset_t *in_rs = (wl_rateset_t *) arg; + struct brcm_rateset *in_rs = + (struct brcm_rateset *) arg; if (len < (int)(in_rs->count + sizeof(in_rs->count))) { bcmerror = -EOVERFLOW; diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h index 8b3e17dec15..838424c05e5 100644 --- a/drivers/staging/brcm80211/include/defs.h +++ b/drivers/staging/brcm80211/include/defs.h @@ -54,10 +54,10 @@ #define WL_NUMRATES 16 /* max # of rates in a rateset */ -typedef struct wl_rateset { +struct brcm_rateset { u32 count; /* # rates in this set */ u8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */ -} wl_rateset_t; +}; #define BRCM_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NUL */ From 0da649102e6b2efc772b48ab7d1f70b9486ac6f1 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:01 +0200 Subject: [PATCH 0039/1519] staging: brcm80211: replaced all volatile typedefs Volatile keyword is not needed, hardware is accessed using native Linux calls that provide synchronization. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 3 +- drivers/staging/brcm80211/brcmsmac/aiutils.c | 64 ++++++++-------- drivers/staging/brcm80211/brcmsmac/d11.h | 24 +++--- drivers/staging/brcm80211/brcmsmac/dma.c | 16 ++-- drivers/staging/brcm80211/brcmsmac/main.c | 73 +++++++++---------- drivers/staging/brcm80211/brcmsmac/main.h | 4 +- drivers/staging/brcm80211/brcmsmac/nicpci.c | 10 +-- drivers/staging/brcm80211/brcmsmac/otp.c | 16 ++-- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 33 +++++---- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 10 +-- drivers/staging/brcm80211/brcmsmac/pmu.c | 42 ++++++----- drivers/staging/brcm80211/brcmsmac/types.h | 12 --- .../staging/brcm80211/include/chipcommon.h | 4 +- 14 files changed, 157 insertions(+), 156 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index acad298567f..ddd781e530a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -475,7 +475,8 @@ BRCMF_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep); * Core reg address translation. * Both macro's returns a 32 bits byte address on the backplane bus. */ -#define CORE_CC_REG(base, field) (base + offsetof(chipcregs_t, field)) +#define CORE_CC_REG(base, field) \ + (base + offsetof(struct chipcregs, field)) #define CORE_BUS_REG(base, field) \ (base + offsetof(struct sdpcmd_regs, field)) #define CORE_SB(base, field) \ diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 5a5fc4b7141..58a5cfc239e 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -437,7 +437,7 @@ static void ai_hwfixup(struct si_info *sii) void ai_scan(struct si_pub *sih, void *regs) { struct si_info *sii = SI_INFO(sih); - chipcregs_t *cc = (chipcregs_t *) regs; + struct chipcregs *cc = (struct chipcregs *) regs; u32 erombase, *eromptr, *eromlim; erombase = R_REG(&cc->eromptr); @@ -854,8 +854,9 @@ static struct si_info *ai_doattach(struct si_info *sii, void *regs, uint bustype, void *sdh, char **vars, uint *varsz); static bool ai_buscore_prep(struct si_info *sii, uint bustype); -static bool ai_buscore_setup(struct si_info *sii, chipcregs_t *cc, uint bustype, - u32 savewin, uint *origidx, void *regs); +static bool ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, + uint bustype, u32 savewin, uint *origidx, + void *regs); static void ai_nvram_process(struct si_info *sii, char *pvars); /* dev path concatenation util */ @@ -910,8 +911,9 @@ static bool ai_buscore_prep(struct si_info *sii, uint bustype) return true; } -static bool ai_buscore_setup(struct si_info *sii, chipcregs_t *cc, uint bustype, - u32 savewin, uint *origidx, void *regs) +static bool +ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, uint bustype, + u32 savewin, uint *origidx, void *regs) { bool pci, pcie; uint i; @@ -1074,7 +1076,7 @@ static struct si_info *ai_doattach(struct si_info *sii, { struct si_pub *sih = &sii->pub; u32 w, savewin; - chipcregs_t *cc; + struct chipcregs *cc; char *pvars = NULL; uint socitype; uint origidx; @@ -1106,9 +1108,9 @@ static struct si_info *ai_doattach(struct si_info *sii, savewin = SI_ENUM_BASE; pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, SI_ENUM_BASE); - cc = (chipcregs_t *) regs; + cc = (struct chipcregs *) regs; } else { - cc = (chipcregs_t *) REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE); + cc = (struct chipcregs *) REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE); } sih->bustype = bustype; @@ -1167,7 +1169,7 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_nvram_process(sii, pvars); /* === NVRAM, clock is ready === */ - cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); W_REG(&cc->gpiopullup, 0); W_REG(&cc->gpiopulldown, 0); ai_setcoreidx(sih, origidx); @@ -1190,7 +1192,8 @@ static struct si_info *ai_doattach(struct si_info *sii, w = getintvar(pvars, "leddc"); if (w == 0) w = DEFAULT_GPIOTIMERVAL; - ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, gpiotimerval), ~0, w); + ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), + ~0, w); if (PCIE(sii)) { pcicore_attach(sii->pch, pvars, SI_DOATTACH); @@ -1204,7 +1207,7 @@ static struct si_info *ai_doattach(struct si_info *sii, if (sih->chiprev == 0) { SI_MSG(("Applying 43224A0 WARs\n")); ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol), + offsetof(struct chipcregs, chipcontrol), CCTRL43224_GPIO_TOGGLE, CCTRL43224_GPIO_TOGGLE); si_pmu_chipcontrol(sih, 0, CCTRL_43224A0_12MA_LED_DRIVE, @@ -1556,7 +1559,7 @@ void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits) /* return the slow clock source - LPO, XTAL, or PCI */ static uint ai_slowclk_src(struct si_info *sii) { - chipcregs_t *cc; + struct chipcregs *cc; u32 val; if (sii->pub.ccrev < 6) { @@ -1568,7 +1571,7 @@ static uint ai_slowclk_src(struct si_info *sii) } return SCC_SS_XTAL; } else if (sii->pub.ccrev < 10) { - cc = (chipcregs_t *) ai_setcoreidx(&sii->pub, sii->curidx); + cc = (struct chipcregs *) ai_setcoreidx(&sii->pub, sii->curidx); return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; } else /* Insta-clock */ return SCC_SS_XTAL; @@ -1578,7 +1581,8 @@ static uint ai_slowclk_src(struct si_info *sii) * return the ILP (slowclock) min or max frequency * precondition: we've established the chip has dynamic clk control */ -static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, chipcregs_t *cc) +static uint +ai_slowclk_freq(struct si_info *sii, bool max_freq, struct chipcregs *cc) { u32 slowclk; uint div; @@ -1614,7 +1618,7 @@ static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, chipcregs_t *cc) static void ai_clkctl_setdelay(struct si_info *sii, void *chipcregs) { - chipcregs_t *cc = (chipcregs_t *) chipcregs; + struct chipcregs *cc = (struct chipcregs *) chipcregs; uint slowmaxfreq, pll_delay, slowclk; uint pll_on_delay, fref_sel_delay; @@ -1646,7 +1650,7 @@ void ai_clkctl_init(struct si_pub *sih) { struct si_info *sii; uint origidx = 0; - chipcregs_t *cc; + struct chipcregs *cc; bool fast; if (!CCCTL_ENAB(sih)) @@ -1656,11 +1660,11 @@ void ai_clkctl_init(struct si_pub *sih) fast = SI_FAST(sii); if (!fast) { origidx = sii->curidx; - cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); if (cc == NULL) return; } else { - cc = (chipcregs_t *) CCREGS_FAST(sii); + cc = (struct chipcregs *) CCREGS_FAST(sii); if (cc == NULL) return; } @@ -1684,7 +1688,7 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) { struct si_info *sii; uint origidx = 0; - chipcregs_t *cc; + struct chipcregs *cc; uint slowminfreq; u16 fpdelay; uint intr_val = 0; @@ -1706,11 +1710,11 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) if (!fast) { origidx = sii->curidx; INTR_OFF(sii, intr_val); - cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); if (cc == NULL) goto done; } else { - cc = (chipcregs_t *) CCREGS_FAST(sii); + cc = (struct chipcregs *) CCREGS_FAST(sii); if (cc == NULL) goto done; } @@ -1825,7 +1829,7 @@ bool ai_clkctl_cc(struct si_pub *sih, uint mode) static bool _ai_clkctl_cc(struct si_info *sii, uint mode) { uint origidx = 0; - chipcregs_t *cc; + struct chipcregs *cc; u32 scc; uint intr_val = 0; bool fast = SI_FAST(sii); @@ -1843,9 +1847,9 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) (ai_corerev(&sii->pub) <= 7) && (sii->pub.ccrev >= 10)) goto done; - cc = (chipcregs_t *) ai_setcore(&sii->pub, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(&sii->pub, CC_CORE_ID, 0); } else { - cc = (chipcregs_t *) CCREGS_FAST(sii); + cc = (struct chipcregs *) CCREGS_FAST(sii); if (cc == NULL) goto done; } @@ -2164,21 +2168,21 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) val &= mask; } - regoff = offsetof(chipcregs_t, gpiocontrol); + regoff = offsetof(struct chipcregs, gpiocontrol); return ai_corereg(sih, SI_CC_IDX, regoff, mask, val); } void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) { struct si_info *sii; - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; u32 val; sii = SI_INFO(sih); origidx = ai_coreidx(sih); - cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); val = R_REG(&cc->chipcontrol); @@ -2205,13 +2209,13 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) void ai_epa_4313war(struct si_pub *sih) { struct si_info *sii; - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; sii = SI_INFO(sih); origidx = ai_coreidx(sih); - cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); /* EPA Fix */ W_REG(&cc->gpiocontrol, @@ -2243,7 +2247,7 @@ bool ai_is_sprom_available(struct si_pub *sih) if (sih->ccrev >= 31) { struct si_info *sii; uint origidx; - chipcregs_t *cc; + struct chipcregs *cc; u32 sromctrl; if ((sih->cccaps & CC_CAP_SROM) == 0) diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index e7ff0e6f28e..4dc73407fb3 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -73,8 +73,8 @@ struct pio2regs { /* a pair of pio channels(tx and rx) */ struct pio2regp { - pio2regs_t tx; - pio2regs_t rx; + struct pio2regs tx; + struct pio2regs rx; }; /* 4byte-wide pio register set per channel(xmt or rcv) */ @@ -85,8 +85,8 @@ struct pio4regs { /* a pair of pio channels(tx and rx) */ struct pio4regp { - pio4regs_t tx; - pio4regs_t rx; + struct pio4regs tx; + struct pio4regs rx; }; /* read: 32-bit register that can be read as 32-bit or as 2 16-bit @@ -101,10 +101,10 @@ union pmqreg { }; struct fifo64 { - dma64regs_t dmaxmt; /* dma tx */ - pio4regs_t piotx; /* pio tx */ - dma64regs_t dmarcv; /* dma rx */ - pio4regs_t piorx; /* pio rx */ + struct dma64regs dmaxmt; /* dma tx */ + struct pio4regs piotx; /* pio tx */ + struct dma64regs dmarcv; /* dma rx */ + struct pio4regs piorx; /* pio rx */ }; /* @@ -120,7 +120,7 @@ struct d11regs { u32 usectimer; /* 0x1c *//* for corerev >= 26 */ /* Interrupt Control *//* 0x20 */ - intctrlregs_t intctrlregs[8]; + struct intctrlregs intctrlregs[8]; u32 PAD[40]; /* 0x60 - 0xFC */ @@ -139,7 +139,7 @@ struct d11regs { u32 PAD[2]; /* 0x138 - 0x13C */ /* PMQ registers */ - pmqreg_t pmqreg; /* 0x140 */ + union pmqreg pmqreg; /* 0x140 */ u32 pmqpatl; /* 0x144 */ u32 pmqpath; /* 0x148 */ u32 PAD; /* 0x14C */ @@ -179,10 +179,10 @@ struct d11regs { u32 PAD[5]; /* 0x1ec - 0x1fc */ /* 0x200-0x37F dma/pio registers */ - fifo64_t fifo64regs[6]; + struct fifo64 fifo64regs[6]; /* FIFO diagnostic port access */ - dma32diag_t dmafifo; /* 0x380 - 0x38C */ + struct dma32diag dmafifo; /* 0x380 - 0x38C */ u32 aggfifocnt; /* 0x390 */ u32 aggfifodata; /* 0x394 */ diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 84b5d80f9be..6fabb09b69e 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -240,8 +240,10 @@ struct dma_info { union { struct { - dma64regs_t *txregs_64; /* 64-bit dma tx engine registers */ - dma64regs_t *rxregs_64; /* 64-bit dma rx engine registers */ + /* 64-bit dma tx engine registers */ + struct dma64regs *txregs_64; + /* 64-bit dma rx engine registers */ + struct dma64regs *rxregs_64; /* pointer to dma64 tx descriptor ring */ struct dma64desc *txd_64; /* pointer to dma64 rx descriptor ring */ @@ -385,7 +387,7 @@ static void dma64_txreclaim(struct dma_info *di, enum txd_range range); static bool dma64_txstopped(struct dma_info *di); static bool dma64_rxstopped(struct dma_info *di); static bool dma64_rxenabled(struct dma_info *di); -static bool _dma64_addrext(dma64regs_t *dma64regs); +static bool _dma64_addrext(struct dma64regs *dma64regs); static inline u32 parity32(u32 data); @@ -459,8 +461,8 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); /* init dma reg pointer */ - di->d64txregs = (dma64regs_t *) dmaregstx; - di->d64rxregs = (dma64regs_t *) dmaregsrx; + di->d64txregs = (struct dma64regs *) dmaregstx; + di->d64rxregs = (struct dma64regs *) dmaregsrx; di->dma.di_fn = (const struct di_fcn_s *)&dma64proc; /* Default flags (which can be changed by the driver calling dma_ctrlflags @@ -1683,7 +1685,7 @@ static void *dma64_getnexttxp(struct dma_info *di, enum txd_range range) if (range == DMA_RANGE_ALL) end = di->txout; else { - dma64regs_t *dregs = di->d64txregs; + struct dma64regs *dregs = di->d64txregs; end = (u16) (B2I(((R_REG(&dregs->status0) & D64_XS0_CD_MASK) - @@ -1795,7 +1797,7 @@ static void *dma64_getnextrxp(struct dma_info *di, bool forceall) return rxp; } -static bool _dma64_addrext(dma64regs_t *dma64regs) +static bool _dma64_addrext(struct dma64regs *dma64regs) { u32 w; OR_REG(&dma64regs->control, D64_XC_AE); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index c96f43a54a4..d3c325cff0b 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -516,7 +516,7 @@ static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, bool shortslot) { - d11regs_t *regs; + struct d11regs *regs; regs = wlc_hw->regs; @@ -661,7 +661,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) { bool morepending = false; struct brcms_c_info *wlc = wlc_hw->wlc; - d11regs_t *regs; + struct d11regs *regs; struct tx_status txstatus, *txs; u32 s1, s2; uint n = 0; @@ -719,7 +719,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) { u32 macintstatus; struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; bool fatal = false; struct wiphy *wiphy = wlc->wiphy; @@ -1270,7 +1270,7 @@ void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, const u8 *addr) { - d11regs_t *regs; + struct d11regs *regs; u16 mac_l; u16 mac_m; u16 mac_h; @@ -1295,7 +1295,7 @@ void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, void *buf) { - d11regs_t *regs; + struct d11regs *regs; u32 word; bool be_bit; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -1365,7 +1365,7 @@ static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, int len) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3, bcn); @@ -1379,7 +1379,7 @@ static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, int len) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3, bcn); @@ -1469,16 +1469,16 @@ void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), ~0, 0); + offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); udelay(1); ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); + offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); udelay(1); ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 4); + offsetof(struct chipcregs, chipcontrol_data), 0x4, 4); udelay(1); ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), 0x4, 0); + offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); udelay(1); } @@ -1697,9 +1697,8 @@ bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = - (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); + wlc_hw->regs = (struct d11regs *) + ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); ai_core_reset(wlc_hw->sih, flags, resetbits); brcms_c_mctrl_reset(wlc_hw); } @@ -1732,7 +1731,7 @@ static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) */ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) { - d11regs_t *regs; + struct d11regs *regs; uint i; bool fastclk; u32 resetbits = 0; @@ -1815,7 +1814,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) */ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; u16 fifo_nu; u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; u16 txfifo_def, txfifo_def1; @@ -1875,7 +1874,7 @@ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) { - d11regs_t *regs; + struct d11regs *regs; regs = wlc_hw->regs; if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || @@ -1905,7 +1904,7 @@ void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) static void brcms_c_gpio_init(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs; + struct d11regs *regs; u32 gc, gm; regs = wlc_hw->regs; @@ -1996,7 +1995,7 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw) static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], const uint nbytes) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; uint i; uint count; @@ -2077,7 +2076,7 @@ void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) bool fatal = false; uint unit; uint intstatus, idx; - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; struct wiphy *wiphy = wlc_hw->wlc->wiphy; unit = wlc_hw->unit; @@ -2324,7 +2323,7 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) { struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; u32 macintstatus; /* macintstatus includes a DMA interrupt summary bit */ @@ -2434,7 +2433,7 @@ bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; u32 mc, mi; struct wiphy *wiphy = wlc->wiphy; @@ -2503,7 +2502,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) void brcms_c_enable_mac(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; u32 mc, mi; BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, @@ -2614,7 +2613,7 @@ void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) { - d11regs_t *regs; + struct d11regs *regs; u32 w, val; struct wiphy *wiphy = wlc_hw->wlc->wiphy; @@ -2679,7 +2678,7 @@ static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) { - d11regs_t *regs; + struct d11regs *regs; u32 tmp; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -2818,7 +2817,7 @@ void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; volatile u16 *objdata_hi = objdata_lo + 1; u16 v; @@ -2838,7 +2837,7 @@ static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, u32 sel) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; volatile u16 *objdata_hi = objdata_lo + 1; @@ -3061,7 +3060,7 @@ static void brcms_c_init_scb(struct brcms_c_info *wlc, struct scb *scb) static void brcms_b_coreinit(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - d11regs_t *regs; + struct d11regs *regs; u32 sflags; uint bcnint_us; uint i = 0; @@ -3289,7 +3288,7 @@ brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, void brcms_c_init(struct brcms_c_info *wlc) { - d11regs_t *regs; + struct d11regs *regs; u16 chanspec; int i; struct brcms_bss_cfg *bsscfg; @@ -4261,7 +4260,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, bool piomode, void *regsva, uint bustype, void *btparam) { struct brcms_hardware *wlc_hw; - d11regs_t *regs; + struct d11regs *regs; char *macaddr = NULL; char *vars; uint err = 0; @@ -4340,7 +4339,8 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, wlc_hw->deviceid = device; /* set bar0 window to point at D11 core */ - wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + wlc_hw->regs = (struct d11regs *) ai_setcore(wlc_hw->sih, D11_CORE_ID, + 0); wlc_hw->corerev = ai_corerev(wlc_hw->sih); regs = wlc_hw->regs; @@ -5354,9 +5354,8 @@ void brcms_b_hw_up(struct brcms_hardware *wlc_hw) /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = - (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); + wlc_hw->regs = (struct d11regs *) + ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); } /* Inform phy that a POR reset has occurred so it does a complete phy init */ @@ -8011,7 +8010,7 @@ void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, u32 *tsf_h_ptr) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; /* read the tsf timer low, then high to get an atomic read */ *tsf_l_ptr = R_REG(®s->tsf_timerlow); @@ -8846,7 +8845,7 @@ void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, int len, bool both) { - d11regs_t *regs = wlc_hw->regs; + struct d11regs *regs = wlc_hw->regs; if (both) { brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); @@ -8884,7 +8883,7 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, /* Hardware beaconing for this config */ u16 bcn[BCN_TMPL_LEN / 2]; u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD; - d11regs_t *regs = wlc->regs; + struct d11regs *regs = wlc->regs; /* Check if both templates are in use, if so sched. an interrupt * that will call back into this routine diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 8cbb2d67222..e797bf09cb5 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -543,7 +543,7 @@ struct brcms_hardware { struct si_pub *sih; /* SI handle (cookie for siutils calls) */ char *vars; /* "environment" name=value */ uint vars_size; /* size of vars, free vars on detach */ - d11regs_t *regs; /* pointer to device registers */ + struct d11regs *regs; /* pointer to device registers */ void *physhim; /* phy shim layer handler */ void *phy_sh; /* pointer to shared phy state */ struct brcms_hw_band *band;/* pointer to active per-band state */ @@ -613,7 +613,7 @@ struct brcms_txq_info { struct brcms_c_info { struct brcms_pub *pub; /* pointer to wlc public state */ struct brcms_info *wl; /* pointer to os-specific private state */ - d11regs_t *regs; /* pointer to device registers */ + struct d11regs *regs; /* pointer to device registers */ /* HW related state used primarily by BMAC */ struct brcms_hardware *hw; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 3d71c590fce..6d6e7d3f530 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -542,10 +542,10 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) case SI_PCIDOWN: if (sih->buscorerev == 6) { /* turn on serdes PLL down */ ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), + offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), + offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0); } else if (pi->pcie_pr42767) { pcie_clkreq((void *)pi, 1, 1); @@ -554,10 +554,10 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) case SI_PCIUP: if (sih->buscorerev == 6) { /* turn off serdes PLL down */ ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), + offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), + offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0x40); } else if (PCIE_ASPM(sih)) { /* disable clkreq */ pcie_clkreq((void *)pi, 1, 0); @@ -674,7 +674,7 @@ static void pcie_war_noplldown(struct pcicore_info *pi) u16 *reg16; /* turn off serdes PLL down */ - ai_corereg(pi->sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol), + ai_corereg(pi->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); /* clear srom shadow backdoor */ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index a257ed86b87..d09424db054 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -62,7 +62,7 @@ /* OTP function struct */ struct otp_fn_s { int (*size)(void *oh); - u16 (*read_bit)(void *oh, chipcregs_t *cc, uint off); + u16 (*read_bit)(void *oh, struct chipcregs *cc, uint off); void *(*init)(struct si_pub *sih); int (*read_region)(struct si_pub *sih, int region, u16 *data, uint *wlen); @@ -156,7 +156,7 @@ static int ipxotp_size(void *oh) return (int)oi->wsize * 2; } -static u16 ipxotp_otpr(void *oh, chipcregs_t *cc, uint wn) +static u16 ipxotp_otpr(void *oh, struct chipcregs *cc, uint wn) { struct otpinfo *oi; @@ -165,7 +165,7 @@ static u16 ipxotp_otpr(void *oh, chipcregs_t *cc, uint wn) return R_REG(&cc->sromotp[wn]); } -static u16 ipxotp_read_bit(void *oh, chipcregs_t *cc, uint off) +static u16 ipxotp_read_bit(void *oh, struct chipcregs *cc, uint off) { struct otpinfo *oi = (struct otpinfo *) oh; uint k, row, col; @@ -217,7 +217,7 @@ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) return ret; } -static void _ipxotp_init(struct otpinfo *oi, chipcregs_t *cc) +static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) { uint k; u32 otpp, st; @@ -291,7 +291,7 @@ static void _ipxotp_init(struct otpinfo *oi, chipcregs_t *cc) static void *ipxotp_init(struct si_pub *sih) { uint idx; - chipcregs_t *cc; + struct chipcregs *cc; struct otpinfo *oi; /* Make sure we're running IPX OTP */ @@ -350,7 +350,7 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen) { struct otpinfo *oi = (struct otpinfo *) oh; uint idx; - chipcregs_t *cc; + struct chipcregs *cc; uint base, i, sz; /* Validate region selection */ @@ -438,7 +438,7 @@ static int ipxotp_nvread(void *oh, char *data, uint *len) static struct otp_fn_s ipxotp_fn = { (int (*)(void *)) ipxotp_size, - (u16 (*)(void *, chipcregs_t *, uint)) ipxotp_read_bit, + (u16 (*)(void *, struct chipcregs *, uint)) ipxotp_read_bit, (void *(*)(struct si_pub *)) ipxotp_init, (int (*)(struct si_pub *, int, u16 *, uint *)) ipxotp_read_region, @@ -474,7 +474,7 @@ u16 otp_read_bit(void *oh, uint offset) { struct otpinfo *oi = (struct otpinfo *) oh; uint idx = ai_coreidx(oi->sih); - chipcregs_t *cc = ai_setcoreidx(oi->sih, SI_CC_IDX); + struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX); u16 readBit = (u16) oi->fn->read_bit(oh, cc, offset); ai_setcoreidx(oi->sih, idx); return readBit; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 13a447fea5b..940f76ba778 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -365,7 +365,7 @@ void write_phy_channel_reg(struct brcms_phy *pi, uint val) u16 read_phy_reg(struct brcms_phy *pi, u16 addr) { - d11regs_t *regs; + struct d11regs *regs; regs = pi->regs; @@ -377,7 +377,7 @@ u16 read_phy_reg(struct brcms_phy *pi, u16 addr) void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - d11regs_t *regs; + struct d11regs *regs; regs = pi->regs; @@ -400,7 +400,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - d11regs_t *regs; + struct d11regs *regs; regs = pi->regs; @@ -412,7 +412,7 @@ void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - d11regs_t *regs; + struct d11regs *regs; regs = pi->regs; @@ -424,7 +424,7 @@ void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) { - d11regs_t *regs; + struct d11regs *regs; regs = pi->regs; @@ -543,7 +543,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, return NULL; } pi->wiphy = wiphy; - pi->regs = (d11regs_t *) regs; + pi->regs = (struct d11regs *) regs; pi->sh = sh; pi->phy_init_por = true; pi->phy_wreg_limit = PHY_WREG_LIMIT; @@ -1134,7 +1134,7 @@ wlc_phy_init_radio_regs(struct brcms_phy *pi, struct radio_regs *radioregs, void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) { #define DUMMY_PKT_LEN 20 - d11regs_t *regs = pi->regs; + struct d11regs *regs = pi->regs; int i, count; u8 ofdmpkt[DUMMY_PKT_LEN] = { 0xcc, 0x01, 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, @@ -3134,12 +3134,13 @@ void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) } ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpiocontrol), ~0x0, - 0x0); + offsetof(struct chipcregs, gpiocontrol), + ~0x0, 0x0); ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpioout), 0x40, 0x40); + offsetof(struct chipcregs, gpioout), 0x40, + 0x40); ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpioouten), 0x40, + offsetof(struct chipcregs, gpioouten), 0x40, 0x40); } else { mod_phy_reg(pi, 0x44c, (0x1 << 2), (0) << 2); @@ -3147,12 +3148,14 @@ void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpioout), 0x40, 0x00); + offsetof(struct chipcregs, gpioout), 0x40, + 0x00); ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpioouten), 0x40, 0x0); + offsetof(struct chipcregs, gpioouten), 0x40, + 0x0); ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, gpiocontrol), ~0x0, - 0x40); + offsetof(struct chipcregs, gpiocontrol), + ~0x0, 0x40); } } } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 6d468e7b07e..1276084b4e9 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -593,7 +593,7 @@ struct brcms_phy { } u; bool user_txpwr_at_rfport; - d11regs_t *regs; + struct d11regs *regs; struct brcms_phy *next; char *vars; struct brcms_phy_pub pubpi; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index b4ac0d1b15c..f758812ee5d 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14533,7 +14533,7 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) bool do_nphy_cal = false; uint core; uint origidx, intr_val; - d11regs_t *regs; + struct d11regs *regs; u32 d11_clk_ctl_st; core = 0; @@ -14548,16 +14548,16 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if ((pi->sh->boardflags & BFL_EXTLNA) && (CHSPEC_IS2G(pi->radio_chanspec))) { ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol), 0x40, - 0x40); + offsetof(struct chipcregs, chipcontrol), + 0x40, 0x40); } } if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && CHSPEC_IS40(pi->radio_chanspec)) { - regs = (d11regs_t *) ai_switch_core(pi->sh->sih, D11_CORE_ID, - &origidx, &intr_val); + regs = (struct d11regs *) ai_switch_core(pi->sh->sih, + D11_CORE_ID, &origidx, &intr_val); d11_clk_ctl_st = R_REG(®s->clk_ctl_st); AND_REG(®s->clk_ctl_st, ~(CCS_FORCEHT | CCS_HTAREQ)); diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index e8b2b81d2d0..ec53a086855 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -137,7 +137,8 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) } static void -si_pmu_spuravoid_pllupdate(struct si_pub *sih, chipcregs_t *cc, u8 spuravoid) +si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs *cc, + u8 spuravoid) { u32 tmp = 0; @@ -209,7 +210,7 @@ u32 si_pmu_ilp_clock(struct si_pub *sih) if (ilpcycles_per_sec == 0) { u32 start, end, delta; u32 origidx = ai_coreidx(sih); - chipcregs_t *cc = ai_setcoreidx(sih, SI_CC_IDX); + struct chipcregs *cc = ai_setcoreidx(sih, SI_CC_IDX); start = R_REG(&cc->pmutimer); mdelay(ILP_CALC_DUR); end = R_REG(&cc->pmutimer); @@ -240,7 +241,7 @@ u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) void si_pmu_sprom_enable(struct si_pub *sih, bool enable) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -254,34 +255,37 @@ void si_pmu_sprom_enable(struct si_pub *sih, bool enable) /* Read/write a chipcontrol reg */ u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol_addr), ~0, - reg); + ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol_addr), + ~0, reg); return ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), mask, val); + offsetof(struct chipcregs, chipcontrol_data), mask, + val); } /* Read/write a regcontrol reg */ u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr), ~0, - reg); + ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, regcontrol_addr), + ~0, reg); return ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, regcontrol_data), mask, val); + offsetof(struct chipcregs, regcontrol_data), mask, + val); } /* Read/write a pllcontrol reg */ u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pllcontrol_addr), ~0, - reg); + ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pllcontrol_addr), + ~0, reg); return ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, pllcontrol_data), mask, val); + offsetof(struct chipcregs, pllcontrol_data), mask, + val); } /* PMU PLL update */ void si_pmu_pllupd(struct si_pub *sih) { - ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmucontrol), + ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pmucontrol), PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD); } @@ -310,11 +314,11 @@ u32 si_pmu_alp_clock(struct si_pub *sih) void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx, intr_val; /* Remember original core before switch to chipc */ - cc = (chipcregs_t *) ai_switch_core(sih, CC_CORE_ID, &origidx, + cc = (struct chipcregs *) ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); /* update the pll changes */ @@ -327,7 +331,7 @@ void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) /* initialize PMU */ void si_pmu_init(struct si_pub *sih) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -366,7 +370,7 @@ void si_pmu_swreg_init(struct si_pub *sih) /* initialize PLL */ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -390,7 +394,7 @@ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) /* initialize PMU resources */ void si_pmu_res_init(struct si_pub *sih) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; u32 min_mask = 0, max_mask = 0; @@ -422,7 +426,7 @@ void si_pmu_res_init(struct si_pub *sih) u32 si_pmu_measure_alpclk(struct si_pub *sih) { - chipcregs_t *cc; + struct chipcregs *cc; uint origidx; u32 alp_khz; diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index c70c9e6b02d..e0880a01fab 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -374,18 +374,6 @@ struct tx_status; struct d11rxhdr; struct brcms_d11rxhdr; struct txpwr_limits; -struct brcms_phy; - -typedef volatile struct intctrlregs intctrlregs_t; -typedef volatile struct pio2regs pio2regs_t; -typedef volatile struct pio2regp pio2regp_t; -typedef volatile struct pio4regs pio4regs_t; -typedef volatile struct pio4regp pio4regp_t; -typedef volatile struct fifo64 fifo64_t; -typedef volatile struct d11regs d11regs_t; -typedef volatile struct dma32diag dma32diag_t; -typedef volatile struct dma64regs dma64regs_t; -typedef volatile union pmqreg pmqreg_t; /* brcm_msg_level is a bit vector with defs in defs.h */ extern u32 brcm_msg_level; diff --git a/drivers/staging/brcm80211/include/chipcommon.h b/drivers/staging/brcm80211/include/chipcommon.h index 296582aced6..8de5913031d 100644 --- a/drivers/staging/brcm80211/include/chipcommon.h +++ b/drivers/staging/brcm80211/include/chipcommon.h @@ -19,7 +19,7 @@ #include "defs.h" /* for PAD macro */ -typedef volatile struct { +struct chipcregs { u32 chipid; /* 0x0 */ u32 capabilities; u32 corecontrol; /* corerev >= 1 */ @@ -214,7 +214,7 @@ typedef volatile struct { u32 pmu_xtalfreq; /* 0x66C, pmurev >= 10 */ u32 PAD[100]; u16 sromotp[768]; -} chipcregs_t; +}; /* chipid */ #define CID_ID_MASK 0x0000ffff /* Chip Id mask */ From 49552d332bf72d08701ee92b99f2408017910efb Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:02 +0200 Subject: [PATCH 0040/1519] staging: brcm80211: modify the FOREACH_BSS macro The FOREACH_BSS macro was changed to remove a checkpatch error. However, the patch was considered ugly. This patch is another attempt to make it more clear. END_FOREACH_BSS is defined with braces to avoid an invalid checkpatch.pl warning. Ideally, the checkpatch.pl script should be adapted but lacking good perl knowledge to do so. Reported-by: Dan Carpenter Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 47 +++++++++++++---------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d3c325cff0b..d5f570a3762 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -250,10 +250,14 @@ #define BSSCFG_STA(cfg) (1) #define BSSCFG_IBSS(cfg) (!(cfg)->BSS) -/* As above for all non-NULL BSS configs */ +/* iterate through all valid bsscfg entries */ #define FOREACH_BSS(wlc, idx, cfg) \ - for (idx = 0; (int) idx < BRCMS_MAXBSSCFG; idx++) \ - if ((cfg = (wlc)->bsscfg[idx])) + for (idx = 0; (int) idx < BRCMS_MAXBSSCFG; idx++) { \ + cfg = (wlc)->bsscfg[idx]; \ + if (!cfg) \ + continue; +/* close marker for iterator code block */ +#define END_FOREACH_BSS() } /* Shared memory location index for various AC params */ #define wme_shmemacindex(ac) wme_ac2fifo[ac] @@ -3315,14 +3319,14 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_reprate_init(wlc); /* write ethernet address to core */ - FOREACH_BSS(wlc, i, bsscfg) { + FOREACH_BSS(wlc, i, bsscfg) brcms_c_set_mac(bsscfg); brcms_c_set_bssid(bsscfg); - } + END_FOREACH_BSS() /* Update tsf_cfprep if associated and up */ if (wlc->pub->associated) { - FOREACH_BSS(wlc, i, bsscfg) { + FOREACH_BSS(wlc, i, bsscfg) if (bsscfg->up) { u32 bi; @@ -3340,7 +3344,7 @@ void brcms_c_init(struct brcms_c_info *wlc) break; } - } + END_FOREACH_BSS() } brcms_c_bandinit_ordered(wlc, chanspec); @@ -3540,7 +3544,7 @@ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) wlc->shortslot = shortslot; /* update the capability based on current shortslot mode */ - FOREACH_BSS(wlc, idx, cfg) { + FOREACH_BSS(wlc, idx, cfg) if (!cfg->associated) continue; cfg->current_bss->capability &= @@ -3548,7 +3552,7 @@ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) if (wlc->shortslot) cfg->current_bss->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME; - } + END_FOREACH_BSS() brcms_b_set_shortslot(wlc->hw, shortslot); } @@ -3589,12 +3593,13 @@ void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) wlc->home_chanspec = chanspec; - FOREACH_BSS(wlc, idx, cfg) { + FOREACH_BSS(wlc, idx, cfg) if (!cfg->associated) continue; cfg->current_bss->chanspec = chanspec; - } + END_FOREACH_BSS() + } } @@ -5309,14 +5314,14 @@ static void brcms_c_watchdog(void *arg) brcms_c_statsupd(wlc); /* Manage TKIP countermeasures timers */ - FOREACH_BSS(wlc, i, cfg) { + FOREACH_BSS(wlc, i, cfg) if (cfg->tk_cm_dt) { cfg->tk_cm_dt--; } if (cfg->tk_cm_bt) { cfg->tk_cm_bt--; } - } + END_FOREACH_BSS() /* Call any registered watchdog handlers */ for (i = 0; i < BRCMS_MAXMODULES; i++) { @@ -5474,7 +5479,7 @@ int brcms_c_up(struct brcms_c_info *wlc) mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - FOREACH_BSS(wlc, idx, bsscfg) { + FOREACH_BSS(wlc, idx, bsscfg) if (!BSSCFG_STA(bsscfg) || !bsscfg->enable || !bsscfg->BSS) continue; @@ -5482,7 +5487,7 @@ int brcms_c_up(struct brcms_c_info *wlc) ": rfdisable -> " "bsscfg_disable()\n", wlc->pub->unit, idx); - } + END_FOREACH_BSS() } } } @@ -8918,10 +8923,10 @@ void brcms_c_update_beacon(struct brcms_c_info *wlc) struct brcms_bss_cfg *bsscfg; /* update AP or IBSS beacons */ - FOREACH_BSS(wlc, idx, bsscfg) { + FOREACH_BSS(wlc, idx, bsscfg) if (bsscfg->up && (BSSCFG_AP(bsscfg) || !bsscfg->BSS)) brcms_c_bss_update_beacon(wlc, bsscfg); - } + END_FOREACH_BSS() } /* Write ssid into shared memory */ @@ -8947,10 +8952,10 @@ void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) struct brcms_bss_cfg *bsscfg; /* update AP or IBSS probe responses */ - FOREACH_BSS(wlc, idx, bsscfg) { + FOREACH_BSS(wlc, idx, bsscfg) if (bsscfg->up && (BSSCFG_AP(bsscfg) || !bsscfg->BSS)) brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); - } + END_FOREACH_BSS() } void @@ -9031,9 +9036,9 @@ void brcms_c_reprate_init(struct brcms_c_info *wlc) int i; struct brcms_bss_cfg *bsscfg; - FOREACH_BSS(wlc, i, bsscfg) { + FOREACH_BSS(wlc, i, bsscfg) brcms_c_bsscfg_reprate_init(bsscfg); - } + END_FOREACH_BSS() } /* per bsscfg init tx reported rate mechanism */ From 26f1283099600b33f879cb222dd320c111650c0b Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:03 +0200 Subject: [PATCH 0041/1519] staging: brcm80211: use mutex instead of semaphore in dhd_linux.c The semaphore proto_sem has been replaced with mutex proto_block which lock certain code paths for one thread. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 05dada98eb6..4ba9d7dbd67 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -75,7 +75,7 @@ struct brcmf_info { /* OS/stack specifics */ struct brcmf_if *iflist[BRCMF_MAX_IFS]; - struct semaphore proto_sem; + struct mutex proto_block; wait_queue_head_t ioctl_resp_wait; /* Thread to issue ioctl for multicast */ @@ -1314,7 +1314,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) goto fail; net->netdev_ops = NULL; - sema_init(&drvr_priv->proto_sem, 1); + mutex_init(&drvr_priv->proto_block); /* Initialize other structure content */ init_waitqueue_head(&drvr_priv->ioctl_resp_wait); @@ -1584,7 +1584,7 @@ int brcmf_os_proto_block(struct brcmf_pub *drvr) struct brcmf_info *drvr_priv = drvr->info; if (drvr_priv) { - down(&drvr_priv->proto_sem); + mutex_lock(&drvr_priv->proto_block); return 1; } return 0; @@ -1595,7 +1595,7 @@ int brcmf_os_proto_unblock(struct brcmf_pub *drvr) struct brcmf_info *drvr_priv = drvr->info; if (drvr_priv) { - up(&drvr_priv->proto_sem); + mutex_unlock(&drvr_priv->proto_block); return 1; } From 4b616d81bacef2a1ffcee5fbc89af5d0361a3840 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:04 +0200 Subject: [PATCH 0042/1519] staging: brcm80211: remove duplicated code from brcmf_init_iscan Part of the code in brcmf_init_scan was identical to the code in brcmf_invoke_iscan and has been replaced by a call to it. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index e9ccf06db8d..a69fa937117 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3343,7 +3343,6 @@ static void brcmf_iscan_timer(unsigned long data) static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - int err = 0; if (cfg_priv->iscan_on && !iscan->tsk) { iscan->state = WL_ISCAN_STATE_IDLE; @@ -3356,7 +3355,7 @@ static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) } } - return err; + return 0; } static void brcmf_init_iscan_eloop(struct brcmf_cfg80211_iscan_eloop *el) @@ -3376,20 +3375,14 @@ static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) if (cfg_priv->iscan_on) { iscan->dev = cfg_to_ndev(cfg_priv); - iscan->state = WL_ISCAN_STATE_IDLE; brcmf_init_iscan_eloop(&iscan->el); iscan->timer_ms = WL_ISCAN_TIMER_INTERVAL_MS; init_timer(&iscan->timer); iscan->timer.data = (unsigned long) iscan; iscan->timer.function = brcmf_iscan_timer; - sema_init(&iscan->sync, 0); - iscan->tsk = kthread_run(brcmf_iscan_thread, iscan, "wl_iscan"); - if (IS_ERR(iscan->tsk)) { - WL_ERR("Could not create iscan thread\n"); - iscan->tsk = NULL; - return -ENOMEM; - } - iscan->data = cfg_priv; + err = brcmf_invoke_iscan(cfg_priv); + if (!err) + iscan->data = cfg_priv; } return err; From a918137ab54598dc8350079c7a14d7f77e5c4f54 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:05 +0200 Subject: [PATCH 0043/1519] staging: brcm80211: remove volatile keyword from driver sources As checkpatch.pl rightfully indicated the volatile keyword was used but not necessary. It has been removed from the code. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 12 ++++++------ drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d5f570a3762..a49379580af 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -2017,11 +2017,11 @@ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, const struct d11init *inits) { int i; - volatile u8 *base; + u8 *base; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - base = (volatile u8 *)wlc_hw->regs; + base = (u8 *)wlc_hw->regs; for (i = 0; inits[i].addr != 0xffff; i++) { if (inits[i].size == 2) @@ -2822,8 +2822,8 @@ static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) { struct d11regs *regs = wlc_hw->regs; - volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; - volatile u16 *objdata_hi = objdata_lo + 1; + u16 *objdata_lo = (u16 *)®s->objdata; + u16 *objdata_hi = objdata_lo + 1; u16 v; W_REG(®s->objaddr, sel | (offset >> 2)); @@ -2842,8 +2842,8 @@ brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, u32 sel) { struct d11regs *regs = wlc_hw->regs; - volatile u16 *objdata_lo = (volatile u16 *)®s->objdata; - volatile u16 *objdata_hi = objdata_lo + 1; + u16 *objdata_lo = (u16 *)®s->objdata; + u16 *objdata_hi = objdata_lo + 1; W_REG(®s->objaddr, sel | (offset >> 2)); (void)R_REG(®s->objaddr); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 940f76ba778..c6c52870dfe 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -205,7 +205,7 @@ void wlc_radioreg_enter(struct brcms_phy_pub *pih) void wlc_radioreg_exit(struct brcms_phy_pub *pih) { struct brcms_phy *pi = (struct brcms_phy *) pih; - volatile u16 dummy; + u16 dummy; dummy = R_REG(&pi->regs->phyversion); pi->phy_wreg = 0; From fee32378cad26dbe3f16009ba8ce43f483d10a19 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:06 +0200 Subject: [PATCH 0044/1519] staging: brcm80211: use native error code in brcmf_c_pattern_atoh() The function brcmf_c_pattern_atoh() returned meaningless -1 value. These have been replaced by linux error code -EINVAL. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 1e757b73b80..44128934dc0 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -841,12 +841,12 @@ static int brcmf_c_pattern_atoh(char *src, char *dst) int i; if (strncmp(src, "0x", 2) != 0 && strncmp(src, "0X", 2) != 0) { BRCMF_ERROR(("Mask invalid format. Needs to start with 0x\n")); - return -1; + return -EINVAL; } src = src + 2; /* Skip past 0x */ if (strlen(src) % 2 != 0) { BRCMF_ERROR(("Mask invalid format. Length must be even.\n")); - return -1; + return -EINVAL; } for (i = 0; *src != '\0'; i++) { char num[3]; From 2740a329487c68b079785074c72d5a97946ad597 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:07 +0200 Subject: [PATCH 0045/1519] staging: brcm80211: fix for checkpatch 'avoid externs in c file' warning Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 10 ++-------- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 4 ++-- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 1 + 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index f4e72ed126b..fb3ab638e40 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -103,16 +103,8 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; module_param(sd_msglevel, uint, 0); -extern uint sd_f2_blocksize; module_param(sd_f2_blocksize, int, 0); -/* forward declarations */ -int brcmf_sdio_probe(struct device *dev); -EXPORT_SYMBOL(brcmf_sdio_probe); - -int brcmf_sdio_remove(struct device *dev); -EXPORT_SYMBOL(brcmf_sdio_remove); - struct brcmf_sdio_card* brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq) { @@ -590,6 +582,7 @@ err: return -ENODEV; } +EXPORT_SYMBOL(brcmf_sdio_probe); int brcmf_sdio_remove(struct device *dev) { @@ -619,6 +612,7 @@ int brcmf_sdio_remove(struct device *dev) kfree(sdhc); return 0; } +EXPORT_SYMBOL(brcmf_sdio_remove); int brcmf_sdio_register(struct brcmf_sdioh_driver *driver) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 4ba9d7dbd67..b0a98620998 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -423,7 +423,7 @@ static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *a } #ifdef SOFTAP -extern struct net_device *ap_net_dev; +static struct net_device *ap_net_dev; #endif /* Virtual interfaces only ((ifp && ifp->info && ifp->idx == true) */ @@ -469,7 +469,7 @@ static void brcmf_op_if(struct brcmf_if *ifp) #ifdef SOFTAP /* semaphore that the soft AP CODE waits on */ - extern struct semaphore ap_eth_sema; + struct semaphore ap_eth_sema; /* save ptr to wl0.1 netdev for use in wl_iw.c */ diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index d3454721506..ad679558bda 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -341,6 +341,7 @@ extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); extern void brcmf_sdio_wdtmr_enable(bool enable); extern uint sd_msglevel; /* Debug message level */ +extern uint sd_f2_blocksize; extern struct brcmf_sdmmc_instance *gInstance; From 92faa4ea9f749a20c325863c5c40c48602eebe29 Mon Sep 17 00:00:00 2001 From: Sukesh Srikakula Date: Mon, 8 Aug 2011 15:58:08 +0200 Subject: [PATCH 0046/1519] staging: brcm80211: power save issue fixed in brcmfmac driver brcmfmac driver is getting request for enabling power save before the interface is up. With the earlier implementation, this request used to fail resulting out of sync power save state between cfg80211 & brcmfmac driver. With this fix, power save state is stored in configuration parameters and will be used while initializing the adapter. Signed-off-by: Sukesh Srikakula Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_common.c | 5 --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 34 +++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 44128934dc0..62b7591fdad 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -1099,7 +1099,6 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) "event_msgs" + '\0' + bitvec */ uint up = 0; char buf[128], *ptr; - uint power_mode = PM_FAST; u32 dongle_align = BRCMF_SDALIGN; u32 glom = 0; uint bcn_timeout = 3; @@ -1128,10 +1127,6 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* Print fw version info */ BRCMF_ERROR(("Firmware version = %s\n", buf)); - /* Set PowerSave mode */ - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_PM, (char *)&power_mode, - sizeof(power_mode)); - /* Match Host and Dongle rx alignment */ brcmu_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, sizeof(iovbuf)); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index a69fa937117..d4d7c52f83a 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1974,9 +1974,24 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, { s32 pm; s32 err = 0; + struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + + /* + * Powersave enable/disable request is coming from the + * cfg80211 even before the interface is up. In that + * scenario, driver will be storing the power save + * preference in cfg_priv struct to apply this to + * FW later while initializing the dongle + */ + cfg_priv->pwr_save = enabled; + if (!test_bit(WL_STATUS_READY, &cfg_priv->status)) { + + WL_INFO("Device is not ready," + "storing the value in cfg_priv struct\n"); + goto done; + } pm = enabled ? PM_FAST : PM_OFF; pm = cpu_to_le32(pm); @@ -1989,6 +2004,7 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, else WL_ERR("error (%d)\n", err); } +done: WL_TRACE("Exit\n"); return err; } @@ -3390,11 +3406,12 @@ static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) { - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); s32 err = 0; cfg_priv->scan_request = NULL; - cfg_priv->pwr_save = !!(wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT); +#ifndef WL_POWERSAVE_DISABLED + cfg_priv->pwr_save = true; +#endif /* WL_POWERSAVE_DISABLED */ cfg_priv->iscan_on = true; /* iscan on & off switch. we enable iscan per default */ cfg_priv->roam_on = false; /* roam on & off switch. @@ -3811,6 +3828,7 @@ s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, bool need_lock) { struct net_device *ndev; struct wireless_dev *wdev; + s32 power_mode; s32 err = 0; if (cfg_priv->dongle_up) @@ -3827,6 +3845,16 @@ s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, bool need_lock) err = brcmf_dongle_eventmsg(ndev); if (unlikely(err)) goto default_conf_out; + + power_mode = cfg_priv->pwr_save ? PM_FAST : PM_OFF; + power_mode = cpu_to_le32(power_mode); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_PM, + &power_mode, sizeof(power_mode)); + if (err) + goto default_conf_out; + WL_INFO("power save set to %s\n", + (power_mode ? "enabled" : "disabled")); + err = brcmf_dongle_roam(ndev, (cfg_priv->roam_on ? 0 : 1), WL_BEACON_TIMEOUT); if (unlikely(err)) From aed2ee1ff0afa95e487a0ac4c0f165e85de23c7b Mon Sep 17 00:00:00 2001 From: Sukesh Srikakula Date: Mon, 8 Aug 2011 15:58:09 +0200 Subject: [PATCH 0047/1519] staging: brcm80211: brcmfmac: Enabling FW roaming by default With this patch, FW roaming will be enabled by default in brcmfmac driver Signed-off-by: Sukesh Srikakula Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index d4d7c52f83a..a915b6e409e 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3414,7 +3414,7 @@ static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) #endif /* WL_POWERSAVE_DISABLED */ cfg_priv->iscan_on = true; /* iscan on & off switch. we enable iscan per default */ - cfg_priv->roam_on = false; /* roam on & off switch. + cfg_priv->roam_on = true; /* roam on & off switch. we enable roam per default */ cfg_priv->iscan_kickstart = false; From bf4c4f434d473e63e87b2b0b4f86d52079764df0 Mon Sep 17 00:00:00 2001 From: Sukesh Srikakula Date: Mon, 8 Aug 2011 15:58:10 +0200 Subject: [PATCH 0048/1519] staging: brcm80211: brcmfmac: Connect request made robust Connect request made robust by passing broadcast bssid to the FW in SET_SSID request. This fix helps STA to connect to any available AP in ESS instead of sticking to one unresponsive AP. Signed-off-by: Sukesh Srikakula Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index a915b6e409e..2e8fd6e7052 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1420,11 +1420,6 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, goto done; } - brcmf_update_prof(cfg_priv, NULL, sme->bssid, WL_PROF_BSSID); - /* - ** Join with specific BSSID and cached SSID - ** If SSID is zero join based on BSSID only - */ memset(&join_params, 0, sizeof(join_params)); join_params_size = sizeof(join_params.ssid); @@ -1433,10 +1428,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); - if (sme->bssid) - memcpy(join_params.params.bssid, sme->bssid, ETH_ALEN); - else - memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); + memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) { WL_CONN("ssid \"%s\", len (%d)\n", From 5973f660c49e2cb1d73e262103dabe458955c685 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:11 +0200 Subject: [PATCH 0049/1519] staging: brcm80211: use mac_pton() instead of own implementation The function brcmu_ether_atoe() does exactly the same as mac_pton(). The driver now uses the latter and brcmu_ether_atoe() has been removed as it is not used anymore. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 5 +++-- drivers/staging/brcm80211/brcmutil/utils.c | 15 --------------- drivers/staging/brcm80211/include/brcmu_utils.h | 3 --- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index a49379580af..eb394f5a5f1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -4584,8 +4585,8 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, err = 21; goto fail; } - brcmu_ether_atoe(macaddr, wlc_hw->etheraddr); - if (is_broadcast_ether_addr(wlc_hw->etheraddr) || + if (!mac_pton(macaddr, wlc_hw->etheraddr) || + is_broadcast_ether_addr(wlc_hw->etheraddr) || is_zero_ether_addr(wlc_hw->etheraddr)) { wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", unit, macaddr); diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index cad1600e6d4..2151e0b481c 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -350,21 +350,6 @@ struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, } EXPORT_SYMBOL(brcmu_pktq_mdeq); -/* parse a xx:xx:xx:xx:xx:xx format ethernet address */ -int brcmu_ether_atoe(char *p, u8 *ea) -{ - int i = 0; - - for (;;) { - ea[i++] = (char)simple_strtoul(p, &p, 16); - if (!*p++ || i == 6) - break; - } - - return i == 6; -} -EXPORT_SYMBOL(brcmu_ether_atoe); - #if defined(BCMDBG) /* pretty hex print a pkt buffer chain */ void brcmu_prpkt(const char *msg, struct sk_buff *p0) diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index 8a340f06b50..513fa34f921 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -133,9 +133,6 @@ extern uint brcmu_pktfrombuf(struct sk_buff *p, uint offset, int len, unsigned char *buf); extern uint brcmu_pkttotlen(struct sk_buff *p); -/* ethernet address */ -extern int brcmu_ether_atoe(char *p, u8 *ea); - /* ip address */ struct ipv4_addr; From 8ea54c9f140bb5eecf3f9e9b02043bbfcff80eb5 Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Mon, 8 Aug 2011 15:58:12 +0200 Subject: [PATCH 0050/1519] staging: brcm80211: fix for 'remove unnecessary braces' checkpatch warning Removed unnecessary braces in single-statement blocks. Used the tools 'uncrustify' and 'coccinelle' to accomplish this. Signed-off-by: Henry Ptasinski Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 20 +- .../staging/brcm80211/brcmfmac/dhd_common.c | 45 +- .../staging/brcm80211/brcmfmac/dhd_linux.c | 13 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 64 +- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 26 +- drivers/staging/brcm80211/brcmsmac/aiutils.c | 30 +- drivers/staging/brcm80211/brcmsmac/alloc.c | 9 +- drivers/staging/brcm80211/brcmsmac/ampdu.c | 29 +- drivers/staging/brcm80211/brcmsmac/antsel.c | 9 +- drivers/staging/brcm80211/brcmsmac/channel.c | 121 +- drivers/staging/brcm80211/brcmsmac/dma.c | 27 +- .../staging/brcm80211/brcmsmac/mac80211_if.c | 51 +- drivers/staging/brcm80211/brcmsmac/main.c | 349 ++--- drivers/staging/brcm80211/brcmsmac/nicpci.c | 2 + drivers/staging/brcm80211/brcmsmac/otp.c | 14 +- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 187 +-- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 145 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 1326 ++++++----------- .../brcm80211/brcmsmac/phy/phy_qmath.c | 36 +- drivers/staging/brcm80211/brcmsmac/rate.c | 5 +- drivers/staging/brcm80211/brcmsmac/srom.c | 17 +- drivers/staging/brcm80211/brcmsmac/stf.c | 35 +- drivers/staging/brcm80211/brcmutil/utils.c | 17 +- drivers/staging/brcm80211/brcmutil/wifi.c | 10 +- 25 files changed, 985 insertions(+), 1604 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index e345af7918e..bfe73eefbfd 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -218,10 +218,9 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) sdio_claim_host(gInstance->func[1]); err_ret = sdio_enable_func(gInstance->func[1]); sdio_release_host(gInstance->func[1]); - if (err_ret) { + if (err_ret) sd_err(("brcmf_sdioh_enablefuncs: Failed to enable F1 " "Err: 0x%08x\n", err_ret)); - } return false; } @@ -763,35 +762,32 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, sdio_claim_host(gInstance->func[func]); if (rw) { /* CMD52 Write */ - if (nbytes == 4) { + if (nbytes == 4) sdio_writel(gInstance->func[func], *word, addr, &err_ret); - } else if (nbytes == 2) { + else if (nbytes == 2) sdio_writew(gInstance->func[func], (*word & 0xFFFF), addr, &err_ret); - } else { + else sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); - } } else { /* CMD52 Read */ - if (nbytes == 4) { + if (nbytes == 4) *word = sdio_readl(gInstance->func[func], addr, &err_ret); - } else if (nbytes == 2) { + else if (nbytes == 2) *word = sdio_readw(gInstance->func[func], addr, &err_ret) & 0xFFFF; - } else { + else sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); - } } /* Release host controller */ sdio_release_host(gInstance->func[func]); - if (err_ret) { + if (err_ret) sd_err(("brcmf: Failed to %s word, Err: 0x%08x\n", rw ? "Write" : "Read", err_ret)); - } return err_ret; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 62b7591fdad..d5648f87f5a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -284,18 +284,17 @@ bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, /* Evict packet according to discard policy */ p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) : brcmu_pktq_pdeq_tail(q, eprec); - if (p == NULL) { + if (p == NULL) BRCMF_ERROR(("%s: brcmu_pktq_penq() failed, oldest %d.", __func__, discard_oldest)); - } + brcmu_pkt_buf_free_skb(p); } /* Enqueue */ p = brcmu_pktq_penq(q, prec, pkt); - if (p == NULL) { + if (p == NULL) BRCMF_ERROR(("%s: brcmu_pktq_penq() failed.", __func__)); - } return p != NULL; } @@ -542,20 +541,19 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) case BRCMF_E_ASSOC: case BRCMF_E_REASSOC: - if (status == BRCMF_E_STATUS_SUCCESS) { + if (status == BRCMF_E_STATUS_SUCCESS) BRCMF_EVENT(("MACEVENT: %s, MAC %s, SUCCESS\n", event_name, eabuf)); - } else if (status == BRCMF_E_STATUS_TIMEOUT) { + else if (status == BRCMF_E_STATUS_TIMEOUT) BRCMF_EVENT(("MACEVENT: %s, MAC %s, TIMEOUT\n", event_name, eabuf)); - } else if (status == BRCMF_E_STATUS_FAIL) { + else if (status == BRCMF_E_STATUS_FAIL) BRCMF_EVENT(("MACEVENT: %s, MAC %s, FAILURE," " reason %d\n", event_name, eabuf, (int)reason)); - } else { + else BRCMF_EVENT(("MACEVENT: %s, MAC %s, unexpected status " "%d\n", event_name, eabuf, (int)status)); - } break; case BRCMF_E_DEAUTH_IND: @@ -574,16 +572,16 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) sprintf(err_msg, "AUTH unknown: %d", (int)auth_type); auth_str = err_msg; } - if (event_type == BRCMF_E_AUTH_IND) { + if (event_type == BRCMF_E_AUTH_IND) BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s\n", event_name, eabuf, auth_str)); - } else if (status == BRCMF_E_STATUS_SUCCESS) { + else if (status == BRCMF_E_STATUS_SUCCESS) BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, SUCCESS\n", event_name, eabuf, auth_str)); - } else if (status == BRCMF_E_STATUS_TIMEOUT) { + else if (status == BRCMF_E_STATUS_TIMEOUT) BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, TIMEOUT\n", event_name, eabuf, auth_str)); - } else if (status == BRCMF_E_STATUS_FAIL) { + else if (status == BRCMF_E_STATUS_FAIL) { BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, FAILURE, " "reason %d\n", event_name, eabuf, auth_str, (int)reason)); @@ -594,29 +592,27 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) case BRCMF_E_JOIN: case BRCMF_E_ROAM: case BRCMF_E_SET_SSID: - if (status == BRCMF_E_STATUS_SUCCESS) { + if (status == BRCMF_E_STATUS_SUCCESS) BRCMF_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf)); - } else if (status == BRCMF_E_STATUS_FAIL) { + else if (status == BRCMF_E_STATUS_FAIL) BRCMF_EVENT(("MACEVENT: %s, failed\n", event_name)); - } else if (status == BRCMF_E_STATUS_NO_NETWORKS) { + else if (status == BRCMF_E_STATUS_NO_NETWORKS) BRCMF_EVENT(("MACEVENT: %s, no networks found\n", event_name)); - } else { + else BRCMF_EVENT(("MACEVENT: %s, unexpected status %d\n", event_name, (int)status)); - } break; case BRCMF_E_BEACON_RX: - if (status == BRCMF_E_STATUS_SUCCESS) { + if (status == BRCMF_E_STATUS_SUCCESS) BRCMF_EVENT(("MACEVENT: %s, SUCCESS\n", event_name)); - } else if (status == BRCMF_E_STATUS_FAIL) { + else if (status == BRCMF_E_STATUS_FAIL) BRCMF_EVENT(("MACEVENT: %s, FAIL\n", event_name)); - } else { + else BRCMF_EVENT(("MACEVENT: %s, status %d\n", event_name, status)); - } break; case BRCMF_E_LINK: @@ -1111,11 +1107,10 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* Set Country code */ if (drvr->country_code[0] != 0) { if (brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_COUNTRY, - drvr->country_code, - sizeof(drvr->country_code)) < 0) { + drvr->country_code, + sizeof(drvr->country_code)) < 0) BRCMF_ERROR(("%s: country code setting failed\n", __func__)); - } } /* query for 'ver' to get version info from firmware */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index b0a98620998..7e9c86b9742 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -412,12 +412,11 @@ static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *a ioc.set = true; ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); - if (ret < 0) { + if (ret < 0) BRCMF_ERROR(("%s: set cur_etheraddr failed\n", brcmf_ifname(&drvr_priv->pub, ifidx))); - } else { + else memcpy(drvr_priv->iflist[ifidx]->net->dev_addr, addr, ETH_ALEN); - } return ret; } @@ -771,9 +770,9 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, drvr->dstats.rx_bytes += skb->len; drvr->rx_packets++; /* Local count */ - if (in_interrupt()) { + if (in_interrupt()) netif_rx(skb); - } else { + else /* If the receive is not processed inside an ISR, * the softirqd must be woken explicitly to service * the NET_RX_SOFTIRQ. In 2.6 kernels, this is handled @@ -781,7 +780,6 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, * to do it manually. */ netif_rx_ni(skb); - } } } @@ -816,10 +814,9 @@ static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *net) ifp = drvr_priv->iflist[ifidx]; - if (drvr_priv->pub.up) { + if (drvr_priv->pub.up) /* Use the protocol to get dongle stats */ brcmf_proto_dstats(&drvr_priv->pub); - } /* Copy dongle stats to net device stats */ ifp->stats.rx_packets = drvr_priv->pub.dstats.rx_packets; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index ddd781e530a..705b57ca2ca 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1127,10 +1127,9 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) #if defined(BCMDBG) if (bus->alp_only != true) { - if (SBSDIO_ALPONLY(clkctl)) { + if (SBSDIO_ALPONLY(clkctl)) BRCMF_ERROR(("%s: HT Clock should be on.\n", __func__)); - } } #endif /* defined (BCMDBG) */ @@ -1428,9 +1427,8 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, uint c } /* Some controllers have trouble with odd bytes -- round to even */ - if (forcealign && (len & (ALIGNMENT - 1))) { + if (forcealign && (len & (ALIGNMENT - 1))) len = roundup(len, ALIGNMENT); - } do { ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(card), @@ -1782,10 +1780,10 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) } } - if (ret == 0) { + if (ret == 0) bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - } + } while ((ret < 0) && retries++ < TXRETRIES); } @@ -2181,10 +2179,9 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, xfer_done: /* Return the window to backplane enumeration space for core access */ if (brcmf_sdbrcm_set_siaddr_window(bus, - brcmf_sdcard_cur_sbwad(bus->card))) { + brcmf_sdcard_cur_sbwad(bus->card))) BRCMF_ERROR(("%s: FAILED to set window back to 0x%x\n", __func__, brcmf_sdcard_cur_sbwad(bus->card))); - } return bcmerror; } @@ -2287,13 +2284,12 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) "msgtrace address : 0x%08X\nconsole address : 0x%08X\n", sdpcm_shared.msgtrace_addr, sdpcm_shared.console_addr); - if ((sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) == 0) { + if ((sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) == 0) /* NOTE: Misspelled assert is intentional - DO NOT FIX. * (Avoids conflict with real asserts for programmatic * parsing of output.) */ brcmu_bprintf(&strbuf, "Assrt not built in dongle\n"); - } if ((sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) == 0) { @@ -2358,10 +2354,10 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) BRCMF_ERROR(("%s: %s\n", __func__, strbuf.origbuf)); #ifdef BCMDBG - if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) { + if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) /* Mem dump to a file on device */ brcmf_sdbrcm_mem_dump(bus); - } + #endif /* BCMDBG */ done: @@ -2591,11 +2587,10 @@ brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, const struct brcmu_iovar *vi, u32 ac if (bus->drvr->up) { BRCMF_INTR(("%s: %s SDIO interrupts\n", __func__, bus->intr ? "enable" : "disable")); - if (bus->intr) { + if (bus->intr) brcmf_sdcard_intr_enable(bus->card); - } else { + else brcmf_sdcard_intr_disable(bus->card); - } } break; @@ -3016,10 +3011,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) varsize, varaddr)); } /* Compare the org NVRAM with the one read from RAM */ - if (memcmp(vbuffer, nvram_ularray, varsize)) { + if (memcmp(vbuffer, nvram_ularray, varsize)) BRCMF_ERROR(("%s: Downloaded NVRAM image is " "corrupted.\n", __func__)); - } else + else BRCMF_ERROR(("%s: Download/Upload/Compare of" " NVRAM ok.\n", __func__)); @@ -3249,10 +3244,9 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) SBSDIO_FUNC1_CHIPCLKCSR, (saveclk | SBSDIO_FORCE_HT), &err); } - if (err) { + if (err) BRCMF_ERROR(("%s: Failed to force clock for F2: err %d\n", __func__, err)); - } /* Turn off the bus (F2), free any pending packets */ BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); @@ -3456,13 +3450,12 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) lastrbc = (hi << 8) + lo; } - if (!retries) { + if (!retries) BRCMF_ERROR(("%s: count never zeroed: last 0x%04x\n", __func__, lastrbc)); - } else { + else BRCMF_INFO(("%s: flush took %d iterations\n", __func__, (0xffff - retries))); - } if (rtx) { bus->rxrtx++; @@ -3936,11 +3929,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) if (pfirst->len == 0) { brcmu_pkt_buf_free_skb(pfirst); - if (plast) { + if (plast) plast->next = pnext; - } else { + else save_pfirst = pnext; - } + continue; } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pfirst) != 0) { @@ -3948,11 +3941,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) __func__)); bus->drvr->rx_errors++; brcmu_pkt_buf_free_skb(pfirst); - if (plast) { + if (plast) plast->next = pnext; - } else { + else save_pfirst = pnext; - } + continue; } @@ -4647,10 +4640,9 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) HMB_DATA_NAKHANDLED | HMB_DATA_FC | HMB_DATA_FWREADY | - HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) { + HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) BRCMF_ERROR(("Unknown mailbox data content: 0x%02x\n", hmb_data)); - } return intstatus; } @@ -5773,13 +5765,13 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) default to use if supported */ if (brcmf_sdcard_iovar_op(card, "sd_rxchain", NULL, 0, &bus->sd_rxchain, sizeof(s32), - false) != 0) { + false) != 0) bus->sd_rxchain = false; - } else { + else BRCMF_INFO(("%s: bus module (through sdiocard API) %s" " chaining\n", __func__, bus->sd_rxchain ? "supports" : "does not support")); - } + bus->use_rxchain = (bool) bus->sd_rxchain; return true; @@ -5864,9 +5856,8 @@ static void brcmf_sdbrcm_disconnect(void *ptr) BRCMF_TRACE(("%s: Enter\n", __func__)); - if (bus) { + if (bus) brcmf_sdbrcm_release(bus); - } BRCMF_TRACE(("%s: Disconnected\n", __func__)); } @@ -6085,10 +6076,9 @@ static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) } /* External nvram takes precedence if specified */ - if (brcmf_sdbrcm_download_nvram(bus)) { + if (brcmf_sdbrcm_download_nvram(bus)) BRCMF_ERROR(("%s: dongle nvram file download failed\n", __func__)); - } /* Take arm out of reset */ if (brcmf_sdbrcm_download_state(bus, false)) { diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 2e8fd6e7052..8423aadd87a 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -677,12 +677,12 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, err = brcmf_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size, iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); if (unlikely(err)) { - if (err == -EBUSY) { + if (err == -EBUSY) WL_INFO("system busy : iscan canceled\n"); - } else { + else WL_ERR("error (%d)\n", err); - } } + kfree(params); return err; } @@ -790,12 +790,12 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN, &sr->ssid, sizeof(sr->ssid)); if (err) { - if (err == -EBUSY) { + if (err == -EBUSY) WL_INFO("system busy : scan for \"%s\" canceled\n", sr->ssid.SSID); - } else { + else WL_ERR("WLC_SCAN error (%d)\n", err); - } + brcmf_set_mpc(ndev, 1); goto scan_out; } @@ -1049,6 +1049,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, } else { memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); } + brcmf_update_prof(cfg_priv, NULL, &join_params.params.bssid, WL_PROF_BSSID); @@ -1430,10 +1431,9 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); - if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) { + if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) WL_CONN("ssid \"%s\", len (%d)\n", join_params.ssid.SSID, join_params.ssid.SSID_len); - } brcmf_ch_to_chanspec(cfg_priv->channel, &join_params, &join_params_size); @@ -1946,9 +1946,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, scb_val.val = 0; err = brcmf_dev_ioctl(dev, BRCMF_C_GET_RSSI, &scb_val, sizeof(struct brcmf_scb_val)); - if (unlikely(err)) { + if (unlikely(err)) WL_ERR("Could not get rssi (%d)\n", err); - } + rssi = le32_to_cpu(scb_val.val); sinfo->filled |= STATION_INFO_SIGNAL; sinfo->signal = rssi; @@ -3523,13 +3523,13 @@ static s32 brcmf_event_handler(void *data) BUG(); } WL_INFO("event type (%d)\n", e->etype); - if (cfg_priv->el.handler[e->etype]) { + if (cfg_priv->el.handler[e->etype]) cfg_priv->el.handler[e->etype](cfg_priv, cfg_to_ndev(cfg_priv), &e->emsg, e->edata); - } else { + else WL_INFO("Unknown Event (%d): ignoring\n", e->etype); - } + brcmf_put_event(e); } WL_INFO("was terminated\n"); diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 58a5cfc239e..bc4e2e14a21 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -387,10 +387,10 @@ get_erom_ent(struct si_pub *sih, u32 **eromptr, u32 mask, u32 match) } SI_VMSG(("%s: Returning ent 0x%08x\n", __func__, ent)); - if (inv + nom) { + if (inv + nom) SI_VMSG((" after %d invalid and %d non-matching entries\n", inv, nom)); - } + return ent; } @@ -511,9 +511,8 @@ void ai_scan(struct si_pub *sih, void *regs) if (cid == OOB_ROUTER_CORE_ID) { asd = get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, &addrl, &addrh, &sizel, &sizeh); - if (asd != 0) { + if (asd != 0) sii->oob_router = addrl; - } } continue; } @@ -650,13 +649,13 @@ void *ai_setcoreidx(struct si_pub *sih, uint coreidx) switch (sih->bustype) { case SI_BUS: /* map new one */ - if (!sii->regs[coreidx]) { + if (!sii->regs[coreidx]) sii->regs[coreidx] = REG_MAP(addr, SI_CORE_SIZE); - } + sii->curmap = regs = sii->regs[coreidx]; - if (!sii->wrappers[coreidx]) { + if (!sii->wrappers[coreidx]) sii->wrappers[coreidx] = REG_MAP(wrap, SI_CORE_SIZE); - } + sii->curwrap = sii->wrappers[coreidx]; break; @@ -1063,9 +1062,8 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) break; } - if (sii->pub.boardtype == 0) { + if (sii->pub.boardtype == 0) SI_ERROR(("si_doattach: unknown board type\n")); - } sii->pub.boardflags = getintvar(pvars, "boardflags"); } @@ -1195,9 +1193,8 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), ~0, w); - if (PCIE(sii)) { + if (PCIE(sii)) pcicore_attach(sii->pch, pvars, SI_DOATTACH); - } if (sih->chip == BCM43224_CHIP_ID) { /* @@ -1435,10 +1432,10 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, /* If internal bus, we can always get at everything */ fast = true; /* map if does not exist */ - if (!sii->regs[coreidx]) { + if (!sii->regs[coreidx]) sii->regs[coreidx] = REG_MAP(sii->coresba[coreidx], SI_CORE_SIZE); - } + r = (u32 *) ((unsigned char *) sii->regs[coreidx] + regoff); } else if (sih->bustype == PCI_BUS) { /* @@ -2187,16 +2184,15 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) val = R_REG(&cc->chipcontrol); if (on) { - if (sih->chippkg == 9 || sih->chippkg == 0xb) { + if (sih->chippkg == 9 || sih->chippkg == 0xb) /* Ext PA Controls for 4331 12x9 Package */ W_REG(&cc->chipcontrol, val | (CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5)); - } else { + else /* Ext PA Controls for 4331 12x12 Package */ W_REG(&cc->chipcontrol, val | (CCTRL4331_EXTPA_EN)); - } } else { val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); W_REG(&cc->chipcontrol, val); diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 7f8dd7b396b..7dc287576cb 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -161,11 +161,10 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) } else { int i; - for (i = 1; i < MAXBANDS; i++) { + for (i = 1; i < MAXBANDS; i++) wlc->hw->bandstate[i] = (struct brcms_hw_band *) ((unsigned long)wlc->hw->bandstate[0] + (sizeof(struct brcms_hw_band) * i)); - } } wlc->modulecb = @@ -196,11 +195,10 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) goto fail; } else { int i; - for (i = 1; i < BRCMS_DEFAULT_KEYS; i++) { + for (i = 1; i < BRCMS_DEFAULT_KEYS; i++) wlc->wsec_def_keys[i] = (struct wsec_key *) ((unsigned long)wlc->wsec_def_keys[0] + (sizeof(struct wsec_key) * i)); - } } wlc->protection = kzalloc(sizeof(struct brcms_protection), @@ -224,11 +222,10 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) } else { int i; - for (i = 1; i < MAXBANDS; i++) { + for (i = 1; i < MAXBANDS; i++) wlc->bandstate[i] = (struct brcms_band *) ((unsigned long)wlc->bandstate[0] + (sizeof(struct brcms_band)*i)); - } } wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 5d090385844..b462fc80bf3 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -195,9 +195,8 @@ void brcms_c_ampdu_detach(struct ampdu_info *ampdu) return; /* free all ini's which were to be freed on callbacks which were never called */ - for (i = 0; i < AMPDU_INI_FREE; i++) { + for (i = 0; i < AMPDU_INI_FREE; i++) kfree(ampdu->ini_free[i]); - } brcms_c_module_unregister(ampdu->wlc->pub, "ampdu", ampdu); kfree(ampdu); @@ -317,9 +316,9 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) txunfl_ratio = current_ampdu_cnt / fifo->accum_txfunfl; if (txunfl_ratio > ampdu->tx_max_funl) { - if (current_ampdu_cnt >= FFPLD_MAX_AMPDU_CNT) { + if (current_ampdu_cnt >= FFPLD_MAX_AMPDU_CNT) fifo->accum_txfunfl = 0; - } + return 0; } max_mpdu = @@ -486,10 +485,9 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, /* Let pressure continue to build ... */ qlen = pktq_plen(&qi->q, prec); if (ini->tx_in_transit > 0 && - qlen < min(scb_ampdu->max_pdu, ini->ba_wsize)) { + qlen < min(scb_ampdu->max_pdu, ini->ba_wsize)) /* Collect multiple MPDU's to be sent in the next AMPDU */ return -EBUSY; - } /* at this point we intend to transmit an AMPDU */ rr_retry_limit = ampdu->rr_retry_limit_tid[tid]; @@ -665,9 +663,8 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, break; } - if (count == scb_ampdu->max_pdu) { + if (count == scb_ampdu->max_pdu) break; - } /* check to see if the next pkt is a candidate for aggregation */ p = pktq_ppeek(&qi->q, prec); @@ -797,10 +794,10 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, /* inform rate_sel if it this is a rate probe pkt */ frameid = le16_to_cpu(txh->TxFrameID); - if (frameid & TXFID_RATE_PROBE_MASK) { + if (frameid & TXFID_RATE_PROBE_MASK) wiphy_err(wiphy, "%s: XXX what to do with " "TXFID_RATE_PROBE_MASK!?\n", __func__); - } + for (i = 0; i < count; i++) brcms_c_txfifo(wlc, fifo, pkt[i], i == (count - 1), ampdu->txpkt_weight); @@ -833,9 +830,8 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { udelay(1); status_delay++; - if (status_delay > 10) { + if (status_delay > 10) return; /* error condition */ - } } s2 = R_REG(&wlc->regs->frmtxstatus2); @@ -923,9 +919,8 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, supr_status = txs->status & TX_STATUS_SUPR_MASK; if (txs->status & TX_STATUS_ACK_RCV) { - if (TX_STATUS_SUPR_UF == supr_status) { + if (TX_STATUS_SUPR_UF == supr_status) update_rate = false; - } WARN_ON(!(txs->status & TX_STATUS_INTERMEDIATE)); start_seq = txs->sequence >> SEQNUM_SHIFT; @@ -973,9 +968,8 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, notify rate adaptation. */ if (brcms_c_ffpld_check_txfunfl(wlc, - prio2fifo[tid]) > 0) { + prio2fifo[tid]) > 0) tx_error = true; - } } } else if (txs->phyerr) { update_rate = false; @@ -1211,9 +1205,8 @@ void brcms_c_ampdu_flush(struct brcms_c_info *wlc, ampdu_pars.sta = sta; ampdu_pars.tid = tid; - for (prec = 0; prec < pq->num_prec; prec++) { + for (prec = 0; prec < pq->num_prec; prec++) brcmu_pktq_pflush(pq, prec, true, cb_del_ampdu_pkt, (void *)&du_pars); - } brcms_c_inval_dma_pkts(wlc->hw, sta, dma_cb_fn_ampdu); } diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index 1d6c3984bc7..5a5d5d6569a 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -110,17 +110,16 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) if (((u16) getintvar(asi->pub->vars, "aa2g") == 7) || ((u16) getintvar(asi->pub->vars, "aa5g") == 7)) { asi->antsel_avail = true; - } else - if (((u16) getintvar(asi->pub->vars, "aa2g") == - 3) - || ((u16) getintvar(asi->pub->vars, "aa5g") - == 3)) { + } else if ( + (u16) getintvar(asi->pub->vars, "aa2g") == 3 || + (u16) getintvar(asi->pub->vars, "aa5g") == 3) { asi->antsel_avail = false; } else { asi->antsel_avail = false; wiphy_err(wlc->wiphy, "antsel_attach: 2o3 " "board cfg invalid\n"); } + break; default: break; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 807df6ac61a..a738e3bd0a1 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -409,10 +409,9 @@ static void brcms_c_locale_get_channels(const struct locale_info *locale, memset(channels, 0, sizeof(struct brcms_chanvec)); for (i = 0; i < ARRAY_SIZE(g_table_locale_base); i++) { - if (locale->valid_channels & (1 << i)) { + if (locale->valid_channels & (1 << i)) brcms_c_locale_add_channels(channels, g_table_locale_base[i]); - } } } @@ -590,33 +589,33 @@ struct chan20_info chan20_info[] = { static const struct locale_info *brcms_c_get_locale_2g(u8 locale_idx) { - if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) { + if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) return NULL; /* error condition */ - } + return g_locale_2g_table[locale_idx]; } static const struct locale_info *brcms_c_get_locale_5g(u8 locale_idx) { - if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) { + if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) return NULL; /* error condition */ - } + return g_locale_5g_table[locale_idx]; } static const struct locale_mimo_info *brcms_c_get_mimo_2g(u8 locale_idx) { - if (locale_idx >= ARRAY_SIZE(g_mimo_2g_table)) { + if (locale_idx >= ARRAY_SIZE(g_mimo_2g_table)) return NULL; - } + return g_mimo_2g_table[locale_idx]; } static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx) { - if (locale_idx >= ARRAY_SIZE(g_mimo_5g_table)) { + if (locale_idx >= ARRAY_SIZE(g_mimo_5g_table)) return NULL; - } + return g_mimo_5g_table[locale_idx]; } @@ -642,9 +641,8 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) /* store the country code for passing up as a regulatory hint */ ccode = getvar(wlc->pub->vars, "ccode"); - if (ccode) { + if (ccode) strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - } /* internal country information which must match regulatory constraints in firmware */ memset(country_abbrev, 0, BRCM_CNTRY_BUF_SZ); @@ -759,11 +757,10 @@ brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); /* set or restore gmode as required by regulatory */ locale = brcms_c_get_locale_2g(country->locale_2G); - if (locale && (locale->flags & BRCMS_NO_OFDM)) { + if (locale && (locale->flags & BRCMS_NO_OFDM)) brcms_c_set_gmode(wlc, GMODE_LEGACY_B, false); - } else { + else brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); - } brcms_c_channels_init(wlc_cm, country); @@ -860,9 +857,8 @@ brcms_c_country_lookup_direct(const char *ccode, uint regrev) /* find matched table entry from country code */ size = ARRAY_SIZE(cntry_locales); for (i = 0; i < size; i++) { - if (strcmp(ccode, cntry_locales[i].abbrev) == 0) { + if (strcmp(ccode, cntry_locales[i].abbrev) == 0) return &cntry_locales[i].country; - } } return NULL; } @@ -929,9 +925,8 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) /* search for the existence of any valid channel */ for (chan = 0; chan < MAXCHANNEL; chan++) { - if (VALID_CHANNEL20_DB(wlc, chan)) { + if (VALID_CHANNEL20_DB(wlc, chan)) break; - } } if (chan == MAXCHANNEL) chan = INVCHANNEL; @@ -944,9 +939,8 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) "nbands %d bandlocked %d\n", wlc->pub->unit, __func__, wlc_cm->country_abbrev, NBANDS(wlc), wlc->bandlocked); - } else - if (mboolisset(wlc->pub->radio_disabled, - WL_RADIO_COUNTRY_DISABLE)) { + } else if (mboolisset(wlc->pub->radio_disabled, + WL_RADIO_COUNTRY_DISABLE)) { /* country/locale with valid channel, clear the radio disable bit */ mboolclr(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); } @@ -954,11 +948,10 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) /* Now that the country abbreviation is set, if the radio supports 2G, then * set channel 14 restrictions based on the new locale. */ - if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) { + if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, brcms_c_japan(wlc) ? true : false); - } if (wlc->pub->up && chan != INVCHANNEL) { brcms_c_channel_reg_limits(wlc_cm, wlc->chanspec, &txpwr); @@ -1043,50 +1036,42 @@ brcms_c_channel_min_txpower_limits_with_local_constraint( int j; /* CCK Rates */ - for (j = 0; j < WL_TX_POWER_CCK_NUM; j++) { + for (j = 0; j < WL_TX_POWER_CCK_NUM; j++) txpwr->cck[j] = min(txpwr->cck[j], local_constraint_qdbm); - } /* 20 MHz Legacy OFDM SISO */ - for (j = 0; j < WL_TX_POWER_OFDM_NUM; j++) { + for (j = 0; j < WL_TX_POWER_OFDM_NUM; j++) txpwr->ofdm[j] = min(txpwr->ofdm[j], local_constraint_qdbm); - } /* 20 MHz Legacy OFDM CDD */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) txpwr->ofdm_cdd[j] = min(txpwr->ofdm_cdd[j], local_constraint_qdbm); - } /* 40 MHz Legacy OFDM SISO */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) txpwr->ofdm_40_siso[j] = min(txpwr->ofdm_40_siso[j], local_constraint_qdbm); - } /* 40 MHz Legacy OFDM CDD */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) txpwr->ofdm_40_cdd[j] = min(txpwr->ofdm_40_cdd[j], local_constraint_qdbm); - } /* 20MHz MCS 0-7 SISO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_20_siso[j] = min(txpwr->mcs_20_siso[j], local_constraint_qdbm); - } /* 20MHz MCS 0-7 CDD */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_20_cdd[j] = min(txpwr->mcs_20_cdd[j], local_constraint_qdbm); - } /* 20MHz MCS 0-7 STBC */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_20_stbc[j] = min(txpwr->mcs_20_stbc[j], local_constraint_qdbm); - } /* 20MHz MCS 8-15 MIMO */ for (j = 0; j < BRCMS_NUM_RATES_MCS_2_STREAM; j++) @@ -1094,22 +1079,19 @@ brcms_c_channel_min_txpower_limits_with_local_constraint( min(txpwr->mcs_20_mimo[j], local_constraint_qdbm); /* 40MHz MCS 0-7 SISO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_40_siso[j] = min(txpwr->mcs_40_siso[j], local_constraint_qdbm); - } /* 40MHz MCS 0-7 CDD */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_40_cdd[j] = min(txpwr->mcs_40_cdd[j], local_constraint_qdbm); - } /* 40MHz MCS 0-7 STBC */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) { + for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) txpwr->mcs_40_stbc[j] = min(txpwr->mcs_40_stbc[j], local_constraint_qdbm); - } /* 40MHz MCS 8-15 MIMO */ for (j = 0; j < BRCMS_NUM_RATES_MCS_2_STREAM; j++) @@ -1146,112 +1128,100 @@ static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; sprintf(buf, "CCK "); - for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) { + for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->cck[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->cck[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->ofdm[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->ofdm[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->ofdm_cdd[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->ofdm_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->ofdm_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->ofdm_40_siso[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->ofdm_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->ofdm_40_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_20_siso[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_20_siso[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_20_cdd[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_20_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_20_stbc[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_20_stbc[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "20 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_20_mimo[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_20_mimo[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_40_siso[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_40_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_40_stbc[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_40_stbc[i] % BRCMS_TXPWR_DB_FACTOR]); - } printk(KERN_DEBUG "%s\n", buf); sprintf(buf, "40 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) { + for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) sprintf(buf[strlen(buf)], " %2d%s", txpwr->mcs_40_mimo[i] / BRCMS_TXPWR_DB_FACTOR, fraction[txpwr->mcs_40_mimo[i] % @@ -1330,12 +1300,10 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } /* OFDM txpwr limits for 2.4G or 5G bands */ - if (BAND_2G(band->bandtype)) { + if (BAND_2G(band->bandtype)) maxpwr = li->maxpwr[CHANNEL_POWER_IDX_2G_OFDM(chan)]; - - } else { + else maxpwr = li->maxpwr[CHANNEL_POWER_IDX_5G(chan)]; - } maxpwr = maxpwr - delta; maxpwr = max(maxpwr, 0); @@ -1405,9 +1373,8 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, maxpwr20 = QDB(16); maxpwr40 = 0; - if (chan >= 3 && chan <= 11) { + if (chan >= 3 && chan <= 11) maxpwr40 = QDB(16); - } } for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 6fabb09b69e..31a47286d12 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -533,12 +533,12 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->aligndesc_4k = _dma_descriptor_align(di); if (di->aligndesc_4k) { di->dmadesc_align = D64RINGALIGN_BITS; - if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) { + if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) /* for smaller dd table, HW relax alignment reqmnt */ di->dmadesc_align = D64RINGALIGN_BITS - 1; - } - } else + } else { di->dmadesc_align = 4; /* 16 byte alignment */ + } DMA_NONE(("DMA descriptor align_needed %d, align %d\n", di->aligndesc_4k, di->dmadesc_align)); @@ -662,10 +662,9 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2)); } if (di->dma.dmactrlflags & DMA_CTRL_PEN) { - if (DMA64_DD_PARITY(&ddring[outidx])) { + if (DMA64_DD_PARITY(&ddring[outidx])) W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2 | D64_CTRL2_PARITY)); - } } } @@ -743,18 +742,17 @@ static bool _dma_isaddrext(struct dma_info *di) /* not all tx or rx channel are available */ if (di->d64txregs != NULL) { - if (!_dma64_addrext(di->d64txregs)) { + if (!_dma64_addrext(di->d64txregs)) DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have " "AE set\n", di->name)); - } return true; } else if (di->d64rxregs != NULL) { - if (!_dma64_addrext(di->d64rxregs)) { + if (!_dma64_addrext(di->d64rxregs)) DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have " "AE set\n", di->name)); - } return true; } + return false; } @@ -1157,16 +1155,15 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) control = R_REG(&di->d64txregs->control); W_REG(&di->d64txregs->control, control | D64_XC_PD); - if (R_REG(&di->d64txregs->control) & D64_XC_PD) { + if (R_REG(&di->d64txregs->control) & D64_XC_PD) /* We *can* disable it so it is supported, * restore control register */ W_REG(&di->d64txregs->control, control); - } else { + else /* Not supported, don't allow it to be enabled */ dmactrlflags &= ~DMA_CTRL_PEN; - } } di->dma.dmactrlflags = dmactrlflags; @@ -1186,9 +1183,8 @@ static u8 dma_align_sizetobits(uint size) { u8 bitpos = 0; - while (size >>= 1) { + while (size >>= 1) bitpos++; - } return bitpos; } @@ -1521,10 +1517,9 @@ dma64_txunframed(struct dma_info *di, void *buf, uint len, bool commit) di->txout = txout; /* kick the chip */ - if (commit) { + if (commit) W_REG(&di->d64txregs->ptr, di->xmtptrbase + I2B(txout, struct dma64desc)); - } /* tx flow control */ di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index d2d2d1b042d..35d9ee86f29 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -217,10 +217,10 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) err = brcms_up(wl); UNLOCK(wl); - if (err != 0) { + if (err != 0) wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, err); - } + return err; } @@ -307,9 +307,9 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) "\n", __func__, conf->power_level * 4, new_int); } - if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { + if (changed & IEEE80211_CONF_CHANGE_CHANNEL) err = ieee_set_channel(hw, conf->channel, conf->channel_type); - } + if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { if (brcms_c_set (wl->wlc, BRCM_SET_SRL, @@ -420,32 +420,36 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, info->bssid); UNLOCK(wl); } - if (changed & BSS_CHANGED_BEACON) { + if (changed & BSS_CHANGED_BEACON) /* Beacon data changed, retrieve new beacon (beaconing modes) */ wiphy_err(wiphy, "%s: beacon changed\n", __func__); - } + if (changed & BSS_CHANGED_BEACON_ENABLED) { /* Beaconing should be enabled/disabled (beaconing modes) */ wiphy_err(wiphy, "%s: Beacon enabled: %s\n", __func__, info->enable_beacon ? "true" : "false"); } + if (changed & BSS_CHANGED_CQM) { /* Connection quality monitor config changed */ wiphy_err(wiphy, "%s: cqm change: threshold %d, hys %d " " (implement)\n", __func__, info->cqm_rssi_thold, info->cqm_rssi_hyst); } + if (changed & BSS_CHANGED_IBSS) { /* IBSS join status changed */ wiphy_err(wiphy, "%s: IBSS joined: %s (implement)\n", __func__, info->ibss_joined ? "true" : "false"); } + if (changed & BSS_CHANGED_ARP_FILTER) { /* Hardware ARP filter address list or state changed */ wiphy_err(wiphy, "%s: arp filtering: enabled %s, count %d" " (implement)\n", __func__, info->arp_filter_enabled ? "true" : "false", info->arp_addr_cnt); } + if (changed & BSS_CHANGED_QOS) { /* * QoS for this association was enabled/disabled. @@ -757,9 +761,8 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, unit = n_adapters_found; err = 0; - if (unit < 0) { + if (unit < 0) return NULL; - } /* allocate private info */ hw = pci_get_drvdata(btparam); /* btparam == pdev */ @@ -816,10 +819,9 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; - if (brcms_c_set_par(wl->wlc, IOV_MPC, 0) < 0) { + if (brcms_c_set_par(wl->wlc, IOV_MPC, 0) < 0) wiphy_err(wl->wiphy, "wl%d: Error setting MPC variable to 0\n", unit); - } /* register our interrupt handler */ if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { @@ -843,19 +845,17 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, SET_IEEE80211_PERM_ADDR(hw, perm); err = ieee80211_register_hw(hw); - if (err) { + if (err) wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status" "%d\n", __func__, err); - } if (wl->pub->srom_ccode[0]) err = brcms_set_hint(wl, wl->pub->srom_ccode); else err = brcms_set_hint(wl, "US"); - if (err) { + if (err) wiphy_err(wl->wiphy, "%s: regulatory_hint failed, status %d\n", __func__, err); - } n_adapters_found++; return wl; @@ -1064,12 +1064,11 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) /* Assume all bands use the same phy. True for 11n devices. */ if (NBANDS_PUB(wl->pub) > 1) { has_5g++; - if (phy_list[0] == 'n' || phy_list[0] == 'c') { + if (phy_list[0] == 'n' || phy_list[0] == 'c') hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &brcms_band_5GHz_nphy; - } else { + else return -EPERM; - } } return 0; } @@ -1337,9 +1336,8 @@ static void brcms_free(struct brcms_info *wl) /* kill dpc */ tasklet_kill(&wl->tasklet); - if (wl->pub) { + if (wl->pub) brcms_c_module_unregister(wl->pub, "linux", wl); - } /* free common resources */ if (wl->wlc) { @@ -1368,9 +1366,9 @@ static void brcms_free(struct brcms_info *wl) * so we cannot unmap the chip registers until after calling unregister_netdev() . */ if (wl->regsva && wl->bcm_bustype != SDIO_BUS && - wl->bcm_bustype != JTAG_BUS) { + wl->bcm_bustype != JTAG_BUS) iounmap((void *)wl->regsva); - } + wl->regsva = NULL; } @@ -1558,10 +1556,9 @@ static void brcms_dpc(unsigned long data) /* re-schedule dpc */ if (wl->resched) tasklet_schedule(&wl->tasklet); - else { + else /* re-enable interrupts */ brcms_intrson(wl); - } done: UNLOCK(wl); @@ -1645,10 +1642,10 @@ void brcms_add_timer(struct brcms_info *wl, struct brcms_timer *t, uint ms, int periodic) { #ifdef BCMDBG - if (t->set) { + if (t->set) wiphy_err(wl->wiphy, "%s: Already set. Name: %s, per %d\n", __func__, t->name, periodic); - } + #endif t->ms = ms; t->periodic = (bool) periodic; @@ -1668,9 +1665,9 @@ bool brcms_del_timer(struct brcms_info *wl, struct brcms_timer *t) { if (t->set) { t->set = false; - if (!del_timer(&t->timer)) { + if (!del_timer(&t->timer)) return false; - } + atomic_dec(&wl->callbacks); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index eb394f5a5f1..5c97778c1db 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -545,19 +545,18 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) /* do band-specific ucode IHR, SHM, and SCR inits */ if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) { + if (BRCMS_ISNPHY(wlc_hw->band)) brcms_c_write_inits(wlc_hw, d11n0bsinitvals16); - } else { + else wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" " %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); - } } else { if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) brcms_c_write_inits(wlc_hw, d11lcn0bsinitvals24); - } else + else wiphy_err(wiphy, "%s: wl%d: unsupported phy in" " core rev %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); @@ -651,9 +650,8 @@ brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, * transmission count) */ if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) { + && (txs->status & TX_STATUS_INTERMEDIATE)) return false; - } return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); } @@ -747,9 +745,8 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) /* BCN template is available */ /* ZZZ: Use AP_ACTIVE ? */ if (AP_ENAB(wlc->pub) && (!APSTA_ENAB(wlc->pub)) - && (macintstatus & MI_BCNTPL)) { + && (macintstatus & MI_BCNTPL)) brcms_c_update_beacon(wlc); - } /* tx status */ if (macintstatus & MI_TFS) { @@ -781,9 +778,8 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) brcms_b_tx_fifo_suspended(wlc_hw, TX_DATA_FIFO); /* noise sample collected */ - if (macintstatus & MI_BG_NOISE) { + if (macintstatus & MI_BG_NOISE) wlc_phy_noise_sample_intr(wlc_hw->band->pi); - } if (macintstatus & MI_GP0) { wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " @@ -797,9 +793,8 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) } /* gptimer timeout */ - if (macintstatus & MI_TO) { + if (macintstatus & MI_TO) W_REG(®s->gptimer, 0); - } if (macintstatus & MI_RFDISABLE) { BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" @@ -1142,9 +1137,8 @@ static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) M_HOST_FLAGS5 }; - for (idx = 0; idx < MHFMAX; idx++) { + for (idx = 0; idx < MHFMAX; idx++) brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); - } } /* set the maccontrol register to desired reset state and @@ -1400,13 +1394,12 @@ static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) struct brcms_c_info *wlc = wlc_hw->wlc; /* update SYNTHPU_DLY */ - if (BRCMS_ISLCNPHY(wlc->band)) { + if (BRCMS_ISLCNPHY(wlc->band)) v = SYNTHPU_DLY_LPPHY_US; - } else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) { + else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) v = SYNTHPU_DLY_NPHY_US; - } else { + else v = SYNTHPU_DLY_BPHY_US; - } brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); } @@ -1540,7 +1533,6 @@ void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) (SICF_PRST | SICF_PCLKE)); phy_in_reset = true; } else { - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE | SICF_BWMASK), (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); @@ -1602,10 +1594,9 @@ void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; /* set gmode core flag */ - if (wlc_hw->sbclk && !wlc_hw->noreset) { + if (wlc_hw->sbclk && !wlc_hw->noreset) ai_core_cflags(wlc_hw->sih, SICF_GMODE, ((bandunit == 0) ? SICF_GMODE : 0)); - } } static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) @@ -1666,10 +1657,9 @@ static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) varname = "il0macaddr"; macaddr = getvar(wlc_hw->vars, varname); - if (macaddr == NULL) { + if (macaddr == NULL) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " "getvar(%s) not found\n", wlc_hw->unit, varname); - } return macaddr; } @@ -1756,18 +1746,16 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) /* reset the dma engines except first time thru */ if (ai_iscoreup(wlc_hw->sih)) { for (i = 0; i < NFIFO; i++) - if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) { + if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " "dma_txreset[%d]: cannot stop dma\n", wlc_hw->unit, __func__, i); - } if ((wlc_hw->di[RX_FIFO]) - && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) { + && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset" "[%d]: cannot stop dma\n", wlc_hw->unit, __func__, RX_FIFO); - } } /* if noreset, just stop the psm and return */ if (wlc_hw->noreset) { @@ -2120,10 +2108,9 @@ void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) fatal = true; } - if (intstatus & I_RU) { + if (intstatus & I_RU) wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor " "underflow\n", idx, unit); - } if (intstatus & I_XU) { wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo " @@ -2246,9 +2233,9 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) null_ether_addr); } else { /* resume tx fifos */ - if (!wlc_hw->wlc->tx_suspended) { + if (!wlc_hw->wlc->tx_suspended) brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); - } + brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); @@ -2367,7 +2354,7 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) W_REG(®s->macintstatus, macintstatus); /* MI_DMAINT is indication of non-zero intstatus */ - if (macintstatus & MI_DMAINT) { + if (macintstatus & MI_DMAINT) /* * only fifo interrupt enabled is I_RI in * RX_FIFO. If MI_DMAINT is set, assume it @@ -2375,7 +2362,6 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) */ W_REG(®s->intctrlregs[RX_FIFO].intstatus, DEF_RXINTMASK); - } return macintstatus; } @@ -2702,10 +2688,9 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) tmp = R_REG(®s->clk_ctl_st); if ((tmp & (CCS_ERSRC_AVAIL_HT)) != - (CCS_ERSRC_AVAIL_HT)) { + (CCS_ERSRC_AVAIL_HT)) wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" " PLL failed\n", __func__); - } } else { OR_REG(®s->clk_ctl_st, (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); @@ -2719,10 +2704,9 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) if ((tmp & (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) != - (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) { + (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on " "PHY PLL failed\n", __func__); - } } } else { /* Since the PLL may be shared, other cores can still be requesting it; @@ -2829,11 +2813,10 @@ brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) W_REG(®s->objaddr, sel | (offset >> 2)); (void)R_REG(®s->objaddr); - if (offset & 2) { + if (offset & 2) v = R_REG(objdata_hi); - } else { + else v = R_REG(objdata_lo); - } return v; } @@ -2848,11 +2831,10 @@ brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, W_REG(®s->objaddr, sel | (offset >> 2)); (void)R_REG(®s->objaddr); - if (offset & 2) { + if (offset & 2) W_REG(objdata_hi, v); - } else { + else W_REG(objdata_lo, v); - } } /* Copy a buffer to shared memory of specified type . @@ -2937,9 +2919,8 @@ void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) mboolset(wlc_hw->pllreq, req_bit); if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (!wlc_hw->sbclk) { + if (!wlc_hw->sbclk) brcms_b_xtal(wlc_hw, ON); - } } } else { if (!mboolisset(wlc_hw->pllreq, req_bit)) @@ -2948,9 +2929,8 @@ void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) mboolclr(wlc_hw->pllreq, req_bit); if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (wlc_hw->sbclk) { + if (wlc_hw->sbclk) brcms_b_xtal(wlc_hw, OFF); - } } } @@ -3111,22 +3091,20 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) " %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { + if (BRCMS_ISLCNPHY(wlc_hw->band)) brcms_c_write_inits(wlc_hw, d11lcn0initvals24); - } else { + else wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" " %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); - } } else { wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); } /* For old ucode, txfifo sizes needs to be modified(increased) */ - if (fifosz_fixup == true) { + if (fifosz_fixup == true) brcms_b_corerev_fifofixup(wlc_hw); - } /* check txfifo allocations match between ucode and driver */ buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); @@ -3161,11 +3139,10 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) i = TX_ATIM_FIFO; err = -1; } - if (err != 0) { + if (err != 0) wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" " driver size %d index %d\n", buf[i], wlc_hw->xmtfifo_sz[i], i); - } /* make sure we can still talk to the mac */ WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); @@ -3409,10 +3386,9 @@ void brcms_c_init(struct brcms_c_info *wlc) /* Uninitialized; read from HW */ int ac; - for (ac = 0; ac < AC_COUNT; ac++) { + for (ac = 0; ac < AC_COUNT; ac++) wlc->wme_retries[ac] = brcms_c_read_shm(wlc, M_AC_TXLMT_ADDR(ac)); - } } } @@ -3487,10 +3463,9 @@ int brcms_c_set_mac(struct brcms_bss_cfg *cfg) int err = 0; struct brcms_c_info *wlc = cfg->wlc; - if (cfg == wlc->cfg) { + if (cfg == wlc->cfg) /* enter the MAC addr into the RXE match registers */ brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, cfg->cur_etheraddr); - } brcms_c_ampdu_macaddr_upd(wlc); @@ -3505,13 +3480,12 @@ void brcms_c_set_bssid(struct brcms_bss_cfg *cfg) struct brcms_c_info *wlc = cfg->wlc; /* if primary config, we need to update BSSID in RXE match registers */ - if (cfg == wlc->cfg) { + if (cfg == wlc->cfg) brcms_c_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID); - } #ifdef SUPPORT_HWKEYS - else if (BSSCFG_STA(cfg) && cfg->BSS) { + else if (BSSCFG_STA(cfg) && cfg->BSS) brcms_c_rcmta_add_bssid(wlc, cfg); - } + #endif } @@ -3741,9 +3715,9 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, } #if NCONF /* pick siso/cdd as default for OFDM (note no basic rate MCSs are supported yet) */ - if (IS_OFDM(lowest_basic_rspec)) { + if (IS_OFDM(lowest_basic_rspec)) lowest_basic_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); - } + #endif return lowest_basic_rspec; @@ -3865,10 +3839,9 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) * to set up a beacon for testing, the test routines should write it down, * not expect the inits to populate a bogus beacon. */ - if (BRCMS_PHY_11N_CAP(wlc->band)) { + if (BRCMS_PHY_11N_CAP(wlc->band)) brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, wlc->band->bcntsfoff); - } } } else { /* disable an active IBSS if we are not on the home channel */ @@ -4403,10 +4376,10 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, /* check device id(srom, nvram etc.) to set bands */ if (wlc_hw->deviceid == BCM43224_D11N_ID || - wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) { + wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) /* Dualband boards */ wlc_hw->_nbands = 2; - } else + else wlc_hw->_nbands = 1; if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) @@ -5070,11 +5043,10 @@ static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) if (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO || wlc->pub->hw_off) return; - if (brcms_b_radio_read_hwdisabled(wlc->hw)) { + if (brcms_b_radio_read_hwdisabled(wlc->hw)) mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - } else { + else mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - } } /* return true if Minimum Power Consumption should be entered, false otherwise */ @@ -5134,9 +5106,9 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) * wlc->mpc_delay_off to wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off */ if ((wlc->prev_non_delay_mpc == false) && - (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) { + (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) wlc->mpc_delay_off = wlc->mpc_dlycnt; - } + wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); } @@ -5146,11 +5118,10 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) */ static void brcms_c_radio_upd(struct brcms_c_info *wlc) { - if (wlc->pub->radio_disabled) { + if (wlc->pub->radio_disabled) brcms_c_radio_disable(wlc); - } else { + else brcms_c_radio_enable(wlc); - } } /* maintain LED behavior in down state */ @@ -5316,12 +5287,10 @@ static void brcms_c_watchdog(void *arg) /* Manage TKIP countermeasures timers */ FOREACH_BSS(wlc, i, cfg) - if (cfg->tk_cm_dt) { + if (cfg->tk_cm_dt) cfg->tk_cm_dt--; - } - if (cfg->tk_cm_bt) { + if (cfg->tk_cm_bt) cfg->tk_cm_bt--; - } END_FOREACH_BSS() /* Call any registered watchdog handlers */ @@ -5453,13 +5422,12 @@ int brcms_c_up(struct brcms_c_info *wlc) if ((wlc->pub->boardflags & BFL_FEM) && (wlc->pub->sih->chip == BCM4313_CHIP_ID)) { if (wlc->pub->boardrev >= 0x1250 - && (wlc->pub->boardflags & BFL_FEM_BT)) { + && (wlc->pub->boardflags & BFL_FEM_BT)) brcms_c_mhf(wlc, MHF5, MHF5_4313_GPIOCTRL, MHF5_4313_GPIOCTRL, BRCM_BAND_ALL); - } else { + else brcms_c_mhf(wlc, MHF4, MHF4_EXTPA_ENABLE, MHF4_EXTPA_ENABLE, BRCM_BAND_ALL); - } } /* @@ -5504,11 +5472,10 @@ int brcms_c_up(struct brcms_c_info *wlc) brcms_c_radio_monitor_stop(wlc); /* Set EDCF hostflags */ - if (EDCF_ENAB(wlc->pub)) { + if (EDCF_ENAB(wlc->pub)) brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); - } else { + else brcms_c_mhf(wlc, MHF1, MHF1_EDCF, 0, BRCM_BAND_ALL); - } if (BRCMS_WAR16165(wlc)) brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR, @@ -5699,9 +5666,8 @@ uint brcms_c_down(struct brcms_c_info *wlc) brcms_c_txflowcontrol_reset(wlc); /* flush tx queues */ - for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { + for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) brcmu_pktq_flush(&qi->q, true, NULL, NULL); - } callbacks += brcms_b_down_finish(wlc->hw); @@ -5813,21 +5779,19 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) band->rspec_override = 0; brcms_c_reprate_init(wlc); } - if (band->mrspec_override && !IS_CCK(band->mrspec_override)) { + if (band->mrspec_override && !IS_CCK(band->mrspec_override)) band->mrspec_override = 0; - } } band->gmode = gmode; wlc->shortslot_override = shortslot; - if (AP_ENAB(wlc->pub)) { + if (AP_ENAB(wlc->pub)) /* wlc->ap->shortslot_restrict = shortslot_restrict; */ wlc->PLCPHdr_override = (preamble != BRCMS_PLCP_LONG) ? BRCMS_PLCP_SHORT : BRCMS_PLCP_AUTO; - } if ((AP_ENAB(wlc->pub) && preamble != BRCMS_PLCP_LONG) || preamble == BRCMS_PLCP_SHORT) @@ -6115,9 +6079,9 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - for (ac = 0; ac < AC_COUNT; ac++) { + for (ac = 0; ac < AC_COUNT; ac++) BRCMS_WME_RETRY_SHORT_SET(wlc, ac, wlc->SRL); - } + brcms_c_wme_retries_write(wlc); } else bcmerror = -EINVAL; @@ -6130,9 +6094,9 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - for (ac = 0; ac < AC_COUNT; ac++) { + for (ac = 0; ac < AC_COUNT; ac++) BRCMS_WME_RETRY_LONG_SET(wlc, ac, wlc->LRL); - } + brcms_c_wme_retries_write(wlc); } else bcmerror = -EINVAL; @@ -6250,13 +6214,12 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, } else { /* driver is down, so just update the brcms_c_info * value */ - if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) { + if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) wlc->shortslot = false; - } else { + else wlc->shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); - } } break; @@ -6326,10 +6289,9 @@ static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) if (!wlc->clk) return; - for (ac = 0; ac < AC_COUNT; ac++) { + for (ac = 0; ac < AC_COUNT; ac++) brcms_c_write_shm(wlc, M_AC_TXLMT_ADDR(ac), wlc->wme_retries[ac]); - } } #ifdef BCMDBG @@ -6431,9 +6393,8 @@ void brcms_c_statsupd(struct brcms_c_info *wlc) /* merge counters from dma module */ for (i = 0; i < NFIFO; i++) { - if (wlc->hw->di[i]) { + if (wlc->hw->di[i]) dma_counterreset(wlc->hw->di[i]); - } } } @@ -6705,14 +6666,12 @@ void brcms_c_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, */ if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { - if (pktq_len(q) >= wlc->pub->tunables->datahiwat) { + if (pktq_len(q) >= wlc->pub->tunables->datahiwat) brcms_c_txflowcontrol(wlc, qi, ON, ALLPRIO); - } } else if (wlc->pub->_priofc) { if (pktq_plen(q, wlc_prio2prec_map[prio]) >= - wlc->pub->tunables->datahiwat) { + wlc->pub->tunables->datahiwat) brcms_c_txflowcontrol(wlc, qi, ON, prio); - } } } @@ -6769,10 +6728,9 @@ void brcms_c_send_q(struct brcms_c_info *wlc) count = 1; err = brcms_c_prep_pdu(wlc, pkt[0], &fifo); if (!err) { - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) brcms_c_txfifo(wlc, fifo, pkt[i], true, 1); - } } } @@ -6791,17 +6749,15 @@ void brcms_c_send_q(struct brcms_c_info *wlc) if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) - && (pktq_len(q) < wlc->pub->tunables->datahiwat / 2)) { + && (pktq_len(q) < wlc->pub->tunables->datahiwat / 2)) brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); - } } else if (wlc->pub->_priofc) { int prio; for (prio = MAXPRIO; prio >= 0; prio--) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && (pktq_plen(q, wlc_prio2prec_map[prio]) < - wlc->pub->tunables->datahiwat / 2)) { + wlc->pub->tunables->datahiwat / 2)) brcms_c_txflowcontrol(wlc, qi, OFF, prio); - } } } in_send_q = false; @@ -6840,11 +6796,9 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, /* When a BC/MC frame is being committed to the BCMC fifo via DMA (NOT PIO), update * ucode or BSS info as appropriate. */ - if (fifo == TX_BCMC_FIFO) { + if (fifo == TX_BCMC_FIFO) frameid = le16_to_cpu(txh->TxFrameID); - } - if (BRCMS_WAR16165(wlc)) brcms_c_war16165(wlc, true); @@ -6862,22 +6816,20 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, if (frameid != INVALIDFID) BCMCFID(wlc, frameid); - if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) { + if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); - } } void brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, uint length, u8 *plcp) { - if (IS_MCS(rspec)) { + if (IS_MCS(rspec)) brcms_c_compute_mimo_plcp(rspec, length, plcp); - } else if (IS_OFDM(rspec)) { + else if (IS_OFDM(rspec)) brcms_c_compute_ofdm_plcp(rspec, length, plcp); - } else { + else brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); - } return; } @@ -7032,12 +6984,14 @@ brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, sifs = SIFS(wlc->band); - if (!cts_only) { /* RTS/CTS */ + if (!cts_only) { + /* RTS/CTS */ dur = 3 * sifs; dur += (u16) brcms_c_calc_cts_time(wlc, rts_rate, rts_preamble_type); - } else { /* CTS-TO-SELF */ + } else { + /* CTS-TO-SELF */ dur = 2 * sifs; } @@ -7108,11 +7062,10 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, { u32 rts_rspec = 0; - if (use_rspec) { + if (use_rspec) /* use frame rate as rts rate */ rts_rspec = rspec; - - } else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) { + else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) /* Use 11Mbps as the g protection RTS target rate and fallback. * Use the BRCMS_BASIC_RATE() lookup to find the best basic rate * under the target in case 11 Mbps is not Basic. @@ -7120,13 +7073,12 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, * if the OFDM rate we are protecting is 6 or 9 Mbps, 11 is more robust. */ rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); - } else { + else /* calculate RTS rate and fallback rate based on the frame rate * RTS must be sent at a basic rate since it is a * control frame, sec 9.6 of 802.11 spec */ rts_rspec = BRCMS_BASIC_RATE(wlc, rspec); - } if (BRCMS_PHY_11N_CAP(wlc->band)) { /* set rts txbw to correct side band */ @@ -7210,9 +7162,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * the packet itself, thus phylen = packet length + ICV_LEN + FCS_LEN * in this case */ - if (key) { + if (key) phylen += key->icv_len; - } /* Get tx_info */ tx_info = IEEE80211_SKB_CB(p); @@ -7233,9 +7184,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, frameid = bcmc_fid_generate(wlc, NULL, txh); } else { /* Increment the counter for first fragment */ - if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) { + if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) SCB_SEQNUM(scb, p->priority)++; - } /* extract fragment number from frame first */ seq = le16_to_cpu(seq) & FRAGNUM_MASK; @@ -7256,9 +7206,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, txrate[1] = txrate[0] + 1; /* if rate control algorithm didn't give us a fallback rate, use the primary rate */ - if (txrate[1]->idx < 0) { + if (txrate[1]->idx < 0) txrate[1] = txrate[0]; - } for (k = 0; k < hw->max_rates; k++) { is_mcs[k] = @@ -7280,6 +7229,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } else { rate_val[k] = txrate[k]->idx; } + /* Currently only support same setting for primay and fallback rates. * Unify flags for each rate into a single value for the frame */ @@ -7355,18 +7305,17 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } else if (IS_OFDM(rspec[k])) { if (wlc->ofdm_40txbw != AUTO) mimo_txbw = wlc->ofdm_40txbw; - } else { - if (wlc->cck_40txbw != AUTO) - mimo_txbw = wlc->cck_40txbw; + } else if (wlc->cck_40txbw != AUTO) { + mimo_txbw = wlc->cck_40txbw; } } else { /* mcs32 is 40 b/w only. * This is possible for probe packets on a STA during SCAN */ - if ((rspec[k] & RSPEC_RATE_MASK) == 32) { + if ((rspec[k] & RSPEC_RATE_MASK) == 32) /* mcs 0 */ rspec[k] = RSPEC_MIMORATE; - } + mimo_txbw = PHY_TXC1_BW_20MHZ; } @@ -7405,9 +7354,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* if SGI is selected, then forced mm for single stream */ if ((rspec[k] & RSPEC_SHORT_GI) && IS_SINGLE_STREAM(rspec[k] & - RSPEC_RATE_MASK)) { + RSPEC_RATE_MASK)) preamble_type[k] = BRCMS_MM_PREAMBLE; - } } /* should be better conditionalized */ @@ -7635,10 +7583,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, #ifdef SUPPORT_40MHZ /* add null delimiter count */ - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && IS_MCS(rspec)) { + if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && IS_MCS(rspec)) txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); - } + #endif /* Now that RTS/RTS FB preamble types are updated, write the final value */ @@ -7751,34 +7699,32 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* update txop byte threshold (txop minus intraframe overhead) */ if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { - { - uint newfragthresh; + uint newfragthresh; + newfragthresh = + brcms_c_calc_frame_len(wlc, + rspec[0], preamble_type[0], + (wlc->edcf_txop[ac] - + (dur - frag_dur))); + /* range bound the fragthreshold */ + if (newfragthresh < DOT11_MIN_FRAG_LEN) newfragthresh = - brcms_c_calc_frame_len(wlc, - rspec[0], preamble_type[0], - (wlc->edcf_txop[ac] - - (dur - frag_dur))); - /* range bound the fragthreshold */ - if (newfragthresh < DOT11_MIN_FRAG_LEN) - newfragthresh = - DOT11_MIN_FRAG_LEN; - else if (newfragthresh > - wlc->usr_fragthresh) - newfragthresh = - wlc->usr_fragthresh; - /* update the fragthresh and do txc update */ - if (wlc->fragthresh[queue] != - (u16) newfragthresh) { - wlc->fragthresh[queue] = - (u16) newfragthresh; - } - } - } else + DOT11_MIN_FRAG_LEN; + else if (newfragthresh > + wlc->usr_fragthresh) + newfragthresh = + wlc->usr_fragthresh; + /* update the fragthresh and do txc update */ + if (wlc->fragthresh[queue] != + (u16) newfragthresh) + wlc->fragthresh[queue] = + (u16) newfragthresh; + } else { wiphy_err(wlc->wiphy, "wl%d: %s txop invalid " "for rate %d\n", wlc->pub->unit, fifo_names[queue], RSPEC2RATE(rspec[0])); + } if (dur > wlc->edcf_txop[ac]) wiphy_err(wlc->wiphy, "wl%d: %s: %s txop " @@ -7797,10 +7743,9 @@ void brcms_c_tbtt(struct brcms_c_info *wlc) { struct brcms_bss_cfg *cfg = wlc->cfg; - if (!cfg->BSS) { + if (!cfg->BSS) /* DirFrmQ is now valid...defer setting until end of ATIM window */ wlc->qvalid |= MCMD_DIRFRMQVAL; - } } static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) @@ -7991,9 +7936,8 @@ brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) /* Clear MHF2_TXBCMC_NOW flag if BCMC fifo has drained */ if (AP_ENAB(wlc->pub) && - !TXPKTPENDGET(wlc, TX_BCMC_FIFO)) { + !TXPKTPENDGET(wlc, TX_BCMC_FIFO)) brcms_c_mhf(wlc, MHF2, MHF2_TXBCMC_NOW, 0, BRCM_BAND_AUTO); - } /* figure out which bsscfg is being worked on... */ } @@ -8252,9 +8196,8 @@ void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) } /* check received pkt has at least frame control field */ - if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) { + if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) goto toss; - } is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; @@ -8659,12 +8602,11 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc) * which a response ACK/CTS should be sent. */ basic_rate = BRCMS_BASIC_RATE(wlc, rate); - if (basic_rate == 0) { + if (basic_rate == 0) /* This should only happen if we are using a * restricted rateset. */ basic_rate = rs.rates[0] & BRCMS_RATE_MASK; - } brcms_c_write_rate_shm(wlc, rate, basic_rate); } @@ -8680,14 +8622,13 @@ bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, struct brcms_c_rateset *hw_rateset; uint i; - if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) { + if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) hw_rateset = &wlc->band->hw_rateset; - } else if (NBANDS(wlc) > 1) { + else if (NBANDS(wlc) > 1) hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; - } else { + else /* other band specified and we are a single band device */ return false; - } /* check if this is a mimo rate */ if (IS_MCS(rspec)) { @@ -8701,10 +8642,9 @@ bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, if (hw_rateset->rates[i] == RSPEC2RATE(rspec)) return true; error: - if (verbose) { + if (verbose) wiphy_err(wlc->wiphy, "wl%d: valid_rate: rate spec 0x%x " "not in hw_rateset\n", wlc->pub->unit, rspec); - } return false; } @@ -8809,13 +8749,12 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, plcp = (struct cck_phy_hdr *) buf; /* PLCP for Probe Response frames are filled in from core's rate table */ - if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) { + if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) /* fill in PLCP */ brcms_c_compute_plcp(wlc, bcn_rspec, (DOT11_MAC_HDR_LEN + body_len + FCS_LEN), (u8 *) plcp); - } /* "Regular" and 16 MBSS but not for 4 MBSS */ /* Update the phytxctl for the beacon based on the rspec */ if (!SOFTBCN_ENAB(cfg)) @@ -8880,9 +8819,9 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, /* Clear the soft intmask */ wlc->defmacintmask &= ~MI_BCNTPL; - if (!cfg->up) { /* Only allow updates on an UP bss */ + if (!cfg->up) + /* Only allow updates on an UP bss */ return; - } /* Optimize: Some of if/else could be combined */ if (!MBSS_BCN_ENAB(cfg) && HWBCN_ENAB(cfg)) { @@ -8894,10 +8833,10 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, /* Check if both templates are in use, if so sched. an interrupt * that will call back into this routine */ - if ((R_REG(®s->maccommand) & both_valid) == both_valid) { + if ((R_REG(®s->maccommand) & both_valid) == both_valid) /* clear any previous status */ W_REG(®s->macintstatus, MI_BCNTPL); - } + /* Check that after scheduling the interrupt both of the * templates are still busy. if not clear the int. & remask */ @@ -9103,9 +9042,8 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, == NRATE_OVERRIDE_MCS_ONLY); int bcmerror = 0; - if (!ismcs) { + if (!ismcs) return (u32) rate; - } /* validate the combination of rate/mcs/stf is allowed */ if (N_ENAB(wlc->pub) && ismcs) { @@ -9196,9 +9134,8 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, rspec |= RSPEC_SHORT_GI; if ((rate != 0) - && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) { + && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) return rate; - } return rspec; done: @@ -9329,11 +9266,10 @@ brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc, { uint prio_mask; - if (prio == ALLPRIO) { + if (prio == ALLPRIO) prio_mask = TXQ_STOP_FOR_PRIOFC_MASK; - } else { + else prio_mask = NBITVAL(prio); - } return (q->stopped & prio_mask) == prio_mask; } @@ -9348,11 +9284,10 @@ void brcms_c_txflowcontrol(struct brcms_c_info *wlc, BCMMSG(wlc->wiphy, "flow control kicks in\n"); - if (prio == ALLPRIO) { + if (prio == ALLPRIO) prio_bits = TXQ_STOP_FOR_PRIOFC_MASK; - } else { + else prio_bits = NBITVAL(prio); - } cur_bits = qi->stopped & prio_bits; @@ -9360,23 +9295,22 @@ void brcms_c_txflowcontrol(struct brcms_c_info *wlc, * Otherwise update the bit and continue */ if (on) { - if (cur_bits == prio_bits) { + if (cur_bits == prio_bits) return; - } + mboolset(qi->stopped, prio_bits); } else { - if (cur_bits == 0) { + if (cur_bits == 0) return; - } + mboolclr(qi->stopped, prio_bits); } /* If there is a flow control override we will not change the external * flow control state. */ - if (qi->stopped & ~TXQ_STOP_FOR_PRIOFC_MASK) { + if (qi->stopped & ~TXQ_STOP_FOR_PRIOFC_MASK) return; - } brcms_c_txflowcontrol_signal(wlc, qi, on, prio); } @@ -9398,9 +9332,8 @@ brcms_c_txflowcontrol_override(struct brcms_c_info *wlc, /* if there was a previous override bit on, then setting this * makes no difference. */ - if (prev_override) { + if (prev_override) return; - } brcms_c_txflowcontrol_signal(wlc, qi, ON, ALLPRIO); } else { @@ -9409,9 +9342,8 @@ brcms_c_txflowcontrol_override(struct brcms_c_info *wlc, * flow control if it was the only bit set. For any other * override setting, just return */ - if (prev_override != override) { + if (prev_override != override) return; - } if (qi->stopped == 0) { brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO); @@ -9555,9 +9487,8 @@ void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) /* wait for queue and DMA fifos to run dry */ while (!pktq_empty(&wlc->pkt_queue->q) || - TXPKTPENDTOT(wlc) > 0) { + TXPKTPENDTOT(wlc) > 0) brcms_msleep(wlc->wl, 1); - } } int brcms_c_set_par(struct brcms_c_info *wlc, enum wlc_par_id par_id, diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 6d6e7d3f530..ab675460d5e 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -399,6 +399,7 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) while (i < pcie_serdes_spinwait) { if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) break; + udelay(1000); i++; } @@ -823,6 +824,7 @@ void pcicore_fixcfg(void *pch, void *regs) reg16 = &pcieregs->sprom[SRSH_PI_OFFSET]; else if (sii->pub.buscoretype == PCI_CORE_ID) reg16 = &pciregs->sprom[SRSH_PI_OFFSET]; + pciidx = ai_coreidx(&sii->pub); val16 = R_REG(reg16); if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index d09424db054..03f9856646c 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -184,12 +184,12 @@ static u16 ipxotp_read_bit(void *oh, struct chipcregs *cc, uint off) ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) && (k < OTPP_TRIES); k++) ; - if (k >= OTPP_TRIES) { + if (k >= OTPP_TRIES) return 0xffff; - } - if (st & OTPP_READERR) { + + if (st & OTPP_READERR) return 0xffff; - } + st = (st & OTPP_VALUE_MASK) >> OTPP_VALUE_SHIFT; return (int)st; @@ -245,9 +245,8 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) && (k < OTPP_TRIES); k++) ; - if (k >= OTPP_TRIES) { + if (k >= OTPP_TRIES) return; - } /* Read OTP lock bits and subregion programmed indication bits */ oi->status = R_REG(&cc->otpstatus); @@ -493,9 +492,8 @@ void *otp_init(struct si_pub *sih) if (OTPTYPE_IPX(oi->ccrev)) oi->fn = &ipxotp_fn; - if (oi->fn == NULL) { + if (oi->fn == NULL) return NULL; - } oi->sih = sih; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index c6c52870dfe..2636114227e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -466,9 +466,8 @@ static void wlc_set_phy_uninitted(struct brcms_phy *pi) } pi->radiopwr = 0xffff; for (i = 0; i < STATIC_NUM_RF; i++) { - for (j = 0; j < STATIC_NUM_BB; j++) { + for (j = 0; j < STATIC_NUM_BB; j++) pi->stats_11b_txpower[i][j] = -1; - } } } @@ -477,9 +476,8 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) struct shared_phy *sh; sh = kzalloc(sizeof(struct shared_phy), GFP_ATOMIC); - if (sh == NULL) { + if (sh == NULL) return NULL; - } sh->sih = shp->sih; sh->physhim = shp->physhim; @@ -525,23 +523,20 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, sflags = ai_core_sflags(sh->sih, 0, 0); if (BAND_5G(bandtype)) { - if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) { + if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) return NULL; - } } pi = sh->phy_head; if ((sflags & SISF_DB_PHY) && pi) { - wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); pi->refcnt++; return &pi->pubpi_ro; } pi = kzalloc(sizeof(struct brcms_phy), GFP_ATOMIC); - if (pi == NULL) { + if (pi == NULL) return NULL; - } pi->wiphy = wiphy; pi->regs = (struct d11regs *) regs; pi->sh = sh; @@ -556,10 +551,8 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, pi->phycal_tempdelta = 0; - if (BAND_2G(bandtype) && (sflags & SISF_2G_PHY)) { - + if (BAND_2G(bandtype) && (sflags & SISF_2G_PHY)) pi->pubpi.coreflags = SICF_GMODE; - } wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); phyversion = R_REG(&pi->regs->phyversion); @@ -574,17 +567,14 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, pi->pubpi.phy_corenum = PHY_CORE_NUM_2; pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; - if (!VALID_PHYTYPE(pi->pubpi.phy_type)) { + if (!VALID_PHYTYPE(pi->pubpi.phy_type)) goto err; - } + if (BAND_5G(bandtype)) { - if (!ISNPHY(pi)) { + if (!ISNPHY(pi)) goto err; - } - } else { - if (!ISNPHY(pi) && !ISLCNPHY(pi)) { - goto err; - } + } else if (!ISNPHY(pi) && !ISLCNPHY(pi)) { + goto err; } wlc_phy_anacore((struct brcms_phy_pub *) pi, ON); @@ -652,9 +642,8 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, pi->phycal_timer = wlapi_init_timer(pi->sh->physhim, wlc_phy_timercb_phycal, pi, "phycal"); - if (!pi->phycal_timer) { + if (!pi->phycal_timer) goto err; - } if (!wlc_phy_attach_nphy(pi)) goto err; @@ -663,8 +652,6 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, if (!wlc_phy_attach_lcnphy(pi)) goto err; - } else { - } pi->refcnt++; @@ -687,9 +674,8 @@ void wlc_phy_detach(struct brcms_phy_pub *pih) struct brcms_phy *pi = (struct brcms_phy *) pih; if (pih) { - if (--pi->refcnt) { + if (--pi->refcnt) return; - } if (pi->phycal_timer) { wlapi_free_timer(pi->sh->physhim, pi->phycal_timer); @@ -881,9 +867,8 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) if (WARN(mc & MCTL_EN_MAC, "HW error MAC running on init")) return; - if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) { + if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - } if (WARN(!(ai_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA), "HW error SISF_FCLKA\n")) @@ -891,9 +876,8 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) phy_init = pi->pi_fptr.init; - if (phy_init == NULL) { + if (phy_init == NULL) return; - } wlc_phy_anacore(pih, ON); @@ -992,11 +976,9 @@ void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val) } if (width == 32) { - write_phy_reg(pi, pi->tbl_data_hi, (u16) (val >> 16)); write_phy_reg(pi, pi->tbl_data_lo, (u16) val); } else { - write_phy_reg(pi, pi->tbl_data_lo, (u16) val); } } @@ -1027,15 +1009,12 @@ wlc_phy_write_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, } if (tbl_width == 32) { - write_phy_reg(pi, tblDataHi, (u16) (ptbl_32b[idx] >> 16)); write_phy_reg(pi, tblDataLo, (u16) ptbl_32b[idx]); } else if (tbl_width == 16) { - write_phy_reg(pi, tblDataLo, ptbl_16b[idx]); } else { - write_phy_reg(pi, tblDataLo, ptbl_8b[idx]); } } @@ -1066,14 +1045,11 @@ wlc_phy_read_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, } if (tbl_width == 32) { - ptbl_32b[idx] = read_phy_reg(pi, tblDataLo); ptbl_32b[idx] |= (read_phy_reg(pi, tblDataHi) << 16); } else if (tbl_width == 16) { - ptbl_16b[idx] = read_phy_reg(pi, tblDataLo); } else { - ptbl_8b[idx] = (u8) read_phy_reg(pi, tblDataLo); } } @@ -1086,10 +1062,9 @@ wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, uint i = 0; do { - if (radioregs[i].do_init) { + if (radioregs[i].do_init) write_radio_reg(pi, radioregs[i].address, (u16) radioregs[i].init); - } i++; } while (radioregs[i].address != 0xffff); @@ -1158,9 +1133,8 @@ void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) W_REG(®s->wepctl, 0); W_REG(®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); - if (ISNPHY(pi) || ISLCNPHY(pi)) { + if (ISNPHY(pi) || ISLCNPHY(pi)) W_REG(®s->txe_phyctl1, 0x1A02); - } W_REG(®s->txe_wm_0, 0); W_REG(®s->txe_wm_1, 0); @@ -1187,16 +1161,14 @@ void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) i = 0; count = ofdm ? 30 : 250; while ((i++ < count) - && (R_REG(®s->txe_status) & (1 << 7))) { + && (R_REG(®s->txe_status) & (1 << 7))) udelay(10); - } i = 0; while ((i++ < 10) - && ((R_REG(®s->txe_status) & (1 << 10)) == 0)) { + && ((R_REG(®s->txe_status) & (1 << 10)) == 0)) udelay(10); - } i = 0; @@ -1213,11 +1185,10 @@ void wlc_phy_hold_upd(struct brcms_phy_pub *pih, u32 id, bool set) { struct brcms_phy *pi = (struct brcms_phy *) pih; - if (set) { + if (set) mboolset(pi->measure_hold, id); - } else { + else mboolclr(pi->measure_hold, id); - } return; } @@ -1226,11 +1197,10 @@ void wlc_phy_mute_upd(struct brcms_phy_pub *pih, bool mute, u32 flags) { struct brcms_phy *pi = (struct brcms_phy *) pih; - if (mute) { + if (mute) mboolset(pi->measure_hold, PHY_HOLD_FOR_MUTE); - } else { + else mboolclr(pi->measure_hold, PHY_HOLD_FOR_MUTE); - } if (!mute && (flags & PHY_MUTE_FOR_PREISM)) pi->nphy_perical_last = pi->sh->now - pi->sh->glacial_timer; @@ -1271,7 +1241,6 @@ void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on) if (ISNPHY(pi)) { wlc_phy_switch_radio_nphy(pi, on); - } else if (ISLCNPHY(pi)) { if (on) { and_phy_reg(pi, 0x44c, @@ -1367,11 +1336,10 @@ int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, u16 chanspec) uint channel = CHSPEC_CHANNEL(chanspec); uint freq = wlc_phy_channel2freq(channel); - if (ISNPHY(pi)) { + if (ISNPHY(pi)) range = wlc_phy_get_chan_freq_range_nphy(pi, channel); - } else if (ISLCNPHY(pi)) { + else if (ISLCNPHY(pi)) range = wlc_phy_chanspec_freq2bandrange_lpssn(freq); - } return range; } @@ -1585,9 +1553,8 @@ wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint channel, u8 *min_pwr, txp_rate_idx = TXP_FIRST_OFDM; for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { - if (channel == chan_info_all[i].chan) { + if (channel == chan_info_all[i].chan) break; - } } if (pi->hwtxpwr) { @@ -1720,11 +1687,10 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) tx_pwr_target[rate] = pi->tx_user_target[rate]; - if (pi->user_txpwr_at_rfport) { + if (pi->user_txpwr_at_rfport) tx_pwr_target[rate] += wlc_user_txpwr_antport_to_rfport(pi, target_chan, band, rate); - } { @@ -1765,13 +1731,12 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) pi->tx_power_target[rate] = tx_pwr_target[rate]; - if (!pi->hwpwrctrl || ISNPHY(pi)) { + if (!pi->hwpwrctrl || ISNPHY(pi)) pi->tx_power_offset[rate] = pi->tx_power_max - pi->tx_power_target[rate]; - } else { + else pi->tx_power_offset[rate] = pi->tx_power_target[rate] - pi->tx_power_min; - } } txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc; @@ -2017,9 +1982,8 @@ void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt) void wlc_phy_txpower_update_shm(struct brcms_phy *pi) { int j; - if (ISNPHY(pi)) { + if (ISNPHY(pi)) return; - } if (!pi->sh->clk) return; @@ -2069,22 +2033,19 @@ bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi) { struct brcms_phy *pi = (struct brcms_phy *) ppi; - if (ISNPHY(pi)) { + if (ISNPHY(pi)) return pi->nphy_txpwrctrl; - } else { + else return pi->hwpwrctrl; - } } void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl) { struct brcms_phy *pi = (struct brcms_phy *) ppi; - bool cur_hwpwrctrl = pi->hwpwrctrl; bool suspend; - if (!pi->hwpwrctrl_capable) { + if (!pi->hwpwrctrl_capable) return; - } pi->hwpwrctrl = hwpwrctrl; pi->nphy_txpwrctrl = hwpwrctrl; @@ -2098,19 +2059,14 @@ void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); - if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) { + if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) wlc_phy_txpwr_fixpower_nphy(pi); - } else { - + else mod_phy_reg(pi, 0x1e7, (0x7f << 0), pi->saved_txpwr_idx); - } if (!suspend) wlapi_enable_mac(pi->sh->physhim); - } else if (hwpwrctrl != cur_hwpwrctrl) { - - return; } } @@ -2126,8 +2082,6 @@ void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi) } } -static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi); - static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) { s16 tx0_status, tx1_status; @@ -2139,38 +2093,34 @@ static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) estPower2 = read_phy_reg(pi, 0x119); if ((estPower1 & (0x1 << 8)) - == (0x1 << 8)) { + == (0x1 << 8)) pwr0 = (u8) (estPower1 & (0xff << 0)) >> 0; - } else { + else pwr0 = 0x80; - } if ((estPower2 & (0x1 << 8)) - == (0x1 << 8)) { + == (0x1 << 8)) pwr1 = (u8) (estPower2 & (0xff << 0)) >> 0; - } else { + else pwr1 = 0x80; - } tx0_status = read_phy_reg(pi, 0x1ed); tx1_status = read_phy_reg(pi, 0x1ee); if ((tx0_status & (0x1 << 15)) - == (0x1 << 15)) { + == (0x1 << 15)) adj_pwr0 = (u8) (tx0_status & (0xff << 0)) >> 0; - } else { + else adj_pwr0 = 0x80; - } if ((tx1_status & (0x1 << 15)) - == (0x1 << 15)) { + == (0x1 << 15)) adj_pwr1 = (u8) (tx1_status & (0xff << 0)) >> 0; - } else { + else adj_pwr1 = 0x80; - } est_pwr = (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) | adj_pwr1); @@ -2305,10 +2255,8 @@ void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val) BRCM_BAND_ALL); } - if (ISNPHY(pi)) { - + if (ISNPHY(pi)) return; - } if (!pi->sh->clk) return; @@ -2370,20 +2318,16 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) bool sampling_in_progress = (pi->phynoise_state != 0); bool wait_for_intr = true; - if (NORADIO_ENAB(pi->pubpi)) { + if (NORADIO_ENAB(pi->pubpi)) return; - } switch (reason) { case PHY_NOISE_SAMPLE_MON: - pi->phynoise_chan_watchdog = ch; pi->phynoise_state |= PHY_NOISE_STATE_MON; - break; case PHY_NOISE_SAMPLE_EXTERNAL: - pi->phynoise_state |= PHY_NOISE_STATE_EXTERNAL; break; @@ -2407,7 +2351,6 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; } else { - noise_dbm = PHY_NOISE_FIXED_VAL; } @@ -2521,9 +2464,8 @@ static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) pi->phynoise_state &= ~PHY_NOISE_STATE_MON; } - if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) { + if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; - } } @@ -2545,9 +2487,9 @@ static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) M_PWRIND_MAP(idx + 1)); cmplx_pwr[core] = (hi << 16) + lo; cmplx_pwr_tot += cmplx_pwr[core]; - if (cmplx_pwr[core] == 0) { + if (cmplx_pwr[core] == 0) noise_dbm_ant[core] = PHY_NOISE_FIXED_VAL_NPHY; - } else + else cmplx_pwr[core] >>= PHY_NOISE_SAMPLE_LOG_NUM_UCODE; } @@ -2716,7 +2658,6 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx) } if (ISLCNPHY(pi)) { - if (rssi > 127) rssi -= 256; } else if (radioid == BCM2055_ID || radioid == BCM2056_ID @@ -2758,23 +2699,20 @@ void wlc_phy_watchdog(struct brcms_phy_pub *pih) if (!pi->watchdog_override) return; - if (!(SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi))) { + if (!(SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi))) wlc_phy_noise_sample_request((struct brcms_phy_pub *) pi, PHY_NOISE_SAMPLE_MON, CHSPEC_CHANNEL(pi-> radio_chanspec)); - } - if (pi->phynoise_state && (pi->sh->now - pi->phynoise_now) > 5) { + if (pi->phynoise_state && (pi->sh->now - pi->phynoise_now) > 5) pi->phynoise_state = 0; - } if ((!pi->phycal_txpower) || ((pi->sh->now - pi->phycal_txpower) >= pi->sh->fast_timer)) { - if (!SCAN_INPROG_PHY(pi) && wlc_phy_cal_txpower_recalc_sw(pi)) { + if (!SCAN_INPROG_PHY(pi) && wlc_phy_cal_txpower_recalc_sw(pi)) pi->phycal_txpower = pi->sh->now; - } } if (NORADIO_ENAB(pi->pubpi)) @@ -2820,9 +2758,8 @@ void wlc_phy_BSSinit(struct brcms_phy_pub *pih, bool bonlyap, int rssi) uint i; uint k; - for (i = 0; i < MA_WINDOW_SZ; i++) { + for (i = 0; i < MA_WINDOW_SZ; i++) pi->sh->phy_noise_window[i] = (s8) (rssi & 0xff); - } if (ISLCNPHY(pi)) { for (i = 0; i < MA_WINDOW_SZ; i++) pi->sh->phy_noise_window[i] = @@ -2955,9 +2892,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) case PHY_PERICAL_PHYINIT: if (pi->nphy_perical == PHY_PERICAL_MPHASE) { - if (PHY_PERICAL_MPHASE_PENDING(pi)) { + if (PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_reset(pi); - } + wlc_phy_cal_perical_mphase_schedule(pi, PHY_PERICAL_INIT_DELAY); } @@ -2967,17 +2904,16 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) case PHY_PERICAL_START_IBSS: case PHY_PERICAL_UP_BSS: if ((pi->nphy_perical == PHY_PERICAL_MPHASE) && - PHY_PERICAL_MPHASE_PENDING(pi)) { + PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_reset(pi); - } pi->first_cal_after_assoc = true; pi->cal_type_override = PHY_PERICAL_FULL; - if (pi->phycal_tempdelta) { + if (pi->phycal_tempdelta) pi->nphy_lastcal_temp = wlc_phy_tempsense_nphy(pi); - } + wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_FULL); break; @@ -2991,17 +2927,14 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) if ((delta_temp < (s16) pi->phycal_tempdelta) && (pi->nphy_txiqlocal_chanspec == - pi->radio_chanspec)) { + pi->radio_chanspec)) do_periodic_cal = false; - } else { + else pi->nphy_lastcal_temp = nphy_currtemp; - } } if (do_periodic_cal) { - if (pi->nphy_perical == PHY_PERICAL_MPHASE) { - if (!PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_schedule(pi, PHY_PERICAL_WDOG_DELAY); @@ -3050,9 +2983,9 @@ void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) pi->sh->phytxchain = txchain; - if (ISNPHY(pi)) { + if (ISNPHY(pi)) wlc_phy_rxcore_setstate_nphy(pih, rxchain); - } + pi->pubpi.phy_corenum = (u8) PHY_BITSCNT(pi->sh->phyrxchain); } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 1276084b4e9..e580420d203 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -246,7 +246,7 @@ enum phy_cal_mode { #define MOD_PHY_REG(pi, phy_type, reg_name, field, value) \ mod_phy_reg(pi, phy_type##_##reg_name, phy_type##_##reg_name##_##field##_MASK, \ - (value) << phy_type##_##reg_name##_##field##_##SHIFT); + (value) << phy_type##_##reg_name##_##field##_##SHIFT) #define READ_PHY_REG(pi, phy_type, reg_name, field) \ ((read_phy_reg(pi, phy_type##_##reg_name) & phy_type##_##reg_name##_##field##_##MASK)\ >> phy_type##_##reg_name##_##field##_##SHIFT) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index c232f501610..d64a98fd4f9 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -1092,12 +1092,12 @@ static int wlc_lcnphy_calc_floor(s16 coeff_x, int type) int k; k = 0; if (type == 0) { - if (coeff_x < 0) { + if (coeff_x < 0) k = (coeff_x - 1) / 2; - } else { + else k = coeff_x / 2; - } } + if (type == 1) { if ((coeff_x + 1) < 0) k = (coeff_x) / 2; @@ -1531,10 +1531,9 @@ static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) mod_radio_reg(pi, RADIO_2064_REG005, 0x8, 1 << 3); - if (!wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { + if (!wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) mod_phy_reg(pi, 0x4d7, (0x1 << 3) | (0x7 << 12), 0 << 3 | 2 << 12); - } rfseq = wlc_lcnphy_rfseq_tbl_adc_pwrup(pi); tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; @@ -1697,24 +1696,21 @@ static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) if (NORADIO_ENAB(pi->pubpi)) return index; - if (pi_lcn->lcnphy_tempsense_slope == 0) { + if (pi_lcn->lcnphy_tempsense_slope == 0) return index; - } + temp = (u16) wlc_lcnphy_tempsense(pi, 0); meas_temp = LCNPHY_TEMPSENSE(temp); - if (pi->tx_power_min != 0) { + if (pi->tx_power_min != 0) delta_brd = (pi_lcn->lcnphy_measPower - pi->tx_power_min); - } else { + else delta_brd = 0; - } manp = LCNPHY_TEMPSENSE(pi_lcn->lcnphy_rawtempsense); temp_diff = manp - meas_temp; if (temp_diff < 0) { - neg = 1; - temp_diff = -temp_diff; } @@ -1740,9 +1736,10 @@ static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) if (LCNREV_IS(pi->pubpi.phy_rev, 1)) index = 127; - if (new_index < 0 || new_index > 126) { + + if (new_index < 0 || new_index > 126) return index; - } + return new_index; } @@ -1866,9 +1863,8 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, return; values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); - if (NULL == values_to_save) { + if (NULL == values_to_save) return; - } save_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); save_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); @@ -1991,7 +1987,6 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, write_phy_reg(pi, 0x452, command_num); if ((cal_type == 3) || (cal_type == 4)) { - wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, &diq_start, 1, 16, 69); @@ -2001,10 +1996,8 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, write_phy_reg(pi, 0x451, cal_cmds[i]); - if (!wlc_lcnphy_iqcal_wait(pi)) { - + if (!wlc_lcnphy_iqcal_wait(pi)) goto cleanup; - } wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, best_coeffs, @@ -2013,10 +2006,9 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, best_coeffs, ARRAY_SIZE(best_coeffs), 16, 64); - if ((cal_type == 3) || (cal_type == 4)) { + if ((cal_type == 3) || (cal_type == 4)) wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, &diq_start, 1, 16, 69); - } wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, pi_lcn->lcnphy_cal_results. txiqlocal_bestcoeffs, @@ -2878,7 +2870,6 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) lcnphy_recal ? LCNPHY_CAL_RECAL : LCNPHY_CAL_FULL), false); } else { - wlc_lcnphy_tx_iqlo_soft_cal_full(pi); } @@ -2905,10 +2896,8 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) wlc_lcnphy_tx_iqlo_cal(pi, &target_gains, LCNPHY_CAL_FULL, false); } else { - wlc_lcnphy_tx_iqlo_soft_cal_full(pi); } - } wlc_lcnphy_get_tx_iqcc(pi, &a, &b); @@ -3205,30 +3194,26 @@ static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps) if (arsh >= 0) { a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); temp = (s32) (ii >> arsh); - if (temp == 0) { + if (temp == 0) return false; - } } else { a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); temp = (s32) (ii << -arsh); - if (temp == 0) { + if (temp == 0) return false; - } } a /= temp; brsh = qq_nbits - 31 + 20; if (brsh >= 0) { b = (qq << (31 - qq_nbits)); temp = (s32) (ii >> brsh); - if (temp == 0) { + if (temp == 0) return false; - } } else { b = (qq << (31 - qq_nbits)); temp = (s32) (ii << -brsh); - if (temp == 0) { + if (temp == 0) return false; - } } b /= temp; b -= a * a; @@ -3272,14 +3257,12 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) { + if (NULL == ptr) return false; - } if (module == 2) { while (iqcomp_sz--) { if (iqcomp[iqcomp_sz].chan == CHSPEC_CHANNEL(pi->radio_chanspec)) { - wlc_lcnphy_set_rx_iq_comp(pi, (u16) iqcomp[iqcomp_sz].a, @@ -3297,10 +3280,9 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - for (i = 0; i < 11; i++) { + for (i = 0; i < 11; i++) values_to_save[i] = read_radio_reg(pi, rxiq_cal_rf_reg[i]); - } Core1TxControl_old = read_phy_reg(pi, 0x631); or_phy_reg(pi, 0x631, 0x0015); @@ -3401,17 +3383,16 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); - for (i = 0; i < 11; i++) { + for (i = 0; i < 11; i++) write_radio_reg(pi, rxiq_cal_rf_reg[i], values_to_save[i]); - } - if (tx_gain_override_old) { + if (tx_gain_override_old) wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); - } else + else wlc_lcnphy_disable_tx_gain_override(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); + wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); wlc_lcnphy_rx_gain_override_enable(pi, false); } @@ -3477,10 +3458,10 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) { - wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); wlapi_suspend_mac_and_wait(pi->sh->physhim); } + wlc_lcnphy_deaf_mode(pi, true); wlc_lcnphy_txpwrtbl_iqlo_cal(pi); @@ -3531,7 +3512,6 @@ void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode) switch (mode) { case PHY_PERICAL_CHAN: - break; case PHY_FULLCAL: wlc_lcnphy_periodic_cal(pi); @@ -3600,13 +3580,11 @@ wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) if (NORADIO_ENAB(pi->pubpi)) return; - if (channel == 14) { + if (channel == 14) mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); - - } else { + else mod_phy_reg(pi, 0x448, (0x3 << 8), (1) << 8); - } pi_lcn->lcnphy_bandedge_corr = 2; if (channel == 1) pi_lcn->lcnphy_bandedge_corr = 4; @@ -3731,10 +3709,9 @@ wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, u16 *values_to_save) { u16 vmid; int i; - for (i = 0; i < 20; i++) { + for (i = 0; i < 20; i++) values_to_save[i] = read_radio_reg(pi, iqlo_loopback_rf_regs[i]); - } mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); @@ -3872,22 +3849,24 @@ wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, val = R_REG(&pi->regs->tplatewrdata); imag = ((val >> 16) & 0x3ff); real = ((val) & 0x3ff); - if (imag > 511) { + if (imag > 511) imag -= 1024; - } - if (real > 511) { + + if (real > 511) real -= 1024; - } + if (pi_lcn->lcnphy_iqcal_swp_dis) ptr[(strptr - 0x7E00) / 4] = real; else ptr[(strptr - 0x7E00) / 4] = imag; + if (clip_detect_algo) { if (imag > thresh || imag < -thresh) { strptr = 0x8000; ptr[130] = 1; } } + strptr += 4; } @@ -4019,9 +3998,8 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, phy_c21 = 0; phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) { + if (NULL == ptr) return; - } phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); if (NULL == phy_c32) { @@ -4054,18 +4032,16 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, phy_c4 = 32; if (num_levels == 0) { - if (cal_type != 0) { + if (cal_type != 0) num_levels = 4; - } else { + else num_levels = 9; - } } if (step_size_lg2 == 0) { - if (cal_type != 0) { + if (cal_type != 0) step_size_lg2 = 3; - } else { + else step_size_lg2 = 8; - } } phy_c7 = (1 << step_size_lg2); @@ -4150,11 +4126,11 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, phy_c18 = 0; phy_c19 = 0; for (j = 0; j < 128; j++) { - if (cal_type != 0) { + if (cal_type != 0) phy_c6 = j % phy_c4; - } else { + else phy_c6 = (2 * j) % phy_c4; - } + phy_c2.re = phy_c1[phy_c6].re; phy_c2.im = phy_c1[phy_c6].im; phy_c17 = ptr[j]; @@ -4206,10 +4182,9 @@ wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, u16 *values_to_save) and_phy_reg(pi, 0x43b, 0xC); - for (i = 0; i < 20; i++) { + for (i = 0; i < 20; i++) write_radio_reg(pi, iqlo_loopback_rf_regs[i], values_to_save[i]); - } } static void @@ -4306,9 +4281,8 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) phybw40 = CHSPEC_IS40(pi->radio_chanspec); - for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++) { + for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++) wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]); - } if (pi->sh->boardflags & BFL_FEM_BT) { tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; @@ -4443,7 +4417,6 @@ static void wlc_lcnphy_rev2_baseband_init(struct brcms_phy *pi) { if (CHSPEC_IS5G(pi->radio_chanspec)) { mod_phy_reg(pi, 0x416, (0xff << 0), 80 << 0); - mod_phy_reg(pi, 0x416, (0xff << 8), 80 << 8); } } @@ -4763,9 +4736,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) opo = (u8) PHY_GETINTVAR(pi, "opo"); - for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) { + for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) pi->tx_srom_max_rate_2g[i] = txpwr; - } offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); @@ -4811,9 +4783,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) if (PHY_GETVAR(pi, "cckdigfilttype")) { s16 temp; temp = (s16) PHY_GETINTVAR(pi, "cckdigfilttype"); - if (temp >= 0) { + if (temp >= 0) pi_lcn->lcnphy_cck_dig_filt_type = temp; - } } return true; @@ -4866,9 +4837,8 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) if (chan_info_2064_lcnphy[i].chan == channel) break; - if (i >= ARRAY_SIZE(chan_info_2064_lcnphy)) { + if (i >= ARRAY_SIZE(chan_info_2064_lcnphy)) return; - } ci = &chan_info_2064_lcnphy[i]; } @@ -5015,14 +4985,11 @@ void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi) if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { wlc_lcnphy_calib_modes(pi, LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL); } else if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) { - pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); wlc_lcnphy_txpower_recalc_target(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, pwr_ctrl); - } else - return; + } } void wlc_phy_detach_lcnphy(struct brcms_phy *pi) @@ -5035,9 +5002,8 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) struct brcms_phy_lcnphy *pi_lcn; pi->u.pi_lcnphy = kzalloc(sizeof(struct brcms_phy_lcnphy), GFP_ATOMIC); - if (pi->u.pi_lcnphy == NULL) { + if (pi->u.pi_lcnphy == NULL) return false; - } pi_lcn = pi->u.pi_lcnphy; @@ -5196,18 +5162,17 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) temperature = pi_lcn->lcnphy_lastsensed_temperature; - if ((temperature - 15) < -30) { + if ((temperature - 15) < -30) input_power_db = input_power_db + (((temperature - 10 - 25) * 286) >> 12) - 7; - } else if ((temperature - 15) < 4) { + else if ((temperature - 15) < 4) input_power_db = input_power_db + (((temperature - 10 - 25) * 286) >> 12) - 3; - } else { + else input_power_db = input_power_db + (((temperature - 10 - 25) * 286) >> 12); - } wlc_lcnphy_rx_gain_override_enable(pi, 0); @@ -5267,11 +5232,10 @@ wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, s16 filt_type) } if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, addr[j], LCNPHY_txdigfiltcoeffs_cck [filt_index][j + 1]); - } } } else { for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_OFDM; j++) { @@ -5282,11 +5246,10 @@ wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, s16 filt_type) } if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, addr_ofdm[j], LCNPHY_txdigfiltcoeffs_ofdm [filt_index][j + 1]); - } } } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index f758812ee5d..ee1fe58ecf0 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -33,22 +33,23 @@ ((core == PHY_CORE_0) ? radio_type##_##jspace##0 : radio_type##_##jspace##1)) #define WRITE_RADIO_REG2(pi, radio_type, jspace, core, reg_name, value) \ write_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ - ((core == PHY_CORE_0) ? radio_type##_##jspace##0 : radio_type##_##jspace##1), value); + ((core == PHY_CORE_0) ? radio_type##_##jspace##0 : \ + radio_type##_##jspace##1), value) #define WRITE_RADIO_SYN(pi, radio_type, reg_name, value) \ - write_radio_reg(pi, radio_type##_##SYN##_##reg_name, value); + write_radio_reg(pi, radio_type##_##SYN##_##reg_name, value) #define READ_RADIO_REG3(pi, radio_type, jspace, core, reg_name) \ read_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name)); + radio_type##_##jspace##1##_##reg_name)) #define WRITE_RADIO_REG3(pi, radio_type, jspace, core, reg_name, value) \ write_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name), value); + radio_type##_##jspace##1##_##reg_name), value) #define READ_RADIO_REG4(pi, radio_type, jspace, core, reg_name) \ read_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1)); + radio_type##_##reg_name##_##jspace##1)) #define WRITE_RADIO_REG4(pi, radio_type, jspace, core, reg_name, value) \ write_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1), value); + radio_type##_##reg_name##_##jspace##1), value) #define NPHY_ACI_MAX_UNDETECT_WINDOW_SZ 40 #define NPHY_ACI_CHANNEL_DELTA 5 @@ -14209,9 +14210,8 @@ bool wlc_phy_bist_check_phy(struct brcms_phy_pub *pih) phybist4 = read_phy_reg(pi, 0x156); if ((phybist0 == 0) && (phybist1 == 0x4000) && (phybist2 == 0x1fe0) && - (phybist3 == 0) && (phybist4 == 0)) { + (phybist3 == 0) && (phybist4 == 0)) return true; - } return false; } @@ -14239,7 +14239,6 @@ static void wlc_phy_bphy_init_nphy(struct brcms_phy *pi) or_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_LNA_GAIN_RANGE, 0x1a); } else { - write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_STEP, 0x668); } } @@ -14316,20 +14315,19 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) case 1: - if (pi->aa2g == 7) { - + if (pi->aa2g == 7) wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, 2, 0x21, 8, &ant_sw_ctrl_tbl_rev8_2o3 [0]); - } else { + else wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, 2, 0x21, 8, &ant_sw_ctrl_tbl_rev8 [0]); - } + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, 2, 0x25, 8, &ant_sw_ctrl_tbl_rev8[2]); @@ -14409,11 +14407,10 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) } } } else { - for (idx = 0; idx < mimophytbl_info_sz_rev0_volatile; idx++) { + for (idx = 0; idx < mimophytbl_info_sz_rev0_volatile; idx++) wlc_phy_write_table_nphy(pi, &mimophytbl_info_rev0_volatile [idx]); - } } } @@ -14440,32 +14437,25 @@ void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs) wlc_phy_write_txmacreg_nphy(pi, holdoff, delay); - if (pi && pi->sh && (pi->sh->_rifs_phy != rifs)) { + if (pi && pi->sh && (pi->sh->_rifs_phy != rifs)) pi->sh->_rifs_phy = rifs; - } } bool wlc_phy_attach_nphy(struct brcms_phy *pi) { uint i; - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 6)) { + if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 6)) pi->phyhang_avoid = true; - } if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - pi->nphy_gband_spurwar_en = true; - - if (pi->sh->boardflags2 & BFL2_SPUR_WAR) { + if (pi->sh->boardflags2 & BFL2_SPUR_WAR) pi->nphy_aband_spurwar_en = true; - } } if (NREV_GE(pi->pubpi.phy_rev, 6) && NREV_LT(pi->pubpi.phy_rev, 7)) { - - if (pi->sh->boardflags2 & BFL2_2G_SPUR_WAR) { + if (pi->sh->boardflags2 & BFL2_2G_SPUR_WAR) pi->nphy_gband_spurwar2_en = true; - } } pi->n_preamble_override = AUTO; @@ -14485,9 +14475,8 @@ bool wlc_phy_attach_nphy(struct brcms_phy *pi) pi->nphy_elna_gain_config = false; pi->radio_is_on = false; - for (i = 0; i < pi->pubpi.phy_corenum; i++) { + for (i = 0; i < pi->pubpi.phy_corenum; i++) pi->nphy_txpwrindex[i].index = AUTO; - } wlc_phy_txpwrctrl_config_nphy(pi); if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) @@ -14538,19 +14527,17 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) core = 0; - if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) { + if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - } if ((ISNPHY(pi)) && (NREV_GE(pi->pubpi.phy_rev, 5)) && ((pi->sh->chippkg == BCM4717_PKG_ID) || (pi->sh->chippkg == BCM4718_PKG_ID))) { if ((pi->sh->boardflags & BFL_EXTLNA) && - (CHSPEC_IS2G(pi->radio_chanspec))) { + (CHSPEC_IS2G(pi->radio_chanspec))) ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), 0x40, 0x40); - } } if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && @@ -14632,9 +14619,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) write_phy_reg(pi, 0x1ff, 48); - if (NREV_LT(pi->pubpi.phy_rev, 8)) { + if (NREV_LT(pi->pubpi.phy_rev, 8)) wlc_phy_update_mimoconfig_nphy(pi, pi->n_preamble_override); - } wlc_phy_stf_chain_upd_nphy(pi); @@ -14656,11 +14642,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) } wlc_phy_ipa_set_tx_digi_filts_nphy(pi); - } else { - - if (NREV_GE(pi->pubpi.phy_rev, 5)) { - wlc_phy_extpa_set_tx_digi_filts_nphy(pi); - } + } else if (NREV_GE(pi->pubpi.phy_rev, 5)) { + wlc_phy_extpa_set_tx_digi_filts_nphy(pi); } wlc_phy_workarounds_nphy(pi); @@ -14705,38 +14688,33 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi); } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(pi->pubpi.phy_rev, 3)) { + if (NREV_IS(pi->pubpi.phy_rev, 3)) tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev3; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { + else if (NREV_IS(pi->pubpi.phy_rev, 4)) tx_pwrctrl_tbl = (pi->srom_fem5g.extpagain == 3) ? nphy_tpc_5GHz_txgain_HiPwrEPA : nphy_tpc_5GHz_txgain_rev4; - } else { + else tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev5; - } - } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (pi->pubpi.radiorev == 5) { + if (pi->pubpi.radiorev == 5) tx_pwrctrl_tbl = nphy_tpc_txgain_epa_2057rev5; - } else if (pi->pubpi.radiorev == 3) { + else if (pi->pubpi.radiorev == 3) tx_pwrctrl_tbl = nphy_tpc_txgain_epa_2057rev3; - } - } else { if (NREV_GE(pi->pubpi.phy_rev, 5) && - (pi->srom_fem2g.extpagain == 3)) { + (pi->srom_fem2g.extpagain == 3)) tx_pwrctrl_tbl = nphy_tpc_txgain_HiPwrEPA; - } else { + else tx_pwrctrl_tbl = nphy_tpc_txgain_rev3; - } } } } @@ -14757,35 +14735,33 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { + (pi->pubpi.radiorev == 6)) rfpwr_offset = (s16) nphy_papd_padgain_dlt_2g_2057rev3n4 [pad_gn]; - } else if (pi->pubpi.radiorev == 5) { + else if (pi->pubpi.radiorev == 5) rfpwr_offset = (s16) nphy_papd_padgain_dlt_2g_2057rev5 [pad_gn]; - } else if ((pi->pubpi.radiorev == 7) + else if ((pi->pubpi.radiorev == 7) || (pi->pubpi.radiorev == - 8)) { + 8)) rfpwr_offset = (s16) nphy_papd_padgain_dlt_2g_2057rev7 [pad_gn]; - } } else { if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { + (pi->pubpi.radiorev == 6)) rfpwr_offset = (s16) nphy_papd_pgagain_dlt_5g_2057 [pga_gn]; - } else if ((pi->pubpi.radiorev == 7) + else if ((pi->pubpi.radiorev == 7) || (pi->pubpi.radiorev == - 8)) { + 8)) rfpwr_offset = (s16) nphy_papd_pgagain_dlt_5g_2057rev7 [pga_gn]; - } } wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, @@ -14800,15 +14776,14 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) for (idx = 0; idx < 128; idx++) { pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) rfpwr_offset = (s16) nphy_papd_pga_gain_delta_ipa_2g [pga_gn]; - } else { + else rfpwr_offset = (s16) nphy_papd_pga_gain_delta_ipa_5g [pga_gn]; - } wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, @@ -14829,14 +14804,12 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) 192, 32, nphy_tpc_txgain); } - if (pi->sh->phyrxchain != 0x3) { + if (pi->sh->phyrxchain != 0x3) wlc_phy_rxcore_setstate_nphy((struct brcms_phy_pub *) pi, pi->sh->phyrxchain); - } - if (PHY_PERICAL_MPHASE_PENDING(pi)) { + if (PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_restart(pi); - } if (!NORADIO_ENAB(pi->pubpi)) { bool do_rssi_cal = false; @@ -14846,20 +14819,18 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) (pi->nphy_rssical_chanspec_2G == 0) : (pi->nphy_rssical_chanspec_5G == 0); - if (do_rssi_cal) { + if (do_rssi_cal) wlc_phy_rssi_cal_nphy(pi); - } else { + else wlc_phy_restore_rssical_nphy(pi); - } } else { wlc_phy_rssi_cal_nphy(pi); } - if (!SCAN_RM_IN_PROGRESS(pi)) { + if (!SCAN_RM_IN_PROGRESS(pi)) do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? (pi->nphy_iqcal_chanspec_2G == 0) : (pi->nphy_iqcal_chanspec_5G == 0); - } if (!pi->do_initcal) do_nphy_cal = false; @@ -14892,14 +14863,12 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) (pi, target_gain, true, false) == 0) { if (wlc_phy_cal_rxiq_nphy (pi, target_gain, 2, - false) == 0) { + false) == 0) wlc_phy_savecal_nphy(pi); - } } } else if (pi->mphase_cal_phase_id == MPHASE_CAL_STATE_IDLE) { - wlc_phy_cal_perical((struct brcms_phy_pub *) pi, PHY_PERICAL_PHYINIT); } @@ -14967,20 +14936,18 @@ void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en) pi->rfctrlIntc1_save = read_phy_reg(pi, 0x91); pi->rfctrlIntc2_save = read_phy_reg(pi, 0x92); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) rfctrlintc_override_val = 0x1480; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + else if (NREV_GE(pi->pubpi.phy_rev, 3)) rfctrlintc_override_val = CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; - } else { + else rfctrlintc_override_val = CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; - } write_phy_reg(pi, 0x91, rfctrlintc_override_val); write_phy_reg(pi, 0x92, rfctrlintc_override_val); } else { - write_phy_reg(pi, 0x91, pi->rfctrlIntc1_save); write_phy_reg(pi, 0x92, pi->rfctrlIntc2_save); } @@ -14998,22 +14965,19 @@ void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi) txrx_chain = NPHY_RfseqCoreActv_TxRxChain0; CoreActv_override = true; - if (NREV_LE(pi->pubpi.phy_rev, 2)) { + if (NREV_LE(pi->pubpi.phy_rev, 2)) and_phy_reg(pi, 0xa0, ~0x20); - } } else if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN1) { txrx_chain = NPHY_RfseqCoreActv_TxRxChain1; CoreActv_override = true; - if (NREV_LE(pi->pubpi.phy_rev, 2)) { + if (NREV_LE(pi->pubpi.phy_rev, 2)) or_phy_reg(pi, 0xa0, 0x20); - } } mod_phy_reg(pi, 0xa2, ((0xf << 0) | (0xf << 4)), txrx_chain); if (CoreActv_override) { - pi->nphy_perical = PHY_PERICAL_DISABLE; or_phy_reg(pi, 0xa1, NPHY_RfseqMode_CoreActv_override); } else { @@ -15073,9 +15037,8 @@ void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) &tbl_opcode); break; } else if (tbl_buf[i] == - NPHY_REV3_RFSEQ_CMD_END) { + NPHY_REV3_RFSEQ_CMD_END) break; - } } } } @@ -15123,9 +15086,8 @@ static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) { u8 idx, idx2, i, delta_ind; - for (idx = TXP_FIRST_CCK; idx <= TXP_LAST_CCK; idx++) { + for (idx = TXP_FIRST_CCK; idx <= TXP_LAST_CCK; idx++) pi->adj_pwr_tbl_nphy[idx] = pi->tx_power_offset[idx]; - } for (i = 0; i < 4; i++) { idx2 = 0; @@ -15222,18 +15184,16 @@ wlc_phy_war_force_trsw_to_R_cliplo_nphy(struct brcms_phy *pi, u8 core) { if (core == PHY_CORE_0) { write_phy_reg(pi, 0x38, 0x4); - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) write_phy_reg(pi, 0x37, 0x0060); - } else { + else write_phy_reg(pi, 0x37, 0x1080); - } } else if (core == PHY_CORE_1) { write_phy_reg(pi, 0x2ae, 0x4); - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) write_phy_reg(pi, 0x2ad, 0x0060); - } else { + else write_phy_reg(pi, 0x2ad, 0x1080); - } } } @@ -15243,13 +15203,11 @@ static void wlc_phy_war_txchain_upd_nphy(struct brcms_phy *pi, u8 txchain) txchain0 = txchain & 0x1; txchain1 = (txchain & 0x2) >> 1; - if (!txchain0) { + if (!txchain0) wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); - } - if (!txchain1) { + if (!txchain1) wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); - } } static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) @@ -15362,11 +15320,10 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) u16 freq; int coreNum; - if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 0); - } else { + else wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 1); - } if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, true); @@ -15401,9 +15358,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) write_phy_reg(pi, 0x240, 0x1b0); } - if (NREV_GE(pi->pubpi.phy_rev, 8)) { + if (NREV_GE(pi->pubpi.phy_rev, 8)) mod_phy_reg(pi, 0xbd, (0xff << 0), (114 << 0)); - } wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, &dac_control); @@ -15422,7 +15378,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x16e, 16, rfseq_rx2tx_dacbufpu_rev7); - if (PHY_IPA(pi)) { + if (PHY_IPA(pi)) wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, rfseq_rx2tx_events_rev3_ipa, rfseq_rx2tx_dlys_rev3_ipa, @@ -15431,7 +15387,6 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) sizeof (rfseq_rx2tx_events_rev3_ipa [0])); - } mod_phy_reg(pi, 0x299, (0x3 << 14), (0x1 << 14)); mod_phy_reg(pi, 0x29d, (0x3 << 14), (0x1 << 14)); @@ -15572,15 +15527,13 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_REV7_RFCTRLOVERRIDE_ID2); } - if (!NORADIO_ENAB(pi->pubpi)) { + if (!NORADIO_ENAB(pi->pubpi)) write_phy_reg(pi, 0x32f, 0x3); - } - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { + if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 0, NPHY_REV7_RFCTRLOVERRIDE_ID0); - } if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { @@ -15635,10 +15588,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - + || (pi->pubpi.radiorev == 6)) txgm_idac_bleed = 0x7f; - } for (coreNum = 0; coreNum <= 1; coreNum++) { if (txgm_idac_bleed != 0) @@ -15918,7 +15869,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) sizeof(rfseq_tx2rx_events_rev3) / sizeof(rfseq_tx2rx_events_rev3[0])); - if (PHY_IPA(pi)) { + if (PHY_IPA(pi)) wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, rfseq_rx2tx_events_rev3_ipa, rfseq_rx2tx_dlys_rev3_ipa, @@ -15927,7 +15878,6 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) sizeof (rfseq_rx2tx_events_rev3_ipa [0])); - } if ((pi->sh->hw_phyrxchain != 0x3) && (pi->sh->hw_phyrxchain != pi->sh->hw_phytxchain)) { @@ -15947,11 +15897,10 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) [0])); } - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) write_phy_reg(pi, 0x6a, 0x2); - } else { + else write_phy_reg(pi, 0x6a, 0x9c40); - } mod_phy_reg(pi, 0x294, (0xf << 8), (7 << 8)); @@ -16212,11 +16161,10 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 6)) { - if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) { + if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) wlapi_bmac_mhf(pi->sh->physhim, MHF4, MHF4_BPHY_TXCORE0, MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); - } } } else { @@ -16314,11 +16262,10 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) write_phy_reg(pi, 0x194, 0x0); } - if (NREV_IS(pi->pubpi.phy_rev, 2)) { + if (NREV_IS(pi->pubpi.phy_rev, 2)) mod_phy_reg(pi, 0x221, NPHY_FORCESIG_DECODEGATEDCLKS, NPHY_FORCESIG_DECODEGATEDCLKS); - } } if (pi->phyhang_avoid) @@ -16485,7 +16432,6 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (pi->pubpi.radiorev == 5) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev5(pi); } else if (pi->pubpi.radiorev == 7) { wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); @@ -16697,11 +16643,11 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) crsmin_th = crsminA_th_rev6; crsminl_th = crsminlA_th_rev6; if ((pi->pubpi.radiorev == 11) && - (CHSPEC_IS40(pi->radio_chanspec) == 0)) { + (CHSPEC_IS40(pi->radio_chanspec) == 0)) crsminu_th = crsminuA_th_rev6_224B0; - } else { + else crsminu_th = crsminuA_th_rev6; - } + nbclip_th = nbclipA_th_rev6; rssi_gain = rssiA_gain_rev6; } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { @@ -16895,9 +16841,8 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) mod_phy_reg(pi, 0x20, (0x1f << 7), (hpf_code << 7)); mod_phy_reg(pi, 0x36, (0x1f << 7), (hpf_code << 7)); - for (ctr = 0; ctr < 4; ctr++) { + for (ctr = 0; ctr < 4; ctr++) regval[ctr] = (hpf_code << 8) | 0x7c; - } wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); wlc_phy_adjust_lnagaintbl_nphy(pi); @@ -16910,22 +16855,19 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) wlc_phy_table_write_nphy(pi, 2, 4, 8, 16, regval); wlc_phy_table_write_nphy(pi, 3, 4, 8, 16, regval); - for (ctr = 0; ctr < 4; ctr++) { + for (ctr = 0; ctr < 4; ctr++) regval[ctr] = (hpf_code << 8) | 0x74; - } wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); } if (NREV_IS(pi->pubpi.phy_rev, 2)) { - for (ctr = 0; ctr < 21; ctr++) { + for (ctr = 0; ctr < 21; ctr++) regval[ctr] = 3 * ctr; - } wlc_phy_table_write_nphy(pi, 0, 21, 32, 16, regval); wlc_phy_table_write_nphy(pi, 1, 21, 32, 16, regval); - for (ctr = 0; ctr < 21; ctr++) { + for (ctr = 0; ctr < 21; ctr++) regval[ctr] = (u16) ctr; - } wlc_phy_table_write_nphy(pi, 2, 21, 32, 16, regval); wlc_phy_table_write_nphy(pi, 3, 21, 32, 16, regval); } @@ -17201,9 +17143,7 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) } else { mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); } - } - } static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) @@ -17251,10 +17191,9 @@ static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) regval[2] = nphy_def_lnagains[3] + gain_delta[core]; regval[3] = nphy_def_lnagains[3] + gain_delta[core]; } else { - for (ctr = 0; ctr < 4; ctr++) { + for (ctr = 0; ctr < 4; ctr++) regval[ctr] = nphy_def_lnagains[ctr] + gain_delta[core]; - } } wlc_phy_table_write_nphy(pi, core, 4, 8, 16, regval); @@ -17515,19 +17454,15 @@ static void wlc_phy_radio_postinit_2056(struct brcms_phy *pi) mod_radio_reg(pi, RADIO_2056_SYN_COM_RESET, 0x2, 0x0); if ((pi->sh->boardflags2 & BFL2_LEGACY) - || (pi->sh->boardflags2 & BFL2_XTALBUFOUTEN)) { - + || (pi->sh->boardflags2 & BFL2_XTALBUFOUTEN)) mod_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2, 0xf4, 0x0); - } else { - + else mod_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2, 0xfc, 0x0); - } mod_radio_reg(pi, RADIO_2056_SYN_RCCAL_CTRL0, 0x1, 0x0); - if (pi->phy_init_por) { + if (pi->phy_init_por) wlc_phy_radio205x_rcal(pi); - } } static void wlc_phy_radio_init_2057(struct brcms_phy *pi) @@ -17535,23 +17470,18 @@ static void wlc_phy_radio_init_2057(struct brcms_phy *pi) struct radio_20xx_regs *regs_2057_ptr = NULL; if (NREV_IS(pi->pubpi.phy_rev, 7)) { - regs_2057_ptr = regs_2057_rev4; } else if (NREV_IS(pi->pubpi.phy_rev, 8) || NREV_IS(pi->pubpi.phy_rev, 9)) { switch (pi->pubpi.radiorev) { case 5: - if (pi->pubpi.radiover == 0x0) { - + if (pi->pubpi.radiover == 0x0) regs_2057_ptr = regs_2057_rev5; - - } else if (pi->pubpi.radiover == 0x1) { - + else if (pi->pubpi.radiover == 0x1) regs_2057_ptr = regs_2057_rev5v1; - } else { + else break; - } case 7: @@ -17652,9 +17582,9 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, break; default: - if (NORADIO_ENAB(pi->pubpi)) { + if (NORADIO_ENAB(pi->pubpi)) goto fail; - } + break; } } else if (NREV_IS(pi->pubpi.phy_rev, 16)) { @@ -17677,9 +17607,9 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, } } - if (i >= tbl_len) { + if (i >= tbl_len) goto fail; - } + if (pi->pubpi.radiorev == 5) { *t2 = &chan_info_tbl_p_2[i]; freq = chan_info_tbl_p_2[i].freq; @@ -17721,9 +17651,9 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, tbl_len = ARRAY_SIZE(chan_info_nphyrev6_2056v11); break; default: - if (NORADIO_ENAB(pi->pubpi)) { + if (NORADIO_ENAB(pi->pubpi)) goto fail; - } + break; } } @@ -17733,9 +17663,9 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, break; } - if (i >= tbl_len) { + if (i >= tbl_len) goto fail; - } + *t1 = &chan_info_tbl_p_1[i]; freq = chan_info_tbl_p_1[i].freq; @@ -17744,9 +17674,9 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, if (chan_info_nphy_2055[i].chan == channel) break; - if (i >= ARRAY_SIZE(chan_info_nphy_2055)) { + if (i >= ARRAY_SIZE(chan_info_nphy_2055)) goto fail; - } + *t3 = &chan_info_nphy_2055[i]; freq = chan_info_nphy_2055[i].freq; } @@ -17778,13 +17708,12 @@ u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint channel) if (CHSPEC_IS2G(pi->radio_chanspec)) return WL_CHAN_FREQ_RANGE_2G; - if ((freq >= BASE_LOW_5G_CHAN) && (freq < BASE_MID_5G_CHAN)) { + if ((freq >= BASE_LOW_5G_CHAN) && (freq < BASE_MID_5G_CHAN)) return WL_CHAN_FREQ_RANGE_5GL; - } else if ((freq >= BASE_MID_5G_CHAN) && (freq < BASE_HIGH_5G_CHAN)) { + else if ((freq >= BASE_MID_5G_CHAN) && (freq < BASE_HIGH_5G_CHAN)) return WL_CHAN_FREQ_RANGE_5GM; - } else { + else return WL_CHAN_FREQ_RANGE_5GH; - } } static void @@ -17960,15 +17889,14 @@ wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, break; } } - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | RADIO_2056_SYN, (u16) regs_SYN_2056_ptr[0x49 - 2].init_g); - } else { + else write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | RADIO_2056_SYN, (u16) regs_SYN_2056_ptr[0x49 - 2].init_a); - } if (pi->sh->boardflags2 & BFL2_GPLL_WAR) { if (CHSPEC_IS2G(pi->radio_chanspec)) { @@ -18116,11 +18044,11 @@ wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, paa_boost_tune = 0x0; pada_boost_tune = 0x77; - if (freq != 5825) { + if (freq != 5825) pgaa_boost_tune = -(int)(freq - 18) / 36 + 168; - } else { + else pgaa_boost_tune = 6; - } + mixa_boost_tune = 0xf; } @@ -18146,9 +18074,8 @@ wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, if ((pi->sh->chip == BCM43224_CHIP_ID) || (pi->sh->chip == BCM43225_CHIP_ID)) { - if (pi->sh->chippkg == BCM43224_FAB_SMIC) { + if (pi->sh->chippkg == BCM43224_FAB_SMIC) cascbias = 0x35; - } } pabias = (pi->phy_pabias == 0) ? 0x30 : pi->phy_pabias; @@ -18213,9 +18140,9 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS); - if (rcal_reg & 0x1) { + if (rcal_reg & 0x1) break; - } + udelay(100); } @@ -18264,9 +18191,9 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) rcal_reg = read_radio_reg(pi, RADIO_2056_SYN_RCAL_CODE_OUT | RADIO_2056_SYN); - if (rcal_reg & 0x80) { + if (rcal_reg & 0x80) break; - } + udelay(100); } @@ -18455,9 +18382,8 @@ wlc_phy_chanspec_radio2057_setup(struct brcms_phy *pi, if (CHSPEC_IS2G(pi->radio_chanspec)) { if (PHY_IPA(pi)) { - if (pi->pubpi.radiorev == 3) { + if (pi->pubpi.radiorev == 3) txmix2g_tune_boost_pu = 0x6b; - } if (pi->pubpi.radiorev == 5) pad2g_tune_pus = 0x73; @@ -18513,9 +18439,9 @@ static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) { + if (rccal_valid & 0x2) break; - } + udelay(500); } @@ -18535,9 +18461,9 @@ static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) { + if (rccal_valid & 0x2) break; - } + udelay(500); } @@ -18558,9 +18484,9 @@ static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) { + if (rccal_valid & 0x2) break; - } + udelay(500); } @@ -18706,19 +18632,18 @@ static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi) u8 tx_lpf_bw = 0; if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) tx_lpf_bw = 3; - } else { + else tx_lpf_bw = 1; - } if (PHY_IPA(pi)) { - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) tx_lpf_bw = 5; - } else { + else tx_lpf_bw = 4; - } } + write_phy_reg(pi, 0xe8, (tx_lpf_bw << 0) | (tx_lpf_bw << 3) | @@ -18726,11 +18651,10 @@ static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi) if (PHY_IPA(pi)) { - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) tx_lpf_bw = 4; - } else { + else tx_lpf_bw = 1; - } write_phy_reg(pi, 0xe9, (tx_lpf_bw << 0) | @@ -18762,18 +18686,16 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((cur_channel == 11) - && CHSPEC_IS40(pi->radio_chanspec)) { - + && CHSPEC_IS40(pi->radio_chanspec)) wlc_phy_adjust_min_noisevar_nphy(pi, 2, nphy_adj_tone_id_buf, nphy_adj_noise_var_buf); - } else { - + else wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, NULL); - } } + wlc_phy_adjust_crsminpwr_nphy(pi, NPHY_ADJUSTED_MINCRSPOWER); } @@ -18857,7 +18779,6 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) tempval = 0; } else { - wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, NULL); } @@ -18896,14 +18817,13 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) } if (nphy_adj_tone_id_buf[0] - && nphy_adj_noise_var_buf[0]) { + && nphy_adj_noise_var_buf[0]) wlc_phy_adjust_min_noisevar_nphy(pi, 1, nphy_adj_tone_id_buf, nphy_adj_noise_var_buf); - } else { + else wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, NULL); - } } if (pi->phyhang_avoid) @@ -18964,14 +18884,11 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, and_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_TEST, ~0x840); } - if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) { + if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) wlc_phy_txpwr_fixpower_nphy(pi); - } - - if (NREV_LT(pi->pubpi.phy_rev, 3)) { + if (NREV_LT(pi->pubpi.phy_rev, 3)) wlc_phy_adjust_lnagaintbl_nphy(pi); - } wlc_phy_txlpfbw_nphy(pi); @@ -18982,28 +18899,20 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, val = CHSPEC_CHANNEL(chanspec); if (!CHSPEC_IS40(pi->radio_chanspec)) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((val == 13) || (val == 14) || (val == 153)) { + if ((val == 13) || (val == 14) || (val == 153)) spuravoid = 1; - } - } else { - - if (((val >= 5) && (val <= 8)) || (val == 13) + } else if (((val >= 5) && (val <= 8)) || (val == 13) || (val == 14)) { spuravoid = 1; - } } + } else if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (val == 54) + spuravoid = 1; } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (val == 54) { - spuravoid = 1; - } - } else { - - if (pi->nphy_aband_spurwar_en && - ((val == 38) || (val == 102) - || (val == 118))) - spuravoid = 1; - } + if (pi->nphy_aband_spurwar_en && + ((val == 38) || (val == 102) + || (val == 118))) + spuravoid = 1; } if (pi->phy_spuravoid == SPURAVOID_FORCEON) @@ -19055,9 +18964,8 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) struct chan_info_nphy_radio2057_rev5 *t2 = NULL; struct chan_info_nphy_2055 *t3 = NULL; - if (NORADIO_ENAB(pi->pubpi)) { + if (NORADIO_ENAB(pi->pubpi)) return; - } if (!wlc_phy_chan2freq_nphy (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) @@ -19071,15 +18979,13 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) if (CHSPEC_IS40(chanspec)) { if (CHSPEC_SB_UPPER(chanspec)) { or_phy_reg(pi, 0xa0, BPHY_BAND_SEL_UP20); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) or_phy_reg(pi, 0x310, PRIM_SEL_UP20); - } } else { and_phy_reg(pi, 0xa0, ~BPHY_BAND_SEL_UP20); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) and_phy_reg(pi, 0x310, (~PRIM_SEL_UP20 & 0xffff)); - } } } @@ -19657,11 +19563,10 @@ static u16 wlc_phy_read_lpf_bw_ctl_nphy(struct brcms_phy *pi, u16 offset) u16 rx2tx_lpf_rc_lut_offset = 0; if (offset == 0) { - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) rx2tx_lpf_rc_lut_offset = 0x159; - } else { + else rx2tx_lpf_rc_lut_offset = 0x154; - } } else { rx2tx_lpf_rc_lut_offset = offset; } @@ -19932,12 +19837,11 @@ wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, || (core_mask & (1 << core_num))) { or_phy_reg(pi, en_addr, en_mask); - if (addr != 0xffff) { + if (addr != 0xffff) mod_phy_reg(pi, val_addr, val_mask, (value << val_shift)); - } } } } @@ -20066,12 +19970,11 @@ wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, || (core_mask & (1 << core_num))) { or_phy_reg(pi, en_addr, en_mask); - if (addr != 0xffff) { + if (addr != 0xffff) mod_phy_reg(pi, val_addr, val_mask, (value << val_shift)); - } } } } @@ -20178,9 +20081,8 @@ wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, break; } - if ((addr != 0xffff) && (core_mask & (1 << core_num))) { + if ((addr != 0xffff) && (core_mask & (1 << core_num))) mod_phy_reg(pi, addr, mask, (value << shift)); - } } or_phy_reg(pi, 0xec, (0x1 << 0)); @@ -20291,130 +20193,118 @@ wlc_phy_scale_offset_rssi_nphy(struct brcms_phy *pi, u16 scale, s8 offset, if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) write_phy_reg(pi, 0x1a6, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) write_phy_reg(pi, 0x1ac, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) write_phy_reg(pi, 0x1b2, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) write_phy_reg(pi, 0x1b8, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) write_phy_reg(pi, 0x1a4, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) write_phy_reg(pi, 0x1aa, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) write_phy_reg(pi, 0x1b0, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) write_phy_reg(pi, 0x1b6, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) write_phy_reg(pi, 0x1a5, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) write_phy_reg(pi, 0x1ab, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) write_phy_reg(pi, 0x1b1, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) write_phy_reg(pi, 0x1b7, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) write_phy_reg(pi, 0x1a7, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) write_phy_reg(pi, 0x1ad, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) write_phy_reg(pi, 0x1b3, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) write_phy_reg(pi, 0x1b9, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) write_phy_reg(pi, 0x1a8, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) write_phy_reg(pi, 0x1ae, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) { + (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) write_phy_reg(pi, 0x1b4, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) { + (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) write_phy_reg(pi, 0x1ba, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) { + (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) write_phy_reg(pi, 0x1a9, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) { + (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) write_phy_reg(pi, 0x1b5, valuetostuff); - } if (((coresel == RADIO_MIMO_CORESEL_CORE1) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) { + (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) write_phy_reg(pi, 0x1af, valuetostuff); - } + if (((coresel == RADIO_MIMO_CORESEL_CORE2) || (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) { + (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) write_phy_reg(pi, 0x1bb, valuetostuff); - } } void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) @@ -20459,7 +20349,6 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) if (rssi_type == NPHY_RSSI_SEL_W1 || rssi_type == NPHY_RSSI_SEL_W2 || rssi_type == NPHY_RSSI_SEL_NB) { - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0xa6 : 0xa7, @@ -20501,7 +20390,6 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) 0xe5 : 0xe6, mask, val); } else { if (rssi_type == NPHY_RSSI_SEL_TBD) { - mask = (0x3 << 8); val = 1 << 8; mod_phy_reg(pi, @@ -20516,7 +20404,6 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) : 0xa7, mask, val); } else if (rssi_type == NPHY_RSSI_SEL_IQ) { - mask = (0x3 << 8); val = 2 << 8; mod_phy_reg(pi, @@ -20530,7 +20417,6 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) PHY_CORE_0) ? 0xa6 : 0xa7, mask, val); } else { - mask = (0x3 << 8); val = 3 << 8; mod_phy_reg(pi, @@ -20547,8 +20433,7 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) if (PHY_IPA(pi)) { if (NREV_GE (pi->pubpi.phy_rev, - 7)) { - + 7)) write_radio_reg (pi, ((core == @@ -20562,7 +20447,7 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) radio_chanspec) ? 0xc : 0xe)); - } else { + else write_radio_reg (pi, RADIO_2056_TX_TX_SSI_MUX @@ -20578,7 +20463,6 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) radio_chanspec) ? 0xc : 0xe)); - } } else { if (NREV_GE @@ -20631,19 +20515,15 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) if ((rssi_type == NPHY_RSSI_SEL_W1) || (rssi_type == NPHY_RSSI_SEL_W2) || - (rssi_type == NPHY_RSSI_SEL_NB)) { - + (rssi_type == NPHY_RSSI_SEL_NB)) val = 0x0; - } else if (rssi_type == NPHY_RSSI_SEL_TBD) { - + else if (rssi_type == NPHY_RSSI_SEL_TBD) val = 0x1; - } else if (rssi_type == NPHY_RSSI_SEL_IQ) { - + else if (rssi_type == NPHY_RSSI_SEL_IQ) val = 0x2; - } else { - + else val = 0x3; - } + mask = ((0x3 << 12) | (0x3 << 14)); val = (val << 12) | (val << 14); mod_phy_reg(pi, 0xa6, mask, val); @@ -20652,15 +20532,13 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) if ((rssi_type == NPHY_RSSI_SEL_W1) || (rssi_type == NPHY_RSSI_SEL_W2) || (rssi_type == NPHY_RSSI_SEL_NB)) { - if (rssi_type == NPHY_RSSI_SEL_W1) { + if (rssi_type == NPHY_RSSI_SEL_W1) val = 0x1; - } - if (rssi_type == NPHY_RSSI_SEL_W2) { + if (rssi_type == NPHY_RSSI_SEL_W2) val = 0x2; - } - if (rssi_type == NPHY_RSSI_SEL_NB) { + if (rssi_type == NPHY_RSSI_SEL_NB) val = 0x3; - } + mask = (0x3 << 4); val = (val << 4); mod_phy_reg(pi, 0x7a, mask, val); @@ -20762,13 +20640,11 @@ wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type, s32 *rssi_buf, wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); gpiosel_orig = read_phy_reg(pi, 0xca); - if (NREV_LT(pi->pubpi.phy_rev, 2)) { + if (NREV_LT(pi->pubpi.phy_rev, 2)) write_phy_reg(pi, 0xca, 5); - } - for (ctr = 0; ctr < 4; ctr++) { + for (ctr = 0; ctr < 4; ctr++) rssi_buf[ctr] = 0; - } for (samp = 0; samp < nsamps; samp++) { if (NREV_LT(pi->pubpi.phy_rev, 2)) { @@ -20785,9 +20661,8 @@ wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type, s32 *rssi_buf, tmp_buf[ctr++] = ((s8) ((rssi1 & 0x3f) << 2)) >> 2; tmp_buf[ctr++] = ((s8) (((rssi1 >> 8) & 0x3f) << 2)) >> 2; - for (ctr = 0; ctr < 4; ctr++) { + for (ctr = 0; ctr < 4; ctr++) rssi_buf[ctr] += tmp_buf[ctr]; - } } @@ -20796,9 +20671,8 @@ wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type, s32 *rssi_buf, rssi_out_val |= (rssi_buf[1] & 0xff) << 16; rssi_out_val |= (rssi_buf[0] & 0xff) << 24; - if (NREV_LT(pi->pubpi.phy_rev, 2)) { + if (NREV_LT(pi->pubpi.phy_rev, 2)) write_phy_reg(pi, 0xca, gpiosel_orig); - } write_phy_reg(pi, 0xa6, afectrlCore1_save); write_phy_reg(pi, 0xa7, afectrlCore2_save); @@ -20997,11 +20871,10 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x05); wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp2, 1); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, 0x01); - } else { + else write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x01); - } radio_temp[0] = (126 * (radio_temp[1] + radio_temp2[1]) + 3987) / 64; @@ -21126,22 +20999,20 @@ wlc_phy_set_rssi_2055_vcm(struct brcms_phy *pi, u8 rssi_type, u8 *vcm_buf) RADIO_2055_NBRSSI_VCM_Q_SHIFT); } } else { - - if (core == PHY_CORE_0) { + if (core == PHY_CORE_0) mod_radio_reg(pi, RADIO_2055_CORE1_RXBB_RSSI_CTRL5, RADIO_2055_WBRSSI_VCM_IQ_MASK, vcm_buf[2 * core] << RADIO_2055_WBRSSI_VCM_IQ_SHIFT); - } else { + else mod_radio_reg(pi, RADIO_2055_CORE2_RXBB_RSSI_CTRL5, RADIO_2055_WBRSSI_VCM_IQ_MASK, vcm_buf[2 * core] << RADIO_2055_WBRSSI_VCM_IQ_SHIFT); - } } } } @@ -21149,7 +21020,6 @@ wlc_phy_set_rssi_2055_vcm(struct brcms_phy *pi, u8 rssi_type, u8 *vcm_buf) void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi) { if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_rssi_cal_nphy_rev3(pi); } else { wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_NB); @@ -21246,20 +21116,18 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) for (vcm = 0; vcm < 4; vcm++) { vcm_tmp[0] = vcm_tmp[1] = vcm_tmp[2] = vcm_tmp[3] = vcm; - if (rssi_type != NPHY_RSSI_SEL_W2) { + if (rssi_type != NPHY_RSSI_SEL_W2) wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_tmp); - } wlc_phy_poll_rssi_nphy(pi, rssi_type, &poll_results[vcm][0], NPHY_RSSICAL_NPOLL); if ((rssi_type == NPHY_RSSI_SEL_W1) || (rssi_type == NPHY_RSSI_SEL_W2)) { - for (ctr = 0; ctr < 2; ctr++) { + for (ctr = 0; ctr < 2; ctr++) poll_miniq[vcm][ctr] = min(poll_results[vcm][ctr * 2 + 0], poll_results[vcm][ctr * 2 + 1]); - } } } @@ -21276,17 +21144,15 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) min_d = curr_d; min_vcm = vcm; } - if (poll_results[vcm][result_idx] < min_poll) { + if (poll_results[vcm][result_idx] < min_poll) min_poll = poll_results[vcm][result_idx]; - } } vcm_final[result_idx] = min_vcm; poll_results_min[result_idx] = min_poll; } - if (rssi_type != NPHY_RSSI_SEL_W2) { + if (rssi_type != NPHY_RSSI_SEL_W2) wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_final); - } for (result_idx = 0; result_idx < 4; result_idx++) { fine_digital_offset[result_idx] = @@ -21307,10 +21173,9 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) } if (poll_results_min[result_idx] == - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) { + NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) fine_digital_offset[result_idx] = (target_code - NPHY_RSSICAL_MAXREAD - 1); - } wlc_phy_scale_offset_rssi_nphy(pi, 0x0, (s8) @@ -21325,32 +21190,30 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, pd_state[0]); mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, pd_state[1]); - if (rssi_ctrl_state[0] == RADIO_2055_NBRSSI_SEL) { + if (rssi_ctrl_state[0] == RADIO_2055_NBRSSI_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, NPHY_RSSI_SEL_NB); - } else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G1_SEL) { + else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G1_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, NPHY_RSSI_SEL_W1); - } else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G2_SEL) { + else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G2_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, NPHY_RSSI_SEL_W2); - } else { + else wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, NPHY_RSSI_SEL_W2); - } - if (rssi_ctrl_state[1] == RADIO_2055_NBRSSI_SEL) { + if (rssi_ctrl_state[1] == RADIO_2055_NBRSSI_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, NPHY_RSSI_SEL_NB); - } else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G1_SEL) { + else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G1_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, NPHY_RSSI_SEL_W1); - } else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G2_SEL) { + else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G2_SEL) wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, NPHY_RSSI_SEL_W2); - } else { + else wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, NPHY_RSSI_SEL_W2); - } wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, rssi_type); @@ -21500,11 +21363,10 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, mask = (0x1 << 4) | (0x1 << 5); - if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) val = value << 5; - } else { + else val = value << 4; - } mod_phy_reg(pi, (core == @@ -21636,8 +21498,6 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, } } } - } else { - return; } } @@ -21726,21 +21586,19 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_TRSW, 1, RADIO_MIMO_CORESEL_ALLRXTX); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_rxrf_pu, 0, 0, 0); - } else { + else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0, 0); - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_rx_pu, 1, 0, 0); - } else { + else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0, 0); - } if (NREV_GE(pi->pubpi.phy_rev, 7)) { wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), @@ -21804,21 +21662,18 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) NPHY_RAIL_Q, NPHY_RSSI_SEL_NB); for (vcm = 0; vcm < vcm_level_max; vcm++) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - + if (NREV_GE(pi->pubpi.phy_rev, 7)) mod_radio_reg(pi, (core == PHY_CORE_0) ? RADIO_2057_NB_MASTER_CORE0 : RADIO_2057_NB_MASTER_CORE1, RADIO_2057_VCM_MASK, vcm); - } else { - + else mod_radio_reg(pi, RADIO_2056_RX_RSSI_MISC | ((core == PHY_CORE_0) ? RADIO_2056_RX0 : RADIO_2056_RX1), RADIO_2056_VCM_MASK, vcm << RADIO_2056_RSSI_VCM_SHIFT); - } wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_NB, &poll_results[vcm][0], @@ -21843,29 +21698,27 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) min_vcm = vcm; } if (poll_results[vcm][result_idx] < - min_poll) { + min_poll) min_poll = poll_results[vcm] [result_idx]; - } } vcm_final = min_vcm; poll_results_min[result_idx] = min_poll; } } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) mod_radio_reg(pi, (core == PHY_CORE_0) ? RADIO_2057_NB_MASTER_CORE0 : RADIO_2057_NB_MASTER_CORE1, RADIO_2057_VCM_MASK, vcm_final); - } else { + else mod_radio_reg(pi, RADIO_2056_RX_RSSI_MISC | ((core == PHY_CORE_0) ? RADIO_2056_RX0 : RADIO_2056_RX1), RADIO_2056_VCM_MASK, vcm_final << RADIO_2056_RSSI_VCM_SHIFT); - } for (result_idx = 0; result_idx < 4; result_idx++) { if (core == result_idx / 2) { @@ -21891,11 +21744,10 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) } if (poll_results_min[result_idx] == - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) { + NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) fine_digital_offset[result_idx] = (NPHY_RSSICAL_NB_TARGET - NPHY_RSSICAL_MAXREAD - 1); - } wlc_phy_scale_offset_rssi_nphy(pi, 0x0, (s8) @@ -22259,9 +22111,8 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, } tone_buf = kmalloc(sizeof(struct cs32) * tbl_len, GFP_ATOMIC); - if (tone_buf == NULL) { + if (tone_buf == NULL) return 0; - } num_samps = (u16) tbl_len; rot = FIXED((f_kHz * 36) / phy_bw) / 100; @@ -22294,9 +22145,8 @@ wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, num_samps = wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, dac_test_mode); - if (num_samps == 0) { + if (num_samps == 0) return -EBADE; - } wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode, dac_test_mode, modify_bbmult); @@ -22312,17 +22162,15 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cs32 *tone_buf, u32 *data_buf = NULL; data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); - if (data_buf == NULL) { + if (data_buf == NULL) return; - } if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, true); - for (t = 0; t < num_samps; t++) { + for (t = 0; t < num_samps; t++) data_buf[t] = ((((unsigned int)tone_buf[t].i) & 0x3ff) << 10) | (((unsigned int)tone_buf[t].q) & 0x3ff); - } wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, data_buf); @@ -22395,11 +22243,11 @@ wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, write_phy_reg(pi, 0xc6, num_samps - 1); - if (loops != 0xffff) { + if (loops != 0xffff) write_phy_reg(pi, 0xc4, loops - 1); - } else { + else write_phy_reg(pi, 0xc4, loops); - } + write_phy_reg(pi, 0xc5, wait); orig_RfseqCoreActv = read_phy_reg(pi, 0xa1); @@ -22429,13 +22277,11 @@ void wlc_phy_stopplayback_nphy(struct brcms_phy *pi) wlc_phy_stay_in_carriersearch_nphy(pi, true); playback_status = read_phy_reg(pi, 0xc7); - if (playback_status & 0x1) { + if (playback_status & 0x1) or_phy_reg(pi, 0xc3, NPHY_sampleCmd_STOP); - } else if (playback_status & 0x2) { - + else if (playback_status & 0x2) and_phy_reg(pi, 0xc2, (u16) ~NPHY_iqloCalCmdGctl_IQLO_CAL_EN); - } and_phy_reg(pi, 0xc3, (u16) ~(0x1 << 2)); @@ -22523,10 +22369,10 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) wlc_phy_get_ipa_gaintbl_nphy(pi); } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(phyrev, 3)) { + if (NREV_IS(phyrev, 3)) tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev3; - } else if (NREV_IS(phyrev, 4)) { + else if (NREV_IS(phyrev, 4)) tx_pwrctrl_tbl = (pi->srom_fem5g. extpagain == @@ -22534,34 +22380,30 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) nphy_tpc_5GHz_txgain_HiPwrEPA : nphy_tpc_5GHz_txgain_rev4; - } else { + else tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev5; - } } else { if (NREV_GE(phyrev, 7)) { if (pi->pubpi. - radiorev == 3) { + radiorev == 3) tx_pwrctrl_tbl = nphy_tpc_txgain_epa_2057rev3; - } else if (pi->pubpi. + else if (pi->pubpi. radiorev == - 5) { + 5) tx_pwrctrl_tbl = nphy_tpc_txgain_epa_2057rev5; - } - } else { if (NREV_GE(phyrev, 5) && (pi->srom_fem2g. extpagain == - 3)) { + 3)) tx_pwrctrl_tbl = nphy_tpc_txgain_HiPwrEPA; - } else { + else tx_pwrctrl_tbl = nphy_tpc_txgain_rev3; - } } } } @@ -22626,26 +22468,26 @@ wlc_phy_iqcal_gainparams_nphy(struct brcms_phy *pi, u16 core_no, u8 band_idx = (CHSPEC_IS5G(pi->radio_chanspec) ? 1 : 0); if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) params->txlpf = target_gain.txlpf[core_no]; - } + params->txgm = target_gain.txgm[core_no]; params->pga = target_gain.pga[core_no]; params->pad = target_gain.pad[core_no]; params->ipa = target_gain.ipa[core_no]; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) params->cal_gain = ((params->txlpf << 15) | (params-> txgm << 12) | (params-> pga << 8) | (params->pad << 3) | (params->ipa)); - } else { + else params->cal_gain = ((params->txgm << 12) | (params-> pga << 8) | (params-> pad << 4) | (params->ipa)); - } + params->ncorr[0] = 0x79; params->ncorr[1] = 0x79; params->ncorr[2] = 0x79; @@ -22734,19 +22576,15 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) if (pi->use_int_tx_iqlo_cal_nphy) { WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MUX, 0x4); - if (! - (pi-> - internal_tx_iqlo_cal_tapoff_intpa_nphy)) { - + if (!(pi-> + internal_tx_iqlo_cal_tapoff_intpa_nphy)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, 0x31); - } else { - + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, 0x21); - } } WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, 0x00); @@ -22767,19 +22605,15 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MUX, 0x06); - if (! - (pi-> - internal_tx_iqlo_cal_tapoff_intpa_nphy)) { - + if (!(pi-> + internal_tx_iqlo_cal_tapoff_intpa_nphy)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, 0x31); - } else { - + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, 0x21); - } } WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, 0x00); @@ -22912,19 +22746,16 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | jtag_core, 0x06); - if (NREV_LT(pi->pubpi.phy_rev, 5)) { - + if (NREV_LT(pi->pubpi.phy_rev, 5)) write_radio_reg(pi, RADIO_2056_TX_TSSIG | jtag_core, 0x11); - } else { - + else write_radio_reg(pi, RADIO_2056_TX_TSSIG | jtag_core, 0x1); - } } else { write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX @@ -23171,23 +23002,20 @@ static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) pi->tx_rx_cal_phy_saveregs[7] = read_phy_reg(pi, 0x91); pi->tx_rx_cal_phy_saveregs[8] = read_phy_reg(pi, 0x92); - if (!(pi->use_int_tx_iqlo_cal_nphy)) { - + if (!(pi->use_int_tx_iqlo_cal_nphy)) wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 1, RADIO_MIMO_CORESEL_CORE1 | RADIO_MIMO_CORESEL_CORE2); - } else { - + else wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 0, RADIO_MIMO_CORESEL_CORE1 | RADIO_MIMO_CORESEL_CORE2); - } wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_TRSW, @@ -23205,12 +23033,11 @@ static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) 0x29b, (0x1 << 0), (0) << 0); if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) { + || NREV_GE(pi->pubpi.phy_rev, 8)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), wlc_phy_read_lpf_bw_ctl_nphy (pi, 0), 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } if (pi->use_int_tx_iqlo_cal_nphy && !(pi->internal_tx_iqlo_cal_tapoff_intpa_nphy)) { @@ -23302,11 +23129,10 @@ static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) write_phy_reg(pi, 0x29b, pi->tx_rx_cal_phy_saveregs[10]); if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) { + || NREV_GE(pi->pubpi.phy_rev, 8)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, 1, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } wlc_phy_resetcca_nphy(pi); @@ -23390,17 +23216,15 @@ wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, u8 num_samps) pwrindex[0] = idle_tssi[0] - tssival[0] + 64; pwrindex[1] = idle_tssi[1] - tssival[1] + 64; - if (pwrindex[0] < 0) { + if (pwrindex[0] < 0) pwrindex[0] = 0; - } else if (pwrindex[0] > 63) { + else if (pwrindex[0] > 63) pwrindex[0] = 63; - } - if (pwrindex[1] < 0) { + if (pwrindex[1] < 0) pwrindex[1] = 0; - } else if (pwrindex[1] > 63) { + else if (pwrindex[1] > 63) pwrindex[1] = 63; - } wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 1, (u32) pwrindex[0], 32, &qdBm_pwrbuf[0]); @@ -23488,22 +23312,19 @@ static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) save_bbmult = true; } } else { - wlc_phy_internal_cal_txgain_nphy(pi); save_bbmult = true; } } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) wlc_phy_cal_txgainctrl_nphy(pi, 12, false); - } else { + else wlc_phy_cal_txgainctrl_nphy(pi, 14, false); - } } else { - wlc_phy_internal_cal_txgain_nphy(pi); save_bbmult = true; } @@ -23513,10 +23334,9 @@ static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) wlc_phy_cal_txgainctrl_nphy(pi, 10, false); } - if (save_bbmult) { + if (save_bbmult) wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &pi->nphy_txcal_bbmult); - } } void @@ -23536,19 +23356,15 @@ wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, uint stepsize; bool phyhang_avoid_state = false; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - + if (NREV_GE(pi->pubpi.phy_rev, 7)) stepsize = 2; - } else { - + else stepsize = 1; - } - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) freq_test = 5000; - } else { + else freq_test = 2500; - } wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); @@ -23596,11 +23412,10 @@ wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, false); - if (core == PHY_CORE_0) { + if (core == PHY_CORE_0) curr_m0m1 = m0m1 & 0xff00; - } else { + else curr_m0m1 = m0m1 & 0x00ff; - } wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &curr_m0m1); wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &curr_m0m1); @@ -23616,25 +23431,22 @@ wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, delta_power = (dBm_targetpower * 4) - qdBm_power[core]; txpwrindex -= stepsize * delta_power; - if (txpwrindex < 0) { + if (txpwrindex < 0) txpwrindex = 0; - } else if (txpwrindex > 127) { + else if (txpwrindex > 127) txpwrindex = 127; - } if (CHSPEC_IS5G(pi->radio_chanspec)) { if (NREV_IS(pi->pubpi.phy_rev, 4) && (pi->srom_fem5g.extpagain == 3)) { - if (txpwrindex < 30) { + if (txpwrindex < 30) txpwrindex = 30; - } } } else { if (NREV_GE(pi->pubpi.phy_rev, 5) && (pi->srom_fem2g.extpagain == 3)) { - if (txpwrindex < 50) { + if (txpwrindex < 50) txpwrindex = 50; - } } } @@ -23751,19 +23563,17 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) else if (caltype == PHY_PERICAL_PARTIAL) fullcal = false; - if (pi->cal_type_override != PHY_PERICAL_AUTO) { + if (pi->cal_type_override != PHY_PERICAL_AUTO) fullcal = (pi->cal_type_override == PHY_PERICAL_FULL) ? true : false; - } if ((pi->mphase_cal_phase_id > MPHASE_CAL_STATE_INIT)) { if (pi->nphy_txiqlocal_chanspec != pi->radio_chanspec) wlc_phy_cal_perical_mphase_restart(pi); } - if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_RXCAL)) { + if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_RXCAL)) wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); - } wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -23829,9 +23639,8 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) pi->nphy_perical_last = pi->sh->now; } } - if (caltype != PHY_PERICAL_AUTO) { + if (caltype != PHY_PERICAL_AUTO) wlc_phy_rssi_cal_nphy(pi); - } if (pi->first_cal_after_assoc || (pi->cal_type_override == PHY_PERICAL_FULL)) { @@ -23840,18 +23649,17 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) wlc_phy_txpwrctrl_pwr_setup_nphy(pi); } - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_radio205x_vcocal_nphy(pi); - } } else { switch (pi->mphase_cal_phase_id) { case MPHASE_CAL_STATE_INIT: pi->nphy_perical_last = pi->sh->now; pi->nphy_txiqlocal_chanspec = pi->radio_chanspec; - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_precal_txgain_nphy(pi); - } + pi->nphy_cal_target_gain = wlc_phy_get_tx_gain_nphy(pi); pi->mphase_cal_phase_id++; break; @@ -23875,20 +23683,19 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) if (NREV_LE(pi->pubpi.phy_rev, 2) && (pi->mphase_cal_phase_id == - MPHASE_CAL_STATE_TXPHASE4)) { + MPHASE_CAL_STATE_TXPHASE4)) pi->mphase_cal_phase_id += 2; - } else { + else pi->mphase_cal_phase_id++; - } break; case MPHASE_CAL_STATE_PAPDCAL: if ((pi->radar_percal_mask & 0x2) != 0) pi->nphy_rxcal_active = true; - if (PHY_IPA(pi)) { + if (PHY_IPA(pi)) wlc_phy_a4(pi, true); - } + pi->mphase_cal_phase_id++; break; @@ -23899,9 +23706,8 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) (pi->first_cal_after_assoc || (pi->cal_type_override == PHY_PERICAL_FULL)) ? 2 : 0, - false) == 0) { + false) == 0) wlc_phy_savecal_nphy(pi); - } pi->mphase_cal_phase_id++; break; @@ -23912,16 +23718,15 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) wlc_phy_txpwrctrl_coeff_setup_nphy(pi); wlc_phy_rssi_cal_nphy(pi); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_radio205x_vcocal_nphy(pi); - } + restore_tx_gain = true; - if (pi->first_cal_after_assoc) { + if (pi->first_cal_after_assoc) pi->mphase_cal_phase_id++; - } else { + else wlc_phy_cal_perical_mphase_reset(pi); - } break; @@ -24071,11 +23876,10 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, pi->phyhang_avoid = false; } - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) phy_bw = 40; - } else { + else phy_bw = 20; - } wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); @@ -24117,11 +23921,10 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, 16, tbl_ptr); } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) write_phy_reg(pi, 0xc2, 0x8ad9); - } else { + else write_phy_reg(pi, 0xc2, 0x8aa9); - } max_val = 250; tone_freq = (phy_bw == 20) ? 2500 : 5000; @@ -24139,19 +23942,15 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) { tbl_ptr = pi->mphase_txcal_bestcoeffs; tbl_len = ARRAY_SIZE(pi->mphase_txcal_bestcoeffs); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - + if (NREV_LT(pi->pubpi.phy_rev, 3)) tbl_len -= 2; - } } else { if ((!fullcal) && (pi->nphy_txiqlocal_coeffsvalid)) { tbl_ptr = pi->nphy_txiqlocal_bestc; tbl_len = ARRAY_SIZE(pi->nphy_txiqlocal_bestc); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - + if (NREV_LT(pi->pubpi.phy_rev, 3)) tbl_len -= 2; - } } else { fullcal = true; @@ -24185,11 +23984,10 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, if (mphase) { cal_cnt = pi->mphase_txcal_cmdidx; - if ((cal_cnt + pi->mphase_txcal_numcmds) < max_cal_cmds) { + if ((cal_cnt + pi->mphase_txcal_numcmds) < max_cal_cmds) num_cals = cal_cnt + pi->mphase_txcal_numcmds; - } else { + else num_cals = max_cal_cmds; - } } else { cal_cnt = 0; num_cals = max_cal_cmds; @@ -24303,10 +24101,9 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, 16, tbl_buf); tbl_len = ARRAY_SIZE(pi->nphy_txiqlocal_bestc); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - + if (NREV_LT(pi->pubpi.phy_rev, 3)) tbl_len -= 2; - } + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, tbl_len, 96, 16, pi->nphy_txiqlocal_bestc); @@ -24315,10 +24112,9 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, pi->nphy_txiqlocal_chanspec = pi->radio_chanspec; } else { tbl_len = ARRAY_SIZE(pi->mphase_txcal_bestcoeffs); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - + if (NREV_LT(pi->pubpi.phy_rev, 3)) tbl_len -= 2; - } + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, tbl_len, 96, 16, pi->mphase_txcal_bestcoeffs); @@ -24343,9 +24139,8 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, wlc_phy_tx_iq_war_nphy(pi); } - if (NREV_GE(pi->pubpi.phy_rev, 4)) { + if (NREV_GE(pi->pubpi.phy_rev, 4)) pi->phyhang_avoid = phyhang_avoid_state; - } wlc_phy_stay_in_carriersearch_nphy(pi, false); @@ -24946,37 +24741,35 @@ static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) } if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev >= 5) { + if (pi->pubpi.radiorev >= 5) write_radio_reg(pi, RADIO_2056_RX_LNAA_MASTER | RADIO_2056_RX0, pi-> tx_rx_cal_radio_saveregs [4]); - } else { + else write_radio_reg(pi, RADIO_2056_RX_LNAA_TUNE | RADIO_2056_RX0, pi-> tx_rx_cal_radio_saveregs [4]); - } } else { - if (pi->pubpi.radiorev >= 5) { + if (pi->pubpi.radiorev >= 5) write_radio_reg(pi, RADIO_2056_RX_LNAG_MASTER | RADIO_2056_RX0, pi-> tx_rx_cal_radio_saveregs [4]); - } else { + else write_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | RADIO_2056_RX0, pi-> tx_rx_cal_radio_saveregs [4]); - } } } else { @@ -25005,37 +24798,35 @@ static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) } if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev >= 5) { + if (pi->pubpi.radiorev >= 5) write_radio_reg(pi, RADIO_2056_RX_LNAA_MASTER | RADIO_2056_RX1, pi-> tx_rx_cal_radio_saveregs [4]); - } else { + else write_radio_reg(pi, RADIO_2056_RX_LNAA_TUNE | RADIO_2056_RX1, pi-> tx_rx_cal_radio_saveregs [4]); - } } else { - if (pi->pubpi.radiorev >= 5) { + if (pi->pubpi.radiorev >= 5) write_radio_reg(pi, RADIO_2056_RX_LNAG_MASTER | RADIO_2056_RX1, pi-> tx_rx_cal_radio_saveregs [4]); - } else { + else write_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | RADIO_2056_RX1, pi-> tx_rx_cal_radio_saveregs [4]); - } } } } @@ -25046,12 +24837,10 @@ static void wlc_phy_rxcal_physetup_nphy(struct brcms_phy *pi, u8 rx_core) u8 tx_core; u16 rx_antval, tx_antval; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - + if (NREV_GE(pi->pubpi.phy_rev, 7)) tx_core = rx_core; - } else { + else tx_core = (rx_core == PHY_CORE_0) ? 1 : 0; - } pi->tx_rx_cal_phy_saveregs[0] = read_phy_reg(pi, 0xa2); pi->tx_rx_cal_phy_saveregs[1] = @@ -25122,17 +24911,17 @@ static void wlc_phy_rxcal_physetup_nphy(struct brcms_phy *pi, u8 rx_core) NPHY_REV7_RFCTRLOVERRIDE_ID2); wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); - if (CHSPEC_IS40(pi->radio_chanspec)) { + if (CHSPEC_IS40(pi->radio_chanspec)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 2, 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } else { + else wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); @@ -25217,12 +25006,10 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, s8 txpwrindex; u16 nphy_rxcal_txgain[2]; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - + if (NREV_GE(pi->pubpi.phy_rev, 7)) tx_core = rx_core; - } else { + else tx_core = 1 - rx_core; - } num_samps = 1024; desired_log2_pwr = (cal_type == 0) ? 13 : 13; @@ -25232,24 +25019,21 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, wlc_phy_rx_iq_coeffs_nphy(pi, 1, &zero_comp); if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) mix_tia_gain = 3; - } else if (NREV_GE(pi->pubpi.phy_rev, 4)) { + else if (NREV_GE(pi->pubpi.phy_rev, 4)) mix_tia_gain = 4; - } else { + else mix_tia_gain = 6; - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_5GHz_rev7; - } else { + else nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_5GHz; - } } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_2GHz_rev7; - } else { + else nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_2GHz; - } } do { @@ -25262,7 +25046,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, lna1 = nphy_rxcal_gaintbl[curr_gaintbl_index].lna1; txpwrindex = nphy_rxcal_gaintbl[curr_gaintbl_index].txpwrindex; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_rxgain, ((lpf_biq1 << 12) | @@ -25270,7 +25054,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, (mix_tia_gain << 4) | (lna2 << 2) | lna1), 0x3, 0); - } else { + else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), ((hpvga << 12) | (lpf_biq1 << 10) | @@ -25278,7 +25062,6 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, (mix_tia_gain << 4) | (lna2 << 2) | lna1), 0x3, 0); - } pi->nphy_rxcal_pwr_idx[tx_core] = txpwrindex; @@ -25367,11 +25150,11 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, if (NREV_GE(pi->pubpi.phy_rev, 7)) { fine_gain_idx = (int)lpf_biq1 + delta_pwr; - if (fine_gain_idx + (int)lpf_biq0 > 10) { + if (fine_gain_idx + (int)lpf_biq0 > 10) lpf_biq1 = 10 - lpf_biq0; - } else { + else lpf_biq1 = (u16) max(fine_gain_idx, 0); - } + wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_rxgain, ((lpf_biq1 << 12) | @@ -25444,9 +25227,8 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) u16 num_samps, log_num_samps = 10; struct phy_iq_est est[PHY_CORE_MAX]; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) return 0; - } num_samps = (1 << log_num_samps); @@ -25549,17 +25331,16 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - if (core_idx == 0) { + if (core_idx == 0) ref_iq_vals = max_t(u32, (est[0].i_pwr + est[0].q_pwr) >> (log_num_samps + 1), 1); - } else { + else ref_iq_vals = max_t(u32, (est[1].i_pwr + est[1].q_pwr) >> (log_num_samps + 1), 1); - } wlc_phy_tx_tone_nphy(pi, target_bw, NPHY_RXCAL_TONEAMP, 0, 1, false); @@ -25568,20 +25349,20 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - if (core_idx == 0) { + if (core_idx == 0) target_iq_vals = (est[0].i_pwr + est[0].q_pwr) >> (log_num_samps + 1); - } else { + else target_iq_vals = (est[1].i_pwr + est[1].q_pwr) >> (log_num_samps + 1); - } + pwr_ratio = (uint) ((target_iq_vals << 16) / ref_iq_vals); - if (rccal_stepsize == 0) { + if (rccal_stepsize == 0) rccal_stepsize--; - } else if (rccal_stepsize == 1) { + else if (rccal_stepsize == 1) { last_rccal_val = rccal_val; rccal_val += (pwr_ratio > target_pwr_ratio) ? 1 : -1; last_pwr_ratio = pwr_ratio; @@ -25601,14 +25382,12 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) if (CHSPEC_IS40(pi->radio_chanspec)) { if ((best_rccal_val > 140) - || (best_rccal_val < 135)) { + || (best_rccal_val < 135)) best_rccal_val = 138; - } } else { if ((best_rccal_val > 142) - || (best_rccal_val < 137)) { + || (best_rccal_val < 137)) best_rccal_val = 140; - } } write_radio_reg(pi, @@ -25721,10 +25500,9 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, if (rx_core == PHY_CORE_1) { - if (rxcore_state == 1) { + if (rxcore_state == 1) wlc_phy_rxcore_setstate_nphy( (struct brcms_phy_pub *) pi, 3); - } wlc_phy_rxcal_gainctrl_nphy(pi, rx_core, NULL, 1); @@ -25733,11 +25511,10 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, wlc_phy_rc_sweep_nphy(pi, rx_core, 1); pi->nphy_rccal_value = best_rccal[rx_core]; - if (rxcore_state == 1) { + if (rxcore_state == 1) wlc_phy_rxcore_setstate_nphy( (struct brcms_phy_pub *) pi, rxcore_state); - } } } @@ -25787,21 +25564,20 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, wlc_phy_resetcca_nphy(pi); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_rxgain, 0, 0x3, 1); - } else { + else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); - } + wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); - if (NREV_GE(pi->pubpi.phy_rev, 4)) { + if (NREV_GE(pi->pubpi.phy_rev, 4)) pi->phyhang_avoid = phyhang_avoid_state; - } wlc_phy_stay_in_carriersearch_nphy(pi, false); @@ -25835,10 +25611,8 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, wlc_phy_stay_in_carriersearch_nphy(pi, true); - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - + if (NREV_LT(pi->pubpi.phy_rev, 2)) wlc_phy_reapply_txcal_coeffs_nphy(pi); - } wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); @@ -25874,19 +25648,16 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, ((0x1 << 1) | (0x1 << 2))); or_phy_reg(pi, 0xa5, ((0x1 << 1) | (0x1 << 2))); - if (((pi->nphy_rxcalparams) & 0xff000000)) { - + if (((pi->nphy_rxcalparams) & 0xff000000)) write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x91 : 0x92, (CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110)); - } else { - + else write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x91 : 0x92, (CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120)); - } write_phy_reg(pi, (tx_core == PHY_CORE_0) ? 0x91 : 0x92, (CHSPEC_IS5G(pi->radio_chanspec) ? 0x148 : @@ -25950,11 +25721,10 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, hpf_change = desired_log2_pwr - actual_log2_pwr; curr_hpf += hpf_change; curr_hpf = max(min_t(u16, curr_hpf, 10), 0); - if (use_hpf_num == 1) { + if (use_hpf_num == 1) curr_hpf1 = curr_hpf; - } else { + else curr_hpf2 = curr_hpf; - } } wlc_phy_rfctrl_override_nphy(pi, (0x1 << 10), @@ -26038,16 +25808,14 @@ int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, u8 cal_type, bool debug) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - + if (NREV_GE(pi->pubpi.phy_rev, 7)) cal_type = 0; - } - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + if (NREV_GE(pi->pubpi.phy_rev, 3)) return wlc_phy_cal_rxiq_nphy_rev3(pi, target_gain, cal_type, debug); - } else { + else return wlc_phy_cal_rxiq_nphy_rev2(pi, target_gain, debug); - } } static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi) @@ -26055,46 +25823,39 @@ static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi) int j, type = 2; u16 addr_offset = 0x2c5; - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, addr_offset + j, NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); - } } static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) { int j, type; - u16 addr_offset[] = { 0x186, 0x195, - 0x2c5 - }; + u16 addr_offset[] = { 0x186, 0x195, 0x2c5}; for (type = 0; type < 3; type++) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, addr_offset[type] + j, NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); - } } if (IS40MHZ(pi)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x186 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x186 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[5] [j]); - } } if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x2c5 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[6] [j]); - } } } } @@ -26104,15 +25865,13 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) int j; if (IS40MHZ(pi)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x195 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[4][j]); - } } else { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x186 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } } } @@ -26138,55 +25897,39 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) u32 *tx_pwrctrl_tbl = NULL; if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - + || (pi->pubpi.radiorev == 6)) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_2g_2057rev4n6; - } else if (pi->pubpi.radiorev == 3) { - + else if (pi->pubpi.radiorev == 3) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_2g_2057rev3; - } else if (pi->pubpi.radiorev == 5) { - + else if (pi->pubpi.radiorev == 5) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_2g_2057rev5; - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_2g_2057rev7; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev6; } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev5; } else { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa; } - } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - + (pi->pubpi.radiorev == 6)) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057; - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057rev7; - } - } else { tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g; } @@ -26207,39 +25950,29 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) { + || NREV_GE(pi->pubpi.phy_rev, 8)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), wlc_phy_read_lpf_bw_ctl_nphy (pi, 0), 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 5) { + if (pi->pubpi.radiorev == 5) mixgain = (core == 0) ? 0x20 : 0x00; - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) mixgain = 0x00; - - } else if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) { - + else if ((pi->pubpi.radiorev <= 4) + || (pi->pubpi.radiorev == 6)) mixgain = 0x00; - } - } else { if ((pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - + (pi->pubpi.radiorev == 6)) mixgain = 0x50; - } else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + else if ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) mixgain = 0x0; - } } wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), @@ -26323,30 +26056,22 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - + (pi->pubpi.radiorev == 6)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_2G_ATTEN, 0xf0); - - } else if (pi->pubpi.radiorev == 5) { - + else if (pi->pubpi.radiorev == 5) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_2G_ATTEN, (core == 0) ? 0xf7 : 0xf2); - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_2G_ATTEN, 0xf0); - } - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, TXRXCOUPLE_2G_PWRUP, 0x0); WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, TXRXCOUPLE_2G_ATTEN, 0xff); - } else { state->pwrup[core] = READ_RADIO_REG3(pi, RADIO_2057, TX, core, @@ -26365,15 +26090,13 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, TXRXCOUPLE_5G_PWRUP, 0xc); if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - + || (pi->pubpi.radiorev == 8)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_5G_ATTEN, 0xf4); - } else { + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_5G_ATTEN, 0xf0); - } WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, TXRXCOUPLE_5G_PWRUP, 0x0); @@ -26492,15 +26215,15 @@ wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, } } - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { + if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 0, NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else { + else wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 0, 0x3, 1, NPHY_REV7_RFCTRLOVERRIDE_ID0); - } + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 0, 0x3, 1, NPHY_REV7_RFCTRLOVERRIDE_ID1); @@ -26547,13 +26270,11 @@ wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, (state->mm & 0xff)); if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) { + || NREV_GE(pi->pubpi.phy_rev, 8)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, 1, NPHY_REV7_RFCTRLOVERRIDE_ID1); - } } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 0x3, 1); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 1); @@ -26601,9 +26322,8 @@ wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32 start, sz = end - start + 1; buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC); - if (NULL == buf) { + if (NULL == buf) return; - } src = buf; dst = buf + NPHY_PAPD_EPS_TBL_SIZE; @@ -26667,18 +26387,17 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, phy_a9 = wlc_phy_get_tx_gain_nphy(pi); - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) phy_a5 = ((phy_a9.txlpf[core] << 15) | (phy_a9.txgm[core] << 12) | (phy_a9.pga[core] << 8) | (txgains->gains.pad[core] << 3) | (phy_a9.ipa[core])); - } else { + else phy_a5 = ((phy_a9.txlpf[core] << 15) | (phy_a9.txgm[core] << 12) | (txgains->gains.pga[core] << 8) | (phy_a9.pad[core] << 3) | (phy_a9.ipa[core])); - } wlc_phy_rfctrl_override_1tomany_nphy(pi, NPHY_REV7_RfctrlOverride_cmd_txgain, @@ -26686,14 +26405,10 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) { - + || (pi->pubpi.radiorev == 6)) m[core] = IS40MHZ(pi) ? 60 : 79; - } else { - + else m[core] = IS40MHZ(pi) ? 45 : 64; - } - } else { m[core] = IS40MHZ(pi) ? 75 : 107; } @@ -26726,16 +26441,15 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, if (cal_mode == CAL_GCTRL) { if ((pi->pubpi.radiorev == 5) - && (CHSPEC_IS2G(pi->radio_chanspec))) { + && (CHSPEC_IS2G(pi->radio_chanspec))) phy_a1 = 55; - } else if (((pi->pubpi.radiorev == 7) && + else if (((pi->pubpi.radiorev == 7) && (CHSPEC_IS2G(pi->radio_chanspec))) || ((pi->pubpi.radiorev == 8) && - (CHSPEC_IS2G(pi->radio_chanspec)))) { + (CHSPEC_IS2G(pi->radio_chanspec)))) phy_a1 = 60; - } else { + else phy_a1 = 63; - } } else if ((cal_mode != CAL_FULL) && (cal_mode != CAL_SOFT)) { @@ -26796,9 +26510,8 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, 32, &phy_a8); if (cal_mode != CAL_GCTRL) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) wlc_phy_a1_nphy(pi, core, 5, 0, 35); - } } wlc_phy_rfctrl_override_1tomany_nphy(pi, @@ -26834,11 +26547,10 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, } } - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) m[core] = IS40MHZ(pi) ? 45 : 64; - } else { + else m[core] = IS40MHZ(pi) ? 75 : 107; - } m[phy_a7] = 0; wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); @@ -26928,9 +26640,8 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, 32, &phy_a8); - if (cal_mode != CAL_GCTRL) { + if (cal_mode != CAL_GCTRL) wlc_phy_a1_nphy(pi, core, 5, 0, 40); - } } } @@ -26990,13 +26701,12 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) phy_a14 = 0; for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) phy_a4.gains.pad[core] = (u16) phy_a15[phy_a12]; - } else { + else phy_a4.gains.pga[core] = (u16) phy_a15[phy_a12]; - } wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); @@ -27013,9 +26723,9 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) (phy_a8 == 4095) || (phy_a8 == -4096)); if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) { + if (!phy_a3) phy_a12 -= (u8) phy_a1; - } + phy_a11 = true; break; } @@ -27026,11 +26736,11 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) phy_a12 -= (u8) phy_a1; if ((phy_a12 < phy_a14) || (phy_a12 > phy_a13)) { - if (phy_a12 < phy_a14) { + if (phy_a12 < phy_a14) phy_a12 = phy_a14; - } else { + else phy_a12 = phy_a13; - } + phy_a11 = true; break; } @@ -27059,9 +26769,9 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) (phy_a8 == 4095) || (phy_a8 == -4096)); if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) { + if (!phy_a3) phy_a12 -= (u8) phy_a1; - } + phy_a11 = true; break; } @@ -27072,11 +26782,11 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) phy_a12 -= (u8) phy_a1; if ((phy_a12 < 0) || (phy_a12 > 127)) { - if (phy_a12 < 0) { + if (phy_a12 < 0) phy_a12 = 0; - } else { + else phy_a12 = 127; - } + phy_a11 = true; break; } @@ -27087,11 +26797,10 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) return (u8) phy_a15[phy_a12]; - } else { + else return (u8) phy_a12; - } } @@ -27117,9 +26826,8 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!phy_b3) { + if (!phy_b3) wlapi_suspend_mac_and_wait(pi->sh->physhim); - } wlc_phy_stay_in_carriersearch_nphy(pi, true); @@ -27148,14 +26856,13 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { s32 i, val = 0; - for (i = 0; i < 64; i++) { + for (i = 0; i < 64; i++) wlc_phy_table_write_nphy(pi, ((phy_b5 == PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 : NPHY_TBL_ID_EPSILONTBL1), 1, i, 32, &val); - } } wlc_phy_ipa_restore_tx_digi_filts_nphy(pi); @@ -27166,16 +26873,12 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { - pi->nphy_papd_cal_gain_index[phy_b5] = 23; - } else if (pi->pubpi.radiorev == 5) { - pi->nphy_papd_cal_gain_index[phy_b5] = 0; pi->nphy_papd_cal_gain_index[phy_b5] = @@ -27229,27 +26932,24 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) break; } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - } } - if (NREV_LT(pi->pubpi.phy_rev, 7)) { + if (NREV_LT(pi->pubpi.phy_rev, 7)) wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - } for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { int eps_offset = 0; if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 3) { + if (pi->pubpi.radiorev == 3) eps_offset = -2; - } else if (pi->pubpi.radiorev == 5) { + else if (pi->pubpi.radiorev == 5) eps_offset = 3; - } else { + else eps_offset = -1; - } } else { eps_offset = 2; } @@ -27282,40 +26982,37 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5]; if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { + (pi->pubpi.radiorev == 6)) phy_b11 = -(nphy_papd_pgagain_dlt_5g_2057 [phy_b7] + 1) / 2; - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) phy_b11 = -(nphy_papd_pgagain_dlt_5g_2057rev7 [phy_b7] + 1) / 2; - } phy_b10 = -9; } - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) phy_b6 = -60 + 27 + eps_offset + phy_b12 + phy_b10; - } else { + else phy_b6 = -60 + 27 + eps_offset + phy_b11 + phy_b10; - } mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : 0x29c, (0x1ff << 7), (phy_b6) << 7); pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; } else { - if (NREV_LT(pi->pubpi.phy_rev, 5)) { + if (NREV_LT(pi->pubpi.phy_rev, 5)) eps_offset = 4; - } else { + else eps_offset = 2; - } phy_b7 = 15 - ((phy_b1[phy_b5].index) >> 3); @@ -27379,9 +27076,8 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) wlc_phy_stay_in_carriersearch_nphy(pi, false); - if (!phy_b3) { + if (!phy_b3) wlapi_enable_mac(pi->sh->physhim); - } } void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) @@ -27423,11 +27119,10 @@ void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) } } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) txpi[0] = txpi[1] = 30; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + else if (NREV_GE(pi->pubpi.phy_rev, 3)) txpi[0] = txpi[1] = 40; - } if (NREV_LT(pi->pubpi.phy_rev, 7)) { @@ -27497,12 +27192,12 @@ void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) bbmult = (txgain >> 0) & ((1 << (7 - 0 + 1)) - 1); - if (NREV_GE(phyrev, 3)) { + if (NREV_GE(phyrev, 3)) mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : 0xa5), (0x1 << 8), (0x1 << 8)); - } else { + else mod_phy_reg(pi, 0xa5, (0x1 << 14), (0x1 << 14)); - } + write_phy_reg(pi, (core == PHY_CORE_0) ? 0xaa : 0xab, dac_gain); wlc_phy_table_write_nphy(pi, 7, 1, (0x110 + core), 16, @@ -27562,9 +27257,8 @@ wlc_phy_txpwr_nphy_po_apply(u8 *srom_max, u8 pwr_offset, { u8 rate; - for (rate = rate_start; rate <= rate_end; rate++) { + for (rate = rate_start; rate <= rate_end; rate++) srom_max[rate] -= 2 * pwr_offset; - } } void @@ -27696,12 +27390,10 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) TXP_FIRST_MCS_20_CDD, TXP_LAST_MCS_20_CDD); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, tmp_cddpo, TXP_FIRST_MCS_20_CDD, TXP_LAST_MCS_20_CDD); - } wlc_phy_mcs_to_ofdm_powers_nphy(tx_srom_max_rate, TXP_FIRST_OFDM_20_CDD, @@ -27713,13 +27405,11 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) TXP_FIRST_MCS_20_STBC, TXP_LAST_MCS_20_STBC); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, tmp_stbcpo, TXP_FIRST_MCS_20_STBC, TXP_LAST_MCS_20_STBC); - } wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, &pwr_offsets2[2], tmp_max_pwr, @@ -27779,12 +27469,11 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) tx_srom_max_rate[rate2]; } - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, tmp_bw40po, TXP_FIRST_OFDM_40_SISO, TXP_LAST_MCS_40_SDM); - } tx_srom_max_rate[TXP_MCS_32] = tx_srom_max_rate[TXP_FIRST_MCS_40_CDD]; @@ -27798,10 +27487,8 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) u16 bw40po, cddpo, stbcpo, bwduppo; uint band_num; - if (pi->sh->sromrev >= 9) { - + if (pi->sh->sromrev >= 9) return; - } bw40po = (u16) PHY_GETINTVAR(pi, "bw40po"); pi->bw402gpo = bw40po & 0xf; @@ -28018,43 +27705,37 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) pi->srom_fem5g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain5g"); pi->srom_fem5g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange5g"); pi->srom_fem5g.triso = (u8) PHY_GETINTVAR(pi, "triso5g"); - if (PHY_GETVAR(pi, "antswctl5g")) { - + if (PHY_GETVAR(pi, "antswctl5g")) pi->srom_fem5g.antswctrllut = (u8) PHY_GETINTVAR(pi, "antswctl5g"); - } else { - + else pi->srom_fem5g.antswctrllut = (u8) PHY_GETINTVAR(pi, "antswctl2g"); - } wlc_phy_txpower_ipa_upd(pi); pi->phy_txcore_disable_temp = (s16) PHY_GETINTVAR(pi, "tempthresh"); - if (pi->phy_txcore_disable_temp == 0) { + if (pi->phy_txcore_disable_temp == 0) pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - } pi->phy_tempsense_offset = (s8) PHY_GETINTVAR(pi, "tempoffset"); if (pi->phy_tempsense_offset != 0) { if (pi->phy_tempsense_offset > - (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) { + (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) pi->phy_tempsense_offset = NPHY_SROM_MAXTEMPOFFSET; - } else if (pi->phy_tempsense_offset < (NPHY_SROM_TEMPSHIFT + - NPHY_SROM_MINTEMPOFFSET)) { + else if (pi->phy_tempsense_offset < (NPHY_SROM_TEMPSHIFT + + NPHY_SROM_MINTEMPOFFSET)) pi->phy_tempsense_offset = NPHY_SROM_MINTEMPOFFSET; - } else { + else pi->phy_tempsense_offset -= NPHY_SROM_TEMPSHIFT; - } } pi->phy_txcore_enable_temp = pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; pi->phycal_tempdelta = (u8) PHY_GETINTVAR(pi, "phycal_tempdelta"); - if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) { + if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) pi->phycal_tempdelta = 0; - } wlc_phy_txpwr_srom_read_ppr_nphy(pi); @@ -28107,9 +27788,8 @@ static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | (iqloCalbuf[3] & 0x3ff); - for (idx = 0; idx < tbl_len; idx++) { + for (idx = 0; idx < tbl_len; idx++) regval[idx] = iqcomp; - } wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, regval); } @@ -28168,15 +27848,12 @@ static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, 0); - if (!NREV_IS(pi->pubpi.phy_rev, 7)) { - + if (!NREV_IS(pi->pubpi.phy_rev, 7)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, 0x1); - } else { - + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, 0x31); - } } else { WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MASTER, 0x9); @@ -28186,17 +27863,14 @@ static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) TSSIG, 0); if (pi->pubpi.radiorev != 5) { - if (!NREV_IS(pi->pubpi.phy_rev, 7)) { - + if (!NREV_IS(pi->pubpi.phy_rev, 7)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, 0x1); - } else { - + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, 0x31); - } } } WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_VCM_HG, @@ -28238,14 +27912,12 @@ static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) if (pi->pubpi.radiorev != 5) WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSIA, 0x0); - if (NREV_GE(pi->pubpi.phy_rev, 5)) { - + if (NREV_GE(pi->pubpi.phy_rev, 5)) WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSIG, 0x31); - } else { + else WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSIG, 0x11); - } WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TX_SSI_MUX, 0xe); } else { @@ -28271,17 +27943,15 @@ static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) return; - if (PHY_IPA(pi)) { + if (PHY_IPA(pi)) wlc_phy_ipa_internal_tssi_setup_nphy(pi); - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), 0, 0x3, 0, NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + else if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 0); - } wlc_phy_stopplayback_nphy(pi); @@ -28294,13 +27964,12 @@ static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) wlc_phy_stopplayback_nphy(pi); wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, 0); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), 0, 0x3, 1, NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + else if (NREV_GE(pi->pubpi.phy_rev, 3)) wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 1); - } if (NREV_GE(pi->pubpi.phy_rev, 3)) { @@ -28351,12 +28020,10 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) or_phy_reg(pi, 0x122, (0x1 << 0)); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) and_phy_reg(pi, 0x1e7, (u16) (~(0x1 << 15))); - } else { - + else or_phy_reg(pi, 0x1e7, (0x1 << 15)); - } if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); @@ -28451,26 +28118,22 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) target_pwr_qtrdbm[1] = (s8) pi->tx_power_max; if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->srom_fem2g.tssipos) { + if (pi->srom_fem2g.tssipos) or_phy_reg(pi, 0x1e9, (0x1 << 14)); - } if (NREV_GE(pi->pubpi.phy_rev, 7)) { for (core = 0; core <= 1; core++) { if (PHY_IPA(pi)) { - - if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MUX, 0xe); - } else { + else WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MUX, 0xc); - } - } else { } } } else { @@ -28503,21 +28166,19 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) udelay(1); } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) mod_phy_reg(pi, 0x1e7, (0x7f << 0), (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - } else { + else mod_phy_reg(pi, 0x1e7, (0x7f << 0), (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) mod_phy_reg(pi, 0x222, (0xff << 0), (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - } else if (NREV_GT(pi->pubpi.phy_rev, 1)) { + else if (NREV_GT(pi->pubpi.phy_rev, 1)) mod_phy_reg(pi, 0x222, (0xff << 0), (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - } if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); @@ -28622,9 +28283,8 @@ void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi) pi->nphy_papd_tx_gain_at_last_cal[0]) >= 4) || ((u32) ABS(wlc_phy_txpwr_idx_cur_get_nphy(pi, 1) - - pi->nphy_papd_tx_gain_at_last_cal[1]) >= 4))))) { + pi->nphy_papd_tx_gain_at_last_cal[1]) >= 4))))) wlc_phy_a4(pi, true); - } } void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) @@ -28664,23 +28324,20 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) tbl_len = 84; tbl_offset = 64; - for (ctr = 0; ctr < tbl_len; ctr++) { + for (ctr = 0; ctr < tbl_len; ctr++) regval[ctr] = 0; - } wlc_phy_table_write_nphy(pi, 26, tbl_len, tbl_offset, 16, regval); wlc_phy_table_write_nphy(pi, 27, tbl_len, tbl_offset, 16, regval); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - + if (NREV_GE(pi->pubpi.phy_rev, 3)) and_phy_reg(pi, 0x1e7, (u16) (~((0x1 << 15) | (0x1 << 14) | (0x1 << 13)))); - } else { + else and_phy_reg(pi, 0x1e7, (u16) (~((0x1 << 14) | (0x1 << 13)))); - } if (NREV_GE(pi->pubpi.phy_rev, 3)) { or_phy_reg(pi, 0x8f, (0x1 << 8)); @@ -28730,7 +28387,7 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) if (NREV_GE(pi->pubpi.phy_rev, 3)) { if ((pi->nphy_txpwr_idx[0] != 128) - && (pi->nphy_txpwr_idx[1] != 128)) { + && (pi->nphy_txpwr_idx[1] != 128)) wlc_phy_txpwr_idx_cur_set_nphy(pi, pi-> nphy_txpwr_idx @@ -28738,7 +28395,6 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) pi-> nphy_txpwr_idx [1]); - } } if (NREV_GE(pi->pubpi.phy_rev, 3)) { @@ -28799,17 +28455,14 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if ((core_mask & (1 << core)) == 0) { + if ((core_mask & (1 << core)) == 0) continue; - } txpwrctl_tbl = (core == PHY_CORE_0) ? 26 : 27; if (txpwrindex < 0) { - if (pi->nphy_txpwrindex[core].index < 0) { - + if (pi->nphy_txpwrindex[core].index < 0) continue; - } if (NREV_GE(pi->pubpi.phy_rev, 3)) { mod_phy_reg(pi, 0x8f, @@ -28927,22 +28580,22 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, (tx_ind0 + txpwrindex), 32, &txgain); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) rad_gain = (txgain >> 16) & ((1 << (32 - 16 + 1)) - 1); - } else { + else rad_gain = (txgain >> 16) & ((1 << (28 - 16 + 1)) - 1); - } + dac_gain = (txgain >> 8) & ((1 << (13 - 8 + 1)) - 1); bbmult = (txgain >> 0) & ((1 << (7 - 0 + 1)) - 1); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : 0xa5), (0x1 << 8), (0x1 << 8)); - } else { + else mod_phy_reg(pi, 0xa5, (0x1 << 14), (0x1 << 14)); - } + write_phy_reg(pi, (core == PHY_CORE_0) ? 0xaa : 0xab, dac_gain); @@ -28974,10 +28627,9 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, wlc_phy_table_read_nphy(pi, txpwrctl_tbl, 1, (lo_ind0 + txpwrindex), 32, &locomp); - if (restore_cals) { + if (restore_cals) wlc_phy_table_write_nphy(pi, 15, 1, (85 + core), 16, &locomp); - } if (NREV_IS(pi->pubpi.phy_rev, 1)) wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); @@ -29074,9 +28726,9 @@ void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode) if (mode) { if (pi->nphy_deaf_count == 0) wlc_phy_stay_in_carriersearch_nphy(pi, true); - } else { - if (pi->nphy_deaf_count > 0) - wlc_phy_stay_in_carriersearch_nphy(pi, false); + } else if (pi->nphy_deaf_count > 0) { + wlc_phy_stay_in_carriersearch_nphy(pi, false); } + wlapi_enable_mac(pi->sh->physhim); } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c index 01ff0c8eb4b..7ff28507f1b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c @@ -35,11 +35,11 @@ When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff s16 qm_muls16(s16 op1, s16 op2) { s32 result; - if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) { + if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) result = 0x7fffffff; - } else { + else result = ((s32) (op1) * (s32) (op2)); - } + return (s16) (result >> 15); } @@ -51,11 +51,11 @@ s32 qm_add32(s32 op1, s32 op2) { s32 result; result = op1 + op2; - if (op1 < 0 && op2 < 0 && result > 0) { + if (op1 < 0 && op2 < 0 && result > 0) result = 0x80000000; - } else if (op1 > 0 && op2 > 0 && result < 0) { + else if (op1 > 0 && op2 > 0 && result < 0) result = 0x7fffffff; - } + return result; } @@ -67,13 +67,13 @@ s16 qm_add16(s16 op1, s16 op2) { s16 result; s32 temp = (s32) op1 + (s32) op2; - if (temp > (s32) 0x7fff) { + if (temp > (s32) 0x7fff) result = (s16) 0x7fff; - } else if (temp < (s32) 0xffff8000) { + else if (temp < (s32) 0xffff8000) result = (s16) 0xffff8000; - } else { + else result = (s16) temp; - } + return result; } @@ -85,13 +85,13 @@ s16 qm_sub16(s16 op1, s16 op2) { s16 result; s32 temp = (s32) op1 - (s32) op2; - if (temp > (s32) 0x7fff) { + if (temp > (s32) 0x7fff) result = (s16) 0x7fff; - } else if (temp < (s32) 0xffff8000) { + else if (temp < (s32) 0xffff8000) result = (s16) 0xffff8000; - } else { + else result = (s16) temp; - } + return result; } @@ -110,12 +110,12 @@ s32 qm_shl32(s32 op, int shift) else if (shift < -31) shift = -31; if (shift >= 0) { - for (i = 0; i < shift; i++) { + for (i = 0; i < shift; i++) result = qm_add32(result, result); - } } else { result = result >> (-shift); } + return result; } @@ -134,12 +134,12 @@ s16 qm_shl16(s16 op, int shift) else if (shift < -15) shift = -15; if (shift > 0) { - for (i = 0; i < shift; i++) { + for (i = 0; i < shift; i++) result = qm_add16(result, result); - } } else { result = result >> (-shift); } + return result; } diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index 86d47c88658..c320384ee35 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -435,14 +435,13 @@ brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, (PHYTYPE_IS(phy_type, PHY_TYPE_N)) || (PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) || (PHYTYPE_IS(phy_type, PHY_TYPE_SSN))) { - if (BAND_5G(bandtype)) { + if (BAND_5G(bandtype)) rs_dflt = (bw == BRCMS_20_MHZ ? &ofdm_mimo_rates : &ofdm_40bw_mimo_rates); - } else { + else rs_dflt = (bw == BRCMS_20_MHZ ? &cck_ofdm_mimo_rates : &cck_ofdm_40bw_mimo_rates); - } } else if (PHYTYPE_IS(phy_type, PHY_TYPE_LP)) { rs_dflt = (BAND_5G(bandtype)) ? &ofdm_rates : &cck_ofdm_rates; } else if (PHYTYPE_IS(phy_type, PHY_TYPE_A)) { diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index f39442ed4ce..bef43ea8ddb 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -901,21 +901,20 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, if (check_crc) { - if (buf[0] == 0xffff) { + if (buf[0] == 0xffff) /* The hardware thinks that an srom that starts with 0xffff * is blank, regardless of the rest of the content, so declare * it bad. */ return -ENODATA; - } /* fixup the endianness so crc8 will pass */ htol16_buf(buf, nwords * 2); if (brcmu_crc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE) { + CRC8_GOOD_VALUE) /* DBG only pci always read srom4 first, then srom8/9 */ err = -EIO; - } + /* now correct the endianness of the byte array */ ltoh16_buf(buf, nwords * 2); } @@ -930,9 +929,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) int err = 0; otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); - if (otp == NULL) { + if (otp == NULL) return -ENOMEM; - } err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); @@ -941,20 +939,19 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) kfree(otp); /* Check CRC */ - if (buf[0] == 0xffff) { + if (buf[0] == 0xffff) /* The hardware thinks that an srom that starts with 0xffff * is blank, regardless of the rest of the content, so declare * it bad. */ return -ENODATA; - } /* fixup the endianness so crc8 will pass */ htol16_buf(buf, bufsz); if (brcmu_crc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE) { + CRC8_GOOD_VALUE) err = -EIO; - } + /* now correct the endianness of the byte array */ ltoh16_buf(buf, bufsz); diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index f6a4b66d1e4..709c9a3d5ab 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -80,15 +80,13 @@ void brcms_c_tempsense_upd(struct brcms_c_info *wlc) txchain = active_chains & 0xf; if (wlc->stf->txchain == wlc->stf->hw_txchain) { - if (txchain && (txchain < wlc->stf->hw_txchain)) { + if (txchain && (txchain < wlc->stf->hw_txchain)) /* turn off 1 tx chain */ brcms_c_stf_txchain_set(wlc, txchain, true); - } } else if (wlc->stf->txchain < wlc->stf->hw_txchain) { - if (txchain == wlc->stf->hw_txchain) { + if (txchain == wlc->stf->hw_txchain) /* turn back on txchain */ brcms_c_stf_txchain_set(wlc, txchain, true); - } } } @@ -136,9 +134,8 @@ brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, static bool brcms_c_stf_stbc_tx_set(struct brcms_c_info *wlc, s32 int_val) { - if ((int_val != AUTO) && (int_val != OFF) && (int_val != ON)) { + if ((int_val != AUTO) && (int_val != OFF) && (int_val != ON)) return false; - } if ((int_val == ON) && (wlc->stf->txstreams == 1)) return false; @@ -158,9 +155,8 @@ static bool brcms_c_stf_stbc_tx_set(struct brcms_c_info *wlc, s32 int_val) bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val) { if ((int_val != HT_CAP_RX_STBC_NO) - && (int_val != HT_CAP_RX_STBC_ONE_STREAM)) { + && (int_val != HT_CAP_RX_STBC_ONE_STREAM)) return false; - } if (BRCMS_STF_SS_STBC_RX(wlc)) { if ((int_val != HT_CAP_RX_STBC_NO) @@ -178,15 +174,13 @@ static int brcms_c_stf_txcore_set(struct brcms_c_info *wlc, u8 Nsts, BCMMSG(wlc->wiphy, "wl%d: Nsts %d core_mask %x\n", wlc->pub->unit, Nsts, core_mask); - if (BRCMS_BITSCNT(core_mask) > wlc->stf->txstreams) { + if (BRCMS_BITSCNT(core_mask) > wlc->stf->txstreams) core_mask = 0; - } if ((BRCMS_BITSCNT(core_mask) == wlc->stf->txstreams) && ((core_mask & ~wlc->stf->txchain) - || !(core_mask & wlc->stf->txchain))) { + || !(core_mask & wlc->stf->txchain))) core_mask = wlc->stf->txchain; - } wlc->stf->txcore[Nsts] = core_mask; /* Nsts = 1..4, txcore index = 1..4 */ @@ -375,9 +369,8 @@ static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) if (BRCMS_ISNPHY(wlc->band) && NREV_GE(wlc->band->phyrev, 3) - && NREV_LT(wlc->band->phyrev, 7)) { + && NREV_LT(wlc->band->phyrev, 7)) wlc->stf->phytxant = PHY_TXC_ANT_2; - } } else { if (BRCMS_ISLCNPHY(wlc->band) || BRCMS_ISSSLPNPHY(wlc->band)) @@ -414,22 +407,20 @@ void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) /* these parameter are intended to be used for all PHY types */ if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) { - if (BRCMS_ISNPHY(wlc->band)) { + if (BRCMS_ISNPHY(wlc->band)) wlc->stf->hw_txchain = TXCHAIN_DEF_NPHY; - } else { + else wlc->stf->hw_txchain = TXCHAIN_DEF; - } } wlc->stf->txchain = wlc->stf->hw_txchain; wlc->stf->txstreams = (u8) BRCMS_BITSCNT(wlc->stf->hw_txchain); if (wlc->stf->hw_rxchain == 0 || wlc->stf->hw_rxchain == 0xf) { - if (BRCMS_ISNPHY(wlc->band)) { + if (BRCMS_ISNPHY(wlc->band)) wlc->stf->hw_rxchain = RXCHAIN_DEF_NPHY; - } else { + else wlc->stf->hw_rxchain = RXCHAIN_DEF; - } } wlc->stf->rxchain = wlc->stf->hw_rxchain; @@ -448,9 +439,9 @@ static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, { u16 phytxant = wlc->stf->phytxant; - if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) { + if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; - } else if (wlc->stf->txant == ANT_TX_DEF) + else if (wlc->stf->txant == ANT_TX_DEF) phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; phytxant &= PHY_TXC_ANT_MASK; return phytxant; diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 2151e0b481c..4b0815760d2 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -244,9 +244,8 @@ brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, } } - if (q->head == NULL) { + if (q->head == NULL) q->tail = NULL; - } } EXPORT_SYMBOL(brcmu_pktq_pflush); @@ -404,26 +403,23 @@ int brcmu_iovar_lencheck(const struct brcmu_iovar *vi, void *arg, int len, case IOVT_UINT16: case IOVT_UINT32: /* all integers are s32 sized args at the ioctl interface */ - if (len < (int)sizeof(int)) { + if (len < (int)sizeof(int)) bcmerror = -EOVERFLOW; - } break; case IOVT_BUFFER: /* buffer must meet minimum length requirement */ - if (len < vi->minlen) { + if (len < vi->minlen) bcmerror = -EOVERFLOW; - } break; case IOVT_VOID: - if (!set) { + if (!set) /* Cannot return nil... */ bcmerror = -ENOTSUPP; - } else if (len) { + else if (len) /* Set is an action w/o parameters */ bcmerror = -ENOBUFS; - } break; default: @@ -670,10 +666,9 @@ u16 brcmu_qdbm_to_mw(u8 qdbm) uint factor = 1; int idx = qdbm - QDBM_OFFSET; - if (idx >= QDBM_TABLE_LEN) { + if (idx >= QDBM_TABLE_LEN) /* clamp to max u16 mW value */ return 0xFFFF; - } /* scale the qdBm index up to the range of the table 0-40 * where an offset of 40 qdBm equals a factor of 10 mW. diff --git a/drivers/staging/brcm80211/brcmutil/wifi.c b/drivers/staging/brcm80211/brcmutil/wifi.c index e8f7f56add8..1bce8887ddf 100644 --- a/drivers/staging/brcm80211/brcmutil/wifi.c +++ b/drivers/staging/brcm80211/brcmutil/wifi.c @@ -34,9 +34,8 @@ bool brcmu_chspec_malformed(u16 chanspec) if (CHSPEC_IS20(chanspec)) { if (!CHSPEC_SB_NONE(chanspec)) return true; - } else { - if (!CHSPEC_SB_UPPER(chanspec) && !CHSPEC_SB_LOWER(chanspec)) - return true; + } else if (!CHSPEC_SB_UPPER(chanspec) && !CHSPEC_SB_LOWER(chanspec)) { + return true; } return false; @@ -60,13 +59,12 @@ u8 brcmu_chspec_ctlchan(u16 chspec) /* chanspec channel holds the centre frequency, use that and the * side band information to reconstruct the control channel number */ - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) { + if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) /* control chan is the upper 20 MHZ SB of the 40MHZ channel */ ctl_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec)); - } else { + else /* control chan is the lower 20 MHZ SB of the 40MHZ channel */ ctl_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec)); - } } return ctl_chan; From db25e44b9fa9e04f18122aed5bd4dedf45c7dd9c Mon Sep 17 00:00:00 2001 From: Sukesh Srikakula Date: Mon, 8 Aug 2011 15:58:13 +0200 Subject: [PATCH 0051/1519] staging: brcm80211: brcmfmac: Fixed issues with iscan Disabling the interface doesn't terminate undergoing iscan in FW. When the interface is enabled immediately, first scan request is returning the stale scan results, which are populated during the earlier iscan. These stale scan results are causing random failures with chromium auto test cases. With this patch, iscan will be terminated in FW whenever iscan thread is terminated by the host driver. Signed-off-by: Sukesh Srikakula Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 8423aadd87a..cf5708718e8 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -709,10 +709,14 @@ static s32 brcmf_do_iscan(struct brcmf_cfg80211_priv *cfg_priv) } brcmf_set_mpc(ndev, 0); cfg_priv->iscan_kickstart = true; - brcmf_run_iscan(iscan, &ssid, BRCMF_SCAN_ACTION_START); + err = brcmf_run_iscan(iscan, &ssid, BRCMF_SCAN_ACTION_START); + if (err) { + brcmf_set_mpc(ndev, 1); + cfg_priv->iscan_kickstart = false; + return err; + } mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); iscan->timer_on = 1; - return err; } @@ -3165,12 +3169,17 @@ static void brcmf_destroy_event_handler(struct brcmf_cfg80211_priv *cfg_priv) static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); + struct brcmf_ssid ssid; if (cfg_priv->iscan_on && iscan->tsk) { iscan->state = WL_ISCAN_STATE_IDLE; send_sig(SIGTERM, iscan->tsk, 1); kthread_stop(iscan->tsk); iscan->tsk = NULL; + + /* Abort iscan running in FW */ + memset(&ssid, 0, sizeof(ssid)); + brcmf_run_iscan(iscan, &ssid, WL_SCAN_ACTION_ABORT); } } @@ -3237,6 +3246,7 @@ brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, WL_SCAN("results->count = %d\n", results->count); WL_SCAN("results->buflen = %d\n", results->buflen); *status = le32_to_cpu(list_buf->status); + WL_SCAN("status = %d\n", *status); *bss_list = results; return err; From 1f44a8219e47d0803a7386d7e501fbe8b04058a6 Mon Sep 17 00:00:00 2001 From: Sukesh Srikakula Date: Mon, 8 Aug 2011 15:58:14 +0200 Subject: [PATCH 0052/1519] staging: brcm80211: brcmfmac: Roamed channel info passed to cfg80211 With this patch, brcmfmac driver will pass roamed channel information to cfg80211 via cfg80211_roamed() API. Signed-off-by: Sukesh Srikakula Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index cf5708718e8..440ae6d43e3 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2890,6 +2890,11 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, const struct brcmf_event_msg *e, void *data) { struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); + struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); + struct brcmf_channel_info channel; + struct ieee80211_channel *notify_channel; + struct ieee80211_supported_band *band; + u32 freq; s32 err = 0; WL_TRACE("Enter\n"); @@ -2898,7 +2903,21 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, brcmf_update_prof(cfg_priv, NULL, &e->addr, WL_PROF_BSSID); brcmf_update_bss_info(cfg_priv); - cfg80211_roamed(ndev, NULL, + brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel, sizeof(channel)); + + channel.target_channel = le32_to_cpu(channel.target_channel); + WL_CONN("Roamed to channel %d\n", channel.target_channel); + + if (channel.target_channel <= CH_MAX_2G_CHANNEL) + band = wiphy->bands[IEEE80211_BAND_2GHZ]; + else + band = wiphy->bands[IEEE80211_BAND_5GHZ]; + + freq = ieee80211_channel_to_frequency(channel.target_channel, + band->band); + notify_channel = ieee80211_get_channel(wiphy, freq); + + cfg80211_roamed(ndev, notify_channel, (u8 *)brcmf_read_prof(cfg_priv, WL_PROF_BSSID), conn_info->req_ie, conn_info->req_ie_len, conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL); From e1ae77bb4a5a58d1d93619148e0dddcc7c8010d6 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:15 +0200 Subject: [PATCH 0053/1519] staging: brcm80211: move sdio related variables to dhd_sdio.c In fullmac some variables are used by sdio layer declared in dhd_linux.c. Move them to dhd_sdio.c for clean up. Signed-off-by: Franky Lin Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 13 ----------- .../staging/brcm80211/brcmfmac/dhd_linux.c | 22 ------------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 18 +++++++++++++++ 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 537eb00cd0c..1f203fb75a5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -669,12 +669,6 @@ extern atomic_t brcmf_mmc_suspend; * Insmod parameters for debug/test */ -/* Use interrupts */ -extern uint brcmf_intr; - -/* Use polling */ -extern uint brcmf_poll; - /* ARP offload agent mode */ extern uint brcmf_arp_mode; @@ -696,13 +690,6 @@ extern uint brcmf_roam; /* Roaming mode control */ extern uint brcmf_radio_up; -/* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */ -extern int brcmf_idletime; -#define BRCMF_IDLETIME_TICKS 1 - -/* SDIO Drive Strength */ -extern uint brcmf_sdiod_drive_strength; - /* Override to force tx queueing all the time */ extern uint brcmf_force_tx_queueing; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 7e9c86b9742..f3eaef1e1d3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -115,8 +115,6 @@ module_param(brcmf_pkt_filter_init, uint, 0); uint brcmf_master_mode = true; module_param(brcmf_master_mode, uint, 0); -module_param(brcmf_dongle_memsize, int, 0); - /* Contorl fw roaming */ uint brcmf_roam = 1; @@ -132,26 +130,6 @@ module_param_string(iface_name, iface_name, IFNAMSIZ, 0); /* IOCTL response timeout */ int brcmf_ioctl_timeout_msec = IOCTL_RESP_TIMEOUT; -/* Idle timeout for backplane clock */ -int brcmf_idletime = BRCMF_IDLETIME_TICKS; -module_param(brcmf_idletime, int, 0); - -/* Use polling */ -uint brcmf_poll; -module_param(brcmf_poll, uint, 0); - -/* Use interrupts */ -uint brcmf_intr = true; -module_param(brcmf_intr, uint, 0); - -/* SDIO Drive Strength (in milliamps) */ -uint brcmf_sdiod_drive_strength = 6; -module_param(brcmf_sdiod_drive_strength, uint, 0); - -/* Tx/Rx bounds */ -module_param(brcmf_txbound, uint, 0); -module_param(brcmf_rxbound, uint, 0); - #ifdef SDTEST /* Echo packet generator (pkts/s) */ uint brcmf_pktgen; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 705b57ca2ca..2f33f37db4d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -838,11 +838,29 @@ module_param(brcmf_console_ms, uint, 0); /* Tx/Rx bounds */ uint brcmf_txbound; uint brcmf_rxbound; +module_param(brcmf_txbound, uint, 0); +module_param(brcmf_rxbound, uint, 0); uint brcmf_txminmax; +int brcmf_idletime = 1; +module_param(brcmf_idletime, int, 0); + +/* SDIO Drive Strength (in milliamps) */ +uint brcmf_sdiod_drive_strength = 6; +module_param(brcmf_sdiod_drive_strength, uint, 0); + +/* Use polling */ +uint brcmf_poll; +module_param(brcmf_poll, uint, 0); + +/* Use interrupts */ +uint brcmf_intr = true; +module_param(brcmf_intr, uint, 0); + /* override the RAM size if possible */ #define DONGLE_MIN_MEMSIZE (128 * 1024) int brcmf_dongle_memsize; +module_param(brcmf_dongle_memsize, int, 0); static bool brcmf_alignctl; From f61b2af43de25eb7ead33b390660a4338e75c541 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:16 +0200 Subject: [PATCH 0054/1519] staging: brcm80211: move ioctl response wait code to dhd_sdio.c Ioctl response wait is used only by bus layer in fullmac. Move the corresponding code to dhd_sdio.c Signed-off-by: Franky Lin Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 5 -- .../staging/brcm80211/brcmfmac/dhd_common.c | 18 ------ .../staging/brcm80211/brcmfmac/dhd_linux.c | 52 ---------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 60 ++++++++++++++++++- 4 files changed, 57 insertions(+), 78 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 1f203fb75a5..f3633fe1a1c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -779,11 +779,6 @@ extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, /* OS independent layer functions */ extern int brcmf_os_proto_block(struct brcmf_pub *drvr); extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr); -extern int brcmf_os_ioctl_resp_wait(struct brcmf_pub *drvr, uint *condition, - bool *pending); -extern int brcmf_os_ioctl_resp_wake(struct brcmf_pub *drvr); -extern unsigned int brcmf_os_get_ioctl_resp_timeout(void); -extern void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec); #ifdef BCMDBG extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size); #endif /* BCMDBG */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index d5648f87f5a..12c772d1789 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -55,7 +55,6 @@ enum { IOV_LOGCAL, IOV_LOGSTAMP, IOV_GPIOOB, - IOV_IOCTLTIMEOUT, IOV_LAST }; @@ -76,8 +75,6 @@ const struct brcmu_iovar brcmf_iovars[] = { , {"gpioob", IOV_GPIOOB, 0, IOVT_UINT32, 0} , - {"ioctl_timeout", IOV_IOCTLTIMEOUT, 0, IOVT_UINT32, 0} - , {NULL, 0, 0, 0, 0} }; @@ -227,21 +224,6 @@ brcmf_c_doiovar(struct brcmf_pub *drvr, const struct brcmu_iovar *vi, brcmf_bus_clearcounts(drvr); break; - case IOV_GVAL(IOV_IOCTLTIMEOUT):{ - int_val = (s32) brcmf_os_get_ioctl_resp_timeout(); - memcpy(arg, &int_val, sizeof(int_val)); - break; - } - - case IOV_SVAL(IOV_IOCTLTIMEOUT):{ - if (int_val <= 0) - bcmerror = -EINVAL; - else - brcmf_os_set_ioctl_resp_timeout((unsigned int) - int_val); - break; - } - default: bcmerror = -ENOTSUPP; break; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index f3eaef1e1d3..b7a741b6485 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -76,7 +76,6 @@ struct brcmf_info { struct brcmf_if *iflist[BRCMF_MAX_IFS]; struct mutex proto_block; - wait_queue_head_t ioctl_resp_wait; /* Thread to issue ioctl for multicast */ struct task_struct *sysioc_tsk; @@ -127,9 +126,6 @@ module_param_string(iface_name, iface_name, IFNAMSIZ, 0); /* The following are specific to the SDIO dongle */ -/* IOCTL response timeout */ -int brcmf_ioctl_timeout_msec = IOCTL_RESP_TIMEOUT; - #ifdef SDTEST /* Echo packet generator (pkts/s) */ uint brcmf_pktgen; @@ -1290,8 +1286,6 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) net->netdev_ops = NULL; mutex_init(&drvr_priv->proto_block); - /* Initialize other structure content */ - init_waitqueue_head(&drvr_priv->ioctl_resp_wait); /* Link to info module */ drvr_priv->pub.info = drvr_priv; @@ -1577,52 +1571,6 @@ int brcmf_os_proto_unblock(struct brcmf_pub *drvr) return 0; } -unsigned int brcmf_os_get_ioctl_resp_timeout(void) -{ - return (unsigned int)brcmf_ioctl_timeout_msec; -} - -void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec) -{ - brcmf_ioctl_timeout_msec = (int)timeout_msec; -} - -int brcmf_os_ioctl_resp_wait(struct brcmf_pub *drvr, uint *condition, - bool *pending) -{ - struct brcmf_info *drvr_priv = drvr->info; - DECLARE_WAITQUEUE(wait, current); - int timeout = brcmf_ioctl_timeout_msec; - - /* Convert timeout in millsecond to jiffies */ - timeout = timeout * HZ / 1000; - - /* Wait until control frame is available */ - add_wait_queue(&drvr_priv->ioctl_resp_wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); - - while (!(*condition) && (!signal_pending(current) && timeout)) - timeout = schedule_timeout(timeout); - - if (signal_pending(current)) - *pending = true; - - set_current_state(TASK_RUNNING); - remove_wait_queue(&drvr_priv->ioctl_resp_wait, &wait); - - return timeout; -} - -int brcmf_os_ioctl_resp_wake(struct brcmf_pub *drvr) -{ - struct brcmf_info *drvr_priv = drvr->info; - - if (waitqueue_active(&drvr_priv->ioctl_resp_wait)) - wake_up_interruptible(&drvr_priv->ioctl_resp_wait); - - return 0; -} - static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, struct brcmf_event_msg *event, void **data) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 2f33f37db4d..3e7d5b273f1 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -740,6 +740,7 @@ struct brcmf_bus { spinlock_t txqlock; wait_queue_head_t ctrl_wait; + wait_queue_head_t ioctl_resp_wait; struct timer_list timer; struct completion watchdog_wait; @@ -857,6 +858,9 @@ module_param(brcmf_poll, uint, 0); uint brcmf_intr = true; module_param(brcmf_intr, uint, 0); +/* IOCTL response timeout */ +static int brcmf_ioctl_timeout_msec = IOCTL_RESP_TIMEOUT; + /* override the RAM size if possible */ #define DONGLE_MIN_MEMSIZE (128 * 1024) int brcmf_dongle_memsize; @@ -1005,6 +1009,9 @@ static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus); static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus); static void brcmf_sdbrcm_sdunlock(struct brcmf_bus *bus); static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus); +static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, + bool *pending); +static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus); /* Packet free applicable unconditionally for sdio and sdspi. * Conditional if bufpool was present for gspi bus. @@ -1832,7 +1839,7 @@ int brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msgle return -EIO; /* Wait until control frame is available */ - timeleft = brcmf_os_ioctl_resp_wait(bus->drvr, &bus->rxlen, &pending); + timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); brcmf_sdbrcm_sdlock(bus); rxlen = bus->rxlen; @@ -1906,6 +1913,7 @@ enum { IOV_SD1IDLE, IOV_SLEEP, IOV_WDTICK, + IOV_IOCTLTIMEOUT, IOV_VARS }; @@ -1927,6 +1935,7 @@ const struct brcmu_iovar brcmf_sdio_iovars[] = { {"sdalign", IOV_SDALIGN, 0, IOVT_BOOL, 0}, {"devreset", IOV_DEVRESET, 0, IOVT_BOOL, 0}, {"wdtick", IOV_WDTICK, 0, IOVT_UINT32, 0}, + {"ioctl_timeout", IOV_IOCTLTIMEOUT, 0, IOVT_UINT32, 0}, #ifdef BCMDBG {"cons", IOV_CONS, 0, IOVT_BUFFER, 0} , @@ -2964,6 +2973,20 @@ brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, const struct brcmu_iovar *vi, u32 ac brcmf_sdbrcm_wd_timer(bus, (uint) int_val); break; + case IOV_GVAL(IOV_IOCTLTIMEOUT):{ + int_val = brcmf_ioctl_timeout_msec; + memcpy(arg, &int_val, sizeof(int_val)); + break; + } + + case IOV_SVAL(IOV_IOCTLTIMEOUT):{ + if (int_val <= 0) + bcmerror = -EINVAL; + else + brcmf_ioctl_timeout_msec = int_val; + break; + } + default: bcmerror = -ENOTSUPP; break; @@ -3293,7 +3316,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) /* Clear rx control and wake any waiters */ bus->rxlen = 0; - brcmf_os_ioctl_resp_wake(bus->drvr); + brcmf_sdbrcm_ioctl_resp_wake(bus); /* Reset some F2 state stuff */ bus->rxskip = false; @@ -3593,7 +3616,7 @@ gotpkt: done: /* Awake any waiters */ - brcmf_os_ioctl_resp_wake(bus->drvr); + brcmf_sdbrcm_ioctl_resp_wake(bus); } static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) @@ -5506,6 +5529,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, spin_lock_init(&bus->txqlock); init_waitqueue_head(&bus->ctrl_wait); + init_waitqueue_head(&bus->ioctl_resp_wait); /* Set up the watchdog timer */ init_timer(&bus->timer); @@ -6779,3 +6803,33 @@ static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) MODULE_FIRMWARE(BCM4329_FW_NAME); MODULE_FIRMWARE(BCM4329_NV_NAME); + +static int +brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, bool *pending) +{ + DECLARE_WAITQUEUE(wait, current); + int timeout = msecs_to_jiffies(brcmf_ioctl_timeout_msec); + + /* Wait until control frame is available */ + add_wait_queue(&bus->ioctl_resp_wait, &wait); + set_current_state(TASK_INTERRUPTIBLE); + + while (!(*condition) && (!signal_pending(current) && timeout)) + timeout = schedule_timeout(timeout); + + if (signal_pending(current)) + *pending = true; + + set_current_state(TASK_RUNNING); + remove_wait_queue(&bus->ioctl_resp_wait, &wait); + + return timeout; +} + +static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus) +{ + if (waitqueue_active(&bus->ioctl_resp_wait)) + wake_up_interruptible(&bus->ioctl_resp_wait); + + return 0; +} From 277195acd20a929b08db72fe73d62cf8da49d63c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:17 +0200 Subject: [PATCH 0055/1519] staging: brcm80211: replace semaphore by wait_queue for sysioc thread The sysioc thread was triggered using a semaphore. Now it waits for a wake_up() on its wait queue and the semaphore has been removed as the semaphore serves another purpose. This removes a checkpatch warning for dhd_linux.c. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index b7a741b6485..0d868190db8 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ struct brcmf_info { /* Thread to issue ioctl for multicast */ struct task_struct *sysioc_tsk; - struct semaphore sysioc_sem; + wait_queue_head_t sysioc_waitq; bool set_multicast; bool set_macaddress; u8 macvalue[ETH_ALEN]; @@ -494,12 +495,20 @@ static int _brcmf_sysioc_thread(void *data) #ifdef SOFTAP bool in_ap = false; #endif - + DECLARE_WAITQUEUE(wait, current); allow_signal(SIGTERM); - while (down_interruptible(&drvr_priv->sysioc_sem) == 0) { + add_wait_queue(&drvr_priv->sysioc_waitq, &wait); + while (1) { + prepare_to_wait(&drvr_priv->sysioc_waitq, &wait, + TASK_INTERRUPTIBLE); + + /* wait for event */ + schedule(); + if (kthread_should_stop()) break; + for (i = 0; i < BRCMF_MAX_IFS; i++) { struct brcmf_if *ifentry = drvr_priv->iflist[i]; if (ifentry) { @@ -546,6 +555,7 @@ static int _brcmf_sysioc_thread(void *data) } } } + finish_wait(&drvr_priv->sysioc_waitq, &wait); return 0; } @@ -563,8 +573,7 @@ static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); drvr_priv->set_macaddress = true; - up(&drvr_priv->sysioc_sem); - + wake_up(&drvr_priv->sysioc_waitq); return ret; } @@ -578,7 +587,7 @@ static void brcmf_netdev_set_multicast_list(struct net_device *dev) return; drvr_priv->set_multicast = true; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) @@ -1218,7 +1227,7 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name, if (handle == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } else ifp->net = (struct net_device *)handle; @@ -1239,7 +1248,7 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) ifp->state = BRCMF_E_IF_DEL; ifp->idx = ifidx; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) @@ -1307,7 +1316,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) } if (brcmf_sysioc) { - sema_init(&drvr_priv->sysioc_sem, 0); + init_waitqueue_head(&drvr_priv->sysioc_waitq); drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, drvr_priv, "_brcmf_sysioc"); if (IS_ERR(drvr_priv->sysioc_tsk)) { From 85567f52f2ba6159b98b066c792e5eb7cdc9bf0c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:18 +0200 Subject: [PATCH 0056/1519] staging: brcm80211: remove volatile keyword used in struct rte_console Two members vcons_in and vcons_out were declared using the volatile keyword. However, there is no reason for doing so. The member is used only to calculate the backplane address to access using offsetof. This address is passed to subsequent read function. Use of volatile is not warranted. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 3e7d5b273f1..8cb34d67348 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -126,8 +126,8 @@ struct rte_console { * (at risk of conflicting with * the real UART). vcons_out is currently unused. */ - volatile uint vcons_in; - volatile uint vcons_out; + uint vcons_in; + uint vcons_out; /* Output (logging) buffer * Console output is written to a ring buffer log_buf at index log_idx. From 7b4d189f65245bd8e0ced3475c762d61e0caa61b Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:19 +0200 Subject: [PATCH 0057/1519] staging: brcm80211: fix for checkpatch warnings in phy directory Most of them being 'line exceeds 80 chars'. Still checkpatch warnings for the phy dir left, these will be resolved in the subsequent commits. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 237 +- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 51 +- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 138 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 407 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 3659 +++++++++-------- .../brcm80211/brcmsmac/phy/phy_qmath.c | 136 +- .../brcm80211/brcmsmac/phy/phytbl_lcn.c | 1168 ++---- .../staging/brcm80211/brcmsmac/phy/phytbl_n.c | 3 +- .../staging/brcm80211/brcmsmac/phy/phytbl_n.h | 24 +- 9 files changed, 2883 insertions(+), 2940 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 2636114227e..582df4a248b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -119,7 +119,7 @@ const u8 ofdm_rate_lookup[] = { BRCM_RATE_9M }; -#define PHY_WREG_LIMIT 24 +#define PHY_WREG_LIMIT 24 static void wlc_set_phy_uninitted(struct brcms_phy *pi); static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi); @@ -142,7 +142,7 @@ static void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi); static s8 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, - u32 band, u8 rate); + u32 band, u8 rate); static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band); static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi); static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi); @@ -581,11 +581,11 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, idcode = wlc_phy_get_radio_ver(pi); pi->pubpi.radioid = - (idcode & IDCODE_ID_MASK) >> IDCODE_ID_SHIFT; + (idcode & IDCODE_ID_MASK) >> IDCODE_ID_SHIFT; pi->pubpi.radiorev = - (idcode & IDCODE_REV_MASK) >> IDCODE_REV_SHIFT; + (idcode & IDCODE_REV_MASK) >> IDCODE_REV_SHIFT; pi->pubpi.radiover = - (idcode & IDCODE_VER_MASK) >> IDCODE_VER_SHIFT; + (idcode & IDCODE_VER_MASK) >> IDCODE_VER_SHIFT; if (!VALID_RADIO(pi, pi->pubpi.radioid)) goto err; @@ -595,7 +595,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, pi->bw = WL_CHANSPEC_BW_20; pi->radio_chanspec = - BAND_2G(bandtype) ? CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36); + BAND_2G(bandtype) ? CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36); pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; pi->rxiq_antsel = ANT_RX_DIV_DEF; @@ -617,7 +617,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; pi->phy_txcore_enable_temp = - PHY_CHAIN_TX_DISABLE_TEMP - PHY_HYSTERESIS_DELTATEMP; + PHY_CHAIN_TX_DISABLE_TEMP - PHY_HYSTERESIS_DELTATEMP; pi->phy_tempsense_offset = 0; pi->phy_txcore_heatedup = false; @@ -640,8 +640,8 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, if (ISNPHY(pi)) { pi->phycal_timer = wlapi_init_timer(pi->sh->physhim, - wlc_phy_timercb_phycal, - pi, "phycal"); + wlc_phy_timercb_phycal, + pi, "phycal"); if (!pi->phycal_timer) goto err; @@ -664,7 +664,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, return &pi->pubpi_ro; - err: +err: kfree(pi); return NULL; } @@ -688,7 +688,7 @@ void wlc_phy_detach(struct brcms_phy_pub *pih) pi->sh->phy_head->next = NULL; if (pi->pi_fptr.detach) - (pi->pi_fptr.detach) (pi); + (pi->pi_fptr.detach)(pi); kfree(pi); } @@ -853,7 +853,7 @@ void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate) void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) { u32 mc; - void (*phy_init) (struct brcms_phy *) = NULL; + void (*phy_init)(struct brcms_phy *) = NULL; struct brcms_phy *pi = (struct brcms_phy *) pih; if (pi->init_in_progress) @@ -889,7 +889,7 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) wlc_phy_switch_radio((struct brcms_phy_pub *) pi, ON); - (*phy_init) (pi); + (*phy_init)(pi); pi->phy_init_por = false; @@ -916,7 +916,7 @@ void wlc_phy_cal_init(struct brcms_phy_pub *pih) if (!pi->initialized) { cal_init = pi->pi_fptr.calinit; if (cal_init) - (*cal_init) (pi); + (*cal_init)(pi); pi->initialized = true; } @@ -1108,7 +1108,7 @@ wlc_phy_init_radio_regs(struct brcms_phy *pi, struct radio_regs *radioregs, void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) { -#define DUMMY_PKT_LEN 20 +#define DUMMY_PKT_LEN 20 struct d11regs *regs = pi->regs; int i, count; u8 ofdmpkt[DUMMY_PKT_LEN] = { @@ -1300,7 +1300,7 @@ void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec) { struct brcms_phy *pi = (struct brcms_phy *) ppi; u16 m_cur_channel; - void (*chanspec_set) (struct brcms_phy *, u16) = NULL; + void (*chanspec_set)(struct brcms_phy *, u16) = NULL; m_cur_channel = CHSPEC_CHANNEL(chanspec); if (CHSPEC_IS5G(chanspec)) m_cur_channel |= D11_CURCHANNEL_5G; @@ -1310,7 +1310,7 @@ void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec) chanspec_set = pi->pi_fptr.chanset; if (chanspec_set) - (*chanspec_set) (pi, chanspec); + (*chanspec_set)(pi, chanspec); } @@ -1409,9 +1409,8 @@ u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) continue; channel = UPPER_20_SB(channel); - chspec = - channel | WL_CHANSPEC_BW_40 | - WL_CHANSPEC_CTL_SB_LOWER; + chspec = channel | WL_CHANSPEC_BW_40 | + WL_CHANSPEC_CTL_SB_LOWER; if (band == BRCM_BAND_2G) chspec |= WL_CHANSPEC_BAND_2G; else @@ -1508,10 +1507,8 @@ int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override) if (!SCAN_INPROG_PHY(pi)) { bool suspend; - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & - MCTL_EN_MAC)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -1588,7 +1585,8 @@ wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan, pactrl = 0; max_num_rate = ISNPHY(pi) ? TXP_NUM_RATES : - ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + 1) : (TXP_LAST_OFDM + 1); + ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + + 1) : (TXP_LAST_OFDM + 1); for (rate = 0; rate < max_num_rate; rate++) { @@ -1658,8 +1656,8 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { pi->tx_srom_max_rate_2g[i - 8] = - pi->tx_srom_max_2g - - ((offset_mcs & 0xf) * 2); + pi->tx_srom_max_2g - + ((offset_mcs & 0xf) * 2); offset_mcs >>= 4; } } else { @@ -1667,8 +1665,8 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { pi->tx_srom_max_rate_2g[i - 8] = - pi->tx_srom_max_2g - - ((offset_mcs & 0xf) * 2); + pi->tx_srom_max_2g - + ((offset_mcs & 0xf) * 2); offset_mcs >>= 4; } } @@ -1689,8 +1687,10 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) if (pi->user_txpwr_at_rfport) tx_pwr_target[rate] += - wlc_user_txpwr_antport_to_rfport(pi, target_chan, - band, rate); + wlc_user_txpwr_antport_to_rfport(pi, + target_chan, + band, + rate); { @@ -1701,7 +1701,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); maxtxpwr = - (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; + (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0; @@ -1714,7 +1714,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) } tx_pwr_target[rate] = - min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); + min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); if (tx_pwr_target[rate] > tx_pwr_max) tx_pwr_max_rate_ind = rate; @@ -1733,15 +1733,15 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) if (!pi->hwpwrctrl || ISNPHY(pi)) pi->tx_power_offset[rate] = - pi->tx_power_max - pi->tx_power_target[rate]; + pi->tx_power_max - pi->tx_power_target[rate]; else pi->tx_power_offset[rate] = - pi->tx_power_target[rate] - pi->tx_power_min; + pi->tx_power_target[rate] - pi->tx_power_min; } txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc; if (txpwr_recalc_fn) - (*txpwr_recalc_fn) (pi); + (*txpwr_recalc_fn)(pi); } void @@ -1781,7 +1781,7 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, txpwr_ptr1 = txpwr->mcs_40_siso; txpwr_ptr2 = txpwr->ofdm_40_siso; rate_start_index = - WL_TX_POWER_OFDM40_SISO_FIRST; + WL_TX_POWER_OFDM40_SISO_FIRST; break; case 3: @@ -1791,18 +1791,21 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, break; } - for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; rate2++) { + for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; + rate2++) { tmp_txpwr_limit[rate2] = 0; tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] = - txpwr_ptr1[rate2]; + txpwr_ptr1[rate2]; } - wlc_phy_mcs_to_ofdm_powers_nphy(tmp_txpwr_limit, 0, - BRCMS_NUM_RATES_OFDM - 1, BRCMS_NUM_RATES_OFDM); + wlc_phy_mcs_to_ofdm_powers_nphy( + tmp_txpwr_limit, 0, + BRCMS_NUM_RATES_OFDM - + 1, BRCMS_NUM_RATES_OFDM); for (rate1 = rate_start_index, rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; rate1++, rate2++) pi->txpwr_limit[rate1] = - min(txpwr_ptr2[rate2], - tmp_txpwr_limit[rate2]); + min(txpwr_ptr2[rate2], + tmp_txpwr_limit[rate2]); } for (k = 0; k < 4; k++) { @@ -1832,19 +1835,22 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, rate_start_index = WL_TX_POWER_MCS40_CDD_FIRST; break; } - for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; rate2++) { + for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; + rate2++) { tmp_txpwr_limit[rate2] = 0; tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] = - txpwr_ptr1[rate2]; + txpwr_ptr1[rate2]; } - wlc_phy_ofdm_to_mcs_powers_nphy(tmp_txpwr_limit, 0, - BRCMS_NUM_RATES_OFDM - 1, BRCMS_NUM_RATES_OFDM); + wlc_phy_ofdm_to_mcs_powers_nphy( + tmp_txpwr_limit, 0, + BRCMS_NUM_RATES_OFDM - + 1, BRCMS_NUM_RATES_OFDM); for (rate1 = rate_start_index, rate2 = 0; rate2 < BRCMS_NUM_RATES_MCS_1_STREAM; rate1++, rate2++) pi->txpwr_limit[rate1] = - min(txpwr_ptr2[rate2], - tmp_txpwr_limit[rate2]); + min(txpwr_ptr2[rate2], + tmp_txpwr_limit[rate2]); } for (k = 0; k < 2; k++) { @@ -1888,10 +1894,10 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, pi->txpwr_limit[WL_TX_POWER_MCS_32] = txpwr->mcs32; pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST] = - min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST], - pi->txpwr_limit[WL_TX_POWER_MCS_32]); + min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST], + pi->txpwr_limit[WL_TX_POWER_MCS_32]); pi->txpwr_limit[WL_TX_POWER_MCS_32] = - pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST]; + pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST]; } } @@ -2005,9 +2011,9 @@ void wlc_phy_txpower_update_shm(struct brcms_phy *pi) const u8 ucode_ofdm_rates[] = { 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c }; - offset = wlapi_bmac_rate_shm_offset(pi->sh->physhim, - ucode_ofdm_rates[j - - TXP_FIRST_OFDM]); + offset = wlapi_bmac_rate_shm_offset( + pi->sh->physhim, + ucode_ofdm_rates[j - TXP_FIRST_OFDM]); wlapi_bmac_write_shm(pi->sh->physhim, offset + 6, pi->tx_power_offset[j]); wlapi_bmac_write_shm(pi->sh->physhim, offset + 14, @@ -2021,11 +2027,11 @@ void wlc_phy_txpower_update_shm(struct brcms_phy *pi) for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) pi->tx_power_offset[i] = - (u8) roundup(pi->tx_power_offset[i], 8); + (u8) roundup(pi->tx_power_offset[i], 8); wlapi_bmac_write_shm(pi->sh->physhim, M_OFDM_OFFSET, - (u16) ((pi-> - tx_power_offset[TXP_FIRST_OFDM] - + 7) >> 3)); + (u16) + ((pi->tx_power_offset[TXP_FIRST_OFDM] + + 7) >> 3)); } } @@ -2052,9 +2058,7 @@ void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl) pi->txpwrctrl = hwpwrctrl; if (ISNPHY(pi)) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2092,38 +2096,31 @@ static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) estPower1 = read_phy_reg(pi, 0x118); estPower2 = read_phy_reg(pi, 0x119); - if ((estPower1 & (0x1 << 8)) - == (0x1 << 8)) - pwr0 = (u8) (estPower1 & (0xff << 0)) - >> 0; + if ((estPower1 & (0x1 << 8)) == (0x1 << 8)) + pwr0 = (u8) (estPower1 & (0xff << 0)) >> 0; else pwr0 = 0x80; - if ((estPower2 & (0x1 << 8)) - == (0x1 << 8)) - pwr1 = (u8) (estPower2 & (0xff << 0)) - >> 0; + if ((estPower2 & (0x1 << 8)) == (0x1 << 8)) + pwr1 = (u8) (estPower2 & (0xff << 0)) >> 0; else pwr1 = 0x80; tx0_status = read_phy_reg(pi, 0x1ed); tx1_status = read_phy_reg(pi, 0x1ee); - if ((tx0_status & (0x1 << 15)) - == (0x1 << 15)) - adj_pwr0 = (u8) (tx0_status & (0xff << 0)) - >> 0; + if ((tx0_status & (0x1 << 15)) == (0x1 << 15)) + adj_pwr0 = (u8) (tx0_status & (0xff << 0)) >> 0; else adj_pwr0 = 0x80; - if ((tx1_status & (0x1 << 15)) - == (0x1 << 15)) - adj_pwr1 = (u8) (tx1_status & (0xff << 0)) - >> 0; + if ((tx1_status & (0x1 << 15)) == (0x1 << 15)) + adj_pwr1 = (u8) (tx1_status & (0xff << 0)) >> 0; else adj_pwr1 = 0x80; - est_pwr = - (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) | adj_pwr1); + est_pwr = (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) | + adj_pwr1); + return est_pwr; } @@ -2144,7 +2141,7 @@ wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power, power->flags |= (WL_TX_POWER_F_MIMO); if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) power->flags |= - (WL_TX_POWER_F_ENABLED | WL_TX_POWER_F_HW); + (WL_TX_POWER_F_ENABLED | WL_TX_POWER_F_HW); } else if (ISLCNPHY(pi)) { power->rf_cores = 1; power->flags |= (WL_TX_POWER_F_SISO); @@ -2207,16 +2204,18 @@ wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power, power->tx_power_max[1] = pi->tx_power_max; power->tx_power_max_rate_ind[0] = - pi->tx_power_max_rate_ind; + pi->tx_power_max_rate_ind; power->tx_power_max_rate_ind[1] = - pi->tx_power_max_rate_ind; + pi->tx_power_max_rate_ind; if (wlc_phy_tpc_isenabled_lcnphy(pi)) power->flags |= - (WL_TX_POWER_F_HW | WL_TX_POWER_F_ENABLED); + (WL_TX_POWER_F_HW | + WL_TX_POWER_F_ENABLED); else power->flags &= - ~(WL_TX_POWER_F_HW | WL_TX_POWER_F_ENABLED); + ~(WL_TX_POWER_F_HW | + WL_TX_POWER_F_ENABLED); wlc_lcnphy_get_tssi(pi, (s8 *) &power->est_Pout[0], (s8 *) &power->est_Pout_cck); @@ -2261,8 +2260,7 @@ void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val) if (!pi->sh->clk) return; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2306,7 +2304,7 @@ wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant) pwr_ant[i] = cmplx_pwr_dbm[i]; } pi->nphy_noise_index = - MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); + MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); return true; } @@ -2343,12 +2341,11 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) if (pi->phy_fixed_noise) { if (ISNPHY(pi)) { pi->nphy_noise_win[WL_ANT_IDX_1][pi->nphy_noise_index] = - PHY_NOISE_FIXED_VAL_NPHY; + PHY_NOISE_FIXED_VAL_NPHY; pi->nphy_noise_win[WL_ANT_IDX_2][pi->nphy_noise_index] = - PHY_NOISE_FIXED_VAL_NPHY; + PHY_NOISE_FIXED_VAL_NPHY; pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); - noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; } else { noise_dbm = PHY_NOISE_FIXED_VAL; @@ -2413,15 +2410,14 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) wlapi_enable_mac(pi->sh->physhim); for (i = 0; i < pi->pubpi.phy_corenum; i++) - cmplx_pwr[i] = - (est[i].i_pwr + - est[i].q_pwr) >> log_num_samps; + cmplx_pwr[i] = (est[i].i_pwr + est[i].q_pwr) >> + log_num_samps; wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); for (i = 0; i < pi->pubpi.phy_corenum; i++) { pi->nphy_noise_win[i][pi->nphy_noise_index] = - noise_dbm_ant[i]; + noise_dbm_ant[i]; if (noise_dbm_ant[i] > noise_dbm) noise_dbm = noise_dbm_ant[i]; @@ -2433,7 +2429,7 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) } } - done: +done: if (!wait_for_intr) wlc_phy_noise_cb(pi, ch, noise_dbm); @@ -2457,9 +2453,9 @@ static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) if (pi->phynoise_state & PHY_NOISE_STATE_MON) { if (pi->phynoise_chan_watchdog == channel) { pi->sh->phy_noise_window[pi->sh->phy_noise_index] = - noise_dbm; + noise_dbm; pi->sh->phy_noise_index = - MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); + MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); } pi->phynoise_state &= ~PHY_NOISE_STATE_MON; } @@ -2481,7 +2477,8 @@ static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); - for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, core++) { + for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, + core++) { lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx + 1)); @@ -2498,13 +2495,13 @@ static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) for (core = 0; core < pi->pubpi.phy_corenum; core++) { pi->nphy_noise_win[core][pi->nphy_noise_index] = - noise_dbm_ant[core]; + noise_dbm_ant[core]; if (noise_dbm_ant[core] > noise_dbm) noise_dbm = noise_dbm_ant[core]; } pi->nphy_noise_index = - MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); + MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); return noise_dbm; @@ -2665,7 +2662,7 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx) rssi = wlc_phy_rssi_compute_nphy(pi, wlc_rxhdr); } - end: +end: wlc_rxhdr->rssi = (s8) rssi; } @@ -2739,8 +2736,9 @@ void wlc_phy_watchdog(struct brcms_phy_pub *pih) ((pi->sh->now - pi->phy_lastcal) >= pi->sh->glacial_timer)) { if (!(SCAN_RM_IN_PROGRESS(pi) || ASSOC_INPROG_PHY(pi))) - wlc_lcnphy_calib_modes(pi, - LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL); + wlc_lcnphy_calib_modes( + pi, + LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL); if (! (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) || ASSOC_INPROG_PHY(pi) @@ -2763,7 +2761,7 @@ void wlc_phy_BSSinit(struct brcms_phy_pub *pih, bool bonlyap, int rssi) if (ISLCNPHY(pi)) { for (i = 0; i < MA_WINDOW_SZ; i++) pi->sh->phy_noise_window[i] = - PHY_NOISE_FIXED_VAL_LCNPHY; + PHY_NOISE_FIXED_VAL_LCNPHY; } pi->sh->phy_noise_index = 0; @@ -2819,9 +2817,8 @@ void wlc_phy_cordic(s32 theta, struct cs32 *val) angle = 0; signtheta = (theta < 0) ? -1 : 1; - theta = - ((theta + FIXED(180) * signtheta) % FIXED(360)) - - FIXED(180) * signtheta; + theta = ((theta + FIXED(180) * signtheta) % FIXED(360)) - + FIXED(180) * signtheta; if (FLOAT(theta) > 90) { theta -= FIXED(180); @@ -2895,8 +2892,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) if (PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_reset(pi); - wlc_phy_cal_perical_mphase_schedule(pi, - PHY_PERICAL_INIT_DELAY); + wlc_phy_cal_perical_mphase_schedule( + pi, + PHY_PERICAL_INIT_DELAY); } break; @@ -2921,9 +2919,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) if (pi->phycal_tempdelta) { nphy_currtemp = wlc_phy_tempsense_nphy(pi); delta_temp = - (nphy_currtemp > pi->nphy_lastcal_temp) ? - nphy_currtemp - pi->nphy_lastcal_temp : - pi->nphy_lastcal_temp - nphy_currtemp; + (nphy_currtemp > pi->nphy_lastcal_temp) ? + nphy_currtemp - pi->nphy_lastcal_temp : + pi->nphy_lastcal_temp - nphy_currtemp; if ((delta_temp < (s16) pi->phycal_tempdelta) && (pi->nphy_txiqlocal_chanspec == @@ -2936,8 +2934,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) if (do_periodic_cal) { if (pi->nphy_perical == PHY_PERICAL_MPHASE) { if (!PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_schedule(pi, - PHY_PERICAL_WDOG_DELAY); + wlc_phy_cal_perical_mphase_schedule( + pi, + PHY_PERICAL_WDOG_DELAY); } else if (pi->nphy_perical == PHY_PERICAL_SPHASE) wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); @@ -3035,11 +3034,11 @@ s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec) u8 siso_mcs_id, cdd_mcs_id; siso_mcs_id = - (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_SISO : - TXP_FIRST_MCS_20_SISO; + (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_SISO : + TXP_FIRST_MCS_20_SISO; cdd_mcs_id = - (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_CDD : - TXP_FIRST_MCS_20_CDD; + (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_CDD : + TXP_FIRST_MCS_20_CDD; if (pi->tx_power_target[siso_mcs_id] > (pi->tx_power_target[cdd_mcs_id] + 12)) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index bc0cc59d79b..d2faba2e522 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -126,28 +126,32 @@ struct txpwr_limits { struct tx_power { u32 flags; - u16 chanspec; /* txpwr report for this channel */ - u16 local_chanspec; /* channel on which we are associated */ - u8 local_max; /* local max according to the AP */ - u8 local_constraint; /* local constraint according to the AP */ - s8 antgain[2]; /* Ant gain for each band - from SROM */ - u8 rf_cores; /* count of RF Cores being reported */ - u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */ - u8 est_Pout_act[4]; /* Latest tx power out estimate per RF chain - * without adjustment - */ - u8 est_Pout_cck; /* Latest CCK tx power out estimate */ - u8 tx_power_max[4]; /* Maximum target power among all rates */ - u8 tx_power_max_rate_ind[4]; /* Index of the rate with the max target power */ - u8 user_limit[WL_TX_POWER_RATES]; /* User limit */ - u8 reg_limit[WL_TX_POWER_RATES]; /* Regulatory power limit */ - u8 board_limit[WL_TX_POWER_RATES]; /* Max power board can support (SROM) */ - u8 target[WL_TX_POWER_RATES]; /* Latest target power */ + u16 chanspec; /* txpwr report for this channel */ + u16 local_chanspec; /* channel on which we are associated */ + u8 local_max; /* local max according to the AP */ + u8 local_constraint; /* local constraint according to the AP */ + s8 antgain[2]; /* Ant gain for each band - from SROM */ + u8 rf_cores; /* count of RF Cores being reported */ + u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */ + u8 est_Pout_act[4]; /* Latest tx power out estimate per RF chain + * without adjustment */ + u8 est_Pout_cck; /* Latest CCK tx power out estimate */ + u8 tx_power_max[4]; /* Maximum target power among all rates */ + /* Index of the rate with the max target power */ + u8 tx_power_max_rate_ind[4]; + /* User limit */ + u8 user_limit[WL_TX_POWER_RATES]; + /* Regulatory power limit */ + u8 reg_limit[WL_TX_POWER_RATES]; + /* Max power board can support (SROM) */ + u8 board_limit[WL_TX_POWER_RATES]; + /* Latest target power */ + u8 target[WL_TX_POWER_RATES]; }; struct tx_inst_power { - u8 txpwr_est_Pout[2]; /* Latest estimate for 2.4 and 5 Ghz */ - u8 txpwr_est_Pout_gofdm; /* Pwr estimate for 2.4 OFDM */ + u8 txpwr_est_Pout[2]; /* Latest estimate for 2.4 and 5 Ghz */ + u8 txpwr_est_Pout_gofdm; /* Pwr estimate for 2.4 OFDM */ }; struct brcms_chanvec { @@ -178,7 +182,8 @@ struct shared_phy_params { extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, void *regs, - int bandtype, char *vars, struct wiphy *wiphy); + int bandtype, char *vars, + struct wiphy *wiphy); extern void wlc_phy_detach(struct brcms_phy_pub *ppi); extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, @@ -222,7 +227,7 @@ extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi, extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, struct brcms_chanvec *channels); extern u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, - uint band); + uint band); extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, u8 *_min_, u8 *_max_, int rate); @@ -289,6 +294,6 @@ extern void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi); extern const u8 *wlc_phy_get_ofdm_rate_lookup(void); extern s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi, - u8 mcs_offset); + u8 mcs_offset); extern s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset); -#endif /* _BRCM_PHY_HAL_H_ */ +#endif /* _BRCM_PHY_HAL_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index e580420d203..25ea00342f5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -42,11 +42,16 @@ extern u32 phyhal_msg_level; #define LCNXN_BASEREV 16 struct brcms_phy_srom_fem { - u8 tssipos; /* TSSI positive slope, 1: positive, 0: negative */ - u8 extpagain; /* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */ - u8 pdetrange; /* support 32 combinations of different Pdet dynamic ranges */ - u8 triso; /* TR switch isolation */ - u8 antswctrllut; /* antswctrl lookup table configuration: 32 possible choices */ + /* TSSI positive slope, 1: positive, 0: negative */ + u8 tssipos; + /* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */ + u8 extpagain; + /* support 32 combinations of different Pdet dynamic ranges */ + u8 pdetrange; + /* TR switch isolation */ + u8 triso; + /* antswctrl lookup table configuration: 32 possible choices */ + u8 antswctrllut; }; #undef ISNPHY @@ -192,7 +197,9 @@ struct brcms_phy_srom_fem { #define PHY_PERICAL_WDOG_DELAY 5 #define MPHASE_TXCAL_NUMCMDS 2 -#define PHY_PERICAL_MPHASE_PENDING(pi) (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE) + +#define PHY_PERICAL_MPHASE_PENDING(pi) \ + (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE) enum { MPHASE_CAL_STATE_IDLE = 0, @@ -237,7 +244,9 @@ enum phy_cal_mode { #define CORDIC_AG 39797 #define CORDIC_NI 18 #define FIXED(X) ((s32)((X) << 16)) -#define FLOAT(X) (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1)) + +#define FLOAT(X) \ + (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1)) #define PHY_CHAIN_TX_DISABLE_TEMP 115 #define PHY_HYSTERESIS_DELTATEMP 5 @@ -245,30 +254,46 @@ enum phy_cal_mode { #define PHY_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8)) #define MOD_PHY_REG(pi, phy_type, reg_name, field, value) \ - mod_phy_reg(pi, phy_type##_##reg_name, phy_type##_##reg_name##_##field##_MASK, \ - (value) << phy_type##_##reg_name##_##field##_##SHIFT) + mod_phy_reg(pi, phy_type##_##reg_name, \ + phy_type##_##reg_name##_##field##_MASK, \ + (value) << phy_type##_##reg_name##_##field##_##SHIFT) + #define READ_PHY_REG(pi, phy_type, reg_name, field) \ - ((read_phy_reg(pi, phy_type##_##reg_name) & phy_type##_##reg_name##_##field##_##MASK)\ - >> phy_type##_##reg_name##_##field##_##SHIFT) + ((read_phy_reg(pi, phy_type##_##reg_name) & \ + phy_type##_##reg_name##_##field##_##MASK) \ + >> phy_type##_##reg_name##_##field##_##SHIFT) #define VALID_PHYTYPE(phytype) (((uint)phytype == PHY_TYPE_N) || \ ((uint)phytype == PHY_TYPE_LCN)) -#define VALID_N_RADIO(radioid) ((radioid == BCM2055_ID) || (radioid == BCM2056_ID) || \ - (radioid == BCM2057_ID)) +#define VALID_N_RADIO(radioid) ((radioid == BCM2055_ID) || \ + (radioid == BCM2056_ID) || \ + (radioid == BCM2057_ID)) + #define VALID_LCN_RADIO(radioid) (radioid == BCM2064_ID) -#define VALID_RADIO(pi, radioid) (\ - (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ - (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) +#define VALID_RADIO(pi, radioid) ( \ + (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ + (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) -#define SCAN_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN)) -#define RM_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_RM)) -#define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT)) -#define ASSOC_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC)) -#define SCAN_RM_IN_PROGRESS(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM)) -#define PHY_MUTED(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE)) -#define PUB_NOT_ASSOC(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC)) +#define SCAN_INPROG_PHY(pi) \ + (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN)) + +#define RM_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_RM)) + +#define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT)) + +#define ASSOC_INPROG_PHY(pi) \ + (mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC)) + +#define SCAN_RM_IN_PROGRESS(pi) \ + (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM)) + +#define PHY_MUTED(pi) \ + (mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE)) + +#define PUB_NOT_ASSOC(pi) \ + (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC)) #if defined(EXT_CBALL) #define NORADIO_ENAB(pub) ((pub).radioid == NORADIO_ID) @@ -568,18 +593,18 @@ struct brcms_phy_pub { }; struct phy_func_ptr { - void (*init) (struct brcms_phy *); - void (*calinit) (struct brcms_phy *); - void (*chanset) (struct brcms_phy *, u16 chanspec); - void (*txpwrrecalc) (struct brcms_phy *); - int (*longtrn) (struct brcms_phy *, int); - void (*txiqccget) (struct brcms_phy *, u16 *, u16 *); - void (*txiqccset) (struct brcms_phy *, u16, u16); - u16(*txloccget) (struct brcms_phy *); - void (*radioloftget) (struct brcms_phy *, u8 *, u8 *, u8 *, u8 *); - void (*carrsuppr) (struct brcms_phy *); - s32(*rxsigpwr) (struct brcms_phy *, s32); - void (*detach) (struct brcms_phy *); + void (*init)(struct brcms_phy *); + void (*calinit)(struct brcms_phy *); + void (*chanset)(struct brcms_phy *, u16 chanspec); + void (*txpwrrecalc)(struct brcms_phy *); + int (*longtrn)(struct brcms_phy *, int); + void (*txiqccget)(struct brcms_phy *, u16 *, u16 *); + void (*txiqccset)(struct brcms_phy *, u16, u16); + u16 (*txloccget)(struct brcms_phy *); + void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *); + void (*carrsuppr)(struct brcms_phy *); + s32 (*rxsigpwr)(struct brcms_phy *, s32); + void (*detach)(struct brcms_phy *); }; struct brcms_phy { @@ -712,7 +737,7 @@ struct brcms_phy { u16 mintxbias; u16 mintxmag; struct lo_complex_abgphy_info gphy_locomp_iq - [STATIC_NUM_RF][STATIC_NUM_BB]; + [STATIC_NUM_RF][STATIC_NUM_BB]; s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB]; u16 gain_table[TX_GAIN_TABLE_LENGTH]; bool loopback_gain; @@ -955,26 +980,29 @@ struct lcnphy_radio_regs { extern struct lcnphy_radio_regs lcnphy_radio_regs_2064[]; extern struct lcnphy_radio_regs lcnphy_radio_regs_2066[]; + extern struct radio_regs regs_2055[], regs_SYN_2056[], regs_TX_2056[], - regs_RX_2056[]; + regs_RX_2056[]; extern struct radio_regs regs_SYN_2056_A1[], regs_TX_2056_A1[], - regs_RX_2056_A1[]; + regs_RX_2056_A1[]; extern struct radio_regs regs_SYN_2056_rev5[], regs_TX_2056_rev5[], - regs_RX_2056_rev5[]; + regs_RX_2056_rev5[]; extern struct radio_regs regs_SYN_2056_rev6[], regs_TX_2056_rev6[], - regs_RX_2056_rev6[]; + regs_RX_2056_rev6[]; extern struct radio_regs regs_SYN_2056_rev7[], regs_TX_2056_rev7[], - regs_RX_2056_rev7[]; + regs_RX_2056_rev7[]; extern struct radio_regs regs_SYN_2056_rev8[], regs_TX_2056_rev8[], - regs_RX_2056_rev8[]; + regs_RX_2056_rev8[]; + extern struct radio_20xx_regs regs_2057_rev4[], regs_2057_rev5[], - regs_2057_rev5v1[]; + regs_2057_rev5v1[]; extern struct radio_20xx_regs regs_2057_rev7[], regs_2057_rev8[]; extern char *phy_getvar(struct brcms_phy *pi, const char *name); extern int phy_getintvar(struct brcms_phy *pi, const char *name); -#define PHY_GETVAR(pi, name) phy_getvar(pi, name) -#define PHY_GETINTVAR(pi, name) phy_getintvar(pi, name) + +#define PHY_GETVAR(pi, name) phy_getvar(pi, name) +#define PHY_GETINTVAR(pi, name) phy_getintvar(pi, name) extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr); extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); @@ -1131,13 +1159,17 @@ extern void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable); extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode); -#define wlc_phy_write_table_nphy(pi, pti) wlc_phy_write_table(pi, pti, 0x72, \ - 0x74, 0x73) -#define wlc_phy_read_table_nphy(pi, pti) wlc_phy_read_table(pi, pti, 0x72, \ - 0x74, 0x73) -#define wlc_nphy_table_addr(pi, id, off) wlc_phy_table_addr((pi), (id), (off), \ - 0x72, 0x74, 0x73) -#define wlc_nphy_table_data_write(pi, w, v) wlc_phy_table_data_write((pi), (w), (v)) +#define wlc_phy_write_table_nphy(pi, pti) \ + wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73) + +#define wlc_phy_read_table_nphy(pi, pti) \ + wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73) + +#define wlc_nphy_table_addr(pi, id, off) \ + wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73) + +#define wlc_nphy_table_data_write(pi, w, v) \ + wlc_phy_table_data_write((pi), (w), (v)) extern void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, u32 w, void *d); @@ -1218,7 +1250,7 @@ extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs); void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset); extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, - u16 chanspec); + u16 chanspec); extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih); #endif /* _BRCM_PHY_INT_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index d64a98fd4f9..a109866dcf2 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -79,15 +79,15 @@ #define wlc_lcnphy_enable_tx_gain_override(pi) \ wlc_lcnphy_set_tx_gain_override(pi, true) -#define wlc_lcnphy_disable_tx_gain_override(pi) \ +#define wlc_lcnphy_disable_tx_gain_override(pi) \ wlc_lcnphy_set_tx_gain_override(pi, false) #define wlc_lcnphy_iqcal_active(pi) \ (read_phy_reg((pi), 0x451) & \ - ((0x1 << 15) | (0x1 << 14))) + ((0x1 << 15) | (0x1 << 14))) #define txpwrctrl_off(pi) (0x7 != ((read_phy_reg(pi, 0x4a4) & 0xE000) >> 13)) -#define wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) \ +#define wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) \ (pi->temppwrctrl_capable) #define wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi) \ (pi->hwpwrctrl_capable) @@ -132,12 +132,12 @@ #define LCNPHY_ACI_DETECT_TIMEOUT 2 #define LCNPHY_ACI_START_DELAY 0 -#define wlc_lcnphy_tx_gain_override_enabled(pi) \ +#define wlc_lcnphy_tx_gain_override_enabled(pi) \ (0 != (read_phy_reg((pi), 0x43b) & (0x1 << 6))) #define wlc_lcnphy_total_tx_frames(pi) \ - wlapi_bmac_read_shm((pi)->sh->physhim, \ - M_UCODE_MACSTAT + offsetof(struct macstat, txallfrm)) + wlapi_bmac_read_shm((pi)->sh->physhim, M_UCODE_MACSTAT + \ + offsetof(struct macstat, txallfrm)) struct lcnphy_txgains { u16 gm_gain; @@ -198,7 +198,7 @@ static const iqcal_gain_params_lcnphy *tbl_iqcal_gainparams_lcnphy[1] = { static const u16 iqcal_gainparams_numgains_lcnphy[1] = { sizeof(tbl_iqcal_gainparams_lcnphy_2G) / - sizeof(*tbl_iqcal_gainparams_lcnphy_2G), + sizeof(*tbl_iqcal_gainparams_lcnphy_2G), }; static const struct lcnphy_sfo_cfg lcnphy_sfo_cfg[] = { @@ -920,47 +920,52 @@ u16 LCNPHY_txdigfiltcoeffs_ofdm[LCNPHY_NUM_TX_DIG_FILTERS_OFDM] #define wlc_lcnphy_set_start_tx_pwr_idx(pi, idx) \ mod_phy_reg(pi, 0x4a4, \ - (0x1ff << 0), \ - (u16)(idx) << 0) + (0x1ff << 0), \ + (u16)(idx) << 0) #define wlc_lcnphy_set_tx_pwr_npt(pi, npt) \ mod_phy_reg(pi, 0x4a5, \ - (0x7 << 8), \ - (u16)(npt) << 8) + (0x7 << 8), \ + (u16)(npt) << 8) #define wlc_lcnphy_get_tx_pwr_ctrl(pi) \ (read_phy_reg((pi), 0x4a4) & \ - ((0x1 << 15) | \ - (0x1 << 14) | \ - (0x1 << 13))) + ((0x1 << 15) | \ + (0x1 << 14) | \ + (0x1 << 13))) #define wlc_lcnphy_get_tx_pwr_npt(pi) \ ((read_phy_reg(pi, 0x4a5) & \ - (0x7 << 8)) >> \ - 8) + (0x7 << 8)) >> \ + 8) #define wlc_lcnphy_get_current_tx_pwr_idx_if_pwrctrl_on(pi) \ (read_phy_reg(pi, 0x473) & 0x1ff) #define wlc_lcnphy_get_target_tx_pwr(pi) \ ((read_phy_reg(pi, 0x4a7) & \ - (0xff << 0)) >> \ - 0) + (0xff << 0)) >> \ + 0) #define wlc_lcnphy_set_target_tx_pwr(pi, target) \ mod_phy_reg(pi, 0x4a7, \ - (0xff << 0), \ - (u16)(target) << 0) + (0xff << 0), \ + (u16)(target) << 0) -#define wlc_radio_2064_rcal_done(pi) (0 != (read_radio_reg(pi, RADIO_2064_REG05C) & 0x20)) -#define tempsense_done(pi) (0x8000 == (read_phy_reg(pi, 0x476) & 0x8000)) +#define wlc_radio_2064_rcal_done(pi) \ + (0 != (read_radio_reg(pi, RADIO_2064_REG05C) & 0x20)) + +#define tempsense_done(pi) \ + (0x8000 == (read_phy_reg(pi, 0x476) & 0x8000)) + +#define LCNPHY_IQLOCC_READ(val) \ + ((u8)(-(s8)(((val) & 0xf0) >> 4) + (s8)((val) & 0x0f))) -#define LCNPHY_IQLOCC_READ(val) ((u8)(-(s8)(((val) & 0xf0) >> 4) + (s8)((val) & 0x0f))) #define FIXED_TXPWR 78 #define LCNPHY_TEMPSENSE(val) ((s16)((val > 255) ? (val - 512) : val)) static u32 wlc_lcnphy_qdiv_roundup(u32 divident, u32 divisor, - u8 precision); + u8 precision); static void wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, u16 ext_lna, u16 trsw, u16 biq2, u16 biq1, @@ -989,8 +994,10 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi); static void wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel); -static void wlc_lcnphy_load_tx_gain_table(struct brcms_phy *pi, - const struct lcnphy_tx_gain_tbl_entry *g); +static void wlc_lcnphy_load_tx_gain_table( + struct brcms_phy *pi, + const struct lcnphy_tx_gain_tbl_entry + *g); static void wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, s16 *ptr, int mode); @@ -1115,9 +1122,8 @@ s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi) if (txpwrctrl_off(pi)) index = pi_lcn->lcnphy_current_index; else if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) - index = - (s8) (wlc_lcnphy_get_current_tx_pwr_idx_if_pwrctrl_on(pi) - / 2); + index = (s8) (wlc_lcnphy_get_current_tx_pwr_idx_if_pwrctrl_on( + pi) / 2); else index = pi_lcn->lcnphy_current_index; return index; @@ -1265,7 +1271,7 @@ static u16 wlc_lcnphy_get_pa_gain(struct brcms_phy *pi) pa_gain = (read_phy_reg(pi, 0x4fb) & LCNPHY_txgainctrlovrval1_pagain_ovr_val1_MASK) >> - LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT; + LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT; return pa_gain; } @@ -1275,18 +1281,22 @@ static void wlc_lcnphy_set_tx_gain(struct brcms_phy *pi, { u16 pa_gain = wlc_lcnphy_get_pa_gain(pi); - mod_phy_reg(pi, 0x4b5, - (0xffff << 0), - ((target_gains->gm_gain) | (target_gains->pga_gain << 8)) << - 0); + mod_phy_reg( + pi, 0x4b5, + (0xffff << 0), + ((target_gains->gm_gain) | + (target_gains->pga_gain << 8)) << + 0); mod_phy_reg(pi, 0x4fb, (0x7fff << 0), ((target_gains->pad_gain) | (pa_gain << 8)) << 0); - mod_phy_reg(pi, 0x4fc, - (0xffff << 0), - ((target_gains->gm_gain) | (target_gains->pga_gain << 8)) << - 0); + mod_phy_reg( + pi, 0x4fc, + (0xffff << 0), + ((target_gains->gm_gain) | + (target_gains->pga_gain << 8)) << + 0); mod_phy_reg(pi, 0x4fd, (0x7fff << 0), ((target_gains->pad_gain) | (pa_gain << 8)) << 0); @@ -1404,8 +1414,8 @@ static void wlc_lcnphy_pwrctrl_rssiparams(struct brcms_phy *pi) u16 auxpga_vmid, auxpga_vmid_temp, auxpga_gain_temp; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - auxpga_vmid = - (2 << 8) | (pi_lcn->lcnphy_rssi_vc << 4) | pi_lcn->lcnphy_rssi_vf; + auxpga_vmid = (2 << 8) | + (pi_lcn->lcnphy_rssi_vc << 4) | pi_lcn->lcnphy_rssi_vf; auxpga_vmid_temp = (2 << 8) | (8 << 4) | 4; auxpga_gain_temp = 2; @@ -1600,7 +1610,7 @@ void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi) { struct phytbl_info tab; u32 rate_table[BRCMS_NUM_RATES_CCK + BRCMS_NUM_RATES_OFDM + - BRCMS_NUM_RATES_MCS_1_STREAM]; + BRCMS_NUM_RATES_MCS_1_STREAM]; uint i, j; if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) return; @@ -1715,9 +1725,9 @@ static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) } delta_temp = (s8) wlc_lcnphy_qdiv_roundup((u32) (temp_diff * 192), - (u32) (pi_lcn-> - lcnphy_tempsense_slope - * 10), 0); + (u32) (pi_lcn-> + lcnphy_tempsense_slope + * 10), 0); if (neg) delta_temp = -delta_temp; @@ -1731,7 +1741,7 @@ static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) if (LCNREV_IS(pi->pubpi.phy_rev, 1)) tempcorrx = 4; new_index = - index + delta_brd + delta_temp - pi_lcn->lcnphy_bandedge_corr; + index + delta_brd + delta_temp - pi_lcn->lcnphy_bandedge_corr; new_index += tempcorrx; if (LCNREV_IS(pi->pubpi.phy_rev, 1)) @@ -1789,7 +1799,7 @@ void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode) mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 0); pi_lcn->lcnphy_tssi_tx_cnt = - wlc_lcnphy_total_tx_frames(pi); + wlc_lcnphy_total_tx_frames(pi); wlc_lcnphy_disable_tx_gain_override(pi); pi_lcn->lcnphy_tx_power_idx_override = -1; @@ -1802,7 +1812,9 @@ void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode) index = wlc_lcnphy_tempcompensated_txpwrctrl(pi); wlc_lcnphy_set_tx_pwr_soft_ctrl(pi, index); pi_lcn->lcnphy_current_index = (s8) - ((read_phy_reg(pi, 0x4a9) & 0xFF) / 2); + ((read_phy_reg(pi, + 0x4a9) & + 0xFF) / 2); } } } @@ -1834,20 +1846,23 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, int j; u16 ncorr_override[5]; u16 syst_coeffs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; u16 commands_fullcal[] = { - 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 }; + 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 + }; u16 commands_recal[] = { - 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 }; + 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 + }; u16 command_nums_fullcal[] = { - 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 }; + 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 + }; u16 command_nums_recal[] = { - 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 }; + 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 + }; u16 *command_nums = command_nums_fullcal; u16 *start_coeffs = NULL, *cal_cmds = NULL, cal_type, diq_start; @@ -1923,7 +1938,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, } hash = (target_gains->gm_gain << 8) | - (target_gains->pga_gain << 4) | (target_gains->pad_gain); + (target_gains->pga_gain << 4) | (target_gains->pad_gain); band_idx = (CHSPEC_IS5G(pi->radio_chanspec) ? 1 : 0); @@ -1932,11 +1947,11 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, for (j = 0; j < iqcal_gainparams_numgains_lcnphy[band_idx]; j++) { if (hash == tbl_iqcal_gainparams_lcnphy[band_idx][j][0]) { cal_gains.gm_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][1]; + tbl_iqcal_gainparams_lcnphy[band_idx][j][1]; cal_gains.pga_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][2]; + tbl_iqcal_gainparams_lcnphy[band_idx][j][2]; cal_gains.pad_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][3]; + tbl_iqcal_gainparams_lcnphy[band_idx][j][3]; memcpy(ncorr_override, &tbl_iqcal_gainparams_lcnphy[band_idx][j][3], sizeof(ncorr_override)); @@ -1957,7 +1972,8 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, (const void *)lcnphy_iqcal_ir_gainladder, - ARRAY_SIZE(lcnphy_iqcal_ir_gainladder), 16, + ARRAY_SIZE( + lcnphy_iqcal_ir_gainladder), 16, 32); if (pi->phy_tx_tone_freq) { @@ -1981,8 +1997,8 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, command_num = command_nums[i]; if (ncorr_override[cal_type]) command_num = - ncorr_override[cal_type] << 8 | (command_num & - 0xff); + ncorr_override[cal_type] << 8 | (command_num & + 0xff); write_phy_reg(pi, 0x452, command_num); @@ -2013,8 +2029,8 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, pi_lcn->lcnphy_cal_results. txiqlocal_bestcoeffs, ARRAY_SIZE(pi_lcn-> - lcnphy_cal_results. - txiqlocal_bestcoeffs), + lcnphy_cal_results. + txiqlocal_bestcoeffs), 16, 96); } @@ -2022,7 +2038,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, pi_lcn->lcnphy_cal_results. txiqlocal_bestcoeffs, ARRAY_SIZE(pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs), 16, 96); + txiqlocal_bestcoeffs), 16, 96); pi_lcn->lcnphy_cal_results.txiqlocal_bestcoeffs_valid = true; wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, @@ -2033,7 +2049,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, &pi_lcn->lcnphy_cal_results. txiqlocal_bestcoeffs[5], 2, 16, 85); - cleanup: +cleanup: wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, values_to_save); kfree(values_to_save); @@ -2063,14 +2079,14 @@ static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); u16 SAVE_lpfgain = read_radio_reg(pi, RADIO_2064_REG112); u16 SAVE_jtag_bb_afe_switch = - read_radio_reg(pi, RADIO_2064_REG007) & 1; + read_radio_reg(pi, RADIO_2064_REG007) & 1; u16 SAVE_jtag_auxpga = read_radio_reg(pi, RADIO_2064_REG0FF) & 0x10; u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; idleTssi = read_phy_reg(pi, 0x4ab); suspend = - (0 == - (R_REG(&((struct brcms_phy *) pi)->regs->maccontrol) & - MCTL_EN_MAC)); + (0 == + (R_REG(&((struct brcms_phy *) pi)->regs->maccontrol) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); @@ -2128,7 +2144,7 @@ static void wlc_lcnphy_vbat_temp_sense_setup(struct brcms_phy *pi, u8 mode) struct phytbl_info tab; u32 val; u8 save_reg007, save_reg0FF, save_reg11F, save_reg005, save_reg025, - save_reg112; + save_reg112; u16 values_to_save[14]; s8 index; int i; @@ -2144,8 +2160,7 @@ static void wlc_lcnphy_vbat_temp_sense_setup(struct brcms_phy *pi, u8 mode) for (i = 0; i < 14; i++) values_to_save[i] = read_phy_reg(pi, tempsense_phy_regs[i]); - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); save_txpwrCtrlEn = read_radio_reg(pi, 0x4a4); @@ -2228,7 +2243,7 @@ static void wlc_lcnphy_vbat_temp_sense_setup(struct brcms_phy *pi, u8 mode) auxpga_gain = 2; } auxpga_vmid = - (u16) ((2 << 8) | (auxpga_vmidcourse << 4) | auxpga_vmidfine); + (u16) ((2 << 8) | (auxpga_vmidcourse << 4) | auxpga_vmidfine); mod_phy_reg(pi, 0x4d8, (0x1 << 0), (1) << 0); mod_phy_reg(pi, 0x4d8, (0x3ff << 2), (auxpga_vmid) << 2); @@ -2272,7 +2287,7 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi) struct brcms_phy *pi = (struct brcms_phy *) ppi; suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2522,9 +2537,10 @@ wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, gain16_19 = biq2 & 0xf; gain0_15 = ((biq1 & 0xf) << 12) | - ((tia & 0xf) << 8) | - ((lna2 & 0x3) << 6) | - ((lna2 & 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); + ((tia & 0xf) << 8) | + ((lna2 & 0x3) << 6) | + ((lna2 & + 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); @@ -2581,9 +2597,9 @@ void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable) and_phy_reg(pi, 0x44c, ~(u16) ((0x1 << 3) | - (0x1 << 5) | - (0x1 << 12) | - (0x1 << 0) | (0x1 << 1) | (0x1 << 2))); + (0x1 << 5) | + (0x1 << 12) | + (0x1 << 0) | (0x1 << 1) | (0x1 << 2))); and_phy_reg(pi, 0x44d, ~(u16) ((0x1 << 3) | (0x1 << 5) | (0x1 << 14))); @@ -2693,7 +2709,8 @@ void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode) mod_phy_reg((pi), 0x410, (0x1 << 6) | (0x1 << 5), - ((CHSPEC_IS2G(pi->radio_chanspec)) ? (!mode) : 0) << + ((CHSPEC_IS2G( + pi->radio_chanspec)) ? (!mode) : 0) << 6 | (!mode) << 5); mod_phy_reg(pi, 0x410, (0x1 << 7), (mode) << 7); } @@ -2916,7 +2933,7 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) wlc_lcnphy_read_table(pi, &tab); val = (val & 0xfff00000) | - ((u32) (a & 0x3FF) << 10) | (b & 0x3ff); + ((u32) (a & 0x3FF) << 10) | (b & 0x3ff); wlc_lcnphy_write_table(pi, &tab); val = didq; @@ -2953,8 +2970,8 @@ s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode) if (mode == 1) { suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -3000,8 +3017,8 @@ u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode) if (mode == 1) { suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -3052,8 +3069,9 @@ s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode) { s32 degree = wlc_lcnphy_tempsense_new(pi, mode); degree = - ((degree << 10) + LCN_TEMPSENSE_OFFSET + (LCN_TEMPSENSE_DEN >> 1)) - / LCN_TEMPSENSE_DEN; + ((degree << + 10) + LCN_TEMPSENSE_OFFSET + (LCN_TEMPSENSE_DEN >> 1)) + / LCN_TEMPSENSE_DEN; return (s8) degree; } @@ -3068,8 +3086,8 @@ s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode) if (mode == 1) { suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, VBATSENSE); @@ -3082,9 +3100,8 @@ s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode) else avg = (s32) vbatsenseval; - avg = - (avg * LCN_VBAT_SCALE_NOM + - (LCN_VBAT_SCALE_DEN >> 1)) / LCN_VBAT_SCALE_DEN; + avg = (avg * LCN_VBAT_SCALE_NOM + + (LCN_VBAT_SCALE_DEN >> 1)) / LCN_VBAT_SCALE_DEN; if (mode == 1) { if (!suspend) @@ -3140,13 +3157,13 @@ wlc_lcnphy_rx_iq_est(struct brcms_phy *pi, } iq_est->iq_prod = ((u32) read_phy_reg(pi, 0x483) << 16) | - (u32) read_phy_reg(pi, 0x484); + (u32) read_phy_reg(pi, 0x484); iq_est->i_pwr = ((u32) read_phy_reg(pi, 0x485) << 16) | - (u32) read_phy_reg(pi, 0x486); + (u32) read_phy_reg(pi, 0x486); iq_est->q_pwr = ((u32) read_phy_reg(pi, 0x487) << 16) | - (u32) read_phy_reg(pi, 0x488); + (u32) read_phy_reg(pi, 0x488); - cleanup: +cleanup: mod_phy_reg(pi, 0x410, (0x1 << 3), (1) << 3); mod_phy_reg(pi, 0x6da, (0x1 << 5), (0) << 5); @@ -3221,7 +3238,7 @@ static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps) b -= (1 << 10); a0_new = (u16) (a & 0x3ff); b0_new = (u16) (b & 0x3ff); - cleanup: +cleanup: wlc_lcnphy_set_rx_iq_comp(pi, a0_new, b0_new); @@ -3282,7 +3299,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, for (i = 0; i < 11; i++) values_to_save[i] = - read_radio_reg(pi, rxiq_cal_rf_reg[i]); + read_radio_reg(pi, rxiq_cal_rf_reg[i]); Core1TxControl_old = read_phy_reg(pi, 0x631); or_phy_reg(pi, 0x631, 0x0015); @@ -3356,7 +3373,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, udelay(500); received_power = - wlc_lcnphy_measure_digital_power(pi, 2000); + wlc_lcnphy_measure_digital_power(pi, 2000); if (received_power < rx_pwr_threshold) break; } @@ -3396,7 +3413,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, wlc_lcnphy_rx_gain_override_enable(pi, false); } - cal_done: +cal_done: kfree(ptr); return result; } @@ -3414,7 +3431,7 @@ static void wlc_lcnphy_glacial_timer_based_cal(struct brcms_phy *pi) u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_deaf_mode(pi, true); @@ -3450,13 +3467,13 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) pi->phy_lastcal = pi->sh->now; pi->phy_forcecal = false; full_cal = - (pi_lcn->lcnphy_full_cal_channel != - CHSPEC_CHANNEL(pi->radio_chanspec)); + (pi_lcn->lcnphy_full_cal_channel != + CHSPEC_CHANNEL(pi->radio_chanspec)); pi_lcn->lcnphy_full_cal_channel = CHSPEC_CHANNEL(pi->radio_chanspec); index = pi_lcn->lcnphy_current_index; suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) { wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -3538,7 +3555,7 @@ void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode) case LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL: if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) wlc_lcnphy_tx_power_adjustment( - (struct brcms_phy_pub *) pi); + (struct brcms_phy_pub *) pi); break; } } @@ -3551,7 +3568,7 @@ void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr) if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi) && (status & (0x1 << 15))) { *ofdm_pwr = (s8) (((read_phy_reg(pi, 0x4ab) & (0x1ff << 0)) - >> 0) >> 1); + >> 0) >> 1); if (wlc_phy_tpc_isenabled_lcnphy(pi)) cck_offset = pi->tx_power_offset[TXP_FIRST_CCK]; @@ -3629,13 +3646,14 @@ void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi) struct brcms_phy *pi = (struct brcms_phy *) ppi; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) && SAVE_txpwrctrl) { + if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) && + SAVE_txpwrctrl) { index = wlc_lcnphy_tempcompensated_txpwrctrl(pi); index2 = (u16) (index * 2); mod_phy_reg(pi, 0x4a9, (0x1ff << 0), (index2) << 0); - pi_lcn->lcnphy_current_index = (s8) - ((read_phy_reg(pi, 0x4a9) & 0xFF) / 2); + pi_lcn->lcnphy_current_index = + (s8)((read_phy_reg(pi, 0x4a9) & 0xFF) / 2); } } @@ -3711,7 +3729,7 @@ wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, u16 *values_to_save) int i; for (i = 0; i < 20; i++) values_to_save[i] = - read_radio_reg(pi, iqlo_loopback_rf_regs[i]); + read_radio_reg(pi, iqlo_loopback_rf_regs[i]); mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); @@ -4140,8 +4158,8 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, phy_c18 = phy_c18 >> 10; phy_c19 = phy_c19 >> 10; - phy_c20 = - ((phy_c18 * phy_c18) + (phy_c19 * phy_c19)); + phy_c20 = ((phy_c18 * phy_c18) + + (phy_c19 * phy_c19)); if (phy_c23 || phy_c20 < phy_c21) { phy_c21 = phy_c20; @@ -4159,7 +4177,7 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, udelay(20); } goto cleanup; - cleanup: +cleanup: wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, phy_c32); wlc_lcnphy_stop_tx_tone(pi); write_phy_reg(pi, 0x6da, phy_c26); @@ -4189,7 +4207,8 @@ wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, u16 *values_to_save) static void wlc_lcnphy_load_tx_gain_table(struct brcms_phy *pi, - const struct lcnphy_tx_gain_tbl_entry *gain_table) { + const struct lcnphy_tx_gain_tbl_entry *gain_table) +{ u32 j; struct phytbl_info tab; u32 val; @@ -4313,11 +4332,13 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if (pi->sh->boardflags & BFL_FEM) - wlc_lcnphy_load_tx_gain_table(pi, - dot11lcnphy_2GHz_extPA_gaintable_rev0); + wlc_lcnphy_load_tx_gain_table( + pi, + dot11lcnphy_2GHz_extPA_gaintable_rev0); else - wlc_lcnphy_load_tx_gain_table(pi, - dot11lcnphy_2GHz_gaintable_rev0); + wlc_lcnphy_load_tx_gain_table( + pi, + dot11lcnphy_2GHz_gaintable_rev0); } if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { @@ -4326,25 +4347,33 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) idx < dot11lcnphytbl_rx_gain_info_2G_rev2_sz; idx++) if (pi->sh->boardflags & BFL_EXTLNA) - wlc_lcnphy_write_table(pi, - &dot11lcnphytbl_rx_gain_info_extlna_2G_rev2 - [idx]); + wlc_lcnphy_write_table( + pi, + & + dot11lcnphytbl_rx_gain_info_extlna_2G_rev2 + [idx]); else - wlc_lcnphy_write_table(pi, - &dot11lcnphytbl_rx_gain_info_2G_rev2 - [idx]); + wlc_lcnphy_write_table( + pi, + & + dot11lcnphytbl_rx_gain_info_2G_rev2 + [idx]); } else { for (idx = 0; idx < dot11lcnphytbl_rx_gain_info_5G_rev2_sz; idx++) if (pi->sh->boardflags & BFL_EXTLNA_5GHz) - wlc_lcnphy_write_table(pi, - &dot11lcnphytbl_rx_gain_info_extlna_5G_rev2 - [idx]); + wlc_lcnphy_write_table( + pi, + & + dot11lcnphytbl_rx_gain_info_extlna_5G_rev2 + [idx]); else - wlc_lcnphy_write_table(pi, - &dot11lcnphytbl_rx_gain_info_5G_rev2 - [idx]); + wlc_lcnphy_write_table( + pi, + & + dot11lcnphytbl_rx_gain_info_5G_rev2 + [idx]); } } @@ -4353,11 +4382,13 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313_epa); else if (pi->sh->boardflags & BFL_FEM_BT) { if (pi->sh->boardrev < 0x1250) - wlc_lcnphy_write_table(pi, - &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa); + wlc_lcnphy_write_table( + pi, + &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa); else - wlc_lcnphy_write_table(pi, - &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250); + wlc_lcnphy_write_table( + pi, + &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250); } else wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313); @@ -4394,9 +4425,8 @@ static void wlc_lcnphy_rev0_baseband_init(struct brcms_phy *pi) if (0) { afectrl1 = 0; afectrl1 = (u16) ((pi_lcn->lcnphy_rssi_vf) | - (pi_lcn->lcnphy_rssi_vc << 4) | (pi_lcn-> - lcnphy_rssi_gs - << 10)); + (pi_lcn->lcnphy_rssi_vc << 4) | + (pi_lcn->lcnphy_rssi_gs << 10)); write_phy_reg(pi, 0x43e, afectrl1); } @@ -4457,18 +4487,15 @@ static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi) tableBuffer[1] -= 128; pi_lcn->lcnphy_tr_T_gain_val = tableBuffer[1]; - temp = (s16) (read_phy_reg(pi, 0x434) - & (0xff << 0)); + temp = (s16) (read_phy_reg(pi, 0x434) & (0xff << 0)); if (temp > 127) temp -= 256; pi_lcn->lcnphy_input_pwr_offset_db = (s8) temp; - pi_lcn->lcnphy_Med_Low_Gain_db = (read_phy_reg(pi, 0x424) - & (0xff << 8)) - >> 8; - pi_lcn->lcnphy_Very_Low_Gain_db = (read_phy_reg(pi, 0x425) - & (0xff << 0)) - >> 0; + pi_lcn->lcnphy_Med_Low_Gain_db = + (read_phy_reg(pi, 0x424) & (0xff << 8)) >> 8; + pi_lcn->lcnphy_Very_Low_Gain_db = + (read_phy_reg(pi, 0x425) & (0xff << 0)) >> 0; tab.tbl_ptr = tableBuffer; tab.tbl_len = 2; @@ -4659,8 +4686,8 @@ static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) if (LCNREV_IS(pi->pubpi.phy_rev, 1)) dflt_rc_cal_val = 11; flt_val = - (dflt_rc_cal_val << 10) | (dflt_rc_cal_val << 5) | - (dflt_rc_cal_val); + (dflt_rc_cal_val << 10) | (dflt_rc_cal_val << 5) | + (dflt_rc_cal_val); write_phy_reg(pi, 0x933, flt_val); write_phy_reg(pi, 0x934, flt_val); write_phy_reg(pi, 0x935, flt_val); @@ -4681,10 +4708,10 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) u32 offset_ofdm, offset_mcs; pi_lcn->lcnphy_tr_isolation_mid = - (u8) PHY_GETINTVAR(pi, "triso2g"); + (u8) PHY_GETINTVAR(pi, "triso2g"); pi_lcn->lcnphy_rx_power_offset = - (u8) PHY_GETINTVAR(pi, "rxpo2g"); + (u8) PHY_GETINTVAR(pi, "rxpo2g"); pi->txpa_2g[0] = (s16) PHY_GETINTVAR(pi, "pa0b0"); pi->txpa_2g[1] = (s16) PHY_GETINTVAR(pi, "pa0b1"); @@ -4700,11 +4727,11 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi_lcn->lcnphy_rssi_gs_lowtemp = pi_lcn->lcnphy_rssi_gs; pi_lcn->lcnphy_rssi_vf_hightemp = - pi_lcn->lcnphy_rssi_vf; + pi_lcn->lcnphy_rssi_vf; pi_lcn->lcnphy_rssi_vc_hightemp = - pi_lcn->lcnphy_rssi_vc; + pi_lcn->lcnphy_rssi_vc; pi_lcn->lcnphy_rssi_gs_hightemp = - pi_lcn->lcnphy_rssi_gs; + pi_lcn->lcnphy_rssi_gs; } txpwr = (s8) PHY_GETINTVAR(pi, "maxp2ga0"); @@ -4720,15 +4747,16 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) uint max_pwr_chan = txpwr; for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) { - pi->tx_srom_max_rate_2g[i] = max_pwr_chan - - ((cckpo & 0xf) * 2); + pi->tx_srom_max_rate_2g[i] = + max_pwr_chan - ((cckpo & 0xf) * 2); cckpo >>= 4; } offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { - pi->tx_srom_max_rate_2g[i] = max_pwr_chan - - ((offset_ofdm & 0xf) * 2); + pi->tx_srom_max_rate_2g[i] = + max_pwr_chan - + ((offset_ofdm & 0xf) * 2); offset_ofdm >>= 4; } } else { @@ -4743,41 +4771,41 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = txpwr - - ((offset_ofdm & 0xf) * 2); + ((offset_ofdm & 0xf) * 2); offset_ofdm >>= 4; } offset_mcs = - ((u16) PHY_GETINTVAR(pi, "mcs2gpo1") << 16) | - (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); + ((u16) PHY_GETINTVAR(pi, "mcs2gpo1") << 16) | + (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); pi_lcn->lcnphy_mcs20_po = offset_mcs; for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { pi->tx_srom_max_rate_2g[i] = - txpwr - ((offset_mcs & 0xf) * 2); + txpwr - ((offset_mcs & 0xf) * 2); offset_mcs >>= 4; } } pi_lcn->lcnphy_rawtempsense = - (u16) PHY_GETINTVAR(pi, "rawtempsense"); + (u16) PHY_GETINTVAR(pi, "rawtempsense"); pi_lcn->lcnphy_measPower = - (u8) PHY_GETINTVAR(pi, "measpower"); + (u8) PHY_GETINTVAR(pi, "measpower"); pi_lcn->lcnphy_tempsense_slope = - (u8) PHY_GETINTVAR(pi, "tempsense_slope"); + (u8) PHY_GETINTVAR(pi, "tempsense_slope"); pi_lcn->lcnphy_hw_iqcal_en = - (bool) PHY_GETINTVAR(pi, "hw_iqcal_en"); + (bool) PHY_GETINTVAR(pi, "hw_iqcal_en"); pi_lcn->lcnphy_iqcal_swp_dis = - (bool) PHY_GETINTVAR(pi, "iqcal_swp_dis"); + (bool) PHY_GETINTVAR(pi, "iqcal_swp_dis"); pi_lcn->lcnphy_tempcorrx = - (u8) PHY_GETINTVAR(pi, "tempcorrx"); + (u8) PHY_GETINTVAR(pi, "tempcorrx"); pi_lcn->lcnphy_tempsense_option = - (u8) PHY_GETINTVAR(pi, "tempsense_option"); + (u8) PHY_GETINTVAR(pi, "tempsense_option"); pi_lcn->lcnphy_freqoffset_corr = - (u8) PHY_GETINTVAR(pi, "freqoffset_corr"); + (u8) PHY_GETINTVAR(pi, "freqoffset_corr"); if ((u8) getintvar(pi->vars, "aa2g") > 1) wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, (u8) getintvar(pi->vars, - "aa2g")); + "aa2g")); } pi_lcn->lcnphy_cck_dig_filt_type = -1; if (PHY_GETVAR(pi, "cckdigfilttype")) { @@ -4942,7 +4970,7 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) - + PLL_2064_LOW_END_KVCO; + + PLL_2064_LOW_END_KVCO; h28_ten = (d28 * 10) / c28; c30 = 2640; e30 = (d30 - 680) / 490; @@ -5007,7 +5035,8 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) pi_lcn = pi->u.pi_lcnphy; - if ((0 == (pi->sh->boardflags & BFL_NOPA)) && !NORADIO_ENAB(pi->pubpi)) { + if ((0 == (pi->sh->boardflags & BFL_NOPA)) && + !NORADIO_ENAB(pi->pubpi)) { pi->hwpwrctrl = true; pi->hwpwrctrl_capable = true; } @@ -5028,7 +5057,8 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) return false; - if ((pi->sh->boardflags & BFL_FEM) && (LCNREV_IS(pi->pubpi.phy_rev, 1))) { + if ((pi->sh->boardflags & BFL_FEM) && + (LCNREV_IS(pi->pubpi.phy_rev, 1))) { if (pi_lcn->lcnphy_tempsense_option == 3) { pi->hwpwrctrl = true; pi->hwpwrctrl_capable = true; @@ -5056,8 +5086,8 @@ static void wlc_lcnphy_set_rx_gain(struct brcms_phy *pi, u32 gain) biq1 = (u16) (gain >> 16) & 0xf; gain0_15 = (u16) ((lna1 & 0x3) | ((lna1 & 0x3) << 2) | - ((lna2 & 0x3) << 4) | ((lna2 & 0x3) << 6) | - ((tia & 0xf) << 8) | ((biq0 & 0xf) << 12)); + ((lna2 & 0x3) << 4) | ((lna2 & 0x3) << 6) | + ((tia & 0xf) << 8) | ((biq0 & 0xf) << 12)); gain16_19 = biq1; mod_phy_reg(pi, 0x44d, (0x1 << 0), trsw << 0); @@ -5092,18 +5122,19 @@ static u32 wlc_lcnphy_get_receive_power(struct brcms_phy *pi, s32 *gain_index) lcnphy_23bitgaincode_table [*gain_index]); received_power = - wlc_lcnphy_measure_digital_power(pi, - pi_lcn-> - lcnphy_noise_samples); + wlc_lcnphy_measure_digital_power( + pi, + pi_lcn-> + lcnphy_noise_samples); (*gain_index)++; } (*gain_index)--; } else { wlc_lcnphy_set_rx_gain(pi, gain_code); received_power = - wlc_lcnphy_measure_digital_power(pi, - pi_lcn-> - lcnphy_noise_samples); + wlc_lcnphy_measure_digital_power(pi, + pi_lcn-> + lcnphy_noise_samples); } return received_power; @@ -5154,7 +5185,7 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) input_power_db = input_power_offset_db - desired_gain; input_power_db = - input_power_db + lcnphy_gain_index_offset_for_rssi[gain_index]; + input_power_db + lcnphy_gain_index_offset_for_rssi[gain_index]; freq = wlc_phy_channel2freq(CHSPEC_CHANNEL(pi->radio_chanspec)); if ((freq > 2427) && (freq <= 2467)) @@ -5164,15 +5195,17 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) if ((temperature - 15) < -30) input_power_db = - input_power_db + (((temperature - 10 - 25) * 286) >> 12) - - 7; + input_power_db + + (((temperature - 10 - 25) * 286) >> 12) - + 7; else if ((temperature - 15) < 4) input_power_db = - input_power_db + (((temperature - 10 - 25) * 286) >> 12) - - 3; + input_power_db + + (((temperature - 10 - 25) * 286) >> 12) - + 3; else - input_power_db = - input_power_db + (((temperature - 10 - 25) * 286) >> 12); + input_power_db = input_power_db + + (((temperature - 10 - 25) * 286) >> 12); wlc_lcnphy_rx_gain_override_enable(pi, 0); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index ee1fe58ecf0..ca6f7499834 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -28,28 +28,42 @@ #include "phyreg_n.h" #include "phytbl_n.h" -#define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ - ((core == PHY_CORE_0) ? radio_type##_##jspace##0 : radio_type##_##jspace##1)) -#define WRITE_RADIO_REG2(pi, radio_type, jspace, core, reg_name, value) \ +#define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ + read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ + ((core == PHY_CORE_0) ? \ + radio_type##_##jspace##0 : \ + radio_type##_##jspace##1)) + +#define WRITE_RADIO_REG2(pi, radio_type, jspace, core, reg_name, value) \ write_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ - ((core == PHY_CORE_0) ? radio_type##_##jspace##0 : \ - radio_type##_##jspace##1), value) -#define WRITE_RADIO_SYN(pi, radio_type, reg_name, value) \ + ((core == PHY_CORE_0) ? \ + radio_type##_##jspace##0 : \ + radio_type##_##jspace##1), value) + +#define WRITE_RADIO_SYN(pi, radio_type, reg_name, value) \ write_radio_reg(pi, radio_type##_##SYN##_##reg_name, value) -#define READ_RADIO_REG3(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name)) -#define WRITE_RADIO_REG3(pi, radio_type, jspace, core, reg_name, value) \ - write_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name), value) -#define READ_RADIO_REG4(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1)) -#define WRITE_RADIO_REG4(pi, radio_type, jspace, core, reg_name, value) \ - write_radio_reg(pi, ((core == PHY_CORE_0) ? radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1), value) +#define READ_RADIO_REG3(pi, radio_type, jspace, core, reg_name) \ + read_radio_reg(pi, ((core == PHY_CORE_0) ? \ + radio_type##_##jspace##0##_##reg_name : \ + radio_type##_##jspace##1##_##reg_name)) + +#define WRITE_RADIO_REG3(pi, radio_type, jspace, core, reg_name, value) \ + write_radio_reg(pi, ((core == PHY_CORE_0) ? \ + radio_type##_##jspace##0##_##reg_name : \ + radio_type##_##jspace##1##_##reg_name), \ + value) + +#define READ_RADIO_REG4(pi, radio_type, jspace, core, reg_name) \ + read_radio_reg(pi, ((core == PHY_CORE_0) ? \ + radio_type##_##reg_name##_##jspace##0 : \ + radio_type##_##reg_name##_##jspace##1)) + +#define WRITE_RADIO_REG4(pi, radio_type, jspace, core, reg_name, value) \ + write_radio_reg(pi, ((core == PHY_CORE_0) ? \ + radio_type##_##reg_name##_##jspace##0 : \ + radio_type##_##reg_name##_##jspace##1), \ + value) #define NPHY_ACI_MAX_UNDETECT_WINDOW_SZ 40 #define NPHY_ACI_CHANNEL_DELTA 5 @@ -104,9 +118,11 @@ #define NPHY_CALSANITY_RSSI_NB_MAX_POS 9 #define NPHY_CALSANITY_RSSI_NB_MAX_NEG -9 #define NPHY_CALSANITY_RSSI_W1_MAX_POS 12 -#define NPHY_CALSANITY_RSSI_W1_MAX_NEG (NPHY_RSSICAL_W1_TARGET - NPHY_RSSICAL_MAXREAD) +#define NPHY_CALSANITY_RSSI_W1_MAX_NEG (NPHY_RSSICAL_W1_TARGET - \ + NPHY_RSSICAL_MAXREAD) #define NPHY_CALSANITY_RSSI_W2_MAX_POS NPHY_CALSANITY_RSSI_W1_MAX_POS -#define NPHY_CALSANITY_RSSI_W2_MAX_NEG (NPHY_RSSICAL_W2_TARGET - NPHY_RSSICAL_MAXREAD) +#define NPHY_CALSANITY_RSSI_W2_MAX_NEG (NPHY_RSSICAL_W2_TARGET - \ + NPHY_RSSICAL_MAXREAD) #define NPHY_RSSI_SXT(x) ((s8) (-((x) & 0x20) + ((x) & 0x1f))) #define NPHY_RSSI_NB_VIOL(x) (((x) > NPHY_CALSANITY_RSSI_NB_MAX_POS) || \ ((x) < NPHY_CALSANITY_RSSI_NB_MAX_NEG)) @@ -125,11 +141,11 @@ #define NPHY_PAPD_COMP_OFF 0 #define NPHY_PAPD_COMP_ON 1 -#define NPHY_SROM_TEMPSHIFT 32 -#define NPHY_SROM_MAXTEMPOFFSET 16 -#define NPHY_SROM_MINTEMPOFFSET -16 +#define NPHY_SROM_TEMPSHIFT 32 +#define NPHY_SROM_MAXTEMPOFFSET 16 +#define NPHY_SROM_MINTEMPOFFSET -16 -#define NPHY_CAL_MAXTEMPDELTA 64 +#define NPHY_CAL_MAXTEMPDELTA 64 #define NPHY_NOISEVAR_TBLLEN40 256 #define NPHY_NOISEVAR_TBLLEN20 128 @@ -139,8 +155,8 @@ #define NPHY_ADJUSTED_MINCRSPOWER 0x1e /* 5357 Chip specific ChipControl register bits */ -#define CCTRL5357_EXTPA (1<<14) /* extPA in ChipControl 1, bit 14 */ -#define CCTRL5357_ANT_MUX_2o3 (1<<15) /* 2o3 in ChipControl 1, bit 15 */ +#define CCTRL5357_EXTPA (1<<14) /* extPA in ChipControl 1, bit 14 */ +#define CCTRL5357_ANT_MUX_2o3 (1<<15) /* 2o3 in ChipControl 1, bit 15 */ struct nphy_iqcal_params { u16 txlpf; @@ -185,38 +201,40 @@ struct nphy_ipa_txrxgain { #define NPHY_IPA_RXCAL_MAXGAININDEX (6 - 1) -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { {0, 0, 0, 0, 0, 100}, -{0, 0, 0, 0, 0, 50}, -{0, 0, 0, 0, 0, -1}, -{0, 0, 0, 3, 0, -1}, -{0, 0, 3, 3, 0, -1}, -{0, 2, 3, 3, 0, -1} +struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { + {0, 0, 0, 0, 0, 100}, + {0, 0, 0, 0, 0, 50}, + {0, 0, 0, 0, 0, -1}, + {0, 0, 0, 3, 0, -1}, + {0, 0, 3, 3, 0, -1}, + {0, 2, 3, 3, 0, -1} }; -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { {0, 0, 0, 0, 0, 128}, -{0, 0, 0, 0, 0, 70}, -{0, 0, 0, 0, 0, 20}, -{0, 0, 0, 3, 0, 20}, -{0, 0, 3, 3, 0, 20}, -{0, 2, 3, 3, 0, 20} +struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { + {0, 0, 0, 0, 0, 128}, + {0, 0, 0, 0, 0, 70}, + {0, 0, 0, 0, 0, 20}, + {0, 0, 0, 3, 0, 20}, + {0, 0, 3, 3, 0, 20}, + {0, 2, 3, 3, 0, 20} }; struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz_rev7[] = { -{0, 0, 0, 0, 0, 100}, -{0, 0, 0, 0, 0, 50}, -{0, 0, 0, 0, 0, -1}, -{0, 0, 0, 3, 0, -1}, -{0, 0, 3, 3, 0, -1}, -{0, 0, 5, 3, 0, -1} + {0, 0, 0, 0, 0, 100}, + {0, 0, 0, 0, 0, 50}, + {0, 0, 0, 0, 0, -1}, + {0, 0, 0, 3, 0, -1}, + {0, 0, 3, 3, 0, -1}, + {0, 0, 5, 3, 0, -1} }; struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz_rev7[] = { -{0, 0, 0, 0, 0, 10}, -{0, 0, 0, 1, 0, 10}, -{0, 0, 1, 2, 0, 10}, -{0, 0, 1, 3, 0, 10}, -{0, 0, 4, 3, 0, 10}, -{0, 0, 6, 3, 0, 10} + {0, 0, 0, 0, 0, 10}, + {0, 0, 0, 1, 0, 10}, + {0, 0, 1, 2, 0, 10}, + {0, 0, 1, 3, 0, 10}, + {0, 0, 4, 3, 0, 10}, + {0, 0, 6, 3, 0, 10} }; #define NPHY_RXCAL_TONEAMP 181 @@ -231,9 +249,9 @@ enum { #define wlc_phy_get_papd_nphy(pi) \ (read_phy_reg((pi), 0x1e7) & \ - ((0x1 << 15) | \ - (0x1 << 14) | \ - (0x1 << 13))) + ((0x1 << 15) | \ + (0x1 << 14) | \ + (0x1 << 13))) #define TXFILT_SHAPING_OFDM20 0 #define TXFILT_SHAPING_OFDM40 1 @@ -13291,27 +13309,27 @@ static s32 nphy_lnagain_est1[] = { -224, 23242 }; static const u16 tbl_iqcal_gainparams_nphy[2][NPHY_IQCAL_NUMGAINS][8] = { { - {0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69}, - {0x700, 7, 0, 0, 0x69, 0x69, 0x69, 0x69}, - {0x710, 7, 1, 0, 0x68, 0x68, 0x68, 0x68}, - {0x720, 7, 2, 0, 0x67, 0x67, 0x67, 0x67}, - {0x730, 7, 3, 0, 0x66, 0x66, 0x66, 0x66}, - {0x740, 7, 4, 0, 0x65, 0x65, 0x65, 0x65}, - {0x741, 7, 4, 1, 0x65, 0x65, 0x65, 0x65}, - {0x742, 7, 4, 2, 0x65, 0x65, 0x65, 0x65}, - {0x743, 7, 4, 3, 0x65, 0x65, 0x65, 0x65} - }, + {0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69}, + {0x700, 7, 0, 0, 0x69, 0x69, 0x69, 0x69}, + {0x710, 7, 1, 0, 0x68, 0x68, 0x68, 0x68}, + {0x720, 7, 2, 0, 0x67, 0x67, 0x67, 0x67}, + {0x730, 7, 3, 0, 0x66, 0x66, 0x66, 0x66}, + {0x740, 7, 4, 0, 0x65, 0x65, 0x65, 0x65}, + {0x741, 7, 4, 1, 0x65, 0x65, 0x65, 0x65}, + {0x742, 7, 4, 2, 0x65, 0x65, 0x65, 0x65}, + {0x743, 7, 4, 3, 0x65, 0x65, 0x65, 0x65} + }, { - {0x000, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, - {0x700, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, - {0x710, 7, 1, 0, 0x79, 0x79, 0x79, 0x79}, - {0x720, 7, 2, 0, 0x78, 0x78, 0x78, 0x78}, - {0x730, 7, 3, 0, 0x78, 0x78, 0x78, 0x78}, - {0x740, 7, 4, 0, 0x78, 0x78, 0x78, 0x78}, - {0x741, 7, 4, 1, 0x78, 0x78, 0x78, 0x78}, - {0x742, 7, 4, 2, 0x78, 0x78, 0x78, 0x78}, - {0x743, 7, 4, 3, 0x78, 0x78, 0x78, 0x78} - } + {0x000, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, + {0x700, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, + {0x710, 7, 1, 0, 0x79, 0x79, 0x79, 0x79}, + {0x720, 7, 2, 0, 0x78, 0x78, 0x78, 0x78}, + {0x730, 7, 3, 0, 0x78, 0x78, 0x78, 0x78}, + {0x740, 7, 4, 0, 0x78, 0x78, 0x78, 0x78}, + {0x741, 7, 4, 1, 0x78, 0x78, 0x78, 0x78}, + {0x742, 7, 4, 2, 0x78, 0x78, 0x78, 0x78}, + {0x743, 7, 4, 3, 0x78, 0x78, 0x78, 0x78} + } }; static const u32 nphy_tpc_txgain[] = { @@ -14082,9 +14100,11 @@ static u32 nphy_tpc_5GHz_txgain_HiPwrEPA[] = { static u8 ant_sw_ctrl_tbl_rev8_2o3[] = { 0x14, 0x18 }; static u8 ant_sw_ctrl_tbl_rev8[] = { 0x4, 0x8, 0x4, 0x8, 0x11, 0x12 }; static u8 ant_sw_ctrl_tbl_rev8_2057v7_core0[] = { - 0x09, 0x0a, 0x15, 0x16, 0x09, 0x0a }; + 0x09, 0x0a, 0x15, 0x16, 0x09, 0x0a +}; static u8 ant_sw_ctrl_tbl_rev8_2057v7_core1[] = { - 0x09, 0x0a, 0x09, 0x0a, 0x15, 0x16 }; + 0x09, 0x0a, 0x09, 0x0a, 0x15, 0x16 +}; static bool wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, struct chan_info_nphy_radio2057 **t0, @@ -14145,10 +14165,14 @@ static void wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32, static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core); static void wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *, enum phy_cal_mode, u8); -static void wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state); + +static void +wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, + struct nphy_papd_restore_state *state); + static void wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state, u8); + struct nphy_papd_restore_state *state, + u8); static void wlc_phy_clip_det_nphy(struct brcms_phy *pi, u8 write, u16 *vals); @@ -14187,8 +14211,8 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi); static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi); static u16 wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, - u16 max_val, - u8 dac_test_mode); + u16 max_val, + u8 dac_test_mode); static void wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cs32 *tone_buf, u16 num_samps); static void wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 n, u16 lps, @@ -14306,7 +14330,8 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 7)) { antswctrllut = CHSPEC_IS2G(pi->radio_chanspec) ? - pi->srom_fem2g.antswctrllut : pi->srom_fem5g.antswctrllut; + pi->srom_fem2g.antswctrllut : pi->srom_fem5g. + antswctrllut; switch (antswctrllut) { case 0: @@ -14316,17 +14341,18 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) case 1: if (pi->aa2g == 7) - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8_2o3 - [0]); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x21, 8, + &ant_sw_ctrl_tbl_rev8_2o3[0]); else - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8 - [0]); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x21, 8, + &ant_sw_ctrl_tbl_rev8 + [0]); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, 2, 0x25, 8, @@ -14338,31 +14364,31 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) case 2: - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x1, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0 - [0]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x5, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0 - [2]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x9, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0 - [4]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x1, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core0[0]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x5, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core0[2]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x9, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core0[4]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1 - [0]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x25, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1 - [2]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x29, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1 - [4]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x21, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core1[0]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x25, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core1[2]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_ANTSWCTRLLUT, + 2, 0x29, 8, + &ant_sw_ctrl_tbl_rev8_2057v7_core1[4]); break; default: @@ -14373,37 +14399,42 @@ static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) for (idx = 0; idx < mimophytbl_info_sz_rev3_volatile; idx++) { if (idx == ANT_SWCTRL_TBL_REV3_IDX) { - antswctrllut = CHSPEC_IS2G(pi->radio_chanspec) ? - pi->srom_fem2g.antswctrllut : pi-> - srom_fem5g.antswctrllut; + antswctrllut = + CHSPEC_IS2G(pi->radio_chanspec) ? + pi->srom_fem2g.antswctrllut : + pi->srom_fem5g.antswctrllut; switch (antswctrllut) { case 0: - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3_volatile - [idx]); + wlc_phy_write_table_nphy( + pi, + &mimophytbl_info_rev3_volatile + [idx]); break; case 1: - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3_volatile1 - [idx]); + wlc_phy_write_table_nphy( + pi, + &mimophytbl_info_rev3_volatile1 + [idx]); break; case 2: - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3_volatile2 - [idx]); + wlc_phy_write_table_nphy( + pi, + &mimophytbl_info_rev3_volatile2 + [idx]); break; case 3: - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3_volatile3 - [idx]); + wlc_phy_write_table_nphy( + pi, + &mimophytbl_info_rev3_volatile3 + [idx]); break; default: break; } } else { - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3_volatile - [idx]); + wlc_phy_write_table_nphy( + pi, + &mimophytbl_info_rev3_volatile[idx]); } } } else { @@ -14544,7 +14575,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) CHSPEC_IS40(pi->radio_chanspec)) { regs = (struct d11regs *) ai_switch_core(pi->sh->sih, - D11_CORE_ID, &origidx, &intr_val); + D11_CORE_ID, &origidx, + &intr_val); d11_clk_ctl_st = R_REG(®s->clk_ctl_st); AND_REG(®s->clk_ctl_st, ~(CCS_FORCEHT | CCS_HTAREQ)); @@ -14555,10 +14587,10 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) } pi->use_int_tx_iqlo_cal_nphy = - (PHY_IPA(pi) || - (NREV_GE(pi->pubpi.phy_rev, 7) || - (NREV_GE(pi->pubpi.phy_rev, 5) - && pi->sh->boardflags2 & BFL2_INTERNDET_TXIQCAL))); + (PHY_IPA(pi) || + (NREV_GE(pi->pubpi.phy_rev, 7) || + (NREV_GE(pi->pubpi.phy_rev, 5) + && pi->sh->boardflags2 & BFL2_INTERNDET_TXIQCAL))); pi->internal_tx_iqlo_cal_tapoff_intpa_nphy = false; @@ -14690,31 +14722,32 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (CHSPEC_IS5G(pi->radio_chanspec)) { if (NREV_IS(pi->pubpi.phy_rev, 3)) tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev3; + nphy_tpc_5GHz_txgain_rev3; else if (NREV_IS(pi->pubpi.phy_rev, 4)) tx_pwrctrl_tbl = - (pi->srom_fem5g.extpagain == 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA : - nphy_tpc_5GHz_txgain_rev4; + (pi->srom_fem5g.extpagain == + 3) ? + nphy_tpc_5GHz_txgain_HiPwrEPA : + nphy_tpc_5GHz_txgain_rev4; else tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev5; + nphy_tpc_5GHz_txgain_rev5; } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (pi->pubpi.radiorev == 5) tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev5; + nphy_tpc_txgain_epa_2057rev5; else if (pi->pubpi.radiorev == 3) tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev3; + nphy_tpc_txgain_epa_2057rev3; } else { if (NREV_GE(pi->pubpi.phy_rev, 5) && (pi->srom_fem2g.extpagain == 3)) tx_pwrctrl_tbl = - nphy_tpc_txgain_HiPwrEPA; + nphy_tpc_txgain_HiPwrEPA; else tx_pwrctrl_tbl = - nphy_tpc_txgain_rev3; + nphy_tpc_txgain_rev3; } } } @@ -14737,40 +14770,42 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev3n4 - [pad_gn]; + nphy_papd_padgain_dlt_2g_2057rev3n4 + [pad_gn]; else if (pi->pubpi.radiorev == 5) rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev5 - [pad_gn]; + nphy_papd_padgain_dlt_2g_2057rev5 + [pad_gn]; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) + || (pi->pubpi.radiorev == + 8)) rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev7 - [pad_gn]; + nphy_papd_padgain_dlt_2g_2057rev7 + [pad_gn]; } else { if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057 - [pga_gn]; + nphy_papd_pgagain_dlt_5g_2057 + [pga_gn]; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) + || (pi->pubpi.radiorev == + 8)) rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057rev7 - [pga_gn]; + nphy_papd_pgagain_dlt_5g_2057rev7 + [pga_gn]; } - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE1TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE2TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); } } else { @@ -14778,21 +14813,23 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; if (CHSPEC_IS2G(pi->radio_chanspec)) rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_2g - [pga_gn]; + nphy_papd_pga_gain_delta_ipa_2g + [pga_gn]; else rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_5g - [pga_gn]; + nphy_papd_pga_gain_delta_ipa_5g + [pga_gn]; - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE1TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE2TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); } } @@ -14816,8 +14853,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 3)) { do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_rssical_chanspec_2G == 0) : - (pi->nphy_rssical_chanspec_5G == 0); + (pi->nphy_rssical_chanspec_2G == 0) : + (pi->nphy_rssical_chanspec_5G == 0); if (do_rssi_cal) wlc_phy_rssi_cal_nphy(pi); @@ -14829,8 +14866,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (!SCAN_RM_IN_PROGRESS(pi)) do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_iqcal_chanspec_2G == 0) : - (pi->nphy_iqcal_chanspec_5G == 0); + (pi->nphy_iqcal_chanspec_2G == 0) : + (pi->nphy_iqcal_chanspec_5G == 0); if (!pi->do_initcal) do_nphy_cal = false; @@ -14848,22 +14885,25 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 3)) { pi->nphy_cal_orig_pwr_idx[0] = - pi->nphy_txpwrindex[PHY_CORE_0]. - index_internal; + pi->nphy_txpwrindex[PHY_CORE_0] + . + index_internal; pi->nphy_cal_orig_pwr_idx[1] = - pi->nphy_txpwrindex[PHY_CORE_1]. - index_internal; + pi->nphy_txpwrindex[PHY_CORE_1] + . + index_internal; wlc_phy_precal_txgain_nphy(pi); target_gain = - wlc_phy_get_tx_gain_nphy(pi); + wlc_phy_get_tx_gain_nphy(pi); } if (wlc_phy_cal_txiqlo_nphy - (pi, target_gain, true, false) == 0) { + (pi, target_gain, true, + false) == 0) { if (wlc_phy_cal_rxiq_nphy - (pi, target_gain, 2, - false) == 0) + (pi, target_gain, 2, + false) == 0) wlc_phy_savecal_nphy(pi); } @@ -14940,10 +14980,10 @@ void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en) rfctrlintc_override_val = 0x1480; else if (NREV_GE(pi->pubpi.phy_rev, 3)) rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; + CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; else rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; + CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; write_phy_reg(pi, 0x91, rfctrlintc_override_val); write_phy_reg(pi, 0x92, rfctrlintc_override_val); @@ -14958,7 +14998,7 @@ void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi) { u16 txrx_chain = - (NPHY_RfseqCoreActv_TxRxChain0 | NPHY_RfseqCoreActv_TxRxChain1); + (NPHY_RfseqCoreActv_TxRxChain0 | NPHY_RfseqCoreActv_TxRxChain1); bool CoreActv_override = false; if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN0) { @@ -15000,8 +15040,7 @@ void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) if (!pi->sh->clk) return; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -15026,15 +15065,15 @@ void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) for (i = 0; i < ARRAY_SIZE(tbl_buf); i++) { if (tbl_buf[i] == NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS) { - pi->rx2tx_biasentry = (u8) i; tbl_opcode = - NPHY_REV3_RFSEQ_CMD_NOP; - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_RFSEQ, - 1, i, - 16, - &tbl_opcode); + NPHY_REV3_RFSEQ_CMD_NOP; + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_RFSEQ, + 1, i, + 16, + &tbl_opcode); break; } else if (tbl_buf[i] == NPHY_REV3_RFSEQ_CMD_END) @@ -15102,7 +15141,7 @@ static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) idx = TXP_FIRST_MCS_40_SISO; } else { idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_OFDM_40_SISO : TXP_FIRST_OFDM; + TXP_FIRST_OFDM_40_SISO : TXP_FIRST_OFDM; delta_ind = 1; } break; @@ -15110,68 +15149,68 @@ static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) case 1: idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_CDD : TXP_FIRST_MCS_20_CDD; + TXP_FIRST_MCS_40_CDD : TXP_FIRST_MCS_20_CDD; break; case 2: idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_STBC : TXP_FIRST_MCS_20_STBC; + TXP_FIRST_MCS_40_STBC : TXP_FIRST_MCS_20_STBC; break; case 3: idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_SDM : TXP_FIRST_MCS_20_SDM; + TXP_FIRST_MCS_40_SDM : TXP_FIRST_MCS_20_SDM; break; } pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; idx = idx + delta_ind; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; + pi->tx_power_offset[idx++]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; idx = idx + 1 - delta_ind; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; + pi->tx_power_offset[idx]; } } @@ -15403,11 +15442,13 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) || (pi->pubpi.radiorev == 8)) { rccal_bcap_val = - read_radio_reg(pi, - RADIO_2057_RCCAL_BCAP_VAL); + read_radio_reg( + pi, + RADIO_2057_RCCAL_BCAP_VAL); rccal_scap_val = - read_radio_reg(pi, - RADIO_2057_RCCAL_SCAP_VAL); + read_radio_reg( + pi, + RADIO_2057_RCCAL_SCAP_VAL); rccal_tx20_11b_bcap = rccal_bcap_val; rccal_tx20_11b_scap = rccal_scap_val; @@ -15452,11 +15493,13 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) tx_lpf_bw_ofdm_40mhz = 3; rccal_bcap_val = - read_radio_reg(pi, - RADIO_2057_RCCAL_BCAP_VAL); + read_radio_reg( + pi, + RADIO_2057_RCCAL_BCAP_VAL); rccal_scap_val = - read_radio_reg(pi, - RADIO_2057_RCCAL_SCAP_VAL); + read_radio_reg( + pi, + RADIO_2057_RCCAL_SCAP_VAL); rccal_tx20_11b_bcap = rccal_bcap_val; rccal_tx20_11b_scap = rccal_scap_val; @@ -15472,68 +15515,84 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (rccal_ovrd) { - rx2tx_lpf_rc_lut_tx20_11b = (rccal_tx20_11b_bcap << 8) | - (rccal_tx20_11b_scap << 3) | tx_lpf_bw_11b; - rx2tx_lpf_rc_lut_tx20_11n = (rccal_tx20_11n_bcap << 8) | - (rccal_tx20_11n_scap << 3) | tx_lpf_bw_ofdm_20mhz; - rx2tx_lpf_rc_lut_tx40_11n = (rccal_tx40_11n_bcap << 8) | - (rccal_tx40_11n_scap << 3) | tx_lpf_bw_ofdm_40mhz; + rx2tx_lpf_rc_lut_tx20_11b = + (rccal_tx20_11b_bcap << 8) | + (rccal_tx20_11b_scap << 3) | + tx_lpf_bw_11b; + rx2tx_lpf_rc_lut_tx20_11n = + (rccal_tx20_11n_bcap << 8) | + (rccal_tx20_11n_scap << 3) | + tx_lpf_bw_ofdm_20mhz; + rx2tx_lpf_rc_lut_tx40_11n = + (rccal_tx40_11n_bcap << 8) | + (rccal_tx40_11n_scap << 3) | + tx_lpf_bw_ofdm_40mhz; for (coreNum = 0; coreNum <= 1; coreNum++) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x152 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11b); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x153 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x154 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x155 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x156 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x157 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x158 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x159 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x152 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx20_11b); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x153 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx20_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x154 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx20_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x155 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x156 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x157 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x158 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_RFSEQ, + 1, + 0x159 + coreNum * 0x10, + 16, + &rx2tx_lpf_rc_lut_tx40_11n); } - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 4), + 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID2); } if (!NORADIO_ENAB(pi->pubpi)) write_phy_reg(pi, 0x32f, 0x3); if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { @@ -15593,10 +15652,11 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) for (coreNum = 0; coreNum <= 1; coreNum++) { if (txgm_idac_bleed != 0) - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - TXGM_IDAC_BLEED, - txgm_idac_bleed); + WRITE_RADIO_REG4( + pi, RADIO_2057, + CORE, coreNum, + TXGM_IDAC_BLEED, + txgm_idac_bleed); } if (pi->pubpi.radiorev == 5) { @@ -15611,18 +15671,20 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) CORE, coreNum, IPA2G_IMAIN, 0x1f); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - IPA2G_BIAS_FILTER, - 0xee); + WRITE_RADIO_REG4( + pi, RADIO_2057, + CORE, coreNum, + IPA2G_BIAS_FILTER, + 0xee); WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, PAD2G_IDACS, 0x8a); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - PAD_BIAS_FILTER_BWS, - 0x3e); + WRITE_RADIO_REG4( + pi, RADIO_2057, + CORE, coreNum, + PAD_BIAS_FILTER_BWS, + 0x3e); } } else if ((pi->pubpi.radiorev == 7) @@ -15651,9 +15713,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) } } else { - freq = - CHAN5G_FREQ(CHSPEC_CHANNEL - (pi->radio_chanspec)); + freq = CHAN5G_FREQ(CHSPEC_CHANNEL( + pi->radio_chanspec)); if (((freq >= 5180) && (freq <= 5230)) || ((freq >= 5745) && (freq <= 5805))) { WRITE_RADIO_REG4(pi, RADIO_2057, CORE, @@ -15760,12 +15821,12 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) wlc_phy_workarounds_nphy_gainctrl(pi); pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; + (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. + pdetrange : pi->srom_fem2g.pdetrange; if (pdetrange == 0) { chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { aux_adc_vmid_rev7_core0[3] = 0x70; aux_adc_vmid_rev7_core1[3] = 0x70; @@ -15793,15 +15854,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (chan_freq_range == WL_CHAN_FREQ_RANGE_2G) { aux_adc_vmid_rev7_core0[3] = - 0x8c; + 0x8c; aux_adc_vmid_rev7_core1[3] = - 0x8c; + 0x8c; aux_adc_gain_rev7[3] = 0; } else { aux_adc_vmid_rev7_core0[3] = - 0x96; + 0x96; aux_adc_vmid_rev7_core1[3] = - 0x96; + 0x96; aux_adc_gain_rev7[3] = 0; } } @@ -15886,15 +15947,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) rfseq_rx2tx_dlys_rev3[5] = 59; rfseq_rx2tx_dlys_rev3[6] = 1; rfseq_rx2tx_events_rev3[7] = - NPHY_REV3_RFSEQ_CMD_END; + NPHY_REV3_RFSEQ_CMD_END; } - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3, - rfseq_rx2tx_dlys_rev3, - sizeof(rfseq_rx2tx_events_rev3) / - sizeof(rfseq_rx2tx_events_rev3 - [0])); + wlc_phy_set_rfseq_nphy( + pi, NPHY_RFSEQ_RX2TX, + rfseq_rx2tx_events_rev3, + rfseq_rx2tx_dlys_rev3, + sizeof(rfseq_rx2tx_events_rev3) / + sizeof(rfseq_rx2tx_events_rev3[0])); } if (CHSPEC_IS2G(pi->radio_chanspec)) @@ -15927,8 +15988,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) &dac_control); pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; + (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. + pdetrange : pi->srom_fem2g.pdetrange; if (pdetrange == 0) { if (NREV_GE(pi->pubpi.phy_rev, 4)) { @@ -15939,7 +16000,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) aux_adc_gain = aux_adc_gain_rev3; } chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { switch (chan_freq_range) { case WL_CHAN_FREQ_RANGE_5GL: @@ -15982,7 +16043,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 6)) { chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { bcm_adc_vmid[3] = 0x8e; bcm_adc_gain[3] = 0x03; @@ -16005,14 +16066,16 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) 0x1c, 16, bcm_adc_gain); } else if (pdetrange == 3) { chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if ((NREV_GE(pi->pubpi.phy_rev, 4)) && (chan_freq_range == WL_CHAN_FREQ_RANGE_2G)) { u16 auxadc_vmid[] = { - 0xa2, 0xb4, 0xb4, 0x270 }; + 0xa2, 0xb4, 0xb4, 0x270 + }; u16 auxadc_gain[] = { - 0x02, 0x02, 0x02, 0x00 }; + 0x02, 0x02, 0x02, 0x00 + }; wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, @@ -16033,7 +16096,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) u16 Vmid[2], Av[2]; chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { Vmid[0] = (pdetrange == 4) ? 0x8e : 0x89; Vmid[1] = (pdetrange == 4) ? 0x96 : 0x89; @@ -16104,8 +16167,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) 0x0); triso = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - triso : pi->srom_fem2g.triso; + (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. + triso : pi->srom_fem2g.triso; if (triso == 7) { wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); @@ -16163,8 +16226,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) wlapi_bmac_mhf(pi->sh->physhim, MHF4, - MHF4_BPHY_TXCORE0, - MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); + MHF4_BPHY_TXCORE0, + MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); } } else { @@ -16428,7 +16491,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) u8 triso; triso = (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g.triso : - pi->srom_fem2g.triso; + pi->srom_fem2g.triso; if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (pi->pubpi.radiorev == 5) { @@ -16460,20 +16523,20 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); currband = - read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; + read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; if (currband == 0) { if (NREV_GE(pi->pubpi.phy_rev, 6)) { if (pi->pubpi.radiorev == 11) { lna1_gain_db = lna1G_gain_db_rev6_224B0; lna2_gain_db = lna2G_gain_db_rev6_224B0; rfseq_init_gain = - rfseqG_init_gain_rev6_224B0; + rfseqG_init_gain_rev6_224B0; init_gaincode = - initG_gaincode_rev6_224B0; + initG_gaincode_rev6_224B0; clip1hi_gaincode = - clip1hiG_gaincode_rev6; + clip1hiG_gaincode_rev6; clip1lo_gaincode = - clip1loG_gaincode_rev6_224B0; + clip1loG_gaincode_rev6_224B0; nbclip_th = nbclipG_th_rev6; w1clip_th = w1clipG_th_rev6; crsmin_th = crsminG_th_rev6; @@ -16486,51 +16549,59 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) if (pi->sh->boardflags & BFL_EXTLNA) { rfseq_init_gain = - rfseqG_init_gain_rev6_elna; + rfseqG_init_gain_rev6_elna; init_gaincode = - initG_gaincode_rev6_elna; + initG_gaincode_rev6_elna; } else { rfseq_init_gain = - rfseqG_init_gain_rev6; + rfseqG_init_gain_rev6; init_gaincode = - initG_gaincode_rev6; + initG_gaincode_rev6; } clip1hi_gaincode = - clip1hiG_gaincode_rev6; + clip1hiG_gaincode_rev6; switch (triso) { case 0: clip1lo_gaincode = - clip1loG_gaincode_rev6[0]; + clip1loG_gaincode_rev6 + [0]; break; case 1: clip1lo_gaincode = - clip1loG_gaincode_rev6[1]; + clip1loG_gaincode_rev6 + [1]; break; case 2: clip1lo_gaincode = - clip1loG_gaincode_rev6[2]; + clip1loG_gaincode_rev6 + [2]; break; case 3: default: clip1lo_gaincode = - clip1loG_gaincode_rev6[3]; + clip1loG_gaincode_rev6 + [3]; break; case 4: clip1lo_gaincode = - clip1loG_gaincode_rev6[4]; + clip1loG_gaincode_rev6 + [4]; break; case 5: clip1lo_gaincode = - clip1loG_gaincode_rev6[5]; + clip1loG_gaincode_rev6 + [5]; break; case 6: clip1lo_gaincode = - clip1loG_gaincode_rev6[6]; + clip1loG_gaincode_rev6 + [6]; break; case 7: clip1lo_gaincode = - clip1loG_gaincode_rev6[7]; + clip1loG_gaincode_rev6 + [7]; break; } nbclip_th = nbclipG_th_rev6; @@ -16546,9 +16617,9 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) if (pi->sh->boardflags & BFL_EXTLNA) { rfseq_init_gain = - rfseqG_init_gain_rev5_elna; + rfseqG_init_gain_rev5_elna; init_gaincode = - initG_gaincode_rev5_elna; + initG_gaincode_rev5_elna; } else { rfseq_init_gain = rfseqG_init_gain_rev5; init_gaincode = initG_gaincode_rev5; @@ -16557,40 +16628,40 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) switch (triso) { case 0: clip1lo_gaincode = - clip1loG_gaincode_rev5[0]; + clip1loG_gaincode_rev5[0]; break; case 1: clip1lo_gaincode = - clip1loG_gaincode_rev5[1]; + clip1loG_gaincode_rev5[1]; break; case 2: clip1lo_gaincode = - clip1loG_gaincode_rev5[2]; + clip1loG_gaincode_rev5[2]; break; case 3: clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; + clip1loG_gaincode_rev5[3]; break; case 4: clip1lo_gaincode = - clip1loG_gaincode_rev5[4]; + clip1loG_gaincode_rev5[4]; break; case 5: clip1lo_gaincode = - clip1loG_gaincode_rev5[5]; + clip1loG_gaincode_rev5[5]; break; case 6: clip1lo_gaincode = - clip1loG_gaincode_rev5[6]; + clip1loG_gaincode_rev5[6]; break; case 7: clip1lo_gaincode = - clip1loG_gaincode_rev5[7]; + clip1loG_gaincode_rev5[7]; break; default: clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; + clip1loG_gaincode_rev5[3]; break; } nbclip_th = nbclipG_th_rev5; @@ -16673,9 +16744,9 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) if (pi->sh->boardflags & BFL_EXTLNA_5GHz) { rfseq_init_gain = - rfseqA_init_gain_rev4_elna; + rfseqA_init_gain_rev4_elna; init_gaincode = - initA_gaincode_rev4_elna; + initA_gaincode_rev4_elna; } else { rfseq_init_gain = rfseqA_init_gain_rev4; init_gaincode = initA_gaincode_rev4; @@ -17017,7 +17088,7 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; s8 lna1A_gain_db_2_rev7[] = { - 11, 17, 22, 25 }; + 11, 17, 22, 25}; s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; crsminu_th = 0x3e; @@ -17028,7 +17099,7 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26 }; + 12, 18, 22, 26}; s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; crsminu_th = 0x45; @@ -17042,7 +17113,7 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26 }; + 12, 18, 22, 26}; s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; crsminu_th = 0x41; @@ -17167,15 +17238,15 @@ static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) curr_channel = CHSPEC_CHANNEL(pi->radio_chanspec); gain_delta[0] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est0[0] * - curr_channel) + - nphy_lnagain_est0[1]), 13); + (s16) + PHY_HW_ROUND(((nphy_lnagain_est0[0] * + curr_channel) + + nphy_lnagain_est0[1]), 13); gain_delta[1] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est1[0] * - curr_channel) + - nphy_lnagain_est1[1]), 13); + (s16) + PHY_HW_ROUND(((nphy_lnagain_est1[0] * + curr_channel) + + nphy_lnagain_est1[1]), 13); } } else { @@ -17193,12 +17264,13 @@ static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) } else { for (ctr = 0; ctr < 4; ctr++) regval[ctr] = - nphy_def_lnagains[ctr] + gain_delta[core]; + nphy_def_lnagains[ctr] + + gain_delta[core]; } wlc_phy_table_write_nphy(pi, core, 4, 8, 16, regval); minmax_gain[core] = - (u16) (nphy_def_lnagains[2] + gain_delta[core] + 4); + (u16) (nphy_def_lnagains[2] + gain_delta[core] + 4); } mod_phy_reg(pi, 0x1e, (0xff << 0), (minmax_gain[0] << 0)); @@ -17336,7 +17408,7 @@ static void wlc_phy_radio_postinit_2055(struct brcms_phy *pi) RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000); if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & - RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE, + RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE, "HW error: radio calibration1\n")) return; @@ -17551,34 +17623,32 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, if (pi->pubpi.radiover == 0x0) { chan_info_tbl_p_2 = - chan_info_nphyrev8_2057_rev5; - tbl_len = - ARRAY_SIZE - (chan_info_nphyrev8_2057_rev5); + chan_info_nphyrev8_2057_rev5; + tbl_len = ARRAY_SIZE( + chan_info_nphyrev8_2057_rev5); } else if (pi->pubpi.radiover == 0x1) { chan_info_tbl_p_2 = - chan_info_nphyrev9_2057_rev5v1; - tbl_len = - ARRAY_SIZE - (chan_info_nphyrev9_2057_rev5v1); + chan_info_nphyrev9_2057_rev5v1; + tbl_len = ARRAY_SIZE( + chan_info_nphyrev9_2057_rev5v1); } break; case 7: chan_info_tbl_p_0 = - chan_info_nphyrev8_2057_rev7; - tbl_len = - ARRAY_SIZE(chan_info_nphyrev8_2057_rev7); + chan_info_nphyrev8_2057_rev7; + tbl_len = ARRAY_SIZE( + chan_info_nphyrev8_2057_rev7); break; case 8: chan_info_tbl_p_0 = - chan_info_nphyrev8_2057_rev8; - tbl_len = - ARRAY_SIZE(chan_info_nphyrev8_2057_rev8); + chan_info_nphyrev8_2057_rev8; + tbl_len = ARRAY_SIZE( + chan_info_nphyrev8_2057_rev8); break; default: @@ -17640,7 +17710,7 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, case 9: chan_info_tbl_p_1 = chan_info_nphyrev5n6_2056v7; tbl_len = - ARRAY_SIZE(chan_info_nphyrev5n6_2056v7); + ARRAY_SIZE(chan_info_nphyrev5n6_2056v7); break; case 8: chan_info_tbl_p_1 = chan_info_nphyrev6_2056v8; @@ -17648,7 +17718,8 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, break; case 11: chan_info_tbl_p_1 = chan_info_nphyrev6_2056v11; - tbl_len = ARRAY_SIZE(chan_info_nphyrev6_2056v11); + tbl_len = ARRAY_SIZE( + chan_info_nphyrev6_2056v11); break; default: if (NORADIO_ENAB(pi->pubpi)) @@ -17684,7 +17755,7 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, *f = freq; return true; - fail: +fail: *f = WL_CHAN_FREQ_RANGE_2G; return false; } @@ -18174,8 +18245,10 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) u16 savereg; savereg = - read_radio_reg(pi, - RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN); + read_radio_reg( + pi, + RADIO_2056_SYN_PLL_MAST2 | + RADIO_2056_SYN); write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, savereg | 0x7); udelay(10); @@ -18188,9 +18261,10 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) 0x9); for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rcal_reg = read_radio_reg(pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); + rcal_reg = read_radio_reg( + pi, + RADIO_2056_SYN_RCAL_CODE_OUT | + RADIO_2056_SYN); if (rcal_reg & 0x80) break; @@ -18205,9 +18279,9 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) 0x1); rcal_reg = - read_radio_reg(pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); + read_radio_reg(pi, + RADIO_2056_SYN_RCAL_CODE_OUT | + RADIO_2056_SYN); write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, 0x0); @@ -18221,9 +18295,11 @@ static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) } static void -wlc_phy_chanspec_radio2057_setup(struct brcms_phy *pi, - const struct chan_info_nphy_radio2057 *ci, - const struct chan_info_nphy_radio2057_rev5 *ci2) +wlc_phy_chanspec_radio2057_setup( + struct brcms_phy *pi, + const struct chan_info_nphy_radio2057 *ci, + const struct chan_info_nphy_radio2057_rev5 * + ci2) { int coreNum; u16 txmix2g_tune_boost_pu = 0; @@ -18534,15 +18610,15 @@ wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, u32 offset; int tone_id; int tbllen = - CHSPEC_IS40(pi-> - radio_chanspec) ? NPHY_NOISEVAR_TBLLEN40 : - NPHY_NOISEVAR_TBLLEN20; + CHSPEC_IS40(pi->radio_chanspec) ? + NPHY_NOISEVAR_TBLLEN40 : NPHY_NOISEVAR_TBLLEN20; if (pi->nphy_noisevars_adjusted) { for (i = 0; i < pi->nphy_saved_noisevars.bufcount; i++) { tone_id = pi->nphy_saved_noisevars.tone_id[i]; offset = (tone_id >= 0) ? - ((tone_id * 2) + 1) : (tbllen + (tone_id * 2) + 1); + ((tone_id * + 2) + 1) : (tbllen + (tone_id * 2) + 1); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, offset, 32, (void *)&pi-> @@ -18560,7 +18636,8 @@ wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, for (i = 0; i < ntones; i++) { tone_id = tone_id_buf[i]; offset = (tone_id >= 0) ? - ((tone_id * 2) + 1) : (tbllen + (tone_id * 2) + 1); + ((tone_id * 2) + 1) : + (tbllen + (tone_id * 2) + 1); pi->nphy_saved_noisevars.tone_id[i] = tone_id; wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, offset, 32, @@ -18681,15 +18758,17 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) if (pi->nphy_gband_spurwar_en) { - wlc_phy_adjust_rx_analpfbw_nphy(pi, - NPHY_ANARXLPFBW_REDUCTIONFACT); + wlc_phy_adjust_rx_analpfbw_nphy( + pi, + NPHY_ANARXLPFBW_REDUCTIONFACT); if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((cur_channel == 11) && CHSPEC_IS40(pi->radio_chanspec)) - wlc_phy_adjust_min_noisevar_nphy(pi, 2, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); + wlc_phy_adjust_min_noisevar_nphy( + pi, 2, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); else wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, @@ -18697,7 +18776,7 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) } wlc_phy_adjust_crsminpwr_nphy(pi, - NPHY_ADJUSTED_MINCRSPOWER); + NPHY_ADJUSTED_MINCRSPOWER); } if ((pi->nphy_gband_spurwar2_en) @@ -18769,12 +18848,13 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) if (isAdjustNoiseVar) { numTonesAdjust = sizeof(nphy_adj_tone_id_buf) / - sizeof(nphy_adj_tone_id_buf[0]); + sizeof(nphy_adj_tone_id_buf[0]); - wlc_phy_adjust_min_noisevar_nphy(pi, - numTonesAdjust, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); + wlc_phy_adjust_min_noisevar_nphy( + pi, + numTonesAdjust, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); tempval = 0; @@ -18818,9 +18898,10 @@ static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) if (nphy_adj_tone_id_buf[0] && nphy_adj_noise_var_buf[0]) - wlc_phy_adjust_min_noisevar_nphy(pi, 1, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); + wlc_phy_adjust_min_noisevar_nphy( + pi, 1, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); else wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, NULL); @@ -18902,8 +18983,8 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, if ((val == 13) || (val == 14) || (val == 153)) spuravoid = 1; } else if (((val >= 5) && (val <= 8)) || (val == 13) - || (val == 14)) { - spuravoid = 1; + || (val == 14)) { + spuravoid = 1; } } else if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (val == 54) @@ -18968,7 +19049,7 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) return; if (!wlc_phy_chan2freq_nphy - (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) + (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) return; wlc_phy_chanspec_radio_set((struct brcms_phy_pub *) pi, chanspec); @@ -19030,8 +19111,8 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) wlc_phy_chanspec_radio2055_setup(pi, t3); wlc_phy_chanspec_nphy_setup(pi, chanspec, - (const struct nphy_sfo_cfg *)&(t3-> - PHY_BW1a)); + (const struct nphy_sfo_cfg *) + &(t3->PHY_BW1a)); } } @@ -19053,51 +19134,51 @@ static void wlc_phy_savecal_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 7)) { txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; + pi->calibration_cache.txcal_radio_regs_2G; } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_2G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_2G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_2G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_2G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1); } else { pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); + read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); + read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); + read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); + read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); } pi->nphy_iqcal_chanspec_2G = pi->radio_chanspec; @@ -19110,51 +19191,51 @@ static void wlc_phy_savecal_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 7)) { txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; + pi->calibration_cache.txcal_radio_regs_5G; } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_5G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_5G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0); pi->calibration_cache.txcal_radio_regs_5G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1); pi->calibration_cache.txcal_radio_regs_5G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1); } else { pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); + read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); + read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); + read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); + read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); } pi->nphy_iqcal_chanspec_5G = pi->radio_chanspec; @@ -19164,18 +19245,18 @@ static void wlc_phy_savecal_nphy(struct brcms_phy *pi) for (coreNum = 0; coreNum <= 1; coreNum++) { txcal_radio_regs[2 * coreNum] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_I); + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_I); txcal_radio_regs[2 * coreNum + 1] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_Q); + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_Q); txcal_radio_regs[2 * coreNum + 4] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_I); + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_I); txcal_radio_regs[2 * coreNum + 5] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_Q); + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_Q); } } @@ -19235,7 +19316,7 @@ static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; + pi->calibration_cache.txcal_radio_regs_2G; } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { write_radio_reg(pi, @@ -19300,7 +19381,7 @@ static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; + pi->calibration_cache.txcal_radio_regs_5G; } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { write_radio_reg(pi, @@ -19451,8 +19532,8 @@ u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val) if (D11REV_IS(pi->sh->corerev, 16)) { suspended = - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) ? - false : true; + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) ? + false : true; if (!suspended) wlapi_suspend_mac_and_wait(pi->sh->physhim); } @@ -19532,8 +19613,8 @@ wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, u32 t1_offset, t2_offset; u8 ctr; u8 end_event = - NREV_GE(pi->pubpi.phy_rev, - 3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END; + NREV_GE(pi->pubpi.phy_rev, + 3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END; u8 end_dly = 1; if (pi->phyhang_avoid) @@ -19596,77 +19677,77 @@ wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, case (0x1 << 2): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 1); val_shift = 1; break; case (0x1 << 3): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 2); val_shift = 2; break; case (0x1 << 4): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 4); val_shift = 4; break; case (0x1 << 5): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 5); val_shift = 5; break; case (0x1 << 6): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 6); val_shift = 6; break; case (0x1 << 7): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7a : - 0x7d; + 0x7d; val_mask = (0x1 << 7); val_shift = 7; break; case (0x1 << 10): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0xf8 : - 0xfa; + 0xfa; val_mask = (0x7 << 4); val_shift = 4; break; case (0x1 << 11): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7b : - 0x7e; + 0x7e; val_mask = (0xffff << 0); val_shift = 0; break; case (0x1 << 12): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x7c : - 0x7f; + 0x7f; val_mask = (0xffff << 0); val_shift = 0; break; case (0x3 << 13): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x348 : - 0x349; + 0x349; val_mask = (0xff << 0); val_shift = 0; break; case (0x1 << 13): en_addr = (core_num == 0) ? 0xe7 : 0xec; val_addr = (core_num == 0) ? 0x348 : - 0x349; + 0x349; val_mask = (0xf << 0); val_shift = 0; break; @@ -19674,104 +19755,105 @@ wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, addr = 0xffff; break; } - } else if (override_id == NPHY_REV7_RFCTRLOVERRIDE_ID1) { + } else if (override_id == + NPHY_REV7_RFCTRLOVERRIDE_ID1) { switch (field) { case (0x1 << 1): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 1); val_shift = 1; break; case (0x1 << 3): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 3); val_shift = 3; break; case (0x1 << 5): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 5); val_shift = 5; break; case (0x1 << 4): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 4); val_shift = 4; break; case (0x1 << 2): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 2); val_shift = 2; break; case (0x1 << 7): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x7 << 8); val_shift = 8; break; case (0x1 << 11): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 14); val_shift = 14; break; case (0x1 << 10): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 13); val_shift = 13; break; case (0x1 << 9): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 12); val_shift = 12; break; case (0x1 << 8): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 11); val_shift = 11; break; case (0x1 << 6): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 6); val_shift = 6; break; case (0x1 << 0): en_addr = (core_num == 0) ? 0x342 : - 0x343; + 0x343; val_addr = (core_num == 0) ? 0x340 : - 0x341; + 0x341; val_mask = (0x1 << 0); val_shift = 0; break; @@ -19779,46 +19861,47 @@ wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, addr = 0xffff; break; } - } else if (override_id == NPHY_REV7_RFCTRLOVERRIDE_ID2) { + } else if (override_id == + NPHY_REV7_RFCTRLOVERRIDE_ID2) { switch (field) { case (0x1 << 3): en_addr = (core_num == 0) ? 0x346 : - 0x347; + 0x347; val_addr = (core_num == 0) ? 0x344 : - 0x345; + 0x345; val_mask = (0x1 << 3); val_shift = 3; break; case (0x1 << 1): en_addr = (core_num == 0) ? 0x346 : - 0x347; + 0x347; val_addr = (core_num == 0) ? 0x344 : - 0x345; + 0x345; val_mask = (0x1 << 1); val_shift = 1; break; case (0x1 << 0): en_addr = (core_num == 0) ? 0x346 : - 0x347; + 0x347; val_addr = (core_num == 0) ? 0x344 : - 0x345; + 0x345; val_mask = (0x1 << 0); val_shift = 0; break; case (0x1 << 2): en_addr = (core_num == 0) ? 0x346 : - 0x347; + 0x347; val_addr = (core_num == 0) ? 0x344 : - 0x345; + 0x345; val_mask = (0x1 << 2); val_shift = 2; break; case (0x1 << 4): en_addr = (core_num == 0) ? 0x346 : - 0x347; + 0x347; val_addr = (core_num == 0) ? 0x344 : - 0x345; + 0x345; val_mask = (0x1 << 4); val_shift = 4; break; @@ -19854,7 +19937,7 @@ wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, { u8 core_num; u16 addr = 0, mask = 0, en_addr = 0, val_addr = 0, en_mask = - 0, val_mask = 0; + 0, val_mask = 0; u8 shift = 0, val_shift = 0; if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { @@ -20103,76 +20186,93 @@ wlc_phy_rfctrl_override_1tomany_nphy(struct brcms_phy *pi, u16 cmd, u16 value, switch (cmd) { case NPHY_REV7_RfctrlOverride_cmd_rxrf_pu: - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 5), + value, core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 4), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 3), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); break; case NPHY_REV7_RfctrlOverride_cmd_rx_pu: - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + value, core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 1), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 0), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 1), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 11), 0, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); break; case NPHY_REV7_RfctrlOverride_cmd_tx_pu: - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 1, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + value, core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 1), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 0), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), value, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 11), 1, + core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID1); break; case NPHY_REV7_RfctrlOverride_cmd_rxgain: rfmxgain = value & 0x000ff; lpfgain = value & 0x0ff00; lpfgain = lpfgain >> 8; - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), - rfmxgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x3 << 13), - lpfgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 11), + rfmxgain, core_mask, + off, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x3 << 13), + lpfgain, core_mask, + off, + NPHY_REV7_RFCTRLOVERRIDE_ID0); break; case NPHY_REV7_RfctrlOverride_cmd_txgain: tgain = value & 0x7fff; lpfgain = value & 0x8000; lpfgain = lpfgain >> 14; - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), - tgain, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 13), - lpfgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 12), + tgain, core_mask, off, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 13), + lpfgain, core_mask, + off, + NPHY_REV7_RFCTRLOVERRIDE_ID0); break; } } @@ -20185,9 +20285,9 @@ wlc_phy_scale_offset_rssi_nphy(struct brcms_phy *pi, u16 scale, s8 offset, u16 valuetostuff; offset = (offset > NPHY_RSSICAL_MAXREAD) ? - NPHY_RSSICAL_MAXREAD : offset; + NPHY_RSSICAL_MAXREAD : offset; offset = (offset < (-NPHY_RSSICAL_MAXREAD - 1)) ? - -NPHY_RSSICAL_MAXREAD - 1 : offset; + -NPHY_RSSICAL_MAXREAD - 1 : offset; valuetostuff = ((scale & 0x3f) << 8) | (offset & 0x3f); @@ -20330,7 +20430,7 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) mod_phy_reg(pi, 0xe6, (0x1 << 5), 0); mask = (0x1 << 2) | - (0x1 << 3) | (0x1 << 4) | (0x1 << 5); + (0x1 << 3) | (0x1 << 4) | (0x1 << 5); mod_phy_reg(pi, 0xf9, mask, 0); mod_phy_reg(pi, 0xfb, mask, 0); @@ -20355,16 +20455,16 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) (0x3 << 8), 0); mask = (0x1 << 2) | - (0x1 << 3) | - (0x1 << 4) | (0x1 << 5); + (0x1 << 3) | + (0x1 << 4) | (0x1 << 5); mod_phy_reg(pi, (core == PHY_CORE_0) ? 0xf9 : 0xfb, mask, 0); if (rssi_type == NPHY_RSSI_SEL_W1) { - if (CHSPEC_IS5G - (pi->radio_chanspec)) { + if (CHSPEC_IS5G( + pi->radio_chanspec)) { mask = (0x1 << 2); val = 1 << 2; } else { @@ -20432,72 +20532,91 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) if (PHY_IPA(pi)) { if (NREV_GE - (pi->pubpi.phy_rev, - 7)) + (pi->pubpi. + phy_rev, + 7)) write_radio_reg - (pi, - ((core == - PHY_CORE_0) - ? - RADIO_2057_TX0_TX_SSI_MUX - : - RADIO_2057_TX1_TX_SSI_MUX), - (CHSPEC_IS5G - (pi-> - radio_chanspec) - ? 0xc : - 0xe)); + (pi, + ((core + == + PHY_CORE_0) + ? + RADIO_2057_TX0_TX_SSI_MUX + : + RADIO_2057_TX1_TX_SSI_MUX), + ( + CHSPEC_IS5G + ( + pi + -> + radio_chanspec) + ? + 0xc + : + 0xe)); else write_radio_reg - (pi, - RADIO_2056_TX_TX_SSI_MUX - | - ((core == - PHY_CORE_0) - ? - RADIO_2056_TX0 - : - RADIO_2056_TX1), - (CHSPEC_IS5G - (pi-> - radio_chanspec) - ? 0xc : - 0xe)); + ( + pi, + RADIO_2056_TX_TX_SSI_MUX + | + ((core + == + PHY_CORE_0) + ? + RADIO_2056_TX0 + : + RADIO_2056_TX1), + ( + CHSPEC_IS5G + ( + pi + -> + radio_chanspec) + ? + 0xc + : + 0xe)); } else { if (NREV_GE - (pi->pubpi.phy_rev, - 7)) { + (pi->pubpi. + phy_rev, + 7)) { write_radio_reg - (pi, - ((core == - PHY_CORE_0) - ? - RADIO_2057_TX0_TX_SSI_MUX - : - RADIO_2057_TX1_TX_SSI_MUX), - 0x11); + (pi, + ((core + == + PHY_CORE_0) + ? + RADIO_2057_TX0_TX_SSI_MUX + : + RADIO_2057_TX1_TX_SSI_MUX), + 0x11); if (pi->pubpi. radioid == BCM2057_ID) write_radio_reg - (pi, - RADIO_2057_IQTEST_SEL_PU, - 0x1); + ( + pi, + RADIO_2057_IQTEST_SEL_PU, + 0x1); } else { write_radio_reg - (pi, - RADIO_2056_TX_TX_SSI_MUX - | - ((core == - PHY_CORE_0) - ? - RADIO_2056_TX0 - : - RADIO_2056_TX1), - 0x11); + ( + pi, + RADIO_2056_TX_TX_SSI_MUX + | + ((core + == + PHY_CORE_0) + ? + RADIO_2056_TX0 + : + RADIO_2056_TX1), + 0x11); } } @@ -20576,16 +20695,16 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) (rssi_type == NPHY_RSSI_SEL_NB)) { rfctrlcmd_mask = ((0x1 << 8) | (0x7 << 3)); rfctrlcmd_val = (rfctrlcmd_rxen_val << 8) | - (rfctrlcmd_coresel_val << 3); + (rfctrlcmd_coresel_val << 3); rfctrlovr_mask = ((0x1 << 5) | (0x1 << 12) | (0x1 << 1) | (0x1 << 0)); rfctrlovr_val = (rfctrlovr_rssi_val << 5) | - (rfctrlovr_rxen_val << 12) | - (rfctrlovr_coresel_val << 1) | - (rfctrlovr_trigger_val << 0); + (rfctrlovr_rxen_val << 12) | + (rfctrlovr_coresel_val << 1) | + (rfctrlovr_trigger_val << 0); mod_phy_reg(pi, 0x78, rfctrlcmd_mask, rfctrlcmd_val); mod_phy_reg(pi, 0xec, rfctrlovr_mask, rfctrlovr_val); @@ -20722,7 +20841,7 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) u16 tempsense_Rcal; syn_tempprocsense_save = - read_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG); + read_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG); afectrlCore1_save = read_phy_reg(pi, 0xa6); afectrlCore2_save = read_phy_reg(pi, 0xa7); @@ -20856,7 +20975,7 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { syn_tempprocsense_save = - read_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE); + read_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE); afectrlCore1_save = read_phy_reg(pi, 0xa6); afectrlCore2_save = read_phy_reg(pi, 0xa7); @@ -20877,7 +20996,7 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x01); radio_temp[0] = - (126 * (radio_temp[1] + radio_temp2[1]) + 3987) / 64; + (126 * (radio_temp[1] + radio_temp2[1]) + 3987) / 64; write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, syn_tempprocsense_save); @@ -20892,17 +21011,17 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) } else { pwrdet_rxtx_core1_save = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); + read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); pwrdet_rxtx_core2_save = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); + read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); core1_txrf_iqcal1_save = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); + read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); core1_txrf_iqcal2_save = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); + read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); core2_txrf_iqcal1_save = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); + read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); core2_txrf_iqcal2_save = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); + read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); pd_pll_ts_save = read_radio_reg(pi, RADIO_2055_PD_PLL_TS); afectrlCore1_save = read_phy_reg(pi, 0xa6); @@ -20933,11 +21052,12 @@ s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) radio_temp[3] = (radio_temp[3] + radio_temp2[3]); radio_temp[0] = - (radio_temp[0] + radio_temp[1] + radio_temp[2] + - radio_temp[3]); + (radio_temp[0] + radio_temp[1] + radio_temp[2] + + radio_temp[3]); radio_temp[0] = - (radio_temp[0] + (8 * 32)) * (950 - 350) / 63 + (350 * 8); + (radio_temp[0] + + (8 * 32)) * (950 - 350) / 63 + (350 * 8); radio_temp[0] = (radio_temp[0] - (8 * 420)) / 38; @@ -21080,7 +21200,7 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) rf_pd_val = (rssi_type == NPHY_RSSI_SEL_NB) ? 0x6 : 0x4; rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110; + CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110; rfctrlintc_state[0] = read_phy_reg(pi, 0x91); rfpdcorerxtx_state[0] = read_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX); @@ -21093,19 +21213,19 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rf_pd_val); pd_mask = RADIO_2055_NBRSSI_PD | RADIO_2055_WBRSSI_G1_PD | - RADIO_2055_WBRSSI_G2_PD; + RADIO_2055_WBRSSI_G2_PD; pd_state[0] = - read_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC) & pd_mask; + read_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC) & pd_mask; pd_state[1] = - read_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC) & pd_mask; + read_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC) & pd_mask; mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, 0); mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, 0); rssi_ctrl_mask = RADIO_2055_NBRSSI_SEL | RADIO_2055_WBRSSI_G1_SEL | - RADIO_2055_WBRSSI_G2_SEL; + RADIO_2055_WBRSSI_G2_SEL; rssi_ctrl_state[0] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE1) & rssi_ctrl_mask; + read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE1) & rssi_ctrl_mask; rssi_ctrl_state[1] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE2) & rssi_ctrl_mask; + read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE2) & rssi_ctrl_mask; wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, @@ -21126,8 +21246,8 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) || (rssi_type == NPHY_RSSI_SEL_W2)) { for (ctr = 0; ctr < 2; ctr++) poll_miniq[vcm][ctr] = - min(poll_results[vcm][ctr * 2 + 0], - poll_results[vcm][ctr * 2 + 1]); + min(poll_results[vcm][ctr * 2 + 0], + poll_results[vcm][ctr * 2 + 1]); } } @@ -21156,26 +21276,26 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) for (result_idx = 0; result_idx < 4; result_idx++) { fine_digital_offset[result_idx] = - (target_code * NPHY_RSSICAL_NPOLL) - - poll_results[vcm_final[result_idx]][result_idx]; + (target_code * NPHY_RSSICAL_NPOLL) - + poll_results[vcm_final[result_idx]][result_idx]; if (fine_digital_offset[result_idx] < 0) { fine_digital_offset[result_idx] = - ABS(fine_digital_offset[result_idx]); + ABS(fine_digital_offset[result_idx]); fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); + (NPHY_RSSICAL_NPOLL / 2); fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; fine_digital_offset[result_idx] = - -fine_digital_offset[result_idx]; + -fine_digital_offset[result_idx]; } else { fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); + (NPHY_RSSICAL_NPOLL / 2); fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; } if (poll_results_min[result_idx] == NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) fine_digital_offset[result_idx] = - (target_code - NPHY_RSSICAL_MAXREAD - 1); + (target_code - NPHY_RSSICAL_MAXREAD - 1); wlc_phy_scale_offset_rssi_nphy(pi, 0x0, (s8) @@ -21324,8 +21444,8 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, } else { mask = (0x1 << 6) | - (0x1 << 7) | - (0x1 << 8) | (0x1 << 9); + (0x1 << 7) | + (0x1 << 8) | (0x1 << 9); val = value << 6; mod_phy_reg(pi, (core == @@ -21339,8 +21459,8 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, PHY_CORE_0) ? 0xe7 : 0xec, mask, val); - mask = (core == PHY_CORE_0) ? (0x1 << 0) - : (0x1 << 1); + mask = (core == PHY_CORE_0) ? + (0x1 << 0) : (0x1 << 1); val = 1 << ((core == PHY_CORE_0) ? 0 : 1); mod_phy_reg(pi, 0x78, mask, val); @@ -21348,7 +21468,7 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, SPINWAIT(((read_phy_reg(pi, 0x78) & val) != 0), 10000); if (WARN(read_phy_reg(pi, 0x78) & val, - "HW error: override failed")) + "HW error: override failed")) return; mask = (0x1 << 0); @@ -21391,7 +21511,8 @@ wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, PHY_CORE_0) ? 0x91 : 0x92, mask, val); } - } else if (field == NPHY_RfctrlIntc_override_EXT_LNA_PU) { + } else if (field == + NPHY_RfctrlIntc_override_EXT_LNA_PU) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (CHSPEC_IS5G(pi->radio_chanspec)) { @@ -21543,10 +21664,14 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) u16 NPHY_REV7_RfctrlMiscReg3_save, NPHY_REV7_RfctrlMiscReg4_save; u16 NPHY_REV7_RfctrlMiscReg5_save, NPHY_REV7_RfctrlMiscReg6_save; - NPHY_REV7_RfctrlOverride3_save = NPHY_REV7_RfctrlOverride4_save = - NPHY_REV7_RfctrlOverride5_save = NPHY_REV7_RfctrlOverride6_save = - NPHY_REV7_RfctrlMiscReg3_save = NPHY_REV7_RfctrlMiscReg4_save = - NPHY_REV7_RfctrlMiscReg5_save = NPHY_REV7_RfctrlMiscReg6_save = 0; + NPHY_REV7_RfctrlOverride3_save = + NPHY_REV7_RfctrlOverride4_save = + NPHY_REV7_RfctrlOverride5_save = + NPHY_REV7_RfctrlOverride6_save = + NPHY_REV7_RfctrlMiscReg3_save = + NPHY_REV7_RfctrlMiscReg4_save = + NPHY_REV7_RfctrlMiscReg5_save = + NPHY_REV7_RfctrlMiscReg6_save = 0; classif_state = wlc_phy_classifier_nphy(pi, 0, 0); wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); @@ -21587,16 +21712,18 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) RADIO_MIMO_CORESEL_ALLRXTX); if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_rxrf_pu, - 0, 0, 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_rxrf_pu, + 0, 0, 0); else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0, 0); if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_rx_pu, - 1, 0, 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_rx_pu, + 1, 0, 0); else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0, 0); @@ -21613,12 +21740,14 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) if (CHSPEC_IS5G(pi->radio_chanspec)) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 1, 0, - 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 5), + 0, 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 4), 1, 0, + 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); } else { wlc_phy_rfctrl_override_nphy(pi, (0x1 << 5), 0, 0, 0); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 4), 1, 0, 0); @@ -21626,12 +21755,14 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), 1, 0, - 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 4), + 0, 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 5), 1, 0, + 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); } else { wlc_phy_rfctrl_override_nphy(pi, (0x1 << 4), 0, 0, 0); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 5), 1, 0, 0); @@ -21639,7 +21770,7 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) } rxcore_state = wlc_phy_rxcore_getstate_nphy( - (struct brcms_phy_pub *) pi); + (struct brcms_phy_pub *) pi); vcm_level_max = 8; @@ -21681,18 +21812,22 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) } for (result_idx = 0; result_idx < 4; result_idx++) { - if ((core == result_idx / 2) && (result_idx % 2 == 0)) { + if ((core == result_idx / 2) && + (result_idx % 2 == 0)) { min_d = NPHY_RSSICAL_MAXD; min_vcm = 0; min_poll = - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL + - 1; + NPHY_RSSICAL_MAXREAD * + NPHY_RSSICAL_NPOLL + 1; for (vcm = 0; vcm < vcm_level_max; vcm++) { - curr_d = poll_results[vcm][result_idx] * - poll_results[vcm][result_idx] + - poll_results[vcm][result_idx + 1] * - poll_results[vcm][result_idx + 1]; + curr_d = + poll_results[vcm][result_idx] * + poll_results[vcm][result_idx] + + poll_results[vcm][result_idx + + 1] * + poll_results[vcm][result_idx + + 1]; if (curr_d < min_d) { min_d = curr_d; min_vcm = vcm; @@ -21700,8 +21835,8 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) if (poll_results[vcm][result_idx] < min_poll) min_poll = - poll_results[vcm] - [result_idx]; + poll_results[vcm] + [result_idx]; } vcm_final = min_vcm; poll_results_min[result_idx] = min_poll; @@ -21723,47 +21858,44 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) for (result_idx = 0; result_idx < 4; result_idx++) { if (core == result_idx / 2) { fine_digital_offset[result_idx] = - (NPHY_RSSICAL_NB_TARGET * - NPHY_RSSICAL_NPOLL) - - poll_results[vcm_final][result_idx]; + (NPHY_RSSICAL_NB_TARGET * + NPHY_RSSICAL_NPOLL) - + poll_results[vcm_final][result_idx]; if (fine_digital_offset[result_idx] < 0) { fine_digital_offset[result_idx] = - ABS(fine_digital_offset - [result_idx]); + ABS(fine_digital_offset + [result_idx]); fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); + (NPHY_RSSICAL_NPOLL / 2); fine_digital_offset[result_idx] /= - NPHY_RSSICAL_NPOLL; + NPHY_RSSICAL_NPOLL; fine_digital_offset[result_idx] = - -fine_digital_offset[result_idx]; + -fine_digital_offset[ + result_idx]; } else { fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); + (NPHY_RSSICAL_NPOLL / 2); fine_digital_offset[result_idx] /= - NPHY_RSSICAL_NPOLL; + NPHY_RSSICAL_NPOLL; } if (poll_results_min[result_idx] == NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) fine_digital_offset[result_idx] = - (NPHY_RSSICAL_NB_TARGET - - NPHY_RSSICAL_MAXREAD - 1); + (NPHY_RSSICAL_NB_TARGET - + NPHY_RSSICAL_MAXREAD - 1); - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, - (s8) - fine_digital_offset - [result_idx], - (result_idx / - 2 == - 0) ? - RADIO_MIMO_CORESEL_CORE1 - : - RADIO_MIMO_CORESEL_CORE2, - (result_idx % - 2 == - 0) ? NPHY_RAIL_I - : NPHY_RAIL_Q, - NPHY_RSSI_SEL_NB); + wlc_phy_scale_offset_rssi_nphy( + pi, 0x0, + (s8) + fine_digital_offset + [result_idx], + (result_idx / 2 == 0) ? + RADIO_MIMO_CORESEL_CORE1 : + RADIO_MIMO_CORESEL_CORE2, + (result_idx % 2 == 0) ? + NPHY_RAIL_I : NPHY_RAIL_Q, + NPHY_RSSI_SEL_NB); } } @@ -21804,46 +21936,44 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) for (result_idx = 0; result_idx < 4; result_idx++) { if (core == result_idx / 2) { fine_digital_offset[result_idx] = - (target_code * NPHY_RSSICAL_NPOLL) - - poll_result_core[result_idx]; - if (fine_digital_offset[result_idx] < 0) { + (target_code * + NPHY_RSSICAL_NPOLL) - + poll_result_core[result_idx]; + if (fine_digital_offset[result_idx] < + 0) { fine_digital_offset[result_idx] - = - ABS(fine_digital_offset - [result_idx]); + = ABS( + fine_digital_offset + [result_idx]); fine_digital_offset[result_idx] - += (NPHY_RSSICAL_NPOLL / 2); + += (NPHY_RSSICAL_NPOLL + / 2); fine_digital_offset[result_idx] - /= NPHY_RSSICAL_NPOLL; + /= NPHY_RSSICAL_NPOLL; fine_digital_offset[result_idx] - = - -fine_digital_offset - [result_idx]; + = -fine_digital_offset + [result_idx]; } else { fine_digital_offset[result_idx] - += (NPHY_RSSICAL_NPOLL / 2); + += (NPHY_RSSICAL_NPOLL + / 2); fine_digital_offset[result_idx] - /= NPHY_RSSICAL_NPOLL; + /= NPHY_RSSICAL_NPOLL; } - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, - (s8) - fine_digital_offset - [core * - 2], - (core == - PHY_CORE_0) - ? - RADIO_MIMO_CORESEL_CORE1 - : - RADIO_MIMO_CORESEL_CORE2, - (result_idx - % 2 == - 0) ? - NPHY_RAIL_I - : - NPHY_RAIL_Q, - rssi_type); + wlc_phy_scale_offset_rssi_nphy( + pi, 0x0, + (s8) + fine_digital_offset + [core * + 2], + (core == PHY_CORE_0) ? + RADIO_MIMO_CORESEL_CORE1 : + RADIO_MIMO_CORESEL_CORE2, + (result_idx % 2 == 0) ? + NPHY_RAIL_I : + NPHY_RAIL_Q, + rssi_type); } } @@ -21892,87 +22022,87 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) if (CHSPEC_IS2G(pi->radio_chanspec)) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { pi->rssical_cache.rssical_radio_regs_2G[0] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); + read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); pi->rssical_cache.rssical_radio_regs_2G[1] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); + read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); } else { pi->rssical_cache.rssical_radio_regs_2G[0] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | + RADIO_2056_RX0); pi->rssical_cache.rssical_radio_regs_2G[1] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX1); + read_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | + RADIO_2056_RX1); } pi->rssical_cache.rssical_phyregs_2G[0] = - read_phy_reg(pi, 0x1a6); + read_phy_reg(pi, 0x1a6); pi->rssical_cache.rssical_phyregs_2G[1] = - read_phy_reg(pi, 0x1ac); + read_phy_reg(pi, 0x1ac); pi->rssical_cache.rssical_phyregs_2G[2] = - read_phy_reg(pi, 0x1b2); + read_phy_reg(pi, 0x1b2); pi->rssical_cache.rssical_phyregs_2G[3] = - read_phy_reg(pi, 0x1b8); + read_phy_reg(pi, 0x1b8); pi->rssical_cache.rssical_phyregs_2G[4] = - read_phy_reg(pi, 0x1a4); + read_phy_reg(pi, 0x1a4); pi->rssical_cache.rssical_phyregs_2G[5] = - read_phy_reg(pi, 0x1aa); + read_phy_reg(pi, 0x1aa); pi->rssical_cache.rssical_phyregs_2G[6] = - read_phy_reg(pi, 0x1b0); + read_phy_reg(pi, 0x1b0); pi->rssical_cache.rssical_phyregs_2G[7] = - read_phy_reg(pi, 0x1b6); + read_phy_reg(pi, 0x1b6); pi->rssical_cache.rssical_phyregs_2G[8] = - read_phy_reg(pi, 0x1a5); + read_phy_reg(pi, 0x1a5); pi->rssical_cache.rssical_phyregs_2G[9] = - read_phy_reg(pi, 0x1ab); + read_phy_reg(pi, 0x1ab); pi->rssical_cache.rssical_phyregs_2G[10] = - read_phy_reg(pi, 0x1b1); + read_phy_reg(pi, 0x1b1); pi->rssical_cache.rssical_phyregs_2G[11] = - read_phy_reg(pi, 0x1b7); + read_phy_reg(pi, 0x1b7); pi->nphy_rssical_chanspec_2G = pi->radio_chanspec; } else { if (NREV_GE(pi->pubpi.phy_rev, 7)) { pi->rssical_cache.rssical_radio_regs_5G[0] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); + read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); pi->rssical_cache.rssical_radio_regs_5G[1] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); + read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); } else { pi->rssical_cache.rssical_radio_regs_5G[0] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | + RADIO_2056_RX0); pi->rssical_cache.rssical_radio_regs_5G[1] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX1); + read_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | + RADIO_2056_RX1); } pi->rssical_cache.rssical_phyregs_5G[0] = - read_phy_reg(pi, 0x1a6); + read_phy_reg(pi, 0x1a6); pi->rssical_cache.rssical_phyregs_5G[1] = - read_phy_reg(pi, 0x1ac); + read_phy_reg(pi, 0x1ac); pi->rssical_cache.rssical_phyregs_5G[2] = - read_phy_reg(pi, 0x1b2); + read_phy_reg(pi, 0x1b2); pi->rssical_cache.rssical_phyregs_5G[3] = - read_phy_reg(pi, 0x1b8); + read_phy_reg(pi, 0x1b8); pi->rssical_cache.rssical_phyregs_5G[4] = - read_phy_reg(pi, 0x1a4); + read_phy_reg(pi, 0x1a4); pi->rssical_cache.rssical_phyregs_5G[5] = - read_phy_reg(pi, 0x1aa); + read_phy_reg(pi, 0x1aa); pi->rssical_cache.rssical_phyregs_5G[6] = - read_phy_reg(pi, 0x1b0); + read_phy_reg(pi, 0x1b0); pi->rssical_cache.rssical_phyregs_5G[7] = - read_phy_reg(pi, 0x1b6); + read_phy_reg(pi, 0x1b6); pi->rssical_cache.rssical_phyregs_5G[8] = - read_phy_reg(pi, 0x1a5); + read_phy_reg(pi, 0x1a5); pi->rssical_cache.rssical_phyregs_5G[9] = - read_phy_reg(pi, 0x1ab); + read_phy_reg(pi, 0x1ab); pi->rssical_cache.rssical_phyregs_5G[10] = - read_phy_reg(pi, 0x1b1); + read_phy_reg(pi, 0x1b1); pi->rssical_cache.rssical_phyregs_5G[11] = - read_phy_reg(pi, 0x1b7); + read_phy_reg(pi, 0x1b7); pi->nphy_rssical_chanspec_5G = pi->radio_chanspec; } @@ -22143,8 +22273,8 @@ wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u16 loops = 0xffff; u16 wait = 0; - num_samps = - wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, dac_test_mode); + num_samps = wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, + dac_test_mode); if (num_samps == 0) return -EBADE; @@ -22170,7 +22300,7 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cs32 *tone_buf, for (t = 0; t < num_samps; t++) data_buf[t] = ((((unsigned int)tone_buf[t].i) & 0x3ff) << 10) | - (((unsigned int)tone_buf[t].q) & 0x3ff); + (((unsigned int)tone_buf[t].q) & 0x3ff); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, data_buf); @@ -22204,22 +22334,24 @@ wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, lpf_bw_ctl_override4 = read_phy_reg(pi, 0x343) & (0x1 << 7); if (lpf_bw_ctl_override3 | lpf_bw_ctl_override4) { lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) & - (0x7 << 8); + (0x7 << 8); lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) & - (0x7 << 8); + (0x7 << 8); } else { - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 7), + wlc_phy_read_lpf_bw_ctl_nphy + (pi, + 0), 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); pi->nphy_sample_play_lpf_bw_ctl_ovr = true; lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) & - (0x7 << 8); + (0x7 << 8); lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) & - (0x7 << 8); + (0x7 << 8); } } @@ -22228,7 +22360,7 @@ wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, 87, 16, &bb_mult); pi->nphy_bb_mult_save = - BB_MULT_VALID_MASK | (bb_mult & BB_MULT_MASK); + BB_MULT_VALID_MASK | (bb_mult & BB_MULT_MASK); } if (modify_bbmult) { @@ -22296,10 +22428,11 @@ void wlc_phy_stopplayback_nphy(struct brcms_phy *pi) if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) { if (pi->nphy_sample_play_lpf_bw_ctl_ovr) { - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 7), - 0, 0, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 7), + 0, 0, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); pi->nphy_sample_play_lpf_bw_ctl_ovr = false; } } @@ -22328,33 +22461,33 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) for (core_no = 0; core_no < 2; core_no++) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { target_gain.ipa[core_no] = - curr_gain[core_no] & 0x0007; + curr_gain[core_no] & 0x0007; target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x00F8) >> 3); + ((curr_gain[core_no] & 0x00F8) >> 3); target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0F00) >> 8); + ((curr_gain[core_no] & 0x0F00) >> 8); target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x7000) >> 12); + ((curr_gain[core_no] & 0x7000) >> 12); target_gain.txlpf[core_no] = - ((curr_gain[core_no] & 0x8000) >> 15); + ((curr_gain[core_no] & 0x8000) >> 15); } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { target_gain.ipa[core_no] = - curr_gain[core_no] & 0x000F; + curr_gain[core_no] & 0x000F; target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x00F0) >> 4); + ((curr_gain[core_no] & 0x00F0) >> 4); target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0F00) >> 8); + ((curr_gain[core_no] & 0x0F00) >> 8); target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x7000) >> 12); + ((curr_gain[core_no] & 0x7000) >> 12); } else { target_gain.ipa[core_no] = - curr_gain[core_no] & 0x0003; + curr_gain[core_no] & 0x0003; target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x000C) >> 2); + ((curr_gain[core_no] & 0x000C) >> 2); target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0070) >> 4); + ((curr_gain[core_no] & 0x0070) >> 4); target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x0380) >> 7); + ((curr_gain[core_no] & 0x0380) >> 7); } } } else { @@ -22366,90 +22499,104 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) if (NREV_GE(phyrev, 3)) { if (PHY_IPA(pi)) { tx_pwrctrl_tbl = - wlc_phy_get_ipa_gaintbl_nphy(pi); + wlc_phy_get_ipa_gaintbl_nphy(pi); } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { if (NREV_IS(phyrev, 3)) tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev3; + nphy_tpc_5GHz_txgain_rev3; else if (NREV_IS(phyrev, 4)) tx_pwrctrl_tbl = - (pi->srom_fem5g. - extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA - : - nphy_tpc_5GHz_txgain_rev4; + (pi->srom_fem5g + . + extpagain == + 3) ? + nphy_tpc_5GHz_txgain_HiPwrEPA + : + nphy_tpc_5GHz_txgain_rev4; else tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev5; + nphy_tpc_5GHz_txgain_rev5; } else { if (NREV_GE(phyrev, 7)) { if (pi->pubpi. radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev3; + tx_pwrctrl_tbl + = + nphy_tpc_txgain_epa_2057rev3; else if (pi->pubpi. - radiorev == + radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev5; + tx_pwrctrl_tbl + = + nphy_tpc_txgain_epa_2057rev5; } else { if (NREV_GE(phyrev, 5) && (pi->srom_fem2g. extpagain == 3)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_HiPwrEPA; + tx_pwrctrl_tbl + = + nphy_tpc_txgain_HiPwrEPA; else - tx_pwrctrl_tbl = - nphy_tpc_txgain_rev3; + tx_pwrctrl_tbl + = + nphy_tpc_txgain_rev3; } } } if (NREV_GE(phyrev, 7)) { target_gain.ipa[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 16) & 0x7; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 16) & 0x7; target_gain.pad[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 19) & 0x1f; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 19) & 0x1f; target_gain.pga[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 24) & 0xf; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 24) & 0xf; target_gain.txgm[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 28) & 0x7; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 28) & 0x7; target_gain.txlpf[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 31) & 0x1; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 31) & 0x1; } else { target_gain.ipa[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 16) & 0xf; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 16) & 0xf; target_gain.pad[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 20) & 0xf; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 20) & 0xf; target_gain.pga[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 24) & 0xf; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 24) & 0xf; target_gain.txgm[core_no] = - (tx_pwrctrl_tbl[base_idx[core_no]] - >> 28) & 0x7; + (tx_pwrctrl_tbl + [base_idx[core_no]] + >> 28) & 0x7; } } else { target_gain.ipa[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> 16) & - 0x3; + (nphy_tpc_txgain[base_idx[core_no]] >> + 16) & 0x3; target_gain.pad[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> 18) & - 0x3; + (nphy_tpc_txgain[base_idx[core_no]] >> + 18) & 0x3; target_gain.pga[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> 20) & - 0x7; + (nphy_tpc_txgain[base_idx[core_no]] >> + 20) & 0x7; target_gain.txgm[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> 23) & - 0x7; + (nphy_tpc_txgain[base_idx[core_no]] >> + 23) & 0x7; } } } @@ -22477,16 +22624,13 @@ wlc_phy_iqcal_gainparams_nphy(struct brcms_phy *pi, u16 core_no, params->ipa = target_gain.ipa[core_no]; if (NREV_GE(pi->pubpi.phy_rev, 7)) params->cal_gain = - ((params->txlpf << 15) | (params-> - txgm << 12) | (params-> - pga << 8) | - (params->pad << 3) | (params->ipa)); + ((params->txlpf << 15) | (params->txgm << 12) | + (params->pga << 8) | + (params->pad << 3) | (params->ipa)); else params->cal_gain = - ((params->txgm << 12) | (params-> - pga << 8) | (params-> - pad << 4) | - (params->ipa)); + ((params->txgm << 12) | (params->pga << 8) | + (params->pad << 4) | (params->ipa)); params->ncorr[0] = 0x79; params->ncorr[1] = 0x79; @@ -22496,9 +22640,8 @@ wlc_phy_iqcal_gainparams_nphy(struct brcms_phy *pi, u16 core_no, } else { gain_index = ((target_gain.pad[core_no] << 0) | - (target_gain.pga[core_no] << 4) | (target_gain. - txgm[core_no] - << 8)); + (target_gain.pga[core_no] << 4) | + (target_gain.txgm[core_no] << 8)); idx = -1; for (k = 0; k < NPHY_IQCAL_NUMGAINS; k++) { @@ -22530,37 +22673,39 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) for (core = 0; core <= 1; core++) { pi->tx_rx_cal_radio_saveregs[(core * 11) + 0] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MASTER); pi->tx_rx_cal_radio_saveregs[(core * 11) + 1] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_VCM_HG); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + IQCAL_VCM_HG); pi->tx_rx_cal_radio_saveregs[(core * 11) + 2] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_IDAC); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + IQCAL_IDAC); pi->tx_rx_cal_radio_saveregs[(core * 11) + 3] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_VCM); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TSSI_VCM); pi->tx_rx_cal_radio_saveregs[(core * 11) + 4] = 0; pi->tx_rx_cal_radio_saveregs[(core * 11) + 5] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MUX); if (pi->pubpi.radiorev != 5) pi->tx_rx_cal_radio_saveregs[(core * 11) + 6] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSIA); + READ_RADIO_REG3(pi, RADIO_2057, TX, + core, + TSSIA); pi->tx_rx_cal_radio_saveregs[(core * 11) + 7] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG); pi->tx_rx_cal_radio_saveregs[(core * 11) + 8] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_MISC1); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TSSI_MISC1); if (CHSPEC_IS5G(pi->radio_chanspec)) { WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, @@ -22623,58 +22768,62 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) for (core = 0; core <= 1; core++) { jtag_core = - (core == - PHY_CORE_0) ? RADIO_2056_TX0 : RADIO_2056_TX1; + (core == + PHY_CORE_0) ? RADIO_2056_TX0 : RADIO_2056_TX1; pi->tx_rx_cal_radio_saveregs[(core * 11) + 0] = - read_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MASTER | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TX_SSI_MASTER | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 1] = - read_radio_reg(pi, - RADIO_2056_TX_IQCAL_VCM_HG | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_IQCAL_VCM_HG | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 2] = - read_radio_reg(pi, - RADIO_2056_TX_IQCAL_IDAC | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_IQCAL_IDAC | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 3] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_VCM | jtag_core); + read_radio_reg( + pi, + RADIO_2056_TX_TSSI_VCM | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 4] = - read_radio_reg(pi, - RADIO_2056_TX_TX_AMP_DET | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TX_AMP_DET | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 5] = - read_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TX_SSI_MUX | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 6] = - read_radio_reg(pi, RADIO_2056_TX_TSSIA | jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TSSIA | jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 7] = - read_radio_reg(pi, RADIO_2056_TX_TSSIG | jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TSSIG | jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 8] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC1 | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TSSI_MISC1 | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 9] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC2 | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TSSI_MISC2 | + jtag_core); pi->tx_rx_cal_radio_saveregs[(core * 11) + 10] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC3 | - jtag_core); + read_radio_reg(pi, + RADIO_2056_TX_TSSI_MISC3 | + jtag_core); if (CHSPEC_IS5G(pi->radio_chanspec)) { write_radio_reg(pi, @@ -22694,16 +22843,18 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) jtag_core, 0x00); if (PHY_IPA(pi)) { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x4); + write_radio_reg( + pi, + RADIO_2056_TX_TX_SSI_MUX + | jtag_core, 0x4); write_radio_reg(pi, RADIO_2056_TX_TSSIA | jtag_core, 0x1); } else { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x00); + write_radio_reg( + pi, + RADIO_2056_TX_TX_SSI_MUX + | jtag_core, 0x00); write_radio_reg(pi, RADIO_2056_TX_TSSIA | jtag_core, 0x2f); @@ -22743,23 +22894,27 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) if (PHY_IPA(pi)) { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x06); + write_radio_reg( + pi, + RADIO_2056_TX_TX_SSI_MUX + | jtag_core, 0x06); if (NREV_LT(pi->pubpi.phy_rev, 5)) - write_radio_reg(pi, - RADIO_2056_TX_TSSIG - | jtag_core, - 0x11); + write_radio_reg( + pi, + RADIO_2056_TX_TSSIG + | jtag_core, + 0x11); else - write_radio_reg(pi, - RADIO_2056_TX_TSSIG - | jtag_core, - 0x1); + write_radio_reg( + pi, + RADIO_2056_TX_TSSIG + | jtag_core, + 0x1); } else { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x00); + write_radio_reg( + pi, + RADIO_2056_TX_TX_SSI_MUX + | jtag_core, 0x00); write_radio_reg(pi, RADIO_2056_TX_TSSIG | jtag_core, 0x20); @@ -22779,23 +22934,23 @@ static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) } else { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); + read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1, 0x29); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); + read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2, 0x54); pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); + read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1, 0x29); pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); + read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2, 0x54); pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); + read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); pi->tx_rx_cal_radio_saveregs[5] = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); + read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); if ((read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand) == 0) { @@ -22856,11 +23011,8 @@ static void wlc_phy_txcal_radio_cleanup_nphy(struct brcms_phy *pi) if (pi->pubpi.radiorev != 5) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIA, - pi-> - tx_rx_cal_radio_saveregs[(core - * - 11) + - 6]); + pi->tx_rx_cal_radio_saveregs + [(core * 11) + 6]); WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, pi-> @@ -22874,9 +23026,8 @@ static void wlc_phy_txcal_radio_cleanup_nphy(struct brcms_phy *pi) } } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { for (core = 0; core <= 1; core++) { - jtag_core = - (core == - PHY_CORE_0) ? RADIO_2056_TX0 : RADIO_2056_TX1; + jtag_core = (core == PHY_CORE_0) ? + RADIO_2056_TX0 : RADIO_2056_TX1; write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MASTER | jtag_core, @@ -23003,19 +23154,21 @@ static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) pi->tx_rx_cal_phy_saveregs[8] = read_phy_reg(pi, 0x92); if (!(pi->use_int_tx_iqlo_cal_nphy)) - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_PA, - 1, - RADIO_MIMO_CORESEL_CORE1 - | - RADIO_MIMO_CORESEL_CORE2); + wlc_phy_rfctrlintc_override_nphy( + pi, + NPHY_RfctrlIntc_override_PA, + 1, + RADIO_MIMO_CORESEL_CORE1 + | + RADIO_MIMO_CORESEL_CORE2); else - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_PA, - 0, - RADIO_MIMO_CORESEL_CORE1 - | - RADIO_MIMO_CORESEL_CORE2); + wlc_phy_rfctrlintc_override_nphy( + pi, + NPHY_RfctrlIntc_override_PA, + 0, + RADIO_MIMO_CORESEL_CORE1 + | + RADIO_MIMO_CORESEL_CORE2); wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_TRSW, @@ -23034,10 +23187,12 @@ static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), + wlc_phy_read_lpf_bw_ctl_nphy + (pi, + 0), 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); if (pi->use_int_tx_iqlo_cal_nphy && !(pi->internal_tx_iqlo_cal_tapoff_intpa_nphy)) { @@ -23048,25 +23203,30 @@ static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) 1 << 4); if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - 1, 0); - mod_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - 1, 0); + mod_radio_reg( + pi, + RADIO_2057_PAD2G_TUNE_PUS_CORE0, + 1, 0); + mod_radio_reg( + pi, + RADIO_2057_PAD2G_TUNE_PUS_CORE1, + 1, 0); } else { - mod_radio_reg(pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, - 1, 0); - mod_radio_reg(pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, - 1, 0); + mod_radio_reg( + pi, + RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, + 1, 0); + mod_radio_reg( + pi, + RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, + 1, 0); } } else if (NREV_GE(pi->pubpi.phy_rev, 8)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 3), 0, - 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 3), 0, + 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); } } } else { @@ -23130,9 +23290,10 @@ static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, - 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), 0, 0, + 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); wlc_phy_resetcca_nphy(pi); @@ -23141,28 +23302,33 @@ static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) if (NREV_IS(pi->pubpi.phy_rev, 7)) { if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - 1, 1); - mod_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - 1, 1); + mod_radio_reg( + pi, + RADIO_2057_PAD2G_TUNE_PUS_CORE0, + 1, 1); + mod_radio_reg( + pi, + RADIO_2057_PAD2G_TUNE_PUS_CORE1, + 1, 1); } else { - mod_radio_reg(pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, - 1, 1); - mod_radio_reg(pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, - 1, 1); + mod_radio_reg( + pi, + RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, + 1, 1); + mod_radio_reg( + pi, + RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, + 1, 1); } mod_radio_reg(pi, RADIO_2057_OVR_REG0, 1 << 4, 0); } else if (NREV_GE(pi->pubpi.phy_rev, 8)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 3), 0, - 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 3), 0, + 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); } } } else { @@ -23182,7 +23348,7 @@ static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) } } -#define NPHY_CAL_TSSISAMPS 64 +#define NPHY_CAL_TSSISAMPS 64 #define NPHY_TEST_TONE_FREQ_40MHz 4000 #define NPHY_TEST_TONE_FREQ_20MHz 2500 @@ -23205,8 +23371,8 @@ wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, u8 num_samps) idle_tssi[1] = (temp <= 31) ? temp : (temp - 64); tssi_type = - CHSPEC_IS5G(pi->radio_chanspec) ? - (u8)NPHY_RSSI_SEL_TSSI_5G : (u8)NPHY_RSSI_SEL_TSSI_2G; + CHSPEC_IS5G(pi->radio_chanspec) ? + (u8)NPHY_RSSI_SEL_TSSI_5G : (u8)NPHY_RSSI_SEL_TSSI_2G; wlc_phy_poll_rssi_nphy(pi, tssi_type, rssi_buf, num_samps); @@ -23269,21 +23435,23 @@ static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) (pi->pubpi.radiorev == 6)) { pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev3n4n6; + txcal_index_2057_rev3n4n6; pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev3n4n6; - wlc_phy_txpwr_index_nphy(pi, 3, - txcal_index_2057_rev3n4n6, - false); + txcal_index_2057_rev3n4n6; + wlc_phy_txpwr_index_nphy( + pi, 3, + txcal_index_2057_rev3n4n6, + false); } else { pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev5n7; + txcal_index_2057_rev5n7; pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev5n7; - wlc_phy_txpwr_index_nphy(pi, 3, - txcal_index_2057_rev5n7, - false); + txcal_index_2057_rev5n7; + wlc_phy_txpwr_index_nphy( + pi, 3, + txcal_index_2057_rev5n7, + false); } save_bbmult = true; @@ -23291,7 +23459,7 @@ static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) wlc_phy_cal_txgainctrl_nphy(pi, 11, false); if (pi->sh->hw_phytxchain != 3) { pi->nphy_txcal_pwr_idx[1] = - pi->nphy_txcal_pwr_idx[0]; + pi->nphy_txcal_pwr_idx[0]; wlc_phy_txpwr_index_nphy(pi, 3, pi-> nphy_txcal_pwr_idx[0], @@ -23520,15 +23688,15 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) }; bbmult = (core == PHY_CORE_0) ? - ((pi->nphy_txcal_bbmult >> 8) & 0xff) : (pi-> - nphy_txcal_bbmult & 0xff); + ((pi->nphy_txcal_bbmult >> 8) & 0xff) : + (pi->nphy_txcal_bbmult & 0xff); for (index = 0; index < 18; index++) { bbmult_scale = ladder_lo[index].percent * bbmult; bbmult_scale /= 100; tblentry = - ((bbmult_scale & 0xff) << 8) | ladder_lo[index].g_env; + ((bbmult_scale & 0xff) << 8) | ladder_lo[index].g_env; wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, index, 16, &tblentry); @@ -23536,7 +23704,7 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) bbmult_scale /= 100; tblentry = - ((bbmult_scale & 0xff) << 8) | ladder_iq[index].g_env; + ((bbmult_scale & 0xff) << 8) | ladder_iq[index].g_env; wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, index + 32, 16, &tblentry); } @@ -23565,7 +23733,8 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) if (pi->cal_type_override != PHY_PERICAL_AUTO) fullcal = - (pi->cal_type_override == PHY_PERICAL_FULL) ? true : false; + (pi->cal_type_override == + PHY_PERICAL_FULL) ? true : false; if ((pi->mphase_cal_phase_id > MPHASE_CAL_STATE_INIT)) { if (pi->nphy_txiqlocal_chanspec != pi->radio_chanspec) @@ -23582,9 +23751,9 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_IDLE) || (pi->mphase_cal_phase_id == MPHASE_CAL_STATE_INIT)) { pi->nphy_cal_orig_pwr_idx[0] = - (u8) ((read_phy_reg(pi, 0x1ed) >> 8) & 0x7f); + (u8) ((read_phy_reg(pi, 0x1ed) >> 8) & 0x7f); pi->nphy_cal_orig_pwr_idx[1] = - (u8) ((read_phy_reg(pi, 0x1ee) >> 8) & 0x7f); + (u8) ((read_phy_reg(pi, 0x1ee) >> 8) & 0x7f); if (pi->nphy_txpwrctrl != PHY_TPC_HW_OFF) { wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, @@ -23613,7 +23782,8 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) target_gain = pi->nphy_cal_target_gain; } if (0 == - wlc_phy_cal_txiqlo_nphy(pi, target_gain, fullcal, mphase)) { + wlc_phy_cal_txiqlo_nphy(pi, target_gain, fullcal, + mphase)) { if (PHY_IPA(pi)) wlc_phy_a4(pi, true); @@ -23625,13 +23795,9 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) wlc_phyreg_enter((struct brcms_phy_pub *) pi); if (0 == wlc_phy_cal_rxiq_nphy(pi, target_gain, - (pi-> - first_cal_after_assoc - || (pi-> - cal_type_override - == - PHY_PERICAL_FULL)) - ? 2 : 0, false)) { + (pi->first_cal_after_assoc || + (pi->cal_type_override == + PHY_PERICAL_FULL)) ? 2 : 0, false)) { wlc_phy_savecal_nphy(pi); wlc_phy_txpwrctrl_coeff_setup_nphy(pi); @@ -23674,8 +23840,8 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) pi->nphy_rxcal_active = true; if (wlc_phy_cal_txiqlo_nphy - (pi, pi->nphy_cal_target_gain, fullcal, - true) != 0) { + (pi, pi->nphy_cal_target_gain, fullcal, + true) != 0) { wlc_phy_cal_perical_mphase_reset(pi); break; @@ -23767,15 +23933,15 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) } else { wlc_phy_txpwr_index_nphy(pi, (1 << 0), (s8) (pi-> - nphy_txpwrindex - [0]. - index_internal), + nphy_txpwrindex + [0]. + index_internal), false); wlc_phy_txpwr_index_nphy(pi, (1 << 1), (s8) (pi-> - nphy_txpwrindex - [1]. - index_internal), + nphy_txpwrindex + [1]. + index_internal), false); } } @@ -23812,35 +23978,35 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, - 0x1902, + 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, - 0x6407 + 0x6407 }; u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, - 0x3200, + 0x3200, 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, - 0x6407 + 0x6407 }; u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, - 0x1202, + 0x1202, 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, - 0x4707 + 0x4707 }; u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, - 0x2300, + 0x2300, 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, - 0x4707 + 0x4707 }; u16 tbl_tx_iqlo_cal_startcoefs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000 + 0x0000 }; u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { @@ -23934,7 +24100,8 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, bcmerror = 0; } else { bcmerror = - wlc_phy_tx_tone_nphy(pi, tone_freq, max_val, 1, 0, false); + wlc_phy_tx_tone_nphy(pi, tone_freq, max_val, 1, 0, + false); } if (bcmerror == 0) { @@ -23958,14 +24125,12 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, if (NREV_GE(pi->pubpi.phy_rev, 3)) { tbl_ptr = tbl_tx_iqlo_cal_startcoefs_nphyrev3; - tbl_len = - ARRAY_SIZE - (tbl_tx_iqlo_cal_startcoefs_nphyrev3); + tbl_len = ARRAY_SIZE( + tbl_tx_iqlo_cal_startcoefs_nphyrev3); } else { tbl_ptr = tbl_tx_iqlo_cal_startcoefs; - tbl_len = - ARRAY_SIZE - (tbl_tx_iqlo_cal_startcoefs); + tbl_len = ARRAY_SIZE( + tbl_tx_iqlo_cal_startcoefs); } } } @@ -23974,12 +24139,14 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, if (fullcal) { max_cal_cmds = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3) : - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_fullcal); + ARRAY_SIZE( + tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3) : + ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_fullcal); } else { max_cal_cmds = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_recal_nphyrev3) : - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_recal); + ARRAY_SIZE( + tbl_tx_iqlo_cal_cmds_recal_nphyrev3) : + ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_recal); } if (mphase) { @@ -23997,13 +24164,14 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, if (fullcal) { cal_cmd = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3 - [cal_cnt] : - tbl_tx_iqlo_cal_cmds_fullcal[cal_cnt]; + tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3 + [cal_cnt] : + tbl_tx_iqlo_cal_cmds_fullcal[cal_cnt]; } else { cal_cmd = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - tbl_tx_iqlo_cal_cmds_recal_nphyrev3[cal_cnt] - : tbl_tx_iqlo_cal_cmds_recal[cal_cnt]; + tbl_tx_iqlo_cal_cmds_recal_nphyrev3[ + cal_cnt] + : tbl_tx_iqlo_cal_cmds_recal[cal_cnt]; } core_no = ((cal_cmd & 0x3000) >> 12); @@ -24014,15 +24182,16 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, PHY_IPA(pi) && (CHSPEC_IS2G(pi->radio_chanspec)))) { if (!ladder_updated[core_no]) { - wlc_phy_update_txcal_ladder_nphy(pi, - core_no); + wlc_phy_update_txcal_ladder_nphy( + pi, + core_no); ladder_updated[core_no] = true; } } val = - (cal_params[core_no]. - ncorr[cal_type] << 8) | NPHY_N_GCTL; + (cal_params[core_no]. + ncorr[cal_type] << 8) | NPHY_N_GCTL; write_phy_reg(pi, 0xc1, val); if ((cal_type == 1) || (cal_type == 3) @@ -24070,8 +24239,8 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, } mphase_cal_lastphase = - (NREV_LE(pi->pubpi.phy_rev, 2)) ? - MPHASE_CAL_STATE_TXPHASE4 : MPHASE_CAL_STATE_TXPHASE5; + (NREV_LE(pi->pubpi.phy_rev, 2)) ? + MPHASE_CAL_STATE_TXPHASE4 : MPHASE_CAL_STATE_TXPHASE5; if (!mphase || (pi->mphase_cal_phase_id == mphase_cal_lastphase)) { @@ -24233,14 +24402,17 @@ wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est, if ((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0) { for (core = 0; core < pi->pubpi.phy_corenum; core++) { est[core].i_pwr = - (read_phy_reg(pi, NPHY_IqestipwrAccHi(core)) << 16) - | read_phy_reg(pi, NPHY_IqestipwrAccLo(core)); + (read_phy_reg(pi, + NPHY_IqestipwrAccHi(core)) << 16) + | read_phy_reg(pi, NPHY_IqestipwrAccLo(core)); est[core].q_pwr = - (read_phy_reg(pi, NPHY_IqestqpwrAccHi(core)) << 16) - | read_phy_reg(pi, NPHY_IqestqpwrAccLo(core)); + (read_phy_reg(pi, + NPHY_IqestqpwrAccHi(core)) << 16) + | read_phy_reg(pi, NPHY_IqestqpwrAccLo(core)); est[core].iq_prod = - (read_phy_reg(pi, NPHY_IqestIqAccHi(core)) << 16) | - read_phy_reg(pi, NPHY_IqestIqAccLo(core)); + (read_phy_reg(pi, + NPHY_IqestIqAccHi(core)) << 16) | + read_phy_reg(pi, NPHY_IqestIqAccLo(core)); } } } @@ -24265,7 +24437,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(struct brcms_phy *pi, u8 core_mask) new_comp.a0 = new_comp.b0 = new_comp.a1 = new_comp.b1 = 0x0; wlc_phy_rx_iq_coeffs_nphy(pi, 1, &new_comp); - cal_try: +cal_try: wlc_phy_rx_iq_est_nphy(pi, est, 0x4000, 32, 0); new_comp = old_comp; @@ -24356,7 +24528,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(struct brcms_phy *pi, u8 core_mask) if (bcmerror != 0) { printk(KERN_DEBUG "%s: Failed, cnt = %d\n", __func__, - cal_retry); + cal_retry); if (cal_retry < CAL_RETRY_CNT) { cal_retry++; @@ -24379,121 +24551,125 @@ static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core) if (rx_core == PHY_CORE_0) { if (CHSPEC_IS5G(pi->radio_chanspec)) { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP); + read_radio_reg(pi, + RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN); + read_radio_reg(pi, + RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN); write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, - 0x3); + RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, + 0x3); write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, - 0xaf); + RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, + 0xaf); } else { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP); + read_radio_reg(pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN); + read_radio_reg(pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN); - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, - 0x3); - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, - 0x7f); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, + 0x3); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, + 0x7f); } } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP); + read_radio_reg(pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN); + read_radio_reg(pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN); - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, - 0x3); - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, - 0xaf); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, + 0x3); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, + 0xaf); } else { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP); + read_radio_reg(pi, + RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN); + read_radio_reg(pi, + RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN); write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, - 0x3); + RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, + 0x3); write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, - 0x7f); + RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, + 0x7f); } } } else { if (rx_core == PHY_CORE_0) { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_RXIQCAL_TXMUX | + RADIO_2056_TX1); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_RXIQCAL_RXMUX | + RADIO_2056_RX0); if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_RXSPARE2 | + RADIO_2056_RX0); pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1); + read_radio_reg(pi, + RADIO_2056_TX_TXSPARE2 | + RADIO_2056_TX1); } if (CHSPEC_IS5G(pi->radio_chanspec)) { if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_LNAA_MASTER + | RADIO_2056_RX0); + + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_MASTER + | RADIO_2056_RX0, 0x40); write_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0, 0x40); + RADIO_2056_TX_TXSPARE2 | + RADIO_2056_TX1, bias_a); write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1, bias_a); - - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0, bias_a); + RADIO_2056_RX_RXSPARE2 | + RADIO_2056_RX0, bias_a); } else { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX0); + read_radio_reg(pi, + RADIO_2056_RX_LNAA_TUNE + | RADIO_2056_RX0); offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & 0xF0) - >> 8; + (pi->tx_rx_cal_radio_saveregs + [2] & 0xF0) >> 8; offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; + (offtune_val <= 0x7) ? 0xF : 0; mod_radio_reg(pi, RADIO_2056_RX_LNAA_TUNE | @@ -24510,34 +24686,41 @@ static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core) } else { if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0); + read_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX0); - write_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0, 0x40); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX0, 0x40); - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1, bias_g); + write_radio_reg( + pi, + RADIO_2056_TX_TXSPARE2 + | + RADIO_2056_TX1, bias_g); - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0, bias_g); + write_radio_reg( + pi, + RADIO_2056_RX_RXSPARE2 + | + RADIO_2056_RX0, bias_g); } else { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX0); + read_radio_reg( + pi, + RADIO_2056_RX_LNAG_TUNE + | RADIO_2056_RX0); offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & 0xF0) - >> 8; + (pi-> + tx_rx_cal_radio_saveregs[2] & + 0xF0) >> 8; offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; + (offtune_val <= 0x7) ? 0xF : 0; mod_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | @@ -24555,56 +24738,63 @@ static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core) } else { pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_RXIQCAL_TXMUX | + RADIO_2056_TX0); pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX1); + read_radio_reg(pi, + RADIO_2056_RX_RXIQCAL_RXMUX | + RADIO_2056_RX1); if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX1); + read_radio_reg(pi, + RADIO_2056_RX_RXSPARE2 | + RADIO_2056_RX1); pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX0); + read_radio_reg(pi, + RADIO_2056_TX_TXSPARE2 | + RADIO_2056_TX0); } if (CHSPEC_IS5G(pi->radio_chanspec)) { if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX1); + read_radio_reg( + pi, + RADIO_2056_RX_LNAA_MASTER + | RADIO_2056_RX1); - write_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX1, 0x40); + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_MASTER | + RADIO_2056_RX1, 0x40); - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX0, bias_a); + write_radio_reg( + pi, + RADIO_2056_TX_TXSPARE2 + | + RADIO_2056_TX0, bias_a); - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX1, bias_a); + write_radio_reg( + pi, + RADIO_2056_RX_RXSPARE2 + | + RADIO_2056_RX1, bias_a); } else { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX1); + read_radio_reg( + pi, + RADIO_2056_RX_LNAA_TUNE + | RADIO_2056_RX1); offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & 0xF0) - >> 8; + (pi-> + tx_rx_cal_radio_saveregs[2] & + 0xF0) >> 8; offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; + (offtune_val <= 0x7) ? 0xF : 0; mod_radio_reg(pi, RADIO_2056_RX_LNAA_TUNE | @@ -24621,33 +24811,40 @@ static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core) } else { if (pi->pubpi.radiorev >= 5) { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1); + read_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX1); - write_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1, 0x40); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX1, 0x40); - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX0, bias_g); + write_radio_reg( + pi, + RADIO_2056_TX_TXSPARE2 + | + RADIO_2056_TX0, bias_g); - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX1, bias_g); + write_radio_reg( + pi, + RADIO_2056_RX_RXSPARE2 + | + RADIO_2056_RX1, bias_g); } else { pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX1); + read_radio_reg( + pi, + RADIO_2056_RX_LNAG_TUNE + | RADIO_2056_RX1); offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & 0xF0) - >> 8; + (pi-> + tx_rx_cal_radio_saveregs[2] & + 0xF0) >> 8; offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; + (offtune_val <= 0x7) ? 0xF : 0; mod_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | @@ -24671,46 +24868,54 @@ static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (rx_core == PHY_CORE_0) { if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, + pi-> + tx_rx_cal_radio_saveregs[0]); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, + pi-> + tx_rx_cal_radio_saveregs[1]); } else { - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, + pi-> + tx_rx_cal_radio_saveregs[0]); + write_radio_reg( + pi, + RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, + pi-> + tx_rx_cal_radio_saveregs[1]); } } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, + pi-> + tx_rx_cal_radio_saveregs[0]); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, + pi-> + tx_rx_cal_radio_saveregs[1]); } else { - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, + pi-> + tx_rx_cal_radio_saveregs[0]); + write_radio_reg( + pi, + RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, + pi-> + tx_rx_cal_radio_saveregs[1]); } } @@ -24742,34 +24947,38 @@ static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) if (CHSPEC_IS5G(pi->radio_chanspec)) { if (pi->pubpi.radiorev >= 5) - write_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_MASTER + | RADIO_2056_RX0, + pi-> + tx_rx_cal_radio_saveregs + [4]); else - write_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_TUNE + | RADIO_2056_RX0, + pi-> + tx_rx_cal_radio_saveregs + [4]); } else { if (pi->pubpi.radiorev >= 5) - write_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX0, + pi-> + tx_rx_cal_radio_saveregs + [4]); else - write_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_TUNE + | RADIO_2056_RX0, + pi-> + tx_rx_cal_radio_saveregs + [4]); } } else { @@ -24799,34 +25008,38 @@ static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) if (CHSPEC_IS5G(pi->radio_chanspec)) { if (pi->pubpi.radiorev >= 5) - write_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_MASTER + | RADIO_2056_RX1, + pi-> + tx_rx_cal_radio_saveregs + [4]); else - write_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAA_TUNE + | RADIO_2056_RX1, + pi-> + tx_rx_cal_radio_saveregs + [4]); } else { if (pi->pubpi.radiorev >= 5) - write_radio_reg(pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_MASTER + | RADIO_2056_RX1, + pi-> + tx_rx_cal_radio_saveregs + [4]); else - write_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); + write_radio_reg( + pi, + RADIO_2056_RX_LNAG_TUNE + | RADIO_2056_RX1, + pi-> + tx_rx_cal_radio_saveregs + [4]); } } } @@ -24844,9 +25057,9 @@ static void wlc_phy_rxcal_physetup_nphy(struct brcms_phy *pi, u8 rx_core) pi->tx_rx_cal_phy_saveregs[0] = read_phy_reg(pi, 0xa2); pi->tx_rx_cal_phy_saveregs[1] = - read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0xa6 : 0xa7); + read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0xa6 : 0xa7); pi->tx_rx_cal_phy_saveregs[2] = - read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x8f : 0xa5); + read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x8f : 0xa5); pi->tx_rx_cal_phy_saveregs[3] = read_phy_reg(pi, 0x91); pi->tx_rx_cal_phy_saveregs[4] = read_phy_reg(pi, 0x92); pi->tx_rx_cal_phy_saveregs[5] = read_phy_reg(pi, 0x7a); @@ -24912,15 +25125,17 @@ static void wlc_phy_rxcal_physetup_nphy(struct brcms_phy *pi, u8 rx_core) wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0, 0, NPHY_REV7_RFCTRLOVERRIDE_ID1); if (CHSPEC_IS40(pi->radio_chanspec)) - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 7), - 2, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 7), + 2, 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); else - wlc_phy_rfctrl_override_nphy_rev7(pi, - (0x1 << 7), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, + (0x1 << 7), + 0, 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, 0, @@ -24992,8 +25207,8 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, struct phy_iq_est est[PHY_CORE_MAX]; u8 tx_core; struct nphy_iq_comp save_comp, zero_comp; - u32 i_pwr, q_pwr, curr_pwr, optim_pwr = 0, prev_pwr = 0, thresh_pwr = - 10000; + u32 i_pwr, q_pwr, curr_pwr, optim_pwr = 0, prev_pwr = 0, + thresh_pwr = 10000; s16 desired_log2_pwr, actual_log2_pwr, delta_pwr; bool gainctrl_done = false; u8 mix_tia_gain = 3; @@ -25039,7 +25254,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, do { hpvga = (NREV_GE(pi->pubpi.phy_rev, 7)) ? - 0 : nphy_rxcal_gaintbl[curr_gaintbl_index].hpvga; + 0 : nphy_rxcal_gaintbl[curr_gaintbl_index].hpvga; lpf_biq1 = nphy_rxcal_gaintbl[curr_gaintbl_index].lpf_biq1; lpf_biq0 = nphy_rxcal_gaintbl[curr_gaintbl_index].lpf_biq0; lna2 = nphy_rxcal_gaintbl[curr_gaintbl_index].lna2; @@ -25047,13 +25262,13 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, txpwrindex = nphy_rxcal_gaintbl[curr_gaintbl_index].txpwrindex; if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - ((lpf_biq1 << 12) | - (lpf_biq0 << 8) | - (mix_tia_gain << - 4) | (lna2 << 2) - | lna1), 0x3, 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_rxgain, + ((lpf_biq1 << 12) | + (lpf_biq0 << 8) | + (mix_tia_gain << 4) | (lna2 << 2) + | lna1), 0x3, 0); else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), ((hpvga << 12) | @@ -25155,22 +25370,23 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, else lpf_biq1 = (u16) max(fine_gain_idx, 0); - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - ((lpf_biq1 << 12) | - (lpf_biq0 << 8) | - (mix_tia_gain << 4) | - (lna2 << 2) | lna1), 0x3, - 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_rxgain, + ((lpf_biq1 << 12) | + (lpf_biq0 << 8) | + (mix_tia_gain << 4) | + (lna2 << 2) | lna1), 0x3, + 0); } else { hpvga = (u16) max(min(((int)hpvga) + delta_pwr, 10), 0); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), - ((hpvga << 12) | (lpf_biq1 << 10) | - (lpf_biq0 << 8) | (mix_tia_gain << - 4) | (lna2 << - 2) | + ((hpvga << 12) | + (lpf_biq1 << 10) | + (lpf_biq0 << 8) | + (mix_tia_gain << 4) | + (lna2 << 2) | lna1), 0x3, 0); - } if (rxgain != NULL) { @@ -25247,20 +25463,21 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) if (core_idx == 0) { radio_addr_offset_rx = RADIO_2056_RX0; radio_addr_offset_tx = - (loopback_type == 0) ? RADIO_2056_TX0 : RADIO_2056_TX1; + (loopback_type == 0) ? RADIO_2056_TX0 : RADIO_2056_TX1; } else { radio_addr_offset_rx = RADIO_2056_RX1; radio_addr_offset_tx = - (loopback_type == 0) ? RADIO_2056_TX1 : RADIO_2056_TX0; + (loopback_type == 0) ? RADIO_2056_TX1 : RADIO_2056_TX0; } orig_txlpf_rccal_lpc_ovr_val = - read_radio_reg(pi, - (RADIO_2056_TX_TXLPF_RCCAL | radio_addr_offset_tx)); + read_radio_reg(pi, + (RADIO_2056_TX_TXLPF_RCCAL | + radio_addr_offset_tx)); orig_rxlpf_rccal_hpc_ovr_val = - read_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_HPC | - radio_addr_offset_rx)); + read_radio_reg(pi, + (RADIO_2056_RX_RXLPF_RCCAL_HPC | + radio_addr_offset_rx)); orig_dcBypass = ((read_phy_reg(pi, 0x48) >> 8) & 1); @@ -25333,14 +25550,16 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) if (core_idx == 0) ref_iq_vals = - max_t(u32, (est[0].i_pwr + - est[0].q_pwr) >> (log_num_samps + 1), - 1); + max_t(u32, (est[0].i_pwr + + est[0].q_pwr) >> + (log_num_samps + 1), + 1); else ref_iq_vals = - max_t(u32, (est[1].i_pwr + - est[1].q_pwr) >> (log_num_samps + 1), - 1); + max_t(u32, (est[1].i_pwr + + est[1].q_pwr) >> + (log_num_samps + 1), + 1); wlc_phy_tx_tone_nphy(pi, target_bw, NPHY_RXCAL_TONEAMP, 0, 1, false); @@ -25350,13 +25569,12 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); if (core_idx == 0) - target_iq_vals = - (est[0].i_pwr + est[0].q_pwr) >> (log_num_samps + - 1); + target_iq_vals = (est[0].i_pwr + est[0].q_pwr) >> + (log_num_samps + 1); else target_iq_vals = - (est[1].i_pwr + est[1].q_pwr) >> (log_num_samps + - 1); + (est[1].i_pwr + + est[1].q_pwr) >> (log_num_samps + 1); pwr_ratio = (uint) ((target_iq_vals << 16) / ref_iq_vals); @@ -25375,10 +25593,11 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) if (rccal_stepsize == -1) { best_rccal_val = - (ABS((int)last_pwr_ratio - (int)target_pwr_ratio) < - ABS((int)pwr_ratio - - (int)target_pwr_ratio)) ? last_rccal_val : - rccal_val; + (ABS((int)last_pwr_ratio - + (int)target_pwr_ratio) < + ABS((int)pwr_ratio - + (int)target_pwr_ratio)) ? last_rccal_val : + rccal_val; if (CHSPEC_IS40(pi->radio_chanspec)) { if ((best_rccal_val > 140) @@ -25428,7 +25647,7 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) return best_rccal_val - 0x80; } -#define WAIT_FOR_SCOPE 4000 +#define WAIT_FOR_SCOPE 4000 static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, struct nphy_txgains target_gain, u8 cal_type, bool debug) @@ -25466,12 +25685,12 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, cal_gain); rxcore_state = wlc_phy_rxcore_getstate_nphy( - (struct brcms_phy_pub *) pi); + (struct brcms_phy_pub *) pi); for (rx_core = 0; rx_core < pi->pubpi.phy_corenum; rx_core++) { skip_rxiqcal = - ((rxcore_state & (1 << rx_core)) == 0) ? true : false; + ((rxcore_state & (1 << rx_core)) == 0) ? true : false; wlc_phy_rxcal_physetup_nphy(pi, rx_core); @@ -25482,7 +25701,8 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, wlc_phy_rxcal_gainctrl_nphy(pi, rx_core, NULL, 0); wlc_phy_tx_tone_nphy(pi, - (CHSPEC_IS40(pi->radio_chanspec)) ? + (CHSPEC_IS40( + pi->radio_chanspec)) ? NPHY_RXCAL_TONEFREQ_40MHz : NPHY_RXCAL_TONEFREQ_20MHz, NPHY_RXCAL_TONEAMP, 0, cal_type, @@ -25508,7 +25728,7 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, 1); best_rccal[rx_core] = - wlc_phy_rc_sweep_nphy(pi, rx_core, 1); + wlc_phy_rc_sweep_nphy(pi, rx_core, 1); pi->nphy_rccal_value = best_rccal[rx_core]; if (rxcore_state == 1) @@ -25533,7 +25753,7 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, for (rx_core = 0; rx_core < pi->pubpi.phy_corenum; rx_core++) { rxlpf_rccal_hpc = - (((int)best_rccal[rx_core] - 12) >> 1) + 10; + (((int)best_rccal[rx_core] - 12) >> 1) + 10; txlpf_rccal_lpc = ((int)best_rccal[rx_core] - 12) + 10; if (PHY_IPA(pi)) { @@ -25543,8 +25763,10 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, TXLPF_IDAC_4, txlpf_idac); } - rxlpf_rccal_hpc = max(min_t(u8, rxlpf_rccal_hpc, 31), 0); - txlpf_rccal_lpc = max(min_t(u8, txlpf_rccal_lpc, 31), 0); + rxlpf_rccal_hpc = max(min_t(u8, rxlpf_rccal_hpc, 31), + 0); + txlpf_rccal_lpc = max(min_t(u8, txlpf_rccal_lpc, 31), + 0); write_radio_reg(pi, (RADIO_2056_RX_RXLPF_RCCAL_HPC | ((rx_core == @@ -25565,9 +25787,10 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, wlc_phy_resetcca_nphy(pi); if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - 0, 0x3, 1); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_rxgain, + 0, 0x3, 1); else wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); @@ -25651,13 +25874,13 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, if (((pi->nphy_rxcalparams) & 0xff000000)) write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x91 : 0x92, - (CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : - 0x110)); + (CHSPEC_IS5G(pi->radio_chanspec) ? + 0x140 : 0x110)); else write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x91 : 0x92, - (CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : - 0x120)); + (CHSPEC_IS5G(pi->radio_chanspec) ? + 0x180 : 0x120)); write_phy_reg(pi, (tx_core == PHY_CORE_0) ? 0x91 : 0x92, (CHSPEC_IS5G(pi->radio_chanspec) ? 0x148 : @@ -25697,7 +25920,7 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, use_hpf_num = 1; curr_hpf = curr_hpf1; actual_log2_pwr = - wlc_phy_nbits(tot_pwr[2]); + wlc_phy_nbits(tot_pwr[2]); } else { if (tot_pwr[0] > 10000) { curr_lna = lna_vals[1]; @@ -25706,7 +25929,8 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, use_hpf_num = 1; curr_hpf = curr_hpf1; actual_log2_pwr = - wlc_phy_nbits(tot_pwr[1]); + wlc_phy_nbits( + tot_pwr[1]); } else { curr_lna = lna_vals[0]; curr_hpf1 = hpf1_vals[0]; @@ -25714,7 +25938,8 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, use_hpf_num = 2; curr_hpf = curr_hpf2; actual_log2_pwr = - wlc_phy_nbits(tot_pwr[0]); + wlc_phy_nbits( + tot_pwr[0]); } } @@ -25737,15 +25962,12 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, if (first_playtone) { bcmerror = wlc_phy_tx_tone_nphy(pi, 4000, - (u16) (pi-> - nphy_rxcalparams - & - 0xffff), - 0, 0, true); + (u16) (pi->nphy_rxcalparams & + 0xffff), 0, 0, true); first_playtone = false; } else { - phy_bw = - (CHSPEC_IS40(pi->radio_chanspec)) ? 40 : 20; + phy_bw = (CHSPEC_IS40(pi->radio_chanspec)) ? + 40 : 20; wlc_phy_runsamples_nphy(pi, phy_bw * 8, 0xffff, 0, 0, 0, true); } @@ -25756,12 +25978,10 @@ wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - i_pwr = - (est[rx_core].i_pwr + - num_samps / 2) / num_samps; - q_pwr = - (est[rx_core].q_pwr + - num_samps / 2) / num_samps; + i_pwr = (est[rx_core].i_pwr + + num_samps / 2) / num_samps; + q_pwr = (est[rx_core].q_pwr + + num_samps / 2) / num_samps; tot_pwr[gain_pass] = i_pwr + q_pwr; } else { @@ -25847,15 +26067,13 @@ static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) if (CHSPEC_IS5G(pi->radio_chanspec)) { for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[5] - [j]); + NPHY_IPA_REV4_txdigi_filtcoeffs[5][j]); } if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x2c5 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[6] - [j]); + NPHY_IPA_REV4_txdigi_filtcoeffs[6][j]); } } } @@ -25901,17 +26119,17 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev4n6; + nphy_tpc_txgain_ipa_2g_2057rev4n6; else if (pi->pubpi.radiorev == 3) tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev3; + nphy_tpc_txgain_ipa_2g_2057rev3; else if (pi->pubpi.radiorev == 5) tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev5; + nphy_tpc_txgain_ipa_2g_2057rev5; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) + || (pi->pubpi.radiorev == 8)) tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev7; + nphy_tpc_txgain_ipa_2g_2057rev7; } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev6; } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { @@ -25927,9 +26145,9 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) (pi->pubpi.radiorev == 6)) tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) + || (pi->pubpi.radiorev == 8)) tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_5g_2057rev7; + nphy_tpc_txgain_ipa_5g_2057rev7; } else { tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g; } @@ -25951,27 +26169,29 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), + wlc_phy_read_lpf_bw_ctl_nphy + (pi, + 0), 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); if (CHSPEC_IS2G(pi->radio_chanspec)) { if (pi->pubpi.radiorev == 5) mixgain = (core == 0) ? 0x20 : 0x00; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) + || (pi->pubpi.radiorev == 8)) mixgain = 0x00; else if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) + || (pi->pubpi.radiorev == 6)) mixgain = 0x00; } else { if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) mixgain = 0x50; else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) mixgain = 0x0; } @@ -25979,12 +26199,14 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, mixgain, (1 << core), 0, NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 1, (1 << core), 0); - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 0, (1 << off_core), 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_tx_pu, + 1, (1 << core), 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_tx_pu, + 0, (1 << off_core), 0); wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 0, 0x3, 0, @@ -26021,11 +26243,11 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa6 : 0xa7); state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); + read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); state->afectrl[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa7 : 0xa6); + read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa7 : 0xa6); state->afeoverride[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa5 : 0x8f); + read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa5 : 0x8f); mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), (0x1 << 2), 0); @@ -26039,17 +26261,17 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, if (CHSPEC_IS2G(pi->radio_chanspec)) { state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_PWRUP); state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN); state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_PWRUP); + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_PWRUP); state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_ATTEN); + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_ATTEN); WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_2G_PWRUP, 0xc); @@ -26064,7 +26286,7 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, TXRXCOUPLE_2G_ATTEN, (core == 0) ? 0xf7 : 0xf2); else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) + || (pi->pubpi.radiorev == 8)) WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_2G_ATTEN, 0xf0); @@ -26074,17 +26296,17 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, TXRXCOUPLE_2G_ATTEN, 0xff); } else { state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_PWRUP); state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN); + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_ATTEN); state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_PWRUP); + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_PWRUP); state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_ATTEN); + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_ATTEN); WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TXRXCOUPLE_5G_PWRUP, 0xc); @@ -26134,7 +26356,7 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa6 : 0xa7); state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); + read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), (0x1 << 0) | (0x1 << 1) | (0x1 << 2), 0); @@ -26145,15 +26367,15 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, (0x1 << 2), (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); state->vga_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER); + READ_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER); WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, 0x2b); if (CHSPEC_IS2G(pi->radio_chanspec)) { state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_G); + READ_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_G); state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER); + READ_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAG_MASTER); WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_G, 0x03); @@ -26161,11 +26383,11 @@ wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, INTPAG_MASTER, 0x04); } else { state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_A); + READ_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_A); state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER); + READ_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAA_MASTER); WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_A, 0x03); @@ -26216,13 +26438,15 @@ wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, } if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); else - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 0, 0x3, 1, @@ -26271,9 +26495,10 @@ wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), 0, 0, - 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), 0, 0, + 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); } else { wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 0x3, 1); @@ -26339,7 +26564,8 @@ wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32 start, s32 phy_a3, phy_a4, phy_a5, phy_a6, phy_a7; phy_a1 = end - min(end, (winsz >> 1)); - phy_a2 = min_t(u32, NPHY_PAPD_EPS_TBL_SIZE - 1, end + (winsz >> 1)); + phy_a2 = min_t(u32, NPHY_PAPD_EPS_TBL_SIZE - 1, + end + (winsz >> 1)); phy_a3 = phy_a2 - phy_a1 + 1; phy_a6 = 0; phy_a7 = 0; @@ -26399,9 +26625,10 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, (txgains->gains.pga[core] << 8) | (phy_a9.pad[core] << 3) | (phy_a9.ipa[core])); - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_txgain, + phy_a5, (1 << core), 0); if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((pi->pubpi.radiorev <= 4) @@ -26444,8 +26671,8 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, && (CHSPEC_IS2G(pi->radio_chanspec))) phy_a1 = 55; else if (((pi->pubpi.radiorev == 7) && - (CHSPEC_IS2G(pi->radio_chanspec))) || - ((pi->pubpi.radiorev == 8) && + (CHSPEC_IS2G(pi->radio_chanspec))) || + ((pi->pubpi.radiorev == 8) && (CHSPEC_IS2G(pi->radio_chanspec)))) phy_a1 = 60; else @@ -26514,9 +26741,10 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, wlc_phy_a1_nphy(pi, core, 5, 0, 35); } - wlc_phy_rfctrl_override_1tomany_nphy(pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 1); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_txgain, + phy_a5, (1 << core), 1); } else { @@ -26528,7 +26756,7 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, phy_a5 = 0x00f7 | (phy_a4 << 8); else - if (NREV_IS(pi->pubpi.phy_rev, 5)) + if (NREV_IS(pi->pubpi.phy_rev, 5)) phy_a5 = 0x10f7 | (phy_a4 << 8); else phy_a5 = 0x50f7 | (phy_a4 << 8); @@ -26674,28 +26902,33 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) if (pi->pubpi.radiorev == 5) { phy_a15 = pad_gain_codes_used_2057rev5; - phy_a13 = sizeof(pad_gain_codes_used_2057rev5) / - sizeof(pad_gain_codes_used_2057rev5[0]) - 1; + phy_a13 = + sizeof(pad_gain_codes_used_2057rev5) / + sizeof(pad_gain_codes_used_2057rev5 + [0]) - 1; } else if ((pi->pubpi.radiorev == 7) || (pi->pubpi.radiorev == 8)) { phy_a15 = pad_gain_codes_used_2057rev7; - phy_a13 = sizeof(pad_gain_codes_used_2057rev7) / - sizeof(pad_gain_codes_used_2057rev7[0]) - 1; + phy_a13 = + sizeof(pad_gain_codes_used_2057rev7) / + sizeof(pad_gain_codes_used_2057rev7 + [0]) - 1; } else { phy_a15 = pad_all_gain_codes_2057; phy_a13 = sizeof(pad_all_gain_codes_2057) / - sizeof(pad_all_gain_codes_2057[0]) - 1; + sizeof(pad_all_gain_codes_2057[0]) - + 1; } } else { phy_a15 = pga_all_gain_codes_2057; phy_a13 = sizeof(pga_all_gain_codes_2057) / - sizeof(pga_all_gain_codes_2057[0]) - 1; + sizeof(pga_all_gain_codes_2057[0]) - 1; } phy_a14 = 0; @@ -26703,10 +26936,10 @@ static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { if (CHSPEC_IS2G(pi->radio_chanspec)) phy_a4.gains.pad[core] = - (u16) phy_a15[phy_a12]; + (u16) phy_a15[phy_a12]; else phy_a4.gains.pga[core] = - (u16) phy_a15[phy_a12]; + (u16) phy_a15[phy_a12]; wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); @@ -26824,8 +27057,7 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if (pi->nphy_papd_skip == 1) return; - phy_b3 = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!phy_b3) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -26835,7 +27067,7 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) pi->nphy_papd_tx_gain_at_last_cal[phy_b5] = - wlc_phy_txpwr_idx_cur_get_nphy(pi, phy_b5); + wlc_phy_txpwr_idx_cur_get_nphy(pi, phy_b5); pi->nphy_papd_last_cal = pi->sh->now; pi->nphy_papd_recal_counter++; @@ -26877,50 +27109,56 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { pi->nphy_papd_cal_gain_index[phy_b5] = - 23; + 23; } else if (pi->pubpi.radiorev == 5) { pi->nphy_papd_cal_gain_index[phy_b5] = - 0; + 0; pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy(pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], phy_b5); + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], + phy_b5); } else if ((pi->pubpi.radiorev == 7) || (pi->pubpi.radiorev == 8)) { pi->nphy_papd_cal_gain_index[phy_b5] = - 0; + 0; pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy(pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], phy_b5); + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], + phy_b5); } phy_b1[phy_b5].gains.pad[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; + pi->nphy_papd_cal_gain_index[phy_b5]; } else { pi->nphy_papd_cal_gain_index[phy_b5] = 0; pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy(pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], phy_b5); + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], phy_b5); phy_b1[phy_b5].gains.pga[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; + pi->nphy_papd_cal_gain_index[phy_b5]; } } else { phy_b1[phy_b5].useindex = true; phy_b1[phy_b5].index = 16; phy_b1[phy_b5].index = - wlc_phy_a3_nphy(pi, phy_b1[phy_b5].index, phy_b5); + wlc_phy_a3_nphy(pi, phy_b1[phy_b5].index, + phy_b5); pi->nphy_papd_cal_gain_index[phy_b5] = - 15 - ((phy_b1[phy_b5].index) >> 3); + 15 - ((phy_b1[phy_b5].index) >> 3); } switch (pi->nphy_papd_cal_type) { @@ -26960,23 +27198,19 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) { - phy_b12 = - - - (nphy_papd_padgain_dlt_2g_2057rev3n4 - [phy_b8] - + 1) / 2; + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev3n4 + [phy_b8] + 1) / 2; phy_b10 = -1; } else if (pi->pubpi.radiorev == 5) { - phy_b12 = - -(nphy_papd_padgain_dlt_2g_2057rev5 - [phy_b8] - + 1) / 2; + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev5 + [phy_b8] + 1) / 2; } else if ((pi->pubpi.radiorev == 7) || (pi->pubpi.radiorev == 8)) { - phy_b12 = - -(nphy_papd_padgain_dlt_2g_2057rev7 - [phy_b8] - + 1) / 2; + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev7 + [phy_b8] + 1) / 2; } } else { phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5]; @@ -26984,25 +27218,26 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) (pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) phy_b11 = - -(nphy_papd_pgagain_dlt_5g_2057 - [phy_b7] - + 1) / 2; + -(nphy_papd_pgagain_dlt_5g_2057 + [phy_b7] + + 1) / 2; else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - phy_b11 = - -(nphy_papd_pgagain_dlt_5g_2057rev7 - [phy_b7] - + 1) / 2; + || (pi->pubpi.radiorev == 8)) + phy_b11 = -( + nphy_papd_pgagain_dlt_5g_2057rev7 + [phy_b7] + 1) / 2; phy_b10 = -9; } if (CHSPEC_IS2G(pi->radio_chanspec)) phy_b6 = - -60 + 27 + eps_offset + phy_b12 + phy_b10; + -60 + 27 + eps_offset + phy_b12 + + phy_b10; else phy_b6 = - -60 + 27 + eps_offset + phy_b11 + phy_b10; + -60 + 27 + eps_offset + phy_b11 + + phy_b10; mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : 0x29c, (0x1ff << 7), (phy_b6) << 7); @@ -27018,13 +27253,15 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if (CHSPEC_IS2G(pi->radio_chanspec)) { phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_2g[phy_b7] + - 1) / 2; + -(nphy_papd_pga_gain_delta_ipa_2g[ + phy_b7] + + 1) / 2; phy_b10 = 0; } else { phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_5g[phy_b7] + - 1) / 2; + -(nphy_papd_pga_gain_delta_ipa_5g[ + phy_b7] + + 1) / 2; phy_b10 = -9; } @@ -27068,10 +27305,10 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if (phy_b4 == PHY_TPC_HW_OFF) { wlc_phy_txpwr_index_nphy(pi, (1 << 0), (s8) (pi->nphy_txpwrindex[0]. - index_internal), false); + index_internal), false); wlc_phy_txpwr_index_nphy(pi, (1 << 1), (s8) (pi->nphy_txpwrindex[1]. - index_internal), false); + index_internal), false); } wlc_phy_stay_in_carriersearch_nphy(pi, false); @@ -27142,37 +27379,36 @@ void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) if (NREV_GE(phyrev, 3)) { if (PHY_IPA(pi)) { u32 *tx_gaintbl = - wlc_phy_get_ipa_gaintbl_nphy(pi); + wlc_phy_get_ipa_gaintbl_nphy(pi); txgain = tx_gaintbl[txpi[core]]; } else { if (CHSPEC_IS5G(pi->radio_chanspec)) { if (NREV_IS(phyrev, 3)) { txgain = - nphy_tpc_5GHz_txgain_rev3 - [txpi[core]]; + nphy_tpc_5GHz_txgain_rev3 + [txpi[core]]; } else if (NREV_IS(phyrev, 4)) { - txgain = - (pi->srom_fem5g.extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA - [txpi[core]] : - nphy_tpc_5GHz_txgain_rev4 - [txpi[core]]; + txgain = ( + pi->srom_fem5g.extpagain == + 3) ? + nphy_tpc_5GHz_txgain_HiPwrEPA + [txpi[core]] : + nphy_tpc_5GHz_txgain_rev4 + [txpi[core]]; } else { txgain = - nphy_tpc_5GHz_txgain_rev5 - [txpi[core]]; + nphy_tpc_5GHz_txgain_rev5 + [txpi[core]]; } } else { if (NREV_GE(phyrev, 5) && (pi->srom_fem2g.extpagain == 3)) { txgain = - nphy_tpc_txgain_HiPwrEPA - [txpi[core]]; + nphy_tpc_txgain_HiPwrEPA + [txpi[core]]; } else { - txgain = - nphy_tpc_txgain_rev3[txpi - [core]]; + txgain = nphy_tpc_txgain_rev3 + [txpi[core]]; } } } @@ -27297,7 +27533,8 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) u16 pwr_offsets1[2], *pwr_offsets2 = NULL; u8 *tx_srom_max_rate = NULL; - for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); band_num++) { + for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); + band_num++) { switch (band_num) { case 0: @@ -27313,7 +27550,7 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) pwr_offsets1[0] = (u16) (pi->ofdm2gpo & 0xffff); pwr_offsets1[1] = - (u16) (pi->ofdm2gpo >> 16) & 0xffff; + (u16) (pi->ofdm2gpo >> 16) & 0xffff; pwr_offsets2 = pi->mcs2gpo; @@ -27330,7 +27567,7 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) pwr_offsets1[0] = (u16) (pi->ofdm5gpo & 0xffff); pwr_offsets1[1] = - (u16) (pi->ofdm5gpo >> 16) & 0xffff; + (u16) (pi->ofdm5gpo >> 16) & 0xffff; pwr_offsets2 = pi->mcs5gpo; @@ -27347,7 +27584,7 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) pwr_offsets1[0] = (u16) (pi->ofdm5glpo & 0xffff); pwr_offsets1[1] = - (u16) (pi->ofdm5glpo >> 16) & 0xffff; + (u16) (pi->ofdm5glpo >> 16) & 0xffff; pwr_offsets2 = pi->mcs5glpo; @@ -27364,7 +27601,7 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) pwr_offsets1[0] = (u16) (pi->ofdm5ghpo & 0xffff); pwr_offsets1[1] = - (u16) (pi->ofdm5ghpo >> 16) & 0xffff; + (u16) (pi->ofdm5ghpo >> 16) & 0xffff; pwr_offsets2 = pi->mcs5ghpo; @@ -27463,10 +27700,11 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) } else { for (rate1 = TXP_FIRST_OFDM_40_SISO, rate2 = - TXP_FIRST_OFDM; rate1 <= TXP_LAST_MCS_40_SDM; + TXP_FIRST_OFDM; + rate1 <= TXP_LAST_MCS_40_SDM; rate1++, rate2++) tx_srom_max_rate[rate1] = - tx_srom_max_rate[rate2]; + tx_srom_max_rate[rate2]; } if (NREV_GE(pi->pubpi.phy_rev, 3)) @@ -27476,7 +27714,7 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) TXP_LAST_MCS_40_SDM); tx_srom_max_rate[TXP_MCS_32] = - tx_srom_max_rate[TXP_FIRST_MCS_40_CDD]; + tx_srom_max_rate[TXP_FIRST_MCS_40_CDD]; } return; @@ -27514,34 +27752,35 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; pi->bwdup5ghpo = (bwduppo & 0xf000) >> 12; - for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); band_num++) { + for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); + band_num++) { switch (band_num) { case 0: pi->nphy_txpid2g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid2ga0"); + (u8) PHY_GETINTVAR(pi, "txpid2ga0"); pi->nphy_txpid2g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid2ga1"); + (u8) PHY_GETINTVAR(pi, "txpid2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga0"); + (s8) PHY_GETINTVAR(pi, "maxp2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga1"); + (s8) PHY_GETINTVAR(pi, "maxp2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a0"); + (s16) PHY_GETINTVAR(pi, "pa2gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a1"); + (s16) PHY_GETINTVAR(pi, "pa2gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a0"); + (s16) PHY_GETINTVAR(pi, "pa2gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a1"); + (s16) PHY_GETINTVAR(pi, "pa2gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a0"); + (s16) PHY_GETINTVAR(pi, "pa2gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a1"); + (s16) PHY_GETINTVAR(pi, "pa2gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga0"); + (s8) PHY_GETINTVAR(pi, "itt2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga1"); + (s8) PHY_GETINTVAR(pi, "itt2ga1"); pi->cck2gpo = (u16) PHY_GETINTVAR(pi, "cck2gpo"); @@ -27559,29 +27798,29 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) case 1: pi->nphy_txpid5g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid5ga0"); + (u8) PHY_GETINTVAR(pi, "txpid5ga0"); pi->nphy_txpid5g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid5ga1"); + (u8) PHY_GETINTVAR(pi, "txpid5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga0"); + (s8) PHY_GETINTVAR(pi, "maxp5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga1"); + (s8) PHY_GETINTVAR(pi, "maxp5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a0"); + (s16) PHY_GETINTVAR(pi, "pa5gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a1"); + (s16) PHY_GETINTVAR(pi, "pa5gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a0"); + (s16) PHY_GETINTVAR(pi, "pa5gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a1"); + (s16) PHY_GETINTVAR(pi, "pa5gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a0"); + (s16) PHY_GETINTVAR(pi, "pa5gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a1"); + (s16) PHY_GETINTVAR(pi, "pa5gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga0"); + (s8) PHY_GETINTVAR(pi, "itt5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga1"); + (s8) PHY_GETINTVAR(pi, "itt5ga1"); pi->ofdm5gpo = (u32) PHY_GETINTVAR(pi, "ofdm5gpo"); @@ -27597,90 +27836,90 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) case 2: pi->nphy_txpid5gl[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gla0"); + (u8) PHY_GETINTVAR(pi, "txpid5gla0"); pi->nphy_txpid5gl[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gla1"); + (u8) PHY_GETINTVAR(pi, "txpid5gla1"); pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla0"); + (s8) PHY_GETINTVAR(pi, "maxp5gla0"); pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla1"); + (s8) PHY_GETINTVAR(pi, "maxp5gla1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a0"); + (s16) PHY_GETINTVAR(pi, "pa5glw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a1"); + (s16) PHY_GETINTVAR(pi, "pa5glw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a0"); + (s16) PHY_GETINTVAR(pi, "pa5glw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a1"); + (s16) PHY_GETINTVAR(pi, "pa5glw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a0"); + (s16) PHY_GETINTVAR(pi, "pa5glw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a1"); + (s16) PHY_GETINTVAR(pi, "pa5glw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; pi->ofdm5glpo = (u32) PHY_GETINTVAR(pi, "ofdm5glpo"); pi->mcs5glpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo0"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo0"); pi->mcs5glpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo1"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo1"); pi->mcs5glpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo2"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo2"); pi->mcs5glpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo3"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo3"); pi->mcs5glpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo4"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo4"); pi->mcs5glpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo5"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo5"); pi->mcs5glpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo6"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo6"); pi->mcs5glpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo7"); + (u16) PHY_GETINTVAR(pi, "mcs5glpo7"); break; case 3: pi->nphy_txpid5gh[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gha0"); + (u8) PHY_GETINTVAR(pi, "txpid5gha0"); pi->nphy_txpid5gh[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gha1"); + (u8) PHY_GETINTVAR(pi, "txpid5gha1"); pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha0"); + (s8) PHY_GETINTVAR(pi, "maxp5gha0"); pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha1"); + (s8) PHY_GETINTVAR(pi, "maxp5gha1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a0"); + (s16) PHY_GETINTVAR(pi, "pa5ghw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a1"); + (s16) PHY_GETINTVAR(pi, "pa5ghw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a0"); + (s16) PHY_GETINTVAR(pi, "pa5ghw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a1"); + (s16) PHY_GETINTVAR(pi, "pa5ghw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a0"); + (s16) PHY_GETINTVAR(pi, "pa5ghw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a1"); + (s16) PHY_GETINTVAR(pi, "pa5ghw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; pi->ofdm5ghpo = (u32) PHY_GETINTVAR(pi, "ofdm5ghpo"); pi->mcs5ghpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo0"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo0"); pi->mcs5ghpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo1"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo1"); pi->mcs5ghpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo2"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo2"); pi->mcs5ghpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo3"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo3"); pi->mcs5ghpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo4"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo4"); pi->mcs5ghpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo5"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo5"); pi->mcs5ghpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo6"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo6"); pi->mcs5ghpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo7"); + (u16) PHY_GETINTVAR(pi, "mcs5ghpo7"); break; } } @@ -27707,10 +27946,10 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) pi->srom_fem5g.triso = (u8) PHY_GETINTVAR(pi, "triso5g"); if (PHY_GETVAR(pi, "antswctl5g")) pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl5g"); + (u8) PHY_GETINTVAR(pi, "antswctl5g"); else pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl2g"); + (u8) PHY_GETINTVAR(pi, "antswctl2g"); wlc_phy_txpower_ipa_upd(pi); @@ -27731,7 +27970,7 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) } pi->phy_txcore_enable_temp = - pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; + pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; pi->phycal_tempdelta = (u8) PHY_GETINTVAR(pi, "phycal_tempdelta"); if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) @@ -27782,11 +28021,11 @@ static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { iqcomp = - (tbl_id == - 26) ? (((u32) (iqloCalbuf[0] & 0x3ff)) << 10) | - (iqloCalbuf[1] & 0x3ff) - : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | - (iqloCalbuf[3] & 0x3ff); + (tbl_id == + 26) ? (((u32) (iqloCalbuf[0] & 0x3ff)) << 10) | + (iqloCalbuf[1] & 0x3ff) + : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | + (iqloCalbuf[3] & 0x3ff); for (idx = 0; idx < tbl_len; idx++) regval[idx] = iqcomp; @@ -27799,7 +28038,7 @@ static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { locomp = - (u32) ((tbl_id == 26) ? iqloCalbuf[5] : iqloCalbuf[6]); + (u32) ((tbl_id == 26) ? iqloCalbuf[5] : iqloCalbuf[6]); locomp_i = (s8) ((locomp >> 8) & 0xff); locomp_q = (s8) ((locomp) & 0xff); for (idx = 0; idx < tbl_len; idx++) { @@ -27808,11 +28047,12 @@ static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) curr_locomp_q = locomp_q; } else { curr_locomp_i = (s8) ((locomp_i * - nphy_tpc_loscale[idx] + - 128) >> 8); + nphy_tpc_loscale[idx] + + 128) >> 8); curr_locomp_q = - (s8) ((locomp_q * nphy_tpc_loscale[idx] + - 128) >> 8); + (s8) ((locomp_q * + nphy_tpc_loscale[idx] + + 128) >> 8); } curr_locomp = (u32) ((curr_locomp_i & 0xff) << 8); curr_locomp |= (u32) (curr_locomp_q & 0xff); @@ -27959,8 +28199,8 @@ static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) udelay(20); int_val = - wlc_phy_poll_rssi_nphy(pi, (u8) NPHY_RSSI_SEL_TSSI_2G, rssi_buf, - 1); + wlc_phy_poll_rssi_nphy(pi, (u8) NPHY_RSSI_SEL_TSSI_2G, rssi_buf, + 1); wlc_phy_stopplayback_nphy(pi); wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, 0); @@ -27974,25 +28214,25 @@ static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) if (NREV_GE(pi->pubpi.phy_rev, 3)) { pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); + (u8) ((int_val >> 24) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 24) & 0xff); + (u8) ((int_val >> 24) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); + (u8) ((int_val >> 8) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val >> 8) & 0xff); + (u8) ((int_val >> 8) & 0xff); } else { pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); + (u8) ((int_val >> 24) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); + (u8) ((int_val >> 8) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 16) & 0xff); + (u8) ((int_val >> 16) & 0xff); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val) & 0xff); + (u8) ((int_val) & 0xff); } } @@ -28047,9 +28287,9 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_2g; + pi->nphy_pwrctrl_info[0].max_pwr_2g; target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_2g; + pi->nphy_pwrctrl_info[1].max_pwr_2g; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b0; @@ -28061,9 +28301,9 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gl; + pi->nphy_pwrctrl_info[0].max_pwr_5gl; target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gl; + pi->nphy_pwrctrl_info[1].max_pwr_5gl; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0; @@ -28075,9 +28315,9 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gm; + pi->nphy_pwrctrl_info[0].max_pwr_5gm; target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gm; + pi->nphy_pwrctrl_info[1].max_pwr_5gm; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b0; @@ -28089,9 +28329,9 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gh; + pi->nphy_pwrctrl_info[0].max_pwr_5gh; target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gh; + pi->nphy_pwrctrl_info[1].max_pwr_5gh; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0; @@ -28142,14 +28382,14 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | RADIO_2056_TX0, (CHSPEC_IS5G - (pi-> - radio_chanspec)) ? 0xc : 0xe); + (pi->radio_chanspec)) ? + 0xc : 0xe); write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | RADIO_2056_TX1, (CHSPEC_IS5G - (pi-> - radio_chanspec)) ? 0xc : 0xe); + (pi->radio_chanspec)) ? + 0xc : 0xe); } else { write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | @@ -28198,17 +28438,17 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { for (idx = 0; idx < tbl_len; idx++) { - num = - 8 * (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx); + num = 8 * + (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx); den = 32768 + a1[tbl_id - 26] * idx; pwr_est = max(((4 * num + den / 2) / den), -8); if (NREV_LT(pi->pubpi.phy_rev, 3)) { if (idx <= (uint) (31 - idle_tssi[tbl_id - 26] + 1)) pwr_est = - max(pwr_est, - target_pwr_qtrdbm[tbl_id - 26] + - 1); + max(pwr_est, + target_pwr_qtrdbm + [tbl_id - 26] + 1); } regval[idx] = (u32) pwr_est; } @@ -28229,7 +28469,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) static bool wlc_phy_txpwr_ison_nphy(struct brcms_phy *pi) { return read_phy_reg((pi), 0x1e7) & ((0x1 << 15) | - (0x1 << 14) | (0x1 << 13)); + (0x1 << 14) | (0x1 << 13)); } static u8 wlc_phy_txpwr_idx_cur_get_nphy(struct brcms_phy *pi, u8 core) @@ -28261,12 +28501,9 @@ u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi) tmp = (pwr_idx[0] << 8) | pwr_idx[1]; } else { - tmp = - ((pi->nphy_txpwrindex[PHY_CORE_0]. - index_internal & 0xff) << 8) | (pi-> - nphy_txpwrindex - [PHY_CORE_1]. - index_internal & 0xff); + tmp = ((pi->nphy_txpwrindex[PHY_CORE_0].index_internal & 0xff) + << 8) | + (pi->nphy_txpwrindex[PHY_CORE_1].index_internal & 0xff); } return tmp; @@ -28315,9 +28552,9 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) for (core = 0; core < pi->pubpi.phy_corenum; core++) pi->nphy_txpwr_idx[core] = - wlc_phy_txpwr_idx_cur_get_nphy(pi, - (u8) - core); + wlc_phy_txpwr_idx_cur_get_nphy( + pi, + (u8) core); } } @@ -28334,7 +28571,7 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) if (NREV_GE(pi->pubpi.phy_rev, 3)) and_phy_reg(pi, 0x1e7, (u16) (~((0x1 << 15) | - (0x1 << 14) | (0x1 << 13)))); + (0x1 << 14) | (0x1 << 13)))); else and_phy_reg(pi, 0x1e7, (u16) (~((0x1 << 14) | (0x1 << 13)))); @@ -28517,7 +28754,7 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); pi->nphy_txpwrindex[core].index_internal = - pi->nphy_txpwrindex[core].index_internal_save; + pi->nphy_txpwrindex[core].index_internal_save; } else { if (pi->nphy_txpwrindex[core].index < 0) { @@ -28532,14 +28769,13 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, AfectrlOverride); } else { pi->nphy_txpwrindex[core]. - AfectrlOverride = - read_phy_reg(pi, 0xa5); + AfectrlOverride = + read_phy_reg(pi, 0xa5); } pi->nphy_txpwrindex[core].AfeCtrlDacGain = - read_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xaa : 0xab); + read_phy_reg(pi, (core == PHY_CORE_0) ? + 0xaa : 0xab); wlc_phy_table_read_nphy(pi, 7, 1, (0x110 + core), 16, @@ -28551,8 +28787,7 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, &tmpval); tmpval >>= ((core == PHY_CORE_0) ? 8 : 0); tmpval &= 0xff; - pi->nphy_txpwrindex[core].bbmult = - (u8) tmpval; + pi->nphy_txpwrindex[core].bbmult = (u8) tmpval; wlc_phy_table_read_nphy(pi, 15, 2, (80 + 2 * core), 16, @@ -28567,7 +28802,8 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, locomp); pi->nphy_txpwrindex[core].index_internal_save = - pi->nphy_txpwrindex[core].index_internal; + pi->nphy_txpwrindex[core]. + index_internal; } tx_pwr_ctrl_state = pi->nphy_txpwrctrl; @@ -28581,11 +28817,11 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, &txgain); if (NREV_GE(pi->pubpi.phy_rev, 3)) - rad_gain = - (txgain >> 16) & ((1 << (32 - 16 + 1)) - 1); + rad_gain = (txgain >> 16) & + ((1 << (32 - 16 + 1)) - 1); else - rad_gain = - (txgain >> 16) & ((1 << (28 - 16 + 1)) - 1); + rad_gain = (txgain >> 16) & + ((1 << (28 - 16 + 1)) - 1); dac_gain = (txgain >> 8) & ((1 << (13 - 8 + 1)) - 1); bbmult = (txgain >> 0) & ((1 << (7 - 0 + 1)) - 1); @@ -28604,9 +28840,8 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m1m2); m1m2 &= ((core == PHY_CORE_0) ? 0x00ff : 0xff00); - m1m2 |= - ((core == - PHY_CORE_0) ? (bbmult << 8) : (bbmult << 0)); + m1m2 |= ((core == PHY_CORE_0) ? + (bbmult << 8) : (bbmult << 0)); wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m1m2); @@ -28636,13 +28871,11 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, if (PHY_IPA(pi)) { wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_CORE1TXPWRCTL - : - NPHY_TBL_ID_CORE2TXPWRCTL), - 1, 576 + txpwrindex, 32, - &rfpwr_offset); + (core == PHY_CORE_0 ? + NPHY_TBL_ID_CORE1TXPWRCTL : + NPHY_TBL_ID_CORE2TXPWRCTL), + 1, 576 + txpwrindex, 32, + &rfpwr_offset); mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : 0x29b, (0x1ff << 4), @@ -28698,7 +28931,7 @@ void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable) if (enable) { if (pi->nphy_deaf_count == 0) { pi->classifier_state = - wlc_phy_classifier_nphy(pi, 0, 0); + wlc_phy_classifier_nphy(pi, 0, 0); wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); wlc_phy_clip_det_nphy(pi, 0, pi->clip_state); wlc_phy_clip_det_nphy(pi, 1, clip_off); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c index 7ff28507f1b..faf1ebe7606 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c @@ -17,21 +17,23 @@ #include "phy_qmath.h" /* -Description: This function make 16 bit unsigned multiplication. To fit the output into -16 bits the 32 bit multiplication result is right shifted by 16 bits. -*/ + * Description: This function make 16 bit unsigned multiplication. + * To fit the output into 16 bits the 32 bit multiplication result is right + * shifted by 16 bits. + */ u16 qm_mulu16(u16 op1, u16 op2) { return (u16) (((u32) op1 * (u32) op2) >> 16); } /* -Description: This function make 16 bit multiplication and return the result in 16 bits. -To fit the multiplication result into 16 bits the multiplication result is right shifted by -15 bits. Right shifting 15 bits instead of 16 bits is done to remove the extra sign bit formed -due to the multiplication. -When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff. -*/ + * Description: This function make 16 bit multiplication and return the result + * in 16 bits. To fit the multiplication result into 16 bits the multiplication + * result is right shifted by 15 bits. Right shifting 15 bits instead of 16 bits + * is done to remove the extra sign bit formed due to the multiplication. + * When both the 16bit inputs are 0x8000 then the output is saturated to + * 0x7fffffff. + */ s16 qm_muls16(s16 op1, s16 op2) { s32 result; @@ -44,9 +46,10 @@ s16 qm_muls16(s16 op1, s16 op2) } /* -Description: This function add two 32 bit numbers and return the 32bit result. -If the result overflow 32 bits, the output will be saturated to 32bits. -*/ + * Description: This function add two 32 bit numbers and return the 32bit + * result. If the result overflow 32 bits, the output will be saturated to + * 32bits. + */ s32 qm_add32(s32 op1, s32 op2) { s32 result; @@ -60,9 +63,10 @@ s32 qm_add32(s32 op1, s32 op2) } /* -Description: This function add two 16 bit numbers and return the 16bit result. -If the result overflow 16 bits, the output will be saturated to 16bits. -*/ + * Description: This function add two 16 bit numbers and return the 16bit + * result. If the result overflow 16 bits, the output will be saturated to + * 16bits. + */ s16 qm_add16(s16 op1, s16 op2) { s16 result; @@ -78,9 +82,10 @@ s16 qm_add16(s16 op1, s16 op2) } /* -Description: This function make 16 bit subtraction and return the 16bit result. -If the result overflow 16 bits, the output will be saturated to 16bits. -*/ + * Description: This function make 16 bit subtraction and return the 16bit + * result. If the result overflow 16 bits, the output will be saturated to + * 16bits. + */ s16 qm_sub16(s16 op1, s16 op2) { s16 result; @@ -96,10 +101,11 @@ s16 qm_sub16(s16 op1, s16 op2) } /* -Description: This function make a 32 bit saturated left shift when the specified shift -is +ve. This function will make a 32 bit right shift when the specified shift is -ve. -This function return the result after shifting operation. -*/ + * Description: This function make a 32 bit saturated left shift when the + * specified shift is +ve. This function will make a 32 bit right shift when + * the specified shift is -ve. This function return the result after shifting + * operation. + */ s32 qm_shl32(s32 op, int shift) { int i; @@ -120,10 +126,11 @@ s32 qm_shl32(s32 op, int shift) } /* -Description: This function make a 16 bit saturated left shift when the specified shift -is +ve. This function will make a 16 bit right shift when the specified shift is -ve. -This function return the result after shifting operation. -*/ + * Description: This function make a 16 bit saturated left shift when the + * specified shift is +ve. This function will make a 16 bit right shift when + * the specified shift is -ve. This function return the result after shifting + * operation. + */ s16 qm_shl16(s16 op, int shift) { int i; @@ -144,19 +151,19 @@ s16 qm_shl16(s16 op, int shift) } /* -Description: This function make a 16 bit right shift when shift is +ve. -This function make a 16 bit saturated left shift when shift is -ve. This function -return the result of the shift operation. -*/ + * Description: This function make a 16 bit right shift when shift is +ve. + * This function make a 16 bit saturated left shift when shift is -ve. This + * function return the result of the shift operation. + */ s16 qm_shr16(s16 op, int shift) { return qm_shl16(op, -shift); } /* -Description: This function return the number of redundant sign bits in a 32 bit number. -Example: qm_norm32(0x00000080) = 23 -*/ + * Description: This function return the number of redundant sign bits in a + * 32 bit number. Example: qm_norm32(0x00000080) = 23 + */ s16 qm_norm32(s32 op) { u16 u16extraSignBits; @@ -208,28 +215,30 @@ static const s16 log_table[] = { 32024 }; -#define LOG_TABLE_SIZE 32 /* log_table size */ -#define LOG2_LOG_TABLE_SIZE 5 /* log2(log_table size) */ -#define Q_LOG_TABLE 15 /* qformat of log_table */ -#define LOG10_2 19728 /* log10(2) in q.16 */ +#define LOG_TABLE_SIZE 32 /* log_table size */ +#define LOG2_LOG_TABLE_SIZE 5 /* log2(log_table size) */ +#define Q_LOG_TABLE 15 /* qformat of log_table */ +#define LOG10_2 19728 /* log10(2) in q.16 */ /* -Description: -This routine takes the input number N and its q format qN and compute -the log10(N). This routine first normalizes the input no N. Then N is in mag*(2^x) format. -mag is any number in the range 2^30-(2^31 - 1). Then log2(mag * 2^x) = log2(mag) + x is computed. -From that log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed. -This routine looks the log2 value in the table considering LOG2_LOG_TABLE_SIZE+1 MSBs. -As the MSB is always 1, only next LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup. -Next 16 MSBs are used for interpolation. -Inputs: -N - number to which log10 has to be found. -qN - q format of N -log10N - address where log10(N) will be written. -qLog10N - address where log10N qformat will be written. -Note/Problem: -For accurate results input should be in normalized or near normalized form. -*/ + * Description: + * This routine takes the input number N and its q format qN and compute + * the log10(N). This routine first normalizes the input no N. Then N is in + * mag*(2^x) format. mag is any number in the range 2^30-(2^31 - 1). + * Then log2(mag * 2^x) = log2(mag) + x is computed. From that + * log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed. + * This routine looks the log2 value in the table considering + * LOG2_LOG_TABLE_SIZE+1 MSBs. As the MSB is always 1, only next + * LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup. Next 16 MSBs are used + * for interpolation. + * Inputs: + * N - number to which log10 has to be found. + * qN - q format of N + * log10N - address where log10(N) will be written. + * qLog10N - address where log10N qformat will be written. + * Note/Problem: + * For accurate results input should be in normalized or near normalized form. + */ void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N) { s16 s16norm, s16tableIndex, s16errorApproximation; @@ -248,12 +257,13 @@ void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N) */ qN = qN + s16norm - 30; - /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the MSB */ + /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the + * MSB */ s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE))); /* remove the MSB. the MSB is always 1 after normalization. */ s16tableIndex = - s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1); + s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1); /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */ N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1); @@ -263,23 +273,27 @@ void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N) u16offset = (u16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE + 16))); /* look the log value in the table. */ - s32log = log_table[s16tableIndex]; /* q.15 format */ + s32log = log_table[s16tableIndex]; /* q.15 format */ - /* interpolate using the offset. */ - s16errorApproximation = (s16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex])); /* q.15 */ + /* interpolate using the offset. q.15 format. */ + s16errorApproximation = (s16) qm_mulu16(u16offset, + (u16) (log_table[s16tableIndex + 1] - + log_table[s16tableIndex])); - s32log = qm_add16((s16) s32log, s16errorApproximation); /* q.15 format */ + /* q.15 format */ + s32log = qm_add16((s16) s32log, s16errorApproximation); /* adjust for the qformat of the N as * log2(mag * 2^x) = log2(mag) + x */ - s32log = qm_add32(s32log, ((s32) -qN) << 15); /* q.15 format */ + s32log = qm_add32(s32log, ((s32) -qN) << 15); /* q.15 format */ /* normalize the result. */ s16norm = qm_norm32(s32log); /* bring all the important bits into lower 16 bits */ - s32log = qm_shl32(s32log, s16norm - 16); /* q.15+s16norm-16 format */ + /* q.15+s16norm-16 format */ + s32log = qm_shl32(s32log, s16norm - 16); /* compute the log10(N) by multiplying log2(N) with log10(2). * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c index 023d05aa97a..c354496d3e7 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c @@ -2834,26 +2834,26 @@ const struct phytbl_info dot11lcnphytbl_info_rev0[] = { const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313 = { &dot11lcn_sw_ctrl_tbl_4313_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0[0]), 15, 0, 16 + sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0) / + sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0[0]), 15, 0, 16 }; const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa = { &dot11lcn_sw_ctrl_tbl_4313_epa_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0[0]), 15, 0, 16 + sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0) / + sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0[0]), 15, 0, 16 }; const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa = { &dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo, - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[0]), 15, 0, 16 + sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo) / + sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[0]), 15, 0, 16 }; const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250 = { &dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[0]), 15, 0, 16 + sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0) / + sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[0]), 15, 0, 16 }; const u32 dot11lcnphytbl_info_sz_rev0 = @@ -2861,778 +2861,394 @@ const u32 dot11lcnphytbl_info_sz_rev0 = const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_extPA_gaintable_rev0[128] = { - {3, 0, 31, 0, 72,} - , - {3, 0, 31, 0, 70,} - , - {3, 0, 31, 0, 68,} - , - {3, 0, 30, 0, 67,} - , - {3, 0, 29, 0, 68,} - , - {3, 0, 28, 0, 68,} - , - {3, 0, 27, 0, 69,} - , - {3, 0, 26, 0, 70,} - , - {3, 0, 25, 0, 70,} - , - {3, 0, 24, 0, 71,} - , - {3, 0, 23, 0, 72,} - , - {3, 0, 23, 0, 70,} - , - {3, 0, 22, 0, 71,} - , - {3, 0, 21, 0, 72,} - , - {3, 0, 21, 0, 70,} - , - {3, 0, 21, 0, 68,} - , - {3, 0, 21, 0, 66,} - , - {3, 0, 21, 0, 64,} - , - {3, 0, 21, 0, 63,} - , - {3, 0, 20, 0, 64,} - , - {3, 0, 19, 0, 65,} - , - {3, 0, 19, 0, 64,} - , - {3, 0, 18, 0, 65,} - , - {3, 0, 18, 0, 64,} - , - {3, 0, 17, 0, 65,} - , - {3, 0, 17, 0, 64,} - , - {3, 0, 16, 0, 65,} - , - {3, 0, 16, 0, 64,} - , - {3, 0, 16, 0, 62,} - , - {3, 0, 16, 0, 60,} - , - {3, 0, 16, 0, 58,} - , - {3, 0, 15, 0, 61,} - , - {3, 0, 15, 0, 59,} - , - {3, 0, 14, 0, 61,} - , - {3, 0, 14, 0, 60,} - , - {3, 0, 14, 0, 58,} - , - {3, 0, 13, 0, 60,} - , - {3, 0, 13, 0, 59,} - , - {3, 0, 12, 0, 62,} - , - {3, 0, 12, 0, 60,} - , - {3, 0, 12, 0, 58,} - , - {3, 0, 11, 0, 62,} - , - {3, 0, 11, 0, 60,} - , - {3, 0, 11, 0, 59,} - , - {3, 0, 11, 0, 57,} - , - {3, 0, 10, 0, 61,} - , - {3, 0, 10, 0, 59,} - , - {3, 0, 10, 0, 57,} - , - {3, 0, 9, 0, 62,} - , - {3, 0, 9, 0, 60,} - , - {3, 0, 9, 0, 58,} - , - {3, 0, 9, 0, 57,} - , - {3, 0, 8, 0, 62,} - , - {3, 0, 8, 0, 60,} - , - {3, 0, 8, 0, 58,} - , - {3, 0, 8, 0, 57,} - , - {3, 0, 8, 0, 55,} - , - {3, 0, 7, 0, 61,} - , - {3, 0, 7, 0, 60,} - , - {3, 0, 7, 0, 58,} - , - {3, 0, 7, 0, 56,} - , - {3, 0, 7, 0, 55,} - , - {3, 0, 6, 0, 62,} - , - {3, 0, 6, 0, 60,} - , - {3, 0, 6, 0, 58,} - , - {3, 0, 6, 0, 57,} - , - {3, 0, 6, 0, 55,} - , - {3, 0, 6, 0, 54,} - , - {3, 0, 6, 0, 52,} - , - {3, 0, 5, 0, 61,} - , - {3, 0, 5, 0, 59,} - , - {3, 0, 5, 0, 57,} - , - {3, 0, 5, 0, 56,} - , - {3, 0, 5, 0, 54,} - , - {3, 0, 5, 0, 53,} - , - {3, 0, 5, 0, 51,} - , - {3, 0, 4, 0, 62,} - , - {3, 0, 4, 0, 60,} - , - {3, 0, 4, 0, 58,} - , - {3, 0, 4, 0, 57,} - , - {3, 0, 4, 0, 55,} - , - {3, 0, 4, 0, 54,} - , - {3, 0, 4, 0, 52,} - , - {3, 0, 4, 0, 51,} - , - {3, 0, 4, 0, 49,} - , - {3, 0, 4, 0, 48,} - , - {3, 0, 4, 0, 46,} - , - {3, 0, 3, 0, 60,} - , - {3, 0, 3, 0, 58,} - , - {3, 0, 3, 0, 57,} - , - {3, 0, 3, 0, 55,} - , - {3, 0, 3, 0, 54,} - , - {3, 0, 3, 0, 52,} - , - {3, 0, 3, 0, 51,} - , - {3, 0, 3, 0, 49,} - , - {3, 0, 3, 0, 48,} - , - {3, 0, 3, 0, 46,} - , - {3, 0, 3, 0, 45,} - , - {3, 0, 3, 0, 44,} - , - {3, 0, 3, 0, 43,} - , - {3, 0, 3, 0, 41,} - , - {3, 0, 2, 0, 61,} - , - {3, 0, 2, 0, 59,} - , - {3, 0, 2, 0, 57,} - , - {3, 0, 2, 0, 56,} - , - {3, 0, 2, 0, 54,} - , - {3, 0, 2, 0, 53,} - , - {3, 0, 2, 0, 51,} - , - {3, 0, 2, 0, 50,} - , - {3, 0, 2, 0, 48,} - , - {3, 0, 2, 0, 47,} - , - {3, 0, 2, 0, 46,} - , - {3, 0, 2, 0, 44,} - , - {3, 0, 2, 0, 43,} - , - {3, 0, 2, 0, 42,} - , - {3, 0, 2, 0, 41,} - , - {3, 0, 2, 0, 39,} - , - {3, 0, 2, 0, 38,} - , - {3, 0, 2, 0, 37,} - , - {3, 0, 2, 0, 36,} - , - {3, 0, 2, 0, 35,} - , - {3, 0, 2, 0, 34,} - , - {3, 0, 2, 0, 33,} - , - {3, 0, 2, 0, 32,} - , - {3, 0, 1, 0, 63,} - , - {3, 0, 1, 0, 61,} - , - {3, 0, 1, 0, 59,} - , - {3, 0, 1, 0, 57,} - , + {3, 0, 31, 0, 72}, + {3, 0, 31, 0, 70}, + {3, 0, 31, 0, 68}, + {3, 0, 30, 0, 67}, + {3, 0, 29, 0, 68}, + {3, 0, 28, 0, 68}, + {3, 0, 27, 0, 69}, + {3, 0, 26, 0, 70}, + {3, 0, 25, 0, 70}, + {3, 0, 24, 0, 71}, + {3, 0, 23, 0, 72}, + {3, 0, 23, 0, 70}, + {3, 0, 22, 0, 71}, + {3, 0, 21, 0, 72}, + {3, 0, 21, 0, 70}, + {3, 0, 21, 0, 68}, + {3, 0, 21, 0, 66}, + {3, 0, 21, 0, 64}, + {3, 0, 21, 0, 63}, + {3, 0, 20, 0, 64}, + {3, 0, 19, 0, 65}, + {3, 0, 19, 0, 64}, + {3, 0, 18, 0, 65}, + {3, 0, 18, 0, 64}, + {3, 0, 17, 0, 65}, + {3, 0, 17, 0, 64}, + {3, 0, 16, 0, 65}, + {3, 0, 16, 0, 64}, + {3, 0, 16, 0, 62}, + {3, 0, 16, 0, 60}, + {3, 0, 16, 0, 58}, + {3, 0, 15, 0, 61}, + {3, 0, 15, 0, 59}, + {3, 0, 14, 0, 61}, + {3, 0, 14, 0, 60}, + {3, 0, 14, 0, 58}, + {3, 0, 13, 0, 60}, + {3, 0, 13, 0, 59}, + {3, 0, 12, 0, 62}, + {3, 0, 12, 0, 60}, + {3, 0, 12, 0, 58}, + {3, 0, 11, 0, 62}, + {3, 0, 11, 0, 60}, + {3, 0, 11, 0, 59}, + {3, 0, 11, 0, 57}, + {3, 0, 10, 0, 61}, + {3, 0, 10, 0, 59}, + {3, 0, 10, 0, 57}, + {3, 0, 9, 0, 62}, + {3, 0, 9, 0, 60}, + {3, 0, 9, 0, 58}, + {3, 0, 9, 0, 57}, + {3, 0, 8, 0, 62}, + {3, 0, 8, 0, 60}, + {3, 0, 8, 0, 58}, + {3, 0, 8, 0, 57}, + {3, 0, 8, 0, 55}, + {3, 0, 7, 0, 61}, + {3, 0, 7, 0, 60}, + {3, 0, 7, 0, 58}, + {3, 0, 7, 0, 56}, + {3, 0, 7, 0, 55}, + {3, 0, 6, 0, 62}, + {3, 0, 6, 0, 60}, + {3, 0, 6, 0, 58}, + {3, 0, 6, 0, 57}, + {3, 0, 6, 0, 55}, + {3, 0, 6, 0, 54}, + {3, 0, 6, 0, 52}, + {3, 0, 5, 0, 61}, + {3, 0, 5, 0, 59}, + {3, 0, 5, 0, 57}, + {3, 0, 5, 0, 56}, + {3, 0, 5, 0, 54}, + {3, 0, 5, 0, 53}, + {3, 0, 5, 0, 51}, + {3, 0, 4, 0, 62}, + {3, 0, 4, 0, 60}, + {3, 0, 4, 0, 58}, + {3, 0, 4, 0, 57}, + {3, 0, 4, 0, 55}, + {3, 0, 4, 0, 54}, + {3, 0, 4, 0, 52}, + {3, 0, 4, 0, 51}, + {3, 0, 4, 0, 49}, + {3, 0, 4, 0, 48}, + {3, 0, 4, 0, 46}, + {3, 0, 3, 0, 60}, + {3, 0, 3, 0, 58}, + {3, 0, 3, 0, 57}, + {3, 0, 3, 0, 55}, + {3, 0, 3, 0, 54}, + {3, 0, 3, 0, 52}, + {3, 0, 3, 0, 51}, + {3, 0, 3, 0, 49}, + {3, 0, 3, 0, 48}, + {3, 0, 3, 0, 46}, + {3, 0, 3, 0, 45}, + {3, 0, 3, 0, 44}, + {3, 0, 3, 0, 43}, + {3, 0, 3, 0, 41}, + {3, 0, 2, 0, 61}, + {3, 0, 2, 0, 59}, + {3, 0, 2, 0, 57}, + {3, 0, 2, 0, 56}, + {3, 0, 2, 0, 54}, + {3, 0, 2, 0, 53}, + {3, 0, 2, 0, 51}, + {3, 0, 2, 0, 50}, + {3, 0, 2, 0, 48}, + {3, 0, 2, 0, 47}, + {3, 0, 2, 0, 46}, + {3, 0, 2, 0, 44}, + {3, 0, 2, 0, 43}, + {3, 0, 2, 0, 42}, + {3, 0, 2, 0, 41}, + {3, 0, 2, 0, 39}, + {3, 0, 2, 0, 38}, + {3, 0, 2, 0, 37}, + {3, 0, 2, 0, 36}, + {3, 0, 2, 0, 35}, + {3, 0, 2, 0, 34}, + {3, 0, 2, 0, 33}, + {3, 0, 2, 0, 32}, + {3, 0, 1, 0, 63}, + {3, 0, 1, 0, 61}, + {3, 0, 1, 0, 59}, + {3, 0, 1, 0, 57}, }; const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_gaintable_rev0[128] = { - {7, 0, 31, 0, 72,} - , - {7, 0, 31, 0, 70,} - , - {7, 0, 31, 0, 68,} - , - {7, 0, 30, 0, 67,} - , - {7, 0, 29, 0, 68,} - , - {7, 0, 28, 0, 68,} - , - {7, 0, 27, 0, 69,} - , - {7, 0, 26, 0, 70,} - , - {7, 0, 25, 0, 70,} - , - {7, 0, 24, 0, 71,} - , - {7, 0, 23, 0, 72,} - , - {7, 0, 23, 0, 70,} - , - {7, 0, 22, 0, 71,} - , - {7, 0, 21, 0, 72,} - , - {7, 0, 21, 0, 70,} - , - {7, 0, 21, 0, 68,} - , - {7, 0, 21, 0, 66,} - , - {7, 0, 21, 0, 64,} - , - {7, 0, 21, 0, 63,} - , - {7, 0, 20, 0, 64,} - , - {7, 0, 19, 0, 65,} - , - {7, 0, 19, 0, 64,} - , - {7, 0, 18, 0, 65,} - , - {7, 0, 18, 0, 64,} - , - {7, 0, 17, 0, 65,} - , - {7, 0, 17, 0, 64,} - , - {7, 0, 16, 0, 65,} - , - {7, 0, 16, 0, 64,} - , - {7, 0, 16, 0, 62,} - , - {7, 0, 16, 0, 60,} - , - {7, 0, 16, 0, 58,} - , - {7, 0, 15, 0, 61,} - , - {7, 0, 15, 0, 59,} - , - {7, 0, 14, 0, 61,} - , - {7, 0, 14, 0, 60,} - , - {7, 0, 14, 0, 58,} - , - {7, 0, 13, 0, 60,} - , - {7, 0, 13, 0, 59,} - , - {7, 0, 12, 0, 62,} - , - {7, 0, 12, 0, 60,} - , - {7, 0, 12, 0, 58,} - , - {7, 0, 11, 0, 62,} - , - {7, 0, 11, 0, 60,} - , - {7, 0, 11, 0, 59,} - , - {7, 0, 11, 0, 57,} - , - {7, 0, 10, 0, 61,} - , - {7, 0, 10, 0, 59,} - , - {7, 0, 10, 0, 57,} - , - {7, 0, 9, 0, 62,} - , - {7, 0, 9, 0, 60,} - , - {7, 0, 9, 0, 58,} - , - {7, 0, 9, 0, 57,} - , - {7, 0, 8, 0, 62,} - , - {7, 0, 8, 0, 60,} - , - {7, 0, 8, 0, 58,} - , - {7, 0, 8, 0, 57,} - , - {7, 0, 8, 0, 55,} - , - {7, 0, 7, 0, 61,} - , - {7, 0, 7, 0, 60,} - , - {7, 0, 7, 0, 58,} - , - {7, 0, 7, 0, 56,} - , - {7, 0, 7, 0, 55,} - , - {7, 0, 6, 0, 62,} - , - {7, 0, 6, 0, 60,} - , - {7, 0, 6, 0, 58,} - , - {7, 0, 6, 0, 57,} - , - {7, 0, 6, 0, 55,} - , - {7, 0, 6, 0, 54,} - , - {7, 0, 6, 0, 52,} - , - {7, 0, 5, 0, 61,} - , - {7, 0, 5, 0, 59,} - , - {7, 0, 5, 0, 57,} - , - {7, 0, 5, 0, 56,} - , - {7, 0, 5, 0, 54,} - , - {7, 0, 5, 0, 53,} - , - {7, 0, 5, 0, 51,} - , - {7, 0, 4, 0, 62,} - , - {7, 0, 4, 0, 60,} - , - {7, 0, 4, 0, 58,} - , - {7, 0, 4, 0, 57,} - , - {7, 0, 4, 0, 55,} - , - {7, 0, 4, 0, 54,} - , - {7, 0, 4, 0, 52,} - , - {7, 0, 4, 0, 51,} - , - {7, 0, 4, 0, 49,} - , - {7, 0, 4, 0, 48,} - , - {7, 0, 4, 0, 46,} - , - {7, 0, 3, 0, 60,} - , - {7, 0, 3, 0, 58,} - , - {7, 0, 3, 0, 57,} - , - {7, 0, 3, 0, 55,} - , - {7, 0, 3, 0, 54,} - , - {7, 0, 3, 0, 52,} - , - {7, 0, 3, 0, 51,} - , - {7, 0, 3, 0, 49,} - , - {7, 0, 3, 0, 48,} - , - {7, 0, 3, 0, 46,} - , - {7, 0, 3, 0, 45,} - , - {7, 0, 3, 0, 44,} - , - {7, 0, 3, 0, 43,} - , - {7, 0, 3, 0, 41,} - , - {7, 0, 2, 0, 61,} - , - {7, 0, 2, 0, 59,} - , - {7, 0, 2, 0, 57,} - , - {7, 0, 2, 0, 56,} - , - {7, 0, 2, 0, 54,} - , - {7, 0, 2, 0, 53,} - , - {7, 0, 2, 0, 51,} - , - {7, 0, 2, 0, 50,} - , - {7, 0, 2, 0, 48,} - , - {7, 0, 2, 0, 47,} - , - {7, 0, 2, 0, 46,} - , - {7, 0, 2, 0, 44,} - , - {7, 0, 2, 0, 43,} - , - {7, 0, 2, 0, 42,} - , - {7, 0, 2, 0, 41,} - , - {7, 0, 2, 0, 39,} - , - {7, 0, 2, 0, 38,} - , - {7, 0, 2, 0, 37,} - , - {7, 0, 2, 0, 36,} - , - {7, 0, 2, 0, 35,} - , - {7, 0, 2, 0, 34,} - , - {7, 0, 2, 0, 33,} - , - {7, 0, 2, 0, 32,} - , - {7, 0, 1, 0, 63,} - , - {7, 0, 1, 0, 61,} - , - {7, 0, 1, 0, 59,} - , - {7, 0, 1, 0, 57,} - , + {7, 0, 31, 0, 72}, + {7, 0, 31, 0, 70}, + {7, 0, 31, 0, 68}, + {7, 0, 30, 0, 67}, + {7, 0, 29, 0, 68}, + {7, 0, 28, 0, 68}, + {7, 0, 27, 0, 69}, + {7, 0, 26, 0, 70}, + {7, 0, 25, 0, 70}, + {7, 0, 24, 0, 71}, + {7, 0, 23, 0, 72}, + {7, 0, 23, 0, 70}, + {7, 0, 22, 0, 71}, + {7, 0, 21, 0, 72}, + {7, 0, 21, 0, 70}, + {7, 0, 21, 0, 68}, + {7, 0, 21, 0, 66}, + {7, 0, 21, 0, 64}, + {7, 0, 21, 0, 63}, + {7, 0, 20, 0, 64}, + {7, 0, 19, 0, 65}, + {7, 0, 19, 0, 64}, + {7, 0, 18, 0, 65}, + {7, 0, 18, 0, 64}, + {7, 0, 17, 0, 65}, + {7, 0, 17, 0, 64}, + {7, 0, 16, 0, 65}, + {7, 0, 16, 0, 64}, + {7, 0, 16, 0, 62}, + {7, 0, 16, 0, 60}, + {7, 0, 16, 0, 58}, + {7, 0, 15, 0, 61}, + {7, 0, 15, 0, 59}, + {7, 0, 14, 0, 61}, + {7, 0, 14, 0, 60}, + {7, 0, 14, 0, 58}, + {7, 0, 13, 0, 60}, + {7, 0, 13, 0, 59}, + {7, 0, 12, 0, 62}, + {7, 0, 12, 0, 60}, + {7, 0, 12, 0, 58}, + {7, 0, 11, 0, 62}, + {7, 0, 11, 0, 60}, + {7, 0, 11, 0, 59}, + {7, 0, 11, 0, 57}, + {7, 0, 10, 0, 61}, + {7, 0, 10, 0, 59}, + {7, 0, 10, 0, 57}, + {7, 0, 9, 0, 62}, + {7, 0, 9, 0, 60}, + {7, 0, 9, 0, 58}, + {7, 0, 9, 0, 57}, + {7, 0, 8, 0, 62}, + {7, 0, 8, 0, 60}, + {7, 0, 8, 0, 58}, + {7, 0, 8, 0, 57}, + {7, 0, 8, 0, 55}, + {7, 0, 7, 0, 61}, + {7, 0, 7, 0, 60}, + {7, 0, 7, 0, 58}, + {7, 0, 7, 0, 56}, + {7, 0, 7, 0, 55}, + {7, 0, 6, 0, 62}, + {7, 0, 6, 0, 60}, + {7, 0, 6, 0, 58}, + {7, 0, 6, 0, 57}, + {7, 0, 6, 0, 55}, + {7, 0, 6, 0, 54}, + {7, 0, 6, 0, 52}, + {7, 0, 5, 0, 61}, + {7, 0, 5, 0, 59}, + {7, 0, 5, 0, 57}, + {7, 0, 5, 0, 56}, + {7, 0, 5, 0, 54}, + {7, 0, 5, 0, 53}, + {7, 0, 5, 0, 51}, + {7, 0, 4, 0, 62}, + {7, 0, 4, 0, 60}, + {7, 0, 4, 0, 58}, + {7, 0, 4, 0, 57}, + {7, 0, 4, 0, 55}, + {7, 0, 4, 0, 54}, + {7, 0, 4, 0, 52}, + {7, 0, 4, 0, 51}, + {7, 0, 4, 0, 49}, + {7, 0, 4, 0, 48}, + {7, 0, 4, 0, 46}, + {7, 0, 3, 0, 60}, + {7, 0, 3, 0, 58}, + {7, 0, 3, 0, 57}, + {7, 0, 3, 0, 55}, + {7, 0, 3, 0, 54}, + {7, 0, 3, 0, 52}, + {7, 0, 3, 0, 51}, + {7, 0, 3, 0, 49}, + {7, 0, 3, 0, 48}, + {7, 0, 3, 0, 46}, + {7, 0, 3, 0, 45}, + {7, 0, 3, 0, 44}, + {7, 0, 3, 0, 43}, + {7, 0, 3, 0, 41}, + {7, 0, 2, 0, 61}, + {7, 0, 2, 0, 59}, + {7, 0, 2, 0, 57}, + {7, 0, 2, 0, 56}, + {7, 0, 2, 0, 54}, + {7, 0, 2, 0, 53}, + {7, 0, 2, 0, 51}, + {7, 0, 2, 0, 50}, + {7, 0, 2, 0, 48}, + {7, 0, 2, 0, 47}, + {7, 0, 2, 0, 46}, + {7, 0, 2, 0, 44}, + {7, 0, 2, 0, 43}, + {7, 0, 2, 0, 42}, + {7, 0, 2, 0, 41}, + {7, 0, 2, 0, 39}, + {7, 0, 2, 0, 38}, + {7, 0, 2, 0, 37}, + {7, 0, 2, 0, 36}, + {7, 0, 2, 0, 35}, + {7, 0, 2, 0, 34}, + {7, 0, 2, 0, 33}, + {7, 0, 2, 0, 32}, + {7, 0, 1, 0, 63}, + {7, 0, 1, 0, 61}, + {7, 0, 1, 0, 59}, + {7, 0, 1, 0, 57}, }; const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_5GHz_gaintable_rev0[128] = { - {255, 255, 0xf0, 0, 152,} - , - {255, 255, 0xf0, 0, 147,} - , - {255, 255, 0xf0, 0, 143,} - , - {255, 255, 0xf0, 0, 139,} - , - {255, 255, 0xf0, 0, 135,} - , - {255, 255, 0xf0, 0, 131,} - , - {255, 255, 0xf0, 0, 128,} - , - {255, 255, 0xf0, 0, 124,} - , - {255, 255, 0xf0, 0, 121,} - , - {255, 255, 0xf0, 0, 117,} - , - {255, 255, 0xf0, 0, 114,} - , - {255, 255, 0xf0, 0, 111,} - , - {255, 255, 0xf0, 0, 107,} - , - {255, 255, 0xf0, 0, 104,} - , - {255, 255, 0xf0, 0, 101,} - , - {255, 255, 0xf0, 0, 99,} - , - {255, 255, 0xf0, 0, 96,} - , - {255, 255, 0xf0, 0, 93,} - , - {255, 255, 0xf0, 0, 90,} - , - {255, 255, 0xf0, 0, 88,} - , - {255, 255, 0xf0, 0, 85,} - , - {255, 255, 0xf0, 0, 83,} - , - {255, 255, 0xf0, 0, 81,} - , - {255, 255, 0xf0, 0, 78,} - , - {255, 255, 0xf0, 0, 76,} - , - {255, 255, 0xf0, 0, 74,} - , - {255, 255, 0xf0, 0, 72,} - , - {255, 255, 0xf0, 0, 70,} - , - {255, 255, 0xf0, 0, 68,} - , - {255, 255, 0xf0, 0, 66,} - , - {255, 255, 0xf0, 0, 64,} - , - {255, 248, 0xf0, 0, 64,} - , - {255, 241, 0xf0, 0, 64,} - , - {255, 251, 0xe0, 0, 64,} - , - {255, 244, 0xe0, 0, 64,} - , - {255, 254, 0xd0, 0, 64,} - , - {255, 246, 0xd0, 0, 64,} - , - {255, 239, 0xd0, 0, 64,} - , - {255, 249, 0xc0, 0, 64,} - , - {255, 242, 0xc0, 0, 64,} - , - {255, 255, 0xb0, 0, 64,} - , - {255, 248, 0xb0, 0, 64,} - , - {255, 241, 0xb0, 0, 64,} - , - {255, 254, 0xa0, 0, 64,} - , - {255, 246, 0xa0, 0, 64,} - , - {255, 239, 0xa0, 0, 64,} - , - {255, 255, 0x90, 0, 64,} - , - {255, 248, 0x90, 0, 64,} - , - {255, 241, 0x90, 0, 64,} - , - {255, 234, 0x90, 0, 64,} - , - {255, 255, 0x80, 0, 64,} - , - {255, 248, 0x80, 0, 64,} - , - {255, 241, 0x80, 0, 64,} - , - {255, 234, 0x80, 0, 64,} - , - {255, 255, 0x70, 0, 64,} - , - {255, 248, 0x70, 0, 64,} - , - {255, 241, 0x70, 0, 64,} - , - {255, 234, 0x70, 0, 64,} - , - {255, 227, 0x70, 0, 64,} - , - {255, 221, 0x70, 0, 64,} - , - {255, 215, 0x70, 0, 64,} - , - {255, 208, 0x70, 0, 64,} - , - {255, 203, 0x70, 0, 64,} - , - {255, 197, 0x70, 0, 64,} - , - {255, 255, 0x60, 0, 64,} - , - {255, 248, 0x60, 0, 64,} - , - {255, 241, 0x60, 0, 64,} - , - {255, 234, 0x60, 0, 64,} - , - {255, 227, 0x60, 0, 64,} - , - {255, 221, 0x60, 0, 64,} - , - {255, 255, 0x50, 0, 64,} - , - {255, 248, 0x50, 0, 64,} - , - {255, 241, 0x50, 0, 64,} - , - {255, 234, 0x50, 0, 64,} - , - {255, 227, 0x50, 0, 64,} - , - {255, 221, 0x50, 0, 64,} - , - {255, 215, 0x50, 0, 64,} - , - {255, 208, 0x50, 0, 64,} - , - {255, 255, 0x40, 0, 64,} - , - {255, 248, 0x40, 0, 64,} - , - {255, 241, 0x40, 0, 64,} - , - {255, 234, 0x40, 0, 64,} - , - {255, 227, 0x40, 0, 64,} - , - {255, 221, 0x40, 0, 64,} - , - {255, 215, 0x40, 0, 64,} - , - {255, 208, 0x40, 0, 64,} - , - {255, 203, 0x40, 0, 64,} - , - {255, 197, 0x40, 0, 64,} - , - {255, 255, 0x30, 0, 64,} - , - {255, 248, 0x30, 0, 64,} - , - {255, 241, 0x30, 0, 64,} - , - {255, 234, 0x30, 0, 64,} - , - {255, 227, 0x30, 0, 64,} - , - {255, 221, 0x30, 0, 64,} - , - {255, 215, 0x30, 0, 64,} - , - {255, 208, 0x30, 0, 64,} - , - {255, 203, 0x30, 0, 64,} - , - {255, 197, 0x30, 0, 64,} - , - {255, 191, 0x30, 0, 64,} - , - {255, 186, 0x30, 0, 64,} - , - {255, 181, 0x30, 0, 64,} - , - {255, 175, 0x30, 0, 64,} - , - {255, 255, 0x20, 0, 64,} - , - {255, 248, 0x20, 0, 64,} - , - {255, 241, 0x20, 0, 64,} - , - {255, 234, 0x20, 0, 64,} - , - {255, 227, 0x20, 0, 64,} - , - {255, 221, 0x20, 0, 64,} - , - {255, 215, 0x20, 0, 64,} - , - {255, 208, 0x20, 0, 64,} - , - {255, 203, 0x20, 0, 64,} - , - {255, 197, 0x20, 0, 64,} - , - {255, 191, 0x20, 0, 64,} - , - {255, 186, 0x20, 0, 64,} - , - {255, 181, 0x20, 0, 64,} - , - {255, 175, 0x20, 0, 64,} - , - {255, 170, 0x20, 0, 64,} - , - {255, 166, 0x20, 0, 64,} - , - {255, 161, 0x20, 0, 64,} - , - {255, 156, 0x20, 0, 64,} - , - {255, 152, 0x20, 0, 64,} - , - {255, 148, 0x20, 0, 64,} - , - {255, 143, 0x20, 0, 64,} - , - {255, 139, 0x20, 0, 64,} - , - {255, 135, 0x20, 0, 64,} - , - {255, 132, 0x20, 0, 64,} - , - {255, 255, 0x10, 0, 64,} - , - {255, 248, 0x10, 0, 64,} - , + {255, 255, 0xf0, 0, 152}, + {255, 255, 0xf0, 0, 147}, + {255, 255, 0xf0, 0, 143}, + {255, 255, 0xf0, 0, 139}, + {255, 255, 0xf0, 0, 135}, + {255, 255, 0xf0, 0, 131}, + {255, 255, 0xf0, 0, 128}, + {255, 255, 0xf0, 0, 124}, + {255, 255, 0xf0, 0, 121}, + {255, 255, 0xf0, 0, 117}, + {255, 255, 0xf0, 0, 114}, + {255, 255, 0xf0, 0, 111}, + {255, 255, 0xf0, 0, 107}, + {255, 255, 0xf0, 0, 104}, + {255, 255, 0xf0, 0, 101}, + {255, 255, 0xf0, 0, 99}, + {255, 255, 0xf0, 0, 96}, + {255, 255, 0xf0, 0, 93}, + {255, 255, 0xf0, 0, 90}, + {255, 255, 0xf0, 0, 88}, + {255, 255, 0xf0, 0, 85}, + {255, 255, 0xf0, 0, 83}, + {255, 255, 0xf0, 0, 81}, + {255, 255, 0xf0, 0, 78}, + {255, 255, 0xf0, 0, 76}, + {255, 255, 0xf0, 0, 74}, + {255, 255, 0xf0, 0, 72}, + {255, 255, 0xf0, 0, 70}, + {255, 255, 0xf0, 0, 68}, + {255, 255, 0xf0, 0, 66}, + {255, 255, 0xf0, 0, 64}, + {255, 248, 0xf0, 0, 64}, + {255, 241, 0xf0, 0, 64}, + {255, 251, 0xe0, 0, 64}, + {255, 244, 0xe0, 0, 64}, + {255, 254, 0xd0, 0, 64}, + {255, 246, 0xd0, 0, 64}, + {255, 239, 0xd0, 0, 64}, + {255, 249, 0xc0, 0, 64}, + {255, 242, 0xc0, 0, 64}, + {255, 255, 0xb0, 0, 64}, + {255, 248, 0xb0, 0, 64}, + {255, 241, 0xb0, 0, 64}, + {255, 254, 0xa0, 0, 64}, + {255, 246, 0xa0, 0, 64}, + {255, 239, 0xa0, 0, 64}, + {255, 255, 0x90, 0, 64}, + {255, 248, 0x90, 0, 64}, + {255, 241, 0x90, 0, 64}, + {255, 234, 0x90, 0, 64}, + {255, 255, 0x80, 0, 64}, + {255, 248, 0x80, 0, 64}, + {255, 241, 0x80, 0, 64}, + {255, 234, 0x80, 0, 64}, + {255, 255, 0x70, 0, 64}, + {255, 248, 0x70, 0, 64}, + {255, 241, 0x70, 0, 64}, + {255, 234, 0x70, 0, 64}, + {255, 227, 0x70, 0, 64}, + {255, 221, 0x70, 0, 64}, + {255, 215, 0x70, 0, 64}, + {255, 208, 0x70, 0, 64}, + {255, 203, 0x70, 0, 64}, + {255, 197, 0x70, 0, 64}, + {255, 255, 0x60, 0, 64}, + {255, 248, 0x60, 0, 64}, + {255, 241, 0x60, 0, 64}, + {255, 234, 0x60, 0, 64}, + {255, 227, 0x60, 0, 64}, + {255, 221, 0x60, 0, 64}, + {255, 255, 0x50, 0, 64}, + {255, 248, 0x50, 0, 64}, + {255, 241, 0x50, 0, 64}, + {255, 234, 0x50, 0, 64}, + {255, 227, 0x50, 0, 64}, + {255, 221, 0x50, 0, 64}, + {255, 215, 0x50, 0, 64}, + {255, 208, 0x50, 0, 64}, + {255, 255, 0x40, 0, 64}, + {255, 248, 0x40, 0, 64}, + {255, 241, 0x40, 0, 64}, + {255, 234, 0x40, 0, 64}, + {255, 227, 0x40, 0, 64}, + {255, 221, 0x40, 0, 64}, + {255, 215, 0x40, 0, 64}, + {255, 208, 0x40, 0, 64}, + {255, 203, 0x40, 0, 64}, + {255, 197, 0x40, 0, 64}, + {255, 255, 0x30, 0, 64}, + {255, 248, 0x30, 0, 64}, + {255, 241, 0x30, 0, 64}, + {255, 234, 0x30, 0, 64}, + {255, 227, 0x30, 0, 64}, + {255, 221, 0x30, 0, 64}, + {255, 215, 0x30, 0, 64}, + {255, 208, 0x30, 0, 64}, + {255, 203, 0x30, 0, 64}, + {255, 197, 0x30, 0, 64}, + {255, 191, 0x30, 0, 64}, + {255, 186, 0x30, 0, 64}, + {255, 181, 0x30, 0, 64}, + {255, 175, 0x30, 0, 64}, + {255, 255, 0x20, 0, 64}, + {255, 248, 0x20, 0, 64}, + {255, 241, 0x20, 0, 64}, + {255, 234, 0x20, 0, 64}, + {255, 227, 0x20, 0, 64}, + {255, 221, 0x20, 0, 64}, + {255, 215, 0x20, 0, 64}, + {255, 208, 0x20, 0, 64}, + {255, 203, 0x20, 0, 64}, + {255, 197, 0x20, 0, 64}, + {255, 191, 0x20, 0, 64}, + {255, 186, 0x20, 0, 64}, + {255, 181, 0x20, 0, 64}, + {255, 175, 0x20, 0, 64}, + {255, 170, 0x20, 0, 64}, + {255, 166, 0x20, 0, 64}, + {255, 161, 0x20, 0, 64}, + {255, 156, 0x20, 0, 64}, + {255, 152, 0x20, 0, 64}, + {255, 148, 0x20, 0, 64}, + {255, 143, 0x20, 0, 64}, + {255, 139, 0x20, 0, 64}, + {255, 135, 0x20, 0, 64}, + {255, 132, 0x20, 0, 64}, + {255, 255, 0x10, 0, 64}, + {255, 248, 0x10, 0, 64}, }; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c index 7f741f4868a..d1455aeebf4 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c @@ -4522,7 +4522,8 @@ const struct phytbl_info mimophytbl_info_rev0[] = { {&chanest_tbl_rev0, sizeof(chanest_tbl_rev0) / sizeof(chanest_tbl_rev0[0]), 22, 0, 32} , - {&mcs_tbl_rev0, sizeof(mcs_tbl_rev0) / sizeof(mcs_tbl_rev0[0]), 18, 0, 8} + {&mcs_tbl_rev0, sizeof(mcs_tbl_rev0) / sizeof(mcs_tbl_rev0[0]), 18, 0, + 8} , {&noise_var_tbl0_rev0, sizeof(noise_var_tbl0_rev0) / sizeof(noise_var_tbl0_rev0[0]), 16, 0, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h index c5266cf2372..dc8a84e8511 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h @@ -20,21 +20,31 @@ #include "phy_int.h" extern const struct phytbl_info mimophytbl_info_rev0[], - mimophytbl_info_rev0_volatile[]; -extern const u32 mimophytbl_info_sz_rev0, mimophytbl_info_sz_rev0_volatile; + mimophytbl_info_rev0_volatile[]; + +extern const u32 mimophytbl_info_sz_rev0, + mimophytbl_info_sz_rev0_volatile; extern const struct phytbl_info mimophytbl_info_rev3[], - mimophytbl_info_rev3_volatile[], mimophytbl_info_rev3_volatile1[], - mimophytbl_info_rev3_volatile2[], mimophytbl_info_rev3_volatile3[]; -extern const u32 mimophytbl_info_sz_rev3, mimophytbl_info_sz_rev3_volatile, - mimophytbl_info_sz_rev3_volatile1, mimophytbl_info_sz_rev3_volatile2, - mimophytbl_info_sz_rev3_volatile3; + mimophytbl_info_rev3_volatile[], + mimophytbl_info_rev3_volatile1[], + mimophytbl_info_rev3_volatile2[], + mimophytbl_info_rev3_volatile3[]; + +extern const u32 mimophytbl_info_sz_rev3, + mimophytbl_info_sz_rev3_volatile, + mimophytbl_info_sz_rev3_volatile1, + mimophytbl_info_sz_rev3_volatile2, + mimophytbl_info_sz_rev3_volatile3; extern const u32 noise_var_tbl_rev3[]; extern const struct phytbl_info mimophytbl_info_rev7[]; + extern const u32 mimophytbl_info_sz_rev7; + extern const u32 noise_var_tbl_rev7[]; extern const struct phytbl_info mimophytbl_info_rev16[]; + extern const u32 mimophytbl_info_sz_rev16; From d5efae41b43cb37ee215a83d2c90b7170092af17 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:20 +0200 Subject: [PATCH 0058/1519] staging: brcm80211: resolved checkpatch warnings in LCN phy Refactored code to not exceed the 80 char limit. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 46 +++++++------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index a109866dcf2..3d140eb0bc5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -4342,39 +4342,25 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) } if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { + const struct phytbl_info *tb; + int l; + if (CHSPEC_IS2G(pi->radio_chanspec)) { - for (idx = 0; - idx < dot11lcnphytbl_rx_gain_info_2G_rev2_sz; - idx++) - if (pi->sh->boardflags & BFL_EXTLNA) - wlc_lcnphy_write_table( - pi, - & - dot11lcnphytbl_rx_gain_info_extlna_2G_rev2 - [idx]); - else - wlc_lcnphy_write_table( - pi, - & - dot11lcnphytbl_rx_gain_info_2G_rev2 - [idx]); + l = dot11lcnphytbl_rx_gain_info_2G_rev2_sz; + if (pi->sh->boardflags & BFL_EXTLNA) + tb = dot11lcnphytbl_rx_gain_info_extlna_2G_rev2; + else + tb = dot11lcnphytbl_rx_gain_info_2G_rev2; } else { - for (idx = 0; - idx < dot11lcnphytbl_rx_gain_info_5G_rev2_sz; - idx++) - if (pi->sh->boardflags & BFL_EXTLNA_5GHz) - wlc_lcnphy_write_table( - pi, - & - dot11lcnphytbl_rx_gain_info_extlna_5G_rev2 - [idx]); - else - wlc_lcnphy_write_table( - pi, - & - dot11lcnphytbl_rx_gain_info_5G_rev2 - [idx]); + l = dot11lcnphytbl_rx_gain_info_5G_rev2_sz; + if (pi->sh->boardflags & BFL_EXTLNA_5GHz) + tb = dot11lcnphytbl_rx_gain_info_extlna_5G_rev2; + else + tb = dot11lcnphytbl_rx_gain_info_5G_rev2; } + + for (idx = 0; idx < l; idx++) + wlc_lcnphy_write_table(pi, &tb[idx]); } if ((pi->sh->boardflags & BFL_FEM) From 9204df650808cf6cf1d84e027c3fec66d7d845d2 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:21 +0200 Subject: [PATCH 0059/1519] staging: brcm80211: resolved checkpatch warnings in N phy Code that exceeded the 80 char limit has been placed in separate functions. Checkpatch warnings for the phy dir are now reduced to 1. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 304 ++++++++---------- 1 file changed, 128 insertions(+), 176 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index ca6f7499834..fb64597df43 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14544,6 +14544,44 @@ static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi) pi->phy_5g_pwrgain = true; } +static s32 get_rf_pwr_offset(struct brcms_phy *pi, s16 pga_gn, s16 pad_gn) +{ + s32 rfpwr_offset = 0; + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + rfpwr_offset = (s16) + nphy_papd_padgain_dlt_2g_2057rev3n4 + [pad_gn]; + else if (pi->pubpi.radiorev == 5) + rfpwr_offset = (s16) + nphy_papd_padgain_dlt_2g_2057rev5 + [pad_gn]; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == + 8)) + rfpwr_offset = (s16) + nphy_papd_padgain_dlt_2g_2057rev7 + [pad_gn]; + } else { + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + rfpwr_offset = (s16) + nphy_papd_pgagain_dlt_5g_2057 + [pga_gn]; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == + 8)) + rfpwr_offset = (s16) + nphy_papd_pgagain_dlt_5g_2057rev7 + [pga_gn]; + } + return rfpwr_offset; +} + void wlc_phy_init_nphy(struct brcms_phy *pi) { u16 val; @@ -14714,7 +14752,7 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) u16 idx; s16 pga_gn = 0; s16 pad_gn = 0; - s32 rfpwr_offset = 0; + s32 rfpwr_offset; if (PHY_IPA(pi)) { tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi); @@ -14764,38 +14802,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) for (idx = 0; idx < 128; idx++) { pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; pad_gn = (tx_pwrctrl_tbl[idx] >> 19) & 0x1f; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev3n4 - [pad_gn]; - else if (pi->pubpi.radiorev == 5) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev5 - [pad_gn]; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev7 - [pad_gn]; - } else { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057 - [pga_gn]; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) - rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057rev7 - [pga_gn]; - } + rfpwr_offset = get_rf_pwr_offset(pi, pga_gn, + pad_gn); wlc_phy_table_write_nphy( pi, NPHY_TBL_ID_CORE1TXPWRCTL, @@ -20407,6 +20415,45 @@ wlc_phy_scale_offset_rssi_nphy(struct brcms_phy *pi, u16 scale, s8 offset, write_phy_reg(pi, 0x1bb, valuetostuff); } +static void brcms_phy_wr_tx_mux(struct brcms_phy *pi, u8 core) +{ + if (PHY_IPA(pi)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) + write_radio_reg(pi, + ((core == PHY_CORE_0) ? + RADIO_2057_TX0_TX_SSI_MUX : + RADIO_2057_TX1_TX_SSI_MUX), + (CHSPEC_IS5G(pi->radio_chanspec) ? + 0xc : 0xe)); + else + write_radio_reg(pi, + RADIO_2056_TX_TX_SSI_MUX | + ((core == PHY_CORE_0) ? + RADIO_2056_TX0 : RADIO_2056_TX1), + (CHSPEC_IS5G(pi->radio_chanspec) ? + 0xc : 0xe)); + } else { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + write_radio_reg(pi, + ((core == PHY_CORE_0) ? + RADIO_2057_TX0_TX_SSI_MUX : + RADIO_2057_TX1_TX_SSI_MUX), + 0x11); + + if (pi->pubpi.radioid == BCM2057_ID) + write_radio_reg(pi, + RADIO_2057_IQTEST_SEL_PU, 0x1); + + } else { + write_radio_reg(pi, + RADIO_2056_TX_TX_SSI_MUX | + ((core == PHY_CORE_0) ? + RADIO_2056_TX0 : RADIO_2056_TX1), + 0x11); + } + } +} + void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) { u16 mask, val; @@ -20529,103 +20576,13 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) (core == PHY_CORE_0) ? 0xa6 : 0xa7, mask, val); - - if (PHY_IPA(pi)) { - if (NREV_GE - (pi->pubpi. - phy_rev, - 7)) - write_radio_reg - (pi, - ((core - == - PHY_CORE_0) - ? - RADIO_2057_TX0_TX_SSI_MUX - : - RADIO_2057_TX1_TX_SSI_MUX), - ( - CHSPEC_IS5G - ( - pi - -> - radio_chanspec) - ? - 0xc - : - 0xe)); - else - write_radio_reg - ( - pi, - RADIO_2056_TX_TX_SSI_MUX - | - ((core - == - PHY_CORE_0) - ? - RADIO_2056_TX0 - : - RADIO_2056_TX1), - ( - CHSPEC_IS5G - ( - pi - -> - radio_chanspec) - ? - 0xc - : - 0xe)); - } else { - - if (NREV_GE - (pi->pubpi. - phy_rev, - 7)) { - write_radio_reg - (pi, - ((core - == - PHY_CORE_0) - ? - RADIO_2057_TX0_TX_SSI_MUX - : - RADIO_2057_TX1_TX_SSI_MUX), - 0x11); - - if (pi->pubpi. - radioid == - BCM2057_ID) - write_radio_reg - ( - pi, - RADIO_2057_IQTEST_SEL_PU, - 0x1); - - } else { - write_radio_reg - ( - pi, - RADIO_2056_TX_TX_SSI_MUX - | - ((core - == - PHY_CORE_0) - ? - RADIO_2056_TX0 - : - RADIO_2056_TX1), - 0x11); - } - } - + brcms_phy_wr_tx_mux(pi, core); afectrlovr_rssi_val = 1 << 9; mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x8f - : 0xa5, (0x1 << 9), - afectrlovr_rssi_val); + (core == + PHY_CORE_0) ? 0x8f + : 0xa5, (0x1 << 9), + afectrlovr_rssi_val); } } } @@ -22441,6 +22398,47 @@ void wlc_phy_stopplayback_nphy(struct brcms_phy *pi) wlc_phy_stay_in_carriersearch_nphy(pi, false); } +static u32 *brcms_phy_get_tx_pwrctrl_tbl(struct brcms_phy *pi) +{ + u32 *tx_pwrctrl_tbl = NULL; + uint phyrev = pi->pubpi.phy_rev; + + if (PHY_IPA(pi)) { + tx_pwrctrl_tbl = + wlc_phy_get_ipa_gaintbl_nphy(pi); + } else { + if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (NREV_IS(phyrev, 3)) + tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev3; + else if (NREV_IS(phyrev, 4)) + tx_pwrctrl_tbl = + (pi->srom_fem5g.extpagain == 3) ? + nphy_tpc_5GHz_txgain_HiPwrEPA : + nphy_tpc_5GHz_txgain_rev4; + else + tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev5; + } else { + if (NREV_GE(phyrev, 7)) { + if (pi->pubpi.radiorev == 3) + tx_pwrctrl_tbl = + nphy_tpc_txgain_epa_2057rev3; + else if (pi->pubpi.radiorev == 5) + tx_pwrctrl_tbl = + nphy_tpc_txgain_epa_2057rev5; + } else { + if (NREV_GE(phyrev, 5) && + (pi->srom_fem2g.extpagain == 3)) + tx_pwrctrl_tbl = + nphy_tpc_txgain_HiPwrEPA; + else + tx_pwrctrl_tbl = + nphy_tpc_txgain_rev3; + } + } + } + return tx_pwrctrl_tbl; +} + struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) { u16 base_idx[2], curr_gain[2]; @@ -22497,54 +22495,8 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) base_idx[1] = (read_phy_reg(pi, 0x1ee) >> 8) & 0x7f; for (core_no = 0; core_no < 2; core_no++) { if (NREV_GE(phyrev, 3)) { - if (PHY_IPA(pi)) { - tx_pwrctrl_tbl = - wlc_phy_get_ipa_gaintbl_nphy(pi); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(phyrev, 3)) - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev3; - else if (NREV_IS(phyrev, 4)) - tx_pwrctrl_tbl = - (pi->srom_fem5g - . - extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA - : - nphy_tpc_5GHz_txgain_rev4; - else - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev5; - } else { - if (NREV_GE(phyrev, 7)) { - if (pi->pubpi. - radiorev == 3) - tx_pwrctrl_tbl - = - nphy_tpc_txgain_epa_2057rev3; - else if (pi->pubpi. - radiorev == - 5) - tx_pwrctrl_tbl - = - nphy_tpc_txgain_epa_2057rev5; - } else { - if (NREV_GE(phyrev, 5) - && (pi->srom_fem2g. - extpagain == - 3)) - tx_pwrctrl_tbl - = - nphy_tpc_txgain_HiPwrEPA; - else - tx_pwrctrl_tbl - = - nphy_tpc_txgain_rev3; - } - } - } + tx_pwrctrl_tbl = + brcms_phy_get_tx_pwrctrl_tbl(pi); if (NREV_GE(phyrev, 7)) { target_gain.ipa[core_no] = (tx_pwrctrl_tbl From 98ff86e37d1d1c3ebcaa124dfa9a900eb0e1fa77 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:22 +0200 Subject: [PATCH 0060/1519] staging: brcm80211: fixed build issue for big endian platforms Driver now builds for big endian mips platform, possibly also for other big endian platforms. A change was made to the R_REG and W_REG macro's. These macro's perform an xor (^) operation for endianess swap purposes. Gcc complained because an xor operation is not allowed on a pointer type. Fixed this by casting the pointer to an unsigned long. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.h | 1 + drivers/staging/brcm80211/brcmsmac/types.h | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 3ff109fa3e7..334f2eb3036 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -17,6 +17,7 @@ #ifndef _BRCM_DMA_H_ #define _BRCM_DMA_H_ +#include #include "types.h" /* forward structure declarations */ /* DMA structure: diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index e0880a01fab..ab97718ea47 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -305,11 +305,11 @@ do { \ switch (sizeof(*(r))) { \ case sizeof(u8): \ __osl_v = \ - readb((u8 *)((r)^3)); \ + readb((u8 *)((unsigned long)(r)^3)); \ break; \ case sizeof(u16): \ __osl_v = \ - readw((u16 *)((r)^2)); \ + readw((u16 *)((unsigned long)(r)^2)); \ break; \ case sizeof(u32): \ __osl_v = readl((u32 *)(r)); \ @@ -322,10 +322,10 @@ do { \ switch (sizeof(*(r))) { \ case sizeof(u8): \ writeb((u8)(v), \ - (u8 *)((r)^3)); break; \ + (u8 *)((unsigned long)(r)^3)); break; \ case sizeof(u16): \ writew((u16)(v), \ - (u16 *)((r)^2)); break; \ + (u16 *)((unsigned long)(r)^2)); break; \ case sizeof(u32): \ writel((u32)(v), \ (u32 *)(r)); break; \ From 9e631b8c80bc4f57e1f40ddb02edc98f8cb980a4 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:23 +0200 Subject: [PATCH 0061/1519] staging: brcm80211: remove MIPS specific 'sync' instruction in fullmac This instruction was required for the bcm4716/bcm4322, but since the fullmac driver only supports bcm4329, it could be removed. After that, the R_REG macro's were identical and thus were reduced to just 1 R_REG macro. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8cb34d67348..8224ba49fd2 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -35,26 +35,8 @@ #include "sdio_host.h" /* register access macros */ -#ifndef __BIG_ENDIAN -#ifndef __mips__ #define R_REG(r, typ) \ brcmf_sdcard_reg_read(NULL, (r), sizeof(typ)) -#else /* __mips__ */ -#define R_REG(r, typ) \ - ({ \ - __typeof(*(r)) __osl_v; \ - __asm__ __volatile__("sync"); \ - __osl_v = brcmf_sdcard_reg_read(NULL, (r),\ - sizeof(typ)); \ - __asm__ __volatile__("sync"); \ - __osl_v; \ - }) -#endif /* __mips__ */ - -#else /* __BIG_ENDIAN */ -#define R_REG(r, typ) \ - brcmf_sdcard_reg_read(NULL, (r), sizeof(typ)) -#endif /* __BIG_ENDIAN */ #define OR_REG(r, v, typ) \ brcmf_sdcard_reg_write(NULL, (r), sizeof(typ), R_REG(r, typ) | (v)) From 459f059a44062202717821f50d1edc58bd166eb1 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:24 +0200 Subject: [PATCH 0062/1519] staging: brcm80211: removed R_REG and OR_REG macro's from fullmac Code cleanup. Macro invocations have been substituted with macro expansion. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8224ba49fd2..27a693717fa 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -34,13 +34,6 @@ #include #include "sdio_host.h" -/* register access macros */ -#define R_REG(r, typ) \ - brcmf_sdcard_reg_read(NULL, (r), sizeof(typ)) - -#define OR_REG(r, v, typ) \ - brcmf_sdcard_reg_write(NULL, (r), sizeof(typ), R_REG(r, typ) | (v)) - #ifdef BCMDBG /* ARM trap handling */ @@ -896,7 +889,8 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) { *retryvar = 0; do { - *regvar = R_REG(bus->ci->buscorebase + reg_offset, u32); + *regvar = brcmf_sdcard_reg_read(NULL, + bus->ci->buscorebase + reg_offset, sizeof(u32)); } while (brcmf_sdcard_regfail(bus->card) && (++(*retryvar) <= retry_limit)); if (*retryvar) { @@ -5618,6 +5612,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva, { u8 clkctl = 0; int err = 0; + int reg_addr; + u32 reg_val; bus->alp_only = true; @@ -5684,9 +5680,11 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva, } /* Set core control so an SDIO reset does a backplane reset */ - OR_REG(bus->ci->buscorebase + offsetof(struct sdpcmd_regs, - corecontrol), - CC_BPRESEN, u32); + reg_addr = bus->ci->buscorebase + + offsetof(struct sdpcmd_regs, corecontrol); + reg_val = brcmf_sdcard_reg_read(NULL, reg_addr, sizeof(u32)); + brcmf_sdcard_reg_write(NULL, reg_addr, sizeof(u32), + reg_val | CC_BPRESEN); brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); From 1fda276eb1707ec9cef3d00c293d7cb488af7ca6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:25 +0200 Subject: [PATCH 0063/1519] staging: brcm80211: removed global variable from sdio fullmac Code cleanup. bus->card is assigned in brcmf_sdbrcm_probe (before brcmf_sdbrcm_probe_attach()). Since w_sdreg32() and r_sdreg32() are called only after that assignment, they can safely use bus->card. Thus there is no instance left where brcmf_sdcard_reg_read() or brcmf_sdcard_reg_write() is called with a NULL parameter, so the mechanism in bcmsdh.c that deals with a NULL pointer could be deleted. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 31 ------------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 9 +++--- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index fb3ab638e40..916d41f6a10 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -89,9 +89,6 @@ struct sdio_hc { bool oob_irq_registered; }; -/* local copy of bcm sd handler */ -static struct brcmf_sdio_card *l_card; - const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL; static struct sdio_hc *sdhcinfo; @@ -116,9 +113,6 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq) return NULL; } - /* save the handler locally */ - l_card = card; - card->sdioh = brcmf_sdioh_attach(cfghdl, irq); if (!card->sdioh) { brcmf_sdcard_detach(card); @@ -144,7 +138,6 @@ int brcmf_sdcard_detach(struct brcmf_sdio_card *card) kfree(card); } - l_card = NULL; return 0; } @@ -184,9 +177,6 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, s32 retry = 0; u8 data = 0; - if (!card) - card = l_card; - do { if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); @@ -211,9 +201,6 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, int status; s32 retry = 0; - if (!card) - card = l_card; - do { if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); @@ -235,9 +222,6 @@ u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num, int status; u32 data = 0; - if (!card) - card = l_card; - status = brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_READ, fnc_num, addr, &data, 4); @@ -256,9 +240,6 @@ brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num, { int status; - if (!card) - card = l_card; - status = brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_WRITE, fnc_num, addr, &data, 4); @@ -280,9 +261,6 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis, bool ascii = func & ~0xf; func &= 0x7; - if (!card) - card = l_card; - status = brcmf_sdioh_cis_read(card->sdioh, func, cis, length); if (ascii) { @@ -334,9 +312,6 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr)); - if (!card) - card = l_card; - if (bar0 != card->sbwad) { if (brcmf_sdcard_set_sbaddr_window(card, bar0)) return 0xFFFFFFFF; @@ -386,9 +361,6 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", __func__, addr, size * 8, data)); - if (!card) - card = l_card; - if (bar0 != card->sbwad) { err = brcmf_sdcard_set_sbaddr_window(card, bar0); if (err) @@ -522,9 +494,6 @@ int brcmf_sdcard_query_device(struct brcmf_sdio_card *card) u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) { - if (!card) - card = l_card; - return card->sbwad; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 27a693717fa..d02bcc76894 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -889,7 +889,7 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) { *retryvar = 0; do { - *regvar = brcmf_sdcard_reg_read(NULL, + *regvar = brcmf_sdcard_reg_read(bus->card, bus->ci->buscorebase + reg_offset, sizeof(u32)); } while (brcmf_sdcard_regfail(bus->card) && (++(*retryvar) <= retry_limit)); @@ -907,7 +907,8 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) { *retryvar = 0; do { - brcmf_sdcard_reg_write(NULL, bus->ci->buscorebase + reg_offset, + brcmf_sdcard_reg_write(bus->card, + bus->ci->buscorebase + reg_offset, sizeof(u32), regval); } while (brcmf_sdcard_regfail(bus->card) && (++(*retryvar) <= retry_limit)); @@ -5682,8 +5683,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva, /* Set core control so an SDIO reset does a backplane reset */ reg_addr = bus->ci->buscorebase + offsetof(struct sdpcmd_regs, corecontrol); - reg_val = brcmf_sdcard_reg_read(NULL, reg_addr, sizeof(u32)); - brcmf_sdcard_reg_write(NULL, reg_addr, sizeof(u32), + reg_val = brcmf_sdcard_reg_read(bus->card, reg_addr, sizeof(u32)); + brcmf_sdcard_reg_write(bus->card, reg_addr, sizeof(u32), reg_val | CC_BPRESEN); brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); From 3f7e0c5df5910157441b680622447c903436f04a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:26 +0200 Subject: [PATCH 0064/1519] staging: brcm80211: replace simple_strtoul usage in brcmsmac The usage of simple_strtoul is not preferred. Instead kstrtoul should be used. This patch fixes this for the brcmsmac driver. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 16 +++++++++------- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 5c97778c1db..001a1f77e69 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4287,16 +4287,17 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, #endif if (bustype != SI_BUS) { char *var; + unsigned long res; var = getvar(vars, "vendid"); - if (var) { - vendor = (u16) simple_strtoul(var, NULL, 0); + if (var && !kstrtoul(var, 0, &res)) { + vendor = (u16)res; wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", vendor); } var = getvar(vars, "devid"); - if (var) { - u16 devid = (u16) simple_strtoul(var, NULL, 0); + if (var && !kstrtoul(var, 0, &res)) { + u16 devid = (u16)res; if (devid != 0xffff) { device = devid; wiphy_err(wiphy, "Overriding device id = 0x%x" @@ -9596,10 +9597,11 @@ char *getvar(char *vars, const char *name) int getintvar(char *vars, const char *name) { char *val; + unsigned long res; val = getvar(vars, name); - if (val == NULL) - return 0; + if (val && !kstrtoul(val, 0, &res)) + return res; - return simple_strtoul(val, NULL, 0); + return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 582df4a248b..22f7bfc79dd 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -174,12 +174,13 @@ char *phy_getvar(struct brcms_phy *pi, const char *name) int phy_getintvar(struct brcms_phy *pi, const char *name) { char *val; + unsigned long res; val = PHY_GETVAR(pi, name); - if (val == NULL) - return 0; + if (val && !kstrtoul(val, 0, &res)) + return res; - return simple_strtoul(val, NULL, 0); + return 0; } void wlc_phyreg_enter(struct brcms_phy_pub *pih) From 5744955061e4a9617110bcb3e7250db7718857cf Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:27 +0200 Subject: [PATCH 0065/1519] staging: brcm80211: remove private timeout functions in fullmac Use kernel timer macros to replace current private timeout functions used in dhd_sdio.c Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 10 ---- .../staging/brcm80211/brcmfmac/dhd_linux.c | 58 ------------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 18 +++--- 3 files changed, 11 insertions(+), 75 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index f3633fe1a1c..1fe9d69e100 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -614,13 +614,6 @@ struct brcmf_if_event { u8 bssidx; }; -struct brcmf_timeout { - u32 limit; /* Expiration time (usec) */ - u32 increment; /* Current expiration increment (usec) */ - u32 elapsed; /* Current elapsed time (usec) */ - u32 tick; /* O/S tick time (usec) */ -}; - struct bcmevent_name { uint event; const char *name; @@ -783,9 +776,6 @@ extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr); extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size); #endif /* BCMDBG */ -extern void brcmf_timeout_start(struct brcmf_timeout *tmo, uint usec); -extern int brcmf_timeout_expired(struct brcmf_timeout *tmo); - extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name); extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, void *pktdata, struct brcmf_event_msg *, diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 0d868190db8..07ceaf9243b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -143,64 +143,6 @@ static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktd struct brcmf_event_msg *event_ptr, void **data_ptr); -/* - * Generalized timeout mechanism. Uses spin sleep with exponential - * back-off until - * the sleep time reaches one jiffy, then switches over to task delay. Usage: - * - * brcmf_timeout_start(&tmo, usec); - * while (!brcmf_timeout_expired(&tmo)) - * if (poll_something()) - * break; - * if (brcmf_timeout_expired(&tmo)) - * fatal(); - */ - -void brcmf_timeout_start(struct brcmf_timeout *tmo, uint usec) -{ - tmo->limit = usec; - tmo->increment = 0; - tmo->elapsed = 0; - tmo->tick = 1000000 / HZ; -} - -int brcmf_timeout_expired(struct brcmf_timeout *tmo) -{ - /* Does nothing the first call */ - if (tmo->increment == 0) { - tmo->increment = 1; - return 0; - } - - if (tmo->elapsed >= tmo->limit) - return 1; - - /* Add the delay that's about to take place */ - tmo->elapsed += tmo->increment; - - if (tmo->increment < tmo->tick) { - udelay(tmo->increment); - tmo->increment *= 2; - if (tmo->increment > tmo->tick) - tmo->increment = tmo->tick; - } else { - wait_queue_head_t delay_wait; - DECLARE_WAITQUEUE(wait, current); - int pending; - init_waitqueue_head(&delay_wait); - add_wait_queue(&delay_wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - pending = signal_pending(current); - remove_wait_queue(&delay_wait, &wait); - set_current_state(TASK_RUNNING); - if (pending) - return 1; /* Interrupted */ - } - - return 0; -} - static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net) { int i = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index d02bcc76894..7a0d036b1ef 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -3306,7 +3306,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) { struct brcmf_bus *bus = drvr->bus; - struct brcmf_timeout tmo; + unsigned long timeout; uint retries = 0; u8 ready, enable; int err, ret = 0; @@ -3358,16 +3358,20 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable, NULL); - /* Give the dongle some time to do its thing and set IOR2 */ - brcmf_timeout_start(&tmo, BRCMF_WAIT_F2RDY * 1000); - + timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); ready = 0; - while (ready != enable && !brcmf_timeout_expired(&tmo)) + while (enable != ready) { ready = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_0, SDIO_CCCR_IORx, NULL); + if (time_after(jiffies, timeout)) + break; + else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50)) + /* prevent busy waiting if it takes too long */ + msleep_interruptible(20); + } - BRCMF_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n", - __func__, enable, ready, tmo.elapsed)); + BRCMF_INFO(("%s: enable 0x%02x, ready 0x%02x\n", + __func__, enable, ready)); /* If F2 successfully enabled, set core and enable interrupts */ if (ready == enable) { From a9b977183727004e9f5bf38f45fe4d1e98d42d60 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:28 +0200 Subject: [PATCH 0066/1519] staging: brcm80211: move brcmf_mmc_suspend to sdio layer in fullmac brcmf_mmc_suspend is used for sdio suspend/resume function. Hence it should be placed in sdio interface layer. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 38 ++++++++++++++----- drivers/staging/brcm80211/brcmfmac/dhd.h | 17 --------- .../staging/brcm80211/brcmfmac/dhd_linux.c | 8 ---- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 8 ---- 4 files changed, 28 insertions(+), 43 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index bfe73eefbfd..d6f0f921e56 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -143,6 +143,7 @@ module_param(clockoverride, int, 0644); MODULE_PARM_DESC(clockoverride, "SDIO card clock override"); struct brcmf_sdmmc_instance *gInstance; +static atomic_t brcmf_mmc_suspend; struct device sdmmc_dev; @@ -157,31 +158,44 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = { { /* end: all zeroes */ }, }; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static const struct dev_pm_ops brcmf_sdio_pm_ops = { .suspend = brcmf_sdio_suspend, .resume = brcmf_sdio_resume, }; -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct sdio_driver brcmf_sdmmc_driver = { .probe = brcmf_ops_sdio_probe, .remove = brcmf_ops_sdio_remove, .name = "brcmfmac", .id_table = brcmf_sdmmc_ids, -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .drv = { .pm = &brcmf_sdio_pm_ops, }, -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ }; MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); -BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_byte_wait); -BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_word_wait); -BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_packet_wait); -BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait); +#ifdef CONFIG_PM_SLEEP +DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); +DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); +DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); +DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); +#define BRCMF_PM_RESUME_WAIT(a) do { \ + int retry = 0; \ + while (atomic_read(&brcmf_mmc_suspend) && retry++ != 30) { \ + wait_event_timeout(a, false, HZ/100); \ + } \ + } while (0) +#define BRCMF_PM_RESUME_RETURN_ERROR(a) \ + do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0) +#else +#define BRCMF_PM_RESUME_WAIT(a) +#define BRCMF_PM_RESUME_RETURN_ERROR(a) +#endif /* CONFIG_PM_SLEEP */ static int brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, @@ -1049,6 +1063,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sd_trace(("NIC found, calling brcmf_sdio_probe...\n")); ret = brcmf_sdio_probe(&sdmmc_dev); } + atomic_set(&brcmf_mmc_suspend, false); } gInstance->func[func->num] = func; @@ -1077,7 +1092,7 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int brcmf_sdio_suspend(struct device *dev) { mmc_pm_flag_t sdio_flags; @@ -1085,6 +1100,8 @@ static int brcmf_sdio_suspend(struct device *dev) sd_trace(("%s\n", __func__)); + atomic_set(&brcmf_mmc_suspend, true); + sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { sd_err(("Host can't keep power while suspended\n")); @@ -1105,9 +1122,10 @@ static int brcmf_sdio_suspend(struct device *dev) static int brcmf_sdio_resume(struct device *dev) { brcmf_sdio_wdtmr_enable(true); + atomic_set(&brcmf_mmc_suspend, false); return 0; } -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ int brcmf_sdioh_osinit(struct sdioh_info *sd) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 1fe9d69e100..9afd9ff3f98 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -620,18 +620,6 @@ struct bcmevent_name { }; #if defined(CONFIG_PM_SLEEP) -extern atomic_t brcmf_mmc_suspend; -#define BRCMF_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a); -#define _BRCMF_PM_RESUME_WAIT(a, b) do { \ - int retry = 0; \ - while (atomic_read(&brcmf_mmc_suspend) && retry++ != b) { \ - wait_event_timeout(a, false, HZ/100); \ - } \ - } while (0) -#define BRCMF_PM_RESUME_WAIT(a) _BRCMF_PM_RESUME_WAIT(a, 30) -#define BRCMF_PM_RESUME_RETURN_ERROR(a) \ - do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0) - #define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a); #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \ uint countdown = (us) + 9999; \ @@ -642,11 +630,6 @@ extern atomic_t brcmf_mmc_suspend; } while (0) #else - -#define BRCMF_PM_RESUME_WAIT_INIT(a) -#define BRCMF_PM_RESUME_WAIT(a) -#define BRCMF_PM_RESUME_RETURN_ERROR(a) - #define BRCMF_SPINWAIT_SLEEP_INIT(a) #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \ uint countdown = (us) + 9; \ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 07ceaf9243b..9dc327b21a3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -43,11 +43,6 @@ #include "wl_cfg80211.h" #include "bcmchip.h" -#if defined(CONFIG_PM_SLEEP) -#include -atomic_t brcmf_mmc_suspend; -#endif /* defined(CONFIG_PM_SLEEP) */ - MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver."); MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards"); @@ -1274,9 +1269,6 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) */ memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv)); -#if defined(CONFIG_PM_SLEEP) - atomic_set(&brcmf_mmc_suspend, false); -#endif /* defined(CONFIG_PM_SLEEP) */ return &drvr_priv->pub; fail: diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 440ae6d43e3..02137ac1838 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2102,10 +2102,6 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy) */ WL_TRACE("Enter\n"); -#if defined(CONFIG_PM_SLEEP) - atomic_set(&brcmf_mmc_suspend, false); -#endif /* defined(CONFIG_PM_SLEEP) */ - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) brcmf_invoke_iscan(wiphy_to_cfg(wiphy)); @@ -2167,10 +2163,6 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, brcmf_set_mpc(ndev, 1); } -#if defined(CONFIG_PM_SLEEP) - atomic_set(&brcmf_mmc_suspend, true); -#endif /* defined(CONFIG_PM_SLEEP) */ - WL_TRACE("Exit\n"); return 0; From 45fda7d2fdcb10d09fd5498491212be6ffcf91e1 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:29 +0200 Subject: [PATCH 0067/1519] staging: brcm80211: remove global wait queue head sdioh_spinwait_sleep Remove global wait queue head sdioh_spinwait_sleep in fullmac. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 22 ------------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 21 +++++++++--------- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 9afd9ff3f98..3c950cc5b7f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -619,28 +619,6 @@ struct bcmevent_name { const char *name; }; -#if defined(CONFIG_PM_SLEEP) -#define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a); -#define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \ - uint countdown = (us) + 9999; \ - while ((exp) && (countdown >= 10000)) { \ - wait_event_timeout(a, false, HZ/100); \ - countdown -= 10000; \ - } \ - } while (0) - -#else -#define BRCMF_SPINWAIT_SLEEP_INIT(a) -#define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \ - uint countdown = (us) + 9; \ - while ((exp) && (countdown >= 10)) { \ - udelay(10); \ - countdown -= 10; \ - } \ - } while (0) - -#endif /* defined(CONFIG_PM_SLEEP) */ - /* * Insmod parameters for debug/test */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 7a0d036b1ef..e9806c3c1f8 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -444,8 +444,6 @@ struct rte_console { (((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? \ ((prio^2)) : (prio)) -BRCMF_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep); - /* * Core reg address translation. * Both macro's returns a 32 bits byte address on the backplane bus. @@ -1033,6 +1031,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) int err; u8 clkctl, clkreq, devctl; struct brcmf_sdio_card *card; + unsigned long timeout; BRCMF_TRACE(("%s: Enter\n", __func__)); @@ -1102,14 +1101,16 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) } /* Otherwise, wait here (polling) for HT Avail */ - if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { - BRCMF_SPINWAIT_SLEEP(sdioh_spinwait_sleep, - ((clkctl = - brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - &err)), - !SBSDIO_CLKAV(clkctl, bus->alp_only)), - PMU_MAX_TRANSITION_DLY); + timeout = jiffies + + msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000); + while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { + clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + &err); + if (time_after(jiffies, timeout)) + break; + else + usleep_range(5000, 10000); } if (err) { BRCMF_ERROR(("%s: HT Avail request error: %d\n", From 4dad25300b2326e2903a5f05e99f4890c1549d45 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:30 +0200 Subject: [PATCH 0068/1519] staging: brcm80211: remove code for unsupported chip Currently fullmac only support bcm4329. Remove dead code for unsupported chip. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 40 +------------------ drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 17 +------- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index d6f0f921e56..846b6beff5a 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -34,36 +34,17 @@ #include "dhd_dbg.h" #include "wl_cfg80211.h" -#define BLOCK_SIZE_64 64 -#define BLOCK_SIZE_512 512 -#define BLOCK_SIZE_4318 64 -#define BLOCK_SIZE_4328 512 - -/* private bus modes */ -#define SDIOH_MODE_SD4 2 - #define CLIENT_INTR 0x100 /* Get rid of this! */ #if !defined(SDIO_VENDOR_ID_BROADCOM) #define SDIO_VENDOR_ID_BROADCOM 0x02d0 #endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */ -#define SDIO_DEVICE_ID_BROADCOM_DEFAULT 0x0000 - #define DMA_ALIGN_MASK 0x03 -#if !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) -#define SDIO_DEVICE_ID_BROADCOM_4325_SDGWB 0x0492 /* BCM94325SDGWB */ -#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) */ -#if !defined(SDIO_DEVICE_ID_BROADCOM_4325) -#define SDIO_DEVICE_ID_BROADCOM_4325 0x0493 -#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */ #if !defined(SDIO_DEVICE_ID_BROADCOM_4329) #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ -#if !defined(SDIO_DEVICE_ID_BROADCOM_4319) -#define SDIO_DEVICE_ID_BROADCOM_4319 0x4319 -#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ /* Common msglevel constants */ #define SDH_ERROR_VAL 0x0001 /* Error */ @@ -136,12 +117,6 @@ uint sd_f2_blocksize = 512; /* Default blocksize */ uint sd_msglevel = 0x01; -/* module param defaults */ -static int clockoverride; - -module_param(clockoverride, int, 0644); -MODULE_PARM_DESC(clockoverride, "SDIO card clock override"); - struct brcmf_sdmmc_instance *gInstance; static atomic_t brcmf_mmc_suspend; @@ -149,12 +124,7 @@ struct device sdmmc_dev; /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { - {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_DEFAULT)}, - {SDIO_DEVICE - (SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)}, - {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325)}, {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, - {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4319)}, { /* end: all zeroes */ }, }; @@ -498,10 +468,10 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, maxsize = 32; break; case 1: - maxsize = BLOCK_SIZE_4318; + maxsize = 64; break; case 2: - maxsize = BLOCK_SIZE_4328; + maxsize = 512; break; default: maxsize = 0; @@ -1058,12 +1028,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdio_func_0.num = 0; sdio_func_0.card = func->card; gInstance->func[0] = &sdio_func_0; - if (func->device == 0x4) { /* 4318 */ - gInstance->func[2] = NULL; - sd_trace(("NIC found, calling brcmf_sdio_probe...\n")); - ret = brcmf_sdio_probe(&sdmmc_dev); - } - atomic_set(&brcmf_mmc_suspend, false); } gInstance->func[func->num] = func; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index e9806c3c1f8..fe114788676 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1273,8 +1273,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); /* Isolate the bus */ - if (bus->ci->chip != BCM4329_CHIP_ID - && bus->ci->chip != BCM4319_CHIP_ID) { + if (bus->ci->chip != BCM4329_CHIP_ID) { brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, SBSDIO_DEVCTL_PADS_ISO, NULL); @@ -5401,12 +5400,8 @@ done: static bool brcmf_sdbrcm_chipmatch(u16 chipid) { - if (chipid == BCM4325_CHIP_ID) - return true; if (chipid == BCM4329_CHIP_ID) return true; - if (chipid == BCM4319_CHIP_ID) - return true; return false; } @@ -5461,22 +5456,12 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, /* Check the Device ID and make sure it's one that we support */ switch (devid) { - case BCM4325_D11DUAL_ID: /* 4325 802.11a/g id */ - case BCM4325_D11G_ID: /* 4325 802.11g 2.4Ghz band id */ - case BCM4325_D11A_ID: /* 4325 802.11a 5Ghz band id */ - BRCMF_INFO(("%s: found 4325 Dongle\n", __func__)); - break; case BCM4329_D11NDUAL_ID: /* 4329 802.11n dualband device */ case BCM4329_D11N2G_ID: /* 4329 802.11n 2.4G device */ case BCM4329_D11N5G_ID: /* 4329 802.11n 5G device */ case 0x4329: BRCMF_INFO(("%s: found 4329 Dongle\n", __func__)); break; - case BCM4319_D11N_ID: /* 4319 802.11n id */ - case BCM4319_D11N2G_ID: /* 4319 802.11n2g id */ - case BCM4319_D11N5G_ID: /* 4319 802.11n5g id */ - BRCMF_INFO(("%s: found 4319 Dongle\n", __func__)); - break; case 0: BRCMF_INFO(("%s: allow device id 0, will check chip" " internals\n", __func__)); From e38a80cc29ce821cf0d359891c363616507b8db5 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:31 +0200 Subject: [PATCH 0069/1519] staging: brcm80211: get rid of sd debug message macro in fullmac Use BRCMF_* instead of sd_* as debug message interface Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 2 - .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 222 +++++++----------- .../staging/brcm80211/brcmfmac/sdio_host.h | 1 - 3 files changed, 82 insertions(+), 143 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 916d41f6a10..310d4fd8c25 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -98,8 +98,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; /* Module parameters specific to each host-controller driver */ -module_param(sd_msglevel, uint, 0); - module_param(sd_f2_blocksize, int, 0); struct brcmf_sdio_card* diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 846b6beff5a..4ffd934377d 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -46,56 +46,6 @@ #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ -/* Common msglevel constants */ -#define SDH_ERROR_VAL 0x0001 /* Error */ -#define SDH_TRACE_VAL 0x0002 /* Trace */ -#define SDH_INFO_VAL 0x0004 /* Info */ -#define SDH_DEBUG_VAL 0x0008 /* Debug */ -#define SDH_DATA_VAL 0x0010 /* Data */ -#define SDH_CTRL_VAL 0x0020 /* Control Regs */ -#define SDH_LOG_VAL 0x0040 /* Enable bcmlog */ -#define SDH_DMA_VAL 0x0080 /* DMA */ - -#ifdef BCMDBG -#define sd_err(x) \ - do { \ - if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#define sd_trace(x) \ - do { \ - if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#define sd_info(x) \ - do { \ - if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#define sd_debug(x) \ - do { \ - if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#define sd_data(x) \ - do { \ - if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#define sd_ctrl(x) \ - do { \ - if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) \ - printk x; \ - } while (0) -#else -#define sd_err(x) -#define sd_trace(x) -#define sd_info(x) -#define sd_debug(x) -#define sd_data(x) -#define sd_ctrl(x) -#endif - struct sdos_info { struct sdioh_info *sd; spinlock_t lock; @@ -115,8 +65,6 @@ static int brcmf_sdio_resume(struct device *dev); uint sd_f2_blocksize = 512; /* Default blocksize */ -uint sd_msglevel = 0x01; - struct brcmf_sdmmc_instance *gInstance; static atomic_t brcmf_mmc_suspend; @@ -177,12 +125,12 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) u32 fbraddr; u8 func; - sd_trace(("%s\n", __func__)); + BRCMF_TRACE(("%s\n", __func__)); /* Get the Card's common CIS address */ sd->com_cis_ptr = brcmf_sdioh_get_cisaddr(sd, SDIO_CCCR_CIS); sd->func_cis_ptr[0] = sd->com_cis_ptr; - sd_info(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, + BRCMF_INFO(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, sd->com_cis_ptr)); /* Get the Card's function CIS (for each function) */ @@ -190,12 +138,12 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) func <= sd->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { sd->func_cis_ptr[func] = brcmf_sdioh_get_cisaddr(sd, SDIO_FBR_CIS + fbraddr); - sd_info(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func, + BRCMF_INFO(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func, sd->func_cis_ptr[func])); } sd->func_cis_ptr[0] = sd->com_cis_ptr; - sd_info(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, + BRCMF_INFO(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, sd->com_cis_ptr)); /* Enable Function 1 */ @@ -203,7 +151,7 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) err_ret = sdio_enable_func(gInstance->func[1]); sdio_release_host(gInstance->func[1]); if (err_ret) - sd_err(("brcmf_sdioh_enablefuncs: Failed to enable F1 " + BRCMF_ERROR(("brcmf_sdioh_enablefuncs: Failed to enable F1 " "Err: 0x%08x\n", err_ret)); return false; @@ -217,20 +165,20 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) struct sdioh_info *sd; int err_ret; - sd_trace(("%s\n", __func__)); + BRCMF_TRACE(("%s\n", __func__)); if (gInstance == NULL) { - sd_err(("%s: SDIO Device not present\n", __func__)); + BRCMF_ERROR(("%s: SDIO Device not present\n", __func__)); return NULL; } sd = kzalloc(sizeof(struct sdioh_info), GFP_ATOMIC); if (sd == NULL) { - sd_err(("sdioh_attach: out of memory\n")); + BRCMF_ERROR(("sdioh_attach: out of memory\n")); return NULL; } if (brcmf_sdioh_osinit(sd) != 0) { - sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__)); + BRCMF_ERROR(("%s:sdioh_sdmmc_osinit() failed\n", __func__)); kfree(sd); return NULL; } @@ -247,7 +195,7 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) sd->client_block_size[1] = 64; err_ret = sdio_set_block_size(gInstance->func[1], 64); if (err_ret) - sd_err(("brcmf_sdioh_attach: Failed to set F1 blocksize\n")); + BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); /* Release host controller F1 */ sdio_release_host(gInstance->func[1]); @@ -260,8 +208,8 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) err_ret = sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); if (err_ret) - sd_err(("brcmf_sdioh_attach: Failed to set F2 blocksize" - " to %d\n", sd_f2_blocksize)); + BRCMF_ERROR(("%s: Failed to set F2 blocksize" + " to %d\n", __func__, sd_f2_blocksize)); /* Release host controller F2 */ sdio_release_host(gInstance->func[2]); @@ -269,13 +217,13 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) brcmf_sdioh_enablefuncs(sd); - sd_trace(("%s: Done\n", __func__)); + BRCMF_TRACE(("%s: Done\n", __func__)); return sd; } extern int brcmf_sdioh_detach(struct sdioh_info *sd) { - sd_trace(("%s\n", __func__)); + BRCMF_TRACE(("%s\n", __func__)); if (sd) { @@ -302,9 +250,9 @@ extern int brcmf_sdioh_interrupt_register(struct sdioh_info *sd, void (*fn)(void *), void *argh) { - sd_trace(("%s: Entering\n", __func__)); + BRCMF_TRACE(("%s: Entering\n", __func__)); if (fn == NULL) { - sd_err(("%s: interrupt handler is NULL, not registering\n", + BRCMF_ERROR(("%s: interrupt handler is NULL, not registering\n", __func__)); return -EINVAL; } @@ -331,7 +279,7 @@ brcmf_sdioh_interrupt_register(struct sdioh_info *sd, void (*fn)(void *), extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) { - sd_trace(("%s: Entering\n", __func__)); + BRCMF_TRACE(("%s: Entering\n", __func__)); if (gInstance->func[1]) { /* register and unmask irq */ @@ -367,7 +315,6 @@ enum { }; const struct brcmu_iovar sdioh_iovars[] = { - {"sd_msglevel", IOV_MSGLEVEL, 0, IOVT_UINT32, 0}, {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0},/* ((fn << 16) | size) */ {"sd_ints", IOV_USEINTS, 0, IOVT_BOOL, 0}, @@ -401,7 +348,7 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, if (!set && !(arg && len)) return -EINVAL; - sd_trace(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), + BRCMF_TRACE(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), name)); vi = brcmu_iovar_lookup(sdioh_iovars, name); @@ -434,15 +381,6 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); switch (actionid) { - case IOV_GVAL(IOV_MSGLEVEL): - int_val = (s32) sd_msglevel; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_MSGLEVEL): - sd_msglevel = int_val; - break; - case IOV_GVAL(IOV_BLOCKSIZE): if ((u32) int_val > si->num_funcs) { bcmerror = -EINVAL; @@ -580,7 +518,7 @@ static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr) for (i = 0; i < 3; i++) { if ((brcmf_sdioh_card_regread(sd, 0, regaddr, 1, ®data)) != SUCCESS) - sd_err(("%s: Can't read!\n", __func__)); + BRCMF_ERROR(("%s: Can't read!\n", __func__)); *ptr++ = (u8) regdata; regaddr++; @@ -600,21 +538,21 @@ brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length) u32 foo; u8 *cis = cisd; - sd_trace(("%s: Func = %d\n", __func__, func)); + BRCMF_TRACE(("%s: Func = %d\n", __func__, func)); if (!sd->func_cis_ptr[func]) { memset(cis, 0, length); - sd_err(("%s: no func_cis_ptr[%d]\n", __func__, func)); + BRCMF_ERROR(("%s: no func_cis_ptr[%d]\n", __func__, func)); return -ENOTSUPP; } - sd_err(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func, + BRCMF_ERROR(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func, sd->func_cis_ptr[func])); for (count = 0; count < length; count++) { offset = sd->func_cis_ptr[func] + count; if (brcmf_sdioh_card_regread(sd, 0, offset, 1, &foo) < 0) { - sd_err(("%s: regread failed: Can't read CIS\n", + BRCMF_ERROR(("%s: regread failed: Can't read CIS\n", __func__)); return -EIO; } @@ -632,7 +570,7 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, { int err_ret; - sd_info(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, + BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, regaddr)); BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait); @@ -652,7 +590,8 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, sdio_enable_func (gInstance->func[2]); if (err_ret) - sd_err(("request_byte: " + BRCMF_ERROR(( + "request_byte: " "enable F2 " "failed:%d\n", err_ret)); @@ -662,7 +601,8 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, sdio_disable_func (gInstance->func[2]); if (err_ret) - sd_err(("request_byte: " + BRCMF_ERROR(( + "request_byte: " "Disab F2 " "failed:%d\n", err_ret)); @@ -683,7 +623,7 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, regaddr, &err_ret); sdio_release_host(gInstance->func[func]); } else if (regaddr < 0xF0) { - sd_err(("brcmf: F0 Wr:0x%02x: write " + BRCMF_ERROR(("brcmf: F0 Wr:0x%02x: write " "disallowed\n", regaddr)); } else { /* Claim host controller, perform F0 write, @@ -719,7 +659,7 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, } if (err_ret) - sd_err(("brcmf: Failed to %s byte F%d:@0x%05x=%02x, " + BRCMF_ERROR(("brcmf: Failed to %s byte F%d:@0x%05x=%02x, " "Err: %d\n", rw ? "Write" : "Read", func, regaddr, *byte, err_ret)); @@ -733,11 +673,11 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, int err_ret = -EIO; if (func == 0) { - sd_err(("%s: Only CMD52 allowed to F0.\n", __func__)); + BRCMF_ERROR(("%s: Only CMD52 allowed to F0.\n", __func__)); return -EINVAL; } - sd_info(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", + BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", __func__, cmd_type, rw, func, addr, nbytes)); BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait); @@ -753,7 +693,8 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, sdio_writew(gInstance->func[func], (*word & 0xFFFF), addr, &err_ret); else - sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); + BRCMF_ERROR(("%s: Invalid nbytes: %d\n", + __func__, nbytes)); } else { /* CMD52 Read */ if (nbytes == 4) *word = @@ -763,14 +704,15 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, sdio_readw(gInstance->func[func], addr, &err_ret) & 0xFFFF; else - sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); + BRCMF_ERROR(("%s: Invalid nbytes: %d\n", + __func__, nbytes)); } /* Release host controller */ sdio_release_host(gInstance->func[func]); if (err_ret) - sd_err(("brcmf: Failed to %s word, Err: 0x%08x\n", + BRCMF_ERROR(("brcmf: Failed to %s word, Err: 0x%08x\n", rw ? "Write" : "Read", err_ret)); return err_ret; @@ -786,7 +728,7 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, struct sk_buff *pnext; - sd_trace(("%s: Enter\n", __func__)); + BRCMF_TRACE(("%s: Enter\n", __func__)); BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait); BRCMF_PM_RESUME_RETURN_ERROR(-EIO); @@ -817,15 +759,15 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, } if (err_ret) { - sd_err(("%s: %s FAILED %p[%d], addr=0x%05x, pkt_len=%d," - "ERR=0x%08x\n", __func__, + BRCMF_ERROR(("%s: %s FAILED %p[%d], addr=0x%05x, " + "pkt_len=%d, ERR=0x%08x\n", __func__, (write) ? "TX" : "RX", pnext, SGCount, addr, pkt_len, err_ret)); } else { - sd_trace(("%s: %s xfr'd %p[%d], addr=0x%05x, len=%d\n", - __func__, - (write) ? "TX" : "RX", - pnext, SGCount, addr, pkt_len)); + BRCMF_TRACE(("%s: %s xfr'd %p[%d], addr=0x%05x, " + "len=%d\n", __func__, + (write) ? "TX" : "RX", + pnext, SGCount, addr, pkt_len)); } if (!fifo) @@ -837,7 +779,7 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, /* Release host controller */ sdio_release_host(gInstance->func[func]); - sd_trace(("%s: Exit\n", __func__)); + BRCMF_TRACE(("%s: Exit\n", __func__)); return err_ret; } @@ -864,18 +806,18 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, int Status; struct sk_buff *mypkt = NULL; - sd_trace(("%s: Enter\n", __func__)); + BRCMF_TRACE(("%s: Enter\n", __func__)); BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait); BRCMF_PM_RESUME_RETURN_ERROR(-EIO); /* Case 1: we don't have a packet. */ if (pkt == NULL) { - sd_data(("%s: Creating new %s Packet, len=%d\n", + BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n", __func__, write ? "TX" : "RX", buflen_u)); mypkt = brcmu_pkt_buf_get_skb(buflen_u); if (!mypkt) { - sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n", - __func__, buflen_u)); + BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed: " + "len %d\n", __func__, buflen_u)); return -EIO; } @@ -896,12 +838,12 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, * Case 2: We have a packet, but it is unaligned. * In this case, we cannot have a chain (pkt->next == NULL) */ - sd_data(("%s: Creating aligned %s Packet, len=%d\n", + BRCMF_DATA(("%s: Creating aligned %s Packet, len=%d\n", __func__, write ? "TX" : "RX", pkt->len)); mypkt = brcmu_pkt_buf_get_skb(pkt->len); if (!mypkt) { - sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n", - __func__, pkt->len)); + BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed: " + "len %d\n", __func__, pkt->len)); return -EIO; } @@ -919,7 +861,7 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, brcmu_pkt_buf_free_skb(mypkt); } else { /* case 3: We have a packet and it is aligned. */ - sd_data(("%s: Aligned %s Packet, direct DMA\n", + BRCMF_DATA(("%s: Aligned %s Packet, direct DMA\n", __func__, write ? "Tx" : "Rx")); Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, addr, pkt); @@ -932,27 +874,27 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func) { char t_func = (char)func; - sd_trace(("%s: Enter\n", __func__)); + BRCMF_TRACE(("%s: Enter\n", __func__)); /* issue abort cmd52 command through F0 */ brcmf_sdioh_request_byte(sd, SDIOH_WRITE, SDIO_FUNC_0, SDIO_CCCR_ABORT, &t_func); - sd_trace(("%s: Exit\n", __func__)); + BRCMF_TRACE(("%s: Exit\n", __func__)); return 0; } /* Disable device interrupt */ void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd) { - sd_trace(("%s: %d\n", __func__, sd->use_client_ints)); + BRCMF_TRACE(("%s: %d\n", __func__, sd->use_client_ints)); sd->intmask &= ~CLIENT_INTR; } /* Enable device interrupt */ void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd) { - sd_trace(("%s: %d\n", __func__, sd->use_client_ints)); + BRCMF_TRACE(("%s: %d\n", __func__, sd->use_client_ints)); sd->intmask |= CLIENT_INTR; } @@ -968,14 +910,14 @@ brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, brcmf_sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp); *data = temp; *data &= 0xff; - sd_data(("%s: byte read data=0x%02x\n", __func__, *data)); + BRCMF_DATA(("%s: byte read data=0x%02x\n", __func__, *data)); } else { brcmf_sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, data, regsize); if (regsize == 2) *data &= 0xffff; - sd_data(("%s: word read data=0x%08x\n", __func__, *data)); + BRCMF_DATA(("%s: word read data=0x%08x\n", __func__, *data)); } return SUCCESS; @@ -985,7 +927,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) { struct sdioh_info *sd; - sd_trace(("brcmf: ***IRQHandler\n")); + BRCMF_TRACE(("brcmf: ***IRQHandler\n")); sd = gInstance->sd; sdio_release_host(gInstance->func[0]); @@ -994,9 +936,9 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) sd->intrcount++; (sd->intr_handler) (sd->intr_handler_arg); } else { - sd_err(("brcmf: ***IRQHandler\n")); + BRCMF_ERROR(("brcmf: ***IRQHandler\n")); - sd_err(("%s: Not ready for intr: enabled %d, handler %p\n", + BRCMF_ERROR(("%s: Not ready for intr: enabled %d, handler %p\n", __func__, sd->client_intr_enabled, sd->intr_handler)); } @@ -1008,7 +950,7 @@ static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func) { struct sdioh_info *sd; - sd_trace(("brcmf: ***IRQHandlerF2\n")); + BRCMF_TRACE(("brcmf: ***IRQHandlerF2\n")); sd = gInstance->sd; } @@ -1018,11 +960,11 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, { int ret = 0; static struct sdio_func sdio_func_0; - sd_trace(("sdio_probe: %s Enter\n", __func__)); - sd_trace(("sdio_probe: func->class=%x\n", func->class)); - sd_trace(("sdio_vendor: 0x%04x\n", func->vendor)); - sd_trace(("sdio_device: 0x%04x\n", func->device)); - sd_trace(("Function#: 0x%04x\n", func->num)); + BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__)); + BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class)); + BRCMF_TRACE(("sdio_vendor: 0x%04x\n", func->vendor)); + BRCMF_TRACE(("sdio_device: 0x%04x\n", func->device)); + BRCMF_TRACE(("Function#: 0x%04x\n", func->num)); if (func->num == 1) { sdio_func_0.num = 0; @@ -1034,7 +976,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, if (func->num == 2) { brcmf_cfg80211_sdio_func(func); - sd_trace(("F2 found, calling brcmf_sdio_probe...\n")); + BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n")); ret = brcmf_sdio_probe(&sdmmc_dev); } @@ -1043,14 +985,14 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, static void brcmf_ops_sdio_remove(struct sdio_func *func) { - sd_trace(("%s Enter\n", __func__)); - sd_info(("func->class=%x\n", func->class)); - sd_info(("sdio_vendor: 0x%04x\n", func->vendor)); - sd_info(("sdio_device: 0x%04x\n", func->device)); - sd_info(("Function#: 0x%04x\n", func->num)); + BRCMF_TRACE(("%s Enter\n", __func__)); + BRCMF_INFO(("func->class=%x\n", func->class)); + BRCMF_INFO(("sdio_vendor: 0x%04x\n", func->vendor)); + BRCMF_INFO(("sdio_device: 0x%04x\n", func->device)); + BRCMF_INFO(("Function#: 0x%04x\n", func->num)); if (func->num == 2) { - sd_trace(("F2 found, calling brcmf_sdio_remove...\n")); + BRCMF_TRACE(("F2 found, calling brcmf_sdio_remove...\n")); brcmf_sdio_remove(&sdmmc_dev); } } @@ -1062,19 +1004,19 @@ static int brcmf_sdio_suspend(struct device *dev) mmc_pm_flag_t sdio_flags; int ret = 0; - sd_trace(("%s\n", __func__)); + BRCMF_TRACE(("%s\n", __func__)); atomic_set(&brcmf_mmc_suspend, true); sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { - sd_err(("Host can't keep power while suspended\n")); + BRCMF_ERROR(("Host can't keep power while suspended\n")); return -EINVAL; } ret = sdio_set_host_pm_flags(gInstance->func[1], MMC_PM_KEEP_POWER); if (ret) { - sd_err(("Failed to set pm_flags\n")); + BRCMF_ERROR(("Failed to set pm_flags\n")); return ret; } @@ -1119,12 +1061,12 @@ int brcmf_sdioh_interrupt_set(struct sdioh_info *sd, bool enable) unsigned long flags; struct sdos_info *sdos; - sd_trace(("%s: %s\n", __func__, enable ? "Enabling" : "Disabling")); + BRCMF_TRACE(("%s: %s\n", __func__, enable ? "Enabling" : "Disabling")); sdos = (struct sdos_info *)sd->sdos_info; if (enable && !(sd->intr_handler && sd->intr_handler_arg)) { - sd_err(("%s: no handler registered, will not enable\n", + BRCMF_ERROR(("%s: no handler registered, will not enable\n", __func__)); return -EINVAL; } @@ -1149,7 +1091,7 @@ int brcmf_sdioh_interrupt_set(struct sdioh_info *sd, bool enable) int brcmf_sdio_function_init(void) { int error = 0; - sd_trace(("brcmf_sdio_function_init: %s Enter\n", __func__)); + BRCMF_TRACE(("brcmf_sdio_function_init: %s Enter\n", __func__)); gInstance = kzalloc(sizeof(struct brcmf_sdmmc_instance), GFP_KERNEL); if (!gInstance) @@ -1166,7 +1108,7 @@ int brcmf_sdio_function_init(void) */ void brcmf_sdio_function_cleanup(void) { - sd_trace(("%s Enter\n", __func__)); + BRCMF_TRACE(("%s Enter\n", __func__)); sdio_unregister_driver(&brcmf_sdmmc_driver); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index ad679558bda..c33720d9b56 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -340,7 +340,6 @@ extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(bool enable); -extern uint sd_msglevel; /* Debug message level */ extern uint sd_f2_blocksize; extern struct brcmf_sdmmc_instance *gInstance; From 6bdc78fae281694d45268081748e40e4aee0078c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:32 +0200 Subject: [PATCH 0070/1519] staging: brcm80211: remove structure sdio_hc in brcmfmac Most members in sdio_hc are no longer needed anymore. And fullmac is keeping a global pointer of this structure. This patch deletes the structure and places the useful member to a new structure brcmf_sdio_dev. The pointer of brcmf_sdio_dev will be save in the private driver data during sdio_probe. Therefore, we don't need to keep the global pointer. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 90 ++++--------------- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 41 +++++++-- .../staging/brcm80211/brcmfmac/sdio_host.h | 18 ++-- 3 files changed, 61 insertions(+), 88 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 310d4fd8c25..7b667879194 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -74,25 +74,8 @@ struct brcmf_sdio_card { u32 sbwad; /* Save backplane window address */ }; -/** - * SDIO Host Controller info - */ -struct sdio_hc { - struct sdio_hc *next; - struct device *dev; /* platform device handle */ - void *regs; /* SDIO Host Controller address */ - struct brcmf_sdio_card *card; - void *ch; - unsigned int oob_irq; - unsigned long oob_flags; /* OOB Host specifiction - as edge and etc */ - bool oob_irq_registered; -}; - const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL; -static struct sdio_hc *sdhcinfo; - /* driver info, initialized when brcmf_sdio_register is called */ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; @@ -101,7 +84,7 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; module_param(sd_f2_blocksize, int, 0); struct brcmf_sdio_card* -brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq) +brcmf_sdcard_attach(void *cfghdl, u32 *regsva) { struct brcmf_sdio_card *card; @@ -111,7 +94,7 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq) return NULL; } - card->sdioh = brcmf_sdioh_attach(cfghdl, irq); + card->sdioh = brcmf_sdioh_attach(cfghdl); if (!card->sdioh) { brcmf_sdcard_detach(card); return NULL; @@ -495,44 +478,26 @@ u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) return card->sbwad; } -int brcmf_sdio_probe(struct device *dev) +int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) { - struct sdio_hc *sdhc = NULL; u32 regs = 0; struct brcmf_sdio_card *card = NULL; - int irq = 0; u32 vendevid; - unsigned long irq_flags = 0; - /* allocate SDIO Host Controller state info */ - sdhc = kzalloc(sizeof(struct sdio_hc), GFP_ATOMIC); - if (!sdhc) { - SDLX_MSG(("%s: out of memory\n", __func__)); - goto err; - } - sdhc->dev = (void *)dev; - - card = brcmf_sdcard_attach((void *)0, ®s, irq); + card = brcmf_sdcard_attach((void *)0, ®s); if (!card) { SDLX_MSG(("%s: attach failed\n", __func__)); goto err; } + sdiodev->card = card; - sdhc->card = card; - sdhc->oob_irq = irq; - sdhc->oob_flags = irq_flags; - sdhc->oob_irq_registered = false; /* to make sure.. */ - - /* chain SDIO Host Controller info together */ - sdhc->next = sdhcinfo; - sdhcinfo = sdhc; /* Read the vendor/device ID from the CIS */ vendevid = brcmf_sdcard_query_device(card); /* try to attach to the target device */ - sdhc->ch = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), + sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), 0, 0, 0, 0, regs, card); - if (!sdhc->ch) { + if (!sdiodev->bus) { SDLX_MSG(("%s: device attach failed\n", __func__)); goto err; } @@ -541,42 +506,17 @@ int brcmf_sdio_probe(struct device *dev) /* error handling */ err: - if (sdhc) { - if (sdhc->card) - brcmf_sdcard_detach(sdhc->card); - kfree(sdhc); - } + if (sdiodev->card) + brcmf_sdcard_detach(sdiodev->card); return -ENODEV; } EXPORT_SYMBOL(brcmf_sdio_probe); -int brcmf_sdio_remove(struct device *dev) +int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) { - struct sdio_hc *sdhc, *prev; - - sdhc = sdhcinfo; - drvinfo.detach(sdhc->ch); - brcmf_sdcard_detach(sdhc->card); - /* find the SDIO Host Controller state for this pdev - and take it out from the list */ - for (sdhc = sdhcinfo, prev = NULL; sdhc; sdhc = sdhc->next) { - if (sdhc->dev == (void *)dev) { - if (prev) - prev->next = sdhc->next; - else - sdhcinfo = NULL; - break; - } - prev = sdhc; - } - if (!sdhc) { - SDLX_MSG(("%s: failed\n", __func__)); - return 0; - } - - /* release SDIO Host Controller info */ - kfree(sdhc); + drvinfo.detach(sdiodev->bus); + brcmf_sdcard_detach(sdiodev->card); return 0; } EXPORT_SYMBOL(brcmf_sdio_remove); @@ -594,10 +534,10 @@ void brcmf_sdio_unregister(void) brcmf_sdio_function_cleanup(); } -void brcmf_sdio_wdtmr_enable(bool enable) +void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable) { if (enable) - brcmf_sdbrcm_wd_timer(sdhcinfo->ch, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(sdiodev->bus, brcmf_watchdog_ms); else - brcmf_sdbrcm_wd_timer(sdhcinfo->ch, 0); + brcmf_sdbrcm_wd_timer(sdiodev->bus, 0); } diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 4ffd934377d..16ea6e87cfa 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -68,8 +68,6 @@ uint sd_f2_blocksize = 512; /* Default blocksize */ struct brcmf_sdmmc_instance *gInstance; static atomic_t brcmf_mmc_suspend; -struct device sdmmc_dev; - /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, @@ -160,7 +158,7 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) /* * Public entry points & extern's */ -struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) +struct sdioh_info *brcmf_sdioh_attach(void *bar0) { struct sdioh_info *sd; int err_ret; @@ -960,6 +958,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, { int ret = 0; static struct sdio_func sdio_func_0; + struct brcmf_sdio_dev *sdiodev; BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__)); BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class)); BRCMF_TRACE(("sdio_vendor: 0x%04x\n", func->vendor)); @@ -970,14 +969,30 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdio_func_0.num = 0; sdio_func_0.card = func->card; gInstance->func[0] = &sdio_func_0; + + if (dev_get_drvdata(&func->card->dev)) { + BRCMF_ERROR(("%s: card private drvdata occupied.\n", + __func__)); + return -ENXIO; + } + sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); + if (!sdiodev) + return -ENOMEM; + sdiodev->func1 = func; + dev_set_drvdata(&func->card->dev, sdiodev); } gInstance->func[func->num] = func; if (func->num == 2) { + sdiodev = dev_get_drvdata(&func->card->dev); + if ((!sdiodev) || (sdiodev->func1->card != func->card)) + return -ENODEV; + sdiodev->func2 = func; + brcmf_cfg80211_sdio_func(func); BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n")); - ret = brcmf_sdio_probe(&sdmmc_dev); + ret = brcmf_sdio_probe(sdiodev); } return ret; @@ -985,6 +1000,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, static void brcmf_ops_sdio_remove(struct sdio_func *func) { + struct brcmf_sdio_dev *sdiodev; BRCMF_TRACE(("%s Enter\n", __func__)); BRCMF_INFO(("func->class=%x\n", func->class)); BRCMF_INFO(("sdio_vendor: 0x%04x\n", func->vendor)); @@ -992,8 +1008,11 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) BRCMF_INFO(("Function#: 0x%04x\n", func->num)); if (func->num == 2) { + sdiodev = dev_get_drvdata(&func->card->dev); BRCMF_TRACE(("F2 found, calling brcmf_sdio_remove...\n")); - brcmf_sdio_remove(&sdmmc_dev); + brcmf_sdio_remove(sdiodev); + dev_set_drvdata(&func->card->dev, NULL); + kfree(sdiodev); } } @@ -1002,6 +1021,8 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) static int brcmf_sdio_suspend(struct device *dev) { mmc_pm_flag_t sdio_flags; + struct brcmf_sdio_dev *sdiodev; + struct sdio_func *func = dev_to_sdio_func(dev); int ret = 0; BRCMF_TRACE(("%s\n", __func__)); @@ -1020,14 +1041,19 @@ static int brcmf_sdio_suspend(struct device *dev) return ret; } - brcmf_sdio_wdtmr_enable(false); + sdiodev = dev_get_drvdata(&func->card->dev); + brcmf_sdio_wdtmr_enable(sdiodev, false); return ret; } static int brcmf_sdio_resume(struct device *dev) { - brcmf_sdio_wdtmr_enable(true); + struct brcmf_sdio_dev *sdiodev; + struct sdio_func *func = dev_to_sdio_func(dev); + + sdiodev = dev_get_drvdata(&func->card->dev); + brcmf_sdio_wdtmr_enable(sdiodev, true); atomic_set(&brcmf_mmc_suspend, false); return 0; } @@ -1097,7 +1123,6 @@ int brcmf_sdio_function_init(void) if (!gInstance) return -ENOMEM; - memset(&sdmmc_dev, 0, sizeof(sdmmc_dev)); error = sdio_register_driver(&brcmf_sdmmc_driver); return error; diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index c33720d9b56..9853e74e385 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -130,6 +130,13 @@ struct brcmf_sdmmc_instance { u32 host_claimed; }; +struct brcmf_sdio_dev { + struct sdio_func *func1; + struct sdio_func *func2; + struct brcmf_sdio_card *card; + void *bus; +}; + /* Attach and build an interface to the underlying SD host driver. * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by * brcmf_sdcard. @@ -139,7 +146,7 @@ struct brcmf_sdmmc_instance { * most recent one) to enable single-instance implementations to pass NULL. */ extern struct brcmf_sdio_card* -brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq); +brcmf_sdcard_attach(void *cfghdl, u32 *regsva); /* Detach - freeup resources allocated in attach */ extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card); @@ -272,8 +279,8 @@ extern int brcmf_sdio_function_init(void); extern int brcmf_sdio_register(struct brcmf_sdioh_driver *driver); extern void brcmf_sdio_unregister(void); extern void brcmf_sdio_function_cleanup(void); -extern int brcmf_sdio_probe(struct device *dev); -extern int brcmf_sdio_remove(struct device *dev); +extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); +extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); /* Function to return current window addr */ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card); @@ -290,7 +297,7 @@ extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd); * The handler shall be provided by all subsequent calls. No local cache * cfghdl points to the starting address of pci device mapped memory */ -extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq); +extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl); extern int brcmf_sdioh_detach(struct sdioh_info *si); extern int @@ -338,7 +345,8 @@ extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); /* Watchdog timer interface for pm ops */ -extern void brcmf_sdio_wdtmr_enable(bool enable); +extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, + bool enable); extern uint sd_f2_blocksize; From 23eec9e1776d2e4ff7872f4d547d6913922c8977 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:33 +0200 Subject: [PATCH 0071/1519] staging: brcm80211: remove SDLX_MSG from brcmfmac Use unified debug macros in fullmac Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 7b667879194..09531608c5c 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -29,6 +29,7 @@ #include #include "dhd.h" #include "dhd_bus.h" +#include "dhd_dbg.h" #include "sdio_host.h" #define SDIOH_API_ACCESS_RETRY_LIMIT 2 @@ -55,9 +56,6 @@ #define BRCMF_SD_INFO(x) #endif /* BCMDBG */ -/* debugging macros */ -#define SDLX_MSG(x) - #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */ #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ @@ -486,7 +484,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) card = brcmf_sdcard_attach((void *)0, ®s); if (!card) { - SDLX_MSG(("%s: attach failed\n", __func__)); + BRCMF_ERROR(("%s: attach failed\n", __func__)); goto err; } sdiodev->card = card; @@ -498,7 +496,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), 0, 0, 0, 0, regs, card); if (!sdiodev->bus) { - SDLX_MSG(("%s: device attach failed\n", __func__)); + BRCMF_ERROR(("%s: device attach failed\n", __func__)); goto err; } @@ -525,7 +523,6 @@ int brcmf_sdio_register(struct brcmf_sdioh_driver *driver) { drvinfo = *driver; - SDLX_MSG(("Linux Kernel SDIO/MMC Driver\n")); return brcmf_sdio_function_init(); } From 1a1038033ea08bf4f82e6abbdd9fbed5df2148c8 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:34 +0200 Subject: [PATCH 0072/1519] staging: brcm80211: remove BRCMF_SD_* debug macros from brcmfmac Use unified debug macros BRCMF_* in fullmac. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 50 +++++-------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 1 - 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 09531608c5c..53dfecdf5aa 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -34,28 +34,6 @@ #define SDIOH_API_ACCESS_RETRY_LIMIT 2 -#define BRCMF_SD_ERROR_VAL 0x0001 /* Error */ -#define BRCMF_SD_INFO_VAL 0x0002 /* Info */ - - -#ifdef BCMDBG -#define BRCMF_SD_ERROR(x) \ - do { \ - if ((brcmf_sdio_msglevel & BRCMF_SD_ERROR_VAL) && \ - net_ratelimit()) \ - printk x; \ - } while (0) -#define BRCMF_SD_INFO(x) \ - do { \ - if ((brcmf_sdio_msglevel & BRCMF_SD_INFO_VAL) && \ - net_ratelimit()) \ - printk x; \ - } while (0) -#else /* BCMDBG */ -#define BRCMF_SD_ERROR(x) -#define BRCMF_SD_INFO(x) -#endif /* BCMDBG */ - #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */ #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ @@ -72,8 +50,6 @@ struct brcmf_sdio_card { u32 sbwad; /* Save backplane window address */ }; -const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL; - /* driver info, initialized when brcmf_sdio_register is called */ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; @@ -88,7 +64,7 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva) card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC); if (card == NULL) { - BRCMF_SD_ERROR(("sdcard_attach: out of memory")); + BRCMF_ERROR(("sdcard_attach: out of memory")); return NULL; } @@ -167,7 +143,7 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, if (err) *err = status; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", __func__, fnc_num, addr, data)); return data; @@ -191,7 +167,7 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, if (err) *err = status; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", __func__, fnc_num, addr, data)); } @@ -207,7 +183,7 @@ u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num, if (err) *err = status; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", __func__, fnc_num, addr, data)); return data; @@ -226,7 +202,7 @@ brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num, if (err) *err = status; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", __func__, fnc_num, addr, data)); } @@ -247,7 +223,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis, into the provided buffer. */ tmp_buf = kmalloc(length, GFP_ATOMIC); if (tmp_buf == NULL) { - BRCMF_SD_ERROR(("%s: out of memory\n", __func__)); + BRCMF_ERROR(("%s: out of memory\n", __func__)); return -ENOMEM; } memcpy(tmp_buf, cis, length); @@ -289,7 +265,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) u32 word = 0; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr)); + BRCMF_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr)); if (bar0 != card->sbwad) { if (brcmf_sdcard_set_sbaddr_window(card, bar0)) @@ -307,7 +283,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) card->regfail = (status != 0); - BRCMF_SD_INFO(("u32data = 0x%x\n", word)); + BRCMF_INFO(("u32data = 0x%x\n", word)); /* if ok, return appropriately masked word */ if (status == 0) { @@ -325,7 +301,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) } /* otherwise, bad sdio access or invalid size */ - BRCMF_SD_ERROR(("%s: error reading addr 0x%04x size %d\n", __func__, + BRCMF_ERROR(("%s: error reading addr 0x%04x size %d\n", __func__, addr, size)); return 0xFFFFFFFF; } @@ -337,7 +313,7 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", + BRCMF_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", __func__, addr, size * 8, data)); if (bar0 != card->sbwad) { @@ -359,7 +335,7 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, if (status == 0) return 0; - BRCMF_SD_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n", + BRCMF_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n", __func__, data, addr, size)); return 0xFFFFFFFF; } @@ -383,7 +359,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", __func__, fn, addr, nbytes)); /* Async not implemented yet */ @@ -423,7 +399,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", + BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", __func__, fn, addr, nbytes)); /* Async not implemented yet */ diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 9853e74e385..5e7552e7aaa 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -18,7 +18,6 @@ #define _BRCM_SDH_H_ #include -extern const uint brcmf_sdio_msglevel; #define SDIO_FUNC_0 0 #define SDIO_FUNC_1 1 From 0f188ea3d9c8457cdc788bb509929908b80efe46 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:35 +0200 Subject: [PATCH 0073/1519] staging: brcm80211: absorb brcmf_sdcard_attach into brcmf_sdio_probe Increase readability of brcmfmac Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 68 ++++++++----------- .../staging/brcm80211/brcmfmac/sdio_host.h | 11 --- 2 files changed, 27 insertions(+), 52 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 53dfecdf5aa..6f88bd2e9aa 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -57,32 +57,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; module_param(sd_f2_blocksize, int, 0); -struct brcmf_sdio_card* -brcmf_sdcard_attach(void *cfghdl, u32 *regsva) -{ - struct brcmf_sdio_card *card; - - card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC); - if (card == NULL) { - BRCMF_ERROR(("sdcard_attach: out of memory")); - return NULL; - } - - card->sdioh = brcmf_sdioh_attach(cfghdl); - if (!card->sdioh) { - brcmf_sdcard_detach(card); - return NULL; - } - - card->init_success = true; - - *regsva = SI_ENUM_BASE; - - /* Report the BAR, to fix if needed */ - card->sbwad = SI_ENUM_BASE; - return card; -} - int brcmf_sdcard_detach(struct brcmf_sdio_card *card) { if (card != NULL) { @@ -455,35 +429,47 @@ u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) { u32 regs = 0; - struct brcmf_sdio_card *card = NULL; u32 vendevid; + int ret = 0; - card = brcmf_sdcard_attach((void *)0, ®s); - if (!card) { - BRCMF_ERROR(("%s: attach failed\n", __func__)); - goto err; + sdiodev->card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC); + if (sdiodev->card == NULL) { + BRCMF_ERROR(("sdcard_attach: out of memory")); + ret = -ENOMEM; + goto out; } - sdiodev->card = card; + + sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0); + if (!sdiodev->card->sdioh) { + brcmf_sdcard_detach(sdiodev->card); + ret = -ENODEV; + goto out; + } + + sdiodev->card->init_success = true; + + regs = SI_ENUM_BASE; + + /* Report the BAR, to fix if needed */ + sdiodev->card->sbwad = SI_ENUM_BASE; /* Read the vendor/device ID from the CIS */ - vendevid = brcmf_sdcard_query_device(card); + vendevid = brcmf_sdcard_query_device(sdiodev->card); /* try to attach to the target device */ sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), - 0, 0, 0, 0, regs, card); + 0, 0, 0, 0, regs, sdiodev->card); if (!sdiodev->bus) { BRCMF_ERROR(("%s: device attach failed\n", __func__)); - goto err; + ret = -ENODEV; + goto out; } - return 0; - - /* error handling */ -err: - if (sdiodev->card) +out: + if ((ret) && (sdiodev->card)) brcmf_sdcard_detach(sdiodev->card); - return -ENODEV; + return ret; } EXPORT_SYMBOL(brcmf_sdio_probe); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 5e7552e7aaa..68b684392af 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -136,17 +136,6 @@ struct brcmf_sdio_dev { void *bus; }; -/* Attach and build an interface to the underlying SD host driver. - * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by - * brcmf_sdcard. - * - Returns the sdio card handle and virtual address base for register access. - * The returned handle should be used in all subsequent calls, but the bcmsh - * implementation may maintain a single "default" handle (e.g. the first or - * most recent one) to enable single-instance implementations to pass NULL. - */ -extern struct brcmf_sdio_card* -brcmf_sdcard_attach(void *cfghdl, u32 *regsva); - /* Detach - freeup resources allocated in attach */ extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card); From 9917124f23210da0d07491b33e7eae004f908f78 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:36 +0200 Subject: [PATCH 0074/1519] staging: brcm80211: absorb brcmf_sdcard_detach into brcmf_sdio_remove To increase code readability of brcmfmac Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 32 ++++++++----------- .../staging/brcm80211/brcmfmac/sdio_host.h | 3 -- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 6f88bd2e9aa..0cd449d332e 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -57,19 +57,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; module_param(sd_f2_blocksize, int, 0); -int brcmf_sdcard_detach(struct brcmf_sdio_card *card) -{ - if (card != NULL) { - if (card->sdioh) { - brcmf_sdioh_detach(card->sdioh); - card->sdioh = NULL; - } - kfree(card); - } - - return 0; -} - int brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name, void *params, int plen, void *arg, int len, bool set) @@ -441,7 +428,6 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0); if (!sdiodev->card->sdioh) { - brcmf_sdcard_detach(sdiodev->card); ret = -ENODEV; goto out; } @@ -466,8 +452,8 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) } out: - if ((ret) && (sdiodev->card)) - brcmf_sdcard_detach(sdiodev->card); + if (ret) + brcmf_sdio_remove(sdiodev); return ret; } @@ -475,8 +461,18 @@ EXPORT_SYMBOL(brcmf_sdio_probe); int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) { - drvinfo.detach(sdiodev->bus); - brcmf_sdcard_detach(sdiodev->card); + if (sdiodev->bus) { + drvinfo.detach(sdiodev->bus); + sdiodev->bus = NULL; + } + + if (sdiodev->card) { + if (sdiodev->card->sdioh) + brcmf_sdioh_detach(sdiodev->card->sdioh); + kfree(sdiodev->card); + sdiodev->card = NULL; + } + return 0; } EXPORT_SYMBOL(brcmf_sdio_remove); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 68b684392af..cf3b8fc3a52 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -136,9 +136,6 @@ struct brcmf_sdio_dev { void *bus; }; -/* Detach - freeup resources allocated in attach */ -extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card); - /* Enable/disable SD interrupt */ extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card); extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card); From 05b92610eef4646c252171d059a84c705b66ede5 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:37 +0200 Subject: [PATCH 0075/1519] staging: brcm80211: replace simple_strtoul usage in brcmfmac The usage of simple_strtoul is not preferred. Instead kstrtoul should be used. This patch fixes this for the brcmfmac driver. Reported-by: Dan Carpenter Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_common.c | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 12c772d1789..fdd362901df 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -827,10 +827,13 @@ static int brcmf_c_pattern_atoh(char *src, char *dst) return -EINVAL; } for (i = 0; *src != '\0'; i++) { + unsigned long res; char num[3]; strncpy(num, src, 2); num[2] = '\0'; - dst[i] = (u8) simple_strtoul(num, NULL, 16); + if (kstrtoul(num, 16, &res)) + return -EINVAL; + dst[i] = (u8)res; src += 2; } return i; @@ -840,6 +843,7 @@ void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, int master_mode) { + unsigned long res; char *argv[8]; int i = 0; const char *str; @@ -876,7 +880,9 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, pkt_filterp = (struct brcmf_pkt_filter_enable *) (buf + str_len + 1); /* Parse packet filter id. */ - enable_parm.id = simple_strtoul(argv[i], NULL, 0); + enable_parm.id = 0; + if (!kstrtoul(argv[i], 0, &res)) + enable_parm.id = (u32)res; /* Parse enable/disable value. */ enable_parm.enable = enable; @@ -913,6 +919,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) const char *str; struct brcmf_pkt_filter pkt_filter; struct brcmf_pkt_filter *pkt_filterp; + unsigned long res; int buf_len; int str_len; int rc; @@ -956,7 +963,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) pkt_filterp = (struct brcmf_pkt_filter *) (buf + str_len + 1); /* Parse packet filter id. */ - pkt_filter.id = simple_strtoul(argv[i], NULL, 0); + pkt_filter.id = 0; + if (!kstrtoul(argv[i], 0, &res)) + pkt_filter.id = (u32)res; if (NULL == argv[++i]) { BRCMF_ERROR(("Polarity not provided\n")); @@ -964,7 +973,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) } /* Parse filter polarity. */ - pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0); + pkt_filter.negate_match = 0; + if (!kstrtoul(argv[i], 0, &res)) + pkt_filter.negate_match = (u32)res; if (NULL == argv[++i]) { BRCMF_ERROR(("Filter type not provided\n")); @@ -972,7 +983,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) } /* Parse filter type. */ - pkt_filter.type = simple_strtoul(argv[i], NULL, 0); + pkt_filter.type = 0; + if (!kstrtoul(argv[i], 0, &res)) + pkt_filter.type = (u32)res; if (NULL == argv[++i]) { BRCMF_ERROR(("Offset not provided\n")); @@ -980,7 +993,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) } /* Parse pattern filter offset. */ - pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0); + pkt_filter.u.pattern.offset = 0; + if (!kstrtoul(argv[i], 0, &res)) + pkt_filter.u.pattern.offset = (u32)res; if (NULL == argv[++i]) { BRCMF_ERROR(("Bitmask not provided\n")); From 54d7879c4ed0b6cbed8f992efa67c954915bb2b6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:38 +0200 Subject: [PATCH 0076/1519] staging: brcm80211: fixed checkpatch warnings for fullmac Most of them being 'line longer than 80 chars' type of warning. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 113 ++++++++----- .../staging/brcm80211/brcmfmac/dhd_common.c | 23 ++- .../staging/brcm80211/brcmfmac/dhd_linux.c | 27 +-- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 154 ++++++++++-------- .../staging/brcm80211/brcmfmac/sdio_host.h | 95 +++++++---- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 23 ++- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 3 +- 7 files changed, 263 insertions(+), 175 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 3c950cc5b7f..cd1b90da126 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -117,11 +117,16 @@ #define BRCMF_SCAN_RESULTS_ABORTED 3 #define BRCMF_SCAN_RESULTS_NO_MEM 4 -#define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */ -#define BRCMF_PRIMARY_KEY (1 << 1) /* primary (ie tx) key */ -#define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */ -#define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */ -#define WL_IBSS_PEER_GROUP_KEY (1 << 6) /* Indicates a group key for a IBSS PEER */ +/* Indicates this key is using soft encrypt */ +#define WL_SOFT_KEY (1 << 0) +/* primary (ie tx) key */ +#define BRCMF_PRIMARY_KEY (1 << 1) +/* Reserved for backward compat */ +#define WL_KF_RES_4 (1 << 4) +/* Reserved for backward compat */ +#define WL_KF_RES_5 (1 << 5) +/* Indicates a group key for a IBSS PEER */ +#define WL_IBSS_PEER_GROUP_KEY (1 << 6) /* For supporting multiple interfaces */ #define BRCMF_MAX_IFS 16 @@ -333,13 +338,18 @@ enum brcmf_bus_state { * that indicates which bits within the pattern should be matched. */ struct brcmf_pkt_filter_pattern { - u32 offset; /* Offset within received packet to start pattern matching. - * Offset '0' is the first byte of the ethernet header. - */ - u32 size_bytes; /* Size of the pattern. Bitmask must be the same size. */ - u8 mask_and_pattern[1]; /* Variable length mask and pattern data. mask starts - * at offset 0. Pattern immediately follows mask. - */ + /* + * Offset within received packet to start pattern matching. + * Offset '0' is the first byte of the ethernet header. + */ + u32 offset; + /* Size of the pattern. Bitmask must be the same size.*/ + u32 size_bytes; + /* + * Variable length mask and pattern data. mask starts at offset 0. + * Pattern immediately follows mask. + */ + u8 mask_and_pattern[1]; }; /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */ @@ -373,8 +383,8 @@ struct brcmf_bss_info { u8 SSID_len; u8 SSID[32]; struct { - uint count; /* # rates in this set */ - u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */ + uint count; /* # rates in this set */ + u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */ } rateset; /* supported rates */ u16 chanspec; /* chanspec for bss */ u16 atim_window; /* units are Kusec */ @@ -409,7 +419,7 @@ struct brcmf_scan_params { * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */ u8 scan_type; /* flags, 0 use default */ - s32 nprobes; /* -1 use default, number of probes per channel */ + s32 nprobes; /* -1 use default, number of probes per channel */ s32 active_time; /* -1 use default, dwell time per channel for * active scanning */ @@ -460,11 +470,13 @@ struct brcmf_scan_results { /* used for association with a specific BSSID and chanspec list */ struct brcmf_assoc_params { - u8 bssid[ETH_ALEN]; /* 00:00:00:00:00:00: broadcast scan */ - s32 chanspec_num; /* 0: all available channels, - * otherwise count of chanspecs in chanspec_list - */ - u16 chanspec_list[1]; /* list of chanspecs */ + /* 00:00:00:00:00:00: broadcast scan */ + u8 bssid[ETH_ALEN]; + /* 0: all available channels, otherwise count of chanspecs in + * chanspec_list */ + s32 chanspec_num; + /* list of chanspecs */ + u16 chanspec_list[1]; }; #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ (sizeof(struct brcmf_assoc_params) - sizeof(u16)) @@ -495,8 +507,8 @@ struct brcmf_wsec_key { u32 len; /* key length */ u8 data[WLAN_MAX_KEY_LEN]; /* key data */ u32 pad_1[18]; - u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ - u32 flags; /* misc flags */ + u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ + u32 flags; /* misc flags */ u32 pad_2[2]; int pad_3; int iv_initialized; /* has IV been initialized already? */ @@ -558,32 +570,45 @@ struct brcmf_pub { /* Dongle media info */ bool iswl; /* Dongle-resident driver is wl */ unsigned long drv_version; /* Version of dongle-resident driver */ - u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */ + u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */ struct dngl_stats dstats; /* Stats for dongle-based data */ /* Additional stats for the bus level */ - unsigned long tx_packets; /* Data packets sent to dongle */ - unsigned long tx_multicast; /* Multicast data packets sent to dongle */ - unsigned long tx_errors; /* Errors in sending data to dongle */ - unsigned long tx_ctlpkts; /* Control packets sent to dongle */ - unsigned long tx_ctlerrs; /* Errors sending control frames to dongle */ - unsigned long rx_packets; /* Packets sent up the network interface */ - unsigned long rx_multicast; /* Multicast packets sent up the network - interface */ - unsigned long rx_errors; /* Errors processing rx data packets */ - unsigned long rx_ctlpkts; /* Control frames processed from dongle */ - unsigned long rx_ctlerrs; /* Errors in processing rx control frames */ - unsigned long rx_dropped; /* Packets dropped locally (no memory) */ - unsigned long rx_flushed; /* Packets flushed due to - unscheduled sendup thread */ - unsigned long wd_dpc_sched; /* Number of times dpc scheduled by - watchdog timer */ - unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead - was used. */ - unsigned long tx_realloc; /* Number of tx packets we had to realloc for - headroom */ - unsigned long fc_packets; /* Number of flow control pkts recvd */ + /* Data packets sent to dongle */ + unsigned long tx_packets; + /* Multicast data packets sent to dongle */ + unsigned long tx_multicast; + /* Errors in sending data to dongle */ + unsigned long tx_errors; + /* Control packets sent to dongle */ + unsigned long tx_ctlpkts; + /* Errors sending control frames to dongle */ + unsigned long tx_ctlerrs; + /* Packets sent up the network interface */ + unsigned long rx_packets; + /* Multicast packets sent up the network interface */ + unsigned long rx_multicast; + /* Errors processing rx data packets */ + unsigned long rx_errors; + /* Control frames processed from dongle */ + unsigned long rx_ctlpkts; + + /* Errors in processing rx control frames */ + unsigned long rx_ctlerrs; + /* Packets dropped locally (no memory) */ + unsigned long rx_dropped; + /* Packets flushed due to unscheduled sendup thread */ + unsigned long rx_flushed; + /* Number of times dpc scheduled by watchdog timer */ + unsigned long wd_dpc_sched; + + /* Number of packets where header read-ahead was used. */ + unsigned long rx_readahead_cnt; + /* Number of tx packets we had to realloc for headroom */ + unsigned long tx_realloc; + /* Number of flow control pkts recvd */ + unsigned long fc_packets; /* Last error return */ int bcmerror; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index fdd362901df..a6704c43a81 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -660,20 +660,19 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) + be16_to_cpu(hdr.len)) = '\0'; if (be32_to_cpu(hdr.discarded_bytes) - || be32_to_cpu(hdr.discarded_printf)) { - BRCMF_ERROR( - ("\nWLC_E_TRACE: [Discarded traces in dongle -->" - "discarded_bytes %d discarded_printf %d]\n", - be32_to_cpu(hdr.discarded_bytes), - be32_to_cpu(hdr.discarded_printf))); - } + || be32_to_cpu(hdr.discarded_printf)) + BRCMF_ERROR(("\nWLC_E_TRACE: [Discarded traces " + "in dongle -->discarded_bytes %d " + "discarded_printf %d]\n", + be32_to_cpu(hdr.discarded_bytes), + be32_to_cpu(hdr.discarded_printf))) + ; nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; - if (nblost > 0) { - BRCMF_ERROR( - ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n", - be32_to_cpu(hdr.seqnum), nblost)); - } + if (nblost > 0) + BRCMF_ERROR(("\nWLC_E_TRACE: [Event lost --> " + "seqnum %d nblost %d\n", + be32_to_cpu(hdr.seqnum), nblost)); seqnum_prev = be32_to_cpu(hdr.seqnum); /* Display the trace buffer. Advance from \n to \n to diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 9dc327b21a3..ca26cc1f677 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -134,8 +134,8 @@ module_param(brcmf_pktgen_len, uint, 0); static int brcmf_toe_get(struct brcmf_info *drvr_priv, int idx, u32 *toe_ol); static int brcmf_toe_set(struct brcmf_info *drvr_priv, int idx, u32 toe_ol); -static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, - struct brcmf_event_msg *event_ptr, +static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, + void *pktdata, struct brcmf_event_msg *event_ptr, void **data_ptr); static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net) @@ -304,7 +304,8 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) } } -static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) +static int +_brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) { char buf[32]; struct brcmf_ioctl ioc; @@ -369,7 +370,8 @@ static void brcmf_op_if(struct brcmf_if *ifp) } if (ret == 0) { strcpy(ifp->net->name, ifp->name); - memcpy(netdev_priv(ifp->net), &drvr_priv, sizeof(drvr_priv)); + memcpy(netdev_priv(ifp->net), &drvr_priv, + sizeof(drvr_priv)); err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); if (err != 0) { BRCMF_ERROR(("%s: brcmf_net_attach failed, " @@ -1025,7 +1027,8 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, /* check for local brcmf ioctl and handle it */ if (driver == BRCMF_IOCTL_MAGIC) { - bcmerror = brcmf_c_ioctl((void *)&drvr_priv->pub, &ioc, buf, buflen); + bcmerror = brcmf_c_ioctl((void *)&drvr_priv->pub, &ioc, + buf, buflen); if (bcmerror) drvr_priv->pub.bcmerror = bcmerror; goto done; @@ -1055,9 +1058,8 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(net); - bcmerror = - brcmf_proto_ioctl(&drvr_priv->pub, ifidx, (struct brcmf_ioctl *)&ioc, - buf, buflen); + bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, + (struct brcmf_ioctl *)&ioc, buf, buflen); done: if (!bcmerror && buf && ioc.buf) { @@ -1254,8 +1256,8 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) if (brcmf_sysioc) { init_waitqueue_head(&drvr_priv->sysioc_waitq); - drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, drvr_priv, - "_brcmf_sysioc"); + drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, + drvr_priv, "_brcmf_sysioc"); if (IS_ERR(drvr_priv->sysioc_tsk)) { printk(KERN_WARNING "_brcmf_sysioc thread failed to start\n"); @@ -1514,8 +1516,9 @@ int brcmf_os_proto_unblock(struct brcmf_pub *drvr) return 0; } -static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, - struct brcmf_event_msg *event, void **data) +static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, + void *pktdata, struct brcmf_event_msg *event, + void **data) { int bcmerror = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index fe114788676..6c96f777481 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -160,48 +160,63 @@ struct rte_console { #endif /* SBSDIO_DEVICE_CTL */ -#define SBSDIO_DEVCTL_SETBUSY 0x01 /* 1: device will assert busy signal when - * receiving CMD53 - */ -#define SBSDIO_DEVCTL_SPI_INTR_SYNC 0x02 /* 1: assertion of sdio interrupt is - * synchronous to the sdio clock - */ -#define SBSDIO_DEVCTL_CA_INT_ONLY 0x04 /* 1: mask all interrupts to host - * except the chipActive (rev 8) - */ -#define SBSDIO_DEVCTL_PADS_ISO 0x08 /* 1: isolate internal sdio signals, put - * external pads in tri-state; requires - * sdio bus power cycle to clear (rev 9) - */ -#define SBSDIO_DEVCTL_SB_RST_CTL 0x30 /* Force SD->SB reset mapping (rev 11) */ -#define SBSDIO_DEVCTL_RST_CORECTL 0x00 /* Determined by CoreControl bit */ -#define SBSDIO_DEVCTL_RST_BPRESET 0x10 /* Force backplane reset */ -#define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 /* Force no backplane reset */ + +/* 1: device will assert busy signal when receiving CMD53 */ +#define SBSDIO_DEVCTL_SETBUSY 0x01 +/* 1: assertion of sdio interrupt is synchronous to the sdio clock */ +#define SBSDIO_DEVCTL_SPI_INTR_SYNC 0x02 +/* 1: mask all interrupts to host except the chipActive (rev 8) */ +#define SBSDIO_DEVCTL_CA_INT_ONLY 0x04 +/* 1: isolate internal sdio signals, put external pads in tri-state; requires + * sdio bus power cycle to clear (rev 9) */ +#define SBSDIO_DEVCTL_PADS_ISO 0x08 +/* Force SD->SB reset mapping (rev 11) */ +#define SBSDIO_DEVCTL_SB_RST_CTL 0x30 +/* Determined by CoreControl bit */ +#define SBSDIO_DEVCTL_RST_CORECTL 0x00 +/* Force backplane reset */ +#define SBSDIO_DEVCTL_RST_BPRESET 0x10 +/* Force no backplane reset */ +#define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 /* SBSDIO_FUNC1_CHIPCLKCSR */ -#define SBSDIO_FORCE_ALP 0x01 /* Force ALP request to backplane */ -#define SBSDIO_FORCE_HT 0x02 /* Force HT request to backplane */ -#define SBSDIO_FORCE_ILP 0x04 /* Force ILP request to backplane */ -#define SBSDIO_ALP_AVAIL_REQ 0x08 /* Make ALP ready (power up xtal) */ -#define SBSDIO_HT_AVAIL_REQ 0x10 /* Make HT ready (power up PLL) */ -#define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 /* Squelch clock requests from HW */ -#define SBSDIO_ALP_AVAIL 0x40 /* Status: ALP is ready */ -#define SBSDIO_HT_AVAIL 0x80 /* Status: HT is ready */ -#define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) -#define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) -#define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) -#define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) -#define SBSDIO_CLKAV(regval, alponly) (SBSDIO_ALPAV(regval) && \ - (alponly ? 1 : SBSDIO_HTAV(regval))) +/* Force ALP request to backplane */ +#define SBSDIO_FORCE_ALP 0x01 +/* Force HT request to backplane */ +#define SBSDIO_FORCE_HT 0x02 +/* Force ILP request to backplane */ +#define SBSDIO_FORCE_ILP 0x04 +/* Make ALP ready (power up xtal) */ +#define SBSDIO_ALP_AVAIL_REQ 0x08 +/* Make HT ready (power up PLL) */ +#define SBSDIO_HT_AVAIL_REQ 0x10 +/* Squelch clock requests from HW */ +#define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 +/* Status: ALP is ready */ +#define SBSDIO_ALP_AVAIL 0x40 +/* Status: HT is ready */ +#define SBSDIO_HT_AVAIL 0x80 + +#define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) +#define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) +#define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) +#define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) + +#define SBSDIO_CLKAV(regval, alponly) \ + (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) + /* direct(mapped) cis space */ -#define SBSDIO_CIS_BASE_COMMON 0x1000 /* MAPPED common CIS address */ -#define SBSDIO_CIS_SIZE_LIMIT 0x200 /* maximum bytes in one CIS */ -#define SBSDIO_CIS_OFT_ADDR_MASK 0x1FFFF /* cis offset addr is < 17 bits */ -#define SBSDIO_CIS_MANFID_TUPLE_LEN 6 /* manfid tuple length, include tuple, - * link bytes - */ +/* MAPPED common CIS address */ +#define SBSDIO_CIS_BASE_COMMON 0x1000 +/* maximum bytes in one CIS */ +#define SBSDIO_CIS_SIZE_LIMIT 0x200 +/* cis offset addr is < 17 bits */ +#define SBSDIO_CIS_OFT_ADDR_MASK 0x1FFFF + +/* manfid tuple length, include tuple, link bytes */ +#define SBSDIO_CIS_MANFID_TUPLE_LEN 6 /* intstatus */ #define I_SMB_SW0 (1 << 0) /* To SB Mail S/W interrupt 0 */ @@ -408,12 +423,18 @@ struct rte_console { #define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ /* sbtmstatelow */ -#define SBTML_RESET 0x0001 /* reset */ -#define SBTML_REJ_MASK 0x0006 /* reject field */ -#define SBTML_REJ 0x0002 /* reject */ -#define SBTML_TMPREJ 0x0004 /* temporary reject, for error recovery */ -#define SBTML_SICF_SHIFT 16 /* Shift to locate the SI control flags in sbtml */ +/* reset */ +#define SBTML_RESET 0x0001 +/* reject field */ +#define SBTML_REJ_MASK 0x0006 +/* reject */ +#define SBTML_REJ 0x0002 +/* temporary reject, for error recovery */ +#define SBTML_TMPREJ 0x0004 + +/* Shift to locate the SI control flags in sbtml */ +#define SBTML_SICF_SHIFT 16 /* sbtmstatehigh */ #define SBTMH_SERR 0x0001 /* serror */ @@ -421,7 +442,8 @@ struct rte_console { #define SBTMH_BUSY 0x0004 /* busy */ #define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ -#define SBTMH_SISF_SHIFT 16 /* Shift to locate the SI status flags in sbtmh */ +/* Shift to locate the SI status flags in sbtmh */ +#define SBTMH_SISF_SHIFT 16 /* sbidlow */ #define SBIDL_INIT 0x80 /* initiator */ @@ -431,7 +453,8 @@ struct rte_console { #define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ #define SBIDH_RCE_SHIFT 8 #define SBCOREREV(sbidh) \ - ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK)) + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ + ((sbidh) & SBIDH_RC_MASK)) #define SBIDH_CC_MASK 0x8ff0 /* core code */ #define SBIDH_CC_SHIFT 4 #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ @@ -1333,8 +1356,8 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) /* Writes a HW/SW header into the packet and sends it. */ /* Assumes: (a) header space already there, (b) caller holds lock */ -static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, uint chan, - bool free_pkt) +static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, + uint chan, bool free_pkt) { int ret; u8 *frame; @@ -1523,7 +1546,8 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) /* Priority based enq */ spin_lock_bh(&bus->txqlock); - if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == false) { + if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == + false) { skb_pull(pkt, SDPCM_HDRLEN); brcmf_txcomplete(bus->drvr, pkt, false); brcmu_pkt_buf_free_skb(pkt); @@ -1804,7 +1828,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) return ret ? -EIO : 0; } -int brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) +int +brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) { int timeleft; uint rxlen = 0; @@ -2191,7 +2216,8 @@ xfer_done: } #ifdef BCMDBG -static int brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) +static int +brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) { u32 addr; int rv; @@ -2530,10 +2556,10 @@ err: return bcmerror; } -static int -brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, const struct brcmu_iovar *vi, u32 actionid, - const char *name, void *params, int plen, void *arg, int len, - int val_size) +static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, + const struct brcmu_iovar *vi, u32 actionid, + const char *name, void *params, int plen, + void *arg, int len, int val_size) { int bcmerror = 0; s32 int_val = 0; @@ -3957,8 +3983,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) save_pfirst = pnext; continue; - } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pfirst) - != 0) { + } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, + pfirst) != 0) { BRCMF_ERROR(("%s: rx protocol error\n", __func__)); bus->drvr->rx_errors++; @@ -4080,8 +4106,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) MAX_RX_DATASZ)) rdlen += pad; } else if (rdlen % BRCMF_SDALIGN) { - rdlen += - BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); + rdlen += BRCMF_SDALIGN - + (rdlen % BRCMF_SDALIGN); } } @@ -4103,11 +4129,11 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->rxctl = bus->rxbuf; if (brcmf_alignctl) { bus->rxctl += firstread; - pad = ((unsigned long)bus->rxctl % - BRCMF_SDALIGN); + pad = ((unsigned long)bus->rxctl + % BRCMF_SDALIGN); if (pad) bus->rxctl += - (BRCMF_SDALIGN - pad); + (BRCMF_SDALIGN - pad); bus->rxctl -= firstread; } rxbuf = bus->rxctl; @@ -6503,8 +6529,8 @@ static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) -static void -brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, u32 drivestrength) { +static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, + u32 drivestrength) { struct sdiod_drive_str *str_tab = NULL; u32 str_mask = 0; u32 str_shift = 0; @@ -6775,8 +6801,8 @@ static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) MODULE_FIRMWARE(BCM4329_FW_NAME); MODULE_FIRMWARE(BCM4329_NV_NAME); -static int -brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, bool *pending) +static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, + bool *pending) { DECLARE_WAITQUEUE(wait, current); int timeout = msecs_to_jiffies(brcmf_ioctl_timeout_msec); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index cf3b8fc3a52..aecc8e33df7 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -40,46 +40,71 @@ /* Maximum number of I/O funcs */ #define SDIOD_MAX_IOFUNCS 7 -#define SBSDIO_NUM_FUNCTION 3 /* as of sdiod rev 0, supports 3 functions */ +/* as of sdiod rev 0, supports 3 functions */ +#define SBSDIO_NUM_FUNCTION 3 /* function 1 miscellaneous registers */ -#define SBSDIO_SPROM_CS 0x10000 /* sprom command and status */ -#define SBSDIO_SPROM_INFO 0x10001 /* sprom info register */ -#define SBSDIO_SPROM_DATA_LOW 0x10002 /* sprom indirect access data byte 0 */ -#define SBSDIO_SPROM_DATA_HIGH 0x10003 /* sprom indirect access data byte 1 */ -#define SBSDIO_SPROM_ADDR_LOW 0x10004 /* sprom indirect access addr byte 0 */ -#define SBSDIO_SPROM_ADDR_HIGH 0x10005 /* sprom indirect access addr byte 0 */ -#define SBSDIO_CHIP_CTRL_DATA 0x10006 /* xtal_pu (gpio) output */ -#define SBSDIO_CHIP_CTRL_EN 0x10007 /* xtal_pu (gpio) enable */ -#define SBSDIO_WATERMARK 0x10008 /* rev < 7, watermark for sdio device */ -#define SBSDIO_DEVICE_CTL 0x10009 /* control busy signal generation */ -/* registers introduced in rev 8, some content (mask/bits) defs in sbsdpcmdev.h */ -#define SBSDIO_FUNC1_SBADDRLOW 0x1000A /* SB Address Window Low (b15) */ -#define SBSDIO_FUNC1_SBADDRMID 0x1000B /* SB Address Window Mid (b23:b16) */ -#define SBSDIO_FUNC1_SBADDRHIGH 0x1000C /* SB Address Window High (b31:b24) */ -#define SBSDIO_FUNC1_FRAMECTRL 0x1000D /* Frame Control (frame term/abort) */ -#define SBSDIO_FUNC1_CHIPCLKCSR 0x1000E /* ChipClockCSR (ALP/HT ctl/status) */ -#define SBSDIO_FUNC1_SDIOPULLUP 0x1000F /* SdioPullUp (on cmd, d0-d2) */ -#define SBSDIO_FUNC1_WFRAMEBCLO 0x10019 /* Write Frame Byte Count Low */ -#define SBSDIO_FUNC1_WFRAMEBCHI 0x1001A /* Write Frame Byte Count High */ -#define SBSDIO_FUNC1_RFRAMEBCLO 0x1001B /* Read Frame Byte Count Low */ -#define SBSDIO_FUNC1_RFRAMEBCHI 0x1001C /* Read Frame Byte Count High */ +/* sprom command and status */ +#define SBSDIO_SPROM_CS 0x10000 +/* sprom info register */ +#define SBSDIO_SPROM_INFO 0x10001 +/* sprom indirect access data byte 0 */ +#define SBSDIO_SPROM_DATA_LOW 0x10002 +/* sprom indirect access data byte 1 */ +#define SBSDIO_SPROM_DATA_HIGH 0x10003 +/* sprom indirect access addr byte 0 */ +#define SBSDIO_SPROM_ADDR_LOW 0x10004 +/* sprom indirect access addr byte 0 */ +#define SBSDIO_SPROM_ADDR_HIGH 0x10005 +/* xtal_pu (gpio) output */ +#define SBSDIO_CHIP_CTRL_DATA 0x10006 +/* xtal_pu (gpio) enable */ +#define SBSDIO_CHIP_CTRL_EN 0x10007 +/* rev < 7, watermark for sdio device */ +#define SBSDIO_WATERMARK 0x10008 +/* control busy signal generation */ +#define SBSDIO_DEVICE_CTL 0x10009 + +/* SB Address Window Low (b15) */ +#define SBSDIO_FUNC1_SBADDRLOW 0x1000A +/* SB Address Window Mid (b23:b16) */ +#define SBSDIO_FUNC1_SBADDRMID 0x1000B +/* SB Address Window High (b31:b24) */ +#define SBSDIO_FUNC1_SBADDRHIGH 0x1000C +/* Frame Control (frame term/abort) */ +#define SBSDIO_FUNC1_FRAMECTRL 0x1000D +/* ChipClockCSR (ALP/HT ctl/status) */ +#define SBSDIO_FUNC1_CHIPCLKCSR 0x1000E +/* SdioPullUp (on cmd, d0-d2) */ +#define SBSDIO_FUNC1_SDIOPULLUP 0x1000F +/* Write Frame Byte Count Low */ +#define SBSDIO_FUNC1_WFRAMEBCLO 0x10019 +/* Write Frame Byte Count High */ +#define SBSDIO_FUNC1_WFRAMEBCHI 0x1001A +/* Read Frame Byte Count Low */ +#define SBSDIO_FUNC1_RFRAMEBCLO 0x1001B +/* Read Frame Byte Count High */ +#define SBSDIO_FUNC1_RFRAMEBCHI 0x1001C #define SBSDIO_FUNC1_MISC_REG_START 0x10000 /* f1 misc register start */ #define SBSDIO_FUNC1_MISC_REG_LIMIT 0x1001C /* f1 misc register end */ /* function 1 OCP space */ -#define SBSDIO_SB_OFT_ADDR_MASK 0x07FFF /* sb offset addr is <= 15 bits, 32k */ -#define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000 -#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000 /* with b15, maps to 32-bit SB access */ -/* some duplication with sbsdpcmdev.h here */ +/* sb offset addr is <= 15 bits, 32k */ +#define SBSDIO_SB_OFT_ADDR_MASK 0x07FFF +#define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000 +/* with b15, maps to 32-bit SB access */ +#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000 + /* valid bits in SBSDIO_FUNC1_SBADDRxxx regs */ + #define SBSDIO_SBADDRLOW_MASK 0x80 /* Valid bits in SBADDRLOW */ #define SBSDIO_SBADDRMID_MASK 0xff /* Valid bits in SBADDRMID */ #define SBSDIO_SBADDRHIGH_MASK 0xffU /* Valid bits in SBADDRHIGH */ -#define SBSDIO_SBWINDOW_MASK 0xffff8000 /* Address bits from SBADDR regs */ +/* Address bits from SBADDR regs */ +#define SBSDIO_SBWINDOW_MASK 0xffff8000 #define SDIOH_READ 0 /* Read request */ #define SDIOH_WRITE 1 /* Write request */ @@ -103,7 +128,7 @@ struct brcmf_sdreg { struct sdioh_info { struct osl_info *osh; /* osh handler */ bool client_intr_enabled; /* interrupt connnected flag */ - bool intr_handler_valid; /* client driver interrupt handler valid */ + bool intr_handler_valid; /* client driver interrupt handler valid */ void (*intr_handler)(void *); /* registered interrupt handler */ void *intr_handler_arg; /* argument to call interrupt handler */ u16 intmask; /* Current active interrupts */ @@ -119,8 +144,8 @@ struct sdioh_info { u32 com_cis_ptr; u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; uint max_dma_len; - uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */ - /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */ + /* DMA Descriptors supported by this controller. */ + uint max_dma_descriptors; }; struct brcmf_sdmmc_instance { @@ -218,9 +243,13 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, void *handle); /* Flags bits */ -#define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */ -#define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */ -#define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */ + +/* Four-byte target (backplane) width (vs. two-byte) */ +#define SDIO_REQ_4BYTE 0x1 +/* Fixed address (FIFO) (vs. incrementing address) */ +#define SDIO_REQ_FIXED 0x2 +/* Async request (vs. sync request) */ +#define SDIO_REQ_ASYNC 0x4 /* Pending (non-error) return code */ #define BCME_PENDING 1 diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 02137ac1838..bc1e1a958b1 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -795,8 +795,8 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, sizeof(sr->ssid)); if (err) { if (err == -EBUSY) - WL_INFO("system busy : scan for \"%s\" canceled\n", - sr->ssid.SSID); + WL_INFO("system busy : scan for \"%s\" " + "canceled\n", sr->ssid.SSID); else WL_ERR("WLC_SCAN error (%d)\n", err); @@ -1098,7 +1098,8 @@ done: return err; } -static s32 brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) +static s32 +brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); s32 err = 0; @@ -1113,8 +1114,8 @@ static s32 brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev return err; } -static s32 -brcmf_set_wpa_version(struct net_device *dev, struct cfg80211_connect_params *sme) +static s32 brcmf_set_wpa_version(struct net_device *dev, + struct cfg80211_connect_params *sme) { struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); struct brcmf_cfg80211_security *sec; @@ -1178,7 +1179,8 @@ brcmf_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) } static s32 -brcmf_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme) +brcmf_set_set_cipher(struct net_device *dev, + struct cfg80211_connect_params *sme) { struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); struct brcmf_cfg80211_security *sec; @@ -1428,7 +1430,8 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, memset(&join_params, 0, sizeof(join_params)); join_params_size = sizeof(join_params.ssid); - join_params.ssid.SSID_len = min(sizeof(join_params.ssid.SSID), sme->ssid_len); + join_params.ssid.SSID_len = + min(sizeof(join_params.ssid.SSID), sme->ssid_len); memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len); join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); @@ -1515,7 +1518,8 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, /* Make sure radio is off or on as far as software is concerned */ disable = WL_RADIO_SW_DISABLE << 16; disable = cpu_to_le32(disable); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_RADIO, &disable, sizeof(disable)); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_RADIO, &disable, + sizeof(disable)); if (unlikely(err)) WL_ERR("WLC_SET_RADIO error (%d)\n", err); @@ -2061,7 +2065,8 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, legacy = brcmf_find_msb(mask->control[IEEE80211_BAND_2GHZ].legacy); if (!legacy) - legacy = brcmf_find_msb(mask->control[IEEE80211_BAND_5GHZ].legacy); + legacy = brcmf_find_msb( + mask->control[IEEE80211_BAND_5GHZ].legacy); val = wl_g_rates[legacy - 1].bitrate * 100000; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 48f10d0403a..ff5c19a9b91 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -341,7 +341,8 @@ static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, } #define for_each_bss(list, bss, __i) \ - for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss)) + for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, \ + bss = next_bss(list, bss)) extern s32 brcmf_cfg80211_attach(struct net_device *ndev, void *data); extern void brcmf_cfg80211_detach(void); From 7e0395ec28aec4ea9d62fca3281c413b8f42dcd3 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:39 +0200 Subject: [PATCH 0077/1519] staging: brcm80211: fixed checkpatch warnings for brcmutil dir Most of them being 'line longer than 80 chars' type of warning. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmutil/utils.c | 9 ++++++--- drivers/staging/brcm80211/brcmutil/wifi.c | 23 ++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 4b0815760d2..7b4d6586f03 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -489,8 +489,8 @@ static const u8 crc8_table[256] = { }; u8 brcmu_crc8(u8 *pdata, /* pointer to array of data to process */ - uint nbytes, /* number of input data bytes to process */ - u8 crc /* either CRC8_INIT_VALUE or previous return value */ + uint nbytes, /* number of input data bytes to process */ + u8 crc /* either CRC8_INIT_VALUE or previous return value */ ) { /* loop over the buffer data */ while (nbytes-- > 0) @@ -586,7 +586,10 @@ brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, char *buf, } EXPORT_SYMBOL(brcmu_format_flags); -/* print bytes formatted as hex to a string. return the resulting string length */ +/* + * print bytes formatted as hex to a string. return the resulting + * string length + */ int brcmu_format_hex(char *str, const void *bytes, int len) { int i; diff --git a/drivers/staging/brcm80211/brcmutil/wifi.c b/drivers/staging/brcm80211/brcmutil/wifi.c index 1bce8887ddf..636515cc192 100644 --- a/drivers/staging/brcm80211/brcmutil/wifi.c +++ b/drivers/staging/brcm80211/brcmutil/wifi.c @@ -43,9 +43,9 @@ bool brcmu_chspec_malformed(u16 chanspec) EXPORT_SYMBOL(brcmu_chspec_malformed); /* - * This function returns the channel number that control traffic is being sent on, for legacy - * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ - * sideband depending on the chanspec selected + * This function returns the channel number that control traffic is being sent + * on, for legacy channels this is just the channel number, for 40MHZ channels + * it is the upper or lower 20MHZ sideband depending on the chanspec selected. */ u8 brcmu_chspec_ctlchan(u16 chspec) { @@ -55,15 +55,22 @@ u8 brcmu_chspec_ctlchan(u16 chspec) if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) { return CHSPEC_CHANNEL(chspec); } else { - /* we only support 40MHZ with sidebands */ - /* chanspec channel holds the centre frequency, use that and the - * side band information to reconstruct the control channel number + /* + * we only support 40MHZ with sidebands. chanspec channel holds + * the centre frequency, use that and the side band information + * to reconstruct the control channel number */ if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) - /* control chan is the upper 20 MHZ SB of the 40MHZ channel */ + /* + * control chan is the upper 20 MHZ SB of the + * 40MHZ channel + */ ctl_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec)); else - /* control chan is the lower 20 MHZ SB of the 40MHZ channel */ + /* + * control chan is the lower 20 MHZ SB of the + * 40MHZ channel + */ ctl_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec)); } From d7bfc088624dfedb32d04d02837177a0e4f49284 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:40 +0200 Subject: [PATCH 0078/1519] staging: brcm80211: fixed checkpatch warnings for 'include' dir All of them being 'line longer than 80 chars' type of warning. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/include/brcmu_utils.h | 3 +- .../staging/brcm80211/include/brcmu_wifi.h | 103 ++++++++++++------ .../staging/brcm80211/include/chipcommon.h | 9 +- drivers/staging/brcm80211/include/defs.h | 14 ++- drivers/staging/brcm80211/include/soc.h | 5 +- 5 files changed, 88 insertions(+), 46 deletions(-) diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index 513fa34f921..da13e243d39 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -264,7 +264,8 @@ struct brcmu_tlv { u8 data[1]; }; -#define ETHER_ADDR_STR_LEN 18 /* 18-bytes of Ethernet address buffer length */ +/* 18-bytes of Ethernet address buffer length */ +#define ETHER_ADDR_STR_LEN 18 /* externs */ /* crc */ diff --git a/drivers/staging/brcm80211/include/brcmu_wifi.h b/drivers/staging/brcm80211/include/brcmu_wifi.h index 949349f0bbd..717d88542b7 100644 --- a/drivers/staging/brcm80211/include/brcmu_wifi.h +++ b/drivers/staging/brcm80211/include/brcmu_wifi.h @@ -31,13 +31,16 @@ #define CH_EWA_VALID 0x04 #define CH_20MHZ_APART 4 #define CH_10MHZ_APART 2 -#define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */ +#define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */ #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */ #define BRCM_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */ -#define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216, - * this is that + 1 rounded up to a multiple of NBBY (8). - * DO NOT MAKE it > 255: channels are u8's all over - */ + +/* + * max # supported channels. The max channel no is 216, this is that + 1 + * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are + * u8's all over +*/ +#define MAXCHANNEL 224 #define WL_CHANSPEC_CHAN_MASK 0x00ff #define WL_CHANSPEC_CHAN_SHIFT 0 @@ -66,20 +69,30 @@ #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */ /* channel defines */ -#define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0) -#define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \ - ((channel) + CH_10MHZ_APART) : 0) -#define CHSPEC_BANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : \ - BAND_2G_INDEX) -#define CH20MHZ_CHSPEC(channel) (u16)((u16)(channel) | WL_CHANSPEC_BW_20 | \ - WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \ - WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) -#define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ - ((channel) + CH_20MHZ_APART) : 0) -#define CH40MHZ_CHSPEC(channel, ctlsb) (u16) \ - ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ - ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \ - WL_CHANSPEC_BAND_5G)) +#define LOWER_20_SB(channel) \ + (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0) + +#define UPPER_20_SB(channel) \ + (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \ + ((channel) + CH_10MHZ_APART) : 0) + +#define CHSPEC_BANDUNIT(chspec) \ + (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX) + +#define CH20MHZ_CHSPEC(channel) \ + (u16)((u16)(channel) | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE | \ + (((channel) <= CH_MAX_2G_CHANNEL) ? \ + WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) + +#define NEXT_20MHZ_CHAN(channel) \ + (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ + ((channel) + CH_20MHZ_APART) : 0) + +#define CH40MHZ_CHSPEC(channel, ctlsb) \ + (u16)((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ + ((channel) <= CH_MAX_2G_CHANNEL ? \ + WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) + #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK)) #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) @@ -97,22 +110,40 @@ #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK) #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK) -#define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) -#define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) + +#define CHSPEC_IS10(chspec) \ + (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) + +#define CHSPEC_IS20(chspec) \ + (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) + #ifndef CHSPEC_IS40 -#define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) +#define CHSPEC_IS40(chspec) \ + (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) #endif #endif /* !WL11N_20MHZONLY */ -#define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) -#define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) -#define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) -#define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) -#define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) -#define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \ - (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ - (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK)))) +#define CHSPEC_IS5G(chspec) \ + (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) + +#define CHSPEC_IS2G(chspec) \ + (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) + +#define CHSPEC_SB_NONE(chspec) \ + (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) + +#define CHSPEC_SB_UPPER(chspec) \ + (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) + +#define CHSPEC_SB_LOWER(chspec) \ + (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) + +#define CHSPEC_CTL_CHAN(chspec) \ + ((CHSPEC_SB_LOWER(chspec)) ? \ + (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ + (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK)))) + #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G) #define CHANSPEC_STR_LEN 8 @@ -147,9 +178,9 @@ extern bool brcmu_chspec_malformed(u16 chanspec); /* - * This function returns the channel number that control traffic is being sent on, for legacy - * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ - * sideband depending on the chanspec selected + * This function returns the channel number that control traffic is being sent + * on, for legacy channels this is just the channel number, for 40MHZ channels + * it is the upper or lower 20MHZ sideband depending on the chanspec selected. */ extern u8 brcmu_chspec_ctlchan(u16 chspec); @@ -185,11 +216,13 @@ extern int brcmu_mhz2channel(uint freq, uint start_factor); #define CRYPTO_ALGO_NALG 7 /* wireless security bitvec */ + #define WEP_ENABLED 0x0001 #define TKIP_ENABLED 0x0002 #define AES_ENABLED 0x0004 #define WSEC_SWFLAG 0x0008 -#define SES_OW_ENABLED 0x0040 /* to go into transition mode without setting wep */ +/* to go into transition mode without setting wep */ +#define SES_OW_ENABLED 0x0040 /* WPA authentication mode bitvec */ #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */ @@ -198,7 +231,7 @@ extern int brcmu_mhz2channel(uint freq, uint start_factor); #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */ #define WPA_AUTH_RESERVED1 0x0008 #define WPA_AUTH_RESERVED2 0x0010 - /* #define WPA_AUTH_8021X 0x0020 *//* 802.1x, reserved */ + #define WPA2_AUTH_RESERVED1 0x0020 #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */ #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */ diff --git a/drivers/staging/brcm80211/include/chipcommon.h b/drivers/staging/brcm80211/include/chipcommon.h index 8de5913031d..fefabc39e64 100644 --- a/drivers/staging/brcm80211/include/chipcommon.h +++ b/drivers/staging/brcm80211/include/chipcommon.h @@ -231,7 +231,8 @@ struct chipcregs { #define CC_CAP_UARTS_MASK 0x00000003 /* Number of UARTs */ #define CC_CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */ #define CC_CAP_UCLKSEL 0x00000018 /* UARTs clock select */ -#define CC_CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */ +/* UARTs are driven by internal divided clock */ +#define CC_CAP_UINTCLK 0x00000008 #define CC_CAP_UARTGPIO 0x00000020 /* UARTs own GPIOs 15:12 */ #define CC_CAP_EXTBUS_MASK 0x000000c0 /* External bus mask */ #define CC_CAP_EXTBUS_NONE 0x00000000 /* No ExtBus present */ @@ -248,10 +249,12 @@ struct chipcregs { #define CC_CAP_BKPLN64 0x08000000 /* 64-bit backplane */ #define CC_CAP_PMU 0x10000000 /* PMU Present, rev >= 20 */ #define CC_CAP_SROM 0x40000000 /* Srom Present, rev >= 32 */ -#define CC_CAP_NFLASH 0x80000000 /* Nand flash present, rev >= 35 */ +/* Nand flash present, rev >= 35 */ +#define CC_CAP_NFLASH 0x80000000 #define CC_CAP2_SECI 0x00000001 /* SECI Present, rev >= 36 */ -#define CC_CAP2_GSIO 0x00000002 /* GSIO (spi/i2c) present, rev >= 37 */ +/* GSIO (spi/i2c) present, rev >= 37 */ +#define CC_CAP2_GSIO 0x00000002 /* pmucapabilities */ #define PCAP_REV_MASK 0x000000ff diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h index 838424c05e5..8e0c559398c 100644 --- a/drivers/staging/brcm80211/include/defs.h +++ b/drivers/staging/brcm80211/include/defs.h @@ -55,8 +55,10 @@ #define WL_NUMRATES 16 /* max # of rates in a rateset */ struct brcm_rateset { - u32 count; /* # rates in this set */ - u8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */ + /* # rates in this set */ + u32 count; + /* rates in 500kbps units w/hi bit set if basic */ + u8 rates[WL_NUMRATES]; }; #define BRCM_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NUL */ @@ -71,10 +73,12 @@ struct brcm_rateset { #define BRCM_GET_PHYLIST 180 /* Bit masks for radio disabled status - returned by WL_GET_RADIO */ + #define WL_RADIO_SW_DISABLE (1<<0) #define WL_RADIO_HW_DISABLE (1<<1) #define WL_RADIO_MPC_DISABLE (1<<2) -#define WL_RADIO_COUNTRY_DISABLE (1<<3) /* some countries don't support any channel */ +/* some countries don't support any channel */ +#define WL_RADIO_COUNTRY_DISABLE (1<<3) /* Override bit for SET_TXPWR. if set, ignore other level limits */ #define WL_TXPWR_OVERRIDE (1U<<31) @@ -100,7 +104,9 @@ struct brcm_rateset { /* * Sonics Configuration Space Registers. */ -#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */ + +/* core sbconfig regs are top 256bytes of regs */ +#define SBCONFIGOFF 0xf00 /* cpp contortions to concatenate w/arg prescan */ #ifndef PAD diff --git a/drivers/staging/brcm80211/include/soc.h b/drivers/staging/brcm80211/include/soc.h index 6e5a705c493..f23edc5d307 100644 --- a/drivers/staging/brcm80211/include/soc.h +++ b/drivers/staging/brcm80211/include/soc.h @@ -81,9 +81,8 @@ #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ -#define DEF_AI_COMP 0xfff /* Default component, in ai chips it maps all - * unused address ranges - */ +/* Default component, in ai chips it maps all unused address ranges */ +#define DEF_AI_COMP 0xfff /* Common core control flags */ #define SICF_BIST_EN 0x8000 From 5b7ea9d06e2ea33f10a7ff7549a680f433b77573 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:41 +0200 Subject: [PATCH 0079/1519] staging: brcm80211: use PCI_DEVICE() macro in device table The macro PCI_DEVICE() fills in the entry in abbreviated manner. Using this removes the "lines over 80 characters" checkpatch warning on these entries. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 35d9ee86f29..1437e51a237 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -95,11 +95,10 @@ MODULE_LICENSE("Dual BSD/GPL"); /* recognized PCI IDs */ static DEFINE_PCI_DEVICE_TABLE(brcms_pci_id_table) = { - {PCI_VENDOR_ID_BROADCOM, 0x4357, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43225 2G */ - {PCI_VENDOR_ID_BROADCOM, 0x4353, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43224 DUAL */ - {PCI_VENDOR_ID_BROADCOM, 0x4727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 4313 DUAL */ - /* 43224 Ven */ - {PCI_VENDOR_ID_BROADCOM, 0x0576, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, /* 43225 2G */ + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, /* 43224 DUAL */ + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, /* 4313 DUAL */ + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, /* 43224 Ven */ {0} }; From 7cdac4ff8deba68234e110d560876763943f9fa6 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:42 +0200 Subject: [PATCH 0080/1519] staging: brcm80211: remove unused rx status definitions The file pub.h contained a number of definitions that are not used in the brcmsmac driver and consequently have been removed. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/pub.h | 33 ------------------------ 1 file changed, 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 9b847b34efa..bfbdc3a54c3 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -308,39 +308,6 @@ struct wl_rxsts { struct brcms_if *wlif; /* wl interface */ }; -/* status per error RX pkt */ -#define WL_RXS_CRC_ERROR 0x00000001 /* CRC Error in packet */ -#define WL_RXS_RUNT_ERROR 0x00000002 /* Runt packet */ -#define WL_RXS_ALIGN_ERROR 0x00000004 /* Misaligned packet */ -#define WL_RXS_OVERSIZE_ERROR 0x00000008 /* packet bigger than RX_LENGTH (usually 1518) */ -#define WL_RXS_WEP_ICV_ERROR 0x00000010 /* Integrity Check Value error */ -#define WL_RXS_WEP_ENCRYPTED 0x00000020 /* Encrypted with WEP */ -#define WL_RXS_PLCP_SHORT 0x00000040 /* Short PLCP error */ -#define WL_RXS_DECRYPT_ERR 0x00000080 /* Decryption error */ -#define WL_RXS_OTHER_ERR 0x80000000 /* Other errors */ - -/* phy type */ -#define WL_RXS_PHY_A 0x00000000 /* A phy type */ -#define WL_RXS_PHY_B 0x00000001 /* B phy type */ -#define WL_RXS_PHY_G 0x00000002 /* G phy type */ -#define WL_RXS_PHY_N 0x00000004 /* N phy type */ - -/* encoding */ -#define WL_RXS_ENCODING_CCK 0x00000000 /* CCK encoding */ -#define WL_RXS_ENCODING_OFDM 0x00000001 /* OFDM encoding */ - -/* preamble */ -#define WL_RXS_UNUSED_STUB 0x0 /* stub to match with wlc_ethereal.h */ -#define WL_RXS_PREAMBLE_SHORT 0x00000001 /* Short preamble */ -#define WL_RXS_PREAMBLE_LONG 0x00000002 /* Long preamble */ -#define WL_RXS_PREAMBLE_MIMO_MM 0x00000003 /* MIMO mixed mode preamble */ -#define WL_RXS_PREAMBLE_MIMO_GF 0x00000004 /* MIMO green field preamble */ - -#define WL_RXS_NFRM_AMPDU_FIRST 0x00000001 /* first MPDU in A-MPDU */ -#define WL_RXS_NFRM_AMPDU_SUB 0x00000002 /* subsequent MPDU(s) in A-MPDU */ -#define WL_RXS_NFRM_AMSDU_FIRST 0x00000004 /* first MSDU in A-MSDU */ -#define WL_RXS_NFRM_AMSDU_SUB 0x00000008 /* subsequent MSDU(s) in A-MSDU */ - enum wlc_par_id { IOV_MPC = 1, IOV_RTSTHRESH, From 419ad34e819cd90056eea8bb5de63c338fbbc3bd Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:43 +0200 Subject: [PATCH 0081/1519] staging: brcm80211: reformat long lines in brcmsmac to 80 columns Linux coding style strongly suggest to limit length of source lines to 80 characters. This commit correct this for the brcmsmac sources. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 191 +++-- drivers/staging/brcm80211/brcmsmac/aiutils.h | 21 +- drivers/staging/brcm80211/brcmsmac/ampdu.c | 196 +++-- drivers/staging/brcm80211/brcmsmac/antsel.c | 15 +- drivers/staging/brcm80211/brcmsmac/channel.c | 151 ++-- drivers/staging/brcm80211/brcmsmac/channel.h | 15 +- drivers/staging/brcm80211/brcmsmac/d11.h | 599 +++++++++------ drivers/staging/brcm80211/brcmsmac/dma.c | 247 +++--- drivers/staging/brcm80211/brcmsmac/dma.h | 15 +- .../staging/brcm80211/brcmsmac/mac80211_if.c | 26 +- .../staging/brcm80211/brcmsmac/mac80211_if.h | 9 +- drivers/staging/brcm80211/brcmsmac/main.c | 701 ++++++++++++------ drivers/staging/brcm80211/brcmsmac/main.h | 696 ++++++++++------- drivers/staging/brcm80211/brcmsmac/otp.c | 32 +- drivers/staging/brcm80211/brcmsmac/otp.h | 3 +- drivers/staging/brcm80211/brcmsmac/phy_shim.c | 9 +- drivers/staging/brcm80211/brcmsmac/phy_shim.h | 60 +- drivers/staging/brcm80211/brcmsmac/pmu.c | 10 +- drivers/staging/brcm80211/brcmsmac/pub.h | 184 +++-- drivers/staging/brcm80211/brcmsmac/rate.c | 104 +-- drivers/staging/brcm80211/brcmsmac/rate.h | 143 ++-- drivers/staging/brcm80211/brcmsmac/scb.h | 35 +- drivers/staging/brcm80211/brcmsmac/srom.c | 70 +- drivers/staging/brcm80211/brcmsmac/stf.c | 54 +- drivers/staging/brcm80211/brcmsmac/types.h | 186 +++-- 25 files changed, 2387 insertions(+), 1385 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index bc4e2e14a21..4b1c60ffc47 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -28,48 +28,68 @@ #include "aiutils.h" /* slow_clk_ctl */ -#define SCC_SS_MASK 0x00000007 /* slow clock source mask */ -#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */ -#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */ -#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */ -#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */ -#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, - * 0: LPO is enabled - */ -#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, - * 0: power logic control - */ -#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors - * PLL clock disable requests from core - */ -#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't - * disable crystal when appropriate - */ -#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */ -#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */ + /* slow clock source mask */ +#define SCC_SS_MASK 0x00000007 + /* source of slow clock is LPO */ +#define SCC_SS_LPO 0x00000000 + /* source of slow clock is crystal */ +#define SCC_SS_XTAL 0x00000001 + /* source of slow clock is PCI */ +#define SCC_SS_PCI 0x00000002 + /* LPOFreqSel, 1: 160Khz, 0: 32KHz */ +#define SCC_LF 0x00000200 + /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */ +#define SCC_LP 0x00000400 + /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */ +#define SCC_FS 0x00000800 + /* IgnorePllOffReq, 1/0: + * power logic ignores/honors PLL clock disable requests from core + */ +#define SCC_IP 0x00001000 + /* XtalControlEn, 1/0: + * power logic does/doesn't disable crystal when appropriate + */ +#define SCC_XC 0x00002000 + /* XtalPU (RO), 1/0: crystal running/disabled */ +#define SCC_XP 0x00004000 + /* ClockDivider (SlowClk = 1/(4+divisor)) */ +#define SCC_CD_MASK 0xffff0000 #define SCC_CD_SHIFT 16 /* system_clk_ctl */ -#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */ -#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */ -#define SYCC_FP 0x00000004 /* ForcePLLOn */ -#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */ -#define SYCC_HR 0x00000010 /* Force HT */ -#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4 * (divisor + 1)) */ + /* ILPen: Enable Idle Low Power */ +#define SYCC_IE 0x00000001 + /* ALPen: Enable Active Low Power */ +#define SYCC_AE 0x00000002 + /* ForcePLLOn */ +#define SYCC_FP 0x00000004 + /* Force ALP (or HT if ALPen is not set */ +#define SYCC_AR 0x00000008 + /* Force HT */ +#define SYCC_HR 0x00000010 + /* ClkDiv (ILP = 1/(4 * (divisor + 1)) */ +#define SYCC_CD_MASK 0xffff0000 #define SYCC_CD_SHIFT 16 #define CST4329_SPROM_OTP_SEL_MASK 0x00000003 -#define CST4329_DEFCIS_SEL 0 /* OTP is powered up, use def. CIS, no SPROM */ -#define CST4329_SPROM_SEL 1 /* OTP is powered up, SPROM is present */ -#define CST4329_OTP_SEL 2 /* OTP is powered up, no SPROM */ -#define CST4329_OTP_PWRDN 3 /* OTP is powered down, SPROM is present */ + /* OTP is powered up, use def. CIS, no SPROM */ +#define CST4329_DEFCIS_SEL 0 + /* OTP is powered up, SPROM is present */ +#define CST4329_SPROM_SEL 1 + /* OTP is powered up, no SPROM */ +#define CST4329_OTP_SEL 2 + /* OTP is powered down, SPROM is present */ +#define CST4329_OTP_PWRDN 3 + #define CST4329_SPI_SDIO_MODE_MASK 0x00000004 #define CST4329_SPI_SDIO_MODE_SHIFT 2 /* 43224 chip-specific ChipControl register bits */ #define CCTRL43224_GPIO_TOGGLE 0x8000 -#define CCTRL_43224A0_12MA_LED_DRIVE 0x00F000F0 /* 12 mA drive strength */ -#define CCTRL_43224B0_12MA_LED_DRIVE 0xF0 /* 12 mA drive strength for later 43224s */ + /* 12 mA drive strength */ +#define CCTRL_43224A0_12MA_LED_DRIVE 0x00F000F0 + /* 12 mA drive strength for later 43224s */ +#define CCTRL_43224B0_12MA_LED_DRIVE 0xF0 /* 43236 Chip specific ChipStatus register bits */ #define CST43236_SFLASH_MASK 0x00000040 @@ -78,29 +98,44 @@ #define CST43236_BP_CLK 0x00000200 /* 120/96Mbps */ #define CST43236_BOOT_MASK 0x00001800 #define CST43236_BOOT_SHIFT 11 -#define CST43236_BOOT_FROM_SRAM 0 /* boot from SRAM, ARM in reset */ -#define CST43236_BOOT_FROM_ROM 1 /* boot from ROM */ -#define CST43236_BOOT_FROM_FLASH 2 /* boot from FLASH */ +#define CST43236_BOOT_FROM_SRAM 0 /* boot from SRAM, ARM in reset */ +#define CST43236_BOOT_FROM_ROM 1 /* boot from ROM */ +#define CST43236_BOOT_FROM_FLASH 2 /* boot from FLASH */ #define CST43236_BOOT_FROM_INVALID 3 /* 4331 chip-specific ChipControl register bits */ -#define CCTRL4331_BT_COEXIST (1<<0) /* 0 disable */ -#define CCTRL4331_SECI (1<<1) /* 0 SECI is disabled (JATG functional) */ -#define CCTRL4331_EXT_LNA (1<<2) /* 0 disable */ -#define CCTRL4331_SPROM_GPIO13_15 (1<<3) /* sprom/gpio13-15 mux */ -#define CCTRL4331_EXTPA_EN (1<<4) /* 0 ext pa disable, 1 ext pa enabled */ -#define CCTRL4331_GPIOCLK_ON_SPROMCS (1<<5) /* set drive out GPIO_CLK on sprom_cs pin */ -#define CCTRL4331_PCIE_MDIO_ON_SPROMCS (1<<6) /* use sprom_cs pin as PCIE mdio interface */ -#define CCTRL4331_EXTPA_ON_GPIO2_5 (1<<7) /* aband extpa will be at gpio2/5 and sprom_dout */ -#define CCTRL4331_OVR_PIPEAUXCLKEN (1<<8) /* override core control on pipe_AuxClkEnable */ -#define CCTRL4331_OVR_PIPEAUXPWRDOWN (1<<9) /* override core control on pipe_AuxPowerDown */ -#define CCTRL4331_PCIE_AUXCLKEN (1<<10) /* pcie_auxclkenable */ -#define CCTRL4331_PCIE_PIPE_PLLDOWN (1<<11) /* pcie_pipe_pllpowerdown */ -#define CCTRL4331_BT_SHD0_ON_GPIO4 (1<<16) /* enable bt_shd0 at gpio4 */ -#define CCTRL4331_BT_SHD1_ON_GPIO5 (1<<17) /* enable bt_shd1 at gpio5 */ + /* 0 disable */ +#define CCTRL4331_BT_COEXIST (1<<0) + /* 0 SECI is disabled (JTAG functional) */ +#define CCTRL4331_SECI (1<<1) + /* 0 disable */ +#define CCTRL4331_EXT_LNA (1<<2) + /* sprom/gpio13-15 mux */ +#define CCTRL4331_SPROM_GPIO13_15 (1<<3) + /* 0 ext pa disable, 1 ext pa enabled */ +#define CCTRL4331_EXTPA_EN (1<<4) + /* set drive out GPIO_CLK on sprom_cs pin */ +#define CCTRL4331_GPIOCLK_ON_SPROMCS (1<<5) + /* use sprom_cs pin as PCIE mdio interface */ +#define CCTRL4331_PCIE_MDIO_ON_SPROMCS (1<<6) + /* aband extpa will be at gpio2/5 and sprom_dout */ +#define CCTRL4331_EXTPA_ON_GPIO2_5 (1<<7) + /* override core control on pipe_AuxClkEnable */ +#define CCTRL4331_OVR_PIPEAUXCLKEN (1<<8) + /* override core control on pipe_AuxPowerDown */ +#define CCTRL4331_OVR_PIPEAUXPWRDOWN (1<<9) + /* pcie_auxclkenable */ +#define CCTRL4331_PCIE_AUXCLKEN (1<<10) + /* pcie_pipe_pllpowerdown */ +#define CCTRL4331_PCIE_PIPE_PLLDOWN (1<<11) + /* enable bt_shd0 at gpio4 */ +#define CCTRL4331_BT_SHD0_ON_GPIO4 (1<<16) + /* enable bt_shd1 at gpio5 */ +#define CCTRL4331_BT_SHD1_ON_GPIO5 (1<<17) /* 4331 Chip specific ChipStatus register bits */ -#define CST4331_XTAL_FREQ 0x00000001 /* crystal frequency 20/40Mhz */ + /* crystal frequency 20/40Mhz */ +#define CST4331_XTAL_FREQ 0x00000001 #define CST4331_SPROM_PRESENT 0x00000002 #define CST4331_OTP_PRESENT 0x00000004 #define CST4331_LDO_RF 0x00000008 @@ -110,19 +145,26 @@ #define CST4319_SPI_CPULESSUSB 0x00000001 #define CST4319_SPI_CLK_POL 0x00000002 #define CST4319_SPI_CLK_PH 0x00000008 -#define CST4319_SPROM_OTP_SEL_MASK 0x000000c0 /* gpio [7:6], SDIO CIS selection */ + /* gpio [7:6], SDIO CIS selection */ +#define CST4319_SPROM_OTP_SEL_MASK 0x000000c0 #define CST4319_SPROM_OTP_SEL_SHIFT 6 -#define CST4319_DEFCIS_SEL 0x00000000 /* use default CIS, OTP is powered up */ -#define CST4319_SPROM_SEL 0x00000040 /* use SPROM, OTP is powered up */ -#define CST4319_OTP_SEL 0x00000080 /* use OTP, OTP is powered up */ -#define CST4319_OTP_PWRDN 0x000000c0 /* use SPROM, OTP is powered down */ -#define CST4319_SDIO_USB_MODE 0x00000100 /* gpio [8], sdio/usb mode */ + /* use default CIS, OTP is powered up */ +#define CST4319_DEFCIS_SEL 0x00000000 + /* use SPROM, OTP is powered up */ +#define CST4319_SPROM_SEL 0x00000040 + /* use OTP, OTP is powered up */ +#define CST4319_OTP_SEL 0x00000080 + /* use SPROM, OTP is powered down */ +#define CST4319_OTP_PWRDN 0x000000c0 + /* gpio [8], sdio/usb mode */ +#define CST4319_SDIO_USB_MODE 0x00000100 #define CST4319_REMAP_SEL_MASK 0x00000600 #define CST4319_ILPDIV_EN 0x00000800 #define CST4319_XTAL_PD_POL 0x00001000 #define CST4319_LPO_SEL 0x00002000 #define CST4319_RES_INIT_MODE 0x0000c000 -#define CST4319_PALDO_EXTPNP 0x00010000 /* PALDO is configured with external PNP */ + /* PALDO is configured with external PNP */ +#define CST4319_PALDO_EXTPNP 0x00010000 #define CST4319_CBUCK_MODE_MASK 0x00060000 #define CST4319_CBUCK_MODE_BURST 0x00020000 #define CST4319_CBUCK_MODE_LPBURST 0x00060000 @@ -153,7 +195,8 @@ #define CST4313_SPROM_OTP_SEL_SHIFT 0 /* 4313 Chip specific ChipControl register bits */ -#define CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */ + /* 12 mA drive strengh for later 4313 */ +#define CCTRL_4313_12MA_LED_DRIVE 0x00000007 #define BCM47162_DMP() ((sih->chip == BCM47162_CHIP_ID) && \ (sih->chiprev == 0) && \ @@ -227,9 +270,12 @@ #define SD_SG32 0x00000008 #define SD_SZ_ALIGN 0x00000fff -#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */ -#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal power-up */ -#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL power-down */ +/* PCI config space bit 4 for 4306c0 slow clock source */ +#define PCI_CFG_GPIO_SCS 0x10 +/* PCI config space GPIO 14 for Xtal power-up */ +#define PCI_CFG_GPIO_XTAL 0x40 +/* PCI config space GPIO 15 for PLL power-down */ +#define PCI_CFG_GPIO_PLL 0x80 /* power control defines */ #define PLL_DELAY 150 /* us pll on delay */ @@ -468,7 +514,8 @@ void ai_scan(struct si_pub *sih, void *regs) } eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); - SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, eromlim = 0x%p\n", regs, erombase, eromptr, eromlim)); + SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, " + "eromlim = 0x%p\n", regs, erombase, eromptr, eromlim)); while (eromptr < eromlim) { u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp; u32 mpd, asd, addrl, addrh, sizel, sizeh; @@ -502,7 +549,9 @@ void ai_scan(struct si_pub *sih, void *regs) nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT; nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT; - SI_VMSG(("Found component 0x%04x/0x%04x rev %d at erom addr 0x%p, with nmw = %d, " "nsw = %d, nmp = %d & nsp = %d\n", mfg, cid, crev, base, nmw, nsw, nmp, nsp)); + SI_VMSG(("Found component 0x%04x/0x%04x rev %d at erom addr " + "0x%p, with nmw = %d, nsw = %d, nmp = %d & nsp = %d\n", + mfg, cid, crev, base, nmw, nsw, nmp, nsp)); if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0)) continue; @@ -526,7 +575,8 @@ void ai_scan(struct si_pub *sih, void *regs) for (i = 0; i < nmp; i++) { mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID); if ((mpd & ER_TAG) != ER_MP) { - SI_ERROR(("Not enough MP entries for component 0x%x\n", cid)); + SI_ERROR(("Not enough MP entries for " + "component 0x%x\n", cid)); goto error; } SI_VMSG((" Master port %d, mp: %d id: %d\n", i, @@ -549,7 +599,8 @@ void ai_scan(struct si_pub *sih, void *regs) br = true; else if ((addrh != 0) || (sizeh != 0) || (sizel != SI_CORE_SIZE)) { - SI_ERROR(("First Slave ASD for core 0x%04x malformed " "(0x%08x)\n", cid, asd)); + SI_ERROR(("First Slave ASD for core 0x%04x " + "malformed (0x%08x)\n", cid, asd)); goto error; } } @@ -704,7 +755,8 @@ u32 ai_addrspace(struct si_pub *sih, uint asidx) else if (asidx == 1) return sii->coresba2[cidx]; else { - SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx)); + SI_ERROR(("%s: Need to parse the erom again to find addr " + "space %d\n", __func__, asidx)); return 0; } } @@ -723,7 +775,8 @@ u32 ai_addrspacesize(struct si_pub *sih, uint asidx) else if (asidx == 1) return sii->coresba2_size[cidx]; else { - SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx)); + SI_ERROR(("%s: Need to parse the erom again to find addr " + "space %d\n", __func__, asidx)); return 0; } } @@ -735,7 +788,8 @@ uint ai_flag(struct si_pub *sih) sii = SI_INFO(sih); if (BCM47162_DMP()) { - SI_ERROR(("%s: Attempting to read MIPS DMP registers on 47162a0", __func__)); + SI_ERROR(("%s: Attempting to read MIPS DMP registers " + "on 47162a0", __func__)); return sii->curidx; } ai = sii->curwrap; @@ -833,7 +887,8 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) sii = SI_INFO(sih); if (BCM47162_DMP()) { - SI_ERROR(("%s: Accessing MIPS DMP register (iostatus) on 47162a0", __func__)); + SI_ERROR(("%s: Accessing MIPS DMP register (iostatus) " + "on 47162a0", __func__)); return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index f881b449364..4c682a539e4 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -242,16 +242,23 @@ #define SRC_PRESENT 0x00000001 /* 4330 chip-specific ChipStatus register bits */ -#define CST4330_CHIPMODE_SDIOD(cs) (((cs) & 0x7) < 6) /* SDIO || gSPI */ -#define CST4330_CHIPMODE_USB20D(cs) (((cs) & 0x7) >= 6) /* USB || USBDA */ -#define CST4330_CHIPMODE_SDIO(cs) (((cs) & 0x4) == 0) /* SDIO */ -#define CST4330_CHIPMODE_GSPI(cs) (((cs) & 0x6) == 4) /* gSPI */ -#define CST4330_CHIPMODE_USB(cs) (((cs) & 0x7) == 6) /* USB packet-oriented */ -#define CST4330_CHIPMODE_USBDA(cs) (((cs) & 0x7) == 7) /* USB Direct Access */ + /* SDIO || gSPI */ +#define CST4330_CHIPMODE_SDIOD(cs) (((cs) & 0x7) < 6) + /* USB || USBDA */ +#define CST4330_CHIPMODE_USB20D(cs) (((cs) & 0x7) >= 6) + /* SDIO */ +#define CST4330_CHIPMODE_SDIO(cs) (((cs) & 0x4) == 0) + /* gSPI */ +#define CST4330_CHIPMODE_GSPI(cs) (((cs) & 0x6) == 4) + /* USB packet-oriented */ +#define CST4330_CHIPMODE_USB(cs) (((cs) & 0x7) == 6) + /* USB Direct Access */ +#define CST4330_CHIPMODE_USBDA(cs) (((cs) & 0x7) == 7) #define CST4330_OTP_PRESENT 0x00000010 #define CST4330_LPO_AUTODET_EN 0x00000020 #define CST4330_ARMREMAP_0 0x00000040 -#define CST4330_SPROM_PRESENT 0x00000080 /* takes priority over OTP if both set */ + /* takes priority over OTP if both set */ +#define CST4330_SPROM_PRESENT 0x00000080 #define CST4330_ILPDIV_EN 0x00000100 #define CST4330_LPO_SEL 0x00000200 #define CST4330_RES_INIT_MODE_SHIFT 10 diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index b462fc80bf3..64bbc242157 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -22,19 +22,32 @@ #include "main.h" #include "ampdu.h" -#define AMPDU_MAX_MPDU 32 /* max number of mpdus in an ampdu */ -#define AMPDU_NUM_MPDU_LEGACY 16 /* max number of mpdus in an ampdu to a legacy */ -#define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */ -#define AMPDU_TX_BA_DEF_WSIZE 64 /* default Tx ba window size (in pdu) */ -#define AMPDU_RX_BA_DEF_WSIZE 64 /* max Rx ba window size (in pdu) */ -#define AMPDU_RX_BA_MAX_WSIZE 64 /* default Rx ba window size (in pdu) */ -#define AMPDU_MAX_DUR 5 /* max dur of tx ampdu (in msec) */ -#define AMPDU_DEF_RETRY_LIMIT 5 /* default tx retry limit */ -#define AMPDU_DEF_RR_RETRY_LIMIT 2 /* default tx retry limit at reg rate */ -#define AMPDU_DEF_TXPKT_WEIGHT 2 /* default weight of ampdu in txfifo */ -#define AMPDU_DEF_FFPLD_RSVD 2048 /* default ffpld reserved bytes */ -#define AMPDU_INI_FREE 10 /* # of inis to be freed on detach */ -#define AMPDU_SCB_MAX_RELEASE 20 /* max # of mpdus released at a time */ +/* max number of mpdus in an ampdu */ +#define AMPDU_MAX_MPDU 32 +/* max number of mpdus in an ampdu to a legacy */ +#define AMPDU_NUM_MPDU_LEGACY 16 +/* max Tx ba window size (in pdu) */ +#define AMPDU_TX_BA_MAX_WSIZE 64 +/* default Tx ba window size (in pdu) */ +#define AMPDU_TX_BA_DEF_WSIZE 64 +/* default Rx ba window size (in pdu) */ +#define AMPDU_RX_BA_DEF_WSIZE 64 +/* max Rx ba window size (in pdu) */ +#define AMPDU_RX_BA_MAX_WSIZE 64 +/* max dur of tx ampdu (in msec) */ +#define AMPDU_MAX_DUR 5 +/* default tx retry limit */ +#define AMPDU_DEF_RETRY_LIMIT 5 +/* default tx retry limit at reg rate */ +#define AMPDU_DEF_RR_RETRY_LIMIT 2 +/* default weight of ampdu in txfifo */ +#define AMPDU_DEF_TXPKT_WEIGHT 2 +/* default ffpld reserved bytes */ +#define AMPDU_DEF_FFPLD_RSVD 2048 +/* # of inis to be freed on detach */ +#define AMPDU_INI_FREE 10 +/* max # of mpdus released at a time */ +#define AMPDU_SCB_MAX_RELEASE 20 #define NUM_FFPLD_FIFO 4 /* number of fifo concerned by pre-loading */ #define FFPLD_TX_MAX_UNFL 200 /* default value of the average number of ampdu @@ -59,44 +72,70 @@ * some counters might be redundant with the ones in wlc or ampdu structures. * This allows to maintain a specific state independently of * how often and/or when the wlc counters are updated. + * + * ampdu_pld_size: number of bytes to be pre-loaded + * mcs2ampdu_table: per-mcs max # of mpdus in an ampdu + * prev_txfunfl: num of underflows last read from the HW macstats counter + * accum_txfunfl: num of underflows since we modified pld params + * accum_txampdu: num of tx ampdu since we modified pld params + * prev_txampdu: previous reading of tx ampdu + * dmaxferrate: estimated dma avg xfer rate in kbits/sec */ struct brcms_fifo_info { - u16 ampdu_pld_size; /* number of bytes to be pre-loaded */ - u8 mcs2ampdu_table[FFPLD_MAX_MCS + 1]; /* per-mcs max # of mpdus in an ampdu */ - u16 prev_txfunfl; /* num of underflows last read from the HW macstats counter */ - u32 accum_txfunfl; /* num of underflows since we modified pld params */ - u32 accum_txampdu; /* num of tx ampdu since we modified pld params */ - u32 prev_txampdu; /* previous reading of tx ampdu */ - u32 dmaxferrate; /* estimated dma avg xfer rate in kbits/sec */ + u16 ampdu_pld_size; + u8 mcs2ampdu_table[FFPLD_MAX_MCS + 1]; + u16 prev_txfunfl; + u32 accum_txfunfl; + u32 accum_txampdu; + u32 prev_txampdu; + u32 dmaxferrate; }; -/* AMPDU module specific state */ +/* AMPDU module specific state + * + * wlc: pointer to main wlc structure + * scb_handle: scb cubby handle to retrieve data from scb + * ini_enable: per-tid initiator enable/disable of ampdu + * ba_tx_wsize: Tx ba window size (in pdu) + * ba_rx_wsize: Rx ba window size (in pdu) + * retry_limit: mpdu transmit retry limit + * rr_retry_limit: mpdu transmit retry limit at regular rate + * retry_limit_tid: per-tid mpdu transmit retry limit + * rr_retry_limit_tid: per-tid mpdu transmit retry limit at regular rate + * mpdu_density: min mpdu spacing (0-7) ==> 2^(x-1)/8 usec + * max_pdu: max pdus allowed in ampdu + * dur: max duration of an ampdu (in msec) + * txpkt_weight: weight of ampdu in txfifo; reduces rate lag + * rx_factor: maximum rx ampdu factor (0-3) ==> 2^(13+x) bytes + * ffpld_rsvd: number of bytes to reserve for preload + * max_txlen: max size of ampdu per mcs, bw and sgi + * ini_free: array of ini's to be freed on detach + * mfbr: enable multiple fallback rate + * tx_max_funl: underflows should be kept such that + * (tx_max_funfl*underflows) < tx frames + * fifo_tb: table of fifo infos + */ struct ampdu_info { - struct brcms_c_info *wlc; /* pointer to main wlc structure */ - int scb_handle; /* scb cubby handle to retrieve data from scb */ - u8 ini_enable[AMPDU_MAX_SCB_TID]; /* per-tid initiator enable/disable of ampdu */ - u8 ba_tx_wsize; /* Tx ba window size (in pdu) */ - u8 ba_rx_wsize; /* Rx ba window size (in pdu) */ - u8 retry_limit; /* mpdu transmit retry limit */ - u8 rr_retry_limit; /* mpdu transmit retry limit at regular rate */ - u8 retry_limit_tid[AMPDU_MAX_SCB_TID]; /* per-tid mpdu transmit retry limit */ - /* per-tid mpdu transmit retry limit at regular rate */ + struct brcms_c_info *wlc; + int scb_handle; + u8 ini_enable[AMPDU_MAX_SCB_TID]; + u8 ba_tx_wsize; + u8 ba_rx_wsize; + u8 retry_limit; + u8 rr_retry_limit; + u8 retry_limit_tid[AMPDU_MAX_SCB_TID]; u8 rr_retry_limit_tid[AMPDU_MAX_SCB_TID]; - u8 mpdu_density; /* min mpdu spacing (0-7) ==> 2^(x-1)/8 usec */ - s8 max_pdu; /* max pdus allowed in ampdu */ - u8 dur; /* max duration of an ampdu (in msec) */ - u8 txpkt_weight; /* weight of ampdu in txfifo; reduces rate lag */ - u8 rx_factor; /* maximum rx ampdu factor (0-3) ==> 2^(13+x) bytes */ - u32 ffpld_rsvd; /* number of bytes to reserve for preload */ - u32 max_txlen[MCS_TABLE_SIZE][2][2]; /* max size of ampdu per mcs, bw and sgi */ - void *ini_free[AMPDU_INI_FREE]; /* array of ini's to be freed on detach */ - bool mfbr; /* enable multiple fallback rate */ - u32 tx_max_funl; /* underflows should be kept such that - * (tx_max_funfl*underflows) < tx frames - */ - /* table of fifo infos */ + u8 mpdu_density; + s8 max_pdu; + u8 dur; + u8 txpkt_weight; + u8 rx_factor; + u32 ffpld_rsvd; + u32 max_txlen[MCS_TABLE_SIZE][2][2]; + void *ini_free[AMPDU_INI_FREE]; + bool mfbr; + u32 tx_max_funl; struct brcms_fifo_info fifo_tb[NUM_FFPLD_FIFO]; - }; /* used for flushing ampdu packets */ @@ -163,7 +202,10 @@ struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc) ampdu->txpkt_weight = AMPDU_DEF_TXPKT_WEIGHT; ampdu->ffpld_rsvd = AMPDU_DEF_FFPLD_RSVD; - /* bump max ampdu rcv size to 64k for all 11n devices except 4321A0 and 4321A1 */ + /* + * bump max ampdu rcv size to 64k for all 11n + * devices except 4321A0 and 4321A1 + */ if (BRCMS_ISNPHY(wlc->band) && NREV_LT(wlc->band->phyrev, 2)) ampdu->rx_factor = IEEE80211_HT_MAX_AMPDU_32K; else @@ -194,7 +236,10 @@ void brcms_c_ampdu_detach(struct ampdu_info *ampdu) if (!ampdu) return; - /* free all ini's which were to be freed on callbacks which were never called */ + /* + * free all ini's which were to be freed on + * callbacks which were never called + */ for (i = 0; i < AMPDU_INI_FREE; i++) kfree(ampdu->ini_free[i]); @@ -220,7 +265,8 @@ static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, if (ampdu->max_pdu != AUTO) scb_ampdu->max_pdu = (u8) ampdu->max_pdu; - scb_ampdu->release = min_t(u8, scb_ampdu->max_pdu, AMPDU_SCB_MAX_RELEASE); + scb_ampdu->release = min_t(u8, scb_ampdu->max_pdu, + AMPDU_SCB_MAX_RELEASE); if (scb_ampdu->max_rx_ampdu_bytes) scb_ampdu->release = min_t(u8, scb_ampdu->release, @@ -321,8 +367,8 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) return 0; } - max_mpdu = - min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], AMPDU_NUM_MPDU_LEGACY); + max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], + AMPDU_NUM_MPDU_LEGACY); /* In case max value max_pdu is already lower than the fifo depth, there is nothing more we can do. @@ -344,11 +390,12 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) brcms_c_scb_ampdu_update_config_all(ampdu); /* - compute a new dma xfer rate for max_mpdu @ max mcs. - This is the minimum dma rate that - can achieve no underflow condition for the current mpdu size. + * compute a new dma xfer rate for max_mpdu @ max mcs. + * This is the minimum dma rate that can achieve no + * underflow condition for the current mpdu size. + * + * note : we divide/multiply by 100 to avoid integer overflows */ - /* note : we divide/multiply by 100 to avoid integer overflows */ fifo->dmaxferrate = (((phy_rate / 100) * (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) @@ -387,8 +434,8 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) /* recompute the dma rate */ /* note : we divide/multiply by 100 to avoid integer overflows */ - max_mpdu = - min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], AMPDU_NUM_MPDU_LEGACY); + max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], + AMPDU_NUM_MPDU_LEGACY); phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); dma_rate = (((phy_rate / 100) * @@ -666,9 +713,13 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, if (count == scb_ampdu->max_pdu) break; - /* check to see if the next pkt is a candidate for aggregation */ + /* + * check to see if the next pkt is + * a candidate for aggregation + */ p = pktq_ppeek(&qi->q, prec); - tx_info = IEEE80211_SKB_CB(p); /* tx_info must be checked with current p */ + /* tx_info must be checked with current p */ + tx_info = IEEE80211_SKB_CB(p); if (p) { if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && @@ -683,7 +734,10 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, continue; } - /* check if there are enough descriptors available */ + /* + * check if there are enough + * descriptors available + */ if (TXAVAIL(wlc, fifo) <= (seg_cnt + 1)) { wiphy_err(wiphy, "%s: No fifo space " "!!\n", __func__); @@ -962,10 +1016,13 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, supr_status == TX_STATUS_SUPR_EXPTIME) { retry = false; } else if (supr_status == TX_STATUS_SUPR_EXPTIME) { - /* TX underflow : try tuning pre-loading or ampdu size */ + /* TX underflow: + * try tuning pre-loading or ampdu size + */ } else if (supr_status == TX_STATUS_SUPR_FRAG) { - /* if there were underflows, but pre-loading is not active, - notify rate adaptation. + /* + * if there were underflows, but pre-loading + * is not active, notify rate adaptation. */ if (brcms_c_ffpld_check_txfunfl(wlc, prio2fifo[tid]) > 0) @@ -1013,7 +1070,10 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, ini->tx_in_transit--; ini->txretry[index] = 0; - /* ampdu_ack_len: number of acked aggregated frames */ + /* + * ampdu_ack_len: + * number of acked aggregated frames + */ /* ampdu_len: number of aggregated frames */ brcms_c_ampdu_rate_status(wlc, tx_info, txs, mcs); @@ -1038,11 +1098,14 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, if (retry && (txrate[0].count < (int)retry_limit)) { ini->txretry[index]++; ini->tx_in_transit--; - /* Use high prededence for retransmit to give some punch */ + /* + * Use high prededence for retransmit to + * give some punch + */ /* brcms_c_txq_enq(wlc, scb, p, * BRCMS_PRIO_TO_PREC(tid)); */ brcms_c_txq_enq(wlc, scb, p, - BRCMS_PRIO_TO_HI_PREC(tid)); + BRCMS_PRIO_TO_HI_PREC(tid)); } else { /* Retry timeout */ ini->tx_in_transit--; @@ -1150,7 +1213,10 @@ void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu) { struct brcms_c_info *wlc = ampdu->wlc; - /* Extend ucode internal watchdog timer to match larger received frames */ + /* + * Extend ucode internal watchdog timer to + * match larger received frames + */ if ((ampdu->rx_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) == IEEE80211_HT_MAX_AMPDU_64K) { brcms_c_write_shm(wlc, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX); diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index 5a5d5d6569a..23e04537995 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -259,7 +259,10 @@ static u8 brcms_c_antsel_id2antcfg(struct antsel_info *asi, u8 id) return antcfg; } -/* boardlevel antenna selection: convert ant_cfg to mimo_antsel (ucode interface) */ +/* + * boardlevel antenna selection: + * convert ant_cfg to mimo_antsel (ucode interface) + */ static u16 brcms_c_antsel_antcfg2antsel(struct antsel_info *asi, u8 ant_cfg) { u8 idx = BRCMS_ANTIDX_11N(BRCMS_ANTSEL_11N(ant_cfg)); @@ -293,7 +296,10 @@ static int brcms_c_antsel_cfgupd(struct antsel_info *asi, ant_cfg = antsel->ant_config[ANT_SELCFG_TX_DEF]; mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); brcms_c_write_shm(wlc, M_MIMO_ANTSEL_TXDFLT, mimo_antsel); - /* Update driver stats for currently selected default tx/rx antenna config */ + /* + * Update driver stats for currently selected + * default tx/rx antenna config + */ asi->antcfg_cur.ant_config[ANT_SELCFG_TX_DEF] = ant_cfg; /* 2) Update RX antconfig for all frames that are not unicast data @@ -302,7 +308,10 @@ static int brcms_c_antsel_cfgupd(struct antsel_info *asi, ant_cfg = antsel->ant_config[ANT_SELCFG_RX_DEF]; mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); brcms_c_write_shm(wlc, M_MIMO_ANTSEL_RXDFLT, mimo_antsel); - /* Update driver stats for currently selected default tx/rx antenna config */ + /* + * Update driver stats for currently selected + * default tx/rx antenna config + */ asi->antcfg_cur.ant_config[ANT_SELCFG_RX_DEF] = ant_cfg; return 0; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index a738e3bd0a1..b9cb892377e 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -151,9 +151,9 @@ const struct brcms_chanvec chanvec_all_5G = { /* Channels 52 - 64, 100 - 140 */ static const struct brcms_chanvec radar_set1 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, /* 52 - 60 */ - 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, /* 64, 100 - 124 */ - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128 - 140 */ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, /* 52 - 60 */ + 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, /* 64, 100 - 124 */ + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128 - 140 */ 0x00, 0x00, 0x00, 0x00} }; @@ -220,15 +220,19 @@ static const struct brcms_chanvec restricted_set_12_13_14 = { #define LOCALE_CHAN_52_140_ALL (1<<14) #define LOCALE_SET_5G_HIGH4 (1<<15) /* 184-216 */ -#define LOCALE_CHAN_36_64 (LOCALE_SET_5G_LOW1 | LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_52_64 (LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_100_124 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2) -#define LOCALE_CHAN_100_140 \ - (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2 | LOCALE_SET_5G_MID3 | LOCALE_SET_5G_HIGH1) -#define LOCALE_CHAN_149_165 (LOCALE_SET_5G_HIGH2 | LOCALE_SET_5G_HIGH3) -#define LOCALE_CHAN_184_216 LOCALE_SET_5G_HIGH4 +#define LOCALE_CHAN_36_64 (LOCALE_SET_5G_LOW1 | \ + LOCALE_SET_5G_LOW2 | \ + LOCALE_SET_5G_LOW3) +#define LOCALE_CHAN_52_64 (LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) +#define LOCALE_CHAN_100_124 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2) +#define LOCALE_CHAN_100_140 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2 | \ + LOCALE_SET_5G_MID3 | LOCALE_SET_5G_HIGH1) +#define LOCALE_CHAN_149_165 (LOCALE_SET_5G_HIGH2 | LOCALE_SET_5G_HIGH3) +#define LOCALE_CHAN_184_216 LOCALE_SET_5G_HIGH4 -#define LOCALE_CHAN_01_14 (LOCALE_CHAN_01_11 | LOCALE_CHAN_12_13 | LOCALE_CHAN_14) +#define LOCALE_CHAN_01_14 (LOCALE_CHAN_01_11 | \ + LOCALE_CHAN_12_13 | \ + LOCALE_CHAN_14) #define LOCALE_RADAR_SET_NONE 0 #define LOCALE_RADAR_SET_1 1 @@ -500,7 +504,8 @@ static const struct locale_mimo_info *g_mimo_5g_table[] = { #endif #define LC_5G(id) LOCALE_5G_IDX_ ## id -#define LOCALES(band2, band5, mimo2, mimo5) {LC_2G(band2), LC_5G(band5), LC(mimo2), LC(mimo5)} +#define LOCALES(band2, band5, mimo2, mimo5) \ + {LC_2G(band2), LC_5G(band5), LC(mimo2), LC(mimo5)} static const struct { char abbrev[BRCM_CNTRY_BUF_SZ]; /* country abbreviation */ @@ -644,7 +649,10 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) if (ccode) strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - /* internal country information which must match regulatory constraints in firmware */ + /* + * internal country information which must match + * regulatory constraints in firmware + */ memset(country_abbrev, 0, BRCM_CNTRY_BUF_SZ); strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1); country = brcms_c_country_lookup(wlc, country_abbrev); @@ -672,8 +680,10 @@ brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, return wlc_cm->bandstate[bandunit].locale_flags; } -/* set the driver's current country and regulatory information using a country code - * as the source. Lookup built in country information found with the country code. +/* + * set the driver's current country and regulatory information using + * a country code as the source. Lookup built in country information + * found with the country code. */ static int brcms_c_set_countrycode(struct brcms_cm_info *wlc_cm, const char *ccode) @@ -696,7 +706,10 @@ brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, * otherwise use the ccode and regrev directly */ if (regrev == -1) { - /* map the country code to a built-in country code, regrev, and country_info */ + /* + * map the country code to a built-in country + * code, regrev, and country_info + */ country = brcms_c_countrycode_map(wlc_cm, ccode, mapped_ccode, &mapped_regrev); @@ -717,8 +730,10 @@ brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, return 0; } -/* set the driver's current country and regulatory information using a country code - * as the source. Look up built in country information found with the country code. +/* + * set the driver's current country and regulatory information + * using a country code as the source. Look up built in country + * information found with the country code. */ static void brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, @@ -777,7 +792,10 @@ brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode) char mapped_ccode[BRCM_CNTRY_BUF_SZ]; uint mapped_regrev; - /* map the country code to a built-in country code, regrev, and country_info struct */ + /* + * map the country code to a built-in country code, regrev, and + * country_info struct + */ country = brcms_c_countrycode_map(wlc->cmi, ccode, mapped_ccode, &mapped_regrev); @@ -850,7 +868,10 @@ brcms_c_country_lookup_direct(const char *ccode, uint regrev) /* Should just return 0 for single locale driver. */ /* Keep it this way in case we add more locales. (for now anyway) */ - /* all other country def arrays are for regrev == 0, so if regrev is non-zero, fail */ + /* + * all other country def arrays are for regrev == 0, so if + * regrev is non-zero, fail + */ if (regrev > 0) return NULL; @@ -895,8 +916,9 @@ brcms_c_channels_init(struct brcms_cm_info *wlc_cm, wlc_cm->bandstate[band->bandunit].radar_channels = g_table_radar_set[li->radar_channels]; - /* set the channel availability, - * masking out the channels that may not be supported on this phy + /* + * set the channel availability, masking out the channels + * that may not be supported on this phy. */ wlc_phy_chanspec_band_validch(band->pi, band->bandtype, &sup_chan); @@ -931,9 +953,15 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) if (chan == MAXCHANNEL) chan = INVCHANNEL; - /* based on the channel search above, set or clear WL_RADIO_COUNTRY_DISABLE */ + /* + * based on the channel search above, set or + * clear WL_RADIO_COUNTRY_DISABLE. + */ if (chan == INVCHANNEL) { - /* country/locale with no valid channels, set the radio disable bit */ + /* + * country/locale with no valid channels, set + * the radio disable bit + */ mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" " "nbands %d bandlocked %d\n", wlc->pub->unit, @@ -941,12 +969,16 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) wlc->bandlocked); } else if (mboolisset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE)) { - /* country/locale with valid channel, clear the radio disable bit */ + /* + * country/locale with valid channel, clear + * the radio disable bit + */ mboolclr(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); } - /* Now that the country abbreviation is set, if the radio supports 2G, then - * set channel 14 restrictions based on the new locale. + /* + * Now that the country abbreviation is set, if the radio supports 2G, + * then set channel 14 restrictions based on the new locale. */ if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, @@ -961,7 +993,10 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) } } -/* reset the quiet channels vector to the union of the restricted and radar channel sets */ +/* + * reset the quiet channels vector to the union + * of the restricted and radar channel sets + */ static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) { struct brcms_c_info *wlc = wlc_cm->wlc; @@ -987,15 +1022,11 @@ static bool brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) { return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? - (isset - (wlc_cm->quiet_channels.vec, - LOWER_20_SB(CHSPEC_CHANNEL(chspec))) - || isset(wlc_cm->quiet_channels.vec, - UPPER_20_SB(CHSPEC_CHANNEL(chspec)))) : isset(wlc_cm-> - quiet_channels. - vec, - CHSPEC_CHANNEL - (chspec)); + (isset(wlc_cm->quiet_channels.vec, + LOWER_20_SB(CHSPEC_CHANNEL(chspec))) || + isset(wlc_cm->quiet_channels.vec, + UPPER_20_SB(CHSPEC_CHANNEL(chspec)))) : + isset(wlc_cm->quiet_channels.vec, CHSPEC_CHANNEL(chspec)); } /* Is the channel valid for the current locale? (but don't consider channels not @@ -1112,8 +1143,9 @@ brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, brcms_c_channel_reg_limits(wlc_cm, chanspec, &txpwr); - brcms_c_channel_min_txpower_limits_with_local_constraint(wlc_cm, &txpwr, - local_constraint_qdbm); + brcms_c_channel_min_txpower_limits_with_local_constraint( + wlc_cm, &txpwr, local_constraint_qdbm + ); brcms_b_set_chanspec(wlc->hw, chanspec, (brcms_c_quiet_chanspec(wlc_cm, chanspec) != 0), @@ -1317,10 +1349,12 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, txpwr->ofdm[i] = (u8) maxpwr; for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { - /* OFDM 40 MHz SISO has the same power as the corresponding MCS0-7 rate unless - * overriden by the locale specific code. We set this value to 0 as a - * flag (presumably 0 dBm isn't a possibility) and then copy the MCS0-7 value - * to the 40 MHz value if it wasn't explicitly set. + /* + * OFDM 40 MHz SISO has the same power as the corresponding + * MCS0-7 rate unless overriden by the locale specific code. + * We set this value to 0 as a flag (presumably 0 dBm isn't + * a possibility) and then copy the MCS0-7 value to the 40 MHz + * value if it wasn't explicitly set. */ txpwr->ofdm_40_siso[i] = 0; @@ -1354,8 +1388,9 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, /* Fill in the MCS 0-7 (SISO) rates */ for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - /* 20 MHz has the same power as the corresponding OFDM rate unless - * overriden by the locale specific code. + /* + * 20 MHz has the same power as the corresponding OFDM rate + * unless overriden by the locale specific code. */ txpwr->mcs_20_siso[i] = txpwr->ofdm[i]; txpwr->mcs_40_siso[i] = 0; @@ -1367,7 +1402,10 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, txpwr->mcs_40_cdd[i] = (u8) maxpwr40; } - /* These locales have SISO expressed in the table and override CDD later */ + /* + * These locales have SISO expressed in the + * table and override CDD later + */ if (li_mimo == &locale_bn) { if (li_mimo == &locale_bn) { maxpwr20 = QDB(16); @@ -1408,10 +1446,10 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } } - /* Copy the 40 MHZ MCS 0-7 CDD value to the 40 MHZ MCS 0-7 SISO value if it wasn't - * provided explicitly. + /* + * Copy the 40 MHZ MCS 0-7 CDD value to the 40 MHZ MCS 0-7 SISO + * value if it wasn't provided explicitly. */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { if (txpwr->mcs_40_siso[i] == 0) txpwr->mcs_40_siso[i] = txpwr->mcs_40_cdd[i]; @@ -1427,8 +1465,9 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } } - /* Copy the 20 and 40 MHz MCS0-7 CDD values to the corresponding STBC values if they weren't - * provided explicitly. + /* + * Copy the 20 and 40 MHz MCS0-7 CDD values to the corresponding + * STBC values if they weren't provided explicitly. */ for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { if (txpwr->mcs_20_stbc[i] == 0) @@ -1458,8 +1497,9 @@ static bool brcms_c_japan_ccode(const char *ccode) } /* - * Validate the chanspec for this locale, for 40MHZ we need to also check that the sidebands - * are valid 20MZH channels in this locale and they are also a legal HT combination + * Validate the chanspec for this locale, for 40MHZ we need to also + * check that the sidebands are valid 20MZH channels in this locale + * and they are also a legal HT combination */ static bool brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, @@ -1487,8 +1527,9 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, return VALID_CHANNEL20(wlc_cm->wlc, channel); } #ifdef SUPPORT_40MHZ - /* We know we are now checking a 40MHZ channel, so we should only be here - * for NPHYS + /* + * We know we are now checking a 40MHZ channel, so we should + * only be here for NPHYS */ if (BRCMS_ISNPHY(wlc->band) || BRCMS_ISSSLPNPHY(wlc->band)) { u8 upper_sideband = 0, idx; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.h b/drivers/staging/brcm80211/brcmsmac/channel.h index c9452bef647..3e85844ec87 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.h +++ b/drivers/staging/brcm80211/brcmsmac/channel.h @@ -40,12 +40,14 @@ */ /* macro to get 2.4 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) /* cck index */ -#define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) /* ofdm index */ +#define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) +#define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) /* macro to get 5 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_5G(c) \ - (((c) < 52) ? 0 : (((c) < 62) ? 1 : (((c) < 100) ? 2 : (((c) < 149) ? 3 : 4)))) +#define CHANNEL_POWER_IDX_5G(c) (((c) < 52) ? 0 : \ + (((c) < 62) ? 1 : \ + (((c) < 100) ? 2 : \ + (((c) < 149) ? 3 : 4)))) /* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */ #define BRCMS_MAXPWR_TBL_SIZE 6 @@ -67,9 +69,8 @@ struct locale_info { u8 restricted_channels; /* Max tx pwr in qdBm for each sub-band */ s8 maxpwr[BRCMS_MAXPWR_TBL_SIZE]; - s8 pub_maxpwr[BAND_5G_PWR_LVLS]; /* Country IE advertised max tx pwr in dBm - * per sub-band - */ + /* Country IE advertised max tx pwr in dBm per sub-band */ + s8 pub_maxpwr[BAND_5G_PWR_LVLS]; u8 flags; }; diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index 4dc73407fb3..96f487aed9b 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -29,11 +29,11 @@ #define RX_FIFO 0 /* data and ctl frames */ #define RX_TXSTATUS_FIFO 3 /* RX fifo for tx status packages */ -/* TX FIFO numbers using WME Access Classes */ -#define TX_AC_BK_FIFO 0 /* Access Category Background TX FIFO */ -#define TX_AC_BE_FIFO 1 /* Access Category Best-Effort TX FIFO */ -#define TX_AC_VI_FIFO 2 /* Access Class Video TX FIFO */ -#define TX_AC_VO_FIFO 3 /* Access Class Voice TX FIFO */ +/* TX FIFO numbers using WME Access Category */ +#define TX_AC_BK_FIFO 0 /* Background TX FIFO */ +#define TX_AC_BE_FIFO 1 /* Best-Effort TX FIFO */ +#define TX_AC_VI_FIFO 2 /* Video TX FIFO */ +#define TX_AC_VO_FIFO 3 /* Voice TX FIFO */ #define TX_BCMC_FIFO 4 /* Broadcast/Multicast TX FIFO */ #define TX_ATIM_FIFO 5 /* TX fifo for ATIM window info */ @@ -457,7 +457,7 @@ struct d11regs { #define IRL_FC_MASK 0xff000000 /* frame count */ #define IRL_FC_SHIFT 24 /* frame count */ -/* maccontrol register */ +/*== maccontrol register ==*/ #define MCTL_GMODE (1U << 31) #define MCTL_DISCARD_PMQ (1 << 30) #define MCTL_WAKE (1 << 26) @@ -481,75 +481,119 @@ struct d11regs { #define MCTL_PSM_RUN (1 << 1) #define MCTL_EN_MAC (1 << 0) -/* maccommand register */ +/*== maccommand register ==*/ #define MCMD_BCN0VLD (1 << 0) #define MCMD_BCN1VLD (1 << 1) #define MCMD_DIRFRMQVAL (1 << 2) #define MCMD_CCA (1 << 3) #define MCMD_BG_NOISE (1 << 4) #define MCMD_SKIP_SHMINIT (1 << 5) /* only used for simulation */ -#define MCMD_SAMPLECOLL MCMD_SKIP_SHMINIT /* reuse for sample collect */ +#define MCMD_SAMPLECOLL MCMD_SKIP_SHMINIT /* reuse for sample collect */ -/* macintstatus/macintmask */ -#define MI_MACSSPNDD (1 << 0) /* MAC has gracefully suspended */ -#define MI_BCNTPL (1 << 1) /* beacon template available */ -#define MI_TBTT (1 << 2) /* TBTT indication */ -#define MI_BCNSUCCESS (1 << 3) /* beacon successfully tx'd */ -#define MI_BCNCANCLD (1 << 4) /* beacon canceled (IBSS) */ -#define MI_ATIMWINEND (1 << 5) /* end of ATIM-window (IBSS) */ -#define MI_PMQ (1 << 6) /* PMQ entries available */ -#define MI_NSPECGEN_0 (1 << 7) /* non-specific gen-stat bits that are set by PSM */ -#define MI_NSPECGEN_1 (1 << 8) /* non-specific gen-stat bits that are set by PSM */ -#define MI_MACTXERR (1 << 9) /* MAC level Tx error */ -#define MI_NSPECGEN_3 (1 << 10) /* non-specific gen-stat bits that are set by PSM */ -#define MI_PHYTXERR (1 << 11) /* PHY Tx error */ -#define MI_PME (1 << 12) /* Power Management Event */ -#define MI_GP0 (1 << 13) /* General-purpose timer0 */ -#define MI_GP1 (1 << 14) /* General-purpose timer1 */ -#define MI_DMAINT (1 << 15) /* (ORed) DMA-interrupts */ -#define MI_TXSTOP (1 << 16) /* MAC has completed a TX FIFO Suspend/Flush */ -#define MI_CCA (1 << 17) /* MAC has completed a CCA measurement */ -#define MI_BG_NOISE (1 << 18) /* MAC has collected background noise samples */ -#define MI_DTIM_TBTT (1 << 19) /* MBSS DTIM TBTT indication */ -#define MI_PRQ (1 << 20) /* Probe response queue needs attention */ -#define MI_PWRUP (1 << 21) /* Radio/PHY has been powered back up. */ +/*== macintstatus/macintmask ==*/ +/* gracefully suspended */ +#define MI_MACSSPNDD (1 << 0) +/* beacon template available */ +#define MI_BCNTPL (1 << 1) +/* TBTT indication */ +#define MI_TBTT (1 << 2) +/* beacon successfully tx'd */ +#define MI_BCNSUCCESS (1 << 3) +/* beacon canceled (IBSS) */ +#define MI_BCNCANCLD (1 << 4) +/* end of ATIM-window (IBSS) */ +#define MI_ATIMWINEND (1 << 5) +/* PMQ entries available */ +#define MI_PMQ (1 << 6) +/* non-specific gen-stat bits that are set by PSM */ +#define MI_NSPECGEN_0 (1 << 7) +/* non-specific gen-stat bits that are set by PSM */ +#define MI_NSPECGEN_1 (1 << 8) +/* MAC level Tx error */ +#define MI_MACTXERR (1 << 9) +/* non-specific gen-stat bits that are set by PSM */ +#define MI_NSPECGEN_3 (1 << 10) +/* PHY Tx error */ +#define MI_PHYTXERR (1 << 11) +/* Power Management Event */ +#define MI_PME (1 << 12) +/* General-purpose timer0 */ +#define MI_GP0 (1 << 13) +/* General-purpose timer1 */ +#define MI_GP1 (1 << 14) +/* (ORed) DMA-interrupts */ +#define MI_DMAINT (1 << 15) +/* MAC has completed a TX FIFO Suspend/Flush */ +#define MI_TXSTOP (1 << 16) +/* MAC has completed a CCA measurement */ +#define MI_CCA (1 << 17) +/* MAC has collected background noise samples */ +#define MI_BG_NOISE (1 << 18) +/* MBSS DTIM TBTT indication */ +#define MI_DTIM_TBTT (1 << 19) +/* Probe response queue needs attention */ +#define MI_PRQ (1 << 20) +/* Radio/PHY has been powered back up. */ +#define MI_PWRUP (1 << 21) #define MI_RESERVED3 (1 << 22) #define MI_RESERVED2 (1 << 23) #define MI_RESERVED1 (1 << 25) /* MAC detected change on RF Disable input*/ #define MI_RFDISABLE (1 << 28) -#define MI_TFS (1 << 29) /* MAC has completed a TX */ -#define MI_PHYCHANGED (1 << 30) /* A phy status change wrt G mode */ -#define MI_TO (1U << 31) /* general purpose timeout */ +/* MAC has completed a TX */ +#define MI_TFS (1 << 29) +/* A phy status change wrt G mode */ +#define MI_PHYCHANGED (1 << 30) +/* general purpose timeout */ +#define MI_TO (1U << 31) /* Mac capabilities registers */ -/* machwcap */ +/*== machwcap ==*/ #define MCAP_TKIPMIC 0x80000000 /* TKIP MIC hardware present */ -/* pmqhost data */ -#define PMQH_DATA_MASK 0xffff0000 /* data entry of head pmq entry */ -#define PMQH_BSSCFG 0x00100000 /* PM entry for BSS config */ -#define PMQH_PMOFF 0x00010000 /* PM Mode OFF: power save off */ -#define PMQH_PMON 0x00020000 /* PM Mode ON: power save on */ -#define PMQH_DASAT 0x00040000 /* Dis-associated or De-authenticated */ -#define PMQH_ATIMFAIL 0x00080000 /* ATIM not acknowledged */ -#define PMQH_DEL_ENTRY 0x00000001 /* delete head entry */ -#define PMQH_DEL_MULT 0x00000002 /* delete head entry to cur read pointer -1 */ -#define PMQH_OFLO 0x00000004 /* pmq overflow indication */ -#define PMQH_NOT_EMPTY 0x00000008 /* entries are present in pmq */ +/*== pmqhost data ==*/ +/* data entry of head pmq entry */ +#define PMQH_DATA_MASK 0xffff0000 +/* PM entry for BSS config */ +#define PMQH_BSSCFG 0x00100000 +/* PM Mode OFF: power save off */ +#define PMQH_PMOFF 0x00010000 +/* PM Mode ON: power save on */ +#define PMQH_PMON 0x00020000 +/* Dis-associated or De-authenticated */ +#define PMQH_DASAT 0x00040000 +/* ATIM not acknowledged */ +#define PMQH_ATIMFAIL 0x00080000 +/* delete head entry */ +#define PMQH_DEL_ENTRY 0x00000001 +/* delete head entry to cur read pointer -1 */ +#define PMQH_DEL_MULT 0x00000002 +/* pmq overflow indication */ +#define PMQH_OFLO 0x00000004 +/* entries are present in pmq */ +#define PMQH_NOT_EMPTY 0x00000008 -/* phydebug */ -#define PDBG_CRS (1 << 0) /* phy is asserting carrier sense */ -#define PDBG_TXA (1 << 1) /* phy is taking xmit byte from mac this cycle */ -#define PDBG_TXF (1 << 2) /* mac is instructing the phy to transmit a frame */ -#define PDBG_TXE (1 << 3) /* phy is signalling a transmit Error to the mac */ -#define PDBG_RXF (1 << 4) /* phy detected the end of a valid frame preamble */ -#define PDBG_RXS (1 << 5) /* phy detected the end of a valid PLCP header */ -#define PDBG_RXFRG (1 << 6) /* rx start not asserted */ -#define PDBG_RXV (1 << 7) /* mac is taking receive byte from phy this cycle */ -#define PDBG_RFD (1 << 16) /* RF portion of the radio is disabled */ +/*== phydebug ==*/ +/* phy is asserting carrier sense */ +#define PDBG_CRS (1 << 0) +/* phy is taking xmit byte from mac this cycle */ +#define PDBG_TXA (1 << 1) +/* mac is instructing the phy to transmit a frame */ +#define PDBG_TXF (1 << 2) +/* phy is signalling a transmit Error to the mac */ +#define PDBG_TXE (1 << 3) +/* phy detected the end of a valid frame preamble */ +#define PDBG_RXF (1 << 4) +/* phy detected the end of a valid PLCP header */ +#define PDBG_RXS (1 << 5) +/* rx start not asserted */ +#define PDBG_RXFRG (1 << 6) +/* mac is taking receive byte from phy this cycle */ +#define PDBG_RXV (1 << 7) +/* RF portion of the radio is disabled */ +#define PDBG_RFD (1 << 16) -/* objaddr register */ +/*== objaddr register ==*/ #define OBJADDR_SEL_MASK 0x000F0000 #define OBJADDR_UCM_SEL 0x00000000 #define OBJADDR_SHM_SEL 0x00010000 @@ -564,20 +608,20 @@ struct d11regs { #define WEP_PCMADDR 0x07d4 #define WEP_PCMDATA 0x07d6 -/* frmtxstatus */ +/*== frmtxstatus ==*/ #define TXS_V (1 << 0) /* valid bit */ #define TXS_STATUS_MASK 0xffff #define TXS_FID_MASK 0xffff0000 #define TXS_FID_SHIFT 16 -/* frmtxstatus2 */ +/*== frmtxstatus2 ==*/ #define TXS_SEQ_MASK 0xffff #define TXS_PTX_MASK 0xff0000 #define TXS_PTX_SHIFT 16 #define TXS_MU_MASK 0x01000000 #define TXS_MU_SHIFT 24 -/* clk_ctl_st */ +/*== clk_ctl_st ==*/ #define CCS_ERSRC_REQ_D11PLL 0x00000100 /* d11 core pll request */ #define CCS_ERSRC_REQ_PHYPLL 0x00000200 /* PHY pll request */ #define CCS_ERSRC_AVAIL_D11PLL 0x01000000 /* d11 core pll available */ @@ -602,22 +646,27 @@ struct d11regs { #define TXFIFO_SIZE_UNIT 256 /* one unit corresponds to 256 bytes */ #define MBSS16_TEMPLMEM_MINBLKS 65 /* one unit corresponds to 256 bytes */ -/* phy versions, PhyVersion:Revision field */ -#define PV_AV_MASK 0xf000 /* analog block version */ -#define PV_AV_SHIFT 12 /* analog block version bitfield offset */ -#define PV_PT_MASK 0x0f00 /* phy type */ -#define PV_PT_SHIFT 8 /* phy type bitfield offset */ -#define PV_PV_MASK 0x000f /* phy version */ +/*== phy versions (PhyVersion:Revision field) ==*/ +/* analog block version */ +#define PV_AV_MASK 0xf000 +/* analog block version bitfield offset */ +#define PV_AV_SHIFT 12 +/* phy type */ +#define PV_PT_MASK 0x0f00 +/* phy type bitfield offset */ +#define PV_PT_SHIFT 8 +/* phy version */ +#define PV_PV_MASK 0x000f #define PHY_TYPE(v) ((v & PV_PT_MASK) >> PV_PT_SHIFT) -/* phy types, PhyVersion:PhyType field */ +/*== phy types (PhyVersion:PhyType field) ==*/ #define PHY_TYPE_N 4 /* N-Phy value */ #define PHY_TYPE_SSN 6 /* SSLPN-Phy value */ #define PHY_TYPE_LCN 8 /* LCN-Phy value */ #define PHY_TYPE_LCNXN 9 /* LCNXN-Phy value */ #define PHY_TYPE_NULL 0xf /* Invalid Phy value */ -/* analog types, PhyVersion:AnalogType field */ +/*== analog types (PhyVersion:AnalogType field) ==*/ #define ANA_11N_013 5 /* 802.11a PLCP header def */ @@ -693,9 +742,10 @@ struct cck_phy_hdr { #define BRCMS_CLR_MIMO_PLCP_AMPDU(plcp) (plcp[3] &= ~MIMO_PLCP_AMPDU) #define BRCMS_IS_MIMO_PLCP_AMPDU(plcp) (plcp[3] & MIMO_PLCP_AMPDU) -/* The dot11a PLCP header is 5 bytes. To simplify the software (so that we - * don't need e.g. different tx DMA headers for 11a and 11b), the PLCP header has - * padding added in the ucode. +/* + * The dot11a PLCP header is 5 bytes. To simplify the software (so that we + * don't need e.g. different tx DMA headers for 11a and 11b), the PLCP header + * has padding added in the ucode. */ #define D11_PHY_HDR_LEN 6 @@ -745,14 +795,17 @@ struct d11txh { #define FT_HT 2 #define FT_N 3 -/* Position of MPDU inside A-MPDU; indicated with bits 10:9 of MacTxControlLow */ +/* + * Position of MPDU inside A-MPDU; indicated with bits 10:9 + * of MacTxControlLow + */ #define TXC_AMPDU_SHIFT 9 /* shift for ampdu settings */ #define TXC_AMPDU_NONE 0 /* Regular MPDU, not an A-MPDU */ #define TXC_AMPDU_FIRST 1 /* first MPDU of an A-MPDU */ #define TXC_AMPDU_MIDDLE 2 /* intermediate MPDU of an A-MPDU */ #define TXC_AMPDU_LAST 3 /* last (or single) MPDU of an A-MPDU */ -/* MacTxControlLow */ +/*== MacTxControlLow ==*/ #define TXC_AMIC 0x8000 #define TXC_SENDCTS 0x0800 #define TXC_AMPDU_MASK 0x0600 @@ -766,18 +819,25 @@ struct d11txh { #define TXC_LONGFRAME 0x0002 #define TXC_IMMEDACK 0x0001 -/* MacTxControlHigh */ -#define TXC_PREAMBLE_RTS_FB_SHORT 0x8000 /* RTS fallback preamble type 1 = SHORT 0 = LONG */ -#define TXC_PREAMBLE_RTS_MAIN_SHORT 0x4000 /* RTS main rate preamble type 1 = SHORT 0 = LONG */ -#define TXC_PREAMBLE_DATA_FB_SHORT 0x2000 /* Main fallback rate preamble type - * 1 = SHORT for OFDM/GF for MIMO - * 0 = LONG for CCK/MM for MIMO - */ +/*== MacTxControlHigh ==*/ +/* RTS fallback preamble type 1 = SHORT 0 = LONG */ +#define TXC_PREAMBLE_RTS_FB_SHORT 0x8000 +/* RTS main rate preamble type 1 = SHORT 0 = LONG */ +#define TXC_PREAMBLE_RTS_MAIN_SHORT 0x4000 +/* + * Main fallback rate preamble type + * 1 = SHORT for OFDM/GF for MIMO + * 0 = LONG for CCK/MM for MIMO + */ +#define TXC_PREAMBLE_DATA_FB_SHORT 0x2000 + /* TXC_PREAMBLE_DATA_MAIN is in PhyTxControl bit 5 */ -#define TXC_AMPDU_FBR 0x1000 /* use fallback rate for this AMPDU */ +/* use fallback rate for this AMPDU */ +#define TXC_AMPDU_FBR 0x1000 #define TXC_SECKEY_MASK 0x0FF0 #define TXC_SECKEY_SHIFT 4 -#define TXC_ALT_TXPWR 0x0008 /* Use alternate txpwr defined at loc. M_ALT_TXPWR_IDX */ +/* Use alternate txpwr defined at loc. M_ALT_TXPWR_IDX */ +#define TXC_ALT_TXPWR 0x0008 #define TXC_SECTYPE_MASK 0x0007 #define TXC_SECTYPE_SHIFT 0 @@ -817,7 +877,7 @@ struct d11txh { #define PHY_TXC1_MODE_SDM 3 /* PhyTxControl for HTphy that are different from Mimophy */ -#define PHY_TXC_HTANT_MASK 0x3fC0 /* bit 6, 7, 8, 9, 10, 11, 12, 13 */ +#define PHY_TXC_HTANT_MASK 0x3fC0 /* bits 6-13 */ /* XtraFrameTypes */ #define XFTS_RTS_FT_SHIFT 2 @@ -862,23 +922,23 @@ struct tx_status { #define TX_STATUS_RTS_RTX_MASK 0x0F00 #define TX_STATUS_RTS_RTX_SHIFT 8 #define TX_STATUS_MASK 0x00FE -#define TX_STATUS_PMINDCTD (1 << 7) /* PM mode indicated to AP */ -#define TX_STATUS_INTERMEDIATE (1 << 6) /* intermediate or 1st ampdu pkg */ -#define TX_STATUS_AMPDU (1 << 5) /* AMPDU status */ -#define TX_STATUS_SUPR_MASK 0x1C /* suppress status bits (4:2) */ +#define TX_STATUS_PMINDCTD (1 << 7) /* PM mode indicated to AP */ +#define TX_STATUS_INTERMEDIATE (1 << 6) /* intermediate or 1st ampdu pkg */ +#define TX_STATUS_AMPDU (1 << 5) /* AMPDU status */ +#define TX_STATUS_SUPR_MASK 0x1C /* suppress status bits (4:2) */ #define TX_STATUS_SUPR_SHIFT 2 -#define TX_STATUS_ACK_RCV (1 << 1) /* ACK received */ -#define TX_STATUS_VALID (1 << 0) /* Tx status valid */ +#define TX_STATUS_ACK_RCV (1 << 1) /* ACK received */ +#define TX_STATUS_VALID (1 << 0) /* Tx status valid */ #define TX_STATUS_NO_ACK 0 /* suppress status reason codes */ -#define TX_STATUS_SUPR_PMQ (1 << 2) /* PMQ entry */ -#define TX_STATUS_SUPR_FLUSH (2 << 2) /* flush request */ -#define TX_STATUS_SUPR_FRAG (3 << 2) /* previous frag failure */ -#define TX_STATUS_SUPR_TBTT (3 << 2) /* SHARED: Probe response supr for TBTT */ -#define TX_STATUS_SUPR_BADCH (4 << 2) /* channel mismatch */ -#define TX_STATUS_SUPR_EXPTIME (5 << 2) /* lifetime expiry */ -#define TX_STATUS_SUPR_UF (6 << 2) /* underflow */ +#define TX_STATUS_SUPR_PMQ (1 << 2) /* PMQ entry */ +#define TX_STATUS_SUPR_FLUSH (2 << 2) /* flush request */ +#define TX_STATUS_SUPR_FRAG (3 << 2) /* previous frag failure */ +#define TX_STATUS_SUPR_TBTT (3 << 2) /* SHARED: Probe resp supr for TBTT */ +#define TX_STATUS_SUPR_BADCH (4 << 2) /* channel mismatch */ +#define TX_STATUS_SUPR_EXPTIME (5 << 2) /* lifetime expiry */ +#define TX_STATUS_SUPR_UF (6 << 2) /* underflow */ /* Unexpected tx status for rate update */ #define TX_STATUS_UNEXP(status) \ @@ -939,8 +999,8 @@ struct tx_status { #define ADDR_BMP_RA (1 << 0) /* Receiver Address (RA) */ #define ADDR_BMP_TA (1 << 1) /* Transmitter Address (TA) */ #define ADDR_BMP_BSSID (1 << 2) /* BSSID */ -#define ADDR_BMP_AP (1 << 3) /* Infra-BSS Access Point (AP) */ -#define ADDR_BMP_STA (1 << 4) /* Infra-BSS Station (STA) */ +#define ADDR_BMP_AP (1 << 3) /* Infra-BSS Access Point */ +#define ADDR_BMP_STA (1 << 4) /* Infra-BSS Station */ #define ADDR_BMP_RESERVED1 (1 << 5) #define ADDR_BMP_RESERVED2 (1 << 6) #define ADDR_BMP_RESERVED3 (1 << 7) @@ -1012,9 +1072,10 @@ struct tx_status { #define T_BCN0_TPL_BASE (0x34 * 2) #define T_PRS_TPL_BASE (0x134 * 2) #define T_BCN1_TPL_BASE (0x234 * 2) -#define T_TX_FIFO_TXRAM_BASE (T_ACTS_TPL_BASE + (TXFIFO_START_BLK * TXFIFO_SIZE_UNIT)) +#define T_TX_FIFO_TXRAM_BASE (T_ACTS_TPL_BASE + \ + (TXFIFO_START_BLK * TXFIFO_SIZE_UNIT)) -#define T_BA_TPL_BASE T_QNULL_TPL_BASE /* template area for BA */ +#define T_BA_TPL_BASE T_QNULL_TPL_BASE /* template area for BA */ #define T_RAM_ACCESS_SZ 4 /* template ram is 4 byte access only */ @@ -1207,14 +1268,18 @@ struct tx_status { #define WATCHDOG_8TU_MAX 10 /* Manufacturing Test Variables */ -#define M_PKTENG_CTRL (0x6c * 2) /* PER test mode */ -#define M_PKTENG_IFS (0x6d * 2) /* IFS for TX mode */ -#define M_PKTENG_FRMCNT_LO (0x6e * 2) /* Lower word of tx frmcnt/rx lostcnt */ -#define M_PKTENG_FRMCNT_HI (0x6f * 2) /* Upper word of tx frmcnt/rx lostcnt */ +/* PER test mode */ +#define M_PKTENG_CTRL (0x6c * 2) +/* IFS for TX mode */ +#define M_PKTENG_IFS (0x6d * 2) +/* Lower word of tx frmcnt/rx lostcnt */ +#define M_PKTENG_FRMCNT_LO (0x6e * 2) +/* Upper word of tx frmcnt/rx lostcnt */ +#define M_PKTENG_FRMCNT_HI (0x6f * 2) /* Index variation in vbat ripple */ -#define M_LCN_PWR_IDX_MAX (0x67 * 2) /* highest index read by ucode */ -#define M_LCN_PWR_IDX_MIN (0x66 * 2) /* lowest index read by ucode */ +#define M_LCN_PWR_IDX_MAX (0x67 * 2) /* highest index read by ucode */ +#define M_LCN_PWR_IDX_MIN (0x66 * 2) /* lowest index read by ucode */ /* M_PKTENG_CTRL bit definitions */ #define M_PKTENG_MODE_TX 0x0001 @@ -1223,11 +1288,14 @@ struct tx_status { #define M_PKTENG_MODE_RX 0x0002 #define M_PKTENG_MODE_RX_WITH_ACK 0x0402 #define M_PKTENG_MODE_MASK 0x0003 -#define M_PKTENG_FRMCNT_VLD 0x0100 /* TX frames indicated in the frmcnt reg */ +/* TX frames indicated in the frmcnt reg */ +#define M_PKTENG_FRMCNT_VLD 0x0100 /* Sample Collect parameters (bitmap and type) */ -#define M_SMPL_COL_BMP (0x37d * 2) /* Trigger bitmap for sample collect */ -#define M_SMPL_COL_CTL (0x3b2 * 2) /* Sample collect type */ +/* Trigger bitmap for sample collect */ +#define M_SMPL_COL_BMP (0x37d * 2) +/* Sample collect type */ +#define M_SMPL_COL_CTL (0x3b2 * 2) #define ANTSEL_CLKDIV_4MHZ 6 #define MIMO_ANTSEL_BUSY 0x4000 /* bit 14 (busy) */ @@ -1259,27 +1327,37 @@ struct shm_acparams { #define MHF5 4 /* Hostflag 5 index */ /* Flags in M_HOST_FLAGS */ -#define MHF1_ANTDIV 0x0001 /* Enable ucode antenna diversity help */ -#define MHF1_EDCF 0x0100 /* Enable EDCF access control */ +/* Enable ucode antenna diversity help */ +#define MHF1_ANTDIV 0x0001 +/* Enable EDCF access control */ +#define MHF1_EDCF 0x0100 #define MHF1_IQSWAP_WAR 0x0200 -#define MHF1_FORCEFASTCLK 0x0400 /* Disable Slow clock request, for corerev < 11 */ +/* Disable Slow clock request, for corerev < 11 */ +#define MHF1_FORCEFASTCLK 0x0400 /* Flags in M_HOST_FLAGS2 */ -#define MHF2_PCISLOWCLKWAR 0x0008 /* PR16165WAR : Enable ucode PCI slow clock WAR */ -#define MHF2_TXBCMC_NOW 0x0040 /* Flush BCMC FIFO immediately */ -#define MHF2_HWPWRCTL 0x0080 /* Enable ucode/hw power control */ +/* PR16165WAR : Enable ucode PCI slow clock WAR */ +#define MHF2_PCISLOWCLKWAR 0x0008 +/* Flush BCMC FIFO immediately */ +#define MHF2_TXBCMC_NOW 0x0040 +/* Enable ucode/hw power control */ +#define MHF2_HWPWRCTL 0x0080 #define MHF2_NPHY40MHZ_WAR 0x0800 /* Flags in M_HOST_FLAGS3 */ -#define MHF3_ANTSEL_EN 0x0001 /* enabled mimo antenna selection */ -#define MHF3_ANTSEL_MODE 0x0002 /* antenna selection mode: 0: 2x3, 1: 2x4 */ +/* enabled mimo antenna selection */ +#define MHF3_ANTSEL_EN 0x0001 +/* antenna selection mode: 0: 2x3, 1: 2x4 */ +#define MHF3_ANTSEL_MODE 0x0002 #define MHF3_RESERVED1 0x0004 #define MHF3_RESERVED2 0x0008 #define MHF3_NPHY_MLADV_WAR 0x0010 /* Flags in M_HOST_FLAGS4 */ -#define MHF4_BPHY_TXCORE0 0x0080 /* force bphy Tx on core 0 (board level WAR) */ -#define MHF4_EXTPA_ENABLE 0x4000 /* for 4313A0 FEM boards */ +/* force bphy Tx on core 0 (board level WAR) */ +#define MHF4_BPHY_TXCORE0 0x0080 +/* for 4313A0 FEM boards */ +#define MHF4_EXTPA_ENABLE 0x4000 /* Flags in M_HOST_FLAGS5 */ #define MHF5_4313_GPIOCTRL 0x0001 @@ -1292,52 +1370,87 @@ struct shm_acparams { #define M_PHY_NOISE (0x037 * 2) #define PHY_NOISE_MASK 0x00ff -/* Receive Frame Data Header for 802.11b DCF-only frames */ +/* + * Receive Frame Data Header for 802.11b DCF-only frames + * + * RxFrameSize: Actual byte length of the frame data received + * PAD: padding (not used) + * PhyRxStatus_0: PhyRxStatus 15:0 + * PhyRxStatus_1: PhyRxStatus 31:16 + * PhyRxStatus_2: PhyRxStatus 47:32 + * PhyRxStatus_3: PhyRxStatus 63:48 + * PhyRxStatus_4: PhyRxStatus 79:64 + * PhyRxStatus_5: PhyRxStatus 95:80 + * RxStatus1: MAC Rx Status + * RxStatus2: extended MAC Rx status + * RxTSFTime: RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY + * RxChan: gain code, channel radio code, and phy type + */ struct d11rxhdr { - u16 RxFrameSize; /* Actual byte length of the frame data received */ + u16 RxFrameSize; u16 PAD; - u16 PhyRxStatus_0; /* PhyRxStatus 15:0 */ - u16 PhyRxStatus_1; /* PhyRxStatus 31:16 */ - u16 PhyRxStatus_2; /* PhyRxStatus 47:32 */ - u16 PhyRxStatus_3; /* PhyRxStatus 63:48 */ - u16 PhyRxStatus_4; /* PhyRxStatus 79:64 */ - u16 PhyRxStatus_5; /* PhyRxStatus 95:80 */ - u16 RxStatus1; /* MAC Rx Status */ - u16 RxStatus2; /* extended MAC Rx status */ - u16 RxTSFTime; /* RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY */ - u16 RxChan; /* gain code, channel radio code, and phy type */ + u16 PhyRxStatus_0; + u16 PhyRxStatus_1; + u16 PhyRxStatus_2; + u16 PhyRxStatus_3; + u16 PhyRxStatus_4; + u16 PhyRxStatus_5; + u16 RxStatus1; + u16 RxStatus2; + u16 RxTSFTime; + u16 RxChan; } __packed; #define RXHDR_LEN 24 /* sizeof struct d11rxhdr */ #define FRAMELEN(h) ((h)->RxFrameSize) +/* + * rxhdr: received frame header data + * tsf_l: TSF_L reading + * rssi: computed instanteneous rssi in BMAC + * rxpwr0: obsoleted, place holder for legacy ROM code. use rxpwr[] + * rxpwr1: obsoleted, place holder for legacy ROM code. use rxpwr[] + * do_rssi_ma: do per-pkt sampling for per-antenna ma in HIGH + * rxpwr: rssi for supported antennas + */ struct brcms_d11rxhdr { struct d11rxhdr rxhdr; - u32 tsf_l; /* TSF_L reading */ - s8 rssi; /* computed instanteneous rssi in BMAC */ - s8 rxpwr0; /* obsoleted, place holder for legacy ROM code. use rxpwr[] */ - s8 rxpwr1; /* obsoleted, place holder for legacy ROM code. use rxpwr[] */ - s8 do_rssi_ma; /* do per-pkt sampling for per-antenna ma in HIGH */ - s8 rxpwr[WL_RSSI_ANT_MAX]; /* rssi for supported antennas */ + u32 tsf_l; + s8 rssi; + s8 rxpwr0; + s8 rxpwr1; + s8 do_rssi_ma; + s8 rxpwr[WL_RSSI_ANT_MAX]; } __packed; /* PhyRxStatus_0: */ -#define PRXS0_FT_MASK 0x0003 /* NPHY only: CCK, OFDM, preN, N */ -#define PRXS0_CLIP_MASK 0x000C /* NPHY only: clip count adjustment steps by AGC */ +/* NPHY only: CCK, OFDM, preN, N */ +#define PRXS0_FT_MASK 0x0003 +/* NPHY only: clip count adjustment steps by AGC */ +#define PRXS0_CLIP_MASK 0x000C #define PRXS0_CLIP_SHIFT 2 -#define PRXS0_UNSRATE 0x0010 /* PHY received a frame with unsupported rate */ -#define PRXS0_RXANT_UPSUBBAND 0x0020 /* GPHY: rx ant, NPHY: upper sideband */ -#define PRXS0_LCRS 0x0040 /* CCK frame only: lost crs during cck frame reception */ -#define PRXS0_SHORTH 0x0080 /* Short Preamble */ -#define PRXS0_PLCPFV 0x0100 /* PLCP violation */ -#define PRXS0_PLCPHCF 0x0200 /* PLCP header integrity check failed */ -#define PRXS0_GAIN_CTL 0x4000 /* legacy PHY gain control */ -#define PRXS0_ANTSEL_MASK 0xF000 /* NPHY: Antennas used for received frame, bitmask */ +/* PHY received a frame with unsupported rate */ +#define PRXS0_UNSRATE 0x0010 +/* GPHY: rx ant, NPHY: upper sideband */ +#define PRXS0_RXANT_UPSUBBAND 0x0020 +/* CCK frame only: lost crs during cck frame reception */ +#define PRXS0_LCRS 0x0040 +/* Short Preamble */ +#define PRXS0_SHORTH 0x0080 +/* PLCP violation */ +#define PRXS0_PLCPFV 0x0100 +/* PLCP header integrity check failed */ +#define PRXS0_PLCPHCF 0x0200 +/* legacy PHY gain control */ +#define PRXS0_GAIN_CTL 0x4000 +/* NPHY: Antennas used for received frame, bitmask */ +#define PRXS0_ANTSEL_MASK 0xF000 #define PRXS0_ANTSEL_SHIFT 0x12 /* subfield PRXS0_FT_MASK */ #define PRXS0_CCK 0x0000 -#define PRXS0_OFDM 0x0001 /* valid only for G phy, use rxh->RxChan for A phy */ +/* valid only for G phy, use rxh->RxChan for A phy */ +#define PRXS0_OFDM 0x0001 #define PRXS0_PREN 0x0002 #define PRXS0_STDN 0x0003 @@ -1364,35 +1477,51 @@ struct brcms_d11rxhdr { #define PRXS0_UNUSED 0xF000 /* unused and not defined; set to 0 */ /* htphy PhyRxStatus_1: */ -#define PRXS1_HTPHY_CORE_MASK 0x000F /* core enables for {3..0}, 0=disabled, 1=enabled */ -#define PRXS1_HTPHY_ANTCFG_MASK 0x00F0 /* antenna configation */ -#define PRXS1_HTPHY_MMPLCPLenL_MASK 0xFF00 /* Mixmode PLCP Length low byte mask */ +/* core enables for {3..0}, 0=disabled, 1=enabled */ +#define PRXS1_HTPHY_CORE_MASK 0x000F +/* antenna configation */ +#define PRXS1_HTPHY_ANTCFG_MASK 0x00F0 +/* Mixmode PLCP Length low byte mask */ +#define PRXS1_HTPHY_MMPLCPLenL_MASK 0xFF00 /* htphy PhyRxStatus_2: */ -#define PRXS2_HTPHY_MMPLCPLenH_MASK 0x000F /* Mixmode PLCP Length high byte maskw */ -#define PRXS2_HTPHY_MMPLCH_RATE_MASK 0x00F0 /* Mixmode PLCP rate mask */ -#define PRXS2_HTPHY_RXPWR_ANT0 0xFF00 /* Rx power on core 0 */ +/* Mixmode PLCP Length high byte maskw */ +#define PRXS2_HTPHY_MMPLCPLenH_MASK 0x000F +/* Mixmode PLCP rate mask */ +#define PRXS2_HTPHY_MMPLCH_RATE_MASK 0x00F0 +/* Rx power on core 0 */ +#define PRXS2_HTPHY_RXPWR_ANT0 0xFF00 /* htphy PhyRxStatus_3: */ -#define PRXS3_HTPHY_RXPWR_ANT1 0x00FF /* Rx power on core 1 */ -#define PRXS3_HTPHY_RXPWR_ANT2 0xFF00 /* Rx power on core 2 */ +/* Rx power on core 1 */ +#define PRXS3_HTPHY_RXPWR_ANT1 0x00FF +/* Rx power on core 2 */ +#define PRXS3_HTPHY_RXPWR_ANT2 0xFF00 /* htphy PhyRxStatus_4: */ -#define PRXS4_HTPHY_RXPWR_ANT3 0x00FF /* Rx power on core 3 */ -#define PRXS4_HTPHY_CFO 0xFF00 /* Coarse frequency offset */ +/* Rx power on core 3 */ +#define PRXS4_HTPHY_RXPWR_ANT3 0x00FF +/* Coarse frequency offset */ +#define PRXS4_HTPHY_CFO 0xFF00 /* htphy PhyRxStatus_5: */ -#define PRXS5_HTPHY_FFO 0x00FF /* Fine frequency offset */ -#define PRXS5_HTPHY_AR 0xFF00 /* Advance Retard */ +/* Fine frequency offset */ +#define PRXS5_HTPHY_FFO 0x00FF +/* Advance Retard */ +#define PRXS5_HTPHY_AR 0xFF00 -#define HTPHY_MMPLCPLen(rxs) ((((rxs)->PhyRxStatus_1 & PRXS1_HTPHY_MMPLCPLenL_MASK) >> 8) | \ +#define HTPHY_MMPLCPLen(rxs) \ + ((((rxs)->PhyRxStatus_1 & PRXS1_HTPHY_MMPLCPLenL_MASK) >> 8) | \ (((rxs)->PhyRxStatus_2 & PRXS2_HTPHY_MMPLCPLenH_MASK) << 8)) /* Get Rx power on core 0 */ -#define HTPHY_RXPWR_ANT0(rxs) ((((rxs)->PhyRxStatus_2) & PRXS2_HTPHY_RXPWR_ANT0) >> 8) +#define HTPHY_RXPWR_ANT0(rxs) \ + ((((rxs)->PhyRxStatus_2) & PRXS2_HTPHY_RXPWR_ANT0) >> 8) /* Get Rx power on core 1 */ -#define HTPHY_RXPWR_ANT1(rxs) (((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT1) +#define HTPHY_RXPWR_ANT1(rxs) \ + (((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT1) /* Get Rx power on core 2 */ -#define HTPHY_RXPWR_ANT2(rxs) ((((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT2) >> 8) +#define HTPHY_RXPWR_ANT2(rxs) \ + ((((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT2) >> 8) /* ucode RxStatus1: */ #define RXS_BCNSENT 0x8000 @@ -1400,7 +1529,8 @@ struct brcms_d11rxhdr { #define RXS_SECKINDX_SHIFT 5 #define RXS_DECERR (1 << 4) #define RXS_DECATMPT (1 << 3) -#define RXS_PBPRES (1 << 2) /* PAD bytes to make IP data 4 bytes aligned */ +/* PAD bytes to make IP data 4 bytes aligned */ +#define RXS_PBPRES (1 << 2) #define RXS_RESPFRAMETX (1 << 1) #define RXS_FCSERR (1 << 0) @@ -1433,16 +1563,17 @@ struct brcms_d11rxhdr { #define M_PSM_SOFT_REGS 0x0 #define M_BOM_REV_MAJOR (M_PSM_SOFT_REGS + 0x0) #define M_BOM_REV_MINOR (M_PSM_SOFT_REGS + 0x2) -#define M_UCODE_DBGST (M_PSM_SOFT_REGS + 0x40) /* ucode debug status code */ -#define M_UCODE_MACSTAT (M_PSM_SOFT_REGS + 0xE0) /* macstat counters */ +#define M_UCODE_DBGST (M_PSM_SOFT_REGS + 0x40) /* ucode debug status code */ +#define M_UCODE_MACSTAT (M_PSM_SOFT_REGS + 0xE0) /* macstat counters */ -#define M_AGING_THRSH (0x3e * 2) /* max time waiting for medium before tx */ -#define M_MBURST_SIZE (0x40 * 2) /* max frames in a frameburst */ -#define M_MBURST_TXOP (0x41 * 2) /* max frameburst TXOP in unit of us */ -#define M_SYNTHPU_DLY (0x4a * 2) /* pre-wakeup for synthpu, default: 500 */ +#define M_AGING_THRSH (0x3e * 2) /* max time waiting for medium before tx */ +#define M_MBURST_SIZE (0x40 * 2) /* max frames in a frameburst */ +#define M_MBURST_TXOP (0x41 * 2) /* max frameburst TXOP in unit of us */ +#define M_SYNTHPU_DLY (0x4a * 2) /* pre-wakeup for synthpu, default: 500 */ #define M_PRETBTT (0x4b * 2) -#define M_ALT_TXPWR_IDX (M_PSM_SOFT_REGS + (0x3b * 2)) /* offset to the target txpwr */ +/* offset to the target txpwr */ +#define M_ALT_TXPWR_IDX (M_PSM_SOFT_REGS + (0x3b * 2)) #define M_PHY_TX_FLT_PTR (M_PSM_SOFT_REGS + (0x3d * 2)) #define M_CTS_DURATION (M_PSM_SOFT_REGS + (0x5c * 2)) #define M_LP_RCCAL_OVR (M_PSM_SOFT_REGS + (0x6b * 2)) @@ -1451,11 +1582,16 @@ struct brcms_d11rxhdr { #define M_RXSTATS_BLK_PTR (M_PSM_SOFT_REGS + (0x65 * 2)) /* ucode debug status codes */ -#define DBGST_INACTIVE 0 /* not valid really */ -#define DBGST_INIT 1 /* after zeroing SHM, before suspending at init */ -#define DBGST_ACTIVE 2 /* "normal" state */ -#define DBGST_SUSPENDED 3 /* suspended */ -#define DBGST_ASLEEP 4 /* asleep (PS mode) */ +/* not valid really */ +#define DBGST_INACTIVE 0 +/* after zeroing SHM, before suspending at init */ +#define DBGST_INIT 1 +/* "normal" state */ +#define DBGST_ACTIVE 2 +/* suspended */ +#define DBGST_SUSPENDED 3 +/* asleep (PS mode) */ +#define DBGST_ASLEEP 4 /* Scratch Reg defs */ enum _ePsmScratchPadRegDefinitions { @@ -1463,66 +1599,66 @@ enum _ePsmScratchPadRegDefinitions { S_RSV1, S_RSV2, - /* scratch registers for Dot11-contants */ - S_DOT11_CWMIN, /* CW-minimum 0x03 */ - S_DOT11_CWMAX, /* CW-maximum 0x04 */ - S_DOT11_CWCUR, /* CW-current 0x05 */ - S_DOT11_SRC_LMT, /* short retry count limit 0x06 */ - S_DOT11_LRC_LMT, /* long retry count limit 0x07 */ - S_DOT11_DTIMCOUNT, /* DTIM-count 0x08 */ + /* offset 0x03: scratch registers for Dot11-contants */ + S_DOT11_CWMIN, /* CW-minimum */ + S_DOT11_CWMAX, /* CW-maximum */ + S_DOT11_CWCUR, /* CW-current */ + S_DOT11_SRC_LMT, /* short retry count limit */ + S_DOT11_LRC_LMT, /* long retry count limit */ + S_DOT11_DTIMCOUNT, /* DTIM-count */ - /* Tx-side scratch registers */ - S_SEQ_NUM, /* hardware sequence number reg 0x09 */ - S_SEQ_NUM_FRAG, /* seq-num for frags (Set at the start os MSDU 0x0A */ - S_FRMRETX_CNT, /* frame retx count 0x0B */ - S_SSRC, /* Station short retry count 0x0C */ - S_SLRC, /* Station long retry count 0x0D */ - S_EXP_RSP, /* Expected response frame 0x0E */ - S_OLD_BREM, /* Remaining backoff ctr 0x0F */ - S_OLD_CWWIN, /* saved-off CW-cur 0x10 */ - S_TXECTL, /* TXE-Ctl word constructed in scr-pad 0x11 */ - S_CTXTST, /* frm type-subtype as read from Tx-descr 0x12 */ + /* offset 0x09: Tx-side scratch registers */ + S_SEQ_NUM, /* hardware sequence number reg */ + S_SEQ_NUM_FRAG, /* seq num for frags (at the start of MSDU) */ + S_FRMRETX_CNT, /* frame retx count */ + S_SSRC, /* Station short retry count */ + S_SLRC, /* Station long retry count */ + S_EXP_RSP, /* Expected response frame */ + S_OLD_BREM, /* Remaining backoff ctr */ + S_OLD_CWWIN, /* saved-off CW-cur */ + S_TXECTL, /* TXE-Ctl word constructed in scr-pad */ + S_CTXTST, /* frm type-subtype as read from Tx-descr */ - /* Rx-side scratch registers */ - S_RXTST, /* Type and subtype in Rxframe 0x13 */ + /* offset 0x13: Rx-side scratch registers */ + S_RXTST, /* Type and subtype in Rxframe */ /* Global state register */ - S_STREG, /* state storage actual bit maps below 0x14 */ + S_STREG, /* state storage actual bit maps below */ - S_TXPWR_SUM, /* Tx power control: accumulator 0x15 */ - S_TXPWR_ITER, /* Tx power control: iteration 0x16 */ - S_RX_FRMTYPE, /* Rate and PHY type for frames 0x17 */ - S_THIS_AGG, /* Size of this AGG (A-MSDU) 0x18 */ + S_TXPWR_SUM, /* Tx power control: accumulator */ + S_TXPWR_ITER, /* Tx power control: iteration */ + S_RX_FRMTYPE, /* Rate and PHY type for frames */ + S_THIS_AGG, /* Size of this AGG (A-MSDU) */ - S_KEYINDX, /* 0x19 */ - S_RXFRMLEN, /* Receive MPDU length in bytes 0x1A */ + S_KEYINDX, + S_RXFRMLEN, /* Receive MPDU length in bytes */ - /* Receive TSF time stored in SCR */ - S_RXTSFTMRVAL_WD3, /* TSF value at the start of rx 0x1B */ - S_RXTSFTMRVAL_WD2, /* TSF value at the start of rx 0x1C */ - S_RXTSFTMRVAL_WD1, /* TSF value at the start of rx 0x1D */ - S_RXTSFTMRVAL_WD0, /* TSF value at the start of rx 0x1E */ - S_RXSSN, /* Received start seq number for A-MPDU BA 0x1F */ - S_RXQOSFLD, /* Rx-QoS field (if present) 0x20 */ + /* offset 0x1B: Receive TSF time stored in SCR */ + S_RXTSFTMRVAL_WD3, /* TSF value at the start of rx */ + S_RXTSFTMRVAL_WD2, /* TSF value at the start of rx */ + S_RXTSFTMRVAL_WD1, /* TSF value at the start of rx */ + S_RXTSFTMRVAL_WD0, /* TSF value at the start of rx */ + S_RXSSN, /* Received start seq number for A-MPDU BA */ + S_RXQOSFLD, /* Rx-QoS field (if present) */ - /* Scratch pad regs used in microcode as temp storage */ - S_TMP0, /* stmp0 0x21 */ - S_TMP1, /* stmp1 0x22 */ - S_TMP2, /* stmp2 0x23 */ - S_TMP3, /* stmp3 0x24 */ - S_TMP4, /* stmp4 0x25 */ - S_TMP5, /* stmp5 0x26 */ - S_PRQPENALTY_CTR, /* Probe response queue penalty counter 0x27 */ - S_ANTCNT, /* unsuccessful attempts on current ant. 0x28 */ - S_SYMBOL, /* flag for possible symbol ctl frames 0x29 */ - S_RXTP, /* rx frame type 0x2A */ - S_STREG2, /* extra state storage 0x2B */ - S_STREG3, /* even more extra state storage 0x2C */ - S_STREG4, /* ... 0x2D */ - S_STREG5, /* remember to initialize it to zero 0x2E */ + /* offset 0x21: Scratch pad regs used in microcode as temp storage */ + S_TMP0, /* stmp0 */ + S_TMP1, /* stmp1 */ + S_TMP2, /* stmp2 */ + S_TMP3, /* stmp3 */ + S_TMP4, /* stmp4 */ + S_TMP5, /* stmp5 */ + S_PRQPENALTY_CTR, /* Probe response queue penalty counter */ + S_ANTCNT, /* unsuccessful attempts on current ant. */ + S_SYMBOL, /* flag for possible symbol ctl frames */ + S_RXTP, /* rx frame type */ + S_STREG2, /* extra state storage */ + S_STREG3, /* even more extra state storage */ + S_STREG4, /* ... */ + S_STREG5, /* remember to initialize it to zero */ S_ADJPWR_IDX, - S_CUR_PTR, /* Temp pointer for A-MPDU re-Tx SHM table 0x32 */ + S_CUR_PTR, /* Temp pointer for A-MPDU re-Tx SHM table */ S_REVID4, /* 0x33 */ S_INDX, /* 0x34 */ S_ADDR0, /* 0x35 */ @@ -1532,9 +1668,9 @@ enum _ePsmScratchPadRegDefinitions { S_ADDR4, /* 0x39 */ S_ADDR5, /* 0x3A */ S_TMP6, /* 0x3B */ - S_KEYINDX_BU, /* Backup for Key index 0x3C */ - S_MFGTEST_TMP0, /* Temp register used for RX test calculations 0x3D */ - S_RXESN, /* Received end sequence number for A-MPDU BA 0x3E */ + S_KEYINDX_BU, /* Backup for Key index */ + S_MFGTEST_TMP0, /* Temp regs used for RX test calculations */ + S_RXESN, /* Received end sequence number for A-MPDU BA */ S_STREG6, /* 0x3F */ }; @@ -1628,7 +1764,8 @@ struct macstat { #define SISF_FCLKA 0x0004 /* FastClkAvailable */ #define SISF_DB_PHY 0x0008 /* Dualband phy */ -/* === End of MAC reg, Beginning of PHY(b/a/g/n) reg, radio and LPPHY regs are separated === */ +/* === End of MAC reg, Beginning of PHY(b/a/g/n) reg === */ +/* radio and LPPHY regs are separated */ #define BPHY_REG_OFT_BASE 0x0 /* offsets for indirect access to bphy registers */ diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 31a47286d12..e6620237105 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -28,7 +28,8 @@ #include "dma.h" /* - * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical address. + * Each descriptor ring must be 8kB aligned, and fit within a + * contiguous 8kB physical address. */ #define D64RINGALIGN_BITS 13 #define D64MAXRINGSZ (1 << D64RINGALIGN_BITS) @@ -69,21 +70,32 @@ #define D64_XS1_XE_COREE 0x50000000 /* core error */ /* receive channel control */ -#define D64_RC_RE 0x00000001 /* receive enable */ -#define D64_RC_RO_MASK 0x000000fe /* receive frame offset */ +/* receive enable */ +#define D64_RC_RE 0x00000001 +/* receive frame offset */ +#define D64_RC_RO_MASK 0x000000fe #define D64_RC_RO_SHIFT 1 -#define D64_RC_FM 0x00000100 /* direct fifo receive (pio) mode */ -#define D64_RC_SH 0x00000200 /* separate rx header descriptor enable */ -#define D64_RC_OC 0x00000400 /* overflow continue */ -#define D64_RC_PD 0x00000800 /* parity check disable */ -#define D64_RC_AE 0x00030000 /* address extension bits */ +/* direct fifo receive (pio) mode */ +#define D64_RC_FM 0x00000100 +/* separate rx header descriptor enable */ +#define D64_RC_SH 0x00000200 +/* overflow continue */ +#define D64_RC_OC 0x00000400 +/* parity check disable */ +#define D64_RC_PD 0x00000800 +/* address extension bits */ +#define D64_RC_AE 0x00030000 #define D64_RC_AE_SHIFT 16 /* flags for dma controller */ -#define DMA_CTRL_PEN (1 << 0) /* partity enable */ -#define DMA_CTRL_ROC (1 << 1) /* rx overflow continue */ -#define DMA_CTRL_RXMULTI (1 << 2) /* allow rx scatter to multiple descriptors */ -#define DMA_CTRL_UNFRAMED (1 << 3) /* Unframed Rx/Tx data */ +/* partity enable */ +#define DMA_CTRL_PEN (1 << 0) +/* rx overflow continue */ +#define DMA_CTRL_ROC (1 << 1) +/* allow rx scatter to multiple descriptors */ +#define DMA_CTRL_RXMULTI (1 << 2) +/* Unframed Rx/Tx data */ +#define DMA_CTRL_UNFRAMED (1 << 3) /* receive descriptor table pointer */ #define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */ @@ -131,10 +143,13 @@ #define D64_CTRL1_SOF ((u32)1 << 31) /* start of frame */ /* descriptor control flags 2 */ -#define D64_CTRL2_BC_MASK 0x00007fff /* buffer byte count. real data len must <= 16KB */ -#define D64_CTRL2_AE 0x00030000 /* address extension bits */ +/* buffer byte count. real data len must <= 16KB */ +#define D64_CTRL2_BC_MASK 0x00007fff +/* address extension bits */ +#define D64_CTRL2_AE 0x00030000 #define D64_CTRL2_AE_SHIFT 16 -#define D64_CTRL2_PARITY 0x00040000 /* parity bit */ +/* parity bit */ +#define D64_CTRL2_PARITY 0x00040000 /* control flags in the range [27:20] are core-specific and not defined here */ #define D64_CTRL_CORE_MASK 0x0ff00000 @@ -149,10 +164,17 @@ #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */ #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */ -/* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF). - * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL. - * There is a compile time check in wlc.c which ensure that this value is at least as big - * as TXOFF. This value is used in dma_rxfill (dma.c). +#define DMA64_DD_PARITY(dd) \ + parity32((dd)->addrlow ^ (dd)->addrhigh ^ (dd)->ctrl1 ^ (dd)->ctrl2) + + +/* + * packet headroom necessary to accommodate the largest header + * in the system, (i.e TXOFF). By doing, we avoid the need to + * allocate an extra buffer for the header when bridging to WL. + * There is a compile time check in wlc.c which ensure that this + * value is at least as big as TXOFF. This value is used in + * dma_rxfill(). */ #define BCMEXTRAHDROOM 172 @@ -193,7 +215,10 @@ #define txd64 dregs.d64_u.txd_64 #define rxd64 dregs.d64_u.rxd_64 -/* default dma message level (if input msg_level pointer is null in dma_attach()) */ +/* + * default dma message level (if input msg_level + * pointer is null in dma_attach()) + */ static uint dma_msg_level; #define MAXNAMEL 8 /* 8 char names */ @@ -210,8 +235,8 @@ struct dma_seg { }; struct dma_seg_map { - void *oshdmah; /* Opaque handle for OSL to store its information */ - uint origsize; /* Size of the virtual packet */ + void *oshdmah; /* Opaque handle for OSL to store its information */ + uint origsize; /* Size of the virtual packet */ uint nsegs; struct dma_seg segs[MAX_DMA_SEGS]; }; @@ -221,9 +246,9 @@ struct dma_seg_map { * Descriptors are only read by the hardware, never written back. */ struct dma64desc { - u32 ctrl1; /* misc control bits & bufcount */ - u32 ctrl2; /* buffer count and address extension */ - u32 addrlow; /* memory address of the date buffer, bits 31:0 */ + u32 ctrl1; /* misc control bits & bufcount */ + u32 ctrl2; /* buffer count and address extension */ + u32 addrlow; /* memory address of the date buffer, bits 31:0 */ u32 addrhigh; /* memory address of the date buffer, bits 63:32 */ }; @@ -235,8 +260,8 @@ struct dma_info { void *pbus; /* bus handle */ - bool dma64; /* this dma engine is operating in 64-bit mode */ - bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ + bool dma64; /* this dma engine is operating in 64-bit mode */ + bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ union { struct { @@ -256,7 +281,7 @@ struct dma_info { u16 ntxd; /* # tx descriptors tunable */ u16 txin; /* index of next descriptor to reclaim */ u16 txout; /* index of next descriptor to post */ - void **txp; /* pointer to parallel array of pointers to packets */ + void **txp; /* pointer to parallel array of pointers to packets */ struct dma_seg_map *txp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long txdpa; @@ -265,14 +290,14 @@ struct dma_info { u16 txdalign; /* #bytes added to alloc'd mem to align txd */ u32 txdalloc; /* #bytes allocated for the ring */ u32 xmtptrbase; /* When using unaligned descriptors, the ptr register - * is not just an index, it needs all 13 bits to be - * an offset from the addr register. - */ + * is not just an index, it needs all 13 bits to be + * an offset from the addr register. + */ - u16 nrxd; /* # rx descriptors tunable */ - u16 rxin; /* index of next descriptor to reclaim */ - u16 rxout; /* index of next descriptor to post */ - void **rxp; /* pointer to parallel array of pointers to packets */ + u16 nrxd; /* # rx descriptors tunable */ + u16 rxin; /* index of next descriptor to reclaim */ + u16 rxout; /* index of next descriptor to post */ + void **rxp; /* pointer to parallel array of pointers to packets */ struct dma_seg_map *rxp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long rxdpa; @@ -283,25 +308,34 @@ struct dma_info { u32 rcvptrbase; /* Base for ptr reg when using unaligned descriptors */ /* tunables */ - unsigned int rxbufsize; /* rx buffer size in bytes, - * not including the extra headroom + unsigned int rxbufsize; /* rx buffer size in bytes, not including + * the extra headroom */ - uint rxextrahdrroom; /* extra rx headroom, reverseved to assist upper stack - * e.g. some rx pkt buffers will be bridged to tx side - * without byte copying. The extra headroom needs to be - * large enough to fit txheader needs. - * Some dongle driver may not need it. + uint rxextrahdrroom; /* extra rx headroom, reverseved to assist upper + * stack, e.g. some rx pkt buffers will be + * bridged to tx side without byte copying. + * The extra headroom needs to be large enough + * to fit txheader needs. Some dongle driver may + * not need it. */ uint nrxpost; /* # rx buffers to keep posted */ unsigned int rxoffset; /* rxcontrol offset */ - uint ddoffsetlow; /* add to get dma address of descriptor ring, low 32 bits */ - uint ddoffsethigh; /* high 32 bits */ - uint dataoffsetlow; /* add to get dma address of data buffer, low 32 bits */ - uint dataoffsethigh; /* high 32 bits */ - bool aligndesc_4k; /* descriptor base need to be aligned or not */ + /* add to get dma address of descriptor ring, low 32 bits */ + uint ddoffsetlow; + /* high 32 bits */ + uint ddoffsethigh; + /* add to get dma address of data buffer, low 32 bits */ + uint dataoffsetlow; + /* high 32 bits */ + uint dataoffsethigh; + /* descriptor base need to be aligned or not */ + bool aligndesc_4k; }; -/* DMA Scatter-gather list is supported. Note this is limited to TX direction only */ +/* + * DMA Scatter-gather list is supported. Note this is limited to TX + * direction only + */ #ifdef BCMDMASGLISTOSL #define DMASGLIST_ENAB true #else @@ -309,7 +343,9 @@ struct dma_info { #endif /* BCMDMASGLISTOSL */ /* descriptor bumping macros */ -#define XXD(x, n) ((x) & ((n) - 1)) /* faster than %, but n must be power of 2 */ +/* faster than %, but n must be power of 2 */ +#define XXD(x, n) ((x) & ((n) - 1)) + #define TXD(x) XXD((x), di->ntxd) #define RXD(x) XXD((x), di->nrxd) #define NEXTTXD(i) TXD((i) + 1) @@ -465,10 +501,10 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->d64rxregs = (struct dma64regs *) dmaregsrx; di->dma.di_fn = (const struct di_fcn_s *)&dma64proc; - /* Default flags (which can be changed by the driver calling dma_ctrlflags - * before enable): For backwards compatibility both Rx Overflow Continue - * and Parity are DISABLED. - * supports it. + /* + * Default flags (which can be changed by the driver calling + * dma_ctrlflags before enable): For backwards compatibility + * both Rx Overflow Continue and Parity are DISABLED. */ di->dma.di_fn->ctrlflags(&di->dma, DMA_CTRL_ROC | DMA_CTRL_PEN, 0); @@ -502,9 +538,10 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, /* * figure out the DMA physical address offset for dd and data - * PCI/PCIE: they map silicon backplace address to zero based memory, need offset - * Other bus: use zero - * SI_BUS BIGENDIAN kludge: use sdram swapped region for data buffer, not descriptor + * PCI/PCIE: they map silicon backplace address to zero + * based memory, need offset + * Other bus: use zero SI_BUS BIGENDIAN kludge: use sdram + * swapped region for data buffer, not descriptor */ di->ddoffsetlow = 0; di->dataoffsetlow = 0; @@ -529,7 +566,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, else di->addrext = _dma_isaddrext(di); - /* does the descriptors need to be aligned and if yes, on 4K/8K or not */ + /* does the descriptor need to be aligned and if yes, on 4K/8K or not */ di->aligndesc_4k = _dma_descriptor_align(di); if (di->aligndesc_4k) { di->dmadesc_align = D64RINGALIGN_BITS; @@ -548,7 +585,8 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, size = ntxd * sizeof(void *); di->txp = kzalloc(size, GFP_ATOMIC); if (di->txp == NULL) { - DMA_ERROR(("%s: dma_attach: out of tx memory\n", di->name)); + DMA_ERROR(("%s: dma_attach: out of tx memory\n", + di->name)); goto fail; } } @@ -558,18 +596,25 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, size = nrxd * sizeof(void *); di->rxp = kzalloc(size, GFP_ATOMIC); if (di->rxp == NULL) { - DMA_ERROR(("%s: dma_attach: out of rx memory\n", di->name)); + DMA_ERROR(("%s: dma_attach: out of rx memory\n", + di->name)); goto fail; } } - /* allocate transmit descriptor ring, only need ntxd descriptors but it must be aligned */ + /* + * allocate transmit descriptor ring, only need ntxd descriptors + * but it must be aligned + */ if (ntxd) { if (!_dma_alloc(di, DMA_TX)) goto fail; } - /* allocate receive descriptor ring, only need nrxd descriptors but it must be aligned */ + /* + * allocate receive descriptor ring, only need nrxd descriptors + * but it must be aligned + */ if (nrxd) { if (!_dma_alloc(di, DMA_RX)) goto fail; @@ -577,16 +622,23 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, if ((di->ddoffsetlow != 0) && !di->addrext) { if (PHYSADDRLO(di->txdpa) > SI_PCI_DMA_SZ) { - DMA_ERROR(("%s: dma_attach: txdpa 0x%x: addrext not supported\n", di->name, (u32) PHYSADDRLO(di->txdpa))); + DMA_ERROR(("%s: dma_attach: txdpa 0x%x: addrext not " + "supported\n", di->name, + (u32)PHYSADDRLO(di->txdpa))); goto fail; } if (PHYSADDRLO(di->rxdpa) > SI_PCI_DMA_SZ) { - DMA_ERROR(("%s: dma_attach: rxdpa 0x%x: addrext not supported\n", di->name, (u32) PHYSADDRLO(di->rxdpa))); + DMA_ERROR(("%s: dma_attach: rxdpa 0x%x: addrext not " + "supported\n", di->name, + (u32)PHYSADDRLO(di->rxdpa))); goto fail; } } - DMA_TRACE(("ddoffsetlow 0x%x ddoffsethigh 0x%x dataoffsetlow 0x%x dataoffsethigh " "0x%x addrext %d\n", di->ddoffsetlow, di->ddoffsethigh, di->dataoffsetlow, di->dataoffsethigh, di->addrext)); + DMA_TRACE(("ddoffsetlow 0x%x ddoffsethigh 0x%x dataoffsetlow 0x%x " + "dataoffsethigh " "0x%x addrext %d\n", di->ddoffsetlow, + di->ddoffsethigh, di->dataoffsetlow, di->dataoffsethigh, + di->addrext)); /* allocate DMA mapping vectors */ if (DMASGLIST_ENAB) { @@ -624,8 +676,6 @@ static inline u32 parity32(u32 data) return data & 1; } -#define DMA64_DD_PARITY(dd) parity32((dd)->addrlow ^ (dd)->addrhigh ^ (dd)->ctrl1 ^ (dd)->ctrl2) - static inline void dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, unsigned long pa, uint outidx, u32 *flags, u32 bufcount) @@ -735,7 +785,10 @@ static bool _dma_descriptor_align(struct dma_info *di) return true; } -/* return true if this dma engine supports DmaExtendedAddrChanges, otherwise false */ +/* + * return true if this dma engine supports DmaExtendedAddrChanges, + * otherwise false + */ static bool _dma_isaddrext(struct dma_info *di) { /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ @@ -868,14 +921,15 @@ _dma_rx_param_get(struct dma_info *di, u16 *rxoffset, u16 *rxbufsize) *rxbufsize = (u16) di->rxbufsize; } -/* !! rx entry routine +/* + * !! rx entry routine * returns a pointer to the next frame received, or NULL if there are no more - * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is supported - * with pkts chain + * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is + * supported with pkts chain * otherwise, it's treated as giant pkt and will be tossed. - * The DMA scattering starts with normal DMA header, followed by first buffer data. - * After it reaches the max size of buffer, the data continues in next DMA descriptor - * buffer WITHOUT DMA header + * The DMA scattering starts with normal DMA header, followed by first + * buffer data. After it reaches the max size of buffer, the data continues + * in next DMA descriptor buffer WITHOUT DMA header */ static void *_dma_rx(struct dma_info *di) { @@ -935,10 +989,11 @@ static void *_dma_rx(struct dma_info *di) return head; } -/* post receive buffers - * return false is refill failed completely and ring is empty - * this will stall the rx dma and user might want to call rxfill again asap - * This unlikely happens on memory-rich NIC, but often on memory-constrained dongle +/* + * post receive buffers + * return false is refill failed completely and ring is empty this will stall + * the rx dma and user might want to call rxfill again asap. This unlikely + * happens on memory-rich NIC, but often on memory-constrained dongle */ static bool _dma_rxfill(struct dma_info *di) { @@ -970,10 +1025,10 @@ static bool _dma_rxfill(struct dma_info *di) extra_offset = di->rxextrahdrroom; for (i = 0; i < n; i++) { - /* the di->rxbufsize doesn't include the extra headroom, we need to add it to the - size to be allocated + /* + * the di->rxbufsize doesn't include the extra headroom, + * we need to add it to the size to be allocated */ - p = brcmu_pkt_buf_get_skb(di->rxbufsize + extra_offset); if (p == NULL) { @@ -1339,7 +1394,8 @@ static bool dma64_alloc(struct dma_info *di, uint direction) va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, &alloced, &di->txdpaorig); if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name)); + DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd)" + " failed\n", di->name)); return false; } align = (1 << align_bits); @@ -1354,7 +1410,8 @@ static bool dma64_alloc(struct dma_info *di, uint direction) va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, &alloced, &di->rxdpaorig); if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name)); + DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd)" + " failed\n", di->name)); return false; } align = (1 << align_bits); @@ -1445,9 +1502,10 @@ static bool dma64_txsuspendedidle(struct dma_info *di) return 0; } -/* Useful when sending unframed data. This allows us to get a progress report from the DMA. - * We return a pointer to the beginning of the DATA buffer of the current descriptor. - * If DMA is idle, we return NULL. +/* + * Useful when sending unframed data. This allows us to get a progress report + * from the DMA. We return a pointer to the beginning of the DATA buffer of the + * current descriptor. If DMA is idle, we return NULL. */ static void *dma64_getpos(struct dma_info *di, bool direction) { @@ -1481,8 +1539,8 @@ static void *dma64_getpos(struct dma_info *di, bool direction) * Adds a DMA ring descriptor for the data pointed to by "buf". * This is for DMA of a buffer of data and is unlike other dma TX functions * that take a pointer to a "packet" - * Each call to this is results in a single descriptor being added for "len" bytes of - * data starting at "buf", it doesn't handle chained buffers. + * Each call to this is results in a single descriptor being added for "len" + * bytes of data starting at "buf", it doesn't handle chained buffers. */ static int dma64_txunframed(struct dma_info *di, void *buf, uint len, bool commit) @@ -1533,9 +1591,11 @@ dma64_txunframed(struct dma_info *di, void *buf, uint len, bool commit) return -1; } -/* !! tx entry routine +/* + * !! tx entry routine * WARNING: call must check the return value for error. - * the error(toss frames) could be fatal and cause many subsequent hard to debug problems + * the error(toss frames) could be fatal and cause many subsequent hard + * to debug problems */ static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, bool commit) @@ -1597,8 +1657,8 @@ static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, /* With a DMA segment list, Descriptor table is filled * using the segment list instead of looping over - * buffers in multi-chain DMA. Therefore, EOF for SGLIST is when - * end of segment list is reached. + * buffers in multi-chain DMA. Therefore, EOF for SGLIST + * is when end of segment list is reached. */ if ((!DMASGLIST_ENAB && next == NULL) || (DMASGLIST_ENAB && j == nsegs)) @@ -1746,7 +1806,8 @@ static void *dma64_getnexttxp(struct dma_info *di, enum txd_range range) return txp; bogus: - DMA_NONE(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n", start, end, di->txout, forceall)); + DMA_NONE(("dma_getnexttxp: bogus curr: start %d end %d txout %d " + "force %d\n", start, end, di->txout, forceall)); return NULL; } @@ -1888,7 +1949,7 @@ uint dma_addrwidth(struct si_pub *sih, void *dmaregs) (sih->buscoretype == PCIE_CORE_ID))) return DMADDRWIDTH_64; } - /* DMA hardware not supported by this driver*/ + /* DMA hardware not supported by this driver */ return DMADDRWIDTH_64; } diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 334f2eb3036..4a330284dcc 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -39,12 +39,12 @@ struct dma32diag { /* diag access */ /* dma registers per channel(xmt or rcv) */ struct dma64regs { - u32 control; /* enable, et al */ - u32 ptr; /* last descriptor posted to chip */ - u32 addrlow; /* descriptor ring base address low 32-bits (8K aligned) */ - u32 addrhigh; /* descriptor ring base address bits 63:32 (8K aligned) */ - u32 status0; /* current descriptor, xmt state */ - u32 status1; /* active descriptor, xmt error */ + u32 control; /* enable, et al */ + u32 ptr; /* last descriptor posted to chip */ + u32 addrlow; /* desc ring base address low 32-bits (8K aligned) */ + u32 addrhigh; /* desc ring base address bits 63:32 (8K aligned) */ + u32 status0; /* current descriptor, xmt state */ + u32 status1; /* active descriptor, xmt error */ }; /* map/unmap direction */ @@ -172,7 +172,8 @@ extern const struct di_fcn_s dma64proc; #define dma_rxactive(di) (dma64proc.rxactive(di)) #define dma_txrotate(di) (dma64proc.txrotate(di)) #define dma_counterreset(di) (dma64proc.counterreset(di)) -#define dma_ctrlflags(di, mask, flags) (dma64proc.ctrlflags((di), (mask), (flags))) +#define dma_ctrlflags(di, mask, flags) \ + (dma64proc.ctrlflags((di), (mask), (flags))) #define dma_txpending(di) (dma64proc.txpending(di)) #define dma_txcommitted(di) (dma64proc.txcommitted(di)) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 1437e51a237..0af60414d9e 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -606,7 +606,10 @@ brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; - /* minstrel_ht initiates addBA on our behalf by calling ieee80211_start_tx_ba_session() */ + /* + * minstrel_ht initiates addBA on our behalf by calling + * ieee80211_start_tx_ba_session() + */ return 0; } @@ -644,7 +647,10 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, tid); return -EINVAL; } - /* Future improvement: Use the starting sequence number provided ... */ + /* + * Future improvement: + * Use the starting sequence number provided ... + */ *ssn = 0; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); break; @@ -1019,8 +1025,9 @@ static struct ieee80211_supported_band brcms_band_5GHz_nphy = { .bitrates = legacy_ratetable + 4, .n_bitrates = ARRAY_SIZE(legacy_ratetable) - 4, .ht_cap = { - /* use IEEE80211_HT_CAP_* from include/linux/ieee80211.h */ - .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ + .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40 | + IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ .ht_supported = true, .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, .ampdu_density = AMPDU_DEF_MPDU_DENSITY, @@ -1086,7 +1093,8 @@ static int ieee_hw_init(struct ieee80211_hw *hw) hw->queues = N_TX_QUEUES; hw->max_rates = 2; /* Primary rate and 1 fallback rate */ - hw->channel_change_time = 7 * 1000; /* channel change time is dependent on chip and band */ + /* channel change time is dependent on chip and band */ + hw->channel_change_time = 7 * 1000; hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); hw->rate_control_algorithm = "minstrel_ht"; @@ -1361,8 +1369,9 @@ static void brcms_free(struct brcms_info *wl) } /* - * unregister_netdev() calls get_stats() which may read chip registers - * so we cannot unmap the chip registers until after calling unregister_netdev() . + * unregister_netdev() calls get_stats() which may read chip + * registers so we cannot unmap the chip registers until + * after calling unregister_netdev() . */ if (wl->regsva && wl->bcm_bustype != SDIO_BUS && wl->bcm_bustype != JTAG_BUS) @@ -1632,7 +1641,8 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl, return t; } -/* BMAC_NOTE: Add timer adds only the kernel timer since it's going to be more accurate +/* + * adds only the kernel timer since it's going to be more accurate * as well as it's easier to make it periodic * * precondition: perimeter lock has been acquired diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 40e3d375ea9..0d913664355 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -23,11 +23,6 @@ /* softmac ioctl definitions */ #define BRCMS_SET_SHORTSLOT_OVERRIDE 146 - -/* BMAC Note: High-only driver is no longer working in softirq context as it needs to block and - * sleep so perimeter lock has to be a semaphore instead of spinlock. This requires timers to be - * submitted to workqueue instead of being on kernel timer - */ struct brcms_timer { struct timer_list timer; struct brcms_info *wl; @@ -56,8 +51,8 @@ struct brcms_firmware { }; struct brcms_info { - struct brcms_pub *pub; /* pointer to public wlc state */ - void *wlc; /* pointer to private common os-independent data */ + struct brcms_pub *pub; /* pointer to public wlc state */ + void *wlc; /* pointer to private common data */ u32 magic; int irq; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 001a1f77e69..d1a8388073a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -53,8 +53,10 @@ */ #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) -#define TIMER_INTERVAL_WATCHDOG 1000 /* watchdog timer, in unit of ms */ -#define TIMER_INTERVAL_RADIOCHK 800 /* radio monitor timer, in unit of ms */ +/* watchdog timer, in unit of ms */ +#define TIMER_INTERVAL_WATCHDOG 1000 +/* radio monitor timer, in unit of ms */ +#define TIMER_INTERVAL_RADIOCHK 800 /* Max MPC timeout, in unit of watchdog */ #ifndef BRCMS_MPC_MAX_DELAYCNT @@ -65,12 +67,16 @@ #define BRCMS_MPC_MIN_DELAYCNT 1 #define BRCMS_MPC_THRESHOLD 3 /* MPC count threshold level */ -#define BEACON_INTERVAL_DEFAULT 100 /* beacon interval, in unit of 1024TU */ -#define DTIM_INTERVAL_DEFAULT 3 /* DTIM interval, in unit of beacon interval */ +/* beacon interval, in unit of 1024TU */ +#define BEACON_INTERVAL_DEFAULT 100 +/* DTIM interval, in unit of beacon interval */ +#define DTIM_INTERVAL_DEFAULT 3 /* Scale down delays to accommodate QT slow speed */ -#define BEACON_INTERVAL_DEF_QT 20 /* beacon interval, in unit of 1024TU */ -#define DTIM_INTERVAL_DEF_QT 1 /* DTIM interval, in unit of beacon interval */ +/* beacon interval, in unit of 1024TU */ +#define BEACON_INTERVAL_DEF_QT 20 +/* DTIM interval, in unit of beacon interval */ +#define DTIM_INTERVAL_DEF_QT 1 #define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ @@ -163,26 +169,32 @@ #define AC_VO 3 /* - * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s OS timer(soft - * watchdog) it is not a wall clock and won't increment when driver is in "down" state - * this low resolution driver tick can be used for maintenance tasks such as phy - * calibration and scb update + * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s + * OS timer(soft watchdog) it is not a wall clock and won't increment when + * driver is in "down" state this low resolution driver tick can be used + * for maintenance tasks such as phy calibration and scb update */ -/* To inform the ucode of the last mcast frame posted so that it can clear moredata bit */ +/* + * To inform the ucode of the last mcast frame posted + * so that it can clear moredata bit + */ #define BCMCFID(wlc, fid) brcms_b_write_shm((wlc)->hw, M_BCMC_FID, (fid)) #define BRCMS_WAR16165(wlc) (wlc->pub->sih->bustype == PCI_BUS && \ (!AP_ENAB(wlc->pub)) && (wlc->war16165)) /* Find basic rate for a given rate */ -#define BRCMS_BASIC_RATE(wlc, rspec) (IS_MCS(rspec) ? \ - (wlc)->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK].leg_ofdm] : \ - (wlc)->band->basic_rate[rspec & RSPEC_RATE_MASK]) +#define BRCMS_BASIC_RATE(wlc, rspec) \ + (IS_MCS(rspec) \ + ? (wlc)->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK].leg_ofdm] \ + : (wlc)->band->basic_rate[rspec & RSPEC_RATE_MASK]) -#define FRAMETYPE(r, mimoframe) (IS_MCS(r) ? mimoframe : (IS_CCK(r) ? FT_CCK : FT_OFDM)) +#define FRAMETYPE(r, mimoframe) \ + (IS_MCS(r) ? mimoframe : (IS_CCK(r) ? FT_CCK : FT_OFDM)) -#define RFDISABLE_DEFAULT 10000000 /* rfdisable delay timer 500 ms, runs of ALP clock */ +/* rfdisable delay timer 500 ms, runs of ALP clock */ +#define RFDISABLE_DEFAULT 10000000 #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ @@ -193,7 +205,8 @@ /* precedences numbers for wlc queues. These are twice as may levels as * 802.1D priorities. * Odd numbers are used for HI priority traffic at same precedence levels - * These constants are used ONLY by wlc_prio2prec_map. Do not use them elsewhere. + * These constants are used ONLY by wlc_prio2prec_map. Do not use them + * elsewhere. */ #define _BRCMS_PREC_NONE 0 /* None = - */ #define _BRCMS_PREC_BK 2 /* BK - Background */ @@ -216,11 +229,9 @@ #define MBSS_PRB_ENAB(cfg) 0 #define SOFTBCN_ENAB(pub) (0) -#define TIMER_INTERVAL_WATCHDOG_BMAC 1000 /* watchdog timer, in unit of ms */ - #define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ -#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us, default */ -#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us, default */ +#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ +#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ #define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ #define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ @@ -244,7 +255,8 @@ * the twiki is updated before making changes. */ -#define XMTFIFOTBL_STARTREV 20 /* Starting corerev for the fifo size table */ +/* Starting corerev for the fifo size table */ +#define XMTFIFOTBL_STARTREV 20 /* Check if a particular BSS config is AP or STA */ #define BSSCFG_AP(cfg) (0) @@ -487,11 +499,16 @@ const u8 wlc_prio2prec_map[] = { }; static u16 xmtfifo_sz[][NFIFO] = { - {20, 192, 192, 21, 17, 5}, /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ - {9, 58, 22, 14, 14, 5}, /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ - {20, 192, 192, 21, 17, 5}, /* corerev 22: 5120, 49152, 49152, 5376, 4352, 1280 */ - {20, 192, 192, 21, 17, 5}, /* corerev 23: 5120, 49152, 49152, 5376, 4352, 1280 */ - {9, 58, 22, 14, 14, 5}, /* corerev 24: 2304, 14848, 5632, 3584, 3584, 1280 */ + /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ + {20, 192, 192, 21, 17, 5}, + /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ + {9, 58, 22, 14, 14, 5}, + /* corerev 22: 5120, 49152, 49152, 5376, 4352, 1280 */ + {20, 192, 192, 21, 17, 5}, + /* corerev 23: 5120, 49152, 49152, 5376, 4352, 1280 */ + {20, 192, 192, 21, 17, 5}, + /* corerev 24: 2304, 14848, 5632, 3584, 3584, 1280 */ + {9, 58, 22, 14, 14, 5}, }; static const u8 acbitmap2maxprio[] = { @@ -631,7 +648,9 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; - /* compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ + /* + * compute the RSSI from d11rxhdr and record it in wlc_rxd11hr + */ wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr); brcms_c_recv(wlc_hw->wlc, p); @@ -645,9 +664,9 @@ brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, u32 s2) { /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent - * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts - * transmission count) + * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, + * but the subsequent tx of DATA failed. so it will start rts/cts from + * the beginning (resetting the rts transmission count) */ if (!(txs->status & TX_STATUS_AMPDU) && (txs->status & TX_STATUS_INTERMEDIATE)) @@ -768,7 +787,10 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) wlc->qvalid = 0; } - /* received data or control frame, MI_DMAINT is indication of RX_FIFO interrupt */ + /* + * received data or control frame, MI_DMAINT is + * indication of RX_FIFO interrupt + */ if (macintstatus & MI_DMAINT) if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) wlc->macintstatus |= MI_DMAINT; @@ -826,7 +848,9 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) { uint i; char name[8]; - /* ucode host flag 2 needed for pio mode, independent of band and fifo */ + /* + * ucode host flag 2 needed for pio mode, independent of band and fifo + */ u16 pio_mhf2 = 0; struct brcms_hardware *wlc_hw = wlc->hw; uint unit = wlc_hw->unit; @@ -979,10 +1003,10 @@ static int brcms_b_bandtype(struct brcms_hardware *wlc_hw) static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) { if (PMUCTL_ENAB(wlc_hw->sih)) { - /* new chips with PMU, CCS_FORCEHT will distribute the HT clock on backplane, - * but mac core will still run on ALP(not HT) when it enters powersave mode, - * which means the FCA bit may not be set. - * should wakeup mac if driver wants it to run on HT. + /* new chips with PMU, CCS_FORCEHT will distribute the HT clock + * on backplane, but mac core will still run on ALP(not HT) when + * it enters powersave mode, which means the FCA bit may not be + * set. Should wakeup mac if driver wants it to run on HT. */ if (wlc_hw->clk) { @@ -1027,14 +1051,15 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) & SISF_FCLKA)); - /* keep the ucode wake bit on if forcefastclk is on - * since we do not want ucode to put us back to slow clock - * when it dozes for PM mode. - * Code below matches the wake override bit with current forcefastclk state - * Only setting bit in wake_override instead of waking ucode immediately - * since old code (wlc.c 1.4499) had this behavior. Older code set - * wlc->forcefastclk but only had the wake happen if the wakup_ucode work - * (protected by an up check) was executed just below. + /* + * keep the ucode wake bit on if forcefastclk is on since we + * do not want ucode to put us back to slow clock when it dozes + * for PM mode. Code below matches the wake override bit with + * current forcefastclk state. Only setting bit in wake_override + * instead of waking ucode immediately since old code had this + * behavior. Older code set wlc->forcefastclk but only had the + * wake happen if the wakup_ucode work (protected by an up + * check) was executed just below. */ if (wlc_hw->forcefastclk) mboolset(wlc_hw->wake_override, @@ -1176,7 +1201,10 @@ void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) brcms_c_mctrl_write(wlc_hw); } -/* write the software state of maccontrol and overrides to the maccontrol register */ +/* + * write the software state of maccontrol and + * overrides to the maccontrol register + */ static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) { u32 maccontrol = wlc_hw->maccontrol; @@ -1418,7 +1446,10 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) brcms_c_ucode_txant_set(wlc_hw); - /* cwmin is band-specific, update hardware with value for current band */ + /* + * cwmin is band-specific, update hardware + * with value for current band + */ brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); @@ -1431,7 +1462,10 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); - /* initialize the txphyctl1 rate table since shmem is shared between bands */ + /* + * initialize the txphyctl1 rate table since + * shmem is shared between bands + */ brcms_upd_ofdm_pctl1_table(wlc_hw); brcms_b_upd_synthpu(wlc_hw); @@ -1590,7 +1624,10 @@ void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) wlc_hw->band = wlc_hw->bandstate[bandunit]; - /* BMAC_NOTE: until we eliminate need for wlc->band refs in low level code */ + /* + * BMAC_NOTE: + * until we eliminate need for wlc->band refs in low level code + */ wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; /* set gmode core flag */ @@ -1689,7 +1726,10 @@ bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) */ flags |= SICF_PCLKE; - /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ + /* + * AI chip doesn't restore bar0win2 on + * hibernation/resume, need sw fixup + */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) wlc_hw->regs = (struct d11regs *) @@ -1771,12 +1811,15 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) */ flags |= SICF_PCLKE; - /* reset the core - * In chips with PMU, the fastclk request goes through d11 core reg 0x1e0, which - * is cleared by the core_reset. have to re-request it. - * This adds some delay and we can optimize it by also requesting fastclk through - * chipcommon during this period if necessary. But that has to work coordinate - * with other driver like mips/arm since they may touch chipcommon as well. + /* + * reset the core + * In chips with PMU, the fastclk request goes through d11 core + * reg 0x1e0, which is cleared by the core_reset. have to re-request it. + * + * This adds some delay and we can optimize it by also requesting + * fastclk through chipcommon during this period if necessary. But + * that has to work coordinate with other driver like mips/arm since + * they may touch chipcommon as well. */ wlc_hw->clk = false; ai_core_reset(wlc_hw->sih, flags, resetbits); @@ -1948,7 +1991,10 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) ANTSEL_CLKDIV_4MHZ); } - /* gpio 9 controls the PA. ucode is responsible for wiggling out and oe */ + /* + * gpio 9 controls the PA. ucode is responsible + * for wiggling out and oe + */ if (wlc_hw->boardflags & BFL_PACTRL) gm |= gc |= BOARD_GPIO_PACTRL; @@ -2134,11 +2180,11 @@ void brcms_c_intrson(struct brcms_c_info *wlc) W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); } -/* callback for siutils.c, which has only wlc handler, no wl - * they both check up, not only because there is no need to off/restore d11 interrupt - * but also because per-port code may require sync with valid interrupt. +/* + * callback for siutils.c, which has only wlc handler, no wl they both check + * up, not only because there is no need to off/restore d11 interrupt but also + * because per-port code may require sync with valid interrupt. */ - static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc) { if (!wlc->hw->up) @@ -2203,9 +2249,10 @@ static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, wlc_hw->suspended_fifos |= fifo; if (wlc_hw->di[tx_fifo]) { - /* Suspending AMPDU transmissions in the middle can cause underflow - * which may result in mismatch between ucode and driver - * so suspend the mac before suspending the FIFO + /* + * Suspending AMPDU transmissions in the middle can cause + * underflow which may result in mismatch between ucode and + * driver so suspend the mac before suspending the FIFO */ if (BRCMS_PHY_11N_CAP(wlc_hw->band)) brcms_c_suspend_mac_and_wait(wlc_hw->wlc); @@ -2268,11 +2315,12 @@ static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, /* check that a suspend has been requested and is no longer pending */ /* - * for DMA mode, the suspend request is set in xmtcontrol of the DMA engine, - * and the tx fifo suspend at the lower end of the MAC is acknowledged in the - * chnstatus register. - * The tx fifo suspend completion is independent of the DMA suspend completion and - * may be acked before or after the DMA is suspended. + * for DMA mode, the suspend request is set in xmtcontrol of the DMA + * engine, and the tx fifo suspend at the lower end of the MAC is + * acknowledged in the chnstatus register. + * + * The tx fifo suspend completion is independent of the DMA suspend + * completion and may be acked before or after the DMA is suspended. */ if (dma_txsuspended(wlc_hw->di[tx_fifo]) && (R_REG(&wlc_hw->regs->chnstatus) & @@ -2709,8 +2757,10 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) "PHY PLL failed\n", __func__); } } else { - /* Since the PLL may be shared, other cores can still be requesting it; - * so we'll deassert the request but not wait for status to comply. + /* + * Since the PLL may be shared, other cores can still + * be requesting it; so we'll deassert the request but + * not wait for status to comply. */ AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); tmp = R_REG(®s->clk_ctl_st); @@ -2759,7 +2809,10 @@ static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) { BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); - /* dont power down if plldown is false or we must poll hw radio disable */ + /* + * dont power down if plldown is false or + * we must poll hw radio disable + */ if (!want && wlc_hw->pllreq) return; @@ -2942,7 +2995,9 @@ void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) wlc_hw->antsel_avail = antsel_avail; } -/* conditions under which the PM bit should be set in outgoing frames and STAY_AWAKE is meaningful +/* + * conditions under which the PM bit should be set in outgoing frames + * and STAY_AWAKE is meaningful */ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) { @@ -3259,7 +3314,8 @@ brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); /* - * initialize mac_suspend_depth to 1 to match ucode initial suspended state + * initialize mac_suspend_depth to 1 to match ucode + * initial suspended state */ wlc_hw->mac_suspend_depth = 1; @@ -3280,8 +3336,10 @@ void brcms_c_init(struct brcms_c_info *wlc) regs = wlc->regs; - /* This will happen if a big-hammer was executed. In that case, we want to go back - * to the channel that we were on and not new channel + /* + * This will happen if a big-hammer was executed. In + * that case, we want to go back to the channel that + * we were on and not new channel */ if (wlc->pub->associated) chanspec = wlc->home_chanspec; @@ -3341,7 +3399,10 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); - /* Update some shared memory locations related to max AMPDU size allowed to received */ + /* + * Update some shared memory locations related to + * max AMPDU size allowed to received + */ brcms_c_ampdu_shm_upd(wlc->ampdu); /* band-specific inits */ @@ -3412,9 +3473,11 @@ void brcms_c_mac_promisc(struct brcms_c_info *wlc) { u32 promisc_bits = 0; - /* promiscuous mode just sets MCTL_PROMISC - * Note: APs get all BSS traffic without the need to set the MCTL_PROMISC bit - * since all BSS data traffic is directed at the AP + /* + * promiscuous mode just sets MCTL_PROMISC + * Note: APs get all BSS traffic without the need to set + * the MCTL_PROMISC bit since all BSS data traffic is + * directed at the AP */ if (PROMISC_ENAB(wlc->pub) && !AP_ENAB(wlc->pub)) promisc_bits |= MCTL_PROMISC; @@ -3559,7 +3622,10 @@ static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc) return local; } -/* propagate home chanspec to all bsscfgs in case bsscfg->current_bss->chanspec is referenced */ +/* + * propagate home chanspec to all bsscfgs in + * case bsscfg->current_bss->chanspec is referenced + */ void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) { if (wlc->home_chanspec != chanspec) { @@ -3714,7 +3780,10 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, } } #if NCONF - /* pick siso/cdd as default for OFDM (note no basic rate MCSs are supported yet) */ + /* + * pick siso/cdd as default for OFDM (note no basic + * rate MCSs are supported yet) + */ if (IS_OFDM(lowest_basic_rspec)) lowest_basic_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); @@ -3723,8 +3792,9 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, return lowest_basic_rspec; } -/* This function changes the phytxctl for beacon based on current beacon ratespec AND txant - * setting as per this table: +/* + * This function changes the phytxctl for beacon based on current + * beacon ratespec AND txant setting as per this table: * ratespec CCK ant = wlc->stf->txant * OFDM ant = 3 */ @@ -3744,9 +3814,11 @@ void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, brcms_c_write_shm(wlc, M_BCN_PCTLWD, phyctl); } -/* centralized protection config change function to simplify debugging, no consistency checking - * this should be called only on changes to avoid overhead in periodic function -*/ +/* + * centralized protection config change function to simplify debugging, no + * consistency checking this should be called only on changes to avoid overhead + * in periodic function + */ void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) { BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); @@ -3833,11 +3905,14 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) */ if (wlc->home_chanspec == BRCMS_BAND_PI_RADIO_CHANSPEC) { if (wlc->pub->associated) { - /* BMAC_NOTE: This is something that should be fixed in ucode inits. - * I think that the ucode inits set up the bcn templates and shm values - * with a bogus beacon. This should not be done in the inits. If ucode needs - * to set up a beacon for testing, the test routines should write it down, - * not expect the inits to populate a bogus beacon. + /* + * BMAC_NOTE: This is something that should be fixed + * in ucode inits. I think that the ucode inits set + * up the bcn templates and shm values with a bogus + * beacon. This should not be done in the inits. If + * ucode needs to set up a beacon for testing, the + * test routines should write it down, not expect the + * inits to populate a bogus beacon. */ if (BRCMS_PHY_11N_CAP(wlc->band)) brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, @@ -3861,8 +3936,8 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); /* - * We might have been bandlocked during down and the chip power-cycled (hibernate). - * figure out the right band to park on + * We might have been bandlocked during down and the chip + * power-cycled (hibernate). Figure out the right band to park on */ if (wlc->bandlocked || NBANDS(wlc) == 1) { /* updated in brcms_c_bandlock() */ @@ -3939,7 +4014,10 @@ static void brcms_c_setband(struct brcms_c_info *wlc, brcms_c_bsinit(wlc); } -/* Initialize a WME Parameter Info Element with default STA parameters from WMM Spec, Table 12 */ +/* + * Initialize a WME Parameter Info Element with default + * STA parameters from WMM Spec, Table 12 + */ void brcms_c_wme_initparams_sta(struct brcms_c_info *wlc, struct wme_param_ie *pe) { @@ -4165,7 +4243,8 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->pub->_wme = AUTO; #ifdef BCMSDIODEV_ENABLED - wlc->pub->_priofc = true; /* enable priority flow control for sdio dongle */ + /* enable priority flow control for sdio dongle */ + wlc->pub->_priofc = true; #endif wlc->pub->_ampdu = AMPDU_AGG_HOST; @@ -4263,9 +4342,8 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, brcms_b_info_init(wlc_hw); /* - * Do the hardware portion of the attach. - * Also initialize software state that depends on the particular hardware - * we are running. + * Do the hardware portion of the attach. Also initialize software + * state that depends on the particular hardware we are running. */ wlc_hw->sih = ai_attach(regsva, bustype, btparam, &wlc_hw->vars, &wlc_hw->vars_size); @@ -4338,8 +4416,9 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, /* request fastclock and force fastclock for the rest of attach * bring the d11 core out of reset. - * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk is still false; - * But it will be called again inside wlc_corereset, after d11 is out of reset. + * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk + * is still false; But it will be called again inside wlc_corereset, + * after d11 is out of reset. */ brcms_b_clkctl_clk(wlc_hw, CLK_FAST); brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); @@ -4505,11 +4584,14 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, } good_phy: - /* BMAC_NOTE: wlc->band->pi should not be set below and should be done in the - * high level attach. However we can not make that change until all low level access - * is changed to wlc_hw->band->pi. Instead do the wlc->band->pi init below, keeping - * wlc_hw->band->pi as well for incremental update of low level fns, and cut over - * low only init when all fns updated. + /* + * BMAC_NOTE: wlc->band->pi should not be set below and should + * be done in the high level attach. However we can not make + * that change until all low level access is changed to + * wlc_hw->band->pi. Instead do the wlc->band->pi init below, + * keeping wlc_hw->band->pi as well for incremental update of + * low level fns, and cut over low only init when all fns + * updated. */ wlc->band->pi = wlc_hw->band->pi; wlc->band->phytype = wlc_hw->band->phytype; @@ -4541,7 +4623,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, /* turn off pll and xtal to match driver "down" state */ brcms_b_xtal(wlc_hw, OFF); - /* ********************************************************************* + /* ******************************************************************* * The hardware is in the DOWN state at this point. D11 core * or cores are in reset with clocks off, and the board PLLs * are off if possible. @@ -4630,8 +4712,10 @@ void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, if (err) goto fail; - /* for some states, due to different info pointer(e,g, wlc, wlc_hw) or master/slave split, - * HIGH driver(both monolithic and HIGH_ONLY) needs to sync states FROM BMAC portion driver + /* + * for some states, due to different info pointer(e,g, wlc, wlc_hw) or + * master/slave split, HIGH driver(both monolithic and HIGH_ONLY) needs + * to sync states FROM BMAC portion driver */ if (!brcms_c_state_bmac_sync(wlc)) { err = 20; @@ -4719,7 +4803,10 @@ void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, (bool) N_ENAB(wlc->pub)); } - /* update antenna config due to wlc->stf->txant/txchain/ant_rx_ovr change */ + /* + * update antenna config due to + * wlc->stf->txant/txchain/ant_rx_ovr change + */ brcms_c_stf_phy_txant_upd(wlc); /* attach each modules */ @@ -4847,14 +4934,17 @@ static void brcms_c_attach_antgain_init(struct brcms_c_info *wlc) } else { s8 gain, fract; /* Older sroms specified gain in whole dbm only. In order - * be able to specify qdbm granularity and remain backward compatible - * the whole dbms are now encoded in only low 6 bits and remaining qdbms - * are encoded in the hi 2 bits. 6 bit signed number ranges from - * -32 - 31. Examples: 0x1 = 1 db, + * be able to specify qdbm granularity and remain backward + * compatible the whole dbms are now encoded in only + * low 6 bits and remaining qdbms are encoded in the hi 2 bits. + * 6 bit signed number ranges from -32 - 31. + * + * Examples: + * 0x1 = 1 db, * 0xc1 = 1.75 db (1 + 3 quarters), * 0x3f = -1 (-1 + 0 quarters), - * 0x7f = -.75 (-1 in low 6 bits + 1 quarters in hi 2 bits) = -3 qdbm. - * 0xbf = -.50 (-1 in low 6 bits + 2 quarters in hi 2 bits) = -2 qdbm. + * 0x7f = -.75 (-1 + 1 quarters) = -3 qdbm. + * 0xbf = -.50 (-1 + 2 quarters) = -2 qdbm. */ gain = wlc->band->antgain & 0x3f; gain <<= 2; /* Sign extend */ @@ -4946,8 +5036,10 @@ int brcms_b_detach(struct brcms_c_info *wlc) callbacks = 0; if (wlc_hw->sih) { - /* detach interrupt sync mechanism since interrupt is disabled and per-port - * interrupt object may has been freed. this must be done before sb core switch + /* + * detach interrupt sync mechanism since interrupt is disabled + * and per-port interrupt object may has been freed. this must + * be done before sb core switch */ ai_deregister_intr_callback(wlc_hw->sih); @@ -5050,7 +5142,10 @@ static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); } -/* return true if Minimum Power Consumption should be entered, false otherwise */ +/* + * return true if Minimum Power Consumption should + * be entered, false otherwise + */ bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc) { return false; @@ -5082,9 +5177,10 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) } /* - * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in wlc->pub->radio_disabled - * to go ON, always call radio_upd synchronously - * to go OFF, postpone radio_upd to later when context is safe(e.g. watchdog) + * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in + * wlc->pub->radio_disabled to go ON, always call radio_upd + * synchronously to go OFF, postpone radio_upd to later when + * context is safe(e.g. watchdog) */ radio_state = (mboolisset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE) ? OFF : @@ -5102,9 +5198,11 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; wlc->mpc_dur += OSL_SYSUPTIME() - wlc->mpc_laston_ts; } - /* Below logic is meant to capture the transition from mpc off to mpc on for reasons - * other than wlc->mpc_delay_off keeping the mpc off. In that case reset - * wlc->mpc_delay_off to wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off + /* + * Below logic is meant to capture the transition from mpc off + * to mpc on for reasons other than wlc->mpc_delay_off keeping + * the mpc off. In that case reset wlc->mpc_delay_off to + * wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off */ if ((wlc->prev_non_delay_mpc == false) && (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) @@ -5128,8 +5226,10 @@ static void brcms_c_radio_upd(struct brcms_c_info *wlc) /* maintain LED behavior in down state */ static void brcms_c_down_led_upd(struct brcms_c_info *wlc) { - /* maintain LEDs while in down state, turn on sbclk if not available yet */ - /* turn on sbclk if necessary */ + /* + * maintain LEDs while in down state, turn on sbclk if + * not available yet. Turn on sbclk if necessary + */ if (!AP_ENAB(wlc->pub)) { brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); @@ -5142,7 +5242,8 @@ bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) { brcms_c_radio_hwdisable_upd(wlc); - return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? true : false; + return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? + true : false; } void brcms_c_radio_disable(struct brcms_c_info *wlc) @@ -5282,7 +5383,10 @@ static void brcms_c_watchdog(void *arg) brcms_b_watchdog(wlc); - /* occasionally sample mac stat counters to detect 16-bit counter wrap */ + /* + * occasionally sample mac stat counters to + * detect 16-bit counter wrap + */ if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) brcms_c_statsupd(wlc); @@ -5327,14 +5431,20 @@ void brcms_b_hw_up(struct brcms_hardware *wlc_hw) if (wlc_hw->sih->bustype == PCI_BUS) { ai_pci_fixcfg(wlc_hw->sih); - /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ + /* + * AI chip doesn't restore bar0win2 on + * hibernation/resume, need sw fixup + */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) wlc_hw->regs = (struct d11regs *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); } - /* Inform phy that a POR reset has occurred so it does a complete phy init */ + /* + * Inform phy that a POR reset has occurred so + * it does a complete phy init + */ wlc_phy_por_inform(wlc_hw->band->pi); wlc_hw->ucode_loaded = false; @@ -5373,8 +5483,9 @@ int brcms_b_up_prep(struct brcms_hardware *wlc_hw) ai_pci_setup(wlc_hw->sih, coremask); /* - * Need to read the hwradio status here to cover the case where the system - * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. + * Need to read the hwradio status here to cover the case where the + * system is loaded with the hw radio disabled. We do not want to + * bring the driver up in this case. */ if (brcms_b_radio_read_hwdisabled(wlc_hw)) { /* put SB PCI in down state again */ @@ -5432,10 +5543,11 @@ int brcms_c_up(struct brcms_c_info *wlc) } /* - * Need to read the hwradio status here to cover the case where the system - * is loaded with the hw radio disabled. We do not want to bring the driver up in this case. - * if radio is disabled, abort up, lower power, start radio timer and return 0(for NDIS) - * don't call radio_update to avoid looping brcms_c_up. + * Need to read the hwradio status here to cover the case where the + * system is loaded with the hw radio disabled. We do not want to bring + * the driver up in this case. If radio is disabled, abort up, lower + * power, start radio timer and return 0(for NDIS) don't call + * radio_update to avoid looping brcms_c_up. * * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only */ @@ -5513,14 +5625,18 @@ int brcms_c_up(struct brcms_c_info *wlc) return 0; } -/* Initialize the base precedence map for dequeueing from txq based on WME settings */ +/* + * Initialize the base precedence map for dequeueing + * from txq based on WME settings + */ static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc) { wlc->tx_prec_map = BRCMS_PREC_BMP_ALL; memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16)); - /* For non-WME, both fifos have overlapping MAXPRIO. So just disable all precedences - * if either is full. + /* + * For non-WME, both fifos have overlapping MAXPRIO. So just + * disable all precedences if either is full. */ if (!EDCF_ENAB(wlc->pub)) { wlc->fifo2prec_map[TX_DATA_FIFO] = BRCMS_PREC_BMP_ALL; @@ -5688,13 +5804,14 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) /* Default to 54g Auto */ /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ s8 shortslot = BRCMS_SHORTSLOT_AUTO; - bool shortslot_restrict = false; /* Restrict association to stations that support shortslot - */ + bool shortslot_restrict = false; /* Restrict association to stations + * that support shortslot + */ bool ofdm_basic = false; /* Make 6, 12, and 24 basic rates */ /* Advertise and use short preambles (-1/0/1 Auto/Off/On) */ int preamble = BRCMS_PLCP_LONG; - bool preamble_restrict = false; /* Restrict association to stations that support short - * preambles + bool preamble_restrict = false; /* Restrict association to stations + * that support short preambles */ struct brcms_band *band; @@ -5752,7 +5869,8 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) break; case GMODE_PERFORMANCE: - if (AP_ENAB(wlc->pub)) /* Put all rates into the Supported Rates element */ + if (AP_ENAB(wlc->pub)) + /* Put all rates into the Supported Rates element */ brcms_c_rateset_copy(&cck_ofdm_rates, &wlc->sup_rates_override); @@ -6281,7 +6399,10 @@ brcms_c_module_unregister(struct brcms_pub *pub, const char *name, void *hdl) return -ENODATA; } -/* Write WME tunable parameters for retransmit/max rate from wlc struct to ucode */ +/* + * Write WME tunable parameters for retransmit/max rate + * from wlc struct to ucode + */ static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) { int ac; @@ -6661,9 +6782,11 @@ void brcms_c_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, brcmu_pkt_buf_free_skb(sdu); } - /* Check if flow control needs to be turned on after enqueuing the packet - * Don't turn on flow control if EDCF is enabled. Driver would make the decision on what - * to drop instead of relying on stack to make the right decision + /* + * Check if flow control needs to be turned on after enqueuing the + * packet. Don't turn on flow control if EDCF is enabled. Driver + * would make the decision on what to drop instead of relying on + * stack to make the right decision */ if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { @@ -6686,7 +6809,10 @@ brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, struct scb *scb = &global_scb; struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); - /* 802.11 standard requires management traffic to go at highest priority */ + /* + * 802.11 standard requires management traffic + * to go at highest priority + */ prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : MAXPRIO; fifo = prio2fifo[prio]; @@ -6737,8 +6863,10 @@ void brcms_c_send_q(struct brcms_c_info *wlc) if (err == -EBUSY) { brcmu_pktq_penq_head(q, prec, pkt[0]); - /* If send failed due to any other reason than a change in - * HW FIFO condition, quit. Otherwise, read the new prec_map! + /* + * If send failed due to any other reason than a + * change in HW FIFO condition, quit. Otherwise, + * read the new prec_map! */ if (prec_map == wlc->tx_prec_map) break; @@ -6746,7 +6874,10 @@ void brcms_c_send_q(struct brcms_c_info *wlc) } } - /* Check if flow control needs to be turned off after sending the packet */ + /* + * Check if flow control needs to be turned off after + * sending the packet + */ if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) @@ -6794,8 +6925,8 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, txh = (struct d11txh *) (p->data); - /* When a BC/MC frame is being committed to the BCMC fifo via DMA (NOT PIO), update - * ucode or BSS info as appropriate. + /* When a BC/MC frame is being committed to the BCMC fifo + * via DMA (NOT PIO), update ucode or BSS info as appropriate. */ if (fifo == TX_BCMC_FIFO) frameid = le16_to_cpu(txh->TxFrameID); @@ -6804,8 +6935,9 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, brcms_c_war16165(wlc, true); - /* Bump up pending count for if not using rpc. If rpc is used, this will be handled - * in brcms_b_txfifo() + /* + * Bump up pending count for if not using rpc. If rpc is + * used, this will be handled in brcms_b_txfifo() */ if (commit) { TXPKTPENDINC(wlc, fifo, txpktpend); @@ -6842,9 +6974,9 @@ static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) if (RSPEC_IS40MHZ(rspec) || (mcs == 32)) plcp[0] |= MIMO_PLCP_40MHZ; BRCMS_SET_MIMO_PLCP_LEN(plcp, length); - plcp[3] = RSPEC_MIMOPLCP3(rspec); /* rspec already holds this byte */ - plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ - plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ + plcp[3] = RSPEC_MIMOPLCP3(rspec); /* rspec already holds this byte */ + plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ + plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ plcp[5] = 0; } @@ -6856,7 +6988,10 @@ brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) u32 tmp = 0; int rate = RSPEC2RATE(rspec); - /* encode rate per 802.11a-1999 sec 17.3.4.1, with lsb transmitted first */ + /* + * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb + * transmitted first + */ rate_signal = rate_info[rate] & BRCMS_RATE_MASK; memset(plcp, 0, D11_PHY_HDR_LEN); D11A_PHY_HDR_SRATE((struct ofdm_phy_hdr *) plcp, rate_signal); @@ -6904,8 +7039,9 @@ static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, break; default: - wiphy_err(wlc->wiphy, "brcms_c_cck_plcp_set: unsupported rate %d" - "\n", rate_500); + wiphy_err(wlc->wiphy, + "brcms_c_cck_plcp_set: unsupported rate %d\n", + rate_500); rate_500 = BRCM_RATE_1M; usec = length << 3; break; @@ -7036,8 +7172,11 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 << 8); } else if (IS_CCK(rspec) && !BRCMS_ISLCNPHY(wlc->band) && !BRCMS_ISSSLPNPHY(wlc->band)) { - /* In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate */ - /* Eventually MIMOPHY would also be converted to this format */ + /* + * In CCK mode LPPHY overloads OFDM Modulation bits with CCK + * Data Rate. Eventually MIMOPHY would also be converted to + * this format + */ /* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ phyctl1 = (bw | (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); } else { /* legacy OFDM/CCK */ @@ -7070,8 +7209,9 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, /* Use 11Mbps as the g protection RTS target rate and fallback. * Use the BRCMS_BASIC_RATE() lookup to find the best basic rate * under the target in case 11 Mbps is not Basic. - * 6 and 9 Mbps are not usually selected by rate selection, but even - * if the OFDM rate we are protecting is 6 or 9 Mbps, 11 is more robust. + * 6 and 9 Mbps are not usually selected by rate selection, but + * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 + * is more robust. */ rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); else @@ -7085,8 +7225,9 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, /* set rts txbw to correct side band */ rts_rspec &= ~RSPEC_BW_MASK; - /* if rspec/rspec_fallback is 40MHz, then send RTS on both 20MHz channel - * (DUP), otherwise send RTS on control channel + /* + * if rspec/rspec_fallback is 40MHz, then send RTS on both + * 20MHz channel (DUP), otherwise send RTS on control channel */ if (RSPEC_IS40MHZ(rspec) && !IS_CCK(rts_rspec)) rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT); @@ -7206,7 +7347,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, txrate[0] = tx_info->control.rates; txrate[1] = txrate[0] + 1; - /* if rate control algorithm didn't give us a fallback rate, use the primary rate */ + /* + * if rate control algorithm didn't give us a fallback + * rate, use the primary rate + */ if (txrate[1]->idx < 0) txrate[1] = txrate[0]; @@ -7231,8 +7375,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, rate_val[k] = txrate[k]->idx; } - /* Currently only support same setting for primay and fallback rates. - * Unify flags for each rate into a single value for the frame + /* + * Currently only support same setting for primay and + * fallback rates. Unify flags for each rate into a + * single value for the frame */ use_rts |= txrate[k]-> @@ -7246,7 +7392,11 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, rate_val[k]); - /* (1) RATE: determine and validate primary rate and fallback rates */ + /* + * (1) RATE: + * determine and validate primary rate + * and fallback rates + */ if (!RSPEC_ACTIVE(rspec[k])) { rspec[k] = BRCM_RATE_1M; } else { @@ -7262,7 +7412,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (N_ENAB(wlc->pub)) { for (k = 0; k < hw->max_rates; k++) { - /* apply siso/cdd to single stream mcs's or ofdm if rspec is auto selected */ + /* + * apply siso/cdd to single stream mcs's or ofdm + * if rspec is auto selected + */ if (((IS_MCS(rspec[k]) && IS_SINGLE_STREAM(rspec[k] & RSPEC_RATE_MASK)) || IS_OFDM(rspec[k])) @@ -7275,17 +7428,20 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, && BRCMS_STF_SS_STBC_TX(wlc, scb)) { u8 stc; - stc = 1; /* Nss for single stream is always 1 */ - rspec[k] |= - (PHY_TXC1_MODE_STBC << - RSPEC_STF_SHIFT) | (stc << - RSPEC_STC_SHIFT); + /* Nss for single stream is always 1 */ + stc = 1; + rspec[k] |= (PHY_TXC1_MODE_STBC << + RSPEC_STF_SHIFT) | + (stc << RSPEC_STC_SHIFT); } else rspec[k] |= (phyctl1_stf << RSPEC_STF_SHIFT); } - /* Is the phy configured to use 40MHZ frames? If so then pick the desired txbw */ + /* + * Is the phy configured to use 40MHZ frames? If + * so then pick the desired txbw + */ if (CHSPEC_WLC_BW(wlc->chanspec) == BRCMS_40_MHZ) { /* default txbw is 20in40 SB */ mimo_ctlchbw = mimo_txbw = @@ -7294,7 +7450,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (IS_MCS(rspec[k])) { /* mcs 32 must be 40b/w DUP */ - if ((rspec[k] & RSPEC_RATE_MASK) == 32) { + if ((rspec[k] & RSPEC_RATE_MASK) + == 32) { mimo_txbw = PHY_TXC1_BW_40MHZ_DUP; /* use override */ @@ -7310,8 +7467,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, mimo_txbw = wlc->cck_40txbw; } } else { - /* mcs32 is 40 b/w only. - * This is possible for probe packets on a STA during SCAN + /* + * mcs32 is 40 b/w only. + * This is possible for probe packets on + * a STA during SCAN */ if ((rspec[k] & RSPEC_RATE_MASK) == 32) /* mcs 0 */ @@ -7352,7 +7511,10 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (IS_MCS(rspec[k])) { preamble_type[k] = mimo_preamble_type; - /* if SGI is selected, then forced mm for single stream */ + /* + * if SGI is selected, then forced mm + * for single stream + */ if ((rspec[k] & RSPEC_SHORT_GI) && IS_SINGLE_STREAM(rspec[k] & RSPEC_RATE_MASK)) @@ -7476,12 +7638,14 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* TxFrameID */ txh->TxFrameID = cpu_to_le16(frameid); - /* TxStatus, Note the case of recreating the first frag of a suppressed frame - * then we may need to reset the retry cnt's via the status reg + /* + * TxStatus, Note the case of recreating the first frag of a suppressed + * frame then we may need to reset the retry cnt's via the status reg */ txh->TxStatus = cpu_to_le16(status); - /* extra fields for ucode AMPDU aggregation, the new fields are added to + /* + * extra fields for ucode AMPDU aggregation, the new fields are added to * the END of previous structure so that it's compatible in driver. */ txh->MaxNMpdus = cpu_to_le16(0); @@ -7590,10 +7754,16 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, #endif - /* Now that RTS/RTS FB preamble types are updated, write the final value */ + /* + * Now that RTS/RTS FB preamble types are updated, write + * the final value + */ txh->MacTxControlHigh = cpu_to_le16(mch); - /* MainRates (both the rts and frag plcp rates have been calculated now) */ + /* + * MainRates (both the rts and frag plcp rates have + * been calculated now) + */ txh->MainRates = cpu_to_le16(mainrates); /* XtraFrameTypes */ @@ -7633,9 +7803,9 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } /* - * For mcs frames, if mixedmode(overloaded with long preamble) is going to be set, - * fill in non-zero MModeLen and/or MModeFbrLen - * it will be unnecessary if they are separated + * For mcs frames, if mixedmode(overloaded with long preamble) + * is going to be set, fill in non-zero MModeLen and/or + * MModeFbrLen it will be unnecessary if they are separated */ if (IS_MCS(rspec[0]) && (preamble_type[0] == BRCMS_MM_PREAMBLE)) { @@ -7657,7 +7827,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, uint frag_dur, dur, dur_fallback; /* WME: Update TXOP threshold */ - if ((!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) && (frag == 0)) { + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { frag_dur = brcms_c_calc_frame_time(wlc, rspec[0], preamble_type[0], phylen); @@ -7694,11 +7864,17 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } /* NEED to set TxFesTimeNormal (hard) */ txh->TxFesTimeNormal = cpu_to_le16((u16) dur); - /* NEED to set fallback rate version of TxFesTimeNormal (hard) */ + /* + * NEED to set fallback rate version of + * TxFesTimeNormal (hard) + */ txh->TxFesTimeFallback = cpu_to_le16((u16) dur_fallback); - /* update txop byte threshold (txop minus intraframe overhead) */ + /* + * update txop byte threshold (txop minus intraframe + * overhead) + */ if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { uint newfragthresh; @@ -7745,7 +7921,10 @@ void brcms_c_tbtt(struct brcms_c_info *wlc) struct brcms_bss_cfg *cfg = wlc->cfg; if (!cfg->BSS) - /* DirFrmQ is now valid...defer setting until end of ATIM window */ + /* + * DirFrmQ is now valid...defer setting until end + * of ATIM window + */ wlc->qvalid |= MCMD_DIRFRMQVAL; } @@ -7780,12 +7959,13 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) struct ieee80211_tx_rate *txrate; int i; - (void)(frm_tx2); /* Compiler reference to avoid unused variable warning */ + /* Compiler reference to avoid unused variable warning */ + (void)(frm_tx2); /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, but the subsequent - * tx of DATA failed. so it will start rts/cts from the beginning (resetting the rts - * transmission count) + * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, + * but the subsequent tx of DATA failed. so it will start rts/cts + * from the beginning (resetting the rts transmission count) */ if (!(txs->status & TX_STATUS_AMPDU) && (txs->status & TX_STATUS_INTERMEDIATE)) { @@ -7877,13 +8057,22 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) ieee80211_tx_info_clear_status(tx_info); if ((tx_frame_count > fbl) && (txrate[1].idx >= 0)) { - /* rate selection requested a fallback rate and we used it */ + /* + * rate selection requested a fallback rate + * and we used it + */ txrate[0].count = fbl; txrate[1].count = tx_frame_count - fbl; } else { - /* rate selection did not request fallback rate, or we didn't need it */ + /* + * rate selection did not request fallback rate, or + * we didn't need it + */ txrate[0].count = tx_frame_count; - /* rc80211_minstrel.c:minstrel_tx_status() expects unused rates to be marked with idx = -1 */ + /* + * rc80211_minstrel.c:minstrel_tx_status() expects + * unused rates to be marked with idx = -1 + */ txrate[1].idx = -1; txrate[1].count = 0; } @@ -8035,11 +8224,12 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, rx_status->freq = ieee80211_dsss_chan_to_freq(channel); } - rx_status->signal = wlc_rxh->rssi; /* signal */ + rx_status->signal = wlc_rxh->rssi; /* noise */ /* qual */ - rx_status->antenna = (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; /* ant */ + rx_status->antenna = + (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; plcp = p->data; @@ -8253,14 +8443,16 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, /* MCS_TXS(mcs) returns num tx streams - 1 */ int tot_streams = (MCS_TXS(mcs) + 1) + RSPEC_STC(ratespec); - /* the payload duration calculation matches that of regular ofdm */ + /* + * the payload duration calculation matches that + * of regular ofdm + */ /* 1000Ndbps = kbps * 4 */ kNdps = MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), RSPEC_ISSGI(ratespec)) * 4; if (RSPEC_STC(ratespec) == 0) - /* NSyms = CEILING((SERVICE + 8*NBytes + TAIL) / Ndbps) */ nsyms = CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS) * 1000, kNdps); @@ -8271,15 +8463,22 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS) * 1000, 2 * kNdps); - nsyms += (tot_streams + 3); /* (+3) account for HT-SIG(2) and HT-STF(1) */ - /* 3 bytes/symbol @ legacy 6Mbps rate */ - len = (3 * nsyms) - 3; /* (-3) excluding service bits and tail bits */ + /* (+3) account for HT-SIG(2) and HT-STF(1) */ + nsyms += (tot_streams + 3); + /* + * 3 bytes/symbol @ legacy 6Mbps rate + * (-3) excluding service bits and tail bits + */ + len = (3 * nsyms) - 3; } return (u16) len; } -/* calculate frame duration of a given rate and length, return time in usec unit */ +/* + * calculate frame duration of a given rate and length, return + * time in usec unit + */ uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, u8 preamble_type, uint mac_len) @@ -8309,7 +8508,6 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, RSPEC_ISSGI(ratespec)) * 4; if (RSPEC_STC(ratespec) == 0) - /* NSyms = CEILING((SERVICE + 8*NBytes + TAIL) / Ndbps) */ nsyms = CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS) * 1000, kNdps); @@ -8336,7 +8534,10 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, if (BAND_2G(wlc->band->bandtype)) dur += DOT11_OFDM_SIGNAL_EXTENSION; } else { - /* calc # bits * 2 so factor of 2 in rate (1/2 mbps) will divide out */ + /* + * calc # bits * 2 so factor of 2 in rate (1/2 mbps) + * will divide out + */ mac_len = mac_len * 8 * 2; /* calc ceiling of bits/rate = microseconds of air time */ dur = (mac_len + rate - 1) / rate; @@ -8401,8 +8602,10 @@ brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, { BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, " "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type); - /* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that is less than - * or equal to the rate of the immediately previous frame in the FES + /* + * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that + * is less than or equal to the rate of the immediately previous + * frame in the FES */ rspec = BRCMS_BASIC_RATE(wlc, rspec); /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ @@ -8419,8 +8622,10 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n", wlc->pub->unit, rspec, preamble_type); - /* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that is less than - * or equal to the rate of the immediately previous frame in the FES + /* + * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that + * is less than or equal to the rate of the immediately previous + * frame in the FES */ rspec = BRCMS_BASIC_RATE(wlc, rspec); /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ @@ -8515,7 +8720,10 @@ void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, continue; if (IS_OFDM(rate)) { - /* In 11g and 11a, the OFDM mandatory rates are 6, 12, and 24 Mbps */ + /* + * In 11g and 11a, the OFDM mandatory rates + * are 6, 12, and 24 Mbps + */ if (rate >= BRCM_RATE_24M) mandatory = BRCM_RATE_24M; else if (rate >= BRCM_RATE_12M) @@ -8523,7 +8731,7 @@ void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, else mandatory = BRCM_RATE_6M; } else { - /* In 11b, all the CCK rates are mandatory 1 - 11 Mbps */ + /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ mandatory = rate; } @@ -8691,7 +8899,10 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) brcms_c_rateset_copy(rs_dflt, &rs); brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); - /* walk the phy rate table and update MAC core SHM basic rate table entries */ + /* + * walk the phy rate table and update MAC core SHM + * basic rate table entries + */ for (i = 0; i < rs.count; i++) { rate = rs.rates[i] & BRCMS_RATE_MASK; @@ -8700,7 +8911,10 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) /* Calculate the Probe Response PLCP for the given rate */ brcms_c_compute_plcp(wlc, rate, frame_len, plcp); - /* Calculate the duration of the Probe Response frame plus SIFS for the MAC */ + /* + * Calculate the duration of the Probe Response + * frame plus SIFS for the MAC + */ dur = (u16) brcms_c_calc_frame_time(wlc, rate, BRCMS_LONG_PREAMBLE, frame_len); dur += sifs; @@ -8723,8 +8937,8 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) * * *len on input contains the max length of the packet available. * - * The *len value is set to the number of bytes in buf used, and starts with the PLCP - * and included up to, but not including, the 4 byte FCS. + * The *len value is set to the number of bytes in buf used, and starts + * with the PLCP and included up to, but not including, the 4 byte FCS. */ static void brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, @@ -8740,16 +8954,21 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, hdr_len = DOT11_MAC_HDR_LEN; else hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN; - body_len = *len - hdr_len; /* calc buffer size provided for frame body */ - *len = hdr_len + body_len; /* return actual size */ + /* calc buffer size provided for frame body */ + body_len = *len - hdr_len; + /* return actual size */ + *len = hdr_len + body_len; /* format PHY and MAC headers */ memset((char *)buf, 0, hdr_len); plcp = (struct cck_phy_hdr *) buf; - /* PLCP for Probe Response frames are filled in from core's rate table */ + /* + * PLCP for Probe Response frames are filled in from + * core's rate table + */ if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) /* fill in PLCP */ brcms_c_compute_plcp(wlc, bcn_rspec, @@ -8807,10 +9026,11 @@ brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, } } -/* Update a beacon for a particular BSS - * For MBSS, this updates the software template and sets "latest" to the index of the - * template updated. - * Otherwise, it updates the hardware template. +/* + * Update a beacon for a particular BSS + * For MBSS, this updates the software template and sets "latest" to + * the index of the template updated. Otherwise, it updates the hardware + * template. */ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) @@ -8907,7 +9127,10 @@ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, u16 prb_resp[BCN_TMPL_LEN / 2]; int len = BCN_TMPL_LEN; - /* write the probe response to hardware, or save in the config structure */ + /* + * write the probe response to hardware, or save in + * the config structure + */ if (!MBSS_PRB_ENAB(cfg)) { /* create the probe response template */ @@ -8928,17 +9151,18 @@ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, brcms_c_shm_ssid_upd(wlc, cfg); /* - * Write PLCP headers and durations for probe response frames at all rates. - * Use the actual frame length covered by the PLCP header for the call to - * brcms_c_mod_prb_rsp_rate_table() by subtracting the PLCP len - * and adding the FCS. + * Write PLCP headers and durations for probe response frames + * at all rates. Use the actual frame length covered by the + * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table() + * by subtracting the PLCP len and adding the FCS. */ len += (-D11_PHY_HDR_LEN + FCS_LEN); brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len); if (suspend) brcms_c_enable_mac(wlc); - } else { /* Generating probe resp in sw; update local template */ + } else { + /* Generating probe resp in sw; update local template */ /* error: No software probe response support without MBSS */ } } @@ -9076,7 +9300,10 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, stf = PHY_TXC1_MODE_SDM; } } else { - /* MCS 0-7 may use SISO, CDD, and for phy_rev >= 3 STBC */ + /* + * MCS 0-7 may use SISO, CDD, and for + * phy_rev >= 3 STBC + */ if ((stf > PHY_TXC1_MODE_STBC) || (!BRCMS_STBC_CAP_PHY(wlc) && (stf == PHY_TXC1_MODE_STBC))) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index e797bf09cb5..0fd061b02b9 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -49,8 +49,7 @@ /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */ #define BRCMS_MAX_MAC_SUSPEND 83000 -/* Probe Response timeout - responses for probe requests older that this are tossed, zero to disable - */ +/* responses for probe requests older that this are tossed, zero to disable */ #define BRCMS_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */ /* transmit buffer max headroom for protocol headers */ @@ -123,7 +122,9 @@ #define BOARDREV_PROMOTABLE 0xFF /* from */ #define BOARDREV_PROMOTED 1 /* to */ -/* if wpa is in use then portopen is true when the group key is plumbed otherwise it is always true +/* + * if wpa is in use then portopen is true when the + * group key is plumbed otherwise it is always true */ #define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED)) #define BRCMS_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \ @@ -163,13 +164,13 @@ extern const u8 prio2fifo[]; #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ #define RETRY_LONG_DEF 4 /* Default Long retry count */ -#define RETRY_SHORT_FB 3 /* Short retry count for fallback rate */ -#define RETRY_LONG_FB 2 /* Long retry count for fallback rate */ +#define RETRY_SHORT_FB 3 /* Short count for fallback rate */ +#define RETRY_LONG_FB 2 /* Long count for fallback rate */ #define MAXTXPKTS 6 /* max # pkts pending */ /* frameburst */ -#define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */ +#define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */ #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */ /* Per-AC retry limit register definitions; uses defs.h bitfield macros */ @@ -228,11 +229,12 @@ extern const u8 prio2fifo[]; /* * Detect Card removed. - * Even checking an sbconfig register read will not false trigger when the core is in reset. - * it breaks CF address mechanism. Accessing gphy phyversion will cause SB error if aphy - * is in reset on 4306B0-DB. Need a simple accessible reg with fixed 0/1 pattern - * (some platforms return all 0). - * If clocks are present, call the sb routine which will figure out if the device is removed. + * Even checking an sbconfig register read will not false trigger when the core + * is in reset it breaks CF address mechanism. Accessing gphy phyversion will + * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible + * reg with fixed 0/1 pattern (some platforms return all 0). + * If clocks are present, call the sb routine which will figure out if the + * device is removed. */ #define DEVICEREMOVED(wlc) \ ((wlc->hw->clk) ? \ @@ -248,52 +250,81 @@ extern const u8 prio2fifo[]; #define brcms_b_copyto_shm(wlc_hw, offset, buf, len) \ brcms_b_copyto_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) +/* + * 802.11 protection information + * + * _g: use g spec protection, driver internal. + * g_override: override for use of g spec protection. + * gmode_user: user config gmode, operating band->gmode is different. + * overlap: Overlap BSS/IBSS protection for both 11g and 11n. + * nmode_user: user config nmode, operating pub->nmode is different. + * n_cfg: use OFDM protection on MIMO frames. + * n_cfg_override: override for use of N protection. + * nongf: non-GF present protection. + * nongf_override: override for use of GF protection. + * n_pam_override: override for preamble: MM or GF. + * n_obss: indicated OBSS Non-HT STA present. +*/ struct brcms_protection { - bool _g; /* use g spec protection, driver internal */ - s8 g_override; /* override for use of g spec protection */ - u8 gmode_user; /* user config gmode, operating band->gmode is different */ - s8 overlap; /* Overlap BSS/IBSS protection for both 11g and 11n */ - s8 nmode_user; /* user config nmode, operating pub->nmode is different */ - s8 n_cfg; /* use OFDM protection on MIMO frames */ - s8 n_cfg_override; /* override for use of N protection */ - bool nongf; /* non-GF present protection */ - s8 nongf_override; /* override for use of GF protection */ - s8 n_pam_override; /* override for preamble: MM or GF */ - bool n_obss; /* indicated OBSS Non-HT STA present */ + bool _g; + s8 g_override; + u8 gmode_user; + s8 overlap; + s8 nmode_user; + s8 n_cfg; + s8 n_cfg_override; + bool nongf; + s8 nongf_override; + s8 n_pam_override; + bool n_obss; }; -/* anything affects the single/dual streams/antenna operation */ +/* + * anything affecting the single/dual streams/antenna operation + * + * hw_txchain: HW txchain bitmap cfg. + * txchain: txchain bitmap being used. + * txstreams: number of txchains being used. + * hw_rxchain: HW rxchain bitmap cfg. + * rxchain: rxchain bitmap being used. + * rxstreams: number of rxchains being used. + * ant_rx_ovr: rx antenna override. + * txant: userTx antenna setting. + * phytxant: phyTx antenna setting in txheader. + * ss_opmode: singlestream Operational mode, 0:siso; 1:cdd. + * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel; + * else use wlc->band->stf->ss_mode_band. + * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC. + * no_cddstbc: stf override, 1: no CDD (or STBC) allowed. + * rxchain_restore_delay: delay time to restore default rxchain. + * ldpc: AUTO/ON/OFF ldpc cap supported. + * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts. + * spatial_policy: + */ struct brcms_stf { - u8 hw_txchain; /* HW txchain bitmap cfg */ - u8 txchain; /* txchain bitmap being used */ - u8 txstreams; /* number of txchains being used */ - - u8 hw_rxchain; /* HW rxchain bitmap cfg */ - u8 rxchain; /* rxchain bitmap being used */ - u8 rxstreams; /* number of rxchains being used */ - - u8 ant_rx_ovr; /* rx antenna override */ - s8 txant; /* userTx antenna setting */ - u16 phytxant; /* phyTx antenna setting in txheader */ - - u8 ss_opmode; /* singlestream Operational mode, 0:siso; 1:cdd */ - bool ss_algosel_auto; /* if true, use wlc->stf->ss_algo_channel; */ - /* else use wlc->band->stf->ss_mode_band; */ - u16 ss_algo_channel; /* ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC */ - u8 no_cddstbc; /* stf override, 1: no CDD (or STBC) allowed */ - - u8 rxchain_restore_delay; /* delay time to restore default rxchain */ - - s8 ldpc; /* AUTO/ON/OFF ldpc cap supported */ - u8 txcore[MAX_STREAMS_SUPPORTED + 1]; /* bitmap of selected core for each Nsts */ + u8 hw_txchain; + u8 txchain; + u8 txstreams; + u8 hw_rxchain; + u8 rxchain; + u8 rxstreams; + u8 ant_rx_ovr; + s8 txant; + u16 phytxant; + u8 ss_opmode; + bool ss_algosel_auto; + u16 ss_algo_channel; + u8 no_cddstbc; + u8 rxchain_restore_delay; + s8 ldpc; + u8 txcore[MAX_STREAMS_SUPPORTED + 1]; s8 spatial_policy; }; #define BRCMS_STF_SS_STBC_TX(wlc, scb) \ - (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) || \ - (SCB_STBC_CAP((scb)) && \ - (wlc)->band->band_stf_stbc_tx == AUTO && \ - isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC)))) + (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \ + || (SCB_STBC_CAP((scb)) && (wlc)->band->band_stf_stbc_tx == AUTO && \ + isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC)))) #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \ NREV_GE(wlc->band->phyrev, 3)) @@ -312,9 +343,12 @@ struct brcms_stf { #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ /* Flags used in brcms_c_txq_info.stopped */ -#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF /* per prio flow control bits */ -#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 /* stop txq enqueue for packet drain */ -#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 /* stop txq enqueue for ampdu flow control */ +/* per prio flow control bits */ +#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF +/* stop txq enqueue for packet drain */ +#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 +/* stop txq enqueue for ampdu flow control */ +#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 #define BRCMS_HT_WEP_RESTRICT 0x01 /* restrict HT with WEP */ #define BRCMS_HT_TKIP_RESTRICT 0x02 /* restrict HT with TKIP */ @@ -322,8 +356,8 @@ struct brcms_stf { /* Maximum # of keys that wl driver supports in S/W. * Keys supported in H/W is less than or equal to WSEC_MAX_KEYS. */ -#define WSEC_MAX_KEYS 54 /* Max # of keys (50 + 4 default keys) */ -#define BRCMS_DEFAULT_KEYS 4 /* Default # of keys */ +#define WSEC_MAX_KEYS 54 /* Max # of keys (50 + 4 default keys) */ +#define BRCMS_DEFAULT_KEYS 4 /* Default # of keys */ /* * Max # of keys currently supported: @@ -347,14 +381,14 @@ struct wsec_key { u8 ea[ETH_ALEN]; /* per station */ u8 idx; /* key index in wsec_keys array */ u8 id; /* key ID [0-3] */ - u8 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ - u8 rcmta; /* rcmta entry index, same as idx by default */ - u16 flags; /* misc flags */ - u8 algo_hw; /* cache for hw register */ - u8 aes_mode; /* cache for hw register */ - s8 iv_len; /* IV length */ - s8 icv_len; /* ICV length */ - u32 len; /* key length..don't move this var */ + u8 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ + u8 rcmta; /* rcmta entry index, same as idx by default */ + u16 flags; /* misc flags */ + u8 algo_hw; /* cache for hw register */ + u8 aes_mode; /* cache for hw register */ + s8 iv_len; /* IV length */ + s8 icv_len; /* ICV length */ + u32 len; /* key length..don't move this var */ /* data is 4byte aligned */ u8 data[WLAN_MAX_KEY_LEN]; /* key data */ struct wsec_iv rxiv[BRCMS_NUMRXIVS]; /* Rx IV (one per TID) */ @@ -405,8 +439,8 @@ struct brcms_band { bool mimo_cap_40; /* 40 MHz cap enabled on this band */ s8 antgain; /* antenna gain from srom */ - u16 CWmin; /* The minimum size of contention window, in unit of aSlotTime */ - u16 CWmax; /* The maximum size of contention window, in unit of aSlotTime */ + u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */ + u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */ u16 bcntsfoff; /* beacon tsf offset */ }; @@ -422,10 +456,14 @@ struct pkt_cb { /* module control blocks */ struct modulecb { - char name[32]; /* module name : NULL indicates empty array member */ - const struct brcmu_iovar *iovars; /* iovar table */ - void *hdl; /* handle passed when handler 'doiovar' is called */ - int (*watchdog_fn)(void *handle); /* watchdog handler */ + /* module name : NULL indicates empty array member */ + char name[32]; + /* iovar table */ + const struct brcmu_iovar *iovars; + /* handle passed when handler 'doiovar' is called */ + void *hdl; + /* watchdog handler */ + int (*watchdog_fn)(void *handle); /* IOVar handler * @@ -483,11 +521,11 @@ struct wme_param_ie { /* virtual interface */ struct brcms_c_if { struct brcms_c_if *next; - u8 type; /* BSS or WDS */ - u8 index; /* assigned in wl_add_if(), index of the wlif if any, - * not necessarily corresponding to bsscfg._idx or - * AID2PVBMAP(scb). - */ + u8 type; /* BSS or WDS */ + u8 index; /* assigned in wl_add_if(), index of the wlif if any, + * not necessarily corresponding to bsscfg._idx or + * AID2PVBMAP(scb). + */ u8 flags; /* flags for the interface */ struct brcms_if *wlif; /* pointer to wlif */ struct brcms_txq_info *qi; /* pointer to associated tx queue */ @@ -569,12 +607,12 @@ struct brcms_hardware { u8 suspended_fifos; /* Which TX fifo to remain awake for */ u32 maccontrol; /* Cached value of maccontrol */ uint mac_suspend_depth; /* current depth of mac_suspend levels */ - u32 wake_override; /* Various conditions to force MAC to WAKE mode */ + u32 wake_override; /* bit flags to force MAC to WAKE mode */ u32 mute_override; /* Prevent ucode from sending beacons */ u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */ u32 led_gpio_mask; /* LED GPIO Mask */ bool noreset; /* true= do not reset hw, used by WLC_OUT */ - bool forcefastclk; /* true if the h/w is forcing the use of fast clk */ + bool forcefastclk; /* true if h/w is forcing to use fast clk */ bool clk; /* core is out of reset and has clock */ bool sbclk; /* sb has clock */ struct bmac_pmq *bmac_pmq; /* bmac PM states derived from ucode PMQ */ @@ -608,192 +646,267 @@ struct brcms_txq_info { }; /* - * Principal common (os-independent) software data structure. + * Principal common driver data structure. + * + * pub: pointer to driver public state. + * wl: pointer to specific private state. + * regs: pointer to device registers. + * hw: HW related state. + * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1. + * fastpwrup_dly: time in us needed to bring up d11 fast clock. + * macintstatus: bit channel between isr and dpc. + * macintmask: sw runtime master macintmask value. + * defmacintmask: default "on" macintmask value. + * device_present: (removable) device is present. + * clk: core is out of reset and has clock. + * core: pointer to active io core. + * band: pointer to active per-band state. + * corestate: per-core state (one per hw core). + * bandstate: per-band state (one per phy/radio). + * war16165: PCI slow clock 16165 war flag. + * tx_suspended: data fifos need to remain suspended. + * txpend16165war: PCI slow clock 16165 war flag. + * qvalid: DirFrmQValid and BcMcFrmQValid. + * txpwr_local_max: regulatory local txpwr max. + * txpwr_local_constraint: local power contraint in dB. + * ampdu: ampdu module handler. + * asi: antsel module handler. + * cmi: channel manager module handler. + * vars_size: size of vars, free vars on detach. + * vendorid: PCI vendor id. + * deviceid: PCI device id. + * ucode_rev: microcode revision. + * machwcap: MAC capabilities, BMAC shadow. + * perm_etheraddr: original sprom local ethernet address. + * bandlocked: disable auto multi-band switching. + * bandinit_pending: track band init in auto band. + * radio_monitor: radio timer is running. + * going_down: down path intermediate variable. + * mpc: enable minimum power consumption. + * mpc_dlycnt: # of watchdog cnt before turn disable radio. + * mpc_offcnt: # of watchdog cnt that radio is disabled. + * mpc_delay_off: delay radio disable by # of watchdog cnt. + * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc. + * wdtimer: timer for watchdog routine. + * radio_timer: timer for hw radio button monitor routine. + * monitor: monitor (MPDU sniffing) mode. + * bcnmisc_ibss: bcns promisc mode override for IBSS. + * bcnmisc_scan: bcns promisc mode override for scan. + * bcnmisc_monitor: bcns promisc mode override for monitor. + * _rifs: enable per-packet rifs. + * sgi_tx: sgi tx. + * bcn_li_bcn: beacon listen interval in # beacons. + * bcn_li_dtim: beacon listen interval in # dtims. + * WDarmed: watchdog timer is armed. + * WDlast: last time wlc_watchdog() was called. + * wme_dp: AC bitmap. Discard (oldest first) policy per AC. + * edcf_txop[AC_COUNT]: current txop for each ac. + * wme_param_ie: on STA contains parameters in use locally, and on AP + * contains parameters advertised + * wme_retries: per-AC retry limits. + * tx_prec_map: Precedence map based on HW FIFO space. + * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. + * bsscfg: set of BSS configurations, idx 0 is default and always valid. + * cfg: the primary bsscfg (can be AP or STA). + * tx_queues: common TX Queue list. + * wsec_keys[WSEC_MAX_KEYS]: dynamic key storage. + * wsec_def_keys[BRCMS_DEFAULT_KEYS]: default key storage. + * wsec_swkeys: indicates that all keys should be treated as + * sw keys (used for debugging). + * modulecb: + * mimoft: SIGN or 11N. + * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode. + * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode. + * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode. + * ht_cap: HT CAP IE being advertised by this node. + * default_bss: configured BSS parameters. + * mc_fid_counter: BC/MC FIFO frame ID counter. + * country_default: saved country for leaving 802.11d auto-country mode. + * autocountry_default: initial country for 802.11d auto-country mode. + * prb_resp_timeout: do not send prb resp if request older + * than this, 0 = disable. + * sup_rates_override: use only these rates in 11g supported rates if specified. + * home_chanspec: shared home chanspec. + * chanspec: target operational channel. + * usr_fragthresh: user configured fragmentation threshold. + * fragthresh[NFIFO]: per-fifo fragmentation thresholds. + * RTSThresh: 802.11 dot11RTSThreshold. + * SRL: 802.11 dot11ShortRetryLimit. + * LRL: 802.11 dot11LongRetryLimit. + * SFBL: Short Frame Rate Fallback Limit. + * LFBL: Long Frame Rate Fallback Limit. + * shortslot: currently using 11g ShortSlot timing. + * shortslot_override: 11g ShortSlot override. + * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42. + * PLCPHdr_override: 802.11b Preamble Type override. + * stf: + * bcn_rspec: save bcn ratespec purpose. + * tempsense_lasttime; + * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM. + * tx_duty_cycle_cck: maximum allowed duty cycle for CCK. + * next_bsscfg_ID; + * pkt_queue: txq for transmit packets. + * mpc_dur: total time (ms) in mpc mode except for the portion since + * radio is turned off last time. + * mpc_laston_ts: timestamp (ms) when radio is turned off last time. + * wiphy: */ struct brcms_c_info { - struct brcms_pub *pub; /* pointer to wlc public state */ - struct brcms_info *wl; /* pointer to os-specific private state */ - struct d11regs *regs; /* pointer to device registers */ - - /* HW related state used primarily by BMAC */ + struct brcms_pub *pub; + struct brcms_info *wl; + struct d11regs *regs; struct brcms_hardware *hw; /* clock */ - int clkreq_override; /* setting for clkreq for PCIE : Auto, 0, 1 */ - u16 fastpwrup_dly; /* time in us needed to bring up d11 fast clock */ + int clkreq_override; + u16 fastpwrup_dly; /* interrupt */ - u32 macintstatus; /* bit channel between isr and dpc */ - u32 macintmask; /* sw runtime master macintmask value */ - u32 defmacintmask; /* default "on" macintmask value */ + u32 macintstatus; + u32 macintmask; + u32 defmacintmask; /* up and down */ - bool device_present; /* (removable) device is present */ + bool device_present; - bool clk; /* core is out of reset and has clock */ + bool clk; /* multiband */ - struct brcms_core *core; /* pointer to active io core */ - struct brcms_band *band; /* pointer to active per-band state */ - struct brcms_core *corestate; /* per-core state (one per hw core) */ - /* per-band state (one per phy/radio): */ + struct brcms_core *core; + struct brcms_band *band; + struct brcms_core *corestate; struct brcms_band *bandstate[MAXBANDS]; - bool war16165; /* PCI slow clock 16165 war flag */ + bool war16165; - bool tx_suspended; /* data fifos need to remain suspended */ + bool tx_suspended; uint txpend16165war; /* packet queue */ - uint qvalid; /* DirFrmQValid and BcMcFrmQValid */ + uint qvalid; /* Regulatory power limits */ - s8 txpwr_local_max; /* regulatory local txpwr max */ - u8 txpwr_local_constraint; /* local power contraint in dB */ + s8 txpwr_local_max; + u8 txpwr_local_constraint; - struct ampdu_info *ampdu; /* ampdu module handler */ - struct antsel_info *asi; /* antsel module handler */ - struct brcms_cm_info *cmi; /* channel manager module handler */ + struct ampdu_info *ampdu; + struct antsel_info *asi; + struct brcms_cm_info *cmi; - uint vars_size; /* size of vars, free vars on detach */ + uint vars_size; - u16 vendorid; /* PCI vendor id */ - u16 deviceid; /* PCI device id */ - uint ucode_rev; /* microcode revision */ + u16 vendorid; + u16 deviceid; + uint ucode_rev; - u32 machwcap; /* MAC capabilities, BMAC shadow */ + u32 machwcap; - u8 perm_etheraddr[ETH_ALEN]; /* original sprom local ethernet address */ + u8 perm_etheraddr[ETH_ALEN]; - bool bandlocked; /* disable auto multi-band switching */ - bool bandinit_pending; /* track band init in auto band */ + bool bandlocked; + bool bandinit_pending; - bool radio_monitor; /* radio timer is running */ - bool going_down; /* down path intermediate variable */ + bool radio_monitor; + bool going_down; - bool mpc; /* enable minimum power consumption */ - u8 mpc_dlycnt; /* # of watchdog cnt before turn disable radio */ - u8 mpc_offcnt; /* # of watchdog cnt that radio is disabled */ - u8 mpc_delay_off; /* delay radio disable by # of watchdog cnt */ - u8 prev_non_delay_mpc; /* prev state brcms_c_is_non_delay_mpc */ + bool mpc; + u8 mpc_dlycnt; + u8 mpc_offcnt; + u8 mpc_delay_off; + u8 prev_non_delay_mpc; - /* timer for watchdog routine */ struct brcms_timer *wdtimer; - /* timer for hw radio button monitor routine */ struct brcms_timer *radio_timer; /* promiscuous */ - bool monitor; /* monitor (MPDU sniffing) mode */ - bool bcnmisc_ibss; /* bcns promisc mode override for IBSS */ - bool bcnmisc_scan; /* bcns promisc mode override for scan */ - bool bcnmisc_monitor; /* bcns promisc mode override for monitor */ + bool monitor; + bool bcnmisc_ibss; + bool bcnmisc_scan; + bool bcnmisc_monitor; /* driver feature */ - bool _rifs; /* enable per-packet rifs */ - s8 sgi_tx; /* sgi tx */ + bool _rifs; + s8 sgi_tx; /* AP-STA synchronization, power save */ - u8 bcn_li_bcn; /* beacon listen interval in # beacons */ - u8 bcn_li_dtim; /* beacon listen interval in # dtims */ + u8 bcn_li_bcn; + u8 bcn_li_dtim; - bool WDarmed; /* watchdog timer is armed */ - u32 WDlast; /* last time wlc_watchdog() was called */ + bool WDarmed; + u32 WDlast; /* WME */ - u8 wme_dp; /* AC bitmap. Discard (oldest first) policy per AC */ - u16 edcf_txop[AC_COUNT]; /* current txop for each ac */ + u8 wme_dp; + u16 edcf_txop[AC_COUNT]; - /* - * WME parameter info element, which on STA contains parameters in use - * locally, and on AP contains parameters advertised to STA in beacons - * and assoc responses. - */ struct wme_param_ie wme_param_ie; - u16 wme_retries[AC_COUNT]; /* per-AC retry limits */ + u16 wme_retries[AC_COUNT]; + u16 tx_prec_map; + u16 fifo2prec_map[NFIFO]; - u16 tx_prec_map; /* Precedence map based on HW FIFO space */ - u16 fifo2prec_map[NFIFO]; /* pointer to fifo2_prec map based on WME */ - - /* - * BSS Configurations set of BSS configurations, idx 0 is default and - * always valid - */ struct brcms_bss_cfg *bsscfg[BRCMS_MAXBSSCFG]; - struct brcms_bss_cfg *cfg; /* the primary bsscfg (can be AP or STA) */ + struct brcms_bss_cfg *cfg; /* tx queue */ - struct brcms_txq_info *tx_queues; /* common TX Queue list */ + struct brcms_txq_info *tx_queues; /* security */ - struct wsec_key *wsec_keys[WSEC_MAX_KEYS]; /* dynamic key storage */ - /* default key storage */ + struct wsec_key *wsec_keys[WSEC_MAX_KEYS]; struct wsec_key *wsec_def_keys[BRCMS_DEFAULT_KEYS]; - bool wsec_swkeys; /* indicates that all keys should be - * treated as sw keys (used for debugging) - */ + bool wsec_swkeys; struct modulecb *modulecb; - u8 mimoft; /* SIGN or 11N */ - s8 cck_40txbw; /* 11N, cck tx b/w override when in 40MHZ mode */ - s8 ofdm_40txbw; /* 11N, ofdm tx b/w override when in 40MHZ mode */ - s8 mimo_40txbw; /* 11N, mimo tx b/w override when in 40MHZ mode */ - /* HT CAP IE being advertised by this node: */ + u8 mimoft; + s8 cck_40txbw; + s8 ofdm_40txbw; + s8 mimo_40txbw; struct ieee80211_ht_cap ht_cap; - struct brcms_bss_info *default_bss; /* configured BSS parameters */ + struct brcms_bss_info *default_bss; - u16 mc_fid_counter; /* BC/MC FIFO frame ID counter */ + u16 mc_fid_counter; - /* saved country for leaving 802.11d auto-country mode */ char country_default[BRCM_CNTRY_BUF_SZ]; - /* initial country for 802.11d auto-country mode */ char autocountry_default[BRCM_CNTRY_BUF_SZ]; - u16 prb_resp_timeout; /* do not send prb resp if request older than this, - * 0 = disable - */ - /* use only these rates in 11g supported rates if specified */ + u16 prb_resp_timeout; struct brcms_c_rateset sup_rates_override; - u16 home_chanspec; /* shared home chanspec */ + u16 home_chanspec; /* PHY parameters */ - u16 chanspec; /* target operational channel */ - u16 usr_fragthresh; /* user configured fragmentation threshold */ - u16 fragthresh[NFIFO]; /* per-fifo fragmentation thresholds */ - u16 RTSThresh; /* 802.11 dot11RTSThreshold */ - u16 SRL; /* 802.11 dot11ShortRetryLimit */ - u16 LRL; /* 802.11 dot11LongRetryLimit */ - u16 SFBL; /* Short Frame Rate Fallback Limit */ - u16 LFBL; /* Long Frame Rate Fallback Limit */ + u16 chanspec; + u16 usr_fragthresh; + u16 fragthresh[NFIFO]; + u16 RTSThresh; + u16 SRL; + u16 LRL; + u16 SFBL; + u16 LFBL; /* network config */ - bool shortslot; /* currently using 11g ShortSlot timing */ - s8 shortslot_override; /* 11g ShortSlot override */ - bool include_legacy_erp; /* include Legacy ERP info elt ID 47 as well as g ID 42 */ + bool shortslot; + s8 shortslot_override; + bool include_legacy_erp; struct brcms_protection *protection; - s8 PLCPHdr_override; /* 802.11b Preamble Type override */ + s8 PLCPHdr_override; struct brcms_stf *stf; - u32 bcn_rspec; /* save bcn ratespec purpose */ + u32 bcn_rspec; uint tempsense_lasttime; - u16 tx_duty_cycle_ofdm; /* maximum allowed duty cycle for OFDM */ - u16 tx_duty_cycle_cck; /* maximum allowed duty cycle for CCK */ + u16 tx_duty_cycle_ofdm; + u16 tx_duty_cycle_cck; u16 next_bsscfg_ID; - struct brcms_txq_info *pkt_queue; /* txq for transmit packets */ - u32 mpc_dur; /* total time (ms) in mpc mode except for the - * portion since radio is turned off last time - */ - u32 mpc_laston_ts; /* timestamp (ms) when radio is turned off last - * time - */ + struct brcms_txq_info *pkt_queue; + u32 mpc_dur; + u32 mpc_laston_ts; struct wiphy *wiphy; }; @@ -810,88 +923,136 @@ struct antsel_info { struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */ }; -/* BSS configuration state */ +/* + * BSS configuration state + * + * wlc: wlc to which this bsscfg belongs to. + * up: is this configuration up operational + * enable: is this configuration enabled + * associated: is BSS in ASSOCIATED state + * BSS: infraustructure or adhoc + * dtim_programmed: + * SSID_len: the length of SSID + * SSID: SSID string + * bcmc_scb: one bcmc_scb per band + * _idx: the index of this bsscfg, assigned at wlc_bsscfg_alloc() + * + * MAC filter + * ---------- + * nmac: # of entries on maclist array + * macmode: allow/deny stations on maclist array + * maclist: list of source MAC addrs to match + + * security + * -------- + * wsec: wireless security bitvec + * auth: 802.11 authentication: Open, Shared Key, WPA + * openshared: try Open auth first, then Shared Key + * wsec_restrict: drop unencrypted packets if wsec is enabled + * eap_restrict: restrict data until 802.1X auth succeeds + * WPA_auth: WPA authenticated key management + * wpa2_preauth: default is true, wpa_cap sets value + * wsec_portopen: indicates keys are plumbed + * wpa_none_txiv: global txiv for WPA_NONE, tkip and aes + * wsec_index: 0-3: default tx key, -1: not set + * bss_def_keys: default key storage + * + * TKIP countermeasures + * -------------------- + * tkip_countermeasures: flags TKIP no-assoc period + * tk_cm_dt: detect timer + * tk_cm_bt: blocking timer + * tk_cm_bt_tmstmp: Timestamp when TKIP BT is activated + * tk_cm_activate: activate countermeasures after EAPOL-Key sent + * + * BSSID: BSSID (associated) + * cur_etheraddr: h/w address + * bcmc_fid: the last BCMC FID queued to TX_BCMC_FIFO + * bcmc_fid_shm: the last BCMC FID written to shared mem + * flags: BSSCFG flags; see below + * bcn: AP beacon + * bcn_len: AP beacon length + * ar_disassoc: disassociated in associated recreation + * auth_atmptd: auth type (open/shared) attempted + * + * pmkid_cand: PMKID candidate list + * npmkid_cand: num PMKID candidates + * pmkid: PMKID cache + * npmkid: num cached PMKIDs + * current_bss: BSS parms in ASSOCIATED state + * + * PM states + * --------- + * PMawakebcn: bcn recvd during current waking state + * PMpending: waiting for tx status with PM indicated set + * priorPMstate: Detecting PM state transitions + * PSpoll: flags there is an outstanding PS-Poll frame + * + * rcmta: BSSID entry in RCMTA, use the wsec key to manage the RCMTA entries. + * + * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation + * + * txrspecidx: index into tx rate circular buffer + * txrspec: circular buffer of prev MPDUs tx rates + */ struct brcms_bss_cfg { - struct brcms_c_info *wlc; /* wlc to which this bsscfg belongs to. */ - bool up; /* is this configuration up operational */ - bool enable; /* is this configuration enabled */ - bool associated; /* is BSS in ASSOCIATED state */ - bool BSS; /* infraustructure or adhac */ + struct brcms_c_info *wlc; + bool up; + bool enable; + bool associated; + bool BSS; bool dtim_programmed; - - u8 SSID_len; /* the length of SSID */ - u8 SSID[IEEE80211_MAX_SSID_LEN]; /* SSID string */ - struct scb *bcmc_scb[MAXBANDS]; /* one bcmc_scb per band */ - s8 _idx; /* the index of this bsscfg, - * assigned at wlc_bsscfg_alloc() - */ - /* MAC filter */ - uint nmac; /* # of entries on maclist array */ - int macmode; /* allow/deny stations on maclist array */ - struct ether_addr *maclist; /* list of source MAC addrs to match */ - - /* security */ - u32 wsec; /* wireless security bitvec */ - s16 auth; /* 802.11 authentication: Open, Shared Key, WPA */ - s16 openshared; /* try Open auth first, then Shared Key */ - bool wsec_restrict; /* drop unencrypted packets if wsec is enabled */ - bool eap_restrict; /* restrict data until 802.1X auth succeeds */ - u16 WPA_auth; /* WPA: authenticated key management */ - bool wpa2_preauth; /* default is true, wpa_cap sets value */ - bool wsec_portopen; /* indicates keys are plumbed */ - /* global txiv for WPA_NONE, tkip and aes */ + u8 SSID_len; + u8 SSID[IEEE80211_MAX_SSID_LEN]; + struct scb *bcmc_scb[MAXBANDS]; + s8 _idx; + uint nmac; + int macmode; + struct ether_addr *maclist; + u32 wsec; + s16 auth; + s16 openshared; + bool wsec_restrict; + bool eap_restrict; + u16 WPA_auth; + bool wpa2_preauth; + bool wsec_portopen; struct wsec_iv wpa_none_txiv; - int wsec_index; /* 0-3: default tx key, -1: not set */ - /* default key storage: */ + int wsec_index; struct wsec_key *bss_def_keys[BRCMS_DEFAULT_KEYS]; - - /* TKIP countermeasures */ - bool tkip_countermeasures; /* flags TKIP no-assoc period */ - u32 tk_cm_dt; /* detect timer */ - u32 tk_cm_bt; /* blocking timer */ - u32 tk_cm_bt_tmstmp; /* Timestamp when TKIP BT is activated */ - bool tk_cm_activate; /* activate countermeasures after EAPOL-Key sent */ - - u8 BSSID[ETH_ALEN]; /* BSSID (associated) */ - u8 cur_etheraddr[ETH_ALEN]; /* h/w address */ - u16 bcmc_fid; /* the last BCMC FID queued to TX_BCMC_FIFO */ - u16 bcmc_fid_shm; /* the last BCMC FID written to shared mem */ - - u32 flags; /* BSSCFG flags; see below */ - - u8 *bcn; /* AP beacon */ - uint bcn_len; /* AP beacon length */ - bool ar_disassoc; /* disassociated in associated recreation */ - - int auth_atmptd; /* auth type (open/shared) attempted */ - - struct pmkid_cand pmkid_cand[MAXPMKID]; /* PMKID candidate list */ - uint npmkid_cand; /* num PMKID candidates */ - struct pmkid pmkid[MAXPMKID]; /* PMKID cache */ - uint npmkid; /* num cached PMKIDs */ - - struct brcms_bss_info *current_bss; /* BSS parms in ASSOCIATED state */ - - /* PM states */ - bool PMawakebcn; /* bcn recvd during current waking state */ - bool PMpending; /* waiting for tx status with PM indicated set */ - bool priorPMstate; /* Detecting PM state transitions */ - bool PSpoll; /* whether there is an outstanding PS-Poll frame */ - - /* BSSID entry in RCMTA, use the wsec key management infrastructure to - * manage the RCMTA entries. - */ + bool tkip_countermeasures; + u32 tk_cm_dt; + u32 tk_cm_bt; + u32 tk_cm_bt_tmstmp; + bool tk_cm_activate; + u8 BSSID[ETH_ALEN]; + u8 cur_etheraddr[ETH_ALEN]; + u16 bcmc_fid; + u16 bcmc_fid_shm; + u32 flags; + u8 *bcn; + uint bcn_len; + bool ar_disassoc; + int auth_atmptd; + struct pmkid_cand pmkid_cand[MAXPMKID]; + uint npmkid_cand; + struct pmkid pmkid[MAXPMKID]; + uint npmkid; + struct brcms_bss_info *current_bss; + bool PMawakebcn; + bool PMpending; + bool priorPMstate; + bool PSpoll; struct wsec_key *rcmta; - - /* 'unique' ID of this bsscfg, assigned at bsscfg allocation */ u16 ID; - - uint txrspecidx; /* index into tx rate circular buffer */ - u32 txrspec[NTXRATE][2]; /* circular buffer of prev MPDUs tx rates */ + uint txrspecidx; + u32 txrspec[NTXRATE][2]; }; -#define CHANNEL_BANDUNIT(wlc, ch) (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) -#define OTHERBANDUNIT(wlc) ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) +#define CHANNEL_BANDUNIT(wlc, ch) \ + (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) +#define OTHERBANDUNIT(wlc) \ + ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) #define IS_MBAND_UNLOCKED(wlc) \ ((NBANDS(wlc) > 1) && !(wlc)->bandlocked) @@ -899,14 +1060,15 @@ struct brcms_bss_cfg { #define BRCMS_BAND_PI_RADIO_CHANSPEC wlc_phy_chanspec_get(wlc->band->pi) /* sum the individual fifo tx pending packet counts */ -#define TXPKTPENDTOT(wlc) ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ - (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) -#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) -#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) -#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val)) -#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) -#define TXAVAIL(wlc, fifo) (*(wlc)->core->txavail[(fifo)]) -#define GETNEXTTXP(wlc, _queue) \ +#define TXPKTPENDTOT(wlc) \ + ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ + (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) +#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) +#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) +#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val)) +#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) +#define TXAVAIL(wlc, fifo) (*(wlc)->core->txavail[(fifo)]) +#define GETNEXTTXP(wlc, _queue) \ dma_getnexttxp((wlc)->hw->di[(_queue)], DMA_RANGE_TRANSMITTED) #define BRCMS_IS_MATCH_SSID(wlc, ssid1, ssid2, len1, len2) \ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 03f9856646c..975d80cb884 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -24,10 +24,14 @@ #define OTPS_GUP_MASK 0x00000f00 #define OTPS_GUP_SHIFT 8 -#define OTPS_GUP_HW 0x00000100 /* h/w subregion is programmed */ -#define OTPS_GUP_SW 0x00000200 /* s/w subregion is programmed */ -#define OTPS_GUP_CI 0x00000400 /* chipid/pkgopt subregion is programmed */ -#define OTPS_GUP_FUSE 0x00000800 /* fuse subregion is programmed */ +/* h/w subregion is programmed */ +#define OTPS_GUP_HW 0x00000100 +/* s/w subregion is programmed */ +#define OTPS_GUP_SW 0x00000200 +/* chipid/pkgopt subregion is programmed */ +#define OTPS_GUP_CI 0x00000400 +/* fuse subregion is programmed */ +#define OTPS_GUP_FUSE 0x00000800 /* Fields in otpprog in rev >= 21 */ #define OTPP_COL_MASK 0x000000ff @@ -195,8 +199,9 @@ static u16 ipxotp_read_bit(void *oh, struct chipcregs *cc, uint off) return (int)st; } -/* Calculate max HW/SW region byte size by subtracting fuse region and checksum size, - * osizew is oi->wsize (OTP size - GU size) in words +/* + * Calculate max HW/SW region byte size by subtracting fuse region + * and checksum size, osizew is oi->wsize (OTP size - GU size) in words */ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) { @@ -222,12 +227,18 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) uint k; u32 otpp, st; - /* record word offset of General Use Region for various chipcommon revs */ + /* + * record word offset of General Use Region + * for various chipcommon revs + */ if (oi->sih->ccrev == 21 || oi->sih->ccrev == 24 || oi->sih->ccrev == 27) { oi->otpgu_base = REVA4_OTPGU_BASE; } else if (oi->sih->ccrev == 36) { - /* OTP size greater than equal to 2KB (128 words), otpgu_base is similar to rev23 */ + /* + * OTP size greater than equal to 2KB (128 words), + * otpgu_base is similar to rev23 + */ if (oi->wsize >= 128) oi->otpgu_base = REVB8_OTPGU_BASE; else @@ -262,8 +273,9 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) } /* - * h/w region base and fuse region limit are fixed to the top and - * the bottom of the general use region. Everything else can be flexible. + * h/w region base and fuse region limit are fixed to + * the top and the bottom of the general use region. + * Everything else can be flexible. */ oi->hwbase = oi->otpgu_base + OTPGU_SROM_OFF; oi->hwlim = oi->wsize; diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h index f6d3a56acf1..4d792469896 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.h +++ b/drivers/staging/brcm80211/brcmsmac/otp.h @@ -24,7 +24,8 @@ #define OTP_SW_RGN 2 #define OTP_CI_RGN 4 #define OTP_FUSE_RGN 8 -#define OTP_ALL_RGN 0xf /* From h/w region to end of OTP including checksum */ +/* From h/w region to end of OTP including checksum */ +#define OTP_ALL_RGN 0xf /* OTP Size */ #define OTP_SZ_MAX (6144/8) /* maximum bytes in one CIS */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index 56824f43605..a8821390628 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -15,10 +15,11 @@ */ /* - * This is "two-way" interface, acting as the SHIM layer between WL and PHY layer. - * WL driver can optinally call this translation layer to do some preprocessing, then reach PHY. - * On the PHY->WL driver direction, all calls go through this layer since PHY doesn't have the - * access to wlc_hw pointer. + * This is "two-way" interface, acting as the SHIM layer between driver + * and PHY layer. The driver can optionally call this translation layer + * to do some preprocessing, then reach PHY. On the PHY->driver direction, + * all calls go through this layer since PHY doesn't have access to the + * driver's brcms_hardware pointer. */ #include #include diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index 2d12bb4400f..a35e1ed973b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -45,17 +45,17 @@ #define FRA_ERR_20MHZ 60 #define FRA_ERR_40MHZ 120 -#define ANTSEL_NA 0 /* No boardlevel selection available */ -#define ANTSEL_2x4 1 /* 2x4 boardlevel selection available */ -#define ANTSEL_2x3 2 /* 2x3 CB2 boardlevel selection available */ +#define ANTSEL_NA 0 /* No boardlevel selection available */ +#define ANTSEL_2x4 1 /* 2x4 boardlevel selection available */ +#define ANTSEL_2x3 2 /* 2x3 CB2 boardlevel selection available */ /* Rx Antenna diversity control values */ -#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ -#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ -#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ -#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ -#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ -#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* default antdiv setting */ +#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ +#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ +#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ +#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ +#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ +#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* default antdiv setting */ #define WL_ANT_RX_MAX 2 /* max 2 receive antennas */ #define WL_ANT_HT_RX_MAX 3 /* max 3 receive antennas/cores */ @@ -77,26 +77,40 @@ #define WL_TX_POWER_RATES 101 #define WL_TX_POWER_CCK_FIRST 0 #define WL_TX_POWER_CCK_NUM 4 -#define WL_TX_POWER_OFDM_FIRST 4 /* Index for first 20MHz OFDM SISO rate */ -#define WL_TX_POWER_OFDM20_CDD_FIRST 12 /* Index for first 20MHz OFDM CDD rate */ -#define WL_TX_POWER_OFDM40_SISO_FIRST 52 /* Index for first 40MHz OFDM SISO rate */ -#define WL_TX_POWER_OFDM40_CDD_FIRST 60 /* Index for first 40MHz OFDM CDD rate */ +/* Index for first 20MHz OFDM SISO rate */ +#define WL_TX_POWER_OFDM_FIRST 4 +/* Index for first 20MHz OFDM CDD rate */ +#define WL_TX_POWER_OFDM20_CDD_FIRST 12 +/* Index for first 40MHz OFDM SISO rate */ +#define WL_TX_POWER_OFDM40_SISO_FIRST 52 +/* Index for first 40MHz OFDM CDD rate */ +#define WL_TX_POWER_OFDM40_CDD_FIRST 60 #define WL_TX_POWER_OFDM_NUM 8 -#define WL_TX_POWER_MCS20_SISO_FIRST 20 /* Index for first 20MHz MCS SISO rate */ -#define WL_TX_POWER_MCS20_CDD_FIRST 28 /* Index for first 20MHz MCS CDD rate */ -#define WL_TX_POWER_MCS20_STBC_FIRST 36 /* Index for first 20MHz MCS STBC rate */ -#define WL_TX_POWER_MCS20_SDM_FIRST 44 /* Index for first 20MHz MCS SDM rate */ -#define WL_TX_POWER_MCS40_SISO_FIRST 68 /* Index for first 40MHz MCS SISO rate */ -#define WL_TX_POWER_MCS40_CDD_FIRST 76 /* Index for first 40MHz MCS CDD rate */ -#define WL_TX_POWER_MCS40_STBC_FIRST 84 /* Index for first 40MHz MCS STBC rate */ -#define WL_TX_POWER_MCS40_SDM_FIRST 92 /* Index for first 40MHz MCS SDM rate */ +/* Index for first 20MHz MCS SISO rate */ +#define WL_TX_POWER_MCS20_SISO_FIRST 20 +/* Index for first 20MHz MCS CDD rate */ +#define WL_TX_POWER_MCS20_CDD_FIRST 28 +/* Index for first 20MHz MCS STBC rate */ +#define WL_TX_POWER_MCS20_STBC_FIRST 36 +/* Index for first 20MHz MCS SDM rate */ +#define WL_TX_POWER_MCS20_SDM_FIRST 44 +/* Index for first 40MHz MCS SISO rate */ +#define WL_TX_POWER_MCS40_SISO_FIRST 68 +/* Index for first 40MHz MCS CDD rate */ +#define WL_TX_POWER_MCS40_CDD_FIRST 76 +/* Index for first 40MHz MCS STBC rate */ +#define WL_TX_POWER_MCS40_STBC_FIRST 84 +/* Index for first 40MHz MCS SDM rate */ +#define WL_TX_POWER_MCS40_SDM_FIRST 92 #define WL_TX_POWER_MCS_1_STREAM_NUM 8 #define WL_TX_POWER_MCS_2_STREAM_NUM 8 -#define WL_TX_POWER_MCS_32 100 /* Index for 40MHz rate MCS 32 */ +/* Index for 40MHz rate MCS 32 */ +#define WL_TX_POWER_MCS_32 100 #define WL_TX_POWER_MCS_32_NUM 1 /* sslpnphy specifics */ -#define WL_TX_POWER_MCS20_SISO_FIRST_SSN 12 /* Index for first 20MHz MCS SISO rate */ +/* Index for first 20MHz MCS SISO rate */ +#define WL_TX_POWER_MCS20_SISO_FIRST_SSN 12 /* struct tx_power::flags bits */ #define WL_TX_POWER_F_ENABLED 1 diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index ec53a086855..f5e10850d87 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -70,11 +70,13 @@ #define PMURES_BIT(bit) (1 << (bit)) /* PMU corerev and chip specific PLL controls. - * PMU_PLL_XX where is PMU corerev and is an arbitrary number - * to differentiate different PLLs controlled by the same PMU rev. + * PMU_PLL_XX where is PMU corerev and is an arbitrary + * number to differentiate different PLLs controlled by the same PMU rev. + */ +/* pllcontrol registers: + * ndiv_pwrdn, pwrdn_ch, refcomp_pwrdn, dly_ch, + * p1div, p2div, _bypass_sdmod */ -/* pllcontrol registers */ -/* ndiv_pwrdn, pwrdn_ch, refcomp_pwrdn, dly_ch, p1div, p2div, _bypass_sdmod */ #define PMU1_PLL0_PLLCTL0 0 #define PMU1_PLL0_PLLCTL1 1 #define PMU1_PLL0_PLLCTL2 2 diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index bfbdc3a54c3..8da72505515 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -69,36 +69,53 @@ #define BRCMS_RATE_MASK 0x7f /* Rate value mask w/o basic rate flag */ /* legacy rx Antenna diversity for SISO rates */ -#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ -#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ -#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ -#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ -#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ -#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* default antdiv setting */ +#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ +#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ +#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ +#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ +#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ +/* default antdiv setting */ +#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* legacy rx Antenna diversity for SISO rates */ -#define ANT_TX_FORCE_0 0 /* Tx on antenna 0, "legacy term Main" */ -#define ANT_TX_FORCE_1 1 /* Tx on antenna 1, "legacy term Aux" */ -#define ANT_TX_LAST_RX 3 /* Tx on phy's last good Rx antenna */ -#define ANT_TX_DEF 3 /* driver's default tx antenna setting */ +/* Tx on antenna 0, "legacy term Main" */ +#define ANT_TX_FORCE_0 0 +/* Tx on antenna 1, "legacy term Aux" */ +#define ANT_TX_FORCE_1 1 +/* Tx on phy's last good Rx antenna */ +#define ANT_TX_LAST_RX 3 +/* driver's default tx antenna setting */ +#define ANT_TX_DEF 3 -#define TXCORE_POLICY_ALL 0x1 /* use all available core for transmit */ +/* use all available core for transmit */ +#define TXCORE_POLICY_ALL 0x1 /* Tx Chain values */ -#define TXCHAIN_DEF 0x1 /* def bitmap of txchain */ -#define TXCHAIN_DEF_NPHY 0x3 /* default bitmap of tx chains for nphy */ -#define TXCHAIN_DEF_HTPHY 0x7 /* default bitmap of tx chains for nphy */ -#define RXCHAIN_DEF 0x1 /* def bitmap of rxchain */ -#define RXCHAIN_DEF_NPHY 0x3 /* default bitmap of rx chains for nphy */ -#define RXCHAIN_DEF_HTPHY 0x7 /* default bitmap of rx chains for nphy */ -#define ANTSWITCH_NONE 0 /* no antenna switch */ -#define ANTSWITCH_TYPE_1 1 /* antenna switch on 4321CB2, 2of3 */ -#define ANTSWITCH_TYPE_2 2 /* antenna switch on 4321MPCI, 2of3 */ -#define ANTSWITCH_TYPE_3 3 /* antenna switch on 4322, 2of3 */ +/* def bitmap of txchain */ +#define TXCHAIN_DEF 0x1 +/* default bitmap of tx chains for nphy */ +#define TXCHAIN_DEF_NPHY 0x3 +/* default bitmap of tx chains for nphy */ +#define TXCHAIN_DEF_HTPHY 0x7 +/* def bitmap of rxchain */ +#define RXCHAIN_DEF 0x1 +/* default bitmap of rx chains for nphy */ +#define RXCHAIN_DEF_NPHY 0x3 +/* default bitmap of rx chains for nphy */ +#define RXCHAIN_DEF_HTPHY 0x7 +/* no antenna switch */ +#define ANTSWITCH_NONE 0 +/* antenna switch on 4321CB2, 2of3 */ +#define ANTSWITCH_TYPE_1 1 +/* antenna switch on 4321MPCI, 2of3 */ +#define ANTSWITCH_TYPE_2 2 +/* antenna switch on 4322, 2of3 */ +#define ANTSWITCH_TYPE_3 3 #define RXBUFSZ PKTBUFSZ #ifndef AIDMAPSZ -#define AIDMAPSZ (roundup(MAXSCB, NBBY)/NBBY) /* aid bitmap size in bytes */ +/* aid bitmap size in bytes */ +#define AIDMAPSZ (roundup(MAXSCB, NBBY)/NBBY) #endif /* AIDMAPSZ */ #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ @@ -108,21 +125,21 @@ #define WL_SPURAVOID_ON2 2 struct brcms_tunables { - int ntxd; /* size of tx descriptor table */ - int nrxd; /* size of rx descriptor table */ - int rxbufsz; /* size of rx buffers to post */ - int nrxbufpost; /* # of rx buffers to post */ - int maxscb; /* # of SCBs supported */ + int ntxd; /* size of tx descriptor table */ + int nrxd; /* size of rx descriptor table */ + int rxbufsz; /* size of rx buffers to post */ + int nrxbufpost; /* # of rx buffers to post */ + int maxscb; /* # of SCBs supported */ int ampdunummpdu; /* max number of mpdu in an ampdu */ - int maxpktcb; /* max # of packet callbacks */ - int maxucodebss; /* max # of BSS handled in ucode bcn/prb */ + int maxpktcb; /* max # of packet callbacks */ + int maxucodebss;/* max # of BSS handled in ucode bcn/prb */ int maxucodebss4; /* max # of BSS handled in sw bcn/prb */ - int maxbss; /* max # of bss info elements in scan list */ - int datahiwat; /* data msg txq hiwat mark */ + int maxbss; /* max # of bss info elements in scan list */ + int datahiwat; /* data msg txq hiwat mark */ int ampdudatahiwat; /* AMPDU msg txq hiwat mark */ - int rxbnd; /* max # of rx bufs to process before deferring to dpc */ - int txsbnd; /* max # tx status to process in wlc_txstatus() */ - int memreserved; /* memory reserved for BMAC's USB dma rx */ + int rxbnd; /* max # rx bufs to process before deferring to dpc */ + int txsbnd; /* max # tx status to process in wlc_txstatus() */ + int memreserved;/* memory reserved for BMAC's USB dma rx */ }; struct brcms_c_rateset { @@ -181,7 +198,7 @@ struct brcms_bss_info { struct rsn_parms wpa; struct rsn_parms wpa2; u16 qbss_load_aac; /* qbss load available admission capacity */ - /* qbss_load_chan_free <- (0xff - channel_utilization of qbss_load_ie_t) */ + /* qbss_load_chan_free <- (0xff - chan utilization of qbss_load_ie_t) */ u8 qbss_load_chan_free; /* indicates how free the channel is */ u8 mcipher; /* multicast cipher */ u8 wpacfg; /* wpa config index */ @@ -207,7 +224,7 @@ struct brcms_bss_info { #define MAC80211_SCAN (1 << 1) /* - * Public portion of "common" os-independent state structure. + * Public portion of common driver state structure. * The wlc handle points at this. */ struct brcms_pub { @@ -225,8 +242,8 @@ struct brcms_pub { bool hw_off; /* HW is off */ /* tunables: ntxd, nrxd, maxscb, etc. */ struct brcms_tunables *tunables; - bool hw_up; /* one time hw up/down(from boot or hibernation) */ - bool _piomode; /* true if pio mode *//* BMAC_NOTE: NEED In both */ + bool hw_up; /* one time hw up/down */ + bool _piomode; /* true if pio mode */ uint _nbands; /* # bands supported */ uint now; /* # elapsed seconds */ @@ -247,7 +264,7 @@ struct brcms_pub { u8 _n_enab; /* bitmap of 11N + HT support */ bool _n_reqd; /* N support required for clients */ - s8 _coex; /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */ + s8 _coex; /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */ bool _priofc; /* Priority-based flowcontrol */ u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */ @@ -337,8 +354,10 @@ enum wlc_par_id { #define SUPPORT_11N (ENAB_1x1|ENAB_2x2) #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) /* WL11N Support */ -#if ((defined(NCONF) && (NCONF != 0)) || (defined(LCNCONF) && (LCNCONF != 0)) || \ - (defined(HTCONF) && (HTCONF != 0)) || (defined(SSLPNCONF) && (SSLPNCONF != 0))) +#if ((defined(NCONF) && (NCONF != 0)) || \ + (defined(LCNCONF) && (LCNCONF != 0)) || \ + (defined(HTCONF) && (HTCONF != 0)) || \ + (defined(SSLPNCONF) && (SSLPNCONF != 0))) #define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N) #define N_REQD(pub) ((pub)->_n_reqd) #else @@ -370,8 +389,10 @@ enum wlc_par_id { extern const u8 wlc_prio2prec_map[]; #define BRCMS_PRIO_TO_PREC(pri) wlc_prio2prec_map[(pri) & 7] -/* This maps priority to one precedence higher - Used by PS-Poll response packets to - * simulate enqueue-at-head operation, but still maintain the order on the queue +/* + * This maps priority to one precedence higher - Used by PS-Poll response + * packets to simulate enqueue-at-head operation, but still maintain the + * order on the queue */ #define BRCMS_PRIO_TO_HI_PREC(pri) min(BRCMS_PRIO_TO_PREC(pri) + 1,\ BRCMS_PREC_COUNT - 1) @@ -424,28 +445,34 @@ extern const u8 wme_fifo2ac[]; /* * 54g modes (basic bits may still be overridden) * - * GMODE_LEGACY_B Rateset: 1b, 2b, 5.5, 11 - * Preamble: Long - * Shortslot: Off - * GMODE_AUTO Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 - * Extended Rateset: 6, 9, 12, 48 - * Preamble: Long - * Shortslot: Auto - * GMODE_ONLY Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54 - * Extended Rateset: 6b, 9, 12b, 48 - * Preamble: Short required - * Shortslot: Auto - * GMODE_B_DEFERRED Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 - * Extended Rateset: 6, 9, 12, 48 - * Preamble: Long - * Shortslot: On - * GMODE_PERFORMANCE Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54 - * Preamble: Short required - * Shortslot: On and required - * GMODE_LRS Rateset: 1b, 2b, 5.5b, 11b - * Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54 - * Preamble: Long - * Shortslot: Auto + * GMODE_LEGACY_B + * Rateset: 1b, 2b, 5.5, 11 + * Preamble: Long + * Shortslot: Off + * GMODE_AUTO + * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 + * Extended Rateset: 6, 9, 12, 48 + * Preamble: Long + * Shortslot: Auto + * GMODE_ONLY + * Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54 + * Extended Rateset: 6b, 9, 12b, 48 + * Preamble: Short required + * Shortslot: Auto + * GMODE_B_DEFERRED + * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 + * Extended Rateset: 6, 9, 12, 48 + * Preamble: Long + * Shortslot: On + * GMODE_PERFORMANCE + * Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54 + * Preamble: Short required + * Shortslot: On and required + * GMODE_LRS + * Rateset: 1b, 2b, 5.5b, 11b + * Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54 + * Preamble: Long + * Shortslot: Auto */ #define GMODE_LEGACY_B 0 #define GMODE_AUTO 1 @@ -488,12 +515,18 @@ extern const u8 wme_fifo2ac[]; #define BRCMS_N_SGI_40 0x02 /* defines used by the nrate iovar */ -#define NRATE_MCS_INUSE 0x00000080 /* MSC in use,indicates b0-6 holds an mcs */ -#define NRATE_RATE_MASK 0x0000007f /* rate/mcs value */ -#define NRATE_STF_MASK 0x0000ff00 /* stf mode mask: siso, cdd, stbc, sdm */ -#define NRATE_STF_SHIFT 8 /* stf mode shift */ -#define NRATE_OVERRIDE 0x80000000 /* bit indicates override both rate & mode */ -#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 /* bit indicate to override mcs only */ +/* MSC in use,indicates b0-6 holds an mcs */ +#define NRATE_MCS_INUSE 0x00000080 +/* rate/mcs value */ +#define NRATE_RATE_MASK 0x0000007f +/* stf mode mask: siso, cdd, stbc, sdm */ +#define NRATE_STF_MASK 0x0000ff00 +/* stf mode shift */ +#define NRATE_STF_SHIFT 8 +/* bit indicates override both rate & mode */ +#define NRATE_OVERRIDE 0x80000000 +/* bit indicate to override mcs only */ +#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 #define NRATE_SGI_MASK 0x00800000 /* sgi mode */ #define NRATE_SGI_SHIFT 23 /* sgi mode */ #define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ @@ -504,9 +537,11 @@ extern const u8 wme_fifo2ac[]; #define NRATE_STF_STBC 2 /* stf mode STBC */ #define NRATE_STF_SDM 3 /* stf mode SDM */ -#define ANT_SELCFG_MAX 4 /* max number of antenna configurations */ +/* max number of antenna configurations */ +#define ANT_SELCFG_MAX 4 -#define HIGHEST_SINGLE_STREAM_MCS 7 /* MCS values greater than this enable multiple streams */ +/* MCS values greater than this enable multiple streams */ +#define HIGHEST_SINGLE_STREAM_MCS 7 struct brcms_antselcfg { u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */ @@ -606,7 +641,4 @@ extern bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc); #define BAND_2G_NAME "2.4G" #define BAND_5G_NAME "5G" -/* BMAC RPC: 7 u32 params: pkttotlen, fifo, commit, fid, txpktpend, pktflag, rpc_id */ -#define BRCMS_RPCTX_PARAMS 32 - #endif /* _BRCM_PUB_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index c320384ee35..5fb0d9e8c5e 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -21,7 +21,10 @@ #include "pub.h" #include "rate.h" -/* Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate value */ +/* + * Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate + * value + */ const u8 rate_info[BRCM_MAXRATE + 1] = { /* 0 1 2 3 4 5 6 7 8 9 */ /* 0 */ 0x00, 0x00, 0x0a, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -139,20 +142,25 @@ const struct brcms_mcs_info mcs_table[MCS_TABLE_SIZE] = { {0, 6000, 0, CEIL(6000 * 10, 9), 0x00, BRCM_RATE_6M}, }; -/* phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams - * Number of spatial streams: always 1 - * other fields: refer to table 78 of section 17.3.2.2 of the original .11a standard +/* + * phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams + * Number of spatial streams: always 1 other fields: refer to table 78 of + * section 17.3.2.2 of the original .11a standard */ struct legacy_phycfg { u32 rate_ofdm; /* ofdm mac rate */ - u8 tx_phy_ctl3; /* phy ctl byte 3, code rate, modulation type, # of streams */ + /* phy ctl byte 3, code rate, modulation type, # of streams */ + u8 tx_phy_ctl3; }; -#define LEGACY_PHYCFG_TABLE_SIZE 12 /* Number of legacy_rate_cfg entries in the table */ +/* Number of legacy_rate_cfg entries in the table */ +#define LEGACY_PHYCFG_TABLE_SIZE 12 -/* In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate */ -/* Eventually MIMOPHY would also be converted to this format */ -/* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ +/* + * In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate + * Eventually MIMOPHY would also be converted to this format + * 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps + */ static const struct legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = { {BRCM_RATE_1M, 0x00}, /* CCK 1Mbps, data rate 0 */ @@ -181,78 +189,81 @@ legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = { const struct brcms_c_rateset cck_ofdm_mimo_rates = { 12, - { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ - 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - 0x6c}, + /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, */ + { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, + /* 54 Mbps */ + 0x6c}, 0x00, - {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset ofdm_mimo_rates = { 8, - { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, + /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ + { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, - {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; /* Default ratesets that include MCS32 for 40BW channels */ const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { 12, - { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ - 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - 0x6c}, + /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48 */ + { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, + /* 54 Mbps */ + 0x6c}, 0x00, - {0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset ofdm_40bw_mimo_rates = { 8, - { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, + /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ + { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, - {0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset cck_ofdm_rates = { 12, - { /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, 54 Mbps */ - 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - 0x6c}, + /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48,*/ + { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, + /*54 Mbps */ + 0x6c}, 0x00, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset gphy_legacy_rates = { 4, - { /* 1b, 2b, 5.5b, 11b Mbps */ - 0x82, 0x84, 0x8b, 0x96}, + /* 1b, 2b, 5.5b, 11b Mbps */ + { 0x82, 0x84, 0x8b, 0x96}, 0x00, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset ofdm_rates = { 8, - { /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, + /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ + { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset cck_rates = { 4, - { /* 1b, 2b, 5.5, 11 Mbps */ - 0x82, 0x84, 0x0b, 0x16}, + /* 1b, 2b, 5.5, 11 Mbps */ + { 0x82, 0x84, 0x0b, 0x16}, 0x00, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00} }; /* check if rateset is valid. @@ -283,8 +294,9 @@ void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams) rs->mcs[i] = 0; } -/* filter based on hardware rateset, and sort filtered rateset with basic bit(s) preserved, - * and check if resulting rateset is valid. +/* + * filter based on hardware rateset, and sort filtered rateset with basic + * bit(s) preserved, and check if resulting rateset is valid. */ bool brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index 9fb187e549a..39e1796e924 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -30,12 +30,18 @@ extern const struct brcms_c_rateset wlc_lrs_rates; extern const struct brcms_c_rateset rate_limit_1_2; struct brcms_mcs_info { - u32 phy_rate_20; /* phy rate in kbps [20Mhz] */ - u32 phy_rate_40; /* phy rate in kbps [40Mhz] */ - u32 phy_rate_20_sgi; /* phy rate in kbps [20Mhz] with SGI */ - u32 phy_rate_40_sgi; /* phy rate in kbps [40Mhz] with SGI */ - u8 tx_phy_ctl3; /* phy ctl byte 3, code rate, modulation type, # of streams */ - u8 leg_ofdm; /* matching legacy ofdm rate in 500bkps */ + /* phy rate in kbps [20Mhz] */ + u32 phy_rate_20; + /* phy rate in kbps [40Mhz] */ + u32 phy_rate_40; + /* phy rate in kbps [20Mhz] with SGI */ + u32 phy_rate_20_sgi; + /* phy rate in kbps [40Mhz] with SGI */ + u32 phy_rate_40_sgi; + /* phy ctl byte 3, code rate, modulation type, # of streams */ + u8 tx_phy_ctl3; + /* matching legacy ofdm rate in 500bkps */ + u8 leg_ofdm; }; #define BRCMS_MAXMCS 32 /* max valid mcs index */ @@ -49,11 +55,18 @@ extern const struct brcms_mcs_info mcs_table[]; #define MCS_TXS_MASK 0xc0 /* num tx streams - 1 bit mask */ #define MCS_TXS_SHIFT 6 /* num tx streams - 1 bit shift */ #define MCS_CR(_mcs) (mcs_table[_mcs].tx_phy_ctl3 & MCS_CR_MASK) -#define MCS_MOD(_mcs) ((mcs_table[_mcs].tx_phy_ctl3 & MCS_MOD_MASK) >> MCS_MOD_SHIFT) -#define MCS_TXS(_mcs) ((mcs_table[_mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT) + +#define MCS_MOD(_mcs) \ + ((mcs_table[_mcs].tx_phy_ctl3 & MCS_MOD_MASK) >> MCS_MOD_SHIFT) + +#define MCS_TXS(_mcs) \ + ((mcs_table[_mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT) + #define MCS_RATE(_mcs, _is40, _sgi) (_sgi ? \ - (_is40 ? mcs_table[_mcs].phy_rate_40_sgi : mcs_table[_mcs].phy_rate_20_sgi) : \ + (_is40 ? mcs_table[_mcs].phy_rate_40_sgi : \ + mcs_table[_mcs].phy_rate_20_sgi) : \ (_is40 ? mcs_table[_mcs].phy_rate_40 : mcs_table[_mcs].phy_rate_20)) + #define VALID_MCS(_mcs) ((_mcs < MCS_TABLE_SIZE)) /* Macro to use the rate_info table */ @@ -62,46 +75,78 @@ extern const struct brcms_mcs_info mcs_table[]; /* convert 500kbps to bps */ #define BRCMS_RATE_500K_TO_BPS(rate) ((rate) * 500000) -/* rate spec : holds rate and mode specific information required to generate a tx frame. */ -/* Legacy CCK and OFDM information is held in the same manner as was done in the past */ -/* (in the lower byte) the upper 3 bytes primarily hold MIMO specific information */ +/* + * rate spec : holds rate and mode specific information required to generate a + * tx frame. Legacy CCK and OFDM information is held in the same manner as was + * done in the past (in the lower byte) the upper 3 bytes primarily hold MIMO + * specific information + */ /* rate spec bit fields */ -#define RSPEC_RATE_MASK 0x0000007F /* Either 500Kbps units or MIMO MCS idx */ -#define RSPEC_MIMORATE 0x08000000 /* mimo MCS is stored in RSPEC_RATE_MASK */ -#define RSPEC_BW_MASK 0x00000700 /* mimo bw mask */ -#define RSPEC_BW_SHIFT 8 /* mimo bw shift */ -#define RSPEC_STF_MASK 0x00003800 /* mimo Space/Time/Frequency mode mask */ -#define RSPEC_STF_SHIFT 11 /* mimo Space/Time/Frequency mode shift */ -#define RSPEC_CT_MASK 0x0000C000 /* mimo coding type mask */ -#define RSPEC_CT_SHIFT 14 /* mimo coding type shift */ -#define RSPEC_STC_MASK 0x00300000 /* mimo num STC streams per PLCP defn. */ -#define RSPEC_STC_SHIFT 20 /* mimo num STC streams per PLCP defn. */ -#define RSPEC_LDPC_CODING 0x00400000 /* mimo bit indicates adv coding in use */ -#define RSPEC_SHORT_GI 0x00800000 /* mimo bit indicates short GI in use */ -#define RSPEC_OVERRIDE 0x80000000 /* bit indicates override both rate & mode */ -#define RSPEC_OVERRIDE_MCS_ONLY 0x40000000 /* bit indicates override rate only */ + +/* Either 500Kbps units or MIMO MCS idx */ +#define RSPEC_RATE_MASK 0x0000007F +/* mimo MCS is stored in RSPEC_RATE_MASK */ +#define RSPEC_MIMORATE 0x08000000 +/* mimo bw mask */ +#define RSPEC_BW_MASK 0x00000700 +/* mimo bw shift */ +#define RSPEC_BW_SHIFT 8 +/* mimo Space/Time/Frequency mode mask */ +#define RSPEC_STF_MASK 0x00003800 +/* mimo Space/Time/Frequency mode shift */ +#define RSPEC_STF_SHIFT 11 +/* mimo coding type mask */ +#define RSPEC_CT_MASK 0x0000C000 +/* mimo coding type shift */ +#define RSPEC_CT_SHIFT 14 +/* mimo num STC streams per PLCP defn. */ +#define RSPEC_STC_MASK 0x00300000 +/* mimo num STC streams per PLCP defn. */ +#define RSPEC_STC_SHIFT 20 +/* mimo bit indicates adv coding in use */ +#define RSPEC_LDPC_CODING 0x00400000 +/* mimo bit indicates short GI in use */ +#define RSPEC_SHORT_GI 0x00800000 +/* bit indicates override both rate & mode */ +#define RSPEC_OVERRIDE 0x80000000 +/* bit indicates override rate only */ +#define RSPEC_OVERRIDE_MCS_ONLY 0x40000000 #define BRCMS_HTPHY 127 /* HT PHY Membership */ #define RSPEC_ACTIVE(rspec) (rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE)) -#define RSPEC2RATE(rspec) ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), RSPEC_ISSGI(rspec)) : \ - (rspec & RSPEC_RATE_MASK)) -/* return rate in unit of 500Kbps -- for internal use in wlc_rate_sel.c */ -#define RSPEC2RATE500K(rspec) ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), state->is40bw, RSPEC_ISSGI(rspec))/500 : \ - (rspec & RSPEC_RATE_MASK)) -#define CRSPEC2RATE500K(rspec) ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), RSPEC_ISSGI(rspec))/500 :\ - (rspec & RSPEC_RATE_MASK)) -#define RSPEC2KBPS(rspec) (IS_MCS(rspec) ? RSPEC2RATE(rspec) : RSPEC2RATE(rspec)*500) +#define RSPEC2RATE(rspec) \ + ((rspec & RSPEC_MIMORATE) ? \ + MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), \ + RSPEC_ISSGI(rspec)) : \ + (rspec & RSPEC_RATE_MASK)) + +/* return rate in unit of 500Kbps -- for internal use in wlc_rate_sel.c */ +#define RSPEC2RATE500K(rspec) \ + ((rspec & RSPEC_MIMORATE) ? \ + MCS_RATE((rspec & RSPEC_RATE_MASK), state->is40bw, \ + RSPEC_ISSGI(rspec))/500 : \ + (rspec & RSPEC_RATE_MASK)) + +#define CRSPEC2RATE500K(rspec) \ + ((rspec & RSPEC_MIMORATE) ? \ + MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), \ + RSPEC_ISSGI(rspec))/500 :\ + (rspec & RSPEC_RATE_MASK)) + +#define RSPEC2KBPS(rspec) \ + (IS_MCS(rspec) ? RSPEC2RATE(rspec) : RSPEC2RATE(rspec)*500) + #define RSPEC_PHYTXBYTE2(rspec) ((rspec & 0xff00) >> 8) + #define RSPEC_GET_BW(rspec) ((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) -#define RSPEC_IS40MHZ(rspec) ((((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == \ - PHY_TXC1_BW_40MHZ) || (((rspec & RSPEC_BW_MASK) >> \ - RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ_DUP)) + +#define RSPEC_IS40MHZ(rspec) \ + ((((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ) || \ + (((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ_DUP)) + #define RSPEC_ISSGI(rspec) ((rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI) #define RSPEC_MIMOPLCP3(rspec) ((rspec & 0xf00000) >> 16) #define PLCP3_ISSGI(plcp) (plcp & (RSPEC_SHORT_GI >> 16)) @@ -113,24 +158,33 @@ extern const struct brcms_mcs_info mcs_table[]; /* Rate info table; takes a legacy rate or u32 */ #define IS_MCS(r) (r & RSPEC_MIMORATE) + #define IS_OFDM(r) (!IS_MCS(r) && (rate_info[(r) & RSPEC_RATE_MASK] & \ BRCMS_RATE_FLAG)) + #define IS_CCK(r) (!IS_MCS(r) && ( \ ((r) & BRCMS_RATE_MASK) == BRCM_RATE_1M || \ ((r) & BRCMS_RATE_MASK) == BRCM_RATE_2M || \ ((r) & BRCMS_RATE_MASK) == BRCM_RATE_5M5 || \ ((r) & BRCMS_RATE_MASK) == BRCM_RATE_11M)) -#define IS_SINGLE_STREAM(mcs) (((mcs) <= HIGHEST_SINGLE_STREAM_MCS) || ((mcs) == 32)) + +#define IS_SINGLE_STREAM(mcs) \ + (((mcs) <= HIGHEST_SINGLE_STREAM_MCS) || ((mcs) == 32)) + #define CCK_RSPEC(cck) ((cck) & RSPEC_RATE_MASK) + #define OFDM_RSPEC(ofdm) (((ofdm) & RSPEC_RATE_MASK) |\ (PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT)) -#define LEGACY_RSPEC(rate) (IS_CCK(rate) ? CCK_RSPEC(rate) : OFDM_RSPEC(rate)) + +#define LEGACY_RSPEC(rate) \ + (IS_CCK(rate) ? CCK_RSPEC(rate) : OFDM_RSPEC(rate)) #define MCS_RSPEC(mcs) (((mcs) & RSPEC_RATE_MASK) | RSPEC_MIMORATE | \ (IS_SINGLE_STREAM(mcs) ? (PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT) : \ (PHY_TXC1_MODE_SDM << RSPEC_STF_SHIFT))) -/* Convert encoded rate value in plcp header to numerical rates in 500 KHz increments */ +/* Convert encoded rate value in plcp header to numerical rates in 500 KHz + * increments */ extern const u8 ofdm_rate_lookup[]; #define OFDM_PHY2MAC_RATE(rlpt) (ofdm_rate_lookup[rlpt & 0x7]) #define CCK_PHY2MAC_RATE(signal) (signal/5) @@ -140,7 +194,8 @@ extern const u8 ofdm_rate_lookup[]; #define BRCMS_RATES_CCK 1 #define BRCMS_RATES_OFDM 2 -/* sanitize, and sort a rateset with the basic bit(s) preserved, validate rateset */ +/* sanitize, and sort a rateset with the basic bit(s) preserved, validate + * rateset */ extern bool brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, const struct brcms_c_rateset *hw_rs, diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index d6c8328554d..22ef8e883e3 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -23,13 +23,15 @@ #include "types.h" #define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */ + /* structure to store per-tid state for the ampdu initiator */ struct scb_ampdu_tid_ini { - u8 tx_in_transit; /* number of pending mpdus in transit in driver */ - u8 tid; /* initiator tid for easy lookup */ - u8 txretry[AMPDU_TX_BA_MAX_WSIZE]; /* tx retry count; indexed by seq modulo */ - struct scb *scb; /* backptr for easy lookup */ - u8 ba_wsize; /* negotiated ba window size (in pdu) */ + u8 tx_in_transit; /* number of pending mpdus in transit in driver */ + u8 tid; /* initiator tid for easy lookup */ + /* tx retry count; indexed by seq modulo */ + u8 txretry[AMPDU_TX_BA_MAX_WSIZE]; + struct scb *scb; /* backptr for easy lookup */ + u8 ba_wsize; /* negotiated ba window size (in pdu) */ }; #define AMPDU_MAX_SCB_TID NUMPRIO @@ -43,9 +45,10 @@ struct scb_ampdu { u32 max_rx_ampdu_bytes; /* max ampdu rcv length; 8k, 16k, 32k, 64k */ struct pktq txq; /* sdu transmit queue pending aggregation */ - /* This could easily be a ini[] pointer and we keep this info in wl itself instead - * of having mac80211 hold it for us. Also could be made dynamic per tid instead of - * static. + /* + * This could easily be a ini[] pointer and we keep this info in wl + * itself instead of having mac80211 hold it for us. Also could be made + * dynamic per tid instead of static. */ /* initiator info - per tid (NUMPRIO): */ struct scb_ampdu_tid_ini ini[AMPDU_MAX_SCB_TID]; @@ -56,18 +59,18 @@ struct scb_ampdu { /* station control block - one per remote MAC address */ struct scb { u32 magic; - u32 flags; /* various bit flags as defined below */ - u32 flags2; /* various bit flags2 as defined below */ - u8 state; /* current state bitfield of auth/assoc process */ + u32 flags; /* various bit flags as defined below */ + u32 flags2; /* various bit flags2 as defined below */ + u8 state; /* current state bitfield of auth/assoc process */ u8 ea[ETH_ALEN]; /* station address */ void *fragbuf[NUMPRIO]; /* defragmentation buffer per prio */ - uint fragresid[NUMPRIO]; /* #bytes unused in frag buffer per prio */ + uint fragresid[NUMPRIO];/* #bytes unused in frag buffer per prio */ u16 seqctl[NUMPRIO]; /* seqctl of last received frame (for dups) */ - u16 seqctl_nonqos; /* seqctl of last received frame (for dups) for - * non-QoS data and management - */ - u16 seqnum[NUMPRIO]; /* WME: driver maintained sw seqnum per priority */ + /* seqctl of last received frame (for dups) for non-QoS data and + * management */ + u16 seqctl_nonqos; + u16 seqnum[NUMPRIO];/* WME: driver maintained sw seqnum per priority */ struct scb_ampdu scb_ampdu; /* AMPDU state including per tid info */ }; diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index bef43ea8ddb..40a315631b5 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -33,8 +33,10 @@ ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET)) #if defined(BCMDBG) -#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */ -#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */ +/* 500 ms after write enable/disable toggle */ +#define WRITE_ENABLE_DELAY 500 +/* 20 ms between each word write */ +#define WRITE_WORD_DELAY 20 #endif /* Maximum srom: 6 Kilobits == 768 bytes */ @@ -260,7 +262,8 @@ /* Temp sense related entries */ #define SROM8_MPWR_RAWTS 90 #define SROM8_TS_SLP_OPT_CORRX 91 -/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, IQSWP: IQ CAL swap disable */ +/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, + * IQSWP: IQ CAL swap disable */ #define SROM8_FOC_HWIQ_IQSWP 92 /* Temperature delta for PHY calibration */ @@ -349,14 +352,17 @@ #define SROM9_PO_LOFDM40DUP 203 /* SROM flags (see sromvar_t) */ -#define SRFL_MORE 1 /* value continues as described by the next entry */ + +/* value continues as described by the next entry */ +#define SRFL_MORE 1 #define SRFL_NOFFS 2 /* value bits can't be all one's */ #define SRFL_PRHEX 4 /* value is in hexdecimal format */ #define SRFL_PRSIGN 8 /* value is in signed decimal format */ #define SRFL_CCODE 0x10 /* value is in country code format */ #define SRFL_ETHADDR 0x20 /* value is an Ethernet address */ #define SRFL_LEDDC 0x40 /* value is an LED duty cycle */ -#define SRFL_NOVAR 0x80 /* do not generate a nvram param, entry is for mfgc */ +/* do not generate a nvram param, entry is for mfgc */ +#define SRFL_NOVAR 0x80 /* Max. nvram variable table size */ #define MAXSZ_NVRAM_VARS 4096 @@ -375,17 +381,18 @@ struct brcms_varbuf { unsigned int size; /* current (residual) size in bytes */ }; -/* Assumptions: - * - Ethernet address spans across 3 consective words +/* + * Assumptions: + * - Ethernet address spans across 3 consecutive words * * Table rules: - * - Add multiple entries next to each other if a value spans across multiple words - * (even multiple fields in the same word) with each entry except the last having - * it's SRFL_MORE bit set. - * - Ethernet address entry does not follow above rule and must not have SRFL_MORE - * bit set. Its SRFL_ETHADDR bit implies it takes multiple words. - * - The last entry's name field must be NULL to indicate the end of the table. Other - * entries must have non-NULL name. + * - Add multiple entries next to each other if a value spans across multiple + * words (even multiple fields in the same word) with each entry except the + * last having it's SRFL_MORE bit set. + * - Ethernet address entry does not follow above rule and must not have + * SRFL_MORE bit set. Its SRFL_ETHADDR bit implies it takes multiple words. + * - The last entry's name field must be NULL to indicate the end of the table. + * Other entries must have non-NULL name. */ static const struct brcms_sromvar pci_sromvars[] = { {"devid", 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, 0xffff}, @@ -810,12 +817,12 @@ static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) r = vsnprintf(b->buf, b->size, fmt, ap); va_end(ap); - /* C99 snprintf behavior returns r >= size on overflow, - * others return -1 on overflow. - * All return -1 on format error. - * We need to leave room for 2 null terminations, one for the current var - * string, and one for final null of the var table. So check that the - * strlen written, r, leaves room for 2 chars. + /* + * C99 snprintf behavior returns r >= size on overflow, + * others return -1 on overflow. All return -1 on format error. + * We need to leave room for 2 null terminations, one for the current + * var string, and one for final null of the var table. So check that + * the strlen written, r, leaves room for 2 chars. */ if ((r == -1) || (r > (int)(b->size - 2))) { b->size = 0; @@ -902,9 +909,10 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, if (check_crc) { if (buf[0] == 0xffff) - /* The hardware thinks that an srom that starts with 0xffff - * is blank, regardless of the rest of the content, so declare - * it bad. + /* + * The hardware thinks that an srom that starts with + * 0xffff is blank, regardless of the rest of the + * content, so declare it bad. */ return -ENODATA; @@ -1081,8 +1089,10 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) *(oncount >> 24) (offcount >> 8) */ else if (flags & SRFL_LEDDC) { - u32 w32 = (((val >> 8) & 0xff) << 24) | /* oncount */ - (((val & 0xff)) << 8); /* offcount */ + u32 w32 = /* oncount */ + (((val >> 8) & 0xff) << 24) | + /* offcount */ + (((val & 0xff)) << 8); varbuf_append(b, "leddc=%d", w32); } else if (flags & SRFL_PRHEX) varbuf_append(b, "%s=0x%x", name, val); @@ -1116,7 +1126,6 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) if (pb + srv->off < off) continue; - /* This entry is for mfgc only. Don't generate param for it, */ if (srv->flags & SRFL_NOVAR) continue; @@ -1124,8 +1133,8 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) val = (w & srv->mask) >> mask_shift(srv->mask); width = mask_width(srv->mask); - /* Cheating: no per-path var is more than 1 word */ - + /* Cheating: no per-path var is more than + * 1 word */ if ((srv->flags & SRFL_NOFFS) && ((int)val == (1 << width) - 1)) continue; @@ -1203,7 +1212,10 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, /* Bitmask for the sromrev */ sr = 1 << sromrev; - /* srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, 9 */ + /* + * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, + * 9 + */ if ((sr & 0x33e) == 0) { err = -EINVAL; goto errout; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 709c9a3d5ab..a4c5c637744 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -68,7 +68,10 @@ static void brcms_c_stf_stbc_rx_ht_update(struct brcms_c_info *wlc, int val) } } -/* every WLC_TEMPSENSE_PERIOD seconds temperature check to decide whether to turn on/off txchain */ +/* + * every WLC_TEMPSENSE_PERIOD seconds temperature check to decide whether to + * turn on/off txchain. + */ void brcms_c_tempsense_upd(struct brcms_c_info *wlc) { struct brcms_phy_pub *pi = wlc->band->pi; @@ -117,16 +120,19 @@ brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, /* criteria to choose stf mode */ - /* the "+3dbm (12 0.25db units)" is to account for the fact that with CDD, tx occurs - * on both chains + /* + * the "+3dbm (12 0.25db units)" is to account for the fact that with + * CDD, tx occurs on both chains */ if (power.target[siso_mcs_id] > (power.target[cdd_mcs_id] + 12)) setbit(ss_algo_channel, PHY_TXC1_MODE_SISO); else setbit(ss_algo_channel, PHY_TXC1_MODE_CDD); - /* STBC is ORed into to algo channel as STBC requires per-packet SCB capability check - * so cannot be default mode of operation. One of SISO, CDD have to be set + /* + * STBC is ORed into to algo channel as STBC requires per-packet SCB + * capability check so cannot be default mode of operation. One of + * SISO, CDD have to be set */ if (power.target[siso_mcs_id] <= (power.target[stbc_mcs_id] + 12)) setbit(ss_algo_channel, PHY_TXC1_MODE_STBC); @@ -229,7 +235,10 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) || !(txchain & wlc->stf->hw_txchain)) return -EINVAL; - /* if nrate override is configured to be non-SISO STF mode, reject reducing txchain to 1 */ + /* + * if nrate override is configured to be non-SISO STF mode, reject + * reducing txchain to 1 + */ txstreams = (u8) BRCMS_BITSCNT(txchain); if (txstreams > MAX_STREAMS_SUPPORTED) return -EINVAL; @@ -282,7 +291,10 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) return 0; } -/* update wlc->stf->ss_opmode which represents the operational stf_ss mode we're using */ +/* + * update wlc->stf->ss_opmode which represents the operational stf_ss mode + * we're using + */ int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band) { int ret_code = 0; @@ -291,7 +303,10 @@ int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band) prev_stf_ss = wlc->stf->ss_opmode; - /* NOTE: opmode can only be SISO or CDD as STBC is decided on a per-packet basis */ + /* + * NOTE: opmode can only be SISO or CDD as STBC is decided on a + * per-packet basis + */ if (BRCMS_STBC_CAP_PHY(wlc) && wlc->stf->ss_algosel_auto && (wlc->stf->ss_algo_channel != (u16) -1)) { @@ -333,7 +348,8 @@ int brcms_c_stf_attach(struct brcms_c_info *wlc) if (BRCMS_STBC_CAP_PHY(wlc)) { wlc->stf->ss_algosel_auto = true; - wlc->stf->ss_algo_channel = (u16) -1; /* Init the default value */ + /* Init the default value */ + wlc->stf->ss_algo_channel = (u16) -1; } return 0; } @@ -343,18 +359,20 @@ void brcms_c_stf_detach(struct brcms_c_info *wlc) } /* - * Centralized txant update function. call it whenever wlc->stf->txant and/or wlc->stf->txchain - * change + * Centralized txant update function. call it whenever wlc->stf->txant and/or + * wlc->stf->txchain change. * * Antennas are controlled by ucode indirectly, which drives PHY or GPIO to - * achieve various tx/rx antenna selection schemes + * achieve various tx/rx antenna selection schemes * - * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 means auto(last rx) - * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 means last rx and - * do tx-antenna selection for SISO transmissions - * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 means last rx and - * do tx-antenna selection for SISO transmissions - * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 means both cores active + * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 + * means auto(last rx). + * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 + * means last rx and do tx-antenna selection for SISO transmissions + * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 + * means last rx and do tx-antenna selection for SISO transmissions + * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 + * means both cores active */ static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) { diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index ab97718ea47..360795fed06 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -37,42 +37,71 @@ #define MAX_DMA_SEGS 4 /* boardflags */ -#define BFL_PACTRL 0x00000002 /* Board has gpio 9 controlling the PA */ -#define BFL_NOPLLDOWN 0x00000020 /* Not ok to power down the chip pll and oscillator */ -#define BFL_FEM 0x00000800 /* Board supports the Front End Module */ -#define BFL_EXTLNA 0x00001000 /* Board has an external LNA in 2.4GHz band */ -#define BFL_NOPA 0x00010000 /* Board has no PA */ -#define BFL_BUCKBOOST 0x00200000 /* Power topology uses BUCKBOOST */ -#define BFL_FEM_BT 0x00400000 /* Board has FEM and switch to share antenna w/ BT */ -#define BFL_NOCBUCK 0x00800000 /* Power topology doesn't use CBUCK */ -#define BFL_PALDO 0x02000000 /* Power topology uses PALDO */ -#define BFL_EXTLNA_5GHz 0x10000000 /* Board has an external LNA in 5GHz band */ + +/* Board has gpio 9 controlling the PA */ +#define BFL_PACTRL 0x00000002 +/* Not ok to power down the chip pll and oscillator */ +#define BFL_NOPLLDOWN 0x00000020 +/* Board supports the Front End Module */ +#define BFL_FEM 0x00000800 +/* Board has an external LNA in 2.4GHz band */ +#define BFL_EXTLNA 0x00001000 +/* Board has no PA */ +#define BFL_NOPA 0x00010000 +/* Power topology uses BUCKBOOST */ +#define BFL_BUCKBOOST 0x00200000 +/* Board has FEM and switch to share antenna w/ BT */ +#define BFL_FEM_BT 0x00400000 +/* Power topology doesn't use CBUCK */ +#define BFL_NOCBUCK 0x00800000 +/* Power topology uses PALDO */ +#define BFL_PALDO 0x02000000 +/* Board has an external LNA in 5GHz band */ +#define BFL_EXTLNA_5GHz 0x10000000 /* boardflags2 */ -#define BFL2_RXBB_INT_REG_DIS 0x00000001 /* Board has an external rxbb regulator */ -#define BFL2_APLL_WAR 0x00000002 /* Flag to implement alternative A-band PLL settings */ -#define BFL2_TXPWRCTRL_EN 0x00000004 /* Board permits enabling TX Power Control */ -#define BFL2_2X4_DIV 0x00000008 /* Board supports the 2X4 diversity switch */ -#define BFL2_5G_PWRGAIN 0x00000010 /* Board supports 5G band power gain */ -#define BFL2_PCIEWAR_OVR 0x00000020 /* Board overrides ASPM and Clkreq settings */ -#define BFL2_LEGACY 0x00000080 -#define BFL2_SKWRKFEM_BRD 0x00000100 /* 4321mcm93 board uses Skyworks FEM */ -#define BFL2_SPUR_WAR 0x00000200 /* Board has a WAR for clock-harmonic spurs */ -#define BFL2_GPLL_WAR 0x00000400 /* Flag to narrow G-band PLL loop b/w */ -#define BFL2_SINGLEANT_CCK 0x00001000 /* Tx CCK pkts on Ant 0 only */ -#define BFL2_2G_SPUR_WAR 0x00002000 /* WAR to reduce and avoid clock-harmonic spurs in 2G */ -#define BFL2_GPLL_WAR2 0x00010000 /* Flag to widen G-band PLL loop b/w */ -#define BFL2_IPALVLSHIFT_3P3 0x00020000 -#define BFL2_INTERNDET_TXIQCAL 0x00040000 /* Use internal envelope detector for TX IQCAL */ -#define BFL2_XTALBUFOUTEN 0x00080000 /* Keep the buffered Xtal output from radio "ON" - * Most drivers will turn it off without this flag - * to save power. - */ -/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */ -#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */ -#define BOARD_GPIO_12 0x1000 /* gpio 12 */ -#define BOARD_GPIO_13 0x2000 /* gpio 13 */ +/* Board has an external rxbb regulator */ +#define BFL2_RXBB_INT_REG_DIS 0x00000001 +/* Flag to implement alternative A-band PLL settings */ +#define BFL2_APLL_WAR 0x00000002 +/* Board permits enabling TX Power Control */ +#define BFL2_TXPWRCTRL_EN 0x00000004 +/* Board supports the 2X4 diversity switch */ +#define BFL2_2X4_DIV 0x00000008 +/* Board supports 5G band power gain */ +#define BFL2_5G_PWRGAIN 0x00000010 +/* Board overrides ASPM and Clkreq settings */ +#define BFL2_PCIEWAR_OVR 0x00000020 +#define BFL2_LEGACY 0x00000080 +/* 4321mcm93 board uses Skyworks FEM */ +#define BFL2_SKWRKFEM_BRD 0x00000100 +/* Board has a WAR for clock-harmonic spurs */ +#define BFL2_SPUR_WAR 0x00000200 +/* Flag to narrow G-band PLL loop b/w */ +#define BFL2_GPLL_WAR 0x00000400 +/* Tx CCK pkts on Ant 0 only */ +#define BFL2_SINGLEANT_CCK 0x00001000 +/* WAR to reduce and avoid clock-harmonic spurs in 2G */ +#define BFL2_2G_SPUR_WAR 0x00002000 +/* Flag to widen G-band PLL loop b/w */ +#define BFL2_GPLL_WAR2 0x00010000 +#define BFL2_IPALVLSHIFT_3P3 0x00020000 +/* Use internal envelope detector for TX IQCAL */ +#define BFL2_INTERNDET_TXIQCAL 0x00040000 +/* Keep the buffered Xtal output from radio "ON". Most drivers will turn it + * off without this flag to save power. */ +#define BFL2_XTALBUFOUTEN 0x00080000 + +/* + * board specific GPIO assignment, gpio 0-3 are also customer-configurable + * led + */ + +/* bit 9 controls the PA on new 4306 boards */ +#define BOARD_GPIO_PACTRL 0x200 +#define BOARD_GPIO_12 0x1000 +#define BOARD_GPIO_13 0x2000 /* **** Core type/rev defaults **** */ #define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27 @@ -152,25 +181,53 @@ #define PHYCONF_HAS(val) CONF_HAS(PHYTYPE, val) #define PHYCONF_IS(val) CONF_IS(PHYTYPE, val) -#define NREV_IS(var, val) (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val)))) -#define NREV_GE(var, val) (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val)))) -#define NREV_GT(var, val) (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val)))) -#define NREV_LT(var, val) (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val)))) -#define NREV_LE(var, val) (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val)))) +#define NREV_IS(var, val) \ + (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val)))) -#define LCNREV_IS(var, val) (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val)))) -#define LCNREV_GE(var, val) (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val)))) -#define LCNREV_GT(var, val) (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val)))) -#define LCNREV_LT(var, val) (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val)))) -#define LCNREV_LE(var, val) (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val)))) +#define NREV_GE(var, val) \ + (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val)))) -#define D11REV_IS(var, val) (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val)))) -#define D11REV_GE(var, val) (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val)))) -#define D11REV_GT(var, val) (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val)))) -#define D11REV_LT(var, val) (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val)))) -#define D11REV_LE(var, val) (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val)))) +#define NREV_GT(var, val) \ + (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val)))) -#define PHYTYPE_IS(var, val) (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val)))) +#define NREV_LT(var, val) \ + (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val)))) + +#define NREV_LE(var, val) \ + (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val)))) + +#define LCNREV_IS(var, val) \ + (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val)))) + +#define LCNREV_GE(var, val) \ + (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val)))) + +#define LCNREV_GT(var, val) \ + (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val)))) + +#define LCNREV_LT(var, val) \ + (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val)))) + +#define LCNREV_LE(var, val) \ + (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val)))) + +#define D11REV_IS(var, val) \ + (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val)))) + +#define D11REV_GE(var, val) \ + (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val)))) + +#define D11REV_GT(var, val) \ + (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val)))) + +#define D11REV_LT(var, val) \ + (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val)))) + +#define D11REV_LE(var, val) \ + (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val)))) + +#define PHYTYPE_IS(var, val)\ + (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val)))) /* Finally, early-exit from switch case if anyone wants it... */ @@ -213,11 +270,18 @@ * * *********************************************** */ -#define NTXD 256 /* Max # of entries in Tx FIFO based on 4kb page size */ -#define NRXD 256 /* Max # of entries in Rx FIFO based on 4kb page size */ -#define NRXBUFPOST 32 /* try to keep this # rbufs posted to the chip */ -#define MAXSCB 32 /* Maximum SCBs in cache for STA */ -#define AMPDU_NUM_MPDU 16 /* max allowed number of mpdus in an ampdu (2 streams) */ + +/* Max # of entries in Tx FIFO based on 4kb page size */ +#define NTXD 256 +/* Max # of entries in Rx FIFO based on 4kb page size */ +#define NRXD 256 +/* try to keep this # rbufs posted to the chip */ +#define NRXBUFPOST 32 +/* Maximum SCBs in cache for STA */ +#define MAXSCB 32 + +/* max allowed number of mpdus in an ampdu (2 streams) */ +#define AMPDU_NUM_MPDU 16 /* Count of packet callback structures. either of following * 1. Set to the number of SCBs since a STA @@ -242,8 +306,8 @@ #define BRCMS_AMPDUDATAHIWAT 255 /* bounded rx loops */ -#define RXBND 8 /* max # frames to process in brcms_c_recv() */ -#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ +#define RXBND 8 /* max # frames to process in brcms_c_recv() */ +#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ #define BAND_5G(bt) ((bt) == BRCM_BAND_5G) #define BAND_2G(bt) ((bt) == BRCM_BAND_2G) @@ -351,9 +415,13 @@ do { \ W_REG((r), ((R_REG(r) & ~(mask)) | (val))) /* multi-bool data type: set of bools, mbool is true if any is set */ -#define mboolset(mb, bit) ((mb) |= (bit)) /* set one bool */ -#define mboolclr(mb, bit) ((mb) &= ~(bit)) /* clear one bool */ -#define mboolisset(mb, bit) (((mb) & (bit)) != 0) /* true if one bool is set */ + +/* set one bool */ +#define mboolset(mb, bit) ((mb) |= (bit)) +/* clear one bool */ +#define mboolclr(mb, bit) ((mb) &= ~(bit)) +/* true if one bool is set */ +#define mboolisset(mb, bit) (((mb) & (bit)) != 0) #define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) /* forward declarations */ From 76890e69baa3956c3faf170479027a92d74cbf91 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:44 +0200 Subject: [PATCH 0082/1519] staging: brcm80211: remove wl_alloc_dma_resources() function The function wl_alloc_dma_resources() does not provide any value for the brcmsmac driver as it only returns true. It has been removed from the driver. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 8 -------- drivers/staging/brcm80211/brcmsmac/mac80211_if.h | 1 - drivers/staging/brcm80211/brcmsmac/main.c | 6 ------ 3 files changed, 15 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 0af60414d9e..c66b67f900f 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -1444,14 +1444,6 @@ void brcms_intrson(struct brcms_info *wl) INT_UNLOCK(wl, flags); } -/* - * precondition: perimeter lock has been acquired - */ -bool wl_alloc_dma_resources(struct brcms_info *wl, uint addrwidth) -{ - return true; -} - u32 brcms_intrsoff(struct brcms_info *wl) { unsigned long flags; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 0d913664355..01fce542f23 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -87,7 +87,6 @@ extern int brcms_up(struct brcms_info *wl); extern void brcms_down(struct brcms_info *wl); extern void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif, bool state, int prio); -extern bool wl_alloc_dma_resources(struct brcms_info *wl, uint dmaddrwidth); extern bool brcms_rfkill_set_hw_state(struct brcms_info *wl); /* timer functions */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d1a8388073a..d2551e970e5 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -870,12 +870,6 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) addrwidth = dma_addrwidth(wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 0)); - if (!wl_alloc_dma_resources(wlc_hw->wlc->wl, addrwidth)) { - wiphy_err(wiphy, "wl%d: wlc_attach: alloc_dma_" - "resources failed\n", unit); - return false; - } - /* * FIFO 0 * TX: TX_AC_BK_FIFO (TX AC Background data packets) From 50206949c3ead36f21f38d26fc20122bc40779d6 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:45 +0200 Subject: [PATCH 0083/1519] staging: brcm80211: remove dma_addrwidth() function The function dma_addrwidth() always returns the same value so it is redundant. As such it has been removed. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 23 ----------------------- drivers/staging/brcm80211/brcmsmac/dma.h | 6 ------ drivers/staging/brcm80211/brcmsmac/main.c | 7 ------- 3 files changed, 36 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index e6620237105..27b07ce854d 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -159,15 +159,9 @@ #define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1 */ #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /* core-dependent data type */ -#define DMADDRWIDTH_30 30 /* 30-bit addressing capability */ -#define DMADDRWIDTH_32 32 /* 32-bit addressing capability */ -#define DMADDRWIDTH_63 63 /* 64-bit addressing capability */ -#define DMADDRWIDTH_64 64 /* 64-bit addressing capability */ - #define DMA64_DD_PARITY(dd) \ parity32((dd)->addrlow ^ (dd)->addrhigh ^ (dd)->ctrl1 ^ (dd)->ctrl2) - /* * packet headroom necessary to accommodate the largest header * in the system, (i.e TXOFF). By doing, we avoid the need to @@ -1936,23 +1930,6 @@ static void dma64_txrotate(struct dma_info *di) di->xmtptrbase + I2B(di->txout, struct dma64desc)); } -uint dma_addrwidth(struct si_pub *sih, void *dmaregs) -{ - /* Perform 64-bit checks only if we want to advertise 64-bit (> 32bit) capability) */ - /* DMA engine is 64-bit capable */ - if ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64) { - /* backplane are 64-bit capable */ - if (ai_backplane64(sih)) - /* If bus is System Backplane or PCIE then we can access 64-bits */ - if ((sih->bustype == SI_BUS) || - ((sih->bustype == PCI_BUS) && - (sih->buscoretype == PCIE_CORE_ID))) - return DMADDRWIDTH_64; - } - /* DMA hardware not supported by this driver */ - return DMADDRWIDTH_64; -} - /* * Mac80211 initiated actions sometimes require packets in the DMA queue to be * modified. The modified portion of the packet is not under control of the DMA diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 4a330284dcc..f75a0201d82 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -178,12 +178,6 @@ extern const struct di_fcn_s dma64proc; #define dma_txcommitted(di) (dma64proc.txcommitted(di)) -/* return addresswidth allowed - * This needs to be done after SB attach but before dma attach. - * SB attach provides ability to probe backplane and dma core capabilities - * This info is needed by DMA_ALLOC_CONSISTENT in dma attach - */ -extern uint dma_addrwidth(struct si_pub *sih, void *dmaregs); void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) (void *pkt, void *arg_a), void *arg_a); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d2551e970e5..e7a166f64f1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -861,14 +861,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) snprintf(name, sizeof(name), "wl%d", unit); if (wlc_hw->di[0] == 0) { /* Init FIFOs */ - uint addrwidth; int dma_attach_err = 0; - /* Find out the DMA addressing capability and let OS know - * All the channels within one DMA core have 'common-minimum' same - * capability - */ - addrwidth = - dma_addrwidth(wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 0)); /* * FIFO 0 From a4a94142131676c34f53b45d2d601d8a6094492f Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:46 +0200 Subject: [PATCH 0084/1519] staging: brcm80211: revert removal of atomic initialization The commit "staging: brcm80211: remove code for unsupported chip" unintentionally got rid of initialization of the atomic variable brcmf_mmc_suspend. The patch restore that particular piece of code. Reported-by: Dan Carpenter Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 16ea6e87cfa..2a9efc30d85 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -980,6 +980,8 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, return -ENOMEM; sdiodev->func1 = func; dev_set_drvdata(&func->card->dev, sdiodev); + + atomic_set(&brcmf_mmc_suspend, false); } gInstance->func[func->num] = func; From 28e3edfedf86fbc1274d666b6445fb3098f337a7 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:47 +0200 Subject: [PATCH 0085/1519] staging: brcm80211: cleaned up softmac DMA layer Code cleanup. Since this driver only needs to support 64 bit DMA hardware, an unnecessary layer of abstraction could be removed. Also DMA functions that were not called have been removed. Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 461 +++-------------------- drivers/staging/brcm80211/brcmsmac/dma.h | 114 +----- 2 files changed, 58 insertions(+), 517 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 27b07ce854d..48a053cb8f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -364,30 +364,10 @@ struct dma_info { static bool _dma_isaddrext(struct dma_info *di); static bool _dma_descriptor_align(struct dma_info *di); static bool _dma_alloc(struct dma_info *di, uint direction); -static void _dma_detach(struct dma_info *di); static void _dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa); -static void _dma_rxinit(struct dma_info *di); -static void *_dma_rx(struct dma_info *di); -static bool _dma_rxfill(struct dma_info *di); -static void _dma_rxreclaim(struct dma_info *di); static void _dma_rxenable(struct dma_info *di); static void *_dma_getnextrxp(struct dma_info *di, bool forceall); -static void _dma_rx_param_get(struct dma_info *di, u16 *rxoffset, - u16 *rxbufsize); - -static void _dma_txblock(struct dma_info *di); -static void _dma_txunblock(struct dma_info *di); -static uint _dma_txactive(struct dma_info *di); -static uint _dma_rxactive(struct dma_info *di); -static uint _dma_txpending(struct dma_info *di); -static uint _dma_txcommitted(struct dma_info *di); - -static void *_dma_peeknexttxp(struct dma_info *di); -static void *_dma_peeknextrxp(struct dma_info *di); -static unsigned long _dma_getvar(struct dma_info *di, const char *name); -static void _dma_counterreset(struct dma_info *di); -static void _dma_fifoloopbackenable(struct dma_info *di); static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, @@ -396,78 +376,12 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, /* Prototypes for 64-bit routines */ static bool dma64_alloc(struct dma_info *di, uint direction); -static bool dma64_txreset(struct dma_info *di); -static bool dma64_rxreset(struct dma_info *di); -static bool dma64_txsuspendedidle(struct dma_info *di); -static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, bool commit); -static int dma64_txunframed(struct dma_info *di, void *p0, uint len, - bool commit); -static void *dma64_getpos(struct dma_info *di, bool direction); -static void *dma64_getnexttxp(struct dma_info *di, enum txd_range range); static void *dma64_getnextrxp(struct dma_info *di, bool forceall); -static void dma64_txrotate(struct dma_info *di); - static bool dma64_rxidle(struct dma_info *di); -static void dma64_txinit(struct dma_info *di); -static bool dma64_txenabled(struct dma_info *di); -static void dma64_txsuspend(struct dma_info *di); -static void dma64_txresume(struct dma_info *di); -static bool dma64_txsuspended(struct dma_info *di); -static void dma64_txreclaim(struct dma_info *di, enum txd_range range); -static bool dma64_txstopped(struct dma_info *di); -static bool dma64_rxstopped(struct dma_info *di); -static bool dma64_rxenabled(struct dma_info *di); static bool _dma64_addrext(struct dma64regs *dma64regs); static inline u32 parity32(u32 data); -const struct di_fcn_s dma64proc = { - (void (*)(struct dma_pub *)) _dma_detach, - (void (*)(struct dma_pub *)) dma64_txinit, - (bool(*)(struct dma_pub *)) dma64_txreset, - (bool(*)(struct dma_pub *)) dma64_txenabled, - (void (*)(struct dma_pub *)) dma64_txsuspend, - (void (*)(struct dma_pub *)) dma64_txresume, - (bool(*)(struct dma_pub *)) dma64_txsuspended, - (bool(*)(struct dma_pub *)) dma64_txsuspendedidle, - (int (*)(struct dma_pub *, struct sk_buff *, bool)) dma64_txfast, - (int (*)(struct dma_pub *, void *, uint, bool)) dma64_txunframed, - (void *(*)(struct dma_pub *, bool)) dma64_getpos, - (bool(*)(struct dma_pub *)) dma64_txstopped, - (void (*)(struct dma_pub *, enum txd_range)) dma64_txreclaim, - (void *(*)(struct dma_pub *, enum txd_range)) dma64_getnexttxp, - (void *(*)(struct dma_pub *)) _dma_peeknexttxp, - (void (*)(struct dma_pub *)) _dma_txblock, - (void (*)(struct dma_pub *)) _dma_txunblock, - (uint (*)(struct dma_pub *)) _dma_txactive, - (void (*)(struct dma_pub *)) dma64_txrotate, - - (void (*)(struct dma_pub *)) _dma_rxinit, - (bool(*)(struct dma_pub *)) dma64_rxreset, - (bool(*)(struct dma_pub *)) dma64_rxidle, - (bool(*)(struct dma_pub *)) dma64_rxstopped, - (bool(*)(struct dma_pub *)) _dma_rxenable, - (bool(*)(struct dma_pub *)) dma64_rxenabled, - (void *(*)(struct dma_pub *)) _dma_rx, - (bool(*)(struct dma_pub *)) _dma_rxfill, - (void (*)(struct dma_pub *)) _dma_rxreclaim, - (void *(*)(struct dma_pub *, bool)) _dma_getnextrxp, - (void *(*)(struct dma_pub *)) _dma_peeknextrxp, - (void (*)(struct dma_pub *, u16 *, u16 *)) _dma_rx_param_get, - - (void (*)(struct dma_pub *)) _dma_fifoloopbackenable, - (unsigned long (*)(struct dma_pub *, const char *)) _dma_getvar, - (void (*)(struct dma_pub *)) _dma_counterreset, - (uint (*)(struct dma_pub *, uint, uint)) _dma_ctrlflags, - NULL, - NULL, - NULL, - (uint (*)(struct dma_pub *)) _dma_rxactive, - (uint (*)(struct dma_pub *)) _dma_txpending, - (uint (*)(struct dma_pub *)) _dma_txcommitted, - 39 -}; - struct dma_pub *dma_attach(char *name, struct si_pub *sih, void *dmaregstx, void *dmaregsrx, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, @@ -493,15 +407,13 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, /* init dma reg pointer */ di->d64txregs = (struct dma64regs *) dmaregstx; di->d64rxregs = (struct dma64regs *) dmaregsrx; - di->dma.di_fn = (const struct di_fcn_s *)&dma64proc; /* * Default flags (which can be changed by the driver calling * dma_ctrlflags before enable): For backwards compatibility * both Rx Overflow Continue and Parity are DISABLED. */ - di->dma.di_fn->ctrlflags(&di->dma, DMA_CTRL_ROC | DMA_CTRL_PEN, - 0); + _dma_ctrlflags(di, DMA_CTRL_ROC | DMA_CTRL_PEN, 0); DMA_TRACE(("%s: dma_attach: %s flags 0x%x ntxd %d nrxd %d " "rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d " @@ -654,7 +566,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, return (struct dma_pub *) di; fail: - _dma_detach(di); + dma_detach((struct dma_pub *)di); return NULL; } @@ -730,8 +642,9 @@ void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, } /* !! may be called with core in reset */ -static void _dma_detach(struct dma_info *di) +void dma_detach(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; DMA_TRACE(("%s: dma_detach\n", di->name)); @@ -854,15 +767,10 @@ _dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa) } } -static void _dma_fifoloopbackenable(struct dma_info *di) +void dma_rxinit(struct dma_pub *pub) { - DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name)); + struct dma_info *di = (struct dma_info *)pub; - OR_REG(&di->d64txregs->control, D64_XC_LE); -} - -static void _dma_rxinit(struct dma_info *di) -{ DMA_TRACE(("%s: dma_rxinit\n", di->name)); if (di->nrxd == 0) @@ -907,14 +815,6 @@ static void _dma_rxenable(struct dma_info *di) ((di->rxoffset << D64_RC_RO_SHIFT) | control)); } -static void -_dma_rx_param_get(struct dma_info *di, u16 *rxoffset, u16 *rxbufsize) -{ - /* the normal values fit into 16 bits */ - *rxoffset = (u16) di->rxoffset; - *rxbufsize = (u16) di->rxbufsize; -} - /* * !! rx entry routine * returns a pointer to the next frame received, or NULL if there are no more @@ -925,8 +825,9 @@ _dma_rx_param_get(struct dma_info *di, u16 *rxoffset, u16 *rxbufsize) * buffer data. After it reaches the max size of buffer, the data continues * in next DMA descriptor buffer WITHOUT DMA header */ -static void *_dma_rx(struct dma_info *di) +void *dma_rx(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; struct sk_buff *p, *head, *tail; uint len; uint pkt_len; @@ -966,7 +867,7 @@ static void *_dma_rx(struct dma_info *di) D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); - DMA_ERROR(("_dma_rx, rxin %d rxout %d, hw_curr %d\n", + DMA_ERROR(("dma_rx, rxin %d rxout %d, hw_curr %d\n", di->rxin, di->rxout, cur)); } #endif /* BCMDBG */ @@ -989,8 +890,9 @@ static void *_dma_rx(struct dma_info *di) * the rx dma and user might want to call rxfill again asap. This unlikely * happens on memory-rich NIC, but often on memory-constrained dongle */ -static bool _dma_rxfill(struct dma_info *di) +bool dma_rxfill(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; struct sk_buff *p; u16 rxin, rxout; u32 flags = 0; @@ -1074,48 +976,9 @@ static bool _dma_rxfill(struct dma_info *di) return ring_empty; } -/* like getnexttxp but no reclaim */ -static void *_dma_peeknexttxp(struct dma_info *di) -{ - uint end, i; - - if (di->ntxd == 0) - return NULL; - - end = - B2I(((R_REG(&di->d64txregs->status0) & - D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, - struct dma64desc); - - for (i = di->txin; i != end; i = NEXTTXD(i)) - if (di->txp[i]) - return di->txp[i]; - - return NULL; -} - -/* like getnextrxp but not take off the ring */ -static void *_dma_peeknextrxp(struct dma_info *di) -{ - uint end, i; - - if (di->nrxd == 0) - return NULL; - - end = - B2I(((R_REG(&di->d64rxregs->status0) & - D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, - struct dma64desc); - - for (i = di->rxin; i != end; i = NEXTRXD(i)) - if (di->rxp[i]) - return di->rxp[i]; - - return NULL; -} - -static void _dma_rxreclaim(struct dma_info *di) +void dma_rxreclaim(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; void *p; DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); @@ -1132,57 +995,12 @@ static void *_dma_getnextrxp(struct dma_info *di, bool forceall) return dma64_getnextrxp(di, forceall); } -static void _dma_txblock(struct dma_info *di) +void dma_counterreset(struct dma_pub *pub) { - di->dma.txavail = 0; -} - -static void _dma_txunblock(struct dma_info *di) -{ - di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; -} - -static uint _dma_txactive(struct dma_info *di) -{ - return NTXDACTIVE(di->txin, di->txout); -} - -static uint _dma_txpending(struct dma_info *di) -{ - uint curr; - - curr = - B2I(((R_REG(&di->d64txregs->status0) & - D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, - struct dma64desc); - - return NTXDACTIVE(curr, di->txout); -} - -static uint _dma_txcommitted(struct dma_info *di) -{ - uint ptr; - uint txin = di->txin; - - if (txin == di->txout) - return 0; - - ptr = B2I(R_REG(&di->d64txregs->ptr), struct dma64desc); - - return NTXDACTIVE(di->txin, ptr); -} - -static uint _dma_rxactive(struct dma_info *di) -{ - return NRXDACTIVE(di->rxin, di->rxout); -} - -static void _dma_counterreset(struct dma_info *di) -{ - /* reset all software counter */ - di->dma.rxgiants = 0; - di->dma.rxnobuf = 0; - di->dma.txnobuf = 0; + /* reset all software counters */ + pub->rxgiants = 0; + pub->rxnobuf = 0; + pub->txnobuf = 0; } static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) @@ -1221,8 +1039,10 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) } /* get the address of the var in order to change later */ -static unsigned long _dma_getvar(struct dma_info *di, const char *name) +unsigned long dma_getvar(struct dma_pub *pub, const char *name) { + struct dma_info *di = (struct dma_info *)pub; + if (!strcmp(name, "&txavail")) return (unsigned long)&(di->dma.txavail); return 0; @@ -1269,8 +1089,9 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, /* 64-bit DMA functions */ -static void dma64_txinit(struct dma_info *di) +void dma_txinit(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; u32 control = D64_XC_XE; DMA_TRACE(("%s: dma_txinit\n", di->name)); @@ -1301,17 +1122,10 @@ static void dma64_txinit(struct dma_info *di) _dma_ddtable_init(di, DMA_TX, di->txdpa); } -static bool dma64_txenabled(struct dma_info *di) +void dma_txsuspend(struct dma_pub *pub) { - u32 xc; + struct dma_info *di = (struct dma_info *)pub; - /* If the chip is dead, it is not enabled :-) */ - xc = R_REG(&di->d64txregs->control); - return (xc != 0xffffffff) && (xc & D64_XC_XE); -} - -static void dma64_txsuspend(struct dma_info *di) -{ DMA_TRACE(("%s: dma_txsuspend\n", di->name)); if (di->ntxd == 0) @@ -1320,8 +1134,10 @@ static void dma64_txsuspend(struct dma_info *di) OR_REG(&di->d64txregs->control, D64_XC_SE); } -static void dma64_txresume(struct dma_info *di) +void dma_txresume(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; + DMA_TRACE(("%s: dma_txresume\n", di->name)); if (di->ntxd == 0) @@ -1330,15 +1146,18 @@ static void dma64_txresume(struct dma_info *di) AND_REG(&di->d64txregs->control, ~D64_XC_SE); } -static bool dma64_txsuspended(struct dma_info *di) +bool dma_txsuspended(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; + return (di->ntxd == 0) || ((R_REG(&di->d64txregs->control) & D64_XC_SE) == D64_XC_SE); } -static void dma64_txreclaim(struct dma_info *di, enum txd_range range) +void dma_txreclaim(struct dma_pub *pub, enum txd_range range) { + struct dma_info *di = (struct dma_info *)pub; void *p; DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, @@ -1350,25 +1169,13 @@ static void dma64_txreclaim(struct dma_info *di, enum txd_range range) if (di->txin == di->txout) return; - while ((p = dma64_getnexttxp(di, range))) { + while ((p = dma_getnexttxp(pub, range))) { /* For unframed data, we don't have any packets to free */ if (!(di->dma.dmactrlflags & DMA_CTRL_UNFRAMED)) brcmu_pkt_buf_free_skb(p); } } -static bool dma64_txstopped(struct dma_info *di) -{ - return ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == - D64_XS0_XS_STOPPED); -} - -static bool dma64_rxstopped(struct dma_info *di) -{ - return ((R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK) == - D64_RS0_RS_STOPPED); -} - static bool dma64_alloc(struct dma_info *di, uint direction) { u16 size; @@ -1421,8 +1228,9 @@ static bool dma64_alloc(struct dma_info *di, uint direction) return true; } -static bool dma64_txreset(struct dma_info *di) +bool dma_txreset(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; u32 status; if (di->ntxd == 0) @@ -1457,8 +1265,9 @@ static bool dma64_rxidle(struct dma_info *di) (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); } -static bool dma64_rxreset(struct dma_info *di) +bool dma_rxreset(struct dma_pub *pub) { + struct dma_info *di = (struct dma_info *)pub; u32 status; if (di->nrxd == 0) @@ -1472,128 +1281,15 @@ static bool dma64_rxreset(struct dma_info *di) return status == D64_RS0_RS_DISABLED; } -static bool dma64_rxenabled(struct dma_info *di) -{ - u32 rc; - - rc = R_REG(&di->d64rxregs->control); - return (rc != 0xffffffff) && (rc & D64_RC_RE); -} - -static bool dma64_txsuspendedidle(struct dma_info *di) -{ - - if (di->ntxd == 0) - return true; - - if (!(R_REG(&di->d64txregs->control) & D64_XC_SE)) - return 0; - - if ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == - D64_XS0_XS_IDLE) - return 1; - - return 0; -} - -/* - * Useful when sending unframed data. This allows us to get a progress report - * from the DMA. We return a pointer to the beginning of the DATA buffer of the - * current descriptor. If DMA is idle, we return NULL. - */ -static void *dma64_getpos(struct dma_info *di, bool direction) -{ - void *va; - bool idle; - u32 cd_offset; - - if (direction == DMA_TX) { - cd_offset = - R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK; - idle = !NTXDACTIVE(di->txin, di->txout); - va = di->txp[B2I(cd_offset, struct dma64desc)]; - } else { - cd_offset = - R_REG(&di->d64rxregs->status0) & D64_XS0_CD_MASK; - idle = !NRXDACTIVE(di->rxin, di->rxout); - va = di->rxp[B2I(cd_offset, struct dma64desc)]; - } - - /* If DMA is IDLE, return NULL */ - if (idle) { - DMA_TRACE(("%s: DMA idle, return NULL\n", __func__)); - va = NULL; - } - - return va; -} - -/* TX of unframed data - * - * Adds a DMA ring descriptor for the data pointed to by "buf". - * This is for DMA of a buffer of data and is unlike other dma TX functions - * that take a pointer to a "packet" - * Each call to this is results in a single descriptor being added for "len" - * bytes of data starting at "buf", it doesn't handle chained buffers. - */ -static int -dma64_txunframed(struct dma_info *di, void *buf, uint len, bool commit) -{ - u16 txout; - u32 flags = 0; - unsigned long pa; /* phys addr */ - - txout = di->txout; - - /* return nonzero if out of tx descriptors */ - if (NEXTTXD(txout) == di->txin) - goto outoftxd; - - if (len == 0) - return 0; - - pa = pci_map_single(di->pbus, buf, len, PCI_DMA_TODEVICE); - - flags = (D64_CTRL1_SOF | D64_CTRL1_IOC | D64_CTRL1_EOF); - - if (txout == (di->ntxd - 1)) - flags |= D64_CTRL1_EOT; - - dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - - /* save the buffer pointer - used by dma_getpos */ - di->txp[txout] = buf; - - txout = NEXTTXD(txout); - /* bump the tx descriptor index */ - di->txout = txout; - - /* kick the chip */ - if (commit) - W_REG(&di->d64txregs->ptr, - di->xmtptrbase + I2B(txout, struct dma64desc)); - - /* tx flow control */ - di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; - - return 0; - - outoftxd: - DMA_ERROR(("%s: %s: out of txds !!!\n", di->name, __func__)); - di->dma.txavail = 0; - di->dma.txnobuf++; - return -1; -} - /* * !! tx entry routine * WARNING: call must check the return value for error. * the error(toss frames) could be fatal and cause many subsequent hard * to debug problems */ -static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, - bool commit) +int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) { + struct dma_info *di = (struct dma_info *)pub; struct sk_buff *p, *next; unsigned char *data; uint len; @@ -1713,8 +1409,9 @@ static int dma64_txfast(struct dma_info *di, struct sk_buff *p0, * If range is DMA_RANGE_ALL, reclaim all txd(s) posted to the ring and * return associated packet regardless of the value of hardware pointers. */ -static void *dma64_getnexttxp(struct dma_info *di, enum txd_range range) +void *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) { + struct dma_info *di = (struct dma_info *)pub; u16 start, end, i; u16 active_desc; void *txp; @@ -1856,80 +1553,6 @@ static bool _dma64_addrext(struct dma64regs *dma64regs) return (w & D64_XC_AE) == D64_XC_AE; } -/* - * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin). - */ -static void dma64_txrotate(struct dma_info *di) -{ - u16 ad; - uint nactive; - uint rot; - u16 old, new; - u32 w; - u16 first, last; - - nactive = _dma_txactive(di); - ad = (u16) (B2I((((R_REG(&di->d64txregs->status1) & - D64_XS1_AD_MASK) - di->xmtptrbase) & - D64_XS1_AD_MASK), struct dma64desc)); - rot = TXD(ad - di->txin); - - /* full-ring case is a lot harder - don't worry about this */ - if (rot >= (di->ntxd - nactive)) { - DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name)); - return; - } - - first = di->txin; - last = PREVTXD(di->txout); - - /* move entries starting at last and moving backwards to first */ - for (old = last; old != PREVTXD(first); old = PREVTXD(old)) { - new = TXD(old + rot); - - /* - * Move the tx dma descriptor. - * EOT is set only in the last entry in the ring. - */ - w = BUS_SWAP32(R_SM(&di->txd64[old].ctrl1)) & ~D64_CTRL1_EOT; - if (new == (di->ntxd - 1)) - w |= D64_CTRL1_EOT; - W_SM(&di->txd64[new].ctrl1, BUS_SWAP32(w)); - - w = BUS_SWAP32(R_SM(&di->txd64[old].ctrl2)); - W_SM(&di->txd64[new].ctrl2, BUS_SWAP32(w)); - - W_SM(&di->txd64[new].addrlow, R_SM(&di->txd64[old].addrlow)); - W_SM(&di->txd64[new].addrhigh, R_SM(&di->txd64[old].addrhigh)); - - /* zap the old tx dma descriptor address field */ - W_SM(&di->txd64[old].addrlow, BUS_SWAP32(0xdeadbeef)); - W_SM(&di->txd64[old].addrhigh, BUS_SWAP32(0xdeadbeef)); - - /* move the corresponding txp[] entry */ - di->txp[new] = di->txp[old]; - - /* Move the map */ - if (DMASGLIST_ENAB) { - memcpy(&di->txp_dmah[new], &di->txp_dmah[old], - sizeof(struct dma_seg_map)); - memset(&di->txp_dmah[old], 0, - sizeof(struct dma_seg_map)); - } - - di->txp[old] = NULL; - } - - /* update txin and txout */ - di->txin = ad; - di->txout = TXD(di->txout + rot); - di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; - - /* kick the chip */ - W_REG(&di->d64txregs->ptr, - di->xmtptrbase + I2B(di->txout, struct dma64desc)); -} - /* * Mac80211 initiated actions sometimes require packets in the DMA queue to be * modified. The modified portion of the packet is not under control of the DMA diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index f75a0201d82..3b2351779f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -59,66 +59,11 @@ enum txd_range { DMA_RANGE_TRANSFERED }; -/* dma opsvec */ -struct di_fcn_s { - void (*detach)(struct dma_pub *dmah); - void (*txinit)(struct dma_pub *dmah); - bool (*txreset)(struct dma_pub *dmah); - bool (*txenabled)(struct dma_pub *dmah); - void (*txsuspend)(struct dma_pub *dmah); - void (*txresume)(struct dma_pub *dmah); - bool (*txsuspended)(struct dma_pub *dmah); - bool (*txsuspendedidle)(struct dma_pub *dmah); - int (*txfast)(struct dma_pub *dmah, struct sk_buff *p, bool commit); - int (*txunframed)(struct dma_pub *dmah, void *p, uint len, bool commit); - - void *(*getpos)(struct dma_pub *di, bool direction); - bool (*txstopped)(struct dma_pub *dmah); - void (*txreclaim)(struct dma_pub *dmah, enum txd_range range); - void *(*getnexttxp)(struct dma_pub *dmah, enum txd_range range); - void *(*peeknexttxp) (struct dma_pub *dmah); - void (*txblock) (struct dma_pub *dmah); - void (*txunblock) (struct dma_pub *dmah); - uint (*txactive)(struct dma_pub *dmah); - void (*txrotate) (struct dma_pub *dmah); - - void (*rxinit)(struct dma_pub *dmah); - bool (*rxreset)(struct dma_pub *dmah); - bool (*rxidle)(struct dma_pub *dmah); - bool (*rxstopped)(struct dma_pub *dmah); - bool (*rxenable)(struct dma_pub *dmah); - bool (*rxenabled)(struct dma_pub *dmah); - void *(*rx)(struct dma_pub *dmah); - bool (*rxfill)(struct dma_pub *dmah); - void (*rxreclaim)(struct dma_pub *dmah); - void *(*getnextrxp)(struct dma_pub *dmah, bool forceall); - void *(*peeknextrxp)(struct dma_pub *dmah); - void (*rxparam_get)(struct dma_pub *dmah, u16 *rxoffset, - u16 *rxbufsize); - - void (*fifoloopbackenable)(struct dma_pub *dmah); - unsigned long (*d_getvar)(struct dma_pub *dmah, const char *name); - - void (*counterreset)(struct dma_pub *dmah); - uint (*ctrlflags)(struct dma_pub *dmah, uint mask, uint flags); - char *(*dump)(struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); - char *(*dumptx)(struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); - char *(*dumprx)(struct dma_pub *dmah, struct brcmu_strbuf *b, - bool dumpring); - uint (*rxactive)(struct dma_pub *dmah); - uint (*txpending)(struct dma_pub *dmah); - uint (*txcommitted)(struct dma_pub *dmah); - uint endnum; -}; - /* * Exported data structure (read-only) */ /* export structure */ struct dma_pub { - const struct di_fcn_s *di_fn; /* DMA function pointers */ uint txavail; /* # free tx descriptors */ uint dmactrlflags; /* dma control flags */ @@ -134,49 +79,22 @@ extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level); -extern const struct di_fcn_s dma64proc; - -#define dma_detach(di) (dma64proc.detach(di)) -#define dma_txreset(di) (dma64proc.txreset(di)) -#define dma_rxreset(di) (dma64proc.rxreset(di)) -#define dma_rxidle(di) (dma64proc.rxidle(di)) -#define dma_txinit(di) (dma64proc.txinit(di)) -#define dma_txenabled(di) (dma64proc.txenabled(di)) -#define dma_rxinit(di) (dma64proc.rxinit(di)) -#define dma_txsuspend(di) (dma64proc.txsuspend(di)) -#define dma_txresume(di) (dma64proc.txresume(di)) -#define dma_txsuspended(di) (dma64proc.txsuspended(di)) -#define dma_txsuspendedidle(di) (dma64proc.txsuspendedidle(di)) -#define dma_txfast(di, p, commit) (dma64proc.txfast(di, p, commit)) -#define dma_txunframed(di, p, l, commit)(dma64proc.txunframed(di, p, l, commit)) -#define dma_getpos(di, dir) (dma64proc.getpos(di, dir)) -#define dma_fifoloopbackenable(di) (dma64proc.fifoloopbackenable(di)) -#define dma_txstopped(di) (dma64proc.txstopped(di)) -#define dma_rxstopped(di) (dma64proc.rxstopped(di)) -#define dma_rxenable(di) (dma64proc.rxenable(di)) -#define dma_rxenabled(di) (dma64proc.rxenabled(di)) -#define dma_rx(di) (dma64proc.rx(di)) -#define dma_rxfill(di) (dma64proc.rxfill(di)) -#define dma_txreclaim(di, range) (dma64proc.txreclaim(di, range)) -#define dma_rxreclaim(di) (dma64proc.rxreclaim(di)) -#define dma_getvar(di, name) (dma64proc.d_getvar(di, name)) -#define dma_getnexttxp(di, range) (dma64proc.getnexttxp(di, range)) -#define dma_getnextrxp(di, forceall) (dma64proc.getnextrxp(di, forceall)) -#define dma_peeknexttxp(di) (dma64proc.peeknexttxp(di)) -#define dma_peeknextrxp(di) (dma64proc.peeknextrxp(di)) -#define dma_rxparam_get(di, off, bufs) (dma64proc.rxparam_get(di, off, bufs)) - -#define dma_txblock(di) (dma64proc.txblock(di)) -#define dma_txunblock(di) (dma64proc.txunblock(di)) -#define dma_txactive(di) (dma64proc.txactive(di)) -#define dma_rxactive(di) (dma64proc.rxactive(di)) -#define dma_txrotate(di) (dma64proc.txrotate(di)) -#define dma_counterreset(di) (dma64proc.counterreset(di)) -#define dma_ctrlflags(di, mask, flags) \ - (dma64proc.ctrlflags((di), (mask), (flags))) -#define dma_txpending(di) (dma64proc.txpending(di)) -#define dma_txcommitted(di) (dma64proc.txcommitted(di)) - +void dma_rxinit(struct dma_pub *pub); +void *dma_rx(struct dma_pub *pub); +bool dma_rxfill(struct dma_pub *pub); +bool dma_rxreset(struct dma_pub *pub); +bool dma_txreset(struct dma_pub *pub); +void dma_txinit(struct dma_pub *pub); +int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit); +void dma_txsuspend(struct dma_pub *pub); +bool dma_txsuspended(struct dma_pub *pub); +void dma_txresume(struct dma_pub *pub); +void dma_txreclaim(struct dma_pub *pub, enum txd_range range); +void dma_rxreclaim(struct dma_pub *pub); +void dma_detach(struct dma_pub *pub); +unsigned long dma_getvar(struct dma_pub *pub, const char *name); +void *dma_getnexttxp(struct dma_pub *pub, enum txd_range range); +void dma_counterreset(struct dma_pub *pub); void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) (void *pkt, void *arg_a), void *arg_a); From d89a4c80601db2e565b89b1f13fdbd9a987324dd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:48 +0200 Subject: [PATCH 0086/1519] staging: brcm80211: removed void * from softmac phy Code cleanup. Replacing void * by other pointer types improves code readability and enforces stronger type checking. Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 7 +-- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 13 +++-- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 11 +++-- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 5 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 7 ++- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 47 +++++++------------ drivers/staging/brcm80211/brcmsmac/phy_shim.c | 7 +-- drivers/staging/brcm80211/brcmsmac/phy_shim.h | 6 ++- 8 files changed, 50 insertions(+), 53 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index e7a166f64f1..f5f914fccf8 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4528,9 +4528,10 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; /* Get a phy for this band */ - wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, - (void *)regs, brcms_b_bandtype(wlc_hw), vars, - wlc->wiphy); + wlc_hw->band->pi = + wlc_phy_attach(wlc_hw->phy_sh, regs, + brcms_b_bandtype(wlc_hw), vars, + wlc->wiphy); if (wlc_hw->band->pi == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" "attach failed\n", unit); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 22f7bfc79dd..831c2fe35ee 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -123,7 +123,7 @@ const u8 ofdm_rate_lookup[] = { static void wlc_set_phy_uninitted(struct brcms_phy *pi); static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi); -static void wlc_phy_timercb_phycal(void *arg); +static void wlc_phy_timercb_phycal(struct brcms_phy *pi); static bool wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant); @@ -509,7 +509,7 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) } struct brcms_phy_pub * -wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, +wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, char *vars, struct wiphy *wiphy) { struct brcms_phy *pi; @@ -539,7 +539,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype, if (pi == NULL) return NULL; pi->wiphy = wiphy; - pi->regs = (struct d11regs *) regs; + pi->regs = regs; pi->sh = sh; pi->phy_init_por = true; pi->phy_wreg_limit = PHY_WREG_LIMIT; @@ -720,9 +720,8 @@ u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih) return pi->pubpi.coreflags; } -static void wlc_phy_timercb_phycal(void *arg) +static void wlc_phy_timercb_phycal(struct brcms_phy *pi) { - struct brcms_phy *pi = (struct brcms_phy *) arg; uint delay = 5; if (PHY_PERICAL_MPHASE_PENDING(pi)) { @@ -2619,9 +2618,9 @@ void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) } } -void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx) +void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, + struct brcms_d11rxhdr *wlc_rxhdr) { - struct brcms_d11rxhdr *wlc_rxhdr = (struct brcms_d11rxhdr *) ctx; struct d11rxhdr *rxh = &wlc_rxhdr->rxhdr; int rssi = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_JSSI_MASK; uint radioid = pih->radioid; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index d2faba2e522..42e0cf044a5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -103,6 +103,9 @@ #define BRCMS_RSSI_INVALID 0 /* invalid RSSI value */ +struct d11regs; +struct phy_shim_info; + struct txpwr_limits { u8 cck[BRCMS_NUM_RATES_CCK]; u8 ofdm[BRCMS_NUM_RATES_OFDM]; @@ -160,7 +163,7 @@ struct brcms_chanvec { struct shared_phy_params { struct si_pub *sih; - void *physhim; + struct phy_shim_info *physhim; uint unit; uint corerev; uint bustype; @@ -181,7 +184,8 @@ struct shared_phy_params { extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); -extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, void *regs, +extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, + struct d11regs *regs, int bandtype, char *vars, struct wiphy *wiphy); extern void wlc_phy_detach(struct brcms_phy_pub *ppi); @@ -209,7 +213,8 @@ extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi); extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw); -extern void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx); +extern void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, + struct brcms_d11rxhdr *wlc_rxhdr); extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi); extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi); extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 25ea00342f5..bcc6d8312f3 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -41,6 +41,8 @@ extern u32 phyhal_msg_level; #define LCNXN_BASEREV 16 +struct phy_shim_info; + struct brcms_phy_srom_fem { /* TSSI positive slope, 1: positive, 0: negative */ u8 tssipos; @@ -546,7 +548,7 @@ struct shared_phy { struct brcms_phy *phy_head; uint unit; struct si_pub *sih; - void *physhim; + struct phy_shim_info *physhim; uint corerev; u32 machwcap; bool up; @@ -611,7 +613,6 @@ struct brcms_phy { struct brcms_phy_pub pubpi_ro; struct shared_phy *sh; struct phy_func_ptr pi_fptr; - void *pi_ptr; union { struct brcms_phy_lcnphy *pi_lcnphy; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 3d140eb0bc5..dcf626e574c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -1041,7 +1041,7 @@ void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti) static void wlc_lcnphy_common_read_table(struct brcms_phy *pi, u32 tbl_id, - const void *tbl_ptr, u32 tbl_len, + const u16 *tbl_ptr, u32 tbl_len, u32 tbl_width, u32 tbl_offset) { struct phytbl_info tab; @@ -1055,7 +1055,7 @@ wlc_lcnphy_common_read_table(struct brcms_phy *pi, u32 tbl_id, static void wlc_lcnphy_common_write_table(struct brcms_phy *pi, u32 tbl_id, - const void *tbl_ptr, u32 tbl_len, + const u16 *tbl_ptr, u32 tbl_len, u32 tbl_width, u32 tbl_offset) { @@ -1965,13 +1965,12 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, write_phy_reg(pi, 0x93d, 0xc0); wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - (const void *) lcnphy_iqcal_loft_gainladder, ARRAY_SIZE(lcnphy_iqcal_loft_gainladder), 16, 0); wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - (const void *)lcnphy_iqcal_ir_gainladder, + lcnphy_iqcal_ir_gainladder, ARRAY_SIZE( lcnphy_iqcal_ir_gainladder), 16, 32); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index fb64597df43..2e8aa64979c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -18627,11 +18627,10 @@ wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, offset = (tone_id >= 0) ? ((tone_id * 2) + 1) : (tbllen + (tone_id * 2) + 1); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - (void *)&pi-> - nphy_saved_noisevars. - min_noise_vars[i]); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_NOISEVAR, 1, + offset, 32, + &pi->nphy_saved_noisevars.min_noise_vars[i]); } pi->nphy_saved_noisevars.bufcount = 0; @@ -18652,8 +18651,7 @@ wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, &pi->nphy_saved_noisevars. min_noise_vars[i]); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - (void *)&noise_var_buf[i]); + offset, 32, &noise_var_buf[i]); pi->nphy_saved_noisevars.bufcount++; } @@ -19296,8 +19294,7 @@ static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) loft_comp = &pi->calibration_cache.txcal_coeffs_5G[5]; } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, 16, - (void *)tbl_ptr); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, 16, tbl_ptr); if (NREV_GE(pi->pubpi.phy_rev, 3)) { txcal_coeffs_bphy[0] = tbl_ptr[0]; @@ -24307,7 +24304,7 @@ static void wlc_phy_tx_iq_war_nphy(struct brcms_phy *pi) { struct nphy_iq_comp tx_comp; - wlc_phy_table_read_nphy(pi, 15, 4, 0x50, 16, (void *)&tx_comp); + wlc_phy_table_read_nphy(pi, 15, 4, 0x50, 16, &tx_comp); wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ, tx_comp.a0); wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 2, tx_comp.b0); @@ -28684,23 +28681,15 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m1m2); if (restore_cals) { - - wlc_phy_table_write_nphy(pi, 15, 2, - (80 + 2 * core), 16, - (void *)&pi-> - nphy_txpwrindex[core]. - iqcomp_a); - - wlc_phy_table_write_nphy(pi, 15, 1, (85 + core), - 16, - &pi-> - nphy_txpwrindex[core]. - locomp); - wlc_phy_table_write_nphy(pi, 15, 1, (93 + core), - 16, - (void *)&pi-> - nphy_txpwrindex[core]. - locomp); + wlc_phy_table_write_nphy( + pi, 15, 2, (80 + 2 * core), 16, + &pi->nphy_txpwrindex[core].iqcomp_a); + wlc_phy_table_write_nphy( + pi, 15, 1, (85 + core), 16, + &pi->nphy_txpwrindex[core].locomp); + wlc_phy_table_write_nphy( + pi, 15, 1, (93 + core), 16, + &pi->nphy_txpwrindex[core].locomp); } wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); @@ -28743,13 +28732,13 @@ wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, wlc_phy_table_read_nphy(pi, 15, 2, (80 + 2 * core), 16, - (void *)&pi-> + &pi-> nphy_txpwrindex[core]. iqcomp_a); wlc_phy_table_read_nphy(pi, 15, 1, (85 + core), 16, - (void *)&pi-> + &pi-> nphy_txpwrindex[core]. locomp); diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index a8821390628..ec88867163e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -59,11 +59,12 @@ void wlc_phy_shim_detach(struct phy_shim_info *physhim) } struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim, - void (*fn) (void *arg), void *arg, - const char *name) + void (*fn)(struct brcms_phy *pi), + void *arg, const char *name) { return (struct wlapi_timer *) - brcms_init_timer(physhim->wl, fn, arg, name); + brcms_init_timer(physhim->wl, (void (*)(void *))fn, + arg, name); } void wlapi_free_timer(struct phy_shim_info *physhim, struct wlapi_timer *t) diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index a35e1ed973b..14c56f9bb2c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -122,14 +122,16 @@ #define BRCMS_N_TXRX_CHAIN0 0 #define BRCMS_N_TXRX_CHAIN1 1 +struct brcms_phy; + extern struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, void *wl, void *wlc); extern void wlc_phy_shim_detach(struct phy_shim_info *physhim); /* PHY to WL utility functions */ extern struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim, - void (*fn) (void *arg), void *arg, - const char *name); + void (*fn) (struct brcms_phy *pi), + void *arg, const char *name); extern void wlapi_free_timer(struct phy_shim_info *physhim, struct wlapi_timer *t); extern void wlapi_add_timer(struct phy_shim_info *physhim, From b60987a15628046259be17471fd80ba92cf35ed2 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:49 +0200 Subject: [PATCH 0087/1519] staging: brcm80211: simplified register access macro's in softmac Code cleanup. Removed MIPS specific 'sync' instruction since this is not required for the chips that this driver supports. MIPS specific macro's were now the same as non-MIPS register access macro's and thus have been deleted. Also added comment that makes clearer what the benefit of these macro's is. Unified big and little end register access macro's. Reported-by: Dan Carpenter Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/types.h | 83 ++++++++-------------- 1 file changed, 30 insertions(+), 53 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 360795fed06..16a1c6a0467 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -320,60 +320,38 @@ do { \ #define WL_ERROR_ON() (brcm_msg_level & LOG_ERROR_VAL) -/* register access macros */ -#ifndef __BIG_ENDIAN -#ifndef __mips__ -#define R_REG(r) \ - ({\ - sizeof(*(r)) == sizeof(u8) ? \ - readb((u8 *)(r)) : \ - sizeof(*(r)) == sizeof(u16) ? readw((u16 *)(r)) : \ - readl((u32 *)(r)); \ - }) -#else /* __mips__ */ -#define R_REG(r) \ - ({ \ - __typeof(*(r)) __osl_v; \ - __asm__ __volatile__("sync"); \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - __osl_v = readb((u8 *)(r)); \ - break; \ - case sizeof(u16): \ - __osl_v = readw((u16 *)(r)); \ - break; \ - case sizeof(u32): \ - __osl_v = \ - readl((u32 *)(r)); \ - break; \ - } \ - __asm__ __volatile__("sync"); \ - __osl_v; \ - }) -#endif /* __mips__ */ +/* + * Register access macros. + * + * These macro's take a pointer to the address to read as one of their + * arguments. The macro itself deduces the size of the IO transaction (u8, u16 + * or u32). Advantage of this approach in combination with using a struct to + * define the registers in a register block, is that access size and access + * location are defined in only one spot. This reduces the risk of the + * programmer trying to use an unsupported transaction size on a register. + * + * For big endian operation, a byte swap has to be done. Eg, when attempting + * to read byte address 0, byte 3 should be read. This is accomplished + * using an xor ('^') operator. + */ + +#ifndef __BIG_ENDIAN +#define SWP2(r) (r) +#define SWP3(r) (r) +#else +#define SWP2(r) ((unsigned long)(r)^2) +#define SWP3(r) ((unsigned long)(r)^3) +#endif /* __BIG_ENDIAN */ -#define W_REG(r, v) do { \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - writeb((u8)(v), (u8 *)(r)); break; \ - case sizeof(u16): \ - writew((u16)(v), (u16 *)(r)); break; \ - case sizeof(u32): \ - writel((u32)(v), (u32 *)(r)); break; \ - }; \ - } while (0) -#else /* __BIG_ENDIAN */ #define R_REG(r) \ ({ \ __typeof(*(r)) __osl_v; \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - __osl_v = \ - readb((u8 *)((unsigned long)(r)^3)); \ + __osl_v = readb((u8 *)(SWP3(r))); \ break; \ case sizeof(u16): \ - __osl_v = \ - readw((u16 *)((unsigned long)(r)^2)); \ + __osl_v = readw((u16 *)(SWP2(r))); \ break; \ case sizeof(u32): \ __osl_v = readl((u32 *)(r)); \ @@ -385,17 +363,16 @@ do { \ #define W_REG(r, v) do { \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - writeb((u8)(v), \ - (u8 *)((unsigned long)(r)^3)); break; \ + writeb((u8)(v), (u8 *)(SWP3(r))); \ + break; \ case sizeof(u16): \ - writew((u16)(v), \ - (u16 *)((unsigned long)(r)^2)); break; \ + writew((u16)(v), (u16 *)(SWP2(r))); \ + break; \ case sizeof(u32): \ - writel((u32)(v), \ - (u32 *)(r)); break; \ + writel((u32)(v), (u32 *)(r)); \ + break; \ } \ } while (0) -#endif /* __BIG_ENDIAN */ #ifdef __mips__ /* From bea4f542e43433e77ab01e8ba7943bf6c1a8e3ce Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:50 +0200 Subject: [PATCH 0088/1519] staging: brcm80211: placed suspend flag in gInstance in brcmfmac One of the steps to remove global variable. gInstance will be replaced by brcmf_sdio_dev in the upcoming patch. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 35 +++++++++---------- .../staging/brcm80211/brcmfmac/sdio_host.h | 1 + 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 2a9efc30d85..edcd98eb23f 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -66,7 +66,6 @@ static int brcmf_sdio_resume(struct device *dev); uint sd_f2_blocksize = 512; /* Default blocksize */ struct brcmf_sdmmc_instance *gInstance; -static atomic_t brcmf_mmc_suspend; /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { @@ -100,17 +99,17 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); -#define BRCMF_PM_RESUME_WAIT(a) do { \ +#define BRCMF_PM_RESUME_WAIT(a, b) do { \ int retry = 0; \ - while (atomic_read(&brcmf_mmc_suspend) && retry++ != 30) { \ + while (atomic_read(&b->suspend) && retry++ != 30) { \ wait_event_timeout(a, false, HZ/100); \ } \ } while (0) -#define BRCMF_PM_RESUME_RETURN_ERROR(a) \ - do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0) +#define BRCMF_PM_RESUME_RETURN_ERROR(a, b) \ + do { if (atomic_read(&b->suspend)) return a; } while (0) #else -#define BRCMF_PM_RESUME_WAIT(a) -#define BRCMF_PM_RESUME_RETURN_ERROR(a) +#define BRCMF_PM_RESUME_WAIT(a, b) +#define BRCMF_PM_RESUME_RETURN_ERROR(a, b) #endif /* CONFIG_PM_SLEEP */ static int @@ -571,8 +570,8 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, regaddr)); - BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO); + BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, gInstance); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); if (rw) { /* CMD52 Write */ if (func == 0) { /* Can only directly write to some F0 registers. @@ -678,8 +677,8 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", __func__, cmd_type, rw, func, addr, nbytes)); - BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO); + BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, gInstance); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); /* Claim host controller */ sdio_claim_host(gInstance->func[func]); @@ -728,8 +727,8 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO); + BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, gInstance); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); /* Claim host controller */ sdio_claim_host(gInstance->func[func]); @@ -806,8 +805,8 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO); + BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, gInstance); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); /* Case 1: we don't have a packet. */ if (pkt == NULL) { BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n", @@ -981,7 +980,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdiodev->func1 = func; dev_set_drvdata(&func->card->dev, sdiodev); - atomic_set(&brcmf_mmc_suspend, false); + atomic_set(&gInstance->suspend, false); } gInstance->func[func->num] = func; @@ -1029,7 +1028,7 @@ static int brcmf_sdio_suspend(struct device *dev) BRCMF_TRACE(("%s\n", __func__)); - atomic_set(&brcmf_mmc_suspend, true); + atomic_set(&gInstance->suspend, true); sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { @@ -1056,7 +1055,7 @@ static int brcmf_sdio_resume(struct device *dev) sdiodev = dev_get_drvdata(&func->card->dev); brcmf_sdio_wdtmr_enable(sdiodev, true); - atomic_set(&brcmf_mmc_suspend, false); + atomic_set(&gInstance->suspend, false); return 0; } #endif /* CONFIG_PM_SLEEP */ diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index aecc8e33df7..f4e2329fd6b 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -152,6 +152,7 @@ struct brcmf_sdmmc_instance { struct sdioh_info *sd; struct sdio_func *func[SDIOD_MAX_IOFUNCS]; u32 host_claimed; + atomic_t suspend; /* suspend flag */ }; struct brcmf_sdio_dev { From 55963d748b13d0a8ceef1219e70e02da4dc9e20a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:51 +0200 Subject: [PATCH 0089/1519] staging: brcm80211: remove struct brcmf_sdioh_driver from brcmfmac brcmf_sdioh_driver is a legacy bus driver interface we dont need any more. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 11 +++-------- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 4 ++++ drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 17 +++-------------- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 11 +---------- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 0cd449d332e..82d9d2cc69c 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -50,9 +50,6 @@ struct brcmf_sdio_card { u32 sbwad; /* Save backplane window address */ }; -/* driver info, initialized when brcmf_sdio_register is called */ -static struct brcmf_sdioh_driver drvinfo = { NULL, NULL }; - /* Module parameters specific to each host-controller driver */ module_param(sd_f2_blocksize, int, 0); @@ -443,7 +440,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) vendevid = brcmf_sdcard_query_device(sdiodev->card); /* try to attach to the target device */ - sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), + sdiodev->bus = brcmf_sdbrcm_probe((vendevid >> 16), (vendevid & 0xFFFF), 0, 0, 0, 0, regs, sdiodev->card); if (!sdiodev->bus) { BRCMF_ERROR(("%s: device attach failed\n", __func__)); @@ -462,7 +459,7 @@ EXPORT_SYMBOL(brcmf_sdio_probe); int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) { if (sdiodev->bus) { - drvinfo.detach(sdiodev->bus); + brcmf_sdbrcm_disconnect(sdiodev->bus); sdiodev->bus = NULL; } @@ -477,10 +474,8 @@ int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) } EXPORT_SYMBOL(brcmf_sdio_remove); -int brcmf_sdio_register(struct brcmf_sdioh_driver *driver) +int brcmf_sdio_register(void) { - drvinfo = *driver; - return brcmf_sdio_function_init(); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 653cf0daa0e..0fb32509cee 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -75,4 +75,8 @@ extern void brcmf_bus_clearcounts(struct brcmf_pub *drvr); extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); +extern void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, + u16 slot, u16 func, uint bustype, u32 regsva, + void *card); +extern void brcmf_sdbrcm_disconnect(void *ptr); #endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 6c96f777481..1b847678c47 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -962,7 +962,6 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter); static void brcmf_sdbrcm_release(struct brcmf_bus *bus); static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus); -static void brcmf_sdbrcm_disconnect(void *ptr); static bool brcmf_sdbrcm_chipmatch(u16 chipid); static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva, u16 devid); @@ -5431,7 +5430,7 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) return false; } -static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, +void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, u16 slot, u16 func, uint bustype, u32 regsva, void *card) { @@ -5889,7 +5888,7 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) BRCMF_TRACE(("%s: Disconnected\n", __func__)); } -static void brcmf_sdbrcm_disconnect(void *ptr) +void brcmf_sdbrcm_disconnect(void *ptr) { struct brcmf_bus *bus = (struct brcmf_bus *)ptr; @@ -5901,16 +5900,6 @@ static void brcmf_sdbrcm_disconnect(void *ptr) BRCMF_TRACE(("%s: Disconnected\n", __func__)); } -/* Register/Unregister functions are called by the main DHD entry - * point (e.g. module insertion) to link with the bus driver, in - * order to look for or await the device. - */ - -static struct brcmf_sdioh_driver brcmf_sdio = { - brcmf_sdbrcm_probe, - brcmf_sdbrcm_disconnect -}; - int brcmf_bus_register(void) { BRCMF_TRACE(("%s: Enter\n", __func__)); @@ -5930,7 +5919,7 @@ int brcmf_bus_register(void) return -EINVAL; } while (0); - return brcmf_sdio_register(&brcmf_sdio); + return brcmf_sdio_register(); } void brcmf_bus_unregister(void) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index f4e2329fd6b..3d6c2613432 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -278,20 +278,11 @@ extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name, /* helper functions */ -/* callback functions */ -struct brcmf_sdioh_driver { - /* attach to device */ - void *(*attach) (u16 vend_id, u16 dev_id, u16 bus, u16 slot, - u16 func, uint bustype, u32 regsva, void *param); - /* detach from device */ - void (*detach) (void *ch); -}; - struct sdioh_info; /* platform specific/high level functions */ extern int brcmf_sdio_function_init(void); -extern int brcmf_sdio_register(struct brcmf_sdioh_driver *driver); +extern int brcmf_sdio_register(void); extern void brcmf_sdio_unregister(void); extern void brcmf_sdio_function_cleanup(void); extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); From a493f4e1b5d1b5cb277d5058415dabc83cac202a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:52 +0200 Subject: [PATCH 0090/1519] staging: brcm80211: remove vendor and device id check from brcmfmac mmc core is handling the vendor/device id check and matching drivers with devices. No need to do it again in driver. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 14 +---- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 5 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 53 +++---------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 3 -- 4 files changed, 9 insertions(+), 66 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 82d9d2cc69c..3208a11386e 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -44,7 +44,6 @@ struct brcmf_sdio_card { bool init_success; /* underlying driver successfully attached */ void *sdioh; /* handler for sdioh */ - u32 vendevid; /* Target Vendor and Device ID on SD bus */ bool regfail; /* Save status of last reg_read/reg_write call */ u32 sbwad; /* Save backplane window address */ @@ -399,12 +398,6 @@ int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn) return brcmf_sdioh_abort(card->sdioh, fn); } -int brcmf_sdcard_query_device(struct brcmf_sdio_card *card) -{ - card->vendevid = (PCI_VENDOR_ID_BROADCOM << 16) | 0; - return card->vendevid; -} - u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) { return card->sbwad; @@ -413,7 +406,6 @@ u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) { u32 regs = 0; - u32 vendevid; int ret = 0; sdiodev->card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC); @@ -436,12 +428,8 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) /* Report the BAR, to fix if needed */ sdiodev->card->sbwad = SI_ENUM_BASE; - /* Read the vendor/device ID from the CIS */ - vendevid = brcmf_sdcard_query_device(sdiodev->card); - /* try to attach to the target device */ - sdiodev->bus = brcmf_sdbrcm_probe((vendevid >> 16), (vendevid & 0xFFFF), - 0, 0, 0, 0, regs, sdiodev->card); + sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev->card); if (!sdiodev->bus) { BRCMF_ERROR(("%s: device attach failed\n", __func__)); ret = -ENODEV; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 0fb32509cee..4521fe5460f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -75,8 +75,7 @@ extern void brcmf_bus_clearcounts(struct brcmf_pub *drvr); extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); -extern void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, - u16 slot, u16 func, uint bustype, u32 regsva, - void *card); +extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, + u32 regsva, void *card); extern void brcmf_sdbrcm_disconnect(void *ptr); #endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 1b847678c47..bd83da39c29 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -625,8 +625,6 @@ struct brcmf_bus { bool dpc_sched; /* Indicates DPC schedule (intrpt rcvd) */ bool fcstate; /* State of dongle flow-control */ - u16 cl_devid; /* cached devid for brcmf_sdio_probe_attach() */ - uint blocksize; /* Block size of SDIO transfers */ uint roundup; /* Max roundup limit */ @@ -964,7 +962,7 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus); static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus); static bool brcmf_sdbrcm_chipmatch(u16 chipid); static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, - u32 regsva, u16 devid); + u32 regsva); static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus, void *card); static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card); static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus); @@ -5430,9 +5428,8 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) return false; } -void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, - u16 slot, u16 func, uint bustype, u32 regsva, - void *card) +void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, + u32 regsva, void *card) { int ret; struct brcmf_bus *bus; @@ -5459,45 +5456,10 @@ void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, brcmf_c_init(); BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_INFO(("%s: venid 0x%04x devid 0x%04x\n", __func__, venid, devid)); /* We make an assumption about address window mappings: * regsva == SI_ENUM_BASE*/ - /* SDIO car passes venid and devid based on CIS parsing -- but - * low-power start - * means early parse could fail, so here we should get either an ID - * we recognize OR (-1) indicating we must request power first. - */ - /* Check the Vendor ID */ - switch (venid) { - case 0x0000: - case PCI_VENDOR_ID_BROADCOM: - break; - default: - BRCMF_ERROR(("%s: unknown vendor: 0x%04x\n", __func__, venid)); - return NULL; - } - - /* Check the Device ID and make sure it's one that we support */ - switch (devid) { - case BCM4329_D11NDUAL_ID: /* 4329 802.11n dualband device */ - case BCM4329_D11N2G_ID: /* 4329 802.11n 2.4G device */ - case BCM4329_D11N5G_ID: /* 4329 802.11n 5G device */ - case 0x4329: - BRCMF_INFO(("%s: found 4329 Dongle\n", __func__)); - break; - case 0: - BRCMF_INFO(("%s: allow device id 0, will check chip" - " internals\n", __func__)); - break; - - default: - BRCMF_ERROR(("%s: skipping 0x%04x/0x%04x, not a dongle\n", - __func__, venid, devid)); - return NULL; - } - /* Allocate private bus interface state */ bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); if (!bus) { @@ -5506,14 +5468,13 @@ void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, goto fail; } bus->card = card; - bus->cl_devid = (u16) devid; bus->bus = BRCMF_BUS; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ /* attempt to attach to the dongle */ - if (!(brcmf_sdbrcm_probe_attach(bus, card, regsva, devid))) { + if (!(brcmf_sdbrcm_probe_attach(bus, card, regsva))) { BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_attach failed\n", __func__)); goto fail; @@ -5623,8 +5584,7 @@ fail: } static bool -brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva, - u16 devid) +brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) { u8 clkctl = 0; int err = 0; @@ -6170,8 +6130,7 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) /* Attempt to re-attach & download */ if (brcmf_sdbrcm_probe_attach(bus, bus->card, - SI_ENUM_BASE, - bus->cl_devid)) { + SI_ENUM_BASE)) { /* Attempt to download binary to the dongle */ if (brcmf_sdbrcm_probe_init(bus, bus->card)) { /* Re-init bus, enable F2 transfer */ diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 3d6c2613432..22441e95e86 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -268,9 +268,6 @@ extern int brcmf_sdcard_rwdata(struct brcmf_sdio_card *card, uint rw, u32 addr, /* Issue an abort to the specified function */ extern int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn); -/* Returns the "Device ID" of target device on the SDIO bus. */ -extern int brcmf_sdcard_query_device(struct brcmf_sdio_card *card); - /* Miscellaneous knob tweaker. */ extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name, void *params, int plen, void *arg, int len, From 306f49ba57a6ce63668185cf1b68f2557b139341 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:53 +0200 Subject: [PATCH 0091/1519] staging: brcm80211: remove struct brcmf_sdio_card from brcmfmac Use brcmf_sdio_dev as the unified structure to store information of wifi dongle Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 145 +++--- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 3 - drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 445 +++++++++--------- .../staging/brcm80211/brcmfmac/sdio_host.h | 52 +- 4 files changed, 317 insertions(+), 328 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 3208a11386e..31e6728560f 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -41,48 +41,40 @@ #define SDIOH_DATA_PIO 0 /* PIO mode */ #define SDIOH_DATA_DMA 1 /* DMA mode */ -struct brcmf_sdio_card { - bool init_success; /* underlying driver successfully attached */ - void *sdioh; /* handler for sdioh */ - bool regfail; /* Save status of last - reg_read/reg_write call */ - u32 sbwad; /* Save backplane window address */ -}; - /* Module parameters specific to each host-controller driver */ module_param(sd_f2_blocksize, int, 0); int -brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name, +brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, void *params, int plen, void *arg, int len, bool set) { - return brcmf_sdioh_iovar_op(card->sdioh, name, params, plen, arg, + return brcmf_sdioh_iovar_op(sdiodev->sdioh, name, params, plen, arg, len, set); } -int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card) +int brcmf_sdcard_intr_enable(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_set(card->sdioh, true); + return brcmf_sdioh_interrupt_set(sdiodev->sdioh, true); } -int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card) +int brcmf_sdcard_intr_disable(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_set(card->sdioh, false); + return brcmf_sdioh_interrupt_set(sdiodev->sdioh, false); } -int brcmf_sdcard_intr_reg(struct brcmf_sdio_card *card, +int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, void (*fn)(void *), void *argh) { - return brcmf_sdioh_interrupt_register(card->sdioh, fn, argh); + return brcmf_sdioh_interrupt_register(sdiodev->sdioh, fn, argh); } -int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card *card) +int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_deregister(card->sdioh); + return brcmf_sdioh_interrupt_deregister(sdiodev->sdioh); } -u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, +u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, int *err) { int status; @@ -93,7 +85,7 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); status = - brcmf_sdioh_cfg_read(card->sdioh, fnc_num, addr, + brcmf_sdioh_cfg_read(sdiodev->sdioh, fnc_num, addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); @@ -107,7 +99,7 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, } void -brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, +brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u8 data, int *err) { int status; @@ -117,7 +109,7 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); status = - brcmf_sdioh_cfg_write(card->sdioh, fnc_num, addr, + brcmf_sdioh_cfg_write(sdiodev->sdioh, fnc_num, addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); @@ -128,13 +120,13 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr, __func__, fnc_num, addr, data)); } -u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num, +u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, int *err) { int status; u32 data = 0; - status = brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, + status = brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_READ, fnc_num, addr, &data, 4); if (err) @@ -147,13 +139,13 @@ u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num, } void -brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num, +brcmf_sdcard_cfg_write_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u32 data, int *err) { int status; status = - brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, + brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_WRITE, fnc_num, addr, &data, 4); if (err) @@ -163,7 +155,7 @@ brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num, __func__, fnc_num, addr, data)); } -int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis, +int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, uint length) { int status; @@ -173,7 +165,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis, bool ascii = func & ~0xf; func &= 0x7; - status = brcmf_sdioh_cis_read(card->sdioh, func, cis, length); + status = brcmf_sdioh_cis_read(sdiodev->sdioh, func, cis, length); if (ascii) { /* Move binary bits to tmp and format them @@ -197,18 +189,18 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis, } static int -brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_card *card, u32 address) +brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) { int err = 0; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); if (!err) - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, (address >> 16) & SBSDIO_SBADDRMID_MASK, &err); if (!err) - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, (address >> 24) & SBSDIO_SBADDRHIGH_MASK, &err); @@ -216,7 +208,7 @@ brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_card *card, u32 address) return err; } -u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) +u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) { int status; u32 word = 0; @@ -224,21 +216,21 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) BRCMF_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr)); - if (bar0 != card->sbwad) { - if (brcmf_sdcard_set_sbaddr_window(card, bar0)) + if (bar0 != sdiodev->sbwad) { + if (brcmf_sdcard_set_sbaddr_window(sdiodev, bar0)) return 0xFFFFFFFF; - card->sbwad = bar0; + sdiodev->sbwad = bar0; } addr &= SBSDIO_SB_OFT_ADDR_MASK; if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, + status = brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_READ, SDIO_FUNC_1, addr, &word, size); - card->regfail = (status != 0); + sdiodev->regfail = (status != 0); BRCMF_INFO(("u32data = 0x%x\n", word)); @@ -252,7 +244,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) case sizeof(u32): return word; default: - card->regfail = true; + sdiodev->regfail = true; } } @@ -263,7 +255,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size) return 0xFFFFFFFF; } -u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, +u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, u32 data) { int status; @@ -273,21 +265,21 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, BRCMF_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", __func__, addr, size * 8, data)); - if (bar0 != card->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(card, bar0); + if (bar0 != sdiodev->sbwad) { + err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); if (err) return err; - card->sbwad = bar0; + sdiodev->sbwad = bar0; } addr &= SBSDIO_SB_OFT_ADDR_MASK; if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; status = - brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL, + brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, SDIOH_WRITE, SDIO_FUNC_1, addr, &data, size); - card->regfail = (status != 0); + sdiodev->regfail = (status != 0); if (status == 0) return 0; @@ -297,13 +289,13 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, return 0xFFFFFFFF; } -bool brcmf_sdcard_regfail(struct brcmf_sdio_card *card) +bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev) { - return card->regfail; + return sdiodev->regfail; } int -brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, +brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt, void (*complete)(void *handle, int status, @@ -323,12 +315,12 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, if (flags & SDIO_REQ_ASYNC) return -ENOTSUPP; - if (bar0 != card->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(card, bar0); + if (bar0 != sdiodev->sbwad) { + err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); if (err) return err; - card->sbwad = bar0; + sdiodev->sbwad = bar0; } addr &= SBSDIO_SB_OFT_ADDR_MASK; @@ -338,14 +330,14 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_buffer(card->sdioh, SDIOH_DATA_PIO, + status = brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, incr_fix, SDIOH_READ, fn, addr, width, nbytes, buf, pkt); return status; } int -brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, +brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, void *pkt, void (*complete)(void *handle, int status, bool sync_waiting), @@ -363,12 +355,12 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, if (flags & SDIO_REQ_ASYNC) return -ENOTSUPP; - if (bar0 != card->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(card, bar0); + if (bar0 != sdiodev->sbwad) { + err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); if (err) return err; - card->sbwad = bar0; + sdiodev->sbwad = bar0; } addr &= SBSDIO_SB_OFT_ADDR_MASK; @@ -378,29 +370,29 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(card->sdioh, SDIOH_DATA_PIO, + return brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt); } -int brcmf_sdcard_rwdata(struct brcmf_sdio_card *card, uint rw, u32 addr, +int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, u8 *buf, uint nbytes) { addr &= SBSDIO_SB_OFT_ADDR_MASK; addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(card->sdioh, SDIOH_DATA_PIO, + return brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, SDIOH_DATA_INC, (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, addr, 4, nbytes, buf, NULL); } -int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn) +int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) { - return brcmf_sdioh_abort(card->sdioh, fn); + return brcmf_sdioh_abort(sdiodev->sdioh, fn); } -u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card) +u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev) { - return card->sbwad; + return sdiodev->sbwad; } int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) @@ -408,28 +400,19 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) u32 regs = 0; int ret = 0; - sdiodev->card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC); - if (sdiodev->card == NULL) { - BRCMF_ERROR(("sdcard_attach: out of memory")); - ret = -ENOMEM; - goto out; - } - - sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0); - if (!sdiodev->card->sdioh) { + sdiodev->sdioh = brcmf_sdioh_attach((void *)0); + if (!sdiodev->sdioh) { ret = -ENODEV; goto out; } - sdiodev->card->init_success = true; - regs = SI_ENUM_BASE; /* Report the BAR, to fix if needed */ - sdiodev->card->sbwad = SI_ENUM_BASE; + sdiodev->sbwad = SI_ENUM_BASE; /* try to attach to the target device */ - sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev->card); + sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev); if (!sdiodev->bus) { BRCMF_ERROR(("%s: device attach failed\n", __func__)); ret = -ENODEV; @@ -451,13 +434,13 @@ int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) sdiodev->bus = NULL; } - if (sdiodev->card) { - if (sdiodev->card->sdioh) - brcmf_sdioh_detach(sdiodev->card->sdioh); - kfree(sdiodev->card); - sdiodev->card = NULL; + if (sdiodev->sdioh) { + brcmf_sdioh_detach(sdiodev->sdioh); + sdiodev->sdioh = NULL; } + sdiodev->sbwad = 0; + return 0; } EXPORT_SYMBOL(brcmf_sdio_remove); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 4521fe5460f..653cf0daa0e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -75,7 +75,4 @@ extern void brcmf_bus_clearcounts(struct brcmf_pub *drvr); extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); -extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, void *card); -extern void brcmf_sdbrcm_disconnect(void *ptr); #endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index bd83da39c29..4fc17f80f74 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -611,7 +611,7 @@ struct chip_info { struct brcmf_bus { struct brcmf_pub *drvr; - struct brcmf_sdio_card *card; /* Handle for sdio card calls */ + struct brcmf_sdio_dev *sdiodev; /* sdio device handler */ struct chip_info *ci; /* Chip info struct */ char *vars; /* Variables (from CIS and/or other) */ uint varsz; /* Size of variables buffer */ @@ -908,9 +908,9 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) { *retryvar = 0; do { - *regvar = brcmf_sdcard_reg_read(bus->card, + *regvar = brcmf_sdcard_reg_read(bus->sdiodev, bus->ci->buscorebase + reg_offset, sizeof(u32)); - } while (brcmf_sdcard_regfail(bus->card) && + } while (brcmf_sdcard_regfail(bus->sdiodev) && (++(*retryvar) <= retry_limit)); if (*retryvar) { bus->regfails += (*retryvar-1); @@ -926,10 +926,10 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) { *retryvar = 0; do { - brcmf_sdcard_reg_write(bus->card, + brcmf_sdcard_reg_write(bus->sdiodev, bus->ci->buscorebase + reg_offset, sizeof(u32), regval); - } while (brcmf_sdcard_regfail(bus->card) && + } while (brcmf_sdcard_regfail(bus->sdiodev) && (++(*retryvar) <= retry_limit)); if (*retryvar) { bus->regfails += (*retryvar-1); @@ -961,10 +961,9 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter); static void brcmf_sdbrcm_release(struct brcmf_bus *bus); static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus); static bool brcmf_sdbrcm_chipmatch(u16 chipid); -static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, - u32 regsva); -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus, void *card); -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card); +static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva); +static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus); +static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus); static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus); static uint brcmf_process_nvram_vars(char *varbuf, uint len); @@ -984,12 +983,12 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus); static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus); static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_card *card, u32 corebase); +brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase); static int brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs); static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_card *card, u32 corebase); +brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase); static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, u32 drivestrength); @@ -1031,14 +1030,15 @@ static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size) static int brcmf_sdbrcm_set_siaddr_window(struct brcmf_bus *bus, u32 address) { int err = 0; - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, - (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_SBADDRLOW, + (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); if (!err) - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, (address >> 16) & SBSDIO_SBADDRMID_MASK, &err); if (!err) - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, (address >> 24) & SBSDIO_SBADDRHIGH_MASK, &err); @@ -1050,13 +1050,11 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) { int err; u8 clkctl, clkreq, devctl; - struct brcmf_sdio_card *card; unsigned long timeout; BRCMF_TRACE(("%s: Enter\n", __func__)); clkctl = 0; - card = bus->card; if (on) { /* Request HT Avail */ @@ -1067,7 +1065,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) && (bus->ci->chiprev == 0)) clkreq |= SBSDIO_FORCE_ALP; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); if (err) { BRCMF_ERROR(("%s: HT Avail request error: %d\n", @@ -1084,7 +1082,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) } /* Check current status */ - clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err) { BRCMF_ERROR(("%s: HT Avail read error: %d\n", @@ -1095,7 +1093,8 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) /* Go to pending and await interrupt if appropriate */ if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { /* Allow only clock-available interrupt */ - devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + devctl = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { BRCMF_ERROR(("%s: Devctl error setting CA:" @@ -1104,7 +1103,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) } devctl |= SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); BRCMF_INFO(("CLKCTL: set PENDING\n")); bus->clkstate = CLK_PENDING; @@ -1113,10 +1112,10 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) } else if (bus->clkstate == CLK_PENDING) { /* Cancel CA-only interrupt filter */ devctl = - brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); } @@ -1124,7 +1123,8 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) timeout = jiffies + msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000); while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { - clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (time_after(jiffies, timeout)) @@ -1162,15 +1162,16 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) if (bus->clkstate == CLK_PENDING) { /* Cancel CA-only interrupt filter */ - devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + devctl = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); } bus->clkstate = CLK_SDONLY; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); BRCMF_INFO(("CLKCTL: turned OFF\n")); if (err) { @@ -1255,7 +1256,6 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) { - struct brcmf_sdio_card *card = bus->card; uint retries = 0; BRCMF_INFO(("brcmf_sdbrcm_bussleep: request %s (currently %s)\n", @@ -1273,7 +1273,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) return -EBUSY; /* Disable SDIO interrupts (no longer interested) */ - brcmf_sdcard_intr_disable(bus->card); + brcmf_sdcard_intr_disable(bus->sdiodev); /* Make sure the controller has the bus up */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -1288,13 +1288,13 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) /* Turn off our contribution to the HT clock request */ brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); /* Isolate the bus */ if (bus->ci->chip != BCM4329_CHIP_ID) { - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, SBSDIO_DEVCTL_PADS_ISO, NULL); } @@ -1305,14 +1305,14 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) } else { /* Waking up: bus power up is ok, set local state */ - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); /* Force pad isolation off if possible (in case power never toggled) */ if ((bus->ci->buscoretype == PCMCIA_CORE_ID) && (bus->ci->buscorerev >= 10)) - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, 0, NULL); /* Make sure the controller has the bus up */ @@ -1338,7 +1338,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) /* Enable interrupts again */ if (bus->intr && (bus->drvr->busstate == BRCMF_BUS_DATA)) { bus->intdis = false; - brcmf_sdcard_intr_enable(bus->card); + brcmf_sdcard_intr_enable(bus->sdiodev); } } @@ -1361,14 +1361,11 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, u16 len, pad = 0; u32 swheader; uint retries = 0; - struct brcmf_sdio_card *card; struct sk_buff *new; int i; BRCMF_TRACE(("%s: Enter\n", __func__)); - card = bus->card; - if (bus->drvr->dongle_reset) { ret = -EPERM; goto done; @@ -1453,7 +1450,8 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, len = roundup(len, ALIGNMENT); do { - ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(card), + ret = brcmf_sdbrcm_send_buf(bus, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, frame, len, pkt, NULL, NULL); bus->f2txdata++; @@ -1464,18 +1462,20 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, "terminate frame.\n", __func__, ret)); bus->tx_sderrs++; - brcmf_sdcard_abort(card, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, NULL); bus->f1regdata++; for (i = 0; i < 3; i++) { u8 hi, lo; - hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + hi = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCHI, NULL); - lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + lo = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCLO, NULL); bus->f1regdata += 2; @@ -1647,7 +1647,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) offsetof(struct sdpcmd_regs, intstatus), &retries); bus->f2txdata++; - if (brcmf_sdcard_regfail(bus->card)) + if (brcmf_sdcard_regfail(bus->sdiodev)) break; if (intstatus & bus->hostintmask) bus->ipend = true; @@ -1669,7 +1669,6 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) u16 len; u32 swheader; uint retries = 0; - struct brcmf_sdio_card *card = bus->card; u8 doff = 0; int ret = -1; int i; @@ -1769,7 +1768,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) do { bus->ctrl_frame_stat = false; ret = brcmf_sdbrcm_send_buf(bus, - brcmf_sdcard_cur_sbwad(card), SDIO_FUNC_2, + brcmf_sdcard_cur_sbwad(bus->sdiodev), + SDIO_FUNC_2, F2SYNC, frame, len, NULL, NULL, NULL); if (ret < 0) { @@ -1780,20 +1780,21 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) __func__, ret)); bus->tx_sderrs++; - brcmf_sdcard_abort(card, SDIO_FUNC_2); + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, NULL); bus->f1regdata++; for (i = 0; i < 3; i++) { u8 hi, lo; - hi = brcmf_sdcard_cfg_read(card, + hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCHI, NULL); - lo = brcmf_sdcard_cfg_read(card, + lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCLO, NULL); @@ -2178,8 +2179,8 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, BRCMF_INFO(("%s: %s %d bytes at offset 0x%08x in window" " 0x%08x\n", __func__, (write ? "write" : "read"), dsize, sdaddr, (address & SBSDIO_SBWINDOW_MASK))); - bcmerror = - brcmf_sdcard_rwdata(bus->card, write, sdaddr, data, dsize); + bcmerror = brcmf_sdcard_rwdata(bus->sdiodev, write, + sdaddr, data, dsize); if (bcmerror) { BRCMF_ERROR(("%s: membytes transfer failed\n", __func__)); @@ -2205,9 +2206,10 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, xfer_done: /* Return the window to backplane enumeration space for core access */ if (brcmf_sdbrcm_set_siaddr_window(bus, - brcmf_sdcard_cur_sbwad(bus->card))) + brcmf_sdcard_cur_sbwad( + bus->sdiodev))) BRCMF_ERROR(("%s: FAILED to set window back to 0x%x\n", - __func__, brcmf_sdcard_cur_sbwad(bus->card))); + __func__, brcmf_sdcard_cur_sbwad(bus->sdiodev))); return bcmerror; } @@ -2615,9 +2617,9 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, BRCMF_INTR(("%s: %s SDIO interrupts\n", __func__, bus->intr ? "enable" : "disable")); if (bus->intr) - brcmf_sdcard_intr_enable(bus->card); + brcmf_sdcard_intr_enable(bus->sdiodev); else - brcmf_sdcard_intr_disable(bus->card); + brcmf_sdcard_intr_disable(bus->sdiodev); } break; @@ -2807,9 +2809,9 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, addr = bus->ci->buscorebase + sd_ptr->offset; size = sd_ptr->func; - int_val = (s32) brcmf_sdcard_reg_read(bus->card, addr, - size); - if (brcmf_sdcard_regfail(bus->card)) + int_val = (s32) brcmf_sdcard_reg_read(bus->sdiodev, + addr, size); + if (brcmf_sdcard_regfail(bus->sdiodev)) bcmerror = -EIO; memcpy(arg, &int_val, sizeof(s32)); break; @@ -2824,9 +2826,9 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, addr = bus->ci->buscorebase + sd_ptr->offset; size = sd_ptr->func; - brcmf_sdcard_reg_write(bus->card, addr, size, + brcmf_sdcard_reg_write(bus->sdiodev, addr, size, sd_ptr->value); - if (brcmf_sdcard_regfail(bus->card)) + if (brcmf_sdcard_regfail(bus->sdiodev)) bcmerror = -EIO; break; } @@ -2842,9 +2844,9 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, addr = SI_ENUM_BASE + sdreg.offset; size = sdreg.func; - int_val = (s32) brcmf_sdcard_reg_read(bus->card, addr, - size); - if (brcmf_sdcard_regfail(bus->card)) + int_val = (s32) brcmf_sdcard_reg_read(bus->sdiodev, + addr, size); + if (brcmf_sdcard_regfail(bus->sdiodev)) bcmerror = -EIO; memcpy(arg, &int_val, sizeof(s32)); break; @@ -2859,9 +2861,9 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, addr = SI_ENUM_BASE + sdreg.offset; size = sdreg.func; - brcmf_sdcard_reg_write(bus->card, addr, size, + brcmf_sdcard_reg_write(bus->sdiodev, addr, size, sdreg.value); - if (brcmf_sdcard_regfail(bus->card)) + if (brcmf_sdcard_regfail(bus->sdiodev)) bcmerror = -EIO; break; } @@ -2871,15 +2873,15 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, *(char *)arg = 0; strcat(arg, "\nFunc 0\n"); - brcmf_sdcard_cis_read(bus->card, 0x10, + brcmf_sdcard_cis_read(bus->sdiodev, 0x10, (u8 *) arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); strcat(arg, "\nFunc 1\n"); - brcmf_sdcard_cis_read(bus->card, 0x11, + brcmf_sdcard_cis_read(bus->sdiodev, 0x11, (u8 *) arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); strcat(arg, "\nFunc 2\n"); - brcmf_sdcard_cis_read(bus->card, 0x12, + brcmf_sdcard_cis_read(bus->sdiodev, 0x12, (u8 *) arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); break; @@ -3106,9 +3108,10 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) if (enter) { bus->alp_only = true; - brcmf_sdbrcm_chip_disablecore(bus->card, bus->ci->armcorebase); + brcmf_sdbrcm_chip_disablecore(bus->sdiodev, + bus->ci->armcorebase); - brcmf_sdbrcm_chip_resetcore(bus->card, bus->ci->ramcorebase); + brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); /* Clear the top bit of memory */ if (bus->ramsize) { @@ -3117,7 +3120,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) (u8 *)&zeros, 4); } } else { - regdata = brcmf_sdcard_reg_read(bus->card, + regdata = brcmf_sdcard_reg_read(bus->sdiodev, CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); regdata &= (SBTML_RESET | SBTML_REJ_MASK | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); @@ -3137,7 +3140,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) w_sdreg32(bus, 0xFFFFFFFF, offsetof(struct sdpcmd_regs, intstatus), &retries); - brcmf_sdbrcm_chip_resetcore(bus->card, bus->ci->armcorebase); + brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; @@ -3181,14 +3184,14 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, /* Turn on clock in case SD command needs backplane */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - bcmerror = brcmf_sdcard_iovar_op(bus->card, name, params, plen, - arg, len, set); + bcmerror = brcmf_sdcard_iovar_op(bus->sdiodev, name, params, + plen, arg, len, set); /* Similar check for blocksize change */ if (set && strcmp(name, "sd_blocksize") == 0) { s32 fnum = 2; if (brcmf_sdcard_iovar_op - (bus->card, "sd_blocksize", &fnum, sizeof(s32), + (bus->sdiodev, "sd_blocksize", &fnum, sizeof(s32), &bus->blocksize, sizeof(s32), false) != 0) { bus->blocksize = 0; @@ -3278,10 +3281,10 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) bus->drvr->busstate = BRCMF_BUS_DOWN; /* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1, + saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (!err) { - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, (saveclk | SBSDIO_FORCE_HT), &err); } @@ -3291,8 +3294,8 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) /* Turn off the bus (F2), free any pending packets */ BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); - brcmf_sdcard_intr_disable(bus->card); - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, + brcmf_sdcard_intr_disable(bus->sdiodev); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); /* Clear any pending interrupts now that F2 is disabled */ @@ -3339,7 +3342,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* try to download image and nvram to the dongle */ if (drvr->busstate == BRCMF_BUS_DOWN) { - if (!(brcmf_sdbrcm_download_firmware(bus, bus->card))) + if (!(brcmf_sdbrcm_download_firmware(bus, bus->sdiodev))) return -1; } @@ -3360,10 +3363,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* Force clocks on backplane to be sure F2 interrupt propagates */ saveclk = - brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (!err) { - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, (saveclk | SBSDIO_FORCE_HT), &err); } @@ -3378,13 +3381,13 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) offsetof(struct sdpcmd_regs, tosbmailboxdata), &retries); enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2); - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable, - NULL); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, + enable, NULL); timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); ready = 0; while (enable != ready) { - ready = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_0, + ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IORx, NULL); if (time_after(jiffies, timeout)) break; @@ -3403,8 +3406,8 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) w_sdreg32(bus, bus->hostintmask, offsetof(struct sdpcmd_regs, hostintmask), &retries); - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_WATERMARK, - (u8) watermark, &err); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_WATERMARK, (u8) watermark, &err); /* Set bus state according to enable result */ drvr->busstate = BRCMF_BUS_DATA; @@ -3413,10 +3416,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) if (bus->intr) { BRCMF_INTR(("%s: enable SDIO device interrupts\n", __func__)); - brcmf_sdcard_intr_enable(bus->card); + brcmf_sdcard_intr_enable(bus->sdiodev); } else { BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); - brcmf_sdcard_intr_disable(bus->card); + brcmf_sdcard_intr_disable(bus->sdiodev); } } @@ -3424,13 +3427,13 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) else { /* Disable F2 again */ enable = SDIO_FUNC_ENABLE_1; - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, - enable, NULL); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, + SDIO_CCCR_IOEx, enable, NULL); } /* Restore previous clock setting */ - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, - saveclk, &err); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); #if defined(OOB_INTR_ONLY) /* Host registration for OOB interrupt */ @@ -3459,7 +3462,6 @@ exit: static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) { - struct brcmf_sdio_card *card = bus->card; uint retries = 0; u16 lastrbc; u8 hi, lo; @@ -3470,17 +3472,18 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) (rtx ? ", send NAK" : ""))); if (abort) - brcmf_sdcard_abort(card, SDIO_FUNC_2); + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_FRAMECTRL, SFC_RF_TERM, &err); bus->f1regdata++; /* Wait until the packet has been flushed (device/FIFO stable) */ for (lastrbc = retries = 0xffff; retries > 0; retries--) { - hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_RFRAMEBCHI, NULL); - lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_RFRAMEBCLO, NULL); bus->f1regdata += 2; @@ -3516,14 +3519,13 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) bus->nextlen = 0; /* If we can't reach the device, signal failure */ - if (err || brcmf_sdcard_regfail(card)) + if (err || brcmf_sdcard_regfail(bus->sdiodev)) bus->drvr->busstate = BRCMF_BUS_DOWN; } static void brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) { - struct brcmf_sdio_card *card = bus->card; uint rdlen, pad; int sdret; @@ -3590,7 +3592,8 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) } /* Read remainder of frame body into the rxctl buffer */ - sdret = brcmf_sdcard_recv_buf(card, brcmf_sdcard_cur_sbwad(card), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (bus->rxctl + firstread), rdlen, NULL, NULL, NULL); @@ -3753,14 +3756,14 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) * packet and and copy into the chain. */ if (usechain) { - errcode = brcmf_sdcard_recv_buf(bus->card, - brcmf_sdcard_cur_sbwad(bus->card), + errcode = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (u8 *) pfirst->data, dlen, pfirst, NULL, NULL); } else if (bus->dataptr) { - errcode = brcmf_sdcard_recv_buf(bus->card, - brcmf_sdcard_cur_sbwad(bus->card), + errcode = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, bus->dataptr, dlen, NULL, NULL, NULL); @@ -4029,8 +4032,6 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) static uint brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) { - struct brcmf_sdio_card *card = bus->card; - u16 len, check; /* Extracted hardware header fields */ u8 chan, seq, doff; /* Extracted software header fields */ u8 fcbits; /* Extracted fcbits from software header */ @@ -4135,8 +4136,10 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) } rxbuf = bus->rxctl; /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf(card, - brcmf_sdcard_cur_sbwad(card), + sdret = brcmf_sdcard_recv_buf( + bus->sdiodev, + brcmf_sdcard_cur_sbwad( + bus->sdiodev), SDIO_FUNC_2, F2SYNC, rxbuf, rdlen, NULL, NULL, NULL); @@ -4176,8 +4179,9 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); rxbuf = (u8 *) (pkt->data); /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf(card, - brcmf_sdcard_cur_sbwad(card), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad( + bus->sdiodev), SDIO_FUNC_2, F2SYNC, rxbuf, rdlen, pkt, NULL, NULL); @@ -4360,8 +4364,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) break; /* Read frame header (hardware and software) */ - sdret = brcmf_sdcard_recv_buf(card, - brcmf_sdcard_cur_sbwad(card), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread, NULL, NULL, NULL); bus->f2rxhdrs++; @@ -4517,8 +4521,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); /* Read the remaining frame data */ - sdret = brcmf_sdcard_recv_buf(card, - brcmf_sdcard_cur_sbwad(card), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), rdlen, pkt, NULL, NULL); bus->f2rxdata++; @@ -4694,7 +4698,6 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) { - struct brcmf_sdio_card *card = bus->card; u32 intstatus, newstatus = 0; uint retries = 0; uint rxlimit = brcmf_rxbound; /* Rx frames to read before resched */ @@ -4717,7 +4720,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) #ifdef BCMDBG /* Check for inconsistent device control */ - devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { BRCMF_ERROR(("%s: error reading DEVCTL: %d\n", @@ -4727,7 +4730,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) #endif /* BCMDBG */ /* Read CSR, if clock on switch to AVAIL, else ignore */ - clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err) { BRCMF_ERROR(("%s: error reading CSR: %d\n", __func__, @@ -4739,7 +4742,8 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) devctl, clkctl)); if (SBSDIO_HTAV(clkctl)) { - devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + devctl = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { BRCMF_ERROR(("%s: error reading DEVCTL: %d\n", @@ -4747,7 +4751,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) bus->drvr->busstate = BRCMF_BUS_DOWN; } devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); if (err) { BRCMF_ERROR(("%s: error writing DEVCTL: %d\n", @@ -4773,7 +4777,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) r_sdreg32(bus, &newstatus, offsetof(struct sdpcmd_regs, intstatus), &retries); bus->f1regdata++; - if (brcmf_sdcard_regfail(bus->card)) + if (brcmf_sdcard_regfail(bus->sdiodev)) newstatus = 0; newstatus &= bus->hostintmask; bus->fcstate = !!(newstatus & I_HMB_FC_STATE); @@ -4854,18 +4858,19 @@ clkwait: * or clock availability. (Allows tx loop to check ipend if desired.) * (Unless register access seems hosed, as we may not be able to ACK...) */ - if (bus->intr && bus->intdis && !brcmf_sdcard_regfail(card)) { + if (bus->intr && bus->intdis && !brcmf_sdcard_regfail(bus->sdiodev)) { BRCMF_INTR(("%s: enable SDIO interrupts, rxdone %d" " framecnt %d\n", __func__, rxdone, framecnt)); bus->intdis = false; - brcmf_sdcard_intr_enable(card); + brcmf_sdcard_intr_enable(bus->sdiodev); } if (DATAOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) { int ret, i; - ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(card), + ret = brcmf_sdbrcm_send_buf(bus, + brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, (u32) bus->ctrl_frame_len, NULL, NULL, NULL); @@ -4876,19 +4881,21 @@ clkwait: "terminate frame.\n", __func__, ret)); bus->tx_sderrs++; - brcmf_sdcard_abort(card, SDIO_FUNC_2); + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, NULL); bus->f1regdata++; for (i = 0; i < 3; i++) { u8 hi, lo; - hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + hi = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCHI, NULL); - lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + lo = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCLO, NULL); bus->f1regdata += 2; @@ -4918,10 +4925,10 @@ clkwait: /* On failed register access, all bets are off: no resched or interrupts */ if ((bus->drvr->busstate == BRCMF_BUS_DOWN) || - brcmf_sdcard_regfail(card)) { + brcmf_sdcard_regfail(bus->sdiodev)) { BRCMF_ERROR(("%s: failed backplane access over SDIO, halting " "operation %d\n", __func__, - brcmf_sdcard_regfail(card))); + brcmf_sdcard_regfail(bus->sdiodev))); bus->drvr->busstate = BRCMF_BUS_DOWN; bus->intstatus = 0; } else if (bus->clkstate == CLK_PENDING) { @@ -4951,7 +4958,6 @@ clkwait: void brcmf_sdbrcm_isr(void *arg) { struct brcmf_bus *bus = (struct brcmf_bus *) arg; - struct brcmf_sdio_card *card; BRCMF_TRACE(("%s: Enter\n", __func__)); @@ -4959,7 +4965,6 @@ void brcmf_sdbrcm_isr(void *arg) BRCMF_ERROR(("%s : bus is null pointer , exit\n", __func__)); return; } - card = bus->card; if (bus->drvr->busstate == BRCMF_BUS_DOWN) { BRCMF_ERROR(("%s : bus is down. we have nothing to do\n", @@ -4982,7 +4987,7 @@ void brcmf_sdbrcm_isr(void *arg) else BRCMF_ERROR(("brcmf_sdbrcm_isr() w/o interrupt configured!\n")); - brcmf_sdcard_intr_disable(card); + brcmf_sdcard_intr_disable(bus->sdiodev); bus->intdis = true; #if defined(SDIO_ISR_THREAD) @@ -5287,7 +5292,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) if (!bus->dpc_sched) { u8 devpend; - devpend = brcmf_sdcard_cfg_read(bus->card, + devpend = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_INTx, NULL); intstatus = @@ -5301,7 +5306,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) bus->pollcnt++; bus->ipend = true; if (bus->intr) - brcmf_sdcard_intr_disable(bus->card); + brcmf_sdcard_intr_disable(bus->sdiodev); bus->dpc_sched = true; brcmf_sdbrcm_sched_dpc(bus); @@ -5429,7 +5434,7 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) } void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, void *card) + u32 regsva, struct brcmf_sdio_dev *sdiodev) { int ret; struct brcmf_bus *bus; @@ -5467,14 +5472,14 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, __func__)); goto fail; } - bus->card = card; + bus->sdiodev = sdiodev; bus->bus = BRCMF_BUS; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ /* attempt to attach to the dongle */ - if (!(brcmf_sdbrcm_probe_attach(bus, card, regsva))) { + if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_attach failed\n", __func__)); goto fail; @@ -5536,13 +5541,13 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, } /* Allocate buffers */ - if (!(brcmf_sdbrcm_probe_malloc(bus, card))) { + if (!(brcmf_sdbrcm_probe_malloc(bus))) { BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_malloc failed\n", __func__)); goto fail; } - if (!(brcmf_sdbrcm_probe_init(bus, card))) { + if (!(brcmf_sdbrcm_probe_init(bus))) { BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_init failed\n", __func__)); goto fail; } @@ -5550,8 +5555,8 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Register interrupt callback, but mask it (not operational yet). */ BRCMF_INTR(("%s: disable SDIO interrupts (not interested yet)\n", __func__)); - brcmf_sdcard_intr_disable(card); - ret = brcmf_sdcard_intr_reg(card, brcmf_sdbrcm_isr, bus); + brcmf_sdcard_intr_disable(bus->sdiodev); + ret = brcmf_sdcard_intr_reg(bus->sdiodev, brcmf_sdbrcm_isr, bus); if (ret != 0) { BRCMF_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n", __func__, ret)); @@ -5584,7 +5589,7 @@ fail: } static bool -brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) +brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) { u8 clkctl = 0; int err = 0; @@ -5600,7 +5605,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) #ifdef BCMDBG printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", - brcmf_sdcard_reg_read(bus->card, SI_ENUM_BASE, 4)); + brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); #endif /* BCMDBG */ @@ -5609,11 +5614,12 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) * programs PLL control regs */ - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, - BRCMF_INIT_CLKCTL1, &err); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + BRCMF_INIT_CLKCTL1, &err); if (!err) clkctl = - brcmf_sdcard_cfg_read(card, SDIO_FUNC_1, + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { @@ -5639,7 +5645,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) /* Get info on the ARM and SOCRAM cores... */ if (!BRCMF_NOPMU(bus)) { - brcmf_sdcard_reg_read(bus->card, + brcmf_sdcard_reg_read(bus->sdiodev, CORE_SB(bus->ci->armcorebase, sbidhigh), 4); bus->orig_ramsize = bus->ci->ramsize; if (!(bus->orig_ramsize)) { @@ -5658,8 +5664,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva) /* Set core control so an SDIO reset does a backplane reset */ reg_addr = bus->ci->buscorebase + offsetof(struct sdpcmd_regs, corecontrol); - reg_val = brcmf_sdcard_reg_read(bus->card, reg_addr, sizeof(u32)); - brcmf_sdcard_reg_write(bus->card, reg_addr, sizeof(u32), + reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); + brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), reg_val | CC_BPRESEN); brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); @@ -5680,7 +5686,7 @@ fail: return false; } -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus, void *card) +static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) { BRCMF_TRACE(("%s: Enter\n", __func__)); @@ -5720,7 +5726,7 @@ fail: return false; } -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) +static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) { s32 fnum; @@ -5731,7 +5737,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) #endif /* SDTEST */ /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(card, SDIO_FUNC_0, SDIO_CCCR_IOEx, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); bus->drvr->busstate = BRCMF_BUS_DOWN; @@ -5739,8 +5745,8 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) bus->rxflow = false; /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0, - NULL); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); /* ...and initialize clock/power states */ bus->clkstate = CLK_SDONLY; @@ -5749,8 +5755,9 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) /* Query the F2 block size, set roundup accordingly */ fnum = 2; - if (brcmf_sdcard_iovar_op(card, "sd_blocksize", &fnum, sizeof(s32), - &bus->blocksize, sizeof(s32), false) != 0) { + if (brcmf_sdcard_iovar_op(bus->sdiodev, "sd_blocksize", &fnum, + sizeof(s32), &bus->blocksize, + sizeof(s32), false) != 0) { bus->blocksize = 0; BRCMF_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize")); } else { @@ -5761,7 +5768,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus, void *card) /* Query if bus module supports packet chaining, default to use if supported */ - if (brcmf_sdcard_iovar_op(card, "sd_rxchain", NULL, 0, + if (brcmf_sdcard_iovar_op(bus->sdiodev, "sd_rxchain", NULL, 0, &bus->sd_rxchain, sizeof(s32), false) != 0) bus->sd_rxchain = false; @@ -5797,8 +5804,8 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) if (bus) { /* De-register interrupt handler */ - brcmf_sdcard_intr_disable(bus->card); - brcmf_sdcard_intr_dereg(bus->card); + brcmf_sdcard_intr_disable(bus->sdiodev); + brcmf_sdcard_intr_dereg(bus->sdiodev); if (bus->drvr) { brcmf_detach(bus->drvr); @@ -6090,7 +6097,7 @@ brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, void *handle) { return brcmf_sdcard_send_buf - (bus->card, addr, fn, flags, buf, nbytes, pkt, complete, + (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt, complete, handle); } @@ -6129,10 +6136,9 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) /* Turn on WLAN */ /* Attempt to re-attach & download */ - if (brcmf_sdbrcm_probe_attach(bus, bus->card, - SI_ENUM_BASE)) { + if (brcmf_sdbrcm_probe_attach(bus, SI_ENUM_BASE)) { /* Attempt to download binary to the dongle */ - if (brcmf_sdbrcm_probe_init(bus, bus->card)) { + if (brcmf_sdbrcm_probe_init(bus)) { /* Re-init bus, enable F2 transfer */ brcmf_sdbrcm_bus_init(bus->drvr, false); @@ -6157,7 +6163,7 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) } static int -brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_card *card, +brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs) { u32 regdata; @@ -6169,7 +6175,7 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_card *card, * other ways of recognition should be added here. */ ci->cccorebase = regs; - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_CC_REG(ci->cccorebase, chipid), 4); ci->chip = regdata & CID_ID_MASK; ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; @@ -6191,15 +6197,15 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_card *card, return -ENODEV; } - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->cccorebase, sbidhigh), 4); ci->ccrev = SBCOREREV(regdata); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); ci->pmurev = regdata & PCAP_REV_MASK; - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->buscorebase, sbidhigh), 4); ci->buscorerev = SBCOREREV(regdata); ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; @@ -6209,87 +6215,87 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_card *card, ci->buscorerev, ci->buscoretype)); /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(card, + ci->cccaps = brcmf_sdcard_reg_read(sdiodev, CORE_CC_REG(ci->cccorebase, capabilities), 4); return 0; } static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_card *card, u32 corebase) +brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) { u32 regdata; - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); if (regdata & SBTML_RESET) return; - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { /* * set target reject and spin until busy is clear * (preserve core-specific bits) */ - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4, - regdata | SBTML_REJ); + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), + 4, regdata | SBTML_REJ); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(card, + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4) & SBTMH_BUSY), 100000); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4); if (regdata & SBTMH_BUSY) BRCMF_ERROR(("%s: ARM core still busy\n", __func__)); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbidlow), 4); if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) | SBIM_RJ; - brcmf_sdcard_reg_write(card, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, regdata); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4); udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(card, + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) & SBIM_BY), 100000); } /* set reset and reject while enabling the clocks */ - brcmf_sdcard_reg_write(card, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | SBTML_REJ | SBTML_RESET)); - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); udelay(10); /* clear the initiator reject bit */ - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbidlow), 4); if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(card, + regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) & ~SBIM_RJ; - brcmf_sdcard_reg_write(card, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, regdata); } } /* leave reset and reject asserted */ - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, (SBTML_REJ | SBTML_RESET)); udelay(1); } @@ -6315,8 +6321,8 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) /* bus/core/clk setup for register access */ /* Try forcing SDIO core to do ALPAvail request only */ clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, - clkset, &err); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); if (err) { BRCMF_ERROR(("%s: error writing for HT off\n", __func__)); goto fail; @@ -6324,11 +6330,11 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) /* If register supported, wait for ALPAvail and then force ALP */ /* This may take up to 15 milliseconds */ - clkval = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1, + clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, NULL); if ((clkval & ~SBSDIO_AVBITS) == clkset) { SPINWAIT(((clkval = - brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, NULL)), !SBSDIO_ALPAV(clkval)), @@ -6341,7 +6347,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) } clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_FORCE_ALP; - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); udelay(65); @@ -6353,10 +6359,10 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) } /* Also, disable the extra SDIO pull-ups */ - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, - 0, NULL); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); - err = brcmf_sdbrcm_chip_recognition(bus->card, ci, regs); + err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); if (err) goto fail; @@ -6364,24 +6370,24 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) * Make sure any on-chip ARM is off (in case strapping is wrong), * or downloaded code was already running. */ - brcmf_sdbrcm_chip_disablecore(bus->card, ci->armcorebase); + brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); - brcmf_sdcard_reg_write(bus->card, + brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); - brcmf_sdcard_reg_write(bus->card, + brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); /* WAR: cmd52 backplane read so core HW will drop ALPReq */ - clkval = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1, + clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 0, NULL); /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, - 0, NULL); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); bus->ci = ci; return 0; @@ -6392,7 +6398,7 @@ fail: } static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_card *card, u32 corebase) +brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) { u32 regdata; @@ -6400,37 +6406,38 @@ brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_card *card, u32 corebase) * Must do the disable sequence first to work for * arbitrary current core state. */ - brcmf_sdbrcm_chip_disablecore(card, corebase); + brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); /* * Now do the initialization sequence. * set reset while enabling the clock and * forcing them on throughout the core */ - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | SBTML_RESET); udelay(1); - regdata = brcmf_sdcard_reg_read(card, CORE_SB(corebase, sbtmstatehigh), - 4); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4); if (regdata & SBTMH_SERR) - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatehigh), - 4, 0); + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4, 0); - regdata = brcmf_sdcard_reg_read(card, CORE_SB(corebase, sbimstate), 4); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4); if (regdata & (SBIM_IBE | SBIM_TO)) - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbimstate), 4, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, regdata & ~(SBIM_IBE | SBIM_TO)); /* clear reset and allow it to propagate throughout the core */ - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, (SICF_FGC << SBTML_SICF_SHIFT) | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); udelay(1); /* leave clock enabled */ - brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); udelay(1); } @@ -6524,15 +6531,15 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, } } - brcmf_sdcard_reg_write(bus->card, + brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4, 1); - cc_data_temp = brcmf_sdcard_reg_read(bus->card, + cc_data_temp = brcmf_sdcard_reg_read(bus->sdiodev, CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); cc_data_temp &= ~str_mask; drivestrength_sel <<= str_shift; cc_data_temp |= drivestrength_sel; - brcmf_sdcard_reg_write(bus->card, + brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4, cc_data_temp); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 22441e95e86..b82a462c5a1 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -116,9 +116,6 @@ #define SUCCESS 0 #define ERROR 1 -/* forward declarations */ -struct brcmf_sdio_card; - struct brcmf_sdreg { int func; int offset; @@ -158,20 +155,22 @@ struct brcmf_sdmmc_instance { struct brcmf_sdio_dev { struct sdio_func *func1; struct sdio_func *func2; - struct brcmf_sdio_card *card; + void *sdioh; /* sdioh handler */ + u32 sbwad; /* Save backplane window address */ + bool regfail; /* status of last reg_r/w call */ void *bus; }; /* Enable/disable SD interrupt */ -extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card); -extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card); +extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_dev *sdiodev); +extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_dev *sdiodev); /* Register/deregister device interrupt handler. */ extern int -brcmf_sdcard_intr_reg(struct brcmf_sdio_card *card, +brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, void (*fn)(void *), void *argh); -extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card *card); +extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev); /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface). * fn: function number @@ -179,17 +178,17 @@ extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card *card); * data: data byte to write * err: pointer to error code (or NULL) */ -extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint func, +extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func, u32 addr, int *err); -extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint func, +extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func, u32 addr, u8 data, int *err); /* Read/Write 4bytes from/to cfg space */ extern u32 -brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num, +brcmf_sdcard_cfg_read_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, int *err); -extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, +extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u32 data, int *err); @@ -200,7 +199,7 @@ extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, * Internally, this routine uses the values from the cis base regs (0x9-0xB) * to form an SDIO-space address to read the data from. */ -extern int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, +extern int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 *cis, uint length); /* Synchronous access to device (client) core registers via CMD53 to F1. @@ -209,14 +208,14 @@ extern int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, * data: data for register write */ extern u32 -brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size); +brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size); extern u32 -brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size, +brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, u32 data); /* Indicate if last reg read/write failed */ -extern bool brcmf_sdcard_regfail(struct brcmf_sdio_card *card); +extern bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev); /* Buffer transfer to/from device (client) core via cmd53. * fn: function number @@ -231,13 +230,13 @@ extern bool brcmf_sdcard_regfail(struct brcmf_sdio_card *card); * NOTE: Async operation is not currently supported. */ extern int -brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, +brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, void *pkt, void (*complete)(void *handle, int status, bool sync_waiting), void *handle); extern int -brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, +brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt, void (*complete)(void *handle, int status, bool sync_waiting), @@ -262,16 +261,16 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn, * nbytes: number of bytes to transfer to/from buf * Returns 0 or error code. */ -extern int brcmf_sdcard_rwdata(struct brcmf_sdio_card *card, uint rw, u32 addr, - u8 *buf, uint nbytes); +extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, + u32 addr, u8 *buf, uint nbytes); /* Issue an abort to the specified function */ -extern int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn); +extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn); /* Miscellaneous knob tweaker. */ -extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name, - void *params, int plen, void *arg, int len, - bool set); +extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, + const char *name, void *params, int plen, + void *arg, int len, bool set); /* helper functions */ @@ -286,7 +285,7 @@ extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); /* Function to return current window addr */ -extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card); +extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); /* Allocate/init/free per-OS private data */ extern int brcmf_sdioh_osinit(struct sdioh_info *sd); @@ -355,4 +354,7 @@ extern uint sd_f2_blocksize; extern struct brcmf_sdmmc_instance *gInstance; +extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, + u32 regsva, struct brcmf_sdio_dev *sdiodev); +extern void brcmf_sdbrcm_disconnect(void *ptr); #endif /* _BRCM_SDH_H_ */ From f5c9c0c81d8589656d0e2ca7dd694a75e35ea1bd Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:54 +0200 Subject: [PATCH 0092/1519] staging: brcm80211: remove dead code from brcmfmac brcmf_sdcrad_cfg_read_word and brcmf_sdcard_cfg_write_word are not used by anyone. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 35 ------------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 9 ----- 2 files changed, 44 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 31e6728560f..6cabda5c718 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -120,41 +120,6 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, __func__, fnc_num, addr, data)); } -u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, - u32 addr, int *err) -{ - int status; - u32 data = 0; - - status = brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, - SDIOH_READ, fnc_num, addr, &data, 4); - - if (err) - *err = status; - - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", - __func__, fnc_num, addr, data)); - - return data; -} - -void -brcmf_sdcard_cfg_write_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, - u32 addr, u32 data, int *err) -{ - int status; - - status = - brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, - SDIOH_WRITE, fnc_num, addr, &data, 4); - - if (err) - *err = status; - - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n", - __func__, fnc_num, addr, data)); -} - int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, uint length) { diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index b82a462c5a1..3c97af4fb45 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -183,15 +183,6 @@ extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func, extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func, u32 addr, u8 data, int *err); -/* Read/Write 4bytes from/to cfg space */ -extern u32 -brcmf_sdcard_cfg_read_word(struct brcmf_sdio_dev *sdiodev, uint fnc_num, - u32 addr, int *err); - -extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_dev *sdiodev, - uint fnc_num, u32 addr, - u32 data, int *err); - /* Read CIS content for specified function. * fn: function whose CIS is being requested (0 is common CIS) * cis: pointer to memory location to place results From b1b8b756d24c529cb5cb4f9d2d8dd75156f770ac Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:55 +0200 Subject: [PATCH 0093/1519] staging: brcm80211: remove dead client interrupt code from brcmfmac In fullmac, brcmf_sdcard_intr_enable/disable is a legacy layer and doesn't really enable/disable any interrupt. This patch removes the corresponding code. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 10 -- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 109 +----------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 53 +-------- .../staging/brcm80211/brcmfmac/sdio_host.h | 20 ---- 4 files changed, 3 insertions(+), 189 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 6cabda5c718..3a6c015b0e3 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -53,16 +53,6 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, len, set); } -int brcmf_sdcard_intr_enable(struct brcmf_sdio_dev *sdiodev) -{ - return brcmf_sdioh_interrupt_set(sdiodev->sdioh, true); -} - -int brcmf_sdcard_intr_disable(struct brcmf_sdio_dev *sdiodev) -{ - return brcmf_sdioh_interrupt_set(sdiodev->sdioh, false); -} - int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, void (*fn)(void *), void *argh) { diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index edcd98eb23f..db43b09829d 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -34,8 +34,6 @@ #include "dhd_dbg.h" #include "wl_cfg80211.h" -#define CLIENT_INTR 0x100 /* Get rid of this! */ - #if !defined(SDIO_VENDOR_ID_BROADCOM) #define SDIO_VENDOR_ID_BROADCOM 0x02d0 #endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */ @@ -46,11 +44,6 @@ #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ -struct sdos_info { - struct sdioh_info *sd; - spinlock_t lock; -}; - static void brcmf_sdioh_irqhandler(struct sdio_func *func); static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func); static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr); @@ -174,14 +167,8 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0) BRCMF_ERROR(("sdioh_attach: out of memory\n")); return NULL; } - if (brcmf_sdioh_osinit(sd) != 0) { - BRCMF_ERROR(("%s:sdioh_sdmmc_osinit() failed\n", __func__)); - kfree(sd); - return NULL; - } sd->num_funcs = 2; - sd->use_client_ints = true; sd->client_block_size[0] = 64; gInstance->sd = sd; @@ -234,9 +221,6 @@ extern int brcmf_sdioh_detach(struct sdioh_info *sd) sdio_disable_func(gInstance->func[1]); sdio_release_host(gInstance->func[1]); - /* deregister irq */ - brcmf_sdioh_osfree(sd); - kfree(sd); } return 0; @@ -304,7 +288,6 @@ extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) enum { IOV_MSGLEVEL = 1, IOV_BLOCKSIZE, - IOV_USEINTS, IOV_NUMINTS, IOV_DEVREG, IOV_HCIREGS, @@ -314,7 +297,6 @@ enum { const struct brcmu_iovar sdioh_iovars[] = { {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0},/* ((fn << 16) | size) */ - {"sd_ints", IOV_USEINTS, 0, IOVT_BOOL, 0}, {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0}, {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} , @@ -429,20 +411,6 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, memcpy(arg, &int_val, val_size); break; - case IOV_GVAL(IOV_USEINTS): - int_val = (s32) si->use_client_ints; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_USEINTS): - si->use_client_ints = (bool) int_val; - if (si->use_client_ints) - si->intmask |= CLIENT_INTR; - else - si->intmask &= ~CLIENT_INTR; - - break; - case IOV_GVAL(IOV_NUMINTS): int_val = (s32) si->intrcount; memcpy(arg, &int_val, val_size); @@ -881,20 +849,6 @@ extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func) return 0; } -/* Disable device interrupt */ -void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd) -{ - BRCMF_TRACE(("%s: %d\n", __func__, sd->use_client_ints)); - sd->intmask &= ~CLIENT_INTR; -} - -/* Enable device interrupt */ -void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd) -{ - BRCMF_TRACE(("%s: %d\n", __func__, sd->use_client_ints)); - sd->intmask |= CLIENT_INTR; -} - /* Read client card reg */ int brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, @@ -929,15 +883,8 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) sdio_release_host(gInstance->func[0]); - if (sd->use_client_ints) { - sd->intrcount++; - (sd->intr_handler) (sd->intr_handler_arg); - } else { - BRCMF_ERROR(("brcmf: ***IRQHandler\n")); - - BRCMF_ERROR(("%s: Not ready for intr: enabled %d, handler %p\n", - __func__, sd->client_intr_enabled, sd->intr_handler)); - } + sd->intrcount++; + (sd->intr_handler) (sd->intr_handler_arg); sdio_claim_host(gInstance->func[0]); } @@ -1060,58 +1007,6 @@ static int brcmf_sdio_resume(struct device *dev) } #endif /* CONFIG_PM_SLEEP */ -int brcmf_sdioh_osinit(struct sdioh_info *sd) -{ - struct sdos_info *sdos; - - sdos = kmalloc(sizeof(struct sdos_info), GFP_ATOMIC); - sd->sdos_info = (void *)sdos; - if (sdos == NULL) - return -ENOMEM; - - sdos->sd = sd; - spin_lock_init(&sdos->lock); - return 0; -} - -void brcmf_sdioh_osfree(struct sdioh_info *sd) -{ - struct sdos_info *sdos; - - sdos = (struct sdos_info *)sd->sdos_info; - kfree(sdos); -} - -/* Interrupt enable/disable */ -int brcmf_sdioh_interrupt_set(struct sdioh_info *sd, bool enable) -{ - unsigned long flags; - struct sdos_info *sdos; - - BRCMF_TRACE(("%s: %s\n", __func__, enable ? "Enabling" : "Disabling")); - - sdos = (struct sdos_info *)sd->sdos_info; - - if (enable && !(sd->intr_handler && sd->intr_handler_arg)) { - BRCMF_ERROR(("%s: no handler registered, will not enable\n", - __func__)); - return -EINVAL; - } - - /* Ensure atomicity for enable/disable calls */ - spin_lock_irqsave(&sdos->lock, flags); - - sd->client_intr_enabled = enable; - if (enable) - brcmf_sdioh_dev_intr_on(sd); - else - brcmf_sdioh_dev_intr_off(sd); - - spin_unlock_irqrestore(&sdos->lock, flags); - - return 0; -} - /* * module init */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 4fc17f80f74..126090b45b5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -655,7 +655,6 @@ struct brcmf_bus { bool intr; /* Use interrupts */ bool poll; /* Use polling */ bool ipend; /* Device interrupt is pending */ - bool intdis; /* Interrupts disabled by isr */ uint intrcount; /* Count of device interrupt callbacks */ uint lastintrs; /* Count as of last watchdog timer */ uint spurious; /* Count of spurious interrupts */ @@ -1272,9 +1271,6 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) if (bus->dpc_sched || bus->rxskip || pktq_len(&bus->txq)) return -EBUSY; - /* Disable SDIO interrupts (no longer interested) */ - brcmf_sdcard_intr_disable(bus->sdiodev); - /* Make sure the controller has the bus up */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -1334,12 +1330,6 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) /* Change state */ bus->sleeping = false; - - /* Enable interrupts again */ - if (bus->intr && (bus->drvr->busstate == BRCMF_BUS_DATA)) { - bus->intdis = false; - brcmf_sdcard_intr_enable(bus->sdiodev); - } } return 0; @@ -2612,15 +2602,6 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, case IOV_SVAL(IOV_INTR): bus->intr = bool_val; - bus->intdis = false; - if (bus->drvr->up) { - BRCMF_INTR(("%s: %s SDIO interrupts\n", __func__, - bus->intr ? "enable" : "disable")); - if (bus->intr) - brcmf_sdcard_intr_enable(bus->sdiodev); - else - brcmf_sdcard_intr_disable(bus->sdiodev); - } break; case IOV_GVAL(IOV_POLLRATE): @@ -3294,7 +3275,6 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) /* Turn off the bus (F2), free any pending packets */ BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); - brcmf_sdcard_intr_disable(bus->sdiodev); brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); @@ -3411,17 +3391,6 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* Set bus state according to enable result */ drvr->busstate = BRCMF_BUS_DATA; - - bus->intdis = false; - if (bus->intr) { - BRCMF_INTR(("%s: enable SDIO device interrupts\n", - __func__)); - brcmf_sdcard_intr_enable(bus->sdiodev); - } else { - BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); - brcmf_sdcard_intr_disable(bus->sdiodev); - } - } else { @@ -4854,17 +4823,6 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) bus->intstatus = intstatus; clkwait: - /* Re-enable interrupts to detect new device events (mailbox, rx frame) - * or clock availability. (Allows tx loop to check ipend if desired.) - * (Unless register access seems hosed, as we may not be able to ACK...) - */ - if (bus->intr && bus->intdis && !brcmf_sdcard_regfail(bus->sdiodev)) { - BRCMF_INTR(("%s: enable SDIO interrupts, rxdone %d" - " framecnt %d\n", __func__, rxdone, framecnt)); - bus->intdis = false; - brcmf_sdcard_intr_enable(bus->sdiodev); - } - if (DATAOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) { int ret, i; @@ -4982,14 +4940,9 @@ void brcmf_sdbrcm_isr(void *arg) } /* Disable additional interrupts (is this needed now)? */ - if (bus->intr) - BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); - else + if (!bus->intr) BRCMF_ERROR(("brcmf_sdbrcm_isr() w/o interrupt configured!\n")); - brcmf_sdcard_intr_disable(bus->sdiodev); - bus->intdis = true; - #if defined(SDIO_ISR_THREAD) BRCMF_TRACE(("Calling brcmf_sdbrcm_dpc() from %s\n", __func__)); while (brcmf_sdbrcm_dpc(bus)) @@ -5305,8 +5258,6 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) if (intstatus) { bus->pollcnt++; bus->ipend = true; - if (bus->intr) - brcmf_sdcard_intr_disable(bus->sdiodev); bus->dpc_sched = true; brcmf_sdbrcm_sched_dpc(bus); @@ -5555,7 +5506,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Register interrupt callback, but mask it (not operational yet). */ BRCMF_INTR(("%s: disable SDIO interrupts (not interested yet)\n", __func__)); - brcmf_sdcard_intr_disable(bus->sdiodev); ret = brcmf_sdcard_intr_reg(bus->sdiodev, brcmf_sdbrcm_isr, bus); if (ret != 0) { BRCMF_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n", @@ -5804,7 +5754,6 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) if (bus) { /* De-register interrupt handler */ - brcmf_sdcard_intr_disable(bus->sdiodev); brcmf_sdcard_intr_dereg(bus->sdiodev); if (bus->drvr) { diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 3c97af4fb45..4fcba2ad368 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -124,18 +124,14 @@ struct brcmf_sdreg { struct sdioh_info { struct osl_info *osh; /* osh handler */ - bool client_intr_enabled; /* interrupt connnected flag */ bool intr_handler_valid; /* client driver interrupt handler valid */ void (*intr_handler)(void *); /* registered interrupt handler */ void *intr_handler_arg; /* argument to call interrupt handler */ - u16 intmask; /* Current active interrupts */ - void *sdos_info; /* Pointer to per-OS private data */ uint irq; /* Client irq */ int intrcount; /* Client interrupts */ bool sd_blockmode; /* sd_blockmode == false => 64 Byte Cmd 53s. */ /* Must be on for sd_multiblock to be effective */ - bool use_client_ints; /* If this is false, make sure to restore */ int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ u8 num_funcs; /* Supported funcs on client */ u32 com_cis_ptr; @@ -161,10 +157,6 @@ struct brcmf_sdio_dev { void *bus; }; -/* Enable/disable SD interrupt */ -extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_dev *sdiodev); -extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_dev *sdiodev); - /* Register/deregister device interrupt handler. */ extern int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, @@ -278,14 +270,6 @@ extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); /* Function to return current window addr */ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); -/* Allocate/init/free per-OS private data */ -extern int brcmf_sdioh_osinit(struct sdioh_info *sd); -extern void brcmf_sdioh_osfree(struct sdioh_info *sd); - -/* Core interrupt enable/disable of device interrupts */ -extern void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd); -extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd); - /* attach, return handler on success, NULL if failed. * The handler shall be provided by all subsequent calls. No local cache * cfghdl points to the starting address of pci device mapped memory @@ -299,10 +283,6 @@ brcmf_sdioh_interrupt_register(struct sdioh_info *si, extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si); -/* enable or disable SD interrupt */ -extern int -brcmf_sdioh_interrupt_set(struct sdioh_info *si, bool enable_disable); - /* read or write one byte using cmd52 */ extern int brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr, From cc1e1a1bc65bfc06875cf91af3ce68204430eae3 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 8 Aug 2011 15:58:56 +0200 Subject: [PATCH 0094/1519] staging: brcm80211: remove function pointer of interrupt isr in brcmfmac The use of function pointer of bus interrupt isr is no longer needed in fullmac as there is only one available isr. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 5 ++--- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 19 +++---------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 3 ++- .../staging/brcm80211/brcmfmac/sdio_host.h | 10 +++------- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 3a6c015b0e3..c9893e9287b 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -53,10 +53,9 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, len, set); } -int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, - void (*fn)(void *), void *argh) +int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_register(sdiodev->sdioh, fn, argh); + return brcmf_sdioh_interrupt_register(sdiodev->sdioh); } int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index db43b09829d..1256847ae91 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -228,19 +228,9 @@ extern int brcmf_sdioh_detach(struct sdioh_info *sd) /* Configure callback to client when we receive client interrupt */ extern int -brcmf_sdioh_interrupt_register(struct sdioh_info *sd, void (*fn)(void *), - void *argh) +brcmf_sdioh_interrupt_register(struct sdioh_info *sd) { BRCMF_TRACE(("%s: Entering\n", __func__)); - if (fn == NULL) { - BRCMF_ERROR(("%s: interrupt handler is NULL, not registering\n", - __func__)); - return -EINVAL; - } - - sd->intr_handler = fn; - sd->intr_handler_arg = argh; - sd->intr_handler_valid = true; /* register and unmask irq */ if (gInstance->func[2]) { @@ -277,10 +267,6 @@ extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) sdio_release_host(gInstance->func[2]); } - sd->intr_handler_valid = false; - sd->intr_handler = NULL; - sd->intr_handler_arg = NULL; - return 0; } @@ -877,6 +863,7 @@ brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, static void brcmf_sdioh_irqhandler(struct sdio_func *func) { struct sdioh_info *sd; + struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); BRCMF_TRACE(("brcmf: ***IRQHandler\n")); sd = gInstance->sd; @@ -884,7 +871,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) sdio_release_host(gInstance->func[0]); sd->intrcount++; - (sd->intr_handler) (sd->intr_handler_arg); + brcmf_sdbrcm_isr(sdiodev->bus); sdio_claim_host(gInstance->func[0]); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 126090b45b5..8bea86595d6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -5424,6 +5424,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, goto fail; } bus->sdiodev = sdiodev; + sdiodev->bus = bus; bus->bus = BRCMF_BUS; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, @@ -5506,7 +5507,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Register interrupt callback, but mask it (not operational yet). */ BRCMF_INTR(("%s: disable SDIO interrupts (not interested yet)\n", __func__)); - ret = brcmf_sdcard_intr_reg(bus->sdiodev, brcmf_sdbrcm_isr, bus); + ret = brcmf_sdcard_intr_reg(bus->sdiodev); if (ret != 0) { BRCMF_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n", __func__, ret)); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 4fcba2ad368..c5a68c0382a 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -124,9 +124,6 @@ struct brcmf_sdreg { struct sdioh_info { struct osl_info *osh; /* osh handler */ - bool intr_handler_valid; /* client driver interrupt handler valid */ - void (*intr_handler)(void *); /* registered interrupt handler */ - void *intr_handler_arg; /* argument to call interrupt handler */ uint irq; /* Client irq */ int intrcount; /* Client interrupts */ @@ -159,8 +156,7 @@ struct brcmf_sdio_dev { /* Register/deregister device interrupt handler. */ extern int -brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev, - void (*fn)(void *), void *argh); +brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev); @@ -278,8 +274,7 @@ extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl); extern int brcmf_sdioh_detach(struct sdioh_info *si); extern int -brcmf_sdioh_interrupt_register(struct sdioh_info *si, - void (*sdioh_cb_fn)(void *), void *argh); +brcmf_sdioh_interrupt_register(struct sdioh_info *si); extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si); @@ -328,4 +323,5 @@ extern struct brcmf_sdmmc_instance *gInstance; extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, u32 regsva, struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdbrcm_disconnect(void *ptr); +extern void brcmf_sdbrcm_isr(void *arg); #endif /* _BRCM_SDH_H_ */ From 09f882b0713fc1a2f1b48342179f70131f5e4d0a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:58:57 +0200 Subject: [PATCH 0095/1519] staging: brcm80211: cleanup to get rid of 'over 80 character' line One checkpatch warning was remaining in the brcmsmac driver. The code has been restructured to get rid of this last checkpatch warning. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index f5f914fccf8..2a139aa4005 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6253,14 +6253,13 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, /* merge rateset coming in with the current mcsset */ if (N_ENAB(wlc->pub)) { + struct brcms_bss_info *mcsset_bss; if (bsscfg->associated) - memcpy(rs.mcs, - ¤t_bss->rateset.mcs[0], - MCSSET_LEN); + mcsset_bss = current_bss; else - memcpy(rs.mcs, - &wlc->default_bss->rateset.mcs[0], - MCSSET_LEN); + mcsset_bss = wlc->default_bss; + memcpy(rs.mcs, &mcsset_bss->rateset.mcs[0], + MCSSET_LEN); } bcmerror = brcms_c_set_rateset(wlc, &rs); From 821e4e93172e4f7d5ac1eade04665c3dc5049c4a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:58 +0200 Subject: [PATCH 0096/1519] staging: brcm80211: removed unused bus code from softmac Code cleanup. For the softmac, the 'bustype' in use is always PCI_BUS. Hence code related to dealing with different bus types (eg: PCI_BUS, JTAG_BUS, SI_BUS) could be removed. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 480 ++++++------------ drivers/staging/brcm80211/brcmsmac/aiutils.h | 12 +- drivers/staging/brcm80211/brcmsmac/dma.c | 13 +- .../staging/brcm80211/brcmsmac/mac80211_if.c | 17 +- .../staging/brcm80211/brcmsmac/mac80211_if.h | 3 +- drivers/staging/brcm80211/brcmsmac/main.c | 113 ++--- drivers/staging/brcm80211/brcmsmac/nicpci.c | 4 +- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 17 +- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 1 - .../staging/brcm80211/brcmsmac/phy/phy_int.h | 3 +- drivers/staging/brcm80211/brcmsmac/pub.h | 2 +- drivers/staging/brcm80211/brcmsmac/srom.c | 5 +- drivers/staging/brcm80211/brcmsmac/srom.h | 4 +- drivers/staging/brcm80211/brcmsmac/types.h | 5 +- 14 files changed, 228 insertions(+), 451 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 4b1c60ffc47..37edd1ce312 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -12,7 +12,10 @@ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * File contents: support functions for PCI/PCIe */ + #include #include @@ -488,30 +491,12 @@ void ai_scan(struct si_pub *sih, void *regs) erombase = R_REG(&cc->eromptr); - switch (sih->bustype) { - case SI_BUS: - eromptr = (u32 *) REG_MAP(erombase, SI_CORE_SIZE); - break; + /* Set wrappers address */ + sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE); - case PCI_BUS: - /* Set wrappers address */ - sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE); - - /* Now point the window at the erom */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); - eromptr = regs; - break; - - case SPI_BUS: - case SDIO_BUS: - eromptr = (u32 *)(unsigned long)erombase; - break; - - default: - SI_ERROR(("Don't know how to do AXI enumertion on bus %d\n", - sih->bustype)); - return; - } + /* Now point the window at the erom */ + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); + eromptr = regs; eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, " @@ -684,7 +669,8 @@ void ai_scan(struct si_pub *sih, void *regs) return; } -/* This function changes the logical "focus" to the indicated core. +/* + * This function changes the logical "focus" to the indicated core. * Return the current core's virtual address. */ void *ai_setcoreidx(struct si_pub *sih, uint coreidx) @@ -692,47 +678,17 @@ void *ai_setcoreidx(struct si_pub *sih, uint coreidx) struct si_info *sii = SI_INFO(sih); u32 addr = sii->coresba[coreidx]; u32 wrap = sii->wrapba[coreidx]; - void *regs; if (coreidx >= sii->numcores) return NULL; - switch (sih->bustype) { - case SI_BUS: - /* map new one */ - if (!sii->regs[coreidx]) - sii->regs[coreidx] = REG_MAP(addr, SI_CORE_SIZE); - - sii->curmap = regs = sii->regs[coreidx]; - if (!sii->wrappers[coreidx]) - sii->wrappers[coreidx] = REG_MAP(wrap, SI_CORE_SIZE); - - sii->curwrap = sii->wrappers[coreidx]; - break; - - case PCI_BUS: - /* point bar0 window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr); - regs = sii->curmap; - /* point bar0 2nd 4KB window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap); - break; - - case SPI_BUS: - case SDIO_BUS: - sii->curmap = regs = (void *)(unsigned long)addr; - sii->curwrap = (void *)(unsigned long)wrap; - break; - - default: - regs = NULL; - break; - } - - sii->curmap = regs; + /* point bar0 window */ + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr); + /* point bar0 2nd 4KB window */ + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap); sii->curidx = coreidx; - return regs; + return sii->curmap; } /* Return the number of address spaces in current core */ @@ -905,12 +861,10 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) /* *************** from siutils.c ************** */ /* local prototypes */ static struct si_info *ai_doattach(struct si_info *sii, void *regs, - uint bustype, void *sdh, char **vars, - uint *varsz); -static bool ai_buscore_prep(struct si_info *sii, uint bustype); + void *sdh, char **vars, uint *varsz); +static bool ai_buscore_prep(struct si_info *sii); static bool ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, - uint bustype, u32 savewin, uint *origidx, - void *regs); + u32 savewin, uint *origidx, void *regs); static void ai_nvram_process(struct si_info *sii, char *pvars); /* dev path concatenation util */ @@ -919,20 +873,15 @@ static char *ai_devpathvar(struct si_pub *sih, char *var, int len, static bool _ai_clkctl_cc(struct si_info *sii, uint mode); static bool ai_ispcie(struct si_info *sii); -/* global variable to indicate reservation/release of gpio's */ -static u32 ai_gpioreservation; - /* * Allocate a si handle. * devid - pci device id (used to determine chip#) * osh - opaque OS handle * regs - virtual address of initial core registers - * bustype - pci/sb/sdio/etc * vars - pointer to a pointer area for "environment" variables * varsz - pointer to int to return the size of the vars */ -struct si_pub *ai_attach(void *regs, uint bustype, - void *sdh, char **vars, uint *varsz) +struct si_pub *ai_attach(void *regs, void *sdh, char **vars, uint *varsz) { struct si_info *sii; @@ -943,8 +892,7 @@ struct si_pub *ai_attach(void *regs, uint bustype, return NULL; } - if (ai_doattach(sii, regs, bustype, sdh, vars, varsz) == - NULL) { + if (ai_doattach(sii, regs, sdh, vars, varsz) == NULL) { kfree(sii); return NULL; } @@ -957,17 +905,17 @@ struct si_pub *ai_attach(void *regs, uint bustype, /* global kernel resource */ static struct si_info ksii; -static bool ai_buscore_prep(struct si_info *sii, uint bustype) +static bool ai_buscore_prep(struct si_info *sii) { /* kludge to enable the clock on the 4306 which lacks a slowclock */ - if (bustype == PCI_BUS && !ai_ispcie(sii)) + if (!ai_ispcie(sii)) ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON); return true; } static bool -ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, uint bustype, - u32 savewin, uint *origidx, void *regs) +ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, u32 savewin, + uint *origidx, void *regs) { bool pci, pcie; uint i; @@ -1015,16 +963,14 @@ ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, uint bustype, SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x regs 0x%p\n", i, cid, crev, sii->coresba[i], sii->regs[i])); - if (bustype == PCI_BUS) { - if (cid == PCI_CORE_ID) { - pciidx = i; - pcirev = crev; - pci = true; - } else if (cid == PCIE_CORE_ID) { - pcieidx = i; - pcierev = crev; - pcie = true; - } + if (cid == PCI_CORE_ID) { + pciidx = i; + pcirev = crev; + pci = true; + } else if (cid == PCIE_CORE_ID) { + pcieidx = i; + pcierev = crev; + pcie = true; } /* find the core idx before entering this func. */ @@ -1053,21 +999,19 @@ ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, uint bustype, sii->pub.buscoretype, sii->pub.buscorerev)); /* fixup necessary chip/core configurations */ - if (sii->pub.bustype == PCI_BUS) { - if (SI_FAST(sii)) { - if (!sii->pch) { - sii->pch = (void *)pcicore_init( - &sii->pub, sii->pbus, - (void *)PCIEREGS(sii)); - if (sii->pch == NULL) - return false; - } - } - if (ai_pci_fixcfg(&sii->pub)) { - SI_ERROR(("si_doattach: si_pci_fixcfg failed\n")); - return false; + if (SI_FAST(sii)) { + if (!sii->pch) { + sii->pch = (void *)pcicore_init( + &sii->pub, sii->pbus, + (void *)PCIEREGS(sii)); + if (sii->pch == NULL) + return false; } } + if (ai_pci_fixcfg(&sii->pub)) { + SI_ERROR(("si_doattach: si_pci_fixcfg failed\n")); + return false; + } /* return to the original core */ ai_setcoreidx(&sii->pub, *origidx); @@ -1075,47 +1019,31 @@ ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, uint bustype, return true; } +/* + * get boardtype and boardrev + */ static __used void ai_nvram_process(struct si_info *sii, char *pvars) { uint w = 0; - /* get boardtype and boardrev */ - switch (sii->pub.bustype) { - case PCI_BUS: - /* do a pci config read to get subsystem id and subvendor id */ - pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w); - /* Let nvram variables override subsystem Vend/ID */ - sii->pub.boardvendor = (u16)ai_getdevpathintvar(&sii->pub, - "boardvendor"); - if (sii->pub.boardvendor == 0) - sii->pub.boardvendor = w & 0xffff; - else - SI_ERROR(("Overriding boardvendor: 0x%x instead of " - "0x%x\n", sii->pub.boardvendor, w & 0xffff)); - sii->pub.boardtype = (u16)ai_getdevpathintvar(&sii->pub, - "boardtype"); - if (sii->pub.boardtype == 0) - sii->pub.boardtype = (w >> 16) & 0xffff; - else - SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n" - , sii->pub.boardtype, (w >> 16) & 0xffff)); - break; + /* do a pci config read to get subsystem id and subvendor id */ + pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w); + /* Let nvram variables override subsystem Vend/ID */ + sii->pub.boardvendor = (u16)ai_getdevpathintvar(&sii->pub, + "boardvendor"); + if (sii->pub.boardvendor == 0) + sii->pub.boardvendor = w & 0xffff; + else + SI_ERROR(("Overriding boardvendor: 0x%x instead of " + "0x%x\n", sii->pub.boardvendor, w & 0xffff)); - sii->pub.boardvendor = getintvar(pvars, "manfid"); - sii->pub.boardtype = getintvar(pvars, "prodid"); - break; - - case SI_BUS: - case JTAG_BUS: - sii->pub.boardvendor = PCI_VENDOR_ID_BROADCOM; - sii->pub.boardtype = getintvar(pvars, "prodid"); - if (pvars == NULL || (sii->pub.boardtype == 0)) { - sii->pub.boardtype = getintvar(NULL, "boardtype"); - if (sii->pub.boardtype == 0) - sii->pub.boardtype = 0xffff; - } - break; - } + sii->pub.boardtype = (u16)ai_getdevpathintvar(&sii->pub, + "boardtype"); + if (sii->pub.boardtype == 0) + sii->pub.boardtype = (w >> 16) & 0xffff; + else + SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n" + , sii->pub.boardtype, (w >> 16) & 0xffff)); if (sii->pub.boardtype == 0) SI_ERROR(("si_doattach: unknown board type\n")); @@ -1124,8 +1052,8 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) } static struct si_info *ai_doattach(struct si_info *sii, - void *regs, uint bustype, void *pbus, - char **vars, uint *varsz) + void *regs, void *pbus, + char **vars, uint *varsz) { struct si_pub *sih = &sii->pub; u32 w, savewin; @@ -1143,35 +1071,18 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->curmap = regs; sii->pbus = pbus; - /* check to see if we are a si core mimic'ing a pci core */ - if (bustype == PCI_BUS) { - pci_read_config_dword(sii->pbus, PCI_SPROM_CONTROL, &w); - if (w == 0xffffffff) { - SI_ERROR(("%s: incoming bus is PCI but it's a lie, " - " switching to SI devid:0x%x\n", - __func__, devid)); - bustype = SI_BUS; - } - } - /* find Chipcommon address */ - if (bustype == PCI_BUS) { - pci_read_config_dword(sii->pbus, PCI_BAR0_WIN, &savewin); - if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) - savewin = SI_ENUM_BASE; - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, - SI_ENUM_BASE); - cc = (struct chipcregs *) regs; - } else { - cc = (struct chipcregs *) REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE); - } + pci_read_config_dword(sii->pbus, PCI_BAR0_WIN, &savewin); + if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) + savewin = SI_ENUM_BASE; - sih->bustype = bustype; + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, + SI_ENUM_BASE); + cc = (struct chipcregs *) regs; /* bus/core/clk setup for register access */ - if (!ai_buscore_prep(sii, bustype)) { - SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n", - bustype)); + if (!ai_buscore_prep(sii)) { + SI_ERROR(("si_doattach: si_core_clk_prep failed\n")); return NULL; } @@ -1207,14 +1118,13 @@ static struct si_info *ai_doattach(struct si_info *sii, } /* bus/core/clk setup */ origidx = SI_CC_IDX; - if (!ai_buscore_setup(sii, cc, bustype, savewin, &origidx, regs)) { + if (!ai_buscore_setup(sii, cc, savewin, &origidx, regs)) { SI_ERROR(("si_doattach: si_buscore_setup failed\n")); goto exit; } /* Init nvram from sprom/otp if they exist */ - if (srom_var_init - (&sii->pub, bustype, regs, vars, varsz)) { + if (srom_var_init(&sii->pub, regs, vars, varsz)) { SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } @@ -1283,12 +1193,11 @@ static struct si_info *ai_doattach(struct si_info *sii, } return sii; + exit: - if (sih->bustype == PCI_BUS) { - if (sii->pch) - pcicore_deinit(sii->pch); - sii->pch = NULL; - } + if (sii->pch) + pcicore_deinit(sii->pch); + sii->pch = NULL; return NULL; } @@ -1297,7 +1206,6 @@ static struct si_info *ai_doattach(struct si_info *sii, void ai_detach(struct si_pub *sih) { struct si_info *sii; - uint idx; struct si_pub *si_local = NULL; memcpy(&si_local, &sih, sizeof(struct si_pub **)); @@ -1307,18 +1215,9 @@ void ai_detach(struct si_pub *sih) if (sii == NULL) return; - if (sih->bustype == SI_BUS) - for (idx = 0; idx < SI_MAXCORES; idx++) - if (sii->regs[idx]) { - iounmap(sii->regs[idx]); - sii->regs[idx] = NULL; - } - - if (sih->bustype == PCI_BUS) { - if (sii->pch) - pcicore_deinit(sii->pch); - sii->pch = NULL; - } + if (sii->pch) + pcicore_deinit(sii->pch); + sii->pch = NULL; if (sii != &ksii) kfree(sii); @@ -1483,43 +1382,29 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, if (coreidx >= SI_MAXCORES) return 0; - if (sih->bustype == SI_BUS) { - /* If internal bus, we can always get at everything */ + /* + * If pci/pcie, we can get at pci/pcie regs + * and on newer cores to chipc + */ + if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { + /* Chipc registers are mapped at 12KB */ fast = true; - /* map if does not exist */ - if (!sii->regs[coreidx]) - sii->regs[coreidx] = REG_MAP(sii->coresba[coreidx], - SI_CORE_SIZE); - - r = (u32 *) ((unsigned char *) sii->regs[coreidx] + regoff); - } else if (sih->bustype == PCI_BUS) { + r = (u32 *)((char *)sii->curmap + + PCI_16KB0_CCREGS_OFFSET + regoff); + } else if (sii->pub.buscoreidx == coreidx) { /* - * If pci/pcie, we can get at pci/pcie regs - * and on newer cores to chipc + * pci registers are at either in the last 2KB of + * an 8KB window or, in pcie and pci rev 13 at 8KB */ - if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { - /* Chipc registers are mapped at 12KB */ - - fast = true; - r = (u32 *) ((char *)sii->curmap + - PCI_16KB0_CCREGS_OFFSET + regoff); - } else if (sii->pub.buscoreidx == coreidx) { - /* - * pci registers are at either in the last 2KB of - * an 8KB window or, in pcie and pci rev 13 at 8KB - */ - fast = true; - if (SI_FAST(sii)) - r = (u32 *) ((char *)sii->curmap + - PCI_16KB0_PCIREGS_OFFSET + - regoff); - else - r = (u32 *) ((char *)sii->curmap + - ((regoff >= SBCONFIGOFF) ? - PCI_BAR0_PCISBR_OFFSET : - PCI_BAR0_PCIREGS_OFFSET) + - regoff); - } + fast = true; + if (SI_FAST(sii)) + r = (u32 *)((char *)sii->curmap + + PCI_16KB0_PCIREGS_OFFSET + regoff); + else + r = (u32 *)((char *)sii->curmap + + ((regoff >= SBCONFIGOFF) ? + PCI_BAR0_PCISBR_OFFSET : + PCI_BAR0_PCIREGS_OFFSET) + regoff); } if (!fast) { @@ -1615,12 +1500,10 @@ static uint ai_slowclk_src(struct si_info *sii) u32 val; if (sii->pub.ccrev < 6) { - if (sii->pub.bustype == PCI_BUS) { - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, - &val); - if (val & PCI_CFG_GPIO_SCS) - return SCC_SS_PCI; - } + pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, + &val); + if (val & PCI_CFG_GPIO_SCS) + return SCC_SS_PCI; return SCC_SS_XTAL; } else if (sii->pub.ccrev < 10) { cc = (struct chipcregs *) ai_setcoreidx(&sii->pub, sii->curidx); @@ -1791,63 +1674,56 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) sii = SI_INFO(sih); - switch (sih->bustype) { + /* pcie core doesn't have any mapping to control the xtal pu */ + if (PCIE(sii)) + return -1; - case PCI_BUS: - /* pcie core doesn't have any mapping to control the xtal pu */ - if (PCIE(sii)) - return -1; + pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); + pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &out); + pci_read_config_dword(sii->pbus, PCI_GPIO_OUTEN, &outen); - pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &out); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUTEN, &outen); + /* + * Avoid glitching the clock if GPRS is already using it. + * We can't actually read the state of the PLLPD so we infer it + * by the value of XTAL_PU which *is* readable via gpioin. + */ + if (on && (in & PCI_CFG_GPIO_XTAL)) + return 0; - /* - * Avoid glitching the clock if GPRS is already using it. - * We can't actually read the state of the PLLPD so we infer it - * by the value of XTAL_PU which *is* readable via gpioin. - */ - if (on && (in & PCI_CFG_GPIO_XTAL)) - return 0; + if (what & XTAL) + outen |= PCI_CFG_GPIO_XTAL; + if (what & PLL) + outen |= PCI_CFG_GPIO_PLL; - if (what & XTAL) - outen |= PCI_CFG_GPIO_XTAL; - if (what & PLL) - outen |= PCI_CFG_GPIO_PLL; - - if (on) { - /* turn primary xtal on */ - if (what & XTAL) { - out |= PCI_CFG_GPIO_XTAL; - if (what & PLL) - out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUT, out); - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUTEN, outen); - udelay(XTAL_ON_DELAY); - } - - /* turn pll on */ - if (what & PLL) { - out &= ~PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUT, out); - mdelay(2); - } - } else { - if (what & XTAL) - out &= ~PCI_CFG_GPIO_XTAL; + if (on) { + /* turn primary xtal on */ + if (what & XTAL) { + out |= PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; pci_write_config_dword(sii->pbus, PCI_GPIO_OUT, out); pci_write_config_dword(sii->pbus, PCI_GPIO_OUTEN, outen); + udelay(XTAL_ON_DELAY); } - default: - return -1; + /* turn pll on */ + if (what & PLL) { + out &= ~PCI_CFG_GPIO_PLL; + pci_write_config_dword(sii->pbus, + PCI_GPIO_OUT, out); + mdelay(2); + } + } else { + if (what & XTAL) + out &= ~PCI_CFG_GPIO_XTAL; + if (what & PLL) + out |= PCI_CFG_GPIO_PLL; + pci_write_config_dword(sii->pbus, + PCI_GPIO_OUT, out); + pci_write_config_dword(sii->pbus, + PCI_GPIO_OUTEN, outen); } return 0; @@ -1893,12 +1769,6 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) if (!fast) { INTR_OFF(sii, intr_val); origidx = sii->curidx; - - if ((sii->pub.bustype == SI_BUS) && - ai_setcore(&sii->pub, MIPS33_CORE_ID, 0) && - (ai_corerev(&sii->pub) <= 7) && (sii->pub.ccrev >= 10)) - goto done; - cc = (struct chipcregs *) ai_setcore(&sii->pub, CC_CORE_ID, 0); } else { cc = (struct chipcregs *) CCREGS_FAST(sii); @@ -1969,7 +1839,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) return mode == CLK_FAST; } -/* Build device path. Support SI, PCI, and JTAG for now. */ +/* Build device path */ int ai_devpath(struct si_pub *sih, char *path, int size) { int slen; @@ -1977,22 +1847,9 @@ int ai_devpath(struct si_pub *sih, char *path, int size) if (!path || size <= 0) return -1; - switch (sih->bustype) { - case SI_BUS: - case JTAG_BUS: - slen = snprintf(path, (size_t) size, "sb/%u/", ai_coreidx(sih)); - break; - case PCI_BUS: - slen = snprintf(path, (size_t) size, "pci/%u/%u/", - ((struct pci_dev *)((SI_INFO(sih))->pbus))->bus->number, - PCI_SLOT( - ((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn)); - break; - - default: - slen = -1; - break; - } + slen = snprintf(path, (size_t) size, "pci/%u/%u/", + ((struct pci_dev *)((SI_INFO(sih))->pbus))->bus->number, + PCI_SLOT(((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn)); if (slen < 0 || slen >= size) { path[0] = '\0'; @@ -2015,15 +1872,11 @@ char *ai_getdevpathvar(struct si_pub *sih, const char *name) /* Get a variable, but only if it has a devpath prefix */ int ai_getdevpathintvar(struct si_pub *sih, const char *name) { -#if defined(BCMBUSTYPE) && (BCMBUSTYPE == SI_BUS) - return getintvar(NULL, name); -#else char varname[SI_DEVPATH_BUFSZ + 32]; ai_devpathvar(sih, varname, sizeof(varname), name); return getintvar(NULL, varname); -#endif } char *ai_getnvramflvar(struct si_pub *sih, const char *name) @@ -2061,9 +1914,6 @@ static bool ai_ispcie(struct si_info *sii) { u8 cap_ptr; - if (sii->pub.bustype != PCI_BUS) - return false; - cap_ptr = pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL, NULL); @@ -2088,10 +1938,6 @@ void ai_pci_up(struct si_pub *sih) sii = SI_INFO(sih); - /* if not pci bus, we're done */ - if (sih->bustype != PCI_BUS) - return; - if (PCI_FORCEHT(sii)) _ai_clkctl_cc(sii, CLK_FAST); @@ -2117,10 +1963,6 @@ void ai_pci_down(struct si_pub *sih) sii = SI_INFO(sih); - /* if not pci bus, we're done */ - if (sih->bustype != PCI_BUS) - return; - /* release FORCEHT since chip is going to "down" state */ if (PCI_FORCEHT(sii)) _ai_clkctl_cc(sii, CLK_DYNAMIC); @@ -2141,9 +1983,6 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) sii = SI_INFO(sih); - if (sii->pub.bustype != PCI_BUS) - return; - if (PCI(sii)) { /* get current core index */ idx = sii->curidx; @@ -2208,18 +2047,6 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) { uint regoff; - regoff = 0; - - /* gpios could be shared on router platforms - * ignore reservation if it's high priority (e.g., test apps) - */ - if ((priority != GPIO_HI_PRIORITY) && - (sih->bustype == SI_BUS) && (val || mask)) { - mask = priority ? (ai_gpioreservation & mask) : - ((ai_gpioreservation | mask) & ~(ai_gpioreservation)); - val &= mask; - } - regoff = offsetof(struct chipcregs, gpiocontrol); return ai_corereg(sih, SI_CC_IDX, regoff, mask, val); } @@ -2283,13 +2110,10 @@ bool ai_deviceremoved(struct si_pub *sih) sii = SI_INFO(sih); - switch (sih->bustype) { - case PCI_BUS: - pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w); - if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM) - return true; - break; - } + pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w); + if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM) + return true; + return false; } diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 4c682a539e4..076b4c889fc 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -330,10 +330,8 @@ #define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */ #define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */ -#define PCI(si) (((si)->pub.bustype == PCI_BUS) && \ - ((si)->pub.buscoretype == PCI_CORE_ID)) -#define PCIE(si) (((si)->pub.bustype == PCI_BUS) && \ - ((si)->pub.buscoretype == PCIE_CORE_ID)) +#define PCI(si) ((si)->pub.buscoretype == PCI_CORE_ID) +#define PCIE(si) ((si)->pub.buscoretype == PCIE_CORE_ID) #define PCI_FORCEHT(si) \ (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID)) @@ -351,7 +349,6 @@ * public (read-only) portion of aiutils handle returned by si_attach() */ struct si_pub { - uint bustype; /* SI_BUS, PCI_BUS */ uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ uint buscorerev; /* buscore rev */ uint buscoreidx; /* buscore index */ @@ -518,9 +515,8 @@ extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ -extern struct si_pub *ai_attach(void *regs, uint bustype, - void *sdh, char **vars, uint *varsz); - +extern struct si_pub *ai_attach(void *regs, void *sdh, char **vars, + uint *varsz); extern void ai_detach(struct si_pub *sih); extern bool ai_pci_war16165(struct si_pub *sih); diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 48a053cb8f6..64d7639d38e 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -451,14 +451,11 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, */ di->ddoffsetlow = 0; di->dataoffsetlow = 0; - /* for pci bus, add offset */ - if (sih->bustype == PCI_BUS) { - /* pcie with DMA64 */ - di->ddoffsetlow = 0; - di->ddoffsethigh = SI_PCIE_DMA_H32; - di->dataoffsetlow = di->ddoffsetlow; - di->dataoffsethigh = di->ddoffsethigh; - } + /* add offset for pcie with DMA64 bus */ + di->ddoffsetlow = 0; + di->ddoffsethigh = SI_PCIE_DMA_H32; + di->dataoffsetlow = di->ddoffsetlow; + di->dataoffsethigh = di->ddoffsethigh; #if defined(__mips__) && defined(IL_BIGENDIAN) di->dataoffsetlow = di->dataoffsetlow + SI_SDRAM_SWAPPED; #endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index c66b67f900f..6bcb7ea1b10 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -755,7 +755,7 @@ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) */ static struct brcms_info *brcms_attach(u16 vendor, u16 device, unsigned long regs, - uint bustype, void *btparam, uint irq) + void *btparam, uint irq) { struct brcms_info *wl = NULL; int unit, err; @@ -786,14 +786,6 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, base_addr = regs; - if (bustype == PCI_BUS || bustype == RPC_BUS) { - /* Do nothing */ - } else { - bustype = PCI_BUS; - BCMMSG(wl->wiphy, "force to PCI\n"); - } - wl->bcm_bustype = bustype; - wl->regsva = ioremap_nocache(base_addr, PCI_BAR0_WINSZ); if (wl->regsva == NULL) { wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit); @@ -813,7 +805,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, /* common load-time initialization */ wl->wlc = brcms_c_attach((void *)wl, vendor, device, unit, false, - wl->regsva, wl->bcm_bustype, btparam, &err); + wl->regsva, btparam, &err); brcms_release_fw(wl); if (!wl->wlc) { wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n", @@ -1156,7 +1148,7 @@ brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) memset(hw->priv, 0, sizeof(*wl)); wl = brcms_attach(pdev->vendor, pdev->device, - pci_resource_start(pdev, 0), PCI_BUS, pdev, + pci_resource_start(pdev, 0), pdev, pdev->irq); if (!wl) { @@ -1373,8 +1365,7 @@ static void brcms_free(struct brcms_info *wl) * registers so we cannot unmap the chip registers until * after calling unregister_netdev() . */ - if (wl->regsva && wl->bcm_bustype != SDIO_BUS && - wl->bcm_bustype != JTAG_BUS) + if (wl->regsva) iounmap((void *)wl->regsva); wl->regsva = NULL; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 01fce542f23..c574723eece 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -60,8 +60,7 @@ struct brcms_info { spinlock_t lock; /* per-device perimeter lock */ spinlock_t isr_lock; /* per-device ISR synchronization lock */ - /* bus type and regsva for unmap in brcms_free() */ - uint bcm_bustype; /* bus type */ + /* regsva for unmap in brcms_free() */ void *regsva; /* opaque chip registers virtual address */ /* timer related fields */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 2a139aa4005..fb9f13fe5fc 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -181,8 +181,7 @@ */ #define BCMCFID(wlc, fid) brcms_b_write_shm((wlc)->hw, M_BCMC_FID, (fid)) -#define BRCMS_WAR16165(wlc) (wlc->pub->sih->bustype == PCI_BUS && \ - (!AP_ENAB(wlc->pub)) && (wlc->war16165)) +#define BRCMS_WAR16165(wlc) ((!AP_ENAB(wlc->pub)) && (wlc->war16165)) /* Find basic rate for a given rate */ #define BRCMS_BASIC_RATE(wlc, rspec) \ @@ -313,8 +312,8 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, struct brcms_b_state; static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, uint bustype, - void *btparam); + uint unit, bool piomode, void *regsva, + void *btparam); /* up/down, reset, clk */ static void brcms_b_reset(struct brcms_hardware *wlc_hw); @@ -4302,7 +4301,7 @@ struct brcms_pub *brcms_c_pub(void *wlc) * put the whole chip in reset(driver down state), no clock */ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, uint bustype, void *btparam) + bool piomode, void *regsva, void *btparam) { struct brcms_hardware *wlc_hw; struct d11regs *regs; @@ -4313,6 +4312,8 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, bool wme = false; struct shared_phy_params sha_params; struct wiphy *wiphy = wlc->wiphy; + char *var; + unsigned long res; BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, device); @@ -4332,7 +4333,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, * Do the hardware portion of the attach. Also initialize software * state that depends on the particular hardware we are running. */ - wlc_hw->sih = ai_attach(regsva, bustype, btparam, + wlc_hw->sih = ai_attach(regsva, btparam, &wlc_hw->vars, &wlc_hw->vars_size); if (wlc_hw->sih == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", @@ -4347,37 +4348,29 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, * than those the BIOS recognizes for devices on PCMCIA_BUS, * SDIO_BUS, and SROMless devices on PCI_BUS. */ -#ifdef BCMBUSTYPE - bustype = BCMBUSTYPE; -#endif - if (bustype != SI_BUS) { - char *var; - unsigned long res; + var = getvar(vars, "vendid"); + if (var && !kstrtoul(var, 0, &res)) { + vendor = (u16)res; + wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", + vendor); + } + var = getvar(vars, "devid"); + if (var && !kstrtoul(var, 0, &res)) { + u16 devid = (u16)res; + if (devid != 0xffff) { + device = devid; + wiphy_err(wiphy, "Overriding device id = 0x%x" + "\n", device); + } + } - var = getvar(vars, "vendid"); - if (var && !kstrtoul(var, 0, &res)) { - vendor = (u16)res; - wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", - vendor); - } - var = getvar(vars, "devid"); - if (var && !kstrtoul(var, 0, &res)) { - u16 devid = (u16)res; - if (devid != 0xffff) { - device = devid; - wiphy_err(wiphy, "Overriding device id = 0x%x" - "\n", device); - } - } - - /* verify again the device is supported */ - if (!brcms_c_chipmatch(vendor, device)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " - "vendor/device (0x%x/0x%x)\n", - unit, vendor, device); - err = 12; - goto fail; - } + /* verify again the device is supported */ + if (!brcms_c_chipmatch(vendor, device)) { + wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " + "vendor/device (0x%x/0x%x)\n", + unit, vendor, device); + err = 12; + goto fail; } wlc_hw->vendorid = vendor; @@ -4437,8 +4430,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, if (wlc_hw->boardflags & BFL_NOPLLDOWN) brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); - if ((wlc_hw->sih->bustype == PCI_BUS) - && (ai_pci_war16165(wlc_hw->sih))) + if (ai_pci_war16165(wlc_hw->sih)) wlc->war16165 = true; /* check device id(srom, nvram etc.) to set bands */ @@ -4491,7 +4483,6 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, sha_params.boardvendor = wlc_hw->sih->boardvendor; sha_params.boardflags = wlc_hw->boardflags; sha_params.boardflags2 = wlc_hw->boardflags2; - sha_params.bustype = wlc_hw->sih->bustype; sha_params.buscorerev = wlc_hw->sih->buscorerev; /* alloc and save pointer to shared phy state area */ @@ -4601,8 +4592,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, brcms_c_coredisable(wlc_hw); /* Match driver "down" state */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); + ai_pci_down(wlc_hw->sih); /* register sb interrupt callback functions */ ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, @@ -4655,8 +4645,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, * The common driver entry routine. Error codes should be unique */ void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, uint bustype, void *btparam, - uint *perr) + bool piomode, void *regsva, void *btparam, uint *perr) { struct brcms_c_info *wlc; uint err = 0; @@ -4696,7 +4685,7 @@ void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, * inside, no more in rest of the attach) */ err = brcms_b_attach(wlc, vendor, device, unit, piomode, regsva, - bustype, btparam); + btparam); if (err) goto fail; @@ -5030,9 +5019,7 @@ int brcms_b_detach(struct brcms_c_info *wlc) * be done before sb core switch */ ai_deregister_intr_callback(wlc_hw->sih); - - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_sleep(wlc_hw->sih); + ai_pci_sleep(wlc_hw->sih); } brcms_b_detach_dmapio(wlc_hw); @@ -5416,18 +5403,16 @@ void brcms_b_hw_up(struct brcms_hardware *wlc_hw) ai_clkctl_init(wlc_hw->sih); brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - if (wlc_hw->sih->bustype == PCI_BUS) { - ai_pci_fixcfg(wlc_hw->sih); + ai_pci_fixcfg(wlc_hw->sih); - /* - * AI chip doesn't restore bar0win2 on - * hibernation/resume, need sw fixup - */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - } + /* + * AI chip doesn't restore bar0win2 on + * hibernation/resume, need sw fixup + */ + if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || + (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + wlc_hw->regs = (struct d11regs *) + ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); /* * Inform phy that a POR reset has occurred so @@ -5467,8 +5452,7 @@ int brcms_b_up_prep(struct brcms_hardware *wlc_hw) */ coremask = (1 << wlc_hw->wlc->core->coreidx); - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_setup(wlc_hw->sih, coremask); + ai_pci_setup(wlc_hw->sih, coremask); /* * Need to read the hwradio status here to cover the case where the @@ -5477,14 +5461,12 @@ int brcms_b_up_prep(struct brcms_hardware *wlc_hw) */ if (brcms_b_radio_read_hwdisabled(wlc_hw)) { /* put SB PCI in down state again */ - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); + ai_pci_down(wlc_hw->sih); brcms_b_xtal(wlc_hw, OFF); return -ENOMEDIUM; } - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_up(wlc_hw->sih); + ai_pci_up(wlc_hw->sih); /* reset the d11 core */ brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); @@ -5707,8 +5689,7 @@ int brcms_b_down_finish(struct brcms_hardware *wlc_hw) /* turn off primary xtal and pll */ if (!wlc_hw->noreset) { - if (wlc_hw->sih->bustype == PCI_BUS) - ai_pci_down(wlc_hw->sih); + ai_pci_down(wlc_hw->sih); brcms_b_xtal(wlc_hw, OFF); } } diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index ab675460d5e..8249ea910ba 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -213,9 +213,7 @@ struct pcicore_info { /* debug/trace */ #define PCI_ERROR(args) -#define PCIE_PUB(sih) \ - (((sih)->bustype == PCI_BUS) && \ - ((sih)->buscoretype == PCIE_CORE_ID)) +#define PCIE_PUB(sih) ((sih)->buscoretype == PCIE_CORE_ID) /* routines to access mdio slave device registers */ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 831c2fe35ee..c00178d18b5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -279,11 +279,9 @@ void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) W_REG(&pi->regs->phy4wdatalo, val); } - if (pi->sh->bustype == PCI_BUS) { - if (++pi->phy_wreg >= pi->phy_wreg_limit) { - (void)R_REG(&pi->regs->maccontrol); - pi->phy_wreg = 0; - } + if (++pi->phy_wreg >= pi->phy_wreg_limit) { + (void)R_REG(&pi->regs->maccontrol); + pi->phy_wreg = 0; } } @@ -390,11 +388,9 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) #else W_REG((u32 *)(®s->phyregaddr), addr | (val << 16)); - if (pi->sh->bustype == PCI_BUS) { - if (++pi->phy_wreg >= pi->phy_wreg_limit) { - pi->phy_wreg = 0; - (void)R_REG(®s->phyversion); - } + if (++pi->phy_wreg >= pi->phy_wreg_limit) { + pi->phy_wreg = 0; + (void)R_REG(®s->phyversion); } #endif } @@ -496,7 +492,6 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) sh->boardvendor = shp->boardvendor; sh->boardflags = shp->boardflags; sh->boardflags2 = shp->boardflags2; - sh->bustype = shp->bustype; sh->buscorerev = shp->buscorerev; sh->fast_timer = PHY_SW_TIMER_FAST; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index 42e0cf044a5..1dbfaa3522b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -166,7 +166,6 @@ struct shared_phy_params { struct phy_shim_info *physhim; uint unit; uint corerev; - uint bustype; uint buscorerev; char *vars; u16 vid; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index bcc6d8312f3..b98d76bc833 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -565,7 +565,6 @@ struct shared_phy { uint boardvendor; u32 boardflags; u32 boardflags2; - uint bustype; uint buscorerev; uint fast_timer; uint slow_timer; @@ -1182,7 +1181,7 @@ extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, (pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec))) #define BRCMS_PHY_WAR_PR51571(pi) \ - if (((pi)->sh->bustype == PCI_BUS) && NREV_LT((pi)->pubpi.phy_rev, 3)) \ + if (NREV_LT((pi)->pubpi.phy_rev, 3)) \ (void)R_REG(&(pi)->regs->maccontrol) extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype); diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 8da72505515..5e15c6753f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -550,7 +550,7 @@ struct brcms_antselcfg { /* common functions for every port */ extern void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, uint bustype, + uint unit, bool piomode, void *regsva, void *btparam, uint *perr); extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 40a315631b5..060f06fc144 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -860,8 +860,7 @@ static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. */ -int srom_var_init(struct si_pub *sih, uint bustype, void *curmap, - char **vars, uint *count) +int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) { uint len; @@ -873,7 +872,7 @@ int srom_var_init(struct si_pub *sih, uint bustype, void *curmap, *vars = NULL; *count = 0; - if (curmap != NULL && bustype == PCI_BUS) + if (curmap != NULL) return initvars_srom_pci(sih, curmap, vars, count); return -EINVAL; diff --git a/drivers/staging/brcm80211/brcmsmac/srom.h b/drivers/staging/brcm80211/brcmsmac/srom.h index efc4d1edd86..dd51156fb12 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.h +++ b/drivers/staging/brcm80211/brcmsmac/srom.h @@ -20,8 +20,8 @@ #include "types.h" /* Prototypes */ -extern int srom_var_init(struct si_pub *sih, uint bus, void *curmap, - char **vars, uint *count); +extern int srom_var_init(struct si_pub *sih, void *curmap, char **vars, + uint *count); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, uint byteoff, uint nbytes, u16 *buf, bool check_crc); diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 16a1c6a0467..c0d41cc910d 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -20,14 +20,13 @@ #include #include +#if 0 /* Bus types */ -#define SI_BUS 0 /* SOC Interconnect */ -#define PCI_BUS 1 /* PCI target */ #define SDIO_BUS 3 /* SDIO target */ -#define JTAG_BUS 4 /* JTAG */ #define USB_BUS 5 /* USB (does not support R/W REG) */ #define SPI_BUS 6 /* gSPI target */ #define RPC_BUS 7 /* RPC target */ +#endif #define WL_CHAN_FREQ_RANGE_2G 0 #define WL_CHAN_FREQ_RANGE_5GL 1 From 07cefb9fef3c4f9527906d716725778deea06007 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:58:59 +0200 Subject: [PATCH 0097/1519] staging: brcm80211: replaced void *btparam into struct pci_dev *btparam Code cleanup. Since the softmac driver only supports a PCI(e) bus, the void * could be replaced with a less generic type. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 8 +++++--- drivers/staging/brcm80211/brcmsmac/aiutils.h | 4 +++- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 6 +++--- drivers/staging/brcm80211/brcmsmac/main.c | 9 +++++---- drivers/staging/brcm80211/brcmsmac/pub.h | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 37edd1ce312..9cfb492d7c3 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -861,7 +861,8 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) /* *************** from siutils.c ************** */ /* local prototypes */ static struct si_info *ai_doattach(struct si_info *sii, void *regs, - void *sdh, char **vars, uint *varsz); + struct pci_dev *sdh, + char **vars, uint *varsz); static bool ai_buscore_prep(struct si_info *sii); static bool ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, u32 savewin, uint *origidx, void *regs); @@ -881,7 +882,8 @@ static bool ai_ispcie(struct si_info *sii); * vars - pointer to a pointer area for "environment" variables * varsz - pointer to int to return the size of the vars */ -struct si_pub *ai_attach(void *regs, void *sdh, char **vars, uint *varsz) +struct si_pub * +ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz) { struct si_info *sii; @@ -1052,7 +1054,7 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) } static struct si_info *ai_doattach(struct si_info *sii, - void *regs, void *pbus, + void *regs, struct pci_dev *pbus, char **vars, uint *varsz) { struct si_pub *sih = &sii->pub; diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 076b4c889fc..101ab92f2ea 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -446,6 +446,8 @@ struct si_pub { #define IS_SIM(chippkg) \ ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) +struct pci_dev; + struct gpioh_item { void *arg; bool level; @@ -515,7 +517,7 @@ extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ -extern struct si_pub *ai_attach(void *regs, void *sdh, char **vars, +extern struct si_pub *ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz); extern void ai_detach(struct si_pub *sih); extern bool ai_pci_war16165(struct si_pub *sih); diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 6bcb7ea1b10..7f6a490310f 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -755,7 +755,7 @@ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) */ static struct brcms_info *brcms_attach(u16 vendor, u16 device, unsigned long regs, - void *btparam, uint irq) + struct pci_dev *btparam, uint irq) { struct brcms_info *wl = NULL; int unit, err; @@ -795,11 +795,11 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, spin_lock_init(&wl->isr_lock); /* prepare ucode */ - if (brcms_request_fw(wl, (struct pci_dev *)btparam) < 0) { + if (brcms_request_fw(wl, btparam) < 0) { wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in " "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm"); brcms_release_fw(wl); - brcms_remove((struct pci_dev *)btparam); + brcms_remove(btparam); return NULL; } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index fb9f13fe5fc..d011ed68c71 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -313,7 +313,7 @@ struct brcms_b_state; static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, bool piomode, void *regsva, - void *btparam); + struct pci_dev *btparam); /* up/down, reset, clk */ static void brcms_b_reset(struct brcms_hardware *wlc_hw); @@ -4301,7 +4301,7 @@ struct brcms_pub *brcms_c_pub(void *wlc) * put the whole chip in reset(driver down state), no clock */ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, void *btparam) + bool piomode, void *regsva, struct pci_dev *btparam) { struct brcms_hardware *wlc_hw; struct d11regs *regs; @@ -4644,8 +4644,9 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, /* * The common driver entry routine. Error codes should be unique */ -void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, void *btparam, uint *perr) +void * +brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, + bool piomode, void *regsva, struct pci_dev *btparam, uint *perr) { struct brcms_c_info *wlc; uint err = 0; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 5e15c6753f6..bfbb2615bed 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -551,7 +551,7 @@ struct brcms_antselcfg { /* common functions for every port */ extern void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, bool piomode, void *regsva, - void *btparam, uint *perr); + struct pci_dev *btparam, uint *perr); extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); From c6c092ae87dafd735daad32d4bd74477af2b928c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:59:00 +0200 Subject: [PATCH 0098/1519] staging: brcm80211: removed void * from ai_ functions Code cleanup. Replaced void * by less generic pointer types. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 46 ++++++++++---------- drivers/staging/brcm80211/brcmsmac/aiutils.h | 5 +-- drivers/staging/brcm80211/brcmsmac/pmu.c | 4 +- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 9cfb492d7c3..3d392a3963f 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -483,16 +483,16 @@ static void ai_hwfixup(struct si_info *sii) } /* parse the enumeration rom to identify all cores */ -void ai_scan(struct si_pub *sih, void *regs) +void ai_scan(struct si_pub *sih, struct chipcregs *cc) { struct si_info *sii = SI_INFO(sih); - struct chipcregs *cc = (struct chipcregs *) regs; u32 erombase, *eromptr, *eromlim; + void *regs = cc; erombase = R_REG(&cc->eromptr); /* Set wrappers address */ - sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE); + sii->curwrap = (void *)((unsigned long)cc + SI_CORE_SIZE); /* Now point the window at the erom */ pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); @@ -671,7 +671,10 @@ void ai_scan(struct si_pub *sih, void *regs) /* * This function changes the logical "focus" to the indicated core. - * Return the current core's virtual address. + * Return the current core's virtual address. Since each core starts with the + * same set of registers (BIST, clock control, etc), the returned address + * contains the first register of this 'common' register block (not to be + * confused with 'common core'). */ void *ai_setcoreidx(struct si_pub *sih, uint coreidx) { @@ -864,8 +867,7 @@ static struct si_info *ai_doattach(struct si_info *sii, void *regs, struct pci_dev *sdh, char **vars, uint *varsz); static bool ai_buscore_prep(struct si_info *sii); -static bool ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, - u32 savewin, uint *origidx, void *regs); +static bool ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx); static void ai_nvram_process(struct si_info *sii, char *pvars); /* dev path concatenation util */ @@ -916,12 +918,12 @@ static bool ai_buscore_prep(struct si_info *sii) } static bool -ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, u32 savewin, - uint *origidx, void *regs) +ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) { bool pci, pcie; uint i; uint pciidx, pcieidx, pcirev, pcierev; + struct chipcregs *cc; cc = ai_setcoreidx(&sii->pub, SI_CC_IDX); @@ -977,7 +979,7 @@ ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, u32 savewin, /* find the core idx before entering this func. */ if ((savewin && (savewin == sii->coresba[i])) || - (regs == sii->regs[i])) + (cc == sii->regs[i])) *origidx = i; } @@ -1003,9 +1005,8 @@ ai_buscore_setup(struct si_info *sii, struct chipcregs *cc, u32 savewin, /* fixup necessary chip/core configurations */ if (SI_FAST(sii)) { if (!sii->pch) { - sii->pch = (void *)pcicore_init( - &sii->pub, sii->pbus, - (void *)PCIEREGS(sii)); + sii->pch = pcicore_init(&sii->pub, sii->pbus, + (void *)PCIEREGS(sii)); if (sii->pch == NULL) return false; } @@ -1108,7 +1109,7 @@ static struct si_info *ai_doattach(struct si_info *sii, if (socitype == SOCI_AI) { SI_MSG(("Found chip type AI (0x%08x)\n", w)); /* pass chipc address instead of original core base */ - ai_scan(&sii->pub, (void *)cc); + ai_scan(&sii->pub, cc); } else { SI_ERROR(("Found chip of unknown type (0x%08x)\n", w)); return NULL; @@ -1120,13 +1121,13 @@ static struct si_info *ai_doattach(struct si_info *sii, } /* bus/core/clk setup */ origidx = SI_CC_IDX; - if (!ai_buscore_setup(sii, cc, savewin, &origidx, regs)) { + if (!ai_buscore_setup(sii, savewin, &origidx)) { SI_ERROR(("si_doattach: si_buscore_setup failed\n")); goto exit; } /* Init nvram from sprom/otp if they exist */ - if (srom_var_init(&sii->pub, regs, vars, varsz)) { + if (srom_var_init(&sii->pub, cc, vars, varsz)) { SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } @@ -1327,9 +1328,9 @@ void *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, */ *origidx = coreid; if (coreid == CC_CORE_ID) - return (void *)CCREGS_FAST(sii); + return CCREGS_FAST(sii); else if (coreid == sih->buscoretype) - return (void *)PCIEREGS(sii); + return PCIEREGS(sii); } INTR_OFF(sii, *intr_val); *origidx = sii->curidx; @@ -1553,9 +1554,8 @@ ai_slowclk_freq(struct si_info *sii, bool max_freq, struct chipcregs *cc) return 0; } -static void ai_clkctl_setdelay(struct si_info *sii, void *chipcregs) +static void ai_clkctl_setdelay(struct si_info *sii, struct chipcregs *cc) { - struct chipcregs *cc = (struct chipcregs *) chipcregs; uint slowmaxfreq, pll_delay, slowclk; uint pll_on_delay, fref_sel_delay; @@ -1611,7 +1611,7 @@ void ai_clkctl_init(struct si_pub *sih) SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); - ai_clkctl_setdelay(sii, (void *)cc); + ai_clkctl_setdelay(sii, cc); if (!fast) ai_setcoreidx(sih, origidx); @@ -1979,7 +1979,7 @@ void ai_pci_down(struct si_pub *sih) void ai_pci_setup(struct si_pub *sih, uint coremask) { struct si_info *sii; - void *regs = NULL; + struct sbpciregs *regs = NULL; u32 siflag = 0, w; uint idx = 0; @@ -2025,7 +2025,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) int ai_pci_fixcfg(struct si_pub *sih) { uint origidx; - void *regs = NULL; + struct sbpciregs *regs = NULL; struct si_info *sii = SI_INFO(sih); @@ -2095,7 +2095,7 @@ void ai_epa_4313war(struct si_pub *sih) sii = SI_INFO(sih); origidx = ai_coreidx(sih); - cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); + cc = ai_setcore(sih, CC_CORE_ID, 0); /* EPA Fix */ W_REG(&cc->gpiocontrol, diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 101ab92f2ea..84c69013600 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -468,7 +468,7 @@ struct si_info { /* check if interrupts are enabled */ bool (*intrsenabled_fn) (void *intr_arg); - void *pch; /* PCI/E core handle */ + struct pcicore_info *pch; /* PCI/E core handle */ char *vars; uint varsz; @@ -495,15 +495,12 @@ struct si_info { }; /* AMBA Interconnect exported externs */ -extern void ai_scan(struct si_pub *sih, void *regs); - extern uint ai_flag(struct si_pub *sih); extern void ai_setint(struct si_pub *sih, int siflag); extern uint ai_coreidx(struct si_pub *sih); extern uint ai_corevendor(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); extern bool ai_iscoreup(struct si_pub *sih); -extern void *ai_setcoreidx(struct si_pub *sih, uint coreidx); extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); extern void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val); extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index f5e10850d87..cdeaa4e534c 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -320,8 +320,8 @@ void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) uint origidx, intr_val; /* Remember original core before switch to chipc */ - cc = (struct chipcregs *) ai_switch_core(sih, CC_CORE_ID, &origidx, - &intr_val); + cc = (struct chipcregs *) + ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); /* update the pll changes */ si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); From a09818cc6aefd266998ec8b5e961e889965060ea Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:59:01 +0200 Subject: [PATCH 0099/1519] staging: brcm80211: removed brcms_c_module_unregister() call in ampdu.c The AMPDU module was never registered, so it does not have to be unregistered. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 64bbc242157..3c0fa13ff0b 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -243,7 +243,6 @@ void brcms_c_ampdu_detach(struct ampdu_info *ampdu) for (i = 0; i < AMPDU_INI_FREE; i++) kfree(ampdu->ini_free[i]); - brcms_c_module_unregister(ampdu->wlc->pub, "ampdu", ampdu); kfree(ampdu); } From 1a5f680d7cb55eac1a6047b178b0100443702b57 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 8 Aug 2011 15:59:02 +0200 Subject: [PATCH 0100/1519] staging: brcm80211: removed watchdog function from softmac Code cleanup. Watchdog function served no purpose since it had an empty body. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 14 +------------- drivers/staging/brcm80211/brcmsmac/main.c | 11 ++--------- drivers/staging/brcm80211/brcmsmac/main.h | 2 -- drivers/staging/brcm80211/brcmsmac/pub.h | 5 ++--- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 7f6a490310f..a4d46dd9245 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -61,8 +61,6 @@ static void _brcms_timer(struct brcms_timer *t); static int ieee_hw_init(struct ieee80211_hw *hw); static int ieee_hw_rate_init(struct ieee80211_hw *hw); -static int wl_linux_watchdog(void *ctx); - /* Flags we support */ #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | \ @@ -828,7 +826,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->irq = irq; /* register module */ - brcms_c_module_register(wl->pub, "linux", wl, wl_linux_watchdog, NULL); + brcms_c_module_register(wl->pub, "linux", wl, NULL); if (ieee_hw_init(hw)) { wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit, @@ -1701,16 +1699,6 @@ void brcms_free_timer(struct brcms_info *wl, struct brcms_timer *t) } -/* - * runs in software irq context - * - * precondition: perimeter lock is not acquired - */ -static int wl_linux_watchdog(void *ctx) -{ - return 0; -} - struct firmware_hdr { u32 offset; u32 len; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d011ed68c71..bdc7fb4d62d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5374,12 +5374,6 @@ static void brcms_c_watchdog(void *arg) cfg->tk_cm_bt--; END_FOREACH_BSS() - /* Call any registered watchdog handlers */ - for (i = 0; i < BRCMS_MAXMODULES; i++) { - if (wlc->modulecb[i].watchdog_fn) - wlc->modulecb[i].watchdog_fn(wlc->modulecb[i].hdl); - } - if (BRCMS_ISNPHY(wlc->band) && !wlc->pub->tempsense_disable && ((wlc->pub->now - wlc->tempsense_lasttime) >= BRCMS_TEMPSENSE_PERIOD)) { @@ -6325,8 +6319,8 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, * register watchdog and down handlers. */ int brcms_c_module_register(struct brcms_pub *pub, - const char *name, void *hdl, - int (*w_fn)(void *handle), int (*d_fn)(void *handle)) + const char *name, void *hdl, + int (*d_fn)(void *handle)) { struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; int i; @@ -6337,7 +6331,6 @@ int brcms_c_module_register(struct brcms_pub *pub, strncpy(wlc->modulecb[i].name, name, sizeof(wlc->modulecb[i].name) - 1); wlc->modulecb[i].hdl = hdl; - wlc->modulecb[i].watchdog_fn = w_fn; wlc->modulecb[i].down_fn = d_fn; return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 0fd061b02b9..e2febe0565a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -462,8 +462,6 @@ struct modulecb { const struct brcmu_iovar *iovars; /* handle passed when handler 'doiovar' is called */ void *hdl; - /* watchdog handler */ - int (*watchdog_fn)(void *handle); /* IOVar handler * diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index bfbb2615bed..40efee6e624 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -614,9 +614,8 @@ extern void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc); extern void brcms_c_mctrl(struct brcms_c_info *wlc, u32 mask, u32 val); extern int brcms_c_module_register(struct brcms_pub *pub, - const char *name, void *hdl, - int (*watchdog_fn)(void *handle), - int (*down_fn)(void *handle)); + const char *name, void *hdl, + int (*down_fn)(void *handle)); extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, void *hdl); From d788766c12f89ebf486101a3f9a30317c324a14b Mon Sep 17 00:00:00 2001 From: Pieter-Paul Giesberts Date: Mon, 8 Aug 2011 15:59:03 +0200 Subject: [PATCH 0101/1519] staging: brcm80211: SPARC build error fix Due to missing memset function declaration. Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/otp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 975d80cb884..b6ff76706ef 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -16,6 +16,7 @@ #include #include +#include #include #include From 124bf340114b74eb0a9f49dd51e855fa2300b565 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:59:04 +0200 Subject: [PATCH 0102/1519] staging: brcm80211: fix 'uninitialized usage' compiler warning Building for the ARM resulted in a compiler warning about usage of a possibly uninitialized variable. The warning is valid and the code has been fixed accordingly. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index b9cb892377e..1aad680c7f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1279,8 +1279,8 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, const struct country_info *country; struct brcms_band *band; const struct locale_info *li; - int conducted_max; - int conducted_ofdm_max; + int conducted_max = BRCMS_TXPWR_MAX; + int conducted_ofdm_max = BRCMS_TXPWR_MAX; const struct locale_mimo_info *li_mimo; int maxpwr20, maxpwr40; int maxpwr_idx; From 37d2e1f3dfbac5cdb93f9990840b24350b3d9403 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:59:05 +0200 Subject: [PATCH 0103/1519] staging: brcm80211: remove target platform limitations for drivers Several issue have been reported building the driver on big endian systems. Following commits were done on driver Kconfig: d462039 Staging: brcm80211: disable drivers except for X86 or MIPS platforms 15e5201 Staging: brcm80211: disable drivers for PPC platforms These problems have been resolved so the added 'depends' lines in the Kconfig have been removed. Compile tested it for following architectures: little endian x86 x86_64 arm mips big endian ppc64 sparc64 mips Reported-by: David S. Miller Reported-by: Stephen Rothwell Reported-by: Greg Kroah-Hartman Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index 379cf16e89f..f4cf9b23481 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -7,7 +7,6 @@ config BRCMSMAC default n depends on PCI depends on WLAN && MAC80211 - depends on X86 || MIPS select BRCMUTIL select FW_LOADER select CRC_CCITT @@ -21,7 +20,6 @@ config BRCMFMAC default n depends on MMC depends on WLAN && CFG80211 - depends on X86 || MIPS select BRCMUTIL select FW_LOADER select WIRELESS_EXT From 05e6468db5e5cb733b096a9ccd244fe2e148ac14 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 8 Aug 2011 15:59:06 +0200 Subject: [PATCH 0104/1519] staging: brcm80211: updated TODO file The only remaining TODO item has been tackled so it was removed. No other TODO items left. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/brcm80211/TODO b/drivers/staging/brcm80211/TODO index e2e2ef9bd7a..7f68762b1c3 100644 --- a/drivers/staging/brcm80211/TODO +++ b/drivers/staging/brcm80211/TODO @@ -4,10 +4,6 @@ Bugs ==== - none known at this moment -brcmfmac -===================== -- ASSERTS deprecated in mainline, replace by warning + error handling - brcm80211 info page ===================== http://linuxwireless.org/en/users/Drivers/brcm80211 From 297658defcfea01e6c662ec34cd5e2cdacfe8a2e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 12 Aug 2011 15:34:48 +0200 Subject: [PATCH 0105/1519] staging: brcm80211: use wait queues instead of semaphores in wl_cfg80211.c In wl_cfg80211.c two semaphores were used to trigger a task to process an event. The wait queues are better suited for that purpose. This also removes checkpatch warning on sema_init() calls in this source file. Reviewed-by: Roland Vossen Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 49 +++++++++++++------ .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 5 +- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index bc1e1a958b1..833defb0d9b 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3162,7 +3162,7 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) static s32 brcmf_create_event_handler(struct brcmf_cfg80211_priv *cfg_priv) { - sema_init(&cfg_priv->event_sync, 0); + init_waitqueue_head(&cfg_priv->event_waitq); cfg_priv->event_tsk = kthread_run(brcmf_event_handler, cfg_priv, "wl_event_handler"); if (IS_ERR(cfg_priv->event_tsk)) { @@ -3224,7 +3224,7 @@ static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) { if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) { WL_SCAN("wake up iscan\n"); - up(&iscan->sync); + wake_up(&iscan->waitq); return 0; } @@ -3330,13 +3330,19 @@ static s32 brcmf_iscan_thread(void *data) (struct brcmf_cfg80211_iscan_ctrl *)data; struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); struct brcmf_cfg80211_iscan_eloop *el = &iscan->el; + DECLARE_WAITQUEUE(wait, current); u32 status; int err = 0; sched_setscheduler(current, SCHED_FIFO, ¶m); allow_signal(SIGTERM); status = BRCMF_SCAN_RESULTS_PARTIAL; - while (likely(!down_interruptible(&iscan->sync))) { + add_wait_queue(&iscan->waitq, &wait); + while (1) { + prepare_to_wait(&iscan->waitq, &wait, TASK_INTERRUPTIBLE); + + schedule(); + if (kthread_should_stop()) break; if (iscan->timer_on) { @@ -3353,6 +3359,7 @@ static s32 brcmf_iscan_thread(void *data) rtnl_unlock(); el->handler[status](cfg_priv); } + finish_wait(&iscan->waitq, &wait); if (iscan->timer_on) { del_timer_sync(&iscan->timer); iscan->timer_on = 0; @@ -3380,7 +3387,7 @@ static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) if (cfg_priv->iscan_on && !iscan->tsk) { iscan->state = WL_ISCAN_STATE_IDLE; - sema_init(&iscan->sync, 0); + init_waitqueue_head(&iscan->waitq); iscan->tsk = kthread_run(brcmf_iscan_thread, iscan, "wl_iscan"); if (IS_ERR(iscan->tsk)) { WL_ERR("Could not create iscan thread\n"); @@ -3528,7 +3535,7 @@ void brcmf_cfg80211_detach(void) static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv) { - up(&cfg_priv->event_sync); + wake_up(&cfg_priv->event_waitq); } static s32 brcmf_event_handler(void *data) @@ -3537,27 +3544,39 @@ static s32 brcmf_event_handler(void *data) (struct brcmf_cfg80211_priv *)data; struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; struct brcmf_cfg80211_event_q *e; + DECLARE_WAITQUEUE(wait, current); sched_setscheduler(current, SCHED_FIFO, ¶m); allow_signal(SIGTERM); - while (likely(!down_interruptible(&cfg_priv->event_sync))) { + add_wait_queue(&cfg_priv->event_waitq, &wait); + while (1) { + prepare_to_wait(&cfg_priv->event_waitq, &wait, + TASK_INTERRUPTIBLE); + + schedule(); + if (kthread_should_stop()) break; + e = brcmf_deq_event(cfg_priv); if (unlikely(!e)) { WL_ERR("event queue empty...\n"); - BUG(); + continue; } - WL_INFO("event type (%d)\n", e->etype); - if (cfg_priv->el.handler[e->etype]) - cfg_priv->el.handler[e->etype](cfg_priv, - cfg_to_ndev(cfg_priv), - &e->emsg, e->edata); - else - WL_INFO("Unknown Event (%d): ignoring\n", e->etype); - brcmf_put_event(e); + do { + WL_INFO("event type (%d)\n", e->etype); + if (cfg_priv->el.handler[e->etype]) + cfg_priv->el.handler[e->etype](cfg_priv, + cfg_to_ndev(cfg_priv), + &e->emsg, e->edata); + else + WL_INFO("Unknown Event (%d): ignoring\n", + e->etype); + brcmf_put_event(e); + } while ((e = brcmf_deq_event(cfg_priv))); } + finish_wait(&cfg_priv->event_waitq, &wait); WL_INFO("was terminated\n"); return 0; } diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index ff5c19a9b91..049138b9e5d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -249,7 +249,7 @@ struct brcmf_cfg80211_iscan_ctrl { u32 timer_on; s32 state; struct task_struct *tsk; - struct semaphore sync; + wait_queue_head_t waitq; struct brcmf_cfg80211_iscan_eloop el; void *data; s8 ioctl_buf[BRCMF_C_IOCTL_SMLEN]; @@ -295,13 +295,12 @@ struct brcmf_cfg80211_priv { cfg80211 layer */ struct brcmf_cfg80211_ie ie; /* information element object for internal purpose */ - struct semaphore event_sync; /* for synchronization of main event - thread */ struct brcmf_cfg80211_profile *profile; /* holding dongle profile */ struct brcmf_cfg80211_iscan_ctrl *iscan; /* iscan controller */ struct brcmf_cfg80211_connect_info conn_info; /* association info */ struct brcmf_cfg80211_pmk_list *pmk_list; /* wpa2 pmk list */ struct task_struct *event_tsk; /* task of main event handler thread */ + wait_queue_head_t event_waitq; /* wait queue for main event handling */ unsigned long status; /* current dongle status */ void *pub; u32 channel; /* current channel */ From c9ed29ac1a556085afba3fd75f1795805b0b766f Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:49 +0200 Subject: [PATCH 0106/1519] staging: brcm80211: remove iovar IOV_BLOCKSIZE in brcmfmac Iovar IOV_BLOCKSIZE code is not actually setting the sdio function's block size. Use cur_blksize provided by mmc core where necessary. Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 52 ------------------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 31 +---------- .../staging/brcm80211/brcmfmac/sdio_host.h | 1 - 3 files changed, 1 insertion(+), 83 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 1256847ae91..a2fba4f0904 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -169,14 +169,12 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0) } sd->num_funcs = 2; - sd->client_block_size[0] = 64; gInstance->sd = sd; /* Claim host controller */ sdio_claim_host(gInstance->func[1]); - sd->client_block_size[1] = 64; err_ret = sdio_set_block_size(gInstance->func[1], 64); if (err_ret) BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); @@ -188,7 +186,6 @@ struct sdioh_info *brcmf_sdioh_attach(void *bar0) /* Claim host controller F2 */ sdio_claim_host(gInstance->func[2]); - sd->client_block_size[2] = sd_f2_blocksize; err_ret = sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); if (err_ret) @@ -273,7 +270,6 @@ extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) /* IOVar table */ enum { IOV_MSGLEVEL = 1, - IOV_BLOCKSIZE, IOV_NUMINTS, IOV_DEVREG, IOV_HCIREGS, @@ -281,8 +277,6 @@ enum { }; const struct brcmu_iovar sdioh_iovars[] = { - {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0},/* ((fn << 16) | - size) */ {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0}, {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} , @@ -346,52 +340,6 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); switch (actionid) { - case IOV_GVAL(IOV_BLOCKSIZE): - if ((u32) int_val > si->num_funcs) { - bcmerror = -EINVAL; - break; - } - int_val = (s32) si->client_block_size[int_val]; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_BLOCKSIZE): - { - uint func = ((u32) int_val >> 16); - uint blksize = (u16) int_val; - uint maxsize; - - if (func > si->num_funcs) { - bcmerror = -EINVAL; - break; - } - - switch (func) { - case 0: - maxsize = 32; - break; - case 1: - maxsize = 64; - break; - case 2: - maxsize = 512; - break; - default: - maxsize = 0; - } - if (blksize > maxsize) { - bcmerror = -EINVAL; - break; - } - if (!blksize) - blksize = maxsize; - - /* Now set it */ - si->client_block_size[func] = blksize; - - break; - } - case IOV_GVAL(IOV_RXCHAIN): int_val = false; memcpy(arg, &int_val, val_size); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8bea86595d6..65b245c1cb3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -3168,24 +3168,6 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, bcmerror = brcmf_sdcard_iovar_op(bus->sdiodev, name, params, plen, arg, len, set); - /* Similar check for blocksize change */ - if (set && strcmp(name, "sd_blocksize") == 0) { - s32 fnum = 2; - if (brcmf_sdcard_iovar_op - (bus->sdiodev, "sd_blocksize", &fnum, sizeof(s32), - &bus->blocksize, sizeof(s32), - false) != 0) { - bus->blocksize = 0; - BRCMF_ERROR(("%s: fail on %s get\n", __func__, - "sd_blocksize")); - } else { - BRCMF_INFO(("%s: noted sd_blocksize update," - " value now %d\n", __func__, - bus->blocksize)); - } - } - bus->roundup = min(max_roundup, bus->blocksize); - if (bus->idletime == BRCMF_IDLE_IMMEDIATE && !bus->dpc_sched) { bus->activity = false; @@ -5679,8 +5661,6 @@ fail: static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) { - s32 fnum; - BRCMF_TRACE(("%s: Enter\n", __func__)); #ifdef SDTEST @@ -5705,16 +5685,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) bus->idleclock = BRCMF_IDLE_ACTIVE; /* Query the F2 block size, set roundup accordingly */ - fnum = 2; - if (brcmf_sdcard_iovar_op(bus->sdiodev, "sd_blocksize", &fnum, - sizeof(s32), &bus->blocksize, - sizeof(s32), false) != 0) { - bus->blocksize = 0; - BRCMF_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize")); - } else { - BRCMF_INFO(("%s: Initial value for %s is %d\n", - __func__, "sd_blocksize", bus->blocksize)); - } + bus->blocksize = bus->sdiodev->func2->cur_blksize; bus->roundup = min(max_roundup, bus->blocksize); /* Query if bus module supports packet chaining, diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index c5a68c0382a..c61a18679f6 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -129,7 +129,6 @@ struct sdioh_info { int intrcount; /* Client interrupts */ bool sd_blockmode; /* sd_blockmode == false => 64 Byte Cmd 53s. */ /* Must be on for sd_multiblock to be effective */ - int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ u8 num_funcs; /* Supported funcs on client */ u32 com_cis_ptr; u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; From b73b2f9e6c99a6bbc06b3ffa2a9981335fad610b Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:50 +0200 Subject: [PATCH 0107/1519] staging: brcm80211: remove struct sdioh_info from brcmfmac Use brcmf_sdio_dev as the unified structure to store information of device. Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 35 ++-- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 186 ++++++++---------- .../staging/brcm80211/brcmfmac/sdio_host.h | 59 ++---- 3 files changed, 115 insertions(+), 165 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index c9893e9287b..6a9ac1dda12 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -49,18 +49,18 @@ int brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, void *params, int plen, void *arg, int len, bool set) { - return brcmf_sdioh_iovar_op(sdiodev->sdioh, name, params, plen, arg, + return brcmf_sdioh_iovar_op(sdiodev, name, params, plen, arg, len, set); } int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_register(sdiodev->sdioh); + return brcmf_sdioh_interrupt_register(); } int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_deregister(sdiodev->sdioh); + return brcmf_sdioh_interrupt_deregister(); } u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, @@ -74,7 +74,7 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); status = - brcmf_sdioh_cfg_read(sdiodev->sdioh, fnc_num, addr, + brcmf_sdioh_cfg_read(sdiodev, fnc_num, addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); @@ -98,7 +98,7 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); status = - brcmf_sdioh_cfg_write(sdiodev->sdioh, fnc_num, addr, + brcmf_sdioh_cfg_write(sdiodev, fnc_num, addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); @@ -119,7 +119,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, bool ascii = func & ~0xf; func &= 0x7; - status = brcmf_sdioh_cis_read(sdiodev->sdioh, func, cis, length); + status = brcmf_sdioh_cis_read(sdiodev, func, cis, length); if (ascii) { /* Move binary bits to tmp and format them @@ -181,7 +181,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, + status = brcmf_sdioh_request_word(sdiodev, SDIOH_CMD_TYPE_NORMAL, SDIOH_READ, SDIO_FUNC_1, addr, &word, size); sdiodev->regfail = (status != 0); @@ -231,7 +231,7 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; status = - brcmf_sdioh_request_word(sdiodev->sdioh, SDIOH_CMD_TYPE_NORMAL, + brcmf_sdioh_request_word(sdiodev, SDIOH_CMD_TYPE_NORMAL, SDIOH_WRITE, SDIO_FUNC_1, addr, &data, size); sdiodev->regfail = (status != 0); @@ -284,7 +284,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, + status = brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, incr_fix, SDIOH_READ, fn, addr, width, nbytes, buf, pkt); return status; @@ -324,7 +324,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, + return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt); } @@ -334,14 +334,14 @@ int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, addr &= SBSDIO_SB_OFT_ADDR_MASK; addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(sdiodev->sdioh, SDIOH_DATA_PIO, + return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, SDIOH_DATA_INC, (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, addr, 4, nbytes, buf, NULL); } int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) { - return brcmf_sdioh_abort(sdiodev->sdioh, fn); + return brcmf_sdioh_abort(sdiodev, fn); } u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev) @@ -354,11 +354,9 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) u32 regs = 0; int ret = 0; - sdiodev->sdioh = brcmf_sdioh_attach((void *)0); - if (!sdiodev->sdioh) { - ret = -ENODEV; + ret = brcmf_sdioh_attach(sdiodev); + if (ret) goto out; - } regs = SI_ENUM_BASE; @@ -388,10 +386,7 @@ int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) sdiodev->bus = NULL; } - if (sdiodev->sdioh) { - brcmf_sdioh_detach(sdiodev->sdioh); - sdiodev->sdioh = NULL; - } + brcmf_sdioh_detach(sdiodev); sdiodev->sbwad = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index a2fba4f0904..877428c9b65 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -46,7 +46,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func); static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func); -static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr); +static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr); static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id); static void brcmf_ops_sdio_remove(struct sdio_func *func); @@ -106,10 +106,10 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); #endif /* CONFIG_PM_SLEEP */ static int -brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, +brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, int regsize, u32 *data); -static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) +static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) { int err_ret; u32 fbraddr; @@ -118,24 +118,20 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) BRCMF_TRACE(("%s\n", __func__)); /* Get the Card's common CIS address */ - sd->com_cis_ptr = brcmf_sdioh_get_cisaddr(sd, SDIO_CCCR_CIS); - sd->func_cis_ptr[0] = sd->com_cis_ptr; + sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev, + SDIO_CCCR_CIS); BRCMF_INFO(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, - sd->com_cis_ptr)); + sdiodev->func_cis_ptr[0])); /* Get the Card's function CIS (for each function) */ for (fbraddr = SDIO_FBR_BASE(1), func = 1; - func <= sd->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { - sd->func_cis_ptr[func] = - brcmf_sdioh_get_cisaddr(sd, SDIO_FBR_CIS + fbraddr); + func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { + sdiodev->func_cis_ptr[func] = + brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr); BRCMF_INFO(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func, - sd->func_cis_ptr[func])); + sdiodev->func_cis_ptr[func])); } - sd->func_cis_ptr[0] = sd->com_cis_ptr; - BRCMF_INFO(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, - sd->com_cis_ptr)); - /* Enable Function 1 */ sdio_claim_host(gInstance->func[1]); err_ret = sdio_enable_func(gInstance->func[1]); @@ -150,82 +146,66 @@ static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) /* * Public entry points & extern's */ -struct sdioh_info *brcmf_sdioh_attach(void *bar0) +int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) { - struct sdioh_info *sd; - int err_ret; + int err_ret = 0; BRCMF_TRACE(("%s\n", __func__)); if (gInstance == NULL) { BRCMF_ERROR(("%s: SDIO Device not present\n", __func__)); - return NULL; + err_ret = -ENODEV; + goto out; } - sd = kzalloc(sizeof(struct sdioh_info), GFP_ATOMIC); - if (sd == NULL) { - BRCMF_ERROR(("sdioh_attach: out of memory\n")); - return NULL; - } + sdiodev->num_funcs = 2; - sd->num_funcs = 2; - - gInstance->sd = sd; - - /* Claim host controller */ sdio_claim_host(gInstance->func[1]); - err_ret = sdio_set_block_size(gInstance->func[1], 64); - if (err_ret) - BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); - - /* Release host controller F1 */ sdio_release_host(gInstance->func[1]); + if (err_ret) { + BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); + goto out; + } if (gInstance->func[2]) { - /* Claim host controller F2 */ sdio_claim_host(gInstance->func[2]); - err_ret = sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); - if (err_ret) + sdio_release_host(gInstance->func[2]); + if (err_ret) { BRCMF_ERROR(("%s: Failed to set F2 blocksize" " to %d\n", __func__, sd_f2_blocksize)); - - /* Release host controller F2 */ - sdio_release_host(gInstance->func[2]); + goto out; + } } - brcmf_sdioh_enablefuncs(sd); + brcmf_sdioh_enablefuncs(sdiodev); +out: BRCMF_TRACE(("%s: Done\n", __func__)); - return sd; + return err_ret; } -extern int brcmf_sdioh_detach(struct sdioh_info *sd) +void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) { BRCMF_TRACE(("%s\n", __func__)); - if (sd) { + /* Disable Function 2 */ + sdio_claim_host(gInstance->func[2]); + sdio_disable_func(gInstance->func[2]); + sdio_release_host(gInstance->func[2]); - /* Disable Function 2 */ - sdio_claim_host(gInstance->func[2]); - sdio_disable_func(gInstance->func[2]); - sdio_release_host(gInstance->func[2]); + /* Disable Function 1 */ + sdio_claim_host(gInstance->func[1]); + sdio_disable_func(gInstance->func[1]); + sdio_release_host(gInstance->func[1]); - /* Disable Function 1 */ - sdio_claim_host(gInstance->func[1]); - sdio_disable_func(gInstance->func[1]); - sdio_release_host(gInstance->func[1]); - - kfree(sd); - } - return 0; } /* Configure callback to client when we receive client interrupt */ extern int -brcmf_sdioh_interrupt_register(struct sdioh_info *sd) +brcmf_sdioh_interrupt_register(void) { BRCMF_TRACE(("%s: Entering\n", __func__)); @@ -245,7 +225,7 @@ brcmf_sdioh_interrupt_register(struct sdioh_info *sd) return 0; } -extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) +extern int brcmf_sdioh_interrupt_deregister(void) { BRCMF_TRACE(("%s: Entering\n", __func__)); @@ -270,14 +250,12 @@ extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) /* IOVar table */ enum { IOV_MSGLEVEL = 1, - IOV_NUMINTS, IOV_DEVREG, IOV_HCIREGS, IOV_RXCHAIN }; const struct brcmu_iovar sdioh_iovars[] = { - {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0}, {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} , {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} @@ -286,7 +264,7 @@ const struct brcmu_iovar sdioh_iovars[] = { }; int -brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, +brcmf_sdioh_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, void *params, int plen, void *arg, int len, bool set) { const struct brcmu_iovar *vi = NULL; @@ -345,11 +323,6 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, memcpy(arg, &int_val, val_size); break; - case IOV_GVAL(IOV_NUMINTS): - int_val = (s32) si->intrcount; - memcpy(arg, &int_val, val_size); - break; - case IOV_GVAL(IOV_DEVREG): { struct brcmf_sdreg *sd_ptr = @@ -357,7 +330,7 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, u8 data = 0; if (brcmf_sdioh_cfg_read - (si, sd_ptr->func, sd_ptr->offset, &data)) { + (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { bcmerror = -EIO; break; } @@ -374,7 +347,7 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, u8 data = (u8) sd_ptr->value; if (brcmf_sdioh_cfg_write - (si, sd_ptr->func, sd_ptr->offset, &data)) { + (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { bcmerror = -EIO; break; } @@ -391,32 +364,36 @@ exit: } extern int -brcmf_sdioh_cfg_read(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data) +brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, + u8 *data) { int status; /* No lock needed since brcmf_sdioh_request_byte does locking */ - status = brcmf_sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data); + status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num, + addr, data); return status; } extern int -brcmf_sdioh_cfg_write(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data) +brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, + u8 *data) { /* No lock needed since brcmf_sdioh_request_byte does locking */ int status; - status = brcmf_sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data); + status = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, fnc_num, + addr, data); return status; } -static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr) +static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) { /* read 24 bits and return valid 17 bit addr */ int i; u32 scratch, regdata; u8 *ptr = (u8 *)&scratch; for (i = 0; i < 3; i++) { - if ((brcmf_sdioh_card_regread(sd, 0, regaddr, 1, ®data)) != - SUCCESS) + if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, + ®data)) != SUCCESS) BRCMF_ERROR(("%s: Can't read!\n", __func__)); *ptr++ = (u8) regdata; @@ -430,7 +407,8 @@ static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr) } extern int -brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length) +brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, + u8 *cisd, u32 length) { u32 count; int offset; @@ -439,18 +417,18 @@ brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length) BRCMF_TRACE(("%s: Func = %d\n", __func__, func)); - if (!sd->func_cis_ptr[func]) { + if (!sdiodev->func_cis_ptr[func]) { memset(cis, 0, length); BRCMF_ERROR(("%s: no func_cis_ptr[%d]\n", __func__, func)); return -ENOTSUPP; } BRCMF_ERROR(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func, - sd->func_cis_ptr[func])); + sdiodev->func_cis_ptr[func])); for (count = 0; count < length; count++) { - offset = sd->func_cis_ptr[func] + count; - if (brcmf_sdioh_card_regread(sd, 0, offset, 1, &foo) < 0) { + offset = sdiodev->func_cis_ptr[func] + count; + if (brcmf_sdioh_card_regread(sdiodev, 0, offset, 1, &foo) < 0) { BRCMF_ERROR(("%s: regread failed: Can't read CIS\n", __func__)); return -EIO; @@ -464,7 +442,7 @@ brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length) } extern int -brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, +brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint regaddr, u8 *byte) { int err_ret; @@ -566,7 +544,7 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, } extern int -brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, +brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, uint func, uint addr, u32 *word, uint nbytes) { int err_ret = -EIO; @@ -618,8 +596,9 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, } static int -brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, - uint func, uint addr, struct sk_buff *pkt) +brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, + uint write, uint func, uint addr, + struct sk_buff *pkt) { bool fifo = (fix_inc == SDIOH_DATA_FIX); u32 SGCount = 0; @@ -698,9 +677,10 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, * */ extern int -brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, - uint write, uint func, uint addr, uint reg_width, - uint buflen_u, u8 *buffer, struct sk_buff *pkt) +brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, + uint fix_inc, uint write, uint func, uint addr, + uint reg_width, uint buflen_u, u8 *buffer, + struct sk_buff *pkt) { int Status; struct sk_buff *mypkt = NULL; @@ -724,8 +704,8 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, if (write) memcpy(mypkt->data, buffer, buflen_u); - Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, - addr, mypkt); + Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, + func, addr, mypkt); /* For a read, copy the packet data back to the buffer. */ if (!write) @@ -750,8 +730,8 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, if (write) memcpy(mypkt->data, pkt->data, pkt->len); - Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, - addr, mypkt); + Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, + func, addr, mypkt); /* For a read, copy the packet data back to the buffer. */ if (!write) @@ -762,22 +742,22 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, it is aligned. */ BRCMF_DATA(("%s: Aligned %s Packet, direct DMA\n", __func__, write ? "Tx" : "Rx")); - Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, - addr, pkt); + Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, + func, addr, pkt); } return Status; } /* this function performs "abort" for both of host & device */ -extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func) +extern int brcmf_sdioh_abort(struct brcmf_sdio_dev *sdiodev, uint func) { char t_func = (char)func; BRCMF_TRACE(("%s: Enter\n", __func__)); /* issue abort cmd52 command through F0 */ - brcmf_sdioh_request_byte(sd, SDIOH_WRITE, SDIO_FUNC_0, SDIO_CCCR_ABORT, - &t_func); + brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, SDIO_FUNC_0, + SDIO_CCCR_ABORT, &t_func); BRCMF_TRACE(("%s: Exit\n", __func__)); return 0; @@ -785,20 +765,21 @@ extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func) /* Read client card reg */ int -brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, +brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, int regsize, u32 *data) { if ((func == 0) || (regsize == 1)) { u8 temp = 0; - brcmf_sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp); + brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, func, regaddr, + &temp); *data = temp; *data &= 0xff; BRCMF_DATA(("%s: byte read data=0x%02x\n", __func__, *data)); } else { - brcmf_sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, data, - regsize); + brcmf_sdioh_request_word(sdiodev, 0, SDIOH_READ, func, regaddr, + data, regsize); if (regsize == 2) *data &= 0xffff; @@ -810,15 +791,12 @@ brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, static void brcmf_sdioh_irqhandler(struct sdio_func *func) { - struct sdioh_info *sd; struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); BRCMF_TRACE(("brcmf: ***IRQHandler\n")); - sd = gInstance->sd; sdio_release_host(gInstance->func[0]); - sd->intrcount++; brcmf_sdbrcm_isr(sdiodev->bus); sdio_claim_host(gInstance->func[0]); @@ -827,11 +805,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) /* interrupt handler for F2 (dummy handler) */ static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func) { - struct sdioh_info *sd; - BRCMF_TRACE(("brcmf: ***IRQHandlerF2\n")); - - sd = gInstance->sd; } static int brcmf_ops_sdio_probe(struct sdio_func *func, diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index c61a18679f6..dc95c4d9273 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -122,23 +122,7 @@ struct brcmf_sdreg { int value; }; -struct sdioh_info { - struct osl_info *osh; /* osh handler */ - - uint irq; /* Client irq */ - int intrcount; /* Client interrupts */ - bool sd_blockmode; /* sd_blockmode == false => 64 Byte Cmd 53s. */ - /* Must be on for sd_multiblock to be effective */ - u8 num_funcs; /* Supported funcs on client */ - u32 com_cis_ptr; - u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; - uint max_dma_len; - /* DMA Descriptors supported by this controller. */ - uint max_dma_descriptors; -}; - struct brcmf_sdmmc_instance { - struct sdioh_info *sd; struct sdio_func *func[SDIOD_MAX_IOFUNCS]; u32 host_claimed; atomic_t suspend; /* suspend flag */ @@ -147,7 +131,8 @@ struct brcmf_sdmmc_instance { struct brcmf_sdio_dev { struct sdio_func *func1; struct sdio_func *func2; - void *sdioh; /* sdioh handler */ + u8 num_funcs; /* Supported funcs on client */ + u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; u32 sbwad; /* Save backplane window address */ bool regfail; /* status of last reg_r/w call */ void *bus; @@ -250,10 +235,6 @@ extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, void *params, int plen, void *arg, int len, bool set); -/* helper functions */ - -struct sdioh_info; - /* platform specific/high level functions */ extern int brcmf_sdio_function_init(void); extern int brcmf_sdio_register(void); @@ -269,47 +250,47 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); * The handler shall be provided by all subsequent calls. No local cache * cfghdl points to the starting address of pci device mapped memory */ -extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl); -extern int brcmf_sdioh_detach(struct sdioh_info *si); +extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); +extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); extern int -brcmf_sdioh_interrupt_register(struct sdioh_info *si); +brcmf_sdioh_interrupt_register(void); -extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si); +extern int brcmf_sdioh_interrupt_deregister(void); /* read or write one byte using cmd52 */ -extern int -brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr, - u8 *byte); +extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, + uint fnc, uint addr, u8 *byte); /* read or write 2/4 bytes using cmd53 */ extern int -brcmf_sdioh_request_word(struct sdioh_info *si, uint cmd_type, +brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, uint fnc, uint addr, u32 *word, uint nbyte); /* read or write any buffer using cmd53 */ extern int -brcmf_sdioh_request_buffer(struct sdioh_info *si, uint pio_dma, +brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, uint fix_inc, uint rw, uint fnc_num, u32 addr, uint regwidth, u32 buflen, u8 *buffer, struct sk_buff *pkt); /* get cis data */ -extern int -brcmf_sdioh_cis_read(struct sdioh_info *si, uint fuc, u8 *cis, u32 length); +extern int brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint fuc, + u8 *cis, u32 length); -extern int -brcmf_sdioh_cfg_read(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); -extern int -brcmf_sdioh_cfg_write(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); +extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fuc, + u32 addr, u8 *data); +extern int brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fuc, + u32 addr, u8 *data); /* handle iovars */ -extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, - void *params, int plen, void *arg, int len, bool set); +extern int brcmf_sdioh_iovar_op(struct brcmf_sdio_dev *sdiodev, + const char *name, void *params, int plen, + void *arg, int len, bool set); /* Issue abort to the specified function and clear controller as needed */ -extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); +extern int brcmf_sdioh_abort(struct brcmf_sdio_dev *sdiodev, uint fnc); /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, From 47b4c640b849fc4aea881f4dd5f074c8943891d2 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:51 +0200 Subject: [PATCH 0108/1519] staging: brcm80211: remove global var gInstance from brcmfmac Use sdio function pointer stored in struct brcmf_sdio_dev instead of those in gInstance. Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 5 +- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 198 ++++++++---------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 7 +- .../staging/brcm80211/brcmfmac/sdio_host.h | 18 +- 4 files changed, 99 insertions(+), 129 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 6a9ac1dda12..aaf13f48b12 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -55,12 +56,12 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_register(); + return brcmf_sdioh_interrupt_register(sdiodev); } int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_deregister(); + return brcmf_sdioh_interrupt_deregister(sdiodev); } u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 877428c9b65..76b33942c74 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -58,8 +58,6 @@ static int brcmf_sdio_resume(struct device *dev); uint sd_f2_blocksize = 512; /* Default blocksize */ -struct brcmf_sdmmc_instance *gInstance; - /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, @@ -133,9 +131,9 @@ static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) } /* Enable Function 1 */ - sdio_claim_host(gInstance->func[1]); - err_ret = sdio_enable_func(gInstance->func[1]); - sdio_release_host(gInstance->func[1]); + sdio_claim_host(sdiodev->func[1]); + err_ret = sdio_enable_func(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); if (err_ret) BRCMF_ERROR(("brcmf_sdioh_enablefuncs: Failed to enable F1 " "Err: 0x%08x\n", err_ret)); @@ -152,32 +150,23 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) BRCMF_TRACE(("%s\n", __func__)); - if (gInstance == NULL) { - BRCMF_ERROR(("%s: SDIO Device not present\n", __func__)); - err_ret = -ENODEV; - goto out; - } - sdiodev->num_funcs = 2; - sdio_claim_host(gInstance->func[1]); - err_ret = sdio_set_block_size(gInstance->func[1], 64); - sdio_release_host(gInstance->func[1]); + sdio_claim_host(sdiodev->func[1]); + err_ret = sdio_set_block_size(sdiodev->func[1], 64); + sdio_release_host(sdiodev->func[1]); if (err_ret) { BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); goto out; } - if (gInstance->func[2]) { - sdio_claim_host(gInstance->func[2]); - err_ret = - sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); - sdio_release_host(gInstance->func[2]); - if (err_ret) { - BRCMF_ERROR(("%s: Failed to set F2 blocksize" - " to %d\n", __func__, sd_f2_blocksize)); - goto out; - } + sdio_claim_host(sdiodev->func[2]); + err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize); + sdio_release_host(sdiodev->func[2]); + if (err_ret) { + BRCMF_ERROR(("%s: Failed to set F2 blocksize" + " to %d\n", __func__, sd_f2_blocksize)); + goto out; } brcmf_sdioh_enablefuncs(sdiodev); @@ -192,56 +181,56 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) BRCMF_TRACE(("%s\n", __func__)); /* Disable Function 2 */ - sdio_claim_host(gInstance->func[2]); - sdio_disable_func(gInstance->func[2]); - sdio_release_host(gInstance->func[2]); + sdio_claim_host(sdiodev->func[2]); + sdio_disable_func(sdiodev->func[2]); + sdio_release_host(sdiodev->func[2]); /* Disable Function 1 */ - sdio_claim_host(gInstance->func[1]); - sdio_disable_func(gInstance->func[1]); - sdio_release_host(gInstance->func[1]); + sdio_claim_host(sdiodev->func[1]); + sdio_disable_func(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); } /* Configure callback to client when we receive client interrupt */ extern int -brcmf_sdioh_interrupt_register(void) +brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev) { BRCMF_TRACE(("%s: Entering\n", __func__)); /* register and unmask irq */ - if (gInstance->func[2]) { - sdio_claim_host(gInstance->func[2]); - sdio_claim_irq(gInstance->func[2], brcmf_sdioh_irqhandler_f2); - sdio_release_host(gInstance->func[2]); + if (sdiodev->func[2]) { + sdio_claim_host(sdiodev->func[2]); + sdio_claim_irq(sdiodev->func[2], brcmf_sdioh_irqhandler_f2); + sdio_release_host(sdiodev->func[2]); } - if (gInstance->func[1]) { - sdio_claim_host(gInstance->func[1]); - sdio_claim_irq(gInstance->func[1], brcmf_sdioh_irqhandler); - sdio_release_host(gInstance->func[1]); + if (sdiodev->func[1]) { + sdio_claim_host(sdiodev->func[1]); + sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler); + sdio_release_host(sdiodev->func[1]); } return 0; } -extern int brcmf_sdioh_interrupt_deregister(void) +int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev) { BRCMF_TRACE(("%s: Entering\n", __func__)); - if (gInstance->func[1]) { + if (sdiodev->func[1]) { /* register and unmask irq */ - sdio_claim_host(gInstance->func[1]); - sdio_release_irq(gInstance->func[1]); - sdio_release_host(gInstance->func[1]); + sdio_claim_host(sdiodev->func[1]); + sdio_release_irq(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); } - if (gInstance->func[2]) { + if (sdiodev->func[2]) { /* Claim host controller F2 */ - sdio_claim_host(gInstance->func[2]); - sdio_release_irq(gInstance->func[2]); + sdio_claim_host(sdiodev->func[2]); + sdio_release_irq(sdiodev->func[2]); /* Release host controller F2 */ - sdio_release_host(gInstance->func[2]); + sdio_release_host(sdiodev->func[2]); } return 0; @@ -450,8 +439,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, regaddr)); - BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, gInstance); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); + BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); if (rw) { /* CMD52 Write */ if (func == 0) { /* Can only directly write to some F0 registers. @@ -459,13 +448,13 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, * as a special case. */ if (regaddr == SDIO_CCCR_IOEx) { - if (gInstance->func[2]) { - sdio_claim_host(gInstance->func[2]); + if (sdiodev->func[2]) { + sdio_claim_host(sdiodev->func[2]); if (*byte & SDIO_FUNC_ENABLE_2) { /* Enable Function 2 */ err_ret = sdio_enable_func - (gInstance->func[2]); + (sdiodev->func[2]); if (err_ret) BRCMF_ERROR(( "request_byte: " @@ -476,7 +465,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, /* Disable Function 2 */ err_ret = sdio_disable_func - (gInstance->func[2]); + (sdiodev->func[2]); if (err_ret) BRCMF_ERROR(( "request_byte: " @@ -484,55 +473,55 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, "failed:%d\n", err_ret)); } - sdio_release_host(gInstance->func[2]); + sdio_release_host(sdiodev->func[2]); } } /* to allow abort command through F1 */ else if (regaddr == SDIO_CCCR_ABORT) { - sdio_claim_host(gInstance->func[func]); + sdio_claim_host(sdiodev->func[func]); /* * this sdio_f0_writeb() can be replaced * with another api * depending upon MMC driver change. * As of this time, this is temporaray one */ - sdio_writeb(gInstance->func[func], *byte, + sdio_writeb(sdiodev->func[func], *byte, regaddr, &err_ret); - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); } else if (regaddr < 0xF0) { BRCMF_ERROR(("brcmf: F0 Wr:0x%02x: write " "disallowed\n", regaddr)); } else { /* Claim host controller, perform F0 write, and release */ - sdio_claim_host(gInstance->func[func]); - sdio_f0_writeb(gInstance->func[func], *byte, + sdio_claim_host(sdiodev->func[func]); + sdio_f0_writeb(sdiodev->func[func], *byte, regaddr, &err_ret); - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); } } else { /* Claim host controller, perform Fn write, and release */ - sdio_claim_host(gInstance->func[func]); - sdio_writeb(gInstance->func[func], *byte, regaddr, + sdio_claim_host(sdiodev->func[func]); + sdio_writeb(sdiodev->func[func], *byte, regaddr, &err_ret); - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); } } else { /* CMD52 Read */ /* Claim host controller, perform Fn read, and release */ - sdio_claim_host(gInstance->func[func]); + sdio_claim_host(sdiodev->func[func]); if (func == 0) { *byte = - sdio_f0_readb(gInstance->func[func], regaddr, + sdio_f0_readb(sdiodev->func[func], regaddr, &err_ret); } else { *byte = - sdio_readb(gInstance->func[func], regaddr, + sdio_readb(sdiodev->func[func], regaddr, &err_ret); } - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); } if (err_ret) @@ -557,17 +546,17 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", __func__, cmd_type, rw, func, addr, nbytes)); - BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, gInstance); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); + BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); /* Claim host controller */ - sdio_claim_host(gInstance->func[func]); + sdio_claim_host(sdiodev->func[func]); if (rw) { /* CMD52 Write */ if (nbytes == 4) - sdio_writel(gInstance->func[func], *word, addr, + sdio_writel(sdiodev->func[func], *word, addr, &err_ret); else if (nbytes == 2) - sdio_writew(gInstance->func[func], (*word & 0xFFFF), + sdio_writew(sdiodev->func[func], (*word & 0xFFFF), addr, &err_ret); else BRCMF_ERROR(("%s: Invalid nbytes: %d\n", @@ -575,10 +564,10 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, } else { /* CMD52 Read */ if (nbytes == 4) *word = - sdio_readl(gInstance->func[func], addr, &err_ret); + sdio_readl(sdiodev->func[func], addr, &err_ret); else if (nbytes == 2) *word = - sdio_readw(gInstance->func[func], addr, + sdio_readw(sdiodev->func[func], addr, &err_ret) & 0xFFFF; else BRCMF_ERROR(("%s: Invalid nbytes: %d\n", @@ -586,7 +575,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, } /* Release host controller */ - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); if (err_ret) BRCMF_ERROR(("brcmf: Failed to %s word, Err: 0x%08x\n", @@ -608,30 +597,30 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, gInstance); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); + BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); /* Claim host controller */ - sdio_claim_host(gInstance->func[func]); + sdio_claim_host(sdiodev->func[func]); for (pnext = pkt; pnext; pnext = pnext->next) { uint pkt_len = pnext->len; pkt_len += 3; pkt_len &= 0xFFFFFFFC; if ((write) && (!fifo)) { - err_ret = sdio_memcpy_toio(gInstance->func[func], addr, + err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, ((u8 *) (pnext->data)), pkt_len); } else if (write) { - err_ret = sdio_memcpy_toio(gInstance->func[func], addr, + err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, ((u8 *) (pnext->data)), pkt_len); } else if (fifo) { - err_ret = sdio_readsb(gInstance->func[func], + err_ret = sdio_readsb(sdiodev->func[func], ((u8 *) (pnext->data)), addr, pkt_len); } else { - err_ret = sdio_memcpy_fromio(gInstance->func[func], + err_ret = sdio_memcpy_fromio(sdiodev->func[func], ((u8 *) (pnext->data)), addr, pkt_len); } @@ -655,7 +644,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, } /* Release host controller */ - sdio_release_host(gInstance->func[func]); + sdio_release_host(sdiodev->func[func]); BRCMF_TRACE(("%s: Exit\n", __func__)); return err_ret; @@ -687,8 +676,8 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, gInstance); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); + BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev); + BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); /* Case 1: we don't have a packet. */ if (pkt == NULL) { BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n", @@ -795,11 +784,11 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) BRCMF_TRACE(("brcmf: ***IRQHandler\n")); - sdio_release_host(gInstance->func[0]); + sdio_release_host(func); brcmf_sdbrcm_isr(sdiodev->bus); - sdio_claim_host(gInstance->func[0]); + sdio_claim_host(func); } /* interrupt handler for F2 (dummy handler) */ @@ -812,7 +801,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { int ret = 0; - static struct sdio_func sdio_func_0; struct brcmf_sdio_dev *sdiodev; BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__)); BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class)); @@ -821,10 +809,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, BRCMF_TRACE(("Function#: 0x%04x\n", func->num)); if (func->num == 1) { - sdio_func_0.num = 0; - sdio_func_0.card = func->card; - gInstance->func[0] = &sdio_func_0; - if (dev_get_drvdata(&func->card->dev)) { BRCMF_ERROR(("%s: card private drvdata occupied.\n", __func__)); @@ -833,19 +817,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); if (!sdiodev) return -ENOMEM; - sdiodev->func1 = func; + sdiodev->func[0] = func->card->sdio_func[0]; + sdiodev->func[1] = func; dev_set_drvdata(&func->card->dev, sdiodev); - atomic_set(&gInstance->suspend, false); + atomic_set(&sdiodev->suspend, false); } - gInstance->func[func->num] = func; - if (func->num == 2) { sdiodev = dev_get_drvdata(&func->card->dev); - if ((!sdiodev) || (sdiodev->func1->card != func->card)) + if ((!sdiodev) || (sdiodev->func[1]->card != func->card)) return -ENODEV; - sdiodev->func2 = func; + sdiodev->func[2] = func; brcmf_cfg80211_sdio_func(func); BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n")); @@ -884,21 +867,22 @@ static int brcmf_sdio_suspend(struct device *dev) BRCMF_TRACE(("%s\n", __func__)); - atomic_set(&gInstance->suspend, true); + sdiodev = dev_get_drvdata(&func->card->dev); - sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]); + atomic_set(&sdiodev->suspend, true); + + sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { BRCMF_ERROR(("Host can't keep power while suspended\n")); return -EINVAL; } - ret = sdio_set_host_pm_flags(gInstance->func[1], MMC_PM_KEEP_POWER); + ret = sdio_set_host_pm_flags(sdiodev->func[1], MMC_PM_KEEP_POWER); if (ret) { BRCMF_ERROR(("Failed to set pm_flags\n")); return ret; } - sdiodev = dev_get_drvdata(&func->card->dev); brcmf_sdio_wdtmr_enable(sdiodev, false); return ret; @@ -911,7 +895,7 @@ static int brcmf_sdio_resume(struct device *dev) sdiodev = dev_get_drvdata(&func->card->dev); brcmf_sdio_wdtmr_enable(sdiodev, true); - atomic_set(&gInstance->suspend, false); + atomic_set(&sdiodev->suspend, false); return 0; } #endif /* CONFIG_PM_SLEEP */ @@ -924,10 +908,6 @@ int brcmf_sdio_function_init(void) int error = 0; BRCMF_TRACE(("brcmf_sdio_function_init: %s Enter\n", __func__)); - gInstance = kzalloc(sizeof(struct brcmf_sdmmc_instance), GFP_KERNEL); - if (!gInstance) - return -ENOMEM; - error = sdio_register_driver(&brcmf_sdmmc_driver); return error; @@ -941,6 +921,4 @@ void brcmf_sdio_function_cleanup(void) BRCMF_TRACE(("%s Enter\n", __func__)); sdio_unregister_driver(&brcmf_sdmmc_driver); - - kfree(gInstance); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 65b245c1cb3..b61b9555fab 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -5685,7 +5686,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) bus->idleclock = BRCMF_IDLE_ACTIVE; /* Query the F2 block size, set roundup accordingly */ - bus->blocksize = bus->sdiodev->func2->cur_blksize; + bus->blocksize = bus->sdiodev->func[2]->cur_blksize; bus->roundup = min(max_roundup, bus->blocksize); /* Query if bus module supports packet chaining, @@ -5828,7 +5829,7 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) bus->fw_name = BCM4329_FW_NAME; ret = request_firmware(&bus->firmware, bus->fw_name, - &gInstance->func[2]->dev); + &bus->sdiodev->func[2]->dev); if (ret) { BRCMF_ERROR(("%s: Fail to request firmware %d\n", __func__, ret)); @@ -5930,7 +5931,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) bus->nv_name = BCM4329_NV_NAME; ret = request_firmware(&bus->firmware, bus->nv_name, - &gInstance->func[2]->dev); + &bus->sdiodev->func[2]->dev); if (ret) { BRCMF_ERROR(("%s: Fail to request nvram %d\n", __func__, ret)); return ret; diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index dc95c4d9273..4296c937505 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -122,20 +122,14 @@ struct brcmf_sdreg { int value; }; -struct brcmf_sdmmc_instance { - struct sdio_func *func[SDIOD_MAX_IOFUNCS]; - u32 host_claimed; - atomic_t suspend; /* suspend flag */ -}; - struct brcmf_sdio_dev { - struct sdio_func *func1; - struct sdio_func *func2; + struct sdio_func *func[SDIO_MAX_FUNCS]; u8 num_funcs; /* Supported funcs on client */ u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; u32 sbwad; /* Save backplane window address */ bool regfail; /* status of last reg_r/w call */ void *bus; + atomic_t suspend; /* suspend flag */ }; /* Register/deregister device interrupt handler. */ @@ -253,10 +247,8 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); -extern int -brcmf_sdioh_interrupt_register(void); - -extern int brcmf_sdioh_interrupt_deregister(void); +extern int brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev); +extern int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev); /* read or write one byte using cmd52 */ extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, @@ -298,8 +290,6 @@ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, extern uint sd_f2_blocksize; -extern struct brcmf_sdmmc_instance *gInstance; - extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, u32 regsva, struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdbrcm_disconnect(void *ptr); From a9ac9703aa66262d3ec6d5180734ccac00f2b02d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:52 +0200 Subject: [PATCH 0109/1519] staging: brcm80211: remove wext traces in fullmac wext support code have been removed a while ago. This patch removes the traces left behind. Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 2 -- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index f4cf9b23481..621570a77bc 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -22,8 +22,6 @@ config BRCMFMAC depends on WLAN && CFG80211 select BRCMUTIL select FW_LOADER - select WIRELESS_EXT - select WEXT_PRIV ---help--- This module adds support for embedded wireless adapters based on Broadcom IEEE802.11n FullMAC chipsets. This driver uses the kernel's diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 833defb0d9b..def1f777f0c 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include From 632ea5ee37b21a01dc3b74e77fef54b69d0c88b1 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:53 +0200 Subject: [PATCH 0110/1519] staging: brcm80211: absorb brcmf_sdioh_iovar_op into brcmf_sdcard_iovar_op fullmac wrapper function cleanup. Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 112 ++++++++++++++++- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 116 ------------------ .../staging/brcm80211/brcmfmac/sdio_host.h | 5 - 3 files changed, 110 insertions(+), 123 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index aaf13f48b12..13b6dbe7a18 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -46,12 +46,120 @@ module_param(sd_f2_blocksize, int, 0); +/* IOVar table */ +enum { + IOV_MSGLEVEL = 1, + IOV_DEVREG, + IOV_HCIREGS, + IOV_RXCHAIN +}; + +const struct brcmu_iovar sdioh_iovars[] = { + {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} + , + {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} + , + {NULL, 0, 0, 0, 0} +}; + int brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, void *params, int plen, void *arg, int len, bool set) { - return brcmf_sdioh_iovar_op(sdiodev, name, params, plen, arg, - len, set); + const struct brcmu_iovar *vi = NULL; + int bcmerror = 0; + int val_size; + s32 int_val = 0; + bool bool_val; + u32 actionid; + + if (name == NULL || len < 0) + return -EINVAL; + + /* Set does not take qualifiers */ + if (set && (params || plen)) + return -EINVAL; + + /* Get must have return space;*/ + if (!set && !(arg && len)) + return -EINVAL; + + BRCMF_TRACE(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), + name)); + + vi = brcmu_iovar_lookup(sdioh_iovars, name); + if (vi == NULL) { + bcmerror = -ENOTSUPP; + goto exit; + } + + bcmerror = brcmu_iovar_lencheck(vi, arg, len, set); + if (bcmerror != 0) + goto exit; + + /* Set up params so get and set can share the convenience variables */ + if (params == NULL) { + params = arg; + plen = len; + } + + if (vi->type == IOVT_VOID) + val_size = 0; + else if (vi->type == IOVT_BUFFER) + val_size = len; + else + val_size = sizeof(int); + + if (plen >= (int)sizeof(int_val)) + memcpy(&int_val, params, sizeof(int_val)); + + bool_val = (int_val != 0) ? true : false; + + actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); + switch (actionid) { + case IOV_GVAL(IOV_RXCHAIN): + int_val = false; + memcpy(arg, &int_val, val_size); + break; + + case IOV_GVAL(IOV_DEVREG): + { + struct brcmf_sdreg *sd_ptr = + (struct brcmf_sdreg *) params; + u8 data = 0; + + if (brcmf_sdioh_cfg_read + (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { + bcmerror = -EIO; + break; + } + + int_val = (int)data; + memcpy(arg, &int_val, sizeof(int_val)); + break; + } + + case IOV_SVAL(IOV_DEVREG): + { + struct brcmf_sdreg *sd_ptr = + (struct brcmf_sdreg *) params; + u8 data = (u8) sd_ptr->value; + + if (brcmf_sdioh_cfg_write + (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { + bcmerror = -EIO; + break; + } + break; + } + + default: + bcmerror = -ENOTSUPP; + break; + } +exit: + + return bcmerror; } int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 76b33942c74..1bfeec62865 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -236,122 +236,6 @@ int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev) return 0; } -/* IOVar table */ -enum { - IOV_MSGLEVEL = 1, - IOV_DEVREG, - IOV_HCIREGS, - IOV_RXCHAIN -}; - -const struct brcmu_iovar sdioh_iovars[] = { - {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} - , - {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} - , - {NULL, 0, 0, 0, 0} -}; - -int -brcmf_sdioh_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, - void *params, int plen, void *arg, int len, bool set) -{ - const struct brcmu_iovar *vi = NULL; - int bcmerror = 0; - int val_size; - s32 int_val = 0; - bool bool_val; - u32 actionid; - - if (name == NULL || len < 0) - return -EINVAL; - - /* Set does not take qualifiers */ - if (set && (params || plen)) - return -EINVAL; - - /* Get must have return space;*/ - if (!set && !(arg && len)) - return -EINVAL; - - BRCMF_TRACE(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), - name)); - - vi = brcmu_iovar_lookup(sdioh_iovars, name); - if (vi == NULL) { - bcmerror = -ENOTSUPP; - goto exit; - } - - bcmerror = brcmu_iovar_lencheck(vi, arg, len, set); - if (bcmerror != 0) - goto exit; - - /* Set up params so get and set can share the convenience variables */ - if (params == NULL) { - params = arg; - plen = len; - } - - if (vi->type == IOVT_VOID) - val_size = 0; - else if (vi->type == IOVT_BUFFER) - val_size = len; - else - val_size = sizeof(int); - - if (plen >= (int)sizeof(int_val)) - memcpy(&int_val, params, sizeof(int_val)); - - bool_val = (int_val != 0) ? true : false; - - actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); - switch (actionid) { - case IOV_GVAL(IOV_RXCHAIN): - int_val = false; - memcpy(arg, &int_val, val_size); - break; - - case IOV_GVAL(IOV_DEVREG): - { - struct brcmf_sdreg *sd_ptr = - (struct brcmf_sdreg *) params; - u8 data = 0; - - if (brcmf_sdioh_cfg_read - (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { - bcmerror = -EIO; - break; - } - - int_val = (int)data; - memcpy(arg, &int_val, sizeof(int_val)); - break; - } - - case IOV_SVAL(IOV_DEVREG): - { - struct brcmf_sdreg *sd_ptr = - (struct brcmf_sdreg *) params; - u8 data = (u8) sd_ptr->value; - - if (brcmf_sdioh_cfg_write - (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { - bcmerror = -EIO; - break; - } - break; - } - - default: - bcmerror = -ENOTSUPP; - break; - } -exit: - - return bcmerror; -} - extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u8 *data) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 4296c937505..4a814e54f99 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -276,11 +276,6 @@ extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fuc, extern int brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fuc, u32 addr, u8 *data); -/* handle iovars */ -extern int brcmf_sdioh_iovar_op(struct brcmf_sdio_dev *sdiodev, - const char *name, void *params, int plen, - void *arg, int len, bool set); - /* Issue abort to the specified function and clear controller as needed */ extern int brcmf_sdioh_abort(struct brcmf_sdio_dev *sdiodev, uint fnc); From 8e8d49663f0beca00b12de11b3a332fd24c23af3 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:54 +0200 Subject: [PATCH 0111/1519] staging: brcm80211: absorb brcmf_sdioh_interrupt_register into brcmf_sdcard_intr_reg brcmfmac wrapper function cleanup Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 22 +++++++++- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 43 ------------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 1 - 3 files changed, 21 insertions(+), 45 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 13b6dbe7a18..e5cf138100f 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -162,9 +163,28 @@ exit: return bcmerror; } +static void brcmf_sdioh_irqhandler(struct sdio_func *func) +{ + struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); + + BRCMF_TRACE(("brcmf: ***IRQHandler\n")); + + sdio_release_host(func); + + brcmf_sdbrcm_isr(sdiodev->bus); + + sdio_claim_host(func); +} + int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_register(sdiodev); + BRCMF_TRACE(("%s: Entering\n", __func__)); + + sdio_claim_host(sdiodev->func[1]); + sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler); + sdio_release_host(sdiodev->func[1]); + + return 0; } int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 1bfeec62865..2e7d3cea867 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -44,8 +44,6 @@ #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ -static void brcmf_sdioh_irqhandler(struct sdio_func *func); -static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func); static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr); static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id); @@ -192,28 +190,6 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) } -/* Configure callback to client when we receive client interrupt */ -extern int -brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev) -{ - BRCMF_TRACE(("%s: Entering\n", __func__)); - - /* register and unmask irq */ - if (sdiodev->func[2]) { - sdio_claim_host(sdiodev->func[2]); - sdio_claim_irq(sdiodev->func[2], brcmf_sdioh_irqhandler_f2); - sdio_release_host(sdiodev->func[2]); - } - - if (sdiodev->func[1]) { - sdio_claim_host(sdiodev->func[1]); - sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler); - sdio_release_host(sdiodev->func[1]); - } - - return 0; -} - int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev) { BRCMF_TRACE(("%s: Entering\n", __func__)); @@ -662,25 +638,6 @@ brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, return SUCCESS; } -static void brcmf_sdioh_irqhandler(struct sdio_func *func) -{ - struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); - - BRCMF_TRACE(("brcmf: ***IRQHandler\n")); - - sdio_release_host(func); - - brcmf_sdbrcm_isr(sdiodev->bus); - - sdio_claim_host(func); -} - -/* interrupt handler for F2 (dummy handler) */ -static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func) -{ - BRCMF_TRACE(("brcmf: ***IRQHandlerF2\n")); -} - static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 4a814e54f99..bdbf4112434 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -247,7 +247,6 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); -extern int brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev); /* read or write one byte using cmd52 */ From 7b687524f78dac9d521051483e7e77154c314be5 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:55 +0200 Subject: [PATCH 0112/1519] staging: brcm80211: absorb brcmf_sdioh_interrupt_deregister into brcmf_sdcard_intr_dereg brcmfmac wrapper function cleanup Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 8 ++++++- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 22 ------------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 2 -- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index e5cf138100f..6c1b57d2faa 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -189,7 +189,13 @@ int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) { - return brcmf_sdioh_interrupt_deregister(sdiodev); + BRCMF_TRACE(("%s: Entering\n", __func__)); + + sdio_claim_host(sdiodev->func[1]); + sdio_release_irq(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); + + return 0; } u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 2e7d3cea867..1dfad3e13e0 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -190,28 +190,6 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) } -int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev) -{ - BRCMF_TRACE(("%s: Entering\n", __func__)); - - if (sdiodev->func[1]) { - /* register and unmask irq */ - sdio_claim_host(sdiodev->func[1]); - sdio_release_irq(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - } - - if (sdiodev->func[2]) { - /* Claim host controller F2 */ - sdio_claim_host(sdiodev->func[2]); - sdio_release_irq(sdiodev->func[2]); - /* Release host controller F2 */ - sdio_release_host(sdiodev->func[2]); - } - - return 0; -} - extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u8 *data) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index bdbf4112434..d9803071d03 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -247,8 +247,6 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); -extern int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev); - /* read or write one byte using cmd52 */ extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint fnc, uint addr, u8 *byte); From 8c1d08537bde4fc816da775e0a6f11442498e98d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:56 +0200 Subject: [PATCH 0113/1519] staging: brcm80211: absorb brcmf_sdioh_abort into brcmf_sdcard_abort brcmfmac wrapper function cleanup Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 11 ++++++++++- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 14 -------------- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 3 --- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 6c1b57d2faa..8bb84a98566 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -476,7 +477,15 @@ int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) { - return brcmf_sdioh_abort(sdiodev, fn); + char t_func = (char)fn; + BRCMF_TRACE(("%s: Enter\n", __func__)); + + /* issue abort cmd52 command through F0 */ + brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, SDIO_FUNC_0, + SDIO_CCCR_ABORT, &t_func); + + BRCMF_TRACE(("%s: Exit\n", __func__)); + return 0; } u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 1dfad3e13e0..d7648f867c9 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -576,20 +576,6 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, return Status; } -/* this function performs "abort" for both of host & device */ -extern int brcmf_sdioh_abort(struct brcmf_sdio_dev *sdiodev, uint func) -{ - char t_func = (char)func; - BRCMF_TRACE(("%s: Enter\n", __func__)); - - /* issue abort cmd52 command through F0 */ - brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, SDIO_FUNC_0, - SDIO_CCCR_ABORT, &t_func); - - BRCMF_TRACE(("%s: Exit\n", __func__)); - return 0; -} - /* Read client card reg */ int brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index d9803071d03..555f17bab9a 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -273,9 +273,6 @@ extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fuc, extern int brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fuc, u32 addr, u8 *data); -/* Issue abort to the specified function and clear controller as needed */ -extern int brcmf_sdioh_abort(struct brcmf_sdio_dev *sdiodev, uint fnc); - /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable); From 72b1f6c382bc2b7a7180c4a97563405ec4e7ad83 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:57 +0200 Subject: [PATCH 0114/1519] staging: brcm80211: remove dead code from dhd_sdio.c Code cleanup for brcmfmac Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 220 ++++-------------- 1 file changed, 46 insertions(+), 174 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index b61b9555fab..cd58ef847aa 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -38,28 +38,6 @@ #ifdef BCMDBG /* ARM trap handling */ - -/* Trap types defined by ARM (see arminc.h) */ - -#if defined(__ARM_ARCH_4T__) -#define MAX_TRAP_TYPE (TR_FIQ + 1) -#elif defined(__ARM_ARCH_7M__) -#define MAX_TRAP_TYPE (TR_ISR + ARMCM3_NUMINTS) -#endif /* __ARM_ARCH_7M__ */ - -/* The trap structure is defined here as offsets for assembly */ -#define TR_TYPE 0x00 -#define TR_EPC 0x04 -#define TR_CPSR 0x08 -#define TR_SPSR 0x0c -#define TR_REGS 0x10 -#define TR_REG(n) (TR_REGS + (n) * 4) -#define TR_SP TR_REG(13) -#define TR_LR TR_REG(14) -#define TR_PC TR_REG(15) - -#define TRAP_T_SIZE 80 - struct brcmf_trap { u32 type; u32 epc; @@ -620,7 +598,6 @@ struct brcmf_bus { u32 ramsize; /* Size of RAM in SOCRAM (bytes) */ u32 orig_ramsize; /* Size of RAM in SOCRAM (bytes) */ - u32 bus; /* gSPI or SDIO bus */ u32 hostintmask; /* Copy of Host Interrupt Mask */ u32 intstatus; /* Intstatus bits (events) pending */ bool dpc_sched; /* Indicates DPC schedule (intrpt rcvd) */ @@ -801,8 +778,6 @@ struct sbconfig { #define CLK_PENDING 2 /* Not used yet */ #define CLK_AVAIL 3 -#define BRCMF_NOPMU(brcmf) (false) - #ifdef BCMDBG static int qcount[NUMPRIO]; static int tx_packets[NUMPRIO]; @@ -862,12 +837,9 @@ module_param(brcmf_dongle_memsize, int, 0); static bool brcmf_alignctl; -static bool sd1idle; - static bool retrydata; #define RETRYCHAN(chan) (((chan) == SDPCM_EVENT_CHANNEL) || retrydata) -static const uint watermark = 8; static const uint firstread = BRCMF_FIRSTREAD; /* Retry count for register access failures */ @@ -939,8 +911,6 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) } } -#define BRCMF_BUS SDIO_BUS - #define PKT_AVAILABLE() (intstatus & I_HMB_FRAME_IND) #define HOSTINTMASK (I_HMB_SW_MASK | I_CHIPACTIVE) @@ -1012,7 +982,7 @@ static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus); */ static void brcmf_sdbrcm_pktfree2(struct brcmf_bus *bus, struct sk_buff *pkt) { - if ((bus->bus != SPI_BUS) || bus->usebufpool) + if (bus->usebufpool) brcmu_pkt_buf_free_skb(pkt); } @@ -1890,18 +1860,15 @@ enum { IOV_ALIGNCTL, IOV_SDALIGN, IOV_DEVRESET, - IOV_CPU, #ifdef SDTEST IOV_PKTGEN, IOV_EXTLOOP, #endif /* SDTEST */ - IOV_SPROM, IOV_TXBOUND, IOV_RXBOUND, IOV_TXMINMAX, IOV_IDLETIME, IOV_IDLECLOCK, - IOV_SD1IDLE, IOV_SLEEP, IOV_WDTICK, IOV_IOCTLTIMEOUT, @@ -1914,7 +1881,6 @@ const struct brcmu_iovar brcmf_sdio_iovars[] = { {"pollrate", IOV_POLLRATE, 0, IOVT_UINT32, 0}, {"idletime", IOV_IDLETIME, 0, IOVT_INT32, 0}, {"idleclock", IOV_IDLECLOCK, 0, IOVT_INT32, 0}, - {"sd1idle", IOV_SD1IDLE, 0, IOVT_BOOL, 0}, {"membytes", IOV_MEMBYTES, 0, IOVT_BUFFER, 2 * sizeof(int)}, {"memsize", IOV_MEMSIZE, 0, IOVT_UINT32, 0}, {"download", IOV_DOWNLOAD, 0, IOVT_BOOL, 0}, @@ -1946,8 +1912,6 @@ const struct brcmu_iovar brcmf_sdio_iovars[] = { , {"txminmax", IOV_TXMINMAX, 0, IOVT_UINT32, 0} , - {"cpu", IOV_CPU, 0, IOVT_BOOL, 0} - , {"checkdied", IOV_CHECKDIED, 0, IOVT_BUFFER, 0} , #endif /* BCMDBG */ @@ -2636,15 +2600,6 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, bus->idleclock = int_val; break; - case IOV_GVAL(IOV_SD1IDLE): - int_val = (s32) sd1idle; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_SD1IDLE): - sd1idle = bool_val; - break; - case IOV_SVAL(IOV_MEMBYTES): case IOV_GVAL(IOV_MEMBYTES): { @@ -3370,7 +3325,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) offsetof(struct sdpcmd_regs, hostintmask), &retries); brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_WATERMARK, (u8) watermark, &err); + SBSDIO_WATERMARK, 8, &err); /* Set bus state according to enable result */ drvr->busstate = BRCMF_BUS_DATA; @@ -3484,10 +3439,6 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) BRCMF_TRACE(("%s: Enter\n", __func__)); - /* Control data already received in aligned rxctl */ - if ((bus->bus == SPI_BUS) && (!bus->usebufpool)) - goto gotpkt; - /* Set rxctl for frame (w/optional alignment) */ bus->rxctl = bus->rxbuf; if (brcmf_alignctl) { @@ -3503,12 +3454,6 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) if (len <= firstread) goto gotpkt; - /* Copy the full data pkt in gSPI case and process ioctl. */ - if (bus->bus == SPI_BUS) { - memcpy(bus->rxctl, hdr, len); - goto gotpkt; - } - /* Raise rdlen to next SDIO block to avoid tail command */ rdlen = len - firstread; if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { @@ -4039,26 +3984,22 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) u16 nextlen = bus->nextlen; bus->nextlen = 0; - if (bus->bus == SPI_BUS) { - rdlen = len = nextlen; - } else { - rdlen = len = nextlen << 4; + rdlen = len = nextlen << 4; - /* Pad read to blocksize for efficiency */ - if (bus->roundup && bus->blocksize - && (rdlen > bus->blocksize)) { - pad = - bus->blocksize - - (rdlen % bus->blocksize); - if ((pad <= bus->roundup) - && (pad < bus->blocksize) - && ((rdlen + pad + firstread) < - MAX_RX_DATASZ)) - rdlen += pad; - } else if (rdlen % BRCMF_SDALIGN) { - rdlen += BRCMF_SDALIGN - - (rdlen % BRCMF_SDALIGN); - } + /* Pad read to blocksize for efficiency */ + if (bus->roundup && bus->blocksize + && (rdlen > bus->blocksize)) { + pad = + bus->blocksize - + (rdlen % bus->blocksize); + if ((pad <= bus->roundup) + && (pad < bus->blocksize) + && ((rdlen + pad + firstread) < + MAX_RX_DATASZ)) + rdlen += pad; + } else if (rdlen % BRCMF_SDALIGN) { + rdlen += BRCMF_SDALIGN - + (rdlen % BRCMF_SDALIGN); } /* We use bus->rxctl buffer in WinXP for initial @@ -4074,60 +4015,15 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Allocate a packet buffer */ pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN); if (!pkt) { - if (bus->bus == SPI_BUS) { - bus->usebufpool = false; - bus->rxctl = bus->rxbuf; - if (brcmf_alignctl) { - bus->rxctl += firstread; - pad = ((unsigned long)bus->rxctl - % BRCMF_SDALIGN); - if (pad) - bus->rxctl += - (BRCMF_SDALIGN - pad); - bus->rxctl -= firstread; - } - rxbuf = bus->rxctl; - /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf( - bus->sdiodev, - brcmf_sdcard_cur_sbwad( - bus->sdiodev), - SDIO_FUNC_2, F2SYNC, - rxbuf, rdlen, - NULL, NULL, NULL); - bus->f2rxdata++; - - /* Control frame failures need - retransmission */ - if (sdret < 0) { - BRCMF_ERROR(("%s: read %d " - "control bytes " - "failed: %d\n", - __func__, - rdlen, sdret)); - /* dhd.rx_ctlerrs is higher */ - bus->rxc_errors++; - brcmf_sdbrcm_rxfail(bus, true, - (bus->bus == - SPI_BUS) ? false - : true); - continue; - } - } else { - /* Give up on data, - request rtx of events */ - BRCMF_ERROR(("%s (nextlen): " - "brcmu_pkt_buf_get_skb " - "failed:" - " len %d rdlen %d expected" - " rxseq %d\n", __func__, - len, rdlen, rxseq)); - continue; - } + /* Give up on data, request rtx of events */ + BRCMF_ERROR(("%s (nextlen): " + "brcmu_pkt_buf_get_skb " + "failed:" + " len %d rdlen %d expected" + " rxseq %d\n", __func__, + len, rdlen, rxseq)); + continue; } else { - if (bus->bus == SPI_BUS) - bus->usebufpool = true; - PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); rxbuf = (u8 *) (pkt->data); /* Read the entire frame */ @@ -4149,10 +4045,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) * Don't attempt NAK for * gSPI */ - brcmf_sdbrcm_rxfail(bus, true, - (bus->bus == - SPI_BUS) ? false : - true); + brcmf_sdbrcm_rxfail(bus, true, true); continue; } } @@ -4202,8 +4095,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) "expected rxseq %d\n", __func__, nextlen, len, roundup(len, 16), rxseq)); - brcmf_sdbrcm_rxfail(bus, true, - bus->bus != SPI_BUS); + brcmf_sdbrcm_rxfail(bus, true, true); brcmf_sdbrcm_pktfree2(bus, pkt); continue; } @@ -4275,29 +4167,16 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) #endif if (chan == SDPCM_CONTROL_CHANNEL) { - if (bus->bus == SPI_BUS) { - brcmf_sdbrcm_read_control(bus, rxbuf, - len, doff); - } else { - BRCMF_ERROR(("%s (nextlen): readahead" - " on control packet %d?\n", - __func__, seq)); - /* Force retry w/normal header read */ - bus->nextlen = 0; - brcmf_sdbrcm_rxfail(bus, false, true); - } + BRCMF_ERROR(("%s (nextlen): readahead" + " on control packet %d?\n", + __func__, seq)); + /* Force retry w/normal header read */ + bus->nextlen = 0; + brcmf_sdbrcm_rxfail(bus, false, true); brcmf_sdbrcm_pktfree2(bus, pkt); continue; } - if ((bus->bus == SPI_BUS) && !bus->usebufpool) { - BRCMF_ERROR(("Received %d bytes on %d channel." - " Running out of " "rx pktbuf's or" - " not yet malloced.\n", - len, chan)); - continue; - } - /* Validate data offset */ if ((doff < SDPCM_HDRLEN) || (doff > len)) { BRCMF_ERROR(("%s (nextlen): bad data offset %d:" @@ -4311,9 +4190,6 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* All done with this one -- now deliver the packet */ goto deliver; } - /* gSPI frames should not be handled in fractions */ - if (bus->bus == SPI_BUS) - break; /* Read frame header (hardware and software) */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, @@ -5384,7 +5260,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, brcmf_txbound = BRCMF_TXBOUND; brcmf_rxbound = BRCMF_RXBOUND; brcmf_alignctl = true; - sd1idle = true; brcmf_readahead = true; retrydata = false; brcmf_dongle_memsize = 0; @@ -5408,7 +5283,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, } bus->sdiodev = sdiodev; sdiodev->bus = bus; - bus->bus = BRCMF_BUS; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ @@ -5578,22 +5452,20 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) brcmf_sdbrcm_sdiod_drive_strength_init(bus, brcmf_sdiod_drive_strength); /* Get info on the ARM and SOCRAM cores... */ - if (!BRCMF_NOPMU(bus)) { - brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->armcorebase, sbidhigh), 4); - bus->orig_ramsize = bus->ci->ramsize; - if (!(bus->orig_ramsize)) { - BRCMF_ERROR(("%s: failed to find SOCRAM memory!\n", - __func__)); - goto fail; - } - bus->ramsize = bus->orig_ramsize; - if (brcmf_dongle_memsize) - brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); - - BRCMF_ERROR(("DHD: dongle ram size is set to %d(orig %d)\n", - bus->ramsize, bus->orig_ramsize)); + brcmf_sdcard_reg_read(bus->sdiodev, + CORE_SB(bus->ci->armcorebase, sbidhigh), 4); + bus->orig_ramsize = bus->ci->ramsize; + if (!(bus->orig_ramsize)) { + BRCMF_ERROR(("%s: failed to find SOCRAM memory!\n", + __func__)); + goto fail; } + bus->ramsize = bus->orig_ramsize; + if (brcmf_dongle_memsize) + brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); + + BRCMF_ERROR(("DHD: dongle ram size is set to %d(orig %d)\n", + bus->ramsize, bus->orig_ramsize)); /* Set core control so an SDIO reset does a backplane reset */ reg_addr = bus->ci->buscorebase + From 2eb55852cf0cf966f977cf5afab78f1321b06c1a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:58 +0200 Subject: [PATCH 0115/1519] staging: brcm80211: remove wrapper functions in bcmsdh_sdmmc.c Use brcmf_sdioh_request_byte directly instead of calling brcmf_sdioh_cfg_read and brcmf_sdioh_cfg_write in brcmfmac Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 18 +++++++-------- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 22 ------------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 5 ----- 3 files changed, 8 insertions(+), 37 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 8bb84a98566..824208fbbea 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -130,8 +130,8 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, (struct brcmf_sdreg *) params; u8 data = 0; - if (brcmf_sdioh_cfg_read - (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { + if (brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, + sd_ptr->func, sd_ptr->offset, &data)) { bcmerror = -EIO; break; } @@ -147,8 +147,8 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, (struct brcmf_sdreg *) params; u8 data = (u8) sd_ptr->value; - if (brcmf_sdioh_cfg_write - (sdiodev, sd_ptr->func, sd_ptr->offset, &data)) { + if (brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, + sd_ptr->func, sd_ptr->offset, &data)) { bcmerror = -EIO; break; } @@ -209,9 +209,8 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, do { if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); - status = - brcmf_sdioh_cfg_read(sdiodev, fnc_num, addr, - (u8 *) &data); + status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num, + addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); if (err) @@ -233,9 +232,8 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, do { if (retry) /* wait for 1 ms till bus get settled down */ udelay(1000); - status = - brcmf_sdioh_cfg_write(sdiodev, fnc_num, addr, - (u8 *) &data); + status = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, fnc_num, + addr, (u8 *) &data); } while (status != 0 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); if (err) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index d7648f867c9..fca966cd30f 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -190,28 +190,6 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) } -extern int -brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, - u8 *data) -{ - int status; - /* No lock needed since brcmf_sdioh_request_byte does locking */ - status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num, - addr, data); - return status; -} - -extern int -brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, - u8 *data) -{ - /* No lock needed since brcmf_sdioh_request_byte does locking */ - int status; - status = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, fnc_num, - addr, data); - return status; -} - static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) { /* read 24 bits and return valid 17 bit addr */ diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 555f17bab9a..dc588e71c8f 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -268,11 +268,6 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, extern int brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint fuc, u8 *cis, u32 length); -extern int brcmf_sdioh_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fuc, - u32 addr, u8 *data); -extern int brcmf_sdioh_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fuc, - u32 addr, u8 *data); - /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable); From d58bdd3f92a936d3ba58321aedd23da840644e20 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:34:59 +0200 Subject: [PATCH 0116/1519] staging: brcm80211: remove unused parameter from data interface in fullmac Remove redundant complete function pointer in send/recv buffer interface. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 10 ++---- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 31 +++++++------------ .../staging/brcm80211/brcmfmac/sdio_host.h | 10 ++---- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 824208fbbea..0c845c945f2 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -385,10 +385,7 @@ bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev) int brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle) + u8 *buf, uint nbytes, struct sk_buff *pkt) { int status; uint incr_fix; @@ -426,10 +423,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, int brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, void *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle) + uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt) { uint incr_fix; uint width; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index cd58ef847aa..8cd84c5de1b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -941,10 +941,7 @@ static uint brcmf_process_nvram_vars(char *varbuf, uint len); static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size); static int brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, - struct sk_buff *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle); + struct sk_buff *pkt); static bool brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus, void *card); static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus); @@ -1413,7 +1410,7 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, do { ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(bus->sdiodev), - SDIO_FUNC_2, F2SYNC, frame, len, pkt, NULL, NULL); + SDIO_FUNC_2, F2SYNC, frame, len, pkt); bus->f2txdata++; if (ret < 0) { @@ -1731,7 +1728,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, - F2SYNC, frame, len, NULL, NULL, NULL); + F2SYNC, frame, len, NULL); if (ret < 0) { /* On failure, abort the command and @@ -3493,7 +3490,7 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (bus->rxctl + firstread), rdlen, - NULL, NULL, NULL); + NULL); bus->f2rxdata++; /* Control frame failures need retransmission */ @@ -3657,13 +3654,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (u8 *) pfirst->data, dlen, - pfirst, NULL, NULL); + pfirst); } else if (bus->dataptr) { errcode = brcmf_sdcard_recv_buf(bus->sdiodev, brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, bus->dataptr, dlen, - NULL, NULL, NULL); + NULL); sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, bus->dataptr); if (sublen != dlen) { @@ -4032,7 +4029,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->sdiodev), SDIO_FUNC_2, F2SYNC, rxbuf, rdlen, - pkt, NULL, NULL); + pkt); bus->f2rxdata++; if (sdret < 0) { @@ -4195,7 +4192,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) sdret = brcmf_sdcard_recv_buf(bus->sdiodev, brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread, - NULL, NULL, NULL); + NULL); bus->f2rxhdrs++; if (sdret < 0) { @@ -4352,7 +4349,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) sdret = brcmf_sdcard_recv_buf(bus->sdiodev, brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), - rdlen, pkt, NULL, NULL); + rdlen, pkt); bus->f2rxdata++; if (sdret < 0) { @@ -4689,7 +4686,7 @@ clkwait: ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(bus->sdiodev), SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, - (u32) bus->ctrl_frame_len, NULL, NULL, NULL); + (u32) bus->ctrl_frame_len, NULL); if (ret < 0) { /* On failure, abort the command and @@ -5885,14 +5882,10 @@ err: static int brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle) + u8 *buf, uint nbytes, struct sk_buff *pkt) { return brcmf_sdcard_send_buf - (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt, complete, - handle); + (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt); } int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index dc588e71c8f..03ae16aac32 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -188,16 +188,10 @@ extern bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev); */ extern int brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, void *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle); + uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); extern int brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt, - void (*complete)(void *handle, int status, - bool sync_waiting), - void *handle); + uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); /* Flags bits */ From 5179bd96961f726a4d519807c3bec1eb98ca807d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:35:00 +0200 Subject: [PATCH 0117/1519] staging: brcm80211: remove dead SDTEST code from fullmac Remove legacy dead code of SDTEST Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 37 -- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 455 +----------------- 2 files changed, 1 insertion(+), 491 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index cd1b90da126..ae8a9a6807e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -672,15 +672,6 @@ extern uint brcmf_radio_up; /* Override to force tx queueing all the time */ extern uint brcmf_force_tx_queueing; -#ifdef SDTEST -/* Echo packet generator (SDIO), pkts/s */ -extern uint brcmf_pktgen; - -/* Echo packet len (0 => sawtooth, max 1800) */ -extern uint brcmf_pktgen_len; -#define BRCMF_MAX_PKTGEN_LEN 1800 -#endif - extern const struct bcmevent_name bcmevent_names[]; extern const int bcmevent_names_size; @@ -823,34 +814,6 @@ struct brcmf_c_ioctl { #define BRCMF_BTA_VAL 0x1000 #define BRCMF_ISCAN_VAL 0x2000 -#ifdef SDTEST -/* For pktgen iovar */ -struct brcmf_pktgen { - uint version; /* To allow structure change tracking */ - uint freq; /* Max ticks between tx/rx attempts */ - uint count; /* Test packets to send/rcv each attempt */ - uint print; /* Print counts every attempts */ - uint total; /* Total packets (or bursts) */ - uint minlen; /* Minimum length of packets to send */ - uint maxlen; /* Maximum length of packets to send */ - uint numsent; /* Count of test packets sent */ - uint numrcvd; /* Count of test packets received */ - uint numfail; /* Count of test send failures */ - uint mode; /* Test mode (type of test packets) */ - uint stop; /* Stop after this many tx failures */ -}; - -/* Version in case structure changes */ -#define BRCMF_PKTGEN_VERSION 2 - -/* Type of test packets to use */ -#define BRCMF_PKTGEN_ECHO 1 /* Send echo requests */ -#define BRCMF_PKTGEN_SEND 2 /* Send discard packets */ -#define BRCMF_PKTGEN_RXBURST 3 /* Request dongle send N packets */ -#define BRCMF_PKTGEN_RECV 4 /* Continuous rx from continuous - tx dongle */ -#endif /* SDTEST */ - /* Enter idle immediately (no timeout) */ #define BRCMF_IDLE_IMMEDIATE (-1) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8cd84c5de1b..a9d661c2fd4 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -251,11 +251,7 @@ struct rte_console { /* Total length of frame header for dongle protocol */ #define SDPCM_HDRLEN (SDPCM_FRAMETAG_LEN + SDPCM_SWHEADER_LEN) -#ifdef SDTEST -#define SDPCM_RESERVE (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + BRCMF_SDALIGN) -#else #define SDPCM_RESERVE (SDPCM_HDRLEN + BRCMF_SDALIGN) -#endif /* * Software allocation of To SB Mailbox resources @@ -661,30 +657,6 @@ struct brcmf_bus { /* Field to decide if rx of control frames happen in rxbuf or lb-pool */ bool usebufpool; -#ifdef SDTEST - /* external loopback */ - bool ext_loop; - u8 loopid; - - /* pktgen configuration */ - uint pktgen_freq; /* Ticks between bursts */ - uint pktgen_count; /* Packets to send each burst */ - uint pktgen_print; /* Bursts between count displays */ - uint pktgen_total; /* Stop after this many */ - uint pktgen_minlen; /* Minimum packet data len */ - uint pktgen_maxlen; /* Maximum packet data len */ - uint pktgen_mode; /* Configured mode: tx, rx, or echo */ - uint pktgen_stop; /* Number of tx failures causing stop */ - - /* active pktgen fields */ - uint pktgen_tick; /* Tick counter for bursts */ - uint pktgen_ptick; /* Burst counter for printing */ - uint pktgen_sent; /* Number of test packets generated */ - uint pktgen_rcvd; /* Number of test packets received */ - uint pktgen_fail; /* Number of failed send attempts */ - u16 pktgen_len; /* Length of next packet to send */ -#endif /* SDTEST */ - /* Some additional counters */ uint tx_sderrs; /* Count of tx attempts with sd errors */ uint fcqueued; /* Tx packets that got queued */ @@ -915,11 +887,6 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) #define HOSTINTMASK (I_HMB_SW_MASK | I_CHIPACTIVE) -#ifdef SDTEST -static void brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, void *pkt, uint seq); -static void brcmf_sdbrcm_sdtest_set(struct brcmf_bus *bus, bool start); -#endif - #ifdef BCMDBG static int brcmf_sdbrcm_bus_console_in(struct brcmf_pub *drvr, unsigned char *msg, uint msglen); @@ -1469,20 +1436,6 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) datalen = pkt->len; -#ifdef SDTEST - /* Push the test header if doing loopback */ - if (bus->ext_loop) { - u8 *data; - skb_push(pkt, SDPCM_TEST_HDRLEN); - data = pkt->data; - *data++ = SDPCM_TEST_ECHOREQ; - *data++ = (u8) bus->loopid++; - *data++ = (datalen >> 0); - *data++ = (datalen >> 8); - datalen += SDPCM_TEST_HDRLEN; - } -#endif /* SDTEST */ - /* Add space for the header */ skb_push(pkt, SDPCM_HDRLEN); /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ @@ -1534,14 +1487,8 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) /* Make sure back plane ht clk is on, no pending allowed */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); -#ifndef SDTEST BRCMF_TRACE(("%s: calling txpkt\n", __func__)); ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); -#else - ret = brcmf_sdbrcm_txpkt(bus, pkt, - (bus->ext_loop ? SDPCM_TEST_CHANNEL : - SDPCM_DATA_CHANNEL), true); -#endif if (ret) bus->drvr->tx_errors++; else @@ -1586,13 +1533,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) spin_unlock_bh(&bus->txqlock); datalen = pkt->len - SDPCM_HDRLEN; -#ifndef SDTEST ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); -#else - ret = brcmf_sdbrcm_txpkt(bus, pkt, - (bus->ext_loop ? SDPCM_TEST_CHANNEL : - SDPCM_DATA_CHANNEL), true); -#endif if (ret) bus->drvr->tx_errors++; else @@ -1857,10 +1798,6 @@ enum { IOV_ALIGNCTL, IOV_SDALIGN, IOV_DEVRESET, -#ifdef SDTEST - IOV_PKTGEN, - IOV_EXTLOOP, -#endif /* SDTEST */ IOV_TXBOUND, IOV_RXBOUND, IOV_TXMINMAX, @@ -1912,12 +1849,6 @@ const struct brcmu_iovar brcmf_sdio_iovars[] = { {"checkdied", IOV_CHECKDIED, 0, IOVT_BUFFER, 0} , #endif /* BCMDBG */ -#ifdef SDTEST - {"extloop", IOV_EXTLOOP, 0, IOVT_BOOL, 0} - , - {"pktgen", IOV_PKTGEN, 0, IOVT_BUFFER, sizeof(struct brcmf_pktgen)} - , -#endif /* SDTEST */ {NULL, 0, 0, 0, 0} }; @@ -2011,19 +1942,6 @@ void brcmf_sdbrcm_bus_dump(struct brcmf_pub *drvr, struct brcmu_strbuf *strbuf) brcmu_bprintf(strbuf, "\n\n"); } -#ifdef SDTEST - if (bus->pktgen_count) { - brcmu_bprintf(strbuf, "pktgen config and count:\n"); - brcmu_bprintf(strbuf, - "freq %d count %d print %d total %d min %d len %d\n", - bus->pktgen_freq, bus->pktgen_count, - bus->pktgen_print, bus->pktgen_total, - bus->pktgen_minlen, bus->pktgen_maxlen); - brcmu_bprintf(strbuf, "send attempts %d rcvd %d fail %d\n", - bus->pktgen_sent, bus->pktgen_rcvd, - bus->pktgen_fail); - } -#endif /* SDTEST */ #ifdef BCMDBG brcmu_bprintf(strbuf, "dpc_sched %d host interrupt%spending\n", bus->dpc_sched, " not "); @@ -2048,62 +1966,6 @@ void brcmf_bus_clearcounts(struct brcmf_pub *drvr) bus->f2rxhdrs = bus->f2rxdata = bus->f2txdata = bus->f1regdata = 0; } -#ifdef SDTEST -static int brcmf_sdbrcm_pktgen_get(struct brcmf_bus *bus, u8 *arg) -{ - struct brcmf_pktgen pktgen; - - pktgen.version = BRCMF_PKTGEN_VERSION; - pktgen.freq = bus->pktgen_freq; - pktgen.count = bus->pktgen_count; - pktgen.print = bus->pktgen_print; - pktgen.total = bus->pktgen_total; - pktgen.minlen = bus->pktgen_minlen; - pktgen.maxlen = bus->pktgen_maxlen; - pktgen.numsent = bus->pktgen_sent; - pktgen.numrcvd = bus->pktgen_rcvd; - pktgen.numfail = bus->pktgen_fail; - pktgen.mode = bus->pktgen_mode; - pktgen.stop = bus->pktgen_stop; - - memcpy(arg, &pktgen, sizeof(pktgen)); - - return 0; -} - -static int brcmf_sdbrcm_pktgen_set(struct brcmf_bus *bus, u8 *arg) -{ - struct brcmf_pktgen pktgen; - uint oldcnt, oldmode; - - memcpy(&pktgen, arg, sizeof(pktgen)); - if (pktgen.version != BRCMF_PKTGEN_VERSION) - return -EINVAL; - - oldcnt = bus->pktgen_count; - oldmode = bus->pktgen_mode; - - bus->pktgen_freq = pktgen.freq; - bus->pktgen_count = pktgen.count; - bus->pktgen_print = pktgen.print; - bus->pktgen_total = pktgen.total; - bus->pktgen_minlen = pktgen.minlen; - bus->pktgen_maxlen = pktgen.maxlen; - bus->pktgen_mode = pktgen.mode; - bus->pktgen_stop = pktgen.stop; - - bus->pktgen_tick = bus->pktgen_ptick = 0; - bus->pktgen_len = max(bus->pktgen_len, bus->pktgen_minlen); - bus->pktgen_len = min(bus->pktgen_len, bus->pktgen_maxlen); - - /* Clear counts for a new pktgen (mode change, or was stopped) */ - if (bus->pktgen_count && (!oldcnt || oldmode != bus->pktgen_mode)) - bus->pktgen_sent = bus->pktgen_rcvd = bus->pktgen_fail = 0; - - return 0; -} -#endif /* SDTEST */ - static int brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, uint size) @@ -2858,25 +2720,6 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, break; #endif /* BCMDBG */ -#ifdef SDTEST - case IOV_GVAL(IOV_EXTLOOP): - int_val = (s32) bus->ext_loop; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_EXTLOOP): - bus->ext_loop = bool_val; - break; - - case IOV_GVAL(IOV_PKTGEN): - bcmerror = brcmf_sdbrcm_pktgen_get(bus, arg); - break; - - case IOV_SVAL(IOV_PKTGEN): - bcmerror = brcmf_sdbrcm_pktgen_set(bus, arg); - break; -#endif /* SDTEST */ - case IOV_SVAL(IOV_DEVRESET): BRCMF_TRACE(("%s: Called set IOV_DEVRESET=%d dongle_reset=%d " "busstate=%d\n", @@ -3943,20 +3786,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) int ifidx = 0; uint rxcount = 0; /* Total frames read */ -#if defined(BCMDBG) || defined(SDTEST) - bool sdtest = false; /* To limit message spew from test mode */ -#endif - BRCMF_TRACE(("%s: Enter\n", __func__)); -#ifdef SDTEST - /* Allow pktgen to override maxframes */ - if (bus->pktgen_count && (bus->pktgen_mode == BRCMF_PKTGEN_RECV)) { - maxframes = bus->pktgen_count; - sdtest = true; - } -#endif - /* Not finished unless we encounter no more frames indication */ *finished = false; @@ -4405,14 +4236,6 @@ deliver: __skb_trim(pkt, len); skb_pull(pkt, doff); -#ifdef SDTEST - /* Test channel packets are processed separately */ - if (chan == SDPCM_TEST_CHANNEL) { - brcmf_sdbrcm_checkdied(bus, pkt, seq); - continue; - } -#endif /* SDTEST */ - if (pkt->len == 0) { brcmu_pkt_buf_free_skb(pkt); continue; @@ -4431,7 +4254,7 @@ deliver: rxcount = maxframes - rxleft; #ifdef BCMDBG /* Message if we hit the limit */ - if (!rxleft && !sdtest) + if (!rxleft) BRCMF_DATA(("%s: hit rx limit of %d frames\n", __func__, maxframes)); else @@ -4810,268 +4633,6 @@ void brcmf_sdbrcm_isr(void *arg) } -#ifdef SDTEST -static void brcmf_sdbrcm_pktgen_init(struct brcmf_bus *bus) -{ - /* Default to specified length, or full range */ - if (brcmf_pktgen_len) { - bus->pktgen_maxlen = min(brcmf_pktgen_len, - BRCMF_MAX_PKTGEN_LEN); - bus->pktgen_minlen = bus->pktgen_maxlen; - } else { - bus->pktgen_maxlen = BRCMF_MAX_PKTGEN_LEN; - bus->pktgen_minlen = 0; - } - bus->pktgen_len = (u16) bus->pktgen_minlen; - - /* Default to per-watchdog burst with 10s print time */ - bus->pktgen_freq = 1; - bus->pktgen_print = 10000 / brcmf_watchdog_ms; - bus->pktgen_count = (brcmf_pktgen * brcmf_watchdog_ms + 999) / 1000; - - /* Default to echo mode */ - bus->pktgen_mode = BRCMF_PKTGEN_ECHO; - bus->pktgen_stop = 1; -} - -static void brcmf_sdbrcm_pktgen(struct brcmf_bus *bus) -{ - struct sk_buff *pkt; - u8 *data; - uint pktcount; - uint fillbyte; - u16 len; - - /* Display current count if appropriate */ - if (bus->pktgen_print && (++bus->pktgen_ptick >= bus->pktgen_print)) { - bus->pktgen_ptick = 0; - printk(KERN_DEBUG "%s: send attempts %d rcvd %d\n", - __func__, bus->pktgen_sent, bus->pktgen_rcvd); - } - - /* For recv mode, just make sure dongle has started sending */ - if (bus->pktgen_mode == BRCMF_PKTGEN_RECV) { - if (!bus->pktgen_rcvd) - brcmf_sdbrcm_sdtest_set(bus, true); - return; - } - - /* Otherwise, generate or request the specified number of packets */ - for (pktcount = 0; pktcount < bus->pktgen_count; pktcount++) { - /* Stop if total has been reached */ - if (bus->pktgen_total - && (bus->pktgen_sent >= bus->pktgen_total)) { - bus->pktgen_count = 0; - break; - } - - /* Allocate an appropriate-sized packet */ - len = bus->pktgen_len; - pkt = brcmu_pkt_buf_get_skb( - len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + BRCMF_SDALIGN, - true); - if (!pkt) { - BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed!\n", - __func__)); - break; - } - PKTALIGN(pkt, (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), - BRCMF_SDALIGN); - data = (u8 *) (pkt->data) + SDPCM_HDRLEN; - - /* Write test header cmd and extra based on mode */ - switch (bus->pktgen_mode) { - case BRCMF_PKTGEN_ECHO: - *data++ = SDPCM_TEST_ECHOREQ; - *data++ = (u8) bus->pktgen_sent; - break; - - case BRCMF_PKTGEN_SEND: - *data++ = SDPCM_TEST_DISCARD; - *data++ = (u8) bus->pktgen_sent; - break; - - case BRCMF_PKTGEN_RXBURST: - *data++ = SDPCM_TEST_BURST; - *data++ = (u8) bus->pktgen_count; - break; - - default: - BRCMF_ERROR(("Unrecognized pktgen mode %d\n", - bus->pktgen_mode)); - brcmu_pkt_buf_free_skb(pkt, true); - bus->pktgen_count = 0; - return; - } - - /* Write test header length field */ - *data++ = (len >> 0); - *data++ = (len >> 8); - - /* Then fill in the remainder -- N/A for burst, - but who cares... */ - for (fillbyte = 0; fillbyte < len; fillbyte++) - *data++ = - SDPCM_TEST_FILL(fillbyte, (u8) bus->pktgen_sent); - -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - data = (u8 *) (pkt->data) + SDPCM_HDRLEN; - printk(KERN_DEBUG "brcmf_sdbrcm_pktgen: Tx Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, - pkt->len - SDPCM_HDRLEN); - } -#endif - - /* Send it */ - if (brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_TEST_CHANNEL, true)) { - bus->pktgen_fail++; - if (bus->pktgen_stop - && bus->pktgen_stop == bus->pktgen_fail) - bus->pktgen_count = 0; - } - bus->pktgen_sent++; - - /* Bump length if not fixed, wrap at max */ - if (++bus->pktgen_len > bus->pktgen_maxlen) - bus->pktgen_len = (u16) bus->pktgen_minlen; - - /* Special case for burst mode: just send one request! */ - if (bus->pktgen_mode == BRCMF_PKTGEN_RXBURST) - break; - } -} - -static void brcmf_sdbrcm_sdtest_set(struct brcmf_bus *bus, bool start) -{ - struct sk_buff *pkt; - u8 *data; - - /* Allocate the packet */ - pkt = brcmu_pkt_buf_get_skb(SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + - BRCMF_SDALIGN, true); - if (!pkt) { - BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed!\n", __func__)); - return; - } - PKTALIGN(pkt, (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), BRCMF_SDALIGN); - data = (u8 *) (pkt->data) + SDPCM_HDRLEN; - - /* Fill in the test header */ - *data++ = SDPCM_TEST_SEND; - *data++ = start; - *data++ = (bus->pktgen_maxlen >> 0); - *data++ = (bus->pktgen_maxlen >> 8); - - /* Send it */ - if (brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_TEST_CHANNEL, true)) - bus->pktgen_fail++; -} - -static void -brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, struct sk_buff *pkt, uint seq) -{ - u8 *data; - uint pktlen; - - u8 cmd; - u8 extra; - u16 len; - u16 offset; - - /* Check for min length */ - pktlen = pkt->len; - if (pktlen < SDPCM_TEST_HDRLEN) { - BRCMF_ERROR(("brcmf_sdbrcm_checkdied: toss runt frame, pktlen " - "%d\n", pktlen)); - brcmu_pkt_buf_free_skb(pkt, false); - return; - } - - /* Extract header fields */ - data = pkt->data; - cmd = *data++; - extra = *data++; - len = *data++; - len += *data++ << 8; - - /* Check length for relevant commands */ - if (cmd == SDPCM_TEST_DISCARD || cmd == SDPCM_TEST_ECHOREQ - || cmd == SDPCM_TEST_ECHORSP) { - if (pktlen != len + SDPCM_TEST_HDRLEN) { - BRCMF_ERROR(("brcmf_sdbrcm_checkdied: frame length " - "mismatch, pktlen %d seq %d" - " cmd %d extra %d len %d\n", - pktlen, seq, cmd, extra, len)); - brcmu_pkt_buf_free_skb(pkt, false); - return; - } - } - - /* Process as per command */ - switch (cmd) { - case SDPCM_TEST_ECHOREQ: - /* Rx->Tx turnaround ok (even on NDIS w/current - implementation) */ - *(u8 *) (pkt->data) = SDPCM_TEST_ECHORSP; - if (brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_TEST_CHANNEL, true) == 0) - bus->pktgen_sent++; - else { - bus->pktgen_fail++; - brcmu_pkt_buf_free_skb(pkt, false); - } - bus->pktgen_rcvd++; - break; - - case SDPCM_TEST_ECHORSP: - if (bus->ext_loop) { - brcmu_pkt_buf_free_skb(pkt, false); - bus->pktgen_rcvd++; - break; - } - - for (offset = 0; offset < len; offset++, data++) { - if (*data != SDPCM_TEST_FILL(offset, extra)) { - BRCMF_ERROR(("brcmf_sdbrcm_checkdied: echo" - " data mismatch: " - "offset %d (len %d) " - "expect 0x%02x rcvd 0x%02x\n", - offset, len, - SDPCM_TEST_FILL(offset, extra), - *data)); - break; - } - } - brcmu_pkt_buf_free_skb(pkt, false); - bus->pktgen_rcvd++; - break; - - case SDPCM_TEST_DISCARD: - brcmu_pkt_buf_free_skb(pkt, false); - bus->pktgen_rcvd++; - break; - - case SDPCM_TEST_BURST: - case SDPCM_TEST_SEND: - default: - BRCMF_INFO(("brcmf_sdbrcm_checkdied: unsupported or unknown " - "command, pktlen %d seq %d" " cmd %d extra %d" - " len %d\n", pktlen, seq, cmd, extra, len)); - brcmu_pkt_buf_free_skb(pkt, false); - break; - } - - /* For recv mode, stop at limie (and tell dongle to stop sending) */ - if (bus->pktgen_mode == BRCMF_PKTGEN_RECV) { - if (bus->pktgen_total - && (bus->pktgen_rcvd >= bus->pktgen_total)) { - bus->pktgen_count = 0; - brcmf_sdbrcm_sdtest_set(bus, false); - } - } -} -#endif /* SDTEST */ - extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) { struct brcmf_bus *bus; @@ -5139,16 +4700,6 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) } #endif /* BCMDBG */ -#ifdef SDTEST - /* Generate packets if configured */ - if (bus->pktgen_count && (++bus->pktgen_tick >= bus->pktgen_freq)) { - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - bus->pktgen_tick = 0; - brcmf_sdbrcm_pktgen(bus); - } -#endif - /* On idle timeout clear activity flag and/or turn off clock */ if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { if (++bus->idlecount >= bus->idletime) { @@ -5533,10 +5084,6 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) { BRCMF_TRACE(("%s: Enter\n", __func__)); -#ifdef SDTEST - brcmf_sdbrcm_pktgen_init(bus); -#endif /* SDTEST */ - /* Disable F2 to clear any intermediate frame state on the dongle */ brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); From cdf853c05ddf17c55a7d9079c77356b41daf12f1 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 12 Aug 2011 15:35:01 +0200 Subject: [PATCH 0118/1519] staging: brcm80211: remove unused func parameter in wl_cfg80211 of fullmac Get rid of some unused void *data parameter Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index def1f777f0c..6c604cf627d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -117,7 +117,7 @@ static void brcmf_init_eloop_handler(struct brcmf_cfg80211_event_loop *el); static struct brcmf_cfg80211_event_q * brcmf_deq_event(struct brcmf_cfg80211_priv *cfg_priv); static s32 brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 type, - const struct brcmf_event_msg *msg, void *data); + const struct brcmf_event_msg *msg); static void brcmf_put_event(struct brcmf_cfg80211_event_q *e); static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv); static s32 brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, @@ -134,11 +134,11 @@ static s32 brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, void *data); static s32 brcmf_bss_connect_done(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, - const struct brcmf_event_msg *e, void *data, + const struct brcmf_event_msg *e, bool completed); static s32 brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, - const struct brcmf_event_msg *e, void *data); + const struct brcmf_event_msg *e); static s32 brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, const struct brcmf_event_msg *e, void *data); @@ -2631,7 +2631,7 @@ brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); } else - brcmf_bss_connect_done(cfg_priv, ndev, e, data, true); + brcmf_bss_connect_done(cfg_priv, ndev, e, true); } else if (brcmf_is_linkdown(cfg_priv, e)) { WL_CONN("Linkdown\n"); if (brcmf_is_ibssmode(cfg_priv)) { @@ -2640,7 +2640,7 @@ brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, &cfg_priv->status)) brcmf_link_down(cfg_priv); } else { - brcmf_bss_connect_done(cfg_priv, ndev, e, data, false); + brcmf_bss_connect_done(cfg_priv, ndev, e, false); if (test_and_clear_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { cfg80211_disconnected(ndev, 0, NULL, 0, @@ -2653,7 +2653,7 @@ brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, if (brcmf_is_ibssmode(cfg_priv)) clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); else - brcmf_bss_connect_done(cfg_priv, ndev, e, data, false); + brcmf_bss_connect_done(cfg_priv, ndev, e, false); } return err; @@ -2670,9 +2670,9 @@ brcmf_notify_roaming_status(struct brcmf_cfg80211_priv *cfg_priv, if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) - brcmf_bss_roaming_done(cfg_priv, ndev, e, data); + brcmf_bss_roaming_done(cfg_priv, ndev, e); else - brcmf_bss_connect_done(cfg_priv, ndev, e, data, true); + brcmf_bss_connect_done(cfg_priv, ndev, e, true); } return err; @@ -2883,7 +2883,7 @@ update_bss_info_out: static s32 brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) + const struct brcmf_event_msg *e) { struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); @@ -2927,7 +2927,7 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, static s32 brcmf_bss_connect_done(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, const struct brcmf_event_msg *e, - void *data, bool completed) + bool completed) { struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); s32 err = 0; @@ -3587,7 +3587,7 @@ brcmf_cfg80211_event(struct net_device *ndev, u32 event_type = be32_to_cpu(e->event_type); struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - if (likely(!brcmf_enq_event(cfg_priv, event_type, e, data))) + if (likely(!brcmf_enq_event(cfg_priv, event_type, e))) brcmf_wakeup_event(cfg_priv); } @@ -3637,7 +3637,7 @@ static struct brcmf_cfg80211_event_q *brcmf_deq_event( static s32 brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, - const struct brcmf_event_msg *msg, void *data) + const struct brcmf_event_msg *msg) { struct brcmf_cfg80211_event_q *e; s32 err = 0; From a51e4478f515b8b5e23ace84086bcb32d0e8a5f6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 15 Aug 2011 15:34:13 +0200 Subject: [PATCH 0119/1519] staging: brcm80211: got rid of several void pointers for softmac PCI Code cleanup. Replace void * related to PCI functionality by less generic pointer types. Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 10 ++-- drivers/staging/brcm80211/brcmsmac/aiutils.h | 2 +- drivers/staging/brcm80211/brcmsmac/dma.c | 2 +- drivers/staging/brcm80211/brcmsmac/nicpci.c | 63 +++++++++----------- drivers/staging/brcm80211/brcmsmac/nicpci.h | 30 ++++++---- 5 files changed, 54 insertions(+), 53 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 3d392a3963f..c9c41a5327b 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1850,7 +1850,7 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return -1; slen = snprintf(path, (size_t) size, "pci/%u/%u/", - ((struct pci_dev *)((SI_INFO(sih))->pbus))->bus->number, + (((SI_INFO(sih))->pbus))->bus->number, PCI_SLOT(((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn)); if (slen < 0 || slen >= size) { @@ -2025,8 +2025,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) int ai_pci_fixcfg(struct si_pub *sih) { uint origidx; - struct sbpciregs *regs = NULL; - + void *regs = NULL; struct si_info *sii = SI_INFO(sih); /* Fixup PI in SROM shadow area to enable the correct PCI core access */ @@ -2035,7 +2034,10 @@ int ai_pci_fixcfg(struct si_pub *sih) /* check 'pi' is correct and fix it if not */ regs = ai_setcore(&sii->pub, sii->pub.buscoretype, 0); - pcicore_fixcfg(sii->pch, regs); + if (sii->pub.buscoretype == PCIE_CORE_ID) + pcicore_fixcfg_pcie(sii->pch, (struct sbpcieregs *)regs); + else if (sii->pub.buscoretype == PCI_CORE_ID) + pcicore_fixcfg_pci(sii->pch, (struct sbpciregs *)regs); /* restore the original index */ ai_setcoreidx(&sii->pub, origidx); diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 84c69013600..7ea42aff9bd 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -459,7 +459,7 @@ struct gpioh_item { /* misc si info needed by some of the routines */ struct si_info { struct si_pub pub; /* back plane public state (must be first) */ - void *pbus; /* handle to bus (pci/sdio/..) */ + struct pci_dev *pbus; /* handle to pci bus */ uint dev_coreid; /* the core provides driver functions */ void *intr_arg; /* interrupt callback function arg */ u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */ diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 64d7639d38e..10a25d23852 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -252,7 +252,7 @@ struct dma_info { uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ - void *pbus; /* bus handle */ + struct pci_dev *pbus; /* bus handle */ bool dma64; /* this dma engine is operating in 64-bit mode */ bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 8249ea910ba..2d46e701dd2 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -245,7 +245,8 @@ static void pcie_war_pci_setup(struct pcicore_info *pi); /* Initialize the PCI core. * It's caller's responsibility to make sure that this is done only once */ -void *pcicore_init(struct si_pub *sih, void *pdev, void *regs) +struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, + void *regs) { struct pcicore_info *pi; @@ -271,7 +272,7 @@ void *pcicore_init(struct si_pub *sih, void *pdev, void *regs) return pi; } -void pcicore_deinit(void *pch) +void pcicore_deinit(struct pcicore_info *pch) { kfree(pch); } @@ -279,7 +280,7 @@ void pcicore_deinit(void *pch) /* return cap_offset if requested capability exists in the PCI config space */ /* Note that it's caller's responsibility to make sure it's a pci bus */ u8 -pcicore_find_pci_capability(void *dev, u8 req_cap_id, +pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen) { u8 cap_id; @@ -484,9 +485,8 @@ pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint regaddr, uint val) } /* ***** Support functions ***** */ -static u8 pcie_clkreq(void *pch, u32 mask, u32 val) +static u8 pcie_clkreq(struct pcicore_info *pi, u32 mask, u32 val) { - struct pcicore_info *pi = pch; u32 reg_val; u8 offset; @@ -536,7 +536,7 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) switch (state) { case SI_DOATTACH: if (PCIE_ASPM(sih)) - pcie_clkreq((void *)pi, 1, 0); + pcie_clkreq(pi, 1, 0); break; case SI_PCIDOWN: if (sih->buscorerev == 6) { /* turn on serdes PLL down */ @@ -547,7 +547,7 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0); } else if (pi->pcie_pr42767) { - pcie_clkreq((void *)pi, 1, 1); + pcie_clkreq(pi, 1, 1); } break; case SI_PCIUP: @@ -559,7 +559,7 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0x40); } else if (PCIE_ASPM(sih)) { /* disable clkreq */ - pcie_clkreq((void *)pi, 1, 0); + pcie_clkreq(pi, 1, 0); } break; } @@ -729,9 +729,8 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) } /* ***** Functions called during driver state changes ***** */ -void pcicore_attach(void *pch, char *pvars, int state) +void pcicore_attach(struct pcicore_info *pi, char *pvars, int state) { - struct pcicore_info *pi = pch; struct si_pub *sih = pi->sih; /* Determine if this board needs override */ @@ -753,20 +752,16 @@ void pcicore_attach(void *pch, char *pvars, int state) } -void pcicore_hwup(void *pch) +void pcicore_hwup(struct pcicore_info *pi) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; pcie_war_pci_setup(pi); } -void pcicore_up(void *pch, int state) +void pcicore_up(struct pcicore_info *pi, int state) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; @@ -779,9 +774,8 @@ void pcicore_up(void *pch, int state) /* When the device is going to enter D3 state * (or the system is going to enter S3/S4 states) */ -void pcicore_sleep(void *pch) +void pcicore_sleep(struct pcicore_info *pi) { - struct pcicore_info *pi = pch; u32 w; if (!pi || !PCIE_ASPM(pi->sih)) @@ -794,10 +788,8 @@ void pcicore_sleep(void *pch) pi->pcie_pr42767 = false; } -void pcicore_down(void *pch, int state) +void pcicore_down(struct pcicore_info *pi, int state) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; @@ -808,21 +800,12 @@ void pcicore_down(void *pch, int state) } /* precondition: current core is sii->buscoretype */ -void pcicore_fixcfg(void *pch, void *regs) +static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16) { - struct pcicore_info *pi = pch; struct si_info *sii = SI_INFO(pi->sih); - struct sbpciregs *pciregs = regs; - struct sbpcieregs *pcieregs = regs; - u16 val16, *reg16 = NULL; + u16 val16; uint pciidx; - /* check 'pi' is correct and fix it if not */ - if (sii->pub.buscoretype == PCIE_CORE_ID) - reg16 = &pcieregs->sprom[SRSH_PI_OFFSET]; - else if (sii->pub.buscoretype == PCI_CORE_ID) - reg16 = &pciregs->sprom[SRSH_PI_OFFSET]; - pciidx = ai_coreidx(&sii->pub); val16 = R_REG(reg16); if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { @@ -832,11 +815,19 @@ void pcicore_fixcfg(void *pch, void *regs) } } -/* precondition: current core is pci core */ -void pcicore_pci_setup(void *pch, void *regs) +void pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs *pciregs) +{ + pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]); +} + +void pcicore_fixcfg_pcie(struct pcicore_info *pi, struct sbpcieregs *pcieregs) +{ + pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); +} + +/* precondition: current core is pci core */ +void pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs *pciregs) { - struct pcicore_info *pi = pch; - struct sbpciregs *pciregs = regs; u32 w; OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.h b/drivers/staging/brcm80211/brcmsmac/nicpci.h index f71f842a215..3082db0d4f4 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.h +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.h @@ -70,16 +70,24 @@ #define SRSH_PI_MASK 0xf000 /* bit 15:12 */ #define SRSH_PI_SHIFT 12 /* bit 15:12 */ -extern void *pcicore_init(struct si_pub *sih, void *pdev, void *regs); -extern void pcicore_deinit(void *pch); -extern void pcicore_attach(void *pch, char *pvars, int state); -extern void pcicore_hwup(void *pch); -extern void pcicore_up(void *pch, int state); -extern void pcicore_sleep(void *pch); -extern void pcicore_down(void *pch, int state); -extern u8 pcicore_find_pci_capability(void *dev, u8 req_cap_id, - unsigned char *buf, u32 *buflen); -extern void pcicore_fixcfg(void *pch, void *regs); -extern void pcicore_pci_setup(void *pch, void *regs); +struct sbpciregs; +struct sbpcieregs; + +extern struct pcicore_info *pcicore_init(struct si_pub *sih, + struct pci_dev *pdev, void *regs); +extern void pcicore_deinit(struct pcicore_info *pch); +extern void pcicore_attach(struct pcicore_info *pch, char *pvars, int state); +extern void pcicore_hwup(struct pcicore_info *pch); +extern void pcicore_up(struct pcicore_info *pch, int state); +extern void pcicore_sleep(struct pcicore_info *pch); +extern void pcicore_down(struct pcicore_info *pch, int state); +extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, + unsigned char *buf, u32 *buflen); +extern void pcicore_fixcfg_pci(struct pcicore_info *pch, + struct sbpciregs *pciregs); +extern void pcicore_fixcfg_pcie(struct pcicore_info *pch, + struct sbpcieregs *pciregs); +extern void pcicore_pci_setup(struct pcicore_info *pch, + struct sbpciregs *pciregs); #endif /* _BRCM_NICPCI_H_ */ From 7b1cbc1d84a90ee659e8ae8f77cea1aad3b79261 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 15 Aug 2011 15:34:14 +0200 Subject: [PATCH 0120/1519] staging: brcm80211: replaced void pointers in dma functions Code cleanup. Replaced by less generic pointer types. Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 31 ++++++++++++----------- drivers/staging/brcm80211/brcmsmac/dma.h | 4 +-- drivers/staging/brcm80211/brcmsmac/main.c | 4 +-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 10a25d23852..3cb9e6881e1 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -275,7 +275,8 @@ struct dma_info { u16 ntxd; /* # tx descriptors tunable */ u16 txin; /* index of next descriptor to reclaim */ u16 txout; /* index of next descriptor to post */ - void **txp; /* pointer to parallel array of pointers to packets */ + /* pointer to parallel array of pointers to packets */ + struct sk_buff **txp; struct dma_seg_map *txp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long txdpa; @@ -291,7 +292,8 @@ struct dma_info { u16 nrxd; /* # rx descriptors tunable */ u16 rxin; /* index of next descriptor to reclaim */ u16 rxout; /* index of next descriptor to post */ - void **rxp; /* pointer to parallel array of pointers to packets */ + /* pointer to parallel array of pointers to packets */ + struct sk_buff **rxp; struct dma_seg_map *rxp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long rxdpa; @@ -367,7 +369,7 @@ static bool _dma_alloc(struct dma_info *di, uint direction); static void _dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa); static void _dma_rxenable(struct dma_info *di); -static void *_dma_getnextrxp(struct dma_info *di, bool forceall); +static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall); static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, @@ -376,7 +378,7 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, /* Prototypes for 64-bit routines */ static bool dma64_alloc(struct dma_info *di, uint direction); -static void *dma64_getnextrxp(struct dma_info *di, bool forceall); +static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall); static bool dma64_rxidle(struct dma_info *di); static bool _dma64_addrext(struct dma64regs *dma64regs); @@ -776,8 +778,7 @@ void dma_rxinit(struct dma_pub *pub) di->rxin = di->rxout = 0; /* clear rx descriptor ring */ - memset((void *)di->rxd64, '\0', - (di->nrxd * sizeof(struct dma64desc))); + memset(di->rxd64, '\0', di->nrxd * sizeof(struct dma64desc)); /* DMA engine with out alignment requirement requires table to be inited * before enabling the engine @@ -822,7 +823,7 @@ static void _dma_rxenable(struct dma_info *di) * buffer data. After it reaches the max size of buffer, the data continues * in next DMA descriptor buffer WITHOUT DMA header */ -void *dma_rx(struct dma_pub *pub) +struct sk_buff *dma_rx(struct dma_pub *pub) { struct dma_info *di = (struct dma_info *)pub; struct sk_buff *p, *head, *tail; @@ -976,7 +977,7 @@ bool dma_rxfill(struct dma_pub *pub) void dma_rxreclaim(struct dma_pub *pub) { struct dma_info *di = (struct dma_info *)pub; - void *p; + struct sk_buff *p; DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); @@ -984,7 +985,7 @@ void dma_rxreclaim(struct dma_pub *pub) brcmu_pkt_buf_free_skb(p); } -static void *_dma_getnextrxp(struct dma_info *di, bool forceall) +static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) { if (di->nrxd == 0) return NULL; @@ -1100,7 +1101,7 @@ void dma_txinit(struct dma_pub *pub) di->dma.txavail = di->ntxd - 1; /* clear tx descriptor ring */ - memset((void *)di->txd64, '\0', (di->ntxd * sizeof(struct dma64desc))); + memset(di->txd64, '\0', (di->ntxd * sizeof(struct dma64desc))); /* DMA engine with out alignment requirement requires table to be inited * before enabling the engine @@ -1155,7 +1156,7 @@ bool dma_txsuspended(struct dma_pub *pub) void dma_txreclaim(struct dma_pub *pub, enum txd_range range) { struct dma_info *di = (struct dma_info *)pub; - void *p; + struct sk_buff *p; DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, (range == DMA_RANGE_ALL) ? "all" : @@ -1406,12 +1407,12 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) * If range is DMA_RANGE_ALL, reclaim all txd(s) posted to the ring and * return associated packet regardless of the value of hardware pointers. */ -void *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) +struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) { struct dma_info *di = (struct dma_info *)pub; u16 start, end, i; u16 active_desc; - void *txp; + struct sk_buff *txp; DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, (range == DMA_RANGE_ALL) ? "all" : @@ -1499,10 +1500,10 @@ void *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) return NULL; } -static void *dma64_getnextrxp(struct dma_info *di, bool forceall) +static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) { uint i, curr; - void *rxp; + struct sk_buff *rxp; unsigned long pa; i = di->rxin; diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 3b2351779f6..134402cc008 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -80,7 +80,7 @@ extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, uint nrxpost, uint rxoffset, uint *msg_level); void dma_rxinit(struct dma_pub *pub); -void *dma_rx(struct dma_pub *pub); +struct sk_buff *dma_rx(struct dma_pub *pub); bool dma_rxfill(struct dma_pub *pub); bool dma_rxreset(struct dma_pub *pub); bool dma_txreset(struct dma_pub *pub); @@ -93,7 +93,7 @@ void dma_txreclaim(struct dma_pub *pub, enum txd_range range); void dma_rxreclaim(struct dma_pub *pub); void dma_detach(struct dma_pub *pub); unsigned long dma_getvar(struct dma_pub *pub, const char *name); -void *dma_getnexttxp(struct dma_pub *pub, enum txd_range range); +struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range); void dma_counterreset(struct dma_pub *pub); void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index bdc7fb4d62d..c462377ead1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -239,8 +239,8 @@ #define DMAREG(wlc_hw, direction, fifonum) \ ((direction == DMA_TX) ? \ - (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ - (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) + &(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ + &(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) #define APHY_SLOT_TIME 9 #define BPHY_SLOT_TIME 20 From e45e8698a994923d57d778ae3ca6123a61917fe0 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 15 Aug 2011 15:34:15 +0200 Subject: [PATCH 0121/1519] staging: brcm80211: replaced void pointers in otp functions Code cleanup. Otp is 'One Time Programmable' functionality. Replaced void pointers by less generic pointer types. Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/otp.c | 90 ++++++++++-------------- drivers/staging/brcm80211/brcmsmac/otp.h | 12 ++-- 2 files changed, 44 insertions(+), 58 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index b6ff76706ef..1e0093c71ca 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -66,13 +66,13 @@ /* OTP function struct */ struct otp_fn_s { - int (*size)(void *oh); - u16 (*read_bit)(void *oh, struct chipcregs *cc, uint off); - void *(*init)(struct si_pub *sih); - int (*read_region)(struct si_pub *sih, int region, u16 *data, + int (*size)(struct otpinfo *oi); + u16 (*read_bit)(struct otpinfo *oi, struct chipcregs *cc, uint off); + struct otpinfo *(*init)(struct si_pub *sih); + int (*read_region)(struct otpinfo *oi, int region, u16 *data, uint *wlen); - int (*nvread)(void *oh, char *data, uint *len); - int (*status)(void *oh); + int (*nvread)(struct otpinfo *oi, char *data, uint *len); + int (*status)(struct otpinfo *oi); }; struct otpinfo { @@ -148,31 +148,24 @@ static struct otpinfo otpinfo; #define OTP4315_SWREG_SZ 178 /* 178 bytes */ #define OTP_SZ_FU_144 (144/8) /* 144 bits */ -static int ipxotp_status(void *oh) +static int ipxotp_status(struct otpinfo *oi) { - struct otpinfo *oi = (struct otpinfo *) oh; return (int)(oi->status); } /* Return size in bytes */ -static int ipxotp_size(void *oh) +static int ipxotp_size(struct otpinfo *oi) { - struct otpinfo *oi = (struct otpinfo *) oh; return (int)oi->wsize * 2; } -static u16 ipxotp_otpr(void *oh, struct chipcregs *cc, uint wn) +static u16 ipxotp_otpr(struct otpinfo *oi, struct chipcregs *cc, uint wn) { - struct otpinfo *oi; - - oi = (struct otpinfo *) oh; - return R_REG(&cc->sromotp[wn]); } -static u16 ipxotp_read_bit(void *oh, struct chipcregs *cc, uint off) +static u16 ipxotp_read_bit(struct otpinfo *oi, struct chipcregs *cc, uint off) { - struct otpinfo *oi = (struct otpinfo *) oh; uint k, row, col; u32 otpp, st; @@ -300,7 +293,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) oi->flim = oi->wsize; } -static void *ipxotp_init(struct si_pub *sih) +static struct otpinfo *ipxotp_init(struct si_pub *sih) { uint idx; struct chipcregs *cc; @@ -355,12 +348,12 @@ static void *ipxotp_init(struct si_pub *sih) ai_setcoreidx(sih, idx); - return (void *)oi; + return oi; } -static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen) +static int +ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) { - struct otpinfo *oi = (struct otpinfo *) oh; uint idx; struct chipcregs *cc; uint base, i, sz; @@ -436,27 +429,27 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen) /* Read the data */ for (i = 0; i < sz; i++) - data[i] = ipxotp_otpr(oh, cc, base + i); + data[i] = ipxotp_otpr(oi, cc, base + i); ai_setcoreidx(oi->sih, idx); *wlen = sz; return 0; } -static int ipxotp_nvread(void *oh, char *data, uint *len) +static int ipxotp_nvread(struct otpinfo *oi, char *data, uint *len) { return -ENOTSUPP; } static struct otp_fn_s ipxotp_fn = { - (int (*)(void *)) ipxotp_size, - (u16 (*)(void *, struct chipcregs *, uint)) ipxotp_read_bit, + (int (*)(struct otpinfo *)) ipxotp_size, + (u16 (*)(struct otpinfo *, struct chipcregs *, uint)) ipxotp_read_bit, - (void *(*)(struct si_pub *)) ipxotp_init, - (int (*)(struct si_pub *, int, u16 *, uint *)) ipxotp_read_region, - (int (*)(void *, char *, uint *)) ipxotp_nvread, + (struct otpinfo *(*)(struct si_pub *)) ipxotp_init, + (int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region, + (int (*)(struct otpinfo *, char *, uint *)) ipxotp_nvread, - (int (*)(void *)) ipxotp_status + (int (*)(struct otpinfo *)) ipxotp_status }; /* @@ -468,34 +461,29 @@ static struct otp_fn_s ipxotp_fn = { * otp_nvread() */ -int otp_status(void *oh) +int otp_status(struct otpinfo *oi) { - struct otpinfo *oi = (struct otpinfo *) oh; - - return oi->fn->status(oh); + return oi->fn->status(oi); } -int otp_size(void *oh) +int otp_size(struct otpinfo *oi) { - struct otpinfo *oi = (struct otpinfo *) oh; - - return oi->fn->size(oh); + return oi->fn->size(oi); } -u16 otp_read_bit(void *oh, uint offset) +u16 otp_read_bit(struct otpinfo *oi, uint offset) { - struct otpinfo *oi = (struct otpinfo *) oh; uint idx = ai_coreidx(oi->sih); struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX); - u16 readBit = (u16) oi->fn->read_bit(oh, cc, offset); + u16 readBit = (u16) oi->fn->read_bit(oi, cc, offset); ai_setcoreidx(oi->sih, idx); return readBit; } -void *otp_init(struct si_pub *sih) +struct otpinfo *otp_init(struct si_pub *sih) { struct otpinfo *oi; - void *ret = NULL; + struct otpinfo *ret = NULL; oi = &otpinfo; memset(oi, 0, sizeof(struct otpinfo)); @@ -516,9 +504,8 @@ void *otp_init(struct si_pub *sih) } int -otp_read_region(struct si_pub *sih, int region, u16 *data, - uint *wlen) { - void *oh; +otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) { + struct otpinfo *oi; int err = 0; if (ai_is_otp_disabled(sih)) { @@ -526,22 +513,19 @@ otp_read_region(struct si_pub *sih, int region, u16 *data, goto out; } - oh = otp_init(sih); - if (oh == NULL) { + oi = otp_init(sih); + if (oi == NULL) { err = -EBADE; goto out; } - err = (((struct otpinfo *) oh)->fn->read_region) - (oh, region, data, wlen); + err = ((oi)->fn->read_region)(oi, region, data, wlen); out: return err; } -int otp_nvread(void *oh, char *data, uint *len) +int otp_nvread(struct otpinfo *oi, char *data, uint *len) { - struct otpinfo *oi = (struct otpinfo *) oh; - - return oi->fn->nvread(oh, data, len); + return oi->fn->nvread(oi, data, len); } diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h index 4d792469896..938100e2548 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.h +++ b/drivers/staging/brcm80211/brcmsmac/otp.h @@ -36,13 +36,15 @@ /* OTP usage */ #define OTP4325_FM_DISABLED_OFFSET 188 +struct otpinfo; + /* Exported functions */ -extern int otp_status(void *oh); -extern int otp_size(void *oh); -extern u16 otp_read_bit(void *oh, uint offset); -extern void *otp_init(struct si_pub *sih); +extern int otp_status(struct otpinfo *oi); +extern int otp_size(struct otpinfo *oi); +extern u16 otp_read_bit(struct otpinfo *oi, uint offset); +extern struct otpinfo *otp_init(struct si_pub *sih); extern int otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen); -extern int otp_nvread(void *oh, char *data, uint *len); +extern int otp_nvread(struct otpinfo *oi, char *data, uint *len); #endif /* _BRCM_OTP_H_ */ From 2f6b1dde0fe1a2f9d4fc701f7b9650c138e5e0ef Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 15 Aug 2011 15:34:16 +0200 Subject: [PATCH 0122/1519] staging: brcm80211: got rid of several void pointers in softmac Code cleanup. Replaced void pointers by less generic pointer types. Reported-by: Julian Calaby Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 14 ------ drivers/staging/brcm80211/brcmsmac/dma.c | 1 - .../staging/brcm80211/brcmsmac/mac80211_if.c | 4 +- .../staging/brcm80211/brcmsmac/mac80211_if.h | 4 +- drivers/staging/brcm80211/brcmsmac/main.c | 45 +++++++++---------- drivers/staging/brcm80211/brcmsmac/main.h | 23 +++------- drivers/staging/brcm80211/brcmsmac/phy_shim.c | 7 +-- drivers/staging/brcm80211/brcmsmac/phy_shim.h | 3 +- drivers/staging/brcm80211/brcmsmac/pub.h | 16 +++---- drivers/staging/brcm80211/brcmsmac/scb.h | 1 - 10 files changed, 44 insertions(+), 74 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 3c0fa13ff0b..6fc15918b5b 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -109,7 +109,6 @@ struct brcms_fifo_info { * rx_factor: maximum rx ampdu factor (0-3) ==> 2^(13+x) bytes * ffpld_rsvd: number of bytes to reserve for preload * max_txlen: max size of ampdu per mcs, bw and sgi - * ini_free: array of ini's to be freed on detach * mfbr: enable multiple fallback rate * tx_max_funl: underflows should be kept such that * (tx_max_funfl*underflows) < tx frames @@ -132,7 +131,6 @@ struct ampdu_info { u8 rx_factor; u32 ffpld_rsvd; u32 max_txlen[MCS_TABLE_SIZE][2][2]; - void *ini_free[AMPDU_INI_FREE]; bool mfbr; u32 tx_max_funl; struct brcms_fifo_info fifo_tb[NUM_FFPLD_FIFO]; @@ -231,18 +229,6 @@ struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc) void brcms_c_ampdu_detach(struct ampdu_info *ampdu) { - int i; - - if (!ampdu) - return; - - /* - * free all ini's which were to be freed on - * callbacks which were never called - */ - for (i = 0; i < AMPDU_INI_FREE; i++) - kfree(ampdu->ini_free[i]); - kfree(ampdu); } diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 3cb9e6881e1..815329c70cc 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -229,7 +229,6 @@ struct dma_seg { }; struct dma_seg_map { - void *oshdmah; /* Opaque handle for OSL to store its information */ uint origsize; /* Size of the virtual packet */ uint nsegs; struct dma_seg segs[MAX_DMA_SEGS]; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index a4d46dd9245..e4657495ebd 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -802,7 +802,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, } /* common load-time initialization */ - wl->wlc = brcms_c_attach((void *)wl, vendor, device, unit, false, + wl->wlc = brcms_c_attach(wl, vendor, device, unit, false, wl->regsva, btparam, &err); brcms_release_fw(wl); if (!wl->wlc) { @@ -1782,7 +1782,7 @@ static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev) char fw_name[100]; int i; - memset((void *)&wl->fw, 0, sizeof(struct brcms_firmware)); + memset(&wl->fw, 0, sizeof(struct brcms_firmware)); for (i = 0; i < MAX_FW_IMAGES; i++) { if (brcms_firmwares[i] == NULL) break; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index c574723eece..fcd711a7c38 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -51,8 +51,8 @@ struct brcms_firmware { }; struct brcms_info { - struct brcms_pub *pub; /* pointer to public wlc state */ - void *wlc; /* pointer to private common data */ + struct brcms_pub *pub; /* pointer to public wlc state */ + struct brcms_c_info *wlc; /* pointer to private common data */ u32 magic; int irq; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index c462377ead1..d6837d38cbf 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -367,9 +367,9 @@ static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc); static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask); static void brcms_c_gpio_init(struct brcms_c_info *wlc); static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, - void *bcn, int len); + u16 bcn[], int len); static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, - void *bcn, int len); + u16 bcn[], int len); static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec); static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit); static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, @@ -457,6 +457,8 @@ static uint brcms_c_down_del_timer(struct brcms_c_info *wlc); static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc); static int _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, struct brcms_c_if *wlcif); +static void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], + int len, bool both); const u8 prio2fifo[NUMPRIO] = { TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ @@ -1375,7 +1377,7 @@ void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) } static void -brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, +brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, u16 bcn[], int len) { struct d11regs *regs = wlc_hw->regs; @@ -1389,7 +1391,7 @@ brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, void *bcn, } static void -brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, void *bcn, +brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, u16 bcn[], int len) { struct d11regs *regs = wlc_hw->regs; @@ -4287,9 +4289,9 @@ static uint brcms_c_attach_module(struct brcms_c_info *wlc) return err; } -struct brcms_pub *brcms_c_pub(void *wlc) +struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) { - return ((struct brcms_c_info *) wlc)->pub; + return wlc->pub; } #define CHIP_SUPPORTS_11N(wlc) 1 @@ -4644,7 +4646,7 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, /* * The common driver entry routine. Error codes should be unique */ -void * +struct brcms_c_info * brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, bool piomode, void *regsva, struct pci_dev *btparam, uint *perr) { @@ -4884,7 +4886,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, if (perr) *perr = 0; - return (void *)wlc; + return wlc; fail: wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", @@ -6319,7 +6321,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, * register watchdog and down handlers. */ int brcms_c_module_register(struct brcms_pub *pub, - const char *name, void *hdl, + const char *name, struct brcms_info *hdl, int (*d_fn)(void *handle)) { struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; @@ -6340,8 +6342,8 @@ int brcms_c_module_register(struct brcms_pub *pub, } /* unregister module callbacks */ -int -brcms_c_module_unregister(struct brcms_pub *pub, const char *name, void *hdl) +int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, + struct brcms_info *hdl) { struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; int i; @@ -6668,8 +6670,8 @@ static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate) * * Returns true if packet consumed (queued), false if not. */ -bool -brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, void *pkt, int prec) +bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, + struct sk_buff *pkt, int prec) { return brcms_c_prec_enq_head(wlc, q, pkt, prec, false); } @@ -6721,10 +6723,9 @@ brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, return true; } -void brcms_c_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, - uint prec) +void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, + struct sk_buff *sdu, uint prec) { - struct brcms_c_info *wlc = (struct brcms_c_info *) ctx; struct brcms_txq_info *qi = wlc->pkt_queue; /* Check me */ struct pktq *q = &qi->q; int prio; @@ -6767,7 +6768,6 @@ brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, { u8 prio; uint fifo; - void *pkt; struct scb *scb = &global_scb; struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); @@ -6778,12 +6778,11 @@ brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : MAXPRIO; fifo = prio2fifo[prio]; - pkt = sdu; if (unlikely (brcms_c_d11hdrs_mac80211( - wlc, hw, pkt, scb, 0, 1, fifo, 0, NULL, 0))) + wlc, hw, sdu, scb, 0, 1, fifo, 0, NULL, 0))) return -EINVAL; - brcms_c_txq_enq(wlc, scb, pkt, BRCMS_PRIO_TO_PREC(prio)); + brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); brcms_c_send_q(wlc); return 0; } @@ -8969,7 +8968,7 @@ int brcms_c_get_header_len() /* mac is assumed to be suspended at this point */ void -brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, void *bcn, +brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], int len, bool both) { struct d11regs *regs = wlc_hw->regs; @@ -9424,8 +9423,8 @@ void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, brcms_b_write_template_ram(wlc->hw, offset, len, buf); } -void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, void *bcn, int len, - bool both) +void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], int len, + bool both) { brcms_b_write_hw_bcntemplates(wlc->hw, bcn, len, both); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index e2febe0565a..433e6a94c5d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -461,7 +461,7 @@ struct modulecb { /* iovar table */ const struct brcmu_iovar *iovars; /* handle passed when handler 'doiovar' is called */ - void *hdl; + struct brcms_info *hdl; /* IOVar handler * @@ -491,15 +491,6 @@ struct modulecb { }; -/* dump control blocks */ -struct dumpcb_s { - const char *name; /* dump name */ - /* 'wl dump' handler */ - int (*dump_fn)(void *handle, struct brcmu_strbuf *b); - void *dump_fn_arg; - struct dumpcb_s *next; -}; - struct edcf_acparam { u8 ACI; u8 ECW; @@ -580,8 +571,8 @@ struct brcms_hardware { char *vars; /* "environment" name=value */ uint vars_size; /* size of vars, free vars on detach */ struct d11regs *regs; /* pointer to device registers */ - void *physhim; /* phy shim layer handler */ - void *phy_sh; /* pointer to shared phy state */ + struct phy_shim_info *physhim; /* phy shim layer handler */ + struct shared_phy *phy_sh; /* pointer to shared phy state */ struct brcms_hw_band *band;/* pointer to active per-band state */ /* band state per phy/radio */ struct brcms_hw_band *bandstate[MAXBANDS]; @@ -1082,16 +1073,14 @@ extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, bool commit, s8 txpktpend); extern void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend); -extern void brcms_c_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, - uint prec); +extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, + struct sk_buff *sdu, uint prec); extern void brcms_c_info_init(struct brcms_c_info *wlc, int unit); extern void brcms_c_print_txstatus(struct tx_status *txs); extern int brcms_c_xmtfifo_sz_get(struct brcms_c_info *wlc, uint fifo, uint *blocks); extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, void *buf); -extern void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, void *bcn, - int len, bool both); extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit); extern void brcms_c_reset_bmac_done(struct brcms_c_info *wlc); @@ -1168,8 +1157,6 @@ extern void brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, extern bool brcms_c_ismpc(struct brcms_c_info *wlc); extern bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc); extern void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc); -extern bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, - void *pkt, int prec); extern bool brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, struct sk_buff *pkt, int prec, bool head); extern u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec); diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index ec88867163e..31c93742f0f 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -31,12 +31,13 @@ /* PHY SHIM module specific state */ struct phy_shim_info { struct brcms_hardware *wlc_hw; /* pointer to main wlc_hw structure */ - void *wlc; /* pointer to main wlc structure */ - void *wl; /* pointer to os-specific private state */ + struct brcms_c_info *wlc; /* pointer to main wlc structure */ + struct brcms_info *wl; /* pointer to os-specific private state */ }; struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, - void *wl, void *wlc) { + struct brcms_info *wl, + struct brcms_c_info *wlc) { struct phy_shim_info *physhim = NULL; physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC); diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index 14c56f9bb2c..d88c8202c97 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -125,7 +125,8 @@ struct brcms_phy; extern struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, - void *wl, void *wlc); + struct brcms_info *wl, + struct brcms_c_info *wlc); extern void wlc_phy_shim_detach(struct phy_shim_info *physhim); /* PHY to WL utility functions */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 40efee6e624..c2ab1a3e288 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -228,8 +228,7 @@ struct brcms_bss_info { * The wlc handle points at this. */ struct brcms_pub { - void *wlc; - + struct brcms_c_info *wlc; struct ieee80211_hw *ieee_hw; struct scb *global_scb; struct scb_ampdu *global_ampdu; @@ -549,9 +548,9 @@ struct brcms_antselcfg { }; /* common functions for every port */ -extern void *brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, - struct pci_dev *btparam, uint *perr); +struct brcms_c_info * +brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, + bool piomode, void *regsva, struct pci_dev *btparam, uint *perr); extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); @@ -588,7 +587,7 @@ extern void brcms_c_set_addrmatch(struct brcms_c_info *wlc, extern void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, const struct ieee80211_tx_queue_params *arg, bool suspend); -extern struct brcms_pub *brcms_c_pub(void *wlc); +extern struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc); /* common functions for every port */ extern void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, @@ -614,11 +613,10 @@ extern void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc); extern void brcms_c_mctrl(struct brcms_c_info *wlc, u32 mask, u32 val); extern int brcms_c_module_register(struct brcms_pub *pub, - const char *name, void *hdl, + const char *name, struct brcms_info *hdl, int (*down_fn)(void *handle)); - extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, - void *hdl); + struct brcms_info *hdl); extern void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc); extern void brcms_c_enable_mac(struct brcms_c_info *wlc); extern void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state); diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index 22ef8e883e3..efa50471661 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -63,7 +63,6 @@ struct scb { u32 flags2; /* various bit flags2 as defined below */ u8 state; /* current state bitfield of auth/assoc process */ u8 ea[ETH_ALEN]; /* station address */ - void *fragbuf[NUMPRIO]; /* defragmentation buffer per prio */ uint fragresid[NUMPRIO];/* #bytes unused in frag buffer per prio */ u16 seqctl[NUMPRIO]; /* seqctl of last received frame (for dups) */ From 6f7d7362aca1bffd05776fe65e682d34c62ed86b Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 15 Aug 2011 15:34:17 +0200 Subject: [PATCH 0123/1519] staging: brcm80211: void * cleanup in fullmac Remove improper usage of void * in dhd_linux.c and dhd_sdio.c Reported-by: Julian Calaby Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 5 +++-- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 14 +++++++------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index ae8a9a6807e..ee09c17db58 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -760,8 +760,9 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, extern void brcmf_c_init(void); -extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, - char *name, u8 *mac_addr, u32 flags, u8 bssidx); +extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, + struct net_device *net, char *name, u8 *mac_addr, + u32 flags, u8 bssidx); extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); /* Send packet to dongle via data channel */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index ca26cc1f677..b8f9922c56e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -978,7 +978,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, return -1; if (cmd == SIOCETHTOOL) - return brcmf_ethtool(drvr_priv, (void *)ifr->ifr_data); + return brcmf_ethtool(drvr_priv, ifr->ifr_data); if (cmd != SIOCDEVPRIVATE) return -EOPNOTSUPP; @@ -1140,12 +1140,12 @@ static int brcmf_netdev_open(struct net_device *net) } int -brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name, - u8 *mac_addr, u32 flags, u8 bssidx) +brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, + char *name, u8 *mac_addr, u32 flags, u8 bssidx) { struct brcmf_if *ifp; - BRCMF_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, handle)); + BRCMF_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, net)); ifp = drvr_priv->iflist[ifidx]; if (!ifp) { @@ -1163,12 +1163,12 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name, if (mac_addr != NULL) memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - if (handle == NULL) { + if (net == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; wake_up(&drvr_priv->sysioc_waitq); } else - ifp->net = (struct net_device *)handle; + ifp->net = net; return 0; } @@ -1228,7 +1228,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) strcat(net->name, "%d"); } - if (brcmf_add_if(drvr_priv, 0, (void *)net, net->name, NULL, 0, 0) == + if (brcmf_add_if(drvr_priv, 0, net, net->name, NULL, 0, 0) == BRCMF_BAD_IF) goto fail; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index a9d661c2fd4..53d4825cc72 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -910,7 +910,7 @@ static int brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); -static bool brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus, void *card); +static bool brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus); static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus); static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus); @@ -3100,7 +3100,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* try to download image and nvram to the dongle */ if (drvr->busstate == BRCMF_BUS_DOWN) { - if (!(brcmf_sdbrcm_download_firmware(bus, bus->sdiodev))) + if (!(brcmf_sdbrcm_download_firmware(bus))) return -1; } @@ -5122,7 +5122,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) } static bool -brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus, void *card) +brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) { bool ret; From 61aee4c17a5945a2b74b0be8c0e23c7e791e66ab Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:18 +0200 Subject: [PATCH 0124/1519] staging: brcm80211: remove W_SM and R_SM macros from dma.c The macros W_SM and R_SM are not doing much conversion of the macro parameters and complicate code readability without good cause. It is more clear to remove usage of the macros expanding it in the source code. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 54 +++++++++++------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 815329c70cc..9ac38679b5a 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -219,9 +219,6 @@ static uint dma_msg_level; #define DI_INFO(dmah) ((dma_info_t *)dmah) -#define R_SM(r) (*(r)) -#define W_SM(r, v) (*(r) = (v)) - /* One physical DMA segment */ struct dma_seg { unsigned long addr; @@ -593,13 +590,12 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, #else if ((di->dataoffsetlow == 0) || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { #endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ - - W_SM(&ddring[outidx].addrlow, - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow)); - W_SM(&ddring[outidx].addrhigh, - BUS_SWAP32(PHYSADDRHI(pa) + di->dataoffsethigh)); - W_SM(&ddring[outidx].ctrl1, BUS_SWAP32(*flags)); - W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2)); + ddring[outidx].addrlow = + BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow); + ddring[outidx].addrhigh = + BUS_SWAP32(PHYSADDRHI(pa) + di->dataoffsethigh); + ddring[outidx].ctrl1 = BUS_SWAP32(*flags); + ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); } else { /* address extension for 32-bit PCI */ u32 ae; @@ -608,17 +604,17 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; ctrl2 |= (ae << D64_CTRL2_AE_SHIFT) & D64_CTRL2_AE; - W_SM(&ddring[outidx].addrlow, - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow)); - W_SM(&ddring[outidx].addrhigh, - BUS_SWAP32(0 + di->dataoffsethigh)); - W_SM(&ddring[outidx].ctrl1, BUS_SWAP32(*flags)); - W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2)); + ddring[outidx].addrlow = + BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow); + ddring[outidx].addrhigh = + BUS_SWAP32(0 + di->dataoffsethigh); + ddring[outidx].ctrl1 = BUS_SWAP32(*flags); + ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); } if (di->dma.dmactrlflags & DMA_CTRL_PEN) { if (DMA64_DD_PARITY(&ddring[outidx])) - W_SM(&ddring[outidx].ctrl2, - BUS_SWAP32(ctrl2 | D64_CTRL2_PARITY)); + ddring[outidx].ctrl2 = + BUS_SWAP32(ctrl2 | D64_CTRL2_PARITY); } } @@ -1369,8 +1365,8 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) /* if last txd eof not set, fix it */ if (!(flags & D64_CTRL1_EOF)) - W_SM(&di->txd64[PREVTXD(txout)].ctrl1, - BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF)); + di->txd64[PREVTXD(txout)].ctrl1 = + BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); /* save the packet */ di->txp[PREVTXD(txout)] = p0; @@ -1456,10 +1452,10 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) uint size, j, nsegs; PHYSADDRLOSET(pa, - (BUS_SWAP32(R_SM(&di->txd64[i].addrlow)) - + (BUS_SWAP32(di->txd64[i].addrlow) - di->dataoffsetlow)); PHYSADDRHISET(pa, - (BUS_SWAP32(R_SM(&di->txd64[i].addrhigh)) - + (BUS_SWAP32(di->txd64[i].addrhigh) - di->dataoffsethigh)); if (DMASGLIST_ENAB) { @@ -1468,14 +1464,14 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) nsegs = map->nsegs; } else { size = - (BUS_SWAP32(R_SM(&di->txd64[i].ctrl2)) & + (BUS_SWAP32(di->txd64[i].ctrl2) & D64_CTRL2_BC_MASK); nsegs = 1; } for (j = nsegs; j > 0; j--) { - W_SM(&di->txd64[i].addrlow, 0xdeadbeef); - W_SM(&di->txd64[i].addrhigh, 0xdeadbeef); + di->txd64[i].addrlow = 0xdeadbeef; + di->txd64[i].addrhigh = 0xdeadbeef; txp = di->txp[i]; di->txp[i] = NULL; @@ -1524,17 +1520,17 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) di->rxp[i] = NULL; PHYSADDRLOSET(pa, - (BUS_SWAP32(R_SM(&di->rxd64[i].addrlow)) - + (BUS_SWAP32(di->rxd64[i].addrlow) - di->dataoffsetlow)); PHYSADDRHISET(pa, - (BUS_SWAP32(R_SM(&di->rxd64[i].addrhigh)) - + (BUS_SWAP32(di->rxd64[i].addrhigh) - di->dataoffsethigh)); /* clear this packet from the descriptor ring */ pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); - W_SM(&di->rxd64[i].addrlow, 0xdeadbeef); - W_SM(&di->rxd64[i].addrhigh, 0xdeadbeef); + di->rxd64[i].addrlow = 0xdeadbeef; + di->rxd64[i].addrhigh = 0xdeadbeef; di->rxin = NEXTRXD(i); From 303a1e5c0be3745a5fccd59347e3765ac7628372 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:19 +0200 Subject: [PATCH 0125/1519] staging: brcm80211: remove PHYSADDR macro from dma.c Four macros with PHYSADDR name prefix are not doing a lot and complicate code readability. These have been expanded in the source code and consequently removed the definitions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 95 ++++++++---------------- 1 file changed, 29 insertions(+), 66 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 9ac38679b5a..64d311f95d9 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -196,14 +196,6 @@ #define DMA_NONE(args) -#define PHYSADDRHI(_pa) (0) -#define PHYSADDRHISET(_pa, _val) -#define PHYSADDRLO(_pa) ((_pa)) -#define PHYSADDRLOSET(_pa, _val) \ - do { \ - (_pa) = (_val); \ - } while (0) - #define d64txregs dregs.d64_u.txregs_64 #define d64rxregs dregs.d64_u.rxregs_64 #define txd64 dregs.d64_u.txd_64 @@ -522,16 +514,14 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, } if ((di->ddoffsetlow != 0) && !di->addrext) { - if (PHYSADDRLO(di->txdpa) > SI_PCI_DMA_SZ) { + if (di->txdpa > SI_PCI_DMA_SZ) { DMA_ERROR(("%s: dma_attach: txdpa 0x%x: addrext not " - "supported\n", di->name, - (u32)PHYSADDRLO(di->txdpa))); + "supported\n", di->name, (u32)di->txdpa)); goto fail; } - if (PHYSADDRLO(di->rxdpa) > SI_PCI_DMA_SZ) { + if (di->rxdpa > SI_PCI_DMA_SZ) { DMA_ERROR(("%s: dma_attach: rxdpa 0x%x: addrext not " - "supported\n", di->name, - (u32)PHYSADDRLO(di->rxdpa))); + "supported\n", di->name, (u32)di->rxdpa)); goto fail; } } @@ -586,28 +576,24 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, /* PCI bus with big(>1G) physical address, use address extension */ #if defined(__mips__) && defined(IL_BIGENDIAN) if ((di->dataoffsetlow == SI_SDRAM_SWAPPED) - || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { + || !(pa & PCI32ADDR_HIGH)) { #else - if ((di->dataoffsetlow == 0) || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { + if ((di->dataoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { #endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ - ddring[outidx].addrlow = - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow); - ddring[outidx].addrhigh = - BUS_SWAP32(PHYSADDRHI(pa) + di->dataoffsethigh); + ddring[outidx].addrlow = BUS_SWAP32(pa + di->dataoffsetlow); + ddring[outidx].addrhigh = BUS_SWAP32(di->dataoffsethigh); ddring[outidx].ctrl1 = BUS_SWAP32(*flags); ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); } else { /* address extension for 32-bit PCI */ u32 ae; - ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; - PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; + pa &= ~PCI32ADDR_HIGH; ctrl2 |= (ae << D64_CTRL2_AE_SHIFT) & D64_CTRL2_AE; - ddring[outidx].addrlow = - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow); - ddring[outidx].addrhigh = - BUS_SWAP32(0 + di->dataoffsethigh); + ddring[outidx].addrlow = BUS_SWAP32(pa + di->dataoffsetlow); + ddring[outidx].addrhigh = BUS_SWAP32(di->dataoffsethigh); ddring[outidx].ctrl1 = BUS_SWAP32(*flags); ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); } @@ -716,45 +702,36 @@ _dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa) { if (!di->aligndesc_4k) { if (direction == DMA_TX) - di->xmtptrbase = PHYSADDRLO(pa); + di->xmtptrbase = pa; else - di->rcvptrbase = PHYSADDRLO(pa); + di->rcvptrbase = pa; } if ((di->ddoffsetlow == 0) - || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { + || !(pa & PCI32ADDR_HIGH)) { if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(&di->d64txregs->addrhigh, - (PHYSADDRHI(pa) + di->ddoffsethigh)); + W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); + W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); } else { - W_REG(&di->d64rxregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(&di->d64rxregs->addrhigh, - (PHYSADDRHI(pa) + di->ddoffsethigh)); + W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); + W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); } } else { /* DMA64 32bits address extension */ u32 ae; /* shift the high bit(s) from pa to ae */ - ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> - PCI32ADDR_HIGH_SHIFT; - PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; + pa &= ~PCI32ADDR_HIGH; if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(&di->d64txregs->addrhigh, - di->ddoffsethigh); + W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); + W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); SET_REG(&di->d64txregs->control, D64_XC_AE, (ae << D64_XC_AE_SHIFT)); } else { - W_REG(&di->d64rxregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(&di->d64rxregs->addrhigh, - di->ddoffsethigh); + W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); + W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); SET_REG(&di->d64rxregs->control, D64_RC_AE, (ae << D64_RC_AE_SHIFT)); } @@ -1196,9 +1173,7 @@ static bool dma64_alloc(struct dma_info *di, uint direction) di->txd64 = (struct dma64desc *) roundup((unsigned long)va, align); di->txdalign = (uint) ((s8 *)di->txd64 - (s8 *) va); - PHYSADDRLOSET(di->txdpa, - PHYSADDRLO(di->txdpaorig) + di->txdalign); - PHYSADDRHISET(di->txdpa, PHYSADDRHI(di->txdpaorig)); + di->txdpa = di->txdpaorig + di->txdalign; di->txdalloc = alloced; } else { va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, @@ -1212,9 +1187,7 @@ static bool dma64_alloc(struct dma_info *di, uint direction) di->rxd64 = (struct dma64desc *) roundup((unsigned long)va, align); di->rxdalign = (uint) ((s8 *)di->rxd64 - (s8 *) va); - PHYSADDRLOSET(di->rxdpa, - PHYSADDRLO(di->rxdpaorig) + di->rxdalign); - PHYSADDRHISET(di->rxdpa, PHYSADDRHI(di->rxdpaorig)); + di->rxdpa = di->rxdpaorig + di->rxdalign; di->rxdalloc = alloced; } @@ -1451,12 +1424,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) struct dma_seg_map *map = NULL; uint size, j, nsegs; - PHYSADDRLOSET(pa, - (BUS_SWAP32(di->txd64[i].addrlow) - - di->dataoffsetlow)); - PHYSADDRHISET(pa, - (BUS_SWAP32(di->txd64[i].addrhigh) - - di->dataoffsethigh)); + pa = BUS_SWAP32(di->txd64[i].addrlow) - di->dataoffsetlow; if (DMASGLIST_ENAB) { map = &di->txp_dmah[i]; @@ -1519,12 +1487,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) rxp = di->rxp[i]; di->rxp[i] = NULL; - PHYSADDRLOSET(pa, - (BUS_SWAP32(di->rxd64[i].addrlow) - - di->dataoffsetlow)); - PHYSADDRHISET(pa, - (BUS_SWAP32(di->rxd64[i].addrhigh) - - di->dataoffsethigh)); + pa = BUS_SWAP32(di->rxd64[i].addrlow) - di->dataoffsetlow; /* clear this packet from the descriptor ring */ pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); From c9be7049ad7892d96011ee00fe430efb8f30b89b Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:20 +0200 Subject: [PATCH 0126/1519] staging: brcm80211: replace BUS_SWAP32 macro with cpu_to_le32() The macro BUS_SWAP32(a) expanded to (a) which was fine for a little endian system. For big endian platform this should do as the name implies. As the driver is intended for PCI which is little-endian the macro cpu_to_le32() can be used instead. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 64d311f95d9..aa4d9cf905a 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -580,10 +580,10 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, #else if ((di->dataoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { #endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ - ddring[outidx].addrlow = BUS_SWAP32(pa + di->dataoffsetlow); - ddring[outidx].addrhigh = BUS_SWAP32(di->dataoffsethigh); - ddring[outidx].ctrl1 = BUS_SWAP32(*flags); - ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); + ddring[outidx].addrlow = cpu_to_le32(pa + di->dataoffsetlow); + ddring[outidx].addrhigh = cpu_to_le32(di->dataoffsethigh); + ddring[outidx].ctrl1 = cpu_to_le32(*flags); + ddring[outidx].ctrl2 = cpu_to_le32(ctrl2); } else { /* address extension for 32-bit PCI */ u32 ae; @@ -592,15 +592,15 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, pa &= ~PCI32ADDR_HIGH; ctrl2 |= (ae << D64_CTRL2_AE_SHIFT) & D64_CTRL2_AE; - ddring[outidx].addrlow = BUS_SWAP32(pa + di->dataoffsetlow); - ddring[outidx].addrhigh = BUS_SWAP32(di->dataoffsethigh); - ddring[outidx].ctrl1 = BUS_SWAP32(*flags); - ddring[outidx].ctrl2 = BUS_SWAP32(ctrl2); + ddring[outidx].addrlow = cpu_to_le32(pa + di->dataoffsetlow); + ddring[outidx].addrhigh = cpu_to_le32(di->dataoffsethigh); + ddring[outidx].ctrl1 = cpu_to_le32(*flags); + ddring[outidx].ctrl2 = cpu_to_le32(ctrl2); } if (di->dma.dmactrlflags & DMA_CTRL_PEN) { if (DMA64_DD_PARITY(&ddring[outidx])) ddring[outidx].ctrl2 = - BUS_SWAP32(ctrl2 | D64_CTRL2_PARITY); + cpu_to_le32(ctrl2 | D64_CTRL2_PARITY); } } @@ -1339,7 +1339,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) /* if last txd eof not set, fix it */ if (!(flags & D64_CTRL1_EOF)) di->txd64[PREVTXD(txout)].ctrl1 = - BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); + cpu_to_le32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); /* save the packet */ di->txp[PREVTXD(txout)] = p0; @@ -1424,7 +1424,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) struct dma_seg_map *map = NULL; uint size, j, nsegs; - pa = BUS_SWAP32(di->txd64[i].addrlow) - di->dataoffsetlow; + pa = cpu_to_le32(di->txd64[i].addrlow) - di->dataoffsetlow; if (DMASGLIST_ENAB) { map = &di->txp_dmah[i]; @@ -1432,7 +1432,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) nsegs = map->nsegs; } else { size = - (BUS_SWAP32(di->txd64[i].ctrl2) & + (cpu_to_le32(di->txd64[i].ctrl2) & D64_CTRL2_BC_MASK); nsegs = 1; } @@ -1487,7 +1487,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) rxp = di->rxp[i]; di->rxp[i] = NULL; - pa = BUS_SWAP32(di->rxd64[i].addrlow) - di->dataoffsetlow; + pa = cpu_to_le32(di->rxd64[i].addrlow) - di->dataoffsetlow; /* clear this packet from the descriptor ring */ pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); From 8ac98a56fac0cafb56d900154ac4569a959011c0 Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Mon, 15 Aug 2011 15:34:21 +0200 Subject: [PATCH 0127/1519] staging: brcm80211: fix off-by-one error in swap functions The original implementation iterated over the data in buf+1 through buf+size, whereas it should have been over the data in buf through buf+size-1. Tested on Mac G5 PPC and BCM63281. Signed-off-by: Henry Ptasinski Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/srom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 060f06fc144..7a17f598e49 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -880,13 +880,15 @@ int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) static inline void ltoh16_buf(u16 *buf, unsigned int size) { - for (size /= 2; size; size--) + size /= 2; + while (size--) *(buf + size) = le16_to_cpu(*(buf + size)); } static inline void htol16_buf(u16 *buf, unsigned int size) { - for (size /= 2; size; size--) + size /= 2; + while (size--) *(buf + size) = cpu_to_le16(*(buf + size)); } From ba1fff7f705ed15e9d5a5922614aa4a259e9f8bc Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Mon, 15 Aug 2011 15:34:22 +0200 Subject: [PATCH 0128/1519] staging: brcm80211: Remove swaps in R_REG and W_REG macros Swapping the addresses is unnecessary, since the swaps are handled by the underlying platform code (i.e. readb() etc. handle any necessary swapping). Tested on Mac G5 PPC and BCM63281. Signed-off-by: Henry Ptasinski Reviewed-by: Arend van Spriel Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/types.h | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index c0d41cc910d..ad874a79cb4 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -329,28 +329,17 @@ do { \ * location are defined in only one spot. This reduces the risk of the * programmer trying to use an unsupported transaction size on a register. * - * For big endian operation, a byte swap has to be done. Eg, when attempting - * to read byte address 0, byte 3 should be read. This is accomplished - * using an xor ('^') operator. */ -#ifndef __BIG_ENDIAN -#define SWP2(r) (r) -#define SWP3(r) (r) -#else -#define SWP2(r) ((unsigned long)(r)^2) -#define SWP3(r) ((unsigned long)(r)^3) -#endif /* __BIG_ENDIAN */ - #define R_REG(r) \ ({ \ __typeof(*(r)) __osl_v; \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - __osl_v = readb((u8 *)(SWP3(r))); \ + __osl_v = readb((u8 *)(r)); \ break; \ case sizeof(u16): \ - __osl_v = readw((u16 *)(SWP2(r))); \ + __osl_v = readw((u16 *)(r)); \ break; \ case sizeof(u32): \ __osl_v = readl((u32 *)(r)); \ @@ -362,10 +351,10 @@ do { \ #define W_REG(r, v) do { \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - writeb((u8)(v), (u8 *)(SWP3(r))); \ + writeb((u8)(v), (u8 *)(r)); \ break; \ case sizeof(u16): \ - writew((u16)(v), (u16 *)(SWP2(r))); \ + writew((u16)(v), (u16 *)(r)); \ break; \ case sizeof(u32): \ writel((u32)(v), (u32 *)(r)); \ From d745a845045f31a8250cd856b79e84c8374a3adb Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Mon, 15 Aug 2011 15:34:23 +0200 Subject: [PATCH 0129/1519] staging: brcm80211: Fix handling of firmware and inits on big-endian platforms The firmware files are encoded as little-endian. Do the appropriate swapping for big-endian platforms. Tested on Mac G5 PPC and BCM63281. Signed-off-by: Henry Ptasinski Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 24 +++++++++++-------- drivers/staging/brcm80211/brcmsmac/main.c | 21 ++++++++++------ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index e4657495ebd..7179edda94a 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -1722,15 +1722,17 @@ int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx) hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data; for (entry = 0; entry < wl->fw.hdr_num_entries[i]; entry++, hdr++) { - if (hdr->idx == idx) { - pdata = wl->fw.fw_bin[i]->data + hdr->offset; - *pbuf = kmalloc(hdr->len, GFP_ATOMIC); + u32 len = le32_to_cpu(hdr->len); + if (le32_to_cpu(hdr->idx) == idx) { + pdata = wl->fw.fw_bin[i]->data + + le32_to_cpu(hdr->offset); + *pbuf = kmalloc(len, GFP_ATOMIC); if (*pbuf == NULL) { wiphy_err(wl->wiphy, "fail to alloc %d" - " bytes\n", hdr->len); + " bytes\n", len); goto fail; } - memcpy(*pbuf, pdata, hdr->len); + memcpy(*pbuf, pdata, len); return 0; } } @@ -1755,14 +1757,15 @@ int brcms_ucode_init_uint(struct brcms_info *wl, u32 *data, u32 idx) hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data; for (entry = 0; entry < wl->fw.hdr_num_entries[i]; entry++, hdr++) { - if (hdr->idx == idx) { - pdata = wl->fw.fw_bin[i]->data + hdr->offset; - if (hdr->len != 4) { + if (le32_to_cpu(hdr->idx) == idx) { + pdata = wl->fw.fw_bin[i]->data + + le32_to_cpu(hdr->offset); + if (le32_to_cpu(hdr->len) != 4) { wiphy_err(wl->wiphy, "ERROR: fw hdr len\n"); return -ENOMSG; } - *data = *((u32 *) pdata); + *data = le32_to_cpu(*((u32 *) pdata)); return 0; } } @@ -1868,7 +1871,8 @@ int brcms_check_firmwares(struct brcms_info *wl) ucode_hdr = (struct firmware_hdr *)fw_hdr->data; for (entry = 0; entry < wl->fw.hdr_num_entries[i] && !rc; entry++, ucode_hdr++) { - if (ucode_hdr->offset + ucode_hdr->len > + if (le32_to_cpu(ucode_hdr->offset) + + le32_to_cpu(ucode_hdr->len) > fw->size) { wiphy_err(wl->wiphy, "%s: conflicting bin/hdr\n", diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d6837d38cbf..c625c2556ae 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -2033,7 +2033,8 @@ static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); (void)R_REG(®s->objaddr); for (i = 0; i < count; i++) - W_REG(®s->objdata, ucode[i]); + W_REG(®s->objdata, le32_to_cpu(ucode[i])); + } static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, @@ -2041,18 +2042,24 @@ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, { int i; u8 *base; + u8 *addr; + u16 size; + u32 value; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); base = (u8 *)wlc_hw->regs; for (i = 0; inits[i].addr != 0xffff; i++) { - if (inits[i].size == 2) - W_REG((u16 *)(base + inits[i].addr), - inits[i].value); - else if (inits[i].size == 4) - W_REG((u32 *)(base + inits[i].addr), - inits[i].value); + size = le16_to_cpu(inits[i].size); + addr = base + le16_to_cpu(inits[i].addr); + value = le32_to_cpu(inits[i].value); + if (size == 2) + W_REG((u16 *)addr, value); + else if (size == 4) + W_REG((u32 *)addr, value); + else + break; } } From a87602e075126c9a7acad7ba999a40837f966e54 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:24 +0200 Subject: [PATCH 0130/1519] staging: brcm80211: remove mips specific include from dma.c The include has been removed as it is not needed. None of the definitions from it are used in the source file. Tested on BCM63281. Reviewed-by: Henry Ptasinski Reviewed-by: Pieter-Paul Giesberts Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index aa4d9cf905a..bda36c70509 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -18,10 +18,6 @@ #include #include -#if defined(__mips__) -#include -#endif - #include #include #include "types.h" From 3bd8ef6799524fd48044a83aab38da57d9a98dbc Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:25 +0200 Subject: [PATCH 0131/1519] staging: brcm80211: restrict register access method for bcm47xx The driver contained conditional code for resolving issue with dma transaction reordering. This code was conditionalized using __mips__ macro, but it actually is specific to bcm47xx chips. This patch replaces it for the more speficic CONFIG_BCM47XX macro. Tested on BCM63281. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- drivers/staging/brcm80211/brcmsmac/types.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index c00178d18b5..448afae0d69 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -380,7 +380,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) regs = pi->regs; -#ifdef __mips__ +#ifdef CONFIG_BCM47XX W_REG_FLUSH(®s->phyregaddr, addr); W_REG(®s->phyregdata, val); if (addr == 0x72) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index ad874a79cb4..d44db5674b3 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -362,7 +362,7 @@ do { \ } \ } while (0) -#ifdef __mips__ +#ifdef CONFIG_BCM47XX /* * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder * transactions. As a fix, a read after write is performed on certain places @@ -371,7 +371,7 @@ do { \ #define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); }) #else #define W_REG_FLUSH(r, v) W_REG((r), (v)) -#endif /* __mips__ */ +#endif /* CONFIG_BCM47XX */ #define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) #define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) From adf27befdc79a9403bfba82ee84f02a47bcd546c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 15 Aug 2011 15:34:26 +0200 Subject: [PATCH 0132/1519] staging: brcm80211: restrict MIPS dma bug workaround to BCM47XX The inline function dma_spin_for_len() was defined for MIPS platforms but the problem only occurs with dma of the PCI core in bcm47xx chips. This patch restricts the function further to BCM47XX platforms only. Tested on BCM63281. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 134402cc008..2ce5963818d 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -100,21 +100,21 @@ void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) (void *pkt, void *arg_a), void *arg_a); /* - * DMA(Bug) on some chips seems to declare that the packet is ready, but the - * packet length is not updated yet (by DMA) on the expected time. + * DMA(Bug) on bcm47xx chips seems to declare that the packet is ready, but + * the packet length is not updated yet (by DMA) on the expected time. * Workaround is to hold processor till DMA updates the length, and stay off * the bus to allow DMA update the length in buffer */ static inline void dma_spin_for_len(uint len, struct sk_buff *head) { -#if defined(__mips__) +#if defined(CONFIG_BCM47XX) if (!len) { while (!(len = *(u16 *) KSEG1ADDR(head->data))) udelay(1); *(u16 *) (head->data) = cpu_to_le16((u16) len); } -#endif /* defined(__mips__) */ +#endif /* defined(CONFIG_BCM47XX) */ } #endif /* _BRCM_DMA_H_ */ From dcaf762fa4b8ea1ba7f0c0ebbc7c04a22a3ca0bd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 15 Aug 2011 15:34:27 +0200 Subject: [PATCH 0133/1519] staging: brcm80211: removed unused MIPS specific SDRAM swap window Certain Mips based, big endian Broadcom products contain a memory window for endianness swap purposes. However, this is too system specific for this driver as there are more big endian platforms to support. Thus, this 'window' functionality is not to be used and can be removed. The swap window would be a performance improvement and could be provided with a dedicated mapping function in the platform specific code. Tested on BCM63281. Reviewed-by: Henry Ptasinski Reviewed-by: Arend van Spriel Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.h | 2 -- drivers/staging/brcm80211/brcmsmac/dma.c | 8 -------- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 7ea42aff9bd..375c06f7c02 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -30,8 +30,6 @@ #define SI_PCI_MEM_SZ (64 * 1024 * 1024) /* Host Mode sb2pcitranslation1 (64 MB) */ #define SI_PCI_CFG 0x0c000000 -/* Byteswapped Physical SDRAM */ -#define SI_SDRAM_SWAPPED 0x10000000 /* Region 2 for sdram (512 MB) */ #define SI_SDRAM_R2 0x80000000 diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index bda36c70509..2ef416a9558 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -442,9 +442,6 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->ddoffsethigh = SI_PCIE_DMA_H32; di->dataoffsetlow = di->ddoffsetlow; di->dataoffsethigh = di->ddoffsethigh; -#if defined(__mips__) && defined(IL_BIGENDIAN) - di->dataoffsetlow = di->dataoffsetlow + SI_SDRAM_SWAPPED; -#endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ /* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */ if ((ai_coreid(sih) == SDIOD_CORE_ID) && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2))) @@ -570,12 +567,7 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, u32 ctrl2 = bufcount & D64_CTRL2_BC_MASK; /* PCI bus with big(>1G) physical address, use address extension */ -#if defined(__mips__) && defined(IL_BIGENDIAN) - if ((di->dataoffsetlow == SI_SDRAM_SWAPPED) - || !(pa & PCI32ADDR_HIGH)) { -#else if ((di->dataoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { -#endif /* defined(__mips__) && defined(IL_BIGENDIAN) */ ddring[outidx].addrlow = cpu_to_le32(pa + di->dataoffsetlow); ddring[outidx].addrhigh = cpu_to_le32(di->dataoffsethigh); ddring[outidx].ctrl1 = cpu_to_le32(*flags); From 75e07b6b2bcb1dad971870a039d5f1441e64bd58 Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Tue, 23 Aug 2011 14:13:53 +0200 Subject: [PATCH 0134/1519] staging: brcm80211: only enable brcmsmac if bcma is not set brcmsmac doesn't yet use bcma, but both drivers attempt to claim the same device. For now, turn of brcmsmac if bcma is enabled. Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index 621570a77bc..ef77b44ec8e 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -7,6 +7,7 @@ config BRCMSMAC default n depends on PCI depends on WLAN && MAC80211 + depends on BCMA=n select BRCMUTIL select FW_LOADER select CRC_CCITT From 0ed129c9df583f22584521e42a65817a89fcd6ad Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 23 Aug 2011 14:13:54 +0200 Subject: [PATCH 0135/1519] staging: brcm80211: make use of crc8 library function The crc8 function is now available as a library function provided by kernel module crc8.ko. The function has been removed from brcmutil module and srom.c now uses crc8 library function. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 1 + drivers/staging/brcm80211/brcmsmac/srom.c | 20 ++++-- drivers/staging/brcm80211/brcmutil/utils.c | 69 ------------------- .../staging/brcm80211/include/brcmu_utils.h | 5 -- 4 files changed, 17 insertions(+), 78 deletions(-) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index ef77b44ec8e..816a7af6a63 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -11,6 +11,7 @@ config BRCMSMAC select BRCMUTIL select FW_LOADER select CRC_CCITT + select CRC8 ---help--- This module adds support for PCIe wireless adapters based on Broadcom IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 7a17f598e49..90e2ac80c22 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,13 @@ #define WRITE_WORD_DELAY 20 #endif +/* + * SROM CRC8 polynomial value: + * + * x^8 + x^7 +x^6 + x^4 + x^2 + 1 + */ +#define SROM_CRC8_POLY 0xAB + /* Maximum srom: 6 Kilobits == 768 bytes */ #define SROM_MAX 768 @@ -782,6 +790,8 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { {NULL, 0, 0, 0, 0} }; +static u8 srom_crc8_table[CRC8_TABLE_SIZE]; + static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b); static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, @@ -919,8 +929,8 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, /* fixup the endianness so crc8 will pass */ htol16_buf(buf, nwords * 2); - if (brcmu_crc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE) + if (crc8(srom_crc8_table, (u8 *) buf, nwords * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) /* DBG only pci always read srom4 first, then srom8/9 */ err = -EIO; @@ -957,8 +967,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) /* fixup the endianness so crc8 will pass */ htol16_buf(buf, bufsz); - if (brcmu_crc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE) + if (crc8(srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) err = -EIO; /* now correct the endianness of the byte array */ @@ -1174,6 +1184,8 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, return -ENOMEM; sromwindow = (u16 *) SROM_OFFSET(sih); + + crc8_populate_lsb(srom_crc8_table, SROM_CRC8_POLY); if (ai_is_sprom_available(sih)) { err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, true); diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 7b4d6586f03..6280ec15f34 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -431,75 +431,6 @@ int brcmu_iovar_lencheck(const struct brcmu_iovar *vi, void *arg, int len, } EXPORT_SYMBOL(brcmu_iovar_lencheck); -/******************************************************************************* - * crc8 - * - * Computes a crc8 over the input data using the polynomial: - * - * x^8 + x^7 +x^6 + x^4 + x^2 + 1 - * - * The caller provides the initial value (either CRC8_INIT_VALUE - * or the previous returned value) to allow for processing of - * discontiguous blocks of data. When generating the CRC the - * caller is responsible for complementing the final return value - * and inserting it into the byte stream. When checking, a final - * return value of CRC8_GOOD_VALUE indicates a valid CRC. - * - * Reference: Dallas Semiconductor Application Note 27 - * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", - * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., - * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt - * - * **************************************************************************** - */ - -static const u8 crc8_table[256] = { - 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B, - 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21, - 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF, - 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5, - 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14, - 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E, - 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80, - 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA, - 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95, - 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF, - 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01, - 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B, - 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA, - 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0, - 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E, - 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34, - 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0, - 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A, - 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54, - 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E, - 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF, - 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5, - 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B, - 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61, - 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E, - 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74, - 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA, - 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0, - 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41, - 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B, - 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5, - 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F -}; - -u8 brcmu_crc8(u8 *pdata, /* pointer to array of data to process */ - uint nbytes, /* number of input data bytes to process */ - u8 crc /* either CRC8_INIT_VALUE or previous return value */ - ) { - /* loop over the buffer data */ - while (nbytes-- > 0) - crc = crc8_table[(crc ^ *pdata++) & 0xff]; - - return crc; -} -EXPORT_SYMBOL(brcmu_crc8); - /* * Traverse a string of 1-byte tag/1-byte length/variable-length value * triples, returning a pointer to the substring whose first element diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index da13e243d39..ff8f3634d28 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -246,8 +246,6 @@ extern int brcmu_iovar_lencheck(const struct brcmu_iovar *table, void *arg, #define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) /* crc defines */ -#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */ -#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */ #define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */ #define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */ @@ -268,9 +266,6 @@ struct brcmu_tlv { #define ETHER_ADDR_STR_LEN 18 /* externs */ -/* crc */ -extern u8 brcmu_crc8(u8 *p, uint nbytes, u8 crc); - /* format/print */ #if defined(BCMDBG) extern int brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, From 85fd3ec4b1048d84f1c36438c7a91827a49c97c7 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 23 Aug 2011 14:13:55 +0200 Subject: [PATCH 0136/1519] staging: brcm80211: make use of cordic library function The cordic function which calculates cosine and sine values for given angle is now provided in library module. The phy code now uses this module function. Reviewed-by: Henry Ptasinski Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 1 + .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 62 ------------------- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 1 - .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 7 ++- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 14 +++-- 5 files changed, 13 insertions(+), 72 deletions(-) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index 816a7af6a63..59e9c8548d0 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -12,6 +12,7 @@ config BRCMSMAC select FW_LOADER select CRC_CCITT select CRC8 + select CORDIC ---help--- This module adds support for PCIe wireless adapters based on Broadcom IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 448afae0d69..5307bd8c258 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -2779,68 +2779,6 @@ wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag) *eps_real -= 0x2000; } -static const s32 AtanTbl[] = { - 2949120, - 1740967, - 919879, - 466945, - 234379, - 117304, - 58666, - 29335, - 14668, - 7334, - 3667, - 1833, - 917, - 458, - 229, - 115, - 57, - 29 -}; - -void wlc_phy_cordic(s32 theta, struct cs32 *val) -{ - s32 angle, valtmp; - unsigned iter; - int signx = 1; - int signtheta; - - val[0].i = CORDIC_AG; - val[0].q = 0; - angle = 0; - - signtheta = (theta < 0) ? -1 : 1; - theta = ((theta + FIXED(180) * signtheta) % FIXED(360)) - - FIXED(180) * signtheta; - - if (FLOAT(theta) > 90) { - theta -= FIXED(180); - signx = -1; - } else if (FLOAT(theta) < -90) { - theta += FIXED(180); - signx = -1; - } - - for (iter = 0; iter < CORDIC_NI; iter++) { - if (theta > angle) { - valtmp = val[0].i - (val[0].q >> iter); - val[0].q = (val[0].i >> iter) + val[0].q; - val[0].i = valtmp; - angle += AtanTbl[iter]; - } else { - valtmp = val[0].i + (val[0].q >> iter); - val[0].q = -(val[0].i >> iter) + val[0].q; - val[0].i = valtmp; - angle -= AtanTbl[iter]; - } - } - - val[0].i = val[0].i * signx; - val[0].q = val[0].q * signx; -} - void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi) { wlapi_del_timer(pi->sh->physhim, pi->phycal_timer); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index b98d76bc833..0594a088e72 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -1039,7 +1039,6 @@ extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val); extern void write_phy_channel_reg(struct brcms_phy *pi, uint val); extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi); -extern void wlc_phy_cordic(s32 theta, struct cs32 *val); extern u8 wlc_phy_nbits(s32 value); extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index dcf626e574c..269346e18a1 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -2723,7 +2724,7 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, u16 num_samps, t, k; u32 bw; s32 theta = 0, rot = 0; - struct cs32 tone_samp; + struct cordic_iq tone_samp; u32 data_buf[64]; u16 i_samp, q_samp; struct phytbl_info tab; @@ -2751,12 +2752,12 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, } else num_samps = 2; - rot = FIXED((f_kHz * 36) / phy_bw) / 100; + rot = ((f_kHz * 36) / phy_bw) / 100; theta = 0; for (t = 0; t < num_samps; t++) { - wlc_phy_cordic(theta, &tone_samp); + tone_samp = cordic_calc_iq(theta); theta += rot; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 2e8aa64979c..2d90f098b07 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -14214,7 +14215,8 @@ static u16 wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 dac_test_mode); static void wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, - struct cs32 *tone_buf, u16 num_samps); + struct cordic_iq *tone_buf, + u16 num_samps); static void wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 n, u16 lps, u16 wait, u8 iq, u8 dac_test_mode, bool modify_bbmult); @@ -22179,7 +22181,7 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u16 num_samps, t, spur; s32 theta = 0, rot = 0; u32 tbl_len; - struct cs32 *tone_buf = NULL; + struct cordic_iq *tone_buf = NULL; is_phybw40 = CHSPEC_IS40(pi->radio_chanspec); phy_bw = (is_phybw40 == 1) ? 40 : 20; @@ -22194,17 +22196,17 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, tbl_len = (phy_bw << 1); } - tone_buf = kmalloc(sizeof(struct cs32) * tbl_len, GFP_ATOMIC); + tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC); if (tone_buf == NULL) return 0; num_samps = (u16) tbl_len; - rot = FIXED((f_kHz * 36) / phy_bw) / 100; + rot = ((f_kHz * 36) / phy_bw) / 100; theta = 0; for (t = 0; t < num_samps; t++) { - wlc_phy_cordic(theta, &tone_buf[t]); + tone_buf[t] = cordic_calc_iq(theta); theta += rot; @@ -22239,7 +22241,7 @@ wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, } static void -wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cs32 *tone_buf, +wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, u16 num_samps) { u16 t; From 60be7ec5099cee40f40b0fbb75ea4396016a5231 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 23 Aug 2011 14:13:56 +0200 Subject: [PATCH 0137/1519] staging: brcm80211: fix checkpatch warning in fullmac Fix the __aligned checkpatch warning in wl_cfg80211.h Reviewed-by: Roland Vossen Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 049138b9e5d..0542bac2d79 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -317,7 +317,7 @@ struct brcmf_cfg80211_priv { u8 *ioctl_buf; /* ioctl buffer */ u8 *extra_buf; /* maily to grab assoc information */ struct dentry *debugfsdir; - u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN))); + u8 ci[0] __aligned(NETDEV_ALIGN); }; #define cfg_to_wiphy(w) (w->wdev->wiphy) From 183eeb985a2cdbf37c7850c5e8e99cc1cc26901f Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 23 Aug 2011 14:13:57 +0200 Subject: [PATCH 0138/1519] staging: brcm80211: fix rtnl_lock issue when bringing down brcmfmac When bringing down the netdevice interface a deadlock occurred sporadically due to the rtnl_lock being held by a task that was waiting for another task trying to get the lock. This patch fixes that issue. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 6c604cf627d..80bb30a8a76 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3189,7 +3189,14 @@ static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) if (cfg_priv->iscan_on && iscan->tsk) { iscan->state = WL_ISCAN_STATE_IDLE; send_sig(SIGTERM, iscan->tsk, 1); + + /* + * The iscan task may want to acquire the rtnl_lock + * so release it here upon stopping the task. + */ + rtnl_unlock(); kthread_stop(iscan->tsk); + rtnl_lock(); iscan->tsk = NULL; /* Abort iscan running in FW */ From 49d468f64d59016030c2835a423833e7b45ccce5 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 23 Aug 2011 14:13:58 +0200 Subject: [PATCH 0139/1519] staging: brcm80211: bugfix for exception on Sparc platforms Problem would pop up during driver load on a Sun Fire V120 and manifested itself as an exception. This was caused by int* pointers provided to memcpy() that were not aligned on an int boundary. The pointer type provided to memcpy() is used by the compiler for optimization purposes. Fix was to cast the int* pointers to void* pointers. Bernhard R. Link and David S. Miller provided valuable feedback, thanks gents. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index c625c2556ae..7e729d295d7 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6111,9 +6111,12 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, /* default argument is generic integer */ pval = arg ? (int *)arg : NULL; - /* This will prevent the misaligned access */ + /* + * This will prevent misaligned access. The (void *) cast prevents a + * memcpy alignment issue on e.g. Sparc64 platforms. + */ if (pval && (u32) len >= sizeof(val)) - memcpy(&val, pval, sizeof(val)); + memcpy((void *)&val, (void *)pval, sizeof(val)); else val = 0; From c13d2ad0599a73d87871c5a2b4468e8cbd4bf369 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 23 Aug 2011 14:13:59 +0200 Subject: [PATCH 0140/1519] staging: brcm80211: bugfix for fifo problem on 64 bits platforms. Message 'receive fifo overflow' appeared in the log. Root cause was an invalid physical address being programmed into the DMA engine. This was caused by an invalid pointer cast in the dma code. Issue was observed on a Sparc (Sun Fire V120) machine but could theoretically also pop up on other architectures. Driver was tested to scan and ping on aforementioned machine. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 2ef416a9558..05dad9fcc93 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -600,13 +600,18 @@ static bool _dma_alloc(struct dma_info *di, uint direction) void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, uint *alloced, unsigned long *pap) { + void *rc; + dma_addr_t dma_addr; + if (align_bits) { u16 align = (1 << align_bits); if (!IS_ALIGNED(PAGE_SIZE, align)) size += align; *alloced = size; } - return pci_alloc_consistent(pdev, size, (dma_addr_t *) pap); + rc = pci_alloc_consistent(pdev, size, &dma_addr); + *pap = dma_addr; + return rc; } /* !! may be called with core in reset */ From 5a84d6ad4c9306afb467a600a4c6d7b50da49440 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 23 Aug 2011 14:14:00 +0200 Subject: [PATCH 0141/1519] staging: brcm80211: fill in proper rx rate in mac80211 rx status The brcmsmac driver supports different rates on 5GHz but this is not taken into account when providing the rate index in the receive status information passed to mac80211. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Henry Ptasinski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 9 +++++++-- drivers/staging/brcm80211/brcmsmac/mac80211_if.h | 6 ++++++ drivers/staging/brcm80211/brcmsmac/main.c | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 7179edda94a..23701718613 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -971,6 +971,10 @@ static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { .hw_value = (rate100m / 5), \ } +/* + * The rate table is used for both 2.4G and 5G rates. The + * latter being a subset as it does not support CCK rates. + */ static struct ieee80211_rate legacy_ratetable[] = { RATE(10, 0), RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), @@ -1012,8 +1016,9 @@ static struct ieee80211_supported_band brcms_band_5GHz_nphy = { .band = IEEE80211_BAND_5GHZ, .channels = brcms_5ghz_nphy_chantable, .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), - .bitrates = legacy_ratetable + 4, - .n_bitrates = ARRAY_SIZE(legacy_ratetable) - 4, + .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET, + .n_bitrates = ARRAY_SIZE(legacy_ratetable) - + BRCMS_LEGACY_5G_RATE_OFFSET, .ht_cap = { .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index fcd711a7c38..7f290d7c0c4 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -20,6 +20,12 @@ #include #include +/* + * Starting index for 5G rates in the + * legacy rate table. + */ +#define BRCMS_LEGACY_5G_RATE_OFFSET 4 + /* softmac ioctl definitions */ #define BRCMS_SET_SHORTSLOT_OVERRIDE 146 diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 7e729d295d7..339ab28477a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -8252,6 +8252,14 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, wiphy_err(wlc->wiphy, "%s: Unknown rate\n", __func__); } + /* + * For 5GHz, we should decrease the index as it is + * a subset of the 2.4G rates. See bitrates field + * of brcms_band_5GHz_nphy (in mac80211_if.c). + */ + if (rx_status->band == IEEE80211_BAND_5GHZ) + rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; + /* Determine short preamble and rate_idx */ preamble = 0; if (IS_CCK(rspec)) { From 5349d3d880cdfdeda918f6e84e490f2e86f9d810 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 6 Aug 2011 13:26:29 +0200 Subject: [PATCH 0142/1519] staging: brcm80211: use kzalloc() Use kzalloc rather than kmalloc followed by memset with 0 This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/kzalloc-simple.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Acked-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 53d4825cc72..7632a0ebd97 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -5644,14 +5644,12 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) BRCMF_TRACE(("%s: Enter\n", __func__)); /* alloc chip_info_t */ - ci = kmalloc(sizeof(struct chip_info), GFP_ATOMIC); + ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); if (NULL == ci) { BRCMF_ERROR(("%s: malloc failed!\n", __func__)); return -ENOMEM; } - memset((unsigned char *)ci, 0, sizeof(struct chip_info)); - /* bus/core/clk setup for register access */ /* Try forcing SDIO core to do ALPAvail request only */ clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; From fe39f945bac555165962b58f0cafa5fbfa3d5724 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 6 Aug 2011 11:17:20 +0200 Subject: [PATCH 0143/1519] staging: brcm80211: use kstrdup() Use kstrdup rather than duplicating its implementation The semantic patch that makes this output is available in scripts/coccinelle/api/kstrdup.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index a6704c43a81..bd655a31087 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -928,7 +928,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) int i = 0; char *arg_save = 0, *arg_org = 0; - arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC); + arg_save = kstrdup(arg, GFP_ATOMIC); if (!arg_save) { BRCMF_ERROR(("%s: kmalloc failed\n", __func__)); goto fail; @@ -942,8 +942,6 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) goto fail; } - strcpy(arg_save, arg); - argv[i] = strsep(&arg_save, " "); while (argv[i++]) argv[i] = strsep(&arg_save, " "); From 88d94e301e416f672b2991af3404aebfb6277b2c Mon Sep 17 00:00:00 2001 From: Colin Brophy Date: Fri, 15 Jul 2011 13:08:16 +0100 Subject: [PATCH 0144/1519] Staging: nvec: fixes coding style issues in nvec_kbd.c This patches nvec_kbd.c to the file that fixes up errors found by the checkpath.pl tool. Signed-off-by: Colin Brophy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec_kbd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 9a9850725b5..04bd285cfe0 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -4,7 +4,7 @@ #include "nvec-keytable.h" #include "nvec.h" -#define ACK_KBD_EVENT {'\x05','\xed','\x01'} +#define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) + ARRAY_SIZE(extcode_tab_us102)]; @@ -27,10 +27,10 @@ static int nvec_keys_notifier(struct notifier_block *nb, nvec_size _size = (msg[0] & (3 << 5)) >> 5; /* power on/off button */ - if(_size == NVEC_VAR_SIZE) + if (_size == NVEC_VAR_SIZE) return NOTIFY_STOP; - if(_size == NVEC_3BYTES) + if (_size == NVEC_3BYTES) msg++; code = msg[1] & 0x7f; @@ -51,13 +51,13 @@ static int nvec_kbd_event(struct input_dev *dev, unsigned int type, unsigned char buf[] = ACK_KBD_EVENT; struct nvec_chip *nvec = keys_dev.nvec; - if(type==EV_REP) + if (type == EV_REP) return 0; - if(type!=EV_LED) + if (type != EV_LED) return -1; - if(code!=LED_CAPSL) + if (code != LED_CAPSL) return -1; buf[2] = !!value; @@ -73,11 +73,11 @@ int __init nvec_kbd_init(struct nvec_chip *nvec) j = 0; - for(i = 0; i < ARRAY_SIZE(code_tab_102us); ++i) + for (i = 0; i < ARRAY_SIZE(code_tab_102us); ++i) keycodes[j++] = code_tab_102us[i]; - for(i = 0; i < ARRAY_SIZE(extcode_tab_us102); ++i) - keycodes[j++]=extcode_tab_us102[i]; + for (i = 0; i < ARRAY_SIZE(extcode_tab_us102); ++i) + keycodes[j++] = extcode_tab_us102[i]; idev = input_allocate_device(); idev->name = "Tegra nvec keyboard"; @@ -89,12 +89,12 @@ int __init nvec_kbd_init(struct nvec_chip *nvec) idev->keycodesize = sizeof(unsigned char); idev->keycodemax = ARRAY_SIZE(keycodes); - for( i = 0; i < ARRAY_SIZE(keycodes); ++i) + for (i = 0; i < ARRAY_SIZE(keycodes); ++i) set_bit(keycodes[i], idev->keybit); clear_bit(0, idev->keybit); err = input_register_device(idev); - if(err) + if (err) goto fail; keys_dev.input = idev; From 796fd547cfbd7bbded3672eda21d9aa45f603dda Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Sun, 17 Jul 2011 00:30:09 +0200 Subject: [PATCH 0145/1519] staging: rtl8192u: Follow all suggestions from checkpatch on compress.c Signed-off-by: Toon Schoenmakers Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/compress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/compress.c b/drivers/staging/rtl8192u/ieee80211/compress.c index 86c23c9223f..5416ab63a73 100644 --- a/drivers/staging/rtl8192u/ieee80211/compress.c +++ b/drivers/staging/rtl8192u/ieee80211/compress.c @@ -12,10 +12,10 @@ * */ #include -//#include +/*#include */ #include "rtl_crypto.h" #include -#include +#include #include #include "internal.h" From 51ce068c50b05585dc68bcd55759fc147218cf1d Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Sun, 17 Jul 2011 01:38:29 +0200 Subject: [PATCH 0146/1519] staging: vt6655: Fixed all the indents and other errors in IEEE11h.c Signed-off-by: Toon Schoenmakers Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/IEEE11h.c | 370 ++++++++++++++++--------------- 1 file changed, 197 insertions(+), 173 deletions(-) diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c index e07ebd578d4..cf7364d6526 100644 --- a/drivers/staging/vt6655/IEEE11h.c +++ b/drivers/staging/vt6655/IEEE11h.c @@ -41,52 +41,52 @@ #include "channel.h" /*--------------------- Static Definitions -------------------------*/ -static int msglevel =MSG_LEVEL_INFO; +static int msglevel = MSG_LEVEL_INFO; #pragma pack(1) typedef struct _WLAN_FRAME_ACTION { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char abyVars[1]; + WLAN_80211HDR_A3 Header; + unsigned char byCategory; + unsigned char byAction; + unsigned char abyVars[1]; } WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION; typedef struct _WLAN_FRAME_MSRREQ { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_MEASURE_REQ sMSRReqEIDs[1]; + WLAN_80211HDR_A3 Header; + unsigned char byCategory; + unsigned char byAction; + unsigned char byDialogToken; + WLAN_IE_MEASURE_REQ sMSRReqEIDs[1]; } WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ; typedef struct _WLAN_FRAME_MSRREP { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_MEASURE_REP sMSRRepEIDs[1]; + WLAN_80211HDR_A3 Header; + unsigned char byCategory; + unsigned char byAction; + unsigned char byDialogToken; + WLAN_IE_MEASURE_REP sMSRRepEIDs[1]; } WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP; typedef struct _WLAN_FRAME_TPCREQ { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_TPC_REQ sTPCReqEIDs; + WLAN_80211HDR_A3 Header; + unsigned char byCategory; + unsigned char byAction; + unsigned char byDialogToken; + WLAN_IE_TPC_REQ sTPCReqEIDs; } WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ; typedef struct _WLAN_FRAME_TPCREP { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_TPC_REP sTPCRepEIDs; + WLAN_80211HDR_A3 Header; + unsigned char byCategory; + unsigned char byAction; + unsigned char byDialogToken; + WLAN_IE_TPC_REP sTPCRepEIDs; } WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP; #pragma pack() -// action field reference ieee 802.11h Table 20e +/* action field reference ieee 802.11h Table 20e */ #define ACTION_MSRREQ 0 #define ACTION_MSRREP 1 #define ACTION_TPCREQ 2 @@ -101,84 +101,100 @@ typedef struct _WLAN_FRAME_TPCREP { static bool s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq, unsigned int uLength) { - size_t uNumOfEIDs = 0; - bool bResult = true; + size_t uNumOfEIDs = 0; + bool bResult = true; - if (uLength <= WLAN_A3FR_MAXLEN) { - memcpy(pMgmt->abyCurrentMSRReq, pMSRReq, uLength); - } - uNumOfEIDs = ((uLength - offsetof(WLAN_FRAME_MSRREQ, sMSRReqEIDs))/ (sizeof(WLAN_IE_MEASURE_REQ))); - pMgmt->pCurrMeasureEIDRep = &(((PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep))->sMSRRepEIDs[0]); - pMgmt->uLengthOfRepEIDs = 0; - bResult = CARDbStartMeasure(pMgmt->pAdapter, - ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->sMSRReqEIDs, - uNumOfEIDs - ); - return (bResult); + if (uLength <= WLAN_A3FR_MAXLEN) + memcpy(pMgmt->abyCurrentMSRReq, pMSRReq, uLength); + uNumOfEIDs = ((uLength - offsetof(WLAN_FRAME_MSRREQ, + sMSRReqEIDs))/ + (sizeof(WLAN_IE_MEASURE_REQ))); + pMgmt->pCurrMeasureEIDRep = &(((PWLAN_FRAME_MSRREP) + (pMgmt->abyCurrentMSRRep))->sMSRRepEIDs[0]); + pMgmt->uLengthOfRepEIDs = 0; + bResult = CARDbStartMeasure(pMgmt->pAdapter, + ((PWLAN_FRAME_MSRREQ) + (pMgmt->abyCurrentMSRReq))->sMSRReqEIDs, + uNumOfEIDs + ); + return bResult; } -static bool s_bRxTPCReq(PSMgmtObject pMgmt, PWLAN_FRAME_TPCREQ pTPCReq, unsigned char byRate, unsigned char byRSSI) +static bool s_bRxTPCReq(PSMgmtObject pMgmt, + PWLAN_FRAME_TPCREQ pTPCReq, + unsigned char byRate, + unsigned char byRSSI) { - PWLAN_FRAME_TPCREP pFrame; - PSTxMgmtPacket pTxPacket = NULL; + PWLAN_FRAME_TPCREP pFrame; + PSTxMgmtPacket pTxPacket = NULL; + pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + +sizeof(STxMgmtPacket)); - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + pFrame = (PWLAN_FRAME_TPCREP)((unsigned char *)pTxPacket + +sizeof(STxMgmtPacket)); - pFrame = (PWLAN_FRAME_TPCREP)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + pFrame->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | + WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) + ); - pFrame->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) - ); + memcpy(pFrame->Header.abyAddr1, + pTPCReq->Header.abyAddr2, + WLAN_ADDR_LEN); + memcpy(pFrame->Header.abyAddr2, + CARDpGetCurrentAddress(pMgmt->pAdapter), + WLAN_ADDR_LEN); + memcpy(pFrame->Header.abyAddr3, + pMgmt->abyCurrBSSID, + WLAN_BSSID_LEN); - memcpy( pFrame->Header.abyAddr1, pTPCReq->Header.abyAddr2, WLAN_ADDR_LEN); - memcpy( pFrame->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN); - memcpy( pFrame->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); + pFrame->byCategory = 0; + pFrame->byAction = 3; + pFrame->byDialogToken = ((PWLAN_FRAME_MSRREQ) +(pMgmt->abyCurrentMSRReq))->byDialogToken; - pFrame->byCategory = 0; - pFrame->byAction = 3; - pFrame->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken; + pFrame->sTPCRepEIDs.byElementID = WLAN_EID_TPC_REP; + pFrame->sTPCRepEIDs.len = 2; + pFrame->sTPCRepEIDs.byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter); + switch (byRate) { + case RATE_54M: + pFrame->sTPCRepEIDs.byLinkMargin = 65 - byRSSI; + break; + case RATE_48M: + pFrame->sTPCRepEIDs.byLinkMargin = 66 - byRSSI; + break; + case RATE_36M: + pFrame->sTPCRepEIDs.byLinkMargin = 70 - byRSSI; + break; + case RATE_24M: + pFrame->sTPCRepEIDs.byLinkMargin = 74 - byRSSI; + break; + case RATE_18M: + pFrame->sTPCRepEIDs.byLinkMargin = 77 - byRSSI; + break; + case RATE_12M: + pFrame->sTPCRepEIDs.byLinkMargin = 79 - byRSSI; + break; + case RATE_9M: + pFrame->sTPCRepEIDs.byLinkMargin = 81 - byRSSI; + break; + case RATE_6M: + default: + pFrame->sTPCRepEIDs.byLinkMargin = 82 - byRSSI; + break; +} - pFrame->sTPCRepEIDs.byElementID = WLAN_EID_TPC_REP; - pFrame->sTPCRepEIDs.len = 2; - pFrame->sTPCRepEIDs.byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter); - switch (byRate) { - case RATE_54M: - pFrame->sTPCRepEIDs.byLinkMargin = 65 - byRSSI; - break; - case RATE_48M: - pFrame->sTPCRepEIDs.byLinkMargin = 66 - byRSSI; - break; - case RATE_36M: - pFrame->sTPCRepEIDs.byLinkMargin = 70 - byRSSI; - break; - case RATE_24M: - pFrame->sTPCRepEIDs.byLinkMargin = 74 - byRSSI; - break; - case RATE_18M: - pFrame->sTPCRepEIDs.byLinkMargin = 77 - byRSSI; - break; - case RATE_12M: - pFrame->sTPCRepEIDs.byLinkMargin = 79 - byRSSI; - break; - case RATE_9M: - pFrame->sTPCRepEIDs.byLinkMargin = 81 - byRSSI; - break; - case RATE_6M: - default: - pFrame->sTPCRepEIDs.byLinkMargin = 82 - byRSSI; - break; - } - - pTxPacket->cbMPDULen = sizeof(WLAN_FRAME_TPCREP); - pTxPacket->cbPayloadLen = sizeof(WLAN_FRAME_TPCREP) - WLAN_HDR_ADDR3_LEN; - if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) - return (false); - return (true); -// return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, sizeof(WLAN_FRAME_TPCREP))); + pTxPacket->cbMPDULen = sizeof(WLAN_FRAME_TPCREP); + pTxPacket->cbPayloadLen = sizeof(WLAN_FRAME_TPCREP) - +WLAN_HDR_ADDR3_LEN; + if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) + return false; + return true; +/* return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, +sizeof(WLAN_FRAME_TPCREP))); */ } @@ -204,102 +220,110 @@ static bool s_bRxTPCReq(PSMgmtObject pMgmt, PWLAN_FRAME_TPCREQ pTPCReq, unsigned * -*/ bool -IEEE11hbMgrRxAction ( - void *pMgmtHandle, - void *pRxPacket - ) +IEEE11hbMgrRxAction(void *pMgmtHandle, void *pRxPacket) { - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - PWLAN_FRAME_ACTION pAction = NULL; - unsigned int uLength = 0; - PWLAN_IE_CH_SW pChannelSwitch = NULL; + PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; + PWLAN_FRAME_ACTION pAction = NULL; + unsigned int uLength = 0; + PWLAN_IE_CH_SW pChannelSwitch = NULL; + /* decode the frame */ + uLength = ((PSRxMgmtPacket)pRxPacket)->cbMPDULen; + if (uLength > WLAN_A3FR_MAXLEN) + return false; - // decode the frame - uLength = ((PSRxMgmtPacket)pRxPacket)->cbMPDULen; - if (uLength > WLAN_A3FR_MAXLEN) { - return (false); - } + pAction = (PWLAN_FRAME_ACTION) +(((PSRxMgmtPacket)pRxPacket)->p80211Header); + if (pAction->byCategory == 0) { + switch (pAction->byAction) { + case ACTION_MSRREQ: + return s_bRxMSRReq(pMgmt, + (PWLAN_FRAME_MSRREQ) + pAction, + uLength); + break; + case ACTION_MSRREP: + break; + case ACTION_TPCREQ: + return s_bRxTPCReq(pMgmt, + (PWLAN_FRAME_TPCREQ) pAction, + ((PSRxMgmtPacket)pRxPacket)->byRxRate, + (unsigned char) + ((PSRxMgmtPacket)pRxPacket)->uRSSI); + break; + case ACTION_TPCREP: + break; + case ACTION_CHSW: + pChannelSwitch = (PWLAN_IE_CH_SW) (pAction->abyVars); + if ((pChannelSwitch->byElementID == WLAN_EID_CH_SWITCH) + && (pChannelSwitch->len == 3)) { + /* valid element id */ + CARDbChannelSwitch(pMgmt->pAdapter, + pChannelSwitch->byMode, + get_channel_mapping(pMgmt->pAdapter, + pChannelSwitch->byChannel, + pMgmt->eCurrentPHYMode), + pChannelSwitch->byCount); + } + break; + default: + DBG_PRT(MSG_LEVEL_DEBUG, + KERN_INFO"Unknown Action = %d\n", + pAction->byAction); + break; + } + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Category = %d\n", +pAction->byCategory); + pAction->byCategory |= 0x80; - pAction = (PWLAN_FRAME_ACTION) (((PSRxMgmtPacket)pRxPacket)->p80211Header); - - if (pAction->byCategory == 0) { - switch (pAction->byAction) { - case ACTION_MSRREQ: - return (s_bRxMSRReq(pMgmt, (PWLAN_FRAME_MSRREQ) pAction, uLength)); - break; - case ACTION_MSRREP: - break; - case ACTION_TPCREQ: - return (s_bRxTPCReq(pMgmt, - (PWLAN_FRAME_TPCREQ) pAction, - ((PSRxMgmtPacket)pRxPacket)->byRxRate, - (unsigned char) ((PSRxMgmtPacket)pRxPacket)->uRSSI)); - break; - case ACTION_TPCREP: - break; - case ACTION_CHSW: - pChannelSwitch = (PWLAN_IE_CH_SW) (pAction->abyVars); - if ((pChannelSwitch->byElementID == WLAN_EID_CH_SWITCH) && - (pChannelSwitch->len == 3)) { - // valid element id - CARDbChannelSwitch( pMgmt->pAdapter, - pChannelSwitch->byMode, - get_channel_mapping(pMgmt->pAdapter, pChannelSwitch->byChannel, pMgmt->eCurrentPHYMode), - pChannelSwitch->byCount - ); - } - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Action = %d\n", pAction->byAction); - break; - } - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Category = %d\n", pAction->byCategory); - pAction->byCategory |= 0x80; - - //return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, uLength)); - return (true); - } - return (true); + /*return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, +uLength));*/ + return true; + } + return true; } -bool IEEE11hbMSRRepTx ( - void *pMgmtHandle - ) +bool IEEE11hbMSRRepTx(void *pMgmtHandle) { - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket)); - size_t uLength = 0; - PSTxMgmtPacket pTxPacket = NULL; + PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; + PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) +(pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket)); + size_t uLength = 0; + PSTxMgmtPacket pTxPacket = NULL; - pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep; + memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + +sizeof(STxMgmtPacket)); + pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | + WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) + ); - pMSRRep->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) - ); + memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) + (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN); + memcpy(pMSRRep->Header.abyAddr2, + CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN); + memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - memcpy( pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN); - memcpy( pMSRRep->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN); - memcpy( pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); + pMSRRep->byCategory = 0; + pMSRRep->byAction = 1; + pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) + (pMgmt->abyCurrentMSRReq))->byDialogToken; - pMSRRep->byCategory = 0; - pMSRRep->byAction = 1; - pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken; + uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP, + sMSRRepEIDs); - uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP, sMSRRepEIDs); - - pTxPacket->cbMPDULen = uLength; - pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN; - if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) - return (false); - return (true); -// return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, uLength)); + pTxPacket->cbMPDULen = uLength; + pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN; + if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) + return false; + return true; +/* return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, +uLength)); */ } From cdf6e817904412931ba9a54fa0376cf6f4f678fe Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:28 +0100 Subject: [PATCH 0147/1519] staging:iio:gyro:adis16130 fix adis16130_spi_read which was never selecting the channel Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16130_core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index c80e908d8ac..caf067ce98c 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -75,15 +75,24 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr, int ret; struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16130_state *st = iio_priv(indio_dev); + struct spi_message msg; + struct spi_transfer xfer = { + .tx_buf = st->buf, + .rx_buf = st->buf, + }; mutex_lock(&st->buf_lock); st->buf[0] = ADIS16130_CON_RD | reg_addr; - if (st->mode) - ret = spi_read(st->us, st->buf, 4); - else - ret = spi_read(st->us, st->buf, 3); + st->buf[1] = st->buf[2] = st->buf[3] = 0; + if (st->mode) + xfer.len = 4; + else + xfer.len = 3; + spi_message_init(&msg); + spi_message_add_tail(&xfer, &msg); + ret = spi_sync(st->us, &msg); if (ret == 0) { if (st->mode) *val = (st->buf[1] << 16) | From cd0380190f7c7ad8d5a8f15403a67fedd37fcddb Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:29 +0100 Subject: [PATCH 0148/1519] staging:iio:adc: max1363 fix 2 raw sysfs issues. indio_dev->channels was accidentally removed thus preventing any sysfs registrations occuring for direct reading. That hid the other issue. Unfortunately the incorrect handling leads to misspresentation of data in sysfs reads. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/max1363_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 72b0917412e..d93b7a917b9 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -255,7 +255,7 @@ static int max1363_read_raw(struct iio_dev *indio_dev, switch (m) { case 0: ret = max1363_read_single_chan(indio_dev, chan, val, m); - if (ret) + if (ret < 0) return ret; return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): @@ -1295,6 +1295,8 @@ static int __devinit max1363_probe(struct i2c_client *client, indio_dev->info = st->chip_info->info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = st->chip_info->channels; + indio_dev->num_channels = st->chip_info->num_channels; ret = max1363_initial_setup(st); if (ret < 0) goto error_free_available_scan_masks; From cc2439fdecb85f27866cab0ae1cbf21a9b61c423 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:30 +0100 Subject: [PATCH 0149/1519] staging:iio:core simplify and fix a bug in iio_device_(un)register_event_set. The unwinding index was j, not i and it is much simpler to do these as a single loop unwinding those elements necessary in before jumping to the error handler. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 19819e7578c..7ee4186c4df 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1061,7 +1061,7 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) if (ret) { dev_err(&dev_info->dev, "Could not get chrdev interface\n"); - goto error_free_setup_ev_ints; + goto error_free_setup_event_lines; } dev_set_drvdata(&dev_info->event_interfaces[i].dev, @@ -1077,31 +1077,33 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) if (ret) { dev_err(&dev_info->dev, "Failed to register sysfs for event attrs"); - goto error_remove_sysfs_interfaces; + iio_free_ev_int(&dev_info->event_interfaces[i]); + goto error_free_setup_event_lines; } - } - - for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { ret = __iio_add_event_config_attrs(dev_info, i); - if (ret) - goto error_unregister_config_attrs; + if (ret) { + if (dev_info->info->event_attrs != NULL) + sysfs_remove_group(&dev_info + ->event_interfaces[i] + .dev.kobj, + &dev_info->info + ->event_attrs[i]); + iio_free_ev_int(&dev_info->event_interfaces[i]); + goto error_free_setup_event_lines; + } } return 0; -error_unregister_config_attrs: - for (j = 0; j < i; j++) - __iio_remove_event_config_attrs(dev_info, i); - i = dev_info->info->num_interrupt_lines - 1; -error_remove_sysfs_interfaces: - for (j = 0; j < i; j++) +error_free_setup_event_lines: + for (j = 0; j < i; j++) { + __iio_remove_event_config_attrs(dev_info, j); if (dev_info->info->event_attrs != NULL) sysfs_remove_group(&dev_info - ->event_interfaces[j].dev.kobj, - &dev_info->info->event_attrs[j]); -error_free_setup_ev_ints: - for (j = 0; j < i; j++) + ->event_interfaces[j].dev.kobj, + &dev_info->info->event_attrs[j]); iio_free_ev_int(&dev_info->event_interfaces[j]); + } kfree(dev_info->event_interfaces); error_ret: @@ -1120,10 +1122,8 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) sysfs_remove_group(&dev_info ->event_interfaces[i].dev.kobj, &dev_info->info->event_attrs[i]); - } - - for (i = 0; i < dev_info->info->num_interrupt_lines; i++) iio_free_ev_int(&dev_info->event_interfaces[i]); + } kfree(dev_info->event_interfaces); } From 4266868c9cc8abebdad4b570d2df65a71ad46e03 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:31 +0100 Subject: [PATCH 0150/1519] staging:iio: sysfs.h remove unused val2 and dead macro. Vivien pointed out that 99e5dc45b854b4b661044e807905152911ed3fdb removed the IIO_DEVICE_ATTR_2 macro but didn't clean up the other macros that used it. As it turns out, no one is using val2 in tree, so lets scrap that until it is needed. Signed-off-by: Jonathan Cameron Reported-by: Vivien Didelot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/sysfs.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index dd79b584421..203ee83f992 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -18,13 +18,11 @@ * struct iio_dev_attr - iio specific device attribute * @dev_attr: underlying device attribute * @address: associated register address - * @val2: secondary attribute value * @l: list head for maintaining list of dynamically created attrs. */ struct iio_dev_attr { struct device_attribute dev_attr; int address; - int val2; struct list_head l; struct iio_chan_spec const *c; }; @@ -64,10 +62,6 @@ struct iio_const_attr { struct iio_dev_attr iio_dev_attr_##_vname \ = IIO_ATTR(_name, _mode, _show, _store, _addr) -#define IIO_DEVICE_ATTR_2(_name, _mode, _show, _store, _addr, _val2) \ - struct iio_dev_attr iio_dev_attr_##_name \ - = IIO_ATTR_2(_name, _mode, _show, _store, _addr, _val2) - #define IIO_CONST_ATTR(_name, _string) \ struct iio_const_attr iio_const_attr_##_name \ = { .string = _string, \ From 8df322385a7e253672dc5077c11dc1a6219d25cc Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:32 +0100 Subject: [PATCH 0151/1519] staging:iio:addac:adt7316 make interrupt mask sane. Coccinelle found this one. I'm not certain what the intent is, but this fix makes no functional changes. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 637316f79f7..c828b6f0a28 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -203,7 +203,7 @@ struct adt7316_chip_info { #define ADT7316_TEMP_INT_MASK 0x1F #define ADT7516_AIN_INT_MASK 0xE0 #define ADT7316_TEMP_AIN_INT_MASK \ - (ADT7316_TEMP_INT_MASK | ADT7316_TEMP_INT_MASK) + (ADT7316_TEMP_INT_MASK) /* * struct adt7316_chip_info - chip specifc information From 0cbb2b53fb57b002d0511226f3ad001569be9c66 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:33 +0100 Subject: [PATCH 0152/1519] staging:iio:dac:ad5504 dereferencing just freed st in error path. Introduced when I did the iio_chan_spec conversion. Detected by smatch. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5504.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 1915f459868..88512dd6450 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -338,7 +338,7 @@ error_free_dev: iio_free_device(indio_dev); error_disable_reg: if (!IS_ERR(reg)) - regulator_disable(st->reg); + regulator_disable(reg); error_put_reg: if (!IS_ERR(reg)) regulator_put(reg); From 70a876c59007ddb166a36c1073f45633bef1513b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:34 +0100 Subject: [PATCH 0153/1519] staging:iio:accel:adis16201 overflow tx buffer. Smatch caught bug. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 66e708ddf8b..a745d5debc2 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -38,10 +38,12 @@ static int adis16201_read_ring_data(struct iio_dev *indio_dev, u8 *rx) xfers[i].cs_change = 1; xfers[i].len = 2; xfers[i].delay_usecs = 20; - xfers[i].tx_buf = st->tx + 2 * i; - st->tx[2 * i] = ADIS16201_READ_REG(ADIS16201_SUPPLY_OUT + - 2 * i); - st->tx[2 * i + 1] = 0; + if (i < ADIS16201_OUTPUTS) { + xfers[i].tx_buf = st->tx + 2 * i; + st->tx[2 * i] = ADIS16201_READ_REG(ADIS16201_SUPPLY_OUT + + 2 * i); + st->tx[2 * i + 1] = 0; + } if (i >= 1) xfers[i].rx_buf = rx + 2 * (i - 1); spi_message_add_tail(&xfers[i], &msg); From f7256877c777d08f3af445840d94e37b11038fe2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:35 +0100 Subject: [PATCH 0154/1519] staging:iio: dummy sysfs group for autogenerated base directories. Needed to ensure the reference counting is correct. Temporary fix whilst discussions are ongoing. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 7ee4186c4df..8bee56250a9 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -725,19 +725,29 @@ static ssize_t iio_show_dev_name(struct device *dev, static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); +static struct attribute *iio_base_dummy_attrs[] = { + NULL +}; +static struct attribute_group iio_base_dummy_group = { + .attrs = iio_base_dummy_attrs, +}; + static int iio_device_register_sysfs(struct iio_dev *dev_info) { int i, ret = 0; struct iio_dev_attr *p, *n; - if (dev_info->info->attrs) { + if (dev_info->info->attrs) ret = sysfs_create_group(&dev_info->dev.kobj, dev_info->info->attrs); - if (ret) { - dev_err(dev_info->dev.parent, - "Failed to register sysfs hooks\n"); - goto error_ret; - } + else + ret = sysfs_create_group(&dev_info->dev.kobj, + &iio_base_dummy_group); + + if (ret) { + dev_err(dev_info->dev.parent, + "Failed to register sysfs hooks\n"); + goto error_ret; } /* @@ -753,7 +763,7 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) if (ret < 0) goto error_clear_attrs; } - if (dev_info->name) { + if (dev_info->name) { ret = sysfs_add_file_to_group(&dev_info->dev.kobj, &dev_attr_name.attr, NULL); @@ -770,6 +780,8 @@ error_clear_attrs: } if (dev_info->info->attrs) sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); + else + sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group); error_ret: return ret; @@ -790,6 +802,8 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info) if (dev_info->info->attrs) sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); + else + sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group); } /* Return a negative errno on failure */ From 9076faa9af99e6eb69fb8939b97ab701d14b3145 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:36 +0100 Subject: [PATCH 0155/1519] staging:iio: in case of buggy drivers avoid using undefined mask. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 8bee56250a9..e8ad648de3d 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -958,6 +958,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, break; default: printk(KERN_INFO "currently unhandled type of event\n"); + continue; } ret = __iio_add_chan_devattr(postfix, NULL, From 705099a763000872ae1a7ffda6b0433d56b55a6c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:37 +0100 Subject: [PATCH 0156/1519] staging:iio:various Stop drivers putting sysfs attributes in a directory named after the device. No idea how this particularly 'quirk' got in there in the first place. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dds/ad9852.c | 1 - drivers/staging/iio/dds/ad9910.c | 1 - drivers/staging/iio/dds/ad9951.c | 1 - drivers/staging/iio/resolver/ad2s1210.c | 1 - drivers/staging/iio/resolver/ad2s90.c | 1 - 5 files changed, 5 deletions(-) diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index 0184585425d..86722657e7c 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c @@ -217,7 +217,6 @@ static struct attribute *ad9852_attributes[] = { }; static const struct attribute_group ad9852_attribute_group = { - .name = DRV_NAME, .attrs = ad9852_attributes, }; diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index 0fa217f7b90..33585533a0b 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c @@ -352,7 +352,6 @@ static struct attribute *ad9910_attributes[] = { }; static const struct attribute_group ad9910_attribute_group = { - .name = DRV_NAME, .attrs = ad9910_attributes, }; diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index d361d1f125d..6c18e24d0f6 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c @@ -161,7 +161,6 @@ static struct attribute *ad9951_attributes[] = { }; static const struct attribute_group ad9951_attribute_group = { - .name = DRV_NAME, .attrs = ad9951_attributes, }; diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ecaf7bb790f..53cb031b04d 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -639,7 +639,6 @@ static struct attribute *ad2s1210_attributes[] = { }; static const struct attribute_group ad2s1210_attribute_group = { - .name = DRV_NAME, .attrs = ad2s1210_attributes, }; diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 166e2414ac8..43a66d46d00 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -58,7 +58,6 @@ static struct attribute *ad2s90_attributes[] = { }; static const struct attribute_group ad2s90_attribute_group = { - .name = DRV_NAME, .attrs = ad2s90_attributes, }; From de1874b7876e5423e9b5f5e876c48eaa8d800f44 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:55:38 +0100 Subject: [PATCH 0157/1519] staging:iio:documentation trivial typo fix Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/sysfs-bus-iio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index 467c49a4725..5f99f88d1b2 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -2,7 +2,7 @@ What: /sys/bus/iio/devices/deviceX KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: - Hardware chip or device accessed by on communication port. + Hardware chip or device accessed by one communication port. Corresponds to a grouping of sensor channels. X is the IIO index of the device. From deda386deb537dd2c8ec129bb53c1ffe57e827f7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:35 +0100 Subject: [PATCH 0158/1519] staging:iio:trivial sparse related cleanups. Getting rid of messages that make it harder to spot important issues. Some code removed that will be useful one day. Can put it back then. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/sca3000_ring.c | 68 ------------------------ drivers/staging/iio/adc/ad7150.c | 2 + drivers/staging/iio/dac/ad5791.c | 1 - drivers/staging/iio/light/tsl2563.c | 2 +- drivers/staging/iio/light/tsl2583.c | 4 +- drivers/staging/iio/meter/ade7854.c | 2 +- 6 files changed, 6 insertions(+), 73 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index a704c75fffc..3e608619412 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -226,74 +226,6 @@ static IIO_DEVICE_ATTR(75_percent, S_IRUGO | S_IWUSR, sca3000_set_ring_int, SCA3000_INT_MASK_RING_THREE_QUARTER); - -/** - * sca3000_show_ring_bpse() -sysfs function to query bits per sample from ring - * @dev: ring buffer device - * @attr: this device attribute - * @buf: buffer to write to - **/ -static ssize_t sca3000_show_ring_bpse(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int len = 0, ret; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - struct iio_dev *indio_dev = ring->indio_dev; - struct sca3000_state *st = iio_priv(indio_dev); - - mutex_lock(&st->lock); - ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1); - if (ret) - goto error_ret; - if (st->rx[0] & SCA3000_RING_BUF_8BIT) - len = sprintf(buf, "s8/8\n"); - else - len = sprintf(buf, "s11/16\n"); -error_ret: - mutex_unlock(&st->lock); - - return ret ? ret : len; -} - -/** - * sca3000_store_ring_bpse() - bits per scan element - * @dev: ring buffer device - * @attr: attribute called from - * @buf: input from userspace - * @len: length of input - **/ -static ssize_t sca3000_store_ring_bpse(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - struct iio_dev *indio_dev = ring->indio_dev; - struct sca3000_state *st = iio_priv(indio_dev); - int ret; - - mutex_lock(&st->lock); - - ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1); - if (ret) - goto error_ret; - if (sysfs_streq(buf, "s8/8")) { - ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, - st->rx[0] | SCA3000_RING_BUF_8BIT); - st->bpse = 8; - } else if (sysfs_streq(buf, "s11/16")) { - ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, - st->rx[0] & ~SCA3000_RING_BUF_8BIT); - st->bpse = 11; - } else - ret = -EINVAL; -error_ret: - mutex_unlock(&st->lock); - - return ret ? ret : len; -} - static ssize_t sca3000_show_buffer_scale(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 04017ef6688..917fb2fa0de 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -617,6 +617,8 @@ static IIO_DEV_ATTR_POWERDOWN_TIMER(S_IRUGO | S_IWUSR, ad7150_store_powerdown_timer); static struct attribute *ad7150_attributes[] = { + &iio_dev_attr_available_conversion_modes.dev_attr.attr, + &iio_dev_attr_conversion_mode.dev_attr.attr, &iio_dev_attr_available_threshold_modes.dev_attr.attr, &iio_dev_attr_threshold_mode.dev_attr.attr, &iio_dev_attr_ch1_threshold.dev_attr.attr, diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 64770d2a1b4..5b00b70b3fe 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -381,7 +381,6 @@ error_put_reg_pos: if (!IS_ERR(reg_vdd)) regulator_put(reg_vdd); -error_ret: return ret; } diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index f25243b0847..bb96857f33f 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -697,7 +697,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client, struct tsl2563_platform_data *pdata = client->dev.platform_data; int err = 0; int ret; - u8 id; + u8 id = 0; indio_dev = iio_allocate_device(sizeof(*chip)); if (!indio_dev) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 5694610da1c..296d0ffa0b0 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -68,7 +68,7 @@ enum { TSL258X_CHIP_UNKNOWN = 0, TSL258X_CHIP_WORKING = 1, TSL258X_CHIP_SUSPENDED = 2 -} TSL258X_CHIP_WORKING_STATUS; +}; /* Per-device data */ struct taos_als_info { @@ -114,7 +114,7 @@ struct taos_lux { /* This structure is intentionally large to accommodate updates via sysfs. */ /* Sized to 11 = max 10 segments + 1 termination segment */ /* Assumption is is one and only one type of glass used */ -struct taos_lux taos_device_lux[11] = { +static struct taos_lux taos_device_lux[11] = { { 9830, 8520, 15729 }, { 12452, 10807, 23344 }, { 14746, 6383, 11705 }, diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index b82659f43bc..9b240ed858f 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -582,7 +582,7 @@ error_unreg_dev: iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); -error_ret: + return ret; } EXPORT_SYMBOL(ade7854_probe); From 7a6ff010e5f423822145e728a57744e5d0f18e2f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:36 +0100 Subject: [PATCH 0159/1519] staging:iio:imu:adis16400: use strtobool for reset sysfs and don't assign unused tx members. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_core.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index a2c3b67dcbd..4feee26c6f6 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -150,8 +150,6 @@ static int adis16400_spi_read_reg_16(struct iio_dev *indio_dev, mutex_lock(&st->buf_lock); st->tx[0] = ADIS16400_READ_REG(lower_reg_address); st->tx[1] = 0; - st->tx[2] = 0; - st->tx[3] = 0; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); @@ -240,17 +238,18 @@ static ssize_t adis16400_write_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); + bool val; + int ret; - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return adis16400_reset(indio_dev); - } - return -1; + ret = strtobool(buf, &val); + if (ret < 0) + return ret; + if (val) + ret = adis16400_reset(dev_get_drvdata(dev)); + if (ret < 0) + return ret; + + return len; } int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) From 214320b6ec0de0f98b5f929a1738363872b0178d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:37 +0100 Subject: [PATCH 0160/1519] staging:iio:imu:adis16400 remove now unused headers. These should really have gone away with the code that needed them. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_ring.c | 7 ------- drivers/staging/iio/imu/adis16400_trigger.c | 6 ------ 2 files changed, 13 deletions(-) diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 3612373dded..556d928fdcd 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -1,18 +1,11 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../accel/accel.h" #include "../trigger.h" diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c index c6ec41a02a6..ce981731a34 100644 --- a/drivers/staging/iio/imu/adis16400_trigger.c +++ b/drivers/staging/iio/imu/adis16400_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16400.h" From d29f73db791098179af90e6a5b1df41f941b32cd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:38 +0100 Subject: [PATCH 0161/1519] staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure. Right now this results in increased code, but I still think it is worth doing to avoid replication across instances of drivers etc and move as much stuff as possible to constant. Ops structure is optional for the occasional driver that uses none of it (currently only the ad7793). Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_trigger.c | 8 +++-- drivers/staging/iio/accel/adis16203_trigger.c | 8 +++-- drivers/staging/iio/accel/adis16204_trigger.c | 8 +++-- drivers/staging/iio/accel/adis16209_trigger.c | 8 +++-- drivers/staging/iio/accel/adis16240_trigger.c | 8 +++-- drivers/staging/iio/accel/lis3l02dq_ring.c | 10 ++++-- drivers/staging/iio/gyro/adis16260_trigger.c | 8 +++-- drivers/staging/iio/imu/adis16400_trigger.c | 8 +++-- drivers/staging/iio/industrialio-trigger.c | 16 ++++----- drivers/staging/iio/meter/ade7758_trigger.c | 10 ++++-- drivers/staging/iio/trigger.h | 36 ++++++++++++------- .../staging/iio/trigger/iio-trig-bfin-timer.c | 6 +++- drivers/staging/iio/trigger/iio-trig-gpio.c | 6 +++- .../iio/trigger/iio-trig-periodic-rtc.c | 7 +++- drivers/staging/iio/trigger/iio-trig-sysfs.c | 6 +++- 15 files changed, 109 insertions(+), 44 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_trigger.c b/drivers/staging/iio/accel/adis16201_trigger.c index 3a95c083b45..7c853a6f700 100644 --- a/drivers/staging/iio/accel/adis16201_trigger.c +++ b/drivers/staging/iio/accel/adis16201_trigger.c @@ -23,6 +23,11 @@ static int adis16201_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16201_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16201_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16201_data_rdy_trigger_set_state, +}; + int adis16201_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -41,9 +46,8 @@ int adis16201_probe_trigger(struct iio_dev *indio_dev) if (ret) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16201_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16201_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/accel/adis16203_trigger.c b/drivers/staging/iio/accel/adis16203_trigger.c index 3caf3e8bc9d..9ea1c1e1e1c 100644 --- a/drivers/staging/iio/accel/adis16203_trigger.c +++ b/drivers/staging/iio/accel/adis16203_trigger.c @@ -24,6 +24,11 @@ static int adis16203_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16203_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16203_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16203_data_rdy_trigger_set_state, +}; + int adis16203_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -44,9 +49,8 @@ int adis16203_probe_trigger(struct iio_dev *indio_dev) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16203_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16203_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/accel/adis16204_trigger.c b/drivers/staging/iio/accel/adis16204_trigger.c index 01f73b9b888..bd6d293a818 100644 --- a/drivers/staging/iio/accel/adis16204_trigger.c +++ b/drivers/staging/iio/accel/adis16204_trigger.c @@ -24,6 +24,11 @@ static int adis16204_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16204_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16204_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16204_data_rdy_trigger_set_state, +}; + int adis16204_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -44,9 +49,8 @@ int adis16204_probe_trigger(struct iio_dev *indio_dev) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16204_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16204_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/accel/adis16209_trigger.c b/drivers/staging/iio/accel/adis16209_trigger.c index 6df7b47ec7b..4c6df9e564f 100644 --- a/drivers/staging/iio/accel/adis16209_trigger.c +++ b/drivers/staging/iio/accel/adis16209_trigger.c @@ -33,6 +33,11 @@ static int adis16209_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16209_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16209_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16209_data_rdy_trigger_set_state, +}; + int adis16209_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -52,9 +57,8 @@ int adis16209_probe_trigger(struct iio_dev *indio_dev) if (ret) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16209_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16209_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/accel/adis16240_trigger.c b/drivers/staging/iio/accel/adis16240_trigger.c index 17135fc33c9..0c753389643 100644 --- a/drivers/staging/iio/accel/adis16240_trigger.c +++ b/drivers/staging/iio/accel/adis16240_trigger.c @@ -33,6 +33,11 @@ static int adis16240_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16240_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16240_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16240_data_rdy_trigger_set_state, +}; + int adis16240_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -53,9 +58,8 @@ int adis16240_probe_trigger(struct iio_dev *indio_dev) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16240_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16240_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 8d5c8ac7db5..5795f82c1f1 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -306,6 +306,12 @@ static int lis3l02dq_trig_try_reen(struct iio_trigger *trig) return 0; } +static const struct iio_trigger_ops lis3l02dq_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state, + .try_reenable = &lis3l02dq_trig_try_reen, +}; + int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -318,10 +324,8 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) } st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &lis3l02dq_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state; - st->trig->try_reenable = &lis3l02dq_trig_try_reen; ret = iio_trigger_register(st->trig); if (ret) goto error_free_trig; diff --git a/drivers/staging/iio/gyro/adis16260_trigger.c b/drivers/staging/iio/gyro/adis16260_trigger.c index 01094d0e714..f2409615706 100644 --- a/drivers/staging/iio/gyro/adis16260_trigger.c +++ b/drivers/staging/iio/gyro/adis16260_trigger.c @@ -24,6 +24,11 @@ static int adis16260_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16260_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16260_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16260_data_rdy_trigger_set_state, +}; + int adis16260_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -46,9 +51,8 @@ int adis16260_probe_trigger(struct iio_dev *indio_dev) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &adis16260_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16260_data_rdy_trigger_set_state; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c index ce981731a34..3860d92f1ae 100644 --- a/drivers/staging/iio/imu/adis16400_trigger.c +++ b/drivers/staging/iio/imu/adis16400_trigger.c @@ -18,6 +18,11 @@ static int adis16400_data_rdy_trigger_set_state(struct iio_trigger *trig, return adis16400_set_irq(indio_dev, state); } +static const struct iio_trigger_ops adis16400_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &adis16400_data_rdy_trigger_set_state, +}; + int adis16400_probe_trigger(struct iio_dev *indio_dev) { int ret; @@ -39,9 +44,8 @@ int adis16400_probe_trigger(struct iio_dev *indio_dev) if (ret) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &adis16400_data_rdy_trigger_set_state; + st->trig->ops = &adis16400_trigger_ops; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 90ca2df23ea..513a7a04099 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -206,8 +206,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained); void iio_trigger_notify_done(struct iio_trigger *trig) { trig->use_count--; - if (trig->use_count == 0 && trig->try_reenable) - if (trig->try_reenable(trig)) { + if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable) + if (trig->ops->try_reenable(trig)) { /* Missed and interrupt so launch new poll now */ iio_trigger_poll(trig, 0); } @@ -234,8 +234,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, ret = request_threaded_irq(pf->irq, pf->h, pf->thread, pf->type, pf->name, pf); - if (trig->set_trigger_state && notinuse) - ret = trig->set_trigger_state(trig, true); + if (trig->ops && trig->ops->set_trigger_state && notinuse) + ret = trig->ops->set_trigger_state(trig, true); return ret; } @@ -249,8 +249,8 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, = (bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1); - if (trig->set_trigger_state && no_other_users) { - ret = trig->set_trigger_state(trig, false); + if (trig->ops && trig->ops->set_trigger_state && no_other_users) { + ret = trig->ops->set_trigger_state(trig, false); if (ret) goto error_ret; } @@ -358,8 +358,8 @@ static ssize_t iio_trigger_write_current(struct device *dev, return ret; } - if (trig && trig->validate_device) { - ret = trig->validate_device(trig, dev_info); + if (trig && trig->ops && trig->ops->validate_device) { + ret = trig->ops->validate_device(trig, dev_info); if (ret) return ret; } diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c index a5c3248151e..4c451c26efb 100644 --- a/drivers/staging/iio/meter/ade7758_trigger.c +++ b/drivers/staging/iio/meter/ade7758_trigger.c @@ -57,6 +57,12 @@ static int ade7758_trig_try_reen(struct iio_trigger *trig) return 0; } +static const struct iio_trigger_ops ade7758_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &ade7758_data_rdy_trigger_set_state, + .try_reenable = &ade7758_trig_try_reen, +}; + int ade7758_probe_trigger(struct iio_dev *indio_dev) { struct ade7758_state *st = iio_priv(indio_dev); @@ -79,10 +85,8 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) goto error_free_trig; st->trig->dev.parent = &st->us->dev; - st->trig->owner = THIS_MODULE; + st->trig->ops = &ade7758_trigger_ops; st->trig->private_data = indio_dev; - st->trig->set_trigger_state = &ade7758_data_rdy_trigger_set_state; - st->trig->try_reenable = &ade7758_trig_try_reen; ret = iio_trigger_register(st->trig); /* select default trigger */ diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index e0b58ed749b..325e086e9e6 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -15,6 +15,27 @@ struct iio_subirq { bool enabled; }; +/** + * struct iio_trigger_ops - operations structure for an iio_trigger. + * @owner: used to monitor usage count of the trigger. + * @set_trigger_state: switch on/off the trigger on demand + * @try_reenable: function to reenable the trigger when the + * use count is zero (may be NULL) + * @validate_device: function to validate the device when the + * current trigger gets changed. + * + * This is typically static const within a driver and shared by + * instances of a given device. + **/ +struct iio_trigger_ops { + struct module *owner; + int (*set_trigger_state)(struct iio_trigger *trig, bool state); + int (*try_reenable)(struct iio_trigger *trig); + int (*validate_device)(struct iio_trigger *trig, + struct iio_dev *indio_dev); +}; + + /** * struct iio_trigger - industrial I/O trigger device * @@ -26,11 +47,6 @@ struct iio_subirq { * @alloc_list: [DRIVER] used for driver specific trigger list * @owner: [DRIVER] used to monitor usage count of the trigger. * @use_count: use count for the trigger - * @set_trigger_state: [DRIVER] switch on/off the trigger on demand - * @try_reenable: function to reenable the trigger when the - * use count is zero (may be NULL) - * @validate_device: function to validate the device when the - * current trigger gets changed. * @subirq_chip: [INTERN] associate 'virtual' irq chip. * @subirq_base: [INTERN] base number for irqs provided by trigger. * @subirqs: [INTERN] information about the 'child' irqs. @@ -38,6 +54,7 @@ struct iio_subirq { * @pool_lock: [INTERN] protection of the irq pool. **/ struct iio_trigger { + const struct iio_trigger_ops *ops; int id; const char *name; struct device dev; @@ -48,11 +65,6 @@ struct iio_trigger { struct module *owner; int use_count; - int (*set_trigger_state)(struct iio_trigger *trig, bool state); - int (*try_reenable)(struct iio_trigger *trig); - int (*validate_device)(struct iio_trigger *trig, - struct iio_dev *indio_dev); - struct irq_chip subirq_chip; int subirq_base; @@ -93,12 +105,12 @@ static inline struct iio_trigger *to_iio_trigger(struct device *d) static inline void iio_put_trigger(struct iio_trigger *trig) { put_device(&trig->dev); - module_put(trig->owner); + module_put(trig->ops->owner); }; static inline void iio_get_trigger(struct iio_trigger *trig) { - __module_get(trig->owner); + __module_get(trig->ops->owner); get_device(&trig->dev); }; diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 4f172956558..243f38f80de 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -143,6 +143,10 @@ static int iio_bfin_tmr_get_number(int irq) return -ENODEV; } +static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = { + owner = THIS_MODULE, +}; + static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev) { struct bfin_tmr_state *st; @@ -175,7 +179,7 @@ static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev) } st->trig->private_data = st; - st->trig->owner = THIS_MODULE; + st->trig->ops = &iio_bfin_tmr_trigger_ops; st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups; ret = iio_trigger_register(st->trig); if (ret) diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c index f1fb795e641..f2a65598162 100644 --- a/drivers/staging/iio/trigger/iio-trig-gpio.c +++ b/drivers/staging/iio/trigger/iio-trig-gpio.c @@ -47,6 +47,10 @@ static irqreturn_t iio_gpio_trigger_poll(int irq, void *private) return IRQ_HANDLED; } +static const struct iio_trigger_ops iio_gpio_trigger_ops = { + .owner = THIS_MODULE, +}; + static int iio_gpio_trigger_probe(struct platform_device *pdev) { struct iio_gpio_trigger_info *trig_info; @@ -81,7 +85,7 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev) } trig->private_data = trig_info; trig_info->irq = irq; - trig->owner = THIS_MODULE; + trig->ops = &iio_gpio_trigger_ops; ret = request_irq(irq, iio_gpio_trigger_poll, irqflags, trig->name, trig); if (ret) { diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 01cf7e20b51..d35d085da94 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -96,6 +96,11 @@ static void iio_prtc_trigger_poll(void *private_data) iio_trigger_poll(private_data, 0); } +static const struct iio_trigger_ops iio_prtc_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = &iio_trig_periodic_rtc_set_state, +}; + static int iio_trig_periodic_rtc_probe(struct platform_device *dev) { char **pdata = dev->dev.platform_data; @@ -121,7 +126,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev) } trig->private_data = trig_info; trig->owner = THIS_MODULE; - trig->set_trigger_state = &iio_trig_periodic_rtc_set_state; + trig->ops = &iio_prtc_trigger_ops; /* RTC access */ trig_info->rtc = rtc_class_open(pdata[i]); diff --git a/drivers/staging/iio/trigger/iio-trig-sysfs.c b/drivers/staging/iio/trigger/iio-trig-sysfs.c index 47248cd1fa0..346b30c2f7f 100644 --- a/drivers/staging/iio/trigger/iio-trig-sysfs.c +++ b/drivers/staging/iio/trigger/iio-trig-sysfs.c @@ -107,6 +107,10 @@ static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = { NULL }; +static const struct iio_trigger_ops iio_sysfs_trigger_ops = { + .owner = THIS_MODULE, +}; + static int iio_sysfs_trigger_probe(int id) { struct iio_sysfs_trig *t; @@ -135,7 +139,7 @@ static int iio_sysfs_trigger_probe(int id) } t->trig->dev.groups = iio_sysfs_trigger_attr_groups; - t->trig->owner = THIS_MODULE; + t->trig->ops = &iio_sysfs_trigger_ops; t->trig->dev.parent = &iio_sysfs_trig_dev; ret = iio_trigger_register(t->trig); From bc8ea46b5547b9827990abd356d821d4bc950911 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:39 +0100 Subject: [PATCH 0162/1519] staging:iio:gyro:adis16260 remove some unused headers These should have gone with the iio_chan_spec conversion patch. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16260_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index f2d43cfcc49..bc45228d070 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -21,8 +21,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "../adc/adc.h" -#include "gyro.h" #include "adis16260.h" From b066b4f89bebb13febdbe179f9000d68a02f0996 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:40 +0100 Subject: [PATCH 0163/1519] staging:iio:imu:adis16400 remove unused headers. These should have gone with the iio_chan_spec conversion. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 4feee26c6f6..8b8e8a3b769 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -29,11 +29,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "../accel/accel.h" -#include "../adc/adc.h" -#include "../gyro/gyro.h" -#include "../magnetometer/magnet.h" - #include "adis16400.h" #define DRIVER_NAME "adis16400" From a5e7363ca46d58eafa904130d801b23c59bd1ec4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:41 +0100 Subject: [PATCH 0164/1519] staging:iio:gyro:adis16130 drop control of adc resolution. There is no clear use case for this functionality in a driver that only supports slow reading via sysfs. The interface use was non compliant with the abi motiving it being dropped. It can go back in if anyone ever implements buffered reading support for this device. Then it will be controlled as part of the buffering abi where this should indeed be correctly supported. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16130_core.c | 76 ++--------------------- 1 file changed, 4 insertions(+), 72 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index caf067ce98c..6d3cd6c2bff 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -41,34 +41,15 @@ /** * struct adis16130_state - device instance specific data * @us: actual spi_device to write data - * @mode: 24 bits (1) or 16 bits (0) * @buf_lock: mutex to protect tx and rx * @buf: unified tx/rx buffer **/ struct adis16130_state { struct spi_device *us; - u32 mode; struct mutex buf_lock; u8 buf[4] ____cacheline_aligned; }; -static int adis16130_spi_write(struct device *dev, u8 reg_addr, - u8 val) -{ - int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct adis16130_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - st->buf[0] = reg_addr; - st->buf[1] = val; - - ret = spi_write(st->us, st->buf, 2); - mutex_unlock(&st->buf_lock); - - return ret; -} - static int adis16130_spi_read(struct device *dev, u8 reg_addr, u32 *val) { @@ -79,6 +60,7 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr, struct spi_transfer xfer = { .tx_buf = st->buf, .rx_buf = st->buf, + .len = 4, }; mutex_lock(&st->buf_lock); @@ -86,22 +68,13 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr, st->buf[0] = ADIS16130_CON_RD | reg_addr; st->buf[1] = st->buf[2] = st->buf[3] = 0; - if (st->mode) - xfer.len = 4; - else - xfer.len = 3; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); ret = spi_sync(st->us, &msg); - if (ret == 0) { - if (st->mode) - *val = (st->buf[1] << 16) | - (st->buf[2] << 8) | - st->buf[3]; - else - *val = (st->buf[1] << 8) | st->buf[2]; - } + ret = spi_read(st->us, st->buf, 4); + if (ret == 0) + *val = (st->buf[1] << 16) | (st->buf[2] << 8) | st->buf[3]; mutex_unlock(&st->buf_lock); return ret; @@ -127,54 +100,14 @@ static ssize_t adis16130_val_read(struct device *dev, return ret; } -static ssize_t adis16130_bitsmode_read(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct adis16130_state *st = iio_priv(indio_dev); - - if (st->mode == 1) - return sprintf(buf, "s24\n"); - else - return sprintf(buf, "s16\n"); -} - -static ssize_t adis16130_bitsmode_write(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - int ret; - u8 val; - - if (sysfs_streq(buf, "s16")) - val = 0; - else if (sysfs_streq(buf, "s24")) - val = 1; - else - return -EINVAL; - - ret = adis16130_spi_write(dev, ADIS16130_MODE, val); - - return ret ? ret : len; -} static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16130_val_read, NULL, ADIS16130_TEMPDATA); static IIO_DEV_ATTR_GYRO_Z(adis16130_val_read, ADIS16130_RATEDATA); -static IIO_DEVICE_ATTR(gyro_z_type, S_IWUSR | S_IRUGO, adis16130_bitsmode_read, - adis16130_bitsmode_write, - ADIS16130_MODE); - -static IIO_CONST_ATTR(gyro_z_type_available, "s16 s24"); - static struct attribute *adis16130_attributes[] = { &iio_dev_attr_temp_raw.dev_attr.attr, &iio_dev_attr_gyro_z_raw.dev_attr.attr, - &iio_dev_attr_gyro_z_type.dev_attr.attr, - &iio_const_attr_gyro_z_type_available.dev_attr.attr, NULL }; @@ -208,7 +141,6 @@ static int __devinit adis16130_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16130_info; indio_dev->modes = INDIO_DIRECT_MODE; - st->mode = 1; ret = iio_device_register(indio_dev); if (ret) From 5b847ccbf52844a6a6ce95af45c0fd9f9e187c46 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:42 +0100 Subject: [PATCH 0165/1519] staging:iio:accel: usused header removals. Missing from the iio_chan_spec conversion patches. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 4 ---- drivers/staging/iio/accel/adis16201_ring.c | 1 - drivers/staging/iio/accel/adis16203_core.c | 3 --- drivers/staging/iio/accel/adis16203_ring.c | 1 - drivers/staging/iio/accel/adis16204_ring.c | 1 - drivers/staging/iio/accel/adis16209_core.c | 3 --- drivers/staging/iio/accel/adis16209_ring.c | 1 - drivers/staging/iio/accel/adis16240_core.c | 2 -- drivers/staging/iio/accel/adis16240_ring.c | 1 - drivers/staging/iio/accel/lis3l02dq_core.c | 2 -- drivers/staging/iio/accel/lis3l02dq_ring.c | 1 - drivers/staging/iio/accel/sca3000_core.c | 1 - drivers/staging/iio/accel/sca3000_ring.c | 1 - 13 files changed, 22 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 2fd01aecdf9..16b388bf899 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -18,10 +18,6 @@ #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" -#include "inclinometer.h" -#include "../adc/adc.h" - #include "adis16201.h" enum adis16201_chan { diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index a745d5debc2..30bac860397 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -10,7 +10,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "accel.h" #include "../trigger.h" #include "adis16201.h" diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index cf5d15da76a..a7c06b957be 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -16,10 +16,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "accel.h" -#include "inclinometer.h" #include "../ring_generic.h" -#include "../adc/adc.h" #include "adis16203.h" diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index d2c07c52746..7ca9c25ca1a 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -13,7 +13,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "accel.h" #include "../trigger.h" #include "adis16203.h" diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 852df06684d..537d4630231 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -13,7 +13,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "accel.h" #include "../trigger.h" #include "adis16204.h" diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index bec1fa8de9b..bd3d55714ed 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -18,9 +18,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" -#include "inclinometer.h" -#include "../adc/adc.h" #include "adis16209.h" diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 45017d3f02f..77b70e38f61 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -13,7 +13,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "accel.h" #include "../trigger.h" #include "adis16209.h" diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index aee8b69173c..237da463c67 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -21,8 +21,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" -#include "../adc/adc.h" #include "adis16240.h" diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index c812a34daca..3f1e159af2e 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -13,7 +13,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "accel.h" #include "../trigger.h" #include "adis16240.h" diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index a29dfd27d44..83ec286c477 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -26,8 +26,6 @@ #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" - #include "lis3l02dq.h" /* At the moment the spi framework doesn't allow global setting of cs_change. diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 5795f82c1f1..7305c78962e 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -12,7 +12,6 @@ #include "../sysfs.h" #include "../ring_sw.h" #include "../kfifo_buf.h" -#include "accel.h" #include "../trigger.h" #include "lis3l02dq.h" diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 603f5bca797..3c637b90e4f 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -22,7 +22,6 @@ #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" #include "sca3000.h" enum sca3000_variant { diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 3e608619412..6ce8bf58ba8 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -24,7 +24,6 @@ #include "../sysfs.h" #include "../ring_generic.h" #include "../ring_hw.h" -#include "accel.h" #include "sca3000.h" /* RFC / future work From cdf387096e34e71eeb6238183dd1856fd94a4e38 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:43 +0100 Subject: [PATCH 0166/1519] staging:iio:adc: unused header removals. More headers now not needed after iio_chan_spec conversions. A couple of drivers were using helpers from adc.h. Given these were trivial, they are pushed down into the drivers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7298_core.c | 1 - drivers/staging/iio/adc/ad7476_core.c | 1 - drivers/staging/iio/adc/ad7606_core.c | 1 - drivers/staging/iio/adc/ad7780.c | 1 - drivers/staging/iio/adc/ad7793.c | 1 - drivers/staging/iio/adc/ad7887_core.c | 2 +- drivers/staging/iio/adc/ad799x_core.c | 13 +++++++++---- drivers/staging/iio/adc/max1363_core.c | 23 +++++++++++++++++------ 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index b8e4ae29b0b..21d1931edb3 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -18,7 +18,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "adc.h" #include "ad7298.h" diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index c21089894d2..f2fdd48303e 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -17,7 +17,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "adc.h" #include "ad7476.h" diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 459371ae4dc..dcdb180d7e7 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -20,7 +20,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "adc.h" #include "ad7606.h" diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index e0c7b6cc05c..f90cdeacadf 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -20,7 +20,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "adc.h" #include "ad7780.h" diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 90f6c039d6c..ab6f10932be 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -22,7 +22,6 @@ #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "adc.h" #include "ad7793.h" diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 3d9121e5c37..a7da9e68eba 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "adc.h" + #include "ad7887.h" diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 92cfe2e3ea4..d42d61d6063 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -34,9 +34,8 @@ #include "../iio.h" #include "../sysfs.h" - #include "../ring_generic.h" -#include "adc.h" + #include "ad799x.h" /* @@ -336,8 +335,14 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) if (status & (1 << i)) iio_push_event(indio_dev, 0, i & 0x1 ? - IIO_EVENT_CODE_IN_HIGH_THRESH(i >> 1) : - IIO_EVENT_CODE_IN_LOW_THRESH(i >> 1), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING) : + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), iio_get_time_ns()); } diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index d93b7a917b9..9525aec5873 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -33,9 +33,8 @@ #include "../iio.h" #include "../sysfs.h" - #include "../ring_generic.h" -#include "adc.h" + #include "max1363.h" #define MAX1363_MODE_SINGLE(_num, _mask) { \ @@ -592,10 +591,22 @@ static int max1363_write_thresh(struct iio_dev *indio_dev, } static const int max1363_event_codes[] = { - IIO_EVENT_CODE_IN_LOW_THRESH(3), IIO_EVENT_CODE_IN_HIGH_THRESH(3), - IIO_EVENT_CODE_IN_LOW_THRESH(2), IIO_EVENT_CODE_IN_HIGH_THRESH(2), - IIO_EVENT_CODE_IN_LOW_THRESH(1), IIO_EVENT_CODE_IN_HIGH_THRESH(1), - IIO_EVENT_CODE_IN_LOW_THRESH(0), IIO_EVENT_CODE_IN_HIGH_THRESH(0) + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 0, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 1, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 2, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 3, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 0, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 1, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 2, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 3, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), }; static irqreturn_t max1363_event_handler(int irq, void *private) From e18ef34419c06b2327f1b9ed28e3cea7d73d03fa Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:44 +0100 Subject: [PATCH 0167/1519] staging:iio:inclinometer.h remove as now unused. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/inclinometer.h | 25 ------------------------ 1 file changed, 25 deletions(-) delete mode 100644 drivers/staging/iio/accel/inclinometer.h diff --git a/drivers/staging/iio/accel/inclinometer.h b/drivers/staging/iio/accel/inclinometer.h deleted file mode 100644 index faf73d7892e..00000000000 --- a/drivers/staging/iio/accel/inclinometer.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Inclinometer related attributes - */ -#include "../sysfs.h" - -#define IIO_DEV_ATTR_INCLI_X(_show, _addr) \ - IIO_DEVICE_ATTR(incli_x_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_INCLI_Y(_show, _addr) \ - IIO_DEVICE_ATTR(incli_y_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_INCLI_Z(_show, _addr) \ - IIO_DEVICE_ATTR(incli_z_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_INCLI_X_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(incli_x_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_INCLI_Y_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(incli_y_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_INCLI_Z_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(incli_z_offset, _mode, _show, _store, _addr) - -#define IIO_CONST_ATTR_INCLI_SCALE(_string) \ - IIO_CONST_ATTR(incli_scale, _string) From ce87c128b9fbf23ba23ac1d8991402b252b03c46 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:45 +0100 Subject: [PATCH 0168/1519] staging:iio:various header includes that should never have been. I will assume these were cut and pastes messup. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16260_ring.c | 1 - drivers/staging/iio/imu/adis16400_ring.c | 1 - drivers/staging/iio/meter/ade7758_ring.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index a4df8b32251..e9cff3b3ab7 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -13,7 +13,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "../accel/accel.h" #include "../trigger.h" #include "adis16260.h" diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 556d928fdcd..ef3847746ec 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -7,7 +7,6 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../accel/accel.h" #include "../trigger.h" #include "adis16400.h" diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index b89b7f882e8..e7a04b46517 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -21,7 +21,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_sw.h" -#include "../accel/accel.h" #include "../trigger.h" #include "ade7758.h" From 6dd7bcaae20a6880f3a07a2d7daa2cb464446d08 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:46 +0100 Subject: [PATCH 0169/1519] staging:iio:adc: header cleanup - remove unused. Clear out all the excessive includes in the *_ring.c files. Mixture of cut and paste bloat and things needed for code that has gone away. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7298_ring.c | 3 --- drivers/staging/iio/adc/ad7476_ring.c | 2 -- drivers/staging/iio/adc/ad7606_ring.c | 2 -- drivers/staging/iio/adc/ad7887_ring.c | 3 --- drivers/staging/iio/adc/ad799x_ring.c | 3 --- drivers/staging/iio/adc/max1363_ring.c | 4 ---- 6 files changed, 17 deletions(-) diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index a04c0335262..7423d4a9c0d 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -7,17 +7,14 @@ */ #include -#include #include #include -#include #include #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "ad7298.h" diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index a92fc5a1a60..86bbba87f32 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -11,14 +11,12 @@ #include #include #include -#include #include #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "ad7476.h" diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index a199bf48396..f8f574a52fd 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -10,13 +10,11 @@ #include #include #include -#include #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "ad7606.h" diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 0ac7c0b9d71..b77b120bdd1 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -8,17 +8,14 @@ */ #include -#include #include #include -#include #include #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "ad7887.h" diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 0376a826c26..d84efd65f6b 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -10,10 +10,8 @@ */ #include -#include #include #include -#include #include #include #include @@ -22,7 +20,6 @@ #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "ad799x.h" diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index f43befd1f77..696676fa25a 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -9,11 +9,8 @@ */ #include -#include #include #include -#include -#include #include #include @@ -21,7 +18,6 @@ #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" -#include "../sysfs.h" #include "max1363.h" From 779921683e6d907e5d2f8deb3c1296d6a1633c94 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:47 +0100 Subject: [PATCH 0170/1519] staging:iio:accel header housekeeping - remove unecessary includes. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 4 ---- drivers/staging/iio/accel/adis16201_trigger.c | 5 ----- drivers/staging/iio/accel/adis16203_ring.c | 7 ------- drivers/staging/iio/accel/adis16203_trigger.c | 6 ------ drivers/staging/iio/accel/adis16204_ring.c | 7 ------- drivers/staging/iio/accel/adis16204_trigger.c | 6 ------ drivers/staging/iio/accel/adis16209_ring.c | 7 ------- drivers/staging/iio/accel/adis16209_trigger.c | 6 ------ drivers/staging/iio/accel/adis16240_ring.c | 7 ------- drivers/staging/iio/accel/adis16240_trigger.c | 6 ------ drivers/staging/iio/accel/lis3l02dq_ring.c | 4 ---- drivers/staging/iio/accel/sca3000_ring.c | 2 -- 12 files changed, 67 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 30bac860397..9925785a9c8 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -1,14 +1,10 @@ #include -#include #include -#include #include #include #include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16201.h" diff --git a/drivers/staging/iio/accel/adis16201_trigger.c b/drivers/staging/iio/accel/adis16201_trigger.c index 7c853a6f700..f448258884c 100644 --- a/drivers/staging/iio/accel/adis16201_trigger.c +++ b/drivers/staging/iio/accel/adis16201_trigger.c @@ -1,13 +1,8 @@ #include -#include -#include -#include #include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16201.h" diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index 7ca9c25ca1a..049174d73b6 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -1,17 +1,10 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16203.h" diff --git a/drivers/staging/iio/accel/adis16203_trigger.c b/drivers/staging/iio/accel/adis16203_trigger.c index 9ea1c1e1e1c..50165f9ddc5 100644 --- a/drivers/staging/iio/accel/adis16203_trigger.c +++ b/drivers/staging/iio/accel/adis16203_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16203.h" diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 537d4630231..b1738562efb 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -1,17 +1,10 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16204.h" diff --git a/drivers/staging/iio/accel/adis16204_trigger.c b/drivers/staging/iio/accel/adis16204_trigger.c index bd6d293a818..55b661c98d2 100644 --- a/drivers/staging/iio/accel/adis16204_trigger.c +++ b/drivers/staging/iio/accel/adis16204_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16204.h" diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 77b70e38f61..7547ddb1460 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -1,17 +1,10 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16209.h" diff --git a/drivers/staging/iio/accel/adis16209_trigger.c b/drivers/staging/iio/accel/adis16209_trigger.c index 4c6df9e564f..8df8a9791d5 100644 --- a/drivers/staging/iio/accel/adis16209_trigger.c +++ b/drivers/staging/iio/accel/adis16209_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16209.h" diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 3f1e159af2e..9bb4ff80dbc 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -1,17 +1,10 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16240.h" diff --git a/drivers/staging/iio/accel/adis16240_trigger.c b/drivers/staging/iio/accel/adis16240_trigger.c index 0c753389643..13f1d142eea 100644 --- a/drivers/staging/iio/accel/adis16240_trigger.c +++ b/drivers/staging/iio/accel/adis16240_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16240.h" diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 7305c78962e..c53985e70b8 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -1,15 +1,11 @@ #include -#include #include #include -#include #include #include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../kfifo_buf.h" #include "../trigger.h" diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 6ce8bf58ba8..0b736dbe818 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -10,9 +10,7 @@ */ #include -#include #include -#include #include #include #include From 17ee97e5f30995baf00f490e3facfea9996630ab Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:48 +0100 Subject: [PATCH 0171/1519] staging:iio:gyro and meter: header housecleaning. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16260_ring.c | 7 ------- drivers/staging/iio/gyro/adis16260_trigger.c | 6 ------ drivers/staging/iio/meter/ade7758_ring.c | 8 -------- drivers/staging/iio/meter/ade7758_trigger.c | 6 ------ 4 files changed, 27 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index e9cff3b3ab7..92d1facf3c7 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -1,17 +1,10 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "adis16260.h" diff --git a/drivers/staging/iio/gyro/adis16260_trigger.c b/drivers/staging/iio/gyro/adis16260_trigger.c index f2409615706..2f2b2160f44 100644 --- a/drivers/staging/iio/gyro/adis16260_trigger.c +++ b/drivers/staging/iio/gyro/adis16260_trigger.c @@ -1,14 +1,8 @@ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "adis16260.h" diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index e7a04b46517..c9271d01317 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -6,20 +6,12 @@ * Licensed under the GPL-2. */ #include -#include -#include -#include -#include -#include #include #include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../ring_sw.h" #include "../trigger.h" #include "ade7758.h" diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c index 4c451c26efb..392dfe30244 100644 --- a/drivers/staging/iio/meter/ade7758_trigger.c +++ b/drivers/staging/iio/meter/ade7758_trigger.c @@ -7,16 +7,10 @@ */ #include -#include -#include -#include #include -#include -#include #include #include "../iio.h" -#include "../sysfs.h" #include "../trigger.h" #include "ade7758.h" From 232b9cba130025d47531c5c539d6affc64950213 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:49 +0100 Subject: [PATCH 0172/1519] staging:iio:core flatten convenience function that only has one user. Fix trivial wrong index (no effect on any current drivers). Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index e8ad648de3d..97f4d632917 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1004,18 +1004,17 @@ error_ret: return ret; } -static inline void __iio_remove_all_event_sysfs(struct iio_dev *dev_info, - const char *groupname, - int num) +static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info, + int i) { struct iio_dev_attr *p, *n; list_for_each_entry_safe(p, n, - &dev_info->event_interfaces[num]. + &dev_info->event_interfaces[i]. dev_attr_list, l) { sysfs_remove_file_from_group(&dev_info - ->event_interfaces[num].dev.kobj, + ->event_interfaces[i].dev.kobj, &p->dev_attr.attr, - groupname); + NULL); kfree(p->dev_attr.attr.name); kfree(p); } @@ -1025,7 +1024,7 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info, int i) { int j; int ret; - INIT_LIST_HEAD(&dev_info->event_interfaces[0].dev_attr_list); + INIT_LIST_HEAD(&dev_info->event_interfaces[i].dev_attr_list); /* Dynically created from the channels array */ if (dev_info->channels) { for (j = 0; j < dev_info->num_channels; j++) { @@ -1039,18 +1038,11 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info, int i) return 0; error_clear_attrs: - __iio_remove_all_event_sysfs(dev_info, NULL, i); + __iio_remove_event_config_attrs(dev_info, i); return ret; } -static inline int __iio_remove_event_config_attrs(struct iio_dev *dev_info, - int i) -{ - __iio_remove_all_event_sysfs(dev_info, NULL, i); - return 0; -} - static int iio_device_register_eventset(struct iio_dev *dev_info) { int ret = 0, i, j; From 9aa1a167f0b8d6a58fe012992fd801bd78bf91f1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:50 +0100 Subject: [PATCH 0173/1519] staging:iio:core squash trivial wrappers and use ida allocation func. Reorder to remove need for definitions currently in header. Remove ida related utility function defs from header. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 4 - drivers/staging/iio/industrialio-core.c | 108 +++++++++--------------- 2 files changed, 42 insertions(+), 70 deletions(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 7a6ce4d0fb7..42254b49395 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -432,8 +432,4 @@ static inline bool iio_ring_enabled(struct iio_dev *dev_info) | INDIO_RING_HARDWARE_BUFFER); }; -struct ida; - -int iio_get_new_ida_val(struct ida *this_ida); -void iio_free_ida_val(struct ida *this_ida, int id); #endif /* _INDUSTRIAL_IO_H_ */ diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 97f4d632917..b4246491bfc 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -87,6 +87,36 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_PEAK_SCALE_SHARED/2] = "peak_scale", }; +/* Return a negative errno on failure */ +int iio_get_new_ida_val(struct ida *this_ida) +{ + int ret; + int val; + +ida_again: + if (unlikely(ida_pre_get(this_ida, GFP_KERNEL) == 0)) + return -ENOMEM; + + spin_lock(&iio_ida_lock); + ret = ida_get_new(this_ida, &val); + spin_unlock(&iio_ida_lock); + if (unlikely(ret == -EAGAIN)) + goto ida_again; + else if (unlikely(ret)) + return ret; + + return val; +} +EXPORT_SYMBOL(iio_get_new_ida_val); + +void iio_free_ida_val(struct ida *this_ida, int id) +{ + spin_lock(&iio_ida_lock); + ida_remove(this_ida, id); + spin_unlock(&iio_ida_lock); +} +EXPORT_SYMBOL(iio_free_ida_val); + int iio_push_event(struct iio_dev *dev_info, int ev_line, int ev_code, @@ -246,28 +276,18 @@ static struct device_type iio_event_type = { int iio_device_get_chrdev_minor(void) { - int ret, val; + int ret; -ida_again: - if (unlikely(ida_pre_get(&iio_chrdev_ida, GFP_KERNEL) == 0)) - return -ENOMEM; - spin_lock(&iio_ida_lock); - ret = ida_get_new(&iio_chrdev_ida, &val); - spin_unlock(&iio_ida_lock); - if (unlikely(ret == -EAGAIN)) - goto ida_again; - else if (unlikely(ret)) + ret = iio_get_new_ida_val(&iio_chrdev_ida); + if (ret < IIO_DEV_MAX) /* both errors and valid */ return ret; - if (val > IIO_DEV_MAX) + else return -ENOMEM; - return val; } void iio_device_free_chrdev_minor(int val) { - spin_lock(&iio_ida_lock); - ida_remove(&iio_chrdev_ida, val); - spin_unlock(&iio_ida_lock); + iio_free_ida_val(&iio_chrdev_ida, val); } static int iio_setup_ev_int(struct iio_event_interface *ev_int, @@ -329,24 +349,6 @@ static void iio_free_ev_int(struct iio_event_interface *ev_int) put_device(&ev_int->dev); } -static int __init iio_dev_init(void) -{ - int err; - - err = alloc_chrdev_region(&iio_devt, 0, IIO_DEV_MAX, "iio"); - if (err < 0) - printk(KERN_ERR "%s: failed to allocate char dev region\n", - __FILE__); - - return err; -} - -static void __exit iio_dev_exit(void) -{ - if (iio_devt) - unregister_chrdev_region(iio_devt, IIO_DEV_MAX); -} - static int __init iio_init(void) { int ret; @@ -360,9 +362,12 @@ static int __init iio_init(void) goto error_nothing; } - ret = iio_dev_init(); - if (ret < 0) + ret = alloc_chrdev_region(&iio_devt, 0, IIO_DEV_MAX, "iio"); + if (ret < 0) { + printk(KERN_ERR "%s: failed to allocate char dev region\n", + __FILE__); goto error_unregister_bus_type; + } return 0; @@ -374,7 +379,8 @@ error_nothing: static void __exit iio_exit(void) { - iio_dev_exit(); + if (iio_devt) + unregister_chrdev_region(iio_devt, IIO_DEV_MAX); bus_unregister(&iio_bus_type); } @@ -806,36 +812,6 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info) sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group); } -/* Return a negative errno on failure */ -int iio_get_new_ida_val(struct ida *this_ida) -{ - int ret; - int val; - -ida_again: - if (unlikely(ida_pre_get(this_ida, GFP_KERNEL) == 0)) - return -ENOMEM; - - spin_lock(&iio_ida_lock); - ret = ida_get_new(this_ida, &val); - spin_unlock(&iio_ida_lock); - if (unlikely(ret == -EAGAIN)) - goto ida_again; - else if (unlikely(ret)) - return ret; - - return val; -} -EXPORT_SYMBOL(iio_get_new_ida_val); - -void iio_free_ida_val(struct ida *this_ida, int id) -{ - spin_lock(&iio_ida_lock); - ida_remove(this_ida, id); - spin_unlock(&iio_ida_lock); -} -EXPORT_SYMBOL(iio_free_ida_val); - static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_THRESH] = "thresh", [IIO_EV_TYPE_MAG] = "mag", From 355e25c1de7c87e3629cdcb11c2f95719b5ed807 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:51 +0100 Subject: [PATCH 0174/1519] staging:iio:sysfs cleanout header for unused definitions. Also push one down into the only driver that actually uses it. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/sca3000_core.c | 2 +- drivers/staging/iio/sysfs.h | 45 ++---------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 3c637b90e4f..22c38c328da 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -421,7 +421,7 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR, /* More standard attributes */ -static IIO_DEV_ATTR_REV(sca3000_show_rev); +static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0); #define SCA3000_INFO_MASK \ (1 << IIO_CHAN_INFO_SCALE_SHARED) diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 203ee83f992..56f4efbeb5d 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -71,30 +71,14 @@ struct iio_const_attr { struct iio_const_attr iio_const_attr_##_vname \ = { .string = _string, \ .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)} + /* Generic attributes of onetype or another */ - -/** - * IIO_DEV_ATTR_REV - revision number for the device - * @_show: output method for the attribute - * - * Very much device dependent. - **/ -#define IIO_DEV_ATTR_REV(_show) \ - IIO_DEVICE_ATTR(revision, S_IRUGO, _show, NULL, 0) - /** * IIO_DEV_ATTR_RESET: resets the device **/ #define IIO_DEV_ATTR_RESET(_store) \ IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, _store, 0) -/** - * IIO_CONST_ATTR_NAME - constant identifier - * @_string: the name - **/ -#define IIO_CONST_ATTR_NAME(_string) \ - IIO_CONST_ATTR(name, _string) - /** * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency * @_mode: sysfs file mode/permissions @@ -105,15 +89,11 @@ struct iio_const_attr { IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0) /** - * IIO_DEV_ATTR_AVAIL_SAMP_FREQ - list available sampling frequencies + * IIO_DEV_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies * @_show: output method for the attribute * * May be mode dependent on some devices **/ -/* Deprecated */ -#define IIO_DEV_ATTR_AVAIL_SAMP_FREQ(_show) \ - IIO_DEVICE_ATTR(available_sampling_frequency, S_IRUGO, _show, NULL, 0) - #define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \ IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0) /** @@ -125,27 +105,6 @@ struct iio_const_attr { #define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \ IIO_CONST_ATTR(sampling_frequency_available, _string) -/** - * IIO_DEV_ATTR_SW_RING_ENABLE - enable software ring buffer - * @_show: output method for the attribute - * @_store: input method for the attribute - * - * Success may be dependent on attachment of trigger previously. - **/ -#define IIO_DEV_ATTR_SW_RING_ENABLE(_show, _store) \ - IIO_DEVICE_ATTR(sw_ring_enable, S_IRUGO | S_IWUSR, _show, _store, 0) - -/** - * IIO_DEV_ATTR_HW_RING_ENABLE - enable hardware ring buffer - * @_show: output method for the attribute - * @_store: input method for the attribute - * - * This is a different attribute from the software one as one can envision - * schemes where a combination of the two may be used. - **/ -#define IIO_DEV_ATTR_HW_RING_ENABLE(_show, _store) \ - IIO_DEVICE_ATTR(hw_ring_enable, S_IRUGO | S_IWUSR, _show, _store, 0) - #define IIO_DEV_ATTR_TEMP_RAW(_show) \ IIO_DEVICE_ATTR(temp_raw, S_IRUGO, _show, NULL, 0) From e05e5f2336a94f127553c947dcfe2ce15f2c5f9a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:52 +0100 Subject: [PATCH 0175/1519] staging:iio:light:tsl2583 allocate chip state with iio_dev There are some unusual corners in the probe function of this driver, so may need another look. V2: Now with the check for allocation success not inverted. V3: Now with the i2c devdata calls actually being correctly cast. Signed-off-by: Jonathan Cameron Tested-by: Jon Brenner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 216 +++++++++++++--------------- 1 file changed, 101 insertions(+), 115 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 296d0ffa0b0..f75fe856389 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -87,7 +87,6 @@ struct taos_settings { struct tsl2583_chip { struct mutex als_mutex; struct i2c_client *client; - struct iio_dev *iio_dev; struct taos_als_info als_cur_info; struct taos_settings taos_settings; int als_time_scale; @@ -159,8 +158,7 @@ static void taos_defaults(struct tsl2583_chip *chip) static int taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) { - int ret; - int i; + int i, ret; for (i = 0; i < len; i++) { /* select register to write */ @@ -191,47 +189,47 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) * the array are then used along with the time scale factor array values, to * calculate the lux. */ -static int taos_get_lux(struct i2c_client *client) +static int taos_get_lux(struct iio_dev *indio_dev) { u16 ch0, ch1; /* separated ch0/ch1 data from device */ u32 lux; /* raw lux calculated from device data */ u32 ratio; u8 buf[5]; struct taos_lux *p; - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); int i, ret; u32 ch0lux = 0; u32 ch1lux = 0; if (mutex_trylock(&chip->als_mutex) == 0) { - dev_info(&client->dev, "taos_get_lux device is busy\n"); + dev_info(&chip->client->dev, "taos_get_lux device is busy\n"); return chip->als_cur_info.lux; /* busy, so return LAST VALUE */ } if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { /* device is not enabled */ - dev_err(&client->dev, "taos_get_lux device is not enabled\n"); + dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); ret = -EBUSY ; goto out_unlock; } - ret = taos_i2c_read(client, (TSL258X_CMD_REG), &buf[0], 1); + ret = taos_i2c_read(chip->client, (TSL258X_CMD_REG), &buf[0], 1); if (ret < 0) { - dev_err(&client->dev, "taos_get_lux failed to read CMD_REG\n"); + dev_err(&chip->client->dev, "taos_get_lux failed to read CMD_REG\n"); goto out_unlock; } /* is data new & valid */ if (!(buf[0] & TSL258X_STA_ADC_INTR)) { - dev_err(&client->dev, "taos_get_lux data not valid\n"); + dev_err(&chip->client->dev, "taos_get_lux data not valid\n"); ret = chip->als_cur_info.lux; /* return LAST VALUE */ goto out_unlock; } for (i = 0; i < 4; i++) { int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i); - ret = taos_i2c_read(client, reg, &buf[i], 1); + ret = taos_i2c_read(chip->client, reg, &buf[i], 1); if (ret < 0) { - dev_err(&client->dev, "taos_get_lux failed to read" + dev_err(&chip->client->dev, "taos_get_lux failed to read" " register %x\n", reg); goto out_unlock; } @@ -239,11 +237,12 @@ static int taos_get_lux(struct i2c_client *client) /* clear status, really interrupt status (interrupts are off), but * we use the bit anyway - don't forget 0x80 - this is a command*/ - ret = i2c_smbus_write_byte(client, - (TSL258X_CMD_REG | TSL258X_CMD_SPL_FN | TSL258X_CMD_ALS_INT_CLR)); + ret = i2c_smbus_write_byte(chip->client, + (TSL258X_CMD_REG | TSL258X_CMD_SPL_FN | + TSL258X_CMD_ALS_INT_CLR)); if (ret < 0) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_i2c_write_command failed in taos_get_lux, err = %d\n", ret); goto out_unlock; /* have no data, so return failure */ @@ -285,7 +284,7 @@ static int taos_get_lux(struct i2c_client *client) /* note: lux is 31 bit max at this point */ if (ch1lux > ch0lux) { - dev_dbg(&client->dev, "No Data - Return last value\n"); + dev_dbg(&chip->client->dev, "No Data - Return last value\n"); ret = chip->als_cur_info.lux = 0; goto out_unlock; } @@ -319,54 +318,56 @@ out_unlock: * to derive actual lux). * Return updated gain_trim value. */ -int taos_als_calibrate(struct i2c_client *client) +static int taos_als_calibrate(struct iio_dev *indio_dev) { - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); u8 reg_val; unsigned int gain_trim_val; int ret; int lux_val; - ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | TSL258X_CNTRL)); + ret = i2c_smbus_write_byte(chip->client, + (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_als_calibrate failed to reach the CNTRL register, ret=%d\n", ret); return ret; } - reg_val = i2c_smbus_read_byte(client); + reg_val = i2c_smbus_read_byte(chip->client); if ((reg_val & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) != (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_als_calibrate failed: device not powered on with ADC enabled\n"); return -1; } - ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | TSL258X_CNTRL)); + ret = i2c_smbus_write_byte(chip->client, + (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_als_calibrate failed to reach the STATUS register, ret=%d\n", ret); return ret; } - reg_val = i2c_smbus_read_byte(client); + reg_val = i2c_smbus_read_byte(chip->client); if ((reg_val & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_als_calibrate failed: STATUS - ADC not valid.\n"); return -ENODATA; } - lux_val = taos_get_lux(client); + lux_val = taos_get_lux(indio_dev); if (lux_val < 0) { - dev_err(&client->dev, "taos_als_calibrate failed to get lux\n"); + dev_err(&chip->client->dev, "taos_als_calibrate failed to get lux\n"); return lux_val; } gain_trim_val = (unsigned int) (((chip->taos_settings.als_cal_target) * chip->taos_settings.als_gain_trim) / lux_val); if ((gain_trim_val < 250) || (gain_trim_val > 4000)) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_als_calibrate failed: trim_val of %d is out of range\n", gain_trim_val); return -ENODATA; @@ -380,21 +381,21 @@ int taos_als_calibrate(struct i2c_client *client) * Turn the device on. * Configuration must be set before calling this function. */ -static int taos_chip_on(struct i2c_client *client) +static int taos_chip_on(struct iio_dev *indio_dev) { int i; - int ret = 0; + int ret; u8 *uP; u8 utmp; int als_count; int als_time; - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); /* and make sure we're not already on */ if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { /* if forcing a register update - turn off, then on */ - dev_info(&client->dev, "device is already enabled\n"); - return -EINVAL; + dev_info(&chip->client->dev, "device is already enabled\n"); + return -EINVAL; } /* determine als integration regster */ @@ -416,20 +417,21 @@ static int taos_chip_on(struct i2c_client *client) /* TSL258x Specific power-on / adc enable sequence * Power on the device 1st. */ utmp = TSL258X_CNTL_PWR_ON; - ret = i2c_smbus_write_byte_data(client, - TSL258X_CMD_REG | TSL258X_CNTRL, utmp); + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_CNTRL, utmp); if (ret < 0) { - dev_err(&client->dev, "taos_chip_on failed on CNTRL reg.\n"); + dev_err(&chip->client->dev, "taos_chip_on failed on CNTRL reg.\n"); return -1; } /* Use the following shadow copy for our delay before enabling ADC. * Write all the registers. */ for (i = 0, uP = chip->taos_config; i < TSL258X_REG_MAX; i++) { - ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG + i, + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG + i, *uP++); if (ret < 0) { - dev_err(&client->dev, + dev_err(&chip->client->dev, "taos_chip_on failed on reg %d.\n", i); return -1; } @@ -439,10 +441,11 @@ static int taos_chip_on(struct i2c_client *client) /* NOW enable the ADC * initialize the desired mode of operation */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; - ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG | TSL258X_CNTRL, + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_CNTRL, utmp); if (ret < 0) { - dev_err(&client->dev, "taos_chip_on failed on 2nd CTRL reg.\n"); + dev_err(&chip->client->dev, "taos_chip_on failed on 2nd CTRL reg.\n"); return -1; } chip->taos_chip_status = TSL258X_CHIP_WORKING; @@ -450,33 +453,26 @@ static int taos_chip_on(struct i2c_client *client) return ret; } -static int taos_chip_off(struct i2c_client *client) +static int taos_chip_off(struct iio_dev *indio_dev) { - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); int ret; /* turn device off */ chip->taos_chip_status = TSL258X_CHIP_SUSPENDED; - ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG | TSL258X_CNTRL, + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_CNTRL, 0x00); return ret; } /* Sysfs Interface Functions */ -static ssize_t taos_device_id(struct device *dev, -struct device_attribute *attr, char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; - - return sprintf(buf, "%s\n", chip->client->name); -} static ssize_t taos_power_state_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%d\n", chip->taos_chip_status); } @@ -485,16 +481,15 @@ static ssize_t taos_power_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; unsigned long value; if (strict_strtoul(buf, 0, &value)) return -EINVAL; if (value == 0) - taos_chip_off(chip->client); + taos_chip_off(indio_dev); else - taos_chip_on(chip->client); + taos_chip_on(indio_dev); return len; } @@ -503,7 +498,7 @@ static ssize_t taos_gain_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); char gain[4] = {0}; switch (chip->taos_settings.als_gain) { @@ -528,7 +523,7 @@ static ssize_t taos_gain_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); unsigned long value; if (strict_strtoul(buf, 0, &value)) @@ -565,7 +560,7 @@ static ssize_t taos_als_time_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%d\n", chip->taos_settings.als_time); } @@ -574,7 +569,7 @@ static ssize_t taos_als_time_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); unsigned long value; if (strict_strtoul(buf, 0, &value)) @@ -586,7 +581,7 @@ static ssize_t taos_als_time_store(struct device *dev, if (value % 50) return -EINVAL; - chip->taos_settings.als_time = value; + chip->taos_settings.als_time = value; return len; } @@ -602,7 +597,7 @@ static ssize_t taos_als_trim_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%d\n", chip->taos_settings.als_gain_trim); } @@ -611,7 +606,7 @@ static ssize_t taos_als_trim_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); unsigned long value; if (strict_strtoul(buf, 0, &value)) @@ -627,7 +622,7 @@ static ssize_t taos_als_cal_target_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%d\n", chip->taos_settings.als_cal_target); } @@ -636,7 +631,7 @@ static ssize_t taos_als_cal_target_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; + struct tsl2583_chip *chip = iio_priv(indio_dev); unsigned long value; if (strict_strtoul(buf, 0, &value)) @@ -651,27 +646,26 @@ static ssize_t taos_als_cal_target_store(struct device *dev, static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; - int lux; + int ret; - lux = taos_get_lux(chip->client); + ret = taos_get_lux(dev_get_drvdata(dev)); + if (ret < 0) + return ret; - return sprintf(buf, "%d\n", lux); + return sprintf(buf, "%d\n", ret); } static ssize_t taos_do_calibrate(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; unsigned long value; if (strict_strtoul(buf, 0, &value)) return -EINVAL; if (value == 1) - taos_als_calibrate(chip->client); + taos_als_calibrate(indio_dev); return len; } @@ -703,8 +697,8 @@ static ssize_t taos_luxtable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct tsl2583_chip *chip = indio_dev->dev_data; - int value[ARRAY_SIZE(taos_device_lux)]; + struct tsl2583_chip *chip = iio_priv(indio_dev); + int value[ARRAY_SIZE(taos_device_lux)*3 + 1]; int n; get_options(buf, ARRAY_SIZE(value), value); @@ -725,18 +719,17 @@ static ssize_t taos_luxtable_store(struct device *dev, } if (chip->taos_chip_status == TSL258X_CHIP_WORKING) - taos_chip_off(chip->client); + taos_chip_off(indio_dev); /* Zero out the table */ memset(taos_device_lux, 0, sizeof(taos_device_lux)); memcpy(taos_device_lux, &value[1], (value[0] * 4)); - taos_chip_on(chip->client); + taos_chip_on(indio_dev); return len; } -static DEVICE_ATTR(name, S_IRUGO, taos_device_id, NULL); static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR, taos_power_state_show, taos_power_state_store); @@ -762,7 +755,6 @@ static DEVICE_ATTR(illuminance0_lux_table, S_IRUGO | S_IWUSR, taos_luxtable_show, taos_luxtable_store); static struct attribute *sysfs_attrs_ctrl[] = { - &dev_attr_name.attr, &dev_attr_power_state.attr, &dev_attr_illuminance0_calibscale.attr, /* Gain */ &dev_attr_illuminance0_calibscale_available.attr, @@ -798,9 +790,10 @@ static const struct iio_info tsl2583_info = { static int __devinit taos_probe(struct i2c_client *clientp, const struct i2c_device_id *idp) { - int i, ret = 0; + int i, ret; unsigned char buf[TSL258X_MAX_DEVICE_REGS]; - static struct tsl2583_chip *chip; + struct tsl2583_chip *chip; + struct iio_dev *indio_dev; if (!i2c_check_functionality(clientp->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -810,12 +803,15 @@ static int __devinit taos_probe(struct i2c_client *clientp, return -EOPNOTSUPP; } - chip = kzalloc(sizeof(struct tsl2583_chip), GFP_KERNEL); - if (!chip) - return -ENOMEM; - + indio_dev = iio_allocate_device(sizeof(*chip)); + if (indio_dev == NULL) { + ret = -ENOMEM; + dev_err(&clientp->dev, "iio allocation failed\n"); + goto fail1; + } + chip = iio_priv(indio_dev); chip->client = clientp; - i2c_set_clientdata(clientp, chip); + i2c_set_clientdata(clientp, indio_dev); mutex_init(&chip->als_mutex); chip->taos_chip_status = TSL258X_CHIP_UNKNOWN; @@ -827,14 +823,14 @@ static int __devinit taos_probe(struct i2c_client *clientp, if (ret < 0) { dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd " "reg failed in taos_probe(), err = %d\n", ret); - goto fail1; + goto fail2; } ret = i2c_smbus_read_byte(clientp); if (ret < 0) { dev_err(&clientp->dev, "i2c_smbus_read_byte from " "reg failed in taos_probe(), err = %d\n", ret); - goto fail1; + goto fail2; } buf[i] = ret; } @@ -842,58 +838,50 @@ static int __devinit taos_probe(struct i2c_client *clientp, if (!taos_tsl258x_device(buf)) { dev_info(&clientp->dev, "i2c device found but does not match " "expected id in taos_probe()\n"); - goto fail1; + goto fail2; } ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg " "failed in taos_probe(), err = %d\n", ret); - goto fail1; + goto fail2; } - chip->iio_dev = iio_allocate_device(0); - if (!chip->iio_dev) { - ret = -ENOMEM; - dev_err(&clientp->dev, "iio allocation failed\n"); - goto fail1; - } - - chip->iio_dev->info = &tsl2583_info; - chip->iio_dev->dev.parent = &clientp->dev; - chip->iio_dev->dev_data = (void *)(chip); - chip->iio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(chip->iio_dev); + indio_dev->info = &tsl2583_info; + indio_dev->dev.parent = &clientp->dev; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->name = chip->client->name; + ret = iio_device_register(indio_dev); if (ret) { dev_err(&clientp->dev, "iio registration failed\n"); - goto fail1; + goto fail2; } /* Load up the V2 defaults (these are hard coded defaults for now) */ taos_defaults(chip); /* Make sure the chip is on */ - taos_chip_on(clientp); + taos_chip_on(indio_dev); dev_info(&clientp->dev, "Light sensor found.\n"); - return 0; - fail1: - kfree(chip); - + iio_free_device(indio_dev); +fail2: return ret; } static int taos_suspend(struct i2c_client *client, pm_message_t state) { - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); int ret = 0; mutex_lock(&chip->als_mutex); if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { - ret = taos_chip_off(client); + ret = taos_chip_off(indio_dev); chip->taos_chip_status = TSL258X_CHIP_SUSPENDED; } @@ -903,13 +891,14 @@ static int taos_suspend(struct i2c_client *client, pm_message_t state) static int taos_resume(struct i2c_client *client) { - struct tsl2583_chip *chip = i2c_get_clientdata(client); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct tsl2583_chip *chip = iio_priv(indio_dev); int ret = 0; mutex_lock(&chip->als_mutex); if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED) - ret = taos_chip_on(client); + ret = taos_chip_on(indio_dev); mutex_unlock(&chip->als_mutex); return ret; @@ -918,11 +907,8 @@ static int taos_resume(struct i2c_client *client) static int __devexit taos_remove(struct i2c_client *client) { - struct tsl2583_chip *chip = i2c_get_clientdata(client); + iio_device_unregister(i2c_get_clientdata(client)); - iio_device_unregister(chip->iio_dev); - - kfree(chip); return 0; } From 4024bc73b1d1d8f82518b67b0996cb7b870dd1d4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:53 +0100 Subject: [PATCH 0176/1519] staging:iio: Remove deprecated dev_data from iio_dev. The equivalent should always be done using iio_alllocate_device with to create a private area for the driver and then iio_priv to access it. There may be other uses for a private data pointer but right now it just leads driver writers astray. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 42254b49395..d86a6102405 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -276,7 +276,6 @@ struct iio_info { /** * struct iio_dev - industrial I/O device * @id: [INTERN] used to identify device internally - * @dev_data: [DRIVER] device specific data * @modes: [DRIVER] operating modes supported by device * @currentmode: [DRIVER] current operating mode * @dev: [DRIVER] device structure, should be assigned a parent @@ -296,7 +295,7 @@ struct iio_info { **/ struct iio_dev { int id; - void *dev_data; + int modes; int currentmode; struct device dev; @@ -370,16 +369,6 @@ static inline struct iio_dev *to_iio_dev(struct device *d) return container_of(d, struct iio_dev, dev); }; -/** - * iio_dev_get_devdata() - helper function gets device specific data - * @d: the iio_dev associated with the device - **/ -static inline void *iio_dev_get_devdata(struct iio_dev *d) -{ - return d->dev_data; -} - - /* Can we make this smaller? */ #define IIO_ALIGN L1_CACHE_BYTES /** From d34dbee8ac8e953eb7115804bf406990f976b942 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:52 +0100 Subject: [PATCH 0177/1519] staging:iio:accel:kxsd9 cleanup and conversion to iio_chan_spec. Lots of minor bits and pieces. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/kxsd9.c | 270 ++++++++++++------------------ 1 file changed, 106 insertions(+), 164 deletions(-) diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index c8a358a5df8..3f2d047f58e 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c @@ -24,8 +24,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "../adc/adc.h" -#include "accel.h" #define KXSD9_REG_X 0x00 #define KXSD9_REG_Y 0x02 @@ -34,10 +32,6 @@ #define KXSD9_REG_RESET 0x0a #define KXSD9_REG_CTRL_C 0x0c -#define KXSD9_FS_8 0x00 -#define KXSD9_FS_6 0x01 -#define KXSD9_FS_4 0x02 -#define KXSD9_FS_2 0x03 #define KXSD9_FS_MASK 0x03 #define KXSD9_REG_CTRL_B 0x0d @@ -46,13 +40,8 @@ #define KXSD9_READ(a) (0x80 | (a)) #define KXSD9_WRITE(a) (a) -#define KXSD9_SCALE_2G "0.011978" -#define KXSD9_SCALE_4G "0.023927" -#define KXSD9_SCALE_6G "0.035934" -#define KXSD9_SCALE_8G "0.047853" - #define KXSD9_STATE_RX_SIZE 2 -#define KXSD9_STATE_TX_SIZE 4 +#define KXSD9_STATE_TX_SIZE 2 /** * struct kxsd9_state - device related storage * @buf_lock: protect the rx and tx buffers. @@ -67,170 +56,70 @@ struct kxsd9_state { u8 tx[KXSD9_STATE_TX_SIZE]; }; -/* This may want to move to mili g to allow for non integer ranges */ -static ssize_t kxsd9_read_scale(struct device *dev, - struct device_attribute *attr, - char *buf) +#define KXSD9_SCALE_2G "0.011978" +#define KXSD9_SCALE_4G "0.023927" +#define KXSD9_SCALE_6G "0.035934" +#define KXSD9_SCALE_8G "0.047853" + +/* reverse order */ +static const int kxsd9_micro_scales[4] = { 47853, 35934, 23927, 11978 }; + +static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro) { - int ret; - ssize_t len = 0; - struct iio_dev *indio_dev = dev_get_drvdata(dev); + int ret, i; struct kxsd9_state *st = iio_priv(indio_dev); - struct spi_transfer xfer = { - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - .tx_buf = st->tx, - .rx_buf = st->rx, - }; - struct spi_message msg; + bool foundit = false; - mutex_lock(&st->buf_lock); - st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C); - st->tx[1] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->us, &msg); - if (ret) - goto error_ret; - - switch (st->rx[1] & KXSD9_FS_MASK) { - case KXSD9_FS_8: - len += sprintf(buf, "%s\n", KXSD9_SCALE_8G); - break; - case KXSD9_FS_6: - len += sprintf(buf, "%s\n", KXSD9_SCALE_6G); - break; - case KXSD9_FS_4: - len += sprintf(buf, "%s\n", KXSD9_SCALE_4G); - break; - case KXSD9_FS_2: - len += sprintf(buf, "%s\n", KXSD9_SCALE_2G); - break; - } - -error_ret: - mutex_unlock(&st->buf_lock); - - return ret ? ret : len; -} -static ssize_t kxsd9_write_scale(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - - struct spi_message msg; - int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct kxsd9_state *st = iio_priv(indio_dev); - u8 val; - struct spi_transfer xfers[] = { - { - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - .tx_buf = st->tx, - .rx_buf = st->rx, - }, { - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - .tx_buf = st->tx, - }, - }; - - if (!strncmp(buf, KXSD9_SCALE_8G, - strlen(buf) < strlen(KXSD9_SCALE_8G) - ? strlen(buf) : strlen(KXSD9_SCALE_8G))) - val = KXSD9_FS_8; - else if (!strncmp(buf, KXSD9_SCALE_6G, - strlen(buf) < strlen(KXSD9_SCALE_6G) - ? strlen(buf) : strlen(KXSD9_SCALE_6G))) - val = KXSD9_FS_6; - else if (!strncmp(buf, KXSD9_SCALE_4G, - strlen(buf) < strlen(KXSD9_SCALE_4G) - ? strlen(buf) : strlen(KXSD9_SCALE_4G))) - val = KXSD9_FS_4; - else if (!strncmp(buf, KXSD9_SCALE_2G, - strlen(buf) < strlen(KXSD9_SCALE_2G) - ? strlen(buf) : strlen(KXSD9_SCALE_2G))) - val = KXSD9_FS_2; - else + for (i = 0; i < 4; i++) + if (micro == kxsd9_micro_scales[i]) { + foundit = true; + break; + } + if (!foundit) return -EINVAL; mutex_lock(&st->buf_lock); - st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C); - st->tx[1] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); if (ret) goto error_ret; st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C); - st->tx[1] = (st->rx[1] & ~KXSD9_FS_MASK) | val; + st->tx[1] = (ret & ~KXSD9_FS_MASK) | i; - spi_message_init(&msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_write(st->us, st->tx, 2); error_ret: mutex_unlock(&st->buf_lock); - return ret ? ret : len; + return ret; } -static ssize_t kxsd9_read_accel(struct device *dev, - struct device_attribute *attr, - char *buf) +static int kxsd9_read(struct iio_dev *indio_dev, u8 address) { struct spi_message msg; int ret; - ssize_t len = 0; - u16 val; - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct kxsd9_state *st = iio_priv(indio_dev); struct spi_transfer xfers[] = { { .bits_per_word = 8, .len = 1, - .cs_change = 0, .delay_usecs = 200, .tx_buf = st->tx, }, { .bits_per_word = 8, .len = 2, - .cs_change = 1, .rx_buf = st->rx, }, }; mutex_lock(&st->buf_lock); - st->tx[0] = KXSD9_READ(this_attr->address); + st->tx[0] = KXSD9_READ(address); spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); spi_message_add_tail(&xfers[1], &msg); ret = spi_sync(st->us, &msg); if (ret) - goto error_ret; - val = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); - len = sprintf(buf, "%d\n", val); -error_ret: - mutex_unlock(&st->buf_lock); - - return ret ? ret : len; + return ret; + return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); } -static IIO_DEV_ATTR_ACCEL_X(kxsd9_read_accel, KXSD9_REG_X); -static IIO_DEV_ATTR_ACCEL_Y(kxsd9_read_accel, KXSD9_REG_Y); -static IIO_DEV_ATTR_ACCEL_Z(kxsd9_read_accel, KXSD9_REG_Z); -static IIO_DEV_ATTR_IN_RAW(0, kxsd9_read_accel, KXSD9_REG_AUX); - -static IIO_DEVICE_ATTR(accel_scale, - S_IRUGO | S_IWUSR, - kxsd9_read_scale, - kxsd9_write_scale, - 0); - static IIO_CONST_ATTR(accel_scale_available, KXSD9_SCALE_2G " " KXSD9_SCALE_4G " " @@ -238,48 +127,94 @@ static IIO_CONST_ATTR(accel_scale_available, KXSD9_SCALE_8G); static struct attribute *kxsd9_attributes[] = { - &iio_dev_attr_accel_x_raw.dev_attr.attr, - &iio_dev_attr_accel_y_raw.dev_attr.attr, - &iio_dev_attr_accel_z_raw.dev_attr.attr, - &iio_dev_attr_in0_raw.dev_attr.attr, - &iio_dev_attr_accel_scale.dev_attr.attr, &iio_const_attr_accel_scale_available.dev_attr.attr, NULL, }; +static int kxsd9_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + int ret = -EINVAL; + + if (mask == (1 << IIO_CHAN_INFO_SCALE_SHARED)) { + /* Check no integer component */ + if (val) + return -EINVAL; + ret = kxsd9_write_scale(indio_dev, val2); + } + + return ret; +} + +static int kxsd9_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + int ret = -EINVAL; + struct kxsd9_state *st = iio_priv(indio_dev); + + switch (mask) { + case 0: + ret = kxsd9_read(indio_dev, chan->address); + if (ret < 0) + goto error_ret; + *val = ret; + break; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); + if (ret) + goto error_ret; + *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; + ret = IIO_VAL_INT_PLUS_MICRO; + break; + }; + +error_ret: + return ret; +}; +#define KXSD9_ACCEL_CHAN(axis) \ + { \ + .type = IIO_ACCEL, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask = 1 << IIO_CHAN_INFO_SCALE_SHARED, \ + .address = KXSD9_REG_##axis, \ + } + +static struct iio_chan_spec kxsd9_channels[] = { + KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z), + { + .type = IIO_IN, + .indexed = 1, + .address = KXSD9_REG_AUX, + } +}; + static const struct attribute_group kxsd9_attribute_group = { .attrs = kxsd9_attributes, }; static int __devinit kxsd9_power_up(struct kxsd9_state *st) { - struct spi_transfer xfers[2] = { - { - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - .tx_buf = st->tx, - }, { - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - .tx_buf = st->tx + 2, - }, - }; - struct spi_message msg; + int ret; + st->tx[0] = 0x0d; st->tx[1] = 0x40; - st->tx[2] = 0x0c; - st->tx[3] = 0x9b; + ret = spi_write(st->us, st->tx, 2); + if (ret) + return ret; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - - return spi_sync(st->us, &msg); + st->tx[0] = 0x0c; + st->tx[1] = 0x9b; + return spi_write(st->us, st->tx, 2); }; static const struct iio_info kxsd9_info = { + .read_raw = &kxsd9_read_raw, + .write_raw = &kxsd9_write_raw, .attrs = &kxsd9_attribute_group, .driver_module = THIS_MODULE, }; @@ -300,7 +235,9 @@ static int __devinit kxsd9_probe(struct spi_device *spi) st->us = spi; mutex_init(&st->buf_lock); - + indio_dev->channels = kxsd9_channels; + indio_dev->num_channels = ARRAY_SIZE(kxsd9_channels); + indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &kxsd9_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -328,6 +265,10 @@ static int __devexit kxsd9_remove(struct spi_device *spi) return 0; } +static const struct spi_device_id kxsd9_id[] = { + {"kxsd9", 0} +}; + static struct spi_driver kxsd9_driver = { .driver = { .name = "kxsd9", @@ -335,6 +276,7 @@ static struct spi_driver kxsd9_driver = { }, .probe = kxsd9_probe, .remove = __devexit_p(kxsd9_remove), + .id_table = kxsd9_id, }; static __init int kxsd9_spi_init(void) From 7d43817803c6a1786d60834ea1a110360b098085 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:53 +0100 Subject: [PATCH 0178/1519] staging:iio: add quadrature correction to chan info types. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 3 +++ drivers/staging/iio/industrialio-core.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index d86a6102405..07f88aa878a 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -1,3 +1,4 @@ + /* The industrial I/O core * * Copyright (c) 2008 Jonathan Cameron @@ -75,6 +76,8 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_PEAK_SEPARATE, IIO_CHAN_INFO_PEAK_SCALE_SHARED, IIO_CHAN_INFO_PEAK_SCALE_SEPARATE, + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SHARED, + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE, }; /** diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index b4246491bfc..364964b1a81 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -85,6 +85,8 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBBIAS_SHARED/2] = "calibbias", [IIO_CHAN_INFO_PEAK_SHARED/2] = "peak_raw", [IIO_CHAN_INFO_PEAK_SCALE_SHARED/2] = "peak_scale", + [IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SHARED/2] + = "quadrature_correction_raw", }; /* Return a negative errno on failure */ From 58ea7784a361fb8e25f84fa2f9e7cb26b8ea41e6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:54 +0100 Subject: [PATCH 0179/1519] staging:iio:gyro:adxrs450 move to iio_chan_spec registration Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adxrs450_core.c | 172 ++++++++++++++--------- 1 file changed, 102 insertions(+), 70 deletions(-) diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 7502a264770..97a07f9636d 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -20,7 +20,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "gyro.h" #include "../adc/adc.h" #include "adxrs450.h" @@ -32,12 +31,11 @@ * Second register's address is reg_address + 1. * @val: somewhere to pass back the value read **/ -static int adxrs450_spi_read_reg_16(struct device *dev, - u8 reg_address, - u16 *val) +static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, + u8 reg_address, + u16 *val) { struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adxrs450_state *st = iio_priv(indio_dev); int ret; struct spi_transfer xfers[] = { @@ -86,12 +84,11 @@ error_ret: * Second register's address is reg_address + 1. * @val: value to be written. **/ -static int adxrs450_spi_write_reg_16(struct device *dev, - u8 reg_address, - u16 val) +static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, + u8 reg_address, + u16 val) { struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adxrs450_state *st = iio_priv(indio_dev); int ret; struct spi_transfer xfers = { @@ -126,10 +123,9 @@ static int adxrs450_spi_write_reg_16(struct device *dev, * @dev: device associated with child of actual iio_dev * @val: somewhere to pass back the value read **/ -static int adxrs450_spi_sensor_data(struct device *dev, s16 *val) +static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) { struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adxrs450_state *st = iio_priv(indio_dev); int ret; struct spi_transfer xfers[] = { @@ -206,64 +202,39 @@ error_ret: return ret; } -static ssize_t adxrs450_read_temp(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adxrs450_read_temp(struct iio_dev *indio_dev, int *val) { int ret; u16 t; - ret = adxrs450_spi_read_reg_16(dev, - ADXRS450_TEMP1, - &t); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_TEMP1, &t); if (ret) return ret; - return sprintf(buf, "%d\n", t >> 7); + *val = t; + return 0; } -static ssize_t adxrs450_read_quad(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adxrs450_read_quad(struct iio_dev *indio_dev, int *val) { int ret; s16 t; - ret = adxrs450_spi_read_reg_16(dev, - ADXRS450_QUAD1, - &t); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); if (ret) return ret; - return sprintf(buf, "%d\n", t); + *val = t; + return 0; } -static ssize_t adxrs450_write_dnc(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - int ret; - long val; - - ret = strict_strtol(buf, 10, &val); - if (ret) - goto error_ret; - ret = adxrs450_spi_write_reg_16(dev, - ADXRS450_DNC1, - val & 0x3FF); -error_ret: - return ret ? ret : len; -} - -static ssize_t adxrs450_read_sensor_data(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adxrs450_read_sensor_data(struct iio_dev *indio_dev, int *val) { int ret; s16 t; - ret = adxrs450_spi_sensor_data(dev, &t); + ret = adxrs450_spi_sensor_data(indio_dev, &t); if (ret) return ret; - return sprintf(buf, "%d\n", t); + *val = t; + return 0; } /* Recommended Startup Sequence by spec */ @@ -272,7 +243,6 @@ static int adxrs450_initial_setup(struct iio_dev *indio_dev) u32 t; u16 data; int ret; - struct device *dev = &indio_dev->dev; struct adxrs450_state *st = iio_priv(indio_dev); msleep(ADXRS450_STARTUP_DELAY*2); @@ -305,23 +275,23 @@ static int adxrs450_initial_setup(struct iio_dev *indio_dev) return -EIO; } - ret = adxrs450_spi_read_reg_16(dev, ADXRS450_FAULT1, &data); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_FAULT1, &data); if (ret) return ret; if (data & 0x0fff) { dev_err(&st->us->dev, "The device is not in normal status!\n"); return -EINVAL; } - ret = adxrs450_spi_read_reg_16(dev, ADXRS450_PID1, &data); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_PID1, &data); if (ret) return ret; dev_info(&st->us->dev, "The Part ID is 0x%x\n", data); - ret = adxrs450_spi_read_reg_16(dev, ADXRS450_SNL, &data); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_SNL, &data); if (ret) return ret; t = data; - ret = adxrs450_spi_read_reg_16(dev, ADXRS450_SNH, &data); + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_SNH, &data); if (ret) return ret; t |= data << 16; @@ -330,29 +300,88 @@ static int adxrs450_initial_setup(struct iio_dev *indio_dev) return 0; } -static IIO_DEV_ATTR_GYRO_Z(adxrs450_read_sensor_data, 0); -static IIO_DEV_ATTR_TEMP_RAW(adxrs450_read_temp); -static IIO_DEV_ATTR_GYRO_Z_QUADRATURE_CORRECTION(adxrs450_read_quad, 0); -static IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(S_IWUSR, - NULL, adxrs450_write_dnc, 0); -static IIO_CONST_ATTR(name, "adxrs450"); +static int adxrs450_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + int ret; + switch (mask) { + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + ret = adxrs450_spi_write_reg_16(indio_dev, + ADXRS450_DNC1, + val & 0x3FF); + break; + default: + ret = -EINVAL; + break; + } + return ret; +} -static struct attribute *adxrs450_attributes[] = { - &iio_dev_attr_gyro_z_raw.dev_attr.attr, - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_dev_attr_gyro_z_quadrature_correction_raw.dev_attr.attr, - &iio_dev_attr_gyro_z_calibbias.dev_attr.attr, - &iio_const_attr_name.dev_attr.attr, - NULL -}; +static int adxrs450_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) +{ + int ret; + switch (mask) { + case 0: + switch (chan->type) { + case IIO_GYRO: + ret = adxrs450_read_sensor_data(indio_dev, val); + if (ret < 0) + break; + *val = ret; + ret = IIO_VAL_INT; + break; + case IIO_TEMP: + ret = adxrs450_read_temp(indio_dev, val); + if (ret < 0) + break; + *val = ret; + ret = IIO_VAL_INT; + break; + default: + ret = -EINVAL; + break; + } + break; + case (1 << IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE): + ret = adxrs450_read_quad(indio_dev, val); + if (ret < 0) + break; + *val = ret; + ret = IIO_VAL_INT; + break; + default: + ret = -EINVAL; + break; + } -static const struct attribute_group adxrs450_attribute_group = { - .attrs = adxrs450_attributes, + return ret; +} + +static const struct iio_chan_spec adxrs450_channels[] = { + { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE) + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + } }; static const struct iio_info adxrs450_info = { - .attrs = &adxrs450_attribute_group, .driver_module = THIS_MODULE, + .read_raw = &adxrs450_read_raw, + .write_raw = &adxrs450_write_raw, }; static int __devinit adxrs450_probe(struct spi_device *spi) @@ -376,6 +405,9 @@ static int __devinit adxrs450_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &adxrs450_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = adxrs450_channels; + indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); + indio_dev->name = spi->dev.driver->name; ret = iio_device_register(indio_dev); if (ret) From cb4496876f03631eff913b3c608c964d48d61eb9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:55 +0100 Subject: [PATCH 0180/1519] staging:iio:gyro:adxrs450 make more use of spi_read and spi_write. This needs confirmation that the devices is happy if another part is talked to in between the request for a register and the read back. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adxrs450_core.c | 63 +++++++----------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 97a07f9636d..967a772a121 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -35,21 +35,8 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, u8 reg_address, u16 *val) { - struct spi_message msg; struct adxrs450_state *st = iio_priv(indio_dev); int ret; - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 4, - .cs_change = 1, - }, { - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 4, - }, - }; mutex_lock(&st->buf_lock); st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7); @@ -60,10 +47,13 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) st->tx[3] |= ADXRS450_P; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_write(st->us, st->tx, 4); + if (ret) { + dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", + reg_address); + goto error_ret; + } + ret = spi_read(st->us, st->rx, 4); if (ret) { dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", reg_address); @@ -88,15 +78,8 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, u8 reg_address, u16 val) { - struct spi_message msg; struct adxrs450_state *st = iio_priv(indio_dev); int ret; - struct spi_transfer xfers = { - .tx_buf = st->tx, - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 4, - }; mutex_lock(&st->buf_lock); st->tx[0] = ADXRS450_WRITE_DATA | reg_address >> 7; @@ -105,14 +88,12 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, st->tx[3] = val << 1; if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) - st->tx[3] |= ADXRS450_P; + st->tx[3] |= ADXRS450_P; - spi_message_init(&msg); - spi_message_add_tail(&xfers, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_write(st->us, st->tx, 4); if (ret) dev_err(&st->us->dev, "problem while writing 16 bit register 0x%02x\n", - reg_address); + reg_address); msleep(1); /* enforce sequential transfer delay 0.1ms */ mutex_unlock(&st->buf_lock); return ret; @@ -125,21 +106,8 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, **/ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) { - struct spi_message msg; struct adxrs450_state *st = iio_priv(indio_dev); int ret; - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 4, - .cs_change = 1, - }, { - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 4, - }, - }; mutex_lock(&st->buf_lock); st->tx[0] = ADXRS450_SENSOR_DATA; @@ -147,10 +115,13 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) st->tx[2] = 0; st->tx[3] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_write(st->us, st->tx, 4); + if (ret) { + dev_err(&st->us->dev, "Problem while reading sensor data\n"); + goto error_ret; + } + + ret = spi_read(st->us, st->rx, 4); if (ret) { dev_err(&st->us->dev, "Problem while reading sensor data\n"); goto error_ret; From 037bad9a7228c9009b5f4f6e63ad5c7012b8f659 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:56 +0100 Subject: [PATCH 0181/1519] staging:iio:gyro:adxrs450 squish some trivial single call point wrappers functions. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adxrs450_core.c | 57 +++++------------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 967a772a121..f65ad497263 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -20,7 +20,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "../adc/adc.h" #include "adxrs450.h" @@ -173,41 +172,6 @@ error_ret: return ret; } -static int adxrs450_read_temp(struct iio_dev *indio_dev, int *val) -{ - int ret; - u16 t; - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_TEMP1, &t); - if (ret) - return ret; - *val = t; - return 0; -} - -static int adxrs450_read_quad(struct iio_dev *indio_dev, int *val) -{ - int ret; - s16 t; - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); - if (ret) - return ret; - *val = t; - return 0; -} - -static int adxrs450_read_sensor_data(struct iio_dev *indio_dev, int *val) -{ - int ret; - s16 t; - - ret = adxrs450_spi_sensor_data(indio_dev, &t); - if (ret) - return ret; - - *val = t; - return 0; -} - /* Recommended Startup Sequence by spec */ static int adxrs450_initial_setup(struct iio_dev *indio_dev) { @@ -298,21 +262,24 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, long mask) { int ret; + s16 t; + u16 ut; switch (mask) { case 0: switch (chan->type) { case IIO_GYRO: - ret = adxrs450_read_sensor_data(indio_dev, val); - if (ret < 0) + ret = adxrs450_spi_sensor_data(indio_dev, &t); + if (ret) break; - *val = ret; + *val = t; ret = IIO_VAL_INT; break; case IIO_TEMP: - ret = adxrs450_read_temp(indio_dev, val); - if (ret < 0) + ret = adxrs450_spi_read_reg_16(indio_dev, + ADXRS450_TEMP1, &ut); + if (ret) break; - *val = ret; + *val = ut; ret = IIO_VAL_INT; break; default: @@ -321,10 +288,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, } break; case (1 << IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE): - ret = adxrs450_read_quad(indio_dev, val); - if (ret < 0) + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); + if (ret) break; - *val = ret; + *val = t; ret = IIO_VAL_INT; break; default: From 584c81fbee8d549d68679e42fa56540cc74148da Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:57 +0100 Subject: [PATCH 0182/1519] staging:iio:gyro:adis16080 convert to iio_chan_spec. This is a rare driver that is so simple it actually gets longer as a result of this conversion. Oh well, swings and roundabouts. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16080_core.c | 92 +++++++++++++---------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index ad2db4d723d..bd3eb101986 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -16,8 +16,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "gyro.h" -#include "../adc/adc.h" #define ADIS16080_DIN_GYRO (0 << 10) /* Gyroscope output */ #define ADIS16080_DIN_TEMP (1 << 10) /* Temperature output */ @@ -44,11 +42,10 @@ struct adis16080_state { u8 buf[2] ____cacheline_aligned; }; -static int adis16080_spi_write(struct device *dev, +static int adis16080_spi_write(struct iio_dev *indio_dev, u16 val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16080_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); @@ -61,11 +58,10 @@ static int adis16080_spi_write(struct device *dev, return ret; } -static int adis16080_spi_read(struct device *dev, - u16 *val) +static int adis16080_spi_read(struct iio_dev *indio_dev, + u16 *val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16080_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); @@ -79,50 +75,62 @@ static int adis16080_spi_read(struct device *dev, return ret; } -static ssize_t adis16080_read(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adis16080_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) { - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *indio_dev = dev_get_drvdata(dev); - u16 val = 0; - ssize_t ret; - + int ret = -EINVAL; + u16 ut; /* Take the iio_dev status lock */ + mutex_lock(&indio_dev->mlock); - ret = adis16080_spi_write(dev, - this_attr->address | ADIS16080_DIN_WRITE); - if (ret < 0) - goto error_ret; - ret = adis16080_spi_read(dev, &val); -error_ret: + switch (mask) { + case 0: + ret = adis16080_spi_write(indio_dev, + chan->address | + ADIS16080_DIN_WRITE); + if (ret < 0) + break; + ret = adis16080_spi_read(indio_dev, &ut); + if (ret < 0) + break; + *val = ut; + ret = IIO_VAL_INT; + break; + } mutex_unlock(&indio_dev->mlock); - if (ret == 0) - return sprintf(buf, "%d\n", val); - else - return ret; + return ret; } -static IIO_DEV_ATTR_GYRO_Z(adis16080_read, ADIS16080_DIN_GYRO); -static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16080_read, NULL, - ADIS16080_DIN_TEMP); -static IIO_DEV_ATTR_IN_RAW(0, adis16080_read, ADIS16080_DIN_AIN1); -static IIO_DEV_ATTR_IN_RAW(1, adis16080_read, ADIS16080_DIN_AIN2); -static struct attribute *adis16080_attributes[] = { - &iio_dev_attr_gyro_z_raw.dev_attr.attr, - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_dev_attr_in0_raw.dev_attr.attr, - &iio_dev_attr_in1_raw.dev_attr.attr, - NULL -}; - -static const struct attribute_group adis16080_attribute_group = { - .attrs = adis16080_attributes, +static const struct iio_chan_spec adis16080_channels[] = { + { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .address = ADIS16080_DIN_GYRO, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 0, + .address = ADIS16080_DIN_AIN1, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .address = ADIS16080_DIN_AIN2, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .address = ADIS16080_DIN_TEMP, + } }; static const struct iio_info adis16080_info = { - .attrs = &adis16080_attribute_group, + .read_raw = &adis16080_read_raw, .driver_module = THIS_MODULE, }; @@ -147,6 +155,8 @@ static int __devinit adis16080_probe(struct spi_device *spi) mutex_init(&st->buf_lock); indio_dev->name = spi->dev.driver->name; + indio_dev->channels = adis16080_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16080_channels); indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16080_info; indio_dev->modes = INDIO_DIRECT_MODE; From 494c6b150a3170b27b65969de83ec1ab580de701 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:58 +0100 Subject: [PATCH 0183/1519] staging:iio:magnetometer:hmc5843 iio_chan_spec conversion. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/hmc5843.c | 96 ++++++++++++---------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index b44c273a91a..1bb71864d58 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -24,7 +24,6 @@ #include #include "../iio.h" #include "../sysfs.h" -#include "magnet.h" #define HMC5843_I2C_ADDRESS 0x1E @@ -62,9 +61,9 @@ /* * Device status */ -#define DATA_READY 0x01 -#define DATA_OUTPUT_LOCK 0x02 -#define VOLTAGE_REGULATOR_ENABLED 0x04 +#define DATA_READY 0x01 +#define DATA_OUTPUT_LOCK 0x02 +#define VOLTAGE_REGULATOR_ENABLED 0x04 /* * Mode register configuration @@ -89,22 +88,16 @@ /* * Device Configutration */ -#define CONF_NORMAL 0x00 +#define CONF_NORMAL 0x00 #define CONF_POSITIVE_BIAS 0x01 #define CONF_NEGATIVE_BIAS 0x02 #define CONF_NOT_USED 0x03 #define MEAS_CONF_MASK 0x03 -static const char *regval_to_scale[] = { - "0.0000006173", - "0.0000007692", - "0.0000010309", - "0.0000012821", - "0.0000018868", - "0.0000021739", - "0.0000025641", - "0.0000035714", +static int hmc5843_regval_to_nanoscale[] = { + 6173, 7692, 10309, 12821, 18868, 21739, 25641, 35714 }; + static const int regval_to_input_field_mg[] = { 700, 1000, @@ -115,7 +108,7 @@ static const int regval_to_input_field_mg[] = { 4500, 6500 }; -static const char *regval_to_samp_freq[] = { +static const char * const regval_to_samp_freq[] = { "0.5", "1", "2", @@ -150,37 +143,28 @@ static s32 hmc5843_configure(struct i2c_client *client, } /* Return the measurement value from the specified channel */ -static ssize_t hmc5843_read_measurement(struct device *dev, - struct device_attribute *attr, - char *buf) +static int hmc5843_read_measurement(struct iio_dev *indio_dev, + int address, + int *val) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct i2c_client *client = to_i2c_client(indio_dev->dev.parent); - s16 coordinate_val; - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct hmc5843_data *data = iio_priv(indio_dev); s32 result; mutex_lock(&data->lock); - result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG); while (!(result & DATA_READY)) result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG); - result = i2c_smbus_read_word_data(client, this_attr->address); + result = i2c_smbus_read_word_data(client, address); mutex_unlock(&data->lock); if (result < 0) return -EINVAL; - coordinate_val = (s16)swab16((u16)result); - return sprintf(buf, "%d\n", coordinate_val); + *val = (s16)swab16((u16)result); + return IIO_VAL_INT; } -static IIO_DEV_ATTR_MAGN_X(hmc5843_read_measurement, - HMC5843_DATA_OUT_X_MSB_REG); -static IIO_DEV_ATTR_MAGN_Y(hmc5843_read_measurement, - HMC5843_DATA_OUT_Y_MSB_REG); -static IIO_DEV_ATTR_MAGN_Z(hmc5843_read_measurement, - HMC5843_DATA_OUT_Z_MSB_REG); + /* * From the datasheet @@ -336,7 +320,7 @@ static s32 hmc5843_set_rate(struct i2c_client *client, reg_val = (data->meas_conf) | (rate << RATE_OFFSET); if (rate >= RATE_NOT_USED) { dev_err(&client->dev, - "This data output rate is not supported \n"); + "This data output rate is not supported\n"); return -EINVAL; } return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val); @@ -467,28 +451,46 @@ static IIO_DEVICE_ATTR(magn_range, set_range, HMC5843_CONFIG_REG_B); -static ssize_t show_scale(struct device *dev, - struct device_attribute *attr, - char *buf) +static int hmc5843_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct hmc5843_data *data = iio_priv(indio_dev); - return strlen(strcpy(buf, regval_to_scale[data->range])); + + switch (mask) { + case 0: + return hmc5843_read_measurement(indio_dev, + chan->address, + val); + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + *val = 0; + *val2 = hmc5843_regval_to_nanoscale[data->range]; + return IIO_VAL_INT_PLUS_NANO; + }; + return -EINVAL; } -static IIO_DEVICE_ATTR(magn_scale, - S_IRUGO, - show_scale, - NULL , 0); + +#define HMC5843_CHANNEL(axis, add) \ + { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .address = add \ + } + +static const struct iio_chan_spec hmc5843_channels[] = { + HMC5843_CHANNEL(X, HMC5843_DATA_OUT_X_MSB_REG), + HMC5843_CHANNEL(Y, HMC5843_DATA_OUT_Y_MSB_REG), + HMC5843_CHANNEL(Z, HMC5843_DATA_OUT_Z_MSB_REG), +}; static struct attribute *hmc5843_attributes[] = { &iio_dev_attr_meas_conf.dev_attr.attr, &iio_dev_attr_operating_mode.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_magn_range.dev_attr.attr, - &iio_dev_attr_magn_scale.dev_attr.attr, - &iio_dev_attr_magn_x_raw.dev_attr.attr, - &iio_dev_attr_magn_y_raw.dev_attr.attr, - &iio_dev_attr_magn_z_raw.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL }; @@ -530,6 +532,7 @@ static void hmc5843_init_client(struct i2c_client *client) static const struct iio_info hmc5843_info = { .attrs = &hmc5843_group, + .read_raw = &hmc5843_read_raw, .driver_module = THIS_MODULE, }; @@ -558,6 +561,9 @@ static int hmc5843_probe(struct i2c_client *client, hmc5843_init_client(client); indio_dev->info = &hmc5843_info; + indio_dev->name = id->name; + indio_dev->channels = hmc5843_channels; + indio_dev->num_channels = ARRAY_SIZE(hmc5843_channels); indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; err = iio_device_register(indio_dev); From ae0b4bddc666834b3075a08ecb15f54989c18136 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:47:59 +0100 Subject: [PATCH 0184/1519] staging:iio:gyro:adis16130 move to iio_chan_spec registration. Simple conversion now we've dropped the type attributes. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16130_core.c | 57 +++++++++++------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index 6d3cd6c2bff..5ddaefcf94a 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -17,8 +17,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "gyro.h" -#include "../adc/adc.h" #define ADIS16130_CON 0x0 #define ADIS16130_CON_RD (1 << 6) @@ -50,11 +48,9 @@ struct adis16130_state { u8 buf[4] ____cacheline_aligned; }; -static int adis16130_spi_read(struct device *dev, u8 reg_addr, - u32 *val) +static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16130_state *st = iio_priv(indio_dev); struct spi_message msg; struct spi_transfer xfer = { @@ -80,43 +76,40 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr, return ret; } -static ssize_t adis16130_val_read(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adis16130_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) { - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *indio_dev = dev_get_drvdata(dev); - u32 val; - ssize_t ret; + int ret; + u32 temp; /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); - ret = adis16130_spi_read(dev, this_attr->address, &val); + ret = adis16130_spi_read(indio_dev, chan->address, &temp); mutex_unlock(&indio_dev->mlock); - - if (ret == 0) - return sprintf(buf, "%d\n", val); - else + if (ret) return ret; + *val = temp; + return IIO_VAL_INT; } -static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16130_val_read, NULL, - ADIS16130_TEMPDATA); - -static IIO_DEV_ATTR_GYRO_Z(adis16130_val_read, ADIS16130_RATEDATA); - -static struct attribute *adis16130_attributes[] = { - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_dev_attr_gyro_z_raw.dev_attr.attr, - NULL -}; - -static const struct attribute_group adis16130_attribute_group = { - .attrs = adis16130_attributes, +static const struct iio_chan_spec adis16130_channels[] = { + { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .address = ADIS16130_RATEDATA, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .address = ADIS16130_TEMPDATA, + } }; static const struct iio_info adis16130_info = { - .attrs = &adis16130_attribute_group, + .read_raw = &adis16130_read_raw, .driver_module = THIS_MODULE, }; @@ -138,6 +131,8 @@ static int __devinit adis16130_probe(struct spi_device *spi) st->us = spi; mutex_init(&st->buf_lock); indio_dev->name = spi->dev.driver->name; + indio_dev->channels = adis16130_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16130_channels); indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16130_info; indio_dev->modes = INDIO_DIRECT_MODE; From 4f2ca0809ccfa683f631d86820834decacd0ada9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:48:00 +0100 Subject: [PATCH 0185/1519] staging:iio:gyro:adis16060 convert to iio_chan_spec Still a very odd driver. This patch has the side effect of changing it's name slightly. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16060_core.c | 115 ++++++++++++---------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index afa52d1961a..0cbe677359b 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -14,11 +14,8 @@ #include #include - #include "../iio.h" #include "../sysfs.h" -#include "gyro.h" -#include "../adc/adc.h" #define ADIS16060_GYRO 0x20 /* Measure Angular Rate (Gyro) */ #define ADIS16060_TEMP_OUT 0x10 /* Measure Temperature */ @@ -42,11 +39,9 @@ struct adis16060_state { static struct iio_dev *adis16060_iio_dev; -static int adis16060_spi_write(struct device *dev, - u8 val) +static int adis16060_spi_write(struct iio_dev *indio_dev, u8 val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16060_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); @@ -57,11 +52,9 @@ static int adis16060_spi_write(struct device *dev, return ret; } -static int adis16060_spi_read(struct device *dev, - u16 *val) +static int adis16060_spi_read(struct iio_dev *indio_dev, u16 *val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16060_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); @@ -82,60 +75,71 @@ static int adis16060_spi_read(struct device *dev, return ret; } -static ssize_t adis16060_read(struct device *dev, - struct device_attribute *attr, - char *buf) +static int adis16060_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) { - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *indio_dev = dev_get_drvdata(dev); - u16 val = 0; - ssize_t ret; + u16 tval = 0; + int ret; - /* Take the iio_dev status lock */ - mutex_lock(&indio_dev->mlock); + switch (mask) { + case 0: + /* Take the iio_dev status lock */ + mutex_lock(&indio_dev->mlock); + ret = adis16060_spi_write(indio_dev, chan->address); + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); + return ret; + } + ret = adis16060_spi_read(indio_dev, &tval); + mutex_unlock(&indio_dev->mlock); + *val = tval; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + *val = -7; + *val2 = 461117; + return IIO_VAL_INT_PLUS_MICRO; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + *val = 0; + *val2 = 34000; + return IIO_VAL_INT_PLUS_MICRO; + } - ret = adis16060_spi_write(dev, this_attr->address); - if (ret < 0) - goto error_ret; - ret = adis16060_spi_read(dev, &val); -error_ret: - mutex_unlock(&indio_dev->mlock); - - if (ret == 0) - return sprintf(buf, "%d\n", val); - else - return ret; + return -EINVAL; } -static IIO_DEV_ATTR_GYRO_Z(adis16060_read, ADIS16060_GYRO); -static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16060_read, NULL, - ADIS16060_TEMP_OUT); -static IIO_CONST_ATTR_TEMP_SCALE("34"); /* Milli degrees C */ -static IIO_CONST_ATTR_TEMP_OFFSET("-7461.117"); /* Milli degrees C */ -static IIO_DEV_ATTR_IN_RAW(0, adis16060_read, ADIS16060_AIN1); -static IIO_DEV_ATTR_IN_RAW(1, adis16060_read, ADIS16060_AIN2); -static IIO_CONST_ATTR(name, "adis16060"); - -static struct attribute *adis16060_attributes[] = { - &iio_dev_attr_gyro_z_raw.dev_attr.attr, - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_dev_attr_in0_raw.dev_attr.attr, - &iio_dev_attr_in1_raw.dev_attr.attr, - &iio_const_attr_name.dev_attr.attr, - NULL -}; - -static const struct attribute_group adis16060_attribute_group = { - .attrs = adis16060_attributes, -}; - static const struct iio_info adis16060_info = { - .attrs = &adis16060_attribute_group, + .read_raw = &adis16060_read_raw, .driver_module = THIS_MODULE, }; +static const struct iio_chan_spec adis16060_channels[] = { + { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .address = ADIS16060_GYRO, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 0, + .address = ADIS16060_AIN1, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .address = ADIS16060_AIN2, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = ADIS16060_TEMP_OUT, + } +}; + static int __devinit adis16060_r_probe(struct spi_device *spi) { int ret, regdone = 0; @@ -154,9 +158,12 @@ static int __devinit adis16060_r_probe(struct spi_device *spi) st->us_r = spi; mutex_init(&st->buf_lock); + indio_dev->name = spi->dev.driver->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16060_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = adis16060_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16060_channels); ret = iio_device_register(indio_dev); if (ret) From c9b9e49e131ccf51aad931b490134f0d1f04a8e7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:48:01 +0100 Subject: [PATCH 0186/1519] staging:iio:accel:adis16204: use peak_raw info_mask element + push some defs down from header. Currently this is the only driver using some of the defines in accel.h. If these become common we'll just add them to the channel_spec options, for now push down into this driver. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16204_core.c | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 3e2b62654b7..6a64b2b723d 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -21,8 +21,6 @@ #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" -#include "accel.h" -#include "../adc/adc.h" #include "adis16204.h" @@ -299,12 +297,15 @@ static int adis16204_initial_setup(struct iio_dev *indio_dev) err_ret: return ret; } + +/* Unique to this driver currently */ +#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \ + IIO_DEVICE_ATTR(accel_xy, S_IRUGO, _show, NULL, _addr) +#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \ + IIO_DEVICE_ATTR(accel_xypeak, S_IRUGO, _show, NULL, _addr) + static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed, ADIS16204_XY_RSS_OUT); -static IIO_DEV_ATTR_ACCEL_XPEAK(adis16204_read_14bit_signed, - ADIS16204_X_PEAK_OUT); -static IIO_DEV_ATTR_ACCEL_YPEAK(adis16204_read_14bit_signed, - ADIS16204_Y_PEAK_OUT); static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed, ADIS16204_XY_PEAK_OUT); static IIO_CONST_ATTR(accel_xy_scale, "0.017125"); @@ -319,13 +320,16 @@ enum adis16204_channel { accel_y, }; -static u8 adis16204_addresses[5][2] = { +static u8 adis16204_addresses[5][3] = { [in_supply] = { ADIS16204_SUPPLY_OUT }, [in_aux] = { ADIS16204_AUX_ADC }, [temp] = { ADIS16204_TEMP_OUT }, - [accel_x] = { ADIS16204_XACCL_OUT, ADIS16204_XACCL_NULL }, - [accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL }, + [accel_x] = { ADIS16204_XACCL_OUT, ADIS16204_XACCL_NULL, + ADIS16204_X_PEAK_OUT }, + [accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL, + ADIS16204_Y_PEAK_OUT }, }; + static int adis16204_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, @@ -335,6 +339,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, int bits; u8 addr; s16 val16; + int addrind; switch (mask) { case 0: @@ -389,15 +394,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, *val = 25; return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): - switch (chan->type) { - case IIO_ACCEL: + case (1 << IIO_CHAN_INFO_PEAK_SEPARATE): + if (mask == (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE)) { bits = 12; - break; - default: - return -EINVAL; - }; + addrind = 1; + } else { /* PEAK_SEPARATE */ + bits = 14; + addrind = 2; + } mutex_lock(&indio_dev->mlock); - addr = adis16204_addresses[chan->address][1]; + addr = adis16204_addresses[chan->address][addrind]; ret = adis16204_spi_read_reg_16(indio_dev, addr, &val16); if (ret) { mutex_unlock(&indio_dev->mlock); @@ -453,21 +459,22 @@ static struct iio_chan_spec adis16204_channels[] = { IIO_ST('u', 12, 16, 0), 0), IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, (1 << IIO_CHAN_INFO_SCALE_SEPARATE) | - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_PEAK_SEPARATE), accel_x, ADIS16204_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, (1 << IIO_CHAN_INFO_SCALE_SEPARATE) | - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_PEAK_SEPARATE), accel_y, ADIS16204_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), IIO_CHAN_SOFT_TIMESTAMP(5), }; + static struct attribute *adis16204_attributes[] = { &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_accel_xy.dev_attr.attr, - &iio_dev_attr_accel_xpeak.dev_attr.attr, - &iio_dev_attr_accel_ypeak.dev_attr.attr, &iio_dev_attr_accel_xypeak.dev_attr.attr, &iio_const_attr_accel_xy_scale.dev_attr.attr, NULL From 7991029a55fa1d172b2162288345276f9e818785 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:48:02 +0100 Subject: [PATCH 0187/1519] staging:iio:accel:adis16220 iio_chan_spec conversion. I still have numerous issues with this driver and it needs a substantial rewrite. Whilst doing this patch at least one bug has been fixed (temp reading didn't have an address) and a number of missing channel info elements added. Untested! Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16220_core.c | 342 +++++++++++++-------- 1 file changed, 211 insertions(+), 131 deletions(-) diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index bf9ba07c038..075e40fabf4 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -6,9 +6,6 @@ * Licensed under the GPL-2 or later. */ -#include -#include -#include #include #include #include @@ -16,12 +13,9 @@ #include #include #include -#include #include "../iio.h" #include "../sysfs.h" -#include "accel.h" -#include "../adc/adc.h" #include "adis16220.h" @@ -29,16 +23,15 @@ /** * adis16220_spi_write_reg_8() - write single byte to a register - * @dev: device associated with child of actual device (iio_dev or iio_trig) + * @indio_dev: iio device associated with child of actual device * @reg_address: the address of the register to be written * @val: the value to write **/ -static int adis16220_spi_write_reg_8(struct device *dev, +static int adis16220_spi_write_reg_8(struct iio_dev *indio_dev, u8 reg_address, u8 val) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16220_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); @@ -53,18 +46,17 @@ static int adis16220_spi_write_reg_8(struct device *dev, /** * adis16220_spi_write_reg_16() - write 2 bytes to a pair of registers - * @dev: device associated with child of actual device (iio_dev or iio_trig) + * @indio_dev: iio device associated with child of actual device * @reg_address: the address of the lower of the two registers. Second register * is assumed to have address one greater. * @val: value to be written **/ -static int adis16220_spi_write_reg_16(struct device *dev, +static int adis16220_spi_write_reg_16(struct iio_dev *indio_dev, u8 lower_reg_address, u16 value) { int ret; struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16220_state *st = iio_priv(indio_dev); struct spi_transfer xfers[] = { { @@ -77,7 +69,6 @@ static int adis16220_spi_write_reg_16(struct device *dev, .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, - .cs_change = 1, .delay_usecs = 35, }, }; @@ -99,17 +90,16 @@ static int adis16220_spi_write_reg_16(struct device *dev, /** * adis16220_spi_read_reg_16() - read 2 bytes from a 16-bit register - * @dev: device associated with child of actual device (iio_dev or iio_trig) + * @indio_dev: iio device associated with child of actual device * @reg_address: the address of the lower of the two registers. Second register * is assumed to have address one greater. * @val: somewhere to pass back the value read **/ -static int adis16220_spi_read_reg_16(struct device *dev, - u8 lower_reg_address, - u16 *val) +static int adis16220_spi_read_reg_16(struct iio_dev *indio_dev, + u8 lower_reg_address, + u16 *val) { struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adis16220_state *st = iio_priv(indio_dev); int ret; struct spi_transfer xfers[] = { @@ -149,52 +139,23 @@ error_ret: return ret; } -static ssize_t adis16220_spi_read_signed(struct device *dev, - struct device_attribute *attr, - char *buf, - unsigned bits) -{ - int ret; - s16 val = 0; - unsigned shift = 16 - bits; - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - - ret = adis16220_spi_read_reg_16(dev, this_attr->address, (u16 *)&val); - if (ret) - return ret; - - val = ((s16)(val << shift) >> shift); - return sprintf(buf, "%d\n", val); -} - -static ssize_t adis16220_read_12bit_unsigned(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int ret; - u16 val = 0; - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - - ret = adis16220_spi_read_reg_16(dev, this_attr->address, &val); - if (ret) - return ret; - - return sprintf(buf, "%u\n", val & 0x0FFF); -} - static ssize_t adis16220_read_16bit(struct device *dev, struct device_attribute *attr, char *buf) { + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev *indio_dev = dev_get_drvdata(dev); ssize_t ret; + s16 val = 0; /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); - ret = adis16220_spi_read_signed(dev, attr, buf, 16); + ret = adis16220_spi_read_reg_16(indio_dev, this_attr->address, + (u16 *)&val); mutex_unlock(&indio_dev->mlock); - - return ret; + if (ret) + return ret; + return sprintf(buf, "%d\n", val); } static ssize_t adis16220_write_16bit(struct device *dev, @@ -202,6 +163,7 @@ static ssize_t adis16220_write_16bit(struct device *dev, const char *buf, size_t len) { + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; long val; @@ -209,34 +171,34 @@ static ssize_t adis16220_write_16bit(struct device *dev, ret = strict_strtol(buf, 10, &val); if (ret) goto error_ret; - ret = adis16220_spi_write_reg_16(dev, this_attr->address, val); + ret = adis16220_spi_write_reg_16(indio_dev, this_attr->address, val); error_ret: return ret ? ret : len; } -static int adis16220_capture(struct device *dev) +static int adis16220_capture(struct iio_dev *indio_dev) { int ret; - ret = adis16220_spi_write_reg_16(dev, + ret = adis16220_spi_write_reg_16(indio_dev, ADIS16220_GLOB_CMD, 0xBF08); /* initiates a manual data capture */ if (ret) - dev_err(dev, "problem beginning capture"); + dev_err(&indio_dev->dev, "problem beginning capture"); msleep(10); /* delay for capture to finish */ return ret; } -static int adis16220_reset(struct device *dev) +static int adis16220_reset(struct iio_dev *indio_dev) { int ret; - ret = adis16220_spi_write_reg_8(dev, + ret = adis16220_spi_write_reg_8(indio_dev, ADIS16220_GLOB_CMD, ADIS16220_GLOB_CMD_SW_RESET); if (ret) - dev_err(dev, "problem resetting device"); + dev_err(&indio_dev->dev, "problem resetting device"); return ret; } @@ -245,72 +207,84 @@ static ssize_t adis16220_write_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return adis16220_reset(dev) == 0 ? len : -EIO; - } - return -1; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + bool val; + int ret; + + ret = strtobool(buf, &val); + if (ret) + return ret; + if (!val) + return -EINVAL; + + ret = adis16220_reset(indio_dev); + if (ret) + return ret; + return len; } static ssize_t adis16220_write_capture(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return adis16220_capture(dev) == 0 ? len : -EIO; - } - return -1; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + bool val; + int ret; + + ret = strtobool(buf, &val); + if (ret) + return ret; + if (!val) + return -EINVAL; + ret = adis16220_capture(indio_dev); + if (ret) + return ret; + + return len; } -static int adis16220_check_status(struct device *dev) +static int adis16220_check_status(struct iio_dev *indio_dev) { u16 status; int ret; - ret = adis16220_spi_read_reg_16(dev, ADIS16220_DIAG_STAT, &status); + ret = adis16220_spi_read_reg_16(indio_dev, ADIS16220_DIAG_STAT, + &status); if (ret < 0) { - dev_err(dev, "Reading status failed\n"); + dev_err(&indio_dev->dev, "Reading status failed\n"); goto error_ret; } ret = status & 0x7F; if (status & ADIS16220_DIAG_STAT_VIOLATION) - dev_err(dev, "Capture period violation/interruption\n"); + dev_err(&indio_dev->dev, + "Capture period violation/interruption\n"); if (status & ADIS16220_DIAG_STAT_SPI_FAIL) - dev_err(dev, "SPI failure\n"); + dev_err(&indio_dev->dev, "SPI failure\n"); if (status & ADIS16220_DIAG_STAT_FLASH_UPT) - dev_err(dev, "Flash update failed\n"); + dev_err(&indio_dev->dev, "Flash update failed\n"); if (status & ADIS16220_DIAG_STAT_POWER_HIGH) - dev_err(dev, "Power supply above 3.625V\n"); + dev_err(&indio_dev->dev, "Power supply above 3.625V\n"); if (status & ADIS16220_DIAG_STAT_POWER_LOW) - dev_err(dev, "Power supply below 3.15V\n"); + dev_err(&indio_dev->dev, "Power supply below 3.15V\n"); error_ret: return ret; } -static int adis16220_self_test(struct device *dev) +static int adis16220_self_test(struct iio_dev *indio_dev) { int ret; - ret = adis16220_spi_write_reg_16(dev, + ret = adis16220_spi_write_reg_16(indio_dev, ADIS16220_MSC_CTRL, ADIS16220_MSC_CTRL_SELF_TEST_EN); if (ret) { - dev_err(dev, "problem starting self test"); + dev_err(&indio_dev->dev, "problem starting self test"); goto err_ret; } - adis16220_check_status(dev); + adis16220_check_status(indio_dev); err_ret: return ret; @@ -319,24 +293,23 @@ err_ret: static int adis16220_initial_setup(struct iio_dev *indio_dev) { int ret; - struct device *dev = &indio_dev->dev; /* Do self test */ - ret = adis16220_self_test(dev); + ret = adis16220_self_test(indio_dev); if (ret) { - dev_err(dev, "self test failure"); + dev_err(&indio_dev->dev, "self test failure"); goto err_ret; } /* Read status register to check the result */ - ret = adis16220_check_status(dev); + ret = adis16220_check_status(indio_dev); if (ret) { - adis16220_reset(dev); - dev_err(dev, "device not playing ball -> reset"); + adis16220_reset(indio_dev); + dev_err(&indio_dev->dev, "device not playing ball -> reset"); msleep(ADIS16220_STARTUP_DELAY); - ret = adis16220_check_status(dev); + ret = adis16220_check_status(indio_dev); if (ret) { - dev_err(dev, "giving up"); + dev_err(&indio_dev->dev, "giving up"); goto err_ret; } } @@ -381,7 +354,7 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev, count = ADIS16220_CAPTURE_SIZE - off; /* write the begin position of capture buffer */ - ret = adis16220_spi_write_reg_16(&indio_dev->dev, + ret = adis16220_spi_write_reg_16(indio_dev, ADIS16220_CAPT_PNTR, off > 1); if (ret) @@ -480,24 +453,6 @@ static struct bin_attribute adc2_bin = { .size = ADIS16220_CAPTURE_SIZE, }; -static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16220_read_12bit_unsigned, - ADIS16220_CAPT_SUPPLY); -static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.0012207"); -static IIO_DEV_ATTR_ACCEL(adis16220_read_16bit, ADIS16220_CAPT_BUFA); -static IIO_DEVICE_ATTR(accel_peak_raw, S_IRUGO, adis16220_read_16bit, - NULL, ADIS16220_CAPT_PEAKA); -static IIO_DEV_ATTR_ACCEL_OFFSET(S_IWUSR | S_IRUGO, - adis16220_read_16bit, - adis16220_write_16bit, - ADIS16220_ACCL_NULL); -static IIO_CONST_ATTR_ACCEL_SCALE("0.18704223545"); -static IIO_DEV_ATTR_TEMP_RAW(adis16220_read_12bit_unsigned); -static IIO_CONST_ATTR_TEMP_OFFSET("25"); -static IIO_CONST_ATTR_TEMP_SCALE("-0.47"); - -static IIO_DEV_ATTR_IN_RAW(1, adis16220_read_16bit, ADIS16220_CAPT_BUF1); -static IIO_DEV_ATTR_IN_RAW(2, adis16220_read_16bit, ADIS16220_CAPT_BUF2); - static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16220_write_reset, 0); @@ -514,21 +469,142 @@ static IIO_DEV_ATTR_CAPTURE_COUNT(S_IWUSR | S_IRUGO, adis16220_write_16bit, ADIS16220_CAPT_PNTR); -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100200"); +enum adis16220_channel { + in_supply, in_1, in_2, accel, temp +}; + +struct adis16220_address_spec { + u8 addr; + u8 bits; + bool sign; +}; + +/* Address / bits / signed */ +static const struct adis16220_address_spec adis16220_addresses[][3] = { + [in_supply] = { { ADIS16220_CAPT_SUPPLY, 12, 0 }, }, + [in_1] = { { ADIS16220_CAPT_BUF1, 16, 1 }, + { ADIS16220_AIN1_NULL, 16, 1 }, + { ADIS16220_CAPT_PEAK1, 16, 1 }, }, + [in_2] = { { ADIS16220_CAPT_BUF2, 16, 1 }, + { ADIS16220_AIN2_NULL, 16, 1 }, + { ADIS16220_CAPT_PEAK2, 16, 1 }, }, + [accel] = { { ADIS16220_CAPT_BUFA, 16, 1 }, + { ADIS16220_ACCL_NULL, 16, 1 }, + { ADIS16220_CAPT_PEAKA, 16, 1 }, }, + [temp] = { { ADIS16220_CAPT_TEMP, 12, 0 }, } +}; + +static int adis16220_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + int ret = -EINVAL; + int addrind = 0; + u16 uval; + s16 sval; + u8 bits; + + switch (mask) { + case 0: + addrind = 0; + break; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + if (chan->type == IIO_TEMP) { + *val = 25; + return IIO_VAL_INT; + } + addrind = 1; + break; + case (1 << IIO_CHAN_INFO_PEAK_SEPARATE): + addrind = 2; + break; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + *val = 0; + switch (chan->type) { + case IIO_TEMP: + *val2 = -470000; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_ACCEL: + *val2 = 1887042; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_IN: + if (chan->channel == 0) + *val2 = 0012221; + else /* Should really be dependent on VDD */ + *val2 = 305; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + default: + return -EINVAL; + } + if (adis16220_addresses[chan->address][addrind].sign) { + ret = adis16220_spi_read_reg_16(indio_dev, + adis16220_addresses[chan + ->address] + [addrind].addr, + &sval); + if (ret) + return ret; + bits = adis16220_addresses[chan->address][addrind].bits; + sval &= (1 << bits) - 1; + sval = (s16)(sval << (16 - bits)) >> (16 - bits); + *val = sval; + return IIO_VAL_INT; + } else { + ret = adis16220_spi_read_reg_16(indio_dev, + adis16220_addresses[chan + ->address] + [addrind].addr, + &uval); + if (ret) + return ret; + bits = adis16220_addresses[chan->address][addrind].bits; + uval &= (1 << bits) - 1; + *val = uval; + return IIO_VAL_INT; + } +} + +static const struct iio_chan_spec adis16220_channels[] = { + { + .type = IIO_IN, + .indexed = 1, + .channel = 0, + .extend_name = "supply", + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in_supply, + }, { + .type = IIO_ACCEL, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_PEAK_SEPARATE), + .address = accel, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in_1, + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 2, + .address = in_2, + } +}; static struct attribute *adis16220_attributes[] = { - &iio_dev_attr_in0_supply_raw.dev_attr.attr, - &iio_const_attr_in0_supply_scale.dev_attr.attr, - &iio_dev_attr_accel_raw.dev_attr.attr, - &iio_dev_attr_accel_offset.dev_attr.attr, - &iio_dev_attr_accel_peak_raw.dev_attr.attr, - &iio_const_attr_accel_scale.dev_attr.attr, - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_dev_attr_in1_raw.dev_attr.attr, - &iio_dev_attr_in2_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_capture.dev_attr.attr, &iio_dev_attr_capture_count.dev_attr.attr, @@ -542,7 +618,9 @@ static const struct attribute_group adis16220_attribute_group = { static const struct iio_info adis16220_info = { .attrs = &adis16220_attribute_group, .driver_module = THIS_MODULE, + .read_raw = &adis16220_read_raw, }; + static int __devinit adis16220_probe(struct spi_device *spi) { int ret, regdone = 0; @@ -567,6 +645,8 @@ static int __devinit adis16220_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16220_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = adis16220_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16220_channels); ret = iio_device_register(indio_dev); if (ret) From 694e1b5f95725d48a1d4ff5e93042118d50ee235 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:48:03 +0100 Subject: [PATCH 0188/1519] staging:iio:magnetometer:ak8975 convert to iio_chan_spec + cleanups. iio_chan_spec conversion is straight forward. Other changes: * use i2c_smbus_write_byte_data in write_data * c99 isms to setup various structures. * move the comment about the scale factor and kill off trivial access func. * make mode setting code use a bool rather than a ulong. Ultimately I'd like to get rid of that mode bit entirely and handle it through core pm routines, but have left it for now. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/ak8975.c | 242 +++++++++++----------- 1 file changed, 117 insertions(+), 125 deletions(-) diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 33919e87e7c..a17fa9f6a30 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -31,7 +31,6 @@ #include #include "../iio.h" -#include "magnet.h" /* * Register definitions, as well as various shifts and masks to get at the @@ -93,38 +92,28 @@ struct ak8975_data { struct mutex lock; u8 asa[3]; long raw_to_gauss[3]; - unsigned long mode; + bool mode; u8 reg_cache[AK8975_MAX_REGS]; int eoc_gpio; int eoc_irq; }; +static const int ak8975_index_to_reg[] = { + AK8975_REG_HXL, AK8975_REG_HYL, AK8975_REG_HZL, +}; + /* * Helper function to write to the I2C device's registers. */ static int ak8975_write_data(struct i2c_client *client, u8 reg, u8 val, u8 mask, u8 shift) { - u8 regval; - struct i2c_msg msg; - u8 w_data[2]; - int ret = 0; - struct ak8975_data *data = i2c_get_clientdata(client); + u8 regval; + int ret; - regval = data->reg_cache[reg]; - regval &= ~mask; - regval |= val << shift; - - w_data[0] = reg; - w_data[1] = regval; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - msg.buf = w_data; - - ret = i2c_transfer(client->adapter, &msg, 1); + regval = (data->reg_cache[reg] & ~mask) | (val << shift); + ret = i2c_smbus_write_byte_data(client, reg, regval); if (ret < 0) { dev_err(&client->dev, "Write to device fails status %x\n", ret); return ret; @@ -140,21 +129,20 @@ static int ak8975_write_data(struct i2c_client *client, static int ak8975_read_data(struct i2c_client *client, u8 reg, u8 length, u8 *buffer) { - struct i2c_msg msg[2]; - u8 w_data[2]; int ret; - - w_data[0] = reg; - - msg[0].addr = client->addr; - msg[0].flags = I2C_M_NOSTART; /* set repeated start and write */ - msg[0].len = 1; - msg[0].buf = w_data; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = length; - msg[1].buf = buffer; + struct i2c_msg msg[2] = { + { + .addr = client->addr, + .flags = I2C_M_NOSTART, + .len = 1, + .buf = ®, + }, { + .addr = client->addr, + .flags = I2C_M_RD, + .len = length, + .buf = buffer, + } + }; ret = i2c_transfer(client->adapter, msg, 2); if (ret < 0) { @@ -204,75 +192,9 @@ static int ak8975_setup(struct i2c_client *client) return ret; } - /* Precalculate scale factor for each axis and - store in the device data. */ - data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8; - data->raw_to_gauss[1] = ((data->asa[1] + 128) * 30) >> 8; - data->raw_to_gauss[2] = ((data->asa[2] + 128) * 30) >> 8; - - return 0; -} - /* - * Shows the device's mode. 0 = off, 1 = on. - */ -static ssize_t show_mode(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ak8975_data *data = iio_priv(indio_dev); - - return sprintf(buf, "%lu\n", data->mode); -} - -/* - * Sets the device's mode. 0 = off, 1 = on. The device's mode must be on - * for the magn raw attributes to be available. - */ -static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ak8975_data *data = iio_priv(indio_dev); - struct i2c_client *client = data->client; - unsigned long oval; - int ret; - - /* Convert mode string and do some basic sanity checking on it. - only 0 or 1 are valid. */ - if (strict_strtoul(buf, 10, &oval)) - return -EINVAL; - - if (oval > 1) { - dev_err(dev, "mode value is not supported\n"); - return -EINVAL; - } - - mutex_lock(&data->lock); - - /* Write the mode to the device. */ - if (data->mode != oval) { - ret = ak8975_write_data(client, - AK8975_REG_CNTL, - (u8)oval, - AK8975_REG_CNTL_MODE_MASK, - AK8975_REG_CNTL_MODE_SHIFT); - - if (ret < 0) { - dev_err(&client->dev, "Error in setting mode\n"); - mutex_unlock(&data->lock); - return ret; - } - data->mode = oval; - } - - mutex_unlock(&data->lock); - - return count; -} - -/* - * Emits the scale factor to bring the raw value into Gauss units. + * Precalculate scale factor (in Gauss units) for each axis and + * store in the device data. * * This scale factor is axis-dependent, and is derived from 3 calibration * factors ASA(x), ASA(y), and ASA(z). @@ -305,14 +227,65 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, * Since ASA doesn't change, we cache the resultant scale factor into the * device context in ak8975_setup(). */ -static ssize_t show_scale(struct device *dev, struct device_attribute *devattr, - char *buf) + data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8; + data->raw_to_gauss[1] = ((data->asa[1] + 128) * 30) >> 8; + data->raw_to_gauss[2] = ((data->asa[2] + 128) * 30) >> 8; + + return 0; +} + +/* + * Shows the device's mode. 0 = off, 1 = on. + */ +static ssize_t show_mode(struct device *dev, struct device_attribute *devattr, + char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ak8975_data *data = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(devattr); - return sprintf(buf, "%ld\n", data->raw_to_gauss[this_attr->address]); + return sprintf(buf, "%u\n", data->mode); +} + +/* + * Sets the device's mode. 0 = off, 1 = on. The device's mode must be on + * for the magn raw attributes to be available. + */ +static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ak8975_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + bool value; + int ret; + + /* Convert mode string and do some basic sanity checking on it. + only 0 or 1 are valid. */ + ret = strtobool(buf, &value); + if (ret < 0) + return ret; + + mutex_lock(&data->lock); + + /* Write the mode to the device. */ + if (data->mode != value) { + ret = ak8975_write_data(client, + AK8975_REG_CNTL, + (u8)value, + AK8975_REG_CNTL_MODE_MASK, + AK8975_REG_CNTL_MODE_SHIFT); + + if (ret < 0) { + dev_err(&client->dev, "Error in setting mode\n"); + mutex_unlock(&data->lock); + return ret; + } + data->mode = value; + } + + mutex_unlock(&data->lock); + + return count; } static int wait_conversion_complete_gpio(struct ak8975_data *data) @@ -371,13 +344,10 @@ static int wait_conversion_complete_polled(struct ak8975_data *data) /* * Emits the raw flux value for the x, y, or z axis. */ -static ssize_t show_raw(struct device *dev, struct device_attribute *devattr, - char *buf) +static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ak8975_data *data = iio_priv(indio_dev); struct i2c_client *client = data->client; - struct iio_dev_attr *this_attr = to_iio_dev_attr(devattr); u16 meas_reg; s16 raw; u8 read_status; @@ -429,7 +399,8 @@ static ssize_t show_raw(struct device *dev, struct device_attribute *devattr, /* Read the flux value from the appropriate register (the register is specified in the iio device attributes). */ - ret = ak8975_read_data(client, this_attr->address, 2, (u8 *)&meas_reg); + ret = ak8975_read_data(client, ak8975_index_to_reg[index], + 2, (u8 *)&meas_reg); if (ret < 0) { dev_err(&client->dev, "Read axis data fails\n"); goto exit; @@ -442,30 +413,48 @@ static ssize_t show_raw(struct device *dev, struct device_attribute *devattr, /* Clamp to valid range. */ raw = clamp_t(s16, raw, -4096, 4095); - - return sprintf(buf, "%d\n", raw); + *val = raw; + return IIO_VAL_INT; exit: mutex_unlock(&data->lock); return ret; } +static int ak8975_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + struct ak8975_data *data = iio_priv(indio_dev); + + switch (mask) { + case 0: + return ak8975_read_axis(indio_dev, chan->address, val); + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + *val = data->raw_to_gauss[chan->address]; + return IIO_VAL_INT; + } + return -EINVAL; +} + +#define AK8975_CHANNEL(axis, index) \ + { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ + .address = index, \ + } + +static const struct iio_chan_spec ak8975_channels[] = { + AK8975_CHANNEL(X, 0), AK8975_CHANNEL(Y, 1), AK8975_CHANNEL(Z, 2), +}; + static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, show_mode, store_mode, 0); -static IIO_DEV_ATTR_MAGN_X_SCALE(S_IRUGO, show_scale, NULL, 0); -static IIO_DEV_ATTR_MAGN_Y_SCALE(S_IRUGO, show_scale, NULL, 1); -static IIO_DEV_ATTR_MAGN_Z_SCALE(S_IRUGO, show_scale, NULL, 2); -static IIO_DEV_ATTR_MAGN_X(show_raw, AK8975_REG_HXL); -static IIO_DEV_ATTR_MAGN_Y(show_raw, AK8975_REG_HYL); -static IIO_DEV_ATTR_MAGN_Z(show_raw, AK8975_REG_HZL); static struct attribute *ak8975_attr[] = { &iio_dev_attr_mode.dev_attr.attr, - &iio_dev_attr_magn_x_scale.dev_attr.attr, - &iio_dev_attr_magn_y_scale.dev_attr.attr, - &iio_dev_attr_magn_z_scale.dev_attr.attr, - &iio_dev_attr_magn_x_raw.dev_attr.attr, - &iio_dev_attr_magn_y_raw.dev_attr.attr, - &iio_dev_attr_magn_z_raw.dev_attr.attr, NULL }; @@ -475,6 +464,7 @@ static struct attribute_group ak8975_attr_group = { static const struct iio_info ak8975_info = { .attrs = &ak8975_attr_group, + .read_raw = &ak8975_read_raw, .driver_module = THIS_MODULE, }; @@ -530,6 +520,8 @@ static int ak8975_probe(struct i2c_client *client, data->eoc_irq = client->irq; data->eoc_gpio = eoc_gpio; indio_dev->dev.parent = &client->dev; + indio_dev->channels = ak8975_channels; + indio_dev->num_channels = ARRAY_SIZE(ak8975_channels); indio_dev->info = &ak8975_info; indio_dev->modes = INDIO_DIRECT_MODE; From 765f88f2ea18c8807f2ac9c1a302d06cc137cda3 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:55:59 +0100 Subject: [PATCH 0189/1519] staging:iio:magnetometer: remove unused header magnet.h Now all magnetomers are using iio_chan_spec there is no need for the macros in magnet.h Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/magnet.h | 31 ----------------------- 1 file changed, 31 deletions(-) delete mode 100644 drivers/staging/iio/magnetometer/magnet.h diff --git a/drivers/staging/iio/magnetometer/magnet.h b/drivers/staging/iio/magnetometer/magnet.h deleted file mode 100644 index 1260eb7bd41..00000000000 --- a/drivers/staging/iio/magnetometer/magnet.h +++ /dev/null @@ -1,31 +0,0 @@ - -#include "../sysfs.h" - -/* Magnetometer types of attribute */ - -#define IIO_DEV_ATTR_MAGN_X_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_x_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_Y_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_y_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_Z_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_z_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_X_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_x_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_Y_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_y_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_Z_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(magn_z_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_MAGN_X(_show, _addr) \ - IIO_DEVICE_ATTR(magn_x_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_MAGN_Y(_show, _addr) \ - IIO_DEVICE_ATTR(magn_y_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_MAGN_Z(_show, _addr) \ - IIO_DEVICE_ATTR(magn_z_raw, S_IRUGO, _show, NULL, _addr) From 9a0a73f4859b2793988a6c173615a3b18ec5eca6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:00 +0100 Subject: [PATCH 0190/1519] staging:iio:gyro: remove gyro.h Not longer needed now all devices with gyro channels are using iio_chan_spec registration. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/gyro.h | 85 --------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 drivers/staging/iio/gyro/gyro.h diff --git a/drivers/staging/iio/gyro/gyro.h b/drivers/staging/iio/gyro/gyro.h deleted file mode 100644 index b5495613407..00000000000 --- a/drivers/staging/iio/gyro/gyro.h +++ /dev/null @@ -1,85 +0,0 @@ - -#include "../sysfs.h" - -/* Gyroscope types of attribute */ - -#define IIO_CONST_ATTR_GYRO_OFFSET(_string) \ - IIO_CONST_ATTR(gyro_offset, _string) - -#define IIO_DEV_ATTR_GYRO_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_X_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_x_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Y_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_y_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Z_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_z_offset, _mode, _show, _store, _addr) - -#define IIO_CONST_ATTR_GYRO_SCALE(_string) \ - IIO_CONST_ATTR(gyro_scale, _string) - -#define IIO_DEV_ATTR_GYRO_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_scale, S_IRUGO, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_X_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_x_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Y_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_y_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Z_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_z_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_calibbias, S_IRUGO, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_X_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_x_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Y_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_y_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_z_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_calibscale, S_IRUGO, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_X_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_x_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Y_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_y_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Z_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(gyro_z_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_GYRO_Z_QUADRATURE_CORRECTION(_show, _addr) \ - IIO_DEVICE_ATTR(gyro_z_quadrature_correction_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_GYRO(_show, _addr) \ - IIO_DEVICE_ATTR(gyro_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_GYRO_X(_show, _addr) \ - IIO_DEVICE_ATTR(gyro_x_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_GYRO_Y(_show, _addr) \ - IIO_DEVICE_ATTR(gyro_y_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_GYRO_Z(_show, _addr) \ - IIO_DEVICE_ATTR(gyro_z_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ANGL(_show, _addr) \ - IIO_DEVICE_ATTR(angl_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ANGL_X(_show, _addr) \ - IIO_DEVICE_ATTR(angl_x_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ANGL_Y(_show, _addr) \ - IIO_DEVICE_ATTR(angl_y_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ANGL_Z(_show, _addr) \ - IIO_DEVICE_ATTR(angl_z_raw, S_IRUGO, _show, NULL, _addr) From bbb658a99b4de941048cc28daf874ddf0ddb146d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:01 +0100 Subject: [PATCH 0191/1519] staging:iio:accel remove unused accel.h header. The chan spec conversions and a small amount of pushdown of defines mean this header is no longer used. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/accel.h | 87 ------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 drivers/staging/iio/accel/accel.h diff --git a/drivers/staging/iio/accel/accel.h b/drivers/staging/iio/accel/accel.h deleted file mode 100644 index 50651f835ce..00000000000 --- a/drivers/staging/iio/accel/accel.h +++ /dev/null @@ -1,87 +0,0 @@ - -#include "../sysfs.h" - -/* Accelerometer types of attribute */ -#define IIO_DEV_ATTR_ACCEL_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_X_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_x_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Y_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_y_offset, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Z_OFFSET(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_z_offset, _mode, _show, _store, _addr) - -#define IIO_CONST_ATTR_ACCEL_SCALE(_string) \ - IIO_CONST_ATTR(accel_scale, _string) - -#define IIO_DEV_ATTR_ACCEL_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_X_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_x_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Y_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_y_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Z_SCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_z_scale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_x_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_y_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_z_calibbias, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_X_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_x_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Y_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_y_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL_Z_CALIBSCALE(_mode, _show, _store, _addr) \ - IIO_DEVICE_ATTR(accel_z_calibscale, _mode, _show, _store, _addr) - -#define IIO_DEV_ATTR_ACCEL(_show, _addr) \ - IIO_DEVICE_ATTR(accel_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_X(_show, _addr) \ - IIO_DEVICE_ATTR(accel_x_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_Y(_show, _addr) \ - IIO_DEVICE_ATTR(accel_y_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_Z(_show, _addr) \ - IIO_DEVICE_ATTR(accel_z_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xy, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_PEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_peak, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_XPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xpeak, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_YPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_ypeak, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_ZPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_zpeak, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xypeak, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_ACCEL_XYZPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xyzpeak, S_IRUGO, _show, NULL, _addr) From 657b90473b925da471e92fd207b127d3059e8d5b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:02 +0100 Subject: [PATCH 0192/1519] staging:iio:adc remove unused adc.h. Another header unused after chan_spec conversions. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/adc.h | 42 ----------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 drivers/staging/iio/adc/adc.h diff --git a/drivers/staging/iio/adc/adc.h b/drivers/staging/iio/adc/adc.h deleted file mode 100644 index 40c5949880b..00000000000 --- a/drivers/staging/iio/adc/adc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * adc.h - sysfs attributes associated with ADCs - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Copyright (c) 2008 Jonathan Cameron - * - */ - -/* Deprecated */ -#define IIO_DEV_ATTR_ADC(_num, _show, _addr) \ - IIO_DEVICE_ATTR(adc_##_num, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_IN_RAW(_num, _show, _addr) \ - IIO_DEVICE_ATTR(in##_num##_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_IN_NAMED_RAW(_num, _name, _show, _addr) \ - IIO_DEVICE_ATTR(in##_num##_##_name##_raw, S_IRUGO, _show, NULL, _addr) - -#define IIO_DEV_ATTR_IN_DIFF_RAW(_nump, _numn, _show, _addr) \ - IIO_DEVICE_ATTR_NAMED(in##_nump##min##_numn##_raw, \ - in##_nump-in##_numn##_raw, \ - S_IRUGO, \ - _show, \ - NULL, \ - _addr) - - -#define IIO_CONST_ATTR_IN_NAMED_OFFSET(_num, _name, _string) \ - IIO_CONST_ATTR(in##_num##_##_name##_offset, _string) - -#define IIO_CONST_ATTR_IN_NAMED_SCALE(_num, _name, _string) \ - IIO_CONST_ATTR(in##_num##_##_name##_scale, _string) - -#define IIO_EVENT_CODE_IN_HIGH_THRESH(a) \ - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, a, IIO_EV_TYPE_THRESH, \ - IIO_EV_DIR_RISING) -#define IIO_EVENT_CODE_IN_LOW_THRESH(a) \ - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, a, IIO_EV_TYPE_THRESH, \ - IIO_EV_DIR_FALLING) From df9c1c42c26f9a516dd44c956cff301741a0884e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:03 +0100 Subject: [PATCH 0193/1519] staging:iio: Introduce iio_core.h and move all core only stuff out of iio.h. Also get rid of a few function defs where they are only now in one core file anyway. Whilst here add mask = 0 to get rid of warning. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 63 +--------------------- drivers/staging/iio/iio_core.h | 48 +++++++++++++++++ drivers/staging/iio/industrialio-core.c | 16 +++--- drivers/staging/iio/industrialio-ring.c | 1 + drivers/staging/iio/industrialio-trigger.c | 1 + 5 files changed, 59 insertions(+), 70 deletions(-) create mode 100644 drivers/staging/iio/iio_core.h diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 07f88aa878a..61cfb26d193 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -23,9 +23,6 @@ * Currently assumes nano seconds. */ -/* Event interface flags */ -#define IIO_BUSY_BIT_POS 1 - /* naughty temporary hack to match these against the event version - need to flattern these together */ enum iio_chan_type { @@ -131,19 +128,7 @@ struct iio_chan_spec { unsigned modified:1; unsigned indexed:1; }; -/* Meant for internal use only */ -void __iio_device_attr_deinit(struct device_attribute *dev_attr); -int __iio_device_attr_init(struct device_attribute *dev_attr, - const char *postfix, - struct iio_chan_spec const *chan, - ssize_t (*readfunc)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*writefunc)(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len), - bool generic); + #define IIO_ST(si, rb, sb, sh) \ { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } @@ -166,20 +151,6 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, { .type = IIO_TIMESTAMP, .channel = -1, \ .scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) } -int __iio_add_chan_devattr(const char *postfix, - const char *group, - struct iio_chan_spec const *chan, - ssize_t (*func)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*writefunc)(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len), - int mask, - bool generic, - struct device *dev, - struct list_head *attr_list); /** * iio_get_time_ns() - utility function to get a time stamp for events etc **/ @@ -344,13 +315,6 @@ int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); -/* Used to distinguish between bipolar and unipolar scan elemenents. - * Whilst this may seem obvious, we may well want to change the representation - * in the future!*/ -#define IIO_SIGNED(a) -(a) -#define IIO_UNSIGNED(a) (a) - -extern dev_t iio_devt; extern struct bus_type iio_bus_type; /** @@ -363,15 +327,6 @@ static inline void iio_put_device(struct iio_dev *dev) put_device(&dev->dev); }; -/** - * to_iio_dev() - get iio_dev for which we have the struct device - * @d: the struct device - **/ -static inline struct iio_dev *to_iio_dev(struct device *d) -{ - return container_of(d, struct iio_dev, dev); -}; - /* Can we make this smaller? */ #define IIO_ALIGN L1_CACHE_BYTES /** @@ -397,22 +352,6 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) **/ void iio_free_device(struct iio_dev *dev); -/** - * iio_put() - internal module reference count reduce - **/ -void iio_put(void); - -/** - * iio_get() - internal module reference count increase - **/ -void iio_get(void); - -/** - * iio_device_get_chrdev_minor() - get an unused minor number - **/ -int iio_device_get_chrdev_minor(void); -void iio_device_free_chrdev_minor(int val); - /** * iio_ring_enabled() - helper function to test if any form of ring is enabled * @dev_info: IIO device info structure for device diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h new file mode 100644 index 00000000000..00e894d50e7 --- /dev/null +++ b/drivers/staging/iio/iio_core.h @@ -0,0 +1,48 @@ +/* The industrial I/O core function defs. + * + * Copyright (c) 2008 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * These definitions are meant for use only within the IIO core, not indvidual + * drivers. + */ + +/** + * iio_device_get_chrdev_minor() - get an unused minor number + **/ +int iio_device_get_chrdev_minor(void); +void iio_device_free_chrdev_minor(int val); + + +/** + * iio_put() - internal module reference count reduce + **/ +void iio_put(void); + +/** + * iio_get() - internal module reference count increase + **/ +void iio_get(void); + +extern dev_t iio_devt; + +int __iio_add_chan_devattr(const char *postfix, + const char *group, + struct iio_chan_spec const *chan, + ssize_t (*func)(struct device *dev, + struct device_attribute *attr, + char *buf), + ssize_t (*writefunc)(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len), + int mask, + bool generic, + struct device *dev, + struct list_head *attr_list); + +/* Event interface flags */ +#define IIO_BUSY_BIT_POS 1 diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 364964b1a81..cf268bc2ee1 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -23,6 +23,7 @@ #include #include "iio.h" #include "trigger_consumer.h" +#include "iio_core.h" #define IIO_ID_PREFIX "device" #define IIO_ID_FORMAT IIO_ID_PREFIX "%d" @@ -35,7 +36,6 @@ static DEFINE_IDA(iio_chrdev_ida); static DEFINE_SPINLOCK(iio_ida_lock); dev_t iio_devt; -EXPORT_SYMBOL(iio_devt); #define IIO_DEV_MAX 256 struct bus_type iio_bus_type = { @@ -90,7 +90,7 @@ static const char * const iio_chan_info_postfix[] = { }; /* Return a negative errno on failure */ -int iio_get_new_ida_val(struct ida *this_ida) +static int iio_get_new_ida_val(struct ida *this_ida) { int ret; int val; @@ -109,15 +109,13 @@ ida_again: return val; } -EXPORT_SYMBOL(iio_get_new_ida_val); -void iio_free_ida_val(struct ida *this_ida, int id) +static void iio_free_ida_val(struct ida *this_ida, int id) { spin_lock(&iio_ida_lock); ida_remove(this_ida, id); spin_unlock(&iio_ida_lock); } -EXPORT_SYMBOL(iio_free_ida_val); int iio_push_event(struct iio_dev *dev_info, int ev_line, @@ -532,6 +530,7 @@ static int __iio_build_postfix(struct iio_chan_spec const *chan, return 0; } +static int __iio_device_attr_init(struct device_attribute *dev_attr, const char *postfix, struct iio_chan_spec const *chan, @@ -604,7 +603,7 @@ error_ret: return ret; } -void __iio_device_attr_deinit(struct device_attribute *dev_attr) +static void __iio_device_attr_deinit(struct device_attribute *dev_attr) { kfree(dev_attr->attr.name); } @@ -903,7 +902,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret = 0, i, mask; + int ret = 0, i, mask = 0; char *postfix; if (!chan->event_mask) return 0; @@ -1114,8 +1113,9 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) static void iio_dev_release(struct device *device) { + struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); iio_put(); - kfree(to_iio_dev(device)); + kfree(dev_info); } static struct device_type iio_dev_type = { diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 843eb82a69b..dce50b1a4ee 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -21,6 +21,7 @@ #include #include "iio.h" +#include "iio_core.h" #include "ring_generic.h" /** diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 513a7a04099..ebacfdadee1 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -18,6 +18,7 @@ #include "iio.h" #include "trigger.h" +#include "iio_core.h" #include "trigger_consumer.h" /* RFC - Question of approach From c4b14d99bbc93c9fa03b5934a07e95594efe7a93 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:04 +0100 Subject: [PATCH 0194/1519] staging:iio:events: use IIO_ and IIO_MOD_<> instead of IIO_EV_CLASS_ etc The original definitions were duplicated to reduce tree churn during introduction of chan_spec registration. Now there is no point in maintaining the two sets of definitions. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq_core.c | 24 ++++++++++---------- drivers/staging/iio/accel/sca3000_core.c | 16 ++++++------- drivers/staging/iio/adc/ad7150.c | 8 +++---- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/adc/ad799x_core.c | 4 ++-- drivers/staging/iio/adc/adt75.c | 2 +- drivers/staging/iio/adc/max1363_core.c | 24 +++++++------------- drivers/staging/iio/dac/ad5504.c | 2 +- drivers/staging/iio/iio.h | 2 -- drivers/staging/iio/light/tsl2563.c | 2 +- drivers/staging/iio/sysfs.h | 26 ---------------------- 11 files changed, 38 insertions(+), 74 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 83ec286c477..7f946aa0140 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -452,54 +452,54 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Z, + IIO_MOD_Z, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Z, + IIO_MOD_Z, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Y, + IIO_MOD_Y, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Y, + IIO_MOD_Y, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X, + IIO_MOD_X, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X, + IIO_MOD_X, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 22c38c328da..d5684fc29cd 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -815,36 +815,36 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) if (val & SCA3000_INT_STATUS_FREE_FALL) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X_AND_Y_AND_Z, + IIO_MOD_X_AND_Y_AND_Z, IIO_EV_TYPE_MAG, IIO_EV_DIR_FALLING), last_timestamp); if (val & SCA3000_INT_STATUS_Y_TRIGGER) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Y, + IIO_MOD_Y, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), last_timestamp); if (val & SCA3000_INT_STATUS_X_TRIGGER) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X, + IIO_MOD_X, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), last_timestamp); if (val & SCA3000_INT_STATUS_Z_TRIGGER) iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Z, + IIO_MOD_Z, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), last_timestamp); diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 917fb2fa0de..5a1e15f6aec 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -654,14 +654,14 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), @@ -669,14 +669,14 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 0c84217bde3..3fa4bb34a43 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -246,7 +246,7 @@ static const struct attribute_group ad7816_attribute_group = { * temperature bound events */ -#define IIO_EVENT_CODE_AD7816_OTI IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP, \ +#define IIO_EVENT_CODE_AD7816_OTI IIO_UNMOD_EVENT_CODE(IIO_TEMP, \ 0, \ IIO_EV_TYPE_THRESH, \ IIO_EV_DIR_FALLING) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index d42d61d6063..2438ed597e9 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -335,11 +335,11 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) if (status & (1 << i)) iio_push_event(indio_dev, 0, i & 0x1 ? - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, (i >> 1), IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) : - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, + IIO_UNMOD_EVENT_CODE(IIO_IN, (i >> 1), IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index 38f141de6a4..fc31cac7eae 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -257,7 +257,7 @@ static const struct attribute_group adt75_attribute_group = { * temperature bound events */ -#define IIO_EVENT_CODE_ADT75_OTI IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP, \ +#define IIO_EVENT_CODE_ADT75_OTI IIO_UNMOD_EVENT_CODE(IIO_TEMP, \ 0, \ IIO_EV_TYPE_THRESH, \ IIO_EV_DIR_FALLING) diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 9525aec5873..6896b4cddf3 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -591,22 +591,14 @@ static int max1363_write_thresh(struct iio_dev *indio_dev, } static const int max1363_event_codes[] = { - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 0, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 1, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 2, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 3, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 0, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 1, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 2, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN, 3, - IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), }; static irqreturn_t max1363_event_handler(int irq, void *private) diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 88512dd6450..ba3d9b3154a 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -251,7 +251,7 @@ static struct attribute_group ad5504_ev_attribute_group = { static irqreturn_t ad5504_event_handler(int irq, void *private) { iio_push_event(private, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP, + IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 61cfb26d193..16abb3749f7 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -23,8 +23,6 @@ * Currently assumes nano seconds. */ -/* naughty temporary hack to match these against the event version - - need to flattern these together */ enum iio_chan_type { /* real channel types */ IIO_IN, diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index bb96857f33f..665a7441b2e 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -596,7 +596,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) struct tsl2563_chip *chip = iio_priv(dev_info); iio_push_event(dev_info, 0, - IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_LIGHT, + IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 56f4efbeb5d..bf34cfbd9c2 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -114,28 +114,6 @@ struct iio_const_attr { #define IIO_CONST_ATTR_TEMP_SCALE(_string) \ IIO_CONST_ATTR(temp_scale, _string) -/* must match our channel defs */ -#define IIO_EV_CLASS_IN IIO_IN -#define IIO_EV_CLASS_IN_DIFF IIO_IN_DIFF -#define IIO_EV_CLASS_ACCEL IIO_ACCEL -#define IIO_EV_CLASS_GYRO IIO_GYRO -#define IIO_EV_CLASS_MAGN IIO_MAGN -#define IIO_EV_CLASS_LIGHT IIO_LIGHT -#define IIO_EV_CLASS_PROXIMITY IIO_PROXIMITY -#define IIO_EV_CLASS_TEMP IIO_TEMP - -#define IIO_EV_MOD_X IIO_MOD_X -#define IIO_EV_MOD_Y IIO_MOD_Y -#define IIO_EV_MOD_Z IIO_MOD_Z -#define IIO_EV_MOD_X_AND_Y IIO_MOD_X_AND_Y -#define IIO_EV_MOD_X_ANX_Z IIO_MOD_X_AND_Z -#define IIO_EV_MOD_Y_AND_Z IIO_MOD_Y_AND_Z -#define IIO_EV_MOD_X_AND_Y_AND_Z IIO_MOD_X_AND_Y_AND_Z -#define IIO_EV_MOD_X_OR_Y IIO_MOD_X_OR_Y -#define IIO_EV_MOD_X_OR_Z IIO_MOD_X_OR_Z -#define IIO_EV_MOD_Y_OR_Z IIO_MOD_Y_OR_Z -#define IIO_EV_MOD_X_OR_Y_OR_Z IIO_MOD_X_OR_Y_OR_Z - #define IIO_EV_TYPE_THRESH 0 #define IIO_EV_TYPE_MAG 1 #define IIO_EV_TYPE_ROC 2 @@ -160,10 +138,6 @@ struct iio_const_attr { #define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction) \ IIO_EVENT_CODE(channelclass, 0, number, 0, type, direction) - -#define IIO_BUFFER_EVENT_CODE(code) \ - (IIO_EV_CLASS_BUFFER | (code << 8)) - #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 24) & 0xf) /* Event code number extraction depends on which type of event we have. From 4bfd542103dd343eca1275f99e02f40369f80163 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:05 +0100 Subject: [PATCH 0195/1519] staging:iio: remove unneeded include Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/sysfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index bf34cfbd9c2..0b75823fbe1 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -12,7 +12,7 @@ #ifndef _INDUSTRIAL_IO_SYSFS_H_ #define _INDUSTRIAL_IO_SYSFS_H_ -#include "iio.h" +struct iio_chan_spec; /** * struct iio_dev_attr - iio specific device attribute From 1c5e6a3f76a4f55d403bb6d0359b16efa4289809 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 20 Jul 2011 15:03:07 +0200 Subject: [PATCH 0196/1519] iio: core: deconstify members of struct iio_chan_spec Allow dynamic allocation and population of channel spec. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 16abb3749f7..753f769736e 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -119,9 +119,9 @@ struct iio_chan_spec { u8 storagebits; u8 shift; } scan_type; - const long info_mask; - const long event_mask; - const char *extend_name; + long info_mask; + long event_mask; + char *extend_name; unsigned processed_val:1; unsigned modified:1; unsigned indexed:1; From 2051f25d2a26573918b59d69847f5bf77635023e Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 20 Jul 2011 15:03:09 +0200 Subject: [PATCH 0197/1519] iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System The AD7280A monitoring system contains all the functions required for general purpose monitoring and maintenance of stacked lithium ion batteries as used in hybrid electric vehicles, battery backup applications, etc. Changes since V1: Make cell channels all type IIO_IN_DIFF, update documentation accordingly. Remove unused and redundant defines. Use SI units where applicable. Remove unnecessary wrapper function. Remove redundant initialization. Add comments where requested. Revise event handler. Use const where applicable. Changes since V2: Remove redundant adc.h include file, scheduled for removal. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../Documentation/sysfs-bus-iio-adc-ad7280a | 21 + drivers/staging/iio/adc/Kconfig | 10 + drivers/staging/iio/adc/Makefile | 1 + drivers/staging/iio/adc/ad7280a.c | 992 ++++++++++++++++++ drivers/staging/iio/adc/ad7280a.h | 38 + 5 files changed, 1062 insertions(+) create mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-adc-ad7280a create mode 100644 drivers/staging/iio/adc/ad7280a.c create mode 100644 drivers/staging/iio/adc/ad7280a.h diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-adc-ad7280a b/drivers/staging/iio/Documentation/sysfs-bus-iio-adc-ad7280a new file mode 100644 index 00000000000..863d3856718 --- /dev/null +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-adc-ad7280a @@ -0,0 +1,21 @@ +What: /sys/bus/iio/devices/deviceX/inY-inZ_balance_switch_en +KernelVersion: 3.0.0 +Contact: linux-iio@vger.kernel.org +Description: + Writing 1 enables the cell balance output switch corresponding + to input Y. Writing 0 disables it. If the inY-inZ_balance_timer + is set to a none zero value, the corresponding switch will + enable for the programmed amount of time, before it + automatically disables. + +What: /sys/bus/iio/devices/deviceX/inY-inZ_balance_timer +KernelVersion: 3.0.0 +Contact: linux-iio@vger.kernel.org +Description: + The inY-inZ_balance_timer file allows the user to program + individual times for each cell balance output. The AD7280A + allows the user to set the timer to a value from 0 minutes to + 36.9 minutes. The resolution of the timer is 71.5 sec. + The value written is the on-time in milliseconds. When the + timer value is set 0, the timer is disabled. The cell balance + outputs are controlled only by inY-inZ_balance_switch_en. diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index b39f2e1c1fe..60de7d72bb2 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -182,6 +182,16 @@ config ADT7410 Say yes here to build support for Analog Devices ADT7410 temperature sensors. +config AD7280 + tristate "Analog Devices AD7280A Lithium Ion Battery Monitoring System" + depends on SPI + help + Say yes here to build support for Analog Devices AD7280A + Lithium Ion Battery Monitoring System. + + To compile this driver as a module, choose M here: the + module will be called ad7280a + config MAX1363 tristate "Maxim max1363 ADC driver" depends on I2C diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index f0203513997..634a55f54a7 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -40,3 +40,4 @@ obj-$(CONFIG_AD7816) += ad7816.o obj-$(CONFIG_ADT75) += adt75.o obj-$(CONFIG_ADT7310) += adt7310.o obj-$(CONFIG_ADT7410) += adt7410.o +obj-$(CONFIG_AD7280) += ad7280a.o diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c new file mode 100644 index 00000000000..ab6cf9cb5a7 --- /dev/null +++ b/drivers/staging/iio/adc/ad7280a.c @@ -0,0 +1,992 @@ +/* + * AD7280A Lithium Ion Battery Monitoring System + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" + +#include "ad7280a.h" + +/* Registers */ +#define AD7280A_CELL_VOLTAGE_1 0x0 /* D11 to D0, Read only */ +#define AD7280A_CELL_VOLTAGE_2 0x1 /* D11 to D0, Read only */ +#define AD7280A_CELL_VOLTAGE_3 0x2 /* D11 to D0, Read only */ +#define AD7280A_CELL_VOLTAGE_4 0x3 /* D11 to D0, Read only */ +#define AD7280A_CELL_VOLTAGE_5 0x4 /* D11 to D0, Read only */ +#define AD7280A_CELL_VOLTAGE_6 0x5 /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_1 0x6 /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_2 0x7 /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_3 0x8 /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_4 0x9 /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_5 0xA /* D11 to D0, Read only */ +#define AD7280A_AUX_ADC_6 0xB /* D11 to D0, Read only */ +#define AD7280A_SELF_TEST 0xC /* D11 to D0, Read only */ +#define AD7280A_CONTROL_HB 0xD /* D15 to D8, Read/write */ +#define AD7280A_CONTROL_LB 0xE /* D7 to D0, Read/write */ +#define AD7280A_CELL_OVERVOLTAGE 0xF /* D7 to D0, Read/write */ +#define AD7280A_CELL_UNDERVOLTAGE 0x10 /* D7 to D0, Read/write */ +#define AD7280A_AUX_ADC_OVERVOLTAGE 0x11 /* D7 to D0, Read/write */ +#define AD7280A_AUX_ADC_UNDERVOLTAGE 0x12 /* D7 to D0, Read/write */ +#define AD7280A_ALERT 0x13 /* D7 to D0, Read/write */ +#define AD7280A_CELL_BALANCE 0x14 /* D7 to D0, Read/write */ +#define AD7280A_CB1_TIMER 0x15 /* D7 to D0, Read/write */ +#define AD7280A_CB2_TIMER 0x16 /* D7 to D0, Read/write */ +#define AD7280A_CB3_TIMER 0x17 /* D7 to D0, Read/write */ +#define AD7280A_CB4_TIMER 0x18 /* D7 to D0, Read/write */ +#define AD7280A_CB5_TIMER 0x19 /* D7 to D0, Read/write */ +#define AD7280A_CB6_TIMER 0x1A /* D7 to D0, Read/write */ +#define AD7280A_PD_TIMER 0x1B /* D7 to D0, Read/write */ +#define AD7280A_READ 0x1C /* D7 to D0, Read/write */ +#define AD7280A_CNVST_CONTROL 0x1D /* D7 to D0, Read/write */ + +/* Bits and Masks */ +#define AD7280A_CTRL_HB_CONV_INPUT_ALL (0 << 6) +#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4 (1 << 6) +#define AD7280A_CTRL_HB_CONV_INPUT_6CELL (2 << 6) +#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST (3 << 6) +#define AD7280A_CTRL_HB_CONV_RES_READ_ALL (0 << 4) +#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4 (1 << 4) +#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL (2 << 4) +#define AD7280A_CTRL_HB_CONV_RES_READ_NO (3 << 4) +#define AD7280A_CTRL_HB_CONV_START_CNVST (0 << 3) +#define AD7280A_CTRL_HB_CONV_START_CS (1 << 3) +#define AD7280A_CTRL_HB_CONV_AVG_DIS (0 << 1) +#define AD7280A_CTRL_HB_CONV_AVG_2 (1 << 1) +#define AD7280A_CTRL_HB_CONV_AVG_4 (2 << 1) +#define AD7280A_CTRL_HB_CONV_AVG_8 (3 << 1) +#define AD7280A_CTRL_HB_CONV_AVG(x) ((x) << 1) +#define AD7280A_CTRL_HB_PWRDN_SW (1 << 0) + +#define AD7280A_CTRL_LB_SWRST (1 << 7) +#define AD7280A_CTRL_LB_ACQ_TIME_400ns (0 << 5) +#define AD7280A_CTRL_LB_ACQ_TIME_800ns (1 << 5) +#define AD7280A_CTRL_LB_ACQ_TIME_1200ns (2 << 5) +#define AD7280A_CTRL_LB_ACQ_TIME_1600ns (3 << 5) +#define AD7280A_CTRL_LB_ACQ_TIME(x) ((x) << 5) +#define AD7280A_CTRL_LB_MUST_SET (1 << 4) +#define AD7280A_CTRL_LB_THERMISTOR_EN (1 << 3) +#define AD7280A_CTRL_LB_LOCK_DEV_ADDR (1 << 2) +#define AD7280A_CTRL_LB_INC_DEV_ADDR (1 << 1) +#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN (1 << 0) + +#define AD7280A_ALERT_GEN_STATIC_HIGH (1 << 6) +#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN (3 << 6) + +#define AD7280A_ALL_CELLS (0xAD << 16) + +#define AD7280A_MAX_SPI_CLK_Hz 700000 /* < 1MHz */ +#define AD7280A_MAX_CHAIN 8 +#define AD7280A_CELLS_PER_DEV 6 +#define AD7280A_BITS 12 +#define AD7280A_NUM_CH (AD7280A_AUX_ADC_6 - \ + AD7280A_CELL_VOLTAGE_1 + 1) + +#define AD7280A_DEVADDR_MASTER 0 +#define AD7280A_DEVADDR_ALL 0x1F +/* 5-bit device address is sent LSB first */ +#define AD7280A_DEVADDR(addr) (((addr & 0x1) << 4) | ((addr & 0x2) << 3) | \ + (addr & 0x4) | ((addr & 0x8) >> 3) | \ + ((addr & 0x10) >> 4)) + +/* During a read a valid write is mandatory. + * So writing to the highest available address (Address 0x1F) + * and setting the address all parts bit to 0 is recommended + * So the TXVAL is AD7280A_DEVADDR_ALL + CRC + */ +#define AD7280A_READ_TXVAL 0xF800030A + +/* + * AD7280 CRC + * + * P(x) = x^8 + x^5 + x^3 + x^2 + x^1 + x^0 = 0b100101111 => 0x2F + */ +#define POLYNOM 0x2F +#define POLYNOM_ORDER 8 +#define HIGHBIT 1 << (POLYNOM_ORDER - 1); + +struct ad7280_state { + struct spi_device *spi; + struct iio_chan_spec *channels; + struct iio_dev_attr *iio_attr; + int slave_num; + int scan_cnt; + int readback_delay_us; + unsigned char crc_tab[256]; + unsigned char ctrl_hb; + unsigned char ctrl_lb; + unsigned char cell_threshhigh; + unsigned char cell_threshlow; + unsigned char aux_threshhigh; + unsigned char aux_threshlow; + unsigned char cb_mask[AD7280A_MAX_CHAIN]; +}; + +static void ad7280_crc8_build_table(unsigned char *crc_tab) +{ + unsigned char bit, crc; + int cnt, i; + + for (cnt = 0; cnt < 256; cnt++) { + crc = cnt; + for (i = 0; i < 8; i++) { + bit = crc & HIGHBIT; + crc <<= 1; + if (bit) + crc ^= POLYNOM; + } + crc_tab[cnt] = crc; + } +} + +static unsigned char ad7280_calc_crc8(unsigned char *crc_tab, unsigned val) +{ + unsigned char crc; + + crc = crc_tab[val >> 16 & 0xFF]; + crc = crc_tab[crc ^ (val >> 8 & 0xFF)]; + + return crc ^ (val & 0xFF); +} + +static int ad7280_check_crc(struct ad7280_state *st, unsigned val) +{ + unsigned char crc = ad7280_calc_crc8(st->crc_tab, val >> 10); + + if (crc != ((val >> 2) & 0xFF)) + return -EIO; + + return 0; +} + +/* After initiating a conversion sequence we need to wait until the + * conversion is done. The delay is typically in the range of 15..30 us + * however depending an the number of devices in the daisy chain and the + * number of averages taken, conversion delays and acquisition time options + * it may take up to 250us, in this case we better sleep instead of busy + * wait. + */ + +static void ad7280_delay(struct ad7280_state *st) +{ + if (st->readback_delay_us < 50) + udelay(st->readback_delay_us); + else + msleep(1); +} + +static int __ad7280_read32(struct spi_device *spi, unsigned *val) +{ + unsigned rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL); + int ret; + + struct spi_transfer t = { + .tx_buf = &tx_buf, + .rx_buf = &rx_buf, + .len = 4, + }; + struct spi_message m; + + spi_message_init(&m); + spi_message_add_tail(&t, &m); + + ret = spi_sync(spi, &m); + if (ret) + return ret; + + *val = be32_to_cpu(rx_buf); + + return 0; +} + +static int ad7280_write(struct ad7280_state *st, unsigned devaddr, + unsigned addr, bool all, unsigned val) +{ + unsigned reg = (devaddr << 27 | addr << 21 | + (val & 0xFF) << 13 | all << 12); + + reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2; + reg = cpu_to_be32(reg); + + return spi_write(st->spi, ®, 4); +} + +static int ad7280_read(struct ad7280_state *st, unsigned devaddr, + unsigned addr) +{ + int ret; + unsigned tmp; + + /* turns off the read operation on all parts */ + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_NO | + st->ctrl_hb); + if (ret) + return ret; + + /* turns on the read operation on the addressed part */ + ret = ad7280_write(st, devaddr, AD7280A_CONTROL_HB, 0, + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + st->ctrl_hb); + if (ret) + return ret; + + /* Set register address on the part to be read from */ + ret = ad7280_write(st, devaddr, AD7280A_READ, 0, addr << 2); + if (ret) + return ret; + + __ad7280_read32(st->spi, &tmp); + + if (ad7280_check_crc(st, tmp)) + return -EIO; + + if (((tmp >> 27) != devaddr) || (((tmp >> 21) & 0x3F) != addr)) + return -EFAULT; + + return (tmp >> 13) & 0xFF; +} + +static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr, + unsigned addr) +{ + int ret; + unsigned tmp; + + ret = ad7280_write(st, devaddr, AD7280A_READ, 0, addr << 2); + if (ret) + return ret; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_NO | + st->ctrl_hb); + if (ret) + return ret; + + ret = ad7280_write(st, devaddr, AD7280A_CONTROL_HB, 0, + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + AD7280A_CTRL_HB_CONV_START_CS | + st->ctrl_hb); + if (ret) + return ret; + + ad7280_delay(st); + + __ad7280_read32(st->spi, &tmp); + + if (ad7280_check_crc(st, tmp)) + return -EIO; + + if (((tmp >> 27) != devaddr) || (((tmp >> 23) & 0xF) != addr)) + return -EFAULT; + + return (tmp >> 11) & 0xFFF; +} + +static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt, + unsigned *array) +{ + int i, ret; + unsigned tmp, sum = 0; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_READ, 1, + AD7280A_CELL_VOLTAGE_1 << 2); + if (ret) + return ret; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + AD7280A_CTRL_HB_CONV_START_CS | + st->ctrl_hb); + if (ret) + return ret; + + ad7280_delay(st); + + for (i = 0; i < cnt; i++) { + __ad7280_read32(st->spi, &tmp); + + if (ad7280_check_crc(st, tmp)) + return -EIO; + + if (array) + array[i] = tmp; + /* only sum cell voltages */ + if (((tmp >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) + sum += ((tmp >> 11) & 0xFFF); + } + + return sum; +} + +static int ad7280_chain_setup(struct ad7280_state *st) +{ + unsigned val, n; + int ret; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_LB, 1, + AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | + AD7280A_CTRL_LB_LOCK_DEV_ADDR | + AD7280A_CTRL_LB_MUST_SET | + AD7280A_CTRL_LB_SWRST | + st->ctrl_lb); + if (ret) + return ret; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_LB, 1, + AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | + AD7280A_CTRL_LB_LOCK_DEV_ADDR | + AD7280A_CTRL_LB_MUST_SET | + st->ctrl_lb); + if (ret) + return ret; + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_READ, 1, + AD7280A_CONTROL_LB << 2); + if (ret) + return ret; + + for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { + __ad7280_read32(st->spi, &val); + if (val == 0) + return n - 1; + + if (ad7280_check_crc(st, val)) + return -EIO; + + if (n != AD7280A_DEVADDR(val >> 27)) + return -EIO; + } + + return -EFAULT; +} + +static ssize_t ad7280_show_balance_sw(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + return sprintf(buf, "%d\n", + !!(st->cb_mask[this_attr->address >> 8] & + (1 << ((this_attr->address & 0xFF) + 2)))); +} + +static ssize_t ad7280_store_balance_sw(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + bool readin; + int ret; + unsigned devaddr, ch; + + ret = strtobool(buf, &readin); + if (ret) + return ret; + + devaddr = this_attr->address >> 8; + ch = this_attr->address & 0xFF; + + mutex_lock(&dev_info->mlock); + if (readin) + st->cb_mask[devaddr] |= 1 << (ch + 2); + else + st->cb_mask[devaddr] &= ~(1 << (ch + 2)); + + ret = ad7280_write(st, devaddr, AD7280A_CELL_BALANCE, + 0, st->cb_mask[devaddr]); + mutex_unlock(&dev_info->mlock); + + return ret ? ret : len; +} + +static ssize_t ad7280_show_balance_timer(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret; + unsigned msecs; + + mutex_lock(&dev_info->mlock); + ret = ad7280_read(st, this_attr->address >> 8, + this_attr->address & 0xFF); + mutex_unlock(&dev_info->mlock); + + if (ret < 0) + return ret; + + msecs = (ret >> 3) * 71500; + + return sprintf(buf, "%d\n", msecs); +} + +static ssize_t ad7280_store_balance_timer(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + long val; + int ret; + + ret = strict_strtoul(buf, 10, &val); + if (ret) + return ret; + + val /= 71500; + + if (val > 31) + return -EINVAL; + + mutex_lock(&dev_info->mlock); + ret = ad7280_write(st, this_attr->address >> 8, + this_attr->address & 0xFF, + 0, (val & 0x1F) << 3); + mutex_unlock(&dev_info->mlock); + + return ret ? ret : len; +} + +static struct attribute *ad7280_attributes[AD7280A_MAX_CHAIN * + AD7280A_CELLS_PER_DEV * 2 + 1]; + +static struct attribute_group ad7280_attrs_group = { + .attrs = ad7280_attributes, +}; + +static int ad7280_channel_init(struct ad7280_state *st) +{ + int dev, ch, cnt; + + st->channels = kzalloc(sizeof(*st->channels) * + ((st->slave_num + 1) * 12 + 2), GFP_KERNEL); + if (st->channels == NULL) + return -ENOMEM; + + for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) + for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++, + cnt++) { + if (ch < AD7280A_AUX_ADC_1) { + st->channels[cnt].type = IIO_IN_DIFF; + st->channels[cnt].channel = (dev * 6) + ch; + st->channels[cnt].channel2 = + st->channels[cnt].channel + 1; + } else { + st->channels[cnt].type = IIO_TEMP; + st->channels[cnt].channel = (dev * 6) + ch - 6; + } + st->channels[cnt].indexed = 1; + st->channels[cnt].info_mask = + (1 << IIO_CHAN_INFO_SCALE_SHARED); + st->channels[cnt].address = + AD7280A_DEVADDR(dev) << 8 | ch; + st->channels[cnt].scan_index = cnt; + st->channels[cnt].scan_type.sign = 'u'; + st->channels[cnt].scan_type.realbits = 12; + st->channels[cnt].scan_type.storagebits = 32; + st->channels[cnt].scan_type.shift = 0; + } + + st->channels[cnt].type = IIO_IN_DIFF; + st->channels[cnt].channel = 0; + st->channels[cnt].channel2 = dev * 6; + st->channels[cnt].address = AD7280A_ALL_CELLS; + st->channels[cnt].indexed = 1; + st->channels[cnt].info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED); + st->channels[cnt].scan_index = cnt; + st->channels[cnt].scan_type.sign = 'u'; + st->channels[cnt].scan_type.realbits = 32; + st->channels[cnt].scan_type.storagebits = 32; + st->channels[cnt].scan_type.shift = 0; + cnt++; + st->channels[cnt].type = IIO_TIMESTAMP; + st->channels[cnt].channel = -1; + st->channels[cnt].scan_index = cnt; + st->channels[cnt].scan_type.sign = 's'; + st->channels[cnt].scan_type.realbits = 64; + st->channels[cnt].scan_type.storagebits = 64; + st->channels[cnt].scan_type.shift = 0; + + return cnt + 1; +} + +static int ad7280_attr_init(struct ad7280_state *st) +{ + int dev, ch, cnt; + + st->iio_attr = kzalloc(sizeof(*st->iio_attr) * (st->slave_num + 1) * + AD7280A_CELLS_PER_DEV * 2, GFP_KERNEL); + if (st->iio_attr == NULL) + return -ENOMEM; + + for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) + for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_CELL_VOLTAGE_6; + ch++, cnt++) { + st->iio_attr[cnt].address = + AD7280A_DEVADDR(dev) << 8 | ch; + st->iio_attr[cnt].dev_attr.attr.mode = + S_IWUSR | S_IRUGO; + st->iio_attr[cnt].dev_attr.show = + ad7280_show_balance_sw; + st->iio_attr[cnt].dev_attr.store = + ad7280_store_balance_sw; + st->iio_attr[cnt].dev_attr.attr.name = + kasprintf(GFP_KERNEL, + "in%d-in%d_balance_switch_en", + (dev * AD7280A_CELLS_PER_DEV) + ch, + (dev * AD7280A_CELLS_PER_DEV) + ch + 1); + ad7280_attributes[cnt] = + &st->iio_attr[cnt].dev_attr.attr; + cnt++; + st->iio_attr[cnt].address = + AD7280A_DEVADDR(dev) << 8 | + (AD7280A_CB1_TIMER + ch); + st->iio_attr[cnt].dev_attr.attr.mode = + S_IWUSR | S_IRUGO; + st->iio_attr[cnt].dev_attr.show = + ad7280_show_balance_timer; + st->iio_attr[cnt].dev_attr.store = + ad7280_store_balance_timer; + st->iio_attr[cnt].dev_attr.attr.name = + kasprintf(GFP_KERNEL, "in%d-in%d_balance_timer", + (dev * AD7280A_CELLS_PER_DEV) + ch, + (dev * AD7280A_CELLS_PER_DEV) + ch + 1); + ad7280_attributes[cnt] = + &st->iio_attr[cnt].dev_attr.attr; + } + + ad7280_attributes[cnt] = NULL; + + return 0; +} + +static ssize_t ad7280_read_channel_config(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + unsigned val; + + switch (this_attr->address) { + case AD7280A_CELL_OVERVOLTAGE: + val = 1000 + (st->cell_threshhigh * 1568) / 100; + break; + case AD7280A_CELL_UNDERVOLTAGE: + val = 1000 + (st->cell_threshlow * 1568) / 100; + break; + case AD7280A_AUX_ADC_OVERVOLTAGE: + val = (st->aux_threshhigh * 196) / 10; + break; + case AD7280A_AUX_ADC_UNDERVOLTAGE: + val = (st->aux_threshlow * 196) / 10; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t ad7280_write_channel_config(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + long val; + int ret; + + ret = strict_strtol(buf, 10, &val); + if (ret) + return ret; + + switch (this_attr->address) { + case AD7280A_CELL_OVERVOLTAGE: + case AD7280A_CELL_UNDERVOLTAGE: + val = ((val - 1000) * 100) / 1568; /* LSB 15.68mV */ + break; + case AD7280A_AUX_ADC_OVERVOLTAGE: + case AD7280A_AUX_ADC_UNDERVOLTAGE: + val = (val * 10) / 196; /* LSB 19.6mV */ + break; + default: + return -EFAULT; + } + + val = clamp(val, 0L, 0xFFL); + + mutex_lock(&dev_info->mlock); + switch (this_attr->address) { + case AD7280A_CELL_OVERVOLTAGE: + st->cell_threshhigh = val; + break; + case AD7280A_CELL_UNDERVOLTAGE: + st->cell_threshlow = val; + break; + case AD7280A_AUX_ADC_OVERVOLTAGE: + st->aux_threshhigh = val; + break; + case AD7280A_AUX_ADC_UNDERVOLTAGE: + st->aux_threshlow = val; + break; + } + + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, + this_attr->address, 1, val); + + mutex_unlock(&dev_info->mlock); + + return ret ? ret : len; +} + +static irqreturn_t ad7280_event_handler(int irq, void *private) +{ + struct iio_dev *dev_info = private; + struct ad7280_state *st = iio_priv(dev_info); + unsigned *channels; + int i, ret; + + channels = kzalloc(sizeof(*channels) * st->scan_cnt, GFP_KERNEL); + if (channels == NULL) + return IRQ_HANDLED; + + ret = ad7280_read_all_channels(st, st->scan_cnt, channels); + if (ret < 0) + return IRQ_HANDLED; + + for (i = 0; i < st->scan_cnt; i++) { + if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) { + if (((channels[i] >> 11) & 0xFFF) >= + st->cell_threshhigh) + iio_push_event(dev_info, 0, + IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + iio_get_time_ns()); + else if (((channels[i] >> 11) & 0xFFF) <= + st->cell_threshlow) + iio_push_event(dev_info, 0, + IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), + iio_get_time_ns()); + } else { + if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) + iio_push_event(dev_info, 0, + IIO_UNMOD_EVENT_CODE(IIO_TEMP, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + iio_get_time_ns()); + else if (((channels[i] >> 11) & 0xFFF) <= + st->aux_threshlow) + iio_push_event(dev_info, 0, + IIO_UNMOD_EVENT_CODE(IIO_TEMP, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), + iio_get_time_ns()); + } + } + + kfree(channels); + + return IRQ_HANDLED; +} + +static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value, + in-in_thresh_low_value, + S_IRUGO | S_IWUSR, + ad7280_read_channel_config, + ad7280_write_channel_config, + AD7280A_CELL_UNDERVOLTAGE); + +static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value, + in-in_thresh_high_value, + S_IRUGO | S_IWUSR, + ad7280_read_channel_config, + ad7280_write_channel_config, + AD7280A_CELL_OVERVOLTAGE); + +static IIO_DEVICE_ATTR(temp_thresh_low_value, + S_IRUGO | S_IWUSR, + ad7280_read_channel_config, + ad7280_write_channel_config, + AD7280A_AUX_ADC_UNDERVOLTAGE); + +static IIO_DEVICE_ATTR(temp_thresh_high_value, + S_IRUGO | S_IWUSR, + ad7280_read_channel_config, + ad7280_write_channel_config, + AD7280A_AUX_ADC_OVERVOLTAGE); + + +static struct attribute *ad7280_event_attributes[] = { + &iio_dev_attr_in_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_thresh_high_value.dev_attr.attr, + &iio_dev_attr_temp_thresh_low_value.dev_attr.attr, + &iio_dev_attr_temp_thresh_high_value.dev_attr.attr, + NULL, +}; + +static struct attribute_group ad7280_event_attrs_group = { + .attrs = ad7280_event_attributes, +}; + +static int ad7280_read_raw(struct iio_dev *dev_info, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad7280_state *st = iio_priv(dev_info); + unsigned int scale_uv; + int ret; + + switch (m) { + case 0: + mutex_lock(&dev_info->mlock); + if (chan->address == AD7280A_ALL_CELLS) + ret = ad7280_read_all_channels(st, st->scan_cnt, NULL); + else + ret = ad7280_read_channel(st, chan->address >> 8, + chan->address & 0xFF); + mutex_unlock(&dev_info->mlock); + + if (ret < 0) + return ret; + + *val = ret; + + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6) + scale_uv = (4000 * 1000) >> AD7280A_BITS; + else + scale_uv = (5000 * 1000) >> AD7280A_BITS; + + *val = scale_uv / 1000; + *val2 = (scale_uv % 1000) * 1000; + return IIO_VAL_INT_PLUS_MICRO; + } + return -EINVAL; +} + +static const struct iio_info ad7280_info = { + .read_raw = &ad7280_read_raw, + .num_interrupt_lines = 1, + .event_attrs = &ad7280_event_attrs_group, + .attrs = &ad7280_attrs_group, + .driver_module = THIS_MODULE, +}; + +static const struct ad7280_platform_data ad7793_default_pdata = { + .acquisition_time = AD7280A_ACQ_TIME_400ns, + .conversion_averaging = AD7280A_CONV_AVG_DIS, + .thermistor_term_en = true, +}; + +static int __devinit ad7280_probe(struct spi_device *spi) +{ + const struct ad7280_platform_data *pdata = spi->dev.platform_data; + struct ad7280_state *st; + int ret, regdone = 0; + const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890}; + const unsigned short nAVG[4] = {1, 2, 4, 8}; + struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); + + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + st->spi = spi; + + if (!pdata) + pdata = &ad7793_default_pdata; + + ad7280_crc8_build_table(st->crc_tab); + + st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_Hz; + st->spi->mode = SPI_MODE_1; + spi_setup(st->spi); + + st->ctrl_lb = AD7280A_CTRL_LB_ACQ_TIME(pdata->acquisition_time & 0x3); + st->ctrl_hb = AD7280A_CTRL_HB_CONV_AVG(pdata->conversion_averaging + & 0x3) | (pdata->thermistor_term_en ? + AD7280A_CTRL_LB_THERMISTOR_EN : 0); + + ret = ad7280_chain_setup(st); + if (ret < 0) + goto error_free_device; + + st->slave_num = ret; + st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH; + st->cell_threshhigh = 0xFF; + st->aux_threshhigh = 0xFF; + + /* + * Total Conversion Time = ((tACQ + tCONV) * + * (Number of Conversions per Part)) − + * tACQ + ((N - 1) * tDELAY) + * + * Readback Delay = Total Conversion Time + tWAIT + */ + + st->readback_delay_us = + ((tACQ_ns[pdata->acquisition_time & 0x3] + 695) * + (AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3])) + - tACQ_ns[pdata->acquisition_time & 0x3] + + st->slave_num * 250; + + /* Convert to usecs */ + st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000); + st->readback_delay_us += 5; /* Add tWAIT */ + + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->dev.parent = &spi->dev; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = ad7280_channel_init(st); + if (ret < 0) + goto error_free_device; + + indio_dev->num_channels = ret; + indio_dev->channels = st->channels; + indio_dev->info = &ad7280_info; + + ret = ad7280_attr_init(st); + if (ret < 0) + goto error_free_channels; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_attr; + regdone = 1; + + if (spi->irq > 0) { + ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, + AD7280A_ALERT, 1, + AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN); + if (ret) + goto error_free_attr; + + ret = ad7280_write(st, AD7280A_DEVADDR(st->slave_num), + AD7280A_ALERT, 0, + AD7280A_ALERT_GEN_STATIC_HIGH | + (pdata->chain_last_alert_ignore & 0xF)); + if (ret) + goto error_free_attr; + + ret = request_threaded_irq(spi->irq, + NULL, + ad7280_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + indio_dev->name, + indio_dev); + if (ret) + goto error_free_attr; + } + + return 0; + +error_free_attr: + kfree(st->iio_attr); + +error_free_channels: + kfree(st->channels); + +error_free_device: + if (regdone) + iio_device_unregister(indio_dev); + else + iio_free_device(indio_dev); + + return ret; +} + +static int __devexit ad7280_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad7280_state *st = iio_priv(indio_dev); + + if (spi->irq > 0) + free_irq(spi->irq, indio_dev); + + ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); + + kfree(st->channels); + kfree(st->iio_attr); + iio_device_unregister(indio_dev); + + return 0; +} + +static const struct spi_device_id ad7280_id[] = { + {"ad7280a", 0}, + {} +}; + +static struct spi_driver ad7280_driver = { + .driver = { + .name = "ad7280", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = ad7280_probe, + .remove = __devexit_p(ad7280_remove), + .id_table = ad7280_id, +}; + +static int __init ad7280_init(void) +{ + return spi_register_driver(&ad7280_driver); +} +module_init(ad7280_init); + +static void __exit ad7280_exit(void) +{ + spi_unregister_driver(&ad7280_driver); +} +module_exit(ad7280_exit); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD7280A"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/adc/ad7280a.h b/drivers/staging/iio/adc/ad7280a.h new file mode 100644 index 00000000000..20400b0045e --- /dev/null +++ b/drivers/staging/iio/adc/ad7280a.h @@ -0,0 +1,38 @@ +/* + * AD7280A Lithium Ion Battery Monitoring System + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#ifndef IIO_ADC_AD7280_H_ +#define IIO_ADC_AD7280_H_ + +/* + * TODO: struct ad7280_platform_data needs to go into include/linux/iio + */ + +#define AD7280A_ACQ_TIME_400ns 0 +#define AD7280A_ACQ_TIME_800ns 1 +#define AD7280A_ACQ_TIME_1200ns 2 +#define AD7280A_ACQ_TIME_1600ns 3 + +#define AD7280A_CONV_AVG_DIS 0 +#define AD7280A_CONV_AVG_2 1 +#define AD7280A_CONV_AVG_4 2 +#define AD7280A_CONV_AVG_8 3 + +#define AD7280A_ALERT_REMOVE_VIN5 (1 << 2) +#define AD7280A_ALERT_REMOVE_VIN4_VIN5 (2 << 2) +#define AD7280A_ALERT_REMOVE_AUX5 (1 << 0) +#define AD7280A_ALERT_REMOVE_AUX4_AUX5 (2 << 0) + +struct ad7280_platform_data { + unsigned acquisition_time; + unsigned conversion_averaging; + unsigned chain_last_alert_ignore; + bool thermistor_term_en; +}; + +#endif /* IIO_ADC_AD7280_H_ */ From f94aa354d676532448e8e222e737fdd0755fc786 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Tue, 2 Aug 2011 08:48:22 +0200 Subject: [PATCH 0198/1519] iio: impedance-analyzer: New driver for AD5933/4 Impedance Converter, Network Analyzer The AD5933 is a high precision impedance converter system solution that combines an on-board frequency generator with a 12-bit, 1 MSPS, analog-to-digital converter (ADC). The frequency generator allows an external complex impedance to be excited with a known frequency. The response signal from the impedance is sampled by the on-board ADC and a discrete Fourier transform (DFT) is processed by an on-chip DSP engine. The DFT algorithm returns a real (R) and imaginary (I) data-word at each output frequency. Changes since V1: Apply list review feedback: Consistently use poll_time_jiffies. Use be|le cpu endian helpers where applicable. Add various comments. Changes since V2: Fix KernelVersion tag in Documentation. Declare ad5933_default_pdata static. Fix typos. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../sysfs-bus-iio-impedance-analyzer-ad5933 | 30 + drivers/staging/iio/Kconfig | 1 + drivers/staging/iio/Makefile | 1 + .../staging/iio/impedance-analyzer/Kconfig | 16 + .../staging/iio/impedance-analyzer/Makefile | 5 + .../staging/iio/impedance-analyzer/ad5933.c | 818 ++++++++++++++++++ .../staging/iio/impedance-analyzer/ad5933.h | 28 + 7 files changed, 899 insertions(+) create mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-impedance-analyzer-ad5933 create mode 100644 drivers/staging/iio/impedance-analyzer/Kconfig create mode 100644 drivers/staging/iio/impedance-analyzer/Makefile create mode 100644 drivers/staging/iio/impedance-analyzer/ad5933.c create mode 100644 drivers/staging/iio/impedance-analyzer/ad5933.h diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-impedance-analyzer-ad5933 b/drivers/staging/iio/Documentation/sysfs-bus-iio-impedance-analyzer-ad5933 new file mode 100644 index 00000000000..79c7e88c64c --- /dev/null +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-impedance-analyzer-ad5933 @@ -0,0 +1,30 @@ +What: /sys/bus/iio/devices/iio:deviceX/outY_freq_start +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + Frequency sweep start frequency in Hz. + +What: /sys/bus/iio/devices/iio:deviceX/outY_freq_increment +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + Frequency increment in Hz (step size) between consecutive + frequency points along the sweep. + +What: /sys/bus/iio/devices/iio:deviceX/outY_freq_points +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + Number of frequency points (steps) in the frequency sweep. + This value, in conjunction with the outY_freq_start and the + outY_freq_increment, determines the frequency sweep range + for the sweep operation. + +What: /sys/bus/iio/devices/iio:deviceX/outY_settling_cycles +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + Number of output excitation cycles (settling time cycles) + that are allowed to pass through the unknown impedance, + after each frequency increment, and before the ADC is triggered + to perform a conversion sequence of the response signal. diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index d329635fb5c..75265678348 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -62,6 +62,7 @@ source "drivers/staging/iio/addac/Kconfig" source "drivers/staging/iio/dac/Kconfig" source "drivers/staging/iio/dds/Kconfig" source "drivers/staging/iio/gyro/Kconfig" +source "drivers/staging/iio/impedance-analyzer/Kconfig" source "drivers/staging/iio/imu/Kconfig" source "drivers/staging/iio/light/Kconfig" source "drivers/staging/iio/magnetometer/Kconfig" diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index bb5c95c7d69..eaff649faf9 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -16,6 +16,7 @@ obj-y += addac/ obj-y += dac/ obj-y += dds/ obj-y += gyro/ +obj-y += impedance-analyzer/ obj-y += imu/ obj-y += light/ obj-y += magnetometer/ diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig new file mode 100644 index 00000000000..9e91a9bc8bf --- /dev/null +++ b/drivers/staging/iio/impedance-analyzer/Kconfig @@ -0,0 +1,16 @@ +# +# Impedance Converter, Network Analyzer drivers +# +comment "Network Analyzer, Impedance Converters" + +config AD5933 + tristate "Analog Devices AD5933, AD5934 driver" + depends on I2C + select IIO_RING_BUFFER + select IIO_SW_RING + help + Say yes here to build support for Analog Devices Impedance Converter, + Network Analyzer, AD5933/4, provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad5933. diff --git a/drivers/staging/iio/impedance-analyzer/Makefile b/drivers/staging/iio/impedance-analyzer/Makefile new file mode 100644 index 00000000000..7604d786583 --- /dev/null +++ b/drivers/staging/iio/impedance-analyzer/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Impedance Converter, Network Analyzer drivers +# + +obj-$(CONFIG_AD5933) += ad5933.o diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c new file mode 100644 index 00000000000..acc0e69cb58 --- /dev/null +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -0,0 +1,818 @@ +/* + * AD5933 AD5934 Impedance Converter, Network Analyzer + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" +#include "../ring_generic.h" +#include "../ring_sw.h" + +#include "ad5933.h" + +/* AD5933/AD5934 Registers */ +#define AD5933_REG_CONTROL_HB 0x80 /* R/W, 2 bytes */ +#define AD5933_REG_CONTROL_LB 0x81 /* R/W, 2 bytes */ +#define AD5933_REG_FREQ_START 0x82 /* R/W, 3 bytes */ +#define AD5933_REG_FREQ_INC 0x85 /* R/W, 3 bytes */ +#define AD5933_REG_INC_NUM 0x88 /* R/W, 2 bytes, 9 bit */ +#define AD5933_REG_SETTLING_CYCLES 0x8A /* R/W, 2 bytes */ +#define AD5933_REG_STATUS 0x8F /* R, 1 byte */ +#define AD5933_REG_TEMP_DATA 0x92 /* R, 2 bytes*/ +#define AD5933_REG_REAL_DATA 0x94 /* R, 2 bytes*/ +#define AD5933_REG_IMAG_DATA 0x96 /* R, 2 bytes*/ + +/* AD5933_REG_CONTROL_HB Bits */ +#define AD5933_CTRL_INIT_START_FREQ (0x1 << 4) +#define AD5933_CTRL_START_SWEEP (0x2 << 4) +#define AD5933_CTRL_INC_FREQ (0x3 << 4) +#define AD5933_CTRL_REPEAT_FREQ (0x4 << 4) +#define AD5933_CTRL_MEASURE_TEMP (0x9 << 4) +#define AD5933_CTRL_POWER_DOWN (0xA << 4) +#define AD5933_CTRL_STANDBY (0xB << 4) + +#define AD5933_CTRL_RANGE_2000mVpp (0x0 << 1) +#define AD5933_CTRL_RANGE_200mVpp (0x1 << 1) +#define AD5933_CTRL_RANGE_400mVpp (0x2 << 1) +#define AD5933_CTRL_RANGE_1000mVpp (0x3 << 1) +#define AD5933_CTRL_RANGE(x) ((x) << 1) + +#define AD5933_CTRL_PGA_GAIN_1 (0x1 << 0) +#define AD5933_CTRL_PGA_GAIN_5 (0x0 << 0) + +/* AD5933_REG_CONTROL_LB Bits */ +#define AD5933_CTRL_RESET (0x1 << 4) +#define AD5933_CTRL_INT_SYSCLK (0x0 << 3) +#define AD5933_CTRL_EXT_SYSCLK (0x1 << 3) + +/* AD5933_REG_STATUS Bits */ +#define AD5933_STAT_TEMP_VALID (0x1 << 0) +#define AD5933_STAT_DATA_VALID (0x1 << 1) +#define AD5933_STAT_SWEEP_DONE (0x1 << 2) + +/* I2C Block Commands */ +#define AD5933_I2C_BLOCK_WRITE 0xA0 +#define AD5933_I2C_BLOCK_READ 0xA1 +#define AD5933_I2C_ADDR_POINTER 0xB0 + +/* Device Specs */ +#define AD5933_INT_OSC_FREQ_Hz 16776000 +#define AD5933_MAX_OUTPUT_FREQ_Hz 100000 +#define AD5933_MAX_RETRIES 100 + +#define AD5933_OUT_RANGE 1 +#define AD5933_OUT_RANGE_AVAIL 2 +#define AD5933_OUT_SETTLING_CYCLES 3 +#define AD5933_IN_PGA_GAIN 4 +#define AD5933_IN_PGA_GAIN_AVAIL 5 +#define AD5933_FREQ_POINTS 6 + +#define AD5933_POLL_TIME_ms 10 +#define AD5933_INIT_EXCITATION_TIME_ms 100 + +struct ad5933_state { + struct i2c_client *client; + struct regulator *reg; + struct ad5933_platform_data *pdata; + struct delayed_work work; + unsigned long mclk_hz; + unsigned char ctrl_hb; + unsigned char ctrl_lb; + unsigned range_avail[4]; + unsigned short vref_mv; + unsigned short settling_cycles; + unsigned short freq_points; + unsigned freq_start; + unsigned freq_inc; + unsigned state; + unsigned poll_time_jiffies; +}; + +static struct ad5933_platform_data ad5933_default_pdata = { + .vref_mv = 3300, +}; + +static struct iio_chan_spec ad5933_channels[] = { + IIO_CHAN(IIO_TEMP, 0, 1, 1, NULL, 0, 0, 0, + 0, AD5933_REG_TEMP_DATA, IIO_ST('s', 14, 16, 0), 0), + /* Ring Channels */ + IIO_CHAN(IIO_IN, 0, 1, 0, "real_raw", 0, 0, + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + AD5933_REG_REAL_DATA, 0, IIO_ST('s', 16, 16, 0), 0), + IIO_CHAN(IIO_IN, 0, 1, 0, "imag_raw", 0, 0, + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + AD5933_REG_IMAG_DATA, 1, IIO_ST('s', 16, 16, 0), 0), +}; + +static int ad5933_i2c_write(struct i2c_client *client, + u8 reg, u8 len, u8 *data) +{ + int ret; + + while (len--) { + ret = i2c_smbus_write_byte_data(client, reg++, *data++); + if (ret < 0) { + dev_err(&client->dev, "I2C write error\n"); + return ret; + } + } + return 0; +} + +static int ad5933_i2c_read(struct i2c_client *client, + u8 reg, u8 len, u8 *data) +{ + int ret; + + while (len--) { + ret = i2c_smbus_read_byte_data(client, reg++); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + *data++ = ret; + } + return 0; +} + +static int ad5933_cmd(struct ad5933_state *st, unsigned char cmd) +{ + unsigned char dat = st->ctrl_hb | cmd; + + return ad5933_i2c_write(st->client, + AD5933_REG_CONTROL_HB, 1, &dat); +} + +static int ad5933_reset(struct ad5933_state *st) +{ + unsigned char dat = st->ctrl_lb | AD5933_CTRL_RESET; + return ad5933_i2c_write(st->client, + AD5933_REG_CONTROL_LB, 1, &dat); +} + +static int ad5933_wait_busy(struct ad5933_state *st, unsigned char event) +{ + unsigned char val, timeout = AD5933_MAX_RETRIES; + int ret; + + while (timeout--) { + ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &val); + if (ret < 0) + return ret; + if (val & event) + return val; + cpu_relax(); + mdelay(1); + } + + return -EAGAIN; +} + +static int ad5933_set_freq(struct ad5933_state *st, + unsigned reg, unsigned long freq) +{ + unsigned long long freqreg; + union { + u32 d32; + u8 d8[4]; + } dat; + + freqreg = (u64) freq * (u64) (1 << 27); + do_div(freqreg, st->mclk_hz / 4); + + switch (reg) { + case AD5933_REG_FREQ_START: + st->freq_start = freq; + break; + case AD5933_REG_FREQ_INC: + st->freq_inc = freq; + break; + default: + return -EINVAL; + } + + dat.d32 = cpu_to_be32(freqreg); + return ad5933_i2c_write(st->client, reg, 3, &dat.d8[1]); +} + +static int ad5933_setup(struct ad5933_state *st) +{ + unsigned short dat; + int ret; + + ret = ad5933_reset(st); + if (ret < 0) + return ret; + + ret = ad5933_set_freq(st, AD5933_REG_FREQ_START, 10000); + if (ret < 0) + return ret; + + ret = ad5933_set_freq(st, AD5933_REG_FREQ_INC, 200); + if (ret < 0) + return ret; + + st->settling_cycles = 10; + dat = cpu_to_be16(st->settling_cycles); + + ret = ad5933_i2c_write(st->client, + AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat); + if (ret < 0) + return ret; + + st->freq_points = 100; + dat = cpu_to_be16(st->freq_points); + + return ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, (u8 *)&dat); +} + +static void ad5933_calc_out_ranges(struct ad5933_state *st) +{ + int i; + unsigned normalized_3v3[4] = {1980, 198, 383, 970}; + + for (i = 0; i < 4; i++) + st->range_avail[i] = normalized_3v3[i] * st->vref_mv / 3300; + +} + +/* + * handles: AD5933_REG_FREQ_START and AD5933_REG_FREQ_INC + */ + +static ssize_t ad5933_show_frequency(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret; + unsigned long long freqreg; + union { + u32 d32; + u8 d8[4]; + } dat; + + mutex_lock(&dev_info->mlock); + ret = ad5933_i2c_read(st->client, this_attr->address, 3, &dat.d8[1]); + mutex_unlock(&dev_info->mlock); + if (ret < 0) + return ret; + + freqreg = be32_to_cpu(dat.d32) & 0xFFFFFF; + + freqreg = (u64) freqreg * (u64) (st->mclk_hz / 4); + do_div(freqreg, 1 << 27); + + return sprintf(buf, "%d\n", (int) freqreg); +} + +static ssize_t ad5933_store_frequency(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + long val; + int ret; + + ret = strict_strtoul(buf, 10, &val); + if (ret) + return ret; + + if (val > AD5933_MAX_OUTPUT_FREQ_Hz) + return -EINVAL; + + mutex_lock(&dev_info->mlock); + ret = ad5933_set_freq(st, this_attr->address, val); + mutex_unlock(&dev_info->mlock); + + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(out0_freq_start, S_IRUGO | S_IWUSR, + ad5933_show_frequency, + ad5933_store_frequency, + AD5933_REG_FREQ_START); + +static IIO_DEVICE_ATTR(out0_freq_increment, S_IRUGO | S_IWUSR, + ad5933_show_frequency, + ad5933_store_frequency, + AD5933_REG_FREQ_INC); + +static ssize_t ad5933_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret = 0, len = 0; + + mutex_lock(&dev_info->mlock); + switch (this_attr->address) { + case AD5933_OUT_RANGE: + len = sprintf(buf, "%d\n", + st->range_avail[(st->ctrl_hb >> 1) & 0x3]); + break; + case AD5933_OUT_RANGE_AVAIL: + len = sprintf(buf, "%d %d %d %d\n", st->range_avail[0], + st->range_avail[3], st->range_avail[2], + st->range_avail[1]); + break; + case AD5933_OUT_SETTLING_CYCLES: + len = sprintf(buf, "%d\n", st->settling_cycles); + break; + case AD5933_IN_PGA_GAIN: + len = sprintf(buf, "%s\n", + (st->ctrl_hb & AD5933_CTRL_PGA_GAIN_1) ? + "1" : "0.2"); + break; + case AD5933_IN_PGA_GAIN_AVAIL: + len = sprintf(buf, "1 0.2\n"); + break; + case AD5933_FREQ_POINTS: + len = sprintf(buf, "%d\n", st->freq_points); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&dev_info->mlock); + return ret ? ret : len; +} + +static ssize_t ad5933_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + long val; + int i, ret = 0; + unsigned short dat; + + if (this_attr->address != AD5933_IN_PGA_GAIN) { + ret = strict_strtol(buf, 10, &val); + if (ret) + return ret; + } + + mutex_lock(&dev_info->mlock); + switch (this_attr->address) { + case AD5933_OUT_RANGE: + for (i = 0; i < 4; i++) + if (val == st->range_avail[i]) { + st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); + st->ctrl_hb |= AD5933_CTRL_RANGE(i); + ret = ad5933_cmd(st, 0); + break; + } + ret = -EINVAL; + break; + case AD5933_IN_PGA_GAIN: + if (sysfs_streq(buf, "1")) { + st->ctrl_hb |= AD5933_CTRL_PGA_GAIN_1; + } else if (sysfs_streq(buf, "0.2")) { + st->ctrl_hb &= ~AD5933_CTRL_PGA_GAIN_1; + } else { + ret = -EINVAL; + break; + } + ret = ad5933_cmd(st, 0); + break; + case AD5933_OUT_SETTLING_CYCLES: + val = clamp(val, 0L, 0x7FFL); + st->settling_cycles = val; + + /* 2x, 4x handling, see datasheet */ + if (val > 511) + val = (val >> 1) | (1 << 9); + else if (val > 1022) + val = (val >> 2) | (3 << 9); + + dat = cpu_to_be16(val); + ret = ad5933_i2c_write(st->client, + AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat); + break; + case AD5933_FREQ_POINTS: + val = clamp(val, 0L, 511L); + st->freq_points = val; + + dat = cpu_to_be16(val); + ret = ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, + (u8 *)&dat); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&dev_info->mlock); + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(out0_scale, S_IRUGO | S_IWUSR, + ad5933_show, + ad5933_store, + AD5933_OUT_RANGE); + +static IIO_DEVICE_ATTR(out0_scale_available, S_IRUGO, + ad5933_show, + NULL, + AD5933_OUT_RANGE_AVAIL); + +static IIO_DEVICE_ATTR(in0_scale, S_IRUGO | S_IWUSR, + ad5933_show, + ad5933_store, + AD5933_IN_PGA_GAIN); + +static IIO_DEVICE_ATTR(in0_scale_available, S_IRUGO, + ad5933_show, + NULL, + AD5933_IN_PGA_GAIN_AVAIL); + +static IIO_DEVICE_ATTR(out0_freq_points, S_IRUGO | S_IWUSR, + ad5933_show, + ad5933_store, + AD5933_FREQ_POINTS); + +static IIO_DEVICE_ATTR(out0_settling_cycles, S_IRUGO | S_IWUSR, + ad5933_show, + ad5933_store, + AD5933_OUT_SETTLING_CYCLES); + +/* note: + * ideally we would handle the scale attributes via the iio_info + * (read|write)_raw methods, however this part is a untypical since we + * don't create dedicated sysfs channel attributes for out0 and in0. + */ +static struct attribute *ad5933_attributes[] = { + &iio_dev_attr_out0_scale.dev_attr.attr, + &iio_dev_attr_out0_scale_available.dev_attr.attr, + &iio_dev_attr_out0_freq_start.dev_attr.attr, + &iio_dev_attr_out0_freq_increment.dev_attr.attr, + &iio_dev_attr_out0_freq_points.dev_attr.attr, + &iio_dev_attr_out0_settling_cycles.dev_attr.attr, + &iio_dev_attr_in0_scale.dev_attr.attr, + &iio_dev_attr_in0_scale_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group ad5933_attribute_group = { + .attrs = ad5933_attributes, +}; + +static int ad5933_read_raw(struct iio_dev *dev_info, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad5933_state *st = iio_priv(dev_info); + unsigned short dat; + int ret = -EINVAL; + + mutex_lock(&dev_info->mlock); + switch (m) { + case 0: + if (iio_ring_enabled(dev_info)) { + ret = -EBUSY; + goto out; + } + ret = ad5933_cmd(st, AD5933_CTRL_MEASURE_TEMP); + if (ret < 0) + goto out; + ret = ad5933_wait_busy(st, AD5933_STAT_TEMP_VALID); + if (ret < 0) + goto out; + + ret = ad5933_i2c_read(st->client, + AD5933_REG_TEMP_DATA, 2, + (u8 *)&dat); + if (ret < 0) + goto out; + mutex_unlock(&dev_info->mlock); + ret = be16_to_cpu(dat); + /* Temp in Milli degrees Celsius */ + if (ret < 8192) + *val = ret * 1000 / 32; + else + *val = (ret - 16384) * 1000 / 32; + + return IIO_VAL_INT; + } + +out: + mutex_unlock(&dev_info->mlock); + return ret; +} + +static const struct iio_info ad5933_info = { + .read_raw = &ad5933_read_raw, + .attrs = &ad5933_attribute_group, + .driver_module = THIS_MODULE, +}; + +static int ad5933_ring_preenable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + struct iio_ring_buffer *ring = indio_dev->ring; + size_t d_size; + int ret; + + if (!ring->scan_count) + return -EINVAL; + + d_size = ring->scan_count * + ad5933_channels[1].scan_type.storagebits / 8; + + if (indio_dev->ring->access->set_bytes_per_datum) + indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, + d_size); + + ret = ad5933_reset(st); + if (ret < 0) + return ret; + + ret = ad5933_cmd(st, AD5933_CTRL_STANDBY); + if (ret < 0) + return ret; + + ret = ad5933_cmd(st, AD5933_CTRL_INIT_START_FREQ); + if (ret < 0) + return ret; + + st->state = AD5933_CTRL_INIT_START_FREQ; + + return 0; +} + +static int ad5933_ring_postenable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + + /* AD5933_CTRL_INIT_START_FREQ: + * High Q complex circuits require a long time to reach steady state. + * To facilitate the measurement of such impedances, this mode allows + * the user full control of the settling time requirement before + * entering start frequency sweep mode where the impedance measurement + * takes place. In this mode the impedance is excited with the + * programmed start frequency (ad5933_ring_preenable), + * but no measurement takes place. + */ + + schedule_delayed_work(&st->work, + msecs_to_jiffies(AD5933_INIT_EXCITATION_TIME_ms)); + return 0; +} + +static int ad5933_ring_postdisable(struct iio_dev *indio_dev) +{ + struct ad5933_state *st = iio_priv(indio_dev); + + cancel_delayed_work_sync(&st->work); + return ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); +} + +static const struct iio_ring_setup_ops ad5933_ring_setup_ops = { + .preenable = &ad5933_ring_preenable, + .postenable = &ad5933_ring_postenable, + .postdisable = &ad5933_ring_postdisable, +}; + +static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) +{ + indio_dev->ring = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->ring) + return -ENOMEM; + + /* Effectively select the ring buffer implementation */ + indio_dev->ring->access = &ring_sw_access_funcs; + + /* Ring buffer functions - here trigger setup related */ + indio_dev->ring->setup_ops = &ad5933_ring_setup_ops; + + indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; + + return 0; +} + +static void ad5933_work(struct work_struct *work) +{ + struct ad5933_state *st = container_of(work, + struct ad5933_state, work.work); + struct iio_dev *indio_dev = i2c_get_clientdata(st->client); + struct iio_ring_buffer *ring = indio_dev->ring; + signed short buf[2]; + unsigned char status; + + mutex_lock(&indio_dev->mlock); + if (st->state == AD5933_CTRL_INIT_START_FREQ) { + /* start sweep */ + ad5933_cmd(st, AD5933_CTRL_START_SWEEP); + st->state = AD5933_CTRL_START_SWEEP; + schedule_delayed_work(&st->work, st->poll_time_jiffies); + mutex_unlock(&indio_dev->mlock); + return; + } + + ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); + + if (status & AD5933_STAT_DATA_VALID) { + ad5933_i2c_read(st->client, + (ring->scan_mask & (1 << 0)) ? + AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA, + ring->scan_count * 2, (u8 *)buf); + + if (ring->scan_count == 2) { + buf[0] = be16_to_cpu(buf[0]); + buf[1] = be16_to_cpu(buf[1]); + } else { + buf[0] = be16_to_cpu(buf[0]); + } + /* save datum to the ring */ + ring->access->store_to(ring, (u8 *)buf, iio_get_time_ns()); + } else { + /* no data available - try again later */ + schedule_delayed_work(&st->work, st->poll_time_jiffies); + mutex_unlock(&indio_dev->mlock); + return; + } + + if (status & AD5933_STAT_SWEEP_DONE) { + /* last sample received - power down do nothing until + * the ring enable is toggled */ + ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); + } else { + /* we just received a valid datum, move on to the next */ + ad5933_cmd(st, AD5933_CTRL_INC_FREQ); + schedule_delayed_work(&st->work, st->poll_time_jiffies); + } + + mutex_unlock(&indio_dev->mlock); +} + +static int __devinit ad5933_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret, regdone = 0, voltage_uv = 0; + struct ad5933_platform_data *pdata = client->dev.platform_data; + struct ad5933_state *st; + struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + st->client = client; + + if (!pdata) + st->pdata = &ad5933_default_pdata; + else + st->pdata = pdata; + + st->reg = regulator_get(&client->dev, "vcc"); + if (!IS_ERR(st->reg)) { + ret = regulator_enable(st->reg); + if (ret) + goto error_put_reg; + voltage_uv = regulator_get_voltage(st->reg); + } + + if (voltage_uv) + st->vref_mv = voltage_uv / 1000; + else + st->vref_mv = st->pdata->vref_mv; + + if (st->pdata->ext_clk_Hz) { + st->mclk_hz = st->pdata->ext_clk_Hz; + st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK; + } else { + st->mclk_hz = AD5933_INT_OSC_FREQ_Hz; + st->ctrl_lb = AD5933_CTRL_INT_SYSCLK; + } + + ad5933_calc_out_ranges(st); + INIT_DELAYED_WORK(&st->work, ad5933_work); + st->poll_time_jiffies = msecs_to_jiffies(AD5933_POLL_TIME_ms); + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &ad5933_info; + indio_dev->name = id->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ad5933_channels; + indio_dev->num_channels = 1; /* only register temp0_input */ + + ret = ad5933_register_ring_funcs_and_init(indio_dev); + if (ret) + goto error_disable_reg; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_ring; + regdone = 1; + + /* skip temp0_input, register in0_(real|imag)_raw */ + ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + &ad5933_channels[1], + 2); + if (ret) + goto error_unreg_ring; + + /* enable both REAL and IMAG channels by default */ + iio_scan_mask_set(indio_dev->ring, 0); + iio_scan_mask_set(indio_dev->ring, 1); + + ret = ad5933_setup(st); + if (ret) + goto error_uninitialize_ring; + + return 0; + +error_uninitialize_ring: + iio_ring_buffer_unregister(indio_dev->ring); +error_unreg_ring: + iio_sw_rb_free(indio_dev->ring); +error_disable_reg: + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); +error_put_reg: + if (!IS_ERR(st->reg)) + regulator_put(st->reg); + + if (regdone) + iio_device_unregister(indio_dev); + else + iio_free_device(indio_dev); + + return ret; +} + +static __devexit int ad5933_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad5933_state *st = iio_priv(indio_dev); + + iio_ring_buffer_unregister(indio_dev->ring); + iio_sw_rb_free(indio_dev->ring); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); + } + iio_device_unregister(indio_dev); + + return 0; +} + +static const struct i2c_device_id ad5933_id[] = { + { "ad5933", 0 }, + { "ad5934", 0 }, + {} +}; + +MODULE_DEVICE_TABLE(i2c, ad5933_id); + +static struct i2c_driver ad5933_driver = { + .driver = { + .name = "ad5933", + }, + .probe = ad5933_probe, + .remove = __devexit_p(ad5933_remove), + .id_table = ad5933_id, +}; + +static __init int ad5933_init(void) +{ + return i2c_add_driver(&ad5933_driver); +} +module_init(ad5933_init); + +static __exit void ad5933_exit(void) +{ + i2c_del_driver(&ad5933_driver); +} +module_exit(ad5933_exit); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD5933 Impedance Conv. Network Analyzer"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.h b/drivers/staging/iio/impedance-analyzer/ad5933.h new file mode 100644 index 00000000000..b140e42d67c --- /dev/null +++ b/drivers/staging/iio/impedance-analyzer/ad5933.h @@ -0,0 +1,28 @@ +/* + * AD5933 AD5934 Impedance Converter, Network Analyzer + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#ifndef IIO_ADC_AD5933_H_ +#define IIO_ADC_AD5933_H_ + +/* + * TODO: struct ad5933_platform_data needs to go into include/linux/iio + */ + +/** + * struct ad5933_platform_data - platform specific data + * @ext_clk_Hz: the external clock frequency in Hz, if not set + * the driver uses the internal clock (16.776 MHz) + * @vref_mv: the external reference voltage in millivolt + */ + +struct ad5933_platform_data { + unsigned long ext_clk_Hz; + unsigned short vref_mv; +}; + +#endif /* IIO_ADC_AD5933_H_ */ From 176f9f29cec95f88cfa01a8e40741d1fc532add2 Mon Sep 17 00:00:00 2001 From: Grant Grundler Date: Tue, 9 Aug 2011 15:18:14 -0700 Subject: [PATCH 0199/1519] STAGING:iio:light: fix ISL29018 init to handle brownout After a voltage brownout, sensor will now operate correctly. Page 10 of ISL29018 data sheet and the Intersil Application Note 1534 describe the required initialization sequence: 1. Write 0x00 to register 0x08 (TEST) 2. Write 0x00 to register 0x00 (CMD1) 3. msleep(1) 4. program remaining registers as before Signed-off-by: Grant Grundler Reviewed-by: Bryan Freed Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/isl29018.c | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 426b6af7080..da5bb33a66c 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -53,6 +53,10 @@ #define ISL29018_REG_ADD_DATA_MSB 0x03 #define ISL29018_MAX_REGS ISL29018_REG_ADD_DATA_MSB +#define ISL29018_REG_TEST 0x08 +#define ISL29018_TEST_SHIFT 0 +#define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT) + struct isl29018_chip { struct i2c_client *client; struct mutex lock; @@ -457,6 +461,48 @@ static int isl29018_chip_init(struct i2c_client *client) memset(chip->reg_cache, 0, sizeof(chip->reg_cache)); + /* Code added per Intersil Application Note 1534: + * When VDD sinks to approximately 1.8V or below, some of + * the part's registers may change their state. When VDD + * recovers to 2.25V (or greater), the part may thus be in an + * unknown mode of operation. The user can return the part to + * a known mode of operation either by (a) setting VDD = 0V for + * 1 second or more and then powering back up with a slew rate + * of 0.5V/ms or greater, or (b) via I2C disable all ALS/PROX + * conversions, clear the test registers, and then rewrite all + * registers to the desired values. + * ... + * FOR ISL29011, ISL29018, ISL29021, ISL29023 + * 1. Write 0x00 to register 0x08 (TEST) + * 2. Write 0x00 to register 0x00 (CMD1) + * 3. Rewrite all registers to the desired values + * + * ISL29018 Data Sheet (FN6619.1, Feb 11, 2010) essentially says + * the same thing EXCEPT the data sheet asks for a 1ms delay after + * writing the CMD1 register. + */ + status = isl29018_write_data(client, ISL29018_REG_TEST, 0, + ISL29018_TEST_MASK, ISL29018_TEST_SHIFT); + if (status < 0) { + dev_err(&client->dev, "Failed to clear isl29018 TEST reg." + "(%d)\n", status); + return status; + } + + /* See Intersil AN1534 comments above. + * "Operating Mode" (COMMAND1) register is reprogrammed when + * data is read from the device. + */ + status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1, 0, + 0xff, 0); + if (status < 0) { + dev_err(&client->dev, "Failed to clear isl29018 CMD1 reg." + "(%d)\n", status); + return status; + } + + msleep(1); /* per data sheet, page 10 */ + /* set defaults */ status = isl29018_set_range(client, chip->range, &new_range); if (status < 0) { From 88b42f3a75ee53a4943069d4f8206f3c8d56bd58 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 18:04:37 +0100 Subject: [PATCH 0200/1519] staging:iio:imu:adis16344 support Simple device. Note the sparse scan mask used. Done from datasheet as very similar to existing parts. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_core.c | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 8b8e8a3b769..371eb0104b4 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -35,6 +35,7 @@ enum adis16400_chip_variant { ADIS16300, + ADIS16344, ADIS16350, ADIS16360, ADIS16362, @@ -689,6 +690,38 @@ static struct iio_chan_spec adis16300_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(14) }; +static const struct iio_chan_spec adis16344_channels[] = { + IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + gyro_y, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + gyro_z, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0), + IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + temp0, ADIS16350_SCAN_TEMP_X, IIO_ST('s', 12, 16, 0), 0), + IIO_CHAN_SOFT_TIMESTAMP(12) +}; + static struct attribute *adis16400_attributes[] = { &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, @@ -713,6 +746,16 @@ static struct adis16400_chip_info adis16400_chips[] = { (1 << ADIS16300_SCAN_INCLI_X) | (1 << ADIS16300_SCAN_INCLI_Y) | (1 << 14), }, + [ADIS16344] = { + .channels = adis16344_channels, + .num_channels = ARRAY_SIZE(adis16344_channels), + .gyro_scale_micro = 873, + .accel_scale_micro = 981, + .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) | + (1 << ADIS16400_SCAN_GYRO_Y) | (1 << ADIS16400_SCAN_GYRO_Z) | + (1 << ADIS16400_SCAN_ACC_X) | (1 << ADIS16400_SCAN_ACC_Y) | + (1 << ADIS16400_SCAN_ACC_Z), + }, [ADIS16350] = { .channels = adis16350_channels, .num_channels = ARRAY_SIZE(adis16350_channels), @@ -868,6 +911,7 @@ err_ret: static const struct spi_device_id adis16400_id[] = { {"adis16300", ADIS16300}, + {"adis16344", ADIS16344}, {"adis16350", ADIS16350}, {"adis16354", ADIS16350}, {"adis16355", ADIS16350}, From 7a27b042f9cf6bd6e60c236a55d7a71a64287a84 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 17 Aug 2011 17:29:34 +0200 Subject: [PATCH 0201/1519] IIO: ADC: New driver for AD7190/AD7192/AD7195 4 Channel SPI ADC New driver for AD7190/AD7192/AD7195 4.8 kHz, Ultralow Noise, 24-Bit Sigma-Delta ADC with PGA These devices features a dual use data out ready DOUT/RDY output. In order to avoid contentions on the SPI bus, it's necessary to use spi bus locking. The DOUT/RDY output must also be wired to an interrupt capable GPIO. In INDIO_RING_TRIGGERED mode, this driver may block its SPI bus segment for an extended period of time. Changes since V1: Add missing documentation. Remove obsoleted include files. Fix typos and style issues. Fix buffer size. Split ad7192_show() into two functions. Avoid race condition add mutex. Abandon IIO_CHAN macro. Reorder elements in ad7192_platform_data. Remove driver bus type. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 21 + drivers/staging/iio/adc/Kconfig | 14 + drivers/staging/iio/adc/Makefile | 1 + drivers/staging/iio/adc/ad7192.c | 1189 +++++++++++++++++ drivers/staging/iio/adc/ad7192.h | 47 + 5 files changed, 1272 insertions(+) create mode 100644 drivers/staging/iio/adc/ad7192.c create mode 100644 drivers/staging/iio/adc/ad7192.h diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index 5f99f88d1b2..c19dbf4ab24 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -711,3 +711,24 @@ Contact: linux-iio@xxxxxxxxxxxxxxx Description: This attribute is used to read the amount of quadrature error present in the device at a given time. + +What: /sys/.../iio:deviceX/ac_excitation_en +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + This attribute, if available, is used to enable the AC + excitation mode found on some converters. In ac excitation mode, + the polarity of the excitation voltage is reversed on + alternate cycles, to eliminate DC errors. + +What: /sys/.../iio:deviceX/bridge_switch_en +KernelVersion: 3.1.0 +Contact: linux-iio@vger.kernel.org +Description: + This attribute, if available, is used to close or open the + bridge power down switch found on some converters. + In bridge applications, such as strain gauges and load cells, + the bridge itself consumes the majority of the current in the + system. To minimize the current consumption of the system, + the bridge can be disconnected (when it is not being used + using the bridge_switch_en attribute. diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 60de7d72bb2..25566c62467 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -161,6 +161,20 @@ config AD7816 Say yes here to build support for Analog Devices AD7816/7/8 temperature sensors and ADC. +config AD7192 + tristate "Analog Devices AD7190 AD7192 AD7195 ADC driver" + depends on SPI + select IIO_RING_BUFFER + select IIO_SW_RING + select IIO_TRIGGER + help + Say yes here to build support for Analog Devices AD7190, + AD7192 or AD7195 SPI analog to digital convertors (ADC). + If unsure, say N (but it's safe to say "Y"). + + To compile this driver as a module, choose M here: the + module will be called ad7192. + config ADT75 tristate "Analog Devices ADT75 temperature sensor driver" depends on I2C diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 634a55f54a7..990d3fada30 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_AD7745) += ad7745.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7816) += ad7816.o +obj-$(CONFIG_AD7192) += ad7192.o obj-$(CONFIG_ADT75) += adt75.o obj-$(CONFIG_ADT7310) += adt7310.o obj-$(CONFIG_ADT7410) += adt7410.o diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c new file mode 100644 index 00000000000..c5a8b50ddf4 --- /dev/null +++ b/drivers/staging/iio/adc/ad7192.c @@ -0,0 +1,1189 @@ +/* + * AD7190 AD7192 AD7195 SPI ADC driver + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" +#include "../ring_generic.h" +#include "../ring_sw.h" +#include "../trigger.h" + +#include "ad7192.h" + +/* Registers */ +#define AD7192_REG_COMM 0 /* Communications Register (WO, 8-bit) */ +#define AD7192_REG_STAT 0 /* Status Register (RO, 8-bit) */ +#define AD7192_REG_MODE 1 /* Mode Register (RW, 24-bit */ +#define AD7192_REG_CONF 2 /* Configuration Register (RW, 24-bit) */ +#define AD7192_REG_DATA 3 /* Data Register (RO, 24/32-bit) */ +#define AD7192_REG_ID 4 /* ID Register (RO, 8-bit) */ +#define AD7192_REG_GPOCON 5 /* GPOCON Register (RO, 8-bit) */ +#define AD7192_REG_OFFSET 6 /* Offset Register (RW, 16-bit + * (AD7792)/24-bit (AD7192)) */ +#define AD7192_REG_FULLSALE 7 /* Full-Scale Register + * (RW, 16-bit (AD7792)/24-bit (AD7192)) */ + +/* Communications Register Bit Designations (AD7192_REG_COMM) */ +#define AD7192_COMM_WEN (1 << 7) /* Write Enable */ +#define AD7192_COMM_WRITE (0 << 6) /* Write Operation */ +#define AD7192_COMM_READ (1 << 6) /* Read Operation */ +#define AD7192_COMM_ADDR(x) (((x) & 0x7) << 3) /* Register Address */ +#define AD7192_COMM_CREAD (1 << 2) /* Continuous Read of Data Register */ + +/* Status Register Bit Designations (AD7192_REG_STAT) */ +#define AD7192_STAT_RDY (1 << 7) /* Ready */ +#define AD7192_STAT_ERR (1 << 6) /* Error (Overrange, Underrange) */ +#define AD7192_STAT_NOREF (1 << 5) /* Error no external reference */ +#define AD7192_STAT_PARITY (1 << 4) /* Parity */ +#define AD7192_STAT_CH3 (1 << 2) /* Channel 3 */ +#define AD7192_STAT_CH2 (1 << 1) /* Channel 2 */ +#define AD7192_STAT_CH1 (1 << 0) /* Channel 1 */ + +/* Mode Register Bit Designations (AD7192_REG_MODE) */ +#define AD7192_MODE_SEL(x) (((x) & 0x7) << 21) /* Operation Mode Select */ +#define AD7192_MODE_DAT_STA (1 << 20) /* Status Register transmission */ +#define AD7192_MODE_CLKSRC(x) (((x) & 0x3) << 18) /* Clock Source Select */ +#define AD7192_MODE_SINC3 (1 << 15) /* SINC3 Filter Select */ +#define AD7192_MODE_ACX (1 << 14) /* AC excitation enable(AD7195 only)*/ +#define AD7192_MODE_ENPAR (1 << 13) /* Parity Enable */ +#define AD7192_MODE_CLKDIV (1 << 12) /* Clock divide by 2 (AD7190/2 only)*/ +#define AD7192_MODE_SCYCLE (1 << 11) /* Single cycle conversion */ +#define AD7192_MODE_REJ60 (1 << 10) /* 50/60Hz notch filter */ +#define AD7192_MODE_RATE(x) ((x) & 0x3FF) /* Filter Update Rate Select */ + +/* Mode Register: AD7192_MODE_SEL options */ +#define AD7192_MODE_CONT 0 /* Continuous Conversion Mode */ +#define AD7192_MODE_SINGLE 1 /* Single Conversion Mode */ +#define AD7192_MODE_IDLE 2 /* Idle Mode */ +#define AD7192_MODE_PWRDN 3 /* Power-Down Mode */ +#define AD7192_MODE_CAL_INT_ZERO 4 /* Internal Zero-Scale Calibration */ +#define AD7192_MODE_CAL_INT_FULL 5 /* Internal Full-Scale Calibration */ +#define AD7192_MODE_CAL_SYS_ZERO 6 /* System Zero-Scale Calibration */ +#define AD7192_MODE_CAL_SYS_FULL 7 /* System Full-Scale Calibration */ + +/* Mode Register: AD7192_MODE_CLKSRC options */ +#define AD7192_CLK_EXT_MCLK1_2 0 /* External 4.92 MHz Clock connected + * from MCLK1 to MCLK2 */ +#define AD7192_CLK_EXT_MCLK2 1 /* External Clock applied to MCLK2 */ +#define AD7192_CLK_INT 2 /* Internal 4.92 MHz Clock not + * available at the MCLK2 pin */ +#define AD7192_CLK_INT_CO 3 /* Internal 4.92 MHz Clock available + * at the MCLK2 pin */ + + +/* Configuration Register Bit Designations (AD7192_REG_CONF) */ + +#define AD7192_CONF_CHOP (1 << 23) /* CHOP enable */ +#define AD7192_CONF_REFSEL (1 << 20) /* REFIN1/REFIN2 Reference Select */ +#define AD7192_CONF_CHAN(x) (((x) & 0xFF) << 8) /* Channel select */ +#define AD7192_CONF_BURN (1 << 7) /* Burnout current enable */ +#define AD7192_CONF_REFDET (1 << 6) /* Reference detect enable */ +#define AD7192_CONF_BUF (1 << 4) /* Buffered Mode Enable */ +#define AD7192_CONF_UNIPOLAR (1 << 3) /* Unipolar/Bipolar Enable */ +#define AD7192_CONF_GAIN(x) ((x) & 0x7) /* Gain Select */ + +#define AD7192_CH_AIN1P_AIN2M 0 /* AIN1(+) - AIN2(-) */ +#define AD7192_CH_AIN3P_AIN4M 1 /* AIN3(+) - AIN4(-) */ +#define AD7192_CH_TEMP 2 /* Temp Sensor */ +#define AD7192_CH_AIN2P_AIN2M 3 /* AIN2(+) - AIN2(-) */ +#define AD7192_CH_AIN1 4 /* AIN1 - AINCOM */ +#define AD7192_CH_AIN2 5 /* AIN2 - AINCOM */ +#define AD7192_CH_AIN3 6 /* AIN3 - AINCOM */ +#define AD7192_CH_AIN4 7 /* AIN4 - AINCOM */ + +/* ID Register Bit Designations (AD7192_REG_ID) */ +#define ID_AD7190 0x4 +#define ID_AD7192 0x0 +#define ID_AD7195 0x6 +#define AD7192_ID_MASK 0x0F + +/* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */ +#define AD7192_GPOCON_BPDSW (1 << 6) /* Bridge power-down switch enable */ +#define AD7192_GPOCON_GP32EN (1 << 5) /* Digital Output P3 and P2 enable */ +#define AD7192_GPOCON_GP10EN (1 << 4) /* Digital Output P1 and P0 enable */ +#define AD7192_GPOCON_P3DAT (1 << 3) /* P3 state */ +#define AD7192_GPOCON_P2DAT (1 << 2) /* P2 state */ +#define AD7192_GPOCON_P1DAT (1 << 1) /* P1 state */ +#define AD7192_GPOCON_P0DAT (1 << 0) /* P0 state */ + +#define AD7192_INT_FREQ_MHz 4915200 + +/* NOTE: + * The AD7190/2/5 features a dual use data out ready DOUT/RDY output. + * In order to avoid contentions on the SPI bus, it's therefore necessary + * to use spi bus locking. + * + * The DOUT/RDY output must also be wired to an interrupt capable GPIO. + */ + +struct ad7192_state { + struct spi_device *spi; + struct iio_trigger *trig; + struct regulator *reg; + struct ad7192_platform_data *pdata; + wait_queue_head_t wq_data_avail; + bool done; + bool irq_dis; + u16 int_vref_mv; + u32 mclk; + u32 f_order; + u32 mode; + u32 conf; + u32 scale_avail[8][2]; + u32 available_scan_masks[9]; + u8 gpocon; + u8 devid; + /* + * DMA (thus cache coherency maintenance) requires the + * transfer buffers to live in their own cache lines. + */ + u8 data[4] ____cacheline_aligned; +}; + +static int __ad7192_write_reg(struct ad7192_state *st, bool locked, + bool cs_change, unsigned char reg, + unsigned size, unsigned val) +{ + u8 *data = st->data; + struct spi_transfer t = { + .tx_buf = data, + .len = size + 1, + .cs_change = cs_change, + }; + struct spi_message m; + + data[0] = AD7192_COMM_WRITE | AD7192_COMM_ADDR(reg); + + switch (size) { + case 3: + data[1] = val >> 16; + data[2] = val >> 8; + data[3] = val; + break; + case 2: + data[1] = val >> 8; + data[2] = val; + break; + case 1: + data[1] = val; + break; + default: + return -EINVAL; + } + + spi_message_init(&m); + spi_message_add_tail(&t, &m); + + if (locked) + return spi_sync_locked(st->spi, &m); + else + return spi_sync(st->spi, &m); +} + +static int ad7192_write_reg(struct ad7192_state *st, + unsigned reg, unsigned size, unsigned val) +{ + return __ad7192_write_reg(st, false, false, reg, size, val); +} + +static int __ad7192_read_reg(struct ad7192_state *st, bool locked, + bool cs_change, unsigned char reg, + int *val, unsigned size) +{ + u8 *data = st->data; + int ret; + struct spi_transfer t[] = { + { + .tx_buf = data, + .len = 1, + }, { + .rx_buf = data, + .len = size, + .cs_change = cs_change, + }, + }; + struct spi_message m; + + data[0] = AD7192_COMM_READ | AD7192_COMM_ADDR(reg); + + spi_message_init(&m); + spi_message_add_tail(&t[0], &m); + spi_message_add_tail(&t[1], &m); + + if (locked) + ret = spi_sync_locked(st->spi, &m); + else + ret = spi_sync(st->spi, &m); + + if (ret < 0) + return ret; + + switch (size) { + case 3: + *val = data[0] << 16 | data[1] << 8 | data[2]; + break; + case 2: + *val = data[0] << 8 | data[1]; + break; + case 1: + *val = data[0]; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int ad7192_read_reg(struct ad7192_state *st, + unsigned reg, int *val, unsigned size) +{ + return __ad7192_read_reg(st, 0, 0, reg, val, size); +} + +static int ad7192_read(struct ad7192_state *st, unsigned ch, + unsigned len, int *val) +{ + int ret; + st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) | + AD7192_CONF_CHAN(1 << ch); + st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | + AD7192_MODE_SEL(AD7192_MODE_SINGLE); + + ad7192_write_reg(st, AD7192_REG_CONF, 3, st->conf); + + spi_bus_lock(st->spi->master); + st->done = false; + + ret = __ad7192_write_reg(st, 1, 1, AD7192_REG_MODE, 3, st->mode); + if (ret < 0) + goto out; + + st->irq_dis = false; + enable_irq(st->spi->irq); + wait_event_interruptible(st->wq_data_avail, st->done); + + ret = __ad7192_read_reg(st, 1, 0, AD7192_REG_DATA, val, len); +out: + spi_bus_unlock(st->spi->master); + + return ret; +} + +static int ad7192_calibrate(struct ad7192_state *st, unsigned mode, unsigned ch) +{ + int ret; + + st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) | + AD7192_CONF_CHAN(1 << ch); + st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | AD7192_MODE_SEL(mode); + + ad7192_write_reg(st, AD7192_REG_CONF, 3, st->conf); + + spi_bus_lock(st->spi->master); + st->done = false; + + ret = __ad7192_write_reg(st, 1, 1, AD7192_REG_MODE, 3, + (st->devid != ID_AD7195) ? + st->mode | AD7192_MODE_CLKDIV : + st->mode); + if (ret < 0) + goto out; + + st->irq_dis = false; + enable_irq(st->spi->irq); + wait_event_interruptible(st->wq_data_avail, st->done); + + st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | + AD7192_MODE_SEL(AD7192_MODE_IDLE); + + ret = __ad7192_write_reg(st, 1, 0, AD7192_REG_MODE, 3, st->mode); +out: + spi_bus_unlock(st->spi->master); + + return ret; +} + +static const u8 ad7192_calib_arr[8][2] = { + {AD7192_MODE_CAL_INT_ZERO, AD7192_CH_AIN1}, + {AD7192_MODE_CAL_INT_FULL, AD7192_CH_AIN1}, + {AD7192_MODE_CAL_INT_ZERO, AD7192_CH_AIN2}, + {AD7192_MODE_CAL_INT_FULL, AD7192_CH_AIN2}, + {AD7192_MODE_CAL_INT_ZERO, AD7192_CH_AIN3}, + {AD7192_MODE_CAL_INT_FULL, AD7192_CH_AIN3}, + {AD7192_MODE_CAL_INT_ZERO, AD7192_CH_AIN4}, + {AD7192_MODE_CAL_INT_FULL, AD7192_CH_AIN4} +}; + +static int ad7192_calibrate_all(struct ad7192_state *st) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(ad7192_calib_arr); i++) { + ret = ad7192_calibrate(st, ad7192_calib_arr[i][0], + ad7192_calib_arr[i][1]); + if (ret) + goto out; + } + + return 0; +out: + dev_err(&st->spi->dev, "Calibration failed\n"); + return ret; +} + +static int ad7192_setup(struct ad7192_state *st) +{ + struct iio_dev *indio_dev = spi_get_drvdata(st->spi); + struct ad7192_platform_data *pdata = st->pdata; + unsigned long long scale_uv; + int i, ret, id; + u8 ones[6]; + + /* reset the serial interface */ + memset(&ones, 0xFF, 6); + ret = spi_write(st->spi, &ones, 6); + if (ret < 0) + goto out; + msleep(1); /* Wait for at least 500us */ + + /* write/read test for device presence */ + ret = ad7192_read_reg(st, AD7192_REG_ID, &id, 1); + if (ret) + goto out; + + id &= AD7192_ID_MASK; + + if (id != st->devid) + dev_warn(&st->spi->dev, "device ID query failed (0x%X)\n", id); + + switch (pdata->clock_source_sel) { + case AD7192_CLK_EXT_MCLK1_2: + case AD7192_CLK_EXT_MCLK2: + st->mclk = AD7192_INT_FREQ_MHz; + break; + case AD7192_CLK_INT: + case AD7192_CLK_INT_CO: + if (pdata->ext_clk_Hz) + st->mclk = pdata->ext_clk_Hz; + else + st->mclk = AD7192_INT_FREQ_MHz; + break; + default: + ret = -EINVAL; + goto out; + } + + st->mode = AD7192_MODE_SEL(AD7192_MODE_IDLE) | + AD7192_MODE_CLKSRC(pdata->clock_source_sel) | + AD7192_MODE_RATE(480); + + st->conf = AD7192_CONF_GAIN(0); + + if (pdata->rej60_en) + st->mode |= AD7192_MODE_REJ60; + + if (pdata->sinc3_en) + st->mode |= AD7192_MODE_SINC3; + + if (pdata->refin2_en && (st->devid != ID_AD7195)) + st->conf |= AD7192_CONF_REFSEL; + + if (pdata->chop_en) { + st->conf |= AD7192_CONF_CHOP; + if (pdata->sinc3_en) + st->f_order = 3; /* SINC 3rd order */ + else + st->f_order = 4; /* SINC 4th order */ + } else { + st->f_order = 1; + } + + if (pdata->buf_en) + st->conf |= AD7192_CONF_BUF; + + if (pdata->unipolar_en) + st->conf |= AD7192_CONF_UNIPOLAR; + + if (pdata->burnout_curr_en) + st->conf |= AD7192_CONF_BURN; + + ret = ad7192_write_reg(st, AD7192_REG_MODE, 3, st->mode); + if (ret) + goto out; + + ret = ad7192_write_reg(st, AD7192_REG_CONF, 3, st->conf); + if (ret) + goto out; + + ret = ad7192_calibrate_all(st); + if (ret) + goto out; + + /* Populate available ADC input ranges */ + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) { + scale_uv = ((u64)st->int_vref_mv * 100000000) + >> (indio_dev->channels[0].scan_type.realbits - + ((st->conf & AD7192_CONF_UNIPOLAR) ? 0 : 1)); + scale_uv >>= i; + + st->scale_avail[i][1] = do_div(scale_uv, 100000000) * 10; + st->scale_avail[i][0] = scale_uv; + } + + return 0; +out: + dev_err(&st->spi->dev, "setup failed\n"); + return ret; +} + +static int ad7192_scan_from_ring(struct ad7192_state *st, unsigned ch, int *val) +{ + struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + int ret; + s64 dat64[2]; + u32 *dat32 = (u32 *)dat64; + + if (!(ring->scan_mask & (1 << ch))) + return -EBUSY; + + ret = ring->access->read_last(ring, (u8 *) &dat64); + if (ret) + return ret; + + *val = *dat32; + + return 0; +} + +static int ad7192_ring_preenable(struct iio_dev *indio_dev) +{ + struct ad7192_state *st = iio_priv(indio_dev); + struct iio_ring_buffer *ring = indio_dev->ring; + size_t d_size; + unsigned channel; + + if (!ring->scan_count) + return -EINVAL; + + channel = __ffs(ring->scan_mask); + + d_size = ring->scan_count * + indio_dev->channels[0].scan_type.storagebits / 8; + + if (ring->scan_timestamp) { + d_size += sizeof(s64); + + if (d_size % sizeof(s64)) + d_size += sizeof(s64) - (d_size % sizeof(s64)); + } + + if (indio_dev->ring->access->set_bytes_per_datum) + indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, + d_size); + + st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | + AD7192_MODE_SEL(AD7192_MODE_CONT); + st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) | + AD7192_CONF_CHAN(1 << indio_dev->channels[channel].address); + + ad7192_write_reg(st, AD7192_REG_CONF, 3, st->conf); + + spi_bus_lock(st->spi->master); + __ad7192_write_reg(st, 1, 1, AD7192_REG_MODE, 3, st->mode); + + st->irq_dis = false; + enable_irq(st->spi->irq); + + return 0; +} + +static int ad7192_ring_postdisable(struct iio_dev *indio_dev) +{ + struct ad7192_state *st = iio_priv(indio_dev); + + st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | + AD7192_MODE_SEL(AD7192_MODE_IDLE); + + st->done = false; + wait_event_interruptible(st->wq_data_avail, st->done); + + if (!st->irq_dis) + disable_irq_nosync(st->spi->irq); + + __ad7192_write_reg(st, 1, 0, AD7192_REG_MODE, 3, st->mode); + + return spi_bus_unlock(st->spi->master); +} + +/** + * ad7192_trigger_handler() bh of trigger launched polling to ring buffer + **/ +static irqreturn_t ad7192_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->private_data; + struct iio_ring_buffer *ring = indio_dev->ring; + struct ad7192_state *st = iio_priv(indio_dev); + s64 dat64[2]; + s32 *dat32 = (s32 *)dat64; + + if (ring->scan_count) + __ad7192_read_reg(st, 1, 1, AD7192_REG_DATA, + dat32, + indio_dev->channels[0].scan_type.realbits/8); + + /* Guaranteed to be aligned with 8 byte boundary */ + if (ring->scan_timestamp) + dat64[1] = pf->timestamp; + + ring->access->store_to(ring, (u8 *)dat64, pf->timestamp); + + iio_trigger_notify_done(indio_dev->trig); + st->irq_dis = false; + enable_irq(st->spi->irq); + + return IRQ_HANDLED; +} + +static const struct iio_ring_setup_ops ad7192_ring_setup_ops = { + .preenable = &ad7192_ring_preenable, + .postenable = &iio_triggered_ring_postenable, + .predisable = &iio_triggered_ring_predisable, + .postdisable = &ad7192_ring_postdisable, +}; + +static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev) +{ + int ret; + + indio_dev->ring = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->ring) { + ret = -ENOMEM; + goto error_ret; + } + /* Effectively select the ring buffer implementation */ + indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, + &ad7192_trigger_handler, + IRQF_ONESHOT, + indio_dev, + "ad7192_consumer%d", + indio_dev->id); + if (indio_dev->pollfunc == NULL) { + ret = -ENOMEM; + goto error_deallocate_sw_rb; + } + + /* Ring buffer functions - here trigger setup related */ + indio_dev->ring->setup_ops = &ad7192_ring_setup_ops; + + /* Flag that polled ring buffering is possible */ + indio_dev->modes |= INDIO_RING_TRIGGERED; + return 0; + +error_deallocate_sw_rb: + iio_sw_rb_free(indio_dev->ring); +error_ret: + return ret; +} + +static void ad7192_ring_cleanup(struct iio_dev *indio_dev) +{ + /* ensure that the trigger has been detached */ + if (indio_dev->trig) { + iio_put_trigger(indio_dev->trig); + iio_trigger_dettach_poll_func(indio_dev->trig, + indio_dev->pollfunc); + } + iio_dealloc_pollfunc(indio_dev->pollfunc); + iio_sw_rb_free(indio_dev->ring); +} + +/** + * ad7192_data_rdy_trig_poll() the event handler for the data rdy trig + **/ +static irqreturn_t ad7192_data_rdy_trig_poll(int irq, void *private) +{ + struct ad7192_state *st = iio_priv(private); + + st->done = true; + wake_up_interruptible(&st->wq_data_avail); + disable_irq_nosync(irq); + st->irq_dis = true; + iio_trigger_poll(st->trig, iio_get_time_ns()); + + return IRQ_HANDLED; +} + +static int ad7192_probe_trigger(struct iio_dev *indio_dev) +{ + struct ad7192_state *st = iio_priv(indio_dev); + int ret; + + st->trig = iio_allocate_trigger("%s-dev%d", + spi_get_device_id(st->spi)->name, + indio_dev->id); + if (st->trig == NULL) { + ret = -ENOMEM; + goto error_ret; + } + + ret = request_irq(st->spi->irq, + ad7192_data_rdy_trig_poll, + IRQF_TRIGGER_LOW, + spi_get_device_id(st->spi)->name, + indio_dev); + if (ret) + goto error_free_trig; + + disable_irq_nosync(st->spi->irq); + st->irq_dis = true; + st->trig->dev.parent = &st->spi->dev; + st->trig->owner = THIS_MODULE; + st->trig->private_data = indio_dev; + + ret = iio_trigger_register(st->trig); + + /* select default trigger */ + indio_dev->trig = st->trig; + if (ret) + goto error_free_irq; + + return 0; + +error_free_irq: + free_irq(st->spi->irq, indio_dev); +error_free_trig: + iio_free_trigger(st->trig); +error_ret: + return ret; +} + +static void ad7192_remove_trigger(struct iio_dev *indio_dev) +{ + struct ad7192_state *st = iio_priv(indio_dev); + + iio_trigger_unregister(st->trig); + free_irq(st->spi->irq, indio_dev); + iio_free_trigger(st->trig); +} + +static ssize_t ad7192_read_frequency(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", st->mclk / + (st->f_order * 1024 * AD7192_MODE_RATE(st->mode))); +} + +static ssize_t ad7192_write_frequency(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + unsigned long lval; + int div, ret; + + ret = strict_strtoul(buf, 10, &lval); + if (ret) + return ret; + + mutex_lock(&indio_dev->mlock); + if (iio_ring_enabled(indio_dev)) { + mutex_unlock(&indio_dev->mlock); + return -EBUSY; + } + + div = st->mclk / (lval * st->f_order * 1024); + if (div < 1 || div > 1023) { + ret = -EINVAL; + goto out; + } + + st->mode &= ~AD7192_MODE_RATE(-1); + st->mode |= AD7192_MODE_RATE(div); + ad7192_write_reg(st, AD7192_REG_MODE, 3, st->mode); + +out: + mutex_unlock(&indio_dev->mlock); + + return ret ? ret : len; +} + +static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, + ad7192_read_frequency, + ad7192_write_frequency); + + +static ssize_t ad7192_show_scale_available(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + int i, len = 0; + + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) + len += sprintf(buf + len, "%d.%09u ", st->scale_avail[i][0], + st->scale_avail[i][1]); + + len += sprintf(buf + len, "\n"); + + return len; +} + +static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available, in-in_scale_available, + S_IRUGO, ad7192_show_scale_available, NULL, 0); + +static IIO_DEVICE_ATTR(in_scale_available, S_IRUGO, + ad7192_show_scale_available, NULL, 0); + +static ssize_t ad7192_show_ac_excitation(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", !!(st->mode & AD7192_MODE_ACX)); +} + +static ssize_t ad7192_show_bridge_switch(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", !!(st->gpocon & AD7192_GPOCON_BPDSW)); +} + +static ssize_t ad7192_set(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int ret; + bool val; + + ret = strtobool(buf, &val); + if (ret < 0) + return ret; + + mutex_lock(&indio_dev->mlock); + if (iio_ring_enabled(indio_dev)) { + mutex_unlock(&indio_dev->mlock); + return -EBUSY; + } + + switch (this_attr->address) { + case AD7192_REG_GPOCON: + if (val) + st->gpocon |= AD7192_GPOCON_BPDSW; + else + st->gpocon &= ~AD7192_GPOCON_BPDSW; + + ad7192_write_reg(st, AD7192_REG_GPOCON, 1, st->gpocon); + break; + case AD7192_REG_MODE: + if (val) + st->mode |= AD7192_MODE_ACX; + else + st->mode &= ~AD7192_MODE_ACX; + + ad7192_write_reg(st, AD7192_REG_GPOCON, 3, st->mode); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&indio_dev->mlock); + + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(bridge_switch_en, S_IRUGO | S_IWUSR, + ad7192_show_bridge_switch, ad7192_set, + AD7192_REG_GPOCON); + +static IIO_DEVICE_ATTR(ac_excitation_en, S_IRUGO | S_IWUSR, + ad7192_show_ac_excitation, ad7192_set, + AD7192_REG_MODE); + +static struct attribute *ad7192_attributes[] = { + &iio_dev_attr_sampling_frequency.dev_attr.attr, + &iio_dev_attr_in_m_in_scale_available.dev_attr.attr, + &iio_dev_attr_in_scale_available.dev_attr.attr, + &iio_dev_attr_bridge_switch_en.dev_attr.attr, + &iio_dev_attr_ac_excitation_en.dev_attr.attr, + NULL +}; + +static mode_t ad7192_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(dev_info); + + mode_t mode = attr->mode; + + if ((st->devid != ID_AD7195) && + (attr == &iio_dev_attr_ac_excitation_en.dev_attr.attr)) + mode = 0; + + return mode; +} + +static const struct attribute_group ad7192_attribute_group = { + .attrs = ad7192_attributes, + .is_visible = ad7192_attr_is_visible, +}; + +static int ad7192_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad7192_state *st = iio_priv(indio_dev); + int ret, smpl = 0; + bool unipolar = !!(st->conf & AD7192_CONF_UNIPOLAR); + + switch (m) { + case 0: + mutex_lock(&indio_dev->mlock); + if (iio_ring_enabled(indio_dev)) + ret = ad7192_scan_from_ring(st, + chan->scan_index, &smpl); + else + ret = ad7192_read(st, chan->address, + chan->scan_type.realbits / 8, &smpl); + mutex_unlock(&indio_dev->mlock); + + if (ret < 0) + return ret; + + *val = (smpl >> chan->scan_type.shift) & + ((1 << (chan->scan_type.realbits)) - 1); + + switch (chan->type) { + case IIO_IN: + case IIO_IN_DIFF: + if (!unipolar) + *val -= (1 << (chan->scan_type.realbits - 1)); + break; + case IIO_TEMP: + *val -= 0x800000; + *val /= 2815; /* temp Kelvin */ + *val -= 273; /* temp Celsius */ + break; + default: + return -EINVAL; + } + return IIO_VAL_INT; + + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + mutex_lock(&indio_dev->mlock); + *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; + *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; + mutex_unlock(&indio_dev->mlock); + + return IIO_VAL_INT_PLUS_NANO; + + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + *val = 1000; + + return IIO_VAL_INT; + } + + return -EINVAL; +} + +static int ad7192_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct ad7192_state *st = iio_priv(indio_dev); + int ret, i; + unsigned int tmp; + + mutex_lock(&indio_dev->mlock); + if (iio_ring_enabled(indio_dev)) { + mutex_unlock(&indio_dev->mlock); + return -EBUSY; + } + + switch (mask) { + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + ret = -EINVAL; + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) + if (val2 == st->scale_avail[i][1]) { + tmp = st->conf; + st->conf &= ~AD7192_CONF_GAIN(-1); + st->conf |= AD7192_CONF_GAIN(i); + + if (tmp != st->conf) { + ad7192_write_reg(st, AD7192_REG_CONF, + 3, st->conf); + ad7192_calibrate_all(st); + } + ret = 0; + } + + default: + ret = -EINVAL; + } + + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static int ad7192_validate_trigger(struct iio_dev *indio_dev, + struct iio_trigger *trig) +{ + if (indio_dev->trig != trig) + return -EINVAL; + + return 0; +} + +static int ad7192_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + return IIO_VAL_INT_PLUS_NANO; +} + +static const struct iio_info ad7192_info = { + .read_raw = &ad7192_read_raw, + .write_raw = &ad7192_write_raw, + .write_raw_get_fmt = &ad7192_write_raw_get_fmt, + .attrs = &ad7192_attribute_group, + .validate_trigger = ad7192_validate_trigger, + .driver_module = THIS_MODULE, +}; + +#define AD7192_CHAN_DIFF(_chan, _chan2, _name, _address, _si) \ + { .type = IIO_IN_DIFF, \ + .indexed = 1, \ + .extend_name = _name, \ + .channel = _chan, \ + .channel2 = _chan2, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .address = _address, \ + .scan_index = _si, \ + .scan_type = IIO_ST('s', 24, 32, 0)} + +#define AD7192_CHAN(_chan, _address, _si) \ + { .type = IIO_IN, \ + .indexed = 1, \ + .channel = _chan, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .address = _address, \ + .scan_index = _si, \ + .scan_type = IIO_ST('s', 24, 32, 0)} + +#define AD7192_CHAN_TEMP(_chan, _address, _si) \ + { .type = IIO_TEMP, \ + .indexed = 1, \ + .channel = _chan, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ + .address = _address, \ + .scan_index = _si, \ + .scan_type = IIO_ST('s', 24, 32, 0)} + +static struct iio_chan_spec ad7192_channels[] = { + AD7192_CHAN_DIFF(1, 2, NULL, AD7192_CH_AIN1P_AIN2M, 0), + AD7192_CHAN_DIFF(3, 4, NULL, AD7192_CH_AIN3P_AIN4M, 1), + AD7192_CHAN_TEMP(0, AD7192_CH_TEMP, 2), + AD7192_CHAN_DIFF(2, 2, "shorted", AD7192_CH_AIN2P_AIN2M, 3), + AD7192_CHAN(1, AD7192_CH_AIN1, 4), + AD7192_CHAN(2, AD7192_CH_AIN2, 5), + AD7192_CHAN(3, AD7192_CH_AIN3, 6), + AD7192_CHAN(4, AD7192_CH_AIN4, 7), + IIO_CHAN_SOFT_TIMESTAMP(8), +}; + +static int __devinit ad7192_probe(struct spi_device *spi) +{ + struct ad7192_platform_data *pdata = spi->dev.platform_data; + struct ad7192_state *st; + struct iio_dev *indio_dev; + int ret, i , voltage_uv = 0, regdone = 0; + + if (!pdata) { + dev_err(&spi->dev, "no platform data?\n"); + return -ENODEV; + } + + if (!spi->irq) { + dev_err(&spi->dev, "no IRQ?\n"); + return -ENODEV; + } + + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + + st->reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(st->reg)) { + ret = regulator_enable(st->reg); + if (ret) + goto error_put_reg; + + voltage_uv = regulator_get_voltage(st->reg); + } + + st->pdata = pdata; + + if (pdata && pdata->vref_mv) + st->int_vref_mv = pdata->vref_mv; + else if (voltage_uv) + st->int_vref_mv = voltage_uv / 1000; + else + dev_warn(&spi->dev, "reference voltage undefined\n"); + + spi_set_drvdata(spi, indio_dev); + st->spi = spi; + st->devid = spi_get_device_id(spi)->driver_data; + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ad7192_channels; + indio_dev->num_channels = ARRAY_SIZE(ad7192_channels); + indio_dev->available_scan_masks = st->available_scan_masks; + indio_dev->info = &ad7192_info; + + for (i = 0; i < indio_dev->num_channels; i++) + st->available_scan_masks[i] = (1 << i) | (1 << + indio_dev->channels[indio_dev->num_channels - 1]. + scan_index); + + init_waitqueue_head(&st->wq_data_avail); + + ret = ad7192_register_ring_funcs_and_init(indio_dev); + if (ret) + goto error_disable_reg; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_ring; + regdone = 1; + + ret = ad7192_probe_trigger(indio_dev); + if (ret) + goto error_unreg_ring; + + ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + indio_dev->channels, + indio_dev->num_channels); + if (ret) + goto error_remove_trigger; + + ret = ad7192_setup(st); + if (ret) + goto error_uninitialize_ring; + + return 0; + +error_uninitialize_ring: + iio_ring_buffer_unregister(indio_dev->ring); +error_remove_trigger: + ad7192_remove_trigger(indio_dev); +error_unreg_ring: + ad7192_ring_cleanup(indio_dev); +error_disable_reg: + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); +error_put_reg: + if (!IS_ERR(st->reg)) + regulator_put(st->reg); + + if (regdone) + iio_device_unregister(indio_dev); + else + iio_free_device(indio_dev); + + return ret; +} + +static int ad7192_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad7192_state *st = iio_priv(indio_dev); + + iio_ring_buffer_unregister(indio_dev->ring); + ad7192_remove_trigger(indio_dev); + ad7192_ring_cleanup(indio_dev); + + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); + } + + iio_device_unregister(indio_dev); + + return 0; +} + +static const struct spi_device_id ad7192_id[] = { + {"ad7190", ID_AD7190}, + {"ad7192", ID_AD7192}, + {"ad7195", ID_AD7195}, + {} +}; + +static struct spi_driver ad7192_driver = { + .driver = { + .name = "ad7192", + .owner = THIS_MODULE, + }, + .probe = ad7192_probe, + .remove = __devexit_p(ad7192_remove), + .id_table = ad7192_id, +}; + +static int __init ad7192_init(void) +{ + return spi_register_driver(&ad7192_driver); +} +module_init(ad7192_init); + +static void __exit ad7192_exit(void) +{ + spi_unregister_driver(&ad7192_driver); +} +module_exit(ad7192_exit); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD7190, AD7192, AD7195 ADC"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h new file mode 100644 index 00000000000..a0a5b61a41f --- /dev/null +++ b/drivers/staging/iio/adc/ad7192.h @@ -0,0 +1,47 @@ +/* + * AD7190 AD7192 AD7195 SPI ADC driver + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ +#ifndef IIO_ADC_AD7192_H_ +#define IIO_ADC_AD7192_H_ + +/* + * TODO: struct ad7192_platform_data needs to go into include/linux/iio + */ + +/** + * struct ad7192_platform_data - platform/board specific information + * @vref_mv: the external reference voltage in millivolt + * @clock_source_sel: [0..3] + * 0 External 4.92 MHz clock connected from MCLK1 to MCLK2 + * 1 External Clock applied to MCLK2 + * 2 Internal 4.92 MHz Clock not available at the MCLK2 pin + * 3 Internal 4.92 MHz Clock available at the MCLK2 pin + * @ext_clk_Hz: the external clock frequency in Hz, if not set + * the driver uses the internal clock (16.776 MHz) + * @refin2_en: REFIN1/REFIN2 Reference Select (AD7190/2 only) + * @rej60_en: 50/60Hz notch filter enable + * @sinc3_en: SINC3 filter enable (default SINC4) + * @chop_en: CHOP mode enable + * @buf_en: buffered input mode enable + * @unipolar_en: unipolar mode enable + * @burnout_curr_en: constant current generators on AIN(+|-) enable + */ + +struct ad7192_platform_data { + u16 vref_mv; + u8 clock_source_sel; + u32 ext_clk_Hz; + bool refin2_en; + bool rej60_en; + bool sinc3_en; + bool chop_en; + bool buf_en; + bool unipolar_en; + bool burnout_curr_en; +}; + +#endif /* IIO_ADC_AD7192_H_ */ From 44c4ec78c901f7ce85c64f074ca12828c1301d3f Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Thu, 21 Jul 2011 11:57:40 +0300 Subject: [PATCH 0202/1519] Staging: xgifb: Fixed up a errors "do not initialise statics to 0 or NULL" in XGI_main.h This is a patch to the XGI_main.h file that fixed up a errors "do not initialise statics to 0 or NULL" found by the checkpatch.pl tools. Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index f6cd22d7963..856c9f18c4c 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -268,28 +268,28 @@ static u32 pseudo_palette[17]; /* display status */ -static int XGIfb_off = 0; -static int XGIfb_crt1off = 0; +static int XGIfb_off; +static int XGIfb_crt1off; static int XGIfb_forcecrt1 = -1; -static int XGIfb_userom = 0; +static int XGIfb_userom ; /*static int XGIfb_useoem = -1; */ /* global flags */ static int XGIfb_registered; -static int XGIfb_tvmode = 0; -static int XGIfb_pdc = 0; -static int enable_dstn = 0; +static int XGIfb_tvmode; +static int XGIfb_pdc; +static int enable_dstn; static int XGIfb_ypan = -1; -static int XGIfb_CRT2_write_enable = 0; +static int XGIfb_CRT2_write_enable; /* TW: CRT2 type (for overriding autodetection) */ static int XGIfb_crt2type = -1; /* PR: Tv plug type (for overriding autodetection) */ static int XGIfb_tvplug = -1; -static unsigned char XGIfb_detectedpdc = 0; +static unsigned char XGIfb_detectedpdc; static unsigned char XGIfb_detectedlcda = 0xff; @@ -483,8 +483,8 @@ static int xgifb_mode_idx = 1; static int xgifb_mode_idx = -1; /* Use a default mode if we are inside the kernel */ #endif -static u8 XGIfb_mode_no = 0; -static u8 XGIfb_rate_idx = 0; +static u8 XGIfb_mode_no; +static u8 XGIfb_rate_idx; /* TW: CR36 evaluation */ static const unsigned short XGI300paneltype[] = { From e684f4682d49e4815d2b6893a1862f183d755fb2 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Thu, 21 Jul 2011 11:58:53 +0300 Subject: [PATCH 0203/1519] Staging: xgifb: Fixed up a errors "do not initialise statics to 0 or NULL" in XGI_main_26.c This is a patch to the XGI_main_26.c file that fixed up a errors "do not initialise statics to 0 or NULL" found by the checkpatch.pl tools. Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 4403e5f8059..b6ee11fbca7 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -396,8 +396,8 @@ static unsigned char XGIfb_query_VGA_config_space( struct xgi_hw_device_info *pXGIhw_ext, unsigned long offset, unsigned long set, unsigned long *value) { - static struct pci_dev *pdev = NULL; - static unsigned char init = 0, valid_pdev = 0; + static struct pci_dev *pdev; + static unsigned char init, valid_pdev; if (!set) DPRINTK("XGIfb: Get VGA offset 0x%lx\n", offset); @@ -2564,26 +2564,26 @@ module_init(xgifb_init); #ifdef MODULE -static char *mode = NULL; -static int vesa = 0; -static unsigned int rate = 0; -static unsigned int mem = 0; -static char *forcecrt2type = NULL; +static char *mode; +static int vesa; +static unsigned int rate; +static unsigned int mem; +static char *forcecrt2type; static int forcecrt1 = -1; static int pdc = -1; static int pdc1 = -1; static int noypan = -1; static int userom = -1; static int useoem = -1; -static char *tvstandard = NULL; -static int nocrt2rate = 0; +static char *tvstandard; +static int nocrt2rate; static int scalelcd = -1; -static char *specialtiming = NULL; +static char *specialtiming; static int lvdshl = -1; -static int tvxposoffset = 0, tvyposoffset = 0; +static int tvxposoffset, tvyposoffset; #if !defined(__i386__) && !defined(__x86_64__) -static int resetcard = 0; -static int videoram = 0; +static int resetcard; +static int videoram; #endif MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver"); From 032abf7bf9ee3a1ca89dd9dd88b1a8cee5e56e63 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Thu, 21 Jul 2011 11:59:11 +0300 Subject: [PATCH 0204/1519] Staging: xgifb: Delete define XGIINITSTATIC in XGI_main_26.c and XGI_main.h This is a patch to the XGI_main.h and XGI_main_26.c file that fixed up a define warrning found by the checkpatch.pl tools. Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 856c9f18c4c..543ef2c363e 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -41,7 +41,6 @@ #define XGI_IOTYPE1 void __iomem #define XGI_IOTYPE2 __iomem -#define XGIINITSTATIC static static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = { {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index b6ee11fbca7..df27dfed756 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1949,7 +1949,7 @@ static void XGIfb_get_VB_type(void) } } -XGIINITSTATIC int __init XGIfb_setup(char *options) +static int __init XGIfb_setup(char *options) { char *this_opt; @@ -2543,7 +2543,7 @@ static struct pci_driver xgifb_driver = { .remove = __devexit_p(xgifb_remove) }; -XGIINITSTATIC int __init xgifb_init(void) +static int __init xgifb_init(void) { char *option = NULL; From 5c167b30c1b4004506b13e59b0fde5b8d5b3a05c Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:19 +0300 Subject: [PATCH 0205/1519] staging: xgifb: eliminate #ifdef NewScratch NewScratch is always defined so all checks can be eliminated. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 77 ---------------------------------- 1 file changed, 77 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 339c071854f..d7358d85202 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -3,11 +3,6 @@ #ifndef _INITDEF_ #define _INITDEF_ -#ifndef NewScratch -#define NewScratch -#endif -/* shampoo */ - #define SEQ_ADDRESS_PORT 0x0014 #define SEQ_DATA_PORT 0x0015 #define MISC_OUTPUT_REG_READ_PORT 0x001C @@ -616,16 +611,13 @@ #define Monitor1Sense 0x20 #define HiTVSense 0x40 -#ifdef NewScratch #define YPbPrSense 0x80 /* NEW SCRATCH */ -#endif #define TVSense 0xc7 #define TVOverScan 0x10 /* CR35 */ #define TVOverScanShift 4 -#ifdef NewScratch #define NTSCMode 0x00 #define PALMode 0x00 #define NTSCJMode 0x02 @@ -635,9 +627,6 @@ #define YPbPrMode525p 0x20 #define YPbPrMode750p 0x40 #define YPbPrMode1080i 0x60 -#else /* Old Scratch */ -#define ClearBufferFlag 0x20 -#endif #define LCDRGB18Bit 0x01 /* CR37 */ @@ -647,19 +636,10 @@ #define LCDSyncBit 0xe0 /* H/V polarity & sync ID */ #define LCDSyncShift 6 -#ifdef NewScratch #define ScalingLCD 0x08 -#else /* Old Scratch */ -#define ExtChipType 0x0e -#define ExtChip301 0x02 -#define ExtChipLVDS 0x04 -#define ExtChipCH7019 0x06 -#define ScalingLCD 0x10 -#endif #define EnableDualEdge 0x01 /* CR38 */ #define SetToLCDA 0x02 -#ifdef NewScratch #define SetYPbPr 0x04 #define DisableChannelA 0x08 #define DisableChannelB 0x10 @@ -667,16 +647,6 @@ #define ExtChip301 0x20 #define ExtChipLVDS 0x40 #define ExtChipCH7019 0x60 -#else /* Old Scratch */ -#define YPbPrSense 0x04 -#define SetYPbPr 0x08 -#define YPbPrMode 0x30 -#define YPbPrMode525i 0x00 -#define YPbPrMode525p 0x10 -#define YPbPrMode750p 0x20 -#define YPbPrMode1080i 0x30 -#define PALMNMode 0xc0 -#endif #define BacklightControlBit 0x01 /* CR3A */ #define Win9xforJap 0x40 @@ -694,7 +664,6 @@ #define EnableForceMDinBIOS 0x40 #define EnableForceMDinDrv 0x80 -#ifdef NewScratch /* New Scratch */ /* ---------------------- VUMA Information */ #define LCDSettingFromCMOS 0x04 /* CR3C */ #define TVSettingFromCMOS 0x08 @@ -730,52 +699,6 @@ #define StartOSDEvent 0x04 #define IgnoreHKEvent 0x08 #define IgnoreOSDEvent 0x10 -#else /* Old Scratch */ -#define OSD_SBIOS 0x02 /* SR17 */ -#define DisableLogo 0x04 -#define SelectKDOS 0x08 -#define KorWinMode 0x10 -#define KorMode3Bit 0x0020 -#define PSCCtrlBit 0x40 -#define NPSCCtrlBitShift 6 -#define BlueScreenBit 0x80 - -#define HKEvent 0x0f /* CR79 */ -#define HK_ModeSwitch 0x01 -#define HK_Expanding 0x02 -#define HK_OverScan 0x03 -#define HK_Brightness 0x04 -#define HK_Contrast 0x05 -#define HK_Mute 0x06 -#define HK_Volume 0x07 -#define ActivePAL 0x0020 -#define ActivePALShift 5 -#define ActiveNonExpanding 0x40 -#define ActiveNonExpandingShift 6 -#define ActiveOverScan 0x80 -#define ActiveOverScanShift 7 - -#define ModeSwitchStatus 0x0b /* SR15 */ -#define ActiveCRT1 0x01 -#define ActiveLCD 0x02 -#define ActiveCRT2 0x08 - -#define TVSwitchStatus 0xf0 /* SR16 */ -#define TVConfigShift 3 -#define ActiveTV 0x01 -#define ActiveYPbPr 0x04 -#define ActiveAVideo 0x10 -#define ActiveSVideo 0x0020 -#define ActiveSCART 0x40 -#define ActiveHiTV 0x80 - -#define EnableHKEvent 0x01 /* CR7A */ -#define EnableOSDEvent 0x02 -#define StartOSDEvent 0x04 -#define CMOSSupport 0x08 -#define HotKeySupport 0x10 -#define IngoreHKOSDEvent 0x20 -#endif /* //------------- Misc. Definition */ #define SelectCRT1Rate 00h From 1f8385841b74dc208dbcc1a1ac2b8d034b5e06bb Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:21 +0300 Subject: [PATCH 0206/1519] staging: xgifb: delete duplicate #defines Delete duplicate identical #defines. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 94 ------------------------------ drivers/staging/xgifb/vb_setmode.c | 3 - drivers/staging/xgifb/vb_struct.h | 1 - 3 files changed, 98 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index d7358d85202..852887164e1 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -17,13 +17,7 @@ /* ~shampoo */ -#define VB_XGI301 0x0001 /*301b*/ -#define VB_XGI301B 0x0002 -#define VB_XGI302B 0x0004 -#define VB_XGI301LV 0x0008 /*301lv*/ -#define VB_XGI302LV 0x0010 #define VB_XGI301C 0x0020 /* for 301C */ -#define VB_NoLCD 0x8000 /*end 301b*/ #define VB_YPbPrInfo 0x07 /*301lv*/ @@ -51,29 +45,8 @@ /* #define MemoryInfoFlag 0x1E0 */ /* #define MemorySizeShift 0x05 */ -#define Charx8Dot 0x0200 -#define LineCompareOff 0x0400 -#define CRT2Mode 0x0800 -#define HalfDCLK 0x1000 -#define NoSupportSimuTV 0x2000 -#define DoubleScanMode 0x8000 - -#define SupportAllCRT2 0x0078 -#define SupportTV 0x0008 -#define SupportHiVisionTV 0x0010 -#define SupportLCD 0x0020 -#define SupportRAMDAC2 0x0040 -#define NoSupportTV 0x0070 -#define NoSupportHiVisionTV 0x0060 -#define NoSupportLCD 0x0058 #define SupportCHTV 0x0800 #define SupportCRT2in301C 0x0100 /* for 301C */ -#define SupportTV1024 0x0800 /*301b*/ -#define SupportYPbPr 0x1000 /*301lv*/ -#define InterlaceMode 0x0080 -#define SyncPP 0x0000 -#define SyncPN 0x4000 -#define SyncNP 0x8000 /* #define SyncNN 0xc000 */ #define ECLKindex0 0x0000 #define ECLKindex1 0x0100 @@ -81,35 +54,16 @@ #define ECLKindex3 0x0300 #define ECLKindex4 0x0400 -#define SetSimuScanMode 0x0001 -#define SwitchToCRT2 0x0002 /* #define SetCRT2ToTV 0x009C */ -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSVIDEO 0x0008 -#define SetCRT2ToSCART 0x0010 -#define SetCRT2ToLCD 0x0020 -#define SetCRT2ToRAMDAC 0x0040 -#define SetCRT2ToHiVisionTV 0x0080 -#define SetNTSCTV 0x0000 /* #define SetPALTV 0x0100 */ -#define SetInSlaveMode 0x0200 -#define SetNotSimuMode 0x0400 #define SetNotSimuTVMode 0x0400 #define SetDispDevSwitch 0x0800 -#define LoadDACFlag 0x1000 -#define DisableCRT2Display 0x2000 -#define DriverMode 0x4000 -#define HotKeySwitch 0x8000 #define SetCHTVOverScan 0x8000 /* #define SetCRT2ToLCDA 0x8000 301b */ #define PanelRGB18Bit 0x0100 #define PanelRGB24Bit 0x0000 -#define TVOverScan 0x10 -#define TVOverScanShift 4 #define ClearBufferFlag 0x20 -#define EnableDualEdge 0x01 /*301b*/ -#define SetToLCDA 0x02 #define YPbPrModeInfo 0x38 /* #define YPbPrMode525i 0x00 */ @@ -117,8 +71,6 @@ /* #define YPbPrMode750p 0x10 */ /* #define YPbPrMode1080i 0x18 */ -#define SetSCARTOutput 0x01 -#define BoardTVType 0x02 #define EnablePALMN 0x40 /* #define ProgrammingCRT2 0x01 */ /* #define TVSimuMode 0x02 */ @@ -149,16 +101,10 @@ #define PanelRef60Hz 0x00 #define PanelRef75Hz 0x20 -#define LCDRGB18Bit 0x01 #define ExtChipTrumpion 0x06 #define ExtChipCH7005 0x08 #define ExtChipMitacTV 0x0a -#define LCDNonExpanding 0x10 -#define LCDNonExpandingShift 4 -#define LCDSync 0x20 -#define LCDSyncBit 0xe0 -#define LCDSyncShift 6 /* #define DDC2DelayTime 300 */ @@ -167,17 +113,6 @@ /* #define HiTVDataLen 12 */ /* #define TVDataLen 16 */ /* #define SetPALTV 0x0100 */ -#define HalfDCLK 0x1000 -#define NTSCHT 1716 -#define NTSCVT 525 -#define PALHT 1728 -#define PALVT 625 -#define StHiTVHT 892 -#define StHiTVVT 1126 -#define StHiTextTVHT 1000 -#define StHiTextTVVT 1126 -#define ExtHiTVHT 2100 -#define ExtHiTVVT 1125 #define St750pTVHT 1716 #define St750pTVVT 525 @@ -194,33 +129,15 @@ #define VCLKStartFreq 25 #define SoftDramType 0x80 -#define VCLK40 0x04 -#define VCLK162 0x21 - -#define LCDRGB18Bit 0x01 -#define LoadDACFlag 0x1000 #define AfterLockCRT2 0x4000 -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSCART 0x0010 #define Ext2StructSize 5 #define YPbPr525iVCLK 0x03B #define YPbPr525iVCLK_2 0x03A -#define SwitchToCRT2 0x0002 /* #define LCDVESATiming 0x08 */ -#define SetSCARTOutput 0x01 -#define AVIDEOSense 0x01 -#define SVIDEOSense 0x02 -#define SCARTSense 0x04 -#define LCDSense 0x08 -#define Monitor1Sense 0x20 -#define Monitor2Sense 0x10 -#define HiTVSense 0x40 -#define BoardTVType 0x02 -#define HotPlugFunction 0x08 #define StStructSize 0x06 @@ -231,7 +148,6 @@ #define XGI_CRT2_PORT_14 (0x14 - 0x30) -#define LCDNonExpanding 0x10 #define ADR_CRT2PtrData 0x20E #define offset_Zurac 0x210 #define ADR_LVDSDesPtrData 0x212 @@ -239,7 +155,6 @@ #define ADR_CHTVVCLKPtr 0x216 #define ADR_CHTVRegDataPtr 0x218 -#define LVDSDataLen 6 /* #define EnableLVDSDDA 0x10 */ /* #define LVDSDesDataLen 3 */ #define ActiveNonExpanding 0x40 @@ -315,19 +230,10 @@ /* #define LCDVESATiming 0x0001 //LCD Info CR37 */ /* #define EnableLVDSDDA 0x0002 */ -#define EnableScalingLCD 0x0008 -#define SetPWDEnable 0x0004 -#define SetLCDtoNonExpanding 0x0010 /* #define SetLCDPolarity 0x00E0 */ -#define SetLCDDualLink 0x0100 -#define SetLCDLowResolution 0x0200 -#define SetLCDStdMode 0x0400 -#define SetTVStdMode 0x0200 -#define SetTVLowResolution 0x0400 /* ============================================================= for 310 ============================================================== */ -#define SoftDRAMType 0x80 #define SoftSetting_OFFSET 0x52 #define SR07_OFFSET 0x7C #define SR15_OFFSET 0x7D diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index dc4d6e6fc9b..845e036bd78 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -14,9 +14,6 @@ #define IndexMask 0xff -#ifndef XGI_MASK_DUAL_CHIP -#define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */ -#endif static unsigned short XGINew_MDA_DAC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 377d27c0c33..de02913cab6 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -478,5 +478,4 @@ struct TimingInfo { unsigned short Margin; }; -#define _VB_STRUCT_ #endif /* _VB_STRUCT_ */ From fa4c212f2b81ef7ffab94a6416675c6ab9dabb81 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:22 +0300 Subject: [PATCH 0207/1519] staging: xgifb: delete unused definitions Delete some more unused definitions. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 93 ------- drivers/staging/xgifb/XGI_main_26.c | 2 - drivers/staging/xgifb/XGIfb.h | 12 - drivers/staging/xgifb/vb_def.h | 417 ---------------------------- drivers/staging/xgifb/vb_struct.h | 6 - 5 files changed, 530 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 543ef2c363e..44b7adc672c 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -15,8 +15,6 @@ #define VER_MINOR 8 #define VER_LEVEL 1 -#define DRIVER_DESC "XGI Volari Frame Buffer Module Version 0.8.1" - #ifndef PCI_VENDOR_ID_XG #define PCI_VENDOR_ID_XG 0x18CA #endif @@ -37,11 +35,6 @@ #define PCI_DEVICE_ID_XG_27 0x027 #endif - - -#define XGI_IOTYPE1 void __iomem -#define XGI_IOTYPE2 __iomem - static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = { {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -57,31 +50,11 @@ static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = { MODULE_DEVICE_TABLE(pci, xgifb_pci_table); /* To be included in fb.h */ -#ifndef FB_ACCEL_XGI_GLAMOUR_2 -#define FB_ACCEL_XGI_GLAMOUR_2 40 /* XGI 315, 650, 740 */ -#endif #ifndef FB_ACCEL_XGI_XABRE #define FB_ACCEL_XGI_XABRE 41 /* XGI 330 ("Xabre") */ #endif -#define MAX_ROM_SCAN 0x10000 - -#define SEQ_ADR 0x14 #define SEQ_DATA 0x15 -#define DAC_ADR 0x18 -#define DAC_DATA 0x19 -#define CRTC_ADR 0x24 -#define CRTC_DATA 0x25 -#define DAC2_ADR (0x16-0x30) -#define DAC2_DATA (0x17-0x30) -#define VB_PART1_ADR (0x04-0x30) -#define VB_PART1_DATA (0x05-0x30) -#define VB_PART2_ADR (0x10-0x30) -#define VB_PART2_DATA (0x11-0x30) -#define VB_PART3_ADR (0x12-0x30) -#define VB_PART3_DATA (0x13-0x30) -#define VB_PART4_ADR (0x14-0x30) -#define VB_PART4_DATA (0x15-0x30) #define XGISR XGI_Pr.P3c4 #define XGICR XGI_Pr.P3d4 @@ -94,24 +67,12 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); #define XGIPART5 XGI_Pr.Part5Port #define XGIDAC2A XGIPART5 #define XGIDAC2D (XGIPART5 + 1) -#define XGIMISCR (XGI_Pr.RelIO + 0x1c) -#define XGIINPSTAT (XGI_Pr.RelIO + 0x2a) #define IND_XGI_PASSWORD 0x05 /* SRs */ -#define IND_XGI_COLOR_MODE 0x06 #define IND_XGI_RAMDAC_CONTROL 0x07 #define IND_XGI_DRAM_SIZE 0x14 -#define IND_XGI_SCRATCH_REG_16 0x16 -#define IND_XGI_SCRATCH_REG_17 0x17 -#define IND_XGI_SCRATCH_REG_1A 0x1A #define IND_XGI_MODULE_ENABLE 0x1E #define IND_XGI_PCI_ADDRESS_SET 0x20 -#define IND_XGI_TURBOQUEUE_ADR 0x26 -#define IND_XGI_TURBOQUEUE_SET 0x27 -#define IND_XGI_POWER_ON_TRAP 0x38 -#define IND_XGI_POWER_ON_TRAP2 0x39 -#define IND_XGI_CMDQUEUE_SET 0x26 -#define IND_XGI_CMDQUEUE_THRESHOLD 0x27 #define IND_XGI_SCRATCH_REG_CR30 0x30 /* CRs */ #define IND_XGI_SCRATCH_REG_CR31 0x31 @@ -119,23 +80,10 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); #define IND_XGI_SCRATCH_REG_CR33 0x33 #define IND_XGI_LCD_PANEL 0x36 #define IND_XGI_SCRATCH_REG_CR37 0x37 -#define IND_XGI_AGP_IO_PAD 0x48 -#define IND_BRI_DRAM_STATUS 0x63 /* PCI config memory size offset */ - -#define MMIO_QUEUE_PHYBASE 0x85C0 -#define MMIO_QUEUE_WRITEPORT 0x85C4 -#define MMIO_QUEUE_READPORT 0x85C8 - -#define IND_XGI_CRT2_WRITE_ENABLE_300 0x24 #define IND_XGI_CRT2_WRITE_ENABLE_315 0x2F #define XGI_PASSWORD 0x86 /* SR05 */ -#define XGI_INTERLACED_MODE 0x20 /* SR06 */ -#define XGI_8BPP_COLOR_MODE 0x0 -#define XGI_15BPP_COLOR_MODE 0x1 -#define XGI_16BPP_COLOR_MODE 0x2 -#define XGI_32BPP_COLOR_MODE 0x4 #define XGI_DRAM_SIZE_MASK 0xF0 /*SR14 */ #define XGI_DRAM_SIZE_1MB 0x00 @@ -147,27 +95,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); #define XGI_DRAM_SIZE_64MB 0x06 #define XGI_DRAM_SIZE_128MB 0x07 #define XGI_DRAM_SIZE_256MB 0x08 -#define XGI_DATA_BUS_MASK 0x02 -#define XGI_DATA_BUS_64 0x00 -#define XGI_DATA_BUS_128 0x01 -#define XGI_DUAL_CHANNEL_MASK 0x0C -#define XGI_SINGLE_CHANNEL_1_RANK 0x0 -#define XGI_SINGLE_CHANNEL_2_RANK 0x1 -#define XGI_ASYM_DDR 0x02 -#define XGI_DUAL_CHANNEL_1_RANK 0x3 - -#define XGI550_DRAM_SIZE_MASK 0x3F /* 550/650/740 SR14 */ -#define XGI550_DRAM_SIZE_4MB 0x00 -#define XGI550_DRAM_SIZE_8MB 0x01 -#define XGI550_DRAM_SIZE_16MB 0x03 -#define XGI550_DRAM_SIZE_24MB 0x05 -#define XGI550_DRAM_SIZE_32MB 0x07 -#define XGI550_DRAM_SIZE_64MB 0x0F -#define XGI550_DRAM_SIZE_96MB 0x17 -#define XGI550_DRAM_SIZE_128MB 0x1F -#define XGI550_DRAM_SIZE_256MB 0x3F - -#define XGI_SCRATCH_REG_1A_MASK 0x10 #define XGI_ENABLE_2D 0x40 /* SR1E */ @@ -175,7 +102,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); #define XGI_PCI_ADDR_ENABLE 0x80 #define XGI_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */ -#define XGI_MODE_SELECT_CRT2 0x02 #define XGI_VB_OUTPUT_COMPOSITE 0x04 #define XGI_VB_OUTPUT_SVIDEO 0x08 #define XGI_VB_OUTPUT_SCART 0x10 @@ -198,27 +124,9 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR) #define XGI_EXTERNAL_CHIP_MASK 0x0E /* CR37 */ -#define XGI_EXTERNAL_CHIP_XGI301 0x01 /* in CR37 << 1 ! */ -#define XGI_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */ -#define XGI_EXTERNAL_CHIP_TRUMPION 0x03 /* in CR37 << 1 ! */ -#define XGI_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04 /* in CR37 << 1 ! */ -#define XGI_EXTERNAL_CHIP_CHRONTEL 0x05 /* in CR37 << 1 ! */ #define XGI310_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */ #define XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03 /* in CR37 << 1 ! */ -#define XGI_AGP_2X 0x20 /* CR48 */ - -#define BRI_DRAM_SIZE_MASK 0x70 /* PCI bridge config data */ -#define BRI_DRAM_SIZE_2MB 0x00 -#define BRI_DRAM_SIZE_4MB 0x01 -#define BRI_DRAM_SIZE_8MB 0x02 -#define BRI_DRAM_SIZE_16MB 0x03 -#define BRI_DRAM_SIZE_32MB 0x04 -#define BRI_DRAM_SIZE_64MB 0x05 - -#define SR_BUFFER_SIZE 5 -#define CR_BUFFER_SIZE 5 - /* ------------------- Global Variables ----------------------------- */ /* Fbcon variables */ @@ -423,7 +331,6 @@ static struct _XGIbios_mode { MD_XGI315}, {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315}, -#define MODEINDEX_1280x960 48 {"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_XGI300|MD_XGI315}, /* TW: Modenumbers being patched */ {"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index df27dfed756..d71ea61cbf4 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -45,11 +45,9 @@ #include "vb_setmode.h" #define Index_CR_GPIO_Reg1 0x48 -#define Index_CR_GPIO_Reg2 0x49 #define Index_CR_GPIO_Reg3 0x4a #define GPIOG_EN (1<<6) -#define GPIOG_WRITE (1<<6) #define GPIOG_READ (1<<1) #define XGIFB_ROM_SIZE 65536 diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 45b6015d160..5d81cb69e63 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -7,11 +7,9 @@ #define DISPTYPE_CRT2 0x00000004L #define DISPTYPE_LCD 0x00000002L #define DISPTYPE_TV 0x00000001L -#define DISPTYPE_DISP1 DISPTYPE_CRT1 #define DISPTYPE_DISP2 (DISPTYPE_CRT2 | DISPTYPE_LCD | DISPTYPE_TV) #define DISPMODE_SINGLE 0x00000020L #define DISPMODE_MIRROR 0x00000010L -#define DISPMODE_DUALVIEW 0x00000040L #define HASVB_NONE 0x00 #define HASVB_301 0x01 @@ -19,13 +17,8 @@ #define HASVB_TRUMPION 0x04 #define HASVB_LVDS_CHRONTEL 0x10 #define HASVB_302 0x20 -#define HASVB_303 0x40 #define HASVB_CHRONTEL 0x80 -#ifndef XGIFB_ID -#define XGIFB_ID 0x53495346 /* Identify myself with 'XGIF' */ -#endif - enum XGI_CHIP_TYPE { XG40 = 32, XG41, @@ -47,11 +40,6 @@ enum xgi_tvtype { }; enum xgi_tv_plug { /* vicki@030226 */ -/* TVPLUG_Legacy = 0, */ -/* TVPLUG_COMPOSITE, */ -/* TVPLUG_SVIDEO, */ -/* TVPLUG_SCART, */ -/* TVPLUG_TOTAL */ TVPLUG_UNKNOWN = 0, TVPLUG_COMPOSITE = 1, TVPLUG_SVIDEO = 2, diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 852887164e1..06846868e9f 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -3,171 +3,48 @@ #ifndef _INITDEF_ #define _INITDEF_ -#define SEQ_ADDRESS_PORT 0x0014 -#define SEQ_DATA_PORT 0x0015 -#define MISC_OUTPUT_REG_READ_PORT 0x001C -#define MISC_OUTPUT_REG_WRITE_PORT 0x0012 -#define GRAPH_DATA_PORT 0x1F -#define GRAPH_ADDRESS_PORT 0x1E -#define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */ -#define CRTC_ADDRESS_PORT_COLOR 0x0024 -#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013 -#define PCI_COMMAND 0x04 - -/* ~shampoo */ - - #define VB_XGI301C 0x0020 /* for 301C */ /*end 301b*/ -#define VB_YPbPrInfo 0x07 /*301lv*/ -#define VB_YPbPr525i 0x00 #define VB_YPbPr525p 0x01 #define VB_YPbPr750p 0x02 #define VB_YPbPr1080i 0x03 -/* #define CRT1Len 17 */ #define LVDSCRT1Len 15 -#define CHTVRegDataLen 5 - -/* #define ModeInfoFlag 0x07 */ -/* #define IsTextMode 0x07 */ -/* #define ModeText 0x00 */ -/* #define ModeCGA 0x01 */ -/* #define ModeEGA 0x02 */ -/* #define ModeVGA 0x03 */ -/* #define Mode15Bpp 0x04 */ -/* #define Mode16Bpp 0x05 */ -/* #define Mode24Bpp 0x06 */ -/* #define Mode32Bpp 0x07 */ - -/* #define DACInfoFlag 0x18 */ -/* #define MemoryInfoFlag 0x1E0 */ -/* #define MemorySizeShift 0x05 */ #define SupportCHTV 0x0800 #define SupportCRT2in301C 0x0100 /* for 301C */ -/* #define SyncNN 0xc000 */ -#define ECLKindex0 0x0000 -#define ECLKindex1 0x0100 -#define ECLKindex2 0x0200 -#define ECLKindex3 0x0300 -#define ECLKindex4 0x0400 - -/* #define SetCRT2ToTV 0x009C */ -/* #define SetPALTV 0x0100 */ -#define SetNotSimuTVMode 0x0400 -#define SetDispDevSwitch 0x0800 #define SetCHTVOverScan 0x8000 -/* #define SetCRT2ToLCDA 0x8000 301b */ #define PanelRGB18Bit 0x0100 #define PanelRGB24Bit 0x0000 -#define ClearBufferFlag 0x20 - -#define YPbPrModeInfo 0x38 -/* #define YPbPrMode525i 0x00 */ -/* #define YPbPrMode525p 0x08 */ -/* #define YPbPrMode750p 0x10 */ -/* #define YPbPrMode1080i 0x18 */ - -#define EnablePALMN 0x40 -/* #define ProgrammingCRT2 0x01 */ -/* #define TVSimuMode 0x02 */ -/* #define RPLLDIV2XO 0x04 */ -/* #define LCDVESATiming 0x08 */ -/* #define EnableLVDSDDA 0x10 */ -#define SetDispDevSwitchFlag 0x20 -#define CheckWinDos 0x40 -#define SetJDOSMode 0x80 - #define Panel320x480 0x07 /*fstn*/ /* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */ #define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */ -#define PanelRefInfo 0x60 #define Panel800x600 0x01 #define Panel1024x768 0x02 #define Panel1024x768x75 0x22 #define Panel1280x1024 0x03 #define Panel1280x1024x75 0x23 #define Panel640x480 0x04 -#define Panel1024x600 0x05 -#define Panel1152x864 0x06 #define Panel1280x960 0x07 -#define Panel1152x768 0x08 #define Panel1400x1050 0x09 -#define Panel1280x768 0x0A #define Panel1600x1200 0x0B #define PanelRef60Hz 0x00 #define PanelRef75Hz 0x20 -#define ExtChipTrumpion 0x06 -#define ExtChipCH7005 0x08 -#define ExtChipMitacTV 0x0a - -/* #define DDC2DelayTime 300 */ - #define CRT2DisplayFlag 0x2000 -/* #define LCDDataLen 8 */ -/* #define HiTVDataLen 12 */ -/* #define TVDataLen 16 */ -/* #define SetPALTV 0x0100 */ - -#define St750pTVHT 1716 -#define St750pTVVT 525 -#define Ext750pTVHT 1716 -#define Ext750pTVVT 525 -#define St525pTVHT 1716 -#define St525pTVVT 525 -#define Ext525pTVHT 1716 -#define Ext525pTVVT 525 -#define St525iTVHT 1716 -#define St525iTVVT 525 -#define Ext525iTVHT 1716 -#define Ext525iTVVT 525 - -#define VCLKStartFreq 25 -#define SoftDramType 0x80 - -#define AfterLockCRT2 0x4000 -#define Ext2StructSize 5 - #define YPbPr525iVCLK 0x03B #define YPbPr525iVCLK_2 0x03A -/* #define LCDVESATiming 0x08 */ -#define StStructSize 0x06 - - #define XGI_CRT2_PORT_00 (0x00 - 0x030) #define XGI_CRT2_PORT_04 (0x04 - 0x030) #define XGI_CRT2_PORT_10 (0x10 - 0x30) #define XGI_CRT2_PORT_12 (0x12 - 0x30) #define XGI_CRT2_PORT_14 (0x14 - 0x30) - -#define ADR_CRT2PtrData 0x20E -#define offset_Zurac 0x210 -#define ADR_LVDSDesPtrData 0x212 -#define ADR_LVDSCRT1DataPtr 0x214 -#define ADR_CHTVVCLKPtr 0x216 -#define ADR_CHTVRegDataPtr 0x218 - -/* #define EnableLVDSDDA 0x10 */ -/* #define LVDSDesDataLen 3 */ -#define ActiveNonExpanding 0x40 -#define ActiveNonExpandingShift 6 -/* #define ActivePAL 0x20 */ -#define ActivePALShift 5 -/* #define ModeSwitchStatus 0x0F */ -#define SoftTVType 0x40 -#define SoftSettingAddr 0x52 -#define ModeSettingAddr 0x53 - -/* #define SelectCRT1Rate 0x4 */ - #define _PanelType00 0x00 #define _PanelType01 0x08 #define _PanelType02 0x10 @@ -185,164 +62,26 @@ #define _PanelType0E 0x70 #define _PanelType0F 0x78 -/* 1: XGI is primary vga 0:XGI is secondary vga */ -#define PRIMARY_VGA 0 -#define BIOSIDCodeAddr 0x235 -#define OEMUtilIDCodeAddr 0x237 -#define VBModeIDTableAddr 0x239 -#define OEMTVPtrAddr 0x241 -#define PhaseTableAddr 0x243 -#define NTSCFilterTableAddr 0x245 -#define PALFilterTableAddr 0x247 -#define OEMLCDPtr_1Addr 0x249 -#define OEMLCDPtr_2Addr 0x24B -#define LCDHPosTable_1Addr 0x24D -#define LCDHPosTable_2Addr 0x24F -#define LCDVPosTable_1Addr 0x251 -#define LCDVPosTable_2Addr 0x253 -#define OEMLCDPIDTableAddr 0x255 - -#define VBModeStructSize 5 -#define PhaseTableSize 4 -#define FilterTableSize 4 -#define LCDHPosTableSize 7 -#define LCDVPosTableSize 5 -#define OEMLVDSPIDTableSize 4 -#define LVDSHPosTableSize 4 -#define LVDSVPosTableSize 6 - -#define VB_ModeID 0 -#define VB_TVTableIndex 1 -#define VB_LCDTableIndex 2 -#define VB_LCDHIndex 3 -#define VB_LCDVIndex 4 - -#define OEMLCDEnable 0x0001 -#define OEMLCDDelayEnable 0x0002 -#define OEMLCDPOSEnable 0x0004 -#define OEMTVEnable 0x0100 -#define OEMTVDelayEnable 0x0200 -#define OEMTVFlickerEnable 0x0400 -#define OEMTVPhaseEnable 0x0800 -#define OEMTVFilterEnable 0x1000 - -#define OEMLCDPanelIDSupport 0x0080 - -/* #define LCDVESATiming 0x0001 //LCD Info CR37 */ -/* #define EnableLVDSDDA 0x0002 */ -/* #define SetLCDPolarity 0x00E0 */ /* ============================================================= for 310 ============================================================== */ -#define SoftSetting_OFFSET 0x52 -#define SR07_OFFSET 0x7C -#define SR15_OFFSET 0x7D -#define SR16_OFFSET 0x81 -#define SR17_OFFSET 0x85 -#define SR19_OFFSET 0x8D -#define SR1F_OFFSET 0x99 -#define SR21_OFFSET 0x9A -#define SR22_OFFSET 0x9B -#define SR23_OFFSET 0x9C -#define SR24_OFFSET 0x9D -#define SR25_OFFSET 0x9E -#define SR31_OFFSET 0x9F -#define SR32_OFFSET 0xA0 -#define SR33_OFFSET 0xA1 - -#define CR40_OFFSET 0xA2 -#define SR25_1_OFFSET 0xF6 -#define CR49_OFFSET 0xF7 - -#define VB310Data_1_2_Offset 0xB6 -#define VB310Data_4_D_Offset 0xB7 -#define VB310Data_4_E_Offset 0xB8 -#define VB310Data_4_10_Offset 0xBB - -#define RGBSenseDataOffset 0xBD -#define YCSenseDataOffset 0xBF -#define VideoSenseDataOffset 0xC1 -#define OutputSelectOffset 0xF3 - -#define ECLK_MCLK_DISTANCE 0x14 -#define VBIOSTablePointerStart 0x200 -#define StandTablePtrOffset (VBIOSTablePointerStart+0x02) -#define EModeIDTablePtrOffset (VBIOSTablePointerStart+0x04) -#define CRT1TablePtrOffset (VBIOSTablePointerStart+0x06) -#define ScreenOffsetPtrOffset (VBIOSTablePointerStart+0x08) -#define VCLKDataPtrOffset (VBIOSTablePointerStart+0x0A) -#define MCLKDataPtrOffset (VBIOSTablePointerStart+0x0E) -#define CRT2PtrDataPtrOffset (VBIOSTablePointerStart+0x10) -#define TVAntiFlickPtrOffset (VBIOSTablePointerStart+0x12) -#define TVDelayPtr1Offset (VBIOSTablePointerStart+0x14) -#define TVPhaseIncrPtr1Offset (VBIOSTablePointerStart+0x16) -#define TVYFilterPtr1Offset (VBIOSTablePointerStart+0x18) -#define LCDDelayPtr1Offset (VBIOSTablePointerStart+0x20) -#define TVEdgePtr1Offset (VBIOSTablePointerStart+0x24) -#define CRT2Delay1Offset (VBIOSTablePointerStart+0x28) -#define LCDDataDesOffset (VBIOSTablePointerStart-0x02) -#define LCDDataPtrOffset (VBIOSTablePointerStart+0x2A) -#define LCDDesDataPtrOffset (VBIOSTablePointerStart+0x2C) /* add LCDDataList for GetLCDPtr */ #define LCDDataList (VBIOSTablePointerStart+0x22) -/* add TVDataList for GetTVPtr */ -#define TVDataList (VBIOSTablePointerStart+0x36) /* */ /* Modify from 310.inc */ /* */ /* */ - -#define ShowMsgFlag 0x20 /* SoftSetting */ -#define ShowVESAFlag 0x10 -#define HotPlugFunction 0x08 #define ModeSoftSetting 0x04 -#define TVSoftSetting 0x02 -#define LCDSoftSetting 0x01 -#define GatingCRTinLCDA 0x10 -#define SetHiTVOutput 0x08 -#define SetYPbPrOutput 0x04 #define BoardTVType 0x02 -#define SetSCARTOutput 0x01 - -/* TVModeSetting, Others as same as CR30 */ -#define ModeSettingYPbPr 0x02 - -/* TVModeSetting same as CR35 */ - -/* LCDModeSetting same as CR37 */ - -#define EnableNewTVFont 0x10 /* MiscCapability */ - -#define EnableLCDOutput 0x80 /* LCDCfgSetting */ #define SoftDRAMType 0x80 /* DRAMSetting */ -#define SoftDRAMConfig 0x40 -#define MosSelDRAMType 0x20 -#define SDRAM 000h -#define SGRAM 0x01 -#define ESDRAM 0x02 - -#define EnableAGPCfgSetting 0x01 /* AGPCfgSetting */ /* ---------------- SetMode Stack */ #define CRT1Len 15 #define VCLKLen 4 -#define DefThreshold 0x0100 -#define ExtRegsSize ((57+8+37+70+63+28+768+1)/64+1) - -#define VGA_XGI315 0x0001 /* VGA Type Info */ -#define VGA_SNewis315e 0x0002 /* 315 series */ -#define VGA_XGI550 0x0004 -#define VGA_XGI640 0x0008 -#define VGA_XGI740 0x0010 -#define VGA_XGI650 0x0020 -#define VGA_XGI650M 0x0040 -#define VGA_XGI651 0x0080 #define VGA_XGI340 0x0001 /* 340 series */ -#define VGA_XGI330 0x0001 /* 330 series */ -#define VGA_XGI660 0x0001 /* 660 series */ #define VB_XGI301 0x0001 /* VB Type Info */ #define VB_XGI301B 0x0002 /* 301 series */ @@ -353,32 +92,16 @@ #define VB_LVDS_NS 0x0001 /* 3rd party chip */ #define VB_CH7017 0x0002 #define VB_CH7007 0x0080 /* [Billy] 07/05/03 */ -/* #define VB_LVDS_SI 0x0004 */ #define ModeInfoFlag 0x0007 -#define IsTextMode 0x0007 #define ModeText 0x0000 -#define ModeCGA 0x0001 #define ModeEGA 0x0002 /* 16 colors mode */ #define ModeVGA 0x0003 /* 256 colors mode */ -#define Mode15Bpp 0x0004 /* 15 Bpp Color Mode */ -#define Mode16Bpp 0x0005 /* 16 Bpp Color Mode */ -#define Mode24Bpp 0x0006 /* 24 Bpp Color Mode */ -#define Mode32Bpp 0x0007 /* 32 Bpp Color Mode */ #define DACInfoFlag 0x0018 -#define MONODAC 0x0000 -#define CGADAC 0x0008 -#define EGADAC 0x0010 -#define VGADAC 0x0018 #define MemoryInfoFlag 0x01e0 #define MemorySizeShift 5 -#define Need1MSize 0x0000 -#define Need2MSize 0x0020 -#define Need4MSize 0x0060 -#define Need8MSize 0x00e0 -#define Need16MSize 0x01e0 #define Charx8Dot 0x0200 #define LineCompareOff 0x0400 @@ -388,11 +111,7 @@ #define DoubleScanMode 0x8000 /* -------------- Ext_InfoFlag */ -#define SupportModeInfo 0x0007 -#define Support256 0x0003 -#define Support15Bpp 0x0004 #define Support16Bpp 0x0005 -#define Support24Bpp 0x0006 #define Support32Bpp 0x0007 #define SupportAllCRT2 0x0078 @@ -414,7 +133,6 @@ /* -------------- SetMode Stack/Scratch */ #define SetSimuScanMode 0x0001 /* VBInfo/CR30 & CR31 */ #define SwitchToCRT2 0x0002 -#define SetCRT2ToTV1 0x009C #define SetCRT2ToTV 0x089C #define SetCRT2ToAVIDEO 0x0004 #define SetCRT2ToSVIDEO 0x0008 @@ -425,23 +143,16 @@ #define SetCRT2ToLCDA 0x0100 #define SetInSlaveMode 0x0200 #define SetNotSimuMode 0x0400 -#define HKEventMode 0x0800 #define SetCRT2ToYPbPr 0x0800 #define LoadDACFlag 0x1000 #define DisableCRT2Display 0x2000 #define DriverMode 0x4000 #define SetCRT2ToDualEdge 0x8000 -#define HotKeySwitch 0x8000 #define ProgrammingCRT2 0x0001 /* Set Flag */ #define EnableVCMode 0x0002 -#define SetHKEventMode 0x0004 #define ReserveTVOption 0x0008 -#define DisableRelocateIO 0x0010 #define Win9xDOSMode 0x0020 -#define JDOSMode 0x0040 -/* #define SetWin9xforJap 0x0080 // not used now */ -/* #define SetWin9xforKorea 0x0100 // not used now */ #define GatingCRT 0x0800 #define DisableChB 0x1000 #define EnableChB 0x2000 @@ -453,15 +164,11 @@ #define SetNTSCJ 0x0002 #define SetPALMTV 0x0004 #define SetPALNTV 0x0008 -#define SetCHTVUnderScan 0x0000 -/* #define SetCHTVOverScan 0x0010 */ #define SetYPbPrMode525i 0x0020 #define SetYPbPrMode525p 0x0040 #define SetYPbPrMode750p 0x0080 #define SetYPbPrMode1080i 0x0100 -#define SetTVStdMode 0x0200 #define SetTVLowResolution 0x0400 -#define SetTVSimuMode 0x0800 #define TVSimuMode 0x0800 #define RPLLDIV2XO 0x1000 #define NTSC1024x768 0x2000 @@ -472,38 +179,20 @@ #define EnableScalingLCD 0x0008 #define SetPWDEnable 0x0004 #define SetLCDtoNonExpanding 0x0010 -#define SetLCDPolarity 0x00e0 #define SetLCDDualLink 0x0100 #define SetLCDLowResolution 0x0200 #define SetLCDStdMode 0x0400 /* LCD Capability shampoo */ #define DefaultLCDCap 0x80ea -#define RLVDSDHL00 0x0000 -#define RLVDSDHL01 0x0001 -#define RLVDSDHL10 0x0002 /* default */ -#define RLVDSDHL11 0x0003 #define EnableLCD24bpp 0x0004 /* default */ #define DisableLCD24bpp 0x0000 -#define RLVDSClkSFT0 0x0000 -#define RLVDSClkSFT1 0x0008 /* default */ -#define EnableLVDSDCBal 0x0010 -#define DisableLVDSDCBal 0x0000 /* default */ -#define SinglePolarity 0x0020 /* default */ -#define MultiPolarity 0x0000 #define LCDPolarity 0x00c0 /* default: SyncNN */ -#define LCDSingleLink 0x0000 /* default */ #define LCDDualLink 0x0100 #define EnableSpectrum 0x0200 -#define DisableSpectrum 0x0000 /* default */ #define PWDEnable 0x0400 -#define PWDDisable 0x0000 /* default */ -#define PWMEnable 0x0800 -#define PWMDisable 0x0000 /* default */ #define EnableVBCLKDRVLOW 0x4000 -#define EnableVBCLKDRVHigh 0x0000 /* default */ #define EnablePLLSPLOW 0x8000 -#define EnablePLLSPHigh 0x0000 /* default */ #define LCDBToA 0x20 /* LCD SetFlag */ #define StLCDBToA 0x40 @@ -522,12 +211,7 @@ #define TVSense 0xc7 #define TVOverScan 0x10 /* CR35 */ -#define TVOverScanShift 4 -#define NTSCMode 0x00 -#define PALMode 0x00 -#define NTSCJMode 0x02 -#define PALMNMode 0x0c #define YPbPrMode 0xe0 #define YPbPrMode525i 0x00 #define YPbPrMode525p 0x20 @@ -537,95 +221,36 @@ #define LCDRGB18Bit 0x01 /* CR37 */ #define LCDNonExpanding 0x10 -#define LCDNonExpandingShift 4 #define LCDSync 0x20 #define LCDSyncBit 0xe0 /* H/V polarity & sync ID */ -#define LCDSyncShift 6 #define ScalingLCD 0x08 #define EnableDualEdge 0x01 /* CR38 */ #define SetToLCDA 0x02 #define SetYPbPr 0x04 -#define DisableChannelA 0x08 -#define DisableChannelB 0x10 -#define ExtChipType 0xe0 -#define ExtChip301 0x20 -#define ExtChipLVDS 0x40 -#define ExtChipCH7019 0x60 - -#define BacklightControlBit 0x01 /* CR3A */ -#define Win9xforJap 0x40 -#define Win9xforKorea 0x80 - -#define ForceMDBits 0x07 /* CR3B */ -#define ForceMD_JDOS 0x00 -#define ForceMD_640x400T 0x01 -#define ForceMD_640x350T 0x02 -#define ForceMD_720x400T 0x03 -#define ForceMD_640x480E 0x04 -#define ForceMD_640x400E 0x05 -#define ForceP1Bit 0x10 -#define ForceP2Bit 0x20 -#define EnableForceMDinBIOS 0x40 -#define EnableForceMDinDrv 0x80 /* ---------------------- VUMA Information */ -#define LCDSettingFromCMOS 0x04 /* CR3C */ -#define TVSettingFromCMOS 0x08 #define DisplayDeviceFromCMOS 0x10 -#define HKSupportInSBIOS 0x20 -#define OSDSupportInSBIOS 0x40 -#define DisableLogo 0x80 /* ---------------------- HK Evnet Definition */ -#define HKEvent 0x0f /* CR3D */ -#define HK_ModeSwitch 0x01 -#define HK_Expanding 0x02 -#define HK_OverScan 0x03 -#define HK_Brightness 0x04 -#define HK_Contrast 0x05 -#define HK_Mute 0x06 -#define HK_Volume 0x07 #define ModeSwitchStatus 0xf0 #define ActiveCRT1 0x10 #define ActiveLCD 0x0020 #define ActiveTV 0x40 #define ActiveCRT2 0x80 -#define TVSwitchStatus 0x1f /* CR3E */ #define ActiveAVideo 0x01 #define ActiveSVideo 0x02 #define ActiveSCART 0x04 #define ActiveHiTV 0x08 #define ActiveYPbPr 0x10 -#define EnableHKEvent 0x01 /* CR3F */ -#define EnableOSDEvent 0x02 -#define StartOSDEvent 0x04 -#define IgnoreHKEvent 0x08 -#define IgnoreOSDEvent 0x10 - -/* //------------- Misc. Definition */ -#define SelectCRT1Rate 00h -/* #define SelectCRT2Rate 04h */ - -#define DDC1DelayTime 1000 -#ifdef TRUMPION -#define DDC2DelayTime 15 -#else -#define DDC2DelayTime 150 -#endif - -#define R_FACTOR 04Dh -#define G_FACTOR 097h -#define B_FACTOR 01Ch /* --------------------------------------------------------- */ /* translated from asm code 301def.h */ /* */ /* --------------------------------------------------------- */ #define LCDDataLen 8 -#define HiTVDataLen 12 #define TVDataLen 12 #define LVDSCRT1Len_H 8 #define LVDSCRT1Len_V 7 @@ -635,7 +260,6 @@ #define LVDSDesDataLen2 8 #define LCDDesDataLen2 8 #define CHTVRegLen 16 -#define CHLVRegLen 12 #define StHiTVHT 892 #define StHiTVVT 1126 @@ -646,7 +270,6 @@ #define NTSCHT 1716 #define NTSCVT 525 #define NTSC1024x768HT 1908 -#define NTSC1024x768VT 525 #define PALHT 1728 #define PALVT 625 @@ -657,8 +280,6 @@ #define YPbPrTV750pHT 1650 #define YPbPrTV750pVT 750 -#define CRT2VCLKSel 0xc0 - #define CRT2Delay1 0x04 /* XGI301 */ #define CRT2Delay2 0x0A /* 301B,302 */ @@ -675,57 +296,41 @@ #define VCLK52_406 0x09 #define VCLK56_25 0x0A #define VCLK65 0x0B -#define VCLK67_765 0x0C #define VCLK68_179 0x0D #define VCLK72_852 0x0E #define VCLK75 0x0F -#define VCLK75_8 0x10 #define VCLK78_75 0x11 #define VCLK79_411 0x12 #define VCLK83_95 0x13 -#define VCLK84_8 0x14 #define VCLK86_6 0x15 #define VCLK94_5 0x16 -#define VCLK104_998 0x17 -#define VCLK105_882 0x18 #define VCLK108_2 0x19 -#define VCLK109_175 0x1A #define VCLK113_309 0x1B #define VCLK116_406 0x1C -#define VCLK132_258 0x1D #define VCLK135_5 0x1E #define VCLK139_054 0x1F #define VCLK157_5 0x20 #define VCLK162 0x21 #define VCLK175 0x22 #define VCLK189 0x23 -#define VCLK194_4 0x24 #define VCLK202_5 0x25 #define VCLK229_5 0x26 #define VCLK234 0x27 -#define VCLK252_699 0x28 #define VCLK254_817 0x29 -#define VCLK265_728 0x2A #define VCLK266_952 0x2B #define VCLK269_655 0x2C -#define VCLK272_042 0x2D #define VCLK277_015 0x2E -#define VCLK286_359 0x2F #define VCLK291_132 0x30 #define VCLK291_766 0x31 -#define VCLK309_789 0x32 #define VCLK315_195 0x33 #define VCLK323_586 0x34 #define VCLK330_615 0x35 -#define VCLK332_177 0x36 #define VCLK340_477 0x37 #define VCLK375_847 0x38 #define VCLK388_631 0x39 #define VCLK125_999 0x51 #define VCLK148_5 0x52 -#define VCLK178_992 0x54 #define VCLK217_325 0x55 -#define VCLK299_505 0x56 #define YPbPr750pVCLK 0x57 #define TVVCLKDIV2 0x3A @@ -735,34 +340,13 @@ #define HiTVSimuVCLK 0x3E #define HiTVTextVCLK 0x3F #define VCLK39_77 0x40 -/* #define YPbPr750pVCLK 0x0F */ #define YPbPr525pVCLK 0x3A -/* #define ;;YPbPr525iVCLK 0x3B */ -/* #define ;;YPbPr525iVCLK_2 0x3A */ #define NTSC1024VCLK 0x41 -#define VCLK25_175_41 0x42 /* ; ScaleLCD */ -#define VCLK25_175_42 0x43 -#define VCLK28_322_43 0x44 -#define VCLK40_44 0x45 -#define VCLKQVGA_1 0x46 /* ; QVGA */ -#define VCLKQVGA_2 0x47 -#define VCLKQVGA_3 0x48 #define VCLK35_2 0x49 /* ; 800x480 */ #define VCLK122_61 0x4A #define VCLK80_350 0x4B #define VCLK107_385 0x4C -#define CHTVVCLK30_2 0x50 /* ;;CHTV */ -#define CHTVVCLK28_1 0x51 -#define CHTVVCLK43_6 0x52 -#define CHTVVCLK26_4 0x53 -#define CHTVVCLK24_6 0x54 -#define CHTVVCLK47_8 0x55 -#define CHTVVCLK31_5 0x56 -#define CHTVVCLK26_2 0x57 -#define CHTVVCLK39 0x58 -#define CHTVVCLK36 0x59 - #define CH7007TVVCLK30_2 0x00 /* [Billy] 2007/05/18 For CH7007 */ #define CH7007TVVCLK28_1 0x01 #define CH7007TVVCLK43_6 0x02 @@ -847,5 +431,4 @@ #define RES1280x960x85 0x46 #define RES1280x960x120 0x47 -#define LFBDRAMTrap 0x30 #endif diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index de02913cab6..c40d9d854cb 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -1,12 +1,6 @@ #ifndef _VB_STRUCT_ #define _VB_STRUCT_ -#ifdef _INITNEW_ -#define EXTERN -#else -#define EXTERN extern -#endif - struct XGI_PanelDelayTblStruct { unsigned char timer[2]; }; From 3f1095328e8d5af8d08a4f9215b55c78ee55bc49 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:23 +0300 Subject: [PATCH 0208/1519] staging: xgifb: vb_table: delete unused data Delete unused data. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_table.h | 729 ------------------------------- 1 file changed, 729 deletions(-) diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index d10de4888dc..0184292fc7e 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -173,37 +173,6 @@ static unsigned char XGI340_AGPReg[12] = { static unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83}; -#if 0 -static unsigned char XGI330_SR15_1[8][8] = { - {0x0, 0x0, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00}, - {0x5, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00, 0x00}, - {0xba, 0xba, 0xba, 0xba, 0xBA, 0xBA, 0x00, 0x00}, - {0x55, 0x57, 0x57, 0xAB, 0xAB, 0xAB, 0x00, 0x00}, - {0x60, 0x34, 0x34, 0x34, 0x34, 0x34, 0x00, 0x00}, - {0x0, 0x80, 0x80, 0x80, 0x83, 0x83, 0x00, 0x00}, - {0x50, 0x50, 0x50, 0x3C, 0x3C, 0x3C, 0x00, 0x00}, - {0x0, 0xa5, 0xfb, 0xf6, 0xF6, 0xF6, 0x00, 0x00} -}; - -static unsigned char XGI330_cr40_1[15][8] = { - {0x66, 0x40, 0x40, 0x28, 0x24, 0x24, 0x00, 0x00}, - {0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, - {0x00, 0xf0, 0xf0, 0xf0, 0xF0, 0xF0, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x88, 0x88, 0x88, 0xAA, 0xAC, 0xAC, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0xA2, 0x00, 0x00, 0xA2, 0xA2, 0x00, 0x00}, -}; -#endif - static unsigned char XGI330_sr25[] = {0x00, 0x0}; static unsigned char XGI330_sr31 = 0xc0; static unsigned char XGI330_sr32 = 0x11; @@ -1007,112 +976,6 @@ static struct XGI_CRT1TableStruct XGI_CRT1Table[] = { 0x03, 0xDE, 0xC0, 0x84, 0xBF, 0x04, 0x90} } /* 0x47 */ }; -#if 0 -static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = { - /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h, - 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */ - /* 00 (640x200,640x400) */ - { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01 } }, - /* 01 (640x350) */ - { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01 } }, - /* 02 (720x400) */ - { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01 } }, - /* 03 (720x350) */ - { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01 } }, - /* 04 (640x480) ;;5/6/02 */ - { {0x6A, 0x77, 0xBB, 0x6E, 0x84, 0x2E, 0x02, 0x5A, - 0x04, 0x00, 0x80, 0x20, 0x7E, 0x80, 0x97, 0x00 } }, - /* 05 (800x600) ;;1/12/02 */ - { {0xCF, 0x77, 0xB7, 0xC8, 0x84, 0x3B, 0x02, 0x5A, - 0x04, 0x00, 0x80, 0x19, 0x88, 0xAE, 0xA3, 0x00 } }, - /* 06 (1024x768) ;;5/6/02 */ - { {0xEE, 0x77, 0xBB, 0x66, 0x87, 0x32, 0x01, 0x5A, - 0x04, 0x00, 0x80, 0x1B, 0xD4, 0x2F, 0x6F, 0x00 } } -}; - -static struct XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[] = { - /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h, - 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */ - /* 00 (640x200,640x400) */ - { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00, 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 01 (640x350) */ - { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 02 (720x400) */ - { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 03 (720x350) */ - { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50, - 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 04 (640x480) ;;5/6/02 */ - { {0x69, 0x77, 0xBB, 0x6E, 0x84, 0x1E, 0x00 , 0x5A, - 0x04, 0x00, 0x80, 0x25, 0x1A, 0x80, 0x26, 0x00} }, - /* 05 (800x600) ;;5/6/02 */ - { {0xCE, 0x77, 0xB7, 0xB6, 0x83, 0x2C, 0x02 , 0x5A, - 0x04, 0x00, 0x80, 0x1C, 0x00, 0x82, 0x97, 0x00} }, - /* 06 (1024x768) ;;5/6/02 */ - { {0xED, 0x77, 0xBB, 0x66, 0x8C, 0x21, 0x02 , 0x5A, - 0x04, 0x00, 0x80, 0x1F, 0xA0, 0x7E, 0x73, 0x00} } -}; - -static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[] = { - /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h, - 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */ - /* ; 00 (640x200,640x400) */ - { {0x41, 0x7F, 0xB7, 0x34, 0xAD, 0x50, 0x34, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* ; 01 (640x350) */ - { {0x41, 0x7F, 0xB7, 0x80, 0x85, 0x50, 0x00, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* ; 02 (720x400) */ - { {0x41, 0x7F, 0xB7, 0x34, 0xAD, 0x50, 0x34, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* ; 03 (720x350) */ - { {0x41, 0x7F, 0xB7, 0x12, 0x85, 0x50, 0x00, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* ; 04 (640x480) */ - { {0x61, 0x7F, 0xB7, 0x99, 0x84, 0x35, 0x04, 0x5A, - 0x05, 0x00, 0x80, 0x26, 0x2A, 0x55, 0x5D, 0x00} }, - /* ; 05 (800x600) ;;1/12/02 */ - { {0xC3, 0x7F, 0xB7, 0x7A, 0x84, 0x40, 0x02, 0x5A, - 0x05, 0x00, 0x80, 0x1F, 0x84, 0x3D, 0x28, 0x00} }, - /* ; 06 (1024x768) ;;1/12/02 */ - { {0xE5, 0x7F, 0xB7, 0x1D, 0xA7, 0x3E, 0x04, 0x5A, - 0x05, 0x00, 0x80, 0x20, 0x3E, 0xE4, 0x22, 0x00} } -}; - -static struct XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[] = { - /* Index: 000, 0x01, 0x02, 0x04, 0x03, 0x05, 0x06, 0x07, - 0x08, 0x15, 0x1F, 0x0C, 0x0D, 0x0E, 0x0F, 0x10h */ - /* 00 (640x200,640x400) */ - { {0x41, 0x7F, 0xB7, 0x36, 0xAD, 0x50, 0x34, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 01 (640x350) */ - { {0x41, 0x7F, 0xB7, 0x86, 0x85, 0x50, 0x00, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 02 (720x400) */ - { {0x41, 0x7F, 0xB7, 0x36, 0xAD, 0x50, 0x34, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 03 (720x350) */ - { {0x41, 0x7F, 0xB7, 0x86, 0x85, 0x50, 0x00, 0x83, - 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} }, - /* 04 (640x480) */ - { {0x61, 0x7F, 0xB7, 0x99, 0x84, 0x35, 0x04, 0x5A, - 0x05, 0x00, 0x80, 0x26, 0x2A, 0x55, 0x5D, 0x00} }, - /* 05 (800x600) ;;1/12/02 */ - { {0xC1, 0x7F, 0xB7, 0x4D, 0x8C, 0x1E, 0x31, 0x5A, - 0x05, 0x00, 0x80, 0x26, 0x78, 0x19, 0x34, 0x00} }, - /* 06 (1024x768) ;;1/12/02 */ - { {0xE4, 0x7F, 0xB7, 0x1E, 0xAF, 0x29, 0x37, 0x5A, - 0x05, 0x00, 0x80, 0x25, 0x8C, 0xB2, 0x2A, 0x00} } -}; -#endif - static unsigned char XGI_CH7017LV1024x768[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xED, 0xA3, 0xC8, 0xC7, 0xAC, 0xE0, 0x02}; @@ -1151,16 +1014,6 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] = { {1, 1, 1344, 806, 1344, 806} }; -/*struct XGI330_LCDDataStruct XGI_St2LCD1024x768Data[] = { - {62, 25, 800, 546, 1344, 806}, - {32, 15, 930, 546, 1344, 806}, - {62, 25, 800, 546, 1344, 806}, - {104, 45, 945, 496, 1344, 806}, - {62, 25, 800, 546, 1344, 806}, - {31, 18, 1008, 624, 1344, 806}, - {1, 1, 1344, 806, 1344, 806} -};*/ - static struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] = { {1, 1, 1344, 806, 1344, 806}, /* ; 00 (320x200,320x400, 640x200,640x400) */ @@ -1194,19 +1047,6 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] = { {1, 1, 1688, 1066, 1688, 1066} }; -#if 0 -static struct XGI330_LCDDataStruct XGI_St2LCD1280x1024Data[] = { - {22, 5, 800, 510, 1650, 1088}, - {22, 5, 800, 510, 1650, 1088}, - {176, 45, 900, 510, 1650, 1088}, - {176, 45, 900, 510, 1650, 1088}, - {22, 5, 800, 510, 1650, 1088}, - {13, 5, 1024, 675, 1560, 1152}, - {16, 9, 1266, 804, 1688, 1072}, - {1, 1, 1688, 1066, 1688, 1066} -}; -#endif - static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] = { {1, 1, 1688, 1066, 1688, 1066}, /* 00 (320x200,320x400, 640x200,640x400) */ @@ -1315,19 +1155,6 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] = { {1, 1, 1312, 800, 1312, 800} /* ; 06 (1024x768x75Hz) */ }; -#if 0 -static struct XGI330_LCDDataStruct XGI_StLCD1024x768x75Data[] = { - {42, 25, 1536, 419, 1344, 806}, /* ; 00 (320x200,320x400, - 640x200,640x400) */ - {48, 25, 1536, 369, 1344, 806}, /* ; 01 (320x350,640x350) */ - {42, 25, 1536, 419, 1344, 806}, /* ; 02 (360x400,720x400) */ - {48, 25, 1536, 369, 1344, 806}, /* ; 03 (720x350) */ - {8, 5, 1312, 500, 1312, 800}, /* ; 04 (640x480x75Hz) */ - {41, 25, 1024, 625, 1312, 800}, /* ; 05 (800x600x75Hz) */ - {1, 1, 1312, 800, 1312, 800} /* ; 06 (1024x768x75Hz) */ -}; -#endif - static struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] = { {1, 1, 1312, 800, 1312, 800}, /* ; 00 (320x200,320x400, 640x200,640x400) */ @@ -2041,63 +1868,6 @@ static unsigned char XGI330_Ren750pGroup3[] = { 0x18, 0x1D, 0x23, 0x28, 0x4C, 0xAA, 0x01 }; -#if 0 -static struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] = { - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} }, - { {0x00, 0x00} } -}; - -static struct XGI330_LVDSDataStruct XGI330_LVDS320x480Data_1[] = { - {848, 433, 400, 525}, - {848, 389, 400, 525}, - {848, 433, 400, 525}, - {848, 389, 400, 525}, - {848, 518, 400, 525}, - {1056, 628, 400, 525}, - {400, 525, 400, 525}, - {800, 449, 1000, 644}, - {800, 525, 1000, 635} -}; - -static struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_1[] = { - {848, 433, 1060, 629}, - {848, 389, 1060, 629}, - {848, 433, 1060, 629}, - {848, 389, 1060, 629}, - {848, 518, 1060, 629}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {800, 449, 1000, 644}, - {800, 525, 1000, 635} -}; - -static struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_2[] = { - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {800, 449, 1000, 644}, - {800, 525, 1000, 635} -}; -#endif - static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] = { { 960, 438, 1344, 806}, /* 00 (320x200,320x400,640x200,640x400) */ { 960, 388, 1344, 806}, /* 01 (320x350,640x350) */ @@ -2143,79 +1913,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[] = { {800, 449, 1280, 801}, {800, 525, 1280, 813} }; -/* -struct XGI330_LVDSDataStruct XGI_LVDS1280x768Data_1[] = { - {768, 438, 1408, 806}, - {768, 388, 1408, 806}, - {768, 438, 1408, 806}, - {768, 388, 1408, 806}, - {768, 518, 1408, 806}, - {928, 638, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; -struct XGI330_LVDSDataStruct XGI_LVDS1280x768Data_2[] = { - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -struct XGI330_LVDSDataStruct XGI_LVDS1280x768NData_1[] = { - {704, 438, 1344, 806}, - {704, 388, 1344, 806}, - {704, 438, 1344, 806}, - {704, 388, 1344, 806}, - {704, 518, 1344, 806}, - {864, 638, 1344, 806}, - {1088, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806} -}; - -struct XGI330_LVDSDataStruct XGI_LVDS1280x768NData_2[] = { - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806} -}; - -struct XGI330_LVDSDataStruct XGI_LVDS1280x768SData_1[] = { - {1048, 438, 1688, 806}, - {1048, 388, 1688, 806}, - {1148, 438, 1688, 806}, - {1148, 388, 1688, 806}, - {1048, 518, 1688, 806}, - {1208, 638, 1688, 806}, - {1432, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806} -}; - -struct XGI330_LVDSDataStruct XGI_LVDS1280x768SData_2[] = { - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806}, - {1688, 806, 1688, 806} -}; -*/ static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] = { {928, 416, 1688, 1066}, {928, 366, 1688, 1066}, @@ -2502,20 +2200,6 @@ static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = { {0, 1328, 0, 771, 112, 6} /* ; 0A (1280x768x75Hz) */ }; -#if 0 -static struct XGI330_LVDSDataStruct XGI330_LVDS640x480Data_1[] = { - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 525, 800, 525}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628}, - {1056, 628, 1056, 628} -}; -#endif - static struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] = { { 840, 600, 840, 600}, { 840, 600, 840, 600}, @@ -2805,68 +2489,6 @@ static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] = { { {0x28, 0x5A, 0x13, 0x87, 0xFF, 0x29, 0xA9} } /* ; 05 (x1024) */ }; -#if 0 -static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UNTSC[] = { - { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e, - 0xe8, 0x84, 0x8f, 0x57, 0x20, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e, - 0xd0, 0x82, 0x5d, 0x57, 0x00, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e, - 0xe8, 0x84, 0x8f, 0x57, 0x20, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e, - 0xd0, 0x82, 0x5d, 0x57, 0x00, 0x00, 0x01, 0x00 } }, - { {0x5d, 0x4f, 0x81, 0x53, 0x9c, 0x56, 0xba, - 0x18, 0x84, 0xdf, 0x57, 0x00, 0x00, 0x01, 0x00 } }, - { {0x80, 0x63, 0x84, 0x6c, 0x17, 0xec, 0xf0, - x90, 0x8c, 0x57, 0xed, 0x20, 0x00, 0x06, 0x01 } } -}; - -static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1ONTSC[] = { - { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e, - 0xc0, 0x84, 0x8f, 0x0c, 0x20, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e, - 0xb0, 0x8d, 0x5d, 0x0c, 0x00, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e, - 0xc0, 0x84, 0x8f, 0x0c, 0x20, 0x00, 0x01, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e, - 0xb0, 0x8d, 0x5d, 0x0c, 0x00, 0x00, 0x01, 0x00 } }, - { {0x5d, 0x4f, 0x81, 0x56, 0x9c, 0x0b, 0x3e, - 0xe8, 0x84, 0xdf, 0x0c, 0x00, 0x00, 0x01, 0x00 } }, - { {0x7d, 0x63, 0x81, 0x6a, 0x16, 0xba, 0xf0, - x7f, 0x86, 0x57, 0xbb, 0x00, 0x00, 0x06, 0x01 } } -}; - -static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UPAL[] = { - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xf8, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xf8, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x55, 0x80, 0xec, 0xba, - 0x50, 0x84, 0xdf, 0xed, 0x00, 0x00, 0x05, 0x00 } }, - { {0x70, 0x63, 0x94, 0x68, 0x8d, 0x42, 0xf1, - xc8, 0x8c, 0x57, 0xe9, 0x20, 0x00, 0x05, 0x01 } } -}; - -static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1OPAL[] = { - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xf0, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xf0, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } }, - { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e, - 0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } }, - { {0x64, 0x4f, 0x88, 0x55, 0x80, 0x6f, 0xba, - 0x20, 0x83, 0xdf, 0x70, 0x00, 0x00, 0x05, 0x00 } }, - { {0x73, 0x63, 0x97, 0x69, 0x8e, 0xec, 0xf0, - x90, 0x8c, 0x57, 0xed, 0x20, 0x00, 0x05, 0x01 } } -}; -#endif - /*add for new UNIVGABIOS*/ static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] = { {Panel1024x768, 0x0019, 0x0001, 0}, /* XGI_ExtLCD1024x768Data */ @@ -3007,19 +2629,6 @@ static struct XGI330_TVDataTablStruct XGI_TVDataTable[] = { {0xffff, 0x0000, 12} /* END */ }; -#if 0 -static unsigned short TVLenList[] = { - LVDSCRT1Len_H, - LVDSCRT1Len_V, - LVDSDataLen, - 0, - TVDataLen, - 0, - 0, - CHTVRegLen -}; -#endif - /* Chrontel 7017 TV CRT1 Timing List */ static struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] = { {0x0011, 0x0000, 0}, /* XGI_CHTVCRT1UNTSC */ @@ -3060,44 +2669,6 @@ static unsigned short LCDLenList[] = { 0 }; -#if 0 -/* 660, Dual link */ -static struct XGI330_LCDCapStruct XGI660_LCDDLCapList[] = { -/* LCDCap1024x768 */ - {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65, - 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}, -/* LCDCap1280x1024 */ - {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA, - 0x053, 0x70, 0x03, VCLK108_2, - 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1400x1050 */ - {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA, - 0x053, 0x70, 0x03, VCLK108_2, - 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1600x1200 */ - {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull, - 0x053, 0xC0, 0x03, VCLK162, - 0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1024x768x75 */ - {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75, - 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}, -/* LCDCap1280x1024x75 */ - {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA, - 0x053, 0x90, 0x03, VCLK135_5, - 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCapDefault */ - {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65, - 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10} -}; -#endif - /* Dual link only */ static struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = { /* LCDCap1024x768 */ @@ -3134,40 +2705,6 @@ static struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = { 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10} }; -#if 0 -static struct XGI330_LCDCapStruct XGI660_LCDCapList[] = { -/* LCDCap1024x768 */ - {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65, - 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}, -/* LCDCap1280x1024 */ - {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2, - 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1400x1050 */ - {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2, - 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1600x1200 */ - {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162, - 0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCap1024x768x75 */ - {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75, - 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}, -/* LCDCap1280x1024x75 */ - {Panel1280x1024x75, + DefaultLCDCap, StLCDBToA, - 0x053, 0x90, 0x03, VCLK135_5, - 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10}, -/* LCDCapDefault */ - {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65, - 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00, - 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10} -}; -#endif - static struct XGI330_LCDCapStruct XGI_LCDCapList[] = { /* LCDCap1024x768 */ {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65, @@ -3384,169 +2921,6 @@ static struct XGI_Ext2Struct XGI330_RefIndex[] = { 0x30, 0x47, 0x37, 1024, 768},/* 48 1024x768x160Hz */ }; - -#if 0 -static struct XGI330_VCLKDataStruct XGI330_VCLKData[] = { - {0x1b, 0xe1, 25}, /* 0x0 */ - {0x4e, 0xe4, 28}, /* 0x1 */ - {0x57, 0xe4, 31}, /* 0x2 */ - {0xc3, 0xc8, 36}, /* 0x3 */ - {0x42, 0xe2, 40}, /* 0x4 */ - {0xfe, 0xcd, 43}, /* 0x5 */ - {0x5d, 0xc4, 44}, /* 0x6 */ - {0x52, 0xe2, 49}, /* 0x7 */ - {0x53, 0xe2, 50}, /* 0x8 */ - {0x74, 0x67, 52}, /* 0x9 */ - {0x6d, 0x66, 56}, /* 0xa */ - {0x6c, 0xc3, 65}, /* 0xb */ - {0x46, 0x44, 67}, /* 0xc */ - {0xb1, 0x46, 68}, /* 0xd */ - {0xd3, 0x4a, 72}, /* 0xe */ - {0x29, 0x61, 75}, /* 0xf */ - {0x6e, 0x46, 76}, /* 0x10 */ - {0x2b, 0x61, 78}, /* 0x11 */ - {0x31, 0x42, 79}, /* 0x12 */ - {0xab, 0x44, 83}, /* 0x13 */ - {0x46, 0x25, 84}, /* 0x14 */ - {0x78, 0x29, 86}, /* 0x15 */ - {0x62, 0x44, 94}, /* 0x16 */ - {0x2b, 0x41, 104}, /* 0x17 */ - {0x3a, 0x23, 105}, /* 0x18 */ - {0x70, 0x44, 108}, /* 0x19 */ - {0x3c, 0x23, 109}, /* 0x1a */ - {0x5e, 0x43, 113}, /* 0x1b */ - {0xbc, 0x44, 116}, /* 0x1c */ - {0xe0, 0x46, 132}, /* 0x1d */ - {0x54, 0x42, 135}, /* 0x1e */ - {0xea, 0x2a, 139}, /* 0x1f */ - {0x41, 0x22, 157}, /* 0x20 */ - {0x70, 0x24, 162}, /* 0x21 */ - {0x30, 0x21, 175}, /* 0x22 */ - {0x4e, 0x22, 189}, /* 0x23 */ - {0xde, 0x26, 194}, /* 0x24 */ - {0x62, 0x06, 202}, /* 0x25 */ - {0x3f, 0x03, 229}, /* 0x26 */ - {0xb8, 0x06, 234}, /* 0x27 */ - {0x34, 0x02, 253}, /* 0x28 */ - {0x58, 0x04, 255}, /* 0x29 */ - {0x24, 0x01, 265}, /* 0x2a */ - {0x9b, 0x02, 267}, /* 0x2b */ - {0x70, 0x05, 270}, /* 0x2c */ - {0x25, 0x01, 272}, /* 0x2d */ - {0x9c, 0x02, 277}, /* 0x2e */ - {0x27, 0x01, 286}, /* 0x2f */ - {0x3c, 0x02, 291}, /* 0x30 */ - {0xef, 0x0a, 292}, /* 0x31 */ - {0xf6, 0x0a, 310}, /* 0x32 */ - {0x95, 0x01, 315}, /* 0x33 */ - {0xf0, 0x09, 324}, /* 0x34 */ - {0xfe, 0x0a, 331}, /* 0x35 */ - {0xf3, 0x09, 332}, /* 0x36 */ - {0xea, 0x08, 340}, /* 0x37 */ - {0xe8, 0x07, 376}, /* 0x38 */ - {0xde, 0x06, 389}, /* 0x39 */ - {0x52, 0x2a, 54}, /* 0x3a */ - {0x52, 0x6a, 27}, /* 0x3b */ - {0x62, 0x24, 70}, /* 0x3c */ - {0x62, 0x64, 70}, /* 0x3d */ - {0xa8, 0x4c, 30}, /* 0x3e */ - {0x20, 0x26, 33}, /* 0x3f */ - {0x31, 0xc2, 39}, /* 0x40 */ - {0x60, 0x36, 30}, /* 0x41 */ - {0x40, 0x4A, 28}, /* 0x42 */ - {0x9F, 0x46, 44}, /* 0x43 */ - {0x97, 0x2C, 26}, /* 0x44 */ - {0x44, 0xE4, 25}, /* 0x45 */ - {0x7E, 0x32, 47}, /* 0x46 */ - {0x08, 0x24, 31}, /* 0x47 */ - {0x97, 0x2c, 26}, /* 0x48 */ - {0xCE, 0x3c, 39}, /* 0x49 */ - {0x52, 0x4A, 36}, /* 0x4a */ - {0x2C, 0x61, 95}, /* 0x4b */ - {0x78, 0x27, 108}, /* 0x4c */ - {0x66, 0x43, 123}, /* 0x4d */ - {0x2c, 0x61, 80}, /* 0x4e */ - {0x3b, 0x61, 108} /* 0x4f */ -}; - -static struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] = { - {0x1b, 0xe1, 25}, /* 0x0 */ - {0x4e, 0xe4, 28}, /* 0x1 */ - {0x57, 0xe4, 31}, /* 0x2 */ - {0xc3, 0xc8, 36}, /* 0x3 */ - {0x42, 0x47, 40}, /* 0x4 */ - {0xfe, 0xcd, 43}, /* 0x5 */ - {0x5d, 0xc4, 44}, /* 0x6 */ - {0x52, 0x47, 49}, /* 0x7 */ - {0x53, 0x47, 50}, /* 0x8 */ - {0x74, 0x67, 52}, /* 0x9 */ - {0x6d, 0x66, 56}, /* 0xa */ - {0x5a, 0x64, 65}, /* 0xb */ - {0x46, 0x44, 67}, /* 0xc */ - {0xb1, 0x46, 68}, /* 0xd */ - {0xd3, 0x4a, 72}, /* 0xe */ - {0x29, 0x61, 75}, /* 0xf */ - {0x6d, 0x46, 75}, /* 0x10 */ - {0x41, 0x43, 78}, /* 0x11 */ - {0x31, 0x42, 79}, /* 0x12 */ - {0xab, 0x44, 83}, /* 0x13 */ - {0x46, 0x25, 84}, /* 0x14 */ - {0x78, 0x29, 86}, /* 0x15 */ - {0x62, 0x44, 94}, /* 0x16 */ - {0x2b, 0x22, 104}, /* 0x17 */ - {0x49, 0x24, 105}, /* 0x18 */ - {0xf8, 0x2f, 108}, /* 0x19 */ - {0x3c, 0x23, 109}, /* 0x1a */ - {0x5e, 0x43, 113}, /* 0x1b */ - {0xbc, 0x44, 116}, /* 0x1c */ - {0xe0, 0x46, 132}, /* 0x1d */ - {0xd4, 0x28, 135}, /* 0x1e */ - {0xea, 0x2a, 139}, /* 0x1f */ - {0x41, 0x22, 157}, /* 0x20 */ - {0x70, 0x24, 162}, /* 0x21 */ - {0x30, 0x21, 175}, /* 0x22 */ - {0x4e, 0x22, 189}, /* 0x23 */ - {0xde, 0x26, 194}, /* 0x24 */ - {0x70, 0x07, 202}, /* 0x25 */ - {0x3f, 0x03, 229}, /* 0x26 */ - {0xb8, 0x06, 234}, /* 0x27 */ - {0x34, 0x02, 253}, /* 0x28 */ - {0x58, 0x04, 255}, /* 0x29 */ - {0x24, 0x01, 265}, /* 0x2a */ - {0x9b, 0x02, 267}, /* 0x2b */ - {0x70, 0x05, 270}, /* 0x2c */ - {0x25, 0x01, 272}, /* 0x2d */ - {0x9c, 0x02, 277}, /* 0x2e */ - {0x27, 0x01, 286}, /* 0x2f */ - {0x3c, 0x02, 291}, /* 0x30 */ - {0xef, 0x0a, 292}, /* 0x31 */ - {0xf6, 0x0a, 310}, /* 0x32 */ - {0x95, 0x01, 315}, /* 0x33 */ - {0xf0, 0x09, 324}, /* 0x34 */ - {0xfe, 0x0a, 331}, /* 0x35 */ - {0xf3, 0x09, 332}, /* 0x36 */ - {0xea, 0x08, 340}, /* 0x37 */ - {0xe8, 0x07, 376}, /* 0x38 */ - {0xde, 0x06, 389}, /* 0x39 */ - {0x52, 0x2a, 54}, /* 0x3a */ - {0x52, 0x6a, 27}, /* 0x3b */ - {0x62, 0x24, 70}, /* 0x3c */ - {0x62, 0x64, 70}, /* 0x3d */ - {0xa8, 0x4c, 30}, /* 0x3e */ - {0x20, 0x26, 33}, /* 0x3f */ - {0x31, 0xc2, 39}, /* 0x40 */ - {0x2e, 0x48, 25}, /* 0x41 */ - {0x24, 0x46, 25}, /* 0x42 */ - {0x26, 0x64, 28}, /* 0x43 */ - {0x37, 0x64, 40}, /* 0x44 */ - {0xa1, 0x42, 108}, /* 0x45 */ - {0x37, 0x61, 100}, /* 0x46 */ - {0x78, 0x27, 108}, /* 0x47 */ - {0x5e, 0x64, 68}, /* 0x48 chiawen for fuj1280x768*/ - {0x70, 0x44, 108}, /* 0x49 chiawen for 1400x1050*/ -}; -#endif - static unsigned char XGI330_ScreenOffset[] = { 0x14, 0x19, 0x20, 0x28, 0x32, 0x40, 0x50, 0x64, 0x78, 0x80, 0x2d, 0x35, @@ -3591,46 +2965,13 @@ static unsigned char XGI330_OutputSelect = 0x40; static unsigned char XGI330_SoftSetting = 0x30; static unsigned char XGI330_SR07 = 0x18; -#if 0 -static unsigned char XGI330New_SR15[8][8] = { - { 0x0, 0x4, 0x60, 0x60}, - { 0xf, 0xf, 0xf, 0xf}, - {0xba, 0xba, 0xba, 0xba}, - {0xa9, 0xa9, 0xac, 0xac}, - {0xa0, 0xa0, 0xa0, 0xa8}, - { 0x0, 0x0, 0x2, 0x2}, - {0x30, 0x30, 0x40, 0x40}, - { 0x0, 0xa5, 0xfb, 0xf6} -}; - -static unsigned char XGI330New_CR40[5][8] = { - {0x77, 0x77, 0x44, 0x44}, - {0x77, 0x77, 0x44, 0x44}, - { 0x0, 0x0, 0x0, 0x0}, - {0x5b, 0x5b, 0xab, 0xab}, - { 0x0, 0x0, 0xf0, 0xf8} -}; -#endif - static unsigned char XGI330_CR49[] = {0xaa, 0x88}; static unsigned char XGI330_SR1F = 0x0; static unsigned char XGI330_SR21 = 0xa3; -#if 0 -static unsigned char XGI330_650_SR21 = 0xa7; -#endif static unsigned char XGI330_SR22 = 0xfb; static unsigned char XGI330_SR23 = 0xf6; static unsigned char XGI330_SR24 = 0xd; -#if 0 -static unsigned char XGI660_SR21 = 0xa3;/* 2003.0312 */ -static unsigned char XGI660_SR22 = 0xf3;/* 2003.0312 */ - -static unsigned char XGI330_LVDS_SR32 = 0x00; /* ynlai for 650 LVDS */ -static unsigned char XGI330_LVDS_SR33 = 0x00; /* chiawen for 650 LVDS */ -static unsigned char XGI330_650_SR31 = 0x40; -static unsigned char XGI330_650_SR33 = 0x04; -#endif static unsigned char XGI330_CRT2Data_1_2 = 0x0; static unsigned char XGI330_CRT2Data_4_D = 0x0; static unsigned char XGI330_CRT2Data_4_E = 0x0; @@ -3641,14 +2982,6 @@ static unsigned short XGI330_YCSenseData = 0xb3; static unsigned short XGI330_RGBSenseData2 = 0x0190; /*301b*/ static unsigned short XGI330_VideoSenseData2 = 0x0110; static unsigned short XGI330_YCSenseData2 = 0x016B; -#if 0 -static unsigned char XGI330_NTSCPhase[] = {0x21, 0xed, 0x8a, 0x8}; -static unsigned char XGI330_PALPhase[] = {0x2a, 0x5, 0xd3, 0x0}; -static unsigned char XGI330_NTSCPhase2[] = {0x21, 0xF0, 0x7B, 0xD6};/*301b*/ -static unsigned char XGI330_PALPhase2[] = {0x2a, 0x09, 0x86, 0xe9}; -static unsigned char XGI330_PALMPhase[] = {0x21, 0xE4, 0x2E, 0x9B}; /*palmn*/ -static unsigned char XGI330_PALNPhase[] = {0x21, 0xF4, 0x3E, 0xBA}; -#endif static unsigned char XG40_I2CDefinition = 0x00 ; static unsigned char XG20_CR97 = 0x10 ; @@ -3805,21 +3138,6 @@ static struct XGI330_VCLKDataStruct XGI_VCLKData[] = { {0x66, 0x43, 123}, /* 4A (122.61Mhz) */ {0x2C, 0x61, 80}, /* 4B (80.350Mhz) */ {0x3B, 0x61, 108}, /* 4C (107.385Mhz) */ -/* - {0x60, 0x36, 30},// 4D (30.200MHz) }// No use - {0x60, 0x36, 30},// 4E (30.200MHz) }// No use - {0x60, 0x36, 30},// 4F (30.200MHz) }// No use - {0x60, 0x36, 30},// 50 (30.200MHz) }// CHTV - {0x40, 0x4A, 28},// 51 (28.190MHz) - {0x9F, 0x46, 44},// 52 (43.600MHz) - {0x97, 0x2C, 26},// 53 (26.400MHz) - {0x44, 0xE4, 25},// 54 (24.600MHz) - {0x7E, 0x32, 47},// 55 (47.832MHz) - {0x8A, 0x24, 31},// 56 (31.500MHz) - {0x97, 0x2C, 26},// 57 (26.200MHz) - {0xCE, 0x3C, 39},// 58 (39.000MHz) - {0x52, 0x4A, 36},// 59 (36.000MHz) -*/ {0x69, 0x61, 191}, /* 4D (190.96MHz ) */ {0x4F, 0x22, 192}, /* 4E (192.069MHz) */ {0x28, 0x26, 322}, /* 4F (322.273MHz) */ @@ -3912,21 +3230,6 @@ static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] = { {0x66, 0x43, 123}, /* 4A (122.61Mhz) */ {0x2C, 0x61, 80 }, /* 4B (80.350Mhz) */ {0x3B, 0x61, 108}, /* 4C (107.385Mhz) */ -/* - {0x60, 0x36, 30}, // 4D (30.200MHz) }// No use - {0x60, 0x36, 30}, // 4E (30.200MHz) }// No use - {0x60, 0x36, 30}, // 4F (30.200MHz) }// No use - {0x60, 0x36, 30}, // 50 (30.200MHz) }// CHTV - {0x40, 0x4A, 28}, // 51 (28.190MHz) - {0x9F, 0x46, 44}, // 52 (43.600MHz) - {0x97, 0x2C, 26}, // 53 (26.400MHz) - {0x44, 0xE4, 25}, // 54 (24.600MHz) - {0x7E, 0x32, 47}, // 55 (47.832MHz) - {0x8A, 0x24, 31}, // 56 (31.500MHz) - {0x97, 0x2C, 26}, // 57 (26.200MHz) - {0xCE, 0x3C, 39}, // 58 (39.000MHz) - {0x52, 0x4A, 36}, // 59 (36.000MHz) -*/ {0x69, 0x61, 191}, /* 4D (190.96MHz ) */ {0x4F, 0x22, 192}, /* 4E (192.069MHz) */ {0x28, 0x26, 322}, /* 4F (322.273MHz) */ @@ -3941,38 +3244,6 @@ static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] = { {0xFF, 0x00, 0} /* End mark */ }; -#if 0 -static unsigned char XGI660_TVDelayList[] = { - 0x44, /* ; 0 ExtNTSCDelay */ - 0x44, /* ; 1 StNTSCDelay */ - 0x44, /* ; 2 ExtPALDelay */ - 0x44, /* ; 3 StPALDelay */ - 0x44, /* ; 4 ExtHiTVDelay(1080i) */ - 0x44, /* ; 5 StHiTVDelay(1080i) */ - 0x44, /* ; 6 ExtYPbPrDelay(525i) */ - 0x44, /* ; 7 StYPbPrDealy(525i) */ - 0x44, /* ; 8 ExtYPbPrDelay(525p) */ - 0x44, /* ; 9 StYPbPrDealy(525p) */ - 0x44, /* ; A ExtYPbPrDelay(750p) */ - 0x44 /* ; B StYPbPrDealy(750p) */ -}; - -static unsigned char XGI660_TVDelayList2[] = { - 0x44, /* ; 0 ExtNTSCDelay */ - 0x44, /* ; 1 StNTSCDelay */ - 0x44, /* ; 2 ExtPALDelay */ - 0x44, /* ; 3 StPALDelay */ - 0x44, /* ; 4 ExtHiTVDelay */ - 0x44, /* ; 5 StHiTVDelay */ - 0x44, /* ; 6 ExtYPbPrDelay(525i) */ - 0x44, /* ; 7 StYPbPrDealy(525i) */ - 0x44, /* ; 8 ExtYPbPrDelay(525p) */ - 0x44, /* ; 9 StYPbPrDealy(525p) */ - 0x44, /* ; A ExtYPbPrDelay(750p) */ - 0x44 /* ; B StYPbPrDealy(750p) */ -}; -#endif - static unsigned char XGI301TVDelayList[] = { 0x22, /* ; 0 ExtNTSCDelay */ 0x22, /* ; 1 StNTSCDelay */ From f3e5260585ac1be73417ebe5f7528b828b1d57a2 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:24 +0300 Subject: [PATCH 0209/1519] staging: xgifb: delete unused structs Delete unused struct declarations. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_ext.h | 20 ---------- drivers/staging/xgifb/vb_struct.h | 64 ------------------------------- drivers/staging/xgifb/vgatypes.h | 5 --- 3 files changed, 89 deletions(-) diff --git a/drivers/staging/xgifb/vb_ext.h b/drivers/staging/xgifb/vb_ext.h index 814a446b70c..0b1f55b4242 100644 --- a/drivers/staging/xgifb/vb_ext.h +++ b/drivers/staging/xgifb/vb_ext.h @@ -1,26 +1,6 @@ #ifndef _VBEXT_ #define _VBEXT_ -struct DWORDREGS { - unsigned long Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp; -}; - -struct WORDREGS { - unsigned short ax, hi_ax, bx, hi_bx, cx, hi_cx, dx, hi_dx, si, - hi_si, di, hi_di, bp, hi_bp; -}; - -struct BYTEREGS { - unsigned char al, ah, hi_al, hi_ah, bl, bh, hi_bl, hi_bh, cl, ch, - hi_cl, hi_ch, dl, dh, hi_dl, hi_dh; -}; - -typedef union _X86_REGS { - struct DWORDREGS e; - struct WORDREGS x; - struct BYTEREGS h; -} X86_REGS, *PX86_REGS; - extern void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); extern unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *, diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index c40d9d854cb..3ef79e08857 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -1,10 +1,6 @@ #ifndef _VB_STRUCT_ #define _VB_STRUCT_ -struct XGI_PanelDelayTblStruct { - unsigned char timer[2]; -}; - struct XGI_LCDDataStruct { unsigned short RVBHCMAX; unsigned short RVBHCFACT; @@ -39,24 +35,6 @@ struct XGI_TVDataStruct { unsigned char RY4COE; }; -struct XGI_LVDSDataStruct { - unsigned short VGAHT; - unsigned short VGAVT; - unsigned short LCDHT; - unsigned short LCDVT; -}; - -struct XGI_LVDSDesStruct { - unsigned short LCDHDES; - unsigned short LCDVDES; -}; - -struct XGI_LVDSCRT1DataStruct { - unsigned char CR[15]; -}; - -/*add for LCDA*/ - struct XGI_StStruct { unsigned char St_ModeID; unsigned short St_ModeFlag; @@ -140,10 +118,6 @@ struct XGI_ModeResInfoStruct { unsigned char YChar; }; -struct XGI_LCDNBDesStruct { - unsigned char NB[12]; -}; - /*add for new UNIVGABIOS*/ struct XGI_LCDDesStruct { unsigned short LCDHDES; @@ -159,12 +133,6 @@ struct XGI_LCDDataTablStruct { unsigned short DATAPTR; }; -struct XGI_TVTablDataStruct { - unsigned short MASK; - unsigned short CAP; - unsigned short DATAPTR; -}; - struct XGI330_LCDDataDesStruct { unsigned short LCDHDES; unsigned short LCDHRS; @@ -252,10 +220,6 @@ struct XGI_XG21CRT1Struct { unsigned char ModeID, CR02, CR03, CR15, CR16; }; -struct XGI330_CHTVRegDataStruct { - unsigned char Reg[16]; -}; - struct XGI330_LCDCapStruct { unsigned char LCD_ID; unsigned short LCD_Capability; @@ -318,18 +282,6 @@ struct XGI301C_Tap4TimingStruct { unsigned char Reg[64]; /* C0-FF */ }; -struct XGI_New_StandTableStruct { - unsigned char CRT_COLS; - unsigned char ROWS; - unsigned char CHAR_HEIGHT; - unsigned short CRT_LEN; - unsigned char SR[4]; - unsigned char MISC; - unsigned char CRTC[0x19]; - unsigned char ATTR[0x14]; - unsigned char GRC[9]; -}; - struct vb_device_info { unsigned char ISXPDOS; unsigned long P3c4, P3d4, P3c0, P3ce, P3c2, P3cc; @@ -456,20 +408,4 @@ struct vb_device_info { struct XGI_XG21CRT1Struct *UpdateCRT1; }; /* _struct vb_device_info */ - -struct TimingInfo { - unsigned short Horizontal_ACTIVE; - unsigned short Horizontal_FP; - unsigned short Horizontal_SYNC; - unsigned short Horizontal_BP; - unsigned short Vertical_ACTIVE; - unsigned short Vertical_FP; - unsigned short Vertical_SYNC; - unsigned short Vertical_BP; - double DCLK; - unsigned char FrameRate; - unsigned char Interlace; - unsigned short Margin; -}; - #endif /* _VB_STRUCT_ */ diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h index 5aeb3a4d66f..7f911f1ac32 100644 --- a/drivers/staging/xgifb/vgatypes.h +++ b/drivers/staging/xgifb/vgatypes.h @@ -47,11 +47,6 @@ enum XGI_LCD_TYPE { }; #endif -struct XGI_DSReg { - unsigned char jIdx; - unsigned char jVal; -}; - struct xgi_hw_device_info { unsigned long ulExternalChip; /* NO VB or other video bridge*/ /* if ujVBChipID = VB_CHIP_UNKNOWN, */ From c39aada6926c915f8f3bdee19fa9b27800b8cb09 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:25 +0300 Subject: [PATCH 0210/1519] staging: xgifb: eliminate #ifdef XGIFB_PAN XGIFB_PAN is always defined and checks can be eliminated. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index d71ea61cbf4..911e1a75017 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -28,10 +28,6 @@ #include #include -#ifndef XGIFB_PAN -#define XGIFB_PAN -#endif - #include #ifdef CONFIG_MTRR #include @@ -1361,7 +1357,6 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, return 0; } -#ifdef XGIFB_PAN static int XGIfb_pan_var(struct fb_var_screeninfo *var) { unsigned int base; @@ -1414,7 +1409,6 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var) /* printk("End of pan_var"); */ return 0; } -#endif static int XGIfb_open(struct fb_info *info, int user) { @@ -1500,10 +1494,8 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, else fix->visual = FB_VISUAL_DIRECTCOLOR; fix->xpanstep = 0; -#ifdef XGIFB_PAN if (XGIfb_ypan) fix->ypanstep = 1; -#endif fix->ywrapstep = 0; fix->line_length = xgi_video_info.video_linelength; fix->mmio_start = xgi_video_info.mmio_base; @@ -1671,7 +1663,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) return 0; } -#ifdef XGIFB_PAN static int XGIfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { @@ -1708,7 +1699,6 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, /* printk("End of pan_display\n"); */ return 0; } -#endif static int XGIfb_blank(int blank, struct fb_info *info) { @@ -1734,9 +1724,7 @@ static struct fb_ops XGIfb_ops = { .fb_check_var = XGIfb_check_var, .fb_set_par = XGIfb_set_par, .fb_setcolreg = XGIfb_setcolreg, -#ifdef XGIFB_PAN .fb_pan_display = XGIfb_pan_display, -#endif .fb_blank = XGIfb_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, From e1521a166d2cb2551a41fa2a697f92e661500cdd Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:26 +0300 Subject: [PATCH 0211/1519] staging: xgifb: probe: delete checks for mode "none" The driver does not allow selecting the mode "none", so no need to check for that in probe. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 541 ++++++++++++++-------------- 1 file changed, 267 insertions(+), 274 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 911e1a75017..630f447b461 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2143,15 +2143,12 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error; } - if ((xgifb_mode_idx < 0) || - ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) { - /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ - xgifb_reg_or(XGISR, - IND_XGI_PCI_ADDRESS_SET, - (XGI_PCI_ADDR_ENABLE | XGI_MEM_MAP_IO_ENABLE)); - /* Enable 2D accelerator engine */ - xgifb_reg_or(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D); - } + /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ + xgifb_reg_or(XGISR, + IND_XGI_PCI_ADDRESS_SET, + (XGI_PCI_ADDR_ENABLE | XGI_MEM_MAP_IO_ENABLE)); + /* Enable 2D accelerator engine */ + xgifb_reg_or(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D); XGIhw_ext.ulVideoMemorySize = xgi_video_info.video_size; @@ -2195,299 +2192,295 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgi_video_info.mtrr = (unsigned int) 0; - if ((xgifb_mode_idx < 0) || - ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) { + xgi_video_info.hasVB = HASVB_NONE; + if ((xgi_video_info.chip == XG20) || + (xgi_video_info.chip == XG27)) { xgi_video_info.hasVB = HASVB_NONE; - if ((xgi_video_info.chip == XG20) || - (xgi_video_info.chip == XG27)) { - xgi_video_info.hasVB = HASVB_NONE; - } else if (xgi_video_info.chip == XG21) { - CR38 = xgifb_reg_get(XGICR, 0x38); - if ((CR38&0xE0) == 0xC0) { - xgi_video_info.disp_state = DISPTYPE_LCD; - if (!XGIfb_GetXG21LVDSData()) { - int m; - for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) { - if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) && - (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) { - xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); - } + } else if (xgi_video_info.chip == XG21) { + CR38 = xgifb_reg_get(XGICR, 0x38); + if ((CR38&0xE0) == 0xC0) { + xgi_video_info.disp_state = DISPTYPE_LCD; + if (!XGIfb_GetXG21LVDSData()) { + int m; + for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) { + if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) && + (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) { + xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); } } - } else if ((CR38&0xE0) == 0x60) { - xgi_video_info.hasVB = HASVB_CHRONTEL; - } else { - xgi_video_info.hasVB = HASVB_NONE; } + } else if ((CR38&0xE0) == 0x60) { + xgi_video_info.hasVB = HASVB_CHRONTEL; } else { - XGIfb_get_VB_type(); + xgi_video_info.hasVB = HASVB_NONE; } + } else { + XGIfb_get_VB_type(); + } - XGIhw_ext.ujVBChipID = VB_CHIP_UNKNOWN; + XGIhw_ext.ujVBChipID = VB_CHIP_UNKNOWN; - XGIhw_ext.ulExternalChip = 0; + XGIhw_ext.ulExternalChip = 0; - switch (xgi_video_info.hasVB) { - case HASVB_301: - reg = xgifb_reg_get(XGIPART4, 0x01); - if (reg >= 0xE0) { - XGIhw_ext.ujVBChipID = VB_CHIP_302LV; - printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); - } else if (reg >= 0xD0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301LV; - printk(KERN_INFO "XGIfb: XGI301LV bridge detected (revision 0x%02x)\n", reg); - } - /* else if (reg >= 0xB0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301B; - reg1 = xgifb_reg_get(XGIPART4, 0x23); - printk("XGIfb: XGI301B bridge detected\n"); - } */ - else { - XGIhw_ext.ujVBChipID = VB_CHIP_301; - printk("XGIfb: XGI301 bridge detected\n"); - } - break; - case HASVB_302: - reg = xgifb_reg_get(XGIPART4, 0x01); - if (reg >= 0xE0) { - XGIhw_ext.ujVBChipID = VB_CHIP_302LV; - printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); - } else if (reg >= 0xD0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301LV; - printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); - } else if (reg >= 0xB0) { - reg1 = xgifb_reg_get(XGIPART4, 0x23); - - XGIhw_ext.ujVBChipID = VB_CHIP_302B; - - } else { - XGIhw_ext.ujVBChipID = VB_CHIP_302; - printk(KERN_INFO "XGIfb: XGI302 bridge detected\n"); - } - break; - case HASVB_LVDS: - XGIhw_ext.ulExternalChip = 0x1; - printk(KERN_INFO "XGIfb: LVDS transmitter detected\n"); - break; - case HASVB_TRUMPION: - XGIhw_ext.ulExternalChip = 0x2; - printk(KERN_INFO "XGIfb: Trumpion Zurac LVDS scaler detected\n"); - break; - case HASVB_CHRONTEL: - XGIhw_ext.ulExternalChip = 0x4; - printk(KERN_INFO "XGIfb: Chrontel TV encoder detected\n"); - break; - case HASVB_LVDS_CHRONTEL: - XGIhw_ext.ulExternalChip = 0x5; - printk(KERN_INFO "XGIfb: LVDS transmitter and Chrontel TV encoder detected\n"); - break; - default: - printk(KERN_INFO "XGIfb: No or unknown bridge type detected\n"); - break; + switch (xgi_video_info.hasVB) { + case HASVB_301: + reg = xgifb_reg_get(XGIPART4, 0x01); + if (reg >= 0xE0) { + XGIhw_ext.ujVBChipID = VB_CHIP_302LV; + printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); + } else if (reg >= 0xD0) { + XGIhw_ext.ujVBChipID = VB_CHIP_301LV; + printk(KERN_INFO "XGIfb: XGI301LV bridge detected (revision 0x%02x)\n", reg); } + /* else if (reg >= 0xB0) { + XGIhw_ext.ujVBChipID = VB_CHIP_301B; + reg1 = xgifb_reg_get(XGIPART4, 0x23); + printk("XGIfb: XGI301B bridge detected\n"); + } */ + else { + XGIhw_ext.ujVBChipID = VB_CHIP_301; + printk("XGIfb: XGI301 bridge detected\n"); + } + break; + case HASVB_302: + reg = xgifb_reg_get(XGIPART4, 0x01); + if (reg >= 0xE0) { + XGIhw_ext.ujVBChipID = VB_CHIP_302LV; + printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); + } else if (reg >= 0xD0) { + XGIhw_ext.ujVBChipID = VB_CHIP_301LV; + printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); + } else if (reg >= 0xB0) { + reg1 = xgifb_reg_get(XGIPART4, 0x23); - if (xgi_video_info.hasVB != HASVB_NONE) - XGIfb_detect_VB(); + XGIhw_ext.ujVBChipID = VB_CHIP_302B; - if (xgi_video_info.disp_state & DISPTYPE_DISP2) { - if (XGIfb_crt1off) - xgi_video_info.disp_state |= DISPMODE_SINGLE; - else - xgi_video_info.disp_state |= (DISPMODE_MIRROR | - DISPTYPE_CRT1); } else { - xgi_video_info.disp_state = DISPMODE_SINGLE | - DISPTYPE_CRT1; + XGIhw_ext.ujVBChipID = VB_CHIP_302; + printk(KERN_INFO "XGIfb: XGI302 bridge detected\n"); } + break; + case HASVB_LVDS: + XGIhw_ext.ulExternalChip = 0x1; + printk(KERN_INFO "XGIfb: LVDS transmitter detected\n"); + break; + case HASVB_TRUMPION: + XGIhw_ext.ulExternalChip = 0x2; + printk(KERN_INFO "XGIfb: Trumpion Zurac LVDS scaler detected\n"); + break; + case HASVB_CHRONTEL: + XGIhw_ext.ulExternalChip = 0x4; + printk(KERN_INFO "XGIfb: Chrontel TV encoder detected\n"); + break; + case HASVB_LVDS_CHRONTEL: + XGIhw_ext.ulExternalChip = 0x5; + printk(KERN_INFO "XGIfb: LVDS transmitter and Chrontel TV encoder detected\n"); + break; + default: + printk(KERN_INFO "XGIfb: No or unknown bridge type detected\n"); + break; + } - if (xgi_video_info.disp_state & DISPTYPE_LCD) { - if (!enable_dstn) { - reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); - reg &= 0x0f; - XGIhw_ext.ulCRT2LCDType = XGI310paneltype[reg]; + if (xgi_video_info.hasVB != HASVB_NONE) + XGIfb_detect_VB(); + if (xgi_video_info.disp_state & DISPTYPE_DISP2) { + if (XGIfb_crt1off) + xgi_video_info.disp_state |= DISPMODE_SINGLE; + else + xgi_video_info.disp_state |= (DISPMODE_MIRROR | + DISPTYPE_CRT1); + } else { + xgi_video_info.disp_state = DISPMODE_SINGLE | + DISPTYPE_CRT1; + } + + if (xgi_video_info.disp_state & DISPTYPE_LCD) { + if (!enable_dstn) { + reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); + reg &= 0x0f; + XGIhw_ext.ulCRT2LCDType = XGI310paneltype[reg]; + + } else { + /* TW: FSTN/DSTN */ + XGIhw_ext.ulCRT2LCDType = LCD_320x480; + } + } + + XGIfb_detectedpdc = 0; + + XGIfb_detectedlcda = 0xff; + + /* TW: Try to find about LCDA */ + + if ((XGIhw_ext.ujVBChipID == VB_CHIP_302B) || + (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) || + (XGIhw_ext.ujVBChipID == VB_CHIP_302LV)) { + int tmp; + tmp = xgifb_reg_get(XGICR, 0x34); + if (tmp <= 0x13) { + /* Currently on LCDA? + *(Some BIOSes leave CR38) */ + tmp = xgifb_reg_get(XGICR, 0x38); + if ((tmp & 0x03) == 0x03) { + /* XGI_Pr.XGI_UseLCDA = 1; */ } else { - /* TW: FSTN/DSTN */ - XGIhw_ext.ulCRT2LCDType = LCD_320x480; - } - } - - XGIfb_detectedpdc = 0; - - XGIfb_detectedlcda = 0xff; - - /* TW: Try to find about LCDA */ - - if ((XGIhw_ext.ujVBChipID == VB_CHIP_302B) || - (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) || - (XGIhw_ext.ujVBChipID == VB_CHIP_302LV)) { - int tmp; - tmp = xgifb_reg_get(XGICR, 0x34); - if (tmp <= 0x13) { /* Currently on LCDA? - *(Some BIOSes leave CR38) */ - tmp = xgifb_reg_get(XGICR, 0x38); - if ((tmp & 0x03) == 0x03) { + *(Some newer BIOSes set D0 in CR35) */ + tmp = xgifb_reg_get(XGICR, 0x35); + if (tmp & 0x01) { /* XGI_Pr.XGI_UseLCDA = 1; */ } else { - /* Currently on LCDA? - *(Some newer BIOSes set D0 in CR35) */ - tmp = xgifb_reg_get(XGICR, 0x35); - if (tmp & 0x01) { - /* XGI_Pr.XGI_UseLCDA = 1; */ - } else { - tmp = xgifb_reg_get(XGICR, - 0x30); - if (tmp & 0x20) { - tmp = xgifb_reg_get( - XGIPART1, 0x13); - if (tmp & 0x04) { - /* XGI_Pr.XGI_UseLCDA = 1; */ - } + tmp = xgifb_reg_get(XGICR, + 0x30); + if (tmp & 0x20) { + tmp = xgifb_reg_get( + XGIPART1, 0x13); + if (tmp & 0x04) { + /* XGI_Pr.XGI_UseLCDA = 1; */ } } } } - } - if (xgifb_mode_idx >= 0) - xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); - - if (xgifb_mode_idx < 0) { - switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { - case DISPTYPE_LCD: - xgifb_mode_idx = DEFAULT_LCDMODE; - if (xgi_video_info.chip == XG21) - xgifb_mode_idx = - XGIfb_GetXG21DefaultLVDSModeIdx(); - break; - case DISPTYPE_TV: - xgifb_mode_idx = DEFAULT_TVMODE; - break; - default: - xgifb_mode_idx = DEFAULT_MODE; - break; - } - } - - XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; - - /* yilin set default refresh rate */ - if (xgi_video_info.refresh_rate == 0) - xgi_video_info.refresh_rate = 60; - if (XGIfb_search_refresh_rate( - xgi_video_info.refresh_rate) == 0) { - XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; - xgi_video_info.refresh_rate = 60; - } - - xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; - xgi_video_info.video_vwidth = - xgi_video_info.video_width = - XGIbios_mode[xgifb_mode_idx].xres; - xgi_video_info.video_vheight = - xgi_video_info.video_height = - XGIbios_mode[xgifb_mode_idx].yres; - xgi_video_info.org_x = xgi_video_info.org_y = 0; - xgi_video_info.video_linelength = - xgi_video_info.video_width * - (xgi_video_info.video_bpp >> 3); - switch (xgi_video_info.video_bpp) { - case 8: - xgi_video_info.DstColor = 0x0000; - xgi_video_info.XGI310_AccelDepth = 0x00000000; - xgi_video_info.video_cmap_len = 256; - break; - case 16: - xgi_video_info.DstColor = 0x8000; - xgi_video_info.XGI310_AccelDepth = 0x00010000; - xgi_video_info.video_cmap_len = 16; - break; - case 32: - xgi_video_info.DstColor = 0xC000; - xgi_video_info.XGI310_AccelDepth = 0x00020000; - xgi_video_info.video_cmap_len = 16; - break; - default: - xgi_video_info.video_cmap_len = 16; - printk(KERN_INFO "XGIfb: Unsupported depth %d", - xgi_video_info.video_bpp); - break; - } - - printk(KERN_INFO "XGIfb: Default mode is %dx%dx%d (%dHz)\n", - xgi_video_info.video_width, - xgi_video_info.video_height, - xgi_video_info.video_bpp, - xgi_video_info.refresh_rate); - - default_var.xres = - default_var.xres_virtual = - xgi_video_info.video_width; - default_var.yres = - default_var.yres_virtual = - xgi_video_info.video_height; - default_var.bits_per_pixel = xgi_video_info.video_bpp; - - XGIfb_bpp_to_var(&default_var); - - default_var.pixclock = (u32) (1000000000 / - XGIfb_mode_rate_to_dclock(&XGI_Pr, &XGIhw_ext, - XGIfb_mode_no, XGIfb_rate_idx)); - - if (XGIfb_mode_rate_to_ddata(&XGI_Pr, &XGIhw_ext, - XGIfb_mode_no, XGIfb_rate_idx, - &default_var.left_margin, &default_var.right_margin, - &default_var.upper_margin, &default_var.lower_margin, - &default_var.hsync_len, &default_var.vsync_len, - &default_var.sync, &default_var.vmode)) { - - if ((default_var.vmode & FB_VMODE_MASK) == - FB_VMODE_INTERLACED) { - default_var.yres <<= 1; - default_var.yres_virtual <<= 1; - } else if ((default_var.vmode & FB_VMODE_MASK) == - FB_VMODE_DOUBLE) { - default_var.pixclock >>= 1; - default_var.yres >>= 1; - default_var.yres_virtual >>= 1; - } - - } - - fb_info->flags = FBINFO_FLAG_DEFAULT; - fb_info->var = default_var; - fb_info->fix = XGIfb_fix; - fb_info->par = &xgi_video_info; - fb_info->screen_base = xgi_video_info.video_vbase; - fb_info->fbops = &XGIfb_ops; - XGIfb_get_fix(&fb_info->fix, -1, fb_info); - fb_info->pseudo_palette = pseudo_palette; - - fb_alloc_cmap(&fb_info->cmap, 256 , 0); - -#ifdef CONFIG_MTRR - xgi_video_info.mtrr = mtrr_add( - (unsigned int) xgi_video_info.video_base, - (unsigned int) xgi_video_info.video_size, - MTRR_TYPE_WRCOMB, 1); - if (xgi_video_info.mtrr) - printk(KERN_INFO "XGIfb: Added MTRRs\n"); -#endif - - if (register_framebuffer(fb_info) < 0) { - ret = -EINVAL; - goto error_1; - } - - XGIfb_registered = 1; - - printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", - fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); - } + if (xgifb_mode_idx >= 0) + xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); + + if (xgifb_mode_idx < 0) { + switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { + case DISPTYPE_LCD: + xgifb_mode_idx = DEFAULT_LCDMODE; + if (xgi_video_info.chip == XG21) + xgifb_mode_idx = + XGIfb_GetXG21DefaultLVDSModeIdx(); + break; + case DISPTYPE_TV: + xgifb_mode_idx = DEFAULT_TVMODE; + break; + default: + xgifb_mode_idx = DEFAULT_MODE; + break; + } + } + + XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; + + /* yilin set default refresh rate */ + if (xgi_video_info.refresh_rate == 0) + xgi_video_info.refresh_rate = 60; + if (XGIfb_search_refresh_rate( + xgi_video_info.refresh_rate) == 0) { + XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; + xgi_video_info.refresh_rate = 60; + } + + xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; + xgi_video_info.video_vwidth = + xgi_video_info.video_width = + XGIbios_mode[xgifb_mode_idx].xres; + xgi_video_info.video_vheight = + xgi_video_info.video_height = + XGIbios_mode[xgifb_mode_idx].yres; + xgi_video_info.org_x = xgi_video_info.org_y = 0; + xgi_video_info.video_linelength = + xgi_video_info.video_width * + (xgi_video_info.video_bpp >> 3); + switch (xgi_video_info.video_bpp) { + case 8: + xgi_video_info.DstColor = 0x0000; + xgi_video_info.XGI310_AccelDepth = 0x00000000; + xgi_video_info.video_cmap_len = 256; + break; + case 16: + xgi_video_info.DstColor = 0x8000; + xgi_video_info.XGI310_AccelDepth = 0x00010000; + xgi_video_info.video_cmap_len = 16; + break; + case 32: + xgi_video_info.DstColor = 0xC000; + xgi_video_info.XGI310_AccelDepth = 0x00020000; + xgi_video_info.video_cmap_len = 16; + break; + default: + xgi_video_info.video_cmap_len = 16; + printk(KERN_INFO "XGIfb: Unsupported depth %d", + xgi_video_info.video_bpp); + break; + } + + printk(KERN_INFO "XGIfb: Default mode is %dx%dx%d (%dHz)\n", + xgi_video_info.video_width, + xgi_video_info.video_height, + xgi_video_info.video_bpp, + xgi_video_info.refresh_rate); + + default_var.xres = + default_var.xres_virtual = + xgi_video_info.video_width; + default_var.yres = + default_var.yres_virtual = + xgi_video_info.video_height; + default_var.bits_per_pixel = xgi_video_info.video_bpp; + + XGIfb_bpp_to_var(&default_var); + + default_var.pixclock = (u32) (1000000000 / + XGIfb_mode_rate_to_dclock(&XGI_Pr, &XGIhw_ext, + XGIfb_mode_no, XGIfb_rate_idx)); + + if (XGIfb_mode_rate_to_ddata(&XGI_Pr, &XGIhw_ext, + XGIfb_mode_no, XGIfb_rate_idx, + &default_var.left_margin, &default_var.right_margin, + &default_var.upper_margin, &default_var.lower_margin, + &default_var.hsync_len, &default_var.vsync_len, + &default_var.sync, &default_var.vmode)) { + + if ((default_var.vmode & FB_VMODE_MASK) == + FB_VMODE_INTERLACED) { + default_var.yres <<= 1; + default_var.yres_virtual <<= 1; + } else if ((default_var.vmode & FB_VMODE_MASK) == + FB_VMODE_DOUBLE) { + default_var.pixclock >>= 1; + default_var.yres >>= 1; + default_var.yres_virtual >>= 1; + } + + } + + fb_info->flags = FBINFO_FLAG_DEFAULT; + fb_info->var = default_var; + fb_info->fix = XGIfb_fix; + fb_info->par = &xgi_video_info; + fb_info->screen_base = xgi_video_info.video_vbase; + fb_info->fbops = &XGIfb_ops; + XGIfb_get_fix(&fb_info->fix, -1, fb_info); + fb_info->pseudo_palette = pseudo_palette; + + fb_alloc_cmap(&fb_info->cmap, 256 , 0); + +#ifdef CONFIG_MTRR + xgi_video_info.mtrr = mtrr_add( + (unsigned int) xgi_video_info.video_base, + (unsigned int) xgi_video_info.video_size, + MTRR_TYPE_WRCOMB, 1); + if (xgi_video_info.mtrr) + printk(KERN_INFO "XGIfb: Added MTRRs\n"); +#endif + + if (register_framebuffer(fb_info) < 0) { + ret = -EINVAL; + goto error_1; + } + + XGIfb_registered = 1; + + printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", + fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); + dumpVGAReg(); return 0; From de351ba690422fbee2a8c01031ef0eb6fd75cfc0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 19 Aug 2011 22:40:27 +0300 Subject: [PATCH 0212/1519] staging: xgifb: replace video_type with FB_TYPE_PACKED_PIXELS Replace a global variable with a constant. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 3 --- drivers/staging/xgifb/XGI_main_26.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 44b7adc672c..39893ca7814 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -132,9 +132,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); /* Fbcon variables */ static struct fb_info *fb_info; - -static int video_type = FB_TYPE_PACKED_PIXELS; - static struct fb_var_screeninfo default_var = { .xres = 0, .yres = 0, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 630f447b461..4415d4aedbe 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1487,7 +1487,7 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, fix->smem_len = xgi_video_info.video_size; - fix->type = video_type; + fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; if (xgi_video_info.video_bpp == 8) fix->visual = FB_VISUAL_PSEUDOCOLOR; From 746a54ac1d9878c60d2a3a852a9ccfd3127c3249 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Mon, 25 Jul 2011 17:26:47 +0300 Subject: [PATCH 0213/1519] Staging: pohmelfs: Coding style fixes in trans.c I fixed whitespace in drivers/staging/pohmelfs/trans.c Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pohmelfs/trans.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pohmelfs/trans.c b/drivers/staging/pohmelfs/trans.c index 36a25358256..06c1a7451b1 100644 --- a/drivers/staging/pohmelfs/trans.c +++ b/drivers/staging/pohmelfs/trans.c @@ -50,7 +50,7 @@ static int netfs_trans_send_pages(struct netfs_trans *t, struct netfs_state *st) int err = 0; unsigned int i, attached_pages = t->attached_pages, ci; struct msghdr msg; - struct page **pages = (t->eng)?t->eng->pages:t->pages; + struct page **pages = (t->eng) ? t->eng->pages : t->pages; struct page *p; unsigned int size; @@ -61,7 +61,7 @@ static int netfs_trans_send_pages(struct netfs_trans *t, struct netfs_state *st) msg.msg_flags = MSG_WAITALL | MSG_MORE; ci = 0; - for (i=0; ipage_num; ++i) { + for (i = 0; i < t->page_num; ++i) { struct page *page = pages[ci]; struct netfs_cmd cmd; struct iovec io; @@ -169,7 +169,7 @@ int netfs_trans_send(struct netfs_trans *t, struct netfs_state *st) } dprintk("%s: sent %s transaction: t: %p, gen: %u, size: %zu, page_num: %u.\n", - __func__, (t->page_num)?"partial":"full", + __func__, (t->page_num) ? "partial" : "full", t, t->gen, t->iovec.iov_len, t->page_num); err = 0; From 9ac4025d8088675a325124b61b592922efa56d22 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 12 Aug 2011 22:08:00 +0300 Subject: [PATCH 0214/1519] staging: remove ath6kl ath6kl is now in drivers/net/wireless/ath so the staging driver is not supported anymore and should be removed. Reported-by: Stephen Rothwell Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/ath6kl/Kconfig | 158 - drivers/staging/ath6kl/Makefile | 122 - drivers/staging/ath6kl/TODO | 25 - .../staging/ath6kl/bmi/include/bmi_internal.h | 54 - drivers/staging/ath6kl/bmi/src/bmi.c | 1010 --- .../ath6kl/hif/common/hif_sdio_common.h | 87 - .../sdio/linux_sdio/include/hif_internal.h | 131 - .../ath6kl/hif/sdio/linux_sdio/src/hif.c | 1273 ---- .../hif/sdio/linux_sdio/src/hif_scatter.c | 393 - drivers/staging/ath6kl/htc2/AR6000/ar6k.c | 1479 ---- drivers/staging/ath6kl/htc2/AR6000/ar6k.h | 401 - .../staging/ath6kl/htc2/AR6000/ar6k_events.c | 783 -- .../staging/ath6kl/htc2/AR6000/ar6k_gmbox.c | 755 -- .../ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c | 1284 ---- drivers/staging/ath6kl/htc2/htc.c | 575 -- drivers/staging/ath6kl/htc2/htc_debug.h | 38 - drivers/staging/ath6kl/htc2/htc_internal.h | 211 - drivers/staging/ath6kl/htc2/htc_recv.c | 1572 ---- drivers/staging/ath6kl/htc2/htc_send.c | 1018 --- drivers/staging/ath6kl/htc2/htc_services.c | 450 -- drivers/staging/ath6kl/include/a_config.h | 31 - drivers/staging/ath6kl/include/a_debug.h | 195 - drivers/staging/ath6kl/include/a_drv.h | 32 - drivers/staging/ath6kl/include/a_drv_api.h | 204 - drivers/staging/ath6kl/include/a_osapi.h | 32 - .../staging/ath6kl/include/aggr_recv_api.h | 140 - drivers/staging/ath6kl/include/ar3kconfig.h | 65 - drivers/staging/ath6kl/include/ar6000_api.h | 32 - drivers/staging/ath6kl/include/ar6000_diag.h | 48 - .../staging/ath6kl/include/ar6kap_common.h | 44 - drivers/staging/ath6kl/include/athbtfilter.h | 135 - drivers/staging/ath6kl/include/bmi.h | 134 - .../include/common/AR6002/AR6K_version.h | 52 - .../ath6kl/include/common/AR6002/addrs.h | 90 - .../AR6002/hw4.0/hw/apb_athr_wlan_map.h | 40 - .../include/common/AR6002/hw4.0/hw/apb_map.h | 40 - .../common/AR6002/hw4.0/hw/mbox_host_reg.h | 24 - .../include/common/AR6002/hw4.0/hw/mbox_reg.h | 552 -- .../AR6002/hw4.0/hw/mbox_wlan_host_reg.h | 471 -- .../common/AR6002/hw4.0/hw/mbox_wlan_reg.h | 589 -- .../include/common/AR6002/hw4.0/hw/rtc_reg.h | 187 - .../common/AR6002/hw4.0/hw/rtc_wlan_reg.h | 162 - .../include/common/AR6002/hw4.0/hw/uart_reg.h | 40 - .../staging/ath6kl/include/common/athdefs.h | 75 - .../staging/ath6kl/include/common/bmi_msg.h | 233 - .../staging/ath6kl/include/common/cnxmgmt.h | 36 - .../staging/ath6kl/include/common/dbglog.h | 126 - .../staging/ath6kl/include/common/dbglog_id.h | 558 -- .../staging/ath6kl/include/common/discovery.h | 75 - .../ath6kl/include/common/epping_test.h | 111 - .../staging/ath6kl/include/common/gmboxif.h | 70 - .../staging/ath6kl/include/common/gpio_reg.h | 9 - drivers/staging/ath6kl/include/common/htc.h | 227 - .../ath6kl/include/common/htc_services.h | 52 - .../staging/ath6kl/include/common/pkt_log.h | 45 - .../staging/ath6kl/include/common/roaming.h | 41 - .../staging/ath6kl/include/common/targaddrs.h | 395 - .../staging/ath6kl/include/common/testcmd.h | 185 - drivers/staging/ath6kl/include/common/tlpm.h | 38 - .../staging/ath6kl/include/common/wlan_defs.h | 79 - drivers/staging/ath6kl/include/common/wmi.h | 3220 -------- drivers/staging/ath6kl/include/common/wmix.h | 271 - drivers/staging/ath6kl/include/common_drv.h | 104 - drivers/staging/ath6kl/include/dbglog_api.h | 52 - drivers/staging/ath6kl/include/dl_list.h | 153 - drivers/staging/ath6kl/include/dset_api.h | 65 - .../ath6kl/include/hci_transport_api.h | 259 - drivers/staging/ath6kl/include/hif.h | 456 -- drivers/staging/ath6kl/include/host_version.h | 52 - drivers/staging/ath6kl/include/htc_api.h | 575 -- drivers/staging/ath6kl/include/htc_packet.h | 227 - drivers/staging/ath6kl/include/wlan_api.h | 128 - drivers/staging/ath6kl/include/wmi_api.h | 441 -- drivers/staging/ath6kl/miscdrv/ar3kconfig.c | 565 -- .../ath6kl/miscdrv/ar3kps/ar3kpsconfig.c | 572 -- .../ath6kl/miscdrv/ar3kps/ar3kpsconfig.h | 75 - .../ath6kl/miscdrv/ar3kps/ar3kpsparser.c | 969 --- .../ath6kl/miscdrv/ar3kps/ar3kpsparser.h | 113 - drivers/staging/ath6kl/miscdrv/common_drv.c | 910 --- drivers/staging/ath6kl/miscdrv/credit_dist.c | 417 -- drivers/staging/ath6kl/miscdrv/miscdrv.h | 42 - drivers/staging/ath6kl/os/linux/ar6000_drv.c | 6267 ---------------- drivers/staging/ath6kl/os/linux/ar6000_pm.c | 626 -- .../staging/ath6kl/os/linux/ar6000_raw_if.c | 455 -- drivers/staging/ath6kl/os/linux/cfg80211.c | 1892 ----- .../ath6kl/os/linux/export_hci_transport.c | 124 - drivers/staging/ath6kl/os/linux/hci_bridge.c | 1141 --- .../ath6kl/os/linux/include/ar6000_drv.h | 776 -- .../ath6kl/os/linux/include/ar6k_pal.h | 36 - .../ath6kl/os/linux/include/ar6xapi_linux.h | 190 - .../ath6kl/os/linux/include/athdrv_linux.h | 1217 ---- .../ath6kl/os/linux/include/cfg80211.h | 61 - .../ath6kl/os/linux/include/config_linux.h | 51 - .../ath6kl/os/linux/include/debug_linux.h | 50 - .../os/linux/include/export_hci_transport.h | 76 - .../ath6kl/os/linux/include/ieee80211_ioctl.h | 177 - .../ath6kl/os/linux/include/osapi_linux.h | 339 - .../ath6kl/os/linux/include/wlan_config.h | 108 - .../os/linux/include/wmi_filter_linux.h | 300 - drivers/staging/ath6kl/os/linux/netbuf.c | 231 - .../staging/ath6kl/reorder/aggr_rx_internal.h | 117 - drivers/staging/ath6kl/reorder/rcv_aggr.c | 661 -- .../staging/ath6kl/wlan/include/ieee80211.h | 397 - .../ath6kl/wlan/include/ieee80211_node.h | 93 - drivers/staging/ath6kl/wlan/src/wlan_node.c | 636 -- .../ath6kl/wlan/src/wlan_recv_beacon.c | 199 - drivers/staging/ath6kl/wlan/src/wlan_utils.c | 58 - drivers/staging/ath6kl/wmi/wmi.c | 6444 ----------------- drivers/staging/ath6kl/wmi/wmi_host.h | 102 - 111 files changed, 50006 deletions(-) delete mode 100644 drivers/staging/ath6kl/Kconfig delete mode 100644 drivers/staging/ath6kl/Makefile delete mode 100644 drivers/staging/ath6kl/TODO delete mode 100644 drivers/staging/ath6kl/bmi/include/bmi_internal.h delete mode 100644 drivers/staging/ath6kl/bmi/src/bmi.c delete mode 100644 drivers/staging/ath6kl/hif/common/hif_sdio_common.h delete mode 100644 drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h delete mode 100644 drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c delete mode 100644 drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif_scatter.c delete mode 100644 drivers/staging/ath6kl/htc2/AR6000/ar6k.c delete mode 100644 drivers/staging/ath6kl/htc2/AR6000/ar6k.h delete mode 100644 drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c delete mode 100644 drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c delete mode 100644 drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c delete mode 100644 drivers/staging/ath6kl/htc2/htc.c delete mode 100644 drivers/staging/ath6kl/htc2/htc_debug.h delete mode 100644 drivers/staging/ath6kl/htc2/htc_internal.h delete mode 100644 drivers/staging/ath6kl/htc2/htc_recv.c delete mode 100644 drivers/staging/ath6kl/htc2/htc_send.c delete mode 100644 drivers/staging/ath6kl/htc2/htc_services.c delete mode 100644 drivers/staging/ath6kl/include/a_config.h delete mode 100644 drivers/staging/ath6kl/include/a_debug.h delete mode 100644 drivers/staging/ath6kl/include/a_drv.h delete mode 100644 drivers/staging/ath6kl/include/a_drv_api.h delete mode 100644 drivers/staging/ath6kl/include/a_osapi.h delete mode 100644 drivers/staging/ath6kl/include/aggr_recv_api.h delete mode 100644 drivers/staging/ath6kl/include/ar3kconfig.h delete mode 100644 drivers/staging/ath6kl/include/ar6000_api.h delete mode 100644 drivers/staging/ath6kl/include/ar6000_diag.h delete mode 100644 drivers/staging/ath6kl/include/ar6kap_common.h delete mode 100644 drivers/staging/ath6kl/include/athbtfilter.h delete mode 100644 drivers/staging/ath6kl/include/bmi.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/AR6K_version.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/addrs.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_athr_wlan_map.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_map.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_host_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_host_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_wlan_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/uart_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/athdefs.h delete mode 100644 drivers/staging/ath6kl/include/common/bmi_msg.h delete mode 100644 drivers/staging/ath6kl/include/common/cnxmgmt.h delete mode 100644 drivers/staging/ath6kl/include/common/dbglog.h delete mode 100644 drivers/staging/ath6kl/include/common/dbglog_id.h delete mode 100644 drivers/staging/ath6kl/include/common/discovery.h delete mode 100644 drivers/staging/ath6kl/include/common/epping_test.h delete mode 100644 drivers/staging/ath6kl/include/common/gmboxif.h delete mode 100644 drivers/staging/ath6kl/include/common/gpio_reg.h delete mode 100644 drivers/staging/ath6kl/include/common/htc.h delete mode 100644 drivers/staging/ath6kl/include/common/htc_services.h delete mode 100644 drivers/staging/ath6kl/include/common/pkt_log.h delete mode 100644 drivers/staging/ath6kl/include/common/roaming.h delete mode 100644 drivers/staging/ath6kl/include/common/targaddrs.h delete mode 100644 drivers/staging/ath6kl/include/common/testcmd.h delete mode 100644 drivers/staging/ath6kl/include/common/tlpm.h delete mode 100644 drivers/staging/ath6kl/include/common/wlan_defs.h delete mode 100644 drivers/staging/ath6kl/include/common/wmi.h delete mode 100644 drivers/staging/ath6kl/include/common/wmix.h delete mode 100644 drivers/staging/ath6kl/include/common_drv.h delete mode 100644 drivers/staging/ath6kl/include/dbglog_api.h delete mode 100644 drivers/staging/ath6kl/include/dl_list.h delete mode 100644 drivers/staging/ath6kl/include/dset_api.h delete mode 100644 drivers/staging/ath6kl/include/hci_transport_api.h delete mode 100644 drivers/staging/ath6kl/include/hif.h delete mode 100644 drivers/staging/ath6kl/include/host_version.h delete mode 100644 drivers/staging/ath6kl/include/htc_api.h delete mode 100644 drivers/staging/ath6kl/include/htc_packet.h delete mode 100644 drivers/staging/ath6kl/include/wlan_api.h delete mode 100644 drivers/staging/ath6kl/include/wmi_api.h delete mode 100644 drivers/staging/ath6kl/miscdrv/ar3kconfig.c delete mode 100644 drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c delete mode 100644 drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.h delete mode 100644 drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.c delete mode 100644 drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.h delete mode 100644 drivers/staging/ath6kl/miscdrv/common_drv.c delete mode 100644 drivers/staging/ath6kl/miscdrv/credit_dist.c delete mode 100644 drivers/staging/ath6kl/miscdrv/miscdrv.h delete mode 100644 drivers/staging/ath6kl/os/linux/ar6000_drv.c delete mode 100644 drivers/staging/ath6kl/os/linux/ar6000_pm.c delete mode 100644 drivers/staging/ath6kl/os/linux/ar6000_raw_if.c delete mode 100644 drivers/staging/ath6kl/os/linux/cfg80211.c delete mode 100644 drivers/staging/ath6kl/os/linux/export_hci_transport.c delete mode 100644 drivers/staging/ath6kl/os/linux/hci_bridge.c delete mode 100644 drivers/staging/ath6kl/os/linux/include/ar6000_drv.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/ar6k_pal.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/athdrv_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/cfg80211.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/config_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/debug_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/export_hci_transport.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/ieee80211_ioctl.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/osapi_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/wlan_config.h delete mode 100644 drivers/staging/ath6kl/os/linux/include/wmi_filter_linux.h delete mode 100644 drivers/staging/ath6kl/os/linux/netbuf.c delete mode 100644 drivers/staging/ath6kl/reorder/aggr_rx_internal.h delete mode 100644 drivers/staging/ath6kl/reorder/rcv_aggr.c delete mode 100644 drivers/staging/ath6kl/wlan/include/ieee80211.h delete mode 100644 drivers/staging/ath6kl/wlan/include/ieee80211_node.h delete mode 100644 drivers/staging/ath6kl/wlan/src/wlan_node.c delete mode 100644 drivers/staging/ath6kl/wlan/src/wlan_recv_beacon.c delete mode 100644 drivers/staging/ath6kl/wlan/src/wlan_utils.c delete mode 100644 drivers/staging/ath6kl/wmi/wmi.c delete mode 100644 drivers/staging/ath6kl/wmi/wmi_host.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index a097763529f..eac0a7fd8ef 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -128,8 +128,6 @@ source "drivers/staging/quickstart/Kconfig" source "drivers/staging/sbe-2t3e3/Kconfig" -source "drivers/staging/ath6kl/Kconfig" - source "drivers/staging/keucr/Kconfig" source "drivers/staging/bcm/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a84a6b331b3..20be1129424 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -55,7 +55,6 @@ obj-$(CONFIG_SOLO6X10) += solo6x10/ obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/ obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/ obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/ -obj-$(CONFIG_ATH6K_LEGACY) += ath6kl/ obj-$(CONFIG_USB_ENESTORAGE) += keucr/ obj-$(CONFIG_BCM_WIMAX) += bcm/ obj-$(CONFIG_FT1000) += ft1000/ diff --git a/drivers/staging/ath6kl/Kconfig b/drivers/staging/ath6kl/Kconfig deleted file mode 100644 index afd6cc16a2b..00000000000 --- a/drivers/staging/ath6kl/Kconfig +++ /dev/null @@ -1,158 +0,0 @@ -config ATH6K_LEGACY - tristate "Atheros AR6003 support (non mac80211)" - depends on MMC && WLAN - depends on CFG80211 - select WIRELESS_EXT - select WEXT_PRIV - help - This module adds support for wireless adapters based on Atheros AR6003 chipset running over SDIO. If you choose to build it as a module, it will be called ath6kl. Pls note that AR6002 and AR6001 are not supported by this driver. - -choice - prompt "AR6003 Board Data Configuration" - depends on ATH6K_LEGACY - default AR600x_SD31_XXX - help - Select the appropriate board data template from the list below that matches your AR6003 based reference design. - -config AR600x_SD31_XXX - bool "SD31-xxx" - help - Board Data file for a standard SD31 reference design (File: bdata.SD31.bin) - -config AR600x_WB31_XXX - bool "WB31-xxx" - help - Board Data file for a standard WB31 (BT/WiFi) reference design (File: bdata.WB31.bin) - -config AR600x_SD32_XXX - bool "SD32-xxx" - help - Board Data file for a standard SD32 (5GHz) reference design (File: bdata.SD32.bin) - -config AR600x_CUSTOM_XXX - bool "CUSTOM-xxx" - help - Board Data file for a custom reference design (File: should be named as bdata.CUSTOM.bin) -endchoice - -config ATH6KL_ENABLE_COEXISTENCE - bool "BT Coexistence support" - depends on ATH6K_LEGACY - help - Enables WLAN/BT coexistence support. Select the apprpriate configuration from below. - -choice - prompt "Front-End Antenna Configuration" - depends on ATH6KL_ENABLE_COEXISTENCE - default AR600x_DUAL_ANTENNA - help - Indicates the number of antennas being used by BT and WLAN. Select the appropriate configuration from the list below that matches your AR6003 based reference design. - -config AR600x_DUAL_ANTENNA - bool "Dual Antenna" - help - Dual Antenna Design - -config AR600x_SINGLE_ANTENNA - bool "Single Antenna" - help - Single Antenna Design -endchoice - -choice - prompt "Collocated Bluetooth Type" - depends on ATH6KL_ENABLE_COEXISTENCE - default AR600x_BT_AR3001 - help - Select the appropriate configuration from the list below that matches your AR6003 based reference design. - -config AR600x_BT_QCOM - bool "Qualcomm BTS4020X" - help - Qualcomm BT (3 Wire PTA) - -config AR600x_BT_CSR - bool "CSR BC06" - help - CSR BT (3 Wire PTA) - -config AR600x_BT_AR3001 - bool "Atheros AR3001" - help - Atheros BT (3 Wire PTA) -endchoice - -config ATH6KL_HCI_BRIDGE - bool "HCI over SDIO support" - depends on ATH6K_LEGACY - help - Enables BT over SDIO. Applicable only for combo designs (eg: WB31) - -config ATH6KL_CONFIG_GPIO_BT_RESET - bool "Configure BT Reset GPIO" - depends on ATH6KL_HCI_BRIDGE - help - Configure a WLAN GPIO for use with BT. - -config AR600x_BT_RESET_PIN - int "GPIO" - depends on ATH6KL_CONFIG_GPIO_BT_RESET - default 22 - help - WLAN GPIO to be used for resetting BT - -config ATH6KL_HTC_RAW_INTERFACE - bool "RAW HTC support" - depends on ATH6K_LEGACY - help - Enables raw HTC interface. Allows application to directly talk to the HTC interface via the ioctl interface - -config ATH6KL_VIRTUAL_SCATTER_GATHER - bool "Virtual Scatter-Gather support" - depends on ATH6K_LEGACY - help - Enables virtual scatter gather support for the hardware that does not support it natively. - -config ATH6KL_SKIP_ABI_VERSION_CHECK - bool "Skip ABI version check support" - depends on ATH6K_LEGACY - help - Forces the driver to disable ABI version check. Caution: Incompatilbity between the host driver and target firmware may lead to unknown side effects. - -config ATH6KL_BT_UART_FC_POLARITY - int "UART Flow Control Polarity" - depends on ATH6KL_LEGACY - default 0 - help - Configures the polarity of UART Flow Control. A value of 0 implies active low and is the default setting. Set it to 1 for active high. - -config ATH6KL_DEBUG - bool "Debug support" - depends on ATH6K_LEGACY - help - Enables debug support - -config ATH6KL_ENABLE_HOST_DEBUG - bool "Host Debug support" - depends on ATH6KL_DEBUG - help - Enables debug support in the driver - -config ATH6KL_ENABLE_TARGET_DEBUG_PRINTS - bool "Target Debug support - Enable UART prints" - depends on ATH6KL_DEBUG - help - Enables uart prints - -config AR600x_DEBUG_UART_TX_PIN - int "GPIO" - depends on ATH6KL_ENABLE_TARGET_DEBUG_PRINTS - default 8 - help - WLAN GPIO to be used for Debug UART (Tx) - -config ATH6KL_DISABLE_TARGET_DBGLOGS - bool "Target Debug support - Disable Debug logs" - depends on ATH6KL_DEBUG - help - Enables debug logs diff --git a/drivers/staging/ath6kl/Makefile b/drivers/staging/ath6kl/Makefile deleted file mode 100644 index 1d3f2390a17..00000000000 --- a/drivers/staging/ath6kl/Makefile +++ /dev/null @@ -1,122 +0,0 @@ -#------------------------------------------------------------------------------ -# Copyright (c) 2004-2010 Atheros Communications Inc. -# All rights reserved. -# -# -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# -# -# -# Author(s): ="Atheros" -#------------------------------------------------------------------------------ - -ccflags-y += -I$(obj)/include -ccflags-y += -I$(obj)/include/common -ccflags-y += -I$(obj)/wlan/include -ccflags-y += -I$(obj)/os/linux/include -ccflags-y += -I$(obj)/os -ccflags-y += -I$(obj)/bmi/include -ccflags-y += -I$(obj)/include/common/AR6002/hw4.0 - -ifeq ($(CONFIG_AR600x_DUAL_ANTENNA),y) -ccflags-y += -DAR600x_DUAL_ANTENNA -endif - -ifeq ($(CONFIG_AR600x_SINGLE_ANTENNA),y) -ccflags-y += -DAR600x_SINGLE_ANTENNA -endif - -ifeq ($(CONFIG_AR600x_BT_QCOM),y) -ccflags-y += -DAR600x_BT_QCOM -endif - -ifeq ($(CONFIG_AR600x_BT_CSR),y) -ccflags-y += -DAR600x_BT_CSR -endif - -ifeq ($(CONFIG_AR600x_BT_AR3001),y) -ccflags-y += -DAR600x_BT_AR3001 -endif - -ifeq ($(CONFIG_ATH6KL_HCI_BRIDGE),y) -ccflags-y += -DATH_AR6K_ENABLE_GMBOX -ccflags-y += -DHCI_TRANSPORT_SDIO -ccflags-y += -DSETUPHCI_ENABLED -ccflags-y += -DSETUPBTDEV_ENABLED -ath6kl-y += htc2/AR6000/ar6k_gmbox.o -ath6kl-y += htc2/AR6000/ar6k_gmbox_hciuart.o -ath6kl-y += miscdrv/ar3kconfig.o -ath6kl-y += miscdrv/ar3kps/ar3kpsconfig.o -ath6kl-y += miscdrv/ar3kps/ar3kpsparser.o -endif - -ifeq ($(CONFIG_ATH6KL_CONFIG_GPIO_BT_RESET),y) -ccflags-y += -DATH6KL_CONFIG_GPIO_BT_RESET -endif - -ifeq ($(CONFIG_ATH6KL_HTC_RAW_INTERFACE),y) -ccflags-y += -DHTC_RAW_INTERFACE -endif - -ifeq ($(CONFIG_ATH6KL_ENABLE_HOST_DEBUG),y) -ccflags-y += -DDEBUG -ccflags-y += -DATH_DEBUG_MODULE -endif - -ifeq ($(CONFIG_ATH6KL_ENABLE_TARGET_DEBUG_PRINTS),y) -ccflags-y += -DENABLEUARTPRINT_SET -endif - -ifeq ($(CONFIG_ATH6KL_DISABLE_TARGET_DBGLOGS),y) -ccflags-y += -DATH6KL_DISABLE_TARGET_DBGLOGS -endif - -ifeq ($(CONFIG_ATH6KL_VIRTUAL_SCATTER_GATHER),y) -ccflags-y += -DATH6KL_CONFIG_HIF_VIRTUAL_SCATTER -endif - -ifeq ($(CONFIG_ATH6KL_SKIP_ABI_VERSION_CHECK),y) -ccflags-y += -DATH6KL_SKIP_ABI_VERSION_CHECK -endif - -ccflags-y += -DWAPI_ENABLE -ccflags-y += -DCHECKSUM_OFFLOAD - -obj-$(CONFIG_ATH6K_LEGACY) := ath6kl.o -ath6kl-y += htc2/AR6000/ar6k.o -ath6kl-y += htc2/AR6000/ar6k_events.o -ath6kl-y += htc2/htc_send.o -ath6kl-y += htc2/htc_recv.o -ath6kl-y += htc2/htc_services.o -ath6kl-y += htc2/htc.o -ath6kl-y += bmi/src/bmi.o -ath6kl-y += os/linux/cfg80211.o -ath6kl-y += os/linux/ar6000_drv.o -ath6kl-y += os/linux/ar6000_raw_if.o -ath6kl-y += os/linux/ar6000_pm.o -ath6kl-y += os/linux/netbuf.o -ath6kl-y += os/linux/hci_bridge.o -ath6kl-y += miscdrv/common_drv.o -ath6kl-y += miscdrv/credit_dist.o -ath6kl-y += wmi/wmi.o -ath6kl-y += reorder/rcv_aggr.o -ath6kl-y += wlan/src/wlan_node.o -ath6kl-y += wlan/src/wlan_recv_beacon.o -ath6kl-y += wlan/src/wlan_utils.o - -# ATH_HIF_TYPE := sdio -ccflags-y += -I$(obj)/hif/sdio/linux_sdio/include -ccflags-y += -DSDIO -ath6kl-y += hif/sdio/linux_sdio/src/hif.o -ath6kl-y += hif/sdio/linux_sdio/src/hif_scatter.o diff --git a/drivers/staging/ath6kl/TODO b/drivers/staging/ath6kl/TODO deleted file mode 100644 index 7be4b46ebb5..00000000000 --- a/drivers/staging/ath6kl/TODO +++ /dev/null @@ -1,25 +0,0 @@ -TODO: - -We are working hard on cleaning up the driver. There's sooooooooo much todo -so instead of editing this file please use the wiki: - -http://wireless.kernel.org/en/users/Drivers/ath6kl - -There's a respective TODO page there. Please also subscribe to the wiki page -to get e-mail updates on changes. - -IRC: - -We *really* need to coordinate development for ath6kl as the cleanup -patches will break pretty much any other patches. Please use IRC to -help coordinate better: - -irc.freenode.net -#ath6kl - -Send patches to: - - - Greg Kroah-Hartman - - Luis R. Rodriguez - - Joe Perches - - Naveen Singh diff --git a/drivers/staging/ath6kl/bmi/include/bmi_internal.h b/drivers/staging/ath6kl/bmi/include/bmi_internal.h deleted file mode 100644 index 8e2577074d6..00000000000 --- a/drivers/staging/ath6kl/bmi/include/bmi_internal.h +++ /dev/null @@ -1,54 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef BMI_INTERNAL_H -#define BMI_INTERNAL_H - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#define ATH_MODULE_NAME bmi -#include "a_debug.h" -#include "hw/mbox_host_reg.h" -#include "bmi_msg.h" - -#define ATH_DEBUG_BMI ATH_DEBUG_MAKE_MODULE_MASK(0) - - -#define BMI_COMMUNICATION_TIMEOUT 100000 - -/* ------ Global Variable Declarations ------- */ -static bool bmiDone; - -int -bmiBufferSend(struct hif_device *device, - u8 *buffer, - u32 length); - -int -bmiBufferReceive(struct hif_device *device, - u8 *buffer, - u32 length, - bool want_timeout); - -#endif diff --git a/drivers/staging/ath6kl/bmi/src/bmi.c b/drivers/staging/ath6kl/bmi/src/bmi.c deleted file mode 100644 index f1f085eba9c..00000000000 --- a/drivers/staging/ath6kl/bmi/src/bmi.c +++ /dev/null @@ -1,1010 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// -// Author(s): ="Atheros" -//============================================================================== - - -#ifdef THREAD_X -#include -#endif - -#include "hif.h" -#include "bmi.h" -#include "htc_api.h" -#include "bmi_internal.h" - -#ifdef ATH_DEBUG_MODULE -static struct ath_debug_mask_description bmi_debug_desc[] = { - { ATH_DEBUG_BMI , "BMI Tracing"}, -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(bmi, - "bmi", - "Boot Manager Interface", - ATH_DEBUG_MASK_DEFAULTS, - ATH_DEBUG_DESCRIPTION_COUNT(bmi_debug_desc), - bmi_debug_desc); - -#endif - -/* -Although we had envisioned BMI to run on top of HTC, this is not how the -final implementation ended up. On the Target side, BMI is a part of the BSP -and does not use the HTC protocol nor even DMA -- it is intentionally kept -very simple. -*/ - -static bool pendingEventsFuncCheck = false; -static u32 *pBMICmdCredits; -static u8 *pBMICmdBuf; -#define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \ - sizeof(u32) /* cmd */ + \ - sizeof(u32) /* addr */ + \ - sizeof(u32))/* length */ -#define BMI_COMMAND_FITS(sz) ((sz) <= MAX_BMI_CMDBUF_SZ) - -/* APIs visible to the driver */ -void -BMIInit(void) -{ - bmiDone = false; - pendingEventsFuncCheck = false; - - /* - * On some platforms, it's not possible to DMA to a static variable - * in a device driver (e.g. Linux loadable driver module). - * So we need to A_MALLOC space for "command credits" and for commands. - * - * Note: implicitly relies on A_MALLOC to provide a buffer that is - * suitable for DMA (or PIO). This buffer will be passed down the - * bus stack. - */ - if (!pBMICmdCredits) { - pBMICmdCredits = (u32 *)A_MALLOC_NOWAIT(4); - A_ASSERT(pBMICmdCredits); - } - - if (!pBMICmdBuf) { - pBMICmdBuf = (u8 *)A_MALLOC_NOWAIT(MAX_BMI_CMDBUF_SZ); - A_ASSERT(pBMICmdBuf); - } - - A_REGISTER_MODULE_DEBUG_INFO(bmi); -} - -void -BMICleanup(void) -{ - if (pBMICmdCredits) { - kfree(pBMICmdCredits); - pBMICmdCredits = NULL; - } - - if (pBMICmdBuf) { - kfree(pBMICmdBuf); - pBMICmdBuf = NULL; - } -} - -int -BMIDone(struct hif_device *device) -{ - int status; - u32 cid; - - if (bmiDone) { - AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n")); - return 0; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device)); - bmiDone = true; - cid = BMI_DONE; - - status = bmiBufferSend(device, (u8 *)&cid, sizeof(cid)); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - if (pBMICmdCredits) { - kfree(pBMICmdCredits); - pBMICmdCredits = NULL; - } - - if (pBMICmdBuf) { - kfree(pBMICmdBuf); - pBMICmdBuf = NULL; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n")); - - return 0; -} - -int -BMIGetTargetInfo(struct hif_device *device, struct bmi_target_info *targ_info) -{ - int status; - u32 cid; - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Enter (device: 0x%p)\n", device)); - cid = BMI_GET_TARGET_INFO; - - status = bmiBufferSend(device, (u8 *)&cid, sizeof(cid)); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - status = bmiBufferReceive(device, (u8 *)&targ_info->target_ver, - sizeof(targ_info->target_ver), true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Version from the device\n")); - return A_ERROR; - } - - if (targ_info->target_ver == TARGET_VERSION_SENTINAL) { - /* Determine how many bytes are in the Target's targ_info */ - status = bmiBufferReceive(device, (u8 *)&targ_info->target_info_byte_count, - sizeof(targ_info->target_info_byte_count), true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info Byte Count from the device\n")); - return A_ERROR; - } - - /* - * The Target's targ_info doesn't match the Host's targ_info. - * We need to do some backwards compatibility work to make this OK. - */ - A_ASSERT(targ_info->target_info_byte_count == sizeof(*targ_info)); - - /* Read the remainder of the targ_info */ - status = bmiBufferReceive(device, - ((u8 *)targ_info)+sizeof(targ_info->target_info_byte_count), - sizeof(*targ_info)-sizeof(targ_info->target_info_byte_count), true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info (%d bytes) from the device\n", - targ_info->target_info_byte_count)); - return A_ERROR; - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n", - targ_info->target_ver, targ_info->target_type)); - - return 0; -} - -int -BMIReadMemory(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length) -{ - u32 cid; - int status; - u32 offset; - u32 remaining, rxlen; - - A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length))); - memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Read Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", - device, address, length)); - - cid = BMI_READ_MEMORY; - - remaining = length; - - while (remaining) - { - rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX; - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - memcpy(&(pBMICmdBuf[offset]), &rxlen, sizeof(rxlen)); - offset += sizeof(length); - - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - status = bmiBufferReceive(device, pBMICmdBuf, rxlen, true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); - return A_ERROR; - } - memcpy(&buffer[length - remaining], pBMICmdBuf, rxlen); - remaining -= rxlen; address += rxlen; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n")); - return 0; -} - -int -BMIWriteMemory(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length) -{ - u32 cid; - int status; - u32 offset; - u32 remaining, txlen; - const u32 header = sizeof(cid) + sizeof(address) + sizeof(length); - u8 alignedBuffer[BMI_DATASZ_MAX]; - u8 *src; - - A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header)); - memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + header); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Write Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", - device, address, length)); - - cid = BMI_WRITE_MEMORY; - - remaining = length; - while (remaining) - { - src = &buffer[length - remaining]; - if (remaining < (BMI_DATASZ_MAX - header)) { - if (remaining & 3) { - /* align it with 4 bytes */ - remaining = remaining + (4 - (remaining & 3)); - memcpy(alignedBuffer, src, remaining); - src = alignedBuffer; - } - txlen = remaining; - } else { - txlen = (BMI_DATASZ_MAX - header); - } - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - memcpy(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); - offset += sizeof(txlen); - memcpy(&(pBMICmdBuf[offset]), src, txlen); - offset += txlen; - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - remaining -= txlen; address += txlen; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write Memory: Exit\n")); - - return 0; -} - -int -BMIExecute(struct hif_device *device, - u32 address, - u32 *param) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n", - device, address, *param)); - - cid = BMI_EXECUTE; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - memcpy(&(pBMICmdBuf[offset]), param, sizeof(*param)); - offset += sizeof(*param); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*param), false); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); - return A_ERROR; - } - - memcpy(param, pBMICmdBuf, sizeof(*param)); - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); - return 0; -} - -int -BMISetAppStart(struct hif_device *device, - u32 address) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Set App Start: Enter (device: 0x%p, address: 0x%x)\n", - device, address)); - - cid = BMI_SET_APP_START; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Set App Start: Exit\n")); - return 0; -} - -int -BMIReadSOCRegister(struct hif_device *device, - u32 address, - u32 *param) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n", - device, address)); - - cid = BMI_READ_SOC_REGISTER; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*param), true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); - return A_ERROR; - } - memcpy(param, pBMICmdBuf, sizeof(*param)); - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit (value: %d)\n", *param)); - return 0; -} - -int -BMIWriteSOCRegister(struct hif_device *device, - u32 address, - u32 param) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Write SOC Register: Enter (device: 0x%p, address: 0x%x, param: %d)\n", - device, address, param)); - - cid = BMI_WRITE_SOC_REGISTER; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - memcpy(&(pBMICmdBuf[offset]), ¶m, sizeof(param)); - offset += sizeof(param); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit\n")); - return 0; -} - -int -BMIrompatchInstall(struct hif_device *device, - u32 ROM_addr, - u32 RAM_addr, - u32 nbytes, - u32 do_activate, - u32 *rompatch_id) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + - sizeof(nbytes) + sizeof(do_activate))); - memset(pBMICmdBuf, 0, sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + - sizeof(nbytes) + sizeof(do_activate)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI rompatch Install: Enter (device: 0x%p, ROMaddr: 0x%x, RAMaddr: 0x%x length: %d activate: %d)\n", - device, ROM_addr, RAM_addr, nbytes, do_activate)); - - cid = BMI_ROMPATCH_INSTALL; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &ROM_addr, sizeof(ROM_addr)); - offset += sizeof(ROM_addr); - memcpy(&(pBMICmdBuf[offset]), &RAM_addr, sizeof(RAM_addr)); - offset += sizeof(RAM_addr); - memcpy(&(pBMICmdBuf[offset]), &nbytes, sizeof(nbytes)); - offset += sizeof(nbytes); - memcpy(&(pBMICmdBuf[offset]), &do_activate, sizeof(do_activate)); - offset += sizeof(do_activate); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*rompatch_id), true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); - return A_ERROR; - } - memcpy(rompatch_id, pBMICmdBuf, sizeof(*rompatch_id)); - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id)); - return 0; -} - -int -BMIrompatchUninstall(struct hif_device *device, - u32 rompatch_id) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(rompatch_id))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(rompatch_id)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI rompatch Uninstall: Enter (device: 0x%p, rompatch_id: %d)\n", - device, rompatch_id)); - - cid = BMI_ROMPATCH_UNINSTALL; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &rompatch_id, sizeof(rompatch_id)); - offset += sizeof(rompatch_id); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch UNinstall: (rompatch_id=0x%x)\n", rompatch_id)); - return 0; -} - -static int -_BMIrompatchChangeActivation(struct hif_device *device, - u32 rompatch_count, - u32 *rompatch_list, - u32 do_activate) -{ - u32 cid; - int status; - u32 offset; - u32 length; - - A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count))); - memset(pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n", - device, rompatch_count)); - - cid = do_activate ? BMI_ROMPATCH_ACTIVATE : BMI_ROMPATCH_DEACTIVATE; - - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &rompatch_count, sizeof(rompatch_count)); - offset += sizeof(rompatch_count); - length = rompatch_count * sizeof(*rompatch_list); - memcpy(&(pBMICmdBuf[offset]), rompatch_list, length); - offset += length; - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n")); - - return 0; -} - -int -BMIrompatchActivate(struct hif_device *device, - u32 rompatch_count, - u32 *rompatch_list) -{ - return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 1); -} - -int -BMIrompatchDeactivate(struct hif_device *device, - u32 rompatch_count, - u32 *rompatch_list) -{ - return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 0); -} - -int -BMILZData(struct hif_device *device, - u8 *buffer, - u32 length) -{ - u32 cid; - int status; - u32 offset; - u32 remaining, txlen; - const u32 header = sizeof(cid) + sizeof(length); - - A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX+header)); - memset (pBMICmdBuf, 0, BMI_DATASZ_MAX+header); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI Send LZ Data: Enter (device: 0x%p, length: %d)\n", - device, length)); - - cid = BMI_LZ_DATA; - - remaining = length; - while (remaining) - { - txlen = (remaining < (BMI_DATASZ_MAX - header)) ? - remaining : (BMI_DATASZ_MAX - header); - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); - offset += sizeof(txlen); - memcpy(&(pBMICmdBuf[offset]), &buffer[length - remaining], txlen); - offset += txlen; - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); - return A_ERROR; - } - remaining -= txlen; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Data: Exit\n")); - - return 0; -} - -int -BMILZStreamStart(struct hif_device *device, - u32 address) -{ - u32 cid; - int status; - u32 offset; - - A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); - memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address)); - - if (bmiDone) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, - ("BMI LZ Stream Start: Enter (device: 0x%p, address: 0x%x)\n", - device, address)); - - cid = BMI_LZ_STREAM_START; - offset = 0; - memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); - offset += sizeof(cid); - memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); - offset += sizeof(address); - status = bmiBufferSend(device, pBMICmdBuf, offset); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to Start LZ Stream to the device\n")); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Stream Start: Exit\n")); - - return 0; -} - -/* BMI Access routines */ -int -bmiBufferSend(struct hif_device *device, - u8 *buffer, - u32 length) -{ - int status; - u32 timeout; - u32 address; - u32 mboxAddress[HTC_MAILBOX_NUM_MAX]; - - HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR, - &mboxAddress[0], sizeof(mboxAddress)); - - *pBMICmdCredits = 0; - timeout = BMI_COMMUNICATION_TIMEOUT; - - while(timeout-- && !(*pBMICmdCredits)) { - /* Read the counter register to get the command credits */ - address = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4; - /* hit the credit counter with a 4-byte access, the first byte read will hit the counter and cause - * a decrement, while the remaining 3 bytes has no effect. The rationale behind this is to - * make all HIF accesses 4-byte aligned */ - status = HIFReadWrite(device, address, (u8 *)pBMICmdCredits, 4, - HIF_RD_SYNC_BYTE_INC, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to decrement the command credit count register\n")); - return A_ERROR; - } - /* the counter is only 8=bits, ignore anything in the upper 3 bytes */ - (*pBMICmdCredits) &= 0xFF; - } - - if (*pBMICmdCredits) { - address = mboxAddress[ENDPOINT1]; - status = HIFReadWrite(device, address, buffer, length, - HIF_WR_SYNC_BYTE_INC, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to send the BMI data to the device\n")); - return A_ERROR; - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout - bmiBufferSend\n")); - return A_ERROR; - } - - return status; -} - -int -bmiBufferReceive(struct hif_device *device, - u8 *buffer, - u32 length, - bool want_timeout) -{ - int status; - u32 address; - u32 mboxAddress[HTC_MAILBOX_NUM_MAX]; - struct hif_pending_events_info hifPendingEvents; - static HIF_PENDING_EVENTS_FUNC getPendingEventsFunc = NULL; - - if (!pendingEventsFuncCheck) { - /* see if the HIF layer implements an alternative function to get pending events - * do this only once! */ - HIFConfigureDevice(device, - HIF_DEVICE_GET_PENDING_EVENTS_FUNC, - &getPendingEventsFunc, - sizeof(getPendingEventsFunc)); - pendingEventsFuncCheck = true; - } - - HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR, - &mboxAddress[0], sizeof(mboxAddress)); - - /* - * During normal bootup, small reads may be required. - * Rather than issue an HIF Read and then wait as the Target - * adds successive bytes to the FIFO, we wait here until - * we know that response data is available. - * - * This allows us to cleanly timeout on an unexpected - * Target failure rather than risk problems at the HIF level. In - * particular, this avoids SDIO timeouts and possibly garbage - * data on some host controllers. And on an interconnect - * such as Compact Flash (as well as some SDIO masters) which - * does not provide any indication on data timeout, it avoids - * a potential hang or garbage response. - * - * Synchronization is more difficult for reads larger than the - * size of the MBOX FIFO (128B), because the Target is unable - * to push the 129th byte of data until AFTER the Host posts an - * HIF Read and removes some FIFO data. So for large reads the - * Host proceeds to post an HIF Read BEFORE all the data is - * actually available to read. Fortunately, large BMI reads do - * not occur in practice -- they're supported for debug/development. - * - * So Host/Target BMI synchronization is divided into these cases: - * CASE 1: length < 4 - * Should not happen - * - * CASE 2: 4 <= length <= 128 - * Wait for first 4 bytes to be in FIFO - * If CONSERVATIVE_BMI_READ is enabled, also wait for - * a BMI command credit, which indicates that the ENTIRE - * response is available in the the FIFO - * - * CASE 3: length > 128 - * Wait for the first 4 bytes to be in FIFO - * - * For most uses, a small timeout should be sufficient and we will - * usually see a response quickly; but there may be some unusual - * (debug) cases of BMI_EXECUTE where we want an larger timeout. - * For now, we use an unbounded busy loop while waiting for - * BMI_EXECUTE. - * - * If BMI_EXECUTE ever needs to support longer-latency execution, - * especially in production, this code needs to be enhanced to sleep - * and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently - * a function of Host processor speed. - */ - if (length >= 4) { /* NB: Currently, always true */ - /* - * NB: word_available is declared static for esoteric reasons - * having to do with protection on some OSes. - */ - static u32 word_available; - u32 timeout; - - word_available = 0; - timeout = BMI_COMMUNICATION_TIMEOUT; - while((!want_timeout || timeout--) && !word_available) { - - if (getPendingEventsFunc != NULL) { - status = getPendingEventsFunc(device, - &hifPendingEvents, - NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMI: Failed to get pending events \n")); - break; - } - - if (hifPendingEvents.AvailableRecvBytes >= sizeof(u32)) { - word_available = 1; - } - continue; - } - - status = HIFReadWrite(device, RX_LOOKAHEAD_VALID_ADDRESS, (u8 *)&word_available, - sizeof(word_available), HIF_RD_SYNC_BYTE_INC, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read RX_LOOKAHEAD_VALID register\n")); - return A_ERROR; - } - /* We did a 4-byte read to the same register; all we really want is one bit */ - word_available &= (1 << ENDPOINT1); - } - - if (!word_available) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout - bmiBufferReceive FIFO empty\n")); - return A_ERROR; - } - } - -#define CONSERVATIVE_BMI_READ 0 -#if CONSERVATIVE_BMI_READ - /* - * This is an extra-conservative CREDIT check. It guarantees - * that ALL data is available in the FIFO before we start to - * read from the interconnect. - * - * This credit check is useless when firmware chooses to - * allow multiple outstanding BMI Command Credits, since the next - * credit will already be present. To restrict the Target to one - * BMI Command Credit, see HI_OPTION_BMI_CRED_LIMIT. - * - * And for large reads (when HI_OPTION_BMI_CRED_LIMIT is set) - * we cannot wait for the next credit because the Target's FIFO - * will not hold the entire response. So we need the Host to - * start to empty the FIFO sooner. (And again, large reads are - * not used in practice; they are for debug/development only.) - * - * For a more conservative Host implementation (which would be - * safer for a Compact Flash interconnect): - * Set CONSERVATIVE_BMI_READ (above) to 1 - * Set HI_OPTION_BMI_CRED_LIMIT and - * reduce BMI_DATASZ_MAX to 32 or 64 - */ - if ((length > 4) && (length < 128)) { /* check against MBOX FIFO size */ - u32 timeout; - - *pBMICmdCredits = 0; - timeout = BMI_COMMUNICATION_TIMEOUT; - while((!want_timeout || timeout--) && !(*pBMICmdCredits) { - /* Read the counter register to get the command credits */ - address = COUNT_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 1; - /* read the counter using a 4-byte read. Since the counter is NOT auto-decrementing, - * we can read this counter multiple times using a non-incrementing address mode. - * The rationale here is to make all HIF accesses a multiple of 4 bytes */ - status = HIFReadWrite(device, address, (u8 *)pBMICmdCredits, sizeof(*pBMICmdCredits), - HIF_RD_SYNC_BYTE_FIX, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the command credit count register\n")); - return A_ERROR; - } - /* we did a 4-byte read to the same count register so mask off upper bytes */ - (*pBMICmdCredits) &= 0xFF; - } - - if (!(*pBMICmdCredits)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout- bmiBufferReceive no credit\n")); - return A_ERROR; - } - } -#endif - - address = mboxAddress[ENDPOINT1]; - status = HIFReadWrite(device, address, buffer, length, HIF_RD_SYNC_BYTE_INC, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the BMI data from the device\n")); - return A_ERROR; - } - - return 0; -} - -int -BMIFastDownload(struct hif_device *device, u32 address, u8 *buffer, u32 length) -{ - int status = A_ERROR; - u32 lastWord = 0; - u32 lastWordOffset = length & ~0x3; - u32 unalignedBytes = length & 0x3; - - status = BMILZStreamStart (device, address); - if (status) { - return A_ERROR; - } - - if (unalignedBytes) { - /* copy the last word into a zero padded buffer */ - memcpy(&lastWord, &buffer[lastWordOffset], unalignedBytes); - } - - status = BMILZData(device, buffer, lastWordOffset); - - if (status) { - return A_ERROR; - } - - if (unalignedBytes) { - status = BMILZData(device, (u8 *)&lastWord, 4); - } - - if (!status) { - // - // Close compressed stream and open a new (fake) one. This serves mainly to flush Target caches. - // - status = BMILZStreamStart (device, 0x00); - if (status) { - return A_ERROR; - } - } - return status; -} - -int -BMIRawWrite(struct hif_device *device, u8 *buffer, u32 length) -{ - return bmiBufferSend(device, buffer, length); -} - -int -BMIRawRead(struct hif_device *device, u8 *buffer, u32 length, bool want_timeout) -{ - return bmiBufferReceive(device, buffer, length, want_timeout); -} diff --git a/drivers/staging/ath6kl/hif/common/hif_sdio_common.h b/drivers/staging/ath6kl/hif/common/hif_sdio_common.h deleted file mode 100644 index 93a2adceca3..00000000000 --- a/drivers/staging/ath6kl/hif/common/hif_sdio_common.h +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// common header file for HIF modules designed for SDIO -// -// Author(s): ="Atheros" -//============================================================================== - -#ifndef HIF_SDIO_COMMON_H_ -#define HIF_SDIO_COMMON_H_ - - /* SDIO manufacturer ID and Codes */ -#define MANUFACTURER_ID_AR6002_BASE 0x200 -#define MANUFACTURER_ID_AR6003_BASE 0x300 -#define MANUFACTURER_ID_AR6K_BASE_MASK 0xFF00 -#define FUNCTION_CLASS 0x0 -#define MANUFACTURER_CODE 0x271 /* Atheros */ - - /* Mailbox address in SDIO address space */ -#define HIF_MBOX_BASE_ADDR 0x800 -#define HIF_MBOX_WIDTH 0x800 -#define HIF_MBOX_START_ADDR(mbox) \ - ( HIF_MBOX_BASE_ADDR + mbox * HIF_MBOX_WIDTH) - -#define HIF_MBOX_END_ADDR(mbox) \ - (HIF_MBOX_START_ADDR(mbox) + HIF_MBOX_WIDTH - 1) - - /* extended MBOX address for larger MBOX writes to MBOX 0*/ -#define HIF_MBOX0_EXTENDED_BASE_ADDR 0x2800 -#define HIF_MBOX0_EXTENDED_WIDTH_AR6002 (6*1024) -#define HIF_MBOX0_EXTENDED_WIDTH_AR6003 (18*1024) - - /* version 1 of the chip has only a 12K extended mbox range */ -#define HIF_MBOX0_EXTENDED_BASE_ADDR_AR6003_V1 0x4000 -#define HIF_MBOX0_EXTENDED_WIDTH_AR6003_V1 (12*1024) - - /* GMBOX addresses */ -#define HIF_GMBOX_BASE_ADDR 0x7000 -#define HIF_GMBOX_WIDTH 0x4000 - - /* for SDIO we recommend a 128-byte block size */ -#define HIF_DEFAULT_IO_BLOCK_SIZE 128 - - /* set extended MBOX window information for SDIO interconnects */ -static INLINE void SetExtendedMboxWindowInfo(u16 Manfid, struct hif_device_mbox_info *pInfo) -{ - switch (Manfid & MANUFACTURER_ID_AR6K_BASE_MASK) { - case MANUFACTURER_ID_AR6002_BASE : - /* MBOX 0 has an extended range */ - pInfo->MboxProp[0].ExtendedAddress = HIF_MBOX0_EXTENDED_BASE_ADDR; - pInfo->MboxProp[0].ExtendedSize = HIF_MBOX0_EXTENDED_WIDTH_AR6002; - break; - case MANUFACTURER_ID_AR6003_BASE : - /* MBOX 0 has an extended range */ - pInfo->MboxProp[0].ExtendedAddress = HIF_MBOX0_EXTENDED_BASE_ADDR_AR6003_V1; - pInfo->MboxProp[0].ExtendedSize = HIF_MBOX0_EXTENDED_WIDTH_AR6003_V1; - pInfo->GMboxAddress = HIF_GMBOX_BASE_ADDR; - pInfo->GMboxSize = HIF_GMBOX_WIDTH; - break; - default: - A_ASSERT(false); - break; - } -} - -/* special CCCR (func 0) registers */ - -#define CCCR_SDIO_IRQ_MODE_REG 0xF0 /* interrupt mode register */ -#define SDIO_IRQ_MODE_ASYNC_4BIT_IRQ (1 << 0) /* mode to enable special 4-bit interrupt assertion without clock*/ - -#endif /*HIF_SDIO_COMMON_H_*/ diff --git a/drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h b/drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h deleted file mode 100644 index ed7ad4786f5..00000000000 --- a/drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h +++ /dev/null @@ -1,131 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// internal header file for hif layer -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HIF_INTERNAL_H_ -#define _HIF_INTERNAL_H_ - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include "hif.h" -#include "../../../common/hif_sdio_common.h" -#include -#define HIF_LINUX_MMC_SCATTER_SUPPORT - -#define BUS_REQUEST_MAX_NUM 64 - -#define SDIO_CLOCK_FREQUENCY_DEFAULT 25000000 -#define SDWLAN_ENABLE_DISABLE_TIMEOUT 20 -#define FLAGS_CARD_ENAB 0x02 -#define FLAGS_CARD_IRQ_UNMSK 0x04 - -#define HIF_MBOX_BLOCK_SIZE HIF_DEFAULT_IO_BLOCK_SIZE -#define HIF_MBOX0_BLOCK_SIZE 1 -#define HIF_MBOX1_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE -#define HIF_MBOX2_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE -#define HIF_MBOX3_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE - -typedef struct bus_request { - struct bus_request *next; /* link list of available requests */ - struct bus_request *inusenext; /* link list of in use requests */ - struct semaphore sem_req; - u32 address; /* request data */ - u8 *buffer; - u32 length; - u32 request; - void *context; - int status; - struct hif_scatter_req_priv *pScatterReq; /* this request is a scatter request */ -} BUS_REQUEST; - -struct hif_device { - struct sdio_func *func; - spinlock_t asynclock; - struct task_struct* async_task; /* task to handle async commands */ - struct semaphore sem_async; /* wake up for async task */ - int async_shutdown; /* stop the async task */ - struct completion async_completion; /* thread completion */ - BUS_REQUEST *asyncreq; /* request for async tasklet */ - BUS_REQUEST *taskreq; /* async tasklet data */ - spinlock_t lock; - BUS_REQUEST *s_busRequestFreeQueue; /* free list */ - BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM]; /* available bus requests */ - void *claimedContext; - HTC_CALLBACKS htcCallbacks; - u8 *dma_buffer; - struct dl_list ScatterReqHead; /* scatter request list head */ - bool scatter_enabled; /* scatter enabled flag */ - bool is_suspend; - bool is_disabled; - atomic_t irqHandling; - HIF_DEVICE_POWER_CHANGE_TYPE powerConfig; - const struct sdio_device_id *id; -}; - -#define HIF_DMA_BUFFER_SIZE (32 * 1024) -#define CMD53_FIXED_ADDRESS 1 -#define CMD53_INCR_ADDRESS 2 - -BUS_REQUEST *hifAllocateBusRequest(struct hif_device *device); -void hifFreeBusRequest(struct hif_device *device, BUS_REQUEST *busrequest); -void AddToAsyncList(struct hif_device *device, BUS_REQUEST *busrequest); - -#ifdef HIF_LINUX_MMC_SCATTER_SUPPORT - -#define MAX_SCATTER_REQUESTS 4 -#define MAX_SCATTER_ENTRIES_PER_REQ 16 -#define MAX_SCATTER_REQ_TRANSFER_SIZE 32*1024 - -struct hif_scatter_req_priv { - struct hif_scatter_req *pHifScatterReq; /* HIF scatter request with allocated entries */ - struct hif_device *device; /* this device */ - BUS_REQUEST *busrequest; /* request associated with request */ - /* scatter list for linux */ - struct scatterlist sgentries[MAX_SCATTER_ENTRIES_PER_REQ]; -}; - -#define ATH_DEBUG_SCATTER ATH_DEBUG_MAKE_MODULE_MASK(0) - -int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo); -void CleanupHIFScatterResources(struct hif_device *device); -int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest); - -#else // HIF_LINUX_MMC_SCATTER_SUPPORT - -static inline int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo) -{ - return A_ENOTSUP; -} - -static inline int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest) -{ - return A_ENOTSUP; -} - -#define CleanupHIFScatterResources(d) { } - -#endif // HIF_LINUX_MMC_SCATTER_SUPPORT - -#endif // _HIF_INTERNAL_H_ - diff --git a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c b/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c deleted file mode 100644 index 5f5d67720fa..00000000000 --- a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c +++ /dev/null @@ -1,1273 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HIF layer reference implementation for Linux Native MMC stack -// -// Author(s): ="Atheros" -//============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include - -/* by default setup a bounce buffer for the data packets, if the underlying host controller driver - does not use DMA you may be able to skip this step and save the memory allocation and transfer time */ -#define HIF_USE_DMA_BOUNCE_BUFFER 1 -#include "hif_internal.h" -#define ATH_MODULE_NAME hif -#include "a_debug.h" -#include "hw/mbox_host_reg.h" - -#if HIF_USE_DMA_BOUNCE_BUFFER -/* macro to check if DMA buffer is WORD-aligned and DMA-able. Most host controllers assume the - * buffer is DMA'able and will bug-check otherwise (i.e. buffers on the stack). - * virt_addr_valid check fails on stack memory. - */ -#define BUFFER_NEEDS_BOUNCE(buffer) (((unsigned long)(buffer) & 0x3) || !virt_addr_valid((buffer))) -#else -#define BUFFER_NEEDS_BOUNCE(buffer) (false) -#endif - -/* ATHENV */ -#if defined(CONFIG_PM) -#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev) -#define to_sdio_driver(d) container_of(d, struct sdio_driver, drv) -#endif /* CONFIG_PM */ -static void delHifDevice(struct hif_device * device); -static int Func0_CMD52WriteByte(struct mmc_card *card, unsigned int address, unsigned char byte); -static int Func0_CMD52ReadByte(struct mmc_card *card, unsigned int address, unsigned char *byte); - -static int hifEnableFunc(struct hif_device *device, struct sdio_func *func); -static int hifDisableFunc(struct hif_device *device, struct sdio_func *func); -OSDRV_CALLBACKS osdrvCallbacks; - -int reset_sdio_on_unload = 0; -module_param(reset_sdio_on_unload, int, 0644); - -extern u32 nohifscattersupport; - -static struct hif_device *ath6kl_alloc_hifdev(struct sdio_func *func) -{ - struct hif_device *hifdevice; - - hifdevice = kzalloc(sizeof(struct hif_device), GFP_KERNEL); - -#if HIF_USE_DMA_BOUNCE_BUFFER - hifdevice->dma_buffer = kmalloc(HIF_DMA_BUFFER_SIZE, GFP_KERNEL); -#endif - hifdevice->func = func; - hifdevice->powerConfig = HIF_DEVICE_POWER_UP; - sdio_set_drvdata(func, hifdevice); - - return hifdevice; -} - -static struct hif_device *ath6kl_get_hifdev(struct sdio_func *func) -{ - return (struct hif_device *) sdio_get_drvdata(func); -} - -static const struct sdio_device_id ath6kl_hifdev_ids[] = { - { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x0)) }, - { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x1)) }, - { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0)) }, - { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1)) }, - { /* null */ }, -}; - -MODULE_DEVICE_TABLE(sdio, ath6kl_hifdev_ids); - -static int ath6kl_hifdev_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - int ret; - struct hif_device *device; - int count; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, - ("ath6kl: Function: 0x%X, Vendor ID: 0x%X, " - "Device ID: 0x%X, block size: 0x%X/0x%X\n", - func->num, func->vendor, func->device, - func->max_blksize, func->cur_blksize)); - - ath6kl_alloc_hifdev(func); - device = ath6kl_get_hifdev(func); - - device->id = id; - device->is_disabled = true; - - spin_lock_init(&device->lock); - spin_lock_init(&device->asynclock); - - DL_LIST_INIT(&device->ScatterReqHead); - - /* Try to allow scatter unless globally overridden */ - if (!nohifscattersupport) - device->scatter_enabled = true; - - A_MEMZERO(device->busRequest, sizeof(device->busRequest)); - - for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) { - sema_init(&device->busRequest[count].sem_req, 0); - hifFreeBusRequest(device, &device->busRequest[count]); - } - - sema_init(&device->sem_async, 0); - - ret = hifEnableFunc(device, func); - - return ret; -} - -static void ath6kl_hifdev_remove(struct sdio_func *func) -{ - int status = 0; - struct hif_device *device; - - device = ath6kl_get_hifdev(func); - if (device->claimedContext != NULL) - status = osdrvCallbacks. - deviceRemovedHandler(device->claimedContext, device); - - if (device->is_disabled) - device->is_disabled = false; - else - status = hifDisableFunc(device, func); - - CleanupHIFScatterResources(device); - - delHifDevice(device); -} - -#if defined(CONFIG_PM) -static int ath6kl_hifdev_suspend(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - int status = 0; - struct hif_device *device; - - device = ath6kl_get_hifdev(func); - - if (device && device->claimedContext && - osdrvCallbacks.deviceSuspendHandler) { - /* set true first for PowerStateChangeNotify(..) */ - device->is_suspend = true; - status = osdrvCallbacks. - deviceSuspendHandler(device->claimedContext); - if (status) - device->is_suspend = false; - } - - CleanupHIFScatterResources(device); - - switch (status) { - case 0: - return 0; - case A_EBUSY: - /* Hack for kernel in order to support deep sleep and wow */ - return -EBUSY; - default: - return -1; - } -} - -static int ath6kl_hifdev_resume(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - int status = 0; - struct hif_device *device; - - device = ath6kl_get_hifdev(func); - if (device && device->claimedContext && - osdrvCallbacks.deviceSuspendHandler) { - status = osdrvCallbacks. - deviceResumeHandler(device->claimedContext); - if (status == 0) - device->is_suspend = false; - } - - return status; -} - -static const struct dev_pm_ops ath6kl_hifdev_pmops = { - .suspend = ath6kl_hifdev_suspend, - .resume = ath6kl_hifdev_resume, -}; -#endif /* CONFIG_PM */ - -static struct sdio_driver ath6kl_hifdev_driver = { - .name = "ath6kl_hifdev", - .id_table = ath6kl_hifdev_ids, - .probe = ath6kl_hifdev_probe, - .remove = ath6kl_hifdev_remove, -#if defined(CONFIG_PM) - .drv = { - .pm = &ath6kl_hifdev_pmops, - }, -#endif -}; - -/* make sure we only unregister when registered. */ -static int registered = 0; - -extern u32 onebitmode; -extern u32 busspeedlow; -extern u32 debughif; - -static void ResetAllCards(void); - -#ifdef DEBUG - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(hif, - "hif", - "(Linux MMC) Host Interconnect Framework", - ATH_DEBUG_MASK_DEFAULTS, - 0, - NULL); - -#endif - - -/* ------ Functions ------ */ -int HIFInit(OSDRV_CALLBACKS *callbacks) -{ - int r; - AR_DEBUG_ASSERT(callbacks != NULL); - - A_REGISTER_MODULE_DEBUG_INFO(hif); - - /* store the callback handlers */ - osdrvCallbacks = *callbacks; - - /* Register with bus driver core */ - registered = 1; - - r = sdio_register_driver(&ath6kl_hifdev_driver); - if (r < 0) - return r; - - return 0; -} - -static int -__HIFReadWrite(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length, - u32 request, - void *context) -{ - u8 opcode; - int status = 0; - int ret; - u8 *tbuffer; - bool bounced = false; - - AR_DEBUG_ASSERT(device != NULL); - AR_DEBUG_ASSERT(device->func != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Device: 0x%p, buffer:0x%p (addr:0x%X)\n", - device, buffer, address)); - - do { - if (request & HIF_EXTENDED_IO) { - //AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Command type: CMD53\n")); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: Invalid command type: 0x%08x\n", request)); - status = A_EINVAL; - break; - } - - if (request & HIF_BLOCK_BASIS) { - /* round to whole block length size */ - length = (length / HIF_MBOX_BLOCK_SIZE) * HIF_MBOX_BLOCK_SIZE; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, - ("AR6000: Block mode (BlockLen: %d)\n", - length)); - } else if (request & HIF_BYTE_BASIS) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, - ("AR6000: Byte mode (BlockLen: %d)\n", - length)); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: Invalid data mode: 0x%08x\n", request)); - status = A_EINVAL; - break; - } - -#if 0 - /* useful for checking register accesses */ - if (length & 0x3) { - A_PRINTF(KERN_ALERT"AR6000: HIF (%s) is not a multiple of 4 bytes, addr:0x%X, len:%d\n", - request & HIF_WRITE ? "write":"read", address, length); - } -#endif - - if (request & HIF_WRITE) { - if ((address >= HIF_MBOX_START_ADDR(0)) && - (address <= HIF_MBOX_END_ADDR(3))) - { - - AR_DEBUG_ASSERT(length <= HIF_MBOX_WIDTH); - - /* - * Mailbox write. Adjust the address so that the last byte - * falls on the EOM address. - */ - address += (HIF_MBOX_WIDTH - length); - } - } - - if (request & HIF_FIXED_ADDRESS) { - opcode = CMD53_FIXED_ADDRESS; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Address mode: Fixed 0x%X\n", address)); - } else if (request & HIF_INCREMENTAL_ADDRESS) { - opcode = CMD53_INCR_ADDRESS; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Address mode: Incremental 0x%X\n", address)); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: Invalid address mode: 0x%08x\n", request)); - status = A_EINVAL; - break; - } - - if (request & HIF_WRITE) { -#if HIF_USE_DMA_BOUNCE_BUFFER - if (BUFFER_NEEDS_BOUNCE(buffer)) { - AR_DEBUG_ASSERT(device->dma_buffer != NULL); - tbuffer = device->dma_buffer; - /* copy the write data to the dma buffer */ - AR_DEBUG_ASSERT(length <= HIF_DMA_BUFFER_SIZE); - memcpy(tbuffer, buffer, length); - bounced = true; - } else { - tbuffer = buffer; - } -#else - tbuffer = buffer; -#endif - if (opcode == CMD53_FIXED_ADDRESS) { - ret = sdio_writesb(device->func, address, tbuffer, length); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: writesb ret=%d address: 0x%X, len: %d, 0x%X\n", - ret, address, length, *(int *)tbuffer)); - } else { - ret = sdio_memcpy_toio(device->func, address, tbuffer, length); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: writeio ret=%d address: 0x%X, len: %d, 0x%X\n", - ret, address, length, *(int *)tbuffer)); - } - } else if (request & HIF_READ) { -#if HIF_USE_DMA_BOUNCE_BUFFER - if (BUFFER_NEEDS_BOUNCE(buffer)) { - AR_DEBUG_ASSERT(device->dma_buffer != NULL); - AR_DEBUG_ASSERT(length <= HIF_DMA_BUFFER_SIZE); - tbuffer = device->dma_buffer; - bounced = true; - } else { - tbuffer = buffer; - } -#else - tbuffer = buffer; -#endif - if (opcode == CMD53_FIXED_ADDRESS) { - ret = sdio_readsb(device->func, tbuffer, address, length); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: readsb ret=%d address: 0x%X, len: %d, 0x%X\n", - ret, address, length, *(int *)tbuffer)); - } else { - ret = sdio_memcpy_fromio(device->func, tbuffer, address, length); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: readio ret=%d address: 0x%X, len: %d, 0x%X\n", - ret, address, length, *(int *)tbuffer)); - } -#if HIF_USE_DMA_BOUNCE_BUFFER - if (bounced) { - /* copy the read data from the dma buffer */ - memcpy(buffer, tbuffer, length); - } -#endif - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: Invalid direction: 0x%08x\n", request)); - status = A_EINVAL; - break; - } - - if (ret) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: SDIO bus operation failed! MMC stack returned : %d \n", ret)); - status = A_ERROR; - } - } while (false); - - return status; -} - -void AddToAsyncList(struct hif_device *device, BUS_REQUEST *busrequest) -{ - unsigned long flags; - BUS_REQUEST *async; - BUS_REQUEST *active; - - spin_lock_irqsave(&device->asynclock, flags); - active = device->asyncreq; - if (active == NULL) { - device->asyncreq = busrequest; - device->asyncreq->inusenext = NULL; - } else { - for (async = device->asyncreq; - async != NULL; - async = async->inusenext) { - active = async; - } - active->inusenext = busrequest; - busrequest->inusenext = NULL; - } - spin_unlock_irqrestore(&device->asynclock, flags); -} - - -/* queue a read/write request */ -int -HIFReadWrite(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length, - u32 request, - void *context) -{ - int status = 0; - BUS_REQUEST *busrequest; - - - AR_DEBUG_ASSERT(device != NULL); - AR_DEBUG_ASSERT(device->func != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Device: %p addr:0x%X\n", device,address)); - - do { - if ((request & HIF_ASYNCHRONOUS) || (request & HIF_SYNCHRONOUS)){ - /* serialize all requests through the async thread */ - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Execution mode: %s\n", - (request & HIF_ASYNCHRONOUS)?"Async":"Synch")); - busrequest = hifAllocateBusRequest(device); - if (busrequest == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: no async bus requests available (%s, addr:0x%X, len:%d) \n", - request & HIF_READ ? "READ":"WRITE", address, length)); - return A_ERROR; - } - busrequest->address = address; - busrequest->buffer = buffer; - busrequest->length = length; - busrequest->request = request; - busrequest->context = context; - - AddToAsyncList(device, busrequest); - - if (request & HIF_SYNCHRONOUS) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: queued sync req: 0x%lX\n", (unsigned long)busrequest)); - - /* wait for completion */ - up(&device->sem_async); - if (down_interruptible(&busrequest->sem_req) != 0) { - /* interrupted, exit */ - return A_ERROR; - } else { - int status = busrequest->status; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: sync return freeing 0x%lX: 0x%X\n", - (unsigned long)busrequest, busrequest->status)); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: freeing req: 0x%X\n", (unsigned int)request)); - hifFreeBusRequest(device, busrequest); - return status; - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: queued async req: 0x%lX\n", (unsigned long)busrequest)); - up(&device->sem_async); - return A_PENDING; - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: Invalid execution mode: 0x%08x\n", (unsigned int)request)); - status = A_EINVAL; - break; - } - } while(0); - - return status; -} -/* thread to serialize all requests, both sync and async */ -static int async_task(void *param) - { - struct hif_device *device; - BUS_REQUEST *request; - int status; - unsigned long flags; - - device = (struct hif_device *)param; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task\n")); - set_current_state(TASK_INTERRUPTIBLE); - while(!device->async_shutdown) { - /* wait for work */ - if (down_interruptible(&device->sem_async) != 0) { - /* interrupted, exit */ - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task interrupted\n")); - break; - } - if (device->async_shutdown) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task stopping\n")); - break; - } - /* we want to hold the host over multiple cmds if possible, but holding the host blocks card interrupts */ - sdio_claim_host(device->func); - spin_lock_irqsave(&device->asynclock, flags); - /* pull the request to work on */ - while (device->asyncreq != NULL) { - request = device->asyncreq; - if (request->inusenext != NULL) { - device->asyncreq = request->inusenext; - } else { - device->asyncreq = NULL; - } - spin_unlock_irqrestore(&device->asynclock, flags); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task processing req: 0x%lX\n", (unsigned long)request)); - - if (request->pScatterReq != NULL) { - A_ASSERT(device->scatter_enabled); - /* this is a queued scatter request, pass the request to scatter routine which - * executes it synchronously, note, no need to free the request since scatter requests - * are maintained on a separate list */ - status = DoHifReadWriteScatter(device,request); - } else { - /* call HIFReadWrite in sync mode to do the work */ - status = __HIFReadWrite(device, request->address, request->buffer, - request->length, request->request & ~HIF_SYNCHRONOUS, NULL); - if (request->request & HIF_ASYNCHRONOUS) { - void *context = request->context; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task freeing req: 0x%lX\n", (unsigned long)request)); - hifFreeBusRequest(device, request); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task completion routine req: 0x%lX\n", (unsigned long)request)); - device->htcCallbacks.rwCompletionHandler(context, status); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task upping req: 0x%lX\n", (unsigned long)request)); - request->status = status; - up(&request->sem_req); - } - } - spin_lock_irqsave(&device->asynclock, flags); - } - spin_unlock_irqrestore(&device->asynclock, flags); - sdio_release_host(device->func); - } - - complete_and_exit(&device->async_completion, 0); - return 0; -} - -static s32 IssueSDCommand(struct hif_device *device, u32 opcode, u32 arg, u32 flags, u32 *resp) -{ - struct mmc_command cmd; - s32 err; - struct mmc_host *host; - struct sdio_func *func; - - func = device->func; - host = func->card->host; - - memset(&cmd, 0, sizeof(struct mmc_command)); - cmd.opcode = opcode; - cmd.arg = arg; - cmd.flags = flags; - err = mmc_wait_for_cmd(host, &cmd, 3); - - if ((!err) && (resp)) { - *resp = cmd.resp[0]; - } - - return err; -} - -int ReinitSDIO(struct hif_device *device) -{ - s32 err; - struct mmc_host *host; - struct mmc_card *card; - struct sdio_func *func; - u8 cmd52_resp; - u32 clock; - - func = device->func; - card = func->card; - host = card->host; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +ReinitSDIO \n")); - sdio_claim_host(func); - - do { - if (!device->is_suspend) { - u32 resp; - u16 rca; - u32 i; - int bit = fls(host->ocr_avail) - 1; - /* emulate the mmc_power_up(...) */ - host->ios.vdd = bit; - host->ios.chip_select = MMC_CS_DONTCARE; - host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; - host->ios.power_mode = MMC_POWER_UP; - host->ios.bus_width = MMC_BUS_WIDTH_1; - host->ios.timing = MMC_TIMING_LEGACY; - host->ops->set_ios(host, &host->ios); - /* - * This delay should be sufficient to allow the power supply - * to reach the minimum voltage. - */ - msleep(2); - - host->ios.clock = host->f_min; - host->ios.power_mode = MMC_POWER_ON; - host->ops->set_ios(host, &host->ios); - - /* - * This delay must be at least 74 clock sizes, or 1 ms, or the - * time required to reach a stable voltage. - */ - msleep(2); - - /* Issue CMD0. Goto idle state */ - host->ios.chip_select = MMC_CS_HIGH; - host->ops->set_ios(host, &host->ios); - msleep(1); - err = IssueSDCommand(device, MMC_GO_IDLE_STATE, 0, (MMC_RSP_NONE | MMC_CMD_BC), NULL); - host->ios.chip_select = MMC_CS_DONTCARE; - host->ops->set_ios(host, &host->ios); - msleep(1); - host->use_spi_crc = 0; - - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD0 failed : %d \n",err)); - break; - } - - if (!host->ocr) { - /* Issue CMD5, arg = 0 */ - err = IssueSDCommand(device, SD_IO_SEND_OP_COND, 0, (MMC_RSP_R4 | MMC_CMD_BCR), &resp); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD5 failed : %d \n",err)); - break; - } - host->ocr = resp; - } - - /* Issue CMD5, arg = ocr. Wait till card is ready */ - for (i=0;i<100;i++) { - err = IssueSDCommand(device, SD_IO_SEND_OP_COND, host->ocr, (MMC_RSP_R4 | MMC_CMD_BCR), &resp); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD5 failed : %d \n",err)); - break; - } - if (resp & MMC_CARD_BUSY) { - break; - } - msleep(10); - } - - if ((i == 100) || (err)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: card in not ready : %d %d \n",i,err)); - break; - } - - /* Issue CMD3, get RCA */ - err = IssueSDCommand(device, SD_SEND_RELATIVE_ADDR, 0, MMC_RSP_R6 | MMC_CMD_BCR, &resp); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD3 failed : %d \n",err)); - break; - } - rca = resp >> 16; - host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; - host->ops->set_ios(host, &host->ios); - - /* Issue CMD7, select card */ - err = IssueSDCommand(device, MMC_SELECT_CARD, (rca << 16), MMC_RSP_R1 | MMC_CMD_AC, NULL); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD7 failed : %d \n",err)); - break; - } - } - - /* Enable high speed */ - if (card->host->caps & MMC_CAP_SD_HIGHSPEED) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("ReinitSDIO: Set high speed mode\n")); - err = Func0_CMD52ReadByte(card, SDIO_CCCR_SPEED, &cmd52_resp); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD52 read to CCCR speed register failed : %d \n",err)); - card->state &= ~MMC_STATE_HIGHSPEED; - /* no need to break */ - } else { - err = Func0_CMD52WriteByte(card, SDIO_CCCR_SPEED, (cmd52_resp | SDIO_SPEED_EHS)); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD52 write to CCCR speed register failed : %d \n",err)); - break; - } - mmc_card_set_highspeed(card); - host->ios.timing = MMC_TIMING_SD_HS; - host->ops->set_ios(host, &host->ios); - } - } - - /* Set clock */ - if (mmc_card_highspeed(card)) { - clock = 50000000; - } else { - clock = card->cis.max_dtr; - } - - if (clock > host->f_max) { - clock = host->f_max; - } - host->ios.clock = clock; - host->ops->set_ios(host, &host->ios); - - - if (card->host->caps & MMC_CAP_4_BIT_DATA) { - /* CMD52: Set bus width & disable card detect resistor */ - err = Func0_CMD52WriteByte(card, SDIO_CCCR_IF, SDIO_BUS_CD_DISABLE | SDIO_BUS_WIDTH_4BIT); - if (err) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("ReinitSDIO: CMD52 to set bus mode failed : %d \n",err)); - break; - } - host->ios.bus_width = MMC_BUS_WIDTH_4; - host->ops->set_ios(host, &host->ios); - } - } while (0); - - sdio_release_host(func); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -ReinitSDIO \n")); - - return (err) ? A_ERROR : 0; -} - -int -PowerStateChangeNotify(struct hif_device *device, HIF_DEVICE_POWER_CHANGE_TYPE config) -{ - int status = 0; -#if defined(CONFIG_PM) - struct sdio_func *func = device->func; - int old_reset_val; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +PowerStateChangeNotify %d\n", config)); - switch (config) { - case HIF_DEVICE_POWER_DOWN: - case HIF_DEVICE_POWER_CUT: - old_reset_val = reset_sdio_on_unload; - reset_sdio_on_unload = 1; - status = hifDisableFunc(device, func); - reset_sdio_on_unload = old_reset_val; - if (!device->is_suspend) { - struct mmc_host *host = func->card->host; - host->ios.clock = 0; - host->ios.vdd = 0; - host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; - host->ios.chip_select = MMC_CS_DONTCARE; - host->ios.power_mode = MMC_POWER_OFF; - host->ios.bus_width = MMC_BUS_WIDTH_1; - host->ios.timing = MMC_TIMING_LEGACY; - host->ops->set_ios(host, &host->ios); - } - break; - case HIF_DEVICE_POWER_UP: - if (device->powerConfig == HIF_DEVICE_POWER_CUT) { - status = ReinitSDIO(device); - } - if (status == 0) { - status = hifEnableFunc(device, func); - } - break; - } - device->powerConfig = config; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -PowerStateChangeNotify\n")); -#endif - return status; -} - -int -HIFConfigureDevice(struct hif_device *device, HIF_DEVICE_CONFIG_OPCODE opcode, - void *config, u32 configLen) -{ - u32 count; - int status = 0; - - switch(opcode) { - case HIF_DEVICE_GET_MBOX_BLOCK_SIZE: - ((u32 *)config)[0] = HIF_MBOX0_BLOCK_SIZE; - ((u32 *)config)[1] = HIF_MBOX1_BLOCK_SIZE; - ((u32 *)config)[2] = HIF_MBOX2_BLOCK_SIZE; - ((u32 *)config)[3] = HIF_MBOX3_BLOCK_SIZE; - break; - - case HIF_DEVICE_GET_MBOX_ADDR: - for (count = 0; count < 4; count ++) { - ((u32 *)config)[count] = HIF_MBOX_START_ADDR(count); - } - - if (configLen >= sizeof(struct hif_device_mbox_info)) { - SetExtendedMboxWindowInfo((u16)device->func->device, - (struct hif_device_mbox_info *)config); - } - - break; - case HIF_DEVICE_GET_IRQ_PROC_MODE: - *((HIF_DEVICE_IRQ_PROCESSING_MODE *)config) = HIF_DEVICE_IRQ_SYNC_ONLY; - break; - case HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: - if (!device->scatter_enabled) { - return A_ENOTSUP; - } - status = SetupHIFScatterSupport(device, (struct hif_device_scatter_support_info *)config); - if (status) { - device->scatter_enabled = false; - } - break; - case HIF_DEVICE_GET_OS_DEVICE: - /* pass back a pointer to the SDIO function's "dev" struct */ - ((struct hif_device_os_device_info *)config)->pOSDevice = &device->func->dev; - break; - case HIF_DEVICE_POWER_STATE_CHANGE: - status = PowerStateChangeNotify(device, *(HIF_DEVICE_POWER_CHANGE_TYPE *)config); - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - ("AR6000: Unsupported configuration opcode: %d\n", opcode)); - status = A_ERROR; - } - - return status; -} - -void -HIFShutDownDevice(struct hif_device *device) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +HIFShutDownDevice\n")); - if (device != NULL) { - AR_DEBUG_ASSERT(device->func != NULL); - } else { - /* since we are unloading the driver anyways, reset all cards in case the SDIO card - * is externally powered and we are unloading the SDIO stack. This avoids the problem when - * the SDIO stack is reloaded and attempts are made to re-enumerate a card that is already - * enumerated */ - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFShutDownDevice, resetting\n")); - ResetAllCards(); - - /* Unregister with bus driver core */ - if (registered) { - registered = 0; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, - ("AR6000: Unregistering with the bus driver\n")); - sdio_unregister_driver(&ath6kl_hifdev_driver); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, - ("AR6000: Unregistered\n")); - } - } - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -HIFShutDownDevice\n")); -} - -static void -hifIRQHandler(struct sdio_func *func) -{ - int status; - struct hif_device *device; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifIRQHandler\n")); - - device = ath6kl_get_hifdev(func); - atomic_set(&device->irqHandling, 1); - /* release the host during ints so we can pick it back up when we process cmds */ - sdio_release_host(device->func); - status = device->htcCallbacks.dsrHandler(device->htcCallbacks.context); - sdio_claim_host(device->func); - atomic_set(&device->irqHandling, 0); - AR_DEBUG_ASSERT(status == 0 || status == A_ECANCELED); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifIRQHandler\n")); -} - -/* handle HTC startup via thread*/ -static int startup_task(void *param) -{ - struct hif_device *device; - - device = (struct hif_device *)param; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: call HTC from startup_task\n")); - /* start up inform DRV layer */ - if ((osdrvCallbacks.deviceInsertedHandler(osdrvCallbacks.context,device)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Device rejected\n")); - } - return 0; -} - -#if defined(CONFIG_PM) -static int enable_task(void *param) -{ - struct hif_device *device; - device = (struct hif_device *)param; - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: call from resume_task\n")); - - /* start up inform DRV layer */ - if (device && - device->claimedContext && - osdrvCallbacks.devicePowerChangeHandler && - osdrvCallbacks.devicePowerChangeHandler(device->claimedContext, HIF_DEVICE_POWER_UP) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Device rejected\n")); - } - - return 0; -} -#endif - -void -HIFAckInterrupt(struct hif_device *device) -{ - AR_DEBUG_ASSERT(device != NULL); - - /* Acknowledge our function IRQ */ -} - -void -HIFUnMaskInterrupt(struct hif_device *device) -{ - int ret; - - AR_DEBUG_ASSERT(device != NULL); - AR_DEBUG_ASSERT(device->func != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFUnMaskInterrupt\n")); - - /* Register the IRQ Handler */ - sdio_claim_host(device->func); - ret = sdio_claim_irq(device->func, hifIRQHandler); - sdio_release_host(device->func); - AR_DEBUG_ASSERT(ret == 0); -} - -void HIFMaskInterrupt(struct hif_device *device) -{ - int ret; - AR_DEBUG_ASSERT(device != NULL); - AR_DEBUG_ASSERT(device->func != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFMaskInterrupt\n")); - - /* Mask our function IRQ */ - sdio_claim_host(device->func); - while (atomic_read(&device->irqHandling)) { - sdio_release_host(device->func); - schedule_timeout(HZ/10); - sdio_claim_host(device->func); - } - ret = sdio_release_irq(device->func); - sdio_release_host(device->func); - AR_DEBUG_ASSERT(ret == 0); -} - -BUS_REQUEST *hifAllocateBusRequest(struct hif_device *device) -{ - BUS_REQUEST *busrequest; - unsigned long flag; - - /* Acquire lock */ - spin_lock_irqsave(&device->lock, flag); - - /* Remove first in list */ - if((busrequest = device->s_busRequestFreeQueue) != NULL) - { - device->s_busRequestFreeQueue = busrequest->next; - } - /* Release lock */ - spin_unlock_irqrestore(&device->lock, flag); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: hifAllocateBusRequest: 0x%p\n", busrequest)); - return busrequest; -} - -void -hifFreeBusRequest(struct hif_device *device, BUS_REQUEST *busrequest) -{ - unsigned long flag; - - AR_DEBUG_ASSERT(busrequest != NULL); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: hifFreeBusRequest: 0x%p\n", busrequest)); - /* Acquire lock */ - spin_lock_irqsave(&device->lock, flag); - - - /* Insert first in list */ - busrequest->next = device->s_busRequestFreeQueue; - busrequest->inusenext = NULL; - device->s_busRequestFreeQueue = busrequest; - - /* Release lock */ - spin_unlock_irqrestore(&device->lock, flag); -} - -static int hifDisableFunc(struct hif_device *device, struct sdio_func *func) -{ - int ret; - int status = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifDisableFunc\n")); - device = ath6kl_get_hifdev(func); - if (!IS_ERR(device->async_task)) { - init_completion(&device->async_completion); - device->async_shutdown = 1; - up(&device->sem_async); - wait_for_completion(&device->async_completion); - device->async_task = NULL; - } - /* Disable the card */ - sdio_claim_host(device->func); - ret = sdio_disable_func(device->func); - if (ret) { - status = A_ERROR; - } - - if (reset_sdio_on_unload) { - /* reset the SDIO interface. This is useful in automated testing where the card - * does not need to be removed at the end of the test. It is expected that the user will - * also unload/reload the host controller driver to force the bus driver to re-enumerate the slot */ - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("AR6000: reseting SDIO card back to uninitialized state \n")); - - /* NOTE : sdio_f0_writeb() cannot be used here, that API only allows access - * to undefined registers in the range of: 0xF0-0xFF */ - - ret = Func0_CMD52WriteByte(device->func->card, SDIO_CCCR_ABORT, (1 << 3)); - if (ret) { - status = A_ERROR; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("AR6000: reset failed : %d \n",ret)); - } - } - - sdio_release_host(device->func); - - if (status == 0) { - device->is_disabled = true; - } - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifDisableFunc\n")); - - return status; -} - -static int hifEnableFunc(struct hif_device *device, struct sdio_func *func) -{ - struct task_struct* pTask; - const char *taskName = NULL; - int (*taskFunc)(void *) = NULL; - int ret = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifEnableFunc\n")); - device = ath6kl_get_hifdev(func); - - if (device->is_disabled) { - /* enable the SDIO function */ - sdio_claim_host(func); - - if ((device->id->device & MANUFACTURER_ID_AR6K_BASE_MASK) >= MANUFACTURER_ID_AR6003_BASE) { - /* enable 4-bit ASYNC interrupt on AR6003 or later devices */ - ret = Func0_CMD52WriteByte(func->card, CCCR_SDIO_IRQ_MODE_REG, SDIO_IRQ_MODE_ASYNC_4BIT_IRQ); - if (ret) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("AR6000: failed to enable 4-bit ASYNC IRQ mode %d \n",ret)); - sdio_release_host(func); - return ret; - } - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: 4-bit ASYNC IRQ mode enabled\n")); - } - /* give us some time to enable, in ms */ - func->enable_timeout = 100; - ret = sdio_enable_func(func); - if (ret) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), Unable to enable AR6K: 0x%X\n", - __FUNCTION__, ret)); - sdio_release_host(func); - return ret; - } - ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE); - sdio_release_host(func); - if (ret) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), Unable to set block size 0x%x AR6K: 0x%X\n", - __FUNCTION__, HIF_MBOX_BLOCK_SIZE, ret)); - return ret; - } - device->is_disabled = false; - /* create async I/O thread */ - if (!device->async_task) { - device->async_shutdown = 0; - device->async_task = kthread_create(async_task, - (void *)device, - "AR6K Async"); - if (IS_ERR(device->async_task)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), to create async task\n", __FUNCTION__)); - return -ENOMEM; - } - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: start async task\n")); - wake_up_process(device->async_task ); - } - } - - if (!device->claimedContext) { - taskFunc = startup_task; - taskName = "AR6K startup"; - ret = 0; -#if defined(CONFIG_PM) - } else { - taskFunc = enable_task; - taskName = "AR6K enable"; - ret = -ENOMEM; -#endif /* CONFIG_PM */ - } - /* create resume thread */ - pTask = kthread_create(taskFunc, (void *)device, taskName); - if (IS_ERR(pTask)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), to create enabel task\n", __FUNCTION__)); - return -ENOMEM; - } - wake_up_process(pTask); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifEnableFunc\n")); - - /* task will call the enable func, indicate pending */ - return ret; -} - -/* - * This should be moved to AR6K HTC layer. - */ -int hifWaitForPendingRecv(struct hif_device *device) -{ - s32 cnt = 10; - u8 host_int_status; - int status = 0; - - do { - while (atomic_read(&device->irqHandling)) { - /* wait until irq handler finished all the jobs */ - schedule_timeout(HZ/10); - } - /* check if there is any pending irq due to force done */ - host_int_status = 0; - status = HIFReadWrite(device, HOST_INT_STATUS_ADDRESS, - (u8 *)&host_int_status, sizeof(host_int_status), - HIF_RD_SYNC_BYTE_INC, NULL); - host_int_status = !status ? (host_int_status & (1 << 0)) : 0; - if (host_int_status) { - schedule(); /* schedule for next dsrHandler */ - } - } while (host_int_status && --cnt > 0); - - if (host_int_status && cnt == 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("AR6000: %s(), Unable clear up pending IRQ before the system suspended\n", __FUNCTION__)); - } - - return 0; -} - -static void -delHifDevice(struct hif_device * device) -{ - AR_DEBUG_ASSERT(device!= NULL); - AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: delHifDevice; 0x%p\n", device)); - kfree(device->dma_buffer); - kfree(device); -} - -static void ResetAllCards(void) -{ -} - -void HIFClaimDevice(struct hif_device *device, void *context) -{ - device->claimedContext = context; -} - -void HIFReleaseDevice(struct hif_device *device) -{ - device->claimedContext = NULL; -} - -int HIFAttachHTC(struct hif_device *device, HTC_CALLBACKS *callbacks) -{ - if (device->htcCallbacks.context != NULL) { - /* already in use! */ - return A_ERROR; - } - device->htcCallbacks = *callbacks; - return 0; -} - -void HIFDetachHTC(struct hif_device *device) -{ - A_MEMZERO(&device->htcCallbacks,sizeof(device->htcCallbacks)); -} - -#define SDIO_SET_CMD52_ARG(arg,rw,func,raw,address,writedata) \ - (arg) = (((rw) & 1) << 31) | \ - (((func) & 0x7) << 28) | \ - (((raw) & 1) << 27) | \ - (1 << 26) | \ - (((address) & 0x1FFFF) << 9) | \ - (1 << 8) | \ - ((writedata) & 0xFF) - -#define SDIO_SET_CMD52_READ_ARG(arg,func,address) \ - SDIO_SET_CMD52_ARG(arg,0,(func),0,address,0x00) -#define SDIO_SET_CMD52_WRITE_ARG(arg,func,address,value) \ - SDIO_SET_CMD52_ARG(arg,1,(func),0,address,value) - -static int Func0_CMD52WriteByte(struct mmc_card *card, unsigned int address, unsigned char byte) -{ - struct mmc_command ioCmd; - unsigned long arg; - - memset(&ioCmd,0,sizeof(ioCmd)); - SDIO_SET_CMD52_WRITE_ARG(arg,0,address,byte); - ioCmd.opcode = SD_IO_RW_DIRECT; - ioCmd.arg = arg; - ioCmd.flags = MMC_RSP_R5 | MMC_CMD_AC; - - return mmc_wait_for_cmd(card->host, &ioCmd, 0); -} - -static int Func0_CMD52ReadByte(struct mmc_card *card, unsigned int address, unsigned char *byte) -{ - struct mmc_command ioCmd; - unsigned long arg; - s32 err; - - memset(&ioCmd,0,sizeof(ioCmd)); - SDIO_SET_CMD52_READ_ARG(arg,0,address); - ioCmd.opcode = SD_IO_RW_DIRECT; - ioCmd.arg = arg; - ioCmd.flags = MMC_RSP_R5 | MMC_CMD_AC; - - err = mmc_wait_for_cmd(card->host, &ioCmd, 0); - - if ((!err) && (byte)) { - *byte = ioCmd.resp[0] & 0xFF; - } - - return err; -} diff --git a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif_scatter.c b/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif_scatter.c deleted file mode 100644 index 7516d913dab..00000000000 --- a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif_scatter.c +++ /dev/null @@ -1,393 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HIF scatter implementation -// -// Author(s): ="Atheros" -//============================================================================== - -#include -#include -#include -#include -#include -#include -#include "hif_internal.h" -#define ATH_MODULE_NAME hif -#include "a_debug.h" - -#ifdef HIF_LINUX_MMC_SCATTER_SUPPORT - -#define _CMD53_ARG_READ 0 -#define _CMD53_ARG_WRITE 1 -#define _CMD53_ARG_BLOCK_BASIS 1 -#define _CMD53_ARG_FIXED_ADDRESS 0 -#define _CMD53_ARG_INCR_ADDRESS 1 - -#define SDIO_SET_CMD53_ARG(arg,rw,func,mode,opcode,address,bytes_blocks) \ - (arg) = (((rw) & 1) << 31) | \ - (((func) & 0x7) << 28) | \ - (((mode) & 1) << 27) | \ - (((opcode) & 1) << 26) | \ - (((address) & 0x1FFFF) << 9) | \ - ((bytes_blocks) & 0x1FF) - -static void FreeScatterReq(struct hif_device *device, struct hif_scatter_req *pReq) -{ - unsigned long flag; - - spin_lock_irqsave(&device->lock, flag); - - DL_ListInsertTail(&device->ScatterReqHead, &pReq->ListLink); - - spin_unlock_irqrestore(&device->lock, flag); - -} - -static struct hif_scatter_req *AllocScatterReq(struct hif_device *device) -{ - struct dl_list *pItem; - unsigned long flag; - - spin_lock_irqsave(&device->lock, flag); - - pItem = DL_ListRemoveItemFromHead(&device->ScatterReqHead); - - spin_unlock_irqrestore(&device->lock, flag); - - if (pItem != NULL) { - return A_CONTAINING_STRUCT(pItem, struct hif_scatter_req, ListLink); - } - - return NULL; -} - - /* called by async task to perform the operation synchronously using direct MMC APIs */ -int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest) -{ - int i; - u8 rw; - u8 opcode; - struct mmc_request mmcreq; - struct mmc_command cmd; - struct mmc_data data; - struct hif_scatter_req_priv *pReqPriv; - struct hif_scatter_req *pReq; - int status = 0; - struct scatterlist *pSg; - - pReqPriv = busrequest->pScatterReq; - - A_ASSERT(pReqPriv != NULL); - - pReq = pReqPriv->pHifScatterReq; - - memset(&mmcreq, 0, sizeof(struct mmc_request)); - memset(&cmd, 0, sizeof(struct mmc_command)); - memset(&data, 0, sizeof(struct mmc_data)); - - data.blksz = HIF_MBOX_BLOCK_SIZE; - data.blocks = pReq->TotalLength / HIF_MBOX_BLOCK_SIZE; - - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: (%s) Address: 0x%X, (BlockLen: %d, BlockCount: %d) , (tot:%d,sg:%d)\n", - (pReq->Request & HIF_WRITE) ? "WRITE":"READ", pReq->Address, data.blksz, data.blocks, - pReq->TotalLength,pReq->ValidScatterEntries)); - - if (pReq->Request & HIF_WRITE) { - rw = _CMD53_ARG_WRITE; - data.flags = MMC_DATA_WRITE; - } else { - rw = _CMD53_ARG_READ; - data.flags = MMC_DATA_READ; - } - - if (pReq->Request & HIF_FIXED_ADDRESS) { - opcode = _CMD53_ARG_FIXED_ADDRESS; - } else { - opcode = _CMD53_ARG_INCR_ADDRESS; - } - - /* fill SG entries */ - pSg = pReqPriv->sgentries; - sg_init_table(pSg, pReq->ValidScatterEntries); - - /* assemble SG list */ - for (i = 0 ; i < pReq->ValidScatterEntries ; i++, pSg++) { - /* setup each sg entry */ - if ((unsigned long)pReq->ScatterList[i].pBuffer & 0x3) { - /* note some scatter engines can handle unaligned buffers, print this - * as informational only */ - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, - ("HIF: (%s) Scatter Buffer is unaligned 0x%lx\n", - pReq->Request & HIF_WRITE ? "WRITE":"READ", - (unsigned long)pReq->ScatterList[i].pBuffer)); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, (" %d: Addr:0x%lX, Len:%d \n", - i,(unsigned long)pReq->ScatterList[i].pBuffer,pReq->ScatterList[i].Length)); - - sg_set_buf(pSg, pReq->ScatterList[i].pBuffer, pReq->ScatterList[i].Length); - } - /* set scatter-gather table for request */ - data.sg = pReqPriv->sgentries; - data.sg_len = pReq->ValidScatterEntries; - /* set command argument */ - SDIO_SET_CMD53_ARG(cmd.arg, - rw, - device->func->num, - _CMD53_ARG_BLOCK_BASIS, - opcode, - pReq->Address, - data.blocks); - - cmd.opcode = SD_IO_RW_EXTENDED; - cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; - - mmcreq.cmd = &cmd; - mmcreq.data = &data; - - mmc_set_data_timeout(&data, device->func->card); - /* synchronous call to process request */ - mmc_wait_for_req(device->func->card->host, &mmcreq); - - if (cmd.error) { - status = A_ERROR; - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF-SCATTER: cmd error: %d \n",cmd.error)); - } - - if (data.error) { - status = A_ERROR; - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF-SCATTER: data error: %d \n",data.error)); - } - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF-SCATTER: FAILED!!! (%s) Address: 0x%X, Block mode (BlockLen: %d, BlockCount: %d)\n", - (pReq->Request & HIF_WRITE) ? "WRITE":"READ",pReq->Address, data.blksz, data.blocks)); - } - - /* set completion status, fail or success */ - pReq->CompletionStatus = status; - - if (pReq->Request & HIF_ASYNCHRONOUS) { - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: async_task completion routine req: 0x%lX (%d)\n",(unsigned long)busrequest, status)); - /* complete the request */ - A_ASSERT(pReq->CompletionRoutine != NULL); - pReq->CompletionRoutine(pReq); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER async_task upping busrequest : 0x%lX (%d)\n", (unsigned long)busrequest,status)); - /* signal wait */ - up(&busrequest->sem_req); - } - - return status; -} - - /* callback to issue a read-write scatter request */ -static int HifReadWriteScatter(struct hif_device *device, struct hif_scatter_req *pReq) -{ - int status = A_EINVAL; - u32 request = pReq->Request; - struct hif_scatter_req_priv *pReqPriv = (struct hif_scatter_req_priv *)pReq->HIFPrivate[0]; - - do { - - A_ASSERT(pReqPriv != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: total len: %d Scatter Entries: %d\n", - pReq->TotalLength, pReq->ValidScatterEntries)); - - if (!(request & HIF_EXTENDED_IO)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("HIF-SCATTER: Invalid command type: 0x%08x\n", request)); - break; - } - - if (!(request & (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS))) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("HIF-SCATTER: Invalid execution mode: 0x%08x\n", request)); - break; - } - - if (!(request & HIF_BLOCK_BASIS)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("HIF-SCATTER: Invalid data mode: 0x%08x\n", request)); - break; - } - - if (pReq->TotalLength > MAX_SCATTER_REQ_TRANSFER_SIZE) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, - ("HIF-SCATTER: Invalid length: %d \n", pReq->TotalLength)); - break; - } - - if (pReq->TotalLength == 0) { - A_ASSERT(false); - break; - } - - /* add bus request to the async list for the async I/O thread to process */ - AddToAsyncList(device, pReqPriv->busrequest); - - if (request & HIF_SYNCHRONOUS) { - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued sync req: 0x%lX\n", (unsigned long)pReqPriv->busrequest)); - /* signal thread and wait */ - up(&device->sem_async); - if (down_interruptible(&pReqPriv->busrequest->sem_req) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,("HIF-SCATTER: interrupted! \n")); - /* interrupted, exit */ - status = A_ERROR; - break; - } else { - status = pReq->CompletionStatus; - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued async req: 0x%lX\n", (unsigned long)pReqPriv->busrequest)); - /* wake thread, it will process and then take care of the async callback */ - up(&device->sem_async); - status = 0; - } - - } while (false); - - if (status && (request & HIF_ASYNCHRONOUS)) { - pReq->CompletionStatus = status; - pReq->CompletionRoutine(pReq); - status = 0; - } - - return status; -} - - /* setup of HIF scatter resources */ -int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo) -{ - int status = A_ERROR; - int i; - struct hif_scatter_req_priv *pReqPriv; - BUS_REQUEST *busrequest; - - do { - - /* check if host supports scatter requests and it meets our requirements */ - if (device->func->card->host->max_segs < MAX_SCATTER_ENTRIES_PER_REQ) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HIF-SCATTER : host only supports scatter of : %d entries, need: %d \n", - device->func->card->host->max_segs, MAX_SCATTER_ENTRIES_PER_REQ)); - status = A_ENOTSUP; - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("HIF-SCATTER Enabled: max scatter req : %d entries: %d \n", - MAX_SCATTER_REQUESTS, MAX_SCATTER_ENTRIES_PER_REQ)); - - for (i = 0; i < MAX_SCATTER_REQUESTS; i++) { - /* allocate the private request blob */ - pReqPriv = (struct hif_scatter_req_priv *)A_MALLOC(sizeof(struct hif_scatter_req_priv)); - if (NULL == pReqPriv) { - break; - } - A_MEMZERO(pReqPriv, sizeof(struct hif_scatter_req_priv)); - /* save the device instance*/ - pReqPriv->device = device; - /* allocate the scatter request */ - pReqPriv->pHifScatterReq = (struct hif_scatter_req *)A_MALLOC(sizeof(struct hif_scatter_req) + - (MAX_SCATTER_ENTRIES_PER_REQ - 1) * (sizeof(struct hif_scatter_item))); - - if (NULL == pReqPriv->pHifScatterReq) { - kfree(pReqPriv); - break; - } - /* just zero the main part of the scatter request */ - A_MEMZERO(pReqPriv->pHifScatterReq, sizeof(struct hif_scatter_req)); - /* back pointer to the private struct */ - pReqPriv->pHifScatterReq->HIFPrivate[0] = pReqPriv; - /* allocate a bus request for this scatter request */ - busrequest = hifAllocateBusRequest(device); - if (NULL == busrequest) { - kfree(pReqPriv->pHifScatterReq); - kfree(pReqPriv); - break; - } - /* assign the scatter request to this bus request */ - busrequest->pScatterReq = pReqPriv; - /* point back to the request */ - pReqPriv->busrequest = busrequest; - /* add it to the scatter pool */ - FreeScatterReq(device,pReqPriv->pHifScatterReq); - } - - if (i != MAX_SCATTER_REQUESTS) { - status = A_NO_MEMORY; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HIF-SCATTER : failed to alloc scatter resources !\n")); - break; - } - - /* set scatter function pointers */ - pInfo->pAllocateReqFunc = AllocScatterReq; - pInfo->pFreeReqFunc = FreeScatterReq; - pInfo->pReadWriteScatterFunc = HifReadWriteScatter; - pInfo->MaxScatterEntries = MAX_SCATTER_ENTRIES_PER_REQ; - pInfo->MaxTransferSizePerScatterReq = MAX_SCATTER_REQ_TRANSFER_SIZE; - - status = 0; - - } while (false); - - if (status) { - CleanupHIFScatterResources(device); - } - - return status; -} - - /* clean up scatter support */ -void CleanupHIFScatterResources(struct hif_device *device) -{ - struct hif_scatter_req_priv *pReqPriv; - struct hif_scatter_req *pReq; - - /* empty the free list */ - - while (1) { - - pReq = AllocScatterReq(device); - - if (NULL == pReq) { - break; - } - - pReqPriv = (struct hif_scatter_req_priv *)pReq->HIFPrivate[0]; - A_ASSERT(pReqPriv != NULL); - - if (pReqPriv->busrequest != NULL) { - pReqPriv->busrequest->pScatterReq = NULL; - /* free bus request */ - hifFreeBusRequest(device, pReqPriv->busrequest); - pReqPriv->busrequest = NULL; - } - - if (pReqPriv->pHifScatterReq != NULL) { - kfree(pReqPriv->pHifScatterReq); - pReqPriv->pHifScatterReq = NULL; - } - - kfree(pReqPriv); - } -} - -#endif // HIF_LINUX_MMC_SCATTER_SUPPORT diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k.c deleted file mode 100644 index f8607bc0892..00000000000 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k.c +++ /dev/null @@ -1,1479 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// AR6K device layer that handles register level I/O -// -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" -#include "hw/mbox_host_reg.h" -#include "a_osapi.h" -#include "../htc_debug.h" -#include "hif.h" -#include "htc_packet.h" -#include "ar6k.h" - -#define MAILBOX_FOR_BLOCK_SIZE 1 - -int DevEnableInterrupts(struct ar6k_device *pDev); -int DevDisableInterrupts(struct ar6k_device *pDev); - -static void DevCleanupVirtualScatterSupport(struct ar6k_device *pDev); - -void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket) -{ - LOCK_AR6K(pDev); - HTC_PACKET_ENQUEUE(&pDev->RegisterIOList,pPacket); - UNLOCK_AR6K(pDev); -} - -struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev) -{ - struct htc_packet *pPacket; - - LOCK_AR6K(pDev); - pPacket = HTC_PACKET_DEQUEUE(&pDev->RegisterIOList); - UNLOCK_AR6K(pDev); - - return pPacket; -} - -void DevCleanup(struct ar6k_device *pDev) -{ - DevCleanupGMbox(pDev); - - if (pDev->HifAttached) { - HIFDetachHTC(pDev->HIFDevice); - pDev->HifAttached = false; - } - - DevCleanupVirtualScatterSupport(pDev); - - if (A_IS_MUTEX_VALID(&pDev->Lock)) { - A_MUTEX_DELETE(&pDev->Lock); - } -} - -int DevSetup(struct ar6k_device *pDev) -{ - u32 blocksizes[AR6K_MAILBOXES]; - int status = 0; - int i; - HTC_CALLBACKS htcCallbacks; - - do { - - DL_LIST_INIT(&pDev->ScatterReqHead); - /* initialize our free list of IO packets */ - INIT_HTC_PACKET_QUEUE(&pDev->RegisterIOList); - A_MUTEX_INIT(&pDev->Lock); - - A_MEMZERO(&htcCallbacks, sizeof(HTC_CALLBACKS)); - /* the device layer handles these */ - htcCallbacks.rwCompletionHandler = DevRWCompletionHandler; - htcCallbacks.dsrHandler = DevDsrHandler; - htcCallbacks.context = pDev; - - status = HIFAttachHTC(pDev->HIFDevice, &htcCallbacks); - - if (status) { - break; - } - - pDev->HifAttached = true; - - /* get the addresses for all 4 mailboxes */ - status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR, - &pDev->MailBoxInfo, sizeof(pDev->MailBoxInfo)); - - if (status) { - A_ASSERT(false); - break; - } - - /* carve up register I/O packets (these are for ASYNC register I/O ) */ - for (i = 0; i < AR6K_MAX_REG_IO_BUFFERS; i++) { - struct htc_packet *pIOPacket; - pIOPacket = &pDev->RegIOBuffers[i].HtcPacket; - SET_HTC_PACKET_INFO_RX_REFILL(pIOPacket, - pDev, - pDev->RegIOBuffers[i].Buffer, - AR6K_REG_IO_BUFFER_SIZE, - 0); /* don't care */ - AR6KFreeIOPacket(pDev,pIOPacket); - } - - /* get the block sizes */ - status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, - blocksizes, sizeof(blocksizes)); - - if (status) { - A_ASSERT(false); - break; - } - - /* note: we actually get the block size of a mailbox other than 0, for SDIO the block - * size on mailbox 0 is artificially set to 1. So we use the block size that is set - * for the other 3 mailboxes */ - pDev->BlockSize = blocksizes[MAILBOX_FOR_BLOCK_SIZE]; - /* must be a power of 2 */ - A_ASSERT((pDev->BlockSize & (pDev->BlockSize - 1)) == 0); - - /* assemble mask, used for padding to a block */ - pDev->BlockMask = pDev->BlockSize - 1; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("BlockSize: %d, MailboxAddress:0x%X \n", - pDev->BlockSize, pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX])); - - pDev->GetPendingEventsFunc = NULL; - /* see if the HIF layer implements the get pending events function */ - HIFConfigureDevice(pDev->HIFDevice, - HIF_DEVICE_GET_PENDING_EVENTS_FUNC, - &pDev->GetPendingEventsFunc, - sizeof(pDev->GetPendingEventsFunc)); - - /* assume we can process HIF interrupt events asynchronously */ - pDev->HifIRQProcessingMode = HIF_DEVICE_IRQ_ASYNC_SYNC; - - /* see if the HIF layer overrides this assumption */ - HIFConfigureDevice(pDev->HIFDevice, - HIF_DEVICE_GET_IRQ_PROC_MODE, - &pDev->HifIRQProcessingMode, - sizeof(pDev->HifIRQProcessingMode)); - - switch (pDev->HifIRQProcessingMode) { - case HIF_DEVICE_IRQ_SYNC_ONLY: - AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("HIF Interrupt processing is SYNC ONLY\n")); - /* see if HIF layer wants HTC to yield */ - HIFConfigureDevice(pDev->HIFDevice, - HIF_DEVICE_GET_IRQ_YIELD_PARAMS, - &pDev->HifIRQYieldParams, - sizeof(pDev->HifIRQYieldParams)); - - if (pDev->HifIRQYieldParams.RecvPacketYieldCount > 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - ("HIF requests that DSR yield per %d RECV packets \n", - pDev->HifIRQYieldParams.RecvPacketYieldCount)); - pDev->DSRCanYield = true; - } - break; - case HIF_DEVICE_IRQ_ASYNC_SYNC: - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF Interrupt processing is ASYNC and SYNC\n")); - break; - default: - A_ASSERT(false); - } - - pDev->HifMaskUmaskRecvEvent = NULL; - - /* see if the HIF layer implements the mask/unmask recv events function */ - HIFConfigureDevice(pDev->HIFDevice, - HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC, - &pDev->HifMaskUmaskRecvEvent, - sizeof(pDev->HifMaskUmaskRecvEvent)); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF special overrides : 0x%lX , 0x%lX\n", - (unsigned long)pDev->GetPendingEventsFunc, (unsigned long)pDev->HifMaskUmaskRecvEvent)); - - status = DevDisableInterrupts(pDev); - - if (status) { - break; - } - - status = DevSetupGMbox(pDev); - - } while (false); - - if (status) { - if (pDev->HifAttached) { - HIFDetachHTC(pDev->HIFDevice); - pDev->HifAttached = false; - } - } - - return status; - -} - -int DevEnableInterrupts(struct ar6k_device *pDev) -{ - int status; - struct ar6k_irq_enable_registers regs; - - LOCK_AR6K(pDev); - - /* Enable all the interrupts except for the internal AR6000 CPU interrupt */ - pDev->IrqEnableRegisters.int_status_enable = INT_STATUS_ENABLE_ERROR_SET(0x01) | - INT_STATUS_ENABLE_CPU_SET(0x01) | - INT_STATUS_ENABLE_COUNTER_SET(0x01); - - if (NULL == pDev->GetPendingEventsFunc) { - pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); - } else { - /* The HIF layer provided us with a pending events function which means that - * the detection of pending mbox messages is handled in the HIF layer. - * This is the case for the SPI2 interface. - * In the normal case we enable MBOX interrupts, for the case - * with HIFs that offer this mechanism, we keep these interrupts - * masked */ - pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); - } - - - /* Set up the CPU Interrupt Status Register */ - pDev->IrqEnableRegisters.cpu_int_status_enable = CPU_INT_STATUS_ENABLE_BIT_SET(0x00); - - /* Set up the Error Interrupt Status Register */ - pDev->IrqEnableRegisters.error_status_enable = - ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(0x01) | - ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(0x01); - - /* Set up the Counter Interrupt Status Register (only for debug interrupt to catch fatal errors) */ - pDev->IrqEnableRegisters.counter_int_status_enable = - COUNTER_INT_STATUS_ENABLE_BIT_SET(AR6K_TARGET_DEBUG_INTR_MASK); - - /* copy into our temp area */ - memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - - UNLOCK_AR6K(pDev); - - /* always synchronous */ - status = HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_enable, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - /* Can't write it for some reason */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Failed to update interrupt control registers err: %d\n", status)); - - } - - return status; -} - -int DevDisableInterrupts(struct ar6k_device *pDev) -{ - struct ar6k_irq_enable_registers regs; - - LOCK_AR6K(pDev); - /* Disable all interrupts */ - pDev->IrqEnableRegisters.int_status_enable = 0; - pDev->IrqEnableRegisters.cpu_int_status_enable = 0; - pDev->IrqEnableRegisters.error_status_enable = 0; - pDev->IrqEnableRegisters.counter_int_status_enable = 0; - /* copy into our temp area */ - memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - - UNLOCK_AR6K(pDev); - - /* always synchronous */ - return HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_enable, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_SYNC_BYTE_INC, - NULL); -} - -/* enable device interrupts */ -int DevUnmaskInterrupts(struct ar6k_device *pDev) -{ - /* for good measure, make sure interrupt are disabled before unmasking at the HIF - * layer. - * The rationale here is that between device insertion (where we clear the interrupts the first time) - * and when HTC is finally ready to handle interrupts, other software can perform target "soft" resets. - * The AR6K interrupt enables reset back to an "enabled" state when this happens. - * */ - int IntStatus = 0; - DevDisableInterrupts(pDev); - -#ifdef THREAD_X - // Tobe verified... - IntStatus = DevEnableInterrupts(pDev); - /* Unmask the host controller interrupts */ - HIFUnMaskInterrupt(pDev->HIFDevice); -#else - /* Unmask the host controller interrupts */ - HIFUnMaskInterrupt(pDev->HIFDevice); - IntStatus = DevEnableInterrupts(pDev); -#endif - - return IntStatus; -} - -/* disable all device interrupts */ -int DevMaskInterrupts(struct ar6k_device *pDev) -{ - /* mask the interrupt at the HIF layer, we don't want a stray interrupt taken while - * we zero out our shadow registers in DevDisableInterrupts()*/ - HIFMaskInterrupt(pDev->HIFDevice); - - return DevDisableInterrupts(pDev); -} - -/* callback when our fetch to enable/disable completes */ -static void DevDoEnableDisableRecvAsyncHandler(void *Context, struct htc_packet *pPacket) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDoEnableDisableRecvAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" Failed to disable receiver, status:%d \n", pPacket->Status)); - } - /* free this IO packet */ - AR6KFreeIOPacket(pDev,pPacket); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDoEnableDisableRecvAsyncHandler \n")); -} - -/* disable packet reception (used in case the host runs out of buffers) - * this is the "override" method when the HIF reports another methods to - * disable recv events */ -static int DevDoEnableDisableRecvOverride(struct ar6k_device *pDev, bool EnableRecv, bool AsyncMode) -{ - int status = 0; - struct htc_packet *pIOPacket = NULL; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n", - EnableRecv,AsyncMode)); - - do { - - if (AsyncMode) { - - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler; - pIOPacket->pContext = pDev; - - /* call the HIF layer override and do this asynchronously */ - status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, - EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, - pIOPacket); - break; - } - - /* if we get here we are doing it synchronously */ - status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, - EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, - NULL); - - } while (false); - - if (status && (pIOPacket != NULL)) { - AR6KFreeIOPacket(pDev,pIOPacket); - } - - return status; -} - -/* disable packet reception (used in case the host runs out of buffers) - * this is the "normal" method using the interrupt enable registers through - * the host I/F */ -static int DevDoEnableDisableRecvNormal(struct ar6k_device *pDev, bool EnableRecv, bool AsyncMode) -{ - int status = 0; - struct htc_packet *pIOPacket = NULL; - struct ar6k_irq_enable_registers regs; - - /* take the lock to protect interrupt enable shadows */ - LOCK_AR6K(pDev); - - if (EnableRecv) { - pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); - } else { - pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); - } - - /* copy into our temp area */ - memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - UNLOCK_AR6K(pDev); - - do { - - if (AsyncMode) { - - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - /* copy values to write to our async I/O buffer */ - memcpy(pIOPacket->pBuffer,®s,AR6K_IRQ_ENABLE_REGS_SIZE); - - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler; - pIOPacket->pContext = pDev; - - /* write it out asynchronously */ - HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - pIOPacket->pBuffer, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_ASYNC_BYTE_INC, - pIOPacket); - break; - } - - /* if we get here we are doing it synchronously */ - - status = HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_enable, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_SYNC_BYTE_INC, - NULL); - - } while (false); - - if (status && (pIOPacket != NULL)) { - AR6KFreeIOPacket(pDev,pIOPacket); - } - - return status; -} - - -int DevStopRecv(struct ar6k_device *pDev, bool AsyncMode) -{ - if (NULL == pDev->HifMaskUmaskRecvEvent) { - return DevDoEnableDisableRecvNormal(pDev,false,AsyncMode); - } else { - return DevDoEnableDisableRecvOverride(pDev,false,AsyncMode); - } -} - -int DevEnableRecv(struct ar6k_device *pDev, bool AsyncMode) -{ - if (NULL == pDev->HifMaskUmaskRecvEvent) { - return DevDoEnableDisableRecvNormal(pDev,true,AsyncMode); - } else { - return DevDoEnableDisableRecvOverride(pDev,true,AsyncMode); - } -} - -int DevWaitForPendingRecv(struct ar6k_device *pDev,u32 TimeoutInMs,bool *pbIsRecvPending) -{ - int status = 0; - u8 host_int_status = 0x0; - u32 counter = 0x0; - - if(TimeoutInMs < 100) - { - TimeoutInMs = 100; - } - - counter = TimeoutInMs / 100; - - do - { - //Read the Host Interrupt Status Register - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - &host_int_status, - sizeof(u8), - HIF_RD_SYNC_BYTE_INC, - NULL); - if (status) - { - AR_DEBUG_PRINTF(ATH_LOG_ERR,("DevWaitForPendingRecv:Read HOST_INT_STATUS_ADDRESS Failed 0x%X\n",status)); - break; - } - - host_int_status = !status ? (host_int_status & (1 << 0)):0; - if(!host_int_status) - { - status = 0; - *pbIsRecvPending = false; - break; - } - else - { - *pbIsRecvPending = true; - } - - A_MDELAY(100); - - counter--; - - }while(counter); - return status; -} - -void DevDumpRegisters(struct ar6k_device *pDev, - struct ar6k_irq_proc_registers *pIrqProcRegs, - struct ar6k_irq_enable_registers *pIrqEnableRegs) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("\n<------- Register Table -------->\n")); - - if (pIrqProcRegs != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Host Int Status: 0x%x\n",pIrqProcRegs->host_int_status)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("CPU Int Status: 0x%x\n",pIrqProcRegs->cpu_int_status)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Error Int Status: 0x%x\n",pIrqProcRegs->error_int_status)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Counter Int Status: 0x%x\n",pIrqProcRegs->counter_int_status)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Mbox Frame: 0x%x\n",pIrqProcRegs->mbox_frame)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Rx Lookahead Valid: 0x%x\n",pIrqProcRegs->rx_lookahead_valid)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Rx Lookahead 0: 0x%x\n",pIrqProcRegs->rx_lookahead[0])); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Rx Lookahead 1: 0x%x\n",pIrqProcRegs->rx_lookahead[1])); - - if (pDev->MailBoxInfo.GMboxAddress != 0) { - /* if the target supports GMBOX hardware, dump some additional state */ - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("GMBOX Host Int Status 2: 0x%x\n",pIrqProcRegs->host_int_status2)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("GMBOX RX Avail: 0x%x\n",pIrqProcRegs->gmbox_rx_avail)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("GMBOX lookahead alias 0: 0x%x\n",pIrqProcRegs->rx_gmbox_lookahead_alias[0])); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("GMBOX lookahead alias 1: 0x%x\n",pIrqProcRegs->rx_gmbox_lookahead_alias[1])); - } - - } - - if (pIrqEnableRegs != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Int Status Enable: 0x%x\n",pIrqEnableRegs->int_status_enable)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("Counter Int Status Enable: 0x%x\n",pIrqEnableRegs->counter_int_status_enable)); - } - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("<------------------------------->\n")); -} - - -#define DEV_GET_VIRT_DMA_INFO(p) ((struct dev_scatter_dma_virtual_info *)((p)->HIFPrivate[0])) - -static struct hif_scatter_req *DevAllocScatterReq(struct hif_device *Context) -{ - struct dl_list *pItem; - struct ar6k_device *pDev = (struct ar6k_device *)Context; - LOCK_AR6K(pDev); - pItem = DL_ListRemoveItemFromHead(&pDev->ScatterReqHead); - UNLOCK_AR6K(pDev); - if (pItem != NULL) { - return A_CONTAINING_STRUCT(pItem, struct hif_scatter_req, ListLink); - } - return NULL; -} - -static void DevFreeScatterReq(struct hif_device *Context, struct hif_scatter_req *pReq) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - LOCK_AR6K(pDev); - DL_ListInsertTail(&pDev->ScatterReqHead, &pReq->ListLink); - UNLOCK_AR6K(pDev); -} - -int DevCopyScatterListToFromDMABuffer(struct hif_scatter_req *pReq, bool FromDMA) -{ - u8 *pDMABuffer = NULL; - int i, remaining; - u32 length; - - pDMABuffer = pReq->pScatterBounceBuffer; - - if (pDMABuffer == NULL) { - A_ASSERT(false); - return A_EINVAL; - } - - remaining = (int)pReq->TotalLength; - - for (i = 0; i < pReq->ValidScatterEntries; i++) { - - length = min((int)pReq->ScatterList[i].Length, remaining); - - if (length != (int)pReq->ScatterList[i].Length) { - A_ASSERT(false); - /* there is a problem with the scatter list */ - return A_EINVAL; - } - - if (FromDMA) { - /* from DMA buffer */ - memcpy(pReq->ScatterList[i].pBuffer, pDMABuffer , length); - } else { - /* to DMA buffer */ - memcpy(pDMABuffer, pReq->ScatterList[i].pBuffer, length); - } - - pDMABuffer += length; - remaining -= length; - } - - return 0; -} - -static void DevReadWriteScatterAsyncHandler(void *Context, struct htc_packet *pPacket) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - struct hif_scatter_req *pReq = (struct hif_scatter_req *)pPacket->pPktContext; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevReadWriteScatterAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - pReq->CompletionStatus = pPacket->Status; - - AR6KFreeIOPacket(pDev,pPacket); - - pReq->CompletionRoutine(pReq); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-DevReadWriteScatterAsyncHandler \n")); -} - -static int DevReadWriteScatter(struct hif_device *Context, struct hif_scatter_req *pReq) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - int status = 0; - struct htc_packet *pIOPacket = NULL; - u32 request = pReq->Request; - - do { - - if (pReq->TotalLength > AR6K_MAX_TRANSFER_SIZE_PER_SCATTER) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Invalid length: %d \n", pReq->TotalLength)); - break; - } - - if (pReq->TotalLength == 0) { - A_ASSERT(false); - break; - } - - if (request & HIF_ASYNCHRONOUS) { - /* use an I/O packet to carry this request */ - pIOPacket = AR6KAllocIOPacket(pDev); - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - break; - } - - /* save the request */ - pIOPacket->pPktContext = pReq; - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevReadWriteScatterAsyncHandler; - pIOPacket->pContext = pDev; - } - - if (request & HIF_WRITE) { - /* in virtual DMA, we are issuing the requests through the legacy HIFReadWrite API - * this API will adjust the address automatically for the last byte to fall on the mailbox - * EOM. */ - - /* if the address is an extended address, we can adjust the address here since the extended - * address will bypass the normal checks in legacy HIF layers */ - if (pReq->Address == pDev->MailBoxInfo.MboxProp[HTC_MAILBOX].ExtendedAddress) { - pReq->Address += pDev->MailBoxInfo.MboxProp[HTC_MAILBOX].ExtendedSize - pReq->TotalLength; - } - } - - /* use legacy readwrite */ - status = HIFReadWrite(pDev->HIFDevice, - pReq->Address, - DEV_GET_VIRT_DMA_INFO(pReq)->pVirtDmaBuffer, - pReq->TotalLength, - request, - (request & HIF_ASYNCHRONOUS) ? pIOPacket : NULL); - - } while (false); - - if ((status != A_PENDING) && status && (request & HIF_ASYNCHRONOUS)) { - if (pIOPacket != NULL) { - AR6KFreeIOPacket(pDev,pIOPacket); - } - pReq->CompletionStatus = status; - pReq->CompletionRoutine(pReq); - status = 0; - } - - return status; -} - - -static void DevCleanupVirtualScatterSupport(struct ar6k_device *pDev) -{ - struct hif_scatter_req *pReq; - - while (1) { - pReq = DevAllocScatterReq((struct hif_device *)pDev); - if (NULL == pReq) { - break; - } - kfree(pReq); - } - -} - - /* function to set up virtual scatter support if HIF layer has not implemented the interface */ -static int DevSetupVirtualScatterSupport(struct ar6k_device *pDev) -{ - int status = 0; - int bufferSize, sgreqSize; - int i; - struct dev_scatter_dma_virtual_info *pVirtualInfo; - struct hif_scatter_req *pReq; - - bufferSize = sizeof(struct dev_scatter_dma_virtual_info) + - 2 * (A_GET_CACHE_LINE_BYTES()) + AR6K_MAX_TRANSFER_SIZE_PER_SCATTER; - - sgreqSize = sizeof(struct hif_scatter_req) + - (AR6K_SCATTER_ENTRIES_PER_REQ - 1) * (sizeof(struct hif_scatter_item)); - - for (i = 0; i < AR6K_SCATTER_REQS; i++) { - /* allocate the scatter request, buffer info and the actual virtual buffer itself */ - pReq = (struct hif_scatter_req *)A_MALLOC(sgreqSize + bufferSize); - - if (NULL == pReq) { - status = A_NO_MEMORY; - break; - } - - A_MEMZERO(pReq, sgreqSize); - - /* the virtual DMA starts after the scatter request struct */ - pVirtualInfo = (struct dev_scatter_dma_virtual_info *)((u8 *)pReq + sgreqSize); - A_MEMZERO(pVirtualInfo, sizeof(struct dev_scatter_dma_virtual_info)); - - pVirtualInfo->pVirtDmaBuffer = &pVirtualInfo->DataArea[0]; - /* align buffer to cache line in case host controller can actually DMA this */ - pVirtualInfo->pVirtDmaBuffer = A_ALIGN_TO_CACHE_LINE(pVirtualInfo->pVirtDmaBuffer); - /* store the structure in the private area */ - pReq->HIFPrivate[0] = pVirtualInfo; - /* we emulate a DMA bounce interface */ - pReq->ScatterMethod = HIF_SCATTER_DMA_BOUNCE; - pReq->pScatterBounceBuffer = pVirtualInfo->pVirtDmaBuffer; - /* free request to the list */ - DevFreeScatterReq((struct hif_device *)pDev,pReq); - } - - if (status) { - DevCleanupVirtualScatterSupport(pDev); - } else { - pDev->HifScatterInfo.pAllocateReqFunc = DevAllocScatterReq; - pDev->HifScatterInfo.pFreeReqFunc = DevFreeScatterReq; - pDev->HifScatterInfo.pReadWriteScatterFunc = DevReadWriteScatter; - if (pDev->MailBoxInfo.MboxBusIFType == MBOX_BUS_IF_SPI) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("AR6K: SPI bus requires RX scatter limits\n")); - pDev->HifScatterInfo.MaxScatterEntries = AR6K_MIN_SCATTER_ENTRIES_PER_REQ; - pDev->HifScatterInfo.MaxTransferSizePerScatterReq = AR6K_MIN_TRANSFER_SIZE_PER_SCATTER; - } else { - pDev->HifScatterInfo.MaxScatterEntries = AR6K_SCATTER_ENTRIES_PER_REQ; - pDev->HifScatterInfo.MaxTransferSizePerScatterReq = AR6K_MAX_TRANSFER_SIZE_PER_SCATTER; - } - pDev->ScatterIsVirtual = true; - } - - return status; -} - -int DevCleanupMsgBundling(struct ar6k_device *pDev) -{ - if(NULL != pDev) - { - DevCleanupVirtualScatterSupport(pDev); - } - - return 0; -} - -int DevSetupMsgBundling(struct ar6k_device *pDev, int MaxMsgsPerTransfer) -{ - int status; - - if (pDev->MailBoxInfo.Flags & HIF_MBOX_FLAG_NO_BUNDLING) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HIF requires bundling disabled\n")); - return A_ENOTSUP; - } - - status = HIFConfigureDevice(pDev->HIFDevice, - HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT, - &pDev->HifScatterInfo, - sizeof(pDev->HifScatterInfo)); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - ("AR6K: ** HIF layer does not support scatter requests (%d) \n",status)); - - /* we can try to use a virtual DMA scatter mechanism using legacy HIFReadWrite() */ - status = DevSetupVirtualScatterSupport(pDev); - - if (!status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("AR6K: virtual scatter transfers enabled (max scatter items:%d: maxlen:%d) \n", - DEV_GET_MAX_MSG_PER_BUNDLE(pDev), DEV_GET_MAX_BUNDLE_LENGTH(pDev))); - } - - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("AR6K: HIF layer supports scatter requests (max scatter items:%d: maxlen:%d) \n", - DEV_GET_MAX_MSG_PER_BUNDLE(pDev), DEV_GET_MAX_BUNDLE_LENGTH(pDev))); - } - - if (!status) { - /* for the recv path, the maximum number of bytes per recv bundle is just limited - * by the maximum transfer size at the HIF layer */ - pDev->MaxRecvBundleSize = pDev->HifScatterInfo.MaxTransferSizePerScatterReq; - - if (pDev->MailBoxInfo.MboxBusIFType == MBOX_BUS_IF_SPI) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("AR6K : SPI bus requires TX bundling disabled\n")); - pDev->MaxSendBundleSize = 0; - } else { - /* for the send path, the max transfer size is limited by the existence and size of - * the extended mailbox address range */ - if (pDev->MailBoxInfo.MboxProp[0].ExtendedAddress != 0) { - pDev->MaxSendBundleSize = pDev->MailBoxInfo.MboxProp[0].ExtendedSize; - } else { - /* legacy */ - pDev->MaxSendBundleSize = AR6K_LEGACY_MAX_WRITE_LENGTH; - } - - if (pDev->MaxSendBundleSize > pDev->HifScatterInfo.MaxTransferSizePerScatterReq) { - /* limit send bundle size to what the HIF can support for scatter requests */ - pDev->MaxSendBundleSize = pDev->HifScatterInfo.MaxTransferSizePerScatterReq; - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("AR6K: max recv: %d max send: %d \n", - DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev), DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev))); - - } - return status; -} - -int DevSubmitScatterRequest(struct ar6k_device *pDev, struct hif_scatter_req *pScatterReq, bool Read, bool Async) -{ - int status; - - if (Read) { - /* read operation */ - pScatterReq->Request = (Async) ? HIF_RD_ASYNC_BLOCK_FIX : HIF_RD_SYNC_BLOCK_FIX; - pScatterReq->Address = pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX]; - A_ASSERT(pScatterReq->TotalLength <= (u32)DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev)); - } else { - u32 mailboxWidth; - - /* write operation */ - pScatterReq->Request = (Async) ? HIF_WR_ASYNC_BLOCK_INC : HIF_WR_SYNC_BLOCK_INC; - A_ASSERT(pScatterReq->TotalLength <= (u32)DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev)); - if (pScatterReq->TotalLength > AR6K_LEGACY_MAX_WRITE_LENGTH) { - /* for large writes use the extended address */ - pScatterReq->Address = pDev->MailBoxInfo.MboxProp[HTC_MAILBOX].ExtendedAddress; - mailboxWidth = pDev->MailBoxInfo.MboxProp[HTC_MAILBOX].ExtendedSize; - } else { - pScatterReq->Address = pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX]; - mailboxWidth = AR6K_LEGACY_MAX_WRITE_LENGTH; - } - - if (!pDev->ScatterIsVirtual) { - /* we are passing this scatter list down to the HIF layer' scatter request handler, fixup the address - * so that the last byte falls on the EOM, we do this for those HIFs that support the - * scatter API */ - pScatterReq->Address += (mailboxWidth - pScatterReq->TotalLength); - } - - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV | ATH_DEBUG_SEND, - ("DevSubmitScatterRequest, Entries: %d, Total Length: %d Mbox:0x%X (mode: %s : %s)\n", - pScatterReq->ValidScatterEntries, - pScatterReq->TotalLength, - pScatterReq->Address, - Async ? "ASYNC" : "SYNC", - (Read) ? "RD" : "WR")); - - status = DEV_PREPARE_SCATTER_OPERATION(pScatterReq); - - if (status) { - if (Async) { - pScatterReq->CompletionStatus = status; - pScatterReq->CompletionRoutine(pScatterReq); - return 0; - } - return status; - } - - status = pDev->HifScatterInfo.pReadWriteScatterFunc(pDev->ScatterIsVirtual ? pDev : pDev->HIFDevice, - pScatterReq); - if (!Async) { - /* in sync mode, we can touch the scatter request */ - pScatterReq->CompletionStatus = status; - DEV_FINISH_SCATTER_OPERATION(pScatterReq); - } else { - if (status == A_PENDING) { - status = 0; - } - } - - return status; -} - - -#ifdef MBOXHW_UNIT_TEST - - -/* This is a mailbox hardware unit test that must be called in a schedulable context - * This test is very simple, it will send a list of buffers with a counting pattern - * and the target will invert the data and send the message back - * - * the unit test has the following constraints: - * - * The target has at least 8 buffers of 256 bytes each. The host will send - * the following pattern of buffers in rapid succession : - * - * 1 buffer - 128 bytes - * 1 buffer - 256 bytes - * 1 buffer - 512 bytes - * 1 buffer - 1024 bytes - * - * The host will send the buffers to one mailbox and wait for buffers to be reflected - * back from the same mailbox. The target sends the buffers FIFO order. - * Once the final buffer has been received for a mailbox, the next mailbox is tested. - * - * - * Note: To simplifythe test , we assume that the chosen buffer sizes - * will fall on a nice block pad - * - * It is expected that higher-order tests will be written to stress the mailboxes using - * a message-based protocol (with some performance timming) that can create more - * randomness in the packets sent over mailboxes. - * - * */ - -#define A_ROUND_UP_PWR2(x, align) (((int) (x) + ((align)-1)) & ~((align)-1)) - -#define BUFFER_BLOCK_PAD 128 - -#if 0 -#define BUFFER1 128 -#define BUFFER2 256 -#define BUFFER3 512 -#define BUFFER4 1024 -#endif - -#if 1 -#define BUFFER1 80 -#define BUFFER2 200 -#define BUFFER3 444 -#define BUFFER4 800 -#endif - -#define TOTAL_BYTES (A_ROUND_UP_PWR2(BUFFER1,BUFFER_BLOCK_PAD) + \ - A_ROUND_UP_PWR2(BUFFER2,BUFFER_BLOCK_PAD) + \ - A_ROUND_UP_PWR2(BUFFER3,BUFFER_BLOCK_PAD) + \ - A_ROUND_UP_PWR2(BUFFER4,BUFFER_BLOCK_PAD) ) - -#define TEST_BYTES (BUFFER1 + BUFFER2 + BUFFER3 + BUFFER4) - -#define TEST_CREDITS_RECV_TIMEOUT 100 - -static u8 g_Buffer[TOTAL_BYTES]; -static u32 g_MailboxAddrs[AR6K_MAILBOXES]; -static u32 g_BlockSizes[AR6K_MAILBOXES]; - -#define BUFFER_PROC_LIST_DEPTH 4 - -struct buffer_proc_list { - u8 *pBuffer; - u32 length; -}; - - -#define PUSH_BUFF_PROC_ENTRY(pList,len,pCurrpos) \ -{ \ - (pList)->pBuffer = (pCurrpos); \ - (pList)->length = (len); \ - (pCurrpos) += (len); \ - (pList)++; \ -} - -/* a simple and crude way to send different "message" sizes */ -static void AssembleBufferList(struct buffer_proc_list *pList) -{ - u8 *pBuffer = g_Buffer; - -#if BUFFER_PROC_LIST_DEPTH < 4 -#error "Buffer processing list depth is not deep enough!!" -#endif - - PUSH_BUFF_PROC_ENTRY(pList,BUFFER1,pBuffer); - PUSH_BUFF_PROC_ENTRY(pList,BUFFER2,pBuffer); - PUSH_BUFF_PROC_ENTRY(pList,BUFFER3,pBuffer); - PUSH_BUFF_PROC_ENTRY(pList,BUFFER4,pBuffer); - -} - -#define FILL_ZERO true -#define FILL_COUNTING false -static void InitBuffers(bool Zero) -{ - u16 *pBuffer16 = (u16 *)g_Buffer; - int i; - - /* fill buffer with 16 bit counting pattern or zeros */ - for (i = 0; i < (TOTAL_BYTES / 2) ; i++) { - if (!Zero) { - pBuffer16[i] = (u16)i; - } else { - pBuffer16[i] = 0; - } - } -} - - -static bool CheckOneBuffer(u16 *pBuffer16, int Length) -{ - int i; - u16 startCount; - bool success = true; - - /* get the starting count */ - startCount = pBuffer16[0]; - /* invert it, this is the expected value */ - startCount = ~startCount; - /* scan the buffer and verify */ - for (i = 0; i < (Length / 2) ; i++,startCount++) { - /* target will invert all the data */ - if ((u16)pBuffer16[i] != (u16)~startCount) { - success = false; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Invalid Data Got:0x%X, Expecting:0x%X (offset:%d, total:%d) \n", - pBuffer16[i], ((u16)~startCount), i, Length)); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("0x%X 0x%X 0x%X 0x%X \n", - pBuffer16[i], pBuffer16[i + 1], pBuffer16[i + 2],pBuffer16[i+3])); - break; - } - } - - return success; -} - -static bool CheckBuffers(void) -{ - int i; - bool success = true; - struct buffer_proc_list checkList[BUFFER_PROC_LIST_DEPTH]; - - /* assemble the list */ - AssembleBufferList(checkList); - - /* scan the buffers and verify */ - for (i = 0; i < BUFFER_PROC_LIST_DEPTH ; i++) { - success = CheckOneBuffer((u16 *)checkList[i].pBuffer, checkList[i].length); - if (!success) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n", - (u32)checkList[i].pBuffer, checkList[i].length)); - break; - } - } - - return success; -} - - /* find the end marker for the last buffer we will be sending */ -static u16 GetEndMarker(void) -{ - u8 *pBuffer; - struct buffer_proc_list checkList[BUFFER_PROC_LIST_DEPTH]; - - /* fill up buffers with the normal counting pattern */ - InitBuffers(FILL_COUNTING); - - /* assemble the list we will be sending down */ - AssembleBufferList(checkList); - /* point to the last 2 bytes of the last buffer */ - pBuffer = &(checkList[BUFFER_PROC_LIST_DEPTH - 1].pBuffer[(checkList[BUFFER_PROC_LIST_DEPTH - 1].length) - 2]); - - /* the last count in the last buffer is the marker */ - return (u16)pBuffer[0] | ((u16)pBuffer[1] << 8); -} - -#define ATH_PRINT_OUT_ZONE ATH_DEBUG_ERR - -/* send the ordered buffers to the target */ -static int SendBuffers(struct ar6k_device *pDev, int mbox) -{ - int status = 0; - u32 request = HIF_WR_SYNC_BLOCK_INC; - struct buffer_proc_list sendList[BUFFER_PROC_LIST_DEPTH]; - int i; - int totalBytes = 0; - int paddedLength; - int totalwPadding = 0; - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sending buffers on mailbox : %d \n",mbox)); - - /* fill buffer with counting pattern */ - InitBuffers(FILL_COUNTING); - - /* assemble the order in which we send */ - AssembleBufferList(sendList); - - for (i = 0; i < BUFFER_PROC_LIST_DEPTH; i++) { - - /* we are doing block transfers, so we need to pad everything to a block size */ - paddedLength = (sendList[i].length + (g_BlockSizes[mbox] - 1)) & - (~(g_BlockSizes[mbox] - 1)); - - /* send each buffer synchronously */ - status = HIFReadWrite(pDev->HIFDevice, - g_MailboxAddrs[mbox], - sendList[i].pBuffer, - paddedLength, - request, - NULL); - if (status) { - break; - } - totalBytes += sendList[i].length; - totalwPadding += paddedLength; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sent %d bytes (%d padded bytes) to mailbox : %d \n",totalBytes,totalwPadding,mbox)); - - return status; -} - -/* poll the mailbox credit counter until we get a credit or timeout */ -static int GetCredits(struct ar6k_device *pDev, int mbox, int *pCredits) -{ - int status = 0; - int timeout = TEST_CREDITS_RECV_TIMEOUT; - u8 credits = 0; - u32 address; - - while (true) { - - /* Read the counter register to get credits, this auto-decrements */ - address = COUNT_DEC_ADDRESS + (AR6K_MAILBOXES + mbox) * 4; - status = HIFReadWrite(pDev->HIFDevice, address, &credits, sizeof(credits), - HIF_RD_SYNC_BYTE_FIX, NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Unable to decrement the command credit count register (mbox=%d)\n",mbox)); - status = A_ERROR; - break; - } - - if (credits) { - break; - } - - timeout--; - - if (timeout <= 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" Timeout reading credit registers (mbox=%d, address:0x%X) \n",mbox,address)); - status = A_ERROR; - break; - } - - /* delay a little, target may not be ready */ - A_MDELAY(1000); - - } - - if (status == 0) { - *pCredits = credits; - } - - return status; -} - - -/* wait for the buffers to come back */ -static int RecvBuffers(struct ar6k_device *pDev, int mbox) -{ - int status = 0; - u32 request = HIF_RD_SYNC_BLOCK_INC; - struct buffer_proc_list recvList[BUFFER_PROC_LIST_DEPTH]; - int curBuffer; - int credits; - int i; - int totalBytes = 0; - int paddedLength; - int totalwPadding = 0; - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for buffers on mailbox : %d \n",mbox)); - - /* zero the buffers */ - InitBuffers(FILL_ZERO); - - /* assemble the order in which we should receive */ - AssembleBufferList(recvList); - - curBuffer = 0; - - while (curBuffer < BUFFER_PROC_LIST_DEPTH) { - - /* get number of buffers that have been completed, this blocks - * until we get at least 1 credit or it times out */ - status = GetCredits(pDev, mbox, &credits); - - if (status) { - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got %d messages on mailbox : %d \n",credits, mbox)); - - /* get all the buffers that are sitting on the queue */ - for (i = 0; i < credits; i++) { - A_ASSERT(curBuffer < BUFFER_PROC_LIST_DEPTH); - /* recv the current buffer synchronously, the buffers should come back in - * order... with padding applied by the target */ - paddedLength = (recvList[curBuffer].length + (g_BlockSizes[mbox] - 1)) & - (~(g_BlockSizes[mbox] - 1)); - - status = HIFReadWrite(pDev->HIFDevice, - g_MailboxAddrs[mbox], - recvList[curBuffer].pBuffer, - paddedLength, - request, - NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to read %d bytes on mailbox:%d : address:0x%X \n", - recvList[curBuffer].length, mbox, g_MailboxAddrs[mbox])); - break; - } - - totalwPadding += paddedLength; - totalBytes += recvList[curBuffer].length; - curBuffer++; - } - - if (status) { - break; - } - /* go back and get some more */ - credits = 0; - } - - if (totalBytes != TEST_BYTES) { - A_ASSERT(false); - } else { - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got all buffers on mbox:%d total recv :%d (w/Padding : %d) \n", - mbox, totalBytes, totalwPadding)); - } - - return status; - - -} - -static int DoOneMboxHWTest(struct ar6k_device *pDev, int mbox) -{ - int status; - - do { - /* send out buffers */ - status = SendBuffers(pDev,mbox); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Sending buffers Failed : %d mbox:%d\n",status,mbox)); - break; - } - - /* go get them, this will block */ - status = RecvBuffers(pDev, mbox); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Recv buffers Failed : %d mbox:%d\n",status,mbox)); - break; - } - - /* check the returned data patterns */ - if (!CheckBuffers()) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer Verify Failed : mbox:%d\n",mbox)); - status = A_ERROR; - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" Send/Recv success! mailbox : %d \n",mbox)); - - } while (false); - - return status; -} - -/* here is where the test starts */ -int DoMboxHWTest(struct ar6k_device *pDev) -{ - int i; - int status; - int credits = 0; - u8 params[4]; - int numBufs; - int bufferSize; - u16 temp; - - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest START - \n")); - - do { - /* get the addresses for all 4 mailboxes */ - status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR, - g_MailboxAddrs, sizeof(g_MailboxAddrs)); - - if (status) { - A_ASSERT(false); - break; - } - - /* get the block sizes */ - status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, - g_BlockSizes, sizeof(g_BlockSizes)); - - if (status) { - A_ASSERT(false); - break; - } - - /* note, the HIF layer usually reports mbox 0 to have a block size of - * 1, but our test wants to run in block-mode for all mailboxes, so we treat all mailboxes - * the same. */ - g_BlockSizes[0] = g_BlockSizes[1]; - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Block Size to use: %d \n",g_BlockSizes[0])); - - if (g_BlockSizes[1] > BUFFER_BLOCK_PAD) { - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("%d Block size is too large for buffer pad %d\n", - g_BlockSizes[1], BUFFER_BLOCK_PAD)); - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for target.... \n")); - - /* the target lets us know it is ready by giving us 1 credit on - * mailbox 0 */ - status = GetCredits(pDev, 0, &credits); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait for target ready \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target is ready ...\n")); - - /* read the first 4 scratch registers */ - status = HIFReadWrite(pDev->HIFDevice, - SCRATCH_ADDRESS, - params, - 4, - HIF_RD_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait get parameters \n")); - break; - } - - numBufs = params[0]; - bufferSize = (int)(((u16)params[2] << 8) | (u16)params[1]); - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, - ("Target parameters: bufs per mailbox:%d, buffer size:%d bytes (total space: %d, minimum required space (w/padding): %d) \n", - numBufs, bufferSize, (numBufs * bufferSize), TOTAL_BYTES)); - - if ((numBufs * bufferSize) < TOTAL_BYTES) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Not Enough buffer space to run test! need:%d, got:%d \n", - TOTAL_BYTES, (numBufs*bufferSize))); - status = A_ERROR; - break; - } - - temp = GetEndMarker(); - - status = HIFReadWrite(pDev->HIFDevice, - SCRATCH_ADDRESS + 4, - (u8 *)&temp, - 2, - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write end marker \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("End Marker: 0x%X \n",temp)); - - temp = (u16)g_BlockSizes[1]; - /* convert to a mask */ - temp = temp - 1; - status = HIFReadWrite(pDev->HIFDevice, - SCRATCH_ADDRESS + 6, - (u8 *)&temp, - 2, - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write block mask \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Set Block Mask: 0x%X \n",temp)); - - /* execute the test on each mailbox */ - for (i = 0; i < AR6K_MAILBOXES; i++) { - status = DoOneMboxHWTest(pDev, i); - if (status) { - break; - } - } - - } while (false); - - if (status == 0) { - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - SUCCESS! - \n")); - } else { - AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - FAILED! - \n")); - } - /* don't let HTC_Start continue, the target is actually not running any HTC code */ - return A_ERROR; -} -#endif - - - diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k.h b/drivers/staging/ath6kl/htc2/AR6000/ar6k.h deleted file mode 100644 index e551dbe674d..00000000000 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k.h +++ /dev/null @@ -1,401 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// AR6K device layer that handles register level I/O -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef AR6K_H_ -#define AR6K_H_ - -#include "hci_transport_api.h" -#include "../htc_debug.h" - -#define AR6K_MAILBOXES 4 - -/* HTC runs over mailbox 0 */ -#define HTC_MAILBOX 0 - -#define AR6K_TARGET_DEBUG_INTR_MASK 0x01 - -#define OTHER_INTS_ENABLED (INT_STATUS_ENABLE_ERROR_MASK | \ - INT_STATUS_ENABLE_CPU_MASK | \ - INT_STATUS_ENABLE_COUNTER_MASK) - - -//#define MBOXHW_UNIT_TEST 1 - -PREPACK struct ar6k_irq_proc_registers { - u8 host_int_status; - u8 cpu_int_status; - u8 error_int_status; - u8 counter_int_status; - u8 mbox_frame; - u8 rx_lookahead_valid; - u8 host_int_status2; - u8 gmbox_rx_avail; - u32 rx_lookahead[2]; - u32 rx_gmbox_lookahead_alias[2]; -} POSTPACK; - -#define AR6K_IRQ_PROC_REGS_SIZE sizeof(struct ar6k_irq_proc_registers) - -PREPACK struct ar6k_irq_enable_registers { - u8 int_status_enable; - u8 cpu_int_status_enable; - u8 error_status_enable; - u8 counter_int_status_enable; -} POSTPACK; - -PREPACK struct ar6k_gmbox_ctrl_registers { - u8 int_status_enable; -} POSTPACK; - -#define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(struct ar6k_irq_enable_registers) - -#define AR6K_REG_IO_BUFFER_SIZE 32 -#define AR6K_MAX_REG_IO_BUFFERS 8 -#define FROM_DMA_BUFFER true -#define TO_DMA_BUFFER false -#define AR6K_SCATTER_ENTRIES_PER_REQ 16 -#define AR6K_MAX_TRANSFER_SIZE_PER_SCATTER 16*1024 -#define AR6K_SCATTER_REQS 4 -#define AR6K_LEGACY_MAX_WRITE_LENGTH 2048 - -#ifndef A_CACHE_LINE_PAD -#define A_CACHE_LINE_PAD 128 -#endif -#define AR6K_MIN_SCATTER_ENTRIES_PER_REQ 2 -#define AR6K_MIN_TRANSFER_SIZE_PER_SCATTER 4*1024 - -/* buffers for ASYNC I/O */ -struct ar6k_async_reg_io_buffer { - struct htc_packet HtcPacket; /* we use an HTC packet as a wrapper for our async register-based I/O */ - u8 _Pad1[A_CACHE_LINE_PAD]; - u8 Buffer[AR6K_REG_IO_BUFFER_SIZE]; /* cache-line safe with pads around */ - u8 _Pad2[A_CACHE_LINE_PAD]; -}; - -struct ar6k_gmbox_info { - void *pProtocolContext; - int (*pMessagePendingCallBack)(void *pContext, u8 LookAheadBytes[], int ValidBytes); - int (*pCreditsPendingCallback)(void *pContext, int NumCredits, bool CreditIRQEnabled); - void (*pTargetFailureCallback)(void *pContext, int Status); - void (*pStateDumpCallback)(void *pContext); - bool CreditCountIRQEnabled; -}; - -struct ar6k_device { - A_MUTEX_T Lock; - u8 _Pad1[A_CACHE_LINE_PAD]; - struct ar6k_irq_proc_registers IrqProcRegisters; /* cache-line safe with pads around */ - u8 _Pad2[A_CACHE_LINE_PAD]; - struct ar6k_irq_enable_registers IrqEnableRegisters; /* cache-line safe with pads around */ - u8 _Pad3[A_CACHE_LINE_PAD]; - void *HIFDevice; - u32 BlockSize; - u32 BlockMask; - struct hif_device_mbox_info MailBoxInfo; - HIF_PENDING_EVENTS_FUNC GetPendingEventsFunc; - void *HTCContext; - struct htc_packet_queue RegisterIOList; - struct ar6k_async_reg_io_buffer RegIOBuffers[AR6K_MAX_REG_IO_BUFFERS]; - void (*TargetFailureCallback)(void *Context); - int (*MessagePendingCallback)(void *Context, - u32 LookAheads[], - int NumLookAheads, - bool *pAsyncProc, - int *pNumPktsFetched); - HIF_DEVICE_IRQ_PROCESSING_MODE HifIRQProcessingMode; - HIF_MASK_UNMASK_RECV_EVENT HifMaskUmaskRecvEvent; - bool HifAttached; - struct hif_device_irq_yield_params HifIRQYieldParams; - bool DSRCanYield; - int CurrentDSRRecvCount; - struct hif_device_scatter_support_info HifScatterInfo; - struct dl_list ScatterReqHead; - bool ScatterIsVirtual; - int MaxRecvBundleSize; - int MaxSendBundleSize; - struct ar6k_gmbox_info GMboxInfo; - bool GMboxEnabled; - struct ar6k_gmbox_ctrl_registers GMboxControlRegisters; - int RecheckIRQStatusCnt; -}; - -#define LOCK_AR6K(p) A_MUTEX_LOCK(&(p)->Lock); -#define UNLOCK_AR6K(p) A_MUTEX_UNLOCK(&(p)->Lock); -#define REF_IRQ_STATUS_RECHECK(p) (p)->RecheckIRQStatusCnt = 1 /* note: no need to lock this, it only gets set */ - -int DevSetup(struct ar6k_device *pDev); -void DevCleanup(struct ar6k_device *pDev); -int DevUnmaskInterrupts(struct ar6k_device *pDev); -int DevMaskInterrupts(struct ar6k_device *pDev); -int DevPollMboxMsgRecv(struct ar6k_device *pDev, - u32 *pLookAhead, - int TimeoutMS); -int DevRWCompletionHandler(void *context, int status); -int DevDsrHandler(void *context); -int DevCheckPendingRecvMsgsAsync(void *context); -void DevAsyncIrqProcessComplete(struct ar6k_device *pDev); -void DevDumpRegisters(struct ar6k_device *pDev, - struct ar6k_irq_proc_registers *pIrqProcRegs, - struct ar6k_irq_enable_registers *pIrqEnableRegs); - -#define DEV_STOP_RECV_ASYNC true -#define DEV_STOP_RECV_SYNC false -#define DEV_ENABLE_RECV_ASYNC true -#define DEV_ENABLE_RECV_SYNC false -int DevStopRecv(struct ar6k_device *pDev, bool ASyncMode); -int DevEnableRecv(struct ar6k_device *pDev, bool ASyncMode); -int DevEnableInterrupts(struct ar6k_device *pDev); -int DevDisableInterrupts(struct ar6k_device *pDev); -int DevWaitForPendingRecv(struct ar6k_device *pDev,u32 TimeoutInMs,bool *pbIsRecvPending); - -#define DEV_CALC_RECV_PADDED_LEN(pDev, length) (((length) + (pDev)->BlockMask) & (~((pDev)->BlockMask))) -#define DEV_CALC_SEND_PADDED_LEN(pDev, length) DEV_CALC_RECV_PADDED_LEN(pDev,length) -#define DEV_IS_LEN_BLOCK_ALIGNED(pDev, length) (((length) % (pDev)->BlockSize) == 0) - -static INLINE int DevSendPacket(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 SendLength) { - u32 paddedLength; - bool sync = (pPacket->Completion == NULL) ? true : false; - int status; - - /* adjust the length to be a multiple of block size if appropriate */ - paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, SendLength); - -#if 0 - if (paddedLength > pPacket->BufferLength) { - A_ASSERT(false); - if (pPacket->Completion != NULL) { - COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return 0; - } - return A_EINVAL; - } -#endif - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - ("DevSendPacket, Padded Length: %d Mbox:0x%X (mode:%s)\n", - paddedLength, - pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX], - sync ? "SYNC" : "ASYNC")); - - status = HIFReadWrite(pDev->HIFDevice, - pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX], - pPacket->pBuffer, - paddedLength, /* the padded length */ - sync ? HIF_WR_SYNC_BLOCK_INC : HIF_WR_ASYNC_BLOCK_INC, - sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ - - if (sync) { - pPacket->Status = status; - } else { - if (status == A_PENDING) { - status = 0; - } - } - - return status; -} - -static INLINE int DevRecvPacket(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 RecvLength) { - u32 paddedLength; - int status; - bool sync = (pPacket->Completion == NULL) ? true : false; - - /* adjust the length to be a multiple of block size if appropriate */ - paddedLength = DEV_CALC_RECV_PADDED_LEN(pDev, RecvLength); - - if (paddedLength > pPacket->BufferLength) { - A_ASSERT(false); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("DevRecvPacket, Not enough space for padlen:%d recvlen:%d bufferlen:%d \n", - paddedLength,RecvLength,pPacket->BufferLength)); - if (pPacket->Completion != NULL) { - COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return 0; - } - return A_EINVAL; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("DevRecvPacket (0x%lX : hdr:0x%X) Padded Length: %d Mbox:0x%X (mode:%s)\n", - (unsigned long)pPacket, pPacket->PktInfo.AsRx.ExpectedHdr, - paddedLength, - pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX], - sync ? "SYNC" : "ASYNC")); - - status = HIFReadWrite(pDev->HIFDevice, - pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX], - pPacket->pBuffer, - paddedLength, - sync ? HIF_RD_SYNC_BLOCK_FIX : HIF_RD_ASYNC_BLOCK_FIX, - sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ - - if (sync) { - pPacket->Status = status; - } - - return status; -} - -#define DEV_CHECK_RECV_YIELD(pDev) \ - ((pDev)->CurrentDSRRecvCount >= (pDev)->HifIRQYieldParams.RecvPacketYieldCount) - -#define IS_DEV_IRQ_PROC_SYNC_MODE(pDev) (HIF_DEVICE_IRQ_SYNC_ONLY == (pDev)->HifIRQProcessingMode) -#define IS_DEV_IRQ_PROCESSING_ASYNC_ALLOWED(pDev) ((pDev)->HifIRQProcessingMode != HIF_DEVICE_IRQ_SYNC_ONLY) - -/**************************************************/ -/****** Scatter Function and Definitions - * - * - */ - -int DevCopyScatterListToFromDMABuffer(struct hif_scatter_req *pReq, bool FromDMA); - - /* copy any READ data back into scatter list */ -#define DEV_FINISH_SCATTER_OPERATION(pR) \ -do { \ - if (!((pR)->CompletionStatus) && \ - !((pR)->Request & HIF_WRITE) && \ - ((pR)->ScatterMethod == HIF_SCATTER_DMA_BOUNCE)) { \ - (pR)->CompletionStatus = \ - DevCopyScatterListToFromDMABuffer((pR), \ - FROM_DMA_BUFFER); \ - } \ -} while (0) - - /* copy any WRITE data to bounce buffer */ -static INLINE int DEV_PREPARE_SCATTER_OPERATION(struct hif_scatter_req *pReq) { - if ((pReq->Request & HIF_WRITE) && (pReq->ScatterMethod == HIF_SCATTER_DMA_BOUNCE)) { - return DevCopyScatterListToFromDMABuffer(pReq,TO_DMA_BUFFER); - } else { - return 0; - } -} - - -int DevSetupMsgBundling(struct ar6k_device *pDev, int MaxMsgsPerTransfer); - -int DevCleanupMsgBundling(struct ar6k_device *pDev); - -#define DEV_GET_MAX_MSG_PER_BUNDLE(pDev) (pDev)->HifScatterInfo.MaxScatterEntries -#define DEV_GET_MAX_BUNDLE_LENGTH(pDev) (pDev)->HifScatterInfo.MaxTransferSizePerScatterReq -#define DEV_ALLOC_SCATTER_REQ(pDev) \ - (pDev)->HifScatterInfo.pAllocateReqFunc((pDev)->ScatterIsVirtual ? (pDev) : (pDev)->HIFDevice) - -#define DEV_FREE_SCATTER_REQ(pDev,pR) \ - (pDev)->HifScatterInfo.pFreeReqFunc((pDev)->ScatterIsVirtual ? (pDev) : (pDev)->HIFDevice,(pR)) - -#define DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev) (pDev)->MaxRecvBundleSize -#define DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev) (pDev)->MaxSendBundleSize - -#define DEV_SCATTER_READ true -#define DEV_SCATTER_WRITE false -#define DEV_SCATTER_ASYNC true -#define DEV_SCATTER_SYNC false -int DevSubmitScatterRequest(struct ar6k_device *pDev, struct hif_scatter_req *pScatterReq, bool Read, bool Async); - -#ifdef MBOXHW_UNIT_TEST -int DoMboxHWTest(struct ar6k_device *pDev); -#endif - - /* completely virtual */ -struct dev_scatter_dma_virtual_info { - u8 *pVirtDmaBuffer; /* dma-able buffer - CPU accessible address */ - u8 DataArea[1]; /* start of data area */ -}; - - - -void DumpAR6KDevState(struct ar6k_device *pDev); - -/**************************************************/ -/****** GMBOX functions and definitions - * - * - */ - -#ifdef ATH_AR6K_ENABLE_GMBOX - -void DevCleanupGMbox(struct ar6k_device *pDev); -int DevSetupGMbox(struct ar6k_device *pDev); -int DevCheckGMboxInterrupts(struct ar6k_device *pDev); -void DevNotifyGMboxTargetFailure(struct ar6k_device *pDev); - -#else - - /* compiled out */ -#define DevCleanupGMbox(p) -#define DevCheckGMboxInterrupts(p) 0 -#define DevNotifyGMboxTargetFailure(p) - -static INLINE int DevSetupGMbox(struct ar6k_device *pDev) { - pDev->GMboxEnabled = false; - return 0; -} - -#endif - -#ifdef ATH_AR6K_ENABLE_GMBOX - - /* GMBOX protocol modules must expose each of these internal APIs */ -HCI_TRANSPORT_HANDLE GMboxAttachProtocol(struct ar6k_device *pDev, struct hci_transport_config_info *pInfo); -int GMboxProtocolInstall(struct ar6k_device *pDev); -void GMboxProtocolUninstall(struct ar6k_device *pDev); - - /* API used by GMBOX protocol modules */ -struct ar6k_device *HTCGetAR6KDevice(void *HTCHandle); -#define DEV_GMBOX_SET_PROTOCOL(pDev,recv_callback,credits_pending,failure,statedump,context) \ -{ \ - (pDev)->GMboxInfo.pProtocolContext = (context); \ - (pDev)->GMboxInfo.pMessagePendingCallBack = (recv_callback); \ - (pDev)->GMboxInfo.pCreditsPendingCallback = (credits_pending); \ - (pDev)->GMboxInfo.pTargetFailureCallback = (failure); \ - (pDev)->GMboxInfo.pStateDumpCallback = (statedump); \ -} - -#define DEV_GMBOX_GET_PROTOCOL(pDev) (pDev)->GMboxInfo.pProtocolContext - -int DevGMboxWrite(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 WriteLength); -int DevGMboxRead(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 ReadLength); - -#define PROC_IO_ASYNC true -#define PROC_IO_SYNC false -typedef enum GMBOX_IRQ_ACTION_TYPE { - GMBOX_ACTION_NONE = 0, - GMBOX_DISABLE_ALL, - GMBOX_ERRORS_IRQ_ENABLE, - GMBOX_RECV_IRQ_ENABLE, - GMBOX_RECV_IRQ_DISABLE, - GMBOX_CREDIT_IRQ_ENABLE, - GMBOX_CREDIT_IRQ_DISABLE, -} GMBOX_IRQ_ACTION_TYPE; - -int DevGMboxIRQAction(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE, bool AsyncMode); -int DevGMboxReadCreditCounter(struct ar6k_device *pDev, bool AsyncMode, int *pCredits); -int DevGMboxReadCreditSize(struct ar6k_device *pDev, int *pCreditSize); -int DevGMboxRecvLookAheadPeek(struct ar6k_device *pDev, u8 *pLookAheadBuffer, int *pLookAheadBytes); -int DevGMboxSetTargetInterrupt(struct ar6k_device *pDev, int SignalNumber, int AckTimeoutMS); - -#endif - -#endif /*AR6K_H_*/ diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c deleted file mode 100644 index d7af68f7056..00000000000 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c +++ /dev/null @@ -1,783 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// AR6K Driver layer event handling (i.e. interrupts, message polling) -// -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" -#include "hw/mbox_host_reg.h" -#include "a_osapi.h" -#include "../htc_debug.h" -#include "hif.h" -#include "htc_packet.h" -#include "ar6k.h" - -extern void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket); -extern struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev); - -static int DevServiceDebugInterrupt(struct ar6k_device *pDev); - -#define DELAY_PER_INTERVAL_MS 10 /* 10 MS delay per polling interval */ - -/* completion routine for ALL HIF layer async I/O */ -int DevRWCompletionHandler(void *context, int status) -{ - struct htc_packet *pPacket = (struct htc_packet *)context; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("+DevRWCompletionHandler (Pkt:0x%lX) , Status: %d \n", - (unsigned long)pPacket, - status)); - - COMPLETE_HTC_PACKET(pPacket,status); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("-DevRWCompletionHandler\n")); - - return 0; -} - -/* mailbox recv message polling */ -int DevPollMboxMsgRecv(struct ar6k_device *pDev, - u32 *pLookAhead, - int TimeoutMS) -{ - int status = 0; - int timeout = TimeoutMS/DELAY_PER_INTERVAL_MS; - - A_ASSERT(timeout > 0); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevPollMboxMsgRecv \n")); - - while (true) { - - if (pDev->GetPendingEventsFunc != NULL) { - - struct hif_pending_events_info events; - -#ifdef THREAD_X - events.Polling =1; -#endif - - /* the HIF layer uses a special mechanism to get events, do this - * synchronously */ - status = pDev->GetPendingEventsFunc(pDev->HIFDevice, - &events, - NULL); - if (status) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get pending events \n")); - break; - } - - if (events.Events & HIF_RECV_MSG_AVAIL) - { - /* there is a message available, the lookahead should be valid now */ - *pLookAhead = events.LookAhead; - - break; - } - } else { - - /* this is the standard HIF way.... */ - /* load the register table */ - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - (u8 *)&pDev->IrqProcRegisters, - AR6K_IRQ_PROC_REGS_SIZE, - HIF_RD_SYNC_BYTE_INC, - NULL); - - if (status){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to read register table \n")); - break; - } - - /* check for MBOX data and valid lookahead */ - if (pDev->IrqProcRegisters.host_int_status & (1 << HTC_MAILBOX)) { - if (pDev->IrqProcRegisters.rx_lookahead_valid & (1 << HTC_MAILBOX)) - { - /* mailbox has a message and the look ahead is valid */ - *pLookAhead = pDev->IrqProcRegisters.rx_lookahead[HTC_MAILBOX]; - break; - } - } - - } - - timeout--; - - if (timeout <= 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Timeout waiting for recv message \n")); - status = A_ERROR; - - /* check if the target asserted */ - if ( pDev->IrqProcRegisters.counter_int_status & AR6K_TARGET_DEBUG_INTR_MASK) { - /* target signaled an assert, process this pending interrupt - * this will call the target failure handler */ - DevServiceDebugInterrupt(pDev); - } - - break; - } - - /* delay a little */ - A_MDELAY(DELAY_PER_INTERVAL_MS); - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" Retry Mbox Poll : %d \n",timeout)); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-DevPollMboxMsgRecv \n")); - - return status; -} - -static int DevServiceCPUInterrupt(struct ar6k_device *pDev) -{ - int status; - u8 cpu_int_status; - u8 regBuffer[4]; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("CPU Interrupt\n")); - cpu_int_status = pDev->IrqProcRegisters.cpu_int_status & - pDev->IrqEnableRegisters.cpu_int_status_enable; - A_ASSERT(cpu_int_status); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - ("Valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n", - cpu_int_status)); - - /* Clear the interrupt */ - pDev->IrqProcRegisters.cpu_int_status &= ~cpu_int_status; /* W1C */ - - /* set up the register transfer buffer to hit the register 4 times , this is done - * to make the access 4-byte aligned to mitigate issues with host bus interconnects that - * restrict bus transfer lengths to be a multiple of 4-bytes */ - - /* set W1C value to clear the interrupt, this hits the register first */ - regBuffer[0] = cpu_int_status; - /* the remaining 4 values are set to zero which have no-effect */ - regBuffer[1] = 0; - regBuffer[2] = 0; - regBuffer[3] = 0; - - status = HIFReadWrite(pDev->HIFDevice, - CPU_INT_STATUS_ADDRESS, - regBuffer, - 4, - HIF_WR_SYNC_BYTE_FIX, - NULL); - - A_ASSERT(status == 0); - return status; -} - - -static int DevServiceErrorInterrupt(struct ar6k_device *pDev) -{ - int status; - u8 error_int_status; - u8 regBuffer[4]; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error Interrupt\n")); - error_int_status = pDev->IrqProcRegisters.error_int_status & 0x0F; - A_ASSERT(error_int_status); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - ("Valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n", - error_int_status)); - - if (ERROR_INT_STATUS_WAKEUP_GET(error_int_status)) { - /* Wakeup */ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error : Wakeup\n")); - } - - if (ERROR_INT_STATUS_RX_UNDERFLOW_GET(error_int_status)) { - /* Rx Underflow */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Error : Rx Underflow\n")); - } - - if (ERROR_INT_STATUS_TX_OVERFLOW_GET(error_int_status)) { - /* Tx Overflow */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Error : Tx Overflow\n")); - } - - /* Clear the interrupt */ - pDev->IrqProcRegisters.error_int_status &= ~error_int_status; /* W1C */ - - /* set up the register transfer buffer to hit the register 4 times , this is done - * to make the access 4-byte aligned to mitigate issues with host bus interconnects that - * restrict bus transfer lengths to be a multiple of 4-bytes */ - - /* set W1C value to clear the interrupt, this hits the register first */ - regBuffer[0] = error_int_status; - /* the remaining 4 values are set to zero which have no-effect */ - regBuffer[1] = 0; - regBuffer[2] = 0; - regBuffer[3] = 0; - - status = HIFReadWrite(pDev->HIFDevice, - ERROR_INT_STATUS_ADDRESS, - regBuffer, - 4, - HIF_WR_SYNC_BYTE_FIX, - NULL); - - A_ASSERT(status == 0); - return status; -} - -static int DevServiceDebugInterrupt(struct ar6k_device *pDev) -{ - u32 dummy; - int status; - - /* Send a target failure event to the application */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Target debug interrupt\n")); - - if (pDev->TargetFailureCallback != NULL) { - pDev->TargetFailureCallback(pDev->HTCContext); - } - - if (pDev->GMboxEnabled) { - DevNotifyGMboxTargetFailure(pDev); - } - - /* clear the interrupt , the debug error interrupt is - * counter 0 */ - /* read counter to clear interrupt */ - status = HIFReadWrite(pDev->HIFDevice, - COUNT_DEC_ADDRESS, - (u8 *)&dummy, - 4, - HIF_RD_SYNC_BYTE_INC, - NULL); - - A_ASSERT(status == 0); - return status; -} - -static int DevServiceCounterInterrupt(struct ar6k_device *pDev) -{ - u8 counter_int_status; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Counter Interrupt\n")); - - counter_int_status = pDev->IrqProcRegisters.counter_int_status & - pDev->IrqEnableRegisters.counter_int_status_enable; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - ("Valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n", - counter_int_status)); - - /* Check if the debug interrupt is pending - * NOTE: other modules like GMBOX may use the counter interrupt for - * credit flow control on other counters, we only need to check for the debug assertion - * counter interrupt */ - if (counter_int_status & AR6K_TARGET_DEBUG_INTR_MASK) { - return DevServiceDebugInterrupt(pDev); - } - - return 0; -} - -/* callback when our fetch to get interrupt status registers completes */ -static void DevGetEventAsyncHandler(void *Context, struct htc_packet *pPacket) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - u32 lookAhead = 0; - bool otherInts = false; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGetEventAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - do { - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" GetEvents I/O request failed, status:%d \n", pPacket->Status)); - /* bail out, don't unmask HIF interrupt */ - break; - } - - if (pDev->GetPendingEventsFunc != NULL) { - /* the HIF layer collected the information for us */ - struct hif_pending_events_info *pEvents = (struct hif_pending_events_info *)pPacket->pBuffer; - if (pEvents->Events & HIF_RECV_MSG_AVAIL) { - lookAhead = pEvents->LookAhead; - if (0 == lookAhead) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" DevGetEventAsyncHandler1, lookAhead is zero! \n")); - } - } - if (pEvents->Events & HIF_OTHER_EVENTS) { - otherInts = true; - } - } else { - /* standard interrupt table handling.... */ - struct ar6k_irq_proc_registers *pReg = (struct ar6k_irq_proc_registers *)pPacket->pBuffer; - u8 host_int_status; - - host_int_status = pReg->host_int_status & pDev->IrqEnableRegisters.int_status_enable; - - if (host_int_status & (1 << HTC_MAILBOX)) { - host_int_status &= ~(1 << HTC_MAILBOX); - if (pReg->rx_lookahead_valid & (1 << HTC_MAILBOX)) { - /* mailbox has a message and the look ahead is valid */ - lookAhead = pReg->rx_lookahead[HTC_MAILBOX]; - if (0 == lookAhead) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" DevGetEventAsyncHandler2, lookAhead is zero! \n")); - } - } - } - - if (host_int_status) { - /* there are other interrupts to handle */ - otherInts = true; - } - } - - if (otherInts || (lookAhead == 0)) { - /* if there are other interrupts to process, we cannot do this in the async handler so - * ack the interrupt which will cause our sync handler to run again - * if however there are no more messages, we can now ack the interrupt */ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - (" Acking interrupt from DevGetEventAsyncHandler (otherints:%d, lookahead:0x%X)\n", - otherInts, lookAhead)); - HIFAckInterrupt(pDev->HIFDevice); - } else { - int fetched = 0; - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - (" DevGetEventAsyncHandler : detected another message, lookahead :0x%X \n", - lookAhead)); - /* lookahead is non-zero and there are no other interrupts to service, - * go get the next message */ - status = pDev->MessagePendingCallback(pDev->HTCContext, &lookAhead, 1, NULL, &fetched); - - if (!status && !fetched) { - /* HTC layer could not pull out messages due to lack of resources, stop IRQ processing */ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("MessagePendingCallback did not pull any messages, force-ack \n")); - DevAsyncIrqProcessComplete(pDev); - } - } - - } while (false); - - /* free this IO packet */ - AR6KFreeIOPacket(pDev,pPacket); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGetEventAsyncHandler \n")); -} - -/* called by the HTC layer when it wants us to check if the device has any more pending - * recv messages, this starts off a series of async requests to read interrupt registers */ -int DevCheckPendingRecvMsgsAsync(void *context) -{ - struct ar6k_device *pDev = (struct ar6k_device *)context; - int status = 0; - struct htc_packet *pIOPacket; - - /* this is called in an ASYNC only context, we may NOT block, sleep or call any apis that can - * cause us to switch contexts */ - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevCheckPendingRecvMsgsAsync: (dev: 0x%lX)\n", (unsigned long)pDev)); - - do { - - if (HIF_DEVICE_IRQ_SYNC_ONLY == pDev->HifIRQProcessingMode) { - /* break the async processing chain right here, no need to continue. - * The DevDsrHandler() will handle things in a loop when things are driven - * synchronously */ - break; - } - - /* an optimization to bypass reading the IRQ status registers unecessarily which can re-wake - * the target, if upper layers determine that we are in a low-throughput mode, we can - * rely on taking another interrupt rather than re-checking the status registers which can - * re-wake the target */ - if (pDev->RecheckIRQStatusCnt == 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("Bypassing IRQ Status re-check, re-acking HIF interrupts\n")); - /* ack interrupt */ - HIFAckInterrupt(pDev->HIFDevice); - break; - } - - /* first allocate one of our HTC packets we created for async I/O - * we reuse HTC packet definitions so that we can use the completion mechanism - * in DevRWCompletionHandler() */ - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - /* there should be only 1 asynchronous request out at a time to read these registers - * so this should actually never happen */ - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevGetEventAsyncHandler; - pIOPacket->pContext = pDev; - - if (pDev->GetPendingEventsFunc) { - /* HIF layer has it's own mechanism, pass the IO to it.. */ - status = pDev->GetPendingEventsFunc(pDev->HIFDevice, - (struct hif_pending_events_info *)pIOPacket->pBuffer, - pIOPacket); - - } else { - /* standard way, read the interrupt register table asynchronously again */ - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - pIOPacket->pBuffer, - AR6K_IRQ_PROC_REGS_SIZE, - HIF_RD_ASYNC_BYTE_INC, - pIOPacket); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Async IO issued to get interrupt status...\n")); - } while (false); - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevCheckPendingRecvMsgsAsync \n")); - - return status; -} - -void DevAsyncIrqProcessComplete(struct ar6k_device *pDev) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("DevAsyncIrqProcessComplete - forcing HIF IRQ ACK \n")); - HIFAckInterrupt(pDev->HIFDevice); -} - -/* process pending interrupts synchronously */ -static int ProcessPendingIRQs(struct ar6k_device *pDev, bool *pDone, bool *pASyncProcessing) -{ - int status = 0; - u8 host_int_status = 0; - u32 lookAhead = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+ProcessPendingIRQs: (dev: 0x%lX)\n", (unsigned long)pDev)); - - /*** NOTE: the HIF implementation guarantees that the context of this call allows - * us to perform SYNCHRONOUS I/O, that is we can block, sleep or call any API that - * can block or switch thread/task ontexts. - * This is a fully schedulable context. - * */ - do { - - if (pDev->IrqEnableRegisters.int_status_enable == 0) { - /* interrupt enables have been cleared, do not try to process any pending interrupts that - * may result in more bus transactions. The target may be unresponsive at this - * point. */ - break; - } - - if (pDev->GetPendingEventsFunc != NULL) { - struct hif_pending_events_info events; - -#ifdef THREAD_X - events.Polling= 0; -#endif - /* the HIF layer uses a special mechanism to get events - * get this synchronously */ - status = pDev->GetPendingEventsFunc(pDev->HIFDevice, - &events, - NULL); - - if (status) { - break; - } - - if (events.Events & HIF_RECV_MSG_AVAIL) { - lookAhead = events.LookAhead; - if (0 == lookAhead) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ProcessPendingIRQs1 lookAhead is zero! \n")); - } - } - - if (!(events.Events & HIF_OTHER_EVENTS) || - !(pDev->IrqEnableRegisters.int_status_enable & OTHER_INTS_ENABLED)) { - /* no need to read the register table, no other interesting interrupts. - * Some interfaces (like SPI) can shadow interrupt sources without - * requiring the host to do a full table read */ - break; - } - - /* otherwise fall through and read the register table */ - } - - /* - * Read the first 28 bytes of the HTC register table. This will yield us - * the value of different int status registers and the lookahead - * registers. - * length = sizeof(int_status) + sizeof(cpu_int_status) + - * sizeof(error_int_status) + sizeof(counter_int_status) + - * sizeof(mbox_frame) + sizeof(rx_lookahead_valid) + - * sizeof(hole) + sizeof(rx_lookahead) + - * sizeof(int_status_enable) + sizeof(cpu_int_status_enable) + - * sizeof(error_status_enable) + - * sizeof(counter_int_status_enable); - * - */ -#ifdef CONFIG_MMC_SDHCI_S3C - pDev->IrqProcRegisters.host_int_status = 0; - pDev->IrqProcRegisters.rx_lookahead_valid = 0; - pDev->IrqProcRegisters.host_int_status2 = 0; - pDev->IrqProcRegisters.rx_lookahead[0] = 0; - pDev->IrqProcRegisters.rx_lookahead[1] = 0xaaa5555; -#endif /* CONFIG_MMC_SDHCI_S3C */ - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - (u8 *)&pDev->IrqProcRegisters, - AR6K_IRQ_PROC_REGS_SIZE, - HIF_RD_SYNC_BYTE_INC, - NULL); - - if (status) { - break; - } - -#ifdef ATH_DEBUG_MODULE - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_IRQ)) { - DevDumpRegisters(pDev, - &pDev->IrqProcRegisters, - &pDev->IrqEnableRegisters); - } -#endif - - /* Update only those registers that are enabled */ - host_int_status = pDev->IrqProcRegisters.host_int_status & - pDev->IrqEnableRegisters.int_status_enable; - - if (NULL == pDev->GetPendingEventsFunc) { - /* only look at mailbox status if the HIF layer did not provide this function, - * on some HIF interfaces reading the RX lookahead is not valid to do */ - if (host_int_status & (1 << HTC_MAILBOX)) { - /* mask out pending mailbox value, we use "lookAhead" as the real flag for - * mailbox processing below */ - host_int_status &= ~(1 << HTC_MAILBOX); - if (pDev->IrqProcRegisters.rx_lookahead_valid & (1 << HTC_MAILBOX)) { - /* mailbox has a message and the look ahead is valid */ - lookAhead = pDev->IrqProcRegisters.rx_lookahead[HTC_MAILBOX]; - if (0 == lookAhead) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ProcessPendingIRQs2, lookAhead is zero! \n")); - } - } - } - } else { - /* not valid to check if the HIF has another mechanism for reading mailbox pending status*/ - host_int_status &= ~(1 << HTC_MAILBOX); - } - - if (pDev->GMboxEnabled) { - /*call GMBOX layer to process any interrupts of interest */ - status = DevCheckGMboxInterrupts(pDev); - } - - } while (false); - - - do { - - /* did the interrupt status fetches succeed? */ - if (status) { - break; - } - - if ((0 == host_int_status) && (0 == lookAhead)) { - /* nothing to process, the caller can use this to break out of a loop */ - *pDone = true; - break; - } - - if (lookAhead != 0) { - int fetched = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("Pending mailbox message, LookAhead: 0x%X\n",lookAhead)); - /* Mailbox Interrupt, the HTC layer may issue async requests to empty the - * mailbox... - * When emptying the recv mailbox we use the async handler above called from the - * completion routine of the callers read request. This can improve performance - * by reducing context switching when we rapidly pull packets */ - status = pDev->MessagePendingCallback(pDev->HTCContext, &lookAhead, 1, pASyncProcessing, &fetched); - if (status) { - break; - } - - if (!fetched) { - /* HTC could not pull any messages out due to lack of resources */ - /* force DSR handler to ack the interrupt */ - *pASyncProcessing = false; - pDev->RecheckIRQStatusCnt = 0; - } - } - - /* now handle the rest of them */ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - (" Valid interrupt source(s) for OTHER interrupts: 0x%x\n", - host_int_status)); - - if (HOST_INT_STATUS_CPU_GET(host_int_status)) { - /* CPU Interrupt */ - status = DevServiceCPUInterrupt(pDev); - if (status){ - break; - } - } - - if (HOST_INT_STATUS_ERROR_GET(host_int_status)) { - /* Error Interrupt */ - status = DevServiceErrorInterrupt(pDev); - if (status){ - break; - } - } - - if (HOST_INT_STATUS_COUNTER_GET(host_int_status)) { - /* Counter Interrupt */ - status = DevServiceCounterInterrupt(pDev); - if (status){ - break; - } - } - - } while (false); - - /* an optimization to bypass reading the IRQ status registers unecessarily which can re-wake - * the target, if upper layers determine that we are in a low-throughput mode, we can - * rely on taking another interrupt rather than re-checking the status registers which can - * re-wake the target. - * - * NOTE : for host interfaces that use the special GetPendingEventsFunc, this optimization cannot - * be used due to possible side-effects. For example, SPI requires the host to drain all - * messages from the mailbox before exiting the ISR routine. */ - if (!(*pASyncProcessing) && (pDev->RecheckIRQStatusCnt == 0) && (pDev->GetPendingEventsFunc == NULL)) { - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("Bypassing IRQ Status re-check, forcing done \n")); - *pDone = true; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-ProcessPendingIRQs: (done:%d, async:%d) status=%d \n", - *pDone, *pASyncProcessing, status)); - - return status; -} - - -/* Synchronousinterrupt handler, this handler kicks off all interrupt processing.*/ -int DevDsrHandler(void *context) -{ - struct ar6k_device *pDev = (struct ar6k_device *)context; - int status = 0; - bool done = false; - bool asyncProc = false; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDsrHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - /* reset the recv counter that tracks when we need to yield from the DSR */ - pDev->CurrentDSRRecvCount = 0; - /* reset counter used to flag a re-scan of IRQ status registers on the target */ - pDev->RecheckIRQStatusCnt = 0; - - while (!done) { - status = ProcessPendingIRQs(pDev, &done, &asyncProc); - if (status) { - break; - } - - if (HIF_DEVICE_IRQ_SYNC_ONLY == pDev->HifIRQProcessingMode) { - /* the HIF layer does not allow async IRQ processing, override the asyncProc flag */ - asyncProc = false; - /* this will cause us to re-enter ProcessPendingIRQ() and re-read interrupt status registers. - * this has a nice side effect of blocking us until all async read requests are completed. - * This behavior is required on some HIF implementations that do not allow ASYNC - * processing in interrupt handlers (like Windows CE) */ - - if (pDev->DSRCanYield && DEV_CHECK_RECV_YIELD(pDev)) { - /* ProcessPendingIRQs() pulled enough recv messages to satisfy the yield count, stop - * checking for more messages and return */ - break; - } - } - - if (asyncProc) { - /* the function performed some async I/O for performance, we - need to exit the ISR immediately, the check below will prevent the interrupt from being - Ack'd while we handle it asynchronously */ - break; - } - - } - - if (!status && !asyncProc) { - /* Ack the interrupt only if : - * 1. we did not get any errors in processing interrupts - * 2. there are no outstanding async processing requests */ - if (pDev->DSRCanYield) { - /* if the DSR can yield do not ACK the interrupt, there could be more pending messages. - * The HIF layer must ACK the interrupt on behalf of HTC */ - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Yield in effect (cur RX count: %d) \n", pDev->CurrentDSRRecvCount)); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Acking interrupt from DevDsrHandler \n")); - HIFAckInterrupt(pDev->HIFDevice); - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDsrHandler \n")); - return status; -} - -#ifdef ATH_DEBUG_MODULE -void DumpAR6KDevState(struct ar6k_device *pDev) -{ - int status; - struct ar6k_irq_enable_registers regs; - struct ar6k_irq_proc_registers procRegs; - - LOCK_AR6K(pDev); - /* copy into our temp area */ - memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - UNLOCK_AR6K(pDev); - - /* load the register table from the device */ - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - (u8 *)&procRegs, - AR6K_IRQ_PROC_REGS_SIZE, - HIF_RD_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("DumpAR6KDevState : Failed to read register table (%d) \n",status)); - return; - } - - DevDumpRegisters(pDev,&procRegs,®s); - - if (pDev->GMboxInfo.pStateDumpCallback != NULL) { - pDev->GMboxInfo.pStateDumpCallback(pDev->GMboxInfo.pProtocolContext); - } - - /* dump any bus state at the HIF layer */ - HIFConfigureDevice(pDev->HIFDevice,HIF_DEVICE_DEBUG_BUS_STATE,NULL,0); - -} -#endif - - diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c deleted file mode 100644 index 725540f9add..00000000000 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c +++ /dev/null @@ -1,755 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Generic MBOX API implementation -// -// Author(s): ="Atheros" -//============================================================================== -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include "../htc_debug.h" -#include "hif.h" -#include "htc_packet.h" -#include "ar6k.h" -#include "hw/mbox_host_reg.h" -#include "gmboxif.h" - -/* - * This file provides management functions and a toolbox for GMBOX protocol modules. - * Only one protocol module can be installed at a time. The determination of which protocol - * module is installed is determined at compile time. - * - */ -#ifdef ATH_AR6K_ENABLE_GMBOX - /* GMBOX definitions */ -#define GMBOX_INT_STATUS_ENABLE_REG 0x488 -#define GMBOX_INT_STATUS_RX_DATA (1 << 0) -#define GMBOX_INT_STATUS_TX_OVERFLOW (1 << 1) -#define GMBOX_INT_STATUS_RX_OVERFLOW (1 << 2) - -#define GMBOX_LOOKAHEAD_MUX_REG 0x498 -#define GMBOX_LA_MUX_OVERRIDE_2_3 (1 << 0) - -#define AR6K_GMBOX_CREDIT_DEC_ADDRESS (COUNT_DEC_ADDRESS + 4 * AR6K_GMBOX_CREDIT_COUNTER) -#define AR6K_GMBOX_CREDIT_SIZE_ADDRESS (COUNT_ADDRESS + AR6K_GMBOX_CREDIT_SIZE_COUNTER) - - - /* external APIs for allocating and freeing internal I/O packets to handle ASYNC I/O */ -extern void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket); -extern struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev); - - -/* callback when our fetch to enable/disable completes */ -static void DevGMboxIRQActionAsyncHandler(void *Context, struct htc_packet *pPacket) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGMboxIRQActionAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("IRQAction Operation (%d) failed! status:%d \n", pPacket->PktInfo.AsRx.HTCRxFlags,pPacket->Status)); - } - /* free this IO packet */ - AR6KFreeIOPacket(pDev,pPacket); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGMboxIRQActionAsyncHandler \n")); -} - -static int DevGMboxCounterEnableDisable(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, bool AsyncMode) -{ - int status = 0; - struct ar6k_irq_enable_registers regs; - struct htc_packet *pIOPacket = NULL; - - LOCK_AR6K(pDev); - - if (GMBOX_CREDIT_IRQ_ENABLE == IrqAction) { - pDev->GMboxInfo.CreditCountIRQEnabled = true; - pDev->IrqEnableRegisters.counter_int_status_enable |= - COUNTER_INT_STATUS_ENABLE_BIT_SET(1 << AR6K_GMBOX_CREDIT_COUNTER); - pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_COUNTER_SET(0x01); - } else { - pDev->GMboxInfo.CreditCountIRQEnabled = false; - pDev->IrqEnableRegisters.counter_int_status_enable &= - ~(COUNTER_INT_STATUS_ENABLE_BIT_SET(1 << AR6K_GMBOX_CREDIT_COUNTER)); - } - /* copy into our temp area */ - memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - - UNLOCK_AR6K(pDev); - - do { - - if (AsyncMode) { - - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - /* copy values to write to our async I/O buffer */ - memcpy(pIOPacket->pBuffer,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); - - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevGMboxIRQActionAsyncHandler; - pIOPacket->pContext = pDev; - pIOPacket->PktInfo.AsRx.HTCRxFlags = IrqAction; - /* write it out asynchronously */ - HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - pIOPacket->pBuffer, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_ASYNC_BYTE_INC, - pIOPacket); - - pIOPacket = NULL; - break; - } - - /* if we get here we are doing it synchronously */ - status = HIFReadWrite(pDev->HIFDevice, - INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_enable, - AR6K_IRQ_ENABLE_REGS_SIZE, - HIF_WR_SYNC_BYTE_INC, - NULL); - } while (false); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" IRQAction Operation (%d) failed! status:%d \n", IrqAction, status)); - } else { - if (!AsyncMode) { - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - (" IRQAction Operation (%d) success \n", IrqAction)); - } - } - - if (pIOPacket != NULL) { - AR6KFreeIOPacket(pDev,pIOPacket); - } - - return status; -} - - -int DevGMboxIRQAction(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, bool AsyncMode) -{ - int status = 0; - struct htc_packet *pIOPacket = NULL; - u8 GMboxIntControl[4]; - - if (GMBOX_CREDIT_IRQ_ENABLE == IrqAction) { - return DevGMboxCounterEnableDisable(pDev, GMBOX_CREDIT_IRQ_ENABLE, AsyncMode); - } else if(GMBOX_CREDIT_IRQ_DISABLE == IrqAction) { - return DevGMboxCounterEnableDisable(pDev, GMBOX_CREDIT_IRQ_DISABLE, AsyncMode); - } - - if (GMBOX_DISABLE_ALL == IrqAction) { - /* disable credit IRQ, those are on a different set of registers */ - DevGMboxCounterEnableDisable(pDev, GMBOX_CREDIT_IRQ_DISABLE, AsyncMode); - } - - /* take the lock to protect interrupt enable shadows */ - LOCK_AR6K(pDev); - - switch (IrqAction) { - - case GMBOX_DISABLE_ALL: - pDev->GMboxControlRegisters.int_status_enable = 0; - break; - case GMBOX_ERRORS_IRQ_ENABLE: - pDev->GMboxControlRegisters.int_status_enable |= GMBOX_INT_STATUS_TX_OVERFLOW | - GMBOX_INT_STATUS_RX_OVERFLOW; - break; - case GMBOX_RECV_IRQ_ENABLE: - pDev->GMboxControlRegisters.int_status_enable |= GMBOX_INT_STATUS_RX_DATA; - break; - case GMBOX_RECV_IRQ_DISABLE: - pDev->GMboxControlRegisters.int_status_enable &= ~GMBOX_INT_STATUS_RX_DATA; - break; - case GMBOX_ACTION_NONE: - default: - A_ASSERT(false); - break; - } - - GMboxIntControl[0] = pDev->GMboxControlRegisters.int_status_enable; - GMboxIntControl[1] = GMboxIntControl[0]; - GMboxIntControl[2] = GMboxIntControl[0]; - GMboxIntControl[3] = GMboxIntControl[0]; - - UNLOCK_AR6K(pDev); - - do { - - if (AsyncMode) { - - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - /* copy values to write to our async I/O buffer */ - memcpy(pIOPacket->pBuffer,GMboxIntControl,sizeof(GMboxIntControl)); - - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevGMboxIRQActionAsyncHandler; - pIOPacket->pContext = pDev; - pIOPacket->PktInfo.AsRx.HTCRxFlags = IrqAction; - /* write it out asynchronously */ - HIFReadWrite(pDev->HIFDevice, - GMBOX_INT_STATUS_ENABLE_REG, - pIOPacket->pBuffer, - sizeof(GMboxIntControl), - HIF_WR_ASYNC_BYTE_FIX, - pIOPacket); - pIOPacket = NULL; - break; - } - - /* if we get here we are doing it synchronously */ - - status = HIFReadWrite(pDev->HIFDevice, - GMBOX_INT_STATUS_ENABLE_REG, - GMboxIntControl, - sizeof(GMboxIntControl), - HIF_WR_SYNC_BYTE_FIX, - NULL); - - } while (false); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" IRQAction Operation (%d) failed! status:%d \n", IrqAction, status)); - } else { - if (!AsyncMode) { - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, - (" IRQAction Operation (%d) success \n", IrqAction)); - } - } - - if (pIOPacket != NULL) { - AR6KFreeIOPacket(pDev,pIOPacket); - } - - return status; -} - -void DevCleanupGMbox(struct ar6k_device *pDev) -{ - if (pDev->GMboxEnabled) { - pDev->GMboxEnabled = false; - GMboxProtocolUninstall(pDev); - } -} - -int DevSetupGMbox(struct ar6k_device *pDev) -{ - int status = 0; - u8 muxControl[4]; - - do { - - if (0 == pDev->MailBoxInfo.GMboxAddress) { - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,(" GMBOX Advertised: Address:0x%X , size:%d \n", - pDev->MailBoxInfo.GMboxAddress, pDev->MailBoxInfo.GMboxSize)); - - status = DevGMboxIRQAction(pDev, GMBOX_DISABLE_ALL, PROC_IO_SYNC); - - if (status) { - break; - } - - /* write to mailbox look ahead mux control register, we want the - * GMBOX lookaheads to appear on lookaheads 2 and 3 - * the register is 1-byte wide so we need to hit it 4 times to align the operation - * to 4-bytes */ - muxControl[0] = GMBOX_LA_MUX_OVERRIDE_2_3; - muxControl[1] = GMBOX_LA_MUX_OVERRIDE_2_3; - muxControl[2] = GMBOX_LA_MUX_OVERRIDE_2_3; - muxControl[3] = GMBOX_LA_MUX_OVERRIDE_2_3; - - status = HIFReadWrite(pDev->HIFDevice, - GMBOX_LOOKAHEAD_MUX_REG, - muxControl, - sizeof(muxControl), - HIF_WR_SYNC_BYTE_FIX, /* hit this register 4 times */ - NULL); - - if (status) { - break; - } - - status = GMboxProtocolInstall(pDev); - - if (status) { - break; - } - - pDev->GMboxEnabled = true; - - } while (false); - - return status; -} - -int DevCheckGMboxInterrupts(struct ar6k_device *pDev) -{ - int status = 0; - u8 counter_int_status; - int credits; - u8 host_int_status2; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("+DevCheckGMboxInterrupts \n")); - - /* the caller guarantees that this is a context that allows for blocking I/O */ - - do { - - host_int_status2 = pDev->IrqProcRegisters.host_int_status2 & - pDev->GMboxControlRegisters.int_status_enable; - - if (host_int_status2 & GMBOX_INT_STATUS_TX_OVERFLOW) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("GMBOX : TX Overflow \n")); - status = A_ECOMM; - } - - if (host_int_status2 & GMBOX_INT_STATUS_RX_OVERFLOW) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("GMBOX : RX Overflow \n")); - status = A_ECOMM; - } - - if (status) { - if (pDev->GMboxInfo.pTargetFailureCallback != NULL) { - pDev->GMboxInfo.pTargetFailureCallback(pDev->GMboxInfo.pProtocolContext, status); - } - break; - } - - if (host_int_status2 & GMBOX_INT_STATUS_RX_DATA) { - if (pDev->IrqProcRegisters.gmbox_rx_avail > 0) { - A_ASSERT(pDev->GMboxInfo.pMessagePendingCallBack != NULL); - status = pDev->GMboxInfo.pMessagePendingCallBack( - pDev->GMboxInfo.pProtocolContext, - (u8 *)&pDev->IrqProcRegisters.rx_gmbox_lookahead_alias[0], - pDev->IrqProcRegisters.gmbox_rx_avail); - } - } - - if (status) { - break; - } - - counter_int_status = pDev->IrqProcRegisters.counter_int_status & - pDev->IrqEnableRegisters.counter_int_status_enable; - - /* check if credit interrupt is pending */ - if (counter_int_status & (COUNTER_INT_STATUS_ENABLE_BIT_SET(1 << AR6K_GMBOX_CREDIT_COUNTER))) { - - /* do synchronous read */ - status = DevGMboxReadCreditCounter(pDev, PROC_IO_SYNC, &credits); - - if (status) { - break; - } - - A_ASSERT(pDev->GMboxInfo.pCreditsPendingCallback != NULL); - status = pDev->GMboxInfo.pCreditsPendingCallback(pDev->GMboxInfo.pProtocolContext, - credits, - pDev->GMboxInfo.CreditCountIRQEnabled); - } - - } while (false); - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("-DevCheckGMboxInterrupts (%d) \n",status)); - - return status; -} - - -int DevGMboxWrite(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 WriteLength) -{ - u32 paddedLength; - bool sync = (pPacket->Completion == NULL) ? true : false; - int status; - u32 address; - - /* adjust the length to be a multiple of block size if appropriate */ - paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, WriteLength); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - ("DevGMboxWrite, Padded Length: %d Mbox:0x%X (mode:%s)\n", - WriteLength, - pDev->MailBoxInfo.GMboxAddress, - sync ? "SYNC" : "ASYNC")); - - /* last byte of packet has to hit the EOM marker */ - address = pDev->MailBoxInfo.GMboxAddress + pDev->MailBoxInfo.GMboxSize - paddedLength; - - status = HIFReadWrite(pDev->HIFDevice, - address, - pPacket->pBuffer, - paddedLength, /* the padded length */ - sync ? HIF_WR_SYNC_BLOCK_INC : HIF_WR_ASYNC_BLOCK_INC, - sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ - - if (sync) { - pPacket->Status = status; - } else { - if (status == A_PENDING) { - status = 0; - } - } - - return status; -} - -int DevGMboxRead(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 ReadLength) -{ - - u32 paddedLength; - int status; - bool sync = (pPacket->Completion == NULL) ? true : false; - - /* adjust the length to be a multiple of block size if appropriate */ - paddedLength = DEV_CALC_RECV_PADDED_LEN(pDev, ReadLength); - - if (paddedLength > pPacket->BufferLength) { - A_ASSERT(false); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("DevGMboxRead, Not enough space for padlen:%d recvlen:%d bufferlen:%d \n", - paddedLength,ReadLength,pPacket->BufferLength)); - if (pPacket->Completion != NULL) { - COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return 0; - } - return A_EINVAL; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("DevGMboxRead (0x%lX : hdr:0x%X) Padded Length: %d Mbox:0x%X (mode:%s)\n", - (unsigned long)pPacket, pPacket->PktInfo.AsRx.ExpectedHdr, - paddedLength, - pDev->MailBoxInfo.GMboxAddress, - sync ? "SYNC" : "ASYNC")); - - status = HIFReadWrite(pDev->HIFDevice, - pDev->MailBoxInfo.GMboxAddress, - pPacket->pBuffer, - paddedLength, - sync ? HIF_RD_SYNC_BLOCK_FIX : HIF_RD_ASYNC_BLOCK_FIX, - sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ - - if (sync) { - pPacket->Status = status; - } - - return status; -} - - -static int ProcessCreditCounterReadBuffer(u8 *pBuffer, int Length) -{ - int credits = 0; - - /* theory of how this works: - * We read the credit decrement register multiple times on a byte-wide basis. - * The number of times (32) aligns the I/O operation to be a multiple of 4 bytes and provides a - * reasonable chance to acquire "all" pending credits in a single I/O operation. - * - * Once we obtain the filled buffer, we can walk through it looking for credit decrement transitions. - * Each non-zero byte represents a single credit decrement (which is a credit given back to the host) - * For example if the target provides 3 credits and added 4 more during the 32-byte read operation the following - * pattern "could" appear: - * - * 0x3 0x2 0x1 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x1 0x0 0x1 0x0 0x1 0x0 ......rest zeros - * <---------> <-----------------------------> - * \_ credits aleady there \_ target adding 4 more credits - * - * The total available credits would be 7, since there are 7 non-zero bytes in the buffer. - * - * */ - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - DebugDumpBytes(pBuffer, Length, "GMBOX Credit read buffer"); - } - - while (Length) { - if (*pBuffer != 0) { - credits++; - } - Length--; - pBuffer++; - } - - return credits; -} - - -/* callback when our fetch to enable/disable completes */ -static void DevGMboxReadCreditsAsyncHandler(void *Context, struct htc_packet *pPacket) -{ - struct ar6k_device *pDev = (struct ar6k_device *)Context; - - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGMboxReadCreditsAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Read Credit Operation failed! status:%d \n", pPacket->Status)); - } else { - int credits = 0; - credits = ProcessCreditCounterReadBuffer(pPacket->pBuffer, AR6K_REG_IO_BUFFER_SIZE); - pDev->GMboxInfo.pCreditsPendingCallback(pDev->GMboxInfo.pProtocolContext, - credits, - pDev->GMboxInfo.CreditCountIRQEnabled); - - - } - /* free this IO packet */ - AR6KFreeIOPacket(pDev,pPacket); - AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGMboxReadCreditsAsyncHandler \n")); -} - -int DevGMboxReadCreditCounter(struct ar6k_device *pDev, bool AsyncMode, int *pCredits) -{ - int status = 0; - struct htc_packet *pIOPacket = NULL; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+DevGMboxReadCreditCounter (%s) \n", AsyncMode ? "ASYNC" : "SYNC")); - - do { - - pIOPacket = AR6KAllocIOPacket(pDev); - - if (NULL == pIOPacket) { - status = A_NO_MEMORY; - A_ASSERT(false); - break; - } - - A_MEMZERO(pIOPacket->pBuffer,AR6K_REG_IO_BUFFER_SIZE); - - if (AsyncMode) { - /* stick in our completion routine when the I/O operation completes */ - pIOPacket->Completion = DevGMboxReadCreditsAsyncHandler; - pIOPacket->pContext = pDev; - /* read registers asynchronously */ - HIFReadWrite(pDev->HIFDevice, - AR6K_GMBOX_CREDIT_DEC_ADDRESS, - pIOPacket->pBuffer, - AR6K_REG_IO_BUFFER_SIZE, /* hit the register multiple times */ - HIF_RD_ASYNC_BYTE_FIX, - pIOPacket); - pIOPacket = NULL; - break; - } - - pIOPacket->Completion = NULL; - /* if we get here we are doing it synchronously */ - status = HIFReadWrite(pDev->HIFDevice, - AR6K_GMBOX_CREDIT_DEC_ADDRESS, - pIOPacket->pBuffer, - AR6K_REG_IO_BUFFER_SIZE, - HIF_RD_SYNC_BYTE_FIX, - NULL); - } while (false); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" DevGMboxReadCreditCounter failed! status:%d \n", status)); - } - - if (pIOPacket != NULL) { - if (!status) { - /* sync mode processing */ - *pCredits = ProcessCreditCounterReadBuffer(pIOPacket->pBuffer, AR6K_REG_IO_BUFFER_SIZE); - } - AR6KFreeIOPacket(pDev,pIOPacket); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-DevGMboxReadCreditCounter (%s) (%d) \n", - AsyncMode ? "ASYNC" : "SYNC", status)); - - return status; -} - -int DevGMboxReadCreditSize(struct ar6k_device *pDev, int *pCreditSize) -{ - int status; - u8 buffer[4]; - - status = HIFReadWrite(pDev->HIFDevice, - AR6K_GMBOX_CREDIT_SIZE_ADDRESS, - buffer, - sizeof(buffer), - HIF_RD_SYNC_BYTE_FIX, /* hit the register 4 times to align the I/O */ - NULL); - - if (!status) { - if (buffer[0] == 0) { - *pCreditSize = 256; - } else { - *pCreditSize = buffer[0]; - } - - } - - return status; -} - -void DevNotifyGMboxTargetFailure(struct ar6k_device *pDev) -{ - /* Target ASSERTED!!! */ - if (pDev->GMboxInfo.pTargetFailureCallback != NULL) { - pDev->GMboxInfo.pTargetFailureCallback(pDev->GMboxInfo.pProtocolContext, A_HARDWARE); - } -} - -int DevGMboxRecvLookAheadPeek(struct ar6k_device *pDev, u8 *pLookAheadBuffer, int *pLookAheadBytes) -{ - - int status = 0; - struct ar6k_irq_proc_registers procRegs; - int maxCopy; - - do { - /* on entry the caller provides the length of the lookahead buffer */ - if (*pLookAheadBytes > sizeof(procRegs.rx_gmbox_lookahead_alias)) { - A_ASSERT(false); - status = A_EINVAL; - break; - } - - maxCopy = *pLookAheadBytes; - *pLookAheadBytes = 0; - /* load the register table from the device */ - status = HIFReadWrite(pDev->HIFDevice, - HOST_INT_STATUS_ADDRESS, - (u8 *)&procRegs, - AR6K_IRQ_PROC_REGS_SIZE, - HIF_RD_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("DevGMboxRecvLookAheadPeek : Failed to read register table (%d) \n",status)); - break; - } - - if (procRegs.gmbox_rx_avail > 0) { - int bytes = procRegs.gmbox_rx_avail > maxCopy ? maxCopy : procRegs.gmbox_rx_avail; - memcpy(pLookAheadBuffer,&procRegs.rx_gmbox_lookahead_alias[0],bytes); - *pLookAheadBytes = bytes; - } - - } while (false); - - return status; -} - -int DevGMboxSetTargetInterrupt(struct ar6k_device *pDev, int Signal, int AckTimeoutMS) -{ - int status = 0; - int i; - u8 buffer[4]; - - A_MEMZERO(buffer, sizeof(buffer)); - - do { - - if (Signal >= MBOX_SIG_HCI_BRIDGE_MAX) { - status = A_EINVAL; - break; - } - - /* set the last buffer to do the actual signal trigger */ - buffer[3] = (1 << Signal); - - status = HIFReadWrite(pDev->HIFDevice, - INT_WLAN_ADDRESS, - buffer, - sizeof(buffer), - HIF_WR_SYNC_BYTE_FIX, /* hit the register 4 times to align the I/O */ - NULL); - - if (status) { - break; - } - - } while (false); - - - if (!status) { - /* now read back the register to see if the bit cleared */ - while (AckTimeoutMS) { - status = HIFReadWrite(pDev->HIFDevice, - INT_WLAN_ADDRESS, - buffer, - sizeof(buffer), - HIF_RD_SYNC_BYTE_FIX, - NULL); - - if (status) { - break; - } - - for (i = 0; i < sizeof(buffer); i++) { - if (buffer[i] & (1 << Signal)) { - /* bit is still set */ - break; - } - } - - if (i >= sizeof(buffer)) { - /* done */ - break; - } - - AckTimeoutMS--; - A_MDELAY(1); - } - - if (0 == AckTimeoutMS) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("DevGMboxSetTargetInterrupt : Ack Timed-out (sig:%d) \n",Signal)); - status = A_ERROR; - } - } - - return status; - -} - -#endif //ATH_AR6K_ENABLE_GMBOX - - - - diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c deleted file mode 100644 index 56a0d714380..00000000000 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c +++ /dev/null @@ -1,1284 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Protocol module for use in bridging HCI-UART packets over the GMBOX interface -// -// Author(s): ="Atheros" -//============================================================================== -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include "../htc_debug.h" -#include "hif.h" -#include "htc_packet.h" -#include "ar6k.h" -#include "hci_transport_api.h" -#include "gmboxif.h" -#include "ar6000_diag.h" -#include "hw/apb_map.h" -#include "hw/mbox_reg.h" - -#ifdef ATH_AR6K_ENABLE_GMBOX -#define HCI_UART_COMMAND_PKT 0x01 -#define HCI_UART_ACL_PKT 0x02 -#define HCI_UART_SCO_PKT 0x03 -#define HCI_UART_EVENT_PKT 0x04 - -#define HCI_RECV_WAIT_BUFFERS (1 << 0) - -#define HCI_SEND_WAIT_CREDITS (1 << 0) - -#define HCI_UART_BRIDGE_CREDIT_SIZE 128 - -#define CREDIT_POLL_COUNT 256 - -#define HCI_DELAY_PER_INTERVAL_MS 10 -#define BTON_TIMEOUT_MS 500 -#define BTOFF_TIMEOUT_MS 500 -#define BAUD_TIMEOUT_MS 1 -#define BTPWRSAV_TIMEOUT_MS 1 - -struct gmbox_proto_hci_uart { - struct hci_transport_config_info HCIConfig; - bool HCIAttached; - bool HCIStopped; - u32 RecvStateFlags; - u32 SendStateFlags; - HCI_TRANSPORT_PACKET_TYPE WaitBufferType; - struct htc_packet_queue SendQueue; /* write queue holding HCI Command and ACL packets */ - struct htc_packet_queue HCIACLRecvBuffers; /* recv queue holding buffers for incomming ACL packets */ - struct htc_packet_queue HCIEventBuffers; /* recv queue holding buffers for incomming event packets */ - struct ar6k_device *pDev; - A_MUTEX_T HCIRxLock; - A_MUTEX_T HCITxLock; - int CreditsMax; - int CreditsConsumed; - int CreditsAvailable; - int CreditSize; - int CreditsCurrentSeek; - int SendProcessCount; -}; - -#define LOCK_HCI_RX(t) A_MUTEX_LOCK(&(t)->HCIRxLock); -#define UNLOCK_HCI_RX(t) A_MUTEX_UNLOCK(&(t)->HCIRxLock); -#define LOCK_HCI_TX(t) A_MUTEX_LOCK(&(t)->HCITxLock); -#define UNLOCK_HCI_TX(t) A_MUTEX_UNLOCK(&(t)->HCITxLock); - -#define DO_HCI_RECV_INDICATION(p, pt) \ -do { \ - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, \ - ("HCI: Indicate Recv on packet:0x%lX status:%d len:%d type:%d \n", \ - (unsigned long)(pt), \ - (pt)->Status, \ - !(pt)->Status ? (pt)->ActualLength : 0, \ - HCI_GET_PACKET_TYPE(pt))); \ - (p)->HCIConfig.pHCIPktRecv((p)->HCIConfig.pContext, (pt)); \ -} while (0) - -#define DO_HCI_SEND_INDICATION(p,pt) \ -{ AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Indicate Send on packet:0x%lX status:%d type:%d \n", \ - (unsigned long)(pt),(pt)->Status,HCI_GET_PACKET_TYPE(pt))); \ - (p)->HCIConfig.pHCISendComplete((p)->HCIConfig.pContext, (pt)); \ -} - -static int HCITrySend(struct gmbox_proto_hci_uart *pProt, struct htc_packet *pPacket, bool Synchronous); - -static void HCIUartCleanup(struct gmbox_proto_hci_uart *pProtocol) -{ - A_ASSERT(pProtocol != NULL); - - A_MUTEX_DELETE(&pProtocol->HCIRxLock); - A_MUTEX_DELETE(&pProtocol->HCITxLock); - - kfree(pProtocol); -} - -static int InitTxCreditState(struct gmbox_proto_hci_uart *pProt) -{ - int status; - int credits; - int creditPollCount = CREDIT_POLL_COUNT; - bool gotCredits = false; - - pProt->CreditsConsumed = 0; - - do { - - if (pProt->CreditsMax != 0) { - /* we can only call this only once per target reset */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI: InitTxCreditState - already called! \n")); - A_ASSERT(false); - status = A_EINVAL; - break; - } - - /* read the credit counter. At startup the target will set the credit counter - * to the max available, we read this in a loop because it may take - * multiple credit counter reads to get all credits */ - - while (creditPollCount) { - - credits = 0; - - status = DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_SYNC, &credits); - - if (status) { - break; - } - - if (!gotCredits && (0 == credits)) { - creditPollCount--; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: credit is 0, retrying (%d) \n",creditPollCount)); - A_MDELAY(HCI_DELAY_PER_INTERVAL_MS); - continue; - } else { - gotCredits = true; - } - - if (0 == credits) { - break; - } - - pProt->CreditsMax += credits; - } - - if (status) { - break; - } - - if (0 == creditPollCount) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("** HCI : Failed to get credits! GMBOX Target was not available \n")); - status = A_ERROR; - break; - } - - /* now get the size */ - status = DevGMboxReadCreditSize(pProt->pDev, &pProt->CreditSize); - - if (status) { - break; - } - - } while (false); - - if (!status) { - pProt->CreditsAvailable = pProt->CreditsMax; - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("HCI : InitTxCreditState - credits avail: %d, size: %d \n", - pProt->CreditsAvailable, pProt->CreditSize)); - } - - return status; -} - -static int CreditsAvailableCallback(void *pContext, int Credits, bool CreditIRQEnabled) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; - bool enableCreditIrq = false; - bool disableCreditIrq = false; - bool doPendingSends = false; - int status = 0; - - /** this callback is called under 2 conditions: - * 1. The credit IRQ interrupt was enabled and signaled. - * 2. A credit counter read completed. - * - * The function must not assume that the calling context can block ! - */ - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+CreditsAvailableCallback (Credits:%d, IRQ:%s) \n", - Credits, CreditIRQEnabled ? "ON" : "OFF")); - - LOCK_HCI_TX(pProt); - - do { - - if (0 == Credits) { - if (!CreditIRQEnabled) { - /* enable credit IRQ */ - enableCreditIrq = true; - } - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: current credit state, consumed:%d available:%d max:%d seek:%d\n", - pProt->CreditsConsumed, - pProt->CreditsAvailable, - pProt->CreditsMax, - pProt->CreditsCurrentSeek)); - - pProt->CreditsAvailable += Credits; - A_ASSERT(pProt->CreditsAvailable <= pProt->CreditsMax); - pProt->CreditsConsumed -= Credits; - A_ASSERT(pProt->CreditsConsumed >= 0); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: new credit state, consumed:%d available:%d max:%d seek:%d\n", - pProt->CreditsConsumed, - pProt->CreditsAvailable, - pProt->CreditsMax, - pProt->CreditsCurrentSeek)); - - if (pProt->CreditsAvailable >= pProt->CreditsCurrentSeek) { - /* we have enough credits to fulfill at least 1 packet waiting in the queue */ - pProt->CreditsCurrentSeek = 0; - pProt->SendStateFlags &= ~HCI_SEND_WAIT_CREDITS; - doPendingSends = true; - if (CreditIRQEnabled) { - /* credit IRQ was enabled, we shouldn't need it anymore */ - disableCreditIrq = true; - } - } else { - /* not enough credits yet, enable credit IRQ if we haven't already */ - if (!CreditIRQEnabled) { - enableCreditIrq = true; - } - } - - } while (false); - - UNLOCK_HCI_TX(pProt); - - if (enableCreditIrq) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" Enabling credit count IRQ...\n")); - /* must use async only */ - status = DevGMboxIRQAction(pProt->pDev, GMBOX_CREDIT_IRQ_ENABLE, PROC_IO_ASYNC); - } else if (disableCreditIrq) { - /* must use async only */ - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" Disabling credit count IRQ...\n")); - status = DevGMboxIRQAction(pProt->pDev, GMBOX_CREDIT_IRQ_DISABLE, PROC_IO_ASYNC); - } - - if (doPendingSends) { - HCITrySend(pProt, NULL, false); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+CreditsAvailableCallback \n")); - return status; -} - -static INLINE void NotifyTransportFailure(struct gmbox_proto_hci_uart *pProt, int status) -{ - if (pProt->HCIConfig.TransportFailure != NULL) { - pProt->HCIConfig.TransportFailure(pProt->HCIConfig.pContext, status); - } -} - -static void FailureCallback(void *pContext, int Status) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; - - /* target assertion occurred */ - NotifyTransportFailure(pProt, Status); -} - -static void StateDumpCallback(void *pContext) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("============ HCIUart State ======================\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("RecvStateFlags : 0x%X \n",pProt->RecvStateFlags)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("SendStateFlags : 0x%X \n",pProt->SendStateFlags)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("WaitBufferType : %d \n",pProt->WaitBufferType)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("SendQueue Depth : %d \n",HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue))); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("CreditsMax : %d \n",pProt->CreditsMax)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("CreditsConsumed : %d \n",pProt->CreditsConsumed)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("CreditsAvailable : %d \n",pProt->CreditsAvailable)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("==================================================\n")); -} - -static int HCIUartMessagePending(void *pContext, u8 LookAheadBytes[], int ValidBytes) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; - int status = 0; - int totalRecvLength = 0; - HCI_TRANSPORT_PACKET_TYPE pktType = HCI_PACKET_INVALID; - bool recvRefillCalled = false; - bool blockRecv = false; - struct htc_packet *pPacket = NULL; - - /** caller guarantees that this is a fully block-able context (synch I/O is allowed) */ - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HCIUartMessagePending Lookahead Bytes:%d \n",ValidBytes)); - - LOCK_HCI_RX(pProt); - - do { - - if (ValidBytes < 3) { - /* not enough for ACL or event header */ - break; - } - - if ((LookAheadBytes[0] == HCI_UART_ACL_PKT) && (ValidBytes < 5)) { - /* not enough for ACL data header */ - break; - } - - switch (LookAheadBytes[0]) { - case HCI_UART_EVENT_PKT: - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI Event: %d param length: %d \n", - LookAheadBytes[1], LookAheadBytes[2])); - totalRecvLength = LookAheadBytes[2]; - totalRecvLength += 3; /* add type + event code + length field */ - pktType = HCI_EVENT_TYPE; - break; - case HCI_UART_ACL_PKT: - totalRecvLength = (LookAheadBytes[4] << 8) | LookAheadBytes[3]; - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI ACL: conn:0x%X length: %d \n", - ((LookAheadBytes[2] & 0xF0) << 8) | LookAheadBytes[1], totalRecvLength)); - totalRecvLength += 5; /* add type + connection handle + length field */ - pktType = HCI_ACL_TYPE; - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("**Invalid HCI packet type: %d \n",LookAheadBytes[0])); - status = A_EPROTO; - break; - } - - if (status) { - break; - } - - if (pProt->HCIConfig.pHCIPktRecvAlloc != NULL) { - UNLOCK_HCI_RX(pProt); - /* user is using a per-packet allocation callback */ - pPacket = pProt->HCIConfig.pHCIPktRecvAlloc(pProt->HCIConfig.pContext, - pktType, - totalRecvLength); - LOCK_HCI_RX(pProt); - - } else { - struct htc_packet_queue *pQueue; - /* user is using a refill handler that can refill multiple HTC buffers */ - - /* select buffer queue */ - if (pktType == HCI_ACL_TYPE) { - pQueue = &pProt->HCIACLRecvBuffers; - } else { - pQueue = &pProt->HCIEventBuffers; - } - - if (HTC_QUEUE_EMPTY(pQueue)) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("** HCI pkt type: %d has no buffers available calling allocation handler \n", - pktType)); - /* check for refill handler */ - if (pProt->HCIConfig.pHCIPktRecvRefill != NULL) { - recvRefillCalled = true; - UNLOCK_HCI_RX(pProt); - /* call the re-fill handler */ - pProt->HCIConfig.pHCIPktRecvRefill(pProt->HCIConfig.pContext, - pktType, - 0); - LOCK_HCI_RX(pProt); - /* check if we have more buffers */ - pPacket = HTC_PACKET_DEQUEUE(pQueue); - /* fall through */ - } - } else { - pPacket = HTC_PACKET_DEQUEUE(pQueue); - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("HCI pkt type: %d now has %d recv buffers left \n", - pktType, HTC_PACKET_QUEUE_DEPTH(pQueue))); - } - } - - if (NULL == pPacket) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("** HCI pkt type: %d has no buffers available stopping recv...\n", pktType)); - /* this is not an error, we simply need to mark that we are waiting for buffers.*/ - pProt->RecvStateFlags |= HCI_RECV_WAIT_BUFFERS; - pProt->WaitBufferType = pktType; - blockRecv = true; - break; - } - - if (totalRecvLength > (int)pPacket->BufferLength) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** HCI-UART pkt: %d requires %d bytes (%d buffer bytes avail) ! \n", - LookAheadBytes[0], totalRecvLength, pPacket->BufferLength)); - status = A_EINVAL; - break; - } - - } while (false); - - UNLOCK_HCI_RX(pProt); - - /* locks are released, we can go fetch the packet */ - - do { - - if (status || (NULL == pPacket)) { - break; - } - - /* do this synchronously, we don't need to be fast here */ - pPacket->Completion = NULL; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI : getting recv packet len:%d hci-uart-type: %s \n", - totalRecvLength, (LookAheadBytes[0] == HCI_UART_EVENT_PKT) ? "EVENT" : "ACL")); - - status = DevGMboxRead(pProt->pDev, pPacket, totalRecvLength); - - if (status) { - break; - } - - if (pPacket->pBuffer[0] != LookAheadBytes[0]) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** HCI buffer does not contain expected packet type: %d ! \n", - pPacket->pBuffer[0])); - status = A_EPROTO; - break; - } - - if (pPacket->pBuffer[0] == HCI_UART_EVENT_PKT) { - /* validate event header fields */ - if ((pPacket->pBuffer[1] != LookAheadBytes[1]) || - (pPacket->pBuffer[2] != LookAheadBytes[2])) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** HCI buffer does not match lookahead! \n")); - DebugDumpBytes(LookAheadBytes, 3, "Expected HCI-UART Header"); - DebugDumpBytes(pPacket->pBuffer, 3, "** Bad HCI-UART Header"); - status = A_EPROTO; - break; - } - } else if (pPacket->pBuffer[0] == HCI_UART_ACL_PKT) { - /* validate acl header fields */ - if ((pPacket->pBuffer[1] != LookAheadBytes[1]) || - (pPacket->pBuffer[2] != LookAheadBytes[2]) || - (pPacket->pBuffer[3] != LookAheadBytes[3]) || - (pPacket->pBuffer[4] != LookAheadBytes[4])) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** HCI buffer does not match lookahead! \n")); - DebugDumpBytes(LookAheadBytes, 5, "Expected HCI-UART Header"); - DebugDumpBytes(pPacket->pBuffer, 5, "** Bad HCI-UART Header"); - status = A_EPROTO; - break; - } - } - - /* adjust buffer to move past packet ID */ - pPacket->pBuffer++; - pPacket->ActualLength = totalRecvLength - 1; - pPacket->Status = 0; - /* indicate packet */ - DO_HCI_RECV_INDICATION(pProt,pPacket); - pPacket = NULL; - - /* check if we need to refill recv buffers */ - if ((pProt->HCIConfig.pHCIPktRecvRefill != NULL) && !recvRefillCalled) { - struct htc_packet_queue *pQueue; - int watermark; - - if (pktType == HCI_ACL_TYPE) { - watermark = pProt->HCIConfig.ACLRecvBufferWaterMark; - pQueue = &pProt->HCIACLRecvBuffers; - } else { - watermark = pProt->HCIConfig.EventRecvBufferWaterMark; - pQueue = &pProt->HCIEventBuffers; - } - - if (HTC_PACKET_QUEUE_DEPTH(pQueue) < watermark) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("** HCI pkt type: %d watermark hit (%d) current:%d \n", - pktType, watermark, HTC_PACKET_QUEUE_DEPTH(pQueue))); - /* call the re-fill handler */ - pProt->HCIConfig.pHCIPktRecvRefill(pProt->HCIConfig.pContext, - pktType, - HTC_PACKET_QUEUE_DEPTH(pQueue)); - } - } - - } while (false); - - /* check if we need to disable the receiver */ - if (status || blockRecv) { - DevGMboxIRQAction(pProt->pDev, GMBOX_RECV_IRQ_DISABLE, PROC_IO_SYNC); - } - - /* see if we need to recycle the recv buffer */ - if (status && (pPacket != NULL)) { - struct htc_packet_queue queue; - - if (A_EPROTO == status) { - DebugDumpBytes(pPacket->pBuffer, totalRecvLength, "Bad HCI-UART Recv packet"); - } - /* recycle packet */ - HTC_PACKET_RESET_RX(pPacket); - INIT_HTC_PACKET_QUEUE_AND_ADD(&queue,pPacket); - HCI_TransportAddReceivePkts(pProt,&queue); - NotifyTransportFailure(pProt,status); - } - - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HCIUartMessagePending \n")); - - return status; -} - -static void HCISendPacketCompletion(void *Context, struct htc_packet *pPacket) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)Context; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion (pPacket:0x%lX) \n",(unsigned long)pPacket)); - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Send Packet (0x%lX) failed: %d , len:%d \n", - (unsigned long)pPacket, pPacket->Status, pPacket->ActualLength)); - } - - DO_HCI_SEND_INDICATION(pProt,pPacket); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion \n")); -} - -static int SeekCreditsSynch(struct gmbox_proto_hci_uart *pProt) -{ - int status = 0; - int credits; - int retry = 100; - - while (true) { - credits = 0; - status = DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_SYNC, &credits); - if (status) { - break; - } - LOCK_HCI_TX(pProt); - pProt->CreditsAvailable += credits; - pProt->CreditsConsumed -= credits; - if (pProt->CreditsAvailable >= pProt->CreditsCurrentSeek) { - pProt->CreditsCurrentSeek = 0; - UNLOCK_HCI_TX(pProt); - break; - } - UNLOCK_HCI_TX(pProt); - retry--; - if (0 == retry) { - status = A_EBUSY; - break; - } - A_MDELAY(20); - } - - return status; -} - -static int HCITrySend(struct gmbox_proto_hci_uart *pProt, struct htc_packet *pPacket, bool Synchronous) -{ - int status = 0; - int transferLength; - int creditsRequired, remainder; - u8 hciUartType; - bool synchSendComplete = false; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCITrySend (pPacket:0x%lX) %s \n",(unsigned long)pPacket, - Synchronous ? "SYNC" :"ASYNC")); - - LOCK_HCI_TX(pProt); - - /* increment write processing count on entry */ - pProt->SendProcessCount++; - - do { - - if (pProt->HCIStopped) { - status = A_ECANCELED; - break; - } - - if (pPacket != NULL) { - /* packet was supplied */ - if (Synchronous) { - /* in synchronous mode, the send queue can only hold 1 packet */ - if (!HTC_QUEUE_EMPTY(&pProt->SendQueue)) { - status = A_EBUSY; - A_ASSERT(false); - break; - } - - if (pProt->SendProcessCount > 1) { - /* another thread or task is draining the TX queues */ - status = A_EBUSY; - A_ASSERT(false); - break; - } - - HTC_PACKET_ENQUEUE(&pProt->SendQueue,pPacket); - - } else { - /* see if adding this packet hits the max depth (asynchronous mode only) */ - if ((pProt->HCIConfig.MaxSendQueueDepth > 0) && - ((HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue) + 1) >= pProt->HCIConfig.MaxSendQueueDepth)) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("HCI Send queue is full, Depth:%d, Max:%d \n", - HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue), - pProt->HCIConfig.MaxSendQueueDepth)); - /* queue will be full, invoke any callbacks to determine what action to take */ - if (pProt->HCIConfig.pHCISendFull != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - ("HCI : Calling driver's send full callback.... \n")); - if (pProt->HCIConfig.pHCISendFull(pProt->HCIConfig.pContext, - pPacket) == HCI_SEND_FULL_DROP) { - /* drop it */ - status = A_NO_RESOURCE; - break; - } - } - } - - HTC_PACKET_ENQUEUE(&pProt->SendQueue,pPacket); - } - - } - - if (pProt->SendStateFlags & HCI_SEND_WAIT_CREDITS) { - break; - } - - if (pProt->SendProcessCount > 1) { - /* another thread or task is draining the TX queues */ - break; - } - - /***** beyond this point only 1 thread may enter ******/ - - /* now drain the send queue for transmission as long as we have enough - * credits */ - while (!HTC_QUEUE_EMPTY(&pProt->SendQueue)) { - - pPacket = HTC_PACKET_DEQUEUE(&pProt->SendQueue); - - switch (HCI_GET_PACKET_TYPE(pPacket)) { - case HCI_COMMAND_TYPE: - hciUartType = HCI_UART_COMMAND_PKT; - break; - case HCI_ACL_TYPE: - hciUartType = HCI_UART_ACL_PKT; - break; - default: - status = A_EINVAL; - A_ASSERT(false); - break; - } - - if (status) { - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Got head packet:0x%lX , Type:%d Length: %d Remaining Queue Depth: %d\n", - (unsigned long)pPacket, HCI_GET_PACKET_TYPE(pPacket), pPacket->ActualLength, - HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue))); - - transferLength = 1; /* UART type header is 1 byte */ - transferLength += pPacket->ActualLength; - transferLength = DEV_CALC_SEND_PADDED_LEN(pProt->pDev, transferLength); - - /* figure out how many credits this message requires */ - creditsRequired = transferLength / pProt->CreditSize; - remainder = transferLength % pProt->CreditSize; - - if (remainder) { - creditsRequired++; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Creds Required:%d Got:%d\n", - creditsRequired, pProt->CreditsAvailable)); - - if (creditsRequired > pProt->CreditsAvailable) { - if (Synchronous) { - /* in synchronous mode we need to seek credits in synchronously */ - pProt->CreditsCurrentSeek = creditsRequired; - UNLOCK_HCI_TX(pProt); - status = SeekCreditsSynch(pProt); - LOCK_HCI_TX(pProt); - if (status) { - break; - } - /* fall through and continue processing this send op */ - } else { - /* not enough credits, queue back to the head */ - HTC_PACKET_ENQUEUE_TO_HEAD(&pProt->SendQueue,pPacket); - /* waiting for credits */ - pProt->SendStateFlags |= HCI_SEND_WAIT_CREDITS; - /* provide a hint to reduce attempts to re-send if credits are dribbling back - * this hint is the short fall of credits */ - pProt->CreditsCurrentSeek = creditsRequired; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: packet:0x%lX placed back in queue. head packet needs: %d credits \n", - (unsigned long)pPacket, pProt->CreditsCurrentSeek)); - pPacket = NULL; - UNLOCK_HCI_TX(pProt); - - /* schedule a credit counter read, our CreditsAvailableCallback callback will be called - * with the result */ - DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_ASYNC, NULL); - - LOCK_HCI_TX(pProt); - break; - } - } - - /* caller guarantees some head room */ - pPacket->pBuffer--; - pPacket->pBuffer[0] = hciUartType; - - pProt->CreditsAvailable -= creditsRequired; - pProt->CreditsConsumed += creditsRequired; - A_ASSERT(pProt->CreditsConsumed <= pProt->CreditsMax); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: new credit state: consumed:%d available:%d max:%d\n", - pProt->CreditsConsumed, pProt->CreditsAvailable, pProt->CreditsMax)); - - UNLOCK_HCI_TX(pProt); - - /* write it out */ - if (Synchronous) { - pPacket->Completion = NULL; - pPacket->pContext = NULL; - } else { - pPacket->Completion = HCISendPacketCompletion; - pPacket->pContext = pProt; - } - - status = DevGMboxWrite(pProt->pDev,pPacket,transferLength); - if (Synchronous) { - synchSendComplete = true; - } else { - pPacket = NULL; - } - - LOCK_HCI_TX(pProt); - - } - - } while (false); - - pProt->SendProcessCount--; - A_ASSERT(pProt->SendProcessCount >= 0); - UNLOCK_HCI_TX(pProt); - - if (Synchronous) { - A_ASSERT(pPacket != NULL); - if (!status && (!synchSendComplete)) { - status = A_EBUSY; - A_ASSERT(false); - LOCK_HCI_TX(pProt); - if (pPacket->ListLink.pNext != NULL) { - /* remove from the queue */ - HTC_PACKET_REMOVE(&pProt->SendQueue,pPacket); - } - UNLOCK_HCI_TX(pProt); - } - } else { - if (status && (pPacket != NULL)) { - pPacket->Status = status; - DO_HCI_SEND_INDICATION(pProt,pPacket); - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HCITrySend: \n")); - return status; -} - -static void FlushSendQueue(struct gmbox_proto_hci_uart *pProt) -{ - struct htc_packet *pPacket; - struct htc_packet_queue discardQueue; - - INIT_HTC_PACKET_QUEUE(&discardQueue); - - LOCK_HCI_TX(pProt); - - if (!HTC_QUEUE_EMPTY(&pProt->SendQueue)) { - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&discardQueue,&pProt->SendQueue); - } - - UNLOCK_HCI_TX(pProt); - - /* discard packets */ - while (!HTC_QUEUE_EMPTY(&discardQueue)) { - pPacket = HTC_PACKET_DEQUEUE(&discardQueue); - pPacket->Status = A_ECANCELED; - DO_HCI_SEND_INDICATION(pProt,pPacket); - } - -} - -static void FlushRecvBuffers(struct gmbox_proto_hci_uart *pProt) -{ - struct htc_packet_queue discardQueue; - struct htc_packet *pPacket; - - INIT_HTC_PACKET_QUEUE(&discardQueue); - - LOCK_HCI_RX(pProt); - /*transfer list items from ACL and event buffer queues to the discard queue */ - if (!HTC_QUEUE_EMPTY(&pProt->HCIACLRecvBuffers)) { - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&discardQueue,&pProt->HCIACLRecvBuffers); - } - if (!HTC_QUEUE_EMPTY(&pProt->HCIEventBuffers)) { - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&discardQueue,&pProt->HCIEventBuffers); - } - UNLOCK_HCI_RX(pProt); - - /* now empty the discard queue */ - while (!HTC_QUEUE_EMPTY(&discardQueue)) { - pPacket = HTC_PACKET_DEQUEUE(&discardQueue); - pPacket->Status = A_ECANCELED; - DO_HCI_RECV_INDICATION(pProt,pPacket); - } - -} - -/*** protocol module install entry point ***/ - -int GMboxProtocolInstall(struct ar6k_device *pDev) -{ - int status = 0; - struct gmbox_proto_hci_uart *pProtocol = NULL; - - do { - - pProtocol = A_MALLOC(sizeof(struct gmbox_proto_hci_uart)); - - if (NULL == pProtocol) { - status = A_NO_MEMORY; - break; - } - - A_MEMZERO(pProtocol, sizeof(*pProtocol)); - pProtocol->pDev = pDev; - INIT_HTC_PACKET_QUEUE(&pProtocol->SendQueue); - INIT_HTC_PACKET_QUEUE(&pProtocol->HCIACLRecvBuffers); - INIT_HTC_PACKET_QUEUE(&pProtocol->HCIEventBuffers); - A_MUTEX_INIT(&pProtocol->HCIRxLock); - A_MUTEX_INIT(&pProtocol->HCITxLock); - - } while (false); - - if (!status) { - LOCK_AR6K(pDev); - DEV_GMBOX_SET_PROTOCOL(pDev, - HCIUartMessagePending, - CreditsAvailableCallback, - FailureCallback, - StateDumpCallback, - pProtocol); - UNLOCK_AR6K(pDev); - } else { - if (pProtocol != NULL) { - HCIUartCleanup(pProtocol); - } - } - - return status; -} - -/*** protocol module uninstall entry point ***/ -void GMboxProtocolUninstall(struct ar6k_device *pDev) -{ - struct gmbox_proto_hci_uart *pProtocol = (struct gmbox_proto_hci_uart *)DEV_GMBOX_GET_PROTOCOL(pDev); - - if (pProtocol != NULL) { - - /* notify anyone attached */ - if (pProtocol->HCIAttached) { - A_ASSERT(pProtocol->HCIConfig.TransportRemoved != NULL); - pProtocol->HCIConfig.TransportRemoved(pProtocol->HCIConfig.pContext); - pProtocol->HCIAttached = false; - } - - HCIUartCleanup(pProtocol); - DEV_GMBOX_SET_PROTOCOL(pDev,NULL,NULL,NULL,NULL,NULL); - } - -} - -static int NotifyTransportReady(struct gmbox_proto_hci_uart *pProt) -{ - struct hci_transport_properties props; - int status = 0; - - do { - - A_MEMZERO(&props,sizeof(props)); - - /* HCI UART only needs one extra byte at the head to indicate the packet TYPE */ - props.HeadRoom = 1; - props.TailRoom = 0; - props.IOBlockPad = pProt->pDev->BlockSize; - if (pProt->HCIAttached) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("HCI: notifying attached client to transport... \n")); - A_ASSERT(pProt->HCIConfig.TransportReady != NULL); - status = pProt->HCIConfig.TransportReady(pProt, - &props, - pProt->HCIConfig.pContext); - } - - } while (false); - - return status; -} - -/*********** HCI UART protocol implementation ************************************************/ - -HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, struct hci_transport_config_info *pInfo) -{ - struct gmbox_proto_hci_uart *pProtocol = NULL; - struct ar6k_device *pDev; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportAttach \n")); - - pDev = HTCGetAR6KDevice(HTCHandle); - - LOCK_AR6K(pDev); - - do { - - pProtocol = (struct gmbox_proto_hci_uart *)DEV_GMBOX_GET_PROTOCOL(pDev); - - if (NULL == pProtocol) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("GMBOX protocol not installed! \n")); - break; - } - - if (pProtocol->HCIAttached) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("GMBOX protocol already attached! \n")); - break; - } - - memcpy(&pProtocol->HCIConfig, pInfo, sizeof(struct hci_transport_config_info)); - - A_ASSERT(pProtocol->HCIConfig.pHCIPktRecv != NULL); - A_ASSERT(pProtocol->HCIConfig.pHCISendComplete != NULL); - - pProtocol->HCIAttached = true; - - } while (false); - - UNLOCK_AR6K(pDev); - - if (pProtocol != NULL) { - /* TODO ... should we use a worker? */ - NotifyTransportReady(pProtocol); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportAttach (0x%lX) \n",(unsigned long)pProtocol)); - return (HCI_TRANSPORT_HANDLE)pProtocol; -} - -void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans) -{ - struct gmbox_proto_hci_uart *pProtocol = (struct gmbox_proto_hci_uart *)HciTrans; - struct ar6k_device *pDev = pProtocol->pDev; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportDetach \n")); - - LOCK_AR6K(pDev); - if (!pProtocol->HCIAttached) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("GMBOX protocol not attached! \n")); - UNLOCK_AR6K(pDev); - return; - } - pProtocol->HCIAttached = false; - UNLOCK_AR6K(pDev); - - HCI_TransportStop(HciTrans); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportAttach \n")); -} - -int HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - int status = 0; - bool unblockRecv = false; - struct htc_packet *pPacket; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HCI_TransportAddReceivePkt \n")); - - LOCK_HCI_RX(pProt); - - do { - - if (pProt->HCIStopped) { - status = A_ECANCELED; - break; - } - - pPacket = HTC_GET_PKT_AT_HEAD(pQueue); - - if (NULL == pPacket) { - status = A_EINVAL; - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" HCI recv packet added, type :%d, len:%d num:%d \n", - HCI_GET_PACKET_TYPE(pPacket), pPacket->BufferLength, HTC_PACKET_QUEUE_DEPTH(pQueue))); - - if (HCI_GET_PACKET_TYPE(pPacket) == HCI_EVENT_TYPE) { - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&pProt->HCIEventBuffers, pQueue); - } else if (HCI_GET_PACKET_TYPE(pPacket) == HCI_ACL_TYPE) { - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&pProt->HCIACLRecvBuffers, pQueue); - } else { - status = A_EINVAL; - break; - } - - if (pProt->RecvStateFlags & HCI_RECV_WAIT_BUFFERS) { - if (pProt->WaitBufferType == HCI_GET_PACKET_TYPE(pPacket)) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" HCI recv was blocked on packet type :%d, unblocking.. \n", - pProt->WaitBufferType)); - pProt->RecvStateFlags &= ~HCI_RECV_WAIT_BUFFERS; - pProt->WaitBufferType = HCI_PACKET_INVALID; - unblockRecv = true; - } - } - - } while (false); - - UNLOCK_HCI_RX(pProt); - - if (status) { - while (!HTC_QUEUE_EMPTY(pQueue)) { - pPacket = HTC_PACKET_DEQUEUE(pQueue); - pPacket->Status = A_ECANCELED; - DO_HCI_RECV_INDICATION(pProt,pPacket); - } - } - - if (unblockRecv) { - DevGMboxIRQAction(pProt->pDev, GMBOX_RECV_IRQ_ENABLE, PROC_IO_ASYNC); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HCI_TransportAddReceivePkt \n")); - - return 0; -} - -int HCI_TransportSendPkt(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - - return HCITrySend(pProt,pPacket,Synchronous); -} - -void HCI_TransportStop(HCI_TRANSPORT_HANDLE HciTrans) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportStop \n")); - - LOCK_AR6K(pProt->pDev); - if (pProt->HCIStopped) { - UNLOCK_AR6K(pProt->pDev); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStop \n")); - return; - } - pProt->HCIStopped = true; - UNLOCK_AR6K(pProt->pDev); - - /* disable interrupts */ - DevGMboxIRQAction(pProt->pDev, GMBOX_DISABLE_ALL, PROC_IO_SYNC); - FlushSendQueue(pProt); - FlushRecvBuffers(pProt); - - /* signal bridge side to power down BT */ - DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_BT_OFF, BTOFF_TIMEOUT_MS); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStop \n")); -} - -int HCI_TransportStart(HCI_TRANSPORT_HANDLE HciTrans) -{ - int status; - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportStart \n")); - - /* set stopped in case we have a problem in starting */ - pProt->HCIStopped = true; - - do { - - status = InitTxCreditState(pProt); - - if (status) { - break; - } - - status = DevGMboxIRQAction(pProt->pDev, GMBOX_ERRORS_IRQ_ENABLE, PROC_IO_SYNC); - - if (status) { - break; - } - /* enable recv */ - status = DevGMboxIRQAction(pProt->pDev, GMBOX_RECV_IRQ_ENABLE, PROC_IO_SYNC); - - if (status) { - break; - } - /* signal bridge side to power up BT */ - status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_BT_ON, BTON_TIMEOUT_MS); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI_TransportStart : Failed to trigger BT ON \n")); - break; - } - - /* we made it */ - pProt->HCIStopped = false; - - } while (false); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStart \n")); - - return status; -} - -int HCI_TransportEnableDisableAsyncRecv(HCI_TRANSPORT_HANDLE HciTrans, bool Enable) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - return DevGMboxIRQAction(pProt->pDev, - Enable ? GMBOX_RECV_IRQ_ENABLE : GMBOX_RECV_IRQ_DISABLE, - PROC_IO_SYNC); - -} - -int HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, - struct htc_packet *pPacket, - int MaxPollMS) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - int status = 0; - u8 lookAhead[8]; - int bytes; - int totalRecvLength; - - MaxPollMS = MaxPollMS / 16; - - if (MaxPollMS < 2) { - MaxPollMS = 2; - } - - while (MaxPollMS) { - - bytes = sizeof(lookAhead); - status = DevGMboxRecvLookAheadPeek(pProt->pDev,lookAhead,&bytes); - if (status) { - break; - } - - if (bytes < 3) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI recv poll got bytes: %d, retry : %d \n", - bytes, MaxPollMS)); - A_MDELAY(16); - MaxPollMS--; - continue; - } - - totalRecvLength = 0; - switch (lookAhead[0]) { - case HCI_UART_EVENT_PKT: - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI Event: %d param length: %d \n", - lookAhead[1], lookAhead[2])); - totalRecvLength = lookAhead[2]; - totalRecvLength += 3; /* add type + event code + length field */ - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("**Invalid HCI packet type: %d \n",lookAhead[0])); - status = A_EPROTO; - break; - } - - if (status) { - break; - } - - pPacket->Completion = NULL; - status = DevGMboxRead(pProt->pDev,pPacket,totalRecvLength); - if (status) { - break; - } - - pPacket->pBuffer++; - pPacket->ActualLength = totalRecvLength - 1; - pPacket->Status = 0; - break; - } - - if (MaxPollMS == 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI recv poll timeout! \n")); - status = A_ERROR; - } - - return status; -} - -#define LSB_SCRATCH_IDX 4 -#define MSB_SCRATCH_IDX 5 -int HCI_TransportSetBaudRate(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud) -{ - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - struct hif_device *pHIFDevice = (struct hif_device *)(pProt->pDev->HIFDevice); - u32 scaledBaud, scratchAddr; - int status = 0; - - /* Divide the desired baud rate by 100 - * Store the LSB in the local scratch register 4 and the MSB in the local - * scratch register 5 for the target to read - */ - scratchAddr = MBOX_BASE_ADDRESS | (LOCAL_SCRATCH_ADDRESS + 4 * LSB_SCRATCH_IDX); - scaledBaud = (Baud / 100) & LOCAL_SCRATCH_VALUE_MASK; - status = ar6000_WriteRegDiag(pHIFDevice, &scratchAddr, &scaledBaud); - scratchAddr = MBOX_BASE_ADDRESS | (LOCAL_SCRATCH_ADDRESS + 4 * MSB_SCRATCH_IDX); - scaledBaud = ((Baud / 100) >> (LOCAL_SCRATCH_VALUE_MSB+1)) & LOCAL_SCRATCH_VALUE_MASK; - status |= ar6000_WriteRegDiag(pHIFDevice, &scratchAddr, &scaledBaud); - if (0 != status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to set up baud rate in scratch register!")); - return status; - } - - /* Now interrupt the target to tell it about the baud rate */ - status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_BAUD_SET, BAUD_TIMEOUT_MS); - if (0 != status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to tell target to change baud rate!")); - } - - return status; -} - -int HCI_TransportEnablePowerMgmt(HCI_TRANSPORT_HANDLE HciTrans, bool Enable) -{ - int status; - struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; - - if (Enable) { - status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_PWR_SAV_ON, BTPWRSAV_TIMEOUT_MS); - } else { - status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_PWR_SAV_OFF, BTPWRSAV_TIMEOUT_MS); - } - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to enable/disable HCI power management!\n")); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI power management enabled/disabled!\n")); - } - - return status; -} - -#endif //ATH_AR6K_ENABLE_GMBOX - diff --git a/drivers/staging/ath6kl/htc2/htc.c b/drivers/staging/ath6kl/htc2/htc.c deleted file mode 100644 index ae54e64b624..00000000000 --- a/drivers/staging/ath6kl/htc2/htc.c +++ /dev/null @@ -1,575 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#include "htc_internal.h" - -#ifdef ATH_DEBUG_MODULE -static struct ath_debug_mask_description g_HTCDebugDescription[] = { - { ATH_DEBUG_SEND , "Send"}, - { ATH_DEBUG_RECV , "Recv"}, - { ATH_DEBUG_SYNC , "Sync"}, - { ATH_DEBUG_DUMP , "Dump Data (RX or TX)"}, - { ATH_DEBUG_IRQ , "Interrupt Processing"} -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(htc, - "htc", - "Host Target Communications", - ATH_DEBUG_MASK_DEFAULTS, - ATH_DEBUG_DESCRIPTION_COUNT(g_HTCDebugDescription), - g_HTCDebugDescription); - -#endif - -static void HTCReportFailure(void *Context); -static void ResetEndpointStates(struct htc_target *target); - -void HTCFreeControlBuffer(struct htc_target *target, struct htc_packet *pPacket, struct htc_packet_queue *pList) -{ - LOCK_HTC(target); - HTC_PACKET_ENQUEUE(pList,pPacket); - UNLOCK_HTC(target); -} - -struct htc_packet *HTCAllocControlBuffer(struct htc_target *target, struct htc_packet_queue *pList) -{ - struct htc_packet *pPacket; - - LOCK_HTC(target); - pPacket = HTC_PACKET_DEQUEUE(pList); - UNLOCK_HTC(target); - - return pPacket; -} - -/* cleanup the HTC instance */ -static void HTCCleanup(struct htc_target *target) -{ - s32 i; - - DevCleanup(&target->Device); - - for (i = 0;i < NUM_CONTROL_BUFFERS;i++) { - if (target->HTCControlBuffers[i].Buffer) { - kfree(target->HTCControlBuffers[i].Buffer); - } - } - - if (A_IS_MUTEX_VALID(&target->HTCLock)) { - A_MUTEX_DELETE(&target->HTCLock); - } - - if (A_IS_MUTEX_VALID(&target->HTCRxLock)) { - A_MUTEX_DELETE(&target->HTCRxLock); - } - - if (A_IS_MUTEX_VALID(&target->HTCTxLock)) { - A_MUTEX_DELETE(&target->HTCTxLock); - } - /* free our instance */ - kfree(target); -} - -/* registered target arrival callback from the HIF layer */ -HTC_HANDLE HTCCreate(void *hif_handle, struct htc_init_info *pInfo) -{ - struct htc_target *target = NULL; - int status = 0; - int i; - u32 ctrl_bufsz; - u32 blocksizes[HTC_MAILBOX_NUM_MAX]; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCCreate - Enter\n")); - - A_REGISTER_MODULE_DEBUG_INFO(htc); - - do { - - /* allocate target memory */ - if ((target = (struct htc_target *)A_MALLOC(sizeof(struct htc_target))) == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to allocate memory\n")); - status = A_ERROR; - break; - } - - A_MEMZERO(target, sizeof(struct htc_target)); - A_MUTEX_INIT(&target->HTCLock); - A_MUTEX_INIT(&target->HTCRxLock); - A_MUTEX_INIT(&target->HTCTxLock); - INIT_HTC_PACKET_QUEUE(&target->ControlBufferTXFreeList); - INIT_HTC_PACKET_QUEUE(&target->ControlBufferRXFreeList); - - /* give device layer the hif device handle */ - target->Device.HIFDevice = hif_handle; - /* give the device layer our context (for event processing) - * the device layer will register it's own context with HIF - * so we need to set this so we can fetch it in the target remove handler */ - target->Device.HTCContext = target; - /* set device layer target failure callback */ - target->Device.TargetFailureCallback = HTCReportFailure; - /* set device layer recv message pending callback */ - target->Device.MessagePendingCallback = HTCRecvMessagePendingHandler; - target->EpWaitingForBuffers = ENDPOINT_MAX; - - memcpy(&target->HTCInitInfo,pInfo,sizeof(struct htc_init_info)); - - ResetEndpointStates(target); - - /* setup device layer */ - status = DevSetup(&target->Device); - - if (status) { - break; - } - - - /* get the block sizes */ - status = HIFConfigureDevice(hif_handle, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, - blocksizes, sizeof(blocksizes)); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get block size info from HIF layer...\n")); - break; - } - - /* Set the control buffer size based on the block size */ - if (blocksizes[1] > HTC_MAX_CONTROL_MESSAGE_LENGTH) { - ctrl_bufsz = blocksizes[1] + HTC_HDR_LENGTH; - } else { - ctrl_bufsz = HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH; - } - for (i = 0;i < NUM_CONTROL_BUFFERS;i++) { - target->HTCControlBuffers[i].Buffer = A_MALLOC(ctrl_bufsz); - if (target->HTCControlBuffers[i].Buffer == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to allocate memory\n")); - status = A_ERROR; - break; - } - } - - if (status) { - break; - } - - /* carve up buffers/packets for control messages */ - for (i = 0; i < NUM_CONTROL_RX_BUFFERS; i++) { - struct htc_packet *pControlPacket; - pControlPacket = &target->HTCControlBuffers[i].HtcPacket; - SET_HTC_PACKET_INFO_RX_REFILL(pControlPacket, - target, - target->HTCControlBuffers[i].Buffer, - ctrl_bufsz, - ENDPOINT_0); - HTC_FREE_CONTROL_RX(target,pControlPacket); - } - - for (;i < NUM_CONTROL_BUFFERS;i++) { - struct htc_packet *pControlPacket; - pControlPacket = &target->HTCControlBuffers[i].HtcPacket; - INIT_HTC_PACKET_INFO(pControlPacket, - target->HTCControlBuffers[i].Buffer, - ctrl_bufsz); - HTC_FREE_CONTROL_TX(target,pControlPacket); - } - - } while (false); - - if (status) { - if (target != NULL) { - HTCCleanup(target); - target = NULL; - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCCreate - Exit\n")); - - return target; -} - -void HTCDestroy(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCDestroy .. Destroying :0x%lX \n",(unsigned long)target)); - HTCCleanup(target); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCDestroy \n")); -} - -/* get the low level HIF device for the caller , the caller may wish to do low level - * HIF requests */ -void *HTCGetHifDevice(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - return target->Device.HIFDevice; -} - -/* wait for the target to arrive (sends HTC Ready message) - * this operation is fully synchronous and the message is polled for */ -int HTCWaitTarget(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - int status; - struct htc_packet *pPacket = NULL; - HTC_READY_EX_MSG *pRdyMsg; - - struct htc_service_connect_req connect; - struct htc_service_connect_resp resp; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%lX) \n", (unsigned long)target)); - - do { - -#ifdef MBOXHW_UNIT_TEST - - status = DoMboxHWTest(&target->Device); - - if (status) { - break; - } - -#endif - - /* we should be getting 1 control message that the target is ready */ - status = HTCWaitforControlMessage(target, &pPacket); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Target Not Available!!\n")); - break; - } - - /* we controlled the buffer creation so it has to be properly aligned */ - pRdyMsg = (HTC_READY_EX_MSG *)pPacket->pBuffer; - - if ((pRdyMsg->Version2_0_Info.MessageID != HTC_MSG_READY_ID) || - (pPacket->ActualLength < sizeof(HTC_READY_MSG))) { - /* this message is not valid */ - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - - if (pRdyMsg->Version2_0_Info.CreditCount == 0 || pRdyMsg->Version2_0_Info.CreditSize == 0) { - /* this message is not valid */ - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - target->TargetCredits = pRdyMsg->Version2_0_Info.CreditCount; - target->TargetCreditSize = pRdyMsg->Version2_0_Info.CreditSize; - - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, (" Target Ready: credits: %d credit size: %d\n", - target->TargetCredits, target->TargetCreditSize)); - - /* check if this is an extended ready message */ - if (pPacket->ActualLength >= sizeof(HTC_READY_EX_MSG)) { - /* this is an extended message */ - target->HTCTargetVersion = pRdyMsg->HTCVersion; - target->MaxMsgPerBundle = pRdyMsg->MaxMsgsPerHTCBundle; - } else { - /* legacy */ - target->HTCTargetVersion = HTC_VERSION_2P0; - target->MaxMsgPerBundle = 0; - } - -#ifdef HTC_FORCE_LEGACY_2P0 - /* for testing and comparison...*/ - target->HTCTargetVersion = HTC_VERSION_2P0; - target->MaxMsgPerBundle = 0; -#endif - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, - ("Using HTC Protocol Version : %s (%d)\n ", - (target->HTCTargetVersion == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", - target->HTCTargetVersion)); - - if (target->MaxMsgPerBundle > 0) { - /* limit what HTC can handle */ - target->MaxMsgPerBundle = min(HTC_HOST_MAX_MSG_PER_BUNDLE, target->MaxMsgPerBundle); - /* target supports message bundling, setup device layer */ - if (DevSetupMsgBundling(&target->Device,target->MaxMsgPerBundle)) { - /* device layer can't handle bundling */ - target->MaxMsgPerBundle = 0; - } else { - /* limit bundle what the device layer can handle */ - target->MaxMsgPerBundle = min(DEV_GET_MAX_MSG_PER_BUNDLE(&target->Device), - target->MaxMsgPerBundle); - } - } - - if (target->MaxMsgPerBundle > 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, - (" HTC bundling allowed. Max Msg Per HTC Bundle: %d\n", target->MaxMsgPerBundle)); - - if (DEV_GET_MAX_BUNDLE_SEND_LENGTH(&target->Device) != 0) { - target->SendBundlingEnabled = true; - } - if (DEV_GET_MAX_BUNDLE_RECV_LENGTH(&target->Device) != 0) { - target->RecvBundlingEnabled = true; - } - - if (!DEV_IS_LEN_BLOCK_ALIGNED(&target->Device,target->TargetCreditSize)) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("*** Credit size: %d is not block aligned! Disabling send bundling \n", - target->TargetCreditSize)); - /* disallow send bundling since the credit size is not aligned to a block size - * the I/O block padding will spill into the next credit buffer which is fatal */ - target->SendBundlingEnabled = false; - } - } - - /* setup our pseudo HTC control endpoint connection */ - A_MEMZERO(&connect,sizeof(connect)); - A_MEMZERO(&resp,sizeof(resp)); - connect.EpCallbacks.pContext = target; - connect.EpCallbacks.EpTxComplete = HTCControlTxComplete; - connect.EpCallbacks.EpRecv = HTCControlRecv; - connect.EpCallbacks.EpRecvRefill = NULL; /* not needed */ - connect.EpCallbacks.EpSendFull = NULL; /* not nedded */ - connect.MaxSendQueueDepth = NUM_CONTROL_BUFFERS; - connect.ServiceID = HTC_CTRL_RSVD_SVC; - - /* connect fake service */ - status = HTCConnectService((HTC_HANDLE)target, - &connect, - &resp); - - if (!status) { - break; - } - - } while (false); - - if (pPacket != NULL) { - HTC_FREE_CONTROL_RX(target,pPacket); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Exit\n")); - - return status; -} - - - -/* Start HTC, enable interrupts and let the target know host has finished setup */ -int HTCStart(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_packet *pPacket; - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Enter\n")); - - /* make sure interrupts are disabled at the chip level, - * this function can be called again from a reboot of the target without shutting down HTC */ - DevDisableInterrupts(&target->Device); - /* make sure state is cleared again */ - target->OpStateFlags = 0; - target->RecvStateFlags = 0; - - /* now that we are starting, push control receive buffers into the - * HTC control endpoint */ - - while (1) { - pPacket = HTC_ALLOC_CONTROL_RX(target); - if (NULL == pPacket) { - break; - } - HTCAddReceivePkt((HTC_HANDLE)target,pPacket); - } - - do { - - AR_DEBUG_ASSERT(target->InitCredits != NULL); - AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL); - AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL); - - /* call init credits callback to do the distribution , - * NOTE: the first entry in the distribution list is ENDPOINT_0, so - * we pass the start of the list after this one. */ - target->InitCredits(target->pCredDistContext, - target->EpCreditDistributionListHead->pNext, - target->TargetCredits); - -#ifdef ATH_DEBUG_MODULE - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) { - DumpCreditDistStates(target); - } -#endif - - /* the caller is done connecting to services, so we can indicate to the - * target that the setup phase is complete */ - status = HTCSendSetupComplete(target); - - if (status) { - break; - } - - /* unmask interrupts */ - status = DevUnmaskInterrupts(&target->Device); - - if (status) { - HTCStop(target); - } - - } while (false); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Exit\n")); - return status; -} - -static void ResetEndpointStates(struct htc_target *target) -{ - struct htc_endpoint *pEndpoint; - int i; - - for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { - pEndpoint = &target->EndPoint[i]; - - A_MEMZERO(&pEndpoint->CreditDist, sizeof(pEndpoint->CreditDist)); - pEndpoint->ServiceID = 0; - pEndpoint->MaxMsgLength = 0; - pEndpoint->MaxTxQueueDepth = 0; - A_MEMZERO(&pEndpoint->EndPointStats,sizeof(pEndpoint->EndPointStats)); - INIT_HTC_PACKET_QUEUE(&pEndpoint->RxBuffers); - INIT_HTC_PACKET_QUEUE(&pEndpoint->TxQueue); - INIT_HTC_PACKET_QUEUE(&pEndpoint->RecvIndicationQueue); - pEndpoint->target = target; - } - /* reset distribution list */ - target->EpCreditDistributionListHead = NULL; -} - -/* stop HTC communications, i.e. stop interrupt reception, and flush all queued buffers */ -void HTCStop(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCStop \n")); - - LOCK_HTC(target); - /* mark that we are shutting down .. */ - target->OpStateFlags |= HTC_OP_STATE_STOPPING; - UNLOCK_HTC(target); - - /* Masking interrupts is a synchronous operation, when this function returns - * all pending HIF I/O has completed, we can safely flush the queues */ - DevMaskInterrupts(&target->Device); - -#ifdef THREAD_X - // - // Is this delay required - // - A_MDELAY(200); // wait for IRQ process done -#endif - /* flush all send packets */ - HTCFlushSendPkts(target); - /* flush all recv buffers */ - HTCFlushRecvBuffers(target); - - DevCleanupMsgBundling(&target->Device); - - ResetEndpointStates(target); - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n")); -} - -#ifdef ATH_DEBUG_MODULE -void HTCDumpCreditStates(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - - LOCK_HTC_TX(target); - - DumpCreditDistStates(target); - - UNLOCK_HTC_TX(target); - - DumpAR6KDevState(&target->Device); -} -#endif -/* report a target failure from the device, this is a callback from the device layer - * which uses a mechanism to report errors from the target (i.e. special interrupts) */ -static void HTCReportFailure(void *Context) -{ - struct htc_target *target = (struct htc_target *)Context; - - target->TargetFailure = true; - - if (target->HTCInitInfo.TargetFailure != NULL) { - /* let upper layer know, it needs to call HTCStop() */ - target->HTCInitInfo.TargetFailure(target->HTCInitInfo.pContext, A_ERROR); - } -} - -bool HTCGetEndpointStatistics(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint, - HTC_ENDPOINT_STAT_ACTION Action, - struct htc_endpoint_stats *pStats) -{ - - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - bool clearStats = false; - bool sample = false; - - switch (Action) { - case HTC_EP_STAT_SAMPLE : - sample = true; - break; - case HTC_EP_STAT_SAMPLE_AND_CLEAR : - sample = true; - clearStats = true; - break; - case HTC_EP_STAT_CLEAR : - clearStats = true; - break; - default: - break; - } - - A_ASSERT(Endpoint < ENDPOINT_MAX); - - /* lock out TX and RX while we sample and/or clear */ - LOCK_HTC_TX(target); - LOCK_HTC_RX(target); - - if (sample) { - A_ASSERT(pStats != NULL); - /* return the stats to the caller */ - memcpy(pStats, &target->EndPoint[Endpoint].EndPointStats, sizeof(struct htc_endpoint_stats)); - } - - if (clearStats) { - /* reset stats */ - A_MEMZERO(&target->EndPoint[Endpoint].EndPointStats, sizeof(struct htc_endpoint_stats)); - } - - UNLOCK_HTC_RX(target); - UNLOCK_HTC_TX(target); - - return true; -} - -struct ar6k_device *HTCGetAR6KDevice(void *HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - return &target->Device; -} - diff --git a/drivers/staging/ath6kl/htc2/htc_debug.h b/drivers/staging/ath6kl/htc2/htc_debug.h deleted file mode 100644 index 8455703e221..00000000000 --- a/drivers/staging/ath6kl/htc2/htc_debug.h +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef HTC_DEBUG_H_ -#define HTC_DEBUG_H_ - -#define ATH_MODULE_NAME htc -#include "a_debug.h" - -/* ------- Debug related stuff ------- */ - -#define ATH_DEBUG_SEND ATH_DEBUG_MAKE_MODULE_MASK(0) -#define ATH_DEBUG_RECV ATH_DEBUG_MAKE_MODULE_MASK(1) -#define ATH_DEBUG_SYNC ATH_DEBUG_MAKE_MODULE_MASK(2) -#define ATH_DEBUG_DUMP ATH_DEBUG_MAKE_MODULE_MASK(3) -#define ATH_DEBUG_IRQ ATH_DEBUG_MAKE_MODULE_MASK(4) - - -#endif /*HTC_DEBUG_H_*/ diff --git a/drivers/staging/ath6kl/htc2/htc_internal.h b/drivers/staging/ath6kl/htc2/htc_internal.h deleted file mode 100644 index cac97351769..00000000000 --- a/drivers/staging/ath6kl/htc2/htc_internal.h +++ /dev/null @@ -1,211 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HTC_INTERNAL_H_ -#define _HTC_INTERNAL_H_ - -/* for debugging, uncomment this to capture the last frame header, on frame header - * processing errors, the last frame header is dump for comparison */ -//#define HTC_CAPTURE_LAST_FRAME - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Header files */ - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include "htc_debug.h" -#include "htc.h" -#include "htc_api.h" -#include "bmi_msg.h" -#include "hif.h" -#include "AR6000/ar6k.h" - -/* HTC operational parameters */ -#define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */ -#define HTC_TARGET_DEBUG_INTR_MASK 0x01 -#define HTC_TARGET_CREDIT_INTR_MASK 0xF0 - -#define HTC_HOST_MAX_MSG_PER_BUNDLE 8 -#define HTC_MIN_HTC_MSGS_TO_BUNDLE 2 - -/* packet flags */ - -#define HTC_RX_PKT_IGNORE_LOOKAHEAD (1 << 0) -#define HTC_RX_PKT_REFRESH_HDR (1 << 1) -#define HTC_RX_PKT_PART_OF_BUNDLE (1 << 2) -#define HTC_RX_PKT_NO_RECYCLE (1 << 3) - -/* scatter request flags */ - -#define HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE (1 << 0) - -struct htc_endpoint { - HTC_ENDPOINT_ID Id; - HTC_SERVICE_ID ServiceID; /* service ID this endpoint is bound to - non-zero value means this endpoint is in use */ - struct htc_packet_queue TxQueue; /* HTC frame buffer TX queue */ - struct htc_packet_queue RxBuffers; /* HTC frame buffer RX list */ - struct htc_endpoint_credit_dist CreditDist; /* credit distribution structure (exposed to driver layer) */ - struct htc_ep_callbacks EpCallBacks; /* callbacks associated with this endpoint */ - int MaxTxQueueDepth; /* max depth of the TX queue before we need to - call driver's full handler */ - int MaxMsgLength; /* max length of endpoint message */ - int TxProcessCount; /* reference count to continue tx processing */ - struct htc_packet_queue RecvIndicationQueue; /* recv packets ready to be indicated */ - int RxProcessCount; /* reference count to allow single processing context */ - struct htc_target *target; /* back pointer to target */ - u8 SeqNo; /* TX seq no (helpful) for debugging */ - u32 LocalConnectionFlags; /* local connection flags */ - struct htc_endpoint_stats EndPointStats; /* endpoint statistics */ -}; - -#define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count); -#define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL - -#define NUM_CONTROL_BUFFERS 8 -#define NUM_CONTROL_TX_BUFFERS 2 -#define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS) - -struct htc_control_buffer { - struct htc_packet HtcPacket; - u8 *Buffer; -}; - -#define HTC_RECV_WAIT_BUFFERS (1 << 0) -#define HTC_OP_STATE_STOPPING (1 << 0) - -/* our HTC target state */ -struct htc_target { - struct htc_endpoint EndPoint[ENDPOINT_MAX]; - struct htc_control_buffer HTCControlBuffers[NUM_CONTROL_BUFFERS]; - struct htc_endpoint_credit_dist *EpCreditDistributionListHead; - struct htc_packet_queue ControlBufferTXFreeList; - struct htc_packet_queue ControlBufferRXFreeList; - HTC_CREDIT_DIST_CALLBACK DistributeCredits; - HTC_CREDIT_INIT_CALLBACK InitCredits; - void *pCredDistContext; - int TargetCredits; - unsigned int TargetCreditSize; - A_MUTEX_T HTCLock; - A_MUTEX_T HTCRxLock; - A_MUTEX_T HTCTxLock; - struct ar6k_device Device; /* AR6K - specific state */ - u32 OpStateFlags; - u32 RecvStateFlags; - HTC_ENDPOINT_ID EpWaitingForBuffers; - bool TargetFailure; -#ifdef HTC_CAPTURE_LAST_FRAME - struct htc_frame_hdr LastFrameHdr; /* useful for debugging */ - u8 LastTrailer[256]; - u8 LastTrailerLength; -#endif - struct htc_init_info HTCInitInfo; - u8 HTCTargetVersion; - int MaxMsgPerBundle; /* max messages per bundle for HTC */ - bool SendBundlingEnabled; /* run time enable for send bundling (dynamic) */ - int RecvBundlingEnabled; /* run time enable for recv bundling (dynamic) */ -}; - -#define HTC_STOPPING(t) ((t)->OpStateFlags & HTC_OP_STATE_STOPPING) -#define LOCK_HTC(t) A_MUTEX_LOCK(&(t)->HTCLock); -#define UNLOCK_HTC(t) A_MUTEX_UNLOCK(&(t)->HTCLock); -#define LOCK_HTC_RX(t) A_MUTEX_LOCK(&(t)->HTCRxLock); -#define UNLOCK_HTC_RX(t) A_MUTEX_UNLOCK(&(t)->HTCRxLock); -#define LOCK_HTC_TX(t) A_MUTEX_LOCK(&(t)->HTCTxLock); -#define UNLOCK_HTC_TX(t) A_MUTEX_UNLOCK(&(t)->HTCTxLock); - -#define GET_HTC_TARGET_FROM_HANDLE(hnd) ((struct htc_target *)(hnd)) -#define HTC_RECYCLE_RX_PKT(target,p,e) \ -{ \ - if ((p)->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_NO_RECYCLE) { \ - HTC_PACKET_RESET_RX(pPacket); \ - pPacket->Status = A_ECANCELED; \ - (e)->EpCallBacks.EpRecv((e)->EpCallBacks.pContext, \ - (p)); \ - } else { \ - HTC_PACKET_RESET_RX(pPacket); \ - HTCAddReceivePkt((HTC_HANDLE)(target),(p)); \ - } \ -} - -/* internal HTC functions */ -void HTCControlTxComplete(void *Context, struct htc_packet *pPacket); -void HTCControlRecv(void *Context, struct htc_packet *pPacket); -int HTCWaitforControlMessage(struct htc_target *target, struct htc_packet **ppControlPacket); -struct htc_packet *HTCAllocControlBuffer(struct htc_target *target, struct htc_packet_queue *pList); -void HTCFreeControlBuffer(struct htc_target *target, struct htc_packet *pPacket, struct htc_packet_queue *pList); -int HTCIssueSend(struct htc_target *target, struct htc_packet *pPacket); -void HTCRecvCompleteHandler(void *Context, struct htc_packet *pPacket); -int HTCRecvMessagePendingHandler(void *Context, u32 MsgLookAheads[], int NumLookAheads, bool *pAsyncProc, int *pNumPktsFetched); -void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint); -int HTCSendSetupComplete(struct htc_target *target); -void HTCFlushRecvBuffers(struct htc_target *target); -void HTCFlushSendPkts(struct htc_target *target); - -#ifdef ATH_DEBUG_MODULE -void DumpCreditDist(struct htc_endpoint_credit_dist *pEPDist); -void DumpCreditDistStates(struct htc_target *target); -void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription); -#endif - -static INLINE struct htc_packet *HTC_ALLOC_CONTROL_TX(struct htc_target *target) { - struct htc_packet *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXFreeList); - if (pPacket != NULL) { - /* set payload pointer area with some headroom */ - pPacket->pBuffer = pPacket->pBufferStart + HTC_HDR_LENGTH; - } - return pPacket; -} - -#define HTC_FREE_CONTROL_TX(t,p) HTCFreeControlBuffer((t),(p),&(t)->ControlBufferTXFreeList) -#define HTC_ALLOC_CONTROL_RX(t) HTCAllocControlBuffer((t),&(t)->ControlBufferRXFreeList) -#define HTC_FREE_CONTROL_RX(t,p) \ -{ \ - HTC_PACKET_RESET_RX(p); \ - HTCFreeControlBuffer((t),(p),&(t)->ControlBufferRXFreeList); \ -} - -#define HTC_PREPARE_SEND_PKT(pP,sendflags,ctrl0,ctrl1) \ -{ \ - u8 *pHdrBuf; \ - (pP)->pBuffer -= HTC_HDR_LENGTH; \ - pHdrBuf = (pP)->pBuffer; \ - A_SET_UINT16_FIELD(pHdrBuf,struct htc_frame_hdr,PayloadLen,(u16)(pP)->ActualLength); \ - A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,Flags,(sendflags)); \ - A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,EndpointID, (u8)(pP)->Endpoint); \ - A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,ControlBytes[0], (u8)(ctrl0)); \ - A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,ControlBytes[1], (u8)(ctrl1)); \ -} - -#define HTC_UNPREPARE_SEND_PKT(pP) \ - (pP)->pBuffer += HTC_HDR_LENGTH; \ - -#ifdef __cplusplus -} -#endif - -#endif /* _HTC_INTERNAL_H_ */ diff --git a/drivers/staging/ath6kl/htc2/htc_recv.c b/drivers/staging/ath6kl/htc2/htc_recv.c deleted file mode 100644 index 974cc8cd693..00000000000 --- a/drivers/staging/ath6kl/htc2/htc_recv.c +++ /dev/null @@ -1,1572 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#include "htc_internal.h" - -#define HTCIssueRecv(t, p) \ - DevRecvPacket(&(t)->Device, \ - (p), \ - (p)->ActualLength) - -#define DO_RCV_COMPLETION(e,q) DoRecvCompletion(e,q) - -#define DUMP_RECV_PKT_INFO(pP) \ - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC RECV packet 0x%lX (%d bytes) (hdr:0x%X) on ep : %d \n", \ - (unsigned long)(pP), \ - (pP)->ActualLength, \ - (pP)->PktInfo.AsRx.ExpectedHdr, \ - (pP)->Endpoint)) - -#define HTC_RX_STAT_PROFILE(t,ep,numLookAheads) \ -{ \ - INC_HTC_EP_STAT((ep), RxReceived, 1); \ - if ((numLookAheads) == 1) { \ - INC_HTC_EP_STAT((ep), RxLookAheads, 1); \ - } else if ((numLookAheads) > 1) { \ - INC_HTC_EP_STAT((ep), RxBundleLookAheads, 1); \ - } \ -} - -static void DoRecvCompletion(struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pQueueToIndicate) -{ - - do { - - if (HTC_QUEUE_EMPTY(pQueueToIndicate)) { - /* nothing to indicate */ - break; - } - - if (pEndpoint->EpCallBacks.EpRecvPktMultiple != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC calling ep %d, recv multiple callback (%d pkts) \n", - pEndpoint->Id, HTC_PACKET_QUEUE_DEPTH(pQueueToIndicate))); - /* a recv multiple handler is being used, pass the queue to the handler */ - pEndpoint->EpCallBacks.EpRecvPktMultiple(pEndpoint->EpCallBacks.pContext, - pQueueToIndicate); - INIT_HTC_PACKET_QUEUE(pQueueToIndicate); - } else { - struct htc_packet *pPacket; - /* using legacy EpRecv */ - do { - pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC calling ep %d recv callback on packet 0x%lX \n", \ - pEndpoint->Id, (unsigned long)(pPacket))); - pEndpoint->EpCallBacks.EpRecv(pEndpoint->EpCallBacks.pContext, pPacket); - } while (!HTC_QUEUE_EMPTY(pQueueToIndicate)); - } - - } while (false); - -} - -static INLINE int HTCProcessTrailer(struct htc_target *target, - u8 *pBuffer, - int Length, - u32 *pNextLookAheads, - int *pNumLookAheads, - HTC_ENDPOINT_ID FromEndpoint) -{ - HTC_RECORD_HDR *pRecord; - u8 *pRecordBuf; - HTC_LOOKAHEAD_REPORT *pLookAhead; - u8 *pOrigBuffer; - int origLength; - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessTrailer (length:%d) \n", Length)); - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - AR_DEBUG_PRINTBUF(pBuffer,Length,"Recv Trailer"); - } - - pOrigBuffer = pBuffer; - origLength = Length; - status = 0; - - while (Length > 0) { - - if (Length < sizeof(HTC_RECORD_HDR)) { - status = A_EPROTO; - break; - } - /* these are byte aligned structs */ - pRecord = (HTC_RECORD_HDR *)pBuffer; - Length -= sizeof(HTC_RECORD_HDR); - pBuffer += sizeof(HTC_RECORD_HDR); - - if (pRecord->Length > Length) { - /* no room left in buffer for record */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" invalid record length: %d (id:%d) buffer has: %d bytes left \n", - pRecord->Length, pRecord->RecordID, Length)); - status = A_EPROTO; - break; - } - /* start of record follows the header */ - pRecordBuf = pBuffer; - - switch (pRecord->RecordID) { - case HTC_RECORD_CREDITS: - AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_CREDIT_REPORT)); - HTCProcessCreditRpt(target, - (HTC_CREDIT_REPORT *)pRecordBuf, - pRecord->Length / (sizeof(HTC_CREDIT_REPORT)), - FromEndpoint); - break; - case HTC_RECORD_LOOKAHEAD: - AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_LOOKAHEAD_REPORT)); - pLookAhead = (HTC_LOOKAHEAD_REPORT *)pRecordBuf; - if ((pLookAhead->PreValid == ((~pLookAhead->PostValid) & 0xFF)) && - (pNextLookAheads != NULL)) { - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - (" LookAhead Report Found (pre valid:0x%X, post valid:0x%X) \n", - pLookAhead->PreValid, - pLookAhead->PostValid)); - - /* look ahead bytes are valid, copy them over */ - ((u8 *)(&pNextLookAheads[0]))[0] = pLookAhead->LookAhead[0]; - ((u8 *)(&pNextLookAheads[0]))[1] = pLookAhead->LookAhead[1]; - ((u8 *)(&pNextLookAheads[0]))[2] = pLookAhead->LookAhead[2]; - ((u8 *)(&pNextLookAheads[0]))[3] = pLookAhead->LookAhead[3]; - -#ifdef ATH_DEBUG_MODULE - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - DebugDumpBytes((u8 *)pNextLookAheads,4,"Next Look Ahead"); - } -#endif - /* just one normal lookahead */ - *pNumLookAheads = 1; - } - break; - case HTC_RECORD_LOOKAHEAD_BUNDLE: - AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT)); - if (pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT) && - (pNextLookAheads != NULL)) { - HTC_BUNDLED_LOOKAHEAD_REPORT *pBundledLookAheadRpt; - int i; - - pBundledLookAheadRpt = (HTC_BUNDLED_LOOKAHEAD_REPORT *)pRecordBuf; - -#ifdef ATH_DEBUG_MODULE - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - DebugDumpBytes(pRecordBuf,pRecord->Length,"Bundle LookAhead"); - } -#endif - - if ((pRecord->Length / (sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT))) > - HTC_HOST_MAX_MSG_PER_BUNDLE) { - /* this should never happen, the target restricts the number - * of messages per bundle configured by the host */ - A_ASSERT(false); - status = A_EPROTO; - break; - } - - for (i = 0; i < (int)(pRecord->Length / (sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT))); i++) { - ((u8 *)(&pNextLookAheads[i]))[0] = pBundledLookAheadRpt->LookAhead[0]; - ((u8 *)(&pNextLookAheads[i]))[1] = pBundledLookAheadRpt->LookAhead[1]; - ((u8 *)(&pNextLookAheads[i]))[2] = pBundledLookAheadRpt->LookAhead[2]; - ((u8 *)(&pNextLookAheads[i]))[3] = pBundledLookAheadRpt->LookAhead[3]; - pBundledLookAheadRpt++; - } - - *pNumLookAheads = i; - } - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" unhandled record: id:%d length:%d \n", - pRecord->RecordID, pRecord->Length)); - break; - } - - if (status) { - break; - } - - /* advance buffer past this record for next time around */ - pBuffer += pRecord->Length; - Length -= pRecord->Length; - } - -#ifdef ATH_DEBUG_MODULE - if (status) { - DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer"); - } -#endif - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessTrailer \n")); - return status; - -} - -/* process a received message (i.e. strip off header, process any trailer data) - * note : locks must be released when this function is called */ -static int HTCProcessRecvHeader(struct htc_target *target, - struct htc_packet *pPacket, - u32 *pNextLookAheads, - int *pNumLookAheads) -{ - u8 temp; - u8 *pBuf; - int status = 0; - u16 payloadLen; - u32 lookAhead; - - pBuf = pPacket->pBuffer; - - if (pNumLookAheads != NULL) { - *pNumLookAheads = 0; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessRecvHeader \n")); - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - AR_DEBUG_PRINTBUF(pBuf,pPacket->ActualLength,"HTC Recv PKT"); - } - - do { - /* note, we cannot assume the alignment of pBuffer, so we use the safe macros to - * retrieve 16 bit fields */ - payloadLen = A_GET_UINT16_FIELD(pBuf, struct htc_frame_hdr, PayloadLen); - - ((u8 *)&lookAhead)[0] = pBuf[0]; - ((u8 *)&lookAhead)[1] = pBuf[1]; - ((u8 *)&lookAhead)[2] = pBuf[2]; - ((u8 *)&lookAhead)[3] = pBuf[3]; - - if (pPacket->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_REFRESH_HDR) { - /* refresh expected hdr, since this was unknown at the time we grabbed the packets - * as part of a bundle */ - pPacket->PktInfo.AsRx.ExpectedHdr = lookAhead; - /* refresh actual length since we now have the real header */ - pPacket->ActualLength = payloadLen + HTC_HDR_LENGTH; - - /* validate the actual header that was refreshed */ - if (pPacket->ActualLength > pPacket->BufferLength) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Refreshed HDR payload length (%d) in bundled RECV is invalid (hdr: 0x%X) \n", - payloadLen, lookAhead)); - /* limit this to max buffer just to print out some of the buffer */ - pPacket->ActualLength = min(pPacket->ActualLength, pPacket->BufferLength); - status = A_EPROTO; - break; - } - - if (pPacket->Endpoint != A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, EndpointID)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Refreshed HDR endpoint (%d) does not match expected endpoint (%d) \n", - A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, EndpointID), pPacket->Endpoint)); - status = A_EPROTO; - break; - } - } - - if (lookAhead != pPacket->PktInfo.AsRx.ExpectedHdr) { - /* somehow the lookahead that gave us the full read length did not - * reflect the actual header in the pending message */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("HTCProcessRecvHeader, lookahead mismatch! (pPkt:0x%lX flags:0x%X) \n", - (unsigned long)pPacket, pPacket->PktInfo.AsRx.HTCRxFlags)); -#ifdef ATH_DEBUG_MODULE - DebugDumpBytes((u8 *)&pPacket->PktInfo.AsRx.ExpectedHdr,4,"Expected Message LookAhead"); - DebugDumpBytes(pBuf,sizeof(struct htc_frame_hdr),"Current Frame Header"); -#ifdef HTC_CAPTURE_LAST_FRAME - DebugDumpBytes((u8 *)&target->LastFrameHdr,sizeof(struct htc_frame_hdr),"Last Frame Header"); - if (target->LastTrailerLength != 0) { - DebugDumpBytes(target->LastTrailer, - target->LastTrailerLength, - "Last trailer"); - } -#endif -#endif - status = A_EPROTO; - break; - } - - /* get flags */ - temp = A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, Flags); - - if (temp & HTC_FLAGS_RECV_TRAILER) { - /* this packet has a trailer */ - - /* extract the trailer length in control byte 0 */ - temp = A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, ControlBytes[0]); - - if ((temp < sizeof(HTC_RECORD_HDR)) || (temp > payloadLen)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("HTCProcessRecvHeader, invalid header (payloadlength should be :%d, CB[0] is:%d) \n", - payloadLen, temp)); - status = A_EPROTO; - break; - } - - if (pPacket->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_IGNORE_LOOKAHEAD) { - /* this packet was fetched as part of an HTC bundle, the embedded lookahead is - * not valid since the next packet may have already been fetched as part of the - * bundle */ - pNextLookAheads = NULL; - pNumLookAheads = NULL; - } - - /* process trailer data that follows HDR + application payload */ - status = HTCProcessTrailer(target, - (pBuf + HTC_HDR_LENGTH + payloadLen - temp), - temp, - pNextLookAheads, - pNumLookAheads, - pPacket->Endpoint); - - if (status) { - break; - } - -#ifdef HTC_CAPTURE_LAST_FRAME - memcpy(target->LastTrailer, (pBuf + HTC_HDR_LENGTH + payloadLen - temp), temp); - target->LastTrailerLength = temp; -#endif - /* trim length by trailer bytes */ - pPacket->ActualLength -= temp; - } -#ifdef HTC_CAPTURE_LAST_FRAME - else { - target->LastTrailerLength = 0; - } -#endif - - /* if we get to this point, the packet is good */ - /* remove header and adjust length */ - pPacket->pBuffer += HTC_HDR_LENGTH; - pPacket->ActualLength -= HTC_HDR_LENGTH; - - } while (false); - - if (status) { - /* dump the whole packet */ -#ifdef ATH_DEBUG_MODULE - DebugDumpBytes(pBuf,pPacket->ActualLength < 256 ? pPacket->ActualLength : 256 ,"BAD HTC Recv PKT"); -#endif - } else { -#ifdef HTC_CAPTURE_LAST_FRAME - memcpy(&target->LastFrameHdr,pBuf,sizeof(struct htc_frame_hdr)); -#endif - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - if (pPacket->ActualLength > 0) { - AR_DEBUG_PRINTBUF(pPacket->pBuffer,pPacket->ActualLength,"HTC - Application Msg"); - } - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessRecvHeader \n")); - return status; -} - -static INLINE void HTCAsyncRecvCheckMorePackets(struct htc_target *target, - u32 NextLookAheads[], - int NumLookAheads, - bool CheckMoreMsgs) -{ - /* was there a lookahead for the next packet? */ - if (NumLookAheads > 0) { - int nextStatus; - int fetched = 0; - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("HTCAsyncRecvCheckMorePackets - num lookaheads were non-zero : %d \n", - NumLookAheads)); - /* force status re-check */ - REF_IRQ_STATUS_RECHECK(&target->Device); - /* we have more packets, get the next packet fetch started */ - nextStatus = HTCRecvMessagePendingHandler(target, NextLookAheads, NumLookAheads, NULL, &fetched); - if (A_EPROTO == nextStatus) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Next look ahead from recv header was INVALID\n")); -#ifdef ATH_DEBUG_MODULE - DebugDumpBytes((u8 *)NextLookAheads, - NumLookAheads * (sizeof(u32)), - "BAD lookaheads from lookahead report"); -#endif - } - if (!nextStatus && !fetched) { - /* we could not fetch any more packets due to resources */ - DevAsyncIrqProcessComplete(&target->Device); - } - } else { - if (CheckMoreMsgs) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("HTCAsyncRecvCheckMorePackets - rechecking for more messages...\n")); - /* if we did not get anything on the look-ahead, - * call device layer to asynchronously re-check for messages. If we can keep the async - * processing going we get better performance. If there is a pending message we will keep processing - * messages asynchronously which should pipeline things nicely */ - DevCheckPendingRecvMsgsAsync(&target->Device); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("HTCAsyncRecvCheckMorePackets - no check \n")); - } - } - - -} - - /* unload the recv completion queue */ -static INLINE void DrainRecvIndicationQueue(struct htc_target *target, struct htc_endpoint *pEndpoint) -{ - struct htc_packet_queue recvCompletions; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+DrainRecvIndicationQueue \n")); - - INIT_HTC_PACKET_QUEUE(&recvCompletions); - - LOCK_HTC_RX(target); - - /* increment rx processing count on entry */ - pEndpoint->RxProcessCount++; - if (pEndpoint->RxProcessCount > 1) { - pEndpoint->RxProcessCount--; - /* another thread or task is draining the RX completion queue on this endpoint - * that thread will reset the rx processing count when the queue is drained */ - UNLOCK_HTC_RX(target); - return; - } - - /******* at this point only 1 thread may enter ******/ - - while (true) { - - /* transfer items from main recv queue to the local one so we can release the lock */ - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&recvCompletions, &pEndpoint->RecvIndicationQueue); - - if (HTC_QUEUE_EMPTY(&recvCompletions)) { - /* all drained */ - break; - } - - /* release lock while we do the recv completions - * other threads can now queue more recv completions */ - UNLOCK_HTC_RX(target); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("DrainRecvIndicationQueue : completing %d RECV packets \n", - HTC_PACKET_QUEUE_DEPTH(&recvCompletions))); - /* do completion */ - DO_RCV_COMPLETION(pEndpoint,&recvCompletions); - - /* re-acquire lock to grab some more completions */ - LOCK_HTC_RX(target); - } - - /* reset count */ - pEndpoint->RxProcessCount = 0; - UNLOCK_HTC_RX(target); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-DrainRecvIndicationQueue \n")); - -} - - /* optimization for recv packets, we can indicate a "hint" that there are more - * single-packets to fetch on this endpoint */ -#define SET_MORE_RX_PACKET_INDICATION_FLAG(L,N,E,P) \ - if ((N) > 0) { SetRxPacketIndicationFlags((L)[0],(E),(P)); } - - /* for bundled frames, we can force the flag to indicate there are more packets */ -#define FORCE_MORE_RX_PACKET_INDICATION_FLAG(P) \ - (P)->PktInfo.AsRx.IndicationFlags |= HTC_RX_FLAGS_INDICATE_MORE_PKTS; - - /* note: this function can be called with the RX lock held */ -static INLINE void SetRxPacketIndicationFlags(u32 LookAhead, - struct htc_endpoint *pEndpoint, - struct htc_packet *pPacket) -{ - struct htc_frame_hdr *pHdr = (struct htc_frame_hdr *)&LookAhead; - /* check to see if the "next" packet is from the same endpoint of the - completing packet */ - if (pHdr->EndpointID == pPacket->Endpoint) { - /* check that there is a buffer available to actually fetch it */ - if (!HTC_QUEUE_EMPTY(&pEndpoint->RxBuffers)) { - /* provide a hint that there are more RX packets to fetch */ - FORCE_MORE_RX_PACKET_INDICATION_FLAG(pPacket); - } - } -} - - -/* asynchronous completion handler for recv packet fetching, when the device layer - * completes a read request, it will call this completion handler */ -void HTCRecvCompleteHandler(void *Context, struct htc_packet *pPacket) -{ - struct htc_target *target = (struct htc_target *)Context; - struct htc_endpoint *pEndpoint; - u32 nextLookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; - int numLookAheads = 0; - int status; - bool checkMorePkts = true; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (pkt:0x%lX, status:%d, ep:%d) \n", - (unsigned long)pPacket, pPacket->Status, pPacket->Endpoint)); - - A_ASSERT(!IS_DEV_IRQ_PROC_SYNC_MODE(&target->Device)); - AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX); - pEndpoint = &target->EndPoint[pPacket->Endpoint]; - pPacket->Completion = NULL; - - /* get completion status */ - status = pPacket->Status; - - do { - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCRecvCompleteHandler: request failed (status:%d, ep:%d) \n", - pPacket->Status, pPacket->Endpoint)); - break; - } - /* process the header for any trailer data */ - status = HTCProcessRecvHeader(target,pPacket,nextLookAheads,&numLookAheads); - - if (status) { - break; - } - - if (pPacket->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_IGNORE_LOOKAHEAD) { - /* this packet was part of a bundle that had to be broken up. - * It was fetched one message at a time. There may be other asynchronous reads queued behind this one. - * Do no issue another check for more packets since the last one in the series of requests - * will handle it */ - checkMorePkts = false; - } - - DUMP_RECV_PKT_INFO(pPacket); - LOCK_HTC_RX(target); - SET_MORE_RX_PACKET_INDICATION_FLAG(nextLookAheads,numLookAheads,pEndpoint,pPacket); - /* we have a good packet, queue it to the completion queue */ - HTC_PACKET_ENQUEUE(&pEndpoint->RecvIndicationQueue,pPacket); - HTC_RX_STAT_PROFILE(target,pEndpoint,numLookAheads); - UNLOCK_HTC_RX(target); - - /* check for more recv packets before indicating */ - HTCAsyncRecvCheckMorePackets(target,nextLookAheads,numLookAheads,checkMorePkts); - - } while (false); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("HTCRecvCompleteHandler , message fetch failed (status = %d) \n", - status)); - /* recycle this packet */ - HTC_RECYCLE_RX_PKT(target, pPacket, pEndpoint); - } else { - /* a good packet was queued, drain the queue */ - DrainRecvIndicationQueue(target,pEndpoint); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCRecvCompleteHandler\n")); -} - -/* synchronously wait for a control message from the target, - * This function is used at initialization time ONLY. At init messages - * on ENDPOINT 0 are expected. */ -int HTCWaitforControlMessage(struct htc_target *target, struct htc_packet **ppControlPacket) -{ - int status; - u32 lookAhead; - struct htc_packet *pPacket = NULL; - struct htc_frame_hdr *pHdr; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCWaitforControlMessage \n")); - - do { - - *ppControlPacket = NULL; - - /* call the polling function to see if we have a message */ - status = DevPollMboxMsgRecv(&target->Device, - &lookAhead, - HTC_TARGET_RESPONSE_TIMEOUT); - - if (status) { - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("HTCWaitforControlMessage : lookAhead : 0x%X \n", lookAhead)); - - /* check the lookahead */ - pHdr = (struct htc_frame_hdr *)&lookAhead; - - if (pHdr->EndpointID != ENDPOINT_0) { - /* unexpected endpoint number, should be zero */ - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - if (status) { - /* bad message */ - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - pPacket = HTC_ALLOC_CONTROL_RX(target); - - if (pPacket == NULL) { - AR_DEBUG_ASSERT(false); - status = A_NO_MEMORY; - break; - } - - pPacket->PktInfo.AsRx.HTCRxFlags = 0; - pPacket->PktInfo.AsRx.ExpectedHdr = lookAhead; - pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH; - - if (pPacket->ActualLength > pPacket->BufferLength) { - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - /* we want synchronous operation */ - pPacket->Completion = NULL; - - /* get the message from the device, this will block */ - status = HTCIssueRecv(target, pPacket); - - if (status) { - break; - } - - /* process receive header */ - status = HTCProcessRecvHeader(target,pPacket,NULL,NULL); - - pPacket->Status = status; - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("HTCWaitforControlMessage, HTCProcessRecvHeader failed (status = %d) \n", - status)); - break; - } - - /* give the caller this control message packet, they are responsible to free */ - *ppControlPacket = pPacket; - - } while (false); - - if (status) { - if (pPacket != NULL) { - /* cleanup buffer on error */ - HTC_FREE_CONTROL_RX(target,pPacket); - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCWaitforControlMessage \n")); - - return status; -} - -static int AllocAndPrepareRxPackets(struct htc_target *target, - u32 LookAheads[], - int Messages, - struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pQueue) -{ - int status = 0; - struct htc_packet *pPacket; - struct htc_frame_hdr *pHdr; - int i,j; - int numMessages; - int fullLength; - bool noRecycle; - - /* lock RX while we assemble the packet buffers */ - LOCK_HTC_RX(target); - - for (i = 0; i < Messages; i++) { - - pHdr = (struct htc_frame_hdr *)&LookAheads[i]; - - if (pHdr->EndpointID >= ENDPOINT_MAX) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d \n",pHdr->EndpointID)); - /* invalid endpoint */ - status = A_EPROTO; - break; - } - - if (pHdr->EndpointID != pEndpoint->Id) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d should be : %d (index:%d)\n", - pHdr->EndpointID, pEndpoint->Id, i)); - /* invalid endpoint */ - status = A_EPROTO; - break; - } - - if (pHdr->PayloadLen > HTC_MAX_PAYLOAD_LENGTH) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Payload length %d exceeds max HTC : %d !\n", - pHdr->PayloadLen, (u32)HTC_MAX_PAYLOAD_LENGTH)); - status = A_EPROTO; - break; - } - - if (0 == pEndpoint->ServiceID) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Endpoint %d is not connected !\n",pHdr->EndpointID)); - /* endpoint isn't even connected */ - status = A_EPROTO; - break; - } - - if ((pHdr->Flags & HTC_FLAGS_RECV_BUNDLE_CNT_MASK) == 0) { - /* HTC header only indicates 1 message to fetch */ - numMessages = 1; - } else { - /* HTC header indicates that every packet to follow has the same padded length so that it can - * be optimally fetched as a full bundle */ - numMessages = (pHdr->Flags & HTC_FLAGS_RECV_BUNDLE_CNT_MASK) >> HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT; - /* the count doesn't include the starter frame, just a count of frames to follow */ - numMessages++; - A_ASSERT(numMessages <= target->MaxMsgPerBundle); - INC_HTC_EP_STAT(pEndpoint, RxBundleIndFromHdr, 1); - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("HTC header indicates :%d messages can be fetched as a bundle \n",numMessages)); - } - - fullLength = DEV_CALC_RECV_PADDED_LEN(&target->Device,pHdr->PayloadLen + sizeof(struct htc_frame_hdr)); - - /* get packet buffers for each message, if there was a bundle detected in the header, - * use pHdr as a template to fetch all packets in the bundle */ - for (j = 0; j < numMessages; j++) { - - /* reset flag, any packets allocated using the RecvAlloc() API cannot be recycled on cleanup, - * they must be explicitly returned */ - noRecycle = false; - - if (pEndpoint->EpCallBacks.EpRecvAlloc != NULL) { - UNLOCK_HTC_RX(target); - noRecycle = true; - /* user is using a per-packet allocation callback */ - pPacket = pEndpoint->EpCallBacks.EpRecvAlloc(pEndpoint->EpCallBacks.pContext, - pEndpoint->Id, - fullLength); - LOCK_HTC_RX(target); - - } else if ((pEndpoint->EpCallBacks.EpRecvAllocThresh != NULL) && - (fullLength > pEndpoint->EpCallBacks.RecvAllocThreshold)) { - INC_HTC_EP_STAT(pEndpoint,RxAllocThreshHit,1); - INC_HTC_EP_STAT(pEndpoint,RxAllocThreshBytes,pHdr->PayloadLen); - /* threshold was hit, call the special recv allocation callback */ - UNLOCK_HTC_RX(target); - noRecycle = true; - /* user wants to allocate packets above a certain threshold */ - pPacket = pEndpoint->EpCallBacks.EpRecvAllocThresh(pEndpoint->EpCallBacks.pContext, - pEndpoint->Id, - fullLength); - LOCK_HTC_RX(target); - - } else { - /* user is using a refill handler that can refill multiple HTC buffers */ - - /* get a packet from the endpoint recv queue */ - pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers); - - if (NULL == pPacket) { - /* check for refill handler */ - if (pEndpoint->EpCallBacks.EpRecvRefill != NULL) { - UNLOCK_HTC_RX(target); - /* call the re-fill handler */ - pEndpoint->EpCallBacks.EpRecvRefill(pEndpoint->EpCallBacks.pContext, - pEndpoint->Id); - LOCK_HTC_RX(target); - /* check if we have more buffers */ - pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers); - /* fall through */ - } - } - } - - if (NULL == pPacket) { - /* this is not an error, we simply need to mark that we are waiting for buffers.*/ - target->RecvStateFlags |= HTC_RECV_WAIT_BUFFERS; - target->EpWaitingForBuffers = pEndpoint->Id; - status = A_NO_RESOURCE; - break; - } - - AR_DEBUG_ASSERT(pPacket->Endpoint == pEndpoint->Id); - /* clear flags */ - pPacket->PktInfo.AsRx.HTCRxFlags = 0; - pPacket->PktInfo.AsRx.IndicationFlags = 0; - pPacket->Status = 0; - - if (noRecycle) { - /* flag that these packets cannot be recycled, they have to be returned to the - * user */ - pPacket->PktInfo.AsRx.HTCRxFlags |= HTC_RX_PKT_NO_RECYCLE; - } - /* add packet to queue (also incase we need to cleanup down below) */ - HTC_PACKET_ENQUEUE(pQueue,pPacket); - - if (HTC_STOPPING(target)) { - status = A_ECANCELED; - break; - } - - /* make sure this message can fit in the endpoint buffer */ - if ((u32)fullLength > pPacket->BufferLength) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Payload Length Error : header reports payload of: %d (%d) endpoint buffer size: %d \n", - pHdr->PayloadLen, fullLength, pPacket->BufferLength)); - status = A_EPROTO; - break; - } - - if (j > 0) { - /* for messages fetched in a bundle the expected lookahead is unknown since we - * are only using the lookahead of the first packet as a template of what to - * expect for lengths */ - /* flag that once we get the real HTC header we need to refesh the information */ - pPacket->PktInfo.AsRx.HTCRxFlags |= HTC_RX_PKT_REFRESH_HDR; - /* set it to something invalid */ - pPacket->PktInfo.AsRx.ExpectedHdr = 0xFFFFFFFF; - } else { - - pPacket->PktInfo.AsRx.ExpectedHdr = LookAheads[i]; /* set expected look ahead */ - } - /* set the amount of data to fetch */ - pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH; - } - - if (status) { - if (A_NO_RESOURCE == status) { - /* this is actually okay */ - status = 0; - } - break; - } - - } - - UNLOCK_HTC_RX(target); - - if (status) { - while (!HTC_QUEUE_EMPTY(pQueue)) { - pPacket = HTC_PACKET_DEQUEUE(pQueue); - /* recycle all allocated packets */ - HTC_RECYCLE_RX_PKT(target,pPacket,&target->EndPoint[pPacket->Endpoint]); - } - } - - return status; -} - -static void HTCAsyncRecvScatterCompletion(struct hif_scatter_req *pScatterReq) -{ - int i; - struct htc_packet *pPacket; - struct htc_endpoint *pEndpoint; - u32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; - int numLookAheads = 0; - struct htc_target *target = (struct htc_target *)pScatterReq->Context; - int status; - bool partialBundle = false; - struct htc_packet_queue localRecvQueue; - bool procError = false; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCAsyncRecvScatterCompletion TotLen: %d Entries: %d\n", - pScatterReq->TotalLength, pScatterReq->ValidScatterEntries)); - - A_ASSERT(!IS_DEV_IRQ_PROC_SYNC_MODE(&target->Device)); - - if (pScatterReq->CompletionStatus) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** Recv Scatter Request Failed: %d \n",pScatterReq->CompletionStatus)); - } - - if (pScatterReq->CallerFlags & HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE) { - partialBundle = true; - } - - DEV_FINISH_SCATTER_OPERATION(pScatterReq); - - INIT_HTC_PACKET_QUEUE(&localRecvQueue); - - pPacket = (struct htc_packet *)pScatterReq->ScatterList[0].pCallerContexts[0]; - /* note: all packets in a scatter req are for the same endpoint ! */ - pEndpoint = &target->EndPoint[pPacket->Endpoint]; - - /* walk through the scatter list and process */ - /* **** NOTE: DO NOT HOLD ANY LOCKS here, HTCProcessRecvHeader can take the TX lock - * as it processes credit reports */ - for (i = 0; i < pScatterReq->ValidScatterEntries; i++) { - pPacket = (struct htc_packet *)pScatterReq->ScatterList[i].pCallerContexts[0]; - A_ASSERT(pPacket != NULL); - /* reset count, we are only interested in the look ahead in the last packet when we - * break out of this loop */ - numLookAheads = 0; - - if (!pScatterReq->CompletionStatus) { - /* process header for each of the recv packets */ - status = HTCProcessRecvHeader(target,pPacket,lookAheads,&numLookAheads); - } else { - status = A_ERROR; - } - - if (!status) { - LOCK_HTC_RX(target); - HTC_RX_STAT_PROFILE(target,pEndpoint,numLookAheads); - INC_HTC_EP_STAT(pEndpoint, RxPacketsBundled, 1); - UNLOCK_HTC_RX(target); - if (i == (pScatterReq->ValidScatterEntries - 1)) { - /* last packet's more packets flag is set based on the lookahead */ - SET_MORE_RX_PACKET_INDICATION_FLAG(lookAheads,numLookAheads,pEndpoint,pPacket); - } else { - /* packets in a bundle automatically have this flag set */ - FORCE_MORE_RX_PACKET_INDICATION_FLAG(pPacket); - } - - DUMP_RECV_PKT_INFO(pPacket); - /* since we can't hold a lock in this loop, we insert into our local recv queue for - * storage until we can transfer them to the recv completion queue */ - HTC_PACKET_ENQUEUE(&localRecvQueue,pPacket); - - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Recv packet scatter entry %d failed (out of %d) \n", - i, pScatterReq->ValidScatterEntries)); - /* recycle failed recv */ - HTC_RECYCLE_RX_PKT(target, pPacket, pEndpoint); - /* set flag and continue processing the remaining scatter entries */ - procError = true; - } - - } - - /* free scatter request */ - DEV_FREE_SCATTER_REQ(&target->Device,pScatterReq); - - LOCK_HTC_RX(target); - /* transfer the packets in the local recv queue to the recv completion queue */ - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&pEndpoint->RecvIndicationQueue, &localRecvQueue); - - UNLOCK_HTC_RX(target); - - if (!procError) { - /* pipeline the next check (asynchronously) for more packets */ - HTCAsyncRecvCheckMorePackets(target, - lookAheads, - numLookAheads, - partialBundle ? false : true); - } - - /* now drain the indication queue */ - DrainRecvIndicationQueue(target,pEndpoint); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCAsyncRecvScatterCompletion \n")); -} - -static int HTCIssueRecvPacketBundle(struct htc_target *target, - struct htc_packet_queue *pRecvPktQueue, - struct htc_packet_queue *pSyncCompletionQueue, - int *pNumPacketsFetched, - bool PartialBundle) -{ - int status = 0; - struct hif_scatter_req *pScatterReq; - int i, totalLength; - int pktsToScatter; - struct htc_packet *pPacket; - bool asyncMode = (pSyncCompletionQueue == NULL) ? true : false; - int scatterSpaceRemaining = DEV_GET_MAX_BUNDLE_RECV_LENGTH(&target->Device); - - pktsToScatter = HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue); - pktsToScatter = min(pktsToScatter, target->MaxMsgPerBundle); - - if ((HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue) - pktsToScatter) > 0) { - /* we were forced to split this bundle receive operation - * all packets in this partial bundle must have their lookaheads ignored */ - PartialBundle = true; - /* this would only happen if the target ignored our max bundle limit */ - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - ("HTCIssueRecvPacketBundle : partial bundle detected num:%d , %d \n", - HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue), pktsToScatter)); - } - - totalLength = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCIssueRecvPacketBundle (Numpackets: %d , actual : %d) \n", - HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue), pktsToScatter)); - - do { - - pScatterReq = DEV_ALLOC_SCATTER_REQ(&target->Device); - - if (pScatterReq == NULL) { - /* no scatter resources left, just let caller handle it the legacy way */ - break; - } - - pScatterReq->CallerFlags = 0; - - if (PartialBundle) { - /* mark that this is a partial bundle, this has special ramifications to the - * scatter completion routine */ - pScatterReq->CallerFlags |= HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE; - } - - /* convert HTC packets to scatter list */ - for (i = 0; i < pktsToScatter; i++) { - int paddedLength; - - pPacket = HTC_PACKET_DEQUEUE(pRecvPktQueue); - A_ASSERT(pPacket != NULL); - - paddedLength = DEV_CALC_RECV_PADDED_LEN(&target->Device, pPacket->ActualLength); - - if ((scatterSpaceRemaining - paddedLength) < 0) { - /* exceeds what we can transfer, put the packet back */ - HTC_PACKET_ENQUEUE_TO_HEAD(pRecvPktQueue,pPacket); - break; - } - - scatterSpaceRemaining -= paddedLength; - - if (PartialBundle || (i < (pktsToScatter - 1))) { - /* packet 0..n-1 cannot be checked for look-aheads since we are fetching a bundle - * the last packet however can have it's lookahead used */ - pPacket->PktInfo.AsRx.HTCRxFlags |= HTC_RX_PKT_IGNORE_LOOKAHEAD; - } - - /* note: 1 HTC packet per scatter entry */ - /* setup packet into */ - pScatterReq->ScatterList[i].pBuffer = pPacket->pBuffer; - pScatterReq->ScatterList[i].Length = paddedLength; - - pPacket->PktInfo.AsRx.HTCRxFlags |= HTC_RX_PKT_PART_OF_BUNDLE; - - if (asyncMode) { - /* save HTC packet for async completion routine */ - pScatterReq->ScatterList[i].pCallerContexts[0] = pPacket; - } else { - /* queue to caller's sync completion queue, caller will unload this when we return */ - HTC_PACKET_ENQUEUE(pSyncCompletionQueue,pPacket); - } - - A_ASSERT(pScatterReq->ScatterList[i].Length); - totalLength += pScatterReq->ScatterList[i].Length; - } - - pScatterReq->TotalLength = totalLength; - pScatterReq->ValidScatterEntries = i; - - if (asyncMode) { - pScatterReq->CompletionRoutine = HTCAsyncRecvScatterCompletion; - pScatterReq->Context = target; - } - - status = DevSubmitScatterRequest(&target->Device, pScatterReq, DEV_SCATTER_READ, asyncMode); - - if (!status) { - *pNumPacketsFetched = i; - } - - if (!asyncMode) { - /* free scatter request */ - DEV_FREE_SCATTER_REQ(&target->Device, pScatterReq); - } - - } while (false); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCIssueRecvPacketBundle (status:%d) (fetched:%d) \n", - status,*pNumPacketsFetched)); - - return status; -} - -static INLINE void CheckRecvWaterMark(struct htc_endpoint *pEndpoint) -{ - /* see if endpoint is using a refill watermark - * ** no need to use a lock here, since we are only inspecting... - * caller may must not hold locks when calling this function */ - if (pEndpoint->EpCallBacks.RecvRefillWaterMark > 0) { - if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->RxBuffers) < pEndpoint->EpCallBacks.RecvRefillWaterMark) { - /* call the re-fill handler before we continue */ - pEndpoint->EpCallBacks.EpRecvRefill(pEndpoint->EpCallBacks.pContext, - pEndpoint->Id); - } - } -} - -/* callback when device layer or lookahead report parsing detects a pending message */ -int HTCRecvMessagePendingHandler(void *Context, u32 MsgLookAheads[], int NumLookAheads, bool *pAsyncProc, int *pNumPktsFetched) -{ - struct htc_target *target = (struct htc_target *)Context; - int status = 0; - struct htc_packet *pPacket; - struct htc_endpoint *pEndpoint; - bool asyncProc = false; - u32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; - int pktsFetched; - struct htc_packet_queue recvPktQueue, syncCompletedPktsQueue; - bool partialBundle; - HTC_ENDPOINT_ID id; - int totalFetched = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCRecvMessagePendingHandler NumLookAheads: %d \n",NumLookAheads)); - - if (pNumPktsFetched != NULL) { - *pNumPktsFetched = 0; - } - - if (IS_DEV_IRQ_PROCESSING_ASYNC_ALLOWED(&target->Device)) { - /* We use async mode to get the packets if the device layer supports it. - * The device layer interfaces with HIF in which HIF may have restrictions on - * how interrupts are processed */ - asyncProc = true; - } - - if (pAsyncProc != NULL) { - /* indicate to caller how we decided to process this */ - *pAsyncProc = asyncProc; - } - - if (NumLookAheads > HTC_HOST_MAX_MSG_PER_BUNDLE) { - A_ASSERT(false); - return A_EPROTO; - } - - /* on first entry copy the lookaheads into our temp array for processing */ - memcpy(lookAheads, MsgLookAheads, (sizeof(u32)) * NumLookAheads); - - while (true) { - - /* reset packets queues */ - INIT_HTC_PACKET_QUEUE(&recvPktQueue); - INIT_HTC_PACKET_QUEUE(&syncCompletedPktsQueue); - - if (NumLookAheads > HTC_HOST_MAX_MSG_PER_BUNDLE) { - status = A_EPROTO; - A_ASSERT(false); - break; - } - - /* first lookahead sets the expected endpoint IDs for all packets in a bundle */ - id = ((struct htc_frame_hdr *)&lookAheads[0])->EndpointID; - pEndpoint = &target->EndPoint[id]; - - if (id >= ENDPOINT_MAX) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MsgPend, Invalid Endpoint in look-ahead: %d \n",id)); - status = A_EPROTO; - break; - } - - /* try to allocate as many HTC RX packets indicated by the lookaheads - * these packets are stored in the recvPkt queue */ - status = AllocAndPrepareRxPackets(target, - lookAheads, - NumLookAheads, - pEndpoint, - &recvPktQueue); - if (status) { - break; - } - - if (HTC_PACKET_QUEUE_DEPTH(&recvPktQueue) >= 2) { - /* a recv bundle was detected, force IRQ status re-check again */ - REF_IRQ_STATUS_RECHECK(&target->Device); - } - - totalFetched += HTC_PACKET_QUEUE_DEPTH(&recvPktQueue); - - /* we've got packet buffers for all we can currently fetch, - * this count is not valid anymore */ - NumLookAheads = 0; - partialBundle = false; - - /* now go fetch the list of HTC packets */ - while (!HTC_QUEUE_EMPTY(&recvPktQueue)) { - - pktsFetched = 0; - - if (target->RecvBundlingEnabled && (HTC_PACKET_QUEUE_DEPTH(&recvPktQueue) > 1)) { - /* there are enough packets to attempt a bundle transfer and recv bundling is allowed */ - status = HTCIssueRecvPacketBundle(target, - &recvPktQueue, - asyncProc ? NULL : &syncCompletedPktsQueue, - &pktsFetched, - partialBundle); - if (status) { - break; - } - - if (HTC_PACKET_QUEUE_DEPTH(&recvPktQueue) != 0) { - /* we couldn't fetch all packets at one time, this creates a broken - * bundle */ - partialBundle = true; - } - } - - /* see if the previous operation fetched any packets using bundling */ - if (0 == pktsFetched) { - /* dequeue one packet */ - pPacket = HTC_PACKET_DEQUEUE(&recvPktQueue); - A_ASSERT(pPacket != NULL); - - if (asyncProc) { - /* we use async mode to get the packet if the device layer supports it - * set our callback and context */ - pPacket->Completion = HTCRecvCompleteHandler; - pPacket->pContext = target; - } else { - /* fully synchronous */ - pPacket->Completion = NULL; - } - - if (HTC_PACKET_QUEUE_DEPTH(&recvPktQueue) > 0) { - /* lookaheads in all packets except the last one in the bundle must be ignored */ - pPacket->PktInfo.AsRx.HTCRxFlags |= HTC_RX_PKT_IGNORE_LOOKAHEAD; - } - - /* go fetch the packet */ - status = HTCIssueRecv(target, pPacket); - if (status) { - break; - } - - if (!asyncProc) { - /* sent synchronously, queue this packet for synchronous completion */ - HTC_PACKET_ENQUEUE(&syncCompletedPktsQueue,pPacket); - } - - } - - } - - if (!status) { - CheckRecvWaterMark(pEndpoint); - } - - if (asyncProc) { - /* we did this asynchronously so we can get out of the loop, the asynch processing - * creates a chain of requests to continue processing pending messages in the - * context of callbacks */ - break; - } - - /* synchronous handling */ - if (target->Device.DSRCanYield) { - /* for the SYNC case, increment count that tracks when the DSR should yield */ - target->Device.CurrentDSRRecvCount++; - } - - /* in the sync case, all packet buffers are now filled, - * we can process each packet, check lookaheads and then repeat */ - - /* unload sync completion queue */ - while (!HTC_QUEUE_EMPTY(&syncCompletedPktsQueue)) { - struct htc_packet_queue container; - - pPacket = HTC_PACKET_DEQUEUE(&syncCompletedPktsQueue); - A_ASSERT(pPacket != NULL); - - pEndpoint = &target->EndPoint[pPacket->Endpoint]; - /* reset count on each iteration, we are only interested in the last packet's lookahead - * information when we break out of this loop */ - NumLookAheads = 0; - /* process header for each of the recv packets - * note: the lookahead of the last packet is useful for us to continue in this loop */ - status = HTCProcessRecvHeader(target,pPacket,lookAheads,&NumLookAheads); - if (status) { - break; - } - - if (HTC_QUEUE_EMPTY(&syncCompletedPktsQueue)) { - /* last packet's more packets flag is set based on the lookahead */ - SET_MORE_RX_PACKET_INDICATION_FLAG(lookAheads,NumLookAheads,pEndpoint,pPacket); - } else { - /* packets in a bundle automatically have this flag set */ - FORCE_MORE_RX_PACKET_INDICATION_FLAG(pPacket); - } - /* good packet, indicate it */ - HTC_RX_STAT_PROFILE(target,pEndpoint,NumLookAheads); - - if (pPacket->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_PART_OF_BUNDLE) { - INC_HTC_EP_STAT(pEndpoint, RxPacketsBundled, 1); - } - - INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); - DO_RCV_COMPLETION(pEndpoint,&container); - } - - if (status) { - break; - } - - if (NumLookAheads == 0) { - /* no more look aheads */ - break; - } - - /* when we process recv synchronously we need to check if we should yield and stop - * fetching more packets indicated by the embedded lookaheads */ - if (target->Device.DSRCanYield) { - if (DEV_CHECK_RECV_YIELD(&target->Device)) { - /* break out, don't fetch any more packets */ - break; - } - } - - - /* check whether other OS contexts have queued any WMI command/data for WLAN. - * This check is needed only if WLAN Tx and Rx happens in same thread context */ - A_CHECK_DRV_TX(); - - /* for SYNCH processing, if we get here, we are running through the loop again due to a detected lookahead. - * Set flag that we should re-check IRQ status registers again before leaving IRQ processing, - * this can net better performance in high throughput situations */ - REF_IRQ_STATUS_RECHECK(&target->Device); - } - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Failed to get pending recv messages (%d) \n",status)); - /* cleanup any packets we allocated but didn't use to actually fetch any packets */ - while (!HTC_QUEUE_EMPTY(&recvPktQueue)) { - pPacket = HTC_PACKET_DEQUEUE(&recvPktQueue); - /* clean up packets */ - HTC_RECYCLE_RX_PKT(target, pPacket, &target->EndPoint[pPacket->Endpoint]); - } - /* cleanup any packets in sync completion queue */ - while (!HTC_QUEUE_EMPTY(&syncCompletedPktsQueue)) { - pPacket = HTC_PACKET_DEQUEUE(&syncCompletedPktsQueue); - /* clean up packets */ - HTC_RECYCLE_RX_PKT(target, pPacket, &target->EndPoint[pPacket->Endpoint]); - } - if (HTC_STOPPING(target)) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - (" Host is going to stop. blocking receiver for HTCStop.. \n")); - DevStopRecv(&target->Device, asyncProc ? DEV_STOP_RECV_ASYNC : DEV_STOP_RECV_SYNC); - } - } - /* before leaving, check to see if host ran out of buffers and needs to stop the - * receiver */ - if (target->RecvStateFlags & HTC_RECV_WAIT_BUFFERS) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, - (" Host has no RX buffers, blocking receiver to prevent overrun.. \n")); - /* try to stop receive at the device layer */ - DevStopRecv(&target->Device, asyncProc ? DEV_STOP_RECV_ASYNC : DEV_STOP_RECV_SYNC); - } - - if (pNumPktsFetched != NULL) { - *pNumPktsFetched = totalFetched; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCRecvMessagePendingHandler \n")); - - return status; -} - -int HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_endpoint *pEndpoint; - bool unblockRecv = false; - int status = 0; - struct htc_packet *pFirstPacket; - - pFirstPacket = HTC_GET_PKT_AT_HEAD(pPktQueue); - - if (NULL == pFirstPacket) { - A_ASSERT(false); - return A_EINVAL; - } - - AR_DEBUG_ASSERT(pFirstPacket->Endpoint < ENDPOINT_MAX); - - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, - ("+- HTCAddReceivePktMultiple : endPointId: %d, cnt:%d, length: %d\n", - pFirstPacket->Endpoint, - HTC_PACKET_QUEUE_DEPTH(pPktQueue), - pFirstPacket->BufferLength)); - - do { - - pEndpoint = &target->EndPoint[pFirstPacket->Endpoint]; - - LOCK_HTC_RX(target); - - if (HTC_STOPPING(target)) { - struct htc_packet *pPacket; - - UNLOCK_HTC_RX(target); - - /* walk through queue and mark each one canceled */ - HTC_PACKET_QUEUE_ITERATE_ALLOW_REMOVE(pPktQueue,pPacket) { - pPacket->Status = A_ECANCELED; - } HTC_PACKET_QUEUE_ITERATE_END; - - DO_RCV_COMPLETION(pEndpoint,pPktQueue); - break; - } - - /* store receive packets */ - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&pEndpoint->RxBuffers, pPktQueue); - - /* check if we are blocked waiting for a new buffer */ - if (target->RecvStateFlags & HTC_RECV_WAIT_BUFFERS) { - if (target->EpWaitingForBuffers == pFirstPacket->Endpoint) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" receiver was blocked on ep:%d, unblocking.. \n", - target->EpWaitingForBuffers)); - target->RecvStateFlags &= ~HTC_RECV_WAIT_BUFFERS; - target->EpWaitingForBuffers = ENDPOINT_MAX; - unblockRecv = true; - } - } - - UNLOCK_HTC_RX(target); - - if (unblockRecv && !HTC_STOPPING(target)) { - /* TODO : implement a buffer threshold count? */ - DevEnableRecv(&target->Device,DEV_ENABLE_RECV_SYNC); - } - - } while (false); - - return status; -} - -/* Makes a buffer available to the HTC module */ -int HTCAddReceivePkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket) -{ - struct htc_packet_queue queue; - INIT_HTC_PACKET_QUEUE_AND_ADD(&queue,pPacket); - return HTCAddReceivePktMultiple(HTCHandle, &queue); -} - -void HTCUnblockRecv(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - bool unblockRecv = false; - - LOCK_HTC_RX(target); - - /* check if we are blocked waiting for a new buffer */ - if (target->RecvStateFlags & HTC_RECV_WAIT_BUFFERS) { - AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HTCUnblockRx : receiver was blocked on ep:%d, unblocking.. \n", - target->EpWaitingForBuffers)); - target->RecvStateFlags &= ~HTC_RECV_WAIT_BUFFERS; - target->EpWaitingForBuffers = ENDPOINT_MAX; - unblockRecv = true; - } - - UNLOCK_HTC_RX(target); - - if (unblockRecv && !HTC_STOPPING(target)) { - /* re-enable */ - DevEnableRecv(&target->Device,DEV_ENABLE_RECV_ASYNC); - } -} - -static void HTCFlushRxQueue(struct htc_target *target, struct htc_endpoint *pEndpoint, struct htc_packet_queue *pQueue) -{ - struct htc_packet *pPacket; - struct htc_packet_queue container; - - LOCK_HTC_RX(target); - - while (1) { - pPacket = HTC_PACKET_DEQUEUE(pQueue); - if (NULL == pPacket) { - break; - } - UNLOCK_HTC_RX(target); - pPacket->Status = A_ECANCELED; - pPacket->ActualLength = 0; - AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" Flushing RX packet:0x%lX, length:%d, ep:%d \n", - (unsigned long)pPacket, pPacket->BufferLength, pPacket->Endpoint)); - INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); - /* give the packet back */ - DO_RCV_COMPLETION(pEndpoint,&container); - LOCK_HTC_RX(target); - } - - UNLOCK_HTC_RX(target); -} - -static void HTCFlushEndpointRX(struct htc_target *target, struct htc_endpoint *pEndpoint) -{ - /* flush any recv indications not already made */ - HTCFlushRxQueue(target,pEndpoint,&pEndpoint->RecvIndicationQueue); - /* flush any rx buffers */ - HTCFlushRxQueue(target,pEndpoint,&pEndpoint->RxBuffers); -} - -void HTCFlushRecvBuffers(struct htc_target *target) -{ - struct htc_endpoint *pEndpoint; - int i; - - for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { - pEndpoint = &target->EndPoint[i]; - if (pEndpoint->ServiceID == 0) { - /* not in use.. */ - continue; - } - HTCFlushEndpointRX(target,pEndpoint); - } -} - - -void HTCEnableRecv(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - - if (!HTC_STOPPING(target)) { - /* re-enable */ - DevEnableRecv(&target->Device,DEV_ENABLE_RECV_SYNC); - } -} - -void HTCDisableRecv(HTC_HANDLE HTCHandle) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - - if (!HTC_STOPPING(target)) { - /* disable */ - DevStopRecv(&target->Device,DEV_ENABLE_RECV_SYNC); - } -} - -int HTCGetNumRecvBuffers(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - return HTC_PACKET_QUEUE_DEPTH(&(target->EndPoint[Endpoint].RxBuffers)); -} - -int HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, - u32 TimeoutInMs, - bool *pbIsRecvPending) -{ - int status = 0; - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - - status = DevWaitForPendingRecv(&target->Device, - TimeoutInMs, - pbIsRecvPending); - - return status; -} diff --git a/drivers/staging/ath6kl/htc2/htc_send.c b/drivers/staging/ath6kl/htc2/htc_send.c deleted file mode 100644 index 9310d4d5c99..00000000000 --- a/drivers/staging/ath6kl/htc2/htc_send.c +++ /dev/null @@ -1,1018 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#include "htc_internal.h" - -typedef enum _HTC_SEND_QUEUE_RESULT { - HTC_SEND_QUEUE_OK = 0, /* packet was queued */ - HTC_SEND_QUEUE_DROP = 1, /* this packet should be dropped */ -} HTC_SEND_QUEUE_RESULT; - -#define DO_EP_TX_COMPLETION(ep,q) DoSendCompletion(ep,q) - -/* call the distribute credits callback with the distribution */ -#define DO_DISTRIBUTION(t,reason,description,pList) \ -{ \ - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, \ - (" calling distribute function (%s) (dfn:0x%lX, ctxt:0x%lX, dist:0x%lX) \n", \ - (description), \ - (unsigned long)(t)->DistributeCredits, \ - (unsigned long)(t)->pCredDistContext, \ - (unsigned long)pList)); \ - (t)->DistributeCredits((t)->pCredDistContext, \ - (pList), \ - (reason)); \ -} - -static void DoSendCompletion(struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pQueueToIndicate) -{ - do { - - if (HTC_QUEUE_EMPTY(pQueueToIndicate)) { - /* nothing to indicate */ - break; - } - - if (pEndpoint->EpCallBacks.EpTxCompleteMultiple != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" HTC calling ep %d, send complete multiple callback (%d pkts) \n", - pEndpoint->Id, HTC_PACKET_QUEUE_DEPTH(pQueueToIndicate))); - /* a multiple send complete handler is being used, pass the queue to the handler */ - pEndpoint->EpCallBacks.EpTxCompleteMultiple(pEndpoint->EpCallBacks.pContext, - pQueueToIndicate); - /* all packets are now owned by the callback, reset queue to be safe */ - INIT_HTC_PACKET_QUEUE(pQueueToIndicate); - } else { - struct htc_packet *pPacket; - /* using legacy EpTxComplete */ - do { - pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" HTC calling ep %d send complete callback on packet 0x%lX \n", \ - pEndpoint->Id, (unsigned long)(pPacket))); - pEndpoint->EpCallBacks.EpTxComplete(pEndpoint->EpCallBacks.pContext, pPacket); - } while (!HTC_QUEUE_EMPTY(pQueueToIndicate)); - } - - } while (false); - -} - -/* do final completion on sent packet */ -static INLINE void CompleteSentPacket(struct htc_target *target, struct htc_endpoint *pEndpoint, struct htc_packet *pPacket) -{ - pPacket->Completion = NULL; - - if (pPacket->Status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("CompleteSentPacket: request failed (status:%d, ep:%d, length:%d creds:%d) \n", - pPacket->Status, pPacket->Endpoint, pPacket->ActualLength, pPacket->PktInfo.AsTx.CreditsUsed)); - /* on failure to submit, reclaim credits for this packet */ - LOCK_HTC_TX(target); - pEndpoint->CreditDist.TxCreditsToDist += pPacket->PktInfo.AsTx.CreditsUsed; - pEndpoint->CreditDist.TxQueueDepth = HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue); - DO_DISTRIBUTION(target, - HTC_CREDIT_DIST_SEND_COMPLETE, - "Send Complete", - target->EpCreditDistributionListHead->pNext); - UNLOCK_HTC_TX(target); - } - /* first, fixup the head room we allocated */ - pPacket->pBuffer += HTC_HDR_LENGTH; -} - -/* our internal send packet completion handler when packets are submited to the AR6K device - * layer */ -static void HTCSendPktCompletionHandler(void *Context, struct htc_packet *pPacket) -{ - struct htc_target *target = (struct htc_target *)Context; - struct htc_endpoint *pEndpoint = &target->EndPoint[pPacket->Endpoint]; - struct htc_packet_queue container; - - CompleteSentPacket(target,pEndpoint,pPacket); - INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); - /* do completion */ - DO_EP_TX_COMPLETION(pEndpoint,&container); -} - -int HTCIssueSend(struct htc_target *target, struct htc_packet *pPacket) -{ - int status; - bool sync = false; - - if (pPacket->Completion == NULL) { - /* mark that this request was synchronously issued */ - sync = true; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - ("+-HTCIssueSend: transmit length : %d (%s) \n", - pPacket->ActualLength + (u32)HTC_HDR_LENGTH, - sync ? "SYNC" : "ASYNC" )); - - /* send message to device */ - status = DevSendPacket(&target->Device, - pPacket, - pPacket->ActualLength + HTC_HDR_LENGTH); - - if (sync) { - /* use local sync variable. If this was issued asynchronously, pPacket is no longer - * safe to access. */ - pPacket->pBuffer += HTC_HDR_LENGTH; - } - - /* if this request was asynchronous, the packet completion routine will be invoked by - * the device layer when the HIF layer completes the request */ - - return status; -} - - /* get HTC send packets from the TX queue on an endpoint */ -static INLINE void GetHTCSendPackets(struct htc_target *target, - struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pQueue) -{ - int creditsRequired; - int remainder; - u8 sendFlags; - struct htc_packet *pPacket; - unsigned int transferLength; - - /****** NOTE : the TX lock is held when this function is called *****************/ - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+GetHTCSendPackets \n")); - - /* loop until we can grab as many packets out of the queue as we can */ - while (true) { - - sendFlags = 0; - /* get packet at head, but don't remove it */ - pPacket = HTC_GET_PKT_AT_HEAD(&pEndpoint->TxQueue); - if (pPacket == NULL) { - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Got head packet:0x%lX , Queue Depth: %d\n", - (unsigned long)pPacket, HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue))); - - transferLength = DEV_CALC_SEND_PADDED_LEN(&target->Device, pPacket->ActualLength + HTC_HDR_LENGTH); - - if (transferLength <= target->TargetCreditSize) { - creditsRequired = 1; - } else { - /* figure out how many credits this message requires */ - creditsRequired = transferLength / target->TargetCreditSize; - remainder = transferLength % target->TargetCreditSize; - - if (remainder) { - creditsRequired++; - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Creds Required:%d Got:%d\n", - creditsRequired, pEndpoint->CreditDist.TxCredits)); - - if (pEndpoint->CreditDist.TxCredits < creditsRequired) { - - /* not enough credits */ - if (pPacket->Endpoint == ENDPOINT_0) { - /* leave it in the queue */ - break; - } - /* invoke the registered distribution function only if this is not - * endpoint 0, we let the driver layer provide more credits if it can. - * We pass the credit distribution list starting at the endpoint in question - * */ - - /* set how many credits we need */ - pEndpoint->CreditDist.TxCreditsSeek = - creditsRequired - pEndpoint->CreditDist.TxCredits; - DO_DISTRIBUTION(target, - HTC_CREDIT_DIST_SEEK_CREDITS, - "Seek Credits", - &pEndpoint->CreditDist); - pEndpoint->CreditDist.TxCreditsSeek = 0; - - if (pEndpoint->CreditDist.TxCredits < creditsRequired) { - /* still not enough credits to send, leave packet in the queue */ - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - (" Not enough credits for ep %d leaving packet in queue..\n", - pPacket->Endpoint)); - break; - } - - } - - pEndpoint->CreditDist.TxCredits -= creditsRequired; - INC_HTC_EP_STAT(pEndpoint, TxCreditsConsummed, creditsRequired); - - /* check if we need credits back from the target */ - if (pEndpoint->CreditDist.TxCredits < pEndpoint->CreditDist.TxCreditsPerMaxMsg) { - /* we are getting low on credits, see if we can ask for more from the distribution function */ - pEndpoint->CreditDist.TxCreditsSeek = - pEndpoint->CreditDist.TxCreditsPerMaxMsg - pEndpoint->CreditDist.TxCredits; - - DO_DISTRIBUTION(target, - HTC_CREDIT_DIST_SEEK_CREDITS, - "Seek Credits", - &pEndpoint->CreditDist); - - pEndpoint->CreditDist.TxCreditsSeek = 0; - /* see if we were successful in getting more */ - if (pEndpoint->CreditDist.TxCredits < pEndpoint->CreditDist.TxCreditsPerMaxMsg) { - /* tell the target we need credits ASAP! */ - sendFlags |= HTC_FLAGS_NEED_CREDIT_UPDATE; - INC_HTC_EP_STAT(pEndpoint, TxCreditLowIndications, 1); - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Host Needs Credits \n")); - } - } - - /* now we can fully dequeue */ - pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->TxQueue); - /* save the number of credits this packet consumed */ - pPacket->PktInfo.AsTx.CreditsUsed = creditsRequired; - /* all TX packets are handled asynchronously */ - pPacket->Completion = HTCSendPktCompletionHandler; - pPacket->pContext = target; - INC_HTC_EP_STAT(pEndpoint, TxIssued, 1); - /* save send flags */ - pPacket->PktInfo.AsTx.SendFlags = sendFlags; - pPacket->PktInfo.AsTx.SeqNo = pEndpoint->SeqNo; - pEndpoint->SeqNo++; - /* queue this packet into the caller's queue */ - HTC_PACKET_ENQUEUE(pQueue,pPacket); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-GetHTCSendPackets \n")); - -} - -static void HTCAsyncSendScatterCompletion(struct hif_scatter_req *pScatterReq) -{ - int i; - struct htc_packet *pPacket; - struct htc_endpoint *pEndpoint = (struct htc_endpoint *)pScatterReq->Context; - struct htc_target *target = (struct htc_target *)pEndpoint->target; - int status = 0; - struct htc_packet_queue sendCompletes; - - INIT_HTC_PACKET_QUEUE(&sendCompletes); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HTCAsyncSendScatterCompletion TotLen: %d Entries: %d\n", - pScatterReq->TotalLength, pScatterReq->ValidScatterEntries)); - - DEV_FINISH_SCATTER_OPERATION(pScatterReq); - - if (pScatterReq->CompletionStatus) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** Send Scatter Request Failed: %d \n",pScatterReq->CompletionStatus)); - status = A_ERROR; - } - - /* walk through the scatter list and process */ - for (i = 0; i < pScatterReq->ValidScatterEntries; i++) { - pPacket = (struct htc_packet *)(pScatterReq->ScatterList[i].pCallerContexts[0]); - A_ASSERT(pPacket != NULL); - pPacket->Status = status; - CompleteSentPacket(target,pEndpoint,pPacket); - /* add it to the completion queue */ - HTC_PACKET_ENQUEUE(&sendCompletes, pPacket); - } - - /* free scatter request */ - DEV_FREE_SCATTER_REQ(&target->Device,pScatterReq); - /* complete all packets */ - DO_EP_TX_COMPLETION(pEndpoint,&sendCompletes); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCAsyncSendScatterCompletion \n")); -} - - /* drain a queue and send as bundles - * this function may return without fully draining the queue under the following conditions : - * - scatter resources are exhausted - * - a message that will consume a partial credit will stop the bundling process early - * - we drop below the minimum number of messages for a bundle - * */ -static void HTCIssueSendBundle(struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pQueue, - int *pBundlesSent, - int *pTotalBundlesPkts) -{ - int pktsToScatter; - unsigned int scatterSpaceRemaining; - struct hif_scatter_req *pScatterReq = NULL; - int i, packetsInScatterReq; - unsigned int transferLength; - struct htc_packet *pPacket; - bool done = false; - int bundlesSent = 0; - int totalPktsInBundle = 0; - struct htc_target *target = pEndpoint->target; - int creditRemainder = 0; - int creditPad; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HTCIssueSendBundle \n")); - - while (!done) { - - pktsToScatter = HTC_PACKET_QUEUE_DEPTH(pQueue); - pktsToScatter = min(pktsToScatter, target->MaxMsgPerBundle); - - if (pktsToScatter < HTC_MIN_HTC_MSGS_TO_BUNDLE) { - /* not enough to bundle */ - break; - } - - pScatterReq = DEV_ALLOC_SCATTER_REQ(&target->Device); - - if (pScatterReq == NULL) { - /* no scatter resources */ - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" No more scatter resources \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" pkts to scatter: %d \n", pktsToScatter)); - - pScatterReq->TotalLength = 0; - pScatterReq->ValidScatterEntries = 0; - - packetsInScatterReq = 0; - scatterSpaceRemaining = DEV_GET_MAX_BUNDLE_SEND_LENGTH(&target->Device); - - for (i = 0; i < pktsToScatter; i++) { - - pScatterReq->ScatterList[i].pCallerContexts[0] = NULL; - - pPacket = HTC_GET_PKT_AT_HEAD(pQueue); - if (pPacket == NULL) { - A_ASSERT(false); - break; - } - - creditPad = 0; - transferLength = DEV_CALC_SEND_PADDED_LEN(&target->Device, - pPacket->ActualLength + HTC_HDR_LENGTH); - /* see if the padded transfer length falls on a credit boundary */ - creditRemainder = transferLength % target->TargetCreditSize; - - if (creditRemainder != 0) { - /* the transfer consumes a "partial" credit, this packet cannot be bundled unless - * we add additional "dummy" padding (max 255 bytes) to consume the entire credit - *** NOTE: only allow the send padding if the endpoint is allowed to */ - if (pEndpoint->LocalConnectionFlags & HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING) { - if (transferLength < target->TargetCreditSize) { - /* special case where the transfer is less than a credit */ - creditPad = target->TargetCreditSize - transferLength; - } else { - creditPad = creditRemainder; - } - - /* now check to see if we can indicate padding in the HTC header */ - if ((creditPad > 0) && (creditPad <= 255)) { - /* adjust the transferlength of this packet with the new credit padding */ - transferLength += creditPad; - } else { - /* the amount to pad is too large, bail on this packet, we have to - * send it using the non-bundled method */ - pPacket = NULL; - } - } else { - /* bail on this packet, user does not want padding applied */ - pPacket = NULL; - } - } - - if (NULL == pPacket) { - /* can't bundle */ - done = true; - break; - } - - if (scatterSpaceRemaining < transferLength) { - /* exceeds what we can transfer */ - break; - } - - scatterSpaceRemaining -= transferLength; - /* now remove it from the queue */ - pPacket = HTC_PACKET_DEQUEUE(pQueue); - /* save it in the scatter list */ - pScatterReq->ScatterList[i].pCallerContexts[0] = pPacket; - /* prepare packet and flag message as part of a send bundle */ - HTC_PREPARE_SEND_PKT(pPacket, - pPacket->PktInfo.AsTx.SendFlags | HTC_FLAGS_SEND_BUNDLE, - creditPad, - pPacket->PktInfo.AsTx.SeqNo); - pScatterReq->ScatterList[i].pBuffer = pPacket->pBuffer; - pScatterReq->ScatterList[i].Length = transferLength; - A_ASSERT(transferLength); - pScatterReq->TotalLength += transferLength; - pScatterReq->ValidScatterEntries++; - packetsInScatterReq++; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" %d, Adding packet : 0x%lX, len:%d (remaining space:%d) \n", - i, (unsigned long)pPacket,transferLength,scatterSpaceRemaining)); - } - - if (packetsInScatterReq >= HTC_MIN_HTC_MSGS_TO_BUNDLE) { - /* send path is always asynchronous */ - pScatterReq->CompletionRoutine = HTCAsyncSendScatterCompletion; - pScatterReq->Context = pEndpoint; - bundlesSent++; - totalPktsInBundle += packetsInScatterReq; - packetsInScatterReq = 0; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Send Scatter total bytes: %d , entries: %d\n", - pScatterReq->TotalLength,pScatterReq->ValidScatterEntries)); - DevSubmitScatterRequest(&target->Device, pScatterReq, DEV_SCATTER_WRITE, DEV_SCATTER_ASYNC); - /* we don't own this anymore */ - pScatterReq = NULL; - /* try to send some more */ - continue; - } - - /* not enough packets to use the scatter request, cleanup */ - if (pScatterReq != NULL) { - if (packetsInScatterReq > 0) { - /* work backwards to requeue requests */ - for (i = (packetsInScatterReq - 1); i >= 0; i--) { - pPacket = (struct htc_packet *)(pScatterReq->ScatterList[i].pCallerContexts[0]); - if (pPacket != NULL) { - /* undo any prep */ - HTC_UNPREPARE_SEND_PKT(pPacket); - /* queue back to the head */ - HTC_PACKET_ENQUEUE_TO_HEAD(pQueue,pPacket); - } - } - } - DEV_FREE_SCATTER_REQ(&target->Device,pScatterReq); - } - - /* if we get here, we sent all that we could, get out */ - break; - - } - - *pBundlesSent = bundlesSent; - *pTotalBundlesPkts = totalPktsInBundle; - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCIssueSendBundle (sent:%d) \n",bundlesSent)); - - return; -} - -/* - * if there are no credits, the packet(s) remains in the queue. - * this function returns the result of the attempt to send a queue of HTC packets */ -static HTC_SEND_QUEUE_RESULT HTCTrySend(struct htc_target *target, - struct htc_endpoint *pEndpoint, - struct htc_packet_queue *pCallersSendQueue) -{ - struct htc_packet_queue sendQueue; /* temp queue to hold packets at various stages */ - struct htc_packet *pPacket; - int bundlesSent; - int pktsInBundles; - int overflow; - HTC_SEND_QUEUE_RESULT result = HTC_SEND_QUEUE_OK; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HTCTrySend (Queue:0x%lX Depth:%d)\n", - (unsigned long)pCallersSendQueue, - (pCallersSendQueue == NULL) ? 0 : HTC_PACKET_QUEUE_DEPTH(pCallersSendQueue))); - - /* init the local send queue */ - INIT_HTC_PACKET_QUEUE(&sendQueue); - - do { - - if (NULL == pCallersSendQueue) { - /* caller didn't provide a queue, just wants us to check queues and send */ - break; - } - - if (HTC_QUEUE_EMPTY(pCallersSendQueue)) { - /* empty queue */ - result = HTC_SEND_QUEUE_DROP; - break; - } - - if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) >= pEndpoint->MaxTxQueueDepth) { - /* we've already overflowed */ - overflow = HTC_PACKET_QUEUE_DEPTH(pCallersSendQueue); - } else { - /* figure out how much we will overflow by */ - overflow = HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue); - overflow += HTC_PACKET_QUEUE_DEPTH(pCallersSendQueue); - /* figure out how much we will overflow the TX queue by */ - overflow -= pEndpoint->MaxTxQueueDepth; - } - - /* if overflow is negative or zero, we are okay */ - if (overflow > 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - (" Endpoint %d, TX queue will overflow :%d , Tx Depth:%d, Max:%d \n", - pEndpoint->Id, overflow, HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue), pEndpoint->MaxTxQueueDepth)); - } - if ((overflow <= 0) || (pEndpoint->EpCallBacks.EpSendFull == NULL)) { - /* all packets will fit or caller did not provide send full indication handler - * -- just move all of them to the local sendQueue object */ - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&sendQueue, pCallersSendQueue); - } else { - int i; - int goodPkts = HTC_PACKET_QUEUE_DEPTH(pCallersSendQueue) - overflow; - - A_ASSERT(goodPkts >= 0); - /* we have overflowed, and a callback is provided */ - /* dequeue all non-overflow packets into the sendqueue */ - for (i = 0; i < goodPkts; i++) { - /* pop off caller's queue*/ - pPacket = HTC_PACKET_DEQUEUE(pCallersSendQueue); - A_ASSERT(pPacket != NULL); - /* insert into local queue */ - HTC_PACKET_ENQUEUE(&sendQueue,pPacket); - } - - /* the caller's queue has all the packets that won't fit*/ - /* walk through the caller's queue and indicate each one to the send full handler */ - ITERATE_OVER_LIST_ALLOW_REMOVE(&pCallersSendQueue->QueueHead, pPacket, struct htc_packet, ListLink) { - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Indicating overflowed TX packet: 0x%lX \n", - (unsigned long)pPacket)); - if (pEndpoint->EpCallBacks.EpSendFull(pEndpoint->EpCallBacks.pContext, - pPacket) == HTC_SEND_FULL_DROP) { - /* callback wants the packet dropped */ - INC_HTC_EP_STAT(pEndpoint, TxDropped, 1); - /* leave this one in the caller's queue for cleanup */ - } else { - /* callback wants to keep this packet, remove from caller's queue */ - HTC_PACKET_REMOVE(pCallersSendQueue, pPacket); - /* put it in the send queue */ - HTC_PACKET_ENQUEUE(&sendQueue,pPacket); - } - - } ITERATE_END; - - if (HTC_QUEUE_EMPTY(&sendQueue)) { - /* no packets made it in, caller will cleanup */ - result = HTC_SEND_QUEUE_DROP; - break; - } - } - - } while (false); - - if (result != HTC_SEND_QUEUE_OK) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend: \n")); - return result; - } - - LOCK_HTC_TX(target); - - if (!HTC_QUEUE_EMPTY(&sendQueue)) { - /* transfer packets */ - HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&pEndpoint->TxQueue,&sendQueue); - A_ASSERT(HTC_QUEUE_EMPTY(&sendQueue)); - INIT_HTC_PACKET_QUEUE(&sendQueue); - } - - /* increment tx processing count on entry */ - pEndpoint->TxProcessCount++; - if (pEndpoint->TxProcessCount > 1) { - /* another thread or task is draining the TX queues on this endpoint - * that thread will reset the tx processing count when the queue is drained */ - pEndpoint->TxProcessCount--; - UNLOCK_HTC_TX(target); - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend (busy) \n")); - return HTC_SEND_QUEUE_OK; - } - - /***** beyond this point only 1 thread may enter ******/ - - /* now drain the endpoint TX queue for transmission as long as we have enough - * credits */ - while (true) { - - if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) == 0) { - break; - } - - /* get all the packets for this endpoint that we can for this pass */ - GetHTCSendPackets(target, pEndpoint, &sendQueue); - - if (HTC_PACKET_QUEUE_DEPTH(&sendQueue) == 0) { - /* didn't get any packets due to a lack of credits */ - break; - } - - UNLOCK_HTC_TX(target); - - /* any packets to send are now in our local send queue */ - - bundlesSent = 0; - pktsInBundles = 0; - - while (true) { - - /* try to send a bundle on each pass */ - if ((target->SendBundlingEnabled) && - (HTC_PACKET_QUEUE_DEPTH(&sendQueue) >= HTC_MIN_HTC_MSGS_TO_BUNDLE)) { - int temp1,temp2; - /* bundling is enabled and there is at least a minimum number of packets in the send queue - * send what we can in this pass */ - HTCIssueSendBundle(pEndpoint, &sendQueue, &temp1, &temp2); - bundlesSent += temp1; - pktsInBundles += temp2; - } - - /* if not bundling or there was a packet that could not be placed in a bundle, pull it out - * and send it the normal way */ - pPacket = HTC_PACKET_DEQUEUE(&sendQueue); - if (NULL == pPacket) { - /* local queue is fully drained */ - break; - } - HTC_PREPARE_SEND_PKT(pPacket, - pPacket->PktInfo.AsTx.SendFlags, - 0, - pPacket->PktInfo.AsTx.SeqNo); - HTCIssueSend(target, pPacket); - - /* go back and see if we can bundle some more */ - } - - LOCK_HTC_TX(target); - - INC_HTC_EP_STAT(pEndpoint, TxBundles, bundlesSent); - INC_HTC_EP_STAT(pEndpoint, TxPacketsBundled, pktsInBundles); - - } - - /* done with this endpoint, we can clear the count */ - pEndpoint->TxProcessCount = 0; - UNLOCK_HTC_TX(target); - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend: \n")); - - return HTC_SEND_QUEUE_OK; -} - -int HTCSendPktsMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_endpoint *pEndpoint; - struct htc_packet *pPacket; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCSendPktsMultiple: Queue: 0x%lX, Pkts %d \n", - (unsigned long)pPktQueue, HTC_PACKET_QUEUE_DEPTH(pPktQueue))); - - /* get packet at head to figure out which endpoint these packets will go into */ - pPacket = HTC_GET_PKT_AT_HEAD(pPktQueue); - if (NULL == pPacket) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCSendPktsMultiple \n")); - return A_EINVAL; - } - - AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX); - pEndpoint = &target->EndPoint[pPacket->Endpoint]; - - HTCTrySend(target, pEndpoint, pPktQueue); - - /* do completion on any packets that couldn't get in */ - if (!HTC_QUEUE_EMPTY(pPktQueue)) { - - HTC_PACKET_QUEUE_ITERATE_ALLOW_REMOVE(pPktQueue,pPacket) { - if (HTC_STOPPING(target)) { - pPacket->Status = A_ECANCELED; - } else { - pPacket->Status = A_NO_RESOURCE; - } - } HTC_PACKET_QUEUE_ITERATE_END; - - DO_EP_TX_COMPLETION(pEndpoint,pPktQueue); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCSendPktsMultiple \n")); - - return 0; -} - -/* HTC API - HTCSendPkt */ -int HTCSendPkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket) -{ - struct htc_packet_queue queue; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, - ("+-HTCSendPkt: Enter endPointId: %d, buffer: 0x%lX, length: %d \n", - pPacket->Endpoint, (unsigned long)pPacket->pBuffer, pPacket->ActualLength)); - INIT_HTC_PACKET_QUEUE_AND_ADD(&queue,pPacket); - return HTCSendPktsMultiple(HTCHandle, &queue); -} - -/* check TX queues to drain because of credit distribution update */ -static INLINE void HTCCheckEndpointTxQueues(struct htc_target *target) -{ - struct htc_endpoint *pEndpoint; - struct htc_endpoint_credit_dist *pDistItem; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCCheckEndpointTxQueues \n")); - pDistItem = target->EpCreditDistributionListHead; - - /* run through the credit distribution list to see - * if there are packets queued - * NOTE: no locks need to be taken since the distribution list - * is not dynamic (cannot be re-ordered) and we are not modifying any state */ - while (pDistItem != NULL) { - pEndpoint = (struct htc_endpoint *)pDistItem->pHTCReserved; - - if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) > 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Ep %d has %d credits and %d Packets in TX Queue \n", - pDistItem->Endpoint, pEndpoint->CreditDist.TxCredits, HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue))); - /* try to start the stalled queue, this list is ordered by priority. - * Highest priority queue get's processed first, if there are credits available the - * highest priority queue will get a chance to reclaim credits from lower priority - * ones */ - HTCTrySend(target, pEndpoint, NULL); - } - - pDistItem = pDistItem->pNext; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCCheckEndpointTxQueues \n")); -} - -/* process credit reports and call distribution function */ -void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint) -{ - int i; - struct htc_endpoint *pEndpoint; - int totalCredits = 0; - bool doDist = false; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCProcessCreditRpt, Credit Report Entries:%d \n", NumEntries)); - - /* lock out TX while we update credits */ - LOCK_HTC_TX(target); - - for (i = 0; i < NumEntries; i++, pRpt++) { - if (pRpt->EndpointID >= ENDPOINT_MAX) { - AR_DEBUG_ASSERT(false); - break; - } - - pEndpoint = &target->EndPoint[pRpt->EndpointID]; - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Endpoint %d got %d credits \n", - pRpt->EndpointID, pRpt->Credits)); - - INC_HTC_EP_STAT(pEndpoint, TxCreditRpts, 1); - INC_HTC_EP_STAT(pEndpoint, TxCreditsReturned, pRpt->Credits); - - if (FromEndpoint == pRpt->EndpointID) { - /* this credit report arrived on the same endpoint indicating it arrived in an RX - * packet */ - INC_HTC_EP_STAT(pEndpoint, TxCreditsFromRx, pRpt->Credits); - INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromRx, 1); - } else if (FromEndpoint == ENDPOINT_0) { - /* this credit arrived on endpoint 0 as a NULL message */ - INC_HTC_EP_STAT(pEndpoint, TxCreditsFromEp0, pRpt->Credits); - INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromEp0, 1); - } else { - /* arrived on another endpoint */ - INC_HTC_EP_STAT(pEndpoint, TxCreditsFromOther, pRpt->Credits); - INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromOther, 1); - } - - if (ENDPOINT_0 == pRpt->EndpointID) { - /* always give endpoint 0 credits back */ - pEndpoint->CreditDist.TxCredits += pRpt->Credits; - } else { - /* for all other endpoints, update credits to distribute, the distribution function - * will handle giving out credits back to the endpoints */ - pEndpoint->CreditDist.TxCreditsToDist += pRpt->Credits; - /* flag that we have to do the distribution */ - doDist = true; - } - - /* refresh tx depth for distribution function that will recover these credits - * NOTE: this is only valid when there are credits to recover! */ - pEndpoint->CreditDist.TxQueueDepth = HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue); - - totalCredits += pRpt->Credits; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Report indicated %d credits to distribute \n", totalCredits)); - - if (doDist) { - /* this was a credit return based on a completed send operations - * note, this is done with the lock held */ - DO_DISTRIBUTION(target, - HTC_CREDIT_DIST_SEND_COMPLETE, - "Send Complete", - target->EpCreditDistributionListHead->pNext); - } - - UNLOCK_HTC_TX(target); - - if (totalCredits) { - HTCCheckEndpointTxQueues(target); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCProcessCreditRpt \n")); -} - -/* flush endpoint TX queue */ -static void HTCFlushEndpointTX(struct htc_target *target, struct htc_endpoint *pEndpoint, HTC_TX_TAG Tag) -{ - struct htc_packet *pPacket; - struct htc_packet_queue discardQueue; - struct htc_packet_queue container; - - /* initialize the discard queue */ - INIT_HTC_PACKET_QUEUE(&discardQueue); - - LOCK_HTC_TX(target); - - /* interate from the front of the TX queue and flush out packets */ - ITERATE_OVER_LIST_ALLOW_REMOVE(&pEndpoint->TxQueue.QueueHead, pPacket, struct htc_packet, ListLink) { - - /* check for removal */ - if ((HTC_TX_PACKET_TAG_ALL == Tag) || (Tag == pPacket->PktInfo.AsTx.Tag)) { - /* remove from queue */ - HTC_PACKET_REMOVE(&pEndpoint->TxQueue, pPacket); - /* add it to the discard pile */ - HTC_PACKET_ENQUEUE(&discardQueue, pPacket); - } - - } ITERATE_END; - - UNLOCK_HTC_TX(target); - - /* empty the discard queue */ - while (1) { - pPacket = HTC_PACKET_DEQUEUE(&discardQueue); - if (NULL == pPacket) { - break; - } - pPacket->Status = A_ECANCELED; - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" Flushing TX packet:0x%lX, length:%d, ep:%d tag:0x%X \n", - (unsigned long)pPacket, pPacket->ActualLength, pPacket->Endpoint, pPacket->PktInfo.AsTx.Tag)); - INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); - DO_EP_TX_COMPLETION(pEndpoint,&container); - } - -} - -void DumpCreditDist(struct htc_endpoint_credit_dist *pEPDist) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("--- EP : %d ServiceID: 0x%X --------------\n", - pEPDist->Endpoint, pEPDist->ServiceID)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" this:0x%lX next:0x%lX prev:0x%lX\n", - (unsigned long)pEPDist, (unsigned long)pEPDist->pNext, (unsigned long)pEPDist->pPrev)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" DistFlags : 0x%X \n", pEPDist->DistFlags)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsNorm : %d \n", pEPDist->TxCreditsNorm)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsMin : %d \n", pEPDist->TxCreditsMin)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCredits : %d \n", pEPDist->TxCredits)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsAssigned : %d \n", pEPDist->TxCreditsAssigned)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsSeek : %d \n", pEPDist->TxCreditsSeek)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditSize : %d \n", pEPDist->TxCreditSize)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsPerMaxMsg : %d \n", pEPDist->TxCreditsPerMaxMsg)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsToDist : %d \n", pEPDist->TxCreditsToDist)); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxQueueDepth : %d \n", - HTC_PACKET_QUEUE_DEPTH(&((struct htc_endpoint *)pEPDist->pHTCReserved)->TxQueue))); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("----------------------------------------------------\n")); -} - -void DumpCreditDistStates(struct htc_target *target) -{ - struct htc_endpoint_credit_dist *pEPList = target->EpCreditDistributionListHead; - - while (pEPList != NULL) { - DumpCreditDist(pEPList); - pEPList = pEPList->pNext; - } - - if (target->DistributeCredits != NULL) { - DO_DISTRIBUTION(target, - HTC_DUMP_CREDIT_STATE, - "Dump State", - NULL); - } -} - -/* flush all send packets from all endpoint queues */ -void HTCFlushSendPkts(struct htc_target *target) -{ - struct htc_endpoint *pEndpoint; - int i; - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) { - DumpCreditDistStates(target); - } - - for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { - pEndpoint = &target->EndPoint[i]; - if (pEndpoint->ServiceID == 0) { - /* not in use.. */ - continue; - } - HTCFlushEndpointTX(target,pEndpoint,HTC_TX_PACKET_TAG_ALL); - } - - -} - -/* HTC API to flush an endpoint's TX queue*/ -void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; - - if (pEndpoint->ServiceID == 0) { - AR_DEBUG_ASSERT(false); - /* not in use.. */ - return; - } - - HTCFlushEndpointTX(target, pEndpoint, Tag); -} - -/* HTC API to indicate activity to the credit distribution function */ -void HTCIndicateActivityChange(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint, - bool Active) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; - bool doDist = false; - - if (pEndpoint->ServiceID == 0) { - AR_DEBUG_ASSERT(false); - /* not in use.. */ - return; - } - - LOCK_HTC_TX(target); - - if (Active) { - if (!(pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE)) { - /* mark active now */ - pEndpoint->CreditDist.DistFlags |= HTC_EP_ACTIVE; - doDist = true; - } - } else { - if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) { - /* mark inactive now */ - pEndpoint->CreditDist.DistFlags &= ~HTC_EP_ACTIVE; - doDist = true; - } - } - - if (doDist) { - /* indicate current Tx Queue depth to the credit distribution function */ - pEndpoint->CreditDist.TxQueueDepth = HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue); - /* do distribution again based on activity change - * note, this is done with the lock held */ - DO_DISTRIBUTION(target, - HTC_CREDIT_DIST_ACTIVITY_CHANGE, - "Activity Change", - target->EpCreditDistributionListHead->pNext); - } - - UNLOCK_HTC_TX(target); - - if (doDist && !Active) { - /* if a stream went inactive and this resulted in a credit distribution change, - * some credits may now be available for HTC packets that are stuck in - * HTC queues */ - HTCCheckEndpointTxQueues(target); - } -} - -bool HTCIsEndpointActive(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; - - if (pEndpoint->ServiceID == 0) { - return false; - } - - if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) { - return true; - } - - return false; -} diff --git a/drivers/staging/ath6kl/htc2/htc_services.c b/drivers/staging/ath6kl/htc2/htc_services.c deleted file mode 100644 index c48070cbd54..00000000000 --- a/drivers/staging/ath6kl/htc2/htc_services.c +++ /dev/null @@ -1,450 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#include "htc_internal.h" - -void HTCControlTxComplete(void *Context, struct htc_packet *pPacket) -{ - /* not implemented - * we do not send control TX frames during normal runtime, only during setup */ - AR_DEBUG_ASSERT(false); -} - - /* callback when a control message arrives on this endpoint */ -void HTCControlRecv(void *Context, struct htc_packet *pPacket) -{ - AR_DEBUG_ASSERT(pPacket->Endpoint == ENDPOINT_0); - - if (pPacket->Status == A_ECANCELED) { - /* this is a flush operation, return the control packet back to the pool */ - HTC_FREE_CONTROL_RX((struct htc_target*)Context,pPacket); - return; - } - - /* the only control messages we are expecting are NULL messages (credit resports) */ - if (pPacket->ActualLength > 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("HTCControlRecv, got message with length:%d \n", - pPacket->ActualLength + (u32)HTC_HDR_LENGTH)); - -#ifdef ATH_DEBUG_MODULE - /* dump header and message */ - DebugDumpBytes(pPacket->pBuffer - HTC_HDR_LENGTH, - pPacket->ActualLength + HTC_HDR_LENGTH, - "Unexpected ENDPOINT 0 Message"); -#endif - } - - HTC_RECYCLE_RX_PKT((struct htc_target*)Context,pPacket,&((struct htc_target*)Context)->EndPoint[0]); -} - -int HTCSendSetupComplete(struct htc_target *target) -{ - struct htc_packet *pSendPacket = NULL; - int status; - - do { - /* allocate a packet to send to the target */ - pSendPacket = HTC_ALLOC_CONTROL_TX(target); - - if (NULL == pSendPacket) { - status = A_NO_MEMORY; - break; - } - - if (target->HTCTargetVersion >= HTC_VERSION_2P1) { - HTC_SETUP_COMPLETE_EX_MSG *pSetupCompleteEx; - u32 setupFlags = 0; - - pSetupCompleteEx = (HTC_SETUP_COMPLETE_EX_MSG *)pSendPacket->pBuffer; - A_MEMZERO(pSetupCompleteEx, sizeof(HTC_SETUP_COMPLETE_EX_MSG)); - pSetupCompleteEx->MessageID = HTC_MSG_SETUP_COMPLETE_EX_ID; - if (target->MaxMsgPerBundle > 0) { - /* host can do HTC bundling, indicate this to the target */ - setupFlags |= HTC_SETUP_COMPLETE_FLAGS_ENABLE_BUNDLE_RECV; - pSetupCompleteEx->MaxMsgsPerBundledRecv = target->MaxMsgPerBundle; - } - memcpy(&pSetupCompleteEx->SetupFlags, &setupFlags, sizeof(pSetupCompleteEx->SetupFlags)); - SET_HTC_PACKET_INFO_TX(pSendPacket, - NULL, - (u8 *)pSetupCompleteEx, - sizeof(HTC_SETUP_COMPLETE_EX_MSG), - ENDPOINT_0, - HTC_SERVICE_TX_PACKET_TAG); - - } else { - HTC_SETUP_COMPLETE_MSG *pSetupComplete; - /* assemble setup complete message */ - pSetupComplete = (HTC_SETUP_COMPLETE_MSG *)pSendPacket->pBuffer; - A_MEMZERO(pSetupComplete, sizeof(HTC_SETUP_COMPLETE_MSG)); - pSetupComplete->MessageID = HTC_MSG_SETUP_COMPLETE_ID; - SET_HTC_PACKET_INFO_TX(pSendPacket, - NULL, - (u8 *)pSetupComplete, - sizeof(HTC_SETUP_COMPLETE_MSG), - ENDPOINT_0, - HTC_SERVICE_TX_PACKET_TAG); - } - - /* we want synchronous operation */ - pSendPacket->Completion = NULL; - HTC_PREPARE_SEND_PKT(pSendPacket,0,0,0); - /* send the message */ - status = HTCIssueSend(target,pSendPacket); - - } while (false); - - if (pSendPacket != NULL) { - HTC_FREE_CONTROL_TX(target,pSendPacket); - } - - return status; -} - - -int HTCConnectService(HTC_HANDLE HTCHandle, - struct htc_service_connect_req *pConnectReq, - struct htc_service_connect_resp *pConnectResp) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - int status = 0; - struct htc_packet *pRecvPacket = NULL; - struct htc_packet *pSendPacket = NULL; - HTC_CONNECT_SERVICE_RESPONSE_MSG *pResponseMsg; - HTC_CONNECT_SERVICE_MSG *pConnectMsg; - HTC_ENDPOINT_ID assignedEndpoint = ENDPOINT_MAX; - struct htc_endpoint *pEndpoint; - unsigned int maxMsgSize = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCConnectService, target:0x%lX SvcID:0x%X \n", - (unsigned long)target, pConnectReq->ServiceID)); - - do { - - AR_DEBUG_ASSERT(pConnectReq->ServiceID != 0); - - if (HTC_CTRL_RSVD_SVC == pConnectReq->ServiceID) { - /* special case for pseudo control service */ - assignedEndpoint = ENDPOINT_0; - maxMsgSize = HTC_MAX_CONTROL_MESSAGE_LENGTH; - } else { - /* allocate a packet to send to the target */ - pSendPacket = HTC_ALLOC_CONTROL_TX(target); - - if (NULL == pSendPacket) { - AR_DEBUG_ASSERT(false); - status = A_NO_MEMORY; - break; - } - /* assemble connect service message */ - pConnectMsg = (HTC_CONNECT_SERVICE_MSG *)pSendPacket->pBuffer; - AR_DEBUG_ASSERT(pConnectMsg != NULL); - A_MEMZERO(pConnectMsg,sizeof(HTC_CONNECT_SERVICE_MSG)); - pConnectMsg->MessageID = HTC_MSG_CONNECT_SERVICE_ID; - pConnectMsg->ServiceID = pConnectReq->ServiceID; - pConnectMsg->ConnectionFlags = pConnectReq->ConnectionFlags; - /* check caller if it wants to transfer meta data */ - if ((pConnectReq->pMetaData != NULL) && - (pConnectReq->MetaDataLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) { - /* copy meta data into message buffer (after header ) */ - memcpy((u8 *)pConnectMsg + sizeof(HTC_CONNECT_SERVICE_MSG), - pConnectReq->pMetaData, - pConnectReq->MetaDataLength); - pConnectMsg->ServiceMetaLength = pConnectReq->MetaDataLength; - } - - SET_HTC_PACKET_INFO_TX(pSendPacket, - NULL, - (u8 *)pConnectMsg, - sizeof(HTC_CONNECT_SERVICE_MSG) + pConnectMsg->ServiceMetaLength, - ENDPOINT_0, - HTC_SERVICE_TX_PACKET_TAG); - - /* we want synchronous operation */ - pSendPacket->Completion = NULL; - HTC_PREPARE_SEND_PKT(pSendPacket,0,0,0); - status = HTCIssueSend(target,pSendPacket); - - if (status) { - break; - } - - /* wait for response */ - status = HTCWaitforControlMessage(target, &pRecvPacket); - - if (status) { - break; - } - /* we controlled the buffer creation so it has to be properly aligned */ - pResponseMsg = (HTC_CONNECT_SERVICE_RESPONSE_MSG *)pRecvPacket->pBuffer; - - if ((pResponseMsg->MessageID != HTC_MSG_CONNECT_SERVICE_RESPONSE_ID) || - (pRecvPacket->ActualLength < sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG))) { - /* this message is not valid */ - AR_DEBUG_ASSERT(false); - status = A_EPROTO; - break; - } - - pConnectResp->ConnectRespCode = pResponseMsg->Status; - /* check response status */ - if (pResponseMsg->Status != HTC_SERVICE_SUCCESS) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - (" Target failed service 0x%X connect request (status:%d)\n", - pResponseMsg->ServiceID, pResponseMsg->Status)); - status = A_EPROTO; - break; - } - - assignedEndpoint = (HTC_ENDPOINT_ID) pResponseMsg->EndpointID; - maxMsgSize = pResponseMsg->MaxMsgSize; - - if ((pConnectResp->pMetaData != NULL) && - (pResponseMsg->ServiceMetaLength > 0) && - (pResponseMsg->ServiceMetaLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) { - /* caller supplied a buffer and the target responded with data */ - int copyLength = min((int)pConnectResp->BufferLength, (int)pResponseMsg->ServiceMetaLength); - /* copy the meta data */ - memcpy(pConnectResp->pMetaData, - ((u8 *)pResponseMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG), - copyLength); - pConnectResp->ActualLength = copyLength; - } - - } - - /* the rest of these are parameter checks so set the error status */ - status = A_EPROTO; - - if (assignedEndpoint >= ENDPOINT_MAX) { - AR_DEBUG_ASSERT(false); - break; - } - - if (0 == maxMsgSize) { - AR_DEBUG_ASSERT(false); - break; - } - - pEndpoint = &target->EndPoint[assignedEndpoint]; - pEndpoint->Id = assignedEndpoint; - if (pEndpoint->ServiceID != 0) { - /* endpoint already in use! */ - AR_DEBUG_ASSERT(false); - break; - } - - /* return assigned endpoint to caller */ - pConnectResp->Endpoint = assignedEndpoint; - pConnectResp->MaxMsgLength = maxMsgSize; - - /* setup the endpoint */ - pEndpoint->ServiceID = pConnectReq->ServiceID; /* this marks the endpoint in use */ - pEndpoint->MaxTxQueueDepth = pConnectReq->MaxSendQueueDepth; - pEndpoint->MaxMsgLength = maxMsgSize; - /* copy all the callbacks */ - pEndpoint->EpCallBacks = pConnectReq->EpCallbacks; - /* set the credit distribution info for this endpoint, this information is - * passed back to the credit distribution callback function */ - pEndpoint->CreditDist.ServiceID = pConnectReq->ServiceID; - pEndpoint->CreditDist.pHTCReserved = pEndpoint; - pEndpoint->CreditDist.Endpoint = assignedEndpoint; - pEndpoint->CreditDist.TxCreditSize = target->TargetCreditSize; - - if (pConnectReq->MaxSendMsgSize != 0) { - /* override TxCreditsPerMaxMsg calculation, this optimizes the credit-low indications - * since the host will actually issue smaller messages in the Send path */ - if (pConnectReq->MaxSendMsgSize > maxMsgSize) { - /* can't be larger than the maximum the target can support */ - AR_DEBUG_ASSERT(false); - break; - } - pEndpoint->CreditDist.TxCreditsPerMaxMsg = pConnectReq->MaxSendMsgSize / target->TargetCreditSize; - } else { - pEndpoint->CreditDist.TxCreditsPerMaxMsg = maxMsgSize / target->TargetCreditSize; - } - - if (0 == pEndpoint->CreditDist.TxCreditsPerMaxMsg) { - pEndpoint->CreditDist.TxCreditsPerMaxMsg = 1; - } - - /* save local connection flags */ - pEndpoint->LocalConnectionFlags = pConnectReq->LocalConnectionFlags; - - status = 0; - - } while (false); - - if (pSendPacket != NULL) { - HTC_FREE_CONTROL_TX(target,pSendPacket); - } - - if (pRecvPacket != NULL) { - HTC_FREE_CONTROL_RX(target,pRecvPacket); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCConnectService \n")); - - return status; -} - -static void AddToEndpointDistList(struct htc_target *target, struct htc_endpoint_credit_dist *pEpDist) -{ - struct htc_endpoint_credit_dist *pCurEntry,*pLastEntry; - - if (NULL == target->EpCreditDistributionListHead) { - target->EpCreditDistributionListHead = pEpDist; - pEpDist->pNext = NULL; - pEpDist->pPrev = NULL; - return; - } - - /* queue to the end of the list, this does not have to be very - * fast since this list is built at startup time */ - pCurEntry = target->EpCreditDistributionListHead; - - while (pCurEntry) { - pLastEntry = pCurEntry; - pCurEntry = pCurEntry->pNext; - } - - pLastEntry->pNext = pEpDist; - pEpDist->pPrev = pLastEntry; - pEpDist->pNext = NULL; -} - - - -/* default credit init callback */ -static void HTCDefaultCreditInit(void *Context, - struct htc_endpoint_credit_dist *pEPList, - int TotalCredits) -{ - struct htc_endpoint_credit_dist *pCurEpDist; - int totalEps = 0; - int creditsPerEndpoint; - - pCurEpDist = pEPList; - /* first run through the list and figure out how many endpoints we are dealing with */ - while (pCurEpDist != NULL) { - pCurEpDist = pCurEpDist->pNext; - totalEps++; - } - - /* even distribution */ - creditsPerEndpoint = TotalCredits/totalEps; - - pCurEpDist = pEPList; - /* run through the list and set minimum and normal credits and - * provide the endpoint with some credits to start */ - while (pCurEpDist != NULL) { - - if (creditsPerEndpoint < pCurEpDist->TxCreditsPerMaxMsg) { - /* too many endpoints and not enough credits */ - AR_DEBUG_ASSERT(false); - break; - } - /* our minimum is set for at least 1 max message */ - pCurEpDist->TxCreditsMin = pCurEpDist->TxCreditsPerMaxMsg; - /* this value is ignored by our credit alg, since we do - * not dynamically adjust credits, this is the policy of - * the "default" credit distribution, something simple and easy */ - pCurEpDist->TxCreditsNorm = 0xFFFF; - /* give the endpoint minimum credits */ - pCurEpDist->TxCredits = creditsPerEndpoint; - pCurEpDist->TxCreditsAssigned = creditsPerEndpoint; - pCurEpDist = pCurEpDist->pNext; - } - -} - -/* default credit distribution callback, NOTE, this callback holds the TX lock */ -void HTCDefaultCreditDist(void *Context, - struct htc_endpoint_credit_dist *pEPDistList, - HTC_CREDIT_DIST_REASON Reason) -{ - struct htc_endpoint_credit_dist *pCurEpDist; - - if (Reason == HTC_CREDIT_DIST_SEND_COMPLETE) { - pCurEpDist = pEPDistList; - /* simple distribution */ - while (pCurEpDist != NULL) { - if (pCurEpDist->TxCreditsToDist > 0) { - /* just give the endpoint back the credits */ - pCurEpDist->TxCredits += pCurEpDist->TxCreditsToDist; - pCurEpDist->TxCreditsToDist = 0; - } - pCurEpDist = pCurEpDist->pNext; - } - } - - /* note we do not need to handle the other reason codes as this is a very - * simple distribution scheme, no need to seek for more credits or handle inactivity */ -} - -void HTCSetCreditDistribution(HTC_HANDLE HTCHandle, - void *pCreditDistContext, - HTC_CREDIT_DIST_CALLBACK CreditDistFunc, - HTC_CREDIT_INIT_CALLBACK CreditInitFunc, - HTC_SERVICE_ID ServicePriorityOrder[], - int ListLength) -{ - struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - int i; - int ep; - - if (CreditInitFunc != NULL) { - /* caller has supplied their own distribution functions */ - target->InitCredits = CreditInitFunc; - AR_DEBUG_ASSERT(CreditDistFunc != NULL); - target->DistributeCredits = CreditDistFunc; - target->pCredDistContext = pCreditDistContext; - } else { - /* caller wants HTC to do distribution */ - /* if caller wants service to handle distributions then - * it must set both of these to NULL! */ - AR_DEBUG_ASSERT(CreditDistFunc == NULL); - target->InitCredits = HTCDefaultCreditInit; - target->DistributeCredits = HTCDefaultCreditDist; - target->pCredDistContext = target; - } - - /* always add HTC control endpoint first, we only expose the list after the - * first one, this is added for TX queue checking */ - AddToEndpointDistList(target, &target->EndPoint[ENDPOINT_0].CreditDist); - - /* build the list of credit distribution structures in priority order - * supplied by the caller, these will follow endpoint 0 */ - for (i = 0; i < ListLength; i++) { - /* match services with endpoints and add the endpoints to the distribution list - * in FIFO order */ - for (ep = ENDPOINT_1; ep < ENDPOINT_MAX; ep++) { - if (target->EndPoint[ep].ServiceID == ServicePriorityOrder[i]) { - /* queue this one to the list */ - AddToEndpointDistList(target, &target->EndPoint[ep].CreditDist); - break; - } - } - AR_DEBUG_ASSERT(ep < ENDPOINT_MAX); - } - -} diff --git a/drivers/staging/ath6kl/include/a_config.h b/drivers/staging/ath6kl/include/a_config.h deleted file mode 100644 index f7c09319433..00000000000 --- a/drivers/staging/ath6kl/include/a_config.h +++ /dev/null @@ -1,31 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains software configuration options that enables -// specific software "features" -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _A_CONFIG_H_ -#define _A_CONFIG_H_ - -#include "../os/linux/include/config_linux.h" - -#endif diff --git a/drivers/staging/ath6kl/include/a_debug.h b/drivers/staging/ath6kl/include/a_debug.h deleted file mode 100644 index 5154fcb1ca6..00000000000 --- a/drivers/staging/ath6kl/include/a_debug.h +++ /dev/null @@ -1,195 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _A_DEBUG_H_ -#define _A_DEBUG_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - - /* standard debug print masks bits 0..7 */ -#define ATH_DEBUG_ERR (1 << 0) /* errors */ -#define ATH_DEBUG_WARN (1 << 1) /* warnings */ -#define ATH_DEBUG_INFO (1 << 2) /* informational (module startup info) */ -#define ATH_DEBUG_TRC (1 << 3) /* generic function call tracing */ -#define ATH_DEBUG_RSVD1 (1 << 4) -#define ATH_DEBUG_RSVD2 (1 << 5) -#define ATH_DEBUG_RSVD3 (1 << 6) -#define ATH_DEBUG_RSVD4 (1 << 7) - -#define ATH_DEBUG_MASK_DEFAULTS (ATH_DEBUG_ERR | ATH_DEBUG_WARN) -#define ATH_DEBUG_ANY 0xFFFF - - /* other aliases used throughout */ -#define ATH_DEBUG_ERROR ATH_DEBUG_ERR -#define ATH_LOG_ERR ATH_DEBUG_ERR -#define ATH_LOG_INF ATH_DEBUG_INFO -#define ATH_LOG_TRC ATH_DEBUG_TRC -#define ATH_DEBUG_TRACE ATH_DEBUG_TRC -#define ATH_DEBUG_INIT ATH_DEBUG_INFO - - /* bits 8..31 are module-specific masks */ -#define ATH_DEBUG_MODULE_MASK_SHIFT 8 - - /* macro to make a module-specific masks */ -#define ATH_DEBUG_MAKE_MODULE_MASK(index) (1 << (ATH_DEBUG_MODULE_MASK_SHIFT + (index))) - -void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription); - -/* Debug support on a per-module basis - * - * Usage: - * - * Each module can utilize it's own debug mask variable. A set of commonly used - * masks are provided (ERRORS, WARNINGS, TRACE etc..). It is up to each module - * to define module-specific masks using the macros above. - * - * Each module defines a single debug mask variable debug_XXX where the "name" of the module is - * common to all C-files within that module. This requires every C-file that includes a_debug.h - * to define the module name in that file. - * - * Example: - * - * #define ATH_MODULE_NAME htc - * #include "a_debug.h" - * - * This will define a debug mask structure called debug_htc and all debug macros will reference this - * variable. - * - * A module can define module-specific bit masks using the ATH_DEBUG_MAKE_MODULE_MASK() macro: - * - * #define ATH_DEBUG_MY_MASK1 ATH_DEBUG_MAKE_MODULE_MASK(0) - * #define ATH_DEBUG_MY_MASK2 ATH_DEBUG_MAKE_MODULE_MASK(1) - * - * The instantiation of the debug structure should be made by the module. When a module is - * instantiated, the module can set a description string, a default mask and an array of description - * entries containing information on each module-defined debug mask. - * NOTE: The instantiation is statically allocated, only one instance can exist per module. - * - * Example: - * - * - * #define ATH_DEBUG_BMI ATH_DEBUG_MAKE_MODULE_MASK(0) - * - * #ifdef DEBUG - * static struct ath_debug_mask_description bmi_debug_desc[] = { - * { ATH_DEBUG_BMI , "BMI Tracing"}, <== description of the module specific mask - * }; - * - * ATH_DEBUG_INSTANTIATE_MODULE_VAR(bmi, - * "bmi" <== module name - * "Boot Manager Interface", <== description of module - * ATH_DEBUG_MASK_DEFAULTS, <== defaults - * ATH_DEBUG_DESCRIPTION_COUNT(bmi_debug_desc), - * bmi_debug_desc); - * - * #endif - * - * A module can optionally register it's debug module information in order for other tools to change the - * bit mask at runtime. A module can call A_REGISTER_MODULE_DEBUG_INFO() in it's module - * init code. This macro can be called multiple times without consequence. The debug info maintains - * state to indicate whether the information was previously registered. - * - * */ - -#define ATH_DEBUG_MAX_MASK_DESC_LENGTH 32 -#define ATH_DEBUG_MAX_MOD_DESC_LENGTH 64 - -struct ath_debug_mask_description { - u32 Mask; - char Description[ATH_DEBUG_MAX_MASK_DESC_LENGTH]; -}; - -#define ATH_DEBUG_INFO_FLAGS_REGISTERED (1 << 0) - -typedef struct _ATH_DEBUG_MODULE_DBG_INFO{ - struct _ATH_DEBUG_MODULE_DBG_INFO *pNext; - char ModuleName[16]; - char ModuleDescription[ATH_DEBUG_MAX_MOD_DESC_LENGTH]; - u32 Flags; - u32 CurrentMask; - int MaxDescriptions; - struct ath_debug_mask_description *pMaskDescriptions; /* pointer to array of descriptions */ -} ATH_DEBUG_MODULE_DBG_INFO; - -#define ATH_DEBUG_DESCRIPTION_COUNT(d) (int)((sizeof((d))) / (sizeof(struct ath_debug_mask_description))) - -#define GET_ATH_MODULE_DEBUG_VAR_NAME(s) _XGET_ATH_MODULE_NAME_DEBUG_(s) -#define GET_ATH_MODULE_DEBUG_VAR_MASK(s) _XGET_ATH_MODULE_NAME_DEBUG_(s).CurrentMask -#define _XGET_ATH_MODULE_NAME_DEBUG_(s) debug_ ## s - -#ifdef ATH_DEBUG_MODULE - - /* for source files that will instantiate the debug variables */ -#define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions) \ -ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) = \ - {NULL,(name),(moddesc),0,(initmask),count,(descriptions)} - -#ifdef ATH_MODULE_NAME -extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(ATH_MODULE_NAME); -#define AR_DEBUG_LVL_CHECK(lvl) (GET_ATH_MODULE_DEBUG_VAR_MASK(ATH_MODULE_NAME) & (lvl)) -#endif /* ATH_MODULE_NAME */ - -#define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) GET_ATH_MODULE_DEBUG_VAR_MASK(s) = (lvl) - -#define ATH_DEBUG_DECLARE_EXTERN(s) \ - extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) - -#define AR_DEBUG_PRINTBUF(buffer, length, desc) DebugDumpBytes(buffer,length,desc) - - -#define AR_DEBUG_ASSERT A_ASSERT - -void a_dump_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo); -void a_register_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo); -#define A_DUMP_MODULE_DEBUG_INFO(s) a_dump_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s))) -#define A_REGISTER_MODULE_DEBUG_INFO(s) a_register_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s))) - -#else /* !ATH_DEBUG_MODULE */ - /* NON ATH_DEBUG_MODULE */ -#define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions) -#define AR_DEBUG_LVL_CHECK(lvl) 0 -#define AR_DEBUG_PRINTBUF(buffer, length, desc) -#define AR_DEBUG_ASSERT(test) -#define ATH_DEBUG_DECLARE_EXTERN(s) -#define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) -#define A_DUMP_MODULE_DEBUG_INFO(s) -#define A_REGISTER_MODULE_DEBUG_INFO(s) - -#endif - -int a_get_module_mask(char *module_name, u32 *pMask); -int a_set_module_mask(char *module_name, u32 Mask); -void a_dump_module_debug_info_by_name(char *module_name); -void a_module_debug_support_init(void); -void a_module_debug_support_cleanup(void); - -#include "../os/linux/include/debug_linux.h" - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/drivers/staging/ath6kl/include/a_drv.h b/drivers/staging/ath6kl/include/a_drv.h deleted file mode 100644 index 1548604e846..00000000000 --- a/drivers/staging/ath6kl/include/a_drv.h +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the definitions of the basic atheros data types. -// It is used to map the data types in atheros files to a platform specific -// type. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _A_DRV_H_ -#define _A_DRV_H_ - -#include "../os/linux/include/athdrv_linux.h" - -#endif /* _ADRV_H_ */ diff --git a/drivers/staging/ath6kl/include/a_drv_api.h b/drivers/staging/ath6kl/include/a_drv_api.h deleted file mode 100644 index a40d97a84ff..00000000000 --- a/drivers/staging/ath6kl/include/a_drv_api.h +++ /dev/null @@ -1,204 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _A_DRV_API_H_ -#define _A_DRV_API_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************/ -/****************************************************************************/ -/** **/ -/** WMI related hooks **/ -/** **/ -/****************************************************************************/ -/****************************************************************************/ - -#include - -#define A_WMI_CHANNELLIST_RX(devt, numChan, chanList) \ - ar6000_channelList_rx((devt), (numChan), (chanList)) - -#define A_WMI_SET_NUMDATAENDPTS(devt, num) \ - ar6000_set_numdataendpts((devt), (num)) - -#define A_WMI_CONTROL_TX(devt, osbuf, streamID) \ - ar6000_control_tx((devt), (osbuf), (streamID)) - -#define A_WMI_TARGETSTATS_EVENT(devt, pStats, len) \ - ar6000_targetStats_event((devt), (pStats), (len)) - -#define A_WMI_SCANCOMPLETE_EVENT(devt, status) \ - ar6000_scanComplete_event((devt), (status)) - -#ifdef CONFIG_HOST_DSET_SUPPORT - -#define A_WMI_DSET_DATA_REQ(devt, access_cookie, offset, length, targ_buf, targ_reply_fn, targ_reply_arg) \ - ar6000_dset_data_req((devt), (access_cookie), (offset), (length), (targ_buf), (targ_reply_fn), (targ_reply_arg)) - -#define A_WMI_DSET_CLOSE(devt, access_cookie) \ - ar6000_dset_close((devt), (access_cookie)) - -#endif - -#define A_WMI_DSET_OPEN_REQ(devt, id, targ_handle, targ_reply_fn, targ_reply_arg) \ - ar6000_dset_open_req((devt), (id), (targ_handle), (targ_reply_fn), (targ_reply_arg)) - -#define A_WMI_CONNECT_EVENT(devt, channel, bssid, listenInterval, beaconInterval, networkType, beaconIeLen, assocReqLen, assocRespLen, assocInfo) \ - ar6000_connect_event((devt), (channel), (bssid), (listenInterval), (beaconInterval), (networkType), (beaconIeLen), (assocReqLen), (assocRespLen), (assocInfo)) - -#define A_WMI_PSPOLL_EVENT(devt, aid)\ - ar6000_pspoll_event((devt),(aid)) - -#define A_WMI_DTIMEXPIRY_EVENT(devt)\ - ar6000_dtimexpiry_event((devt)) - -#ifdef WAPI_ENABLE -#define A_WMI_WAPI_REKEY_EVENT(devt, type, mac)\ - ap_wapi_rekey_event((devt),(type),(mac)) -#endif - -#define A_WMI_REGDOMAIN_EVENT(devt, regCode) \ - ar6000_regDomain_event((devt), (regCode)) - -#define A_WMI_NEIGHBORREPORT_EVENT(devt, numAps, info) \ - ar6000_neighborReport_event((devt), (numAps), (info)) - -#define A_WMI_DISCONNECT_EVENT(devt, reason, bssid, assocRespLen, assocInfo, protocolReasonStatus) \ - ar6000_disconnect_event((devt), (reason), (bssid), (assocRespLen), (assocInfo), (protocolReasonStatus)) - -#define A_WMI_TKIP_MICERR_EVENT(devt, keyid, ismcast) \ - ar6000_tkip_micerr_event((devt), (keyid), (ismcast)) - -#define A_WMI_BITRATE_RX(devt, rateKbps) \ - ar6000_bitrate_rx((devt), (rateKbps)) - -#define A_WMI_TXPWR_RX(devt, txPwr) \ - ar6000_txPwr_rx((devt), (txPwr)) - -#define A_WMI_READY_EVENT(devt, datap, phyCap, sw_ver, abi_ver) \ - ar6000_ready_event((devt), (datap), (phyCap), (sw_ver), (abi_ver)) - -#define A_WMI_DBGLOG_INIT_DONE(ar) \ - ar6000_dbglog_init_done(ar); - -#define A_WMI_RSSI_THRESHOLD_EVENT(devt, newThreshold, rssi) \ - ar6000_rssiThreshold_event((devt), (newThreshold), (rssi)) - -#define A_WMI_REPORT_ERROR_EVENT(devt, errorVal) \ - ar6000_reportError_event((devt), (errorVal)) - -#define A_WMI_ROAM_TABLE_EVENT(devt, pTbl) \ - ar6000_roam_tbl_event((devt), (pTbl)) - -#define A_WMI_ROAM_DATA_EVENT(devt, p) \ - ar6000_roam_data_event((devt), (p)) - -#define A_WMI_WOW_LIST_EVENT(devt, num_filters, wow_filters) \ - ar6000_wow_list_event((devt), (num_filters), (wow_filters)) - -#define A_WMI_CAC_EVENT(devt, ac, cac_indication, statusCode, tspecSuggestion) \ - ar6000_cac_event((devt), (ac), (cac_indication), (statusCode), (tspecSuggestion)) - -#define A_WMI_CHANNEL_CHANGE_EVENT(devt, oldChannel, newChannel) \ - ar6000_channel_change_event((devt), (oldChannel), (newChannel)) - -#define A_WMI_PMKID_LIST_EVENT(devt, num_pmkid, pmkid_list, bssid_list) \ - ar6000_pmkid_list_event((devt), (num_pmkid), (pmkid_list), (bssid_list)) - -#define A_WMI_PEER_EVENT(devt, eventCode, bssid) \ - ar6000_peer_event ((devt), (eventCode), (bssid)) - -#ifdef CONFIG_HOST_TCMD_SUPPORT -#define A_WMI_TCMD_RX_REPORT_EVENT(devt, results, len) \ - ar6000_tcmd_rx_report_event((devt), (results), (len)) -#endif - -#define A_WMI_HBCHALLENGERESP_EVENT(devt, cookie, source) \ - ar6000_hbChallengeResp_event((devt), (cookie), (source)) - -#define A_WMI_TX_RETRY_ERR_EVENT(devt) \ - ar6000_tx_retry_err_event((devt)) - -#define A_WMI_SNR_THRESHOLD_EVENT_RX(devt, newThreshold, snr) \ - ar6000_snrThresholdEvent_rx((devt), (newThreshold), (snr)) - -#define A_WMI_LQ_THRESHOLD_EVENT_RX(devt, range, lqVal) \ - ar6000_lqThresholdEvent_rx((devt), (range), (lqVal)) - -#define A_WMI_RATEMASK_RX(devt, ratemask) \ - ar6000_ratemask_rx((devt), (ratemask)) - -#define A_WMI_KEEPALIVE_RX(devt, configured) \ - ar6000_keepalive_rx((devt), (configured)) - -#define A_WMI_BSSINFO_EVENT_RX(ar, datp, len) \ - ar6000_bssInfo_event_rx((ar), (datap), (len)) - -#define A_WMI_DBGLOG_EVENT(ar, dropped, buffer, length) \ - ar6000_dbglog_event((ar), (dropped), (buffer), (length)); - -#define A_WMI_STREAM_TX_ACTIVE(devt,trafficClass) \ - ar6000_indicate_tx_activity((devt),(trafficClass), true) - -#define A_WMI_STREAM_TX_INACTIVE(devt,trafficClass) \ - ar6000_indicate_tx_activity((devt),(trafficClass), false) -#define A_WMI_Ac2EndpointID(devht, ac)\ - ar6000_ac2_endpoint_id((devht), (ac)) - -#define A_WMI_AGGR_RECV_ADDBA_REQ_EVT(devt, cmd)\ - ar6000_aggr_rcv_addba_req_evt((devt), (cmd)) -#define A_WMI_AGGR_RECV_ADDBA_RESP_EVT(devt, cmd)\ - ar6000_aggr_rcv_addba_resp_evt((devt), (cmd)) -#define A_WMI_AGGR_RECV_DELBA_REQ_EVT(devt, cmd)\ - ar6000_aggr_rcv_delba_req_evt((devt), (cmd)) -#define A_WMI_HCI_EVENT_EVT(devt, cmd)\ - ar6000_hci_event_rcv_evt((devt), (cmd)) - -#define A_WMI_Endpoint2Ac(devt, ep) \ - ar6000_endpoint_id2_ac((devt), (ep)) - -#define A_WMI_BTCOEX_CONFIG_EVENT(devt, evt, len)\ - ar6000_btcoex_config_event((devt), (evt), (len)) - -#define A_WMI_BTCOEX_STATS_EVENT(devt, datap, len)\ - ar6000_btcoex_stats_event((devt), (datap), (len)) - -/****************************************************************************/ -/****************************************************************************/ -/** **/ -/** HTC related hooks **/ -/** **/ -/****************************************************************************/ -/****************************************************************************/ - -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -#define A_WMI_PROF_COUNT_RX(addr, count) prof_count_rx((addr), (count)) -#endif /* CONFIG_TARGET_PROFILE_SUPPORT */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/staging/ath6kl/include/a_osapi.h b/drivers/staging/ath6kl/include/a_osapi.h deleted file mode 100644 index fd7ae0d612c..00000000000 --- a/drivers/staging/ath6kl/include/a_osapi.h +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the definitions of the basic atheros data types. -// It is used to map the data types in atheros files to a platform specific -// type. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _A_OSAPI_H_ -#define _A_OSAPI_H_ - -#include "../os/linux/include/osapi_linux.h" - -#endif /* _OSAPI_H_ */ diff --git a/drivers/staging/ath6kl/include/aggr_recv_api.h b/drivers/staging/ath6kl/include/aggr_recv_api.h deleted file mode 100644 index 5ead58d5feb..00000000000 --- a/drivers/staging/ath6kl/include/aggr_recv_api.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// - * - */ - -#ifndef __AGGR_RECV_API_H__ -#define __AGGR_RECV_API_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (* RX_CALLBACK)(void * dev, void *osbuf); - -typedef void (* ALLOC_NETBUFS)(A_NETBUF_QUEUE_T *q, u16 num); - -/* - * aggr_init: - * Initialises the data structures, allocates data queues and - * os buffers. Netbuf allocator is the input param, used by the - * aggr module for allocation of NETBUFs from driver context. - * These NETBUFs are used for AMSDU processing. - * Returns the context for the aggr module. - */ -void * -aggr_init(ALLOC_NETBUFS netbuf_allocator); - - -/* - * aggr_register_rx_dispatcher: - * Registers OS call back function to deliver the - * frames to OS. This is generally the topmost layer of - * the driver context, after which the frames go to - * IP stack via the call back function. - * This dispatcher is active only when aggregation is ON. - */ -void -aggr_register_rx_dispatcher(void *cntxt, void * dev, RX_CALLBACK fn); - - -/* - * aggr_process_bar: - * When target receives BAR, it communicates to host driver - * for modifying window parameters. Target indicates this via the - * event: WMI_ADDBA_REQ_EVENTID. Host will dequeue all frames - * up to the indicated sequence number. - */ -void -aggr_process_bar(void *cntxt, u8 tid, u16 seq_no); - - -/* - * aggr_recv_addba_req_evt: - * This event is to initiate/modify the receive side window. - * Target will send WMI_ADDBA_REQ_EVENTID event to host - to setup - * recv re-ordering queues. Target will negotiate ADDBA with peer, - * and indicate via this event after successfully completing the - * negotiation. This happens in two situations: - * 1. Initial setup of aggregation - * 2. Renegotiation of current recv window. - * Window size for re-ordering is limited by target buffer - * space, which is reflected in win_sz. - * (Re)Start the periodic timer to deliver long standing frames, - * in hold_q to OS. - */ -void -aggr_recv_addba_req_evt(void * cntxt, u8 tid, u16 seq_no, u8 win_sz); - - -/* - * aggr_recv_delba_req_evt: - * Target indicates deletion of a BA window for a tid via the - * WMI_DELBA_EVENTID. Host would deliver all the frames in the - * hold_q, reset tid config and disable the periodic timer, if - * aggr is not enabled on any tid. - */ -void -aggr_recv_delba_req_evt(void * cntxt, u8 tid); - - - -/* - * aggr_process_recv_frm: - * Called only for data frames. When aggr is ON for a tid, the buffer - * is always consumed, and osbuf would be NULL. For a non-aggr case, - * osbuf is not modified. - * AMSDU frames are consumed and are later freed. They are sliced and - * diced to individual frames and dispatched to stack. - * After consuming a osbuf(when aggr is ON), a previously registered - * callback may be called to deliver frames in order. - */ -void -aggr_process_recv_frm(void *cntxt, u8 tid, u16 seq_no, bool is_amsdu, void **osbuf); - - -/* - * aggr_module_destroy: - * Frees up all the queues and frames in them. Releases the cntxt to OS. - */ -void -aggr_module_destroy(void *cntxt); - -/* - * Dumps the aggregation stats - */ -void -aggr_dump_stats(void *cntxt, PACKET_LOG **log_buf); - -/* - * aggr_reset_state -- Called when it is deemed necessary to clear the aggregate - * hold Q state. Examples include when a Connect event or disconnect event is - * received. - */ -void -aggr_reset_state(void *cntxt); - - -#ifdef __cplusplus -} -#endif - -#endif /*__AGGR_RECV_API_H__ */ diff --git a/drivers/staging/ath6kl/include/ar3kconfig.h b/drivers/staging/ath6kl/include/ar3kconfig.h deleted file mode 100644 index 91bc4ee3512..00000000000 --- a/drivers/staging/ath6kl/include/ar3kconfig.h +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -/* AR3K module configuration APIs for HCI-bridge operation */ - -#ifndef AR3KCONFIG_H_ -#define AR3KCONFIG_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define AR3K_CONFIG_FLAG_FORCE_MINBOOT_EXIT (1 << 0) -#define AR3K_CONFIG_FLAG_SET_AR3K_BAUD (1 << 1) -#define AR3K_CONFIG_FLAG_AR3K_BAUD_CHANGE_DELAY (1 << 2) -#define AR3K_CONFIG_FLAG_SET_AR6K_SCALE_STEP (1 << 3) - - -struct ar3k_config_info { - u32 Flags; /* config flags */ - void *pHCIDev; /* HCI bridge device */ - struct hci_transport_properties *pHCIProps; /* HCI bridge props */ - struct hif_device *pHIFDevice; /* HIF layer device */ - - u32 AR3KBaudRate; /* AR3K operational baud rate */ - u16 AR6KScale; /* AR6K UART scale value */ - u16 AR6KStep; /* AR6K UART step value */ - struct hci_dev *pBtStackHCIDev; /* BT Stack HCI dev */ - u32 PwrMgmtEnabled; /* TLPM enabled? */ - u16 IdleTimeout; /* TLPM idle timeout */ - u16 WakeupTimeout; /* TLPM wakeup timeout */ - u8 bdaddr[6]; /* Bluetooth device address */ -}; - -int AR3KConfigure(struct ar3k_config_info *pConfigInfo); - -int AR3KConfigureExit(void *config); - -#ifdef __cplusplus -} -#endif - -#endif /*AR3KCONFIG_H_*/ diff --git a/drivers/staging/ath6kl/include/ar6000_api.h b/drivers/staging/ath6kl/include/ar6000_api.h deleted file mode 100644 index e9460800272..00000000000 --- a/drivers/staging/ath6kl/include/ar6000_api.h +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the API to access the OS dependent atheros host driver -// by the WMI or WLAN generic modules. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _AR6000_API_H_ -#define _AR6000_API_H_ - -#include "../os/linux/include/ar6xapi_linux.h" - -#endif /* _AR6000_API_H */ - diff --git a/drivers/staging/ath6kl/include/ar6000_diag.h b/drivers/staging/ath6kl/include/ar6000_diag.h deleted file mode 100644 index 739c01c53f0..00000000000 --- a/drivers/staging/ath6kl/include/ar6000_diag.h +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef AR6000_DIAG_H_ -#define AR6000_DIAG_H_ - - -int -ar6000_ReadRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); - -int -ar6000_WriteRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); - -int -ar6000_ReadDataDiag(struct hif_device *hifDevice, u32 address, - u8 *data, u32 length); - -int -ar6000_WriteDataDiag(struct hif_device *hifDevice, u32 address, - u8 *data, u32 length); - -int -ar6k_ReadTargetRegister(struct hif_device *hifDevice, int regsel, u32 *regval); - -void -ar6k_FetchTargetRegs(struct hif_device *hifDevice, u32 *targregs); - -#endif /*AR6000_DIAG_H_*/ diff --git a/drivers/staging/ath6kl/include/ar6kap_common.h b/drivers/staging/ath6kl/include/ar6kap_common.h deleted file mode 100644 index 532d8eba932..00000000000 --- a/drivers/staging/ath6kl/include/ar6kap_common.h +++ /dev/null @@ -1,44 +0,0 @@ -//------------------------------------------------------------------------------ - -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ - -//============================================================================== - -// This file contains the definitions of common AP mode data structures. -// -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _AR6KAP_COMMON_H_ -#define _AR6KAP_COMMON_H_ -/* - * Used with AR6000_XIOCTL_AP_GET_STA_LIST - */ -typedef struct { - u8 mac[ATH_MAC_LEN]; - u8 aid; - u8 keymgmt; - u8 ucipher; - u8 auth; -} station_t; -typedef struct { - station_t sta[AP_MAX_NUM_STA]; -} ap_get_sta_t; -#endif /* _AR6KAP_COMMON_H_ */ diff --git a/drivers/staging/ath6kl/include/athbtfilter.h b/drivers/staging/ath6kl/include/athbtfilter.h deleted file mode 100644 index 81456eea3b0..00000000000 --- a/drivers/staging/ath6kl/include/athbtfilter.h +++ /dev/null @@ -1,135 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Public Bluetooth filter APIs -// Author(s): ="Atheros" -//============================================================================== -#ifndef ATHBTFILTER_H_ -#define ATHBTFILTER_H_ - -#define ATH_DEBUG_INFO (1 << 2) -#define ATH_DEBUG_INF ATH_DEBUG_INFO - -typedef enum _ATHBT_HCI_CTRL_TYPE { - ATHBT_HCI_COMMAND = 0, - ATHBT_HCI_EVENT = 1, -} ATHBT_HCI_CTRL_TYPE; - -typedef enum _ATHBT_STATE_INDICATION { - ATH_BT_NOOP = 0, - ATH_BT_INQUIRY = 1, - ATH_BT_CONNECT = 2, - ATH_BT_SCO = 3, - ATH_BT_ACL = 4, - ATH_BT_A2DP = 5, - ATH_BT_ESCO = 6, - /* new states go here.. */ - - ATH_BT_MAX_STATE_INDICATION -} ATHBT_STATE_INDICATION; - - /* filter function for OUTGOING commands and INCOMMING events */ -typedef void (*ATHBT_FILTER_CMD_EVENTS_FN)(void *pContext, ATHBT_HCI_CTRL_TYPE Type, unsigned char *pBuffer, int Length); - - /* filter function for OUTGOING data HCI packets */ -typedef void (*ATHBT_FILTER_DATA_FN)(void *pContext, unsigned char *pBuffer, int Length); - -typedef enum _ATHBT_STATE { - STATE_OFF = 0, - STATE_ON = 1, - STATE_MAX -} ATHBT_STATE; - - /* BT state indication (when filter functions are not used) */ - -typedef void (*ATHBT_INDICATE_STATE_FN)(void *pContext, ATHBT_STATE_INDICATION Indication, ATHBT_STATE State, unsigned char LMPVersion); - -struct athbt_filter_instance { -#ifdef UNDER_CE - WCHAR *pWlanAdapterName; /* filled in by user */ -#else - char *pWlanAdapterName; /* filled in by user */ -#endif /* UNDER_CE */ - int FilterEnabled; /* filtering is enabled */ - int Attached; /* filter library is attached */ - void *pContext; /* private context for filter library */ - ATHBT_FILTER_CMD_EVENTS_FN pFilterCmdEvents; /* function ptr to filter a command or event */ - ATHBT_FILTER_DATA_FN pFilterAclDataOut; /* function ptr to filter ACL data out (to radio) */ - ATHBT_FILTER_DATA_FN pFilterAclDataIn; /* function ptr to filter ACL data in (from radio) */ - ATHBT_INDICATE_STATE_FN pIndicateState; /* function ptr to indicate a state */ -}; /* XXX: unused ? */ - - -/* API MACROS */ - -#define AthBtFilterHciCommand(instance,packet,length) \ - if ((instance)->FilterEnabled) { \ - (instance)->pFilterCmdEvents((instance)->pContext, \ - ATHBT_HCI_COMMAND, \ - (unsigned char *)(packet), \ - (length)); \ - } - -#define AthBtFilterHciEvent(instance,packet,length) \ - if ((instance)->FilterEnabled) { \ - (instance)->pFilterCmdEvents((instance)->pContext, \ - ATHBT_HCI_EVENT, \ - (unsigned char *)(packet), \ - (length)); \ - } - -#define AthBtFilterHciAclDataOut(instance,packet,length) \ - if ((instance)->FilterEnabled) { \ - (instance)->pFilterAclDataOut((instance)->pContext, \ - (unsigned char *)(packet), \ - (length)); \ - } - -#define AthBtFilterHciAclDataIn(instance,packet,length) \ - if ((instance)->FilterEnabled) { \ - (instance)->pFilterAclDataIn((instance)->pContext, \ - (unsigned char *)(packet), \ - (length)); \ - } - -/* if filtering is not desired, the application can indicate the state directly using this - * macro: - */ -#define AthBtIndicateState(instance,indication,state) \ - if ((instance)->FilterEnabled) { \ - (instance)->pIndicateState((instance)->pContext, \ - (indication), \ - (state), \ - 0); \ - } - -#ifdef __cplusplus -extern "C" { -#endif - -/* API prototypes */ -int AthBtFilter_Attach(ATH_BT_FILTER_INSTANCE *pInstance, unsigned int flags); -void AthBtFilter_Detach(ATH_BT_FILTER_INSTANCE *pInstance); - -#ifdef __cplusplus -} -#endif - -#endif /*ATHBTFILTER_H_*/ diff --git a/drivers/staging/ath6kl/include/bmi.h b/drivers/staging/ath6kl/include/bmi.h deleted file mode 100644 index d3227f77fa5..00000000000 --- a/drivers/staging/ath6kl/include/bmi.h +++ /dev/null @@ -1,134 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// BMI declarations and prototypes -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _BMI_H_ -#define _BMI_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Header files */ -#include "a_config.h" -#include "athdefs.h" -#include "hif.h" -#include "a_osapi.h" -#include "bmi_msg.h" - -void -BMIInit(void); - -void -BMICleanup(void); - -int -BMIDone(struct hif_device *device); - -int -BMIGetTargetInfo(struct hif_device *device, struct bmi_target_info *targ_info); - -int -BMIReadMemory(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length); - -int -BMIWriteMemory(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length); - -int -BMIExecute(struct hif_device *device, - u32 address, - u32 *param); - -int -BMISetAppStart(struct hif_device *device, - u32 address); - -int -BMIReadSOCRegister(struct hif_device *device, - u32 address, - u32 *param); - -int -BMIWriteSOCRegister(struct hif_device *device, - u32 address, - u32 param); - -int -BMIrompatchInstall(struct hif_device *device, - u32 ROM_addr, - u32 RAM_addr, - u32 nbytes, - u32 do_activate, - u32 *patch_id); - -int -BMIrompatchUninstall(struct hif_device *device, - u32 rompatch_id); - -int -BMIrompatchActivate(struct hif_device *device, - u32 rompatch_count, - u32 *rompatch_list); - -int -BMIrompatchDeactivate(struct hif_device *device, - u32 rompatch_count, - u32 *rompatch_list); - -int -BMILZStreamStart(struct hif_device *device, - u32 address); - -int -BMILZData(struct hif_device *device, - u8 *buffer, - u32 length); - -int -BMIFastDownload(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length); - -int -BMIRawWrite(struct hif_device *device, - u8 *buffer, - u32 length); - -int -BMIRawRead(struct hif_device *device, - u8 *buffer, - u32 length, - bool want_timeout); - -#ifdef __cplusplus -} -#endif - -#endif /* _BMI_H_ */ diff --git a/drivers/staging/ath6kl/include/common/AR6002/AR6K_version.h b/drivers/staging/ath6kl/include/common/AR6002/AR6K_version.h deleted file mode 100644 index 5407e05d9b0..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/AR6K_version.h +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#define __VER_MAJOR_ 3 -#define __VER_MINOR_ 0 -#define __VER_PATCH_ 0 - -/* The makear6ksdk script (used for release builds) modifies the following line. */ -#define __BUILD_NUMBER_ 233 - - -/* Format of the version number. */ -#define VER_MAJOR_BIT_OFFSET 28 -#define VER_MINOR_BIT_OFFSET 24 -#define VER_PATCH_BIT_OFFSET 16 -#define VER_BUILD_NUM_BIT_OFFSET 0 - - -/* - * The version has the following format: - * Bits 28-31: Major version - * Bits 24-27: Minor version - * Bits 16-23: Patch version - * Bits 0-15: Build number (automatically generated during build process ) - * E.g. Build 1.1.3.7 would be represented as 0x11030007. - * - * DO NOT split the following macro into multiple lines as this may confuse the build scripts. - */ -#define AR6K_SW_VERSION ( ( __VER_MAJOR_ << VER_MAJOR_BIT_OFFSET ) + ( __VER_MINOR_ << VER_MINOR_BIT_OFFSET ) + ( __VER_PATCH_ << VER_PATCH_BIT_OFFSET ) + ( __BUILD_NUMBER_ << VER_BUILD_NUM_BIT_OFFSET ) ) - -/* ABI Version. Reflects the version of binary interface exposed by AR6K target firmware. Needs to be incremented by 1 for any change in the firmware that requires upgrade of the driver on the host side for the change to work correctly */ -#define AR6K_ABI_VERSION 1 diff --git a/drivers/staging/ath6kl/include/common/AR6002/addrs.h b/drivers/staging/ath6kl/include/common/AR6002/addrs.h deleted file mode 100644 index bbf8d42828c..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/addrs.h +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef __ADDRS_H__ -#define __ADDRS_H__ - -/* - * Special AR6002 Addresses that may be needed by special - * applications (e.g. ART) on the Host as well as Target. - */ - -#if defined(AR6002_REV2) -#define AR6K_RAM_START 0x00500000 -#define TARG_RAM_OFFSET(vaddr) ((u32)(vaddr) & 0xfffff) -#define TARG_RAM_SZ (184*1024) -#define TARG_ROM_SZ (80*1024) -#endif -#if defined(AR6002_REV4) || defined(AR6003) -#define AR6K_RAM_START 0x00540000 -#define TARG_RAM_OFFSET(vaddr) (((u32)(vaddr) & 0xfffff) - 0x40000) -#define TARG_RAM_SZ (256*1024) -#define TARG_ROM_SZ (256*1024) -#endif - -#define AR6002_BOARD_DATA_SZ 768 -#define AR6002_BOARD_EXT_DATA_SZ 0 -#define AR6003_BOARD_DATA_SZ 1024 -#define AR6003_BOARD_EXT_DATA_SZ 768 - -#define AR6K_RAM_ADDR(byte_offset) (AR6K_RAM_START+(byte_offset)) -#define TARG_RAM_ADDRS(byte_offset) AR6K_RAM_ADDR(byte_offset) - -#define AR6K_ROM_START 0x004e0000 -#define TARG_ROM_OFFSET(vaddr) (((u32)(vaddr) & 0x1fffff) - 0xe0000) -#define AR6K_ROM_ADDR(byte_offset) (AR6K_ROM_START+(byte_offset)) -#define TARG_ROM_ADDRS(byte_offset) AR6K_ROM_ADDR(byte_offset) - -/* - * At this ROM address is a pointer to the start of the ROM DataSet Index. - * If there are no ROM DataSets, there's a 0 at this address. - */ -#define ROM_DATASET_INDEX_ADDR (TARG_ROM_ADDRS(TARG_ROM_SZ)-8) -#define ROM_MBIST_CKSUM_ADDR (TARG_ROM_ADDRS(TARG_ROM_SZ)-4) - -/* - * The API A_BOARD_DATA_ADDR() is the proper way to get a read pointer to - * board data. - */ - -/* Size of Board Data, in bytes */ -#if defined(AR6002_REV4) || defined(AR6003) -#define BOARD_DATA_SZ AR6003_BOARD_DATA_SZ -#else -#define BOARD_DATA_SZ AR6002_BOARD_DATA_SZ -#endif - - -/* - * Constants used by ASM code to access fields of host_interest_s, - * which is at a fixed location in RAM. - */ -#if defined(AR6002_REV4) || defined(AR6003) -#define HOST_INTEREST_FLASH_IS_PRESENT_ADDR (AR6K_RAM_START + 0x60c) -#else -#define HOST_INTEREST_FLASH_IS_PRESENT_ADDR (AR6K_RAM_START + 0x40c) -#endif -#define FLASH_IS_PRESENT_TARGADDR HOST_INTEREST_FLASH_IS_PRESENT_ADDR - -#endif /* __ADDRS_H__ */ - - - diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_athr_wlan_map.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_athr_wlan_map.h deleted file mode 100644 index 609eb9841f5..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_athr_wlan_map.h +++ /dev/null @@ -1,40 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#ifndef _APB_ATHR_WLAN_MAP_H_ -#define _APB_ATHR_WLAN_MAP_H_ - -#define WLAN_RTC_BASE_ADDRESS 0x00004000 -#define WLAN_VMC_BASE_ADDRESS 0x00008000 -#define WLAN_UART_BASE_ADDRESS 0x0000c000 -#define WLAN_DBG_UART_BASE_ADDRESS 0x0000d000 -#define WLAN_UMBOX_BASE_ADDRESS 0x0000e000 -#define WLAN_SI_BASE_ADDRESS 0x00010000 -#define WLAN_GPIO_BASE_ADDRESS 0x00014000 -#define WLAN_MBOX_BASE_ADDRESS 0x00018000 -#define WLAN_ANALOG_INTF_BASE_ADDRESS 0x0001c000 -#define WLAN_MAC_BASE_ADDRESS 0x00020000 -#define WLAN_RDMA_BASE_ADDRESS 0x00030100 -#define EFUSE_BASE_ADDRESS 0x00031000 - -#endif /* _APB_ATHR_WLAN_MAP_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_map.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_map.h deleted file mode 100644 index 0068ca31b05..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_map.h +++ /dev/null @@ -1,40 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#include "apb_athr_wlan_map.h" - -#ifndef BT_HEADERS - -#define RTC_BASE_ADDRESS WLAN_RTC_BASE_ADDRESS -#define VMC_BASE_ADDRESS WLAN_VMC_BASE_ADDRESS -#define UART_BASE_ADDRESS WLAN_UART_BASE_ADDRESS -#define DBG_UART_BASE_ADDRESS WLAN_DBG_UART_BASE_ADDRESS -#define UMBOX_BASE_ADDRESS WLAN_UMBOX_BASE_ADDRESS -#define SI_BASE_ADDRESS WLAN_SI_BASE_ADDRESS -#define GPIO_BASE_ADDRESS WLAN_GPIO_BASE_ADDRESS -#define MBOX_BASE_ADDRESS WLAN_MBOX_BASE_ADDRESS -#define ANALOG_INTF_BASE_ADDRESS WLAN_ANALOG_INTF_BASE_ADDRESS -#define MAC_BASE_ADDRESS WLAN_MAC_BASE_ADDRESS -#define RDMA_BASE_ADDRESS WLAN_RDMA_BASE_ADDRESS - -#endif diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_host_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_host_reg.h deleted file mode 100644 index 109f24e10a6..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_host_reg.h +++ /dev/null @@ -1,24 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#include "mbox_wlan_host_reg.h" diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_reg.h deleted file mode 100644 index 72fa483450d..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_reg.h +++ /dev/null @@ -1,552 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#include "mbox_wlan_reg.h" - -#ifndef BT_HEADERS - -#define MBOX_FIFO_ADDRESS WLAN_MBOX_FIFO_ADDRESS -#define MBOX_FIFO_OFFSET WLAN_MBOX_FIFO_OFFSET -#define MBOX_FIFO_DATA_MSB WLAN_MBOX_FIFO_DATA_MSB -#define MBOX_FIFO_DATA_LSB WLAN_MBOX_FIFO_DATA_LSB -#define MBOX_FIFO_DATA_MASK WLAN_MBOX_FIFO_DATA_MASK -#define MBOX_FIFO_DATA_GET(x) WLAN_MBOX_FIFO_DATA_GET(x) -#define MBOX_FIFO_DATA_SET(x) WLAN_MBOX_FIFO_DATA_SET(x) -#define MBOX_FIFO_STATUS_ADDRESS WLAN_MBOX_FIFO_STATUS_ADDRESS -#define MBOX_FIFO_STATUS_OFFSET WLAN_MBOX_FIFO_STATUS_OFFSET -#define MBOX_FIFO_STATUS_EMPTY_MSB WLAN_MBOX_FIFO_STATUS_EMPTY_MSB -#define MBOX_FIFO_STATUS_EMPTY_LSB WLAN_MBOX_FIFO_STATUS_EMPTY_LSB -#define MBOX_FIFO_STATUS_EMPTY_MASK WLAN_MBOX_FIFO_STATUS_EMPTY_MASK -#define MBOX_FIFO_STATUS_EMPTY_GET(x) WLAN_MBOX_FIFO_STATUS_EMPTY_GET(x) -#define MBOX_FIFO_STATUS_EMPTY_SET(x) WLAN_MBOX_FIFO_STATUS_EMPTY_SET(x) -#define MBOX_FIFO_STATUS_FULL_MSB WLAN_MBOX_FIFO_STATUS_FULL_MSB -#define MBOX_FIFO_STATUS_FULL_LSB WLAN_MBOX_FIFO_STATUS_FULL_LSB -#define MBOX_FIFO_STATUS_FULL_MASK WLAN_MBOX_FIFO_STATUS_FULL_MASK -#define MBOX_FIFO_STATUS_FULL_GET(x) WLAN_MBOX_FIFO_STATUS_FULL_GET(x) -#define MBOX_FIFO_STATUS_FULL_SET(x) WLAN_MBOX_FIFO_STATUS_FULL_SET(x) -#define MBOX_DMA_POLICY_ADDRESS WLAN_MBOX_DMA_POLICY_ADDRESS -#define MBOX_DMA_POLICY_OFFSET WLAN_MBOX_DMA_POLICY_OFFSET -#define MBOX_DMA_POLICY_TX_QUANTUM_MSB WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MSB -#define MBOX_DMA_POLICY_TX_QUANTUM_LSB WLAN_MBOX_DMA_POLICY_TX_QUANTUM_LSB -#define MBOX_DMA_POLICY_TX_QUANTUM_MASK WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MASK -#define MBOX_DMA_POLICY_TX_QUANTUM_GET(x) WLAN_MBOX_DMA_POLICY_TX_QUANTUM_GET(x) -#define MBOX_DMA_POLICY_TX_QUANTUM_SET(x) WLAN_MBOX_DMA_POLICY_TX_QUANTUM_SET(x) -#define MBOX_DMA_POLICY_TX_ORDER_MSB WLAN_MBOX_DMA_POLICY_TX_ORDER_MSB -#define MBOX_DMA_POLICY_TX_ORDER_LSB WLAN_MBOX_DMA_POLICY_TX_ORDER_LSB -#define MBOX_DMA_POLICY_TX_ORDER_MASK WLAN_MBOX_DMA_POLICY_TX_ORDER_MASK -#define MBOX_DMA_POLICY_TX_ORDER_GET(x) WLAN_MBOX_DMA_POLICY_TX_ORDER_GET(x) -#define MBOX_DMA_POLICY_TX_ORDER_SET(x) WLAN_MBOX_DMA_POLICY_TX_ORDER_SET(x) -#define MBOX_DMA_POLICY_RX_QUANTUM_MSB WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MSB -#define MBOX_DMA_POLICY_RX_QUANTUM_LSB WLAN_MBOX_DMA_POLICY_RX_QUANTUM_LSB -#define MBOX_DMA_POLICY_RX_QUANTUM_MASK WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MASK -#define MBOX_DMA_POLICY_RX_QUANTUM_GET(x) WLAN_MBOX_DMA_POLICY_RX_QUANTUM_GET(x) -#define MBOX_DMA_POLICY_RX_QUANTUM_SET(x) WLAN_MBOX_DMA_POLICY_RX_QUANTUM_SET(x) -#define MBOX_DMA_POLICY_RX_ORDER_MSB WLAN_MBOX_DMA_POLICY_RX_ORDER_MSB -#define MBOX_DMA_POLICY_RX_ORDER_LSB WLAN_MBOX_DMA_POLICY_RX_ORDER_LSB -#define MBOX_DMA_POLICY_RX_ORDER_MASK WLAN_MBOX_DMA_POLICY_RX_ORDER_MASK -#define MBOX_DMA_POLICY_RX_ORDER_GET(x) WLAN_MBOX_DMA_POLICY_RX_ORDER_GET(x) -#define MBOX_DMA_POLICY_RX_ORDER_SET(x) WLAN_MBOX_DMA_POLICY_RX_ORDER_SET(x) -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX0_DMA_RX_CONTROL_ADDRESS WLAN_MBOX0_DMA_RX_CONTROL_ADDRESS -#define MBOX0_DMA_RX_CONTROL_OFFSET WLAN_MBOX0_DMA_RX_CONTROL_OFFSET -#define MBOX0_DMA_RX_CONTROL_RESUME_MSB WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MSB -#define MBOX0_DMA_RX_CONTROL_RESUME_LSB WLAN_MBOX0_DMA_RX_CONTROL_RESUME_LSB -#define MBOX0_DMA_RX_CONTROL_RESUME_MASK WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MASK -#define MBOX0_DMA_RX_CONTROL_RESUME_GET(x) WLAN_MBOX0_DMA_RX_CONTROL_RESUME_GET(x) -#define MBOX0_DMA_RX_CONTROL_RESUME_SET(x) WLAN_MBOX0_DMA_RX_CONTROL_RESUME_SET(x) -#define MBOX0_DMA_RX_CONTROL_START_MSB WLAN_MBOX0_DMA_RX_CONTROL_START_MSB -#define MBOX0_DMA_RX_CONTROL_START_LSB WLAN_MBOX0_DMA_RX_CONTROL_START_LSB -#define MBOX0_DMA_RX_CONTROL_START_MASK WLAN_MBOX0_DMA_RX_CONTROL_START_MASK -#define MBOX0_DMA_RX_CONTROL_START_GET(x) WLAN_MBOX0_DMA_RX_CONTROL_START_GET(x) -#define MBOX0_DMA_RX_CONTROL_START_SET(x) WLAN_MBOX0_DMA_RX_CONTROL_START_SET(x) -#define MBOX0_DMA_RX_CONTROL_STOP_MSB WLAN_MBOX0_DMA_RX_CONTROL_STOP_MSB -#define MBOX0_DMA_RX_CONTROL_STOP_LSB WLAN_MBOX0_DMA_RX_CONTROL_STOP_LSB -#define MBOX0_DMA_RX_CONTROL_STOP_MASK WLAN_MBOX0_DMA_RX_CONTROL_STOP_MASK -#define MBOX0_DMA_RX_CONTROL_STOP_GET(x) WLAN_MBOX0_DMA_RX_CONTROL_STOP_GET(x) -#define MBOX0_DMA_RX_CONTROL_STOP_SET(x) WLAN_MBOX0_DMA_RX_CONTROL_STOP_SET(x) -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX0_DMA_TX_CONTROL_ADDRESS WLAN_MBOX0_DMA_TX_CONTROL_ADDRESS -#define MBOX0_DMA_TX_CONTROL_OFFSET WLAN_MBOX0_DMA_TX_CONTROL_OFFSET -#define MBOX0_DMA_TX_CONTROL_RESUME_MSB WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MSB -#define MBOX0_DMA_TX_CONTROL_RESUME_LSB WLAN_MBOX0_DMA_TX_CONTROL_RESUME_LSB -#define MBOX0_DMA_TX_CONTROL_RESUME_MASK WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MASK -#define MBOX0_DMA_TX_CONTROL_RESUME_GET(x) WLAN_MBOX0_DMA_TX_CONTROL_RESUME_GET(x) -#define MBOX0_DMA_TX_CONTROL_RESUME_SET(x) WLAN_MBOX0_DMA_TX_CONTROL_RESUME_SET(x) -#define MBOX0_DMA_TX_CONTROL_START_MSB WLAN_MBOX0_DMA_TX_CONTROL_START_MSB -#define MBOX0_DMA_TX_CONTROL_START_LSB WLAN_MBOX0_DMA_TX_CONTROL_START_LSB -#define MBOX0_DMA_TX_CONTROL_START_MASK WLAN_MBOX0_DMA_TX_CONTROL_START_MASK -#define MBOX0_DMA_TX_CONTROL_START_GET(x) WLAN_MBOX0_DMA_TX_CONTROL_START_GET(x) -#define MBOX0_DMA_TX_CONTROL_START_SET(x) WLAN_MBOX0_DMA_TX_CONTROL_START_SET(x) -#define MBOX0_DMA_TX_CONTROL_STOP_MSB WLAN_MBOX0_DMA_TX_CONTROL_STOP_MSB -#define MBOX0_DMA_TX_CONTROL_STOP_LSB WLAN_MBOX0_DMA_TX_CONTROL_STOP_LSB -#define MBOX0_DMA_TX_CONTROL_STOP_MASK WLAN_MBOX0_DMA_TX_CONTROL_STOP_MASK -#define MBOX0_DMA_TX_CONTROL_STOP_GET(x) WLAN_MBOX0_DMA_TX_CONTROL_STOP_GET(x) -#define MBOX0_DMA_TX_CONTROL_STOP_SET(x) WLAN_MBOX0_DMA_TX_CONTROL_STOP_SET(x) -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_OFFSET -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX1_DMA_RX_CONTROL_ADDRESS WLAN_MBOX1_DMA_RX_CONTROL_ADDRESS -#define MBOX1_DMA_RX_CONTROL_OFFSET WLAN_MBOX1_DMA_RX_CONTROL_OFFSET -#define MBOX1_DMA_RX_CONTROL_RESUME_MSB WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MSB -#define MBOX1_DMA_RX_CONTROL_RESUME_LSB WLAN_MBOX1_DMA_RX_CONTROL_RESUME_LSB -#define MBOX1_DMA_RX_CONTROL_RESUME_MASK WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MASK -#define MBOX1_DMA_RX_CONTROL_RESUME_GET(x) WLAN_MBOX1_DMA_RX_CONTROL_RESUME_GET(x) -#define MBOX1_DMA_RX_CONTROL_RESUME_SET(x) WLAN_MBOX1_DMA_RX_CONTROL_RESUME_SET(x) -#define MBOX1_DMA_RX_CONTROL_START_MSB WLAN_MBOX1_DMA_RX_CONTROL_START_MSB -#define MBOX1_DMA_RX_CONTROL_START_LSB WLAN_MBOX1_DMA_RX_CONTROL_START_LSB -#define MBOX1_DMA_RX_CONTROL_START_MASK WLAN_MBOX1_DMA_RX_CONTROL_START_MASK -#define MBOX1_DMA_RX_CONTROL_START_GET(x) WLAN_MBOX1_DMA_RX_CONTROL_START_GET(x) -#define MBOX1_DMA_RX_CONTROL_START_SET(x) WLAN_MBOX1_DMA_RX_CONTROL_START_SET(x) -#define MBOX1_DMA_RX_CONTROL_STOP_MSB WLAN_MBOX1_DMA_RX_CONTROL_STOP_MSB -#define MBOX1_DMA_RX_CONTROL_STOP_LSB WLAN_MBOX1_DMA_RX_CONTROL_STOP_LSB -#define MBOX1_DMA_RX_CONTROL_STOP_MASK WLAN_MBOX1_DMA_RX_CONTROL_STOP_MASK -#define MBOX1_DMA_RX_CONTROL_STOP_GET(x) WLAN_MBOX1_DMA_RX_CONTROL_STOP_GET(x) -#define MBOX1_DMA_RX_CONTROL_STOP_SET(x) WLAN_MBOX1_DMA_RX_CONTROL_STOP_SET(x) -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_OFFSET -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX1_DMA_TX_CONTROL_ADDRESS WLAN_MBOX1_DMA_TX_CONTROL_ADDRESS -#define MBOX1_DMA_TX_CONTROL_OFFSET WLAN_MBOX1_DMA_TX_CONTROL_OFFSET -#define MBOX1_DMA_TX_CONTROL_RESUME_MSB WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MSB -#define MBOX1_DMA_TX_CONTROL_RESUME_LSB WLAN_MBOX1_DMA_TX_CONTROL_RESUME_LSB -#define MBOX1_DMA_TX_CONTROL_RESUME_MASK WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MASK -#define MBOX1_DMA_TX_CONTROL_RESUME_GET(x) WLAN_MBOX1_DMA_TX_CONTROL_RESUME_GET(x) -#define MBOX1_DMA_TX_CONTROL_RESUME_SET(x) WLAN_MBOX1_DMA_TX_CONTROL_RESUME_SET(x) -#define MBOX1_DMA_TX_CONTROL_START_MSB WLAN_MBOX1_DMA_TX_CONTROL_START_MSB -#define MBOX1_DMA_TX_CONTROL_START_LSB WLAN_MBOX1_DMA_TX_CONTROL_START_LSB -#define MBOX1_DMA_TX_CONTROL_START_MASK WLAN_MBOX1_DMA_TX_CONTROL_START_MASK -#define MBOX1_DMA_TX_CONTROL_START_GET(x) WLAN_MBOX1_DMA_TX_CONTROL_START_GET(x) -#define MBOX1_DMA_TX_CONTROL_START_SET(x) WLAN_MBOX1_DMA_TX_CONTROL_START_SET(x) -#define MBOX1_DMA_TX_CONTROL_STOP_MSB WLAN_MBOX1_DMA_TX_CONTROL_STOP_MSB -#define MBOX1_DMA_TX_CONTROL_STOP_LSB WLAN_MBOX1_DMA_TX_CONTROL_STOP_LSB -#define MBOX1_DMA_TX_CONTROL_STOP_MASK WLAN_MBOX1_DMA_TX_CONTROL_STOP_MASK -#define MBOX1_DMA_TX_CONTROL_STOP_GET(x) WLAN_MBOX1_DMA_TX_CONTROL_STOP_GET(x) -#define MBOX1_DMA_TX_CONTROL_STOP_SET(x) WLAN_MBOX1_DMA_TX_CONTROL_STOP_SET(x) -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_OFFSET -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX2_DMA_RX_CONTROL_ADDRESS WLAN_MBOX2_DMA_RX_CONTROL_ADDRESS -#define MBOX2_DMA_RX_CONTROL_OFFSET WLAN_MBOX2_DMA_RX_CONTROL_OFFSET -#define MBOX2_DMA_RX_CONTROL_RESUME_MSB WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MSB -#define MBOX2_DMA_RX_CONTROL_RESUME_LSB WLAN_MBOX2_DMA_RX_CONTROL_RESUME_LSB -#define MBOX2_DMA_RX_CONTROL_RESUME_MASK WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MASK -#define MBOX2_DMA_RX_CONTROL_RESUME_GET(x) WLAN_MBOX2_DMA_RX_CONTROL_RESUME_GET(x) -#define MBOX2_DMA_RX_CONTROL_RESUME_SET(x) WLAN_MBOX2_DMA_RX_CONTROL_RESUME_SET(x) -#define MBOX2_DMA_RX_CONTROL_START_MSB WLAN_MBOX2_DMA_RX_CONTROL_START_MSB -#define MBOX2_DMA_RX_CONTROL_START_LSB WLAN_MBOX2_DMA_RX_CONTROL_START_LSB -#define MBOX2_DMA_RX_CONTROL_START_MASK WLAN_MBOX2_DMA_RX_CONTROL_START_MASK -#define MBOX2_DMA_RX_CONTROL_START_GET(x) WLAN_MBOX2_DMA_RX_CONTROL_START_GET(x) -#define MBOX2_DMA_RX_CONTROL_START_SET(x) WLAN_MBOX2_DMA_RX_CONTROL_START_SET(x) -#define MBOX2_DMA_RX_CONTROL_STOP_MSB WLAN_MBOX2_DMA_RX_CONTROL_STOP_MSB -#define MBOX2_DMA_RX_CONTROL_STOP_LSB WLAN_MBOX2_DMA_RX_CONTROL_STOP_LSB -#define MBOX2_DMA_RX_CONTROL_STOP_MASK WLAN_MBOX2_DMA_RX_CONTROL_STOP_MASK -#define MBOX2_DMA_RX_CONTROL_STOP_GET(x) WLAN_MBOX2_DMA_RX_CONTROL_STOP_GET(x) -#define MBOX2_DMA_RX_CONTROL_STOP_SET(x) WLAN_MBOX2_DMA_RX_CONTROL_STOP_SET(x) -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_OFFSET -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX2_DMA_TX_CONTROL_ADDRESS WLAN_MBOX2_DMA_TX_CONTROL_ADDRESS -#define MBOX2_DMA_TX_CONTROL_OFFSET WLAN_MBOX2_DMA_TX_CONTROL_OFFSET -#define MBOX2_DMA_TX_CONTROL_RESUME_MSB WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MSB -#define MBOX2_DMA_TX_CONTROL_RESUME_LSB WLAN_MBOX2_DMA_TX_CONTROL_RESUME_LSB -#define MBOX2_DMA_TX_CONTROL_RESUME_MASK WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MASK -#define MBOX2_DMA_TX_CONTROL_RESUME_GET(x) WLAN_MBOX2_DMA_TX_CONTROL_RESUME_GET(x) -#define MBOX2_DMA_TX_CONTROL_RESUME_SET(x) WLAN_MBOX2_DMA_TX_CONTROL_RESUME_SET(x) -#define MBOX2_DMA_TX_CONTROL_START_MSB WLAN_MBOX2_DMA_TX_CONTROL_START_MSB -#define MBOX2_DMA_TX_CONTROL_START_LSB WLAN_MBOX2_DMA_TX_CONTROL_START_LSB -#define MBOX2_DMA_TX_CONTROL_START_MASK WLAN_MBOX2_DMA_TX_CONTROL_START_MASK -#define MBOX2_DMA_TX_CONTROL_START_GET(x) WLAN_MBOX2_DMA_TX_CONTROL_START_GET(x) -#define MBOX2_DMA_TX_CONTROL_START_SET(x) WLAN_MBOX2_DMA_TX_CONTROL_START_SET(x) -#define MBOX2_DMA_TX_CONTROL_STOP_MSB WLAN_MBOX2_DMA_TX_CONTROL_STOP_MSB -#define MBOX2_DMA_TX_CONTROL_STOP_LSB WLAN_MBOX2_DMA_TX_CONTROL_STOP_LSB -#define MBOX2_DMA_TX_CONTROL_STOP_MASK WLAN_MBOX2_DMA_TX_CONTROL_STOP_MASK -#define MBOX2_DMA_TX_CONTROL_STOP_GET(x) WLAN_MBOX2_DMA_TX_CONTROL_STOP_GET(x) -#define MBOX2_DMA_TX_CONTROL_STOP_SET(x) WLAN_MBOX2_DMA_TX_CONTROL_STOP_SET(x) -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_OFFSET -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX3_DMA_RX_CONTROL_ADDRESS WLAN_MBOX3_DMA_RX_CONTROL_ADDRESS -#define MBOX3_DMA_RX_CONTROL_OFFSET WLAN_MBOX3_DMA_RX_CONTROL_OFFSET -#define MBOX3_DMA_RX_CONTROL_RESUME_MSB WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MSB -#define MBOX3_DMA_RX_CONTROL_RESUME_LSB WLAN_MBOX3_DMA_RX_CONTROL_RESUME_LSB -#define MBOX3_DMA_RX_CONTROL_RESUME_MASK WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MASK -#define MBOX3_DMA_RX_CONTROL_RESUME_GET(x) WLAN_MBOX3_DMA_RX_CONTROL_RESUME_GET(x) -#define MBOX3_DMA_RX_CONTROL_RESUME_SET(x) WLAN_MBOX3_DMA_RX_CONTROL_RESUME_SET(x) -#define MBOX3_DMA_RX_CONTROL_START_MSB WLAN_MBOX3_DMA_RX_CONTROL_START_MSB -#define MBOX3_DMA_RX_CONTROL_START_LSB WLAN_MBOX3_DMA_RX_CONTROL_START_LSB -#define MBOX3_DMA_RX_CONTROL_START_MASK WLAN_MBOX3_DMA_RX_CONTROL_START_MASK -#define MBOX3_DMA_RX_CONTROL_START_GET(x) WLAN_MBOX3_DMA_RX_CONTROL_START_GET(x) -#define MBOX3_DMA_RX_CONTROL_START_SET(x) WLAN_MBOX3_DMA_RX_CONTROL_START_SET(x) -#define MBOX3_DMA_RX_CONTROL_STOP_MSB WLAN_MBOX3_DMA_RX_CONTROL_STOP_MSB -#define MBOX3_DMA_RX_CONTROL_STOP_LSB WLAN_MBOX3_DMA_RX_CONTROL_STOP_LSB -#define MBOX3_DMA_RX_CONTROL_STOP_MASK WLAN_MBOX3_DMA_RX_CONTROL_STOP_MASK -#define MBOX3_DMA_RX_CONTROL_STOP_GET(x) WLAN_MBOX3_DMA_RX_CONTROL_STOP_GET(x) -#define MBOX3_DMA_RX_CONTROL_STOP_SET(x) WLAN_MBOX3_DMA_RX_CONTROL_STOP_SET(x) -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_OFFSET WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_OFFSET -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define MBOX3_DMA_TX_CONTROL_ADDRESS WLAN_MBOX3_DMA_TX_CONTROL_ADDRESS -#define MBOX3_DMA_TX_CONTROL_OFFSET WLAN_MBOX3_DMA_TX_CONTROL_OFFSET -#define MBOX3_DMA_TX_CONTROL_RESUME_MSB WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MSB -#define MBOX3_DMA_TX_CONTROL_RESUME_LSB WLAN_MBOX3_DMA_TX_CONTROL_RESUME_LSB -#define MBOX3_DMA_TX_CONTROL_RESUME_MASK WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MASK -#define MBOX3_DMA_TX_CONTROL_RESUME_GET(x) WLAN_MBOX3_DMA_TX_CONTROL_RESUME_GET(x) -#define MBOX3_DMA_TX_CONTROL_RESUME_SET(x) WLAN_MBOX3_DMA_TX_CONTROL_RESUME_SET(x) -#define MBOX3_DMA_TX_CONTROL_START_MSB WLAN_MBOX3_DMA_TX_CONTROL_START_MSB -#define MBOX3_DMA_TX_CONTROL_START_LSB WLAN_MBOX3_DMA_TX_CONTROL_START_LSB -#define MBOX3_DMA_TX_CONTROL_START_MASK WLAN_MBOX3_DMA_TX_CONTROL_START_MASK -#define MBOX3_DMA_TX_CONTROL_START_GET(x) WLAN_MBOX3_DMA_TX_CONTROL_START_GET(x) -#define MBOX3_DMA_TX_CONTROL_START_SET(x) WLAN_MBOX3_DMA_TX_CONTROL_START_SET(x) -#define MBOX3_DMA_TX_CONTROL_STOP_MSB WLAN_MBOX3_DMA_TX_CONTROL_STOP_MSB -#define MBOX3_DMA_TX_CONTROL_STOP_LSB WLAN_MBOX3_DMA_TX_CONTROL_STOP_LSB -#define MBOX3_DMA_TX_CONTROL_STOP_MASK WLAN_MBOX3_DMA_TX_CONTROL_STOP_MASK -#define MBOX3_DMA_TX_CONTROL_STOP_GET(x) WLAN_MBOX3_DMA_TX_CONTROL_STOP_GET(x) -#define MBOX3_DMA_TX_CONTROL_STOP_SET(x) WLAN_MBOX3_DMA_TX_CONTROL_STOP_SET(x) -#define MBOX_INT_STATUS_ADDRESS WLAN_MBOX_INT_STATUS_ADDRESS -#define MBOX_INT_STATUS_OFFSET WLAN_MBOX_INT_STATUS_OFFSET -#define MBOX_INT_STATUS_RX_DMA_COMPLETE_MSB WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MSB -#define MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB -#define MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK -#define MBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) -#define MBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) -#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB -#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB -#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK -#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) -#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) -#define MBOX_INT_STATUS_TX_DMA_COMPLETE_MSB WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MSB -#define MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB -#define MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK -#define MBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) -#define MBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) -#define MBOX_INT_STATUS_TX_OVERFLOW_MSB WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MSB -#define MBOX_INT_STATUS_TX_OVERFLOW_LSB WLAN_MBOX_INT_STATUS_TX_OVERFLOW_LSB -#define MBOX_INT_STATUS_TX_OVERFLOW_MASK WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MASK -#define MBOX_INT_STATUS_TX_OVERFLOW_GET(x) WLAN_MBOX_INT_STATUS_TX_OVERFLOW_GET(x) -#define MBOX_INT_STATUS_TX_OVERFLOW_SET(x) WLAN_MBOX_INT_STATUS_TX_OVERFLOW_SET(x) -#define MBOX_INT_STATUS_RX_UNDERFLOW_MSB WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MSB -#define MBOX_INT_STATUS_RX_UNDERFLOW_LSB WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_LSB -#define MBOX_INT_STATUS_RX_UNDERFLOW_MASK WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MASK -#define MBOX_INT_STATUS_RX_UNDERFLOW_GET(x) WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_GET(x) -#define MBOX_INT_STATUS_RX_UNDERFLOW_SET(x) WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_SET(x) -#define MBOX_INT_STATUS_TX_NOT_EMPTY_MSB WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MSB -#define MBOX_INT_STATUS_TX_NOT_EMPTY_LSB WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_LSB -#define MBOX_INT_STATUS_TX_NOT_EMPTY_MASK WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MASK -#define MBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) -#define MBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) -#define MBOX_INT_STATUS_RX_NOT_FULL_MSB WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MSB -#define MBOX_INT_STATUS_RX_NOT_FULL_LSB WLAN_MBOX_INT_STATUS_RX_NOT_FULL_LSB -#define MBOX_INT_STATUS_RX_NOT_FULL_MASK WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MASK -#define MBOX_INT_STATUS_RX_NOT_FULL_GET(x) WLAN_MBOX_INT_STATUS_RX_NOT_FULL_GET(x) -#define MBOX_INT_STATUS_RX_NOT_FULL_SET(x) WLAN_MBOX_INT_STATUS_RX_NOT_FULL_SET(x) -#define MBOX_INT_STATUS_HOST_MSB WLAN_MBOX_INT_STATUS_HOST_MSB -#define MBOX_INT_STATUS_HOST_LSB WLAN_MBOX_INT_STATUS_HOST_LSB -#define MBOX_INT_STATUS_HOST_MASK WLAN_MBOX_INT_STATUS_HOST_MASK -#define MBOX_INT_STATUS_HOST_GET(x) WLAN_MBOX_INT_STATUS_HOST_GET(x) -#define MBOX_INT_STATUS_HOST_SET(x) WLAN_MBOX_INT_STATUS_HOST_SET(x) -#define MBOX_INT_ENABLE_ADDRESS WLAN_MBOX_INT_ENABLE_ADDRESS -#define MBOX_INT_ENABLE_OFFSET WLAN_MBOX_INT_ENABLE_OFFSET -#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB -#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB -#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK -#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) -#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) -#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB -#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB -#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK -#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) -#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) -#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB -#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB -#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK -#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) -#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) -#define MBOX_INT_ENABLE_TX_OVERFLOW_MSB WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MSB -#define MBOX_INT_ENABLE_TX_OVERFLOW_LSB WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_LSB -#define MBOX_INT_ENABLE_TX_OVERFLOW_MASK WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MASK -#define MBOX_INT_ENABLE_TX_OVERFLOW_GET(x) WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_GET(x) -#define MBOX_INT_ENABLE_TX_OVERFLOW_SET(x) WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_SET(x) -#define MBOX_INT_ENABLE_RX_UNDERFLOW_MSB WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MSB -#define MBOX_INT_ENABLE_RX_UNDERFLOW_LSB WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_LSB -#define MBOX_INT_ENABLE_RX_UNDERFLOW_MASK WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MASK -#define MBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) -#define MBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) -#define MBOX_INT_ENABLE_TX_NOT_EMPTY_MSB WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MSB -#define MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB -#define MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK -#define MBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) -#define MBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) -#define MBOX_INT_ENABLE_RX_NOT_FULL_MSB WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MSB -#define MBOX_INT_ENABLE_RX_NOT_FULL_LSB WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_LSB -#define MBOX_INT_ENABLE_RX_NOT_FULL_MASK WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MASK -#define MBOX_INT_ENABLE_RX_NOT_FULL_GET(x) WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_GET(x) -#define MBOX_INT_ENABLE_RX_NOT_FULL_SET(x) WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_SET(x) -#define MBOX_INT_ENABLE_HOST_MSB WLAN_MBOX_INT_ENABLE_HOST_MSB -#define MBOX_INT_ENABLE_HOST_LSB WLAN_MBOX_INT_ENABLE_HOST_LSB -#define MBOX_INT_ENABLE_HOST_MASK WLAN_MBOX_INT_ENABLE_HOST_MASK -#define MBOX_INT_ENABLE_HOST_GET(x) WLAN_MBOX_INT_ENABLE_HOST_GET(x) -#define MBOX_INT_ENABLE_HOST_SET(x) WLAN_MBOX_INT_ENABLE_HOST_SET(x) -#define INT_HOST_ADDRESS WLAN_INT_HOST_ADDRESS -#define INT_HOST_OFFSET WLAN_INT_HOST_OFFSET -#define INT_HOST_VECTOR_MSB WLAN_INT_HOST_VECTOR_MSB -#define INT_HOST_VECTOR_LSB WLAN_INT_HOST_VECTOR_LSB -#define INT_HOST_VECTOR_MASK WLAN_INT_HOST_VECTOR_MASK -#define INT_HOST_VECTOR_GET(x) WLAN_INT_HOST_VECTOR_GET(x) -#define INT_HOST_VECTOR_SET(x) WLAN_INT_HOST_VECTOR_SET(x) -#define LOCAL_COUNT_ADDRESS WLAN_LOCAL_COUNT_ADDRESS -#define LOCAL_COUNT_OFFSET WLAN_LOCAL_COUNT_OFFSET -#define LOCAL_COUNT_VALUE_MSB WLAN_LOCAL_COUNT_VALUE_MSB -#define LOCAL_COUNT_VALUE_LSB WLAN_LOCAL_COUNT_VALUE_LSB -#define LOCAL_COUNT_VALUE_MASK WLAN_LOCAL_COUNT_VALUE_MASK -#define LOCAL_COUNT_VALUE_GET(x) WLAN_LOCAL_COUNT_VALUE_GET(x) -#define LOCAL_COUNT_VALUE_SET(x) WLAN_LOCAL_COUNT_VALUE_SET(x) -#define COUNT_INC_ADDRESS WLAN_COUNT_INC_ADDRESS -#define COUNT_INC_OFFSET WLAN_COUNT_INC_OFFSET -#define COUNT_INC_VALUE_MSB WLAN_COUNT_INC_VALUE_MSB -#define COUNT_INC_VALUE_LSB WLAN_COUNT_INC_VALUE_LSB -#define COUNT_INC_VALUE_MASK WLAN_COUNT_INC_VALUE_MASK -#define COUNT_INC_VALUE_GET(x) WLAN_COUNT_INC_VALUE_GET(x) -#define COUNT_INC_VALUE_SET(x) WLAN_COUNT_INC_VALUE_SET(x) -#define LOCAL_SCRATCH_ADDRESS WLAN_LOCAL_SCRATCH_ADDRESS -#define LOCAL_SCRATCH_OFFSET WLAN_LOCAL_SCRATCH_OFFSET -#define LOCAL_SCRATCH_VALUE_MSB WLAN_LOCAL_SCRATCH_VALUE_MSB -#define LOCAL_SCRATCH_VALUE_LSB WLAN_LOCAL_SCRATCH_VALUE_LSB -#define LOCAL_SCRATCH_VALUE_MASK WLAN_LOCAL_SCRATCH_VALUE_MASK -#define LOCAL_SCRATCH_VALUE_GET(x) WLAN_LOCAL_SCRATCH_VALUE_GET(x) -#define LOCAL_SCRATCH_VALUE_SET(x) WLAN_LOCAL_SCRATCH_VALUE_SET(x) -#define USE_LOCAL_BUS_ADDRESS WLAN_USE_LOCAL_BUS_ADDRESS -#define USE_LOCAL_BUS_OFFSET WLAN_USE_LOCAL_BUS_OFFSET -#define USE_LOCAL_BUS_PIN_INIT_MSB WLAN_USE_LOCAL_BUS_PIN_INIT_MSB -#define USE_LOCAL_BUS_PIN_INIT_LSB WLAN_USE_LOCAL_BUS_PIN_INIT_LSB -#define USE_LOCAL_BUS_PIN_INIT_MASK WLAN_USE_LOCAL_BUS_PIN_INIT_MASK -#define USE_LOCAL_BUS_PIN_INIT_GET(x) WLAN_USE_LOCAL_BUS_PIN_INIT_GET(x) -#define USE_LOCAL_BUS_PIN_INIT_SET(x) WLAN_USE_LOCAL_BUS_PIN_INIT_SET(x) -#define SDIO_CONFIG_ADDRESS WLAN_SDIO_CONFIG_ADDRESS -#define SDIO_CONFIG_OFFSET WLAN_SDIO_CONFIG_OFFSET -#define SDIO_CONFIG_CCCR_IOR1_MSB WLAN_SDIO_CONFIG_CCCR_IOR1_MSB -#define SDIO_CONFIG_CCCR_IOR1_LSB WLAN_SDIO_CONFIG_CCCR_IOR1_LSB -#define SDIO_CONFIG_CCCR_IOR1_MASK WLAN_SDIO_CONFIG_CCCR_IOR1_MASK -#define SDIO_CONFIG_CCCR_IOR1_GET(x) WLAN_SDIO_CONFIG_CCCR_IOR1_GET(x) -#define SDIO_CONFIG_CCCR_IOR1_SET(x) WLAN_SDIO_CONFIG_CCCR_IOR1_SET(x) -#define MBOX_DEBUG_ADDRESS WLAN_MBOX_DEBUG_ADDRESS -#define MBOX_DEBUG_OFFSET WLAN_MBOX_DEBUG_OFFSET -#define MBOX_DEBUG_SEL_MSB WLAN_MBOX_DEBUG_SEL_MSB -#define MBOX_DEBUG_SEL_LSB WLAN_MBOX_DEBUG_SEL_LSB -#define MBOX_DEBUG_SEL_MASK WLAN_MBOX_DEBUG_SEL_MASK -#define MBOX_DEBUG_SEL_GET(x) WLAN_MBOX_DEBUG_SEL_GET(x) -#define MBOX_DEBUG_SEL_SET(x) WLAN_MBOX_DEBUG_SEL_SET(x) -#define MBOX_FIFO_RESET_ADDRESS WLAN_MBOX_FIFO_RESET_ADDRESS -#define MBOX_FIFO_RESET_OFFSET WLAN_MBOX_FIFO_RESET_OFFSET -#define MBOX_FIFO_RESET_INIT_MSB WLAN_MBOX_FIFO_RESET_INIT_MSB -#define MBOX_FIFO_RESET_INIT_LSB WLAN_MBOX_FIFO_RESET_INIT_LSB -#define MBOX_FIFO_RESET_INIT_MASK WLAN_MBOX_FIFO_RESET_INIT_MASK -#define MBOX_FIFO_RESET_INIT_GET(x) WLAN_MBOX_FIFO_RESET_INIT_GET(x) -#define MBOX_FIFO_RESET_INIT_SET(x) WLAN_MBOX_FIFO_RESET_INIT_SET(x) -#define MBOX_TXFIFO_POP_ADDRESS WLAN_MBOX_TXFIFO_POP_ADDRESS -#define MBOX_TXFIFO_POP_OFFSET WLAN_MBOX_TXFIFO_POP_OFFSET -#define MBOX_TXFIFO_POP_DATA_MSB WLAN_MBOX_TXFIFO_POP_DATA_MSB -#define MBOX_TXFIFO_POP_DATA_LSB WLAN_MBOX_TXFIFO_POP_DATA_LSB -#define MBOX_TXFIFO_POP_DATA_MASK WLAN_MBOX_TXFIFO_POP_DATA_MASK -#define MBOX_TXFIFO_POP_DATA_GET(x) WLAN_MBOX_TXFIFO_POP_DATA_GET(x) -#define MBOX_TXFIFO_POP_DATA_SET(x) WLAN_MBOX_TXFIFO_POP_DATA_SET(x) -#define MBOX_RXFIFO_POP_ADDRESS WLAN_MBOX_RXFIFO_POP_ADDRESS -#define MBOX_RXFIFO_POP_OFFSET WLAN_MBOX_RXFIFO_POP_OFFSET -#define MBOX_RXFIFO_POP_DATA_MSB WLAN_MBOX_RXFIFO_POP_DATA_MSB -#define MBOX_RXFIFO_POP_DATA_LSB WLAN_MBOX_RXFIFO_POP_DATA_LSB -#define MBOX_RXFIFO_POP_DATA_MASK WLAN_MBOX_RXFIFO_POP_DATA_MASK -#define MBOX_RXFIFO_POP_DATA_GET(x) WLAN_MBOX_RXFIFO_POP_DATA_GET(x) -#define MBOX_RXFIFO_POP_DATA_SET(x) WLAN_MBOX_RXFIFO_POP_DATA_SET(x) -#define SDIO_DEBUG_ADDRESS WLAN_SDIO_DEBUG_ADDRESS -#define SDIO_DEBUG_OFFSET WLAN_SDIO_DEBUG_OFFSET -#define SDIO_DEBUG_SEL_MSB WLAN_SDIO_DEBUG_SEL_MSB -#define SDIO_DEBUG_SEL_LSB WLAN_SDIO_DEBUG_SEL_LSB -#define SDIO_DEBUG_SEL_MASK WLAN_SDIO_DEBUG_SEL_MASK -#define SDIO_DEBUG_SEL_GET(x) WLAN_SDIO_DEBUG_SEL_GET(x) -#define SDIO_DEBUG_SEL_SET(x) WLAN_SDIO_DEBUG_SEL_SET(x) -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define GMBOX0_DMA_RX_CONTROL_ADDRESS WLAN_GMBOX0_DMA_RX_CONTROL_ADDRESS -#define GMBOX0_DMA_RX_CONTROL_OFFSET WLAN_GMBOX0_DMA_RX_CONTROL_OFFSET -#define GMBOX0_DMA_RX_CONTROL_RESUME_MSB WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MSB -#define GMBOX0_DMA_RX_CONTROL_RESUME_LSB WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_LSB -#define GMBOX0_DMA_RX_CONTROL_RESUME_MASK WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MASK -#define GMBOX0_DMA_RX_CONTROL_RESUME_GET(x) WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_GET(x) -#define GMBOX0_DMA_RX_CONTROL_RESUME_SET(x) WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_SET(x) -#define GMBOX0_DMA_RX_CONTROL_START_MSB WLAN_GMBOX0_DMA_RX_CONTROL_START_MSB -#define GMBOX0_DMA_RX_CONTROL_START_LSB WLAN_GMBOX0_DMA_RX_CONTROL_START_LSB -#define GMBOX0_DMA_RX_CONTROL_START_MASK WLAN_GMBOX0_DMA_RX_CONTROL_START_MASK -#define GMBOX0_DMA_RX_CONTROL_START_GET(x) WLAN_GMBOX0_DMA_RX_CONTROL_START_GET(x) -#define GMBOX0_DMA_RX_CONTROL_START_SET(x) WLAN_GMBOX0_DMA_RX_CONTROL_START_SET(x) -#define GMBOX0_DMA_RX_CONTROL_STOP_MSB WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MSB -#define GMBOX0_DMA_RX_CONTROL_STOP_LSB WLAN_GMBOX0_DMA_RX_CONTROL_STOP_LSB -#define GMBOX0_DMA_RX_CONTROL_STOP_MASK WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MASK -#define GMBOX0_DMA_RX_CONTROL_STOP_GET(x) WLAN_GMBOX0_DMA_RX_CONTROL_STOP_GET(x) -#define GMBOX0_DMA_RX_CONTROL_STOP_SET(x) WLAN_GMBOX0_DMA_RX_CONTROL_STOP_SET(x) -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) -#define GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) -#define GMBOX0_DMA_TX_CONTROL_ADDRESS WLAN_GMBOX0_DMA_TX_CONTROL_ADDRESS -#define GMBOX0_DMA_TX_CONTROL_OFFSET WLAN_GMBOX0_DMA_TX_CONTROL_OFFSET -#define GMBOX0_DMA_TX_CONTROL_RESUME_MSB WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MSB -#define GMBOX0_DMA_TX_CONTROL_RESUME_LSB WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_LSB -#define GMBOX0_DMA_TX_CONTROL_RESUME_MASK WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MASK -#define GMBOX0_DMA_TX_CONTROL_RESUME_GET(x) WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_GET(x) -#define GMBOX0_DMA_TX_CONTROL_RESUME_SET(x) WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_SET(x) -#define GMBOX0_DMA_TX_CONTROL_START_MSB WLAN_GMBOX0_DMA_TX_CONTROL_START_MSB -#define GMBOX0_DMA_TX_CONTROL_START_LSB WLAN_GMBOX0_DMA_TX_CONTROL_START_LSB -#define GMBOX0_DMA_TX_CONTROL_START_MASK WLAN_GMBOX0_DMA_TX_CONTROL_START_MASK -#define GMBOX0_DMA_TX_CONTROL_START_GET(x) WLAN_GMBOX0_DMA_TX_CONTROL_START_GET(x) -#define GMBOX0_DMA_TX_CONTROL_START_SET(x) WLAN_GMBOX0_DMA_TX_CONTROL_START_SET(x) -#define GMBOX0_DMA_TX_CONTROL_STOP_MSB WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MSB -#define GMBOX0_DMA_TX_CONTROL_STOP_LSB WLAN_GMBOX0_DMA_TX_CONTROL_STOP_LSB -#define GMBOX0_DMA_TX_CONTROL_STOP_MASK WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MASK -#define GMBOX0_DMA_TX_CONTROL_STOP_GET(x) WLAN_GMBOX0_DMA_TX_CONTROL_STOP_GET(x) -#define GMBOX0_DMA_TX_CONTROL_STOP_SET(x) WLAN_GMBOX0_DMA_TX_CONTROL_STOP_SET(x) -#define GMBOX_INT_STATUS_ADDRESS WLAN_GMBOX_INT_STATUS_ADDRESS -#define GMBOX_INT_STATUS_OFFSET WLAN_GMBOX_INT_STATUS_OFFSET -#define GMBOX_INT_STATUS_TX_OVERFLOW_MSB WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MSB -#define GMBOX_INT_STATUS_TX_OVERFLOW_LSB WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_LSB -#define GMBOX_INT_STATUS_TX_OVERFLOW_MASK WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MASK -#define GMBOX_INT_STATUS_TX_OVERFLOW_GET(x) WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_GET(x) -#define GMBOX_INT_STATUS_TX_OVERFLOW_SET(x) WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_SET(x) -#define GMBOX_INT_STATUS_RX_UNDERFLOW_MSB WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MSB -#define GMBOX_INT_STATUS_RX_UNDERFLOW_LSB WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_LSB -#define GMBOX_INT_STATUS_RX_UNDERFLOW_MASK WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MASK -#define GMBOX_INT_STATUS_RX_UNDERFLOW_GET(x) WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_GET(x) -#define GMBOX_INT_STATUS_RX_UNDERFLOW_SET(x) WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_SET(x) -#define GMBOX_INT_STATUS_RX_DMA_COMPLETE_MSB WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MSB -#define GMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB -#define GMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK -#define GMBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) -#define GMBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) -#define GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB -#define GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB -#define GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK -#define GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) -#define GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) -#define GMBOX_INT_STATUS_TX_DMA_COMPLETE_MSB WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MSB -#define GMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB -#define GMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK -#define GMBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) -#define GMBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) -#define GMBOX_INT_STATUS_TX_NOT_EMPTY_MSB WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MSB -#define GMBOX_INT_STATUS_TX_NOT_EMPTY_LSB WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_LSB -#define GMBOX_INT_STATUS_TX_NOT_EMPTY_MASK WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MASK -#define GMBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) -#define GMBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) -#define GMBOX_INT_STATUS_RX_NOT_FULL_MSB WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MSB -#define GMBOX_INT_STATUS_RX_NOT_FULL_LSB WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_LSB -#define GMBOX_INT_STATUS_RX_NOT_FULL_MASK WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MASK -#define GMBOX_INT_STATUS_RX_NOT_FULL_GET(x) WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_GET(x) -#define GMBOX_INT_STATUS_RX_NOT_FULL_SET(x) WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_SET(x) -#define GMBOX_INT_ENABLE_ADDRESS WLAN_GMBOX_INT_ENABLE_ADDRESS -#define GMBOX_INT_ENABLE_OFFSET WLAN_GMBOX_INT_ENABLE_OFFSET -#define GMBOX_INT_ENABLE_TX_OVERFLOW_MSB WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MSB -#define GMBOX_INT_ENABLE_TX_OVERFLOW_LSB WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_LSB -#define GMBOX_INT_ENABLE_TX_OVERFLOW_MASK WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MASK -#define GMBOX_INT_ENABLE_TX_OVERFLOW_GET(x) WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_GET(x) -#define GMBOX_INT_ENABLE_TX_OVERFLOW_SET(x) WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_SET(x) -#define GMBOX_INT_ENABLE_RX_UNDERFLOW_MSB WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MSB -#define GMBOX_INT_ENABLE_RX_UNDERFLOW_LSB WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_LSB -#define GMBOX_INT_ENABLE_RX_UNDERFLOW_MASK WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MASK -#define GMBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) -#define GMBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) -#define GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB -#define GMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB -#define GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK -#define GMBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) -#define GMBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) -#define GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB -#define GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB -#define GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK -#define GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) -#define GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) -#define GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB -#define GMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB -#define GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK -#define GMBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) -#define GMBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) -#define GMBOX_INT_ENABLE_TX_NOT_EMPTY_MSB WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MSB -#define GMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB -#define GMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK -#define GMBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) -#define GMBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) -#define GMBOX_INT_ENABLE_RX_NOT_FULL_MSB WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MSB -#define GMBOX_INT_ENABLE_RX_NOT_FULL_LSB WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_LSB -#define GMBOX_INT_ENABLE_RX_NOT_FULL_MASK WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MASK -#define GMBOX_INT_ENABLE_RX_NOT_FULL_GET(x) WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_GET(x) -#define GMBOX_INT_ENABLE_RX_NOT_FULL_SET(x) WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_SET(x) -#define HOST_IF_WINDOW_ADDRESS WLAN_HOST_IF_WINDOW_ADDRESS -#define HOST_IF_WINDOW_OFFSET WLAN_HOST_IF_WINDOW_OFFSET -#define HOST_IF_WINDOW_DATA_MSB WLAN_HOST_IF_WINDOW_DATA_MSB -#define HOST_IF_WINDOW_DATA_LSB WLAN_HOST_IF_WINDOW_DATA_LSB -#define HOST_IF_WINDOW_DATA_MASK WLAN_HOST_IF_WINDOW_DATA_MASK -#define HOST_IF_WINDOW_DATA_GET(x) WLAN_HOST_IF_WINDOW_DATA_GET(x) -#define HOST_IF_WINDOW_DATA_SET(x) WLAN_HOST_IF_WINDOW_DATA_SET(x) - -#endif diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_host_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_host_reg.h deleted file mode 100644 index 038d0d01927..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_host_reg.h +++ /dev/null @@ -1,471 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#ifndef _MBOX_WLAN_HOST_REG_REG_H_ -#define _MBOX_WLAN_HOST_REG_REG_H_ - -#define HOST_INT_STATUS_ADDRESS 0x00000400 -#define HOST_INT_STATUS_OFFSET 0x00000400 -#define HOST_INT_STATUS_ERROR_MSB 7 -#define HOST_INT_STATUS_ERROR_LSB 7 -#define HOST_INT_STATUS_ERROR_MASK 0x00000080 -#define HOST_INT_STATUS_ERROR_GET(x) (((x) & HOST_INT_STATUS_ERROR_MASK) >> HOST_INT_STATUS_ERROR_LSB) -#define HOST_INT_STATUS_ERROR_SET(x) (((x) << HOST_INT_STATUS_ERROR_LSB) & HOST_INT_STATUS_ERROR_MASK) -#define HOST_INT_STATUS_CPU_MSB 6 -#define HOST_INT_STATUS_CPU_LSB 6 -#define HOST_INT_STATUS_CPU_MASK 0x00000040 -#define HOST_INT_STATUS_CPU_GET(x) (((x) & HOST_INT_STATUS_CPU_MASK) >> HOST_INT_STATUS_CPU_LSB) -#define HOST_INT_STATUS_CPU_SET(x) (((x) << HOST_INT_STATUS_CPU_LSB) & HOST_INT_STATUS_CPU_MASK) -#define HOST_INT_STATUS_INT_MSB 5 -#define HOST_INT_STATUS_INT_LSB 5 -#define HOST_INT_STATUS_INT_MASK 0x00000020 -#define HOST_INT_STATUS_INT_GET(x) (((x) & HOST_INT_STATUS_INT_MASK) >> HOST_INT_STATUS_INT_LSB) -#define HOST_INT_STATUS_INT_SET(x) (((x) << HOST_INT_STATUS_INT_LSB) & HOST_INT_STATUS_INT_MASK) -#define HOST_INT_STATUS_COUNTER_MSB 4 -#define HOST_INT_STATUS_COUNTER_LSB 4 -#define HOST_INT_STATUS_COUNTER_MASK 0x00000010 -#define HOST_INT_STATUS_COUNTER_GET(x) (((x) & HOST_INT_STATUS_COUNTER_MASK) >> HOST_INT_STATUS_COUNTER_LSB) -#define HOST_INT_STATUS_COUNTER_SET(x) (((x) << HOST_INT_STATUS_COUNTER_LSB) & HOST_INT_STATUS_COUNTER_MASK) -#define HOST_INT_STATUS_MBOX_DATA_MSB 3 -#define HOST_INT_STATUS_MBOX_DATA_LSB 0 -#define HOST_INT_STATUS_MBOX_DATA_MASK 0x0000000f -#define HOST_INT_STATUS_MBOX_DATA_GET(x) (((x) & HOST_INT_STATUS_MBOX_DATA_MASK) >> HOST_INT_STATUS_MBOX_DATA_LSB) -#define HOST_INT_STATUS_MBOX_DATA_SET(x) (((x) << HOST_INT_STATUS_MBOX_DATA_LSB) & HOST_INT_STATUS_MBOX_DATA_MASK) - -#define CPU_INT_STATUS_ADDRESS 0x00000401 -#define CPU_INT_STATUS_OFFSET 0x00000401 -#define CPU_INT_STATUS_BIT_MSB 7 -#define CPU_INT_STATUS_BIT_LSB 0 -#define CPU_INT_STATUS_BIT_MASK 0x000000ff -#define CPU_INT_STATUS_BIT_GET(x) (((x) & CPU_INT_STATUS_BIT_MASK) >> CPU_INT_STATUS_BIT_LSB) -#define CPU_INT_STATUS_BIT_SET(x) (((x) << CPU_INT_STATUS_BIT_LSB) & CPU_INT_STATUS_BIT_MASK) - -#define ERROR_INT_STATUS_ADDRESS 0x00000402 -#define ERROR_INT_STATUS_OFFSET 0x00000402 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_MSB 6 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_LSB 6 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_MASK 0x00000040 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_GET(x) (((x) & ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_MASK) >> ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_LSB) -#define ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_SET(x) (((x) << ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_LSB) & ERROR_INT_STATUS_UART_HCI_FRAMER_SYNC_ERROR_MASK) -#define ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_MSB 5 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_LSB 5 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_MASK 0x00000020 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_GET(x) (((x) & ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_MASK) >> ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_LSB) -#define ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_SET(x) (((x) << ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_LSB) & ERROR_INT_STATUS_UART_HCI_FRAMER_OVERFLOW_MASK) -#define ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_MSB 4 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_LSB 4 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_MASK 0x00000010 -#define ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_GET(x) (((x) & ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_MASK) >> ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_LSB) -#define ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_SET(x) (((x) << ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_LSB) & ERROR_INT_STATUS_UART_HCI_FRAMER_UNDERFLOW_MASK) -#define ERROR_INT_STATUS_SPI_MSB 3 -#define ERROR_INT_STATUS_SPI_LSB 3 -#define ERROR_INT_STATUS_SPI_MASK 0x00000008 -#define ERROR_INT_STATUS_SPI_GET(x) (((x) & ERROR_INT_STATUS_SPI_MASK) >> ERROR_INT_STATUS_SPI_LSB) -#define ERROR_INT_STATUS_SPI_SET(x) (((x) << ERROR_INT_STATUS_SPI_LSB) & ERROR_INT_STATUS_SPI_MASK) -#define ERROR_INT_STATUS_WAKEUP_MSB 2 -#define ERROR_INT_STATUS_WAKEUP_LSB 2 -#define ERROR_INT_STATUS_WAKEUP_MASK 0x00000004 -#define ERROR_INT_STATUS_WAKEUP_GET(x) (((x) & ERROR_INT_STATUS_WAKEUP_MASK) >> ERROR_INT_STATUS_WAKEUP_LSB) -#define ERROR_INT_STATUS_WAKEUP_SET(x) (((x) << ERROR_INT_STATUS_WAKEUP_LSB) & ERROR_INT_STATUS_WAKEUP_MASK) -#define ERROR_INT_STATUS_RX_UNDERFLOW_MSB 1 -#define ERROR_INT_STATUS_RX_UNDERFLOW_LSB 1 -#define ERROR_INT_STATUS_RX_UNDERFLOW_MASK 0x00000002 -#define ERROR_INT_STATUS_RX_UNDERFLOW_GET(x) (((x) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK) >> ERROR_INT_STATUS_RX_UNDERFLOW_LSB) -#define ERROR_INT_STATUS_RX_UNDERFLOW_SET(x) (((x) << ERROR_INT_STATUS_RX_UNDERFLOW_LSB) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK) -#define ERROR_INT_STATUS_TX_OVERFLOW_MSB 0 -#define ERROR_INT_STATUS_TX_OVERFLOW_LSB 0 -#define ERROR_INT_STATUS_TX_OVERFLOW_MASK 0x00000001 -#define ERROR_INT_STATUS_TX_OVERFLOW_GET(x) (((x) & ERROR_INT_STATUS_TX_OVERFLOW_MASK) >> ERROR_INT_STATUS_TX_OVERFLOW_LSB) -#define ERROR_INT_STATUS_TX_OVERFLOW_SET(x) (((x) << ERROR_INT_STATUS_TX_OVERFLOW_LSB) & ERROR_INT_STATUS_TX_OVERFLOW_MASK) - -#define COUNTER_INT_STATUS_ADDRESS 0x00000403 -#define COUNTER_INT_STATUS_OFFSET 0x00000403 -#define COUNTER_INT_STATUS_COUNTER_MSB 7 -#define COUNTER_INT_STATUS_COUNTER_LSB 0 -#define COUNTER_INT_STATUS_COUNTER_MASK 0x000000ff -#define COUNTER_INT_STATUS_COUNTER_GET(x) (((x) & COUNTER_INT_STATUS_COUNTER_MASK) >> COUNTER_INT_STATUS_COUNTER_LSB) -#define COUNTER_INT_STATUS_COUNTER_SET(x) (((x) << COUNTER_INT_STATUS_COUNTER_LSB) & COUNTER_INT_STATUS_COUNTER_MASK) - -#define MBOX_FRAME_ADDRESS 0x00000404 -#define MBOX_FRAME_OFFSET 0x00000404 -#define MBOX_FRAME_RX_EOM_MSB 7 -#define MBOX_FRAME_RX_EOM_LSB 4 -#define MBOX_FRAME_RX_EOM_MASK 0x000000f0 -#define MBOX_FRAME_RX_EOM_GET(x) (((x) & MBOX_FRAME_RX_EOM_MASK) >> MBOX_FRAME_RX_EOM_LSB) -#define MBOX_FRAME_RX_EOM_SET(x) (((x) << MBOX_FRAME_RX_EOM_LSB) & MBOX_FRAME_RX_EOM_MASK) -#define MBOX_FRAME_RX_SOM_MSB 3 -#define MBOX_FRAME_RX_SOM_LSB 0 -#define MBOX_FRAME_RX_SOM_MASK 0x0000000f -#define MBOX_FRAME_RX_SOM_GET(x) (((x) & MBOX_FRAME_RX_SOM_MASK) >> MBOX_FRAME_RX_SOM_LSB) -#define MBOX_FRAME_RX_SOM_SET(x) (((x) << MBOX_FRAME_RX_SOM_LSB) & MBOX_FRAME_RX_SOM_MASK) - -#define RX_LOOKAHEAD_VALID_ADDRESS 0x00000405 -#define RX_LOOKAHEAD_VALID_OFFSET 0x00000405 -#define RX_LOOKAHEAD_VALID_MBOX_MSB 3 -#define RX_LOOKAHEAD_VALID_MBOX_LSB 0 -#define RX_LOOKAHEAD_VALID_MBOX_MASK 0x0000000f -#define RX_LOOKAHEAD_VALID_MBOX_GET(x) (((x) & RX_LOOKAHEAD_VALID_MBOX_MASK) >> RX_LOOKAHEAD_VALID_MBOX_LSB) -#define RX_LOOKAHEAD_VALID_MBOX_SET(x) (((x) << RX_LOOKAHEAD_VALID_MBOX_LSB) & RX_LOOKAHEAD_VALID_MBOX_MASK) - -#define HOST_INT_STATUS2_ADDRESS 0x00000406 -#define HOST_INT_STATUS2_OFFSET 0x00000406 -#define HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_MSB 2 -#define HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_LSB 2 -#define HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_MASK 0x00000004 -#define HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_GET(x) (((x) & HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_MASK) >> HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_LSB) -#define HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_SET(x) (((x) << HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_LSB) & HOST_INT_STATUS2_GMBOX_RX_UNDERFLOW_MASK) -#define HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_MSB 1 -#define HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_LSB 1 -#define HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_MASK 0x00000002 -#define HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_GET(x) (((x) & HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_MASK) >> HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_LSB) -#define HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_SET(x) (((x) << HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_LSB) & HOST_INT_STATUS2_GMBOX_TX_OVERFLOW_MASK) -#define HOST_INT_STATUS2_GMBOX_DATA_MSB 0 -#define HOST_INT_STATUS2_GMBOX_DATA_LSB 0 -#define HOST_INT_STATUS2_GMBOX_DATA_MASK 0x00000001 -#define HOST_INT_STATUS2_GMBOX_DATA_GET(x) (((x) & HOST_INT_STATUS2_GMBOX_DATA_MASK) >> HOST_INT_STATUS2_GMBOX_DATA_LSB) -#define HOST_INT_STATUS2_GMBOX_DATA_SET(x) (((x) << HOST_INT_STATUS2_GMBOX_DATA_LSB) & HOST_INT_STATUS2_GMBOX_DATA_MASK) - -#define GMBOX_RX_AVAIL_ADDRESS 0x00000407 -#define GMBOX_RX_AVAIL_OFFSET 0x00000407 -#define GMBOX_RX_AVAIL_BYTE_MSB 6 -#define GMBOX_RX_AVAIL_BYTE_LSB 0 -#define GMBOX_RX_AVAIL_BYTE_MASK 0x0000007f -#define GMBOX_RX_AVAIL_BYTE_GET(x) (((x) & GMBOX_RX_AVAIL_BYTE_MASK) >> GMBOX_RX_AVAIL_BYTE_LSB) -#define GMBOX_RX_AVAIL_BYTE_SET(x) (((x) << GMBOX_RX_AVAIL_BYTE_LSB) & GMBOX_RX_AVAIL_BYTE_MASK) - -#define RX_LOOKAHEAD0_ADDRESS 0x00000408 -#define RX_LOOKAHEAD0_OFFSET 0x00000408 -#define RX_LOOKAHEAD0_DATA_MSB 7 -#define RX_LOOKAHEAD0_DATA_LSB 0 -#define RX_LOOKAHEAD0_DATA_MASK 0x000000ff -#define RX_LOOKAHEAD0_DATA_GET(x) (((x) & RX_LOOKAHEAD0_DATA_MASK) >> RX_LOOKAHEAD0_DATA_LSB) -#define RX_LOOKAHEAD0_DATA_SET(x) (((x) << RX_LOOKAHEAD0_DATA_LSB) & RX_LOOKAHEAD0_DATA_MASK) - -#define RX_LOOKAHEAD1_ADDRESS 0x0000040c -#define RX_LOOKAHEAD1_OFFSET 0x0000040c -#define RX_LOOKAHEAD1_DATA_MSB 7 -#define RX_LOOKAHEAD1_DATA_LSB 0 -#define RX_LOOKAHEAD1_DATA_MASK 0x000000ff -#define RX_LOOKAHEAD1_DATA_GET(x) (((x) & RX_LOOKAHEAD1_DATA_MASK) >> RX_LOOKAHEAD1_DATA_LSB) -#define RX_LOOKAHEAD1_DATA_SET(x) (((x) << RX_LOOKAHEAD1_DATA_LSB) & RX_LOOKAHEAD1_DATA_MASK) - -#define RX_LOOKAHEAD2_ADDRESS 0x00000410 -#define RX_LOOKAHEAD2_OFFSET 0x00000410 -#define RX_LOOKAHEAD2_DATA_MSB 7 -#define RX_LOOKAHEAD2_DATA_LSB 0 -#define RX_LOOKAHEAD2_DATA_MASK 0x000000ff -#define RX_LOOKAHEAD2_DATA_GET(x) (((x) & RX_LOOKAHEAD2_DATA_MASK) >> RX_LOOKAHEAD2_DATA_LSB) -#define RX_LOOKAHEAD2_DATA_SET(x) (((x) << RX_LOOKAHEAD2_DATA_LSB) & RX_LOOKAHEAD2_DATA_MASK) - -#define RX_LOOKAHEAD3_ADDRESS 0x00000414 -#define RX_LOOKAHEAD3_OFFSET 0x00000414 -#define RX_LOOKAHEAD3_DATA_MSB 7 -#define RX_LOOKAHEAD3_DATA_LSB 0 -#define RX_LOOKAHEAD3_DATA_MASK 0x000000ff -#define RX_LOOKAHEAD3_DATA_GET(x) (((x) & RX_LOOKAHEAD3_DATA_MASK) >> RX_LOOKAHEAD3_DATA_LSB) -#define RX_LOOKAHEAD3_DATA_SET(x) (((x) << RX_LOOKAHEAD3_DATA_LSB) & RX_LOOKAHEAD3_DATA_MASK) - -#define INT_STATUS_ENABLE_ADDRESS 0x00000418 -#define INT_STATUS_ENABLE_OFFSET 0x00000418 -#define INT_STATUS_ENABLE_ERROR_MSB 7 -#define INT_STATUS_ENABLE_ERROR_LSB 7 -#define INT_STATUS_ENABLE_ERROR_MASK 0x00000080 -#define INT_STATUS_ENABLE_ERROR_GET(x) (((x) & INT_STATUS_ENABLE_ERROR_MASK) >> INT_STATUS_ENABLE_ERROR_LSB) -#define INT_STATUS_ENABLE_ERROR_SET(x) (((x) << INT_STATUS_ENABLE_ERROR_LSB) & INT_STATUS_ENABLE_ERROR_MASK) -#define INT_STATUS_ENABLE_CPU_MSB 6 -#define INT_STATUS_ENABLE_CPU_LSB 6 -#define INT_STATUS_ENABLE_CPU_MASK 0x00000040 -#define INT_STATUS_ENABLE_CPU_GET(x) (((x) & INT_STATUS_ENABLE_CPU_MASK) >> INT_STATUS_ENABLE_CPU_LSB) -#define INT_STATUS_ENABLE_CPU_SET(x) (((x) << INT_STATUS_ENABLE_CPU_LSB) & INT_STATUS_ENABLE_CPU_MASK) -#define INT_STATUS_ENABLE_INT_MSB 5 -#define INT_STATUS_ENABLE_INT_LSB 5 -#define INT_STATUS_ENABLE_INT_MASK 0x00000020 -#define INT_STATUS_ENABLE_INT_GET(x) (((x) & INT_STATUS_ENABLE_INT_MASK) >> INT_STATUS_ENABLE_INT_LSB) -#define INT_STATUS_ENABLE_INT_SET(x) (((x) << INT_STATUS_ENABLE_INT_LSB) & INT_STATUS_ENABLE_INT_MASK) -#define INT_STATUS_ENABLE_COUNTER_MSB 4 -#define INT_STATUS_ENABLE_COUNTER_LSB 4 -#define INT_STATUS_ENABLE_COUNTER_MASK 0x00000010 -#define INT_STATUS_ENABLE_COUNTER_GET(x) (((x) & INT_STATUS_ENABLE_COUNTER_MASK) >> INT_STATUS_ENABLE_COUNTER_LSB) -#define INT_STATUS_ENABLE_COUNTER_SET(x) (((x) << INT_STATUS_ENABLE_COUNTER_LSB) & INT_STATUS_ENABLE_COUNTER_MASK) -#define INT_STATUS_ENABLE_MBOX_DATA_MSB 3 -#define INT_STATUS_ENABLE_MBOX_DATA_LSB 0 -#define INT_STATUS_ENABLE_MBOX_DATA_MASK 0x0000000f -#define INT_STATUS_ENABLE_MBOX_DATA_GET(x) (((x) & INT_STATUS_ENABLE_MBOX_DATA_MASK) >> INT_STATUS_ENABLE_MBOX_DATA_LSB) -#define INT_STATUS_ENABLE_MBOX_DATA_SET(x) (((x) << INT_STATUS_ENABLE_MBOX_DATA_LSB) & INT_STATUS_ENABLE_MBOX_DATA_MASK) - -#define CPU_INT_STATUS_ENABLE_ADDRESS 0x00000419 -#define CPU_INT_STATUS_ENABLE_OFFSET 0x00000419 -#define CPU_INT_STATUS_ENABLE_BIT_MSB 7 -#define CPU_INT_STATUS_ENABLE_BIT_LSB 0 -#define CPU_INT_STATUS_ENABLE_BIT_MASK 0x000000ff -#define CPU_INT_STATUS_ENABLE_BIT_GET(x) (((x) & CPU_INT_STATUS_ENABLE_BIT_MASK) >> CPU_INT_STATUS_ENABLE_BIT_LSB) -#define CPU_INT_STATUS_ENABLE_BIT_SET(x) (((x) << CPU_INT_STATUS_ENABLE_BIT_LSB) & CPU_INT_STATUS_ENABLE_BIT_MASK) - -#define ERROR_STATUS_ENABLE_ADDRESS 0x0000041a -#define ERROR_STATUS_ENABLE_OFFSET 0x0000041a -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_MSB 6 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_LSB 6 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_MASK 0x00000040 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_GET(x) (((x) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_MASK) >> ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_LSB) -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_SET(x) (((x) << ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_LSB) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_SYNC_ERROR_MASK) -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_MSB 5 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_LSB 5 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_MASK 0x00000020 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_MASK) >> ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_LSB) -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_LSB) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_OVERFLOW_MASK) -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_MSB 4 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_LSB 4 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_MASK 0x00000010 -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_MASK) >> ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_LSB) -#define ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_LSB) & ERROR_STATUS_ENABLE_UART_HCI_FRAMER_UNDERFLOW_MASK) -#define ERROR_STATUS_ENABLE_WAKEUP_MSB 2 -#define ERROR_STATUS_ENABLE_WAKEUP_LSB 2 -#define ERROR_STATUS_ENABLE_WAKEUP_MASK 0x00000004 -#define ERROR_STATUS_ENABLE_WAKEUP_GET(x) (((x) & ERROR_STATUS_ENABLE_WAKEUP_MASK) >> ERROR_STATUS_ENABLE_WAKEUP_LSB) -#define ERROR_STATUS_ENABLE_WAKEUP_SET(x) (((x) << ERROR_STATUS_ENABLE_WAKEUP_LSB) & ERROR_STATUS_ENABLE_WAKEUP_MASK) -#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MSB 1 -#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB 1 -#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x00000002 -#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK) >> ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB) -#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK) -#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MSB 0 -#define ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB 0 -#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK 0x00000001 -#define ERROR_STATUS_ENABLE_TX_OVERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK) >> ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB) -#define ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK) - -#define COUNTER_INT_STATUS_ENABLE_ADDRESS 0x0000041b -#define COUNTER_INT_STATUS_ENABLE_OFFSET 0x0000041b -#define COUNTER_INT_STATUS_ENABLE_BIT_MSB 7 -#define COUNTER_INT_STATUS_ENABLE_BIT_LSB 0 -#define COUNTER_INT_STATUS_ENABLE_BIT_MASK 0x000000ff -#define COUNTER_INT_STATUS_ENABLE_BIT_GET(x) (((x) & COUNTER_INT_STATUS_ENABLE_BIT_MASK) >> COUNTER_INT_STATUS_ENABLE_BIT_LSB) -#define COUNTER_INT_STATUS_ENABLE_BIT_SET(x) (((x) << COUNTER_INT_STATUS_ENABLE_BIT_LSB) & COUNTER_INT_STATUS_ENABLE_BIT_MASK) - -#define COUNT_ADDRESS 0x00000420 -#define COUNT_OFFSET 0x00000420 -#define COUNT_VALUE_MSB 7 -#define COUNT_VALUE_LSB 0 -#define COUNT_VALUE_MASK 0x000000ff -#define COUNT_VALUE_GET(x) (((x) & COUNT_VALUE_MASK) >> COUNT_VALUE_LSB) -#define COUNT_VALUE_SET(x) (((x) << COUNT_VALUE_LSB) & COUNT_VALUE_MASK) - -#define COUNT_DEC_ADDRESS 0x00000440 -#define COUNT_DEC_OFFSET 0x00000440 -#define COUNT_DEC_VALUE_MSB 7 -#define COUNT_DEC_VALUE_LSB 0 -#define COUNT_DEC_VALUE_MASK 0x000000ff -#define COUNT_DEC_VALUE_GET(x) (((x) & COUNT_DEC_VALUE_MASK) >> COUNT_DEC_VALUE_LSB) -#define COUNT_DEC_VALUE_SET(x) (((x) << COUNT_DEC_VALUE_LSB) & COUNT_DEC_VALUE_MASK) - -#define SCRATCH_ADDRESS 0x00000460 -#define SCRATCH_OFFSET 0x00000460 -#define SCRATCH_VALUE_MSB 7 -#define SCRATCH_VALUE_LSB 0 -#define SCRATCH_VALUE_MASK 0x000000ff -#define SCRATCH_VALUE_GET(x) (((x) & SCRATCH_VALUE_MASK) >> SCRATCH_VALUE_LSB) -#define SCRATCH_VALUE_SET(x) (((x) << SCRATCH_VALUE_LSB) & SCRATCH_VALUE_MASK) - -#define FIFO_TIMEOUT_ADDRESS 0x00000468 -#define FIFO_TIMEOUT_OFFSET 0x00000468 -#define FIFO_TIMEOUT_VALUE_MSB 7 -#define FIFO_TIMEOUT_VALUE_LSB 0 -#define FIFO_TIMEOUT_VALUE_MASK 0x000000ff -#define FIFO_TIMEOUT_VALUE_GET(x) (((x) & FIFO_TIMEOUT_VALUE_MASK) >> FIFO_TIMEOUT_VALUE_LSB) -#define FIFO_TIMEOUT_VALUE_SET(x) (((x) << FIFO_TIMEOUT_VALUE_LSB) & FIFO_TIMEOUT_VALUE_MASK) - -#define FIFO_TIMEOUT_ENABLE_ADDRESS 0x00000469 -#define FIFO_TIMEOUT_ENABLE_OFFSET 0x00000469 -#define FIFO_TIMEOUT_ENABLE_SET_MSB 0 -#define FIFO_TIMEOUT_ENABLE_SET_LSB 0 -#define FIFO_TIMEOUT_ENABLE_SET_MASK 0x00000001 -#define FIFO_TIMEOUT_ENABLE_SET_GET(x) (((x) & FIFO_TIMEOUT_ENABLE_SET_MASK) >> FIFO_TIMEOUT_ENABLE_SET_LSB) -#define FIFO_TIMEOUT_ENABLE_SET_SET(x) (((x) << FIFO_TIMEOUT_ENABLE_SET_LSB) & FIFO_TIMEOUT_ENABLE_SET_MASK) - -#define DISABLE_SLEEP_ADDRESS 0x0000046a -#define DISABLE_SLEEP_OFFSET 0x0000046a -#define DISABLE_SLEEP_FOR_INT_MSB 1 -#define DISABLE_SLEEP_FOR_INT_LSB 1 -#define DISABLE_SLEEP_FOR_INT_MASK 0x00000002 -#define DISABLE_SLEEP_FOR_INT_GET(x) (((x) & DISABLE_SLEEP_FOR_INT_MASK) >> DISABLE_SLEEP_FOR_INT_LSB) -#define DISABLE_SLEEP_FOR_INT_SET(x) (((x) << DISABLE_SLEEP_FOR_INT_LSB) & DISABLE_SLEEP_FOR_INT_MASK) -#define DISABLE_SLEEP_ON_MSB 0 -#define DISABLE_SLEEP_ON_LSB 0 -#define DISABLE_SLEEP_ON_MASK 0x00000001 -#define DISABLE_SLEEP_ON_GET(x) (((x) & DISABLE_SLEEP_ON_MASK) >> DISABLE_SLEEP_ON_LSB) -#define DISABLE_SLEEP_ON_SET(x) (((x) << DISABLE_SLEEP_ON_LSB) & DISABLE_SLEEP_ON_MASK) - -#define LOCAL_BUS_ADDRESS 0x00000470 -#define LOCAL_BUS_OFFSET 0x00000470 -#define LOCAL_BUS_STATE_MSB 1 -#define LOCAL_BUS_STATE_LSB 0 -#define LOCAL_BUS_STATE_MASK 0x00000003 -#define LOCAL_BUS_STATE_GET(x) (((x) & LOCAL_BUS_STATE_MASK) >> LOCAL_BUS_STATE_LSB) -#define LOCAL_BUS_STATE_SET(x) (((x) << LOCAL_BUS_STATE_LSB) & LOCAL_BUS_STATE_MASK) - -#define INT_WLAN_ADDRESS 0x00000472 -#define INT_WLAN_OFFSET 0x00000472 -#define INT_WLAN_VECTOR_MSB 7 -#define INT_WLAN_VECTOR_LSB 0 -#define INT_WLAN_VECTOR_MASK 0x000000ff -#define INT_WLAN_VECTOR_GET(x) (((x) & INT_WLAN_VECTOR_MASK) >> INT_WLAN_VECTOR_LSB) -#define INT_WLAN_VECTOR_SET(x) (((x) << INT_WLAN_VECTOR_LSB) & INT_WLAN_VECTOR_MASK) - -#define WINDOW_DATA_ADDRESS 0x00000474 -#define WINDOW_DATA_OFFSET 0x00000474 -#define WINDOW_DATA_DATA_MSB 7 -#define WINDOW_DATA_DATA_LSB 0 -#define WINDOW_DATA_DATA_MASK 0x000000ff -#define WINDOW_DATA_DATA_GET(x) (((x) & WINDOW_DATA_DATA_MASK) >> WINDOW_DATA_DATA_LSB) -#define WINDOW_DATA_DATA_SET(x) (((x) << WINDOW_DATA_DATA_LSB) & WINDOW_DATA_DATA_MASK) - -#define WINDOW_WRITE_ADDR_ADDRESS 0x00000478 -#define WINDOW_WRITE_ADDR_OFFSET 0x00000478 -#define WINDOW_WRITE_ADDR_ADDR_MSB 7 -#define WINDOW_WRITE_ADDR_ADDR_LSB 0 -#define WINDOW_WRITE_ADDR_ADDR_MASK 0x000000ff -#define WINDOW_WRITE_ADDR_ADDR_GET(x) (((x) & WINDOW_WRITE_ADDR_ADDR_MASK) >> WINDOW_WRITE_ADDR_ADDR_LSB) -#define WINDOW_WRITE_ADDR_ADDR_SET(x) (((x) << WINDOW_WRITE_ADDR_ADDR_LSB) & WINDOW_WRITE_ADDR_ADDR_MASK) - -#define WINDOW_READ_ADDR_ADDRESS 0x0000047c -#define WINDOW_READ_ADDR_OFFSET 0x0000047c -#define WINDOW_READ_ADDR_ADDR_MSB 7 -#define WINDOW_READ_ADDR_ADDR_LSB 0 -#define WINDOW_READ_ADDR_ADDR_MASK 0x000000ff -#define WINDOW_READ_ADDR_ADDR_GET(x) (((x) & WINDOW_READ_ADDR_ADDR_MASK) >> WINDOW_READ_ADDR_ADDR_LSB) -#define WINDOW_READ_ADDR_ADDR_SET(x) (((x) << WINDOW_READ_ADDR_ADDR_LSB) & WINDOW_READ_ADDR_ADDR_MASK) - -#define HOST_CTRL_SPI_CONFIG_ADDRESS 0x00000480 -#define HOST_CTRL_SPI_CONFIG_OFFSET 0x00000480 -#define HOST_CTRL_SPI_CONFIG_SPI_RESET_MSB 4 -#define HOST_CTRL_SPI_CONFIG_SPI_RESET_LSB 4 -#define HOST_CTRL_SPI_CONFIG_SPI_RESET_MASK 0x00000010 -#define HOST_CTRL_SPI_CONFIG_SPI_RESET_GET(x) (((x) & HOST_CTRL_SPI_CONFIG_SPI_RESET_MASK) >> HOST_CTRL_SPI_CONFIG_SPI_RESET_LSB) -#define HOST_CTRL_SPI_CONFIG_SPI_RESET_SET(x) (((x) << HOST_CTRL_SPI_CONFIG_SPI_RESET_LSB) & HOST_CTRL_SPI_CONFIG_SPI_RESET_MASK) -#define HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_MSB 3 -#define HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_LSB 3 -#define HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_MASK 0x00000008 -#define HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_GET(x) (((x) & HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_MASK) >> HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_LSB) -#define HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_SET(x) (((x) << HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_LSB) & HOST_CTRL_SPI_CONFIG_INTERRUPT_ENABLE_MASK) -#define HOST_CTRL_SPI_CONFIG_TEST_MODE_MSB 2 -#define HOST_CTRL_SPI_CONFIG_TEST_MODE_LSB 2 -#define HOST_CTRL_SPI_CONFIG_TEST_MODE_MASK 0x00000004 -#define HOST_CTRL_SPI_CONFIG_TEST_MODE_GET(x) (((x) & HOST_CTRL_SPI_CONFIG_TEST_MODE_MASK) >> HOST_CTRL_SPI_CONFIG_TEST_MODE_LSB) -#define HOST_CTRL_SPI_CONFIG_TEST_MODE_SET(x) (((x) << HOST_CTRL_SPI_CONFIG_TEST_MODE_LSB) & HOST_CTRL_SPI_CONFIG_TEST_MODE_MASK) -#define HOST_CTRL_SPI_CONFIG_DATA_SIZE_MSB 1 -#define HOST_CTRL_SPI_CONFIG_DATA_SIZE_LSB 0 -#define HOST_CTRL_SPI_CONFIG_DATA_SIZE_MASK 0x00000003 -#define HOST_CTRL_SPI_CONFIG_DATA_SIZE_GET(x) (((x) & HOST_CTRL_SPI_CONFIG_DATA_SIZE_MASK) >> HOST_CTRL_SPI_CONFIG_DATA_SIZE_LSB) -#define HOST_CTRL_SPI_CONFIG_DATA_SIZE_SET(x) (((x) << HOST_CTRL_SPI_CONFIG_DATA_SIZE_LSB) & HOST_CTRL_SPI_CONFIG_DATA_SIZE_MASK) - -#define HOST_CTRL_SPI_STATUS_ADDRESS 0x00000481 -#define HOST_CTRL_SPI_STATUS_OFFSET 0x00000481 -#define HOST_CTRL_SPI_STATUS_ADDR_ERR_MSB 3 -#define HOST_CTRL_SPI_STATUS_ADDR_ERR_LSB 3 -#define HOST_CTRL_SPI_STATUS_ADDR_ERR_MASK 0x00000008 -#define HOST_CTRL_SPI_STATUS_ADDR_ERR_GET(x) (((x) & HOST_CTRL_SPI_STATUS_ADDR_ERR_MASK) >> HOST_CTRL_SPI_STATUS_ADDR_ERR_LSB) -#define HOST_CTRL_SPI_STATUS_ADDR_ERR_SET(x) (((x) << HOST_CTRL_SPI_STATUS_ADDR_ERR_LSB) & HOST_CTRL_SPI_STATUS_ADDR_ERR_MASK) -#define HOST_CTRL_SPI_STATUS_RD_ERR_MSB 2 -#define HOST_CTRL_SPI_STATUS_RD_ERR_LSB 2 -#define HOST_CTRL_SPI_STATUS_RD_ERR_MASK 0x00000004 -#define HOST_CTRL_SPI_STATUS_RD_ERR_GET(x) (((x) & HOST_CTRL_SPI_STATUS_RD_ERR_MASK) >> HOST_CTRL_SPI_STATUS_RD_ERR_LSB) -#define HOST_CTRL_SPI_STATUS_RD_ERR_SET(x) (((x) << HOST_CTRL_SPI_STATUS_RD_ERR_LSB) & HOST_CTRL_SPI_STATUS_RD_ERR_MASK) -#define HOST_CTRL_SPI_STATUS_WR_ERR_MSB 1 -#define HOST_CTRL_SPI_STATUS_WR_ERR_LSB 1 -#define HOST_CTRL_SPI_STATUS_WR_ERR_MASK 0x00000002 -#define HOST_CTRL_SPI_STATUS_WR_ERR_GET(x) (((x) & HOST_CTRL_SPI_STATUS_WR_ERR_MASK) >> HOST_CTRL_SPI_STATUS_WR_ERR_LSB) -#define HOST_CTRL_SPI_STATUS_WR_ERR_SET(x) (((x) << HOST_CTRL_SPI_STATUS_WR_ERR_LSB) & HOST_CTRL_SPI_STATUS_WR_ERR_MASK) -#define HOST_CTRL_SPI_STATUS_READY_MSB 0 -#define HOST_CTRL_SPI_STATUS_READY_LSB 0 -#define HOST_CTRL_SPI_STATUS_READY_MASK 0x00000001 -#define HOST_CTRL_SPI_STATUS_READY_GET(x) (((x) & HOST_CTRL_SPI_STATUS_READY_MASK) >> HOST_CTRL_SPI_STATUS_READY_LSB) -#define HOST_CTRL_SPI_STATUS_READY_SET(x) (((x) << HOST_CTRL_SPI_STATUS_READY_LSB) & HOST_CTRL_SPI_STATUS_READY_MASK) - -#define NON_ASSOC_SLEEP_EN_ADDRESS 0x00000482 -#define NON_ASSOC_SLEEP_EN_OFFSET 0x00000482 -#define NON_ASSOC_SLEEP_EN_BIT_MSB 0 -#define NON_ASSOC_SLEEP_EN_BIT_LSB 0 -#define NON_ASSOC_SLEEP_EN_BIT_MASK 0x00000001 -#define NON_ASSOC_SLEEP_EN_BIT_GET(x) (((x) & NON_ASSOC_SLEEP_EN_BIT_MASK) >> NON_ASSOC_SLEEP_EN_BIT_LSB) -#define NON_ASSOC_SLEEP_EN_BIT_SET(x) (((x) << NON_ASSOC_SLEEP_EN_BIT_LSB) & NON_ASSOC_SLEEP_EN_BIT_MASK) - -#define CPU_DBG_SEL_ADDRESS 0x00000483 -#define CPU_DBG_SEL_OFFSET 0x00000483 -#define CPU_DBG_SEL_BIT_MSB 5 -#define CPU_DBG_SEL_BIT_LSB 0 -#define CPU_DBG_SEL_BIT_MASK 0x0000003f -#define CPU_DBG_SEL_BIT_GET(x) (((x) & CPU_DBG_SEL_BIT_MASK) >> CPU_DBG_SEL_BIT_LSB) -#define CPU_DBG_SEL_BIT_SET(x) (((x) << CPU_DBG_SEL_BIT_LSB) & CPU_DBG_SEL_BIT_MASK) - -#define CPU_DBG_ADDRESS 0x00000484 -#define CPU_DBG_OFFSET 0x00000484 -#define CPU_DBG_DATA_MSB 7 -#define CPU_DBG_DATA_LSB 0 -#define CPU_DBG_DATA_MASK 0x000000ff -#define CPU_DBG_DATA_GET(x) (((x) & CPU_DBG_DATA_MASK) >> CPU_DBG_DATA_LSB) -#define CPU_DBG_DATA_SET(x) (((x) << CPU_DBG_DATA_LSB) & CPU_DBG_DATA_MASK) - -#define INT_STATUS2_ENABLE_ADDRESS 0x00000488 -#define INT_STATUS2_ENABLE_OFFSET 0x00000488 -#define INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_MSB 2 -#define INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_LSB 2 -#define INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_MASK 0x00000004 -#define INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_GET(x) (((x) & INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_MASK) >> INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_LSB) -#define INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_SET(x) (((x) << INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_LSB) & INT_STATUS2_ENABLE_GMBOX_RX_UNDERFLOW_MASK) -#define INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_MSB 1 -#define INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_LSB 1 -#define INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_MASK 0x00000002 -#define INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_GET(x) (((x) & INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_MASK) >> INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_LSB) -#define INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_SET(x) (((x) << INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_LSB) & INT_STATUS2_ENABLE_GMBOX_TX_OVERFLOW_MASK) -#define INT_STATUS2_ENABLE_GMBOX_DATA_MSB 0 -#define INT_STATUS2_ENABLE_GMBOX_DATA_LSB 0 -#define INT_STATUS2_ENABLE_GMBOX_DATA_MASK 0x00000001 -#define INT_STATUS2_ENABLE_GMBOX_DATA_GET(x) (((x) & INT_STATUS2_ENABLE_GMBOX_DATA_MASK) >> INT_STATUS2_ENABLE_GMBOX_DATA_LSB) -#define INT_STATUS2_ENABLE_GMBOX_DATA_SET(x) (((x) << INT_STATUS2_ENABLE_GMBOX_DATA_LSB) & INT_STATUS2_ENABLE_GMBOX_DATA_MASK) - -#define GMBOX_RX_LOOKAHEAD_ADDRESS 0x00000490 -#define GMBOX_RX_LOOKAHEAD_OFFSET 0x00000490 -#define GMBOX_RX_LOOKAHEAD_DATA_MSB 7 -#define GMBOX_RX_LOOKAHEAD_DATA_LSB 0 -#define GMBOX_RX_LOOKAHEAD_DATA_MASK 0x000000ff -#define GMBOX_RX_LOOKAHEAD_DATA_GET(x) (((x) & GMBOX_RX_LOOKAHEAD_DATA_MASK) >> GMBOX_RX_LOOKAHEAD_DATA_LSB) -#define GMBOX_RX_LOOKAHEAD_DATA_SET(x) (((x) << GMBOX_RX_LOOKAHEAD_DATA_LSB) & GMBOX_RX_LOOKAHEAD_DATA_MASK) - -#define GMBOX_RX_LOOKAHEAD_MUX_ADDRESS 0x00000498 -#define GMBOX_RX_LOOKAHEAD_MUX_OFFSET 0x00000498 -#define GMBOX_RX_LOOKAHEAD_MUX_SEL_MSB 0 -#define GMBOX_RX_LOOKAHEAD_MUX_SEL_LSB 0 -#define GMBOX_RX_LOOKAHEAD_MUX_SEL_MASK 0x00000001 -#define GMBOX_RX_LOOKAHEAD_MUX_SEL_GET(x) (((x) & GMBOX_RX_LOOKAHEAD_MUX_SEL_MASK) >> GMBOX_RX_LOOKAHEAD_MUX_SEL_LSB) -#define GMBOX_RX_LOOKAHEAD_MUX_SEL_SET(x) (((x) << GMBOX_RX_LOOKAHEAD_MUX_SEL_LSB) & GMBOX_RX_LOOKAHEAD_MUX_SEL_MASK) - -#define CIS_WINDOW_ADDRESS 0x00000600 -#define CIS_WINDOW_OFFSET 0x00000600 -#define CIS_WINDOW_DATA_MSB 7 -#define CIS_WINDOW_DATA_LSB 0 -#define CIS_WINDOW_DATA_MASK 0x000000ff -#define CIS_WINDOW_DATA_GET(x) (((x) & CIS_WINDOW_DATA_MASK) >> CIS_WINDOW_DATA_LSB) -#define CIS_WINDOW_DATA_SET(x) (((x) << CIS_WINDOW_DATA_LSB) & CIS_WINDOW_DATA_MASK) - - -#endif /* _MBOX_WLAN_HOST_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_reg.h deleted file mode 100644 index f5167b9ae8d..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_reg.h +++ /dev/null @@ -1,589 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#ifndef _MBOX_WLAN_REG_REG_H_ -#define _MBOX_WLAN_REG_REG_H_ - -#define WLAN_MBOX_FIFO_ADDRESS 0x00000000 -#define WLAN_MBOX_FIFO_OFFSET 0x00000000 -#define WLAN_MBOX_FIFO_DATA_MSB 19 -#define WLAN_MBOX_FIFO_DATA_LSB 0 -#define WLAN_MBOX_FIFO_DATA_MASK 0x000fffff -#define WLAN_MBOX_FIFO_DATA_GET(x) (((x) & WLAN_MBOX_FIFO_DATA_MASK) >> WLAN_MBOX_FIFO_DATA_LSB) -#define WLAN_MBOX_FIFO_DATA_SET(x) (((x) << WLAN_MBOX_FIFO_DATA_LSB) & WLAN_MBOX_FIFO_DATA_MASK) - -#define WLAN_MBOX_FIFO_STATUS_ADDRESS 0x00000010 -#define WLAN_MBOX_FIFO_STATUS_OFFSET 0x00000010 -#define WLAN_MBOX_FIFO_STATUS_EMPTY_MSB 19 -#define WLAN_MBOX_FIFO_STATUS_EMPTY_LSB 16 -#define WLAN_MBOX_FIFO_STATUS_EMPTY_MASK 0x000f0000 -#define WLAN_MBOX_FIFO_STATUS_EMPTY_GET(x) (((x) & WLAN_MBOX_FIFO_STATUS_EMPTY_MASK) >> WLAN_MBOX_FIFO_STATUS_EMPTY_LSB) -#define WLAN_MBOX_FIFO_STATUS_EMPTY_SET(x) (((x) << WLAN_MBOX_FIFO_STATUS_EMPTY_LSB) & WLAN_MBOX_FIFO_STATUS_EMPTY_MASK) -#define WLAN_MBOX_FIFO_STATUS_FULL_MSB 15 -#define WLAN_MBOX_FIFO_STATUS_FULL_LSB 12 -#define WLAN_MBOX_FIFO_STATUS_FULL_MASK 0x0000f000 -#define WLAN_MBOX_FIFO_STATUS_FULL_GET(x) (((x) & WLAN_MBOX_FIFO_STATUS_FULL_MASK) >> WLAN_MBOX_FIFO_STATUS_FULL_LSB) -#define WLAN_MBOX_FIFO_STATUS_FULL_SET(x) (((x) << WLAN_MBOX_FIFO_STATUS_FULL_LSB) & WLAN_MBOX_FIFO_STATUS_FULL_MASK) - -#define WLAN_MBOX_DMA_POLICY_ADDRESS 0x00000014 -#define WLAN_MBOX_DMA_POLICY_OFFSET 0x00000014 -#define WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MSB 3 -#define WLAN_MBOX_DMA_POLICY_TX_QUANTUM_LSB 3 -#define WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MASK 0x00000008 -#define WLAN_MBOX_DMA_POLICY_TX_QUANTUM_GET(x) (((x) & WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MASK) >> WLAN_MBOX_DMA_POLICY_TX_QUANTUM_LSB) -#define WLAN_MBOX_DMA_POLICY_TX_QUANTUM_SET(x) (((x) << WLAN_MBOX_DMA_POLICY_TX_QUANTUM_LSB) & WLAN_MBOX_DMA_POLICY_TX_QUANTUM_MASK) -#define WLAN_MBOX_DMA_POLICY_TX_ORDER_MSB 2 -#define WLAN_MBOX_DMA_POLICY_TX_ORDER_LSB 2 -#define WLAN_MBOX_DMA_POLICY_TX_ORDER_MASK 0x00000004 -#define WLAN_MBOX_DMA_POLICY_TX_ORDER_GET(x) (((x) & WLAN_MBOX_DMA_POLICY_TX_ORDER_MASK) >> WLAN_MBOX_DMA_POLICY_TX_ORDER_LSB) -#define WLAN_MBOX_DMA_POLICY_TX_ORDER_SET(x) (((x) << WLAN_MBOX_DMA_POLICY_TX_ORDER_LSB) & WLAN_MBOX_DMA_POLICY_TX_ORDER_MASK) -#define WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MSB 1 -#define WLAN_MBOX_DMA_POLICY_RX_QUANTUM_LSB 1 -#define WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MASK 0x00000002 -#define WLAN_MBOX_DMA_POLICY_RX_QUANTUM_GET(x) (((x) & WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MASK) >> WLAN_MBOX_DMA_POLICY_RX_QUANTUM_LSB) -#define WLAN_MBOX_DMA_POLICY_RX_QUANTUM_SET(x) (((x) << WLAN_MBOX_DMA_POLICY_RX_QUANTUM_LSB) & WLAN_MBOX_DMA_POLICY_RX_QUANTUM_MASK) -#define WLAN_MBOX_DMA_POLICY_RX_ORDER_MSB 0 -#define WLAN_MBOX_DMA_POLICY_RX_ORDER_LSB 0 -#define WLAN_MBOX_DMA_POLICY_RX_ORDER_MASK 0x00000001 -#define WLAN_MBOX_DMA_POLICY_RX_ORDER_GET(x) (((x) & WLAN_MBOX_DMA_POLICY_RX_ORDER_MASK) >> WLAN_MBOX_DMA_POLICY_RX_ORDER_LSB) -#define WLAN_MBOX_DMA_POLICY_RX_ORDER_SET(x) (((x) << WLAN_MBOX_DMA_POLICY_RX_ORDER_LSB) & WLAN_MBOX_DMA_POLICY_RX_ORDER_MASK) - -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS 0x00000018 -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET 0x00000018 -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX0_DMA_RX_CONTROL_ADDRESS 0x0000001c -#define WLAN_MBOX0_DMA_RX_CONTROL_OFFSET 0x0000001c -#define WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX0_DMA_RX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX0_DMA_RX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MASK) >> WLAN_MBOX0_DMA_RX_CONTROL_RESUME_LSB) -#define WLAN_MBOX0_DMA_RX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX0_DMA_RX_CONTROL_RESUME_LSB) & WLAN_MBOX0_DMA_RX_CONTROL_RESUME_MASK) -#define WLAN_MBOX0_DMA_RX_CONTROL_START_MSB 1 -#define WLAN_MBOX0_DMA_RX_CONTROL_START_LSB 1 -#define WLAN_MBOX0_DMA_RX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX0_DMA_RX_CONTROL_START_GET(x) (((x) & WLAN_MBOX0_DMA_RX_CONTROL_START_MASK) >> WLAN_MBOX0_DMA_RX_CONTROL_START_LSB) -#define WLAN_MBOX0_DMA_RX_CONTROL_START_SET(x) (((x) << WLAN_MBOX0_DMA_RX_CONTROL_START_LSB) & WLAN_MBOX0_DMA_RX_CONTROL_START_MASK) -#define WLAN_MBOX0_DMA_RX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX0_DMA_RX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX0_DMA_RX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX0_DMA_RX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX0_DMA_RX_CONTROL_STOP_MASK) >> WLAN_MBOX0_DMA_RX_CONTROL_STOP_LSB) -#define WLAN_MBOX0_DMA_RX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX0_DMA_RX_CONTROL_STOP_LSB) & WLAN_MBOX0_DMA_RX_CONTROL_STOP_MASK) - -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS 0x00000020 -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET 0x00000020 -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX0_DMA_TX_CONTROL_ADDRESS 0x00000024 -#define WLAN_MBOX0_DMA_TX_CONTROL_OFFSET 0x00000024 -#define WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX0_DMA_TX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX0_DMA_TX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MASK) >> WLAN_MBOX0_DMA_TX_CONTROL_RESUME_LSB) -#define WLAN_MBOX0_DMA_TX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX0_DMA_TX_CONTROL_RESUME_LSB) & WLAN_MBOX0_DMA_TX_CONTROL_RESUME_MASK) -#define WLAN_MBOX0_DMA_TX_CONTROL_START_MSB 1 -#define WLAN_MBOX0_DMA_TX_CONTROL_START_LSB 1 -#define WLAN_MBOX0_DMA_TX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX0_DMA_TX_CONTROL_START_GET(x) (((x) & WLAN_MBOX0_DMA_TX_CONTROL_START_MASK) >> WLAN_MBOX0_DMA_TX_CONTROL_START_LSB) -#define WLAN_MBOX0_DMA_TX_CONTROL_START_SET(x) (((x) << WLAN_MBOX0_DMA_TX_CONTROL_START_LSB) & WLAN_MBOX0_DMA_TX_CONTROL_START_MASK) -#define WLAN_MBOX0_DMA_TX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX0_DMA_TX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX0_DMA_TX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX0_DMA_TX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX0_DMA_TX_CONTROL_STOP_MASK) >> WLAN_MBOX0_DMA_TX_CONTROL_STOP_LSB) -#define WLAN_MBOX0_DMA_TX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX0_DMA_TX_CONTROL_STOP_LSB) & WLAN_MBOX0_DMA_TX_CONTROL_STOP_MASK) - -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS 0x00000028 -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_OFFSET 0x00000028 -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX1_DMA_RX_CONTROL_ADDRESS 0x0000002c -#define WLAN_MBOX1_DMA_RX_CONTROL_OFFSET 0x0000002c -#define WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX1_DMA_RX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX1_DMA_RX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MASK) >> WLAN_MBOX1_DMA_RX_CONTROL_RESUME_LSB) -#define WLAN_MBOX1_DMA_RX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX1_DMA_RX_CONTROL_RESUME_LSB) & WLAN_MBOX1_DMA_RX_CONTROL_RESUME_MASK) -#define WLAN_MBOX1_DMA_RX_CONTROL_START_MSB 1 -#define WLAN_MBOX1_DMA_RX_CONTROL_START_LSB 1 -#define WLAN_MBOX1_DMA_RX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX1_DMA_RX_CONTROL_START_GET(x) (((x) & WLAN_MBOX1_DMA_RX_CONTROL_START_MASK) >> WLAN_MBOX1_DMA_RX_CONTROL_START_LSB) -#define WLAN_MBOX1_DMA_RX_CONTROL_START_SET(x) (((x) << WLAN_MBOX1_DMA_RX_CONTROL_START_LSB) & WLAN_MBOX1_DMA_RX_CONTROL_START_MASK) -#define WLAN_MBOX1_DMA_RX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX1_DMA_RX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX1_DMA_RX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX1_DMA_RX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX1_DMA_RX_CONTROL_STOP_MASK) >> WLAN_MBOX1_DMA_RX_CONTROL_STOP_LSB) -#define WLAN_MBOX1_DMA_RX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX1_DMA_RX_CONTROL_STOP_LSB) & WLAN_MBOX1_DMA_RX_CONTROL_STOP_MASK) - -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS 0x00000030 -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_OFFSET 0x00000030 -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX1_DMA_TX_CONTROL_ADDRESS 0x00000034 -#define WLAN_MBOX1_DMA_TX_CONTROL_OFFSET 0x00000034 -#define WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX1_DMA_TX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX1_DMA_TX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MASK) >> WLAN_MBOX1_DMA_TX_CONTROL_RESUME_LSB) -#define WLAN_MBOX1_DMA_TX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX1_DMA_TX_CONTROL_RESUME_LSB) & WLAN_MBOX1_DMA_TX_CONTROL_RESUME_MASK) -#define WLAN_MBOX1_DMA_TX_CONTROL_START_MSB 1 -#define WLAN_MBOX1_DMA_TX_CONTROL_START_LSB 1 -#define WLAN_MBOX1_DMA_TX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX1_DMA_TX_CONTROL_START_GET(x) (((x) & WLAN_MBOX1_DMA_TX_CONTROL_START_MASK) >> WLAN_MBOX1_DMA_TX_CONTROL_START_LSB) -#define WLAN_MBOX1_DMA_TX_CONTROL_START_SET(x) (((x) << WLAN_MBOX1_DMA_TX_CONTROL_START_LSB) & WLAN_MBOX1_DMA_TX_CONTROL_START_MASK) -#define WLAN_MBOX1_DMA_TX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX1_DMA_TX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX1_DMA_TX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX1_DMA_TX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX1_DMA_TX_CONTROL_STOP_MASK) >> WLAN_MBOX1_DMA_TX_CONTROL_STOP_LSB) -#define WLAN_MBOX1_DMA_TX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX1_DMA_TX_CONTROL_STOP_LSB) & WLAN_MBOX1_DMA_TX_CONTROL_STOP_MASK) - -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS 0x00000038 -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_OFFSET 0x00000038 -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX2_DMA_RX_CONTROL_ADDRESS 0x0000003c -#define WLAN_MBOX2_DMA_RX_CONTROL_OFFSET 0x0000003c -#define WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX2_DMA_RX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX2_DMA_RX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MASK) >> WLAN_MBOX2_DMA_RX_CONTROL_RESUME_LSB) -#define WLAN_MBOX2_DMA_RX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX2_DMA_RX_CONTROL_RESUME_LSB) & WLAN_MBOX2_DMA_RX_CONTROL_RESUME_MASK) -#define WLAN_MBOX2_DMA_RX_CONTROL_START_MSB 1 -#define WLAN_MBOX2_DMA_RX_CONTROL_START_LSB 1 -#define WLAN_MBOX2_DMA_RX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX2_DMA_RX_CONTROL_START_GET(x) (((x) & WLAN_MBOX2_DMA_RX_CONTROL_START_MASK) >> WLAN_MBOX2_DMA_RX_CONTROL_START_LSB) -#define WLAN_MBOX2_DMA_RX_CONTROL_START_SET(x) (((x) << WLAN_MBOX2_DMA_RX_CONTROL_START_LSB) & WLAN_MBOX2_DMA_RX_CONTROL_START_MASK) -#define WLAN_MBOX2_DMA_RX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX2_DMA_RX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX2_DMA_RX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX2_DMA_RX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX2_DMA_RX_CONTROL_STOP_MASK) >> WLAN_MBOX2_DMA_RX_CONTROL_STOP_LSB) -#define WLAN_MBOX2_DMA_RX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX2_DMA_RX_CONTROL_STOP_LSB) & WLAN_MBOX2_DMA_RX_CONTROL_STOP_MASK) - -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS 0x00000040 -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_OFFSET 0x00000040 -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX2_DMA_TX_CONTROL_ADDRESS 0x00000044 -#define WLAN_MBOX2_DMA_TX_CONTROL_OFFSET 0x00000044 -#define WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX2_DMA_TX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX2_DMA_TX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MASK) >> WLAN_MBOX2_DMA_TX_CONTROL_RESUME_LSB) -#define WLAN_MBOX2_DMA_TX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX2_DMA_TX_CONTROL_RESUME_LSB) & WLAN_MBOX2_DMA_TX_CONTROL_RESUME_MASK) -#define WLAN_MBOX2_DMA_TX_CONTROL_START_MSB 1 -#define WLAN_MBOX2_DMA_TX_CONTROL_START_LSB 1 -#define WLAN_MBOX2_DMA_TX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX2_DMA_TX_CONTROL_START_GET(x) (((x) & WLAN_MBOX2_DMA_TX_CONTROL_START_MASK) >> WLAN_MBOX2_DMA_TX_CONTROL_START_LSB) -#define WLAN_MBOX2_DMA_TX_CONTROL_START_SET(x) (((x) << WLAN_MBOX2_DMA_TX_CONTROL_START_LSB) & WLAN_MBOX2_DMA_TX_CONTROL_START_MASK) -#define WLAN_MBOX2_DMA_TX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX2_DMA_TX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX2_DMA_TX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX2_DMA_TX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX2_DMA_TX_CONTROL_STOP_MASK) >> WLAN_MBOX2_DMA_TX_CONTROL_STOP_LSB) -#define WLAN_MBOX2_DMA_TX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX2_DMA_TX_CONTROL_STOP_LSB) & WLAN_MBOX2_DMA_TX_CONTROL_STOP_MASK) - -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS 0x00000048 -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_OFFSET 0x00000048 -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX3_DMA_RX_CONTROL_ADDRESS 0x0000004c -#define WLAN_MBOX3_DMA_RX_CONTROL_OFFSET 0x0000004c -#define WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX3_DMA_RX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX3_DMA_RX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MASK) >> WLAN_MBOX3_DMA_RX_CONTROL_RESUME_LSB) -#define WLAN_MBOX3_DMA_RX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX3_DMA_RX_CONTROL_RESUME_LSB) & WLAN_MBOX3_DMA_RX_CONTROL_RESUME_MASK) -#define WLAN_MBOX3_DMA_RX_CONTROL_START_MSB 1 -#define WLAN_MBOX3_DMA_RX_CONTROL_START_LSB 1 -#define WLAN_MBOX3_DMA_RX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX3_DMA_RX_CONTROL_START_GET(x) (((x) & WLAN_MBOX3_DMA_RX_CONTROL_START_MASK) >> WLAN_MBOX3_DMA_RX_CONTROL_START_LSB) -#define WLAN_MBOX3_DMA_RX_CONTROL_START_SET(x) (((x) << WLAN_MBOX3_DMA_RX_CONTROL_START_LSB) & WLAN_MBOX3_DMA_RX_CONTROL_START_MASK) -#define WLAN_MBOX3_DMA_RX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX3_DMA_RX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX3_DMA_RX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX3_DMA_RX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX3_DMA_RX_CONTROL_STOP_MASK) >> WLAN_MBOX3_DMA_RX_CONTROL_STOP_LSB) -#define WLAN_MBOX3_DMA_RX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX3_DMA_RX_CONTROL_STOP_LSB) & WLAN_MBOX3_DMA_RX_CONTROL_STOP_MASK) - -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS 0x00000050 -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_OFFSET 0x00000050 -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_MBOX3_DMA_TX_CONTROL_ADDRESS 0x00000054 -#define WLAN_MBOX3_DMA_TX_CONTROL_OFFSET 0x00000054 -#define WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MSB 2 -#define WLAN_MBOX3_DMA_TX_CONTROL_RESUME_LSB 2 -#define WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_MBOX3_DMA_TX_CONTROL_RESUME_GET(x) (((x) & WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MASK) >> WLAN_MBOX3_DMA_TX_CONTROL_RESUME_LSB) -#define WLAN_MBOX3_DMA_TX_CONTROL_RESUME_SET(x) (((x) << WLAN_MBOX3_DMA_TX_CONTROL_RESUME_LSB) & WLAN_MBOX3_DMA_TX_CONTROL_RESUME_MASK) -#define WLAN_MBOX3_DMA_TX_CONTROL_START_MSB 1 -#define WLAN_MBOX3_DMA_TX_CONTROL_START_LSB 1 -#define WLAN_MBOX3_DMA_TX_CONTROL_START_MASK 0x00000002 -#define WLAN_MBOX3_DMA_TX_CONTROL_START_GET(x) (((x) & WLAN_MBOX3_DMA_TX_CONTROL_START_MASK) >> WLAN_MBOX3_DMA_TX_CONTROL_START_LSB) -#define WLAN_MBOX3_DMA_TX_CONTROL_START_SET(x) (((x) << WLAN_MBOX3_DMA_TX_CONTROL_START_LSB) & WLAN_MBOX3_DMA_TX_CONTROL_START_MASK) -#define WLAN_MBOX3_DMA_TX_CONTROL_STOP_MSB 0 -#define WLAN_MBOX3_DMA_TX_CONTROL_STOP_LSB 0 -#define WLAN_MBOX3_DMA_TX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_MBOX3_DMA_TX_CONTROL_STOP_GET(x) (((x) & WLAN_MBOX3_DMA_TX_CONTROL_STOP_MASK) >> WLAN_MBOX3_DMA_TX_CONTROL_STOP_LSB) -#define WLAN_MBOX3_DMA_TX_CONTROL_STOP_SET(x) (((x) << WLAN_MBOX3_DMA_TX_CONTROL_STOP_LSB) & WLAN_MBOX3_DMA_TX_CONTROL_STOP_MASK) - -#define WLAN_MBOX_INT_STATUS_ADDRESS 0x00000058 -#define WLAN_MBOX_INT_STATUS_OFFSET 0x00000058 -#define WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MSB 31 -#define WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB 28 -#define WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK 0xf0000000 -#define WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) >> WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) -#define WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) & WLAN_MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) -#define WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB 27 -#define WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB 24 -#define WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK 0x0f000000 -#define WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) >> WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) -#define WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) & WLAN_MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) -#define WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MSB 23 -#define WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB 20 -#define WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK 0x00f00000 -#define WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) >> WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) -#define WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) & WLAN_MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) -#define WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MSB 17 -#define WLAN_MBOX_INT_STATUS_TX_OVERFLOW_LSB 17 -#define WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MASK 0x00020000 -#define WLAN_MBOX_INT_STATUS_TX_OVERFLOW_GET(x) (((x) & WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MASK) >> WLAN_MBOX_INT_STATUS_TX_OVERFLOW_LSB) -#define WLAN_MBOX_INT_STATUS_TX_OVERFLOW_SET(x) (((x) << WLAN_MBOX_INT_STATUS_TX_OVERFLOW_LSB) & WLAN_MBOX_INT_STATUS_TX_OVERFLOW_MASK) -#define WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MSB 16 -#define WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_LSB 16 -#define WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MASK 0x00010000 -#define WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_GET(x) (((x) & WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MASK) >> WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_LSB) -#define WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_SET(x) (((x) << WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_LSB) & WLAN_MBOX_INT_STATUS_RX_UNDERFLOW_MASK) -#define WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MSB 15 -#define WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_LSB 12 -#define WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MASK 0x0000f000 -#define WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) (((x) & WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MASK) >> WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_LSB) -#define WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) (((x) << WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_LSB) & WLAN_MBOX_INT_STATUS_TX_NOT_EMPTY_MASK) -#define WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MSB 11 -#define WLAN_MBOX_INT_STATUS_RX_NOT_FULL_LSB 8 -#define WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MASK 0x00000f00 -#define WLAN_MBOX_INT_STATUS_RX_NOT_FULL_GET(x) (((x) & WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MASK) >> WLAN_MBOX_INT_STATUS_RX_NOT_FULL_LSB) -#define WLAN_MBOX_INT_STATUS_RX_NOT_FULL_SET(x) (((x) << WLAN_MBOX_INT_STATUS_RX_NOT_FULL_LSB) & WLAN_MBOX_INT_STATUS_RX_NOT_FULL_MASK) -#define WLAN_MBOX_INT_STATUS_HOST_MSB 7 -#define WLAN_MBOX_INT_STATUS_HOST_LSB 0 -#define WLAN_MBOX_INT_STATUS_HOST_MASK 0x000000ff -#define WLAN_MBOX_INT_STATUS_HOST_GET(x) (((x) & WLAN_MBOX_INT_STATUS_HOST_MASK) >> WLAN_MBOX_INT_STATUS_HOST_LSB) -#define WLAN_MBOX_INT_STATUS_HOST_SET(x) (((x) << WLAN_MBOX_INT_STATUS_HOST_LSB) & WLAN_MBOX_INT_STATUS_HOST_MASK) - -#define WLAN_MBOX_INT_ENABLE_ADDRESS 0x0000005c -#define WLAN_MBOX_INT_ENABLE_OFFSET 0x0000005c -#define WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB 31 -#define WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB 28 -#define WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK 0xf0000000 -#define WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) >> WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) -#define WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) & WLAN_MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) -#define WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB 27 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB 24 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK 0x0f000000 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) >> WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) -#define WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) & WLAN_MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) -#define WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB 23 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB 20 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK 0x00f00000 -#define WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) >> WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) -#define WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) & WLAN_MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) -#define WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MSB 17 -#define WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_LSB 17 -#define WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MASK 0x00020000 -#define WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MASK) >> WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_LSB) -#define WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_LSB) & WLAN_MBOX_INT_ENABLE_TX_OVERFLOW_MASK) -#define WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MSB 16 -#define WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_LSB 16 -#define WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MASK 0x00010000 -#define WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MASK) >> WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_LSB) -#define WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_LSB) & WLAN_MBOX_INT_ENABLE_RX_UNDERFLOW_MASK) -#define WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MSB 15 -#define WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB 12 -#define WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK 0x0000f000 -#define WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) >> WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) -#define WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) & WLAN_MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) -#define WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MSB 11 -#define WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_LSB 8 -#define WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MASK 0x00000f00 -#define WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MASK) >> WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_LSB) -#define WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_LSB) & WLAN_MBOX_INT_ENABLE_RX_NOT_FULL_MASK) -#define WLAN_MBOX_INT_ENABLE_HOST_MSB 7 -#define WLAN_MBOX_INT_ENABLE_HOST_LSB 0 -#define WLAN_MBOX_INT_ENABLE_HOST_MASK 0x000000ff -#define WLAN_MBOX_INT_ENABLE_HOST_GET(x) (((x) & WLAN_MBOX_INT_ENABLE_HOST_MASK) >> WLAN_MBOX_INT_ENABLE_HOST_LSB) -#define WLAN_MBOX_INT_ENABLE_HOST_SET(x) (((x) << WLAN_MBOX_INT_ENABLE_HOST_LSB) & WLAN_MBOX_INT_ENABLE_HOST_MASK) - -#define WLAN_INT_HOST_ADDRESS 0x00000060 -#define WLAN_INT_HOST_OFFSET 0x00000060 -#define WLAN_INT_HOST_VECTOR_MSB 7 -#define WLAN_INT_HOST_VECTOR_LSB 0 -#define WLAN_INT_HOST_VECTOR_MASK 0x000000ff -#define WLAN_INT_HOST_VECTOR_GET(x) (((x) & WLAN_INT_HOST_VECTOR_MASK) >> WLAN_INT_HOST_VECTOR_LSB) -#define WLAN_INT_HOST_VECTOR_SET(x) (((x) << WLAN_INT_HOST_VECTOR_LSB) & WLAN_INT_HOST_VECTOR_MASK) - -#define WLAN_LOCAL_COUNT_ADDRESS 0x00000080 -#define WLAN_LOCAL_COUNT_OFFSET 0x00000080 -#define WLAN_LOCAL_COUNT_VALUE_MSB 7 -#define WLAN_LOCAL_COUNT_VALUE_LSB 0 -#define WLAN_LOCAL_COUNT_VALUE_MASK 0x000000ff -#define WLAN_LOCAL_COUNT_VALUE_GET(x) (((x) & WLAN_LOCAL_COUNT_VALUE_MASK) >> WLAN_LOCAL_COUNT_VALUE_LSB) -#define WLAN_LOCAL_COUNT_VALUE_SET(x) (((x) << WLAN_LOCAL_COUNT_VALUE_LSB) & WLAN_LOCAL_COUNT_VALUE_MASK) - -#define WLAN_COUNT_INC_ADDRESS 0x000000a0 -#define WLAN_COUNT_INC_OFFSET 0x000000a0 -#define WLAN_COUNT_INC_VALUE_MSB 7 -#define WLAN_COUNT_INC_VALUE_LSB 0 -#define WLAN_COUNT_INC_VALUE_MASK 0x000000ff -#define WLAN_COUNT_INC_VALUE_GET(x) (((x) & WLAN_COUNT_INC_VALUE_MASK) >> WLAN_COUNT_INC_VALUE_LSB) -#define WLAN_COUNT_INC_VALUE_SET(x) (((x) << WLAN_COUNT_INC_VALUE_LSB) & WLAN_COUNT_INC_VALUE_MASK) - -#define WLAN_LOCAL_SCRATCH_ADDRESS 0x000000c0 -#define WLAN_LOCAL_SCRATCH_OFFSET 0x000000c0 -#define WLAN_LOCAL_SCRATCH_VALUE_MSB 7 -#define WLAN_LOCAL_SCRATCH_VALUE_LSB 0 -#define WLAN_LOCAL_SCRATCH_VALUE_MASK 0x000000ff -#define WLAN_LOCAL_SCRATCH_VALUE_GET(x) (((x) & WLAN_LOCAL_SCRATCH_VALUE_MASK) >> WLAN_LOCAL_SCRATCH_VALUE_LSB) -#define WLAN_LOCAL_SCRATCH_VALUE_SET(x) (((x) << WLAN_LOCAL_SCRATCH_VALUE_LSB) & WLAN_LOCAL_SCRATCH_VALUE_MASK) - -#define WLAN_USE_LOCAL_BUS_ADDRESS 0x000000e0 -#define WLAN_USE_LOCAL_BUS_OFFSET 0x000000e0 -#define WLAN_USE_LOCAL_BUS_PIN_INIT_MSB 0 -#define WLAN_USE_LOCAL_BUS_PIN_INIT_LSB 0 -#define WLAN_USE_LOCAL_BUS_PIN_INIT_MASK 0x00000001 -#define WLAN_USE_LOCAL_BUS_PIN_INIT_GET(x) (((x) & WLAN_USE_LOCAL_BUS_PIN_INIT_MASK) >> WLAN_USE_LOCAL_BUS_PIN_INIT_LSB) -#define WLAN_USE_LOCAL_BUS_PIN_INIT_SET(x) (((x) << WLAN_USE_LOCAL_BUS_PIN_INIT_LSB) & WLAN_USE_LOCAL_BUS_PIN_INIT_MASK) - -#define WLAN_SDIO_CONFIG_ADDRESS 0x000000e4 -#define WLAN_SDIO_CONFIG_OFFSET 0x000000e4 -#define WLAN_SDIO_CONFIG_CCCR_IOR1_MSB 0 -#define WLAN_SDIO_CONFIG_CCCR_IOR1_LSB 0 -#define WLAN_SDIO_CONFIG_CCCR_IOR1_MASK 0x00000001 -#define WLAN_SDIO_CONFIG_CCCR_IOR1_GET(x) (((x) & WLAN_SDIO_CONFIG_CCCR_IOR1_MASK) >> WLAN_SDIO_CONFIG_CCCR_IOR1_LSB) -#define WLAN_SDIO_CONFIG_CCCR_IOR1_SET(x) (((x) << WLAN_SDIO_CONFIG_CCCR_IOR1_LSB) & WLAN_SDIO_CONFIG_CCCR_IOR1_MASK) - -#define WLAN_MBOX_DEBUG_ADDRESS 0x000000e8 -#define WLAN_MBOX_DEBUG_OFFSET 0x000000e8 -#define WLAN_MBOX_DEBUG_SEL_MSB 2 -#define WLAN_MBOX_DEBUG_SEL_LSB 0 -#define WLAN_MBOX_DEBUG_SEL_MASK 0x00000007 -#define WLAN_MBOX_DEBUG_SEL_GET(x) (((x) & WLAN_MBOX_DEBUG_SEL_MASK) >> WLAN_MBOX_DEBUG_SEL_LSB) -#define WLAN_MBOX_DEBUG_SEL_SET(x) (((x) << WLAN_MBOX_DEBUG_SEL_LSB) & WLAN_MBOX_DEBUG_SEL_MASK) - -#define WLAN_MBOX_FIFO_RESET_ADDRESS 0x000000ec -#define WLAN_MBOX_FIFO_RESET_OFFSET 0x000000ec -#define WLAN_MBOX_FIFO_RESET_INIT_MSB 0 -#define WLAN_MBOX_FIFO_RESET_INIT_LSB 0 -#define WLAN_MBOX_FIFO_RESET_INIT_MASK 0x00000001 -#define WLAN_MBOX_FIFO_RESET_INIT_GET(x) (((x) & WLAN_MBOX_FIFO_RESET_INIT_MASK) >> WLAN_MBOX_FIFO_RESET_INIT_LSB) -#define WLAN_MBOX_FIFO_RESET_INIT_SET(x) (((x) << WLAN_MBOX_FIFO_RESET_INIT_LSB) & WLAN_MBOX_FIFO_RESET_INIT_MASK) - -#define WLAN_MBOX_TXFIFO_POP_ADDRESS 0x000000f0 -#define WLAN_MBOX_TXFIFO_POP_OFFSET 0x000000f0 -#define WLAN_MBOX_TXFIFO_POP_DATA_MSB 0 -#define WLAN_MBOX_TXFIFO_POP_DATA_LSB 0 -#define WLAN_MBOX_TXFIFO_POP_DATA_MASK 0x00000001 -#define WLAN_MBOX_TXFIFO_POP_DATA_GET(x) (((x) & WLAN_MBOX_TXFIFO_POP_DATA_MASK) >> WLAN_MBOX_TXFIFO_POP_DATA_LSB) -#define WLAN_MBOX_TXFIFO_POP_DATA_SET(x) (((x) << WLAN_MBOX_TXFIFO_POP_DATA_LSB) & WLAN_MBOX_TXFIFO_POP_DATA_MASK) - -#define WLAN_MBOX_RXFIFO_POP_ADDRESS 0x00000100 -#define WLAN_MBOX_RXFIFO_POP_OFFSET 0x00000100 -#define WLAN_MBOX_RXFIFO_POP_DATA_MSB 0 -#define WLAN_MBOX_RXFIFO_POP_DATA_LSB 0 -#define WLAN_MBOX_RXFIFO_POP_DATA_MASK 0x00000001 -#define WLAN_MBOX_RXFIFO_POP_DATA_GET(x) (((x) & WLAN_MBOX_RXFIFO_POP_DATA_MASK) >> WLAN_MBOX_RXFIFO_POP_DATA_LSB) -#define WLAN_MBOX_RXFIFO_POP_DATA_SET(x) (((x) << WLAN_MBOX_RXFIFO_POP_DATA_LSB) & WLAN_MBOX_RXFIFO_POP_DATA_MASK) - -#define WLAN_SDIO_DEBUG_ADDRESS 0x00000110 -#define WLAN_SDIO_DEBUG_OFFSET 0x00000110 -#define WLAN_SDIO_DEBUG_SEL_MSB 3 -#define WLAN_SDIO_DEBUG_SEL_LSB 0 -#define WLAN_SDIO_DEBUG_SEL_MASK 0x0000000f -#define WLAN_SDIO_DEBUG_SEL_GET(x) (((x) & WLAN_SDIO_DEBUG_SEL_MASK) >> WLAN_SDIO_DEBUG_SEL_LSB) -#define WLAN_SDIO_DEBUG_SEL_SET(x) (((x) << WLAN_SDIO_DEBUG_SEL_LSB) & WLAN_SDIO_DEBUG_SEL_MASK) - -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS 0x00000114 -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET 0x00000114 -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_GMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_GMBOX0_DMA_RX_CONTROL_ADDRESS 0x00000118 -#define WLAN_GMBOX0_DMA_RX_CONTROL_OFFSET 0x00000118 -#define WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MSB 2 -#define WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_LSB 2 -#define WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_GET(x) (((x) & WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MASK) >> WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_LSB) -#define WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_SET(x) (((x) << WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_LSB) & WLAN_GMBOX0_DMA_RX_CONTROL_RESUME_MASK) -#define WLAN_GMBOX0_DMA_RX_CONTROL_START_MSB 1 -#define WLAN_GMBOX0_DMA_RX_CONTROL_START_LSB 1 -#define WLAN_GMBOX0_DMA_RX_CONTROL_START_MASK 0x00000002 -#define WLAN_GMBOX0_DMA_RX_CONTROL_START_GET(x) (((x) & WLAN_GMBOX0_DMA_RX_CONTROL_START_MASK) >> WLAN_GMBOX0_DMA_RX_CONTROL_START_LSB) -#define WLAN_GMBOX0_DMA_RX_CONTROL_START_SET(x) (((x) << WLAN_GMBOX0_DMA_RX_CONTROL_START_LSB) & WLAN_GMBOX0_DMA_RX_CONTROL_START_MASK) -#define WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MSB 0 -#define WLAN_GMBOX0_DMA_RX_CONTROL_STOP_LSB 0 -#define WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_GMBOX0_DMA_RX_CONTROL_STOP_GET(x) (((x) & WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MASK) >> WLAN_GMBOX0_DMA_RX_CONTROL_STOP_LSB) -#define WLAN_GMBOX0_DMA_RX_CONTROL_STOP_SET(x) (((x) << WLAN_GMBOX0_DMA_RX_CONTROL_STOP_LSB) & WLAN_GMBOX0_DMA_RX_CONTROL_STOP_MASK) - -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS 0x0000011c -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET 0x0000011c -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27 -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2 -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) -#define WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & WLAN_GMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) - -#define WLAN_GMBOX0_DMA_TX_CONTROL_ADDRESS 0x00000120 -#define WLAN_GMBOX0_DMA_TX_CONTROL_OFFSET 0x00000120 -#define WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MSB 2 -#define WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_LSB 2 -#define WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MASK 0x00000004 -#define WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_GET(x) (((x) & WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MASK) >> WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_LSB) -#define WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_SET(x) (((x) << WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_LSB) & WLAN_GMBOX0_DMA_TX_CONTROL_RESUME_MASK) -#define WLAN_GMBOX0_DMA_TX_CONTROL_START_MSB 1 -#define WLAN_GMBOX0_DMA_TX_CONTROL_START_LSB 1 -#define WLAN_GMBOX0_DMA_TX_CONTROL_START_MASK 0x00000002 -#define WLAN_GMBOX0_DMA_TX_CONTROL_START_GET(x) (((x) & WLAN_GMBOX0_DMA_TX_CONTROL_START_MASK) >> WLAN_GMBOX0_DMA_TX_CONTROL_START_LSB) -#define WLAN_GMBOX0_DMA_TX_CONTROL_START_SET(x) (((x) << WLAN_GMBOX0_DMA_TX_CONTROL_START_LSB) & WLAN_GMBOX0_DMA_TX_CONTROL_START_MASK) -#define WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MSB 0 -#define WLAN_GMBOX0_DMA_TX_CONTROL_STOP_LSB 0 -#define WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MASK 0x00000001 -#define WLAN_GMBOX0_DMA_TX_CONTROL_STOP_GET(x) (((x) & WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MASK) >> WLAN_GMBOX0_DMA_TX_CONTROL_STOP_LSB) -#define WLAN_GMBOX0_DMA_TX_CONTROL_STOP_SET(x) (((x) << WLAN_GMBOX0_DMA_TX_CONTROL_STOP_LSB) & WLAN_GMBOX0_DMA_TX_CONTROL_STOP_MASK) - -#define WLAN_GMBOX_INT_STATUS_ADDRESS 0x00000124 -#define WLAN_GMBOX_INT_STATUS_OFFSET 0x00000124 -#define WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MSB 6 -#define WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_LSB 6 -#define WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MASK 0x00000040 -#define WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MASK) >> WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_LSB) -#define WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_LSB) & WLAN_GMBOX_INT_STATUS_TX_OVERFLOW_MASK) -#define WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MSB 5 -#define WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_LSB 5 -#define WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MASK 0x00000020 -#define WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MASK) >> WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_LSB) -#define WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_LSB) & WLAN_GMBOX_INT_STATUS_RX_UNDERFLOW_MASK) -#define WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MSB 4 -#define WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB 4 -#define WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK 0x00000010 -#define WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) >> WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) -#define WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) & WLAN_GMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) -#define WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB 3 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB 3 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK 0x00000008 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) >> WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) -#define WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) & WLAN_GMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) -#define WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MSB 2 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB 2 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK 0x00000004 -#define WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) >> WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) -#define WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) & WLAN_GMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) -#define WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MSB 1 -#define WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_LSB 1 -#define WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MASK 0x00000002 -#define WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MASK) >> WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_LSB) -#define WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_LSB) & WLAN_GMBOX_INT_STATUS_TX_NOT_EMPTY_MASK) -#define WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MSB 0 -#define WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_LSB 0 -#define WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MASK 0x00000001 -#define WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_GET(x) (((x) & WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MASK) >> WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_LSB) -#define WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_SET(x) (((x) << WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_LSB) & WLAN_GMBOX_INT_STATUS_RX_NOT_FULL_MASK) - -#define WLAN_GMBOX_INT_ENABLE_ADDRESS 0x00000128 -#define WLAN_GMBOX_INT_ENABLE_OFFSET 0x00000128 -#define WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MSB 6 -#define WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_LSB 6 -#define WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MASK 0x00000040 -#define WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MASK) >> WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_LSB) -#define WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_LSB) & WLAN_GMBOX_INT_ENABLE_TX_OVERFLOW_MASK) -#define WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MSB 5 -#define WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_LSB 5 -#define WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MASK 0x00000020 -#define WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MASK) >> WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_LSB) -#define WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_LSB) & WLAN_GMBOX_INT_ENABLE_RX_UNDERFLOW_MASK) -#define WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB 4 -#define WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB 4 -#define WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK 0x00000010 -#define WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) >> WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) -#define WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) & WLAN_GMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB 3 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB 3 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK 0x00000008 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) >> WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) & WLAN_GMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB 2 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB 2 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK 0x00000004 -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) >> WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) -#define WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) & WLAN_GMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) -#define WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MSB 1 -#define WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB 1 -#define WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK 0x00000002 -#define WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) >> WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) -#define WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) & WLAN_GMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) -#define WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MSB 0 -#define WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_LSB 0 -#define WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MASK 0x00000001 -#define WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_GET(x) (((x) & WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MASK) >> WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_LSB) -#define WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_SET(x) (((x) << WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_LSB) & WLAN_GMBOX_INT_ENABLE_RX_NOT_FULL_MASK) - -#define WLAN_HOST_IF_WINDOW_ADDRESS 0x00002000 -#define WLAN_HOST_IF_WINDOW_OFFSET 0x00002000 -#define WLAN_HOST_IF_WINDOW_DATA_MSB 7 -#define WLAN_HOST_IF_WINDOW_DATA_LSB 0 -#define WLAN_HOST_IF_WINDOW_DATA_MASK 0x000000ff -#define WLAN_HOST_IF_WINDOW_DATA_GET(x) (((x) & WLAN_HOST_IF_WINDOW_DATA_MASK) >> WLAN_HOST_IF_WINDOW_DATA_LSB) -#define WLAN_HOST_IF_WINDOW_DATA_SET(x) (((x) << WLAN_HOST_IF_WINDOW_DATA_LSB) & WLAN_HOST_IF_WINDOW_DATA_MASK) - -#endif /* _MBOX_WLAN_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_reg.h deleted file mode 100644 index fcafec88a6b..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_reg.h +++ /dev/null @@ -1,187 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#include "rtc_wlan_reg.h" - -#ifndef BT_HEADERS - -#define RESET_CONTROL_ADDRESS WLAN_RESET_CONTROL_ADDRESS -#define RESET_CONTROL_OFFSET WLAN_RESET_CONTROL_OFFSET -#define RESET_CONTROL_DEBUG_UART_RST_MSB WLAN_RESET_CONTROL_DEBUG_UART_RST_MSB -#define RESET_CONTROL_DEBUG_UART_RST_LSB WLAN_RESET_CONTROL_DEBUG_UART_RST_LSB -#define RESET_CONTROL_DEBUG_UART_RST_MASK WLAN_RESET_CONTROL_DEBUG_UART_RST_MASK -#define RESET_CONTROL_DEBUG_UART_RST_GET(x) WLAN_RESET_CONTROL_DEBUG_UART_RST_GET(x) -#define RESET_CONTROL_DEBUG_UART_RST_SET(x) WLAN_RESET_CONTROL_DEBUG_UART_RST_SET(x) -#define RESET_CONTROL_BB_COLD_RST_MSB WLAN_RESET_CONTROL_BB_COLD_RST_MSB -#define RESET_CONTROL_BB_COLD_RST_LSB WLAN_RESET_CONTROL_BB_COLD_RST_LSB -#define RESET_CONTROL_BB_COLD_RST_MASK WLAN_RESET_CONTROL_BB_COLD_RST_MASK -#define RESET_CONTROL_BB_COLD_RST_GET(x) WLAN_RESET_CONTROL_BB_COLD_RST_GET(x) -#define RESET_CONTROL_BB_COLD_RST_SET(x) WLAN_RESET_CONTROL_BB_COLD_RST_SET(x) -#define RESET_CONTROL_BB_WARM_RST_MSB WLAN_RESET_CONTROL_BB_WARM_RST_MSB -#define RESET_CONTROL_BB_WARM_RST_LSB WLAN_RESET_CONTROL_BB_WARM_RST_LSB -#define RESET_CONTROL_BB_WARM_RST_MASK WLAN_RESET_CONTROL_BB_WARM_RST_MASK -#define RESET_CONTROL_BB_WARM_RST_GET(x) WLAN_RESET_CONTROL_BB_WARM_RST_GET(x) -#define RESET_CONTROL_BB_WARM_RST_SET(x) WLAN_RESET_CONTROL_BB_WARM_RST_SET(x) -#define RESET_CONTROL_CPU_INIT_RESET_MSB WLAN_RESET_CONTROL_CPU_INIT_RESET_MSB -#define RESET_CONTROL_CPU_INIT_RESET_LSB WLAN_RESET_CONTROL_CPU_INIT_RESET_LSB -#define RESET_CONTROL_CPU_INIT_RESET_MASK WLAN_RESET_CONTROL_CPU_INIT_RESET_MASK -#define RESET_CONTROL_CPU_INIT_RESET_GET(x) WLAN_RESET_CONTROL_CPU_INIT_RESET_GET(x) -#define RESET_CONTROL_CPU_INIT_RESET_SET(x) WLAN_RESET_CONTROL_CPU_INIT_RESET_SET(x) -#define RESET_CONTROL_VMC_REMAP_RESET_MSB WLAN_RESET_CONTROL_VMC_REMAP_RESET_MSB -#define RESET_CONTROL_VMC_REMAP_RESET_LSB WLAN_RESET_CONTROL_VMC_REMAP_RESET_LSB -#define RESET_CONTROL_VMC_REMAP_RESET_MASK WLAN_RESET_CONTROL_VMC_REMAP_RESET_MASK -#define RESET_CONTROL_VMC_REMAP_RESET_GET(x) WLAN_RESET_CONTROL_VMC_REMAP_RESET_GET(x) -#define RESET_CONTROL_VMC_REMAP_RESET_SET(x) WLAN_RESET_CONTROL_VMC_REMAP_RESET_SET(x) -#define RESET_CONTROL_RST_OUT_MSB WLAN_RESET_CONTROL_RST_OUT_MSB -#define RESET_CONTROL_RST_OUT_LSB WLAN_RESET_CONTROL_RST_OUT_LSB -#define RESET_CONTROL_RST_OUT_MASK WLAN_RESET_CONTROL_RST_OUT_MASK -#define RESET_CONTROL_RST_OUT_GET(x) WLAN_RESET_CONTROL_RST_OUT_GET(x) -#define RESET_CONTROL_RST_OUT_SET(x) WLAN_RESET_CONTROL_RST_OUT_SET(x) -#define RESET_CONTROL_COLD_RST_MSB WLAN_RESET_CONTROL_COLD_RST_MSB -#define RESET_CONTROL_COLD_RST_LSB WLAN_RESET_CONTROL_COLD_RST_LSB -#define RESET_CONTROL_COLD_RST_MASK WLAN_RESET_CONTROL_COLD_RST_MASK -#define RESET_CONTROL_COLD_RST_GET(x) WLAN_RESET_CONTROL_COLD_RST_GET(x) -#define RESET_CONTROL_COLD_RST_SET(x) WLAN_RESET_CONTROL_COLD_RST_SET(x) -#define RESET_CONTROL_WARM_RST_MSB WLAN_RESET_CONTROL_WARM_RST_MSB -#define RESET_CONTROL_WARM_RST_LSB WLAN_RESET_CONTROL_WARM_RST_LSB -#define RESET_CONTROL_WARM_RST_MASK WLAN_RESET_CONTROL_WARM_RST_MASK -#define RESET_CONTROL_WARM_RST_GET(x) WLAN_RESET_CONTROL_WARM_RST_GET(x) -#define RESET_CONTROL_WARM_RST_SET(x) WLAN_RESET_CONTROL_WARM_RST_SET(x) -#define RESET_CONTROL_CPU_WARM_RST_MSB WLAN_RESET_CONTROL_CPU_WARM_RST_MSB -#define RESET_CONTROL_CPU_WARM_RST_LSB WLAN_RESET_CONTROL_CPU_WARM_RST_LSB -#define RESET_CONTROL_CPU_WARM_RST_MASK WLAN_RESET_CONTROL_CPU_WARM_RST_MASK -#define RESET_CONTROL_CPU_WARM_RST_GET(x) WLAN_RESET_CONTROL_CPU_WARM_RST_GET(x) -#define RESET_CONTROL_CPU_WARM_RST_SET(x) WLAN_RESET_CONTROL_CPU_WARM_RST_SET(x) -#define RESET_CONTROL_MAC_COLD_RST_MSB WLAN_RESET_CONTROL_MAC_COLD_RST_MSB -#define RESET_CONTROL_MAC_COLD_RST_LSB WLAN_RESET_CONTROL_MAC_COLD_RST_LSB -#define RESET_CONTROL_MAC_COLD_RST_MASK WLAN_RESET_CONTROL_MAC_COLD_RST_MASK -#define RESET_CONTROL_MAC_COLD_RST_GET(x) WLAN_RESET_CONTROL_MAC_COLD_RST_GET(x) -#define RESET_CONTROL_MAC_COLD_RST_SET(x) WLAN_RESET_CONTROL_MAC_COLD_RST_SET(x) -#define RESET_CONTROL_MAC_WARM_RST_MSB WLAN_RESET_CONTROL_MAC_WARM_RST_MSB -#define RESET_CONTROL_MAC_WARM_RST_LSB WLAN_RESET_CONTROL_MAC_WARM_RST_LSB -#define RESET_CONTROL_MAC_WARM_RST_MASK WLAN_RESET_CONTROL_MAC_WARM_RST_MASK -#define RESET_CONTROL_MAC_WARM_RST_GET(x) WLAN_RESET_CONTROL_MAC_WARM_RST_GET(x) -#define RESET_CONTROL_MAC_WARM_RST_SET(x) WLAN_RESET_CONTROL_MAC_WARM_RST_SET(x) -#define RESET_CONTROL_MBOX_RST_MSB WLAN_RESET_CONTROL_MBOX_RST_MSB -#define RESET_CONTROL_MBOX_RST_LSB WLAN_RESET_CONTROL_MBOX_RST_LSB -#define RESET_CONTROL_MBOX_RST_MASK WLAN_RESET_CONTROL_MBOX_RST_MASK -#define RESET_CONTROL_MBOX_RST_GET(x) WLAN_RESET_CONTROL_MBOX_RST_GET(x) -#define RESET_CONTROL_MBOX_RST_SET(x) WLAN_RESET_CONTROL_MBOX_RST_SET(x) -#define RESET_CONTROL_UART_RST_MSB WLAN_RESET_CONTROL_UART_RST_MSB -#define RESET_CONTROL_UART_RST_LSB WLAN_RESET_CONTROL_UART_RST_LSB -#define RESET_CONTROL_UART_RST_MASK WLAN_RESET_CONTROL_UART_RST_MASK -#define RESET_CONTROL_UART_RST_GET(x) WLAN_RESET_CONTROL_UART_RST_GET(x) -#define RESET_CONTROL_UART_RST_SET(x) WLAN_RESET_CONTROL_UART_RST_SET(x) -#define RESET_CONTROL_SI0_RST_MSB WLAN_RESET_CONTROL_SI0_RST_MSB -#define RESET_CONTROL_SI0_RST_LSB WLAN_RESET_CONTROL_SI0_RST_LSB -#define RESET_CONTROL_SI0_RST_MASK WLAN_RESET_CONTROL_SI0_RST_MASK -#define RESET_CONTROL_SI0_RST_GET(x) WLAN_RESET_CONTROL_SI0_RST_GET(x) -#define RESET_CONTROL_SI0_RST_SET(x) WLAN_RESET_CONTROL_SI0_RST_SET(x) -#define CPU_CLOCK_ADDRESS WLAN_CPU_CLOCK_ADDRESS -#define CPU_CLOCK_OFFSET WLAN_CPU_CLOCK_OFFSET -#define CPU_CLOCK_STANDARD_MSB WLAN_CPU_CLOCK_STANDARD_MSB -#define CPU_CLOCK_STANDARD_LSB WLAN_CPU_CLOCK_STANDARD_LSB -#define CPU_CLOCK_STANDARD_MASK WLAN_CPU_CLOCK_STANDARD_MASK -#define CPU_CLOCK_STANDARD_GET(x) WLAN_CPU_CLOCK_STANDARD_GET(x) -#define CPU_CLOCK_STANDARD_SET(x) WLAN_CPU_CLOCK_STANDARD_SET(x) -#define CLOCK_OUT_ADDRESS WLAN_CLOCK_OUT_ADDRESS -#define CLOCK_OUT_OFFSET WLAN_CLOCK_OUT_OFFSET -#define CLOCK_OUT_SELECT_MSB WLAN_CLOCK_OUT_SELECT_MSB -#define CLOCK_OUT_SELECT_LSB WLAN_CLOCK_OUT_SELECT_LSB -#define CLOCK_OUT_SELECT_MASK WLAN_CLOCK_OUT_SELECT_MASK -#define CLOCK_OUT_SELECT_GET(x) WLAN_CLOCK_OUT_SELECT_GET(x) -#define CLOCK_OUT_SELECT_SET(x) WLAN_CLOCK_OUT_SELECT_SET(x) -#define CLOCK_CONTROL_ADDRESS WLAN_CLOCK_CONTROL_ADDRESS -#define CLOCK_CONTROL_OFFSET WLAN_CLOCK_CONTROL_OFFSET -#define CLOCK_CONTROL_LF_CLK32_MSB WLAN_CLOCK_CONTROL_LF_CLK32_MSB -#define CLOCK_CONTROL_LF_CLK32_LSB WLAN_CLOCK_CONTROL_LF_CLK32_LSB -#define CLOCK_CONTROL_LF_CLK32_MASK WLAN_CLOCK_CONTROL_LF_CLK32_MASK -#define CLOCK_CONTROL_LF_CLK32_GET(x) WLAN_CLOCK_CONTROL_LF_CLK32_GET(x) -#define CLOCK_CONTROL_LF_CLK32_SET(x) WLAN_CLOCK_CONTROL_LF_CLK32_SET(x) -#define CLOCK_CONTROL_SI0_CLK_MSB WLAN_CLOCK_CONTROL_SI0_CLK_MSB -#define CLOCK_CONTROL_SI0_CLK_LSB WLAN_CLOCK_CONTROL_SI0_CLK_LSB -#define CLOCK_CONTROL_SI0_CLK_MASK WLAN_CLOCK_CONTROL_SI0_CLK_MASK -#define CLOCK_CONTROL_SI0_CLK_GET(x) WLAN_CLOCK_CONTROL_SI0_CLK_GET(x) -#define CLOCK_CONTROL_SI0_CLK_SET(x) WLAN_CLOCK_CONTROL_SI0_CLK_SET(x) -#define RESET_CAUSE_ADDRESS WLAN_RESET_CAUSE_ADDRESS -#define RESET_CAUSE_OFFSET WLAN_RESET_CAUSE_OFFSET -#define RESET_CAUSE_LAST_MSB WLAN_RESET_CAUSE_LAST_MSB -#define RESET_CAUSE_LAST_LSB WLAN_RESET_CAUSE_LAST_LSB -#define RESET_CAUSE_LAST_MASK WLAN_RESET_CAUSE_LAST_MASK -#define RESET_CAUSE_LAST_GET(x) WLAN_RESET_CAUSE_LAST_GET(x) -#define RESET_CAUSE_LAST_SET(x) WLAN_RESET_CAUSE_LAST_SET(x) -#define SYSTEM_SLEEP_ADDRESS WLAN_SYSTEM_SLEEP_ADDRESS -#define SYSTEM_SLEEP_OFFSET WLAN_SYSTEM_SLEEP_OFFSET -#define SYSTEM_SLEEP_HOST_IF_MSB WLAN_SYSTEM_SLEEP_HOST_IF_MSB -#define SYSTEM_SLEEP_HOST_IF_LSB WLAN_SYSTEM_SLEEP_HOST_IF_LSB -#define SYSTEM_SLEEP_HOST_IF_MASK WLAN_SYSTEM_SLEEP_HOST_IF_MASK -#define SYSTEM_SLEEP_HOST_IF_GET(x) WLAN_SYSTEM_SLEEP_HOST_IF_GET(x) -#define SYSTEM_SLEEP_HOST_IF_SET(x) WLAN_SYSTEM_SLEEP_HOST_IF_SET(x) -#define SYSTEM_SLEEP_MBOX_MSB WLAN_SYSTEM_SLEEP_MBOX_MSB -#define SYSTEM_SLEEP_MBOX_LSB WLAN_SYSTEM_SLEEP_MBOX_LSB -#define SYSTEM_SLEEP_MBOX_MASK WLAN_SYSTEM_SLEEP_MBOX_MASK -#define SYSTEM_SLEEP_MBOX_GET(x) WLAN_SYSTEM_SLEEP_MBOX_GET(x) -#define SYSTEM_SLEEP_MBOX_SET(x) WLAN_SYSTEM_SLEEP_MBOX_SET(x) -#define SYSTEM_SLEEP_MAC_IF_MSB WLAN_SYSTEM_SLEEP_MAC_IF_MSB -#define SYSTEM_SLEEP_MAC_IF_LSB WLAN_SYSTEM_SLEEP_MAC_IF_LSB -#define SYSTEM_SLEEP_MAC_IF_MASK WLAN_SYSTEM_SLEEP_MAC_IF_MASK -#define SYSTEM_SLEEP_MAC_IF_GET(x) WLAN_SYSTEM_SLEEP_MAC_IF_GET(x) -#define SYSTEM_SLEEP_MAC_IF_SET(x) WLAN_SYSTEM_SLEEP_MAC_IF_SET(x) -#define SYSTEM_SLEEP_LIGHT_MSB WLAN_SYSTEM_SLEEP_LIGHT_MSB -#define SYSTEM_SLEEP_LIGHT_LSB WLAN_SYSTEM_SLEEP_LIGHT_LSB -#define SYSTEM_SLEEP_LIGHT_MASK WLAN_SYSTEM_SLEEP_LIGHT_MASK -#define SYSTEM_SLEEP_LIGHT_GET(x) WLAN_SYSTEM_SLEEP_LIGHT_GET(x) -#define SYSTEM_SLEEP_LIGHT_SET(x) WLAN_SYSTEM_SLEEP_LIGHT_SET(x) -#define SYSTEM_SLEEP_DISABLE_MSB WLAN_SYSTEM_SLEEP_DISABLE_MSB -#define SYSTEM_SLEEP_DISABLE_LSB WLAN_SYSTEM_SLEEP_DISABLE_LSB -#define SYSTEM_SLEEP_DISABLE_MASK WLAN_SYSTEM_SLEEP_DISABLE_MASK -#define SYSTEM_SLEEP_DISABLE_GET(x) WLAN_SYSTEM_SLEEP_DISABLE_GET(x) -#define SYSTEM_SLEEP_DISABLE_SET(x) WLAN_SYSTEM_SLEEP_DISABLE_SET(x) -#define LPO_INIT_DIVIDEND_INT_ADDRESS WLAN_LPO_INIT_DIVIDEND_INT_ADDRESS -#define LPO_INIT_DIVIDEND_INT_OFFSET WLAN_LPO_INIT_DIVIDEND_INT_OFFSET -#define LPO_INIT_DIVIDEND_INT_VALUE_MSB WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MSB -#define LPO_INIT_DIVIDEND_INT_VALUE_LSB WLAN_LPO_INIT_DIVIDEND_INT_VALUE_LSB -#define LPO_INIT_DIVIDEND_INT_VALUE_MASK WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MASK -#define LPO_INIT_DIVIDEND_INT_VALUE_GET(x) WLAN_LPO_INIT_DIVIDEND_INT_VALUE_GET(x) -#define LPO_INIT_DIVIDEND_INT_VALUE_SET(x) WLAN_LPO_INIT_DIVIDEND_INT_VALUE_SET(x) -#define LPO_INIT_DIVIDEND_FRACTION_ADDRESS WLAN_LPO_INIT_DIVIDEND_FRACTION_ADDRESS -#define LPO_INIT_DIVIDEND_FRACTION_OFFSET WLAN_LPO_INIT_DIVIDEND_FRACTION_OFFSET -#define LPO_INIT_DIVIDEND_FRACTION_VALUE_MSB WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MSB -#define LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB -#define LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK -#define LPO_INIT_DIVIDEND_FRACTION_VALUE_GET(x) WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_GET(x) -#define LPO_INIT_DIVIDEND_FRACTION_VALUE_SET(x) WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_SET(x) -#define LPO_CAL_ADDRESS WLAN_LPO_CAL_ADDRESS -#define LPO_CAL_OFFSET WLAN_LPO_CAL_OFFSET -#define LPO_CAL_ENABLE_MSB WLAN_LPO_CAL_ENABLE_MSB -#define LPO_CAL_ENABLE_LSB WLAN_LPO_CAL_ENABLE_LSB -#define LPO_CAL_ENABLE_MASK WLAN_LPO_CAL_ENABLE_MASK -#define LPO_CAL_ENABLE_GET(x) WLAN_LPO_CAL_ENABLE_GET(x) -#define LPO_CAL_ENABLE_SET(x) WLAN_LPO_CAL_ENABLE_SET(x) -#define LPO_CAL_COUNT_MSB WLAN_LPO_CAL_COUNT_MSB -#define LPO_CAL_COUNT_LSB WLAN_LPO_CAL_COUNT_LSB -#define LPO_CAL_COUNT_MASK WLAN_LPO_CAL_COUNT_MASK -#define LPO_CAL_COUNT_GET(x) WLAN_LPO_CAL_COUNT_GET(x) -#define LPO_CAL_COUNT_SET(x) WLAN_LPO_CAL_COUNT_SET(x) - -#endif diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_wlan_reg.h deleted file mode 100644 index 5c048ff51b0..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_wlan_reg.h +++ /dev/null @@ -1,162 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#ifndef _RTC_WLAN_REG_REG_H_ -#define _RTC_WLAN_REG_REG_H_ - -#define WLAN_RESET_CONTROL_ADDRESS 0x00000000 -#define WLAN_RESET_CONTROL_OFFSET 0x00000000 -#define WLAN_RESET_CONTROL_DEBUG_UART_RST_MSB 14 -#define WLAN_RESET_CONTROL_DEBUG_UART_RST_LSB 14 -#define WLAN_RESET_CONTROL_DEBUG_UART_RST_MASK 0x00004000 -#define WLAN_RESET_CONTROL_DEBUG_UART_RST_GET(x) (((x) & WLAN_RESET_CONTROL_DEBUG_UART_RST_MASK) >> WLAN_RESET_CONTROL_DEBUG_UART_RST_LSB) -#define WLAN_RESET_CONTROL_DEBUG_UART_RST_SET(x) (((x) << WLAN_RESET_CONTROL_DEBUG_UART_RST_LSB) & WLAN_RESET_CONTROL_DEBUG_UART_RST_MASK) -#define WLAN_RESET_CONTROL_BB_COLD_RST_MSB 13 -#define WLAN_RESET_CONTROL_BB_COLD_RST_LSB 13 -#define WLAN_RESET_CONTROL_BB_COLD_RST_MASK 0x00002000 -#define WLAN_RESET_CONTROL_BB_COLD_RST_GET(x) (((x) & WLAN_RESET_CONTROL_BB_COLD_RST_MASK) >> WLAN_RESET_CONTROL_BB_COLD_RST_LSB) -#define WLAN_RESET_CONTROL_BB_COLD_RST_SET(x) (((x) << WLAN_RESET_CONTROL_BB_COLD_RST_LSB) & WLAN_RESET_CONTROL_BB_COLD_RST_MASK) -#define WLAN_RESET_CONTROL_BB_WARM_RST_MSB 12 -#define WLAN_RESET_CONTROL_BB_WARM_RST_LSB 12 -#define WLAN_RESET_CONTROL_BB_WARM_RST_MASK 0x00001000 -#define WLAN_RESET_CONTROL_BB_WARM_RST_GET(x) (((x) & WLAN_RESET_CONTROL_BB_WARM_RST_MASK) >> WLAN_RESET_CONTROL_BB_WARM_RST_LSB) -#define WLAN_RESET_CONTROL_BB_WARM_RST_SET(x) (((x) << WLAN_RESET_CONTROL_BB_WARM_RST_LSB) & WLAN_RESET_CONTROL_BB_WARM_RST_MASK) -#define WLAN_RESET_CONTROL_CPU_INIT_RESET_MSB 11 -#define WLAN_RESET_CONTROL_CPU_INIT_RESET_LSB 11 -#define WLAN_RESET_CONTROL_CPU_INIT_RESET_MASK 0x00000800 -#define WLAN_RESET_CONTROL_CPU_INIT_RESET_GET(x) (((x) & WLAN_RESET_CONTROL_CPU_INIT_RESET_MASK) >> WLAN_RESET_CONTROL_CPU_INIT_RESET_LSB) -#define WLAN_RESET_CONTROL_CPU_INIT_RESET_SET(x) (((x) << WLAN_RESET_CONTROL_CPU_INIT_RESET_LSB) & WLAN_RESET_CONTROL_CPU_INIT_RESET_MASK) -#define WLAN_RESET_CONTROL_VMC_REMAP_RESET_MSB 10 -#define WLAN_RESET_CONTROL_VMC_REMAP_RESET_LSB 10 -#define WLAN_RESET_CONTROL_VMC_REMAP_RESET_MASK 0x00000400 -#define WLAN_RESET_CONTROL_VMC_REMAP_RESET_GET(x) (((x) & WLAN_RESET_CONTROL_VMC_REMAP_RESET_MASK) >> WLAN_RESET_CONTROL_VMC_REMAP_RESET_LSB) -#define WLAN_RESET_CONTROL_VMC_REMAP_RESET_SET(x) (((x) << WLAN_RESET_CONTROL_VMC_REMAP_RESET_LSB) & WLAN_RESET_CONTROL_VMC_REMAP_RESET_MASK) -#define WLAN_RESET_CONTROL_RST_OUT_MSB 9 -#define WLAN_RESET_CONTROL_RST_OUT_LSB 9 -#define WLAN_RESET_CONTROL_RST_OUT_MASK 0x00000200 -#define WLAN_RESET_CONTROL_RST_OUT_GET(x) (((x) & WLAN_RESET_CONTROL_RST_OUT_MASK) >> WLAN_RESET_CONTROL_RST_OUT_LSB) -#define WLAN_RESET_CONTROL_RST_OUT_SET(x) (((x) << WLAN_RESET_CONTROL_RST_OUT_LSB) & WLAN_RESET_CONTROL_RST_OUT_MASK) -#define WLAN_RESET_CONTROL_COLD_RST_MSB 8 -#define WLAN_RESET_CONTROL_COLD_RST_LSB 8 -#define WLAN_RESET_CONTROL_COLD_RST_MASK 0x00000100 -#define WLAN_RESET_CONTROL_COLD_RST_GET(x) (((x) & WLAN_RESET_CONTROL_COLD_RST_MASK) >> WLAN_RESET_CONTROL_COLD_RST_LSB) -#define WLAN_RESET_CONTROL_COLD_RST_SET(x) (((x) << WLAN_RESET_CONTROL_COLD_RST_LSB) & WLAN_RESET_CONTROL_COLD_RST_MASK) -#define WLAN_RESET_CONTROL_WARM_RST_MSB 7 -#define WLAN_RESET_CONTROL_WARM_RST_LSB 7 -#define WLAN_RESET_CONTROL_WARM_RST_MASK 0x00000080 -#define WLAN_RESET_CONTROL_WARM_RST_GET(x) (((x) & WLAN_RESET_CONTROL_WARM_RST_MASK) >> WLAN_RESET_CONTROL_WARM_RST_LSB) -#define WLAN_RESET_CONTROL_WARM_RST_SET(x) (((x) << WLAN_RESET_CONTROL_WARM_RST_LSB) & WLAN_RESET_CONTROL_WARM_RST_MASK) -#define WLAN_RESET_CONTROL_CPU_WARM_RST_MSB 6 -#define WLAN_RESET_CONTROL_CPU_WARM_RST_LSB 6 -#define WLAN_RESET_CONTROL_CPU_WARM_RST_MASK 0x00000040 -#define WLAN_RESET_CONTROL_CPU_WARM_RST_GET(x) (((x) & WLAN_RESET_CONTROL_CPU_WARM_RST_MASK) >> WLAN_RESET_CONTROL_CPU_WARM_RST_LSB) -#define WLAN_RESET_CONTROL_CPU_WARM_RST_SET(x) (((x) << WLAN_RESET_CONTROL_CPU_WARM_RST_LSB) & WLAN_RESET_CONTROL_CPU_WARM_RST_MASK) -#define WLAN_RESET_CONTROL_MAC_COLD_RST_MSB 5 -#define WLAN_RESET_CONTROL_MAC_COLD_RST_LSB 5 -#define WLAN_RESET_CONTROL_MAC_COLD_RST_MASK 0x00000020 -#define WLAN_RESET_CONTROL_MAC_COLD_RST_GET(x) (((x) & WLAN_RESET_CONTROL_MAC_COLD_RST_MASK) >> WLAN_RESET_CONTROL_MAC_COLD_RST_LSB) -#define WLAN_RESET_CONTROL_MAC_COLD_RST_SET(x) (((x) << WLAN_RESET_CONTROL_MAC_COLD_RST_LSB) & WLAN_RESET_CONTROL_MAC_COLD_RST_MASK) -#define WLAN_RESET_CONTROL_MAC_WARM_RST_MSB 4 -#define WLAN_RESET_CONTROL_MAC_WARM_RST_LSB 4 -#define WLAN_RESET_CONTROL_MAC_WARM_RST_MASK 0x00000010 -#define WLAN_RESET_CONTROL_MAC_WARM_RST_GET(x) (((x) & WLAN_RESET_CONTROL_MAC_WARM_RST_MASK) >> WLAN_RESET_CONTROL_MAC_WARM_RST_LSB) -#define WLAN_RESET_CONTROL_MAC_WARM_RST_SET(x) (((x) << WLAN_RESET_CONTROL_MAC_WARM_RST_LSB) & WLAN_RESET_CONTROL_MAC_WARM_RST_MASK) -#define WLAN_RESET_CONTROL_MBOX_RST_MSB 2 -#define WLAN_RESET_CONTROL_MBOX_RST_LSB 2 -#define WLAN_RESET_CONTROL_MBOX_RST_MASK 0x00000004 -#define WLAN_RESET_CONTROL_MBOX_RST_GET(x) (((x) & WLAN_RESET_CONTROL_MBOX_RST_MASK) >> WLAN_RESET_CONTROL_MBOX_RST_LSB) -#define WLAN_RESET_CONTROL_MBOX_RST_SET(x) (((x) << WLAN_RESET_CONTROL_MBOX_RST_LSB) & WLAN_RESET_CONTROL_MBOX_RST_MASK) -#define WLAN_RESET_CONTROL_UART_RST_MSB 1 -#define WLAN_RESET_CONTROL_UART_RST_LSB 1 -#define WLAN_RESET_CONTROL_UART_RST_MASK 0x00000002 -#define WLAN_RESET_CONTROL_UART_RST_GET(x) (((x) & WLAN_RESET_CONTROL_UART_RST_MASK) >> WLAN_RESET_CONTROL_UART_RST_LSB) -#define WLAN_RESET_CONTROL_UART_RST_SET(x) (((x) << WLAN_RESET_CONTROL_UART_RST_LSB) & WLAN_RESET_CONTROL_UART_RST_MASK) -#define WLAN_RESET_CONTROL_SI0_RST_MSB 0 -#define WLAN_RESET_CONTROL_SI0_RST_LSB 0 -#define WLAN_RESET_CONTROL_SI0_RST_MASK 0x00000001 -#define WLAN_RESET_CONTROL_SI0_RST_GET(x) (((x) & WLAN_RESET_CONTROL_SI0_RST_MASK) >> WLAN_RESET_CONTROL_SI0_RST_LSB) -#define WLAN_RESET_CONTROL_SI0_RST_SET(x) (((x) << WLAN_RESET_CONTROL_SI0_RST_LSB) & WLAN_RESET_CONTROL_SI0_RST_MASK) - -#define WLAN_CPU_CLOCK_ADDRESS 0x00000020 -#define WLAN_CPU_CLOCK_OFFSET 0x00000020 -#define WLAN_CPU_CLOCK_STANDARD_MSB 1 -#define WLAN_CPU_CLOCK_STANDARD_LSB 0 -#define WLAN_CPU_CLOCK_STANDARD_MASK 0x00000003 -#define WLAN_CPU_CLOCK_STANDARD_GET(x) (((x) & WLAN_CPU_CLOCK_STANDARD_MASK) >> WLAN_CPU_CLOCK_STANDARD_LSB) -#define WLAN_CPU_CLOCK_STANDARD_SET(x) (((x) << WLAN_CPU_CLOCK_STANDARD_LSB) & WLAN_CPU_CLOCK_STANDARD_MASK) - -#define WLAN_CLOCK_CONTROL_ADDRESS 0x00000028 -#define WLAN_CLOCK_CONTROL_OFFSET 0x00000028 -#define WLAN_CLOCK_CONTROL_LF_CLK32_MSB 2 -#define WLAN_CLOCK_CONTROL_LF_CLK32_LSB 2 -#define WLAN_CLOCK_CONTROL_LF_CLK32_MASK 0x00000004 -#define WLAN_CLOCK_CONTROL_LF_CLK32_GET(x) (((x) & WLAN_CLOCK_CONTROL_LF_CLK32_MASK) >> WLAN_CLOCK_CONTROL_LF_CLK32_LSB) -#define WLAN_CLOCK_CONTROL_LF_CLK32_SET(x) (((x) << WLAN_CLOCK_CONTROL_LF_CLK32_LSB) & WLAN_CLOCK_CONTROL_LF_CLK32_MASK) -#define WLAN_CLOCK_CONTROL_SI0_CLK_MSB 0 -#define WLAN_CLOCK_CONTROL_SI0_CLK_LSB 0 -#define WLAN_CLOCK_CONTROL_SI0_CLK_MASK 0x00000001 -#define WLAN_CLOCK_CONTROL_SI0_CLK_GET(x) (((x) & WLAN_CLOCK_CONTROL_SI0_CLK_MASK) >> WLAN_CLOCK_CONTROL_SI0_CLK_LSB) -#define WLAN_CLOCK_CONTROL_SI0_CLK_SET(x) (((x) << WLAN_CLOCK_CONTROL_SI0_CLK_LSB) & WLAN_CLOCK_CONTROL_SI0_CLK_MASK) - -#define WLAN_SYSTEM_SLEEP_ADDRESS 0x000000c4 -#define WLAN_SYSTEM_SLEEP_OFFSET 0x000000c4 -#define WLAN_SYSTEM_SLEEP_HOST_IF_MSB 4 -#define WLAN_SYSTEM_SLEEP_HOST_IF_LSB 4 -#define WLAN_SYSTEM_SLEEP_HOST_IF_MASK 0x00000010 -#define WLAN_SYSTEM_SLEEP_HOST_IF_GET(x) (((x) & WLAN_SYSTEM_SLEEP_HOST_IF_MASK) >> WLAN_SYSTEM_SLEEP_HOST_IF_LSB) -#define WLAN_SYSTEM_SLEEP_HOST_IF_SET(x) (((x) << WLAN_SYSTEM_SLEEP_HOST_IF_LSB) & WLAN_SYSTEM_SLEEP_HOST_IF_MASK) -#define WLAN_SYSTEM_SLEEP_MBOX_MSB 3 -#define WLAN_SYSTEM_SLEEP_MBOX_LSB 3 -#define WLAN_SYSTEM_SLEEP_MBOX_MASK 0x00000008 -#define WLAN_SYSTEM_SLEEP_MBOX_GET(x) (((x) & WLAN_SYSTEM_SLEEP_MBOX_MASK) >> WLAN_SYSTEM_SLEEP_MBOX_LSB) -#define WLAN_SYSTEM_SLEEP_MBOX_SET(x) (((x) << WLAN_SYSTEM_SLEEP_MBOX_LSB) & WLAN_SYSTEM_SLEEP_MBOX_MASK) -#define WLAN_SYSTEM_SLEEP_MAC_IF_MSB 2 -#define WLAN_SYSTEM_SLEEP_MAC_IF_LSB 2 -#define WLAN_SYSTEM_SLEEP_MAC_IF_MASK 0x00000004 -#define WLAN_SYSTEM_SLEEP_MAC_IF_GET(x) (((x) & WLAN_SYSTEM_SLEEP_MAC_IF_MASK) >> WLAN_SYSTEM_SLEEP_MAC_IF_LSB) -#define WLAN_SYSTEM_SLEEP_MAC_IF_SET(x) (((x) << WLAN_SYSTEM_SLEEP_MAC_IF_LSB) & WLAN_SYSTEM_SLEEP_MAC_IF_MASK) -#define WLAN_SYSTEM_SLEEP_LIGHT_MSB 1 -#define WLAN_SYSTEM_SLEEP_LIGHT_LSB 1 -#define WLAN_SYSTEM_SLEEP_LIGHT_MASK 0x00000002 -#define WLAN_SYSTEM_SLEEP_LIGHT_GET(x) (((x) & WLAN_SYSTEM_SLEEP_LIGHT_MASK) >> WLAN_SYSTEM_SLEEP_LIGHT_LSB) -#define WLAN_SYSTEM_SLEEP_LIGHT_SET(x) (((x) << WLAN_SYSTEM_SLEEP_LIGHT_LSB) & WLAN_SYSTEM_SLEEP_LIGHT_MASK) -#define WLAN_SYSTEM_SLEEP_DISABLE_MSB 0 -#define WLAN_SYSTEM_SLEEP_DISABLE_LSB 0 -#define WLAN_SYSTEM_SLEEP_DISABLE_MASK 0x00000001 -#define WLAN_SYSTEM_SLEEP_DISABLE_GET(x) (((x) & WLAN_SYSTEM_SLEEP_DISABLE_MASK) >> WLAN_SYSTEM_SLEEP_DISABLE_LSB) -#define WLAN_SYSTEM_SLEEP_DISABLE_SET(x) (((x) << WLAN_SYSTEM_SLEEP_DISABLE_LSB) & WLAN_SYSTEM_SLEEP_DISABLE_MASK) - -#define WLAN_LPO_CAL_ADDRESS 0x000000e0 -#define WLAN_LPO_CAL_OFFSET 0x000000e0 -#define WLAN_LPO_CAL_ENABLE_MSB 20 -#define WLAN_LPO_CAL_ENABLE_LSB 20 -#define WLAN_LPO_CAL_ENABLE_MASK 0x00100000 -#define WLAN_LPO_CAL_ENABLE_GET(x) (((x) & WLAN_LPO_CAL_ENABLE_MASK) >> WLAN_LPO_CAL_ENABLE_LSB) -#define WLAN_LPO_CAL_ENABLE_SET(x) (((x) << WLAN_LPO_CAL_ENABLE_LSB) & WLAN_LPO_CAL_ENABLE_MASK) -#define WLAN_LPO_CAL_COUNT_MSB 19 -#define WLAN_LPO_CAL_COUNT_LSB 0 -#define WLAN_LPO_CAL_COUNT_MASK 0x000fffff -#define WLAN_LPO_CAL_COUNT_GET(x) (((x) & WLAN_LPO_CAL_COUNT_MASK) >> WLAN_LPO_CAL_COUNT_LSB) -#define WLAN_LPO_CAL_COUNT_SET(x) (((x) << WLAN_LPO_CAL_COUNT_LSB) & WLAN_LPO_CAL_COUNT_MASK) - -#endif /* _RTC_WLAN_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/uart_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/uart_reg.h deleted file mode 100644 index 302b20bc1ba..00000000000 --- a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/uart_reg.h +++ /dev/null @@ -1,40 +0,0 @@ -// ------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// ------------------------------------------------------------------ -//=================================================================== -// Author(s): ="Atheros" -//=================================================================== - - -#ifndef _UART_REG_REG_H_ -#define _UART_REG_REG_H_ - -#define UART_CLKDIV_ADDRESS 0x00000008 -#define UART_CLKDIV_OFFSET 0x00000008 -#define UART_CLKDIV_CLK_SCALE_MSB 23 -#define UART_CLKDIV_CLK_SCALE_LSB 16 -#define UART_CLKDIV_CLK_SCALE_MASK 0x00ff0000 -#define UART_CLKDIV_CLK_SCALE_GET(x) (((x) & UART_CLKDIV_CLK_SCALE_MASK) >> UART_CLKDIV_CLK_SCALE_LSB) -#define UART_CLKDIV_CLK_SCALE_SET(x) (((x) << UART_CLKDIV_CLK_SCALE_LSB) & UART_CLKDIV_CLK_SCALE_MASK) -#define UART_CLKDIV_CLK_STEP_MSB 15 -#define UART_CLKDIV_CLK_STEP_LSB 0 -#define UART_CLKDIV_CLK_STEP_MASK 0x0000ffff -#define UART_CLKDIV_CLK_STEP_GET(x) (((x) & UART_CLKDIV_CLK_STEP_MASK) >> UART_CLKDIV_CLK_STEP_LSB) -#define UART_CLKDIV_CLK_STEP_SET(x) (((x) << UART_CLKDIV_CLK_STEP_LSB) & UART_CLKDIV_CLK_STEP_MASK) - -#endif /* _UART_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/athdefs.h b/drivers/staging/ath6kl/include/common/athdefs.h deleted file mode 100644 index 74922481e06..00000000000 --- a/drivers/staging/ath6kl/include/common/athdefs.h +++ /dev/null @@ -1,75 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef __ATHDEFS_H__ -#define __ATHDEFS_H__ - -/* - * This file contains definitions that may be used across both - * Host and Target software. Nothing here is module-dependent - * or platform-dependent. - */ - -/* - * Generic error codes that can be used by hw, sta, ap, sim, dk - * and any other environments. - * Feel free to add any more non-zero codes that you need. - */ - -#define A_ERROR (-1) /* Generic error return */ -#define A_DEVICE_NOT_FOUND 1 /* not able to find PCI device */ -#define A_NO_MEMORY 2 /* not able to allocate memory, - * not avail#defineable */ -#define A_MEMORY_NOT_AVAIL 3 /* memory region is not free for - * mapping */ -#define A_NO_FREE_DESC 4 /* no free descriptors available */ -#define A_BAD_ADDRESS 5 /* address does not match descriptor */ -#define A_WIN_DRIVER_ERROR 6 /* used in NT_HW version, - * if problem at init */ -#define A_REGS_NOT_MAPPED 7 /* registers not correctly mapped */ -#define A_EPERM 8 /* Not superuser */ -#define A_EACCES 0 /* Access denied */ -#define A_ENOENT 10 /* No such entry, search failed, etc. */ -#define A_EEXIST 11 /* The object already exists - * (can't create) */ -#define A_EFAULT 12 /* Bad address fault */ -#define A_EBUSY 13 /* Object is busy */ -#define A_EINVAL 14 /* Invalid parameter */ -#define A_EMSGSIZE 15 /* Bad message buffer length */ -#define A_ECANCELED 16 /* Operation canceled */ -#define A_ENOTSUP 17 /* Operation not supported */ -#define A_ECOMM 18 /* Communication error on send */ -#define A_EPROTO 19 /* Protocol error */ -#define A_ENODEV 20 /* No such device */ -#define A_EDEVNOTUP 21 /* device is not UP */ -#define A_NO_RESOURCE 22 /* No resources for - * requested operation */ -#define A_HARDWARE 23 /* Hardware failure */ -#define A_PENDING 24 /* Asynchronous routine; will send up - * results later - * (typically in callback) */ -#define A_EBADCHANNEL 25 /* The channel cannot be used */ -#define A_DECRYPT_ERROR 26 /* Decryption error */ -#define A_PHY_ERROR 27 /* RX PHY error */ -#define A_CONSUMED 28 /* Object was consumed */ - -#endif /* __ATHDEFS_H__ */ diff --git a/drivers/staging/ath6kl/include/common/bmi_msg.h b/drivers/staging/ath6kl/include/common/bmi_msg.h deleted file mode 100644 index 84e8db569a9..00000000000 --- a/drivers/staging/ath6kl/include/common/bmi_msg.h +++ /dev/null @@ -1,233 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef __BMI_MSG_H__ -#define __BMI_MSG_H__ - -/* - * Bootloader Messaging Interface (BMI) - * - * BMI is a very simple messaging interface used during initialization - * to read memory, write memory, execute code, and to define an - * application entry PC. - * - * It is used to download an application to AR6K, to provide - * patches to code that is already resident on AR6K, and generally - * to examine and modify state. The Host has an opportunity to use - * BMI only once during bootup. Once the Host issues a BMI_DONE - * command, this opportunity ends. - * - * The Host writes BMI requests to mailbox0, and reads BMI responses - * from mailbox0. BMI requests all begin with a command - * (see below for specific commands), and are followed by - * command-specific data. - * - * Flow control: - * The Host can only issue a command once the Target gives it a - * "BMI Command Credit", using AR6K Counter #4. As soon as the - * Target has completed a command, it issues another BMI Command - * Credit (so the Host can issue the next command). - * - * BMI handles all required Target-side cache flushing. - */ - - -/* Maximum data size used for BMI transfers */ -#define BMI_DATASZ_MAX 256 - -/* BMI Commands */ - -#define BMI_NO_COMMAND 0 - -#define BMI_DONE 1 - /* - * Semantics: Host is done using BMI - * Request format: - * u32 command (BMI_DONE) - * Response format: none - */ - -#define BMI_READ_MEMORY 2 - /* - * Semantics: Host reads AR6K memory - * Request format: - * u32 command (BMI_READ_MEMORY) - * u32 address - * u32 length, at most BMI_DATASZ_MAX - * Response format: - * u8 data[length] - */ - -#define BMI_WRITE_MEMORY 3 - /* - * Semantics: Host writes AR6K memory - * Request format: - * u32 command (BMI_WRITE_MEMORY) - * u32 address - * u32 length, at most BMI_DATASZ_MAX - * u8 data[length] - * Response format: none - */ - -#define BMI_EXECUTE 4 - /* - * Semantics: Causes AR6K to execute code - * Request format: - * u32 command (BMI_EXECUTE) - * u32 address - * u32 parameter - * Response format: - * u32 return value - */ - -#define BMI_SET_APP_START 5 - /* - * Semantics: Set Target application starting address - * Request format: - * u32 command (BMI_SET_APP_START) - * u32 address - * Response format: none - */ - -#define BMI_READ_SOC_REGISTER 6 - /* - * Semantics: Read a 32-bit Target SOC register. - * Request format: - * u32 command (BMI_READ_REGISTER) - * u32 address - * Response format: - * u32 value - */ - -#define BMI_WRITE_SOC_REGISTER 7 - /* - * Semantics: Write a 32-bit Target SOC register. - * Request format: - * u32 command (BMI_WRITE_REGISTER) - * u32 address - * u32 value - * - * Response format: none - */ - -#define BMI_GET_TARGET_ID 8 -#define BMI_GET_TARGET_INFO 8 - /* - * Semantics: Fetch the 4-byte Target information - * Request format: - * u32 command (BMI_GET_TARGET_ID/INFO) - * Response format1 (old firmware): - * u32 TargetVersionID - * Response format2 (newer firmware): - * u32 TARGET_VERSION_SENTINAL - * struct bmi_target_info; - */ - -PREPACK struct bmi_target_info { - u32 target_info_byte_count; /* size of this structure */ - u32 target_ver; /* Target Version ID */ - u32 target_type; /* Target type */ -} POSTPACK; -#define TARGET_VERSION_SENTINAL 0xffffffff -#define TARGET_TYPE_AR6001 1 -#define TARGET_TYPE_AR6002 2 -#define TARGET_TYPE_AR6003 3 - - -#define BMI_ROMPATCH_INSTALL 9 - /* - * Semantics: Install a ROM Patch. - * Request format: - * u32 command (BMI_ROMPATCH_INSTALL) - * u32 Target ROM Address - * u32 Target RAM Address or Value (depending on Target Type) - * u32 Size, in bytes - * u32 Activate? 1-->activate; - * 0-->install but do not activate - * Response format: - * u32 PatchID - */ - -#define BMI_ROMPATCH_UNINSTALL 10 - /* - * Semantics: Uninstall a previously-installed ROM Patch, - * automatically deactivating, if necessary. - * Request format: - * u32 command (BMI_ROMPATCH_UNINSTALL) - * u32 PatchID - * - * Response format: none - */ - -#define BMI_ROMPATCH_ACTIVATE 11 - /* - * Semantics: Activate a list of previously-installed ROM Patches. - * Request format: - * u32 command (BMI_ROMPATCH_ACTIVATE) - * u32 rompatch_count - * u32 PatchID[rompatch_count] - * - * Response format: none - */ - -#define BMI_ROMPATCH_DEACTIVATE 12 - /* - * Semantics: Deactivate a list of active ROM Patches. - * Request format: - * u32 command (BMI_ROMPATCH_DEACTIVATE) - * u32 rompatch_count - * u32 PatchID[rompatch_count] - * - * Response format: none - */ - - -#define BMI_LZ_STREAM_START 13 - /* - * Semantics: Begin an LZ-compressed stream of input - * which is to be uncompressed by the Target to an - * output buffer at address. The output buffer must - * be sufficiently large to hold the uncompressed - * output from the compressed input stream. This BMI - * command should be followed by a series of 1 or more - * BMI_LZ_DATA commands. - * u32 command (BMI_LZ_STREAM_START) - * u32 address - * Note: Not supported on all versions of ROM firmware. - */ - -#define BMI_LZ_DATA 14 - /* - * Semantics: Host writes AR6K memory with LZ-compressed - * data which is uncompressed by the Target. This command - * must be preceded by a BMI_LZ_STREAM_START command. A series - * of BMI_LZ_DATA commands are considered part of a single - * input stream until another BMI_LZ_STREAM_START is issued. - * Request format: - * u32 command (BMI_LZ_DATA) - * u32 length (of compressed data), - * at most BMI_DATASZ_MAX - * u8 CompressedData[length] - * Response format: none - * Note: Not supported on all versions of ROM firmware. - */ - -#endif /* __BMI_MSG_H__ */ diff --git a/drivers/staging/ath6kl/include/common/cnxmgmt.h b/drivers/staging/ath6kl/include/common/cnxmgmt.h deleted file mode 100644 index 7a902cb5483..00000000000 --- a/drivers/staging/ath6kl/include/common/cnxmgmt.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _CNXMGMT_H_ -#define _CNXMGMT_H_ - -typedef enum { - CM_CONNECT_WITHOUT_SCAN = 0x0001, - CM_CONNECT_ASSOC_POLICY_USER = 0x0002, - CM_CONNECT_SEND_REASSOC = 0x0004, - CM_CONNECT_WITHOUT_ROAMTABLE_UPDATE = 0x0008, - CM_CONNECT_DO_WPA_OFFLOAD = 0x0010, - CM_CONNECT_DO_NOT_DEAUTH = 0x0020, -} CM_CONNECT_TYPE; - -#endif /* _CNXMGMT_H_ */ diff --git a/drivers/staging/ath6kl/include/common/dbglog.h b/drivers/staging/ath6kl/include/common/dbglog.h deleted file mode 100644 index 5566e568b83..00000000000 --- a/drivers/staging/ath6kl/include/common/dbglog.h +++ /dev/null @@ -1,126 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _DBGLOG_H_ -#define _DBGLOG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DBGLOG_TIMESTAMP_OFFSET 0 -#define DBGLOG_TIMESTAMP_MASK 0x0000FFFF /* Bit 0-15. Contains bit - 8-23 of the LF0 timer */ -#define DBGLOG_DBGID_OFFSET 16 -#define DBGLOG_DBGID_MASK 0x03FF0000 /* Bit 16-25 */ -#define DBGLOG_DBGID_NUM_MAX 256 /* Upper limit is width of mask */ - -#define DBGLOG_MODULEID_OFFSET 26 -#define DBGLOG_MODULEID_MASK 0x3C000000 /* Bit 26-29 */ -#define DBGLOG_MODULEID_NUM_MAX 16 /* Upper limit is width of mask */ - -/* - * Please ensure that the definition of any new module introduced is captured - * between the DBGLOG_MODULEID_START and DBGLOG_MODULEID_END defines. The - * structure is required for the parser to correctly pick up the values for - * different modules. - */ -#define DBGLOG_MODULEID_START -#define DBGLOG_MODULEID_INF 0 -#define DBGLOG_MODULEID_WMI 1 -#define DBGLOG_MODULEID_MISC 2 -#define DBGLOG_MODULEID_PM 3 -#define DBGLOG_MODULEID_TXRX_MGMTBUF 4 -#define DBGLOG_MODULEID_TXRX_TXBUF 5 -#define DBGLOG_MODULEID_TXRX_RXBUF 6 -#define DBGLOG_MODULEID_WOW 7 -#define DBGLOG_MODULEID_WHAL 8 -#define DBGLOG_MODULEID_DC 9 -#define DBGLOG_MODULEID_CO 10 -#define DBGLOG_MODULEID_RO 11 -#define DBGLOG_MODULEID_CM 12 -#define DBGLOG_MODULEID_MGMT 13 -#define DBGLOG_MODULEID_TMR 14 -#define DBGLOG_MODULEID_BTCOEX 15 -#define DBGLOG_MODULEID_END - -#define DBGLOG_NUM_ARGS_OFFSET 30 -#define DBGLOG_NUM_ARGS_MASK 0xC0000000 /* Bit 30-31 */ -#define DBGLOG_NUM_ARGS_MAX 2 /* Upper limit is width of mask */ - -#define DBGLOG_MODULE_LOG_ENABLE_OFFSET 0 -#define DBGLOG_MODULE_LOG_ENABLE_MASK 0x0000FFFF - -#define DBGLOG_REPORTING_ENABLED_OFFSET 16 -#define DBGLOG_REPORTING_ENABLED_MASK 0x00010000 - -#define DBGLOG_TIMESTAMP_RESOLUTION_OFFSET 17 -#define DBGLOG_TIMESTAMP_RESOLUTION_MASK 0x000E0000 - -#define DBGLOG_REPORT_SIZE_OFFSET 20 -#define DBGLOG_REPORT_SIZE_MASK 0x3FF00000 - -#define DBGLOG_LOG_BUFFER_SIZE 1500 -#define DBGLOG_DBGID_DEFINITION_LEN_MAX 90 - -PREPACK struct dbglog_buf_s { - struct dbglog_buf_s *next; - u8 *buffer; - u32 bufsize; - u32 length; - u32 count; - u32 free; -} POSTPACK; - -PREPACK struct dbglog_hdr_s { - struct dbglog_buf_s *dbuf; - u32 dropped; -} POSTPACK; - -PREPACK struct dbglog_config_s { - u32 cfgvalid; /* Mask with valid config bits */ - union { - /* TODO: Take care of endianness */ - struct { - u32 mmask:16; /* Mask of modules with logging on */ - u32 rep:1; /* Reporting enabled or not */ - u32 tsr:3; /* Time stamp resolution. Def: 1 ms */ - u32 size:10; /* Report size in number of messages */ - u32 reserved:2; - } dbglog_config; - - u32 value; - } u; -} POSTPACK; - -#define cfgmmask u.dbglog_config.mmask -#define cfgrep u.dbglog_config.rep -#define cfgtsr u.dbglog_config.tsr -#define cfgsize u.dbglog_config.size -#define cfgvalue u.value - -#ifdef __cplusplus -} -#endif - -#endif /* _DBGLOG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/dbglog_id.h b/drivers/staging/ath6kl/include/common/dbglog_id.h deleted file mode 100644 index 15ef829cab2..00000000000 --- a/drivers/staging/ath6kl/include/common/dbglog_id.h +++ /dev/null @@ -1,558 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _DBGLOG_ID_H_ -#define _DBGLOG_ID_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The nomenclature for the debug identifiers is MODULE_DESCRIPTION. - * Please ensure that the definition of any new debugid introduced is captured - * between the _DBGID_DEFINITION_START and - * _DBGID_DEFINITION_END defines. The structure is required for the - * parser to correctly pick up the values for different debug identifiers. - */ - -/* INF debug identifier definitions */ -#define INF_DBGID_DEFINITION_START -#define INF_ASSERTION_FAILED 1 -#define INF_TARGET_ID 2 -#define INF_DBGID_DEFINITION_END - -/* WMI debug identifier definitions */ -#define WMI_DBGID_DEFINITION_START -#define WMI_CMD_RX_XTND_PKT_TOO_SHORT 1 -#define WMI_EXTENDED_CMD_NOT_HANDLED 2 -#define WMI_CMD_RX_PKT_TOO_SHORT 3 -#define WMI_CALLING_WMI_EXTENSION_FN 4 -#define WMI_CMD_NOT_HANDLED 5 -#define WMI_IN_SYNC 6 -#define WMI_TARGET_WMI_SYNC_CMD 7 -#define WMI_SET_SNR_THRESHOLD_PARAMS 8 -#define WMI_SET_RSSI_THRESHOLD_PARAMS 9 -#define WMI_SET_LQ_TRESHOLD_PARAMS 10 -#define WMI_TARGET_CREATE_PSTREAM_CMD 11 -#define WMI_WI_DTM_INUSE 12 -#define WMI_TARGET_DELETE_PSTREAM_CMD 13 -#define WMI_TARGET_IMPLICIT_DELETE_PSTREAM_CMD 14 -#define WMI_TARGET_GET_BIT_RATE_CMD 15 -#define WMI_GET_RATE_MASK_CMD_FIX_RATE_MASK_IS 16 -#define WMI_TARGET_GET_AVAILABLE_CHANNELS_CMD 17 -#define WMI_TARGET_GET_TX_PWR_CMD 18 -#define WMI_FREE_EVBUF_WMIBUF 19 -#define WMI_FREE_EVBUF_DATABUF 20 -#define WMI_FREE_EVBUF_BADFLAG 21 -#define WMI_HTC_RX_ERROR_DATA_PACKET 22 -#define WMI_HTC_RX_SYNC_PAUSING_FOR_MBOX 23 -#define WMI_INCORRECT_WMI_DATA_HDR_DROPPING_PKT 24 -#define WMI_SENDING_READY_EVENT 25 -#define WMI_SETPOWER_MDOE_TO_MAXPERF 26 -#define WMI_SETPOWER_MDOE_TO_REC 27 -#define WMI_BSSINFO_EVENT_FROM 28 -#define WMI_TARGET_GET_STATS_CMD 29 -#define WMI_SENDING_SCAN_COMPLETE_EVENT 30 -#define WMI_SENDING_RSSI_INDB_THRESHOLD_EVENT 31 -#define WMI_SENDING_RSSI_INDBM_THRESHOLD_EVENT 32 -#define WMI_SENDING_LINK_QUALITY_THRESHOLD_EVENT 33 -#define WMI_SENDING_ERROR_REPORT_EVENT 34 -#define WMI_SENDING_CAC_EVENT 35 -#define WMI_TARGET_GET_ROAM_TABLE_CMD 36 -#define WMI_TARGET_GET_ROAM_DATA_CMD 37 -#define WMI_SENDING_GPIO_INTR_EVENT 38 -#define WMI_SENDING_GPIO_ACK_EVENT 39 -#define WMI_SENDING_GPIO_DATA_EVENT 40 -#define WMI_CMD_RX 41 -#define WMI_CMD_RX_XTND 42 -#define WMI_EVENT_SEND 43 -#define WMI_EVENT_SEND_XTND 44 -#define WMI_CMD_PARAMS_DUMP_START 45 -#define WMI_CMD_PARAMS_DUMP_END 46 -#define WMI_CMD_PARAMS 47 -#define WMI_DBGID_DEFINITION_END - -/* MISC debug identifier definitions */ -#define MISC_DBGID_DEFINITION_START -#define MISC_WLAN_SCHEDULER_EVENT_REGISTER_ERROR 1 -#define TLPM_INIT 2 -#define TLPM_FILTER_POWER_STATE 3 -#define TLPM_NOTIFY_NOT_IDLE 4 -#define TLPM_TIMEOUT_IDLE_HANDLER 5 -#define TLPM_TIMEOUT_WAKEUP_HANDLER 6 -#define TLPM_WAKEUP_SIGNAL_HANDLER 7 -#define TLPM_UNEXPECTED_GPIO_INTR_ERROR 8 -#define TLPM_BREAK_ON_NOT_RECEIVED_ERROR 9 -#define TLPM_BREAK_OFF_NOT_RECIVED_ERROR 10 -#define TLPM_ACK_GPIO_INTR 11 -#define TLPM_ON 12 -#define TLPM_OFF 13 -#define TLPM_WAKEUP_FROM_HOST 14 -#define TLPM_WAKEUP_FROM_BT 15 -#define TLPM_TX_BREAK_RECIVED 16 -#define TLPM_IDLE_TIMER_NOT_RUNNING 17 -#define MISC_DBGID_DEFINITION_END - -/* TXRX debug identifier definitions */ -#define TXRX_TXBUF_DBGID_DEFINITION_START -#define TXRX_TXBUF_ALLOCATE_BUF 1 -#define TXRX_TXBUF_QUEUE_BUF_TO_MBOX 2 -#define TXRX_TXBUF_QUEUE_BUF_TO_TXQ 3 -#define TXRX_TXBUF_TXQ_DEPTH 4 -#define TXRX_TXBUF_IBSS_QUEUE_TO_SFQ 5 -#define TXRX_TXBUF_IBSS_QUEUE_TO_TXQ_FRM_SFQ 6 -#define TXRX_TXBUF_INITIALIZE_TIMER 7 -#define TXRX_TXBUF_ARM_TIMER 8 -#define TXRX_TXBUF_DISARM_TIMER 9 -#define TXRX_TXBUF_UNINITIALIZE_TIMER 10 -#define TXRX_TXBUF_DBGID_DEFINITION_END - -#define TXRX_RXBUF_DBGID_DEFINITION_START -#define TXRX_RXBUF_ALLOCATE_BUF 1 -#define TXRX_RXBUF_QUEUE_TO_HOST 2 -#define TXRX_RXBUF_QUEUE_TO_WLAN 3 -#define TXRX_RXBUF_ZERO_LEN_BUF 4 -#define TXRX_RXBUF_QUEUE_TO_HOST_LASTBUF_IN_RXCHAIN 5 -#define TXRX_RXBUF_LASTBUF_IN_RXCHAIN_ZEROBUF 6 -#define TXRX_RXBUF_QUEUE_EMPTY_QUEUE_TO_WLAN 7 -#define TXRX_RXBUF_SEND_TO_RECV_MGMT 8 -#define TXRX_RXBUF_SEND_TO_IEEE_LAYER 9 -#define TXRX_RXBUF_REQUEUE_ERROR 10 -#define TXRX_RXBUF_DBGID_DEFINITION_END - -#define TXRX_MGMTBUF_DBGID_DEFINITION_START -#define TXRX_MGMTBUF_ALLOCATE_BUF 1 -#define TXRX_MGMTBUF_ALLOCATE_SM_BUF 2 -#define TXRX_MGMTBUF_ALLOCATE_RMBUF 3 -#define TXRX_MGMTBUF_GET_BUF 4 -#define TXRX_MGMTBUF_GET_SM_BUF 5 -#define TXRX_MGMTBUF_QUEUE_BUF_TO_TXQ 6 -#define TXRX_MGMTBUF_REAPED_BUF 7 -#define TXRX_MGMTBUF_REAPED_SM_BUF 8 -#define TXRX_MGMTBUF_WAIT_FOR_TXQ_DRAIN 9 -#define TXRX_MGMTBUF_WAIT_FOR_TXQ_SFQ_DRAIN 10 -#define TXRX_MGMTBUF_ENQUEUE_INTO_DATA_SFQ 11 -#define TXRX_MGMTBUF_DEQUEUE_FROM_DATA_SFQ 12 -#define TXRX_MGMTBUF_PAUSE_DATA_TXQ 13 -#define TXRX_MGMTBUF_RESUME_DATA_TXQ 14 -#define TXRX_MGMTBUF_WAIT_FORTXQ_DRAIN_TIMEOUT 15 -#define TXRX_MGMTBUF_DRAINQ 16 -#define TXRX_MGMTBUF_INDICATE_Q_DRAINED 17 -#define TXRX_MGMTBUF_ENQUEUE_INTO_HW_SFQ 18 -#define TXRX_MGMTBUF_DEQUEUE_FROM_HW_SFQ 19 -#define TXRX_MGMTBUF_PAUSE_HW_TXQ 20 -#define TXRX_MGMTBUF_RESUME_HW_TXQ 21 -#define TXRX_MGMTBUF_TEAR_DOWN_BA 22 -#define TXRX_MGMTBUF_PROCESS_ADDBA_REQ 23 -#define TXRX_MGMTBUF_PROCESS_DELBA 24 -#define TXRX_MGMTBUF_PERFORM_BA 25 -#define TXRX_MGMTBUF_WLAN_RESET_ON_ERROR 26 -#define TXRX_MGMTBUF_DBGID_DEFINITION_END - -/* PM (Power Module) debug identifier definitions */ -#define PM_DBGID_DEFINITION_START -#define PM_INIT 1 -#define PM_ENABLE 2 -#define PM_SET_STATE 3 -#define PM_SET_POWERMODE 4 -#define PM_CONN_NOTIFY 5 -#define PM_REF_COUNT_NEGATIVE 6 -#define PM_INFRA_STA_APSD_ENABLE 7 -#define PM_INFRA_STA_UPDATE_APSD_STATE 8 -#define PM_CHAN_OP_REQ 9 -#define PM_SET_MY_BEACON_POLICY 10 -#define PM_SET_ALL_BEACON_POLICY 11 -#define PM_INFRA_STA_SET_PM_PARAMS1 12 -#define PM_INFRA_STA_SET_PM_PARAMS2 13 -#define PM_ADHOC_SET_PM_CAPS_FAIL 14 -#define PM_ADHOC_UNKNOWN_IBSS_ATTRIB_ID 15 -#define PM_ADHOC_SET_PM_PARAMS 16 -#define PM_ADHOC_STATE1 18 -#define PM_ADHOC_STATE2 19 -#define PM_ADHOC_CONN_MAP 20 -#define PM_FAKE_SLEEP 21 -#define PM_AP_STATE1 22 -#define PM_AP_SET_PM_PARAMS 23 -#define PM_DBGID_DEFINITION_END - -/* Wake on Wireless debug identifier definitions */ -#define WOW_DBGID_DEFINITION_START -#define WOW_INIT 1 -#define WOW_GET_CONFIG_DSET 2 -#define WOW_NO_CONFIG_DSET 3 -#define WOW_INVALID_CONFIG_DSET 4 -#define WOW_USE_DEFAULT_CONFIG 5 -#define WOW_SETUP_GPIO 6 -#define WOW_INIT_DONE 7 -#define WOW_SET_GPIO_PIN 8 -#define WOW_CLEAR_GPIO_PIN 9 -#define WOW_SET_WOW_MODE_CMD 10 -#define WOW_SET_HOST_MODE_CMD 11 -#define WOW_ADD_WOW_PATTERN_CMD 12 -#define WOW_NEW_WOW_PATTERN_AT_INDEX 13 -#define WOW_DEL_WOW_PATTERN_CMD 14 -#define WOW_LIST_CONTAINS_PATTERNS 15 -#define WOW_GET_WOW_LIST_CMD 16 -#define WOW_INVALID_FILTER_ID 17 -#define WOW_INVALID_FILTER_LISTID 18 -#define WOW_NO_VALID_FILTER_AT_ID 19 -#define WOW_NO_VALID_LIST_AT_ID 20 -#define WOW_NUM_PATTERNS_EXCEEDED 21 -#define WOW_NUM_LISTS_EXCEEDED 22 -#define WOW_GET_WOW_STATS 23 -#define WOW_CLEAR_WOW_STATS 24 -#define WOW_WAKEUP_HOST 25 -#define WOW_EVENT_WAKEUP_HOST 26 -#define WOW_EVENT_DISCARD 27 -#define WOW_PATTERN_MATCH 28 -#define WOW_PATTERN_NOT_MATCH 29 -#define WOW_PATTERN_NOT_MATCH_OFFSET 30 -#define WOW_DISABLED_HOST_ASLEEP 31 -#define WOW_ENABLED_HOST_ASLEEP_NO_PATTERNS 32 -#define WOW_ENABLED_HOST_ASLEEP_NO_MATCH_FOUND 33 -#define WOW_DBGID_DEFINITION_END - -/* WHAL debug identifier definitions */ -#define WHAL_DBGID_DEFINITION_START -#define WHAL_ERROR_ANI_CONTROL 1 -#define WHAL_ERROR_CHIP_TEST1 2 -#define WHAL_ERROR_CHIP_TEST2 3 -#define WHAL_ERROR_EEPROM_CHECKSUM 4 -#define WHAL_ERROR_EEPROM_MACADDR 5 -#define WHAL_ERROR_INTERRUPT_HIU 6 -#define WHAL_ERROR_KEYCACHE_RESET 7 -#define WHAL_ERROR_KEYCACHE_SET 8 -#define WHAL_ERROR_KEYCACHE_TYPE 9 -#define WHAL_ERROR_KEYCACHE_TKIPENTRY 10 -#define WHAL_ERROR_KEYCACHE_WEPLENGTH 11 -#define WHAL_ERROR_PHY_INVALID_CHANNEL 12 -#define WHAL_ERROR_POWER_AWAKE 13 -#define WHAL_ERROR_POWER_SET 14 -#define WHAL_ERROR_RECV_STOPDMA 15 -#define WHAL_ERROR_RECV_STOPPCU 16 -#define WHAL_ERROR_RESET_CHANNF1 17 -#define WHAL_ERROR_RESET_CHANNF2 18 -#define WHAL_ERROR_RESET_PM 19 -#define WHAL_ERROR_RESET_OFFSETCAL 20 -#define WHAL_ERROR_RESET_RFGRANT 21 -#define WHAL_ERROR_RESET_RXFRAME 22 -#define WHAL_ERROR_RESET_STOPDMA 23 -#define WHAL_ERROR_RESET_RECOVER 24 -#define WHAL_ERROR_XMIT_COMPUTE 25 -#define WHAL_ERROR_XMIT_NOQUEUE 26 -#define WHAL_ERROR_XMIT_ACTIVEQUEUE 27 -#define WHAL_ERROR_XMIT_BADTYPE 28 -#define WHAL_ERROR_XMIT_STOPDMA 29 -#define WHAL_ERROR_INTERRUPT_BB_PANIC 30 -#define WHAL_ERROR_RESET_TXIQCAL 31 -#define WHAL_ERROR_PAPRD_MAXGAIN_ABOVE_WINDOW 32 -#define WHAL_DBGID_DEFINITION_END - -/* DC debug identifier definitions */ -#define DC_DBGID_DEFINITION_START -#define DC_SCAN_CHAN_START 1 -#define DC_SCAN_CHAN_FINISH 2 -#define DC_BEACON_RECEIVE7 3 -#define DC_SSID_PROBE_CB 4 -#define DC_SEND_NEXT_SSID_PROBE 5 -#define DC_START_SEARCH 6 -#define DC_CANCEL_SEARCH_CB 7 -#define DC_STOP_SEARCH 8 -#define DC_END_SEARCH 9 -#define DC_MIN_CHDWELL_TIMEOUT 10 -#define DC_START_SEARCH_CANCELED 11 -#define DC_SET_POWER_MODE 12 -#define DC_INIT 13 -#define DC_SEARCH_OPPORTUNITY 14 -#define DC_RECEIVED_ANY_BEACON 15 -#define DC_RECEIVED_MY_BEACON 16 -#define DC_PROFILE_IS_ADHOC_BUT_BSS_IS_INFRA 17 -#define DC_PS_ENABLED_BUT_ATHEROS_IE_ABSENT 18 -#define DC_BSS_ADHOC_CHANNEL_NOT_ALLOWED 19 -#define DC_SET_BEACON_UPDATE 20 -#define DC_BEACON_UPDATE_COMPLETE 21 -#define DC_END_SEARCH_BEACON_UPDATE_COMP_CB 22 -#define DC_BSSINFO_EVENT_DROPPED 23 -#define DC_IEEEPS_ENABLED_BUT_ATIM_ABSENT 24 -#define DC_DBGID_DEFINITION_END - -/* CO debug identifier definitions */ -#define CO_DBGID_DEFINITION_START -#define CO_INIT 1 -#define CO_ACQUIRE_LOCK 2 -#define CO_START_OP1 3 -#define CO_START_OP2 4 -#define CO_DRAIN_TX_COMPLETE_CB 5 -#define CO_CHANGE_CHANNEL_CB 6 -#define CO_RETURN_TO_HOME_CHANNEL 7 -#define CO_FINISH_OP_TIMEOUT 8 -#define CO_OP_END 9 -#define CO_CANCEL_OP 10 -#define CO_CHANGE_CHANNEL 11 -#define CO_RELEASE_LOCK 12 -#define CO_CHANGE_STATE 13 -#define CO_DBGID_DEFINITION_END - -/* RO debug identifier definitions */ -#define RO_DBGID_DEFINITION_START -#define RO_REFRESH_ROAM_TABLE 1 -#define RO_UPDATE_ROAM_CANDIDATE 2 -#define RO_UPDATE_ROAM_CANDIDATE_CB 3 -#define RO_UPDATE_ROAM_CANDIDATE_FINISH 4 -#define RO_REFRESH_ROAM_TABLE_DONE 5 -#define RO_PERIODIC_SEARCH_CB 6 -#define RO_PERIODIC_SEARCH_TIMEOUT 7 -#define RO_INIT 8 -#define RO_BMISS_STATE1 9 -#define RO_BMISS_STATE2 10 -#define RO_SET_PERIODIC_SEARCH_ENABLE 11 -#define RO_SET_PERIODIC_SEARCH_DISABLE 12 -#define RO_ENABLE_SQ_THRESHOLD 13 -#define RO_DISABLE_SQ_THRESHOLD 14 -#define RO_ADD_BSS_TO_ROAM_TABLE 15 -#define RO_SET_PERIODIC_SEARCH_MODE 16 -#define RO_CONFIGURE_SQ_THRESHOLD1 17 -#define RO_CONFIGURE_SQ_THRESHOLD2 18 -#define RO_CONFIGURE_SQ_PARAMS 19 -#define RO_LOW_SIGNAL_QUALITY_EVENT 20 -#define RO_HIGH_SIGNAL_QUALITY_EVENT 21 -#define RO_REMOVE_BSS_FROM_ROAM_TABLE 22 -#define RO_UPDATE_CONNECTION_STATE_METRIC 23 -#define RO_DBGID_DEFINITION_END - -/* CM debug identifier definitions */ -#define CM_DBGID_DEFINITION_START -#define CM_INITIATE_HANDOFF 1 -#define CM_INITIATE_HANDOFF_CB 2 -#define CM_CONNECT_EVENT 3 -#define CM_DISCONNECT_EVENT 4 -#define CM_INIT 5 -#define CM_HANDOFF_SOURCE 6 -#define CM_SET_HANDOFF_TRIGGERS 7 -#define CM_CONNECT_REQUEST 8 -#define CM_CONNECT_REQUEST_CB 9 -#define CM_CONTINUE_SCAN_CB 10 -#define CM_DBGID_DEFINITION_END - - -/* mgmt debug identifier definitions */ -#define MGMT_DBGID_DEFINITION_START -#define KEYMGMT_CONNECTION_INIT 1 -#define KEYMGMT_CONNECTION_COMPLETE 2 -#define KEYMGMT_CONNECTION_CLOSE 3 -#define KEYMGMT_ADD_KEY 4 -#define MLME_NEW_STATE 5 -#define MLME_CONN_INIT 6 -#define MLME_CONN_COMPLETE 7 -#define MLME_CONN_CLOSE 8 -#define MGMT_DBGID_DEFINITION_END - -/* TMR debug identifier definitions */ -#define TMR_DBGID_DEFINITION_START -#define TMR_HANG_DETECTED 1 -#define TMR_WDT_TRIGGERED 2 -#define TMR_WDT_RESET 3 -#define TMR_HANDLER_ENTRY 4 -#define TMR_HANDLER_EXIT 5 -#define TMR_SAVED_START 6 -#define TMR_SAVED_END 7 -#define TMR_DBGID_DEFINITION_END - -/* BTCOEX debug identifier definitions */ -#define BTCOEX_DBGID_DEFINITION_START -#define BTCOEX_STATUS_CMD 1 -#define BTCOEX_PARAMS_CMD 2 -#define BTCOEX_ANT_CONFIG 3 -#define BTCOEX_COLOCATED_BT_DEVICE 4 -#define BTCOEX_CLOSE_RANGE_SCO_ON 5 -#define BTCOEX_CLOSE_RANGE_SCO_OFF 6 -#define BTCOEX_CLOSE_RANGE_A2DP_ON 7 -#define BTCOEX_CLOSE_RANGE_A2DP_OFF 8 -#define BTCOEX_A2DP_PROTECT_ON 9 -#define BTCOEX_A2DP_PROTECT_OFF 10 -#define BTCOEX_SCO_PROTECT_ON 11 -#define BTCOEX_SCO_PROTECT_OFF 12 -#define BTCOEX_CLOSE_RANGE_DETECTOR_START 13 -#define BTCOEX_CLOSE_RANGE_DETECTOR_STOP 14 -#define BTCOEX_CLOSE_RANGE_TOGGLE 15 -#define BTCOEX_CLOSE_RANGE_TOGGLE_RSSI_LRCNT 16 -#define BTCOEX_CLOSE_RANGE_RSSI_THRESH 17 -#define BTCOEX_CLOSE_RANGE_LOW_RATE_THRESH 18 -#define BTCOEX_PTA_PRI_INTR_HANDLER 19 -#define BTCOEX_PSPOLL_QUEUED 20 -#define BTCOEX_PSPOLL_COMPLETE 21 -#define BTCOEX_DBG_PM_AWAKE 22 -#define BTCOEX_DBG_PM_SLEEP 23 -#define BTCOEX_DBG_SCO_COEX_ON 24 -#define BTCOEX_SCO_DATARECEIVE 25 -#define BTCOEX_INTR_INIT 26 -#define BTCOEX_PTA_PRI_DIFF 27 -#define BTCOEX_TIM_NOTIFICATION 28 -#define BTCOEX_SCO_WAKEUP_ON_DATA 29 -#define BTCOEX_SCO_SLEEP 30 -#define BTCOEX_SET_WEIGHTS 31 -#define BTCOEX_SCO_DATARECEIVE_LATENCY_VAL 32 -#define BTCOEX_SCO_MEASURE_TIME_DIFF 33 -#define BTCOEX_SET_EOL_VAL 34 -#define BTCOEX_OPT_DETECT_HANDLER 35 -#define BTCOEX_SCO_TOGGLE_STATE 36 -#define BTCOEX_SCO_STOMP 37 -#define BTCOEX_NULL_COMP_CALLBACK 38 -#define BTCOEX_RX_INCOMING 39 -#define BTCOEX_RX_INCOMING_CTL 40 -#define BTCOEX_RX_INCOMING_MGMT 41 -#define BTCOEX_RX_INCOMING_DATA 42 -#define BTCOEX_RTS_RECEPTION 43 -#define BTCOEX_FRAME_PRI_LOW_RATE_THRES 44 -#define BTCOEX_PM_FAKE_SLEEP 45 -#define BTCOEX_ACL_COEX_STATUS 46 -#define BTCOEX_ACL_COEX_DETECTION 47 -#define BTCOEX_A2DP_COEX_STATUS 48 -#define BTCOEX_SCO_STATUS 49 -#define BTCOEX_WAKEUP_ON_DATA 50 -#define BTCOEX_DATARECEIVE 51 -#define BTCOEX_GET_MAX_AGGR_SIZE 53 -#define BTCOEX_MAX_AGGR_AVAIL_TIME 54 -#define BTCOEX_DBG_WBTIMER_INTR 55 -#define BTCOEX_DBG_SCO_SYNC 57 -#define BTCOEX_UPLINK_QUEUED_RATE 59 -#define BTCOEX_DBG_UPLINK_ENABLE_EOL 60 -#define BTCOEX_UPLINK_FRAME_DURATION 61 -#define BTCOEX_UPLINK_SET_EOL 62 -#define BTCOEX_DBG_EOL_EXPIRED 63 -#define BTCOEX_DBG_DATA_COMPLETE 64 -#define BTCOEX_UPLINK_QUEUED_TIMESTAMP 65 -#define BTCOEX_DBG_DATA_COMPLETE_TIME 66 -#define BTCOEX_DBG_A2DP_ROLE_IS_SLAVE 67 -#define BTCOEX_DBG_A2DP_ROLE_IS_MASTER 68 -#define BTCOEX_DBG_UPLINK_SEQ_NUM 69 -#define BTCOEX_UPLINK_AGGR_SEQ 70 -#define BTCOEX_DBG_TX_COMP_SEQ_NO 71 -#define BTCOEX_DBG_MAX_AGGR_PAUSE_STATE 72 -#define BTCOEX_DBG_ACL_TRAFFIC 73 -#define BTCOEX_CURR_AGGR_PROP 74 -#define BTCOEX_DBG_SCO_GET_PER_TIME_DIFF 75 -#define BTCOEX_PSPOLL_PROCESS 76 -#define BTCOEX_RETURN_FROM_MAC 77 -#define BTCOEX_FREED_REQUEUED_CNT 78 -#define BTCOEX_DBG_TOGGLE_LOW_RATES 79 -#define BTCOEX_MAC_GOES_TO_SLEEP 80 -#define BTCOEX_DBG_A2DP_NO_SYNC 81 -#define BTCOEX_RETURN_FROM_MAC_HOLD_Q_INFO 82 -#define BTCOEX_RETURN_FROM_MAC_AC 83 -#define BTCOEX_DBG_DTIM_RECV 84 -#define BTCOEX_IS_PRE_UPDATE 86 -#define BTCOEX_ENQUEUED_BIT_MAP 87 -#define BTCOEX_TX_COMPLETE_FIRST_DESC_STATS 88 -#define BTCOEX_UPLINK_DESC 89 -#define BTCOEX_SCO_GET_PER_FIRST_FRM_TIMESTAMP 90 -#define BTCOEX_DBG_RECV_ACK 94 -#define BTCOEX_DBG_ADDBA_INDICATION 95 -#define BTCOEX_TX_COMPLETE_EOL_FAILED 96 -#define BTCOEX_DBG_A2DP_USAGE_COMPLETE 97 -#define BTCOEX_DBG_A2DP_STOMP_FOR_BCN_HANDLER 98 -#define BTCOEX_DBG_A2DP_SYNC_INTR 99 -#define BTCOEX_DBG_A2DP_STOMP_FOR_BCN_RECEPTION 100 -#define BTCOEX_FORM_AGGR_CURR_AGGR 101 -#define BTCOEX_DBG_TOGGLE_A2DP_BURST_CNT 102 -#define BTCOEX_DBG_BT_TRAFFIC 103 -#define BTCOEX_DBG_STOMP_BT_TRAFFIC 104 -#define BTCOEX_RECV_NULL 105 -#define BTCOEX_DBG_A2DP_MASTER_BT_END 106 -#define BTCOEX_DBG_A2DP_BT_START 107 -#define BTCOEX_DBG_A2DP_SLAVE_BT_END 108 -#define BTCOEX_DBG_A2DP_STOMP_BT 109 -#define BTCOEX_DBG_GO_TO_SLEEP 110 -#define BTCOEX_DBG_A2DP_PKT 111 -#define BTCOEX_DBG_A2DP_PSPOLL_DATA_RECV 112 -#define BTCOEX_DBG_A2DP_NULL 113 -#define BTCOEX_DBG_UPLINK_DATA 114 -#define BTCOEX_DBG_A2DP_STOMP_LOW_PRIO_NULL 115 -#define BTCOEX_DBG_ADD_BA_RESP_TIMEOUT 116 -#define BTCOEX_DBG_TXQ_STATE 117 -#define BTCOEX_DBG_ALLOW_SCAN 118 -#define BTCOEX_DBG_SCAN_REQUEST 119 -#define BTCOEX_A2DP_SLEEP 127 -#define BTCOEX_DBG_DATA_ACTIV_TIMEOUT 128 -#define BTCOEX_DBG_SWITCH_TO_PSPOLL_ON_MODE 129 -#define BTCOEX_DBG_SWITCH_TO_PSPOLL_OFF_MODE 130 -#define BTCOEX_DATARECEIVE_AGGR 131 -#define BTCOEX_DBG_DATA_RECV_SLEEPING_PENDING 132 -#define BTCOEX_DBG_DATARESP_TIMEOUT 133 -#define BTCOEX_BDG_BMISS 134 -#define BTCOEX_DBG_DATA_RECV_WAKEUP_TIM 135 -#define BTCOEX_DBG_SECOND_BMISS 136 -#define BTCOEX_DBG_SET_WLAN_STATE 138 -#define BTCOEX_BDG_FIRST_BMISS 139 -#define BTCOEX_DBG_A2DP_CHAN_OP 140 -#define BTCOEX_DBG_A2DP_INTR 141 -#define BTCOEX_DBG_BT_INQUIRY 142 -#define BTCOEX_DBG_BT_INQUIRY_DATA_FETCH 143 -#define BTCOEX_DBG_POST_INQUIRY_FINISH 144 -#define BTCOEX_DBG_SCO_OPT_MODE_TIMER_HANDLER 145 -#define BTCOEX_DBG_NULL_FRAME_SLEEP 146 -#define BTCOEX_DBG_NULL_FRAME_AWAKE 147 -#define BTCOEX_DBG_SET_AGGR_SIZE 152 -#define BTCOEX_DBG_TEAR_BA_TIMEOUT 153 -#define BTCOEX_DBG_MGMT_FRAME_SEQ_NO 154 -#define BTCOEX_DBG_SCO_STOMP_HIGH_PRI 155 -#define BTCOEX_DBG_COLOCATED_BT_DEV 156 -#define BTCOEX_DBG_FE_ANT_TYPE 157 -#define BTCOEX_DBG_BT_INQUIRY_CMD 158 -#define BTCOEX_DBG_SCO_CONFIG 159 -#define BTCOEX_DBG_SCO_PSPOLL_CONFIG 160 -#define BTCOEX_DBG_SCO_OPTMODE_CONFIG 161 -#define BTCOEX_DBG_A2DP_CONFIG 162 -#define BTCOEX_DBG_A2DP_PSPOLL_CONFIG 163 -#define BTCOEX_DBG_A2DP_OPTMODE_CONFIG 164 -#define BTCOEX_DBG_ACLCOEX_CONFIG 165 -#define BTCOEX_DBG_ACLCOEX_PSPOLL_CONFIG 166 -#define BTCOEX_DBG_ACLCOEX_OPTMODE_CONFIG 167 -#define BTCOEX_DBG_DEBUG_CMD 168 -#define BTCOEX_DBG_SET_BT_OPERATING_STATUS 169 -#define BTCOEX_DBG_GET_CONFIG 170 -#define BTCOEX_DBG_GET_STATS 171 -#define BTCOEX_DBG_BT_OPERATING_STATUS 172 -#define BTCOEX_DBG_PERFORM_RECONNECT 173 -#define BTCOEX_DBG_ACL_WLAN_MED 175 -#define BTCOEX_DBG_ACL_BT_MED 176 -#define BTCOEX_DBG_WLAN_CONNECT 177 -#define BTCOEX_DBG_A2DP_DUAL_START 178 -#define BTCOEX_DBG_PMAWAKE_NOTIFY 179 -#define BTCOEX_DBG_BEACON_SCAN_ENABLE 180 -#define BTCOEX_DBG_BEACON_SCAN_DISABLE 181 -#define BTCOEX_DBG_RX_NOTIFY 182 -#define BTCOEX_SCO_GET_PER_SECOND_FRM_TIMESTAMP 183 -#define BTCOEX_DBG_TXQ_DETAILS 184 -#define BTCOEX_DBG_SCO_STOMP_LOW_PRI 185 -#define BTCOEX_DBG_A2DP_FORCE_SCAN 186 -#define BTCOEX_DBG_DTIM_STOMP_COMP 187 -#define BTCOEX_ACL_PRESENCE_TIMER 188 -#define BTCOEX_DBGID_DEFINITION_END - -#ifdef __cplusplus -} -#endif - -#endif /* _DBGLOG_ID_H_ */ diff --git a/drivers/staging/ath6kl/include/common/discovery.h b/drivers/staging/ath6kl/include/common/discovery.h deleted file mode 100644 index da1b3324506..00000000000 --- a/drivers/staging/ath6kl/include/common/discovery.h +++ /dev/null @@ -1,75 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _DISCOVERY_H_ -#define _DISCOVERY_H_ - -/* - * DC_SCAN_PRIORITY is an 8-bit bitmap of the scan priority of a channel - */ -typedef enum { - DEFAULT_SCPRI = 0x01, - POPULAR_SCPRI = 0x02, - SSIDS_SCPRI = 0x04, - PROF_SCPRI = 0x08, -} DC_SCAN_PRIORITY; - -/* The following search type construct can be used to manipulate the behavior of the search module based on different bits set */ -typedef enum { - SCAN_RESET = 0, - SCAN_ALL = (DEFAULT_SCPRI | POPULAR_SCPRI | \ - SSIDS_SCPRI | PROF_SCPRI), - - SCAN_POPULAR = (POPULAR_SCPRI | SSIDS_SCPRI | PROF_SCPRI), - SCAN_SSIDS = (SSIDS_SCPRI | PROF_SCPRI), - SCAN_PROF_MASK = (PROF_SCPRI), - SCAN_MULTI_CHANNEL = 0x000100, - SCAN_DETERMINISTIC = 0x000200, - SCAN_PROFILE_MATCH_TERMINATED = 0x000400, - SCAN_HOME_CHANNEL_SKIP = 0x000800, - SCAN_CHANNEL_LIST_CONTINUE = 0x001000, - SCAN_CURRENT_SSID_SKIP = 0x002000, - SCAN_ACTIVE_PROBE_DISABLE = 0x004000, - SCAN_CHANNEL_HINT_ONLY = 0x008000, - SCAN_ACTIVE_CHANNELS_ONLY = 0x010000, - SCAN_UNUSED1 = 0x020000, /* unused */ - SCAN_PERIODIC = 0x040000, - SCAN_FIXED_DURATION = 0x080000, - SCAN_AP_ASSISTED = 0x100000, -} DC_SCAN_TYPE; - -typedef enum { - BSS_REPORTING_DEFAULT = 0x0, - EXCLUDE_NON_SCAN_RESULTS = 0x1, /* Exclude results outside of scan */ -} DC_BSS_REPORTING_POLICY; - -typedef enum { - DC_IGNORE_WPAx_GROUP_CIPHER = 0x01, - DC_PROFILE_MATCH_DONE = 0x02, - DC_IGNORE_AAC_BEACON = 0x04, - DC_CSA_FOLLOW_BSS = 0x08, -} DC_PROFILE_FILTER; - -#define DEFAULT_DC_PROFILE_FILTER (DC_CSA_FOLLOW_BSS) - -#endif /* _DISCOVERY_H_ */ diff --git a/drivers/staging/ath6kl/include/common/epping_test.h b/drivers/staging/ath6kl/include/common/epping_test.h deleted file mode 100644 index 9eb5fdfa746..00000000000 --- a/drivers/staging/ath6kl/include/common/epping_test.h +++ /dev/null @@ -1,111 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -// - -/* This file contains shared definitions for the host/target endpoint ping test */ - -#ifndef EPPING_TEST_H_ -#define EPPING_TEST_H_ - - /* alignment to 4-bytes */ -#define EPPING_ALIGNMENT_PAD (((sizeof(struct htc_frame_hdr) + 3) & (~0x3)) - sizeof(struct htc_frame_hdr)) - -#ifndef A_OFFSETOF -#define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field)) -#endif - -#define EPPING_RSVD_FILL 0xCC - -#define HCI_RSVD_EXPECTED_PKT_TYPE_RECV_OFFSET 7 - -typedef PREPACK struct { - u8 _HCIRsvd[8]; /* reserved for HCI packet header (GMBOX) testing */ - u8 StreamEcho_h; /* stream no. to echo this packet on (filled by host) */ - u8 StreamEchoSent_t; /* stream no. packet was echoed to (filled by target) - When echoed: StreamEchoSent_t == StreamEcho_h */ - u8 StreamRecv_t; /* stream no. that target received this packet on (filled by target) */ - u8 StreamNo_h; /* stream number to send on (filled by host) */ - u8 Magic_h[4]; /* magic number to filter for this packet on the host*/ - u8 _rsvd[6]; /* reserved fields that must be set to a "reserved" value - since this packet maps to a 14-byte ethernet frame we want - to make sure ethertype field is set to something unknown */ - - u8 _pad[2]; /* padding for alignment */ - u8 TimeStamp[8]; /* timestamp of packet (host or target) */ - u32 HostContext_h; /* 4 byte host context, target echos this back */ - u32 SeqNo; /* sequence number (set by host or target) */ - u16 Cmd_h; /* ping command (filled by host) */ - u16 CmdFlags_h; /* optional flags */ - u8 CmdBuffer_h[8]; /* buffer for command (host -> target) */ - u8 CmdBuffer_t[8]; /* buffer for command (target -> host) */ - u16 DataLength; /* length of data */ - u16 DataCRC; /* 16 bit CRC of data */ - u16 HeaderCRC; /* header CRC (fields : StreamNo_h to end, minus HeaderCRC) */ -} POSTPACK EPPING_HEADER; - -#define EPPING_PING_MAGIC_0 0xAA -#define EPPING_PING_MAGIC_1 0x55 -#define EPPING_PING_MAGIC_2 0xCE -#define EPPING_PING_MAGIC_3 0xEC - - - -#define IS_EPPING_PACKET(pPkt) (((pPkt)->Magic_h[0] == EPPING_PING_MAGIC_0) && \ - ((pPkt)->Magic_h[1] == EPPING_PING_MAGIC_1) && \ - ((pPkt)->Magic_h[2] == EPPING_PING_MAGIC_2) && \ - ((pPkt)->Magic_h[3] == EPPING_PING_MAGIC_3)) - -#define SET_EPPING_PACKET_MAGIC(pPkt) { (pPkt)->Magic_h[0] = EPPING_PING_MAGIC_0; \ - (pPkt)->Magic_h[1] = EPPING_PING_MAGIC_1; \ - (pPkt)->Magic_h[2] = EPPING_PING_MAGIC_2; \ - (pPkt)->Magic_h[3] = EPPING_PING_MAGIC_3;} - -#define CMD_FLAGS_DATA_CRC (1 << 0) /* DataCRC field is valid */ -#define CMD_FLAGS_DELAY_ECHO (1 << 1) /* delay the echo of the packet */ -#define CMD_FLAGS_NO_DROP (1 << 2) /* do not drop at HTC layer no matter what the stream is */ - -#define IS_EPING_PACKET_NO_DROP(pPkt) ((pPkt)->CmdFlags_h & CMD_FLAGS_NO_DROP) - -#define EPPING_CMD_ECHO_PACKET 1 /* echo packet test */ -#define EPPING_CMD_RESET_RECV_CNT 2 /* reset recv count */ -#define EPPING_CMD_CAPTURE_RECV_CNT 3 /* fetch recv count, 4-byte count returned in CmdBuffer_t */ -#define EPPING_CMD_NO_ECHO 4 /* non-echo packet test (tx-only) */ -#define EPPING_CMD_CONT_RX_START 5 /* continuous RX packets, parameters are in CmdBuffer_h */ -#define EPPING_CMD_CONT_RX_STOP 6 /* stop continuous RX packet transmission */ - - /* test command parameters may be no more than 8 bytes */ -typedef PREPACK struct { - u16 BurstCnt; /* number of packets to burst together (for HTC 2.1 testing) */ - u16 PacketLength; /* length of packet to generate including header */ - u16 Flags; /* flags */ - -#define EPPING_CONT_RX_DATA_CRC (1 << 0) /* Add CRC to all data */ -#define EPPING_CONT_RX_RANDOM_DATA (1 << 1) /* randomize the data pattern */ -#define EPPING_CONT_RX_RANDOM_LEN (1 << 2) /* randomize the packet lengths */ -} POSTPACK EPPING_CONT_RX_PARAMS; - -#define EPPING_HDR_CRC_OFFSET A_OFFSETOF(EPPING_HEADER,StreamNo_h) -#define EPPING_HDR_BYTES_CRC (sizeof(EPPING_HEADER) - EPPING_HDR_CRC_OFFSET - (sizeof(u16))) - -#define HCI_TRANSPORT_STREAM_NUM 16 /* this number is higher than the define WMM AC classes so we - can use this to distinguish packets */ - -#endif /*EPPING_TEST_H_*/ diff --git a/drivers/staging/ath6kl/include/common/gmboxif.h b/drivers/staging/ath6kl/include/common/gmboxif.h deleted file mode 100644 index ea11c14def4..00000000000 --- a/drivers/staging/ath6kl/include/common/gmboxif.h +++ /dev/null @@ -1,70 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef __GMBOXIF_H__ -#define __GMBOXIF_H__ - -/* GMBOX interface definitions */ - -#define AR6K_GMBOX_CREDIT_COUNTER 1 /* we use credit counter 1 to track credits */ -#define AR6K_GMBOX_CREDIT_SIZE_COUNTER 2 /* credit counter 2 is used to pass the size of each credit */ - - - /* HCI UART transport definitions when used over GMBOX interface */ -#define HCI_UART_COMMAND_PKT 0x01 -#define HCI_UART_ACL_PKT 0x02 -#define HCI_UART_SCO_PKT 0x03 -#define HCI_UART_EVENT_PKT 0x04 - - /* definitions for BT HCI packets */ -typedef PREPACK struct { - u16 Flags_ConnHandle; - u16 Length; -} POSTPACK BT_HCI_ACL_HEADER; - -typedef PREPACK struct { - u16 Flags_ConnHandle; - u8 Length; -} POSTPACK BT_HCI_SCO_HEADER; - -typedef PREPACK struct { - u16 OpCode; - u8 ParamLength; -} POSTPACK BT_HCI_COMMAND_HEADER; - -typedef PREPACK struct { - u8 EventCode; - u8 ParamLength; -} POSTPACK BT_HCI_EVENT_HEADER; - -/* MBOX host interrupt signal assignments */ - -#define MBOX_SIG_HCI_BRIDGE_MAX 8 -#define MBOX_SIG_HCI_BRIDGE_BT_ON 0 -#define MBOX_SIG_HCI_BRIDGE_BT_OFF 1 -#define MBOX_SIG_HCI_BRIDGE_BAUD_SET 2 -#define MBOX_SIG_HCI_BRIDGE_PWR_SAV_ON 3 -#define MBOX_SIG_HCI_BRIDGE_PWR_SAV_OFF 4 - - -#endif /* __GMBOXIF_H__ */ - diff --git a/drivers/staging/ath6kl/include/common/gpio_reg.h b/drivers/staging/ath6kl/include/common/gpio_reg.h deleted file mode 100644 index f9d425d48dc..00000000000 --- a/drivers/staging/ath6kl/include/common/gpio_reg.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _GPIO_REG_REG_H_ -#define _GPIO_REG_REG_H_ - -#define GPIO_PIN10_ADDRESS 0x00000050 -#define GPIO_PIN11_ADDRESS 0x00000054 -#define GPIO_PIN12_ADDRESS 0x00000058 -#define GPIO_PIN13_ADDRESS 0x0000005c - -#endif /* _GPIO_REG_H_ */ diff --git a/drivers/staging/ath6kl/include/common/htc.h b/drivers/staging/ath6kl/include/common/htc.h deleted file mode 100644 index 85cbfa89d67..00000000000 --- a/drivers/staging/ath6kl/include/common/htc.h +++ /dev/null @@ -1,227 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef __HTC_H__ -#define __HTC_H__ - -#define A_OFFSETOF(type,field) (unsigned long)(&(((type *)NULL)->field)) - -#define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \ - (((u16)(((u8 *)(p))[(highbyte)])) << 8 | (u16)(((u8 *)(p))[(lowbyte)])) - -/* alignment independent macros (little-endian) to fetch UINT16s or UINT8s from a - * structure using only the type and field name. - * Use these macros if there is the potential for unaligned buffer accesses. */ -#define A_GET_UINT16_FIELD(p,type,field) \ - ASSEMBLE_UNALIGNED_UINT16(p,\ - A_OFFSETOF(type,field) + 1, \ - A_OFFSETOF(type,field)) - -#define A_SET_UINT16_FIELD(p,type,field,value) \ -{ \ - ((u8 *)(p))[A_OFFSETOF(type,field)] = (u8)(value); \ - ((u8 *)(p))[A_OFFSETOF(type,field) + 1] = (u8)((value) >> 8); \ -} - -#define A_GET_UINT8_FIELD(p,type,field) \ - ((u8 *)(p))[A_OFFSETOF(type,field)] - -#define A_SET_UINT8_FIELD(p,type,field,value) \ - ((u8 *)(p))[A_OFFSETOF(type,field)] = (value) - -/****** DANGER DANGER *************** - * - * The frame header length and message formats defined herein were - * selected to accommodate optimal alignment for target processing. This reduces code - * size and improves performance. - * - * Any changes to the header length may alter the alignment and cause exceptions - * on the target. When adding to the message structures insure that fields are - * properly aligned. - * - */ - -/* HTC frame header */ -PREPACK struct htc_frame_hdr { - /* do not remove or re-arrange these fields, these are minimally required - * to take advantage of 4-byte lookaheads in some hardware implementations */ - u8 EndpointID; - u8 Flags; - u16 PayloadLen; /* length of data (including trailer) that follows the header */ - - /***** end of 4-byte lookahead ****/ - - u8 ControlBytes[2]; - - /* message payload starts after the header */ - -} POSTPACK; - -/* frame header flags */ - - /* send direction */ -#define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0) -#define HTC_FLAGS_SEND_BUNDLE (1 << 1) /* start or part of bundle */ - /* receive direction */ -#define HTC_FLAGS_RECV_UNUSED_0 (1 << 0) /* bit 0 unused */ -#define HTC_FLAGS_RECV_TRAILER (1 << 1) /* bit 1 trailer data present */ -#define HTC_FLAGS_RECV_UNUSED_2 (1 << 0) /* bit 2 unused */ -#define HTC_FLAGS_RECV_UNUSED_3 (1 << 0) /* bit 3 unused */ -#define HTC_FLAGS_RECV_BUNDLE_CNT_MASK (0xF0) /* bits 7..4 */ -#define HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT 4 - -#define HTC_HDR_LENGTH (sizeof(struct htc_frame_hdr)) -#define HTC_MAX_TRAILER_LENGTH 255 -#define HTC_MAX_PAYLOAD_LENGTH (4096 - sizeof(struct htc_frame_hdr)) - -/* HTC control message IDs */ - -#define HTC_MSG_READY_ID 1 -#define HTC_MSG_CONNECT_SERVICE_ID 2 -#define HTC_MSG_CONNECT_SERVICE_RESPONSE_ID 3 -#define HTC_MSG_SETUP_COMPLETE_ID 4 -#define HTC_MSG_SETUP_COMPLETE_EX_ID 5 - -#define HTC_MAX_CONTROL_MESSAGE_LENGTH 256 - -/* base message ID header */ -typedef PREPACK struct { - u16 MessageID; -} POSTPACK HTC_UNKNOWN_MSG; - -/* HTC ready message - * direction : target-to-host */ -typedef PREPACK struct { - u16 MessageID; /* ID */ - u16 CreditCount; /* number of credits the target can offer */ - u16 CreditSize; /* size of each credit */ - u8 MaxEndpoints; /* maximum number of endpoints the target has resources for */ - u8 _Pad1; -} POSTPACK HTC_READY_MSG; - - /* extended HTC ready message */ -typedef PREPACK struct { - HTC_READY_MSG Version2_0_Info; /* legacy version 2.0 information at the front... */ - /* extended information */ - u8 HTCVersion; - u8 MaxMsgsPerHTCBundle; -} POSTPACK HTC_READY_EX_MSG; - -#define HTC_VERSION_2P0 0x00 -#define HTC_VERSION_2P1 0x01 /* HTC 2.1 */ - -#define HTC_SERVICE_META_DATA_MAX_LENGTH 128 - -/* connect service - * direction : host-to-target */ -typedef PREPACK struct { - u16 MessageID; - u16 ServiceID; /* service ID of the service to connect to */ - u16 ConnectionFlags; /* connection flags */ - -#define HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE (1 << 2) /* reduce credit dribbling when - the host needs credits */ -#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK (0x3) -#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH 0x0 -#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF 0x1 -#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS 0x2 -#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_UNITY 0x3 - - u8 ServiceMetaLength; /* length of meta data that follows */ - u8 _Pad1; - - /* service-specific meta data starts after the header */ - -} POSTPACK HTC_CONNECT_SERVICE_MSG; - -/* connect response - * direction : target-to-host */ -typedef PREPACK struct { - u16 MessageID; - u16 ServiceID; /* service ID that the connection request was made */ - u8 Status; /* service connection status */ - u8 EndpointID; /* assigned endpoint ID */ - u16 MaxMsgSize; /* maximum expected message size on this endpoint */ - u8 ServiceMetaLength; /* length of meta data that follows */ - u8 _Pad1; - - /* service-specific meta data starts after the header */ - -} POSTPACK HTC_CONNECT_SERVICE_RESPONSE_MSG; - -typedef PREPACK struct { - u16 MessageID; - /* currently, no other fields */ -} POSTPACK HTC_SETUP_COMPLETE_MSG; - - /* extended setup completion message */ -typedef PREPACK struct { - u16 MessageID; - u32 SetupFlags; - u8 MaxMsgsPerBundledRecv; - u8 Rsvd[3]; -} POSTPACK HTC_SETUP_COMPLETE_EX_MSG; - -#define HTC_SETUP_COMPLETE_FLAGS_ENABLE_BUNDLE_RECV (1 << 0) - -/* connect response status codes */ -#define HTC_SERVICE_SUCCESS 0 /* success */ -#define HTC_SERVICE_NOT_FOUND 1 /* service could not be found */ -#define HTC_SERVICE_FAILED 2 /* specific service failed the connect */ -#define HTC_SERVICE_NO_RESOURCES 3 /* no resources (i.e. no more endpoints) */ -#define HTC_SERVICE_NO_MORE_EP 4 /* specific service is not allowing any more - endpoints */ - -/* report record IDs */ - -#define HTC_RECORD_NULL 0 -#define HTC_RECORD_CREDITS 1 -#define HTC_RECORD_LOOKAHEAD 2 -#define HTC_RECORD_LOOKAHEAD_BUNDLE 3 - -typedef PREPACK struct { - u8 RecordID; /* Record ID */ - u8 Length; /* Length of record */ -} POSTPACK HTC_RECORD_HDR; - -typedef PREPACK struct { - u8 EndpointID; /* Endpoint that owns these credits */ - u8 Credits; /* credits to report since last report */ -} POSTPACK HTC_CREDIT_REPORT; - -typedef PREPACK struct { - u8 PreValid; /* pre valid guard */ - u8 LookAhead[4]; /* 4 byte lookahead */ - u8 PostValid; /* post valid guard */ - - /* NOTE: the LookAhead array is guarded by a PreValid and Post Valid guard bytes. - * The PreValid bytes must equal the inverse of the PostValid byte */ - -} POSTPACK HTC_LOOKAHEAD_REPORT; - -typedef PREPACK struct { - u8 LookAhead[4]; /* 4 byte lookahead */ -} POSTPACK HTC_BUNDLED_LOOKAHEAD_REPORT; - -#endif /* __HTC_H__ */ - diff --git a/drivers/staging/ath6kl/include/common/htc_services.h b/drivers/staging/ath6kl/include/common/htc_services.h deleted file mode 100644 index fb22268a8d8..00000000000 --- a/drivers/staging/ath6kl/include/common/htc_services.h +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef __HTC_SERVICES_H__ -#define __HTC_SERVICES_H__ - -/* Current service IDs */ - -typedef enum { - RSVD_SERVICE_GROUP = 0, - WMI_SERVICE_GROUP = 1, - - HTC_TEST_GROUP = 254, - HTC_SERVICE_GROUP_LAST = 255 -}HTC_SERVICE_GROUP_IDS; - -#define MAKE_SERVICE_ID(group,index) \ - (int)(((int)group << 8) | (int)(index)) - -/* NOTE: service ID of 0x0000 is reserved and should never be used */ -#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP,1) -#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,0) -#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,1) -#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,2) -#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,3) -#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,4) -#define WMI_MAX_SERVICES 5 - -/* raw stream service (i.e. flash, tcmd, calibration apps) */ -#define HTC_RAW_STREAMS_SVC MAKE_SERVICE_ID(HTC_TEST_GROUP,0) - -#endif /*HTC_SERVICES_H_*/ diff --git a/drivers/staging/ath6kl/include/common/pkt_log.h b/drivers/staging/ath6kl/include/common/pkt_log.h deleted file mode 100644 index a3719adf54c..00000000000 --- a/drivers/staging/ath6kl/include/common/pkt_log.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2005-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef __PKT_LOG_H__ -#define __PKT_LOG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Pkt log info */ -typedef PREPACK struct pkt_log_t { - struct info_t { - u16 st; - u16 end; - u16 cur; - }info[4096]; - u16 last_idx; -}POSTPACK PACKET_LOG; - - -#ifdef __cplusplus -} -#endif -#endif /* __PKT_LOG_H__ */ diff --git a/drivers/staging/ath6kl/include/common/roaming.h b/drivers/staging/ath6kl/include/common/roaming.h deleted file mode 100644 index 8019850a057..00000000000 --- a/drivers/staging/ath6kl/include/common/roaming.h +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef _ROAMING_H_ -#define _ROAMING_H_ - -/* - * The signal quality could be in terms of either snr or rssi. We should - * have an enum for both of them. For the time being, we are going to move - * it to wmi.h that is shared by both host and the target, since we are - * repartitioning the code to the host - */ -#define SIGNAL_QUALITY_NOISE_FLOOR -96 -#define SIGNAL_QUALITY_METRICS_NUM_MAX 2 -typedef enum { - SIGNAL_QUALITY_METRICS_SNR = 0, - SIGNAL_QUALITY_METRICS_RSSI, - SIGNAL_QUALITY_METRICS_ALL, -} SIGNAL_QUALITY_METRICS_TYPE; - -#endif /* _ROAMING_H_ */ diff --git a/drivers/staging/ath6kl/include/common/targaddrs.h b/drivers/staging/ath6kl/include/common/targaddrs.h deleted file mode 100644 index c866cefbd8f..00000000000 --- a/drivers/staging/ath6kl/include/common/targaddrs.h +++ /dev/null @@ -1,395 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef __TARGADDRS_H__ -#define __TARGADDRS_H__ - -#if defined(AR6002) -#include "AR6002/addrs.h" -#endif - -/* - * AR6K option bits, to enable/disable various features. - * By default, all option bits are 0. - * These bits can be set in LOCAL_SCRATCH register 0. - */ -#define AR6K_OPTION_BMI_DISABLE 0x01 /* Disable BMI comm with Host */ -#define AR6K_OPTION_SERIAL_ENABLE 0x02 /* Enable serial port msgs */ -#define AR6K_OPTION_WDT_DISABLE 0x04 /* WatchDog Timer override */ -#define AR6K_OPTION_SLEEP_DISABLE 0x08 /* Disable system sleep */ -#define AR6K_OPTION_STOP_BOOT 0x10 /* Stop boot processes (for ATE) */ -#define AR6K_OPTION_ENABLE_NOANI 0x20 /* Operate without ANI */ -#define AR6K_OPTION_DSET_DISABLE 0x40 /* Ignore DataSets */ -#define AR6K_OPTION_IGNORE_FLASH 0x80 /* Ignore flash during bootup */ - -/* - * xxx_HOST_INTEREST_ADDRESS is the address in Target RAM of the - * host_interest structure. It must match the address of the _host_interest - * symbol (see linker script). - * - * Host Interest is shared between Host and Target in order to coordinate - * between the two, and is intended to remain constant (with additions only - * at the end) across software releases. - * - * All addresses are available here so that it's possible to - * write a single binary that works with all Target Types. - * May be used in assembler code as well as C. - */ -#define AR6002_HOST_INTEREST_ADDRESS 0x00500400 -#define AR6003_HOST_INTEREST_ADDRESS 0x00540600 - - -#define HOST_INTEREST_MAX_SIZE 0x100 - -#if !defined(__ASSEMBLER__) -struct register_dump_s; -struct dbglog_hdr_s; - -/* - * These are items that the Host may need to access - * via BMI or via the Diagnostic Window. The position - * of items in this structure must remain constant - * across firmware revisions! - * - * Types for each item must be fixed size across - * target and host platforms. - * - * More items may be added at the end. - */ -PREPACK struct host_interest_s { - /* - * Pointer to application-defined area, if any. - * Set by Target application during startup. - */ - u32 hi_app_host_interest; /* 0x00 */ - - /* Pointer to register dump area, valid after Target crash. */ - u32 hi_failure_state; /* 0x04 */ - - /* Pointer to debug logging header */ - u32 hi_dbglog_hdr; /* 0x08 */ - - u32 hi_unused1; /* 0x0c */ - - /* - * General-purpose flag bits, similar to AR6000_OPTION_* flags. - * Can be used by application rather than by OS. - */ - u32 hi_option_flag; /* 0x10 */ - - /* - * Boolean that determines whether or not to - * display messages on the serial port. - */ - u32 hi_serial_enable; /* 0x14 */ - - /* Start address of DataSet index, if any */ - u32 hi_dset_list_head; /* 0x18 */ - - /* Override Target application start address */ - u32 hi_app_start; /* 0x1c */ - - /* Clock and voltage tuning */ - u32 hi_skip_clock_init; /* 0x20 */ - u32 hi_core_clock_setting; /* 0x24 */ - u32 hi_cpu_clock_setting; /* 0x28 */ - u32 hi_system_sleep_setting; /* 0x2c */ - u32 hi_xtal_control_setting; /* 0x30 */ - u32 hi_pll_ctrl_setting_24ghz; /* 0x34 */ - u32 hi_pll_ctrl_setting_5ghz; /* 0x38 */ - u32 hi_ref_voltage_trim_setting; /* 0x3c */ - u32 hi_clock_info; /* 0x40 */ - - /* - * Flash configuration overrides, used only - * when firmware is not executing from flash. - * (When using flash, modify the global variables - * with equivalent names.) - */ - u32 hi_bank0_addr_value; /* 0x44 */ - u32 hi_bank0_read_value; /* 0x48 */ - u32 hi_bank0_write_value; /* 0x4c */ - u32 hi_bank0_config_value; /* 0x50 */ - - /* Pointer to Board Data */ - u32 hi_board_data; /* 0x54 */ - u32 hi_board_data_initialized; /* 0x58 */ - - u32 hi_dset_RAM_index_table; /* 0x5c */ - - u32 hi_desired_baud_rate; /* 0x60 */ - u32 hi_dbglog_config; /* 0x64 */ - u32 hi_end_RAM_reserve_sz; /* 0x68 */ - u32 hi_mbox_io_block_sz; /* 0x6c */ - - u32 hi_num_bpatch_streams; /* 0x70 -- unused */ - u32 hi_mbox_isr_yield_limit; /* 0x74 */ - - u32 hi_refclk_hz; /* 0x78 */ - u32 hi_ext_clk_detected; /* 0x7c */ - u32 hi_dbg_uart_txpin; /* 0x80 */ - u32 hi_dbg_uart_rxpin; /* 0x84 */ - u32 hi_hci_uart_baud; /* 0x88 */ - u32 hi_hci_uart_pin_assignments; /* 0x8C */ - /* NOTE: byte [0] = tx pin, [1] = rx pin, [2] = rts pin, [3] = cts pin */ - u32 hi_hci_uart_baud_scale_val; /* 0x90 */ - u32 hi_hci_uart_baud_step_val; /* 0x94 */ - - u32 hi_allocram_start; /* 0x98 */ - u32 hi_allocram_sz; /* 0x9c */ - u32 hi_hci_bridge_flags; /* 0xa0 */ - u32 hi_hci_uart_support_pins; /* 0xa4 */ - /* NOTE: byte [0] = RESET pin (bit 7 is polarity), bytes[1]..bytes[3] are for future use */ - u32 hi_hci_uart_pwr_mgmt_params; /* 0xa8 */ - /* - * 0xa8 - [1]: 0 = UART FC active low, 1 = UART FC active high - * [31:16]: wakeup timeout in ms - */ - - /* Pointer to extended board data */ - u32 hi_board_ext_data; /* 0xac */ - u32 hi_board_ext_data_config; /* 0xb0 */ - - /* - * Bit [0] : valid - * Bit[31:16: size - */ - /* - * hi_reset_flag is used to do some stuff when target reset. - * such as restore app_start after warm reset or - * preserve host Interest area, or preserve ROM data, literals etc. - */ - u32 hi_reset_flag; /* 0xb4 */ - /* indicate hi_reset_flag is valid */ - u32 hi_reset_flag_valid; /* 0xb8 */ - u32 hi_hci_uart_pwr_mgmt_params_ext; /* 0xbc */ - /* - * 0xbc - [31:0]: idle timeout in ms - */ - /* ACS flags */ - u32 hi_acs_flags; /* 0xc0 */ - u32 hi_console_flags; /* 0xc4 */ - u32 hi_nvram_state; /* 0xc8 */ - u32 hi_option_flag2; /* 0xcc */ - - /* If non-zero, override values sent to Host in WMI_READY event. */ - u32 hi_sw_version_override; /* 0xd0 */ - u32 hi_abi_version_override; /* 0xd4 */ - - /* - * Percentage of high priority RX traffic to total expected RX traffic - - * applicable only to ar6004 - */ - u32 hi_hp_rx_traffic_ratio; /* 0xd8 */ - - /* test applications flags */ - u32 hi_test_apps_related ; /* 0xdc */ - /* location of test script */ - u32 hi_ota_testscript; /* 0xe0 */ - /* location of CAL data */ - u32 hi_cal_data; /* 0xe4 */ - /* Number of packet log buffers */ - u32 hi_pktlog_num_buffers; /* 0xe8 */ - -} POSTPACK; - -/* Bits defined in hi_option_flag */ -#define HI_OPTION_TIMER_WAR 0x01 /* Enable timer workaround */ -#define HI_OPTION_BMI_CRED_LIMIT 0x02 /* Limit BMI command credits */ -#define HI_OPTION_RELAY_DOT11_HDR 0x04 /* Relay Dot11 hdr to/from host */ -/* MAC addr method 0-locally administred 1-globally unique addrs */ -#define HI_OPTION_MAC_ADDR_METHOD 0x08 -#define HI_OPTION_FW_BRIDGE 0x10 /* Firmware Bridging */ -#define HI_OPTION_ENABLE_PROFILE 0x20 /* Enable CPU profiling */ -#define HI_OPTION_DISABLE_DBGLOG 0x40 /* Disable debug logging */ -#define HI_OPTION_SKIP_ERA_TRACKING 0x80 /* Skip Era Tracking */ -#define HI_OPTION_PAPRD_DISABLE 0x100 /* Disable PAPRD (debug) */ -#define HI_OPTION_NUM_DEV_LSB 0x200 -#define HI_OPTION_NUM_DEV_MSB 0x800 -#define HI_OPTION_DEV_MODE_LSB 0x1000 -#define HI_OPTION_DEV_MODE_MSB 0x8000000 -/* Disable LowFreq Timer Stabilization */ -#define HI_OPTION_NO_LFT_STBL 0x10000000 -#define HI_OPTION_SKIP_REG_SCAN 0x20000000 /* Skip regulatory scan */ -/* Do regulatory scan during init beforesending WMI ready event to host */ -#define HI_OPTION_INIT_REG_SCAN 0x40000000 -#define HI_OPTION_SKIP_MEMMAP 0x80000000 /* REV6: Do not adjust memory - map */ - -/* hi_option_flag2 options */ -#define HI_OPTION_OFFLOAD_AMSDU 0x01 -#define HI_OPTION_DFS_SUPPORT 0x02 /* Enable DFS support */ - -#define HI_OPTION_MAC_ADDR_METHOD_SHIFT 3 - -/* 2 bits of hi_option_flag are used to represent 3 modes */ -#define HI_OPTION_FW_MODE_IBSS 0x0 /* IBSS Mode */ -#define HI_OPTION_FW_MODE_BSS_STA 0x1 /* STA Mode */ -#define HI_OPTION_FW_MODE_AP 0x2 /* AP Mode */ - -/* 2 bits of hi_option flag are usedto represent 4 submodes */ -#define HI_OPTION_FW_SUBMODE_NONE 0x0 /* Normal mode */ -#define HI_OPTION_FW_SUBMODE_P2PDEV 0x1 /* p2p device mode */ -#define HI_OPTION_FW_SUBMODE_P2PCLIENT 0x2 /* p2p client mode */ -#define HI_OPTION_FW_SUBMODE_P2PGO 0x3 /* p2p go mode */ - -/* Num dev Mask */ -#define HI_OPTION_NUM_DEV_MASK 0x7 -#define HI_OPTION_NUM_DEV_SHIFT 0x9 - -/* firmware bridging */ -#define HI_OPTION_FW_BRIDGE_SHIFT 0x04 - -/* Fw Mode/SubMode Mask -|------------------------------------------------------------------------------| -| SUB | SUB | SUB | SUB | | | | -| MODE[3] | MODE[2] | MODE[1] | MODE[0] | MODE[3] | MODE[2] | MODE[1] | MODE[0| -| (2) | (2) | (2) | (2) | (2) | (2) | (2) | (2) -|------------------------------------------------------------------------------| -*/ -#define HI_OPTION_FW_MODE_BITS 0x2 -#define HI_OPTION_FW_MODE_MASK 0x3 -#define HI_OPTION_FW_MODE_SHIFT 0xC -#define HI_OPTION_ALL_FW_MODE_MASK 0xFF - -#define HI_OPTION_FW_SUBMODE_BITS 0x2 -#define HI_OPTION_FW_SUBMODE_MASK 0x3 -#define HI_OPTION_FW_SUBMODE_SHIFT 0x14 -#define HI_OPTION_ALL_FW_SUBMODE_MASK 0xFF00 -#define HI_OPTION_ALL_FW_SUBMODE_SHIFT 0x8 - -/* hi_reset_flag */ - -/* preserve App Start address */ -#define HI_RESET_FLAG_PRESERVE_APP_START 0x01 -/* preserve host interest */ -#define HI_RESET_FLAG_PRESERVE_HOST_INTEREST 0x02 -#define HI_RESET_FLAG_PRESERVE_ROMDATA 0x04 /* preserve ROM data */ -#define HI_RESET_FLAG_PRESERVE_NVRAM_STATE 0x08 -#define HI_RESET_FLAG_PRESERVE_BOOT_INFO 0x10 - -#define HI_RESET_FLAG_IS_VALID 0x12345678 /* indicate the reset flag is -valid */ - -#define ON_RESET_FLAGS_VALID() \ - (HOST_INTEREST->hi_reset_flag_valid == HI_RESET_FLAG_IS_VALID) - -#define RESET_FLAGS_VALIDATE() \ - (HOST_INTEREST->hi_reset_flag_valid = HI_RESET_FLAG_IS_VALID) - -#define RESET_FLAGS_INVALIDATE() \ - (HOST_INTEREST->hi_reset_flag_valid = 0) - -#define ON_RESET_PRESERVE_APP_START() \ - (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_APP_START) - -#define ON_RESET_PRESERVE_NVRAM_STATE() \ - (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_NVRAM_STATE) - -#define ON_RESET_PRESERVE_HOST_INTEREST() \ - (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_HOST_INTEREST) - -#define ON_RESET_PRESERVE_ROMDATA() \ - (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_ROMDATA) - -#define ON_RESET_PRESERVE_BOOT_INFO() \ - (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_BOOT_INFO) - -#define HI_ACS_FLAGS_ENABLED (1 << 0) /* ACS is enabled */ -#define HI_ACS_FLAGS_USE_WWAN (1 << 1) /* Use physical WWAN device */ -#define HI_ACS_FLAGS_TEST_VAP (1 << 2) /* Use test VAP */ - -/* CONSOLE FLAGS - * - * Bit Range Meaning - * --------- -------------------------------- - * 2..0 UART ID (0 = Default) - * 3 Baud Select (0 = 9600, 1 = 115200) - * 30..4 Reserved - * 31 Enable Console - * - */ - -#define HI_CONSOLE_FLAGS_ENABLE (1 << 31) -#define HI_CONSOLE_FLAGS_UART_MASK (0x7) -#define HI_CONSOLE_FLAGS_UART_SHIFT 0 -#define HI_CONSOLE_FLAGS_BAUD_SELECT (1 << 3) - -/* - * Intended for use by Host software, this macro returns the Target RAM - * address of any item in the host_interest structure. - * Example: target_addr = AR6002_HOST_INTEREST_ITEM_ADDRESS(hi_board_data); - */ -#define AR6002_HOST_INTEREST_ITEM_ADDRESS(item) \ - (u32)((unsigned long)&((((struct host_interest_s *)(AR6002_HOST_INTEREST_ADDRESS))->item))) - -#define AR6003_HOST_INTEREST_ITEM_ADDRESS(item) \ - (u32)((unsigned long)&((((struct host_interest_s *)(AR6003_HOST_INTEREST_ADDRESS))->item))) - -#define AR6004_HOST_INTEREST_ITEM_ADDRESS(item) \ - ((u32)&((((struct host_interest_s *)(AR6004_HOST_INTEREST_ADDRESS))->item))) - - -#define HOST_INTEREST_DBGLOG_IS_ENABLED() \ - (!(HOST_INTEREST->hi_option_flag & HI_OPTION_DISABLE_DBGLOG)) - -#define HOST_INTEREST_PKTLOG_IS_ENABLED() \ - ((HOST_INTEREST->hi_pktlog_num_buffers)) - - -#define HOST_INTEREST_PROFILE_IS_ENABLED() \ - (HOST_INTEREST->hi_option_flag & HI_OPTION_ENABLE_PROFILE) - -#define LF_TIMER_STABILIZATION_IS_ENABLED() \ - (!(HOST_INTEREST->hi_option_flag & HI_OPTION_NO_LFT_STBL)) - -#define IS_AMSDU_OFFLAOD_ENABLED() \ - ((HOST_INTEREST->hi_option_flag2 & HI_OPTION_OFFLOAD_AMSDU)) - -#define HOST_INTEREST_DFS_IS_ENABLED() \ - ((HOST_INTEREST->hi_option_flag2 & HI_OPTION_DFS_SUPPORT)) - -/* Convert a Target virtual address into a Target physical address */ -#define AR6002_VTOP(vaddr) ((vaddr) & 0x001fffff) -#define AR6003_VTOP(vaddr) ((vaddr) & 0x001fffff) -#define TARG_VTOP(TargetType, vaddr) \ - (((TargetType) == TARGET_TYPE_AR6002) ? AR6002_VTOP(vaddr) : AR6003_VTOP(vaddr)) - -#define AR6003_REV2_APP_START_OVERRIDE 0x944C00 -#define AR6003_REV2_APP_LOAD_ADDRESS 0x543180 -#define AR6003_REV2_BOARD_EXT_DATA_ADDRESS 0x57E500 -#define AR6003_REV2_DATASET_PATCH_ADDRESS 0x57e884 -#define AR6003_REV2_RAM_RESERVE_SIZE 6912 - -#define AR6003_REV3_APP_START_OVERRIDE 0x945d00 -#define AR6003_REV3_APP_LOAD_ADDRESS 0x545000 -#define AR6003_REV3_BOARD_EXT_DATA_ADDRESS 0x542330 -#define AR6003_REV3_DATASET_PATCH_ADDRESS 0x57FF74 -#define AR6003_REV3_RAM_RESERVE_SIZE 512 - -#define AR6003_BOARD_EXT_DATA_ADDRESS 0x57E600 - -/* # of u32 entries in targregs, used by DIAG_FETCH_TARG_REGS */ -#define AR6003_FETCH_TARG_REGS_COUNT 64 - -#endif /* !__ASSEMBLER__ */ - -#endif /* __TARGADDRS_H__ */ diff --git a/drivers/staging/ath6kl/include/common/testcmd.h b/drivers/staging/ath6kl/include/common/testcmd.h deleted file mode 100644 index 7d94aee508b..00000000000 --- a/drivers/staging/ath6kl/include/common/testcmd.h +++ /dev/null @@ -1,185 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef TESTCMD_H_ -#define TESTCMD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef AR6002_REV2 -#define TCMD_MAX_RATES 12 -#else -#define TCMD_MAX_RATES 28 -#endif - -typedef enum { - ZEROES_PATTERN = 0, - ONES_PATTERN, - REPEATING_10, - PN7_PATTERN, - PN9_PATTERN, - PN15_PATTERN -}TX_DATA_PATTERN; - -/* Continuous tx - mode : TCMD_CONT_TX_OFF - Disabling continuous tx - TCMD_CONT_TX_SINE - Enable continuous unmodulated tx - TCMD_CONT_TX_FRAME- Enable continuous modulated tx - freq : Channel freq in Mhz. (e.g 2412 for channel 1 in 11 g) -dataRate: 0 - 1 Mbps - 1 - 2 Mbps - 2 - 5.5 Mbps - 3 - 11 Mbps - 4 - 6 Mbps - 5 - 9 Mbps - 6 - 12 Mbps - 7 - 18 Mbps - 8 - 24 Mbps - 9 - 36 Mbps - 10 - 28 Mbps - 11 - 54 Mbps - txPwr: Tx power in dBm[5 -11] for unmod Tx, [5-14] for mod Tx -antenna: 1 - one antenna - 2 - two antenna -Note : Enable/disable continuous tx test cmd works only when target is awake. -*/ - -typedef enum { - TCMD_CONT_TX_OFF = 0, - TCMD_CONT_TX_SINE, - TCMD_CONT_TX_FRAME, - TCMD_CONT_TX_TX99, - TCMD_CONT_TX_TX100 -} TCMD_CONT_TX_MODE; - -typedef enum { - TCMD_WLAN_MODE_NOHT = 0, - TCMD_WLAN_MODE_HT20 = 1, - TCMD_WLAN_MODE_HT40PLUS = 2, - TCMD_WLAN_MODE_HT40MINUS = 3, -} TCMD_WLAN_MODE; - -typedef PREPACK struct { - u32 testCmdId; - u32 mode; - u32 freq; - u32 dataRate; - s32 txPwr; - u32 antenna; - u32 enANI; - u32 scramblerOff; - u32 aifsn; - u16 pktSz; - u16 txPattern; - u32 shortGuard; - u32 numPackets; - u32 wlanMode; -} POSTPACK TCMD_CONT_TX; - -#define TCMD_TXPATTERN_ZERONE 0x1 -#define TCMD_TXPATTERN_ZERONE_DIS_SCRAMBLE 0x2 - -/* Continuous Rx - act: TCMD_CONT_RX_PROMIS - promiscuous mode (accept all incoming frames) - TCMD_CONT_RX_FILTER - filter mode (accept only frames with dest - address equal specified - mac address (set via act =3) - TCMD_CONT_RX_REPORT off mode (disable cont rx mode and get the - report from the last cont - Rx test) - - TCMD_CONT_RX_SETMAC - set MacAddr mode (sets the MAC address for the - target. This Overrides - the default MAC address.) - -*/ -typedef enum { - TCMD_CONT_RX_PROMIS =0, - TCMD_CONT_RX_FILTER, - TCMD_CONT_RX_REPORT, - TCMD_CONT_RX_SETMAC, - TCMD_CONT_RX_SET_ANT_SWITCH_TABLE -} TCMD_CONT_RX_ACT; - -typedef PREPACK struct { - u32 testCmdId; - u32 act; - u32 enANI; - PREPACK union { - struct PREPACK TCMD_CONT_RX_PARA { - u32 freq; - u32 antenna; - u32 wlanMode; - } POSTPACK para; - struct PREPACK TCMD_CONT_RX_REPORT { - u32 totalPkt; - s32 rssiInDBm; - u32 crcErrPkt; - u32 secErrPkt; - u16 rateCnt[TCMD_MAX_RATES]; - u16 rateCntShortGuard[TCMD_MAX_RATES]; - } POSTPACK report; - struct PREPACK TCMD_CONT_RX_MAC { - u8 addr[ATH_MAC_LEN]; - } POSTPACK mac; - struct PREPACK TCMD_CONT_RX_ANT_SWITCH_TABLE { - u32 antswitch1; - u32 antswitch2; - }POSTPACK antswitchtable; - } POSTPACK u; -} POSTPACK TCMD_CONT_RX; - -/* Force sleep/wake test cmd - mode: TCMD_PM_WAKEUP - Wakeup the target - TCMD_PM_SLEEP - Force the target to sleep. - */ -typedef enum { - TCMD_PM_WAKEUP = 1, /* be consistent with target */ - TCMD_PM_SLEEP, - TCMD_PM_DEEPSLEEP -} TCMD_PM_MODE; - -typedef PREPACK struct { - u32 testCmdId; - u32 mode; -} POSTPACK TCMD_PM; - -typedef enum { - TCMD_CONT_TX_ID, - TCMD_CONT_RX_ID, - TCMD_PM_ID -} TCMD_ID; - -typedef PREPACK union { - TCMD_CONT_TX contTx; - TCMD_CONT_RX contRx; - TCMD_PM pm; -} POSTPACK TEST_CMD; - -#ifdef __cplusplus -} -#endif - -#endif /* TESTCMD_H_ */ diff --git a/drivers/staging/ath6kl/include/common/tlpm.h b/drivers/staging/ath6kl/include/common/tlpm.h deleted file mode 100644 index 659b1c07ba9..00000000000 --- a/drivers/staging/ath6kl/include/common/tlpm.h +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#ifndef __TLPM_H__ -#define __TLPM_H__ - -/* idle timeout in 16-bit value as in HOST_INTEREST hi_hci_uart_pwr_mgmt_params */ -#define TLPM_DEFAULT_IDLE_TIMEOUT_MS 1000 -/* hex in LSB and MSB for HCI command */ -#define TLPM_DEFAULT_IDLE_TIMEOUT_LSB 0xE8 -#define TLPM_DEFAULT_IDLE_TIMEOUT_MSB 0x3 - -/* wakeup timeout in 8-bit value as in HOST_INTEREST hi_hci_uart_pwr_mgmt_params */ -#define TLPM_DEFAULT_WAKEUP_TIMEOUT_MS 10 - -/* default UART FC polarity is low */ -#define TLPM_DEFAULT_UART_FC_POLARITY 0 - -#endif diff --git a/drivers/staging/ath6kl/include/common/wlan_defs.h b/drivers/staging/ath6kl/include/common/wlan_defs.h deleted file mode 100644 index 03e4d23788c..00000000000 --- a/drivers/staging/ath6kl/include/common/wlan_defs.h +++ /dev/null @@ -1,79 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef __WLAN_DEFS_H__ -#define __WLAN_DEFS_H__ - -/* - * This file contains WLAN definitions that may be used across both - * Host and Target software. - */ - -typedef enum { - MODE_11A = 0, /* 11a Mode */ - MODE_11G = 1, /* 11b/g Mode */ - MODE_11B = 2, /* 11b Mode */ - MODE_11GONLY = 3, /* 11g only Mode */ -#ifdef SUPPORT_11N - MODE_11NA_HT20 = 4, /* 11a HT20 mode */ - MODE_11NG_HT20 = 5, /* 11g HT20 mode */ - MODE_11NA_HT40 = 6, /* 11a HT40 mode */ - MODE_11NG_HT40 = 7, /* 11g HT40 mode */ - MODE_UNKNOWN = 8, - MODE_MAX = 8 -#else - MODE_UNKNOWN = 4, - MODE_MAX = 4 -#endif -} WLAN_PHY_MODE; - -typedef enum { - WLAN_11A_CAPABILITY = 1, - WLAN_11G_CAPABILITY = 2, - WLAN_11AG_CAPABILITY = 3, -}WLAN_CAPABILITY; - -#ifdef SUPPORT_11N -typedef unsigned long A_RATEMASK; -#else -typedef unsigned short A_RATEMASK; -#endif - -#ifdef SUPPORT_11N -#define IS_MODE_11A(mode) (((mode) == MODE_11A) || \ - ((mode) == MODE_11NA_HT20) || \ - ((mode) == MODE_11NA_HT40)) -#define IS_MODE_11B(mode) ((mode) == MODE_11B) -#define IS_MODE_11G(mode) (((mode) == MODE_11G) || \ - ((mode) == MODE_11GONLY) || \ - ((mode) == MODE_11NG_HT20) || \ - ((mode) == MODE_11NG_HT40)) -#define IS_MODE_11GONLY(mode) ((mode) == MODE_11GONLY) -#else -#define IS_MODE_11A(mode) ((mode) == MODE_11A) -#define IS_MODE_11B(mode) ((mode) == MODE_11B) -#define IS_MODE_11G(mode) (((mode) == MODE_11G) || \ - ((mode) == MODE_11GONLY)) -#define IS_MODE_11GONLY(mode) ((mode) == MODE_11GONLY) -#endif /* SUPPORT_11N */ - -#endif /* __WLANDEFS_H__ */ diff --git a/drivers/staging/ath6kl/include/common/wmi.h b/drivers/staging/ath6kl/include/common/wmi.h deleted file mode 100644 index d9687443d32..00000000000 --- a/drivers/staging/ath6kl/include/common/wmi.h +++ /dev/null @@ -1,3220 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -/* - * This file contains the definitions of the WMI protocol specified in the - * Wireless Module Interface (WMI). It includes definitions of all the - * commands and events. Commands are messages from the host to the WM. - * Events and Replies are messages from the WM to the host. - * - * Ownership of correctness in regards to commands - * belongs to the host driver and the WMI is not required to validate - * parameters for value, proper range, or any other checking. - * - */ - -#ifndef _WMI_H_ -#define _WMI_H_ - -#include "wmix.h" -#include "wlan_defs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define HTC_PROTOCOL_VERSION 0x0002 -#define HTC_PROTOCOL_REVISION 0x0000 - -#define WMI_PROTOCOL_VERSION 0x0002 -#define WMI_PROTOCOL_REVISION 0x0000 - -#define ATH_MAC_LEN 6 /* length of mac in bytes */ -#define WMI_CMD_MAX_LEN 100 -#define WMI_CONTROL_MSG_MAX_LEN 256 -#define WMI_OPT_CONTROL_MSG_MAX_LEN 1536 -#define IS_ETHERTYPE(_typeOrLen) ((_typeOrLen) >= 0x0600) -#define RFC1042OUI {0x00, 0x00, 0x00} - -#define IP_ETHERTYPE 0x0800 - -#define WMI_IMPLICIT_PSTREAM 0xFF -#define WMI_MAX_THINSTREAM 15 - -#ifdef AR6002_REV2 -#define IBSS_MAX_NUM_STA 4 -#else -#define IBSS_MAX_NUM_STA 8 -#endif - -PREPACK struct host_app_area_s { - u32 wmi_protocol_ver; -} POSTPACK; - -/* - * Data Path - */ -typedef PREPACK struct { - u8 dstMac[ATH_MAC_LEN]; - u8 srcMac[ATH_MAC_LEN]; - u16 typeOrLen; -} POSTPACK ATH_MAC_HDR; - -typedef PREPACK struct { - u8 dsap; - u8 ssap; - u8 cntl; - u8 orgCode[3]; - u16 etherType; -} POSTPACK ATH_LLC_SNAP_HDR; - -typedef enum { - DATA_MSGTYPE = 0x0, - CNTL_MSGTYPE, - SYNC_MSGTYPE, - OPT_MSGTYPE, -} WMI_MSG_TYPE; - - -/* - * Macros for operating on WMI_DATA_HDR (info) field - */ - -#define WMI_DATA_HDR_MSG_TYPE_MASK 0x03 -#define WMI_DATA_HDR_MSG_TYPE_SHIFT 0 -#define WMI_DATA_HDR_UP_MASK 0x07 -#define WMI_DATA_HDR_UP_SHIFT 2 -/* In AP mode, the same bit (b5) is used to indicate Power save state in - * the Rx dir and More data bit state in the tx direction. - */ -#define WMI_DATA_HDR_PS_MASK 0x1 -#define WMI_DATA_HDR_PS_SHIFT 5 - -#define WMI_DATA_HDR_MORE_MASK 0x1 -#define WMI_DATA_HDR_MORE_SHIFT 5 - -typedef enum { - WMI_DATA_HDR_DATA_TYPE_802_3 = 0, - WMI_DATA_HDR_DATA_TYPE_802_11, - WMI_DATA_HDR_DATA_TYPE_ACL, /* used to be used for the PAL */ -} WMI_DATA_HDR_DATA_TYPE; - -#define WMI_DATA_HDR_DATA_TYPE_MASK 0x3 -#define WMI_DATA_HDR_DATA_TYPE_SHIFT 6 - -#define WMI_DATA_HDR_SET_MORE_BIT(h) ((h)->info |= (WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT)) - -#define WMI_DATA_HDR_IS_MSG_TYPE(h, t) (((h)->info & (WMI_DATA_HDR_MSG_TYPE_MASK)) == (t)) -#define WMI_DATA_HDR_SET_MSG_TYPE(h, t) (h)->info = (((h)->info & ~(WMI_DATA_HDR_MSG_TYPE_MASK << WMI_DATA_HDR_MSG_TYPE_SHIFT)) | (t << WMI_DATA_HDR_MSG_TYPE_SHIFT)) -#define WMI_DATA_HDR_GET_UP(h) (((h)->info >> WMI_DATA_HDR_UP_SHIFT) & WMI_DATA_HDR_UP_MASK) -#define WMI_DATA_HDR_SET_UP(h, p) (h)->info = (((h)->info & ~(WMI_DATA_HDR_UP_MASK << WMI_DATA_HDR_UP_SHIFT)) | (p << WMI_DATA_HDR_UP_SHIFT)) - -#define WMI_DATA_HDR_GET_DATA_TYPE(h) (((h)->info >> WMI_DATA_HDR_DATA_TYPE_SHIFT) & WMI_DATA_HDR_DATA_TYPE_MASK) -#define WMI_DATA_HDR_SET_DATA_TYPE(h, p) (h)->info = (((h)->info & ~(WMI_DATA_HDR_DATA_TYPE_MASK << WMI_DATA_HDR_DATA_TYPE_SHIFT)) | ((p) << WMI_DATA_HDR_DATA_TYPE_SHIFT)) - -#define WMI_DATA_HDR_GET_DOT11(h) (WMI_DATA_HDR_GET_DATA_TYPE((h)) == WMI_DATA_HDR_DATA_TYPE_802_11) -#define WMI_DATA_HDR_SET_DOT11(h, p) WMI_DATA_HDR_SET_DATA_TYPE((h), (p)) - -/* Macros for operating on WMI_DATA_HDR (info2) field */ -#define WMI_DATA_HDR_SEQNO_MASK 0xFFF -#define WMI_DATA_HDR_SEQNO_SHIFT 0 - -#define WMI_DATA_HDR_AMSDU_MASK 0x1 -#define WMI_DATA_HDR_AMSDU_SHIFT 12 - -#define WMI_DATA_HDR_META_MASK 0x7 -#define WMI_DATA_HDR_META_SHIFT 13 - -#define GET_SEQ_NO(_v) ((_v) & WMI_DATA_HDR_SEQNO_MASK) -#define GET_ISMSDU(_v) ((_v) & WMI_DATA_HDR_AMSDU_MASK) - -#define WMI_DATA_HDR_GET_SEQNO(h) GET_SEQ_NO((h)->info2 >> WMI_DATA_HDR_SEQNO_SHIFT) -#define WMI_DATA_HDR_SET_SEQNO(h, _v) ((h)->info2 = ((h)->info2 & ~(WMI_DATA_HDR_SEQNO_MASK << WMI_DATA_HDR_SEQNO_SHIFT)) | (GET_SEQ_NO(_v) << WMI_DATA_HDR_SEQNO_SHIFT)) - -#define WMI_DATA_HDR_IS_AMSDU(h) GET_ISMSDU((h)->info2 >> WMI_DATA_HDR_AMSDU_SHIFT) -#define WMI_DATA_HDR_SET_AMSDU(h, _v) ((h)->info2 = ((h)->info2 & ~(WMI_DATA_HDR_AMSDU_MASK << WMI_DATA_HDR_AMSDU_SHIFT)) | (GET_ISMSDU(_v) << WMI_DATA_HDR_AMSDU_SHIFT)) - -#define WMI_DATA_HDR_GET_META(h) (((h)->info2 >> WMI_DATA_HDR_META_SHIFT) & WMI_DATA_HDR_META_MASK) -#define WMI_DATA_HDR_SET_META(h, _v) ((h)->info2 = ((h)->info2 & ~(WMI_DATA_HDR_META_MASK << WMI_DATA_HDR_META_SHIFT)) | ((_v) << WMI_DATA_HDR_META_SHIFT)) - -/* Macros for operating on WMI_DATA_HDR (info3) field */ -#define WMI_DATA_HDR_DEVID_MASK 0xF -#define WMI_DATA_HDR_DEVID_SHIFT 0 -#define GET_DEVID(_v) ((_v) & WMI_DATA_HDR_DEVID_MASK) - -#define WMI_DATA_HDR_GET_DEVID(h) \ - (((h)->info3 >> WMI_DATA_HDR_DEVID_SHIFT) & WMI_DATA_HDR_DEVID_MASK) -#define WMI_DATA_HDR_SET_DEVID(h, _v) \ - ((h)->info3 = ((h)->info3 & ~(WMI_DATA_HDR_DEVID_MASK << WMI_DATA_HDR_DEVID_SHIFT)) | (GET_DEVID(_v) << WMI_DATA_HDR_DEVID_SHIFT)) - -typedef PREPACK struct { - s8 rssi; - u8 info; /* usage of 'info' field(8-bit): - * b1:b0 - WMI_MSG_TYPE - * b4:b3:b2 - UP(tid) - * b5 - Used in AP mode. More-data in tx dir, PS in rx. - * b7:b6 - Dot3 header(0), - * Dot11 Header(1), - * ACL data(2) - */ - - u16 info2; /* usage of 'info2' field(16-bit): - * b11:b0 - seq_no - * b12 - A-MSDU? - * b15:b13 - META_DATA_VERSION 0 - 7 - */ - u16 info3; -} POSTPACK WMI_DATA_HDR; - -/* - * TX META VERSION DEFINITIONS - */ -#define WMI_MAX_TX_META_SZ (12) -#define WMI_MAX_TX_META_VERSION (7) -#define WMI_META_VERSION_1 (0x01) -#define WMI_META_VERSION_2 (0X02) - -#define WMI_ACL_TO_DOT11_HEADROOM 36 - -#if 0 /* removed to prevent compile errors for WM.. */ -typedef PREPACK struct { -/* intentionally empty. Default version is no meta data. */ -} POSTPACK WMI_TX_META_V0; -#endif - -typedef PREPACK struct { - u8 pktID; /* The packet ID to identify the tx request */ - u8 ratePolicyID; /* The rate policy to be used for the tx of this frame */ -} POSTPACK WMI_TX_META_V1; - - -#define WMI_CSUM_DIR_TX (0x1) -#define TX_CSUM_CALC_FILL (0x1) -typedef PREPACK struct { - u8 csumStart; /*Offset from start of the WMI header for csum calculation to begin */ - u8 csumDest; /*Offset from start of WMI header where final csum goes*/ - u8 csumFlags; /*number of bytes over which csum is calculated*/ -} POSTPACK WMI_TX_META_V2; - - -/* - * RX META VERSION DEFINITIONS - */ -/* if RX meta data is present at all then the meta data field - * will consume WMI_MAX_RX_META_SZ bytes of space between the - * WMI_DATA_HDR and the payload. How much of the available - * Meta data is actually used depends on which meta data - * version is active. */ -#define WMI_MAX_RX_META_SZ (12) -#define WMI_MAX_RX_META_VERSION (7) - -#define WMI_RX_STATUS_OK 0 /* success */ -#define WMI_RX_STATUS_DECRYPT_ERR 1 /* decrypt error */ -#define WMI_RX_STATUS_MIC_ERR 2 /* tkip MIC error */ -#define WMI_RX_STATUS_ERR 3 /* undefined error */ - -#define WMI_RX_FLAGS_AGGR 0x0001 /* part of AGGR */ -#define WMI_RX_FlAGS_STBC 0x0002 /* used STBC */ -#define WMI_RX_FLAGS_SGI 0x0004 /* used SGI */ -#define WMI_RX_FLAGS_HT 0x0008 /* is HT packet */ -/* the flags field is also used to store the CRYPTO_TYPE of the frame - * that value is shifted by WMI_RX_FLAGS_CRYPTO_SHIFT */ -#define WMI_RX_FLAGS_CRYPTO_SHIFT 4 -#define WMI_RX_FLAGS_CRYPTO_MASK 0x1f -#define WMI_RX_META_GET_CRYPTO(flags) (((flags) >> WMI_RX_FLAGS_CRYPTO_SHIFT) & WMI_RX_FLAGS_CRYPTO_MASK) - -#if 0 /* removed to prevent compile errors for WM.. */ -typedef PREPACK struct { -/* intentionally empty. Default version is no meta data. */ -} POSTPACK WMI_RX_META_VERSION_0; -#endif - -typedef PREPACK struct { - u8 status; /* one of WMI_RX_STATUS_... */ - u8 rix; /* rate index mapped to rate at which this packet was received. */ - u8 rssi; /* rssi of packet */ - u8 channel;/* rf channel during packet reception */ - u16 flags; /* a combination of WMI_RX_FLAGS_... */ -} POSTPACK WMI_RX_META_V1; - -#define RX_CSUM_VALID_FLAG (0x1) -typedef PREPACK struct { - u16 csum; - u8 csumFlags;/* bit 0 set -partial csum valid - bit 1 set -test mode */ -} POSTPACK WMI_RX_META_V2; - - - -#define WMI_GET_DEVICE_ID(info1) ((info1) & 0xF) -/* Macros for operating on WMI_CMD_HDR (info1) field */ -#define WMI_CMD_HDR_DEVID_MASK 0xF -#define WMI_CMD_HDR_DEVID_SHIFT 0 -#define GET_CMD_DEVID(_v) ((_v) & WMI_CMD_HDR_DEVID_MASK) - -#define WMI_CMD_HDR_GET_DEVID(h) \ - (((h)->info1 >> WMI_CMD_HDR_DEVID_SHIFT) & WMI_CMD_HDR_DEVID_MASK) -#define WMI_CMD_HDR_SET_DEVID(h, _v) \ - ((h)->info1 = ((h)->info1 & \ - ~(WMI_CMD_HDR_DEVID_MASK << WMI_CMD_HDR_DEVID_SHIFT)) | \ - (GET_CMD_DEVID(_v) << WMI_CMD_HDR_DEVID_SHIFT)) - -/* - * Control Path - */ -typedef PREPACK struct { - u16 commandId; -/* - * info1 - 16 bits - * b03:b00 - id - * b15:b04 - unused - */ - u16 info1; - - u16 reserved; /* For alignment */ -} POSTPACK WMI_CMD_HDR; /* used for commands and events */ - -/* - * List of Commnands - */ -typedef enum { - WMI_CONNECT_CMDID = 0x0001, - WMI_RECONNECT_CMDID, - WMI_DISCONNECT_CMDID, - WMI_SYNCHRONIZE_CMDID, - WMI_CREATE_PSTREAM_CMDID, - WMI_DELETE_PSTREAM_CMDID, - WMI_START_SCAN_CMDID, - WMI_SET_SCAN_PARAMS_CMDID, - WMI_SET_BSS_FILTER_CMDID, - WMI_SET_PROBED_SSID_CMDID, /* 10 */ - WMI_SET_LISTEN_INT_CMDID, - WMI_SET_BMISS_TIME_CMDID, - WMI_SET_DISC_TIMEOUT_CMDID, - WMI_GET_CHANNEL_LIST_CMDID, - WMI_SET_BEACON_INT_CMDID, - WMI_GET_STATISTICS_CMDID, - WMI_SET_CHANNEL_PARAMS_CMDID, - WMI_SET_POWER_MODE_CMDID, - WMI_SET_IBSS_PM_CAPS_CMDID, - WMI_SET_POWER_PARAMS_CMDID, /* 20 */ - WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID, - WMI_ADD_CIPHER_KEY_CMDID, - WMI_DELETE_CIPHER_KEY_CMDID, - WMI_ADD_KRK_CMDID, - WMI_DELETE_KRK_CMDID, - WMI_SET_PMKID_CMDID, - WMI_SET_TX_PWR_CMDID, - WMI_GET_TX_PWR_CMDID, - WMI_SET_ASSOC_INFO_CMDID, - WMI_ADD_BAD_AP_CMDID, /* 30 */ - WMI_DELETE_BAD_AP_CMDID, - WMI_SET_TKIP_COUNTERMEASURES_CMDID, - WMI_RSSI_THRESHOLD_PARAMS_CMDID, - WMI_TARGET_ERROR_REPORT_BITMASK_CMDID, - WMI_SET_ACCESS_PARAMS_CMDID, - WMI_SET_RETRY_LIMITS_CMDID, - WMI_SET_OPT_MODE_CMDID, - WMI_OPT_TX_FRAME_CMDID, - WMI_SET_VOICE_PKT_SIZE_CMDID, - WMI_SET_MAX_SP_LEN_CMDID, /* 40 */ - WMI_SET_ROAM_CTRL_CMDID, - WMI_GET_ROAM_TBL_CMDID, - WMI_GET_ROAM_DATA_CMDID, - WMI_ENABLE_RM_CMDID, - WMI_SET_MAX_OFFHOME_DURATION_CMDID, - WMI_EXTENSION_CMDID, /* Non-wireless extensions */ - WMI_SNR_THRESHOLD_PARAMS_CMDID, - WMI_LQ_THRESHOLD_PARAMS_CMDID, - WMI_SET_LPREAMBLE_CMDID, - WMI_SET_RTS_CMDID, /* 50 */ - WMI_CLR_RSSI_SNR_CMDID, - WMI_SET_FIXRATES_CMDID, - WMI_GET_FIXRATES_CMDID, - WMI_SET_AUTH_MODE_CMDID, - WMI_SET_REASSOC_MODE_CMDID, - WMI_SET_WMM_CMDID, - WMI_SET_WMM_TXOP_CMDID, - WMI_TEST_CMDID, - /* COEX AR6002 only*/ - WMI_SET_BT_STATUS_CMDID, - WMI_SET_BT_PARAMS_CMDID, /* 60 */ - - WMI_SET_KEEPALIVE_CMDID, - WMI_GET_KEEPALIVE_CMDID, - WMI_SET_APPIE_CMDID, - WMI_GET_APPIE_CMDID, - WMI_SET_WSC_STATUS_CMDID, - - /* Wake on Wireless */ - WMI_SET_HOST_SLEEP_MODE_CMDID, - WMI_SET_WOW_MODE_CMDID, - WMI_GET_WOW_LIST_CMDID, - WMI_ADD_WOW_PATTERN_CMDID, - WMI_DEL_WOW_PATTERN_CMDID, /* 70 */ - - WMI_SET_FRAMERATES_CMDID, - WMI_SET_AP_PS_CMDID, - WMI_SET_QOS_SUPP_CMDID, - /* WMI_THIN_RESERVED_... mark the start and end - * values for WMI_THIN_RESERVED command IDs. These - * command IDs can be found in wmi_thin.h */ - WMI_THIN_RESERVED_START = 0x8000, - WMI_THIN_RESERVED_END = 0x8fff, - /* - * Developer commands starts at 0xF000 - */ - WMI_SET_BITRATE_CMDID = 0xF000, - WMI_GET_BITRATE_CMDID, - WMI_SET_WHALPARAM_CMDID, - - - /*Should add the new command to the tail for compatible with - * etna. - */ - WMI_SET_MAC_ADDRESS_CMDID, - WMI_SET_AKMP_PARAMS_CMDID, - WMI_SET_PMKID_LIST_CMDID, - WMI_GET_PMKID_LIST_CMDID, - WMI_ABORT_SCAN_CMDID, - WMI_SET_TARGET_EVENT_REPORT_CMDID, - - // Unused - WMI_UNUSED1, - WMI_UNUSED2, - - /* - * AP mode commands - */ - WMI_AP_HIDDEN_SSID_CMDID, - WMI_AP_SET_NUM_STA_CMDID, - WMI_AP_ACL_POLICY_CMDID, - WMI_AP_ACL_MAC_LIST_CMDID, - WMI_AP_CONFIG_COMMIT_CMDID, - WMI_AP_SET_MLME_CMDID, - WMI_AP_SET_PVB_CMDID, - WMI_AP_CONN_INACT_CMDID, - WMI_AP_PROT_SCAN_TIME_CMDID, - WMI_AP_SET_COUNTRY_CMDID, - WMI_AP_SET_DTIM_CMDID, - WMI_AP_MODE_STAT_CMDID, - - WMI_SET_IP_CMDID, - WMI_SET_PARAMS_CMDID, - WMI_SET_MCAST_FILTER_CMDID, - WMI_DEL_MCAST_FILTER_CMDID, - - WMI_ALLOW_AGGR_CMDID, - WMI_ADDBA_REQ_CMDID, - WMI_DELBA_REQ_CMDID, - WMI_SET_HT_CAP_CMDID, - WMI_SET_HT_OP_CMDID, - WMI_SET_TX_SELECT_RATES_CMDID, - WMI_SET_TX_SGI_PARAM_CMDID, - WMI_SET_RATE_POLICY_CMDID, - - WMI_HCI_CMD_CMDID, - WMI_RX_FRAME_FORMAT_CMDID, - WMI_SET_THIN_MODE_CMDID, - WMI_SET_BT_WLAN_CONN_PRECEDENCE_CMDID, - - WMI_AP_SET_11BG_RATESET_CMDID, - WMI_SET_PMK_CMDID, - WMI_MCAST_FILTER_CMDID, - /* COEX CMDID AR6003*/ - WMI_SET_BTCOEX_FE_ANT_CMDID, - WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMDID, - WMI_SET_BTCOEX_SCO_CONFIG_CMDID, - WMI_SET_BTCOEX_A2DP_CONFIG_CMDID, - WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMDID, - WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMDID, - WMI_SET_BTCOEX_DEBUG_CMDID, - WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID, - WMI_GET_BTCOEX_STATS_CMDID, - WMI_GET_BTCOEX_CONFIG_CMDID, - - WMI_SET_DFS_ENABLE_CMDID, /* F034 */ - WMI_SET_DFS_MINRSSITHRESH_CMDID, - WMI_SET_DFS_MAXPULSEDUR_CMDID, - WMI_DFS_RADAR_DETECTED_CMDID, - - /* P2P CMDS */ - WMI_P2P_SET_CONFIG_CMDID, /* F038 */ - WMI_WPS_SET_CONFIG_CMDID, - WMI_SET_REQ_DEV_ATTR_CMDID, - WMI_P2P_FIND_CMDID, - WMI_P2P_STOP_FIND_CMDID, - WMI_P2P_GO_NEG_START_CMDID, - WMI_P2P_LISTEN_CMDID, - - WMI_CONFIG_TX_MAC_RULES_CMDID, /* F040 */ - WMI_SET_PROMISCUOUS_MODE_CMDID, - WMI_RX_FRAME_FILTER_CMDID, - WMI_SET_CHANNEL_CMDID, - - /* WAC commands */ - WMI_ENABLE_WAC_CMDID, - WMI_WAC_SCAN_REPLY_CMDID, - WMI_WAC_CTRL_REQ_CMDID, - WMI_SET_DIV_PARAMS_CMDID, - - WMI_GET_PMK_CMDID, - WMI_SET_PASSPHRASE_CMDID, - WMI_SEND_ASSOC_RES_CMDID, - WMI_SET_ASSOC_REQ_RELAY_CMDID, - WMI_GET_RFKILL_MODE_CMDID, - - /* ACS command, consists of sub-commands */ - WMI_ACS_CTRL_CMDID, - - /* Ultra low power store / recall commands */ - WMI_STORERECALL_CONFIGURE_CMDID, - WMI_STORERECALL_RECALL_CMDID, - WMI_STORERECALL_HOST_READY_CMDID, - WMI_FORCE_TARGET_ASSERT_CMDID, - WMI_SET_EXCESS_TX_RETRY_THRES_CMDID, -} WMI_COMMAND_ID; - -/* - * Frame Types - */ -typedef enum { - WMI_FRAME_BEACON = 0, - WMI_FRAME_PROBE_REQ, - WMI_FRAME_PROBE_RESP, - WMI_FRAME_ASSOC_REQ, - WMI_FRAME_ASSOC_RESP, - WMI_NUM_MGMT_FRAME -} WMI_MGMT_FRAME_TYPE; - -/* - * Connect Command - */ -typedef enum { - INFRA_NETWORK = 0x01, - ADHOC_NETWORK = 0x02, - ADHOC_CREATOR = 0x04, - AP_NETWORK = 0x10, -} NETWORK_TYPE; - -typedef enum { - OPEN_AUTH = 0x01, - SHARED_AUTH = 0x02, - LEAP_AUTH = 0x04, /* different from IEEE_AUTH_MODE definitions */ -} DOT11_AUTH_MODE; - -enum { - AUTH_IDLE, - AUTH_OPEN_IN_PROGRESS, -}; - -typedef enum { - NONE_AUTH = 0x01, - WPA_AUTH = 0x02, - WPA2_AUTH = 0x04, - WPA_PSK_AUTH = 0x08, - WPA2_PSK_AUTH = 0x10, - WPA_AUTH_CCKM = 0x20, - WPA2_AUTH_CCKM = 0x40, -} AUTH_MODE; - -typedef enum { - NONE_CRYPT = 0x01, - WEP_CRYPT = 0x02, - TKIP_CRYPT = 0x04, - AES_CRYPT = 0x08, -#ifdef WAPI_ENABLE - WAPI_CRYPT = 0x10, -#endif /*WAPI_ENABLE*/ -} CRYPTO_TYPE; - -#define WMI_MIN_CRYPTO_TYPE NONE_CRYPT -#define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1) - -#ifdef WAPI_ENABLE -#undef WMI_MAX_CRYPTO_TYPE -#define WMI_MAX_CRYPTO_TYPE (WAPI_CRYPT + 1) -#endif /* WAPI_ENABLE */ - -#ifdef WAPI_ENABLE -#define IW_ENCODE_ALG_SM4 0x20 -#define IW_AUTH_WAPI_ENABLED 0x20 -#endif - -#define WMI_MIN_KEY_INDEX 0 -#define WMI_MAX_KEY_INDEX 3 - -#ifdef WAPI_ENABLE -#undef WMI_MAX_KEY_INDEX -#define WMI_MAX_KEY_INDEX 7 /* wapi grpKey 0-3, prwKey 4-7 */ -#endif /* WAPI_ENABLE */ - -#define WMI_MAX_KEY_LEN 32 - -#define WMI_MAX_SSID_LEN 32 - -typedef enum { - CONNECT_ASSOC_POLICY_USER = 0x0001, - CONNECT_SEND_REASSOC = 0x0002, - CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004, - CONNECT_PROFILE_MATCH_DONE = 0x0008, - CONNECT_IGNORE_AAC_BEACON = 0x0010, - CONNECT_CSA_FOLLOW_BSS = 0x0020, - CONNECT_DO_WPA_OFFLOAD = 0x0040, - CONNECT_DO_NOT_DEAUTH = 0x0080, -} WMI_CONNECT_CTRL_FLAGS_BITS; - -#define DEFAULT_CONNECT_CTRL_FLAGS (CONNECT_CSA_FOLLOW_BSS) - -typedef PREPACK struct { - u8 networkType; - u8 dot11AuthMode; - u8 authMode; - u8 pairwiseCryptoType; - u8 pairwiseCryptoLen; - u8 groupCryptoType; - u8 groupCryptoLen; - u8 ssidLength; - u8 ssid[WMI_MAX_SSID_LEN]; - u16 channel; - u8 bssid[ATH_MAC_LEN]; - u32 ctrl_flags; -} POSTPACK WMI_CONNECT_CMD; - -/* - * WMI_RECONNECT_CMDID - */ -typedef PREPACK struct { - u16 channel; /* hint */ - u8 bssid[ATH_MAC_LEN]; /* mandatory if set */ -} POSTPACK WMI_RECONNECT_CMD; - -#define WMI_PMK_LEN 32 -typedef PREPACK struct { - u8 pmk[WMI_PMK_LEN]; -} POSTPACK WMI_SET_PMK_CMD; - -/* - * WMI_SET_EXCESS_TX_RETRY_THRES_CMDID - */ -typedef PREPACK struct { - u32 threshold; -} POSTPACK WMI_SET_EXCESS_TX_RETRY_THRES_CMD; - -/* - * WMI_ADD_CIPHER_KEY_CMDID - */ -typedef enum { - PAIRWISE_USAGE = 0x00, - GROUP_USAGE = 0x01, - TX_USAGE = 0x02, /* default Tx Key - Static WEP only */ -} KEY_USAGE; - -/* - * Bit Flag - * Bit 0 - Initialise TSC - default is Initialize - */ -#define KEY_OP_INIT_TSC 0x01 -#define KEY_OP_INIT_RSC 0x02 -#ifdef WAPI_ENABLE -#define KEY_OP_INIT_WAPIPN 0x10 -#endif /* WAPI_ENABLE */ - -#define KEY_OP_INIT_VAL 0x03 /* Default Initialise the TSC & RSC */ -#define KEY_OP_VALID_MASK 0x03 - -typedef PREPACK struct { - u8 keyIndex; - u8 keyType; - u8 keyUsage; /* KEY_USAGE */ - u8 keyLength; - u8 keyRSC[8]; /* key replay sequence counter */ - u8 key[WMI_MAX_KEY_LEN]; - u8 key_op_ctrl; /* Additional Key Control information */ - u8 key_macaddr[ATH_MAC_LEN]; -} POSTPACK WMI_ADD_CIPHER_KEY_CMD; - -/* - * WMI_DELETE_CIPHER_KEY_CMDID - */ -typedef PREPACK struct { - u8 keyIndex; -} POSTPACK WMI_DELETE_CIPHER_KEY_CMD; - -#define WMI_KRK_LEN 16 -/* - * WMI_ADD_KRK_CMDID - */ -typedef PREPACK struct { - u8 krk[WMI_KRK_LEN]; -} POSTPACK WMI_ADD_KRK_CMD; - -/* - * WMI_SET_TKIP_COUNTERMEASURES_CMDID - */ -typedef enum { - WMI_TKIP_CM_DISABLE = 0x0, - WMI_TKIP_CM_ENABLE = 0x1, -} WMI_TKIP_CM_CONTROL; - -typedef PREPACK struct { - u8 cm_en; /* WMI_TKIP_CM_CONTROL */ -} POSTPACK WMI_SET_TKIP_COUNTERMEASURES_CMD; - -/* - * WMI_SET_PMKID_CMDID - */ - -#define WMI_PMKID_LEN 16 - -typedef enum { - PMKID_DISABLE = 0, - PMKID_ENABLE = 1, -} PMKID_ENABLE_FLG; - -typedef PREPACK struct { - u8 bssid[ATH_MAC_LEN]; - u8 enable; /* PMKID_ENABLE_FLG */ - u8 pmkid[WMI_PMKID_LEN]; -} POSTPACK WMI_SET_PMKID_CMD; - -/* - * WMI_START_SCAN_CMD - */ -typedef enum { - WMI_LONG_SCAN = 0, - WMI_SHORT_SCAN = 1, -} WMI_SCAN_TYPE; - -typedef PREPACK struct { - u32 forceFgScan; - u32 isLegacy; /* For Legacy Cisco AP compatibility */ - u32 homeDwellTime; /* Maximum duration in the home channel(milliseconds) */ - u32 forceScanInterval; /* Time interval between scans (milliseconds)*/ - u8 scanType; /* WMI_SCAN_TYPE */ - u8 numChannels; /* how many channels follow */ - u16 channelList[1]; /* channels in Mhz */ -} POSTPACK WMI_START_SCAN_CMD; - -/* - * WMI_SET_SCAN_PARAMS_CMDID - */ -#define WMI_SHORTSCANRATIO_DEFAULT 3 -/* - * Warning: ScanCtrlFlag value of 0xFF is used to disable all flags in WMI_SCAN_PARAMS_CMD - * Do not add any more flags to WMI_SCAN_CTRL_FLAG_BITS - */ -typedef enum { - CONNECT_SCAN_CTRL_FLAGS = 0x01, /* set if can scan in the Connect cmd */ - SCAN_CONNECTED_CTRL_FLAGS = 0x02, /* set if scan for the SSID it is */ - /* already connected to */ - ACTIVE_SCAN_CTRL_FLAGS = 0x04, /* set if enable active scan */ - ROAM_SCAN_CTRL_FLAGS = 0x08, /* set if enable roam scan when bmiss and lowrssi */ - REPORT_BSSINFO_CTRL_FLAGS = 0x10, /* set if follows customer BSSINFO reporting rule */ - ENABLE_AUTO_CTRL_FLAGS = 0x20, /* if disabled, target doesn't - scan after a disconnect event */ - ENABLE_SCAN_ABORT_EVENT = 0x40 /* Scan complete event with canceled status will be generated when a scan is prempted before it gets completed */ -} WMI_SCAN_CTRL_FLAGS_BITS; - -#define CAN_SCAN_IN_CONNECT(flags) (flags & CONNECT_SCAN_CTRL_FLAGS) -#define CAN_SCAN_CONNECTED(flags) (flags & SCAN_CONNECTED_CTRL_FLAGS) -#define ENABLE_ACTIVE_SCAN(flags) (flags & ACTIVE_SCAN_CTRL_FLAGS) -#define ENABLE_ROAM_SCAN(flags) (flags & ROAM_SCAN_CTRL_FLAGS) -#define CONFIG_REPORT_BSSINFO(flags) (flags & REPORT_BSSINFO_CTRL_FLAGS) -#define IS_AUTO_SCAN_ENABLED(flags) (flags & ENABLE_AUTO_CTRL_FLAGS) -#define SCAN_ABORT_EVENT_ENABLED(flags) (flags & ENABLE_SCAN_ABORT_EVENT) - -#define DEFAULT_SCAN_CTRL_FLAGS (CONNECT_SCAN_CTRL_FLAGS| SCAN_CONNECTED_CTRL_FLAGS| ACTIVE_SCAN_CTRL_FLAGS| ROAM_SCAN_CTRL_FLAGS | ENABLE_AUTO_CTRL_FLAGS) - - -typedef PREPACK struct { - u16 fg_start_period; /* seconds */ - u16 fg_end_period; /* seconds */ - u16 bg_period; /* seconds */ - u16 maxact_chdwell_time; /* msec */ - u16 pas_chdwell_time; /* msec */ - u8 shortScanRatio; /* how many shorts scan for one long */ - u8 scanCtrlFlags; - u16 minact_chdwell_time; /* msec */ - u16 maxact_scan_per_ssid; /* max active scans per ssid */ - u32 max_dfsch_act_time; /* msecs */ -} POSTPACK WMI_SCAN_PARAMS_CMD; - -/* - * WMI_SET_BSS_FILTER_CMDID - */ -typedef enum { - NONE_BSS_FILTER = 0x0, /* no beacons forwarded */ - ALL_BSS_FILTER, /* all beacons forwarded */ - PROFILE_FILTER, /* only beacons matching profile */ - ALL_BUT_PROFILE_FILTER, /* all but beacons matching profile */ - CURRENT_BSS_FILTER, /* only beacons matching current BSS */ - ALL_BUT_BSS_FILTER, /* all but beacons matching BSS */ - PROBED_SSID_FILTER, /* beacons matching probed ssid */ - LAST_BSS_FILTER, /* marker only */ -} WMI_BSS_FILTER; - -typedef PREPACK struct { - u8 bssFilter; /* see WMI_BSS_FILTER */ - u8 reserved1; /* For alignment */ - u16 reserved2; /* For alignment */ - u32 ieMask; -} POSTPACK WMI_BSS_FILTER_CMD; - -/* - * WMI_SET_PROBED_SSID_CMDID - */ -#define MAX_PROBED_SSID_INDEX 9 - -typedef enum { - DISABLE_SSID_FLAG = 0, /* disables entry */ - SPECIFIC_SSID_FLAG = 0x01, /* probes specified ssid */ - ANY_SSID_FLAG = 0x02, /* probes for any ssid */ -} WMI_SSID_FLAG; - -typedef PREPACK struct { - u8 entryIndex; /* 0 to MAX_PROBED_SSID_INDEX */ - u8 flag; /* WMI_SSID_FLG */ - u8 ssidLength; - u8 ssid[32]; -} POSTPACK WMI_PROBED_SSID_CMD; - -/* - * WMI_SET_LISTEN_INT_CMDID - * The Listen interval is between 15 and 3000 TUs - */ -#define MIN_LISTEN_INTERVAL 15 -#define MAX_LISTEN_INTERVAL 5000 -#define MIN_LISTEN_BEACONS 1 -#define MAX_LISTEN_BEACONS 50 - -typedef PREPACK struct { - u16 listenInterval; - u16 numBeacons; -} POSTPACK WMI_LISTEN_INT_CMD; - -/* - * WMI_SET_BEACON_INT_CMDID - */ -typedef PREPACK struct { - u16 beaconInterval; -} POSTPACK WMI_BEACON_INT_CMD; - -/* - * WMI_SET_BMISS_TIME_CMDID - * valid values are between 1000 and 5000 TUs - */ - -#define MIN_BMISS_TIME 1000 -#define MAX_BMISS_TIME 5000 -#define MIN_BMISS_BEACONS 1 -#define MAX_BMISS_BEACONS 50 - -typedef PREPACK struct { - u16 bmissTime; - u16 numBeacons; -} POSTPACK WMI_BMISS_TIME_CMD; - -/* - * WMI_SET_POWER_MODE_CMDID - */ -typedef enum { - REC_POWER = 0x01, - MAX_PERF_POWER, -} WMI_POWER_MODE; - -typedef PREPACK struct { - u8 powerMode; /* WMI_POWER_MODE */ -} POSTPACK WMI_POWER_MODE_CMD; - -typedef PREPACK struct { - s8 status; /* WMI_SET_PARAMS_REPLY */ -} POSTPACK WMI_SET_PARAMS_REPLY; - -typedef PREPACK struct { - u32 opcode; - u32 length; - char buffer[1]; /* WMI_SET_PARAMS */ -} POSTPACK WMI_SET_PARAMS_CMD; - -typedef PREPACK struct { - u8 multicast_mac[ATH_MAC_LEN]; /* WMI_SET_MCAST_FILTER */ -} POSTPACK WMI_SET_MCAST_FILTER_CMD; - -typedef PREPACK struct { - u8 enable; /* WMI_MCAST_FILTER */ -} POSTPACK WMI_MCAST_FILTER_CMD; - -/* - * WMI_SET_POWER_PARAMS_CMDID - */ -typedef enum { - IGNORE_DTIM = 0x01, - NORMAL_DTIM = 0x02, - STICK_DTIM = 0x03, - AUTO_DTIM = 0x04, -} WMI_DTIM_POLICY; - -/* Policy to determnine whether TX should wakeup WLAN if sleeping */ -typedef enum { - TX_WAKEUP_UPON_SLEEP = 1, - TX_DONT_WAKEUP_UPON_SLEEP = 2 -} WMI_TX_WAKEUP_POLICY_UPON_SLEEP; - -/* - * Policy to determnine whether power save failure event should be sent to - * host during scanning - */ -typedef enum { - SEND_POWER_SAVE_FAIL_EVENT_ALWAYS = 1, - IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN = 2, -} POWER_SAVE_FAIL_EVENT_POLICY; - -typedef PREPACK struct { - u16 idle_period; /* msec */ - u16 pspoll_number; - u16 dtim_policy; - u16 tx_wakeup_policy; - u16 num_tx_to_wakeup; - u16 ps_fail_event_policy; -} POSTPACK WMI_POWER_PARAMS_CMD; - -/* Adhoc power save types */ -typedef enum { - ADHOC_PS_DISABLE=1, - ADHOC_PS_ATH=2, - ADHOC_PS_IEEE=3, - ADHOC_PS_OTHER=4, -} WMI_ADHOC_PS_TYPE; - -typedef PREPACK struct { - u8 power_saving; - u8 ttl; /* number of beacon periods */ - u16 atim_windows; /* msec */ - u16 timeout_value; /* msec */ -} POSTPACK WMI_IBSS_PM_CAPS_CMD; - -/* AP power save types */ -typedef enum { - AP_PS_DISABLE=1, - AP_PS_ATH=2, -} WMI_AP_PS_TYPE; - -typedef PREPACK struct { - u32 idle_time; /* in msec */ - u32 ps_period; /* in usec */ - u8 sleep_period; /* in ps periods */ - u8 psType; -} POSTPACK WMI_AP_PS_CMD; - -/* - * WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID - */ -typedef enum { - IGNORE_TIM_ALL_QUEUES_APSD = 0, - PROCESS_TIM_ALL_QUEUES_APSD = 1, - IGNORE_TIM_SIMULATED_APSD = 2, - PROCESS_TIM_SIMULATED_APSD = 3, -} APSD_TIM_POLICY; - -typedef PREPACK struct { - u16 psPollTimeout; /* msec */ - u16 triggerTimeout; /* msec */ - u32 apsdTimPolicy; /* TIM behavior with ques APSD enabled. Default is IGNORE_TIM_ALL_QUEUES_APSD */ - u32 simulatedAPSDTimPolicy; /* TIM behavior with simulated APSD enabled. Default is PROCESS_TIM_SIMULATED_APSD */ -} POSTPACK WMI_POWERSAVE_TIMERS_POLICY_CMD; - -/* - * WMI_SET_VOICE_PKT_SIZE_CMDID - */ -typedef PREPACK struct { - u16 voicePktSize; -} POSTPACK WMI_SET_VOICE_PKT_SIZE_CMD; - -/* - * WMI_SET_MAX_SP_LEN_CMDID - */ -typedef enum { - DELIVER_ALL_PKT = 0x0, - DELIVER_2_PKT = 0x1, - DELIVER_4_PKT = 0x2, - DELIVER_6_PKT = 0x3, -} APSD_SP_LEN_TYPE; - -typedef PREPACK struct { - u8 maxSPLen; -} POSTPACK WMI_SET_MAX_SP_LEN_CMD; - -/* - * WMI_SET_DISC_TIMEOUT_CMDID - */ -typedef PREPACK struct { - u8 disconnectTimeout; /* seconds */ -} POSTPACK WMI_DISC_TIMEOUT_CMD; - -typedef enum { - UPLINK_TRAFFIC = 0, - DNLINK_TRAFFIC = 1, - BIDIR_TRAFFIC = 2, -} DIR_TYPE; - -typedef enum { - DISABLE_FOR_THIS_AC = 0, - ENABLE_FOR_THIS_AC = 1, - ENABLE_FOR_ALL_AC = 2, -} VOICEPS_CAP_TYPE; - -typedef enum { - TRAFFIC_TYPE_APERIODIC = 0, - TRAFFIC_TYPE_PERIODIC = 1, -}TRAFFIC_TYPE; - -/* - * WMI_SYNCHRONIZE_CMDID - */ -typedef PREPACK struct { - u8 dataSyncMap; -} POSTPACK WMI_SYNC_CMD; - -/* - * WMI_CREATE_PSTREAM_CMDID - */ -typedef PREPACK struct { - u32 minServiceInt; /* in milli-sec */ - u32 maxServiceInt; /* in milli-sec */ - u32 inactivityInt; /* in milli-sec */ - u32 suspensionInt; /* in milli-sec */ - u32 serviceStartTime; - u32 minDataRate; /* in bps */ - u32 meanDataRate; /* in bps */ - u32 peakDataRate; /* in bps */ - u32 maxBurstSize; - u32 delayBound; - u32 minPhyRate; /* in bps */ - u32 sba; - u32 mediumTime; - u16 nominalMSDU; /* in octects */ - u16 maxMSDU; /* in octects */ - u8 trafficClass; - u8 trafficDirection; /* DIR_TYPE */ - u8 rxQueueNum; - u8 trafficType; /* TRAFFIC_TYPE */ - u8 voicePSCapability; /* VOICEPS_CAP_TYPE */ - u8 tsid; - u8 userPriority; /* 802.1D user priority */ - u8 nominalPHY; /* nominal phy rate */ -} POSTPACK WMI_CREATE_PSTREAM_CMD; - -/* - * WMI_DELETE_PSTREAM_CMDID - */ -typedef PREPACK struct { - u8 txQueueNumber; - u8 rxQueueNumber; - u8 trafficDirection; - u8 trafficClass; - u8 tsid; -} POSTPACK WMI_DELETE_PSTREAM_CMD; - -/* - * WMI_SET_CHANNEL_PARAMS_CMDID - */ -typedef enum { - WMI_11A_MODE = 0x1, - WMI_11G_MODE = 0x2, - WMI_11AG_MODE = 0x3, - WMI_11B_MODE = 0x4, - WMI_11GONLY_MODE = 0x5, -} WMI_PHY_MODE; - -#define WMI_MAX_CHANNELS 32 - -typedef PREPACK struct { - u8 reserved1; - u8 scanParam; /* set if enable scan */ - u8 phyMode; /* see WMI_PHY_MODE */ - u8 numChannels; /* how many channels follow */ - u16 channelList[1]; /* channels in Mhz */ -} POSTPACK WMI_CHANNEL_PARAMS_CMD; - - -/* - * WMI_RSSI_THRESHOLD_PARAMS_CMDID - * Setting the polltime to 0 would disable polling. - * Threshold values are in the ascending order, and should agree to: - * (lowThreshold_lowerVal < lowThreshold_upperVal < highThreshold_lowerVal - * < highThreshold_upperVal) - */ - -typedef PREPACK struct WMI_RSSI_THRESHOLD_PARAMS{ - u32 pollTime; /* Polling time as a factor of LI */ - s16 thresholdAbove1_Val; /* lowest of upper */ - s16 thresholdAbove2_Val; - s16 thresholdAbove3_Val; - s16 thresholdAbove4_Val; - s16 thresholdAbove5_Val; - s16 thresholdAbove6_Val; /* highest of upper */ - s16 thresholdBelow1_Val; /* lowest of bellow */ - s16 thresholdBelow2_Val; - s16 thresholdBelow3_Val; - s16 thresholdBelow4_Val; - s16 thresholdBelow5_Val; - s16 thresholdBelow6_Val; /* highest of bellow */ - u8 weight; /* "alpha" */ - u8 reserved[3]; -} POSTPACK WMI_RSSI_THRESHOLD_PARAMS_CMD; - -/* - * WMI_SNR_THRESHOLD_PARAMS_CMDID - * Setting the polltime to 0 would disable polling. - */ - -typedef PREPACK struct WMI_SNR_THRESHOLD_PARAMS{ - u32 pollTime; /* Polling time as a factor of LI */ - u8 weight; /* "alpha" */ - u8 thresholdAbove1_Val; /* lowest of uppper*/ - u8 thresholdAbove2_Val; - u8 thresholdAbove3_Val; - u8 thresholdAbove4_Val; /* highest of upper */ - u8 thresholdBelow1_Val; /* lowest of bellow */ - u8 thresholdBelow2_Val; - u8 thresholdBelow3_Val; - u8 thresholdBelow4_Val; /* highest of bellow */ - u8 reserved[3]; -} POSTPACK WMI_SNR_THRESHOLD_PARAMS_CMD; - -/* - * WMI_LQ_THRESHOLD_PARAMS_CMDID - */ -typedef PREPACK struct WMI_LQ_THRESHOLD_PARAMS { - u8 enable; - u8 thresholdAbove1_Val; - u8 thresholdAbove2_Val; - u8 thresholdAbove3_Val; - u8 thresholdAbove4_Val; - u8 thresholdBelow1_Val; - u8 thresholdBelow2_Val; - u8 thresholdBelow3_Val; - u8 thresholdBelow4_Val; - u8 reserved[3]; -} POSTPACK WMI_LQ_THRESHOLD_PARAMS_CMD; - -typedef enum { - WMI_LPREAMBLE_DISABLED = 0, - WMI_LPREAMBLE_ENABLED -} WMI_LPREAMBLE_STATUS; - -typedef enum { - WMI_IGNORE_BARKER_IN_ERP = 0, - WMI_DONOT_IGNORE_BARKER_IN_ERP -} WMI_PREAMBLE_POLICY; - -typedef PREPACK struct { - u8 status; - u8 preamblePolicy; -}POSTPACK WMI_SET_LPREAMBLE_CMD; - -typedef PREPACK struct { - u16 threshold; -}POSTPACK WMI_SET_RTS_CMD; - -/* - * WMI_TARGET_ERROR_REPORT_BITMASK_CMDID - * Sets the error reporting event bitmask in target. Target clears it - * upon an error. Subsequent errors are counted, but not reported - * via event, unless the bitmask is set again. - */ -typedef PREPACK struct { - u32 bitmask; -} POSTPACK WMI_TARGET_ERROR_REPORT_BITMASK; - -/* - * WMI_SET_TX_PWR_CMDID - */ -typedef PREPACK struct { - u8 dbM; /* in dbM units */ -} POSTPACK WMI_SET_TX_PWR_CMD, WMI_TX_PWR_REPLY; - -/* - * WMI_SET_ASSOC_INFO_CMDID - * - * A maximum of 2 private IEs can be sent in the [Re]Assoc request. - * A 3rd one, the CCX version IE can also be set from the host. - */ -#define WMI_MAX_ASSOC_INFO_TYPE 2 -#define WMI_CCX_VER_IE 2 /* ieType to set CCX Version IE */ - -#define WMI_MAX_ASSOC_INFO_LEN 240 - -typedef PREPACK struct { - u8 ieType; - u8 bufferSize; - u8 assocInfo[1]; /* up to WMI_MAX_ASSOC_INFO_LEN */ -} POSTPACK WMI_SET_ASSOC_INFO_CMD; - - -/* - * WMI_GET_TX_PWR_CMDID does not take any parameters - */ - -/* - * WMI_ADD_BAD_AP_CMDID - */ -#define WMI_MAX_BAD_AP_INDEX 1 - -typedef PREPACK struct { - u8 badApIndex; /* 0 to WMI_MAX_BAD_AP_INDEX */ - u8 bssid[ATH_MAC_LEN]; -} POSTPACK WMI_ADD_BAD_AP_CMD; - -/* - * WMI_DELETE_BAD_AP_CMDID - */ -typedef PREPACK struct { - u8 badApIndex; /* 0 to WMI_MAX_BAD_AP_INDEX */ -} POSTPACK WMI_DELETE_BAD_AP_CMD; - -/* - * WMI_SET_ACCESS_PARAMS_CMDID - */ -#define WMI_DEFAULT_TXOP_ACPARAM 0 /* implies one MSDU */ -#define WMI_DEFAULT_ECWMIN_ACPARAM 4 /* corresponds to CWmin of 15 */ -#define WMI_DEFAULT_ECWMAX_ACPARAM 10 /* corresponds to CWmax of 1023 */ -#define WMI_MAX_CW_ACPARAM 15 /* maximum eCWmin or eCWmax */ -#define WMI_DEFAULT_AIFSN_ACPARAM 2 -#define WMI_MAX_AIFSN_ACPARAM 15 -typedef PREPACK struct { - u16 txop; /* in units of 32 usec */ - u8 eCWmin; - u8 eCWmax; - u8 aifsn; - u8 ac; -} POSTPACK WMI_SET_ACCESS_PARAMS_CMD; - - -/* - * WMI_SET_RETRY_LIMITS_CMDID - * - * This command is used to customize the number of retries the - * wlan device will perform on a given frame. - */ -#define WMI_MIN_RETRIES 2 -#define WMI_MAX_RETRIES 13 -typedef enum { - MGMT_FRAMETYPE = 0, - CONTROL_FRAMETYPE = 1, - DATA_FRAMETYPE = 2 -} WMI_FRAMETYPE; - -typedef PREPACK struct { - u8 frameType; /* WMI_FRAMETYPE */ - u8 trafficClass; /* applies only to DATA_FRAMETYPE */ - u8 maxRetries; - u8 enableNotify; -} POSTPACK WMI_SET_RETRY_LIMITS_CMD; - -/* - * WMI_SET_ROAM_CTRL_CMDID - * - * This command is used to influence the Roaming behaviour - * Set the host biases of the BSSs before setting the roam mode as bias - * based. - */ - -/* - * Different types of Roam Control - */ - -typedef enum { - WMI_FORCE_ROAM = 1, /* Roam to the specified BSSID */ - WMI_SET_ROAM_MODE = 2, /* default ,progd bias, no roam */ - WMI_SET_HOST_BIAS = 3, /* Set the Host Bias */ - WMI_SET_LOWRSSI_SCAN_PARAMS = 4, /* Set lowrssi Scan parameters */ -} WMI_ROAM_CTRL_TYPE; - -#define WMI_MIN_ROAM_CTRL_TYPE WMI_FORCE_ROAM -#define WMI_MAX_ROAM_CTRL_TYPE WMI_SET_LOWRSSI_SCAN_PARAMS - -/* - * ROAM MODES - */ - -typedef enum { - WMI_DEFAULT_ROAM_MODE = 1, /* RSSI based ROAM */ - WMI_HOST_BIAS_ROAM_MODE = 2, /* HOST BIAS based ROAM */ - WMI_LOCK_BSS_MODE = 3 /* Lock to the Current BSS - no Roam */ -} WMI_ROAM_MODE; - -/* - * BSS HOST BIAS INFO - */ - -typedef PREPACK struct { - u8 bssid[ATH_MAC_LEN]; - s8 bias; -} POSTPACK WMI_BSS_BIAS; - -typedef PREPACK struct { - u8 numBss; - WMI_BSS_BIAS bssBias[1]; -} POSTPACK WMI_BSS_BIAS_INFO; - -typedef PREPACK struct WMI_LOWRSSI_SCAN_PARAMS { - u16 lowrssi_scan_period; - s16 lowrssi_scan_threshold; - s16 lowrssi_roam_threshold; - u8 roam_rssi_floor; - u8 reserved[1]; /* For alignment */ -} POSTPACK WMI_LOWRSSI_SCAN_PARAMS; - -typedef PREPACK struct { - PREPACK union { - u8 bssid[ATH_MAC_LEN]; /* WMI_FORCE_ROAM */ - u8 roamMode; /* WMI_SET_ROAM_MODE */ - WMI_BSS_BIAS_INFO bssBiasInfo; /* WMI_SET_HOST_BIAS */ - WMI_LOWRSSI_SCAN_PARAMS lrScanParams; - } POSTPACK info; - u8 roamCtrlType ; -} POSTPACK WMI_SET_ROAM_CTRL_CMD; - -/* - * WMI_SET_BT_WLAN_CONN_PRECEDENCE_CMDID - */ -typedef enum { - BT_WLAN_CONN_PRECDENCE_WLAN=0, /* Default */ - BT_WLAN_CONN_PRECDENCE_PAL, -} BT_WLAN_CONN_PRECEDENCE; - -typedef PREPACK struct { - u8 precedence; -} POSTPACK WMI_SET_BT_WLAN_CONN_PRECEDENCE; - -/* - * WMI_ENABLE_RM_CMDID - */ -typedef PREPACK struct { - u32 enable_radio_measurements; -} POSTPACK WMI_ENABLE_RM_CMD; - -/* - * WMI_SET_MAX_OFFHOME_DURATION_CMDID - */ -typedef PREPACK struct { - u8 max_offhome_duration; -} POSTPACK WMI_SET_MAX_OFFHOME_DURATION_CMD; - -typedef PREPACK struct { - u32 frequency; - u8 threshold; -} POSTPACK WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD; -/*---------------------- BTCOEX RELATED -------------------------------------*/ -/*----------------------COMMON to AR6002 and AR6003 -------------------------*/ -typedef enum { - BT_STREAM_UNDEF = 0, - BT_STREAM_SCO, /* SCO stream */ - BT_STREAM_A2DP, /* A2DP stream */ - BT_STREAM_SCAN, /* BT Discovery or Page */ - BT_STREAM_ESCO, - BT_STREAM_MAX -} BT_STREAM_TYPE; - -typedef enum { - BT_PARAM_SCO_PSPOLL_LATENCY_ONE_FOURTH =1, - BT_PARAM_SCO_PSPOLL_LATENCY_HALF, - BT_PARAM_SCO_PSPOLL_LATENCY_THREE_FOURTH, -} BT_PARAMS_SCO_PSPOLL_LATENCY; - -typedef enum { - BT_PARAMS_SCO_STOMP_SCO_NEVER =1, - BT_PARAMS_SCO_STOMP_SCO_ALWAYS, - BT_PARAMS_SCO_STOMP_SCO_IN_LOWRSSI, -} BT_PARAMS_SCO_STOMP_RULES; - -typedef enum { - BT_STATUS_UNDEF = 0, - BT_STATUS_ON, - BT_STATUS_OFF, - BT_STATUS_MAX -} BT_STREAM_STATUS; - -typedef PREPACK struct { - u8 streamType; - u8 status; -} POSTPACK WMI_SET_BT_STATUS_CMD; - -typedef enum { - BT_ANT_TYPE_UNDEF=0, - BT_ANT_TYPE_DUAL, - BT_ANT_TYPE_SPLITTER, - BT_ANT_TYPE_SWITCH, - BT_ANT_TYPE_HIGH_ISO_DUAL -} BT_ANT_FRONTEND_CONFIG; - -typedef enum { - BT_COLOCATED_DEV_BTS4020=0, - BT_COLCATED_DEV_CSR , - BT_COLOCATED_DEV_VALKYRIE -} BT_COLOCATED_DEV_TYPE; - -/*********************** Applicable to AR6002 ONLY ******************************/ - -typedef enum { - BT_PARAM_SCO = 1, /* SCO stream parameters */ - BT_PARAM_A2DP , - BT_PARAM_ANTENNA_CONFIG, - BT_PARAM_COLOCATED_BT_DEVICE, - BT_PARAM_ACLCOEX, - BT_PARAM_11A_SEPARATE_ANT, - BT_PARAM_MAX -} BT_PARAM_TYPE; - - -#define BT_SCO_ALLOW_CLOSE_RANGE_OPT (1 << 0) -#define BT_SCO_FORCE_AWAKE_OPT (1 << 1) -#define BT_SCO_SET_RSSI_OVERRIDE(flags) ((flags) |= (1 << 2)) -#define BT_SCO_GET_RSSI_OVERRIDE(flags) (((flags) >> 2) & 0x1) -#define BT_SCO_SET_RTS_OVERRIDE(flags) ((flags) |= (1 << 3)) -#define BT_SCO_GET_RTS_OVERRIDE(flags) (((flags) >> 3) & 0x1) -#define BT_SCO_GET_MIN_LOW_RATE_CNT(flags) (((flags) >> 8) & 0xFF) -#define BT_SCO_GET_MAX_LOW_RATE_CNT(flags) (((flags) >> 16) & 0xFF) -#define BT_SCO_SET_MIN_LOW_RATE_CNT(flags,val) (flags) |= (((val) & 0xFF) << 8) -#define BT_SCO_SET_MAX_LOW_RATE_CNT(flags,val) (flags) |= (((val) & 0xFF) << 16) - -typedef PREPACK struct { - u32 numScoCyclesForceTrigger; /* Number SCO cycles after which - force a pspoll. default = 10 */ - u32 dataResponseTimeout; /* Timeout Waiting for Downlink pkt - in response for ps-poll, - default = 10 msecs */ - u32 stompScoRules; - u32 scoOptFlags; /* SCO Options Flags : - bits: meaning: - 0 Allow Close Range Optimization - 1 Force awake during close range - 2 If set use host supplied RSSI for OPT - 3 If set use host supplied RTS COUNT for OPT - 4..7 Unused - 8..15 Low Data Rate Min Cnt - 16..23 Low Data Rate Max Cnt - */ - - u8 stompDutyCyleVal; /* Sco cycles to limit ps-poll queuing - if stomped */ - u8 stompDutyCyleMaxVal; /*firm ware increases stomp duty cycle - gradually uptill this value on need basis*/ - u8 psPollLatencyFraction; /* Fraction of idle - period, within which - additional ps-polls - can be queued */ - u8 noSCOSlots; /* Number of SCO Tx/Rx slots. - HVx, EV3, 2EV3 = 2 */ - u8 noIdleSlots; /* Number of Bluetooth idle slots between - consecutive SCO Tx/Rx slots - HVx, EV3 = 4 - 2EV3 = 10 */ - u8 scoOptOffRssi;/*RSSI value below which we go to ps poll*/ - u8 scoOptOnRssi; /*RSSI value above which we reenter opt mode*/ - u8 scoOptRtsCount; -} POSTPACK BT_PARAMS_SCO; - -#define BT_A2DP_ALLOW_CLOSE_RANGE_OPT (1 << 0) -#define BT_A2DP_FORCE_AWAKE_OPT (1 << 1) -#define BT_A2DP_SET_RSSI_OVERRIDE(flags) ((flags) |= (1 << 2)) -#define BT_A2DP_GET_RSSI_OVERRIDE(flags) (((flags) >> 2) & 0x1) -#define BT_A2DP_SET_RTS_OVERRIDE(flags) ((flags) |= (1 << 3)) -#define BT_A2DP_GET_RTS_OVERRIDE(flags) (((flags) >> 3) & 0x1) -#define BT_A2DP_GET_MIN_LOW_RATE_CNT(flags) (((flags) >> 8) & 0xFF) -#define BT_A2DP_GET_MAX_LOW_RATE_CNT(flags) (((flags) >> 16) & 0xFF) -#define BT_A2DP_SET_MIN_LOW_RATE_CNT(flags,val) (flags) |= (((val) & 0xFF) << 8) -#define BT_A2DP_SET_MAX_LOW_RATE_CNT(flags,val) (flags) |= (((val) & 0xFF) << 16) - -typedef PREPACK struct { - u32 a2dpWlanUsageLimit; /* MAX time firmware uses the medium for - wlan, after it identifies the idle time - default (30 msecs) */ - u32 a2dpBurstCntMin; /* Minimum number of bluetooth data frames - to replenish Wlan Usage limit (default 3) */ - u32 a2dpDataRespTimeout; - u32 a2dpOptFlags; /* A2DP Option flags: - bits: meaning: - 0 Allow Close Range Optimization - 1 Force awake during close range - 2 If set use host supplied RSSI for OPT - 3 If set use host supplied RTS COUNT for OPT - 4..7 Unused - 8..15 Low Data Rate Min Cnt - 16..23 Low Data Rate Max Cnt - */ - u8 isCoLocatedBtRoleMaster; - u8 a2dpOptOffRssi;/*RSSI value below which we go to ps poll*/ - u8 a2dpOptOnRssi; /*RSSI value above which we reenter opt mode*/ - u8 a2dpOptRtsCount; -}POSTPACK BT_PARAMS_A2DP; - -/* During BT ftp/ BT OPP or any another data based acl profile on bluetooth - (non a2dp).*/ -typedef PREPACK struct { - u32 aclWlanMediumUsageTime; /* Wlan usage time during Acl (non-a2dp) - coexistence (default 30 msecs) */ - u32 aclBtMediumUsageTime; /* Bt usage time during acl coexistence - (default 30 msecs)*/ - u32 aclDataRespTimeout; - u32 aclDetectTimeout; /* ACL coexistence enabled if we get - 10 Pkts in X msec(default 100 msecs) */ - u32 aclmaxPktCnt; /* No of ACL pkts to receive before - enabling ACL coex */ - -}POSTPACK BT_PARAMS_ACLCOEX; - -typedef PREPACK struct { - PREPACK union { - BT_PARAMS_SCO scoParams; - BT_PARAMS_A2DP a2dpParams; - BT_PARAMS_ACLCOEX aclCoexParams; - u8 antType; /* 0 -Disabled (default) - 1 - BT_ANT_TYPE_DUAL - 2 - BT_ANT_TYPE_SPLITTER - 3 - BT_ANT_TYPE_SWITCH */ - u8 coLocatedBtDev; /* 0 - BT_COLOCATED_DEV_BTS4020 (default) - 1 - BT_COLCATED_DEV_CSR - 2 - BT_COLOCATED_DEV_VALKYRIe - */ - } POSTPACK info; - u8 paramType ; -} POSTPACK WMI_SET_BT_PARAMS_CMD; - -/************************ END AR6002 BTCOEX *******************************/ -/*-----------------------AR6003 BTCOEX -----------------------------------*/ - -/* ---------------WMI_SET_BTCOEX_FE_ANT_CMDID --------------------------*/ -/* Indicates front end antenna configuration. This command needs to be issued - * right after initialization and after WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMDID. - * AR6003 enables coexistence and antenna switching based on the configuration. - */ -typedef enum { - WMI_BTCOEX_NOT_ENABLED = 0, - WMI_BTCOEX_FE_ANT_SINGLE =1, - WMI_BTCOEX_FE_ANT_DUAL=2, - WMI_BTCOEX_FE_ANT_DUAL_HIGH_ISO=3, - WMI_BTCOEX_FE_ANT_TYPE_MAX -}WMI_BTCOEX_FE_ANT_TYPE; - -typedef PREPACK struct { - u8 btcoexFeAntType; /* 1 - WMI_BTCOEX_FE_ANT_SINGLE for single antenna front end - 2 - WMI_BTCOEX_FE_ANT_DUAL for dual antenna front end - (for isolations less 35dB, for higher isolation there - is not need to pass this command). - (not implemented) - */ -}POSTPACK WMI_SET_BTCOEX_FE_ANT_CMD; - -/* -------------WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMDID ----------------*/ -/* Indicate the bluetooth chip to the firmware. Firmware can have different algorithm based - * bluetooth chip type.Based on bluetooth device, different coexistence protocol would be used. - */ -typedef PREPACK struct { - u8 btcoexCoLocatedBTdev; /*1 - Qcom BT (3 -wire PTA) - 2 - CSR BT (3 wire PTA) - 3 - Atheros 3001 BT (3 wire PTA) - 4 - STE bluetooth (4-wire ePTA) - 5 - Atheros 3002 BT (4-wire MCI) - defaults= 3 (Atheros 3001 BT ) - */ -}POSTPACK WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD; - -/* -------------WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMDID ------------*/ -/* Configuration parameters during bluetooth inquiry and page. Page configuration - * is applicable only on interfaces which can distinguish page (applicable only for ePTA - - * STE bluetooth). - * Bluetooth inquiry start and end is indicated via WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID. - * During this the station will be power-save mode. - */ -typedef PREPACK struct { - u32 btInquiryDataFetchFrequency;/* The frequency of querying the AP for data - (via pspoll) is configured by this parameter. - "default = 10 ms" */ - - u32 protectBmissDurPostBtInquiry;/* The firmware will continue to be in inquiry state - for configured duration, after inquiry completion - . This is to ensure other bluetooth transactions - (RDP, SDP profiles, link key exchange ...etc) - goes through smoothly without wifi stomping. - default = 10 secs*/ - - u32 maxpageStomp; /*Applicable only for STE-BT interface. Currently not - used */ - u32 btInquiryPageFlag; /* Not used */ -}POSTPACK WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD; - -/*---------------------WMI_SET_BTCOEX_SCO_CONFIG_CMDID ---------------*/ -/* Configure SCO parameters. These parameters would be used whenever firmware is indicated - * of (e)SCO profile on bluetooth ( via WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID). - * Configration of BTCOEX_SCO_CONFIG data structure are common configuration and applies - * ps-poll mode and opt mode. - * Ps-poll Mode - Station is in power-save and retrieves downlink data between sco gaps. - * Opt Mode - station is in awake state and access point can send data to station any time. - * BTCOEX_PSPOLLMODE_SCO_CONFIG - Configuration applied only during ps-poll mode. - * BTCOEX_OPTMODE_SCO_CONFIG - Configuration applied only during opt mode. - */ -#define WMI_SCO_CONFIG_FLAG_ALLOW_OPTIMIZATION (1 << 0) -#define WMI_SCO_CONFIG_FLAG_IS_EDR_CAPABLE (1 << 1) -#define WMI_SCO_CONFIG_FLAG_IS_BT_MASTER (1 << 2) -#define WMI_SCO_CONFIG_FLAG_FW_DETECT_OF_PER (1 << 3) -typedef PREPACK struct { - u32 scoSlots; /* Number of SCO Tx/Rx slots. - HVx, EV3, 2EV3 = 2 */ - u32 scoIdleSlots; /* Number of Bluetooth idle slots between - consecutive SCO Tx/Rx slots - HVx, EV3 = 4 - 2EV3 = 10 - */ - u32 scoFlags; /* SCO Options Flags : - bits: meaning: - 0 Allow Close Range Optimization - 1 Is EDR capable or Not - 2 IS Co-located Bt role Master - 3 Firmware determines the periodicity of SCO. - */ - - u32 linkId; /* applicable to STE-BT - not used */ -}POSTPACK BTCOEX_SCO_CONFIG; - -typedef PREPACK struct { - u32 scoCyclesForceTrigger; /* Number SCO cycles after which - force a pspoll. default = 10 */ - u32 scoDataResponseTimeout; /* Timeout Waiting for Downlink pkt - in response for ps-poll, - default = 20 msecs */ - - u32 scoStompDutyCyleVal; /* not implemented */ - - u32 scoStompDutyCyleMaxVal; /*Not implemented */ - - u32 scoPsPollLatencyFraction; /* Fraction of idle - period, within which - additional ps-polls can be queued - 1 - 1/4 of idle duration - 2 - 1/2 of idle duration - 3 - 3/4 of idle duration - default =2 (1/2) - */ -}POSTPACK BTCOEX_PSPOLLMODE_SCO_CONFIG; - -typedef PREPACK struct { - u32 scoStompCntIn100ms;/*max number of SCO stomp in 100ms allowed in - opt mode. If exceeds the configured value, - switch to ps-poll mode - default = 3 */ - - u32 scoContStompMax; /* max number of continuous stomp allowed in opt mode. - if exceeded switch to pspoll mode - default = 3 */ - - u32 scoMinlowRateMbps; /* Low rate threshold */ - - u32 scoLowRateCnt; /* number of low rate pkts (< scoMinlowRateMbps) allowed in 100 ms. - If exceeded switch/stay to ps-poll mode, lower stay in opt mode. - default = 36 - */ - - u32 scoHighPktRatio; /*(Total Rx pkts in 100 ms + 1)/ - ((Total tx pkts in 100 ms - No of high rate pkts in 100 ms) + 1) in 100 ms, - if exceeded switch/stay in opt mode and if lower switch/stay in pspoll mode. - default = 5 (80% of high rates) - */ - - u32 scoMaxAggrSize; /* Max number of Rx subframes allowed in this mode. (Firmware re-negogiates - max number of aggregates if it was negogiated to higher value - default = 1 - Recommended value Basic rate headsets = 1, EDR (2-EV3) =4. - */ -}POSTPACK BTCOEX_OPTMODE_SCO_CONFIG; - -typedef PREPACK struct { - u32 scanInterval; - u32 maxScanStompCnt; -}POSTPACK BTCOEX_WLANSCAN_SCO_CONFIG; - -typedef PREPACK struct { - BTCOEX_SCO_CONFIG scoConfig; - BTCOEX_PSPOLLMODE_SCO_CONFIG scoPspollConfig; - BTCOEX_OPTMODE_SCO_CONFIG scoOptModeConfig; - BTCOEX_WLANSCAN_SCO_CONFIG scoWlanScanConfig; -}POSTPACK WMI_SET_BTCOEX_SCO_CONFIG_CMD; - -/* ------------------WMI_SET_BTCOEX_A2DP_CONFIG_CMDID -------------------*/ -/* Configure A2DP profile parameters. These parameters would be used whenver firmware is indicated - * of A2DP profile on bluetooth ( via WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID). - * Configuration of BTCOEX_A2DP_CONFIG data structure are common configuration and applies to - * ps-poll mode and opt mode. - * Ps-poll Mode - Station is in power-save and retrieves downlink data between a2dp data bursts. - * Opt Mode - station is in power save during a2dp bursts and awake in the gaps. - * BTCOEX_PSPOLLMODE_A2DP_CONFIG - Configuration applied only during ps-poll mode. - * BTCOEX_OPTMODE_A2DP_CONFIG - Configuration applied only during opt mode. - */ - -#define WMI_A2DP_CONFIG_FLAG_ALLOW_OPTIMIZATION (1 << 0) -#define WMI_A2DP_CONFIG_FLAG_IS_EDR_CAPABLE (1 << 1) -#define WMI_A2DP_CONFIG_FLAG_IS_BT_ROLE_MASTER (1 << 2) -#define WMI_A2DP_CONFIG_FLAG_IS_A2DP_HIGH_PRI (1 << 3) -#define WMI_A2DP_CONFIG_FLAG_FIND_BT_ROLE (1 << 4) - -typedef PREPACK struct { - u32 a2dpFlags; /* A2DP Option flags: - bits: meaning: - 0 Allow Close Range Optimization - 1 IS EDR capable - 2 IS Co-located Bt role Master - 3 a2dp traffic is high priority - 4 Fw detect the role of bluetooth. - */ - u32 linkId; /* Applicable only to STE-BT - not used */ - -}POSTPACK BTCOEX_A2DP_CONFIG; - -typedef PREPACK struct { - u32 a2dpWlanMaxDur; /* MAX time firmware uses the medium for - wlan, after it identifies the idle time - default (30 msecs) */ - - u32 a2dpMinBurstCnt; /* Minimum number of bluetooth data frames - to replenish Wlan Usage limit (default 3) */ - - u32 a2dpDataRespTimeout; /* Max duration firmware waits for downlink - by stomping on bluetooth - after ps-poll is acknowledged. - default = 20 ms - */ -}POSTPACK BTCOEX_PSPOLLMODE_A2DP_CONFIG; - -typedef PREPACK struct { - u32 a2dpMinlowRateMbps; /* Low rate threshold */ - - u32 a2dpLowRateCnt; /* number of low rate pkts (< a2dpMinlowRateMbps) allowed in 100 ms. - If exceeded switch/stay to ps-poll mode, lower stay in opt mode. - default = 36 - */ - - u32 a2dpHighPktRatio; /*(Total Rx pkts in 100 ms + 1)/ - ((Total tx pkts in 100 ms - No of high rate pkts in 100 ms) + 1) in 100 ms, - if exceeded switch/stay in opt mode and if lower switch/stay in pspoll mode. - default = 5 (80% of high rates) - */ - - u32 a2dpMaxAggrSize; /* Max number of Rx subframes allowed in this mode. (Firmware re-negogiates - max number of aggregates if it was negogiated to higher value - default = 1 - Recommended value Basic rate headsets = 1, EDR (2-EV3) =8. - */ - u32 a2dpPktStompCnt; /*number of a2dp pkts that can be stomped per burst. - default = 6*/ - -}POSTPACK BTCOEX_OPTMODE_A2DP_CONFIG; - -typedef PREPACK struct { - BTCOEX_A2DP_CONFIG a2dpConfig; - BTCOEX_PSPOLLMODE_A2DP_CONFIG a2dppspollConfig; - BTCOEX_OPTMODE_A2DP_CONFIG a2dpOptConfig; -}POSTPACK WMI_SET_BTCOEX_A2DP_CONFIG_CMD; - -/*------------ WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMDID---------------------*/ -/* Configure non-A2dp ACL profile parameters.The starts of ACL profile can either be - * indicated via WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID orenabled via firmware detection - * which is configured via "aclCoexFlags". - * Configration of BTCOEX_ACLCOEX_CONFIG data structure are common configuration and applies - * ps-poll mode and opt mode. - * Ps-poll Mode - Station is in power-save and retrieves downlink data during wlan medium. - * Opt Mode - station is in power save during bluetooth medium time and awake during wlan duration. - * (Not implemented yet) - * - * BTCOEX_PSPOLLMODE_ACLCOEX_CONFIG - Configuration applied only during ps-poll mode. - * BTCOEX_OPTMODE_ACLCOEX_CONFIG - Configuration applied only during opt mode. - */ - -#define WMI_ACLCOEX_FLAGS_ALLOW_OPTIMIZATION (1 << 0) -#define WMI_ACLCOEX_FLAGS_DISABLE_FW_DETECTION (1 << 1) - -typedef PREPACK struct { - u32 aclWlanMediumDur; /* Wlan usage time during Acl (non-a2dp) - coexistence (default 30 msecs) - */ - - u32 aclBtMediumDur; /* Bt usage time during acl coexistence - (default 30 msecs) - */ - - u32 aclDetectTimeout; /* BT activity observation time limit. - In this time duration, number of bt pkts are counted. - If the Cnt reaches "aclPktCntLowerLimit" value - for "aclIterToEnableCoex" iteration continuously, - firmware gets into ACL coexistence mode. - Similarly, if bt traffic count during ACL coexistence - has not reached "aclPktCntLowerLimit" continuously - for "aclIterToEnableCoex", then ACL coexistence is - disabled. - -default 100 msecs - */ - - u32 aclPktCntLowerLimit; /* Acl Pkt Cnt to be received in duration of - "aclDetectTimeout" for - "aclIterForEnDis" times to enabling ACL coex. - Similar logic is used to disable acl coexistence. - (If "aclPktCntLowerLimit" cnt of acl pkts - are not seen by the for "aclIterForEnDis" - then acl coexistence is disabled). - default = 10 - */ - - u32 aclIterForEnDis; /* number of Iteration of "aclPktCntLowerLimit" for Enabling and - Disabling Acl Coexistence. - default = 3 - */ - - u32 aclPktCntUpperLimit; /* This is upperBound limit, if there is more than - "aclPktCntUpperLimit" seen in "aclDetectTimeout", - ACL coexistence is enabled right away. - - default 15*/ - - u32 aclCoexFlags; /* A2DP Option flags: - bits: meaning: - 0 Allow Close Range Optimization - 1 disable Firmware detection - (Currently supported configuration is aclCoexFlags =0) - */ - u32 linkId; /* Applicable only for STE-BT - not used */ - -}POSTPACK BTCOEX_ACLCOEX_CONFIG; - -typedef PREPACK struct { - u32 aclDataRespTimeout; /* Max duration firmware waits for downlink - by stomping on bluetooth - after ps-poll is acknowledged. - default = 20 ms */ - -}POSTPACK BTCOEX_PSPOLLMODE_ACLCOEX_CONFIG; - - -/* Not implemented yet*/ -typedef PREPACK struct { - u32 aclCoexMinlowRateMbps; - u32 aclCoexLowRateCnt; - u32 aclCoexHighPktRatio; - u32 aclCoexMaxAggrSize; - u32 aclPktStompCnt; -}POSTPACK BTCOEX_OPTMODE_ACLCOEX_CONFIG; - -typedef PREPACK struct { - BTCOEX_ACLCOEX_CONFIG aclCoexConfig; - BTCOEX_PSPOLLMODE_ACLCOEX_CONFIG aclCoexPspollConfig; - BTCOEX_OPTMODE_ACLCOEX_CONFIG aclCoexOptConfig; -}POSTPACK WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD; - -/* -----------WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID ------------------*/ -typedef enum { - WMI_BTCOEX_BT_PROFILE_SCO =1, - WMI_BTCOEX_BT_PROFILE_A2DP, - WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE, - WMI_BTCOEX_BT_PROFILE_ACLCOEX, -}WMI_BTCOEX_BT_PROFILE; - -typedef PREPACK struct { - u32 btProfileType; - u32 btOperatingStatus; - u32 btLinkId; -}WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD; - -/*--------------------- WMI_SET_BTCOEX_DEBUG_CMDID ---------------------*/ -/* Used for firmware development and debugging */ -typedef PREPACK struct { - u32 btcoexDbgParam1; - u32 btcoexDbgParam2; - u32 btcoexDbgParam3; - u32 btcoexDbgParam4; - u32 btcoexDbgParam5; -}WMI_SET_BTCOEX_DEBUG_CMD; - -/*---------------------WMI_GET_BTCOEX_CONFIG_CMDID --------------------- */ -/* Command to firmware to get configuration parameters of the bt profile - * reported via WMI_BTCOEX_CONFIG_EVENTID */ -typedef PREPACK struct { - u32 btProfileType; /* 1 - SCO - 2 - A2DP - 3 - INQUIRY_PAGE - 4 - ACLCOEX - */ - u32 linkId; /* not used */ -}WMI_GET_BTCOEX_CONFIG_CMD; - -/*------------------WMI_REPORT_BTCOEX_CONFIG_EVENTID------------------- */ -/* Event from firmware to host, sent in response to WMI_GET_BTCOEX_CONFIG_CMDID - * */ -typedef PREPACK struct { - u32 btProfileType; - u32 linkId; /* not used */ - PREPACK union { - WMI_SET_BTCOEX_SCO_CONFIG_CMD scoConfigCmd; - WMI_SET_BTCOEX_A2DP_CONFIG_CMD a2dpConfigCmd; - WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD aclcoexConfig; - WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD btinquiryPageConfigCmd; - } POSTPACK info; -} POSTPACK WMI_BTCOEX_CONFIG_EVENT; - -/*------------- WMI_REPORT_BTCOEX_BTCOEX_STATS_EVENTID--------------------*/ -/* Used for firmware development and debugging*/ -typedef PREPACK struct { - u32 highRatePktCnt; - u32 firstBmissCnt; - u32 psPollFailureCnt; - u32 nullFrameFailureCnt; - u32 optModeTransitionCnt; -}BTCOEX_GENERAL_STATS; - -typedef PREPACK struct { - u32 scoStompCntAvg; - u32 scoStompIn100ms; - u32 scoMaxContStomp; - u32 scoAvgNoRetries; - u32 scoMaxNoRetriesIn100ms; -}BTCOEX_SCO_STATS; - -typedef PREPACK struct { - u32 a2dpBurstCnt; - u32 a2dpMaxBurstCnt; - u32 a2dpAvgIdletimeIn100ms; - u32 a2dpAvgStompCnt; -}BTCOEX_A2DP_STATS; - -typedef PREPACK struct { - u32 aclPktCntInBtTime; - u32 aclStompCntInWlanTime; - u32 aclPktCntIn100ms; -}BTCOEX_ACLCOEX_STATS; - -typedef PREPACK struct { - BTCOEX_GENERAL_STATS coexStats; - BTCOEX_SCO_STATS scoStats; - BTCOEX_A2DP_STATS a2dpStats; - BTCOEX_ACLCOEX_STATS aclCoexStats; -}WMI_BTCOEX_STATS_EVENT; - - -/*--------------------------END OF BTCOEX -------------------------------------*/ -typedef PREPACK struct { - u32 sleepState; -}WMI_REPORT_SLEEP_STATE_EVENT; - -typedef enum { - WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP =0, - WMI_REPORT_SLEEP_STATUS_IS_AWAKE -} WMI_REPORT_SLEEP_STATUS; -typedef enum { - DISCONN_EVT_IN_RECONN = 0, /* default */ - NO_DISCONN_EVT_IN_RECONN -} TARGET_EVENT_REPORT_CONFIG; - -typedef PREPACK struct { - u32 evtConfig; -} POSTPACK WMI_SET_TARGET_EVENT_REPORT_CMD; - - -typedef PREPACK struct { - u16 cmd_buf_sz; /* HCI cmd buffer size */ - u8 buf[1]; /* Absolute HCI cmd */ -} POSTPACK WMI_HCI_CMD; - -/* - * Command Replies - */ - -/* - * WMI_GET_CHANNEL_LIST_CMDID reply - */ -typedef PREPACK struct { - u8 reserved1; - u8 numChannels; /* number of channels in reply */ - u16 channelList[1]; /* channel in Mhz */ -} POSTPACK WMI_CHANNEL_LIST_REPLY; - -typedef enum { - A_SUCCEEDED = 0, - A_FAILED_DELETE_STREAM_DOESNOT_EXIST=250, - A_SUCCEEDED_MODIFY_STREAM=251, - A_FAILED_INVALID_STREAM = 252, - A_FAILED_MAX_THINSTREAMS = 253, - A_FAILED_CREATE_REMOVE_PSTREAM_FIRST = 254, -} PSTREAM_REPLY_STATUS; - -typedef PREPACK struct { - u8 status; /* PSTREAM_REPLY_STATUS */ - u8 txQueueNumber; - u8 rxQueueNumber; - u8 trafficClass; - u8 trafficDirection; /* DIR_TYPE */ -} POSTPACK WMI_CRE_PRIORITY_STREAM_REPLY; - -typedef PREPACK struct { - u8 status; /* PSTREAM_REPLY_STATUS */ - u8 txQueueNumber; - u8 rxQueueNumber; - u8 trafficDirection; /* DIR_TYPE */ - u8 trafficClass; -} POSTPACK WMI_DEL_PRIORITY_STREAM_REPLY; - -/* - * List of Events (target to host) - */ -typedef enum { - WMI_READY_EVENTID = 0x1001, - WMI_CONNECT_EVENTID, - WMI_DISCONNECT_EVENTID, - WMI_BSSINFO_EVENTID, - WMI_CMDERROR_EVENTID, - WMI_REGDOMAIN_EVENTID, - WMI_PSTREAM_TIMEOUT_EVENTID, - WMI_NEIGHBOR_REPORT_EVENTID, - WMI_TKIP_MICERR_EVENTID, - WMI_SCAN_COMPLETE_EVENTID, /* 0x100a */ - WMI_REPORT_STATISTICS_EVENTID, - WMI_RSSI_THRESHOLD_EVENTID, - WMI_ERROR_REPORT_EVENTID, - WMI_OPT_RX_FRAME_EVENTID, - WMI_REPORT_ROAM_TBL_EVENTID, - WMI_EXTENSION_EVENTID, - WMI_CAC_EVENTID, - WMI_SNR_THRESHOLD_EVENTID, - WMI_LQ_THRESHOLD_EVENTID, - WMI_TX_RETRY_ERR_EVENTID, /* 0x1014 */ - WMI_REPORT_ROAM_DATA_EVENTID, - WMI_TEST_EVENTID, - WMI_APLIST_EVENTID, - WMI_GET_WOW_LIST_EVENTID, - WMI_GET_PMKID_LIST_EVENTID, - WMI_CHANNEL_CHANGE_EVENTID, - WMI_PEER_NODE_EVENTID, - WMI_PSPOLL_EVENTID, - WMI_DTIMEXPIRY_EVENTID, - WMI_WLAN_VERSION_EVENTID, - WMI_SET_PARAMS_REPLY_EVENTID, - WMI_ADDBA_REQ_EVENTID, /*0x1020 */ - WMI_ADDBA_RESP_EVENTID, - WMI_DELBA_REQ_EVENTID, - WMI_TX_COMPLETE_EVENTID, - WMI_HCI_EVENT_EVENTID, - WMI_ACL_DATA_EVENTID, - WMI_REPORT_SLEEP_STATE_EVENTID, -#ifdef WAPI_ENABLE - WMI_WAPI_REKEY_EVENTID, -#endif - WMI_REPORT_BTCOEX_STATS_EVENTID, - WMI_REPORT_BTCOEX_CONFIG_EVENTID, - WMI_GET_PMK_EVENTID, - - /* DFS Events */ - WMI_DFS_HOST_ATTACH_EVENTID, - WMI_DFS_HOST_INIT_EVENTID, - WMI_DFS_RESET_DELAYLINES_EVENTID, - WMI_DFS_RESET_RADARQ_EVENTID, - WMI_DFS_RESET_AR_EVENTID, - WMI_DFS_RESET_ARQ_EVENTID, - WMI_DFS_SET_DUR_MULTIPLIER_EVENTID, - WMI_DFS_SET_BANGRADAR_EVENTID, - WMI_DFS_SET_DEBUGLEVEL_EVENTID, - WMI_DFS_PHYERR_EVENTID, - /* CCX Evants */ - WMI_CCX_RM_STATUS_EVENTID, - - /* P2P Events */ - WMI_P2P_GO_NEG_RESULT_EVENTID, - - WMI_WAC_SCAN_DONE_EVENTID, - WMI_WAC_REPORT_BSS_EVENTID, - WMI_WAC_START_WPS_EVENTID, - WMI_WAC_CTRL_REQ_REPLY_EVENTID, - - /* RFKILL Events */ - WMI_RFKILL_STATE_CHANGE_EVENTID, - WMI_RFKILL_GET_MODE_CMD_EVENTID, - WMI_THIN_RESERVED_START_EVENTID = 0x8000, - - /* - * Events in this range are reserved for thinmode - * See wmi_thin.h for actual definitions - */ - WMI_THIN_RESERVED_END_EVENTID = 0x8fff, - - WMI_SET_CHANNEL_EVENTID, - WMI_ASSOC_REQ_EVENTID, - - /* generic ACS event */ - WMI_ACS_EVENTID, - WMI_REPORT_WMM_PARAMS_EVENTID -} WMI_EVENT_ID; - - -typedef enum { - WMI_11A_CAPABILITY = 1, - WMI_11G_CAPABILITY = 2, - WMI_11AG_CAPABILITY = 3, - WMI_11NA_CAPABILITY = 4, - WMI_11NG_CAPABILITY = 5, - WMI_11NAG_CAPABILITY = 6, - // END CAPABILITY - WMI_11N_CAPABILITY_OFFSET = (WMI_11NA_CAPABILITY - WMI_11A_CAPABILITY), -} WMI_PHY_CAPABILITY; - -typedef PREPACK struct { - u8 macaddr[ATH_MAC_LEN]; - u8 phyCapability; /* WMI_PHY_CAPABILITY */ -} POSTPACK WMI_READY_EVENT_1; - -typedef PREPACK struct { - u32 sw_version; - u32 abi_version; - u8 macaddr[ATH_MAC_LEN]; - u8 phyCapability; /* WMI_PHY_CAPABILITY */ -} POSTPACK WMI_READY_EVENT_2; - -#if defined(ATH_TARGET) -#ifdef AR6002_REV2 -#define WMI_READY_EVENT WMI_READY_EVENT_1 /* AR6002_REV2 target code */ -#else -#define WMI_READY_EVENT WMI_READY_EVENT_2 /* AR6001, AR6002_REV4, AR6002_REV5 */ -#endif -#else -#define WMI_READY_EVENT WMI_READY_EVENT_2 /* host code */ -#endif - - -/* - * Connect Event - */ -typedef PREPACK struct { - u16 channel; - u8 bssid[ATH_MAC_LEN]; - u16 listenInterval; - u16 beaconInterval; - u32 networkType; - u8 beaconIeLen; - u8 assocReqLen; - u8 assocRespLen; - u8 assocInfo[1]; -} POSTPACK WMI_CONNECT_EVENT; - -/* - * Disconnect Event - */ -typedef enum { - NO_NETWORK_AVAIL = 0x01, - LOST_LINK = 0x02, /* bmiss */ - DISCONNECT_CMD = 0x03, - BSS_DISCONNECTED = 0x04, - AUTH_FAILED = 0x05, - ASSOC_FAILED = 0x06, - NO_RESOURCES_AVAIL = 0x07, - CSERV_DISCONNECT = 0x08, - INVALID_PROFILE = 0x0a, - DOT11H_CHANNEL_SWITCH = 0x0b, - PROFILE_MISMATCH = 0x0c, - CONNECTION_EVICTED = 0x0d, - IBSS_MERGE = 0xe, -} WMI_DISCONNECT_REASON; - -typedef PREPACK struct { - u16 protocolReasonStatus; /* reason code, see 802.11 spec. */ - u8 bssid[ATH_MAC_LEN]; /* set if known */ - u8 disconnectReason ; /* see WMI_DISCONNECT_REASON */ - u8 assocRespLen; - u8 assocInfo[1]; -} POSTPACK WMI_DISCONNECT_EVENT; - -/* - * BSS Info Event. - * Mechanism used to inform host of the presence and characteristic of - * wireless networks present. Consists of bss info header followed by - * the beacon or probe-response frame body. The 802.11 header is not included. - */ -typedef enum { - BEACON_FTYPE = 0x1, - PROBERESP_FTYPE, - ACTION_MGMT_FTYPE, - PROBEREQ_FTYPE, -} WMI_BI_FTYPE; - -enum { - BSS_ELEMID_CHANSWITCH = 0x01, - BSS_ELEMID_ATHEROS = 0x02, -}; - -typedef PREPACK struct { - u16 channel; - u8 frameType; /* see WMI_BI_FTYPE */ - u8 snr; - s16 rssi; - u8 bssid[ATH_MAC_LEN]; - u32 ieMask; -} POSTPACK WMI_BSS_INFO_HDR; - -/* - * BSS INFO HDR version 2.0 - * With 6 bytes HTC header and 6 bytes of WMI header - * WMI_BSS_INFO_HDR cannot be accommodated in the removed 802.11 management - * header space. - * - Reduce the ieMask to 2 bytes as only two bit flags are used - * - Remove rssi and compute it on the host. rssi = snr - 95 - */ -typedef PREPACK struct { - u16 channel; - u8 frameType; /* see WMI_BI_FTYPE */ - u8 snr; - u8 bssid[ATH_MAC_LEN]; - u16 ieMask; -} POSTPACK WMI_BSS_INFO_HDR2; - -/* - * Command Error Event - */ -typedef enum { - INVALID_PARAM = 0x01, - ILLEGAL_STATE = 0x02, - INTERNAL_ERROR = 0x03, -} WMI_ERROR_CODE; - -typedef PREPACK struct { - u16 commandId; - u8 errorCode; -} POSTPACK WMI_CMD_ERROR_EVENT; - -/* - * New Regulatory Domain Event - */ -typedef PREPACK struct { - u32 regDomain; -} POSTPACK WMI_REG_DOMAIN_EVENT; - -typedef PREPACK struct { - u8 txQueueNumber; - u8 rxQueueNumber; - u8 trafficDirection; - u8 trafficClass; -} POSTPACK WMI_PSTREAM_TIMEOUT_EVENT; - -typedef PREPACK struct { - u8 reserve1; - u8 reserve2; - u8 reserve3; - u8 trafficClass; -} POSTPACK WMI_ACM_REJECT_EVENT; - -/* - * The WMI_NEIGHBOR_REPORT Event is generated by the target to inform - * the host of BSS's it has found that matches the current profile. - * It can be used by the host to cache PMKs and/to initiate pre-authentication - * if the BSS supports it. The first bssid is always the current associated - * BSS. - * The bssid and bssFlags information repeats according to the number - * or APs reported. - */ -typedef enum { - WMI_DEFAULT_BSS_FLAGS = 0x00, - WMI_PREAUTH_CAPABLE_BSS = 0x01, - WMI_PMKID_VALID_BSS = 0x02, -} WMI_BSS_FLAGS; - -typedef PREPACK struct { - u8 bssid[ATH_MAC_LEN]; - u8 bssFlags; /* see WMI_BSS_FLAGS */ -} POSTPACK WMI_NEIGHBOR_INFO; - -typedef PREPACK struct { - s8 numberOfAps; - WMI_NEIGHBOR_INFO neighbor[1]; -} POSTPACK WMI_NEIGHBOR_REPORT_EVENT; - -/* - * TKIP MIC Error Event - */ -typedef PREPACK struct { - u8 keyid; - u8 ismcast; -} POSTPACK WMI_TKIP_MICERR_EVENT; - -/* - * WMI_SCAN_COMPLETE_EVENTID - no parameters (old), staus parameter (new) - */ -typedef PREPACK struct { - s32 status; -} POSTPACK WMI_SCAN_COMPLETE_EVENT; - -#define MAX_OPT_DATA_LEN 1400 - -/* - * WMI_SET_ADHOC_BSSID_CMDID - */ -typedef PREPACK struct { - u8 bssid[ATH_MAC_LEN]; -} POSTPACK WMI_SET_ADHOC_BSSID_CMD; - -/* - * WMI_SET_OPT_MODE_CMDID - */ -typedef enum { - SPECIAL_OFF, - SPECIAL_ON, -} OPT_MODE_TYPE; - -typedef PREPACK struct { - u8 optMode; -} POSTPACK WMI_SET_OPT_MODE_CMD; - -/* - * WMI_TX_OPT_FRAME_CMDID - */ -typedef enum { - OPT_PROBE_REQ = 0x01, - OPT_PROBE_RESP = 0x02, - OPT_CPPP_START = 0x03, - OPT_CPPP_STOP = 0x04, -} WMI_OPT_FTYPE; - -typedef PREPACK struct { - u16 optIEDataLen; - u8 frmType; - u8 dstAddr[ATH_MAC_LEN]; - u8 bssid[ATH_MAC_LEN]; - u8 reserved; /* For alignment */ - u8 optIEData[1]; -} POSTPACK WMI_OPT_TX_FRAME_CMD; - -/* - * Special frame receive Event. - * Mechanism used to inform host of the receiption of the special frames. - * Consists of special frame info header followed by special frame body. - * The 802.11 header is not included. - */ -typedef PREPACK struct { - u16 channel; - u8 frameType; /* see WMI_OPT_FTYPE */ - s8 snr; - u8 srcAddr[ATH_MAC_LEN]; - u8 bssid[ATH_MAC_LEN]; -} POSTPACK WMI_OPT_RX_INFO_HDR; - -/* - * Reporting statistics. - */ -typedef PREPACK struct { - u32 tx_packets; - u32 tx_bytes; - u32 tx_unicast_pkts; - u32 tx_unicast_bytes; - u32 tx_multicast_pkts; - u32 tx_multicast_bytes; - u32 tx_broadcast_pkts; - u32 tx_broadcast_bytes; - u32 tx_rts_success_cnt; - u32 tx_packet_per_ac[4]; - u32 tx_errors_per_ac[4]; - - u32 tx_errors; - u32 tx_failed_cnt; - u32 tx_retry_cnt; - u32 tx_mult_retry_cnt; - u32 tx_rts_fail_cnt; - s32 tx_unicast_rate; -}POSTPACK tx_stats_t; - -typedef PREPACK struct { - u32 rx_packets; - u32 rx_bytes; - u32 rx_unicast_pkts; - u32 rx_unicast_bytes; - u32 rx_multicast_pkts; - u32 rx_multicast_bytes; - u32 rx_broadcast_pkts; - u32 rx_broadcast_bytes; - u32 rx_fragment_pkt; - - u32 rx_errors; - u32 rx_crcerr; - u32 rx_key_cache_miss; - u32 rx_decrypt_err; - u32 rx_duplicate_frames; - s32 rx_unicast_rate; -}POSTPACK rx_stats_t; - -typedef PREPACK struct { - u32 tkip_local_mic_failure; - u32 tkip_counter_measures_invoked; - u32 tkip_replays; - u32 tkip_format_errors; - u32 ccmp_format_errors; - u32 ccmp_replays; -}POSTPACK tkip_ccmp_stats_t; - -typedef PREPACK struct { - u32 power_save_failure_cnt; - u16 stop_tx_failure_cnt; - u16 atim_tx_failure_cnt; - u16 atim_rx_failure_cnt; - u16 bcn_rx_failure_cnt; -}POSTPACK pm_stats_t; - -typedef PREPACK struct { - u32 cs_bmiss_cnt; - u32 cs_lowRssi_cnt; - u16 cs_connect_cnt; - u16 cs_disconnect_cnt; - s16 cs_aveBeacon_rssi; - u16 cs_roam_count; - s16 cs_rssi; - u8 cs_snr; - u8 cs_aveBeacon_snr; - u8 cs_lastRoam_msec; -} POSTPACK cserv_stats_t; - -typedef PREPACK struct { - tx_stats_t tx_stats; - rx_stats_t rx_stats; - tkip_ccmp_stats_t tkipCcmpStats; -}POSTPACK wlan_net_stats_t; - -typedef PREPACK struct { - u32 arp_received; - u32 arp_matched; - u32 arp_replied; -} POSTPACK arp_stats_t; - -typedef PREPACK struct { - u32 wow_num_pkts_dropped; - u16 wow_num_events_discarded; - u8 wow_num_host_pkt_wakeups; - u8 wow_num_host_event_wakeups; -} POSTPACK wlan_wow_stats_t; - -typedef PREPACK struct { - u32 lqVal; - s32 noise_floor_calibation; - pm_stats_t pmStats; - wlan_net_stats_t txrxStats; - wlan_wow_stats_t wowStats; - arp_stats_t arpStats; - cserv_stats_t cservStats; -} POSTPACK WMI_TARGET_STATS; - -/* - * WMI_RSSI_THRESHOLD_EVENTID. - * Indicate the RSSI events to host. Events are indicated when we breach a - * thresold value. - */ -typedef enum{ - WMI_RSSI_THRESHOLD1_ABOVE = 0, - WMI_RSSI_THRESHOLD2_ABOVE, - WMI_RSSI_THRESHOLD3_ABOVE, - WMI_RSSI_THRESHOLD4_ABOVE, - WMI_RSSI_THRESHOLD5_ABOVE, - WMI_RSSI_THRESHOLD6_ABOVE, - WMI_RSSI_THRESHOLD1_BELOW, - WMI_RSSI_THRESHOLD2_BELOW, - WMI_RSSI_THRESHOLD3_BELOW, - WMI_RSSI_THRESHOLD4_BELOW, - WMI_RSSI_THRESHOLD5_BELOW, - WMI_RSSI_THRESHOLD6_BELOW -}WMI_RSSI_THRESHOLD_VAL; - -typedef PREPACK struct { - s16 rssi; - u8 range; -}POSTPACK WMI_RSSI_THRESHOLD_EVENT; - -/* - * WMI_ERROR_REPORT_EVENTID - */ -typedef enum{ - WMI_TARGET_PM_ERR_FAIL = 0x00000001, - WMI_TARGET_KEY_NOT_FOUND = 0x00000002, - WMI_TARGET_DECRYPTION_ERR = 0x00000004, - WMI_TARGET_BMISS = 0x00000008, - WMI_PSDISABLE_NODE_JOIN = 0x00000010, - WMI_TARGET_COM_ERR = 0x00000020, - WMI_TARGET_FATAL_ERR = 0x00000040 -} WMI_TARGET_ERROR_VAL; - -typedef PREPACK struct { - u32 errorVal; -}POSTPACK WMI_TARGET_ERROR_REPORT_EVENT; - -typedef PREPACK struct { - u8 retrys; -}POSTPACK WMI_TX_RETRY_ERR_EVENT; - -typedef enum{ - WMI_SNR_THRESHOLD1_ABOVE = 1, - WMI_SNR_THRESHOLD1_BELOW, - WMI_SNR_THRESHOLD2_ABOVE, - WMI_SNR_THRESHOLD2_BELOW, - WMI_SNR_THRESHOLD3_ABOVE, - WMI_SNR_THRESHOLD3_BELOW, - WMI_SNR_THRESHOLD4_ABOVE, - WMI_SNR_THRESHOLD4_BELOW -} WMI_SNR_THRESHOLD_VAL; - -typedef PREPACK struct { - u8 range; /* WMI_SNR_THRESHOLD_VAL */ - u8 snr; -}POSTPACK WMI_SNR_THRESHOLD_EVENT; - -typedef enum{ - WMI_LQ_THRESHOLD1_ABOVE = 1, - WMI_LQ_THRESHOLD1_BELOW, - WMI_LQ_THRESHOLD2_ABOVE, - WMI_LQ_THRESHOLD2_BELOW, - WMI_LQ_THRESHOLD3_ABOVE, - WMI_LQ_THRESHOLD3_BELOW, - WMI_LQ_THRESHOLD4_ABOVE, - WMI_LQ_THRESHOLD4_BELOW -} WMI_LQ_THRESHOLD_VAL; - -typedef PREPACK struct { - s32 lq; - u8 range; /* WMI_LQ_THRESHOLD_VAL */ -}POSTPACK WMI_LQ_THRESHOLD_EVENT; -/* - * WMI_REPORT_ROAM_TBL_EVENTID - */ -#define MAX_ROAM_TBL_CAND 5 - -typedef PREPACK struct { - s32 roam_util; - u8 bssid[ATH_MAC_LEN]; - s8 rssi; - s8 rssidt; - s8 last_rssi; - s8 util; - s8 bias; - u8 reserved; /* For alignment */ -} POSTPACK WMI_BSS_ROAM_INFO; - - -typedef PREPACK struct { - u16 roamMode; - u16 numEntries; - WMI_BSS_ROAM_INFO bssRoamInfo[1]; -} POSTPACK WMI_TARGET_ROAM_TBL; - -/* - * WMI_HCI_EVENT_EVENTID - */ -typedef PREPACK struct { - u16 evt_buf_sz; /* HCI event buffer size */ - u8 buf[1]; /* HCI event */ -} POSTPACK WMI_HCI_EVENT; - -/* - * WMI_CAC_EVENTID - */ -typedef enum { - CAC_INDICATION_ADMISSION = 0x00, - CAC_INDICATION_ADMISSION_RESP = 0x01, - CAC_INDICATION_DELETE = 0x02, - CAC_INDICATION_NO_RESP = 0x03, -}CAC_INDICATION; - -#define WMM_TSPEC_IE_LEN 63 - -typedef PREPACK struct { - u8 ac; - u8 cac_indication; - u8 statusCode; - u8 tspecSuggestion[WMM_TSPEC_IE_LEN]; -}POSTPACK WMI_CAC_EVENT; - -/* - * WMI_APLIST_EVENTID - */ - -typedef enum { - APLIST_VER1 = 1, -} APLIST_VER; - -typedef PREPACK struct { - u8 bssid[ATH_MAC_LEN]; - u16 channel; -} POSTPACK WMI_AP_INFO_V1; - -typedef PREPACK union { - WMI_AP_INFO_V1 apInfoV1; -} POSTPACK WMI_AP_INFO; - -typedef PREPACK struct { - u8 apListVer; - u8 numAP; - WMI_AP_INFO apList[1]; -} POSTPACK WMI_APLIST_EVENT; - -/* - * developer commands - */ - -/* - * WMI_SET_BITRATE_CMDID - * - * Get bit rate cmd uses same definition as set bit rate cmd - */ -typedef enum { - RATE_AUTO = -1, - RATE_1Mb = 0, - RATE_2Mb = 1, - RATE_5_5Mb = 2, - RATE_11Mb = 3, - RATE_6Mb = 4, - RATE_9Mb = 5, - RATE_12Mb = 6, - RATE_18Mb = 7, - RATE_24Mb = 8, - RATE_36Mb = 9, - RATE_48Mb = 10, - RATE_54Mb = 11, - RATE_MCS_0_20 = 12, - RATE_MCS_1_20 = 13, - RATE_MCS_2_20 = 14, - RATE_MCS_3_20 = 15, - RATE_MCS_4_20 = 16, - RATE_MCS_5_20 = 17, - RATE_MCS_6_20 = 18, - RATE_MCS_7_20 = 19, - RATE_MCS_0_40 = 20, - RATE_MCS_1_40 = 21, - RATE_MCS_2_40 = 22, - RATE_MCS_3_40 = 23, - RATE_MCS_4_40 = 24, - RATE_MCS_5_40 = 25, - RATE_MCS_6_40 = 26, - RATE_MCS_7_40 = 27, -} WMI_BIT_RATE; - -typedef PREPACK struct { - s8 rateIndex; /* see WMI_BIT_RATE */ - s8 mgmtRateIndex; - s8 ctlRateIndex; -} POSTPACK WMI_BIT_RATE_CMD; - - -typedef PREPACK struct { - s8 rateIndex; /* see WMI_BIT_RATE */ -} POSTPACK WMI_BIT_RATE_REPLY; - - -/* - * WMI_SET_FIXRATES_CMDID - * - * Get fix rates cmd uses same definition as set fix rates cmd - */ -#define FIX_RATE_1Mb ((u32)0x1) -#define FIX_RATE_2Mb ((u32)0x2) -#define FIX_RATE_5_5Mb ((u32)0x4) -#define FIX_RATE_11Mb ((u32)0x8) -#define FIX_RATE_6Mb ((u32)0x10) -#define FIX_RATE_9Mb ((u32)0x20) -#define FIX_RATE_12Mb ((u32)0x40) -#define FIX_RATE_18Mb ((u32)0x80) -#define FIX_RATE_24Mb ((u32)0x100) -#define FIX_RATE_36Mb ((u32)0x200) -#define FIX_RATE_48Mb ((u32)0x400) -#define FIX_RATE_54Mb ((u32)0x800) -#define FIX_RATE_MCS_0_20 ((u32)0x1000) -#define FIX_RATE_MCS_1_20 ((u32)0x2000) -#define FIX_RATE_MCS_2_20 ((u32)0x4000) -#define FIX_RATE_MCS_3_20 ((u32)0x8000) -#define FIX_RATE_MCS_4_20 ((u32)0x10000) -#define FIX_RATE_MCS_5_20 ((u32)0x20000) -#define FIX_RATE_MCS_6_20 ((u32)0x40000) -#define FIX_RATE_MCS_7_20 ((u32)0x80000) -#define FIX_RATE_MCS_0_40 ((u32)0x100000) -#define FIX_RATE_MCS_1_40 ((u32)0x200000) -#define FIX_RATE_MCS_2_40 ((u32)0x400000) -#define FIX_RATE_MCS_3_40 ((u32)0x800000) -#define FIX_RATE_MCS_4_40 ((u32)0x1000000) -#define FIX_RATE_MCS_5_40 ((u32)0x2000000) -#define FIX_RATE_MCS_6_40 ((u32)0x4000000) -#define FIX_RATE_MCS_7_40 ((u32)0x8000000) - -typedef PREPACK struct { - u32 fixRateMask; /* see WMI_BIT_RATE */ -} POSTPACK WMI_FIX_RATES_CMD, WMI_FIX_RATES_REPLY; - -typedef PREPACK struct { - u8 bEnableMask; - u8 frameType; /*type and subtype*/ - u32 frameRateMask; /* see WMI_BIT_RATE */ -} POSTPACK WMI_FRAME_RATES_CMD, WMI_FRAME_RATES_REPLY; - -/* - * WMI_SET_RECONNECT_AUTH_MODE_CMDID - * - * Set authentication mode - */ -typedef enum { - RECONN_DO_AUTH = 0x00, - RECONN_NOT_AUTH = 0x01 -} WMI_AUTH_MODE; - -typedef PREPACK struct { - u8 mode; -} POSTPACK WMI_SET_AUTH_MODE_CMD; - -/* - * WMI_SET_REASSOC_MODE_CMDID - * - * Set authentication mode - */ -typedef enum { - REASSOC_DO_DISASSOC = 0x00, - REASSOC_DONOT_DISASSOC = 0x01 -} WMI_REASSOC_MODE; - -typedef PREPACK struct { - u8 mode; -}POSTPACK WMI_SET_REASSOC_MODE_CMD; - -typedef enum { - ROAM_DATA_TIME = 1, /* Get The Roam Time Data */ -} ROAM_DATA_TYPE; - -typedef PREPACK struct { - u32 disassoc_time; - u32 no_txrx_time; - u32 assoc_time; - u32 allow_txrx_time; - u8 disassoc_bssid[ATH_MAC_LEN]; - s8 disassoc_bss_rssi; - u8 assoc_bssid[ATH_MAC_LEN]; - s8 assoc_bss_rssi; -} POSTPACK WMI_TARGET_ROAM_TIME; - -typedef PREPACK struct { - PREPACK union { - WMI_TARGET_ROAM_TIME roamTime; - } POSTPACK u; - u8 roamDataType ; -} POSTPACK WMI_TARGET_ROAM_DATA; - -typedef enum { - WMI_WMM_DISABLED = 0, - WMI_WMM_ENABLED -} WMI_WMM_STATUS; - -typedef PREPACK struct { - u8 status; -}POSTPACK WMI_SET_WMM_CMD; - -typedef PREPACK struct { - u8 status; -}POSTPACK WMI_SET_QOS_SUPP_CMD; - -typedef enum { - WMI_TXOP_DISABLED = 0, - WMI_TXOP_ENABLED -} WMI_TXOP_CFG; - -typedef PREPACK struct { - u8 txopEnable; -}POSTPACK WMI_SET_WMM_TXOP_CMD; - -typedef PREPACK struct { - u8 keepaliveInterval; -} POSTPACK WMI_SET_KEEPALIVE_CMD; - -typedef PREPACK struct { - u32 configured; - u8 keepaliveInterval; -} POSTPACK WMI_GET_KEEPALIVE_CMD; - -/* - * Add Application specified IE to a management frame - */ -#define WMI_MAX_IE_LEN 255 - -typedef PREPACK struct { - u8 mgmtFrmType; /* one of WMI_MGMT_FRAME_TYPE */ - u8 ieLen; /* Length of the IE that should be added to the MGMT frame */ - u8 ieInfo[1]; -} POSTPACK WMI_SET_APPIE_CMD; - -/* - * Notify the WSC registration status to the target - */ -#define WSC_REG_ACTIVE 1 -#define WSC_REG_INACTIVE 0 -/* Generic Hal Interface for setting hal paramters. */ -/* Add new Set HAL Param cmdIds here for newer params */ -typedef enum { - WHAL_SETCABTO_CMDID = 1, -}WHAL_CMDID; - -typedef PREPACK struct { - u8 cabTimeOut; -} POSTPACK WHAL_SETCABTO_PARAM; - -typedef PREPACK struct { - u8 whalCmdId; - u8 data[1]; -} POSTPACK WHAL_PARAMCMD; - - -#define WOW_MAX_FILTER_LISTS 1 /*4*/ -#define WOW_MAX_FILTERS_PER_LIST 4 -#define WOW_PATTERN_SIZE 64 -#define WOW_MASK_SIZE 64 - -#define MAC_MAX_FILTERS_PER_LIST 4 - -typedef PREPACK struct { - u8 wow_valid_filter; - u8 wow_filter_id; - u8 wow_filter_size; - u8 wow_filter_offset; - u8 wow_filter_mask[WOW_MASK_SIZE]; - u8 wow_filter_pattern[WOW_PATTERN_SIZE]; -} POSTPACK WOW_FILTER; - - -typedef PREPACK struct { - u8 wow_valid_list; - u8 wow_list_id; - u8 wow_num_filters; - u8 wow_total_list_size; - WOW_FILTER list[WOW_MAX_FILTERS_PER_LIST]; -} POSTPACK WOW_FILTER_LIST; - -typedef PREPACK struct { - u8 valid_filter; - u8 mac_addr[ATH_MAC_LEN]; -} POSTPACK MAC_FILTER; - - -typedef PREPACK struct { - u8 total_list_size; - u8 enable; - MAC_FILTER list[MAC_MAX_FILTERS_PER_LIST]; -} POSTPACK MAC_FILTER_LIST; - -#define MAX_IP_ADDRS 2 -typedef PREPACK struct { - u32 ips[MAX_IP_ADDRS]; /* IP in Network Byte Order */ -} POSTPACK WMI_SET_IP_CMD; - -typedef PREPACK struct { - u32 awake; - u32 asleep; -} POSTPACK WMI_SET_HOST_SLEEP_MODE_CMD; - -typedef enum { - WOW_FILTER_SSID = 0x1 -} WMI_WOW_FILTER; - -typedef PREPACK struct { - u32 enable_wow; - WMI_WOW_FILTER filter; - u16 hostReqDelay; -} POSTPACK WMI_SET_WOW_MODE_CMD; - -typedef PREPACK struct { - u8 filter_list_id; -} POSTPACK WMI_GET_WOW_LIST_CMD; - -/* - * WMI_GET_WOW_LIST_CMD reply - */ -typedef PREPACK struct { - u8 num_filters; /* number of patterns in reply */ - u8 this_filter_num; /* this is filter # x of total num_filters */ - u8 wow_mode; - u8 host_mode; - WOW_FILTER wow_filters[1]; -} POSTPACK WMI_GET_WOW_LIST_REPLY; - -typedef PREPACK struct { - u8 filter_list_id; - u8 filter_size; - u8 filter_offset; - u8 filter[1]; -} POSTPACK WMI_ADD_WOW_PATTERN_CMD; - -typedef PREPACK struct { - u16 filter_list_id; - u16 filter_id; -} POSTPACK WMI_DEL_WOW_PATTERN_CMD; - -typedef PREPACK struct { - u8 macaddr[ATH_MAC_LEN]; -} POSTPACK WMI_SET_MAC_ADDRESS_CMD; - -/* - * WMI_SET_AKMP_PARAMS_CMD - */ - -#define WMI_AKMP_MULTI_PMKID_EN 0x000001 - -typedef PREPACK struct { - u32 akmpInfo; -} POSTPACK WMI_SET_AKMP_PARAMS_CMD; - -typedef PREPACK struct { - u8 pmkid[WMI_PMKID_LEN]; -} POSTPACK WMI_PMKID; - -/* - * WMI_SET_PMKID_LIST_CMD - */ -#define WMI_MAX_PMKID_CACHE 8 - -typedef PREPACK struct { - u32 numPMKID; - WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE]; -} POSTPACK WMI_SET_PMKID_LIST_CMD; - -/* - * WMI_GET_PMKID_LIST_CMD Reply - * Following the Number of PMKIDs is the list of PMKIDs - */ -typedef PREPACK struct { - u32 numPMKID; - u8 bssidList[ATH_MAC_LEN][1]; - WMI_PMKID pmkidList[1]; -} POSTPACK WMI_PMKID_LIST_REPLY; - -typedef PREPACK struct { - u16 oldChannel; - u32 newChannel; -} POSTPACK WMI_CHANNEL_CHANGE_EVENT; - -typedef PREPACK struct { - u32 version; -} POSTPACK WMI_WLAN_VERSION_EVENT; - - -/* WMI_ADDBA_REQ_EVENTID */ -typedef PREPACK struct { - u8 tid; - u8 win_sz; - u16 st_seq_no; - u8 status; /* f/w response for ADDBA Req; OK(0) or failure(!=0) */ -} POSTPACK WMI_ADDBA_REQ_EVENT; - -/* WMI_ADDBA_RESP_EVENTID */ -typedef PREPACK struct { - u8 tid; - u8 status; /* OK(0), failure (!=0) */ - u16 amsdu_sz; /* Three values: Not supported(0), 3839, 8k */ -} POSTPACK WMI_ADDBA_RESP_EVENT; - -/* WMI_DELBA_EVENTID - * f/w received a DELBA for peer and processed it. - * Host is notified of this - */ -typedef PREPACK struct { - u8 tid; - u8 is_peer_initiator; - u16 reason_code; -} POSTPACK WMI_DELBA_EVENT; - - -#ifdef WAPI_ENABLE -#define WAPI_REKEY_UCAST 1 -#define WAPI_REKEY_MCAST 2 -typedef PREPACK struct { - u8 type; - u8 macAddr[ATH_MAC_LEN]; -} POSTPACK WMI_WAPIREKEY_EVENT; -#endif - - -/* WMI_ALLOW_AGGR_CMDID - * Configures tid's to allow ADDBA negotiations - * on each tid, in each direction - */ -typedef PREPACK struct { - u16 tx_allow_aggr; /* 16-bit mask to allow uplink ADDBA negotiation - bit position indicates tid*/ - u16 rx_allow_aggr; /* 16-bit mask to allow donwlink ADDBA negotiation - bit position indicates tid*/ -} POSTPACK WMI_ALLOW_AGGR_CMD; - -/* WMI_ADDBA_REQ_CMDID - * f/w starts performing ADDBA negotiations with peer - * on the given tid - */ -typedef PREPACK struct { - u8 tid; -} POSTPACK WMI_ADDBA_REQ_CMD; - -/* WMI_DELBA_REQ_CMDID - * f/w would teardown BA with peer. - * is_send_initiator indicates if it's or tx or rx side - */ -typedef PREPACK struct { - u8 tid; - u8 is_sender_initiator; - -} POSTPACK WMI_DELBA_REQ_CMD; - -#define PEER_NODE_JOIN_EVENT 0x00 -#define PEER_NODE_LEAVE_EVENT 0x01 -#define PEER_FIRST_NODE_JOIN_EVENT 0x10 -#define PEER_LAST_NODE_LEAVE_EVENT 0x11 -typedef PREPACK struct { - u8 eventCode; - u8 peerMacAddr[ATH_MAC_LEN]; -} POSTPACK WMI_PEER_NODE_EVENT; - -#define IEEE80211_FRAME_TYPE_MGT 0x00 -#define IEEE80211_FRAME_TYPE_CTL 0x04 - -/* - * Transmit complete event data structure(s) - */ - - -typedef PREPACK struct { -#define TX_COMPLETE_STATUS_SUCCESS 0 -#define TX_COMPLETE_STATUS_RETRIES 1 -#define TX_COMPLETE_STATUS_NOLINK 2 -#define TX_COMPLETE_STATUS_TIMEOUT 3 -#define TX_COMPLETE_STATUS_OTHER 4 - - u8 status; /* one of TX_COMPLETE_STATUS_... */ - u8 pktID; /* packet ID to identify parent packet */ - u8 rateIdx; /* rate index on successful transmission */ - u8 ackFailures; /* number of ACK failures in tx attempt */ -#if 0 /* optional params currently omitted. */ - u32 queueDelay; // usec delay measured Tx Start time - host delivery time - u32 mediaDelay; // usec delay measured ACK rx time - host delivery time -#endif -} POSTPACK TX_COMPLETE_MSG_V1; /* version 1 of tx complete msg */ - -typedef PREPACK struct { - u8 numMessages; /* number of tx comp msgs following this struct */ - u8 msgLen; /* length in bytes for each individual msg following this struct */ - u8 msgType; /* version of tx complete msg data following this struct */ - u8 reserved; /* individual messages follow this header */ -} POSTPACK WMI_TX_COMPLETE_EVENT; - -#define WMI_TXCOMPLETE_VERSION_1 (0x01) - - -/* - * ------- AP Mode definitions -------------- - */ - -/* - * !!! Warning !!! - * -Changing the following values needs compilation of both driver and firmware - */ -#ifdef AR6002_REV2 -#define AP_MAX_NUM_STA 4 -#else -#define AP_MAX_NUM_STA 8 -#endif -#define AP_ACL_SIZE 10 -#define IEEE80211_MAX_IE 256 -#define MCAST_AID 0xFF /* Spl. AID used to set DTIM flag in the beacons */ -#define DEF_AP_COUNTRY_CODE "US " -#define DEF_AP_WMODE_G WMI_11G_MODE -#define DEF_AP_WMODE_AG WMI_11AG_MODE -#define DEF_AP_DTIM 5 -#define DEF_BEACON_INTERVAL 100 - -/* AP mode disconnect reasons */ -#define AP_DISCONNECT_STA_LEFT 101 -#define AP_DISCONNECT_FROM_HOST 102 -#define AP_DISCONNECT_COMM_TIMEOUT 103 - -/* - * Used with WMI_AP_HIDDEN_SSID_CMDID - */ -#define HIDDEN_SSID_FALSE 0 -#define HIDDEN_SSID_TRUE 1 -typedef PREPACK struct { - u8 hidden_ssid; -} POSTPACK WMI_AP_HIDDEN_SSID_CMD; - -/* - * Used with WMI_AP_ACL_POLICY_CMDID - */ -#define AP_ACL_DISABLE 0x00 -#define AP_ACL_ALLOW_MAC 0x01 -#define AP_ACL_DENY_MAC 0x02 -#define AP_ACL_RETAIN_LIST_MASK 0x80 -typedef PREPACK struct { - u8 policy; -} POSTPACK WMI_AP_ACL_POLICY_CMD; - -/* - * Used with WMI_AP_ACL_MAC_LIST_CMDID - */ -#define ADD_MAC_ADDR 1 -#define DEL_MAC_ADDR 2 -typedef PREPACK struct { - u8 action; - u8 index; - u8 mac[ATH_MAC_LEN]; - u8 wildcard; -} POSTPACK WMI_AP_ACL_MAC_CMD; - -typedef PREPACK struct { - u16 index; - u8 acl_mac[AP_ACL_SIZE][ATH_MAC_LEN]; - u8 wildcard[AP_ACL_SIZE]; - u8 policy; -} POSTPACK WMI_AP_ACL; - -/* - * Used with WMI_AP_SET_NUM_STA_CMDID - */ -typedef PREPACK struct { - u8 num_sta; -} POSTPACK WMI_AP_SET_NUM_STA_CMD; - -/* - * Used with WMI_AP_SET_MLME_CMDID - */ -typedef PREPACK struct { - u8 mac[ATH_MAC_LEN]; - u16 reason; /* 802.11 reason code */ - u8 cmd; /* operation to perform */ -#define WMI_AP_MLME_ASSOC 1 /* associate station */ -#define WMI_AP_DISASSOC 2 /* disassociate station */ -#define WMI_AP_DEAUTH 3 /* deauthenticate station */ -#define WMI_AP_MLME_AUTHORIZE 4 /* authorize station */ -#define WMI_AP_MLME_UNAUTHORIZE 5 /* unauthorize station */ -} POSTPACK WMI_AP_SET_MLME_CMD; - -typedef PREPACK struct { - u32 period; -} POSTPACK WMI_AP_CONN_INACT_CMD; - -typedef PREPACK struct { - u32 period_min; - u32 dwell_ms; -} POSTPACK WMI_AP_PROT_SCAN_TIME_CMD; - -typedef PREPACK struct { - u32 flag; - u16 aid; -} POSTPACK WMI_AP_SET_PVB_CMD; - -#define WMI_DISABLE_REGULATORY_CODE "FF" - -typedef PREPACK struct { - u8 countryCode[3]; -} POSTPACK WMI_AP_SET_COUNTRY_CMD; - -typedef PREPACK struct { - u8 dtim; -} POSTPACK WMI_AP_SET_DTIM_CMD; - -typedef PREPACK struct { - u8 band; /* specifies which band to apply these values */ - u8 enable; /* allows 11n to be disabled on a per band basis */ - u8 chan_width_40M_supported; - u8 short_GI_20MHz; - u8 short_GI_40MHz; - u8 intolerance_40MHz; - u8 max_ampdu_len_exp; -} POSTPACK WMI_SET_HT_CAP_CMD; - -typedef PREPACK struct { - u8 sta_chan_width; -} POSTPACK WMI_SET_HT_OP_CMD; - -typedef PREPACK struct { - u32 rateMasks[8]; -} POSTPACK WMI_SET_TX_SELECT_RATES_CMD; - -typedef PREPACK struct { - u32 sgiMask; - u8 sgiPERThreshold; -} POSTPACK WMI_SET_TX_SGI_PARAM_CMD; - -#define DEFAULT_SGI_MASK 0x08080000 -#define DEFAULT_SGI_PER 10 - -typedef PREPACK struct { - u32 rateField; /* 1 bit per rate corresponding to index */ - u8 id; - u8 shortTrys; - u8 longTrys; - u8 reserved; /* padding */ -} POSTPACK WMI_SET_RATE_POLICY_CMD; - -typedef PREPACK struct { - u8 metaVersion; /* version of meta data for rx packets <0 = default> (0-7 = valid) */ - u8 dot11Hdr; /* 1 == leave .11 header intact , 0 == replace .11 header with .3 */ - u8 defragOnHost; /* 1 == defragmentation is performed by host, 0 == performed by target */ - u8 reserved[1]; /* alignment */ -} POSTPACK WMI_RX_FRAME_FORMAT_CMD; - - -typedef PREPACK struct { - u8 enable; /* 1 == device operates in thin mode , 0 == normal mode */ - u8 reserved[3]; -} POSTPACK WMI_SET_THIN_MODE_CMD; - -/* AP mode events */ -/* WMI_PS_POLL_EVENT */ -typedef PREPACK struct { - u16 aid; -} POSTPACK WMI_PSPOLL_EVENT; - -typedef PREPACK struct { - u32 tx_bytes; - u32 tx_pkts; - u32 tx_error; - u32 tx_discard; - u32 rx_bytes; - u32 rx_pkts; - u32 rx_error; - u32 rx_discard; - u32 aid; -} POSTPACK WMI_PER_STA_STAT; - -#define AP_GET_STATS 0 -#define AP_CLEAR_STATS 1 - -typedef PREPACK struct { - u32 action; - WMI_PER_STA_STAT sta[AP_MAX_NUM_STA+1]; -} POSTPACK WMI_AP_MODE_STAT; -#define WMI_AP_MODE_STAT_SIZE(numSta) (sizeof(u32) + ((numSta + 1) * sizeof(WMI_PER_STA_STAT))) - -#define AP_11BG_RATESET1 1 -#define AP_11BG_RATESET2 2 -#define DEF_AP_11BG_RATESET AP_11BG_RATESET1 -typedef PREPACK struct { - u8 rateset; -} POSTPACK WMI_AP_SET_11BG_RATESET_CMD; -/* - * End of AP mode definitions - */ - -#ifdef __cplusplus -} -#endif - -#endif /* _WMI_H_ */ diff --git a/drivers/staging/ath6kl/include/common/wmix.h b/drivers/staging/ath6kl/include/common/wmix.h deleted file mode 100644 index 9435eab1b7f..00000000000 --- a/drivers/staging/ath6kl/include/common/wmix.h +++ /dev/null @@ -1,271 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -/* - * This file contains extensions of the WMI protocol specified in the - * Wireless Module Interface (WMI). It includes definitions of all - * extended commands and events. Extensions include useful commands - * that are not directly related to wireless activities. They may - * be hardware-specific, and they might not be supported on all - * implementations. - * - * Extended WMIX commands are encapsulated in a WMI message with - * cmd=WMI_EXTENSION_CMD. - */ - -#ifndef _WMIX_H_ -#define _WMIX_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbglog.h" - -/* - * Extended WMI commands are those that are needed during wireless - * operation, but which are not really wireless commands. This allows, - * for instance, platform-specific commands. Extended WMI commands are - * embedded in a WMI command message with WMI_COMMAND_ID=WMI_EXTENSION_CMDID. - * Extended WMI events are similarly embedded in a WMI event message with - * WMI_EVENT_ID=WMI_EXTENSION_EVENTID. - */ -typedef PREPACK struct { - u32 commandId; -} POSTPACK WMIX_CMD_HDR; - -typedef enum { - WMIX_DSETOPEN_REPLY_CMDID = 0x2001, - WMIX_DSETDATA_REPLY_CMDID, - WMIX_GPIO_OUTPUT_SET_CMDID, - WMIX_GPIO_INPUT_GET_CMDID, - WMIX_GPIO_REGISTER_SET_CMDID, - WMIX_GPIO_REGISTER_GET_CMDID, - WMIX_GPIO_INTR_ACK_CMDID, - WMIX_HB_CHALLENGE_RESP_CMDID, - WMIX_DBGLOG_CFG_MODULE_CMDID, - WMIX_PROF_CFG_CMDID, /* 0x200a */ - WMIX_PROF_ADDR_SET_CMDID, - WMIX_PROF_START_CMDID, - WMIX_PROF_STOP_CMDID, - WMIX_PROF_COUNT_GET_CMDID, -} WMIX_COMMAND_ID; - -typedef enum { - WMIX_DSETOPENREQ_EVENTID = 0x3001, - WMIX_DSETCLOSE_EVENTID, - WMIX_DSETDATAREQ_EVENTID, - WMIX_GPIO_INTR_EVENTID, - WMIX_GPIO_DATA_EVENTID, - WMIX_GPIO_ACK_EVENTID, - WMIX_HB_CHALLENGE_RESP_EVENTID, - WMIX_DBGLOG_EVENTID, - WMIX_PROF_COUNT_EVENTID, -} WMIX_EVENT_ID; - -/* - * =============DataSet support================= - */ - -/* - * WMIX_DSETOPENREQ_EVENTID - * DataSet Open Request Event - */ -typedef PREPACK struct { - u32 dset_id; - u32 targ_dset_handle; /* echo'ed, not used by Host, */ - u32 targ_reply_fn; /* echo'ed, not used by Host, */ - u32 targ_reply_arg; /* echo'ed, not used by Host, */ -} POSTPACK WMIX_DSETOPENREQ_EVENT; - -/* - * WMIX_DSETCLOSE_EVENTID - * DataSet Close Event - */ -typedef PREPACK struct { - u32 access_cookie; -} POSTPACK WMIX_DSETCLOSE_EVENT; - -/* - * WMIX_DSETDATAREQ_EVENTID - * DataSet Data Request Event - */ -typedef PREPACK struct { - u32 access_cookie; - u32 offset; - u32 length; - u32 targ_buf; /* echo'ed, not used by Host, */ - u32 targ_reply_fn; /* echo'ed, not used by Host, */ - u32 targ_reply_arg; /* echo'ed, not used by Host, */ -} POSTPACK WMIX_DSETDATAREQ_EVENT; - -typedef PREPACK struct { - u32 status; - u32 targ_dset_handle; - u32 targ_reply_fn; - u32 targ_reply_arg; - u32 access_cookie; - u32 size; - u32 version; -} POSTPACK WMIX_DSETOPEN_REPLY_CMD; - -typedef PREPACK struct { - u32 status; - u32 targ_buf; - u32 targ_reply_fn; - u32 targ_reply_arg; - u32 length; - u8 buf[1]; -} POSTPACK WMIX_DSETDATA_REPLY_CMD; - - -/* - * =============GPIO support================= - * All masks are 18-bit masks with bit N operating on GPIO pin N. - */ - - -/* - * Set GPIO pin output state. - * In order for output to be driven, a pin must be enabled for output. - * This can be done during initialization through the GPIO Configuration - * DataSet, or during operation with the enable_mask. - * - * If a request is made to simultaneously set/clear or set/disable or - * clear/disable or disable/enable, results are undefined. - */ -typedef PREPACK struct { - u32 set_mask; /* pins to set */ - u32 clear_mask; /* pins to clear */ - u32 enable_mask; /* pins to enable for output */ - u32 disable_mask; /* pins to disable/tristate */ -} POSTPACK WMIX_GPIO_OUTPUT_SET_CMD; - -/* - * Set a GPIO register. For debug/exceptional cases. - * Values for gpioreg_id are GPIO_REGISTER_IDs, defined in a - * platform-dependent header. - */ -typedef PREPACK struct { - u32 gpioreg_id; /* GPIO register ID */ - u32 value; /* value to write */ -} POSTPACK WMIX_GPIO_REGISTER_SET_CMD; - -/* Get a GPIO register. For debug/exceptional cases. */ -typedef PREPACK struct { - u32 gpioreg_id; /* GPIO register to read */ -} POSTPACK WMIX_GPIO_REGISTER_GET_CMD; - -/* - * Host acknowledges and re-arms GPIO interrupts. A single - * message should be used to acknowledge all interrupts that - * were delivered in an earlier WMIX_GPIO_INTR_EVENT message. - */ -typedef PREPACK struct { - u32 ack_mask; /* interrupts to acknowledge */ -} POSTPACK WMIX_GPIO_INTR_ACK_CMD; - -/* - * Target informs Host of GPIO interrupts that have occurred since the - * last WMIX_GIPO_INTR_ACK_CMD was received. Additional information -- - * the current GPIO input values is provided -- in order to support - * use of a GPIO interrupt as a Data Valid signal for other GPIO pins. - */ -typedef PREPACK struct { - u32 intr_mask; /* pending GPIO interrupts */ - u32 input_values; /* recent GPIO input values */ -} POSTPACK WMIX_GPIO_INTR_EVENT; - -/* - * Target responds to Host's earlier WMIX_GPIO_INPUT_GET_CMDID request - * using a GPIO_DATA_EVENT with - * value set to the mask of GPIO pin inputs and - * reg_id set to GPIO_ID_NONE - * - * - * Target responds to Hosts's earlier WMIX_GPIO_REGISTER_GET_CMDID request - * using a GPIO_DATA_EVENT with - * value set to the value of the requested register and - * reg_id identifying the register (reflects the original request) - * NB: reg_id supports the future possibility of unsolicited - * WMIX_GPIO_DATA_EVENTs (for polling GPIO input), and it may - * simplify Host GPIO support. - */ -typedef PREPACK struct { - u32 value; - u32 reg_id; -} POSTPACK WMIX_GPIO_DATA_EVENT; - -/* - * =============Error Detection support================= - */ - -/* - * WMIX_HB_CHALLENGE_RESP_CMDID - * Heartbeat Challenge Response command - */ -typedef PREPACK struct { - u32 cookie; - u32 source; -} POSTPACK WMIX_HB_CHALLENGE_RESP_CMD; - -/* - * WMIX_HB_CHALLENGE_RESP_EVENTID - * Heartbeat Challenge Response Event - */ -#define WMIX_HB_CHALLENGE_RESP_EVENT WMIX_HB_CHALLENGE_RESP_CMD - -typedef PREPACK struct { - struct dbglog_config_s config; -} POSTPACK WMIX_DBGLOG_CFG_MODULE_CMD; - -/* - * =============Target Profiling support================= - */ - -typedef PREPACK struct { - u32 period; /* Time (in 30.5us ticks) between samples */ - u32 nbins; -} POSTPACK WMIX_PROF_CFG_CMD; - -typedef PREPACK struct { - u32 addr; -} POSTPACK WMIX_PROF_ADDR_SET_CMD; - -/* - * Target responds to Hosts's earlier WMIX_PROF_COUNT_GET_CMDID request - * using a WMIX_PROF_COUNT_EVENT with - * addr set to the next address - * count set to the corresponding count - */ -typedef PREPACK struct { - u32 addr; - u32 count; -} POSTPACK WMIX_PROF_COUNT_EVENT; - - -#ifdef __cplusplus -} -#endif - -#endif /* _WMIX_H_ */ diff --git a/drivers/staging/ath6kl/include/common_drv.h b/drivers/staging/ath6kl/include/common_drv.h deleted file mode 100644 index 34db29958bc..00000000000 --- a/drivers/staging/ath6kl/include/common_drv.h +++ /dev/null @@ -1,104 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef COMMON_DRV_H_ -#define COMMON_DRV_H_ - -#include "hif.h" -#include "htc_packet.h" -#include "htc_api.h" - -/* structure that is the state information for the default credit distribution callback - * drivers should instantiate (zero-init as well) this structure in their driver instance - * and pass it as a context to the HTC credit distribution functions */ -struct common_credit_state_info { - int TotalAvailableCredits; /* total credits in the system at startup */ - int CurrentFreeCredits; /* credits available in the pool that have not been - given out to endpoints */ - struct htc_endpoint_credit_dist *pLowestPriEpDist; /* pointer to the lowest priority endpoint dist struct */ -}; - -struct hci_transport_callbacks { - s32 (*setupTransport)(void *ar); - void (*cleanupTransport)(void *ar); -}; - -struct hci_transport_misc_handles { - void *netDevice; - void *hifDevice; - void *htcHandle; -}; - -/* HTC TX packet tagging definitions */ -#define AR6K_CONTROL_PKT_TAG HTC_TX_PACKET_TAG_USER_DEFINED -#define AR6K_DATA_PKT_TAG (AR6K_CONTROL_PKT_TAG + 1) - -#define AR6002_VERSION_REV1 0x20000086 -#define AR6002_VERSION_REV2 0x20000188 -#define AR6003_VERSION_REV1 0x300002ba -#define AR6003_VERSION_REV2 0x30000384 - -#define AR6002_CUST_DATA_SIZE 112 -#define AR6003_CUST_DATA_SIZE 16 - -#ifdef __cplusplus -extern "C" { -#endif - -/* OS-independent APIs */ -int ar6000_setup_credit_dist(HTC_HANDLE HTCHandle, struct common_credit_state_info *pCredInfo); - -int ar6000_ReadRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); - -int ar6000_WriteRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); - -int ar6000_ReadDataDiag(struct hif_device *hifDevice, u32 address, u8 *data, u32 length); - -int ar6000_reset_device(struct hif_device *hifDevice, u32 TargetType, bool waitForCompletion, bool coldReset); - -void ar6000_dump_target_assert_info(struct hif_device *hifDevice, u32 TargetType); - -int ar6000_set_htc_params(struct hif_device *hifDevice, - u32 TargetType, - u32 MboxIsrYieldValue, - u8 HtcControlBuffers); - -int ar6000_set_hci_bridge_flags(struct hif_device *hifDevice, - u32 TargetType, - u32 Flags); - -void ar6000_copy_cust_data_from_target(struct hif_device *hifDevice, u32 TargetType); - -u8 *ar6000_get_cust_data_buffer(u32 TargetType); - -int ar6000_setBTState(void *context, u8 *pInBuf, u32 InBufSize); - -int ar6000_setDevicePowerState(void *context, u8 *pInBuf, u32 InBufSize); - -int ar6000_setWowMode(void *context, u8 *pInBuf, u32 InBufSize); - -int ar6000_setHostMode(void *context, u8 *pInBuf, u32 InBufSize); - -#ifdef __cplusplus -} -#endif - -#endif /*COMMON_DRV_H_*/ diff --git a/drivers/staging/ath6kl/include/dbglog_api.h b/drivers/staging/ath6kl/include/dbglog_api.h deleted file mode 100644 index a53aed316e3..00000000000 --- a/drivers/staging/ath6kl/include/dbglog_api.h +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains host side debug primitives. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _DBGLOG_API_H_ -#define _DBGLOG_API_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbglog.h" - -#define DBGLOG_HOST_LOG_BUFFER_SIZE DBGLOG_LOG_BUFFER_SIZE - -#define DBGLOG_GET_DBGID(arg) \ - ((arg & DBGLOG_DBGID_MASK) >> DBGLOG_DBGID_OFFSET) - -#define DBGLOG_GET_MODULEID(arg) \ - ((arg & DBGLOG_MODULEID_MASK) >> DBGLOG_MODULEID_OFFSET) - -#define DBGLOG_GET_NUMARGS(arg) \ - ((arg & DBGLOG_NUM_ARGS_MASK) >> DBGLOG_NUM_ARGS_OFFSET) - -#define DBGLOG_GET_TIMESTAMP(arg) \ - ((arg & DBGLOG_TIMESTAMP_MASK) >> DBGLOG_TIMESTAMP_OFFSET) - -#ifdef __cplusplus -} -#endif - -#endif /* _DBGLOG_API_H_ */ diff --git a/drivers/staging/ath6kl/include/dl_list.h b/drivers/staging/ath6kl/include/dl_list.h deleted file mode 100644 index 13b1e6956c2..00000000000 --- a/drivers/staging/ath6kl/include/dl_list.h +++ /dev/null @@ -1,153 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Double-link list definitions (adapted from Atheros SDIO stack) -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef __DL_LIST_H___ -#define __DL_LIST_H___ - -#include "a_osapi.h" - -#define A_CONTAINING_STRUCT(address, struct_type, field_name)\ - ((struct_type *)((unsigned long)(address) - (unsigned long)(&((struct_type *)0)->field_name))) - -/* list functions */ -/* pointers for the list */ -struct dl_list { - struct dl_list *pPrev; - struct dl_list *pNext; -}; -/* - * DL_LIST_INIT , initialize doubly linked list -*/ -#define DL_LIST_INIT(pList)\ - {(pList)->pPrev = pList; (pList)->pNext = pList;} - -/* faster macro to init list and add a single item */ -#define DL_LIST_INIT_AND_ADD(pList,pItem) \ -{ (pList)->pPrev = (pItem); \ - (pList)->pNext = (pItem); \ - (pItem)->pNext = (pList); \ - (pItem)->pPrev = (pList); \ -} - -#define DL_LIST_IS_EMPTY(pList) (((pList)->pPrev == (pList)) && ((pList)->pNext == (pList))) -#define DL_LIST_GET_ITEM_AT_HEAD(pList) (pList)->pNext -#define DL_LIST_GET_ITEM_AT_TAIL(pList) (pList)->pPrev -/* - * ITERATE_OVER_LIST pStart is the list, pTemp is a temp list member - * NOT: do not use this function if the items in the list are deleted inside the - * iteration loop -*/ -#define ITERATE_OVER_LIST(pStart, pTemp) \ - for((pTemp) =(pStart)->pNext; pTemp != (pStart); (pTemp) = (pTemp)->pNext) - - -/* safe iterate macro that allows the item to be removed from the list - * the iteration continues to the next item in the list - */ -#define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart,pItem,st,offset) \ -{ \ - struct dl_list * pTemp; \ - pTemp = (pStart)->pNext; \ - while (pTemp != (pStart)) { \ - (pItem) = A_CONTAINING_STRUCT(pTemp,st,offset); \ - pTemp = pTemp->pNext; \ - -#define ITERATE_END }} - -/* - * DL_ListInsertTail - insert pAdd to the end of the list -*/ -static INLINE struct dl_list *DL_ListInsertTail(struct dl_list *pList, struct dl_list *pAdd) { - /* insert at tail */ - pAdd->pPrev = pList->pPrev; - pAdd->pNext = pList; - pList->pPrev->pNext = pAdd; - pList->pPrev = pAdd; - return pAdd; -} - -/* - * DL_ListInsertHead - insert pAdd into the head of the list -*/ -static INLINE struct dl_list * DL_ListInsertHead(struct dl_list * pList, struct dl_list * pAdd) { - /* insert at head */ - pAdd->pPrev = pList; - pAdd->pNext = pList->pNext; - pList->pNext->pPrev = pAdd; - pList->pNext = pAdd; - return pAdd; -} - -#define DL_ListAdd(pList,pItem) DL_ListInsertHead((pList),(pItem)) -/* - * DL_ListRemove - remove pDel from list -*/ -static INLINE struct dl_list * DL_ListRemove(struct dl_list * pDel) { - pDel->pNext->pPrev = pDel->pPrev; - pDel->pPrev->pNext = pDel->pNext; - /* point back to itself just to be safe, incase remove is called again */ - pDel->pNext = pDel; - pDel->pPrev = pDel; - return pDel; -} - -/* - * DL_ListRemoveItemFromHead - get a list item from the head -*/ -static INLINE struct dl_list * DL_ListRemoveItemFromHead(struct dl_list * pList) { - struct dl_list * pItem = NULL; - if (pList->pNext != pList) { - pItem = pList->pNext; - /* remove the first item from head */ - DL_ListRemove(pItem); - } - return pItem; -} - -static INLINE struct dl_list * DL_ListRemoveItemFromTail(struct dl_list * pList) { - struct dl_list * pItem = NULL; - if (pList->pPrev != pList) { - pItem = pList->pPrev; - /* remove the item from tail */ - DL_ListRemove(pItem); - } - return pItem; -} - -/* transfer src list items to the tail of the destination list */ -static INLINE void DL_ListTransferItemsToTail(struct dl_list * pDest, struct dl_list * pSrc) { - /* only concatenate if src is not empty */ - if (!DL_LIST_IS_EMPTY(pSrc)) { - /* cut out circular list in src and re-attach to end of dest */ - pSrc->pPrev->pNext = pDest; - pSrc->pNext->pPrev = pDest->pPrev; - pDest->pPrev->pNext = pSrc->pNext; - pDest->pPrev = pSrc->pPrev; - /* terminate src list, it is now empty */ - pSrc->pPrev = pSrc; - pSrc->pNext = pSrc; - } -} - -#endif /* __DL_LIST_H___ */ diff --git a/drivers/staging/ath6kl/include/dset_api.h b/drivers/staging/ath6kl/include/dset_api.h deleted file mode 100644 index fe901ba40ec..00000000000 --- a/drivers/staging/ath6kl/include/dset_api.h +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Host-side DataSet API. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _DSET_API_H_ -#define _DSET_API_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Host-side DataSet support is optional, and is not - * currently required for correct operation. To disable - * Host-side DataSet support, set this to 0. - */ -#ifndef CONFIG_HOST_DSET_SUPPORT -#define CONFIG_HOST_DSET_SUPPORT 1 -#endif - -/* Called to send a DataSet Open Reply back to the Target. */ -int wmi_dset_open_reply(struct wmi_t *wmip, - u32 status, - u32 access_cookie, - u32 size, - u32 version, - u32 targ_handle, - u32 targ_reply_fn, - u32 targ_reply_arg); - -/* Called to send a DataSet Data Reply back to the Target. */ -int wmi_dset_data_reply(struct wmi_t *wmip, - u32 status, - u8 *host_buf, - u32 length, - u32 targ_buf, - u32 targ_reply_fn, - u32 targ_reply_arg); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* _DSET_API_H_ */ diff --git a/drivers/staging/ath6kl/include/hci_transport_api.h b/drivers/staging/ath6kl/include/hci_transport_api.h deleted file mode 100644 index 5e903fad23f..00000000000 --- a/drivers/staging/ath6kl/include/hci_transport_api.h +++ /dev/null @@ -1,259 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HCI_TRANSPORT_API_H_ -#define _HCI_TRANSPORT_API_H_ - - /* Bluetooth HCI packets are stored in HTC packet containers */ -#include "htc_packet.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef void *HCI_TRANSPORT_HANDLE; - -typedef HTC_ENDPOINT_ID HCI_TRANSPORT_PACKET_TYPE; - - /* we map each HCI packet class to a static Endpoint ID */ -#define HCI_COMMAND_TYPE ENDPOINT_1 -#define HCI_EVENT_TYPE ENDPOINT_2 -#define HCI_ACL_TYPE ENDPOINT_3 -#define HCI_PACKET_INVALID ENDPOINT_MAX - -#define HCI_GET_PACKET_TYPE(pP) (pP)->Endpoint -#define HCI_SET_PACKET_TYPE(pP,s) (pP)->Endpoint = (s) - -/* callback when an HCI packet was completely sent */ -typedef void (*HCI_TRANSPORT_SEND_PKT_COMPLETE)(void *, struct htc_packet *); -/* callback when an HCI packet is received */ -typedef void (*HCI_TRANSPORT_RECV_PKT)(void *, struct htc_packet *); -/* Optional receive buffer re-fill callback, - * On some OSes (like Linux) packets are allocated from a global pool and indicated up - * to the network stack. The driver never gets the packets back from the OS. For these OSes - * a refill callback can be used to allocate and re-queue buffers into HTC. - * A refill callback is used for the reception of ACL and EVENT packets. The caller must - * set the watermark trigger point to cause a refill. - */ -typedef void (*HCI_TRANSPORT_RECV_REFILL)(void *, HCI_TRANSPORT_PACKET_TYPE Type, int BuffersAvailable); -/* Optional receive packet refill - * On some systems packet buffers are an extremely limited resource. Rather than - * queue largest-possible-sized buffers to the HCI bridge, some systems would rather - * allocate a specific size as the packet is received. The trade off is - * slightly more processing (callback invoked for each RX packet) - * for the benefit of committing fewer buffer resources into the bridge. - * - * The callback is provided the length of the pending packet to fetch. This includes the - * full transport header, HCI header, plus the length of payload. The callback can return a pointer to - * the allocated HTC packet for immediate use. - * - * NOTE*** This callback is mutually exclusive with the the refill callback above. - * - * */ -typedef struct htc_packet *(*HCI_TRANSPORT_RECV_ALLOC)(void *, HCI_TRANSPORT_PACKET_TYPE Type, int Length); - -typedef enum _HCI_SEND_FULL_ACTION { - HCI_SEND_FULL_KEEP = 0, /* packet that overflowed should be kept in the queue */ - HCI_SEND_FULL_DROP = 1, /* packet that overflowed should be dropped */ -} HCI_SEND_FULL_ACTION; - -/* callback when an HCI send queue exceeds the caller's MaxSendQueueDepth threshold, - * the callback must return the send full action to take (either DROP or KEEP) */ -typedef HCI_SEND_FULL_ACTION (*HCI_TRANSPORT_SEND_FULL)(void *, struct htc_packet *); - -struct hci_transport_properties { - int HeadRoom; /* number of bytes in front of HCI packet for header space */ - int TailRoom; /* number of bytes at the end of the HCI packet for tail space */ - int IOBlockPad; /* I/O block padding required (always a power of 2) */ -}; - -struct hci_transport_config_info { - int ACLRecvBufferWaterMark; /* low watermark to trigger recv refill */ - int EventRecvBufferWaterMark; /* low watermark to trigger recv refill */ - int MaxSendQueueDepth; /* max number of packets in the single send queue */ - void *pContext; /* context for all callbacks */ - void (*TransportFailure)(void *pContext, int Status); /* transport failure callback */ - int (*TransportReady)(HCI_TRANSPORT_HANDLE, struct hci_transport_properties *,void *pContext); /* transport is ready */ - void (*TransportRemoved)(void *pContext); /* transport was removed */ - /* packet processing callbacks */ - HCI_TRANSPORT_SEND_PKT_COMPLETE pHCISendComplete; - HCI_TRANSPORT_RECV_PKT pHCIPktRecv; - HCI_TRANSPORT_RECV_REFILL pHCIPktRecvRefill; - HCI_TRANSPORT_RECV_ALLOC pHCIPktRecvAlloc; - HCI_TRANSPORT_SEND_FULL pHCISendFull; -}; - -/* ------ Function Prototypes ------ */ -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Attach to the HCI transport module - @function name: HCI_TransportAttach - @input: HTCHandle - HTC handle (see HTC apis) - pInfo - initialization information - @output: - @return: HCI_TRANSPORT_HANDLE on success, NULL on failure - @notes: The HTC module provides HCI transport services. - @example: - @see also: HCI_TransportDetach -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, struct hci_transport_config_info *pInfo); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Detach from the HCI transport module - @function name: HCI_TransportDetach - @input: HciTrans - HCI transport handle - pInfo - initialization information - @output: - @return: - @notes: - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Add receive packets to the HCI transport - @function name: HCI_TransportAddReceivePkts - @input: HciTrans - HCI transport handle - pQueue - a queue holding one or more packets - @output: - @return: 0 on success - @notes: user must supply HTC packets for capturing incomming HCI packets. The caller - must initialize each HTC packet using the SET_HTC_PACKET_INFO_RX_REFILL() - macro. Each packet in the queue must be of the same type and length - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Send an HCI packet packet - @function name: HCI_TransportSendPkt - @input: HciTrans - HCI transport handle - pPacket - packet to send - Synchronous - send the packet synchronously (blocking) - @output: - @return: 0 - @notes: Caller must initialize packet using SET_HTC_PACKET_INFO_TX() and - HCI_SET_PACKET_TYPE() macros to prepare the packet. - If Synchronous is set to false the call is fully asynchronous. On error or completion, - the registered send complete callback will be called. - If Synchronous is set to true, the call will block until the packet is sent, if the - interface cannot send the packet within a 2 second timeout, the function will return - the failure code : A_EBUSY. - - Synchronous Mode should only be used at start-up to initialize the HCI device using - custom HCI commands. It should NOT be mixed with Asynchronous operations. Mixed synchronous - and asynchronous operation behavior is undefined. - - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportSendPkt(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous); - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Stop HCI transport - @function name: HCI_TransportStop - @input: HciTrans - hci transport handle - @output: - @return: - @notes: HCI transport communication will be halted. All receive and pending TX packets will - be flushed. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HCI_TransportStop(HCI_TRANSPORT_HANDLE HciTrans); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Start the HCI transport - @function name: HCI_TransportStart - @input: HciTrans - hci transport handle - @output: - @return: 0 on success - @notes: HCI transport communication will begin, the caller can expect the arrival - of HCI recv packets as soon as this call returns. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportStart(HCI_TRANSPORT_HANDLE HciTrans); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Enable or Disable Asynchronous Recv - @function name: HCI_TransportEnableDisableAsyncRecv - @input: HciTrans - hci transport handle - Enable - enable or disable asynchronous recv - @output: - @return: 0 on success - @notes: This API must be called when HCI recv is handled synchronously - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportEnableDisableAsyncRecv(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Receive an event packet from the HCI transport synchronously using polling - @function name: HCI_TransportRecvHCIEventSync - @input: HciTrans - hci transport handle - pPacket - HTC packet to hold the recv data - MaxPollMS - maximum polling duration in Milliseconds; - @output: - @return: 0 on success - @notes: This API should be used only during HCI device initialization, the caller must call - HCI_TransportEnableDisableAsyncRecv with Enable=false prior to using this API. - This API will only capture HCI Event packets. - @example: - @see also: HCI_TransportEnableDisableAsyncRecv -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, - struct htc_packet *pPacket, - int MaxPollMS); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Set the desired baud rate for the underlying transport layer - @function name: HCI_TransportSetBaudRate - @input: HciTrans - hci transport handle - Baud - baud rate in bps - @output: - @return: 0 on success - @notes: This API should be used only after HCI device initialization - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportSetBaudRate(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Enable/Disable HCI Transport Power Management - @function name: HCI_TransportEnablePowerMgmt - @input: HciTrans - hci transport handle - Enable - 1 = Enable, 0 = Disable - @output: - @return: 0 on success - @notes: - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HCI_TransportEnablePowerMgmt(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); - -#ifdef __cplusplus -} -#endif - -#endif /* _HCI_TRANSPORT_API_H_ */ diff --git a/drivers/staging/ath6kl/include/hif.h b/drivers/staging/ath6kl/include/hif.h deleted file mode 100644 index 24200e778c3..00000000000 --- a/drivers/staging/ath6kl/include/hif.h +++ /dev/null @@ -1,456 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HIF specific declarations and prototypes -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HIF_H_ -#define _HIF_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Header files */ -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include "dl_list.h" - - -typedef struct htc_callbacks HTC_CALLBACKS; -struct hif_device; - -/* - * direction - Direction of transfer (HIF_READ/HIF_WRITE). - */ -#define HIF_READ 0x00000001 -#define HIF_WRITE 0x00000002 -#define HIF_DIR_MASK (HIF_READ | HIF_WRITE) - -/* - * type - An interface may support different kind of read/write commands. - * For example: SDIO supports CMD52/CMD53s. In case of MSIO it - * translates to using different kinds of TPCs. The command type - * is thus divided into a basic and an extended command and can - * be specified using HIF_BASIC_IO/HIF_EXTENDED_IO. - */ -#define HIF_BASIC_IO 0x00000004 -#define HIF_EXTENDED_IO 0x00000008 -#define HIF_TYPE_MASK (HIF_BASIC_IO | HIF_EXTENDED_IO) - -/* - * emode - This indicates the whether the command is to be executed in a - * blocking or non-blocking fashion (HIF_SYNCHRONOUS/ - * HIF_ASYNCHRONOUS). The read/write data paths in HTC have been - * implemented using the asynchronous mode allowing the the bus - * driver to indicate the completion of operation through the - * registered callback routine. The requirement primarily comes - * from the contexts these operations get called from (a driver's - * transmit context or the ISR context in case of receive). - * Support for both of these modes is essential. - */ -#define HIF_SYNCHRONOUS 0x00000010 -#define HIF_ASYNCHRONOUS 0x00000020 -#define HIF_EMODE_MASK (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS) - -/* - * dmode - An interface may support different kinds of commands based on - * the tradeoff between the amount of data it can carry and the - * setup time. Byte and Block modes are supported (HIF_BYTE_BASIS/ - * HIF_BLOCK_BASIS). In case of latter, the data is rounded off - * to the nearest block size by padding. The size of the block is - * configurable at compile time using the HIF_BLOCK_SIZE and is - * negotiated with the target during initialization after the - * AR6000 interrupts are enabled. - */ -#define HIF_BYTE_BASIS 0x00000040 -#define HIF_BLOCK_BASIS 0x00000080 -#define HIF_DMODE_MASK (HIF_BYTE_BASIS | HIF_BLOCK_BASIS) - -/* - * amode - This indicates if the address has to be incremented on AR6000 - * after every read/write operation (HIF?FIXED_ADDRESS/ - * HIF_INCREMENTAL_ADDRESS). - */ -#define HIF_FIXED_ADDRESS 0x00000100 -#define HIF_INCREMENTAL_ADDRESS 0x00000200 -#define HIF_AMODE_MASK (HIF_FIXED_ADDRESS | HIF_INCREMENTAL_ADDRESS) - -#define HIF_WR_ASYNC_BYTE_FIX \ - (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS) -#define HIF_WR_ASYNC_BYTE_INC \ - (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_WR_ASYNC_BLOCK_INC \ - (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_WR_SYNC_BYTE_FIX \ - (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS) -#define HIF_WR_SYNC_BYTE_INC \ - (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_WR_SYNC_BLOCK_INC \ - (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_WR_ASYNC_BLOCK_FIX \ - (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS) -#define HIF_WR_SYNC_BLOCK_FIX \ - (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS) -#define HIF_RD_SYNC_BYTE_INC \ - (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_RD_SYNC_BYTE_FIX \ - (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS) -#define HIF_RD_ASYNC_BYTE_FIX \ - (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS) -#define HIF_RD_ASYNC_BLOCK_FIX \ - (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS) -#define HIF_RD_ASYNC_BYTE_INC \ - (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_RD_ASYNC_BLOCK_INC \ - (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_RD_SYNC_BLOCK_INC \ - (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS) -#define HIF_RD_SYNC_BLOCK_FIX \ - (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS) - -typedef enum { - HIF_DEVICE_POWER_STATE = 0, - HIF_DEVICE_GET_MBOX_BLOCK_SIZE, - HIF_DEVICE_GET_MBOX_ADDR, - HIF_DEVICE_GET_PENDING_EVENTS_FUNC, - HIF_DEVICE_GET_IRQ_PROC_MODE, - HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC, - HIF_DEVICE_POWER_STATE_CHANGE, - HIF_DEVICE_GET_IRQ_YIELD_PARAMS, - HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT, - HIF_DEVICE_GET_OS_DEVICE, - HIF_DEVICE_DEBUG_BUS_STATE, -} HIF_DEVICE_CONFIG_OPCODE; - -/* - * HIF CONFIGURE definitions: - * - * HIF_DEVICE_GET_MBOX_BLOCK_SIZE - * input : none - * output : array of 4 u32s - * notes: block size is returned for each mailbox (4) - * - * HIF_DEVICE_GET_MBOX_ADDR - * input : none - * output : struct hif_device_mbox_info - * notes: - * - * HIF_DEVICE_GET_PENDING_EVENTS_FUNC - * input : none - * output: HIF_PENDING_EVENTS_FUNC function pointer - * notes: this is optional for the HIF layer, if the request is - * not handled then it indicates that the upper layer can use - * the standard device methods to get pending events (IRQs, mailbox messages etc..) - * otherwise it can call the function pointer to check pending events. - * - * HIF_DEVICE_GET_IRQ_PROC_MODE - * input : none - * output : HIF_DEVICE_IRQ_PROCESSING_MODE (interrupt processing mode) - * note: the hif layer interfaces with the underlying OS-specific bus driver. The HIF - * layer can report whether IRQ processing is requires synchronous behavior or - * can be processed using asynchronous bus requests (typically faster). - * - * HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC - * input : - * output : HIF_MASK_UNMASK_RECV_EVENT function pointer - * notes: this is optional for the HIF layer. The HIF layer may require a special mechanism - * to mask receive message events. The upper layer can call this pointer when it needs - * to mask/unmask receive events (in case it runs out of buffers). - * - * HIF_DEVICE_POWER_STATE_CHANGE - * - * input : HIF_DEVICE_POWER_CHANGE_TYPE - * output : none - * note: this is optional for the HIF layer. The HIF layer can handle power on/off state change - * requests in an interconnect specific way. This is highly OS and bus driver dependent. - * The caller must guarantee that no HIF read/write requests will be made after the device - * is powered down. - * - * HIF_DEVICE_GET_IRQ_YIELD_PARAMS - * - * input : none - * output : struct hif_device_irq_yield_params - * note: This query checks if the HIF layer wishes to impose a processing yield count for the DSR handler. - * The DSR callback handler will exit after a fixed number of RX packets or events are processed. - * This query is only made if the device reports an IRQ processing mode of HIF_DEVICE_IRQ_SYNC_ONLY. - * The HIF implementation can ignore this command if it does not desire the DSR callback to yield. - * The HIF layer can indicate the maximum number of IRQ processing units (RX packets) before the - * DSR handler callback must yield and return control back to the HIF layer. When a yield limit is - * used the DSR callback will not call HIFAckInterrupts() as it would normally do before returning. - * The HIF implementation that requires a yield count must call HIFAckInterrupt() when it is prepared - * to process interrupts again. - * - * HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT - * input : none - * output : struct hif_device_scatter_support_info - * note: This query checks if the HIF layer implements the SCATTER request interface. Scatter requests - * allows upper layers to submit mailbox I/O operations using a list of buffers. This is useful for - * multi-message transfers that can better utilize the bus interconnect. - * - * - * HIF_DEVICE_GET_OS_DEVICE - * intput : none - * output : struct hif_device_os_device_info; - * note: On some operating systems, the HIF layer has a parent device object for the bus. This object - * may be required to register certain types of logical devices. - * - * HIF_DEVICE_DEBUG_BUS_STATE - * input : none - * output : none - * note: This configure option triggers the HIF interface to dump as much bus interface state. This - * configuration request is optional (No-OP on some HIF implementations) - * - */ - -struct hif_mbox_properties { - u32 ExtendedAddress; /* extended address for larger writes */ - u32 ExtendedSize; -}; - -#define HIF_MBOX_FLAG_NO_BUNDLING (1 << 0) /* do not allow bundling over the mailbox */ - -typedef enum _MBOX_BUF_IF_TYPE { - MBOX_BUS_IF_SDIO = 0, - MBOX_BUS_IF_SPI = 1, -} MBOX_BUF_IF_TYPE; - -struct hif_device_mbox_info { - u32 MboxAddresses[4]; /* must be first element for legacy HIFs that return the address in - and ARRAY of 32-bit words */ - - /* the following describe extended mailbox properties */ - struct hif_mbox_properties MboxProp[4]; - /* if the HIF supports the GMbox extended address region it can report it - * here, some interfaces cannot support the GMBOX address range and not set this */ - u32 GMboxAddress; - u32 GMboxSize; - u32 Flags; /* flags to describe mbox behavior or usage */ - MBOX_BUF_IF_TYPE MboxBusIFType; /* mailbox bus interface type */ -}; - -typedef enum { - HIF_DEVICE_IRQ_SYNC_ONLY, /* for HIF implementations that require the DSR to process all - interrupts before returning */ - HIF_DEVICE_IRQ_ASYNC_SYNC, /* for HIF implementations that allow DSR to process interrupts - using ASYNC I/O (that is HIFAckInterrupt can be called at a - later time */ -} HIF_DEVICE_IRQ_PROCESSING_MODE; - -typedef enum { - HIF_DEVICE_POWER_UP, /* HIF layer should power up interface and/or module */ - HIF_DEVICE_POWER_DOWN, /* HIF layer should initiate bus-specific measures to minimize power */ - HIF_DEVICE_POWER_CUT /* HIF layer should initiate bus-specific AND/OR platform-specific measures - to completely power-off the module and associated hardware (i.e. cut power supplies) - */ -} HIF_DEVICE_POWER_CHANGE_TYPE; - -struct hif_device_irq_yield_params { - int RecvPacketYieldCount; /* max number of packets to force DSR to return */ -}; - - -struct hif_scatter_item { - u8 *pBuffer; /* CPU accessible address of buffer */ - int Length; /* length of transfer to/from this buffer */ - void *pCallerContexts[2]; /* space for caller to insert a context associated with this item */ -}; - -struct hif_scatter_req; -typedef void ( *HIF_SCATTER_COMP_CB)(struct hif_scatter_req *); - -typedef enum _HIF_SCATTER_METHOD { - HIF_SCATTER_NONE = 0, - HIF_SCATTER_DMA_REAL, /* Real SG support no restrictions */ - HIF_SCATTER_DMA_BOUNCE, /* Uses SG DMA but HIF layer uses an internal bounce buffer */ -} HIF_SCATTER_METHOD; - -struct hif_scatter_req { - struct dl_list ListLink; /* link management */ - u32 Address; /* address for the read/write operation */ - u32 Request; /* request flags */ - u32 TotalLength; /* total length of entire transfer */ - u32 CallerFlags; /* caller specific flags can be stored here */ - HIF_SCATTER_COMP_CB CompletionRoutine; /* completion routine set by caller */ - int CompletionStatus; /* status of completion */ - void *Context; /* caller context for this request */ - int ValidScatterEntries; /* number of valid entries set by caller */ - HIF_SCATTER_METHOD ScatterMethod; /* scatter method handled by HIF */ - void *HIFPrivate[4]; /* HIF private area */ - u8 *pScatterBounceBuffer; /* bounce buffer for upper layers to copy to/from */ - struct hif_scatter_item ScatterList[1]; /* start of scatter list */ -}; - -typedef struct hif_scatter_req * ( *HIF_ALLOCATE_SCATTER_REQUEST)(struct hif_device *device); -typedef void ( *HIF_FREE_SCATTER_REQUEST)(struct hif_device *device, struct hif_scatter_req *request); -typedef int ( *HIF_READWRITE_SCATTER)(struct hif_device *device, struct hif_scatter_req *request); - -struct hif_device_scatter_support_info { - /* information returned from HIF layer */ - HIF_ALLOCATE_SCATTER_REQUEST pAllocateReqFunc; - HIF_FREE_SCATTER_REQUEST pFreeReqFunc; - HIF_READWRITE_SCATTER pReadWriteScatterFunc; - int MaxScatterEntries; - int MaxTransferSizePerScatterReq; -}; - -struct hif_device_os_device_info { - void *pOSDevice; -}; - -#define HIF_MAX_DEVICES 1 - -struct htc_callbacks { - void *context; /* context to pass to the dsrhandler - note : rwCompletionHandler is provided the context passed to HIFReadWrite */ - int (* rwCompletionHandler)(void *rwContext, int status); - int (* dsrHandler)(void *context); -}; - -typedef struct osdrv_callbacks { - void *context; /* context to pass for all callbacks except deviceRemovedHandler - the deviceRemovedHandler is only called if the device is claimed */ - int (* deviceInsertedHandler)(void *context, void *hif_handle); - int (* deviceRemovedHandler)(void *claimedContext, void *hif_handle); - int (* deviceSuspendHandler)(void *context); - int (* deviceResumeHandler)(void *context); - int (* deviceWakeupHandler)(void *context); - int (* devicePowerChangeHandler)(void *context, HIF_DEVICE_POWER_CHANGE_TYPE config); -} OSDRV_CALLBACKS; - -#define HIF_OTHER_EVENTS (1 << 0) /* other interrupts (non-Recv) are pending, host - needs to read the register table to figure out what */ -#define HIF_RECV_MSG_AVAIL (1 << 1) /* pending recv packet */ - -struct hif_pending_events_info { - u32 Events; - u32 LookAhead; - u32 AvailableRecvBytes; -#ifdef THREAD_X - u32 Polling; - u32 INT_CAUSE_REG; -#endif -}; - - /* function to get pending events , some HIF modules use special mechanisms - * to detect packet available and other interrupts */ -typedef int ( *HIF_PENDING_EVENTS_FUNC)(struct hif_device *device, - struct hif_pending_events_info *pEvents, - void *AsyncContext); - -#define HIF_MASK_RECV true -#define HIF_UNMASK_RECV false - /* function to mask recv events */ -typedef int ( *HIF_MASK_UNMASK_RECV_EVENT)(struct hif_device *device, - bool Mask, - void *AsyncContext); - - -/* - * This API is used to perform any global initialization of the HIF layer - * and to set OS driver callbacks (i.e. insertion/removal) to the HIF layer - * - */ -int HIFInit(OSDRV_CALLBACKS *callbacks); - -/* This API claims the HIF device and provides a context for handling removal. - * The device removal callback is only called when the OSDRV layer claims - * a device. The claimed context must be non-NULL */ -void HIFClaimDevice(struct hif_device *device, void *claimedContext); -/* release the claimed device */ -void HIFReleaseDevice(struct hif_device *device); - -/* This API allows the HTC layer to attach to the HIF device */ -int HIFAttachHTC(struct hif_device *device, HTC_CALLBACKS *callbacks); -/* This API detaches the HTC layer from the HIF device */ -void HIFDetachHTC(struct hif_device *device); - -/* - * This API is used to provide the read/write interface over the specific bus - * interface. - * address - Starting address in the AR6000's address space. For mailbox - * writes, it refers to the start of the mbox boundary. It should - * be ensured that the last byte falls on the mailbox's EOM. For - * mailbox reads, it refers to the end of the mbox boundary. - * buffer - Pointer to the buffer containg the data to be transmitted or - * received. - * length - Amount of data to be transmitted or received. - * request - Characterizes the attributes of the command. - */ -int -HIFReadWrite(struct hif_device *device, - u32 address, - u8 *buffer, - u32 length, - u32 request, - void *context); - -/* - * This can be initiated from the unload driver context when the OSDRV layer has no more use for - * the device. - */ -void HIFShutDownDevice(struct hif_device *device); - -/* - * This should translate to an acknowledgment to the bus driver indicating that - * the previous interrupt request has been serviced and the all the relevant - * sources have been cleared. HTC is ready to process more interrupts. - * This should prevent the bus driver from raising an interrupt unless the - * previous one has been serviced and acknowledged using the previous API. - */ -void HIFAckInterrupt(struct hif_device *device); - -void HIFMaskInterrupt(struct hif_device *device); - -void HIFUnMaskInterrupt(struct hif_device *device); - -#ifdef THREAD_X -/* - * This set of functions are to be used by the bus driver to notify - * the HIF module about various events. - * These are not implemented if the bus driver provides an alternative - * way for this notification though callbacks for instance. - */ -int HIFInsertEventNotify(void); - -int HIFRemoveEventNotify(void); - -int HIFIRQEventNotify(void); - -int HIFRWCompleteEventNotify(void); -#endif - -int -HIFConfigureDevice(struct hif_device *device, HIF_DEVICE_CONFIG_OPCODE opcode, - void *config, u32 configLen); - -/* - * This API wait for the remaining MBOX messages to be drained - * This should be moved to HTC AR6K layer - */ -int hifWaitForPendingRecv(struct hif_device *device); - -#ifdef __cplusplus -} -#endif - -#endif /* _HIF_H_ */ diff --git a/drivers/staging/ath6kl/include/host_version.h b/drivers/staging/ath6kl/include/host_version.h deleted file mode 100644 index 74f1982c681..00000000000 --- a/drivers/staging/ath6kl/include/host_version.h +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains version information for the sample host driver for the -// AR6000 chip -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HOST_VERSION_H_ -#define _HOST_VERSION_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* - * The version number is made up of major, minor, patch and build - * numbers. These are 16 bit numbers. The build and release script will - * set the build number using a Perforce counter. Here the build number is - * set to 9999 so that builds done without the build-release script are easily - * identifiable. - */ - -#define ATH_SW_VER_MAJOR __VER_MAJOR_ -#define ATH_SW_VER_MINOR __VER_MINOR_ -#define ATH_SW_VER_PATCH __VER_PATCH_ -#define ATH_SW_VER_BUILD __BUILD_NUMBER_ - -#ifdef __cplusplus -} -#endif - -#endif /* _HOST_VERSION_H_ */ diff --git a/drivers/staging/ath6kl/include/htc_api.h b/drivers/staging/ath6kl/include/htc_api.h deleted file mode 100644 index 4fb767559f8..00000000000 --- a/drivers/staging/ath6kl/include/htc_api.h +++ /dev/null @@ -1,575 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HTC_API_H_ -#define _HTC_API_H_ - -#include "htc_packet.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* TODO.. for BMI */ -#define ENDPOINT1 0 -// TODO -remove me, but we have to fix BMI first -#define HTC_MAILBOX_NUM_MAX 4 - -/* this is the amount of header room required by users of HTC */ -#define HTC_HEADER_LEN HTC_HDR_LENGTH - -typedef void *HTC_HANDLE; - -typedef u16 HTC_SERVICE_ID; - -struct htc_init_info { - void *pContext; /* context for target failure notification */ - void (*TargetFailure)(void *Instance, int Status); -}; - -/* per service connection send completion */ -typedef void (*HTC_EP_SEND_PKT_COMPLETE)(void *,struct htc_packet *); -/* per service connection callback when a plurality of packets have been sent - * The struct htc_packet_queue is a temporary queue object (e.g. freed on return from the callback) - * to hold a list of completed send packets. - * If the handler cannot fully traverse the packet queue before returning, it should - * transfer the items of the queue into the caller's private queue using: - * HTC_PACKET_ENQUEUE() */ -typedef void (*HTC_EP_SEND_PKT_COMP_MULTIPLE)(void *,struct htc_packet_queue *); -/* per service connection pkt received */ -typedef void (*HTC_EP_RECV_PKT)(void *,struct htc_packet *); -/* per service connection callback when a plurality of packets are received - * The struct htc_packet_queue is a temporary queue object (e.g. freed on return from the callback) - * to hold a list of recv packets. - * If the handler cannot fully traverse the packet queue before returning, it should - * transfer the items of the queue into the caller's private queue using: - * HTC_PACKET_ENQUEUE() */ -typedef void (*HTC_EP_RECV_PKT_MULTIPLE)(void *,struct htc_packet_queue *); - -/* Optional per service connection receive buffer re-fill callback, - * On some OSes (like Linux) packets are allocated from a global pool and indicated up - * to the network stack. The driver never gets the packets back from the OS. For these OSes - * a refill callback can be used to allocate and re-queue buffers into HTC. - * - * On other OSes, the network stack can call into the driver's OS-specifc "return_packet" handler and - * the driver can re-queue these buffers into HTC. In this regard a refill callback is - * unnecessary */ -typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint); - -/* Optional per service connection receive buffer allocation callback. - * On some systems packet buffers are an extremely limited resource. Rather than - * queue largest-possible-sized buffers to HTC, some systems would rather - * allocate a specific size as the packet is received. The trade off is - * slightly more processing (callback invoked for each RX packet) - * for the benefit of committing fewer buffer resources into HTC. - * - * The callback is provided the length of the pending packet to fetch. This includes the - * HTC header length plus the length of payload. The callback can return a pointer to - * the allocated HTC packet for immediate use. - * - * Alternatively a variant of this handler can be used to allocate large receive packets as needed. - * For example an application can use the refill mechanism for normal packets and the recv-alloc mechanism to - * handle the case where a large packet buffer is required. This can significantly reduce the - * amount of "committed" memory used to receive packets. - * - * */ -typedef struct htc_packet *(*HTC_EP_RECV_ALLOC)(void *, HTC_ENDPOINT_ID Endpoint, int Length); - -typedef enum _HTC_SEND_FULL_ACTION { - HTC_SEND_FULL_KEEP = 0, /* packet that overflowed should be kept in the queue */ - HTC_SEND_FULL_DROP = 1, /* packet that overflowed should be dropped */ -} HTC_SEND_FULL_ACTION; - -/* Optional per service connection callback when a send queue is full. This can occur if the - * host continues queueing up TX packets faster than credits can arrive - * To prevent the host (on some Oses like Linux) from continuously queueing packets - * and consuming resources, this callback is provided so that that the host - * can disable TX in the subsystem (i.e. network stack). - * This callback is invoked for each packet that "overflows" the HTC queue. The callback can - * determine whether the new packet that overflowed the queue can be kept (HTC_SEND_FULL_KEEP) or - * dropped (HTC_SEND_FULL_DROP). If a packet is dropped, the EpTxComplete handler will be called - * and the packet's status field will be set to A_NO_RESOURCE. - * Other OSes require a "per-packet" indication for each completed TX packet, this - * closed loop mechanism will prevent the network stack from overunning the NIC - * The packet to keep or drop is passed for inspection to the registered handler the handler - * must ONLY inspect the packet, it may not free or reclaim the packet. */ -typedef HTC_SEND_FULL_ACTION (*HTC_EP_SEND_QUEUE_FULL)(void *, struct htc_packet *pPacket); - -struct htc_ep_callbacks { - void *pContext; /* context for each callback */ - HTC_EP_SEND_PKT_COMPLETE EpTxComplete; /* tx completion callback for connected endpoint */ - HTC_EP_RECV_PKT EpRecv; /* receive callback for connected endpoint */ - HTC_EP_RECV_REFILL EpRecvRefill; /* OPTIONAL receive re-fill callback for connected endpoint */ - HTC_EP_SEND_QUEUE_FULL EpSendFull; /* OPTIONAL send full callback */ - HTC_EP_RECV_ALLOC EpRecvAlloc; /* OPTIONAL recv allocation callback */ - HTC_EP_RECV_ALLOC EpRecvAllocThresh; /* OPTIONAL recv allocation callback based on a threshold */ - HTC_EP_SEND_PKT_COMP_MULTIPLE EpTxCompleteMultiple; /* OPTIONAL completion handler for multiple complete - indications (EpTxComplete must be NULL) */ - HTC_EP_RECV_PKT_MULTIPLE EpRecvPktMultiple; /* OPTIONAL completion handler for multiple - recv packet indications (EpRecv must be NULL) */ - int RecvAllocThreshold; /* if EpRecvAllocThresh is non-NULL, HTC will compare the - threshold value to the current recv packet length and invoke - the EpRecvAllocThresh callback to acquire a packet buffer */ - int RecvRefillWaterMark; /* if a EpRecvRefill handler is provided, this value - can be used to set a trigger refill callback - when the recv queue drops below this value - if set to 0, the refill is only called when packets - are empty */ -}; - -/* service connection information */ -struct htc_service_connect_req { - HTC_SERVICE_ID ServiceID; /* service ID to connect to */ - u16 ConnectionFlags; /* connection flags, see htc protocol definition */ - u8 *pMetaData; /* ptr to optional service-specific meta-data */ - u8 MetaDataLength; /* optional meta data length */ - struct htc_ep_callbacks EpCallbacks; /* endpoint callbacks */ - int MaxSendQueueDepth; /* maximum depth of any send queue */ - u32 LocalConnectionFlags; /* HTC flags for the host-side (local) connection */ - unsigned int MaxSendMsgSize; /* override max message size in send direction */ -}; - -#define HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING (1 << 0) /* enable send bundle padding for this endpoint */ - -/* service connection response information */ -struct htc_service_connect_resp { - u8 *pMetaData; /* caller supplied buffer to optional meta-data */ - u8 BufferLength; /* length of caller supplied buffer */ - u8 ActualLength; /* actual length of meta data */ - HTC_ENDPOINT_ID Endpoint; /* endpoint to communicate over */ - unsigned int MaxMsgLength; /* max length of all messages over this endpoint */ - u8 ConnectRespCode; /* connect response code from target */ -}; - -/* endpoint distribution structure */ -struct htc_endpoint_credit_dist { - struct htc_endpoint_credit_dist *pNext; - struct htc_endpoint_credit_dist *pPrev; - HTC_SERVICE_ID ServiceID; /* Service ID (set by HTC) */ - HTC_ENDPOINT_ID Endpoint; /* endpoint for this distribution struct (set by HTC) */ - u32 DistFlags; /* distribution flags, distribution function can - set default activity using SET_EP_ACTIVE() macro */ - int TxCreditsNorm; /* credits for normal operation, anything above this - indicates the endpoint is over-subscribed, this field - is only relevant to the credit distribution function */ - int TxCreditsMin; /* floor for credit distribution, this field is - only relevant to the credit distribution function */ - int TxCreditsAssigned; /* number of credits assigned to this EP, this field - is only relevant to the credit dist function */ - int TxCredits; /* current credits available, this field is used by - HTC to determine whether a message can be sent or - must be queued */ - int TxCreditsToDist; /* pending credits to distribute on this endpoint, this - is set by HTC when credit reports arrive. - The credit distribution functions sets this to zero - when it distributes the credits */ - int TxCreditsSeek; /* this is the number of credits that the current pending TX - packet needs to transmit. This is set by HTC when - and endpoint needs credits in order to transmit */ - int TxCreditSize; /* size in bytes of each credit (set by HTC) */ - int TxCreditsPerMaxMsg; /* credits required for a maximum sized messages (set by HTC) */ - void *pHTCReserved; /* reserved for HTC use */ - int TxQueueDepth; /* current depth of TX queue , i.e. messages waiting for credits - This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE - or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint - that has non-zero credits to recover - */ -}; - -#define HTC_EP_ACTIVE ((u32) (1u << 31)) - -/* macro to check if an endpoint has gone active, useful for credit - * distributions */ -#define IS_EP_ACTIVE(epDist) ((epDist)->DistFlags & HTC_EP_ACTIVE) -#define SET_EP_ACTIVE(epDist) (epDist)->DistFlags |= HTC_EP_ACTIVE - - /* credit distibution code that is passed into the distrbution function, - * there are mandatory and optional codes that must be handled */ -typedef enum _HTC_CREDIT_DIST_REASON { - HTC_CREDIT_DIST_SEND_COMPLETE = 0, /* credits available as a result of completed - send operations (MANDATORY) resulting in credit reports */ - HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1, /* a change in endpoint activity occurred (OPTIONAL) */ - HTC_CREDIT_DIST_SEEK_CREDITS, /* an endpoint needs to "seek" credits (OPTIONAL) */ - HTC_DUMP_CREDIT_STATE /* for debugging, dump any state information that is kept by - the distribution function */ -} HTC_CREDIT_DIST_REASON; - -typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context, - struct htc_endpoint_credit_dist *pEPList, - HTC_CREDIT_DIST_REASON Reason); - -typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context, - struct htc_endpoint_credit_dist *pEPList, - int TotalCredits); - - /* endpoint statistics action */ -typedef enum _HTC_ENDPOINT_STAT_ACTION { - HTC_EP_STAT_SAMPLE = 0, /* only read statistics */ - HTC_EP_STAT_SAMPLE_AND_CLEAR = 1, /* sample and immediately clear statistics */ - HTC_EP_STAT_CLEAR /* clear only */ -} HTC_ENDPOINT_STAT_ACTION; - - /* endpoint statistics */ -struct htc_endpoint_stats { - u32 TxCreditLowIndications; /* number of times the host set the credit-low flag in a send message on - this endpoint */ - u32 TxIssued; /* running count of total TX packets issued */ - u32 TxPacketsBundled; /* running count of TX packets that were issued in bundles */ - u32 TxBundles; /* running count of TX bundles that were issued */ - u32 TxDropped; /* tx packets that were dropped */ - u32 TxCreditRpts; /* running count of total credit reports received for this endpoint */ - u32 TxCreditRptsFromRx; /* credit reports received from this endpoint's RX packets */ - u32 TxCreditRptsFromOther; /* credit reports received from RX packets of other endpoints */ - u32 TxCreditRptsFromEp0; /* credit reports received from endpoint 0 RX packets */ - u32 TxCreditsFromRx; /* count of credits received via Rx packets on this endpoint */ - u32 TxCreditsFromOther; /* count of credits received via another endpoint */ - u32 TxCreditsFromEp0; /* count of credits received via another endpoint */ - u32 TxCreditsConsummed; /* count of consummed credits */ - u32 TxCreditsReturned; /* count of credits returned */ - u32 RxReceived; /* count of RX packets received */ - u32 RxLookAheads; /* count of lookahead records - found in messages received on this endpoint */ - u32 RxPacketsBundled; /* count of recv packets received in a bundle */ - u32 RxBundleLookAheads; /* count of number of bundled lookaheads */ - u32 RxBundleIndFromHdr; /* count of the number of bundle indications from the HTC header */ - u32 RxAllocThreshHit; /* count of the number of times the recv allocation threshold was hit */ - u32 RxAllocThreshBytes; /* total number of bytes */ -}; - -/* ------ Function Prototypes ------ */ -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Create an instance of HTC over the underlying HIF device - @function name: HTCCreate - @input: HifDevice - hif device handle, - pInfo - initialization information - @output: - @return: HTC_HANDLE on success, NULL on failure - @notes: - @example: - @see also: HTCDestroy -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -HTC_HANDLE HTCCreate(void *HifDevice, struct htc_init_info *pInfo); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Get the underlying HIF device handle - @function name: HTCGetHifDevice - @input: HTCHandle - handle passed into the AddInstance callback - @output: - @return: opaque HIF device handle usable in HIF API calls. - @notes: - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void *HTCGetHifDevice(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Set credit distribution parameters - @function name: HTCSetCreditDistribution - @input: HTCHandle - HTC handle - pCreditDistCont - caller supplied context to pass into distribution functions - CreditDistFunc - Distribution function callback - CreditDistInit - Credit Distribution initialization callback - ServicePriorityOrder - Array containing list of service IDs, lowest index is highest - priority - ListLength - number of elements in ServicePriorityOrder - @output: - @return: - @notes: The user can set a custom credit distribution function to handle special requirements - for each endpoint. A default credit distribution routine can be used by setting - CreditInitFunc to NULL. The default credit distribution is only provided for simple - "fair" credit distribution without regard to any prioritization. - - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCSetCreditDistribution(HTC_HANDLE HTCHandle, - void *pCreditDistContext, - HTC_CREDIT_DIST_CALLBACK CreditDistFunc, - HTC_CREDIT_INIT_CALLBACK CreditInitFunc, - HTC_SERVICE_ID ServicePriorityOrder[], - int ListLength); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Wait for the target to indicate the HTC layer is ready - @function name: HTCWaitTarget - @input: HTCHandle - HTC handle - @output: - @return: - @notes: This API blocks until the target responds with an HTC ready message. - The caller should not connect services until the target has indicated it is - ready. - @example: - @see also: HTCConnectService -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCWaitTarget(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Start target service communications - @function name: HTCStart - @input: HTCHandle - HTC handle - @output: - @return: - @notes: This API indicates to the target that the service connection phase is complete - and the target can freely start all connected services. This API should only be - called AFTER all service connections have been made. TCStart will issue a - SETUP_COMPLETE message to the target to indicate that all service connections - have been made and the target can start communicating over the endpoints. - @example: - @see also: HTCConnectService -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCStart(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Add receive packet to HTC - @function name: HTCAddReceivePkt - @input: HTCHandle - HTC handle - pPacket - HTC receive packet to add - @output: - @return: 0 on success - @notes: user must supply HTC packets for capturing incomming HTC frames. The caller - must initialize each HTC packet using the SET_HTC_PACKET_INFO_RX_REFILL() - macro. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCAddReceivePkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Connect to an HTC service - @function name: HTCConnectService - @input: HTCHandle - HTC handle - pReq - connection details - @output: pResp - connection response - @return: - @notes: Service connections must be performed before HTCStart. User provides callback handlers - for various endpoint events. - @example: - @see also: HTCStart -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCConnectService(HTC_HANDLE HTCHandle, - struct htc_service_connect_req *pReq, - struct htc_service_connect_resp *pResp); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Send an HTC packet - @function name: HTCSendPkt - @input: HTCHandle - HTC handle - pPacket - packet to send - @output: - @return: 0 - @notes: Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro. - This interface is fully asynchronous. On error, HTC SendPkt will - call the registered Endpoint callback to cleanup the packet. - @example: - @see also: HTCFlushEndpoint -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCSendPkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Stop HTC service communications - @function name: HTCStop - @input: HTCHandle - HTC handle - @output: - @return: - @notes: HTC communications is halted. All receive and pending TX packets will - be flushed. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCStop(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Destroy HTC service - @function name: HTCDestroy - @input: HTCHandle - @output: - @return: - @notes: This cleans up all resources allocated by HTCCreate(). - @example: - @see also: HTCCreate -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCDestroy(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Flush pending TX packets - @function name: HTCFlushEndpoint - @input: HTCHandle - HTC handle - Endpoint - Endpoint to flush - Tag - flush tag - @output: - @return: - @notes: The Tag parameter is used to selectively flush packets with matching tags. - The value of 0 forces all packets to be flush regardless of tag. - @example: - @see also: HTCSendPkt -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Dump credit distribution state - @function name: HTCDumpCreditStates - @input: HTCHandle - HTC handle - @output: - @return: - @notes: This dumps all credit distribution information to the debugger - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCDumpCreditStates(HTC_HANDLE HTCHandle); -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Indicate a traffic activity change on an endpoint - @function name: HTCIndicateActivityChange - @input: HTCHandle - HTC handle - Endpoint - endpoint in which activity has changed - Active - true if active, false if it has become inactive - @output: - @return: - @notes: This triggers the registered credit distribution function to - re-adjust credits for active/inactive endpoints. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCIndicateActivityChange(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint, - bool Active); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Get endpoint statistics - @function name: HTCGetEndpointStatistics - @input: HTCHandle - HTC handle - Endpoint - Endpoint identifier - Action - action to take with statistics - @output: - pStats - statistics that were sampled (can be NULL if Action is HTC_EP_STAT_CLEAR) - - @return: true if statistics profiling is enabled, otherwise false. - - @notes: Statistics is a compile-time option and this function may return false - if HTC is not compiled with profiling. - - The caller can specify the statistic "action" to take when sampling - the statistics. This includes: - - HTC_EP_STAT_SAMPLE: The pStats structure is filled with the current values. - HTC_EP_STAT_SAMPLE_AND_CLEAR: The structure is filled and the current statistics - are cleared. - HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass a NULL value for - pStats - - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -bool HTCGetEndpointStatistics(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint, - HTC_ENDPOINT_STAT_ACTION Action, - struct htc_endpoint_stats *pStats); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Unblock HTC message reception - @function name: HTCUnblockRecv - @input: HTCHandle - HTC handle - @output: - @return: - @notes: - HTC will block the receiver if the EpRecvAlloc callback fails to provide a packet. - The caller can use this API to indicate to HTC when resources (buffers) are available - such that the receiver can be unblocked and HTC may re-attempt fetching the pending message. - - This API is not required if the user uses the EpRecvRefill callback or uses the HTCAddReceivePacket() - API to recycle or provide receive packets to HTC. - - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void HTCUnblockRecv(HTC_HANDLE HTCHandle); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: send a series of HTC packets - @function name: HTCSendPktsMultiple - @input: HTCHandle - HTC handle - pPktQueue - local queue holding packets to send - @output: - @return: 0 - @notes: Caller must initialize each packet using SET_HTC_PACKET_INFO_TX() macro. - The queue must only contain packets directed at the same endpoint. - Caller supplies a pointer to an struct htc_packet_queue structure holding the TX packets in FIFO order. - This API will remove the packets from the pkt queue and place them into the HTC Tx Queue - and bundle messages where possible. - The caller may allocate the pkt queue on the stack to hold the packets. - This interface is fully asynchronous. On error, HTCSendPkts will - call the registered Endpoint callback to cleanup the packet. - @example: - @see also: HTCFlushEndpoint -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCSendPktsMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Add multiple receive packets to HTC - @function name: HTCAddReceivePktMultiple - @input: HTCHandle - HTC handle - pPktQueue - HTC receive packet queue holding packets to add - @output: - @return: 0 on success - @notes: user must supply HTC packets for capturing incomming HTC frames. The caller - must initialize each HTC packet using the SET_HTC_PACKET_INFO_RX_REFILL() - macro. The queue must only contain recv packets for the same endpoint. - Caller supplies a pointer to an struct htc_packet_queue structure holding the recv packet. - This API will remove the packets from the pkt queue and place them into internal - recv packet list. - The caller may allocate the pkt queue on the stack to hold the packets. - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue); - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Check if an endpoint is marked active - @function name: HTCIsEndpointActive - @input: HTCHandle - HTC handle - Endpoint - endpoint to check for active state - @output: - @return: returns true if Endpoint is Active - @notes: - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -bool HTCIsEndpointActive(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint); - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @desc: Get the number of recv buffers currently queued into an HTC endpoint - @function name: HTCGetNumRecvBuffers - @input: HTCHandle - HTC handle - Endpoint - endpoint to check - @output: - @return: returns number of buffers in queue - @notes: - @example: - @see also: -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int HTCGetNumRecvBuffers(HTC_HANDLE HTCHandle, - HTC_ENDPOINT_ID Endpoint); - -/* internally used functions for testing... */ -void HTCEnableRecv(HTC_HANDLE HTCHandle); -void HTCDisableRecv(HTC_HANDLE HTCHandle); -int HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, - u32 TimeoutInMs, - bool *pbIsRecvPending); - -#ifdef __cplusplus -} -#endif - -#endif /* _HTC_API_H_ */ diff --git a/drivers/staging/ath6kl/include/htc_packet.h b/drivers/staging/ath6kl/include/htc_packet.h deleted file mode 100644 index ba65c34ebc9..00000000000 --- a/drivers/staging/ath6kl/include/htc_packet.h +++ /dev/null @@ -1,227 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef HTC_PACKET_H_ -#define HTC_PACKET_H_ - - -#include "dl_list.h" - -/* ------ Endpoint IDS ------ */ -typedef enum -{ - ENDPOINT_UNUSED = -1, - ENDPOINT_0 = 0, - ENDPOINT_1 = 1, - ENDPOINT_2 = 2, - ENDPOINT_3, - ENDPOINT_4, - ENDPOINT_5, - ENDPOINT_6, - ENDPOINT_7, - ENDPOINT_8, - ENDPOINT_MAX, -} HTC_ENDPOINT_ID; - -struct htc_packet; - -typedef void (* HTC_PACKET_COMPLETION)(void *,struct htc_packet *); - -typedef u16 HTC_TX_TAG; - -struct htc_tx_packet_info { - HTC_TX_TAG Tag; /* tag used to selective flush packets */ - int CreditsUsed; /* number of credits used for this TX packet (HTC internal) */ - u8 SendFlags; /* send flags (HTC internal) */ - int SeqNo; /* internal seq no for debugging (HTC internal) */ -}; - -#define HTC_TX_PACKET_TAG_ALL 0 /* a tag of zero is reserved and used to flush ALL packets */ -#define HTC_TX_PACKET_TAG_INTERNAL 1 /* internal tags start here */ -#define HTC_TX_PACKET_TAG_USER_DEFINED (HTC_TX_PACKET_TAG_INTERNAL + 9) /* user-defined tags start here */ - -struct htc_rx_packet_info { - u32 ExpectedHdr; /* HTC internal use */ - u32 HTCRxFlags; /* HTC internal use */ - u32 IndicationFlags; /* indication flags set on each RX packet indication */ -}; - -#define HTC_RX_FLAGS_INDICATE_MORE_PKTS (1 << 0) /* more packets on this endpoint are being fetched */ - -/* wrapper around endpoint-specific packets */ -struct htc_packet { - struct dl_list ListLink; /* double link */ - void *pPktContext; /* caller's per packet specific context */ - - u8 *pBufferStart; /* the true buffer start , the caller can - store the real buffer start here. In - receive callbacks, the HTC layer sets pBuffer - to the start of the payload past the header. This - field allows the caller to reset pBuffer when it - recycles receive packets back to HTC */ - /* - * Pointer to the start of the buffer. In the transmit - * direction this points to the start of the payload. In the - * receive direction, however, the buffer when queued up - * points to the start of the HTC header but when returned - * to the caller points to the start of the payload - */ - u8 *pBuffer; /* payload start (RX/TX) */ - u32 BufferLength; /* length of buffer */ - u32 ActualLength; /* actual length of payload */ - HTC_ENDPOINT_ID Endpoint; /* endpoint that this packet was sent/recv'd from */ - int Status; /* completion status */ - union { - struct htc_tx_packet_info AsTx; /* Tx Packet specific info */ - struct htc_rx_packet_info AsRx; /* Rx Packet specific info */ - } PktInfo; - - /* the following fields are for internal HTC use */ - HTC_PACKET_COMPLETION Completion; /* completion */ - void *pContext; /* HTC private completion context */ -}; - - - -#define COMPLETE_HTC_PACKET(p,status) \ -{ \ - (p)->Status = (status); \ - (p)->Completion((p)->pContext,(p)); \ -} - -#define INIT_HTC_PACKET_INFO(p,b,len) \ -{ \ - (p)->pBufferStart = (b); \ - (p)->BufferLength = (len); \ -} - -/* macro to set an initial RX packet for refilling HTC */ -#define SET_HTC_PACKET_INFO_RX_REFILL(p,c,b,len,ep) \ -{ \ - (p)->pPktContext = (c); \ - (p)->pBuffer = (b); \ - (p)->pBufferStart = (b); \ - (p)->BufferLength = (len); \ - (p)->Endpoint = (ep); \ -} - -/* fast macro to recycle an RX packet that will be re-queued to HTC */ -#define HTC_PACKET_RESET_RX(p) \ - { (p)->pBuffer = (p)->pBufferStart; (p)->ActualLength = 0; } - -/* macro to set packet parameters for TX */ -#define SET_HTC_PACKET_INFO_TX(p,c,b,len,ep,tag) \ -{ \ - (p)->pPktContext = (c); \ - (p)->pBuffer = (b); \ - (p)->ActualLength = (len); \ - (p)->Endpoint = (ep); \ - (p)->PktInfo.AsTx.Tag = (tag); \ -} - -/* HTC Packet Queueing Macros */ -struct htc_packet_queue { - struct dl_list QueueHead; - int Depth; -}; - -/* initialize queue */ -#define INIT_HTC_PACKET_QUEUE(pQ) \ -{ \ - DL_LIST_INIT(&(pQ)->QueueHead); \ - (pQ)->Depth = 0; \ -} - -/* enqueue HTC packet to the tail of the queue */ -#define HTC_PACKET_ENQUEUE(pQ,p) \ -{ DL_ListInsertTail(&(pQ)->QueueHead,&(p)->ListLink); \ - (pQ)->Depth++; \ -} - -/* enqueue HTC packet to the tail of the queue */ -#define HTC_PACKET_ENQUEUE_TO_HEAD(pQ,p) \ -{ DL_ListInsertHead(&(pQ)->QueueHead,&(p)->ListLink); \ - (pQ)->Depth++; \ -} -/* test if a queue is empty */ -#define HTC_QUEUE_EMPTY(pQ) ((pQ)->Depth == 0) -/* get packet at head without removing it */ -static INLINE struct htc_packet *HTC_GET_PKT_AT_HEAD(struct htc_packet_queue *queue) { - if (queue->Depth == 0) { - return NULL; - } - return A_CONTAINING_STRUCT((DL_LIST_GET_ITEM_AT_HEAD(&queue->QueueHead)),struct htc_packet,ListLink); -} -/* remove a packet from a queue, where-ever it is in the queue */ -#define HTC_PACKET_REMOVE(pQ,p) \ -{ \ - DL_ListRemove(&(p)->ListLink); \ - (pQ)->Depth--; \ -} - -/* dequeue an HTC packet from the head of the queue */ -static INLINE struct htc_packet *HTC_PACKET_DEQUEUE(struct htc_packet_queue *queue) { - struct dl_list *pItem = DL_ListRemoveItemFromHead(&queue->QueueHead); - if (pItem != NULL) { - queue->Depth--; - return A_CONTAINING_STRUCT(pItem, struct htc_packet, ListLink); - } - return NULL; -} - -/* dequeue an HTC packet from the tail of the queue */ -static INLINE struct htc_packet *HTC_PACKET_DEQUEUE_TAIL(struct htc_packet_queue *queue) { - struct dl_list *pItem = DL_ListRemoveItemFromTail(&queue->QueueHead); - if (pItem != NULL) { - queue->Depth--; - return A_CONTAINING_STRUCT(pItem, struct htc_packet, ListLink); - } - return NULL; -} - -#define HTC_PACKET_QUEUE_DEPTH(pQ) (pQ)->Depth - - -#define HTC_GET_ENDPOINT_FROM_PKT(p) (p)->Endpoint -#define HTC_GET_TAG_FROM_PKT(p) (p)->PktInfo.AsTx.Tag - - /* transfer the packets from one queue to the tail of another queue */ -#define HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(pQDest,pQSrc) \ -{ \ - DL_ListTransferItemsToTail(&(pQDest)->QueueHead,&(pQSrc)->QueueHead); \ - (pQDest)->Depth += (pQSrc)->Depth; \ - (pQSrc)->Depth = 0; \ -} - - /* fast version to init and add a single packet to a queue */ -#define INIT_HTC_PACKET_QUEUE_AND_ADD(pQ,pP) \ -{ \ - DL_LIST_INIT_AND_ADD(&(pQ)->QueueHead,&(pP)->ListLink) \ - (pQ)->Depth = 1; \ -} - -#define HTC_PACKET_QUEUE_ITERATE_ALLOW_REMOVE(pQ, pPTemp) \ - ITERATE_OVER_LIST_ALLOW_REMOVE(&(pQ)->QueueHead,(pPTemp), struct htc_packet, ListLink) - -#define HTC_PACKET_QUEUE_ITERATE_END ITERATE_END - -#endif /*HTC_PACKET_H_*/ diff --git a/drivers/staging/ath6kl/include/wlan_api.h b/drivers/staging/ath6kl/include/wlan_api.h deleted file mode 100644 index 9eea5875dd3..00000000000 --- a/drivers/staging/ath6kl/include/wlan_api.h +++ /dev/null @@ -1,128 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the API for the host wlan module -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HOST_WLAN_API_H_ -#define _HOST_WLAN_API_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct ieee80211_node_table; -struct ieee80211_frame; - -struct ieee80211_common_ie { - u16 ie_chan; - u8 *ie_tstamp; - u8 *ie_ssid; - u8 *ie_rates; - u8 *ie_xrates; - u8 *ie_country; - u8 *ie_wpa; - u8 *ie_rsn; - u8 *ie_wmm; - u8 *ie_ath; - u16 ie_capInfo; - u16 ie_beaconInt; - u8 *ie_tim; - u8 *ie_chswitch; - u8 ie_erp; - u8 *ie_wsc; - u8 *ie_htcap; - u8 *ie_htop; -#ifdef WAPI_ENABLE - u8 *ie_wapi; -#endif -}; - -typedef struct bss { - u8 ni_macaddr[6]; - u8 ni_snr; - s16 ni_rssi; - struct bss *ni_list_next; - struct bss *ni_list_prev; - struct bss *ni_hash_next; - struct bss *ni_hash_prev; - struct ieee80211_common_ie ni_cie; - u8 *ni_buf; - u16 ni_framelen; - struct ieee80211_node_table *ni_table; - u32 ni_refcnt; - int ni_scangen; - - u32 ni_tstamp; - u32 ni_actcnt; -#ifdef OS_ROAM_MANAGEMENT - u32 ni_si_gen; -#endif -} bss_t; - -typedef void wlan_node_iter_func(void *arg, bss_t *); - -bss_t *wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size); -void wlan_node_free(bss_t *ni); -void wlan_setup_node(struct ieee80211_node_table *nt, bss_t *ni, - const u8 *macaddr); -bss_t *wlan_find_node(struct ieee80211_node_table *nt, const u8 *macaddr); -void wlan_node_reclaim(struct ieee80211_node_table *nt, bss_t *ni); -void wlan_free_allnodes(struct ieee80211_node_table *nt); -void wlan_iterate_nodes(struct ieee80211_node_table *nt, wlan_node_iter_func *f, - void *arg); - -void wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt); -void wlan_node_table_reset(struct ieee80211_node_table *nt); -void wlan_node_table_cleanup(struct ieee80211_node_table *nt); - -int wlan_parse_beacon(u8 *buf, int framelen, - struct ieee80211_common_ie *cie); - -u16 wlan_ieee2freq(int chan); -u32 wlan_freq2ieee(u16 freq); - -void wlan_set_nodeage(struct ieee80211_node_table *nt, u32 nodeAge); - -void -wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt); - -bss_t * -wlan_find_Ssidnode (struct ieee80211_node_table *nt, u8 *pSsid, - u32 ssidLength, bool bIsWPA2, bool bMatchSSID); - -void -wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni); - -bss_t *wlan_node_remove(struct ieee80211_node_table *nt, u8 *bssid); - -bss_t * -wlan_find_matching_Ssidnode (struct ieee80211_node_table *nt, u8 *pSsid, - u32 ssidLength, u32 dot11AuthMode, u32 authMode, - u32 pairwiseCryptoType, u32 grpwiseCryptoTyp); - -#ifdef __cplusplus -} -#endif - -#endif /* _HOST_WLAN_API_H_ */ diff --git a/drivers/staging/ath6kl/include/wmi_api.h b/drivers/staging/ath6kl/include/wmi_api.h deleted file mode 100644 index c8583e0c4a9..00000000000 --- a/drivers/staging/ath6kl/include/wmi_api.h +++ /dev/null @@ -1,441 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the definitions for the Wireless Module Interface (WMI). -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _WMI_API_H_ -#define _WMI_API_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - /* WMI converts a dix frame with an ethernet payload (up to 1500 bytes) - * to an 802.3 frame (adds SNAP header) and adds on a WMI data header */ -#define WMI_MAX_TX_DATA_FRAME_LENGTH (1500 + sizeof(WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) + sizeof(ATH_LLC_SNAP_HDR)) - - /* A normal WMI data frame */ -#define WMI_MAX_NORMAL_RX_DATA_FRAME_LENGTH (1500 + sizeof(WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) + sizeof(ATH_LLC_SNAP_HDR)) - - /* An AMSDU frame */ /* The MAX AMSDU length of AR6003 is 3839 */ -#define WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH (3840 + sizeof(WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) + sizeof(ATH_LLC_SNAP_HDR)) - -/* - * IP QoS Field definitions according to 802.1p - */ -#define BEST_EFFORT_PRI 0 -#define BACKGROUND_PRI 1 -#define EXCELLENT_EFFORT_PRI 3 -#define CONTROLLED_LOAD_PRI 4 -#define VIDEO_PRI 5 -#define VOICE_PRI 6 -#define NETWORK_CONTROL_PRI 7 -#define MAX_NUM_PRI 8 - -#define UNDEFINED_PRI (0xff) - -#define WMI_IMPLICIT_PSTREAM_INACTIVITY_INT 5000 /* 5 seconds */ - -#define A_ROUND_UP(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) - -typedef enum { - ATHEROS_COMPLIANCE = 0x1, -}TSPEC_PARAM_COMPLIANCE; - -struct wmi_t; - -void *wmi_init(void *devt); - -void wmi_qos_state_init(struct wmi_t *wmip); -void wmi_shutdown(struct wmi_t *wmip); -HTC_ENDPOINT_ID wmi_get_control_ep(struct wmi_t * wmip); -void wmi_set_control_ep(struct wmi_t * wmip, HTC_ENDPOINT_ID eid); -u16 wmi_get_mapped_qos_queue(struct wmi_t *, u8 ); -int wmi_dix_2_dot3(struct wmi_t *wmip, void *osbuf); -int wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, u8 msgType, bool bMoreData, WMI_DATA_HDR_DATA_TYPE data_type,u8 metaVersion, void *pTxMetaS); -int wmi_dot3_2_dix(void *osbuf); - -int wmi_dot11_hdr_remove (struct wmi_t *wmip, void *osbuf); -int wmi_dot11_hdr_add(struct wmi_t *wmip, void *osbuf, NETWORK_TYPE mode); - -int wmi_data_hdr_remove(struct wmi_t *wmip, void *osbuf); -int wmi_syncpoint(struct wmi_t *wmip); -int wmi_syncpoint_reset(struct wmi_t *wmip); -u8 wmi_implicit_create_pstream(struct wmi_t *wmip, void *osbuf, u32 layer2Priority, bool wmmEnabled); - -u8 wmi_determine_userPriority (u8 *pkt, u32 layer2Pri); - -int wmi_control_rx(struct wmi_t *wmip, void *osbuf); -void wmi_iterate_nodes(struct wmi_t *wmip, wlan_node_iter_func *f, void *arg); -void wmi_free_allnodes(struct wmi_t *wmip); -bss_t *wmi_find_node(struct wmi_t *wmip, const u8 *macaddr); -void wmi_free_node(struct wmi_t *wmip, const u8 *macaddr); - - -typedef enum { - NO_SYNC_WMIFLAG = 0, - SYNC_BEFORE_WMIFLAG, /* transmit all queued data before cmd */ - SYNC_AFTER_WMIFLAG, /* any new data waits until cmd execs */ - SYNC_BOTH_WMIFLAG, - END_WMIFLAG /* end marker */ -} WMI_SYNC_FLAG; - -int wmi_cmd_send(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId, - WMI_SYNC_FLAG flag); - -int wmi_connect_cmd(struct wmi_t *wmip, - NETWORK_TYPE netType, - DOT11_AUTH_MODE dot11AuthMode, - AUTH_MODE authMode, - CRYPTO_TYPE pairwiseCrypto, - u8 pairwiseCryptoLen, - CRYPTO_TYPE groupCrypto, - u8 groupCryptoLen, - int ssidLength, - u8 *ssid, - u8 *bssid, - u16 channel, - u32 ctrl_flags); - -int wmi_reconnect_cmd(struct wmi_t *wmip, - u8 *bssid, - u16 channel); -int wmi_disconnect_cmd(struct wmi_t *wmip); -int wmi_getrev_cmd(struct wmi_t *wmip); -int wmi_startscan_cmd(struct wmi_t *wmip, WMI_SCAN_TYPE scanType, - u32 forceFgScan, u32 isLegacy, - u32 homeDwellTime, u32 forceScanInterval, - s8 numChan, u16 *channelList); -int wmi_scanparams_cmd(struct wmi_t *wmip, u16 fg_start_sec, - u16 fg_end_sec, u16 bg_sec, - u16 minact_chdw_msec, - u16 maxact_chdw_msec, u16 pas_chdw_msec, - u8 shScanRatio, u8 scanCtrlFlags, - u32 max_dfsch_act_time, - u16 maxact_scan_per_ssid); -int wmi_bssfilter_cmd(struct wmi_t *wmip, u8 filter, u32 ieMask); -int wmi_probedSsid_cmd(struct wmi_t *wmip, u8 index, u8 flag, - u8 ssidLength, u8 *ssid); -int wmi_listeninterval_cmd(struct wmi_t *wmip, u16 listenInterval, u16 listenBeacons); -int wmi_bmisstime_cmd(struct wmi_t *wmip, u16 bmisstime, u16 bmissbeacons); -int wmi_associnfo_cmd(struct wmi_t *wmip, u8 ieType, - u8 ieLen, u8 *ieInfo); -int wmi_powermode_cmd(struct wmi_t *wmip, u8 powerMode); -int wmi_ibsspmcaps_cmd(struct wmi_t *wmip, u8 pmEnable, u8 ttl, - u16 atim_windows, u16 timeout_value); -int wmi_apps_cmd(struct wmi_t *wmip, u8 psType, u32 idle_time, - u32 ps_period, u8 sleep_period); -int wmi_pmparams_cmd(struct wmi_t *wmip, u16 idlePeriod, - u16 psPollNum, u16 dtimPolicy, - u16 wakup_tx_policy, u16 num_tx_to_wakeup, - u16 ps_fail_event_policy); -int wmi_disctimeout_cmd(struct wmi_t *wmip, u8 timeout); -int wmi_sync_cmd(struct wmi_t *wmip, u8 syncNumber); -int wmi_create_pstream_cmd(struct wmi_t *wmip, WMI_CREATE_PSTREAM_CMD *pstream); -int wmi_delete_pstream_cmd(struct wmi_t *wmip, u8 trafficClass, u8 streamID); -int wmi_set_framerate_cmd(struct wmi_t *wmip, u8 bEnable, u8 type, u8 subType, u16 rateMask); -int wmi_set_bitrate_cmd(struct wmi_t *wmip, s32 dataRate, s32 mgmtRate, s32 ctlRate); -int wmi_get_bitrate_cmd(struct wmi_t *wmip); -s8 wmi_validate_bitrate(struct wmi_t *wmip, s32 rate, s8 *rate_idx); -int wmi_get_regDomain_cmd(struct wmi_t *wmip); -int wmi_get_channelList_cmd(struct wmi_t *wmip); -int wmi_set_channelParams_cmd(struct wmi_t *wmip, u8 scanParam, - WMI_PHY_MODE mode, s8 numChan, - u16 *channelList); - -int wmi_set_snr_threshold_params(struct wmi_t *wmip, - WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd); -int wmi_set_rssi_threshold_params(struct wmi_t *wmip, - WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd); -int wmi_clr_rssi_snr(struct wmi_t *wmip); -int wmi_set_lq_threshold_params(struct wmi_t *wmip, - WMI_LQ_THRESHOLD_PARAMS_CMD *lqCmd); -int wmi_set_rts_cmd(struct wmi_t *wmip, u16 threshold); -int wmi_set_lpreamble_cmd(struct wmi_t *wmip, u8 status, u8 preamblePolicy); - -int wmi_set_error_report_bitmask(struct wmi_t *wmip, u32 bitmask); - -int wmi_get_challenge_resp_cmd(struct wmi_t *wmip, u32 cookie, - u32 source); - -int wmi_config_debug_module_cmd(struct wmi_t *wmip, u16 mmask, - u16 tsr, bool rep, u16 size, - u32 valid); - -int wmi_get_stats_cmd(struct wmi_t *wmip); - -int wmi_addKey_cmd(struct wmi_t *wmip, u8 keyIndex, - CRYPTO_TYPE keyType, u8 keyUsage, - u8 keyLength,u8 *keyRSC, - u8 *keyMaterial, u8 key_op_ctrl, u8 *mac, - WMI_SYNC_FLAG sync_flag); -int wmi_add_krk_cmd(struct wmi_t *wmip, u8 *krk); -int wmi_delete_krk_cmd(struct wmi_t *wmip); -int wmi_deleteKey_cmd(struct wmi_t *wmip, u8 keyIndex); -int wmi_set_akmp_params_cmd(struct wmi_t *wmip, - WMI_SET_AKMP_PARAMS_CMD *akmpParams); -int wmi_get_pmkid_list_cmd(struct wmi_t *wmip); -int wmi_set_pmkid_list_cmd(struct wmi_t *wmip, - WMI_SET_PMKID_LIST_CMD *pmkInfo); -int wmi_abort_scan_cmd(struct wmi_t *wmip); -int wmi_set_txPwr_cmd(struct wmi_t *wmip, u8 dbM); -int wmi_get_txPwr_cmd(struct wmi_t *wmip); -int wmi_addBadAp_cmd(struct wmi_t *wmip, u8 apIndex, u8 *bssid); -int wmi_deleteBadAp_cmd(struct wmi_t *wmip, u8 apIndex); -int wmi_set_tkip_countermeasures_cmd(struct wmi_t *wmip, bool en); -int wmi_setPmkid_cmd(struct wmi_t *wmip, u8 *bssid, u8 *pmkId, - bool set); -int wmi_set_access_params_cmd(struct wmi_t *wmip, u8 ac, u16 txop, - u8 eCWmin, u8 eCWmax, - u8 aifsn); -int wmi_set_retry_limits_cmd(struct wmi_t *wmip, u8 frameType, - u8 trafficClass, u8 maxRetries, - u8 enableNotify); - -void wmi_get_current_bssid(struct wmi_t *wmip, u8 *bssid); - -int wmi_get_roam_tbl_cmd(struct wmi_t *wmip); -int wmi_get_roam_data_cmd(struct wmi_t *wmip, u8 roamDataType); -int wmi_set_roam_ctrl_cmd(struct wmi_t *wmip, WMI_SET_ROAM_CTRL_CMD *p, - u8 size); -int wmi_set_powersave_timers_cmd(struct wmi_t *wmip, - WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd, - u8 size); - -int wmi_set_opt_mode_cmd(struct wmi_t *wmip, u8 optMode); -int wmi_opt_tx_frame_cmd(struct wmi_t *wmip, - u8 frmType, - u8 *dstMacAddr, - u8 *bssid, - u16 optIEDataLen, - u8 *optIEData); - -int wmi_set_adhoc_bconIntvl_cmd(struct wmi_t *wmip, u16 intvl); -int wmi_set_voice_pkt_size_cmd(struct wmi_t *wmip, u16 voicePktSize); -int wmi_set_max_sp_len_cmd(struct wmi_t *wmip, u8 maxSpLen); -u8 convert_userPriority_to_trafficClass(u8 userPriority); -u8 wmi_get_power_mode_cmd(struct wmi_t *wmip); -int wmi_verify_tspec_params(WMI_CREATE_PSTREAM_CMD *pCmd, int tspecCompliance); - -#ifdef CONFIG_HOST_TCMD_SUPPORT -int wmi_test_cmd(struct wmi_t *wmip, u8 *buf, u32 len); -#endif - -int wmi_set_bt_status_cmd(struct wmi_t *wmip, u8 streamType, u8 status); -int wmi_set_bt_params_cmd(struct wmi_t *wmip, WMI_SET_BT_PARAMS_CMD* cmd); - -int wmi_set_btcoex_fe_ant_cmd(struct wmi_t *wmip, WMI_SET_BTCOEX_FE_ANT_CMD * cmd); - -int wmi_set_btcoex_colocated_bt_dev_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD * cmd); - -int wmi_set_btcoex_btinquiry_page_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD *cmd); - -int wmi_set_btcoex_sco_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_SCO_CONFIG_CMD * cmd); - -int wmi_set_btcoex_a2dp_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_A2DP_CONFIG_CMD* cmd); - - -int wmi_set_btcoex_aclcoex_config_cmd(struct wmi_t *wmip, WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD* cmd); - -int wmi_set_btcoex_debug_cmd(struct wmi_t *wmip, WMI_SET_BTCOEX_DEBUG_CMD * cmd); - -int wmi_set_btcoex_bt_operating_status_cmd(struct wmi_t * wmip, - WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD * cmd); - -int wmi_get_btcoex_config_cmd(struct wmi_t * wmip, WMI_GET_BTCOEX_CONFIG_CMD * cmd); - -int wmi_get_btcoex_stats_cmd(struct wmi_t * wmip); - -int wmi_SGI_cmd(struct wmi_t *wmip, u32 sgiMask, u8 sgiPERThreshold); - -/* - * This function is used to configure the fix rates mask to the target. - */ -int wmi_set_fixrates_cmd(struct wmi_t *wmip, u32 fixRatesMask); -int wmi_get_ratemask_cmd(struct wmi_t *wmip); - -int wmi_set_authmode_cmd(struct wmi_t *wmip, u8 mode); - -int wmi_set_reassocmode_cmd(struct wmi_t *wmip, u8 mode); - -int wmi_set_qos_supp_cmd(struct wmi_t *wmip,u8 status); -int wmi_set_wmm_cmd(struct wmi_t *wmip, WMI_WMM_STATUS status); -int wmi_set_wmm_txop(struct wmi_t *wmip, WMI_TXOP_CFG txEnable); -int wmi_set_country(struct wmi_t *wmip, u8 *countryCode); - -int wmi_get_keepalive_configured(struct wmi_t *wmip); -u8 wmi_get_keepalive_cmd(struct wmi_t *wmip); -int wmi_set_keepalive_cmd(struct wmi_t *wmip, u8 keepaliveInterval); - -int wmi_set_appie_cmd(struct wmi_t *wmip, u8 mgmtFrmType, - u8 ieLen,u8 *ieInfo); - -int wmi_set_halparam_cmd(struct wmi_t *wmip, u8 *cmd, u16 dataLen); - -s32 wmi_get_rate(s8 rateindex); - -int wmi_set_ip_cmd(struct wmi_t *wmip, WMI_SET_IP_CMD *cmd); - -/*Wake on Wireless WMI commands*/ -int wmi_set_host_sleep_mode_cmd(struct wmi_t *wmip, WMI_SET_HOST_SLEEP_MODE_CMD *cmd); -int wmi_set_wow_mode_cmd(struct wmi_t *wmip, WMI_SET_WOW_MODE_CMD *cmd); -int wmi_get_wow_list_cmd(struct wmi_t *wmip, WMI_GET_WOW_LIST_CMD *cmd); -int wmi_add_wow_pattern_cmd(struct wmi_t *wmip, - WMI_ADD_WOW_PATTERN_CMD *cmd, u8 *pattern, u8 *mask, u8 pattern_size); -int wmi_del_wow_pattern_cmd(struct wmi_t *wmip, - WMI_DEL_WOW_PATTERN_CMD *cmd); -int wmi_set_wsc_status_cmd(struct wmi_t *wmip, u32 status); - -int -wmi_set_params_cmd(struct wmi_t *wmip, u32 opcode, u32 length, char *buffer); - -int -wmi_set_mcast_filter_cmd(struct wmi_t *wmip, u8 dot1, u8 dot2, u8 dot3, u8 dot4); - -int -wmi_del_mcast_filter_cmd(struct wmi_t *wmip, u8 dot1, u8 dot2, u8 dot3, u8 dot4); - -int -wmi_mcast_filter_cmd(struct wmi_t *wmip, u8 enable); - -bss_t * -wmi_find_Ssidnode (struct wmi_t *wmip, u8 *pSsid, - u32 ssidLength, bool bIsWPA2, bool bMatchSSID); - - -void -wmi_node_return (struct wmi_t *wmip, bss_t *bss); - -void -wmi_set_nodeage(struct wmi_t *wmip, u32 nodeAge); - -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -int wmi_prof_cfg_cmd(struct wmi_t *wmip, u32 period, u32 nbins); -int wmi_prof_addr_set_cmd(struct wmi_t *wmip, u32 addr); -int wmi_prof_start_cmd(struct wmi_t *wmip); -int wmi_prof_stop_cmd(struct wmi_t *wmip); -int wmi_prof_count_get_cmd(struct wmi_t *wmip); -#endif /* CONFIG_TARGET_PROFILE_SUPPORT */ -#ifdef OS_ROAM_MANAGEMENT -void wmi_scan_indication (struct wmi_t *wmip); -#endif - -int -wmi_set_target_event_report_cmd(struct wmi_t *wmip, WMI_SET_TARGET_EVENT_REPORT_CMD* cmd); - -bss_t *wmi_rm_current_bss (struct wmi_t *wmip, u8 *id); -int wmi_add_current_bss (struct wmi_t *wmip, u8 *id, bss_t *bss); - - -/* - * AP mode - */ -int -wmi_ap_profile_commit(struct wmi_t *wmip, WMI_CONNECT_CMD *p); - -int -wmi_ap_set_hidden_ssid(struct wmi_t *wmip, u8 hidden_ssid); - -int -wmi_ap_set_num_sta(struct wmi_t *wmip, u8 num_sta); - -int -wmi_ap_set_acl_policy(struct wmi_t *wmip, u8 policy); - -int -wmi_ap_acl_mac_list(struct wmi_t *wmip, WMI_AP_ACL_MAC_CMD *a); - -u8 acl_add_del_mac(WMI_AP_ACL *a, WMI_AP_ACL_MAC_CMD *acl); - -int -wmi_ap_set_mlme(struct wmi_t *wmip, u8 cmd, u8 *mac, u16 reason); - -int -wmi_set_pvb_cmd(struct wmi_t *wmip, u16 aid, bool flag); - -int -wmi_ap_conn_inact_time(struct wmi_t *wmip, u32 period); - -int -wmi_ap_bgscan_time(struct wmi_t *wmip, u32 period, u32 dwell); - -int -wmi_ap_set_dtim(struct wmi_t *wmip, u8 dtim); - -int -wmi_ap_set_rateset(struct wmi_t *wmip, u8 rateset); - -int -wmi_set_ht_cap_cmd(struct wmi_t *wmip, WMI_SET_HT_CAP_CMD *cmd); - -int -wmi_set_ht_op_cmd(struct wmi_t *wmip, u8 sta_chan_width); - -int -wmi_send_hci_cmd(struct wmi_t *wmip, u8 *buf, u16 sz); - -int -wmi_set_tx_select_rates_cmd(struct wmi_t *wmip, u32 *pMaskArray); - -int -wmi_setup_aggr_cmd(struct wmi_t *wmip, u8 tid); - -int -wmi_delete_aggr_cmd(struct wmi_t *wmip, u8 tid, bool uplink); - -int -wmi_allow_aggr_cmd(struct wmi_t *wmip, u16 tx_tidmask, u16 rx_tidmask); - -int -wmi_set_rx_frame_format_cmd(struct wmi_t *wmip, u8 rxMetaVersion, bool rxDot11Hdr, bool defragOnHost); - -int -wmi_set_thin_mode_cmd(struct wmi_t *wmip, bool bThinMode); - -int -wmi_set_wlan_conn_precedence_cmd(struct wmi_t *wmip, BT_WLAN_CONN_PRECEDENCE precedence); - -int -wmi_set_pmk_cmd(struct wmi_t *wmip, u8 *pmk); - -int -wmi_set_excess_tx_retry_thres_cmd(struct wmi_t *wmip, WMI_SET_EXCESS_TX_RETRY_THRES_CMD *cmd); - -u16 wmi_ieee2freq (int chan); - -u32 wmi_freq2ieee (u16 freq); - -bss_t * -wmi_find_matching_Ssidnode (struct wmi_t *wmip, u8 *pSsid, - u32 ssidLength, - u32 dot11AuthMode, u32 authMode, - u32 pairwiseCryptoType, u32 grpwiseCryptoTyp); - -#ifdef __cplusplus -} -#endif - -#endif /* _WMI_API_H_ */ diff --git a/drivers/staging/ath6kl/miscdrv/ar3kconfig.c b/drivers/staging/ath6kl/miscdrv/ar3kconfig.c deleted file mode 100644 index e0ea2183019..00000000000 --- a/drivers/staging/ath6kl/miscdrv/ar3kconfig.c +++ /dev/null @@ -1,565 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// AR3K configuration implementation -// -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#define ATH_MODULE_NAME misc -#include "a_debug.h" -#include "common_drv.h" -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -#include "export_hci_transport.h" -#else -#include "hci_transport_api.h" -#endif -#include "ar3kconfig.h" -#include "tlpm.h" - -#define BAUD_CHANGE_COMMAND_STATUS_OFFSET 5 -#define HCI_EVENT_RESP_TIMEOUTMS 3000 -#define HCI_CMD_OPCODE_BYTE_LOW_OFFSET 0 -#define HCI_CMD_OPCODE_BYTE_HI_OFFSET 1 -#define HCI_EVENT_OPCODE_BYTE_LOW 3 -#define HCI_EVENT_OPCODE_BYTE_HI 4 -#define HCI_CMD_COMPLETE_EVENT_CODE 0xE -#define HCI_MAX_EVT_RECV_LENGTH 257 -#define EXIT_MIN_BOOT_COMMAND_STATUS_OFFSET 5 - -int AthPSInitialize(struct ar3k_config_info *hdev); - -static int SendHCICommand(struct ar3k_config_info *pConfig, - u8 *pBuffer, - int Length) -{ - struct htc_packet *pPacket = NULL; - int status = 0; - - do { - - pPacket = (struct htc_packet *)A_MALLOC(sizeof(struct htc_packet)); - if (NULL == pPacket) { - status = A_NO_MEMORY; - break; - } - - A_MEMZERO(pPacket,sizeof(struct htc_packet)); - SET_HTC_PACKET_INFO_TX(pPacket, - NULL, - pBuffer, - Length, - HCI_COMMAND_TYPE, - AR6K_CONTROL_PKT_TAG); - - /* issue synchronously */ - status = HCI_TransportSendPkt(pConfig->pHCIDev,pPacket,true); - - } while (false); - - if (pPacket != NULL) { - kfree(pPacket); - } - - return status; -} - -static int RecvHCIEvent(struct ar3k_config_info *pConfig, - u8 *pBuffer, - int *pLength) -{ - int status = 0; - struct htc_packet *pRecvPacket = NULL; - - do { - - pRecvPacket = (struct htc_packet *)A_MALLOC(sizeof(struct htc_packet)); - if (NULL == pRecvPacket) { - status = A_NO_MEMORY; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to alloc HTC struct \n")); - break; - } - - A_MEMZERO(pRecvPacket,sizeof(struct htc_packet)); - - SET_HTC_PACKET_INFO_RX_REFILL(pRecvPacket,NULL,pBuffer,*pLength,HCI_EVENT_TYPE); - - status = HCI_TransportRecvHCIEventSync(pConfig->pHCIDev, - pRecvPacket, - HCI_EVENT_RESP_TIMEOUTMS); - if (status) { - break; - } - - *pLength = pRecvPacket->ActualLength; - - } while (false); - - if (pRecvPacket != NULL) { - kfree(pRecvPacket); - } - - return status; -} - -int SendHCICommandWaitCommandComplete(struct ar3k_config_info *pConfig, - u8 *pHCICommand, - int CmdLength, - u8 **ppEventBuffer, - u8 **ppBufferToFree) -{ - int status = 0; - u8 *pBuffer = NULL; - u8 *pTemp; - int length; - bool commandComplete = false; - u8 opCodeBytes[2]; - - do { - - length = max(HCI_MAX_EVT_RECV_LENGTH,CmdLength); - length += pConfig->pHCIProps->HeadRoom + pConfig->pHCIProps->TailRoom; - length += pConfig->pHCIProps->IOBlockPad; - - pBuffer = (u8 *)A_MALLOC(length); - if (NULL == pBuffer) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Failed to allocate bt buffer \n")); - status = A_NO_MEMORY; - break; - } - - /* get the opcodes to check the command complete event */ - opCodeBytes[0] = pHCICommand[HCI_CMD_OPCODE_BYTE_LOW_OFFSET]; - opCodeBytes[1] = pHCICommand[HCI_CMD_OPCODE_BYTE_HI_OFFSET]; - - /* copy HCI command */ - memcpy(pBuffer + pConfig->pHCIProps->HeadRoom,pHCICommand,CmdLength); - /* send command */ - status = SendHCICommand(pConfig, - pBuffer + pConfig->pHCIProps->HeadRoom, - CmdLength); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Failed to send HCI Command (%d) \n", status)); - AR_DEBUG_PRINTBUF(pHCICommand,CmdLength,"HCI Bridge Failed HCI Command"); - break; - } - - /* reuse buffer to capture command complete event */ - A_MEMZERO(pBuffer,length); - status = RecvHCIEvent(pConfig,pBuffer,&length); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: HCI event recv failed \n")); - AR_DEBUG_PRINTBUF(pHCICommand,CmdLength,"HCI Bridge Failed HCI Command"); - break; - } - - pTemp = pBuffer + pConfig->pHCIProps->HeadRoom; - if (pTemp[0] == HCI_CMD_COMPLETE_EVENT_CODE) { - if ((pTemp[HCI_EVENT_OPCODE_BYTE_LOW] == opCodeBytes[0]) && - (pTemp[HCI_EVENT_OPCODE_BYTE_HI] == opCodeBytes[1])) { - commandComplete = true; - } - } - - if (!commandComplete) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Unexpected HCI event : %d \n",pTemp[0])); - AR_DEBUG_PRINTBUF(pTemp,pTemp[1],"Unexpected HCI event"); - status = A_ECOMM; - break; - } - - if (ppEventBuffer != NULL) { - /* caller wants to look at the event */ - *ppEventBuffer = pTemp; - if (ppBufferToFree == NULL) { - status = A_EINVAL; - break; - } - /* caller must free the buffer */ - *ppBufferToFree = pBuffer; - pBuffer = NULL; - } - - } while (false); - - if (pBuffer != NULL) { - kfree(pBuffer); - } - - return status; -} - -static int AR3KConfigureHCIBaud(struct ar3k_config_info *pConfig) -{ - int status = 0; - u8 hciBaudChangeCommand[] = {0x0c,0xfc,0x2,0,0}; - u16 baudVal; - u8 *pEvent = NULL; - u8 *pBufferToFree = NULL; - - do { - - if (pConfig->Flags & AR3K_CONFIG_FLAG_SET_AR3K_BAUD) { - baudVal = (u16)(pConfig->AR3KBaudRate / 100); - hciBaudChangeCommand[3] = (u8)baudVal; - hciBaudChangeCommand[4] = (u8)(baudVal >> 8); - - status = SendHCICommandWaitCommandComplete(pConfig, - hciBaudChangeCommand, - sizeof(hciBaudChangeCommand), - &pEvent, - &pBufferToFree); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Baud rate change failed! \n")); - break; - } - - if (pEvent[BAUD_CHANGE_COMMAND_STATUS_OFFSET] != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("AR3K Config: Baud change command event status failed: %d \n", - pEvent[BAUD_CHANGE_COMMAND_STATUS_OFFSET])); - status = A_ECOMM; - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("AR3K Config: Baud Changed to %d \n",pConfig->AR3KBaudRate)); - } - - if (pConfig->Flags & AR3K_CONFIG_FLAG_AR3K_BAUD_CHANGE_DELAY) { - /* some versions of AR3K do not switch baud immediately, up to 300MS */ - A_MDELAY(325); - } - - if (pConfig->Flags & AR3K_CONFIG_FLAG_SET_AR6K_SCALE_STEP) { - /* Tell target to change UART baud rate for AR6K */ - status = HCI_TransportSetBaudRate(pConfig->pHCIDev, pConfig->AR3KBaudRate); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("AR3K Config: failed to set scale and step values: %d \n", status)); - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ANY, - ("AR3K Config: Baud changed to %d for AR6K\n", pConfig->AR3KBaudRate)); - } - - } while (false); - - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - - return status; -} - -static int AR3KExitMinBoot(struct ar3k_config_info *pConfig) -{ - int status; - char exitMinBootCmd[] = {0x25,0xFC,0x0c,0x03,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00}; - u8 *pEvent = NULL; - u8 *pBufferToFree = NULL; - - status = SendHCICommandWaitCommandComplete(pConfig, - exitMinBootCmd, - sizeof(exitMinBootCmd), - &pEvent, - &pBufferToFree); - - if (!status) { - if (pEvent[EXIT_MIN_BOOT_COMMAND_STATUS_OFFSET] != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("AR3K Config: MinBoot exit command event status failed: %d \n", - pEvent[EXIT_MIN_BOOT_COMMAND_STATUS_OFFSET])); - status = A_ECOMM; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("AR3K Config: MinBoot Exit Command Complete (Success) \n")); - A_MDELAY(1); - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: MinBoot Exit Failed! \n")); - } - - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - - return status; -} - -static int AR3KConfigureSendHCIReset(struct ar3k_config_info *pConfig) -{ - int status = 0; - u8 hciResetCommand[] = {0x03,0x0c,0x0}; - u8 *pEvent = NULL; - u8 *pBufferToFree = NULL; - - status = SendHCICommandWaitCommandComplete( pConfig, - hciResetCommand, - sizeof(hciResetCommand), - &pEvent, - &pBufferToFree ); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: HCI reset failed! \n")); - } - - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - - return status; -} - -static int AR3KEnableTLPM(struct ar3k_config_info *pConfig) -{ - int status; - /* AR3K vendor specific command for Host Wakeup Config */ - char hostWakeupConfig[] = {0x31,0xFC,0x18, - 0x02,0x00,0x00,0x00, - 0x01,0x00,0x00,0x00, - TLPM_DEFAULT_IDLE_TIMEOUT_LSB,TLPM_DEFAULT_IDLE_TIMEOUT_MSB,0x00,0x00, //idle timeout in ms - 0x00,0x00,0x00,0x00, - TLPM_DEFAULT_WAKEUP_TIMEOUT_MS,0x00,0x00,0x00, //wakeup timeout in ms - 0x00,0x00,0x00,0x00}; - /* AR3K vendor specific command for Target Wakeup Config */ - char targetWakeupConfig[] = {0x31,0xFC,0x18, - 0x04,0x00,0x00,0x00, - 0x01,0x00,0x00,0x00, - TLPM_DEFAULT_IDLE_TIMEOUT_LSB,TLPM_DEFAULT_IDLE_TIMEOUT_MSB,0x00,0x00, //idle timeout in ms - 0x00,0x00,0x00,0x00, - TLPM_DEFAULT_WAKEUP_TIMEOUT_MS,0x00,0x00,0x00, //wakeup timeout in ms - 0x00,0x00,0x00,0x00}; - /* AR3K vendor specific command for Host Wakeup Enable */ - char hostWakeupEnable[] = {0x31,0xFC,0x4, - 0x01,0x00,0x00,0x00}; - /* AR3K vendor specific command for Target Wakeup Enable */ - char targetWakeupEnable[] = {0x31,0xFC,0x4, - 0x06,0x00,0x00,0x00}; - /* AR3K vendor specific command for Sleep Enable */ - char sleepEnable[] = {0x4,0xFC,0x1, - 0x1}; - u8 *pEvent = NULL; - u8 *pBufferToFree = NULL; - - if (0 != pConfig->IdleTimeout) { - u8 idle_lsb = pConfig->IdleTimeout & 0xFF; - u8 idle_msb = (pConfig->IdleTimeout & 0xFF00) >> 8; - hostWakeupConfig[11] = targetWakeupConfig[11] = idle_lsb; - hostWakeupConfig[12] = targetWakeupConfig[12] = idle_msb; - } - - if (0 != pConfig->WakeupTimeout) { - hostWakeupConfig[19] = targetWakeupConfig[19] = (pConfig->WakeupTimeout & 0xFF); - } - - status = SendHCICommandWaitCommandComplete(pConfig, - hostWakeupConfig, - sizeof(hostWakeupConfig), - &pEvent, - &pBufferToFree); - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HostWakeup Config Failed! \n")); - return status; - } - - pEvent = NULL; - pBufferToFree = NULL; - status = SendHCICommandWaitCommandComplete(pConfig, - targetWakeupConfig, - sizeof(targetWakeupConfig), - &pEvent, - &pBufferToFree); - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Target Wakeup Config Failed! \n")); - return status; - } - - pEvent = NULL; - pBufferToFree = NULL; - status = SendHCICommandWaitCommandComplete(pConfig, - hostWakeupEnable, - sizeof(hostWakeupEnable), - &pEvent, - &pBufferToFree); - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HostWakeup Enable Failed! \n")); - return status; - } - - pEvent = NULL; - pBufferToFree = NULL; - status = SendHCICommandWaitCommandComplete(pConfig, - targetWakeupEnable, - sizeof(targetWakeupEnable), - &pEvent, - &pBufferToFree); - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Target Wakeup Enable Failed! \n")); - return status; - } - - pEvent = NULL; - pBufferToFree = NULL; - status = SendHCICommandWaitCommandComplete(pConfig, - sleepEnable, - sizeof(sleepEnable), - &pEvent, - &pBufferToFree); - if (pBufferToFree != NULL) { - kfree(pBufferToFree); - } - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Sleep Enable Failed! \n")); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Enable TLPM Completed (status = %d) \n",status)); - - return status; -} - -int AR3KConfigure(struct ar3k_config_info *pConfig) -{ - int status = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR3K Config: Configuring AR3K ...\n")); - - do { - - if ((pConfig->pHCIDev == NULL) || (pConfig->pHCIProps == NULL) || (pConfig->pHIFDevice == NULL)) { - status = A_EINVAL; - break; - } - - /* disable asynchronous recv while we issue commands and receive events synchronously */ - status = HCI_TransportEnableDisableAsyncRecv(pConfig->pHCIDev,false); - if (status) { - break; - } - - if (pConfig->Flags & AR3K_CONFIG_FLAG_FORCE_MINBOOT_EXIT) { - status = AR3KExitMinBoot(pConfig); - if (status) { - break; - } - } - - - /* Load patching and PST file if available*/ - if (0 != AthPSInitialize(pConfig)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Patch Download Failed!\n")); - } - - /* Send HCI reset to make PS tags take effect*/ - AR3KConfigureSendHCIReset(pConfig); - - if (pConfig->Flags & - (AR3K_CONFIG_FLAG_SET_AR3K_BAUD | AR3K_CONFIG_FLAG_SET_AR6K_SCALE_STEP)) { - status = AR3KConfigureHCIBaud(pConfig); - if (status) { - break; - } - } - - - - if (pConfig->PwrMgmtEnabled) { - /* the delay is required after the previous HCI reset before further - * HCI commands can be issued - */ - A_MDELAY(200); - AR3KEnableTLPM(pConfig); - } - - /* re-enable asynchronous recv */ - status = HCI_TransportEnableDisableAsyncRecv(pConfig->pHCIDev,true); - if (status) { - break; - } - - - } while (false); - - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR3K Config: Configuration Complete (status = %d) \n",status)); - - return status; -} - -int AR3KConfigureExit(void *config) -{ - int status = 0; - struct ar3k_config_info *pConfig = (struct ar3k_config_info *)config; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR3K Config: Cleaning up AR3K ...\n")); - - do { - - if ((pConfig->pHCIDev == NULL) || (pConfig->pHCIProps == NULL) || (pConfig->pHIFDevice == NULL)) { - status = A_EINVAL; - break; - } - - /* disable asynchronous recv while we issue commands and receive events synchronously */ - status = HCI_TransportEnableDisableAsyncRecv(pConfig->pHCIDev,false); - if (status) { - break; - } - - if (pConfig->Flags & - (AR3K_CONFIG_FLAG_SET_AR3K_BAUD | AR3K_CONFIG_FLAG_SET_AR6K_SCALE_STEP)) { - status = AR3KConfigureHCIBaud(pConfig); - if (status) { - break; - } - } - - /* re-enable asynchronous recv */ - status = HCI_TransportEnableDisableAsyncRecv(pConfig->pHCIDev,true); - if (status) { - break; - } - - - } while (false); - - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR3K Config: Cleanup Complete (status = %d) \n",status)); - - return status; -} - diff --git a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c b/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c deleted file mode 100644 index 282ceac597b..00000000000 --- a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c +++ /dev/null @@ -1,572 +0,0 @@ -/* - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * This file implements the Atheros PS and patch downloaded for HCI UART Transport driver. - * This file can be used for HCI SDIO transport implementation for AR6002 with HCI_TRANSPORT_SDIO - * defined. - * - * - * ar3kcpsconfig.c - * - * - * - * The software source and binaries included in this development package are - * licensed, not sold. You, or your company, received the package under one - * or more license agreements. The rights granted to you are specifically - * listed in these license agreement(s). All other rights remain with Atheros - * Communications, Inc., its subsidiaries, or the respective owner including - * those listed on the included copyright notices.. Distribution of any - * portion of this package must be in strict compliance with the license - * agreement(s) terms. - * - * - * - */ - - - -#include "ar3kpsconfig.h" -#ifndef HCI_TRANSPORT_SDIO -#include "hci_ath.h" -#include "hci_uart.h" -#endif /* #ifndef HCI_TRANSPORT_SDIO */ - -#define MAX_FW_PATH_LEN 50 -#define MAX_BDADDR_FORMAT_LENGTH 30 - -/* - * Structure used to send HCI packet, hci packet length and device info - * together as parameter to PSThread. - */ -typedef struct { - - struct ps_cmd_packet *HciCmdList; - u32 num_packets; - struct ar3k_config_info *dev; -}HciCommandListParam; - -int SendHCICommandWaitCommandComplete(struct ar3k_config_info *pConfig, - u8 *pHCICommand, - int CmdLength, - u8 **ppEventBuffer, - u8 **ppBufferToFree); - -u32 Rom_Version; -u32 Build_Version; -extern bool BDADDR; - -int getDeviceType(struct ar3k_config_info *pConfig, u32 *code); -int ReadVersionInfo(struct ar3k_config_info *pConfig); -#ifndef HCI_TRANSPORT_SDIO - -DECLARE_WAIT_QUEUE_HEAD(PsCompleteEvent); -DECLARE_WAIT_QUEUE_HEAD(HciEvent); -u8 *HciEventpacket; -rwlock_t syncLock; -wait_queue_t Eventwait; - -int PSHciWritepacket(struct hci_dev*,u8* Data, u32 len); -extern char *bdaddr; -#endif /* HCI_TRANSPORT_SDIO */ - -int write_bdaddr(struct ar3k_config_info *pConfig,u8 *bdaddr,int type); - -int PSSendOps(void *arg); - -#ifdef BT_PS_DEBUG -void Hci_log(u8 * log_string,u8 *data,u32 len) -{ - int i; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s : ",log_string)); - for (i = 0; i < len; i++) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("0x%02x ", data[i])); - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("\n...................................\n")); -} -#else -#define Hci_log(string,data,len) -#endif /* BT_PS_DEBUG */ - - - - -int AthPSInitialize(struct ar3k_config_info *hdev) -{ - int status = 0; - if(hdev == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Device handle received\n")); - return A_ERROR; - } - -#ifndef HCI_TRANSPORT_SDIO - DECLARE_WAITQUEUE(wait, current); -#endif /* HCI_TRANSPORT_SDIO */ - - -#ifdef HCI_TRANSPORT_SDIO - status = PSSendOps((void*)hdev); -#else - if(InitPSState(hdev) == -1) { - return A_ERROR; - } - allow_signal(SIGKILL); - add_wait_queue(&PsCompleteEvent,&wait); - set_current_state(TASK_INTERRUPTIBLE); - if(!kernel_thread(PSSendOps,(void*)hdev,CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Kthread Failed\n")); - remove_wait_queue(&PsCompleteEvent,&wait); - return A_ERROR; - } - wait_event_interruptible(PsCompleteEvent,(PSTagMode == false)); - set_current_state(TASK_RUNNING); - remove_wait_queue(&PsCompleteEvent,&wait); - -#endif /* HCI_TRANSPORT_SDIO */ - - - return status; - -} - -int PSSendOps(void *arg) -{ - int i; - int status = 0; - struct ps_cmd_packet *HciCmdList; /* List storing the commands */ - const struct firmware* firmware; - u32 numCmds; - u8 *event; - u8 *bufferToFree; - struct hci_dev *device; - u8 *buffer; - u32 len; - u32 DevType; - u8 *PsFileName; - u8 *patchFileName; - u8 *path = NULL; - u8 *config_path = NULL; - u8 config_bdaddr[MAX_BDADDR_FORMAT_LENGTH]; - struct ar3k_config_info *hdev = (struct ar3k_config_info*)arg; - struct device *firmwareDev = NULL; - status = 0; - HciCmdList = NULL; -#ifdef HCI_TRANSPORT_SDIO - device = hdev->pBtStackHCIDev; - firmwareDev = device->parent; -#else - device = hdev; - firmwareDev = &device->dev; - AthEnableSyncCommandOp(true); -#endif /* HCI_TRANSPORT_SDIO */ - /* First verify if the controller is an FPGA or ASIC, so depending on the device type the PS file to be written will be different. - */ - - path =(u8 *)A_MALLOC(MAX_FW_PATH_LEN); - if(path == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Malloc failed to allocate %d bytes for path\n", MAX_FW_PATH_LEN)); - goto complete; - } - config_path = (u8 *) A_MALLOC(MAX_FW_PATH_LEN); - if(config_path == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Malloc failed to allocate %d bytes for config_path\n", MAX_FW_PATH_LEN)); - goto complete; - } - - if(A_ERROR == getDeviceType(hdev,&DevType)) { - status = 1; - goto complete; - } - if(A_ERROR == ReadVersionInfo(hdev)) { - status = 1; - goto complete; - } - - patchFileName = PATCH_FILE; - snprintf(path, MAX_FW_PATH_LEN, "%s/%xcoex/",CONFIG_PATH,Rom_Version); - if(DevType){ - if(DevType == 0xdeadc0de){ - PsFileName = PS_ASIC_FILE; - } else{ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" FPGA Test Image : %x %x \n",Rom_Version,Build_Version)); - if((Rom_Version == 0x99999999) && (Build_Version == 1)){ - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("FPGA Test Image : Skipping Patch File load\n")); - patchFileName = NULL; - } - PsFileName = PS_FPGA_FILE; - } - } - else{ - PsFileName = PS_ASIC_FILE; - } - - snprintf(config_path, MAX_FW_PATH_LEN, "%s%s",path,PsFileName); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%x: FPGA/ASIC PS File Name %s\n", DevType,config_path)); - /* Read the PS file to a dynamically allocated buffer */ - if(A_REQUEST_FIRMWARE(&firmware,config_path,firmwareDev) < 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: firmware file open error\n", __FUNCTION__ )); - status = 1; - goto complete; - - } - if(NULL == firmware || firmware->size == 0) { - status = 1; - goto complete; - } - buffer = (u8 *)A_MALLOC(firmware->size); - if(buffer != NULL) { - /* Copy the read file to a local Dynamic buffer */ - memcpy(buffer,firmware->data,firmware->size); - len = firmware->size; - A_RELEASE_FIRMWARE(firmware); - /* Parse the PS buffer to a global variable */ - status = AthDoParsePS(buffer,len); - kfree(buffer); - } else { - A_RELEASE_FIRMWARE(firmware); - } - - - /* Read the patch file to a dynamically allocated buffer */ - if(patchFileName != NULL) - snprintf(config_path, - MAX_FW_PATH_LEN, "%s%s",path,patchFileName); - else { - status = 0; - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Patch File Name %s\n", config_path)); - if((patchFileName == NULL) || (A_REQUEST_FIRMWARE(&firmware,config_path,firmwareDev) < 0)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: firmware file open error\n", __FUNCTION__ )); - /* - * It is not necessary that Patch file be available, continue with PS Operations if. - * failed. - */ - status = 0; - - } else { - if(NULL == firmware || firmware->size == 0) { - status = 0; - } else { - buffer = (u8 *)A_MALLOC(firmware->size); - if(buffer != NULL) { - /* Copy the read file to a local Dynamic buffer */ - memcpy(buffer,firmware->data,firmware->size); - len = firmware->size; - A_RELEASE_FIRMWARE(firmware); - /* parse and store the Patch file contents to a global variables */ - status = AthDoParsePatch(buffer,len); - kfree(buffer); - } else { - A_RELEASE_FIRMWARE(firmware); - } - } - } - - /* Create an HCI command list from the parsed PS and patch information */ - AthCreateCommandList(&HciCmdList,&numCmds); - - /* Form the parameter for PSSendOps() API */ - - - /* - * First Send the CRC packet, - * We have to continue with the PS operations only if the CRC packet has been replied with - * a Command complete event with status Error. - */ - - if(SendHCICommandWaitCommandComplete - (hdev, - HciCmdList[0].Hcipacket, - HciCmdList[0].packetLen, - &event, - &bufferToFree) == 0) { - if(ReadPSEvent(event) == 0) { /* Exit if the status is success */ - if(bufferToFree != NULL) { - kfree(bufferToFree); - } - -#ifndef HCI_TRANSPORT_SDIO - if(bdaddr && bdaddr[0] !='\0') { - write_bdaddr(hdev,bdaddr,BDADDR_TYPE_STRING); - } -#endif - status = 1; - goto complete; - } - if(bufferToFree != NULL) { - kfree(bufferToFree); - } - } else { - status = 0; - goto complete; - } - - for(i = 1; i bdaddr[0] !=0x00 || - hdev->bdaddr[1] !=0x00 || - hdev->bdaddr[2] !=0x00 || - hdev->bdaddr[3] !=0x00 || - hdev->bdaddr[4] !=0x00 || - hdev->bdaddr[5] !=0x00) - write_bdaddr(hdev,hdev->bdaddr,BDADDR_TYPE_HEX); - -#ifndef HCI_TRANSPORT_SDIO - - if(bdaddr && bdaddr[0] != '\0') { - write_bdaddr(hdev,bdaddr,BDADDR_TYPE_STRING); - } else -#endif /* HCI_TRANSPORT_SDIO */ - /* Write BDADDR Read from OTP here */ - - - -#endif - - { - /* Read Contents of BDADDR file if user has not provided any option */ - snprintf(config_path,MAX_FW_PATH_LEN, "%s%s",path,BDADDR_FILE); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Patch File Name %s\n", config_path)); - if(A_REQUEST_FIRMWARE(&firmware,config_path,firmwareDev) < 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: firmware file open error\n", __FUNCTION__ )); - status = 1; - goto complete; - } - if(NULL == firmware || firmware->size == 0) { - status = 1; - goto complete; - } - len = min_t(size_t, firmware->size, MAX_BDADDR_FORMAT_LENGTH - 1); - memcpy(config_bdaddr, firmware->data, len); - config_bdaddr[len] = '\0'; - write_bdaddr(hdev,config_bdaddr,BDADDR_TYPE_STRING); - A_RELEASE_FIRMWARE(firmware); - } -complete: -#ifndef HCI_TRANSPORT_SDIO - AthEnableSyncCommandOp(false); - PSTagMode = false; - wake_up_interruptible(&PsCompleteEvent); -#endif /* HCI_TRANSPORT_SDIO */ - if(NULL != HciCmdList) { - AthFreeCommandList(&HciCmdList,numCmds); - } - if(path) { - kfree(path); - } - if(config_path) { - kfree(config_path); - } - return status; -} -#ifndef HCI_TRANSPORT_SDIO -/* - * This API is used to send the HCI command to controller and return - * with a HCI Command Complete event. - * For HCI SDIO transport, this will be internally defined. - */ -int SendHCICommandWaitCommandComplete(struct ar3k_config_info *pConfig, - u8 *pHCICommand, - int CmdLength, - u8 **ppEventBuffer, - u8 **ppBufferToFree) -{ - if(CmdLength == 0) { - return A_ERROR; - } - Hci_log("COM Write -->",pHCICommand,CmdLength); - PSAcked = false; - if(PSHciWritepacket(pConfig,pHCICommand,CmdLength) == 0) { - /* If the controller is not available, return Error */ - return A_ERROR; - } - //add_timer(&psCmdTimer); - wait_event_interruptible(HciEvent,(PSAcked == true)); - if(NULL != HciEventpacket) { - *ppEventBuffer = HciEventpacket; - *ppBufferToFree = HciEventpacket; - } else { - /* Did not get an event from controller. return error */ - *ppBufferToFree = NULL; - return A_ERROR; - } - - return 0; -} -#endif /* HCI_TRANSPORT_SDIO */ - -int ReadPSEvent(u8* Data){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" PS Event %x %x %x\n",Data[4],Data[5],Data[3])); - - if(Data[4] == 0xFC && Data[5] == 0x00) - { - switch(Data[3]){ - case 0x0B: - return 0; - break; - case 0x0C: - /* Change Baudrate */ - return 0; - break; - case 0x04: - return 0; - break; - case 0x1E: - Rom_Version = Data[9]; - Rom_Version = ((Rom_Version << 8) |Data[8]); - Rom_Version = ((Rom_Version << 8) |Data[7]); - Rom_Version = ((Rom_Version << 8) |Data[6]); - - Build_Version = Data[13]; - Build_Version = ((Build_Version << 8) |Data[12]); - Build_Version = ((Build_Version << 8) |Data[11]); - Build_Version = ((Build_Version << 8) |Data[10]); - return 0; - break; - - - } - } - - return A_ERROR; -} -int str2ba(unsigned char *str_bdaddr,unsigned char *bdaddr) -{ - unsigned char bdbyte[3]; - unsigned char *str_byte = str_bdaddr; - int i,j; - unsigned char colon_present = 0; - - if(NULL != strstr(str_bdaddr,":")) { - colon_present = 1; - } - - - bdbyte[2] = '\0'; - - for( i = 0,j = 5; i < 6; i++, j--) { - bdbyte[0] = str_byte[0]; - bdbyte[1] = str_byte[1]; - bdaddr[j] = A_STRTOL(bdbyte,NULL,16); - if(colon_present == 1) { - str_byte+=3; - } else { - str_byte+=2; - } - } - return 0; -} - -int write_bdaddr(struct ar3k_config_info *pConfig,u8 *bdaddr,int type) -{ - u8 bdaddr_cmd[] = { 0x0B, 0xFC, 0x0A, 0x01, 0x01, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - u8 *event; - u8 *bufferToFree = NULL; - int result = A_ERROR; - int inc,outc; - - if (type == BDADDR_TYPE_STRING) - str2ba(bdaddr,&bdaddr_cmd[7]); - else { - /* Bdaddr has to be sent as LAP first */ - for(inc = 5 ,outc = 7; inc >=0; inc--, outc++) - bdaddr_cmd[outc] = bdaddr[inc]; - } - - if(0 == SendHCICommandWaitCommandComplete(pConfig,bdaddr_cmd, - sizeof(bdaddr_cmd), - &event,&bufferToFree)) { - - if(event[4] == 0xFC && event[5] == 0x00){ - if(event[3] == 0x0B){ - result = 0; - } - } - - } - if(bufferToFree != NULL) { - kfree(bufferToFree); - } - return result; - -} -int ReadVersionInfo(struct ar3k_config_info *pConfig) -{ - u8 hciCommand[] = {0x1E,0xfc,0x00}; - u8 *event; - u8 *bufferToFree = NULL; - int result = A_ERROR; - if(0 == SendHCICommandWaitCommandComplete(pConfig,hciCommand,sizeof(hciCommand),&event,&bufferToFree)) { - result = ReadPSEvent(event); - - } - if(bufferToFree != NULL) { - kfree(bufferToFree); - } - return result; -} -int getDeviceType(struct ar3k_config_info *pConfig, u32 *code) -{ - u8 hciCommand[] = {0x05,0xfc,0x05,0x00,0x00,0x00,0x00,0x04}; - u8 *event; - u8 *bufferToFree = NULL; - u32 reg; - int result = A_ERROR; - *code = 0; - hciCommand[3] = (u8)(FPGA_REGISTER & 0xFF); - hciCommand[4] = (u8)((FPGA_REGISTER >> 8) & 0xFF); - hciCommand[5] = (u8)((FPGA_REGISTER >> 16) & 0xFF); - hciCommand[6] = (u8)((FPGA_REGISTER >> 24) & 0xFF); - if(0 == SendHCICommandWaitCommandComplete(pConfig,hciCommand,sizeof(hciCommand),&event,&bufferToFree)) { - - if(event[4] == 0xFC && event[5] == 0x00){ - switch(event[3]){ - case 0x05: - reg = event[9]; - reg = ((reg << 8) |event[8]); - reg = ((reg << 8) |event[7]); - reg = ((reg << 8) |event[6]); - *code = reg; - result = 0; - - break; - case 0x06: - //Sleep(500); - break; - } - } - - } - if(bufferToFree != NULL) { - kfree(bufferToFree); - } - return result; -} - - diff --git a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.h b/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.h deleted file mode 100644 index d4435130780..00000000000 --- a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * This file defines the symbols exported by Atheros PS and patch download module. - * define the constant HCI_TRANSPORT_SDIO if the module is being used for HCI SDIO transport. - * defined. - * - * - * ar3kcpsconfig.h - * - * - * - * The software source and binaries included in this development package are - * licensed, not sold. You, or your company, received the package under one - * or more license agreements. The rights granted to you are specifically - * listed in these license agreement(s). All other rights remain with Atheros - * Communications, Inc., its subsidiaries, or the respective owner including - * those listed on the included copyright notices.. Distribution of any - * portion of this package must be in strict compliance with the license - * agreement(s) terms. - * - * - * - */ - - - -#ifndef __AR3KPSCONFIG_H -#define __AR3KPSCONFIG_H - -/* - * Define the flag HCI_TRANSPORT_SDIO and undefine HCI_TRANSPORT_UART if the transport being used is SDIO. - */ -#undef HCI_TRANSPORT_UART - -#include -#include -#include - - -#include -#include - - -#include -#include - -#include "ar3kpsparser.h" - -#define FPGA_REGISTER 0x4FFC -#define BDADDR_TYPE_STRING 0 -#define BDADDR_TYPE_HEX 1 -#define CONFIG_PATH "ar3k" - -#define PS_ASIC_FILE "PS_ASIC.pst" -#define PS_FPGA_FILE "PS_FPGA.pst" - -#define PATCH_FILE "RamPatch.txt" -#define BDADDR_FILE "ar3kbdaddr.pst" - -#define ROM_VER_AR3001_3_1_0 30000 -#define ROM_VER_AR3001_3_1_1 30101 - - -#ifndef HCI_TRANSPORT_SDIO -#define struct ar3k_config_info struct hci_dev -extern wait_queue_head_t HciEvent; -extern wait_queue_t Eventwait; -extern u8 *HciEventpacket; -#endif /* #ifndef HCI_TRANSPORT_SDIO */ - -int AthPSInitialize(struct ar3k_config_info *hdev); -int ReadPSEvent(u8* Data); -#endif /* __AR3KPSCONFIG_H */ diff --git a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.c b/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.c deleted file mode 100644 index b99a11a9dd6..00000000000 --- a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.c +++ /dev/null @@ -1,969 +0,0 @@ -/* - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * This file implements the Atheros PS and patch parser. - * It implements APIs to parse data buffer with patch and PS information and convert it to HCI commands. - * - * - * - * ar3kpsparser.c - * - * - * - * The software source and binaries included in this development package are - * licensed, not sold. You, or your company, received the package under one - * or more license agreements. The rights granted to you are specifically - * listed in these license agreement(s). All other rights remain with Atheros - * Communications, Inc., its subsidiaries, or the respective owner including - * those listed on the included copyright notices.. Distribution of any - * portion of this package must be in strict compliance with the license - * agreement(s) terms. - * - * - * - */ - - -#include "ar3kpsparser.h" - -#include -#include - -#define BD_ADDR_SIZE 6 -#define WRITE_PATCH 8 -#define ENABLE_PATCH 11 -#define PS_RESET 2 -#define PS_WRITE 1 -#define PS_VERIFY_CRC 9 -#define CHANGE_BDADDR 15 - -#define HCI_COMMAND_HEADER 7 - -#define HCI_EVENT_SIZE 7 - -#define WRITE_PATCH_COMMAND_STATUS_OFFSET 5 - -#define PS_RAM_SIZE 2048 - -#define RAM_PS_REGION (1<<0) -#define RAM_PATCH_REGION (1<<1) -#define RAMPS_MAX_PS_DATA_PER_TAG 20000 -#define MAX_RADIO_CFG_TABLE_SIZE 244 -#define RAMPS_MAX_PS_TAGS_PER_FILE 50 - -#define PS_MAX_LEN 500 -#define LINE_SIZE_MAX (PS_MAX_LEN *2) - -/* Constant values used by parser */ -#define BYTES_OF_PS_DATA_PER_LINE 16 -#define RAMPS_MAX_PS_DATA_PER_TAG 20000 - - -/* Number pf PS/Patch entries in an HCI packet */ -#define MAX_BYTE_LENGTH 244 - -#define SKIP_BLANKS(str) while (*str == ' ') str++ - -enum MinBootFileFormatE -{ - MB_FILEFORMAT_RADIOTBL, - MB_FILEFORMAT_PATCH, - MB_FILEFORMAT_COEXCONFIG -}; - -enum RamPsSection -{ - RAM_PS_SECTION, - RAM_PATCH_SECTION, - RAM_DYN_MEM_SECTION -}; - -enum eType { - eHex, - edecimal -}; - - -typedef struct tPsTagEntry -{ - u32 TagId; - u32 TagLen; - u8 *TagData; -} tPsTagEntry, *tpPsTagEntry; - -typedef struct tRamPatch -{ - u16 Len; - u8 *Data; -} tRamPatch, *ptRamPatch; - - - -struct st_ps_data_format { - enum eType eDataType; - bool bIsArray; -}; - -struct st_read_status { - unsigned uTagID; - unsigned uSection; - unsigned uLineCount; - unsigned uCharCount; - unsigned uByteCount; -}; - - -/* Stores the number of PS Tags */ -static u32 Tag_Count = 0; - -/* Stores the number of patch commands */ -static u32 Patch_Count = 0; -static u32 Total_tag_lenght = 0; -bool BDADDR = false; -u32 StartTagId; - -tPsTagEntry PsTagEntry[RAMPS_MAX_PS_TAGS_PER_FILE]; -tRamPatch RamPatch[MAX_NUM_PATCH_ENTRY]; - - -int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat); -char AthReadChar(u8 *buffer, u32 len,u32 *pos); -char *AthGetLine(char *buffer, int maxlen, u8 *srcbuffer,u32 len,u32 *pos); -static int AthPSCreateHCICommand(u8 Opcode, u32 Param1,struct ps_cmd_packet *PSPatchPacket,u32 *index); - -/* Function to reads the next character from the input buffer */ -char AthReadChar(u8 *buffer, u32 len,u32 *pos) -{ - char Ch; - if(buffer == NULL || *pos >=len ) - { - return '\0'; - } else { - Ch = buffer[*pos]; - (*pos)++; - return Ch; - } -} -/* PS parser helper function */ -unsigned int uGetInputDataFormat(char *pCharLine, struct st_ps_data_format *pstFormat) -{ - if(pCharLine[0] != '[') { - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - return 0; - } - switch(pCharLine[1]) { - case 'H': - case 'h': - if(pCharLine[2]==':') { - if((pCharLine[3]== 'a') || (pCharLine[3]== 'A')) { - if(pCharLine[4] == ']') { - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 5; - return 0; - } - else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format\n")); //[H:A - return 1; - } - } - if((pCharLine[3]== 'S') || (pCharLine[3]== 's')) { - if(pCharLine[4] == ']') { - pstFormat->eDataType = eHex; - pstFormat->bIsArray = false; - pCharLine += 5; - return 0; - } - else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format\n")); //[H:A - return 1; - } - } - else if(pCharLine[3] == ']') { //[H:] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 4; - return 0; - } - else { //[H: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format\n")); - return 1; - } - } - else if(pCharLine[2]==']') { //[H] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 3; - return 0; - } - else { //[H - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format\n")); - return 1; - } - break; - - case 'A': - case 'a': - if(pCharLine[2]==':') { - if((pCharLine[3]== 'h') || (pCharLine[3]== 'H')) { - if(pCharLine[4] == ']') { - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 5; - return 0; - } - else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 1\n")); //[A:H - return 1; - } - } - else if(pCharLine[3]== ']') { //[A:] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 4; - return 0; - } - else { //[A: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 2\n")); - return 1; - } - } - else if(pCharLine[2]==']') { //[H] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 3; - return 0; - } - else { //[H - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 3\n")); - return 1; - } - break; - - case 'S': - case 's': - if(pCharLine[2]==':') { - if((pCharLine[3]== 'h') || (pCharLine[3]== 'H')) { - if(pCharLine[4] == ']') { - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 5; - return 0; - } - else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 5\n")); //[A:H - return 1; - } - } - else if(pCharLine[3]== ']') { //[A:] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 4; - return 0; - } - else { //[A: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 6\n")); - return 1; - } - } - else if(pCharLine[2]==']') { //[H] - pstFormat->eDataType = eHex; - pstFormat->bIsArray = true; - pCharLine += 3; - return 0; - } - else { //[H - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 7\n")); - return 1; - } - break; - - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Illegal Data format 8\n")); - return 1; - } -} - -unsigned int uReadDataInSection(char *pCharLine, struct st_ps_data_format stPS_DataFormat) -{ - char *pTokenPtr = pCharLine; - - if(pTokenPtr[0] == '[') { - while(pTokenPtr[0] != ']' && pTokenPtr[0] != '\0') { - pTokenPtr++; - } - if(pTokenPtr[0] == '\0') { - return (0x0FFF); - } - pTokenPtr++; - - - } - if(stPS_DataFormat.eDataType == eHex) { - if(stPS_DataFormat.bIsArray == true) { - //Not implemented - return (0x0FFF); - } - else { - return (A_STRTOL(pTokenPtr, NULL, 16)); - } - } - else { - //Not implemented - return (0x0FFF); - } -} -int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat) -{ - char *Buffer; - char *pCharLine; - u8 TagCount; - u16 ByteCount; - u8 ParseSection=RAM_PS_SECTION; - u32 pos; - - - - int uReadCount; - struct st_ps_data_format stPS_DataFormat; - struct st_read_status stReadStatus = {0, 0, 0,0}; - pos = 0; - Buffer = NULL; - - if (srcbuffer == NULL || srclen == 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Could not open .\n")); - return A_ERROR; - } - TagCount = 0; - ByteCount = 0; - Buffer = A_MALLOC(LINE_SIZE_MAX + 1); - if(NULL == Buffer) { - return A_ERROR; - } - if (FileFormat == MB_FILEFORMAT_PATCH) - { - int LineRead = 0; - while((pCharLine = AthGetLine(Buffer, LINE_SIZE_MAX, srcbuffer,srclen,&pos)) != NULL) - { - - SKIP_BLANKS(pCharLine); - - // Comment line or empty line - if ((pCharLine[0] == '/') && (pCharLine[1] == '/')) - { - continue; - } - - if ((pCharLine[0] == '#')) { - if (stReadStatus.uSection != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("error\n")); - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - else { - stReadStatus.uSection = 1; - continue; - } - } - if ((pCharLine[0] == '/') && (pCharLine[1] == '*')) - { - pCharLine+=2; - SKIP_BLANKS(pCharLine); - - if(!strncmp(pCharLine,"PA",2)||!strncmp(pCharLine,"Pa",2)||!strncmp(pCharLine,"pa",2)) - ParseSection=RAM_PATCH_SECTION; - - if(!strncmp(pCharLine,"DY",2)||!strncmp(pCharLine,"Dy",2)||!strncmp(pCharLine,"dy",2)) - ParseSection=RAM_DYN_MEM_SECTION; - - if(!strncmp(pCharLine,"PS",2)||!strncmp(pCharLine,"Ps",2)||!strncmp(pCharLine,"ps",2)) - ParseSection=RAM_PS_SECTION; - - LineRead = 0; - stReadStatus.uSection = 0; - - continue; - } - - switch(ParseSection) - { - case RAM_PS_SECTION: - { - if (stReadStatus.uSection == 1) //TagID - { - SKIP_BLANKS(pCharLine); - if(uGetInputDataFormat(pCharLine, &stPS_DataFormat)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat fail\n")); - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - //pCharLine +=5; - PsTagEntry[TagCount].TagId = uReadDataInSection(pCharLine, stPS_DataFormat); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" TAG ID %d \n",PsTagEntry[TagCount].TagId)); - - //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("tag # %x\n", PsTagEntry[TagCount].TagId); - if (TagCount == 0) - { - StartTagId = PsTagEntry[TagCount].TagId; - } - stReadStatus.uSection = 2; - } - else if (stReadStatus.uSection == 2) //TagLength - { - - if(uGetInputDataFormat(pCharLine, &stPS_DataFormat)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat fail \n")); - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - //pCharLine +=5; - ByteCount = uReadDataInSection(pCharLine, stPS_DataFormat); - - //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("tag length %x\n", ByteCount)); - if (ByteCount > LINE_SIZE_MAX/2) - { - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - PsTagEntry[TagCount].TagLen = ByteCount; - PsTagEntry[TagCount].TagData = (u8 *)A_MALLOC(ByteCount); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" TAG Length %d Tag Index %d \n",PsTagEntry[TagCount].TagLen,TagCount)); - stReadStatus.uSection = 3; - stReadStatus.uLineCount = 0; - } - else if( stReadStatus.uSection == 3) { //Data - - if(stReadStatus.uLineCount == 0) { - if(uGetInputDataFormat(pCharLine,&stPS_DataFormat)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat Fail\n")); - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - //pCharLine +=5; - } - SKIP_BLANKS(pCharLine); - stReadStatus.uCharCount = 0; - if(pCharLine[stReadStatus.uCharCount] == '[') { - while(pCharLine[stReadStatus.uCharCount] != ']' && pCharLine[stReadStatus.uCharCount] != '\0' ) { - stReadStatus.uCharCount++; - } - if(pCharLine[stReadStatus.uCharCount] == ']' ) { - stReadStatus.uCharCount++; - } else { - stReadStatus.uCharCount = 0; - } - } - uReadCount = (ByteCount > BYTES_OF_PS_DATA_PER_LINE)? BYTES_OF_PS_DATA_PER_LINE: ByteCount; - //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ")); - if((stPS_DataFormat.eDataType == eHex) && stPS_DataFormat.bIsArray == true) { - while(uReadCount > 0) { - PsTagEntry[TagCount].TagData[stReadStatus.uByteCount] = - (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount]) << 4) - | (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 1])); - - PsTagEntry[TagCount].TagData[stReadStatus.uByteCount+1] = - (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 3]) << 4) - | (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 4])); - - stReadStatus.uCharCount += 6; // read two bytes, plus a space; - stReadStatus.uByteCount += 2; - uReadCount -= 2; - } - if(ByteCount > BYTES_OF_PS_DATA_PER_LINE) { - ByteCount -= BYTES_OF_PS_DATA_PER_LINE; - } - else { - ByteCount = 0; - } - } - else { - //to be implemented - } - - stReadStatus.uLineCount++; - - if(ByteCount == 0) { - stReadStatus.uSection = 0; - stReadStatus.uCharCount = 0; - stReadStatus.uLineCount = 0; - stReadStatus.uByteCount = 0; - } - else { - stReadStatus.uCharCount = 0; - } - - if((stReadStatus.uSection == 0)&&(++TagCount == RAMPS_MAX_PS_TAGS_PER_FILE)) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("\n Buffer over flow PS File too big!!!")); - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - //Sleep (3000); - //exit(1); - } - - } - } - - break; - default: - { - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - break; - } - LineRead++; - } - Tag_Count = TagCount; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Number of Tags %d\n", Tag_Count)); - } - - - if (TagCount > RAMPS_MAX_PS_TAGS_PER_FILE) - { - - if(Buffer != NULL) { - kfree(Buffer); - } - return A_ERROR; - } - - if(Buffer != NULL) { - kfree(Buffer); - } - return 0; - -} - - - -/********************/ - - -int GetNextTwoChar(u8 *srcbuffer,u32 len, u32 *pos, char *buffer) -{ - unsigned char ch; - - ch = AthReadChar(srcbuffer,len,pos); - if(ch != '\0' && isxdigit(ch)) { - buffer[0] = ch; - } else - { - return A_ERROR; - } - ch = AthReadChar(srcbuffer,len,pos); - if(ch != '\0' && isxdigit(ch)) { - buffer[1] = ch; - } else - { - return A_ERROR; - } - return 0; -} - -int AthDoParsePatch(u8 *patchbuffer, u32 patchlen) -{ - - char Byte[3]; - char Line[MAX_BYTE_LENGTH + 1]; - int ByteCount,ByteCount_Org; - int count; - int i,j,k; - int data; - u32 filepos; - Byte[2] = '\0'; - j = 0; - filepos = 0; - Patch_Count = 0; - - while(NULL != AthGetLine(Line,MAX_BYTE_LENGTH,patchbuffer,patchlen,&filepos)) { - if(strlen(Line) <= 1 || !isxdigit(Line[0])) { - continue; - } else { - break; - } - } - ByteCount = A_STRTOL(Line, NULL, 16); - ByteCount_Org = ByteCount; - - while(ByteCount > MAX_BYTE_LENGTH){ - - /* Handle case when the number of patch buffer is more than the 20K */ - if(MAX_NUM_PATCH_ENTRY == Patch_Count) { - for(i = 0; i < Patch_Count; i++) { - kfree(RamPatch[i].Data); - } - return A_ERROR; - } - RamPatch[Patch_Count].Len= MAX_BYTE_LENGTH; - RamPatch[Patch_Count].Data = (u8 *)A_MALLOC(MAX_BYTE_LENGTH); - Patch_Count ++; - - - ByteCount= ByteCount - MAX_BYTE_LENGTH; - } - - RamPatch[Patch_Count].Len= (ByteCount & 0xFF); - if(ByteCount != 0) { - RamPatch[Patch_Count].Data = (u8 *)A_MALLOC(ByteCount); - Patch_Count ++; - } - count = 0; - while(ByteCount_Org > MAX_BYTE_LENGTH){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Index [%d]\n",j)); - for (i = 0,k=0; i < MAX_BYTE_LENGTH*2; i += 2,k++,count +=2) { - if(GetNextTwoChar(patchbuffer,patchlen,&filepos,Byte) == A_ERROR) { - return A_ERROR; - } - data = A_STRTOUL(&Byte[0], NULL, 16); - RamPatch[j].Data[k] = (data & 0xFF); - - - } - j++; - ByteCount_Org = ByteCount_Org - MAX_BYTE_LENGTH; - } - if(j == 0){ - j++; - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Index [%d]\n",j)); - for (k=0; k < ByteCount_Org; i += 2,k++,count+=2) { - if(GetNextTwoChar(patchbuffer,patchlen,&filepos,Byte) == A_ERROR) { - return A_ERROR; - } - data = A_STRTOUL(Byte, NULL, 16); - RamPatch[j].Data[k] = (data & 0xFF); - - - } - return 0; -} - - -/********************/ -int AthDoParsePS(u8 *srcbuffer, u32 srclen) -{ - int status; - int i; - bool BDADDR_Present = false; - - Tag_Count = 0; - - Total_tag_lenght = 0; - BDADDR = false; - - - status = A_ERROR; - - if(NULL != srcbuffer && srclen != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("File Open Operation Successful\n")); - - status = AthParseFilesUnified(srcbuffer,srclen,MB_FILEFORMAT_PATCH); - } - - - - if(Tag_Count == 0){ - Total_tag_lenght = 10; - - } - else{ - for(i=0; i 0 && !BDADDR_Present){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BD ADDR is not present adding 10 extra bytes \r\n")); - Total_tag_lenght=Total_tag_lenght + 10; - } - Total_tag_lenght = Total_tag_lenght+ 10 + (Tag_Count*4); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** Total Length %d\n",Total_tag_lenght)); - - - return status; -} -char *AthGetLine(char *buffer, int maxlen, u8 *srcbuffer,u32 len,u32 *pos) -{ - - int count; - static short flag; - char CharRead; - count = 0; - flag = A_ERROR; - - do - { - CharRead = AthReadChar(srcbuffer,len,pos); - if( CharRead == '\0' ) { - buffer[count+1] = '\0'; - if(count == 0) { - return NULL; - } - else { - return buffer; - } - } - - if(CharRead == 13) { - } else if(CharRead == 10) { - buffer[count] ='\0'; - flag = A_ERROR; - return buffer; - }else { - buffer[count++] = CharRead; - } - - } - while(count < maxlen-1 && CharRead != '\0'); - buffer[count] = '\0'; - - return buffer; -} - -static void LoadHeader(u8 *HCI_PS_Command,u8 opcode,int length,int index){ - - HCI_PS_Command[0]= 0x0B; - HCI_PS_Command[1]= 0xFC; - HCI_PS_Command[2]= length + 4; - HCI_PS_Command[3]= opcode; - HCI_PS_Command[4]= (index & 0xFF); - HCI_PS_Command[5]= ((index>>8) & 0xFF); - HCI_PS_Command[6]= length; -} - -///////////////////////// -// -int AthCreateCommandList(struct ps_cmd_packet **HciPacketList, u32 *numPackets) -{ - - u8 count; - u32 NumcmdEntry = 0; - - u32 Crc = 0; - *numPackets = 0; - - - if(Patch_Count > 0) - Crc |= RAM_PATCH_REGION; - if(Tag_Count > 0) - Crc |= RAM_PS_REGION; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("PS Thread Started CRC %x Patch Count %d Tag Count %d \n",Crc,Patch_Count,Tag_Count)); - - if(Patch_Count || Tag_Count ){ - NumcmdEntry+=(2 + Patch_Count + Tag_Count); /* CRC Packet + PS Reset Packet + Patch List + PS List*/ - if(Patch_Count > 0) { - NumcmdEntry++; /* Patch Enable Command */ - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Num Cmd Entries %d Size %d \r\n",NumcmdEntry,(u32)sizeof(struct ps_cmd_packet) * NumcmdEntry)); - (*HciPacketList) = A_MALLOC(sizeof(struct ps_cmd_packet) * NumcmdEntry); - if(NULL == *HciPacketList) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("memory allocation failed \r\n")); - } - AthPSCreateHCICommand(PS_VERIFY_CRC,Crc,*HciPacketList,numPackets); - if(Patch_Count > 0){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Write Patch**** \r\n")); - AthPSCreateHCICommand(WRITE_PATCH,Patch_Count,*HciPacketList,numPackets); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Enable Patch**** \r\n")); - AthPSCreateHCICommand(ENABLE_PATCH,0,*HciPacketList,numPackets); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** PS Reset**** %d[0x%x] \r\n",PS_RAM_SIZE,PS_RAM_SIZE)); - AthPSCreateHCICommand(PS_RESET,PS_RAM_SIZE,*HciPacketList,numPackets); - if(Tag_Count > 0){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** PS Write**** \r\n")); - AthPSCreateHCICommand(PS_WRITE,Tag_Count,*HciPacketList,numPackets); - } - } - if(!BDADDR){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BD ADDR not present \r\n")); - - } - for(count = 0; count < Patch_Count; count++) { - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing Patch Buffer %d \r\n",count)); - kfree(RamPatch[count].Data); - } - - for(count = 0; count < Tag_Count; count++) { - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing PS Buffer %d \r\n",count)); - kfree(PsTagEntry[count].TagData); - } - -/* - * SDIO Transport uses synchronous mode of data transfer - * So, AthPSOperations() call returns only after receiving the - * command complete event. - */ - return *numPackets; -} - - -//////////////////////// - -///////////// -static int AthPSCreateHCICommand(u8 Opcode, u32 Param1,struct ps_cmd_packet *PSPatchPacket,u32 *index) -{ - u8 *HCI_PS_Command; - u32 Length; - int i,j; - - switch(Opcode) - { - case WRITE_PATCH: - - - for(i=0;i< Param1;i++){ - - HCI_PS_Command = (u8 *) A_MALLOC(RamPatch[i].Len+HCI_COMMAND_HEADER); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Allocated Buffer Size %d\n",RamPatch[i].Len+HCI_COMMAND_HEADER)); - if(HCI_PS_Command == NULL){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MALLOC Failed\r\n")); - return A_ERROR; - } - memset (HCI_PS_Command, 0, RamPatch[i].Len+HCI_COMMAND_HEADER); - LoadHeader(HCI_PS_Command,Opcode,RamPatch[i].Len,i); - for(j=0;j> 8) & 0xFF); - PSPatchPacket[*index].Hcipacket = HCI_PS_Command; - PSPatchPacket[*index].packetLen = Length+HCI_COMMAND_HEADER; - (*index)++; - - break; - - case PS_WRITE: - for(i=0;i< Param1;i++){ - if(PsTagEntry[i].TagId ==1) - BDADDR = true; - - HCI_PS_Command = (u8 *) A_MALLOC(PsTagEntry[i].TagLen+HCI_COMMAND_HEADER); - if(HCI_PS_Command == NULL){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MALLOC Failed\r\n")); - return A_ERROR; - } - - memset (HCI_PS_Command, 0, PsTagEntry[i].TagLen+HCI_COMMAND_HEADER); - LoadHeader(HCI_PS_Command,Opcode,PsTagEntry[i].TagLen,PsTagEntry[i].TagId); - - for(j=0;j -#include -#include "athdefs.h" -#ifdef HCI_TRANSPORT_SDIO -#include "a_config.h" -#include "a_osapi.h" -#define ATH_MODULE_NAME misc -#include "a_debug.h" -#include "common_drv.h" -#include "hci_transport_api.h" -#include "ar3kconfig.h" -#else -#ifndef A_PRINTF -#define A_PRINTF(args...) printk(KERN_ALERT args) -#endif /* A_PRINTF */ -#include "debug_linux.h" - -/* Helper data type declaration */ - -#define ATH_DEBUG_ERR (1 << 0) -#define ATH_DEBUG_WARN (1 << 1) -#define ATH_DEBUG_INFO (1 << 2) - - - -#define false 0 -#define true 1 - -#ifndef A_MALLOC -#define A_MALLOC(size) kmalloc((size),GFP_KERNEL) -#endif /* A_MALLOC */ -#endif /* HCI_TRANSPORT_UART */ - -/* String manipulation APIs */ -#ifndef A_STRTOUL -#define A_STRTOUL simple_strtoul -#endif /* A_STRTOL */ - -#ifndef A_STRTOL -#define A_STRTOL simple_strtol -#endif /* A_STRTOL */ - - -/* The maximum number of bytes possible in a patch entry */ -#define MAX_PATCH_SIZE 20000 - -/* Maximum HCI packets that will be formed from the Patch file */ -#define MAX_NUM_PATCH_ENTRY (MAX_PATCH_SIZE/MAX_BYTE_LENGTH) + 1 - - - - - - - -struct ps_cmd_packet -{ - u8 *Hcipacket; - int packetLen; -}; - -/* Parses a Patch information buffer and store it in global structure */ -int AthDoParsePatch(u8 *, u32 ); - -/* parses a PS information buffer and stores it in a global structure */ -int AthDoParsePS(u8 *, u32 ); - -/* - * Uses the output of Both AthDoParsePS and AthDoParsePatch APIs to form HCI command array with - * all the PS and patch commands. - * The list will have the below mentioned commands in order. - * CRC command packet - * Download patch command(s) - * Enable patch Command - * PS Reset Command - * PS Tag Command(s) - * - */ -int AthCreateCommandList(struct ps_cmd_packet **, u32 *); - -/* Cleanup the dynamically allicated HCI command list */ -int AthFreeCommandList(struct ps_cmd_packet **HciPacketList, u32 numPackets); -#endif /* __AR3KPSPARSER_H */ diff --git a/drivers/staging/ath6kl/miscdrv/common_drv.c b/drivers/staging/ath6kl/miscdrv/common_drv.c deleted file mode 100644 index 1ce539aa019..00000000000 --- a/drivers/staging/ath6kl/miscdrv/common_drv.c +++ /dev/null @@ -1,910 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" - -#include "hw/mbox_host_reg.h" -#include "gpio_reg.h" -#include "hw/rtc_reg.h" -#include "hw/mbox_reg.h" -#include "hw/apb_map.h" - -#include "a_osapi.h" -#include "targaddrs.h" -#include "hif.h" -#include "htc_api.h" -#include "wmi.h" -#include "bmi.h" -#include "bmi_msg.h" -#include "common_drv.h" -#define ATH_MODULE_NAME misc -#include "a_debug.h" -#include "ar6000_diag.h" - -static ATH_DEBUG_MODULE_DBG_INFO *g_pModuleInfoHead = NULL; -static A_MUTEX_T g_ModuleListLock; -static bool g_ModuleDebugInit = false; - -#ifdef ATH_DEBUG_MODULE - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(misc, - "misc", - "Common and misc APIs", - ATH_DEBUG_MASK_DEFAULTS, - 0, - NULL); - -#endif - -#define HOST_INTEREST_ITEM_ADDRESS(target, item) \ - ((((target) == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \ - (((target) == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0))) - - -#define AR6001_LOCAL_COUNT_ADDRESS 0x0c014080 -#define AR6002_LOCAL_COUNT_ADDRESS 0x00018080 -#define AR6003_LOCAL_COUNT_ADDRESS 0x00018080 -#define CPU_DBG_SEL_ADDRESS 0x00000483 -#define CPU_DBG_ADDRESS 0x00000484 - -static u8 custDataAR6002[AR6002_CUST_DATA_SIZE]; -static u8 custDataAR6003[AR6003_CUST_DATA_SIZE]; - -/* Compile the 4BYTE version of the window register setup routine, - * This mitigates host interconnect issues with non-4byte aligned bus requests, some - * interconnects use bus adapters that impose strict limitations. - * Since diag window access is not intended for performance critical operations, the 4byte mode should - * be satisfactory even though it generates 4X the bus activity. */ - -#ifdef USE_4BYTE_REGISTER_ACCESS - - /* set the window address register (using 4-byte register access ). */ -int ar6000_SetAddressWindowRegister(struct hif_device *hifDevice, u32 RegisterAddr, u32 Address) -{ - int status; - u8 addrValue[4]; - s32 i; - - /* write bytes 1,2,3 of the register to set the upper address bytes, the LSB is written - * last to initiate the access cycle */ - - for (i = 1; i <= 3; i++) { - /* fill the buffer with the address byte value we want to hit 4 times*/ - addrValue[0] = ((u8 *)&Address)[i]; - addrValue[1] = addrValue[0]; - addrValue[2] = addrValue[0]; - addrValue[3] = addrValue[0]; - - /* hit each byte of the register address with a 4-byte write operation to the same address, - * this is a harmless operation */ - status = HIFReadWrite(hifDevice, - RegisterAddr+i, - addrValue, - 4, - HIF_WR_SYNC_BYTE_FIX, - NULL); - if (status) { - break; - } - } - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write initial bytes of 0x%x to window reg: 0x%X \n", - Address, RegisterAddr)); - return status; - } - - /* write the address register again, this time write the whole 4-byte value. - * The effect here is that the LSB write causes the cycle to start, the extra - * 3 byte write to bytes 1,2,3 has no effect since we are writing the same values again */ - status = HIFReadWrite(hifDevice, - RegisterAddr, - (u8 *)(&Address), - 4, - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to window reg: 0x%X \n", - Address, RegisterAddr)); - return status; - } - - return 0; - - - -} - - -#else - - /* set the window address register */ -int ar6000_SetAddressWindowRegister(struct hif_device *hifDevice, u32 RegisterAddr, u32 Address) -{ - int status; - - /* write bytes 1,2,3 of the register to set the upper address bytes, the LSB is written - * last to initiate the access cycle */ - status = HIFReadWrite(hifDevice, - RegisterAddr+1, /* write upper 3 bytes */ - ((u8 *)(&Address))+1, - sizeof(u32)-1, - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write initial bytes of 0x%x to window reg: 0x%X \n", - RegisterAddr, Address)); - return status; - } - - /* write the LSB of the register, this initiates the operation */ - status = HIFReadWrite(hifDevice, - RegisterAddr, - (u8 *)(&Address), - sizeof(u8), - HIF_WR_SYNC_BYTE_INC, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to window reg: 0x%X \n", - RegisterAddr, Address)); - return status; - } - - return 0; -} - -#endif - -/* - * Read from the AR6000 through its diagnostic window. - * No cooperation from the Target is required for this. - */ -int -ar6000_ReadRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data) -{ - int status; - - /* set window register to start read cycle */ - status = ar6000_SetAddressWindowRegister(hifDevice, - WINDOW_READ_ADDR_ADDRESS, - *address); - - if (status) { - return status; - } - - /* read the data */ - status = HIFReadWrite(hifDevice, - WINDOW_DATA_ADDRESS, - (u8 *)data, - sizeof(u32), - HIF_RD_SYNC_BYTE_INC, - NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot read from WINDOW_DATA_ADDRESS\n")); - return status; - } - - return status; -} - - -/* - * Write to the AR6000 through its diagnostic window. - * No cooperation from the Target is required for this. - */ -int -ar6000_WriteRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data) -{ - int status; - - /* set write data */ - status = HIFReadWrite(hifDevice, - WINDOW_DATA_ADDRESS, - (u8 *)data, - sizeof(u32), - HIF_WR_SYNC_BYTE_INC, - NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to WINDOW_DATA_ADDRESS\n", *data)); - return status; - } - - /* set window register, which starts the write cycle */ - return ar6000_SetAddressWindowRegister(hifDevice, - WINDOW_WRITE_ADDR_ADDRESS, - *address); - } - -int -ar6000_ReadDataDiag(struct hif_device *hifDevice, u32 address, - u8 *data, u32 length) -{ - u32 count; - int status = 0; - - for (count = 0; count < length; count += 4, address += 4) { - if ((status = ar6000_ReadRegDiag(hifDevice, &address, - (u32 *)&data[count])) != 0) - { - break; - } - } - - return status; -} - -int -ar6000_WriteDataDiag(struct hif_device *hifDevice, u32 address, - u8 *data, u32 length) -{ - u32 count; - int status = 0; - - for (count = 0; count < length; count += 4, address += 4) { - if ((status = ar6000_WriteRegDiag(hifDevice, &address, - (u32 *)&data[count])) != 0) - { - break; - } - } - - return status; -} - -int -ar6k_ReadTargetRegister(struct hif_device *hifDevice, int regsel, u32 *regval) -{ - int status; - u8 vals[4]; - u8 register_selection[4]; - - register_selection[0] = register_selection[1] = register_selection[2] = register_selection[3] = (regsel & 0xff); - status = HIFReadWrite(hifDevice, - CPU_DBG_SEL_ADDRESS, - register_selection, - 4, - HIF_WR_SYNC_BYTE_FIX, - NULL); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write CPU_DBG_SEL (%d)\n", regsel)); - return status; - } - - status = HIFReadWrite(hifDevice, - CPU_DBG_ADDRESS, - (u8 *)vals, - sizeof(vals), - HIF_RD_SYNC_BYTE_INC, - NULL); - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot read from CPU_DBG_ADDRESS\n")); - return status; - } - - *regval = vals[0]<<0 | vals[1]<<8 | vals[2]<<16 | vals[3]<<24; - - return status; -} - -void -ar6k_FetchTargetRegs(struct hif_device *hifDevice, u32 *targregs) -{ - int i; - u32 val; - - for (i=0; i REGISTER_DUMP_LEN_MAX -#error "REG_DUMP_COUNT_AR6001 too large" -#endif -#if REG_DUMP_COUNT_AR6002 > REGISTER_DUMP_LEN_MAX -#error "REG_DUMP_COUNT_AR6002 too large" -#endif -#if REG_DUMP_COUNT_AR6003 > REGISTER_DUMP_LEN_MAX -#error "REG_DUMP_COUNT_AR6003 too large" -#endif - - -void ar6000_dump_target_assert_info(struct hif_device *hifDevice, u32 TargetType) -{ - u32 address; - u32 regDumpArea = 0; - int status; - u32 regDumpValues[REGISTER_DUMP_LEN_MAX]; - u32 regDumpCount = 0; - u32 i; - - do { - - /* the reg dump pointer is copied to the host interest area */ - address = HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_failure_state); - address = TARG_VTOP(TargetType, address); - - if (TargetType == TARGET_TYPE_AR6002) { - regDumpCount = REG_DUMP_COUNT_AR6002; - } else if (TargetType == TARGET_TYPE_AR6003) { - regDumpCount = REG_DUMP_COUNT_AR6003; - } else { - A_ASSERT(0); - } - - /* read RAM location through diagnostic window */ - status = ar6000_ReadRegDiag(hifDevice, &address, ®DumpArea); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get ptr to register dump area \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Location of register dump data: 0x%X \n",regDumpArea)); - - if (regDumpArea == 0) { - /* no reg dump */ - break; - } - - regDumpArea = TARG_VTOP(TargetType, regDumpArea); - - /* fetch register dump data */ - status = ar6000_ReadDataDiag(hifDevice, - regDumpArea, - (u8 *)®DumpValues[0], - regDumpCount * (sizeof(u32))); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get register dump \n")); - break; - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Register Dump: \n")); - - for (i = 0; i < regDumpCount; i++) { - //ATHR_DISPLAY_MSG (_T(" %d : 0x%8.8X \n"), i, regDumpValues[i]); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" %d : 0x%8.8X \n",i, regDumpValues[i])); - -#ifdef UNDER_CE - /* - * For Every logPrintf() Open the File so that in case of Crashes - * We will have until the Last Message Flushed on to the File - * So use logPrintf Sparingly..!! - */ - tgtassertPrintf (ATH_DEBUG_TRC," %d: 0x%8.8X \n",i, regDumpValues[i]); -#endif - } - - } while (false); - -} - -/* set HTC/Mbox operational parameters, this can only be called when the target is in the - * BMI phase */ -int ar6000_set_htc_params(struct hif_device *hifDevice, - u32 TargetType, - u32 MboxIsrYieldValue, - u8 HtcControlBuffers) -{ - int status; - u32 blocksizes[HTC_MAILBOX_NUM_MAX]; - - do { - /* get the block sizes */ - status = HIFConfigureDevice(hifDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, - blocksizes, sizeof(blocksizes)); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR,("Failed to get block size info from HIF layer...\n")); - break; - } - /* note: we actually get the block size for mailbox 1, for SDIO the block - * size on mailbox 0 is artificially set to 1 */ - /* must be a power of 2 */ - A_ASSERT((blocksizes[1] & (blocksizes[1] - 1)) == 0); - - if (HtcControlBuffers != 0) { - /* set override for number of control buffers to use */ - blocksizes[1] |= ((u32)HtcControlBuffers) << 16; - } - - /* set the host interest area for the block size */ - status = BMIWriteMemory(hifDevice, - HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_mbox_io_block_sz), - (u8 *)&blocksizes[1], - 4); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR,("BMIWriteMemory for IO block size failed \n")); - break; - } - - AR_DEBUG_PRINTF(ATH_LOG_INF,("Block Size Set: %d (target address:0x%X)\n", - blocksizes[1], HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_mbox_io_block_sz))); - - if (MboxIsrYieldValue != 0) { - /* set the host interest area for the mbox ISR yield limit */ - status = BMIWriteMemory(hifDevice, - HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_mbox_isr_yield_limit), - (u8 *)&MboxIsrYieldValue, - 4); - - if (status) { - AR_DEBUG_PRINTF(ATH_LOG_ERR,("BMIWriteMemory for yield limit failed \n")); - break; - } - } - - } while (false); - - return status; -} - -void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription) -{ - char stream[60]; - char byteOffsetStr[10]; - u32 i; - u16 offset, count, byteOffset; - - A_PRINTF("<---------Dumping %d Bytes : %s ------>\n", length, pDescription); - - count = 0; - offset = 0; - byteOffset = 0; - for(i = 0; i < length; i++) { - A_SPRINTF(stream + offset, "%2.2X ", buffer[i]); - count ++; - offset += 3; - - if(count == 16) { - count = 0; - offset = 0; - A_SPRINTF(byteOffsetStr,"%4.4X",byteOffset); - A_PRINTF("[%s]: %s\n", byteOffsetStr, stream); - A_MEMZERO(stream, 60); - byteOffset += 16; - } - } - - if(offset != 0) { - A_SPRINTF(byteOffsetStr,"%4.4X",byteOffset); - A_PRINTF("[%s]: %s\n", byteOffsetStr, stream); - } - - A_PRINTF("<------------------------------------------------->\n"); -} - -void a_dump_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo) -{ - int i; - struct ath_debug_mask_description *pDesc; - - if (pInfo == NULL) { - return; - } - - pDesc = pInfo->pMaskDescriptions; - - A_PRINTF("========================================================\n\n"); - A_PRINTF("Module Debug Info => Name : %s \n", pInfo->ModuleName); - A_PRINTF(" => Descr. : %s \n", pInfo->ModuleDescription); - A_PRINTF("\n Current mask => 0x%8.8X \n", pInfo->CurrentMask); - A_PRINTF("\n Avail. Debug Masks :\n\n"); - - for (i = 0; i < pInfo->MaxDescriptions; i++,pDesc++) { - A_PRINTF(" => 0x%8.8X -- %s \n", pDesc->Mask, pDesc->Description); - } - - if (0 == i) { - A_PRINTF(" => * none defined * \n"); - } - - A_PRINTF("\n Standard Debug Masks :\n\n"); - /* print standard masks */ - A_PRINTF(" => 0x%8.8X -- Errors \n", ATH_DEBUG_ERR); - A_PRINTF(" => 0x%8.8X -- Warnings \n", ATH_DEBUG_WARN); - A_PRINTF(" => 0x%8.8X -- Informational \n", ATH_DEBUG_INFO); - A_PRINTF(" => 0x%8.8X -- Tracing \n", ATH_DEBUG_TRC); - A_PRINTF("\n========================================================\n"); - -} - - -static ATH_DEBUG_MODULE_DBG_INFO *FindModule(char *module_name) -{ - ATH_DEBUG_MODULE_DBG_INFO *pInfo = g_pModuleInfoHead; - - if (!g_ModuleDebugInit) { - return NULL; - } - - while (pInfo != NULL) { - /* TODO: need to use something other than strlen */ - if (memcmp(pInfo->ModuleName,module_name,strlen(module_name)) == 0) { - break; - } - pInfo = pInfo->pNext; - } - - return pInfo; -} - - -void a_register_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo) -{ - if (!g_ModuleDebugInit) { - return; - } - - A_MUTEX_LOCK(&g_ModuleListLock); - - if (!(pInfo->Flags & ATH_DEBUG_INFO_FLAGS_REGISTERED)) { - if (g_pModuleInfoHead == NULL) { - g_pModuleInfoHead = pInfo; - } else { - pInfo->pNext = g_pModuleInfoHead; - g_pModuleInfoHead = pInfo; - } - pInfo->Flags |= ATH_DEBUG_INFO_FLAGS_REGISTERED; - } - - A_MUTEX_UNLOCK(&g_ModuleListLock); -} - -void a_dump_module_debug_info_by_name(char *module_name) -{ - ATH_DEBUG_MODULE_DBG_INFO *pInfo = g_pModuleInfoHead; - - if (!g_ModuleDebugInit) { - return; - } - - if (memcmp(module_name,"all",3) == 0) { - /* dump all */ - while (pInfo != NULL) { - a_dump_module_debug_info(pInfo); - pInfo = pInfo->pNext; - } - return; - } - - pInfo = FindModule(module_name); - - if (pInfo != NULL) { - a_dump_module_debug_info(pInfo); - } - -} - -int a_get_module_mask(char *module_name, u32 *pMask) -{ - ATH_DEBUG_MODULE_DBG_INFO *pInfo = FindModule(module_name); - - if (NULL == pInfo) { - return A_ERROR; - } - - *pMask = pInfo->CurrentMask; - return 0; -} - -int a_set_module_mask(char *module_name, u32 Mask) -{ - ATH_DEBUG_MODULE_DBG_INFO *pInfo = FindModule(module_name); - - if (NULL == pInfo) { - return A_ERROR; - } - - pInfo->CurrentMask = Mask; - A_PRINTF("Module %s, new mask: 0x%8.8X \n",module_name,pInfo->CurrentMask); - return 0; -} - - -void a_module_debug_support_init(void) -{ - if (g_ModuleDebugInit) { - return; - } - A_MUTEX_INIT(&g_ModuleListLock); - g_pModuleInfoHead = NULL; - g_ModuleDebugInit = true; - A_REGISTER_MODULE_DEBUG_INFO(misc); -} - -void a_module_debug_support_cleanup(void) -{ - ATH_DEBUG_MODULE_DBG_INFO *pInfo = g_pModuleInfoHead; - ATH_DEBUG_MODULE_DBG_INFO *pCur; - - if (!g_ModuleDebugInit) { - return; - } - - g_ModuleDebugInit = false; - - A_MUTEX_LOCK(&g_ModuleListLock); - - while (pInfo != NULL) { - pCur = pInfo; - pInfo = pInfo->pNext; - pCur->pNext = NULL; - /* clear registered flag */ - pCur->Flags &= ~ATH_DEBUG_INFO_FLAGS_REGISTERED; - } - - A_MUTEX_UNLOCK(&g_ModuleListLock); - - A_MUTEX_DELETE(&g_ModuleListLock); - g_pModuleInfoHead = NULL; -} - - /* can only be called during bmi init stage */ -int ar6000_set_hci_bridge_flags(struct hif_device *hifDevice, - u32 TargetType, - u32 Flags) -{ - int status = 0; - - do { - - if (TargetType != TARGET_TYPE_AR6003) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("Target Type:%d, does not support HCI bridging! \n", - TargetType)); - break; - } - - /* set hci bridge flags */ - status = BMIWriteMemory(hifDevice, - HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_hci_bridge_flags), - (u8 *)&Flags, - 4); - - - } while (false); - - return status; -} - diff --git a/drivers/staging/ath6kl/miscdrv/credit_dist.c b/drivers/staging/ath6kl/miscdrv/credit_dist.c deleted file mode 100644 index c777e98a756..00000000000 --- a/drivers/staging/ath6kl/miscdrv/credit_dist.c +++ /dev/null @@ -1,417 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#define ATH_MODULE_NAME misc -#include "a_debug.h" -#include "htc_api.h" -#include "common_drv.h" - -/********* CREDIT DISTRIBUTION FUNCTIONS ******************************************/ - -#define NO_VO_SERVICE 1 /* currently WMI only uses 3 data streams, so we leave VO service inactive */ -#define CONFIG_GIVE_LOW_PRIORITY_STREAMS_MIN_CREDITS 1 - -#ifdef NO_VO_SERVICE -#define DATA_SVCS_USED 3 -#else -#define DATA_SVCS_USED 4 -#endif - -static void RedistributeCredits(struct common_credit_state_info *pCredInfo, - struct htc_endpoint_credit_dist *pEPDistList); - -static void SeekCredits(struct common_credit_state_info *pCredInfo, - struct htc_endpoint_credit_dist *pEPDistList); - -/* reduce an ep's credits back to a set limit */ -static INLINE void ReduceCredits(struct common_credit_state_info *pCredInfo, - struct htc_endpoint_credit_dist *pEpDist, - int Limit) -{ - int credits; - - /* set the new limit */ - pEpDist->TxCreditsAssigned = Limit; - - if (pEpDist->TxCredits <= Limit) { - return; - } - - /* figure out how much to take away */ - credits = pEpDist->TxCredits - Limit; - /* take them away */ - pEpDist->TxCredits -= credits; - pCredInfo->CurrentFreeCredits += credits; -} - -/* give an endpoint some credits from the free credit pool */ -#define GiveCredits(pCredInfo,pEpDist,credits) \ -{ \ - (pEpDist)->TxCredits += (credits); \ - (pEpDist)->TxCreditsAssigned += (credits); \ - (pCredInfo)->CurrentFreeCredits -= (credits); \ -} - - -/* default credit init callback. - * This function is called in the context of HTCStart() to setup initial (application-specific) - * credit distributions */ -static void ar6000_credit_init(void *Context, - struct htc_endpoint_credit_dist *pEPList, - int TotalCredits) -{ - struct htc_endpoint_credit_dist *pCurEpDist; - int count; - struct common_credit_state_info *pCredInfo = (struct common_credit_state_info *)Context; - - pCredInfo->CurrentFreeCredits = TotalCredits; - pCredInfo->TotalAvailableCredits = TotalCredits; - - pCurEpDist = pEPList; - - /* run through the list and initialize */ - while (pCurEpDist != NULL) { - - /* set minimums for each endpoint */ - pCurEpDist->TxCreditsMin = pCurEpDist->TxCreditsPerMaxMsg; - -#ifdef CONFIG_GIVE_LOW_PRIORITY_STREAMS_MIN_CREDITS - - if (TotalCredits > 4) - { - if ((pCurEpDist->ServiceID == WMI_DATA_BK_SVC) || (pCurEpDist->ServiceID == WMI_DATA_BE_SVC)){ - /* assign at least min credits to lower than VO priority services */ - GiveCredits(pCredInfo,pCurEpDist,pCurEpDist->TxCreditsMin); - /* force active */ - SET_EP_ACTIVE(pCurEpDist); - } - } - -#endif - - if (pCurEpDist->ServiceID == WMI_CONTROL_SVC) { - /* give control service some credits */ - GiveCredits(pCredInfo,pCurEpDist,pCurEpDist->TxCreditsMin); - /* control service is always marked active, it never goes inactive EVER */ - SET_EP_ACTIVE(pCurEpDist); - } else if (pCurEpDist->ServiceID == WMI_DATA_BK_SVC) { - /* this is the lowest priority data endpoint, save this off for easy access */ - pCredInfo->pLowestPriEpDist = pCurEpDist; - } - - /* Streams have to be created (explicit | implicit)for all kinds - * of traffic. BE endpoints are also inactive in the beginning. - * When BE traffic starts it creates implicit streams that - * redistributes credits. - */ - - /* note, all other endpoints have minimums set but are initially given NO credits. - * Credits will be distributed as traffic activity demands */ - pCurEpDist = pCurEpDist->pNext; - } - - if (pCredInfo->CurrentFreeCredits <= 0) { - AR_DEBUG_PRINTF(ATH_LOG_INF, ("Not enough credits (%d) to do credit distributions \n", TotalCredits)); - A_ASSERT(false); - return; - } - - /* reset list */ - pCurEpDist = pEPList; - /* now run through the list and set max operating credit limits for everyone */ - while (pCurEpDist != NULL) { - if (pCurEpDist->ServiceID == WMI_CONTROL_SVC) { - /* control service max is just 1 max message */ - pCurEpDist->TxCreditsNorm = pCurEpDist->TxCreditsPerMaxMsg; - } else { - /* for the remaining data endpoints, we assume that each TxCreditsPerMaxMsg are - * the same. - * We use a simple calculation here, we take the remaining credits and - * determine how many max messages this can cover and then set each endpoint's - * normal value equal to 3/4 this amount. - * */ - count = (pCredInfo->CurrentFreeCredits/pCurEpDist->TxCreditsPerMaxMsg) * pCurEpDist->TxCreditsPerMaxMsg; - count = (count * 3) >> 2; - count = max(count,pCurEpDist->TxCreditsPerMaxMsg); - /* set normal */ - pCurEpDist->TxCreditsNorm = count; - - } - pCurEpDist = pCurEpDist->pNext; - } - -} - - -/* default credit distribution callback - * This callback is invoked whenever endpoints require credit distributions. - * A lock is held while this function is invoked, this function shall NOT block. - * The pEPDistList is a list of distribution structures in prioritized order as - * defined by the call to the HTCSetCreditDistribution() api. - * - */ -static void ar6000_credit_distribute(void *Context, - struct htc_endpoint_credit_dist *pEPDistList, - HTC_CREDIT_DIST_REASON Reason) -{ - struct htc_endpoint_credit_dist *pCurEpDist; - struct common_credit_state_info *pCredInfo = (struct common_credit_state_info *)Context; - - switch (Reason) { - case HTC_CREDIT_DIST_SEND_COMPLETE : - pCurEpDist = pEPDistList; - /* we are given the start of the endpoint distribution list. - * There may be one or more endpoints to service. - * Run through the list and distribute credits */ - while (pCurEpDist != NULL) { - - if (pCurEpDist->TxCreditsToDist > 0) { - /* return the credits back to the endpoint */ - pCurEpDist->TxCredits += pCurEpDist->TxCreditsToDist; - /* always zero out when we are done */ - pCurEpDist->TxCreditsToDist = 0; - - if (pCurEpDist->TxCredits > pCurEpDist->TxCreditsAssigned) { - /* reduce to the assigned limit, previous credit reductions - * could have caused the limit to change */ - ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsAssigned); - } - - if (pCurEpDist->TxCredits > pCurEpDist->TxCreditsNorm) { - /* oversubscribed endpoints need to reduce back to normal */ - ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsNorm); - } - - if (!IS_EP_ACTIVE(pCurEpDist)) { - /* endpoint is inactive, now check for messages waiting for credits */ - if (pCurEpDist->TxQueueDepth == 0) { - /* EP is inactive and there are no pending messages, - * reduce credits back to zero to recover credits */ - ReduceCredits(pCredInfo, pCurEpDist, 0); - } - } - } - - pCurEpDist = pCurEpDist->pNext; - } - - break; - - case HTC_CREDIT_DIST_ACTIVITY_CHANGE : - RedistributeCredits(pCredInfo,pEPDistList); - break; - case HTC_CREDIT_DIST_SEEK_CREDITS : - SeekCredits(pCredInfo,pEPDistList); - break; - case HTC_DUMP_CREDIT_STATE : - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Credit Distribution, total : %d, free : %d\n", - pCredInfo->TotalAvailableCredits, pCredInfo->CurrentFreeCredits)); - break; - default: - break; - - } - - /* sanity checks done after each distribution action */ - A_ASSERT(pCredInfo->CurrentFreeCredits <= pCredInfo->TotalAvailableCredits); - A_ASSERT(pCredInfo->CurrentFreeCredits >= 0); - -} - -/* redistribute credits based on activity change */ -static void RedistributeCredits(struct common_credit_state_info *pCredInfo, - struct htc_endpoint_credit_dist *pEPDistList) -{ - struct htc_endpoint_credit_dist *pCurEpDist = pEPDistList; - - /* walk through the list and remove credits from inactive endpoints */ - while (pCurEpDist != NULL) { - -#ifdef CONFIG_GIVE_LOW_PRIORITY_STREAMS_MIN_CREDITS - - if ((pCurEpDist->ServiceID == WMI_DATA_BK_SVC) || (pCurEpDist->ServiceID == WMI_DATA_BE_SVC)) { - /* force low priority streams to always be active to retain their minimum credit distribution */ - SET_EP_ACTIVE(pCurEpDist); - } -#endif - - if (pCurEpDist->ServiceID != WMI_CONTROL_SVC) { - if (!IS_EP_ACTIVE(pCurEpDist)) { - if (pCurEpDist->TxQueueDepth == 0) { - /* EP is inactive and there are no pending messages, reduce credits back to zero */ - ReduceCredits(pCredInfo, pCurEpDist, 0); - } else { - /* we cannot zero the credits assigned to this EP, but to keep - * the credits available for these leftover packets, reduce to - * a minimum */ - ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsMin); - } - } - } - - /* NOTE in the active case, we do not need to do anything further, - * when an EP goes active and needs credits, HTC will call into - * our distribution function using a reason code of HTC_CREDIT_DIST_SEEK_CREDITS */ - - pCurEpDist = pCurEpDist->pNext; - } - -} - -/* HTC has an endpoint that needs credits, pEPDist is the endpoint in question */ -static void SeekCredits(struct common_credit_state_info *pCredInfo, - struct htc_endpoint_credit_dist *pEPDist) -{ - struct htc_endpoint_credit_dist *pCurEpDist; - int credits = 0; - int need; - - do { - - if (pEPDist->ServiceID == WMI_CONTROL_SVC) { - /* we never oversubscribe on the control service, this is not - * a high performance path and the target never holds onto control - * credits for too long */ - break; - } - -#ifdef CONFIG_GIVE_LOW_PRIORITY_STREAMS_MIN_CREDITS - if (pEPDist->ServiceID == WMI_DATA_VI_SVC) { - if ((pEPDist->TxCreditsAssigned >= pEPDist->TxCreditsNorm)) { - /* limit VI service from oversubscribing */ - break; - } - } - - if (pEPDist->ServiceID == WMI_DATA_VO_SVC) { - if ((pEPDist->TxCreditsAssigned >= pEPDist->TxCreditsNorm)) { - /* limit VO service from oversubscribing */ - break; - } - } -#else - if (pEPDist->ServiceID == WMI_DATA_VI_SVC) { - if ((pEPDist->TxCreditsAssigned >= pEPDist->TxCreditsNorm) || - (pCredInfo->CurrentFreeCredits <= pEPDist->TxCreditsPerMaxMsg)) { - /* limit VI service from oversubscribing */ - /* at least one free credit will not be used by VI */ - break; - } - } - - if (pEPDist->ServiceID == WMI_DATA_VO_SVC) { - if ((pEPDist->TxCreditsAssigned >= pEPDist->TxCreditsNorm) || - (pCredInfo->CurrentFreeCredits <= pEPDist->TxCreditsPerMaxMsg)) { - /* limit VO service from oversubscribing */ - /* at least one free credit will not be used by VO */ - break; - } - } -#endif - - /* for all other services, we follow a simple algorithm of - * 1. checking the free pool for credits - * 2. checking lower priority endpoints for credits to take */ - - /* give what we can */ - credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek); - - if (credits >= pEPDist->TxCreditsSeek) { - /* we found some to fulfill the seek request */ - break; - } - - /* we don't have enough in the free pool, try taking away from lower priority services - * - * The rule for taking away credits: - * 1. Only take from lower priority endpoints - * 2. Only take what is allocated above the minimum (never starve an endpoint completely) - * 3. Only take what you need. - * - * */ - - /* starting at the lowest priority */ - pCurEpDist = pCredInfo->pLowestPriEpDist; - - /* work backwards until we hit the endpoint again */ - while (pCurEpDist != pEPDist) { - /* calculate how many we need so far */ - need = pEPDist->TxCreditsSeek - pCredInfo->CurrentFreeCredits; - - if ((pCurEpDist->TxCreditsAssigned - need) >= pCurEpDist->TxCreditsMin) { - /* the current one has been allocated more than it's minimum and it - * has enough credits assigned above it's minimum to fulfill our need - * try to take away just enough to fulfill our need */ - ReduceCredits(pCredInfo, - pCurEpDist, - pCurEpDist->TxCreditsAssigned - need); - - if (pCredInfo->CurrentFreeCredits >= pEPDist->TxCreditsSeek) { - /* we have enough */ - break; - } - } - - pCurEpDist = pCurEpDist->pPrev; - } - - /* return what we can get */ - credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek); - - } while (false); - - /* did we find some credits? */ - if (credits) { - /* give what we can */ - GiveCredits(pCredInfo, pEPDist, credits); - } - -} - -/* initialize and setup credit distribution */ -int ar6000_setup_credit_dist(HTC_HANDLE HTCHandle, struct common_credit_state_info *pCredInfo) -{ - HTC_SERVICE_ID servicepriority[5]; - - A_MEMZERO(pCredInfo,sizeof(struct common_credit_state_info)); - - servicepriority[0] = WMI_CONTROL_SVC; /* highest */ - servicepriority[1] = WMI_DATA_VO_SVC; - servicepriority[2] = WMI_DATA_VI_SVC; - servicepriority[3] = WMI_DATA_BE_SVC; - servicepriority[4] = WMI_DATA_BK_SVC; /* lowest */ - - /* set callbacks and priority list */ - HTCSetCreditDistribution(HTCHandle, - pCredInfo, - ar6000_credit_distribute, - ar6000_credit_init, - servicepriority, - 5); - - return 0; -} - diff --git a/drivers/staging/ath6kl/miscdrv/miscdrv.h b/drivers/staging/ath6kl/miscdrv/miscdrv.h deleted file mode 100644 index 41be5670db4..00000000000 --- a/drivers/staging/ath6kl/miscdrv/miscdrv.h +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _MISCDRV_H -#define _MISCDRV_H - - -#define HOST_INTEREST_ITEM_ADDRESS(target, item) \ - AR6002_HOST_INTEREST_ITEM_ADDRESS(item) - -u32 ar6kRev2Array[][128] = { - {0xFFFF, 0xFFFF}, // No Patches - }; - -#define CFG_REV2_ITEMS 0 // no patches so far -#define AR6K_RESET_ADDR 0x4000 -#define AR6K_RESET_VAL 0x100 - -#define EEPROM_SZ 768 -#define EEPROM_WAIT_LIMIT 4 - -#endif - diff --git a/drivers/staging/ath6kl/os/linux/ar6000_drv.c b/drivers/staging/ath6kl/os/linux/ar6000_drv.c deleted file mode 100644 index 32ee39ad00d..00000000000 --- a/drivers/staging/ath6kl/os/linux/ar6000_drv.c +++ /dev/null @@ -1,6267 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -/* - * This driver is a pseudo ethernet driver to access the Atheros AR6000 - * WLAN Device - */ - -#include "ar6000_drv.h" -#include "cfg80211.h" -#include "htc.h" -#include "wmi_filter_linux.h" -#include "epping_test.h" -#include "wlan_config.h" -#include "ar3kconfig.h" -#include "ar6k_pal.h" -#include "AR6002/addrs.h" - - -/* LINUX_HACK_FUDGE_FACTOR -- this is used to provide a workaround for linux behavior. When - * the meta data was added to the header it was found that linux did not correctly provide - * enough headroom. However when more headroom was requested beyond what was truly needed - * Linux gave the requested headroom. Therefore to get the necessary headroom from Linux - * the driver requests more than is needed by the amount = LINUX_HACK_FUDGE_FACTOR */ -#define LINUX_HACK_FUDGE_FACTOR 16 -#define BDATA_BDADDR_OFFSET 28 - -u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -u8 null_mac[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; - -#ifdef DEBUG - -#define ATH_DEBUG_DBG_LOG ATH_DEBUG_MAKE_MODULE_MASK(0) -#define ATH_DEBUG_WLAN_CONNECT ATH_DEBUG_MAKE_MODULE_MASK(1) -#define ATH_DEBUG_WLAN_SCAN ATH_DEBUG_MAKE_MODULE_MASK(2) -#define ATH_DEBUG_WLAN_TX ATH_DEBUG_MAKE_MODULE_MASK(3) -#define ATH_DEBUG_WLAN_RX ATH_DEBUG_MAKE_MODULE_MASK(4) -#define ATH_DEBUG_HTC_RAW ATH_DEBUG_MAKE_MODULE_MASK(5) -#define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6) - -static struct ath_debug_mask_description driver_debug_desc[] = { - { ATH_DEBUG_DBG_LOG , "Target Debug Logs"}, - { ATH_DEBUG_WLAN_CONNECT , "WLAN connect"}, - { ATH_DEBUG_WLAN_SCAN , "WLAN scan"}, - { ATH_DEBUG_WLAN_TX , "WLAN Tx"}, - { ATH_DEBUG_WLAN_RX , "WLAN Rx"}, - { ATH_DEBUG_HTC_RAW , "HTC Raw IF tracing"}, - { ATH_DEBUG_HCI_BRIDGE , "HCI Bridge Setup"}, - { ATH_DEBUG_HCI_RECV , "HCI Recv tracing"}, - { ATH_DEBUG_HCI_DUMP , "HCI Packet dumps"}, -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(driver, - "driver", - "Linux Driver Interface", - ATH_DEBUG_MASK_DEFAULTS | ATH_DEBUG_WLAN_SCAN | - ATH_DEBUG_HCI_BRIDGE, - ATH_DEBUG_DESCRIPTION_COUNT(driver_debug_desc), - driver_debug_desc); - -#endif - - -#define IS_MAC_NULL(mac) (mac[0]==0 && mac[1]==0 && mac[2]==0 && mac[3]==0 && mac[4]==0 && mac[5]==0) -#define IS_MAC_BCAST(mac) (*mac==0xff) - -#define DESCRIPTION "Driver to access the Atheros AR600x Device, version " __stringify(__VER_MAJOR_) "." __stringify(__VER_MINOR_) "." __stringify(__VER_PATCH_) "." __stringify(__BUILD_NUMBER_) - -MODULE_AUTHOR("Atheros Communications, Inc."); -MODULE_DESCRIPTION(DESCRIPTION); -MODULE_LICENSE("Dual BSD/GPL"); - -#ifndef REORG_APTC_HEURISTICS -#undef ADAPTIVE_POWER_THROUGHPUT_CONTROL -#endif /* REORG_APTC_HEURISTICS */ - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL -#define APTC_TRAFFIC_SAMPLING_INTERVAL 100 /* msec */ -#define APTC_UPPER_THROUGHPUT_THRESHOLD 3000 /* Kbps */ -#define APTC_LOWER_THROUGHPUT_THRESHOLD 2000 /* Kbps */ - -typedef struct aptc_traffic_record { - bool timerScheduled; - struct timeval samplingTS; - unsigned long bytesReceived; - unsigned long bytesTransmitted; -} APTC_TRAFFIC_RECORD; - -A_TIMER aptcTimer; -APTC_TRAFFIC_RECORD aptcTR; -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -// callbacks registered by HCI transport driver -struct hci_transport_callbacks ar6kHciTransCallbacks = { NULL }; -#endif - -unsigned int processDot11Hdr = 0; - -char ifname[IFNAMSIZ] = {0,}; - -int wlaninitmode = WLAN_INIT_MODE_DEFAULT; -static bool bypasswmi; -unsigned int debuglevel = 0; -int tspecCompliance = ATHEROS_COMPLIANCE; -unsigned int busspeedlow = 0; -unsigned int onebitmode = 0; -unsigned int skipflash = 0; -unsigned int wmitimeout = 2; -unsigned int wlanNodeCaching = 1; -unsigned int enableuartprint = ENABLEUARTPRINT_DEFAULT; -unsigned int logWmiRawMsgs = 0; -unsigned int enabletimerwar = 0; -unsigned int num_device = 1; -unsigned int regscanmode; -unsigned int fwmode = 1; -unsigned int mbox_yield_limit = 99; -unsigned int enablerssicompensation = 0; -int reduce_credit_dribble = 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF; -int allow_trace_signal = 0; -#ifdef CONFIG_HOST_TCMD_SUPPORT -unsigned int testmode =0; -#endif - -unsigned int irqprocmode = HIF_DEVICE_IRQ_SYNC_ONLY;//HIF_DEVICE_IRQ_ASYNC_SYNC; -unsigned int panic_on_assert = 1; -unsigned int nohifscattersupport = NOHIFSCATTERSUPPORT_DEFAULT; - -unsigned int setuphci = SETUPHCI_DEFAULT; -unsigned int loghci = 0; -unsigned int setupbtdev = SETUPBTDEV_DEFAULT; -#ifndef EXPORT_HCI_BRIDGE_INTERFACE -unsigned int ar3khcibaud = AR3KHCIBAUD_DEFAULT; -unsigned int hciuartscale = HCIUARTSCALE_DEFAULT; -unsigned int hciuartstep = HCIUARTSTEP_DEFAULT; -#endif -unsigned int csumOffload=0; -unsigned int csumOffloadTest=0; -unsigned int eppingtest=0; -unsigned int mac_addr_method; -unsigned int firmware_bridge; - -module_param_string(ifname, ifname, sizeof(ifname), 0644); -module_param(wlaninitmode, int, 0644); -module_param(bypasswmi, bool, 0644); -module_param(debuglevel, uint, 0644); -module_param(tspecCompliance, int, 0644); -module_param(onebitmode, uint, 0644); -module_param(busspeedlow, uint, 0644); -module_param(skipflash, uint, 0644); -module_param(wmitimeout, uint, 0644); -module_param(wlanNodeCaching, uint, 0644); -module_param(logWmiRawMsgs, uint, 0644); -module_param(enableuartprint, uint, 0644); -module_param(enabletimerwar, uint, 0644); -module_param(fwmode, uint, 0644); -module_param(mbox_yield_limit, uint, 0644); -module_param(reduce_credit_dribble, int, 0644); -module_param(allow_trace_signal, int, 0644); -module_param(enablerssicompensation, uint, 0644); -module_param(processDot11Hdr, uint, 0644); -module_param(csumOffload, uint, 0644); -#ifdef CONFIG_HOST_TCMD_SUPPORT -module_param(testmode, uint, 0644); -#endif -module_param(irqprocmode, uint, 0644); -module_param(nohifscattersupport, uint, 0644); -module_param(panic_on_assert, uint, 0644); -module_param(setuphci, uint, 0644); -module_param(loghci, uint, 0644); -module_param(setupbtdev, uint, 0644); -#ifndef EXPORT_HCI_BRIDGE_INTERFACE -module_param(ar3khcibaud, uint, 0644); -module_param(hciuartscale, uint, 0644); -module_param(hciuartstep, uint, 0644); -#endif -module_param(eppingtest, uint, 0644); - -/* in 2.6.10 and later this is now a pointer to a uint */ -unsigned int _mboxnum = HTC_MAILBOX_NUM_MAX; -#define mboxnum &_mboxnum - -#ifdef DEBUG -u32 g_dbg_flags = DBG_DEFAULTS; -unsigned int debugflags = 0; -int debugdriver = 0; -unsigned int debughtc = 0; -unsigned int debugbmi = 0; -unsigned int debughif = 0; -unsigned int txcreditsavailable[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int txcreditsconsumed[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int txcreditintrenable[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int txcreditintrenableaggregate[HTC_MAILBOX_NUM_MAX] = {0}; -module_param(debugflags, uint, 0644); -module_param(debugdriver, int, 0644); -module_param(debughtc, uint, 0644); -module_param(debugbmi, uint, 0644); -module_param(debughif, uint, 0644); -module_param_array(txcreditsavailable, uint, mboxnum, 0644); -module_param_array(txcreditsconsumed, uint, mboxnum, 0644); -module_param_array(txcreditintrenable, uint, mboxnum, 0644); -module_param_array(txcreditintrenableaggregate, uint, mboxnum, 0644); - -#endif /* DEBUG */ - -unsigned int resetok = 1; -unsigned int tx_attempt[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int tx_post[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int tx_complete[HTC_MAILBOX_NUM_MAX] = {0}; -unsigned int hifBusRequestNumMax = 40; -unsigned int war23838_disabled = 0; -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL -unsigned int enableAPTCHeuristics = 1; -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ -module_param_array(tx_attempt, uint, mboxnum, 0644); -module_param_array(tx_post, uint, mboxnum, 0644); -module_param_array(tx_complete, uint, mboxnum, 0644); -module_param(hifBusRequestNumMax, uint, 0644); -module_param(war23838_disabled, uint, 0644); -module_param(resetok, uint, 0644); -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL -module_param(enableAPTCHeuristics, uint, 0644); -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - -#ifdef BLOCK_TX_PATH_FLAG -int blocktx = 0; -module_param(blocktx, int, 0644); -#endif /* BLOCK_TX_PATH_FLAG */ - -typedef struct user_rssi_compensation_t { - u16 customerID; - union { - u16 a_enable; - u16 bg_enable; - u16 enable; - }; - s16 bg_param_a; - s16 bg_param_b; - s16 a_param_a; - s16 a_param_b; - u32 reserved; -} USER_RSSI_CPENSATION; - -static USER_RSSI_CPENSATION rssi_compensation_param; - -static s16 rssi_compensation_table[96]; - -int reconnect_flag = 0; -static ar6k_pal_config_t ar6k_pal_config_g; - -/* Function declarations */ -static int ar6000_init_module(void); -static void ar6000_cleanup_module(void); - -int ar6000_init(struct net_device *dev); -static int ar6000_open(struct net_device *dev); -static int ar6000_close(struct net_device *dev); -static void ar6000_init_control_info(struct ar6_softc *ar); -static int ar6000_data_tx(struct sk_buff *skb, struct net_device *dev); - -void ar6000_destroy(struct net_device *dev, unsigned int unregister); -static void ar6000_detect_error(unsigned long ptr); -static void ar6000_set_multicast_list(struct net_device *dev); -static struct net_device_stats *ar6000_get_stats(struct net_device *dev); - -static void disconnect_timer_handler(unsigned long ptr); - -void read_rssi_compensation_param(struct ar6_softc *ar); - -/* - * HTC service connection handlers - */ -static int ar6000_avail_ev(void *context, void *hif_handle); - -static int ar6000_unavail_ev(void *context, void *hif_handle); - -int ar6000_configure_target(struct ar6_softc *ar); - -static void ar6000_target_failure(void *Instance, int Status); - -static void ar6000_rx(void *Context, struct htc_packet *pPacket); - -static void ar6000_rx_refill(void *Context,HTC_ENDPOINT_ID Endpoint); - -static void ar6000_tx_complete(void *Context, struct htc_packet_queue *pPackets); - -static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket); - -static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num); -static void ar6000_deliver_frames_to_nw_stack(void * dev, void *osbuf); -//static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf); - -static struct htc_packet *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length); - -static void ar6000_refill_amsdu_rxbufs(struct ar6_softc *ar, int Count); - -static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc *ar); - -static ssize_t -ar6000_sysfs_bmi_read(struct file *fp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count); - -static ssize_t -ar6000_sysfs_bmi_write(struct file *fp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count); - -static int -ar6000_sysfs_bmi_init(struct ar6_softc *ar); - -void ar6k_cleanup_hci_pal(struct ar6_softc *ar); - -static void -ar6000_sysfs_bmi_deinit(struct ar6_softc *ar); - -int -ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode); - -/* - * Static variables - */ - -struct net_device *ar6000_devices[MAX_AR6000]; -static int is_netdev_registered; -DECLARE_WAIT_QUEUE_HEAD(arEvent); -static void ar6000_cookie_init(struct ar6_softc *ar); -static void ar6000_cookie_cleanup(struct ar6_softc *ar); -static void ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie); -static struct ar_cookie *ar6000_alloc_cookie(struct ar6_softc *ar); - -static int ar6000_reinstall_keys(struct ar6_softc *ar,u8 key_op_ctrl); - -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT -struct net_device *arApNetDev; -#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - -static struct ar_cookie s_ar_cookie_mem[MAX_COOKIE_NUM]; - -#define HOST_INTEREST_ITEM_ADDRESS(ar, item) \ - (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \ - (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0)) - - -static struct net_device_ops ar6000_netdev_ops = { - .ndo_init = NULL, - .ndo_open = ar6000_open, - .ndo_stop = ar6000_close, - .ndo_get_stats = ar6000_get_stats, - .ndo_start_xmit = ar6000_data_tx, - .ndo_set_multicast_list = ar6000_set_multicast_list, -}; - -/* Debug log support */ - -/* - * Flag to govern whether the debug logs should be parsed in the kernel - * or reported to the application. - */ -#define REPORT_DEBUG_LOGS_TO_APP - -int -ar6000_set_host_app_area(struct ar6_softc *ar) -{ - u32 address, data; - struct host_app_area_s host_app_area; - - /* Fetch the address of the host_app_area_s instance in the host interest area */ - address = TARG_VTOP(ar->arTargetType, HOST_INTEREST_ITEM_ADDRESS(ar, hi_app_host_interest)); - if (ar6000_ReadRegDiag(ar->arHifDevice, &address, &data) != 0) { - return A_ERROR; - } - address = TARG_VTOP(ar->arTargetType, data); - host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION; - if (ar6000_WriteDataDiag(ar->arHifDevice, address, - (u8 *)&host_app_area, - sizeof(struct host_app_area_s)) != 0) - { - return A_ERROR; - } - - return 0; -} - -u32 dbglog_get_debug_hdr_ptr(struct ar6_softc *ar) -{ - u32 param; - u32 address; - int status; - - address = TARG_VTOP(ar->arTargetType, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbglog_hdr)); - if ((status = ar6000_ReadDataDiag(ar->arHifDevice, address, - (u8 *)¶m, 4)) != 0) - { - param = 0; - } - - return param; -} - -/* - * The dbglog module has been initialized. Its ok to access the relevant - * data stuctures over the diagnostic window. - */ -void -ar6000_dbglog_init_done(struct ar6_softc *ar) -{ - ar->dbglog_init_done = true; -} - -u32 dbglog_get_debug_fragment(s8 *datap, u32 len, u32 limit) -{ - s32 *buffer; - u32 count; - u32 numargs; - u32 length; - u32 fraglen; - - count = fraglen = 0; - buffer = (s32 *)datap; - length = (limit >> 2); - - if (len <= limit) { - fraglen = len; - } else { - while (count < length) { - numargs = DBGLOG_GET_NUMARGS(buffer[count]); - fraglen = (count << 2); - count += numargs + 1; - } - } - - return fraglen; -} - -void -dbglog_parse_debug_logs(s8 *datap, u32 len) -{ - s32 *buffer; - u32 count; - u32 timestamp; - u32 debugid; - u32 moduleid; - u32 numargs; - u32 length; - - count = 0; - buffer = (s32 *)datap; - length = (len >> 2); - while (count < length) { - debugid = DBGLOG_GET_DBGID(buffer[count]); - moduleid = DBGLOG_GET_MODULEID(buffer[count]); - numargs = DBGLOG_GET_NUMARGS(buffer[count]); - timestamp = DBGLOG_GET_TIMESTAMP(buffer[count]); - switch (numargs) { - case 0: - AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG,("%d %d (%d)\n", moduleid, debugid, timestamp)); - break; - - case 1: - AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG,("%d %d (%d): 0x%x\n", moduleid, debugid, - timestamp, buffer[count+1])); - break; - - case 2: - AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG,("%d %d (%d): 0x%x, 0x%x\n", moduleid, debugid, - timestamp, buffer[count+1], buffer[count+2])); - break; - - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid args: %d\n", numargs)); - } - count += numargs + 1; - } -} - -int -ar6000_dbglog_get_debug_logs(struct ar6_softc *ar) -{ - u32 data[8]; /* Should be able to accommodate struct dbglog_buf_s */ - u32 address; - u32 length; - u32 dropped; - u32 firstbuf; - u32 debug_hdr_ptr; - - if (!ar->dbglog_init_done) return A_ERROR; - - - AR6000_SPIN_LOCK(&ar->arLock, 0); - - if (ar->dbgLogFetchInProgress) { - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - return A_EBUSY; - } - - /* block out others */ - ar->dbgLogFetchInProgress = true; - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - debug_hdr_ptr = dbglog_get_debug_hdr_ptr(ar); - printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr); - - /* Get the contents of the ring buffer */ - if (debug_hdr_ptr) { - address = TARG_VTOP(ar->arTargetType, debug_hdr_ptr); - length = 4 /* sizeof(dbuf) */ + 4 /* sizeof(dropped) */; - A_MEMZERO(data, sizeof(data)); - ar6000_ReadDataDiag(ar->arHifDevice, address, (u8 *)data, length); - address = TARG_VTOP(ar->arTargetType, data[0] /* dbuf */); - firstbuf = address; - dropped = data[1]; /* dropped */ - length = 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */; - A_MEMZERO(data, sizeof(data)); - ar6000_ReadDataDiag(ar->arHifDevice, address, (u8 *)&data, length); - - do { - address = TARG_VTOP(ar->arTargetType, data[1] /* buffer*/); - length = data[3]; /* length */ - if ((length) && (length <= data[2] /* bufsize*/)) { - /* Rewind the index if it is about to overrun the buffer */ - if (ar->log_cnt > (DBGLOG_HOST_LOG_BUFFER_SIZE - length)) { - ar->log_cnt = 0; - } - if(0 != ar6000_ReadDataDiag(ar->arHifDevice, address, - (u8 *)&ar->log_buffer[ar->log_cnt], length)) - { - break; - } - ar6000_dbglog_event(ar, dropped, (s8 *)&ar->log_buffer[ar->log_cnt], length); - ar->log_cnt += length; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG,("Length: %d (Total size: %d)\n", - data[3], data[2])); - } - - address = TARG_VTOP(ar->arTargetType, data[0] /* next */); - length = 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */; - A_MEMZERO(data, sizeof(data)); - if(0 != ar6000_ReadDataDiag(ar->arHifDevice, address, - (u8 *)&data, length)) - { - break; - } - - } while (address != firstbuf); - } - - ar->dbgLogFetchInProgress = false; - - return 0; -} - -void -ar6000_dbglog_event(struct ar6_softc *ar, u32 dropped, - s8 *buffer, u32 length) -{ -#ifdef REPORT_DEBUG_LOGS_TO_APP - #define MAX_WIRELESS_EVENT_SIZE 252 - /* - * Break it up into chunks of MAX_WIRELESS_EVENT_SIZE bytes of messages. - * There seems to be a limitation on the length of message that could be - * transmitted to the user app via this mechanism. - */ - u32 send, sent; - - sent = 0; - send = dbglog_get_debug_fragment(&buffer[sent], length - sent, - MAX_WIRELESS_EVENT_SIZE); - while (send) { - sent += send; - send = dbglog_get_debug_fragment(&buffer[sent], length - sent, - MAX_WIRELESS_EVENT_SIZE); - } -#else - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Dropped logs: 0x%x\nDebug info length: %d\n", - dropped, length)); - - /* Interpret the debug logs */ - dbglog_parse_debug_logs((s8 *)buffer, length); -#endif /* REPORT_DEBUG_LOGS_TO_APP */ -} - - -static int __init -ar6000_init_module(void) -{ - static int probed = 0; - int r; - OSDRV_CALLBACKS osdrvCallbacks; - - a_module_debug_support_init(); - -#ifdef DEBUG - /* check for debug mask overrides */ - if (debughtc != 0) { - ATH_DEBUG_SET_DEBUG_MASK(htc,debughtc); - } - if (debugbmi != 0) { - ATH_DEBUG_SET_DEBUG_MASK(bmi,debugbmi); - } - if (debughif != 0) { - ATH_DEBUG_SET_DEBUG_MASK(hif,debughif); - } - if (debugdriver != 0) { - ATH_DEBUG_SET_DEBUG_MASK(driver,debugdriver); - } - -#endif - - A_REGISTER_MODULE_DEBUG_INFO(driver); - - A_MEMZERO(&osdrvCallbacks,sizeof(osdrvCallbacks)); - osdrvCallbacks.deviceInsertedHandler = ar6000_avail_ev; - osdrvCallbacks.deviceRemovedHandler = ar6000_unavail_ev; -#ifdef CONFIG_PM - osdrvCallbacks.deviceSuspendHandler = ar6000_suspend_ev; - osdrvCallbacks.deviceResumeHandler = ar6000_resume_ev; - osdrvCallbacks.devicePowerChangeHandler = ar6000_power_change_ev; -#endif - -#ifdef DEBUG - /* Set the debug flags if specified at load time */ - if(debugflags != 0) - { - g_dbg_flags = debugflags; - } -#endif - - if (probed) { - return -ENODEV; - } - probed++; - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL - memset(&aptcTR, 0, sizeof(APTC_TRAFFIC_RECORD)); -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - - r = HIFInit(&osdrvCallbacks); - if (r) - return r; - - return 0; -} - -static void __exit -ar6000_cleanup_module(void) -{ - int i = 0; - struct net_device *ar6000_netdev; - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL - /* Delete the Adaptive Power Control timer */ - if (timer_pending(&aptcTimer)) { - del_timer_sync(&aptcTimer); - } -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - - for (i=0; i < MAX_AR6000; i++) { - if (ar6000_devices[i] != NULL) { - ar6000_netdev = ar6000_devices[i]; - ar6000_devices[i] = NULL; - ar6000_destroy(ar6000_netdev, 1); - } - } - - HIFShutDownDevice(NULL); - - a_module_debug_support_cleanup(); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_cleanup: success\n")); -} - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL -void -aptcTimerHandler(unsigned long arg) -{ - u32 numbytes; - u32 throughput; - struct ar6_softc *ar; - int status; - - ar = (struct ar6_softc *)arg; - A_ASSERT(ar != NULL); - A_ASSERT(!timer_pending(&aptcTimer)); - - AR6000_SPIN_LOCK(&ar->arLock, 0); - - /* Get the number of bytes transferred */ - numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived; - aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0; - - /* Calculate and decide based on throughput thresholds */ - throughput = ((numbytes * 8)/APTC_TRAFFIC_SAMPLING_INTERVAL); /* Kbps */ - if (throughput < APTC_LOWER_THROUGHPUT_THRESHOLD) { - /* Enable Sleep and delete the timer */ - A_ASSERT(ar->arWmiReady == true); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - status = wmi_powermode_cmd(ar->arWmi, REC_POWER); - AR6000_SPIN_LOCK(&ar->arLock, 0); - A_ASSERT(status == 0); - aptcTR.timerScheduled = false; - } else { - A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0); - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); -} -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - -static void -ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num) -{ - void * osbuf; - - while(num) { - if((osbuf = A_NETBUF_ALLOC(AR6000_BUFFER_SIZE))) { - A_NETBUF_ENQUEUE(q, osbuf); - } else { - break; - } - num--; - } - - if(num) { - A_PRINTF("%s(), allocation of netbuf failed", __func__); - } -} - -static struct bin_attribute bmi_attr = { - .attr = {.name = "bmi", .mode = 0600}, - .read = ar6000_sysfs_bmi_read, - .write = ar6000_sysfs_bmi_write, -}; - -static ssize_t -ar6000_sysfs_bmi_read(struct file *fp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count) -{ - int index; - struct ar6_softc *ar; - struct hif_device_os_device_info *osDevInfo; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Read %d bytes\n", (u32)count)); - for (index=0; index < MAX_AR6000; index++) { - ar = (struct ar6_softc *)ar6k_priv(ar6000_devices[index]); - osDevInfo = &ar->osDevInfo; - if (kobj == (&(((struct device *)osDevInfo->pOSDevice)->kobj))) { - break; - } - } - - if (index == MAX_AR6000) return 0; - - if ((BMIRawRead(ar->arHifDevice, (u8*)buf, count, true)) != 0) { - return 0; - } - - return count; -} - -static ssize_t -ar6000_sysfs_bmi_write(struct file *fp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count) -{ - int index; - struct ar6_softc *ar; - struct hif_device_os_device_info *osDevInfo; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Write %d bytes\n", (u32)count)); - for (index=0; index < MAX_AR6000; index++) { - ar = (struct ar6_softc *)ar6k_priv(ar6000_devices[index]); - osDevInfo = &ar->osDevInfo; - if (kobj == (&(((struct device *)osDevInfo->pOSDevice)->kobj))) { - break; - } - } - - if (index == MAX_AR6000) return 0; - - if ((BMIRawWrite(ar->arHifDevice, (u8*)buf, count)) != 0) { - return 0; - } - - return count; -} - -static int -ar6000_sysfs_bmi_init(struct ar6_softc *ar) -{ - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Creating sysfs entry\n")); - A_MEMZERO(&ar->osDevInfo, sizeof(struct hif_device_os_device_info)); - - /* Get the underlying OS device */ - status = HIFConfigureDevice(ar->arHifDevice, - HIF_DEVICE_GET_OS_DEVICE, - &ar->osDevInfo, - sizeof(struct hif_device_os_device_info)); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI: Failed to get OS device info from HIF\n")); - return A_ERROR; - } - - /* Create a bmi entry in the sysfs filesystem */ - if ((sysfs_create_bin_file(&(((struct device *)ar->osDevInfo.pOSDevice)->kobj), &bmi_attr)) < 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMI: Failed to create entry for bmi in sysfs filesystem\n")); - return A_ERROR; - } - - return 0; -} - -static void -ar6000_sysfs_bmi_deinit(struct ar6_softc *ar) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Deleting sysfs entry\n")); - - sysfs_remove_bin_file(&(((struct device *)ar->osDevInfo.pOSDevice)->kobj), &bmi_attr); -} - -#define bmifn(fn) do { \ - if ((fn) < 0) { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); \ - return A_ERROR; \ - } \ -} while(0) - -#ifdef SOFTMAC_FILE_USED -#define AR6002_MAC_ADDRESS_OFFSET 0x0A -#define AR6003_MAC_ADDRESS_OFFSET 0x16 -static -void calculate_crc(u32 TargetType, u8 *eeprom_data) -{ - u16 *ptr_crc; - u16 *ptr16_eeprom; - u16 checksum; - u32 i; - u32 eeprom_size; - - if (TargetType == TARGET_TYPE_AR6001) - { - eeprom_size = 512; - ptr_crc = (u16 *)eeprom_data; - } - else if (TargetType == TARGET_TYPE_AR6003) - { - eeprom_size = 1024; - ptr_crc = (u16 *)((u8 *)eeprom_data + 0x04); - } - else - { - eeprom_size = 768; - ptr_crc = (u16 *)((u8 *)eeprom_data + 0x04); - } - - - // Clear the crc - *ptr_crc = 0; - - // Recalculate new CRC - checksum = 0; - ptr16_eeprom = (u16 *)eeprom_data; - for (i = 0;i < eeprom_size; i += 2) - { - checksum = checksum ^ (*ptr16_eeprom); - ptr16_eeprom++; - } - checksum = 0xFFFF ^ checksum; - *ptr_crc = checksum; -} - -static void -ar6000_softmac_update(struct ar6_softc *ar, u8 *eeprom_data, size_t size) -{ - const char *source = "random generated"; - const struct firmware *softmac_entry; - u8 *ptr_mac; - switch (ar->arTargetType) { - case TARGET_TYPE_AR6002: - ptr_mac = (u8 *)((u8 *)eeprom_data + AR6002_MAC_ADDRESS_OFFSET); - break; - case TARGET_TYPE_AR6003: - ptr_mac = (u8 *)((u8 *)eeprom_data + AR6003_MAC_ADDRESS_OFFSET); - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Invalid Target Type\n")); - return; - } - printk(KERN_DEBUG "MAC from EEPROM %pM\n", ptr_mac); - - /* create a random MAC in case we cannot read file from system */ - ptr_mac[0] = 0; - ptr_mac[1] = 0x03; - ptr_mac[2] = 0x7F; - ptr_mac[3] = random32() & 0xff; - ptr_mac[4] = random32() & 0xff; - ptr_mac[5] = random32() & 0xff; - if ((A_REQUEST_FIRMWARE(&softmac_entry, "softmac", ((struct device *)ar->osDevInfo.pOSDevice))) == 0) - { - char *macbuf = A_MALLOC_NOWAIT(softmac_entry->size+1); - if (macbuf) { - unsigned int softmac[6]; - memcpy(macbuf, softmac_entry->data, softmac_entry->size); - macbuf[softmac_entry->size] = '\0'; - if (sscanf(macbuf, "%02x:%02x:%02x:%02x:%02x:%02x", - &softmac[0], &softmac[1], &softmac[2], - &softmac[3], &softmac[4], &softmac[5])==6) { - int i; - for (i=0; i<6; ++i) { - ptr_mac[i] = softmac[i] & 0xff; - } - source = "softmac file"; - } - kfree(macbuf); - } - A_RELEASE_FIRMWARE(softmac_entry); - } - printk(KERN_DEBUG "MAC from %s %pM\n", source, ptr_mac); - calculate_crc(ar->arTargetType, eeprom_data); -} -#endif /* SOFTMAC_FILE_USED */ - -static int -ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address, bool compressed) -{ - int status; - const char *filename; - const struct firmware *fw_entry; - u32 fw_entry_size; - u8 **buf; - size_t *buf_len; - - switch (file) { - case AR6K_OTP_FILE: - buf = &ar->fw_otp; - buf_len = &ar->fw_otp_len; - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_OTP_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_OTP_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_OTP_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - break; - - case AR6K_FIRMWARE_FILE: - buf = &ar->fw; - buf_len = &ar->fw_len; - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_FIRMWARE_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - - if (eppingtest) { - bypasswmi = true; - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_EPPING_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_EPPING_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_EPPING_FIRMWARE_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("eppingtest : unsupported firmware revision: %d\n", - ar->arVersion.target_ver)); - return A_ERROR; - } - compressed = false; - } - -#ifdef CONFIG_HOST_TCMD_SUPPORT - if(testmode) { - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_TCMD_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_TCMD_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_TCMD_FIRMWARE_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - compressed = false; - } -#endif -#ifdef HTC_RAW_INTERFACE - if (!eppingtest && bypasswmi) { - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_ART_FIRMWARE_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_ART_FIRMWARE_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - compressed = false; - } -#endif - break; - - case AR6K_PATCH_FILE: - buf = &ar->fw_patch; - buf_len = &ar->fw_patch_len; - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_PATCH_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_PATCH_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_PATCH_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - break; - - case AR6K_BOARD_DATA_FILE: - buf = &ar->fw_data; - buf_len = &ar->fw_data_len; - if (ar->arVersion.target_ver == AR6003_REV1_VERSION) { - filename = AR6003_REV1_BOARD_DATA_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - filename = AR6003_REV2_BOARD_DATA_FILE; - } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) { - filename = AR6003_REV3_BOARD_DATA_FILE; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver)); - return A_ERROR; - } - break; - - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown file type: %d\n", file)); - return A_ERROR; - } - - if (*buf == NULL) { - if ((A_REQUEST_FIRMWARE(&fw_entry, filename, ((struct device *)ar->osDevInfo.pOSDevice))) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get %s\n", filename)); - return A_ENOENT; - } - - *buf = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); - *buf_len = fw_entry->size; - A_RELEASE_FIRMWARE(fw_entry); - } - -#ifdef SOFTMAC_FILE_USED - if (file==AR6K_BOARD_DATA_FILE && *buf_len) { - ar6000_softmac_update(ar, *buf, *buf_len); - } -#endif - - - fw_entry_size = *buf_len; - - /* Load extended board data for AR6003 */ - if ((file==AR6K_BOARD_DATA_FILE) && *buf) { - u32 board_ext_address; - u32 board_ext_data_size; - u32 board_data_size; - - board_ext_data_size = (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_BOARD_EXT_DATA_SZ : \ - (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_BOARD_EXT_DATA_SZ : 0)); - - board_data_size = (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_BOARD_DATA_SZ : \ - (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_BOARD_DATA_SZ : 0)); - - /* Determine where in Target RAM to write Board Data */ - bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data), (u8 *)&board_ext_address, 4)); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board extended Data download address: 0x%x\n", board_ext_address)); - - /* check whether the target has allocated memory for extended board data and file contains extended board data */ - if ((board_ext_address) && (*buf_len == (board_data_size + board_ext_data_size))) { - u32 param; - - status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(*buf + board_data_size), board_ext_data_size); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); - return A_ERROR; - } - - /* Record the fact that extended board Data IS initialized */ - param = (board_ext_data_size << 16) | 1; - bmifn(BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_config), - (unsigned char *)¶m, 4)); - } - fw_entry_size = board_data_size; - } - - if (compressed) { - status = BMIFastDownload(ar->arHifDevice, address, *buf, fw_entry_size); - } else { - status = BMIWriteMemory(ar->arHifDevice, address, *buf, fw_entry_size); - } - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); - return A_ERROR; - } - - return 0; -} - -int -ar6000_update_bdaddr(struct ar6_softc *ar) -{ - - if (setupbtdev != 0) { - u32 address; - - if (BMIReadMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (u8 *)&address, 4) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for hi_board_data failed\n")); - return A_ERROR; - } - - if (BMIReadMemory(ar->arHifDevice, address + BDATA_BDADDR_OFFSET, (u8 *)ar->bdaddr, 6) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for BD address failed\n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BDADDR 0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", ar->bdaddr[0], - ar->bdaddr[1], ar->bdaddr[2], ar->bdaddr[3], - ar->bdaddr[4], ar->bdaddr[5])); - } - -return 0; -} - -int -ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Requesting device specific configuration\n")); - - if (mode == WLAN_INIT_MODE_UDEV) { - char version[16]; - const struct firmware *fw_entry; - - /* Get config using udev through a script in user space */ - sprintf(version, "%2.2x", ar->arVersion.target_ver); - if ((A_REQUEST_FIRMWARE(&fw_entry, version, ((struct device *)ar->osDevInfo.pOSDevice))) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI: Failure to get configuration for target version: %s\n", version)); - return A_ERROR; - } - - A_RELEASE_FIRMWARE(fw_entry); - } else { - /* The config is contained within the driver itself */ - int status; - u32 param, options, sleep, address; - - /* Temporarily disable system sleep */ - address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS; - bmifn(BMIReadSOCRegister(ar->arHifDevice, address, ¶m)); - options = param; - param |= AR6K_OPTION_SLEEP_DISABLE; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS; - bmifn(BMIReadSOCRegister(ar->arHifDevice, address, ¶m)); - sleep = param; - param |= WLAN_SYSTEM_SLEEP_DISABLE_SET(1); - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("old options: %d, old sleep: %d\n", options, sleep)); - - if (ar->arTargetType == TARGET_TYPE_AR6003) { - /* Program analog PLL register */ - bmifn(BMIWriteSOCRegister(ar->arHifDevice, ANALOG_INTF_BASE_ADDRESS + 0x284, 0xF9104001)); - /* Run at 80/88MHz by default */ - param = CPU_CLOCK_STANDARD_SET(1); - } else { - /* Run at 40/44MHz by default */ - param = CPU_CLOCK_STANDARD_SET(0); - } - address = RTC_BASE_ADDRESS + CPU_CLOCK_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - param = 0; - if (ar->arTargetType == TARGET_TYPE_AR6002) { - bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (u8 *)¶m, 4)); - } - - /* LPO_CAL.ENABLE = 1 if no external clk is detected */ - if (param != 1) { - address = RTC_BASE_ADDRESS + LPO_CAL_ADDRESS; - param = LPO_CAL_ENABLE_SET(1); - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - } - - /* Venus2.0: Lower SDIO pad drive strength, - * temporary WAR to avoid SDIO CRC error */ - if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("AR6K: Temporary WAR to avoid SDIO CRC error\n")); - param = 0x20; - address = GPIO_BASE_ADDRESS + GPIO_PIN10_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - address = GPIO_BASE_ADDRESS + GPIO_PIN11_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - address = GPIO_BASE_ADDRESS + GPIO_PIN12_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - address = GPIO_BASE_ADDRESS + GPIO_PIN13_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - } - -#ifdef FORCE_INTERNAL_CLOCK - /* Ignore external clock, if any, and force use of internal clock */ - if (ar->arTargetType == TARGET_TYPE_AR6003) { - /* hi_ext_clk_detected = 0 */ - param = 0; - bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (u8 *)¶m, 4)); - - /* CLOCK_CONTROL &= ~LF_CLK32 */ - address = RTC_BASE_ADDRESS + CLOCK_CONTROL_ADDRESS; - bmifn(BMIReadSOCRegister(ar->arHifDevice, address, ¶m)); - param &= (~CLOCK_CONTROL_LF_CLK32_SET(1)); - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - } -#endif /* FORCE_INTERNAL_CLOCK */ - - /* Transfer Board Data from Target EEPROM to Target RAM */ - if (ar->arTargetType == TARGET_TYPE_AR6003) { - /* Determine where in Target RAM to write Board Data */ - bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (u8 *)&address, 4)); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board Data download address: 0x%x\n", address)); - - /* Write EEPROM data to Target RAM */ - if ((ar6000_transfer_bin_file(ar, AR6K_BOARD_DATA_FILE, address, false)) != 0) { - return A_ERROR; - } - - /* Record the fact that Board Data IS initialized */ - param = 1; - bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (u8 *)¶m, 4)); - - /* Transfer One time Programmable data */ - AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver); - if (ar->arVersion.target_ver == AR6003_REV3_VERSION) - address = 0x1234; - status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, true); - if (status == 0) { - /* Execute the OTP code */ - param = 0; - AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver); - bmifn(BMIExecute(ar->arHifDevice, address, ¶m)); - } else if (status != A_ENOENT) { - return A_ERROR; - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Programming of board data for chip %d not supported\n", ar->arTargetType)); - return A_ERROR; - } - - /* Download Target firmware */ - AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver); - if (ar->arVersion.target_ver == AR6003_REV3_VERSION) - address = 0x1234; - if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, true)) != 0) { - return A_ERROR; - } - - /* Set starting address for firmware */ - AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver); - bmifn(BMISetAppStart(ar->arHifDevice, address)); - - if(ar->arTargetType == TARGET_TYPE_AR6003) { - AR6K_DATASET_PATCH_ADDRESS(address, ar->arVersion.target_ver); - if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE, - address, false)) != 0) - return A_ERROR; - param = address; - bmifn(BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), - (unsigned char *)¶m, 4)); - } - - /* Restore system sleep */ - address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, sleep)); - - address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS; - param = options | 0x20; - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - - if (ar->arTargetType == TARGET_TYPE_AR6003) { - /* Configure GPIO AR6003 UART */ -#ifndef CONFIG_AR600x_DEBUG_UART_TX_PIN -#define CONFIG_AR600x_DEBUG_UART_TX_PIN 8 -#endif - param = CONFIG_AR600x_DEBUG_UART_TX_PIN; - bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbg_uart_txpin), (u8 *)¶m, 4)); - -#if (CONFIG_AR600x_DEBUG_UART_TX_PIN == 23) - { - address = GPIO_BASE_ADDRESS + CLOCK_GPIO_ADDRESS; - bmifn(BMIReadSOCRegister(ar->arHifDevice, address, ¶m)); - param |= CLOCK_GPIO_BT_CLK_OUT_EN_SET(1); - bmifn(BMIWriteSOCRegister(ar->arHifDevice, address, param)); - } -#endif - - /* Configure GPIO for BT Reset */ -#ifdef ATH6KL_CONFIG_GPIO_BT_RESET -#define CONFIG_AR600x_BT_RESET_PIN 0x16 - param = CONFIG_AR600x_BT_RESET_PIN; - bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_support_pins), (u8 *)¶m, 4)); -#endif /* ATH6KL_CONFIG_GPIO_BT_RESET */ - - /* Configure UART flow control polarity */ -#ifndef CONFIG_ATH6KL_BT_UART_FC_POLARITY -#define CONFIG_ATH6KL_BT_UART_FC_POLARITY 0 -#endif - -#if (CONFIG_ATH6KL_BT_UART_FC_POLARITY == 1) - if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - param = ((CONFIG_ATH6KL_BT_UART_FC_POLARITY << 1) & 0x2); - bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_pwr_mgmt_params), (u8 *)¶m, 4)); - } -#endif /* CONFIG_ATH6KL_BT_UART_FC_POLARITY */ - } - -#ifdef HTC_RAW_INTERFACE - if (!eppingtest && bypasswmi) { - /* Don't run BMIDone for ART mode and force resetok=0 */ - resetok = 0; - msleep(1000); - } -#endif /* HTC_RAW_INTERFACE */ - } - - return 0; -} - -int -ar6000_configure_target(struct ar6_softc *ar) -{ - u32 param; - if (enableuartprint) { - param = 1; - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_serial_enable), - (u8 *)¶m, - 4)!= 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for enableuartprint failed \n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Serial console prints enabled\n")); - } - - /* Tell target which HTC version it is used*/ - param = HTC_PROTOCOL_VERSION; - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_app_host_interest), - (u8 *)¶m, - 4)!= 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for htc version failed \n")); - return A_ERROR; - } - -#ifdef CONFIG_HOST_TCMD_SUPPORT - if(testmode) { - ar->arTargetMode = AR6000_TCMD_MODE; - }else { - ar->arTargetMode = AR6000_WLAN_MODE; - } -#endif - if (enabletimerwar) { - u32 param; - - if (BMIReadMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4)!= 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for enabletimerwar failed \n")); - return A_ERROR; - } - - param |= HI_OPTION_TIMER_WAR; - - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for enabletimerwar failed \n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Timer WAR enabled\n")); - } - - /* set the firmware mode to STA/IBSS/AP */ - { - u32 param; - - if (BMIReadMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4)!= 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for setting fwmode failed \n")); - return A_ERROR; - } - - param |= (num_device << HI_OPTION_NUM_DEV_SHIFT); - param |= (fwmode << HI_OPTION_FW_MODE_SHIFT); - param |= (mac_addr_method << HI_OPTION_MAC_ADDR_METHOD_SHIFT); - param |= (firmware_bridge << HI_OPTION_FW_BRIDGE_SHIFT); - - - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for setting fwmode failed \n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Firmware mode set\n")); - } - -#ifdef ATH6KL_DISABLE_TARGET_DBGLOGS - { - u32 param; - - if (BMIReadMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4)!= 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for disabling debug logs failed\n")); - return A_ERROR; - } - - param |= HI_OPTION_DISABLE_DBGLOG; - - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag), - (u8 *)¶m, - 4) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for HI_OPTION_DISABLE_DBGLOG\n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Firmware mode set\n")); - } -#endif /* ATH6KL_DISABLE_TARGET_DBGLOGS */ - - /* - * Hardcode the address use for the extended board data - * Ideally this should be pre-allocate by the OS at boot time - * But since it is a new feature and board data is loaded - * at init time, we have to workaround this from host. - * It is difficult to patch the firmware boot code, - * but possible in theory. - */ - - if (ar->arTargetType == TARGET_TYPE_AR6003) { - u32 ramReservedSz; - if (ar->arVersion.target_ver == AR6003_REV2_VERSION) { - param = AR6003_REV2_BOARD_EXT_DATA_ADDRESS; - ramReservedSz = AR6003_REV2_RAM_RESERVE_SIZE; - } else { - param = AR6003_REV3_BOARD_EXT_DATA_ADDRESS; - ramReservedSz = AR6003_REV3_RAM_RESERVE_SIZE; - } - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data), - (u8 *)¶m, 4) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("BMIWriteMemory for " - "hi_board_ext_data failed\n")); - return A_ERROR; - } - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, - hi_end_RAM_reserve_sz), - (u8 *)&ramReservedSz, 4) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR , - ("BMIWriteMemory for " - "hi_end_RAM_reserve_sz failed\n")); - return A_ERROR; - } - } - - /* since BMIInit is called in the driver layer, we have to set the block - * size here for the target */ - - if (ar6000_set_htc_params(ar->arHifDevice, ar->arTargetType, - mbox_yield_limit, 0)) { - /* use default number of control buffers */ - return A_ERROR; - } - - if (setupbtdev != 0) { - if (ar6000_set_hci_bridge_flags(ar->arHifDevice, - ar->arTargetType, - setupbtdev)) { - return A_ERROR; - } - } - return 0; -} - -static void -init_netdev(struct net_device *dev, char *name) -{ - dev->netdev_ops = &ar6000_netdev_ops; - dev->watchdog_timeo = AR6000_TX_TIMEOUT; - - /* - * We need the OS to provide us with more headroom in order to - * perform dix to 802.3, WMI header encap, and the HTC header - */ - if (processDot11Hdr) { - dev->hard_header_len = sizeof(struct ieee80211_qosframe) + sizeof(ATH_LLC_SNAP_HDR) + sizeof(WMI_DATA_HDR) + HTC_HEADER_LEN + WMI_MAX_TX_META_SZ + LINUX_HACK_FUDGE_FACTOR; - } else { - dev->hard_header_len = ETH_HLEN + sizeof(ATH_LLC_SNAP_HDR) + - sizeof(WMI_DATA_HDR) + HTC_HEADER_LEN + WMI_MAX_TX_META_SZ + LINUX_HACK_FUDGE_FACTOR; - } - - if (name[0]) - { - strcpy(dev->name, name); - } - -#ifdef CONFIG_CHECKSUM_OFFLOAD - if(csumOffload){ - dev->features |= NETIF_F_IP_CSUM; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/ - } -#endif - - return; -} - -static int __ath6kl_init_netdev(struct net_device *dev) -{ - int r; - - rtnl_lock(); - r = ar6000_init(dev); - rtnl_unlock(); - - if (r) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n")); - return r; - } - - return 0; -} - -#ifdef HTC_RAW_INTERFACE -static int ath6kl_init_netdev_wmi(struct net_device *dev) -{ - if (!eppingtest && bypasswmi) - return 0; - - return __ath6kl_init_netdev(dev); -} -#else -static int ath6kl_init_netdev_wmi(struct net_device *dev) -{ - return __ath6kl_init_netdev(dev); -} -#endif - -static int ath6kl_init_netdev(struct ar6_softc *ar) -{ - int r; - - r = ar6000_sysfs_bmi_get_config(ar, wlaninitmode); - if (r) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("ar6000_avail: " - "ar6000_sysfs_bmi_get_config failed\n")); - return r; - } - - return ath6kl_init_netdev_wmi(ar->arNetDev); -} - -/* - * HTC Event handlers - */ -static int -ar6000_avail_ev(void *context, void *hif_handle) -{ - int i; - struct net_device *dev; - void *ar_netif; - struct ar6_softc *ar; - int device_index = 0; - struct htc_init_info htcInfo; - struct wireless_dev *wdev; - int r = 0; - struct hif_device_os_device_info osDevInfo; - - memset(&osDevInfo, 0, sizeof(osDevInfo)); - if (HIFConfigureDevice(hif_handle, HIF_DEVICE_GET_OS_DEVICE, - &osDevInfo, sizeof(osDevInfo))) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: Failed to get OS device instance\n", __func__)); - return A_ERROR; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_available\n")); - - for (i=0; i < MAX_AR6000; i++) { - if (ar6000_devices[i] == NULL) { - break; - } - } - - if (i == MAX_AR6000) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_available: max devices reached\n")); - return A_ERROR; - } - - /* Save this. It gives a bit better readability especially since */ - /* we use another local "i" variable below. */ - device_index = i; - - wdev = ar6k_cfg80211_init(osDevInfo.pOSDevice); - if (IS_ERR(wdev)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ar6k_cfg80211_init failed\n", __func__)); - return A_ERROR; - } - ar_netif = wdev_priv(wdev); - - if (ar_netif == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Can't allocate ar6k priv memory\n", __func__)); - return A_ERROR; - } - - A_MEMZERO(ar_netif, sizeof(struct ar6_softc)); - ar = (struct ar6_softc *)ar_netif; - - ar->wdev = wdev; - wdev->iftype = NL80211_IFTYPE_STATION; - - dev = alloc_netdev_mq(0, "wlan%d", ether_setup, 1); - if (!dev) { - printk(KERN_CRIT "AR6K: no memory for network device instance\n"); - ar6k_cfg80211_deinit(ar); - return A_ERROR; - } - - dev->ieee80211_ptr = wdev; - SET_NETDEV_DEV(dev, wiphy_dev(wdev->wiphy)); - wdev->netdev = dev; - ar->arNetworkType = INFRA_NETWORK; - ar->smeState = SME_DISCONNECTED; - ar->arAutoAuthStage = AUTH_IDLE; - - init_netdev(dev, ifname); - - - ar->arNetDev = dev; - ar->arHifDevice = hif_handle; - ar->arWlanState = WLAN_ENABLED; - ar->arDeviceIndex = device_index; - - ar->arWlanPowerState = WLAN_POWER_STATE_ON; - ar->arWlanOff = false; /* We are in ON state */ -#ifdef CONFIG_PM - ar->arWowState = WLAN_WOW_STATE_NONE; - ar->arBTOff = true; /* BT chip assumed to be OFF */ - ar->arBTSharing = WLAN_CONFIG_BT_SHARING; - ar->arWlanOffConfig = WLAN_CONFIG_WLAN_OFF; - ar->arSuspendConfig = WLAN_CONFIG_PM_SUSPEND; - ar->arWow2Config = WLAN_CONFIG_PM_WOW2; -#endif /* CONFIG_PM */ - - A_INIT_TIMER(&ar->arHBChallengeResp.timer, ar6000_detect_error, dev); - ar->arHBChallengeResp.seqNum = 0; - ar->arHBChallengeResp.outstanding = false; - ar->arHBChallengeResp.missCnt = 0; - ar->arHBChallengeResp.frequency = AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT; - ar->arHBChallengeResp.missThres = AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT; - - ar6000_init_control_info(ar); - init_waitqueue_head(&arEvent); - sema_init(&ar->arSem, 1); - ar->bIsDestroyProgress = false; - - INIT_HTC_PACKET_QUEUE(&ar->amsdu_rx_buffer_queue); - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL - A_INIT_TIMER(&aptcTimer, aptcTimerHandler, ar); -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - - A_INIT_TIMER(&ar->disconnect_timer, disconnect_timer_handler, dev); - - BMIInit(); - - ar6000_sysfs_bmi_init(ar); - - { - struct bmi_target_info targ_info; - - r = BMIGetTargetInfo(ar->arHifDevice, &targ_info); - if (r) - goto avail_ev_failed; - - ar->arVersion.target_ver = targ_info.target_ver; - ar->arTargetType = targ_info.target_type; - wdev->wiphy->hw_version = targ_info.target_ver; - } - - r = ar6000_configure_target(ar); - if (r) - goto avail_ev_failed; - - A_MEMZERO(&htcInfo,sizeof(htcInfo)); - htcInfo.pContext = ar; - htcInfo.TargetFailure = ar6000_target_failure; - - ar->arHtcTarget = HTCCreate(ar->arHifDevice,&htcInfo); - - if (!ar->arHtcTarget) { - r = -ENOMEM; - goto avail_ev_failed; - } - - spin_lock_init(&ar->arLock); - -#ifdef WAPI_ENABLE - ar->arWapiEnable = 0; -#endif - - - if(csumOffload){ - /*if external frame work is also needed, change and use an extended rxMetaVerion*/ - ar->rxMetaVersion=WMI_META_VERSION_2; - } - - ar->aggr_cntxt = aggr_init(ar6000_alloc_netbufs); - if (!ar->aggr_cntxt) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Failed to initialize aggr.\n", __func__)); - r = -ENOMEM; - goto avail_ev_failed; - } - - aggr_register_rx_dispatcher(ar->aggr_cntxt, (void *)dev, ar6000_deliver_frames_to_nw_stack); - - HIFClaimDevice(ar->arHifDevice, ar); - - /* We only register the device in the global list if we succeed. */ - /* If the device is in the global list, it will be destroyed */ - /* when the module is unloaded. */ - ar6000_devices[device_index] = dev; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("BMI enabled: %d\n", wlaninitmode)); - if ((wlaninitmode == WLAN_INIT_MODE_UDEV) || - (wlaninitmode == WLAN_INIT_MODE_DRV)) { - r = ath6kl_init_netdev(ar); - if (r) - goto avail_ev_failed; - } - - /* This runs the init function if registered */ - r = register_netdev(dev); - if (r) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: register_netdev failed\n")); - ar6000_destroy(dev, 0); - return r; - } - - is_netdev_registered = 1; - -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT - arApNetDev = NULL; -#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_avail: name=%s hifdevice=0x%lx, dev=0x%lx (%d), ar=0x%lx\n", - dev->name, (unsigned long)ar->arHifDevice, (unsigned long)dev, device_index, - (unsigned long)ar)); - -avail_ev_failed : - if (r) - ar6000_sysfs_bmi_deinit(ar); - - return r; -} - -static void ar6000_target_failure(void *Instance, int Status) -{ - struct ar6_softc *ar = (struct ar6_softc *)Instance; - WMI_TARGET_ERROR_REPORT_EVENT errEvent; - static bool sip = false; - - if (Status != 0) { - - printk(KERN_ERR "ar6000_target_failure: target asserted \n"); - - if (timer_pending(&ar->arHBChallengeResp.timer)) { - A_UNTIMEOUT(&ar->arHBChallengeResp.timer); - } - - /* try dumping target assertion information (if any) */ - ar6000_dump_target_assert_info(ar->arHifDevice,ar->arTargetType); - - /* - * Fetch the logs from the target via the diagnostic - * window. - */ - ar6000_dbglog_get_debug_logs(ar); - - /* Report the error only once */ - if (!sip) { - sip = true; - errEvent.errorVal = WMI_TARGET_COM_ERR | - WMI_TARGET_FATAL_ERR; - } - } -} - -static int -ar6000_unavail_ev(void *context, void *hif_handle) -{ - struct ar6_softc *ar = (struct ar6_softc *)context; - /* NULL out it's entry in the global list */ - ar6000_devices[ar->arDeviceIndex] = NULL; - ar6000_destroy(ar->arNetDev, 1); - - return 0; -} - -void -ar6000_restart_endpoint(struct net_device *dev) -{ - int status = 0; - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - BMIInit(); - do { - if ( (status=ar6000_configure_target(ar))!= 0) - break; - if ( (status=ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n")); - break; - } - rtnl_lock(); - status = (ar6000_init(dev)==0) ? 0 : A_ERROR; - rtnl_unlock(); - - if (status) { - break; - } - if (ar->arSsidLen && ar->arWlanState == WLAN_ENABLED) { - ar6000_connect_to_ap(ar); - } - } while (0); - - if (status== 0) { - return; - } - - ar6000_devices[ar->arDeviceIndex] = NULL; - ar6000_destroy(ar->arNetDev, 1); -} - -void -ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - /* Stop the transmit queues */ - netif_stop_queue(dev); - - /* Disable the target and the interrupts associated with it */ - if (ar->arWmiReady == true) - { - if (!bypasswmi) - { - bool disconnectIssued; - - disconnectIssued = (ar->arConnected) || (ar->arConnectPending); - ar6000_disconnect(ar); - if (!keepprofile) { - ar6000_init_profile_info(ar); - } - - A_UNTIMEOUT(&ar->disconnect_timer); - - if (getdbglogs) { - ar6000_dbglog_get_debug_logs(ar); - } - - ar->arWmiReady = false; - wmi_shutdown(ar->arWmi); - ar->arWmiEnabled = false; - ar->arWmi = NULL; - /* - * After wmi_shudown all WMI events will be dropped. - * We need to cleanup the buffers allocated in AP mode - * and give disconnect notification to stack, which usually - * happens in the disconnect_event. - * Simulate the disconnect_event by calling the function directly. - * Sometimes disconnect_event will be received when the debug logs - * are collected. - */ - if (disconnectIssued) { - if(ar->arNetworkType & AP_NETWORK) { - ar6000_disconnect_event(ar, DISCONNECT_CMD, bcast_mac, 0, NULL, 0); - } else { - ar6000_disconnect_event(ar, DISCONNECT_CMD, ar->arBssid, 0, NULL, 0); - } - } - ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT; - ar->user_key_ctrl = 0; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): WMI stopped\n", __func__)); - } - else - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): WMI not ready 0x%lx 0x%lx\n", - __func__, (unsigned long) ar, (unsigned long) ar->arWmi)); - - /* Shut down WMI if we have started it */ - if(ar->arWmiEnabled == true) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): Shut down WMI\n", __func__)); - wmi_shutdown(ar->arWmi); - ar->arWmiEnabled = false; - ar->arWmi = NULL; - } - } - - if (ar->arHtcTarget != NULL) { -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - if (NULL != ar6kHciTransCallbacks.cleanupTransport) { - ar6kHciTransCallbacks.cleanupTransport(NULL); - } -#else - // FIXME: workaround to reset BT's UART baud rate to default - if (NULL != ar->exitCallback) { - struct ar3k_config_info ar3kconfig; - int status; - - A_MEMZERO(&ar3kconfig,sizeof(ar3kconfig)); - ar6000_set_default_ar3kconfig(ar, (void *)&ar3kconfig); - status = ar->exitCallback(&ar3kconfig); - if (0 != status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to reset AR3K baud rate! \n")); - } - } - // END workaround - if (setuphci) - ar6000_cleanup_hci(ar); -#endif - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Shutting down HTC .... \n")); - /* stop HTC */ - HTCStop(ar->arHtcTarget); - } - - if (resetok) { - /* try to reset the device if we can - * The driver may have been configure NOT to reset the target during - * a debug session */ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Attempting to reset target on instance destroy.... \n")); - if (ar->arHifDevice != NULL) { - bool coldReset = (ar->arTargetType == TARGET_TYPE_AR6003) ? true: false; - ar6000_reset_device(ar->arHifDevice, ar->arTargetType, true, coldReset); - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Host does not want target reset. \n")); - } - /* Done with cookies */ - ar6000_cookie_cleanup(ar); - - /* cleanup any allocated AMSDU buffers */ - ar6000_cleanup_amsdu_rxbufs(ar); -} -/* - * We need to differentiate between the surprise and planned removal of the - * device because of the following consideration: - * - In case of surprise removal, the hcd already frees up the pending - * for the device and hence there is no need to unregister the function - * driver inorder to get these requests. For planned removal, the function - * driver has to explicitly unregister itself to have the hcd return all the - * pending requests before the data structures for the devices are freed up. - * Note that as per the current implementation, the function driver will - * end up releasing all the devices since there is no API to selectively - * release a particular device. - * - Certain commands issued to the target can be skipped for surprise - * removal since they will anyway not go through. - */ -void -ar6000_destroy(struct net_device *dev, unsigned int unregister) -{ - struct ar6_softc *ar; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("+ar6000_destroy \n")); - - if((dev == NULL) || ((ar = ar6k_priv(dev)) == NULL)) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s(): Failed to get device structure.\n", __func__)); - return; - } - - ar->bIsDestroyProgress = true; - - if (down_interruptible(&ar->arSem)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s(): down_interruptible failed \n", __func__)); - return; - } - - if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) { - /* only stop endpoint if we are not stop it in suspend_ev */ - ar6000_stop_endpoint(dev, false, true); - } - - ar->arWlanState = WLAN_DISABLED; - if (ar->arHtcTarget != NULL) { - /* destroy HTC */ - HTCDestroy(ar->arHtcTarget); - } - if (ar->arHifDevice != NULL) { - /*release the device so we do not get called back on remove incase we - * we're explicity destroyed by module unload */ - HIFReleaseDevice(ar->arHifDevice); - HIFShutDownDevice(ar->arHifDevice); - } - aggr_module_destroy(ar->aggr_cntxt); - - /* Done with cookies */ - ar6000_cookie_cleanup(ar); - - /* cleanup any allocated AMSDU buffers */ - ar6000_cleanup_amsdu_rxbufs(ar); - - ar6000_sysfs_bmi_deinit(ar); - - /* Cleanup BMI */ - BMICleanup(); - - /* Clear the tx counters */ - memset(tx_attempt, 0, sizeof(tx_attempt)); - memset(tx_post, 0, sizeof(tx_post)); - memset(tx_complete, 0, sizeof(tx_complete)); - -#ifdef HTC_RAW_INTERFACE - if (ar->arRawHtc) { - kfree(ar->arRawHtc); - ar->arRawHtc = NULL; - } -#endif - /* Free up the device data structure */ - if (unregister && is_netdev_registered) { - unregister_netdev(dev); - is_netdev_registered = 0; - } - free_netdev(dev); - - ar6k_cfg80211_deinit(ar); - -#ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT - ar6000_remove_ap_interface(); -#endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - - kfree(ar->fw_otp); - kfree(ar->fw); - kfree(ar->fw_patch); - kfree(ar->fw_data); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("-ar6000_destroy \n")); -} - -static void disconnect_timer_handler(unsigned long ptr) -{ - struct net_device *dev = (struct net_device *)ptr; - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - A_UNTIMEOUT(&ar->disconnect_timer); - - ar6000_init_profile_info(ar); - ar6000_disconnect(ar); -} - -static void ar6000_detect_error(unsigned long ptr) -{ - struct net_device *dev = (struct net_device *)ptr; - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - WMI_TARGET_ERROR_REPORT_EVENT errEvent; - - AR6000_SPIN_LOCK(&ar->arLock, 0); - - if (ar->arHBChallengeResp.outstanding) { - ar->arHBChallengeResp.missCnt++; - } else { - ar->arHBChallengeResp.missCnt = 0; - } - - if (ar->arHBChallengeResp.missCnt > ar->arHBChallengeResp.missThres) { - /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */ - ar->arHBChallengeResp.missCnt = 0; - ar->arHBChallengeResp.seqNum = 0; - errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR; - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - return; - } - - /* Generate the sequence number for the next challenge */ - ar->arHBChallengeResp.seqNum++; - ar->arHBChallengeResp.outstanding = true; - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - /* Send the challenge on the control channel */ - if (wmi_get_challenge_resp_cmd(ar->arWmi, ar->arHBChallengeResp.seqNum, DRV_HB_CHALLENGE) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to send heart beat challenge\n")); - } - - - /* Reschedule the timer for the next challenge */ - A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0); -} - -void ar6000_init_profile_info(struct ar6_softc *ar) -{ - ar->arSsidLen = 0; - A_MEMZERO(ar->arSsid, sizeof(ar->arSsid)); - - switch(fwmode) { - case HI_OPTION_FW_MODE_IBSS: - ar->arNetworkType = ar->arNextMode = ADHOC_NETWORK; - break; - case HI_OPTION_FW_MODE_BSS_STA: - ar->arNetworkType = ar->arNextMode = INFRA_NETWORK; - break; - case HI_OPTION_FW_MODE_AP: - ar->arNetworkType = ar->arNextMode = AP_NETWORK; - break; - } - - ar->arDot11AuthMode = OPEN_AUTH; - ar->arAuthMode = NONE_AUTH; - ar->arPairwiseCrypto = NONE_CRYPT; - ar->arPairwiseCryptoLen = 0; - ar->arGroupCrypto = NONE_CRYPT; - ar->arGroupCryptoLen = 0; - A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList)); - A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid)); - A_MEMZERO(ar->arBssid, sizeof(ar->arBssid)); - ar->arBssChannel = 0; -} - -static void -ar6000_init_control_info(struct ar6_softc *ar) -{ - ar->arWmiEnabled = false; - ar6000_init_profile_info(ar); - ar->arDefTxKeyIndex = 0; - A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList)); - ar->arChannelHint = 0; - ar->arListenIntervalT = A_DEFAULT_LISTEN_INTERVAL; - ar->arListenIntervalB = 0; - ar->arVersion.host_ver = AR6K_SW_VERSION; - ar->arRssi = 0; - ar->arTxPwr = 0; - ar->arTxPwrSet = false; - ar->arSkipScan = 0; - ar->arBeaconInterval = 0; - ar->arBitRate = 0; - ar->arMaxRetries = 0; - ar->arWmmEnabled = true; - ar->intra_bss = 1; - ar->scan_triggered = 0; - A_MEMZERO(&ar->scParams, sizeof(ar->scParams)); - ar->scParams.shortScanRatio = WMI_SHORTSCANRATIO_DEFAULT; - ar->scParams.scanCtrlFlags = DEFAULT_SCAN_CTRL_FLAGS; - - /* Initialize the AP mode state info */ - { - u8 ctr; - A_MEMZERO((u8 *)ar->sta_list, AP_MAX_NUM_STA * sizeof(sta_t)); - - /* init the Mutexes */ - A_MUTEX_INIT(&ar->mcastpsqLock); - - /* Init the PS queues */ - for (ctr=0; ctr < AP_MAX_NUM_STA ; ctr++) { - A_MUTEX_INIT(&ar->sta_list[ctr].psqLock); - A_NETBUF_QUEUE_INIT(&ar->sta_list[ctr].psq); - } - - ar->ap_profile_flag = 0; - A_NETBUF_QUEUE_INIT(&ar->mcastpsq); - - memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3); - ar->ap_wmode = DEF_AP_WMODE_G; - ar->ap_dtim_period = DEF_AP_DTIM; - ar->ap_beacon_interval = DEF_BEACON_INTERVAL; - } -} - -static int -ar6000_open(struct net_device *dev) -{ - unsigned long flags; - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - spin_lock_irqsave(&ar->arLock, flags); - - if(ar->arWlanState == WLAN_DISABLED) { - ar->arWlanState = WLAN_ENABLED; - } - - if( ar->arConnected || bypasswmi) { - netif_carrier_on(dev); - /* Wake up the queues */ - netif_wake_queue(dev); - } - else - netif_carrier_off(dev); - - spin_unlock_irqrestore(&ar->arLock, flags); - return 0; -} - -static int -ar6000_close(struct net_device *dev) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - netif_stop_queue(dev); - - ar6000_disconnect(ar); - - if(ar->arWmiReady == true) { - if (wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, - 0, 0, 0, 0, 0, 0, 0, 0) != 0) { - return -EIO; - } - ar->arWlanState = WLAN_DISABLED; - } - ar6k_cfg80211_scanComplete_event(ar, A_ECANCELED); - - return 0; -} - -/* connect to a service */ -static int ar6000_connectservice(struct ar6_softc *ar, - struct htc_service_connect_req *pConnect, - char *pDesc) -{ - int status; - struct htc_service_connect_resp response; - - do { - - A_MEMZERO(&response,sizeof(response)); - - status = HTCConnectService(ar->arHtcTarget, - pConnect, - &response); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Failed to connect to %s service status:%d \n", - pDesc, status)); - break; - } - switch (pConnect->ServiceID) { - case WMI_CONTROL_SVC : - if (ar->arWmiEnabled) { - /* set control endpoint for WMI use */ - wmi_set_control_ep(ar->arWmi, response.Endpoint); - } - /* save EP for fast lookup */ - ar->arControlEp = response.Endpoint; - break; - case WMI_DATA_BE_SVC : - arSetAc2EndpointIDMap(ar, WMM_AC_BE, response.Endpoint); - break; - case WMI_DATA_BK_SVC : - arSetAc2EndpointIDMap(ar, WMM_AC_BK, response.Endpoint); - break; - case WMI_DATA_VI_SVC : - arSetAc2EndpointIDMap(ar, WMM_AC_VI, response.Endpoint); - break; - case WMI_DATA_VO_SVC : - arSetAc2EndpointIDMap(ar, WMM_AC_VO, response.Endpoint); - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ServiceID not mapped %d\n", pConnect->ServiceID)); - status = A_EINVAL; - break; - } - - } while (false); - - return status; -} - -void ar6000_TxDataCleanup(struct ar6_softc *ar) -{ - /* flush all the data (non-control) streams - * we only flush packets that are tagged as data, we leave any control packets that - * were in the TX queues alone */ - HTCFlushEndpoint(ar->arHtcTarget, - arAc2EndpointID(ar, WMM_AC_BE), - AR6K_DATA_PKT_TAG); - HTCFlushEndpoint(ar->arHtcTarget, - arAc2EndpointID(ar, WMM_AC_BK), - AR6K_DATA_PKT_TAG); - HTCFlushEndpoint(ar->arHtcTarget, - arAc2EndpointID(ar, WMM_AC_VI), - AR6K_DATA_PKT_TAG); - HTCFlushEndpoint(ar->arHtcTarget, - arAc2EndpointID(ar, WMM_AC_VO), - AR6K_DATA_PKT_TAG); -} - -HTC_ENDPOINT_ID -ar6000_ac2_endpoint_id ( void * devt, u8 ac) -{ - struct ar6_softc *ar = (struct ar6_softc *) devt; - return(arAc2EndpointID(ar, ac)); -} - -u8 ar6000_endpoint_id2_ac(void * devt, HTC_ENDPOINT_ID ep ) -{ - struct ar6_softc *ar = (struct ar6_softc *) devt; - return(arEndpoint2Ac(ar, ep )); -} - -#if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE) -static int ath6kl_config_btcoex_params(struct ar6_softc *ar) -{ - int r; - WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd; - WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd; - - /* Configure the type of BT collocated with WLAN */ - memset(&sbcb_cmd, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD)); - sbcb_cmd.btcoexCoLocatedBTdev = ATH6KL_BT_DEV; - - r = wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd); - - if (r) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Unable to set collocated BT type\n")); - return r; - } - - /* Configure the type of BT collocated with WLAN */ - memset(&sbfa_cmd, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD)); - - sbfa_cmd.btcoexFeAntType = ATH6KL_BT_ANTENNA; - - r = wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd); - if (r) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("Unable to set fornt end antenna configuration\n")); - return r; - } - - return 0; -} -#else -static int ath6kl_config_btcoex_params(struct ar6_softc *ar) -{ - return 0; -} -#endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */ - -/* - * This function applies WLAN specific configuration defined in wlan_config.h - */ -int ar6000_target_config_wlan_params(struct ar6_softc *ar) -{ - int status = 0; - -#ifdef CONFIG_HOST_TCMD_SUPPORT - if (ar->arTargetMode != AR6000_WLAN_MODE) { - return 0; - } -#endif /* CONFIG_HOST_TCMD_SUPPORT */ - - /* - * configure the device for rx dot11 header rules 0,0 are the default values - * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required - * if checksum offload is needed. Set RxMetaVersion to 2 - */ - if ((wmi_set_rx_frame_format_cmd(ar->arWmi,ar->rxMetaVersion, processDot11Hdr, processDot11Hdr)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set the rx frame format.\n")); - status = A_ERROR; - } - - status = ath6kl_config_btcoex_params(ar); - if (status) - return status; - -#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN - if ((wmi_pmparams_cmd(ar->arWmi, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set power save fail event policy\n")); - status = A_ERROR; - } -#endif - -#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP - if ((wmi_set_lpreamble_cmd(ar->arWmi, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set barker preamble policy\n")); - status = A_ERROR; - } -#endif - - if ((wmi_set_keepalive_cmd(ar->arWmi, WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set keep alive interval\n")); - status = A_ERROR; - } - -#if WLAN_CONFIG_DISABLE_11N - { - WMI_SET_HT_CAP_CMD htCap; - - memset(&htCap, 0, sizeof(WMI_SET_HT_CAP_CMD)); - htCap.band = 0; - if ((wmi_set_ht_cap_cmd(ar->arWmi, &htCap)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set ht capabilities \n")); - status = A_ERROR; - } - - htCap.band = 1; - if ((wmi_set_ht_cap_cmd(ar->arWmi, &htCap)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set ht capabilities \n")); - status = A_ERROR; - } - } -#endif /* WLAN_CONFIG_DISABLE_11N */ - -#ifdef ATH6K_CONFIG_OTA_MODE - if ((wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set power mode \n")); - status = A_ERROR; - } -#endif - - if ((wmi_disctimeout_cmd(ar->arWmi, WLAN_CONFIG_DISCONNECT_TIMEOUT)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set disconnect timeout \n")); - status = A_ERROR; - } - -#if WLAN_CONFIG_DISABLE_TX_BURSTING - if ((wmi_set_wmm_txop(ar->arWmi, WMI_TXOP_DISABLED)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set txop bursting \n")); - status = A_ERROR; - } -#endif - - return status; -} - -/* This function does one time initialization for the lifetime of the device */ -int ar6000_init(struct net_device *dev) -{ - struct ar6_softc *ar; - int status; - s32 timeleft; - s16 i; - int ret = 0; - - if((ar = ar6k_priv(dev)) == NULL) - { - return -EIO; - } - - if (wlaninitmode == WLAN_INIT_MODE_USR || wlaninitmode == WLAN_INIT_MODE_DRV) { - - ar6000_update_bdaddr(ar); - - if (enablerssicompensation) { - ar6000_copy_cust_data_from_target(ar->arHifDevice, ar->arTargetType); - read_rssi_compensation_param(ar); - for (i=-95; i<=0; i++) { - rssi_compensation_table[0-i] = rssi_compensation_calc(ar,i); - } - } - } - - dev_hold(dev); - rtnl_unlock(); - - /* Do we need to finish the BMI phase */ - if ((wlaninitmode == WLAN_INIT_MODE_USR || wlaninitmode == WLAN_INIT_MODE_DRV) && - (BMIDone(ar->arHifDevice) != 0)) - { - ret = -EIO; - goto ar6000_init_done; - } - - if (!bypasswmi) - { -#if 0 /* TBDXXX */ - if (ar->arVersion.host_ver != ar->arVersion.target_ver) { - A_PRINTF("WARNING: Host version 0x%x does not match Target " - " version 0x%x!\n", - ar->arVersion.host_ver, ar->arVersion.target_ver); - } -#endif - - /* Indicate that WMI is enabled (although not ready yet) */ - ar->arWmiEnabled = true; - if ((ar->arWmi = wmi_init((void *) ar)) == NULL) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Failed to initialize WMI.\n", __func__)); - ret = -EIO; - goto ar6000_init_done; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Got WMI @ 0x%lx.\n", __func__, - (unsigned long) ar->arWmi)); - } - - do { - struct htc_service_connect_req connect; - - /* the reason we have to wait for the target here is that the driver layer - * has to init BMI in order to set the host block size, - */ - status = HTCWaitTarget(ar->arHtcTarget); - - if (status) { - break; - } - - A_MEMZERO(&connect,sizeof(connect)); - /* meta data is unused for now */ - connect.pMetaData = NULL; - connect.MetaDataLength = 0; - /* these fields are the same for all service endpoints */ - connect.EpCallbacks.pContext = ar; - connect.EpCallbacks.EpTxCompleteMultiple = ar6000_tx_complete; - connect.EpCallbacks.EpRecv = ar6000_rx; - connect.EpCallbacks.EpRecvRefill = ar6000_rx_refill; - connect.EpCallbacks.EpSendFull = ar6000_tx_queue_full; - /* set the max queue depth so that our ar6000_tx_queue_full handler gets called. - * Linux has the peculiarity of not providing flow control between the - * NIC and the network stack. There is no API to indicate that a TX packet - * was sent which could provide some back pressure to the network stack. - * Under linux you would have to wait till the network stack consumed all sk_buffs - * before any back-flow kicked in. Which isn't very friendly. - * So we have to manage this ourselves */ - connect.MaxSendQueueDepth = MAX_DEFAULT_SEND_QUEUE_DEPTH; - connect.EpCallbacks.RecvRefillWaterMark = AR6000_MAX_RX_BUFFERS / 4; /* set to 25 % */ - if (0 == connect.EpCallbacks.RecvRefillWaterMark) { - connect.EpCallbacks.RecvRefillWaterMark++; - } - /* connect to control service */ - connect.ServiceID = WMI_CONTROL_SVC; - status = ar6000_connectservice(ar, - &connect, - "WMI CONTROL"); - if (status) { - break; - } - - connect.LocalConnectionFlags |= HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING; - /* limit the HTC message size on the send path, although we can receive A-MSDU frames of - * 4K, we will only send ethernet-sized (802.3) frames on the send path. */ - connect.MaxSendMsgSize = WMI_MAX_TX_DATA_FRAME_LENGTH; - - /* to reduce the amount of committed memory for larger A_MSDU frames, use the recv-alloc threshold - * mechanism for larger packets */ - connect.EpCallbacks.RecvAllocThreshold = AR6000_BUFFER_SIZE; - connect.EpCallbacks.EpRecvAllocThresh = ar6000_alloc_amsdu_rxbuf; - - /* for the remaining data services set the connection flag to reduce dribbling, - * if configured to do so */ - if (reduce_credit_dribble) { - connect.ConnectionFlags |= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE; - /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value - * of 0-3 */ - connect.ConnectionFlags &= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK; - connect.ConnectionFlags |= - ((u16)reduce_credit_dribble - 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK; - } - /* connect to best-effort service */ - connect.ServiceID = WMI_DATA_BE_SVC; - - status = ar6000_connectservice(ar, - &connect, - "WMI DATA BE"); - if (status) { - break; - } - - /* connect to back-ground - * map this to WMI LOW_PRI */ - connect.ServiceID = WMI_DATA_BK_SVC; - status = ar6000_connectservice(ar, - &connect, - "WMI DATA BK"); - if (status) { - break; - } - - /* connect to Video service, map this to - * to HI PRI */ - connect.ServiceID = WMI_DATA_VI_SVC; - status = ar6000_connectservice(ar, - &connect, - "WMI DATA VI"); - if (status) { - break; - } - - /* connect to VO service, this is currently not - * mapped to a WMI priority stream due to historical reasons. - * WMI originally defined 3 priorities over 3 mailboxes - * We can change this when WMI is reworked so that priorities are not - * dependent on mailboxes */ - connect.ServiceID = WMI_DATA_VO_SVC; - status = ar6000_connectservice(ar, - &connect, - "WMI DATA VO"); - if (status) { - break; - } - - A_ASSERT(arAc2EndpointID(ar,WMM_AC_BE) != 0); - A_ASSERT(arAc2EndpointID(ar,WMM_AC_BK) != 0); - A_ASSERT(arAc2EndpointID(ar,WMM_AC_VI) != 0); - A_ASSERT(arAc2EndpointID(ar,WMM_AC_VO) != 0); - - /* setup access class priority mappings */ - ar->arAcStreamPriMap[WMM_AC_BK] = 0; /* lowest */ - ar->arAcStreamPriMap[WMM_AC_BE] = 1; /* */ - ar->arAcStreamPriMap[WMM_AC_VI] = 2; /* */ - ar->arAcStreamPriMap[WMM_AC_VO] = 3; /* highest */ - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - if (setuphci && (NULL != ar6kHciTransCallbacks.setupTransport)) { - struct hci_transport_misc_handles hciHandles; - - hciHandles.netDevice = ar->arNetDev; - hciHandles.hifDevice = ar->arHifDevice; - hciHandles.htcHandle = ar->arHtcTarget; - status = (int)(ar6kHciTransCallbacks.setupTransport(&hciHandles)); - } -#else - if (setuphci) { - /* setup HCI */ - status = ar6000_setup_hci(ar); - } -#endif - - } while (false); - - if (status) { - ret = -EIO; - goto ar6000_init_done; - } - - if (regscanmode) { - u32 param; - - if (BMIReadMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, - hi_option_flag), - (u8 *)¶m, - 4) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("BMIReadMemory forsetting " - "regscanmode failed\n")); - return A_ERROR; - } - - if (regscanmode == 1) - param |= HI_OPTION_SKIP_REG_SCAN; - else if (regscanmode == 2) - param |= HI_OPTION_INIT_REG_SCAN; - - if (BMIWriteMemory(ar->arHifDevice, - HOST_INTEREST_ITEM_ADDRESS(ar, - hi_option_flag), - (u8 *)¶m, - 4) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("BMIWriteMemory forsetting " - "regscanmode failed\n")); - return A_ERROR; - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Regulatory scan mode set\n")); - } - - /* - * give our connected endpoints some buffers - */ - - ar6000_rx_refill(ar, ar->arControlEp); - ar6000_rx_refill(ar, arAc2EndpointID(ar,WMM_AC_BE)); - - /* - * We will post the receive buffers only for SPE or endpoint ping testing so we are - * making it conditional on the 'bypasswmi' flag. - */ - if (bypasswmi) { - ar6000_rx_refill(ar,arAc2EndpointID(ar,WMM_AC_BK)); - ar6000_rx_refill(ar,arAc2EndpointID(ar,WMM_AC_VI)); - ar6000_rx_refill(ar,arAc2EndpointID(ar,WMM_AC_VO)); - } - - /* allocate some buffers that handle larger AMSDU frames */ - ar6000_refill_amsdu_rxbufs(ar,AR6000_MAX_AMSDU_RX_BUFFERS); - - /* setup credit distribution */ - ar6000_setup_credit_dist(ar->arHtcTarget, &ar->arCreditStateInfo); - - /* Since cookies are used for HTC transports, they should be */ - /* initialized prior to enabling HTC. */ - ar6000_cookie_init(ar); - - /* start HTC */ - status = HTCStart(ar->arHtcTarget); - - if (status) { - if (ar->arWmiEnabled == true) { - wmi_shutdown(ar->arWmi); - ar->arWmiEnabled = false; - ar->arWmi = NULL; - } - ar6000_cookie_cleanup(ar); - ret = -EIO; - goto ar6000_init_done; - } - - if (!bypasswmi) { - /* Wait for Wmi event to be ready */ - timeleft = wait_event_interruptible_timeout(arEvent, - (ar->arWmiReady == true), wmitimeout * HZ); - - if (ar->arVersion.abi_ver != AR6K_ABI_VERSION) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ABI Version mismatch: Host(0x%x), Target(0x%x)\n", AR6K_ABI_VERSION, ar->arVersion.abi_ver)); -#ifndef ATH6K_SKIP_ABI_VERSION_CHECK - ret = -EIO; - goto ar6000_init_done; -#endif /* ATH6K_SKIP_ABI_VERSION_CHECK */ - } - - if(!timeleft || signal_pending(current)) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI is not ready or wait was interrupted\n")); - ret = -EIO; - goto ar6000_init_done; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() WMI is ready\n", __func__)); - - /* Communicate the wmi protocol verision to the target */ - if ((ar6000_set_host_app_area(ar)) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set the host app area\n")); - } - ar6000_target_config_wlan_params(ar); - } - - ar->arNumDataEndPts = 1; - - if (bypasswmi) { - /* for tests like endpoint ping, the MAC address needs to be non-zero otherwise - * the data path through a raw socket is disabled */ - dev->dev_addr[0] = 0x00; - dev->dev_addr[1] = 0x01; - dev->dev_addr[2] = 0x02; - dev->dev_addr[3] = 0xAA; - dev->dev_addr[4] = 0xBB; - dev->dev_addr[5] = 0xCC; - } - -ar6000_init_done: - rtnl_lock(); - dev_put(dev); - - return ret; -} - - -void -ar6000_bitrate_rx(void *devt, s32 rateKbps) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - - ar->arBitRate = rateKbps; - wake_up(&arEvent); -} - -void -ar6000_ratemask_rx(void *devt, u32 ratemask) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - - ar->arRateMask = ratemask; - wake_up(&arEvent); -} - -void -ar6000_txPwr_rx(void *devt, u8 txPwr) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - - ar->arTxPwr = txPwr; - wake_up(&arEvent); -} - - -void -ar6000_channelList_rx(void *devt, s8 numChan, u16 *chanList) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - - memcpy(ar->arChannelList, chanList, numChan * sizeof (u16)); - ar->arNumChannels = numChan; - - wake_up(&arEvent); -} - -u8 ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, u32 *mapNo) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - u8 *datap; - ATH_MAC_HDR *macHdr; - u32 i, eptMap; - - (*mapNo) = 0; - datap = A_NETBUF_DATA(skb); - macHdr = (ATH_MAC_HDR *)(datap + sizeof(WMI_DATA_HDR)); - if (IEEE80211_IS_MULTICAST(macHdr->dstMac)) { - return ENDPOINT_2; - } - - eptMap = -1; - for (i = 0; i < ar->arNodeNum; i ++) { - if (IEEE80211_ADDR_EQ(macHdr->dstMac, ar->arNodeMap[i].macAddress)) { - (*mapNo) = i + 1; - ar->arNodeMap[i].txPending ++; - return ar->arNodeMap[i].epId; - } - - if ((eptMap == -1) && !ar->arNodeMap[i].txPending) { - eptMap = i; - } - } - - if (eptMap == -1) { - eptMap = ar->arNodeNum; - ar->arNodeNum ++; - A_ASSERT(ar->arNodeNum <= MAX_NODE_NUM); - } - - memcpy(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN); - - for (i = ENDPOINT_2; i <= ENDPOINT_5; i ++) { - if (!ar->arTxPending[i]) { - ar->arNodeMap[eptMap].epId = i; - break; - } - // No free endpoint is available, start redistribution on the inuse endpoints. - if (i == ENDPOINT_5) { - ar->arNodeMap[eptMap].epId = ar->arNexEpId; - ar->arNexEpId ++; - if (ar->arNexEpId > ENDPOINT_5) { - ar->arNexEpId = ENDPOINT_2; - } - } - } - - (*mapNo) = eptMap + 1; - ar->arNodeMap[eptMap].txPending ++; - - return ar->arNodeMap[eptMap].epId; -} - -#ifdef DEBUG -static void ar6000_dump_skb(struct sk_buff *skb) -{ - u_char *ch; - for (ch = A_NETBUF_DATA(skb); - (unsigned long)ch < ((unsigned long)A_NETBUF_DATA(skb) + - A_NETBUF_LEN(skb)); ch++) - { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("%2.2x ", *ch)); - } - AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("\n")); -} -#endif - -#ifdef HTC_TEST_SEND_PKTS -static void DoHTCSendPktsTest(struct ar6_softc *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *skb); -#endif - -static int -ar6000_data_tx(struct sk_buff *skb, struct net_device *dev) -{ -#define AC_NOT_MAPPED 99 - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - u8 ac = AC_NOT_MAPPED; - HTC_ENDPOINT_ID eid = ENDPOINT_UNUSED; - u32 mapNo = 0; - int len; - struct ar_cookie *cookie; - bool checkAdHocPsMapping = false,bMoreData = false; - HTC_TX_TAG htc_tag = AR6K_DATA_PKT_TAG; - u8 dot11Hdr = processDot11Hdr; -#ifdef CONFIG_PM - if (ar->arWowState != WLAN_WOW_STATE_NONE) { - A_NETBUF_FREE(skb); - return 0; - } -#endif /* CONFIG_PM */ - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("ar6000_data_tx start - skb=0x%lx, data=0x%lx, len=0x%x\n", - (unsigned long)skb, (unsigned long)A_NETBUF_DATA(skb), - A_NETBUF_LEN(skb))); - - /* If target is not associated */ - if( (!ar->arConnected && !bypasswmi) -#ifdef CONFIG_HOST_TCMD_SUPPORT - /* TCMD doesn't support any data, free the buf and return */ - || (ar->arTargetMode == AR6000_TCMD_MODE) -#endif - ) { - A_NETBUF_FREE(skb); - return 0; - } - - do { - - if (ar->arWmiReady == false && bypasswmi == 0) { - break; - } - -#ifdef BLOCK_TX_PATH_FLAG - if (blocktx) { - break; - } -#endif /* BLOCK_TX_PATH_FLAG */ - - /* AP mode Power save processing */ - /* If the dst STA is in sleep state, queue the pkt in its PS queue */ - - if (ar->arNetworkType == AP_NETWORK) { - ATH_MAC_HDR *datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb); - sta_t *conn = NULL; - - /* If the dstMac is a Multicast address & atleast one of the - * associated STA is in PS mode, then queue the pkt to the - * mcastq - */ - if (IEEE80211_IS_MULTICAST(datap->dstMac)) { - u8 ctr=0; - bool qMcast=false; - - - for (ctr=0; ctrsta_list[ctr]))) { - qMcast = true; - } - } - if(qMcast) { - - /* If this transmit is not because of a Dtim Expiry q it */ - if (ar->DTIMExpired == false) { - bool isMcastqEmpty = false; - - A_MUTEX_LOCK(&ar->mcastpsqLock); - isMcastqEmpty = A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq); - A_NETBUF_ENQUEUE(&ar->mcastpsq, skb); - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - - /* If this is the first Mcast pkt getting queued - * indicate to the target to set the BitmapControl LSB - * of the TIM IE. - */ - if (isMcastqEmpty) { - wmi_set_pvb_cmd(ar->arWmi, MCAST_AID, 1); - } - return 0; - } else { - /* This transmit is because of Dtim expiry. Determine if - * MoreData bit has to be set. - */ - A_MUTEX_LOCK(&ar->mcastpsqLock); - if(!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) { - bMoreData = true; - } - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - } - } - } else { - conn = ieee80211_find_conn(ar, datap->dstMac); - if (conn) { - if (STA_IS_PWR_SLEEP(conn)) { - /* If this transmit is not because of a PsPoll q it*/ - if (!STA_IS_PS_POLLED(conn)) { - bool isPsqEmpty = false; - /* Queue the frames if the STA is sleeping */ - A_MUTEX_LOCK(&conn->psqLock); - isPsqEmpty = A_NETBUF_QUEUE_EMPTY(&conn->psq); - A_NETBUF_ENQUEUE(&conn->psq, skb); - A_MUTEX_UNLOCK(&conn->psqLock); - - /* If this is the first pkt getting queued - * for this STA, update the PVB for this STA - */ - if (isPsqEmpty) { - wmi_set_pvb_cmd(ar->arWmi, conn->aid, 1); - } - - return 0; - } else { - /* This tx is because of a PsPoll. Determine if - * MoreData bit has to be set - */ - A_MUTEX_LOCK(&conn->psqLock); - if (!A_NETBUF_QUEUE_EMPTY(&conn->psq)) { - bMoreData = true; - } - A_MUTEX_UNLOCK(&conn->psqLock); - } - } - } else { - - /* non existent STA. drop the frame */ - A_NETBUF_FREE(skb); - return 0; - } - } - } - - if (ar->arWmiEnabled) { - u8 csumStart=0; - u8 csumDest=0; - u8 csum=skb->ip_summed; - if(csumOffload && (csum==CHECKSUM_PARTIAL)){ - csumStart = (skb->head + skb->csum_start - skb_network_header(skb) + - sizeof(ATH_LLC_SNAP_HDR)); - csumDest=skb->csum_offset+csumStart; - } - if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len - LINUX_HACK_FUDGE_FACTOR) { - struct sk_buff *newbuf; - - /* - * We really should have gotten enough headroom but sometimes - * we still get packets with not enough headroom. Copy the packet. - */ - len = A_NETBUF_LEN(skb); - newbuf = A_NETBUF_ALLOC(len); - if (newbuf == NULL) { - break; - } - A_NETBUF_PUT(newbuf, len); - memcpy(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len); - A_NETBUF_FREE(skb); - skb = newbuf; - /* fall through and assemble header */ - } - - if (dot11Hdr) { - if (wmi_dot11_hdr_add(ar->arWmi,skb,ar->arNetworkType) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx-wmi_dot11_hdr_add failed\n")); - break; - } - } else { - if (wmi_dix_2_dot3(ar->arWmi, skb) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_dix_2_dot3 failed\n")); - break; - } - } - if(csumOffload && (csum ==CHECKSUM_PARTIAL)){ - WMI_TX_META_V2 metaV2; - metaV2.csumStart =csumStart; - metaV2.csumDest = csumDest; - metaV2.csumFlags = 0x1;/*instruct target to calculate checksum*/ - if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr, - WMI_META_VERSION_2,&metaV2) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n")); - break; - } - - } - else - { - if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,0,NULL) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n")); - break; - } - } - - - if ((ar->arNetworkType == ADHOC_NETWORK) && - ar->arIbssPsEnable && ar->arConnected) { - /* flag to check adhoc mapping once we take the lock below: */ - checkAdHocPsMapping = true; - - } else { - /* get the stream mapping */ - ac = wmi_implicit_create_pstream(ar->arWmi, skb, 0, ar->arWmmEnabled); - } - - } else { - EPPING_HEADER *eppingHdr; - - eppingHdr = A_NETBUF_DATA(skb); - - if (IS_EPPING_PACKET(eppingHdr)) { - /* the stream ID is mapped to an access class */ - ac = eppingHdr->StreamNo_h; - /* some EPPING packets cannot be dropped no matter what access class it was - * sent on. We can change the packet tag to guarantee it will not get dropped */ - if (IS_EPING_PACKET_NO_DROP(eppingHdr)) { - htc_tag = AR6K_CONTROL_PKT_TAG; - } - - if (ac == HCI_TRANSPORT_STREAM_NUM) { - /* pass this to HCI */ -#ifndef EXPORT_HCI_BRIDGE_INTERFACE - if (!hci_test_send(ar,skb)) { - return 0; - } -#endif - /* set AC to discard this skb */ - ac = AC_NOT_MAPPED; - } else { - /* a quirk of linux, the payload of the frame is 32-bit aligned and thus the addition - * of the HTC header will mis-align the start of the HTC frame, so we add some - * padding which will be stripped off in the target */ - if (EPPING_ALIGNMENT_PAD > 0) { - A_NETBUF_PUSH(skb, EPPING_ALIGNMENT_PAD); - } - } - - } else { - /* not a ping packet, drop it */ - ac = AC_NOT_MAPPED; - } - } - - } while (false); - - /* did we succeed ? */ - if ((ac == AC_NOT_MAPPED) && !checkAdHocPsMapping) { - /* cleanup and exit */ - A_NETBUF_FREE(skb); - AR6000_STAT_INC(ar, tx_dropped); - AR6000_STAT_INC(ar, tx_aborted_errors); - return 0; - } - - cookie = NULL; - - /* take the lock to protect driver data */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - - do { - - if (checkAdHocPsMapping) { - eid = ar6000_ibss_map_epid(skb, dev, &mapNo); - }else { - eid = arAc2EndpointID (ar, ac); - } - /* validate that the endpoint is connected */ - if (eid == 0 || eid == ENDPOINT_UNUSED ) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" eid %d is NOT mapped!\n", eid)); - break; - } - /* allocate resource for this packet */ - cookie = ar6000_alloc_cookie(ar); - - if (cookie != NULL) { - /* update counts while the lock is held */ - ar->arTxPending[eid]++; - ar->arTotalTxDataPending++; - } - - } while (false); - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (cookie != NULL) { - cookie->arc_bp[0] = (unsigned long)skb; - cookie->arc_bp[1] = mapNo; - SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt, - cookie, - A_NETBUF_DATA(skb), - A_NETBUF_LEN(skb), - eid, - htc_tag); - -#ifdef DEBUG - if (debugdriver >= 3) { - ar6000_dump_skb(skb); - } -#endif -#ifdef HTC_TEST_SEND_PKTS - DoHTCSendPktsTest(ar,mapNo,eid,skb); -#endif - /* HTC interface is asynchronous, if this fails, cleanup will happen in - * the ar6000_tx_complete callback */ - HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt); - } else { - /* no packet to send, cleanup */ - A_NETBUF_FREE(skb); - AR6000_STAT_INC(ar, tx_dropped); - AR6000_STAT_INC(ar, tx_aborted_errors); - } - - return 0; -} - -int -ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - struct ar_cookie *cookie; - HTC_ENDPOINT_ID eid = ENDPOINT_UNUSED; - - cookie = NULL; - AR6000_SPIN_LOCK(&ar->arLock, 0); - - /* For now we send ACL on BE endpoint: We can also have a dedicated EP */ - eid = arAc2EndpointID (ar, 0); - /* allocate resource for this packet */ - cookie = ar6000_alloc_cookie(ar); - - if (cookie != NULL) { - /* update counts while the lock is held */ - ar->arTxPending[eid]++; - ar->arTotalTxDataPending++; - } - - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (cookie != NULL) { - cookie->arc_bp[0] = (unsigned long)skb; - cookie->arc_bp[1] = 0; - SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt, - cookie, - A_NETBUF_DATA(skb), - A_NETBUF_LEN(skb), - eid, - AR6K_DATA_PKT_TAG); - - /* HTC interface is asynchronous, if this fails, cleanup will happen in - * the ar6000_tx_complete callback */ - HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt); - } else { - /* no packet to send, cleanup */ - A_NETBUF_FREE(skb); - AR6000_STAT_INC(ar, tx_dropped); - AR6000_STAT_INC(ar, tx_aborted_errors); - } - return 0; -} - - -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL -static void -tvsub(register struct timeval *out, register struct timeval *in) -{ - if((out->tv_usec -= in->tv_usec) < 0) { - out->tv_sec--; - out->tv_usec += 1000000; - } - out->tv_sec -= in->tv_sec; -} - -void -applyAPTCHeuristics(struct ar6_softc *ar) -{ - u32 duration; - u32 numbytes; - u32 throughput; - struct timeval ts; - int status; - - AR6000_SPIN_LOCK(&ar->arLock, 0); - - if ((enableAPTCHeuristics) && (!aptcTR.timerScheduled)) { - do_gettimeofday(&ts); - tvsub(&ts, &aptcTR.samplingTS); - duration = ts.tv_sec * 1000 + ts.tv_usec / 1000; /* ms */ - numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived; - - if (duration > APTC_TRAFFIC_SAMPLING_INTERVAL) { - /* Initialize the time stamp and byte count */ - aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0; - do_gettimeofday(&aptcTR.samplingTS); - - /* Calculate and decide based on throughput thresholds */ - throughput = ((numbytes * 8) / duration); - if (throughput > APTC_UPPER_THROUGHPUT_THRESHOLD) { - /* Disable Sleep and schedule a timer */ - A_ASSERT(ar->arWmiReady == true); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - status = wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER); - AR6000_SPIN_LOCK(&ar->arLock, 0); - A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0); - aptcTR.timerScheduled = true; - } - } - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); -} -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - -static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - HTC_SEND_FULL_ACTION action = HTC_SEND_FULL_KEEP; - bool stopNet = false; - HTC_ENDPOINT_ID Endpoint = HTC_GET_ENDPOINT_FROM_PKT(pPacket); - - do { - - if (bypasswmi) { - int accessClass; - - if (HTC_GET_TAG_FROM_PKT(pPacket) == AR6K_CONTROL_PKT_TAG) { - /* don't drop special control packets */ - break; - } - - accessClass = arEndpoint2Ac(ar,Endpoint); - /* for endpoint ping testing drop Best Effort and Background */ - if ((accessClass == WMM_AC_BE) || (accessClass == WMM_AC_BK)) { - action = HTC_SEND_FULL_DROP; - stopNet = false; - } else { - /* keep but stop the netqueues */ - stopNet = true; - } - break; - } - - if (Endpoint == ar->arControlEp) { - /* under normal WMI if this is getting full, then something is running rampant - * the host should not be exhausting the WMI queue with too many commands - * the only exception to this is during testing using endpointping */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - /* set flag to handle subsequent messages */ - ar->arWMIControlEpFull = true; - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI Control Endpoint is FULL!!! \n")); - /* no need to stop the network */ - stopNet = false; - break; - } - - /* if we get here, we are dealing with data endpoints getting full */ - - if (HTC_GET_TAG_FROM_PKT(pPacket) == AR6K_CONTROL_PKT_TAG) { - /* don't drop control packets issued on ANY data endpoint */ - break; - } - - if (ar->arNetworkType == ADHOC_NETWORK) { - /* in adhoc mode, we cannot differentiate traffic priorities so there is no need to - * continue, however we should stop the network */ - stopNet = true; - break; - } - /* the last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for the highest - * active stream */ - if (ar->arAcStreamPriMap[arEndpoint2Ac(ar,Endpoint)] < ar->arHiAcStreamActivePri && - ar->arCookieCount <= MAX_HI_COOKIE_NUM) { - /* this stream's priority is less than the highest active priority, we - * give preference to the highest priority stream by directing - * HTC to drop the packet that overflowed */ - action = HTC_SEND_FULL_DROP; - /* since we are dropping packets, no need to stop the network */ - stopNet = false; - break; - } - - } while (false); - - if (stopNet) { - AR6000_SPIN_LOCK(&ar->arLock, 0); - ar->arNetQueueStopped = true; - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - /* one of the data endpoints queues is getting full..need to stop network stack - * the queue will resume in ar6000_tx_complete() */ - netif_stop_queue(ar->arNetDev); - } - - return action; -} - - -static void -ar6000_tx_complete(void *Context, struct htc_packet_queue *pPacketQueue) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - u32 mapNo = 0; - int status; - struct ar_cookie * ar_cookie; - HTC_ENDPOINT_ID eid; - bool wakeEvent = false; - struct sk_buff_head skb_queue; - struct htc_packet *pPacket; - struct sk_buff *pktSkb; - bool flushing = false; - - skb_queue_head_init(&skb_queue); - - /* lock the driver as we update internal state */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - - /* reap completed packets */ - while (!HTC_QUEUE_EMPTY(pPacketQueue)) { - - pPacket = HTC_PACKET_DEQUEUE(pPacketQueue); - - ar_cookie = (struct ar_cookie *)pPacket->pPktContext; - A_ASSERT(ar_cookie); - - status = pPacket->Status; - pktSkb = (struct sk_buff *)ar_cookie->arc_bp[0]; - eid = pPacket->Endpoint; - mapNo = ar_cookie->arc_bp[1]; - - A_ASSERT(pktSkb); - A_ASSERT(pPacket->pBuffer == A_NETBUF_DATA(pktSkb)); - - /* add this to the list, use faster non-lock API */ - __skb_queue_tail(&skb_queue,pktSkb); - - if (!status) { - A_ASSERT(pPacket->ActualLength == A_NETBUF_LEN(pktSkb)); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("ar6000_tx_complete skb=0x%lx data=0x%lx len=0x%x eid=%d ", - (unsigned long)pktSkb, (unsigned long)pPacket->pBuffer, - pPacket->ActualLength, - eid)); - - ar->arTxPending[eid]--; - - if ((eid != ar->arControlEp) || bypasswmi) { - ar->arTotalTxDataPending--; - } - - if (eid == ar->arControlEp) - { - if (ar->arWMIControlEpFull) { - /* since this packet completed, the WMI EP is no longer full */ - ar->arWMIControlEpFull = false; - } - - if (ar->arTxPending[eid] == 0) { - wakeEvent = true; - } - } - - if (status) { - if (status == A_ECANCELED) { - /* a packet was flushed */ - flushing = true; - } - AR6000_STAT_INC(ar, tx_errors); - if (status != A_NO_RESOURCE) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() -TX ERROR, status: 0x%x\n", __func__, - status)); - } - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("OK\n")); - flushing = false; - AR6000_STAT_INC(ar, tx_packets); - ar->arNetStats.tx_bytes += A_NETBUF_LEN(pktSkb); -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL - aptcTR.bytesTransmitted += a_netbuf_to_len(pktSkb); - applyAPTCHeuristics(ar); -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - } - - // TODO this needs to be looked at - if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable - && (eid != ar->arControlEp) && mapNo) - { - mapNo --; - ar->arNodeMap[mapNo].txPending --; - - if (!ar->arNodeMap[mapNo].txPending && (mapNo == (ar->arNodeNum - 1))) { - u32 i; - for (i = ar->arNodeNum; i > 0; i --) { - if (!ar->arNodeMap[i - 1].txPending) { - A_MEMZERO(&ar->arNodeMap[i - 1], sizeof(struct ar_node_mapping)); - ar->arNodeNum --; - } else { - break; - } - } - } - } - - ar6000_free_cookie(ar, ar_cookie); - - if (ar->arNetQueueStopped) { - ar->arNetQueueStopped = false; - } - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - /* lock is released, we can freely call other kernel APIs */ - - /* free all skbs in our local list */ - while (!skb_queue_empty(&skb_queue)) { - /* use non-lock version */ - pktSkb = __skb_dequeue(&skb_queue); - A_NETBUF_FREE(pktSkb); - } - - if ((ar->arConnected == true) || bypasswmi) { - if (!flushing) { - /* don't wake the queue if we are flushing, other wise it will just - * keep queueing packets, which will keep failing */ - netif_wake_queue(ar->arNetDev); - } - } - - if (wakeEvent) { - wake_up(&arEvent); - } - -} - -sta_t * -ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr) -{ - sta_t *conn = NULL; - u8 i, max_conn; - - switch(ar->arNetworkType) { - case AP_NETWORK: - max_conn = AP_MAX_NUM_STA; - break; - default: - max_conn=0; - break; - } - - for (i = 0; i < max_conn; i++) { - if (IEEE80211_ADDR_EQ(node_addr, ar->sta_list[i].mac)) { - conn = &ar->sta_list[i]; - break; - } - } - - return conn; -} - -sta_t *ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid) -{ - sta_t *conn = NULL; - u8 ctr; - - for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { - if (ar->sta_list[ctr].aid == aid) { - conn = &ar->sta_list[ctr]; - break; - } - } - return conn; -} - -/* - * Receive event handler. This is called by HTC when a packet is received - */ -int pktcount; -static void -ar6000_rx(void *Context, struct htc_packet *pPacket) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - struct sk_buff *skb = (struct sk_buff *)pPacket->pPktContext; - int minHdrLen; - u8 containsDot11Hdr = 0; - int status = pPacket->Status; - HTC_ENDPOINT_ID ept = pPacket->Endpoint; - - A_ASSERT((status) || - (pPacket->pBuffer == (A_NETBUF_DATA(skb) + HTC_HEADER_LEN))); - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX,("ar6000_rx ar=0x%lx eid=%d, skb=0x%lx, data=0x%lx, len=0x%x status:%d", - (unsigned long)ar, ept, (unsigned long)skb, (unsigned long)pPacket->pBuffer, - pPacket->ActualLength, status)); - if (status) { - if (status != A_ECANCELED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("RX ERR (%d) \n",status)); - } - } - - /* take lock to protect buffer counts - * and adaptive power throughput state */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - - if (!status) { - AR6000_STAT_INC(ar, rx_packets); - ar->arNetStats.rx_bytes += pPacket->ActualLength; -#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL - aptcTR.bytesReceived += a_netbuf_to_len(skb); - applyAPTCHeuristics(ar); -#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */ - - A_NETBUF_PUT(skb, pPacket->ActualLength + HTC_HEADER_LEN); - A_NETBUF_PULL(skb, HTC_HEADER_LEN); - -#ifdef DEBUG - if (debugdriver >= 2) { - ar6000_dump_skb(skb); - } -#endif /* DEBUG */ - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - skb->dev = ar->arNetDev; - if (status) { - AR6000_STAT_INC(ar, rx_errors); - A_NETBUF_FREE(skb); - } else if (ar->arWmiEnabled == true) { - if (ept == ar->arControlEp) { - /* - * this is a wmi control msg - */ -#ifdef CONFIG_PM - ar6000_check_wow_status(ar, skb, true); -#endif /* CONFIG_PM */ - wmi_control_rx(ar->arWmi, skb); - } else { - WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb); - bool is_amsdu; - u8 tid; - - /* - * This check can be removed if after a while we do not - * see the warning. For now we leave it to ensure - * we drop these frames accordingly in case the - * target generates them for some reason. These - * were used for an internal PAL but that's not - * used or supported anymore. These frames should - * not come up from the target. - */ - if (WARN_ON(WMI_DATA_HDR_GET_DATA_TYPE(dhdr) == - WMI_DATA_HDR_DATA_TYPE_ACL)) { - AR6000_STAT_INC(ar, rx_errors); - A_NETBUF_FREE(skb); - return; - } - -#ifdef CONFIG_PM - ar6000_check_wow_status(ar, NULL, false); -#endif /* CONFIG_PM */ - /* - * this is a wmi data packet - */ - // NWF - - if (processDot11Hdr) { - minHdrLen = sizeof(WMI_DATA_HDR) + sizeof(struct ieee80211_frame) + sizeof(ATH_LLC_SNAP_HDR); - } else { - minHdrLen = sizeof (WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) + - sizeof(ATH_LLC_SNAP_HDR); - } - - /* In the case of AP mode we may receive NULL data frames - * that do not have LLC hdr. They are 16 bytes in size. - * Allow these frames in the AP mode. - * ACL data frames don't follow ethernet frame bounds for - * min length - */ - if (ar->arNetworkType != AP_NETWORK && - ((pPacket->ActualLength < minHdrLen) || - (pPacket->ActualLength > AR6000_MAX_RX_MESSAGE_SIZE))) - { - /* - * packet is too short or too long - */ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("TOO SHORT or TOO LONG\n")); - AR6000_STAT_INC(ar, rx_errors); - AR6000_STAT_INC(ar, rx_length_errors); - A_NETBUF_FREE(skb); - } else { - u16 seq_no; - u8 meta_type; - -#if 0 - /* Access RSSI values here */ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("RSSI %d\n", - ((WMI_DATA_HDR *) A_NETBUF_DATA(skb))->rssi)); -#endif - /* Get the Power save state of the STA */ - if (ar->arNetworkType == AP_NETWORK) { - sta_t *conn = NULL; - u8 psState=0,prevPsState; - ATH_MAC_HDR *datap=NULL; - u16 offset; - - meta_type = WMI_DATA_HDR_GET_META(dhdr); - - psState = (((WMI_DATA_HDR *)A_NETBUF_DATA(skb))->info - >> WMI_DATA_HDR_PS_SHIFT) & WMI_DATA_HDR_PS_MASK; - - offset = sizeof(WMI_DATA_HDR); - - switch (meta_type) { - case 0: - break; - case WMI_META_VERSION_1: - offset += sizeof(WMI_RX_META_V1); - break; - case WMI_META_VERSION_2: - offset += sizeof(WMI_RX_META_V2); - break; - default: - break; - } - - datap = (ATH_MAC_HDR *)(A_NETBUF_DATA(skb)+offset); - conn = ieee80211_find_conn(ar, datap->srcMac); - - if (conn) { - /* if there is a change in PS state of the STA, - * take appropriate steps. - * 1. If Sleep-->Awake, flush the psq for the STA - * Clear the PVB for the STA. - * 2. If Awake-->Sleep, Starting queueing frames - * the STA. - */ - prevPsState = STA_IS_PWR_SLEEP(conn); - if (psState) { - STA_SET_PWR_SLEEP(conn); - } else { - STA_CLR_PWR_SLEEP(conn); - } - - if (prevPsState ^ STA_IS_PWR_SLEEP(conn)) { - - if (!STA_IS_PWR_SLEEP(conn)) { - - A_MUTEX_LOCK(&conn->psqLock); - while (!A_NETBUF_QUEUE_EMPTY(&conn->psq)) { - struct sk_buff *skb=NULL; - - skb = A_NETBUF_DEQUEUE(&conn->psq); - A_MUTEX_UNLOCK(&conn->psqLock); - ar6000_data_tx(skb,ar->arNetDev); - A_MUTEX_LOCK(&conn->psqLock); - } - A_MUTEX_UNLOCK(&conn->psqLock); - /* Clear the PVB for this STA */ - wmi_set_pvb_cmd(ar->arWmi, conn->aid, 0); - } - } - } else { - /* This frame is from a STA that is not associated*/ - A_ASSERT(false); - } - - /* Drop NULL data frames here */ - if((pPacket->ActualLength < minHdrLen) || - (pPacket->ActualLength > AR6000_MAX_RX_MESSAGE_SIZE)) { - A_NETBUF_FREE(skb); - goto rx_done; - } - } - - is_amsdu = WMI_DATA_HDR_IS_AMSDU(dhdr) ? true : false; - tid = WMI_DATA_HDR_GET_UP(dhdr); - seq_no = WMI_DATA_HDR_GET_SEQNO(dhdr); - meta_type = WMI_DATA_HDR_GET_META(dhdr); - containsDot11Hdr = WMI_DATA_HDR_GET_DOT11(dhdr); - - wmi_data_hdr_remove(ar->arWmi, skb); - - switch (meta_type) { - case WMI_META_VERSION_1: - { - WMI_RX_META_V1 *pMeta = (WMI_RX_META_V1 *)A_NETBUF_DATA(skb); - A_PRINTF("META %d %d %d %d %x\n", pMeta->status, pMeta->rix, pMeta->rssi, pMeta->channel, pMeta->flags); - A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V1)); - break; - } - case WMI_META_VERSION_2: - { - WMI_RX_META_V2 *pMeta = (WMI_RX_META_V2 *)A_NETBUF_DATA(skb); - if(pMeta->csumFlags & 0x1){ - skb->ip_summed=CHECKSUM_COMPLETE; - skb->csum=(pMeta->csum); - } - A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V2)); - break; - } - default: - break; - } - - A_ASSERT(status == 0); - - /* NWF: print the 802.11 hdr bytes */ - if(containsDot11Hdr) { - status = wmi_dot11_hdr_remove(ar->arWmi,skb); - } else if(!is_amsdu) { - status = wmi_dot3_2_dix(skb); - } - - if (status) { - /* Drop frames that could not be processed (lack of memory, etc.) */ - A_NETBUF_FREE(skb); - goto rx_done; - } - - if ((ar->arNetDev->flags & IFF_UP) == IFF_UP) { - if (ar->arNetworkType == AP_NETWORK) { - struct sk_buff *skb1 = NULL; - ATH_MAC_HDR *datap; - - datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb); - if (IEEE80211_IS_MULTICAST(datap->dstMac)) { - /* Bcast/Mcast frames should be sent to the OS - * stack as well as on the air. - */ - skb1 = skb_copy(skb,GFP_ATOMIC); - } else { - /* Search for a connected STA with dstMac as - * the Mac address. If found send the frame to - * it on the air else send the frame up the - * stack - */ - sta_t *conn = NULL; - conn = ieee80211_find_conn(ar, datap->dstMac); - - if (conn && ar->intra_bss) { - skb1 = skb; - skb = NULL; - } else if(conn && !ar->intra_bss) { - A_NETBUF_FREE(skb); - skb = NULL; - } - } - if (skb1) { - ar6000_data_tx(skb1, ar->arNetDev); - } - } - } - aggr_process_recv_frm(ar->aggr_cntxt, tid, seq_no, is_amsdu, (void **)&skb); - ar6000_deliver_frames_to_nw_stack((void *) ar->arNetDev, (void *)skb); - } - } - } else { - if (EPPING_ALIGNMENT_PAD > 0) { - A_NETBUF_PULL(skb, EPPING_ALIGNMENT_PAD); - } - ar6000_deliver_frames_to_nw_stack((void *)ar->arNetDev, (void *)skb); - } - -rx_done: - - return; -} - -static void -ar6000_deliver_frames_to_nw_stack(void *dev, void *osbuf) -{ - struct sk_buff *skb = (struct sk_buff *)osbuf; - - if(skb) { - skb->dev = dev; - if ((skb->dev->flags & IFF_UP) == IFF_UP) { -#ifdef CONFIG_PM - ar6000_check_wow_status((struct ar6_softc *)ar6k_priv(dev), skb, false); -#endif /* CONFIG_PM */ - skb->protocol = eth_type_trans(skb, skb->dev); - /* - * If this routine is called on a ISR (Hard IRQ) or DSR (Soft IRQ) - * or tasklet use the netif_rx to deliver the packet to the stack - * netif_rx will queue the packet onto the receive queue and mark - * the softirq thread has a pending action to complete. Kernel will - * schedule the softIrq kernel thread after processing the DSR. - * - * If this routine is called on a process context, use netif_rx_ni - * which will schedle the softIrq kernel thread after queuing the packet. - */ - if (in_interrupt()) { - netif_rx(skb); - } else { - netif_rx_ni(skb); - } - } else { - A_NETBUF_FREE(skb); - } - } -} - -#if 0 -static void -ar6000_deliver_frames_to_bt_stack(void *dev, void *osbuf) -{ - struct sk_buff *skb = (struct sk_buff *)osbuf; - - if(skb) { - skb->dev = dev; - if ((skb->dev->flags & IFF_UP) == IFF_UP) { - skb->protocol = htons(ETH_P_CONTROL); - netif_rx(skb); - } else { - A_NETBUF_FREE(skb); - } - } -} -#endif - -static void -ar6000_rx_refill(void *Context, HTC_ENDPOINT_ID Endpoint) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - void *osBuf; - int RxBuffers; - int buffersToRefill; - struct htc_packet *pPacket; - struct htc_packet_queue queue; - - buffersToRefill = (int)AR6000_MAX_RX_BUFFERS - - HTCGetNumRecvBuffers(ar->arHtcTarget, Endpoint); - - if (buffersToRefill <= 0) { - /* fast return, nothing to fill */ - return; - } - - INIT_HTC_PACKET_QUEUE(&queue); - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX,("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n", - buffersToRefill, Endpoint)); - - for (RxBuffers = 0; RxBuffers < buffersToRefill; RxBuffers++) { - osBuf = A_NETBUF_ALLOC(AR6000_BUFFER_SIZE); - if (NULL == osBuf) { - break; - } - /* the HTC packet wrapper is at the head of the reserved area - * in the skb */ - pPacket = (struct htc_packet *)(A_NETBUF_HEAD(osBuf)); - /* set re-fill info */ - SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),AR6000_BUFFER_SIZE,Endpoint); - /* add to queue */ - HTC_PACKET_ENQUEUE(&queue,pPacket); - } - - if (!HTC_QUEUE_EMPTY(&queue)) { - /* add packets */ - HTCAddReceivePktMultiple(ar->arHtcTarget, &queue); - } - -} - - /* clean up our amsdu buffer list */ -static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc *ar) -{ - struct htc_packet *pPacket; - void *osBuf; - - /* empty AMSDU buffer queue and free OS bufs */ - while (true) { - - AR6000_SPIN_LOCK(&ar->arLock, 0); - pPacket = HTC_PACKET_DEQUEUE(&ar->amsdu_rx_buffer_queue); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (NULL == pPacket) { - break; - } - - osBuf = pPacket->pPktContext; - if (NULL == osBuf) { - A_ASSERT(false); - break; - } - - A_NETBUF_FREE(osBuf); - } - -} - - - /* refill the amsdu buffer list */ -static void ar6000_refill_amsdu_rxbufs(struct ar6_softc *ar, int Count) -{ - struct htc_packet *pPacket; - void *osBuf; - - while (Count > 0) { - osBuf = A_NETBUF_ALLOC(AR6000_AMSDU_BUFFER_SIZE); - if (NULL == osBuf) { - break; - } - /* the HTC packet wrapper is at the head of the reserved area - * in the skb */ - pPacket = (struct htc_packet *)(A_NETBUF_HEAD(osBuf)); - /* set re-fill info */ - SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),AR6000_AMSDU_BUFFER_SIZE,0); - - AR6000_SPIN_LOCK(&ar->arLock, 0); - /* put it in the list */ - HTC_PACKET_ENQUEUE(&ar->amsdu_rx_buffer_queue,pPacket); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - Count--; - } - -} - - /* callback to allocate a large receive buffer for a pending packet. This function is called when - * an HTC packet arrives whose length exceeds a threshold value - * - * We use a pre-allocated list of buffers of maximum AMSDU size (4K). Under linux it is more optimal to - * keep the allocation size the same to optimize cached-slab allocations. - * - * */ -static struct htc_packet *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length) -{ - struct htc_packet *pPacket = NULL; - struct ar6_softc *ar = (struct ar6_softc *)Context; - int refillCount = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX,("ar6000_alloc_amsdu_rxbuf: eid=%d, Length:%d\n",Endpoint,Length)); - - do { - - if (Length <= AR6000_BUFFER_SIZE) { - /* shouldn't be getting called on normal sized packets */ - A_ASSERT(false); - break; - } - - if (Length > AR6000_AMSDU_BUFFER_SIZE) { - A_ASSERT(false); - break; - } - - AR6000_SPIN_LOCK(&ar->arLock, 0); - /* allocate a packet from the list */ - pPacket = HTC_PACKET_DEQUEUE(&ar->amsdu_rx_buffer_queue); - /* see if we need to refill again */ - refillCount = AR6000_MAX_AMSDU_RX_BUFFERS - HTC_PACKET_QUEUE_DEPTH(&ar->amsdu_rx_buffer_queue); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (NULL == pPacket) { - break; - } - /* set actual endpoint ID */ - pPacket->Endpoint = Endpoint; - - } while (false); - - if (refillCount >= AR6000_AMSDU_REFILL_THRESHOLD) { - ar6000_refill_amsdu_rxbufs(ar,refillCount); - } - - return pPacket; -} - -static void -ar6000_set_multicast_list(struct net_device *dev) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000: Multicast filter not supported\n")); -} - -static struct net_device_stats * -ar6000_get_stats(struct net_device *dev) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - return &ar->arNetStats; -} - -void -ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - struct net_device *dev = ar->arNetDev; - - memcpy(dev->dev_addr, datap, AR6000_ETH_ADDR_LEN); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", - dev->dev_addr[0], dev->dev_addr[1], - dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5])); - - ar->arPhyCapability = phyCap; - ar->arVersion.wlan_ver = sw_ver; - ar->arVersion.abi_ver = abi_ver; - - snprintf(ar->wdev->wiphy->fw_version, sizeof(ar->wdev->wiphy->fw_version), - "%u:%u:%u:%u", - (ar->arVersion.wlan_ver & 0xf0000000) >> 28, - (ar->arVersion.wlan_ver & 0x0f000000) >> 24, - (ar->arVersion.wlan_ver & 0x00ff0000) >> 16, - (ar->arVersion.wlan_ver & 0x0000ffff)); - - /* Indicate to the waiting thread that the ready event was received */ - ar->arWmiReady = true; - wake_up(&arEvent); -} - -void ar6000_install_static_wep_keys(struct ar6_softc *ar) -{ - u8 index; - u8 keyUsage; - - for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) { - if (ar->arWepKeyList[index].arKeyLen) { - keyUsage = GROUP_USAGE; - if (index == ar->arDefTxKeyIndex) { - keyUsage |= TX_USAGE; - } - wmi_addKey_cmd(ar->arWmi, - index, - WEP_CRYPT, - keyUsage, - ar->arWepKeyList[index].arKeyLen, - NULL, - ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL, - NO_SYNC_WMIFLAG); - } - } -} - -void -add_new_sta(struct ar6_softc *ar, u8 *mac, u16 aid, u8 *wpaie, - u8 ielen, u8 keymgmt, u8 ucipher, u8 auth) -{ - u8 free_slot=aid-1; - - memcpy(ar->sta_list[free_slot].mac, mac, ATH_MAC_LEN); - memcpy(ar->sta_list[free_slot].wpa_ie, wpaie, ielen); - ar->sta_list[free_slot].aid = aid; - ar->sta_list[free_slot].keymgmt = keymgmt; - ar->sta_list[free_slot].ucipher = ucipher; - ar->sta_list[free_slot].auth = auth; - ar->sta_list_index = ar->sta_list_index | (1 << free_slot); - ar->arAPStats.sta[free_slot].aid = aid; -} - -void -ar6000_connect_event(struct ar6_softc *ar, u16 channel, u8 *bssid, - u16 listenInterval, u16 beaconInterval, - NETWORK_TYPE networkType, u8 beaconIeLen, - u8 assocReqLen, u8 assocRespLen, - u8 *assocInfo) -{ - union iwreq_data wrqu; - int i, beacon_ie_pos, assoc_resp_ie_pos, assoc_req_ie_pos; - static const char *tag1 = "ASSOCINFO(ReqIEs="; - static const char *tag2 = "ASSOCRESPIE="; - static const char *beaconIetag = "BEACONIE="; - char buf[WMI_CONTROL_MSG_MAX_LEN * 2 + strlen(tag1) + 1]; - char *pos; - u8 key_op_ctrl; - unsigned long flags; - struct ieee80211req_key *ik; - CRYPTO_TYPE keyType = NONE_CRYPT; - - if(ar->arNetworkType & AP_NETWORK) { - struct net_device *dev = ar->arNetDev; - if(memcmp(dev->dev_addr, bssid, ATH_MAC_LEN)==0) { - ar->arACS = channel; - ik = &ar->ap_mode_bkey; - - switch(ar->arAuthMode) { - case NONE_AUTH: - if(ar->arPairwiseCrypto == WEP_CRYPT) { - ar6000_install_static_wep_keys(ar); - } -#ifdef WAPI_ENABLE - else if(ar->arPairwiseCrypto == WAPI_CRYPT) { - ap_set_wapi_key(ar, ik); - } -#endif - break; - case WPA_PSK_AUTH: - case WPA2_PSK_AUTH: - case (WPA_PSK_AUTH|WPA2_PSK_AUTH): - switch (ik->ik_type) { - case IEEE80211_CIPHER_TKIP: - keyType = TKIP_CRYPT; - break; - case IEEE80211_CIPHER_AES_CCM: - keyType = AES_CRYPT; - break; - default: - goto skip_key; - } - wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, GROUP_USAGE, - ik->ik_keylen, (u8 *)&ik->ik_keyrsc, - ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr, - SYNC_BOTH_WMIFLAG); - - break; - } -skip_key: - ar->arConnected = true; - return; - } - - A_PRINTF("NEW STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x \n " - " AID=%d \n", bssid[0], bssid[1], bssid[2], - bssid[3], bssid[4], bssid[5], channel); - switch ((listenInterval>>8)&0xFF) { - case OPEN_AUTH: - A_PRINTF("AUTH: OPEN\n"); - break; - case SHARED_AUTH: - A_PRINTF("AUTH: SHARED\n"); - break; - default: - A_PRINTF("AUTH: Unknown\n"); - break; - } - switch (listenInterval&0xFF) { - case WPA_PSK_AUTH: - A_PRINTF("KeyMgmt: WPA-PSK\n"); - break; - case WPA2_PSK_AUTH: - A_PRINTF("KeyMgmt: WPA2-PSK\n"); - break; - default: - A_PRINTF("KeyMgmt: NONE\n"); - break; - } - switch (beaconInterval) { - case AES_CRYPT: - A_PRINTF("Cipher: AES\n"); - break; - case TKIP_CRYPT: - A_PRINTF("Cipher: TKIP\n"); - break; - case WEP_CRYPT: - A_PRINTF("Cipher: WEP\n"); - break; -#ifdef WAPI_ENABLE - case WAPI_CRYPT: - A_PRINTF("Cipher: WAPI\n"); - break; -#endif - default: - A_PRINTF("Cipher: NONE\n"); - break; - } - - add_new_sta(ar, bssid, channel /*aid*/, - assocInfo /* WPA IE */, assocRespLen /* IE len */, - listenInterval&0xFF /* Keymgmt */, beaconInterval /* cipher */, - (listenInterval>>8)&0xFF /* auth alg */); - - /* Send event to application */ - A_MEMZERO(&wrqu, sizeof(wrqu)); - memcpy(wrqu.addr.sa_data, bssid, ATH_MAC_LEN); - wireless_send_event(ar->arNetDev, IWEVREGISTERED, &wrqu, NULL); - /* In case the queue is stopped when we switch modes, this will - * wake it up - */ - netif_wake_queue(ar->arNetDev); - return; - } - - ar6k_cfg80211_connect_event(ar, channel, bssid, - listenInterval, beaconInterval, - networkType, beaconIeLen, - assocReqLen, assocRespLen, - assocInfo); - - memcpy(ar->arBssid, bssid, sizeof(ar->arBssid)); - ar->arBssChannel = channel; - - A_PRINTF("AR6000 connected event on freq %d ", channel); - A_PRINTF("with bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x " - " listenInterval=%d, beaconInterval = %d, beaconIeLen = %d assocReqLen=%d" - " assocRespLen =%d\n", - bssid[0], bssid[1], bssid[2], - bssid[3], bssid[4], bssid[5], - listenInterval, beaconInterval, - beaconIeLen, assocReqLen, assocRespLen); - if (networkType & ADHOC_NETWORK) { - if (networkType & ADHOC_CREATOR) { - A_PRINTF("Network: Adhoc (Creator)\n"); - } else { - A_PRINTF("Network: Adhoc (Joiner)\n"); - } - } else { - A_PRINTF("Network: Infrastructure\n"); - } - - if ((ar->arNetworkType == INFRA_NETWORK)) { - wmi_listeninterval_cmd(ar->arWmi, ar->arListenIntervalT, ar->arListenIntervalB); - } - - if (beaconIeLen && (sizeof(buf) > (9 + beaconIeLen * 2))) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\nBeaconIEs= ")); - - beacon_ie_pos = 0; - A_MEMZERO(buf, sizeof(buf)); - sprintf(buf, "%s", beaconIetag); - pos = buf + 9; - for (i = beacon_ie_pos; i < beacon_ie_pos + beaconIeLen; i++) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("%2.2x ", assocInfo[i])); - sprintf(pos, "%2.2x", assocInfo[i]); - pos += 2; - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\n")); - - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); - } - - if (assocRespLen && (sizeof(buf) > (12 + (assocRespLen * 2)))) - { - assoc_resp_ie_pos = beaconIeLen + assocReqLen + - sizeof(u16) + /* capinfo*/ - sizeof(u16) + /* status Code */ - sizeof(u16) ; /* associd */ - A_MEMZERO(buf, sizeof(buf)); - sprintf(buf, "%s", tag2); - pos = buf + 12; - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\nAssocRespIEs= ")); - /* - * The Association Response Frame w.o. the WLAN header is delivered to - * the host, so skip over to the IEs - */ - for (i = assoc_resp_ie_pos; i < assoc_resp_ie_pos + assocRespLen - 6; i++) - { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("%2.2x ", assocInfo[i])); - sprintf(pos, "%2.2x", assocInfo[i]); - pos += 2; - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\n")); - - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); - } - - if (assocReqLen && (sizeof(buf) > (17 + (assocReqLen * 2)))) { - /* - * assoc Request includes capability and listen interval. Skip these. - */ - assoc_req_ie_pos = beaconIeLen + - sizeof(u16) + /* capinfo*/ - sizeof(u16); /* listen interval */ - - A_MEMZERO(buf, sizeof(buf)); - sprintf(buf, "%s", tag1); - pos = buf + 17; - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("AssocReqIEs= ")); - for (i = assoc_req_ie_pos; i < assoc_req_ie_pos + assocReqLen - 4; i++) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("%2.2x ", assocInfo[i])); - sprintf(pos, "%2.2x", assocInfo[i]); - pos += 2; - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\n")); - - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); - } - - if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN && - ar->user_saved_keys.keyOk == true) - { - key_op_ctrl = KEY_OP_VALID_MASK & ~KEY_OP_INIT_TSC; - - if (ar->user_key_ctrl & AR6000_USER_SETKEYS_RSC_UNCHANGED) { - key_op_ctrl &= ~KEY_OP_INIT_RSC; - } else { - key_op_ctrl |= KEY_OP_INIT_RSC; - } - ar6000_reinstall_keys(ar, key_op_ctrl); - } - - netif_wake_queue(ar->arNetDev); - - /* Update connect & link status atomically */ - spin_lock_irqsave(&ar->arLock, flags); - ar->arConnected = true; - ar->arConnectPending = false; - netif_carrier_on(ar->arNetDev); - spin_unlock_irqrestore(&ar->arLock, flags); - /* reset the rx aggr state */ - aggr_reset_state(ar->aggr_cntxt); - reconnect_flag = 0; - - A_MEMZERO(&wrqu, sizeof(wrqu)); - memcpy(wrqu.addr.sa_data, bssid, IEEE80211_ADDR_LEN); - wrqu.addr.sa_family = ARPHRD_ETHER; - wireless_send_event(ar->arNetDev, SIOCGIWAP, &wrqu, NULL); - if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable) { - A_MEMZERO(ar->arNodeMap, sizeof(ar->arNodeMap)); - ar->arNodeNum = 0; - ar->arNexEpId = ENDPOINT_2; - } - if (!ar->arUserBssFilter) { - wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0); - } - -} - -void ar6000_set_numdataendpts(struct ar6_softc *ar, u32 num) -{ - A_ASSERT(num <= (HTC_MAILBOX_NUM_MAX - 1)); - ar->arNumDataEndPts = num; -} - -void -sta_cleanup(struct ar6_softc *ar, u8 i) -{ - struct sk_buff *skb; - - /* empty the queued pkts in the PS queue if any */ - A_MUTEX_LOCK(&ar->sta_list[i].psqLock); - while (!A_NETBUF_QUEUE_EMPTY(&ar->sta_list[i].psq)) { - skb = A_NETBUF_DEQUEUE(&ar->sta_list[i].psq); - A_NETBUF_FREE(skb); - } - A_MUTEX_UNLOCK(&ar->sta_list[i].psqLock); - - /* Zero out the state fields */ - A_MEMZERO(&ar->arAPStats.sta[ar->sta_list[i].aid-1], sizeof(WMI_PER_STA_STAT)); - A_MEMZERO(&ar->sta_list[i].mac, ATH_MAC_LEN); - A_MEMZERO(&ar->sta_list[i].wpa_ie, IEEE80211_MAX_IE); - ar->sta_list[i].aid = 0; - ar->sta_list[i].flags = 0; - - ar->sta_list_index = ar->sta_list_index & ~(1 << i); - -} - -u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason) -{ - u8 i, removed=0; - - if(IS_MAC_NULL(mac)) { - return removed; - } - - if(IS_MAC_BCAST(mac)) { - A_PRINTF("DEL ALL STA\n"); - for(i=0; i < AP_MAX_NUM_STA; i++) { - if(!IS_MAC_NULL(ar->sta_list[i].mac)) { - sta_cleanup(ar, i); - removed = 1; - } - } - } else { - for(i=0; i < AP_MAX_NUM_STA; i++) { - if(memcmp(ar->sta_list[i].mac, mac, ATH_MAC_LEN)==0) { - A_PRINTF("DEL STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x " - " aid=%d REASON=%d\n", mac[0], mac[1], mac[2], - mac[3], mac[4], mac[5], ar->sta_list[i].aid, reason); - - sta_cleanup(ar, i); - removed = 1; - break; - } - } - } - return removed; -} - -void -ar6000_disconnect_event(struct ar6_softc *ar, u8 reason, u8 *bssid, - u8 assocRespLen, u8 *assocInfo, u16 protocolReasonStatus) -{ - u8 i; - unsigned long flags; - union iwreq_data wrqu; - - if(ar->arNetworkType & AP_NETWORK) { - union iwreq_data wrqu; - struct sk_buff *skb; - - if(!remove_sta(ar, bssid, protocolReasonStatus)) { - return; - } - - /* If there are no more associated STAs, empty the mcast PS q */ - if (ar->sta_list_index == 0) { - A_MUTEX_LOCK(&ar->mcastpsqLock); - while (!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) { - skb = A_NETBUF_DEQUEUE(&ar->mcastpsq); - A_NETBUF_FREE(skb); - } - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - - /* Clear the LSB of the BitMapCtl field of the TIM IE */ - if (ar->arWmiReady) { - wmi_set_pvb_cmd(ar->arWmi, MCAST_AID, 0); - } - } - - if(!IS_MAC_BCAST(bssid)) { - /* Send event to application */ - A_MEMZERO(&wrqu, sizeof(wrqu)); - memcpy(wrqu.addr.sa_data, bssid, ATH_MAC_LEN); - wireless_send_event(ar->arNetDev, IWEVEXPIRED, &wrqu, NULL); - } - - ar->arConnected = false; - return; - } - - ar6k_cfg80211_disconnect_event(ar, reason, bssid, - assocRespLen, assocInfo, - protocolReasonStatus); - - /* Send disconnect event to supplicant */ - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.addr.sa_family = ARPHRD_ETHER; - wireless_send_event(ar->arNetDev, SIOCGIWAP, &wrqu, NULL); - - /* it is necessary to clear the host-side rx aggregation state */ - aggr_reset_state(ar->aggr_cntxt); - - A_UNTIMEOUT(&ar->disconnect_timer); - - A_PRINTF("AR6000 disconnected"); - if (bssid[0] || bssid[1] || bssid[2] || bssid[3] || bssid[4] || bssid[5]) { - A_PRINTF(" from %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", - bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\nDisconnect Reason is %d", reason)); - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\nProtocol Reason/Status Code is %d", protocolReasonStatus)); - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\nAssocResp Frame = %s", - assocRespLen ? " " : "NULL")); - for (i = 0; i < assocRespLen; i++) { - if (!(i % 0x10)) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\n")); - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("%2.2x ", assocInfo[i])); - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("\n")); - /* - * If the event is due to disconnect cmd from the host, only they the target - * would stop trying to connect. Under any other condition, target would - * keep trying to connect. - * - */ - if( reason == DISCONNECT_CMD) - { - if ((!ar->arUserBssFilter) && (ar->arWmiReady)) { - wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0); - } - } else { - ar->arConnectPending = true; - if (((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x11)) || - ((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x0) && (reconnect_flag == 1))) { - ar->arConnected = true; - return; - } - } - - if ((reason == NO_NETWORK_AVAIL) && (ar->arWmiReady)) - { - bss_t *pWmiSsidnode = NULL; - - /* remove the current associated bssid node */ - wmi_free_node (ar->arWmi, bssid); - - /* - * In case any other same SSID nodes are present - * remove it, since those nodes also not available now - */ - do - { - /* - * Find the nodes based on SSID and remove it - * NOTE :: This case will not work out for Hidden-SSID - */ - pWmiSsidnode = wmi_find_Ssidnode (ar->arWmi, ar->arSsid, ar->arSsidLen, false, true); - - if (pWmiSsidnode) - { - wmi_free_node (ar->arWmi, pWmiSsidnode->ni_macaddr); - } - - } while (pWmiSsidnode); - } - - /* Update connect & link status atomically */ - spin_lock_irqsave(&ar->arLock, flags); - ar->arConnected = false; - netif_carrier_off(ar->arNetDev); - spin_unlock_irqrestore(&ar->arLock, flags); - - if( (reason != CSERV_DISCONNECT) || (reconnect_flag != 1) ) { - reconnect_flag = 0; - } - - if (reason != CSERV_DISCONNECT) - { - ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT; - ar->user_key_ctrl = 0; - } - - netif_stop_queue(ar->arNetDev); - A_MEMZERO(ar->arBssid, sizeof(ar->arBssid)); - ar->arBssChannel = 0; - ar->arBeaconInterval = 0; - - ar6000_TxDataCleanup(ar); -} - -void -ar6000_regDomain_event(struct ar6_softc *ar, u32 regCode) -{ - A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode); - ar->arRegCode = regCode; -} - -void -ar6000_aggr_rcv_addba_req_evt(struct ar6_softc *ar, WMI_ADDBA_REQ_EVENT *evt) -{ - if(evt->status == 0) { - aggr_recv_addba_req_evt(ar->aggr_cntxt, evt->tid, evt->st_seq_no, evt->win_sz); - } -} - -void -ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc *ar, WMI_ADDBA_RESP_EVENT *evt) -{ - A_PRINTF("ADDBA RESP. tid %d status %d, sz %d\n", evt->tid, evt->status, evt->amsdu_sz); - if(evt->status == 0) { - } -} - -void -ar6000_aggr_rcv_delba_req_evt(struct ar6_softc *ar, WMI_DELBA_EVENT *evt) -{ - aggr_recv_delba_req_evt(ar->aggr_cntxt, evt->tid); -} - -void register_pal_cb(ar6k_pal_config_t *palConfig_p) -{ - ar6k_pal_config_g = *palConfig_p; -} - -void -ar6000_hci_event_rcv_evt(struct ar6_softc *ar, WMI_HCI_EVENT *cmd) -{ - void *osbuf = NULL; - s8 i; - u8 size, *buf; - int ret = 0; - - size = cmd->evt_buf_sz + 4; - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - ret = A_NO_MEMORY; - A_PRINTF("Error in allocating netbuf \n"); - return; - } - - A_NETBUF_PUT(osbuf, size); - buf = (u8 *)A_NETBUF_DATA(osbuf); - /* First 2-bytes carry HCI event/ACL data type - * the next 2 are free - */ - *((short *)buf) = WMI_HCI_EVENT_EVENTID; - buf += sizeof(int); - memcpy(buf, cmd->buf, cmd->evt_buf_sz); - - ar6000_deliver_frames_to_nw_stack(ar->arNetDev, osbuf); - if(loghci) { - A_PRINTF_LOG("HCI Event From PAL <-- \n"); - for(i = 0; i < cmd->evt_buf_sz; i++) { - A_PRINTF_LOG("0x%02x ", cmd->buf[i]); - if((i % 10) == 0) { - A_PRINTF_LOG("\n"); - } - } - A_PRINTF_LOG("\n"); - A_PRINTF_LOG("==================================\n"); - } -} - -void -ar6000_neighborReport_event(struct ar6_softc *ar, int numAps, WMI_NEIGHBOR_INFO *info) -{ -#if WIRELESS_EXT >= 18 - struct iw_pmkid_cand *pmkcand; -#else /* WIRELESS_EXT >= 18 */ - static const char *tag = "PRE-AUTH"; - char buf[128]; -#endif /* WIRELESS_EXT >= 18 */ - - union iwreq_data wrqu; - int i; - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,("AR6000 Neighbor Report Event\n")); - for (i=0; i < numAps; info++, i++) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,("bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", - info->bssid[0], info->bssid[1], info->bssid[2], - info->bssid[3], info->bssid[4], info->bssid[5])); - if (info->bssFlags & WMI_PREAUTH_CAPABLE_BSS) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,("preauth-cap")); - } - if (info->bssFlags & WMI_PMKID_VALID_BSS) { - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,(" pmkid-valid\n")); - continue; /* we skip bss if the pmkid is already valid */ - } - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,("\n")); - A_MEMZERO(&wrqu, sizeof(wrqu)); -#if WIRELESS_EXT >= 18 - pmkcand = A_MALLOC_NOWAIT(sizeof(struct iw_pmkid_cand)); - A_MEMZERO(pmkcand, sizeof(struct iw_pmkid_cand)); - pmkcand->index = i; - pmkcand->flags = info->bssFlags; - memcpy(pmkcand->bssid.sa_data, info->bssid, ATH_MAC_LEN); - wrqu.data.length = sizeof(struct iw_pmkid_cand); - wireless_send_event(ar->arNetDev, IWEVPMKIDCAND, &wrqu, (char *)pmkcand); - kfree(pmkcand); -#else /* WIRELESS_EXT >= 18 */ - snprintf(buf, sizeof(buf), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", - tag, - info->bssid[0], info->bssid[1], info->bssid[2], - info->bssid[3], info->bssid[4], info->bssid[5], - i, info->bssFlags); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); -#endif /* WIRELESS_EXT >= 18 */ - } -} - -void -ar6000_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast) -{ - static const char *tag = "MLME-MICHAELMICFAILURE.indication"; - char buf[128]; - union iwreq_data wrqu; - - /* - * For AP case, keyid will have aid of STA which sent pkt with - * MIC error. Use this aid to get MAC & send it to hostapd. - */ - if (ar->arNetworkType == AP_NETWORK) { - sta_t *s = ieee80211_find_conn_for_aid(ar, (keyid >> 2)); - if(!s){ - A_PRINTF("AP TKIP MIC error received from Invalid aid / STA not found =%d\n", keyid); - return; - } - A_PRINTF("AP TKIP MIC error received from aid=%d\n", keyid); - snprintf(buf,sizeof(buf), "%s addr=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", - tag, s->mac[0],s->mac[1],s->mac[2],s->mac[3],s->mac[4],s->mac[5]); - } else { - - ar6k_cfg80211_tkip_micerr_event(ar, keyid, ismcast); - - A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n", - keyid & 0x3, ismcast ? "multi": "uni"); - snprintf(buf, sizeof(buf), "%s(keyid=%d %sicast)", tag, keyid & 0x3, - ismcast ? "mult" : "un"); - } - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); -} - -void -ar6000_scanComplete_event(struct ar6_softc *ar, int status) -{ - - ar6k_cfg80211_scanComplete_event(ar, status); - - if (!ar->arUserBssFilter) { - wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0); - } - if (ar->scan_triggered) { - if (status== 0) { - union iwreq_data wrqu; - A_MEMZERO(&wrqu, sizeof(wrqu)); - wireless_send_event(ar->arNetDev, SIOCGIWSCAN, &wrqu, NULL); - } - ar->scan_triggered = 0; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,( "AR6000 scan complete: %d\n", status)); -} - -void -ar6000_targetStats_event(struct ar6_softc *ar, u8 *ptr, u32 len) -{ - u8 ac; - - if(ar->arNetworkType == AP_NETWORK) { - WMI_AP_MODE_STAT *p = (WMI_AP_MODE_STAT *)ptr; - WMI_AP_MODE_STAT *ap = &ar->arAPStats; - - if (len < sizeof(*p)) { - return; - } - - for(ac=0;acsta[ac].tx_bytes += p->sta[ac].tx_bytes; - ap->sta[ac].tx_pkts += p->sta[ac].tx_pkts; - ap->sta[ac].tx_error += p->sta[ac].tx_error; - ap->sta[ac].tx_discard += p->sta[ac].tx_discard; - ap->sta[ac].rx_bytes += p->sta[ac].rx_bytes; - ap->sta[ac].rx_pkts += p->sta[ac].rx_pkts; - ap->sta[ac].rx_error += p->sta[ac].rx_error; - ap->sta[ac].rx_discard += p->sta[ac].rx_discard; - } - - } else { - WMI_TARGET_STATS *pTarget = (WMI_TARGET_STATS *)ptr; - TARGET_STATS *pStats = &ar->arTargetStats; - - if (len < sizeof(*pTarget)) { - return; - } - - // Update the RSSI of the connected bss. - if (ar->arConnected) { - bss_t *pConnBss = NULL; - - pConnBss = wmi_find_node(ar->arWmi,ar->arBssid); - if (pConnBss) - { - pConnBss->ni_rssi = pTarget->cservStats.cs_aveBeacon_rssi; - pConnBss->ni_snr = pTarget->cservStats.cs_aveBeacon_snr; - wmi_node_return(ar->arWmi, pConnBss); - } - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR6000 updating target stats\n")); - pStats->tx_packets += pTarget->txrxStats.tx_stats.tx_packets; - pStats->tx_bytes += pTarget->txrxStats.tx_stats.tx_bytes; - pStats->tx_unicast_pkts += pTarget->txrxStats.tx_stats.tx_unicast_pkts; - pStats->tx_unicast_bytes += pTarget->txrxStats.tx_stats.tx_unicast_bytes; - pStats->tx_multicast_pkts += pTarget->txrxStats.tx_stats.tx_multicast_pkts; - pStats->tx_multicast_bytes += pTarget->txrxStats.tx_stats.tx_multicast_bytes; - pStats->tx_broadcast_pkts += pTarget->txrxStats.tx_stats.tx_broadcast_pkts; - pStats->tx_broadcast_bytes += pTarget->txrxStats.tx_stats.tx_broadcast_bytes; - pStats->tx_rts_success_cnt += pTarget->txrxStats.tx_stats.tx_rts_success_cnt; - for(ac = 0; ac < WMM_NUM_AC; ac++) - pStats->tx_packet_per_ac[ac] += pTarget->txrxStats.tx_stats.tx_packet_per_ac[ac]; - pStats->tx_errors += pTarget->txrxStats.tx_stats.tx_errors; - pStats->tx_failed_cnt += pTarget->txrxStats.tx_stats.tx_failed_cnt; - pStats->tx_retry_cnt += pTarget->txrxStats.tx_stats.tx_retry_cnt; - pStats->tx_mult_retry_cnt += pTarget->txrxStats.tx_stats.tx_mult_retry_cnt; - pStats->tx_rts_fail_cnt += pTarget->txrxStats.tx_stats.tx_rts_fail_cnt; - pStats->tx_unicast_rate = wmi_get_rate(pTarget->txrxStats.tx_stats.tx_unicast_rate); - - pStats->rx_packets += pTarget->txrxStats.rx_stats.rx_packets; - pStats->rx_bytes += pTarget->txrxStats.rx_stats.rx_bytes; - pStats->rx_unicast_pkts += pTarget->txrxStats.rx_stats.rx_unicast_pkts; - pStats->rx_unicast_bytes += pTarget->txrxStats.rx_stats.rx_unicast_bytes; - pStats->rx_multicast_pkts += pTarget->txrxStats.rx_stats.rx_multicast_pkts; - pStats->rx_multicast_bytes += pTarget->txrxStats.rx_stats.rx_multicast_bytes; - pStats->rx_broadcast_pkts += pTarget->txrxStats.rx_stats.rx_broadcast_pkts; - pStats->rx_broadcast_bytes += pTarget->txrxStats.rx_stats.rx_broadcast_bytes; - pStats->rx_fragment_pkt += pTarget->txrxStats.rx_stats.rx_fragment_pkt; - pStats->rx_errors += pTarget->txrxStats.rx_stats.rx_errors; - pStats->rx_crcerr += pTarget->txrxStats.rx_stats.rx_crcerr; - pStats->rx_key_cache_miss += pTarget->txrxStats.rx_stats.rx_key_cache_miss; - pStats->rx_decrypt_err += pTarget->txrxStats.rx_stats.rx_decrypt_err; - pStats->rx_duplicate_frames += pTarget->txrxStats.rx_stats.rx_duplicate_frames; - pStats->rx_unicast_rate = wmi_get_rate(pTarget->txrxStats.rx_stats.rx_unicast_rate); - - - pStats->tkip_local_mic_failure - += pTarget->txrxStats.tkipCcmpStats.tkip_local_mic_failure; - pStats->tkip_counter_measures_invoked - += pTarget->txrxStats.tkipCcmpStats.tkip_counter_measures_invoked; - pStats->tkip_replays += pTarget->txrxStats.tkipCcmpStats.tkip_replays; - pStats->tkip_format_errors += pTarget->txrxStats.tkipCcmpStats.tkip_format_errors; - pStats->ccmp_format_errors += pTarget->txrxStats.tkipCcmpStats.ccmp_format_errors; - pStats->ccmp_replays += pTarget->txrxStats.tkipCcmpStats.ccmp_replays; - - pStats->power_save_failure_cnt += pTarget->pmStats.power_save_failure_cnt; - pStats->noise_floor_calibation = pTarget->noise_floor_calibation; - - pStats->cs_bmiss_cnt += pTarget->cservStats.cs_bmiss_cnt; - pStats->cs_lowRssi_cnt += pTarget->cservStats.cs_lowRssi_cnt; - pStats->cs_connect_cnt += pTarget->cservStats.cs_connect_cnt; - pStats->cs_disconnect_cnt += pTarget->cservStats.cs_disconnect_cnt; - pStats->cs_aveBeacon_snr = pTarget->cservStats.cs_aveBeacon_snr; - pStats->cs_aveBeacon_rssi = pTarget->cservStats.cs_aveBeacon_rssi; - - if (enablerssicompensation) { - pStats->cs_aveBeacon_rssi = - rssi_compensation_calc(ar, pStats->cs_aveBeacon_rssi); - } - pStats->cs_lastRoam_msec = pTarget->cservStats.cs_lastRoam_msec; - pStats->cs_snr = pTarget->cservStats.cs_snr; - pStats->cs_rssi = pTarget->cservStats.cs_rssi; - - pStats->lq_val = pTarget->lqVal; - - pStats->wow_num_pkts_dropped += pTarget->wowStats.wow_num_pkts_dropped; - pStats->wow_num_host_pkt_wakeups += pTarget->wowStats.wow_num_host_pkt_wakeups; - pStats->wow_num_host_event_wakeups += pTarget->wowStats.wow_num_host_event_wakeups; - pStats->wow_num_events_discarded += pTarget->wowStats.wow_num_events_discarded; - pStats->arp_received += pTarget->arpStats.arp_received; - pStats->arp_matched += pTarget->arpStats.arp_matched; - pStats->arp_replied += pTarget->arpStats.arp_replied; - - if (ar->statsUpdatePending) { - ar->statsUpdatePending = false; - wake_up(&arEvent); - } - } -} - -void -ar6000_rssiThreshold_event(struct ar6_softc *ar, WMI_RSSI_THRESHOLD_VAL newThreshold, s16 rssi) -{ - USER_RSSI_THOLD userRssiThold; - - rssi = rssi + SIGNAL_QUALITY_NOISE_FLOOR; - - if (enablerssicompensation) { - rssi = rssi_compensation_calc(ar, rssi); - } - - /* Send an event to the app */ - userRssiThold.tag = ar->rssi_map[newThreshold].tag; - userRssiThold.rssi = rssi; - A_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold, - userRssiThold.tag, userRssiThold.rssi); -} - - -void -ar6000_hbChallengeResp_event(struct ar6_softc *ar, u32 cookie, u32 source) -{ - if (source != APP_HB_CHALLENGE) { - /* This would ignore the replys that come in after their due time */ - if (cookie == ar->arHBChallengeResp.seqNum) { - ar->arHBChallengeResp.outstanding = false; - } - } -} - - -void -ar6000_reportError_event(struct ar6_softc *ar, WMI_TARGET_ERROR_VAL errorVal) -{ - static const char * const errString[] = { - [WMI_TARGET_PM_ERR_FAIL] "WMI_TARGET_PM_ERR_FAIL", - [WMI_TARGET_KEY_NOT_FOUND] "WMI_TARGET_KEY_NOT_FOUND", - [WMI_TARGET_DECRYPTION_ERR] "WMI_TARGET_DECRYPTION_ERR", - [WMI_TARGET_BMISS] "WMI_TARGET_BMISS", - [WMI_PSDISABLE_NODE_JOIN] "WMI_PSDISABLE_NODE_JOIN" - }; - - A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal); - - /* One error is reported at a time, and errorval is a bitmask */ - if(errorVal & (errorVal - 1)) - return; - - A_PRINTF("AR6000 Error type = "); - switch(errorVal) - { - case WMI_TARGET_PM_ERR_FAIL: - case WMI_TARGET_KEY_NOT_FOUND: - case WMI_TARGET_DECRYPTION_ERR: - case WMI_TARGET_BMISS: - case WMI_PSDISABLE_NODE_JOIN: - A_PRINTF("%s\n", errString[errorVal]); - break; - default: - A_PRINTF("INVALID\n"); - break; - } - -} - - -void -ar6000_cac_event(struct ar6_softc *ar, u8 ac, u8 cacIndication, - u8 statusCode, u8 *tspecSuggestion) -{ - WMM_TSPEC_IE *tspecIe; - - /* - * This is the TSPEC IE suggestion from AP. - * Suggestion provided by AP under some error - * cases, could be helpful for the host app. - * Check documentation. - */ - tspecIe = (WMM_TSPEC_IE *)tspecSuggestion; - - /* - * What do we do, if we get TSPEC rejection? One thought - * that comes to mind is implictly delete the pstream... - */ - A_PRINTF("AR6000 CAC notification. " - "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n", - ac, cacIndication, statusCode); -} - -void -ar6000_channel_change_event(struct ar6_softc *ar, u16 oldChannel, - u16 newChannel) -{ - A_PRINTF("Channel Change notification\nOld Channel: %d, New Channel: %d\n", - oldChannel, newChannel); -} - -#define AR6000_PRINT_BSSID(_pBss) do { \ - A_PRINTF("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",\ - (_pBss)[0],(_pBss)[1],(_pBss)[2],(_pBss)[3],\ - (_pBss)[4],(_pBss)[5]); \ -} while(0) - -void -ar6000_roam_tbl_event(struct ar6_softc *ar, WMI_TARGET_ROAM_TBL *pTbl) -{ - u8 i; - - A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n", - pTbl->numEntries, pTbl->roamMode); - for (i= 0; i < pTbl->numEntries; i++) { - A_PRINTF("[%d]bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", i, - pTbl->bssRoamInfo[i].bssid[0], pTbl->bssRoamInfo[i].bssid[1], - pTbl->bssRoamInfo[i].bssid[2], - pTbl->bssRoamInfo[i].bssid[3], - pTbl->bssRoamInfo[i].bssid[4], - pTbl->bssRoamInfo[i].bssid[5]); - A_PRINTF("RSSI %d RSSIDT %d LAST RSSI %d UTIL %d ROAM_UTIL %d" - " BIAS %d\n", - pTbl->bssRoamInfo[i].rssi, - pTbl->bssRoamInfo[i].rssidt, - pTbl->bssRoamInfo[i].last_rssi, - pTbl->bssRoamInfo[i].util, - pTbl->bssRoamInfo[i].roam_util, - pTbl->bssRoamInfo[i].bias); - } -} - -void -ar6000_wow_list_event(struct ar6_softc *ar, u8 num_filters, WMI_GET_WOW_LIST_REPLY *wow_reply) -{ - u8 i,j; - - /*Each event now contains exactly one filter, see bug 26613*/ - A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply->this_filter_num, wow_reply->num_filters); - A_PRINTF("wow mode = %s host mode = %s\n", - (wow_reply->wow_mode == 0? "disabled":"enabled"), - (wow_reply->host_mode == 1 ? "awake":"asleep")); - - - /*If there are no patterns, the reply will only contain generic - WoW information. Pattern information will exist only if there are - patterns present. Bug 26716*/ - - /* If this event contains pattern information, display it*/ - if (wow_reply->this_filter_num) { - i=0; - A_PRINTF("id=%d size=%d offset=%d\n", - wow_reply->wow_filters[i].wow_filter_id, - wow_reply->wow_filters[i].wow_filter_size, - wow_reply->wow_filters[i].wow_filter_offset); - A_PRINTF("wow pattern = "); - for (j=0; j< wow_reply->wow_filters[i].wow_filter_size; j++) { - A_PRINTF("%2.2x",wow_reply->wow_filters[i].wow_filter_pattern[j]); - } - - A_PRINTF("\nwow mask = "); - for (j=0; j< wow_reply->wow_filters[i].wow_filter_size; j++) { - A_PRINTF("%2.2x",wow_reply->wow_filters[i].wow_filter_mask[j]); - } - A_PRINTF("\n"); - } -} - -/* - * Report the Roaming related data collected on the target - */ -void -ar6000_display_roam_time(WMI_TARGET_ROAM_TIME *p) -{ - A_PRINTF("Disconnect Data : BSSID: "); - AR6000_PRINT_BSSID(p->disassoc_bssid); - A_PRINTF(" RSSI %d DISASSOC Time %d NO_TXRX_TIME %d\n", - p->disassoc_bss_rssi,p->disassoc_time, - p->no_txrx_time); - A_PRINTF("Connect Data: BSSID: "); - AR6000_PRINT_BSSID(p->assoc_bssid); - A_PRINTF(" RSSI %d ASSOC Time %d TXRX_TIME %d\n", - p->assoc_bss_rssi,p->assoc_time, - p->allow_txrx_time); -} - -void -ar6000_roam_data_event(struct ar6_softc *ar, WMI_TARGET_ROAM_DATA *p) -{ - switch (p->roamDataType) { - case ROAM_DATA_TIME: - ar6000_display_roam_time(&p->u.roamTime); - break; - default: - break; - } -} - -void -ar6000_bssInfo_event_rx(struct ar6_softc *ar, u8 *datap, int len) -{ - struct sk_buff *skb; - WMI_BSS_INFO_HDR *bih = (WMI_BSS_INFO_HDR *)datap; - - - if (!ar->arMgmtFilter) { - return; - } - if (((ar->arMgmtFilter & IEEE80211_FILTER_TYPE_BEACON) && - (bih->frameType != BEACON_FTYPE)) || - ((ar->arMgmtFilter & IEEE80211_FILTER_TYPE_PROBE_RESP) && - (bih->frameType != PROBERESP_FTYPE))) - { - return; - } - - if ((skb = A_NETBUF_ALLOC_RAW(len)) != NULL) { - - A_NETBUF_PUT(skb, len); - memcpy(A_NETBUF_DATA(skb), datap, len); - skb->dev = ar->arNetDev; - memcpy(skb_mac_header(skb), A_NETBUF_DATA(skb), 6); - skb->ip_summed = CHECKSUM_NONE; - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = __constant_htons(0x0019); - netif_rx(skb); - } -} - -u32 wmiSendCmdNum; - -int -ar6000_control_tx(void *devt, void *osbuf, HTC_ENDPOINT_ID eid) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - int status = 0; - struct ar_cookie *cookie = NULL; - int i; -#ifdef CONFIG_PM - if (ar->arWowState != WLAN_WOW_STATE_NONE) { - A_NETBUF_FREE(osbuf); - return A_EACCES; - } -#endif /* CONFIG_PM */ - /* take lock to protect ar6000_alloc_cookie() */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - - do { - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("ar_contrstatus = ol_tx: skb=0x%lx, len=0x%x eid =%d\n", - (unsigned long)osbuf, A_NETBUF_LEN(osbuf), eid)); - - if (ar->arWMIControlEpFull && (eid == ar->arControlEp)) { - /* control endpoint is full, don't allocate resources, we - * are just going to drop this packet */ - cookie = NULL; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" WMI Control EP full, dropping packet : 0x%lX, len:%d \n", - (unsigned long)osbuf, A_NETBUF_LEN(osbuf))); - } else { - cookie = ar6000_alloc_cookie(ar); - } - - if (cookie == NULL) { - status = A_NO_MEMORY; - break; - } - - if(logWmiRawMsgs) { - A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum); - for(i = 0; i < a_netbuf_to_len(osbuf); i++) - A_PRINTF("%x ", ((u8 *)a_netbuf_to_data(osbuf))[i]); - A_PRINTF("\n"); - } - - wmiSendCmdNum++; - - } while (false); - - if (cookie != NULL) { - /* got a structure to send it out on */ - ar->arTxPending[eid]++; - - if (eid != ar->arControlEp) { - ar->arTotalTxDataPending++; - } - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (cookie != NULL) { - cookie->arc_bp[0] = (unsigned long)osbuf; - cookie->arc_bp[1] = 0; - SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt, - cookie, - A_NETBUF_DATA(osbuf), - A_NETBUF_LEN(osbuf), - eid, - AR6K_CONTROL_PKT_TAG); - /* this interface is asynchronous, if there is an error, cleanup will happen in the - * TX completion callback */ - HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt); - status = 0; - } - - if (status) { - A_NETBUF_FREE(osbuf); - } - return status; -} - -/* indicate tx activity or inactivity on a WMI stream */ -void ar6000_indicate_tx_activity(void *devt, u8 TrafficClass, bool Active) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - HTC_ENDPOINT_ID eid ; - int i; - - if (ar->arWmiEnabled) { - eid = arAc2EndpointID(ar, TrafficClass); - - AR6000_SPIN_LOCK(&ar->arLock, 0); - - ar->arAcStreamActive[TrafficClass] = Active; - - if (Active) { - /* when a stream goes active, keep track of the active stream with the highest priority */ - - if (ar->arAcStreamPriMap[TrafficClass] > ar->arHiAcStreamActivePri) { - /* set the new highest active priority */ - ar->arHiAcStreamActivePri = ar->arAcStreamPriMap[TrafficClass]; - } - - } else { - /* when a stream goes inactive, we may have to search for the next active stream - * that is the highest priority */ - - if (ar->arHiAcStreamActivePri == ar->arAcStreamPriMap[TrafficClass]) { - - /* the highest priority stream just went inactive */ - - /* reset and search for the "next" highest "active" priority stream */ - ar->arHiAcStreamActivePri = 0; - for (i = 0; i < WMM_NUM_AC; i++) { - if (ar->arAcStreamActive[i]) { - if (ar->arAcStreamPriMap[i] > ar->arHiAcStreamActivePri) { - /* set the new highest active priority */ - ar->arHiAcStreamActivePri = ar->arAcStreamPriMap[i]; - } - } - } - } - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - } else { - /* for mbox ping testing, the traffic class is mapped directly as a stream ID, - * see handling of AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE in ioctl.c - * convert the stream ID to a endpoint */ - eid = arAc2EndpointID(ar, TrafficClass); - } - - /* notify HTC, this may cause credit distribution changes */ - - HTCIndicateActivityChange(ar->arHtcTarget, - eid, - Active); - -} - -void -ar6000_btcoex_config_event(struct ar6_softc *ar, u8 *ptr, u32 len) -{ - - WMI_BTCOEX_CONFIG_EVENT *pBtcoexConfig = (WMI_BTCOEX_CONFIG_EVENT *)ptr; - WMI_BTCOEX_CONFIG_EVENT *pArbtcoexConfig =&ar->arBtcoexConfig; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR6000 BTCOEX CONFIG EVENT \n")); - - A_PRINTF("received config event\n"); - pArbtcoexConfig->btProfileType = pBtcoexConfig->btProfileType; - pArbtcoexConfig->linkId = pBtcoexConfig->linkId; - - switch (pBtcoexConfig->btProfileType) { - case WMI_BTCOEX_BT_PROFILE_SCO: - memcpy(&pArbtcoexConfig->info.scoConfigCmd, &pBtcoexConfig->info.scoConfigCmd, - sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD)); - break; - case WMI_BTCOEX_BT_PROFILE_A2DP: - memcpy(&pArbtcoexConfig->info.a2dpConfigCmd, &pBtcoexConfig->info.a2dpConfigCmd, - sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD)); - break; - case WMI_BTCOEX_BT_PROFILE_ACLCOEX: - memcpy(&pArbtcoexConfig->info.aclcoexConfig, &pBtcoexConfig->info.aclcoexConfig, - sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD)); - break; - case WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE: - memcpy(&pArbtcoexConfig->info.btinquiryPageConfigCmd, &pBtcoexConfig->info.btinquiryPageConfigCmd, - sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD)); - break; - } - if (ar->statsUpdatePending) { - ar->statsUpdatePending = false; - wake_up(&arEvent); - } -} - -void -ar6000_btcoex_stats_event(struct ar6_softc *ar, u8 *ptr, u32 len) -{ - WMI_BTCOEX_STATS_EVENT *pBtcoexStats = (WMI_BTCOEX_STATS_EVENT *)ptr; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR6000 BTCOEX CONFIG EVENT \n")); - - memcpy(&ar->arBtcoexStats, pBtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT)); - - if (ar->statsUpdatePending) { - ar->statsUpdatePending = false; - wake_up(&arEvent); - } - -} -module_init(ar6000_init_module); -module_exit(ar6000_cleanup_module); - -/* Init cookie queue */ -static void -ar6000_cookie_init(struct ar6_softc *ar) -{ - u32 i; - - ar->arCookieList = NULL; - ar->arCookieCount = 0; - - A_MEMZERO(s_ar_cookie_mem, sizeof(s_ar_cookie_mem)); - - for (i = 0; i < MAX_COOKIE_NUM; i++) { - ar6000_free_cookie(ar, &s_ar_cookie_mem[i]); - } -} - -/* cleanup cookie queue */ -static void -ar6000_cookie_cleanup(struct ar6_softc *ar) -{ - /* It is gone .... */ - ar->arCookieList = NULL; - ar->arCookieCount = 0; -} - -/* Init cookie queue */ -static void -ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie) -{ - /* Insert first */ - A_ASSERT(ar != NULL); - A_ASSERT(cookie != NULL); - - cookie->arc_list_next = ar->arCookieList; - ar->arCookieList = cookie; - ar->arCookieCount++; -} - -/* cleanup cookie queue */ -static struct ar_cookie * -ar6000_alloc_cookie(struct ar6_softc *ar) -{ - struct ar_cookie *cookie; - - cookie = ar->arCookieList; - if(cookie != NULL) - { - ar->arCookieList = cookie->arc_list_next; - ar->arCookieCount--; - } - - return cookie; -} - -void -ar6000_tx_retry_err_event(void *devt) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Tx retries reach maximum!\n")); -} - -void -ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, u8 snr) -{ - WMI_SNR_THRESHOLD_EVENT event; - - event.range = newThreshold; - event.snr = snr; -} - -void -ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL newThreshold, u8 lq) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("lq threshold range %d, lq %d\n", newThreshold, lq)); -} - - - -u32 a_copy_to_user(void *to, const void *from, u32 n) -{ - return(copy_to_user(to, from, n)); -} - -u32 a_copy_from_user(void *to, const void *from, u32 n) -{ - return(copy_from_user(to, from, n)); -} - - -int -ar6000_get_driver_cfg(struct net_device *dev, - u16 cfgParam, - void *result) -{ - - int ret = 0; - - switch(cfgParam) - { - case AR6000_DRIVER_CFG_GET_WLANNODECACHING: - *((u32 *)result) = wlanNodeCaching; - break; - case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS: - *((u32 *)result) = logWmiRawMsgs; - break; - default: - ret = EINVAL; - break; - } - - return ret; -} - -void -ar6000_keepalive_rx(void *devt, u8 configured) -{ - struct ar6_softc *ar = (struct ar6_softc *)devt; - - ar->arKeepaliveConfigured = configured; - wake_up(&arEvent); -} - -void -ar6000_pmkid_list_event(void *devt, u8 numPMKID, WMI_PMKID *pmkidList, - u8 *bssidList) -{ - u8 i, j; - - A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID); - - for (i = 0; i < numPMKID; i++) { - A_PRINTF("\nBSSID %d ", i); - for (j = 0; j < ATH_MAC_LEN; j++) { - A_PRINTF("%2.2x", bssidList[j]); - } - bssidList += (ATH_MAC_LEN + WMI_PMKID_LEN); - A_PRINTF("\nPMKID %d ", i); - for (j = 0; j < WMI_PMKID_LEN; j++) { - A_PRINTF("%2.2x", pmkidList->pmkid[j]); - } - pmkidList = (WMI_PMKID *)((u8 *)pmkidList + ATH_MAC_LEN + - WMI_PMKID_LEN); - } -} - -void ar6000_pspoll_event(struct ar6_softc *ar,u8 aid) -{ - sta_t *conn=NULL; - bool isPsqEmpty = false; - - conn = ieee80211_find_conn_for_aid(ar, aid); - - /* If the PS q for this STA is not empty, dequeue and send a pkt from - * the head of the q. Also update the More data bit in the WMI_DATA_HDR - * if there are more pkts for this STA in the PS q. If there are no more - * pkts for this STA, update the PVB for this STA. - */ - A_MUTEX_LOCK(&conn->psqLock); - isPsqEmpty = A_NETBUF_QUEUE_EMPTY(&conn->psq); - A_MUTEX_UNLOCK(&conn->psqLock); - - if (isPsqEmpty) { - /* TODO:No buffered pkts for this STA. Send out a NULL data frame */ - } else { - struct sk_buff *skb = NULL; - - A_MUTEX_LOCK(&conn->psqLock); - skb = A_NETBUF_DEQUEUE(&conn->psq); - A_MUTEX_UNLOCK(&conn->psqLock); - /* Set the STA flag to PSPolled, so that the frame will go out */ - STA_SET_PS_POLLED(conn); - ar6000_data_tx(skb, ar->arNetDev); - STA_CLR_PS_POLLED(conn); - - /* Clear the PVB for this STA if the queue has become empty */ - A_MUTEX_LOCK(&conn->psqLock); - isPsqEmpty = A_NETBUF_QUEUE_EMPTY(&conn->psq); - A_MUTEX_UNLOCK(&conn->psqLock); - - if (isPsqEmpty) { - wmi_set_pvb_cmd(ar->arWmi, conn->aid, 0); - } - } -} - -void ar6000_dtimexpiry_event(struct ar6_softc *ar) -{ - bool isMcastQueued = false; - struct sk_buff *skb = NULL; - - /* If there are no associated STAs, ignore the DTIM expiry event. - * There can be potential race conditions where the last associated - * STA may disconnect & before the host could clear the 'Indicate DTIM' - * request to the firmware, the firmware would have just indicated a DTIM - * expiry event. The race is between 'clear DTIM expiry cmd' going - * from the host to the firmware & the DTIM expiry event happening from - * the firmware to the host. - */ - if (ar->sta_list_index == 0) { - return; - } - - A_MUTEX_LOCK(&ar->mcastpsqLock); - isMcastQueued = A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq); - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - - A_ASSERT(isMcastQueued == false); - - /* Flush the mcast psq to the target */ - /* Set the STA flag to DTIMExpired, so that the frame will go out */ - ar->DTIMExpired = true; - - A_MUTEX_LOCK(&ar->mcastpsqLock); - while (!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) { - skb = A_NETBUF_DEQUEUE(&ar->mcastpsq); - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - - ar6000_data_tx(skb, ar->arNetDev); - - A_MUTEX_LOCK(&ar->mcastpsqLock); - } - A_MUTEX_UNLOCK(&ar->mcastpsqLock); - - /* Reset the DTIMExpired flag back to 0 */ - ar->DTIMExpired = false; - - /* Clear the LSB of the BitMapCtl field of the TIM IE */ - wmi_set_pvb_cmd(ar->arWmi, MCAST_AID, 0); -} - -void -read_rssi_compensation_param(struct ar6_softc *ar) -{ - u8 *cust_data_ptr; - -//#define RSSICOMPENSATION_PRINT - -#ifdef RSSICOMPENSATION_PRINT - s16 i; - cust_data_ptr = ar6000_get_cust_data_buffer(ar->arTargetType); - for (i=0; i<16; i++) { - A_PRINTF("cust_data_%d = %x \n", i, *(u8 *)cust_data_ptr); - cust_data_ptr += 1; - } -#endif - - cust_data_ptr = ar6000_get_cust_data_buffer(ar->arTargetType); - - rssi_compensation_param.customerID = *(u16 *)cust_data_ptr & 0xffff; - rssi_compensation_param.enable = *(u16 *)(cust_data_ptr+2) & 0xffff; - rssi_compensation_param.bg_param_a = *(u16 *)(cust_data_ptr+4) & 0xffff; - rssi_compensation_param.bg_param_b = *(u16 *)(cust_data_ptr+6) & 0xffff; - rssi_compensation_param.a_param_a = *(u16 *)(cust_data_ptr+8) & 0xffff; - rssi_compensation_param.a_param_b = *(u16 *)(cust_data_ptr+10) &0xffff; - rssi_compensation_param.reserved = *(u32 *)(cust_data_ptr+12); - -#ifdef RSSICOMPENSATION_PRINT - A_PRINTF("customerID = 0x%x \n", rssi_compensation_param.customerID); - A_PRINTF("enable = 0x%x \n", rssi_compensation_param.enable); - A_PRINTF("bg_param_a = 0x%x and %d \n", rssi_compensation_param.bg_param_a, rssi_compensation_param.bg_param_a); - A_PRINTF("bg_param_b = 0x%x and %d \n", rssi_compensation_param.bg_param_b, rssi_compensation_param.bg_param_b); - A_PRINTF("a_param_a = 0x%x and %d \n", rssi_compensation_param.a_param_a, rssi_compensation_param.a_param_a); - A_PRINTF("a_param_b = 0x%x and %d \n", rssi_compensation_param.a_param_b, rssi_compensation_param.a_param_b); - A_PRINTF("Last 4 bytes = 0x%x \n", rssi_compensation_param.reserved); -#endif - - if (rssi_compensation_param.enable != 0x1) { - rssi_compensation_param.enable = 0; - } - - return; -} - -s32 rssi_compensation_calc_tcmd(u32 freq, s32 rssi, u32 totalPkt) -{ - - if (freq > 5000) - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11a\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before compensation = %d, totalPkt = %d\n", rssi,totalPkt)); - rssi = rssi * rssi_compensation_param.a_param_a + totalPkt * rssi_compensation_param.a_param_b; - rssi = (rssi-50) /100; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after compensation = %d\n", rssi)); - } - } - else - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11bg\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before compensation = %d, totalPkt = %d\n", rssi,totalPkt)); - rssi = rssi * rssi_compensation_param.bg_param_a + totalPkt * rssi_compensation_param.bg_param_b; - rssi = (rssi-50) /100; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after compensation = %d\n", rssi)); - } - } - - return rssi; -} - -s16 rssi_compensation_calc(struct ar6_softc *ar, s16 rssi) -{ - if (ar->arBssChannel > 5000) - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11a\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before compensation = %d\n", rssi)); - rssi = rssi * rssi_compensation_param.a_param_a + rssi_compensation_param.a_param_b; - rssi = (rssi-50) /100; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after compensation = %d\n", rssi)); - } - } - else - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11bg\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before compensation = %d\n", rssi)); - rssi = rssi * rssi_compensation_param.bg_param_a + rssi_compensation_param.bg_param_b; - rssi = (rssi-50) /100; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after compensation = %d\n", rssi)); - } - } - - return rssi; -} - -s16 rssi_compensation_reverse_calc(struct ar6_softc *ar, s16 rssi, bool Above) -{ - s16 i; - - if (ar->arBssChannel > 5000) - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11a\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before rev compensation = %d\n", rssi)); - rssi = rssi * 100; - rssi = (rssi - rssi_compensation_param.a_param_b) / rssi_compensation_param.a_param_a; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after rev compensation = %d\n", rssi)); - } - } - else - { - if (rssi_compensation_param.enable) - { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, (">>> 11bg\n")); - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi before rev compensation = %d\n", rssi)); - - if (Above) { - for (i=95; i>=0; i--) { - if (rssi <= rssi_compensation_table[i]) { - rssi = 0 - i; - break; - } - } - } else { - for (i=0; i<=95; i++) { - if (rssi >= rssi_compensation_table[i]) { - rssi = 0 - i; - break; - } - } - } - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("rssi after rev compensation = %d\n", rssi)); - } - } - - return rssi; -} - -#ifdef WAPI_ENABLE -void ap_wapi_rekey_event(struct ar6_softc *ar, u8 type, u8 *mac) -{ - union iwreq_data wrqu; - char buf[20]; - - A_MEMZERO(buf, sizeof(buf)); - - strcpy(buf, "WAPI_REKEY"); - buf[10] = type; - memcpy(&buf[11], mac, ATH_MAC_LEN); - - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.data.length = 10+1+ATH_MAC_LEN; - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); - - A_PRINTF("WAPI REKEY - %d - %02x:%02x\n", type, mac[4], mac[5]); -} -#endif - -static int -ar6000_reinstall_keys(struct ar6_softc *ar, u8 key_op_ctrl) -{ - int status = 0; - struct ieee80211req_key *uik = &ar->user_saved_keys.ucast_ik; - struct ieee80211req_key *bik = &ar->user_saved_keys.bcast_ik; - CRYPTO_TYPE keyType = ar->user_saved_keys.keyType; - - if (IEEE80211_CIPHER_CCKM_KRK != uik->ik_type) { - if (NONE_CRYPT == keyType) { - goto _reinstall_keys_out; - } - - if (uik->ik_keylen) { - status = wmi_addKey_cmd(ar->arWmi, uik->ik_keyix, - ar->user_saved_keys.keyType, PAIRWISE_USAGE, - uik->ik_keylen, (u8 *)&uik->ik_keyrsc, - uik->ik_keydata, key_op_ctrl, uik->ik_macaddr, SYNC_BEFORE_WMIFLAG); - } - - } else { - status = wmi_add_krk_cmd(ar->arWmi, uik->ik_keydata); - } - - if (IEEE80211_CIPHER_CCKM_KRK != bik->ik_type) { - if (NONE_CRYPT == keyType) { - goto _reinstall_keys_out; - } - - if (bik->ik_keylen) { - status = wmi_addKey_cmd(ar->arWmi, bik->ik_keyix, - ar->user_saved_keys.keyType, GROUP_USAGE, - bik->ik_keylen, (u8 *)&bik->ik_keyrsc, - bik->ik_keydata, key_op_ctrl, bik->ik_macaddr, NO_SYNC_WMIFLAG); - } - } else { - status = wmi_add_krk_cmd(ar->arWmi, bik->ik_keydata); - } - -_reinstall_keys_out: - ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT; - ar->user_key_ctrl = 0; - - return status; -} - - -void -ar6000_dset_open_req( - void *context, - u32 id, - u32 targHandle, - u32 targReplyFn, - u32 targReplyArg) -{ -} - -void -ar6000_dset_close( - void *context, - u32 access_cookie) -{ - return; -} - -void -ar6000_dset_data_req( - void *context, - u32 accessCookie, - u32 offset, - u32 length, - u32 targBuf, - u32 targReplyFn, - u32 targReplyArg) -{ -} - -int -ar6000_ap_mode_profile_commit(struct ar6_softc *ar) -{ - WMI_CONNECT_CMD p; - unsigned long flags; - - /* No change in AP's profile configuration */ - if(ar->ap_profile_flag==0) { - A_PRINTF("COMMIT: No change in profile!!!\n"); - return -ENODATA; - } - - if(!ar->arSsidLen) { - A_PRINTF("SSID not set!!!\n"); - return -ECHRNG; - } - - switch(ar->arAuthMode) { - case NONE_AUTH: - if((ar->arPairwiseCrypto != NONE_CRYPT) && -#ifdef WAPI_ENABLE - (ar->arPairwiseCrypto != WAPI_CRYPT) && -#endif - (ar->arPairwiseCrypto != WEP_CRYPT)) { - A_PRINTF("Cipher not supported in AP mode Open auth\n"); - return -EOPNOTSUPP; - } - break; - case WPA_PSK_AUTH: - case WPA2_PSK_AUTH: - case (WPA_PSK_AUTH|WPA2_PSK_AUTH): - break; - default: - A_PRINTF("This key mgmt type not supported in AP mode\n"); - return -EOPNOTSUPP; - } - - /* Update the arNetworkType */ - ar->arNetworkType = ar->arNextMode; - - A_MEMZERO(&p,sizeof(p)); - p.ssidLength = ar->arSsidLen; - memcpy(p.ssid,ar->arSsid,p.ssidLength); - p.channel = ar->arChannelHint; - p.networkType = ar->arNetworkType; - - p.dot11AuthMode = ar->arDot11AuthMode; - p.authMode = ar->arAuthMode; - p.pairwiseCryptoType = ar->arPairwiseCrypto; - p.pairwiseCryptoLen = ar->arPairwiseCryptoLen; - p.groupCryptoType = ar->arGroupCrypto; - p.groupCryptoLen = ar->arGroupCryptoLen; - p.ctrl_flags = ar->arConnectCtrlFlags; - - wmi_ap_profile_commit(ar->arWmi, &p); - spin_lock_irqsave(&ar->arLock, flags); - ar->arConnected = true; - netif_carrier_on(ar->arNetDev); - spin_unlock_irqrestore(&ar->arLock, flags); - ar->ap_profile_flag = 0; - return 0; -} - -int -ar6000_connect_to_ap(struct ar6_softc *ar) -{ - /* The ssid length check prevents second "essid off" from the user, - to be treated as a connect cmd. The second "essid off" is ignored. - */ - if((ar->arWmiReady == true) && (ar->arSsidLen > 0) && ar->arNetworkType!=AP_NETWORK) - { - int status; - if((ADHOC_NETWORK != ar->arNetworkType) && - (NONE_AUTH==ar->arAuthMode) && - (WEP_CRYPT==ar->arPairwiseCrypto)) { - ar6000_install_static_wep_keys(ar); - } - - if (!ar->arUserBssFilter) { - if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != 0) { - return -EIO; - } - } -#ifdef WAPI_ENABLE - if (ar->arWapiEnable) { - ar->arPairwiseCrypto = WAPI_CRYPT; - ar->arPairwiseCryptoLen = 0; - ar->arGroupCrypto = WAPI_CRYPT; - ar->arGroupCryptoLen = 0; - ar->arAuthMode = NONE_AUTH; - ar->arConnectCtrlFlags |= CONNECT_IGNORE_WPAx_GROUP_CIPHER; - } -#endif - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("Connect called with authmode %d dot11 auth %d"\ - " PW crypto %d PW crypto Len %d GRP crypto %d"\ - " GRP crypto Len %d\n", - ar->arAuthMode, ar->arDot11AuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto, ar->arGroupCryptoLen)); - reconnect_flag = 0; - /* Set the listen interval into 1000TUs or more. This value will be indicated to Ap in the conn. - later set it back locally at the STA to 100/1000 TUs depending on the power mode */ - if ((ar->arNetworkType == INFRA_NETWORK)) { - wmi_listeninterval_cmd(ar->arWmi, max(ar->arListenIntervalT, (u16)A_MAX_WOW_LISTEN_INTERVAL), 0); - } - status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType, - ar->arDot11AuthMode, ar->arAuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto,ar->arGroupCryptoLen, - ar->arSsidLen, ar->arSsid, - ar->arReqBssid, ar->arChannelHint, - ar->arConnectCtrlFlags); - if (status) { - wmi_listeninterval_cmd(ar->arWmi, ar->arListenIntervalT, ar->arListenIntervalB); - if (!ar->arUserBssFilter) { - wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0); - } - return status; - } - - if ((!(ar->arConnectCtrlFlags & CONNECT_DO_WPA_OFFLOAD)) && - ((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode))) - { - A_TIMEOUT_MS(&ar->disconnect_timer, A_DISCONNECT_TIMER_INTERVAL, 0); - } - - ar->arConnectCtrlFlags &= ~CONNECT_DO_WPA_OFFLOAD; - - ar->arConnectPending = true; - return status; - } - return A_ERROR; -} - -int -ar6000_disconnect(struct ar6_softc *ar) -{ - if ((ar->arConnected == true) || (ar->arConnectPending == true)) { - wmi_disconnect_cmd(ar->arWmi); - /* - * Disconnect cmd is issued, clear connectPending. - * arConnected will be cleard in disconnect_event notification. - */ - ar->arConnectPending = false; - } - - return 0; -} - -int -ar6000_ap_mode_get_wpa_ie(struct ar6_softc *ar, struct ieee80211req_wpaie *wpaie) -{ - sta_t *conn = NULL; - conn = ieee80211_find_conn(ar, wpaie->wpa_macaddr); - - A_MEMZERO(wpaie->wpa_ie, IEEE80211_MAX_IE); - A_MEMZERO(wpaie->rsn_ie, IEEE80211_MAX_IE); - - if(conn) { - memcpy(wpaie->wpa_ie, conn->wpa_ie, IEEE80211_MAX_IE); - } - - return 0; -} - -int -is_iwioctl_allowed(u8 mode, u16 cmd) -{ - if(cmd >= SIOCSIWCOMMIT && cmd <= SIOCGIWPOWER) { - cmd -= SIOCSIWCOMMIT; - if(sioctl_filter[cmd] == 0xFF) return 0; - if(sioctl_filter[cmd] & mode) return 0; - } else if(cmd >= SIOCIWFIRSTPRIV && cmd <= (SIOCIWFIRSTPRIV+30)) { - cmd -= SIOCIWFIRSTPRIV; - if(pioctl_filter[cmd] == 0xFF) return 0; - if(pioctl_filter[cmd] & mode) return 0; - } else { - return A_ERROR; - } - return A_ENOTSUP; -} - -int -is_xioctl_allowed(u8 mode, int cmd) -{ - if(sizeof(xioctl_filter)-1 < cmd) { - A_PRINTF("Filter for this cmd=%d not defined\n",cmd); - return 0; - } - if(xioctl_filter[cmd] == 0xFF) return 0; - if(xioctl_filter[cmd] & mode) return 0; - return A_ERROR; -} - -#ifdef WAPI_ENABLE -int -ap_set_wapi_key(struct ar6_softc *ar, void *ikey) -{ - struct ieee80211req_key *ik = (struct ieee80211req_key *)ikey; - KEY_USAGE keyUsage = 0; - int status; - - if (memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN) == 0) { - keyUsage = GROUP_USAGE; - } else { - keyUsage = PAIRWISE_USAGE; - } - A_PRINTF("WAPI_KEY: Type:%d ix:%d mac:%02x:%02x len:%d\n", - keyUsage, ik->ik_keyix, ik->ik_macaddr[4], ik->ik_macaddr[5], - ik->ik_keylen); - - status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, WAPI_CRYPT, keyUsage, - ik->ik_keylen, (u8 *)&ik->ik_keyrsc, - ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr, - SYNC_BOTH_WMIFLAG); - - if (0 != status) { - return -EIO; - } - return 0; -} -#endif - -void ar6000_peer_event( - void *context, - u8 eventCode, - u8 *macAddr) -{ - u8 pos; - - for (pos=0;pos<6;pos++) - printk("%02x: ",*(macAddr+pos)); - printk("\n"); -} - -#ifdef HTC_TEST_SEND_PKTS -#define HTC_TEST_DUPLICATE 8 -static void DoHTCSendPktsTest(struct ar6_softc *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *dupskb) -{ - struct ar_cookie *cookie; - struct ar_cookie *cookieArray[HTC_TEST_DUPLICATE]; - struct sk_buff *new_skb; - int i; - int pkts = 0; - struct htc_packet_queue pktQueue; - EPPING_HEADER *eppingHdr; - - eppingHdr = A_NETBUF_DATA(dupskb); - - if (eppingHdr->Cmd_h == EPPING_CMD_NO_ECHO) { - /* skip test if this is already a tx perf test */ - return; - } - - for (i = 0; i < HTC_TEST_DUPLICATE; i++,pkts++) { - AR6000_SPIN_LOCK(&ar->arLock, 0); - cookie = ar6000_alloc_cookie(ar); - if (cookie != NULL) { - ar->arTxPending[eid]++; - ar->arTotalTxDataPending++; - } - - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - - if (NULL == cookie) { - break; - } - - new_skb = A_NETBUF_ALLOC(A_NETBUF_LEN(dupskb)); - - if (new_skb == NULL) { - AR6000_SPIN_LOCK(&ar->arLock, 0); - ar6000_free_cookie(ar,cookie); - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - break; - } - - A_NETBUF_PUT_DATA(new_skb, A_NETBUF_DATA(dupskb), A_NETBUF_LEN(dupskb)); - cookie->arc_bp[0] = (unsigned long)new_skb; - cookie->arc_bp[1] = MapNo; - SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt, - cookie, - A_NETBUF_DATA(new_skb), - A_NETBUF_LEN(new_skb), - eid, - AR6K_DATA_PKT_TAG); - - cookieArray[i] = cookie; - - { - EPPING_HEADER *pHdr = (EPPING_HEADER *)A_NETBUF_DATA(new_skb); - pHdr->Cmd_h = EPPING_CMD_NO_ECHO; /* do not echo the packet */ - } - } - - if (pkts == 0) { - return; - } - - INIT_HTC_PACKET_QUEUE(&pktQueue); - - for (i = 0; i < pkts; i++) { - HTC_PACKET_ENQUEUE(&pktQueue,&cookieArray[i]->HtcPkt); - } - - HTCSendPktsMultiple(ar->arHtcTarget, &pktQueue); - -} -#endif - -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT -/* - * Add support for adding and removing a virtual adapter for soft AP. - * Some OS requires different adapters names for station and soft AP mode. - * To support these requirement, create and destroy a netdevice instance - * when the AP mode is operational. A full fledged support for virual device - * is not implemented. Rather a virtual interface is created and is linked - * with the existing physical device instance during the operation of the - * AP mode. - */ - -int ar6000_start_ap_interface(struct ar6_softc *ar) -{ - struct ar_virtual_interface *arApDev; - - /* Change net_device to point to AP instance */ - arApDev = (struct ar_virtual_interface *)ar->arApDev; - ar->arNetDev = arApDev->arNetDev; - - return 0; -} - -int ar6000_stop_ap_interface(struct ar6_softc *ar) -{ - struct ar_virtual_interface *arApDev; - - /* Change net_device to point to sta instance */ - arApDev = (struct ar_virtual_interface *)ar->arApDev; - if (arApDev) { - ar->arNetDev = arApDev->arStaNetDev; - } - - return 0; -} - - -int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname) -{ - struct net_device *dev; - struct ar_virtual_interface *arApDev; - - dev = alloc_etherdev(sizeof(struct ar_virtual_interface)); - if (dev == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: can't alloc etherdev\n")); - return A_ERROR; - } - - ether_setup(dev); - init_netdev(dev, ap_ifname); - dev->priv_flags &= ~IFF_TX_SKB_SHARING; - - if (register_netdev(dev)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: register_netdev failed\n")); - return A_ERROR; - } - - arApDev = netdev_priv(dev); - arApDev->arDev = ar; - arApDev->arNetDev = dev; - arApDev->arStaNetDev = ar->arNetDev; - - ar->arApDev = arApDev; - arApNetDev = dev; - - /* Copy the MAC address */ - memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN); - - return 0; -} - -int ar6000_add_ap_interface(struct ar6_softc *ar, char *ap_ifname) -{ - /* Interface already added, need not proceed further */ - if (ar->arApDev != NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_add_ap_interface: interface already present \n")); - return 0; - } - - if (ar6000_create_ap_interface(ar, ap_ifname) != 0) { - return A_ERROR; - } - - A_PRINTF("Add AP interface %s \n",ap_ifname); - - return ar6000_start_ap_interface(ar); -} - -int ar6000_remove_ap_interface(struct ar6_softc *ar) -{ - if (arApNetDev) { - ar6000_stop_ap_interface(ar); - - unregister_netdev(arApNetDev); - free_netdev(apApNetDev); - - A_PRINTF("Remove AP interface\n"); - } - ar->arApDev = NULL; - arApNetDev = NULL; - - - return 0; -} -#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -EXPORT_SYMBOL(setupbtdev); -#endif diff --git a/drivers/staging/ath6kl/os/linux/ar6000_pm.c b/drivers/staging/ath6kl/os/linux/ar6000_pm.c deleted file mode 100644 index 1e0ace8b6d1..00000000000 --- a/drivers/staging/ath6kl/os/linux/ar6000_pm.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// - * - */ - -/* - * Implementation of system power management - */ - -#include "ar6000_drv.h" -#include -#include -#include "wlan_config.h" - -#define WOW_ENABLE_MAX_INTERVAL 0 -#define WOW_SET_SCAN_PARAMS 0 - -extern unsigned int wmitimeout; -extern wait_queue_head_t arEvent; - -#undef ATH_MODULE_NAME -#define ATH_MODULE_NAME pm -#define ATH_DEBUG_PM ATH_DEBUG_MAKE_MODULE_MASK(0) - -#ifdef DEBUG -static struct ath_debug_mask_description pm_debug_desc[] = { - { ATH_DEBUG_PM , "System power management"}, -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(pm, - "pm", - "System Power Management", - ATH_DEBUG_MASK_DEFAULTS | ATH_DEBUG_PM, - ATH_DEBUG_DESCRIPTION_COUNT(pm_debug_desc), - pm_debug_desc); - -#endif /* DEBUG */ - -int ar6000_exit_cut_power_state(struct ar6_softc *ar); - -#ifdef CONFIG_PM -static void ar6k_send_asleep_event_to_app(struct ar6_softc *ar, bool asleep) -{ - char buf[128]; - union iwreq_data wrqu; - - snprintf(buf, sizeof(buf), "HOST_ASLEEP=%s", asleep ? "asleep" : "awake"); - A_MEMZERO(&wrqu, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf); -} - -static void ar6000_wow_resume(struct ar6_softc *ar) -{ - if (ar->arWowState!= WLAN_WOW_STATE_NONE) { - u16 fg_start_period = (ar->scParams.fg_start_period==0) ? 1 : ar->scParams.fg_start_period; - u16 bg_period = (ar->scParams.bg_period==0) ? 60 : ar->scParams.bg_period; - WMI_SET_HOST_SLEEP_MODE_CMD hostSleepMode = {true, false}; - ar->arWowState = WLAN_WOW_STATE_NONE; - if (wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode)!= 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to setup restore host awake\n")); - } -#if WOW_SET_SCAN_PARAMS - wmi_scanparams_cmd(ar->arWmi, fg_start_period, - ar->scParams.fg_end_period, - bg_period, - ar->scParams.minact_chdwell_time, - ar->scParams.maxact_chdwell_time, - ar->scParams.pas_chdwell_time, - ar->scParams.shortScanRatio, - ar->scParams.scanCtrlFlags, - ar->scParams.max_dfsch_act_time, - ar->scParams.maxact_scan_per_ssid); -#else - (void)fg_start_period; - (void)bg_period; -#endif - - -#if WOW_ENABLE_MAX_INTERVAL /* we don't do it if the power consumption is already good enough. */ - if (wmi_listeninterval_cmd(ar->arWmi, ar->arListenIntervalT, ar->arListenIntervalB) == 0) { - } -#endif - ar6k_send_asleep_event_to_app(ar, false); - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Resume WoW successfully\n")); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("WoW does not invoked. skip resume")); - } - ar->arWlanPowerState = WLAN_POWER_STATE_ON; -} - -static void ar6000_wow_suspend(struct ar6_softc *ar) -{ -#define WOW_LIST_ID 1 - if (ar->arNetworkType != AP_NETWORK) { - /* Setup WoW for unicast & Arp request for our own IP - disable background scan. Set listen interval into 1000 TUs - Enable keepliave for 110 seconds - */ - struct in_ifaddr **ifap = NULL; - struct in_ifaddr *ifa = NULL; - struct in_device *in_dev; - u8 macMask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - int status; - WMI_ADD_WOW_PATTERN_CMD addWowCmd = { .filter = { 0 } }; - WMI_DEL_WOW_PATTERN_CMD delWowCmd; - WMI_SET_HOST_SLEEP_MODE_CMD hostSleepMode = {false, true}; - WMI_SET_WOW_MODE_CMD wowMode = { .enable_wow = true, - .hostReqDelay = 500 };/*500 ms delay*/ - - if (ar->arWowState!= WLAN_WOW_STATE_NONE) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("System already go into wow mode!\n")); - return; - } - - ar6000_TxDataCleanup(ar); /* IMPORTANT, otherwise there will be 11mA after listen interval as 1000*/ - -#if WOW_ENABLE_MAX_INTERVAL /* we don't do it if the power consumption is already good enough. */ - if (wmi_listeninterval_cmd(ar->arWmi, A_MAX_WOW_LISTEN_INTERVAL, 0) == 0) { - } -#endif - -#if WOW_SET_SCAN_PARAMS - status = wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0xFFFF, 0, 0, 0, 0, 0, 0, 0); -#endif - /* clear up our WoW pattern first */ - delWowCmd.filter_list_id = WOW_LIST_ID; - delWowCmd.filter_id = 0; - wmi_del_wow_pattern_cmd(ar->arWmi, &delWowCmd); - - /* setup unicast packet pattern for WoW */ - if (ar->arNetDev->dev_addr[1]) { - addWowCmd.filter_list_id = WOW_LIST_ID; - addWowCmd.filter_size = 6; /* MAC address */ - addWowCmd.filter_offset = 0; - status = wmi_add_wow_pattern_cmd(ar->arWmi, &addWowCmd, ar->arNetDev->dev_addr, macMask, addWowCmd.filter_size); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to add WoW pattern\n")); - } - } - /* setup ARP request for our own IP */ - if ((in_dev = __in_dev_get_rtnl(ar->arNetDev)) != NULL) { - for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; ifap = &ifa->ifa_next) { - if (!strcmp(ar->arNetDev->name, ifa->ifa_label)) { - break; /* found */ - } - } - } - if (ifa && ifa->ifa_local) { - WMI_SET_IP_CMD ipCmd; - memset(&ipCmd, 0, sizeof(ipCmd)); - ipCmd.ips[0] = ifa->ifa_local; - status = wmi_set_ip_cmd(ar->arWmi, &ipCmd); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to setup IP for ARP agent\n")); - } - } - -#ifndef ATH6K_CONFIG_OTA_MODE - wmi_powermode_cmd(ar->arWmi, REC_POWER); -#endif - - status = wmi_set_wow_mode_cmd(ar->arWmi, &wowMode); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to enable wow mode\n")); - } - ar6k_send_asleep_event_to_app(ar, true); - - status = wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to set host asleep\n")); - } - - ar->arWowState = WLAN_WOW_STATE_SUSPENDING; - if (ar->arTxPending[ar->arControlEp]) { - u32 timeleft = wait_event_interruptible_timeout(arEvent, - ar->arTxPending[ar->arControlEp] == 0, wmitimeout * HZ); - if (!timeleft || signal_pending(current)) { - /* what can I do? wow resume at once */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to setup WoW. Pending wmi control data %d\n", ar->arTxPending[ar->arControlEp])); - } - } - - status = hifWaitForPendingRecv(ar->arHifDevice); - - ar->arWowState = WLAN_WOW_STATE_SUSPENDED; - ar->arWlanPowerState = WLAN_POWER_STATE_WOW; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Not allowed to go to WOW at this moment.\n")); - } -} - -int ar6000_suspend_ev(void *context) -{ - int status = 0; - struct ar6_softc *ar = (struct ar6_softc *)context; - s16 pmmode = ar->arSuspendConfig; -wow_not_connected: - switch (pmmode) { - case WLAN_SUSPEND_WOW: - if (ar->arWmiReady && ar->arWlanState==WLAN_ENABLED && ar->arConnected) { - ar6000_wow_suspend(ar); - AR_DEBUG_PRINTF(ATH_DEBUG_PM,("%s:Suspend for wow mode %d\n", __func__, ar->arWlanPowerState)); - } else { - pmmode = ar->arWow2Config; - goto wow_not_connected; - } - break; - case WLAN_SUSPEND_CUT_PWR: - /* fall through */ - case WLAN_SUSPEND_CUT_PWR_IF_BT_OFF: - /* fall through */ - case WLAN_SUSPEND_DEEP_SLEEP: - /* fall through */ - default: - status = ar6000_update_wlan_pwr_state(ar, WLAN_DISABLED, true); - if (ar->arWlanPowerState==WLAN_POWER_STATE_ON || - ar->arWlanPowerState==WLAN_POWER_STATE_WOW) { - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Strange suspend state for not wow mode %d", ar->arWlanPowerState)); - } - AR_DEBUG_PRINTF(ATH_DEBUG_PM,("%s:Suspend for %d mode pwr %d status %d\n", __func__, pmmode, ar->arWlanPowerState, status)); - status = (ar->arWlanPowerState == WLAN_POWER_STATE_CUT_PWR) ? 0 : A_EBUSY; - break; - } - - ar->scan_triggered = 0; - return status; -} - -int ar6000_resume_ev(void *context) -{ - struct ar6_softc *ar = (struct ar6_softc *)context; - u16 powerState = ar->arWlanPowerState; - - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: enter previous state %d wowState %d\n", __func__, powerState, ar->arWowState)); - switch (powerState) { - case WLAN_POWER_STATE_WOW: - ar6000_wow_resume(ar); - break; - case WLAN_POWER_STATE_CUT_PWR: - /* fall through */ - case WLAN_POWER_STATE_DEEP_SLEEP: - ar6000_update_wlan_pwr_state(ar, WLAN_ENABLED, true); - AR_DEBUG_PRINTF(ATH_DEBUG_PM,("%s:Resume for %d mode pwr %d\n", __func__, powerState, ar->arWlanPowerState)); - break; - case WLAN_POWER_STATE_ON: - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Strange SDIO bus power mode!!\n")); - break; - } - return 0; -} - -void ar6000_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent) -{ - if (ar->arWowState!=WLAN_WOW_STATE_NONE) { - if (ar->arWowState==WLAN_WOW_STATE_SUSPENDING) { - AR_DEBUG_PRINTF(ATH_DEBUG_PM,("\n%s: Received IRQ while we are wow suspending!!!\n\n", __func__)); - return; - } - /* Wow resume from irq interrupt */ - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: WoW resume from irq thread status %d\n", __func__, ar->arWlanPowerState)); - ar6000_wow_resume(ar); - } -} - -int ar6000_power_change_ev(void *context, u32 config) -{ - struct ar6_softc *ar = (struct ar6_softc *)context; - int status = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: power change event callback %d \n", __func__, config)); - switch (config) { - case HIF_DEVICE_POWER_UP: - ar6000_restart_endpoint(ar->arNetDev); - status = 0; - break; - case HIF_DEVICE_POWER_DOWN: - case HIF_DEVICE_POWER_CUT: - status = 0; - break; - } - return status; -} - -#endif /* CONFIG_PM */ - -int -ar6000_setup_cut_power_state(struct ar6_softc *ar, AR6000_WLAN_STATE state) -{ - int status = 0; - HIF_DEVICE_POWER_CHANGE_TYPE config; - - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: Cut power %d %d \n", __func__,state, ar->arWlanPowerState)); -#ifdef CONFIG_PM - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Wlan OFF %d BT OFf %d \n", ar->arWlanOff, ar->arBTOff)); -#endif - do { - if (state == WLAN_ENABLED) { - /* Not in cut power state.. exit */ - if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) { - break; - } - - /* Change the state to ON */ - ar->arWlanPowerState = WLAN_POWER_STATE_ON; - - - /* Indicate POWER_UP to HIF */ - config = HIF_DEVICE_POWER_UP; - status = HIFConfigureDevice(ar->arHifDevice, - HIF_DEVICE_POWER_STATE_CHANGE, - &config, - sizeof(HIF_DEVICE_POWER_CHANGE_TYPE)); - - if (status == A_PENDING) { - } else if (status == 0) { - ar6000_restart_endpoint(ar->arNetDev); - status = 0; - } - } else if (state == WLAN_DISABLED) { - - - /* Already in cut power state.. exit */ - if (ar->arWlanPowerState == WLAN_POWER_STATE_CUT_PWR) { - break; - } - ar6000_stop_endpoint(ar->arNetDev, true, false); - - config = HIF_DEVICE_POWER_CUT; - status = HIFConfigureDevice(ar->arHifDevice, - HIF_DEVICE_POWER_STATE_CHANGE, - &config, - sizeof(HIF_DEVICE_POWER_CHANGE_TYPE)); - - ar->arWlanPowerState = WLAN_POWER_STATE_CUT_PWR; - } - } while (0); - - return status; -} - -int -ar6000_setup_deep_sleep_state(struct ar6_softc *ar, AR6000_WLAN_STATE state) -{ - int status = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: Deep sleep %d %d \n", __func__,state, ar->arWlanPowerState)); -#ifdef CONFIG_PM - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Wlan OFF %d BT OFf %d \n", ar->arWlanOff, ar->arBTOff)); -#endif - do { - WMI_SET_HOST_SLEEP_MODE_CMD hostSleepMode; - - if (state == WLAN_ENABLED) { - u16 fg_start_period; - - /* Not in deep sleep state.. exit */ - if (ar->arWlanPowerState != WLAN_POWER_STATE_DEEP_SLEEP) { - if (ar->arWlanPowerState != WLAN_POWER_STATE_ON) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Strange state when we resume from deep sleep %d\n", ar->arWlanPowerState)); - } - break; - } - - fg_start_period = (ar->scParams.fg_start_period==0) ? 1 : ar->scParams.fg_start_period; - hostSleepMode.awake = true; - hostSleepMode.asleep = false; - - if ((status=wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode)) != 0) { - break; - } - - /* Change the state to ON */ - ar->arWlanPowerState = WLAN_POWER_STATE_ON; - - /* Enable foreground scanning */ - if ((status=wmi_scanparams_cmd(ar->arWmi, fg_start_period, - ar->scParams.fg_end_period, - ar->scParams.bg_period, - ar->scParams.minact_chdwell_time, - ar->scParams.maxact_chdwell_time, - ar->scParams.pas_chdwell_time, - ar->scParams.shortScanRatio, - ar->scParams.scanCtrlFlags, - ar->scParams.max_dfsch_act_time, - ar->scParams.maxact_scan_per_ssid)) != 0) - { - break; - } - - if (ar->arNetworkType != AP_NETWORK) - { - if (ar->arSsidLen) { - if (ar6000_connect_to_ap(ar) != 0) { - /* no need to report error if connection failed */ - break; - } - } - } - } else if (state == WLAN_DISABLED){ - WMI_SET_WOW_MODE_CMD wowMode = { .enable_wow = false }; - - /* Already in deep sleep state.. exit */ - if (ar->arWlanPowerState != WLAN_POWER_STATE_ON) { - if (ar->arWlanPowerState != WLAN_POWER_STATE_DEEP_SLEEP) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Strange state when we suspend for deep sleep %d\n", ar->arWlanPowerState)); - } - break; - } - - if (ar->arNetworkType != AP_NETWORK) - { - /* Disconnect from the AP and disable foreground scanning */ - AR6000_SPIN_LOCK(&ar->arLock, 0); - if (ar->arConnected == true || ar->arConnectPending == true) { - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - wmi_disconnect_cmd(ar->arWmi); - } else { - AR6000_SPIN_UNLOCK(&ar->arLock, 0); - } - } - - ar->scan_triggered = 0; - - if ((status=wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0)) != 0) { - break; - } - - /* make sure we disable wow for deep sleep */ - if ((status=wmi_set_wow_mode_cmd(ar->arWmi, &wowMode))!= 0) - { - break; - } - - ar6000_TxDataCleanup(ar); -#ifndef ATH6K_CONFIG_OTA_MODE - wmi_powermode_cmd(ar->arWmi, REC_POWER); -#endif - - hostSleepMode.awake = false; - hostSleepMode.asleep = true; - if ((status=wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode))!= 0) { - break; - } - if (ar->arTxPending[ar->arControlEp]) { - u32 timeleft = wait_event_interruptible_timeout(arEvent, - ar->arTxPending[ar->arControlEp] == 0, wmitimeout * HZ); - if (!timeleft || signal_pending(current)) { - status = A_ERROR; - break; - } - } - status = hifWaitForPendingRecv(ar->arHifDevice); - - ar->arWlanPowerState = WLAN_POWER_STATE_DEEP_SLEEP; - } - } while (0); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to enter/exit deep sleep %d\n", state)); - } - - return status; -} - -int -ar6000_update_wlan_pwr_state(struct ar6_softc *ar, AR6000_WLAN_STATE state, bool pmEvent) -{ - int status = 0; - u16 powerState, oldPowerState; - AR6000_WLAN_STATE oldstate = ar->arWlanState; - bool wlanOff = ar->arWlanOff; -#ifdef CONFIG_PM - bool btOff = ar->arBTOff; -#endif /* CONFIG_PM */ - - if ((state!=WLAN_DISABLED && state!=WLAN_ENABLED)) { - return A_ERROR; - } - - if (ar->bIsDestroyProgress) { - return A_EBUSY; - } - - if (down_interruptible(&ar->arSem)) { - return A_ERROR; - } - - if (ar->bIsDestroyProgress) { - up(&ar->arSem); - return A_EBUSY; - } - - ar->arWlanState = wlanOff ? WLAN_DISABLED : state; - oldPowerState = ar->arWlanPowerState; - if (state == WLAN_ENABLED) { - powerState = ar->arWlanPowerState; - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("WLAN PWR set to ENABLE^^\n")); - if (!wlanOff) { - if (powerState == WLAN_POWER_STATE_DEEP_SLEEP) { - status = ar6000_setup_deep_sleep_state(ar, WLAN_ENABLED); - } else if (powerState == WLAN_POWER_STATE_CUT_PWR) { - status = ar6000_setup_cut_power_state(ar, WLAN_ENABLED); - } - } -#ifdef CONFIG_PM - else if (pmEvent && wlanOff) { - bool allowCutPwr = ((!ar->arBTSharing) || btOff); - if ((powerState==WLAN_POWER_STATE_CUT_PWR) && (!allowCutPwr)) { - /* Come out of cut power */ - ar6000_setup_cut_power_state(ar, WLAN_ENABLED); - status = ar6000_setup_deep_sleep_state(ar, WLAN_DISABLED); - } - } -#endif /* CONFIG_PM */ - } else if (state == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("WLAN PWR set to DISABLED~\n")); - powerState = WLAN_POWER_STATE_DEEP_SLEEP; -#ifdef CONFIG_PM - if (pmEvent) { /* disable due to suspend */ - bool suspendCutPwr = (ar->arSuspendConfig == WLAN_SUSPEND_CUT_PWR || - (ar->arSuspendConfig == WLAN_SUSPEND_WOW && - ar->arWow2Config==WLAN_SUSPEND_CUT_PWR)); - bool suspendCutIfBtOff = ((ar->arSuspendConfig == - WLAN_SUSPEND_CUT_PWR_IF_BT_OFF || - (ar->arSuspendConfig == WLAN_SUSPEND_WOW && - ar->arWow2Config==WLAN_SUSPEND_CUT_PWR_IF_BT_OFF)) && - (!ar->arBTSharing || btOff)); - if ((suspendCutPwr) || - (suspendCutIfBtOff) || - (ar->arWlanState==WLAN_POWER_STATE_CUT_PWR)) - { - powerState = WLAN_POWER_STATE_CUT_PWR; - } - } else { - if ((wlanOff) && - (ar->arWlanOffConfig == WLAN_OFF_CUT_PWR) && - (!ar->arBTSharing || btOff)) - { - /* For BT clock sharing designs, CUT_POWER depend on BT state */ - powerState = WLAN_POWER_STATE_CUT_PWR; - } - } -#endif /* CONFIG_PM */ - - if (powerState == WLAN_POWER_STATE_DEEP_SLEEP) { - if (ar->arWlanPowerState == WLAN_POWER_STATE_CUT_PWR) { - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Load firmware before set to deep sleep\n")); - ar6000_setup_cut_power_state(ar, WLAN_ENABLED); - } - status = ar6000_setup_deep_sleep_state(ar, WLAN_DISABLED); - } else if (powerState == WLAN_POWER_STATE_CUT_PWR) { - status = ar6000_setup_cut_power_state(ar, WLAN_DISABLED); - } - - } - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to setup WLAN state %d\n", ar->arWlanState)); - ar->arWlanState = oldstate; - } else if (status == 0) { - WMI_REPORT_SLEEP_STATE_EVENT wmiSleepEvent, *pSleepEvent = NULL; - if ((ar->arWlanPowerState == WLAN_POWER_STATE_ON) && (oldPowerState != WLAN_POWER_STATE_ON)) { - wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE; - pSleepEvent = &wmiSleepEvent; - } else if ((ar->arWlanPowerState != WLAN_POWER_STATE_ON) && (oldPowerState == WLAN_POWER_STATE_ON)) { - wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP; - pSleepEvent = &wmiSleepEvent; - } - if (pSleepEvent) { - AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("SENT WLAN Sleep Event %d\n", wmiSleepEvent.sleepState)); - } - } - up(&ar->arSem); - return status; -} - -int -ar6000_set_bt_hw_state(struct ar6_softc *ar, u32 enable) -{ -#ifdef CONFIG_PM - bool off = (enable == 0); - int status; - if (ar->arBTOff == off) { - return 0; - } - ar->arBTOff = off; - status = ar6000_update_wlan_pwr_state(ar, ar->arWlanOff ? WLAN_DISABLED : WLAN_ENABLED, false); - return status; -#else - return 0; -#endif -} - -int -ar6000_set_wlan_state(struct ar6_softc *ar, AR6000_WLAN_STATE state) -{ - int status; - bool off = (state == WLAN_DISABLED); - if (ar->arWlanOff == off) { - return 0; - } - ar->arWlanOff = off; - status = ar6000_update_wlan_pwr_state(ar, state, false); - return status; -} diff --git a/drivers/staging/ath6kl/os/linux/ar6000_raw_if.c b/drivers/staging/ath6kl/os/linux/ar6000_raw_if.c deleted file mode 100644 index ae7c1dd96d8..00000000000 --- a/drivers/staging/ath6kl/os/linux/ar6000_raw_if.c +++ /dev/null @@ -1,455 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#include "ar6000_drv.h" - -#ifdef HTC_RAW_INTERFACE - -static void -ar6000_htc_raw_read_cb(void *Context, struct htc_packet *pPacket) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - raw_htc_buffer *busy; - HTC_RAW_STREAM_ID streamID; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - - busy = (raw_htc_buffer *)pPacket->pPktContext; - A_ASSERT(busy != NULL); - - if (pPacket->Status == A_ECANCELED) { - /* - * HTC provides A_ECANCELED status when it doesn't want to be refilled - * (probably due to a shutdown) - */ - return; - } - - streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint); - A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED); - -#ifdef CF - if (down_trylock(&arRaw->raw_htc_read_sem[streamID])) { -#else - if (down_interruptible(&arRaw->raw_htc_read_sem[streamID])) { -#endif /* CF */ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to down the semaphore\n")); - } - - A_ASSERT((pPacket->Status != 0) || - (pPacket->pBuffer == (busy->data + HTC_HEADER_LEN))); - - busy->length = pPacket->ActualLength + HTC_HEADER_LEN; - busy->currPtr = HTC_HEADER_LEN; - arRaw->read_buffer_available[streamID] = true; - //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("raw read cb: 0x%X 0x%X \n", busy->currPtr,busy->length); - up(&arRaw->raw_htc_read_sem[streamID]); - - /* Signal the waiting process */ - AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("Waking up the StreamID(%d) read process\n", streamID)); - wake_up_interruptible(&arRaw->raw_htc_read_queue[streamID]); -} - -static void -ar6000_htc_raw_write_cb(void *Context, struct htc_packet *pPacket) -{ - struct ar6_softc *ar = (struct ar6_softc *)Context; - raw_htc_buffer *free; - HTC_RAW_STREAM_ID streamID; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - - free = (raw_htc_buffer *)pPacket->pPktContext; - A_ASSERT(free != NULL); - - if (pPacket->Status == A_ECANCELED) { - /* - * HTC provides A_ECANCELED status when it doesn't want to be refilled - * (probably due to a shutdown) - */ - return; - } - - streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint); - A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED); - -#ifdef CF - if (down_trylock(&arRaw->raw_htc_write_sem[streamID])) { -#else - if (down_interruptible(&arRaw->raw_htc_write_sem[streamID])) { -#endif - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to down the semaphore\n")); - } - - A_ASSERT(pPacket->pBuffer == (free->data + HTC_HEADER_LEN)); - - free->length = 0; - arRaw->write_buffer_available[streamID] = true; - up(&arRaw->raw_htc_write_sem[streamID]); - - /* Signal the waiting process */ - AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("Waking up the StreamID(%d) write process\n", streamID)); - wake_up_interruptible(&arRaw->raw_htc_write_queue[streamID]); -} - -/* connect to a service */ -static int ar6000_connect_raw_service(struct ar6_softc *ar, - HTC_RAW_STREAM_ID StreamID) -{ - int status; - struct htc_service_connect_resp response; - u8 streamNo; - struct htc_service_connect_req connect; - - do { - - A_MEMZERO(&connect,sizeof(connect)); - /* pass the stream ID as meta data to the RAW streams service */ - streamNo = (u8)StreamID; - connect.pMetaData = &streamNo; - connect.MetaDataLength = sizeof(u8); - /* these fields are the same for all endpoints */ - connect.EpCallbacks.pContext = ar; - connect.EpCallbacks.EpTxComplete = ar6000_htc_raw_write_cb; - connect.EpCallbacks.EpRecv = ar6000_htc_raw_read_cb; - /* simple interface, we don't need these optional callbacks */ - connect.EpCallbacks.EpRecvRefill = NULL; - connect.EpCallbacks.EpSendFull = NULL; - connect.MaxSendQueueDepth = RAW_HTC_WRITE_BUFFERS_NUM; - - /* connect to the raw streams service, we may be able to get 1 or more - * connections, depending on WHAT is running on the target */ - connect.ServiceID = HTC_RAW_STREAMS_SVC; - - A_MEMZERO(&response,sizeof(response)); - - /* try to connect to the raw stream, it is okay if this fails with - * status HTC_SERVICE_NO_MORE_EP */ - status = HTCConnectService(ar->arHtcTarget, - &connect, - &response); - - if (status) { - if (response.ConnectRespCode == HTC_SERVICE_NO_MORE_EP) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HTC RAW , No more streams allowed \n")); - status = 0; - } - break; - } - - /* set endpoint mapping for the RAW HTC streams */ - arSetRawStream2EndpointIDMap(ar,StreamID,response.Endpoint); - - AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("HTC RAW : stream ID: %d, endpoint: %d\n", - StreamID, arRawStream2EndpointID(ar,StreamID))); - - } while (false); - - return status; -} - -int ar6000_htc_raw_open(struct ar6_softc *ar) -{ - int status; - int streamID, endPt, count2; - raw_htc_buffer *buffer; - HTC_SERVICE_ID servicepriority; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - if (!arRaw) { - arRaw = ar->arRawHtc = A_MALLOC(sizeof(AR_RAW_HTC_T)); - if (arRaw) { - A_MEMZERO(arRaw, sizeof(AR_RAW_HTC_T)); - } - } - A_ASSERT(ar->arHtcTarget != NULL); - if (!arRaw) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Faile to allocate memory for HTC RAW interface\n")); - return -ENOMEM; - } - /* wait for target */ - status = HTCWaitTarget(ar->arHtcTarget); - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HTCWaitTarget failed (%d)\n", status)); - return -ENODEV; - } - - for (endPt = 0; endPt < ENDPOINT_MAX; endPt++) { - arRaw->arEp2RawMapping[endPt] = HTC_RAW_STREAM_NOT_MAPPED; - } - - for (streamID = HTC_RAW_STREAM_0; streamID < HTC_RAW_STREAM_NUM_MAX; streamID++) { - /* Initialize the data structures */ - sema_init(&arRaw->raw_htc_read_sem[streamID], 1); - sema_init(&arRaw->raw_htc_write_sem[streamID], 1); - init_waitqueue_head(&arRaw->raw_htc_read_queue[streamID]); - init_waitqueue_head(&arRaw->raw_htc_write_queue[streamID]); - - /* try to connect to the raw service */ - status = ar6000_connect_raw_service(ar,streamID); - - if (status) { - break; - } - - if (arRawStream2EndpointID(ar,streamID) == 0) { - break; - } - - for (count2 = 0; count2 < RAW_HTC_READ_BUFFERS_NUM; count2 ++) { - /* Initialize the receive buffers */ - buffer = &arRaw->raw_htc_write_buffer[streamID][count2]; - memset(buffer, 0, sizeof(raw_htc_buffer)); - buffer = &arRaw->raw_htc_read_buffer[streamID][count2]; - memset(buffer, 0, sizeof(raw_htc_buffer)); - - SET_HTC_PACKET_INFO_RX_REFILL(&buffer->HTCPacket, - buffer, - buffer->data, - HTC_RAW_BUFFER_SIZE, - arRawStream2EndpointID(ar,streamID)); - - /* Queue buffers to HTC for receive */ - if ((status = HTCAddReceivePkt(ar->arHtcTarget, &buffer->HTCPacket)) != 0) - { - BMIInit(); - return -EIO; - } - } - - for (count2 = 0; count2 < RAW_HTC_WRITE_BUFFERS_NUM; count2 ++) { - /* Initialize the receive buffers */ - buffer = &arRaw->raw_htc_write_buffer[streamID][count2]; - memset(buffer, 0, sizeof(raw_htc_buffer)); - } - - arRaw->read_buffer_available[streamID] = false; - arRaw->write_buffer_available[streamID] = true; - } - - if (status) { - return -EIO; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("HTC RAW, number of streams the target supports: %d \n", streamID)); - - servicepriority = HTC_RAW_STREAMS_SVC; /* only 1 */ - - /* set callbacks and priority list */ - HTCSetCreditDistribution(ar->arHtcTarget, - ar, - NULL, /* use default */ - NULL, /* use default */ - &servicepriority, - 1); - - /* Start the HTC component */ - if ((status = HTCStart(ar->arHtcTarget)) != 0) { - BMIInit(); - return -EIO; - } - - (ar)->arRawIfInit = true; - - return 0; -} - -int ar6000_htc_raw_close(struct ar6_softc *ar) -{ - A_PRINTF("ar6000_htc_raw_close called \n"); - HTCStop(ar->arHtcTarget); - - /* reset the device */ - ar6000_reset_device(ar->arHifDevice, ar->arTargetType, true, false); - /* Initialize the BMI component */ - BMIInit(); - - return 0; -} - -raw_htc_buffer * -get_filled_buffer(struct ar6_softc *ar, HTC_RAW_STREAM_ID StreamID) -{ - int count; - raw_htc_buffer *busy; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - - /* Check for data */ - for (count = 0; count < RAW_HTC_READ_BUFFERS_NUM; count ++) { - busy = &arRaw->raw_htc_read_buffer[StreamID][count]; - if (busy->length) { - break; - } - } - if (busy->length) { - arRaw->read_buffer_available[StreamID] = true; - } else { - arRaw->read_buffer_available[StreamID] = false; - } - - return busy; -} - -ssize_t ar6000_htc_raw_read(struct ar6_softc *ar, HTC_RAW_STREAM_ID StreamID, - char __user *buffer, size_t length) -{ - int readPtr; - raw_htc_buffer *busy; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - - if (arRawStream2EndpointID(ar,StreamID) == 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("StreamID(%d) not connected! \n", StreamID)); - return -EFAULT; - } - - if (down_interruptible(&arRaw->raw_htc_read_sem[StreamID])) { - return -ERESTARTSYS; - } - - busy = get_filled_buffer(ar,StreamID); - while (!arRaw->read_buffer_available[StreamID]) { - up(&arRaw->raw_htc_read_sem[StreamID]); - - /* Wait for the data */ - AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("Sleeping StreamID(%d) read process\n", StreamID)); - if (wait_event_interruptible(arRaw->raw_htc_read_queue[StreamID], - arRaw->read_buffer_available[StreamID])) - { - return -EINTR; - } - if (down_interruptible(&arRaw->raw_htc_read_sem[StreamID])) { - return -ERESTARTSYS; - } - busy = get_filled_buffer(ar,StreamID); - } - - /* Read the data */ - readPtr = busy->currPtr; - if (length > busy->length - HTC_HEADER_LEN) { - length = busy->length - HTC_HEADER_LEN; - } - if (copy_to_user(buffer, &busy->data[readPtr], length)) { - up(&arRaw->raw_htc_read_sem[StreamID]); - return -EFAULT; - } - - busy->currPtr += length; - - if (busy->currPtr == busy->length) - { - busy->currPtr = 0; - busy->length = 0; - HTC_PACKET_RESET_RX(&busy->HTCPacket); - //AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("raw read ioctl: ep for packet:%d \n", busy->HTCPacket.Endpoint)); - HTCAddReceivePkt(ar->arHtcTarget, &busy->HTCPacket); - } - arRaw->read_buffer_available[StreamID] = false; - up(&arRaw->raw_htc_read_sem[StreamID]); - - return length; -} - -static raw_htc_buffer * -get_free_buffer(struct ar6_softc *ar, HTC_ENDPOINT_ID StreamID) -{ - int count; - raw_htc_buffer *free; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - - free = NULL; - for (count = 0; count < RAW_HTC_WRITE_BUFFERS_NUM; count ++) { - free = &arRaw->raw_htc_write_buffer[StreamID][count]; - if (free->length == 0) { - break; - } - } - if (!free->length) { - arRaw->write_buffer_available[StreamID] = true; - } else { - arRaw->write_buffer_available[StreamID] = false; - } - - return free; -} - -ssize_t ar6000_htc_raw_write(struct ar6_softc *ar, HTC_RAW_STREAM_ID StreamID, - char __user *buffer, size_t length) -{ - int writePtr; - raw_htc_buffer *free; - AR_RAW_HTC_T *arRaw = ar->arRawHtc; - if (arRawStream2EndpointID(ar,StreamID) == 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("StreamID(%d) not connected! \n", StreamID)); - return -EFAULT; - } - - if (down_interruptible(&arRaw->raw_htc_write_sem[StreamID])) { - return -ERESTARTSYS; - } - - /* Search for a free buffer */ - free = get_free_buffer(ar,StreamID); - - /* Check if there is space to write else wait */ - while (!arRaw->write_buffer_available[StreamID]) { - up(&arRaw->raw_htc_write_sem[StreamID]); - - /* Wait for buffer to become free */ - AR_DEBUG_PRINTF(ATH_DEBUG_HTC_RAW,("Sleeping StreamID(%d) write process\n", StreamID)); - if (wait_event_interruptible(arRaw->raw_htc_write_queue[StreamID], - arRaw->write_buffer_available[StreamID])) - { - return -EINTR; - } - if (down_interruptible(&arRaw->raw_htc_write_sem[StreamID])) { - return -ERESTARTSYS; - } - free = get_free_buffer(ar,StreamID); - } - - /* Send the data */ - writePtr = HTC_HEADER_LEN; - if (length > (HTC_RAW_BUFFER_SIZE - HTC_HEADER_LEN)) { - length = HTC_RAW_BUFFER_SIZE - HTC_HEADER_LEN; - } - - if (copy_from_user(&free->data[writePtr], buffer, length)) { - up(&arRaw->raw_htc_read_sem[StreamID]); - return -EFAULT; - } - - free->length = length; - - SET_HTC_PACKET_INFO_TX(&free->HTCPacket, - free, - &free->data[writePtr], - length, - arRawStream2EndpointID(ar,StreamID), - AR6K_DATA_PKT_TAG); - - HTCSendPkt(ar->arHtcTarget,&free->HTCPacket); - - arRaw->write_buffer_available[StreamID] = false; - up(&arRaw->raw_htc_write_sem[StreamID]); - - return length; -} -#endif /* HTC_RAW_INTERFACE */ diff --git a/drivers/staging/ath6kl/os/linux/cfg80211.c b/drivers/staging/ath6kl/os/linux/cfg80211.c deleted file mode 100644 index 5fdda4aa2fe..00000000000 --- a/drivers/staging/ath6kl/os/linux/cfg80211.c +++ /dev/null @@ -1,1892 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#include -#include -#include -#include - -#include "ar6000_drv.h" - - -extern A_WAITQUEUE_HEAD arEvent; -extern unsigned int wmitimeout; -extern int reconnect_flag; - - -#define RATETAB_ENT(_rate, _rateid, _flags) { \ - .bitrate = (_rate), \ - .flags = (_flags), \ - .hw_value = (_rateid), \ -} - -#define CHAN2G(_channel, _freq, _flags) { \ - .band = IEEE80211_BAND_2GHZ, \ - .hw_value = (_channel), \ - .center_freq = (_freq), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -#define CHAN5G(_channel, _flags) { \ - .band = IEEE80211_BAND_5GHZ, \ - .hw_value = (_channel), \ - .center_freq = 5000 + (5 * (_channel)), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -static struct -ieee80211_rate ar6k_rates[] = { - RATETAB_ENT(10, 0x1, 0), - RATETAB_ENT(20, 0x2, 0), - RATETAB_ENT(55, 0x4, 0), - RATETAB_ENT(110, 0x8, 0), - RATETAB_ENT(60, 0x10, 0), - RATETAB_ENT(90, 0x20, 0), - RATETAB_ENT(120, 0x40, 0), - RATETAB_ENT(180, 0x80, 0), - RATETAB_ENT(240, 0x100, 0), - RATETAB_ENT(360, 0x200, 0), - RATETAB_ENT(480, 0x400, 0), - RATETAB_ENT(540, 0x800, 0), -}; - -#define ar6k_a_rates (ar6k_rates + 4) -#define ar6k_a_rates_size 8 -#define ar6k_g_rates (ar6k_rates + 0) -#define ar6k_g_rates_size 12 - -static struct -ieee80211_channel ar6k_2ghz_channels[] = { - CHAN2G(1, 2412, 0), - CHAN2G(2, 2417, 0), - CHAN2G(3, 2422, 0), - CHAN2G(4, 2427, 0), - CHAN2G(5, 2432, 0), - CHAN2G(6, 2437, 0), - CHAN2G(7, 2442, 0), - CHAN2G(8, 2447, 0), - CHAN2G(9, 2452, 0), - CHAN2G(10, 2457, 0), - CHAN2G(11, 2462, 0), - CHAN2G(12, 2467, 0), - CHAN2G(13, 2472, 0), - CHAN2G(14, 2484, 0), -}; - -static struct -ieee80211_channel ar6k_5ghz_a_channels[] = { - CHAN5G(34, 0), CHAN5G(36, 0), - CHAN5G(38, 0), CHAN5G(40, 0), - CHAN5G(42, 0), CHAN5G(44, 0), - CHAN5G(46, 0), CHAN5G(48, 0), - CHAN5G(52, 0), CHAN5G(56, 0), - CHAN5G(60, 0), CHAN5G(64, 0), - CHAN5G(100, 0), CHAN5G(104, 0), - CHAN5G(108, 0), CHAN5G(112, 0), - CHAN5G(116, 0), CHAN5G(120, 0), - CHAN5G(124, 0), CHAN5G(128, 0), - CHAN5G(132, 0), CHAN5G(136, 0), - CHAN5G(140, 0), CHAN5G(149, 0), - CHAN5G(153, 0), CHAN5G(157, 0), - CHAN5G(161, 0), CHAN5G(165, 0), - CHAN5G(184, 0), CHAN5G(188, 0), - CHAN5G(192, 0), CHAN5G(196, 0), - CHAN5G(200, 0), CHAN5G(204, 0), - CHAN5G(208, 0), CHAN5G(212, 0), - CHAN5G(216, 0), -}; - -static struct -ieee80211_supported_band ar6k_band_2ghz = { - .n_channels = ARRAY_SIZE(ar6k_2ghz_channels), - .channels = ar6k_2ghz_channels, - .n_bitrates = ar6k_g_rates_size, - .bitrates = ar6k_g_rates, -}; - -static struct -ieee80211_supported_band ar6k_band_5ghz = { - .n_channels = ARRAY_SIZE(ar6k_5ghz_a_channels), - .channels = ar6k_5ghz_a_channels, - .n_bitrates = ar6k_a_rates_size, - .bitrates = ar6k_a_rates, -}; - -static int -ar6k_set_wpa_version(struct ar6_softc *ar, enum nl80211_wpa_versions wpa_version) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: %u\n", __func__, wpa_version)); - - if (!wpa_version) { - ar->arAuthMode = NONE_AUTH; - } else if (wpa_version & NL80211_WPA_VERSION_1) { - ar->arAuthMode = WPA_AUTH; - } else if (wpa_version & NL80211_WPA_VERSION_2) { - ar->arAuthMode = WPA2_AUTH; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: %u not spported\n", __func__, wpa_version)); - return -ENOTSUPP; - } - - return 0; -} - -static int -ar6k_set_auth_type(struct ar6_softc *ar, enum nl80211_auth_type auth_type) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: 0x%x\n", __func__, auth_type)); - - switch (auth_type) { - case NL80211_AUTHTYPE_OPEN_SYSTEM: - ar->arDot11AuthMode = OPEN_AUTH; - break; - case NL80211_AUTHTYPE_SHARED_KEY: - ar->arDot11AuthMode = SHARED_AUTH; - break; - case NL80211_AUTHTYPE_NETWORK_EAP: - ar->arDot11AuthMode = LEAP_AUTH; - break; - - case NL80211_AUTHTYPE_AUTOMATIC: - ar->arDot11AuthMode = OPEN_AUTH; - ar->arAutoAuthStage = AUTH_OPEN_IN_PROGRESS; - break; - - default: - ar->arDot11AuthMode = OPEN_AUTH; - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: 0x%x not spported\n", __func__, auth_type)); - return -ENOTSUPP; - } - - return 0; -} - -static int -ar6k_set_cipher(struct ar6_softc *ar, u32 cipher, bool ucast) -{ - u8 *ar_cipher = ucast ? &ar->arPairwiseCrypto : - &ar->arGroupCrypto; - u8 *ar_cipher_len = ucast ? &ar->arPairwiseCryptoLen : - &ar->arGroupCryptoLen; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: cipher 0x%x, ucast %u\n", __func__, cipher, ucast)); - - switch (cipher) { - case 0: - case IW_AUTH_CIPHER_NONE: - *ar_cipher = NONE_CRYPT; - *ar_cipher_len = 0; - break; - case WLAN_CIPHER_SUITE_WEP40: - *ar_cipher = WEP_CRYPT; - *ar_cipher_len = 5; - break; - case WLAN_CIPHER_SUITE_WEP104: - *ar_cipher = WEP_CRYPT; - *ar_cipher_len = 13; - break; - case WLAN_CIPHER_SUITE_TKIP: - *ar_cipher = TKIP_CRYPT; - *ar_cipher_len = 0; - break; - case WLAN_CIPHER_SUITE_CCMP: - *ar_cipher = AES_CRYPT; - *ar_cipher_len = 0; - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: cipher 0x%x not supported\n", __func__, cipher)); - return -ENOTSUPP; - } - - return 0; -} - -static void -ar6k_set_key_mgmt(struct ar6_softc *ar, u32 key_mgmt) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: 0x%x\n", __func__, key_mgmt)); - - if (WLAN_AKM_SUITE_PSK == key_mgmt) { - if (WPA_AUTH == ar->arAuthMode) { - ar->arAuthMode = WPA_PSK_AUTH; - } else if (WPA2_AUTH == ar->arAuthMode) { - ar->arAuthMode = WPA2_PSK_AUTH; - } - } else if (WLAN_AKM_SUITE_8021X != key_mgmt) { - ar->arAuthMode = NONE_AUTH; - } -} - -static int -ar6k_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_connect_params *sme) -{ - struct ar6_softc *ar = ar6k_priv(dev); - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - ar->smeState = SME_CONNECTING; - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready yet\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(ar->bIsDestroyProgress) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: destroy in progress\n", __func__)); - return -EBUSY; - } - - if(!sme->ssid_len || IEEE80211_MAX_SSID_LEN < sme->ssid_len) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ssid invalid\n", __func__)); - return -EINVAL; - } - - if(ar->arSkipScan == true && - ((sme->channel && sme->channel->center_freq == 0) || - (sme->bssid && !sme->bssid[0] && !sme->bssid[1] && !sme->bssid[2] && - !sme->bssid[3] && !sme->bssid[4] && !sme->bssid[5]))) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s:SkipScan: channel or bssid invalid\n", __func__)); - return -EINVAL; - } - - if(down_interruptible(&ar->arSem)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__)); - return -ERESTARTSYS; - } - - if(ar->bIsDestroyProgress) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, destroy in progress\n", __func__)); - up(&ar->arSem); - return -EBUSY; - } - - if(ar->arTxPending[wmi_get_control_ep(ar->arWmi)]) { - /* - * sleep until the command queue drains - */ - wait_event_interruptible_timeout(arEvent, - ar->arTxPending[wmi_get_control_ep(ar->arWmi)] == 0, wmitimeout * HZ); - if (signal_pending(current)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: cmd queue drain timeout\n", __func__)); - up(&ar->arSem); - return -EINTR; - } - } - - if(ar->arConnected == true && - ar->arSsidLen == sme->ssid_len && - !memcmp(ar->arSsid, sme->ssid, ar->arSsidLen)) { - reconnect_flag = true; - status = wmi_reconnect_cmd(ar->arWmi, - ar->arReqBssid, - ar->arChannelHint); - - up(&ar->arSem); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_reconnect_cmd failed\n", __func__)); - return -EIO; - } - return 0; - } else if(ar->arSsidLen == sme->ssid_len && - !memcmp(ar->arSsid, sme->ssid, ar->arSsidLen)) { - ar6000_disconnect(ar); - } - - A_MEMZERO(ar->arSsid, sizeof(ar->arSsid)); - ar->arSsidLen = sme->ssid_len; - memcpy(ar->arSsid, sme->ssid, sme->ssid_len); - - if(sme->channel){ - ar->arChannelHint = sme->channel->center_freq; - } - - A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid)); - if(sme->bssid){ - if(memcmp(&sme->bssid, bcast_mac, AR6000_ETH_ADDR_LEN)) { - memcpy(ar->arReqBssid, sme->bssid, sizeof(ar->arReqBssid)); - } - } - - ar6k_set_wpa_version(ar, sme->crypto.wpa_versions); - ar6k_set_auth_type(ar, sme->auth_type); - - if(sme->crypto.n_ciphers_pairwise) { - ar6k_set_cipher(ar, sme->crypto.ciphers_pairwise[0], true); - } else { - ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, true); - } - ar6k_set_cipher(ar, sme->crypto.cipher_group, false); - - if(sme->crypto.n_akm_suites) { - ar6k_set_key_mgmt(ar, sme->crypto.akm_suites[0]); - } - - if((sme->key_len) && - (NONE_AUTH == ar->arAuthMode) && - (WEP_CRYPT == ar->arPairwiseCrypto)) { - struct ar_key *key = NULL; - - if(sme->key_idx < WMI_MIN_KEY_INDEX || sme->key_idx > WMI_MAX_KEY_INDEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: key index %d out of bounds\n", __func__, sme->key_idx)); - up(&ar->arSem); - return -ENOENT; - } - - key = &ar->keys[sme->key_idx]; - key->key_len = sme->key_len; - memcpy(key->key, sme->key, key->key_len); - key->cipher = ar->arPairwiseCrypto; - ar->arDefTxKeyIndex = sme->key_idx; - - wmi_addKey_cmd(ar->arWmi, sme->key_idx, - ar->arPairwiseCrypto, - GROUP_USAGE | TX_USAGE, - key->key_len, - NULL, - key->key, KEY_OP_INIT_VAL, NULL, - NO_SYNC_WMIFLAG); - } - - if (!ar->arUserBssFilter) { - if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Couldn't set bss filtering\n", __func__)); - up(&ar->arSem); - return -EIO; - } - } - - ar->arNetworkType = ar->arNextMode; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Connect called with authmode %d dot11 auth %d"\ - " PW crypto %d PW crypto Len %d GRP crypto %d"\ - " GRP crypto Len %d channel hint %u\n", - __func__, ar->arAuthMode, ar->arDot11AuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto, ar->arGroupCryptoLen, ar->arChannelHint)); - - reconnect_flag = 0; - status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType, - ar->arDot11AuthMode, ar->arAuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto,ar->arGroupCryptoLen, - ar->arSsidLen, ar->arSsid, - ar->arReqBssid, ar->arChannelHint, - ar->arConnectCtrlFlags); - - up(&ar->arSem); - - if (A_EINVAL == status) { - A_MEMZERO(ar->arSsid, sizeof(ar->arSsid)); - ar->arSsidLen = 0; - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Invalid request\n", __func__)); - return -ENOENT; - } else if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_connect_cmd failed\n", __func__)); - return -EIO; - } - - if ((!(ar->arConnectCtrlFlags & CONNECT_DO_WPA_OFFLOAD)) && - ((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode))) - { - A_TIMEOUT_MS(&ar->disconnect_timer, A_DISCONNECT_TIMER_INTERVAL, 0); - } - - ar->arConnectCtrlFlags &= ~CONNECT_DO_WPA_OFFLOAD; - ar->arConnectPending = true; - - return 0; -} - -void -ar6k_cfg80211_connect_event(struct ar6_softc *ar, u16 channel, - u8 *bssid, u16 listenInterval, - u16 beaconInterval,NETWORK_TYPE networkType, - u8 beaconIeLen, u8 assocReqLen, - u8 assocRespLen, u8 *assocInfo) -{ - u16 size = 0; - u16 capability = 0; - struct cfg80211_bss *bss = NULL; - struct ieee80211_mgmt *mgmt = NULL; - struct ieee80211_channel *ibss_channel = NULL; - s32 signal = 50 * 100; - u8 ie_buf_len = 0; - unsigned char ie_buf[256]; - unsigned char *ptr_ie_buf = ie_buf; - unsigned char *ieeemgmtbuf = NULL; - u8 source_mac[ATH_MAC_LEN]; - - u8 assocReqIeOffset = sizeof(u16) + /* capinfo*/ - sizeof(u16); /* listen interval */ - u8 assocRespIeOffset = sizeof(u16) + /* capinfo*/ - sizeof(u16) + /* status Code */ - sizeof(u16); /* associd */ - u8 *assocReqIe = assocInfo + beaconIeLen + assocReqIeOffset; - u8 *assocRespIe = assocInfo + beaconIeLen + assocReqLen + assocRespIeOffset; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - assocReqLen -= assocReqIeOffset; - assocRespLen -= assocRespIeOffset; - - ar->arAutoAuthStage = AUTH_IDLE; - - if((ADHOC_NETWORK & networkType)) { - if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: ath6k not in ibss mode\n", __func__)); - return; - } - } - - if((INFRA_NETWORK & networkType)) { - if(NL80211_IFTYPE_STATION != ar->wdev->iftype) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: ath6k not in station mode\n", __func__)); - return; - } - } - - /* Before informing the join/connect event, make sure that - * bss entry is present in scan list, if it not present - * construct and insert into scan list, otherwise that - * event will be dropped on the way by cfg80211, due to - * this keys will not be plumbed in case of WEP and - * application will not be aware of join/connect status. */ - bss = cfg80211_get_bss(ar->wdev->wiphy, NULL, bssid, - ar->wdev->ssid, ar->wdev->ssid_len, - ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS), - ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS)); - - /* - * Earlier we were updating the cfg about bss by making a beacon frame - * only if the entry for bss is not there. This can have some issue if - * ROAM event is generated and a heavy traffic is ongoing. The ROAM - * event is handled through a work queue and by the time it really gets - * handled, BSS would have been aged out. So it is better to update the - * cfg about BSS irrespective of its entry being present right now or - * not. - */ - - if (ADHOC_NETWORK & networkType) { - /* construct 802.11 mgmt beacon */ - if(ptr_ie_buf) { - *ptr_ie_buf++ = WLAN_EID_SSID; - *ptr_ie_buf++ = ar->arSsidLen; - memcpy(ptr_ie_buf, ar->arSsid, ar->arSsidLen); - ptr_ie_buf +=ar->arSsidLen; - - *ptr_ie_buf++ = WLAN_EID_IBSS_PARAMS; - *ptr_ie_buf++ = 2; /* length */ - *ptr_ie_buf++ = 0; /* ATIM window */ - *ptr_ie_buf++ = 0; /* ATIM window */ - - /* TODO: update ibss params and include supported rates, - * DS param set, extened support rates, wmm. */ - - ie_buf_len = ptr_ie_buf - ie_buf; - } - - capability |= IEEE80211_CAPINFO_IBSS; - if(WEP_CRYPT == ar->arPairwiseCrypto) { - capability |= IEEE80211_CAPINFO_PRIVACY; - } - memcpy(source_mac, ar->arNetDev->dev_addr, ATH_MAC_LEN); - ptr_ie_buf = ie_buf; - } else { - capability = *(u16 *)(&assocInfo[beaconIeLen]); - memcpy(source_mac, bssid, ATH_MAC_LEN); - ptr_ie_buf = assocReqIe; - ie_buf_len = assocReqLen; - } - - size = offsetof(struct ieee80211_mgmt, u) - + sizeof(mgmt->u.beacon) - + ie_buf_len; - - ieeemgmtbuf = A_MALLOC_NOWAIT(size); - if(!ieeemgmtbuf) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: ieeeMgmtbuf alloc error\n", __func__)); - cfg80211_put_bss(bss); - return; - } - - A_MEMZERO(ieeemgmtbuf, size); - mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf; - mgmt->frame_control = (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); - memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN); - memcpy(mgmt->sa, source_mac, ATH_MAC_LEN); - memcpy(mgmt->bssid, bssid, ATH_MAC_LEN); - mgmt->u.beacon.beacon_int = beaconInterval; - mgmt->u.beacon.capab_info = capability; - memcpy(mgmt->u.beacon.variable, ptr_ie_buf, ie_buf_len); - - ibss_channel = ieee80211_get_channel(ar->wdev->wiphy, (int)channel); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: inform bss with bssid %pM channel %d beaconInterval %d " - "capability 0x%x\n", __func__, mgmt->bssid, - ibss_channel->hw_value, beaconInterval, capability)); - - bss = cfg80211_inform_bss_frame(ar->wdev->wiphy, - ibss_channel, mgmt, - le16_to_cpu(size), - signal, GFP_KERNEL); - kfree(ieeemgmtbuf); - cfg80211_put_bss(bss); - - if((ADHOC_NETWORK & networkType)) { - cfg80211_ibss_joined(ar->arNetDev, bssid, GFP_KERNEL); - return; - } - - if (false == ar->arConnected) { - /* inform connect result to cfg80211 */ - ar->smeState = SME_DISCONNECTED; - cfg80211_connect_result(ar->arNetDev, bssid, - assocReqIe, assocReqLen, - assocRespIe, assocRespLen, - WLAN_STATUS_SUCCESS, GFP_KERNEL); - } else { - /* inform roam event to cfg80211 */ - cfg80211_roamed(ar->arNetDev, ibss_channel, bssid, - assocReqIe, assocReqLen, - assocRespIe, assocRespLen, - GFP_KERNEL); - } -} - -static int -ar6k_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, - u16 reason_code) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: reason=%u\n", __func__, reason_code)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(ar->bIsDestroyProgress) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, destroy in progress\n", __func__)); - return -EBUSY; - } - - if(down_interruptible(&ar->arSem)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__)); - return -ERESTARTSYS; - } - - reconnect_flag = 0; - ar6000_disconnect(ar); - A_MEMZERO(ar->arSsid, sizeof(ar->arSsid)); - ar->arSsidLen = 0; - - if (ar->arSkipScan == false) { - A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid)); - } - - up(&ar->arSem); - - return 0; -} - -void -ar6k_cfg80211_disconnect_event(struct ar6_softc *ar, u8 reason, - u8 *bssid, u8 assocRespLen, - u8 *assocInfo, u16 protocolReasonStatus) -{ - - u16 status; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: reason=%u\n", __func__, reason)); - - if (ar->scan_request) { - cfg80211_scan_done(ar->scan_request, true); - ar->scan_request = NULL; - } - if((ADHOC_NETWORK & ar->arNetworkType)) { - if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: ath6k not in ibss mode\n", __func__)); - return; - } - A_MEMZERO(bssid, ETH_ALEN); - cfg80211_ibss_joined(ar->arNetDev, bssid, GFP_KERNEL); - return; - } - - if((INFRA_NETWORK & ar->arNetworkType)) { - if(NL80211_IFTYPE_STATION != ar->wdev->iftype) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: ath6k not in station mode\n", __func__)); - return; - } - } - - if(true == ar->arConnectPending) { - if(NO_NETWORK_AVAIL == reason) { - /* connect cmd failed */ - wmi_disconnect_cmd(ar->arWmi); - } else if (reason == DISCONNECT_CMD) { - if (ar->arAutoAuthStage) { - /* - * If the current auth algorithm is open try shared - * and make autoAuthStage idle. We do not make it - * leap for now being. - */ - if (ar->arDot11AuthMode == OPEN_AUTH) { - struct ar_key *key = NULL; - key = &ar->keys[ar->arDefTxKeyIndex]; - if (down_interruptible(&ar->arSem)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__)); - return; - } - - - ar->arDot11AuthMode = SHARED_AUTH; - ar->arAutoAuthStage = AUTH_IDLE; - - wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex, - ar->arPairwiseCrypto, - GROUP_USAGE | TX_USAGE, - key->key_len, - NULL, - key->key, KEY_OP_INIT_VAL, NULL, - NO_SYNC_WMIFLAG); - - status = wmi_connect_cmd(ar->arWmi, - ar->arNetworkType, - ar->arDot11AuthMode, - ar->arAuthMode, - ar->arPairwiseCrypto, - ar->arPairwiseCryptoLen, - ar->arGroupCrypto, - ar->arGroupCryptoLen, - ar->arSsidLen, - ar->arSsid, - ar->arReqBssid, - ar->arChannelHint, - ar->arConnectCtrlFlags); - up(&ar->arSem); - - } else if (ar->arDot11AuthMode == SHARED_AUTH) { - /* should not reach here */ - } - } else { - ar->arConnectPending = false; - if (ar->smeState == SME_CONNECTING) { - cfg80211_connect_result(ar->arNetDev, bssid, - NULL, 0, - NULL, 0, - WLAN_STATUS_UNSPECIFIED_FAILURE, - GFP_KERNEL); - } else { - cfg80211_disconnected(ar->arNetDev, - reason, - NULL, 0, - GFP_KERNEL); - } - ar->smeState = SME_DISCONNECTED; - } - } - } else { - if (reason != DISCONNECT_CMD) - wmi_disconnect_cmd(ar->arWmi); - } -} - -void -ar6k_cfg80211_scan_node(void *arg, bss_t *ni) -{ - struct wiphy *wiphy = (struct wiphy *)arg; - u16 size; - unsigned char *ieeemgmtbuf = NULL; - struct ieee80211_mgmt *mgmt; - struct ieee80211_channel *channel; - struct ieee80211_supported_band *band; - struct ieee80211_common_ie *cie; - s32 signal; - int freq; - - cie = &ni->ni_cie; - -#define CHAN_IS_11A(x) (!((x >= 2412) && (x <= 2484))) - if(CHAN_IS_11A(cie->ie_chan)) { - /* 11a */ - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - } else if((cie->ie_erp) || (cie->ie_xrates)) { - /* 11g */ - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - } else { - /* 11b */ - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - } - - size = ni->ni_framelen + offsetof(struct ieee80211_mgmt, u); - ieeemgmtbuf = A_MALLOC_NOWAIT(size); - if(!ieeemgmtbuf) - { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ieeeMgmtbuf alloc error\n", __func__)); - return; - } - - /* Note: - TODO: Update target to include 802.11 mac header while sending bss info. - Target removes 802.11 mac header while sending the bss info to host, - cfg80211 needs it, for time being just filling the da, sa and bssid fields alone. - */ - mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf; - memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN); - memcpy(mgmt->sa, ni->ni_macaddr, ATH_MAC_LEN); - memcpy(mgmt->bssid, ni->ni_macaddr, ATH_MAC_LEN); - memcpy(ieeemgmtbuf + offsetof(struct ieee80211_mgmt, u), - ni->ni_buf, ni->ni_framelen); - - freq = cie->ie_chan; - channel = ieee80211_get_channel(wiphy, freq); - signal = ni->ni_snr * 100; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: bssid %pM channel %d freq %d size %d\n", __func__, - mgmt->bssid, channel->hw_value, freq, size)); - cfg80211_inform_bss_frame(wiphy, channel, mgmt, - le16_to_cpu(size), - signal, GFP_KERNEL); - - kfree (ieeemgmtbuf); -} - -static int -ar6k_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_scan_request *request) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - int ret = 0; - u32 forceFgScan = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if (!ar->arUserBssFilter) { - if (wmi_bssfilter_cmd(ar->arWmi, - (ar->arConnected ? ALL_BUT_BSS_FILTER : ALL_BSS_FILTER), - 0) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Couldn't set bss filtering\n", __func__)); - return -EIO; - } - } - - if(request->n_ssids && - request->ssids[0].ssid_len) { - u8 i; - - if(request->n_ssids > (MAX_PROBED_SSID_INDEX - 1)) { - request->n_ssids = MAX_PROBED_SSID_INDEX - 1; - } - - for (i = 0; i < request->n_ssids; i++) { - wmi_probedSsid_cmd(ar->arWmi, i+1, SPECIFIC_SSID_FLAG, - request->ssids[i].ssid_len, - request->ssids[i].ssid); - } - } - - if(ar->arConnected) { - forceFgScan = 1; - } - - if(wmi_startscan_cmd(ar->arWmi, WMI_LONG_SCAN, forceFgScan, false, \ - 0, 0, 0, NULL) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_startscan_cmd failed\n", __func__)); - ret = -EIO; - } - - ar->scan_request = request; - - return ret; -} - -void -ar6k_cfg80211_scanComplete_event(struct ar6_softc *ar, int status) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: status %d\n", __func__, status)); - - if (!ar->scan_request) - return; - - if ((status == A_ECANCELED) || (status == A_EBUSY)) { - cfg80211_scan_done(ar->scan_request, true); - goto out; - } - - /* Translate data to cfg80211 mgmt format */ - wmi_iterate_nodes(ar->arWmi, ar6k_cfg80211_scan_node, ar->wdev->wiphy); - - cfg80211_scan_done(ar->scan_request, false); - - if(ar->scan_request->n_ssids && - ar->scan_request->ssids[0].ssid_len) { - u8 i; - - for (i = 0; i < ar->scan_request->n_ssids; i++) { - wmi_probedSsid_cmd(ar->arWmi, i+1, DISABLE_SSID_FLAG, - 0, NULL); - } - } - -out: - ar->scan_request = NULL; -} - -static int -ar6k_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_index, bool pairwise, const u8 *mac_addr, - struct key_params *params) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - struct ar_key *key = NULL; - u8 key_usage; - u8 key_type; - int status = 0; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s:\n", __func__)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: key index %d out of bounds\n", __func__, key_index)); - return -ENOENT; - } - - key = &ar->keys[key_index]; - A_MEMZERO(key, sizeof(struct ar_key)); - - if(!mac_addr || is_broadcast_ether_addr(mac_addr)) { - key_usage = GROUP_USAGE; - } else { - key_usage = PAIRWISE_USAGE; - } - - if(params) { - if(params->key_len > WLAN_MAX_KEY_LEN || - params->seq_len > IW_ENCODE_SEQ_MAX_SIZE) - return -EINVAL; - - key->key_len = params->key_len; - memcpy(key->key, params->key, key->key_len); - key->seq_len = params->seq_len; - memcpy(key->seq, params->seq, key->seq_len); - key->cipher = params->cipher; - } - - switch (key->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - key_type = WEP_CRYPT; - break; - - case WLAN_CIPHER_SUITE_TKIP: - key_type = TKIP_CRYPT; - break; - - case WLAN_CIPHER_SUITE_CCMP: - key_type = AES_CRYPT; - break; - - default: - return -ENOTSUPP; - } - - if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) && - (GROUP_USAGE & key_usage)) - { - A_UNTIMEOUT(&ar->disconnect_timer); - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: index %d, key_len %d, key_type 0x%x,"\ - " key_usage 0x%x, seq_len %d\n", - __func__, key_index, key->key_len, key_type, - key_usage, key->seq_len)); - - ar->arDefTxKeyIndex = key_index; - status = wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex, key_type, key_usage, - key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, - (u8 *)mac_addr, SYNC_BOTH_WMIFLAG); - - - if (status) { - return -EIO; - } - - return 0; -} - -static int -ar6k_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_index, bool pairwise, const u8 *mac_addr) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: key index %d out of bounds\n", __func__, key_index)); - return -ENOENT; - } - - if(!ar->keys[key_index].key_len) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d is empty\n", __func__, key_index)); - return 0; - } - - ar->keys[key_index].key_len = 0; - - return wmi_deleteKey_cmd(ar->arWmi, key_index); -} - - -static int -ar6k_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_index, bool pairwise, const u8 *mac_addr, - void *cookie, - void (*callback)(void *cookie, struct key_params*)) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - struct ar_key *key = NULL; - struct key_params params; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: key index %d out of bounds\n", __func__, key_index)); - return -ENOENT; - } - - key = &ar->keys[key_index]; - A_MEMZERO(¶ms, sizeof(params)); - params.cipher = key->cipher; - params.key_len = key->key_len; - params.seq_len = key->seq_len; - params.seq = key->seq; - params.key = key->key; - - callback(cookie, ¶ms); - - return key->key_len ? 0 : -ENOENT; -} - - -static int -ar6k_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_index, bool unicast, bool multicast) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - struct ar_key *key = NULL; - int status = 0; - u8 key_usage; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: key index %d out of bounds\n", - __func__, key_index)); - return -ENOENT; - } - - if(!ar->keys[key_index].key_len) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: invalid key index %d\n", - __func__, key_index)); - return -EINVAL; - } - - ar->arDefTxKeyIndex = key_index; - key = &ar->keys[ar->arDefTxKeyIndex]; - key_usage = GROUP_USAGE; - if (WEP_CRYPT == ar->arPairwiseCrypto) { - key_usage |= TX_USAGE; - } - - status = wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex, - ar->arPairwiseCrypto, key_usage, - key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, - NULL, SYNC_BOTH_WMIFLAG); - if (status) { - return -EIO; - } - - return 0; -} - -static int -ar6k_cfg80211_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_index) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__)); - return -ENOTSUPP; -} - -void -ar6k_cfg80211_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, - ("%s: keyid %d, ismcast %d\n", __func__, keyid, ismcast)); - - cfg80211_michael_mic_failure(ar->arNetDev, ar->arBssid, - (ismcast ? NL80211_KEYTYPE_GROUP : NL80211_KEYTYPE_PAIRWISE), - keyid, NULL, GFP_KERNEL); -} - -static int -ar6k_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) -{ - struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: changed 0x%x\n", __func__, changed)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if (changed & WIPHY_PARAM_RTS_THRESHOLD) { - if (wmi_set_rts_cmd(ar->arWmi,wiphy->rts_threshold) != 0){ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_set_rts_cmd failed\n", __func__)); - return -EIO; - } - } - - return 0; -} - -static int -ar6k_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, - const u8 *peer, - const struct cfg80211_bitrate_mask *mask) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Setting rates: Not supported\n")); - return -EIO; -} - -/* The type nl80211_tx_power_setting replaces the following data type from 2.6.36 onwards */ -static int -ar6k_cfg80211_set_txpower(struct wiphy *wiphy, enum nl80211_tx_power_setting type, int dbm) -{ - struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy); - u8 ar_dbm; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type 0x%x, dbm %d\n", __func__, type, dbm)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - ar->arTxPwrSet = false; - switch(type) { - case NL80211_TX_POWER_AUTOMATIC: - return 0; - case NL80211_TX_POWER_LIMITED: - ar->arTxPwr = ar_dbm = dbm; - ar->arTxPwrSet = true; - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type 0x%x not supported\n", __func__, type)); - return -EOPNOTSUPP; - } - - wmi_set_txPwr_cmd(ar->arWmi, ar_dbm); - - return 0; -} - -static int -ar6k_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) -{ - struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if((ar->arConnected == true)) { - ar->arTxPwr = 0; - - if(wmi_get_txPwr_cmd(ar->arWmi) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_get_txPwr_cmd failed\n", __func__)); - return -EIO; - } - - wait_event_interruptible_timeout(arEvent, ar->arTxPwr != 0, 5 * HZ); - - if(signal_pending(current)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Target did not respond\n", __func__)); - return -EINTR; - } - } - - *dbm = ar->arTxPwr; - return 0; -} - -static int -ar6k_cfg80211_set_power_mgmt(struct wiphy *wiphy, - struct net_device *dev, - bool pmgmt, int timeout) -{ - struct ar6_softc *ar = ar6k_priv(dev); - WMI_POWER_MODE_CMD pwrMode; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: pmgmt %d, timeout %d\n", __func__, pmgmt, timeout)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(pmgmt) { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Max Perf\n", __func__)); - pwrMode.powerMode = REC_POWER; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Rec Power\n", __func__)); - pwrMode.powerMode = MAX_PERF_POWER; - } - - if(wmi_powermode_cmd(ar->arWmi, pwrMode.powerMode) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_powermode_cmd failed\n", __func__)); - return -EIO; - } - - return 0; -} - -static struct net_device * -ar6k_cfg80211_add_virtual_intf(struct wiphy *wiphy, char *name, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__)); - - /* Multiple virtual interface is not supported. - * The default interface supports STA and IBSS type - */ - return ERR_PTR(-EOPNOTSUPP); -} - -static int -ar6k_cfg80211_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__)); - - /* Multiple virtual interface is not supported. - * The default interface supports STA and IBSS type - */ - return -EOPNOTSUPP; -} - -static int -ar6k_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -{ - struct ar6_softc *ar = ar6k_priv(ndev); - struct wireless_dev *wdev = ar->wdev; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type %u\n", __func__, type)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - switch (type) { - case NL80211_IFTYPE_STATION: - ar->arNextMode = INFRA_NETWORK; - break; - case NL80211_IFTYPE_ADHOC: - ar->arNextMode = ADHOC_NETWORK; - break; - default: - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: type %u\n", __func__, type)); - return -EOPNOTSUPP; - } - - wdev->iftype = type; - - return 0; -} - -static int -ar6k_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_ibss_params *ibss_param) -{ - struct ar6_softc *ar = ar6k_priv(dev); - int status; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - if(!ibss_param->ssid_len || IEEE80211_MAX_SSID_LEN < ibss_param->ssid_len) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ssid invalid\n", __func__)); - return -EINVAL; - } - - ar->arSsidLen = ibss_param->ssid_len; - memcpy(ar->arSsid, ibss_param->ssid, ar->arSsidLen); - - if(ibss_param->channel) { - ar->arChannelHint = ibss_param->channel->center_freq; - } - - if(ibss_param->channel_fixed) { - /* TODO: channel_fixed: The channel should be fixed, do not search for - * IBSSs to join on other channels. Target firmware does not support this - * feature, needs to be updated.*/ - } - - A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid)); - if(ibss_param->bssid) { - if(memcmp(&ibss_param->bssid, bcast_mac, AR6000_ETH_ADDR_LEN)) { - memcpy(ar->arReqBssid, ibss_param->bssid, sizeof(ar->arReqBssid)); - } - } - - ar6k_set_wpa_version(ar, 0); - ar6k_set_auth_type(ar, NL80211_AUTHTYPE_OPEN_SYSTEM); - - if(ibss_param->privacy) { - ar6k_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, true); - ar6k_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, false); - } else { - ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, true); - ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, false); - } - - ar->arNetworkType = ar->arNextMode; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Connect called with authmode %d dot11 auth %d"\ - " PW crypto %d PW crypto Len %d GRP crypto %d"\ - " GRP crypto Len %d channel hint %u\n", - __func__, ar->arAuthMode, ar->arDot11AuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto, ar->arGroupCryptoLen, ar->arChannelHint)); - - status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType, - ar->arDot11AuthMode, ar->arAuthMode, - ar->arPairwiseCrypto, ar->arPairwiseCryptoLen, - ar->arGroupCrypto,ar->arGroupCryptoLen, - ar->arSsidLen, ar->arSsid, - ar->arReqBssid, ar->arChannelHint, - ar->arConnectCtrlFlags); - ar->arConnectPending = true; - - return 0; -} - -static int -ar6k_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) -{ - struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - if(ar->arWmiReady == false) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__)); - return -EIO; - } - - if(ar->arWlanState == WLAN_DISABLED) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__)); - return -EIO; - } - - ar6000_disconnect(ar); - A_MEMZERO(ar->arSsid, sizeof(ar->arSsid)); - ar->arSsidLen = 0; - - return 0; -} - -#ifdef CONFIG_NL80211_TESTMODE -enum ar6k_testmode_attr { - __AR6K_TM_ATTR_INVALID = 0, - AR6K_TM_ATTR_CMD = 1, - AR6K_TM_ATTR_DATA = 2, - - /* keep last */ - __AR6K_TM_ATTR_AFTER_LAST, - AR6K_TM_ATTR_MAX = __AR6K_TM_ATTR_AFTER_LAST - 1 -}; - -enum ar6k_testmode_cmd { - AR6K_TM_CMD_TCMD = 0, - AR6K_TM_CMD_RX_REPORT = 1, -}; - -#define AR6K_TM_DATA_MAX_LEN 5000 - -static const struct nla_policy ar6k_testmode_policy[AR6K_TM_ATTR_MAX + 1] = { - [AR6K_TM_ATTR_CMD] = { .type = NLA_U32 }, - [AR6K_TM_ATTR_DATA] = { .type = NLA_BINARY, - .len = AR6K_TM_DATA_MAX_LEN }, -}; - -void ar6000_testmode_rx_report_event(struct ar6_softc *ar, void *buf, - int buf_len) -{ - if (down_interruptible(&ar->arSem)) - return; - - kfree(ar->tcmd_rx_report); - - ar->tcmd_rx_report = kmemdup(buf, buf_len, GFP_KERNEL); - ar->tcmd_rx_report_len = buf_len; - - up(&ar->arSem); - - wake_up(&arEvent); -} - -static int ar6000_testmode_rx_report(struct ar6_softc *ar, void *buf, - int buf_len, struct sk_buff *skb) -{ - int ret = 0; - long left; - - if (down_interruptible(&ar->arSem)) - return -ERESTARTSYS; - - if (ar->arWmiReady == false) { - ret = -EIO; - goto out; - } - - if (ar->bIsDestroyProgress) { - ret = -EBUSY; - goto out; - } - - WARN_ON(ar->tcmd_rx_report != NULL); - WARN_ON(ar->tcmd_rx_report_len > 0); - - if (wmi_test_cmd(ar->arWmi, buf, buf_len) < 0) { - up(&ar->arSem); - return -EIO; - } - - left = wait_event_interruptible_timeout(arEvent, - ar->tcmd_rx_report != NULL, - wmitimeout * HZ); - - if (left == 0) { - ret = -ETIMEDOUT; - goto out; - } else if (left < 0) { - ret = left; - goto out; - } - - if (ar->tcmd_rx_report == NULL || ar->tcmd_rx_report_len == 0) { - ret = -EINVAL; - goto out; - } - - NLA_PUT(skb, AR6K_TM_ATTR_DATA, ar->tcmd_rx_report_len, - ar->tcmd_rx_report); - - kfree(ar->tcmd_rx_report); - ar->tcmd_rx_report = NULL; - -out: - up(&ar->arSem); - - return ret; - -nla_put_failure: - ret = -ENOBUFS; - goto out; -} - -static int ar6k_testmode_cmd(struct wiphy *wiphy, void *data, int len) -{ - struct ar6_softc *ar = wiphy_priv(wiphy); - struct nlattr *tb[AR6K_TM_ATTR_MAX + 1]; - int err, buf_len, reply_len; - struct sk_buff *skb; - void *buf; - - err = nla_parse(tb, AR6K_TM_ATTR_MAX, data, len, - ar6k_testmode_policy); - if (err) - return err; - - if (!tb[AR6K_TM_ATTR_CMD]) - return -EINVAL; - - switch (nla_get_u32(tb[AR6K_TM_ATTR_CMD])) { - case AR6K_TM_CMD_TCMD: - if (!tb[AR6K_TM_ATTR_DATA]) - return -EINVAL; - - buf = nla_data(tb[AR6K_TM_ATTR_DATA]); - buf_len = nla_len(tb[AR6K_TM_ATTR_DATA]); - - wmi_test_cmd(ar->arWmi, buf, buf_len); - - return 0; - - break; - case AR6K_TM_CMD_RX_REPORT: - if (!tb[AR6K_TM_ATTR_DATA]) - return -EINVAL; - - buf = nla_data(tb[AR6K_TM_ATTR_DATA]); - buf_len = nla_len(tb[AR6K_TM_ATTR_DATA]); - - reply_len = nla_total_size(AR6K_TM_DATA_MAX_LEN); - skb = cfg80211_testmode_alloc_reply_skb(wiphy, reply_len); - if (!skb) - return -ENOMEM; - - err = ar6000_testmode_rx_report(ar, buf, buf_len, skb); - if (err < 0) { - kfree_skb(skb); - return err; - } - - return cfg80211_testmode_reply(skb); - default: - return -EOPNOTSUPP; - } -} -#endif - -static const -u32 cipher_suites[] = { - WLAN_CIPHER_SUITE_WEP40, - WLAN_CIPHER_SUITE_WEP104, - WLAN_CIPHER_SUITE_TKIP, - WLAN_CIPHER_SUITE_CCMP, -}; - -bool is_rate_legacy(s32 rate) -{ - static const s32 legacy[] = { 1000, 2000, 5500, 11000, - 6000, 9000, 12000, 18000, 24000, - 36000, 48000, 54000 }; - u8 i; - - for (i = 0; i < ARRAY_SIZE(legacy); i++) { - if (rate == legacy[i]) - return true; - } - - return false; -} - -bool is_rate_ht20(s32 rate, u8 *mcs, bool *sgi) -{ - static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000, - 52000, 58500, 65000, 72200 }; - u8 i; - - for (i = 0; i < ARRAY_SIZE(ht20); i++) { - if (rate == ht20[i]) { - if (i == ARRAY_SIZE(ht20) - 1) - /* last rate uses sgi */ - *sgi = true; - else - *sgi = false; - - *mcs = i; - return true; - } - } - return false; -} - -bool is_rate_ht40(s32 rate, u8 *mcs, bool *sgi) -{ - static const s32 ht40[] = { 13500, 27000, 40500, 54000, - 81000, 108000, 121500, 135000, - 150000 }; - u8 i; - - for (i = 0; i < ARRAY_SIZE(ht40); i++) { - if (rate == ht40[i]) { - if (i == ARRAY_SIZE(ht40) - 1) - /* last rate uses sgi */ - *sgi = true; - else - *sgi = false; - - *mcs = i; - return true; - } - } - - return false; -} - -static int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_info *sinfo) -{ - struct ar6_softc *ar = ar6k_priv(dev); - long left; - bool sgi; - s32 rate; - int ret; - u8 mcs; - - if (memcmp(mac, ar->arBssid, ETH_ALEN) != 0) - return -ENOENT; - - if (down_interruptible(&ar->arSem)) - return -EBUSY; - - ar->statsUpdatePending = true; - - ret = wmi_get_stats_cmd(ar->arWmi); - - if (ret != 0) { - up(&ar->arSem); - return -EIO; - } - - left = wait_event_interruptible_timeout(arEvent, - ar->statsUpdatePending == false, - wmitimeout * HZ); - - up(&ar->arSem); - - if (left == 0) - return -ETIMEDOUT; - else if (left < 0) - return left; - - if (ar->arTargetStats.rx_bytes) { - sinfo->rx_bytes = ar->arTargetStats.rx_bytes; - sinfo->filled |= STATION_INFO_RX_BYTES; - sinfo->rx_packets = ar->arTargetStats.rx_packets; - sinfo->filled |= STATION_INFO_RX_PACKETS; - } - - if (ar->arTargetStats.tx_bytes) { - sinfo->tx_bytes = ar->arTargetStats.tx_bytes; - sinfo->filled |= STATION_INFO_TX_BYTES; - sinfo->tx_packets = ar->arTargetStats.tx_packets; - sinfo->filled |= STATION_INFO_TX_PACKETS; - } - - sinfo->signal = ar->arTargetStats.cs_rssi; - sinfo->filled |= STATION_INFO_SIGNAL; - - rate = ar->arTargetStats.tx_unicast_rate; - - if (is_rate_legacy(rate)) { - sinfo->txrate.legacy = rate / 100; - } else if (is_rate_ht20(rate, &mcs, &sgi)) { - if (sgi) { - sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; - sinfo->txrate.mcs = mcs - 1; - } else { - sinfo->txrate.mcs = mcs; - } - - sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; - } else if (is_rate_ht40(rate, &mcs, &sgi)) { - if (sgi) { - sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; - sinfo->txrate.mcs = mcs - 1; - } else { - sinfo->txrate.mcs = mcs; - } - - sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; - sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; - } else { - WARN(1, "invalid rate: %d", rate); - return 0; - } - - sinfo->filled |= STATION_INFO_TX_BITRATE; - - return 0; -} - -static int ar6k_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa) -{ - struct ar6_softc *ar = ar6k_priv(netdev); - return wmi_setPmkid_cmd(ar->arWmi, pmksa->bssid, pmksa->pmkid, true); -} - -static int ar6k_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa) -{ - struct ar6_softc *ar = ar6k_priv(netdev); - return wmi_setPmkid_cmd(ar->arWmi, pmksa->bssid, pmksa->pmkid, false); -} - -static int ar6k_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) -{ - struct ar6_softc *ar = ar6k_priv(netdev); - if (ar->arConnected) - return wmi_setPmkid_cmd(ar->arWmi, ar->arBssid, NULL, false); - return 0; -} - -static struct -cfg80211_ops ar6k_cfg80211_ops = { - .change_virtual_intf = ar6k_cfg80211_change_iface, - .add_virtual_intf = ar6k_cfg80211_add_virtual_intf, - .del_virtual_intf = ar6k_cfg80211_del_virtual_intf, - .scan = ar6k_cfg80211_scan, - .connect = ar6k_cfg80211_connect, - .disconnect = ar6k_cfg80211_disconnect, - .add_key = ar6k_cfg80211_add_key, - .get_key = ar6k_cfg80211_get_key, - .del_key = ar6k_cfg80211_del_key, - .set_default_key = ar6k_cfg80211_set_default_key, - .set_default_mgmt_key = ar6k_cfg80211_set_default_mgmt_key, - .set_wiphy_params = ar6k_cfg80211_set_wiphy_params, - .set_bitrate_mask = ar6k_cfg80211_set_bitrate_mask, - .set_tx_power = ar6k_cfg80211_set_txpower, - .get_tx_power = ar6k_cfg80211_get_txpower, - .set_power_mgmt = ar6k_cfg80211_set_power_mgmt, - .join_ibss = ar6k_cfg80211_join_ibss, - .leave_ibss = ar6k_cfg80211_leave_ibss, - .get_station = ar6k_get_station, - .set_pmksa = ar6k_set_pmksa, - .del_pmksa = ar6k_del_pmksa, - .flush_pmksa = ar6k_flush_pmksa, - CFG80211_TESTMODE_CMD(ar6k_testmode_cmd) -}; - -struct wireless_dev * -ar6k_cfg80211_init(struct device *dev) -{ - int ret = 0; - struct wireless_dev *wdev; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); - if(!wdev) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: Couldn't allocate wireless device\n", __func__)); - return ERR_PTR(-ENOMEM); - } - - /* create a new wiphy for use with cfg80211 */ - wdev->wiphy = wiphy_new(&ar6k_cfg80211_ops, sizeof(struct ar6_softc)); - if(!wdev->wiphy) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: Couldn't allocate wiphy device\n", __func__)); - kfree(wdev); - return ERR_PTR(-ENOMEM); - } - - /* set device pointer for wiphy */ - set_wiphy_dev(wdev->wiphy, dev); - - wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC); - /* max num of ssids that can be probed during scanning */ - wdev->wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; - wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &ar6k_band_2ghz; - wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &ar6k_band_5ghz; - wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - - wdev->wiphy->cipher_suites = cipher_suites; - wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); - - ret = wiphy_register(wdev->wiphy); - if(ret < 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, - ("%s: Couldn't register wiphy device\n", __func__)); - wiphy_free(wdev->wiphy); - return ERR_PTR(ret); - } - - return wdev; -} - -void -ar6k_cfg80211_deinit(struct ar6_softc *ar) -{ - struct wireless_dev *wdev = ar->wdev; - - AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__)); - - if(ar->scan_request) { - cfg80211_scan_done(ar->scan_request, true); - ar->scan_request = NULL; - } - - if(!wdev) - return; - - wiphy_unregister(wdev->wiphy); - wiphy_free(wdev->wiphy); - kfree(wdev); -} - - - - - - - diff --git a/drivers/staging/ath6kl/os/linux/export_hci_transport.c b/drivers/staging/ath6kl/os/linux/export_hci_transport.c deleted file mode 100644 index 430998edacc..00000000000 --- a/drivers/staging/ath6kl/os/linux/export_hci_transport.c +++ /dev/null @@ -1,124 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HCI bridge implementation -// -// Author(s): ="Atheros" -//============================================================================== -#include -#include -#include "a_osapi.h" -#include "htc_api.h" -#include "a_drv.h" -#include "hif.h" -#include "common_drv.h" -#include "a_debug.h" -#include "hci_transport_api.h" - -#include "AR6002/hw4.0/hw/apb_athr_wlan_map.h" -#include "AR6002/hw4.0/hw/uart_reg.h" -#include "AR6002/hw4.0/hw/rtc_wlan_reg.h" - -HCI_TRANSPORT_HANDLE (*_HCI_TransportAttach)(void *HTCHandle, struct hci_transport_config_info *pInfo); -void (*_HCI_TransportDetach)(HCI_TRANSPORT_HANDLE HciTrans); -int (*_HCI_TransportAddReceivePkts)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue); -int (*_HCI_TransportSendPkt)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous); -void (*_HCI_TransportStop)(HCI_TRANSPORT_HANDLE HciTrans); -int (*_HCI_TransportStart)(HCI_TRANSPORT_HANDLE HciTrans); -int (*_HCI_TransportEnableDisableAsyncRecv)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); -int (*_HCI_TransportRecvHCIEventSync)(HCI_TRANSPORT_HANDLE HciTrans, - struct htc_packet *pPacket, - int MaxPollMS); -int (*_HCI_TransportSetBaudRate)(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud); -int (*_HCI_TransportEnablePowerMgmt)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); - -extern struct hci_transport_callbacks ar6kHciTransCallbacks; - -int ar6000_register_hci_transport(struct hci_transport_callbacks *hciTransCallbacks) -{ - ar6kHciTransCallbacks = *hciTransCallbacks; - - _HCI_TransportAttach = HCI_TransportAttach; - _HCI_TransportDetach = HCI_TransportDetach; - _HCI_TransportAddReceivePkts = HCI_TransportAddReceivePkts; - _HCI_TransportSendPkt = HCI_TransportSendPkt; - _HCI_TransportStop = HCI_TransportStop; - _HCI_TransportStart = HCI_TransportStart; - _HCI_TransportEnableDisableAsyncRecv = HCI_TransportEnableDisableAsyncRecv; - _HCI_TransportRecvHCIEventSync = HCI_TransportRecvHCIEventSync; - _HCI_TransportSetBaudRate = HCI_TransportSetBaudRate; - _HCI_TransportEnablePowerMgmt = HCI_TransportEnablePowerMgmt; - - return 0; -} - -int -ar6000_get_hif_dev(struct hif_device *device, void *config) -{ - int status; - - status = HIFConfigureDevice(device, - HIF_DEVICE_GET_OS_DEVICE, - (struct hif_device_os_device_info *)config, - sizeof(struct hif_device_os_device_info)); - return status; -} - -int ar6000_set_uart_config(struct hif_device *hifDevice, - u32 scale, - u32 step) -{ - u32 regAddress; - u32 regVal; - int status; - - regAddress = WLAN_UART_BASE_ADDRESS | UART_CLKDIV_ADDRESS; - regVal = ((u32)scale << 16) | step; - /* change the HCI UART scale/step values through the diagnostic window */ - status = ar6000_WriteRegDiag(hifDevice, ®Address, ®Val); - - return status; -} - -int ar6000_get_core_clock_config(struct hif_device *hifDevice, u32 *data) -{ - u32 regAddress; - int status; - - regAddress = WLAN_RTC_BASE_ADDRESS | WLAN_CPU_CLOCK_ADDRESS; - /* read CPU clock settings*/ - status = ar6000_ReadRegDiag(hifDevice, ®Address, data); - - return status; -} - -EXPORT_SYMBOL(ar6000_register_hci_transport); -EXPORT_SYMBOL(ar6000_get_hif_dev); -EXPORT_SYMBOL(ar6000_set_uart_config); -EXPORT_SYMBOL(ar6000_get_core_clock_config); -EXPORT_SYMBOL(_HCI_TransportAttach); -EXPORT_SYMBOL(_HCI_TransportDetach); -EXPORT_SYMBOL(_HCI_TransportAddReceivePkts); -EXPORT_SYMBOL(_HCI_TransportSendPkt); -EXPORT_SYMBOL(_HCI_TransportStop); -EXPORT_SYMBOL(_HCI_TransportStart); -EXPORT_SYMBOL(_HCI_TransportEnableDisableAsyncRecv); -EXPORT_SYMBOL(_HCI_TransportRecvHCIEventSync); -EXPORT_SYMBOL(_HCI_TransportSetBaudRate); -EXPORT_SYMBOL(_HCI_TransportEnablePowerMgmt); diff --git a/drivers/staging/ath6kl/os/linux/hci_bridge.c b/drivers/staging/ath6kl/os/linux/hci_bridge.c deleted file mode 100644 index 6087edcb1d6..00000000000 --- a/drivers/staging/ath6kl/os/linux/hci_bridge.c +++ /dev/null @@ -1,1141 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HCI bridge implementation -// -// Author(s): ="Atheros" -//============================================================================== - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -#include -#include -#include -#include "a_osapi.h" -#include "htc_api.h" -#include "wmi.h" -#include "a_drv.h" -#include "hif.h" -#include "common_drv.h" -#include "a_debug.h" -#define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6) -#define ATH_DEBUG_HCI_RECV ATH_DEBUG_MAKE_MODULE_MASK(7) -#define ATH_DEBUG_HCI_SEND ATH_DEBUG_MAKE_MODULE_MASK(8) -#define ATH_DEBUG_HCI_DUMP ATH_DEBUG_MAKE_MODULE_MASK(9) -#else -#include "ar6000_drv.h" -#endif /* EXPORT_HCI_BRIDGE_INTERFACE */ - -#ifdef ATH_AR6K_ENABLE_GMBOX -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -#include "export_hci_transport.h" -#else -#include "hci_transport_api.h" -#endif -#include "epping_test.h" -#include "gmboxif.h" -#include "ar3kconfig.h" -#include -#include - - /* only build on newer kernels which have BT configured */ -#if defined(CONFIG_BT_MODULE) || defined(CONFIG_BT) -#define CONFIG_BLUEZ_HCI_BRIDGE -#endif - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -unsigned int ar3khcibaud = 0; -unsigned int hciuartscale = 0; -unsigned int hciuartstep = 0; - -module_param(ar3khcibaud, int, 0644); -module_param(hciuartscale, int, 0644); -module_param(hciuartstep, int, 0644); -#else -extern unsigned int ar3khcibaud; -extern unsigned int hciuartscale; -extern unsigned int hciuartstep; -#endif /* EXPORT_HCI_BRIDGE_INTERFACE */ - -struct ar6k_hci_bridge_info { - void *pHCIDev; /* HCI bridge device */ - struct hci_transport_properties HCIProps; /* HCI bridge props */ - struct hci_dev *pBtStackHCIDev; /* BT Stack HCI dev */ - bool HciNormalMode; /* Actual HCI mode enabled (non-TEST)*/ - bool HciRegistered; /* HCI device registered with stack */ - struct htc_packet_queue HTCPacketStructHead; - u8 *pHTCStructAlloc; - spinlock_t BridgeLock; -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - struct hci_transport_misc_handles HCITransHdl; -#else - struct ar6_softc *ar; -#endif /* EXPORT_HCI_BRIDGE_INTERFACE */ -}; - -#define MAX_ACL_RECV_BUFS 16 -#define MAX_EVT_RECV_BUFS 8 -#define MAX_HCI_WRITE_QUEUE_DEPTH 32 -#define MAX_ACL_RECV_LENGTH 1200 -#define MAX_EVT_RECV_LENGTH 257 -#define TX_PACKET_RSV_OFFSET 32 -#define NUM_HTC_PACKET_STRUCTS ((MAX_ACL_RECV_BUFS + MAX_EVT_RECV_BUFS + MAX_HCI_WRITE_QUEUE_DEPTH) * 2) - -#define HCI_GET_OP_CODE(p) (((u16)((p)[1])) << 8) | ((u16)((p)[0])) - -extern unsigned int setupbtdev; -struct ar3k_config_info ar3kconfig; - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -struct ar6k_hci_bridge_info *g_pHcidevInfo; -#endif - -static int bt_setup_hci(struct ar6k_hci_bridge_info *pHcidevInfo); -static void bt_cleanup_hci(struct ar6k_hci_bridge_info *pHcidevInfo); -static int bt_register_hci(struct ar6k_hci_bridge_info *pHcidevInfo); -static bool bt_indicate_recv(struct ar6k_hci_bridge_info *pHcidevInfo, - HCI_TRANSPORT_PACKET_TYPE Type, - struct sk_buff *skb); -static struct sk_buff *bt_alloc_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, int Length); -static void bt_free_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, struct sk_buff *skb); - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -int ar6000_setup_hci(void *ar); -void ar6000_cleanup_hci(void *ar); -int hci_test_send(void *ar, struct sk_buff *skb); -#else -int ar6000_setup_hci(struct ar6_softc *ar); -void ar6000_cleanup_hci(struct ar6_softc *ar); -/* HCI bridge testing */ -int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb); -#endif /* EXPORT_HCI_BRIDGE_INTERFACE */ - -#define LOCK_BRIDGE(dev) spin_lock_bh(&(dev)->BridgeLock) -#define UNLOCK_BRIDGE(dev) spin_unlock_bh(&(dev)->BridgeLock) - -static inline void FreeBtOsBuf(struct ar6k_hci_bridge_info *pHcidevInfo, void *osbuf) -{ - if (pHcidevInfo->HciNormalMode) { - bt_free_buffer(pHcidevInfo, (struct sk_buff *)osbuf); - } else { - /* in test mode, these are just ordinary netbuf allocations */ - A_NETBUF_FREE(osbuf); - } -} - -static void FreeHTCStruct(struct ar6k_hci_bridge_info *pHcidevInfo, struct htc_packet *pPacket) -{ - LOCK_BRIDGE(pHcidevInfo); - HTC_PACKET_ENQUEUE(&pHcidevInfo->HTCPacketStructHead,pPacket); - UNLOCK_BRIDGE(pHcidevInfo); -} - -static struct htc_packet * AllocHTCStruct(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - struct htc_packet *pPacket = NULL; - LOCK_BRIDGE(pHcidevInfo); - pPacket = HTC_PACKET_DEQUEUE(&pHcidevInfo->HTCPacketStructHead); - UNLOCK_BRIDGE(pHcidevInfo); - return pPacket; -} - -#define BLOCK_ROUND_UP_PWR2(x, align) (((int) (x) + ((align)-1)) & ~((align)-1)) - -static void RefillRecvBuffers(struct ar6k_hci_bridge_info *pHcidevInfo, - HCI_TRANSPORT_PACKET_TYPE Type, - int NumBuffers) -{ - int length, i; - void *osBuf = NULL; - struct htc_packet_queue queue; - struct htc_packet *pPacket; - - INIT_HTC_PACKET_QUEUE(&queue); - - if (Type == HCI_ACL_TYPE) { - if (pHcidevInfo->HciNormalMode) { - length = HCI_MAX_FRAME_SIZE; - } else { - length = MAX_ACL_RECV_LENGTH; - } - } else { - length = MAX_EVT_RECV_LENGTH; - } - - /* add on transport head and tail room */ - length += pHcidevInfo->HCIProps.HeadRoom + pHcidevInfo->HCIProps.TailRoom; - /* round up to the required I/O padding */ - length = BLOCK_ROUND_UP_PWR2(length,pHcidevInfo->HCIProps.IOBlockPad); - - for (i = 0; i < NumBuffers; i++) { - - if (pHcidevInfo->HciNormalMode) { - osBuf = bt_alloc_buffer(pHcidevInfo,length); - } else { - osBuf = A_NETBUF_ALLOC(length); - } - - if (NULL == osBuf) { - break; - } - - pPacket = AllocHTCStruct(pHcidevInfo); - if (NULL == pPacket) { - FreeBtOsBuf(pHcidevInfo,osBuf); - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to alloc HTC struct \n")); - break; - } - - SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),length,Type); - /* add to queue */ - HTC_PACKET_ENQUEUE(&queue,pPacket); - } - - if (i > 0) { - HCI_TransportAddReceivePkts(pHcidevInfo->pHCIDev, &queue); - } -} - -#define HOST_INTEREST_ITEM_ADDRESS(ar, item) \ - (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \ - (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0)) -static int ar6000_hci_transport_ready(HCI_TRANSPORT_HANDLE HCIHandle, - struct hci_transport_properties *pProps, - void *pContext) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - int status; - u32 address, hci_uart_pwr_mgmt_params; -// struct ar3k_config_info ar3kconfig; - - pHcidevInfo->pHCIDev = HCIHandle; - - memcpy(&pHcidevInfo->HCIProps,pProps,sizeof(*pProps)); - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE,("HCI ready (hci:0x%lX, headroom:%d, tailroom:%d blockpad:%d) \n", - (unsigned long)HCIHandle, - pHcidevInfo->HCIProps.HeadRoom, - pHcidevInfo->HCIProps.TailRoom, - pHcidevInfo->HCIProps.IOBlockPad)); - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - A_ASSERT((pProps->HeadRoom + pProps->TailRoom) <= (struct net_device *)(pHcidevInfo->HCITransHdl.netDevice)->hard_header_len); -#else - A_ASSERT((pProps->HeadRoom + pProps->TailRoom) <= pHcidevInfo->ar->arNetDev->hard_header_len); -#endif - - /* provide buffers */ - RefillRecvBuffers(pHcidevInfo, HCI_ACL_TYPE, MAX_ACL_RECV_BUFS); - RefillRecvBuffers(pHcidevInfo, HCI_EVENT_TYPE, MAX_EVT_RECV_BUFS); - - do { - /* start transport */ - status = HCI_TransportStart(pHcidevInfo->pHCIDev); - - if (status) { - break; - } - - if (!pHcidevInfo->HciNormalMode) { - /* in test mode, no need to go any further */ - break; - } - - // The delay is required when AR6K is driving the BT reset line - // where time is needed after the BT chip is out of reset (HCI_TransportStart) - // and before the first HCI command is issued (AR3KConfigure) - // FIXME - // The delay should be configurable and be only applied when AR6K driving the BT - // reset line. This could be done by some module parameter or based on some HW config - // info. For now apply 100ms delay blindly - A_MDELAY(100); - - A_MEMZERO(&ar3kconfig,sizeof(ar3kconfig)); - ar3kconfig.pHCIDev = pHcidevInfo->pHCIDev; - ar3kconfig.pHCIProps = &pHcidevInfo->HCIProps; -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - ar3kconfig.pHIFDevice = (struct hif_device *)(pHcidevInfo->HCITransHdl.hifDevice); -#else - ar3kconfig.pHIFDevice = pHcidevInfo->ar->arHifDevice; -#endif - ar3kconfig.pBtStackHCIDev = pHcidevInfo->pBtStackHCIDev; - - if (ar3khcibaud != 0) { - /* user wants ar3k baud rate change */ - ar3kconfig.Flags |= AR3K_CONFIG_FLAG_SET_AR3K_BAUD; - ar3kconfig.Flags |= AR3K_CONFIG_FLAG_AR3K_BAUD_CHANGE_DELAY; - ar3kconfig.AR3KBaudRate = ar3khcibaud; - } - - if ((hciuartscale != 0) || (hciuartstep != 0)) { - /* user wants to tune HCI bridge UART scale/step values */ - ar3kconfig.AR6KScale = (u16)hciuartscale; - ar3kconfig.AR6KStep = (u16)hciuartstep; - ar3kconfig.Flags |= AR3K_CONFIG_FLAG_SET_AR6K_SCALE_STEP; - } - - /* Fetch the address of the hi_hci_uart_pwr_mgmt_params instance in the host interest area */ - address = TARG_VTOP(pHcidevInfo->ar->arTargetType, - HOST_INTEREST_ITEM_ADDRESS(pHcidevInfo->ar, hi_hci_uart_pwr_mgmt_params)); - status = ar6000_ReadRegDiag(pHcidevInfo->ar->arHifDevice, &address, &hci_uart_pwr_mgmt_params); - if (0 == status) { - ar3kconfig.PwrMgmtEnabled = (hci_uart_pwr_mgmt_params & 0x1); - ar3kconfig.IdleTimeout = (hci_uart_pwr_mgmt_params & 0xFFFF0000) >> 16; - ar3kconfig.WakeupTimeout = (hci_uart_pwr_mgmt_params & 0xFF00) >> 8; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: failed to read hci_uart_pwr_mgmt_params! \n")); - } - /* configure the AR3K device */ - memcpy(ar3kconfig.bdaddr,pHcidevInfo->ar->bdaddr,6); - status = AR3KConfigure(&ar3kconfig); - if (status) { - break; - } - - /* Make sure both AR6K and AR3K have power management enabled */ - if (ar3kconfig.PwrMgmtEnabled) { - status = HCI_TransportEnablePowerMgmt(pHcidevInfo->pHCIDev, true); - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: failed to enable TLPM for AR6K! \n")); - } - } - - status = bt_register_hci(pHcidevInfo); - - } while (false); - - return status; -} - -static void ar6000_hci_transport_failure(void *pContext, int Status) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: transport failure! \n")); - - if (pHcidevInfo->HciNormalMode) { - /* TODO .. */ - } -} - -static void ar6000_hci_transport_removed(void *pContext) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE, ("HCI Bridge: transport removed. \n")); - - A_ASSERT(pHcidevInfo->pHCIDev != NULL); - - HCI_TransportDetach(pHcidevInfo->pHCIDev); - bt_cleanup_hci(pHcidevInfo); - pHcidevInfo->pHCIDev = NULL; -} - -static void ar6000_hci_send_complete(void *pContext, struct htc_packet *pPacket) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - void *osbuf = pPacket->pPktContext; - A_ASSERT(osbuf != NULL); - A_ASSERT(pHcidevInfo != NULL); - - if (pPacket->Status) { - if ((pPacket->Status != A_ECANCELED) && (pPacket->Status != A_NO_RESOURCE)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: Send Packet Failed: %d \n",pPacket->Status)); - } - } - - FreeHTCStruct(pHcidevInfo,pPacket); - FreeBtOsBuf(pHcidevInfo,osbuf); - -} - -static void ar6000_hci_pkt_recv(void *pContext, struct htc_packet *pPacket) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - struct sk_buff *skb; - - A_ASSERT(pHcidevInfo != NULL); - skb = (struct sk_buff *)pPacket->pPktContext; - A_ASSERT(skb != NULL); - - do { - - if (pPacket->Status) { - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_RECV, - ("HCI Bridge, packet received type : %d len:%d \n", - HCI_GET_PACKET_TYPE(pPacket),pPacket->ActualLength)); - - /* set the actual buffer position in the os buffer, HTC recv buffers posted to HCI are set - * to fill the front of the buffer */ - A_NETBUF_PUT(skb,pPacket->ActualLength + pHcidevInfo->HCIProps.HeadRoom); - A_NETBUF_PULL(skb,pHcidevInfo->HCIProps.HeadRoom); - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_HCI_DUMP)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("<<< Recv HCI %s packet len:%d \n", - (HCI_GET_PACKET_TYPE(pPacket) == HCI_EVENT_TYPE) ? "EVENT" : "ACL", - skb->len)); - AR_DEBUG_PRINTBUF(skb->data, skb->len,"BT HCI RECV Packet Dump"); - } - - if (pHcidevInfo->HciNormalMode) { - /* indicate the packet */ - if (bt_indicate_recv(pHcidevInfo,HCI_GET_PACKET_TYPE(pPacket),skb)) { - /* bt stack accepted the packet */ - skb = NULL; - } - break; - } - - /* for testing, indicate packet to the network stack */ -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - skb->dev = (struct net_device *)(pHcidevInfo->HCITransHdl.netDevice); - if ((((struct net_device *)pHcidevInfo->HCITransHdl.netDevice)->flags & IFF_UP) == IFF_UP) { - skb->protocol = eth_type_trans(skb, (struct net_device *)(pHcidevInfo->HCITransHdl.netDevice)); -#else - skb->dev = pHcidevInfo->ar->arNetDev; - if ((pHcidevInfo->ar->arNetDev->flags & IFF_UP) == IFF_UP) { - skb->protocol = eth_type_trans(skb, pHcidevInfo->ar->arNetDev); -#endif - netif_rx(skb); - skb = NULL; - } - - } while (false); - - FreeHTCStruct(pHcidevInfo,pPacket); - - if (skb != NULL) { - /* packet was not accepted, free it */ - FreeBtOsBuf(pHcidevInfo,skb); - } - -} - -static void ar6000_hci_pkt_refill(void *pContext, HCI_TRANSPORT_PACKET_TYPE Type, int BuffersAvailable) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - int refillCount; - - if (Type == HCI_ACL_TYPE) { - refillCount = MAX_ACL_RECV_BUFS - BuffersAvailable; - } else { - refillCount = MAX_EVT_RECV_BUFS - BuffersAvailable; - } - - if (refillCount > 0) { - RefillRecvBuffers(pHcidevInfo,Type,refillCount); - } - -} - -static HCI_SEND_FULL_ACTION ar6000_hci_pkt_send_full(void *pContext, struct htc_packet *pPacket) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)pContext; - HCI_SEND_FULL_ACTION action = HCI_SEND_FULL_KEEP; - - if (!pHcidevInfo->HciNormalMode) { - /* for epping testing, check packet tag, some epping packets are - * special and cannot be dropped */ - if (HTC_GET_TAG_FROM_PKT(pPacket) == AR6K_DATA_PKT_TAG) { - action = HCI_SEND_FULL_DROP; - } - } - - return action; -} - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -int ar6000_setup_hci(void *ar) -#else -int ar6000_setup_hci(struct ar6_softc *ar) -#endif -{ - struct hci_transport_config_info config; - int status = 0; - int i; - struct htc_packet *pPacket; - struct ar6k_hci_bridge_info *pHcidevInfo; - - - do { - - pHcidevInfo = (struct ar6k_hci_bridge_info *)A_MALLOC(sizeof(struct ar6k_hci_bridge_info)); - - if (NULL == pHcidevInfo) { - status = A_NO_MEMORY; - break; - } - - A_MEMZERO(pHcidevInfo, sizeof(struct ar6k_hci_bridge_info)); -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - g_pHcidevInfo = pHcidevInfo; - pHcidevInfo->HCITransHdl = *(struct hci_transport_misc_handles *)ar; -#else - ar->hcidev_info = pHcidevInfo; - pHcidevInfo->ar = ar; -#endif - spin_lock_init(&pHcidevInfo->BridgeLock); - INIT_HTC_PACKET_QUEUE(&pHcidevInfo->HTCPacketStructHead); - - ar->exitCallback = AR3KConfigureExit; - - status = bt_setup_hci(pHcidevInfo); - if (status) { - break; - } - - if (pHcidevInfo->HciNormalMode) { - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE, ("HCI Bridge: running in normal mode... \n")); - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE, ("HCI Bridge: running in test mode... \n")); - } - - pHcidevInfo->pHTCStructAlloc = (u8 *)A_MALLOC((sizeof(struct htc_packet)) * NUM_HTC_PACKET_STRUCTS); - - if (NULL == pHcidevInfo->pHTCStructAlloc) { - status = A_NO_MEMORY; - break; - } - - pPacket = (struct htc_packet *)pHcidevInfo->pHTCStructAlloc; - for (i = 0; i < NUM_HTC_PACKET_STRUCTS; i++,pPacket++) { - FreeHTCStruct(pHcidevInfo,pPacket); - } - - A_MEMZERO(&config,sizeof(struct hci_transport_config_info)); - config.ACLRecvBufferWaterMark = MAX_ACL_RECV_BUFS / 2; - config.EventRecvBufferWaterMark = MAX_EVT_RECV_BUFS / 2; - config.MaxSendQueueDepth = MAX_HCI_WRITE_QUEUE_DEPTH; - config.pContext = pHcidevInfo; - config.TransportFailure = ar6000_hci_transport_failure; - config.TransportReady = ar6000_hci_transport_ready; - config.TransportRemoved = ar6000_hci_transport_removed; - config.pHCISendComplete = ar6000_hci_send_complete; - config.pHCIPktRecv = ar6000_hci_pkt_recv; - config.pHCIPktRecvRefill = ar6000_hci_pkt_refill; - config.pHCISendFull = ar6000_hci_pkt_send_full; - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - pHcidevInfo->pHCIDev = HCI_TransportAttach(pHcidevInfo->HCITransHdl.htcHandle, &config); -#else - pHcidevInfo->pHCIDev = HCI_TransportAttach(ar->arHtcTarget, &config); -#endif - - if (NULL == pHcidevInfo->pHCIDev) { - status = A_ERROR; - } - - } while (false); - - if (status) { - if (pHcidevInfo != NULL) { - if (NULL == pHcidevInfo->pHCIDev) { - /* GMBOX may not be present in older chips */ - /* just return success */ - status = 0; - } - } - ar6000_cleanup_hci(ar); - } - - return status; -} - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -void ar6000_cleanup_hci(void *ar) -#else -void ar6000_cleanup_hci(struct ar6_softc *ar) -#endif -{ -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - struct ar6k_hci_bridge_info *pHcidevInfo = g_pHcidevInfo; -#else - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)ar->hcidev_info; -#endif - - if (pHcidevInfo != NULL) { - bt_cleanup_hci(pHcidevInfo); - - if (pHcidevInfo->pHCIDev != NULL) { - HCI_TransportStop(pHcidevInfo->pHCIDev); - HCI_TransportDetach(pHcidevInfo->pHCIDev); - pHcidevInfo->pHCIDev = NULL; - } - - if (pHcidevInfo->pHTCStructAlloc != NULL) { - kfree(pHcidevInfo->pHTCStructAlloc); - pHcidevInfo->pHTCStructAlloc = NULL; - } - - kfree(pHcidevInfo); -#ifndef EXPORT_HCI_BRIDGE_INTERFACE - ar->hcidev_info = NULL; -#endif - } - - -} - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -int hci_test_send(void *ar, struct sk_buff *skb) -#else -int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb) -#endif -{ - int status = 0; - int length; - EPPING_HEADER *pHeader; - struct htc_packet *pPacket; - HTC_TX_TAG htc_tag = AR6K_DATA_PKT_TAG; -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - struct ar6k_hci_bridge_info *pHcidevInfo = g_pHcidevInfo; -#else - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)ar->hcidev_info; -#endif - - do { - - if (NULL == pHcidevInfo) { - status = A_ERROR; - break; - } - - if (NULL == pHcidevInfo->pHCIDev) { - status = A_ERROR; - break; - } - - if (pHcidevInfo->HciNormalMode) { - /* this interface cannot run when normal WMI is running */ - status = A_ERROR; - break; - } - - pHeader = (EPPING_HEADER *)A_NETBUF_DATA(skb); - - if (!IS_EPPING_PACKET(pHeader)) { - status = A_EINVAL; - break; - } - - if (IS_EPING_PACKET_NO_DROP(pHeader)) { - htc_tag = AR6K_CONTROL_PKT_TAG; - } - - length = sizeof(EPPING_HEADER) + pHeader->DataLength; - - pPacket = AllocHTCStruct(pHcidevInfo); - if (NULL == pPacket) { - status = A_NO_MEMORY; - break; - } - - SET_HTC_PACKET_INFO_TX(pPacket, - skb, - A_NETBUF_DATA(skb), - length, - HCI_ACL_TYPE, /* send every thing out as ACL */ - htc_tag); - - HCI_TransportSendPkt(pHcidevInfo->pHCIDev,pPacket,false); - pPacket = NULL; - - } while (false); - - return status; -} - -void ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig) -{ - struct ar6k_hci_bridge_info *pHcidevInfo = (struct ar6k_hci_bridge_info *)ar->hcidev_info; - struct ar3k_config_info *config = (struct ar3k_config_info *)ar3kconfig; - - config->pHCIDev = pHcidevInfo->pHCIDev; - config->pHCIProps = &pHcidevInfo->HCIProps; - config->pHIFDevice = ar->arHifDevice; - config->pBtStackHCIDev = pHcidevInfo->pBtStackHCIDev; - config->Flags |= AR3K_CONFIG_FLAG_SET_AR3K_BAUD; - config->AR3KBaudRate = 115200; -} - -#ifdef CONFIG_BLUEZ_HCI_BRIDGE -/*** BT Stack Entrypoints *******/ - -/* - * bt_open - open a handle to the device -*/ -static int bt_open(struct hci_dev *hdev) -{ - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_open - enter - x\n")); - set_bit(HCI_RUNNING, &hdev->flags); - set_bit(HCI_UP, &hdev->flags); - set_bit(HCI_INIT, &hdev->flags); - return 0; -} - -/* - * bt_close - close handle to the device -*/ -static int bt_close(struct hci_dev *hdev) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_close - enter\n")); - clear_bit(HCI_RUNNING, &hdev->flags); - return 0; -} - -/* - * bt_send_frame - send data frames -*/ -static int bt_send_frame(struct sk_buff *skb) -{ - struct hci_dev *hdev = (struct hci_dev *)skb->dev; - HCI_TRANSPORT_PACKET_TYPE type; - struct ar6k_hci_bridge_info *pHcidevInfo; - struct htc_packet *pPacket; - int status = 0; - struct sk_buff *txSkb = NULL; - - if (!hdev) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HCI Bridge: bt_send_frame - no device\n")); - return -ENODEV; - } - - if (!test_bit(HCI_RUNNING, &hdev->flags)) { - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_send_frame - not open\n")); - return -EBUSY; - } - - pHcidevInfo = (struct ar6k_hci_bridge_info *)hdev->driver_data; - A_ASSERT(pHcidevInfo != NULL); - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_SEND, ("+bt_send_frame type: %d \n",bt_cb(skb)->pkt_type)); - type = HCI_COMMAND_TYPE; - - switch (bt_cb(skb)->pkt_type) { - case HCI_COMMAND_PKT: - type = HCI_COMMAND_TYPE; - hdev->stat.cmd_tx++; - break; - - case HCI_ACLDATA_PKT: - type = HCI_ACL_TYPE; - hdev->stat.acl_tx++; - break; - - case HCI_SCODATA_PKT: - /* we don't support SCO over the bridge */ - kfree_skb(skb); - return 0; - default: - A_ASSERT(false); - kfree_skb(skb); - return 0; - } - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_HCI_DUMP)) { - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,(">>> Send HCI %s packet len: %d\n", - (type == HCI_COMMAND_TYPE) ? "COMMAND" : "ACL", - skb->len)); - if (type == HCI_COMMAND_TYPE) { - u16 opcode = HCI_GET_OP_CODE(skb->data); - AR_DEBUG_PRINTF(ATH_DEBUG_ANY,(" HCI Command: OGF:0x%X OCF:0x%X \r\n", - opcode >> 10, opcode & 0x3FF)); - } - AR_DEBUG_PRINTBUF(skb->data,skb->len,"BT HCI SEND Packet Dump"); - } - - do { - - txSkb = bt_skb_alloc(TX_PACKET_RSV_OFFSET + pHcidevInfo->HCIProps.HeadRoom + - pHcidevInfo->HCIProps.TailRoom + skb->len, - GFP_ATOMIC); - - if (txSkb == NULL) { - status = A_NO_MEMORY; - break; - } - - bt_cb(txSkb)->pkt_type = bt_cb(skb)->pkt_type; - txSkb->dev = (void *)pHcidevInfo->pBtStackHCIDev; - skb_reserve(txSkb, TX_PACKET_RSV_OFFSET + pHcidevInfo->HCIProps.HeadRoom); - memcpy(txSkb->data, skb->data, skb->len); - skb_put(txSkb,skb->len); - - pPacket = AllocHTCStruct(pHcidevInfo); - if (NULL == pPacket) { - status = A_NO_MEMORY; - break; - } - - /* HCI packet length here doesn't include the 1-byte transport header which - * will be handled by the HCI transport layer. Enough headroom has already - * been reserved above for the transport header - */ - SET_HTC_PACKET_INFO_TX(pPacket, - txSkb, - txSkb->data, - txSkb->len, - type, - AR6K_CONTROL_PKT_TAG); /* HCI packets cannot be dropped */ - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_SEND, ("HCI Bridge: bt_send_frame skb:0x%lX \n",(unsigned long)txSkb)); - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_SEND, ("HCI Bridge: type:%d, Total Length:%d Bytes \n", - type, txSkb->len)); - - status = HCI_TransportSendPkt(pHcidevInfo->pHCIDev,pPacket,false); - pPacket = NULL; - txSkb = NULL; - - } while (false); - - if (txSkb != NULL) { - kfree_skb(txSkb); - } - - kfree_skb(skb); - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_SEND, ("-bt_send_frame \n")); - return 0; -} - -/* - * bt_ioctl - ioctl processing -*/ -static int bt_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_ioctl - enter\n")); - return -ENOIOCTLCMD; -} - -/* - * bt_flush - flush outstandingbpackets -*/ -static int bt_flush(struct hci_dev *hdev) -{ - struct ar6k_hci_bridge_info *pHcidevInfo; - - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_flush - enter\n")); - - pHcidevInfo = (struct ar6k_hci_bridge_info *)hdev->driver_data; - - /* TODO??? */ - - return 0; -} - - -/* - * bt_destruct - -*/ -static void bt_destruct(struct hci_dev *hdev) -{ - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HCI Bridge: bt_destruct - enter\n")); - /* nothing to do here */ -} - -static int bt_setup_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - int status = 0; - struct hci_dev *pHciDev = NULL; - struct hif_device_os_device_info osDevInfo; - - if (!setupbtdev) { - return 0; - } - - do { - - A_MEMZERO(&osDevInfo,sizeof(osDevInfo)); - /* get the underlying OS device */ -#ifdef EXPORT_HCI_BRIDGE_INTERFACE - status = ar6000_get_hif_dev((struct hif_device *)(pHcidevInfo->HCITransHdl.hifDevice), - &osDevInfo); -#else - status = HIFConfigureDevice(pHcidevInfo->ar->arHifDevice, - HIF_DEVICE_GET_OS_DEVICE, - &osDevInfo, - sizeof(osDevInfo)); -#endif - - if (status) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to OS device info from HIF\n")); - break; - } - - /* allocate a BT HCI struct for this device */ - pHciDev = hci_alloc_dev(); - if (NULL == pHciDev) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge - failed to allocate bt struct \n")); - status = A_NO_MEMORY; - break; - } - /* save the device, we'll register this later */ - pHcidevInfo->pBtStackHCIDev = pHciDev; - SET_HCIDEV_DEV(pHciDev,osDevInfo.pOSDevice); - SET_HCI_BUS_TYPE(pHciDev, HCI_VIRTUAL, HCI_BREDR); - pHciDev->driver_data = pHcidevInfo; - pHciDev->open = bt_open; - pHciDev->close = bt_close; - pHciDev->send = bt_send_frame; - pHciDev->ioctl = bt_ioctl; - pHciDev->flush = bt_flush; - pHciDev->destruct = bt_destruct; - pHciDev->owner = THIS_MODULE; - /* driver is running in normal BT mode */ - pHcidevInfo->HciNormalMode = true; - - } while (false); - - if (status) { - bt_cleanup_hci(pHcidevInfo); - } - - return status; -} - -static void bt_cleanup_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - int err; - - if (pHcidevInfo->HciRegistered) { - pHcidevInfo->HciRegistered = false; - clear_bit(HCI_RUNNING, &pHcidevInfo->pBtStackHCIDev->flags); - clear_bit(HCI_UP, &pHcidevInfo->pBtStackHCIDev->flags); - clear_bit(HCI_INIT, &pHcidevInfo->pBtStackHCIDev->flags); - A_ASSERT(pHcidevInfo->pBtStackHCIDev != NULL); - /* unregister */ - if ((err = hci_unregister_dev(pHcidevInfo->pBtStackHCIDev)) < 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: failed to unregister with bluetooth %d\n",err)); - } - } - - kfree(pHcidevInfo->pBtStackHCIDev); - pHcidevInfo->pBtStackHCIDev = NULL; -} - -static int bt_register_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - int err; - int status = 0; - - do { - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE, ("HCI Bridge: registering HCI... \n")); - A_ASSERT(pHcidevInfo->pBtStackHCIDev != NULL); - /* mark that we are registered */ - pHcidevInfo->HciRegistered = true; - if ((err = hci_register_dev(pHcidevInfo->pBtStackHCIDev)) < 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: failed to register with bluetooth %d\n",err)); - pHcidevInfo->HciRegistered = false; - status = A_ERROR; - break; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_BRIDGE, ("HCI Bridge: HCI registered \n")); - - } while (false); - - return status; -} - -static bool bt_indicate_recv(struct ar6k_hci_bridge_info *pHcidevInfo, - HCI_TRANSPORT_PACKET_TYPE Type, - struct sk_buff *skb) -{ - u8 btType; - int len; - bool success = false; - BT_HCI_EVENT_HEADER *pEvent; - - do { - - if (!test_bit(HCI_RUNNING, &pHcidevInfo->pBtStackHCIDev->flags)) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HCI Bridge: bt_indicate_recv - not running\n")); - break; - } - - switch (Type) { - case HCI_ACL_TYPE: - btType = HCI_ACLDATA_PKT; - break; - case HCI_EVENT_TYPE: - btType = HCI_EVENT_PKT; - break; - default: - btType = 0; - A_ASSERT(false); - break; - } - - if (0 == btType) { - break; - } - - /* set the final type */ - bt_cb(skb)->pkt_type = btType; - /* set dev */ - skb->dev = (void *)pHcidevInfo->pBtStackHCIDev; - len = skb->len; - - if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_HCI_RECV)) { - if (bt_cb(skb)->pkt_type == HCI_EVENT_PKT) { - pEvent = (BT_HCI_EVENT_HEADER *)skb->data; - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_RECV, ("BT HCI EventCode: %d, len:%d \n", - pEvent->EventCode, pEvent->ParamLength)); - } - } - - /* pass receive packet up the stack */ - if (hci_recv_frame(skb) != 0) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: hci_recv_frame failed \n")); - break; - } else { - AR_DEBUG_PRINTF(ATH_DEBUG_HCI_RECV, - ("HCI Bridge: Indicated RCV of type:%d, Length:%d \n",btType,len)); - } - - success = true; - - } while (false); - - return success; -} - -static struct sk_buff* bt_alloc_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, int Length) -{ - struct sk_buff *skb; - /* in normal HCI mode we need to alloc from the bt core APIs */ - skb = bt_skb_alloc(Length, GFP_ATOMIC); - if (NULL == skb) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to alloc bt sk_buff \n")); - } - return skb; -} - -static void bt_free_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, struct sk_buff *skb) -{ - kfree_skb(skb); -} - -#else // { CONFIG_BLUEZ_HCI_BRIDGE - - /* stubs when we only want to test the HCI bridging Interface without the HT stack */ -static int bt_setup_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - return 0; -} -static void bt_cleanup_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - -} -static int bt_register_hci(struct ar6k_hci_bridge_info *pHcidevInfo) -{ - A_ASSERT(false); - return A_ERROR; -} - -static bool bt_indicate_recv(struct ar6k_hci_bridge_info *pHcidevInfo, - HCI_TRANSPORT_PACKET_TYPE Type, - struct sk_buff *skb) -{ - A_ASSERT(false); - return false; -} - -static struct sk_buff* bt_alloc_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, int Length) -{ - A_ASSERT(false); - return NULL; -} -static void bt_free_buffer(struct ar6k_hci_bridge_info *pHcidevInfo, struct sk_buff *skb) -{ - A_ASSERT(false); -} - -#endif // } CONFIG_BLUEZ_HCI_BRIDGE - -#else // { ATH_AR6K_ENABLE_GMBOX - - /* stubs when GMBOX support is not needed */ - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -int ar6000_setup_hci(void *ar) -#else -int ar6000_setup_hci(struct ar6_softc *ar) -#endif -{ - return 0; -} - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -void ar6000_cleanup_hci(void *ar) -#else -void ar6000_cleanup_hci(struct ar6_softc *ar) -#endif -{ - return; -} - -#ifndef EXPORT_HCI_BRIDGE_INTERFACE -void ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig) -{ - return; -} -#endif - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -int hci_test_send(void *ar, struct sk_buff *skb) -#else -int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb) -#endif -{ - return -EOPNOTSUPP; -} - -#endif // } ATH_AR6K_ENABLE_GMBOX - - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -static int __init -hcibridge_init_module(void) -{ - int status; - struct hci_transport_callbacks hciTransCallbacks; - - hciTransCallbacks.setupTransport = ar6000_setup_hci; - hciTransCallbacks.cleanupTransport = ar6000_cleanup_hci; - - status = ar6000_register_hci_transport(&hciTransCallbacks); - if (status) - return -ENODEV; - - return 0; -} - -static void __exit -hcibridge_cleanup_module(void) -{ -} - -module_init(hcibridge_init_module); -module_exit(hcibridge_cleanup_module); -MODULE_LICENSE("Dual BSD/GPL"); -#endif diff --git a/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h b/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h deleted file mode 100644 index 80cef77738f..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h +++ /dev/null @@ -1,776 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _AR6000_H_ -#define _AR6000_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "a_osapi.h" -#include "htc_api.h" -#include "wmi.h" -#include "a_drv.h" -#include "bmi.h" -#include -#include -#include -#include -#include "pkt_log.h" -#include "aggr_recv_api.h" -#include -#include -#include -#include "ar6000_api.h" -#ifdef CONFIG_HOST_TCMD_SUPPORT -#include -#endif -#include - -#include "targaddrs.h" -#include "dbglog_api.h" -#include "ar6000_diag.h" -#include "common_drv.h" -#include "roaming.h" -#include "hci_transport_api.h" -#define ATH_MODULE_NAME driver -#include "a_debug.h" -#include "hw/apb_map.h" -#include "hw/rtc_reg.h" -#include "hw/mbox_reg.h" -#include "gpio_reg.h" - -#define ATH_DEBUG_DBG_LOG ATH_DEBUG_MAKE_MODULE_MASK(0) -#define ATH_DEBUG_WLAN_CONNECT ATH_DEBUG_MAKE_MODULE_MASK(1) -#define ATH_DEBUG_WLAN_SCAN ATH_DEBUG_MAKE_MODULE_MASK(2) -#define ATH_DEBUG_WLAN_TX ATH_DEBUG_MAKE_MODULE_MASK(3) -#define ATH_DEBUG_WLAN_RX ATH_DEBUG_MAKE_MODULE_MASK(4) -#define ATH_DEBUG_HTC_RAW ATH_DEBUG_MAKE_MODULE_MASK(5) -#define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6) -#define ATH_DEBUG_HCI_RECV ATH_DEBUG_MAKE_MODULE_MASK(7) -#define ATH_DEBUG_HCI_SEND ATH_DEBUG_MAKE_MODULE_MASK(8) -#define ATH_DEBUG_HCI_DUMP ATH_DEBUG_MAKE_MODULE_MASK(9) - -#ifndef __dev_put -#define __dev_put(dev) dev_put(dev) -#endif - - -#define USER_SAVEDKEYS_STAT_INIT 0 -#define USER_SAVEDKEYS_STAT_RUN 1 - -// TODO this needs to move into the AR_SOFTC struct -struct USER_SAVEDKEYS { - struct ieee80211req_key ucast_ik; - struct ieee80211req_key bcast_ik; - CRYPTO_TYPE keyType; - bool keyOk; -}; - -#define DBG_INFO 0x00000001 -#define DBG_ERROR 0x00000002 -#define DBG_WARNING 0x00000004 -#define DBG_SDIO 0x00000008 -#define DBG_HIF 0x00000010 -#define DBG_HTC 0x00000020 -#define DBG_WMI 0x00000040 -#define DBG_WMI2 0x00000080 -#define DBG_DRIVER 0x00000100 - -#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING) - - -int ar6000_ReadRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); -int ar6000_WriteRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data); - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAX_AR6000 1 -#define AR6000_MAX_RX_BUFFERS 16 -#define AR6000_BUFFER_SIZE 1664 -#define AR6000_MAX_AMSDU_RX_BUFFERS 4 -#define AR6000_AMSDU_REFILL_THRESHOLD 3 -#define AR6000_AMSDU_BUFFER_SIZE (WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH + 128) -#define AR6000_MAX_RX_MESSAGE_SIZE (max(WMI_MAX_NORMAL_RX_DATA_FRAME_LENGTH,WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH)) - -#define AR6000_TX_TIMEOUT 10 -#define AR6000_ETH_ADDR_LEN 6 -#define AR6000_MAX_ENDPOINTS 4 -#define MAX_NODE_NUM 15 -/* MAX_HI_COOKIE_NUM are reserved for high priority traffic */ -#define MAX_DEF_COOKIE_NUM 180 -#define MAX_HI_COOKIE_NUM 18 /* 10% of MAX_COOKIE_NUM */ -#define MAX_COOKIE_NUM (MAX_DEF_COOKIE_NUM + MAX_HI_COOKIE_NUM) - -/* MAX_DEFAULT_SEND_QUEUE_DEPTH is used to set the default queue depth for the - * WMM send queues. If a queue exceeds this depth htc will query back to the - * OS specific layer by calling EpSendFull(). This gives the OS layer the - * opportunity to drop the packet if desired. Therefore changing - * MAX_DEFAULT_SEND_QUEUE_DEPTH does not affect resource utilization but - * does impact the threshold used to identify if a packet should be - * dropped. */ -#define MAX_DEFAULT_SEND_QUEUE_DEPTH (MAX_DEF_COOKIE_NUM / WMM_NUM_AC) - -#define AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT 1 -#define AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT 1 -#define A_DISCONNECT_TIMER_INTERVAL 10 * 1000 -#define A_DEFAULT_LISTEN_INTERVAL 100 -#define A_MAX_WOW_LISTEN_INTERVAL 1000 - -enum { - DRV_HB_CHALLENGE = 0, - APP_HB_CHALLENGE -}; - -enum { - WLAN_INIT_MODE_NONE = 0, - WLAN_INIT_MODE_USR, - WLAN_INIT_MODE_UDEV, - WLAN_INIT_MODE_DRV -}; - -/* Suspend - configuration */ -enum { - WLAN_SUSPEND_CUT_PWR = 0, - WLAN_SUSPEND_DEEP_SLEEP, - WLAN_SUSPEND_WOW, - WLAN_SUSPEND_CUT_PWR_IF_BT_OFF -}; - -/* WiFi OFF - configuration */ -enum { - WLAN_OFF_CUT_PWR = 0, - WLAN_OFF_DEEP_SLEEP, -}; - -/* WLAN low power state */ -enum { - WLAN_POWER_STATE_ON = 0, - WLAN_POWER_STATE_CUT_PWR = 1, - WLAN_POWER_STATE_DEEP_SLEEP, - WLAN_POWER_STATE_WOW -}; - -/* WLAN WoW State */ -enum { - WLAN_WOW_STATE_NONE = 0, - WLAN_WOW_STATE_SUSPENDED, - WLAN_WOW_STATE_SUSPENDING -}; - - -typedef enum _AR6K_BIN_FILE { - AR6K_OTP_FILE, - AR6K_FIRMWARE_FILE, - AR6K_PATCH_FILE, - AR6K_BOARD_DATA_FILE, -} AR6K_BIN_FILE; - -#ifdef SETUPHCI_ENABLED -#define SETUPHCI_DEFAULT 1 -#else -#define SETUPHCI_DEFAULT 0 -#endif /* SETUPHCI_ENABLED */ - -#ifdef SETUPBTDEV_ENABLED -#define SETUPBTDEV_DEFAULT 1 -#else -#define SETUPBTDEV_DEFAULT 0 -#endif /* SETUPBTDEV_ENABLED */ - -#ifdef ENABLEUARTPRINT_SET -#define ENABLEUARTPRINT_DEFAULT 1 -#else -#define ENABLEUARTPRINT_DEFAULT 0 -#endif /* ENABLEARTPRINT_SET */ - -#ifdef ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER -#define NOHIFSCATTERSUPPORT_DEFAULT 1 -#else /* ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER */ -#define NOHIFSCATTERSUPPORT_DEFAULT 0 -#endif /* ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER */ - - -#if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE) - -#ifdef CONFIG_AR600x_BT_QCOM -#define ATH6KL_BT_DEV 1 -#elif defined(CONFIG_AR600x_BT_CSR) -#define ATH6KL_BT_DEV 2 -#else -#define ATH6KL_BT_DEV 3 -#endif - -#ifdef CONFIG_AR600x_DUAL_ANTENNA -#define ATH6KL_BT_ANTENNA 2 -#else -#define ATH6KL_BT_ANTENNA 1 -#endif - -#endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */ - -#ifdef AR600x_BT_AR3001 -#define AR3KHCIBAUD_DEFAULT 3000000 -#define HCIUARTSCALE_DEFAULT 1 -#define HCIUARTSTEP_DEFAULT 8937 -#else -#define AR3KHCIBAUD_DEFAULT 0 -#define HCIUARTSCALE_DEFAULT 0 -#define HCIUARTSTEP_DEFAULT 0 -#endif /* AR600x_BT_AR3001 */ - -#define WLAN_INIT_MODE_DEFAULT WLAN_INIT_MODE_DRV - -#define AR6K_PATCH_DOWNLOAD_ADDRESS(_param, _ver) do { \ - if ((_ver) == AR6003_REV1_VERSION) { \ - (_param) = AR6003_REV1_PATCH_DOWNLOAD_ADDRESS; \ - } else if ((_ver) == AR6003_REV2_VERSION) { \ - (_param) = AR6003_REV2_PATCH_DOWNLOAD_ADDRESS; \ - } else { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \ - A_ASSERT(0); \ - } \ -} while (0) - -#define AR6K_DATA_DOWNLOAD_ADDRESS(_param, _ver) do { \ - if ((_ver) == AR6003_REV1_VERSION) { \ - (_param) = AR6003_REV1_DATA_DOWNLOAD_ADDRESS; \ - } else if ((_ver) == AR6003_REV2_VERSION) { \ - (_param) = AR6003_REV2_DATA_DOWNLOAD_ADDRESS; \ - } else { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \ - A_ASSERT(0); \ - } \ -} while (0) - -#define AR6K_DATASET_PATCH_ADDRESS(_param, _ver) do { \ - if ((_ver) == AR6003_REV2_VERSION) { \ - (_param) = AR6003_REV2_DATASET_PATCH_ADDRESS; \ - } else if ((_ver) == AR6003_REV3_VERSION) { \ - (_param) = AR6003_REV3_DATASET_PATCH_ADDRESS; \ - } else { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \ - A_ASSERT(0); \ - } \ -} while (0) - -#define AR6K_APP_LOAD_ADDRESS(_param, _ver) do { \ - if ((_ver) == AR6003_REV2_VERSION) { \ - (_param) = AR6003_REV2_APP_LOAD_ADDRESS; \ - } else if ((_ver) == AR6003_REV3_VERSION) { \ - (_param) = AR6003_REV3_APP_LOAD_ADDRESS; \ - } else { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \ - A_ASSERT(0); \ - } \ -} while (0) - -#define AR6K_APP_START_OVERRIDE_ADDRESS(_param, _ver) do { \ - if ((_ver) == AR6003_REV2_VERSION) { \ - (_param) = AR6003_REV2_APP_START_OVERRIDE; \ - } else if ((_ver) == AR6003_REV3_VERSION) { \ - (_param) = AR6003_REV3_APP_START_OVERRIDE; \ - } else { \ - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \ - A_ASSERT(0); \ - } \ -} while (0) - -/* AR6003 1.0 definitions */ -#define AR6003_REV1_VERSION 0x300002ba -#define AR6003_REV1_DATA_DOWNLOAD_ADDRESS AR6003_REV1_OTP_DATA_ADDRESS -#define AR6003_REV1_PATCH_DOWNLOAD_ADDRESS 0x57ea6c -#define AR6003_REV1_OTP_FILE "ath6k/AR6003/hw1.0/otp.bin.z77" -#define AR6003_REV1_FIRMWARE_FILE "ath6k/AR6003/hw1.0/athwlan.bin.z77" -#define AR6003_REV1_TCMD_FIRMWARE_FILE "ath6k/AR6003/hw1.0/athtcmd_ram.bin" -#define AR6003_REV1_ART_FIRMWARE_FILE "ath6k/AR6003/hw1.0/device.bin" -#define AR6003_REV1_PATCH_FILE "ath6k/AR6003/hw1.0/data.patch.bin" -#define AR6003_REV1_EPPING_FIRMWARE_FILE "ath6k/AR6003/hw1.0/endpointping.bin" -#ifdef CONFIG_AR600x_SD31_XXX -#define AR6003_REV1_BOARD_DATA_FILE "ath6k/AR6003/hw1.0/bdata.SD31.bin" -#elif defined(CONFIG_AR600x_SD32_XXX) -#define AR6003_REV1_BOARD_DATA_FILE "ath6k/AR6003/hw1.0/bdata.SD32.bin" -#elif defined(CONFIG_AR600x_WB31_XXX) -#define AR6003_REV1_BOARD_DATA_FILE "ath6k/AR6003/hw1.0/bdata.WB31.bin" -#else -#define AR6003_REV1_BOARD_DATA_FILE "ath6k/AR6003/hw1.0/bdata.CUSTOM.bin" -#endif /* Board Data File */ - -/* AR6003 2.0 definitions */ -#define AR6003_REV2_VERSION 0x30000384 -#define AR6003_REV2_DATA_DOWNLOAD_ADDRESS AR6003_REV2_OTP_DATA_ADDRESS -#define AR6003_REV2_PATCH_DOWNLOAD_ADDRESS 0x57e910 -#define AR6003_REV2_OTP_FILE "ath6k/AR6003/hw2.0/otp.bin.z77" -#define AR6003_REV2_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athwlan.bin.z77" -#define AR6003_REV2_TCMD_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athtcmd_ram.bin" -#define AR6003_REV2_ART_FIRMWARE_FILE "ath6k/AR6003/hw2.0/device.bin" -#define AR6003_REV2_PATCH_FILE "ath6k/AR6003/hw2.0/data.patch.bin" -#define AR6003_REV2_EPPING_FIRMWARE_FILE "ath6k/AR6003/hw2.0/endpointping.bin" -#ifdef CONFIG_AR600x_SD31_XXX -#define AR6003_REV2_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.SD31.bin" -#elif defined(CONFIG_AR600x_SD32_XXX) -#define AR6003_REV2_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.SD32.bin" -#elif defined(CONFIG_AR600x_WB31_XXX) -#define AR6003_REV2_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.WB31.bin" -#else -#define AR6003_REV2_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.CUSTOM.bin" -#endif /* Board Data File */ - -/* AR6003 3.0 definitions */ -#define AR6003_REV3_VERSION 0x30000582 -#define AR6003_REV3_OTP_FILE "ath6k/AR6003/hw2.1.1/otp.bin" -#define AR6003_REV3_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/athwlan.bin" -#define AR6003_REV3_TCMD_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/athtcmd_ram.bin" -#define AR6003_REV3_ART_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/device.bin" -#define AR6003_REV3_PATCH_FILE "ath6k/AR6003/hw2.1.1/data.patch.bin" -#define AR6003_REV3_EPPING_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/endpointping.bin" -#ifdef CONFIG_AR600x_SD31_XXX -#define AR6003_REV3_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.SD31.bin" -#elif defined(CONFIG_AR600x_SD32_XXX) -#define AR6003_REV3_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.SD32.bin" -#elif defined(CONFIG_AR600x_WB31_XXX) -#define AR6003_REV3_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.WB31.bin" -#else -#define AR6003_REV3_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.CUSTOM.bin" -#endif /* Board Data File */ - - -/* Power states */ -enum { - WLAN_PWR_CTRL_UP = 0, - WLAN_PWR_CTRL_CUT_PWR, - WLAN_PWR_CTRL_DEEP_SLEEP, - WLAN_PWR_CTRL_WOW, - WLAN_PWR_CTRL_DEEP_SLEEP_DISABLED -}; - -/* HTC RAW streams */ -typedef enum _HTC_RAW_STREAM_ID { - HTC_RAW_STREAM_NOT_MAPPED = -1, - HTC_RAW_STREAM_0 = 0, - HTC_RAW_STREAM_1 = 1, - HTC_RAW_STREAM_2 = 2, - HTC_RAW_STREAM_3 = 3, - HTC_RAW_STREAM_NUM_MAX -} HTC_RAW_STREAM_ID; - -#define RAW_HTC_READ_BUFFERS_NUM 4 -#define RAW_HTC_WRITE_BUFFERS_NUM 4 - -#define HTC_RAW_BUFFER_SIZE 1664 - -typedef struct { - int currPtr; - int length; - unsigned char data[HTC_RAW_BUFFER_SIZE]; - struct htc_packet HTCPacket; -} raw_htc_buffer; - -#ifdef CONFIG_HOST_TCMD_SUPPORT -/* - * add TCMD_MODE besides wmi and bypasswmi - * in TCMD_MODE, only few TCMD releated wmi commands - * counld be hanlder - */ -enum { - AR6000_WMI_MODE = 0, - AR6000_BYPASS_MODE, - AR6000_TCMD_MODE, - AR6000_WLAN_MODE -}; -#endif /* CONFIG_HOST_TCMD_SUPPORT */ - -struct ar_wep_key { - u8 arKeyIndex; - u8 arKeyLen; - u8 arKey[64]; -} ; - -struct ar_key { - u8 key[WLAN_MAX_KEY_LEN]; - u8 key_len; - u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; - u8 seq_len; - u32 cipher; -}; - -enum { - SME_DISCONNECTED, - SME_CONNECTING, - SME_CONNECTED -}; - -struct ar_node_mapping { - u8 macAddress[6]; - u8 epId; - u8 txPending; -}; - -struct ar_cookie { - unsigned long arc_bp[2]; /* Must be first field */ - struct htc_packet HtcPkt; /* HTC packet wrapper */ - struct ar_cookie *arc_list_next; -}; - -struct ar_hb_chlng_resp { - A_TIMER timer; - u32 frequency; - u32 seqNum; - bool outstanding; - u8 missCnt; - u8 missThres; -}; - -/* Per STA data, used in AP mode */ -/*TODO: All this should move to OS independent dir */ - -#define STA_PWR_MGMT_MASK 0x1 -#define STA_PWR_MGMT_SHIFT 0x0 -#define STA_PWR_MGMT_AWAKE 0x0 -#define STA_PWR_MGMT_SLEEP 0x1 - -#define STA_SET_PWR_SLEEP(sta) (sta->flags |= (STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT)) -#define STA_CLR_PWR_SLEEP(sta) (sta->flags &= ~(STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT)) -#define STA_IS_PWR_SLEEP(sta) ((sta->flags >> STA_PWR_MGMT_SHIFT) & STA_PWR_MGMT_MASK) - -#define STA_PS_POLLED_MASK 0x1 -#define STA_PS_POLLED_SHIFT 0x1 -#define STA_SET_PS_POLLED(sta) (sta->flags |= (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT)) -#define STA_CLR_PS_POLLED(sta) (sta->flags &= ~(STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT)) -#define STA_IS_PS_POLLED(sta) (sta->flags & (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT)) - -typedef struct { - u16 flags; - u8 mac[ATH_MAC_LEN]; - u8 aid; - u8 keymgmt; - u8 ucipher; - u8 auth; - u8 wpa_ie[IEEE80211_MAX_IE]; - A_NETBUF_QUEUE_T psq; /* power save q */ - A_MUTEX_T psqLock; -} sta_t; - -typedef struct ar6_raw_htc { - HTC_ENDPOINT_ID arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX]; - HTC_RAW_STREAM_ID arEp2RawMapping[ENDPOINT_MAX]; - struct semaphore raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX]; - struct semaphore raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX]; - wait_queue_head_t raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX]; - wait_queue_head_t raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX]; - raw_htc_buffer raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM]; - raw_htc_buffer raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM]; - bool write_buffer_available[HTC_RAW_STREAM_NUM_MAX]; - bool read_buffer_available[HTC_RAW_STREAM_NUM_MAX]; -} AR_RAW_HTC_T; - -struct ar6_softc { - struct net_device *arNetDev; /* net_device pointer */ - void *arWmi; - int arTxPending[ENDPOINT_MAX]; - int arTotalTxDataPending; - u8 arNumDataEndPts; - bool arWmiEnabled; - bool arWmiReady; - bool arConnected; - HTC_HANDLE arHtcTarget; - void *arHifDevice; - spinlock_t arLock; - struct semaphore arSem; - int arSsidLen; - u_char arSsid[32]; - u8 arNextMode; - u8 arNetworkType; - u8 arDot11AuthMode; - u8 arAuthMode; - u8 arPairwiseCrypto; - u8 arPairwiseCryptoLen; - u8 arGroupCrypto; - u8 arGroupCryptoLen; - u8 arDefTxKeyIndex; - struct ar_wep_key arWepKeyList[WMI_MAX_KEY_INDEX + 1]; - u8 arBssid[6]; - u8 arReqBssid[6]; - u16 arChannelHint; - u16 arBssChannel; - u16 arListenIntervalB; - u16 arListenIntervalT; - struct ar6000_version arVersion; - u32 arTargetType; - s8 arRssi; - u8 arTxPwr; - bool arTxPwrSet; - s32 arBitRate; - struct net_device_stats arNetStats; - struct iw_statistics arIwStats; - s8 arNumChannels; - u16 arChannelList[32]; - u32 arRegCode; - bool statsUpdatePending; - TARGET_STATS arTargetStats; - s8 arMaxRetries; - u8 arPhyCapability; -#ifdef CONFIG_HOST_TCMD_SUPPORT - u32 arTargetMode; - void *tcmd_rx_report; - int tcmd_rx_report_len; -#endif - AR6000_WLAN_STATE arWlanState; - struct ar_node_mapping arNodeMap[MAX_NODE_NUM]; - u8 arIbssPsEnable; - u8 arNodeNum; - u8 arNexEpId; - struct ar_cookie *arCookieList; - u32 arCookieCount; - u32 arRateMask; - u8 arSkipScan; - u16 arBeaconInterval; - bool arConnectPending; - bool arWmmEnabled; - struct ar_hb_chlng_resp arHBChallengeResp; - u8 arKeepaliveConfigured; - u32 arMgmtFilter; - HTC_ENDPOINT_ID arAc2EpMapping[WMM_NUM_AC]; - bool arAcStreamActive[WMM_NUM_AC]; - u8 arAcStreamPriMap[WMM_NUM_AC]; - u8 arHiAcStreamActivePri; - u8 arEp2AcMapping[ENDPOINT_MAX]; - HTC_ENDPOINT_ID arControlEp; -#ifdef HTC_RAW_INTERFACE - AR_RAW_HTC_T *arRawHtc; -#endif - bool arNetQueueStopped; - bool arRawIfInit; - int arDeviceIndex; - struct common_credit_state_info arCreditStateInfo; - bool arWMIControlEpFull; - bool dbgLogFetchInProgress; - u8 log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE]; - u32 log_cnt; - u32 dbglog_init_done; - u32 arConnectCtrlFlags; - s32 user_savedkeys_stat; - u32 user_key_ctrl; - struct USER_SAVEDKEYS user_saved_keys; - USER_RSSI_THOLD rssi_map[12]; - u8 arUserBssFilter; - u16 ap_profile_flag; /* AP mode */ - WMI_AP_ACL g_acl; /* AP mode */ - sta_t sta_list[AP_MAX_NUM_STA]; /* AP mode */ - u8 sta_list_index; /* AP mode */ - struct ieee80211req_key ap_mode_bkey; /* AP mode */ - A_NETBUF_QUEUE_T mcastpsq; /* power save q for Mcast frames */ - A_MUTEX_T mcastpsqLock; - bool DTIMExpired; /* flag to indicate DTIM expired */ - u8 intra_bss; /* enable/disable intra bss data forward */ - void *aggr_cntxt; -#ifndef EXPORT_HCI_BRIDGE_INTERFACE - void *hcidev_info; -#endif - WMI_AP_MODE_STAT arAPStats; - u8 ap_hidden_ssid; - u8 ap_country_code[3]; - u8 ap_wmode; - u8 ap_dtim_period; - u16 ap_beacon_interval; - u16 arRTS; - u16 arACS; /* AP mode - Auto Channel Selection */ - struct htc_packet_queue amsdu_rx_buffer_queue; - bool bIsDestroyProgress; /* flag to indicate ar6k destroy is in progress */ - A_TIMER disconnect_timer; - u8 rxMetaVersion; -#ifdef WAPI_ENABLE - u8 arWapiEnable; -#endif - WMI_BTCOEX_CONFIG_EVENT arBtcoexConfig; - WMI_BTCOEX_STATS_EVENT arBtcoexStats; - s32 (*exitCallback)(void *config); /* generic callback at AR6K exit */ - struct hif_device_os_device_info osDevInfo; - struct wireless_dev *wdev; - struct cfg80211_scan_request *scan_request; - struct ar_key keys[WMI_MAX_KEY_INDEX + 1]; - u32 smeState; - u16 arWlanPowerState; - bool arWlanOff; -#ifdef CONFIG_PM - u16 arWowState; - bool arBTOff; - bool arBTSharing; - u16 arSuspendConfig; - u16 arWlanOffConfig; - u16 arWow2Config; -#endif - u8 scan_triggered; - WMI_SCAN_PARAMS_CMD scParams; -#define AR_MCAST_FILTER_MAC_ADDR_SIZE 4 - u8 mcast_filters[MAC_MAX_FILTERS_PER_LIST][AR_MCAST_FILTER_MAC_ADDR_SIZE]; - u8 bdaddr[6]; - bool scanSpecificSsid; -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT - void *arApDev; -#endif - u8 arAutoAuthStage; - - u8 *fw_otp; - size_t fw_otp_len; - u8 *fw; - size_t fw_len; - u8 *fw_patch; - size_t fw_patch_len; - u8 *fw_data; - size_t fw_data_len; -}; - -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT -struct ar_virtual_interface { - struct net_device *arNetDev; /* net_device pointer */ - struct ar6_softc *arDev; /* ar device pointer */ - struct net_device *arStaNetDev; /* net_device pointer */ -}; -#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - -static inline void *ar6k_priv(struct net_device *dev) -{ - return (wdev_priv(dev->ieee80211_ptr)); -} - -#define SET_HCI_BUS_TYPE(pHciDev, __bus, __type) do { \ - (pHciDev)->bus = (__bus); \ - (pHciDev)->dev_type = (__type); \ -} while(0) - -#define GET_INODE_FROM_FILEP(filp) \ - (filp)->f_path.dentry->d_inode - -#define arAc2EndpointID(ar,ac) (ar)->arAc2EpMapping[(ac)] -#define arSetAc2EndpointIDMap(ar,ac,ep) \ -{ (ar)->arAc2EpMapping[(ac)] = (ep); \ - (ar)->arEp2AcMapping[(ep)] = (ac); } -#define arEndpoint2Ac(ar,ep) (ar)->arEp2AcMapping[(ep)] - -#define arRawIfEnabled(ar) (ar)->arRawIfInit -#define arRawStream2EndpointID(ar,raw) (ar)->arRawHtc->arRaw2EpMapping[(raw)] -#define arSetRawStream2EndpointIDMap(ar,raw,ep) \ -{ (ar)->arRawHtc->arRaw2EpMapping[(raw)] = (ep); \ - (ar)->arRawHtc->arEp2RawMapping[(ep)] = (raw); } -#define arEndpoint2RawStreamID(ar,ep) (ar)->arRawHtc->arEp2RawMapping[(ep)] - -struct ar_giwscan_param { - char *current_ev; - char *end_buf; - u32 bytes_needed; - struct iw_request_info *info; -}; - -#define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++) - -#define AR6000_SPIN_LOCK(lock, param) do { \ - if (irqs_disabled()) { \ - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled:AR6000_LOCK\n")); \ - } \ - spin_lock_bh(lock); \ -} while (0) - -#define AR6000_SPIN_UNLOCK(lock, param) do { \ - if (irqs_disabled()) { \ - AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled: AR6000_UNLOCK\n")); \ - } \ - spin_unlock_bh(lock); \ -} while (0) - -void ar6000_init_profile_info(struct ar6_softc *ar); -void ar6000_install_static_wep_keys(struct ar6_softc *ar); -int ar6000_init(struct net_device *dev); -int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar); -void ar6000_TxDataCleanup(struct ar6_softc *ar); -int ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev); -void ar6000_restart_endpoint(struct net_device *dev); -void ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs); - -#ifdef HTC_RAW_INTERFACE - -#ifndef __user -#define __user -#endif - -int ar6000_htc_raw_open(struct ar6_softc *ar); -int ar6000_htc_raw_close(struct ar6_softc *ar); -ssize_t ar6000_htc_raw_read(struct ar6_softc *ar, - HTC_RAW_STREAM_ID StreamID, - char __user *buffer, size_t count); -ssize_t ar6000_htc_raw_write(struct ar6_softc *ar, - HTC_RAW_STREAM_ID StreamID, - char __user *buffer, size_t count); - -#endif /* HTC_RAW_INTERFACE */ - -/* AP mode */ -/*TODO: These routines should be moved to a file that is common across OS */ -sta_t * -ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr); - -sta_t * -ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid); - -u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason); - -/* HCI support */ - -#ifndef EXPORT_HCI_BRIDGE_INTERFACE -int ar6000_setup_hci(struct ar6_softc *ar); -void ar6000_cleanup_hci(struct ar6_softc *ar); -void ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig); - -/* HCI bridge testing */ -int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb); -#endif - -ATH_DEBUG_DECLARE_EXTERN(htc); -ATH_DEBUG_DECLARE_EXTERN(wmi); -ATH_DEBUG_DECLARE_EXTERN(bmi); -ATH_DEBUG_DECLARE_EXTERN(hif); -ATH_DEBUG_DECLARE_EXTERN(wlan); -ATH_DEBUG_DECLARE_EXTERN(misc); - -extern u8 bcast_mac[]; -extern u8 null_mac[]; - -#ifdef __cplusplus -} -#endif - -#endif /* _AR6000_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/ar6k_pal.h b/drivers/staging/ath6kl/os/linux/include/ar6k_pal.h deleted file mode 100644 index 39e0873aff2..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/ar6k_pal.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// The software source and binaries included in this development package are -// licensed, not sold. You, or your company, received the package under one -// or more license agreements. The rights granted to you are specifically -// listed in these license agreement(s). All other rights remain with Atheros -// Communications, Inc., its subsidiaries, or the respective owner including -// those listed on the included copyright notices. Distribution of any -// portion of this package must be in strict compliance with the license -// agreement(s) terms. -// -// -// -// PAL driver for AR6003 -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _AR6K_PAL_H_ -#define _AR6K_PAL_H_ -#define HCI_GET_OP_CODE(p) (((u16)((p)[1])) << 8) | ((u16)((p)[0])) - -/* transmit packet reserve offset */ -#define TX_PACKET_RSV_OFFSET 32 -/* pal specific config structure */ -typedef bool (*ar6k_pal_recv_pkt_t)(void *pHciPalInfo, void *skb); -typedef struct ar6k_pal_config_s -{ - ar6k_pal_recv_pkt_t fpar6k_pal_recv_pkt; -}ar6k_pal_config_t; - -void register_pal_cb(ar6k_pal_config_t *palConfig_p); -#endif /* _AR6K_PAL_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h b/drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h deleted file mode 100644 index 184dbdb5049..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h +++ /dev/null @@ -1,190 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _AR6XAPI_LINUX_H -#define _AR6XAPI_LINUX_H -#ifdef __cplusplus -extern "C" { -#endif - -struct ar6_softc; - -void ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, - u32 sw_ver, u32 abi_ver); -int ar6000_control_tx(void *devt, void *osbuf, HTC_ENDPOINT_ID eid); -void ar6000_connect_event(struct ar6_softc *ar, u16 channel, - u8 *bssid, u16 listenInterval, - u16 beaconInterval, NETWORK_TYPE networkType, - u8 beaconIeLen, u8 assocReqLen, - u8 assocRespLen,u8 *assocInfo); -void ar6000_disconnect_event(struct ar6_softc *ar, u8 reason, - u8 *bssid, u8 assocRespLen, - u8 *assocInfo, u16 protocolReasonStatus); -void ar6000_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, - bool ismcast); -void ar6000_bitrate_rx(void *devt, s32 rateKbps); -void ar6000_channelList_rx(void *devt, s8 numChan, u16 *chanList); -void ar6000_regDomain_event(struct ar6_softc *ar, u32 regCode); -void ar6000_txPwr_rx(void *devt, u8 txPwr); -void ar6000_keepalive_rx(void *devt, u8 configured); -void ar6000_neighborReport_event(struct ar6_softc *ar, int numAps, - WMI_NEIGHBOR_INFO *info); -void ar6000_set_numdataendpts(struct ar6_softc *ar, u32 num); -void ar6000_scanComplete_event(struct ar6_softc *ar, int status); -void ar6000_targetStats_event(struct ar6_softc *ar, u8 *ptr, u32 len); -void ar6000_rssiThreshold_event(struct ar6_softc *ar, - WMI_RSSI_THRESHOLD_VAL newThreshold, - s16 rssi); -void ar6000_reportError_event(struct ar6_softc *, WMI_TARGET_ERROR_VAL errorVal); -void ar6000_cac_event(struct ar6_softc *ar, u8 ac, u8 cac_indication, - u8 statusCode, u8 *tspecSuggestion); -void ar6000_channel_change_event(struct ar6_softc *ar, u16 oldChannel, u16 newChannel); -void ar6000_hbChallengeResp_event(struct ar6_softc *, u32 cookie, u32 source); -void -ar6000_roam_tbl_event(struct ar6_softc *ar, WMI_TARGET_ROAM_TBL *pTbl); - -void -ar6000_roam_data_event(struct ar6_softc *ar, WMI_TARGET_ROAM_DATA *p); - -void -ar6000_wow_list_event(struct ar6_softc *ar, u8 num_filters, - WMI_GET_WOW_LIST_REPLY *wow_reply); - -void ar6000_pmkid_list_event(void *devt, u8 numPMKID, - WMI_PMKID *pmkidList, u8 *bssidList); - -void ar6000_gpio_intr_rx(u32 intr_mask, u32 input_values); -void ar6000_gpio_data_rx(u32 reg_id, u32 value); -void ar6000_gpio_ack_rx(void); - -s32 rssi_compensation_calc_tcmd(u32 freq, s32 rssi, u32 totalPkt); -s16 rssi_compensation_calc(struct ar6_softc *ar, s16 rssi); -s16 rssi_compensation_reverse_calc(struct ar6_softc *ar, s16 rssi, bool Above); - -void ar6000_dbglog_init_done(struct ar6_softc *ar); - -#ifdef CONFIG_HOST_TCMD_SUPPORT -void ar6000_tcmd_rx_report_event(void *devt, u8 *results, int len); -#endif - -void ar6000_tx_retry_err_event(void *devt); - -void ar6000_snrThresholdEvent_rx(void *devt, - WMI_SNR_THRESHOLD_VAL newThreshold, - u8 snr); - -void ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL range, u8 lqVal); - - -void ar6000_ratemask_rx(void *devt, u32 ratemask); - -int ar6000_get_driver_cfg(struct net_device *dev, - u16 cfgParam, - void *result); -void ar6000_bssInfo_event_rx(struct ar6_softc *ar, u8 *data, int len); - -void ar6000_dbglog_event(struct ar6_softc *ar, u32 dropped, - s8 *buffer, u32 length); - -int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar); - -void ar6000_peer_event(void *devt, u8 eventCode, u8 *bssid); - -void ar6000_indicate_tx_activity(void *devt, u8 trafficClass, bool Active); -HTC_ENDPOINT_ID ar6000_ac2_endpoint_id ( void * devt, u8 ac); -u8 ar6000_endpoint_id2_ac (void * devt, HTC_ENDPOINT_ID ep ); - -void ar6000_btcoex_config_event(struct ar6_softc *ar, u8 *ptr, u32 len); - -void ar6000_btcoex_stats_event(struct ar6_softc *ar, u8 *ptr, u32 len) ; - -void ar6000_dset_open_req(void *devt, - u32 id, - u32 targ_handle, - u32 targ_reply_fn, - u32 targ_reply_arg); -void ar6000_dset_close(void *devt, u32 access_cookie); -void ar6000_dset_data_req(void *devt, - u32 access_cookie, - u32 offset, - u32 length, - u32 targ_buf, - u32 targ_reply_fn, - u32 targ_reply_arg); - - -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -void prof_count_rx(unsigned int addr, unsigned int count); -#endif - -u32 ar6000_getnodeAge (void); - -u32 ar6000_getclkfreq (void); - -int ar6000_ap_mode_profile_commit(struct ar6_softc *ar); - -struct ieee80211req_wpaie; -int -ar6000_ap_mode_get_wpa_ie(struct ar6_softc *ar, struct ieee80211req_wpaie *wpaie); - -int is_iwioctl_allowed(u8 mode, u16 cmd); - -int is_xioctl_allowed(u8 mode, int cmd); - -void ar6000_pspoll_event(struct ar6_softc *ar,u8 aid); - -void ar6000_dtimexpiry_event(struct ar6_softc *ar); - -void ar6000_aggr_rcv_addba_req_evt(struct ar6_softc *ar, WMI_ADDBA_REQ_EVENT *cmd); -void ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc *ar, WMI_ADDBA_RESP_EVENT *cmd); -void ar6000_aggr_rcv_delba_req_evt(struct ar6_softc *ar, WMI_DELBA_EVENT *cmd); -void ar6000_hci_event_rcv_evt(struct ar6_softc *ar, WMI_HCI_EVENT *cmd); - -#ifdef WAPI_ENABLE -int ap_set_wapi_key(struct ar6_softc *ar, void *ik); -void ap_wapi_rekey_event(struct ar6_softc *ar, u8 type, u8 *mac); -#endif - -int ar6000_connect_to_ap(struct ar6_softc *ar); -int ar6000_disconnect(struct ar6_softc *ar); -int ar6000_update_wlan_pwr_state(struct ar6_softc *ar, AR6000_WLAN_STATE state, bool suspending); -int ar6000_set_wlan_state(struct ar6_softc *ar, AR6000_WLAN_STATE state); -int ar6000_set_bt_hw_state(struct ar6_softc *ar, u32 state); - -#ifdef CONFIG_PM -int ar6000_suspend_ev(void *context); -int ar6000_resume_ev(void *context); -int ar6000_power_change_ev(void *context, u32 config); -void ar6000_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent); -#endif - -#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT -int ar6000_add_ap_interface(struct ar6_softc *ar, char *ifname); -int ar6000_remove_ap_interface(struct ar6_softc *ar); -#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/staging/ath6kl/os/linux/include/athdrv_linux.h b/drivers/staging/ath6kl/os/linux/include/athdrv_linux.h deleted file mode 100644 index 3d5f01da543..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/athdrv_linux.h +++ /dev/null @@ -1,1217 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _ATHDRV_LINUX_H -#define _ATHDRV_LINUX_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * There are two types of ioctl's here: Standard ioctls and - * eXtended ioctls. All extended ioctls (XIOCTL) are multiplexed - * off of the single ioctl command, AR6000_IOCTL_EXTENDED. The - * arguments for every XIOCTL starts with a 32-bit command word - * that is used to select which extended ioctl is in use. After - * the command word are command-specific arguments. - */ - -/* Linux standard Wireless Extensions, private ioctl interfaces */ -#define IEEE80211_IOCTL_SETPARAM (SIOCIWFIRSTPRIV+0) -#define IEEE80211_IOCTL_SETKEY (SIOCIWFIRSTPRIV+1) -#define IEEE80211_IOCTL_DELKEY (SIOCIWFIRSTPRIV+2) -#define IEEE80211_IOCTL_SETMLME (SIOCIWFIRSTPRIV+3) -#define IEEE80211_IOCTL_ADDPMKID (SIOCIWFIRSTPRIV+4) -#define IEEE80211_IOCTL_SETOPTIE (SIOCIWFIRSTPRIV+5) -//#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+6) -//#define IEEE80211_IOCTL_SETWMMPARAMS (SIOCIWFIRSTPRIV+7) -//#define IEEE80211_IOCTL_GETWMMPARAMS (SIOCIWFIRSTPRIV+8) -//#define IEEE80211_IOCTL_GETOPTIE (SIOCIWFIRSTPRIV+9) -//#define IEEE80211_IOCTL_SETAUTHALG (SIOCIWFIRSTPRIV+10) -#define IEEE80211_IOCTL_LASTONE (SIOCIWFIRSTPRIV+10) - - - -/* ====WMI Ioctls==== */ -/* - * - * Many ioctls simply provide WMI services to application code: - * an application makes such an ioctl call with a set of arguments - * that are packaged into the corresponding WMI message, and sent - * to the Target. - */ - -#define AR6000_IOCTL_WMI_GETREV (SIOCIWFIRSTPRIV+11) -/* - * arguments: - * ar6000_version *revision - */ - -#define AR6000_IOCTL_WMI_SETPWR (SIOCIWFIRSTPRIV+12) -/* - * arguments: - * WMI_POWER_MODE_CMD pwrModeCmd (see include/wmi.h) - * uses: WMI_SET_POWER_MODE_CMDID - */ - -#define AR6000_IOCTL_WMI_SETSCAN (SIOCIWFIRSTPRIV+13) -/* - * arguments: - * WMI_SCAN_PARAMS_CMD scanParams (see include/wmi.h) - * uses: WMI_SET_SCAN_PARAMS_CMDID - */ - -#define AR6000_IOCTL_WMI_SETLISTENINT (SIOCIWFIRSTPRIV+14) -/* - * arguments: - * UINT32 listenInterval - * uses: WMI_SET_LISTEN_INT_CMDID - */ - -#define AR6000_IOCTL_WMI_SETBSSFILTER (SIOCIWFIRSTPRIV+15) -/* - * arguments: - * WMI_BSS_FILTER filter (see include/wmi.h) - * uses: WMI_SET_BSS_FILTER_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_CHANNELPARAMS (SIOCIWFIRSTPRIV+16) -/* - * arguments: - * WMI_CHANNEL_PARAMS_CMD chParams - * uses: WMI_SET_CHANNEL_PARAMS_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_PROBEDSSID (SIOCIWFIRSTPRIV+17) -/* - * arguments: - * WMI_PROBED_SSID_CMD probedSsids (see include/wmi.h) - * uses: WMI_SETPROBED_SSID_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_PMPARAMS (SIOCIWFIRSTPRIV+18) -/* - * arguments: - * WMI_POWER_PARAMS_CMD powerParams (see include/wmi.h) - * uses: WMI_SET_POWER_PARAMS_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_BADAP (SIOCIWFIRSTPRIV+19) -/* - * arguments: - * WMI_ADD_BAD_AP_CMD badAPs (see include/wmi.h) - * uses: WMI_ADD_BAD_AP_CMDID - */ - -#define AR6000_IOCTL_WMI_GET_QOS_QUEUE (SIOCIWFIRSTPRIV+20) -/* - * arguments: - * ar6000_queuereq queueRequest (see below) - */ - -#define AR6000_IOCTL_WMI_CREATE_QOS (SIOCIWFIRSTPRIV+21) -/* - * arguments: - * WMI_CREATE_PSTREAM createPstreamCmd (see include/wmi.h) - * uses: WMI_CREATE_PSTREAM_CMDID - */ - -#define AR6000_IOCTL_WMI_DELETE_QOS (SIOCIWFIRSTPRIV+22) -/* - * arguments: - * WMI_DELETE_PSTREAM_CMD deletePstreamCmd (see include/wmi.h) - * uses: WMI_DELETE_PSTREAM_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_SNRTHRESHOLD (SIOCIWFIRSTPRIV+23) -/* - * arguments: - * WMI_SNR_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h) - * uses: WMI_SNR_THRESHOLD_PARAMS_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK (SIOCIWFIRSTPRIV+24) -/* - * arguments: - * WMI_TARGET_ERROR_REPORT_BITMASK errorReportBitMask (see include/wmi.h) - * uses: WMI_TARGET_ERROR_REPORT_BITMASK_CMDID - */ - -#define AR6000_IOCTL_WMI_GET_TARGET_STATS (SIOCIWFIRSTPRIV+25) -/* - * arguments: - * TARGET_STATS *targetStats (see below) - * uses: WMI_GET_STATISTICS_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_ASSOC_INFO (SIOCIWFIRSTPRIV+26) -/* - * arguments: - * WMI_SET_ASSOC_INFO_CMD setAssocInfoCmd - * uses: WMI_SET_ASSOC_INFO_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_ACCESS_PARAMS (SIOCIWFIRSTPRIV+27) -/* - * arguments: - * WMI_SET_ACCESS_PARAMS_CMD setAccessParams (see include/wmi.h) - * uses: WMI_SET_ACCESS_PARAMS_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_BMISS_TIME (SIOCIWFIRSTPRIV+28) -/* - * arguments: - * UINT32 beaconMissTime - * uses: WMI_SET_BMISS_TIME_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_DISC_TIMEOUT (SIOCIWFIRSTPRIV+29) -/* - * arguments: - * WMI_DISC_TIMEOUT_CMD disconnectTimeoutCmd (see include/wmi.h) - * uses: WMI_SET_DISC_TIMEOUT_CMDID - */ - -#define AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS (SIOCIWFIRSTPRIV+30) -/* - * arguments: - * WMI_IBSS_PM_CAPS_CMD ibssPowerMgmtCapsCmd - * uses: WMI_SET_IBSS_PM_CAPS_CMDID - */ - -/* - * There is a very small space available for driver-private - * wireless ioctls. In order to circumvent this limitation, - * we multiplex a bunch of ioctls (XIOCTLs) on top of a - * single AR6000_IOCTL_EXTENDED ioctl. - */ -#define AR6000_IOCTL_EXTENDED (SIOCIWFIRSTPRIV+31) - - -/* ====BMI Extended Ioctls==== */ - -#define AR6000_XIOCTL_BMI_DONE 1 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_DONE) - * uses: BMI_DONE - */ - -#define AR6000_XIOCTL_BMI_READ_MEMORY 2 -/* - * arguments: - * union { - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_READ_MEMORY) - * UINT32 address - * UINT32 length - * } - * char results[length] - * } - * uses: BMI_READ_MEMORY - */ - -#define AR6000_XIOCTL_BMI_WRITE_MEMORY 3 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_MEMORY) - * UINT32 address - * UINT32 length - * char data[length] - * uses: BMI_WRITE_MEMORY - */ - -#define AR6000_XIOCTL_BMI_EXECUTE 4 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_EXECUTE) - * UINT32 TargetAddress - * UINT32 parameter - * uses: BMI_EXECUTE - */ - -#define AR6000_XIOCTL_BMI_SET_APP_START 5 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_SET_APP_START) - * UINT32 TargetAddress - * uses: BMI_SET_APP_START - */ - -#define AR6000_XIOCTL_BMI_READ_SOC_REGISTER 6 -/* - * arguments: - * union { - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_READ_SOC_REGISTER) - * UINT32 TargetAddress, 32-bit aligned - * } - * UINT32 result - * } - * uses: BMI_READ_SOC_REGISTER - */ - -#define AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER 7 -/* - * arguments: - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER) - * UINT32 TargetAddress, 32-bit aligned - * UINT32 newValue - * } - * uses: BMI_WRITE_SOC_REGISTER - */ - -#define AR6000_XIOCTL_BMI_TEST 8 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_TEST) - * UINT32 address - * UINT32 length - * UINT32 count - */ - - - -/* Historical Host-side DataSet support */ -#define AR6000_XIOCTL_UNUSED9 9 -#define AR6000_XIOCTL_UNUSED10 10 -#define AR6000_XIOCTL_UNUSED11 11 - -/* ====Misc Extended Ioctls==== */ - -#define AR6000_XIOCTL_FORCE_TARGET_RESET 12 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_FORCE_TARGET_RESET) - */ - - -#ifdef HTC_RAW_INTERFACE -/* HTC Raw Interface Ioctls */ -#define AR6000_XIOCTL_HTC_RAW_OPEN 13 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_OPEN) - */ - -#define AR6000_XIOCTL_HTC_RAW_CLOSE 14 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_CLOSE) - */ - -#define AR6000_XIOCTL_HTC_RAW_READ 15 -/* - * arguments: - * union { - * struct { - * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_READ) - * UINT32 mailboxID - * UINT32 length - * } - * results[length] - * } - */ - -#define AR6000_XIOCTL_HTC_RAW_WRITE 16 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_WRITE) - * UINT32 mailboxID - * UINT32 length - * char buffer[length] - */ -#endif /* HTC_RAW_INTERFACE */ - -#define AR6000_XIOCTL_CHECK_TARGET_READY 17 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_CHECK_TARGET_READY) - */ - - - -/* ====GPIO (General Purpose I/O) Extended Ioctls==== */ - -#define AR6000_XIOCTL_GPIO_OUTPUT_SET 18 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_OUTPUT_SET) - * ar6000_gpio_output_set_cmd_s (see below) - * uses: WMIX_GPIO_OUTPUT_SET_CMDID - */ - -#define AR6000_XIOCTL_GPIO_INPUT_GET 19 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_INPUT_GET) - * uses: WMIX_GPIO_INPUT_GET_CMDID - */ - -#define AR6000_XIOCTL_GPIO_REGISTER_SET 20 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_SET) - * ar6000_gpio_register_cmd_s (see below) - * uses: WMIX_GPIO_REGISTER_SET_CMDID - */ - -#define AR6000_XIOCTL_GPIO_REGISTER_GET 21 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_GET) - * ar6000_gpio_register_cmd_s (see below) - * uses: WMIX_GPIO_REGISTER_GET_CMDID - */ - -#define AR6000_XIOCTL_GPIO_INTR_ACK 22 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_ACK) - * ar6000_cpio_intr_ack_cmd_s (see below) - * uses: WMIX_GPIO_INTR_ACK_CMDID - */ - -#define AR6000_XIOCTL_GPIO_INTR_WAIT 23 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_WAIT) - */ - - - -/* ====more wireless commands==== */ - -#define AR6000_XIOCTL_SET_ADHOC_BSSID 24 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_SET_ADHOC_BSSID) - * WMI_SET_ADHOC_BSSID_CMD setAdHocBssidCmd (see include/wmi.h) - */ - -#define AR6000_XIOCTL_SET_OPT_MODE 25 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_SET_OPT_MODE) - * WMI_SET_OPT_MODE_CMD setOptModeCmd (see include/wmi.h) - * uses: WMI_SET_OPT_MODE_CMDID - */ - -#define AR6000_XIOCTL_OPT_SEND_FRAME 26 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_OPT_SEND_FRAME) - * WMI_OPT_TX_FRAME_CMD optTxFrameCmd (see include/wmi.h) - * uses: WMI_OPT_TX_FRAME_CMDID - */ - -#define AR6000_XIOCTL_SET_BEACON_INTVAL 27 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_SET_BEACON_INTVAL) - * WMI_BEACON_INT_CMD beaconIntCmd (see include/wmi.h) - * uses: WMI_SET_BEACON_INT_CMDID - */ - - -#define IEEE80211_IOCTL_SETAUTHALG 28 - - -#define AR6000_XIOCTL_SET_VOICE_PKT_SIZE 29 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_SET_VOICE_PKT_SIZE) - * WMI_SET_VOICE_PKT_SIZE_CMD setVoicePktSizeCmd (see include/wmi.h) - * uses: WMI_SET_VOICE_PKT_SIZE_CMDID - */ - - -#define AR6000_XIOCTL_SET_MAX_SP 30 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_SET_MAX_SP) - * WMI_SET_MAX_SP_LEN_CMD maxSPLen(see include/wmi.h) - * uses: WMI_SET_MAX_SP_LEN_CMDID - */ - -#define AR6000_XIOCTL_WMI_GET_ROAM_TBL 31 - -#define AR6000_XIOCTL_WMI_SET_ROAM_CTRL 32 - -#define AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS 33 - - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS) - * WMI_SET_POWERSAVE_TIMERS_CMD powerSaveTimers(see include/wmi.h) - * WMI_SET_POWERSAVE_TIMERS_CMDID - */ - -#define AR6000_XIOCTRL_WMI_GET_POWER_MODE 34 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTRL_WMI_GET_POWER_MODE) - */ - -#define AR6000_XIOCTRL_WMI_SET_WLAN_STATE 35 -typedef enum { - WLAN_DISABLED, - WLAN_ENABLED -} AR6000_WLAN_STATE; -/* - * arguments: - * enable/disable - */ - -#define AR6000_XIOCTL_WMI_GET_ROAM_DATA 36 - -#define AR6000_XIOCTL_WMI_SETRETRYLIMITS 37 -/* - * arguments: - * WMI_SET_RETRY_LIMITS_CMD ibssSetRetryLimitsCmd - * uses: WMI_SET_RETRY_LIMITS_CMDID - */ - -#ifdef CONFIG_HOST_TCMD_SUPPORT -/* ====extended commands for radio test ==== */ - -#define AR6000_XIOCTL_TCMD_CONT_TX 38 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_TCMD_CONT_TX) - * WMI_TCMD_CONT_TX_CMD contTxCmd (see include/wmi.h) - * uses: WMI_TCMD_CONT_TX_CMDID - */ - -#define AR6000_XIOCTL_TCMD_CONT_RX 39 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_TCMD_CONT_RX) - * WMI_TCMD_CONT_RX_CMD rxCmd (see include/wmi.h) - * uses: WMI_TCMD_CONT_RX_CMDID - */ - -#define AR6000_XIOCTL_TCMD_PM 40 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_TCMD_PM) - * WMI_TCMD_PM_CMD pmCmd (see include/wmi.h) - * uses: WMI_TCMD_PM_CMDID - */ - -#endif /* CONFIG_HOST_TCMD_SUPPORT */ - -#define AR6000_XIOCTL_WMI_STARTSCAN 41 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_STARTSCAN) - * UINT8 scanType - * UINT8 scanConnected - * u32 forceFgScan - * uses: WMI_START_SCAN_CMDID - */ - -#define AR6000_XIOCTL_WMI_SETFIXRATES 42 - -#define AR6000_XIOCTL_WMI_GETFIXRATES 43 - - -#define AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD 44 -/* - * arguments: - * WMI_RSSI_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h) - * uses: WMI_RSSI_THRESHOLD_PARAMS_CMDID - */ - -#define AR6000_XIOCTL_WMI_CLR_RSSISNR 45 -/* - * arguments: - * WMI_CLR_RSSISNR_CMD thresholdParams (see include/wmi.h) - * uses: WMI_CLR_RSSISNR_CMDID - */ - -#define AR6000_XIOCTL_WMI_SET_LQTHRESHOLD 46 -/* - * arguments: - * WMI_LQ_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h) - * uses: WMI_LQ_THRESHOLD_PARAMS_CMDID - */ - -#define AR6000_XIOCTL_WMI_SET_RTS 47 -/* - * arguments: - * WMI_SET_RTS_MODE_CMD (see include/wmi.h) - * uses: WMI_SET_RTS_MODE_CMDID - */ - -#define AR6000_XIOCTL_WMI_SET_LPREAMBLE 48 - -#define AR6000_XIOCTL_WMI_SET_AUTHMODE 49 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_SET_AUTHMODE) - * UINT8 mode - * uses: WMI_SET_RECONNECT_AUTH_MODE_CMDID - */ - -#define AR6000_XIOCTL_WMI_SET_REASSOCMODE 50 - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_SET_WMM) - * UINT8 mode - * uses: WMI_SET_WMM_CMDID - */ -#define AR6000_XIOCTL_WMI_SET_WMM 51 - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS) - * UINT32 frequency - * UINT8 threshold - */ -#define AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS 52 - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP) - * UINT32 cookie - */ -#define AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP 53 - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_GET_RD) - * UINT32 regDomain - */ -#define AR6000_XIOCTL_WMI_GET_RD 54 - -#define AR6000_XIOCTL_DIAG_READ 55 - -#define AR6000_XIOCTL_DIAG_WRITE 56 - -/* - * arguments cmd (AR6000_XIOCTL_SET_TXOP) - * WMI_TXOP_CFG txopEnable - */ -#define AR6000_XIOCTL_WMI_SET_TXOP 57 - -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_USER_SETKEYS) - * UINT32 keyOpCtrl - * uses struct ar6000_user_setkeys_info - */ -#define AR6000_XIOCTL_USER_SETKEYS 58 - -#define AR6000_XIOCTL_WMI_SET_KEEPALIVE 59 -/* - * arguments: - * UINT8 cmd (AR6000_XIOCTL_WMI_SET_KEEPALIVE) - * UINT8 keepaliveInterval - * uses: WMI_SET_KEEPALIVE_CMDID - */ - -#define AR6000_XIOCTL_WMI_GET_KEEPALIVE 60 -/* - * arguments: - * UINT8 cmd (AR6000_XIOCTL_WMI_GET_KEEPALIVE) - * UINT8 keepaliveInterval - * u32 configured - * uses: WMI_GET_KEEPALIVE_CMDID - */ - -/* ====ROM Patching Extended Ioctls==== */ - -#define AR6000_XIOCTL_BMI_ROMPATCH_INSTALL 61 -/* - * arguments: - * union { - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_INSTALL) - * UINT32 ROM Address - * UINT32 RAM Address - * UINT32 number of bytes - * UINT32 activate? (0 or 1) - * } - * u32 resulting rompatch ID - * } - * uses: BMI_ROMPATCH_INSTALL - */ - -#define AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL 62 -/* - * arguments: - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL) - * UINT32 rompatch ID - * } - * uses: BMI_ROMPATCH_UNINSTALL - */ - -#define AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE 63 -/* - * arguments: - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) - * UINT32 rompatch count - * UINT32 rompatch IDs[rompatch count] - * } - * uses: BMI_ROMPATCH_ACTIVATE - */ - -#define AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE 64 -/* - * arguments: - * struct { - * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE) - * UINT32 rompatch count - * UINT32 rompatch IDs[rompatch count] - * } - * uses: BMI_ROMPATCH_DEACTIVATE - */ - -#define AR6000_XIOCTL_WMI_SET_APPIE 65 -/* - * arguments: - * struct { - * UINT32 cmd (AR6000_XIOCTL_WMI_SET_APPIE) - * UINT32 app_frmtype; - * UINT32 app_buflen; - * UINT8 app_buf[]; - * } - */ -#define AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER 66 -/* - * arguments: - * u32 filter_type; - */ - -#define AR6000_XIOCTL_DBGLOG_CFG_MODULE 67 - -#define AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS 68 - -#define AR6000_XIOCTL_WMI_SET_WSC_STATUS 70 -/* - * arguments: - * u32 wsc_status; - * (WSC_REG_INACTIVE or WSC_REG_ACTIVE) - */ - -/* - * arguments: - * struct { - * u8 streamType; - * u8 status; - * } - * uses: WMI_SET_BT_STATUS_CMDID - */ -#define AR6000_XIOCTL_WMI_SET_BT_STATUS 71 - -/* - * arguments: - * struct { - * u8 paramType; - * union { - * u8 noSCOPkts; - * BT_PARAMS_A2DP a2dpParams; - * BT_COEX_REGS regs; - * }; - * } - * uses: WMI_SET_BT_PARAM_CMDID - */ -#define AR6000_XIOCTL_WMI_SET_BT_PARAMS 72 - -#define AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE 73 -#define AR6000_XIOCTL_WMI_SET_WOW_MODE 74 -#define AR6000_XIOCTL_WMI_GET_WOW_LIST 75 -#define AR6000_XIOCTL_WMI_ADD_WOW_PATTERN 76 -#define AR6000_XIOCTL_WMI_DEL_WOW_PATTERN 77 - - - -#define AR6000_XIOCTL_TARGET_INFO 78 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_TARGET_INFO) - * u32 TargetVersion (returned) - * u32 TargetType (returned) - * (See also bmi_msg.h target_ver and target_type) - */ - -#define AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE 79 -/* - * arguments: - * none - */ - -#define AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE 80 -/* - * This ioctl is used to emulate traffic activity - * timeouts. Activity/inactivity will trigger the driver - * to re-balance credits. - * - * arguments: - * ar6000_traffic_activity_change - */ - -#define AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS 81 -/* - * This ioctl is used to set the connect control flags - * - * arguments: - * u32 connectCtrlFlags - */ - -#define AR6000_XIOCTL_WMI_SET_AKMP_PARAMS 82 -/* - * This IOCTL sets any Authentication,Key Management and Protection - * related parameters. This is used along with the information set in - * Connect Command. - * Currently this enables Multiple PMKIDs to an AP. - * - * arguments: - * struct { - * u32 akmpInfo; - * } - * uses: WMI_SET_AKMP_PARAMS_CMD - */ - -#define AR6000_XIOCTL_WMI_GET_PMKID_LIST 83 - -#define AR6000_XIOCTL_WMI_SET_PMKID_LIST 84 -/* - * This IOCTL is used to set a list of PMKIDs. This list of - * PMKIDs is used in the [Re]AssocReq Frame. This list is used - * only if the MultiPMKID option is enabled via the - * AR6000_XIOCTL_WMI_SET_AKMP_PARAMS IOCTL. - * - * arguments: - * struct { - * u32 numPMKID; - * WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE]; - * } - * uses: WMI_SET_PMKIDLIST_CMD - */ - -#define AR6000_XIOCTL_WMI_SET_PARAMS 85 -#define AR6000_XIOCTL_WMI_SET_MCAST_FILTER 86 -#define AR6000_XIOCTL_WMI_DEL_MCAST_FILTER 87 - - -/* Historical DSETPATCH support for INI patches */ -#define AR6000_XIOCTL_UNUSED90 90 - - -/* Support LZ-compressed firmware download */ -#define AR6000_XIOCTL_BMI_LZ_STREAM_START 91 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_LZ_STREAM_START) - * UINT32 address - * uses: BMI_LZ_STREAM_START - */ - -#define AR6000_XIOCTL_BMI_LZ_DATA 92 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_BMI_LZ_DATA) - * UINT32 length - * char data[length] - * uses: BMI_LZ_DATA - */ - -#define AR6000_XIOCTL_PROF_CFG 93 -/* - * arguments: - * u32 period - * u32 nbins - */ - -#define AR6000_XIOCTL_PROF_ADDR_SET 94 -/* - * arguments: - * u32 Target address - */ - -#define AR6000_XIOCTL_PROF_START 95 - -#define AR6000_XIOCTL_PROF_STOP 96 - -#define AR6000_XIOCTL_PROF_COUNT_GET 97 - -#define AR6000_XIOCTL_WMI_ABORT_SCAN 98 - -/* - * AP mode - */ -#define AR6000_XIOCTL_AP_GET_STA_LIST 99 - -#define AR6000_XIOCTL_AP_HIDDEN_SSID 100 - -#define AR6000_XIOCTL_AP_SET_NUM_STA 101 - -#define AR6000_XIOCTL_AP_SET_ACL_MAC 102 - -#define AR6000_XIOCTL_AP_GET_ACL_LIST 103 - -#define AR6000_XIOCTL_AP_COMMIT_CONFIG 104 - -#define IEEE80211_IOCTL_GETWPAIE 105 - -#define AR6000_XIOCTL_AP_CONN_INACT_TIME 106 - -#define AR6000_XIOCTL_AP_PROT_SCAN_TIME 107 - -#define AR6000_XIOCTL_AP_SET_COUNTRY 108 - -#define AR6000_XIOCTL_AP_SET_DTIM 109 - - - - -#define AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT 110 - -#define AR6000_XIOCTL_SET_IP 111 - -#define AR6000_XIOCTL_AP_SET_ACL_POLICY 112 - -#define AR6000_XIOCTL_AP_INTRA_BSS_COMM 113 - -#define AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO 114 - -#define AR6000_XIOCTL_MODULE_DEBUG_SET_MASK 115 - -#define AR6000_XIOCTL_MODULE_DEBUG_GET_MASK 116 - -#define AR6000_XIOCTL_DUMP_RCV_AGGR_STATS 117 - -#define AR6000_XIOCTL_SET_HT_CAP 118 - -#define AR6000_XIOCTL_SET_HT_OP 119 - -#define AR6000_XIOCTL_AP_GET_STAT 120 - -#define AR6000_XIOCTL_SET_TX_SELECT_RATES 121 - -#define AR6000_XIOCTL_SETUP_AGGR 122 - -#define AR6000_XIOCTL_ALLOW_AGGR 123 - -#define AR6000_XIOCTL_AP_GET_HIDDEN_SSID 124 - -#define AR6000_XIOCTL_AP_GET_COUNTRY 125 - -#define AR6000_XIOCTL_AP_GET_WMODE 126 - -#define AR6000_XIOCTL_AP_GET_DTIM 127 - -#define AR6000_XIOCTL_AP_GET_BINTVL 128 - -#define AR6000_XIOCTL_AP_GET_RTS 129 - -#define AR6000_XIOCTL_DELE_AGGR 130 - -#define AR6000_XIOCTL_FETCH_TARGET_REGS 131 - -#define AR6000_XIOCTL_HCI_CMD 132 - -#define AR6000_XIOCTL_ACL_DATA 133 /* used to be used for PAL */ - -#define AR6000_XIOCTL_WLAN_CONN_PRECEDENCE 134 - -#define AR6000_XIOCTL_AP_SET_11BG_RATESET 135 - -/* - * arguments: - * WMI_AP_PS_CMD apPsCmd - * uses: WMI_AP_PS_CMDID - */ - -#define AR6000_XIOCTL_WMI_SET_AP_PS 136 - -#define AR6000_XIOCTL_WMI_MCAST_FILTER 137 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT 138 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV 139 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG 140 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG 141 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG 142 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG 143 - -#define AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG 144 - -#define AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS 145 - -#define AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG 146 - -#define AR6000_XIOCTL_WMI_GET_BTCOEX_STATS 147 -/* - * arguments: - * UINT32 cmd (AR6000_XIOCTL_WMI_SET_QOS_SUPP) - * UINT8 mode - * uses: WMI_SET_QOS_SUPP_CMDID - */ -#define AR6000_XIOCTL_WMI_SET_QOS_SUPP 148 - -#define AR6000_XIOCTL_GET_WLAN_SLEEP_STATE 149 - -#define AR6000_XIOCTL_SET_BT_HW_POWER_STATE 150 - -#define AR6000_XIOCTL_GET_BT_HW_POWER_STATE 151 - -#define AR6000_XIOCTL_ADD_AP_INTERFACE 152 - -#define AR6000_XIOCTL_REMOVE_AP_INTERFACE 153 - -#define AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM 154 - -#define AR6000_XIOCTL_WMI_SET_EXCESS_TX_RETRY_THRES 161 - -/* used by AR6000_IOCTL_WMI_GETREV */ -struct ar6000_version { - u32 host_ver; - u32 target_ver; - u32 wlan_ver; - u32 abi_ver; -}; - -/* used by AR6000_IOCTL_WMI_GET_QOS_QUEUE */ -struct ar6000_queuereq { - u8 trafficClass; - u16 activeTsids; -}; - -/* used by AR6000_IOCTL_WMI_GET_TARGET_STATS */ -typedef struct targetStats_t { - u64 tx_packets; - u64 tx_bytes; - u64 tx_unicast_pkts; - u64 tx_unicast_bytes; - u64 tx_multicast_pkts; - u64 tx_multicast_bytes; - u64 tx_broadcast_pkts; - u64 tx_broadcast_bytes; - u64 tx_rts_success_cnt; - u64 tx_packet_per_ac[4]; - - u64 tx_errors; - u64 tx_failed_cnt; - u64 tx_retry_cnt; - u64 tx_mult_retry_cnt; - u64 tx_rts_fail_cnt; - - u64 rx_packets; - u64 rx_bytes; - u64 rx_unicast_pkts; - u64 rx_unicast_bytes; - u64 rx_multicast_pkts; - u64 rx_multicast_bytes; - u64 rx_broadcast_pkts; - u64 rx_broadcast_bytes; - u64 rx_fragment_pkt; - - u64 rx_errors; - u64 rx_crcerr; - u64 rx_key_cache_miss; - u64 rx_decrypt_err; - u64 rx_duplicate_frames; - - u64 tkip_local_mic_failure; - u64 tkip_counter_measures_invoked; - u64 tkip_replays; - u64 tkip_format_errors; - u64 ccmp_format_errors; - u64 ccmp_replays; - - u64 power_save_failure_cnt; - - u64 cs_bmiss_cnt; - u64 cs_lowRssi_cnt; - u64 cs_connect_cnt; - u64 cs_disconnect_cnt; - - s32 tx_unicast_rate; - s32 rx_unicast_rate; - - u32 lq_val; - - u32 wow_num_pkts_dropped; - u16 wow_num_events_discarded; - - s16 noise_floor_calibation; - s16 cs_rssi; - s16 cs_aveBeacon_rssi; - u8 cs_aveBeacon_snr; - u8 cs_lastRoam_msec; - u8 cs_snr; - - u8 wow_num_host_pkt_wakeups; - u8 wow_num_host_event_wakeups; - - u32 arp_received; - u32 arp_matched; - u32 arp_replied; -}TARGET_STATS; - -typedef struct targetStats_cmd_t { - TARGET_STATS targetStats; - int clearStats; -} TARGET_STATS_CMD; - -/* used by AR6000_XIOCTL_USER_SETKEYS */ - -/* - * Setting this bit to 1 doesnot initialize the RSC on the firmware - */ -#define AR6000_XIOCTL_USER_SETKEYS_RSC_CTRL 1 -#define AR6000_USER_SETKEYS_RSC_UNCHANGED 0x00000002 - -struct ar6000_user_setkeys_info { - u32 keyOpCtrl; /* Bit Map of Key Mgmt Ctrl Flags */ -}; /* XXX: unused !? */ - -/* used by AR6000_XIOCTL_GPIO_OUTPUT_SET */ -struct ar6000_gpio_output_set_cmd_s { - u32 set_mask; - u32 clear_mask; - u32 enable_mask; - u32 disable_mask; -}; - -/* - * used by AR6000_XIOCTL_GPIO_REGISTER_GET and AR6000_XIOCTL_GPIO_REGISTER_SET - */ -struct ar6000_gpio_register_cmd_s { - u32 gpioreg_id; - u32 value; -}; - -/* used by AR6000_XIOCTL_GPIO_INTR_ACK */ -struct ar6000_gpio_intr_ack_cmd_s { - u32 ack_mask; -}; - -/* used by AR6000_XIOCTL_GPIO_INTR_WAIT */ -struct ar6000_gpio_intr_wait_cmd_s { - u32 intr_mask; - u32 input_values; -}; - -/* used by the AR6000_XIOCTL_DBGLOG_CFG_MODULE */ -typedef struct ar6000_dbglog_module_config_s { - u32 valid; - u16 mmask; - u16 tsr; - u32 rep; - u16 size; -} DBGLOG_MODULE_CONFIG; - -typedef struct user_rssi_thold_t { - s16 tag; - s16 rssi; -} USER_RSSI_THOLD; - -typedef struct user_rssi_params_t { - u8 weight; - u32 pollTime; - USER_RSSI_THOLD tholds[12]; -} USER_RSSI_PARAMS; - -typedef struct ar6000_get_btcoex_config_cmd_t{ - u32 btProfileType; - u32 linkId; - }AR6000_GET_BTCOEX_CONFIG_CMD; - -typedef struct ar6000_btcoex_config_t { - AR6000_GET_BTCOEX_CONFIG_CMD configCmd; - u32 *configEvent; -} AR6000_BTCOEX_CONFIG; - -typedef struct ar6000_btcoex_stats_t { - u32 *statsEvent; - }AR6000_BTCOEX_STATS; -/* - * Host driver may have some config parameters. Typically, these - * config params are one time config parameters. These could - * correspond to any of the underlying modules. Host driver exposes - * an api for the underlying modules to get this config. - */ -#define AR6000_DRIVER_CFG_BASE 0x8000 - -/* Should driver perform wlan node caching? */ -#define AR6000_DRIVER_CFG_GET_WLANNODECACHING 0x8001 -/*Should we log raw WMI msgs */ -#define AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS 0x8002 - -/* used by AR6000_XIOCTL_DIAG_READ & AR6000_XIOCTL_DIAG_WRITE */ -struct ar6000_diag_window_cmd_s { - unsigned int addr; - unsigned int value; -}; - - -struct ar6000_traffic_activity_change { - u32 StreamID; /* stream ID to indicate activity change */ - u32 Active; /* active (1) or inactive (0) */ -}; - -/* Used with AR6000_XIOCTL_PROF_COUNT_GET */ -struct prof_count_s { - u32 addr; /* bin start address */ - u32 count; /* hit count */ -}; - - -/* used by AR6000_XIOCTL_MODULE_DEBUG_SET_MASK */ -/* AR6000_XIOCTL_MODULE_DEBUG_GET_MASK */ -/* AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO */ -struct drv_debug_module_s { - char modulename[128]; /* name of module */ - u32 mask; /* new mask to set .. or .. current mask */ -}; - - -/* All HCI related rx events are sent up to the host app - * via a wmi event id. It can contain ACL data or HCI event, - * based on which it will be de-multiplexed. - */ -typedef enum { - PAL_HCI_EVENT = 0, - PAL_HCI_RX_DATA, -} WMI_PAL_EVENT_INFO; - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/drivers/staging/ath6kl/os/linux/include/cfg80211.h b/drivers/staging/ath6kl/os/linux/include/cfg80211.h deleted file mode 100644 index d5253207b19..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/cfg80211.h +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _AR6K_CFG80211_H_ -#define _AR6K_CFG80211_H_ - -struct wireless_dev *ar6k_cfg80211_init(struct device *dev); -void ar6k_cfg80211_deinit(struct ar6_softc *ar); - -void ar6k_cfg80211_scanComplete_event(struct ar6_softc *ar, int status); - -void ar6k_cfg80211_connect_event(struct ar6_softc *ar, u16 channel, - u8 *bssid, u16 listenInterval, - u16 beaconInterval,NETWORK_TYPE networkType, - u8 beaconIeLen, u8 assocReqLen, - u8 assocRespLen, u8 *assocInfo); - -void ar6k_cfg80211_disconnect_event(struct ar6_softc *ar, u8 reason, - u8 *bssid, u8 assocRespLen, - u8 *assocInfo, u16 protocolReasonStatus); - -void ar6k_cfg80211_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast); - -#ifdef CONFIG_NL80211_TESTMODE -void ar6000_testmode_rx_report_event(struct ar6_softc *ar, void *buf, - int buf_len); -#else -static inline void ar6000_testmode_rx_report_event(struct ar6_softc *ar, - void *buf, int buf_len) -{ -} -#endif - - -#endif /* _AR6K_CFG80211_H_ */ - - - - - - diff --git a/drivers/staging/ath6kl/os/linux/include/config_linux.h b/drivers/staging/ath6kl/os/linux/include/config_linux.h deleted file mode 100644 index dbbe1a00b92..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/config_linux.h +++ /dev/null @@ -1,51 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _CONFIG_LINUX_H_ -#define _CONFIG_LINUX_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Host side Test Command support - */ -#define CONFIG_HOST_TCMD_SUPPORT - -#define USE_4BYTE_REGISTER_ACCESS - -/* Host-side support for Target-side profiling */ -#undef CONFIG_TARGET_PROFILE_SUPPORT - -/* IP/TCP checksum offload */ -/* Checksum offload is currently not supported for 64 bit platforms */ -#ifndef __LP64__ -#define CONFIG_CHECKSUM_OFFLOAD -#endif /* __LP64__ */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/staging/ath6kl/os/linux/include/debug_linux.h b/drivers/staging/ath6kl/os/linux/include/debug_linux.h deleted file mode 100644 index b8dba52badc..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/debug_linux.h +++ /dev/null @@ -1,50 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _DEBUG_LINUX_H_ -#define _DEBUG_LINUX_H_ - - /* macro to remove parens */ -#define ATH_PRINTX_ARG(arg...) arg - -#ifdef DEBUG - /* NOTE: the AR_DEBUG_PRINTF macro is defined here to handle special handling of variable arg macros - * which may be compiler dependent. */ -#define AR_DEBUG_PRINTF(mask, args) do { \ - if (GET_ATH_MODULE_DEBUG_VAR_MASK(ATH_MODULE_NAME) & (mask)) { \ - A_LOGGER(mask, ATH_MODULE_NAME, ATH_PRINTX_ARG args); \ - } \ -} while (0) -#else - /* on non-debug builds, keep in error and warning messages in the driver, all other - * message tracing will get compiled out */ -#define AR_DEBUG_PRINTF(mask, args) \ - if ((mask) & (ATH_DEBUG_ERR | ATH_DEBUG_WARN)) { A_PRINTF(ATH_PRINTX_ARG args); } - -#endif - - /* compile specific macro to get the function name string */ -#define _A_FUNCNAME_ __func__ - - -#endif /* _DEBUG_LINUX_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/export_hci_transport.h b/drivers/staging/ath6kl/os/linux/include/export_hci_transport.h deleted file mode 100644 index 74f98618334..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/export_hci_transport.h +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// HCI bridge implementation -// -// Author(s): ="Atheros" -//============================================================================== - -#include "hci_transport_api.h" -#include "common_drv.h" - -extern HCI_TRANSPORT_HANDLE (*_HCI_TransportAttach)(void *HTCHandle, struct hci_transport_config_info *pInfo); -extern void (*_HCI_TransportDetach)(HCI_TRANSPORT_HANDLE HciTrans); -extern int (*_HCI_TransportAddReceivePkts)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue); -extern int (*_HCI_TransportSendPkt)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous); -extern void (*_HCI_TransportStop)(HCI_TRANSPORT_HANDLE HciTrans); -extern int (*_HCI_TransportStart)(HCI_TRANSPORT_HANDLE HciTrans); -extern int (*_HCI_TransportEnableDisableAsyncRecv)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); -extern int (*_HCI_TransportRecvHCIEventSync)(HCI_TRANSPORT_HANDLE HciTrans, - struct htc_packet *pPacket, - int MaxPollMS); -extern int (*_HCI_TransportSetBaudRate)(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud); -extern int (*_HCI_TransportEnablePowerMgmt)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); - - -#define HCI_TransportAttach(HTCHandle, pInfo) \ - _HCI_TransportAttach((HTCHandle), (pInfo)) -#define HCI_TransportDetach(HciTrans) \ - _HCI_TransportDetach(HciTrans) -#define HCI_TransportAddReceivePkts(HciTrans, pQueue) \ - _HCI_TransportAddReceivePkts((HciTrans), (pQueue)) -#define HCI_TransportSendPkt(HciTrans, pPacket, Synchronous) \ - _HCI_TransportSendPkt((HciTrans), (pPacket), (Synchronous)) -#define HCI_TransportStop(HciTrans) \ - _HCI_TransportStop((HciTrans)) -#define HCI_TransportStart(HciTrans) \ - _HCI_TransportStart((HciTrans)) -#define HCI_TransportEnableDisableAsyncRecv(HciTrans, Enable) \ - _HCI_TransportEnableDisableAsyncRecv((HciTrans), (Enable)) -#define HCI_TransportRecvHCIEventSync(HciTrans, pPacket, MaxPollMS) \ - _HCI_TransportRecvHCIEventSync((HciTrans), (pPacket), (MaxPollMS)) -#define HCI_TransportSetBaudRate(HciTrans, Baud) \ - _HCI_TransportSetBaudRate((HciTrans), (Baud)) -#define HCI_TransportEnablePowerMgmt(HciTrans, Enable) \ - _HCI_TransportEnablePowerMgmt((HciTrans), (Enable)) - - -extern int ar6000_register_hci_transport(struct hci_transport_callbacks *hciTransCallbacks); - -extern int ar6000_get_hif_dev(struct hif_device *device, void *config); - -extern int ar6000_set_uart_config(struct hif_device *hifDevice, u32 scale, u32 step); - -/* get core clock register settings - * data: 0 - 40/44MHz - * 1 - 80/88MHz - * where (5G band/2.4G band) - * assume 2.4G band for now - */ -extern int ar6000_get_core_clock_config(struct hif_device *hifDevice, u32 *data); diff --git a/drivers/staging/ath6kl/os/linux/include/ieee80211_ioctl.h b/drivers/staging/ath6kl/os/linux/include/ieee80211_ioctl.h deleted file mode 100644 index e6e96de3fc6..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/ieee80211_ioctl.h +++ /dev/null @@ -1,177 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _IEEE80211_IOCTL_H_ -#define _IEEE80211_IOCTL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Extracted from the MADWIFI net80211/ieee80211_ioctl.h - */ - -/* - * WPA/RSN get/set key request. Specify the key/cipher - * type and whether the key is to be used for sending and/or - * receiving. The key index should be set only when working - * with global keys (use IEEE80211_KEYIX_NONE for ``no index''). - * Otherwise a unicast/pairwise key is specified by the bssid - * (on a station) or mac address (on an ap). They key length - * must include any MIC key data; otherwise it should be no - more than IEEE80211_KEYBUF_SIZE. - */ -struct ieee80211req_key { - u_int8_t ik_type; /* key/cipher type */ - u_int8_t ik_pad; - u_int16_t ik_keyix; /* key index */ - u_int8_t ik_keylen; /* key length in bytes */ - u_int8_t ik_flags; -#define IEEE80211_KEY_XMIT 0x01 -#define IEEE80211_KEY_RECV 0x02 -#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */ - u_int8_t ik_macaddr[IEEE80211_ADDR_LEN]; - u_int64_t ik_keyrsc; /* key receive sequence counter */ - u_int64_t ik_keytsc; /* key transmit sequence counter */ - u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; -}; -/* - * Delete a key either by index or address. Set the index - * to IEEE80211_KEYIX_NONE when deleting a unicast key. - */ -struct ieee80211req_del_key { - u_int8_t idk_keyix; /* key index */ - u_int8_t idk_macaddr[IEEE80211_ADDR_LEN]; -}; -/* - * MLME state manipulation request. IEEE80211_MLME_ASSOC - * only makes sense when operating as a station. The other - * requests can be used when operating as a station or an - * ap (to effect a station). - */ -struct ieee80211req_mlme { - u_int8_t im_op; /* operation to perform */ -#define IEEE80211_MLME_ASSOC 1 /* associate station */ -#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */ -#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */ -#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */ -#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */ - u_int16_t im_reason; /* 802.11 reason code */ - u_int8_t im_macaddr[IEEE80211_ADDR_LEN]; -}; - -struct ieee80211req_addpmkid { - u_int8_t pi_bssid[IEEE80211_ADDR_LEN]; - u_int8_t pi_enable; - u_int8_t pi_pmkid[16]; -}; - -#define AUTH_ALG_OPEN_SYSTEM 0x01 -#define AUTH_ALG_SHARED_KEY 0x02 -#define AUTH_ALG_LEAP 0x04 - -struct ieee80211req_authalg { - u_int8_t auth_alg; -}; - -/* - * Request to add an IE to a Management Frame - */ -enum{ - IEEE80211_APPIE_FRAME_BEACON = 0, - IEEE80211_APPIE_FRAME_PROBE_REQ = 1, - IEEE80211_APPIE_FRAME_PROBE_RESP = 2, - IEEE80211_APPIE_FRAME_ASSOC_REQ = 3, - IEEE80211_APPIE_FRAME_ASSOC_RESP = 4, - IEEE80211_APPIE_NUM_OF_FRAME = 5 -}; - -/* - * The Maximum length of the IE that can be added to a Management frame - */ -#define IEEE80211_APPIE_FRAME_MAX_LEN 200 - -struct ieee80211req_getset_appiebuf { - u_int32_t app_frmtype; /* management frame type for which buffer is added */ - u_int32_t app_buflen; /*application supplied buffer length */ - u_int8_t app_buf[]; -}; - -/* - * The following definitions are used by an application to set filter - * for receiving management frames - */ -enum { - IEEE80211_FILTER_TYPE_BEACON = 0x1, - IEEE80211_FILTER_TYPE_PROBE_REQ = 0x2, - IEEE80211_FILTER_TYPE_PROBE_RESP = 0x4, - IEEE80211_FILTER_TYPE_ASSOC_REQ = 0x8, - IEEE80211_FILTER_TYPE_ASSOC_RESP = 0x10, - IEEE80211_FILTER_TYPE_AUTH = 0x20, - IEEE80211_FILTER_TYPE_DEAUTH = 0x40, - IEEE80211_FILTER_TYPE_DISASSOC = 0x80, - IEEE80211_FILTER_TYPE_ALL = 0xFF /* used to check the valid filter bits */ -}; - -struct ieee80211req_set_filter { - u_int32_t app_filterype; /* management frame filter type */ -}; - -enum { - IEEE80211_PARAM_AUTHMODE = 3, /* Authentication Mode */ - IEEE80211_PARAM_MCASTCIPHER = 5, - IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */ - IEEE80211_PARAM_UCASTCIPHER = 8, - IEEE80211_PARAM_UCASTKEYLEN = 9, /* unicast key length */ - IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */ - IEEE80211_PARAM_ROAMING = 12, /* roaming mode */ - IEEE80211_PARAM_PRIVACY = 13, /* privacy invoked */ - IEEE80211_PARAM_COUNTERMEASURES = 14, /* WPA/TKIP countermeasures */ - IEEE80211_PARAM_DROPUNENCRYPTED = 15, /* discard unencrypted frames */ - IEEE80211_PARAM_WAPI = 16, /* WAPI policy from wapid */ -}; - -/* - * Values for IEEE80211_PARAM_WPA - */ -#define WPA_MODE_WPA1 1 -#define WPA_MODE_WPA2 2 -#define WPA_MODE_AUTO 3 -#define WPA_MODE_NONE 4 - -struct ieee80211req_wpaie { - u_int8_t wpa_macaddr[IEEE80211_ADDR_LEN]; - u_int8_t wpa_ie[IEEE80211_MAX_IE]; - u_int8_t rsn_ie[IEEE80211_MAX_IE]; -}; - -#ifndef IW_ENCODE_ALG_PMK -#define IW_ENCODE_ALG_PMK 4 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _IEEE80211_IOCTL_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/osapi_linux.h b/drivers/staging/ath6kl/os/linux/include/osapi_linux.h deleted file mode 100644 index 41f43730772..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/osapi_linux.h +++ /dev/null @@ -1,339 +0,0 @@ -//------------------------------------------------------------------------------ -// This file contains the definitions of the basic atheros data types. -// It is used to map the data types in atheros files to a platform specific -// type. -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _OSAPI_LINUX_H_ -#define _OSAPI_LINUX_H_ - -#ifdef __KERNEL__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#define __ATTRIB_PACK __attribute__ ((packed)) -#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2))) -#define __ATTRIB_NORETURN __attribute__ ((noreturn)) -#ifndef INLINE -#define INLINE __inline__ -#endif -#else /* Not GCC */ -#define __ATTRIB_PACK -#define __ATTRIB_PRINTF -#define __ATTRIB_NORETURN -#ifndef INLINE -#define INLINE __inline -#endif -#endif /* End __GNUC__ */ - -#define PREPACK -#define POSTPACK __ATTRIB_PACK - -/* - * Endianes macros - */ -#define A_BE2CPU8(x) ntohb(x) -#define A_BE2CPU16(x) ntohs(x) -#define A_BE2CPU32(x) ntohl(x) - -#define A_LE2CPU8(x) (x) -#define A_LE2CPU16(x) (x) -#define A_LE2CPU32(x) (x) - -#define A_CPU2BE8(x) htonb(x) -#define A_CPU2BE16(x) htons(x) -#define A_CPU2BE32(x) htonl(x) - -#define A_MEMZERO(addr, len) memset(addr, 0, len) -#define A_MALLOC(size) kmalloc((size), GFP_KERNEL) -#define A_MALLOC_NOWAIT(size) kmalloc((size), GFP_ATOMIC) - -#define A_LOGGER(mask, mod, args...) printk(KERN_ALERT args) -#define A_PRINTF(args...) printk(KERN_ALERT args) - -#define A_PRINTF_LOG(args...) printk(args) -#define A_SPRINTF(buf, args...) sprintf (buf, args) - -/* Mutual Exclusion */ -typedef spinlock_t A_MUTEX_T; -#define A_MUTEX_INIT(mutex) spin_lock_init(mutex) -#define A_MUTEX_LOCK(mutex) spin_lock_bh(mutex) -#define A_MUTEX_UNLOCK(mutex) spin_unlock_bh(mutex) -#define A_IS_MUTEX_VALID(mutex) true /* okay to return true, since A_MUTEX_DELETE does nothing */ -#define A_MUTEX_DELETE(mutex) /* spin locks are not kernel resources so nothing to free.. */ - -/* Get current time in ms adding a constant offset (in ms) */ -#define A_GET_MS(offset) \ - (((jiffies / HZ) * 1000) + (offset)) - -/* - * Timer Functions - */ -#define A_MDELAY(msecs) mdelay(msecs) -typedef struct timer_list A_TIMER; - -#define A_INIT_TIMER(pTimer, pFunction, pArg) do { \ - init_timer(pTimer); \ - (pTimer)->function = (pFunction); \ - (pTimer)->data = (unsigned long)(pArg); \ -} while (0) - -/* - * Start a Timer that elapses after 'periodMSec' milli-seconds - * Support is provided for a one-shot timer. The 'repeatFlag' is - * ignored. - */ -#define A_TIMEOUT_MS(pTimer, periodMSec, repeatFlag) do { \ - if (repeatFlag) { \ - printk("\n" __FILE__ ":%d: Timer Repeat requested\n",__LINE__); \ - panic("Timer Repeat"); \ - } \ - mod_timer((pTimer), jiffies + HZ * (periodMSec) / 1000); \ -} while (0) - -/* - * Cancel the Timer. - */ -#define A_UNTIMEOUT(pTimer) do { \ - del_timer((pTimer)); \ -} while (0) - -#define A_DELETE_TIMER(pTimer) do { \ -} while (0) - -/* - * Wait Queue related functions - */ -typedef wait_queue_head_t A_WAITQUEUE_HEAD; -#define A_INIT_WAITQUEUE_HEAD(head) init_waitqueue_head(head) -#ifndef wait_event_interruptible_timeout -#define __wait_event_interruptible_timeout(wq, condition, ret) \ -do { \ - wait_queue_t __wait; \ - init_waitqueue_entry(&__wait, current); \ - \ - add_wait_queue(&wq, &__wait); \ - for (;;) { \ - set_current_state(TASK_INTERRUPTIBLE); \ - if (condition) \ - break; \ - if (!signal_pending(current)) { \ - ret = schedule_timeout(ret); \ - if (!ret) \ - break; \ - continue; \ - } \ - ret = -ERESTARTSYS; \ - break; \ - } \ - current->state = TASK_RUNNING; \ - remove_wait_queue(&wq, &__wait); \ -} while (0) - -#define wait_event_interruptible_timeout(wq, condition, timeout) \ -({ \ - long __ret = timeout; \ - if (!(condition)) \ - __wait_event_interruptible_timeout(wq, condition, __ret); \ - __ret; \ -}) -#endif /* wait_event_interruptible_timeout */ - -#define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \ - wait_event_interruptible_timeout(head, condition, timeout); \ -} while (0) - -#define A_WAKE_UP(head) wake_up(head) - -#ifdef DEBUG -extern unsigned int panic_on_assert; -#define A_ASSERT(expr) \ - if (!(expr)) { \ - printk(KERN_ALERT"Debug Assert Caught, File %s, Line: %d, Test:%s \n",__FILE__, __LINE__,#expr); \ - if (panic_on_assert) panic(#expr); \ - } -#else -#define A_ASSERT(expr) -#endif /* DEBUG */ - -#define A_REQUEST_FIRMWARE(_ppf, _pfile, _dev) request_firmware(_ppf, _pfile, _dev) -#define A_RELEASE_FIRMWARE(_pf) release_firmware(_pf) - -/* - * Initialization of the network buffer subsystem - */ -#define A_NETBUF_INIT() - -/* - * Network buffer queue support - */ -typedef struct sk_buff_head A_NETBUF_QUEUE_T; - -#define A_NETBUF_QUEUE_INIT(q) \ - a_netbuf_queue_init(q) - -#define A_NETBUF_ENQUEUE(q, pkt) \ - a_netbuf_enqueue((q), (pkt)) -#define A_NETBUF_PREQUEUE(q, pkt) \ - a_netbuf_prequeue((q), (pkt)) -#define A_NETBUF_DEQUEUE(q) \ - (a_netbuf_dequeue(q)) -#define A_NETBUF_QUEUE_SIZE(q) \ - a_netbuf_queue_size(q) -#define A_NETBUF_QUEUE_EMPTY(q) \ - (a_netbuf_queue_empty(q) ? true : false) - -/* - * Network buffer support - */ -#define A_NETBUF_ALLOC(size) \ - a_netbuf_alloc(size) -#define A_NETBUF_ALLOC_RAW(size) \ - a_netbuf_alloc_raw(size) -#define A_NETBUF_FREE(bufPtr) \ - a_netbuf_free(bufPtr) -#define A_NETBUF_DATA(bufPtr) \ - a_netbuf_to_data(bufPtr) -#define A_NETBUF_LEN(bufPtr) \ - a_netbuf_to_len(bufPtr) -#define A_NETBUF_PUSH(bufPtr, len) \ - a_netbuf_push(bufPtr, len) -#define A_NETBUF_PUT(bufPtr, len) \ - a_netbuf_put(bufPtr, len) -#define A_NETBUF_TRIM(bufPtr,len) \ - a_netbuf_trim(bufPtr, len) -#define A_NETBUF_PULL(bufPtr, len) \ - a_netbuf_pull(bufPtr, len) -#define A_NETBUF_HEADROOM(bufPtr)\ - a_netbuf_headroom(bufPtr) -#define A_NETBUF_SETLEN(bufPtr,len) \ - a_netbuf_setlen(bufPtr, len) - -/* Add data to end of a buffer */ -#define A_NETBUF_PUT_DATA(bufPtr, srcPtr, len) \ - a_netbuf_put_data(bufPtr, srcPtr, len) - -/* Add data to start of the buffer */ -#define A_NETBUF_PUSH_DATA(bufPtr, srcPtr, len) \ - a_netbuf_push_data(bufPtr, srcPtr, len) - -/* Remove data at start of the buffer */ -#define A_NETBUF_PULL_DATA(bufPtr, dstPtr, len) \ - a_netbuf_pull_data(bufPtr, dstPtr, len) - -/* Remove data from the end of the buffer */ -#define A_NETBUF_TRIM_DATA(bufPtr, dstPtr, len) \ - a_netbuf_trim_data(bufPtr, dstPtr, len) - -/* View data as "size" contiguous bytes of type "t" */ -#define A_NETBUF_VIEW_DATA(bufPtr, t, size) \ - (t )( ((struct skbuf *)(bufPtr))->data) - -/* return the beginning of the headroom for the buffer */ -#define A_NETBUF_HEAD(bufPtr) \ - ((((struct sk_buff *)(bufPtr))->head)) - -/* - * OS specific network buffer access routines - */ -void *a_netbuf_alloc(int size); -void *a_netbuf_alloc_raw(int size); -void a_netbuf_free(void *bufPtr); -void *a_netbuf_to_data(void *bufPtr); -u32 a_netbuf_to_len(void *bufPtr); -int a_netbuf_push(void *bufPtr, s32 len); -int a_netbuf_push_data(void *bufPtr, char *srcPtr, s32 len); -int a_netbuf_put(void *bufPtr, s32 len); -int a_netbuf_put_data(void *bufPtr, char *srcPtr, s32 len); -int a_netbuf_pull(void *bufPtr, s32 len); -int a_netbuf_pull_data(void *bufPtr, char *dstPtr, s32 len); -int a_netbuf_trim(void *bufPtr, s32 len); -int a_netbuf_trim_data(void *bufPtr, char *dstPtr, s32 len); -int a_netbuf_setlen(void *bufPtr, s32 len); -s32 a_netbuf_headroom(void *bufPtr); -void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt); -void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt); -void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q); -int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q); -int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q); -int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q); -void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q); - -/* - * Kernel v.s User space functions - */ -u32 a_copy_to_user(void *to, const void *from, u32 n); -u32 a_copy_from_user(void *to, const void *from, u32 n); - -/* In linux, WLAN Rx and Tx run in different contexts, so no need to check - * for any commands/data queued for WLAN */ -#define A_CHECK_DRV_TX() - -#define A_GET_CACHE_LINE_BYTES() L1_CACHE_BYTES - -#define A_CACHE_LINE_PAD 128 - -static inline void *A_ALIGN_TO_CACHE_LINE(void *ptr) { - return (void *)L1_CACHE_ALIGN((unsigned long)ptr); -} - -#else /* __KERNEL__ */ - -#ifdef __GNUC__ -#define __ATTRIB_PACK __attribute__ ((packed)) -#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2))) -#define __ATTRIB_NORETURN __attribute__ ((noreturn)) -#ifndef INLINE -#define INLINE __inline__ -#endif -#else /* Not GCC */ -#define __ATTRIB_PACK -#define __ATTRIB_PRINTF -#define __ATTRIB_NORETURN -#ifndef INLINE -#define INLINE __inline -#endif -#endif /* End __GNUC__ */ - -#define PREPACK -#define POSTPACK __ATTRIB_PACK - -#define A_MEMZERO(addr, len) memset((addr), 0, (len)) -#define A_MALLOC(size) malloc(size) - -#include - -#endif /* __KERNEL__ */ - -#endif /* _OSAPI_LINUX_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/wlan_config.h b/drivers/staging/ath6kl/os/linux/include/wlan_config.h deleted file mode 100644 index c1fe0c6e4fa..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/wlan_config.h +++ /dev/null @@ -1,108 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains the tunable configuration items for the WLAN module -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _HOST_WLAN_CONFIG_H_ -#define _HOST_WLAN_CONFIG_H_ - -/* Include definitions here that can be used to tune the WLAN module behavior. - * Different customers can tune the behavior as per their needs, here. - */ - -/* This configuration item when defined will consider the barker preamble - * mentioned in the ERP IE of the beacons from the AP to determine the short - * preamble support sent in the (Re)Assoc request frames. - */ -#define WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP 0 - -/* This config item when defined will not send the power module state transition - * failure events that happen during scan, to the host. - */ -#define WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN 0 - -/* - * This configuration item enable/disable keepalive support. - * Keepalive support: In the absence of any data traffic to AP, null - * frames will be sent to the AP at periodic interval, to keep the association - * active. This configuration item defines the periodic interval. - * Use value of zero to disable keepalive support - * Default: 60 seconds - */ -#define WLAN_CONFIG_KEEP_ALIVE_INTERVAL 60 - -/* - * This configuration item sets the value of disconnect timeout - * Firmware delays sending the disconnec event to the host for this - * timeout after is gets disconnected from the current AP. - * If the firmware successly roams within the disconnect timeout - * it sends a new connect event - */ -#define WLAN_CONFIG_DISCONNECT_TIMEOUT 10 - -/* - * This configuration item disables 11n support. - * 0 - Enable - * 1 - Disable - */ -#define WLAN_CONFIG_DISABLE_11N 0 - -/* - * This configuration item enable BT clock sharing support - * 1 - Enable - * 0 - Disable (Default) - */ -#define WLAN_CONFIG_BT_SHARING 0 - -/* - * This configuration item sets WIFI OFF policy - * 0 - CUT_POWER - * 1 - DEEP_SLEEP (Default) - */ -#define WLAN_CONFIG_WLAN_OFF 1 - -/* - * This configuration item sets suspend policy - * 0 - CUT_POWER (Default) - * 1 - DEEP_SLEEP - * 2 - WoW - * 3 - CUT_POWER if BT OFF (clock sharing designs only) - */ -#define WLAN_CONFIG_PM_SUSPEND 0 - -/* - * This configuration item sets suspend policy to use if PM_SUSPEND is - * set to WoW and device is not connected at the time of suspend - * 0 - CUT_POWER (Default) - * 1 - DEEP_SLEEP - * 2 - WoW - * 3 - CUT_POWER if BT OFF (clock sharing designs only) - */ -#define WLAN_CONFIG_PM_WOW2 0 - -/* - * This configuration item enables/disables transmit bursting - * 0 - Enable tx Bursting (default) - * 1 - Disable tx bursting - */ -#define WLAN_CONFIG_DISABLE_TX_BURSTING 0 - -#endif /* _HOST_WLAN_CONFIG_H_ */ diff --git a/drivers/staging/ath6kl/os/linux/include/wmi_filter_linux.h b/drivers/staging/ath6kl/os/linux/include/wmi_filter_linux.h deleted file mode 100644 index 1eb6f822d64..00000000000 --- a/drivers/staging/ath6kl/os/linux/include/wmi_filter_linux.h +++ /dev/null @@ -1,300 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ - -#ifndef _WMI_FILTER_LINUX_H_ -#define _WMI_FILTER_LINUX_H_ - -/* - * sioctl_filter - Standard ioctl - * pioctl_filter - Priv ioctl - * xioctl_filter - eXtended ioctl - * - * ---- Possible values for the WMI filter --------------- - * (0) - Block this cmd always (or) not implemented - * (INFRA_NETWORK) - Allow this cmd only in STA mode - * (ADHOC_NETWORK) - Allow this cmd only in IBSS mode - * (AP_NETWORK) - Allow this cmd only in AP mode - * (INFRA_NETWORK | ADHOC_NETWORK) - Block this cmd in AP mode - * (ADHOC_NETWORK | AP_NETWORK) - Block this cmd in STA mode - * (INFRA_NETWORK | AP_NETWORK) - Block this cmd in IBSS mode - * (INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK)- allow only when mode is set - * (0xFF) - Allow this cmd always irrespective of mode - */ - -u8 sioctl_filter[] = { -(AP_NETWORK), /* SIOCSIWCOMMIT 0x8B00 */ -(0xFF), /* SIOCGIWNAME 0x8B01 */ -(0), /* SIOCSIWNWID 0x8B02 */ -(0), /* SIOCGIWNWID 0x8B03 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWFREQ 0x8B04 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWFREQ 0x8B05 */ -(0xFF), /* SIOCSIWMODE 0x8B06 */ -(0xFF), /* SIOCGIWMODE 0x8B07 */ -(0), /* SIOCSIWSENS 0x8B08 */ -(0), /* SIOCGIWSENS 0x8B09 */ -(0), /* SIOCSIWRANGE 0x8B0A */ -(0xFF), /* SIOCGIWRANGE 0x8B0B */ -(0), /* SIOCSIWPRIV 0x8B0C */ -(0), /* SIOCGIWPRIV 0x8B0D */ -(0), /* SIOCSIWSTATS 0x8B0E */ -(0), /* SIOCGIWSTATS 0x8B0F */ -(0), /* SIOCSIWSPY 0x8B10 */ -(0), /* SIOCGIWSPY 0x8B11 */ -(0), /* SIOCSIWTHRSPY 0x8B12 */ -(0), /* SIOCGIWTHRSPY 0x8B13 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWAP 0x8B14 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWAP 0x8B15 */ -#if (WIRELESS_EXT >= 18) -(INFRA_NETWORK | ADHOC_NETWORK), /* SIOCSIWMLME 0X8B16 */ -#else -(0), /* Dummy 0 */ -#endif /* WIRELESS_EXT */ -(0), /* SIOCGIWAPLIST 0x8B17 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* SIOCSIWSCAN 0x8B18 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* SIOCGIWSCAN 0x8B19 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWESSID 0x8B1A */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWESSID 0x8B1B */ -(0), /* SIOCSIWNICKN 0x8B1C */ -(0), /* SIOCGIWNICKN 0x8B1D */ -(0), /* Dummy 0 */ -(0), /* Dummy 0 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWRATE 0x8B20 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWRATE 0x8B21 */ -(0), /* SIOCSIWRTS 0x8B22 */ -(0), /* SIOCGIWRTS 0x8B23 */ -(0), /* SIOCSIWFRAG 0x8B24 */ -(0), /* SIOCGIWFRAG 0x8B25 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWTXPOW 0x8B26 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWTXPOW 0x8B27 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* SIOCSIWRETRY 0x8B28 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* SIOCGIWRETRY 0x8B29 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWENCODE 0x8B2A */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWENCODE 0x8B2B */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCSIWPOWER 0x8B2C */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* SIOCGIWPOWER 0x8B2D */ -}; - - - -u8 pioctl_filter[] = { -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* IEEE80211_IOCTL_SETPARAM (SIOCIWFIRSTPRIV+0) */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* IEEE80211_IOCTL_SETKEY (SIOCIWFIRSTPRIV+1) */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* IEEE80211_IOCTL_DELKEY (SIOCIWFIRSTPRIV+2) */ -(AP_NETWORK), /* IEEE80211_IOCTL_SETMLME (SIOCIWFIRSTPRIV+3) */ -(INFRA_NETWORK), /* IEEE80211_IOCTL_ADDPMKID (SIOCIWFIRSTPRIV+4) */ -(0), /* IEEE80211_IOCTL_SETOPTIE (SIOCIWFIRSTPRIV+5) */ -(0), /* (SIOCIWFIRSTPRIV+6) */ -(0), /* (SIOCIWFIRSTPRIV+7) */ -(0), /* (SIOCIWFIRSTPRIV+8) */ -(0), /* (SIOCIWFIRSTPRIV+9) */ -(0), /* IEEE80211_IOCTL_LASTONE (SIOCIWFIRSTPRIV+10) */ -(0xFF), /* AR6000_IOCTL_WMI_GETREV (SIOCIWFIRSTPRIV+11) */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_IOCTL_WMI_SETPWR (SIOCIWFIRSTPRIV+12) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SETSCAN (SIOCIWFIRSTPRIV+13) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SETLISTENINT (SIOCIWFIRSTPRIV+14) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SETBSSFILTER (SIOCIWFIRSTPRIV+15) */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_IOCTL_WMI_SET_CHANNELPARAMS (SIOCIWFIRSTPRIV+16) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_PROBEDSSID (SIOCIWFIRSTPRIV+17) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_PMPARAMS (SIOCIWFIRSTPRIV+18) */ -(INFRA_NETWORK), /* AR6000_IOCTL_WMI_SET_BADAP (SIOCIWFIRSTPRIV+19) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_GET_QOS_QUEUE (SIOCIWFIRSTPRIV+20) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_CREATE_QOS (SIOCIWFIRSTPRIV+21) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_DELETE_QOS (SIOCIWFIRSTPRIV+22) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_SNRTHRESHOLD (SIOCIWFIRSTPRIV+23) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK (SIOCIWFIRSTPRIV+24)*/ -(0xFF), /* AR6000_IOCTL_WMI_GET_TARGET_STATS (SIOCIWFIRSTPRIV+25) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_ASSOC_INFO (SIOCIWFIRSTPRIV+26) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_ACCESS_PARAMS (SIOCIWFIRSTPRIV+27) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_BMISS_TIME (SIOCIWFIRSTPRIV+28) */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_DISC_TIMEOUT (SIOCIWFIRSTPRIV+29) */ -(ADHOC_NETWORK), /* AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS (SIOCIWFIRSTPRIV+30) */ -}; - - - -u8 xioctl_filter[] = { -(0xFF), /* Dummy 0 */ -(0xFF), /* AR6000_XIOCTL_BMI_DONE 1 */ -(0xFF), /* AR6000_XIOCTL_BMI_READ_MEMORY 2 */ -(0xFF), /* AR6000_XIOCTL_BMI_WRITE_MEMORY 3 */ -(0xFF), /* AR6000_XIOCTL_BMI_EXECUTE 4 */ -(0xFF), /* AR6000_XIOCTL_BMI_SET_APP_START 5 */ -(0xFF), /* AR6000_XIOCTL_BMI_READ_SOC_REGISTER 6 */ -(0xFF), /* AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER 7 */ -(0xFF), /* AR6000_XIOCTL_BMI_TEST 8 */ -(0xFF), /* AR6000_XIOCTL_UNUSED9 9 */ -(0xFF), /* AR6000_XIOCTL_UNUSED10 10 */ -(0xFF), /* AR6000_XIOCTL_UNUSED11 11 */ -(0xFF), /* AR6000_XIOCTL_FORCE_TARGET_RESET 12 */ -(0xFF), /* AR6000_XIOCTL_HTC_RAW_OPEN 13 */ -(0xFF), /* AR6000_XIOCTL_HTC_RAW_CLOSE 14 */ -(0xFF), /* AR6000_XIOCTL_HTC_RAW_READ 15 */ -(0xFF), /* AR6000_XIOCTL_HTC_RAW_WRITE 16 */ -(0xFF), /* AR6000_XIOCTL_CHECK_TARGET_READY 17 */ -(0xFF), /* AR6000_XIOCTL_GPIO_OUTPUT_SET 18 */ -(0xFF), /* AR6000_XIOCTL_GPIO_INPUT_GET 19 */ -(0xFF), /* AR6000_XIOCTL_GPIO_REGISTER_SET 20 */ -(0xFF), /* AR6000_XIOCTL_GPIO_REGISTER_GET 21 */ -(0xFF), /* AR6000_XIOCTL_GPIO_INTR_ACK 22 */ -(0xFF), /* AR6000_XIOCTL_GPIO_INTR_WAIT 23 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_SET_ADHOC_BSSID 24 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_SET_OPT_MODE 25 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_OPT_SEND_FRAME 26 */ -(ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_SET_BEACON_INTVAL 27 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* IEEE80211_IOCTL_SETAUTHALG 28 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_SET_VOICE_PKT_SIZE 29 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_SET_MAX_SP 30 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_ROAM_TBL 31 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_ROAM_CTRL 32 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS 33 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTRL_WMI_GET_POWER_MODE 34 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTRL_WMI_SET_WLAN_STATE 35 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_ROAM_DATA 36 */ -(0xFF), /* AR6000_XIOCTL_WMI_SETRETRYLIMITS 37 */ -(0xFF), /* AR6000_XIOCTL_TCMD_CONT_TX 38 */ -(0xFF), /* AR6000_XIOCTL_TCMD_CONT_RX 39 */ -(0xFF), /* AR6000_XIOCTL_TCMD_PM 40 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_STARTSCAN 41 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_SETFIXRATES 42 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_GETFIXRATES 43 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD 44 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_CLR_RSSISNR 45 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_LQTHRESHOLD 46 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_SET_RTS 47 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_SET_LPREAMBLE 48 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_SET_AUTHMODE 49 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_REASSOCMODE 50 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_WMM 51 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS 52 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP 53 */ -(INFRA_NETWORK | ADHOC_NETWORK | AP_NETWORK), /* AR6000_XIOCTL_WMI_GET_RD 54 */ -(0xFF), /* AR6000_XIOCTL_DIAG_READ 55 */ -(0xFF), /* AR6000_XIOCTL_DIAG_WRITE 56 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_TXOP 57 */ -(INFRA_NETWORK), /* AR6000_XIOCTL_USER_SETKEYS 58 */ -(INFRA_NETWORK), /* AR6000_XIOCTL_WMI_SET_KEEPALIVE 59 */ -(INFRA_NETWORK), /* AR6000_XIOCTL_WMI_GET_KEEPALIVE 60 */ -(0xFF), /* AR6000_XIOCTL_BMI_ROMPATCH_INSTALL 61 */ -(0xFF), /* AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL 62 */ -(0xFF), /* AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE 63 */ -(0xFF), /* AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE 64 */ -(0xFF), /* AR6000_XIOCTL_WMI_SET_APPIE 65 */ -(0xFF), /* AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER 66 */ -(0xFF), /* AR6000_XIOCTL_DBGLOG_CFG_MODULE 67 */ -(0xFF), /* AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS 68 */ -(0xFF), /* Dummy 69 */ -(0xFF), /* AR6000_XIOCTL_WMI_SET_WSC_STATUS 70 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BT_STATUS 71 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BT_PARAMS 72 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE 73 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_WOW_MODE 74 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_WOW_LIST 75 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_ADD_WOW_PATTERN 76 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_DEL_WOW_PATTERN 77 */ -(0xFF), /* AR6000_XIOCTL_TARGET_INFO 78 */ -(0xFF), /* AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE 79 */ -(0xFF), /* AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE 80 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS 81 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_AKMP_PARAMS 82 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_PMKID_LIST 83 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_PMKID_LIST 84 */ -(0xFF), /* Dummy 85 */ -(0xFF), /* Dummy 86 */ -(0xFF), /* Dummy 87 */ -(0xFF), /* Dummy 88 */ -(0xFF), /* Dummy 89 */ -(0xFF), /* AR6000_XIOCTL_UNUSED90 90 */ -(0xFF), /* AR6000_XIOCTL_BMI_LZ_STREAM_START 91 */ -(0xFF), /* AR6000_XIOCTL_BMI_LZ_DATA 92 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_PROF_CFG 93 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_PROF_ADDR_SET 94 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_PROF_START 95 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_PROF_STOP 96 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_PROF_COUNT_GET 97 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_ABORT_SCAN 98 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_STA_LIST 99 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_HIDDEN_SSID 100 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_SET_NUM_STA 101 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_SET_ACL_MAC 102 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_ACL_LIST 103 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_COMMIT_CONFIG 104 */ -(AP_NETWORK), /* IEEE80211_IOCTL_GETWPAIE 105 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_CONN_INACT_TIME 106 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_PROT_SCAN_TIME 107 */ -(AP_NETWORK), /* AR6000_XIOCTL_WMI_SET_COUNTRY 108 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_SET_DTIM 109 */ -(0xFF), /* AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT 110 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_SET_IP 111 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_SET_ACL_POLICY 112 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_INTRA_BSS_COMM 113 */ -(0xFF), /* AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO 114 */ -(0xFF), /* AR6000_XIOCTL_MODULE_DEBUG_SET_MASK 115 */ -(0xFF), /* AR6000_XIOCTL_MODULE_DEBUG_GET_MASK 116 */ -(0xFF), /* AR6000_XIOCTL_DUMP_RCV_AGGR_STATS 117 */ -(0xFF), /* AR6000_XIOCTL_SET_HT_CAP 118 */ -(0xFF), /* AR6000_XIOCTL_SET_HT_OP 119 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_STAT 120 */ -(0xFF), /* AR6000_XIOCTL_SET_TX_SELECT_RATES 121 */ -(0xFF), /* AR6000_XIOCTL_SETUP_AGGR 122 */ -(0xFF), /* AR6000_XIOCTL_ALLOW_AGGR 123 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_HIDDEN_SSID 124 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_COUNTRY 125 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_WMODE 126 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_GET_DTIM 127 */ -(AP_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_AP_GET_BINTVL 128 */ -(0xFF), /* AR6000_XIOCTL_AP_GET_RTS 129 */ -(0xFF), /* AR6000_XIOCTL_DELE_AGGR 130 */ -(0xFF), /* AR6000_XIOCTL_FETCH_TARGET_REGS 131 */ -(0xFF), /* AR6000_XIOCTL_HCI_CMD 132 */ -(0xFF), /* AR6000_XIOCTL_ACL_DATA(used to be used for PAL) 133 */ -(0xFF), /* AR6000_XIOCTL_WLAN_CONN_PRECEDENCE 134 */ -(AP_NETWORK), /* AR6000_XIOCTL_AP_SET_11BG_RATESET 135 */ -(0xFF), -(0xFF), -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT 138 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV 139 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG 140 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG 141 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG 142 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG 143 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG 144 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS 145 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG 146 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_GET_BTCOEX_GET_STATS 147 */ -(0xFF), /* AR6000_XIOCTL_WMI_SET_QOS_SUPP 148 */ -(0xFF), /* AR6000_XIOCTL_GET_WLAN_SLEEP_STATE 149 */ -(0xFF), /* AR6000_XIOCTL_SET_BT_HW_POWER_STATE 150 */ -(0xFF), /* AR6000_XIOCTL_GET_BT_HW_POWER_STATE 151 */ -(0xFF), /* AR6000_XIOCTL_ADD_AP_INTERFACE 152 */ -(0xFF), /* AR6000_XIOCTL_REMOVE_AP_INTERFACE 153 */ -(0xFF), /* AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM 154 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_WPA_OFFLOAD_STATE 155 */ -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_PASSPHRASE 156 */ -(0xFF), -(0xFF), -(0xFF), -(0xFF), -(INFRA_NETWORK | ADHOC_NETWORK), /* AR6000_XIOCTL_WMI_SET_EXCESS_TX_RETRY_THRES 161 */ -}; - -#endif /*_WMI_FILTER_LINUX_H_*/ diff --git a/drivers/staging/ath6kl/os/linux/netbuf.c b/drivers/staging/ath6kl/os/linux/netbuf.c deleted file mode 100644 index 963a2fb76a9..00000000000 --- a/drivers/staging/ath6kl/os/linux/netbuf.c +++ /dev/null @@ -1,231 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Communications Inc. -// All rights reserved. -// -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -// -// Author(s): ="Atheros" -//------------------------------------------------------------------------------ -#include -#include "athdefs.h" -#include "a_osapi.h" -#include "htc_packet.h" - -#define AR6000_DATA_OFFSET 64 - -void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt) -{ - skb_queue_tail((struct sk_buff_head *) q, (struct sk_buff *) pkt); -} - -void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt) -{ - skb_queue_head((struct sk_buff_head *) q, (struct sk_buff *) pkt); -} - -void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q) -{ - return((void *) skb_dequeue((struct sk_buff_head *) q)); -} - -int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q) -{ - return(skb_queue_len((struct sk_buff_head *) q)); -} - -int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q) -{ - return(skb_queue_empty((struct sk_buff_head *) q)); -} - -void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q) -{ - skb_queue_head_init((struct sk_buff_head *) q); -} - -void * -a_netbuf_alloc(int size) -{ - struct sk_buff *skb; - size += 2 * (A_GET_CACHE_LINE_BYTES()); /* add some cacheline space at front and back of buffer */ - skb = dev_alloc_skb(AR6000_DATA_OFFSET + sizeof(struct htc_packet) + size); - skb_reserve(skb, AR6000_DATA_OFFSET + sizeof(struct htc_packet) + A_GET_CACHE_LINE_BYTES()); - return ((void *)skb); -} - -/* - * Allocate an SKB w.o. any encapsulation requirement. - */ -void * -a_netbuf_alloc_raw(int size) -{ - struct sk_buff *skb; - - skb = dev_alloc_skb(size); - - return ((void *)skb); -} - -void -a_netbuf_free(void *bufPtr) -{ - struct sk_buff *skb = (struct sk_buff *)bufPtr; - - dev_kfree_skb(skb); -} - -u32 a_netbuf_to_len(void *bufPtr) -{ - return (((struct sk_buff *)bufPtr)->len); -} - -void * -a_netbuf_to_data(void *bufPtr) -{ - return (((struct sk_buff *)bufPtr)->data); -} - -/* - * Add len # of bytes to the beginning of the network buffer - * pointed to by bufPtr - */ -int -a_netbuf_push(void *bufPtr, s32 len) -{ - skb_push((struct sk_buff *)bufPtr, len); - - return 0; -} - -/* - * Add len # of bytes to the beginning of the network buffer - * pointed to by bufPtr and also fill with data - */ -int -a_netbuf_push_data(void *bufPtr, char *srcPtr, s32 len) -{ - skb_push((struct sk_buff *) bufPtr, len); - memcpy(((struct sk_buff *)bufPtr)->data, srcPtr, len); - - return 0; -} - -/* - * Add len # of bytes to the end of the network buffer - * pointed to by bufPtr - */ -int -a_netbuf_put(void *bufPtr, s32 len) -{ - skb_put((struct sk_buff *)bufPtr, len); - - return 0; -} - -/* - * Add len # of bytes to the end of the network buffer - * pointed to by bufPtr and also fill with data - */ -int -a_netbuf_put_data(void *bufPtr, char *srcPtr, s32 len) -{ - char *start = (char*)(((struct sk_buff *)bufPtr)->data + - ((struct sk_buff *)bufPtr)->len); - skb_put((struct sk_buff *)bufPtr, len); - memcpy(start, srcPtr, len); - - return 0; -} - - -/* - * Trim the network buffer pointed to by bufPtr to len # of bytes - */ -int -a_netbuf_setlen(void *bufPtr, s32 len) -{ - skb_trim((struct sk_buff *)bufPtr, len); - - return 0; -} - -/* - * Chop of len # of bytes from the end of the buffer. - */ -int -a_netbuf_trim(void *bufPtr, s32 len) -{ - skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len); - - return 0; -} - -/* - * Chop of len # of bytes from the end of the buffer and return the data. - */ -int -a_netbuf_trim_data(void *bufPtr, char *dstPtr, s32 len) -{ - char *start = (char*)(((struct sk_buff *)bufPtr)->data + - (((struct sk_buff *)bufPtr)->len - len)); - - memcpy(dstPtr, start, len); - skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len); - - return 0; -} - - -/* - * Returns the number of bytes available to a a_netbuf_push() - */ -s32 a_netbuf_headroom(void *bufPtr) -{ - return (skb_headroom((struct sk_buff *)bufPtr)); -} - -/* - * Removes specified number of bytes from the beginning of the buffer - */ -int -a_netbuf_pull(void *bufPtr, s32 len) -{ - skb_pull((struct sk_buff *)bufPtr, len); - - return 0; -} - -/* - * Removes specified number of bytes from the beginning of the buffer - * and return the data - */ -int -a_netbuf_pull_data(void *bufPtr, char *dstPtr, s32 len) -{ - memcpy(dstPtr, ((struct sk_buff *)bufPtr)->data, len); - skb_pull((struct sk_buff *)bufPtr, len); - - return 0; -} - -#ifdef EXPORT_HCI_BRIDGE_INTERFACE -EXPORT_SYMBOL(a_netbuf_to_data); -EXPORT_SYMBOL(a_netbuf_put); -EXPORT_SYMBOL(a_netbuf_pull); -EXPORT_SYMBOL(a_netbuf_alloc); -EXPORT_SYMBOL(a_netbuf_free); -#endif diff --git a/drivers/staging/ath6kl/reorder/aggr_rx_internal.h b/drivers/staging/ath6kl/reorder/aggr_rx_internal.h deleted file mode 100644 index 11125967d53..00000000000 --- a/drivers/staging/ath6kl/reorder/aggr_rx_internal.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Copyright (c) 2004-2010 Atheros Communications Inc. - * All rights reserved. - * - * -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// - * - */ - -#ifndef __AGGR_RX_INTERNAL_H__ -#define __AGGR_RX_INTERNAL_H__ - -#include "a_osapi.h" -#include "aggr_recv_api.h" - -#define AGGR_WIN_IDX(x, y) ((x) % (y)) -#define AGGR_INCR_IDX(x, y) AGGR_WIN_IDX(((x)+1), (y)) -#define AGGR_DCRM_IDX(x, y) AGGR_WIN_IDX(((x)-1), (y)) -#define IEEE80211_MAX_SEQ_NO 0xFFF -#define IEEE80211_NEXT_SEQ_NO(x) (((x) + 1) & IEEE80211_MAX_SEQ_NO) - - -#define NUM_OF_TIDS 8 -#define AGGR_SZ_DEFAULT 8 - -#define AGGR_WIN_SZ_MIN 2 -#define AGGR_WIN_SZ_MAX 8 -/* TID Window sz is double of what is negotiated. Derive TID_WINDOW_SZ from win_sz, per tid */ -#define TID_WINDOW_SZ(_x) ((_x) << 1) - -#define AGGR_NUM_OF_FREE_NETBUFS 16 - -#define AGGR_GET_RXTID_STATS(_p, _x) (&(_p->stat[(_x)])) -#define AGGR_GET_RXTID(_p, _x) (&(_p->RxTid[(_x)])) - -/* Hold q is a function of win_sz, which is negotiated per tid */ -#define HOLD_Q_SZ(_x) (TID_WINDOW_SZ((_x))*sizeof(struct osbuf_hold_q)) -/* AGGR_RX_TIMEOUT value is important as a (too) small value can cause frames to be - * delivered out of order and a (too) large value can cause undesirable latency in - * certain situations. */ -#define AGGR_RX_TIMEOUT 400 /* Timeout(in ms) for delivery of frames, if they are stuck */ - -typedef enum { - ALL_SEQNO = 0, - CONTIGUOUS_SEQNO = 1, -}DELIVERY_ORDER; - -struct osbuf_hold_q { - void *osbuf; - bool is_amsdu; - u16 seq_no; -}; - - -#if 0 -/* XXX: unused ? */ -struct window_snapshot { - u16 seqno_st; - u16 seqno_end; -}; -#endif - -struct rxtid { - bool aggr; /* is it ON or OFF */ - bool progress; /* true when frames have arrived after a timer start */ - bool timerMon; /* true if the timer started for the sake of this TID */ - u16 win_sz; /* negotiated window size */ - u16 seq_next; /* Next seq no, in current window */ - u32 hold_q_sz; /* Num of frames that can be held in hold q */ - struct osbuf_hold_q *hold_q; /* Hold q for re-order */ -#if 0 - struct window_snapshot old_win; /* Sliding window snapshot - for timeout */ -#endif - A_NETBUF_QUEUE_T q; /* q head for enqueuing frames for dispatch */ - A_MUTEX_T lock; -}; - -struct rxtid_stats { - u32 num_into_aggr; /* hitting at the input of this module */ - u32 num_dups; /* duplicate */ - u32 num_oow; /* out of window */ - u32 num_mpdu; /* single payload 802.3/802.11 frame */ - u32 num_amsdu; /* AMSDU */ - u32 num_delivered; /* frames delivered to IP stack */ - u32 num_timeouts; /* num of timeouts, during which frames delivered */ - u32 num_hole; /* frame not present, when window moved over */ - u32 num_bar; /* num of resets of seq_num, via BAR */ -}; - -struct aggr_info { - u8 aggr_sz; /* config value of aggregation size */ - u8 timerScheduled; - A_TIMER timer; /* timer for returning held up pkts in re-order que */ - void *dev; /* dev handle */ - RX_CALLBACK rx_fn; /* callback function to return frames; to upper layer */ - struct rxtid RxTid[NUM_OF_TIDS]; /* Per tid window */ - ALLOC_NETBUFS netbuf_allocator; /* OS netbuf alloc fn */ - A_NETBUF_QUEUE_T freeQ; /* pre-allocated buffers - for A_MSDU slicing */ - struct rxtid_stats stat[NUM_OF_TIDS]; /* Tid based statistics */ - PACKET_LOG pkt_log; /* Log info of the packets */ -}; - -#endif /* __AGGR_RX_INTERNAL_H__ */ diff --git a/drivers/staging/ath6kl/reorder/rcv_aggr.c b/drivers/staging/ath6kl/reorder/rcv_aggr.c deleted file mode 100644 index 9b1509ec5a7..00000000000 --- a/drivers/staging/ath6kl/reorder/rcv_aggr.c +++ /dev/null @@ -1,661 +0,0 @@ -/* - * - * Copyright (c) 2010 Atheros Communications Inc. - * All rights reserved. - * - * -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// - * - */ - -#include -#include -#include -#include -#include "pkt_log.h" -#include "aggr_recv_api.h" -#include "aggr_rx_internal.h" -#include "wmi.h" - -extern int -wmi_dot3_2_dix(void *osbuf); - -static void -aggr_slice_amsdu(struct aggr_info *p_aggr, struct rxtid *rxtid, void **osbuf); - -static void -aggr_timeout(unsigned long arg); - -static void -aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, u16 seq_no, u8 order); - -static void -aggr_dispatch_frames(struct aggr_info *p_aggr, A_NETBUF_QUEUE_T *q); - -static void * -aggr_get_osbuf(struct aggr_info *p_aggr); - -void * -aggr_init(ALLOC_NETBUFS netbuf_allocator) -{ - struct aggr_info *p_aggr = NULL; - struct rxtid *rxtid; - u8 i; - int status = 0; - - A_PRINTF("In aggr_init..\n"); - - do { - p_aggr = A_MALLOC(sizeof(struct aggr_info)); - if(!p_aggr) { - A_PRINTF("Failed to allocate memory for aggr_node\n"); - status = A_ERROR; - break; - } - - /* Init timer and data structures */ - A_MEMZERO(p_aggr, sizeof(struct aggr_info)); - p_aggr->aggr_sz = AGGR_SZ_DEFAULT; - A_INIT_TIMER(&p_aggr->timer, aggr_timeout, p_aggr); - p_aggr->timerScheduled = false; - A_NETBUF_QUEUE_INIT(&p_aggr->freeQ); - - p_aggr->netbuf_allocator = netbuf_allocator; - p_aggr->netbuf_allocator(&p_aggr->freeQ, AGGR_NUM_OF_FREE_NETBUFS); - - for(i = 0; i < NUM_OF_TIDS; i++) { - rxtid = AGGR_GET_RXTID(p_aggr, i); - rxtid->aggr = false; - rxtid->progress = false; - rxtid->timerMon = false; - A_NETBUF_QUEUE_INIT(&rxtid->q); - A_MUTEX_INIT(&rxtid->lock); - } - }while(false); - - A_PRINTF("going out of aggr_init..status %s\n", - (status == 0) ? "OK":"Error"); - - if (status) { - /* Cleanup */ - aggr_module_destroy(p_aggr); - } - return ((status == 0) ? p_aggr : NULL); -} - -/* utility function to clear rx hold_q for a tid */ -static void -aggr_delete_tid_state(struct aggr_info *p_aggr, u8 tid) -{ - struct rxtid *rxtid; - struct rxtid_stats *stats; - - A_ASSERT(tid < NUM_OF_TIDS && p_aggr); - - rxtid = AGGR_GET_RXTID(p_aggr, tid); - stats = AGGR_GET_RXTID_STATS(p_aggr, tid); - - if(rxtid->aggr) { - aggr_deque_frms(p_aggr, tid, 0, ALL_SEQNO); - } - - rxtid->aggr = false; - rxtid->progress = false; - rxtid->timerMon = false; - rxtid->win_sz = 0; - rxtid->seq_next = 0; - rxtid->hold_q_sz = 0; - - if(rxtid->hold_q) { - kfree(rxtid->hold_q); - rxtid->hold_q = NULL; - } - - A_MEMZERO(stats, sizeof(struct rxtid_stats)); -} - -void -aggr_module_destroy(void *cntxt) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid *rxtid; - u8 i, k; - A_PRINTF("%s(): aggr = %p\n",_A_FUNCNAME_, p_aggr); - A_ASSERT(p_aggr); - - if(p_aggr) { - if(p_aggr->timerScheduled) { - A_UNTIMEOUT(&p_aggr->timer); - p_aggr->timerScheduled = false; - } - - for(i = 0; i < NUM_OF_TIDS; i++) { - rxtid = AGGR_GET_RXTID(p_aggr, i); - /* Free the hold q contents and hold_q*/ - if(rxtid->hold_q) { - for(k = 0; k< rxtid->hold_q_sz; k++) { - if(rxtid->hold_q[k].osbuf) { - A_NETBUF_FREE(rxtid->hold_q[k].osbuf); - } - } - kfree(rxtid->hold_q); - } - /* Free the dispatch q contents*/ - while(A_NETBUF_QUEUE_SIZE(&rxtid->q)) { - A_NETBUF_FREE(A_NETBUF_DEQUEUE(&rxtid->q)); - } - if (A_IS_MUTEX_VALID(&rxtid->lock)) { - A_MUTEX_DELETE(&rxtid->lock); - } - } - /* free the freeQ and its contents*/ - while(A_NETBUF_QUEUE_SIZE(&p_aggr->freeQ)) { - A_NETBUF_FREE(A_NETBUF_DEQUEUE(&p_aggr->freeQ)); - } - kfree(p_aggr); - } - A_PRINTF("out aggr_module_destroy\n"); -} - - -void -aggr_register_rx_dispatcher(void *cntxt, void * dev, RX_CALLBACK fn) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - - A_ASSERT(p_aggr && fn && dev); - - p_aggr->rx_fn = fn; - p_aggr->dev = dev; -} - - -void -aggr_process_bar(void *cntxt, u8 tid, u16 seq_no) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid_stats *stats; - - A_ASSERT(p_aggr); - stats = AGGR_GET_RXTID_STATS(p_aggr, tid); - stats->num_bar++; - - aggr_deque_frms(p_aggr, tid, seq_no, ALL_SEQNO); -} - - -void -aggr_recv_addba_req_evt(void *cntxt, u8 tid, u16 seq_no, u8 win_sz) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid *rxtid; - struct rxtid_stats *stats; - - A_ASSERT(p_aggr); - rxtid = AGGR_GET_RXTID(p_aggr, tid); - stats = AGGR_GET_RXTID_STATS(p_aggr, tid); - - A_PRINTF("%s(): win_sz = %d aggr %d\n", _A_FUNCNAME_, win_sz, rxtid->aggr); - if(win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) { - A_PRINTF("win_sz %d, tid %d\n", win_sz, tid); - } - - if(rxtid->aggr) { - /* Just go and deliver all the frames up from this - * queue, as if we got DELBA and re-initialize the queue - */ - aggr_delete_tid_state(p_aggr, tid); - } - - rxtid->seq_next = seq_no; - /* create these queues, only upon receiving of ADDBA for a - * tid, reducing memory requirement - */ - rxtid->hold_q = A_MALLOC(HOLD_Q_SZ(win_sz)); - if((rxtid->hold_q == NULL)) { - A_PRINTF("Failed to allocate memory, tid = %d\n", tid); - A_ASSERT(0); - } - A_MEMZERO(rxtid->hold_q, HOLD_Q_SZ(win_sz)); - - /* Update rxtid for the window sz */ - rxtid->win_sz = win_sz; - /* hold_q_sz inicates the depth of holding q - which is - * a factor of win_sz. Compute once, as it will be used often - */ - rxtid->hold_q_sz = TID_WINDOW_SZ(win_sz); - /* There should be no frames on q - even when second ADDBA comes in. - * If aggr was previously ON on this tid, we would have cleaned up - * the q - */ - if(A_NETBUF_QUEUE_SIZE(&rxtid->q) != 0) { - A_PRINTF("ERROR: Frames still on queue ?\n"); - A_ASSERT(0); - } - - rxtid->aggr = true; -} - -void -aggr_recv_delba_req_evt(void *cntxt, u8 tid) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid *rxtid; - - A_ASSERT(p_aggr); - A_PRINTF("%s(): tid %d\n", _A_FUNCNAME_, tid); - - rxtid = AGGR_GET_RXTID(p_aggr, tid); - - if(rxtid->aggr) { - aggr_delete_tid_state(p_aggr, tid); - } -} - -static void -aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, u16 seq_no, u8 order) -{ - struct rxtid *rxtid; - struct osbuf_hold_q *node; - u16 idx, idx_end, seq_end; - struct rxtid_stats *stats; - - A_ASSERT(p_aggr); - rxtid = AGGR_GET_RXTID(p_aggr, tid); - stats = AGGR_GET_RXTID_STATS(p_aggr, tid); - - /* idx is absolute location for first frame */ - idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz); - - /* idx_end is typically the last possible frame in the window, - * but changes to 'the' seq_no, when BAR comes. If seq_no - * is non-zero, we will go up to that and stop. - * Note: last seq no in current window will occupy the same - * index position as index that is just previous to start. - * An imp point : if win_sz is 7, for seq_no space of 4095, - * then, there would be holes when sequence wrap around occurs. - * Target should judiciously choose the win_sz, based on - * this condition. For 4095, (TID_WINDOW_SZ = 2 x win_sz - * 2, 4, 8, 16 win_sz works fine). - * We must deque from "idx" to "idx_end", including both. - */ - seq_end = (seq_no) ? seq_no : rxtid->seq_next; - idx_end = AGGR_WIN_IDX(seq_end, rxtid->hold_q_sz); - - /* Critical section begins */ - A_MUTEX_LOCK(&rxtid->lock); - do { - - node = &rxtid->hold_q[idx]; - - if((order == CONTIGUOUS_SEQNO) && (!node->osbuf)) - break; - - /* chain frames and deliver frames bcos: - * 1. either the frames are in order and window is contiguous, OR - * 2. we need to deque frames, irrespective of holes - */ - if(node->osbuf) { - if(node->is_amsdu) { - aggr_slice_amsdu(p_aggr, rxtid, &node->osbuf); - } else { - A_NETBUF_ENQUEUE(&rxtid->q, node->osbuf); - } - node->osbuf = NULL; - } else { - stats->num_hole++; - } - - /* window is moving */ - rxtid->seq_next = IEEE80211_NEXT_SEQ_NO(rxtid->seq_next); - idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz); - } while(idx != idx_end); - /* Critical section ends */ - A_MUTEX_UNLOCK(&rxtid->lock); - - stats->num_delivered += A_NETBUF_QUEUE_SIZE(&rxtid->q); - aggr_dispatch_frames(p_aggr, &rxtid->q); -} - -static void * -aggr_get_osbuf(struct aggr_info *p_aggr) -{ - void *buf = NULL; - - /* Starving for buffers? get more from OS - * check for low netbuffers( < 1/4 AGGR_NUM_OF_FREE_NETBUFS) : - * re-allocate bufs if so - * allocate a free buf from freeQ - */ - if (A_NETBUF_QUEUE_SIZE(&p_aggr->freeQ) < (AGGR_NUM_OF_FREE_NETBUFS >> 2)) { - p_aggr->netbuf_allocator(&p_aggr->freeQ, AGGR_NUM_OF_FREE_NETBUFS); - } - - if (A_NETBUF_QUEUE_SIZE(&p_aggr->freeQ)) { - buf = A_NETBUF_DEQUEUE(&p_aggr->freeQ); - } - - return buf; -} - - -static void -aggr_slice_amsdu(struct aggr_info *p_aggr, struct rxtid *rxtid, void **osbuf) -{ - void *new_buf; - u16 frame_8023_len, payload_8023_len, mac_hdr_len, amsdu_len; - u8 *framep; - - /* Frame format at this point: - * [DIX hdr | 802.3 | 802.3 | ... | 802.3] - * - * Strip the DIX header. - * Iterate through the osbuf and do: - * grab a free netbuf from freeQ - * find the start and end of a frame - * copy it to netbuf(Vista can do better here) - * convert all msdu's(802.3) frames to upper layer format - os routine - * -for now lets convert from 802.3 to dix - * enque this to dispatch q of tid - * repeat - * free the osbuf - to OS. It's been sliced. - */ - - mac_hdr_len = sizeof(ATH_MAC_HDR); - framep = A_NETBUF_DATA(*osbuf) + mac_hdr_len; - amsdu_len = A_NETBUF_LEN(*osbuf) - mac_hdr_len; - - while(amsdu_len > mac_hdr_len) { - /* Begin of a 802.3 frame */ - payload_8023_len = A_BE2CPU16(((ATH_MAC_HDR *)framep)->typeOrLen); -#define MAX_MSDU_SUBFRAME_PAYLOAD_LEN 1508 -#define MIN_MSDU_SUBFRAME_PAYLOAD_LEN 46 - if(payload_8023_len < MIN_MSDU_SUBFRAME_PAYLOAD_LEN || payload_8023_len > MAX_MSDU_SUBFRAME_PAYLOAD_LEN) { - A_PRINTF("802.3 AMSDU frame bound check failed. len %d\n", payload_8023_len); - break; - } - frame_8023_len = payload_8023_len + mac_hdr_len; - new_buf = aggr_get_osbuf(p_aggr); - if(new_buf == NULL) { - A_PRINTF("No buffer available \n"); - break; - } - - memcpy(A_NETBUF_DATA(new_buf), framep, frame_8023_len); - A_NETBUF_PUT(new_buf, frame_8023_len); - if (wmi_dot3_2_dix(new_buf) != 0) { - A_PRINTF("dot3_2_dix err..\n"); - A_NETBUF_FREE(new_buf); - break; - } - - A_NETBUF_ENQUEUE(&rxtid->q, new_buf); - - /* Is this the last subframe within this aggregate ? */ - if ((amsdu_len - frame_8023_len) == 0) { - break; - } - - /* Add the length of A-MSDU subframe padding bytes - - * Round to nearest word. - */ - frame_8023_len = ((frame_8023_len + 3) & ~3); - - framep += frame_8023_len; - amsdu_len -= frame_8023_len; - } - - A_NETBUF_FREE(*osbuf); - *osbuf = NULL; -} - -void -aggr_process_recv_frm(void *cntxt, u8 tid, u16 seq_no, bool is_amsdu, void **osbuf) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid *rxtid; - struct rxtid_stats *stats; - u16 idx, st, cur, end; - u16 *log_idx; - struct osbuf_hold_q *node; - PACKET_LOG *log; - - A_ASSERT(p_aggr); - A_ASSERT(tid < NUM_OF_TIDS); - - rxtid = AGGR_GET_RXTID(p_aggr, tid); - stats = AGGR_GET_RXTID_STATS(p_aggr, tid); - - stats->num_into_aggr++; - - if(!rxtid->aggr) { - if(is_amsdu) { - aggr_slice_amsdu(p_aggr, rxtid, osbuf); - stats->num_amsdu++; - aggr_dispatch_frames(p_aggr, &rxtid->q); - } - return; - } - - /* Check the incoming sequence no, if it's in the window */ - st = rxtid->seq_next; - cur = seq_no; - end = (st + rxtid->hold_q_sz-1) & IEEE80211_MAX_SEQ_NO; - /* Log the pkt info for future analysis */ - log = &p_aggr->pkt_log; - log_idx = &log->last_idx; - log->info[*log_idx].cur = cur; - log->info[*log_idx].st = st; - log->info[*log_idx].end = end; - *log_idx = IEEE80211_NEXT_SEQ_NO(*log_idx); - - if(((st < end) && (cur < st || cur > end)) || - ((st > end) && (cur > end) && (cur < st))) { - /* the cur frame is outside the window. Since we know - * our target would not do this without reason it must - * be assumed that the window has moved for some valid reason. - * Therefore, we dequeue all frames and start fresh. - */ - u16 extended_end; - - extended_end = (end + rxtid->hold_q_sz-1) & IEEE80211_MAX_SEQ_NO; - - if(((end < extended_end) && (cur < end || cur > extended_end)) || - ((end > extended_end) && (cur > extended_end) && (cur < end))) { - // dequeue all frames in queue and shift window to new frame - aggr_deque_frms(p_aggr, tid, 0, ALL_SEQNO); - //set window start so that new frame is last frame in window - if(cur >= rxtid->hold_q_sz-1) { - rxtid->seq_next = cur - (rxtid->hold_q_sz-1); - }else{ - rxtid->seq_next = IEEE80211_MAX_SEQ_NO - (rxtid->hold_q_sz-2 - cur); - } - } else { - // dequeue only those frames that are outside the new shifted window - if(cur >= rxtid->hold_q_sz-1) { - st = cur - (rxtid->hold_q_sz-1); - }else{ - st = IEEE80211_MAX_SEQ_NO - (rxtid->hold_q_sz-2 - cur); - } - - aggr_deque_frms(p_aggr, tid, st, ALL_SEQNO); - } - - stats->num_oow++; - } - - idx = AGGR_WIN_IDX(seq_no, rxtid->hold_q_sz); - - /*enque the frame, in hold_q */ - node = &rxtid->hold_q[idx]; - - A_MUTEX_LOCK(&rxtid->lock); - if(node->osbuf) { - /* Is the cur frame duplicate or something beyond our - * window(hold_q -> which is 2x, already)? - * 1. Duplicate is easy - drop incoming frame. - * 2. Not falling in current sliding window. - * 2a. is the frame_seq_no preceding current tid_seq_no? - * -> drop the frame. perhaps sender did not get our ACK. - * this is taken care of above. - * 2b. is the frame_seq_no beyond window(st, TID_WINDOW_SZ); - * -> Taken care of it above, by moving window forward. - * - */ - A_NETBUF_FREE(node->osbuf); - stats->num_dups++; - } - - node->osbuf = *osbuf; - node->is_amsdu = is_amsdu; - node->seq_no = seq_no; - if(node->is_amsdu) { - stats->num_amsdu++; - } else { - stats->num_mpdu++; - } - A_MUTEX_UNLOCK(&rxtid->lock); - - *osbuf = NULL; - aggr_deque_frms(p_aggr, tid, 0, CONTIGUOUS_SEQNO); - - if(p_aggr->timerScheduled) { - rxtid->progress = true; - }else{ - for(idx=0 ; idxhold_q_sz ; idx++) { - if(rxtid->hold_q[idx].osbuf) { - /* there is a frame in the queue and no timer so - * start a timer to ensure that the frame doesn't remain - * stuck forever. */ - p_aggr->timerScheduled = true; - A_TIMEOUT_MS(&p_aggr->timer, AGGR_RX_TIMEOUT, 0); - rxtid->progress = false; - rxtid->timerMon = true; - break; - } - } - } -} - -/* - * aggr_reset_state -- Called when it is deemed necessary to clear the aggregate - * hold Q state. Examples include when a Connect event or disconnect event is - * received. - */ -void -aggr_reset_state(void *cntxt) -{ - u8 tid; - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - - A_ASSERT(p_aggr); - - for(tid=0 ; tidaggr == false || - rxtid->timerMon == false || - rxtid->progress == true) { - continue; - } - // dequeue all frames in for this tid - stats->num_timeouts++; - A_PRINTF("TO: st %d end %d\n", rxtid->seq_next, ((rxtid->seq_next + rxtid->hold_q_sz-1) & IEEE80211_MAX_SEQ_NO)); - aggr_deque_frms(p_aggr, i, 0, ALL_SEQNO); - } - - p_aggr->timerScheduled = false; - // determine whether a new timer should be started. - for(i = 0; i < NUM_OF_TIDS; i++) { - rxtid = AGGR_GET_RXTID(p_aggr, i); - - if(rxtid->aggr == true && rxtid->hold_q) { - for(j = 0 ; j < rxtid->hold_q_sz ; j++) - { - if(rxtid->hold_q[j].osbuf) - { - p_aggr->timerScheduled = true; - rxtid->timerMon = true; - rxtid->progress = false; - break; - } - } - - if(j >= rxtid->hold_q_sz) { - rxtid->timerMon = false; - } - } - } - - if(p_aggr->timerScheduled) { - /* Rearm the timer*/ - A_TIMEOUT_MS(&p_aggr->timer, AGGR_RX_TIMEOUT, 0); - } - -} - -static void -aggr_dispatch_frames(struct aggr_info *p_aggr, A_NETBUF_QUEUE_T *q) -{ - void *osbuf; - - while((osbuf = A_NETBUF_DEQUEUE(q))) { - p_aggr->rx_fn(p_aggr->dev, osbuf); - } -} - -void -aggr_dump_stats(void *cntxt, PACKET_LOG **log_buf) -{ - struct aggr_info *p_aggr = (struct aggr_info *)cntxt; - struct rxtid *rxtid; - struct rxtid_stats *stats; - u8 i; - - *log_buf = &p_aggr->pkt_log; - A_PRINTF("\n\n================================================\n"); - A_PRINTF("tid: num_into_aggr, dups, oow, mpdu, amsdu, delivered, timeouts, holes, bar, seq_next\n"); - for(i = 0; i < NUM_OF_TIDS; i++) { - stats = AGGR_GET_RXTID_STATS(p_aggr, i); - rxtid = AGGR_GET_RXTID(p_aggr, i); - A_PRINTF("%d: %d %d %d %d %d %d %d %d %d : %d\n", i, stats->num_into_aggr, stats->num_dups, - stats->num_oow, stats->num_mpdu, - stats->num_amsdu, stats->num_delivered, stats->num_timeouts, - stats->num_hole, stats->num_bar, - rxtid->seq_next); - } - A_PRINTF("================================================\n\n"); - -} diff --git a/drivers/staging/ath6kl/wlan/include/ieee80211.h b/drivers/staging/ath6kl/wlan/include/ieee80211.h deleted file mode 100644 index cf47d0657e7..00000000000 --- a/drivers/staging/ath6kl/wlan/include/ieee80211.h +++ /dev/null @@ -1,397 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _NET80211_IEEE80211_H_ -#define _NET80211_IEEE80211_H_ - -/* - * 802.11 protocol definitions. - */ -#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ -#define IEEE80211_WEP_IVLEN 3 /* 24bit */ -#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ -#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ -#define IEEE80211_WEP_NKID 4 /* number of key ids */ - -/* - * 802.11i defines an extended IV for use with non-WEP ciphers. - * When the EXTIV bit is set in the key id byte an additional - * 4 bytes immediately follow the IV for TKIP. For CCMP the - * EXTIV bit is likewise set but the 8 bytes represent the - * CCMP header rather than IV+extended-IV. - */ -#define IEEE80211_WEP_EXTIV 0x20 -#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ -#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ - -#define IEEE80211_CRC_LEN 4 - -#ifdef WAPI_ENABLE -#define IEEE80211_WAPI_EXTIVLEN 10 /* extended IV length */ -#endif /* WAPI ENABLE */ - - -#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ -/* is 802.11 address multicast/broadcast? */ -#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) -#define IEEE80211_IS_BROADCAST(_a) (*(_a) == 0xFF) -#define WEP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN) -#define WEP_TRAILER IEEE80211_WEP_CRCLEN -#define CCMP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \ - IEEE80211_WEP_EXTIVLEN) -#define CCMP_TRAILER IEEE80211_WEP_MICLEN -#define TKIP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \ - IEEE80211_WEP_EXTIVLEN) -#define TKIP_TRAILER IEEE80211_WEP_CRCLEN -#define TKIP_MICLEN IEEE80211_WEP_MICLEN - - -#define IEEE80211_ADDR_EQ(addr1, addr2) \ - (memcmp(addr1, addr2, IEEE80211_ADDR_LEN) == 0) - -#define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) - -#define IEEE80211_KEYBUF_SIZE 16 -#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx and rx */ - -/* - * NB: these values are ordered carefully; there are lots of - * of implications in any reordering. In particular beware - * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY. - */ -#define IEEE80211_CIPHER_WEP 0 -#define IEEE80211_CIPHER_TKIP 1 -#define IEEE80211_CIPHER_AES_OCB 2 -#define IEEE80211_CIPHER_AES_CCM 3 -#define IEEE80211_CIPHER_CKIP 5 -#define IEEE80211_CIPHER_CCKM_KRK 6 -#define IEEE80211_CIPHER_NONE 7 /* pseudo value */ - -#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1) - -#define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \ - (((len) == 5) || ((len) == 13) || ((len) == 16)) - - - -/* - * generic definitions for IEEE 802.11 frames - */ -PREPACK struct ieee80211_frame { - u8 i_fc[2]; - u8 i_dur[2]; - u8 i_addr1[IEEE80211_ADDR_LEN]; - u8 i_addr2[IEEE80211_ADDR_LEN]; - u8 i_addr3[IEEE80211_ADDR_LEN]; - u8 i_seq[2]; - /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ - /* see below */ -} POSTPACK; - -PREPACK struct ieee80211_qosframe { - u8 i_fc[2]; - u8 i_dur[2]; - u8 i_addr1[IEEE80211_ADDR_LEN]; - u8 i_addr2[IEEE80211_ADDR_LEN]; - u8 i_addr3[IEEE80211_ADDR_LEN]; - u8 i_seq[2]; - u8 i_qos[2]; -} POSTPACK; - -#define IEEE80211_FC0_VERSION_MASK 0x03 -#define IEEE80211_FC0_VERSION_SHIFT 0 -#define IEEE80211_FC0_VERSION_0 0x00 -#define IEEE80211_FC0_TYPE_MASK 0x0c -#define IEEE80211_FC0_TYPE_SHIFT 2 -#define IEEE80211_FC0_TYPE_MGT 0x00 -#define IEEE80211_FC0_TYPE_CTL 0x04 -#define IEEE80211_FC0_TYPE_DATA 0x08 - -#define IEEE80211_FC0_SUBTYPE_MASK 0xf0 -#define IEEE80211_FC0_SUBTYPE_SHIFT 4 -/* for TYPE_MGT */ -#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 -#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 -#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 -#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 -#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 -#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 -#define IEEE80211_FC0_SUBTYPE_BEACON 0x80 -#define IEEE80211_FC0_SUBTYPE_ATIM 0x90 -#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 -#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 -#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 -/* for TYPE_CTL */ -#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 -#define IEEE80211_FC0_SUBTYPE_RTS 0xb0 -#define IEEE80211_FC0_SUBTYPE_CTS 0xc0 -#define IEEE80211_FC0_SUBTYPE_ACK 0xd0 -#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 -#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 -/* for TYPE_DATA (bit combination) */ -#define IEEE80211_FC0_SUBTYPE_DATA 0x00 -#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 -#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 -#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 -#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 -#define IEEE80211_FC0_SUBTYPE_CFACK 0x50 -#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 -#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 -#define IEEE80211_FC0_SUBTYPE_QOS 0x80 -#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 - -#define IEEE80211_FC1_DIR_MASK 0x03 -#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ -#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ -#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ -#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ - -#define IEEE80211_FC1_MORE_FRAG 0x04 -#define IEEE80211_FC1_RETRY 0x08 -#define IEEE80211_FC1_PWR_MGT 0x10 -#define IEEE80211_FC1_MORE_DATA 0x20 -#define IEEE80211_FC1_WEP 0x40 -#define IEEE80211_FC1_ORDER 0x80 - -#define IEEE80211_SEQ_FRAG_MASK 0x000f -#define IEEE80211_SEQ_FRAG_SHIFT 0 -#define IEEE80211_SEQ_SEQ_MASK 0xfff0 -#define IEEE80211_SEQ_SEQ_SHIFT 4 - -#define IEEE80211_NWID_LEN 32 - -/* - * 802.11 rate set. - */ -#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ -#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ - -#define WMM_NUM_AC 4 /* 4 AC categories */ - -#define WMM_PARAM_ACI_M 0x60 /* Mask for ACI field */ -#define WMM_PARAM_ACI_S 5 /* Shift for ACI field */ -#define WMM_PARAM_ACM_M 0x10 /* Mask for ACM bit */ -#define WMM_PARAM_ACM_S 4 /* Shift for ACM bit */ -#define WMM_PARAM_AIFSN_M 0x0f /* Mask for aifsn field */ -#define WMM_PARAM_LOGCWMIN_M 0x0f /* Mask for CwMin field (in log) */ -#define WMM_PARAM_LOGCWMAX_M 0xf0 /* Mask for CwMax field (in log) */ -#define WMM_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ - -#define WMM_AC_TO_TID(_ac) ( \ - ((_ac) == WMM_AC_VO) ? 6 : \ - ((_ac) == WMM_AC_VI) ? 5 : \ - ((_ac) == WMM_AC_BK) ? 1 : \ - 0) - -#define TID_TO_WMM_AC(_tid) ( \ - ((_tid) < 1) ? WMM_AC_BE : \ - ((_tid) < 3) ? WMM_AC_BK : \ - ((_tid) < 6) ? WMM_AC_VI : \ - WMM_AC_VO) -/* - * Management information element payloads. - */ - -enum { - IEEE80211_ELEMID_SSID = 0, - IEEE80211_ELEMID_RATES = 1, - IEEE80211_ELEMID_FHPARMS = 2, - IEEE80211_ELEMID_DSPARMS = 3, - IEEE80211_ELEMID_CFPARMS = 4, - IEEE80211_ELEMID_TIM = 5, - IEEE80211_ELEMID_IBSSPARMS = 6, - IEEE80211_ELEMID_COUNTRY = 7, - IEEE80211_ELEMID_CHALLENGE = 16, - /* 17-31 reserved for challenge text extension */ - IEEE80211_ELEMID_PWRCNSTR = 32, - IEEE80211_ELEMID_PWRCAP = 33, - IEEE80211_ELEMID_TPCREQ = 34, - IEEE80211_ELEMID_TPCREP = 35, - IEEE80211_ELEMID_SUPPCHAN = 36, - IEEE80211_ELEMID_CHANSWITCH = 37, - IEEE80211_ELEMID_MEASREQ = 38, - IEEE80211_ELEMID_MEASREP = 39, - IEEE80211_ELEMID_QUIET = 40, - IEEE80211_ELEMID_IBSSDFS = 41, - IEEE80211_ELEMID_ERP = 42, - IEEE80211_ELEMID_HTCAP_ANA = 45, /* Address ANA, and non-ANA story, for interop. CL#171733 */ - IEEE80211_ELEMID_RSN = 48, - IEEE80211_ELEMID_XRATES = 50, - IEEE80211_ELEMID_HTINFO_ANA = 61, -#ifdef WAPI_ENABLE - IEEE80211_ELEMID_WAPI = 68, -#endif - IEEE80211_ELEMID_TPC = 150, - IEEE80211_ELEMID_CCKM = 156, - IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ -}; - -#define ATH_OUI 0x7f0300 /* Atheros OUI */ -#define ATH_OUI_TYPE 0x01 -#define ATH_OUI_SUBTYPE 0x01 -#define ATH_OUI_VERSION 0x00 - -#define WPA_OUI 0xf25000 -#define WPA_OUI_TYPE 0x01 -#define WPA_VERSION 1 /* current supported version */ - -#define WPA_CSE_NULL 0x00 -#define WPA_CSE_WEP40 0x01 -#define WPA_CSE_TKIP 0x02 -#define WPA_CSE_CCMP 0x04 -#define WPA_CSE_WEP104 0x05 - -#define WPA_ASE_NONE 0x00 -#define WPA_ASE_8021X_UNSPEC 0x01 -#define WPA_ASE_8021X_PSK 0x02 - -#define RSN_OUI 0xac0f00 -#define RSN_VERSION 1 /* current supported version */ - -#define RSN_CSE_NULL 0x00 -#define RSN_CSE_WEP40 0x01 -#define RSN_CSE_TKIP 0x02 -#define RSN_CSE_WRAP 0x03 -#define RSN_CSE_CCMP 0x04 -#define RSN_CSE_WEP104 0x05 - -#define RSN_ASE_NONE 0x00 -#define RSN_ASE_8021X_UNSPEC 0x01 -#define RSN_ASE_8021X_PSK 0x02 - -#define RSN_CAP_PREAUTH 0x01 - -#define WMM_OUI 0xf25000 -#define WMM_OUI_TYPE 0x02 -#define WMM_INFO_OUI_SUBTYPE 0x00 -#define WMM_PARAM_OUI_SUBTYPE 0x01 -#define WMM_VERSION 1 - -/* WMM stream classes */ -#define WMM_NUM_AC 4 -#define WMM_AC_BE 0 /* best effort */ -#define WMM_AC_BK 1 /* background */ -#define WMM_AC_VI 2 /* video */ -#define WMM_AC_VO 3 /* voice */ - -/* TSPEC related */ -#define ACTION_CATEGORY_CODE_TSPEC 17 -#define ACTION_CODE_TSPEC_ADDTS 0 -#define ACTION_CODE_TSPEC_ADDTS_RESP 1 -#define ACTION_CODE_TSPEC_DELTS 2 - -typedef enum { - TSPEC_STATUS_CODE_ADMISSION_ACCEPTED = 0, - TSPEC_STATUS_CODE_ADDTS_INVALID_PARAMS = 0x1, - TSPEC_STATUS_CODE_ADDTS_REQUEST_REFUSED = 0x3, - TSPEC_STATUS_CODE_UNSPECIFIED_QOS_RELATED_FAILURE = 0xC8, - TSPEC_STATUS_CODE_REQUESTED_REFUSED_POLICY_CONFIGURATION = 0xC9, - TSPEC_STATUS_CODE_INSUFFCIENT_BANDWIDTH = 0xCA, - TSPEC_STATUS_CODE_INVALID_PARAMS = 0xCB, - TSPEC_STATUS_CODE_DELTS_SENT = 0x30, - TSPEC_STATUS_CODE_DELTS_RECV = 0x31, -} TSPEC_STATUS_CODE; - -#define TSPEC_TSID_MASK 0xF -#define TSPEC_TSID_S 1 - -/* - * WMM/802.11e Tspec Element - */ -typedef PREPACK struct wmm_tspec_ie_t { - u8 elementId; - u8 len; - u8 oui[3]; - u8 ouiType; - u8 ouiSubType; - u8 version; - u16 tsInfo_info; - u8 tsInfo_reserved; - u16 nominalMSDU; - u16 maxMSDU; - u32 minServiceInt; - u32 maxServiceInt; - u32 inactivityInt; - u32 suspensionInt; - u32 serviceStartTime; - u32 minDataRate; - u32 meanDataRate; - u32 peakDataRate; - u32 maxBurstSize; - u32 delayBound; - u32 minPhyRate; - u16 sba; - u16 mediumTime; -} POSTPACK WMM_TSPEC_IE; - - -/* - * BEACON management packets - * - * octet timestamp[8] - * octet beacon interval[2] - * octet capability information[2] - * information element - * octet elemid - * octet length - * octet information[length] - */ - -#define IEEE80211_BEACON_INTERVAL(beacon) \ - ((beacon)[8] | ((beacon)[9] << 8)) -#define IEEE80211_BEACON_CAPABILITY(beacon) \ - ((beacon)[10] | ((beacon)[11] << 8)) - -#define IEEE80211_CAPINFO_ESS 0x0001 -#define IEEE80211_CAPINFO_IBSS 0x0002 -#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 -#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 -#define IEEE80211_CAPINFO_PRIVACY 0x0010 -#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 -#define IEEE80211_CAPINFO_PBCC 0x0040 -#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 -/* bits 8-9 are reserved */ -#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 -#define IEEE80211_CAPINFO_APSD 0x0800 -/* bit 12 is reserved */ -#define IEEE80211_CAPINFO_DSSSOFDM 0x2000 -/* bits 14-15 are reserved */ - -/* - * Authentication Modes - */ - -enum ieee80211_authmode { - IEEE80211_AUTH_NONE = 0, - IEEE80211_AUTH_OPEN = 1, - IEEE80211_AUTH_SHARED = 2, - IEEE80211_AUTH_8021X = 3, - IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ - /* NB: these are used only for ioctls */ - IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x */ - IEEE80211_AUTH_WPA_PSK = 6, /* WPA/RSN w/ PSK */ - IEEE80211_AUTH_WPA_CCKM = 7, /* WPA/RSN IE w/ CCKM */ -}; - -#define IEEE80211_PS_MAX_QUEUE 50 /*Maximum no of buffers that can be queues for PS*/ - -#endif /* _NET80211_IEEE80211_H_ */ diff --git a/drivers/staging/ath6kl/wlan/include/ieee80211_node.h b/drivers/staging/ath6kl/wlan/include/ieee80211_node.h deleted file mode 100644 index 1cb01671c0d..00000000000 --- a/drivers/staging/ath6kl/wlan/include/ieee80211_node.h +++ /dev/null @@ -1,93 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// Author(s): ="Atheros" -//============================================================================== -#ifndef _IEEE80211_NODE_H_ -#define _IEEE80211_NODE_H_ - -/* - * Node locking definitions. - */ -#define IEEE80211_NODE_LOCK_INIT(_nt) A_MUTEX_INIT(&(_nt)->nt_nodelock) -#define IEEE80211_NODE_LOCK_DESTROY(_nt) if (A_IS_MUTEX_VALID(&(_nt)->nt_nodelock)) { \ - A_MUTEX_DELETE(&(_nt)->nt_nodelock); } - -#define IEEE80211_NODE_LOCK(_nt) A_MUTEX_LOCK(&(_nt)->nt_nodelock) -#define IEEE80211_NODE_UNLOCK(_nt) A_MUTEX_UNLOCK(&(_nt)->nt_nodelock) -#define IEEE80211_NODE_LOCK_BH(_nt) A_MUTEX_LOCK(&(_nt)->nt_nodelock) -#define IEEE80211_NODE_UNLOCK_BH(_nt) A_MUTEX_UNLOCK(&(_nt)->nt_nodelock) -#define IEEE80211_NODE_LOCK_ASSERT(_nt) - -/* - * Node reference counting definitions. - * - * ieee80211_node_initref initialize the reference count to 1 - * ieee80211_node_incref add a reference - * ieee80211_node_decref remove a reference - * ieee80211_node_dectestref remove a reference and return 1 if this - * is the last reference, otherwise 0 - * ieee80211_node_refcnt reference count for printing (only) - */ -#define ieee80211_node_initref(_ni) ((_ni)->ni_refcnt = 1) -#define ieee80211_node_incref(_ni) ((_ni)->ni_refcnt++) -#define ieee80211_node_decref(_ni) ((_ni)->ni_refcnt--) -#define ieee80211_node_dectestref(_ni) (((_ni)->ni_refcnt--) == 1) -#define ieee80211_node_refcnt(_ni) ((_ni)->ni_refcnt) - -#define IEEE80211_NODE_HASHSIZE 32 -/* simple hash is enough for variation of macaddr */ -#define IEEE80211_NODE_HASH(addr) \ - (((const u8 *)(addr))[IEEE80211_ADDR_LEN - 1] % \ - IEEE80211_NODE_HASHSIZE) - -/* - * Table of ieee80211_node instances. Each ieee80211com - * has at least one for holding the scan candidates. - * When operating as an access point or in ibss mode there - * is a second table for associated stations or neighbors. - */ -struct ieee80211_node_table { - void *nt_wmip; /* back reference */ - A_MUTEX_T nt_nodelock; /* on node table */ - struct bss *nt_node_first; /* information of all nodes */ - struct bss *nt_node_last; /* information of all nodes */ - struct bss *nt_hash[IEEE80211_NODE_HASHSIZE]; - const char *nt_name; /* for debugging */ - u32 nt_scangen; /* gen# for timeout scan */ -#ifdef THREAD_X - A_TIMER nt_inact_timer; - u8 isTimerArmed; /* is the node timer armed */ -#endif - u32 nt_nodeAge; /* node aging time */ -#ifdef OS_ROAM_MANAGEMENT - u32 nt_si_gen; /* gen# for scan indication*/ -#endif -}; - -#ifdef THREAD_X -#define WLAN_NODE_INACT_TIMEOUT_MSEC 20000 -#else -#define WLAN_NODE_INACT_TIMEOUT_MSEC 120000 -#endif - -#define WLAN_NODE_INACT_CNT 4 - -#endif /* _IEEE80211_NODE_H_ */ diff --git a/drivers/staging/ath6kl/wlan/src/wlan_node.c b/drivers/staging/ath6kl/wlan/src/wlan_node.c deleted file mode 100644 index 0fe5f4b1346..00000000000 --- a/drivers/staging/ath6kl/wlan/src/wlan_node.c +++ /dev/null @@ -1,636 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// IEEE 802.11 node handling support. -// -// Author(s): ="Atheros" -//============================================================================== -#include -#include -#include -#define ATH_MODULE_NAME wlan -#include -#include "htc.h" -#include "htc_api.h" -#include -#include -#include -#include -#include - -#define ATH_DEBUG_WLAN ATH_DEBUG_MAKE_MODULE_MASK(0) - -#ifdef ATH_DEBUG_MODULE - -static struct ath_debug_mask_description wlan_debug_desc[] = { - { ATH_DEBUG_WLAN , "General WLAN Node Tracing"}, -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(wlan, - "wlan", - "WLAN Node Management", - ATH_DEBUG_MASK_DEFAULTS, - ATH_DEBUG_DESCRIPTION_COUNT(wlan_debug_desc), - wlan_debug_desc); - -#endif - -#ifdef THREAD_X -static void wlan_node_timeout(unsigned long arg); -#endif - -static bss_t * _ieee80211_find_node (struct ieee80211_node_table *nt, - const u8 *macaddr); - -bss_t * -wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size) -{ - bss_t *ni; - - ni = A_MALLOC_NOWAIT(sizeof(bss_t)); - - if (ni != NULL) { - if (wh_size) - { - ni->ni_buf = A_MALLOC_NOWAIT(wh_size); - if (ni->ni_buf == NULL) { - kfree(ni); - ni = NULL; - return ni; - } - } - } else { - return ni; - } - - /* Make sure our lists are clean */ - ni->ni_list_next = NULL; - ni->ni_list_prev = NULL; - ni->ni_hash_next = NULL; - ni->ni_hash_prev = NULL; - - // - // ni_scangen never initialized before and during suspend/resume of winmobile, - // that some junk has been stored in this, due to this scan list didn't properly updated - // - ni->ni_scangen = 0; - -#ifdef OS_ROAM_MANAGEMENT - ni->ni_si_gen = 0; -#endif - - return ni; -} - -void -wlan_node_free(bss_t *ni) -{ - if (ni->ni_buf != NULL) { - kfree(ni->ni_buf); - } - kfree(ni); -} - -void -wlan_setup_node(struct ieee80211_node_table *nt, bss_t *ni, - const u8 *macaddr) -{ - int hash; - u32 timeoutValue = 0; - - memcpy(ni->ni_macaddr, macaddr, IEEE80211_ADDR_LEN); - hash = IEEE80211_NODE_HASH (macaddr); - ieee80211_node_initref (ni); /* mark referenced */ - - timeoutValue = nt->nt_nodeAge; - - ni->ni_tstamp = A_GET_MS (0); - ni->ni_actcnt = WLAN_NODE_INACT_CNT; - - IEEE80211_NODE_LOCK_BH(nt); - - /* Insert at the end of the node list */ - ni->ni_list_next = NULL; - ni->ni_list_prev = nt->nt_node_last; - if(nt->nt_node_last != NULL) - { - nt->nt_node_last->ni_list_next = ni; - } - nt->nt_node_last = ni; - if(nt->nt_node_first == NULL) - { - nt->nt_node_first = ni; - } - - /* Insert into the hash list i.e. the bucket */ - if((ni->ni_hash_next = nt->nt_hash[hash]) != NULL) - { - nt->nt_hash[hash]->ni_hash_prev = ni; - } - ni->ni_hash_prev = NULL; - nt->nt_hash[hash] = ni; - -#ifdef THREAD_X - if (!nt->isTimerArmed) { - A_TIMEOUT_MS(&nt->nt_inact_timer, timeoutValue, 0); - nt->isTimerArmed = true; - } -#endif - - IEEE80211_NODE_UNLOCK_BH(nt); -} - -static bss_t * -_ieee80211_find_node(struct ieee80211_node_table *nt, - const u8 *macaddr) -{ - bss_t *ni; - int hash; - - IEEE80211_NODE_LOCK_ASSERT(nt); - - hash = IEEE80211_NODE_HASH(macaddr); - for(ni = nt->nt_hash[hash]; ni; ni = ni->ni_hash_next) { - if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) { - ieee80211_node_incref(ni); /* mark referenced */ - return ni; - } - } - return NULL; -} - -bss_t * -wlan_find_node(struct ieee80211_node_table *nt, const u8 *macaddr) -{ - bss_t *ni; - - IEEE80211_NODE_LOCK(nt); - ni = _ieee80211_find_node(nt, macaddr); - IEEE80211_NODE_UNLOCK(nt); - return ni; -} - -/* - * Reclaim a node. If this is the last reference count then - * do the normal free work. Otherwise remove it from the node - * table and mark it gone by clearing the back-reference. - */ -void -wlan_node_reclaim(struct ieee80211_node_table *nt, bss_t *ni) -{ - IEEE80211_NODE_LOCK(nt); - - if(ni->ni_list_prev == NULL) - { - /* First in list so fix the list head */ - nt->nt_node_first = ni->ni_list_next; - } - else - { - ni->ni_list_prev->ni_list_next = ni->ni_list_next; - } - - if(ni->ni_list_next == NULL) - { - /* Last in list so fix list tail */ - nt->nt_node_last = ni->ni_list_prev; - } - else - { - ni->ni_list_next->ni_list_prev = ni->ni_list_prev; - } - - if(ni->ni_hash_prev == NULL) - { - /* First in list so fix the list head */ - int hash; - hash = IEEE80211_NODE_HASH(ni->ni_macaddr); - nt->nt_hash[hash] = ni->ni_hash_next; - } - else - { - ni->ni_hash_prev->ni_hash_next = ni->ni_hash_next; - } - - if(ni->ni_hash_next != NULL) - { - ni->ni_hash_next->ni_hash_prev = ni->ni_hash_prev; - } - wlan_node_free(ni); - - IEEE80211_NODE_UNLOCK(nt); -} - -static void -wlan_node_dec_free(bss_t *ni) -{ - if (ieee80211_node_dectestref(ni)) { - wlan_node_free(ni); - } -} - -void -wlan_free_allnodes(struct ieee80211_node_table *nt) -{ - bss_t *ni; - - while ((ni = nt->nt_node_first) != NULL) { - wlan_node_reclaim(nt, ni); - } -} - -void -wlan_iterate_nodes(struct ieee80211_node_table *nt, wlan_node_iter_func *f, - void *arg) -{ - bss_t *ni; - u32 gen; - - gen = ++nt->nt_scangen; - - IEEE80211_NODE_LOCK(nt); - for (ni = nt->nt_node_first; ni; ni = ni->ni_list_next) { - if (ni->ni_scangen != gen) { - ni->ni_scangen = gen; - (void) ieee80211_node_incref(ni); - (*f)(arg, ni); - wlan_node_dec_free(ni); - } - } - IEEE80211_NODE_UNLOCK(nt); -} - -/* - * Node table support. - */ -void -wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt) -{ - int i; - - AR_DEBUG_PRINTF(ATH_DEBUG_WLAN, ("node table = 0x%lx\n", (unsigned long)nt)); - IEEE80211_NODE_LOCK_INIT(nt); - - A_REGISTER_MODULE_DEBUG_INFO(wlan); - - nt->nt_node_first = nt->nt_node_last = NULL; - for(i = 0; i < IEEE80211_NODE_HASHSIZE; i++) - { - nt->nt_hash[i] = NULL; - } - -#ifdef THREAD_X - A_INIT_TIMER(&nt->nt_inact_timer, wlan_node_timeout, nt); - nt->isTimerArmed = false; -#endif - nt->nt_wmip = wmip; - nt->nt_nodeAge = WLAN_NODE_INACT_TIMEOUT_MSEC; - - // - // nt_scangen never initialized before and during suspend/resume of winmobile, - // that some junk has been stored in this, due to this scan list didn't properly updated - // - nt->nt_scangen = 0; - -#ifdef OS_ROAM_MANAGEMENT - nt->nt_si_gen = 0; -#endif -} - -void -wlan_set_nodeage(struct ieee80211_node_table *nt, u32 nodeAge) -{ - nt->nt_nodeAge = nodeAge; - return; -} -void -wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt) -{ -#ifdef THREAD_X - bss_t *bss, *nextBss; - u8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = false; - - wmi_get_current_bssid(nt->nt_wmip, myBssid); - - bss = nt->nt_node_first; - while (bss != NULL) - { - nextBss = bss->ni_list_next; - if (memcmp(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) - { - /* - * free up all but the current bss - if set - */ - wlan_node_reclaim(nt, bss); - - } - bss = nextBss; - } -#else - bss_t *bss, *nextBss; - u8 myBssid[IEEE80211_ADDR_LEN]; - u32 timeoutValue = 0; - u32 now = A_GET_MS(0); - timeoutValue = nt->nt_nodeAge; - - wmi_get_current_bssid(nt->nt_wmip, myBssid); - - bss = nt->nt_node_first; - while (bss != NULL) - { - nextBss = bss->ni_list_next; - if (memcmp(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) - { - - if (((now - bss->ni_tstamp) > timeoutValue) || --bss->ni_actcnt == 0) - { - /* - * free up all but the current bss - if set - */ - wlan_node_reclaim(nt, bss); - } - } - bss = nextBss; - } -#endif -} - -#ifdef THREAD_X -static void -wlan_node_timeout (unsigned long arg) -{ - struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg; - bss_t *bss, *nextBss; - u8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = false; - u32 timeoutValue = 0; - u32 now = A_GET_MS(0); - - timeoutValue = nt->nt_nodeAge; - - wmi_get_current_bssid(nt->nt_wmip, myBssid); - - bss = nt->nt_node_first; - while (bss != NULL) - { - nextBss = bss->ni_list_next; - if (memcmp(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) - { - - if ((now - bss->ni_tstamp) > timeoutValue) - { - /* - * free up all but the current bss - if set - */ - wlan_node_reclaim(nt, bss); - } - else - { - /* - * Re-arm timer, only when we have a bss other than - * current bss AND it is not aged-out. - */ - reArmTimer = true; - } - } - bss = nextBss; - } - - if (reArmTimer) - A_TIMEOUT_MS (&nt->nt_inact_timer, timeoutValue, 0); - - nt->isTimerArmed = reArmTimer; -} -#endif - -void -wlan_node_table_cleanup(struct ieee80211_node_table *nt) -{ -#ifdef THREAD_X - A_UNTIMEOUT(&nt->nt_inact_timer); - A_DELETE_TIMER(&nt->nt_inact_timer); -#endif - wlan_free_allnodes(nt); - IEEE80211_NODE_LOCK_DESTROY(nt); -} - -bss_t * -wlan_find_Ssidnode (struct ieee80211_node_table *nt, u8 *pSsid, - u32 ssidLength, bool bIsWPA2, bool bMatchSSID) -{ - bss_t *ni = NULL; - u8 *pIESsid = NULL; - - IEEE80211_NODE_LOCK (nt); - - for (ni = nt->nt_node_first; ni; ni = ni->ni_list_next) { - pIESsid = ni->ni_cie.ie_ssid; - if (pIESsid[1] <= 32) { - - // Step 1 : Check SSID - if (0x00 == memcmp (pSsid, &pIESsid[2], ssidLength)) { - - // - // Step 2.1 : Check MatchSSID is true, if so, return Matched SSID - // Profile, otherwise check whether WPA2 or WPA - // - if (true == bMatchSSID) { - ieee80211_node_incref (ni); /* mark referenced */ - IEEE80211_NODE_UNLOCK (nt); - return ni; - } - - // Step 2 : if SSID matches, check WPA or WPA2 - if (true == bIsWPA2 && NULL != ni->ni_cie.ie_rsn) { - ieee80211_node_incref (ni); /* mark referenced */ - IEEE80211_NODE_UNLOCK (nt); - return ni; - } - if (false == bIsWPA2 && NULL != ni->ni_cie.ie_wpa) { - ieee80211_node_incref(ni); /* mark referenced */ - IEEE80211_NODE_UNLOCK (nt); - return ni; - } - } - } - } - - IEEE80211_NODE_UNLOCK (nt); - - return NULL; -} - -void -wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni) -{ - IEEE80211_NODE_LOCK (nt); - wlan_node_dec_free (ni); - IEEE80211_NODE_UNLOCK (nt); -} - -void -wlan_node_remove_core (struct ieee80211_node_table *nt, bss_t *ni) -{ - if(ni->ni_list_prev == NULL) - { - /* First in list so fix the list head */ - nt->nt_node_first = ni->ni_list_next; - } - else - { - ni->ni_list_prev->ni_list_next = ni->ni_list_next; - } - - if(ni->ni_list_next == NULL) - { - /* Last in list so fix list tail */ - nt->nt_node_last = ni->ni_list_prev; - } - else - { - ni->ni_list_next->ni_list_prev = ni->ni_list_prev; - } - - if(ni->ni_hash_prev == NULL) - { - /* First in list so fix the list head */ - int hash; - hash = IEEE80211_NODE_HASH(ni->ni_macaddr); - nt->nt_hash[hash] = ni->ni_hash_next; - } - else - { - ni->ni_hash_prev->ni_hash_next = ni->ni_hash_next; - } - - if(ni->ni_hash_next != NULL) - { - ni->ni_hash_next->ni_hash_prev = ni->ni_hash_prev; - } -} - -bss_t * -wlan_node_remove(struct ieee80211_node_table *nt, u8 *bssid) -{ - bss_t *bss, *nextBss; - - IEEE80211_NODE_LOCK(nt); - - bss = nt->nt_node_first; - - while (bss != NULL) - { - nextBss = bss->ni_list_next; - - if (memcmp(bssid, bss->ni_macaddr, 6) == 0) - { - wlan_node_remove_core (nt, bss); - IEEE80211_NODE_UNLOCK(nt); - return bss; - } - - bss = nextBss; - } - - IEEE80211_NODE_UNLOCK(nt); - return NULL; -} - -bss_t * -wlan_find_matching_Ssidnode (struct ieee80211_node_table *nt, u8 *pSsid, - u32 ssidLength, u32 dot11AuthMode, u32 authMode, - u32 pairwiseCryptoType, u32 grpwiseCryptoTyp) -{ - bss_t *ni = NULL; - bss_t *best_ni = NULL; - u8 *pIESsid = NULL; - - IEEE80211_NODE_LOCK (nt); - - for (ni = nt->nt_node_first; ni; ni = ni->ni_list_next) { - pIESsid = ni->ni_cie.ie_ssid; - if (pIESsid[1] <= 32) { - - // Step 1 : Check SSID - if (0x00 == memcmp (pSsid, &pIESsid[2], ssidLength)) { - - if (ni->ni_cie.ie_capInfo & 0x10) - { - - if ((NULL != ni->ni_cie.ie_rsn) && (WPA2_PSK_AUTH == authMode)) - { - /* WPA2 */ - if (NULL == best_ni) - { - best_ni = ni; - } - else if (ni->ni_rssi > best_ni->ni_rssi) - { - best_ni = ni; - } - } - else if ((NULL != ni->ni_cie.ie_wpa) && (WPA_PSK_AUTH == authMode)) - { - /* WPA */ - if (NULL == best_ni) - { - best_ni = ni; - } - else if (ni->ni_rssi > best_ni->ni_rssi) - { - best_ni = ni; - } - } - else if (WEP_CRYPT == pairwiseCryptoType) - { - /* WEP */ - if (NULL == best_ni) - { - best_ni = ni; - } - else if (ni->ni_rssi > best_ni->ni_rssi) - { - best_ni = ni; - } - } - } - else - { - /* open AP */ - if ((OPEN_AUTH == authMode) && (NONE_CRYPT == pairwiseCryptoType)) - { - if (NULL == best_ni) - { - best_ni = ni; - } - else if (ni->ni_rssi > best_ni->ni_rssi) - { - best_ni = ni; - } - } - } - } - } - } - - IEEE80211_NODE_UNLOCK (nt); - - return best_ni; -} - diff --git a/drivers/staging/ath6kl/wlan/src/wlan_recv_beacon.c b/drivers/staging/ath6kl/wlan/src/wlan_recv_beacon.c deleted file mode 100644 index 07b8313b16e..00000000000 --- a/drivers/staging/ath6kl/wlan/src/wlan_recv_beacon.c +++ /dev/null @@ -1,199 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// IEEE 802.11 input handling. -// -// Author(s): ="Atheros" -//============================================================================== - -#include "a_config.h" -#include "athdefs.h" -#include "a_osapi.h" -#include -#include -#include - -#define IEEE80211_VERIFY_LENGTH(_len, _minlen) do { \ - if ((_len) < (_minlen)) { \ - return A_EINVAL; \ - } \ -} while (0) - -#define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen) do { \ - if ((__elem) == NULL) { \ - return A_EINVAL; \ - } \ - if ((__elem)[1] > (__maxlen)) { \ - return A_EINVAL; \ - } \ -} while (0) - - -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((u16) \ - ((((u8 *)(p))[0] ) | (((u8 *)(p))[1] << 8))) - -#define LE_READ_4(p) \ - ((u32) \ - ((((u8 *)(p))[0] ) | (((u8 *)(p))[1] << 8) | \ - (((u8 *)(p))[2] << 16) | (((u8 *)(p))[3] << 24))) - - -static int __inline -iswpaoui(const u8 *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); -} - -static int __inline -iswmmoui(const u8 *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((WMM_OUI_TYPE<<24)|WMM_OUI); -} - -/* unused functions for now */ -#if 0 -static int __inline -iswmmparam(const u8 *frm) -{ - return frm[1] > 5 && frm[6] == WMM_PARAM_OUI_SUBTYPE; -} - -static int __inline -iswmminfo(const u8 *frm) -{ - return frm[1] > 5 && frm[6] == WMM_INFO_OUI_SUBTYPE; -} -#endif - -static int __inline -isatherosoui(const u8 *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI); -} - -static int __inline -iswscoui(const u8 *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((0x04<<24)|WPA_OUI); -} - -int -wlan_parse_beacon(u8 *buf, int framelen, struct ieee80211_common_ie *cie) -{ - u8 *frm, *efrm; - u8 elemid_ssid = false; - - frm = buf; - efrm = (u8 *) (frm + framelen); - - /* - * beacon/probe response frame format - * [8] time stamp - * [2] beacon interval - * [2] capability information - * [tlv] ssid - * [tlv] supported rates - * [tlv] country information - * [tlv] parameter set (FH/DS) - * [tlv] erp information - * [tlv] extended supported rates - * [tlv] WMM - * [tlv] WPA or RSN - * [tlv] Atheros Advanced Capabilities - */ - IEEE80211_VERIFY_LENGTH(efrm - frm, 12); - A_MEMZERO(cie, sizeof(*cie)); - - cie->ie_tstamp = frm; frm += 8; - cie->ie_beaconInt = A_LE2CPU16(*(u16 *)frm); frm += 2; - cie->ie_capInfo = A_LE2CPU16(*(u16 *)frm); frm += 2; - cie->ie_chan = 0; - - while (frm < efrm) { - switch (*frm) { - case IEEE80211_ELEMID_SSID: - if (!elemid_ssid) { - cie->ie_ssid = frm; - elemid_ssid = true; - } - break; - case IEEE80211_ELEMID_RATES: - cie->ie_rates = frm; - break; - case IEEE80211_ELEMID_COUNTRY: - cie->ie_country = frm; - break; - case IEEE80211_ELEMID_FHPARMS: - break; - case IEEE80211_ELEMID_DSPARMS: - cie->ie_chan = frm[2]; - break; - case IEEE80211_ELEMID_TIM: - cie->ie_tim = frm; - break; - case IEEE80211_ELEMID_IBSSPARMS: - break; - case IEEE80211_ELEMID_XRATES: - cie->ie_xrates = frm; - break; - case IEEE80211_ELEMID_ERP: - if (frm[1] != 1) { - //A_PRINTF("Discarding ERP Element - Bad Len\n"); - return A_EINVAL; - } - cie->ie_erp = frm[2]; - break; - case IEEE80211_ELEMID_RSN: - cie->ie_rsn = frm; - break; - case IEEE80211_ELEMID_HTCAP_ANA: - cie->ie_htcap = frm; - break; - case IEEE80211_ELEMID_HTINFO_ANA: - cie->ie_htop = frm; - break; -#ifdef WAPI_ENABLE - case IEEE80211_ELEMID_WAPI: - cie->ie_wapi = frm; - break; -#endif - case IEEE80211_ELEMID_VENDOR: - if (iswpaoui(frm)) { - cie->ie_wpa = frm; - } else if (iswmmoui(frm)) { - cie->ie_wmm = frm; - } else if (isatherosoui(frm)) { - cie->ie_ath = frm; - } else if(iswscoui(frm)) { - cie->ie_wsc = frm; - } - break; - default: - break; - } - frm += frm[1] + 2; - } - IEEE80211_VERIFY_ELEMENT(cie->ie_rates, IEEE80211_RATE_MAXSIZE); - IEEE80211_VERIFY_ELEMENT(cie->ie_ssid, IEEE80211_NWID_LEN); - - return 0; -} diff --git a/drivers/staging/ath6kl/wlan/src/wlan_utils.c b/drivers/staging/ath6kl/wlan/src/wlan_utils.c deleted file mode 100644 index bc91599d9bf..00000000000 --- a/drivers/staging/ath6kl/wlan/src/wlan_utils.c +++ /dev/null @@ -1,58 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This module implements frequently used wlan utilies -// -// Author(s): ="Atheros" -//============================================================================== -#include -#include -#include - -/* - * converts ieee channel number to frequency - */ -u16 wlan_ieee2freq(int chan) -{ - if (chan == 14) { - return 2484; - } - if (chan < 14) { /* 0-13 */ - return (2407 + (chan*5)); - } - if (chan < 27) { /* 15-26 */ - return (2512 + ((chan-15)*20)); - } - return (5000 + (chan*5)); -} - -/* - * Converts MHz frequency to IEEE channel number. - */ -u32 wlan_freq2ieee(u16 freq) -{ - if (freq == 2484) - return 14; - if (freq < 2484) - return (freq - 2407) / 5; - if (freq < 5000) - return 15 + ((freq - 2512) / 20); - return (freq - 5000) / 5; -} diff --git a/drivers/staging/ath6kl/wmi/wmi.c b/drivers/staging/ath6kl/wmi/wmi.c deleted file mode 100644 index c7b5e5cf9df..00000000000 --- a/drivers/staging/ath6kl/wmi/wmi.c +++ /dev/null @@ -1,6444 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This module implements the hardware independent layer of the -// Wireless Module Interface (WMI) protocol. -// -// Author(s): ="Atheros" -//============================================================================== - -#include -#include -#include -#include "htc.h" -#include "htc_api.h" -#include "wmi.h" -#include -#include -#include -#include -#include "dset_api.h" -#include "wmi_host.h" -#include "a_drv.h" -#include "a_drv_api.h" -#define ATH_MODULE_NAME wmi -#include "a_debug.h" -#include "dbglog_api.h" -#include "roaming.h" -#include "cfg80211.h" - -#define ATH_DEBUG_WMI ATH_DEBUG_MAKE_MODULE_MASK(0) - -#ifdef ATH_DEBUG_MODULE - -static struct ath_debug_mask_description wmi_debug_desc[] = { - { ATH_DEBUG_WMI , "General WMI Tracing"}, -}; - -ATH_DEBUG_INSTANTIATE_MODULE_VAR(wmi, - "wmi", - "Wireless Module Interface", - ATH_DEBUG_MASK_DEFAULTS, - ATH_DEBUG_DESCRIPTION_COUNT(wmi_debug_desc), - wmi_debug_desc); - -#endif - -#ifndef REXOS -#define DBGARG _A_FUNCNAME_ -#define DBGFMT "%s() : " -#define DBG_WMI ATH_DEBUG_WMI -#define DBG_ERROR ATH_DEBUG_ERR -#define DBG_WMI2 ATH_DEBUG_WMI -#define A_DPRINTF AR_DEBUG_PRINTF -#endif - -static int wmi_ready_event_rx(struct wmi_t *wmip, u8 *datap, int len); - -static int wmi_connect_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_disconnect_event_rx(struct wmi_t *wmip, u8 *datap, - int len); - -static int wmi_tkip_micerr_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_bssInfo_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_opt_frame_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_pstream_timeout_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_sync_point(struct wmi_t *wmip); - -static int wmi_bitrate_reply_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_ratemask_reply_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_channelList_reply_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_regDomain_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_txPwr_reply_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_neighborReport_event_rx(struct wmi_t *wmip, u8 *datap, - int len); - -static int wmi_dset_open_req_rx(struct wmi_t *wmip, u8 *datap, - int len); -#ifdef CONFIG_HOST_DSET_SUPPORT -static int wmi_dset_close_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_dset_data_req_rx(struct wmi_t *wmip, u8 *datap, - int len); -#endif /* CONFIG_HOST_DSET_SUPPORT */ - - -static int wmi_scanComplete_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_errorEvent_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_statsEvent_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_rssiThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_hbChallengeResp_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_reportErrorEvent_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_cac_event_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_channel_change_event_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_roam_tbl_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_roam_data_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_get_wow_list_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int -wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, u8 *datap, u32 len); - -static int -wmi_set_params_event_rx(struct wmi_t *wmip, u8 *datap, u32 len); - - -#ifdef CONFIG_HOST_TCMD_SUPPORT -static int -wmi_tcmd_test_report_rx(struct wmi_t *wmip, u8 *datap, int len); -#endif - -static int -wmi_txRetryErrEvent_rx(struct wmi_t *wmip, u8 *datap, int len); - -static int -wmi_snrThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len); - -static int -wmi_lqThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len); - -static bool -wmi_is_bitrate_index_valid(struct wmi_t *wmip, s32 rateIndex); - -static int -wmi_aplistEvent_rx(struct wmi_t *wmip, u8 *datap, int len); - -static int -wmi_dbglog_event_rx(struct wmi_t *wmip, u8 *datap, int len); - -static int wmi_keepalive_reply_rx(struct wmi_t *wmip, u8 *datap, int len); - -int wmi_cmd_send_xtnd(struct wmi_t *wmip, void *osbuf, WMIX_COMMAND_ID cmdId, - WMI_SYNC_FLAG syncflag); - -u8 ar6000_get_upper_threshold(s16 rssi, SQ_THRESHOLD_PARAMS *sq_thresh, u32 size); -u8 ar6000_get_lower_threshold(s16 rssi, SQ_THRESHOLD_PARAMS *sq_thresh, u32 size); - -void wmi_cache_configure_rssithreshold(struct wmi_t *wmip, WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd); -void wmi_cache_configure_snrthreshold(struct wmi_t *wmip, WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd); -static int wmi_send_rssi_threshold_params(struct wmi_t *wmip, - WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd); -static int wmi_send_snr_threshold_params(struct wmi_t *wmip, - WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd); -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -static int -wmi_prof_count_rx(struct wmi_t *wmip, u8 *datap, int len); -#endif /* CONFIG_TARGET_PROFILE_SUPPORT */ - -static int wmi_pspoll_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_dtimexpiry_event_rx(struct wmi_t *wmip, u8 *datap, - int len); - -static int wmi_peer_node_event_rx (struct wmi_t *wmip, u8 *datap, - int len); -static int wmi_addba_req_event_rx(struct wmi_t *, u8 *, int); -static int wmi_addba_resp_event_rx(struct wmi_t *, u8 *, int); -static int wmi_delba_req_event_rx(struct wmi_t *, u8 *, int); -static int wmi_btcoex_config_event_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_btcoex_stats_event_rx(struct wmi_t *wmip, u8 *datap, int len); -static int wmi_hci_event_rx(struct wmi_t *, u8 *, int); - -#ifdef WAPI_ENABLE -static int wmi_wapi_rekey_event_rx(struct wmi_t *wmip, u8 *datap, - int len); -#endif - -#if defined(UNDER_CE) -#if defined(NDIS51_MINIPORT) -unsigned int processDot11Hdr = 0; -#else -unsigned int processDot11Hdr = 1; -#endif -#else -extern unsigned int processDot11Hdr; -#endif - -int wps_enable; -static const s32 wmi_rateTable[][2] = { - //{W/O SGI, with SGI} - {1000, 1000}, - {2000, 2000}, - {5500, 5500}, - {11000, 11000}, - {6000, 6000}, - {9000, 9000}, - {12000, 12000}, - {18000, 18000}, - {24000, 24000}, - {36000, 36000}, - {48000, 48000}, - {54000, 54000}, - {6500, 7200}, - {13000, 14400}, - {19500, 21700}, - {26000, 28900}, - {39000, 43300}, - {52000, 57800}, - {58500, 65000}, - {65000, 72200}, - {13500, 15000}, - {27000, 30000}, - {40500, 45000}, - {54000, 60000}, - {81000, 90000}, - {108000, 120000}, - {121500, 135000}, - {135000, 150000}, - {0, 0}}; - -#define MODE_A_SUPPORT_RATE_START ((s32) 4) -#define MODE_A_SUPPORT_RATE_STOP ((s32) 11) - -#define MODE_GONLY_SUPPORT_RATE_START MODE_A_SUPPORT_RATE_START -#define MODE_GONLY_SUPPORT_RATE_STOP MODE_A_SUPPORT_RATE_STOP - -#define MODE_B_SUPPORT_RATE_START ((s32) 0) -#define MODE_B_SUPPORT_RATE_STOP ((s32) 3) - -#define MODE_G_SUPPORT_RATE_START ((s32) 0) -#define MODE_G_SUPPORT_RATE_STOP ((s32) 11) - -#define MODE_GHT20_SUPPORT_RATE_START ((s32) 0) -#define MODE_GHT20_SUPPORT_RATE_STOP ((s32) 19) - -#define MAX_NUMBER_OF_SUPPORT_RATES (MODE_GHT20_SUPPORT_RATE_STOP + 1) - -/* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ -const u8 up_to_ac[]= { - WMM_AC_BE, - WMM_AC_BK, - WMM_AC_BK, - WMM_AC_BE, - WMM_AC_VI, - WMM_AC_VI, - WMM_AC_VO, - WMM_AC_VO, - }; - -/* This stuff is used when we want a simple layer-3 visibility */ -typedef PREPACK struct _iphdr { - u8 ip_ver_hdrlen; /* version and hdr length */ - u8 ip_tos; /* type of service */ - u16 ip_len; /* total length */ - u16 ip_id; /* identification */ - s16 ip_off; /* fragment offset field */ -#define IP_DF 0x4000 /* dont fragment flag */ -#define IP_MF 0x2000 /* more fragments flag */ -#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ - u8 ip_ttl; /* time to live */ - u8 ip_p; /* protocol */ - u16 ip_sum; /* checksum */ - u8 ip_src[4]; /* source and dest address */ - u8 ip_dst[4]; -} POSTPACK iphdr; - -static s16 rssi_event_value = 0; -static s16 snr_event_value = 0; - -bool is_probe_ssid = false; - -void * -wmi_init(void *devt) -{ - struct wmi_t *wmip; - - A_REGISTER_MODULE_DEBUG_INFO(wmi); - - wmip = A_MALLOC (sizeof(struct wmi_t)); - if (wmip == NULL) { - return (NULL); - } - A_MEMZERO(wmip, sizeof(struct wmi_t )); -#ifdef THREAD_X - INIT_WMI_LOCK(wmip); -#else - A_MUTEX_INIT(&wmip->wmi_lock); -#endif - wmip->wmi_devt = devt; - wlan_node_table_init(wmip, &wmip->wmi_scan_table); - wmi_qos_state_init(wmip); - - wmip->wmi_powerMode = REC_POWER; - wmip->wmi_phyMode = WMI_11G_MODE; - - wmip->wmi_pair_crypto_type = NONE_CRYPT; - wmip->wmi_grp_crypto_type = NONE_CRYPT; - - wmip->wmi_ht_allowed[A_BAND_24GHZ] = 1; - wmip->wmi_ht_allowed[A_BAND_5GHZ] = 1; - - return (wmip); -} - -void -wmi_qos_state_init(struct wmi_t *wmip) -{ - u8 i; - - if (wmip == NULL) { - return; - } - LOCK_WMI(wmip); - - /* Initialize QoS States */ - wmip->wmi_numQoSStream = 0; - - wmip->wmi_fatPipeExists = 0; - - for (i=0; i < WMM_NUM_AC; i++) { - wmip->wmi_streamExistsForAC[i]=0; - } - - UNLOCK_WMI(wmip); - - A_WMI_SET_NUMDATAENDPTS(wmip->wmi_devt, 1); -} - -void -wmi_set_control_ep(struct wmi_t * wmip, HTC_ENDPOINT_ID eid) -{ - A_ASSERT( eid != ENDPOINT_UNUSED); - wmip->wmi_endpoint_id = eid; -} - -HTC_ENDPOINT_ID -wmi_get_control_ep(struct wmi_t * wmip) -{ - return(wmip->wmi_endpoint_id); -} - -void -wmi_shutdown(struct wmi_t *wmip) -{ - if (wmip != NULL) { - wlan_node_table_cleanup(&wmip->wmi_scan_table); - if (A_IS_MUTEX_VALID(&wmip->wmi_lock)) { -#ifdef THREAD_X - DELETE_WMI_LOCK(&wmip); -#else - A_MUTEX_DELETE(&wmip->wmi_lock); -#endif - } - kfree(wmip); - } -} - -/* - * performs DIX to 802.3 encapsulation for transmit packets. - * uses passed in buffer. Returns buffer or NULL if failed. - * Assumes the entire DIX header is contigous and that there is - * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. - */ -int -wmi_dix_2_dot3(struct wmi_t *wmip, void *osbuf) -{ - u8 *datap; - u16 typeorlen; - ATH_MAC_HDR macHdr; - ATH_LLC_SNAP_HDR *llcHdr; - - A_ASSERT(osbuf != NULL); - - if (A_NETBUF_HEADROOM(osbuf) < - (sizeof(ATH_LLC_SNAP_HDR) + sizeof(WMI_DATA_HDR))) - { - return A_NO_MEMORY; - } - - datap = A_NETBUF_DATA(osbuf); - - typeorlen = *(u16 *)(datap + ATH_MAC_LEN + ATH_MAC_LEN); - - if (!IS_ETHERTYPE(A_BE2CPU16(typeorlen))) { - /* - * packet is already in 802.3 format - return success - */ - A_DPRINTF(DBG_WMI, (DBGFMT "packet already 802.3\n", DBGARG)); - return (0); - } - - /* - * Save mac fields and length to be inserted later - */ - memcpy(macHdr.dstMac, datap, ATH_MAC_LEN); - memcpy(macHdr.srcMac, datap + ATH_MAC_LEN, ATH_MAC_LEN); - macHdr.typeOrLen = A_CPU2BE16(A_NETBUF_LEN(osbuf) - sizeof(ATH_MAC_HDR) + - sizeof(ATH_LLC_SNAP_HDR)); - - /* - * Make room for LLC+SNAP headers - */ - if (A_NETBUF_PUSH(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != 0) { - return A_NO_MEMORY; - } - datap = A_NETBUF_DATA(osbuf); - - memcpy(datap, &macHdr, sizeof (ATH_MAC_HDR)); - - llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(ATH_MAC_HDR)); - llcHdr->dsap = 0xAA; - llcHdr->ssap = 0xAA; - llcHdr->cntl = 0x03; - llcHdr->orgCode[0] = 0x0; - llcHdr->orgCode[1] = 0x0; - llcHdr->orgCode[2] = 0x0; - llcHdr->etherType = typeorlen; - - return (0); -} - -int wmi_meta_add(struct wmi_t *wmip, void *osbuf, u8 *pVersion,void *pTxMetaS) -{ - switch(*pVersion){ - case 0: - return (0); - case WMI_META_VERSION_1: - { - WMI_TX_META_V1 *pV1= NULL; - A_ASSERT(osbuf != NULL); - if (A_NETBUF_PUSH(osbuf, WMI_MAX_TX_META_SZ) != 0) { - return A_NO_MEMORY; - } - - pV1 = (WMI_TX_META_V1 *)A_NETBUF_DATA(osbuf); - /* the pktID is used in conjunction with txComplete messages - * allowing the target to notify which tx requests have been - * completed and how. */ - pV1->pktID = 0; - /* the ratePolicyID allows the host to specify which rate policy - * to use for transmitting this packet. 0 means use default behavior. */ - pV1->ratePolicyID = 0; - A_ASSERT(pVersion != NULL); - /* the version must be used to populate the meta field of the WMI_DATA_HDR */ - *pVersion = WMI_META_VERSION_1; - return (0); - } - case WMI_META_VERSION_2: - { - WMI_TX_META_V2 *pV2 ; - A_ASSERT(osbuf != NULL); - if (A_NETBUF_PUSH(osbuf, WMI_MAX_TX_META_SZ) != 0) { - return A_NO_MEMORY; - } - pV2 = (WMI_TX_META_V2 *)A_NETBUF_DATA(osbuf); - memcpy(pV2,(WMI_TX_META_V2 *)pTxMetaS,sizeof(WMI_TX_META_V2)); - return (0); - } - default: - return (0); - } -} - -/* Adds a WMI data header */ -int -wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, u8 msgType, bool bMoreData, - WMI_DATA_HDR_DATA_TYPE data_type,u8 metaVersion, void *pTxMetaS) -{ - WMI_DATA_HDR *dtHdr; -// u8 metaVersion = 0; - int status; - - A_ASSERT(osbuf != NULL); - - /* adds the meta data field after the wmi data hdr. If metaVersion - * is returns 0 then no meta field was added. */ - if ((status = wmi_meta_add(wmip, osbuf, &metaVersion,pTxMetaS)) != 0) { - return status; - } - - if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != 0) { - return A_NO_MEMORY; - } - - dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf); - A_MEMZERO(dtHdr, sizeof(WMI_DATA_HDR)); - - WMI_DATA_HDR_SET_MSG_TYPE(dtHdr, msgType); - WMI_DATA_HDR_SET_DATA_TYPE(dtHdr, data_type); - - if (bMoreData) { - WMI_DATA_HDR_SET_MORE_BIT(dtHdr); - } - - WMI_DATA_HDR_SET_META(dtHdr, metaVersion); - - dtHdr->info3 = 0; - - return (0); -} - - -u8 wmi_implicit_create_pstream(struct wmi_t *wmip, void *osbuf, u32 layer2Priority, bool wmmEnabled) -{ - u8 *datap; - u8 trafficClass = WMM_AC_BE; - u16 ipType = IP_ETHERTYPE; - WMI_DATA_HDR *dtHdr; - u8 streamExists = 0; - u8 userPriority; - u32 hdrsize, metasize; - ATH_LLC_SNAP_HDR *llcHdr; - - WMI_CREATE_PSTREAM_CMD cmd; - - A_ASSERT(osbuf != NULL); - - // - // Initialize header size - // - hdrsize = 0; - - datap = A_NETBUF_DATA(osbuf); - dtHdr = (WMI_DATA_HDR *)datap; - metasize = (WMI_DATA_HDR_GET_META(dtHdr))? WMI_MAX_TX_META_SZ : 0; - - if (!wmmEnabled) - { - /* If WMM is disabled all traffic goes as BE traffic */ - userPriority = 0; - } - else - { - if (processDot11Hdr) - { - hdrsize = A_ROUND_UP(sizeof(struct ieee80211_qosframe),sizeof(u32)); - llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(WMI_DATA_HDR) + metasize + - hdrsize); - - - } - else - { - llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(WMI_DATA_HDR) + metasize + - sizeof(ATH_MAC_HDR)); - } - - if (llcHdr->etherType == A_CPU2BE16(ipType)) - { - /* Extract the endpoint info from the TOS field in the IP header */ - - userPriority = wmi_determine_userPriority (((u8 *)llcHdr) + sizeof(ATH_LLC_SNAP_HDR),layer2Priority); - } - else - { - userPriority = layer2Priority & 0x7; - } - } - - - /* workaround for WMM S5 */ - if ((WMM_AC_VI == wmip->wmi_traffic_class) && ((5 == userPriority) || (4 == userPriority))) - { - userPriority = 1; - } - - trafficClass = convert_userPriority_to_trafficClass(userPriority); - - WMI_DATA_HDR_SET_UP(dtHdr, userPriority); - /* lower 3-bits are 802.1d priority */ - //dtHdr->info |= (userPriority & WMI_DATA_HDR_UP_MASK) << WMI_DATA_HDR_UP_SHIFT; - - LOCK_WMI(wmip); - streamExists = wmip->wmi_fatPipeExists; - UNLOCK_WMI(wmip); - - if (!(streamExists & (1 << trafficClass))) - { - - A_MEMZERO(&cmd, sizeof(cmd)); - cmd.trafficClass = trafficClass; - cmd.userPriority = userPriority; - cmd.inactivityInt = WMI_IMPLICIT_PSTREAM_INACTIVITY_INT; - /* Implicit streams are created with TSID 0xFF */ - - cmd.tsid = WMI_IMPLICIT_PSTREAM; - wmi_create_pstream_cmd(wmip, &cmd); - } - - return trafficClass; -} - -int -wmi_dot11_hdr_add (struct wmi_t *wmip, void *osbuf, NETWORK_TYPE mode) -{ - u8 *datap; - u16 typeorlen; - ATH_MAC_HDR macHdr; - ATH_LLC_SNAP_HDR *llcHdr; - struct ieee80211_frame *wh; - u32 hdrsize; - - A_ASSERT(osbuf != NULL); - - if (A_NETBUF_HEADROOM(osbuf) < - (sizeof(struct ieee80211_qosframe) + sizeof(ATH_LLC_SNAP_HDR) + sizeof(WMI_DATA_HDR))) - { - return A_NO_MEMORY; - } - - datap = A_NETBUF_DATA(osbuf); - - typeorlen = *(u16 *)(datap + ATH_MAC_LEN + ATH_MAC_LEN); - - if (!IS_ETHERTYPE(A_BE2CPU16(typeorlen))) { -/* - * packet is already in 802.3 format - return success - */ - A_DPRINTF(DBG_WMI, (DBGFMT "packet already 802.3\n", DBGARG)); - goto AddDot11Hdr; - } - - /* - * Save mac fields and length to be inserted later - */ - memcpy(macHdr.dstMac, datap, ATH_MAC_LEN); - memcpy(macHdr.srcMac, datap + ATH_MAC_LEN, ATH_MAC_LEN); - macHdr.typeOrLen = A_CPU2BE16(A_NETBUF_LEN(osbuf) - sizeof(ATH_MAC_HDR) + - sizeof(ATH_LLC_SNAP_HDR)); - - // Remove the Ethernet hdr - A_NETBUF_PULL(osbuf, sizeof(ATH_MAC_HDR)); - /* - * Make room for LLC+SNAP headers - */ - if (A_NETBUF_PUSH(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != 0) { - return A_NO_MEMORY; - } - datap = A_NETBUF_DATA(osbuf); - - llcHdr = (ATH_LLC_SNAP_HDR *)(datap); - llcHdr->dsap = 0xAA; - llcHdr->ssap = 0xAA; - llcHdr->cntl = 0x03; - llcHdr->orgCode[0] = 0x0; - llcHdr->orgCode[1] = 0x0; - llcHdr->orgCode[2] = 0x0; - llcHdr->etherType = typeorlen; - -AddDot11Hdr: - /* Make room for 802.11 hdr */ - if (wmip->wmi_is_wmm_enabled) - { - hdrsize = A_ROUND_UP(sizeof(struct ieee80211_qosframe),sizeof(u32)); - if (A_NETBUF_PUSH(osbuf, hdrsize) != 0) - { - return A_NO_MEMORY; - } - wh = (struct ieee80211_frame *) A_NETBUF_DATA(osbuf); - wh->i_fc[0] = IEEE80211_FC0_SUBTYPE_QOS; - } - else - { - hdrsize = A_ROUND_UP(sizeof(struct ieee80211_frame),sizeof(u32)); - if (A_NETBUF_PUSH(osbuf, hdrsize) != 0) - { - return A_NO_MEMORY; - } - wh = (struct ieee80211_frame *) A_NETBUF_DATA(osbuf); - wh->i_fc[0] = IEEE80211_FC0_SUBTYPE_DATA; - } - /* Setup the SA & DA */ - IEEE80211_ADDR_COPY(wh->i_addr2, macHdr.srcMac); - - if (mode == INFRA_NETWORK) { - IEEE80211_ADDR_COPY(wh->i_addr3, macHdr.dstMac); - } - else if (mode == ADHOC_NETWORK) { - IEEE80211_ADDR_COPY(wh->i_addr1, macHdr.dstMac); - } - - return (0); -} - -int -wmi_dot11_hdr_remove(struct wmi_t *wmip, void *osbuf) -{ - u8 *datap; - struct ieee80211_frame *pwh,wh; - u8 type,subtype; - ATH_LLC_SNAP_HDR *llcHdr; - ATH_MAC_HDR macHdr; - u32 hdrsize; - - A_ASSERT(osbuf != NULL); - datap = A_NETBUF_DATA(osbuf); - - pwh = (struct ieee80211_frame *)datap; - type = pwh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - subtype = pwh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; - - memcpy((u8 *)&wh, datap, sizeof(struct ieee80211_frame)); - - /* strip off the 802.11 hdr*/ - if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { - hdrsize = A_ROUND_UP(sizeof(struct ieee80211_qosframe),sizeof(u32)); - A_NETBUF_PULL(osbuf, hdrsize); - } else if (subtype == IEEE80211_FC0_SUBTYPE_DATA) { - A_NETBUF_PULL(osbuf, sizeof(struct ieee80211_frame)); - } - - datap = A_NETBUF_DATA(osbuf); - llcHdr = (ATH_LLC_SNAP_HDR *)(datap); - - macHdr.typeOrLen = llcHdr->etherType; - A_MEMZERO(macHdr.dstMac, sizeof(macHdr.dstMac)); - A_MEMZERO(macHdr.srcMac, sizeof(macHdr.srcMac)); - - switch (wh.i_fc[1] & IEEE80211_FC1_DIR_MASK) { - case IEEE80211_FC1_DIR_NODS: - IEEE80211_ADDR_COPY(macHdr.dstMac, wh.i_addr1); - IEEE80211_ADDR_COPY(macHdr.srcMac, wh.i_addr2); - break; - case IEEE80211_FC1_DIR_TODS: - IEEE80211_ADDR_COPY(macHdr.dstMac, wh.i_addr3); - IEEE80211_ADDR_COPY(macHdr.srcMac, wh.i_addr2); - break; - case IEEE80211_FC1_DIR_FROMDS: - IEEE80211_ADDR_COPY(macHdr.dstMac, wh.i_addr1); - IEEE80211_ADDR_COPY(macHdr.srcMac, wh.i_addr3); - break; - case IEEE80211_FC1_DIR_DSTODS: - break; - } - - // Remove the LLC Hdr. - A_NETBUF_PULL(osbuf, sizeof(ATH_LLC_SNAP_HDR)); - - // Insert the ATH MAC hdr. - - A_NETBUF_PUSH(osbuf, sizeof(ATH_MAC_HDR)); - datap = A_NETBUF_DATA(osbuf); - - memcpy (datap, &macHdr, sizeof(ATH_MAC_HDR)); - - return 0; -} - -/* - * performs 802.3 to DIX encapsulation for received packets. - * Assumes the entire 802.3 header is contigous. - */ -int -wmi_dot3_2_dix(void *osbuf) -{ - u8 *datap; - ATH_MAC_HDR macHdr; - ATH_LLC_SNAP_HDR *llcHdr; - - A_ASSERT(osbuf != NULL); - datap = A_NETBUF_DATA(osbuf); - - memcpy(&macHdr, datap, sizeof(ATH_MAC_HDR)); - llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(ATH_MAC_HDR)); - macHdr.typeOrLen = llcHdr->etherType; - - if (A_NETBUF_PULL(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != 0) { - return A_NO_MEMORY; - } - - datap = A_NETBUF_DATA(osbuf); - - memcpy(datap, &macHdr, sizeof (ATH_MAC_HDR)); - - return (0); -} - -/* - * Removes a WMI data header - */ -int -wmi_data_hdr_remove(struct wmi_t *wmip, void *osbuf) -{ - A_ASSERT(osbuf != NULL); - - return (A_NETBUF_PULL(osbuf, sizeof(WMI_DATA_HDR))); -} - -void -wmi_iterate_nodes(struct wmi_t *wmip, wlan_node_iter_func *f, void *arg) -{ - wlan_iterate_nodes(&wmip->wmi_scan_table, f, arg); -} - -/* - * WMI Extended Event received from Target. - */ -int -wmi_control_rx_xtnd(struct wmi_t *wmip, void *osbuf) -{ - WMIX_CMD_HDR *cmd; - u16 id; - u8 *datap; - u32 len; - int status = 0; - - if (A_NETBUF_LEN(osbuf) < sizeof(WMIX_CMD_HDR)) { - A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 1\n", DBGARG)); - wmip->wmi_stats.cmd_len_err++; - return A_ERROR; - } - - cmd = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf); - id = cmd->commandId; - - if (A_NETBUF_PULL(osbuf, sizeof(WMIX_CMD_HDR)) != 0) { - A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 2\n", DBGARG)); - wmip->wmi_stats.cmd_len_err++; - return A_ERROR; - } - - datap = A_NETBUF_DATA(osbuf); - len = A_NETBUF_LEN(osbuf); - - switch (id) { - case (WMIX_DSETOPENREQ_EVENTID): - status = wmi_dset_open_req_rx(wmip, datap, len); - break; -#ifdef CONFIG_HOST_DSET_SUPPORT - case (WMIX_DSETCLOSE_EVENTID): - status = wmi_dset_close_rx(wmip, datap, len); - break; - case (WMIX_DSETDATAREQ_EVENTID): - status = wmi_dset_data_req_rx(wmip, datap, len); - break; -#endif /* CONFIG_HOST_DSET_SUPPORT */ - case (WMIX_HB_CHALLENGE_RESP_EVENTID): - wmi_hbChallengeResp_rx(wmip, datap, len); - break; - case (WMIX_DBGLOG_EVENTID): - wmi_dbglog_event_rx(wmip, datap, len); - break; -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) - case (WMIX_PROF_COUNT_EVENTID): - wmi_prof_count_rx(wmip, datap, len); - break; -#endif /* CONFIG_TARGET_PROFILE_SUPPORT */ - default: - A_DPRINTF(DBG_WMI|DBG_ERROR, - (DBGFMT "Unknown id 0x%x\n", DBGARG, id)); - wmip->wmi_stats.cmd_id_err++; - status = A_ERROR; - break; - } - - return status; -} - -/* - * Control Path - */ -u32 cmdRecvNum; - -int -wmi_control_rx(struct wmi_t *wmip, void *osbuf) -{ - WMI_CMD_HDR *cmd; - u16 id; - u8 *datap; - u32 len, i, loggingReq; - int status = 0; - - A_ASSERT(osbuf != NULL); - if (A_NETBUF_LEN(osbuf) < sizeof(WMI_CMD_HDR)) { - A_NETBUF_FREE(osbuf); - A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 1\n", DBGARG)); - wmip->wmi_stats.cmd_len_err++; - return A_ERROR; - } - - cmd = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf); - id = cmd->commandId; - - if (A_NETBUF_PULL(osbuf, sizeof(WMI_CMD_HDR)) != 0) { - A_NETBUF_FREE(osbuf); - A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 2\n", DBGARG)); - wmip->wmi_stats.cmd_len_err++; - return A_ERROR; - } - - datap = A_NETBUF_DATA(osbuf); - len = A_NETBUF_LEN(osbuf); - - loggingReq = 0; - - ar6000_get_driver_cfg(wmip->wmi_devt, - AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS, - &loggingReq); - - if(loggingReq) { - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("WMI %d \n",id)); - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("WMI recv, MsgNo %d : ", cmdRecvNum)); - for(i = 0; i < len; i++) - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("%x ", datap[i])); - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("\n")); - } - - LOCK_WMI(wmip); - cmdRecvNum++; - UNLOCK_WMI(wmip); - - switch (id) { - case (WMI_GET_BITRATE_CMDID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_BITRATE_CMDID\n", DBGARG)); - status = wmi_bitrate_reply_rx(wmip, datap, len); - break; - case (WMI_GET_CHANNEL_LIST_CMDID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_CHANNEL_LIST_CMDID\n", DBGARG)); - status = wmi_channelList_reply_rx(wmip, datap, len); - break; - case (WMI_GET_TX_PWR_CMDID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_TX_PWR_CMDID\n", DBGARG)); - status = wmi_txPwr_reply_rx(wmip, datap, len); - break; - case (WMI_READY_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_READY_EVENTID\n", DBGARG)); - status = wmi_ready_event_rx(wmip, datap, len); - A_WMI_DBGLOG_INIT_DONE(wmip->wmi_devt); - break; - case (WMI_CONNECT_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CONNECT_EVENTID\n", DBGARG)); - status = wmi_connect_event_rx(wmip, datap, len); - break; - case (WMI_DISCONNECT_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_DISCONNECT_EVENTID\n", DBGARG)); - status = wmi_disconnect_event_rx(wmip, datap, len); - break; - case (WMI_PEER_NODE_EVENTID): - A_DPRINTF (DBG_WMI, (DBGFMT "WMI_PEER_NODE_EVENTID\n", DBGARG)); - status = wmi_peer_node_event_rx(wmip, datap, len); - break; - case (WMI_TKIP_MICERR_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TKIP_MICERR_EVENTID\n", DBGARG)); - status = wmi_tkip_micerr_event_rx(wmip, datap, len); - break; - case (WMI_BSSINFO_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_BSSINFO_EVENTID\n", DBGARG)); - { - /* - * convert WMI_BSS_INFO_HDR2 to WMI_BSS_INFO_HDR - * Take a local copy of the WMI_BSS_INFO_HDR2 from the wmi buffer - * and reconstruct the WMI_BSS_INFO_HDR in its place - */ - WMI_BSS_INFO_HDR2 bih2; - WMI_BSS_INFO_HDR *bih; - memcpy(&bih2, datap, sizeof(WMI_BSS_INFO_HDR2)); - - A_NETBUF_PUSH(osbuf, 4); - datap = A_NETBUF_DATA(osbuf); - len = A_NETBUF_LEN(osbuf); - bih = (WMI_BSS_INFO_HDR *)datap; - - bih->channel = bih2.channel; - bih->frameType = bih2.frameType; - bih->snr = bih2.snr; - bih->rssi = bih2.snr - 95; - bih->ieMask = bih2.ieMask; - memcpy(bih->bssid, bih2.bssid, ATH_MAC_LEN); - - status = wmi_bssInfo_event_rx(wmip, datap, len); - } - break; - case (WMI_REGDOMAIN_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REGDOMAIN_EVENTID\n", DBGARG)); - status = wmi_regDomain_event_rx(wmip, datap, len); - break; - case (WMI_PSTREAM_TIMEOUT_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_PSTREAM_TIMEOUT_EVENTID\n", DBGARG)); - status = wmi_pstream_timeout_event_rx(wmip, datap, len); - break; - case (WMI_NEIGHBOR_REPORT_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_NEIGHBOR_REPORT_EVENTID\n", DBGARG)); - status = wmi_neighborReport_event_rx(wmip, datap, len); - break; - case (WMI_SCAN_COMPLETE_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SCAN_COMPLETE_EVENTID\n", DBGARG)); - status = wmi_scanComplete_rx(wmip, datap, len); - break; - case (WMI_CMDERROR_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CMDERROR_EVENTID\n", DBGARG)); - status = wmi_errorEvent_rx(wmip, datap, len); - break; - case (WMI_REPORT_STATISTICS_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_STATISTICS_EVENTID\n", DBGARG)); - status = wmi_statsEvent_rx(wmip, datap, len); - break; - case (WMI_RSSI_THRESHOLD_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_RSSI_THRESHOLD_EVENTID\n", DBGARG)); - status = wmi_rssiThresholdEvent_rx(wmip, datap, len); - break; - case (WMI_ERROR_REPORT_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_ERROR_REPORT_EVENTID\n", DBGARG)); - status = wmi_reportErrorEvent_rx(wmip, datap, len); - break; - case (WMI_OPT_RX_FRAME_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_OPT_RX_FRAME_EVENTID\n", DBGARG)); - status = wmi_opt_frame_event_rx(wmip, datap, len); - break; - case (WMI_REPORT_ROAM_TBL_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_ROAM_TBL_EVENTID\n", DBGARG)); - status = wmi_roam_tbl_event_rx(wmip, datap, len); - break; - case (WMI_EXTENSION_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_EXTENSION_EVENTID\n", DBGARG)); - status = wmi_control_rx_xtnd(wmip, osbuf); - break; - case (WMI_CAC_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CAC_EVENTID\n", DBGARG)); - status = wmi_cac_event_rx(wmip, datap, len); - break; - case (WMI_CHANNEL_CHANGE_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CHANNEL_CHANGE_EVENTID\n", DBGARG)); - status = wmi_channel_change_event_rx(wmip, datap, len); - break; - case (WMI_REPORT_ROAM_DATA_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_ROAM_DATA_EVENTID\n", DBGARG)); - status = wmi_roam_data_event_rx(wmip, datap, len); - break; -#ifdef CONFIG_HOST_TCMD_SUPPORT - case (WMI_TEST_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TEST_EVENTID\n", DBGARG)); - status = wmi_tcmd_test_report_rx(wmip, datap, len); - break; -#endif - case (WMI_GET_FIXRATES_CMDID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_FIXRATES_CMDID\n", DBGARG)); - status = wmi_ratemask_reply_rx(wmip, datap, len); - break; - case (WMI_TX_RETRY_ERR_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TX_RETRY_ERR_EVENTID\n", DBGARG)); - status = wmi_txRetryErrEvent_rx(wmip, datap, len); - break; - case (WMI_SNR_THRESHOLD_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SNR_THRESHOLD_EVENTID\n", DBGARG)); - status = wmi_snrThresholdEvent_rx(wmip, datap, len); - break; - case (WMI_LQ_THRESHOLD_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_LQ_THRESHOLD_EVENTID\n", DBGARG)); - status = wmi_lqThresholdEvent_rx(wmip, datap, len); - break; - case (WMI_APLIST_EVENTID): - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Received APLIST Event\n")); - status = wmi_aplistEvent_rx(wmip, datap, len); - break; - case (WMI_GET_KEEPALIVE_CMDID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_KEEPALIVE_CMDID\n", DBGARG)); - status = wmi_keepalive_reply_rx(wmip, datap, len); - break; - case (WMI_GET_WOW_LIST_EVENTID): - status = wmi_get_wow_list_event_rx(wmip, datap, len); - break; - case (WMI_GET_PMKID_LIST_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_PMKID_LIST Event\n", DBGARG)); - status = wmi_get_pmkid_list_event_rx(wmip, datap, len); - break; - case (WMI_PSPOLL_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_PSPOLL_EVENT\n", DBGARG)); - status = wmi_pspoll_event_rx(wmip, datap, len); - break; - case (WMI_DTIMEXPIRY_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_DTIMEXPIRY_EVENT\n", DBGARG)); - status = wmi_dtimexpiry_event_rx(wmip, datap, len); - break; - case (WMI_SET_PARAMS_REPLY_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SET_PARAMS_REPLY Event\n", DBGARG)); - status = wmi_set_params_event_rx(wmip, datap, len); - break; - case (WMI_ADDBA_REQ_EVENTID): - status = wmi_addba_req_event_rx(wmip, datap, len); - break; - case (WMI_ADDBA_RESP_EVENTID): - status = wmi_addba_resp_event_rx(wmip, datap, len); - break; - case (WMI_DELBA_REQ_EVENTID): - status = wmi_delba_req_event_rx(wmip, datap, len); - break; - case (WMI_REPORT_BTCOEX_CONFIG_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_BTCOEX_CONFIG_EVENTID", DBGARG)); - status = wmi_btcoex_config_event_rx(wmip, datap, len); - break; - case (WMI_REPORT_BTCOEX_STATS_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_BTCOEX_STATS_EVENTID", DBGARG)); - status = wmi_btcoex_stats_event_rx(wmip, datap, len); - break; - case (WMI_TX_COMPLETE_EVENTID): - { - int index; - TX_COMPLETE_MSG_V1 *pV1; - WMI_TX_COMPLETE_EVENT *pEv = (WMI_TX_COMPLETE_EVENT *)datap; - A_PRINTF("comp: %d %d %d\n", pEv->numMessages, pEv->msgLen, pEv->msgType); - - for(index = 0 ; index < pEv->numMessages ; index++) { - pV1 = (TX_COMPLETE_MSG_V1 *)(datap + sizeof(WMI_TX_COMPLETE_EVENT) + index*sizeof(TX_COMPLETE_MSG_V1)); - A_PRINTF("msg: %d %d %d %d\n", pV1->status, pV1->pktID, pV1->rateIdx, pV1->ackFailures); - } - } - break; - case (WMI_HCI_EVENT_EVENTID): - status = wmi_hci_event_rx(wmip, datap, len); - break; -#ifdef WAPI_ENABLE - case (WMI_WAPI_REKEY_EVENTID): - A_DPRINTF(DBG_WMI, (DBGFMT "WMI_WAPI_REKEY_EVENTID", DBGARG)); - status = wmi_wapi_rekey_event_rx(wmip, datap, len); - break; -#endif - default: - A_DPRINTF(DBG_WMI|DBG_ERROR, - (DBGFMT "Unknown id 0x%x\n", DBGARG, id)); - wmip->wmi_stats.cmd_id_err++; - status = A_ERROR; - break; - } - - A_NETBUF_FREE(osbuf); - - return status; -} - -/* Send a "simple" wmi command -- one with no arguments */ -static int -wmi_simple_cmd(struct wmi_t *wmip, WMI_COMMAND_ID cmdid) -{ - void *osbuf; - - osbuf = A_NETBUF_ALLOC(0); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - return (wmi_cmd_send(wmip, osbuf, cmdid, NO_SYNC_WMIFLAG)); -} - -/* Send a "simple" extended wmi command -- one with no arguments. - Enabling this command only if GPIO or profiling support is enabled. - This is to suppress warnings on some platforms */ -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -static int -wmi_simple_cmd_xtnd(struct wmi_t *wmip, WMIX_COMMAND_ID cmdid) -{ - void *osbuf; - - osbuf = A_NETBUF_ALLOC(0); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - return (wmi_cmd_send_xtnd(wmip, osbuf, cmdid, NO_SYNC_WMIFLAG)); -} -#endif - -static int -wmi_ready_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_READY_EVENT *ev = (WMI_READY_EVENT *)datap; - - if (len < sizeof(WMI_READY_EVENT)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - wmip->wmi_ready = true; - A_WMI_READY_EVENT(wmip->wmi_devt, ev->macaddr, ev->phyCapability, - ev->sw_version, ev->abi_version); - - return 0; -} - -#define LE_READ_4(p) \ - ((u32) \ - ((((u8 *)(p))[0] ) | (((u8 *)(p))[1] << 8) | \ - (((u8 *)(p))[2] << 16) | (((u8 *)(p))[3] << 24))) - -static int __inline -iswmmoui(const u8 *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((WMM_OUI_TYPE<<24)|WMM_OUI); -} - -static int __inline -iswmmparam(const u8 *frm) -{ - return frm[1] > 5 && frm[6] == WMM_PARAM_OUI_SUBTYPE; -} - - -static int -wmi_connect_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_CONNECT_EVENT *ev; - u8 *pie,*peie; - - if (len < sizeof(WMI_CONNECT_EVENT)) - { - return A_EINVAL; - } - ev = (WMI_CONNECT_EVENT *)datap; - - A_DPRINTF(DBG_WMI, - (DBGFMT "freq %d bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", - DBGARG, ev->channel, - ev->bssid[0], ev->bssid[1], ev->bssid[2], - ev->bssid[3], ev->bssid[4], ev->bssid[5])); - - memcpy(wmip->wmi_bssid, ev->bssid, ATH_MAC_LEN); - - /* initialize pointer to start of assoc rsp IEs */ - pie = ev->assocInfo + ev->beaconIeLen + ev->assocReqLen + - sizeof(u16) + /* capinfo*/ - sizeof(u16) + /* status Code */ - sizeof(u16) ; /* associd */ - - /* initialize pointer to end of assoc rsp IEs */ - peie = ev->assocInfo + ev->beaconIeLen + ev->assocReqLen + ev->assocRespLen; - - while (pie < peie) - { - switch (*pie) - { - case IEEE80211_ELEMID_VENDOR: - if (iswmmoui(pie)) - { - if(iswmmparam (pie)) - { - wmip->wmi_is_wmm_enabled = true; - } - } - break; - } - - if (wmip->wmi_is_wmm_enabled) - { - break; - } - pie += pie[1] + 2; - } - - A_WMI_CONNECT_EVENT(wmip->wmi_devt, ev->channel, ev->bssid, - ev->listenInterval, ev->beaconInterval, - (NETWORK_TYPE) ev->networkType, ev->beaconIeLen, - ev->assocReqLen, ev->assocRespLen, - ev->assocInfo); - - return 0; -} - -static int -wmi_regDomain_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_REG_DOMAIN_EVENT *ev; - - if (len < sizeof(*ev)) { - return A_EINVAL; - } - ev = (WMI_REG_DOMAIN_EVENT *)datap; - - A_WMI_REGDOMAIN_EVENT(wmip->wmi_devt, ev->regDomain); - - return 0; -} - -static int -wmi_neighborReport_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_NEIGHBOR_REPORT_EVENT *ev; - int numAps; - - if (len < sizeof(*ev)) { - return A_EINVAL; - } - ev = (WMI_NEIGHBOR_REPORT_EVENT *)datap; - numAps = ev->numberOfAps; - - if (len < (int)(sizeof(*ev) + ((numAps - 1) * sizeof(WMI_NEIGHBOR_INFO)))) { - return A_EINVAL; - } - - A_WMI_NEIGHBORREPORT_EVENT(wmip->wmi_devt, numAps, ev->neighbor); - - return 0; -} - -static int -wmi_disconnect_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_DISCONNECT_EVENT *ev; - wmip->wmi_traffic_class = 100; - - if (len < sizeof(WMI_DISCONNECT_EVENT)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - ev = (WMI_DISCONNECT_EVENT *)datap; - - A_MEMZERO(wmip->wmi_bssid, sizeof(wmip->wmi_bssid)); - - wmip->wmi_is_wmm_enabled = false; - wmip->wmi_pair_crypto_type = NONE_CRYPT; - wmip->wmi_grp_crypto_type = NONE_CRYPT; - - A_WMI_DISCONNECT_EVENT(wmip->wmi_devt, ev->disconnectReason, ev->bssid, - ev->assocRespLen, ev->assocInfo, ev->protocolReasonStatus); - - return 0; -} - -static int -wmi_peer_node_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_PEER_NODE_EVENT *ev; - - if (len < sizeof(WMI_PEER_NODE_EVENT)) { - return A_EINVAL; - } - ev = (WMI_PEER_NODE_EVENT *)datap; - if (ev->eventCode == PEER_NODE_JOIN_EVENT) { - A_DPRINTF (DBG_WMI, (DBGFMT "Joined node with Macaddr: ", DBGARG)); - } else if(ev->eventCode == PEER_NODE_LEAVE_EVENT) { - A_DPRINTF (DBG_WMI, (DBGFMT "left node with Macaddr: ", DBGARG)); - } - - A_WMI_PEER_EVENT (wmip->wmi_devt, ev->eventCode, ev->peerMacAddr); - - return 0; -} - -static int -wmi_tkip_micerr_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_TKIP_MICERR_EVENT *ev; - - if (len < sizeof(*ev)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - ev = (WMI_TKIP_MICERR_EVENT *)datap; - A_WMI_TKIP_MICERR_EVENT(wmip->wmi_devt, ev->keyid, ev->ismcast); - - return 0; -} - -static int -wmi_bssInfo_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - bss_t *bss = NULL; - WMI_BSS_INFO_HDR *bih; - u8 *buf; - u32 nodeCachingAllowed = 1; - u8 cached_ssid_len = 0; - u8 cached_ssid_buf[IEEE80211_NWID_LEN] = {0}; - u8 beacon_ssid_len = 0; - - if (len <= sizeof(WMI_BSS_INFO_HDR)) { - return A_EINVAL; - } - - bih = (WMI_BSS_INFO_HDR *)datap; - bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid); - - if (bih->rssi > 0) { - if (NULL == bss) - return 0; //no node found in the table, just drop the node with incorrect RSSI - else - bih->rssi = bss->ni_rssi; //Adjust RSSI in datap in case it is used in A_WMI_BSSINFO_EVENT_RX - } - - A_WMI_BSSINFO_EVENT_RX(wmip->wmi_devt, datap, len); - /* What is driver config for wlan node caching? */ - if(ar6000_get_driver_cfg(wmip->wmi_devt, - AR6000_DRIVER_CFG_GET_WLANNODECACHING, - &nodeCachingAllowed) != 0) { - wmi_node_return(wmip, bss); - return A_EINVAL; - } - - if(!nodeCachingAllowed) { - wmi_node_return(wmip, bss); - return 0; - } - - buf = datap + sizeof(WMI_BSS_INFO_HDR); - len -= sizeof(WMI_BSS_INFO_HDR); - - A_DPRINTF(DBG_WMI2, (DBGFMT "bssInfo event - ch %u, rssi %02x, " - "bssid \"%pM\"\n", DBGARG, bih->channel, - (unsigned char) bih->rssi, bih->bssid)); - - if(wps_enable && (bih->frameType == PROBERESP_FTYPE) ) { - wmi_node_return(wmip, bss); - return 0; - } - - if (bss != NULL) { - /* - * Free up the node. Not the most efficient process given - * we are about to allocate a new node but it is simple and should be - * adequate. - */ - - /* In case of hidden AP, beacon will not have ssid, - * but a directed probe response will have it, - * so cache the probe-resp-ssid if already present. */ - if ((true == is_probe_ssid) && (BEACON_FTYPE == bih->frameType)) - { - u8 *ie_ssid; - - ie_ssid = bss->ni_cie.ie_ssid; - if(ie_ssid && (ie_ssid[1] <= IEEE80211_NWID_LEN) && (ie_ssid[2] != 0)) - { - cached_ssid_len = ie_ssid[1]; - memcpy(cached_ssid_buf, ie_ssid + 2, cached_ssid_len); - } - } - - /* - * Use the current average rssi of associated AP base on assumpiton - * 1. Most os with GUI will update RSSI by wmi_get_stats_cmd() periodically - * 2. wmi_get_stats_cmd(..) will be called when calling wmi_startscan_cmd(...) - * The average value of RSSI give end-user better feeling for instance value of scan result - * It also sync up RSSI info in GUI between scan result and RSSI signal icon - */ - if (IEEE80211_ADDR_EQ(wmip->wmi_bssid, bih->bssid)) { - bih->rssi = bss->ni_rssi; - bih->snr = bss->ni_snr; - } - - wlan_node_reclaim(&wmip->wmi_scan_table, bss); - } - - /* beacon/probe response frame format - * [8] time stamp - * [2] beacon interval - * [2] capability information - * [tlv] ssid */ - beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; - - /* If ssid is cached for this hidden AP, then change buffer len accordingly. */ - if ((true == is_probe_ssid) && (BEACON_FTYPE == bih->frameType) && - (0 != cached_ssid_len) && - (0 == beacon_ssid_len || (cached_ssid_len > beacon_ssid_len && 0 == buf[SSID_IE_LEN_INDEX + 1]))) - { - len += (cached_ssid_len - beacon_ssid_len); - } - - bss = wlan_node_alloc(&wmip->wmi_scan_table, len); - if (bss == NULL) { - return A_NO_MEMORY; - } - - bss->ni_snr = bih->snr; - bss->ni_rssi = bih->rssi; - A_ASSERT(bss->ni_buf != NULL); - - /* In case of hidden AP, beacon will not have ssid, - * but a directed probe response will have it, - * so place the cached-ssid(probe-resp) in the bssinfo. */ - if ((true == is_probe_ssid) && (BEACON_FTYPE == bih->frameType) && - (0 != cached_ssid_len) && - (0 == beacon_ssid_len || (beacon_ssid_len && 0 == buf[SSID_IE_LEN_INDEX + 1]))) - { - u8 *ni_buf = bss->ni_buf; - int buf_len = len; - - /* copy the first 14 bytes such as - * time-stamp(8), beacon-interval(2), cap-info(2), ssid-id(1), ssid-len(1). */ - memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); - - ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; - ni_buf += (SSID_IE_LEN_INDEX + 1); - - buf += (SSID_IE_LEN_INDEX + 1); - buf_len -= (SSID_IE_LEN_INDEX + 1); - - /* copy the cached ssid */ - memcpy(ni_buf, cached_ssid_buf, cached_ssid_len); - ni_buf += cached_ssid_len; - - buf += beacon_ssid_len; - buf_len -= beacon_ssid_len; - - if (cached_ssid_len > beacon_ssid_len) - buf_len -= (cached_ssid_len - beacon_ssid_len); - - /* now copy the rest of bytes */ - memcpy(ni_buf, buf, buf_len); - } - else - memcpy(bss->ni_buf, buf, len); - - bss->ni_framelen = len; - if (wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie) != 0) { - wlan_node_free(bss); - return A_EINVAL; - } - - /* - * Update the frequency in ie_chan, overwriting of channel number - * which is done in wlan_parse_beacon - */ - bss->ni_cie.ie_chan = bih->channel; - wlan_setup_node(&wmip->wmi_scan_table, bss, bih->bssid); - - return 0; -} - -static int -wmi_opt_frame_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - bss_t *bss; - WMI_OPT_RX_INFO_HDR *bih; - u8 *buf; - - if (len <= sizeof(WMI_OPT_RX_INFO_HDR)) { - return A_EINVAL; - } - - bih = (WMI_OPT_RX_INFO_HDR *)datap; - buf = datap + sizeof(WMI_OPT_RX_INFO_HDR); - len -= sizeof(WMI_OPT_RX_INFO_HDR); - - A_DPRINTF(DBG_WMI2, (DBGFMT "opt frame event %2.2x:%2.2x\n", DBGARG, - bih->bssid[4], bih->bssid[5])); - - bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid); - if (bss != NULL) { - /* - * Free up the node. Not the most efficient process given - * we are about to allocate a new node but it is simple and should be - * adequate. - */ - wlan_node_reclaim(&wmip->wmi_scan_table, bss); - } - - bss = wlan_node_alloc(&wmip->wmi_scan_table, len); - if (bss == NULL) { - return A_NO_MEMORY; - } - - bss->ni_snr = bih->snr; - bss->ni_cie.ie_chan = bih->channel; - A_ASSERT(bss->ni_buf != NULL); - memcpy(bss->ni_buf, buf, len); - wlan_setup_node(&wmip->wmi_scan_table, bss, bih->bssid); - - return 0; -} - - /* This event indicates inactivity timeout of a fatpipe(pstream) - * at the target - */ -static int -wmi_pstream_timeout_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_PSTREAM_TIMEOUT_EVENT *ev; - - if (len < sizeof(WMI_PSTREAM_TIMEOUT_EVENT)) { - return A_EINVAL; - } - - A_DPRINTF(DBG_WMI, (DBGFMT "wmi_pstream_timeout_event_rx\n", DBGARG)); - - ev = (WMI_PSTREAM_TIMEOUT_EVENT *)datap; - - /* When the pstream (fat pipe == AC) timesout, it means there were no - * thinStreams within this pstream & it got implicitly created due to - * data flow on this AC. We start the inactivity timer only for - * implicitly created pstream. Just reset the host state. - */ - /* Set the activeTsids for this AC to 0 */ - LOCK_WMI(wmip); - wmip->wmi_streamExistsForAC[ev->trafficClass]=0; - wmip->wmi_fatPipeExists &= ~(1 << ev->trafficClass); - UNLOCK_WMI(wmip); - - /*Indicate inactivity to driver layer for this fatpipe (pstream)*/ - A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, ev->trafficClass); - - return 0; -} - -static int -wmi_bitrate_reply_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_BIT_RATE_REPLY *reply; - s32 rate; - u32 sgi,index; - /* 54149: - * WMI_BIT_RATE_CMD structure is changed to WMI_BIT_RATE_REPLY. - * since there is difference in the length and to avoid returning - * error value. - */ - if (len < sizeof(WMI_BIT_RATE_REPLY)) { - return A_EINVAL; - } - reply = (WMI_BIT_RATE_REPLY *)datap; - A_DPRINTF(DBG_WMI, - (DBGFMT "Enter - rateindex %d\n", DBGARG, reply->rateIndex)); - - if (reply->rateIndex == (s8) RATE_AUTO) { - rate = RATE_AUTO; - } else { - // the SGI state is stored as the MSb of the rateIndex - index = reply->rateIndex & 0x7f; - sgi = (reply->rateIndex & 0x80)? 1:0; - rate = wmi_rateTable[index][sgi]; - } - - A_WMI_BITRATE_RX(wmip->wmi_devt, rate); - return 0; -} - -static int -wmi_ratemask_reply_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_FIX_RATES_REPLY *reply; - - if (len < sizeof(WMI_FIX_RATES_REPLY)) { - return A_EINVAL; - } - reply = (WMI_FIX_RATES_REPLY *)datap; - A_DPRINTF(DBG_WMI, - (DBGFMT "Enter - fixed rate mask %x\n", DBGARG, reply->fixRateMask)); - - A_WMI_RATEMASK_RX(wmip->wmi_devt, reply->fixRateMask); - - return 0; -} - -static int -wmi_channelList_reply_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_CHANNEL_LIST_REPLY *reply; - - if (len < sizeof(WMI_CHANNEL_LIST_REPLY)) { - return A_EINVAL; - } - reply = (WMI_CHANNEL_LIST_REPLY *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_CHANNELLIST_RX(wmip->wmi_devt, reply->numChannels, - reply->channelList); - - return 0; -} - -static int -wmi_txPwr_reply_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_TX_PWR_REPLY *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_TX_PWR_REPLY *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_TXPWR_RX(wmip->wmi_devt, reply->dbM); - - return 0; -} -static int -wmi_keepalive_reply_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_GET_KEEPALIVE_CMD *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_GET_KEEPALIVE_CMD *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_KEEPALIVE_RX(wmip->wmi_devt, reply->configured); - - return 0; -} - - -static int -wmi_dset_open_req_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMIX_DSETOPENREQ_EVENT *dsetopenreq; - - if (len < sizeof(WMIX_DSETOPENREQ_EVENT)) { - return A_EINVAL; - } - dsetopenreq = (WMIX_DSETOPENREQ_EVENT *)datap; - A_DPRINTF(DBG_WMI, - (DBGFMT "Enter - dset_id=0x%x\n", DBGARG, dsetopenreq->dset_id)); - A_WMI_DSET_OPEN_REQ(wmip->wmi_devt, - dsetopenreq->dset_id, - dsetopenreq->targ_dset_handle, - dsetopenreq->targ_reply_fn, - dsetopenreq->targ_reply_arg); - - return 0; -} - -#ifdef CONFIG_HOST_DSET_SUPPORT -static int -wmi_dset_close_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMIX_DSETCLOSE_EVENT *dsetclose; - - if (len < sizeof(WMIX_DSETCLOSE_EVENT)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - dsetclose = (WMIX_DSETCLOSE_EVENT *)datap; - A_WMI_DSET_CLOSE(wmip->wmi_devt, dsetclose->access_cookie); - - return 0; -} - -static int -wmi_dset_data_req_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMIX_DSETDATAREQ_EVENT *dsetdatareq; - - if (len < sizeof(WMIX_DSETDATAREQ_EVENT)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - dsetdatareq = (WMIX_DSETDATAREQ_EVENT *)datap; - A_WMI_DSET_DATA_REQ(wmip->wmi_devt, - dsetdatareq->access_cookie, - dsetdatareq->offset, - dsetdatareq->length, - dsetdatareq->targ_buf, - dsetdatareq->targ_reply_fn, - dsetdatareq->targ_reply_arg); - - return 0; -} -#endif /* CONFIG_HOST_DSET_SUPPORT */ - -static int -wmi_scanComplete_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_SCAN_COMPLETE_EVENT *ev; - - ev = (WMI_SCAN_COMPLETE_EVENT *)datap; - if ((int)ev->status == 0) { - wlan_refresh_inactive_nodes(&wmip->wmi_scan_table); - } - A_WMI_SCANCOMPLETE_EVENT(wmip->wmi_devt, (int) ev->status); - is_probe_ssid = false; - - return 0; -} - -/* - * Target is reporting a programming error. This is for - * developer aid only. Target only checks a few common violations - * and it is responsibility of host to do all error checking. - * Behavior of target after wmi error event is undefined. - * A reset is recommended. - */ -static int -wmi_errorEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_CMD_ERROR_EVENT *ev; - - ev = (WMI_CMD_ERROR_EVENT *)datap; - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Programming Error: cmd=%d ", ev->commandId)); - switch (ev->errorCode) { - case (INVALID_PARAM): - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Illegal Parameter\n")); - break; - case (ILLEGAL_STATE): - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Illegal State\n")); - break; - case (INTERNAL_ERROR): - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Internal Error\n")); - break; - } - - return 0; -} - - -static int -wmi_statsEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_TARGETSTATS_EVENT(wmip->wmi_devt, datap, len); - - return 0; -} - -static int -wmi_rssiThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_RSSI_THRESHOLD_EVENT *reply; - WMI_RSSI_THRESHOLD_VAL newThreshold; - WMI_RSSI_THRESHOLD_PARAMS_CMD cmd; - SQ_THRESHOLD_PARAMS *sq_thresh = - &wmip->wmi_SqThresholdParams[SIGNAL_QUALITY_METRICS_RSSI]; - u8 upper_rssi_threshold, lower_rssi_threshold; - s16 rssi; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_RSSI_THRESHOLD_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - newThreshold = (WMI_RSSI_THRESHOLD_VAL) reply->range; - rssi = reply->rssi; - - /* - * Identify the threshold breached and communicate that to the app. After - * that install a new set of thresholds based on the signal quality - * reported by the target - */ - if (newThreshold) { - /* Upper threshold breached */ - if (rssi < sq_thresh->upper_threshold[0]) { - A_DPRINTF(DBG_WMI, (DBGFMT "Spurious upper RSSI threshold event: " - " %d\n", DBGARG, rssi)); - } else if ((rssi < sq_thresh->upper_threshold[1]) && - (rssi >= sq_thresh->upper_threshold[0])) - { - newThreshold = WMI_RSSI_THRESHOLD1_ABOVE; - } else if ((rssi < sq_thresh->upper_threshold[2]) && - (rssi >= sq_thresh->upper_threshold[1])) - { - newThreshold = WMI_RSSI_THRESHOLD2_ABOVE; - } else if ((rssi < sq_thresh->upper_threshold[3]) && - (rssi >= sq_thresh->upper_threshold[2])) - { - newThreshold = WMI_RSSI_THRESHOLD3_ABOVE; - } else if ((rssi < sq_thresh->upper_threshold[4]) && - (rssi >= sq_thresh->upper_threshold[3])) - { - newThreshold = WMI_RSSI_THRESHOLD4_ABOVE; - } else if ((rssi < sq_thresh->upper_threshold[5]) && - (rssi >= sq_thresh->upper_threshold[4])) - { - newThreshold = WMI_RSSI_THRESHOLD5_ABOVE; - } else if (rssi >= sq_thresh->upper_threshold[5]) { - newThreshold = WMI_RSSI_THRESHOLD6_ABOVE; - } - } else { - /* Lower threshold breached */ - if (rssi > sq_thresh->lower_threshold[0]) { - A_DPRINTF(DBG_WMI, (DBGFMT "Spurious lower RSSI threshold event: " - "%d %d\n", DBGARG, rssi, sq_thresh->lower_threshold[0])); - } else if ((rssi > sq_thresh->lower_threshold[1]) && - (rssi <= sq_thresh->lower_threshold[0])) - { - newThreshold = WMI_RSSI_THRESHOLD6_BELOW; - } else if ((rssi > sq_thresh->lower_threshold[2]) && - (rssi <= sq_thresh->lower_threshold[1])) - { - newThreshold = WMI_RSSI_THRESHOLD5_BELOW; - } else if ((rssi > sq_thresh->lower_threshold[3]) && - (rssi <= sq_thresh->lower_threshold[2])) - { - newThreshold = WMI_RSSI_THRESHOLD4_BELOW; - } else if ((rssi > sq_thresh->lower_threshold[4]) && - (rssi <= sq_thresh->lower_threshold[3])) - { - newThreshold = WMI_RSSI_THRESHOLD3_BELOW; - } else if ((rssi > sq_thresh->lower_threshold[5]) && - (rssi <= sq_thresh->lower_threshold[4])) - { - newThreshold = WMI_RSSI_THRESHOLD2_BELOW; - } else if (rssi <= sq_thresh->lower_threshold[5]) { - newThreshold = WMI_RSSI_THRESHOLD1_BELOW; - } - } - /* Calculate and install the next set of thresholds */ - lower_rssi_threshold = ar6000_get_lower_threshold(rssi, sq_thresh, - sq_thresh->lower_threshold_valid_count); - upper_rssi_threshold = ar6000_get_upper_threshold(rssi, sq_thresh, - sq_thresh->upper_threshold_valid_count); - /* Issue a wmi command to install the thresholds */ - cmd.thresholdAbove1_Val = upper_rssi_threshold; - cmd.thresholdBelow1_Val = lower_rssi_threshold; - cmd.weight = sq_thresh->weight; - cmd.pollTime = sq_thresh->polling_interval; - - rssi_event_value = rssi; - - if (wmi_send_rssi_threshold_params(wmip, &cmd) != 0) { - A_DPRINTF(DBG_WMI, (DBGFMT "Unable to configure the RSSI thresholds\n", - DBGARG)); - } - - A_WMI_RSSI_THRESHOLD_EVENT(wmip->wmi_devt, newThreshold, reply->rssi); - - return 0; -} - - -static int -wmi_reportErrorEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_TARGET_ERROR_REPORT_EVENT *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_TARGET_ERROR_REPORT_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_REPORT_ERROR_EVENT(wmip->wmi_devt, (WMI_TARGET_ERROR_VAL) reply->errorVal); - - return 0; -} - -static int -wmi_cac_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_CAC_EVENT *reply; - WMM_TSPEC_IE *tspec_ie; - u16 activeTsids; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_CAC_EVENT *)datap; - - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && - (reply->statusCode != TSPEC_STATUS_CODE_ADMISSION_ACCEPTED)) { - tspec_ie = (WMM_TSPEC_IE *) &(reply->tspecSuggestion); - - wmi_delete_pstream_cmd(wmip, reply->ac, - (tspec_ie->tsInfo_info >> TSPEC_TSID_S) & TSPEC_TSID_MASK); - } - else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { - u8 i; - - /* following assumes that there is only one outstanding ADDTS request - when this event is received */ - LOCK_WMI(wmip); - activeTsids = wmip->wmi_streamExistsForAC[reply->ac]; - UNLOCK_WMI(wmip); - - for (i = 0; i < sizeof(activeTsids) * 8; i++) { - if ((activeTsids >> i) & 1) { - break; - } - } - if (i < (sizeof(activeTsids) * 8)) { - wmi_delete_pstream_cmd(wmip, reply->ac, i); - } - } - /* - * Ev#72990: Clear active tsids and Add missing handling - * for delete qos stream from AP - */ - else if (reply->cac_indication == CAC_INDICATION_DELETE) { - u8 tsid = 0; - - tspec_ie = (WMM_TSPEC_IE *) &(reply->tspecSuggestion); - tsid= ((tspec_ie->tsInfo_info >> TSPEC_TSID_S) & TSPEC_TSID_MASK); - LOCK_WMI(wmip); - wmip->wmi_streamExistsForAC[reply->ac] &= ~(1<wmi_streamExistsForAC[reply->ac]; - UNLOCK_WMI(wmip); - - - /* Indicate stream inactivity to driver layer only if all tsids - * within this AC are deleted. - */ - if (!activeTsids) { - A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, reply->ac); - wmip->wmi_fatPipeExists &= ~(1 << reply->ac); - } - } - - A_WMI_CAC_EVENT(wmip->wmi_devt, reply->ac, - reply->cac_indication, reply->statusCode, - reply->tspecSuggestion); - - return 0; -} - -static int -wmi_channel_change_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_CHANNEL_CHANGE_EVENT *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_CHANNEL_CHANGE_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_CHANNEL_CHANGE_EVENT(wmip->wmi_devt, reply->oldChannel, - reply->newChannel); - - return 0; -} - -static int -wmi_hbChallengeResp_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMIX_HB_CHALLENGE_RESP_EVENT *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMIX_HB_CHALLENGE_RESP_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "wmi: challenge response event\n", DBGARG)); - - A_WMI_HBCHALLENGERESP_EVENT(wmip->wmi_devt, reply->cookie, reply->source); - - return 0; -} - -static int -wmi_roam_tbl_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_TARGET_ROAM_TBL *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_TARGET_ROAM_TBL *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_ROAM_TABLE_EVENT(wmip->wmi_devt, reply); - - return 0; -} - -static int -wmi_roam_data_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_TARGET_ROAM_DATA *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_TARGET_ROAM_DATA *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_ROAM_DATA_EVENT(wmip->wmi_devt, reply); - - return 0; -} - -static int -wmi_txRetryErrEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - if (len < sizeof(WMI_TX_RETRY_ERR_EVENT)) { - return A_EINVAL; - } - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_TX_RETRY_ERR_EVENT(wmip->wmi_devt); - - return 0; -} - -static int -wmi_snrThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_SNR_THRESHOLD_EVENT *reply; - SQ_THRESHOLD_PARAMS *sq_thresh = - &wmip->wmi_SqThresholdParams[SIGNAL_QUALITY_METRICS_SNR]; - WMI_SNR_THRESHOLD_VAL newThreshold; - WMI_SNR_THRESHOLD_PARAMS_CMD cmd; - u8 upper_snr_threshold, lower_snr_threshold; - s16 snr; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_SNR_THRESHOLD_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - newThreshold = (WMI_SNR_THRESHOLD_VAL) reply->range; - snr = reply->snr; - /* - * Identify the threshold breached and communicate that to the app. After - * that install a new set of thresholds based on the signal quality - * reported by the target - */ - if (newThreshold) { - /* Upper threshold breached */ - if (snr < sq_thresh->upper_threshold[0]) { - A_DPRINTF(DBG_WMI, (DBGFMT "Spurious upper SNR threshold event: " - "%d\n", DBGARG, snr)); - } else if ((snr < sq_thresh->upper_threshold[1]) && - (snr >= sq_thresh->upper_threshold[0])) - { - newThreshold = WMI_SNR_THRESHOLD1_ABOVE; - } else if ((snr < sq_thresh->upper_threshold[2]) && - (snr >= sq_thresh->upper_threshold[1])) - { - newThreshold = WMI_SNR_THRESHOLD2_ABOVE; - } else if ((snr < sq_thresh->upper_threshold[3]) && - (snr >= sq_thresh->upper_threshold[2])) - { - newThreshold = WMI_SNR_THRESHOLD3_ABOVE; - } else if (snr >= sq_thresh->upper_threshold[3]) { - newThreshold = WMI_SNR_THRESHOLD4_ABOVE; - } - } else { - /* Lower threshold breached */ - if (snr > sq_thresh->lower_threshold[0]) { - A_DPRINTF(DBG_WMI, (DBGFMT "Spurious lower SNR threshold event: " - "%d %d\n", DBGARG, snr, sq_thresh->lower_threshold[0])); - } else if ((snr > sq_thresh->lower_threshold[1]) && - (snr <= sq_thresh->lower_threshold[0])) - { - newThreshold = WMI_SNR_THRESHOLD4_BELOW; - } else if ((snr > sq_thresh->lower_threshold[2]) && - (snr <= sq_thresh->lower_threshold[1])) - { - newThreshold = WMI_SNR_THRESHOLD3_BELOW; - } else if ((snr > sq_thresh->lower_threshold[3]) && - (snr <= sq_thresh->lower_threshold[2])) - { - newThreshold = WMI_SNR_THRESHOLD2_BELOW; - } else if (snr <= sq_thresh->lower_threshold[3]) { - newThreshold = WMI_SNR_THRESHOLD1_BELOW; - } - } - - /* Calculate and install the next set of thresholds */ - lower_snr_threshold = ar6000_get_lower_threshold(snr, sq_thresh, - sq_thresh->lower_threshold_valid_count); - upper_snr_threshold = ar6000_get_upper_threshold(snr, sq_thresh, - sq_thresh->upper_threshold_valid_count); - - /* Issue a wmi command to install the thresholds */ - cmd.thresholdAbove1_Val = upper_snr_threshold; - cmd.thresholdBelow1_Val = lower_snr_threshold; - cmd.weight = sq_thresh->weight; - cmd.pollTime = sq_thresh->polling_interval; - - A_DPRINTF(DBG_WMI, (DBGFMT "snr: %d, threshold: %d, lower: %d, upper: %d\n" - ,DBGARG, snr, newThreshold, lower_snr_threshold, - upper_snr_threshold)); - - snr_event_value = snr; - - if (wmi_send_snr_threshold_params(wmip, &cmd) != 0) { - A_DPRINTF(DBG_WMI, (DBGFMT "Unable to configure the SNR thresholds\n", - DBGARG)); - } - A_WMI_SNR_THRESHOLD_EVENT_RX(wmip->wmi_devt, newThreshold, reply->snr); - - return 0; -} - -static int -wmi_lqThresholdEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_LQ_THRESHOLD_EVENT *reply; - - if (len < sizeof(*reply)) { - return A_EINVAL; - } - reply = (WMI_LQ_THRESHOLD_EVENT *)datap; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_LQ_THRESHOLD_EVENT_RX(wmip->wmi_devt, - (WMI_LQ_THRESHOLD_VAL) reply->range, - reply->lq); - - return 0; -} - -static int -wmi_aplistEvent_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - u16 ap_info_entry_size; - WMI_APLIST_EVENT *ev = (WMI_APLIST_EVENT *)datap; - WMI_AP_INFO_V1 *ap_info_v1; - u8 i; - - if (len < sizeof(WMI_APLIST_EVENT)) { - return A_EINVAL; - } - - if (ev->apListVer == APLIST_VER1) { - ap_info_entry_size = sizeof(WMI_AP_INFO_V1); - ap_info_v1 = (WMI_AP_INFO_V1 *)ev->apList; - } else { - return A_EINVAL; - } - - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Number of APs in APLIST Event is %d\n", ev->numAP)); - if (len < (int)(sizeof(WMI_APLIST_EVENT) + - (ev->numAP - 1) * ap_info_entry_size)) - { - return A_EINVAL; - } - - /* - * AP List Ver1 Contents - */ - for (i = 0; i < ev->numAP; i++) { - AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("AP#%d BSSID %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x "\ - "Channel %d\n", i, - ap_info_v1->bssid[0], ap_info_v1->bssid[1], - ap_info_v1->bssid[2], ap_info_v1->bssid[3], - ap_info_v1->bssid[4], ap_info_v1->bssid[5], - ap_info_v1->channel)); - ap_info_v1++; - } - return 0; -} - -static int -wmi_dbglog_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - u32 dropped; - - dropped = *((u32 *)datap); - datap += sizeof(dropped); - len -= sizeof(dropped); - A_WMI_DBGLOG_EVENT(wmip->wmi_devt, dropped, (s8 *)datap, len); - return 0; -} - -/* - * Called to send a wmi command. Command specific data is already built - * on osbuf and current osbuf->data points to it. - */ -int -wmi_cmd_send(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId, - WMI_SYNC_FLAG syncflag) -{ - int status; -#define IS_OPT_TX_CMD(cmdId) ((cmdId == WMI_OPT_TX_FRAME_CMDID)) - WMI_CMD_HDR *cHdr; - HTC_ENDPOINT_ID eid = wmip->wmi_endpoint_id; - - A_ASSERT(osbuf != NULL); - - if (syncflag >= END_WMIFLAG) { - A_NETBUF_FREE(osbuf); - return A_EINVAL; - } - - if ((syncflag == SYNC_BEFORE_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) { - /* - * We want to make sure all data currently queued is transmitted before - * the cmd execution. Establish a new sync point. - */ - wmi_sync_point(wmip); - } - - if (A_NETBUF_PUSH(osbuf, sizeof(WMI_CMD_HDR)) != 0) { - A_NETBUF_FREE(osbuf); - return A_NO_MEMORY; - } - - cHdr = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf); - cHdr->commandId = (u16) cmdId; - cHdr->info1 = 0; // added for virtual interface - - /* - * Only for OPT_TX_CMD, use BE endpoint. - */ - if (IS_OPT_TX_CMD(cmdId)) { - if ((status=wmi_data_hdr_add(wmip, osbuf, OPT_MSGTYPE, false, false,0,NULL)) != 0) { - A_NETBUF_FREE(osbuf); - return status; - } - eid = A_WMI_Ac2EndpointID(wmip->wmi_devt, WMM_AC_BE); - } - A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, eid); - - if ((syncflag == SYNC_AFTER_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) { - /* - * We want to make sure all new data queued waits for the command to - * execute. Establish a new sync point. - */ - wmi_sync_point(wmip); - } - return (0); -#undef IS_OPT_TX_CMD -} - -int -wmi_cmd_send_xtnd(struct wmi_t *wmip, void *osbuf, WMIX_COMMAND_ID cmdId, - WMI_SYNC_FLAG syncflag) -{ - WMIX_CMD_HDR *cHdr; - - if (A_NETBUF_PUSH(osbuf, sizeof(WMIX_CMD_HDR)) != 0) { - A_NETBUF_FREE(osbuf); - return A_NO_MEMORY; - } - - cHdr = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf); - cHdr->commandId = (u32) cmdId; - - return wmi_cmd_send(wmip, osbuf, WMI_EXTENSION_CMDID, syncflag); -} - -int -wmi_connect_cmd(struct wmi_t *wmip, NETWORK_TYPE netType, - DOT11_AUTH_MODE dot11AuthMode, AUTH_MODE authMode, - CRYPTO_TYPE pairwiseCrypto, u8 pairwiseCryptoLen, - CRYPTO_TYPE groupCrypto, u8 groupCryptoLen, - int ssidLength, u8 *ssid, - u8 *bssid, u16 channel, u32 ctrl_flags) -{ - void *osbuf; - WMI_CONNECT_CMD *cc; - wmip->wmi_traffic_class = 100; - - if ((pairwiseCrypto == NONE_CRYPT) && (groupCrypto != NONE_CRYPT)) { - return A_EINVAL; - } - if ((pairwiseCrypto != NONE_CRYPT) && (groupCrypto == NONE_CRYPT)) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_CONNECT_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_CONNECT_CMD)); - - cc = (WMI_CONNECT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cc, sizeof(*cc)); - - if (ssidLength) - { - memcpy(cc->ssid, ssid, ssidLength); - } - - cc->ssidLength = ssidLength; - cc->networkType = netType; - cc->dot11AuthMode = dot11AuthMode; - cc->authMode = authMode; - cc->pairwiseCryptoType = pairwiseCrypto; - cc->pairwiseCryptoLen = pairwiseCryptoLen; - cc->groupCryptoType = groupCrypto; - cc->groupCryptoLen = groupCryptoLen; - cc->channel = channel; - cc->ctrl_flags = ctrl_flags; - - if (bssid != NULL) { - memcpy(cc->bssid, bssid, ATH_MAC_LEN); - } - - wmip->wmi_pair_crypto_type = pairwiseCrypto; - wmip->wmi_grp_crypto_type = groupCrypto; - - return (wmi_cmd_send(wmip, osbuf, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_reconnect_cmd(struct wmi_t *wmip, u8 *bssid, u16 channel) -{ - void *osbuf; - WMI_RECONNECT_CMD *cc; - wmip->wmi_traffic_class = 100; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_RECONNECT_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_RECONNECT_CMD)); - - cc = (WMI_RECONNECT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cc, sizeof(*cc)); - - cc->channel = channel; - - if (bssid != NULL) { - memcpy(cc->bssid, bssid, ATH_MAC_LEN); - } - - return (wmi_cmd_send(wmip, osbuf, WMI_RECONNECT_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_disconnect_cmd(struct wmi_t *wmip) -{ - int status; - wmip->wmi_traffic_class = 100; - - /* Bug fix for 24817(elevator bug) - the disconnect command does not - need to do a SYNC before.*/ - status = wmi_simple_cmd(wmip, WMI_DISCONNECT_CMDID); - - return status; -} - -int -wmi_startscan_cmd(struct wmi_t *wmip, WMI_SCAN_TYPE scanType, - u32 forceFgScan, u32 isLegacy, - u32 homeDwellTime, u32 forceScanInterval, - s8 numChan, u16 *channelList) -{ - void *osbuf; - WMI_START_SCAN_CMD *sc; - s8 size; - - size = sizeof (*sc); - - if ((scanType != WMI_LONG_SCAN) && (scanType != WMI_SHORT_SCAN)) { - return A_EINVAL; - } - - if (numChan) { - if (numChan > WMI_MAX_CHANNELS) { - return A_EINVAL; - } - size += sizeof(u16) * (numChan - 1); - } - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - sc = (WMI_START_SCAN_CMD *)(A_NETBUF_DATA(osbuf)); - sc->scanType = scanType; - sc->forceFgScan = forceFgScan; - sc->isLegacy = isLegacy; - sc->homeDwellTime = homeDwellTime; - sc->forceScanInterval = forceScanInterval; - sc->numChannels = numChan; - if (numChan) { - memcpy(sc->channelList, channelList, numChan * sizeof(u16)); - } - - return (wmi_cmd_send(wmip, osbuf, WMI_START_SCAN_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_scanparams_cmd(struct wmi_t *wmip, u16 fg_start_sec, - u16 fg_end_sec, u16 bg_sec, - u16 minact_chdw_msec, u16 maxact_chdw_msec, - u16 pas_chdw_msec, - u8 shScanRatio, u8 scanCtrlFlags, - u32 max_dfsch_act_time, u16 maxact_scan_per_ssid) -{ - void *osbuf; - WMI_SCAN_PARAMS_CMD *sc; - - osbuf = A_NETBUF_ALLOC(sizeof(*sc)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*sc)); - - sc = (WMI_SCAN_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(sc, sizeof(*sc)); - sc->fg_start_period = fg_start_sec; - sc->fg_end_period = fg_end_sec; - sc->bg_period = bg_sec; - sc->minact_chdwell_time = minact_chdw_msec; - sc->maxact_chdwell_time = maxact_chdw_msec; - sc->pas_chdwell_time = pas_chdw_msec; - sc->shortScanRatio = shScanRatio; - sc->scanCtrlFlags = scanCtrlFlags; - sc->max_dfsch_act_time = max_dfsch_act_time; - sc->maxact_scan_per_ssid = maxact_scan_per_ssid; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_SCAN_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_bssfilter_cmd(struct wmi_t *wmip, u8 filter, u32 ieMask) -{ - void *osbuf; - WMI_BSS_FILTER_CMD *cmd; - - if (filter >= LAST_BSS_FILTER) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_BSS_FILTER_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->bssFilter = filter; - cmd->ieMask = ieMask; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BSS_FILTER_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_probedSsid_cmd(struct wmi_t *wmip, u8 index, u8 flag, - u8 ssidLength, u8 *ssid) -{ - void *osbuf; - WMI_PROBED_SSID_CMD *cmd; - - if (index > MAX_PROBED_SSID_INDEX) { - return A_EINVAL; - } - if (ssidLength > sizeof(cmd->ssid)) { - return A_EINVAL; - } - if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssidLength > 0)) { - return A_EINVAL; - } - if ((flag & SPECIFIC_SSID_FLAG) && !ssidLength) { - return A_EINVAL; - } - - if (flag & SPECIFIC_SSID_FLAG) { - is_probe_ssid = true; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_PROBED_SSID_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->entryIndex = index; - cmd->flag = flag; - cmd->ssidLength = ssidLength; - memcpy(cmd->ssid, ssid, ssidLength); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_PROBED_SSID_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_listeninterval_cmd(struct wmi_t *wmip, u16 listenInterval, u16 listenBeacons) -{ - void *osbuf; - WMI_LISTEN_INT_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_LISTEN_INT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->listenInterval = listenInterval; - cmd->numBeacons = listenBeacons; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_LISTEN_INT_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_bmisstime_cmd(struct wmi_t *wmip, u16 bmissTime, u16 bmissBeacons) -{ - void *osbuf; - WMI_BMISS_TIME_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_BMISS_TIME_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->bmissTime = bmissTime; - cmd->numBeacons = bmissBeacons; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BMISS_TIME_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_associnfo_cmd(struct wmi_t *wmip, u8 ieType, - u8 ieLen, u8 *ieInfo) -{ - void *osbuf; - WMI_SET_ASSOC_INFO_CMD *cmd; - u16 cmdLen; - - cmdLen = sizeof(*cmd) + ieLen - 1; - osbuf = A_NETBUF_ALLOC(cmdLen); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, cmdLen); - - cmd = (WMI_SET_ASSOC_INFO_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, cmdLen); - cmd->ieType = ieType; - cmd->bufferSize = ieLen; - memcpy(cmd->assocInfo, ieInfo, ieLen); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_ASSOC_INFO_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_powermode_cmd(struct wmi_t *wmip, u8 powerMode) -{ - void *osbuf; - WMI_POWER_MODE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_POWER_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->powerMode = powerMode; - wmip->wmi_powerMode = powerMode; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_MODE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_ibsspmcaps_cmd(struct wmi_t *wmip, u8 pmEnable, u8 ttl, - u16 atim_windows, u16 timeout_value) -{ - void *osbuf; - WMI_IBSS_PM_CAPS_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_IBSS_PM_CAPS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->power_saving = pmEnable; - cmd->ttl = ttl; - cmd->atim_windows = atim_windows; - cmd->timeout_value = timeout_value; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_IBSS_PM_CAPS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_apps_cmd(struct wmi_t *wmip, u8 psType, u32 idle_time, - u32 ps_period, u8 sleep_period) -{ - void *osbuf; - WMI_AP_PS_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_AP_PS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->psType = psType; - cmd->idle_time = idle_time; - cmd->ps_period = ps_period; - cmd->sleep_period = sleep_period; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_AP_PS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_pmparams_cmd(struct wmi_t *wmip, u16 idlePeriod, - u16 psPollNum, u16 dtimPolicy, - u16 tx_wakeup_policy, u16 num_tx_to_wakeup, - u16 ps_fail_event_policy) -{ - void *osbuf; - WMI_POWER_PARAMS_CMD *pm; - - osbuf = A_NETBUF_ALLOC(sizeof(*pm)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*pm)); - - pm = (WMI_POWER_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(pm, sizeof(*pm)); - pm->idle_period = idlePeriod; - pm->pspoll_number = psPollNum; - pm->dtim_policy = dtimPolicy; - pm->tx_wakeup_policy = tx_wakeup_policy; - pm->num_tx_to_wakeup = num_tx_to_wakeup; - pm->ps_fail_event_policy = ps_fail_event_policy; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_disctimeout_cmd(struct wmi_t *wmip, u8 timeout) -{ - void *osbuf; - WMI_DISC_TIMEOUT_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_DISC_TIMEOUT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->disconnectTimeout = timeout; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_DISC_TIMEOUT_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_addKey_cmd(struct wmi_t *wmip, u8 keyIndex, CRYPTO_TYPE keyType, - u8 keyUsage, u8 keyLength, u8 *keyRSC, - u8 *keyMaterial, u8 key_op_ctrl, u8 *macAddr, - WMI_SYNC_FLAG sync_flag) -{ - void *osbuf; - WMI_ADD_CIPHER_KEY_CMD *cmd; - - if ((keyIndex > WMI_MAX_KEY_INDEX) || (keyLength > WMI_MAX_KEY_LEN) || - (keyMaterial == NULL)) - { - return A_EINVAL; - } - - if ((WEP_CRYPT != keyType) && (NULL == keyRSC)) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_ADD_CIPHER_KEY_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->keyIndex = keyIndex; - cmd->keyType = keyType; - cmd->keyUsage = keyUsage; - cmd->keyLength = keyLength; - memcpy(cmd->key, keyMaterial, keyLength); -#ifdef WAPI_ENABLE - if (NULL != keyRSC && key_op_ctrl != KEY_OP_INIT_WAPIPN) { -#else - if (NULL != keyRSC) { -#endif // WAPI_ENABLE - memcpy(cmd->keyRSC, keyRSC, sizeof(cmd->keyRSC)); - } - cmd->key_op_ctrl = key_op_ctrl; - - if(macAddr) { - memcpy(cmd->key_macaddr,macAddr,IEEE80211_ADDR_LEN); - } - - return (wmi_cmd_send(wmip, osbuf, WMI_ADD_CIPHER_KEY_CMDID, sync_flag)); -} - -int -wmi_add_krk_cmd(struct wmi_t *wmip, u8 *krk) -{ - void *osbuf; - WMI_ADD_KRK_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_ADD_KRK_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - memcpy(cmd->krk, krk, WMI_KRK_LEN); - - return (wmi_cmd_send(wmip, osbuf, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_delete_krk_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_DELETE_KRK_CMDID); -} - -int -wmi_deleteKey_cmd(struct wmi_t *wmip, u8 keyIndex) -{ - void *osbuf; - WMI_DELETE_CIPHER_KEY_CMD *cmd; - - if (keyIndex > WMI_MAX_KEY_INDEX) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_DELETE_CIPHER_KEY_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->keyIndex = keyIndex; - - return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_CIPHER_KEY_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_setPmkid_cmd(struct wmi_t *wmip, u8 *bssid, u8 *pmkId, - bool set) -{ - void *osbuf; - WMI_SET_PMKID_CMD *cmd; - - if (bssid == NULL) { - return A_EINVAL; - } - - if ((set == true) && (pmkId == NULL)) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_PMKID_CMD *)(A_NETBUF_DATA(osbuf)); - memcpy(cmd->bssid, bssid, sizeof(cmd->bssid)); - if (set == true) { - memcpy(cmd->pmkid, pmkId, sizeof(cmd->pmkid)); - cmd->enable = PMKID_ENABLE; - } else { - A_MEMZERO(cmd->pmkid, sizeof(cmd->pmkid)); - cmd->enable = PMKID_DISABLE; - } - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_set_tkip_countermeasures_cmd(struct wmi_t *wmip, bool en) -{ - void *osbuf; - WMI_SET_TKIP_COUNTERMEASURES_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_TKIP_COUNTERMEASURES_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->cm_en = (en == true)? WMI_TKIP_CM_ENABLE : WMI_TKIP_CM_DISABLE; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_TKIP_COUNTERMEASURES_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_akmp_params_cmd(struct wmi_t *wmip, - WMI_SET_AKMP_PARAMS_CMD *akmpParams) -{ - void *osbuf; - WMI_SET_AKMP_PARAMS_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - cmd = (WMI_SET_AKMP_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->akmpInfo = akmpParams->akmpInfo; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_AKMP_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_pmkid_list_cmd(struct wmi_t *wmip, - WMI_SET_PMKID_LIST_CMD *pmkInfo) -{ - void *osbuf; - WMI_SET_PMKID_LIST_CMD *cmd; - u16 cmdLen; - u8 i; - - cmdLen = sizeof(pmkInfo->numPMKID) + - pmkInfo->numPMKID * sizeof(WMI_PMKID); - - osbuf = A_NETBUF_ALLOC(cmdLen); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, cmdLen); - cmd = (WMI_SET_PMKID_LIST_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->numPMKID = pmkInfo->numPMKID; - - for (i = 0; i < cmd->numPMKID; i++) { - memcpy(&cmd->pmkidList[i], &pmkInfo->pmkidList[i], - WMI_PMKID_LEN); - } - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_LIST_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_get_pmkid_list_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_PMKID_LIST_CMDID); -} - -int -wmi_dataSync_send(struct wmi_t *wmip, void *osbuf, HTC_ENDPOINT_ID eid) -{ - WMI_DATA_HDR *dtHdr; - - A_ASSERT( eid != wmip->wmi_endpoint_id); - A_ASSERT(osbuf != NULL); - - if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != 0) { - return A_NO_MEMORY; - } - - dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf); - dtHdr->info = - (SYNC_MSGTYPE & WMI_DATA_HDR_MSG_TYPE_MASK) << WMI_DATA_HDR_MSG_TYPE_SHIFT; - - dtHdr->info3 = 0; - A_DPRINTF(DBG_WMI, (DBGFMT "Enter - eid %d\n", DBGARG, eid)); - - return (A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, eid)); -} - -typedef struct _WMI_DATA_SYNC_BUFS { - u8 trafficClass; - void *osbuf; -}WMI_DATA_SYNC_BUFS; - -static int -wmi_sync_point(struct wmi_t *wmip) -{ - void *cmd_osbuf; - WMI_SYNC_CMD *cmd; - WMI_DATA_SYNC_BUFS dataSyncBufs[WMM_NUM_AC]; - u8 i,numPriStreams=0; - int status = 0; - - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - memset(dataSyncBufs,0,sizeof(dataSyncBufs)); - - /* lock out while we walk through the priority list and assemble our local array */ - LOCK_WMI(wmip); - - for (i=0; i < WMM_NUM_AC ; i++) { - if (wmip->wmi_fatPipeExists & (1 << i)) { - numPriStreams++; - dataSyncBufs[numPriStreams-1].trafficClass = i; - } - } - - UNLOCK_WMI(wmip); - - /* dataSyncBufs is now filled with entries (starting at index 0) containing valid streamIDs */ - - do { - /* - * We allocate all network buffers needed so we will be able to - * send all required frames. - */ - cmd_osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (cmd_osbuf == NULL) { - status = A_NO_MEMORY; - break; - } - - A_NETBUF_PUT(cmd_osbuf, sizeof(*cmd)); - - cmd = (WMI_SYNC_CMD *)(A_NETBUF_DATA(cmd_osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - /* In the SYNC cmd sent on the control Ep, send a bitmap of the data - * eps on which the Data Sync will be sent - */ - cmd->dataSyncMap = wmip->wmi_fatPipeExists; - - for (i=0; i < numPriStreams ; i++) { - dataSyncBufs[i].osbuf = A_NETBUF_ALLOC(0); - if (dataSyncBufs[i].osbuf == NULL) { - status = A_NO_MEMORY; - break; - } - } //end for - - /* if Buffer allocation for any of the dataSync fails, then do not - * send the Synchronize cmd on the control ep - */ - if (status) { - break; - } - - /* - * Send sync cmd followed by sync data messages on all endpoints being - * used - */ - status = wmi_cmd_send(wmip, cmd_osbuf, WMI_SYNCHRONIZE_CMDID, - NO_SYNC_WMIFLAG); - - if (status) { - break; - } - /* cmd buffer sent, we no longer own it */ - cmd_osbuf = NULL; - - for(i=0; i < numPriStreams; i++) { - A_ASSERT(dataSyncBufs[i].osbuf != NULL); - status = wmi_dataSync_send(wmip, - dataSyncBufs[i].osbuf, - A_WMI_Ac2EndpointID(wmip->wmi_devt, - dataSyncBufs[i]. - trafficClass) - ); - - if (status) { - break; - } - /* we don't own this buffer anymore, NULL it out of the array so it - * won't get cleaned up */ - dataSyncBufs[i].osbuf = NULL; - } //end for - - } while(false); - - /* free up any resources left over (possibly due to an error) */ - - if (cmd_osbuf != NULL) { - A_NETBUF_FREE(cmd_osbuf); - } - - for (i = 0; i < numPriStreams; i++) { - if (dataSyncBufs[i].osbuf != NULL) { - A_NETBUF_FREE(dataSyncBufs[i].osbuf); - } - } - - return (status); -} - -int -wmi_create_pstream_cmd(struct wmi_t *wmip, WMI_CREATE_PSTREAM_CMD *params) -{ - void *osbuf; - WMI_CREATE_PSTREAM_CMD *cmd; - u8 fatPipeExistsForAC=0; - s32 minimalPHY = 0; - s32 nominalPHY = 0; - - /* Validate all the parameters. */ - if( !((params->userPriority < 8) && - (params->userPriority <= 0x7) && - (convert_userPriority_to_trafficClass(params->userPriority) == params->trafficClass) && - (params->trafficDirection == UPLINK_TRAFFIC || - params->trafficDirection == DNLINK_TRAFFIC || - params->trafficDirection == BIDIR_TRAFFIC) && - (params->trafficType == TRAFFIC_TYPE_APERIODIC || - params->trafficType == TRAFFIC_TYPE_PERIODIC ) && - (params->voicePSCapability == DISABLE_FOR_THIS_AC || - params->voicePSCapability == ENABLE_FOR_THIS_AC || - params->voicePSCapability == ENABLE_FOR_ALL_AC) && - (params->tsid == WMI_IMPLICIT_PSTREAM || params->tsid <= WMI_MAX_THINSTREAM)) ) - { - return A_EINVAL; - } - - // - // check nominal PHY rate is >= minimalPHY, so that DUT - // can allow TSRS IE - // - - // get the physical rate - minimalPHY = ((params->minPhyRate / 1000)/1000); // unit of bps - - // check minimal phy < nominal phy rate - // - if (params->nominalPHY >= minimalPHY) - { - nominalPHY = (params->nominalPHY * 1000)/500; // unit of 500 kbps - A_DPRINTF(DBG_WMI, - (DBGFMT "TSRS IE Enabled::MinPhy %x->NominalPhy ===> %x\n", DBGARG, - minimalPHY, nominalPHY)); - - params->nominalPHY = nominalPHY; - } - else - { - params->nominalPHY = 0; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - A_DPRINTF(DBG_WMI, - (DBGFMT "Sending create_pstream_cmd: ac=%d tsid:%d\n", DBGARG, - params->trafficClass, params->tsid)); - - cmd = (WMI_CREATE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - memcpy(cmd, params, sizeof(*cmd)); - - /* this is an implicitly created Fat pipe */ - if ((u32)params->tsid == (u32)WMI_IMPLICIT_PSTREAM) { - LOCK_WMI(wmip); - fatPipeExistsForAC = (wmip->wmi_fatPipeExists & (1 << params->trafficClass)); - wmip->wmi_fatPipeExists |= (1<trafficClass); - UNLOCK_WMI(wmip); - } else { - /* this is an explicitly created thin stream within a fat pipe */ - LOCK_WMI(wmip); - fatPipeExistsForAC = (wmip->wmi_fatPipeExists & (1 << params->trafficClass)); - wmip->wmi_streamExistsForAC[params->trafficClass] |= (1<tsid); - /* if a thinstream becomes active, the fat pipe automatically - * becomes active - */ - wmip->wmi_fatPipeExists |= (1<trafficClass); - UNLOCK_WMI(wmip); - } - - /* Indicate activty change to driver layer only if this is the - * first TSID to get created in this AC explicitly or an implicit - * fat pipe is getting created. - */ - if (!fatPipeExistsForAC) { - A_WMI_STREAM_TX_ACTIVE(wmip->wmi_devt, params->trafficClass); - } - - /* mike: should be SYNC_BEFORE_WMIFLAG */ - return (wmi_cmd_send(wmip, osbuf, WMI_CREATE_PSTREAM_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_delete_pstream_cmd(struct wmi_t *wmip, u8 trafficClass, u8 tsid) -{ - void *osbuf; - WMI_DELETE_PSTREAM_CMD *cmd; - int status; - u16 activeTsids=0; - - /* validate the parameters */ - if (trafficClass > 3) { - A_DPRINTF(DBG_WMI, (DBGFMT "Invalid trafficClass: %d\n", DBGARG, trafficClass)); - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_DELETE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->trafficClass = trafficClass; - cmd->tsid = tsid; - - LOCK_WMI(wmip); - activeTsids = wmip->wmi_streamExistsForAC[trafficClass]; - UNLOCK_WMI(wmip); - - /* Check if the tsid was created & exists */ - if (!(activeTsids & (1<wmi_streamExistsForAC[trafficClass] &= ~(1<wmi_streamExistsForAC[trafficClass]; - UNLOCK_WMI(wmip); - - - /* Indicate stream inactivity to driver layer only if all tsids - * within this AC are deleted. - */ - if(!activeTsids) { - A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, trafficClass); - wmip->wmi_fatPipeExists &= ~(1< 15)){ - - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_FRAME_RATES_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - frameType = (u8)((subType << 4) | type); - - cmd->bEnableMask = bEnable; - cmd->frameType = frameType; - cmd->frameRateMask = rateMask; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_FRAMERATES_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * used to set the bit rate. rate is in Kbps. If rate == -1 - * then auto selection is used. - */ -int -wmi_set_bitrate_cmd(struct wmi_t *wmip, s32 dataRate, s32 mgmtRate, s32 ctlRate) -{ - void *osbuf; - WMI_BIT_RATE_CMD *cmd; - s8 drix, mrix, crix, ret_val; - - if (dataRate != -1) { - ret_val = wmi_validate_bitrate(wmip, dataRate, &drix); - if(ret_val == A_EINVAL){ - return A_EINVAL; - } - } else { - drix = -1; - } - - if (mgmtRate != -1) { - ret_val = wmi_validate_bitrate(wmip, mgmtRate, &mrix); - if(ret_val == A_EINVAL){ - return A_EINVAL; - } - } else { - mrix = -1; - } - if (ctlRate != -1) { - ret_val = wmi_validate_bitrate(wmip, ctlRate, &crix); - if(ret_val == A_EINVAL){ - return A_EINVAL; - } - } else { - crix = -1; - } - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_BIT_RATE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->rateIndex = drix; - cmd->mgmtRateIndex = mrix; - cmd->ctlRateIndex = crix; - - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BITRATE_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_get_bitrate_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_BITRATE_CMDID); -} - -/* - * Returns true iff the given rate index is legal in the current PHY mode. - */ -bool -wmi_is_bitrate_index_valid(struct wmi_t *wmip, s32 rateIndex) -{ - WMI_PHY_MODE phyMode = (WMI_PHY_MODE) wmip->wmi_phyMode; - bool isValid = true; - switch(phyMode) { - case WMI_11A_MODE: - if (wmip->wmi_ht_allowed[A_BAND_5GHZ]){ - if ((rateIndex < MODE_A_SUPPORT_RATE_START) || (rateIndex > MODE_GHT20_SUPPORT_RATE_STOP)) { - isValid = false; - } - } else { - if ((rateIndex < MODE_A_SUPPORT_RATE_START) || (rateIndex > MODE_A_SUPPORT_RATE_STOP)) { - isValid = false; - } - } - break; - - case WMI_11B_MODE: - if ((rateIndex < MODE_B_SUPPORT_RATE_START) || (rateIndex > MODE_B_SUPPORT_RATE_STOP)) { - isValid = false; - } - break; - - case WMI_11GONLY_MODE: - if (wmip->wmi_ht_allowed[A_BAND_24GHZ]){ - if ((rateIndex < MODE_GONLY_SUPPORT_RATE_START) || (rateIndex > MODE_GHT20_SUPPORT_RATE_STOP)) { - isValid = false; - } - } else { - if ((rateIndex < MODE_GONLY_SUPPORT_RATE_START) || (rateIndex > MODE_GONLY_SUPPORT_RATE_STOP)) { - isValid = false; - } - } - break; - - case WMI_11G_MODE: - case WMI_11AG_MODE: - if (wmip->wmi_ht_allowed[A_BAND_24GHZ]){ - if ((rateIndex < MODE_G_SUPPORT_RATE_START) || (rateIndex > MODE_GHT20_SUPPORT_RATE_STOP)) { - isValid = false; - } - } else { - if ((rateIndex < MODE_G_SUPPORT_RATE_START) || (rateIndex > MODE_G_SUPPORT_RATE_STOP)) { - isValid = false; - } - } - break; - default: - A_ASSERT(false); - break; - } - - return isValid; -} - -s8 wmi_validate_bitrate(struct wmi_t *wmip, s32 rate, s8 *rate_idx) -{ - s8 i; - - for (i=0;;i++) - { - if (wmi_rateTable[(u32) i][0] == 0) { - return A_EINVAL; - } - if (wmi_rateTable[(u32) i][0] == rate) { - break; - } - } - - if(wmi_is_bitrate_index_valid(wmip, (s32) i) != true) { - return A_EINVAL; - } - - *rate_idx = i; - return 0; -} - -int -wmi_set_fixrates_cmd(struct wmi_t *wmip, u32 fixRatesMask) -{ - void *osbuf; - WMI_FIX_RATES_CMD *cmd; -#if 0 - s32 rateIndex; -/* This check does not work for AR6003 as the HT modes are enabled only when - * the STA is connected to a HT_BSS and is not based only on channel. It is - * safe to skip this check however because rate control will only use rates - * that are permitted by the valid rate mask and the fix rate mask. Meaning - * the fix rate mask is not sufficient by itself to cause an invalid rate - * to be used. */ - /* Make sure all rates in the mask are valid in the current PHY mode */ - for(rateIndex = 0; rateIndex < MAX_NUMBER_OF_SUPPORT_RATES; rateIndex++) { - if((1 << rateIndex) & (u32)fixRatesMask) { - if(wmi_is_bitrate_index_valid(wmip, rateIndex) != true) { - A_DPRINTF(DBG_WMI, (DBGFMT "Set Fix Rates command failed: Given rate is illegal in current PHY mode\n", DBGARG)); - return A_EINVAL; - } - } - } -#endif - - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_FIX_RATES_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->fixRateMask = fixRatesMask; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_FIXRATES_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_get_ratemask_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_FIXRATES_CMDID); -} - -int -wmi_get_channelList_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_CHANNEL_LIST_CMDID); -} - -/* - * used to generate a wmi sey channel Parameters cmd. - * mode should always be specified and corresponds to the phy mode of the - * wlan. - * numChan should alway sbe specified. If zero indicates that all available - * channels should be used. - * channelList is an array of channel frequencies (in Mhz) which the radio - * should limit its operation to. It should be NULL if numChan == 0. Size of - * array should correspond to numChan entries. - */ -int -wmi_set_channelParams_cmd(struct wmi_t *wmip, u8 scanParam, - WMI_PHY_MODE mode, s8 numChan, - u16 *channelList) -{ - void *osbuf; - WMI_CHANNEL_PARAMS_CMD *cmd; - s8 size; - - size = sizeof (*cmd); - - if (numChan) { - if (numChan > WMI_MAX_CHANNELS) { - return A_EINVAL; - } - size += sizeof(u16) * (numChan - 1); - } - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_CHANNEL_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - - wmip->wmi_phyMode = mode; - cmd->scanParam = scanParam; - cmd->phyMode = mode; - cmd->numChannels = numChan; - memcpy(cmd->channelList, channelList, numChan * sizeof(u16)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_CHANNEL_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -void -wmi_cache_configure_rssithreshold(struct wmi_t *wmip, WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd) -{ - SQ_THRESHOLD_PARAMS *sq_thresh = - &wmip->wmi_SqThresholdParams[SIGNAL_QUALITY_METRICS_RSSI]; - /* - * Parse the command and store the threshold values here. The checks - * for valid values can be put here - */ - sq_thresh->weight = rssiCmd->weight; - sq_thresh->polling_interval = rssiCmd->pollTime; - - sq_thresh->upper_threshold[0] = rssiCmd->thresholdAbove1_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold[1] = rssiCmd->thresholdAbove2_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold[2] = rssiCmd->thresholdAbove3_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold[3] = rssiCmd->thresholdAbove4_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold[4] = rssiCmd->thresholdAbove5_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold[5] = rssiCmd->thresholdAbove6_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->upper_threshold_valid_count = 6; - - /* List sorted in descending order */ - sq_thresh->lower_threshold[0] = rssiCmd->thresholdBelow6_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold[1] = rssiCmd->thresholdBelow5_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold[2] = rssiCmd->thresholdBelow4_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold[3] = rssiCmd->thresholdBelow3_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold[4] = rssiCmd->thresholdBelow2_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold[5] = rssiCmd->thresholdBelow1_Val - SIGNAL_QUALITY_NOISE_FLOOR; - sq_thresh->lower_threshold_valid_count = 6; - - if (!rssi_event_value) { - /* - * Configuring the thresholds to their extremes allows the host to get an - * event from the target which is used for the configuring the correct - * thresholds - */ - rssiCmd->thresholdAbove1_Val = sq_thresh->upper_threshold[0]; - rssiCmd->thresholdBelow1_Val = sq_thresh->lower_threshold[0]; - } else { - /* - * In case the user issues multiple times of rssi_threshold_setting, - * we should not use the extreames anymore, the target does not expect that. - */ - rssiCmd->thresholdAbove1_Val = ar6000_get_upper_threshold(rssi_event_value, sq_thresh, - sq_thresh->upper_threshold_valid_count); - rssiCmd->thresholdBelow1_Val = ar6000_get_lower_threshold(rssi_event_value, sq_thresh, - sq_thresh->lower_threshold_valid_count); -} -} - -int -wmi_set_rssi_threshold_params(struct wmi_t *wmip, - WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd) -{ - - /* Check these values are in ascending order */ - if( rssiCmd->thresholdAbove6_Val <= rssiCmd->thresholdAbove5_Val || - rssiCmd->thresholdAbove5_Val <= rssiCmd->thresholdAbove4_Val || - rssiCmd->thresholdAbove4_Val <= rssiCmd->thresholdAbove3_Val || - rssiCmd->thresholdAbove3_Val <= rssiCmd->thresholdAbove2_Val || - rssiCmd->thresholdAbove2_Val <= rssiCmd->thresholdAbove1_Val || - rssiCmd->thresholdBelow6_Val <= rssiCmd->thresholdBelow5_Val || - rssiCmd->thresholdBelow5_Val <= rssiCmd->thresholdBelow4_Val || - rssiCmd->thresholdBelow4_Val <= rssiCmd->thresholdBelow3_Val || - rssiCmd->thresholdBelow3_Val <= rssiCmd->thresholdBelow2_Val || - rssiCmd->thresholdBelow2_Val <= rssiCmd->thresholdBelow1_Val) - { - return A_EINVAL; - } - - wmi_cache_configure_rssithreshold(wmip, rssiCmd); - - return (wmi_send_rssi_threshold_params(wmip, rssiCmd)); -} - -int -wmi_set_ip_cmd(struct wmi_t *wmip, WMI_SET_IP_CMD *ipCmd) -{ - void *osbuf; - WMI_SET_IP_CMD *cmd; - - /* Multicast address are not valid */ - if((*((u8 *)&ipCmd->ips[0]) >= 0xE0) || - (*((u8 *)&ipCmd->ips[1]) >= 0xE0)) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_SET_IP_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_SET_IP_CMD)); - cmd = (WMI_SET_IP_CMD *)(A_NETBUF_DATA(osbuf)); - memcpy(cmd, ipCmd, sizeof(WMI_SET_IP_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_IP_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_host_sleep_mode_cmd(struct wmi_t *wmip, - WMI_SET_HOST_SLEEP_MODE_CMD *hostModeCmd) -{ - void *osbuf; - s8 size; - WMI_SET_HOST_SLEEP_MODE_CMD *cmd; - u16 activeTsids=0; - u8 streamExists=0; - u8 i; - - if( hostModeCmd->awake == hostModeCmd->asleep) { - return A_EINVAL; - } - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_SET_HOST_SLEEP_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, hostModeCmd, sizeof(WMI_SET_HOST_SLEEP_MODE_CMD)); - - if(hostModeCmd->asleep) { - /* - * Relinquish credits from all implicitly created pstreams since when we - * go to sleep. If user created explicit thinstreams exists with in a - * fatpipe leave them intact for the user to delete - */ - LOCK_WMI(wmip); - streamExists = wmip->wmi_fatPipeExists; - UNLOCK_WMI(wmip); - - for(i=0;i< WMM_NUM_AC;i++) { - if (streamExists & (1<wmi_streamExistsForAC[i]; - UNLOCK_WMI(wmip); - /* If there are no user created thin streams delete the fatpipe */ - if(!activeTsids) { - streamExists &= ~(1<wmi_devt,i); - } - } - } - - /* Update the fatpipes that exists*/ - LOCK_WMI(wmip); - wmip->wmi_fatPipeExists = streamExists; - UNLOCK_WMI(wmip); - } - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_HOST_SLEEP_MODE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_wow_mode_cmd(struct wmi_t *wmip, - WMI_SET_WOW_MODE_CMD *wowModeCmd) -{ - void *osbuf; - s8 size; - WMI_SET_WOW_MODE_CMD *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_SET_WOW_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, wowModeCmd, sizeof(WMI_SET_WOW_MODE_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_WOW_MODE_CMDID, - NO_SYNC_WMIFLAG)); - -} - -int -wmi_get_wow_list_cmd(struct wmi_t *wmip, - WMI_GET_WOW_LIST_CMD *wowListCmd) -{ - void *osbuf; - s8 size; - WMI_GET_WOW_LIST_CMD *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_GET_WOW_LIST_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, wowListCmd, sizeof(WMI_GET_WOW_LIST_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_GET_WOW_LIST_CMDID, - NO_SYNC_WMIFLAG)); - -} - -static int -wmi_get_wow_list_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_GET_WOW_LIST_REPLY *reply; - - if (len < sizeof(WMI_GET_WOW_LIST_REPLY)) { - return A_EINVAL; - } - reply = (WMI_GET_WOW_LIST_REPLY *)datap; - - A_WMI_WOW_LIST_EVENT(wmip->wmi_devt, reply->num_filters, - reply); - - return 0; -} - -int wmi_add_wow_pattern_cmd(struct wmi_t *wmip, - WMI_ADD_WOW_PATTERN_CMD *addWowCmd, - u8 *pattern, u8 *mask, - u8 pattern_size) -{ - void *osbuf; - s8 size; - WMI_ADD_WOW_PATTERN_CMD *cmd; - u8 *filter_mask = NULL; - - size = sizeof (*cmd); - - size += ((2 * addWowCmd->filter_size)* sizeof(u8)); - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_ADD_WOW_PATTERN_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->filter_list_id = addWowCmd->filter_list_id; - cmd->filter_offset = addWowCmd->filter_offset; - cmd->filter_size = addWowCmd->filter_size; - - memcpy(cmd->filter, pattern, addWowCmd->filter_size); - - filter_mask = (u8 *)(cmd->filter + cmd->filter_size); - memcpy(filter_mask, mask, addWowCmd->filter_size); - - - return (wmi_cmd_send(wmip, osbuf, WMI_ADD_WOW_PATTERN_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_del_wow_pattern_cmd(struct wmi_t *wmip, - WMI_DEL_WOW_PATTERN_CMD *delWowCmd) -{ - void *osbuf; - s8 size; - WMI_DEL_WOW_PATTERN_CMD *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_DEL_WOW_PATTERN_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, delWowCmd, sizeof(WMI_DEL_WOW_PATTERN_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_DEL_WOW_PATTERN_CMDID, - NO_SYNC_WMIFLAG)); - -} - -void -wmi_cache_configure_snrthreshold(struct wmi_t *wmip, WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd) -{ - SQ_THRESHOLD_PARAMS *sq_thresh = - &wmip->wmi_SqThresholdParams[SIGNAL_QUALITY_METRICS_SNR]; - /* - * Parse the command and store the threshold values here. The checks - * for valid values can be put here - */ - sq_thresh->weight = snrCmd->weight; - sq_thresh->polling_interval = snrCmd->pollTime; - - sq_thresh->upper_threshold[0] = snrCmd->thresholdAbove1_Val; - sq_thresh->upper_threshold[1] = snrCmd->thresholdAbove2_Val; - sq_thresh->upper_threshold[2] = snrCmd->thresholdAbove3_Val; - sq_thresh->upper_threshold[3] = snrCmd->thresholdAbove4_Val; - sq_thresh->upper_threshold_valid_count = 4; - - /* List sorted in descending order */ - sq_thresh->lower_threshold[0] = snrCmd->thresholdBelow4_Val; - sq_thresh->lower_threshold[1] = snrCmd->thresholdBelow3_Val; - sq_thresh->lower_threshold[2] = snrCmd->thresholdBelow2_Val; - sq_thresh->lower_threshold[3] = snrCmd->thresholdBelow1_Val; - sq_thresh->lower_threshold_valid_count = 4; - - if (!snr_event_value) { - /* - * Configuring the thresholds to their extremes allows the host to get an - * event from the target which is used for the configuring the correct - * thresholds - */ - snrCmd->thresholdAbove1_Val = (u8)sq_thresh->upper_threshold[0]; - snrCmd->thresholdBelow1_Val = (u8)sq_thresh->lower_threshold[0]; - } else { - /* - * In case the user issues multiple times of snr_threshold_setting, - * we should not use the extreames anymore, the target does not expect that. - */ - snrCmd->thresholdAbove1_Val = ar6000_get_upper_threshold(snr_event_value, sq_thresh, - sq_thresh->upper_threshold_valid_count); - snrCmd->thresholdBelow1_Val = ar6000_get_lower_threshold(snr_event_value, sq_thresh, - sq_thresh->lower_threshold_valid_count); - } - -} -int -wmi_set_snr_threshold_params(struct wmi_t *wmip, - WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd) -{ - if( snrCmd->thresholdAbove4_Val <= snrCmd->thresholdAbove3_Val || - snrCmd->thresholdAbove3_Val <= snrCmd->thresholdAbove2_Val || - snrCmd->thresholdAbove2_Val <= snrCmd->thresholdAbove1_Val || - snrCmd->thresholdBelow4_Val <= snrCmd->thresholdBelow3_Val || - snrCmd->thresholdBelow3_Val <= snrCmd->thresholdBelow2_Val || - snrCmd->thresholdBelow2_Val <= snrCmd->thresholdBelow1_Val) - { - return A_EINVAL; - } - wmi_cache_configure_snrthreshold(wmip, snrCmd); - return (wmi_send_snr_threshold_params(wmip, snrCmd)); -} - -int -wmi_clr_rssi_snr(struct wmi_t *wmip) -{ - void *osbuf; - - osbuf = A_NETBUF_ALLOC(sizeof(int)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - return (wmi_cmd_send(wmip, osbuf, WMI_CLR_RSSI_SNR_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_lq_threshold_params(struct wmi_t *wmip, - WMI_LQ_THRESHOLD_PARAMS_CMD *lqCmd) -{ - void *osbuf; - s8 size; - WMI_LQ_THRESHOLD_PARAMS_CMD *cmd; - /* These values are in ascending order */ - if( lqCmd->thresholdAbove4_Val <= lqCmd->thresholdAbove3_Val || - lqCmd->thresholdAbove3_Val <= lqCmd->thresholdAbove2_Val || - lqCmd->thresholdAbove2_Val <= lqCmd->thresholdAbove1_Val || - lqCmd->thresholdBelow4_Val <= lqCmd->thresholdBelow3_Val || - lqCmd->thresholdBelow3_Val <= lqCmd->thresholdBelow2_Val || - lqCmd->thresholdBelow2_Val <= lqCmd->thresholdBelow1_Val ) { - - return A_EINVAL; - } - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_LQ_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, lqCmd, sizeof(WMI_LQ_THRESHOLD_PARAMS_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_LQ_THRESHOLD_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_error_report_bitmask(struct wmi_t *wmip, u32 mask) -{ - void *osbuf; - s8 size; - WMI_TARGET_ERROR_REPORT_BITMASK *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_TARGET_ERROR_REPORT_BITMASK *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - - cmd->bitmask = mask; - - return (wmi_cmd_send(wmip, osbuf, WMI_TARGET_ERROR_REPORT_BITMASK_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_get_challenge_resp_cmd(struct wmi_t *wmip, u32 cookie, u32 source) -{ - void *osbuf; - WMIX_HB_CHALLENGE_RESP_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMIX_HB_CHALLENGE_RESP_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->cookie = cookie; - cmd->source = source; - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_HB_CHALLENGE_RESP_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_config_debug_module_cmd(struct wmi_t *wmip, u16 mmask, - u16 tsr, bool rep, u16 size, - u32 valid) -{ - void *osbuf; - WMIX_DBGLOG_CFG_MODULE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMIX_DBGLOG_CFG_MODULE_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->config.cfgmmask = mmask; - cmd->config.cfgtsr = tsr; - cmd->config.cfgrep = rep; - cmd->config.cfgsize = size; - cmd->config.cfgvalid = valid; - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DBGLOG_CFG_MODULE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_get_stats_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_STATISTICS_CMDID); -} - -int -wmi_addBadAp_cmd(struct wmi_t *wmip, u8 apIndex, u8 *bssid) -{ - void *osbuf; - WMI_ADD_BAD_AP_CMD *cmd; - - if ((bssid == NULL) || (apIndex > WMI_MAX_BAD_AP_INDEX)) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_ADD_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->badApIndex = apIndex; - memcpy(cmd->bssid, bssid, sizeof(cmd->bssid)); - - return (wmi_cmd_send(wmip, osbuf, WMI_ADD_BAD_AP_CMDID, SYNC_BEFORE_WMIFLAG)); -} - -int -wmi_deleteBadAp_cmd(struct wmi_t *wmip, u8 apIndex) -{ - void *osbuf; - WMI_DELETE_BAD_AP_CMD *cmd; - - if (apIndex > WMI_MAX_BAD_AP_INDEX) { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_DELETE_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->badApIndex = apIndex; - - return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_BAD_AP_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_abort_scan_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_ABORT_SCAN_CMDID); -} - -int -wmi_set_txPwr_cmd(struct wmi_t *wmip, u8 dbM) -{ - void *osbuf; - WMI_SET_TX_PWR_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_TX_PWR_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->dbM = dbM; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_TX_PWR_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_get_txPwr_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_TX_PWR_CMDID); -} - -u16 wmi_get_mapped_qos_queue(struct wmi_t *wmip, u8 trafficClass) -{ - u16 activeTsids=0; - - LOCK_WMI(wmip); - activeTsids = wmip->wmi_streamExistsForAC[trafficClass]; - UNLOCK_WMI(wmip); - - return activeTsids; -} - -int -wmi_get_roam_tbl_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd(wmip, WMI_GET_ROAM_TBL_CMDID); -} - -int -wmi_get_roam_data_cmd(struct wmi_t *wmip, u8 roamDataType) -{ - void *osbuf; - u32 size = sizeof(u8); - WMI_TARGET_ROAM_DATA *cmd; - - osbuf = A_NETBUF_ALLOC(size); /* no payload */ - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_TARGET_ROAM_DATA *)(A_NETBUF_DATA(osbuf)); - cmd->roamDataType = roamDataType; - - return (wmi_cmd_send(wmip, osbuf, WMI_GET_ROAM_DATA_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_roam_ctrl_cmd(struct wmi_t *wmip, WMI_SET_ROAM_CTRL_CMD *p, - u8 size) -{ - void *osbuf; - WMI_SET_ROAM_CTRL_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_SET_ROAM_CTRL_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - - memcpy(cmd, p, size); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_ROAM_CTRL_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_powersave_timers_cmd(struct wmi_t *wmip, - WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd, - u8 size) -{ - void *osbuf; - WMI_POWERSAVE_TIMERS_POLICY_CMD *cmd; - - /* These timers can't be zero */ - if(!pCmd->psPollTimeout || !pCmd->triggerTimeout || - !(pCmd->apsdTimPolicy == IGNORE_TIM_ALL_QUEUES_APSD || - pCmd->apsdTimPolicy == PROCESS_TIM_ALL_QUEUES_APSD) || - !(pCmd->simulatedAPSDTimPolicy == IGNORE_TIM_SIMULATED_APSD || - pCmd->simulatedAPSDTimPolicy == PROCESS_TIM_SIMULATED_APSD)) - return A_EINVAL; - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_POWERSAVE_TIMERS_POLICY_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - - memcpy(cmd, pCmd, size); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_access_params_cmd(struct wmi_t *wmip, u8 ac, u16 txop, u8 eCWmin, - u8 eCWmax, u8 aifsn) -{ - void *osbuf; - WMI_SET_ACCESS_PARAMS_CMD *cmd; - - if ((eCWmin > WMI_MAX_CW_ACPARAM) || (eCWmax > WMI_MAX_CW_ACPARAM) || - (aifsn > WMI_MAX_AIFSN_ACPARAM) || (ac >= WMM_NUM_AC)) - { - return A_EINVAL; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_ACCESS_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->txop = txop; - cmd->eCWmin = eCWmin; - cmd->eCWmax = eCWmax; - cmd->aifsn = aifsn; - cmd->ac = ac; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_ACCESS_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_retry_limits_cmd(struct wmi_t *wmip, u8 frameType, - u8 trafficClass, u8 maxRetries, - u8 enableNotify) -{ - void *osbuf; - WMI_SET_RETRY_LIMITS_CMD *cmd; - - if ((frameType != MGMT_FRAMETYPE) && (frameType != CONTROL_FRAMETYPE) && - (frameType != DATA_FRAMETYPE)) - { - return A_EINVAL; - } - - if (maxRetries > WMI_MAX_RETRIES) { - return A_EINVAL; - } - - if (frameType != DATA_FRAMETYPE) { - trafficClass = 0; - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_RETRY_LIMITS_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->frameType = frameType; - cmd->trafficClass = trafficClass; - cmd->maxRetries = maxRetries; - cmd->enableNotify = enableNotify; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_RETRY_LIMITS_CMDID, - NO_SYNC_WMIFLAG)); -} - -void -wmi_get_current_bssid(struct wmi_t *wmip, u8 *bssid) -{ - if (bssid != NULL) { - memcpy(bssid, wmip->wmi_bssid, ATH_MAC_LEN); - } -} - -int -wmi_set_opt_mode_cmd(struct wmi_t *wmip, u8 optMode) -{ - void *osbuf; - WMI_SET_OPT_MODE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_OPT_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->optMode = optMode; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_OPT_MODE_CMDID, - SYNC_BOTH_WMIFLAG)); -} - -int -wmi_opt_tx_frame_cmd(struct wmi_t *wmip, - u8 frmType, - u8 *dstMacAddr, - u8 *bssid, - u16 optIEDataLen, - u8 *optIEData) -{ - void *osbuf; - WMI_OPT_TX_FRAME_CMD *cmd; - osbuf = A_NETBUF_ALLOC(optIEDataLen + sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, (optIEDataLen + sizeof(*cmd))); - - cmd = (WMI_OPT_TX_FRAME_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, (optIEDataLen + sizeof(*cmd)-1)); - - cmd->frmType = frmType; - cmd->optIEDataLen = optIEDataLen; - //cmd->optIEData = (u8 *)((int)cmd + sizeof(*cmd)); - memcpy(cmd->bssid, bssid, sizeof(cmd->bssid)); - memcpy(cmd->dstAddr, dstMacAddr, sizeof(cmd->dstAddr)); - memcpy(&cmd->optIEData[0], optIEData, optIEDataLen); - - return (wmi_cmd_send(wmip, osbuf, WMI_OPT_TX_FRAME_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_adhoc_bconIntvl_cmd(struct wmi_t *wmip, u16 intvl) -{ - void *osbuf; - WMI_BEACON_INT_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_BEACON_INT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->beaconInterval = intvl; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BEACON_INT_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_voice_pkt_size_cmd(struct wmi_t *wmip, u16 voicePktSize) -{ - void *osbuf; - WMI_SET_VOICE_PKT_SIZE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_VOICE_PKT_SIZE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->voicePktSize = voicePktSize; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_VOICE_PKT_SIZE_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_max_sp_len_cmd(struct wmi_t *wmip, u8 maxSPLen) -{ - void *osbuf; - WMI_SET_MAX_SP_LEN_CMD *cmd; - - /* maxSPLen is a two-bit value. If user trys to set anything - * other than this, then its invalid - */ - if(maxSPLen & ~0x03) - return A_EINVAL; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_MAX_SP_LEN_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->maxSPLen = maxSPLen; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_MAX_SP_LEN_CMDID, - NO_SYNC_WMIFLAG)); -} - -u8 wmi_determine_userPriority( - u8 *pkt, - u32 layer2Pri) -{ - u8 ipPri; - iphdr *ipHdr = (iphdr *)pkt; - - /* Determine IPTOS priority */ - /* - * IP Tos format : - * (Refer Pg 57 WMM-test-plan-v1.2) - * IP-TOS - 8bits - * : DSCP(6-bits) ECN(2-bits) - * : DSCP - P2 P1 P0 X X X - * where (P2 P1 P0) form 802.1D - */ - ipPri = ipHdr->ip_tos >> 5; - ipPri &= 0x7; - - if ((layer2Pri & 0x7) > ipPri) - return ((u8)layer2Pri & 0x7); - else - return ipPri; -} - -u8 convert_userPriority_to_trafficClass(u8 userPriority) -{ - return (up_to_ac[userPriority & 0x7]); -} - -u8 wmi_get_power_mode_cmd(struct wmi_t *wmip) -{ - return wmip->wmi_powerMode; -} - -int -wmi_verify_tspec_params(WMI_CREATE_PSTREAM_CMD *pCmd, int tspecCompliance) -{ - int ret = 0; - -#define TSPEC_SUSPENSION_INTERVAL_ATHEROS_DEF (~0) -#define TSPEC_SERVICE_START_TIME_ATHEROS_DEF 0 -#define TSPEC_MAX_BURST_SIZE_ATHEROS_DEF 0 -#define TSPEC_DELAY_BOUND_ATHEROS_DEF 0 -#define TSPEC_MEDIUM_TIME_ATHEROS_DEF 0 -#define TSPEC_SBA_ATHEROS_DEF 0x2000 /* factor is 1 */ - - /* Verify TSPEC params for ATHEROS compliance */ - if(tspecCompliance == ATHEROS_COMPLIANCE) { - if ((pCmd->suspensionInt != TSPEC_SUSPENSION_INTERVAL_ATHEROS_DEF) || - (pCmd->serviceStartTime != TSPEC_SERVICE_START_TIME_ATHEROS_DEF) || - (pCmd->minDataRate != pCmd->meanDataRate) || - (pCmd->minDataRate != pCmd->peakDataRate) || - (pCmd->maxBurstSize != TSPEC_MAX_BURST_SIZE_ATHEROS_DEF) || - (pCmd->delayBound != TSPEC_DELAY_BOUND_ATHEROS_DEF) || - (pCmd->sba != TSPEC_SBA_ATHEROS_DEF) || - (pCmd->mediumTime != TSPEC_MEDIUM_TIME_ATHEROS_DEF)) { - - A_DPRINTF(DBG_WMI, (DBGFMT "Invalid TSPEC params\n", DBGARG)); - //A_PRINTF("%s: Invalid TSPEC params\n", __func__); - ret = A_EINVAL; - } - } - - return ret; -} - -#ifdef CONFIG_HOST_TCMD_SUPPORT -static int -wmi_tcmd_test_report_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - ar6000_testmode_rx_report_event(wmip->wmi_devt, datap, len); - - return 0; -} - -#endif /* CONFIG_HOST_TCMD_SUPPORT*/ - -int -wmi_set_authmode_cmd(struct wmi_t *wmip, u8 mode) -{ - void *osbuf; - WMI_SET_AUTH_MODE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_AUTH_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->mode = mode; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_AUTH_MODE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_reassocmode_cmd(struct wmi_t *wmip, u8 mode) -{ - void *osbuf; - WMI_SET_REASSOC_MODE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_REASSOC_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->mode = mode; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_REASSOC_MODE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_lpreamble_cmd(struct wmi_t *wmip, u8 status, u8 preamblePolicy) -{ - void *osbuf; - WMI_SET_LPREAMBLE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_LPREAMBLE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->status = status; - cmd->preamblePolicy = preamblePolicy; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_LPREAMBLE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_rts_cmd(struct wmi_t *wmip, u16 threshold) -{ - void *osbuf; - WMI_SET_RTS_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_RTS_CMD*)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->threshold = threshold; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_RTS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_wmm_cmd(struct wmi_t *wmip, WMI_WMM_STATUS status) -{ - void *osbuf; - WMI_SET_WMM_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_WMM_CMD*)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->status = status; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_CMDID, - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_qos_supp_cmd(struct wmi_t *wmip, u8 status) -{ - void *osbuf; - WMI_SET_QOS_SUPP_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_QOS_SUPP_CMD*)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->status = status; - return (wmi_cmd_send(wmip, osbuf, WMI_SET_QOS_SUPP_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_wmm_txop(struct wmi_t *wmip, WMI_TXOP_CFG cfg) -{ - void *osbuf; - WMI_SET_WMM_TXOP_CMD *cmd; - - if( !((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)) ) - return A_EINVAL; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_WMM_TXOP_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->txopEnable = cfg; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_TXOP_CMDID, - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_country(struct wmi_t *wmip, u8 *countryCode) -{ - void *osbuf; - WMI_AP_SET_COUNTRY_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_AP_SET_COUNTRY_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - memcpy(cmd->countryCode,countryCode,3); - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_COUNTRY_CMDID, - NO_SYNC_WMIFLAG)); -} - -#ifdef CONFIG_HOST_TCMD_SUPPORT -/* WMI layer doesn't need to know the data type of the test cmd. - This would be beneficial for customers like Qualcomm, who might - have different test command requirements from different manufacturers - */ -int -wmi_test_cmd(struct wmi_t *wmip, u8 *buf, u32 len) -{ - void *osbuf; - char *data; - - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - osbuf= A_NETBUF_ALLOC(len); - if(osbuf == NULL) - { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, len); - data = A_NETBUF_DATA(osbuf); - memcpy(data, buf, len); - - return(wmi_cmd_send(wmip, osbuf, WMI_TEST_CMDID, - NO_SYNC_WMIFLAG)); -} - -#endif - -int -wmi_set_bt_status_cmd(struct wmi_t *wmip, u8 streamType, u8 status) -{ - void *osbuf; - WMI_SET_BT_STATUS_CMD *cmd; - - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("Enter - streamType=%d, status=%d\n", streamType, status)); - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_BT_STATUS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->streamType = streamType; - cmd->status = status; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_STATUS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_bt_params_cmd(struct wmi_t *wmip, WMI_SET_BT_PARAMS_CMD* cmd) -{ - void *osbuf; - WMI_SET_BT_PARAMS_CMD* alloc_cmd; - - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("cmd params is %d\n", cmd->paramType)); - - if (cmd->paramType == BT_PARAM_SCO) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("sco params %d %d %d %d %d %d %d %d %d %d %d %d\n", cmd->info.scoParams.numScoCyclesForceTrigger, - cmd->info.scoParams.dataResponseTimeout, - cmd->info.scoParams.stompScoRules, - cmd->info.scoParams.scoOptFlags, - cmd->info.scoParams.stompDutyCyleVal, - cmd->info.scoParams.stompDutyCyleMaxVal, - cmd->info.scoParams.psPollLatencyFraction, - cmd->info.scoParams.noSCOSlots, - cmd->info.scoParams.noIdleSlots, - cmd->info.scoParams.scoOptOffRssi, - cmd->info.scoParams.scoOptOnRssi, - cmd->info.scoParams.scoOptRtsCount)); - } - else if (cmd->paramType == BT_PARAM_A2DP) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("A2DP params %d %d %d %d %d %d %d %d\n", cmd->info.a2dpParams.a2dpWlanUsageLimit, - cmd->info.a2dpParams.a2dpBurstCntMin, - cmd->info.a2dpParams.a2dpDataRespTimeout, - cmd->info.a2dpParams.a2dpOptFlags, - cmd->info.a2dpParams.isCoLocatedBtRoleMaster, - cmd->info.a2dpParams.a2dpOptOffRssi, - cmd->info.a2dpParams.a2dpOptOnRssi, - cmd->info.a2dpParams.a2dpOptRtsCount)); - } - else if (cmd->paramType == BT_PARAM_ANTENNA_CONFIG) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("Ant config %d\n", cmd->info.antType)); - } - else if (cmd->paramType == BT_PARAM_COLOCATED_BT_DEVICE) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("co-located BT %d\n", cmd->info.coLocatedBtDev)); - } - else if (cmd->paramType == BT_PARAM_ACLCOEX) { - AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("ACL params %d %d %d\n", cmd->info.aclCoexParams.aclWlanMediumUsageTime, - cmd->info.aclCoexParams.aclBtMediumUsageTime, - cmd->info.aclCoexParams.aclDataRespTimeout)); - } - else if (cmd->paramType == BT_PARAM_11A_SEPARATE_ANT) { - A_DPRINTF(DBG_WMI, (DBGFMT "11A ant\n", DBGARG)); - } - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - alloc_cmd = (WMI_SET_BT_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd, cmd, sizeof(*cmd)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_btcoex_fe_ant_cmd(struct wmi_t *wmip, WMI_SET_BTCOEX_FE_ANT_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_FE_ANT_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_FE_ANT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_FE_ANT_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_FE_ANT_CMDID, - NO_SYNC_WMIFLAG)); - -} - - -int -wmi_set_btcoex_colocated_bt_dev_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD)); - A_PRINTF("colocated bt = %d\n", alloc_cmd->btcoexCoLocatedBTdev); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMDID, - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_btinquiry_page_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD* cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMDID, - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_sco_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_SCO_CONFIG_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_SCO_CONFIG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_SCO_CONFIG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_SCO_CONFIG_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_a2dp_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_A2DP_CONFIG_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_A2DP_CONFIG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_A2DP_CONFIG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_A2DP_CONFIG_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_aclcoex_config_cmd(struct wmi_t *wmip, - WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_debug_cmd(struct wmi_t *wmip, WMI_SET_BTCOEX_DEBUG_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_DEBUG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_DEBUG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_DEBUG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_DEBUG_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_set_btcoex_bt_operating_status_cmd(struct wmi_t * wmip, - WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD * cmd) -{ - void *osbuf; - WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_get_btcoex_config_cmd(struct wmi_t * wmip, WMI_GET_BTCOEX_CONFIG_CMD * cmd) -{ - void *osbuf; - WMI_GET_BTCOEX_CONFIG_CMD *alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - alloc_cmd = (WMI_GET_BTCOEX_CONFIG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd,cmd,sizeof(WMI_GET_BTCOEX_CONFIG_CMD)); - return (wmi_cmd_send(wmip, osbuf, WMI_GET_BTCOEX_CONFIG_CMDID , - NO_SYNC_WMIFLAG)); - -} - -int -wmi_get_btcoex_stats_cmd(struct wmi_t *wmip) -{ - - return wmi_simple_cmd(wmip, WMI_GET_BTCOEX_STATS_CMDID); - -} - -int -wmi_get_keepalive_configured(struct wmi_t *wmip) -{ - void *osbuf; - WMI_GET_KEEPALIVE_CMD *cmd; - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - cmd = (WMI_GET_KEEPALIVE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - return (wmi_cmd_send(wmip, osbuf, WMI_GET_KEEPALIVE_CMDID, - NO_SYNC_WMIFLAG)); -} - -u8 wmi_get_keepalive_cmd(struct wmi_t *wmip) -{ - return wmip->wmi_keepaliveInterval; -} - -int -wmi_set_keepalive_cmd(struct wmi_t *wmip, u8 keepaliveInterval) -{ - void *osbuf; - WMI_SET_KEEPALIVE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_KEEPALIVE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->keepaliveInterval = keepaliveInterval; - wmip->wmi_keepaliveInterval = keepaliveInterval; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_KEEPALIVE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_params_cmd(struct wmi_t *wmip, u32 opcode, u32 length, char *buffer) -{ - void *osbuf; - WMI_SET_PARAMS_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd) + length); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd) + length); - - cmd = (WMI_SET_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->opcode = opcode; - cmd->length = length; - memcpy(cmd->buffer, buffer, length); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_mcast_filter_cmd(struct wmi_t *wmip, u8 dot1, u8 dot2, u8 dot3, u8 dot4) -{ - void *osbuf; - WMI_SET_MCAST_FILTER_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_MCAST_FILTER_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->multicast_mac[0] = 0x01; - cmd->multicast_mac[1] = 0x00; - cmd->multicast_mac[2] = 0x5e; - cmd->multicast_mac[3] = dot2&0x7F; - cmd->multicast_mac[4] = dot3; - cmd->multicast_mac[5] = dot4; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_MCAST_FILTER_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_del_mcast_filter_cmd(struct wmi_t *wmip, u8 dot1, u8 dot2, u8 dot3, u8 dot4) -{ - void *osbuf; - WMI_SET_MCAST_FILTER_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_MCAST_FILTER_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->multicast_mac[0] = 0x01; - cmd->multicast_mac[1] = 0x00; - cmd->multicast_mac[2] = 0x5e; - cmd->multicast_mac[3] = dot2&0x7F; - cmd->multicast_mac[4] = dot3; - cmd->multicast_mac[5] = dot4; - - return (wmi_cmd_send(wmip, osbuf, WMI_DEL_MCAST_FILTER_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_mcast_filter_cmd(struct wmi_t *wmip, u8 enable) -{ - void *osbuf; - WMI_MCAST_FILTER_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_MCAST_FILTER_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->enable = enable; - - return (wmi_cmd_send(wmip, osbuf, WMI_MCAST_FILTER_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_appie_cmd(struct wmi_t *wmip, u8 mgmtFrmType, u8 ieLen, - u8 *ieInfo) -{ - void *osbuf; - WMI_SET_APPIE_CMD *cmd; - u16 cmdLen; - - cmdLen = sizeof(*cmd) + ieLen - 1; - osbuf = A_NETBUF_ALLOC(cmdLen); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, cmdLen); - - cmd = (WMI_SET_APPIE_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, cmdLen); - - cmd->mgmtFrmType = mgmtFrmType; - cmd->ieLen = ieLen; - memcpy(cmd->ieInfo, ieInfo, ieLen); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_APPIE_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_set_halparam_cmd(struct wmi_t *wmip, u8 *cmd, u16 dataLen) -{ - void *osbuf; - u8 *data; - - osbuf = A_NETBUF_ALLOC(dataLen); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, dataLen); - - data = A_NETBUF_DATA(osbuf); - - memcpy(data, cmd, dataLen); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_WHALPARAM_CMDID, NO_SYNC_WMIFLAG)); -} - -s32 wmi_get_rate(s8 rateindex) -{ - if (rateindex == RATE_AUTO) { - return 0; - } else { - return(wmi_rateTable[(u32) rateindex][0]); - } -} - -void -wmi_node_return (struct wmi_t *wmip, bss_t *bss) -{ - if (NULL != bss) - { - wlan_node_return (&wmip->wmi_scan_table, bss); - } -} - -void -wmi_set_nodeage(struct wmi_t *wmip, u32 nodeAge) -{ - wlan_set_nodeage(&wmip->wmi_scan_table,nodeAge); -} - -bss_t * -wmi_find_Ssidnode (struct wmi_t *wmip, u8 *pSsid, - u32 ssidLength, bool bIsWPA2, bool bMatchSSID) -{ - bss_t *node = NULL; - node = wlan_find_Ssidnode (&wmip->wmi_scan_table, pSsid, - ssidLength, bIsWPA2, bMatchSSID); - return node; -} - - -#ifdef THREAD_X -void -wmi_refresh_scan_table (struct wmi_t *wmip) -{ - wlan_refresh_inactive_nodes (&wmip->wmi_scan_table); -} -#endif - -void -wmi_free_allnodes(struct wmi_t *wmip) -{ - wlan_free_allnodes(&wmip->wmi_scan_table); -} - -bss_t * -wmi_find_node(struct wmi_t *wmip, const u8 *macaddr) -{ - bss_t *ni=NULL; - ni=wlan_find_node(&wmip->wmi_scan_table,macaddr); - return ni; -} - -void -wmi_free_node(struct wmi_t *wmip, const u8 *macaddr) -{ - bss_t *ni=NULL; - - ni=wlan_find_node(&wmip->wmi_scan_table,macaddr); - if (ni != NULL) { - wlan_node_reclaim(&wmip->wmi_scan_table, ni); - } - - return; -} - -int -wmi_dset_open_reply(struct wmi_t *wmip, - u32 status, - u32 access_cookie, - u32 dset_size, - u32 dset_version, - u32 targ_handle, - u32 targ_reply_fn, - u32 targ_reply_arg) -{ - void *osbuf; - WMIX_DSETOPEN_REPLY_CMD *open_reply; - - A_DPRINTF(DBG_WMI, (DBGFMT "Enter - wmip=0x%lx\n", DBGARG, (unsigned long)wmip)); - - osbuf = A_NETBUF_ALLOC(sizeof(*open_reply)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*open_reply)); - open_reply = (WMIX_DSETOPEN_REPLY_CMD *)(A_NETBUF_DATA(osbuf)); - - open_reply->status = status; - open_reply->targ_dset_handle = targ_handle; - open_reply->targ_reply_fn = targ_reply_fn; - open_reply->targ_reply_arg = targ_reply_arg; - open_reply->access_cookie = access_cookie; - open_reply->size = dset_size; - open_reply->version = dset_version; - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETOPEN_REPLY_CMDID, - NO_SYNC_WMIFLAG)); -} - -static int -wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, u8 *datap, u32 len) -{ - WMI_PMKID_LIST_REPLY *reply; - u32 expected_len; - - if (len < sizeof(WMI_PMKID_LIST_REPLY)) { - return A_EINVAL; - } - reply = (WMI_PMKID_LIST_REPLY *)datap; - expected_len = sizeof(reply->numPMKID) + reply->numPMKID * WMI_PMKID_LEN; - - if (len < expected_len) { - return A_EINVAL; - } - - A_WMI_PMKID_LIST_EVENT(wmip->wmi_devt, reply->numPMKID, - reply->pmkidList, reply->bssidList[0]); - - return 0; -} - - -static int -wmi_set_params_event_rx(struct wmi_t *wmip, u8 *datap, u32 len) -{ - WMI_SET_PARAMS_REPLY *reply; - - if (len < sizeof(WMI_SET_PARAMS_REPLY)) { - return A_EINVAL; - } - reply = (WMI_SET_PARAMS_REPLY *)datap; - - if (0 == reply->status) - { - - } - else - { - - } - - return 0; -} - - -#ifdef CONFIG_HOST_DSET_SUPPORT -int -wmi_dset_data_reply(struct wmi_t *wmip, - u32 status, - u8 *user_buf, - u32 length, - u32 targ_buf, - u32 targ_reply_fn, - u32 targ_reply_arg) -{ - void *osbuf; - WMIX_DSETDATA_REPLY_CMD *data_reply; - u32 size; - - size = sizeof(*data_reply) + length; - - if (size <= length) { - return A_ERROR; - } - - A_DPRINTF(DBG_WMI, - (DBGFMT "Enter - length=%d status=%d\n", DBGARG, length, status)); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - A_NETBUF_PUT(osbuf, size); - data_reply = (WMIX_DSETDATA_REPLY_CMD *)(A_NETBUF_DATA(osbuf)); - - data_reply->status = status; - data_reply->targ_buf = targ_buf; - data_reply->targ_reply_fn = targ_reply_fn; - data_reply->targ_reply_arg = targ_reply_arg; - data_reply->length = length; - - if (status == 0) { - if (a_copy_from_user(data_reply->buf, user_buf, length)) { - A_NETBUF_FREE(osbuf); - return A_ERROR; - } - } - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETDATA_REPLY_CMDID, - NO_SYNC_WMIFLAG)); -} -#endif /* CONFIG_HOST_DSET_SUPPORT */ - -int -wmi_set_wsc_status_cmd(struct wmi_t *wmip, u32 status) -{ - void *osbuf; - char *cmd; - - wps_enable = status; - - osbuf = a_netbuf_alloc(sizeof(1)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - a_netbuf_put(osbuf, sizeof(1)); - - cmd = (char *)(a_netbuf_to_data(osbuf)); - - A_MEMZERO(cmd, sizeof(*cmd)); - cmd[0] = (status?1:0); - return (wmi_cmd_send(wmip, osbuf, WMI_SET_WSC_STATUS_CMDID, - NO_SYNC_WMIFLAG)); -} - -#if defined(CONFIG_TARGET_PROFILE_SUPPORT) -int -wmi_prof_cfg_cmd(struct wmi_t *wmip, - u32 period, - u32 nbins) -{ - void *osbuf; - WMIX_PROF_CFG_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMIX_PROF_CFG_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->period = period; - cmd->nbins = nbins; - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_PROF_CFG_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_prof_addr_set_cmd(struct wmi_t *wmip, u32 addr) -{ - void *osbuf; - WMIX_PROF_ADDR_SET_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMIX_PROF_ADDR_SET_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->addr = addr; - - return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_PROF_ADDR_SET_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_prof_start_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd_xtnd(wmip, WMIX_PROF_START_CMDID); -} - -int -wmi_prof_stop_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd_xtnd(wmip, WMIX_PROF_STOP_CMDID); -} - -int -wmi_prof_count_get_cmd(struct wmi_t *wmip) -{ - return wmi_simple_cmd_xtnd(wmip, WMIX_PROF_COUNT_GET_CMDID); -} - -/* Called to handle WMIX_PROF_CONT_EVENTID */ -static int -wmi_prof_count_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMIX_PROF_COUNT_EVENT *prof_data = (WMIX_PROF_COUNT_EVENT *)datap; - - A_DPRINTF(DBG_WMI, - (DBGFMT "Enter - addr=0x%x count=%d\n", DBGARG, - prof_data->addr, prof_data->count)); - - A_WMI_PROF_COUNT_RX(prof_data->addr, prof_data->count); - - return 0; -} -#endif /* CONFIG_TARGET_PROFILE_SUPPORT */ - -#ifdef OS_ROAM_MANAGEMENT - -#define ETHERNET_MAC_ADDRESS_LENGTH 6 - -void -wmi_scan_indication (struct wmi_t *wmip) -{ - struct ieee80211_node_table *nt; - u32 gen; - u32 size; - u32 bsssize; - bss_t *bss; - u32 numbss; - PNDIS_802_11_BSSID_SCAN_INFO psi; - PBYTE pie; - NDIS_802_11_FIXED_IEs *pFixed; - NDIS_802_11_VARIABLE_IEs *pVar; - u32 RateSize; - - struct ar6kScanIndication - { - NDIS_802_11_STATUS_INDICATION ind; - NDIS_802_11_BSSID_SCAN_INFO_LIST slist; - } *pAr6kScanIndEvent; - - nt = &wmip->wmi_scan_table; - - ++nt->nt_si_gen; - - - gen = nt->nt_si_gen; - - size = offsetof(struct ar6kScanIndication, slist) + - offsetof(NDIS_802_11_BSSID_SCAN_INFO_LIST, BssidScanInfo); - - numbss = 0; - - IEEE80211_NODE_LOCK(nt); - - //calc size - for (bss = nt->nt_node_first; bss; bss = bss->ni_list_next) { - if (bss->ni_si_gen != gen) { - bsssize = offsetof(NDIS_802_11_BSSID_SCAN_INFO, Bssid) + offsetof(NDIS_WLAN_BSSID_EX, IEs); - bsssize = bsssize + sizeof(NDIS_802_11_FIXED_IEs); - -#ifdef SUPPORT_WPA2 - if (bss->ni_cie.ie_rsn) { - bsssize = bsssize + bss->ni_cie.ie_rsn[1] + 2; - } -#endif - if (bss->ni_cie.ie_wpa) { - bsssize = bsssize + bss->ni_cie.ie_wpa[1] + 2; - } - - // bsssize must be a multiple of 4 to maintain alignment. - bsssize = (bsssize + 3) & ~3; - - size += bsssize; - - numbss++; - } - } - - if (0 == numbss) - { -// RETAILMSG(1, (L"AR6K: scan indication: 0 bss\n")); - ar6000_scan_indication (wmip->wmi_devt, NULL, 0); - IEEE80211_NODE_UNLOCK (nt); - return; - } - - pAr6kScanIndEvent = A_MALLOC(size); - - if (NULL == pAr6kScanIndEvent) - { - IEEE80211_NODE_UNLOCK(nt); - return; - } - - A_MEMZERO(pAr6kScanIndEvent, size); - - //copy data - pAr6kScanIndEvent->ind.StatusType = Ndis802_11StatusType_BssidScanInfoList; - pAr6kScanIndEvent->slist.Version = 1; - pAr6kScanIndEvent->slist.NumItems = numbss; - - psi = &pAr6kScanIndEvent->slist.BssidScanInfo[0]; - - for (bss = nt->nt_node_first; bss; bss = bss->ni_list_next) { - if (bss->ni_si_gen != gen) { - - bss->ni_si_gen = gen; - - //Set scan time - psi->ScanTime = bss->ni_tstamp - WLAN_NODE_INACT_TIMEOUT_MSEC; - - // Copy data to bssid_ex - bsssize = offsetof(NDIS_WLAN_BSSID_EX, IEs); - bsssize = bsssize + sizeof(NDIS_802_11_FIXED_IEs); - -#ifdef SUPPORT_WPA2 - if (bss->ni_cie.ie_rsn) { - bsssize = bsssize + bss->ni_cie.ie_rsn[1] + 2; - } -#endif - if (bss->ni_cie.ie_wpa) { - bsssize = bsssize + bss->ni_cie.ie_wpa[1] + 2; - } - - // bsssize must be a multiple of 4 to maintain alignment. - bsssize = (bsssize + 3) & ~3; - - psi->Bssid.Length = bsssize; - - memcpy (psi->Bssid.MacAddress, bss->ni_macaddr, ETHERNET_MAC_ADDRESS_LENGTH); - - -//if (((bss->ni_macaddr[3] == 0xCE) && (bss->ni_macaddr[4] == 0xF0) && (bss->ni_macaddr[5] == 0xE7)) || -// ((bss->ni_macaddr[3] == 0x03) && (bss->ni_macaddr[4] == 0xE2) && (bss->ni_macaddr[5] == 0x70))) -// RETAILMSG (1, (L"%x\n",bss->ni_macaddr[5])); - - psi->Bssid.Ssid.SsidLength = 0; - pie = bss->ni_cie.ie_ssid; - - if (pie) { - // Format of SSID IE is: - // Type (1 octet) - // Length (1 octet) - // SSID (Length octets) - // - // Validation of the IE should have occurred within WMI. - // - if (pie[1] <= 32) { - psi->Bssid.Ssid.SsidLength = pie[1]; - memcpy(psi->Bssid.Ssid.Ssid, &pie[2], psi->Bssid.Ssid.SsidLength); - } - } - psi->Bssid.Privacy = (bss->ni_cie.ie_capInfo & 0x10) ? 1 : 0; - - //Post the RSSI value relative to the Standard Noise floor value. - psi->Bssid.Rssi = bss->ni_rssi; - - if (bss->ni_cie.ie_chan >= 2412 && bss->ni_cie.ie_chan <= 2484) { - - if (bss->ni_cie.ie_rates && bss->ni_cie.ie_xrates) { - psi->Bssid.NetworkTypeInUse = Ndis802_11OFDM24; - } - else { - psi->Bssid.NetworkTypeInUse = Ndis802_11DS; - } - } - else { - psi->Bssid.NetworkTypeInUse = Ndis802_11OFDM5; - } - - psi->Bssid.Configuration.Length = sizeof(psi->Bssid.Configuration); - psi->Bssid.Configuration.BeaconPeriod = bss->ni_cie.ie_beaconInt; // Units are Kmicroseconds (1024 us) - psi->Bssid.Configuration.ATIMWindow = 0; - psi->Bssid.Configuration.DSConfig = bss->ni_cie.ie_chan * 1000; - psi->Bssid.InfrastructureMode = ((bss->ni_cie.ie_capInfo & 0x03) == 0x01 ) ? Ndis802_11Infrastructure : Ndis802_11IBSS; - - RateSize = 0; - pie = bss->ni_cie.ie_rates; - if (pie) { - RateSize = (pie[1] < NDIS_802_11_LENGTH_RATES_EX) ? pie[1] : NDIS_802_11_LENGTH_RATES_EX; - memcpy(psi->Bssid.SupportedRates, &pie[2], RateSize); - } - pie = bss->ni_cie.ie_xrates; - if (pie && RateSize < NDIS_802_11_LENGTH_RATES_EX) { - memcpy(psi->Bssid.SupportedRates + RateSize, &pie[2], - (pie[1] < (NDIS_802_11_LENGTH_RATES_EX - RateSize)) ? pie[1] : (NDIS_802_11_LENGTH_RATES_EX - RateSize)); - } - - // Copy the fixed IEs - psi->Bssid.IELength = sizeof(NDIS_802_11_FIXED_IEs); - - pFixed = (NDIS_802_11_FIXED_IEs *)psi->Bssid.IEs; - memcpy(pFixed->Timestamp, bss->ni_cie.ie_tstamp, sizeof(pFixed->Timestamp)); - pFixed->BeaconInterval = bss->ni_cie.ie_beaconInt; - pFixed->Capabilities = bss->ni_cie.ie_capInfo; - - // Copy selected variable IEs - - pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pFixed + sizeof(NDIS_802_11_FIXED_IEs)); - -#ifdef SUPPORT_WPA2 - // Copy the WPAv2 IE - if (bss->ni_cie.ie_rsn) { - pie = bss->ni_cie.ie_rsn; - psi->Bssid.IELength += pie[1] + 2; - memcpy(pVar, pie, pie[1] + 2); - pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pVar + pie[1] + 2); - } -#endif - // Copy the WPAv1 IE - if (bss->ni_cie.ie_wpa) { - pie = bss->ni_cie.ie_wpa; - psi->Bssid.IELength += pie[1] + 2; - memcpy(pVar, pie, pie[1] + 2); - pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pVar + pie[1] + 2); - } - - // Advance buffer pointer - psi = (PNDIS_802_11_BSSID_SCAN_INFO)((BYTE*)psi + bsssize + FIELD_OFFSET(NDIS_802_11_BSSID_SCAN_INFO, Bssid)); - } - } - - IEEE80211_NODE_UNLOCK(nt); - -// wmi_free_allnodes(wmip); - -// RETAILMSG(1, (L"AR6K: scan indication: %u bss\n", numbss)); - - ar6000_scan_indication (wmip->wmi_devt, pAr6kScanIndEvent, size); - - kfree(pAr6kScanIndEvent); -} -#endif - -u8 ar6000_get_upper_threshold(s16 rssi, SQ_THRESHOLD_PARAMS *sq_thresh, - u32 size) -{ - u32 index; - u8 threshold = (u8)sq_thresh->upper_threshold[size - 1]; - - /* The list is already in sorted order. Get the next lower value */ - for (index = 0; index < size; index ++) { - if (rssi < sq_thresh->upper_threshold[index]) { - threshold = (u8)sq_thresh->upper_threshold[index]; - break; - } - } - - return threshold; -} - -u8 ar6000_get_lower_threshold(s16 rssi, SQ_THRESHOLD_PARAMS *sq_thresh, - u32 size) -{ - u32 index; - u8 threshold = (u8)sq_thresh->lower_threshold[size - 1]; - - /* The list is already in sorted order. Get the next lower value */ - for (index = 0; index < size; index ++) { - if (rssi > sq_thresh->lower_threshold[index]) { - threshold = (u8)sq_thresh->lower_threshold[index]; - break; - } - } - - return threshold; -} -static int -wmi_send_rssi_threshold_params(struct wmi_t *wmip, - WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd) -{ - void *osbuf; - s8 size; - WMI_RSSI_THRESHOLD_PARAMS_CMD *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - - cmd = (WMI_RSSI_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, rssiCmd, sizeof(WMI_RSSI_THRESHOLD_PARAMS_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_RSSI_THRESHOLD_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} -static int -wmi_send_snr_threshold_params(struct wmi_t *wmip, - WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd) -{ - void *osbuf; - s8 size; - WMI_SNR_THRESHOLD_PARAMS_CMD *cmd; - - size = sizeof (*cmd); - - osbuf = A_NETBUF_ALLOC(size); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, size); - cmd = (WMI_SNR_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, size); - memcpy(cmd, snrCmd, sizeof(WMI_SNR_THRESHOLD_PARAMS_CMD)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SNR_THRESHOLD_PARAMS_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_target_event_report_cmd(struct wmi_t *wmip, WMI_SET_TARGET_EVENT_REPORT_CMD* cmd) -{ - void *osbuf; - WMI_SET_TARGET_EVENT_REPORT_CMD* alloc_cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - alloc_cmd = (WMI_SET_TARGET_EVENT_REPORT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(alloc_cmd, sizeof(*cmd)); - memcpy(alloc_cmd, cmd, sizeof(*cmd)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_TARGET_EVENT_REPORT_CMDID, - NO_SYNC_WMIFLAG)); -} - -bss_t *wmi_rm_current_bss (struct wmi_t *wmip, u8 *id) -{ - wmi_get_current_bssid (wmip, id); - return wlan_node_remove (&wmip->wmi_scan_table, id); -} - -int wmi_add_current_bss (struct wmi_t *wmip, u8 *id, bss_t *bss) -{ - wlan_setup_node (&wmip->wmi_scan_table, bss, id); - return 0; -} - -static int -wmi_addba_req_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_ADDBA_REQ_EVENT *cmd = (WMI_ADDBA_REQ_EVENT *)datap; - - A_WMI_AGGR_RECV_ADDBA_REQ_EVT(wmip->wmi_devt, cmd); - - return 0; -} - - -static int -wmi_addba_resp_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_ADDBA_RESP_EVENT *cmd = (WMI_ADDBA_RESP_EVENT *)datap; - - A_WMI_AGGR_RECV_ADDBA_RESP_EVT(wmip->wmi_devt, cmd); - - return 0; -} - -static int -wmi_delba_req_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_DELBA_EVENT *cmd = (WMI_DELBA_EVENT *)datap; - - A_WMI_AGGR_RECV_DELBA_REQ_EVT(wmip->wmi_devt, cmd); - - return 0; -} - -int -wmi_btcoex_config_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_BTCOEX_CONFIG_EVENT(wmip->wmi_devt, datap, len); - - return 0; -} - - -int -wmi_btcoex_stats_event_rx(struct wmi_t * wmip,u8 *datap,int len) -{ - A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG)); - - A_WMI_BTCOEX_STATS_EVENT(wmip->wmi_devt, datap, len); - - return 0; - -} - -static int -wmi_hci_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_HCI_EVENT *cmd = (WMI_HCI_EVENT *)datap; - A_WMI_HCI_EVENT_EVT(wmip->wmi_devt, cmd); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// -//// //// -//// AP mode functions //// -//// //// -//////////////////////////////////////////////////////////////////////////////// -/* - * IOCTL: AR6000_XIOCTL_AP_COMMIT_CONFIG - * - * When AR6K in AP mode, This command will be called after - * changing ssid, channel etc. It will pass the profile to - * target with a flag which will indicate which parameter changed, - * also if this flag is 0, there was no change in parametes, so - * commit cmd will not be sent to target. Without calling this IOCTL - * the changes will not take effect. - */ -int -wmi_ap_profile_commit(struct wmi_t *wmip, WMI_CONNECT_CMD *p) -{ - void *osbuf; - WMI_CONNECT_CMD *cm; - - osbuf = A_NETBUF_ALLOC(sizeof(*cm)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cm)); - cm = (WMI_CONNECT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cm, sizeof(*cm)); - - memcpy(cm,p,sizeof(*cm)); - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_CONFIG_COMMIT_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * IOCTL: AR6000_XIOCTL_AP_HIDDEN_SSID - * - * This command will be used to enable/disable hidden ssid functioanlity of - * beacon. If it is enabled, ssid will be NULL in beacon. - */ -int -wmi_ap_set_hidden_ssid(struct wmi_t *wmip, u8 hidden_ssid) -{ - void *osbuf; - WMI_AP_HIDDEN_SSID_CMD *hs; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_HIDDEN_SSID_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_HIDDEN_SSID_CMD)); - hs = (WMI_AP_HIDDEN_SSID_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(hs, sizeof(*hs)); - - hs->hidden_ssid = hidden_ssid; - - A_DPRINTF(DBG_WMI, (DBGFMT "AR6000_XIOCTL_AP_HIDDEN_SSID %d\n", DBGARG , hidden_ssid)); - return (wmi_cmd_send(wmip, osbuf, WMI_AP_HIDDEN_SSID_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * IOCTL: AR6000_XIOCTL_AP_SET_MAX_NUM_STA - * - * This command is used to limit max num of STA that can connect - * with this AP. This value should not exceed AP_MAX_NUM_STA (this - * is max num of STA supported by AP). Value was already validated - * in ioctl.c - */ -int -wmi_ap_set_num_sta(struct wmi_t *wmip, u8 num_sta) -{ - void *osbuf; - WMI_AP_SET_NUM_STA_CMD *ns; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_SET_NUM_STA_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_SET_NUM_STA_CMD)); - ns = (WMI_AP_SET_NUM_STA_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(ns, sizeof(*ns)); - - ns->num_sta = num_sta; - - A_DPRINTF(DBG_WMI, (DBGFMT "AR6000_XIOCTL_AP_SET_MAX_NUM_STA %d\n", DBGARG , num_sta)); - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_NUM_STA_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * IOCTL: AR6000_XIOCTL_AP_SET_ACL_MAC - * - * This command is used to send list of mac of STAs which will - * be allowed to connect with this AP. When this list is empty - * firware will allow all STAs till the count reaches AP_MAX_NUM_STA. - */ -int -wmi_ap_acl_mac_list(struct wmi_t *wmip, WMI_AP_ACL_MAC_CMD *acl) -{ - void *osbuf; - WMI_AP_ACL_MAC_CMD *a; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_ACL_MAC_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_ACL_MAC_CMD)); - a = (WMI_AP_ACL_MAC_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(a, sizeof(*a)); - memcpy(a,acl,sizeof(*acl)); - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_ACL_MAC_LIST_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * IOCTL: AR6000_XIOCTL_AP_SET_MLME - * - * This command is used to send list of mac of STAs which will - * be allowed to connect with this AP. When this list is empty - * firware will allow all STAs till the count reaches AP_MAX_NUM_STA. - */ -int -wmi_ap_set_mlme(struct wmi_t *wmip, u8 cmd, u8 *mac, u16 reason) -{ - void *osbuf; - WMI_AP_SET_MLME_CMD *mlme; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_SET_MLME_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_SET_MLME_CMD)); - mlme = (WMI_AP_SET_MLME_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(mlme, sizeof(*mlme)); - - mlme->cmd = cmd; - memcpy(mlme->mac, mac, ATH_MAC_LEN); - mlme->reason = reason; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_MLME_CMDID, NO_SYNC_WMIFLAG)); -} - -static int -wmi_pspoll_event_rx(struct wmi_t *wmip, u8 *datap, int len) -{ - WMI_PSPOLL_EVENT *ev; - - if (len < sizeof(WMI_PSPOLL_EVENT)) { - return A_EINVAL; - } - ev = (WMI_PSPOLL_EVENT *)datap; - - A_WMI_PSPOLL_EVENT(wmip->wmi_devt, ev->aid); - return 0; -} - -static int -wmi_dtimexpiry_event_rx(struct wmi_t *wmip, u8 *datap,int len) -{ - A_WMI_DTIMEXPIRY_EVENT(wmip->wmi_devt); - return 0; -} - -#ifdef WAPI_ENABLE -static int -wmi_wapi_rekey_event_rx(struct wmi_t *wmip, u8 *datap,int len) -{ - u8 *ev; - - if (len < 7) { - return A_EINVAL; - } - ev = (u8 *)datap; - - A_WMI_WAPI_REKEY_EVENT(wmip->wmi_devt, *ev, &ev[1]); - return 0; -} -#endif - -int -wmi_set_pvb_cmd(struct wmi_t *wmip, u16 aid, bool flag) -{ - WMI_AP_SET_PVB_CMD *cmd; - void *osbuf = NULL; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_SET_PVB_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_SET_PVB_CMD)); - cmd = (WMI_AP_SET_PVB_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->aid = aid; - cmd->flag = flag; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_PVB_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_ap_conn_inact_time(struct wmi_t *wmip, u32 period) -{ - WMI_AP_CONN_INACT_CMD *cmd; - void *osbuf = NULL; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_CONN_INACT_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_CONN_INACT_CMD)); - cmd = (WMI_AP_CONN_INACT_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->period = period; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_CONN_INACT_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_ap_bgscan_time(struct wmi_t *wmip, u32 period, u32 dwell) -{ - WMI_AP_PROT_SCAN_TIME_CMD *cmd; - void *osbuf = NULL; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_PROT_SCAN_TIME_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_PROT_SCAN_TIME_CMD)); - cmd = (WMI_AP_PROT_SCAN_TIME_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->period_min = period; - cmd->dwell_ms = dwell; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_PROT_SCAN_TIME_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_ap_set_dtim(struct wmi_t *wmip, u8 dtim) -{ - WMI_AP_SET_DTIM_CMD *cmd; - void *osbuf = NULL; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_SET_DTIM_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_SET_DTIM_CMD)); - cmd = (WMI_AP_SET_DTIM_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - - cmd->dtim = dtim; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_DTIM_CMDID, NO_SYNC_WMIFLAG)); -} - -/* - * IOCTL: AR6000_XIOCTL_AP_SET_ACL_POLICY - * - * This command is used to set ACL policay. While changing policy, if you - * want to retain the existing MAC addresses in the ACL list, policy should be - * OR with AP_ACL_RETAIN_LIST_MASK, else the existing list will be cleared. - * If there is no chage in policy, the list will be intact. - */ -int -wmi_ap_set_acl_policy(struct wmi_t *wmip, u8 policy) -{ - void *osbuf; - WMI_AP_ACL_POLICY_CMD *po; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_ACL_POLICY_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; -} - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_ACL_POLICY_CMD)); - po = (WMI_AP_ACL_POLICY_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(po, sizeof(*po)); - - po->policy = policy; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_ACL_POLICY_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_ap_set_rateset(struct wmi_t *wmip, u8 rateset) -{ - void *osbuf; - WMI_AP_SET_11BG_RATESET_CMD *rs; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_AP_SET_11BG_RATESET_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_AP_SET_11BG_RATESET_CMD)); - rs = (WMI_AP_SET_11BG_RATESET_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(rs, sizeof(*rs)); - - rs->rateset = rateset; - - return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_11BG_RATESET_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_set_ht_cap_cmd(struct wmi_t *wmip, WMI_SET_HT_CAP_CMD *cmd) -{ - void *osbuf; - WMI_SET_HT_CAP_CMD *htCap; - u8 band; - - osbuf = A_NETBUF_ALLOC(sizeof(*htCap)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*htCap)); - - band = (cmd->band)? A_BAND_5GHZ : A_BAND_24GHZ; - wmip->wmi_ht_allowed[band] = (cmd->enable)? 1:0; - - htCap = (WMI_SET_HT_CAP_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(htCap, sizeof(*htCap)); - memcpy(htCap, cmd, sizeof(*htCap)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_HT_CAP_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_ht_op_cmd(struct wmi_t *wmip, u8 sta_chan_width) -{ - void *osbuf; - WMI_SET_HT_OP_CMD *htInfo; - - osbuf = A_NETBUF_ALLOC(sizeof(*htInfo)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*htInfo)); - - htInfo = (WMI_SET_HT_OP_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(htInfo, sizeof(*htInfo)); - htInfo->sta_chan_width = sta_chan_width; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_HT_OP_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_tx_select_rates_cmd(struct wmi_t *wmip, u32 *pMaskArray) -{ - void *osbuf; - WMI_SET_TX_SELECT_RATES_CMD *pData; - - osbuf = A_NETBUF_ALLOC(sizeof(*pData)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*pData)); - - pData = (WMI_SET_TX_SELECT_RATES_CMD *)(A_NETBUF_DATA(osbuf)); - memcpy(pData, pMaskArray, sizeof(*pData)); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_TX_SELECT_RATES_CMDID, - NO_SYNC_WMIFLAG)); -} - - -int -wmi_send_hci_cmd(struct wmi_t *wmip, u8 *buf, u16 sz) -{ - void *osbuf; - WMI_HCI_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd) + sz); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd) + sz); - cmd = (WMI_HCI_CMD *)(A_NETBUF_DATA(osbuf)); - - cmd->cmd_buf_sz = sz; - memcpy(cmd->buf, buf, sz); - return (wmi_cmd_send(wmip, osbuf, WMI_HCI_CMD_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_allow_aggr_cmd(struct wmi_t *wmip, u16 tx_tidmask, u16 rx_tidmask) -{ - void *osbuf; - WMI_ALLOW_AGGR_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_ALLOW_AGGR_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->tx_allow_aggr = tx_tidmask; - cmd->rx_allow_aggr = rx_tidmask; - - return (wmi_cmd_send(wmip, osbuf, WMI_ALLOW_AGGR_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_setup_aggr_cmd(struct wmi_t *wmip, u8 tid) -{ - void *osbuf; - WMI_ADDBA_REQ_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_ADDBA_REQ_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->tid = tid; - - return (wmi_cmd_send(wmip, osbuf, WMI_ADDBA_REQ_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_delete_aggr_cmd(struct wmi_t *wmip, u8 tid, bool uplink) -{ - void *osbuf; - WMI_DELBA_REQ_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_DELBA_REQ_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->tid = tid; - cmd->is_sender_initiator = uplink; /* uplink =1 - uplink direction, 0=downlink direction */ - - /* Delete the local aggr state, on host */ - return (wmi_cmd_send(wmip, osbuf, WMI_DELBA_REQ_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_set_rx_frame_format_cmd(struct wmi_t *wmip, u8 rxMetaVersion, - bool rxDot11Hdr, bool defragOnHost) -{ - void *osbuf; - WMI_RX_FRAME_FORMAT_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_RX_FRAME_FORMAT_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->dot11Hdr = (rxDot11Hdr==true)? 1:0; - cmd->defragOnHost = (defragOnHost==true)? 1:0; - cmd->metaVersion = rxMetaVersion; /* */ - - /* Delete the local aggr state, on host */ - return (wmi_cmd_send(wmip, osbuf, WMI_RX_FRAME_FORMAT_CMDID, NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_thin_mode_cmd(struct wmi_t *wmip, bool bThinMode) -{ - void *osbuf; - WMI_SET_THIN_MODE_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_THIN_MODE_CMD *)(A_NETBUF_DATA(osbuf)); - cmd->enable = (bThinMode==true)? 1:0; - - /* Delete the local aggr state, on host */ - return (wmi_cmd_send(wmip, osbuf, WMI_SET_THIN_MODE_CMDID, NO_SYNC_WMIFLAG)); -} - - -int -wmi_set_wlan_conn_precedence_cmd(struct wmi_t *wmip, BT_WLAN_CONN_PRECEDENCE precedence) -{ - void *osbuf; - WMI_SET_BT_WLAN_CONN_PRECEDENCE *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_BT_WLAN_CONN_PRECEDENCE *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->precedence = precedence; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_WLAN_CONN_PRECEDENCE_CMDID, - NO_SYNC_WMIFLAG)); -} - -int -wmi_set_pmk_cmd(struct wmi_t *wmip, u8 *pmk) -{ - void *osbuf; - WMI_SET_PMK_CMD *p; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_SET_PMK_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_SET_PMK_CMD)); - - p = (WMI_SET_PMK_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(p, sizeof(*p)); - - memcpy(p->pmk, pmk, WMI_PMK_LEN); - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMK_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_set_excess_tx_retry_thres_cmd(struct wmi_t *wmip, WMI_SET_EXCESS_TX_RETRY_THRES_CMD *cmd) -{ - void *osbuf; - WMI_SET_EXCESS_TX_RETRY_THRES_CMD *p; - - osbuf = A_NETBUF_ALLOC(sizeof(WMI_SET_EXCESS_TX_RETRY_THRES_CMD)); - if (osbuf == NULL) { - return A_NO_MEMORY; - } - - A_NETBUF_PUT(osbuf, sizeof(WMI_SET_EXCESS_TX_RETRY_THRES_CMD)); - - p = (WMI_SET_EXCESS_TX_RETRY_THRES_CMD *)(A_NETBUF_DATA(osbuf)); - memset(p, 0, sizeof(*p)); - - p->threshold = cmd->threshold; - - return (wmi_cmd_send(wmip, osbuf, WMI_SET_EXCESS_TX_RETRY_THRES_CMDID, NO_SYNC_WMIFLAG)); -} - -int -wmi_SGI_cmd(struct wmi_t *wmip, u32 sgiMask, u8 sgiPERThreshold) -{ - void *osbuf; - WMI_SET_TX_SGI_PARAM_CMD *cmd; - - osbuf = A_NETBUF_ALLOC(sizeof(*cmd)); - if (osbuf == NULL) { - return A_NO_MEMORY ; - } - - A_NETBUF_PUT(osbuf, sizeof(*cmd)); - - cmd = (WMI_SET_TX_SGI_PARAM_CMD *)(A_NETBUF_DATA(osbuf)); - A_MEMZERO(cmd, sizeof(*cmd)); - cmd->sgiMask = sgiMask; - cmd->sgiPERThreshold = sgiPERThreshold; - return (wmi_cmd_send(wmip, osbuf, WMI_SET_TX_SGI_PARAM_CMDID, - NO_SYNC_WMIFLAG)); -} - -bss_t * -wmi_find_matching_Ssidnode (struct wmi_t *wmip, u8 *pSsid, - u32 ssidLength, - u32 dot11AuthMode, u32 authMode, - u32 pairwiseCryptoType, u32 grpwiseCryptoTyp) -{ - bss_t *node = NULL; - node = wlan_find_matching_Ssidnode (&wmip->wmi_scan_table, pSsid, - ssidLength, dot11AuthMode, authMode, pairwiseCryptoType, grpwiseCryptoTyp); - - return node; -} - -u16 wmi_ieee2freq (int chan) -{ - u16 freq = 0; - freq = wlan_ieee2freq (chan); - return freq; - -} - -u32 wmi_freq2ieee (u16 freq) -{ - u16 chan = 0; - chan = wlan_freq2ieee (freq); - return chan; -} diff --git a/drivers/staging/ath6kl/wmi/wmi_host.h b/drivers/staging/ath6kl/wmi/wmi_host.h deleted file mode 100644 index 53e4f085dfe..00000000000 --- a/drivers/staging/ath6kl/wmi/wmi_host.h +++ /dev/null @@ -1,102 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved. -// -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// -//------------------------------------------------------------------------------ -//============================================================================== -// This file contains local definitios for the wmi host module. -// -// Author(s): ="Atheros" -//============================================================================== -#ifndef _WMI_HOST_H_ -#define _WMI_HOST_H_ - -#include "roaming.h" -#ifdef __cplusplus -extern "C" { -#endif - -struct wmi_stats { - u32 cmd_len_err; - u32 cmd_id_err; -}; - -#define SSID_IE_LEN_INDEX 13 - -/* Host side link management data structures */ -#define SIGNAL_QUALITY_THRESHOLD_LEVELS 6 -#define SIGNAL_QUALITY_UPPER_THRESHOLD_LEVELS SIGNAL_QUALITY_THRESHOLD_LEVELS -#define SIGNAL_QUALITY_LOWER_THRESHOLD_LEVELS SIGNAL_QUALITY_THRESHOLD_LEVELS -typedef struct sq_threshold_params_s { - s16 upper_threshold[SIGNAL_QUALITY_UPPER_THRESHOLD_LEVELS]; - s16 lower_threshold[SIGNAL_QUALITY_LOWER_THRESHOLD_LEVELS]; - u32 upper_threshold_valid_count; - u32 lower_threshold_valid_count; - u32 polling_interval; - u8 weight; - u8 last_rssi; //normally you would expect this to be bss specific but we keep only one instance because its only valid when the device is in a connected state. Not sure if it belongs to host or target. - u8 last_rssi_poll_event; //Not sure if it belongs to host or target -} SQ_THRESHOLD_PARAMS; - -/* - * These constants are used with A_WLAN_BAND_SET. - */ -#define A_BAND_24GHZ 0 -#define A_BAND_5GHZ 1 -#define A_NUM_BANDS 2 - -struct wmi_t { - bool wmi_ready; - bool wmi_numQoSStream; - u16 wmi_streamExistsForAC[WMM_NUM_AC]; - u8 wmi_fatPipeExists; - void *wmi_devt; - struct wmi_stats wmi_stats; - struct ieee80211_node_table wmi_scan_table; - u8 wmi_bssid[ATH_MAC_LEN]; - u8 wmi_powerMode; - u8 wmi_phyMode; - u8 wmi_keepaliveInterval; -#ifdef THREAD_X - A_CSECT_T wmi_lock; -#else - A_MUTEX_T wmi_lock; -#endif - HTC_ENDPOINT_ID wmi_endpoint_id; - SQ_THRESHOLD_PARAMS wmi_SqThresholdParams[SIGNAL_QUALITY_METRICS_NUM_MAX]; - CRYPTO_TYPE wmi_pair_crypto_type; - CRYPTO_TYPE wmi_grp_crypto_type; - bool wmi_is_wmm_enabled; - u8 wmi_ht_allowed[A_NUM_BANDS]; - u8 wmi_traffic_class; -}; - -#ifdef THREAD_X -#define INIT_WMI_LOCK(w) A_CSECT_INIT(&(w)->wmi_lock) -#define LOCK_WMI(w) A_CSECT_ENTER(&(w)->wmi_lock); -#define UNLOCK_WMI(w) A_CSECT_LEAVE(&(w)->wmi_lock); -#define DELETE_WMI_LOCK(w) A_CSECT_DELETE(&(w)->wmi_lock); -#else -#define LOCK_WMI(w) A_MUTEX_LOCK(&(w)->wmi_lock); -#define UNLOCK_WMI(w) A_MUTEX_UNLOCK(&(w)->wmi_lock); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _WMI_HOST_H_ */ From 43801f6e4ee269cd76f601c2b1d79897ea4a892f Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Wed, 20 Jul 2011 17:05:57 -0600 Subject: [PATCH 0215/1519] staging: zram: make global var "devices" use unique name The global variable "devices" is too general to be global. This patch switches the name to be "zram_devices". Signed-off-by: Noah Watkins Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 16 ++++++++-------- drivers/staging/zram/zram_drv.h | 2 +- drivers/staging/zram/zram_sysfs.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index d70ec1ad10d..11e7e92ae72 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -37,7 +37,7 @@ /* Globals */ static int zram_major; -struct zram *devices; +struct zram *zram_devices; /* Module params (documentation at end) */ unsigned int num_devices; @@ -801,14 +801,14 @@ static int __init zram_init(void) /* Allocate the device array and initialize each one */ pr_info("Creating %u devices ...\n", num_devices); - devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); - if (!devices) { + zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); + if (!zram_devices) { ret = -ENOMEM; goto unregister; } for (dev_id = 0; dev_id < num_devices; dev_id++) { - ret = create_device(&devices[dev_id], dev_id); + ret = create_device(&zram_devices[dev_id], dev_id); if (ret) goto free_devices; } @@ -817,8 +817,8 @@ static int __init zram_init(void) free_devices: while (dev_id) - destroy_device(&devices[--dev_id]); - kfree(devices); + destroy_device(&zram_devices[--dev_id]); + kfree(zram_devices); unregister: unregister_blkdev(zram_major, "zram"); out: @@ -831,7 +831,7 @@ static void __exit zram_exit(void) struct zram *zram; for (i = 0; i < num_devices; i++) { - zram = &devices[i]; + zram = &zram_devices[i]; destroy_device(zram); if (zram->init_done) @@ -840,7 +840,7 @@ static void __exit zram_exit(void) unregister_blkdev(zram_major, "zram"); - kfree(devices); + kfree(zram_devices); pr_debug("Cleanup done!\n"); } diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index abe5221c100..0e4b5409f9f 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -123,7 +123,7 @@ struct zram { struct zram_stats stats; }; -extern struct zram *devices; +extern struct zram *zram_devices; extern unsigned int num_devices; #ifdef CONFIG_SYSFS extern struct attribute_group zram_disk_attr_group; diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index a70cc010d18..0f001e89eb5 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -35,7 +35,7 @@ static struct zram *dev_to_zram(struct device *dev) struct zram *zram = NULL; for (i = 0; i < num_devices; i++) { - zram = &devices[i]; + zram = &zram_devices[i]; if (disk_to_dev(zram->disk) == dev) break; } From efd54f4375982a3f8bef3cce610955f4cc37d5cb Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Wed, 20 Jul 2011 17:06:08 -0600 Subject: [PATCH 0216/1519] staging: zram: make global var "num_devices" use unique name The global variable "num_devices" is too general to be global. This patch switches the name to be "zram_num_devices". Signed-off-by: Noah Watkins Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 22 +++++++++++----------- drivers/staging/zram/zram_drv.h | 2 +- drivers/staging/zram/zram_sysfs.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 11e7e92ae72..ec66b0a5873 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -40,7 +40,7 @@ static int zram_major; struct zram *zram_devices; /* Module params (documentation at end) */ -unsigned int num_devices; +unsigned int zram_num_devices; static void zram_stat_inc(u32 *v) { @@ -780,9 +780,9 @@ static int __init zram_init(void) { int ret, dev_id; - if (num_devices > max_num_devices) { + if (zram_num_devices > max_num_devices) { pr_warning("Invalid value for num_devices: %u\n", - num_devices); + zram_num_devices); ret = -EINVAL; goto out; } @@ -794,20 +794,20 @@ static int __init zram_init(void) goto out; } - if (!num_devices) { + if (!zram_num_devices) { pr_info("num_devices not specified. Using default: 1\n"); - num_devices = 1; + zram_num_devices = 1; } /* Allocate the device array and initialize each one */ - pr_info("Creating %u devices ...\n", num_devices); - zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); + pr_info("Creating %u devices ...\n", zram_num_devices); + zram_devices = kzalloc(zram_num_devices * sizeof(struct zram), GFP_KERNEL); if (!zram_devices) { ret = -ENOMEM; goto unregister; } - for (dev_id = 0; dev_id < num_devices; dev_id++) { + for (dev_id = 0; dev_id < zram_num_devices; dev_id++) { ret = create_device(&zram_devices[dev_id], dev_id); if (ret) goto free_devices; @@ -830,7 +830,7 @@ static void __exit zram_exit(void) int i; struct zram *zram; - for (i = 0; i < num_devices; i++) { + for (i = 0; i < zram_num_devices; i++) { zram = &zram_devices[i]; destroy_device(zram); @@ -844,8 +844,8 @@ static void __exit zram_exit(void) pr_debug("Cleanup done!\n"); } -module_param(num_devices, uint, 0); -MODULE_PARM_DESC(num_devices, "Number of zram devices"); +module_param(zram_num_devices, uint, 0); +MODULE_PARM_DESC(zram_num_devices, "Number of zram devices"); module_init(zram_init); module_exit(zram_exit); diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 0e4b5409f9f..59b01d602f4 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -124,7 +124,7 @@ struct zram { }; extern struct zram *zram_devices; -extern unsigned int num_devices; +extern unsigned int zram_num_devices; #ifdef CONFIG_SYSFS extern struct attribute_group zram_disk_attr_group; #endif diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index 0f001e89eb5..df1f9dc4269 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -34,7 +34,7 @@ static struct zram *dev_to_zram(struct device *dev) int i; struct zram *zram = NULL; - for (i = 0; i < num_devices; i++) { + for (i = 0; i < zram_num_devices; i++) { zram = &zram_devices[i]; if (disk_to_dev(zram->disk) == dev) break; From 30d6a2b870a2419e1e887bd3a46f33d98c61c778 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 26 Jul 2011 10:35:30 +0300 Subject: [PATCH 0217/1519] staging: vt6655: simplify MAC printing by using %pM Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 10 ++---- drivers/staging/vt6655/dpc.c | 30 ++++------------- drivers/staging/vt6655/wmgr.c | 49 ++++++---------------------- 3 files changed, 18 insertions(+), 71 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 3d2a9ba16b1..567df434318 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -815,14 +815,8 @@ else CARDbRadioPowerOn(pDevice); pMgmt->eScanType = WMAC_SCAN_PASSIVE; // get Permanent network address SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %02x-%02x-%02x=%02x-%02x-%02x\n", - pDevice->abyCurrentNetAddr[0], - pDevice->abyCurrentNetAddr[1], - pDevice->abyCurrentNetAddr[2], - pDevice->abyCurrentNetAddr[3], - pDevice->abyCurrentNetAddr[4], - pDevice->abyCurrentNetAddr[5]); - + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n", + pDevice->abyCurrentNetAddr); // reset Tx pointer CARDvSafeResetRx(pDevice); diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index cf0deacd9da..c0fab4bc870 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -1107,30 +1107,12 @@ static bool s_bAPModeRxCtl ( &Status ); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr3[0], - p802_11Header->abyAddr3[1], - p802_11Header->abyAddr3[2], - p802_11Header->abyAddr3[3], - p802_11Header->abyAddr3[4], - p802_11Header->abyAddr3[5] - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr2[0], - p802_11Header->abyAddr2[1], - p802_11Header->abyAddr2[2], - p802_11Header->abyAddr2[3], - p802_11Header->abyAddr2[4], - p802_11Header->abyAddr2[5] - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr1[0], - p802_11Header->abyAddr1[1], - p802_11Header->abyAddr1[2], - p802_11Header->abyAddr1[3], - p802_11Header->abyAddr1[4], - p802_11Header->abyAddr1[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%pM\n", + p802_11Header->abyAddr3); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%pM\n", + p802_11Header->abyAddr2); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%pM\n", + p802_11Header->abyAddr1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl ); VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc:pDevice->byRxMode = %x\n", pDevice->byRxMode ); diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index ab289c30edb..c46d51908ac 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -2521,14 +2521,8 @@ vMgrCreateOwnIBSS( if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { // AP mode BSSID = MAC addr memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:%pM\n", + pMgmt->abyCurrBSSID); } if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { @@ -2550,14 +2544,8 @@ vMgrCreateOwnIBSS( pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL; - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:%pM\n", + pMgmt->abyCurrBSSID); } // Set Capability Info @@ -2887,14 +2875,8 @@ vMgrJoinBSSBegin( // pDevice->bLinkPass = true; // memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n", + pMgmt->abyCurrBSSID); // Preamble type auto-switch: if AP can receive short-preamble cap, // and if registry setting is short preamble we can turn on too. @@ -2984,13 +2966,8 @@ s_vMgrSynchBSS ( MACvReadBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = %02x-%02x-%02x=%02x-%02x-%02x\n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5]); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = " + "%pM\n", pMgmt->abyCurrBSSID); if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) { if ((pMgmt->eConfigPHYMode == PHY_TYPE_11A) || @@ -4462,14 +4439,8 @@ s_vMgrRxProbeRequest( sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeProbeRequest(&sFrame); /* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n", - sFrame.pHdr->sA3.abyAddr2[0], - sFrame.pHdr->sA3.abyAddr2[1], - sFrame.pHdr->sA3.abyAddr2[2], - sFrame.pHdr->sA3.abyAddr2[3], - sFrame.pHdr->sA3.abyAddr2[4], - sFrame.pHdr->sA3.abyAddr2[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n", + sFrame.pHdr->sA3.abyAddr2); */ if (sFrame.pSSID->len != 0) { if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) From d6a32aa1b192ac9be8c1b8e8fa8beebf9415107d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 26 Jul 2011 10:35:31 +0300 Subject: [PATCH 0218/1519] staging: vt6656: use %pM for printing MACs Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/dpc.c | 30 ++++--------------- drivers/staging/vt6656/main_usb.c | 11 ++----- drivers/staging/vt6656/wmgr.c | 49 +++++++------------------------ 3 files changed, 18 insertions(+), 72 deletions(-) diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index cb817ced518..c0edf97535d 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -1109,30 +1109,12 @@ static BOOL s_bAPModeRxCtl ( &Status ); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr3[0], - p802_11Header->abyAddr3[1], - p802_11Header->abyAddr3[2], - p802_11Header->abyAddr3[3], - p802_11Header->abyAddr3[4], - p802_11Header->abyAddr3[5] - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr2[0], - p802_11Header->abyAddr2[1], - p802_11Header->abyAddr2[2], - p802_11Header->abyAddr2[3], - p802_11Header->abyAddr2[4], - p802_11Header->abyAddr2[5] - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%02x-%02x-%02x=%02x-%02x-%02x \n", - p802_11Header->abyAddr1[0], - p802_11Header->abyAddr1[1], - p802_11Header->abyAddr1[2], - p802_11Header->abyAddr1[3], - p802_11Header->abyAddr1[4], - p802_11Header->abyAddr1[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%pM\n", + p802_11Header->abyAddr3); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%pM\n", + p802_11Header->abyAddr2); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%pM\n", + p802_11Header->abyAddr1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl ); return TRUE; } diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index e18efd43e3e..73a08381910 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -611,17 +611,10 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) // if exist SW network address, use SW network address. - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %02x-%02x-%02x=%02x-%02x-%02x\n", - pDevice->abyCurrentNetAddr[0], - pDevice->abyCurrentNetAddr[1], - pDevice->abyCurrentNetAddr[2], - pDevice->abyCurrentNetAddr[3], - pDevice->abyCurrentNetAddr[4], - pDevice->abyCurrentNetAddr[5]); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n", + pDevice->abyCurrentNetAddr); } - - // Set BB and packet type at the same time. // Set Short Slot Time, xIFS, and RSPINF. if (pDevice->byBBType == BB_TYPE_11A) { diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index d67748f90b1..f08e2d15c7b 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -2477,14 +2477,8 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { // AP mode BSSID = MAC addr memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:" + "%pM\n", pMgmt->abyCurrBSSID); } if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { @@ -2506,14 +2500,8 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL; - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:" + "%pM\n", pMgmt->abyCurrBSSID); } // set BSSID filter @@ -2878,14 +2866,8 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%02x-%02x-%02x-%02x-%02x-%02x \n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n", + pMgmt->abyCurrBSSID); // Preamble type auto-switch: if AP can receive short-preamble cap, // and if registry setting is short preamble we can turn on too. @@ -2983,13 +2965,8 @@ s_vMgrSynchBSS ( memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, 6); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = %02x-%02x-%02x=%02x-%02x-%02x\n", - pMgmt->abyCurrBSSID[0], - pMgmt->abyCurrBSSID[1], - pMgmt->abyCurrBSSID[2], - pMgmt->abyCurrBSSID[3], - pMgmt->abyCurrBSSID[4], - pMgmt->abyCurrBSSID[5]); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = " + "%pM\n", pMgmt->abyCurrBSSID); if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) { if ((pDevice->eConfigPHYMode == PHY_TYPE_11A) || @@ -4334,14 +4311,8 @@ s_vMgrRxProbeRequest( sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; vMgrDecodeProbeRequest(&sFrame); /* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n", - sFrame.pHdr->sA3.abyAddr2[0], - sFrame.pHdr->sA3.abyAddr2[1], - sFrame.pHdr->sA3.abyAddr2[2], - sFrame.pHdr->sA3.abyAddr2[3], - sFrame.pHdr->sA3.abyAddr2[4], - sFrame.pHdr->sA3.abyAddr2[5] - ); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n", + sFrame.pHdr->sA3.abyAddr2); */ if (sFrame.pSSID->len != 0) { if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) From 24e2617050d9ceb2cd8200982249529c81c5f310 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 21 Jul 2011 20:37:43 -0700 Subject: [PATCH 0219/1519] staging: olpc_dcon: remove noinit module variable This came from Jordan's original 2007 gxfb_dcon commit. I've never seen or heard of it actually being used. Presumably it was once useful for skipping hardware initialization when reloading the module over and over during driver development.. Signed-off-by: Andres Salomon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 750fe5045ef..cf4b45440f6 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -36,9 +36,6 @@ static int resumeline = 898; module_param(resumeline, int, 0444); -static int noinit; -module_param(noinit, int, 0444); - /* Default off since it doesn't work on DCON ASIC in B-test OLPC board */ static int useaa = 1; module_param(useaa, int, 0444); @@ -90,7 +87,7 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) } } - if (ver < 0xdc02 && !noinit) { + if (ver < 0xdc02) { /* Initialize the DCON registers */ /* Start with work-arounds for DCON ASIC */ @@ -106,7 +103,7 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) i2c_smbus_write_word_data(client, 0x3b, 0x002b); i2c_smbus_write_word_data(client, 0x41, 0x0101); i2c_smbus_write_word_data(client, 0x42, 0x0101); - } else if (!noinit) { + } else { /* SDRAM setup/hold time */ i2c_smbus_write_word_data(client, 0x3a, 0xc040); i2c_smbus_write_word_data(client, 0x41, 0x0000); From 1b995ac22b53c6176e61a38558c8a8d16be24b69 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 21 Jul 2011 20:37:55 -0700 Subject: [PATCH 0220/1519] staging: olpc_dcon: drop support for DCON v1 The v1 DCONs only existed for XO-1 prototypes (and even then, very very early prototypes). Drop support for v1 DCON. Signed-off-by: Andres Salomon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 31 +++++++++------------------ 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index cf4b45440f6..ae18cd455fd 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -88,29 +88,18 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) } if (ver < 0xdc02) { - /* Initialize the DCON registers */ - - /* Start with work-arounds for DCON ASIC */ - i2c_smbus_write_word_data(client, 0x4b, 0x00cc); - i2c_smbus_write_word_data(client, 0x4b, 0x00cc); - i2c_smbus_write_word_data(client, 0x4b, 0x00cc); - i2c_smbus_write_word_data(client, 0x0b, 0x007a); - i2c_smbus_write_word_data(client, 0x36, 0x025c); - i2c_smbus_write_word_data(client, 0x37, 0x025e); - - /* Initialise SDRAM */ - - i2c_smbus_write_word_data(client, 0x3b, 0x002b); - i2c_smbus_write_word_data(client, 0x41, 0x0101); - i2c_smbus_write_word_data(client, 0x42, 0x0101); - } else { - /* SDRAM setup/hold time */ - i2c_smbus_write_word_data(client, 0x3a, 0xc040); - i2c_smbus_write_word_data(client, 0x41, 0x0000); - i2c_smbus_write_word_data(client, 0x41, 0x0101); - i2c_smbus_write_word_data(client, 0x42, 0x0101); + dev_err(&dcon->client->dev, + "DCON v1 is unsupported, giving up..\n"); + rc = -ENODEV; + goto err; } + /* SDRAM setup/hold time */ + i2c_smbus_write_word_data(client, 0x3a, 0xc040); + i2c_smbus_write_word_data(client, 0x41, 0x0000); + i2c_smbus_write_word_data(client, 0x41, 0x0101); + i2c_smbus_write_word_data(client, 0x42, 0x0101); + /* Colour swizzle, AA, no passthrough, backlight */ if (is_init) { dcon->disp_mode = MODE_PASSTHRU | MODE_BL_ENABLE | From 0b7a41ebb1bbee4be49e53497dc98e5517f2a2a8 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 21 Jul 2011 20:38:01 -0700 Subject: [PATCH 0221/1519] staging: olpc_dcon: replace remaining calls to i2c_smbus_read/write Use dcon_read and dcon_write; shorter, and understands the dcon_priv struct. This transition was started long ago. This converts the last few i2c_smbus_* callers. Signed-off-by: Andres Salomon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index ae18cd455fd..87268059eb4 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -65,11 +65,10 @@ static s32 dcon_read(struct dcon_priv *dcon, u8 reg) static int dcon_hw_init(struct dcon_priv *dcon, int is_init) { - struct i2c_client *client = dcon->client; uint16_t ver; int rc = 0; - ver = i2c_smbus_read_word_data(client, DCON_REG_ID); + ver = dcon_read(dcon, DCON_REG_ID); if ((ver >> 8) != 0xDC) { printk(KERN_ERR "olpc-dcon: DCON ID not 0xDCxx: 0x%04x " "instead.\n", ver); @@ -95,10 +94,10 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) } /* SDRAM setup/hold time */ - i2c_smbus_write_word_data(client, 0x3a, 0xc040); - i2c_smbus_write_word_data(client, 0x41, 0x0000); - i2c_smbus_write_word_data(client, 0x41, 0x0101); - i2c_smbus_write_word_data(client, 0x42, 0x0101); + dcon_write(dcon, 0x3a, 0xc040); + dcon_write(dcon, 0x41, 0x0000); + dcon_write(dcon, 0x41, 0x0101); + dcon_write(dcon, 0x42, 0x0101); /* Colour swizzle, AA, no passthrough, backlight */ if (is_init) { @@ -107,11 +106,11 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) if (useaa) dcon->disp_mode |= MODE_COL_AA; } - i2c_smbus_write_word_data(client, DCON_REG_MODE, dcon->disp_mode); + dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode); /* Set the scanline to interrupt on during resume */ - i2c_smbus_write_word_data(client, DCON_REG_SCAN_INT, resumeline); + dcon_write(dcon, DCON_REG_SCAN_INT, resumeline); err: return rc; From e1d94ecc1fbbabd3abb0f8c95ca7b2ea5ec2626d Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 14:16:23 +0300 Subject: [PATCH 0222/1519] Staging: keucr: Coding style fixes in smscsi.c I fixed whitespace, brace style and commetnt in smscsi.c Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/smscsi.c | 115 ++++++++++++++++----------------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/drivers/staging/keucr/smscsi.c b/drivers/staging/keucr/smscsi.c index a6fa77f9c48..58b55557118 100644 --- a/drivers/staging/keucr/smscsi.c +++ b/drivers/staging/keucr/smscsi.c @@ -9,36 +9,46 @@ #include "usb.h" #include "scsiglue.h" #include "transport.h" -//#include "smcommon.h" #include "smil.h" -int SM_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb); -int SM_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Start_Stop(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb); +int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb); extern PBYTE SMHostAddr; extern DWORD ErrXDCode; -//----- SM_SCSIIrp() -------------------------------------------------- +/* ----- SM_SCSIIrp() -------------------------------------------------- */ int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb) { int result; us->SrbStatus = SS_SUCCESS; - switch (srb->cmnd[0]) - { - case TEST_UNIT_READY : result = SM_SCSI_Test_Unit_Ready (us, srb); break; //0x00 - case INQUIRY : result = SM_SCSI_Inquiry (us, srb); break; //0x12 - case MODE_SENSE : result = SM_SCSI_Mode_Sense (us, srb); break; //0x1A - case READ_CAPACITY : result = SM_SCSI_Read_Capacity (us, srb); break; //0x25 - case READ_10 : result = SM_SCSI_Read (us, srb); break; //0x28 - case WRITE_10 : result = SM_SCSI_Write (us, srb); break; //0x2A + switch (srb->cmnd[0]) { + case TEST_UNIT_READY: + result = SM_SCSI_Test_Unit_Ready(us, srb); + break; /* 0x00 */ + case INQUIRY: + result = SM_SCSI_Inquiry(us, srb); + break; /* 0x12 */ + case MODE_SENSE: + result = SM_SCSI_Mode_Sense(us, srb); + break; /* 0x1A */ + case READ_CAPACITY: + result = SM_SCSI_Read_Capacity(us, srb); + break; /* 0x25 */ + case READ_10: + result = SM_SCSI_Read(us, srb); + break; /* 0x28 */ + case WRITE_10: + result = SM_SCSI_Write(us, srb); + break; /* 0x2A */ - default: + default: us->SrbStatus = SS_ILLEGAL_REQUEST; result = USB_STOR_TRANSPORT_FAILED; break; @@ -46,25 +56,22 @@ int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb) return result; } -//----- SM_SCSI_Test_Unit_Ready() -------------------------------------------------- +/* ----- SM_SCSI_Test_Unit_Ready() -------------------------------------------------- */ int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb) { - //printk("SM_SCSI_Test_Unit_Ready\n"); if (us->SM_Status.Insert && us->SM_Status.Ready) return USB_STOR_TRANSPORT_GOOD; - else - { + else { ENE_SMInit(us); return USB_STOR_TRANSPORT_GOOD; } - + return USB_STOR_TRANSPORT_GOOD; } -//----- SM_SCSI_Inquiry() -------------------------------------------------- +/* ----- SM_SCSI_Inquiry() -------------------------------------------------- */ int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb) { - //printk("SM_SCSI_Inquiry\n"); BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30}; usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF); @@ -72,11 +79,11 @@ int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb) } -//----- SM_SCSI_Mode_Sense() -------------------------------------------------- +/* ----- SM_SCSI_Mode_Sense() -------------------------------------------------- */ int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb) { - BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00}; - BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00}; + BYTE mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00}; + BYTE mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00}; if (us->SM_Status.WtP) usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF); @@ -87,7 +94,7 @@ int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb) return USB_STOR_TRANSPORT_GOOD; } -//----- SM_SCSI_Read_Capacity() -------------------------------------------------- +/* ----- SM_SCSI_Read_Capacity() -------------------------------------------------- */ int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb) { unsigned int offset = 0; @@ -100,45 +107,37 @@ int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb) bl_len = 0x200; bl_num = Ssfdc.MaxLogBlocks * Ssfdc.MaxSectors * Ssfdc.MaxZones - 1; - //printk("MaxLogBlocks = %x\n", Ssfdc.MaxLogBlocks); - //printk("MaxSectors = %x\n", Ssfdc.MaxSectors); - //printk("MaxZones = %x\n", Ssfdc.MaxZones); - //printk("bl_num = %x\n", bl_num); us->bl_num = bl_num; printk("bl_len = %x\n", bl_len); printk("bl_num = %x\n", bl_num); - //srb->request_bufflen = 8; - buf[0] = (bl_num>>24) & 0xff; - buf[1] = (bl_num>>16) & 0xff; - buf[2] = (bl_num>> 8) & 0xff; - buf[3] = (bl_num>> 0) & 0xff; - buf[4] = (bl_len>>24) & 0xff; - buf[5] = (bl_len>>16) & 0xff; - buf[6] = (bl_len>> 8) & 0xff; - buf[7] = (bl_len>> 0) & 0xff; - + buf[0] = (bl_num >> 24) & 0xff; + buf[1] = (bl_num >> 16) & 0xff; + buf[2] = (bl_num >> 8) & 0xff; + buf[3] = (bl_num >> 0) & 0xff; + buf[4] = (bl_len >> 24) & 0xff; + buf[5] = (bl_len >> 16) & 0xff; + buf[6] = (bl_len >> 8) & 0xff; + buf[7] = (bl_len >> 0) & 0xff; + usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF); - //usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF); return USB_STOR_TRANSPORT_GOOD; } -//----- SM_SCSI_Read() -------------------------------------------------- +/* ----- SM_SCSI_Read() -------------------------------------------------- */ int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) { - //struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; - int result=0; + int result = 0; PBYTE Cdb = srb->cmnd; - DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) | - ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff); - WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff); + DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) | + ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff); + WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff); DWORD blenByte = blen * 0x200; void *buf; - //printk("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg); - + if (bn > us->bl_num) return USB_STOR_TRANSPORT_ERROR; @@ -157,19 +156,17 @@ int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) return USB_STOR_TRANSPORT_GOOD; } -//----- SM_SCSI_Write() -------------------------------------------------- +/* ----- SM_SCSI_Write() -------------------------------------------------- */ int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb) { - //struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; - int result=0; + int result = 0; PBYTE Cdb = srb->cmnd; - DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) | - ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff); - WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff); + DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) | + ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff); + WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff); DWORD blenByte = blen * 0x200; void *buf; - //printk("SCSIOP_Write --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg); if (bn > us->bl_num) return USB_STOR_TRANSPORT_ERROR; From f647b49b8587ec4793d47f007f4c24689004b640 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 14:16:34 +0300 Subject: [PATCH 0223/1519] Staging: keucr: Coding style fixes in smil.h Fixed brace style in smil.h Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/smil.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/keucr/smil.h b/drivers/staging/keucr/smil.h index b5a8fa7c798..24a636a4aa1 100644 --- a/drivers/staging/keucr/smil.h +++ b/drivers/staging/keucr/smil.h @@ -177,8 +177,7 @@ struct SSFDCTYPE { WORD MaxLogBlocks; }; -typedef struct SSFDCTYPE_T -{ +typedef struct SSFDCTYPE_T { BYTE Model; BYTE Attribute; BYTE MaxZones; @@ -194,8 +193,7 @@ struct ADDRESS { WORD LogBlock; /* Logical Block Number of Zone */ }; -typedef struct ADDRESS_T -{ +typedef struct ADDRESS_T { BYTE Zone; /* Zone Number */ BYTE Sector; /* Sector(512byte) Number on Block */ WORD PhyBlock; /* Physical Block Number on Zone */ From 581cd7ee21db5c2a1f991adae8d2d889e79f5cb7 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 14:16:48 +0300 Subject: [PATCH 0224/1519] Staging: keucr: Coding style fixes in scsiglue.c Fixed macros in scsiglue.c Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/scsiglue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c index 135f7f21dfd..e1f3931d41e 100644 --- a/drivers/staging/keucr/scsiglue.c +++ b/drivers/staging/keucr/scsiglue.c @@ -144,7 +144,7 @@ static int command_abort(struct scsi_cmnd *srb) scsi_lock(us_to_host(us)); if (us->srb != srb) { scsi_unlock(us_to_host(us)); - printk ("-- nothing to abort\n"); + printk("-- nothing to abort\n"); return FAILED; } @@ -279,7 +279,8 @@ static int proc_info(struct Scsi_Host *host, char *buffer, char **start, pos += sprintf(pos, " Quirks:"); #define US_FLAG(name, value) \ - if (us->fflags & value) pos += sprintf(pos, " " #name); + if (us->fflags & value)\ + pos += sprintf(pos, " " #name); US_DO_ALL_FLAGS #undef US_FLAG From 74a5e01e40be81db3471bfa606f0f894582045be Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 14:17:04 +0300 Subject: [PATCH 0225/1519] Staging: keucr: Remove dead (comment) code in drivers/staging/keucr/smilsub.c Remove dead (comment) code in drivers/staging/keucr/smilsub.c Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/smilsub.c | 926 +------------------------------- 1 file changed, 10 insertions(+), 916 deletions(-) diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c index b315d5f8e19..4fcb7d6f3e9 100644 --- a/drivers/staging/keucr/smilsub.c +++ b/drivers/staging/keucr/smilsub.c @@ -2,10 +2,7 @@ #include "usb.h" #include "scsiglue.h" #include "transport.h" -//#include "init.h" -//#include "stdlib.h" -//#include "EUCR6SK.h" #include "smcommon.h" #include "smil.h" @@ -35,9 +32,7 @@ BYTE _Check_D_DevCode (BYTE); void _Set_D_ECCdata (BYTE,BYTE *); void _Calc_D_ECCdata (BYTE *); -//void SM_ReadDataWithDMA (PFDO_DEVICE_EXTENSION, BYTE *, WORD); -//void SM_WriteDataWithDMA (PFDO_DEVICE_EXTENSION, BYTE *, WORD); -// + struct SSFDCTYPE Ssfdc; struct ADDRESS Media; struct CIS_AREA CisArea; @@ -49,7 +44,7 @@ extern DWORD ErrXDCode; extern WORD ReadBlock; extern WORD WriteBlock; -//KEVENT SM_DMADoneEvent; + #define EVEN 0 // Even Page for 256byte/page #define ODD 1 // Odd Page for 256byte/page @@ -108,8 +103,6 @@ int Check_D_DataStatus(BYTE *redundant) int Load_D_LogBlockAddr(BYTE *redundant) { WORD addr1,addr2; - //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc; - //ADDRESS_T bb = (ADDRESS_T) &Media; addr1=(WORD)*(redundant+REDT_ADDR1H)*0x0100+(WORD)*(redundant+REDT_ADDR1L); addr2=(WORD)*(redundant+REDT_ADDR2H)*0x0100+(WORD)*(redundant+REDT_ADDR2L); @@ -177,27 +170,7 @@ void Set_D_DataStaus(BYTE *redundant) //----- Ssfdc_D_Reset() ------------------------------------------------ void Ssfdc_D_Reset(struct us_data *us) { - //NTSTATUS ntStatus = STATUS_SUCCESS; - //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - //BYTE buf[0x200]; - - //printk("Ssfdc_D_Reset --- But do nothing !!\n"); return; -/* RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW)); - pBulkCbw->dCBWSignature = CBW_SIGNTURE; - pBulkCbw->bCBWLun = CBW_LUN; - //pBulkCbw->dCBWDataTransferLength = 0x200; - pBulkCbw->bmCBWFlags = 0x80; - pBulkCbw->CBWCb[0] = 0xF2; - pBulkCbw->CBWCb[1] = 0x07; - - ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, NULL); - - if (!NT_SUCCESS(ntStatus)) - { - ENE_Print("Ssfdc_D_Reset Fail !!\n"); - //return ntStatus; - }*/ } //----- Ssfdc_D_ReadCisSect() ------------------------------------------ @@ -205,8 +178,6 @@ int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf,BYTE *redundant) { BYTE zone,sector; WORD block; - //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc; - //ADDRESS_T bb = (ADDRESS_T) &Media; zone=Media.Zone; block=Media.PhyBlock; sector=Media.Sector; Media.Zone=0; @@ -222,29 +193,7 @@ int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf,BYTE *redundant) Media.Zone=zone; Media.PhyBlock=block; Media.Sector=sector; return(SMSUCCESS); } -/* -////----- Ssfdc_D_WriteRedtMode() ---------------------------------------- -//void Ssfdc_D_WriteRedtMode(void) -//{ -// _Set_D_SsfdcRdCmd (RST_CHIP); -// _Check_D_SsfdcBusy (BUSY_RESET); -// _Set_D_SsfdcRdCmd (READ_REDT); -// _Check_D_SsfdcBusy (BUSY_READ); -// _Set_D_SsfdcRdStandby (); -//} -// -////----- Ssfdc_D_ReadID() ----------------------------------------------- -//void Ssfdc_D_ReadID(BYTE *buf, BYTE ReadID) -//{ -// _Set_D_SsfdcRdCmd (ReadID); -// _Set_D_SsfdcRdChip (); -// _Read_D_SsfdcByte (buf++); -// _Read_D_SsfdcByte (buf++); -// _Read_D_SsfdcByte (buf++); -// _Read_D_SsfdcByte (buf); -// _Set_D_SsfdcRdStandby (); -//} -*/ + // 6250 CMD 1 //----- Ssfdc_D_ReadSect() --------------------------------------------- int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant) @@ -305,7 +254,6 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) int result; WORD addr; - //printk("Ssfdc_D_ReadBlock\n"); result = ENE_LoadBinCode(us, SM_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { @@ -350,177 +298,15 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -/* -////----- Ssfdc_D_ReadSect_DMA() --------------------------------------------- -//int Ssfdc_D_ReadSect_DMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -//{ -// WORD SectByteCount, addr; -// DWORD Buffer[4]; -// WORD len; -// -// if (!_Hw_D_ChkCardIn()) -// return(ERROR); -// addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; -// addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector; -// // cycle starting address -// SM_STARTADDR_LSB = 0x00; -// SM_STARTADDR_IISB = (BYTE)addr; -// SM_STARTADDR_IIISB = (BYTE)(addr/0x0100); -// SM_STARTADDR_MSB = Media.Zone/2; -// -// //Sector byte count = 0x200(DMA) -// SectByteCount = 0x20f; -// SM_BYTECNT_LO = (BYTE)SectByteCount; -// SM_CMD_CTRL3 = (SM_CMD_CTRL3 & 0xFC) | (BYTE)(SectByteCount/0x0100); -// if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate ) -// SM_FIFO_CTRL = (SM_APB08_MASK | SM_DMAEN_MASK | SM_DMA_UPSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK); -// else -// SM_FIFO_CTRL = (SM_APB32_MASK | SM_DMAEN_MASK | SM_DMA_UPSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK); -// -// _Hw_D_EccRdReset(); -// _Hw_D_EccRdStart(); -// -// SM_CMD_CTRL1 = (SM_CMD_READ_1); -// SM_CMD_CTRL1 = (SM_CMD_READ_1 | SM_CMD_START_BIT); -// -// SectByteCount = 0x1ff; -// //SM_ReadDataWithDMA(fdoExt, buf, SectByteCount); -// //_ReadRedt_D_SsfdcBuf(redundant); -// len = 0x1000 - ((WORD)(buf) & 0x0FFF); -// if (len < 0x200) -// { -// SM_ReadDataWithDMA(fdoExt, buf, len-1); -// SM_ReadDataWithDMA(fdoExt, buf+len, SectByteCount-len); -// //ENE_Print("Read DMA !!! buf1 = %p, len = %x, buf2 = %p\n", buf, len, buf+len); -// } -// else -// SM_ReadDataWithDMA(fdoExt, buf, SectByteCount); -// -// if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate ) -// { -// _ReadRedt_D_SsfdcBuf(redundant); -// } -// else -// { -// Buffer[0] = READ_PORT_DWORD(SM_REG_DATA); -// Buffer[1] = READ_PORT_DWORD(SM_REG_DATA); -// Buffer[2] = READ_PORT_DWORD(SM_REG_DATA); -// Buffer[3] = READ_PORT_DWORD(SM_REG_DATA); -// memcpy(redundant, Buffer, 0x10); -// } -// -// while ( _Hw_D_ChkCardIn() ) -// { -// if((READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x10)) -// { -// WRITE_PORT_BYTE(SM_REG_INT_STATUS, 0x10); -// break; -// } -// } -// _Hw_D_EccRdStop(); -// _Hw_D_SetRdStandby(); -// _Load_D_SsfdcRdHwECC(EVEN); -// -// _Calc_D_ECCdata(buf); -// _Set_D_SsfdcRdStandby(); -// -// if (!_Hw_D_ChkCardIn()) -// return(ERROR); -// return(SMSUCCESS); -//} -// -////----- Ssfdc_D_ReadSect_PIO() --------------------------------------------- -//int Ssfdc_D_ReadSect_PIO(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -//{ -// _Set_D_SsfdcRdCmd(READ); -// _Set_D_SsfdcRdAddr(EVEN); -// -// if (_Check_D_SsfdcBusy(BUSY_READ)) -// { _Reset_D_SsfdcErr(); return(ERROR); } -// -// _Start_D_SsfdcRdHwECC(); -// _Read_D_SsfdcBuf(buf); -// _Stop_D_SsfdcRdHwECC(); -// _ReadRedt_D_SsfdcBuf(redundant); -// _Load_D_SsfdcRdHwECC(EVEN); -// -// if (_Check_D_SsfdcBusy(BUSY_READ)) -// { _Reset_D_SsfdcErr(); return(ERROR); } -// -// _Calc_D_ECCdata(buf); -// _Set_D_SsfdcRdStandby(); -// return(SMSUCCESS); -//} -// 6250 CMD 3 -//----- Ssfdc_D_WriteSect() -------------------------------------------- -int Ssfdc_D_WriteSect(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -{ - PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - NTSTATUS ntStatus; - WORD addr; - //ENE_Print("SMILSUB --- Ssfdc_D_WriteSect\n"); - ENE_LoadBinCode(fdoExt, SM_RW_PATTERN); - - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; - - // Write sect data - RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW)); - pBulkCbw->dCBWSignature = CBW_SIGNTURE; - pBulkCbw->bCBWLun = CBW_LUN; - pBulkCbw->dCBWDataTransferLength = 0x200; - pBulkCbw->bmCBWFlags = 0x00; - pBulkCbw->CBWCb[0] = 0xF0; - pBulkCbw->CBWCb[1] = 0x04; - //pBulkCbw->CBWCb[4] = (BYTE)addr; - //pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100); - //pBulkCbw->CBWCb[2] = Media.Zone/2; - //pBulkCbw->CBWCb[5] = *(redundant+REDT_ADDR1H); - //pBulkCbw->CBWCb[6] = *(redundant+REDT_ADDR1L); - pBulkCbw->CBWCb[7] = (BYTE)addr; - pBulkCbw->CBWCb[6] = (BYTE)(addr/0x0100); - pBulkCbw->CBWCb[5] = Media.Zone/2; - pBulkCbw->CBWCb[8] = *(redundant+REDT_ADDR1H); - pBulkCbw->CBWCb[9] = *(redundant+REDT_ADDR1L); - - ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_WRITE, buf); - - if (!NT_SUCCESS(ntStatus)) - return(ERROR); - -// // For Test -// { -// BYTE bf[0x200], rdd[0x10]; -// ULONG i; -// -// RtlZeroMemory(bf, 0x200); -// RtlZeroMemory(rdd, 0x10); -// ntStatus = SM_ReadBlock(fdoExt, bf, rdd); -// for (i=0; i<0x200; i++) -// { -// if (buf[i] != bf[i]) -// ENE_Print("buf[%x] = %x, bf[%x] = %x\n", buf, bf); -// } -// if (!NT_SUCCESS(ntStatus)) -// ENE_Print("Error\n"); -// } - - return(SMSUCCESS); -} -*/ //----- Ssfdc_D_CopyBlock() -------------------------------------------- int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; - //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - //NTSTATUS ntStatus; WORD ReadAddr, WriteAddr; - //printk("Ssfdc_D_WriteSect --- ZONE = %x, ReadBlock = %x, WriteBlock = %x\n", Media.Zone, ReadBlock, WriteBlock); - result = ENE_LoadBinCode(us, SM_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { @@ -562,184 +348,14 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -/* -//----- Ssfdc_D_WriteBlock() -------------------------------------------- -int Ssfdc_D_WriteBlock(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf,BYTE *redundant) -{ - PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - NTSTATUS ntStatus; - WORD addr; - //ENE_Print("SMILSUB --- Ssfdc_D_WriteSect\n"); - ENE_LoadBinCode(fdoExt, SM_RW_PATTERN); - - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; - - // Write sect data - RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW)); - pBulkCbw->dCBWSignature = CBW_SIGNTURE; - pBulkCbw->bCBWLun = CBW_LUN; - pBulkCbw->dCBWDataTransferLength = 0x200*count; - pBulkCbw->bmCBWFlags = 0x00; - pBulkCbw->CBWCb[0] = 0xF0; - pBulkCbw->CBWCb[1] = 0x04; - pBulkCbw->CBWCb[7] = (BYTE)addr; - pBulkCbw->CBWCb[6] = (BYTE)(addr/0x0100); - pBulkCbw->CBWCb[5] = Media.Zone/2; - pBulkCbw->CBWCb[8] = *(redundant+REDT_ADDR1H); - pBulkCbw->CBWCb[9] = *(redundant+REDT_ADDR1L); - - ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_WRITE, buf); - - if (!NT_SUCCESS(ntStatus)) - return(ERROR); - -// // For Test -// { -// BYTE bf[0x200], rdd[0x10]; -// ULONG i; -// -// RtlZeroMemory(bf, 0x200); -// RtlZeroMemory(rdd, 0x10); -// ntStatus = SM_ReadBlock(fdoExt, bf, rdd); -// for (i=0; i<0x200; i++) -// { -// if (buf[i] != bf[i]) -// ENE_Print("buf[%x] = %x, bf[%x] = %x\n", buf, bf); -// } -// if (!NT_SUCCESS(ntStatus)) -// ENE_Print("Error\n"); -// } - - return(SMSUCCESS); -} -// -////----- Ssfdc_D_WriteSect_DMA() -------------------------------------------- -//int Ssfdc_D_WriteSect_DMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -//{ -// WORD SectByteCount, addr; -// DWORD Buffer[4]; -// WORD len; -// -// if (!_Hw_D_ChkCardIn()) -// return(ERROR); -// addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; -// addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector; -// // cycle starting address -// SM_STARTADDR_LSB = 0x00; -// SM_STARTADDR_IISB = (BYTE)addr; -// SM_STARTADDR_IIISB = (BYTE)(addr/0x0100); -// SM_STARTADDR_MSB = Media.Zone/2; -// -// //Sector byte count (DMA) -// SectByteCount = 0x20f; -// SM_BYTECNT_LO = (BYTE)SectByteCount; -// SM_CMD_CTRL3 = (SM_CMD_CTRL3 & 0xFC) | 0x20 | (BYTE)(SectByteCount/0x0100); -// if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate ) -// SM_FIFO_CTRL = (SM_APB08_MASK | SM_DMAEN_MASK | SM_DMA_DOWNSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK); -// else -// SM_FIFO_CTRL = (SM_APB32_MASK | SM_DMAEN_MASK | SM_DMA_DOWNSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK); -// -// _Hw_D_EccRdReset(); -// _Hw_D_EccRdStart(); -// -// SM_CMD_CTRL1 = SM_CMD_PAGPRGM_TRUE; -// SM_CMD_CTRL1 = (SM_CMD_PAGPRGM_TRUE | SM_CMD_START_BIT); -// -// SectByteCount = 0x1ff; -// //SM_WriteDataWithDMA(fdoExt, buf, SectByteCount); -// //_WriteRedt_D_SsfdcBuf(redundant); -// len = 0x1000 - ((WORD)(buf) & 0x0FFF); -// if (len < 0x200) -// { -// SM_WriteDataWithDMA(fdoExt, buf, len-1); -// SM_WriteDataWithDMA(fdoExt, buf+len, SectByteCount-len); -// //ENE_Print("Read DMA !!! buf1 = %p, len = %x, buf2 = %p\n", buf, len, buf+len); -// } -// else -// SM_WriteDataWithDMA(fdoExt, buf, SectByteCount); -// -// //T1 = (ULONGLONG)buf & 0xFFFFFFFFFFFFF000; -// //T2 = ((ULONGLONG)buf + 0x1FF) & 0xFFFFFFFFFFFFF000; -// //if (T1 != T2) -// // ENE_Print("Ssfdc_D_WriteSect_DMA !!! buf = %p, T1 = %p, T2 = %p\n", buf, T1, T2); -// //if (T2-T1) -// //{ -// // l1 = (WORD)(T2 - (ULONGLONG)buf); -// // SM_WriteDataWithDMA(fdoExt, buf, l1-1); -// // SM_WriteDataWithDMA(fdoExt, (PBYTE)T2, SectByteCount-l1); -// //} -// //else -// // SM_WriteDataWithDMA(fdoExt, buf, SectByteCount); -// -// if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate ) -// { -// _WriteRedt_D_SsfdcBuf(redundant); -// } -// else -// { -// memcpy(Buffer, redundant, 0x10); -// WRITE_PORT_DWORD(SM_REG_DATA, Buffer[0]); -// WRITE_PORT_DWORD(SM_REG_DATA, Buffer[1]); -// WRITE_PORT_DWORD(SM_REG_DATA, Buffer[2]); -// WRITE_PORT_DWORD(SM_REG_DATA, Buffer[3]); -// } -// -// while ( _Hw_D_ChkCardIn() ) -// { -// if ((READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x10)) -// { -// WRITE_PORT_BYTE(SM_REG_INT_STATUS, 0x10); -// break; -// } -// } -// _Hw_D_EccRdStop(); -// _Hw_D_SetRdStandby(); -// -// _Set_D_SsfdcWrStandby(); -// _Set_D_SsfdcRdStandby(); -// if (!_Hw_D_ChkCardIn()) -// return(ERROR); -// -// return(SMSUCCESS); -//} -// -////----- Ssfdc_D_WriteSect_PIO() -------------------------------------------- -//int Ssfdc_D_WriteSect_PIO(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -//{ -// _Calc_D_ECCdata(buf); -// _Set_D_SsfdcWrCmd(WRDATA); -// _Set_D_SsfdcWrAddr(EVEN); -// _Start_D_SsfdcWrHwECC(); -// -// _Write_D_SsfdcBuf(buf); -// -// _Load_D_SsfdcWrHwECC(EVEN); -// _Set_D_ECCdata(EVEN,redundant); -// -// _WriteRedt_D_SsfdcBuf(redundant); -// -// _Set_D_SsfdcWrCmd(WRITE); -// -// if (_Check_D_SsfdcBusy(BUSY_PROG)) -// { _Reset_D_SsfdcErr(); return(ERROR); } -// -// _Set_D_SsfdcWrStandby(); -// _Set_D_SsfdcRdStandby(); -// return(SMSUCCESS); -//} -*/ //----- Ssfdc_D_WriteSectForCopy() ------------------------------------- int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; - //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - //NTSTATUS ntStatus; WORD addr; - //printk("SMILSUB --- Ssfdc_D_WriteSectForCopy\n"); result = ENE_LoadBinCode(us, SM_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { @@ -838,7 +454,6 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant) bcb->CDB[9] = 1; buf = kmalloc(0x10, GFP_KERNEL); - //result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0); result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0); memcpy(redundant, buf, 0x10); kfree(buf); @@ -854,8 +469,6 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; - //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - //NTSTATUS ntStatus; WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); @@ -890,347 +503,11 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) //----- Ssfdc_D_CheckStatus() ------------------------------------------ int Ssfdc_D_CheckStatus(void) { - // Driver ¤£°µ return(SMSUCCESS); - //_Set_D_SsfdcRdCmd(RDSTATUS); - // - //if (_Check_D_SsfdcStatus()) - //{ _Set_D_SsfdcRdStandby(); return(ERROR); } - // - //_Set_D_SsfdcRdStandby(); - //return(SMSUCCESS); } -/* -////NAND Memory (SmartMedia) Control Subroutine for Read Data -////----- _Set_D_SsfdcRdCmd() -------------------------------------------- -//void _Set_D_SsfdcRdCmd(BYTE cmd) -//{ -// _Hw_D_SetRdCmd(); -// _Hw_D_OutData(cmd); -// _Hw_D_SetRdData(); -//} -// -////----- _Set_D_SsfdcRdAddr() ------------------------------------------- -//void _Set_D_SsfdcRdAddr(BYTE add) -//{ -// WORD addr; -// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc; -// ADDRESS_T bb = (ADDRESS_T) &Media; -// -// addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; -// addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector; -// -// //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page -// // addr=addr*2+(WORD)add; -// -// _Hw_D_SetRdAddr(); -// _Hw_D_OutData(0x00); -// _Hw_D_OutData((BYTE)addr); -// _Hw_D_OutData((BYTE)(addr/0x0100)); -// -// if ((Ssfdc.Attribute &MADC)==AD4CYC) -// _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch -// -// _Hw_D_SetRdData(); -//} -// -////----- _Set_D_SsfdcRdChip() ------------------------------------------- -//void _Set_D_SsfdcRdChip(void) -//{ -// _Hw_D_SetRdAddr(); -// _Hw_D_OutData(0x00); -// _Hw_D_SetRdData(); -//} -// -////----- _Set_D_SsfdcRdStandby() ---------------------------------------- -//void _Set_D_SsfdcRdStandby(void) -//{ -// _Hw_D_SetRdStandby(); -//} -// -////----- _Start_D_SsfdcRdHwECC() ---------------------------------------- -//void _Start_D_SsfdcRdHwECC(void) -//{ -//#ifdef HW_ECC_SUPPORTED -// _Hw_D_EccRdReset(); -// _Hw_D_InData(); -// _Hw_D_EccRdStart(); -//#endif -//} -// -////----- _Stop_D_SsfdcRdHwECC() ----------------------------------------- -//void _Stop_D_SsfdcRdHwECC(void) -//{ -//#ifdef HW_ECC_SUPPORTED -// _Hw_D_EccRdStop(); -//#endif -//} -// -////----- _Load_D_SsfdcRdHwECC() ----------------------------------------- -//void _Load_D_SsfdcRdHwECC(BYTE add) -//{ -//#ifdef HW_ECC_SUPPORTED -// _Hw_D_EccRdRead(); -// //if (!(add==ODD && (Ssfdc.Attribute &MPS)==PS256)) -// { -// EccBuf[0]=_Hw_D_InData(); -// EccBuf[1]=_Hw_D_InData(); -// EccBuf[2]=_Hw_D_InData(); -// } -// -// //if (!(add==EVEN && (Ssfdc.Attribute &MPS)==PS256)) -// { -// EccBuf[3]=_Hw_D_InData(); -// EccBuf[4]=_Hw_D_InData(); -// EccBuf[5]=_Hw_D_InData(); -// } -// -// _Hw_D_EccRdStop(); -//#endif -//} -// -////NAND Memory (SmartMedia) Control Subroutine for Write Data -// -////----- _Set_D_SsfdcWrCmd() ----------------------------------------- -//void _Set_D_SsfdcWrCmd(BYTE cmd) -//{ -// _Hw_D_SetWrCmd(); -// _Hw_D_OutData(cmd); -// _Hw_D_SetWrData(); -//} -// -////----- _Set_D_SsfdcWrAddr() ----------------------------------------- -//void _Set_D_SsfdcWrAddr(BYTE add) -//{ -// WORD addr; -// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc; -// ADDRESS_T bb = (ADDRESS_T) &Media; -// -// addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; -// addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector; -// -// //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page -// // addr=addr*2+(WORD)add; -// -// _Hw_D_SetWrAddr(); -// _Hw_D_OutData(0x00); -// _Hw_D_OutData((BYTE)addr); -// _Hw_D_OutData((BYTE)(addr/0x0100)); -// -// if ((Ssfdc.Attribute &MADC)==AD4CYC) -// _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch -// -// _Hw_D_SetWrData(); -//} -// -////----- _Set_D_SsfdcWrBlock() ----------------------------------------- -//void _Set_D_SsfdcWrBlock(void) -//{ -// WORD addr; -// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc; -// ADDRESS_T bb = (ADDRESS_T) &Media; -// -// addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; -// addr=addr*(WORD)Ssfdc.MaxSectors; -// -// //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page -// // addr=addr*2; -// -// _Hw_D_SetWrAddr(); -// _Hw_D_OutData((BYTE)addr); -// _Hw_D_OutData((BYTE)(addr/0x0100)); -// -// if ((Ssfdc.Attribute &MADC)==AD4CYC) -// _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch -// -// _Hw_D_SetWrData(); -//} -// -////----- _Set_D_SsfdcWrStandby() ----------------------------------------- -//void _Set_D_SsfdcWrStandby(void) -//{ -// _Hw_D_SetWrStandby(); -//} -// -////----- _Start_D_SsfdcWrHwECC() ----------------------------------------- -//void _Start_D_SsfdcWrHwECC(void) -//{ -//#ifdef HW_ECC_SUPPORTED -// _Hw_D_EccWrReset(); -// _Hw_D_InData(); -// _Hw_D_EccWrStart(); -//#endif -//} -// -////----- _Load_D_SsfdcWrHwECC() ----------------------------------------- -//void _Load_D_SsfdcWrHwECC(BYTE add) -//{ -//#ifdef HW_ECC_SUPPORTED -// _Hw_D_EccWrRead(); -// //if (!(add==ODD && (Ssfdc.Attribute &MPS)==PS256)) -// { -// EccBuf[0]=_Hw_D_InData(); -// EccBuf[1]=_Hw_D_InData(); -// EccBuf[2]=_Hw_D_InData(); -// } -// -// //if (!(add==EVEN && (Ssfdc.Attribute &MPS)==PS256)) -// { -// EccBuf[3]=_Hw_D_InData(); -// EccBuf[4]=_Hw_D_InData(); -// EccBuf[5]=_Hw_D_InData(); -// } -// -// _Hw_D_EccWrStop(); -//#endif -//} -// -////NAND Memory (SmartMedia) Control Subroutine -////----- _Check_D_SsfdcBusy() ------------------------------------------- -//int _Check_D_SsfdcBusy(WORD time) -//{ -// WORD count = 0; -// -// do { -// if (!_Hw_D_ChkBusy()) -// return(SMSUCCESS); -// EDelay(100); -// count++; -// } while (count<=time); -// -// return(ERROR); -//} -// -////----- _Check_D_SsfdcStatus() ----------------------------------------- -//int _Check_D_SsfdcStatus(void) -//{ -// if (_Hw_D_InData() & WR_FAIL) -// return(ERROR); -// -// return(SMSUCCESS); -//} -// -//// For 712 -////----- _Reset_D_SsfdcErr() ----------------------------------------- -//void _Reset_D_SsfdcErr(void) -//{ -// WORD count = 0; -// -// _Hw_D_SetRdCmd(); -// _Hw_D_OutData(RST_CHIP); -// _Hw_D_SetRdData(); -// -// do { -// if (!_Hw_D_ChkBusy()) -// break; -// EDelay(100); -// count++; -// } while (count<=BUSY_RESET); -// -// _Hw_D_SetRdStandby(); -//} -// -////NAND Memory (SmartMedia) Buffer Data Xfer Subroutine -////----- SM_ReadDataWithDMA() ----------------------------------------- -//void SM_ReadDataWithDMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *databuf, WORD SectByteCount) -//{ -// PHYSICAL_ADDRESS Addr; -// LARGE_INTEGER ptimeout ; -// -// KeClearEvent(&fdoExt->SM_DMADoneEvent); -// -// Addr = MmGetPhysicalAddress(databuf); -// -// WRITE_PORT_DWORD(SM_DMA_ADDR_REG, (DWORD)Addr.LowPart); -// WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0); -// WRITE_PORT_WORD(SM_DMA_BYTE_COUNT_REG, SectByteCount); -// -// while ( _Hw_D_ChkCardIn() ) -// { -// if ((READ_PORT_BYTE(SM_REG_FIFO_STATUS) & 0x80)) -// break; -// } -// if (!_Hw_D_ChkCardIn()) return; -// WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0x01); -// -// ptimeout.QuadPart = 2000 * (-10000); // 2 sec -// KeWaitForSingleObject(&fdoExt->SM_DMADoneEvent, Executive, KernelMode, FALSE, &ptimeout); -// _Hw_D_SetDMAIntMask(); -//} -// -////----- SM_WriteDataWithDMA() ----------------------------------------- -//void SM_WriteDataWithDMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *databuf, WORD SectByteCount) -//{ -// PHYSICAL_ADDRESS Addr; -// LARGE_INTEGER ptimeout ; -// -// KeClearEvent(&fdoExt->SM_DMADoneEvent); -// -// Addr = MmGetPhysicalAddress(databuf); -// -// WRITE_PORT_DWORD(SM_DMA_ADDR_REG, (DWORD)Addr.LowPart); -// WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 2); -// WRITE_PORT_WORD(SM_DMA_BYTE_COUNT_REG, SectByteCount); -// -// while ( _Hw_D_ChkCardIn() ) -// { -// if ((READ_PORT_BYTE(SM_REG_FIFO_STATUS) & 0x40)) -// break; -// } -// if (!_Hw_D_ChkCardIn()) return; -// WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0x03); -// -// ptimeout.QuadPart = 2000 * (-10000); // 2 sec -// KeWaitForSingleObject(&fdoExt->SM_DMADoneEvent, Executive, KernelMode, FALSE, &ptimeout); -// _Hw_D_SetDMAIntMask(); -//} -// -////----- _Read_D_SsfdcBuf() ----------------------------------------- -//void _Read_D_SsfdcBuf(BYTE *databuf) -//{ -// int i; -// -// //for(i=0x0000;i<(((Ssfdc.Attribute &MPS)==PS256)?0x0100:0x0200);i++) -// for(i=0; i<0x200; i++) -// *databuf++ =_Hw_D_InData(); -//} -// -////----- _Write_D_SsfdcBuf() ----------------------------------------- -//void _Write_D_SsfdcBuf(BYTE *databuf) -//{ -// int i; -// -// //for(i=0x0000;i<(((Ssfdc.Attribute &MPS)==PS256)?0x0100:0x0200);i++) -// for(i=0; i<0x200; i++) -// _Hw_D_OutData(*databuf++); -//} -// -////----- _Read_D_SsfdcByte() ----------------------------------------- -//void _Read_D_SsfdcByte(BYTE *databuf) -//{ -// *databuf=(BYTE)_Hw_D_InData(); -//} -// -////----- _ReadRedt_D_SsfdcBuf() ----------------------------------------- -//void _ReadRedt_D_SsfdcBuf(BYTE *redundant) -//{ -// char i; -// -// //for(i=0x00;i<(((Ssfdc.Attribute &MPS)==PS256)?0x08:0x10);i++) -// for(i=0; i<0x10; i++) -// redundant[i] =_Hw_D_InData(); -//} -// -////----- _WriteRedt_D_SsfdcBuf() ----------------------------------------- -//void _WriteRedt_D_SsfdcBuf(BYTE *redundant) -//{ -// char i; -// -// //for(i=0x00;i<(((Ssfdc.Attribute &MPS)==PS256)?0x08:0x10);i++) -// for(i=0; i<0x10; i++) -// _Hw_D_OutData(*redundant++); -//} -*/ + + + //SmartMedia ID Code Check & Mode Set Subroutine //----- Set_D_SsfdcModel() --------------------------------------------- int Set_D_SsfdcModel(BYTE dcode) @@ -1364,118 +641,10 @@ BYTE _Check_D_DevCode(BYTE dcode) default: return(NOSSFDC); } } -/* -////SmartMedia Power Control Subroutine -////----- Cnt_D_Reset() ---------------------------------------------- -//void Cnt_D_Reset(void) -//{ -// _Hw_D_LedOff(); -// _Hw_D_SetRdStandby(); -// _Hw_D_VccOff(); -//} -// -////----- Cnt_D_PowerOn() ---------------------------------------------- -//int Cnt_D_PowerOn(void) -//{ -// // No support 5V. -// _Hw_D_EnableVcc3VOn(); // Set SM_REG_CTRL_5 Reg. to 3V -// _Hw_D_VccOn(); -// _Hw_D_SetRdStandby(); -// _Wait_D_Timer(TIME_PON); -// -// if (_Hw_D_ChkPower()) -// { -// _Hw_D_EnableOB(); // Set SM_REG_CTRL_5 Reg. to 0x83 -// return(SMSUCCESS); -// } -// -// _Hw_D_SetVccOff(); -// return(ERROR); -//} -// -////----- Cnt_D_PowerOff() ---------------------------------------------- -//void Cnt_D_PowerOff(void) -//{ -// _Hw_D_SetRdStandby(); -// _Hw_D_SetVccOff(); -// _Hw_D_VccOff(); -//} -// -////----- Cnt_D_LedOn() ---------------------------------------------- -//void Cnt_D_LedOn(void) -//{ -// _Hw_D_LedOn(); -//} -// -////----- Cnt_D_LedOff() ---------------------------------------------- -//void Cnt_D_LedOff(void) -//{ -// _Hw_D_LedOff(); -//} -// -////----- Check_D_CntPower() ---------------------------------------------- -//int Check_D_CntPower(void) -//{ -// if (_Hw_D_ChkPower()) -// return(SMSUCCESS); // Power On -// -// return(ERROR); // Power Off -//} -// -////----- Check_D_CardExist() ---------------------------------------------- -//int Check_D_CardExist(void) -//{ -// char i,j,k; -// -// if (!_Hw_D_ChkStatus()) // Not Status Change -// if (_Hw_D_ChkCardIn()) -// return(SMSUCCESS); // Card exist in Slot -// -// for(i=0,j=0,k=0; i<16; i++) { -// if (_Hw_D_ChkCardIn()) // Status Change -// { -// j++; k=0; -// } -// else -// { -// j=0; k++; -// } -// -// if (j>3) -// return(SMSUCCESS); // Card exist in Slot -// if (k>3) -// return(ERROR); // NO Card exist in Slot -// -// _Wait_D_Timer(TIME_CDCHK); -// } -// -// return(ERROR); -//} -// -////----- Check_D_CardStsChg() ---------------------------------------------- -//int Check_D_CardStsChg(void) -//{ -// if (_Hw_D_ChkStatus()) -// return(ERROR); // Status Change -// -// return(SMSUCCESS); // Not Status Change -//} -// -////----- Check_D_SsfdcWP() ---------------------------------------------- -//int Check_D_SsfdcWP(void) -//{ // ERROR: WP, SMSUCCESS: Not WP -// char i; -// -// for(i=0; i<8; i++) { -// if (_Hw_D_ChkWP()) -// return(ERROR); -// _Wait_D_Timer(TIME_WPCHK); -// } -// -// return(SMSUCCESS); -//} -// -*/ + + + + //SmartMedia ECC Control Subroutine //----- Check_D_ReadError() ---------------------------------------------- int Check_D_ReadError(BYTE *redundant) @@ -1521,81 +690,6 @@ void Set_D_RightECC(BYTE *redundant) { // Driver ¤£°µ ECC Check return; - //StringCopy((char *)(redundant+0x0D),(char *)EccBuf,3); - //StringCopy((char *)(redundant+0x08),(char *)(EccBuf+0x03),3); } -/* -////----- _Calc_D_ECCdata() ---------------------------------------------- -//void _Calc_D_ECCdata(BYTE *buf) -//{ -//#ifdef HW_ECC_SUPPORTED -//#else -// _Calculate_D_SwECC(buf,EccBuf); -// buf+=0x0100; -// _Calculate_D_SwECC(buf,EccBuf+0x03); -//#endif -//} -// -////----- _Set_D_ECCdata() ---------------------------------------------- -//void _Set_D_ECCdata(BYTE add,BYTE *redundant) -//{ -// //if (add==EVEN && (Ssfdc.Attribute &MPS)==PS256) -// // return; -// -// // for 256byte/page -// StringCopy((char *)(redundant+0x0D),(char *)EccBuf,3); -// StringCopy((char *)(redundant+0x08),(char *)(EccBuf+0x03),3); -//} -*/ -/* -//----- SM_ReadBlock() --------------------------------------------- -int SM_ReadBlock(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant) -{ - PBULK_CBW pBulkCbw = fdoExt->pBulkCbw; - NTSTATUS ntStatus; - WORD addr; - ENE_LoadBinCode(fdoExt, SM_RW_PATTERN); - - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; - - // Read sect data - RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW)); - pBulkCbw->dCBWSignature = CBW_SIGNTURE; - pBulkCbw->bCBWLun = CBW_LUN; - pBulkCbw->dCBWDataTransferLength = 0x200; - pBulkCbw->bmCBWFlags = 0x80; - pBulkCbw->CBWCb[0] = 0xF1; - pBulkCbw->CBWCb[1] = 0x02; - pBulkCbw->CBWCb[4] = (BYTE)addr; - pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100); - pBulkCbw->CBWCb[2] = Media.Zone/2; - - ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, buf); - - if (!NT_SUCCESS(ntStatus)) - return(ERROR); - - // Read redundant - RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW)); - pBulkCbw->dCBWSignature = CBW_SIGNTURE; - pBulkCbw->bCBWLun = CBW_LUN; - pBulkCbw->dCBWDataTransferLength = 0x10; - pBulkCbw->bmCBWFlags = 0x80; - pBulkCbw->CBWCb[0] = 0xF1; - pBulkCbw->CBWCb[1] = 0x03; - pBulkCbw->CBWCb[4] = (BYTE)addr; - pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100); - pBulkCbw->CBWCb[2] = Media.Zone/2; - pBulkCbw->CBWCb[5] = 0; - pBulkCbw->CBWCb[6] = 1; - - ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, redundant); - - if (!NT_SUCCESS(ntStatus)) - return(ERROR); - - return(SMSUCCESS); -}*/ From 50d487e3cb01182e26a8a277bdc220058e32d697 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 14:17:23 +0300 Subject: [PATCH 0226/1519] Staging: keucr: fix comments, braces, whitespaces coding style issue in tm6000.h This is a patch to the smilsub.c file that fixed up comment, braces, whitespaces error found by the checkpatch.pl tools. Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/smilsub.c | 628 ++++++++++++++++---------------- 1 file changed, 313 insertions(+), 315 deletions(-) diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c index 4fcb7d6f3e9..d4dd5ed516c 100644 --- a/drivers/staging/keucr/smilsub.c +++ b/drivers/staging/keucr/smilsub.c @@ -6,31 +6,31 @@ #include "smcommon.h" #include "smil.h" -void _Set_D_SsfdcRdCmd (BYTE); -void _Set_D_SsfdcRdAddr (BYTE); -void _Set_D_SsfdcRdChip (void); -void _Set_D_SsfdcRdStandby (void); -void _Start_D_SsfdcRdHwECC (void); -void _Stop_D_SsfdcRdHwECC (void); -void _Load_D_SsfdcRdHwECC (BYTE); -void _Set_D_SsfdcWrCmd (BYTE); -void _Set_D_SsfdcWrAddr (BYTE); -void _Set_D_SsfdcWrBlock (void); -void _Set_D_SsfdcWrStandby (void); -void _Start_D_SsfdcWrHwECC (void); -void _Load_D_SsfdcWrHwECC (BYTE); -int _Check_D_SsfdcBusy (WORD); -int _Check_D_SsfdcStatus (void); -void _Reset_D_SsfdcErr (void); -void _Read_D_SsfdcBuf (BYTE *); -void _Write_D_SsfdcBuf (BYTE *); -void _Read_D_SsfdcByte (BYTE *); -void _ReadRedt_D_SsfdcBuf (BYTE *); -void _WriteRedt_D_SsfdcBuf (BYTE *); -BYTE _Check_D_DevCode (BYTE); +void _Set_D_SsfdcRdCmd(BYTE); +void _Set_D_SsfdcRdAddr(BYTE); +void _Set_D_SsfdcRdChip(void); +void _Set_D_SsfdcRdStandby(void); +void _Start_D_SsfdcRdHwECC(void); +void _Stop_D_SsfdcRdHwECC(void); +void _Load_D_SsfdcRdHwECC(BYTE); +void _Set_D_SsfdcWrCmd(BYTE); +void _Set_D_SsfdcWrAddr(BYTE); +void _Set_D_SsfdcWrBlock(void); +void _Set_D_SsfdcWrStandby(void); +void _Start_D_SsfdcWrHwECC(void); +void _Load_D_SsfdcWrHwECC(BYTE); +int _Check_D_SsfdcBusy(WORD); +int _Check_D_SsfdcStatus(void); +void _Reset_D_SsfdcErr(void); +void _Read_D_SsfdcBuf(BYTE *); +void _Write_D_SsfdcBuf(BYTE *); +void _Read_D_SsfdcByte(BYTE *); +void _ReadRedt_D_SsfdcBuf(BYTE *); +void _WriteRedt_D_SsfdcBuf(BYTE *); +BYTE _Check_D_DevCode(BYTE); -void _Set_D_ECCdata (BYTE,BYTE *); -void _Calc_D_ECCdata (BYTE *); +void _Set_D_ECCdata(BYTE, BYTE *); +void _Calc_D_ECCdata(BYTE *); struct SSFDCTYPE Ssfdc; @@ -46,173 +46,177 @@ extern WORD WriteBlock; -#define EVEN 0 // Even Page for 256byte/page -#define ODD 1 // Odd Page for 256byte/page +#define EVEN 0 /* Even Page for 256byte/page */ +#define ODD 1 /* Odd Page for 256byte/page */ -//SmartMedia Redundant buffer data Control Subroutine -//----- Check_D_DataBlank() -------------------------------------------- +/* SmartMedia Redundant buffer data Control Subroutine + *----- Check_D_DataBlank() -------------------------------------------- + */ int Check_D_DataBlank(BYTE *redundant) { char i; - for(i=0; iiobuf; int result; WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector; - // Read sect data + /* Read sect data */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x200; @@ -220,14 +224,14 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant) bcb->CDB[0] = 0xF1; bcb->CDB[1] = 0x02; bcb->CDB[4] = (BYTE)addr; - bcb->CDB[3] = (BYTE)(addr/0x0100); - bcb->CDB[2] = Media.Zone/2; + bcb->CDB[3] = (BYTE)(addr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - // Read redundant + /* Read redundant */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x10; @@ -235,8 +239,8 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant) bcb->CDB[0] = 0xF1; bcb->CDB[1] = 0x03; bcb->CDB[4] = (BYTE)addr; - bcb->CDB[3] = (BYTE)(addr/0x0100); - bcb->CDB[2] = Media.Zone/2; + bcb->CDB[3] = (BYTE)(addr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; bcb->CDB[8] = 0; bcb->CDB[9] = 1; @@ -247,24 +251,23 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -//----- Ssfdc_D_ReadBlock() --------------------------------------------- -int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) +/* ----- Ssfdc_D_ReadBlock() --------------------------------------------- */ +int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector; - // Read sect data + /* Read sect data */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x200*count; @@ -272,14 +275,14 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) bcb->CDB[0] = 0xF1; bcb->CDB[1] = 0x02; bcb->CDB[4] = (BYTE)addr; - bcb->CDB[3] = (BYTE)(addr/0x0100); - bcb->CDB[2] = Media.Zone/2; + bcb->CDB[3] = (BYTE)(addr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - // Read redundant + /* Read redundant */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x10; @@ -287,8 +290,8 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) bcb->CDB[0] = 0xF1; bcb->CDB[1] = 0x03; bcb->CDB[4] = (BYTE)addr; - bcb->CDB[3] = (BYTE)(addr/0x0100); - bcb->CDB[2] = Media.Zone/2; + bcb->CDB[3] = (BYTE)(addr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; bcb->CDB[8] = 0; bcb->CDB[9] = 1; @@ -300,26 +303,25 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) } -//----- Ssfdc_D_CopyBlock() -------------------------------------------- -int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) +/* ----- Ssfdc_D_CopyBlock() -------------------------------------------- */ +int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; WORD ReadAddr, WriteAddr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - ReadAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks+ReadBlock; + ReadAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks + ReadBlock; ReadAddr = ReadAddr*(WORD)Ssfdc.MaxSectors; - WriteAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks+WriteBlock; + WriteAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks + WriteBlock; WriteAddr = WriteAddr*(WORD)Ssfdc.MaxSectors; - // Write sect data + /* Write sect data */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x200*count; @@ -327,19 +329,17 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) bcb->CDB[0] = 0xF0; bcb->CDB[1] = 0x08; bcb->CDB[7] = (BYTE)WriteAddr; - bcb->CDB[6] = (BYTE)(WriteAddr/0x0100); - bcb->CDB[5] = Media.Zone/2; - bcb->CDB[8] = *(redundant+REDT_ADDR1H); - bcb->CDB[9] = *(redundant+REDT_ADDR1L); + bcb->CDB[6] = (BYTE)(WriteAddr / 0x0100); + bcb->CDB[5] = Media.Zone / 2; + bcb->CDB[8] = *(redundant + REDT_ADDR1H); + bcb->CDB[9] = *(redundant + REDT_ADDR1L); bcb->CDB[10] = Media.Sector; - if (ReadBlock != NO_ASSIGN) - { + if (ReadBlock != NO_ASSIGN) { bcb->CDB[4] = (BYTE)ReadAddr; - bcb->CDB[3] = (BYTE)(ReadAddr/0x0100); - bcb->CDB[2] = Media.Zone/2; - } - else + bcb->CDB[3] = (BYTE)(ReadAddr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; + } else bcb->CDB[11] = 1; result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0); @@ -349,25 +349,24 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -//----- Ssfdc_D_WriteSectForCopy() ------------------------------------- +/* ----- Ssfdc_D_WriteSectForCopy() ------------------------------------- */ int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; - WORD addr; + WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector; - // Write sect data + /* Write sect data */ memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = 0x200; @@ -375,10 +374,10 @@ int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant) bcb->CDB[0] = 0xF0; bcb->CDB[1] = 0x04; bcb->CDB[7] = (BYTE)addr; - bcb->CDB[6] = (BYTE)(addr/0x0100); - bcb->CDB[5] = Media.Zone/2; - bcb->CDB[8] = *(redundant+REDT_ADDR1H); - bcb->CDB[9] = *(redundant+REDT_ADDR1L); + bcb->CDB[6] = (BYTE)(addr / 0x0100); + bcb->CDB[5] = Media.Zone / 2; + bcb->CDB[8] = *(redundant + REDT_ADDR1H); + bcb->CDB[9] = *(redundant + REDT_ADDR1L); result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0); if (result != USB_STOR_XFER_GOOD) @@ -387,8 +386,8 @@ int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -// 6250 CMD 5 -//----- Ssfdc_D_EraseBlock() ------------------------------------------- +/* 6250 CMD 5 */ +/* ----- Ssfdc_D_EraseBlock() ------------------------------------------- */ int Ssfdc_D_EraseBlock(struct us_data *us) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; @@ -396,14 +395,13 @@ int Ssfdc_D_EraseBlock(struct us_data *us) WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr=addr*(WORD)Ssfdc.MaxSectors; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors; memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); @@ -412,8 +410,8 @@ int Ssfdc_D_EraseBlock(struct us_data *us) bcb->CDB[0] = 0xF2; bcb->CDB[1] = 0x06; bcb->CDB[7] = (BYTE)addr; - bcb->CDB[6] = (BYTE)(addr/0x0100); - bcb->CDB[5] = Media.Zone/2; + bcb->CDB[6] = (BYTE)(addr / 0x0100); + bcb->CDB[5] = Media.Zone / 2; result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0); if (result != USB_STOR_XFER_GOOD) @@ -422,24 +420,23 @@ int Ssfdc_D_EraseBlock(struct us_data *us) return USB_STOR_TRANSPORT_GOOD; } -// 6250 CMD 2 -//----- Ssfdc_D_ReadRedtData() ----------------------------------------- +/* 6250 CMD 2 */ +/*----- Ssfdc_D_ReadRedtData() ----------------------------------------- */ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; int result; WORD addr; - BYTE *buf; + BYTE *buf; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector; memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); @@ -448,8 +445,8 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant) bcb->CDB[0] = 0xF1; bcb->CDB[1] = 0x03; bcb->CDB[4] = (BYTE)addr; - bcb->CDB[3] = (BYTE)(addr/0x0100); - bcb->CDB[2] = Media.Zone/2; + bcb->CDB[3] = (BYTE)(addr / 0x0100); + bcb->CDB[2] = Media.Zone / 2; bcb->CDB[8] = 0; bcb->CDB[9] = 1; @@ -463,8 +460,8 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -// 6250 CMD 4 -//----- Ssfdc_D_WriteRedtData() ---------------------------------------- +/* 6250 CMD 4 */ +/* ----- Ssfdc_D_WriteRedtData() ---------------------------------------- */ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) { struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; @@ -472,14 +469,13 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) WORD addr; result = ENE_LoadBinCode(us, SM_RW_PATTERN); - if (result != USB_STOR_XFER_GOOD) - { + if (result != USB_STOR_XFER_GOOD) { printk("Load SM RW Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } - addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock; - addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector; + addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock; + addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector; memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); @@ -488,10 +484,10 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) bcb->CDB[0] = 0xF2; bcb->CDB[1] = 0x05; bcb->CDB[7] = (BYTE)addr; - bcb->CDB[6] = (BYTE)(addr/0x0100); - bcb->CDB[5] = Media.Zone/2; - bcb->CDB[8] = *(redundant+REDT_ADDR1H); - bcb->CDB[9] = *(redundant+REDT_ADDR1L); + bcb->CDB[6] = (BYTE)(addr / 0x0100); + bcb->CDB[5] = Media.Zone / 2; + bcb->CDB[8] = *(redundant + REDT_ADDR1H); + bcb->CDB[9] = *(redundant + REDT_ADDR1L); result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0); if (result != USB_STOR_XFER_GOOD) @@ -500,165 +496,167 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant) return USB_STOR_TRANSPORT_GOOD; } -//----- Ssfdc_D_CheckStatus() ------------------------------------------ +/* ----- Ssfdc_D_CheckStatus() ------------------------------------------ */ int Ssfdc_D_CheckStatus(void) { - return(SMSUCCESS); + return SMSUCCESS; } -//SmartMedia ID Code Check & Mode Set Subroutine -//----- Set_D_SsfdcModel() --------------------------------------------- +/* SmartMedia ID Code Check & Mode Set Subroutine + * ----- Set_D_SsfdcModel() --------------------------------------------- + */ int Set_D_SsfdcModel(BYTE dcode) { - switch (_Check_D_DevCode(dcode)) { - case SSFDC1MB: - Ssfdc.Model = SSFDC1MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256; - Ssfdc.MaxZones = 1; - Ssfdc.MaxBlocks = 256; - Ssfdc.MaxLogBlocks = 250; - Ssfdc.MaxSectors = 8; - break; - case SSFDC2MB: - Ssfdc.Model = SSFDC2MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256; - Ssfdc.MaxZones = 1; - Ssfdc.MaxBlocks = 512; - Ssfdc.MaxLogBlocks = 500; - Ssfdc.MaxSectors = 8; - break; - case SSFDC4MB: - Ssfdc.Model = SSFDC4MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512; - Ssfdc.MaxZones = 1; - Ssfdc.MaxBlocks = 512; - Ssfdc.MaxLogBlocks = 500; - Ssfdc.MaxSectors = 16; - break; - case SSFDC8MB: - Ssfdc.Model = SSFDC8MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512; - Ssfdc.MaxZones = 1; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 16; - break; - case SSFDC16MB: - Ssfdc.Model = SSFDC16MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512; - Ssfdc.MaxZones = 1; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC32MB: - Ssfdc.Model = SSFDC32MB; - Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512; - Ssfdc.MaxZones = 2; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC64MB: - Ssfdc.Model = SSFDC64MB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 4; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC128MB: - Ssfdc.Model = SSFDC128MB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 8; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC256MB: - Ssfdc.Model = SSFDC256MB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 16; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC512MB: - Ssfdc.Model = SSFDC512MB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 32; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC1GB: - Ssfdc.Model = SSFDC1GB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 64; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - case SSFDC2GB: - Ssfdc.Model = SSFDC2GB; - Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; - Ssfdc.MaxZones = 128; - Ssfdc.MaxBlocks = 1024; - Ssfdc.MaxLogBlocks = 1000; - Ssfdc.MaxSectors = 32; - break; - default: - Ssfdc.Model = NOSSFDC; - return(ERROR); - } + switch (_Check_D_DevCode(dcode)) { + case SSFDC1MB: + Ssfdc.Model = SSFDC1MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256; + Ssfdc.MaxZones = 1; + Ssfdc.MaxBlocks = 256; + Ssfdc.MaxLogBlocks = 250; + Ssfdc.MaxSectors = 8; + break; + case SSFDC2MB: + Ssfdc.Model = SSFDC2MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256; + Ssfdc.MaxZones = 1; + Ssfdc.MaxBlocks = 512; + Ssfdc.MaxLogBlocks = 500; + Ssfdc.MaxSectors = 8; + break; + case SSFDC4MB: + Ssfdc.Model = SSFDC4MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512; + Ssfdc.MaxZones = 1; + Ssfdc.MaxBlocks = 512; + Ssfdc.MaxLogBlocks = 500; + Ssfdc.MaxSectors = 16; + break; + case SSFDC8MB: + Ssfdc.Model = SSFDC8MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512; + Ssfdc.MaxZones = 1; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 16; + break; + case SSFDC16MB: + Ssfdc.Model = SSFDC16MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512; + Ssfdc.MaxZones = 1; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC32MB: + Ssfdc.Model = SSFDC32MB; + Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512; + Ssfdc.MaxZones = 2; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC64MB: + Ssfdc.Model = SSFDC64MB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 4; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC128MB: + Ssfdc.Model = SSFDC128MB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 8; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC256MB: + Ssfdc.Model = SSFDC256MB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 16; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC512MB: + Ssfdc.Model = SSFDC512MB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 32; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC1GB: + Ssfdc.Model = SSFDC1GB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 64; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + case SSFDC2GB: + Ssfdc.Model = SSFDC2GB; + Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512; + Ssfdc.MaxZones = 128; + Ssfdc.MaxBlocks = 1024; + Ssfdc.MaxLogBlocks = 1000; + Ssfdc.MaxSectors = 32; + break; + default: + Ssfdc.Model = NOSSFDC; + return ERROR; + } - return(SMSUCCESS); + return SMSUCCESS; } -//----- _Check_D_DevCode() --------------------------------------------- +/* ----- _Check_D_DevCode() --------------------------------------------- */ BYTE _Check_D_DevCode(BYTE dcode) { - switch(dcode){ - case 0x6E: - case 0xE8: - case 0xEC: return(SSFDC1MB); // 8Mbit (1M) NAND - case 0x64: - case 0xEA: return(SSFDC2MB); // 16Mbit (2M) NAND - case 0x6B: - case 0xE3: - case 0xE5: return(SSFDC4MB); // 32Mbit (4M) NAND - case 0xE6: return(SSFDC8MB); // 64Mbit (8M) NAND - case 0x73: return(SSFDC16MB); // 128Mbit (16M)NAND - case 0x75: return(SSFDC32MB); // 256Mbit (32M)NAND - case 0x76: return(SSFDC64MB); // 512Mbit (64M)NAND - case 0x79: return(SSFDC128MB); // 1Gbit(128M)NAND - case 0x71: return(SSFDC256MB); - case 0xDC: return(SSFDC512MB); - case 0xD3: return(SSFDC1GB); - case 0xD5: return(SSFDC2GB); - default: return(NOSSFDC); - } + switch (dcode) { + case 0x6E: + case 0xE8: + case 0xEC: return SSFDC1MB; /* 8Mbit (1M) NAND */ + case 0x64: + case 0xEA: return SSFDC2MB; /* 16Mbit (2M) NAND */ + case 0x6B: + case 0xE3: + case 0xE5: return SSFDC4MB; /* 32Mbit (4M) NAND */ + case 0xE6: return SSFDC8MB; /* 64Mbit (8M) NAND */ + case 0x73: return SSFDC16MB; /* 128Mbit (16M)NAND */ + case 0x75: return SSFDC32MB; /* 256Mbit (32M)NAND */ + case 0x76: return SSFDC64MB; /* 512Mbit (64M)NAND */ + case 0x79: return SSFDC128MB; /* 1Gbit(128M)NAND */ + case 0x71: return SSFDC256MB; + case 0xDC: return SSFDC512MB; + case 0xD3: return SSFDC1GB; + case 0xD5: return SSFDC2GB; + default: return NOSSFDC; + } } -//SmartMedia ECC Control Subroutine -//----- Check_D_ReadError() ---------------------------------------------- +/* SmartMedia ECC Control Subroutine + * ----- Check_D_ReadError() ---------------------------------------------- + */ int Check_D_ReadError(BYTE *redundant) { return SMSUCCESS; } -//----- Check_D_Correct() ---------------------------------------------- -int Check_D_Correct(BYTE *buf,BYTE *redundant) +/* ----- Check_D_Correct() ---------------------------------------------- */ +int Check_D_Correct(BYTE *buf, BYTE *redundant) { return SMSUCCESS; } -//----- Check_D_CISdata() ---------------------------------------------- +/* ----- Check_D_CISdata() ---------------------------------------------- */ int Check_D_CISdata(BYTE *buf, BYTE *redundant) { BYTE cis[] = {0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, @@ -685,10 +683,10 @@ int Check_D_CISdata(BYTE *buf, BYTE *redundant) return ERROR; } -//----- Set_D_RightECC() ---------------------------------------------- +/* ----- Set_D_RightECC() ---------------------------------------------- */ void Set_D_RightECC(BYTE *redundant) { - // Driver ¤£°µ ECC Check + /* Driver ECC Check */ return; } From 553a1a5065e478b8e2e75d523b7dc5d39920910b Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 17 Aug 2011 15:58:31 -0400 Subject: [PATCH 0227/1519] Staging: usbip: Remove trailing spaces. Remove trailing spaces to comply with the kernel coding style. Signed-off-by: Akshay Joshi Acked-by: matt mooney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub_dev.c | 4 ++-- drivers/staging/usbip/stub_rx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index fce22f2bd8b..1dacdc0c4e0 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -524,11 +524,11 @@ static void stub_disconnect(struct usb_interface *interface) } } -/* +/* * Presence of pre_reset and post_reset prevents the driver from being unbound * when the device is being reset */ - + int stub_pre_reset(struct usb_interface *interface) { dev_dbg(&interface->dev, "pre_reset\n"); diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index 538fb9ee341..1c1957f98e2 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -175,7 +175,7 @@ static int tweak_reset_device_cmd(struct urb *urb) dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); /* - * With the implementation of pre_reset and post_reset the driver no + * With the implementation of pre_reset and post_reset the driver no * longer unbinds. This allows the use of synchronous reset. */ From 97c451ca1094d9d1ed1f3bf7c7a8b65b783e37e0 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 17 Aug 2011 15:58:32 -0400 Subject: [PATCH 0228/1519] Staging: usbip: Fix braces and spaces to match coding style. Fix brace positioning and spaces at the start of lines in order to comply with the kernel coding style. Signed-off-by: Akshay Joshi Acked-by: matt mooney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub_dev.c | 2 +- drivers/staging/usbip/stub_rx.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 1dacdc0c4e0..77d64693b87 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -548,4 +548,4 @@ struct usb_driver stub_driver = { .id_table = stub_table, .pre_reset = stub_pre_reset, .post_reset = stub_post_reset, - }; +}; diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index 1c1957f98e2..6b4e3e182de 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -179,8 +179,7 @@ static int tweak_reset_device_cmd(struct urb *urb) * longer unbinds. This allows the use of synchronous reset. */ - if (usb_lock_device_for_reset(sdev->udev, sdev->interface)<0) - { + if (usb_lock_device_for_reset(sdev->udev, sdev->interface) < 0) { dev_err(&urb->dev->dev, "could not obtain lock to reset device\n"); return 0; } From 549fb1009755a6ca3cef30914b8c3529ca711947 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 19 Aug 2011 08:54:18 +0200 Subject: [PATCH 0229/1519] staging: usbip: userspace: Check return value for mkdir() mkdir() could fail, so we should check its return value. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbip_attach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index b7885a20275..bdf61c0fe69 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -51,7 +51,9 @@ static int record_connection(char *host, char *port, char *busid, int rhport) char buff[MAX_BUFF+1]; int ret; - mkdir(VHCI_STATE_PATH, 0700); + ret = mkdir(VHCI_STATE_PATH, 0700); + if (ret < 0) + return -1; snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport); From c8742cf07d01eadb8254eac76e4394229cd480d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Mon, 22 Aug 2011 09:52:47 +0800 Subject: [PATCH 0230/1519] staging: usbip: add a usbip protocol document Initial version of USBIP protocol document. Signed-off-by: David Chang Acked-by: matt mooney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/usbip_protocol.txt | 358 +++++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 drivers/staging/usbip/usbip_protocol.txt diff --git a/drivers/staging/usbip/usbip_protocol.txt b/drivers/staging/usbip/usbip_protocol.txt new file mode 100644 index 00000000000..84e353b714b --- /dev/null +++ b/drivers/staging/usbip/usbip_protocol.txt @@ -0,0 +1,358 @@ +PRELIMINARY DRAFT, MAY CONTAIN MISTAKES! +28 Jun 2011 + +The USB/IP protocol follows a server/client architecture. The server exports the +USB devices and the clients imports them. The device driver for the exported +USB device runs on the client machine. + +The client may ask for the list of the exported USB devices. To get the list the +client opens a TCP/IP connection towards the server, and sends an OP_REQ_DEVLIST +packet on top of the TCP/IP connection (so the actual OP_REQ_DEVLIST may be sent +in one or more pieces at the low level transport layer). The server sends back +the OP_REP_DEVLIST packet which lists the exported USB devices. Finally the +TCP/IP connection is closed. + + virtual host controller usb host + "client" "server" + (imports USB devices) (exports USB devices) + | | + | OP_REQ_DEVLIST | + | ----------------------------------------------> | + | | + | OP_REP_DEVLIST | + | <---------------------------------------------- | + | | + +Once the client knows the list of exported USB devices it may decide to use one +of them. First the client opens a TCP/IP connection towards the server and +sends an OP_REQ_IMPORT packet. The server replies with OP_REP_IMPORT. If the +import was successful the TCP/IP connection remains open and will be used +to trasfer the URB traffic between the client and the server. The client may +send two types of packets: the USBIP_CMD_SUBMIT to submit an URB, and +USBIP_CMD_UNLINK to unlink a previously submitted URB. The answers of the +server may be USBIP_RET_SUBMIT and USBIP_RET_UNLINK respectively. + + virtual host controller usb host + "client" "server" + (imports USB devices) (exports USB devices) + | | + | OP_REQ_IMPORT | + | ----------------------------------------------> | + | | + | OP_REP_IMPORT | + | <---------------------------------------------- | + | | + | | + | USBIP_CMD_SUBMIT(seqnum = n) | + | ----------------------------------------------> | + | | + | USBIP_RET_SUBMIT(seqnum = n) | + | <---------------------------------------------- | + | . | + | : | + | | + | USBIP_CMD_SUBMIT(seqnum = m) | + | ----------------------------------------------> | + | | + | USBIP_CMD_SUBMIT(seqnum = m+1) | + | ----------------------------------------------> | + | | + | USBIP_CMD_SUBMIT(seqnum = m+2) | + | ----------------------------------------------> | + | | + | USBIP_RET_SUBMIT(seqnum = m) | + | <---------------------------------------------- | + | | + | USBIP_CMD_SUBMIT(seqnum = m+3) | + | ----------------------------------------------> | + | | + | USBIP_RET_SUBMIT(seqnum = m+1) | + | <---------------------------------------------- | + | | + | USBIP_CMD_SUBMIT(seqnum = m+4) | + | ----------------------------------------------> | + | | + | USBIP_RET_SUBMIT(seqnum = m+2) | + | <---------------------------------------------- | + | . | + | : | + | | + | USBIP_CMD_UNLINK | + | ----------------------------------------------> | + | | + | USBIP_RET_UNLINK | + | <---------------------------------------------- | + | | + +The fields are in network (big endian) byte order meaning that the most significant +byte (MSB) is stored at the lowest address. + + +OP_REQ_DEVLIST: Retrieve the list of exported USB devices. + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0 +-----------+--------+------------+--------------------------------------------------- + 2 | 2 | 0x8005 | Command code: Retrieve the list of exported USB + | | | devices. +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | 0x00000000 | Status: unused, shall be set to 0 + +OP_REP_DEVLIST: Reply with the list of exported USB devices. + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0. +-----------+--------+------------+--------------------------------------------------- + 2 | 2 | 0x0005 | Reply code: The list of exported USB devices. +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | 0x00000000 | Status: 0 for OK +-----------+--------+------------+--------------------------------------------------- + 8 | 4 | n | Number of exported devices: 0 means no exported + | | | devices. +-----------+--------+------------+--------------------------------------------------- + 0x0C | | | From now on the exported n devices are described, + | | | if any. If no devices are exported the message + | | | ends with the previous "number of exported + | | | devices" field. +-----------+--------+------------+--------------------------------------------------- + | 256 | | path: Path of the device on the host exporting the + | | | USB device, string closed with zero byte, e.g. + | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2" + | | | The unused bytes shall be filled with zero + | | | bytes. +-----------+--------+------------+--------------------------------------------------- + 0x10C | 32 | | busid: Bus ID of the exported device, string + | | | closed with zero byte, e.g. "3-2". The unused + | | | bytes shall be filled with zero bytes. +-----------+--------+------------+--------------------------------------------------- + 0x12C | 4 | | busnum +-----------+--------+------------+--------------------------------------------------- + 0x130 | 4 | | devnum +-----------+--------+------------+--------------------------------------------------- + 0x134 | 4 | | speed +-----------+--------+------------+--------------------------------------------------- + 0x138 | 2 | | idVendor +-----------+--------+------------+--------------------------------------------------- + 0x13A | 2 | | idProduct +-----------+--------+------------+--------------------------------------------------- + 0x13C | 2 | | bcdDevice +-----------+--------+------------+--------------------------------------------------- + 0x13E | 1 | | bDeviceClass +-----------+--------+------------+--------------------------------------------------- + 0x13F | 1 | | bDeviceSubClass +-----------+--------+------------+--------------------------------------------------- + 0x140 | 1 | | bDeviceProtocol +-----------+--------+------------+--------------------------------------------------- + 0x141 | 1 | | bConfigurationValue +-----------+--------+------------+--------------------------------------------------- + 0x142 | 1 | | bNumConfigurations +-----------+--------+------------+--------------------------------------------------- + 0x143 | 1 | | bNumInterfaces +-----------+--------+------------+--------------------------------------------------- + 0x144 | | m_0 | From now on each interface is described, all + | | | together bNumInterfaces times, with the + | | | the following 4 fields: +-----------+--------+------------+--------------------------------------------------- + | 1 | | bInterfaceClass +-----------+--------+------------+--------------------------------------------------- + 0x145 | 1 | | bInterfaceSubClass +-----------+--------+------------+--------------------------------------------------- + 0x146 | 1 | | bInterfaceProtocol +-----------+--------+------------+--------------------------------------------------- + 0x147 | 1 | | padding byte for alignment, shall be set to zero +-----------+--------+------------+--------------------------------------------------- + 0xC + | | | The second exported USB device starts at i=1 + i*0x138 + | | | with the busid field. + m_(i-1)*4 | | | + +OP_REQ_IMPORT: Request to import (attach) a remote USB device. + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0 +-----------+--------+------------+--------------------------------------------------- + 2 | 2 | 0x8003 | Command code: import a remote USB device. +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | 0x00000000 | Status: unused, shall be set to 0 +-----------+--------+------------+--------------------------------------------------- + 8 | 32 | | busid: the busid of the exported device on the + | | | remote host. The possible values are taken + | | | from the message field OP_REP_DEVLIST.busid. + | | | A string closed with zero, the unused bytes + | | | shall be filled with zeros. +-----------+--------+------------+--------------------------------------------------- + +OP_REP_IMPORT: Reply to import (attach) a remote USB device. + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0 +-----------+--------+------------+--------------------------------------------------- + 2 | 2 | 0x0003 | Reply code: Reply to import. +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | 0x00000000 | Status: 0 for OK + | | | 1 for error +-----------+--------+------------+--------------------------------------------------- + 8 | | | From now on comes the details of the imported + | | | device, if the previous status field was OK (0), + | | | otherwise the reply ends with the status field. +-----------+--------+------------+--------------------------------------------------- + | 256 | | path: Path of the device on the host exporting the + | | | USB device, string closed with zero byte, e.g. + | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2" + | | | The unused bytes shall be filled with zero + | | | bytes. +-----------+--------+------------+--------------------------------------------------- + 0x108 | 32 | | busid: Bus ID of the exported device, string + | | | closed with zero byte, e.g. "3-2". The unused + | | | bytes shall be filled with zero bytes. +-----------+--------+------------+--------------------------------------------------- + 0x128 | 4 | | busnum +-----------+--------+------------+--------------------------------------------------- + 0x12C | 4 | | devnum +-----------+--------+------------+--------------------------------------------------- + 0x130 | 4 | | speed +-----------+--------+------------+--------------------------------------------------- + 0x134 | 2 | | idVendor +-----------+--------+------------+--------------------------------------------------- + 0x136 | 2 | | idProduct +-----------+--------+------------+--------------------------------------------------- + 0x138 | 2 | | bcdDevice +-----------+--------+------------+--------------------------------------------------- + 0x139 | 1 | | bDeviceClass +-----------+--------+------------+--------------------------------------------------- + 0x13A | 1 | | bDeviceSubClass +-----------+--------+------------+--------------------------------------------------- + 0x13B | 1 | | bDeviceProtocol +-----------+--------+------------+--------------------------------------------------- + 0x13C | 1 | | bConfigurationValue +-----------+--------+------------+--------------------------------------------------- + 0x13D | 1 | | bNumConfigurations +-----------+--------+------------+--------------------------------------------------- + 0x13E | 1 | | bNumInterfaces + +USBIP_CMD_SUBMIT: Submit an URB + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 4 | 0x00000001 | command: Submit an URB +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | | seqnum: the sequence number of the URB to submit +-----------+--------+------------+--------------------------------------------------- + 8 | 4 | | devid +-----------+--------+------------+--------------------------------------------------- + 0xC | 4 | | direction: 0: USBIP_DIR_IN + | | | 1: USBIP_DIR_OUT +-----------+--------+------------+--------------------------------------------------- + 0x10 | 4 | | ep: endpoint number, possible values are: 0...15 +-----------+--------+------------+--------------------------------------------------- + 0x14 | 4 | | transfer_flags: possible values depend on the + | | | URB transfer type, see below +-----------+--------+------------+--------------------------------------------------- + 0x18 | 4 | | transfer_buffer_length +-----------+--------+------------+--------------------------------------------------- + 0x1C | 4 | | start_frame: specify the selected frame to + | | | transmit an ISO frame, ignored if URB_ISO_ASAP + | | | is specified at transfer_flags +-----------+--------+------------+--------------------------------------------------- + 0x20 | 4 | | number_of_packets: number of ISO packets +-----------+--------+------------+--------------------------------------------------- + 0x24 | 4 | | interval: maximum time for the request on the + | | | server-side host controller +-----------+--------+------------+--------------------------------------------------- + 0x28 | 8 | | setup: data bytes for USB setup, filled with + | | | zeros if not used +-----------+--------+------------+--------------------------------------------------- + 0x30 | | | URB data. For ISO transfers the padding between + | | | each ISO packets is not transmitted. + + + Allowed transfer_flags | value | control | interrupt | bulk | isochronous + -------------------------+------------+---------+-----------+----------+------------- + URB_SHORT_NOT_OK | 0x00000001 | only in | only in | only in | no + URB_ISO_ASAP | 0x00000002 | no | no | no | yes + URB_NO_TRANSFER_DMA_MAP | 0x00000004 | yes | yes | yes | yes + URB_NO_FSBR | 0x00000020 | yes | no | no | no + URB_ZERO_PACKET | 0x00000040 | no | no | only out | no + URB_NO_INTERRUPT | 0x00000080 | yes | yes | yes | yes + URB_FREE_BUFFER | 0x00000100 | yes | yes | yes | yes + URB_DIR_MASK | 0x00000200 | yes | yes | yes | yes + + +USBIP_RET_SUBMIT: Reply for submitting an URB + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 4 | 0x00000002 | command +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | | seqnum: URB sequence number +-----------+--------+------------+--------------------------------------------------- + 8 | 4 | | devid +-----------+--------+------------+--------------------------------------------------- + 0xC | 4 | | direction: 0: USBIP_DIR_IN + | | | 1: USBIP_DIR_OUT +-----------+--------+------------+--------------------------------------------------- + 0x10 | 4 | | ep: endpoint number +-----------+--------+------------+--------------------------------------------------- + 0x14 | 4 | | status: zero for successful URB transaction, + | | | otherwise some kind of error happened. +-----------+--------+------------+--------------------------------------------------- + 0x18 | 4 | n | actual_length: number of URB data bytes +-----------+--------+------------+--------------------------------------------------- + 0x1C | 4 | | start_frame: for an ISO frame the actually + | | | selected frame for transmit. +-----------+--------+------------+--------------------------------------------------- + 0x20 | 4 | | number_of_packets +-----------+--------+------------+--------------------------------------------------- + 0x24 | 4 | | error_count +-----------+--------+------------+--------------------------------------------------- + 0x28 | 8 | | setup: data bytes for USB setup, filled with + | | | zeros if not used +-----------+--------+------------+--------------------------------------------------- + 0x30 | n | | URB data bytes. For ISO transfers the padding + | | | between each ISO packets is not transmitted. + +USBIP_CMD_UNLINK: Unlink an URB + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 4 | 0x00000003 | command: URB unlink command +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | | seqnum: URB sequence number to unlink: FIXME: is this so? +-----------+--------+------------+--------------------------------------------------- + 8 | 4 | | devid +-----------+--------+------------+--------------------------------------------------- + 0xC | 4 | | direction: 0: USBIP_DIR_IN + | | | 1: USBIP_DIR_OUT +-----------+--------+------------+--------------------------------------------------- + 0x10 | 4 | | ep: endpoint number: zero +-----------+--------+------------+--------------------------------------------------- + 0x14 | 4 | | seqnum: the URB sequence number given previously + | | | at USBIP_CMD_SUBMIT.seqnum field +-----------+--------+------------+--------------------------------------------------- + 0x30 | n | | URB data bytes. For ISO transfers the padding + | | | between each ISO packets is not transmitted. + +USBIP_RET_UNLINK: Reply for URB unlink + + Offset | Length | Value | Description +-----------+--------+------------+--------------------------------------------------- + 0 | 4 | 0x00000004 | command: reply for the URB unlink command +-----------+--------+------------+--------------------------------------------------- + 4 | 4 | | seqnum: the unlinked URB sequence number +-----------+--------+------------+--------------------------------------------------- + 8 | 4 | | devid +-----------+--------+------------+--------------------------------------------------- + 0xC | 4 | | direction: 0: USBIP_DIR_IN + | | | 1: USBIP_DIR_OUT +-----------+--------+------------+--------------------------------------------------- + 0x10 | 4 | | ep: endpoint number +-----------+--------+------------+--------------------------------------------------- + 0x14 | 4 | | status: This is the value contained in the + | | | urb->status in the URB completition handler. + | | | FIXME: a better explanation needed. +-----------+--------+------------+--------------------------------------------------- + 0x30 | n | | URB data bytes. For ISO transfers the padding + | | | between each ISO packets is not transmitted. From 306dac699e02cb399f0c2546df8cb9f5bbee572c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 22 Aug 2011 08:53:28 +0200 Subject: [PATCH 0231/1519] staging: usbip: Add header guards to stub.h and vhci.h stub.h and vhci.h are missing proper #ifndef/#define header guards, so add them. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub.h | 5 +++++ drivers/staging/usbip/vhci.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h index 132adc57ebc..d4073684eac 100644 --- a/drivers/staging/usbip/stub.h +++ b/drivers/staging/usbip/stub.h @@ -17,6 +17,9 @@ * USA. */ +#ifndef __USBIP_STUB_H +#define __USBIP_STUB_H + #include #include #include @@ -106,3 +109,5 @@ void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum, __u32 status); void stub_complete(struct urb *urb); int stub_tx_loop(void *data); + +#endif /* __USBIP_STUB_H */ diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h index 71a586e00fd..88b32981cf1 100644 --- a/drivers/staging/usbip/vhci.h +++ b/drivers/staging/usbip/vhci.h @@ -8,6 +8,9 @@ * */ +#ifndef __USBIP_VHCI_H +#define __USBIP_VHCI_H + #include #include #include @@ -129,3 +132,5 @@ static inline struct device *vhci_dev(struct vhci_hcd *vhci) { return vhci_to_hcd(vhci)->self.controller; } + +#endif /* __USBIP_VHCI_H */ From 93583548585048812dc05a728d182a13213a9fd2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 22 Aug 2011 16:00:33 +0200 Subject: [PATCH 0232/1519] drivers/staging/usbip/userspace/libsrc/vhci_driver.c: test the just-initialized value Test the just-initialized value rather than some other one. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier x,y,f!={PTR_ERR,ERR_PTR,ERR_CAST}; statement S; @@ x = f(...); ( if (\(x == NULL\|IS_ERR(x)\)) S | *if (\(y == NULL\|IS_ERR(y)\)) { ... when != x return ...; } ) // Signed-off-by: Julia Lawall Acked-by: David Chang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/libsrc/vhci_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index abbc285f433..269787751b2 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -133,7 +133,7 @@ static int check_usbip_device(struct sysfs_class_device *cdev) strlen(vhci_driver->hc_device->path))) { /* found usbip device */ usbip_cdev = calloc(1, sizeof(*usbip_cdev)); - if (!cdev) { + if (!usbip_cdev) { dbg("calloc failed"); return -1; } From 74d556bc63fbf3481100be5c8de2637972cbdaeb Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sat, 13 Aug 2011 00:51:40 +0200 Subject: [PATCH 0233/1519] drivers/staging/rtl8187se: Don't pass huge struct by value struct ieee80211_network is fairly large (more than half a kilobyte), so let's pass a pointer instead of passing the entire structure by value when ieee80211_is_54g() and ieee80211_is_shortslot() need to look at a few members. Also remove parentheses around the values being returned from those two functions - 'return' is not a function. Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211.h | 4 ++-- .../rtl8187se/ieee80211/ieee80211_softmac.c | 14 +++++++------- drivers/staging/rtl8187se/r8180_rtl8225z2.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index e79a7e21297..40dd715d9df 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h @@ -1339,8 +1339,8 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); +extern short ieee80211_is_54g(const struct ieee80211_network *net); +extern short ieee80211_is_shortslot(const struct ieee80211_network *net); extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index 38e67f0bf62..26bacb96d24 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c @@ -32,14 +32,14 @@ u8 rsn_authen_cipher_suite[16][4] = { {0x00,0x0F,0xAC,0x05}, //WEP-104 }; -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g(const struct ieee80211_network *net) { - return ((net.rates_ex_len > 0) || (net.rates_len > 4)); + return (net->rates_ex_len > 0) || (net->rates_len > 4); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot(const struct ieee80211_network *net) { - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); + return net->capability & WLAN_CAPABILITY_SHORT_SLOT; } /* returns the total length needed for pleacing the RATE MFIE @@ -789,7 +789,7 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d else atim_len = 0; - if(ieee80211_is_54g(ieee->current_network)) + if(ieee80211_is_54g(&ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -1258,7 +1258,7 @@ void ieee80211_associate_complete_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(&ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; @@ -1379,7 +1379,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ieee->beinretry = false; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(&ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index 3f09f76080a..ee5b867fd0d 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -596,7 +596,7 @@ static void rtl8225_rf_set_chan(struct net_device *dev, short ch) { struct r8180_priv *priv = ieee80211_priv(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g(&priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -615,7 +615,7 @@ static void rtl8225_rf_set_chan(struct net_device *dev, short ch) } if (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot(&priv->ieee80211->current_network)) write_nic_byte(dev, SLOT, 0x9); else write_nic_byte(dev, SLOT, 0x14); From 58af58007e7bf61ba21133fa42ad2106f72a03a1 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sat, 13 Aug 2011 00:53:07 +0200 Subject: [PATCH 0234/1519] drivers/staging/rtl8192u: Don't pass huge struct by value struct ieee80211_network is fairly large (more than half a kilobyte), so let's pass a pointer instead of passing the entire structure by value when ieee80211_is_54g() and ieee80211_is_shortslot() need to look at a few members. Also remove parentheses around the values being returned from those two functions - 'return' is not a function. Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 463cc261890..1c0a1db6420 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2416,8 +2416,8 @@ extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); +extern short ieee80211_is_54g(const struct ieee80211_network *net); +extern short ieee80211_is_shortslot(const struct ieee80211_network *net); extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index b00eb0e65f3..c2ab5fa1546 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -31,14 +31,14 @@ u8 rsn_authen_cipher_suite[16][4] = { {0x00,0x0F,0xAC,0x05}, //WEP-104 }; -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g(const struct ieee80211_network *net) { - return ((net.rates_ex_len > 0) || (net.rates_len > 4)); + return (net->rates_ex_len > 0) || (net->rates_len > 4); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot(const struct ieee80211_network *net) { - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); + return net->capability & WLAN_CAPABILITY_SHORT_SLOT; } /* returns the total length needed for pleacing the RATE MFIE @@ -718,7 +718,7 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d else atim_len = 0; - if(ieee80211_is_54g(ieee->current_network)) + if(ieee80211_is_54g(&ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -1333,7 +1333,7 @@ void ieee80211_associate_complete_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(&ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 108; @@ -1489,7 +1489,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(&ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 108; ieee->SetWirelessMode(ieee->dev, IEEE_G); From dbe82eb1170c0095e0ce89676235e0b27d7040d1 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 22 Aug 2011 14:30:38 -0500 Subject: [PATCH 0235/1519] staging: zcache: fix possible sleep under lock zcache_new_pool() calls kmalloc() with GFP_KERNEL which has __GFP_WAIT set. However, zcache_new_pool() gets called on a stack that holds the swap_lock spinlock, leading to a possible sleep-with-lock situation. The lock is obtained in enable_swap_info(). The patch replaces GFP_KERNEL with GFP_ATOMIC. v2: replace with GFP_ATOMIC, not GFP_IOFS Signed-off-by: Seth Jennings Acked-by: Dan Magenheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/zcache-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index 855a5bb56a4..cdf0128fb55 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -1668,7 +1668,7 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags) if (cli == NULL) goto out; atomic_inc(&cli->refcount); - pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL); + pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); if (pool == NULL) { pr_info("zcache: pool creation failed: out of memory\n"); goto out; From 0428fec32c5fde013cb8223c248972941b18ca59 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 22 Aug 2011 13:50:08 -0500 Subject: [PATCH 0236/1519] staging: zcache: fix typos The patch fixes two typos in zcache-main.c Signed-off-by: Seth Jennings Acked-by: Dan Magenheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/zcache-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index cdf0128fb55..6c0f001c358 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -651,7 +651,7 @@ static unsigned int zv_max_zsize = (PAGE_SIZE / 8) * 7; /* * byte count defining poor *mean* compression; pages with greater zsize * will be rejected until sufficient better-compressed pages are accepted - * driving the man below this threshold + * driving the mean below this threshold */ static unsigned int zv_max_mean_zsize = (PAGE_SIZE / 8) * 5; @@ -1993,7 +1993,7 @@ static int __init zcache_init(void) pr_info("zcache: frontswap enabled using kernel " "transcendent memory and xvmalloc\n"); if (old_ops.init != NULL) - pr_warning("ktmem: frontswap_ops overridden"); + pr_warning("zcache: frontswap_ops overridden"); } #endif out: From 34a678110ac5d2f1b694c8b9df5cccb1a2607721 Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Mon, 1 Aug 2011 12:20:46 +0200 Subject: [PATCH 0237/1519] staging: vme_user: change kmalloc+memset to kzalloc Signed-off-by: Manohar Vanga Acked-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 91d2cc7bb4c..3cbeb2ada41 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -651,7 +651,7 @@ static int __init vme_user_init(void) /* Dynamically create the bind table based on module parameters */ - ids = kmalloc(sizeof(struct vme_device_id) * (bus_num + 1), GFP_KERNEL); + ids = kzalloc(sizeof(struct vme_device_id) * (bus_num + 1), GFP_KERNEL); if (ids == NULL) { printk(KERN_ERR "%s: Unable to allocate ID table\n", driver_name); @@ -659,8 +659,6 @@ static int __init vme_user_init(void) goto err_id; } - memset(ids, 0, (sizeof(struct vme_device_id) * (bus_num + 1))); - for (i = 0; i < bus_num; i++) { ids[i].bus = bus[i]; /* From 7f58f0255aec0b933e0b26ef64d3d533c362a3d3 Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Wed, 10 Aug 2011 11:33:46 +0200 Subject: [PATCH 0238/1519] staging: vme: make [alloc|free]_consistent bridge specific Make PCI dependent functions ([alloc|free]_consistent() in 'vme.c') bridge specific. By removing the dependency of the VME bridge framework on PCI, this patch allows for addition of non-PCI based VME bridges. Signed-off-by: Manohar Vanga Acked-by: Martyn Welch Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/bridges/vme_ca91cx42.c | 24 +++++++++++++++ drivers/staging/vme/bridges/vme_tsi148.c | 24 +++++++++++++++ drivers/staging/vme/vme.c | 36 +++++++++++++--------- drivers/staging/vme/vme_bridge.h | 10 ++++-- 4 files changed, 76 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c index 5122c13a956..0e4feac138e 100644 --- a/drivers/staging/vme/bridges/vme_ca91cx42.c +++ b/drivers/staging/vme/bridges/vme_ca91cx42.c @@ -1500,6 +1500,28 @@ static int ca91cx42_slot_get(struct vme_bridge *ca91cx42_bridge) } +void *ca91cx42_alloc_consistent(struct device *parent, size_t size, + dma_addr_t *dma) +{ + struct pci_dev *pdev; + + /* Find pci_dev container of dev */ + pdev = container_of(parent, struct pci_dev, dev); + + return pci_alloc_consistent(pdev, size, dma); +} + +void ca91cx42_free_consistent(struct device *parent, size_t size, void *vaddr, + dma_addr_t dma) +{ + struct pci_dev *pdev; + + /* Find pci_dev container of dev */ + pdev = container_of(parent, struct pci_dev, dev); + + pci_free_consistent(pdev, size, vaddr, dma); +} + static int __init ca91cx42_init(void) { return pci_register_driver(&ca91cx42_driver); @@ -1769,6 +1791,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) ca91cx42_bridge->lm_attach = ca91cx42_lm_attach; ca91cx42_bridge->lm_detach = ca91cx42_lm_detach; ca91cx42_bridge->slot_get = ca91cx42_slot_get; + ca91cx42_bridge->alloc_consistent = ca91cx42_alloc_consistent; + ca91cx42_bridge->free_consistent = ca91cx42_free_consistent; data = ioread32(ca91cx42_device->base + MISC_CTL); dev_info(&pdev->dev, "Board is%s the VME system controller\n", diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c index 9c539513c74..6c1167c2bea 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.c +++ b/drivers/staging/vme/bridges/vme_tsi148.c @@ -2114,6 +2114,28 @@ static int tsi148_slot_get(struct vme_bridge *tsi148_bridge) return (int)slot; } +void *tsi148_alloc_consistent(struct device *parent, size_t size, + dma_addr_t *dma) +{ + struct pci_dev *pdev; + + /* Find pci_dev container of dev */ + pdev = container_of(parent, struct pci_dev, dev); + + return pci_alloc_consistent(pdev, size, dma); +} + +void tsi148_free_consistent(struct device *parent, size_t size, void *vaddr, + dma_addr_t dma) +{ + struct pci_dev *pdev; + + /* Find pci_dev container of dev */ + pdev = container_of(parent, struct pci_dev, dev); + + pci_free_consistent(pdev, size, vaddr, dma); +} + static int __init tsi148_init(void) { return pci_register_driver(&tsi148_driver); @@ -2443,6 +2465,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) tsi148_bridge->lm_attach = tsi148_lm_attach; tsi148_bridge->lm_detach = tsi148_lm_detach; tsi148_bridge->slot_get = tsi148_slot_get; + tsi148_bridge->alloc_consistent = tsi148_alloc_consistent; + tsi148_bridge->free_consistent = tsi148_free_consistent; data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT); dev_info(&pdev->dev, "Board is%s the VME system controller\n", diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index c078ce369df..4ca9d02cc2c 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -83,15 +83,11 @@ static struct vme_bridge *find_bridge(struct vme_resource *resource) /* * Allocate a contiguous block of memory for use by the driver. This is used to * create the buffers for the slave windows. - * - * XXX VME bridges could be available on buses other than PCI. At the momment - * this framework only supports PCI devices. */ void *vme_alloc_consistent(struct vme_resource *resource, size_t size, dma_addr_t *dma) { struct vme_bridge *bridge; - struct pci_dev *pdev; if (resource == NULL) { printk(KERN_ERR "No resource\n"); @@ -104,28 +100,29 @@ void *vme_alloc_consistent(struct vme_resource *resource, size_t size, return NULL; } - /* Find pci_dev container of dev */ if (bridge->parent == NULL) { - printk(KERN_ERR "Dev entry NULL\n"); + printk(KERN_ERR "Dev entry NULL for" + " bridge %s\n", bridge->name); return NULL; } - pdev = container_of(bridge->parent, struct pci_dev, dev); - return pci_alloc_consistent(pdev, size, dma); + if (bridge->alloc_consistent == NULL) { + printk(KERN_ERR "alloc_consistent not supported by" + " bridge %s\n", bridge->name); + return NULL; + } + + return bridge->alloc_consistent(bridge->parent, size, dma); } EXPORT_SYMBOL(vme_alloc_consistent); /* * Free previously allocated contiguous block of memory. - * - * XXX VME bridges could be available on buses other than PCI. At the momment - * this framework only supports PCI devices. */ void vme_free_consistent(struct vme_resource *resource, size_t size, void *vaddr, dma_addr_t dma) { struct vme_bridge *bridge; - struct pci_dev *pdev; if (resource == NULL) { printk(KERN_ERR "No resource\n"); @@ -138,10 +135,19 @@ void vme_free_consistent(struct vme_resource *resource, size_t size, return; } - /* Find pci_dev container of dev */ - pdev = container_of(bridge->parent, struct pci_dev, dev); + if (bridge->parent == NULL) { + printk(KERN_ERR "Dev entry NULL for" + " bridge %s\n", bridge->name); + return; + } - pci_free_consistent(pdev, size, vaddr, dma); + if (bridge->free_consistent == NULL) { + printk(KERN_ERR "free_consistent not supported by" + " bridge %s\n", bridge->name); + return; + } + + bridge->free_consistent(bridge->parent, size, vaddr, dma); } EXPORT_SYMBOL(vme_free_consistent); diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h index 4c6ec31b01d..a9084f0f34e 100644 --- a/drivers/staging/vme/vme_bridge.h +++ b/drivers/staging/vme/vme_bridge.h @@ -98,8 +98,6 @@ struct vme_irq { /* This structure stores all the information about one bridge * The structure should be dynamically allocated by the driver and one instance * of the structure should be present for each VME chip present in the system. - * - * Currently we assume that all chips are PCI-based */ struct vme_bridge { char name[VMENAMSIZ]; @@ -112,7 +110,7 @@ struct vme_bridge { struct list_head vme_errors; /* List for errors generated on VME */ /* Bridge Info - XXX Move to private structure? */ - struct device *parent; /* Generic device struct (pdev->dev for PCI) */ + struct device *parent; /* Parent device (eg. pdev->dev for PCI) */ void *driver_priv; /* Private pointer for the bridge driver */ struct device dev[VME_SLOTS_MAX]; /* Device registered with @@ -165,6 +163,12 @@ struct vme_bridge { /* CR/CSR space functions */ int (*slot_get) (struct vme_bridge *); + + /* Bridge parent interface */ + void *(*alloc_consistent)(struct device *dev, size_t size, + dma_addr_t *dma); + void (*free_consistent)(struct device *dev, size_t size, + void *vaddr, dma_addr_t dma); }; void vme_irq_handler(struct vme_bridge *, int, int); From 733e3ef0d364b7e6757a897e7f1862a70c89305a Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Fri, 12 Aug 2011 12:30:48 +0200 Subject: [PATCH 0239/1519] staging: vme: keep track of registered buses This patch adds a list which keeps track of all registered VME buses. This is required for adding refcounting later to bridge modules, something that is not currently implemented. This is based on the changes introduced by Emilio G. Cota in the patch: https://lkml.org/lkml/2010/10/25/486 Signed-off-by: Manohar Vanga Acked-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/vme.c | 38 +++++++++++++++++++------------- drivers/staging/vme/vme_bridge.h | 1 + 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 4ca9d02cc2c..b2968f8588f 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -34,9 +34,10 @@ #include "vme.h" #include "vme_bridge.h" -/* Bitmask and mutex to keep track of bridge numbers */ +/* Bitmask and list of registered buses both protected by common mutex */ static unsigned int vme_bus_numbers; -static DEFINE_MUTEX(vme_bus_num_mtx); +static LIST_HEAD(vme_bus_list); +static DEFINE_MUTEX(vme_buses_lock); static void __exit vme_exit(void); static int __init vme_init(void); @@ -1309,27 +1310,32 @@ EXPORT_SYMBOL(vme_slot_get); /* - Bridge Registration --------------------------------------------------- */ -static int vme_alloc_bus_num(void) +static int vme_add_bus(struct vme_bridge *bridge) { int i; + int ret = -1; - mutex_lock(&vme_bus_num_mtx); + mutex_lock(&vme_buses_lock); for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) { - if (((vme_bus_numbers >> i) & 0x1) == 0) { - vme_bus_numbers |= (0x1 << i); + if ((vme_bus_numbers & (1 << i)) == 0) { + vme_bus_numbers |= (1 << i); + bridge->num = i; + list_add_tail(&bridge->bus_list, &vme_bus_list); + ret = 0; break; } } - mutex_unlock(&vme_bus_num_mtx); + mutex_unlock(&vme_buses_lock); - return i; + return ret; } -static void vme_free_bus_num(int bus) +static void vme_remove_bus(struct vme_bridge *bridge) { - mutex_lock(&vme_bus_num_mtx); - vme_bus_numbers &= ~(0x1 << bus); - mutex_unlock(&vme_bus_num_mtx); + mutex_lock(&vme_buses_lock); + vme_bus_numbers &= ~(1 << bridge->num); + list_del(&bridge->bus_list); + mutex_unlock(&vme_buses_lock); } int vme_register_bridge(struct vme_bridge *bridge) @@ -1338,7 +1344,9 @@ int vme_register_bridge(struct vme_bridge *bridge) int retval; int i; - bridge->num = vme_alloc_bus_num(); + retval = vme_add_bus(bridge); + if (retval) + return retval; /* This creates 32 vme "slot" devices. This equates to a slot for each * ID available in a system conforming to the ANSI/VITA 1-1994 @@ -1370,7 +1378,7 @@ err_reg: dev = &bridge->dev[i]; device_unregister(dev); } - vme_free_bus_num(bridge->num); + vme_remove_bus(bridge); return retval; } EXPORT_SYMBOL(vme_register_bridge); @@ -1385,7 +1393,7 @@ void vme_unregister_bridge(struct vme_bridge *bridge) dev = &bridge->dev[i]; device_unregister(dev); } - vme_free_bus_num(bridge->num); + vme_remove_bus(bridge); } EXPORT_SYMBOL(vme_unregister_bridge); diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h index a9084f0f34e..89596705829 100644 --- a/drivers/staging/vme/vme_bridge.h +++ b/drivers/staging/vme/vme_bridge.h @@ -112,6 +112,7 @@ struct vme_bridge { /* Bridge Info - XXX Move to private structure? */ struct device *parent; /* Parent device (eg. pdev->dev for PCI) */ void *driver_priv; /* Private pointer for the bridge driver */ + struct list_head bus_list; /* list of VME buses */ struct device dev[VME_SLOTS_MAX]; /* Device registered with * device model on VME bus From 5ae717139a6defae9656f743dff8388aeb94df93 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 6 Aug 2011 07:27:48 -0700 Subject: [PATCH 0240/1519] rtl8712: don't just return -EFAULT in wpa_supplicant_ioctl() There were some curly braces missing so the original code in wpa_supplicant_ioctl() pretty much always returned -EFAULT without doing anything. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 59bdab10533..d310a6174b9 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -2089,9 +2089,10 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) param = (struct ieee_param *)_malloc(p->length); if (param == NULL) return -ENOMEM; - if (copy_from_user(param, p->pointer, p->length)) + if (copy_from_user(param, p->pointer, p->length)) { kfree((u8 *)param); return -EFAULT; + } switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: ret = wpa_set_param(dev, param->u.wpa_param.name, From 96936173fd558f7f37c84162fda8390e9d70e3e9 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Tue, 16 Aug 2011 20:50:57 +0200 Subject: [PATCH 0241/1519] staging: rtl8712: remove r8712_cmd_thread()->daemonize() daemonize() is only needed when a user-space task does kernel_thread(). r8712_cmd_thread() is kthread_create()'ed and thus it doesn't need the soon-to-be-deprecated daemonize(). It is the only caller of thread_enter() which actually does the call. Note: - we are going to remove the sigdelset(blocked) code from allow_signal(), this means that without this patch thread_enter() can't work after that. Not to mention daemonize() should be deprecated. - as a side effect, this patch changes ->comm. Hopefully this is fine, and padapter->pnetdev->name probably makes more sense anyway. Signed-off-by: Oleg Nesterov Acked-by: Matt Fleming Acked-by: Tejun Heo Acked-and-tested-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index c683d7609e6..aac97bb8b80 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -203,7 +203,6 @@ static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) static inline void thread_enter(void *context) { - daemonize("%s", "RTKTHREAD"); allow_signal(SIGTERM); } From 6c15e002f97db64d23552099c908a066a8219baa Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 15 Aug 2011 22:07:41 -0400 Subject: [PATCH 0242/1519] staging: bcm: fix coding style warnings and errors reported by checkpatch.pl tool Staging: bcm: Fix coding style errors reported by checkpatch.pl Fix multiple warnings and errors reported by checkpatch.pl Signed-off-by: Kevin McKinney Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 3420 ++++++++++++++++----------------- 1 file changed, 1644 insertions(+), 1776 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 867dbf1c992..4bcc38b5bbb 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -34,7 +34,7 @@ static int bcm_char_open(struct inode *inode, struct file * filp) /* Store the Adapter structure */ filp->private_data = pTarang; - /*Start Queuing the control response Packets*/ + /* Start Queuing the control response Packets */ atomic_inc(&Adapter->ApplicationRunning); nonseekable_open(inode, filp); @@ -84,7 +84,7 @@ static int bcm_char_release(struct inode *inode, struct file *filp) up(&Adapter->RxAppControlQueuelock); - /*Stop Queuing the control response Packets*/ + /* Stop Queuing the control response Packets */ atomic_dec(&Adapter->ApplicationRunning); kfree(pTarang); @@ -100,8 +100,8 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, PPER_TARANG_DATA pTarang = filp->private_data; PMINI_ADAPTER Adapter = pTarang->Adapter; struct sk_buff *Packet = NULL; - ssize_t PktLen = 0; - int wait_ret_val = 0; + ssize_t PktLen = 0; + int wait_ret_val = 0; unsigned long ret = 0; wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, @@ -157,1942 +157,1809 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { PPER_TARANG_DATA pTarang = filp->private_data; void __user *argp = (void __user *)arg; - PMINI_ADAPTER Adapter = pTarang->Adapter; - INT Status = STATUS_FAILURE; + PMINI_ADAPTER Adapter = pTarang->Adapter; + INT Status = STATUS_FAILURE; int timeout = 0; - IOCTL_BUFFER IoBuffer; + IOCTL_BUFFER IoBuffer; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg); - if(_IOC_TYPE(cmd) != BCM_IOCTL) + if (_IOC_TYPE(cmd) != BCM_IOCTL) return -EFAULT; - if(_IOC_DIR(cmd) & _IOC_READ) + if (_IOC_DIR(cmd) & _IOC_READ) Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd)); else if (_IOC_DIR(cmd) & _IOC_WRITE) - Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); + Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) - Status = STATUS_SUCCESS; + Status = STATUS_SUCCESS; - if(Status) + if (Status) return -EFAULT; - if(Adapter->device_removed) - { + if (Adapter->device_removed) return -EFAULT; - } - - if(FALSE == Adapter->fw_download_done) - { - switch (cmd) - { - case IOCTL_MAC_ADDR_REQ: - case IOCTL_LINK_REQ: - case IOCTL_CM_REQUEST: - case IOCTL_SS_INFO_REQ: - case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: - case IOCTL_BCM_GPIO_SET_REQUEST: - case IOCTL_BCM_GPIO_STATUS_REQUEST: - return -EACCES; - default: - break; - } - } - - Status = vendorextnIoctl(Adapter, cmd, arg); - if(Status != CONTINUE_COMMON_PATH ) - return Status; - - switch(cmd){ - // Rdms for Swin Idle... - case IOCTL_BCM_REGISTER_READ_PRIVATE: - { - RDM_BUFFER sRdmBuffer = {0}; - PCHAR temp_buff; - UINT Bufflen; - - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; - - if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - /* FIXME: need to restrict BuffLen */ - Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; - temp_buff = kmalloc(Bufflen, GFP_KERNEL); - if(!temp_buff) - return -ENOMEM; - - Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, Bufflen); - if(Status == STATUS_SUCCESS) - { - if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) - Status = -EFAULT; - } - - kfree(temp_buff); - break; - } - case IOCTL_BCM_REGISTER_WRITE_PRIVATE: - { - WRM_BUFFER sWrmBuffer = {0}; - UINT uiTempVar=0; - /* Copy Ioctl Buffer structure */ - - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1)|| - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, sizeof(ULONG)); - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"WRM Done\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; - } - - case IOCTL_BCM_REGISTER_READ: - case IOCTL_BCM_EEPROM_REGISTER_READ: - { - RDM_BUFFER sRdmBuffer = {0}; - PCHAR temp_buff = NULL; - UINT uiTempVar = 0; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); - return -EACCES; - } - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; - - if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - /* FIXME: don't trust user supplied length */ - temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); - if(!temp_buff) - return STATUS_FAILURE; - - if((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sRdmBuffer.Register & 0x3)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", - (int)sRdmBuffer.Register); - return -EINVAL; - } - - uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; - Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, IoBuffer.OutputLength); - if(Status == STATUS_SUCCESS) - if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) - Status = -EFAULT; - - kfree(temp_buff); - break; - } - case IOCTL_BCM_REGISTER_WRITE: - case IOCTL_BCM_EEPROM_REGISTER_WRITE: - { - WRM_BUFFER sWrmBuffer = {0}; - UINT uiTempVar=0; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if( (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sWrmBuffer.Register & 0x3) ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", - (int)sWrmBuffer.Register); - return -EINVAL; - } - - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1)|| - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, sWrmBuffer.Length); - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "WRM Done\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; - } - case IOCTL_BCM_GPIO_SET_REQUEST: - { - UCHAR ucResetValue[4]; - UINT value =0; - UINT uiBit = 0; - UINT uiOperation = 0; - - GPIO_INFO gpio_info = {0}; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode"); - return -EACCES; - } - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - uiBit = gpio_info.uiGpioNumber; - uiOperation = gpio_info.uiGpioValue; - - value= (1< is not correspond to LED !!!",value); - Status = -EINVAL; - break; - } - - - if(uiOperation)//Set - setting 1 - { - //Set the gpio output register - Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_SET_REG , - (PUINT)(&value), sizeof(UINT)); - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO bit\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to set the %dth GPIO \n",uiBit); - break; - } - } - else//Unset - setting 0 - { - //Set the gpio output register - Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_CLR_REG , - (PUINT)(&value), sizeof(UINT)); - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Set the GPIO bit\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to clear the %dth GPIO \n",uiBit); - break; - } - } - - Status = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, - (PUINT)ucResetValue, sizeof(UINT)); - if (STATUS_SUCCESS != Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO_MODE_REGISTER read failed"); - break; - } - //Set the gpio mode register to output - *(UINT*)ucResetValue |= (1<IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode"); - Status = -EACCES; - break; - } - - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(threadReq)) - return -EINVAL; - - if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - //if LED thread is running(Actively or Inactively) set it state to make inactive - if(Adapter->LEDInfo.led_thread_running) - { - if(threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Activating thread req"); - Adapter->DriverState = LED_THREAD_ACTIVE; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DeActivating Thread req....."); - Adapter->DriverState = LED_THREAD_INACTIVE; - } - - //signal thread. - wake_up(&Adapter->LEDInfo.notify_led_event); - - } - } - break; - case IOCTL_BCM_GPIO_STATUS_REQUEST: - { - ULONG uiBit = 0; - UCHAR ucRead[4]; - GPIO_INFO gpio_info = {0}; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - return -EACCES; - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - uiBit = gpio_info.uiGpioNumber; - //Set the gpio output register - Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)ucRead, sizeof(UINT)); - if(Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Failed\n"); - return Status; - } - - } - break; - case IOCTL_BCM_GPIO_MULTI_REQUEST: - { - UCHAR ucResetValue[4]; - GPIO_MULTI_INFO gpio_multi_info[MAX_IDX]; - PGPIO_MULTI_INFO pgpio_multi_info = (PGPIO_MULTI_INFO)gpio_multi_info; - - memset( pgpio_multi_info, 0, MAX_IDX * sizeof( GPIO_MULTI_INFO)); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - return -EINVAL; - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - if (IoBuffer.InputLength > sizeof(gpio_multi_info)) - return -EINVAL; - if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_info[WIMAX_IDX].uiGPIOMask)== FALSE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_info[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap); - Status = -EINVAL; - break; - } - - /* Set the gpio output register */ - - if( ( pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & - ( pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) - { - /* Set 1's in GPIO OUTPUT REGISTER */ - *(UINT*) ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - - if( *(UINT*) ucResetValue) - Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_SET_REG , (PUINT) ucResetValue, sizeof(ULONG)); - - if( Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); - return Status; - } - - /* Clear to 0's in GPIO OUTPUT REGISTER */ - *(UINT*) ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - ( ~( pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); - - if( *(UINT*) ucResetValue) - Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_CLR_REG , (PUINT) ucResetValue, sizeof(ULONG)); - - if( Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_CLR_REG Failed." ); - return Status; - } - } - - if( pgpio_multi_info[WIMAX_IDX].uiGPIOMask) - { - Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); - - if(Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM to GPIO_PIN_STATE_REGISTER Failed."); - return Status; - } - - pgpio_multi_info[WIMAX_IDX].uiGPIOValue = ( *(UINT*)ucResetValue & - pgpio_multi_info[WIMAX_IDX].uiGPIOMask); - } - - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); - break; - } - } - break; - case IOCTL_BCM_GPIO_MODE_REQUEST: - { - UCHAR ucResetValue[4]; - GPIO_MULTI_MODE gpio_multi_mode[MAX_IDX]; - PGPIO_MULTI_MODE pgpio_multi_mode = ( PGPIO_MULTI_MODE) gpio_multi_mode; - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - return -EINVAL; - - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) - return -EINVAL; - if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT)); - if( STATUS_SUCCESS != Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Read of GPIO_MODE_REGISTER failed"); - return Status; - } - - //Validating the request - if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)== FALSE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_mode[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap); - Status = -EINVAL; - break; - } - - if( pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) - { - /* write all OUT's (1's) */ - *( UINT*) ucResetValue |= ( pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); - /* write all IN's (0's) */ - *( UINT*) ucResetValue &= ~( ( ~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); - - /* Currently implemented return the modes of all GPIO's - * else needs to bit AND with mask - * */ - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT*)ucResetValue; - - Status = wrmaltWithLock( Adapter, GPIO_MODE_REGISTER , ( PUINT) ucResetValue, sizeof( ULONG)); - if( Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM to GPIO_MODE_REGISTER Done"); - } - else - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to GPIO_MODE_REGISTER Failed"); - Status = -EFAULT; - break; - } - } - else /* if uiGPIOMask is 0 then return mode register configuration */ - { - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *( UINT*) ucResetValue; - } - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); - break; - } - } - break; + if (FALSE == Adapter->fw_download_done) { + switch (cmd) { case IOCTL_MAC_ADDR_REQ: case IOCTL_LINK_REQ: case IOCTL_CM_REQUEST: case IOCTL_SS_INFO_REQ: case IOCTL_SEND_CONTROL_MESSAGE: case IOCTL_IDLE_REQ: - { - PVOID pvBuffer=NULL; + case IOCTL_BCM_GPIO_SET_REQUEST: + case IOCTL_BCM_GPIO_STATUS_REQUEST: + return -EACCES; + default: + break; + } + } - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + Status = vendorextnIoctl(Adapter, cmd, arg); + if (Status != CONTINUE_COMMON_PATH) + return Status; - /* FIXME: don't accept any length from user */ - pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); - if(!pvBuffer) - return -ENOMEM; + switch (cmd) { + /* Rdms for Swin Idle... */ + case IOCTL_BCM_REGISTER_READ_PRIVATE: { + RDM_BUFFER sRdmBuffer = {0}; + PCHAR temp_buff; + UINT Bufflen; - if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; + + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* FIXME: need to restrict BuffLen */ + Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; + temp_buff = kmalloc(Bufflen, GFP_KERNEL); + if (!temp_buff) + return -ENOMEM; + + Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register, + (PUINT)temp_buff, Bufflen); + if (Status == STATUS_SUCCESS) { + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) Status = -EFAULT; - kfree(pvBuffer); + } + + kfree(temp_buff); + break; + } + + case IOCTL_BCM_REGISTER_WRITE_PRIVATE: { + WRM_BUFFER sWrmBuffer = {0}; + UINT uiTempVar = 0; + /* Copy Ioctl Buffer structure */ + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4))) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, sizeof(ULONG)); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; + } + break; + } + + case IOCTL_BCM_REGISTER_READ: + case IOCTL_BCM_EEPROM_REGISTER_READ: { + RDM_BUFFER sRdmBuffer = {0}; + PCHAR temp_buff = NULL; + UINT uiTempVar = 0; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); + return -EACCES; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; + + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* FIXME: don't trust user supplied length */ + temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; + + if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sRdmBuffer.Register & 0x3)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", + (int)sRdmBuffer.Register); + return -EINVAL; + } + + uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; + Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, (PUINT)temp_buff, IoBuffer.OutputLength); + + if (Status == STATUS_SUCCESS) + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) + Status = -EFAULT; + + kfree(temp_buff); + break; + } + case IOCTL_BCM_REGISTER_WRITE: + case IOCTL_BCM_EEPROM_REGISTER_WRITE: { + WRM_BUFFER sWrmBuffer = {0}; + UINT uiTempVar = 0; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); + return -EACCES; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sWrmBuffer.Register & 0x3)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)sWrmBuffer.Register); + return -EINVAL; + } + + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, sWrmBuffer.Length); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; + } + break; + } + case IOCTL_BCM_GPIO_SET_REQUEST: { + UCHAR ucResetValue[4]; + UINT value = 0; + UINT uiBit = 0; + UINT uiOperation = 0; + + GPIO_INFO gpio_info = {0}; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "GPIO Can't be set/clear in Low power Mode"); + return -EACCES; + } + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; + + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiBit = gpio_info.uiGpioNumber; + uiOperation = gpio_info.uiGpioValue; + value = (1< is not correspond to LED !!!", value); + Status = -EINVAL; + break; + } + + /* Set - setting 1 */ + if (uiOperation) { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, (PUINT)(&value), sizeof(UINT)); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO bit\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Failed to set the %dth GPIO\n", uiBit); break; } + } else { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)(&value), sizeof(UINT)); - down(&Adapter->LowPowerModeSync); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->bPreparingForLowPowerMode, - (1 * HZ)); - if(Status == -ERESTARTSYS) - goto cntrlEnd; - - if(Adapter->bPreparingForLowPowerMode) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Preparing Idle Mode is still True - Hence Rejecting control message\n"); - Status = STATUS_FAILURE ; - goto cntrlEnd ; + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO bit\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Failed to clear the %dth GPIO\n", uiBit); + break; } - Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); - cntrlEnd: - up(&Adapter->LowPowerModeSync); + } + + Status = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + + if (STATUS_SUCCESS != Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "GPIO_MODE_REGISTER read failed"); + break; + } + + /* Set the gpio mode register to output */ + *(UINT *)ucResetValue |= (1<IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "GPIO Can't be set/clear in Low power Mode"); + Status = -EACCES; + break; + } + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(threadReq)) + return -EINVAL; + + if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* if LED thread is running(Actively or Inactively) set it state to make inactive */ + if (Adapter->LEDInfo.led_thread_running) { + if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Activating thread req"); + Adapter->DriverState = LED_THREAD_ACTIVE; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DeActivating Thread req....."); + Adapter->DriverState = LED_THREAD_INACTIVE; + } + + /* signal thread. */ + wake_up(&Adapter->LEDInfo.notify_led_event); + } + } + break; + + case IOCTL_BCM_GPIO_STATUS_REQUEST: { + ULONG uiBit = 0; + UCHAR ucRead[4]; + GPIO_INFO gpio_info = {0}; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EACCES; + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; + + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiBit = gpio_info.uiGpioNumber; + + /* Set the gpio output register */ + Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, + (PUINT)ucRead, sizeof(UINT)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM Failed\n"); + return Status; + } + } + break; + + case IOCTL_BCM_GPIO_MULTI_REQUEST: { + UCHAR ucResetValue[4]; + GPIO_MULTI_INFO gpio_multi_info[MAX_IDX]; + PGPIO_MULTI_INFO pgpio_multi_info = (PGPIO_MULTI_INFO)gpio_multi_info; + + memset(pgpio_multi_info, 0, MAX_IDX * sizeof(GPIO_MULTI_INFO)); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_multi_info)) + return -EINVAL; + + if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) == FALSE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", + pgpio_multi_info[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); + Status = -EINVAL; + break; + } + + /* Set the gpio output register */ + if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & + (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { + /* Set 1's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + pgpio_multi_info[WIMAX_IDX].uiGPIOValue; + + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, + (PUINT)ucResetValue, sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); + return Status; + } + + /* Clear to 0's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); + + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); + return Status; + } + } + + if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { + Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM to GPIO_PIN_STATE_REGISTER Failed."); + return Status; + } + + pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & + pgpio_multi_info[WIMAX_IDX].uiGPIOMask); + } + + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", Status); + break; + } + } + break; + + case IOCTL_BCM_GPIO_MODE_REQUEST: { + UCHAR ucResetValue[4]; + GPIO_MULTI_MODE gpio_multi_mode[MAX_IDX]; + PGPIO_MULTI_MODE pgpio_multi_mode = (PGPIO_MULTI_MODE)gpio_multi_mode; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) + return -EINVAL; + + if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + Status = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + + if (STATUS_SUCCESS != Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read of GPIO_MODE_REGISTER failed"); + return Status; + } + + /* Validating the request */ + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) == FALSE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); + Status = -EINVAL; + break; + } + + if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { + /* write all OUT's (1's) */ + *(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* write all IN's (0's) */ + *(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* Currently implemented return the modes of all GPIO's + * else needs to bit AND with mask + */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + + Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(ULONG)); + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "WRM to GPIO_MODE_REGISTER Done"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to GPIO_MODE_REGISTER Failed"); + Status = -EFAULT; + break; + } + } else { +/* if uiGPIOMask is 0 then return mode register configuration */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + } + + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", Status); + break; + } + } + break; + + case IOCTL_MAC_ADDR_REQ: + case IOCTL_LINK_REQ: + case IOCTL_CM_REQUEST: + case IOCTL_SS_INFO_REQ: + case IOCTL_SEND_CONTROL_MESSAGE: + case IOCTL_IDLE_REQ: { + PVOID pvBuffer = NULL; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + /* FIXME: don't accept any length from user */ + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); + if (!pvBuffer) + return -ENOMEM; + + if (copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) { + Status = -EFAULT; kfree(pvBuffer); break; } - case IOCTL_BCM_BUFFER_DOWNLOAD_START: - { - INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ; - if(NVMAccess) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); - if(!down_trylock(&Adapter->fw_download_sema)) - { - Adapter->bBinDownloaded=FALSE; - Adapter->fw_download_process_pid=current->pid; - Adapter->bCfgDownloaded=FALSE; - Adapter->fw_download_done=FALSE; - netif_carrier_off(Adapter->dev); - netif_stop_queue(Adapter->dev); - Status = reset_card_proc(Adapter); - if(Status) - { - pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - break; - } - mdelay(10); - } - else - { - Status = -EBUSY; + down(&Adapter->LowPowerModeSync); + Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, + !Adapter->bPreparingForLowPowerMode, + (1 * HZ)); + if (Status == -ERESTARTSYS) + goto cntrlEnd; - } - up(&Adapter->NVMRdmWrmLock); - break; + if (Adapter->bPreparingForLowPowerMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Preparing Idle Mode is still True - Hence Rejecting control message\n"); + Status = STATUS_FAILURE; + goto cntrlEnd; } - case IOCTL_BCM_BUFFER_DOWNLOAD: - { - FIRMWARE_INFO *psFwInfo = NULL; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); - do{ - if(!down_trylock(&Adapter->fw_download_sema)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid way to download buffer. Use Start and then call this!!!\n"); - Status=-EINVAL; - break; - } + Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; +cntrlEnd: + up(&Adapter->LowPowerModeSync); + kfree(pvBuffer); + break; + } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n", - IoBuffer.InputLength); - - if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO)) - return -EINVAL; - - psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); - if(!psFwInfo) - return -ENOMEM; - - if(copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if(!psFwInfo->pvMappedFirmwareAddress || - (psFwInfo->u32FirmwareLength == 0)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", - psFwInfo->u32FirmwareLength); - Status = -EINVAL; - break; - } - Status = bcm_ioctl_fw_download(Adapter, psFwInfo); - if(Status != STATUS_SUCCESS) - { - if(psFwInfo->u32StartingAddress==CONFIG_BEGIN_ADDR) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); - } - //up(&Adapter->fw_download_sema); - - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { - Adapter->DriverState = DRIVER_INIT; - Adapter->LEDInfo.bLedInitDone = FALSE; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } - break ; - }while(0); - - if(Status != STATUS_SUCCESS) - up(&Adapter->fw_download_sema); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); - kfree(psFwInfo); - break; - } - case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: - { - INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - if(NVMAccess) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " FW download blocked as EEPROM Read/Write is in progress\n"); - up(&Adapter->fw_download_sema); - return -EACCES; - } - if(down_trylock(&Adapter->fw_download_sema)) - { - Adapter->bBinDownloaded=TRUE; - Adapter->bCfgDownloaded=TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - - Adapter->CurrNumRecvDescs=0; - Adapter->downloadDDR = 0; - - //setting the Mips to Run - Status = run_card_proc(Adapter); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - break; - } - else - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Firm Download Over...\n"); - mdelay(10); - /* Wait for MailBox Interrupt */ - if(StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); - } - timeout = 5*HZ; - Adapter->waiting_to_fw_download_done = FALSE; - wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, - Adapter->waiting_to_fw_download_done, timeout); - Adapter->fw_download_process_pid=INVALID_PID; - Adapter->fw_download_done=TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - Adapter->CurrNumRecvDescs = 0; - Adapter->PrevNumRecvDescs = 0; - atomic_set(&Adapter->cntrlpktCnt,0); - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { - Adapter->DriverState = FW_DOWNLOAD_DONE; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - if(!timeout) - { - Status = -ENODEV; - } - } - else - { - Status = -EINVAL; - } - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - break; + case IOCTL_BCM_BUFFER_DOWNLOAD_START: { + INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + if (NVMAccess) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; } - case IOCTL_BE_BUCKET_SIZE: - Status = 0; - if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) - Status = -EFAULT; - break; - case IOCTL_RTPS_BUCKET_SIZE: - Status = 0; - if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg)) - Status = -EFAULT; - break; - case IOCTL_CHIP_RESET: - { - INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - if(NVMAccess) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } - down(&Adapter->RxAppControlQueuelock); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Starting the firmware download PID =0x%x!!!!\n", current->pid); + + if (!down_trylock(&Adapter->fw_download_sema)) { + Adapter->bBinDownloaded = FALSE; + Adapter->fw_download_process_pid = current->pid; + Adapter->bCfgDownloaded = FALSE; + Adapter->fw_download_done = FALSE; + netif_carrier_off(Adapter->dev); + netif_stop_queue(Adapter->dev); Status = reset_card_proc(Adapter); - flushAllAppQ(); - up(&Adapter->RxAppControlQueuelock); - up(&Adapter->NVMRdmWrmLock); - ResetCounters(Adapter); - break; - } - case IOCTL_QOS_THRESHOLD: - { - USHORT uiLoopIndex; - - Status = 0; - for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { - if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, - (unsigned long __user *)arg)) { - Status = -EFAULT; - break; - } - } - break; - } - - case IOCTL_DUMP_PACKET_INFO: - - DumpPackInfo(Adapter); - DumpPhsRules(&Adapter->stBCMPhsContext); - Status = STATUS_SUCCESS; - break; - - case IOCTL_GET_PACK_INFO: - if(copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES)) - return -EFAULT; - Status = STATUS_SUCCESS; - break; - case IOCTL_BCM_SWITCH_TRANSFER_MODE: - { - UINT uiData = 0; - if(copy_from_user(&uiData, argp, sizeof(UINT))) - return -EFAULT; - - if(uiData) /* Allow All Packets */ - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); - Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; - } - else /* Allow IP only Packets */ - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); - Adapter->TransferMode = IP_PACKET_ONLY_MODE; - } - Status = STATUS_SUCCESS; - break; - } - - case IOCTL_BCM_GET_DRIVER_VERSION: - { - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if(copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, IoBuffer.OutputLength)) - return -EFAULT; - Status = STATUS_SUCCESS; - break; - } - case IOCTL_BCM_GET_CURRENT_STATUS: - { - LINK_STATE link_state; - - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); - Status = -EFAULT; + if (Status) { + pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); break; } - if (IoBuffer.OutputLength != sizeof(link_state)) { + mdelay(10); + } else { + Status = -EBUSY; + } + + up(&Adapter->NVMRdmWrmLock); + break; + } + + case IOCTL_BCM_BUFFER_DOWNLOAD: { + FIRMWARE_INFO *psFwInfo = NULL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); + do { + if (!down_trylock(&Adapter->fw_download_sema)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Invalid way to download buffer. Use Start and then call this!!!\n"); Status = -EINVAL; break; } - memset(&link_state, 0, sizeof(link_state)); - link_state.bIdleMode = Adapter->IdleMode; - link_state.bShutdownMode = Adapter->bShutStatus; - link_state.ucLinkStatus = Adapter->LinkStatus; + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - if (copy_to_user(IoBuffer.OutputBuffer, &link_state, - min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length for FW DLD is : %lx\n", IoBuffer.InputLength); + + if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO)) + return -EINVAL; + + psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); + if (!psFwInfo) + return -ENOMEM; + + if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if (!psFwInfo->pvMappedFirmwareAddress || + (psFwInfo->u32FirmwareLength == 0)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", + psFwInfo->u32FirmwareLength); + Status = -EINVAL; + break; + } + + Status = bcm_ioctl_fw_download(Adapter, psFwInfo); + + if (Status != STATUS_SUCCESS) { + if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); + else + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); + + /* up(&Adapter->fw_download_sema); */ + + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = DRIVER_INIT; + Adapter->LEDInfo.bLedInitDone = FALSE; + wake_up(&Adapter->LEDInfo.notify_led_event); + } + } + break; + + } while (0); + + if (Status != STATUS_SUCCESS) + up(&Adapter->fw_download_sema); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); + kfree(psFwInfo); + break; + } + + case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: { + INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + + if (NVMAccess) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "FW download blocked as EEPROM Read/Write is in progress\n"); + up(&Adapter->fw_download_sema); + return -EACCES; + } + + if (down_trylock(&Adapter->fw_download_sema)) { + Adapter->bBinDownloaded = TRUE; + Adapter->bCfgDownloaded = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->downloadDDR = 0; + + /* setting the Mips to Run */ + Status = run_card_proc(Adapter); + + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + break; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "Firm Download Over...\n"); + } + + mdelay(10); + + /* Wait for MailBox Interrupt */ + if (StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter)) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); + + timeout = 5*HZ; + Adapter->waiting_to_fw_download_done = FALSE; + wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, + Adapter->waiting_to_fw_download_done, timeout); + Adapter->fw_download_process_pid = INVALID_PID; + Adapter->fw_download_done = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->PrevNumRecvDescs = 0; + atomic_set(&Adapter->cntrlpktCnt, 0); + Adapter->LinkUpStatus = 0; + Adapter->LinkStatus = 0; + + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = FW_DOWNLOAD_DONE; + wake_up(&Adapter->LEDInfo.notify_led_event); + } + + if (!timeout) + Status = -ENODEV; + } else { + Status = -EINVAL; + } + + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + break; + } + + case IOCTL_BE_BUCKET_SIZE: + Status = 0; + if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) + Status = -EFAULT; + break; + + case IOCTL_RTPS_BUCKET_SIZE: + Status = 0; + if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg)) + Status = -EFAULT; + break; + + case IOCTL_CHIP_RESET: { + INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + if (NVMAccess) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; + } + + down(&Adapter->RxAppControlQueuelock); + Status = reset_card_proc(Adapter); + flushAllAppQ(); + up(&Adapter->RxAppControlQueuelock); + up(&Adapter->NVMRdmWrmLock); + ResetCounters(Adapter); + break; + } + + case IOCTL_QOS_THRESHOLD: { + USHORT uiLoopIndex; + + Status = 0; + for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { + if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, + (unsigned long __user *)arg)) { Status = -EFAULT; break; } - Status = STATUS_SUCCESS; - break; - } - case IOCTL_BCM_SET_MAC_TRACING: - { - UINT tracing_flag; - - /* copy ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if(copy_from_user(&tracing_flag,IoBuffer.InputBuffer,sizeof(UINT))) - return -EFAULT; - - if (tracing_flag) - Adapter->pTarangs->MacTracingEnabled = TRUE; - else - Adapter->pTarangs->MacTracingEnabled = FALSE; - break; - } - case IOCTL_BCM_GET_DSX_INDICATION: - { - ULONG ulSFId=0; - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, - "Mismatch req: %lx needed is =0x%zx!!!", - IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); - return -EINVAL; - } - - if(copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId ); - get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); - Status=STATUS_SUCCESS; } break; - case IOCTL_BCM_GET_HOST_MIBS: - { - PVOID temp_buff; + } - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + case IOCTL_DUMP_PACKET_INFO: + DumpPackInfo(Adapter); + DumpPhsRules(&Adapter->stBCMPhsContext); + Status = STATUS_SUCCESS; + break; - if(IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, - "Length Check failed %lu %zd\n", - IoBuffer.OutputLength, sizeof(S_MIBS_HOST_STATS_MIBS)); - return -EINVAL; - } + case IOCTL_GET_PACK_INFO: + if (copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES)) + return -EFAULT; + Status = STATUS_SUCCESS; + break; - /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ - temp_buff = kzalloc(sizeof(S_MIBS_HOST_STATS_MIBS), GFP_KERNEL); - if(!temp_buff) - return STATUS_FAILURE; + case IOCTL_BCM_SWITCH_TRANSFER_MODE: { + UINT uiData = 0; + if (copy_from_user(&uiData, argp, sizeof(UINT))) + return -EFAULT; - Status = ProcessGetHostMibs(Adapter, temp_buff); - GetDroppedAppCntrlPktMibs(temp_buff, pTarang); + if (uiData) { + /* Allow All Packets */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); + Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; + } else { + /* Allow IP only Packets */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); + Adapter->TransferMode = IP_PACKET_ONLY_MODE; + } + Status = STATUS_SUCCESS; + break; + } - if (Status != STATUS_FAILURE) - if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(S_MIBS_HOST_STATS_MIBS))) - Status = -EFAULT; + case IOCTL_BCM_GET_DRIVER_VERSION: { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - kfree(temp_buff); + if (copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, IoBuffer.OutputLength)) + return -EFAULT; + Status = STATUS_SUCCESS; + break; + } + + case IOCTL_BCM_GET_CURRENT_STATUS: { + LINK_STATE link_state; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); + Status = -EFAULT; break; } - case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: - if((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE==Adapter->IdleMode)) - { - Adapter->usIdleModePattern = ABORT_IDLE_MODE; - Adapter->bWakeUpDevice = TRUE; - wake_up(&Adapter->process_rx_cntrlpkt); - } - Status = STATUS_SUCCESS; + if (IoBuffer.OutputLength != sizeof(link_state)) { + Status = -EINVAL; break; + } - case IOCTL_BCM_BULK_WRM: - { - PBULKWRM_BUFFER pBulkBuffer; - UINT uiTempVar=0; - PCHAR pvBuffer = NULL; + memset(&link_state, 0, sizeof(link_state)); + link_state.bIdleMode = Adapter->IdleMode; + link_state.bShutdownMode = Adapter->bShutStatus; + link_state.ucLinkStatus = Adapter->LinkStatus; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); - Status = -EACCES; - break; - } + if (copy_to_user(IoBuffer.OutputBuffer, &link_state, min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); + Status = -EFAULT; + break; + } + Status = STATUS_SUCCESS; + break; + } - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + case IOCTL_BCM_SET_MAC_TRACING: { + UINT tracing_flag; - /* FIXME: restrict length */ - pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); - if(!pvBuffer) - return -ENOMEM; + /* copy ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - /* Get WrmBuffer structure */ - if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - { - kfree(pvBuffer); - Status = -EFAULT; - break; - } + if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) + return -EFAULT; - pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer; + if (tracing_flag) + Adapter->pTarangs->MacTracingEnabled = TRUE; + else + Adapter->pTarangs->MacTracingEnabled = FALSE; + break; + } - if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || - ((ULONG)pBulkBuffer->Register & 0x3)) - { - kfree(pvBuffer); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"WRM Done On invalid Address : %x Access Denied.\n",(int)pBulkBuffer->Register); - Status = -EINVAL; - break; - } + case IOCTL_BCM_GET_DSX_INDICATION: { + ULONG ulSFId = 0; + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if (IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Mismatch req: %lx needed is =0x%zx!!!", + IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); + return -EINVAL; + } - uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; - if(!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) - && ((uiTempVar == EEPROM_REJECT_REG_1)|| - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) - { - kfree(pvBuffer); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"EEPROM Access Denied, not in VSG Mode\n"); - Status = -EFAULT; - break; - } + if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) + return -EFAULT; - if(pBulkBuffer->SwapEndian == FALSE) - Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); - else - Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId); + get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); + Status = STATUS_SUCCESS; + } + break; - if(Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); - } + case IOCTL_BCM_GET_HOST_MIBS: { + PVOID temp_buff; - kfree(pvBuffer); - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - case IOCTL_BCM_GET_NVM_SIZE: - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + if (IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length Check failed %lu %zd\n", + IoBuffer.OutputLength, sizeof(S_MIBS_HOST_STATS_MIBS)); + return -EINVAL; + } + + /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ + temp_buff = kzalloc(sizeof(S_MIBS_HOST_STATS_MIBS), GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; + + Status = ProcessGetHostMibs(Adapter, temp_buff); + GetDroppedAppCntrlPktMibs(temp_buff, pTarang); + + if (Status != STATUS_FAILURE) + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(S_MIBS_HOST_STATS_MIBS))) + Status = -EFAULT; + + kfree(temp_buff); + break; + } + + case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: + if ((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE == Adapter->IdleMode)) { + Adapter->usIdleModePattern = ABORT_IDLE_MODE; + Adapter->bWakeUpDevice = TRUE; + wake_up(&Adapter->process_rx_cntrlpkt); + } + + Status = STATUS_SUCCESS; + break; + + case IOCTL_BCM_BULK_WRM: { + PBULKWRM_BUFFER pBulkBuffer; + UINT uiTempVar = 0; + PCHAR pvBuffer = NULL; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); + Status = -EACCES; + break; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + /* FIXME: restrict length */ + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); + if (!pvBuffer) + return -ENOMEM; + + /* Get WrmBuffer structure */ + if (copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) { + kfree(pvBuffer); + Status = -EFAULT; + break; + } + + pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer; + + if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || + ((ULONG)pBulkBuffer->Register & 0x3)) { + kfree(pvBuffer); + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); + Status = -EINVAL; + break; + } + + uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { + + kfree(pvBuffer); + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); + Status = -EFAULT; + break; + } + + if (pBulkBuffer->SwapEndian == FALSE) + Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + else + Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); + + kfree(pvBuffer); + break; + } + + case IOCTL_BCM_GET_NVM_SIZE: + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) + return -EFAULT; + } + + Status = STATUS_SUCCESS; + break; + + case IOCTL_BCM_CAL_INIT: { + UINT uiSectorSize = 0 ; + if (Adapter->eNVMType == NVM_FLASH) { + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) { - if(copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) + if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) + return -EFAULT; + + if ((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, + sizeof(UINT))) return -EFAULT; - } - Status = STATUS_SUCCESS ; - break; - - case IOCTL_BCM_CAL_INIT : - - { - UINT uiSectorSize = 0 ; - if(Adapter->eNVMType == NVM_FLASH) - { - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + } else { + if (IsFlash2x(Adapter)) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, sizeof(UINT))) return -EFAULT; - - if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) - return -EFAULT; - - if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) - { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, - sizeof(UINT))) - return -EFAULT; + } else { + if ((TRUE == Adapter->bShutStatus) || (TRUE == Adapter->IdleMode)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is in Idle/Shutdown Mode\n"); + return -EACCES; } - else - { - if(IsFlash2x(Adapter)) - { - if (copy_to_user(IoBuffer.OutputBuffer, - &Adapter->uiSectorSize , - sizeof(UINT))) - return -EFAULT; - } - else - { - if((TRUE == Adapter->bShutStatus) || - (TRUE == Adapter->IdleMode)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle/Shutdown Mode\n"); - return -EACCES; - } - Adapter->uiSectorSize = uiSectorSize ; - BcmUpdateSectorSize(Adapter,Adapter->uiSectorSize); - } - } - Status = STATUS_SUCCESS ; - } - else - { - Status = STATUS_FAILURE; + Adapter->uiSectorSize = uiSectorSize; + BcmUpdateSectorSize(Adapter, Adapter->uiSectorSize); } } - break; - case IOCTL_BCM_SET_DEBUG : + Status = STATUS_SUCCESS; + } else { + Status = STATUS_FAILURE; + } + } + break; + + case IOCTL_BCM_SET_DEBUG: #ifdef DEBUG - { - USER_BCM_DBG_STATE sUserDebugState; + { + USER_BCM_DBG_STATE sUserDebugState; -// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Entered the ioctl %x \n", IOCTL_BCM_SET_DEBUG ); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE))) + return -EFAULT; - if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE))) - return -EFAULT; - - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", sUserDebugState.OnOff, sUserDebugState.Type); - //sUserDebugState.Subtype <<= 1; - sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); + /* sUserDebugState.Subtype <<= 1; */ + sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); - // Update new 'DebugState' in the Adapter - Adapter->stDebugState.type |= sUserDebugState.Type; - /* Subtype: A bitmap of 32 bits for Subtype per Type. - * Valid indexes in 'subtype' array: 1,2,4,8 - * corresponding to valid Type values. Hence we can use the 'Type' field - * as the index value, ignoring the array entries 0,3,5,6,7 ! - */ - if (sUserDebugState.OnOff) - Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; - else - Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; + /* Update new 'DebugState' in the Adapter */ + Adapter->stDebugState.type |= sUserDebugState.Type; + /* Subtype: A bitmap of 32 bits for Subtype per Type. + * Valid indexes in 'subtype' array: 1,2,4,8 + * corresponding to valid Type values. Hence we can use the 'Type' field + * as the index value, ignoring the array entries 0,3,5,6,7 ! + */ + if (sUserDebugState.OnOff) + Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; + else + Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; - BCM_SHOW_DEBUG_BITMAP(Adapter); - - } + BCM_SHOW_DEBUG_BITMAP(Adapter); + } #endif + break; + + case IOCTL_BCM_NVM_READ: + case IOCTL_BCM_NVM_WRITE: { + NVM_READWRITE stNVMReadWrite; + PUCHAR pReadData = NULL; + ULONG ulDSDMagicNumInUsrBuff = 0; + struct timeval tv0, tv1; + memset(&tv0, 0, sizeof(struct timeval)); + memset(&tv1, 0, sizeof(struct timeval)); + if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); + Status = -EFAULT; break; - case IOCTL_BCM_NVM_READ: - case IOCTL_BCM_NVM_WRITE: - { - NVM_READWRITE stNVMReadWrite; - PUCHAR pReadData = NULL; - ULONG ulDSDMagicNumInUsrBuff = 0; - struct timeval tv0, tv1; - memset(&tv0,0,sizeof(struct timeval)); - memset(&tv1,0,sizeof(struct timeval)); - if((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,"The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); - Status = -EFAULT; - break; - } + } - if(IsFlash2x(Adapter)) - { - if((Adapter->eActiveDSD != DSD0) && - (Adapter->eActiveDSD != DSD1) && - (Adapter->eActiveDSD != DSD2)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"No DSD is active..hence NVM Command is blocked"); - return STATUS_FAILURE ; - } - } + if (IsFlash2x(Adapter)) { + if ((Adapter->eActiveDSD != DSD0) && + (Adapter->eActiveDSD != DSD1) && + (Adapter->eActiveDSD != DSD2)) { - /* Copy Ioctl Buffer structure */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked"); + return STATUS_FAILURE ; + } + } - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - if(copy_from_user(&stNVMReadWrite, - (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, - sizeof(NVM_READWRITE))) - return -EFAULT; + if (copy_from_user(&stNVMReadWrite, + (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, + sizeof(NVM_READWRITE))) + return -EFAULT; - // - // Deny the access if the offset crosses the cal area limit. - // - if((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) > Adapter->uiNVMDSDSize) - { - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset , -// stNVMReadWrite.uiNumBytes); - Status = STATUS_FAILURE; - break; - } + /* + * Deny the access if the offset crosses the cal area limit. + */ - pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); - if(!pReadData) - return -ENOMEM; + if ((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) > Adapter->uiNVMDSDSize) { + /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */ + Status = STATUS_FAILURE; + break; + } - if(copy_from_user(pReadData, stNVMReadWrite.pBuffer, - stNVMReadWrite.uiNumBytes)) - { - Status = -EFAULT; - kfree(pReadData); - break; - } + pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); + if (!pReadData) + return -ENOMEM; - do_gettimeofday(&tv0); - if(IOCTL_BCM_NVM_READ == cmd) - { - down(&Adapter->NVMRdmWrmLock); + if (copy_from_user(pReadData, stNVMReadWrite.pBuffer, stNVMReadWrite.uiNumBytes)) { + Status = -EFAULT; + kfree(pReadData); + break; + } - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); + do_gettimeofday(&tv0); + if (IOCTL_BCM_NVM_READ == cmd) { + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Status = BeceemNVMRead(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; + } + + if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, stNVMReadWrite.uiNumBytes)) { + kfree(pReadData); + Status = -EFAULT; + } + } else { + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Adapter->bHeaderChangeAllowed = TRUE; + if (IsFlash2x(Adapter)) { + /* + * New Requirement:- + * DSD section updation will be allowed in two case:- + * 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull + * 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is + * corrupted then user space program first modify the DSD header with valid DSD sig so + * that this as well as further write may be worthwhile. + * + * This restriction has been put assuming that if DSD sig is corrupted, DSD + * data won't be considered valid. + */ + + Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); + if (Status != STATUS_SUCCESS) { + if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize) || + (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); up(&Adapter->NVMRdmWrmLock); kfree(pReadData); - return -EACCES; + return Status; } - Status = BeceemNVMRead(Adapter, (PUINT)pReadData, - stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); - - up(&Adapter->NVMRdmWrmLock); - - if(Status != STATUS_SUCCESS) - { - kfree(pReadData); - return Status; - } - if(copy_to_user(stNVMReadWrite.pBuffer,pReadData, stNVMReadWrite.uiNumBytes)) - { - kfree(pReadData); - Status = -EFAULT; - } - } - else - { - - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); + ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); + if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } - - Adapter->bHeaderChangeAllowed = TRUE ; - if(IsFlash2x(Adapter)) - { - /* - New Requirement:- - DSD section updation will be allowed in two case:- - 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull - 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is - corrupted then user space program first modify the DSD header with valid DSD sig so - that this as well as further write may be worthwhile. - - This restriction has been put assuming that if DSD sig is corrupted, DSD - data won't be considered valid. - - - */ - Status = BcmFlash2xCorruptSig(Adapter,Adapter->eActiveDSD); - if(Status != STATUS_SUCCESS) - { - if(( (stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize ) || - (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - - ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); - if(ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - } - } - Status = BeceemNVMWrite(Adapter, (PUINT )pReadData, - stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); - if(IsFlash2x(Adapter)) - BcmFlash2xWriteSig(Adapter,Adapter->eActiveDSD); - - Adapter->bHeaderChangeAllowed = FALSE ; - - up(&Adapter->NVMRdmWrmLock); - - - if(Status != STATUS_SUCCESS) - { kfree(pReadData); return Status; } } - do_gettimeofday(&tv1); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n",(tv1.tv_sec - tv0.tv_sec)*1000 +(tv1.tv_usec - tv0.tv_usec)/1000); + } + Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); + if (IsFlash2x(Adapter)) + BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); + Adapter->bHeaderChangeAllowed = FALSE; + + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { kfree(pReadData); - Status = STATUS_SUCCESS; + return Status; } - break; - case IOCTL_BCM_FLASH2X_SECTION_READ : - { + } - FLASH2X_READWRITE sFlash2xRead = {0}; - PUCHAR pReadBuff = NULL ; - UINT NOB = 0; - UINT BuffSize = 0; - UINT ReadBytes = 0; - UINT ReadOffset = 0; - void __user *OutPutBuff; + do_gettimeofday(&tv1); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000); - if(IsFlash2x(Adapter) != TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); - return -EINVAL; - } + kfree(pReadData); + Status = STATUS_SUCCESS; + } + break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + case IOCTL_BCM_FLASH2X_SECTION_READ: { + FLASH2X_READWRITE sFlash2xRead = {0}; + PUCHAR pReadBuff = NULL ; + UINT NOB = 0; + UINT BuffSize = 0; + UINT ReadBytes = 0; + UINT ReadOffset = 0; + void __user *OutPutBuff; - //Reading FLASH 2.x READ structure - if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE))) - return -EFAULT; + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%x" ,sFlash2xRead.offset); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xRead.numOfBytes); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xRead.bVerify); + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE))) + return -EFAULT; - //This was internal to driver for raw read. now it has ben exposed to user space app. - if(validateFlash2xReadWrite(Adapter,&sFlash2xRead) == FALSE) - return STATUS_FAILURE ; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xRead.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%x", sFlash2xRead.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); - NOB = sFlash2xRead.numOfBytes; - if(NOB > Adapter->uiSectorSize ) - BuffSize = Adapter->uiSectorSize; + /* This was internal to driver for raw read. now it has ben exposed to user space app. */ + if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == FALSE) + return STATUS_FAILURE; + + NOB = sFlash2xRead.numOfBytes; + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; + + ReadOffset = sFlash2xRead.offset ; + OutPutBuff = IoBuffer.OutputBuffer; + pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); + return -ENOMEM; + } + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return -EACCES; + } + + while (NOB) { + if (NOB > Adapter->uiSectorSize) + ReadBytes = Adapter->uiSectorSize; + else + ReadBytes = NOB; + + /* Reading the data from Flash 2.x */ + Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, sFlash2xRead.Section, ReadOffset, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Flash 2x read err with Status :%d", Status); + break; + } + + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); + + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy to use failed with status :%d", Status); + break; + } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes ; + } + } + + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + } + break; + + case IOCTL_BCM_FLASH2X_SECTION_WRITE: { + FLASH2X_READWRITE sFlash2xWrite = {0}; + PUCHAR pWriteBuff; + void __user *InputAddr; + UINT NOB = 0; + UINT BuffSize = 0; + UINT WriteOffset = 0; + UINT WriteBytes = 0; + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + /* First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite */ + Adapter->bAllDSDWriteAllow = FALSE; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE))) + return -EFAULT; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); + + if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && (sFlash2xWrite.Section != VSA2)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Only VSA write is allowed"); + return -EINVAL; + } + + if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == FALSE) + return STATUS_FAILURE; + + InputAddr = sFlash2xWrite.pDataBuff; + WriteOffset = sFlash2xWrite.offset; + NOB = sFlash2xWrite.numOfBytes; + + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB ; + + pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); + + if (pWriteBuff == NULL) + return -ENOMEM; + + /* extracting the remainder of the given offset. */ + WriteBytes = Adapter->uiSectorSize; + if (WriteOffset % Adapter->uiSectorSize) + WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); + + if (NOB < WriteBytes) + WriteBytes = NOB; + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return -EACCES; + } + + BcmFlash2xCorruptSig(Adapter, sFlash2xWrite.Section); + do { + Status = copy_from_user(pWriteBuff, InputAddr, WriteBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to user failed with status :%d", Status); + break; + } + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); + + /* Writing the data from Flash 2.x */ + Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, sFlash2xWrite.Section, WriteOffset, WriteBytes, sFlash2xWrite.bVerify); + + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); + break; + } + + NOB = NOB - WriteBytes; + if (NOB) { + WriteOffset = WriteOffset + WriteBytes; + InputAddr = InputAddr + WriteBytes; + if (NOB > Adapter->uiSectorSize) + WriteBytes = Adapter->uiSectorSize; else - BuffSize = NOB ; - - ReadOffset = sFlash2xRead.offset ; - OutPutBuff = IoBuffer.OutputBuffer; - - - pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); - if(pReadBuff == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); - return -ENOMEM; - } - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EACCES; - } - - while(NOB) - { - - if(NOB > Adapter->uiSectorSize ) - ReadBytes = Adapter->uiSectorSize; - else - ReadBytes = NOB; - - - //Reading the data from Flash 2.x - - Status = BcmFlash2xBulkRead(Adapter,(PUINT)pReadBuff,sFlash2xRead.Section,ReadOffset,ReadBytes); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Flash 2x read err with Status :%d", Status); - break ; - } - - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes); - - Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status); - break; - } - NOB = NOB - ReadBytes; - if(NOB) - { - ReadOffset = ReadOffset + ReadBytes ; - OutPutBuff = OutPutBuff + ReadBytes ; - } - - } - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - - } - break ; - case IOCTL_BCM_FLASH2X_SECTION_WRITE : - { - FLASH2X_READWRITE sFlash2xWrite = {0}; - PUCHAR pWriteBuff; - void __user *InputAddr; - UINT NOB = 0; - UINT BuffSize = 0; - UINT WriteOffset = 0; - UINT WriteBytes = 0; - - if(IsFlash2x(Adapter) != TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); - return -EINVAL; - } - - //First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite - Adapter->bAllDSDWriteAllow = FALSE; - - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - //Reading FLASH 2.x READ structure - if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xWrite.Section); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%d" ,sFlash2xWrite.offset); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xWrite.numOfBytes); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xWrite.bVerify); - if((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && - (sFlash2xWrite.Section != VSA2) ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Only VSA write is allowed"); - return -EINVAL; - } - - if(validateFlash2xReadWrite(Adapter,&sFlash2xWrite) == FALSE) - return STATUS_FAILURE ; - - InputAddr = sFlash2xWrite.pDataBuff; - WriteOffset = sFlash2xWrite.offset ; - NOB = sFlash2xWrite.numOfBytes; - - if(NOB > Adapter->uiSectorSize ) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB ; - - pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); - if(pWriteBuff == NULL) - return -ENOMEM; - - - //extracting the remainder of the given offset. - WriteBytes = Adapter->uiSectorSize ; - if(WriteOffset % Adapter->uiSectorSize) - WriteBytes =Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); - if(NOB < WriteBytes) WriteBytes = NOB; - - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - return -EACCES; - } - - BcmFlash2xCorruptSig(Adapter,sFlash2xWrite.Section); - do - { - Status = copy_from_user(pWriteBuff,InputAddr,WriteBytes); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status); - break ; - } - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes); - //Writing the data from Flash 2.x - Status = BcmFlash2xBulkWrite(Adapter,(PUINT)pWriteBuff,sFlash2xWrite.Section,WriteOffset,WriteBytes,sFlash2xWrite.bVerify); - - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status); - break ; - } - - NOB = NOB - WriteBytes; - if(NOB) - { - WriteOffset = WriteOffset + WriteBytes ; - InputAddr = InputAddr + WriteBytes ; - if(NOB > Adapter->uiSectorSize ) - WriteBytes = Adapter->uiSectorSize; - else - WriteBytes = NOB; - } - - - } while(NOB > 0); - BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - } - break ; - case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP : - { - - PFLASH2X_BITMAP psFlash2xBitMap; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) - return -EINVAL; - - psFlash2xBitMap = kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); - if(psFlash2xBitMap == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available"); - return -ENOMEM ; - } - //Reading the Flash Sectio Bit map - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(psFlash2xBitMap); - return -EACCES; - } - - BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); - up(&Adapter->NVMRdmWrmLock); - if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP))) - Status = -EFAULT; - - kfree(psFlash2xBitMap); - } - break ; - case IOCTL_BCM_SET_ACTIVE_SECTION : - { - FLASH2X_SECTION_VAL eFlash2xSectionVal = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - - if(IsFlash2x(Adapter) != TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); - return -EINVAL; - } - - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return Status; - } - - Status = copy_from_user(&eFlash2xSectionVal,IoBuffer.InputBuffer, sizeof(INT)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return Status; - } - - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } - - Status = BcmSetActiveSection(Adapter,eFlash2xSectionVal); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed to make it's priority Highest. Status %d", Status); - } - up(&Adapter->NVMRdmWrmLock); } - break ; - case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION : - { - //Right Now we are taking care of only DSD - Adapter->bAllDSDWriteAllow = FALSE ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); + } while (NOB > 0); - Status = STATUS_SUCCESS ; - } - break ; - case IOCTL_BCM_COPY_SECTION : - { - FLASH2X_COPY_SECTION sCopySectStrut = {0}; - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); + BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + } + break; - Adapter->bAllDSDWriteAllow = FALSE ; - if(IsFlash2x(Adapter) != TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); - return -EINVAL; - } + case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: { + PFLASH2X_BITMAP psFlash2xBitMap; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); - return Status; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); - return Status; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); + if (IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) + return -EINVAL; + psFlash2xBitMap = kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); + if (psFlash2xBitMap == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); + return -ENOMEM; + } - if(IsSectionExistInFlash(Adapter,sCopySectStrut.SrcSection) == FALSE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source Section<%x> does not exixt in Flash ", sCopySectStrut.SrcSection); - return -EINVAL; - } + /* Reading the Flash Sectio Bit map */ + down(&Adapter->NVMRdmWrmLock); - if(IsSectionExistInFlash(Adapter,sCopySectStrut.DstSection) == FALSE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Destinatio Section<%x> does not exixt in Flash ", sCopySectStrut.DstSection); - return -EINVAL; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if(sCopySectStrut.SrcSection == sCopySectStrut.DstSection) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Source and Destination section should be different"); - return -EINVAL; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(psFlash2xBitMap); + return -EACCES; + } - down(&Adapter->NVMRdmWrmLock); + BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); + up(&Adapter->NVMRdmWrmLock); + if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP))) + Status = -EFAULT; - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } + kfree(psFlash2xBitMap); + } + break; - if(sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) - { - if(IsNonCDLessDevice(Adapter)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is Non-CDLess hence won't have ISO !!"); - Status = -EINVAL ; - } - else if(sCopySectStrut.numOfBytes == 0) - { - Status = BcmCopyISO(Adapter,sCopySectStrut); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Partial Copy of ISO section is not Allowed.."); - Status = STATUS_FAILURE ; - } - up(&Adapter->NVMRdmWrmLock); - return Status; - } + case IOCTL_BCM_SET_ACTIVE_SECTION: { + FLASH2X_SECTION_VAL eFlash2xSectionVal = 0; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, - sCopySectStrut.DstSection,sCopySectStrut.offset,sCopySectStrut.numOfBytes); - up(&Adapter->NVMRdmWrmLock); - } - break ; - case IOCTL_BCM_GET_FLASH_CS_INFO : - { - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - break; - } - if(Adapter->eNVMType != NVM_FLASH) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Connected device does not have flash"); - Status = -EINVAL; - break; - } - if(IsFlash2x(Adapter) == TRUE) - { + Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + return Status; + } - if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) - return -EINVAL; + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + return Status; + } - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO))) - return -EFAULT; - } - else - { - if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) - return -EINVAL; + down(&Adapter->NVMRdmWrmLock); - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO))) - return -EFAULT; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - } - } - break ; - case IOCTL_BCM_SELECT_DSD : - { - UINT SectOfset = 0; - FLASH2X_SECTION_VAL eFlash2xSectionVal; - eFlash2xSectionVal = NO_SECTION_VAL ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_SELECT_DSD Called"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } - if(IsFlash2x(Adapter) != TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); - return -EINVAL; - } + Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); + if (Status) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Failed to make it's priority Highest. Status %d", Status); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return Status; - } - Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return Status; - } + up(&Adapter->NVMRdmWrmLock); + } + break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", eFlash2xSectionVal); - if((eFlash2xSectionVal != DSD0) && - (eFlash2xSectionVal != DSD1) && - (eFlash2xSectionVal != DSD2) ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Passed section<%x> is not DSD section", eFlash2xSectionVal); - return STATUS_FAILURE ; - } + case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: { + /* Right Now we are taking care of only DSD */ + Adapter->bAllDSDWriteAllow = FALSE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); + Status = STATUS_SUCCESS; + } + break; - SectOfset= BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal); - if(SectOfset == INVALID_OFFSET) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Provided Section val <%d> does not exixt in Flash 2.x", eFlash2xSectionVal); - return -EINVAL; - } + case IOCTL_BCM_COPY_SECTION: { + FLASH2X_COPY_SECTION sCopySectStrut = {0}; + Status = STATUS_SUCCESS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); - Adapter->bAllDSDWriteAllow = TRUE ; + Adapter->bAllDSDWriteAllow = FALSE; + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } - Adapter->ulFlashCalStart = SectOfset ; - Adapter->eActiveDSD = eFlash2xSectionVal; - } - Status = STATUS_SUCCESS ; - break; + Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); + return Status; + } - case IOCTL_BCM_NVM_RAW_READ : - { + Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); + return Status; + } - NVM_READWRITE stNVMRead; - INT NOB ; - INT BuffSize ; - INT ReadOffset = 0; - UINT ReadBytes = 0 ; - PUCHAR pReadBuff; - void __user *OutPutBuff; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); - if(Adapter->eNVMType != NVM_FLASH) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"NVM TYPE is not Flash "); - return -EINVAL ; - } + if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == FALSE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source Section<%x> does not exixt in Flash ", sCopySectStrut.SrcSection); + return -EINVAL; + } - /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); - Status = -EFAULT; - break; - } + if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == FALSE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destinatio Section<%x> does not exixt in Flash ", sCopySectStrut.DstSection); + return -EINVAL; + } - if(copy_from_user(&stNVMRead, IoBuffer.OutputBuffer,sizeof(NVM_READWRITE))) - return -EFAULT; + if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source and Destination section should be different"); + return -EINVAL; + } - NOB = stNVMRead.uiNumBytes; - //In Raw-Read max Buff size : 64MB + down(&Adapter->NVMRdmWrmLock); - if(NOB > DEFAULT_BUFF_SIZE) - BuffSize = DEFAULT_BUFF_SIZE; - else - BuffSize = NOB ; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - ReadOffset = stNVMRead.uiOffset; - OutPutBuff = stNVMRead.pBuffer; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } - pReadBuff = kzalloc(BuffSize , GFP_KERNEL); - if(pReadBuff == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); - Status = -ENOMEM; - break; - } - down(&Adapter->NVMRdmWrmLock); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - kfree(pReadBuff); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } - - Adapter->bFlashRawRead = TRUE ; - while(NOB) - { - if(NOB > DEFAULT_BUFF_SIZE ) - ReadBytes = DEFAULT_BUFF_SIZE; - else - ReadBytes = NOB; - - //Reading the data from Flash 2.x - Status = BeceemNVMRead(Adapter,(PUINT)pReadBuff,ReadOffset,ReadBytes); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status); - break; - } - - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff,ReadBytes); - - Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status); - break; - } - NOB = NOB - ReadBytes; - if(NOB) - { - ReadOffset = ReadOffset + ReadBytes ; - OutPutBuff = OutPutBuff + ReadBytes ; - } - - } - Adapter->bFlashRawRead = FALSE ; - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - break ; - } - - case IOCTL_BCM_CNTRLMSG_MASK: - { - ULONG RxCntrlMsgBitMask = 0 ; - - /* Copy Ioctl Buffer structure */ - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space"); - Status = -EFAULT; - break; - } - - if (IoBuffer.InputLength != sizeof(unsigned long)) { - Status = -EINVAL; - break; - } - - Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space"); - Status = -EFAULT; - break; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); - pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask ; - } - break; - case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: - { - DEVICE_DRIVER_INFO DevInfo; - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); - - DevInfo.MaxRDMBufferSize = BUFFER_4K; - DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; - DevInfo.u32RxAlignmentCorrection = 0; - DevInfo.u32NVMType = Adapter->eNVMType; - DevInfo.u32InterfaceType = BCM_USB; - - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if(IoBuffer.OutputLength < sizeof(DevInfo)) - return -EINVAL; - - if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) - return -EFAULT; + if (sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) { + if (IsNonCDLessDevice(Adapter)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is Non-CDLess hence won't have ISO !!"); + Status = -EINVAL; + } else if (sCopySectStrut.numOfBytes == 0) { + Status = BcmCopyISO(Adapter, sCopySectStrut); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Partial Copy of ISO section is not Allowed.."); + Status = STATUS_FAILURE; } - break ; + up(&Adapter->NVMRdmWrmLock); + return Status; + } - case IOCTL_BCM_TIME_SINCE_NET_ENTRY: - { - ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0}; + Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, + sCopySectStrut.DstSection, sCopySectStrut.offset, sCopySectStrut.numOfBytes); + up(&Adapter->NVMRdmWrmLock); + } + break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + case IOCTL_BCM_GET_FLASH_CS_INFO: { + Status = STATUS_SUCCESS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + break; + } - if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED)) - return -EINVAL; + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Connected device does not have flash"); + Status = -EINVAL; + break; + } - stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; + if (IsFlash2x(Adapter) == TRUE) { + if (IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) + return -EINVAL; - if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED))) - return -EFAULT; + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO))) + return -EFAULT; + } else { + if (IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) + return -EINVAL; + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO))) + return -EFAULT; + } + } + break; + + case IOCTL_BCM_SELECT_DSD: { + UINT SectOfset = 0; + FLASH2X_SECTION_VAL eFlash2xSectionVal; + eFlash2xSectionVal = NO_SECTION_VAL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SELECT_DSD Called"); + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + return Status; + } + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + return Status; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read Section :%d", eFlash2xSectionVal); + if ((eFlash2xSectionVal != DSD0) && + (eFlash2xSectionVal != DSD1) && + (eFlash2xSectionVal != DSD2)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Passed section<%x> is not DSD section", eFlash2xSectionVal); + return STATUS_FAILURE; + } + + SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); + if (SectOfset == INVALID_OFFSET) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section val <%d> does not exixt in Flash 2.x", eFlash2xSectionVal); + return -EINVAL; + } + + Adapter->bAllDSDWriteAllow = TRUE; + Adapter->ulFlashCalStart = SectOfset; + Adapter->eActiveDSD = eFlash2xSectionVal; + } + Status = STATUS_SUCCESS; + break; + + case IOCTL_BCM_NVM_RAW_READ: { + NVM_READWRITE stNVMRead; + INT NOB ; + INT BuffSize ; + INT ReadOffset = 0; + UINT ReadBytes = 0 ; + PUCHAR pReadBuff; + void __user *OutPutBuff; + + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NVM TYPE is not Flash"); + return -EINVAL; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); + Status = -EFAULT; + break; + } + + if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(NVM_READWRITE))) + return -EFAULT; + + NOB = stNVMRead.uiNumBytes; + /* In Raw-Read max Buff size : 64MB */ + + if (NOB > DEFAULT_BUFF_SIZE) + BuffSize = DEFAULT_BUFF_SIZE; + else + BuffSize = NOB; + + ReadOffset = stNVMRead.uiOffset; + OutPutBuff = stNVMRead.pBuffer; + + pReadBuff = kzalloc(BuffSize , GFP_KERNEL); + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); + Status = -ENOMEM; + break; + } + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + kfree(pReadBuff); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + + Adapter->bFlashRawRead = TRUE; + + while (NOB) { + if (NOB > DEFAULT_BUFF_SIZE) + ReadBytes = DEFAULT_BUFF_SIZE; + else + ReadBytes = NOB; + + /* Reading the data from Flash 2.x */ + Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, ReadOffset, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); + break; } - break; - case IOCTL_CLOSE_NOTIFICATION: - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_CLOSE_NOTIFICATION"); - break; + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); - default: - pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd); - Status = STATUS_FAILURE; + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to use failed with status :%d", Status); + break; + } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes; + } + } + Adapter->bFlashRawRead = FALSE; + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + break; + } + + case IOCTL_BCM_CNTRLMSG_MASK: { + ULONG RxCntrlMsgBitMask = 0; + + /* Copy Ioctl Buffer structure */ + Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); + Status = -EFAULT; break; + } + + if (IoBuffer.InputLength != sizeof(unsigned long)) { + Status = -EINVAL; + break; + } + + Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of control bit mask failed from user space"); + Status = -EFAULT; + break; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); + pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; + } + break; + + case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: { + DEVICE_DRIVER_INFO DevInfo; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); + + DevInfo.MaxRDMBufferSize = BUFFER_4K; + DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; + DevInfo.u32RxAlignmentCorrection = 0; + DevInfo.u32NVMType = Adapter->eNVMType; + DevInfo.u32InterfaceType = BCM_USB; + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(DevInfo)) + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) + return -EFAULT; + } + break; + + case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { + ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0}; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED)) + return -EINVAL; + + stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; + + if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED))) + return -EFAULT; + } + break; + + case IOCTL_CLOSE_NOTIFICATION: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_CLOSE_NOTIFICATION"); + break; + + default: + pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd); + Status = STATUS_FAILURE; + break; } return Status; } @@ -2122,8 +1989,8 @@ int register_control_device_interface(PMINI_ADAPTER Adapter) } Adapter->pstCreatedClassDevice = device_create(bcm_class, NULL, - MKDEV(Adapter->major, 0), - Adapter, DEV_NAME); + MKDEV(Adapter->major, 0), + Adapter, DEV_NAME); if (IS_ERR(Adapter->pstCreatedClassDevice)) { pr_err(DRV_NAME ": class device create failed\n"); @@ -2141,3 +2008,4 @@ void unregister_control_device_interface(PMINI_ADAPTER Adapter) unregister_chrdev(Adapter->major, DEV_NAME); } } + From fbfcdf254d7be71b25bfc053e9d22ef8ff061750 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 15 Aug 2011 22:10:12 -0400 Subject: [PATCH 0243/1519] Staging: bcm: Fix a coding style error reported by checkpatch.pl Tool checkpatch.pl reported the following error: extern struct class *bcm_class;" declaration not allowed in .c files. Therefore, I move this declaration into the header "headers.h" file. Signed-off-by: Kevin McKinney Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 2 -- drivers/staging/bcm/headers.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 4bcc38b5bbb..d3f3856e2dc 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1974,8 +1974,6 @@ static const struct file_operations bcm_fops = { .llseek = no_llseek, }; -extern struct class *bcm_class; - int register_control_device_interface(PMINI_ADAPTER Adapter) { diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h index 947d0632568..da47db8c8f2 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -74,4 +74,6 @@ #define DRV_VERSION VER_FILEVERSION_STR #define PFX DRV_NAME " " +extern struct class *bcm_class; + #endif From 1dc634772b0daead0e841b9034e88b6c76a05709 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 15 Aug 2011 22:12:15 -0400 Subject: [PATCH 0244/1519] Staging: bcm: Fix memory leak reported during compile. This patch fixes a potential memory leak were temp_buff buffer is not being freed when a certain condition is true. Signed-off-by: Kevin McKinney Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index d3f3856e2dc..6f8a75dc1ef 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -304,6 +304,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", (int)sRdmBuffer.Register); + + kfree(temp_buff); return -EINVAL; } From e5969d55743c49dfca24e165a534cf5f2638e86b Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 8 Aug 2011 13:17:58 +0200 Subject: [PATCH 0245/1519] drivers/staging/bcm/nvm.c: add missing kfree Buff is only used as a temporary buffer within the function, so it should be freed before leaving the function in an error case. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @exists@ local idexpression x; statement S,S1; expression E; identifier fl; expression *ptr != NULL; @@ x = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...kfree(x)...+> } when any when != true x == NULL x->fl ...> ( if (x == NULL) S1 | if (...) { ... when != x when forall ( return \(0\|<+...x...+>\|ptr\); | * return ...; ) } ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/nvm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index 4da5b7b54a1..3de0daf5edb 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -4013,7 +4013,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) if(uiTotalDataToCopy < ISOLength) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); - return STATUS_FAILURE; + Status = STATUS_FAILURE; + goto out; } uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - @@ -4026,7 +4027,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) if(uiTotalDataToCopy < ISOLength) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); - return STATUS_FAILURE; + Status = STATUS_FAILURE; + goto out; } uiTotalDataToCopy = ISOLength; @@ -4143,7 +4145,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) if(uiTotalDataToCopy < ISOLength) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); - return STATUS_FAILURE; + Status = STATUS_FAILURE; + goto out; } uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - @@ -4156,7 +4159,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) if(uiTotalDataToCopy < ISOLength) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); - return STATUS_FAILURE; + Status = STATUS_FAILURE; + goto out; } uiTotalDataToCopy = ISOLength; @@ -4257,6 +4261,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) } +out: kfree(Buff); return Status; From 01188858496ceb3c9508083d8df59eb06ff0d644 Mon Sep 17 00:00:00 2001 From: Ben Wright Date: Wed, 17 Aug 2011 13:42:50 +1000 Subject: [PATCH 0246/1519] Staging: bcm: Macros: Fixed multiple coding style violations. Fixed multiple indentation issues. Signed-off-by: Benjamin James Wright Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Macros.h | 315 +++++++++++++++++------------------ 1 file changed, 156 insertions(+), 159 deletions(-) diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h index 916bebb7ed5..46ed99c5376 100644 --- a/drivers/staging/bcm/Macros.h +++ b/drivers/staging/bcm/Macros.h @@ -1,17 +1,17 @@ /************************************* -* Macros.h +* Macros.h **************************************/ -#ifndef __MACROS_H__ +#ifndef __MACROS_H__ #define __MACROS_H__ -#define TX_TIMER_PERIOD 10 //10 msec +#define TX_TIMER_PERIOD 10 /*10 msec*/ #define MAX_CLASSIFIERS 100 -//#define MAX_CLASSIFIERS_PER_SF 20 +/* #define MAX_CLASSIFIERS_PER_SF 20 */ #define MAX_TARGET_DSX_BUFFERS 24 -#define MAX_CNTRL_PKTS 100 -#define MAX_DATA_PKTS 200 -#define MAX_ETH_SIZE 1536 +#define MAX_CNTRL_PKTS 100 +#define MAX_DATA_PKTS 200 +#define MAX_ETH_SIZE 1536 #define MAX_CNTL_PKT_SIZE 2048 #define MTU_SIZE 1400 @@ -20,102 +20,102 @@ #define MAC_ADDR_REGISTER 0xbf60d000 -///////////Quality of Service/////////////////////////// -#define NO_OF_QUEUES 17 -#define HiPriority NO_OF_QUEUES-1 -#define LowPriority 0 -#define BE 2 -#define rtPS 4 -#define ERTPS 5 -#define UGS 6 +/* Quality of Service */ +#define NO_OF_QUEUES 17 +#define HiPriority (NO_OF_QUEUES-1) +#define LowPriority 0 +#define BE 2 +#define rtPS 4 +#define ERTPS 5 +#define UGS 6 -#define BE_BUCKET_SIZE 1024*1024*100 //32kb -#define rtPS_BUCKET_SIZE 1024*1024*100 //8kb -#define MAX_ALLOWED_RATE 1024*1024*100 -#define TX_PACKET_THRESHOLD 10 -#define XSECONDS 1*HZ -#define DSC_ACTIVATE_REQUEST 248 -#define QUEUE_DEPTH_OFFSET 0x1fc01000 -#define MAX_DEVICE_DESC_SIZE 2040 -#define MAX_CTRL_QUEUE_LEN 100 -#define MAX_APP_QUEUE_LEN 200 -#define MAX_LATENCY_ALLOWED 0xFFFFFFFF -#define DEFAULT_UG_INTERVAL 250 -#define DEFAULT_UGI_FACTOR 4 +#define BE_BUCKET_SIZE (1024*1024*100) /* 32kb */ +#define rtPS_BUCKET_SIZE (1024*1024*100) /* 8kb */ +#define MAX_ALLOWED_RATE (1024*1024*100) +#define TX_PACKET_THRESHOLD 10 +#define XSECONDS (1*HZ) +#define DSC_ACTIVATE_REQUEST 248 +#define QUEUE_DEPTH_OFFSET 0x1fc01000 +#define MAX_DEVICE_DESC_SIZE 2040 +#define MAX_CTRL_QUEUE_LEN 100 +#define MAX_APP_QUEUE_LEN 200 +#define MAX_LATENCY_ALLOWED 0xFFFFFFFF +#define DEFAULT_UG_INTERVAL 250 +#define DEFAULT_UGI_FACTOR 4 -#define DEFAULT_PERSFCOUNT 60 -#define MAX_CONNECTIONS 10 -#define MAX_CLASS_NAME_LENGTH 32 +#define DEFAULT_PERSFCOUNT 60 +#define MAX_CONNECTIONS 10 +#define MAX_CLASS_NAME_LENGTH 32 -#define ETH_LENGTH_OF_ADDRESS 6 -#define MAX_MULTICAST_ADDRESSES 32 -#define IP_LENGTH_OF_ADDRESS 4 +#define ETH_LENGTH_OF_ADDRESS 6 +#define MAX_MULTICAST_ADDRESSES 32 +#define IP_LENGTH_OF_ADDRESS 4 -#define IP_PACKET_ONLY_MODE 0 -#define ETH_PACKET_TUNNELING_MODE 1 +#define IP_PACKET_ONLY_MODE 0 +#define ETH_PACKET_TUNNELING_MODE 1 -////////////Link Request////////////// -#define SET_MAC_ADDRESS_REQUEST 0 -#define SYNC_UP_REQUEST 1 -#define SYNCED_UP 2 -#define LINK_UP_REQUEST 3 -#define LINK_CONNECTED 4 -#define SYNC_UP_NOTIFICATION 2 -#define LINK_UP_NOTIFICATION 4 +/* Link Request */ +#define SET_MAC_ADDRESS_REQUEST 0 +#define SYNC_UP_REQUEST 1 +#define SYNCED_UP 2 +#define LINK_UP_REQUEST 3 +#define LINK_CONNECTED 4 +#define SYNC_UP_NOTIFICATION 2 +#define LINK_UP_NOTIFICATION 4 #define LINK_NET_ENTRY 0x0002 -#define HMC_STATUS 0x0004 +#define HMC_STATUS 0x0004 #define LINK_UP_CONTROL_REQ 0x83 #define STATS_POINTER_REQ_STATUS 0x86 #define NETWORK_ENTRY_REQ_PAYLOAD 198 -#define LINK_DOWN_REQ_PAYLOAD 226 +#define LINK_DOWN_REQ_PAYLOAD 226 #define SYNC_UP_REQ_PAYLOAD 228 -#define STATISTICS_POINTER_REQ 237 +#define STATISTICS_POINTER_REQ 237 #define LINK_UP_REQ_PAYLOAD 245 #define LINK_UP_ACK 246 #define STATS_MSG_SIZE 4 #define INDEX_TO_DATA 4 -#define GO_TO_IDLE_MODE_PAYLOAD 210 -#define COME_UP_FROM_IDLE_MODE_PAYLOAD 211 -#define IDLE_MODE_SF_UPDATE_MSG 187 +#define GO_TO_IDLE_MODE_PAYLOAD 210 +#define COME_UP_FROM_IDLE_MODE_PAYLOAD 211 +#define IDLE_MODE_SF_UPDATE_MSG 187 -#define SKB_RESERVE_ETHERNET_HEADER 16 -#define SKB_RESERVE_PHS_BYTES 32 +#define SKB_RESERVE_ETHERNET_HEADER 16 +#define SKB_RESERVE_PHS_BYTES 32 -#define IP_PACKET_ONLY_MODE 0 -#define ETH_PACKET_TUNNELING_MODE 1 +#define IP_PACKET_ONLY_MODE 0 +#define ETH_PACKET_TUNNELING_MODE 1 -#define ETH_CS_802_3 1 -#define ETH_CS_802_1Q_VLAN 3 -#define IPV4_CS 1 -#define IPV6_CS 2 -#define ETH_CS_MASK 0x3f +#define ETH_CS_802_3 1 +#define ETH_CS_802_1Q_VLAN 3 +#define IPV4_CS 1 +#define IPV6_CS 2 +#define ETH_CS_MASK 0x3f /** \brief Validity bit maps for TLVs in packet classification rule */ -#define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0 -#define PKT_CLASSIFICATION_VLANID_VALID 1 +#define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0 +#define PKT_CLASSIFICATION_VLANID_VALID 1 #ifndef MIN -#define MIN(_a, _b) ((_a) < (_b)? (_a): (_b)) +#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b)) #endif /*Leader related terms */ -#define LEADER_STATUS 0x00 -#define LEADER_STATUS_TCP_ACK 0x1 -#define LEADER_SIZE sizeof(LEADER) -#define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND) -#define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND) -#define CM_REQUEST_SIZE LEADER_SIZE + sizeof(stLocalSFChangeRequest) -#define IDLE_REQ_SIZE sizeof(PACKETTOSEND) +#define LEADER_STATUS 0x00 +#define LEADER_STATUS_TCP_ACK 0x1 +#define LEADER_SIZE sizeof(LEADER) +#define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND) +#define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND) +#define CM_REQUEST_SIZE (LEADER_SIZE + sizeof(stLocalSFChangeRequest)) +#define IDLE_REQ_SIZE sizeof(PACKETTOSEND) -#define MAX_TRANSFER_CTRL_BYTE_USB 2 * 1024 +#define MAX_TRANSFER_CTRL_BYTE_USB (2*1024) #define GET_MAILBOX1_REG_REQUEST 0x87 #define GET_MAILBOX1_REG_RESPONSE 0x67 @@ -124,40 +124,40 @@ #define TRANSMIT_NETWORK_DATA 0x00 #define RECEIVED_NETWORK_DATA 0x20 -#define CM_RESPONSES 0xA0 -#define STATUS_RSP 0xA1 -#define LINK_CONTROL_RESP 0xA2 -#define IDLE_MODE_STATUS 0xA3 -#define STATS_POINTER_RESP 0xA6 -#define MGMT_MSG_INFO_SW_STATUS 0xA7 -#define AUTH_SS_HOST_MSG 0xA8 +#define CM_RESPONSES 0xA0 +#define STATUS_RSP 0xA1 +#define LINK_CONTROL_RESP 0xA2 +#define IDLE_MODE_STATUS 0xA3 +#define STATS_POINTER_RESP 0xA6 +#define MGMT_MSG_INFO_SW_STATUS 0xA7 +#define AUTH_SS_HOST_MSG 0xA8 -#define CM_DSA_ACK_PAYLOAD 247 -#define CM_DSC_ACK_PAYLOAD 248 -#define CM_DSD_ACK_PAYLOAD 249 -#define CM_DSDEACTVATE 250 -#define TOTAL_MASKED_ADDRESS_IN_BYTES 32 +#define CM_DSA_ACK_PAYLOAD 247 +#define CM_DSC_ACK_PAYLOAD 248 +#define CM_DSD_ACK_PAYLOAD 249 +#define CM_DSDEACTVATE 250 +#define TOTAL_MASKED_ADDRESS_IN_BYTES 32 -#define MAC_REQ 0 -#define LINK_RESP 1 -#define RSSI_INDICATION 2 +#define MAC_REQ 0 +#define LINK_RESP 1 +#define RSSI_INDICATION 2 -#define SS_INFO 4 -#define STATISTICS_INFO 5 -#define CM_INDICATION 6 -#define PARAM_RESP 7 -#define BUFFER_1K 1024 -#define BUFFER_2K BUFFER_1K*2 -#define BUFFER_4K BUFFER_2K*2 -#define BUFFER_8K BUFFER_4K*2 -#define BUFFER_16K BUFFER_8K*2 -#define DOWNLINK_DIR 0 -#define UPLINK_DIR 1 +#define SS_INFO 4 +#define STATISTICS_INFO 5 +#define CM_INDICATION 6 +#define PARAM_RESP 7 +#define BUFFER_1K 1024 +#define BUFFER_2K (BUFFER_1K*2) +#define BUFFER_4K (BUFFER_2K*2) +#define BUFFER_8K (BUFFER_4K*2) +#define BUFFER_16K (BUFFER_8K*2) +#define DOWNLINK_DIR 0 +#define UPLINK_DIR 1 -#define BCM_SIGNATURE "BECEEM" +#define BCM_SIGNATURE "BECEEM" -#define GPIO_OUTPUT_REGISTER 0x0F00003C +#define GPIO_OUTPUT_REGISTER 0x0F00003C #define BCM_GPIO_OUTPUT_SET_REG 0x0F000040 #define BCM_GPIO_OUTPUT_CLR_REG 0x0F000044 #define GPIO_MODE_REGISTER 0x0F000034 @@ -165,44 +165,43 @@ typedef struct _LINK_STATE { - UCHAR ucLinkStatus; - UCHAR bIdleMode; - UCHAR bShutdownMode; -}LINK_STATE, *PLINK_STATE; + UCHAR ucLinkStatus; + UCHAR bIdleMode; + UCHAR bShutdownMode; +} LINK_STATE, *PLINK_STATE; enum enLinkStatus { - WAIT_FOR_SYNC = 1, - PHY_SYNC_ACHIVED = 2, - LINKUP_IN_PROGRESS = 3, - LINKUP_DONE = 4, - DREG_RECEIVED = 5, - LINK_STATUS_RESET_RECEIVED = 6, - PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW = 7, - LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8, - COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW =9 + WAIT_FOR_SYNC = 1, + PHY_SYNC_ACHIVED = 2, + LINKUP_IN_PROGRESS = 3, + LINKUP_DONE = 4, + DREG_RECEIVED = 5, + LINK_STATUS_RESET_RECEIVED = 6, + PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW = 7, + LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8, + COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9 }; -typedef enum _E_PHS_DSC_ACTION -{ - eAddPHSRule=0, +typedef enum _E_PHS_DSC_ACTION { + eAddPHSRule = 0, eSetPHSRule, eDeletePHSRule, eDeleteAllPHSRules -}E_PHS_DSC_ACTION; +} E_PHS_DSC_ACTION; -#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 // Host to Mac -#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 // Mac to Host -#define MASK_DISABLE_HEADER_SUPPRESSION 0x10 //0b000010000 -#define MINIMUM_PENDING_DESCRIPTORS 5 +#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 /* Host to Mac */ +#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */ +#define MASK_DISABLE_HEADER_SUPPRESSION 0x10 /* 0b000010000 */ +#define MINIMUM_PENDING_DESCRIPTORS 5 #define SHUTDOWN_HOSTINITIATED_REQUESTPAYLOAD 0xCC #define SHUTDOWN_ACK_FROM_DRIVER 0x1 #define SHUTDOWN_NACK_FROM_DRIVER 0x2 -#define LINK_SYNC_UP_SUBTYPE 0x0001 -#define LINK_SYNC_DOWN_SUBTYPE 0x0001 +#define LINK_SYNC_UP_SUBTYPE 0x0001 +#define LINK_SYNC_DOWN_SUBTYPE 0x0001 @@ -226,9 +225,9 @@ typedef enum _E_PHS_DSC_ACTION #define MAX_PENDING_CTRL_PACKET (MAX_CTRL_QUEUE_LEN-10) -#define WIMAX_MAX_MTU (MTU_SIZE + ETH_HLEN) +#define WIMAX_MAX_MTU (MTU_SIZE + ETH_HLEN) #define AUTO_LINKUP_ENABLE 0x2 -#define AUTO_SYNC_DISABLE 0x1 +#define AUTO_SYNC_DISABLE 0x1 #define AUTO_FIRM_DOWNLOAD 0x1 #define SETTLE_DOWN_TIME 50 @@ -242,9 +241,9 @@ typedef enum _E_PHS_DSC_ACTION #define TARGET_CAN_NOT_GO_TO_IDLE_MODE 3 #define IDLE_MODE_PAYLOAD_LENGTH 8 -#define IP_HEADER(Buffer) ((IPHeaderFormat*)(Buffer)) -#define IPV4 4 -#define IP_VERSION(byte) (((byte&0xF0)>>4)) +#define IP_HEADER(Buffer) ((IPHeaderFormat *)(Buffer)) +#define IPV4 4 +#define IP_VERSION(byte) (((byte&0xF0)>>4)) #define SET_MAC_ADDRESS 193 #define SET_MAC_ADDRESS_RESPONSE 236 @@ -263,15 +262,15 @@ typedef enum _E_PHS_DSC_ACTION #define INVALID_QUEUE_INDEX NO_OF_QUEUES -#define INVALID_PID (pid_t)-1 -#define DDR_80_MHZ 0 -#define DDR_100_MHZ 1 -#define DDR_120_MHZ 2 // Additional Frequency for T3LP -#define DDR_133_MHZ 3 -#define DDR_140_MHZ 4 // Not Used (Reserved for future) -#define DDR_160_MHZ 5 // Additional Frequency for T3LP -#define DDR_180_MHZ 6 // Not Used (Reserved for future) -#define DDR_200_MHZ 7 // Not Used (Reserved for future) +#define INVALID_PID ((pid_t)-1) +#define DDR_80_MHZ 0 +#define DDR_100_MHZ 1 +#define DDR_120_MHZ 2 /* Additional Frequency for T3LP */ +#define DDR_133_MHZ 3 +#define DDR_140_MHZ 4 /* Not Used (Reserved for future) */ +#define DDR_160_MHZ 5 /* Additional Frequency for T3LP */ +#define DDR_180_MHZ 6 /* Not Used (Reserved for future) */ +#define DDR_200_MHZ 7 /* Not Used (Reserved for future) */ #define MIPS_200_MHZ 0 #define MIPS_160_MHZ 1 @@ -291,27 +290,27 @@ typedef enum _E_PHS_DSC_ACTION #define EEPROM_REJECT_REG_3 0x0f003008 #define EEPROM_REJECT_REG_4 0x0f003020 #define EEPROM_REJECT_MASK 0x0fffffff -#define VSG_MODE 0x3 +#define VSG_MODE 0x3 /* Idle Mode Related Registers */ #define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C -#define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC +#define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC -#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e -#define DEVICE_INT_OUT_EP_REG0 0x0F011870 -#define DEVICE_INT_OUT_EP_REG1 0x0F011874 +#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e +#define DEVICE_INT_OUT_EP_REG0 0x0F011870 +#define DEVICE_INT_OUT_EP_REG1 0x0F011874 #define BIN_FILE "/lib/firmware/macxvi200.bin" #define CFG_FILE "/lib/firmware/macxvi.cfg" #define SF_MAX_ALLOWED_PACKETS_TO_BACKUP 128 -#define MIN_VAL(x,y) ((x)<(y)?(x):(y)) +#define MIN_VAL(x, y) ((x) < (y) ? (x) : (y)) #define MAC_ADDRESS_SIZE 6 #define EEPROM_COMMAND_Q_REG 0x0F003018 #define EEPROM_READ_DATA_Q_REG 0x0F003020 -#define CHIP_ID_REG 0x0F000000 -#define GPIO_MODE_REG 0x0F000034 -#define GPIO_OUTPUT_REG 0x0F00003C -#define WIMAX_MAX_ALLOWED_RATE 1024*1024*50 +#define CHIP_ID_REG 0x0F000000 +#define GPIO_MODE_REG 0x0F000034 +#define GPIO_OUTPUT_REG 0x0F00003C +#define WIMAX_MAX_ALLOWED_RATE (1024*1024*50) #define T3 0xbece0300 #define TARGET_SFID_TXDESC_MAP_LOC 0xBFFFF400 @@ -319,31 +318,29 @@ typedef enum _E_PHS_DSC_ACTION #define RWM_READ 0 #define RWM_WRITE 1 -#define T3LPB 0xbece3300 -#define BCS220_2 0xbece3311 -#define BCS220_2BC 0xBECE3310 -#define BCS250_BC 0xbece3301 -#define BCS220_3 0xbece3321 +#define T3LPB 0xbece3300 +#define BCS220_2 0xbece3311 +#define BCS220_2BC 0xBECE3310 +#define BCS250_BC 0xbece3301 +#define BCS220_3 0xbece3321 -#define HPM_CONFIG_LDO145 0x0F000D54 -#define HPM_CONFIG_MSW 0x0F000D58 +#define HPM_CONFIG_LDO145 0x0F000D54 +#define HPM_CONFIG_MSW 0x0F000D58 #define T3B 0xbece0310 -typedef enum eNVM_TYPE -{ +typedef enum eNVM_TYPE { NVM_AUTODETECT = 0, NVM_EEPROM, NVM_FLASH, NVM_UNKNOWN -}NVM_TYPE; +} NVM_TYPE; -typedef enum ePMU_MODES -{ +typedef enum ePMU_MODES { HYBRID_MODE_7C = 0, INTERNAL_MODE_6 = 1, HYBRID_MODE_6 = 2 -}PMU_MODE; +} PMU_MODE; #define MAX_RDM_WRM_RETIRES 1 @@ -360,4 +357,4 @@ enum eAbortPattern { #define SKB_CB_LATENCY_OFFSET 1 #define SKB_CB_TCPACK_OFFSET 2 -#endif //__MACROS_H__ +#endif /* __MACROS_H__ */ From eb93ca4e83ecf06a94a36571be730a98177c8e14 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 8 Aug 2011 11:31:48 -0700 Subject: [PATCH 0247/1519] staging: fix ft1000 sparse warnings Fix sparse warnings in staging/ft1000/: drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:69:7: warning: obsolete struct initializer, use C99 syntax and make many functions & data static. Examples: drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:65:23: warning: symbol 'fw_entry' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:836:6: warning: symbol 'ft1000_send_cmd' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:1014:6: warning: symbol 'ft1000_proc_drvmsg' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:1788:5: warning: symbol 'ft1000_copy_down_pkt' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:2096:6: warning: symbol 'stop_ft1000_card' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c:2155:19: warning: symbol 'init_ft1000_card' was not declared. Should it be static? rivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c:172:5: warning: symbol 'ft1000_confcheck' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c:50:5: warning: symbol 'ft1000ReadProc' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c:194:6: warning: symbol 'ft1000InitProc' was not declared. Should it be static? drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c:207:6: warning: symbol 'ft1000CleanupProc' was not declared. Should it be static? Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000.h | 10 ++++++++ .../staging/ft1000/ft1000-pcmcia/ft1000_cs.c | 8 +++---- .../ft1000/ft1000-pcmcia/ft1000_dnld.c | 3 ++- .../staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 24 ++++++++----------- .../ft1000/ft1000-pcmcia/ft1000_proc.c | 4 ++-- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h index 3b0130fe608..adb436ed251 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h @@ -68,6 +68,16 @@ struct ft1000_info { char netdevname[IFNAMSIZ]; }; +struct pcmcia_device; +struct net_device; +extern struct net_device *init_ft1000_card(struct pcmcia_device *link, + void *ft1000_reset); +extern void stop_ft1000_card(struct net_device *dev); +extern int card_download(struct net_device *dev, const u8 *pFileStart, + size_t FileLength); +extern void ft1000InitProc(struct net_device *dev); +extern void ft1000CleanupProc(struct net_device *dev); + extern u16 ft1000_read_dpram(struct net_device *dev, int offset); extern void card_bootload(struct net_device *dev); extern u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index); diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c index 6a1c1d4dcca..f376ca43720 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c @@ -41,14 +41,12 @@ MODULE_LICENSE("GPL"); /*====================================================================*/ -struct net_device *init_ft1000_card(struct pcmcia_device *link, - void *ft1000_reset); -void stop_ft1000_card(struct net_device *); - static int ft1000_config(struct pcmcia_device *link); static void ft1000_detach(struct pcmcia_device *link); static int ft1000_attach(struct pcmcia_device *link); +#include "ft1000.h" + /*====================================================================*/ static void ft1000_reset(struct pcmcia_device *link) @@ -75,7 +73,7 @@ static void ft1000_detach(struct pcmcia_device *link) free_netdev(dev); } -int ft1000_confcheck(struct pcmcia_device *link, void *priv_data) +static int ft1000_confcheck(struct pcmcia_device *link, void *priv_data) { return pcmcia_request_io(link); } diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c index c956857e2d5..f8b8e71284d 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c @@ -287,7 +287,8 @@ u16 hdr_checksum(struct pseudo_hdr *pHdr) return chksum; } -int card_download(struct net_device *dev, const u8 *pFileStart, u32 FileLength) +int card_download(struct net_device *dev, const u8 *pFileStart, + size_t FileLength) { struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); int Status = SUCCESS; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 990b2afb3d6..b3d743a3d30 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -56,16 +56,11 @@ #include #include "ft1000.h" -int card_download(struct net_device *dev, const u8 *pFileStart, u32 FileLength); - -void ft1000InitProc(struct net_device *dev); -void ft1000CleanupProc(struct net_device *dev); - -const struct firmware *fw_entry; +static const struct firmware *fw_entry; static void ft1000_hbchk(u_long data); static struct timer_list poll_timer = { - function:ft1000_hbchk + .function = ft1000_hbchk }; static u16 cmdbuffer[1024]; @@ -788,7 +783,7 @@ static void ft1000_hbchk(u_long data) // Output: // //--------------------------------------------------------------------------- -void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype) +static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype) { struct ft1000_info *info = netdev_priv(dev); int i; @@ -873,7 +868,8 @@ void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qt // = 1 (successful) // //--------------------------------------------------------------------------- -bool ft1000_receive_cmd(struct net_device *dev, u16 * pbuffer, int maxsz, u16 *pnxtph) +static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, + int maxsz, u16 *pnxtph) { struct ft1000_info *info = netdev_priv(dev); u16 size; @@ -966,7 +962,7 @@ bool ft1000_receive_cmd(struct net_device *dev, u16 * pbuffer, int maxsz, u16 *p // none // //--------------------------------------------------------------------------- -void ft1000_proc_drvmsg(struct net_device *dev) +static void ft1000_proc_drvmsg(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); u16 msgtype; @@ -1245,7 +1241,7 @@ void ft1000_proc_drvmsg(struct net_device *dev) // SUCCESS // //--------------------------------------------------------------------------- -int ft1000_parse_dpram_msg(struct net_device *dev) +static int ft1000_parse_dpram_msg(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); u16 doorbell; @@ -1546,7 +1542,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) // SUCCESS // //--------------------------------------------------------------------------- -int ft1000_copy_up_pkt(struct net_device *dev) +static int ft1000_copy_up_pkt(struct net_device *dev) { u16 tempword; struct ft1000_info *info = netdev_priv(dev); @@ -1734,7 +1730,7 @@ int ft1000_copy_up_pkt(struct net_device *dev) // SUCCESS // //--------------------------------------------------------------------------- -int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len) +static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len) { struct ft1000_info *info = netdev_priv(dev); union { @@ -2102,7 +2098,7 @@ static const struct ethtool_ops ops = { }; struct net_device *init_ft1000_card(struct pcmcia_device *link, - void *ft1000_reset) + void *ft1000_reset) { struct ft1000_info *info; struct net_device *dev; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 9e728b3415e..7faeadad1ff 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c @@ -48,8 +48,8 @@ } \ len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i]) -int ft1000ReadProc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int ft1000ReadProc(char *page, char **start, off_t off, + int count, int *eof, void *data) { struct net_device *dev; int len; From fa2d8bbb6360ec4bf831802e925d9db06d3c9649 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Tue, 9 Aug 2011 10:23:42 +0400 Subject: [PATCH 0248/1519] Staging: serqt_usb2: fix sleeping with spinlock held The patch replaces spinlock with mutex. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/serqt_usb2/serqt_usb2.c | 34 ++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 12f5eba0355..2ea82c104d5 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -190,7 +190,7 @@ struct quatech_port { struct usb_serial_port *port; /* owner of this object */ struct qt_get_device_data DeviceData; - spinlock_t lock; + struct mutex lock; bool read_urb_busy; int RxHolding; int ReadBulkStopped; @@ -745,7 +745,7 @@ static int qt_startup(struct usb_serial *serial) } return -ENOMEM; } - spin_lock_init(&qt_port->lock); + mutex_init(&qt_port->lock); usb_set_serial_port_data(port, qt_port); @@ -1160,7 +1160,6 @@ static int qt_write_room(struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial; struct quatech_port *qt_port; - unsigned long flags; int retval = -EINVAL; @@ -1176,7 +1175,7 @@ static int qt_write_room(struct tty_struct *tty) qt_port = qt_get_port_private(port); - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); dbg("%s - port %d\n", __func__, port->number); @@ -1185,7 +1184,7 @@ static int qt_write_room(struct tty_struct *tty) retval = port->bulk_out_size; } - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); return retval; } @@ -1358,7 +1357,6 @@ static void qt_break(struct tty_struct *tty, int break_state) struct quatech_port *qt_port; u16 index, onoff; unsigned int result; - unsigned long flags; index = tty->index - serial->minor; @@ -1369,7 +1367,7 @@ static void qt_break(struct tty_struct *tty, int break_state) else onoff = 0; - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); dbg("%s - port %d\n", __func__, port->number); @@ -1377,7 +1375,7 @@ static void qt_break(struct tty_struct *tty, int break_state) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), QT_BREAK_CONTROL, 0x40, onoff, index, NULL, 0, 300); - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); } static inline int qt_real_tiocmget(struct tty_struct *tty, @@ -1466,21 +1464,20 @@ static int qt_tiocmget(struct tty_struct *tty) struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port = qt_get_port_private(port); int retval = -ENODEV; - unsigned long flags; dbg("In %s\n", __func__); if (!serial) return -ENODEV; - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); dbg("%s - port %d\n", __func__, port->number); dbg("%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding); retval = qt_real_tiocmget(tty, port, serial); - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); return retval; } @@ -1491,7 +1488,6 @@ static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port = qt_get_port_private(port); - unsigned long flags; int retval = -ENODEV; dbg("In %s\n", __func__); @@ -1499,14 +1495,14 @@ static int qt_tiocmset(struct tty_struct *tty, if (!serial) return -ENODEV; - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); dbg("%s - port %d\n", __func__, port->number); dbg("%s - qt_port->RxHolding = %d\n", __func__, qt_port->RxHolding); retval = qt_real_tiocmset(tty, port, serial, set); - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); return retval; } @@ -1515,7 +1511,6 @@ static void qt_throttle(struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port; - unsigned long flags; dbg("%s - port %d\n", __func__, port->number); @@ -1524,13 +1519,13 @@ static void qt_throttle(struct tty_struct *tty) qt_port = qt_get_port_private(port); - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); /* pass on to the driver specific version of this function */ qt_port->RxHolding = 1; dbg("%s - port->RxHolding = 1\n", __func__); - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); return; } @@ -1539,7 +1534,6 @@ static void qt_unthrottle(struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port; - unsigned long flags; unsigned int result; if (!serial) @@ -1547,7 +1541,7 @@ static void qt_unthrottle(struct tty_struct *tty) qt_port = qt_get_port_private(port); - spin_lock_irqsave(&qt_port->lock, flags); + mutex_lock(&qt_port->lock); dbg("%s - port %d\n", __func__, port->number); @@ -1573,7 +1567,7 @@ static void qt_unthrottle(struct tty_struct *tty) __func__, result); } } - spin_unlock_irqrestore(&qt_port->lock, flags); + mutex_unlock(&qt_port->lock); return; } From 65f15e2de870dcd6c843e19eb4960a0ed6f40f6c Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 16:14:03 +0200 Subject: [PATCH 0249/1519] staging: rts_pstor: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index 8db14ddbeb7..fb62eafe4fc 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c @@ -4139,7 +4139,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) cmd[3] = srb->cmnd[5]; cmd[4] = srb->cmnd[6]; - buf = (u8 *)kmalloc(data_len, GFP_KERNEL); + buf = kmalloc(data_len, GFP_KERNEL); if (buf == NULL) { TRACE_RET(chip, TRANSPORT_ERROR); } @@ -4385,7 +4385,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) u16 i; u8 *buf; - buf = (u8 *)kmalloc(data_len, GFP_KERNEL); + buf = kmalloc(data_len, GFP_KERNEL); if (buf == NULL) { TRACE_RET(chip, TRANSPORT_ERROR); } From 8c82b13a2c2b22fc395f39b6aba301e7fbe09440 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:34:09 +0200 Subject: [PATCH 0250/1519] staging: altera-stapl: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/altera-stapl/altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/altera-stapl/altera.c b/drivers/staging/altera-stapl/altera.c index 8d73a864273..be777a4945c 100644 --- a/drivers/staging/altera-stapl/altera.c +++ b/drivers/staging/altera-stapl/altera.c @@ -2384,7 +2384,7 @@ static int altera_get_act_info(u8 *p, act_proc_attribute = (p[proc_table + (13 * act_proc_id) + 8] & 0x03); - procptr = (struct altera_procinfo *) + procptr = kzalloc(sizeof(struct altera_procinfo), GFP_KERNEL); From 4b608983fe9cbb522e6dd819ea357a3af89f2e8e Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:28:50 +0200 Subject: [PATCH 0251/1519] Staging: rts_pstor: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts_pstor/spi.c b/drivers/staging/rts_pstor/spi.c index c803ba63550..6b36cc532a8 100644 --- a/drivers/staging/rts_pstor/spi.c +++ b/drivers/staging/rts_pstor/spi.c @@ -463,7 +463,7 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) } if (len) { - buf = (u8 *)kmalloc(len, GFP_KERNEL); + buf = kmalloc(len, GFP_KERNEL); if (!buf) TRACE_RET(chip, STATUS_ERROR); From 528959aa08265d1e6b90aaf3767d45b9b57f041b Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:31:48 +0200 Subject: [PATCH 0252/1519] staging: ft1000: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 3f303ea1433..aaf44c35982 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -485,7 +485,7 @@ void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer, DEBUG("card_send_command: enter card_send_command... size=%d\n", size); - commandbuf = (unsigned char *)kmalloc(size + 2, GFP_KERNEL); + commandbuf = kmalloc(size + 2, GFP_KERNEL); memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size); ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL); From 8c670f4d157bcaba0001455ace554572b9b417ef Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:39:08 +0200 Subject: [PATCH 0253/1519] staging: tidspbridge: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/gen/gh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/tidspbridge/gen/gh.c b/drivers/staging/tidspbridge/gen/gh.c index cd725033f27..60aa7b063c9 100644 --- a/drivers/staging/tidspbridge/gen/gh.c +++ b/drivers/staging/tidspbridge/gen/gh.c @@ -55,7 +55,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size, hash_tab->match = match; hash_tab->delete = delete == NULL ? noop : delete; - hash_tab->buckets = (struct element **) + hash_tab->buckets = kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL); if (hash_tab->buckets == NULL) { gh_delete(hash_tab); From a5232bde8449b28230f767e8b558021bb5d08e5c Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:27:10 +0200 Subject: [PATCH 0254/1519] staging: rts_pstor: dont cast void* from kmalloc() Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/rtsx_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts_pstor/rtsx_scsi.c b/drivers/staging/rts_pstor/rtsx_scsi.c index 7de1fae443f..f2e5842d4c9 100644 --- a/drivers/staging/rts_pstor/rtsx_scsi.c +++ b/drivers/staging/rts_pstor/rtsx_scsi.c @@ -2730,7 +2730,7 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf_len = data_len = 0x6A; } - buf = (u8 *)kmalloc(buf_len, GFP_KERNEL); + buf = kmalloc(buf_len, GFP_KERNEL); if (!buf) { TRACE_RET(chip, TRANSPORT_ERROR); } From 71c9c2045cc88f2253603bb7634c2eb523f20dea Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 11:09:26 +0200 Subject: [PATCH 0255/1519] staging/easycap: Use memdup_user Use kmemdup_user rather than duplicating its implementation This is a little bit restricted to reduce false positives The semantic patch that makes this output is available in scripts/coccinelle/api/memdup_user.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/easycap_ioctl.c | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c index 0accab97a7f..91262fbd69e 100644 --- a/drivers/staging/easycap/easycap_ioctl.c +++ b/drivers/staging/easycap/easycap_ioctl.c @@ -1317,17 +1317,12 @@ long easycap_unlocked_ioctl(struct file *file, struct v4l2_control *pv4l2_control; JOM(8, "VIDIOC_G_CTRL\n"); - pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL); - if (!pv4l2_control) { - SAM("ERROR: out of memory\n"); + pv4l2_control = memdup_user((void __user *)arg, + sizeof(struct v4l2_control)); + if (IS_ERR(pv4l2_control)) { + SAM("ERROR: copy from user failed\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -ENOMEM; - } - if (0 != copy_from_user(pv4l2_control, (void __user *)arg, - sizeof(struct v4l2_control))) { - kfree(pv4l2_control); - mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -EFAULT; + return PTR_ERR(pv4l2_control); } switch (pv4l2_control->id) { @@ -2356,17 +2351,12 @@ long easycap_unlocked_ioctl(struct file *file, struct v4l2_streamparm *pv4l2_streamparm; JOM(8, "VIDIOC_G_PARM\n"); - pv4l2_streamparm = kzalloc(sizeof(struct v4l2_streamparm), GFP_KERNEL); - if (!pv4l2_streamparm) { - SAM("ERROR: out of memory\n"); + pv4l2_streamparm = memdup_user((void __user *)arg, + sizeof(struct v4l2_streamparm)); + if (IS_ERR(pv4l2_streamparm)) { + SAM("ERROR: copy from user failed\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -ENOMEM; - } - if (copy_from_user(pv4l2_streamparm, - (void __user *)arg, sizeof(struct v4l2_streamparm))) { - kfree(pv4l2_streamparm); - mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -EFAULT; + return PTR_ERR(pv4l2_streamparm); } if (pv4l2_streamparm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { From 7ec24db8dd7eb7e59316552bda92d950e31999d1 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 13 Aug 2011 10:48:57 +0200 Subject: [PATCH 0256/1519] staging: spectra: Use memdup_user Use kmemdup_user rather than duplicating its implementation This is a little bit restricted to reduce false positives The semantic patch that makes this output is available in scripts/coccinelle/api/memdup_user.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/spectra/ffsport.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c index 506547b603e..86d556d6cf9 100644 --- a/drivers/staging/spectra/ffsport.c +++ b/drivers/staging/spectra/ffsport.c @@ -227,19 +227,12 @@ static int ioctl_write_page_data(unsigned long arg) if (copy_from_user(&info, (void __user *)arg, sizeof(info))) return -EFAULT; - buf = kmalloc(IdentifyDeviceData.PageDataSize, GFP_ATOMIC); - if (!buf) { - printk(KERN_ERR "ioctl_write_page_data: " - "failed to allocate memory\n"); - return -ENOMEM; - } - - if (copy_from_user(buf, (void __user *)info.data, - IdentifyDeviceData.PageDataSize)) { + buf = memdup_user((void __user *)info.data, + IdentifyDeviceData.PageDataSize); + if (IS_ERR(buf)) { printk(KERN_ERR "ioctl_write_page_data: " "failed to copy user data\n"); - kfree(buf); - return -EFAULT; + return PTR_ERR(buf); } mutex_lock(&spectra_lock); From 6efa04ebaba71be253e7361140aa990fe7bc3dee Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 15 Aug 2011 01:07:12 -0400 Subject: [PATCH 0257/1519] drivers/staging: do not use EXTRA_CFLAGS Usage of these flags has been deprecated for nearly 4 years by: commit f77bf01425b11947eeb3b5b54685212c302741b8 Author: Sam Ravnborg Date: Mon Oct 15 22:25:06 2007 +0200 kbuild: introduce ccflags-y, asflags-y and ldflags-y Moreover, these flags (at least EXTRA_CFLAGS) have been documented for command line use. By default, gmake(1) do not override command line setting, so this is likely to result in build failure or unexpected behavior. Replace their usage by Kbuild's `{as,cc,ld}flags-y'. Cc: Sam Ravnborg Signed-off-by: Arnaud Lacombe Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxd2099/Makefile | 6 +++--- drivers/staging/go7007/Makefile | 8 ++------ drivers/staging/rtl8187se/Makefile | 6 +++--- drivers/staging/rts_pstor/Makefile | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cxd2099/Makefile b/drivers/staging/cxd2099/Makefile index 72b14558c11..64cfc77be35 100644 --- a/drivers/staging/cxd2099/Makefile +++ b/drivers/staging/cxd2099/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_DVB_CXD2099) += cxd2099.o -EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -EXTRA_CFLAGS += -Idrivers/media/dvb/frontends/ -EXTRA_CFLAGS += -Idrivers/media/common/tuners/ +ccflags-y += -Idrivers/media/dvb/dvb-core/ +ccflags-y += -Idrivers/media/dvb/frontends/ +ccflags-y += -Idrivers/media/common/tuners/ diff --git a/drivers/staging/go7007/Makefile b/drivers/staging/go7007/Makefile index 60a91853570..6ee837c5670 100644 --- a/drivers/staging/go7007/Makefile +++ b/drivers/staging/go7007/Makefile @@ -20,15 +20,11 @@ go7007-y := go7007-v4l2.o go7007-driver.o go7007-i2c.o go7007-fw.o \ s2250-y := s2250-board.o # Uncomment when the saa7134 patches get into upstream -#ifneq ($(CONFIG_VIDEO_SAA7134),) #obj-$(CONFIG_VIDEO_SAA7134) += saa7134-go7007.o -#EXTRA_CFLAGS += -Idrivers/media/video/saa7134 -DSAA7134_MPEG_GO7007=3 -#endif +#ccflags-$(CONFIG_VIDEO_SAA7134:m=y) += -Idrivers/media/video/saa7134 -DSAA7134_MPEG_GO7007=3 # S2250 needs cypress ezusb loader from dvb-usb -ifneq ($(CONFIG_VIDEO_GO7007_USB_S2250_BOARD),) -ccflags-y := -Idrivers/media/dvb/dvb-usb -endif +ccflags-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD:m=y) += -Idrivers/media/dvb/dvb-usb ccflags-y += -Idrivers/media/dvb/frontends ccflags-y += -Idrivers/media/dvb/dvb-core diff --git a/drivers/staging/rtl8187se/Makefile b/drivers/staging/rtl8187se/Makefile index 11a92262c66..72db504b23b 100644 --- a/drivers/staging/rtl8187se/Makefile +++ b/drivers/staging/rtl8187se/Makefile @@ -1,7 +1,7 @@ -#EXTRA_CFLAGS += -DCONFIG_IEEE80211_NOWEP=y -#EXTRA_CFLAGS += -std=gnu89 -#EXTRA_CFLAGS += -O2 +#ccflags-y += -DCONFIG_IEEE80211_NOWEP=y +#ccflags-y += -std=gnu89 +#ccflags-y += -O2 #CC = gcc ccflags-y := -DSW_ANTE diff --git a/drivers/staging/rts_pstor/Makefile b/drivers/staging/rts_pstor/Makefile index 61609aee0a0..42533d39c07 100644 --- a/drivers/staging/rts_pstor/Makefile +++ b/drivers/staging/rts_pstor/Makefile @@ -1,4 +1,4 @@ -EXTRA_CFLAGS := -Idrivers/scsi +ccflags := -Idrivers/scsi obj-$(CONFIG_RTS_PSTOR) := rts_pstor.o From af69c2943f60e4163bf3b3edbccead388b5ab3c5 Mon Sep 17 00:00:00 2001 From: Vincent Abel-Grimalt Date: Wed, 10 Aug 2011 01:13:38 +0200 Subject: [PATCH 0258/1519] Staging : winbond : fix coding style issue in phy_calibration.c Thus us a patch to the phy_calibration.c file that fixes up coding style warning found by the checkpatch.pl tool Signed-off-by: Vincent Abel-Grimalt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/phy_calibration.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/winbond/phy_calibration.c b/drivers/staging/winbond/phy_calibration.c index c5a07fbe10a..77a3fff708c 100644 --- a/drivers/staging/winbond/phy_calibration.c +++ b/drivers/staging/winbond/phy_calibration.c @@ -24,7 +24,7 @@ #define AG_CONST 0.6072529350 #define FIXED(X) ((s32)((X) * 32768.0)) -#define DEG2RAD(X) 0.017453 * (X) +#define DEG2RAD(X) (0.017453 * (X)) static const s32 Angles[] = { FIXED(DEG2RAD(45.0)), FIXED(DEG2RAD(26.565)), FIXED(DEG2RAD(14.0362)), @@ -51,7 +51,7 @@ s32 _s13_to_s32(u32 data) if ((data & BIT(12)) != 0) val |= 0xFFFFF000; - return ((s32) val); + return (s32) val; } u32 _s32_to_s13(s32 data) @@ -184,7 +184,7 @@ s32 _floor(s32 n) else n -= 5; - return (n/10); + return n/10; } /****************************************************************************/ @@ -455,7 +455,7 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) phy_set_rf_data(phw_data, 11, (11<<24)|0x1901D6); /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ phy_set_rf_data(phw_data, 5, (5<<24)|0x24C48A); - /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x06890C); /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); @@ -577,7 +577,7 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) phy_set_rf_data(phw_data, 11, (11<<24)|0x1901D6); /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ phy_set_rf_data(phw_data, 5, (5<<24)|0x24C48A); - /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x06890C); /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); @@ -974,7 +974,7 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) phy_set_rf_data(phw_data, 11, (11<<24)|0x19BDD6); /* 20060612.1.a 0x1905D6); */ /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ phy_set_rf_data(phw_data, 5, (5<<24)|0x24C60A); /* 0x24C60A (high temperature) */ - /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x34880C); /* 20060612.1.a 0x06890C); */ /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); From ab8ac090142daa3371217de98f8a00419f8c2670 Mon Sep 17 00:00:00 2001 From: Pradheep Shrinivasan Date: Fri, 19 Aug 2011 23:15:26 -0700 Subject: [PATCH 0259/1519] Staging: go7007: fix braces coding style issue in wis-tw2804.c This is a patch to the wis-tw2804.c to fix the braces coding style issue as pointed by checkpatch.pl tool Signed-off-by: Pradheep Shrinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/go7007/wis-tw2804.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/go7007/wis-tw2804.c b/drivers/staging/go7007/wis-tw2804.c index 5b218c55842..9134f03e3cf 100644 --- a/drivers/staging/go7007/wis-tw2804.c +++ b/drivers/staging/go7007/wis-tw2804.c @@ -33,8 +33,7 @@ struct wis_tw2804 { int hue; }; -static u8 global_registers[] = -{ +static u8 global_registers[] = { 0x39, 0x00, 0x3a, 0xff, 0x3b, 0x84, @@ -45,8 +44,7 @@ static u8 global_registers[] = 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ }; -static u8 channel_registers[] = -{ +static u8 channel_registers[] = { 0x01, 0xc4, 0x02, 0xa5, 0x03, 0x20, From 2dda95f80b2afa4bf85c6419f40e11b545cda422 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Fri, 15 Jul 2011 13:38:56 -0700 Subject: [PATCH 0260/1519] Staging: hv: vmbus: Don't wait indefinitely for IRQ resouces If an attempt is made to load the vmbus driver on a non-Hyper-V platform, the load operation will hang since we currently wait indefinitely to retrieve the IRQ information. This is done in the context of an acpi callback context (which will obviously not happen when this driver is loaded on a non-Hyper-V platform). This patch fixes the problem. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 1c949f5fb71..67a4f336df9 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -768,7 +768,7 @@ MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table); static int __init hv_acpi_init(void) { - int ret; + int ret, t; init_completion(&probe_event); @@ -781,16 +781,25 @@ static int __init hv_acpi_init(void) if (ret) return ret; - wait_for_completion(&probe_event); + t = wait_for_completion_timeout(&probe_event, 5*HZ); + if (t == 0) { + ret = -ETIMEDOUT; + goto cleanup; + } if (irq <= 0) { - acpi_bus_unregister_driver(&vmbus_acpi_driver); - return -ENODEV; + ret = -ENODEV; + goto cleanup; } ret = vmbus_bus_init(irq); if (ret) - acpi_bus_unregister_driver(&vmbus_acpi_driver); + goto cleanup; + + return 0; + +cleanup: + acpi_bus_unregister_driver(&vmbus_acpi_driver); return ret; } From 064931d0bb088c56e80d427e91a812ee7dd8c7dc Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 19 Jul 2011 11:44:20 -0700 Subject: [PATCH 0261/1519] Staging: hv: tools: Fix a checkpatch warning in hv_kvp_daemon.c Fix a checkpatch warning in hv_kvp_daemon.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/tools/hv_kvp_daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/drivers/staging/hv/tools/hv_kvp_daemon.c index a4a407f7052..8fd0f2ba57b 100644 --- a/drivers/staging/hv/tools/hv_kvp_daemon.c +++ b/drivers/staging/hv/tools/hv_kvp_daemon.c @@ -116,7 +116,7 @@ void kvp_get_os_info(void) uname(&uts_buf); os_build = uts_buf.release; - processor_arch= uts_buf.machine; + processor_arch = uts_buf.machine; file = fopen("/etc/SuSE-release", "r"); if (file != NULL) From dec317fd6accfdba4daff13aa4d9f5abde02b347 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 19 Jul 2011 11:44:21 -0700 Subject: [PATCH 0262/1519] Staging: hv: vmbus: Fix checkpatch warnings Fix checkpatch warnings in hv.c Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index 824f81679ae..2192d7885d4 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output) u64 hv_status = 0; u64 input_address = (input) ? virt_to_phys(input) : 0; u64 output_address = (output) ? virt_to_phys(output) : 0; - volatile void *hypercall_page = hv_context.hypercall_page; + void *hypercall_page = hv_context.hypercall_page; __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8"); __asm__ __volatile__("call *%3" : "=a" (hv_status) : @@ -132,7 +132,7 @@ static u64 do_hypercall(u64 control, void *input, void *output) u64 output_address = (output) ? virt_to_phys(output) : 0; u32 output_address_hi = output_address >> 32; u32 output_address_lo = output_address & 0xFFFFFFFF; - volatile void *hypercall_page = hv_context.hypercall_page; + void *hypercall_page = hv_context.hypercall_page; __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi), "=a"(hv_status_lo) : "d" (control_hi), From e54bbc6471d7f788d829e5f3b5922960048fbff7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Fri, 22 Jul 2011 10:14:31 -0700 Subject: [PATCH 0263/1519] Staging: hv: util: kvp: Fix the reported OSVersion string The current win7 host does not like it when we return the complete kernel release information. Conform to what the host expects. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/tools/hv_kvp_daemon.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/drivers/staging/hv/tools/hv_kvp_daemon.c index 8fd0f2ba57b..c4cf988ad5c 100644 --- a/drivers/staging/hv/tools/hv_kvp_daemon.c +++ b/drivers/staging/hv/tools/hv_kvp_daemon.c @@ -118,6 +118,15 @@ void kvp_get_os_info(void) os_build = uts_buf.release; processor_arch = uts_buf.machine; + /* + * The current windows host (win7) expects the build + * string to be of the form: x.y.z + * Strip additional information we may have. + */ + p = strchr(os_build, '-'); + if (p) + *p = '\0'; + file = fopen("/etc/SuSE-release", "r"); if (file != NULL) goto kvp_osinfo_found; From 5be528c2130a1281ba858296924dd619068bb0e3 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 26 Jul 2011 11:03:10 -0700 Subject: [PATCH 0264/1519] Staging: hv: util: kvp: Cleanup kvp_get_domain_name() Cleanup kvp_get_domain_name(). If getaddrinfo() fails, deal with it properly (this can happen if no IP address has been assigned). Also, don't specify a specific service in the call to getaddrinfo() to make this code as generic as possible. Lastly, move the call to gethostname() after the local variables. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/tools/hv_kvp_daemon.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/drivers/staging/hv/tools/hv_kvp_daemon.c index c4cf988ad5c..11224eddcdc 100644 --- a/drivers/staging/hv/tools/hv_kvp_daemon.c +++ b/drivers/staging/hv/tools/hv_kvp_daemon.c @@ -273,22 +273,20 @@ static int kvp_get_domain_name(char *buffer, int length) { struct addrinfo hints, *info ; - gethostname(buffer, length); int error = 0; + gethostname(buffer, length); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */ hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; - error = getaddrinfo(buffer, "http", &hints, &info); + error = getaddrinfo(buffer, NULL, &hints, &info); if (error != 0) { strcpy(buffer, "getaddrinfo failed\n"); - error = 1; - goto get_domain_done; + return error; } strcpy(buffer, info->ai_canonname); -get_domain_done: freeaddrinfo(info); return error; } From dbbb24947e1bea5e6034ae2edfbf1be5b8f2b062 Mon Sep 17 00:00:00 2001 From: Ruslan Pisarev Date: Fri, 22 Jul 2011 15:12:47 +0300 Subject: [PATCH 0265/1519] Staging: hv: Fix macros, tab errors and warning in drivers/staging/hv/hv_mouse.c This is a patch to the hv_mouse.c file that fixed up macros, tab errors and warning found by the checkpatch.pl tools. Signed-off-by: Ruslan Pisarev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index d957fc22801..9f3fbeeed8d 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -54,7 +54,7 @@ struct hv_input_dev_info { (SYNTHHID_INPUT_VERSION_MAJOR << 16)) -#pragma pack(push,1) +#pragma pack(push, 1) /* * Message types in the synthetic input protocol */ @@ -120,8 +120,8 @@ struct synthhid_input_report { #pragma pack(pop) -#define INPUTVSC_SEND_RING_BUFFER_SIZE 10*PAGE_SIZE -#define INPUTVSC_RECV_RING_BUFFER_SIZE 10*PAGE_SIZE +#define INPUTVSC_SEND_RING_BUFFER_SIZE (10*PAGE_SIZE) +#define INPUTVSC_RECV_RING_BUFFER_SIZE (10*PAGE_SIZE) #define NBITS(x) (((x)/BITS_PER_LONG)+1) @@ -509,22 +509,22 @@ static void mousevsc_on_channel_callback(void *context) desc = (struct vmpacket_descriptor *)buffer; switch (desc->type) { - case VM_PKT_COMP: - mousevsc_on_send_completion( - device, desc); - break; + case VM_PKT_COMP: + mousevsc_on_send_completion( + device, desc); + break; - case VM_PKT_DATA_INBAND: - mousevsc_on_receive( - device, desc); - break; + case VM_PKT_DATA_INBAND: + mousevsc_on_receive( + device, desc); + break; - default: - pr_err("unhandled packet type %d, tid %llx len %d\n", - desc->type, - req_id, - bytes_recvd); - break; + default: + pr_err("unhandled packet type %d, tid %llx len %d\n", + desc->type, + req_id, + bytes_recvd); + break; } /* reset */ @@ -960,7 +960,7 @@ static void __exit mousevsc_exit(void) * installed and/or configured. We don't do anything else with the table, but * it needs to be present. */ -const static struct pci_device_id microsoft_hv_pci_table[] = { +static const struct pci_device_id microsoft_hv_pci_table[] = { { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ { 0 } }; From 1c863c8bcb653be8e2b17b49b24f752392746ee2 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:33 +0100 Subject: [PATCH 0266/1519] staging: et131x: Remove unecessary *etdev NULL check in et1310_phy_init() It is impossible to get to this function with the pointer being NULL. Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 2385d04e748..36534260fae 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -908,9 +908,6 @@ void et1310_phy_init(struct et131x_adapter *etdev) { u16 data, index; - if (etdev == NULL) - return; - /* get the identity (again ?) */ et131x_mii_read(etdev, PHY_ID_1, &data); et131x_mii_read(etdev, PHY_ID_2, &data); From 567486ac7623e55e81c11ccf5d95c68c617d4e71 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:34 +0100 Subject: [PATCH 0267/1519] staging: et131x: Converting et1310_tx.c function and local names from CamelCase Also some minor code clean-ups. Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_tx.c | 268 ++++++++++++------------ drivers/staging/et131x/et131x.h | 2 +- drivers/staging/et131x/et131x_initpci.c | 2 +- 3 files changed, 132 insertions(+), 140 deletions(-) diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index 8fb3051fe28..da9b4af5cec 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -88,12 +88,6 @@ #include "et1310_tx.h" #include "et131x.h" -static inline void et131x_free_send_packet(struct et131x_adapter *etdev, - struct tcb *tcb); -static int et131x_send_packet(struct sk_buff *skb, - struct et131x_adapter *etdev); -static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb); - /** * et131x_tx_dma_memory_alloc * @adapter: pointer to our private adapter structure @@ -186,13 +180,13 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) } /** - * ConfigTxDmaRegs - Set up the tx dma section of the JAGCore. + * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. * @etdev: pointer to our private adapter structure * * Configure the transmit engine with the ring buffers we have created * and prepare it for use. */ -void ConfigTxDmaRegs(struct et131x_adapter *etdev) +void et131x_config_tx_dma_regs(struct et131x_adapter *etdev) { struct txdma_regs __iomem *txdma = &etdev->regs->txdma; @@ -276,131 +270,6 @@ void et131x_init_send(struct et131x_adapter *adapter) tx_ring->send_tail = NULL; } -/** - * et131x_send_packets - This function is called by the OS to send packets - * @skb: the packet(s) to send - * @netdev:device on which to TX the above packet(s) - * - * Return 0 in almost all cases; non-zero value in extreme hard failure only - */ -int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) -{ - int status = 0; - struct et131x_adapter *etdev = NULL; - - etdev = netdev_priv(netdev); - - /* Send these packets - * - * NOTE: The Linux Tx entry point is only given one packet at a time - * to Tx, so the PacketCount and it's array used makes no sense here - */ - - /* TCB is not available */ - if (etdev->tx_ring.used >= NUM_TCB) { - /* NOTE: If there's an error on send, no need to queue the - * packet under Linux; if we just send an error up to the - * netif layer, it will resend the skb to us. - */ - status = -ENOMEM; - } else { - /* We need to see if the link is up; if it's not, make the - * netif layer think we're good and drop the packet - */ - if ((etdev->flags & fMP_ADAPTER_FAIL_SEND_MASK) || - !netif_carrier_ok(netdev)) { - dev_kfree_skb_any(skb); - skb = NULL; - - etdev->net_stats.tx_dropped++; - } else { - status = et131x_send_packet(skb, etdev); - if (status != 0 && status != -ENOMEM) { - /* On any other error, make netif think we're - * OK and drop the packet - */ - dev_kfree_skb_any(skb); - skb = NULL; - etdev->net_stats.tx_dropped++; - } - } - } - return status; -} - -/** - * et131x_send_packet - Do the work to send a packet - * @skb: the packet(s) to send - * @etdev: a pointer to the device's private adapter structure - * - * Return 0 in almost all cases; non-zero value in extreme hard failure only. - * - * Assumption: Send spinlock has been acquired - */ -static int et131x_send_packet(struct sk_buff *skb, - struct et131x_adapter *etdev) -{ - int status; - struct tcb *tcb = NULL; - u16 *shbufva; - unsigned long flags; - - /* All packets must have at least a MAC address and a protocol type */ - if (skb->len < ETH_HLEN) - return -EIO; - - /* Get a TCB for this packet */ - spin_lock_irqsave(&etdev->TCBReadyQLock, flags); - - tcb = etdev->tx_ring.tcb_qhead; - - if (tcb == NULL) { - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); - return -ENOMEM; - } - - etdev->tx_ring.tcb_qhead = tcb->next; - - if (etdev->tx_ring.tcb_qhead == NULL) - etdev->tx_ring.tcb_qtail = NULL; - - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); - - tcb->skb = skb; - - if (skb->data != NULL && skb->len - skb->data_len >= 6) { - shbufva = (u16 *) skb->data; - - if ((shbufva[0] == 0xffff) && - (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) { - tcb->flags |= fMP_DEST_BROAD; - } else if ((shbufva[0] & 0x3) == 0x0001) { - tcb->flags |= fMP_DEST_MULTI; - } - } - - tcb->next = NULL; - - /* Call the NIC specific send handler. */ - status = nic_send_packet(etdev, tcb); - - if (status != 0) { - spin_lock_irqsave(&etdev->TCBReadyQLock, flags); - - if (etdev->tx_ring.tcb_qtail) - etdev->tx_ring.tcb_qtail->next = tcb; - else - /* Apparently ready Q is empty. */ - etdev->tx_ring.tcb_qhead = tcb; - - etdev->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); - return status; - } - WARN_ON(etdev->tx_ring.used > NUM_TCB); - return 0; -} - /** * nic_send_packet - NIC specific send handler for version B silicon. * @etdev: pointer to our adapter @@ -618,16 +487,139 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) return 0; } +/** + * send_packet - Do the work to send a packet + * @skb: the packet(s) to send + * @etdev: a pointer to the device's private adapter structure + * + * Return 0 in almost all cases; non-zero value in extreme hard failure only. + * + * Assumption: Send spinlock has been acquired + */ +static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) +{ + int status; + struct tcb *tcb = NULL; + u16 *shbufva; + unsigned long flags; + + /* All packets must have at least a MAC address and a protocol type */ + if (skb->len < ETH_HLEN) + return -EIO; + + /* Get a TCB for this packet */ + spin_lock_irqsave(&etdev->TCBReadyQLock, flags); + + tcb = etdev->tx_ring.tcb_qhead; + + if (tcb == NULL) { + spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + return -ENOMEM; + } + + etdev->tx_ring.tcb_qhead = tcb->next; + + if (etdev->tx_ring.tcb_qhead == NULL) + etdev->tx_ring.tcb_qtail = NULL; + + spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + + tcb->skb = skb; + + if (skb->data != NULL && skb->len - skb->data_len >= 6) { + shbufva = (u16 *) skb->data; + + if ((shbufva[0] == 0xffff) && + (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) { + tcb->flags |= fMP_DEST_BROAD; + } else if ((shbufva[0] & 0x3) == 0x0001) { + tcb->flags |= fMP_DEST_MULTI; + } + } + + tcb->next = NULL; + + /* Call the NIC specific send handler. */ + status = nic_send_packet(etdev, tcb); + + if (status != 0) { + spin_lock_irqsave(&etdev->TCBReadyQLock, flags); + + if (etdev->tx_ring.tcb_qtail) + etdev->tx_ring.tcb_qtail->next = tcb; + else + /* Apparently ready Q is empty. */ + etdev->tx_ring.tcb_qhead = tcb; + + etdev->tx_ring.tcb_qtail = tcb; + spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + return status; + } + WARN_ON(etdev->tx_ring.used > NUM_TCB); + return 0; +} /** - * et131x_free_send_packet - Recycle a struct tcb + * et131x_send_packets - This function is called by the OS to send packets + * @skb: the packet(s) to send + * @netdev:device on which to TX the above packet(s) + * + * Return 0 in almost all cases; non-zero value in extreme hard failure only + */ +int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) +{ + int status = 0; + struct et131x_adapter *etdev = NULL; + + etdev = netdev_priv(netdev); + + /* Send these packets + * + * NOTE: The Linux Tx entry point is only given one packet at a time + * to Tx, so the PacketCount and it's array used makes no sense here + */ + + /* TCB is not available */ + if (etdev->tx_ring.used >= NUM_TCB) { + /* NOTE: If there's an error on send, no need to queue the + * packet under Linux; if we just send an error up to the + * netif layer, it will resend the skb to us. + */ + status = -ENOMEM; + } else { + /* We need to see if the link is up; if it's not, make the + * netif layer think we're good and drop the packet + */ + if ((etdev->flags & fMP_ADAPTER_FAIL_SEND_MASK) || + !netif_carrier_ok(netdev)) { + dev_kfree_skb_any(skb); + skb = NULL; + + etdev->net_stats.tx_dropped++; + } else { + status = send_packet(skb, etdev); + if (status != 0 && status != -ENOMEM) { + /* On any other error, make netif think we're + * OK and drop the packet + */ + dev_kfree_skb_any(skb); + skb = NULL; + etdev->net_stats.tx_dropped++; + } + } + } + return status; +} + +/** + * free_send_packet - Recycle a struct tcb * @etdev: pointer to our adapter * @tcb: pointer to struct tcb * * Complete the packet if necessary * Assumption - Send spinlock has been acquired */ -inline void et131x_free_send_packet(struct et131x_adapter *etdev, +static inline void free_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) { unsigned long flags; @@ -717,7 +709,7 @@ void et131x_free_busy_send_packets(struct et131x_adapter *etdev) spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); freed++; - et131x_free_send_packet(etdev, tcb); + free_send_packet(etdev, tcb); spin_lock_irqsave(&etdev->TCBSendQLock, flags); @@ -766,7 +758,7 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) etdev->tx_ring.send_tail = NULL; spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); - et131x_free_send_packet(etdev, tcb); + free_send_packet(etdev, tcb); spin_lock_irqsave(&etdev->TCBSendQLock, flags); /* Goto the next packet */ @@ -781,7 +773,7 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) etdev->tx_ring.send_tail = NULL; spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); - et131x_free_send_packet(etdev, tcb); + free_send_packet(etdev, tcb); spin_lock_irqsave(&etdev->TCBSendQLock, flags); /* Goto the next packet */ diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index fa42d94d408..91fafc0331e 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -137,7 +137,7 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *adapter); /* et131x_tx.c */ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter); void et131x_tx_dma_memory_free(struct et131x_adapter *adapter); -void ConfigTxDmaRegs(struct et131x_adapter *adapter); +void et131x_config_tx_dma_regs(struct et131x_adapter *adapter); void et131x_init_send(struct et131x_adapter *adapter); void et131x_tx_dma_disable(struct et131x_adapter *adapter); void et131x_tx_dma_enable(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 09285b92d09..c217a05fa6d 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -389,7 +389,7 @@ int et131x_adapter_setup(struct et131x_adapter *etdev) et1310_config_txmac_regs(etdev); et131x_config_rx_dma_regs(etdev); - ConfigTxDmaRegs(etdev); + et131x_config_tx_dma_regs(etdev); et1310_config_macstat_regs(etdev); From bf04415e63e2c733fa00756c099dacc66dd69b6c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:35 +0100 Subject: [PATCH 0268/1519] staging: et131x: Converting et1310_adapter.h variable names from CamelCase Tested on an ET-131x device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 75 ++++++++++---------- drivers/staging/et131x/et1310_phy.c | 36 +++++----- drivers/staging/et131x/et1310_pm.c | 8 +-- drivers/staging/et131x/et1310_rx.c | 54 +++++++++------ drivers/staging/et131x/et1310_tx.c | 44 ++++++------ drivers/staging/et131x/et131x_adapter.h | 91 ++++++++++++------------- drivers/staging/et131x/et131x_initpci.c | 52 +++++++------- drivers/staging/et131x/et131x_isr.c | 10 +-- drivers/staging/et131x/et131x_netdev.c | 69 ++++++++++--------- 9 files changed, 226 insertions(+), 213 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index d1847c1614b..8e124fe5b9d 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -149,10 +149,10 @@ void et1310_config_mac_regs1(struct et131x_adapter *etdev) * being truncated. Allow the MAC to pass 4 more than our max packet * size. This is 4 for the Ethernet CRC. * - * Packets larger than (RegistryJumboPacket) that do not contain a + * Packets larger than (registry_jumbo_packet) that do not contain a * VLAN ID will be dropped by the Rx function. */ - writel(etdev->RegistryJumboPacket + 4, ¯egs->max_fm_len); + writel(etdev->registry_jumbo_packet + 4, ¯egs->max_fm_len); /* clear out MAC config reset */ writel(0, ¯egs->cfg1); @@ -294,7 +294,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) writel(0, &rxmac->pf_ctrl); /* Let's initialize the Unicast Packet filtering address */ - if (etdev->PacketFilter & ET131X_PACKET_TYPE_DIRECTED) { + if (etdev->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { et1310_setup_device_for_unicast(etdev); pf_ctrl |= 4; /* Unicast filter */ } else { @@ -304,7 +304,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) } /* Let's initialize the Multicast hash */ - if (!(etdev->PacketFilter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { + if (!(etdev->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { pf_ctrl |= 2; /* Multicast filter */ et1310_setup_device_for_multicast(etdev); } @@ -313,7 +313,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16; pf_ctrl |= 8; /* Fragment filter */ - if (etdev->RegistryJumboPacket > 8192) + if (etdev->registry_jumbo_packet > 8192) /* In order to transmit jumbo packets greater than 8k, the * FIFO between RxMAC and RxDMA needs to be reduced in size * to (16k - Jumbo packet size). In order to implement this, @@ -489,22 +489,22 @@ void et1310_update_macstat_host_counters(struct et131x_adapter *etdev) struct macstat_regs __iomem *macstat = &etdev->regs->macstat; - stats->collisions += readl(&macstat->tx_total_collisions); - stats->first_collision += readl(&macstat->tx_single_collisions); - stats->tx_deferred += readl(&macstat->tx_deferred); - stats->excessive_collisions += readl(&macstat->tx_multiple_collisions); - stats->late_collisions += readl(&macstat->tx_late_collisions); - stats->tx_uflo += readl(&macstat->tx_undersize_frames); - stats->max_pkt_error += readl(&macstat->tx_oversize_frames); + stats->tx_collisions += readl(&macstat->tx_total_collisions); + stats->tx_first_collisions += readl(&macstat->tx_single_collisions); + stats->tx_deferred += readl(&macstat->tx_deferred); + stats->tx_excessive_collisions += + readl(&macstat->tx_multiple_collisions); + stats->tx_late_collisions += readl(&macstat->tx_late_collisions); + stats->tx_underflows += readl(&macstat->tx_undersize_frames); + stats->tx_max_pkt_errs += readl(&macstat->tx_oversize_frames); - stats->alignment_err += readl(&macstat->rx_align_errs); - stats->crc_err += readl(&macstat->rx_code_errs); - stats->norcvbuf += readl(&macstat->rx_drops); - stats->rx_ov_flow += readl(&macstat->rx_oversize_packets); - stats->code_violations += readl(&macstat->rx_fcs_errs); - stats->length_err += readl(&macstat->rx_frame_len_errs); - - stats->other_errors += readl(&macstat->rx_fragment_packets); + stats->rx_align_errs += readl(&macstat->rx_align_errs); + stats->rx_crc_errs += readl(&macstat->rx_code_errs); + stats->rcvd_pkts_dropped += readl(&macstat->rx_drops); + stats->rx_overflows += readl(&macstat->rx_oversize_packets); + stats->rx_code_violations += readl(&macstat->rx_fcs_errs); + stats->rx_length_errs += readl(&macstat->rx_frame_len_errs); + stats->rx_other_errs += readl(&macstat->rx_fragment_packets); } /** @@ -536,33 +536,33 @@ void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) * block indicates that one of the counters has wrapped. */ if (carry_reg1 & (1 << 14)) - etdev->stats.code_violations += COUNTER_WRAP_16_BIT; + etdev->stats.rx_code_violations += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 8)) - etdev->stats.alignment_err += COUNTER_WRAP_12_BIT; + etdev->stats.rx_align_errs += COUNTER_WRAP_12_BIT; if (carry_reg1 & (1 << 7)) - etdev->stats.length_err += COUNTER_WRAP_16_BIT; + etdev->stats.rx_length_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 2)) - etdev->stats.other_errors += COUNTER_WRAP_16_BIT; + etdev->stats.rx_other_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 6)) - etdev->stats.crc_err += COUNTER_WRAP_16_BIT; + etdev->stats.rx_crc_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 3)) - etdev->stats.rx_ov_flow += COUNTER_WRAP_16_BIT; + etdev->stats.rx_overflows += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 0)) - etdev->stats.norcvbuf += COUNTER_WRAP_16_BIT; + etdev->stats.rcvd_pkts_dropped += COUNTER_WRAP_16_BIT; if (carry_reg2 & (1 << 16)) - etdev->stats.max_pkt_error += COUNTER_WRAP_12_BIT; + etdev->stats.tx_max_pkt_errs += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 15)) - etdev->stats.tx_uflo += COUNTER_WRAP_12_BIT; + etdev->stats.tx_underflows += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 6)) - etdev->stats.first_collision += COUNTER_WRAP_12_BIT; + etdev->stats.tx_first_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 8)) - etdev->stats.tx_deferred += COUNTER_WRAP_12_BIT; + etdev->stats.tx_deferred += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 5)) - etdev->stats.excessive_collisions += COUNTER_WRAP_12_BIT; + etdev->stats.tx_excessive_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 4)) - etdev->stats.late_collisions += COUNTER_WRAP_12_BIT; + etdev->stats.tx_late_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 2)) - etdev->stats.collisions += COUNTER_WRAP_12_BIT; + etdev->stats.tx_collisions += COUNTER_WRAP_12_BIT; } void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) @@ -581,10 +581,11 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) * specified) then we should pass NO multi-cast addresses to the * driver. */ - if (etdev->PacketFilter & ET131X_PACKET_TYPE_MULTICAST) { + if (etdev->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { /* Loop through our multicast array and set up the device */ - for (nIndex = 0; nIndex < etdev->MCAddressCount; nIndex++) { - result = ether_crc(6, etdev->MCList[nIndex]); + for (nIndex = 0; nIndex < etdev->multicast_addr_count; + nIndex++) { + result = ether_crc(6, etdev->multicast_list[nIndex]); result = (result & 0x3F800000) >> 23; diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 36534260fae..9d2ce08d9ae 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -596,7 +596,7 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) } /* Determine if we need to go into a force mode and set it */ - if (etdev->AiForceSpeed == 0 && etdev->AiForceDpx == 0) { + if (etdev->ai_force_speed == 0 && etdev->ai_force_duplex == 0) { if (etdev->wanted_flow == FLOW_TXONLY || etdev->wanted_flow == FLOW_BOTH) et1310_phy_access_mii_bit(etdev, @@ -623,7 +623,7 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) et1310_phy_auto_neg(etdev, false); /* Set to the correct force mode. */ - if (etdev->AiForceDpx != 1) { + if (etdev->ai_force_duplex != 1) { if (etdev->wanted_flow == FLOW_TXONLY || etdev->wanted_flow == FLOW_BOTH) et1310_phy_access_mii_bit(etdev, @@ -645,16 +645,16 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) 4, 11, NULL); } et1310_phy_power_down(etdev, 1); - switch (etdev->AiForceSpeed) { + switch (etdev->ai_force_speed) { case 10: /* First we need to turn off all other advertisement */ et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - if (etdev->AiForceDpx == 1) { + if (etdev->ai_force_duplex == 1) { /* Set our advertise values accordingly */ et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); - } else if (etdev->AiForceDpx == 2) { + } else if (etdev->ai_force_duplex == 2) { /* Set our advertise values accordingly */ et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); @@ -674,13 +674,13 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) /* first we need to turn off all other advertisement */ et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - if (etdev->AiForceDpx == 1) { + if (etdev->ai_force_duplex == 1) { /* Set our advertise values accordingly */ et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); /* Set speed */ et1310_phy_speed_select(etdev, TRUEPHY_SPEED_100MBPS); - } else if (etdev->AiForceDpx == 2) { + } else if (etdev->ai_force_duplex == 2) { /* Set our advertise values accordingly */ et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); @@ -741,11 +741,11 @@ void et131x_mii_check(struct et131x_adapter *etdev, /* Update our state variables and indicate the * connected state */ - spin_lock_irqsave(&etdev->Lock, flags); + spin_lock_irqsave(&etdev->lock, flags); - etdev->MediaState = NETIF_STATUS_MEDIA_CONNECT; + etdev->media_state = NETIF_STATUS_MEDIA_CONNECT; - spin_unlock_irqrestore(&etdev->Lock, flags); + spin_unlock_irqrestore(&etdev->lock, flags); netif_carrier_on(etdev->netdev); } else { @@ -774,11 +774,11 @@ void et131x_mii_check(struct et131x_adapter *etdev, * Timer expires, we can report disconnected (handled * in the LinkDetectionDPC). */ - if ((etdev->MediaState == NETIF_STATUS_MEDIA_DISCONNECT)) { - spin_lock_irqsave(&etdev->Lock, flags); - etdev->MediaState = + if (etdev->media_state == NETIF_STATUS_MEDIA_DISCONNECT) { + spin_lock_irqsave(&etdev->lock, flags); + etdev->media_state = NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&etdev->Lock, + spin_unlock_irqrestore(&etdev->lock, flags); netif_carrier_off(etdev->netdev); @@ -810,15 +810,15 @@ void et131x_mii_check(struct et131x_adapter *etdev, /* Setup the PHY into coma mode until the cable is * plugged back in */ - if (etdev->RegistryPhyComa == 1) + if (etdev->registry_phy_coma == 1) et1310_enable_phy_coma(etdev); } } if ((bmsr_ints & MI_BMSR_AUTO_NEG_COMPLETE) || - (etdev->AiForceDpx == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { + (etdev->ai_force_duplex == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { if ((bmsr & MI_BMSR_AUTO_NEG_COMPLETE) || - etdev->AiForceDpx == 3) { + etdev->ai_force_duplex == 3) { et1310_phy_link_status(etdev, &link_status, &autoneg_status, &speed, &duplex, &mdi_mdix, @@ -849,7 +849,7 @@ void et131x_mii_check(struct et131x_adapter *etdev, et1310_config_flow_control(etdev); if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && - etdev->RegistryJumboPacket > 2048) + etdev->registry_jumbo_packet > 2048) et1310_phy_and_or_reg(etdev, 0x16, 0xcfff, 0x2000); diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index 1bfcc670501..914aff65d69 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -116,8 +116,8 @@ void et1310_enable_phy_coma(struct et131x_adapter *etdev) /* Save the GbE PHY speed and duplex modes. Need to restore this * when cable is plugged back in */ - etdev->pdown_speed = etdev->AiForceSpeed; - etdev->pdown_duplex = etdev->AiForceDpx; + etdev->pdown_speed = etdev->ai_force_speed; + etdev->pdown_duplex = etdev->ai_force_duplex; /* Stop sending packets. */ spin_lock_irqsave(&etdev->send_hw_lock, flags); @@ -153,8 +153,8 @@ void et1310_disable_phy_coma(struct et131x_adapter *etdev) /* Restore the GbE PHY speed and duplex modes; * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY */ - etdev->AiForceSpeed = etdev->pdown_speed; - etdev->AiForceDpx = etdev->pdown_duplex; + etdev->ai_force_speed = etdev->pdown_speed; + etdev->ai_force_duplex = etdev->pdown_duplex; /* Re-initialize the send structures */ et131x_init_send(etdev); diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 694bb028477..09243092cb7 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -149,14 +149,14 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * the number of entries halves. FBR0 increases in size, however. */ - if (adapter->RegistryJumboPacket < 2048) { + if (adapter->registry_jumbo_packet < 2048) { #ifdef USE_FBR0 rx_ring->fbr0_buffsize = 256; rx_ring->fbr0_num_entries = 512; #endif rx_ring->fbr1_buffsize = 2048; rx_ring->fbr1_num_entries = 512; - } else if (adapter->RegistryJumboPacket < 4096) { + } else if (adapter->registry_jumbo_packet < 4096) { #ifdef USE_FBR0 rx_ring->fbr0_buffsize = 512; rx_ring->fbr0_num_entries = 1024; @@ -755,7 +755,7 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || #endif (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { - spin_lock_irqsave(&etdev->FbrLock, flags); + spin_lock_irqsave(&etdev->fbr_lock, flags); if (ring_index == 1) { struct fbr_desc *next = @@ -793,7 +793,7 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) &rx_dma->fbr0_full_offset); } #endif - spin_unlock_irqrestore(&etdev->FbrLock, flags); + spin_unlock_irqrestore(&etdev->fbr_lock, flags); } else { dev_err(&etdev->pdev->dev, "%s illegal Buffer Index returned\n", __func__); @@ -983,18 +983,18 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * also counted here. */ if (len < (NIC_MIN_PACKET_SIZE + 4)) { - etdev->stats.other_errors++; + etdev->stats.rx_other_errs++; len = 0; } if (len) { - if (etdev->ReplicaPhyLoopbk == 1) { + if (etdev->replica_phy_loopbk == 1) { buf = rx_local->fbr[ring_index]->virt[buff_index]; if (memcmp(&buf[6], etdev->addr, ETH_ALEN) == 0) { if (memcmp(&buf[42], "Replica packet", ETH_HLEN)) { - etdev->ReplicaPhyLoopbkPF = 1; + etdev->replica_phy_loopbk_passfail = 1; } } } @@ -1009,9 +1009,12 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * filters. Generally filter is 0x2b when in * promiscuous mode. */ - if ((etdev->PacketFilter & ET131X_PACKET_TYPE_MULTICAST) - && !(etdev->PacketFilter & ET131X_PACKET_TYPE_PROMISCUOUS) - && !(etdev->PacketFilter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { + if ((etdev->packet_filter & + ET131X_PACKET_TYPE_MULTICAST) + && !(etdev->packet_filter & + ET131X_PACKET_TYPE_PROMISCUOUS) + && !(etdev->packet_filter & + ET131X_PACKET_TYPE_ALL_MULTICAST)) { buf = rx_local->fbr[ring_index]-> virt[buff_index]; @@ -1019,13 +1022,20 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * destination address of this packet * matches one in our list. */ - for (i = 0; i < etdev->MCAddressCount; i++) { - if (buf[0] == etdev->MCList[i][0] - && buf[1] == etdev->MCList[i][1] - && buf[2] == etdev->MCList[i][2] - && buf[3] == etdev->MCList[i][3] - && buf[4] == etdev->MCList[i][4] - && buf[5] == etdev->MCList[i][5]) { + for (i = 0; i < etdev->multicast_addr_count; + i++) { + if (buf[0] == + etdev->multicast_list[i][0] + && buf[1] == + etdev->multicast_list[i][1] + && buf[2] == + etdev->multicast_list[i][2] + && buf[3] == + etdev->multicast_list[i][3] + && buf[4] == + etdev->multicast_list[i][4] + && buf[5] == + etdev->multicast_list[i][5]) { break; } } @@ -1038,21 +1048,21 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * so we free our RFD when we return * from this function. */ - if (i == etdev->MCAddressCount) + if (i == etdev->multicast_addr_count) len = 0; } if (len > 0) - etdev->stats.multircv++; + etdev->stats.multicast_pkts_rcvd++; } else if (word0 & ALCATEL_BROADCAST_PKT) - etdev->stats.brdcstrcv++; + etdev->stats.broadcast_pkts_rcvd++; else /* Not sure what this counter measures in * promiscuous mode. Perhaps we should check * the MAC address to see if it is directed * to us in promiscuous mode. */ - etdev->stats.unircv++; + etdev->stats.unicast_pkts_rcvd++; } if (len > 0) { @@ -1128,7 +1138,7 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) * If length is zero, return the RFD in order to advance the * Free buffer ring. */ - if (!etdev->PacketFilter || + if (!etdev->packet_filter || !netif_carrier_ok(etdev->netdev) || rfd->len == 0) continue; diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index da9b4af5cec..eb8552b251d 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -456,7 +456,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) } else tcb->index = etdev->tx_ring.send_idx - 1; - spin_lock(&etdev->TCBSendQLock); + spin_lock(&etdev->tcb_send_qlock); if (etdev->tx_ring.send_tail) etdev->tx_ring.send_tail->next = tcb; @@ -469,7 +469,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) etdev->tx_ring.used++; - spin_unlock(&etdev->TCBSendQLock); + spin_unlock(&etdev->tcb_send_qlock); /* Write the new write pointer back to the device. */ writel(etdev->tx_ring.send_idx, @@ -508,12 +508,12 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) return -EIO; /* Get a TCB for this packet */ - spin_lock_irqsave(&etdev->TCBReadyQLock, flags); + spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); tcb = etdev->tx_ring.tcb_qhead; if (tcb == NULL) { - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); return -ENOMEM; } @@ -522,7 +522,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) if (etdev->tx_ring.tcb_qhead == NULL) etdev->tx_ring.tcb_qtail = NULL; - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); tcb->skb = skb; @@ -543,7 +543,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) status = nic_send_packet(etdev, tcb); if (status != 0) { - spin_lock_irqsave(&etdev->TCBReadyQLock, flags); + spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); if (etdev->tx_ring.tcb_qtail) etdev->tx_ring.tcb_qtail->next = tcb; @@ -552,7 +552,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) etdev->tx_ring.tcb_qhead = tcb; etdev->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); return status; } WARN_ON(etdev->tx_ring.used > NUM_TCB); @@ -627,11 +627,11 @@ static inline void free_send_packet(struct et131x_adapter *etdev, struct net_device_stats *stats = &etdev->net_stats; if (tcb->flags & fMP_DEST_BROAD) - atomic_inc(&etdev->stats.brdcstxmt); + atomic_inc(&etdev->stats.broadcast_pkts_xmtd); else if (tcb->flags & fMP_DEST_MULTI) - atomic_inc(&etdev->stats.multixmt); + atomic_inc(&etdev->stats.multicast_pkts_xmtd); else - atomic_inc(&etdev->stats.unixmt); + atomic_inc(&etdev->stats.unicast_pkts_xmtd); if (tcb->skb) { stats->tx_bytes += tcb->skb->len; @@ -663,7 +663,7 @@ static inline void free_send_packet(struct et131x_adapter *etdev, memset(tcb, 0, sizeof(struct tcb)); /* Add the TCB to the Ready Q */ - spin_lock_irqsave(&etdev->TCBReadyQLock, flags); + spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); etdev->net_stats.tx_packets++; @@ -675,7 +675,7 @@ static inline void free_send_packet(struct et131x_adapter *etdev, etdev->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); WARN_ON(etdev->tx_ring.used < 0); } @@ -692,7 +692,7 @@ void et131x_free_busy_send_packets(struct et131x_adapter *etdev) u32 freed = 0; /* Any packets being sent? Check the first TCB on the send list */ - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); tcb = etdev->tx_ring.send_head; @@ -706,19 +706,19 @@ void et131x_free_busy_send_packets(struct et131x_adapter *etdev) etdev->tx_ring.used--; - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); freed++; free_send_packet(etdev, tcb); - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); tcb = etdev->tx_ring.send_head; } WARN_ON(freed == NUM_TCB); - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); etdev->tx_ring.used = 0; } @@ -745,7 +745,7 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) /* Has the ring wrapped? Process any descriptors that do not have * the same "wrap" indicator as the current completion indicator */ - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); tcb = etdev->tx_ring.send_head; @@ -757,9 +757,9 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) if (tcb->next == NULL) etdev->tx_ring.send_tail = NULL; - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); free_send_packet(etdev, tcb); - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); /* Goto the next packet */ tcb = etdev->tx_ring.send_head; @@ -772,9 +772,9 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) if (tcb->next == NULL) etdev->tx_ring.send_tail = NULL; - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); free_send_packet(etdev, tcb); - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); /* Goto the next packet */ tcb = etdev->tx_ring.send_head; @@ -784,6 +784,6 @@ void et131x_handle_send_interrupt(struct et131x_adapter *etdev) if (etdev->tx_ring.used <= NUM_TCB / 3) netif_wake_queue(etdev->netdev); - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); } diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 408c50ba4f2..5dfa1534959 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -105,40 +105,39 @@ struct ce_stats { * MUST have 32, then we'll need another way to perform atomic * operations */ - u32 unircv; /* # multicast packets received */ - atomic_t unixmt; /* # multicast packets for Tx */ - u32 multircv; /* # multicast packets received */ - atomic_t multixmt; /* # multicast packets for Tx */ - u32 brdcstrcv; /* # broadcast packets received */ - atomic_t brdcstxmt; /* # broadcast packets for Tx */ - u32 norcvbuf; /* # Rx packets discarded */ - u32 noxmtbuf; /* # Tx packets discarded */ + u32 unicast_pkts_rcvd; + atomic_t unicast_pkts_xmtd; + u32 multicast_pkts_rcvd; + atomic_t multicast_pkts_xmtd; + u32 broadcast_pkts_rcvd; + atomic_t broadcast_pkts_xmtd; + u32 rcvd_pkts_dropped; /* Transceiver state informations. */ - u8 xcvr_addr; - u32 xcvr_id; + u8 xcvr_addr; + u32 xcvr_id; /* Tx Statistics. */ - u32 tx_uflo; /* Tx Underruns */ + u32 tx_underflows; - u32 collisions; - u32 excessive_collisions; - u32 first_collision; - u32 late_collisions; - u32 max_pkt_error; - u32 tx_deferred; + u32 tx_collisions; + u32 tx_excessive_collisions; + u32 tx_first_collisions; + u32 tx_late_collisions; + u32 tx_max_pkt_errs; + u32 tx_deferred; /* Rx Statistics. */ - u32 rx_ov_flow; /* Rx Overflow */ + u32 rx_overflows; - u32 length_err; - u32 alignment_err; - u32 crc_err; - u32 code_violations; - u32 other_errors; + u32 rx_length_errs; + u32 rx_align_errs; + u32 rx_crc_errs; + u32 rx_code_violations; + u32 rx_other_errs; - u32 SynchrounousIterations; - u32 InterruptStatus; + u32 synchronous_iterations; + u32 interrupt_status; }; @@ -151,7 +150,7 @@ struct et131x_adapter { /* Flags that indicate current state of the adapter */ u32 flags; - u32 HwErrCount; + u32 hw_errs; /* Configuration */ u8 rom_addr[ETH_ALEN]; @@ -160,52 +159,52 @@ struct et131x_adapter { u8 eeprom_data[2]; /* Spinlocks */ - spinlock_t Lock; + spinlock_t lock; - spinlock_t TCBSendQLock; - spinlock_t TCBReadyQLock; + spinlock_t tcb_send_qlock; + spinlock_t tcb_ready_qlock; spinlock_t send_hw_lock; spinlock_t rcv_lock; - spinlock_t RcvPendLock; - spinlock_t FbrLock; + spinlock_t rcv_pend_lock; + spinlock_t fbr_lock; - spinlock_t PHYLock; + spinlock_t phy_lock; /* Packet Filter and look ahead size */ - u32 PacketFilter; + u32 packet_filter; u32 linkspeed; u32 duplex_mode; /* multicast list */ - u32 MCAddressCount; - u8 MCList[NIC_MAX_MCAST_LIST][ETH_ALEN]; + u32 multicast_addr_count; + u8 multicast_list[NIC_MAX_MCAST_LIST][ETH_ALEN]; /* Pointer to the device's PCI register space */ struct address_map __iomem *regs; /* Registry parameters */ - u8 SpeedDuplex; /* speed/duplex */ + u8 speed_duplex; /* speed/duplex */ u8 wanted_flow; /* Flow we want for 802.3x flow control */ - u8 RegistryPhyComa; /* Phy Coma mode enable/disable */ + u8 registry_phy_coma; /* Phy Coma mode enable/disable */ - u32 RegistryRxMemEnd; /* Size of internal rx memory */ - u32 RegistryJumboPacket; /* Max supported ethernet packet size */ + u32 registry_rx_mem_end; /* Size of internal rx memory */ + u32 registry_jumbo_packet; /* Max supported ethernet packet size */ /* Derived from the registry: */ - u8 AiForceDpx; /* duplex setting */ - u16 AiForceSpeed; /* 'Speed', user over-ride of line speed */ + u8 ai_force_duplex; /* duplex setting */ + u16 ai_force_speed; /* 'Speed', user over-ride of line speed */ u8 flowcontrol; /* flow control validated by the far-end */ enum { NETIF_STATUS_INVALID = 0, NETIF_STATUS_MEDIA_CONNECT, NETIF_STATUS_MEDIA_DISCONNECT, NETIF_STATUS_MAX - } MediaState; + } media_state; /* Minimize init-time */ - struct timer_list ErrorTimer; + struct timer_list error_timer; /* variable putting the phy into coma mode when boot up with no cable * plugged in after 5 seconds @@ -219,7 +218,7 @@ struct et131x_adapter { u16 pdown_speed; u8 pdown_duplex; - u32 CachedMaskValue; + u32 cached_mask_value; /* Xcvr status at last poll */ u16 bmsr; @@ -231,8 +230,8 @@ struct et131x_adapter { struct rx_ring rx_ring; /* Loopback specifics */ - u8 ReplicaPhyLoopbk; /* Replica Enable */ - u8 ReplicaPhyLoopbkPF; /* Replica Enable Pass/Fail */ + u8 replica_phy_loopbk; /* Replica Enable */ + u8 replica_phy_loopbk_passfail; /* Replica Enable Pass/Fail */ /* Stats */ struct ce_stats stats; diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index c217a05fa6d..32a20ddaac5 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -275,14 +275,14 @@ void et131x_error_timer_handler(unsigned long data) "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); if (!(etdev->bmsr & MI_BMSR_LINK_STATUS) && - etdev->RegistryPhyComa && + etdev->registry_phy_coma && etdev->boot_coma < 11) { etdev->boot_coma++; } if (etdev->boot_coma == 10) { if (!(etdev->bmsr & MI_BMSR_LINK_STATUS) - && etdev->RegistryPhyComa) { + && etdev->registry_phy_coma) { if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { /* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux? @@ -294,7 +294,7 @@ void et131x_error_timer_handler(unsigned long data) } /* This is a periodic timer, so reschedule */ - mod_timer(&etdev->ErrorTimer, jiffies + + mod_timer(&etdev->error_timer, jiffies + TX_ERROR_PERIOD * HZ / 1000); } @@ -308,12 +308,12 @@ void et131x_link_detection_handler(unsigned long data) struct et131x_adapter *etdev = (struct et131x_adapter *) data; unsigned long flags; - if (etdev->MediaState == 0) { - spin_lock_irqsave(&etdev->Lock, flags); + if (etdev->media_state == 0) { + spin_lock_irqsave(&etdev->lock, flags); - etdev->MediaState = NETIF_STATUS_MEDIA_DISCONNECT; + etdev->media_state = NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&etdev->Lock, flags); + spin_unlock_irqrestore(&etdev->lock, flags); netif_carrier_off(etdev->netdev); } @@ -332,7 +332,7 @@ void et131x_configure_global_regs(struct et131x_adapter *etdev) writel(0, ®s->rxq_start_addr); writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); - if (etdev->RegistryJumboPacket < 2048) { + if (etdev->registry_jumbo_packet < 2048) { /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word * block of RAM that the driver can split between Tx * and Rx as it desires. Our default is to split it @@ -340,7 +340,7 @@ void et131x_configure_global_regs(struct et131x_adapter *etdev) */ writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); - } else if (etdev->RegistryJumboPacket < 8192) { + } else if (etdev->registry_jumbo_packet < 8192) { /* For jumbo packets > 2k but < 8k, split 50-50. */ writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); @@ -547,27 +547,27 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, netdev->base_addr = pci_resource_start(pdev, 0); /* Initialize spinlocks here */ - spin_lock_init(&etdev->Lock); - spin_lock_init(&etdev->TCBSendQLock); - spin_lock_init(&etdev->TCBReadyQLock); + spin_lock_init(&etdev->lock); + spin_lock_init(&etdev->tcb_send_qlock); + spin_lock_init(&etdev->tcb_ready_qlock); spin_lock_init(&etdev->send_hw_lock); spin_lock_init(&etdev->rcv_lock); - spin_lock_init(&etdev->RcvPendLock); - spin_lock_init(&etdev->FbrLock); - spin_lock_init(&etdev->PHYLock); + spin_lock_init(&etdev->rcv_pend_lock); + spin_lock_init(&etdev->fbr_lock); + spin_lock_init(&etdev->phy_lock); /* Parse configuration parameters into the private adapter struct */ if (et131x_speed_set) dev_info(&etdev->pdev->dev, "Speed set manually to : %d\n", et131x_speed_set); - etdev->SpeedDuplex = et131x_speed_set; - etdev->RegistryJumboPacket = 1514; /* 1514-9216 */ + etdev->speed_duplex = et131x_speed_set; + etdev->registry_jumbo_packet = 1514; /* 1514-9216 */ /* Set the MAC address to a default */ memcpy(etdev->addr, default_mac, ETH_ALEN); - /* Decode SpeedDuplex + /* Decode speed_duplex * * Set up as if we are auto negotiating always and then change if we * go into force mode @@ -576,11 +576,11 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, * knock it down to 100 full. */ if (etdev->pdev->device == ET131X_PCI_DEVICE_ID_FAST && - etdev->SpeedDuplex == 5) - etdev->SpeedDuplex = 4; + etdev->speed_duplex == 5) + etdev->speed_duplex = 4; - etdev->AiForceSpeed = speed[etdev->SpeedDuplex]; - etdev->AiForceDpx = duplex[etdev->SpeedDuplex]; /* Auto FDX */ + etdev->ai_force_speed = speed[etdev->speed_duplex]; + etdev->ai_force_duplex = duplex[etdev->speed_duplex]; /* Auto FDX */ return etdev; } @@ -711,11 +711,11 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, et131x_adapter_setup(adapter); /* Create a timer to count errors received by the NIC */ - init_timer(&adapter->ErrorTimer); + init_timer(&adapter->error_timer); - adapter->ErrorTimer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; - adapter->ErrorTimer.function = et131x_error_timer_handler; - adapter->ErrorTimer.data = (unsigned long)adapter; + adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; + adapter->error_timer.function = et131x_error_timer_handler; + adapter->error_timer.data = (unsigned long)adapter; /* Initialize link state */ et131x_link_detection_handler((unsigned long)adapter); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 9b316bed074..1584ab21761 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -124,7 +124,7 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter) else mask = INT_MASK_ENABLE_NO_FLOW; - adapter->CachedMaskValue = mask; + adapter->cached_mask_value = mask; writel(mask, &adapter->regs->global.int_mask); } @@ -138,7 +138,7 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter) void et131x_disable_interrupts(struct et131x_adapter *adapter) { /* Disable all global interrupts */ - adapter->CachedMaskValue = INT_MASK_DISABLE; + adapter->cached_mask_value = INT_MASK_DISABLE; writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); } @@ -222,7 +222,7 @@ irqreturn_t et131x_isr(int irq, void *dev_id) * DPC. We will clear the software copy of that in that * routine. */ - adapter->stats.InterruptStatus = status; + adapter->stats.interrupt_status = status; /* Schedule the ISR handler as a bottom-half task in the * kernel's tq_immediate queue, and mark the queue for @@ -244,7 +244,7 @@ void et131x_isr_handler(struct work_struct *work) { struct et131x_adapter *etdev = container_of(work, struct et131x_adapter, task); - u32 status = etdev->stats.InterruptStatus; + u32 status = etdev->stats.interrupt_status; struct address_map __iomem *iomem = etdev->regs; /* @@ -389,7 +389,7 @@ void et131x_isr_handler(struct work_struct *work) (uint8_t) offsetof(struct mi_regs, isr), &myisr); - if (!etdev->ReplicaPhyLoopbk) { + if (!etdev->replica_phy_loopbk) { et131x_mii_read(etdev, (uint8_t) offsetof(struct mi_regs, bmsr), &bmsr_data); diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 6eef4be69e2..5fe3ec4f869 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -100,15 +100,18 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev) struct net_device_stats *stats = &adapter->net_stats; struct ce_stats *devstat = &adapter->stats; - stats->rx_errors = devstat->length_err + devstat->alignment_err + - devstat->crc_err + devstat->code_violations + devstat->other_errors; - stats->tx_errors = devstat->max_pkt_error; - stats->multicast = devstat->multircv; - stats->collisions = devstat->collisions; + stats->rx_errors = devstat->rx_length_errs + + devstat->rx_align_errs + + devstat->rx_crc_errs + + devstat->rx_code_violations + + devstat->rx_other_errs; + stats->tx_errors = devstat->tx_max_pkt_errs; + stats->multicast = devstat->multicast_pkts_rcvd; + stats->collisions = devstat->tx_collisions; - stats->rx_length_errors = devstat->length_err; - stats->rx_over_errors = devstat->rx_ov_flow; - stats->rx_crc_errors = devstat->crc_err; + stats->rx_length_errors = devstat->rx_length_errs; + stats->rx_over_errors = devstat->rx_overflows; + stats->rx_crc_errors = devstat->rx_crc_errs; /* NOTE: These stats don't have corresponding values in CE_STATS, * so we're going to have to update these directly from within the @@ -144,7 +147,7 @@ int et131x_open(struct net_device *netdev) struct et131x_adapter *adapter = netdev_priv(netdev); /* Start the timer to track NIC errors */ - add_timer(&adapter->ErrorTimer); + add_timer(&adapter->error_timer); /* Register our IRQ */ result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED, @@ -194,7 +197,7 @@ int et131x_close(struct net_device *netdev) free_irq(netdev->irq, netdev); /* Stop the error timer */ - del_timer_sync(&adapter->ErrorTimer); + del_timer_sync(&adapter->error_timer); return 0; } @@ -275,7 +278,7 @@ int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) int et131x_set_packet_filter(struct et131x_adapter *adapter) { int status = 0; - uint32_t filter = adapter->PacketFilter; + uint32_t filter = adapter->packet_filter; u32 ctrl; u32 pf_ctrl; @@ -337,67 +340,67 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter) void et131x_multicast(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); - uint32_t PacketFilter = 0; + uint32_t packet_filter = 0; unsigned long flags; struct netdev_hw_addr *ha; int i; - spin_lock_irqsave(&adapter->Lock, flags); + spin_lock_irqsave(&adapter->lock, flags); /* Before we modify the platform-independent filter flags, store them * locally. This allows us to determine if anything's changed and if * we even need to bother the hardware */ - PacketFilter = adapter->PacketFilter; + packet_filter = adapter->packet_filter; /* Clear the 'multicast' flag locally; because we only have a single * flag to check multicast, and multiple multicast addresses can be * set, this is the easiest way to determine if more than one * multicast address is being set. */ - PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST; + packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; /* Check the net_device flags and set the device independent flags * accordingly */ if (netdev->flags & IFF_PROMISC) - adapter->PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS; + adapter->packet_filter |= ET131X_PACKET_TYPE_PROMISCUOUS; else - adapter->PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; + adapter->packet_filter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; if (netdev->flags & IFF_ALLMULTI) - adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST; + adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) - adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST; + adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; if (netdev_mc_count(netdev) < 1) { - adapter->PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; - adapter->PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST; + adapter->packet_filter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; + adapter->packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; } else - adapter->PacketFilter |= ET131X_PACKET_TYPE_MULTICAST; + adapter->packet_filter |= ET131X_PACKET_TYPE_MULTICAST; /* Set values in the private adapter struct */ i = 0; netdev_for_each_mc_addr(ha, netdev) { if (i == NIC_MAX_MCAST_LIST) break; - memcpy(adapter->MCList[i++], ha->addr, ETH_ALEN); + memcpy(adapter->multicast_list[i++], ha->addr, ETH_ALEN); } - adapter->MCAddressCount = i; + adapter->multicast_addr_count = i; /* Are the new flags different from the previous ones? If not, then no * action is required * - * NOTE - This block will always update the MCList with the hardware, - * even if the addresses aren't the same. + * NOTE - This block will always update the multicast_list with the + * hardware, even if the addresses aren't the same. */ - if (PacketFilter != adapter->PacketFilter) { + if (packet_filter != adapter->packet_filter) { /* Call the device's filter function */ et131x_set_packet_filter(adapter); } - spin_unlock_irqrestore(&adapter->Lock, flags); + spin_unlock_irqrestore(&adapter->lock, flags); } /** @@ -459,7 +462,7 @@ void et131x_tx_timeout(struct net_device *netdev) } /* Is send stuck? */ - spin_lock_irqsave(&etdev->TCBSendQLock, flags); + spin_lock_irqsave(&etdev->tcb_send_qlock, flags); tcb = etdev->tx_ring.send_head; @@ -467,7 +470,7 @@ void et131x_tx_timeout(struct net_device *netdev) tcb->count++; if (tcb->count > NIC_SEND_HANG_THRESHOLD) { - spin_unlock_irqrestore(&etdev->TCBSendQLock, + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); dev_warn(&etdev->pdev->dev, @@ -482,7 +485,7 @@ void et131x_tx_timeout(struct net_device *netdev) } } - spin_unlock_irqrestore(&etdev->TCBSendQLock, flags); + spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); } /** @@ -520,7 +523,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) et131x_adapter_memory_free(adapter); /* Set the config parameter for Jumbo Packet support */ - adapter->RegistryJumboPacket = new_mtu + 14; + adapter->registry_jumbo_packet = new_mtu + 14; et131x_soft_reset(adapter); /* Alloc and init Rx DMA memory */ @@ -601,7 +604,7 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) et131x_adapter_memory_free(adapter); /* Set the config parameter for Jumbo Packet support */ - /* adapter->RegistryJumboPacket = new_mtu + 14; */ + /* adapter->registry_jumbo_packet = new_mtu + 14; */ /* blux: not needet here, we'll change the MAC */ et131x_soft_reset(adapter); From bc8585fc063da29aae17351f7f63c9419b4daaad Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:36 +0100 Subject: [PATCH 0269/1519] staging: et131x: Removing commented out code implemented elsewhere Function et131x_set_mac_addr() contains commented out code that has been moved to et131x_change_mtu() in the same file. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_netdev.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 5fe3ec4f869..93ef9d5f04f 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -593,7 +593,6 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) /* Set the new MAC */ /* netdev->set_mac_address = &new_mac; */ - /* netdev->mtu = new_mtu; */ memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len); @@ -603,10 +602,6 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) /* Free Rx DMA memory */ et131x_adapter_memory_free(adapter); - /* Set the config parameter for Jumbo Packet support */ - /* adapter->registry_jumbo_packet = new_mtu + 14; */ - /* blux: not needet here, we'll change the MAC */ - et131x_soft_reset(adapter); /* Alloc and init Rx DMA memory */ From 10f00a49b048abf759b789a84c4c3431360aa38f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:37 +0100 Subject: [PATCH 0270/1519] staging: et131x: Rename var name 'etdev' to 'adapter' throughout module Used regex (from vim) :%s/\/adapter/g Changed because: * 'etdev' is easily confused as a misspelling of 'netdev' * 'adapter' is more widely used for this struct type in net drivers. This change made comparing code with other drivers much easier. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_eeprom.c | 32 +- drivers/staging/et131x/et1310_mac.c | 200 ++++++------ drivers/staging/et131x/et1310_phy.c | 390 ++++++++++++------------ drivers/staging/et131x/et1310_pm.c | 44 +-- drivers/staging/et131x/et1310_rx.c | 174 +++++------ drivers/staging/et131x/et1310_tx.c | 254 +++++++-------- drivers/staging/et131x/et131x_initpci.c | 136 ++++----- drivers/staging/et131x/et131x_isr.c | 46 +-- drivers/staging/et131x/et131x_netdev.c | 26 +- 9 files changed, 651 insertions(+), 651 deletions(-) diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c index 237584001a8..e8102547e13 100644 --- a/drivers/staging/et131x/et1310_eeprom.c +++ b/drivers/staging/et131x/et1310_eeprom.c @@ -150,15 +150,15 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) /** * eeprom_write - Write a byte to the ET1310's EEPROM - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * @addr: the address to write * @data: the value to write * * Returns 1 for a successful write. */ -static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data) +static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) { - struct pci_dev *pdev = etdev->pdev; + struct pci_dev *pdev = adapter->pdev; int index = 0; int retries; int err = 0; @@ -222,7 +222,7 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data) * 1, this is so we do a blind write for load bug. */ if ((status & LBCIF_STATUS_GENERAL_ERROR) - && etdev->pdev->revision == 0) + && adapter->pdev->revision == 0) break; /* @@ -280,7 +280,7 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data) /** * eeprom_read - Read a byte from the ET1310's EEPROM - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * @addr: the address from which to read * @pdata: a pointer to a byte in which to store the value of the read * @eeprom_id: the ID of the EEPROM @@ -288,9 +288,9 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data) * * Returns 1 for a successful read */ -static int eeprom_read(struct et131x_adapter *etdev, u32 addr, u8 *pdata) +static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata) { - struct pci_dev *pdev = etdev->pdev; + struct pci_dev *pdev = adapter->pdev; int err; u32 status; @@ -337,9 +337,9 @@ static int eeprom_read(struct et131x_adapter *etdev, u32 addr, u8 *pdata) return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0; } -int et131x_init_eeprom(struct et131x_adapter *etdev) +int et131x_init_eeprom(struct et131x_adapter *adapter) { - struct pci_dev *pdev = etdev->pdev; + struct pci_dev *pdev = adapter->pdev; u8 eestatus; /* We first need to check the EEPROM Status code located at offset @@ -374,7 +374,7 @@ int et131x_init_eeprom(struct et131x_adapter *etdev) * corruption seen with 1310 B Silicon */ for (i = 0; i < 3; i++) - if (eeprom_write(etdev, i, eedata[i]) < 0) + if (eeprom_write(adapter, i, eedata[i]) < 0) write_failed = 1; } if (pdev->revision != 0x01 || write_failed) { @@ -387,21 +387,21 @@ int et131x_init_eeprom(struct et131x_adapter *etdev) * gather additional information that normally would * come from the eeprom, like MAC Address */ - etdev->has_eeprom = 0; + adapter->has_eeprom = 0; return -EIO; } } - etdev->has_eeprom = 1; + adapter->has_eeprom = 1; /* Read the EEPROM for information regarding LED behavior. Refer to * ET1310_phy.c, et131x_xcvr_init(), for its use. */ - eeprom_read(etdev, 0x70, &etdev->eeprom_data[0]); - eeprom_read(etdev, 0x71, &etdev->eeprom_data[1]); + eeprom_read(adapter, 0x70, &adapter->eeprom_data[0]); + eeprom_read(adapter, 0x71, &adapter->eeprom_data[1]); - if (etdev->eeprom_data[0] != 0xcd) + if (adapter->eeprom_data[0] != 0xcd) /* Disable all optional features */ - etdev->eeprom_data[1] = 0x00; + adapter->eeprom_data[1] = 0x00; return 0; } diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 8e124fe5b9d..ab85cb3babd 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -100,11 +100,11 @@ /** * et1310_config_mac_regs1 - Initialize the first part of MAC regs - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et1310_config_mac_regs1(struct et131x_adapter *etdev) +void et1310_config_mac_regs1(struct et131x_adapter *adapter) { - struct mac_regs __iomem *macregs = &etdev->regs->mac; + struct mac_regs __iomem *macregs = &adapter->regs->mac; u32 station1; u32 station2; u32 ipg; @@ -136,12 +136,12 @@ void et1310_config_mac_regs1(struct et131x_adapter *etdev) * station address is used for generating and checking pause control * packets. */ - station2 = (etdev->addr[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT) | - (etdev->addr[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT); - station1 = (etdev->addr[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT) | - (etdev->addr[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT) | - (etdev->addr[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT) | - etdev->addr[2]; + station2 = (adapter->addr[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT) | + (adapter->addr[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT); + station1 = (adapter->addr[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT) | + (adapter->addr[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT) | + (adapter->addr[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT) | + adapter->addr[2]; writel(station1, ¯egs->station_addr_1); writel(station2, ¯egs->station_addr_2); @@ -152,7 +152,7 @@ void et1310_config_mac_regs1(struct et131x_adapter *etdev) * Packets larger than (registry_jumbo_packet) that do not contain a * VLAN ID will be dropped by the Rx function. */ - writel(etdev->registry_jumbo_packet + 4, ¯egs->max_fm_len); + writel(adapter->registry_jumbo_packet + 4, ¯egs->max_fm_len); /* clear out MAC config reset */ writel(0, ¯egs->cfg1); @@ -160,25 +160,25 @@ void et1310_config_mac_regs1(struct et131x_adapter *etdev) /** * et1310_config_mac_regs2 - Initialize the second part of MAC regs - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et1310_config_mac_regs2(struct et131x_adapter *etdev) +void et1310_config_mac_regs2(struct et131x_adapter *adapter) { int32_t delay = 0; - struct mac_regs __iomem *mac = &etdev->regs->mac; + struct mac_regs __iomem *mac = &adapter->regs->mac; u32 cfg1; u32 cfg2; u32 ifctrl; u32 ctl; - ctl = readl(&etdev->regs->txmac.ctl); + ctl = readl(&adapter->regs->txmac.ctl); cfg1 = readl(&mac->cfg1); cfg2 = readl(&mac->cfg2); ifctrl = readl(&mac->if_ctrl); /* Set up the if mode bits */ cfg2 &= ~0x300; - if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { cfg2 |= 0x200; /* Phy mode bit */ ifctrl &= ~(1 << 24); @@ -191,7 +191,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *etdev) cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; /* Initialize loop back to off */ cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); - if (etdev->flowcontrol == FLOW_RXONLY || etdev->flowcontrol == FLOW_BOTH) + if (adapter->flowcontrol == FLOW_RXONLY || adapter->flowcontrol == FLOW_BOTH) cfg1 |= CFG1_RX_FLOW; writel(cfg1, &mac->cfg1); @@ -202,11 +202,11 @@ void et1310_config_mac_regs2(struct et131x_adapter *etdev) cfg2 &= ~0x0021; /* Turn on duplex if needed */ - if (etdev->duplex_mode) + if (adapter->duplex_mode) cfg2 |= 0x01; ifctrl &= ~(1 << 26); - if (!etdev->duplex_mode) + if (!adapter->duplex_mode) ifctrl |= (1<<26); /* Enable ghd */ writel(ifctrl, &mac->if_ctrl); @@ -219,25 +219,25 @@ void et1310_config_mac_regs2(struct et131x_adapter *etdev) } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100); if (delay == 100) { - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "Syncd bits did not respond correctly cfg1 word 0x%08x\n", cfg1); } /* Enable txmac */ ctl |= 0x09; /* TX mac enable, FC disable */ - writel(ctl, &etdev->regs->txmac.ctl); + writel(ctl, &adapter->regs->txmac.ctl); /* Ready to start the RXDMA/TXDMA engine */ - if (etdev->flags & fMP_ADAPTER_LOWER_POWER) { - et131x_rx_dma_enable(etdev); - et131x_tx_dma_enable(etdev); + if (adapter->flags & fMP_ADAPTER_LOWER_POWER) { + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); } } -void et1310_config_rxmac_regs(struct et131x_adapter *etdev) +void et1310_config_rxmac_regs(struct et131x_adapter *adapter) { - struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; u32 sa_lo; u32 sa_hi = 0; u32 pf_ctrl = 0; @@ -280,22 +280,22 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) writel(0, &rxmac->mask4_word3); /* Lets setup the WOL Source Address */ - sa_lo = (etdev->addr[2] << ET_WOL_LO_SA3_SHIFT) | - (etdev->addr[3] << ET_WOL_LO_SA4_SHIFT) | - (etdev->addr[4] << ET_WOL_LO_SA5_SHIFT) | - etdev->addr[5]; + sa_lo = (adapter->addr[2] << ET_WOL_LO_SA3_SHIFT) | + (adapter->addr[3] << ET_WOL_LO_SA4_SHIFT) | + (adapter->addr[4] << ET_WOL_LO_SA5_SHIFT) | + adapter->addr[5]; writel(sa_lo, &rxmac->sa_lo); - sa_hi = (u32) (etdev->addr[0] << ET_WOL_HI_SA1_SHIFT) | - etdev->addr[1]; + sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) | + adapter->addr[1]; writel(sa_hi, &rxmac->sa_hi); /* Disable all Packet Filtering */ writel(0, &rxmac->pf_ctrl); /* Let's initialize the Unicast Packet filtering address */ - if (etdev->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { - et1310_setup_device_for_unicast(etdev); + if (adapter->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { + et1310_setup_device_for_unicast(adapter); pf_ctrl |= 4; /* Unicast filter */ } else { writel(0, &rxmac->uni_pf_addr1); @@ -304,16 +304,16 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) } /* Let's initialize the Multicast hash */ - if (!(etdev->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { + if (!(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { pf_ctrl |= 2; /* Multicast filter */ - et1310_setup_device_for_multicast(etdev); + et1310_setup_device_for_multicast(adapter); } /* Runt packet filtering. Didn't work in version A silicon. */ pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16; pf_ctrl |= 8; /* Fragment filter */ - if (etdev->registry_jumbo_packet > 8192) + if (adapter->registry_jumbo_packet > 8192) /* In order to transmit jumbo packets greater than 8k, the * FIFO between RxMAC and RxDMA needs to be reduced in size * to (16k - Jumbo packet size). In order to implement this, @@ -350,7 +350,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) * bit 16: Receive frame truncated. * bit 17: Drop packet enable */ - if (etdev->linkspeed == TRUEPHY_SPEED_100MBPS) + if (adapter->linkspeed == TRUEPHY_SPEED_100MBPS) writel(0x30038, &rxmac->mif_ctrl); else writel(0x30030, &rxmac->mif_ctrl); @@ -365,24 +365,24 @@ void et1310_config_rxmac_regs(struct et131x_adapter *etdev) writel(0x9, &rxmac->ctrl); } -void et1310_config_txmac_regs(struct et131x_adapter *etdev) +void et1310_config_txmac_regs(struct et131x_adapter *adapter) { - struct txmac_regs *txmac = &etdev->regs->txmac; + struct txmac_regs *txmac = &adapter->regs->txmac; /* We need to update the Control Frame Parameters * cfpt - control frame pause timer set to 64 (0x40) * cfep - control frame extended pause timer set to 0x0 */ - if (etdev->flowcontrol == FLOW_NONE) + if (adapter->flowcontrol == FLOW_NONE) writel(0, &txmac->cf_param); else writel(0x40, &txmac->cf_param); } -void et1310_config_macstat_regs(struct et131x_adapter *etdev) +void et1310_config_macstat_regs(struct et131x_adapter *adapter) { struct macstat_regs __iomem *macstat = - &etdev->regs->macstat; + &adapter->regs->macstat; /* Next we need to initialize all the macstat registers to zero on * the device. @@ -444,50 +444,50 @@ void et1310_config_macstat_regs(struct et131x_adapter *etdev) writel(0xFFFE7E8B, &macstat->carry_reg2_mask); } -void et1310_config_flow_control(struct et131x_adapter *etdev) +void et1310_config_flow_control(struct et131x_adapter *adapter) { - if (etdev->duplex_mode == 0) { - etdev->flowcontrol = FLOW_NONE; + if (adapter->duplex_mode == 0) { + adapter->flowcontrol = FLOW_NONE; } else { char remote_pause, remote_async_pause; - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_READ, 5, 10, &remote_pause); - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_READ, 5, 11, &remote_async_pause); if ((remote_pause == TRUEPHY_BIT_SET) && (remote_async_pause == TRUEPHY_BIT_SET)) { - etdev->flowcontrol = etdev->wanted_flow; + adapter->flowcontrol = adapter->wanted_flow; } else if ((remote_pause == TRUEPHY_BIT_SET) && (remote_async_pause == TRUEPHY_BIT_CLEAR)) { - if (etdev->wanted_flow == FLOW_BOTH) - etdev->flowcontrol = FLOW_BOTH; + if (adapter->wanted_flow == FLOW_BOTH) + adapter->flowcontrol = FLOW_BOTH; else - etdev->flowcontrol = FLOW_NONE; + adapter->flowcontrol = FLOW_NONE; } else if ((remote_pause == TRUEPHY_BIT_CLEAR) && (remote_async_pause == TRUEPHY_BIT_CLEAR)) { - etdev->flowcontrol = FLOW_NONE; + adapter->flowcontrol = FLOW_NONE; } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT && remote_async_pause == TRUEPHY_SET_BIT) */ - if (etdev->wanted_flow == FLOW_BOTH) - etdev->flowcontrol = FLOW_RXONLY; + if (adapter->wanted_flow == FLOW_BOTH) + adapter->flowcontrol = FLOW_RXONLY; else - etdev->flowcontrol = FLOW_NONE; + adapter->flowcontrol = FLOW_NONE; } } } /** * et1310_update_macstat_host_counters - Update the local copy of the statistics - * @etdev: pointer to the adapter structure + * @adapter: pointer to the adapter structure */ -void et1310_update_macstat_host_counters(struct et131x_adapter *etdev) +void et1310_update_macstat_host_counters(struct et131x_adapter *adapter) { - struct ce_stats *stats = &etdev->stats; + struct ce_stats *stats = &adapter->stats; struct macstat_regs __iomem *macstat = - &etdev->regs->macstat; + &adapter->regs->macstat; stats->tx_collisions += readl(&macstat->tx_total_collisions); stats->tx_first_collisions += readl(&macstat->tx_single_collisions); @@ -509,13 +509,13 @@ void et1310_update_macstat_host_counters(struct et131x_adapter *etdev) /** * et1310_handle_macstat_interrupt - * @etdev: pointer to the adapter structure + * @adapter: pointer to the adapter structure * * One of the MACSTAT counters has wrapped. Update the local copy of * the statistics held in the adapter structure, checking the "wrap" * bit for each counter. */ -void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) +void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter) { u32 carry_reg1; u32 carry_reg2; @@ -523,11 +523,11 @@ void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) /* Read the interrupt bits from the register(s). These are Clear On * Write. */ - carry_reg1 = readl(&etdev->regs->macstat.carry_reg1); - carry_reg2 = readl(&etdev->regs->macstat.carry_reg2); + carry_reg1 = readl(&adapter->regs->macstat.carry_reg1); + carry_reg2 = readl(&adapter->regs->macstat.carry_reg2); - writel(carry_reg1, &etdev->regs->macstat.carry_reg1); - writel(carry_reg2, &etdev->regs->macstat.carry_reg2); + writel(carry_reg1, &adapter->regs->macstat.carry_reg1); + writel(carry_reg2, &adapter->regs->macstat.carry_reg2); /* We need to do update the host copy of all the MAC_STAT counters. * For each counter, check it's overflow bit. If the overflow bit is @@ -536,38 +536,38 @@ void et1310_handle_macstat_interrupt(struct et131x_adapter *etdev) * block indicates that one of the counters has wrapped. */ if (carry_reg1 & (1 << 14)) - etdev->stats.rx_code_violations += COUNTER_WRAP_16_BIT; + adapter->stats.rx_code_violations += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 8)) - etdev->stats.rx_align_errs += COUNTER_WRAP_12_BIT; + adapter->stats.rx_align_errs += COUNTER_WRAP_12_BIT; if (carry_reg1 & (1 << 7)) - etdev->stats.rx_length_errs += COUNTER_WRAP_16_BIT; + adapter->stats.rx_length_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 2)) - etdev->stats.rx_other_errs += COUNTER_WRAP_16_BIT; + adapter->stats.rx_other_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 6)) - etdev->stats.rx_crc_errs += COUNTER_WRAP_16_BIT; + adapter->stats.rx_crc_errs += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 3)) - etdev->stats.rx_overflows += COUNTER_WRAP_16_BIT; + adapter->stats.rx_overflows += COUNTER_WRAP_16_BIT; if (carry_reg1 & (1 << 0)) - etdev->stats.rcvd_pkts_dropped += COUNTER_WRAP_16_BIT; + adapter->stats.rcvd_pkts_dropped += COUNTER_WRAP_16_BIT; if (carry_reg2 & (1 << 16)) - etdev->stats.tx_max_pkt_errs += COUNTER_WRAP_12_BIT; + adapter->stats.tx_max_pkt_errs += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 15)) - etdev->stats.tx_underflows += COUNTER_WRAP_12_BIT; + adapter->stats.tx_underflows += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 6)) - etdev->stats.tx_first_collisions += COUNTER_WRAP_12_BIT; + adapter->stats.tx_first_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 8)) - etdev->stats.tx_deferred += COUNTER_WRAP_12_BIT; + adapter->stats.tx_deferred += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 5)) - etdev->stats.tx_excessive_collisions += COUNTER_WRAP_12_BIT; + adapter->stats.tx_excessive_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 4)) - etdev->stats.tx_late_collisions += COUNTER_WRAP_12_BIT; + adapter->stats.tx_late_collisions += COUNTER_WRAP_12_BIT; if (carry_reg2 & (1 << 2)) - etdev->stats.tx_collisions += COUNTER_WRAP_12_BIT; + adapter->stats.tx_collisions += COUNTER_WRAP_12_BIT; } -void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) +void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) { - struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; uint32_t nIndex; uint32_t result; uint32_t hash1 = 0; @@ -581,11 +581,11 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) * specified) then we should pass NO multi-cast addresses to the * driver. */ - if (etdev->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { + if (adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { /* Loop through our multicast array and set up the device */ - for (nIndex = 0; nIndex < etdev->multicast_addr_count; + for (nIndex = 0; nIndex < adapter->multicast_addr_count; nIndex++) { - result = ether_crc(6, etdev->multicast_list[nIndex]); + result = ether_crc(6, adapter->multicast_list[nIndex]); result = (result & 0x3F800000) >> 23; @@ -605,7 +605,7 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) } /* Write out the new hash to the device */ - pm_csr = readl(&etdev->regs->global.pm_csr); + pm_csr = readl(&adapter->regs->global.pm_csr); if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { writel(hash1, &rxmac->multi_hash1); writel(hash2, &rxmac->multi_hash2); @@ -614,9 +614,9 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *etdev) } } -void et1310_setup_device_for_unicast(struct et131x_adapter *etdev) +void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) { - struct rxmac_regs __iomem *rxmac = &etdev->regs->rxmac; + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; u32 uni_pf1; u32 uni_pf2; u32 uni_pf3; @@ -631,22 +631,22 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *etdev) * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the * MAC address for first address */ - uni_pf3 = (etdev->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | - (etdev->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | - (etdev->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | - etdev->addr[1]; + uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | + (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | + (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | + adapter->addr[1]; - uni_pf2 = (etdev->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | - (etdev->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | - (etdev->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | - etdev->addr[5]; + uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | + adapter->addr[5]; - uni_pf1 = (etdev->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | - (etdev->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | - (etdev->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | - etdev->addr[5]; + uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | + adapter->addr[5]; - pm_csr = readl(&etdev->regs->global.pm_csr); + pm_csr = readl(&adapter->regs->global.pm_csr); if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { writel(uni_pf1, &rxmac->uni_pf_addr1); writel(uni_pf2, &rxmac->uni_pf_addr2); diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 9d2ce08d9ae..6eb9d5cb643 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -95,17 +95,17 @@ /** * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * @xcvr_addr: the address of the transceiver * @xcvr_reg: the register to read * @value: pointer to a 16-bit value in which the value will be stored * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_phy_mii_read(struct et131x_adapter *etdev, u8 xcvr_addr, +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, u8 xcvr_reg, u16 *value) { - struct mac_regs __iomem *mac = &etdev->regs->mac; + struct mac_regs __iomem *mac = &adapter->regs->mac; int status = 0; u32 delay; u32 mii_addr; @@ -137,9 +137,9 @@ int et131x_phy_mii_read(struct et131x_adapter *etdev, u8 xcvr_addr, /* If we hit the max delay, we could not read the register */ if (delay == 50) { - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "xcvrReg 0x%08x could not be read\n", xcvr_reg); - dev_warn(&etdev->pdev->dev, "status is 0x%08x\n", + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", mii_indicator); status = -EIO; @@ -163,7 +163,7 @@ int et131x_phy_mii_read(struct et131x_adapter *etdev, u8 xcvr_addr, /** * et131x_mii_write - Write to a PHY register through the MII interface of the MAC - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * @xcvr_reg: the register to read * @value: 16-bit value to write * @@ -171,11 +171,11 @@ int et131x_phy_mii_read(struct et131x_adapter *etdev, u8 xcvr_addr, * * Return 0 on success, errno on failure (as defined in errno.h) */ -int et131x_mii_write(struct et131x_adapter *etdev, u8 xcvr_reg, u16 value) +int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) { - struct mac_regs __iomem *mac = &etdev->regs->mac; + struct mac_regs __iomem *mac = &adapter->regs->mac; int status = 0; - u8 xcvr_addr = etdev->stats.xcvr_addr; + u8 xcvr_addr = adapter->stats.xcvr_addr; u32 delay; u32 mii_addr; u32 mii_cmd; @@ -207,14 +207,14 @@ int et131x_mii_write(struct et131x_adapter *etdev, u8 xcvr_reg, u16 value) if (delay == 100) { u16 tmp; - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "xcvrReg 0x%08x could not be written", xcvr_reg); - dev_warn(&etdev->pdev->dev, "status is 0x%08x\n", + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", mii_indicator); - dev_warn(&etdev->pdev->dev, "command is 0x%08x\n", + dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", readl(&mac->mii_mgmt_cmd)); - et131x_mii_read(etdev, xcvr_reg, &tmp); + et131x_mii_read(adapter, xcvr_reg, &tmp); status = -EIO; } @@ -233,11 +233,11 @@ int et131x_mii_write(struct et131x_adapter *etdev, u8 xcvr_reg, u16 value) /** * et131x_xcvr_find - Find the PHY ID - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_xcvr_find(struct et131x_adapter *etdev) +int et131x_xcvr_find(struct et131x_adapter *adapter) { u8 xcvr_addr; u16 idr1; @@ -247,32 +247,32 @@ int et131x_xcvr_find(struct et131x_adapter *etdev) /* We need to get xcvr id and address we just get the first one */ for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) { /* Read the ID from the PHY */ - et131x_phy_mii_read(etdev, xcvr_addr, + et131x_phy_mii_read(adapter, xcvr_addr, (u8) offsetof(struct mi_regs, idr1), &idr1); - et131x_phy_mii_read(etdev, xcvr_addr, + et131x_phy_mii_read(adapter, xcvr_addr, (u8) offsetof(struct mi_regs, idr2), &idr2); xcvr_id = (u32) ((idr1 << 16) | idr2); if (idr1 != 0 && idr1 != 0xffff) { - etdev->stats.xcvr_id = xcvr_id; - etdev->stats.xcvr_addr = xcvr_addr; + adapter->stats.xcvr_id = xcvr_id; + adapter->stats.xcvr_addr = xcvr_addr; return 0; } } return -ENODEV; } -void et1310_phy_reset(struct et131x_adapter *etdev) +void et1310_phy_reset(struct et131x_adapter *adapter) { - et131x_mii_write(etdev, PHY_CONTROL, 0x8000); + et131x_mii_write(adapter, PHY_CONTROL, 0x8000); } /** * et1310_phy_power_down - PHY power control - * @etdev: device to control + * @adapter: device to control * @down: true for off/false for back on * * one hundred, ten, one thousand megs @@ -280,77 +280,77 @@ void et1310_phy_reset(struct et131x_adapter *etdev) * Can't you see that this code processed * Phy power, phy power.. */ -void et1310_phy_power_down(struct et131x_adapter *etdev, bool down) +void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) { u16 data; - et131x_mii_read(etdev, PHY_CONTROL, &data); + et131x_mii_read(adapter, PHY_CONTROL, &data); data &= ~0x0800; /* Power UP */ if (down) /* Power DOWN */ data |= 0x0800; - et131x_mii_write(etdev, PHY_CONTROL, data); + et131x_mii_write(adapter, PHY_CONTROL, data); } /** * et1310_phy_auto_neg - autonegotiate control - * @etdev: device to control + * @adapter: device to control * @enabe: autoneg on/off * * Set up the autonegotiation state according to whether we will be * negotiating the state or forcing a speed. */ -static void et1310_phy_auto_neg(struct et131x_adapter *etdev, bool enable) +static void et1310_phy_auto_neg(struct et131x_adapter *adapter, bool enable) { u16 data; - et131x_mii_read(etdev, PHY_CONTROL, &data); + et131x_mii_read(adapter, PHY_CONTROL, &data); data &= ~0x1000; /* Autonegotiation OFF */ if (enable) data |= 0x1000; /* Autonegotiation ON */ - et131x_mii_write(etdev, PHY_CONTROL, data); + et131x_mii_write(adapter, PHY_CONTROL, data); } /** * et1310_phy_duplex_mode - duplex control - * @etdev: device to control + * @adapter: device to control * @duplex: duplex on/off * * Set up the duplex state on the PHY */ -static void et1310_phy_duplex_mode(struct et131x_adapter *etdev, u16 duplex) +static void et1310_phy_duplex_mode(struct et131x_adapter *adapter, u16 duplex) { u16 data; - et131x_mii_read(etdev, PHY_CONTROL, &data); + et131x_mii_read(adapter, PHY_CONTROL, &data); data &= ~0x100; /* Set Half Duplex */ if (duplex == TRUEPHY_DUPLEX_FULL) data |= 0x100; /* Set Full Duplex */ - et131x_mii_write(etdev, PHY_CONTROL, data); + et131x_mii_write(adapter, PHY_CONTROL, data); } /** * et1310_phy_speed_select - speed control - * @etdev: device to control + * @adapter: device to control * @duplex: duplex on/off * * Set the speed of our PHY. */ -static void et1310_phy_speed_select(struct et131x_adapter *etdev, u16 speed) +static void et1310_phy_speed_select(struct et131x_adapter *adapter, u16 speed) { u16 data; static const u16 bits[3] = {0x0000, 0x2000, 0x0040}; /* Read the PHY control register */ - et131x_mii_read(etdev, PHY_CONTROL, &data); + et131x_mii_read(adapter, PHY_CONTROL, &data); /* Clear all Speed settings (Bits 6, 13) */ data &= ~0x2040; /* Write back the new speed */ - et131x_mii_write(etdev, PHY_CONTROL, data | bits[speed]); + et131x_mii_write(adapter, PHY_CONTROL, data | bits[speed]); } /** * et1310_phy_link_status - read link state - * @etdev: device to read + * @adapter: device to read * @link_status: reported link state * @autoneg: reported autonegotiation state (complete/incomplete/disabled) * @linkspeed: returnedlink speed in use @@ -364,7 +364,7 @@ static void et1310_phy_speed_select(struct et131x_adapter *etdev, u16 speed) * I know your link speed * I see all the setting that you'd rather keep */ -static void et1310_phy_link_status(struct et131x_adapter *etdev, +static void et1310_phy_link_status(struct et131x_adapter *adapter, u8 *link_status, u32 *autoneg, u32 *linkspeed, @@ -377,10 +377,10 @@ static void et1310_phy_link_status(struct et131x_adapter *etdev, u16 vmi_phystatus = 0; u16 control = 0; - et131x_mii_read(etdev, PHY_STATUS, &mistatus); - et131x_mii_read(etdev, PHY_1000_STATUS, &is1000BaseT); - et131x_mii_read(etdev, PHY_PHY_STATUS, &vmi_phystatus); - et131x_mii_read(etdev, PHY_CONTROL, &control); + et131x_mii_read(adapter, PHY_STATUS, &mistatus); + et131x_mii_read(adapter, PHY_1000_STATUS, &is1000BaseT); + et131x_mii_read(adapter, PHY_PHY_STATUS, &vmi_phystatus); + et131x_mii_read(adapter, PHY_CONTROL, &control); *link_status = (vmi_phystatus & 0x0040) ? 1 : 0; *autoneg = (control & 0x1000) ? ((vmi_phystatus & 0x0020) ? @@ -398,26 +398,26 @@ static void et1310_phy_link_status(struct et131x_adapter *etdev, TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL; } -static void et1310_phy_and_or_reg(struct et131x_adapter *etdev, +static void et1310_phy_and_or_reg(struct et131x_adapter *adapter, u16 regnum, u16 and_mask, u16 or_mask) { u16 reg; - et131x_mii_read(etdev, regnum, ®); + et131x_mii_read(adapter, regnum, ®); reg &= and_mask; reg |= or_mask; - et131x_mii_write(etdev, regnum, reg); + et131x_mii_write(adapter, regnum, reg); } /* Still used from _mac for BIT_READ */ -void et1310_phy_access_mii_bit(struct et131x_adapter *etdev, u16 action, +void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, u16 regnum, u16 bitnum, u8 *value) { u16 reg; u16 mask = 0x0001 << bitnum; /* Read the requested register */ - et131x_mii_read(etdev, regnum, ®); + et131x_mii_read(adapter, regnum, ®); switch (action) { case TRUEPHY_BIT_READ: @@ -425,11 +425,11 @@ void et1310_phy_access_mii_bit(struct et131x_adapter *etdev, u16 action, break; case TRUEPHY_BIT_SET: - et131x_mii_write(etdev, regnum, reg | mask); + et131x_mii_write(adapter, regnum, reg | mask); break; case TRUEPHY_BIT_CLEAR: - et131x_mii_write(etdev, regnum, reg & ~mask); + et131x_mii_write(adapter, regnum, reg & ~mask); break; default: @@ -437,13 +437,13 @@ void et1310_phy_access_mii_bit(struct et131x_adapter *etdev, u16 action, } } -void et1310_phy_advertise_1000BaseT(struct et131x_adapter *etdev, +void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter, u16 duplex) { u16 data; /* Read the PHY 1000 Base-T Control Register */ - et131x_mii_read(etdev, PHY_1000_CONTROL, &data); + et131x_mii_read(adapter, PHY_1000_CONTROL, &data); /* Clear Bits 8,9 */ data &= ~0x0300; @@ -470,16 +470,16 @@ void et1310_phy_advertise_1000BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - et131x_mii_write(etdev, PHY_1000_CONTROL, data); + et131x_mii_write(adapter, PHY_1000_CONTROL, data); } -static void et1310_phy_advertise_100BaseT(struct et131x_adapter *etdev, +static void et1310_phy_advertise_100BaseT(struct et131x_adapter *adapter, u16 duplex) { u16 data; /* Read the Autonegotiation Register (10/100) */ - et131x_mii_read(etdev, PHY_AUTO_ADVERTISEMENT, &data); + et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data); /* Clear bits 7,8 */ data &= ~0x0180; @@ -507,16 +507,16 @@ static void et1310_phy_advertise_100BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - et131x_mii_write(etdev, PHY_AUTO_ADVERTISEMENT, data); + et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data); } -static void et1310_phy_advertise_10BaseT(struct et131x_adapter *etdev, +static void et1310_phy_advertise_10BaseT(struct et131x_adapter *adapter, u16 duplex) { u16 data; /* Read the Autonegotiation Register (10/100) */ - et131x_mii_read(etdev, PHY_AUTO_ADVERTISEMENT, &data); + et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data); /* Clear bits 5,6 */ data &= ~0x0060; @@ -544,32 +544,32 @@ static void et1310_phy_advertise_10BaseT(struct et131x_adapter *etdev, } /* Write back advertisement */ - et131x_mii_write(etdev, PHY_AUTO_ADVERTISEMENT, data); + et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data); } /** * et131x_xcvr_init - Init the phy if we are setting it into force mode - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * */ -static void et131x_xcvr_init(struct et131x_adapter *etdev) +static void et131x_xcvr_init(struct et131x_adapter *adapter) { u16 imr; u16 isr; u16 lcr2; /* Zero out the adapter structure variable representing BMSR */ - etdev->bmsr = 0; + adapter->bmsr = 0; - et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, isr), &isr); - et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, imr), &imr); + et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, isr), &isr); + et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, imr), &imr); /* Set the link status interrupt only. Bad behavior when link status * and auto neg are set, we run into a nested interrupt problem */ imr |= 0x0105; - et131x_mii_write(etdev, (u8) offsetof(struct mi_regs, imr), imr); + et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, imr), imr); /* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates @@ -579,150 +579,150 @@ static void et131x_xcvr_init(struct et131x_adapter *etdev) * vendors; The LED behavior is now determined by vendor data in the * EEPROM. However, the above description is the default. */ - if ((etdev->eeprom_data[1] & 0x4) == 0) { - et131x_mii_read(etdev, (u8) offsetof(struct mi_regs, lcr2), + if ((adapter->eeprom_data[1] & 0x4) == 0) { + et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, lcr2), &lcr2); lcr2 &= 0x00FF; lcr2 |= 0xA000; /* led link */ - if ((etdev->eeprom_data[1] & 0x8) == 0) + if ((adapter->eeprom_data[1] & 0x8) == 0) lcr2 |= 0x0300; else lcr2 |= 0x0400; - et131x_mii_write(etdev, (u8) offsetof(struct mi_regs, lcr2), + et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, lcr2), lcr2); } /* Determine if we need to go into a force mode and set it */ - if (etdev->ai_force_speed == 0 && etdev->ai_force_duplex == 0) { - if (etdev->wanted_flow == FLOW_TXONLY || - etdev->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(etdev, + if (adapter->ai_force_speed == 0 && adapter->ai_force_duplex == 0) { + if (adapter->wanted_flow == FLOW_TXONLY || + adapter->wanted_flow == FLOW_BOTH) + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); else - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); - if (etdev->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(etdev, + if (adapter->wanted_flow == FLOW_BOTH) + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); else - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); /* Set the phy to autonegotiation */ - et1310_phy_auto_neg(etdev, true); + et1310_phy_auto_neg(adapter, true); /* NOTE - Do we need this? */ - et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_SET, 0, 9, NULL); + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL); return; } - et1310_phy_auto_neg(etdev, false); + et1310_phy_auto_neg(adapter, false); /* Set to the correct force mode. */ - if (etdev->ai_force_duplex != 1) { - if (etdev->wanted_flow == FLOW_TXONLY || - etdev->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(etdev, + if (adapter->ai_force_duplex != 1) { + if (adapter->wanted_flow == FLOW_TXONLY || + adapter->wanted_flow == FLOW_BOTH) + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); else - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); - if (etdev->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(etdev, + if (adapter->wanted_flow == FLOW_BOTH) + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); else - et1310_phy_access_mii_bit(etdev, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } else { - et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); - et1310_phy_access_mii_bit(etdev, TRUEPHY_BIT_CLEAR, + et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } - et1310_phy_power_down(etdev, 1); - switch (etdev->ai_force_speed) { + et1310_phy_power_down(adapter, 1); + switch (adapter->ai_force_speed) { case 10: /* First we need to turn off all other advertisement */ - et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - if (etdev->ai_force_duplex == 1) { + et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); + if (adapter->ai_force_duplex == 1) { /* Set our advertise values accordingly */ - et1310_phy_advertise_10BaseT(etdev, + et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_HALF); - } else if (etdev->ai_force_duplex == 2) { + } else if (adapter->ai_force_duplex == 2) { /* Set our advertise values accordingly */ - et1310_phy_advertise_10BaseT(etdev, + et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); } else { /* Disable autoneg */ - et1310_phy_auto_neg(etdev, false); + et1310_phy_auto_neg(adapter, false); /* Disable rest of the advertisements */ - et1310_phy_advertise_10BaseT(etdev, + et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); /* Force 10 Mbps */ - et1310_phy_speed_select(etdev, TRUEPHY_SPEED_10MBPS); + et1310_phy_speed_select(adapter, TRUEPHY_SPEED_10MBPS); /* Force Full duplex */ - et1310_phy_duplex_mode(etdev, TRUEPHY_DUPLEX_FULL); + et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL); } break; case 100: /* first we need to turn off all other advertisement */ - et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - if (etdev->ai_force_duplex == 1) { + et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); + if (adapter->ai_force_duplex == 1) { /* Set our advertise values accordingly */ - et1310_phy_advertise_100BaseT(etdev, + et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_HALF); /* Set speed */ - et1310_phy_speed_select(etdev, TRUEPHY_SPEED_100MBPS); - } else if (etdev->ai_force_duplex == 2) { + et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS); + } else if (adapter->ai_force_duplex == 2) { /* Set our advertise values accordingly */ - et1310_phy_advertise_100BaseT(etdev, + et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); } else { /* Disable autoneg */ - et1310_phy_auto_neg(etdev, false); + et1310_phy_auto_neg(adapter, false); /* Disable other advertisement */ - et1310_phy_advertise_100BaseT(etdev, + et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); /* Force 100 Mbps */ - et1310_phy_speed_select(etdev, TRUEPHY_SPEED_100MBPS); + et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS); /* Force Full duplex */ - et1310_phy_duplex_mode(etdev, TRUEPHY_DUPLEX_FULL); + et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL); } break; case 1000: /* first we need to turn off all other advertisement */ - et1310_phy_advertise_100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); /* set our advertise values accordingly */ - et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); + et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); break; } - et1310_phy_power_down(etdev, 0); + et1310_phy_power_down(adapter, 0); } /** * et131x_setphy_normal - Set PHY for normal operation. - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * * Used by Power Management to force the PHY into 10 Base T half-duplex mode, * when going to D3 in WOL mode. Also used during initialization to set the * PHY for normal operation. */ -void et131x_setphy_normal(struct et131x_adapter *etdev) +void et131x_setphy_normal(struct et131x_adapter *adapter) { /* Make sure the PHY is powered up */ - et1310_phy_power_down(etdev, 0); - et131x_xcvr_init(etdev); + et1310_phy_power_down(adapter, 0); + et131x_xcvr_init(adapter); } -void et131x_mii_check(struct et131x_adapter *etdev, +void et131x_mii_check(struct et131x_adapter *adapter, u16 bmsr, u16 bmsr_ints) { u8 link_status; @@ -736,36 +736,36 @@ void et131x_mii_check(struct et131x_adapter *etdev, if (bmsr_ints & MI_BMSR_LINK_STATUS) { if (bmsr & MI_BMSR_LINK_STATUS) { - etdev->boot_coma = 20; + adapter->boot_coma = 20; /* Update our state variables and indicate the * connected state */ - spin_lock_irqsave(&etdev->lock, flags); + spin_lock_irqsave(&adapter->lock, flags); - etdev->media_state = NETIF_STATUS_MEDIA_CONNECT; + adapter->media_state = NETIF_STATUS_MEDIA_CONNECT; - spin_unlock_irqrestore(&etdev->lock, flags); + spin_unlock_irqrestore(&adapter->lock, flags); - netif_carrier_on(etdev->netdev); + netif_carrier_on(adapter->netdev); } else { - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "Link down - cable problem ?\n"); - if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) { + if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { /* NOTE - Is there a way to query this without * TruePHY? - * && TRU_QueryCoreType(etdev->hTruePhy, 0) == + * && TRU_QueryCoreType(adapter->hTruePhy, 0) == * EMI_TRUEPHY_A13O) { */ u16 register18; - et131x_mii_read(etdev, 0x12, ®ister18); - et131x_mii_write(etdev, 0x12, register18 | 0x4); - et131x_mii_write(etdev, 0x10, + et131x_mii_read(adapter, 0x12, ®ister18); + et131x_mii_write(adapter, 0x12, register18 | 0x4); + et131x_mii_write(adapter, 0x10, register18 | 0x8402); - et131x_mii_write(etdev, 0x11, register18 | 511); - et131x_mii_write(etdev, 0x12, register18); + et131x_mii_write(adapter, 0x11, register18 | 511); + et131x_mii_write(adapter, 0x12, register18); } /* For the first N seconds of life, we are in "link @@ -774,27 +774,27 @@ void et131x_mii_check(struct et131x_adapter *etdev, * Timer expires, we can report disconnected (handled * in the LinkDetectionDPC). */ - if (etdev->media_state == NETIF_STATUS_MEDIA_DISCONNECT) { - spin_lock_irqsave(&etdev->lock, flags); - etdev->media_state = + if (adapter->media_state == NETIF_STATUS_MEDIA_DISCONNECT) { + spin_lock_irqsave(&adapter->lock, flags); + adapter->media_state = NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&etdev->lock, + spin_unlock_irqrestore(&adapter->lock, flags); - netif_carrier_off(etdev->netdev); + netif_carrier_off(adapter->netdev); } - etdev->linkspeed = 0; - etdev->duplex_mode = 0; + adapter->linkspeed = 0; + adapter->duplex_mode = 0; /* Free the packets being actively sent & stopped */ - et131x_free_busy_send_packets(etdev); + et131x_free_busy_send_packets(adapter); /* Re-initialize the send structures */ - et131x_init_send(etdev); + et131x_init_send(adapter); /* Reset the RFD list and re-start RU */ - et131x_reset_recv(etdev); + et131x_reset_recv(adapter); /* * Bring the device back to the state it was during @@ -802,59 +802,59 @@ void et131x_mii_check(struct et131x_adapter *etdev, * way, when we get the auto-neg complete interrupt, * we can complete init by calling config_mac_regs2. */ - et131x_soft_reset(etdev); + et131x_soft_reset(adapter); /* Setup ET1310 as per the documentation */ - et131x_adapter_setup(etdev); + et131x_adapter_setup(adapter); /* Setup the PHY into coma mode until the cable is * plugged back in */ - if (etdev->registry_phy_coma == 1) - et1310_enable_phy_coma(etdev); + if (adapter->registry_phy_coma == 1) + et1310_enable_phy_coma(adapter); } } if ((bmsr_ints & MI_BMSR_AUTO_NEG_COMPLETE) || - (etdev->ai_force_duplex == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { + (adapter->ai_force_duplex == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { if ((bmsr & MI_BMSR_AUTO_NEG_COMPLETE) || - etdev->ai_force_duplex == 3) { - et1310_phy_link_status(etdev, + adapter->ai_force_duplex == 3) { + et1310_phy_link_status(adapter, &link_status, &autoneg_status, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); - etdev->linkspeed = speed; - etdev->duplex_mode = duplex; + adapter->linkspeed = speed; + adapter->duplex_mode = duplex; - etdev->boot_coma = 20; + adapter->boot_coma = 20; - if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) { + if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { /* * NOTE - Is there a way to query this without * TruePHY? - * && TRU_QueryCoreType(etdev->hTruePhy, 0)== + * && TRU_QueryCoreType(adapter->hTruePhy, 0)== * EMI_TRUEPHY_A13O) { */ u16 register18; - et131x_mii_read(etdev, 0x12, ®ister18); - et131x_mii_write(etdev, 0x12, register18 | 0x4); - et131x_mii_write(etdev, 0x10, + et131x_mii_read(adapter, 0x12, ®ister18); + et131x_mii_write(adapter, 0x12, register18 | 0x4); + et131x_mii_write(adapter, 0x10, register18 | 0x8402); - et131x_mii_write(etdev, 0x11, register18 | 511); - et131x_mii_write(etdev, 0x12, register18); + et131x_mii_write(adapter, 0x11, register18 | 511); + et131x_mii_write(adapter, 0x12, register18); } - et1310_config_flow_control(etdev); + et1310_config_flow_control(adapter); - if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && - etdev->registry_jumbo_packet > 2048) - et1310_phy_and_or_reg(etdev, 0x16, 0xcfff, + if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS && + adapter->registry_jumbo_packet > 2048) + et1310_phy_and_or_reg(adapter, 0x16, 0xcfff, 0x2000); - et131x_set_rx_dma_timer(etdev); - et1310_config_mac_regs2(etdev); + et131x_set_rx_dma_timer(adapter); + et1310_config_mac_regs2(adapter); } } } @@ -904,71 +904,71 @@ static const u16 config_phy[25][2] = { }; /* condensed version of the phy initialization routine */ -void et1310_phy_init(struct et131x_adapter *etdev) +void et1310_phy_init(struct et131x_adapter *adapter) { u16 data, index; /* get the identity (again ?) */ - et131x_mii_read(etdev, PHY_ID_1, &data); - et131x_mii_read(etdev, PHY_ID_2, &data); + et131x_mii_read(adapter, PHY_ID_1, &data); + et131x_mii_read(adapter, PHY_ID_2, &data); /* what does this do/achieve ? */ /* should read 0002 */ - et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0006); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0006); /* read modem register 0402, should I do something with the return data ? */ - et131x_mii_write(etdev, PHY_INDEX_REG, 0x0402); - et131x_mii_read(etdev, PHY_DATA_REG, &data); + et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402); + et131x_mii_read(adapter, PHY_DATA_REG, &data); /* what does this do/achieve ? */ - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); /* get the identity (again ?) */ - et131x_mii_read(etdev, PHY_ID_1, &data); - et131x_mii_read(etdev, PHY_ID_2, &data); + et131x_mii_read(adapter, PHY_ID_1, &data); + et131x_mii_read(adapter, PHY_ID_2, &data); /* what does this achieve ? */ /* should read 0002 */ - et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0006); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0006); /* read modem register 0402, should I do something with the return data? */ - et131x_mii_write(etdev, PHY_INDEX_REG, 0x0402); - et131x_mii_read(etdev, PHY_DATA_REG, &data); + et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402); + et131x_mii_read(adapter, PHY_DATA_REG, &data); - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); /* what does this achieve (should return 0x1040) */ - et131x_mii_read(etdev, PHY_CONTROL, &data); + et131x_mii_read(adapter, PHY_CONTROL, &data); /* should read 0002 */ - et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(etdev, PHY_CONTROL, 0x1840); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(adapter, PHY_CONTROL, 0x1840); - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0007); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0007); /* here the writing of the array starts.... */ index = 0; while (config_phy[index][0] != 0x0000) { /* write value */ - et131x_mii_write(etdev, PHY_INDEX_REG, config_phy[index][0]); - et131x_mii_write(etdev, PHY_DATA_REG, config_phy[index][1]); + et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]); + et131x_mii_write(adapter, PHY_DATA_REG, config_phy[index][1]); /* read it back */ - et131x_mii_write(etdev, PHY_INDEX_REG, config_phy[index][0]); - et131x_mii_read(etdev, PHY_DATA_REG, &data); + et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]); + et131x_mii_read(adapter, PHY_DATA_REG, &data); /* do a check on the value read back ? */ index++; } /* here the writing of the array ends... */ - et131x_mii_read(etdev, PHY_CONTROL, &data); /* 0x1840 */ + et131x_mii_read(adapter, PHY_CONTROL, &data); /* 0x1840 */ /* should read 0007 */ - et131x_mii_read(etdev, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(etdev, PHY_CONTROL, 0x1040); - et131x_mii_write(etdev, PHY_MPHY_CONTROL_REG, 0x0002); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); + et131x_mii_write(adapter, PHY_CONTROL, 0x1040); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); } diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index 914aff65d69..5ebf0645c1c 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -88,7 +88,7 @@ /** * et1310_enable_phy_coma - called when network cable is unplugged - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure * * driver receive an phy status change interrupt while in D0 and check that * phy_status is down. @@ -106,75 +106,75 @@ * indicating linkup status, call the MPDisablePhyComa routine to * restore JAGCore and gigE PHY */ -void et1310_enable_phy_coma(struct et131x_adapter *etdev) +void et1310_enable_phy_coma(struct et131x_adapter *adapter) { unsigned long flags; u32 pmcsr; - pmcsr = readl(&etdev->regs->global.pm_csr); + pmcsr = readl(&adapter->regs->global.pm_csr); /* Save the GbE PHY speed and duplex modes. Need to restore this * when cable is plugged back in */ - etdev->pdown_speed = etdev->ai_force_speed; - etdev->pdown_duplex = etdev->ai_force_duplex; + adapter->pdown_speed = adapter->ai_force_speed; + adapter->pdown_duplex = adapter->ai_force_duplex; /* Stop sending packets. */ - spin_lock_irqsave(&etdev->send_hw_lock, flags); - etdev->flags |= fMP_ADAPTER_LOWER_POWER; - spin_unlock_irqrestore(&etdev->send_hw_lock, flags); + spin_lock_irqsave(&adapter->send_hw_lock, flags); + adapter->flags |= fMP_ADAPTER_LOWER_POWER; + spin_unlock_irqrestore(&adapter->send_hw_lock, flags); /* Wait for outstanding Receive packets */ /* Gate off JAGCore 3 clock domains */ pmcsr &= ~ET_PMCSR_INIT; - writel(pmcsr, &etdev->regs->global.pm_csr); + writel(pmcsr, &adapter->regs->global.pm_csr); /* Program gigE PHY in to Coma mode */ pmcsr |= ET_PM_PHY_SW_COMA; - writel(pmcsr, &etdev->regs->global.pm_csr); + writel(pmcsr, &adapter->regs->global.pm_csr); } /** * et1310_disable_phy_coma - Disable the Phy Coma Mode - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et1310_disable_phy_coma(struct et131x_adapter *etdev) +void et1310_disable_phy_coma(struct et131x_adapter *adapter) { u32 pmcsr; - pmcsr = readl(&etdev->regs->global.pm_csr); + pmcsr = readl(&adapter->regs->global.pm_csr); /* Disable phy_sw_coma register and re-enable JAGCore clocks */ pmcsr |= ET_PMCSR_INIT; pmcsr &= ~ET_PM_PHY_SW_COMA; - writel(pmcsr, &etdev->regs->global.pm_csr); + writel(pmcsr, &adapter->regs->global.pm_csr); /* Restore the GbE PHY speed and duplex modes; * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY */ - etdev->ai_force_speed = etdev->pdown_speed; - etdev->ai_force_duplex = etdev->pdown_duplex; + adapter->ai_force_speed = adapter->pdown_speed; + adapter->ai_force_duplex = adapter->pdown_duplex; /* Re-initialize the send structures */ - et131x_init_send(etdev); + et131x_init_send(adapter); /* Reset the RFD list and re-start RU */ - et131x_reset_recv(etdev); + et131x_reset_recv(adapter); /* Bring the device back to the state it was during init prior to * autonegotiation being complete. This way, when we get the auto-neg * complete interrupt, we can complete init by calling ConfigMacREGS2. */ - et131x_soft_reset(etdev); + et131x_soft_reset(adapter); /* setup et1310 as per the documentation ?? */ - et131x_adapter_setup(etdev); + et131x_adapter_setup(adapter); /* Allow Tx to restart */ - etdev->flags &= ~fMP_ADAPTER_LOWER_POWER; + adapter->flags &= ~fMP_ADAPTER_LOWER_POWER; /* Need to re-enable Rx. */ - et131x_rx_dma_enable(etdev); + et131x_rx_dma_enable(adapter); } diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 09243092cb7..e6458dbef93 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -605,19 +605,19 @@ int et131x_init_recv(struct et131x_adapter *adapter) /** * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) +void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) { - struct rxdma_regs __iomem *rx_dma = &etdev->regs->rxdma; - struct rx_ring *rx_local = &etdev->rx_ring; + struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; + struct rx_ring *rx_local = &adapter->rx_ring; struct fbr_desc *fbr_entry; u32 entry; u32 psr_num_des; unsigned long flags; /* Halt RXDMA to perform the reconfigure. */ - et131x_rx_dma_disable(etdev); + et131x_rx_dma_disable(adapter); /* Load the completion writeback physical address * @@ -645,7 +645,7 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, &rx_dma->psr_min_des); - spin_lock_irqsave(&etdev->rcv_lock, flags); + spin_lock_irqsave(&adapter->rcv_lock, flags); /* These local variables track the PSR in the adapter structure */ rx_local->local_psr_full = 0; @@ -715,34 +715,34 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *etdev) */ writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time); - spin_unlock_irqrestore(&etdev->rcv_lock, flags); + spin_unlock_irqrestore(&adapter->rcv_lock, flags); } /** * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et131x_set_rx_dma_timer(struct et131x_adapter *etdev) +void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) { /* For version B silicon, we do not use the RxDMA timer for 10 and 100 * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. */ - if ((etdev->linkspeed == TRUEPHY_SPEED_100MBPS) || - (etdev->linkspeed == TRUEPHY_SPEED_10MBPS)) { - writel(0, &etdev->regs->rxdma.max_pkt_time); - writel(1, &etdev->regs->rxdma.num_pkt_done); + if ((adapter->linkspeed == TRUEPHY_SPEED_100MBPS) || + (adapter->linkspeed == TRUEPHY_SPEED_10MBPS)) { + writel(0, &adapter->regs->rxdma.max_pkt_time); + writel(1, &adapter->regs->rxdma.num_pkt_done); } } /** * NICReturnRFD - Recycle a RFD and put it back onto the receive list - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * @rfd: pointer to the RFD */ -static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) +static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) { - struct rx_ring *rx_local = &etdev->rx_ring; - struct rxdma_regs __iomem *rx_dma = &etdev->regs->rxdma; + struct rx_ring *rx_local = &adapter->rx_ring; + struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; u16 buff_index = rfd->bufferindex; u8 ring_index = rfd->ringindex; unsigned long flags; @@ -755,7 +755,7 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || #endif (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { - spin_lock_irqsave(&etdev->fbr_lock, flags); + spin_lock_irqsave(&adapter->fbr_lock, flags); if (ring_index == 1) { struct fbr_desc *next = @@ -793,38 +793,38 @@ static void nic_return_rfd(struct et131x_adapter *etdev, struct rfd *rfd) &rx_dma->fbr0_full_offset); } #endif - spin_unlock_irqrestore(&etdev->fbr_lock, flags); + spin_unlock_irqrestore(&adapter->fbr_lock, flags); } else { - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "%s illegal Buffer Index returned\n", __func__); } /* The processing on this RFD is done, so put it back on the tail of * our list */ - spin_lock_irqsave(&etdev->rcv_lock, flags); + spin_lock_irqsave(&adapter->rcv_lock, flags); list_add_tail(&rfd->list_node, &rx_local->recv_list); rx_local->num_ready_recv++; - spin_unlock_irqrestore(&etdev->rcv_lock, flags); + spin_unlock_irqrestore(&adapter->rcv_lock, flags); WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); } /** * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et131x_rx_dma_disable(struct et131x_adapter *etdev) +void et131x_rx_dma_disable(struct et131x_adapter *adapter) { u32 csr; /* Setup the receive dma configuration register */ - writel(0x00002001, &etdev->regs->rxdma.csr); - csr = readl(&etdev->regs->rxdma.csr); + writel(0x00002001, &adapter->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ udelay(5); - csr = readl(&etdev->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); if ((csr & 0x00020000) == 0) - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "RX Dma failed to enter halt state. CSR 0x%08x\n", csr); } @@ -832,36 +832,36 @@ void et131x_rx_dma_disable(struct et131x_adapter *etdev) /** * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et131x_rx_dma_enable(struct et131x_adapter *etdev) +void et131x_rx_dma_enable(struct et131x_adapter *adapter) { /* Setup the receive dma configuration register for normal operation */ u32 csr = 0x2000; /* FBR1 enable */ - if (etdev->rx_ring.fbr1_buffsize == 4096) + if (adapter->rx_ring.fbr1_buffsize == 4096) csr |= 0x0800; - else if (etdev->rx_ring.fbr1_buffsize == 8192) + else if (adapter->rx_ring.fbr1_buffsize == 8192) csr |= 0x1000; - else if (etdev->rx_ring.fbr1_buffsize == 16384) + else if (adapter->rx_ring.fbr1_buffsize == 16384) csr |= 0x1800; #ifdef USE_FBR0 csr |= 0x0400; /* FBR0 enable */ - if (etdev->rx_ring.fbr0_buffsize == 256) + if (adapter->rx_ring.fbr0_buffsize == 256) csr |= 0x0100; - else if (etdev->rx_ring.fbr0_buffsize == 512) + else if (adapter->rx_ring.fbr0_buffsize == 512) csr |= 0x0200; - else if (etdev->rx_ring.fbr0_buffsize == 1024) + else if (adapter->rx_ring.fbr0_buffsize == 1024) csr |= 0x0300; #endif - writel(csr, &etdev->regs->rxdma.csr); + writel(csr, &adapter->regs->rxdma.csr); - csr = readl(&etdev->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); if ((csr & 0x00020000) != 0) { udelay(5); - csr = readl(&etdev->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); if ((csr & 0x00020000) != 0) { - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "RX Dma failed to exit halt state. CSR 0x%08x\n", csr); } @@ -870,7 +870,7 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) /** * nic_rx_pkts - Checks the hardware for available packets - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * * Returns rfd, a pointer to our MPRFD. * @@ -879,9 +879,9 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) * the packet to it, puts the RFD in the RecvPendList, and also returns * the pointer to the RFD. */ -static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) +static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) { - struct rx_ring *rx_local = &etdev->rx_ring; + struct rx_ring *rx_local = &adapter->rx_ring; struct rx_status_block *status; struct pkt_stat_desc *psr; struct rfd *rfd; @@ -931,7 +931,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) } writel(rx_local->local_psr_full, - &etdev->regs->rxdma.psr_full_offset); + &adapter->regs->rxdma.psr_full_offset); #ifndef USE_FBR0 if (ring_index != 1) @@ -949,7 +949,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "NICRxPkts PSR Entry %d indicates " "length of %d and/or bad bi(%d)\n", rx_local->local_psr_full & 0xFFF, @@ -958,21 +958,21 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) } /* Get and fill the RFD. */ - spin_lock_irqsave(&etdev->rcv_lock, flags); + spin_lock_irqsave(&adapter->rcv_lock, flags); rfd = NULL; element = rx_local->recv_list.next; rfd = (struct rfd *) list_entry(element, struct rfd, list_node); if (rfd == NULL) { - spin_unlock_irqrestore(&etdev->rcv_lock, flags); + spin_unlock_irqrestore(&adapter->rcv_lock, flags); return NULL; } list_del(&rfd->list_node); rx_local->num_ready_recv--; - spin_unlock_irqrestore(&etdev->rcv_lock, flags); + spin_unlock_irqrestore(&adapter->rcv_lock, flags); rfd->bufferindex = buff_index; rfd->ringindex = ring_index; @@ -983,18 +983,18 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * also counted here. */ if (len < (NIC_MIN_PACKET_SIZE + 4)) { - etdev->stats.rx_other_errs++; + adapter->stats.rx_other_errs++; len = 0; } if (len) { - if (etdev->replica_phy_loopbk == 1) { + if (adapter->replica_phy_loopbk == 1) { buf = rx_local->fbr[ring_index]->virt[buff_index]; - if (memcmp(&buf[6], etdev->addr, ETH_ALEN) == 0) { + if (memcmp(&buf[6], adapter->addr, ETH_ALEN) == 0) { if (memcmp(&buf[42], "Replica packet", ETH_HLEN)) { - etdev->replica_phy_loopbk_passfail = 1; + adapter->replica_phy_loopbk_passfail = 1; } } } @@ -1009,11 +1009,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * filters. Generally filter is 0x2b when in * promiscuous mode. */ - if ((etdev->packet_filter & + if ((adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) - && !(etdev->packet_filter & + && !(adapter->packet_filter & ET131X_PACKET_TYPE_PROMISCUOUS) - && !(etdev->packet_filter & + && !(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { buf = rx_local->fbr[ring_index]-> virt[buff_index]; @@ -1022,20 +1022,20 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * destination address of this packet * matches one in our list. */ - for (i = 0; i < etdev->multicast_addr_count; + for (i = 0; i < adapter->multicast_addr_count; i++) { if (buf[0] == - etdev->multicast_list[i][0] + adapter->multicast_list[i][0] && buf[1] == - etdev->multicast_list[i][1] + adapter->multicast_list[i][1] && buf[2] == - etdev->multicast_list[i][2] + adapter->multicast_list[i][2] && buf[3] == - etdev->multicast_list[i][3] + adapter->multicast_list[i][3] && buf[4] == - etdev->multicast_list[i][4] + adapter->multicast_list[i][4] && buf[5] == - etdev->multicast_list[i][5]) { + adapter->multicast_list[i][5]) { break; } } @@ -1048,21 +1048,21 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) * so we free our RFD when we return * from this function. */ - if (i == etdev->multicast_addr_count) + if (i == adapter->multicast_addr_count) len = 0; } if (len > 0) - etdev->stats.multicast_pkts_rcvd++; + adapter->stats.multicast_pkts_rcvd++; } else if (word0 & ALCATEL_BROADCAST_PKT) - etdev->stats.broadcast_pkts_rcvd++; + adapter->stats.broadcast_pkts_rcvd++; else /* Not sure what this counter measures in * promiscuous mode. Perhaps we should check * the MAC address to see if it is directed * to us in promiscuous mode. */ - etdev->stats.unicast_pkts_rcvd++; + adapter->stats.unicast_pkts_rcvd++; } if (len > 0) { @@ -1073,19 +1073,19 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) skb = dev_alloc_skb(rfd->len + 2); if (!skb) { - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "Couldn't alloc an SKB for Rx\n"); return NULL; } - etdev->net_stats.rx_bytes += rfd->len; + adapter->net_stats.rx_bytes += rfd->len; memcpy(skb_put(skb, rfd->len), rx_local->fbr[ring_index]->virt[buff_index], rfd->len); - skb->dev = etdev->netdev; - skb->protocol = eth_type_trans(skb, etdev->netdev); + skb->dev = adapter->netdev; + skb->protocol = eth_type_trans(skb, adapter->netdev); skb->ip_summed = CHECKSUM_NONE; netif_rx(skb); @@ -1093,28 +1093,28 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *etdev) rfd->len = 0; } - nic_return_rfd(etdev, rfd); + nic_return_rfd(adapter, rfd); return rfd; } /** * et131x_reset_recv - Reset the receive list - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * * Assumption, Rcv spinlock has been acquired. */ -void et131x_reset_recv(struct et131x_adapter *etdev) +void et131x_reset_recv(struct et131x_adapter *adapter) { - WARN_ON(list_empty(&etdev->rx_ring.recv_list)); + WARN_ON(list_empty(&adapter->rx_ring.recv_list)); } /** * et131x_handle_recv_interrupt - Interrupt handler for receive processing - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * * Assumption, Rcv spinlock has been acquired. */ -void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) +void et131x_handle_recv_interrupt(struct et131x_adapter *adapter) { struct rfd *rfd = NULL; u32 count = 0; @@ -1122,13 +1122,13 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) /* Process up to available RFD's */ while (count < NUM_PACKETS_HANDLED) { - if (list_empty(&etdev->rx_ring.recv_list)) { - WARN_ON(etdev->rx_ring.num_ready_recv != 0); + if (list_empty(&adapter->rx_ring.recv_list)) { + WARN_ON(adapter->rx_ring.num_ready_recv != 0); done = false; break; } - rfd = nic_rx_pkts(etdev); + rfd = nic_rx_pkts(adapter); if (rfd == NULL) break; @@ -1138,28 +1138,28 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) * If length is zero, return the RFD in order to advance the * Free buffer ring. */ - if (!etdev->packet_filter || - !netif_carrier_ok(etdev->netdev) || + if (!adapter->packet_filter || + !netif_carrier_ok(adapter->netdev) || rfd->len == 0) continue; /* Increment the number of packets we received */ - etdev->net_stats.rx_packets++; + adapter->net_stats.rx_packets++; /* Set the status on the packet, either resources or success */ - if (etdev->rx_ring.num_ready_recv < RFD_LOW_WATER_MARK) { - dev_warn(&etdev->pdev->dev, + if (adapter->rx_ring.num_ready_recv < RFD_LOW_WATER_MARK) { + dev_warn(&adapter->pdev->dev, "RFD's are running out\n"); } count++; } if (count == NUM_PACKETS_HANDLED || !done) { - etdev->rx_ring.unfinished_receives = true; + adapter->rx_ring.unfinished_receives = true; writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, - &etdev->regs->global.watchdog_timer); + &adapter->regs->global.watchdog_timer); } else /* Watchdog timer will disable itself if appropriate. */ - etdev->rx_ring.unfinished_receives = false; + adapter->rx_ring.unfinished_receives = false; } diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index eb8552b251d..f8211048f6b 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -181,59 +181,59 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) /** * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * * Configure the transmit engine with the ring buffers we have created * and prepare it for use. */ -void et131x_config_tx_dma_regs(struct et131x_adapter *etdev) +void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) { - struct txdma_regs __iomem *txdma = &etdev->regs->txdma; + struct txdma_regs __iomem *txdma = &adapter->regs->txdma; /* Load the hardware with the start of the transmit descriptor ring. */ - writel((u32) ((u64)etdev->tx_ring.tx_desc_ring_pa >> 32), + writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32), &txdma->pr_base_hi); - writel((u32) etdev->tx_ring.tx_desc_ring_pa, + writel((u32) adapter->tx_ring.tx_desc_ring_pa, &txdma->pr_base_lo); /* Initialise the transmit DMA engine */ writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des); /* Load the completion writeback physical address */ - writel((u32)((u64)etdev->tx_ring.tx_status_pa >> 32), + writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32), &txdma->dma_wb_base_hi); - writel((u32)etdev->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); + writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); - *etdev->tx_ring.tx_status = 0; + *adapter->tx_ring.tx_status = 0; writel(0, &txdma->service_request); - etdev->tx_ring.send_idx = 0; + adapter->tx_ring.send_idx = 0; } /** * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure */ -void et131x_tx_dma_disable(struct et131x_adapter *etdev) +void et131x_tx_dma_disable(struct et131x_adapter *adapter) { /* Setup the tramsmit dma configuration register */ writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, - &etdev->regs->txdma.csr); + &adapter->regs->txdma.csr); } /** * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure * * Mainly used after a return to the D0 (full-power) state from a lower state. */ -void et131x_tx_dma_enable(struct et131x_adapter *etdev) +void et131x_tx_dma_enable(struct et131x_adapter *adapter) { /* Setup the transmit dma configuration register for normal * operation */ writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), - &etdev->regs->txdma.csr); + &adapter->regs->txdma.csr); } /** @@ -272,12 +272,12 @@ void et131x_init_send(struct et131x_adapter *adapter) /** * nic_send_packet - NIC specific send handler for version B silicon. - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * @tcb: pointer to struct tcb * * Returns 0 or errno. */ -static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) +static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) { u32 i; struct tx_desc desc[24]; /* 24 x 16 byte */ @@ -331,7 +331,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) * subsystem) */ desc[frag++].addr_lo = - pci_map_single(etdev->pdev, + pci_map_single(adapter->pdev, skb->data, skb->len - skb->data_len, @@ -350,7 +350,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) * subsystem) */ desc[frag++].addr_lo = - pci_map_single(etdev->pdev, + pci_map_single(adapter->pdev, skb->data, ((skb->len - skb->data_len) / 2), @@ -369,7 +369,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) * subsystem) */ desc[frag++].addr_lo = - pci_map_single(etdev->pdev, + pci_map_single(adapter->pdev, skb->data + ((skb->len - skb->data_len) / 2), @@ -389,7 +389,7 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) * addressable (as defined by the pci/dma subsystem) */ desc[frag++].addr_lo = - pci_map_page(etdev->pdev, + pci_map_page(adapter->pdev, frags[i - 1].page, frags[i - 1].page_offset, frags[i - 1].size, @@ -400,11 +400,11 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) if (frag == 0) return -EIO; - if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS) { - if (++etdev->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { + if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { /* Last element & Interrupt flag */ desc[frag - 1].flags = 0x5; - etdev->tx_ring.since_irq = 0; + adapter->tx_ring.since_irq = 0; } else { /* Last element */ desc[frag - 1].flags = 0x1; } @@ -413,13 +413,13 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) desc[0].flags |= 2; /* First element flag */ - tcb->index_start = etdev->tx_ring.send_idx; + tcb->index_start = adapter->tx_ring.send_idx; tcb->stale = 0; - spin_lock_irqsave(&etdev->send_hw_lock, flags); + spin_lock_irqsave(&adapter->send_hw_lock, flags); thiscopy = NUM_DESC_PER_RING_TX - - INDEX10(etdev->tx_ring.send_idx); + INDEX10(adapter->tx_ring.send_idx); if (thiscopy >= frag) { remainder = 0; @@ -428,61 +428,61 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) remainder = frag - thiscopy; } - memcpy(etdev->tx_ring.tx_desc_ring + - INDEX10(etdev->tx_ring.send_idx), desc, + memcpy(adapter->tx_ring.tx_desc_ring + + INDEX10(adapter->tx_ring.send_idx), desc, sizeof(struct tx_desc) * thiscopy); - add_10bit(&etdev->tx_ring.send_idx, thiscopy); + add_10bit(&adapter->tx_ring.send_idx, thiscopy); - if (INDEX10(etdev->tx_ring.send_idx) == 0 || - INDEX10(etdev->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { - etdev->tx_ring.send_idx &= ~ET_DMA10_MASK; - etdev->tx_ring.send_idx ^= ET_DMA10_WRAP; + if (INDEX10(adapter->tx_ring.send_idx) == 0 || + INDEX10(adapter->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { + adapter->tx_ring.send_idx &= ~ET_DMA10_MASK; + adapter->tx_ring.send_idx ^= ET_DMA10_WRAP; } if (remainder) { - memcpy(etdev->tx_ring.tx_desc_ring, + memcpy(adapter->tx_ring.tx_desc_ring, desc + thiscopy, sizeof(struct tx_desc) * remainder); - add_10bit(&etdev->tx_ring.send_idx, remainder); + add_10bit(&adapter->tx_ring.send_idx, remainder); } - if (INDEX10(etdev->tx_ring.send_idx) == 0) { - if (etdev->tx_ring.send_idx) + if (INDEX10(adapter->tx_ring.send_idx) == 0) { + if (adapter->tx_ring.send_idx) tcb->index = NUM_DESC_PER_RING_TX - 1; else tcb->index = ET_DMA10_WRAP|(NUM_DESC_PER_RING_TX - 1); } else - tcb->index = etdev->tx_ring.send_idx - 1; + tcb->index = adapter->tx_ring.send_idx - 1; - spin_lock(&etdev->tcb_send_qlock); + spin_lock(&adapter->tcb_send_qlock); - if (etdev->tx_ring.send_tail) - etdev->tx_ring.send_tail->next = tcb; + if (adapter->tx_ring.send_tail) + adapter->tx_ring.send_tail->next = tcb; else - etdev->tx_ring.send_head = tcb; + adapter->tx_ring.send_head = tcb; - etdev->tx_ring.send_tail = tcb; + adapter->tx_ring.send_tail = tcb; WARN_ON(tcb->next != NULL); - etdev->tx_ring.used++; + adapter->tx_ring.used++; - spin_unlock(&etdev->tcb_send_qlock); + spin_unlock(&adapter->tcb_send_qlock); /* Write the new write pointer back to the device. */ - writel(etdev->tx_ring.send_idx, - &etdev->regs->txdma.service_request); + writel(adapter->tx_ring.send_idx, + &adapter->regs->txdma.service_request); /* For Gig only, we use Tx Interrupt coalescing. Enable the software * timer to wake us up if this packet isn't followed by N more. */ - if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, - &etdev->regs->global.watchdog_timer); + &adapter->regs->global.watchdog_timer); } - spin_unlock_irqrestore(&etdev->send_hw_lock, flags); + spin_unlock_irqrestore(&adapter->send_hw_lock, flags); return 0; } @@ -490,13 +490,13 @@ static int nic_send_packet(struct et131x_adapter *etdev, struct tcb *tcb) /** * send_packet - Do the work to send a packet * @skb: the packet(s) to send - * @etdev: a pointer to the device's private adapter structure + * @adapter: a pointer to the device's private adapter structure * * Return 0 in almost all cases; non-zero value in extreme hard failure only. * * Assumption: Send spinlock has been acquired */ -static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) +static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) { int status; struct tcb *tcb = NULL; @@ -508,21 +508,21 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) return -EIO; /* Get a TCB for this packet */ - spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - tcb = etdev->tx_ring.tcb_qhead; + tcb = adapter->tx_ring.tcb_qhead; if (tcb == NULL) { - spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); return -ENOMEM; } - etdev->tx_ring.tcb_qhead = tcb->next; + adapter->tx_ring.tcb_qhead = tcb->next; - if (etdev->tx_ring.tcb_qhead == NULL) - etdev->tx_ring.tcb_qtail = NULL; + if (adapter->tx_ring.tcb_qhead == NULL) + adapter->tx_ring.tcb_qtail = NULL; - spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); tcb->skb = skb; @@ -540,22 +540,22 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) tcb->next = NULL; /* Call the NIC specific send handler. */ - status = nic_send_packet(etdev, tcb); + status = nic_send_packet(adapter, tcb); if (status != 0) { - spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - if (etdev->tx_ring.tcb_qtail) - etdev->tx_ring.tcb_qtail->next = tcb; + if (adapter->tx_ring.tcb_qtail) + adapter->tx_ring.tcb_qtail->next = tcb; else /* Apparently ready Q is empty. */ - etdev->tx_ring.tcb_qhead = tcb; + adapter->tx_ring.tcb_qhead = tcb; - etdev->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); + adapter->tx_ring.tcb_qtail = tcb; + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); return status; } - WARN_ON(etdev->tx_ring.used > NUM_TCB); + WARN_ON(adapter->tx_ring.used > NUM_TCB); return 0; } @@ -569,9 +569,9 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *etdev) int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) { int status = 0; - struct et131x_adapter *etdev = NULL; + struct et131x_adapter *adapter = NULL; - etdev = netdev_priv(netdev); + adapter = netdev_priv(netdev); /* Send these packets * @@ -580,7 +580,7 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) */ /* TCB is not available */ - if (etdev->tx_ring.used >= NUM_TCB) { + if (adapter->tx_ring.used >= NUM_TCB) { /* NOTE: If there's an error on send, no need to queue the * packet under Linux; if we just send an error up to the * netif layer, it will resend the skb to us. @@ -590,21 +590,21 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) /* We need to see if the link is up; if it's not, make the * netif layer think we're good and drop the packet */ - if ((etdev->flags & fMP_ADAPTER_FAIL_SEND_MASK) || + if ((adapter->flags & fMP_ADAPTER_FAIL_SEND_MASK) || !netif_carrier_ok(netdev)) { dev_kfree_skb_any(skb); skb = NULL; - etdev->net_stats.tx_dropped++; + adapter->net_stats.tx_dropped++; } else { - status = send_packet(skb, etdev); + status = send_packet(skb, adapter); if (status != 0 && status != -ENOMEM) { /* On any other error, make netif think we're * OK and drop the packet */ dev_kfree_skb_any(skb); skb = NULL; - etdev->net_stats.tx_dropped++; + adapter->net_stats.tx_dropped++; } } } @@ -613,25 +613,25 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) /** * free_send_packet - Recycle a struct tcb - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * @tcb: pointer to struct tcb * * Complete the packet if necessary * Assumption - Send spinlock has been acquired */ -static inline void free_send_packet(struct et131x_adapter *etdev, +static inline void free_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) { unsigned long flags; struct tx_desc *desc = NULL; - struct net_device_stats *stats = &etdev->net_stats; + struct net_device_stats *stats = &adapter->net_stats; if (tcb->flags & fMP_DEST_BROAD) - atomic_inc(&etdev->stats.broadcast_pkts_xmtd); + atomic_inc(&adapter->stats.broadcast_pkts_xmtd); else if (tcb->flags & fMP_DEST_MULTI) - atomic_inc(&etdev->stats.multicast_pkts_xmtd); + atomic_inc(&adapter->stats.multicast_pkts_xmtd); else - atomic_inc(&etdev->stats.unicast_pkts_xmtd); + atomic_inc(&adapter->stats.unicast_pkts_xmtd); if (tcb->skb) { stats->tx_bytes += tcb->skb->len; @@ -641,10 +641,10 @@ static inline void free_send_packet(struct et131x_adapter *etdev, * they point to */ do { - desc = (struct tx_desc *)(etdev->tx_ring.tx_desc_ring + + desc = (struct tx_desc *)(adapter->tx_ring.tx_desc_ring + INDEX10(tcb->index_start)); - pci_unmap_single(etdev->pdev, + pci_unmap_single(adapter->pdev, desc->addr_lo, desc->len_vlan, PCI_DMA_TODEVICE); @@ -654,7 +654,7 @@ static inline void free_send_packet(struct et131x_adapter *etdev, tcb->index_start &= ~ET_DMA10_MASK; tcb->index_start ^= ET_DMA10_WRAP; } - } while (desc != (etdev->tx_ring.tx_desc_ring + + } while (desc != (adapter->tx_ring.tx_desc_ring + INDEX10(tcb->index))); dev_kfree_skb_any(tcb->skb); @@ -663,127 +663,127 @@ static inline void free_send_packet(struct et131x_adapter *etdev, memset(tcb, 0, sizeof(struct tcb)); /* Add the TCB to the Ready Q */ - spin_lock_irqsave(&etdev->tcb_ready_qlock, flags); + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - etdev->net_stats.tx_packets++; + adapter->net_stats.tx_packets++; - if (etdev->tx_ring.tcb_qtail) - etdev->tx_ring.tcb_qtail->next = tcb; + if (adapter->tx_ring.tcb_qtail) + adapter->tx_ring.tcb_qtail->next = tcb; else /* Apparently ready Q is empty. */ - etdev->tx_ring.tcb_qhead = tcb; + adapter->tx_ring.tcb_qhead = tcb; - etdev->tx_ring.tcb_qtail = tcb; + adapter->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&etdev->tcb_ready_qlock, flags); - WARN_ON(etdev->tx_ring.used < 0); + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); + WARN_ON(adapter->tx_ring.used < 0); } /** * et131x_free_busy_send_packets - Free and complete the stopped active sends - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * * Assumption - Send spinlock has been acquired */ -void et131x_free_busy_send_packets(struct et131x_adapter *etdev) +void et131x_free_busy_send_packets(struct et131x_adapter *adapter) { struct tcb *tcb; unsigned long flags; u32 freed = 0; /* Any packets being sent? Check the first TCB on the send list */ - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; while (tcb != NULL && freed < NUM_TCB) { struct tcb *next = tcb->next; - etdev->tx_ring.send_head = next; + adapter->tx_ring.send_head = next; if (next == NULL) - etdev->tx_ring.send_tail = NULL; + adapter->tx_ring.send_tail = NULL; - etdev->tx_ring.used--; + adapter->tx_ring.used--; - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); freed++; - free_send_packet(etdev, tcb); + free_send_packet(adapter, tcb); - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; } WARN_ON(freed == NUM_TCB); - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - etdev->tx_ring.used = 0; + adapter->tx_ring.used = 0; } /** * et131x_handle_send_interrupt - Interrupt handler for sending processing - * @etdev: pointer to our adapter + * @adapter: pointer to our adapter * * Re-claim the send resources, complete sends and get more to send from * the send wait queue. * * Assumption - Send spinlock has been acquired */ -void et131x_handle_send_interrupt(struct et131x_adapter *etdev) +void et131x_handle_send_interrupt(struct et131x_adapter *adapter) { unsigned long flags; u32 serviced; struct tcb *tcb; u32 index; - serviced = readl(&etdev->regs->txdma.new_service_complete); + serviced = readl(&adapter->regs->txdma.new_service_complete); index = INDEX10(serviced); /* Has the ring wrapped? Process any descriptors that do not have * the same "wrap" indicator as the current completion indicator */ - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; while (tcb && ((serviced ^ tcb->index) & ET_DMA10_WRAP) && index < INDEX10(tcb->index)) { - etdev->tx_ring.used--; - etdev->tx_ring.send_head = tcb->next; + adapter->tx_ring.used--; + adapter->tx_ring.send_head = tcb->next; if (tcb->next == NULL) - etdev->tx_ring.send_tail = NULL; + adapter->tx_ring.send_tail = NULL; - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); - free_send_packet(etdev, tcb); - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + free_send_packet(adapter, tcb); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); /* Goto the next packet */ - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; } while (tcb && !((serviced ^ tcb->index) & ET_DMA10_WRAP) && index > (tcb->index & ET_DMA10_MASK)) { - etdev->tx_ring.used--; - etdev->tx_ring.send_head = tcb->next; + adapter->tx_ring.used--; + adapter->tx_ring.send_head = tcb->next; if (tcb->next == NULL) - etdev->tx_ring.send_tail = NULL; + adapter->tx_ring.send_tail = NULL; - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); - free_send_packet(etdev, tcb); - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + free_send_packet(adapter, tcb); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); /* Goto the next packet */ - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; } /* Wake up the queue when we hit a low-water mark */ - if (etdev->tx_ring.used <= NUM_TCB / 3) - netif_wake_queue(etdev->netdev); + if (adapter->tx_ring.used <= NUM_TCB / 3) + netif_wake_queue(adapter->netdev); - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); } diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 32a20ddaac5..59637c63195 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -263,38 +263,38 @@ static int et131x_pci_init(struct et131x_adapter *adapter, */ void et131x_error_timer_handler(unsigned long data) { - struct et131x_adapter *etdev = (struct et131x_adapter *) data; + struct et131x_adapter *adapter = (struct et131x_adapter *) data; u32 pm_csr; - pm_csr = readl(&etdev->regs->global.pm_csr); + pm_csr = readl(&adapter->regs->global.pm_csr); if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) - et1310_update_macstat_host_counters(etdev); + et1310_update_macstat_host_counters(adapter); else - dev_err(&etdev->pdev->dev, + dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); - if (!(etdev->bmsr & MI_BMSR_LINK_STATUS) && - etdev->registry_phy_coma && - etdev->boot_coma < 11) { - etdev->boot_coma++; + if (!(adapter->bmsr & MI_BMSR_LINK_STATUS) && + adapter->registry_phy_coma && + adapter->boot_coma < 11) { + adapter->boot_coma++; } - if (etdev->boot_coma == 10) { - if (!(etdev->bmsr & MI_BMSR_LINK_STATUS) - && etdev->registry_phy_coma) { + if (adapter->boot_coma == 10) { + if (!(adapter->bmsr & MI_BMSR_LINK_STATUS) + && adapter->registry_phy_coma) { if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { /* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux? */ - et131x_enable_interrupts(etdev); - et1310_enable_phy_coma(etdev); + et131x_enable_interrupts(adapter); + et1310_enable_phy_coma(adapter); } } } /* This is a periodic timer, so reschedule */ - mod_timer(&etdev->error_timer, jiffies + + mod_timer(&adapter->error_timer, jiffies + TX_ERROR_PERIOD * HZ / 1000); } @@ -305,34 +305,34 @@ void et131x_error_timer_handler(unsigned long data) */ void et131x_link_detection_handler(unsigned long data) { - struct et131x_adapter *etdev = (struct et131x_adapter *) data; + struct et131x_adapter *adapter = (struct et131x_adapter *) data; unsigned long flags; - if (etdev->media_state == 0) { - spin_lock_irqsave(&etdev->lock, flags); + if (adapter->media_state == 0) { + spin_lock_irqsave(&adapter->lock, flags); - etdev->media_state = NETIF_STATUS_MEDIA_DISCONNECT; + adapter->media_state = NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&etdev->lock, flags); + spin_unlock_irqrestore(&adapter->lock, flags); - netif_carrier_off(etdev->netdev); + netif_carrier_off(adapter->netdev); } } /** * et131x_configure_global_regs - configure JAGCore global regs - * @etdev: pointer to our adapter structure + * @adapter: pointer to our adapter structure * * Used to configure the global registers on the JAGCore */ -void et131x_configure_global_regs(struct et131x_adapter *etdev) +void et131x_configure_global_regs(struct et131x_adapter *adapter) { - struct global_regs __iomem *regs = &etdev->regs->global; + struct global_regs __iomem *regs = &adapter->regs->global; writel(0, ®s->rxq_start_addr); writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); - if (etdev->registry_jumbo_packet < 2048) { + if (adapter->registry_jumbo_packet < 2048) { /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word * block of RAM that the driver can split between Tx * and Rx as it desires. Our default is to split it @@ -340,7 +340,7 @@ void et131x_configure_global_regs(struct et131x_adapter *etdev) */ writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); - } else if (etdev->registry_jumbo_packet < 8192) { + } else if (adapter->registry_jumbo_packet < 8192) { /* For jumbo packets > 2k but < 8k, split 50-50. */ writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); @@ -368,59 +368,59 @@ void et131x_configure_global_regs(struct et131x_adapter *etdev) /** * et131x_adapter_setup - Set the adapter up as per cassini+ documentation - * @etdev: pointer to our private adapter structure + * @adapter: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_adapter_setup(struct et131x_adapter *etdev) +int et131x_adapter_setup(struct et131x_adapter *adapter) { int status = 0; /* Configure the JAGCore */ - et131x_configure_global_regs(etdev); + et131x_configure_global_regs(adapter); - et1310_config_mac_regs1(etdev); + et1310_config_mac_regs1(adapter); /* Configure the MMC registers */ /* All we need to do is initialize the Memory Control Register */ - writel(ET_MMC_ENABLE, &etdev->regs->mmc.mmc_ctrl); + writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl); - et1310_config_rxmac_regs(etdev); - et1310_config_txmac_regs(etdev); + et1310_config_rxmac_regs(adapter); + et1310_config_txmac_regs(adapter); - et131x_config_rx_dma_regs(etdev); - et131x_config_tx_dma_regs(etdev); + et131x_config_rx_dma_regs(adapter); + et131x_config_tx_dma_regs(adapter); - et1310_config_macstat_regs(etdev); + et1310_config_macstat_regs(adapter); /* Move the following code to Timer function?? */ - status = et131x_xcvr_find(etdev); + status = et131x_xcvr_find(adapter); if (status != 0) - dev_warn(&etdev->pdev->dev, "Could not find the xcvr\n"); + dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n"); /* Prepare the TRUEPHY library. */ - et1310_phy_init(etdev); + et1310_phy_init(adapter); /* Reset the phy now so changes take place */ - et1310_phy_reset(etdev); + et1310_phy_reset(adapter); /* Power down PHY */ - et1310_phy_power_down(etdev, 1); + et1310_phy_power_down(adapter, 1); /* * We need to turn off 1000 base half dulplex, the mac does not * support it. For the 10/100 part, turn off all gig advertisement */ - if (etdev->pdev->device != ET131X_PCI_DEVICE_ID_FAST) - et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); + if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) + et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); else - et1310_phy_advertise_1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); /* Power up PHY */ - et1310_phy_power_down(etdev, 0); + et1310_phy_power_down(adapter, 0); - et131x_setphy_normal(etdev); + et131x_setphy_normal(adapter); return status; } @@ -518,7 +518,7 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) /** * et131x_adapter_init - * @etdev: pointer to the private adapter struct + * @adapter: pointer to the private adapter struct * @pdev: pointer to the PCI device * * Initialize the data structures for the et131x_adapter object and link @@ -531,41 +531,41 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, static const u8 duplex[] = { 0, 1, 2, 1, 2, 2 }; static const u16 speed[] = { 0, 10, 10, 100, 100, 1000 }; - struct et131x_adapter *etdev; + struct et131x_adapter *adapter; /* Setup the fundamental net_device and private adapter structure * elements */ SET_NETDEV_DEV(netdev, &pdev->dev); /* Allocate private adapter struct and copy in relevant information */ - etdev = netdev_priv(netdev); - etdev->pdev = pci_dev_get(pdev); - etdev->netdev = netdev; + adapter = netdev_priv(netdev); + adapter->pdev = pci_dev_get(pdev); + adapter->netdev = netdev; /* Do the same for the netdev struct */ netdev->irq = pdev->irq; netdev->base_addr = pci_resource_start(pdev, 0); /* Initialize spinlocks here */ - spin_lock_init(&etdev->lock); - spin_lock_init(&etdev->tcb_send_qlock); - spin_lock_init(&etdev->tcb_ready_qlock); - spin_lock_init(&etdev->send_hw_lock); - spin_lock_init(&etdev->rcv_lock); - spin_lock_init(&etdev->rcv_pend_lock); - spin_lock_init(&etdev->fbr_lock); - spin_lock_init(&etdev->phy_lock); + spin_lock_init(&adapter->lock); + spin_lock_init(&adapter->tcb_send_qlock); + spin_lock_init(&adapter->tcb_ready_qlock); + spin_lock_init(&adapter->send_hw_lock); + spin_lock_init(&adapter->rcv_lock); + spin_lock_init(&adapter->rcv_pend_lock); + spin_lock_init(&adapter->fbr_lock); + spin_lock_init(&adapter->phy_lock); /* Parse configuration parameters into the private adapter struct */ if (et131x_speed_set) - dev_info(&etdev->pdev->dev, + dev_info(&adapter->pdev->dev, "Speed set manually to : %d\n", et131x_speed_set); - etdev->speed_duplex = et131x_speed_set; - etdev->registry_jumbo_packet = 1514; /* 1514-9216 */ + adapter->speed_duplex = et131x_speed_set; + adapter->registry_jumbo_packet = 1514; /* 1514-9216 */ /* Set the MAC address to a default */ - memcpy(etdev->addr, default_mac, ETH_ALEN); + memcpy(adapter->addr, default_mac, ETH_ALEN); /* Decode speed_duplex * @@ -575,14 +575,14 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, * If we are the 10/100 device, and gigabit is somehow requested then * knock it down to 100 full. */ - if (etdev->pdev->device == ET131X_PCI_DEVICE_ID_FAST && - etdev->speed_duplex == 5) - etdev->speed_duplex = 4; + if (adapter->pdev->device == ET131X_PCI_DEVICE_ID_FAST && + adapter->speed_duplex == 5) + adapter->speed_duplex = 4; - etdev->ai_force_speed = speed[etdev->speed_duplex]; - etdev->ai_force_duplex = duplex[etdev->speed_duplex]; /* Auto FDX */ + adapter->ai_force_speed = speed[adapter->speed_duplex]; + adapter->ai_force_duplex = duplex[adapter->speed_duplex]; /* Auto FDX */ - return etdev; + return adapter; } /** diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 1584ab21761..7cfd213fb13 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -242,10 +242,10 @@ out: */ void et131x_isr_handler(struct work_struct *work) { - struct et131x_adapter *etdev = + struct et131x_adapter *adapter = container_of(work, struct et131x_adapter, task); - u32 status = etdev->stats.interrupt_status; - struct address_map __iomem *iomem = etdev->regs; + u32 status = adapter->stats.interrupt_status; + struct address_map __iomem *iomem = adapter->regs; /* * These first two are by far the most common. Once handled, we clear @@ -254,11 +254,11 @@ void et131x_isr_handler(struct work_struct *work) */ /* Handle all the completed Transmit interrupts */ if (status & ET_INTR_TXDMA_ISR) - et131x_handle_send_interrupt(etdev); + et131x_handle_send_interrupt(adapter); /* Handle all the completed Receives interrupts */ if (status & ET_INTR_RXDMA_XFR_DONE) - et131x_handle_recv_interrupt(etdev); + et131x_handle_recv_interrupt(adapter); status &= 0xffffffd7; @@ -270,7 +270,7 @@ void et131x_isr_handler(struct work_struct *work) /* Following read also clears the register (COR) */ txdma_err = readl(&iomem->txdma.tx_dma_error); - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "TXDMA_ERR interrupt, error = %d\n", txdma_err); } @@ -295,8 +295,8 @@ void et131x_isr_handler(struct work_struct *work) /* If the user has flow control on, then we will * send a pause packet, otherwise just exit */ - if (etdev->flowcontrol == FLOW_TXONLY || - etdev->flowcontrol == FLOW_BOTH) { + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) { u32 pm_csr; /* Tell the device to send a pause packet via @@ -345,7 +345,7 @@ void et131x_isr_handler(struct work_struct *work) */ /* TRAP();*/ - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "RxDMA_ERR interrupt, error %x\n", readl(&iomem->txmac.tx_test)); } @@ -359,7 +359,7 @@ void et131x_isr_handler(struct work_struct *work) * message when we are in DBG mode, otherwise we * will ignore it. */ - dev_err(&etdev->pdev->dev, "WAKE_ON_LAN interrupt\n"); + dev_err(&adapter->pdev->dev, "WAKE_ON_LAN interrupt\n"); } /* Handle the PHY interrupt */ @@ -379,26 +379,26 @@ void et131x_isr_handler(struct work_struct *work) * so, disable it because we will not be able * to read PHY values until we are out. */ - et1310_disable_phy_coma(etdev); + et1310_disable_phy_coma(adapter); } /* Read the PHY ISR to clear the reason for the * interrupt. */ - et131x_mii_read(etdev, + et131x_mii_read(adapter, (uint8_t) offsetof(struct mi_regs, isr), &myisr); - if (!etdev->replica_phy_loopbk) { - et131x_mii_read(etdev, + if (!adapter->replica_phy_loopbk) { + et131x_mii_read(adapter, (uint8_t) offsetof(struct mi_regs, bmsr), &bmsr_data); - bmsr_ints = etdev->bmsr ^ bmsr_data; - etdev->bmsr = bmsr_data; + bmsr_ints = adapter->bmsr ^ bmsr_data; + adapter->bmsr = bmsr_data; /* Do all the cable in / cable out stuff */ - et131x_mii_check(etdev, bmsr_data, bmsr_ints); + et131x_mii_check(adapter, bmsr_data, bmsr_ints); } } @@ -416,7 +416,7 @@ void et131x_isr_handler(struct work_struct *work) * a nutshell, the whole Tx path will have to be reset * and re-configured afterwards. */ - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "TXMAC interrupt, error 0x%08x\n", err); @@ -434,14 +434,14 @@ void et131x_isr_handler(struct work_struct *work) * set the flag to cause us to reset so we can solve * this issue. */ - /* MP_SET_FLAG( etdev, + /* MP_SET_FLAG( adapter, fMP_ADAPTER_HARDWARE_ERROR); */ - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "RXMAC interrupt, error 0x%08x. Requesting reset\n", readl(&iomem->rxmac.err_reg)); - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "Enable 0x%08x, Diag 0x%08x\n", readl(&iomem->rxmac.ctrl), readl(&iomem->rxmac.rxq_diag)); @@ -461,7 +461,7 @@ void et131x_isr_handler(struct work_struct *work) * to maintain the top, software managed bits of the * counter(s). */ - et1310_handle_macstat_interrupt(etdev); + et1310_handle_macstat_interrupt(adapter); } /* Handle SLV Timeout Interrupt */ @@ -477,5 +477,5 @@ void et131x_isr_handler(struct work_struct *work) */ } } - et131x_enable_interrupts(etdev); + et131x_enable_interrupts(adapter); } diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 93ef9d5f04f..37e10696afb 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -212,19 +212,19 @@ int et131x_close(struct net_device *netdev) int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) { int status = 0; - struct et131x_adapter *etdev = netdev_priv(netdev); + struct et131x_adapter *adapter = netdev_priv(netdev); struct mii_ioctl_data *data = if_mii(reqbuf); switch (cmd) { case SIOCGMIIPHY: - data->phy_id = etdev->stats.xcvr_addr; + data->phy_id = adapter->stats.xcvr_addr; break; case SIOCGMIIREG: if (!capable(CAP_NET_ADMIN)) status = -EPERM; else - status = et131x_mii_read(etdev, + status = et131x_mii_read(adapter, data->reg_num, &data->val_out); break; @@ -232,7 +232,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) if (!capable(CAP_NET_ADMIN)) status = -EPERM; else - status = et131x_mii_write(etdev, data->reg_num, + status = et131x_mii_write(adapter, data->reg_num, data->val_in); break; @@ -445,35 +445,35 @@ int et131x_tx(struct sk_buff *skb, struct net_device *netdev) */ void et131x_tx_timeout(struct net_device *netdev) { - struct et131x_adapter *etdev = netdev_priv(netdev); + struct et131x_adapter *adapter = netdev_priv(netdev); struct tcb *tcb; unsigned long flags; /* Any nonrecoverable hardware error? * Checks adapter->flags for any failure in phy reading */ - if (etdev->flags & fMP_ADAPTER_NON_RECOVER_ERROR) + if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR) return; /* Hardware failure? */ - if (etdev->flags & fMP_ADAPTER_HARDWARE_ERROR) { - dev_err(&etdev->pdev->dev, "hardware error - reset\n"); + if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) { + dev_err(&adapter->pdev->dev, "hardware error - reset\n"); return; } /* Is send stuck? */ - spin_lock_irqsave(&etdev->tcb_send_qlock, flags); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - tcb = etdev->tx_ring.send_head; + tcb = adapter->tx_ring.send_head; if (tcb != NULL) { tcb->count++; if (tcb->count > NIC_SEND_HANG_THRESHOLD) { - spin_unlock_irqrestore(&etdev->tcb_send_qlock, + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - dev_warn(&etdev->pdev->dev, + dev_warn(&adapter->pdev->dev, "Send stuck - reset. tcb->WrIndex %x, flags 0x%08x\n", tcb->index, tcb->flags); @@ -485,7 +485,7 @@ void et131x_tx_timeout(struct net_device *netdev) } } - spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags); + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); } /** From c922d1241ff37ab2db0f1a29e4b043fe1d8a8e8c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:38 +0100 Subject: [PATCH 0271/1519] staging: et131x: Fix link detection signalling Remove redundant code around netif_carrier_XXX calls, and associated adapter->media_state, which prevented the link from being reported as off. Tested on an ET-1310 device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 26 +------------------------ drivers/staging/et131x/et131x_adapter.h | 6 ------ drivers/staging/et131x/et131x_initpci.c | 23 +--------------------- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 6eb9d5cb643..2c6898f707b 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -737,16 +737,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, if (bmsr_ints & MI_BMSR_LINK_STATUS) { if (bmsr & MI_BMSR_LINK_STATUS) { adapter->boot_coma = 20; - - /* Update our state variables and indicate the - * connected state - */ - spin_lock_irqsave(&adapter->lock, flags); - - adapter->media_state = NETIF_STATUS_MEDIA_CONNECT; - - spin_unlock_irqrestore(&adapter->lock, flags); - netif_carrier_on(adapter->netdev); } else { dev_warn(&adapter->pdev->dev, @@ -768,21 +758,7 @@ void et131x_mii_check(struct et131x_adapter *adapter, et131x_mii_write(adapter, 0x12, register18); } - /* For the first N seconds of life, we are in "link - * detection" When we are in this state, we should - * only report "connected". When the LinkDetection - * Timer expires, we can report disconnected (handled - * in the LinkDetectionDPC). - */ - if (adapter->media_state == NETIF_STATUS_MEDIA_DISCONNECT) { - spin_lock_irqsave(&adapter->lock, flags); - adapter->media_state = - NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&adapter->lock, - flags); - - netif_carrier_off(adapter->netdev); - } + netif_carrier_off(adapter->netdev); adapter->linkspeed = 0; adapter->duplex_mode = 0; diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 5dfa1534959..762e07ca3ee 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -196,12 +196,6 @@ struct et131x_adapter { u8 ai_force_duplex; /* duplex setting */ u16 ai_force_speed; /* 'Speed', user over-ride of line speed */ u8 flowcontrol; /* flow control validated by the far-end */ - enum { - NETIF_STATUS_INVALID = 0, - NETIF_STATUS_MEDIA_CONNECT, - NETIF_STATUS_MEDIA_DISCONNECT, - NETIF_STATUS_MAX - } media_state; /* Minimize init-time */ struct timer_list error_timer; diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 59637c63195..072cfb52a65 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -298,27 +298,6 @@ void et131x_error_timer_handler(unsigned long data) TX_ERROR_PERIOD * HZ / 1000); } -/** - * et131x_link_detection_handler - * - * Timer function for link up at driver load time - */ -void et131x_link_detection_handler(unsigned long data) -{ - struct et131x_adapter *adapter = (struct et131x_adapter *) data; - unsigned long flags; - - if (adapter->media_state == 0) { - spin_lock_irqsave(&adapter->lock, flags); - - adapter->media_state = NETIF_STATUS_MEDIA_DISCONNECT; - - spin_unlock_irqrestore(&adapter->lock, flags); - - netif_carrier_off(adapter->netdev); - } -} - /** * et131x_configure_global_regs - configure JAGCore global regs * @adapter: pointer to our adapter structure @@ -718,7 +697,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, adapter->error_timer.data = (unsigned long)adapter; /* Initialize link state */ - et131x_link_detection_handler((unsigned long)adapter); + netif_carrier_off(adapter->netdev); /* Initialize variable for counting how long we do not have link status */ From c8b7de7fce9cffe97e9d10dbda7b5476e2339d6f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:39 +0100 Subject: [PATCH 0272/1519] staging: et131x: Fix free IRQ from IRQ context warning after tx_timeout When a tx timeout occured, et131x_tx_timeout closed and re-opened the device to fix. As et131x_close called free_irq(), bad things ensued (see warning trace below), namely a storm of errors and warnings. Fixed by replacing the close() and open() calls with just the relevant functions previously called from these. Verified on an ET-1310 device. Signed-off-by: Mark Einon ---------- Aug 2 21:26:08 msilap kernel: [ 6484.816024] ------------[ cut here ]------------ Aug 2 21:26:08 msilap kernel: [ 6484.816039] WARNING: at /home/mark/Source/staging-2.6/net/sched/sch_generic.c:255 dev_watchdog+0xf0/0x150() Aug 2 21:26:08 msilap kernel: [ 6484.816045] Hardware name: MS-1727 Aug 2 21:26:08 msilap kernel: [ 6484.816050] NETDEV WATCHDOG: eth1 (et131x): transmit queue 0 timed out Aug 2 21:26:08 msilap kernel: [ 6484.816054] Modules linked in: et131x(C) aes_generic tcp_lp fuse nouveau ttm drm_kms_helper drm i2c_algo_bit sunrpc ipv6 cpufreq_ondemand acpi_cpufreq freq_table mperf uinput arc4 iwlagn snd_hda_codec_hdmi mac80211 sdhci_pci sdhci snd_hda_codec_realtek cfg80211 snd_hda_intel snd_hda_codec mmc_core snd_hwdep firewire_ohci firewire_core jmb38x_ms snd_seq snd_seq_device snd_pcm mxm_wmi ir_lirc_codec lirc_dev ir_sony_decoder i2c_i801 ir_jvc_decoder ir_rc6_decoder rc_rc6_mce i7core_edac edac_core snd_timer pcspkr rfkill r8169 mii i2c_core video ir_rc5_decoder memstick iTCO_wdt iTCO_vendor_support ir_nec_decoder ene_ir rc_core joydev microcode wmi snd crc_itu_t soundcore snd_page_alloc [last unloaded: et131x] Aug 2 21:26:08 msilap kernel: [ 6484.816163] Pid: 0, comm: kworker/0:1 Tainted: G C 3.0.0-rc6+ #21 Aug 2 21:26:08 msilap kernel: [ 6484.816167] Call Trace: Aug 2 21:26:08 msilap kernel: [ 6484.816171] [] warn_slowpath_common+0x85/0x9d Aug 2 21:26:08 msilap kernel: [ 6484.816189] [] warn_slowpath_fmt+0x46/0x48 Aug 2 21:26:08 msilap kernel: [ 6484.816196] [] ? netif_tx_lock+0x4a/0x7b Aug 2 21:26:08 msilap kernel: [ 6484.816203] [] dev_watchdog+0xf0/0x150 Aug 2 21:26:08 msilap kernel: [ 6484.816211] [] run_timer_softirq+0x1a9/0x279 Aug 2 21:26:08 msilap kernel: [ 6484.816218] [] ? netif_tx_unlock+0x53/0x53 Aug 2 21:26:08 msilap kernel: [ 6484.816226] [] __do_softirq+0xd5/0x1a4 Aug 2 21:26:08 msilap kernel: [ 6484.816234] [] ? paravirt_read_tsc+0x9/0xd Aug 2 21:26:08 msilap kernel: [ 6484.816245] [] call_softirq+0x1c/0x26 Aug 2 21:26:08 msilap kernel: [ 6484.816251] [] do_softirq+0x46/0x83 Aug 2 21:26:08 msilap kernel: [ 6484.816257] [] irq_exit+0x52/0x9b Aug 2 21:26:08 msilap kernel: [ 6484.816265] [] smp_apic_timer_interrupt+0x7c/0x8a Aug 2 21:26:08 msilap kernel: [ 6484.816273] [] apic_timer_interrupt+0x13/0x20 Aug 2 21:26:08 msilap kernel: [ 6484.816278] [] ? paravirt_read_tsc+0x9/0xd Aug 2 21:26:08 msilap kernel: [ 6484.816291] [] ? intel_idle+0xd1/0xf8 Aug 2 21:26:08 msilap kernel: [ 6484.816297] [] ? intel_idle+0xb3/0xf8 Aug 2 21:26:08 msilap kernel: [ 6484.816306] [] cpuidle_idle_call+0xe2/0x160 Aug 2 21:26:08 msilap kernel: [ 6484.816315] [] cpu_idle+0xaa/0xcc Aug 2 21:26:08 msilap kernel: [ 6484.816323] [] start_secondary+0x248/0x24f Aug 2 21:26:08 msilap kernel: [ 6484.816329] ---[ end trace 10ae1b2c6bae932f ]--- Aug 2 21:26:08 msilap kernel: [ 6484.816337] et131x 0000:02:00.0: Send stuck - reset. tcb->WrIndex 0, flags 0x00000000 Aug 2 21:26:08 msilap kernel: [ 6484.816344] ------------[ cut here ]------------ Aug 2 21:26:08 msilap kernel: [ 6484.816353] WARNING: at /home/mark/Source/staging-2.6/kernel/irq/manage.c:1131 __free_irq+0x58/0x192() Aug 2 21:26:08 msilap kernel: [ 6484.816358] Hardware name: MS-1727 Aug 2 21:26:08 msilap kernel: [ 6484.816362] Trying to free IRQ 16 from IRQ context! Aug 2 21:26:08 msilap kernel: [ 6484.816365] Modules linked in: et131x(C) aes_generic tcp_lp fuse nouveau ttm drm_kms_helper drm i2c_algo_bit sunrpc ipv6 cpufreq_ondemand acpi_cpufreq freq_table mperf uinput arc4 iwlagn snd_hda_codec_hdmi mac80211 sdhci_pci sdhci snd_hda_codec_realtek cfg80211 snd_hda_intel snd_hda_codec mmc_core snd_hwdep firewire_ohci firewire_core jmb38x_ms snd_seq snd_seq_device snd_pcm mxm_wmi ir_lirc_codec lirc_dev ir_sony_decoder i2c_i801 ir_jvc_decoder ir_rc6_decoder rc_rc6_mce i7core_edac edac_core snd_timer pcspkr rfkill r8169 mii i2c_core video ir_rc5_decoder memstick iTCO_wdt iTCO_vendor_support ir_nec_decoder ene_ir rc_core joydev microcode wmi snd crc_itu_t soundcore snd_page_alloc [last unloaded: et131x] Aug 2 21:26:08 msilap kernel: [ 6484.816459] Pid: 0, comm: kworker/0:1 Tainted: G WC 3.0.0-rc6+ #21 Aug 2 21:26:08 msilap kernel: [ 6484.816464] Call Trace: Aug 2 21:26:08 msilap kernel: [ 6484.816467] [] warn_slowpath_common+0x85/0x9d Aug 2 21:26:08 msilap kernel: [ 6484.816480] [] warn_slowpath_fmt+0x46/0x48 Aug 2 21:26:08 msilap kernel: [ 6484.816488] [] __free_irq+0x58/0x192 Aug 2 21:26:08 msilap kernel: [ 6484.816496] [] free_irq+0x5e/0x77 Aug 2 21:26:08 msilap kernel: [ 6484.816506] [] et131x_close+0x4b/0x5e [et131x] Aug 2 21:26:08 msilap kernel: [ 6484.816516] [] et131x_tx_timeout+0xac/0xc7 [et131x] Aug 2 21:26:08 msilap kernel: [ 6484.816523] [] dev_watchdog+0x104/0x150 Aug 2 21:26:08 msilap kernel: [ 6484.816530] [] run_timer_softirq+0x1a9/0x279 Aug 2 21:26:08 msilap kernel: [ 6484.816537] [] ? netif_tx_unlock+0x53/0x53 Aug 2 21:26:08 msilap kernel: [ 6484.816544] [] __do_softirq+0xd5/0x1a4 Aug 2 21:26:08 msilap kernel: [ 6484.816552] [] ? paravirt_read_tsc+0x9/0xd Aug 2 21:26:08 msilap kernel: [ 6484.816560] [] call_softirq+0x1c/0x26 Aug 2 21:26:08 msilap kernel: [ 6484.816566] [] do_softirq+0x46/0x83 Aug 2 21:26:08 msilap kernel: [ 6484.816572] [] irq_exit+0x52/0x9b Aug 2 21:26:08 msilap kernel: [ 6484.816580] [] smp_apic_timer_interrupt+0x7c/0x8a Aug 2 21:26:08 msilap kernel: [ 6484.816588] [] apic_timer_interrupt+0x13/0x20 Aug 2 21:26:08 msilap kernel: [ 6484.816592] [] ? paravirt_read_tsc+0x9/0xd Aug 2 21:26:08 msilap kernel: [ 6484.816604] [] ? intel_idle+0xd1/0xf8 Aug 2 21:26:08 msilap kernel: [ 6484.816610] [] ? intel_idle+0xb3/0xf8 Aug 2 21:26:08 msilap kernel: [ 6484.816617] [] cpuidle_idle_call+0xe2/0x160 Aug 2 21:26:08 msilap kernel: [ 6484.816625] [] cpu_idle+0xaa/0xcc Aug 2 21:26:08 msilap kernel: [ 6484.816632] [] start_secondary+0x248/0x24f Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 1 - drivers/staging/et131x/et131x_netdev.c | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 2c6898f707b..c845c27f23d 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -732,7 +732,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, u32 mdi_mdix; u32 masterslave; u32 polarity; - unsigned long flags; if (bmsr_ints & MI_BMSR_LINK_STATUS) { if (bmsr & MI_BMSR_LINK_STATUS) { diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 37e10696afb..70a0da3fb52 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -478,9 +478,28 @@ void et131x_tx_timeout(struct net_device *netdev) tcb->index, tcb->flags); - et131x_close(netdev); - et131x_open(netdev); + adapter->net_stats.tx_errors++; + /* perform reset */ + /* First thing is to stop the queue */ + netif_stop_queue(netdev); + + /* Stop the Tx and Rx DMA engines */ + et131x_rx_dma_disable(adapter); + et131x_tx_dma_disable(adapter); + + /* Disable device interrupts */ + et131x_disable_interrupts(adapter); + + /* Enable the Tx and Rx DMA engines (if not already enabled) */ + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + + /* Enable device interrupts */ + et131x_enable_interrupts(adapter); + + /* We're ready to move some data, so start the queue */ + netif_start_queue(netdev); return; } } From ac657d5884f31a16c900b2ad1098e01ec7fa4145 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 23 Aug 2011 23:40:40 +0100 Subject: [PATCH 0273/1519] staging: et131x: Update tx trans_start on device close to prevent tx_timeout Updating the tx trans_start before closing the device prevents a possible tx_timeout occuring during the closing process. Tested on an ET1310 device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_netdev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 70a0da3fb52..7555a241ed2 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -153,7 +153,7 @@ int et131x_open(struct net_device *netdev) result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED, netdev->name, netdev); if (result) { - dev_err(&adapter->pdev->dev, "c ould not register IRQ %d\n", + dev_err(&adapter->pdev->dev, "could not register IRQ %d\n", netdev->irq); return result; } @@ -182,6 +182,9 @@ int et131x_close(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); + /* Save the timestamp for the TX watchdog, prevent a timeout */ + netdev->trans_start = jiffies; + /* First thing is to stop the queue */ netif_stop_queue(netdev); @@ -449,6 +452,10 @@ void et131x_tx_timeout(struct net_device *netdev) struct tcb *tcb; unsigned long flags; + /* If the device is closed, ignore the timeout */ + if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)); + return; + /* Any nonrecoverable hardware error? * Checks adapter->flags for any failure in phy reading */ @@ -685,12 +692,12 @@ struct net_device *et131x_device_alloc(void) return NULL; } - /* Setup the function registration table (and other data) for a + /* + * Setup the function registration table (and other data) for a * net_device */ - netdev->watchdog_timeo = ET131X_TX_TIMEOUT; - netdev->netdev_ops = &et131x_netdev_ops; + netdev->netdev_ops = &et131x_netdev_ops; /* netdev->ethtool_ops = &et131x_ethtool_ops; */ From 94a799425eee8225a1e3fbe5f473d2ef04002577 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 23 Aug 2011 19:00:42 -0500 Subject: [PATCH 0274/1519] From: wlanfae [PATCH 1/8] rtl8192e: Import new version of driver from realtek Signed-off-by: wlanfae Signed-off-by: Mike McCormack Signed-off-by: Larry Finger --- --- drivers/staging/rtl8192e/Makefile | 68 +- drivers/staging/rtl8192e/dot11d.c | 216 + drivers/staging/rtl8192e/dot11d.h | 109 +- drivers/staging/rtl8192e/ieee80211/dot11d.c | 218 - drivers/staging/rtl8192e/ieee80211/dot11d.h | 102 - .../staging/rtl8192e/ieee80211/ieee80211.h | 2636 --------- .../rtl8192e/ieee80211/ieee80211_module.c | 352 -- .../staging/rtl8192e/ieee80211/ieee80211_rx.c | 2676 --------- .../rtl8192e/ieee80211/ieee80211_softmac.c | 3278 ----------- .../rtl8192e/ieee80211/rtl819x_BAProc.c | 676 --- .../rtl8192e/ieee80211/rtl819x_HTProc.c | 1732 ------ .../staging/rtl8192e/ieee80211/rtl819x_Qos.h | 582 -- .../rtl8192e/ieee80211/rtl819x_TSProc.c | 627 -- drivers/staging/rtl8192e/internal.h | 129 + drivers/staging/rtl8192e/kmap_types.h | 20 + drivers/staging/rtl8192e/license | 339 ++ drivers/staging/rtl8192e/r8190P_def.h | 415 ++ drivers/staging/rtl8192e/r8190P_hwimg.c | 4538 +++++++++++++++ drivers/staging/rtl8192e/r8190P_hwimg.h | 51 + drivers/staging/rtl8192e/r8190P_rtl8256.c | 366 ++ drivers/staging/rtl8192e/r8190P_rtl8256.h | 34 + drivers/staging/rtl8192e/r8192E_cmdpkt.c | 478 ++ drivers/staging/rtl8192e/r8192E_cmdpkt.h | 163 + drivers/staging/rtl8192e/r8192E_core.c.porig | 5039 +++++++++++++++++ drivers/staging/rtl8192e/r8192E_core.c.rej | 5036 ++++++++++++++++ drivers/staging/rtl8192e/r8192E_dev.c | 2670 +++++++++ drivers/staging/rtl8192e/r8192E_dev.h | 56 + drivers/staging/rtl8192e/r8192E_firmware.c | 396 ++ drivers/staging/rtl8192e/r8192E_firmware.h | 73 + drivers/staging/rtl8192e/r8192E_hw.h | 486 +- drivers/staging/rtl8192e/r8192E_hwimg.c | 3337 +++++++++++ drivers/staging/rtl8192e/r8192E_hwimg.h | 51 + drivers/staging/rtl8192e/r8192E_phy.c | 1963 +++++++ drivers/staging/rtl8192e/r8192E_phy.h | 164 + drivers/staging/rtl8192e/r8192E_phyreg.h | 852 +++ drivers/staging/rtl8192e/readme | 160 + .../rtl8192e/{ieee80211 => }/rtl819x_BA.h | 31 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 618 ++ .../rtl8192e/{ieee80211 => }/rtl819x_HT.h | 254 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 1531 +++++ drivers/staging/rtl8192e/rtl819x_Qos.h | 422 ++ .../rtl8192e/{ieee80211 => }/rtl819x_TS.h | 31 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 647 +++ drivers/staging/rtl8192e/rtl_cam.c | 379 ++ drivers/staging/rtl8192e/rtl_cam.h | 44 + drivers/staging/rtl8192e/rtl_core.c | 4084 +++++++++++++ drivers/staging/rtl8192e/rtl_core.h | 1190 ++++ .../rtl8192e/{ieee80211 => }/rtl_crypto.h | 19 +- drivers/staging/rtl8192e/rtl_debug.c | 1339 +++++ drivers/staging/rtl8192e/rtl_debug.h | 319 ++ drivers/staging/rtl8192e/rtl_dm.c | 4854 ++++++++++++++++ drivers/staging/rtl8192e/rtl_dm.h | 331 ++ drivers/staging/rtl8192e/rtl_eeprom.c | 141 + drivers/staging/rtl8192e/rtl_eeprom.h | 29 + drivers/staging/rtl8192e/rtl_ethtool.c | 59 + drivers/staging/rtl8192e/rtl_pci.c | 444 ++ drivers/staging/rtl8192e/rtl_pci.h | 104 + drivers/staging/rtl8192e/rtl_pm.c | 168 + drivers/staging/rtl8192e/rtl_pm.h | 39 + drivers/staging/rtl8192e/rtl_ps.c | 649 +++ drivers/staging/rtl8192e/rtl_ps.h | 64 + drivers/staging/rtl8192e/rtl_wx.c | 1509 +++++ drivers/staging/rtl8192e/rtl_wx.h | 31 + drivers/staging/rtl8192e/rtllib.h | 3452 +++++++++++ .../ieee80211_crypt.c => rtllib_crypt.c} | 87 +- .../ieee80211_crypt.h => rtllib_crypt.h} | 36 +- ...80211_crypt_ccmp.c => rtllib_crypt_ccmp.c} | 192 +- ...80211_crypt_tkip.c => rtllib_crypt_tkip.c} | 419 +- ...ee80211_crypt_wep.c => rtllib_crypt_wep.c} | 129 +- drivers/staging/rtl8192e/rtllib_endianfree.h | 156 + drivers/staging/rtl8192e/rtllib_module.c | 374 ++ drivers/staging/rtl8192e/rtllib_rx.c | 4234 ++++++++++++++ drivers/staging/rtl8192e/rtllib_softmac.c | 4150 ++++++++++++++ ...80211_softmac_wx.c => rtllib_softmac_wx.c} | 318 +- .../{ieee80211/ieee80211_tx.c => rtllib_tx.c} | 728 ++- .../{ieee80211/ieee80211_wx.c => rtllib_wx.c} | 445 +- 76 files changed, 59876 insertions(+), 14262 deletions(-) create mode 100644 drivers/staging/rtl8192e/dot11d.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/dot11d.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/dot11d.h delete mode 100644 drivers/staging/rtl8192e/ieee80211/ieee80211.h delete mode 100644 drivers/staging/rtl8192e/ieee80211/ieee80211_module.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/rtl819x_BAProc.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/rtl819x_HTProc.c delete mode 100644 drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h delete mode 100644 drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c create mode 100644 drivers/staging/rtl8192e/internal.h create mode 100644 drivers/staging/rtl8192e/kmap_types.h create mode 100644 drivers/staging/rtl8192e/license create mode 100644 drivers/staging/rtl8192e/r8190P_def.h create mode 100644 drivers/staging/rtl8192e/r8190P_hwimg.c create mode 100644 drivers/staging/rtl8192e/r8190P_hwimg.h create mode 100644 drivers/staging/rtl8192e/r8190P_rtl8256.c create mode 100644 drivers/staging/rtl8192e/r8190P_rtl8256.h create mode 100644 drivers/staging/rtl8192e/r8192E_cmdpkt.c create mode 100644 drivers/staging/rtl8192e/r8192E_cmdpkt.h create mode 100644 drivers/staging/rtl8192e/r8192E_core.c.porig create mode 100644 drivers/staging/rtl8192e/r8192E_core.c.rej create mode 100644 drivers/staging/rtl8192e/r8192E_dev.c create mode 100644 drivers/staging/rtl8192e/r8192E_dev.h create mode 100644 drivers/staging/rtl8192e/r8192E_firmware.c create mode 100644 drivers/staging/rtl8192e/r8192E_firmware.h create mode 100644 drivers/staging/rtl8192e/r8192E_hwimg.c create mode 100644 drivers/staging/rtl8192e/r8192E_hwimg.h create mode 100644 drivers/staging/rtl8192e/r8192E_phy.c create mode 100644 drivers/staging/rtl8192e/r8192E_phy.h create mode 100644 drivers/staging/rtl8192e/r8192E_phyreg.h create mode 100644 drivers/staging/rtl8192e/readme rename drivers/staging/rtl8192e/{ieee80211 => }/rtl819x_BA.h (56%) create mode 100644 drivers/staging/rtl8192e/rtl819x_BAProc.c rename drivers/staging/rtl8192e/{ieee80211 => }/rtl819x_HT.h (56%) create mode 100644 drivers/staging/rtl8192e/rtl819x_HTProc.c create mode 100644 drivers/staging/rtl8192e/rtl819x_Qos.h rename drivers/staging/rtl8192e/{ieee80211 => }/rtl819x_TS.h (50%) create mode 100644 drivers/staging/rtl8192e/rtl819x_TSProc.c create mode 100644 drivers/staging/rtl8192e/rtl_cam.c create mode 100644 drivers/staging/rtl8192e/rtl_cam.h create mode 100644 drivers/staging/rtl8192e/rtl_core.c create mode 100644 drivers/staging/rtl8192e/rtl_core.h rename drivers/staging/rtl8192e/{ieee80211 => }/rtl_crypto.h (97%) create mode 100644 drivers/staging/rtl8192e/rtl_debug.c create mode 100644 drivers/staging/rtl8192e/rtl_debug.h create mode 100644 drivers/staging/rtl8192e/rtl_dm.c create mode 100644 drivers/staging/rtl8192e/rtl_dm.h create mode 100644 drivers/staging/rtl8192e/rtl_eeprom.c create mode 100644 drivers/staging/rtl8192e/rtl_eeprom.h create mode 100644 drivers/staging/rtl8192e/rtl_ethtool.c create mode 100644 drivers/staging/rtl8192e/rtl_pci.c create mode 100644 drivers/staging/rtl8192e/rtl_pci.h create mode 100644 drivers/staging/rtl8192e/rtl_pm.c create mode 100644 drivers/staging/rtl8192e/rtl_pm.h create mode 100644 drivers/staging/rtl8192e/rtl_ps.c create mode 100644 drivers/staging/rtl8192e/rtl_ps.h create mode 100644 drivers/staging/rtl8192e/rtl_wx.c create mode 100644 drivers/staging/rtl8192e/rtl_wx.h create mode 100644 drivers/staging/rtl8192e/rtllib.h rename drivers/staging/rtl8192e/{ieee80211/ieee80211_crypt.c => rtllib_crypt.c} (64%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_crypt.h => rtllib_crypt.h} (72%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_crypt_ccmp.c => rtllib_crypt_ccmp.c} (66%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_crypt_tkip.c => rtllib_crypt_tkip.c} (61%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_crypt_wep.c => rtllib_crypt_wep.c} (67%) create mode 100644 drivers/staging/rtl8192e/rtllib_endianfree.h create mode 100644 drivers/staging/rtl8192e/rtllib_module.c create mode 100644 drivers/staging/rtl8192e/rtllib_rx.c create mode 100644 drivers/staging/rtl8192e/rtllib_softmac.c rename drivers/staging/rtl8192e/{ieee80211/ieee80211_softmac_wx.c => rtllib_softmac_wx.c} (55%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_tx.c => rtllib_tx.c} (56%) rename drivers/staging/rtl8192e/{ieee80211/ieee80211_wx.c => rtllib_wx.c} (69%) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index 6e410674359..7cf7a52875e 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -1,38 +1,46 @@ NIC_SELECT = RTL8192E -ccflags-y := -DRTL8192E -ccflags-y += -std=gnu89 -ccflags-y += -O2 -ccflags-y += -DTHOMAS_TURBO +ccflags-y += -DRTL8192E +ccflags-y += -DEEPROM_OLD_FORMAT_SUPPORT=1 +ccflags-y += -DUSE_FW_SOURCE_IMG_FILE +ccflags-y += -DENABLE_GPIO_RADIO_CTL +ccflags-y += -DCONFIG_PM_RTL +ccflags-y += -DCONFIG_PM +ccflags-y += -DENABLE_DOT11D +ccflags-y += -DHAVE_NET_DEVICE_OPS ccflags-y += -DENABLE_DOT11D -ccflags-y += -DENABLE_IPS -ccflags-y += -DENABLE_LPS - r8192e_pci-objs := \ - r8192E_core.o \ - r8180_93cx6.o \ - r8192E_wx.o \ - r8190_rtl8256.o \ - r819xE_phy.o \ - r819xE_firmware.o \ - r819xE_cmdpkt.o \ - r8192E_dm.o \ - r8192_pm.o \ - ieee80211/ieee80211_rx.o \ - ieee80211/ieee80211_softmac.o \ - ieee80211/ieee80211_tx.o \ - ieee80211/ieee80211_wx.o \ - ieee80211/ieee80211_module.o \ - ieee80211/ieee80211_softmac_wx.o \ - ieee80211/rtl819x_HTProc.o \ - ieee80211/rtl819x_TSProc.o \ - ieee80211/rtl819x_BAProc.o \ - ieee80211/dot11d.o \ - ieee80211/ieee80211_crypt.o \ - ieee80211/ieee80211_crypt_tkip.o \ - ieee80211/ieee80211_crypt_ccmp.o \ - ieee80211/ieee80211_crypt_wep.o + rtl_core.o \ + rtl_eeprom.o \ + rtl_ps.o \ + rtl_wx.o \ + rtl_cam.o \ + rtl_dm.o \ + rtl_pm.o \ + rtl_pci.o \ + rtl_debug.o \ + rtl_ethtool.o \ + r8192E_dev.o \ + r8192E_phy.o \ + r8192E_firmware.o \ + r8192E_cmdpkt.o \ + r8192E_hwimg.o \ + r8190P_rtl8256.o \ + rtllib_rx.o \ + rtllib_softmac.o \ + rtllib_tx.o \ + rtllib_wx.o \ + rtllib_module.o \ + rtllib_softmac_wx.o \ + rtl819x_HTProc.o \ + rtl819x_TSProc.o \ + rtl819x_BAProc.o \ + dot11d.o \ + rtllib_crypt.o \ + rtllib_crypt_tkip.o \ + rtllib_crypt_ccmp.o \ + rtllib_crypt_wep.o obj-$(CONFIG_RTL8192E) += r8192e_pci.o diff --git a/drivers/staging/rtl8192e/dot11d.c b/drivers/staging/rtl8192e/dot11d.c new file mode 100644 index 00000000000..ee0381e0a81 --- /dev/null +++ b/drivers/staging/rtl8192e/dot11d.c @@ -0,0 +1,216 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "dot11d.h" + +struct channel_list { + u8 Channel[32]; + u8 Len; +}; + +static struct channel_list ChannelPlan[] = { + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, + 149, 153, 157, 161, 165}, 24}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, + 60, 64}, 21}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, + 56, 60, 64}, 22}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, + 56, 60, 64}, 22}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, + 56, 60, 64}, 22}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, + 56, 60, 64}, 22}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, + 56, 60, 64}, 21} +}; + +void Dot11d_Init(struct rtllib_device *ieee) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); + pDot11dInfo->bEnabled = false; + + pDot11dInfo->State = DOT11D_STATE_NONE; + pDot11dInfo->CountryIeLen = 0; + memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + RESET_CIE_WATCHDOG(ieee); + +} + +void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device *ieee) +{ + int i, max_chan = 14, min_chan = 1; + + ieee->bGlobalDomain = false; + + if (ChannelPlan[channel_plan].Len != 0) { + memset(GET_DOT11D_INFO(ieee)->channel_map, 0, + sizeof(GET_DOT11D_INFO(ieee)->channel_map)); + for (i = 0; i < ChannelPlan[channel_plan].Len; i++) { + if (ChannelPlan[channel_plan].Channel[i] < min_chan || + ChannelPlan[channel_plan].Channel[i] > max_chan) + break; + GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan + [channel_plan].Channel[i]] = 1; + } + } + + switch (channel_plan) { + case COUNTRY_CODE_GLOBAL_DOMAIN: + ieee->bGlobalDomain = true; + for (i = 12; i <= 14; i++) + GET_DOT11D_INFO(ieee)->channel_map[i] = 2; + ieee->IbssStartChnl = 10; + ieee->ibss_maxjoin_chal = 11; + break; + + case COUNTRY_CODE_WORLD_WIDE_13: + for (i = 12; i <= 13; i++) + GET_DOT11D_INFO(ieee)->channel_map[i] = 2; + ieee->IbssStartChnl = 10; + ieee->ibss_maxjoin_chal = 11; + break; + + default: + ieee->IbssStartChnl = 1; + ieee->ibss_maxjoin_chal = 14; + break; + } +} + + +void Dot11d_Reset(struct rtllib_device *ieee) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); + u32 i; + + memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + for (i = 1; i <= 11; i++) + (pDot11dInfo->channel_map)[i] = 1; + for (i = 12; i <= 14; i++) + (pDot11dInfo->channel_map)[i] = 2; + pDot11dInfo->State = DOT11D_STATE_NONE; + pDot11dInfo->CountryIeLen = 0; + RESET_CIE_WATCHDOG(ieee); +} + +void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr, + u16 CoutryIeLen, u8 *pCoutryIe) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); + u8 i, j, NumTriples, MaxChnlNum; + struct chnl_txpow_triple *pTriple; + + memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + MaxChnlNum = 0; + NumTriples = (CoutryIeLen - 3) / 3; + pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3); + for (i = 0; i < NumTriples; i++) { + if (MaxChnlNum >= pTriple->FirstChnl) { + printk(KERN_INFO "Dot11d_UpdateCountryIe(): Invalid" + " country IE, skip it........1\n"); + return; + } + if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + + pTriple->NumChnls)) { + printk(KERN_INFO "Dot11d_UpdateCountryIe(): Invalid " + "country IE, skip it........2\n"); + return; + } + + for (j = 0 ; j < pTriple->NumChnls; j++) { + pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1; + pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = + pTriple->MaxTxPowerInDbm; + MaxChnlNum = pTriple->FirstChnl + j; + } + + pTriple = (struct chnl_txpow_triple *)((u8*)pTriple + 3); + } + + UPDATE_CIE_SRC(dev, pTaddr); + + pDot11dInfo->CountryIeLen = CoutryIeLen; + memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen); + pDot11dInfo->State = DOT11D_STATE_LEARNED; +} + +u8 DOT11D_GetMaxTxPwrInDbm(struct rtllib_device *dev, u8 Channel) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); + u8 MaxTxPwrInDbm = 255; + + if (MAX_CHANNEL_NUMBER < Channel) { + printk(KERN_INFO "DOT11D_GetMaxTxPwrInDbm(): Invalid " + "Channel\n"); + return MaxTxPwrInDbm; + } + if (pDot11dInfo->channel_map[Channel]) + MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel]; + + return MaxTxPwrInDbm; +} + +void DOT11D_ScanComplete(struct rtllib_device *dev) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); + + switch (pDot11dInfo->State) { + case DOT11D_STATE_LEARNED: + pDot11dInfo->State = DOT11D_STATE_DONE; + break; + case DOT11D_STATE_DONE: + Dot11d_Reset(dev); + break; + case DOT11D_STATE_NONE: + break; + } +} + +int ToLegalChannel(struct rtllib_device *dev, u8 channel) +{ + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); + u8 default_chn = 0; + u32 i; + + for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) { + if (pDot11dInfo->channel_map[i] > 0) { + default_chn = i; + break; + } + } + + if (MAX_CHANNEL_NUMBER < channel) { + printk(KERN_ERR "%s(): Invalid Channel\n", __func__); + return default_chn; + } + + if (pDot11dInfo->channel_map[channel] > 0) + return channel; + + return default_chn; +} diff --git a/drivers/staging/rtl8192e/dot11d.h b/drivers/staging/rtl8192e/dot11d.h index 8e644614f21..032f7004a7f 100644 --- a/drivers/staging/rtl8192e/dot11d.h +++ b/drivers/staging/rtl8192e/dot11d.h @@ -1,24 +1,42 @@ -#ifndef INC_DOT11D_H -#define INC_DOT11D_H +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_DOT11D_H +#define __INC_DOT11D_H -#ifdef ENABLE_DOT11D -#include "ieee80211.h" +#include "rtllib.h" -struct _CHNL_TXPOWER_TRIPLE { + + +struct chnl_txpow_triple { u8 FirstChnl; u8 NumChnls; u8 MaxTxPowerInDbm; }; -enum _DOT11D_STATE { +enum dot11d_state { DOT11D_STATE_NONE = 0, DOT11D_STATE_LEARNED, DOT11D_STATE_DONE, }; /** - * struct _RT_DOT11D_INFO - * @CountryIeLen: value greater than 0 if @CountryIeBuf contains + * struct rt_dot11d_info * @CountryIeLen: value greater than 0 if @CountryIeBuf contains * valid country information element. * @chanell_map: holds channel values * 0 - invalid, @@ -27,18 +45,19 @@ enum _DOT11D_STATE { * @CountryIeSrcAddr - Source AP of the country IE */ -struct _RT_DOT11D_INFO { +struct rt_dot11d_info { + bool bEnabled; u16 CountryIeLen; - u8 CountryIeBuf[MAX_IE_LEN]; - u8 CountryIeSrcAddr[6]; - u8 CountryIeWatchdog; + u8 CountryIeBuf[MAX_IE_LEN]; + u8 CountryIeSrcAddr[6]; + u8 CountryIeWatchdog; - u8 channel_map[MAX_CHANNEL_NUMBER+1]; - u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; + u8 channel_map[MAX_CHANNEL_NUMBER+1]; + u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; - DOT11D_STATE State; + enum dot11d_state State; }; static inline void cpMacAddr(unsigned char *des, unsigned char *src) @@ -46,49 +65,41 @@ static inline void cpMacAddr(unsigned char *des, unsigned char *src) memcpy(des, src, 6); } -#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO) \ - ((__pIeeeDev)->pDot11dInfo)) +#define GET_DOT11D_INFO(__pIeeeDev) \ + ((struct rt_dot11d_info *)((__pIeeeDev)->pDot11dInfo)) -#define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->bEnabled) -#define IS_COUNTRY_IE_VALID(__pIeeeDev) \ - (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) +#define IS_DOT11D_ENABLE(__pIeeeDev) \ + (GET_DOT11D_INFO(__pIeeeDev)->bEnabled) +#define IS_COUNTRY_IE_VALID(__pIeeeDev) \ + (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) -#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) \ - eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) - -#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) \ - cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) +#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) \ + eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) +#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) \ + cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ - (((__Ie).Length == 0 || (__Ie).Length != \ - GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? FALSE : \ - (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, \ + (((__Ie).Length == 0 || (__Ie).Length != \ + GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \ + false : (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, \ (__Ie).Octet, (__Ie).Length))) #define CIE_WATCHDOG_TH 1 -#define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)-> \ - CountryIeWatchdog) +#define GET_CIE_WATCHDOG(__pIeeeDev) \ + (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog) #define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0 #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev)) -#define IS_DOT11D_STATE_DONE(__pIeeeDev) \ - (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) +#define IS_DOT11D_STATE_DONE(__pIeeeDev) \ + (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) +void Dot11d_Init(struct rtllib_device *dev); +void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device *ieee); +void Dot11d_Reset(struct rtllib_device *dev); +void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr, + u16 CoutryIeLen, u8 *pCoutryIe); +u8 DOT11D_GetMaxTxPwrInDbm(struct rtllib_device *dev, u8 Channel); +void DOT11D_ScanComplete(struct rtllib_device *dev); +int ToLegalChannel(struct rtllib_device *dev, u8 channel); -void Dot11d_Init(struct ieee80211_device *dev); - -void Dot11d_Reset(struct ieee80211_device *dev); - -void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, - u16 CoutryIeLen, u8 *pCoutryIe); - -u8 DOT11D_GetMaxTxPwrInDbm(struct ieee80211_device *dev, u8 channel); - -void DOT11D_ScanComplete(struct ieee80211_device *dev); - -int IsLegalChannel(struct ieee80211_device *dev, u8 channel); - -int ToLegalChannel(struct ieee80211_device *dev, u8 channel); - -#endif /* ENABLE_DOT11D */ -#endif /* INC_DOT11D_H */ +#endif diff --git a/drivers/staging/rtl8192e/ieee80211/dot11d.c b/drivers/staging/rtl8192e/ieee80211/dot11d.c deleted file mode 100644 index 98e46487dc0..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/dot11d.c +++ /dev/null @@ -1,218 +0,0 @@ -#ifdef ENABLE_DOT11D -//----------------------------------------------------------------------------- -// File: -// Dot11d.c -// -// Description: -// Implement 802.11d. -// -//----------------------------------------------------------------------------- - -#include "dot11d.h" - -void -Dot11d_Init(struct ieee80211_device *ieee) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); - - pDot11dInfo->bEnabled = 0; - - pDot11dInfo->State = DOT11D_STATE_NONE; - pDot11dInfo->CountryIeLen = 0; - memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); - RESET_CIE_WATCHDOG(ieee); - - printk("Dot11d_Init()\n"); -} - -// -// Description: -// Reset to the state as we are just entering a regulatory domain. -// -void -Dot11d_Reset(struct ieee80211_device *ieee) -{ - u32 i; - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); -#if 0 - if(!pDot11dInfo->bEnabled) - return; -#endif - // Clear old channel map - memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); - // Set new channel map - for (i=1; i<=11; i++) { - (pDot11dInfo->channel_map)[i] = 1; - } - for (i=12; i<=14; i++) { - (pDot11dInfo->channel_map)[i] = 2; - } - - pDot11dInfo->State = DOT11D_STATE_NONE; - pDot11dInfo->CountryIeLen = 0; - RESET_CIE_WATCHDOG(ieee); -} - -// -// Description: -// Update country IE from Beacon or Probe Resopnse -// and configure PHY for operation in the regulatory domain. -// -// TODO: -// Configure Tx power. -// -// Assumption: -// 1. IS_DOT11D_ENABLE() is TRUE. -// 2. Input IE is an valid one. -// -void -Dot11d_UpdateCountryIe( - struct ieee80211_device *dev, - u8 * pTaddr, - u16 CoutryIeLen, - u8 * pCoutryIe - ) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - u8 i, j, NumTriples, MaxChnlNum; - PCHNL_TXPOWER_TRIPLE pTriple; - - memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); - MaxChnlNum = 0; - NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string. - pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3); - for(i = 0; i < NumTriples; i++) - { - if(MaxChnlNum >= pTriple->FirstChnl) - { // It is not in a monotonically increasing order, so stop processing. - printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); - return; - } - if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) - { // It is not a valid set of channel id, so stop processing. - printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n"); - return; - } - - for(j = 0 ; j < pTriple->NumChnls; j++) - { - pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1; - pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm; - MaxChnlNum = pTriple->FirstChnl + j; - } - - pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3); - } -#if 1 - printk("Channel List:"); - for(i=1; i<= MAX_CHANNEL_NUMBER; i++) - if(pDot11dInfo->channel_map[i] > 0) - printk(" %d", i); - printk("\n"); -#endif - - UPDATE_CIE_SRC(dev, pTaddr); - - pDot11dInfo->CountryIeLen = CoutryIeLen; - memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen); - pDot11dInfo->State = DOT11D_STATE_LEARNED; -} - - -u8 -DOT11D_GetMaxTxPwrInDbm( - struct ieee80211_device *dev, - u8 Channel - ) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - u8 MaxTxPwrInDbm = 255; - - if(MAX_CHANNEL_NUMBER < Channel) - { - printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n"); - return MaxTxPwrInDbm; - } - if(pDot11dInfo->channel_map[Channel]) - { - MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel]; - } - - return MaxTxPwrInDbm; -} - - -void -DOT11D_ScanComplete( - struct ieee80211_device * dev - ) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - - switch(pDot11dInfo->State) - { - case DOT11D_STATE_LEARNED: - pDot11dInfo->State = DOT11D_STATE_DONE; - break; - - case DOT11D_STATE_DONE: - if( GET_CIE_WATCHDOG(dev) == 0 ) - { // Reset country IE if previous one is gone. - Dot11d_Reset(dev); - } - break; - case DOT11D_STATE_NONE: - break; - } -} - -int IsLegalChannel( - struct ieee80211_device * dev, - u8 channel -) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - - if(MAX_CHANNEL_NUMBER < channel) - { - printk("IsLegalChannel(): Invalid Channel\n"); - return 0; - } - if(pDot11dInfo->channel_map[channel] > 0) - return 1; - return 0; -} - -int ToLegalChannel( - struct ieee80211_device * dev, - u8 channel -) -{ - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - u8 default_chn = 0; - u32 i = 0; - - for (i=1; i<= MAX_CHANNEL_NUMBER; i++) - { - if(pDot11dInfo->channel_map[i] > 0) - { - default_chn = i; - break; - } - } - - if(MAX_CHANNEL_NUMBER < channel) - { - printk("IsLegalChannel(): Invalid Channel\n"); - return default_chn; - } - - if(pDot11dInfo->channel_map[channel] > 0) - return channel; - - return default_chn; -} -#endif diff --git a/drivers/staging/rtl8192e/ieee80211/dot11d.h b/drivers/staging/rtl8192e/ieee80211/dot11d.h deleted file mode 100644 index 15b7a4ba37b..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/dot11d.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __INC_DOT11D_H -#define __INC_DOT11D_H - -#ifdef ENABLE_DOT11D -#include "ieee80211.h" - -//#define ENABLE_DOT11D - -//#define DOT11D_MAX_CHNL_NUM 83 - -typedef struct _CHNL_TXPOWER_TRIPLE { - u8 FirstChnl; - u8 NumChnls; - u8 MaxTxPowerInDbm; -}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; - -typedef enum _DOT11D_STATE { - DOT11D_STATE_NONE = 0, - DOT11D_STATE_LEARNED, - DOT11D_STATE_DONE, -}DOT11D_STATE; - -typedef struct _RT_DOT11D_INFO { - //DECLARE_RT_OBJECT(RT_DOT11D_INFO); - - bool bEnabled; // dot11MultiDomainCapabilityEnabled - - u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element. - u8 CountryIeBuf[MAX_IE_LEN]; - u8 CountryIeSrcAddr[6]; // Source AP of the country IE. - u8 CountryIeWatchdog; - - u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) - //u8 ChnlListLen; // #Bytes valid in ChnlList[]. - //u8 ChnlList[DOT11D_MAX_CHNL_NUM]; - u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; - - DOT11D_STATE State; -}RT_DOT11D_INFO, *PRT_DOT11D_INFO; -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) -#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5]) -#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo)) - -#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled -#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) - -#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) -#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) - -#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ - (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \ - FALSE : \ - (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length))) - -#define CIE_WATCHDOG_TH 1 -#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog -#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0 -#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev) - -#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) - - -void -Dot11d_Init( - struct ieee80211_device *dev - ); - -void -Dot11d_Reset( - struct ieee80211_device *dev - ); - -void -Dot11d_UpdateCountryIe( - struct ieee80211_device *dev, - u8 * pTaddr, - u16 CoutryIeLen, - u8 * pCoutryIe - ); - -u8 -DOT11D_GetMaxTxPwrInDbm( - struct ieee80211_device *dev, - u8 Channel - ); - -void -DOT11D_ScanComplete( - struct ieee80211_device * dev - ); - -int IsLegalChannel( - struct ieee80211_device * dev, - u8 channel -); - -int ToLegalChannel( - struct ieee80211_device * dev, - u8 channel -); -#endif //ENABLE_DOT11D -#endif // #ifndef __INC_DOT11D_H diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211.h b/drivers/staging/rtl8192e/ieee80211/ieee80211.h deleted file mode 100644 index 6d7963e5b6a..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211.h +++ /dev/null @@ -1,2636 +0,0 @@ -/* - * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11 - * remains copyright by the original authors - * - * Portions of the merged code are based on Host AP (software wireless - * LAN access point) driver for Intersil Prism2/2.5/3. - * - * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - * - * Copyright (c) 2002-2003, Jouni Malinen - * - * Adaption to a generic IEEE 802.11 stack by James Ketrenos - * - * Copyright (c) 2004, Intel Corporation - * - * Modified for Realtek's wi-fi cards by Andrea Merello - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. See README and COPYING for - * more details. - */ -#ifndef IEEE80211_H -#define IEEE80211_H -#include /* ETH_ALEN */ -#include /* ARRAY_SIZE */ -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "rtl819x_HT.h" -#include "rtl819x_BA.h" -#include "rtl819x_TS.h" - -#ifndef IW_MODE_MONITOR -#define IW_MODE_MONITOR 6 -#endif - -#ifndef IWEVCUSTOM -#define IWEVCUSTOM 0x8c02 -#endif - -#ifndef container_of -/** - * container_of - cast a member of a structure out to the containing structure - * - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#endif - -#define KEY_TYPE_NA 0x0 -#define KEY_TYPE_WEP40 0x1 -#define KEY_TYPE_TKIP 0x2 -#define KEY_TYPE_CCMP 0x4 -#define KEY_TYPE_WEP104 0x5 - -/* added for rtl819x tx procedure */ -#define MAX_QUEUE_SIZE 0x10 - -// -// 8190 queue mapping -// -#define BK_QUEUE 0 -#define BE_QUEUE 1 -#define VI_QUEUE 2 -#define VO_QUEUE 3 -#define HCCA_QUEUE 4 -#define TXCMD_QUEUE 5 -#define MGNT_QUEUE 6 -#define HIGH_QUEUE 7 -#define BEACON_QUEUE 8 - -#define LOW_QUEUE BE_QUEUE -#define NORMAL_QUEUE MGNT_QUEUE - -//added by amy for ps -#define SWRF_TIMEOUT 50 - -//added by amy for LEAP related -#define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0. -#define SUPPORT_CKIP_MIC 0x08 // bit3 -#define SUPPORT_CKIP_PK 0x10 // bit4 -/* defined for skb cb field */ -/* At most 28 byte */ -typedef struct cb_desc { - /* Tx Desc Related flags (8-9) */ - u8 bLastIniPkt:1; - u8 bCmdOrInit:1; - u8 bFirstSeg:1; - u8 bLastSeg:1; - u8 bEncrypt:1; - u8 bTxDisableRateFallBack:1; - u8 bTxUseDriverAssingedRate:1; - u8 bHwSec:1; //indicate whether use Hw security. WB - - u8 reserved1; - - /* Tx Firmware Relaged flags (10-11)*/ - u8 bCTSEnable:1; - u8 bRTSEnable:1; - u8 bUseShortGI:1; - u8 bUseShortPreamble:1; - u8 bTxEnableFwCalcDur:1; - u8 bAMPDUEnable:1; - u8 bRTSSTBC:1; - u8 RTSSC:1; - - u8 bRTSBW:1; - u8 bPacketBW:1; - u8 bRTSUseShortPreamble:1; - u8 bRTSUseShortGI:1; - u8 bMulticast:1; - u8 bBroadcast:1; - //u8 reserved2:2; - u8 drv_agg_enable:1; - u8 reserved2:1; - - /* Tx Desc related element(12-19) */ - u8 rata_index; - u8 queue_index; - //u8 reserved3; - //u8 reserved4; - u16 txbuf_size; - //u8 reserved5; - u8 RATRIndex; - u8 reserved6; - u8 reserved7; - u8 reserved8; - - /* Tx firmware related element(20-27) */ - u8 data_rate; - u8 rts_rate; - u8 ampdu_factor; - u8 ampdu_density; - //u8 reserved9; - //u8 reserved10; - //u8 reserved11; - u8 DrvAggrNum; - u16 pkt_size; - u8 reserved12; - - u8 bdhcp; -}cb_desc, *pcb_desc; - -/*--------------------------Define -------------------------------------------*/ -#define MGN_1M 0x02 -#define MGN_2M 0x04 -#define MGN_5_5M 0x0b -#define MGN_11M 0x16 - -#define MGN_6M 0x0c -#define MGN_9M 0x12 -#define MGN_12M 0x18 -#define MGN_18M 0x24 -#define MGN_24M 0x30 -#define MGN_36M 0x48 -#define MGN_48M 0x60 -#define MGN_54M 0x6c - -#define MGN_MCS0 0x80 -#define MGN_MCS1 0x81 -#define MGN_MCS2 0x82 -#define MGN_MCS3 0x83 -#define MGN_MCS4 0x84 -#define MGN_MCS5 0x85 -#define MGN_MCS6 0x86 -#define MGN_MCS7 0x87 -#define MGN_MCS8 0x88 -#define MGN_MCS9 0x89 -#define MGN_MCS10 0x8a -#define MGN_MCS11 0x8b -#define MGN_MCS12 0x8c -#define MGN_MCS13 0x8d -#define MGN_MCS14 0x8e -#define MGN_MCS15 0x8f - -//---------------------------------------------------------------------------- -// 802.11 Management frame Reason Code field -//---------------------------------------------------------------------------- -enum _ReasonCode{ - unspec_reason = 0x1, - auth_not_valid = 0x2, - deauth_lv_ss = 0x3, - inactivity = 0x4, - ap_overload = 0x5, - class2_err = 0x6, - class3_err = 0x7, - disas_lv_ss = 0x8, - asoc_not_auth = 0x9, - - //----MIC_CHECK - mic_failure = 0xe, - //----END MIC_CHECK - - // Reason code defined in 802.11i D10.0 p.28. - invalid_IE = 0x0d, - four_way_tmout = 0x0f, - two_way_tmout = 0x10, - IE_dismatch = 0x11, - invalid_Gcipher = 0x12, - invalid_Pcipher = 0x13, - invalid_AKMP = 0x14, - unsup_RSNIEver = 0x15, - invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, - ciper_reject = 0x18, - - // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15. - QoS_unspec = 0x20, // 32 - QAP_bandwidth = 0x21, // 33 - poor_condition = 0x22, // 34 - no_facility = 0x23, // 35 - // Where is 36??? - req_declined = 0x25, // 37 - invalid_param = 0x26, // 38 - req_not_honored= 0x27, // 39 - TS_not_created = 0x2F, // 47 - DL_not_allowed = 0x30, // 48 - dest_not_exist = 0x31, // 49 - dest_not_QSTA = 0x32, // 50 -}; - - - -#define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A)||(priv->ieee80211->current_network.mode == IEEE_N_24G)||(priv->ieee80211->current_network.mode == IEEE_N_5G))? 16 : 10) - -#define MGMT_QUEUE_NUM 5 - -#define IEEE_CMD_SET_WPA_PARAM 1 -#define IEEE_CMD_SET_WPA_IE 2 -#define IEEE_CMD_SET_ENCRYPTION 3 -#define IEEE_CMD_MLME 4 - -#define IEEE_PARAM_WPA_ENABLED 1 -#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 -#define IEEE_PARAM_DROP_UNENCRYPTED 3 -#define IEEE_PARAM_PRIVACY_INVOKED 4 -#define IEEE_PARAM_AUTH_ALGS 5 -#define IEEE_PARAM_IEEE_802_1X 6 -//It should consistent with the driver_XXX.c -// David, 2006.9.26 -#define IEEE_PARAM_WPAX_SELECT 7 -//Added for notify the encryption type selection -// David, 2006.9.26 -#define IEEE_PROTO_WPA 1 -#define IEEE_PROTO_RSN 2 -//Added for notify the encryption type selection -// David, 2006.9.26 -#define IEEE_WPAX_USEGROUP 0 -#define IEEE_WPAX_WEP40 1 -#define IEEE_WPAX_TKIP 2 -#define IEEE_WPAX_WRAP 3 -#define IEEE_WPAX_CCMP 4 -#define IEEE_WPAX_WEP104 5 - -#define IEEE_KEY_MGMT_IEEE8021X 1 -#define IEEE_KEY_MGMT_PSK 2 - -#define IEEE_MLME_STA_DEAUTH 1 -#define IEEE_MLME_STA_DISASSOC 2 - - -#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 -#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 -#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 -#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 -#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 -#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 - - -#define IEEE_CRYPT_ALG_NAME_LEN 16 - -#define MAX_IE_LEN 0xff - -// added for kernel conflict -#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl -#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl -#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl -#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl -#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl -#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl - -#define ieee80211_ccmp_null ieee80211_ccmp_null_rsl - -#define ieee80211_tkip_null ieee80211_tkip_null_rsl - -#define ieee80211_wep_null ieee80211_wep_null_rsl - -#define free_ieee80211 free_ieee80211_rsl -#define alloc_ieee80211 alloc_ieee80211_rsl - -#define ieee80211_rx ieee80211_rx_rsl -#define ieee80211_rx_mgt ieee80211_rx_mgt_rsl - -#define ieee80211_get_beacon ieee80211_get_beacon_rsl -#define ieee80211_rtl_wake_queue ieee80211_rtl_wake_queue_rsl -#define ieee80211_rtl_stop_queue ieee80211_rtl_stop_queue_rsl -#define ieee80211_reset_queue ieee80211_reset_queue_rsl -#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl -#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl -#define ieee80211_is_shortslot ieee80211_is_shortslot_rsl -#define ieee80211_is_54g ieee80211_is_54g_rsl -#define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl -#define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl -#define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl -#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl -#define notify_wx_assoc_event notify_wx_assoc_event_rsl -#define SendDisassociation SendDisassociation_rsl -#define ieee80211_disassociate ieee80211_disassociate_rsl -#define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl -#define ieee80211_stop_scan ieee80211_stop_scan_rsl -#define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl -#define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl -#define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl - -#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl -#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl -#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl -#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl -#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl -#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl -#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl -#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl -#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl -#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl -#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl -#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl -#define ieee80211_wx_get_name ieee80211_wx_get_name_rsl -#define ieee80211_wx_set_power ieee80211_wx_set_power_rsl -#define ieee80211_wx_get_power ieee80211_wx_get_power_rsl -#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl -#define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl -#define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl - -#define ieee80211_txb_free ieee80211_txb_free_rsl - -#define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl -#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl -#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl -#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl -#define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl -#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl -#define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl -#define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl - - -typedef struct ieee_param { - u32 cmd; - u8 sta_addr[ETH_ALEN]; - union { - struct { - u8 name; - u32 value; - } wpa_param; - struct { - u32 len; - u8 reserved[32]; - u8 data[0]; - } wpa_ie; - struct{ - int command; - int reason_code; - } mlme; - struct { - u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; - u8 set_tx; - u32 err; - u8 idx; - u8 seq[8]; /* sequence counter (set: RX, get: TX) */ - u16 key_len; - u8 key[0]; - } crypt; - } u; -}ieee_param; - - -// linux under 2.6.9 release may not support it, so modify it for common use -#define MSECS(t) msecs_to_jiffies(t) -#define msleep_interruptible_rsl msleep_interruptible - -#define IEEE80211_DATA_LEN 2304 -/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section - 6.2.1.1.2. - - The figure in section 7.1.2 suggests a body size of up to 2312 - bytes is allowed, which is a bit confusing, I suspect this - represents the 2304 bytes of real data, plus a possible 8 bytes of - WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ -#define IEEE80211_1ADDR_LEN 10 -#define IEEE80211_2ADDR_LEN 16 -#define IEEE80211_3ADDR_LEN 24 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_FCS_LEN 4 -#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) -#define IEEE80211_MGMT_HDR_LEN 24 -#define IEEE80211_DATA_HDR3_LEN 24 -#define IEEE80211_DATA_HDR4_LEN 30 - -#define MIN_FRAG_THRESHOLD 256U -#define MAX_FRAG_THRESHOLD 2346U - - -/* Frame control field constants */ -#define IEEE80211_FCTL_VERS 0x0003 -#define IEEE80211_FCTL_FTYPE 0x000c -#define IEEE80211_FCTL_STYPE 0x00f0 -#define IEEE80211_FCTL_FRAMETYPE 0x00fc -#define IEEE80211_FCTL_TODS 0x0100 -#define IEEE80211_FCTL_FROMDS 0x0200 -#define IEEE80211_FCTL_DSTODS 0x0300 //added by david -#define IEEE80211_FCTL_MOREFRAGS 0x0400 -#define IEEE80211_FCTL_RETRY 0x0800 -#define IEEE80211_FCTL_PM 0x1000 -#define IEEE80211_FCTL_MOREDATA 0x2000 -#define IEEE80211_FCTL_WEP 0x4000 -#define IEEE80211_FCTL_ORDER 0x8000 - -#define IEEE80211_FTYPE_MGMT 0x0000 -#define IEEE80211_FTYPE_CTL 0x0004 -#define IEEE80211_FTYPE_DATA 0x0008 - -/* management */ -#define IEEE80211_STYPE_ASSOC_REQ 0x0000 -#define IEEE80211_STYPE_ASSOC_RESP 0x0010 -#define IEEE80211_STYPE_REASSOC_REQ 0x0020 -#define IEEE80211_STYPE_REASSOC_RESP 0x0030 -#define IEEE80211_STYPE_PROBE_REQ 0x0040 -#define IEEE80211_STYPE_PROBE_RESP 0x0050 -#define IEEE80211_STYPE_BEACON 0x0080 -#define IEEE80211_STYPE_ATIM 0x0090 -#define IEEE80211_STYPE_DISASSOC 0x00A0 -#define IEEE80211_STYPE_AUTH 0x00B0 -#define IEEE80211_STYPE_DEAUTH 0x00C0 -#define IEEE80211_STYPE_MANAGE_ACT 0x00D0 - -/* control */ -#define IEEE80211_STYPE_PSPOLL 0x00A0 -#define IEEE80211_STYPE_RTS 0x00B0 -#define IEEE80211_STYPE_CTS 0x00C0 -#define IEEE80211_STYPE_ACK 0x00D0 -#define IEEE80211_STYPE_CFEND 0x00E0 -#define IEEE80211_STYPE_CFENDACK 0x00F0 -#define IEEE80211_STYPE_BLOCKACK 0x0094 - -/* data */ -#define IEEE80211_STYPE_DATA 0x0000 -#define IEEE80211_STYPE_DATA_CFACK 0x0010 -#define IEEE80211_STYPE_DATA_CFPOLL 0x0020 -#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 -#define IEEE80211_STYPE_NULLFUNC 0x0040 -#define IEEE80211_STYPE_CFACK 0x0050 -#define IEEE80211_STYPE_CFPOLL 0x0060 -#define IEEE80211_STYPE_CFACKPOLL 0x0070 -#define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2 -#define IEEE80211_STYPE_QOS_NULL 0x00C0 - -#define IEEE80211_SCTL_FRAG 0x000F -#define IEEE80211_SCTL_SEQ 0xFFF0 - -/* QOS control */ -#define IEEE80211_QCTL_TID 0x000F - -#define FC_QOS_BIT BIT7 -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) -//added by wb. Is this right? -#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16*)pframe&IEEE80211_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) -#define SN_EQUAL(a, b) (a == b) -#define MAX_DEV_ADDR_SIZE 8 -typedef enum _ACT_CATEGORY{ - ACT_CAT_QOS = 1, - ACT_CAT_DLS = 2, - ACT_CAT_BA = 3, - ACT_CAT_HT = 7, - ACT_CAT_WMM = 17, -} ACT_CATEGORY, *PACT_CATEGORY; - -typedef enum _TS_ACTION{ - ACT_ADDTSREQ = 0, - ACT_ADDTSRSP = 1, - ACT_DELTS = 2, - ACT_SCHEDULE = 3, -} TS_ACTION, *PTS_ACTION; - -typedef enum _BA_ACTION{ - ACT_ADDBAREQ = 0, - ACT_ADDBARSP = 1, - ACT_DELBA = 2, -} BA_ACTION, *PBA_ACTION; - -typedef enum _InitialGainOpType{ - IG_Backup=0, - IG_Restore, - IG_Max -}InitialGainOpType; - -/* debug macros */ -#define CONFIG_IEEE80211_DEBUG -#ifdef CONFIG_IEEE80211_DEBUG -extern u32 ieee80211_debug_level; -#define IEEE80211_DEBUG(level, fmt, args...) \ -do { if (ieee80211_debug_level & (level)) \ - printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0) -//wb added to debug out data buf -//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA -#define IEEE80211_DEBUG_DATA(level, data, datalen) \ - do{ if ((ieee80211_debug_level & (level)) == (level)) \ - { \ - int i; \ - u8* pdata = (u8*) data; \ - printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \ - for(i=0; i<(int)(datalen); i++) \ - { \ - printk("%2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) -#else -#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) -#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0) -#endif /* CONFIG_IEEE80211_DEBUG */ - -/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ - -/* - * To use the debug system; - * - * If you are defining a new debug classification, simply add it to the #define - * list here in the form of: - * - * #define IEEE80211_DL_xxxx VALUE - * - * shifting value to the left one bit from the previous entry. xxxx should be - * the name of the classification (for example, WEP) - * - * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your - * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want - * to send output to that classification. - * - * To add your debug level to the list of levels seen when you perform - * - * % cat /proc/net/ipw/debug_level - * - * you simply need to add your entry to the ipw_debug_levels array. - * - * If you do not see debug_level in /proc/net/ipw then you do not have - * CONFIG_IEEE80211_DEBUG defined in your kernel configuration - * - */ - -#define IEEE80211_DL_INFO (1<<0) -#define IEEE80211_DL_WX (1<<1) -#define IEEE80211_DL_SCAN (1<<2) -#define IEEE80211_DL_STATE (1<<3) -#define IEEE80211_DL_MGMT (1<<4) -#define IEEE80211_DL_FRAG (1<<5) -#define IEEE80211_DL_EAP (1<<6) -#define IEEE80211_DL_DROP (1<<7) - -#define IEEE80211_DL_TX (1<<8) -#define IEEE80211_DL_RX (1<<9) - -#define IEEE80211_DL_HT (1<<10) //HT -#define IEEE80211_DL_BA (1<<11) //ba -#define IEEE80211_DL_TS (1<<12) //TS -#define IEEE80211_DL_QOS (1<<13) -#define IEEE80211_DL_REORDER (1<<14) -#define IEEE80211_DL_IOT (1<<15) -#define IEEE80211_DL_IPS (1<<16) -#define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen -#define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out. -#define IEEE80211_DL_ERR (1<<31) //always open -#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) -#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) -#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a) - -#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a) -#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a) -#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a) -#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a) -#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a) -#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a) -#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) -#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) -#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) -#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a) - -#ifdef CONFIG_IEEE80211_DEBUG -/* Added by Annie, 2005-11-22. */ -#define MAX_STR_LEN 64 -/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ -#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') -#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if((_Comp) & level) \ - { \ - int __i; \ - u8 buffer[MAX_STR_LEN]; \ - int length = (_Len\n", _Len, buffer); \ - } -#else -#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0) -#endif - -#include -#include /* ARPHRD_ETHER */ - -#ifndef WIRELESS_SPY -#define WIRELESS_SPY // enable iwspy support -#endif -#include // new driver API - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ - -#ifndef ETH_P_80211_RAW -#define ETH_P_80211_RAW (ETH_P_ECONET + 1) -#endif - -/* IEEE 802.11 defines */ - -#define P80211_OUI_LEN 3 - -struct ieee80211_snap_hdr { - - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ - -} __attribute__ ((packed)); - -#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) - -#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) -#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) -#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) -#define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA) - - -#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE) -#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) -#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) - -/* Authentication algorithms */ -#define WLAN_AUTH_OPEN 0 -#define WLAN_AUTH_SHARED_KEY 1 -#define WLAN_AUTH_LEAP 2 - -#define WLAN_AUTH_CHALLENGE_LEN 128 - -#define WLAN_CAPABILITY_BSS (1<<0) -#define WLAN_CAPABILITY_IBSS (1<<1) -#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) -#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) -#define WLAN_CAPABILITY_PRIVACY (1<<4) -#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) -#define WLAN_CAPABILITY_PBCC (1<<6) -#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) -#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) -#define WLAN_CAPABILITY_QOS (1<<9) -#define WLAN_CAPABILITY_SHORT_SLOT (1<<10) -#define WLAN_CAPABILITY_DSSS_OFDM (1<<13) - -/* 802.11g ERP information element */ -#define WLAN_ERP_NON_ERP_PRESENT (1<<0) -#define WLAN_ERP_USE_PROTECTION (1<<1) -#define WLAN_ERP_BARKER_PREAMBLE (1<<2) - -/* Status codes */ -enum ieee80211_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, -}; - -/* Reason codes */ -enum ieee80211_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, -}; - -#define IEEE80211_STATMASK_SIGNAL (1<<0) -#define IEEE80211_STATMASK_RSSI (1<<1) -#define IEEE80211_STATMASK_NOISE (1<<2) -#define IEEE80211_STATMASK_RATE (1<<3) -#define IEEE80211_STATMASK_WEMASK 0x7 - -#define IEEE80211_CCK_MODULATION (1<<0) -#define IEEE80211_OFDM_MODULATION (1<<1) - -#define IEEE80211_24GHZ_BAND (1<<0) -#define IEEE80211_52GHZ_BAND (1<<1) - -#define IEEE80211_CCK_RATE_LEN 4 -#define IEEE80211_CCK_RATE_1MB 0x02 -#define IEEE80211_CCK_RATE_2MB 0x04 -#define IEEE80211_CCK_RATE_5MB 0x0B -#define IEEE80211_CCK_RATE_11MB 0x16 -#define IEEE80211_OFDM_RATE_LEN 8 -#define IEEE80211_OFDM_RATE_6MB 0x0C -#define IEEE80211_OFDM_RATE_9MB 0x12 -#define IEEE80211_OFDM_RATE_12MB 0x18 -#define IEEE80211_OFDM_RATE_18MB 0x24 -#define IEEE80211_OFDM_RATE_24MB 0x30 -#define IEEE80211_OFDM_RATE_36MB 0x48 -#define IEEE80211_OFDM_RATE_48MB 0x60 -#define IEEE80211_OFDM_RATE_54MB 0x6C -#define IEEE80211_BASIC_RATE_MASK 0x80 - -#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) -#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) -#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) -#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) -#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) -#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) -#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) -#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) -#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) -#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) -#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) -#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) - -#define IEEE80211_CCK_RATES_MASK 0x0000000F -#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ - IEEE80211_CCK_RATE_2MB_MASK) -#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ - IEEE80211_CCK_RATE_5MB_MASK | \ - IEEE80211_CCK_RATE_11MB_MASK) - -#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 -#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ - IEEE80211_OFDM_RATE_12MB_MASK | \ - IEEE80211_OFDM_RATE_24MB_MASK) -#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ - IEEE80211_OFDM_RATE_9MB_MASK | \ - IEEE80211_OFDM_RATE_18MB_MASK | \ - IEEE80211_OFDM_RATE_36MB_MASK | \ - IEEE80211_OFDM_RATE_48MB_MASK | \ - IEEE80211_OFDM_RATE_54MB_MASK) -#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ - IEEE80211_CCK_DEFAULT_RATES_MASK) - -#define IEEE80211_NUM_OFDM_RATES 8 -#define IEEE80211_NUM_CCK_RATES 4 -#define IEEE80211_OFDM_SHIFT_MASK_A 4 - - -/* this is stolen and modified from the madwifi driver*/ -#define IEEE80211_FC0_TYPE_MASK 0x0c -#define IEEE80211_FC0_TYPE_DATA 0x08 -#define IEEE80211_FC0_SUBTYPE_MASK 0xB0 -#define IEEE80211_FC0_SUBTYPE_QOS 0x80 - -#define IEEE80211_QOS_HAS_SEQ(fc) \ - (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \ - (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS)) - -/* this is stolen from ipw2200 driver */ -#define IEEE_IBSS_MAC_HASH_SIZE 31 -struct ieee_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num[17]; - u16 frag_num[17]; - unsigned long packet_time[17]; - struct list_head list; -}; - -/* NOTE: This data is for statistical purposes; not all hardware provides this - * information for frames received. Not setting these will not cause - * any adverse affects. */ -struct ieee80211_rx_stats { - u32 mac_time[2]; - s8 rssi; - u8 signal; - u8 noise; - u16 rate; /* in 100 kbps */ - u8 received_channel; - u8 control; - u8 mask; - u8 freq; - u16 len; - u64 tsf; - u32 beacon_time; - u8 nic_type; - u16 Length; - u8 SignalQuality; // in 0-100 index. - s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation. - s8 RxPower; // in dBm Translate from PWdB - u8 SignalStrength; // in 0-100 index. - u16 bHwError:1; - u16 bCRC:1; - u16 bICV:1; - u16 bShortPreamble:1; - u16 Antenna:1; //for rtl8185 - u16 Decrypted:1; //for rtl8185, rtl8187 - u16 Wakeup:1; //for rtl8185 - u16 Reserved0:1; //for rtl8185 - u8 AGC; - u32 TimeStampLow; - u32 TimeStampHigh; - bool bShift; - bool bIsQosData; // Added by Annie, 2005-12-22. - u8 UserPriority; - - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! - //1Attention Please!!!<11n or 8190 specific code should be put below this line> - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! - - u8 RxDrvInfoSize; - u8 RxBufShift; - bool bIsAMPDU; - bool bFirstMPDU; - bool bContainHTC; - u32 RxPWDBAll; - u8 RxMIMOSignalStrength[4]; // in 0~100 index - s8 RxMIMOSignalQuality[2]; - bool bPacketMatchBSSID; - bool bIsCCK; - bool bPacketToSelf; - u8* virtual_address; - bool bPacketBeacon; //cosa add for rssi - bool bToSelfBA; //cosa add for rssi - char cck_adc_pwdb[4]; //cosa add for rx path selection -}; - -/* IEEE 802.11 requires that STA supports concurrent reception of at least - * three fragmented frames. This define can be increased to support more - * concurrent frames, but it should be noted that each entry can consume about - * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ -#define IEEE80211_FRAG_CACHE_LEN 4 - -struct ieee80211_frag_entry { - unsigned long first_frag_time; - unsigned int seq; - unsigned int last_frag; - struct sk_buff *skb; - u8 src_addr[ETH_ALEN]; - u8 dst_addr[ETH_ALEN]; -}; - -struct ieee80211_stats { - unsigned int tx_unicast_frames; - unsigned int tx_multicast_frames; - unsigned int tx_fragments; - unsigned int tx_unicast_octets; - unsigned int tx_multicast_octets; - unsigned int tx_deferred_transmissions; - unsigned int tx_single_retry_frames; - unsigned int tx_multiple_retry_frames; - unsigned int tx_retry_limit_exceeded; - unsigned int tx_discards; - unsigned int rx_unicast_frames; - unsigned int rx_multicast_frames; - unsigned int rx_fragments; - unsigned int rx_unicast_octets; - unsigned int rx_multicast_octets; - unsigned int rx_fcs_errors; - unsigned int rx_discards_no_buffer; - unsigned int tx_discards_wrong_sa; - unsigned int rx_discards_undecryptable; - unsigned int rx_message_in_msg_fragments; - unsigned int rx_message_in_bad_msg_fragments; -}; - -struct ieee80211_device; - -#include "ieee80211_crypt.h" - -#define SEC_KEY_1 (1<<0) -#define SEC_KEY_2 (1<<1) -#define SEC_KEY_3 (1<<2) -#define SEC_KEY_4 (1<<3) -#define SEC_ACTIVE_KEY (1<<4) -#define SEC_AUTH_MODE (1<<5) -#define SEC_UNICAST_GROUP (1<<6) -#define SEC_LEVEL (1<<7) -#define SEC_ENABLED (1<<8) -#define SEC_ENCRYPT (1<<9) - -#define SEC_LEVEL_0 0 /* None */ -#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ -#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ -#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ -#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ - -#define SEC_ALG_NONE 0 -#define SEC_ALG_WEP 1 -#define SEC_ALG_TKIP 2 -#define SEC_ALG_CCMP 4 - -#define WEP_KEYS 4 -#define WEP_KEY_LEN 13 -#define SCM_KEY_LEN 32 -#define SCM_TEMPORAL_KEY_LENGTH 16 - -struct ieee80211_security { - u16 active_key:2, - enabled:1, - auth_mode:2, - auth_algo:4, - unicast_uses_group:1, - encrypt:1; - u8 key_sizes[WEP_KEYS]; - u8 keys[WEP_KEYS][SCM_KEY_LEN]; - u8 level; - u16 flags; -} __attribute__ ((packed)); - - -/* - 802.11 data frame from AP - ,-------------------------------------------------------------------. -Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | - |------|------|---------|---------|---------|------|---------|------| -Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `-------------------------------------------------------------------' -Total: 28-2340 bytes -*/ - -/* Management Frame Information Element Types */ -enum ieee80211_mfie { - MFIE_TYPE_SSID = 0, - MFIE_TYPE_RATES = 1, - MFIE_TYPE_FH_SET = 2, - MFIE_TYPE_DS_SET = 3, - MFIE_TYPE_CF_SET = 4, - MFIE_TYPE_TIM = 5, - MFIE_TYPE_IBSS_SET = 6, - MFIE_TYPE_COUNTRY = 7, - MFIE_TYPE_HOP_PARAMS = 8, - MFIE_TYPE_HOP_TABLE = 9, - MFIE_TYPE_REQUEST = 10, - MFIE_TYPE_CHALLENGE = 16, - MFIE_TYPE_POWER_CONSTRAINT = 32, - MFIE_TYPE_POWER_CAPABILITY = 33, - MFIE_TYPE_TPC_REQUEST = 34, - MFIE_TYPE_TPC_REPORT = 35, - MFIE_TYPE_SUPP_CHANNELS = 36, - MFIE_TYPE_CSA = 37, - MFIE_TYPE_MEASURE_REQUEST = 38, - MFIE_TYPE_MEASURE_REPORT = 39, - MFIE_TYPE_QUIET = 40, - MFIE_TYPE_IBSS_DFS = 41, - MFIE_TYPE_ERP = 42, - MFIE_TYPE_RSN = 48, - MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_CAP= 45, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, - MFIE_TYPE_GENERIC = 221, - MFIE_TYPE_QOS_PARAMETER = 222, -}; - -/* Minimal header; can be used for passing 802.11 frames with sufficient - * information to determine what type of underlying data type is actually - * stored in the data. */ - struct ieee80211_pspoll_hdr { - __le16 frame_ctl; - __le16 aid; - u8 bssid[ETH_ALEN]; - u8 ta[ETH_ALEN]; - //u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr { - __le16 frame_ctl; - __le16 duration_id; - u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr_1addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr_2addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr_3addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr_4addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 addr4[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); - -struct ieee80211_hdr_3addrqos { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 payload[0]; - __le16 qos_ctl; -} __attribute__ ((packed)); - -struct ieee80211_hdr_4addrqos { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 addr4[ETH_ALEN]; - u8 payload[0]; - __le16 qos_ctl; -} __attribute__ ((packed)); - -struct ieee80211_info_element { - u8 id; - u8 len; - u8 data[0]; -} __attribute__ ((packed)); - -struct ieee80211_authentication { - struct ieee80211_hdr_3addr header; - __le16 algorithm; - __le16 transaction; - __le16 status; - /*challenge*/ - struct ieee80211_info_element info_element[0]; -} __attribute__ ((packed)); - -struct ieee80211_disassoc { - struct ieee80211_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); - -struct ieee80211_probe_request { - struct ieee80211_hdr_3addr header; - /* SSID, supported rates */ - struct ieee80211_info_element info_element[0]; -} __attribute__ ((packed)); - -struct ieee80211_probe_response { - struct ieee80211_hdr_3addr header; - u32 time_stamp[2]; - __le16 beacon_interval; - __le16 capability; - /* SSID, supported rates, FH params, DS params, - * CF params, IBSS params, TIM (if beacon), RSN */ - struct ieee80211_info_element info_element[0]; -} __attribute__ ((packed)); - -/* Alias beacon for probe_response */ -#define ieee80211_beacon ieee80211_probe_response - -struct ieee80211_assoc_request_frame { - struct ieee80211_hdr_3addr header; - __le16 capability; - __le16 listen_interval; - /* SSID, supported rates, RSN */ - struct ieee80211_info_element info_element[0]; -} __attribute__ ((packed)); - -struct ieee80211_reassoc_request_frame { - struct ieee80211_hdr_3addr header; - __le16 capability; - __le16 listen_interval; - u8 current_ap[ETH_ALEN]; - /* SSID, supported rates, RSN */ - struct ieee80211_info_element info_element[0]; -} __attribute__ ((packed)); - -struct ieee80211_assoc_response_frame { - struct ieee80211_hdr_3addr header; - __le16 capability; - __le16 status; - __le16 aid; - struct ieee80211_info_element info_element[0]; /* supported rates */ -} __attribute__ ((packed)); - -struct ieee80211_txb { - u8 nr_frags; - u8 encrypted; - u8 queue_index; - u8 rts_included; - u16 reserved; - __le16 frag_size; - __le16 payload_size; - struct sk_buff *fragments[0]; -}; - -#define MAX_TX_AGG_COUNT 16 -struct ieee80211_drv_agg_txb { - u8 nr_drv_agg_frames; - struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -}__attribute__((packed)); - -#define MAX_SUBFRAME_COUNT 64 -struct ieee80211_rxb { - u8 nr_subframes; - struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; -}__attribute__((packed)); - -typedef union _frameqos { - u16 shortdata; - u8 chardata[2]; - struct { - u16 tid:4; - u16 eosp:1; - u16 ack_policy:2; - u16 reserved:1; - u16 txop:8; - }field; -}frameqos,*pframeqos; - -/* SWEEP TABLE ENTRIES NUMBER*/ -#define MAX_SWEEP_TAB_ENTRIES 42 -#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 -/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs - * only use 8, and then use extended rates for the remaining supported - * rates. Other APs, however, stick all of their supported rates on the - * main rates information element... */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 128 - -#define MAX_CHANNEL_NUMBER 161 -#define IEEE80211_SOFTMAC_SCAN_TIME 100 -//(HZ / 2) -#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) - -#define CRC_LENGTH 4U - -#define MAX_WPA_IE_LEN 64 - -#define NETWORK_EMPTY_ESSID (1<<0) -#define NETWORK_HAS_OFDM (1<<1) -#define NETWORK_HAS_CCK (1<<2) - -/* QoS structure */ -#define NETWORK_HAS_QOS_PARAMETERS (1<<3) -#define NETWORK_HAS_QOS_INFORMATION (1<<4) -#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ - NETWORK_HAS_QOS_INFORMATION) -/* 802.11h */ -#define NETWORK_HAS_POWER_CONSTRAINT (1<<5) -#define NETWORK_HAS_CSA (1<<6) -#define NETWORK_HAS_QUIET (1<<7) -#define NETWORK_HAS_IBSS_DFS (1<<8) -#define NETWORK_HAS_TPC_REPORT (1<<9) - -#define NETWORK_HAS_ERP_VALUE (1<<10) - -#define QOS_QUEUE_NUM 4 -#define QOS_OUI_LEN 3 -#define QOS_OUI_TYPE 2 -#define QOS_ELEMENT_ID 221 -#define QOS_OUI_INFO_SUB_TYPE 0 -#define QOS_OUI_PARAM_SUB_TYPE 1 -#define QOS_VERSION_1 1 -#define QOS_AIFSN_MIN_VALUE 2 - -struct ieee80211_qos_information_element { - u8 elementID; - u8 length; - u8 qui[QOS_OUI_LEN]; - u8 qui_type; - u8 qui_subtype; - u8 version; - u8 ac_info; -} __attribute__ ((packed)); - -struct ieee80211_qos_ac_parameter { - u8 aci_aifsn; - u8 ecw_min_max; - __le16 tx_op_limit; -} __attribute__ ((packed)); - -struct ieee80211_qos_parameter_info { - struct ieee80211_qos_information_element info_element; - u8 reserved; - struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); - -struct ieee80211_qos_parameters { - __le16 cw_min[QOS_QUEUE_NUM]; - __le16 cw_max[QOS_QUEUE_NUM]; - u8 aifs[QOS_QUEUE_NUM]; - u8 flag[QOS_QUEUE_NUM]; - __le16 tx_op_limit[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); - -struct ieee80211_qos_data { - struct ieee80211_qos_parameters parameters; - int active; - int supported; - u8 param_count; - u8 old_param_count; -}; - -struct ieee80211_tim_parameters { - u8 tim_count; - u8 tim_period; -} __attribute__ ((packed)); - -//#else -struct ieee80211_wmm_ac_param { - u8 ac_aci_acm_aifsn; - u8 ac_ecwmin_ecwmax; - u16 ac_txop_limit; -}; - -struct ieee80211_wmm_ts_info { - u8 ac_dir_tid; - u8 ac_up_psb; - u8 reserved; -} __attribute__ ((packed)); - -struct ieee80211_wmm_tspec_elem { - struct ieee80211_wmm_ts_info ts_info; - u16 norm_msdu_size; - u16 max_msdu_size; - u32 min_serv_inter; - u32 max_serv_inter; - u32 inact_inter; - u32 suspen_inter; - u32 serv_start_time; - u32 min_data_rate; - u32 mean_data_rate; - u32 peak_data_rate; - u32 max_burst_size; - u32 delay_bound; - u32 min_phy_rate; - u16 surp_band_allow; - u16 medium_time; -}__attribute__((packed)); - -enum eap_type { - EAP_PACKET = 0, - EAPOL_START, - EAPOL_LOGOFF, - EAPOL_KEY, - EAPOL_ENCAP_ASF_ALERT -}; - -static const char *eap_types[] = { - [EAP_PACKET] = "EAP-Packet", - [EAPOL_START] = "EAPOL-Start", - [EAPOL_LOGOFF] = "EAPOL-Logoff", - [EAPOL_KEY] = "EAPOL-Key", - [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert" -}; - -static inline const char *eap_get_type(int type) -{ - return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; -} -//added by amy for reorder -static inline u8 Frame_QoSTID(u8* buf) -{ - struct ieee80211_hdr_3addr *hdr; - u16 fc; - hdr = (struct ieee80211_hdr_3addr *)buf; - fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((frameqos*)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; -} - -//added by amy for reorder - -struct eapol { - u8 snap[6]; - u16 ethertype; - u8 version; - u8 type; - u16 length; -} __attribute__ ((packed)); - -struct ieee80211_softmac_stats{ - unsigned int rx_ass_ok; - unsigned int rx_ass_err; - unsigned int rx_probe_rq; - unsigned int tx_probe_rs; - unsigned int tx_beacons; - unsigned int rx_auth_rq; - unsigned int rx_auth_rs_ok; - unsigned int rx_auth_rs_err; - unsigned int tx_auth_rq; - unsigned int no_auth_rs; - unsigned int no_ass_rs; - unsigned int tx_ass_rq; - unsigned int rx_ass_rq; - unsigned int tx_probe_rq; - unsigned int reassoc; - unsigned int swtxstop; - unsigned int swtxawake; - unsigned char CurrentShowTxate; - unsigned char last_packet_rate; - unsigned int txretrycount; -}; - -#define BEACON_PROBE_SSID_ID_POSITION 12 - -struct ieee80211_info_element_hdr { - u8 id; - u8 len; -} __attribute__ ((packed)); - -/* - * These are the data types that can make up management packets - * - u16 auth_algorithm; - u16 auth_sequence; - u16 beacon_interval; - u16 capability; - u8 current_ap[ETH_ALEN]; - u16 listen_interval; - struct { - u16 association_id:14, reserved:2; - } __attribute__ ((packed)); - u32 time_stamp[2]; - u16 reason; - u16 status; -*/ - -#define IEEE80211_DEFAULT_TX_ESSID "Penguin" -#define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps - -enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; -#define MAX_SP_Len (WMM_all_frame << 4) -#define IEEE80211_QOS_TID 0x0f -#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5) - -#define IEEE80211_DTIM_MBCAST 4 -#define IEEE80211_DTIM_UCAST 2 -#define IEEE80211_DTIM_VALID 1 -#define IEEE80211_DTIM_INVALID 0 - -#define IEEE80211_PS_DISABLED 0 -#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST -#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST - -//added by David for QoS 2006/6/30 -//#define WMM_Hang_8187 -#ifdef WMM_Hang_8187 -#undef WMM_Hang_8187 -#endif - -#define WME_AC_BK 0x00 -#define WME_AC_BE 0x01 -#define WME_AC_VI 0x02 -#define WME_AC_VO 0x03 -#define WME_ACI_MASK 0x03 -#define WME_AIFSN_MASK 0x03 -#define WME_AC_PRAM_LEN 16 - -#define MAX_RECEIVE_BUFFER_SIZE 9100 - -//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP -#define UP2AC(up) ( \ - ((up) < 1) ? WME_AC_BE : \ - ((up) < 3) ? WME_AC_BK : \ - ((up) < 4) ? WME_AC_BE : \ - ((up) < 6) ? WME_AC_VI : \ - WME_AC_VO) - -//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue -#define AC2UP(_ac) ( \ - ((_ac) == WME_AC_VO) ? 6 : \ - ((_ac) == WME_AC_VI) ? 5 : \ - ((_ac) == WME_AC_BK) ? 1 : \ - 0) - -#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ -#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/ - -struct ether_header { - u8 ether_dhost[ETHER_ADDR_LEN]; - u8 ether_shost[ETHER_ADDR_LEN]; - u16 ether_type; -} __attribute__((packed)); - -#ifndef ETHERTYPE_PAE -#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ -#endif -#ifndef ETHERTYPE_IP -#define ETHERTYPE_IP 0x0800 /* IP protocol */ -#endif - -typedef struct _bss_ht{ - - bool support_ht; - - // HT related elements - u8 ht_cap_buf[32]; - u16 ht_cap_len; - u8 ht_info_buf[32]; - u16 ht_info_len; - - HT_SPEC_VER ht_spec_ver; - - bool aggregation; - bool long_slot_time; -}bss_ht, *pbss_ht; - -typedef enum _erp_t{ - ERP_NonERPpresent = 0x01, - ERP_UseProtection = 0x02, - ERP_BarkerPreambleMode = 0x04, -} erp_t; - - -struct ieee80211_network { - /* These entries are used to identify a unique network */ - u8 bssid[ETH_ALEN]; - u8 channel; - /* Ensure null-terminated for any debug msgs */ - u8 ssid[IW_ESSID_MAX_SIZE + 1]; - u8 ssid_len; - struct ieee80211_qos_data qos_data; - - //added by amy for LEAP - bool bWithAironetIE; - bool bCkipSupported; - bool bCcxRmEnable; - u16 CcxRmState[2]; - // CCXv4 S59, MBSSID. - bool bMBssidValid; - u8 MBssidMask; - u8 MBssid[6]; - // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20. - bool bWithCcxVerNum; - u8 BssCcxVerNumber; - /* These are network statistics */ - struct ieee80211_rx_stats stats; - u16 capability; - u8 rates[MAX_RATES_LENGTH]; - u8 rates_len; - u8 rates_ex[MAX_RATES_EX_LENGTH]; - u8 rates_ex_len; - unsigned long last_scanned; - u8 mode; - u32 flags; - u32 last_associate; - u32 time_stamp[2]; - u16 beacon_interval; - u16 listen_interval; - u16 atim_window; - u8 erp_value; - u8 wpa_ie[MAX_WPA_IE_LEN]; - size_t wpa_ie_len; - u8 rsn_ie[MAX_WPA_IE_LEN]; - size_t rsn_ie_len; - - struct ieee80211_tim_parameters tim; - u8 dtim_period; - u8 dtim_data; - u32 last_dtim_sta_time[2]; - - //appeded for QoS - u8 wmm_info; - struct ieee80211_wmm_ac_param wmm_param[4]; - u8 QoS_Enable; -#ifdef THOMAS_TURBO - u8 Turbo_Enable;//enable turbo mode, added by thomas -#endif -#ifdef ENABLE_DOT11D - u16 CountryIeLen; - u8 CountryIeBuf[MAX_IE_LEN]; -#endif - // HT Related, by amy, 2008.04.29 - BSS_HT bssht; - // Add to handle broadcom AP management frame CCK rate. - bool broadcom_cap_exist; - bool ralink_cap_exist; - bool atheros_cap_exist; - bool cisco_cap_exist; - bool marvell_cap_exist; - bool unknown_cap_exist; -// u8 berp_info; - bool berp_info_valid; - bool buseprotection; - //put at the end of the structure. - struct list_head list; -}; - -enum ieee80211_state { - - /* the card is not linked at all */ - IEEE80211_NOLINK = 0, - - /* IEEE80211_ASSOCIATING* are for BSS client mode - * the driver shall not perform RX filtering unless - * the state is LINKED. - * The driver shall just check for the state LINKED and - * defaults to NOLINK for ALL the other states (including - * LINKED_SCANNING) - */ - - /* the association procedure will start (wq scheduling)*/ - IEEE80211_ASSOCIATING, - IEEE80211_ASSOCIATING_RETRY, - - /* the association procedure is sending AUTH request*/ - IEEE80211_ASSOCIATING_AUTHENTICATING, - - /* the association procedure has successfully authentcated - * and is sending association request - */ - IEEE80211_ASSOCIATING_AUTHENTICATED, - - /* the link is ok. the card associated to a BSS or linked - * to a ibss cell or acting as an AP and creating the bss - */ - IEEE80211_LINKED, - - /* same as LINKED, but the driver shall apply RX filter - * rules as we are in NO_LINK mode. As the card is still - * logically linked, but it is doing a syncro site survey - * then it will be back to LINKED state. - */ - IEEE80211_LINKED_SCANNING, - -}; - -#define DEFAULT_MAX_SCAN_AGE (15 * HZ) -#define DEFAULT_FTS 2346 - -#define CFG_IEEE80211_RESERVE_FCS (1<<0) -#define CFG_IEEE80211_COMPUTE_FCS (1<<1) -#define CFG_IEEE80211_RTS (1<<2) - -#define IEEE80211_24GHZ_MIN_CHANNEL 1 -#define IEEE80211_24GHZ_MAX_CHANNEL 14 -#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \ - IEEE80211_24GHZ_MIN_CHANNEL + 1) - -#define IEEE80211_52GHZ_MIN_CHANNEL 34 -#define IEEE80211_52GHZ_MAX_CHANNEL 165 -#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \ - IEEE80211_52GHZ_MIN_CHANNEL + 1) - -typedef struct tx_pending_t{ - int frag; - struct ieee80211_txb *txb; -}tx_pending_t; - -typedef struct _bandwidth_autoswitch -{ - long threshold_20Mhzto40Mhz; - long threshold_40Mhzto20Mhz; - bool bforced_tx20Mhz; - bool bautoswitch_enable; -}bandwidth_autoswitch,*pbandwidth_autoswitch; - - -//added by amy for order - -#define REORDER_WIN_SIZE 128 -#define REORDER_ENTRY_NUM 128 -typedef struct _RX_REORDER_ENTRY -{ - struct list_head List; - u16 SeqNum; - struct ieee80211_rxb* prxb; -} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; -//added by amy for order -typedef enum _Fsync_State{ - Default_Fsync, - HW_Fsync, - SW_Fsync -}Fsync_State; - -typedef struct _IbssParms{ - u16 atimWin; -}IbssParms, *PIbssParms; -#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. - -#ifdef ENABLE_DOT11D -typedef enum -{ - COUNTRY_CODE_FCC = 0, - COUNTRY_CODE_IC = 1, - COUNTRY_CODE_ETSI = 2, - COUNTRY_CODE_SPAIN = 3, - COUNTRY_CODE_FRANCE = 4, - COUNTRY_CODE_MKK = 5, - COUNTRY_CODE_MKK1 = 6, - COUNTRY_CODE_ISRAEL = 7, - COUNTRY_CODE_TELEC, - COUNTRY_CODE_MIC, - COUNTRY_CODE_GLOBAL_DOMAIN -}country_code_type_t; -#endif - -#define RT_MAX_LD_SLOT_NUM 10 -typedef struct _RT_LINK_DETECT_T{ - - u32 NumRecvBcnInPeriod; - u32 NumRecvDataInPeriod; - - u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status - u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status - u16 SlotNum; // number of CheckForHang period to determine link status - u16 SlotIndex; - - u32 NumTxOkInPeriod; - u32 NumRxOkInPeriod; - u32 NumRxUnicastOkInPeriod; - bool bBusyTraffic; -}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; - -//added by amy 090330 -typedef enum _HW_VARIABLES{ - HW_VAR_ETHER_ADDR, - HW_VAR_MULTICAST_REG, - HW_VAR_BASIC_RATE, - HW_VAR_BSSID, - HW_VAR_MEDIA_STATUS, - HW_VAR_SECURITY_CONF, - HW_VAR_BEACON_INTERVAL, - HW_VAR_ATIM_WINDOW, - HW_VAR_LISTEN_INTERVAL, - HW_VAR_CS_COUNTER, - HW_VAR_DEFAULTKEY0, - HW_VAR_DEFAULTKEY1, - HW_VAR_DEFAULTKEY2, - HW_VAR_DEFAULTKEY3, - HW_VAR_SIFS, - HW_VAR_DIFS, - HW_VAR_EIFS, - HW_VAR_SLOT_TIME, - HW_VAR_ACK_PREAMBLE, - HW_VAR_CW_CONFIG, - HW_VAR_CW_VALUES, - HW_VAR_RATE_FALLBACK_CONTROL, - HW_VAR_CONTENTION_WINDOW, - HW_VAR_RETRY_COUNT, - HW_VAR_TR_SWITCH, - HW_VAR_COMMAND, // For Command Register, Annie, 2006-04-07. - HW_VAR_WPA_CONFIG, //2004/08/23, kcwu, for 8187 Security config - HW_VAR_AMPDU_MIN_SPACE, // The spacing between sub-frame. Roger, 2008.07.04. - HW_VAR_SHORTGI_DENSITY, // The density for shortGI. Roger, 2008.07.04. - HW_VAR_AMPDU_FACTOR, - HW_VAR_MCS_RATE_AVAILABLE, - HW_VAR_AC_PARAM, // For AC Parameters, 2005.12.01, by rcnjko. - HW_VAR_ACM_CTRL, // For ACM Control, Annie, 2005-12-13. - HW_VAR_DIS_Req_Qsize, // For DIS_Reg_Qsize, Joseph - HW_VAR_CCX_CHNL_LOAD, // For CCX 2 channel load request, 2006.05.04. - HW_VAR_CCX_NOISE_HISTOGRAM, // For CCX 2 noise histogram request, 2006.05.04. - HW_VAR_CCX_CLM_NHM, // For CCX 2 parallel channel load request and noise histogram request, 2006.05.12. - HW_VAR_TxOPLimit, // For turbo mode related settings, added by Roger, 2006.12.07 - HW_VAR_TURBO_MODE, // For turbo mode related settings, added by Roger, 2006.12.15. - HW_VAR_RF_STATE, // For change or query RF power state, 061214, rcnjko. - HW_VAR_RF_OFF_BY_HW, // For UI to query if external HW signal disable RF, 061229, rcnjko. - HW_VAR_BUS_SPEED, // In unit of bps. 2006.07.03, by rcnjko. - HW_VAR_SET_DEV_POWER, // Set to low power, added by LanHsin, 2007. - - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! - //1Attention Please!!!<11n or 8190 specific code should be put below this line> - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! - HW_VAR_RCR, //for RCR, David 2006,05,11 - HW_VAR_RATR_0, - HW_VAR_RRSR, - HW_VAR_CPU_RST, - HW_VAR_CHECK_BSSID, - HW_VAR_LBK_MODE, // Set lookback mode, 2008.06.11. added by Roger. - // Set HW related setting for 11N AES bug. - HW_VAR_AES_11N_FIX, - // Set Usb Rx Aggregation - HW_VAR_USB_RX_AGGR, - HW_VAR_USER_CONTROL_TURBO_MODE, - HW_VAR_RETRY_LIMIT, -#ifndef _RTL8192_EXT_PATCH_ - HW_VAR_INIT_TX_RATE, //Get Current Tx rate register. 2008.12.10. Added by tynli -#endif - HW_VAR_TX_RATE_REG, //Get Current Tx rate register. 2008.12.10. Added by tynli - HW_VAR_EFUSE_USAGE, //Get current EFUSE utilization. 2008.12.19. Added by Roger. - HW_VAR_EFUSE_BYTES, - HW_VAR_AUTOLOAD_STATUS, //Get current autoload status, 0: autoload success, 1: autoload fail. 2008.12.19. Added by Roger. - HW_VAR_RF_2R_DISABLE, // 2R disable - HW_VAR_SET_RPWM, - HW_VAR_H2C_FW_PWRMODE, // For setting FW related H2C cmd structure. by tynli. 2009.2.18 - HW_VAR_H2C_FW_JOINBSSRPT, // For setting FW related H2C cmd structure. by tynli. 2009.2.18 - HW_VAR_1X1_RECV_COMBINE, // For 1T2R but only 1SS, Add by hpfan 2009.04.16 hpfan - HW_VAR_STOP_SEND_BEACON, - HW_VAR_TSF_TIMER, // Read from TSF register to get the current TSF timer, by Bruce, 2009-07-22. - HW_VAR_IO_CMD, - HW_VAR_HANDLE_FW_C2H, //Added by tynli. For handling FW C2H command. 2009.10.07. - HW_VAR_DL_FW_RSVD_PAGE, //Added by tynli. Download the packets that FW will use to RSVD page. 2009.10.14. - HW_VAR_AID, //Added by tynli. - HW_VAR_HW_SEQ_ENABLE, //Added by tynli. 2009.10.20. - HW_VAR_UPDATE_TSF, //Added by tynli. 2009.10.22. For Hw count TBTT time. - HW_VAR_BCN_VALID, //Added by tynli. - HW_VAR_FWLPS_RF_ON //Added by tynli. 2009.11.09. For checking if Fw finishs RF on sequence. -}HW_VARIABLES; - -#define RT_CHECK_FOR_HANG_PERIOD 2 - -struct ieee80211_device { - struct net_device *dev; - struct ieee80211_security sec; - - bool need_sw_enc; -#ifdef ENABLE_LPS - bool bAwakePktSent; - u8 LPSDelayCnt; - bool bIsAggregateFrame; - bool polling; - void (*LeisurePSLeave)(struct ieee80211_device *ieee); -#endif - -#ifdef ENABLE_IPS - bool proto_stoppping; - bool wx_set_enc; - struct semaphore ips_sem; - struct work_struct ips_leave_wq; - void (*ieee80211_ips_leave_wq) (struct ieee80211_device *ieee); - void (*ieee80211_ips_leave)(struct ieee80211_device *ieee); -#endif - void (*SetHwRegHandler)(struct ieee80211_device *ieee, u8 variable, u8 *val); - u8 (*rtllib_ap_sec_type)(struct ieee80211_device *ieee); - - //hw security related - u8 hwsec_active; //hw security active. - bool is_silent_reset; - bool is_roaming; - bool ieee_up; - bool bSupportRemoteWakeUp; - bool actscanning; - bool beinretry; - bool is_set_key; - //11n spec related I wonder if These info structure need to be moved out of ieee80211_device - - //11n HT below - PRT_HIGH_THROUGHPUT pHTInfo; - spinlock_t bw_spinlock; - - spinlock_t reorder_spinlock; - // for HT operation rate set. we use this one for HT data rate to separate different descriptors - //the way fill this is the same as in the IE - u8 Regdot11HTOperationalRateSet[16]; //use RATR format - u8 dot11HTOperationalRateSet[16]; //use RATR format - u8 RegHTSuppRateSet[16]; - u8 HTCurrentOperaRate; - u8 HTHighestOperaRate; - //wb added for rate operation mode to firmware - u8 bTxDisableRateFallBack; - u8 bTxUseDriverAssingedRate; - atomic_t atm_chnlop; - atomic_t atm_swbw; - - // 802.11e and WMM Traffic Stream Info (TX) - struct list_head Tx_TS_Admit_List; - struct list_head Tx_TS_Pending_List; - struct list_head Tx_TS_Unused_List; - TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM]; - // 802.11e and WMM Traffic Stream Info (RX) - struct list_head Rx_TS_Admit_List; - struct list_head Rx_TS_Pending_List; - struct list_head Rx_TS_Unused_List; - RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM]; - RX_REORDER_ENTRY RxReorderEntry[128]; - struct list_head RxReorder_Unused_List; - u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.) - - - /* Bookkeeping structures */ - struct net_device_stats stats; - struct ieee80211_stats ieee_stats; - struct ieee80211_softmac_stats softmac_stats; - - /* Probe / Beacon management */ - struct list_head network_free_list; - struct list_head network_list; - struct ieee80211_network *networks; - int scans; - int scan_age; - - int iw_mode; /* operating mode (IW_MODE_*) */ - struct iw_spy_data spy_data; - - spinlock_t lock; - spinlock_t wpax_suitlist_lock; - - int tx_headroom; /* Set to size of any additional room needed at front - * of allocated Tx SKBs */ - u32 config; - - /* WEP and other encryption related settings at the device level */ - int open_wep; /* Set to 1 to allow unencrypted frames */ - int auth_mode; - int reset_on_keychange; /* Set to 1 if the HW needs to be reset on - * WEP key changes */ - - /* If the host performs {en,de}cryption, then set to 1 */ - int host_encrypt; - int host_encrypt_msdu; - int host_decrypt; - /* host performs multicast decryption */ - int host_mc_decrypt; - - /* host should strip IV and ICV from protected frames */ - /* meaningful only when hardware decryption is being used */ - int host_strip_iv_icv; - - int host_open_frag; - int host_build_iv; - int ieee802_1x; /* is IEEE 802.1X used */ - - /* WPA data */ - bool bHalfWirelessN24GMode; - int wpa_enabled; - int drop_unencrypted; - int tkip_countermeasures; - int privacy_invoked; - size_t wpa_ie_len; - u8 *wpa_ie; - u8 ap_mac_addr[6]; - u16 pairwise_key_type; - u16 group_key_type; - struct list_head crypt_deinit_list; - struct ieee80211_crypt_data *crypt[WEP_KEYS]; - int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ - struct timer_list crypt_deinit_timer; - int crypt_quiesced; - - int bcrx_sta_key; /* use individual keys to override default keys even - * with RX of broad/multicast frames */ - - /* Fragmentation structures */ - // each streaming contain a entry - struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN]; - unsigned int frag_next_idx[17]; - u16 fts; /* Fragmentation Threshold */ -#define DEFAULT_RTS_THRESHOLD 2346U -#define MIN_RTS_THRESHOLD 1 -#define MAX_RTS_THRESHOLD 2346U - u16 rts; /* RTS threshold */ - - /* Association info */ - u8 bssid[ETH_ALEN]; - - /* This stores infos for the current network. - * Either the network we are associated in INFRASTRUCTURE - * or the network that we are creating in MASTER mode. - * ad-hoc is a mixture ;-). - * Note that in infrastructure mode, even when not associated, - * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig - */ - struct ieee80211_network current_network; - - enum ieee80211_state state; - - int short_slot; - int reg_mode; - int mode; /* A, B, G */ - int modulation; /* CCK, OFDM */ - int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ - int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate - * without wait for the syncro scan to terminate - */ - short sync_scan_hurryup; - - int perfect_rssi; - int worst_rssi; - - u16 prev_seq_ctl; /* used to drop duplicate frames */ - - /* map of allowed channels. 0 is dummy */ - // FIXME: remember to default to a basic channel plan depending of the PHY type -#ifdef ENABLE_DOT11D - void* pDot11dInfo; - bool bGlobalDomain; -#else - int channel_map[MAX_CHANNEL_NUMBER+1]; -#endif - int rate; /* current rate */ - int basic_rate; - //FIXME: pleace callback, see if redundant with softmac_features - short active_scan; - - /* this contains flags for selectively enable softmac support */ - u16 softmac_features; - - /* if the sequence control field is not filled by HW */ - u16 seq_ctrl[5]; - - /* association procedure transaction sequence number */ - u16 associate_seq; - - /* AID for RTXed association responses */ - u16 assoc_id; - - /* power save mode related*/ - u8 ack_tx_to_ieee; - short ps; - short sta_sleep; - int ps_timeout; - int ps_period; - struct tasklet_struct ps_task; - u32 ps_th; - u32 ps_tl; - - short raw_tx; - /* used if IEEE_SOFTMAC_TX_QUEUE is set */ - short queue_stop; - short scanning; - short proto_started; - - struct semaphore wx_sem; - struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; - spinlock_t beacon_lock; - - short beacon_txing; - - short wap_set; - short ssid_set; - - u8 wpax_type_set; //{added by David, 2006.9.28} - u32 wpax_type_notify; //{added by David, 2006.9.26} - - /* QoS related flag */ - char init_wmmparam_flag; - /* set on initialization */ - u8 qos_support; - - /* for discarding duplicated packets in IBSS */ - struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - - /* for discarding duplicated packets in BSS */ - u16 last_rxseq_num[17]; /* rx seq previous per-tid */ - u16 last_rxfrag_num[17];/* tx frag previous per-tid */ - unsigned long last_packet_time[17]; - - /* for PS mode */ - unsigned long last_rx_ps_time; - u8 LPSAwakeIntvl; - u8 RegMaxLPSAwakeIntvl; - - /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ - struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; - int mgmt_queue_head; - int mgmt_queue_tail; -#define IEEE80211_QUEUE_LIMIT 128 - u8 AsocRetryCount; - unsigned int hw_header; - struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; - struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; - struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE]; - u32 sta_edca_param[4]; - bool aggregation; - // Enable/Disable Rx immediate BA capability. - bool enable_rx_imm_BA; - bool bibsscoordinator; - - //+by amy for DM ,080515 - //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15 - bool bdynamic_txpower_enable; - - bool bCTSToSelfEnable; - u8 CTSToSelfTH; - - u32 fsync_time_interval; - u32 fsync_rate_bitmap; - u8 fsync_rssi_threshold; - bool bfsync_enable; - - u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval - u32 fsync_firstdiff_ratethreshold; // low threshold - u32 fsync_seconddiff_ratethreshold; // decrease threshold - Fsync_State fsync_state; - bool bis_any_nonbepkts; - //20Mhz 40Mhz AutoSwitch Threshold - bandwidth_autoswitch bandwidth_auto_switch; - //for txpower tracking - bool FwRWRF; - - //added by amy for AP roaming - RT_LINK_DETECT_T LinkDetectInfo; - - /* used if IEEE_SOFTMAC_TX_QUEUE is set */ - struct tx_pending_t tx_pending; - - /* used if IEEE_SOFTMAC_ASSOCIATE is set */ - struct timer_list associate_timer; - - /* used if IEEE_SOFTMAC_BEACONS is set */ - struct timer_list beacon_timer; - struct work_struct associate_complete_wq; - struct work_struct associate_procedure_wq; - struct delayed_work softmac_scan_wq; - struct delayed_work associate_retry_wq; - struct delayed_work start_ibss_wq; - struct delayed_work hw_wakeup_wq; - - struct work_struct wx_sync_scan_wq; - struct workqueue_struct *wq; - - /* Callback functions */ - void (*set_security)(struct ieee80211_device *ieee, - struct ieee80211_security *sec); - - /* Used to TX data frame by using txb structs. - * this is not used if in the softmac_features - * is set the flag IEEE_SOFTMAC_TX_QUEUE - */ - int (*hard_start_xmit)(struct ieee80211_txb *txb, - struct ieee80211_device *ieee); - - int (*reset_port)(struct ieee80211_device *ieee); - int (*is_queue_full) (struct ieee80211_device *ieee, int pri); - - int (*handle_management) (struct ieee80211_device *ieee, - struct ieee80211_network * network, u16 type); - int (*is_qos_active) (struct ieee80211_device *ieee, struct sk_buff *skb); - - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that - * one might want to use for data and management frames - * the option to have two callbacks might be useful. - * This function can't sleep. - */ - int (*softmac_hard_start_xmit)(struct sk_buff *skb, - struct ieee80211_device *ieee80211); - - /* used instead of hard_start_xmit (not softmac_hard_start_xmit) - * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data - * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set - * then also management frames are sent via this callback. - * This function can't sleep. - */ - void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct ieee80211_device *ieee80211, int rate); - - /* stops the HW queue for DATA frames. Useful to avoid - * waste time to TX data frame when we are reassociating - * This function can sleep. - */ - void (*data_hard_stop)(struct ieee80211_device *ieee80211); - - /* OK this is complementar to data_poll_hard_stop */ - void (*data_hard_resume)(struct ieee80211_device *ieee80211); - - /* ask to the driver to retune the radio . - * This function can sleep. the driver should ensure - * the radio has been swithced before return. - */ - void (*set_chan)(struct ieee80211_device *ieee80211, short ch); - - /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). - * In this case only the set_chan is used. - * - * The syncro version is similar to the start_scan but - * does not return until all channels has been scanned. - * this is called in user context and should sleep, - * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. - * the function stop_scan should stop both the syncro and - * background scanning and can sleep. - * The function start_scan should initiate the background - * scanning and can't sleep. - */ - void (*scan_syncro)(struct ieee80211_device *ieee80211); - void (*start_scan)(struct ieee80211_device *ieee80211); - void (*stop_scan)(struct ieee80211_device *ieee80211); - - /* indicate the driver that the link state is changed - * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led - */ - void (*link_change)(struct ieee80211_device *ieee80211); - - /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the - * IEEE_SOFTMAC_BEACONS is not set. For now the - * stop_send_bacons is NOT guaranteed to be called only - * after start_send_beacons. - */ - void (*start_send_beacons) (struct ieee80211_device *dev); - void (*stop_send_beacons) (struct ieee80211_device *dev); - - /* power save mode related */ - void (*sta_wake_up) (struct ieee80211_device *ieee80211); - void (*enter_sleep_state) (struct ieee80211_device *ieee80211, u32 th, u32 tl); - short (*ps_is_queue_empty) (struct ieee80211_device *ieee80211); - int (*handle_beacon) (struct ieee80211_device *ieee80211, struct ieee80211_beacon *beacon, struct ieee80211_network *network); - int (*handle_assoc_response) (struct ieee80211_device *ieee80211, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network); - - /* check whether Tx hw resouce available */ - short (*check_nic_enough_desc)(struct ieee80211_device *ieee80211, int queue_index); - //added by wb for HT related - void (*SetBWModeHandler)(struct ieee80211_device *ieee80211, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); - bool (*GetNmodeSupportBySecCfg)(struct ieee80211_device *ieee80211); - void (*SetWirelessMode)(struct ieee80211_device *ieee80211, u8 wireless_mode); - bool (*GetHalfNmodeSupportByAPsHandler)(struct ieee80211_device *ieee80211); - void (*InitialGainHandler)(struct ieee80211_device *ieee80211, u8 Operation); - - /* This must be the last item so that it points to the data - * allocated beyond this structure by alloc_ieee80211 */ - u8 priv[0]; -}; - -#define RT_RF_OFF_LEVL_ASPM BIT0 // PCI ASPM -#define RT_RF_OFF_LEVL_CLK_REQ BIT1 // PCI clock request -#define RT_RF_OFF_LEVL_PCI_D3 BIT2 // PCI D3 mode -#define RT_RF_OFF_LEVL_HALT_NIC BIT3 // NIC halt, re-initialize hw parameters -#define RT_RF_OFF_LEVL_FREE_FW BIT4 // FW free, re-download the FW -#define RT_RF_OFF_LEVL_FW_32K BIT5 // FW in 32k -#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 // Always enable ASPM and Clock Req in initialization. -#define RT_RF_LPS_DISALBE_2R BIT30 // When LPS is on, disable 2R if no packet is received or transmittd. -#define RT_RF_LPS_LEVEL_ASPM BIT31 // LPS with ASPM -#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) -#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG))) -#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) - -#define IEEE_A (1<<0) -#define IEEE_B (1<<1) -#define IEEE_G (1<<2) -#define IEEE_N_24G (1<<4) -#define IEEE_N_5G (1<<5) -#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) - -/* Generate a 802.11 header */ - -/* Uses the channel change callback directly - * instead of [start/stop] scan callbacks - */ -#define IEEE_SOFTMAC_SCAN (1<<2) - -/* Perform authentication and association handshake */ -#define IEEE_SOFTMAC_ASSOCIATE (1<<3) - -/* Generate probe requests */ -#define IEEE_SOFTMAC_PROBERQ (1<<4) - -/* Generate respones to probe requests */ -#define IEEE_SOFTMAC_PROBERS (1<<5) - -/* The ieee802.11 stack will manages the netif queue - * wake/stop for the driver, taking care of 802.11 - * fragmentation. See softmac.c for details. */ -#define IEEE_SOFTMAC_TX_QUEUE (1<<7) - -/* Uses only the softmac_data_hard_start_xmit - * even for TX management frames. - */ -#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) - -/* Generate beacons. The stack will enqueue beacons - * to the card - */ -#define IEEE_SOFTMAC_BEACONS (1<<6) - -static inline void *ieee80211_priv(struct net_device *dev) -{ - return ((struct ieee80211_device *)netdev_priv(dev))->priv; -} - -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) -{ - /* Single white space is for Linksys APs */ - if (essid_len == 1 && essid[0] == ' ') - return 1; - - /* Otherwise, if the entire essid is 0, we assume it is hidden */ - while (essid_len) { - essid_len--; - if (essid[essid_len] != '\0') - return 0; - } - - return 1; -} - -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) -{ - /* - * It is possible for both access points and our device to support - * combinations of modes, so as long as there is one valid combination - * of ap/device supported modes, then return success - * - */ - if ((mode & IEEE_A) && - (ieee->modulation & IEEE80211_OFDM_MODULATION) && - (ieee->freq_band & IEEE80211_52GHZ_BAND)) - return 1; - - if ((mode & IEEE_G) && - (ieee->modulation & IEEE80211_OFDM_MODULATION) && - (ieee->freq_band & IEEE80211_24GHZ_BAND)) - return 1; - - if ((mode & IEEE_B) && - (ieee->modulation & IEEE80211_CCK_MODULATION) && - (ieee->freq_band & IEEE80211_24GHZ_BAND)) - return 1; - - return 0; -} - -extern inline int ieee80211_get_hdrlen(u16 fc) -{ - int hdrlen = IEEE80211_3ADDR_LEN; - - switch (WLAN_FC_GET_TYPE(fc)) { - case IEEE80211_FTYPE_DATA: - if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) - hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */ - if(IEEE80211_QOS_HAS_SEQ(fc)) - hdrlen += 2; /* QOS ctrl*/ - break; - case IEEE80211_FTYPE_CTL: - switch (WLAN_FC_GET_STYPE(fc)) { - case IEEE80211_STYPE_CTS: - case IEEE80211_STYPE_ACK: - hdrlen = IEEE80211_1ADDR_LEN; - break; - default: - hdrlen = IEEE80211_2ADDR_LEN; - break; - } - break; - } - - return hdrlen; -} - -static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) -{ - switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { - case IEEE80211_1ADDR_LEN: - return ((struct ieee80211_hdr_1addr *)hdr)->payload; - case IEEE80211_2ADDR_LEN: - return ((struct ieee80211_hdr_2addr *)hdr)->payload; - case IEEE80211_3ADDR_LEN: - return ((struct ieee80211_hdr_3addr *)hdr)->payload; - case IEEE80211_4ADDR_LEN: - return ((struct ieee80211_hdr_4addr *)hdr)->payload; - } - return NULL; -} - -static inline int ieee80211_is_ofdm_rate(u8 rate) -{ - switch (rate & ~IEEE80211_BASIC_RATE_MASK) { - case IEEE80211_OFDM_RATE_6MB: - case IEEE80211_OFDM_RATE_9MB: - case IEEE80211_OFDM_RATE_12MB: - case IEEE80211_OFDM_RATE_18MB: - case IEEE80211_OFDM_RATE_24MB: - case IEEE80211_OFDM_RATE_36MB: - case IEEE80211_OFDM_RATE_48MB: - case IEEE80211_OFDM_RATE_54MB: - return 1; - } - return 0; -} - -static inline int ieee80211_is_cck_rate(u8 rate) -{ - switch (rate & ~IEEE80211_BASIC_RATE_MASK) { - case IEEE80211_CCK_RATE_1MB: - case IEEE80211_CCK_RATE_2MB: - case IEEE80211_CCK_RATE_5MB: - case IEEE80211_CCK_RATE_11MB: - return 1; - } - return 0; -} - - -/* ieee80211.c */ -void free_ieee80211(struct net_device *dev); -struct net_device *alloc_ieee80211(int sizeof_priv); - -int ieee80211_set_encryption(struct ieee80211_device *ieee); - -/* ieee80211_tx.c */ - -int ieee80211_encrypt_fragment( - struct ieee80211_device *ieee, - struct sk_buff *frag, - int hdr_len); - -int ieee80211_rtl_xmit(struct sk_buff *skb, - struct net_device *dev); -void ieee80211_txb_free(struct ieee80211_txb *); - - -/* ieee80211_rx.c */ -int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats); -void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, - struct ieee80211_rx_stats *stats); - -/* ieee80211_wx.c */ -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); -int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); -int ieee80211_wx_set_auth(struct ieee80211_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra); -int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); - -/* ieee80211_softmac.c */ -short ieee80211_is_54g(struct ieee80211_network net); -short ieee80211_is_shortslot(struct ieee80211_network net); -int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, u16 type, - u16 stype); -void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); - -void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn); -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); - -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -void notify_wx_assoc_event(struct ieee80211_device *ieee); -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -void ieee80211_start_bss(struct ieee80211_device *ieee); -void ieee80211_start_master_bss(struct ieee80211_device *ieee); -void ieee80211_start_ibss(struct ieee80211_device *ieee); -void ieee80211_softmac_init(struct ieee80211_device *ieee); -void ieee80211_softmac_free(struct ieee80211_device *ieee); -void ieee80211_associate_abort(struct ieee80211_device *ieee); -void ieee80211_disassociate(struct ieee80211_device *ieee); -void ieee80211_stop_scan(struct ieee80211_device *ieee); -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -void ieee80211_check_all_nets(struct ieee80211_device *ieee); -void ieee80211_start_protocol(struct ieee80211_device *ieee); -void ieee80211_stop_protocol(struct ieee80211_device *ieee,u8 shutdown); -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee,u8 shutdown); -void ieee80211_reset_queue(struct ieee80211_device *ieee); -void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee); -void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee); -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -void notify_wx_assoc_event(struct ieee80211_device *ieee); -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); - -void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee); - -/* ieee80211_crypt_ccmp&tkip&wep.c */ -void ieee80211_tkip_null(void); -void ieee80211_wep_null(void); -void ieee80211_ccmp_null(void); - -/* ieee80211_softmac_wx.c */ - -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *ext); - -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra); - -int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); - -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); - -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); - -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); - -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); - -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); - -void ieee80211_wx_sync_scan_wq(struct work_struct *work); - -int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_set_power(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_get_power(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_set_rts(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); - -int ieee80211_wx_get_rts(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -//HT -#define MAX_RECEIVE_BUFFER_SIZE 9100 -void HTDebugHTCapability(u8 *CapIE, u8 *TitleString ); -void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); - -void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); -void HTUpdateDefaultSetting(struct ieee80211_device *ieee); -void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 isEncrypt); -void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 isEncrypt); -void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len); -void HTOnAssocRsp(struct ieee80211_device *ieee); -void HTInitializeHTInfo(struct ieee80211_device *ieee); -void HTInitializeBssDesc(PBSS_HT pBssHT); -void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); -void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); -u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter); -extern u8 MCS_FILTER_ALL[]; -extern u16 MCS_DATA_RATE[2][2][77] ; - -u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); -void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); -bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee); -u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); -u16 HTMcsToDataRate( struct ieee80211_device *ieee, u8 nMcsRate); -u16 TxCountToDataRate( struct ieee80211_device *ieee, u8 nDataRate); -int ieee80211_rx_ADDBAReq( struct ieee80211_device *ieee, struct sk_buff *skb); -int ieee80211_rx_ADDBARsp( struct ieee80211_device *ieee, struct sk_buff *skb); -int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); -void TsInitAddBA( struct ieee80211_device *ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); -void TsInitDelBA( struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); -void BaSetupTimeOut(unsigned long data); -void TxBaInactTimeout(unsigned long data); -void RxBaInactTimeout(unsigned long data); -void ResetBaEntry( PBA_RECORD pBA); -//function in TS.c -bool GetTs( - struct ieee80211_device* ieee, - PTS_COMMON_INFO *ppTS, - u8* Addr, - u8 TID, - TR_SELECT TxRxSelect, //Rx:1, Tx:0 - bool bAddNewTs - ); -void TSInitialize(struct ieee80211_device *ieee); -void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS); -void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr); -void RemoveAllTS(struct ieee80211_device *ieee); -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee); - -extern const long ieee80211_wlan_frequencies[]; - -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) -{ - ieee->scans++; -} - -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) -{ - return ieee->scans; -} - -static inline const char *escape_essid(const char *essid, u8 essid_len) { - static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; - const char *s = essid; - char *d = escaped; - - if (ieee80211_is_empty_essid(essid, essid_len)) { - memcpy(escaped, "", sizeof("")); - return escaped; - } - - essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE); - while (essid_len--) { - if (*s == '\0') { - *d++ = '\\'; - *d++ = '0'; - s++; - } else { - *d++ = *s++; - } - } - *d = '\0'; - return escaped; -} - -/* For the function is more related to hardware setting, it's better to use the - * ieee handler to refer to it. - */ -int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev); -int ieee80211_parse_info_param(struct ieee80211_device *ieee, - struct ieee80211_info_element *info_element, - u16 length, - struct ieee80211_network *network, - struct ieee80211_rx_stats *stats); - -void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index); -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr); -void ieee80211_sta_ps_send_pspoll_frame(struct ieee80211_device *ieee); -#define RT_ASOC_RETRY_LIMIT 5 -#endif /* IEEE80211_H */ diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c deleted file mode 100644 index 37a65ff4b12..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c +++ /dev/null @@ -1,352 +0,0 @@ -/******************************************************************************* - - Copyright(c) 2004 Intel Corporation. All rights reserved. - - Portions of this file are based on the WEP enablement code provided by the - Host AP project hostap-drivers v0.1.3 - Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - - Copyright (c) 2002-2003, Jouni Malinen - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. - - Contact Information: - James P. Ketrenos - Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - -*******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ieee80211.h" - -MODULE_DESCRIPTION("802.11 data/management/control stack"); -MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation "); -MODULE_LICENSE("GPL"); - -#define DRV_NAME "ieee80211" - -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) -{ - if (ieee->networks) - return 0; - - ieee->networks = kcalloc( - MAX_NETWORK_COUNT, sizeof(struct ieee80211_network), - GFP_KERNEL); - if (!ieee->networks) { - printk(KERN_WARNING "%s: Out of memory allocating beacons\n", - ieee->dev->name); - return -ENOMEM; - } - - return 0; -} - -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) -{ - if (!ieee->networks) - return; - kfree(ieee->networks); - ieee->networks = NULL; -} - -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) -{ - int i; - - INIT_LIST_HEAD(&ieee->network_free_list); - INIT_LIST_HEAD(&ieee->network_list); - for (i = 0; i < MAX_NETWORK_COUNT; i++) - list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); -} - - -struct net_device *alloc_ieee80211(int sizeof_priv) -{ - struct ieee80211_device *ieee; - struct net_device *dev; - int i, err; - - IEEE80211_DEBUG_INFO("Initializing...\n"); - - dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv); - if (!dev) { - IEEE80211_ERROR("Unable to network device.\n"); - goto failed; - } - - ieee = netdev_priv(dev); - - memset(ieee, 0, sizeof(struct ieee80211_device) + sizeof_priv); - ieee->dev = dev; - - err = ieee80211_networks_allocate(ieee); - if (err) { - IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", - err); - goto failed; - } - ieee80211_networks_initialize(ieee); - - - /* Default fragmentation threshold is maximum payload size */ - ieee->fts = DEFAULT_FTS; - ieee->scan_age = DEFAULT_MAX_SCAN_AGE; - ieee->open_wep = 1; - - /* Default to enabling full open WEP with host based encrypt/decrypt */ - ieee->host_encrypt = 1; - ieee->host_decrypt = 1; - ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ - - INIT_LIST_HEAD(&ieee->crypt_deinit_list); - init_timer(&ieee->crypt_deinit_timer); - ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; - - spin_lock_init(&ieee->lock); - spin_lock_init(&ieee->wpax_suitlist_lock); - spin_lock_init(&ieee->bw_spinlock); - spin_lock_init(&ieee->reorder_spinlock); - - /* added by WB */ - atomic_set(&(ieee->atm_chnlop), 0); - atomic_set(&(ieee->atm_swbw), 0); - - ieee->wpax_type_set = 0; - ieee->wpa_enabled = 0; - ieee->tkip_countermeasures = 0; - ieee->drop_unencrypted = 0; - ieee->privacy_invoked = 0; - ieee->ieee802_1x = 1; - ieee->raw_tx = 0; - /* ieee->hwsec_support = 1; default support hw security: use module_param instead */ - ieee->hwsec_active = 0; /* disable hwsec, switch it on when necessary */ - - ieee80211_softmac_init(ieee); - - ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); - if (ieee->pHTInfo == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n"); - return NULL; - } - HTUpdateDefaultSetting(ieee); - HTInitializeHTInfo(ieee); /* may move to other place */ - TSInitialize(ieee); - for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) - INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); - - for (i = 0; i < 17; i++) { - ieee->last_rxseq_num[i] = -1; - ieee->last_rxfrag_num[i] = -1; - ieee->last_packet_time[i] = 0; - } - - /* Functions to load crypt module automatically */ - ieee80211_tkip_null(); - ieee80211_wep_null(); - ieee80211_ccmp_null(); - - return dev; - -failed: - if (dev) - free_netdev(dev); - return NULL; -} - - -void free_ieee80211(struct net_device *dev) -{ - struct ieee80211_device *ieee = netdev_priv(dev); - int i; - kfree(ieee->pHTInfo); - ieee->pHTInfo = NULL; - RemoveAllTS(ieee); - ieee80211_softmac_free(ieee); - del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); - - for (i = 0; i < WEP_KEYS; i++) { - struct ieee80211_crypt_data *crypt = ieee->crypt[i]; - if (crypt) { - if (crypt->ops) - crypt->ops->deinit(crypt->priv); - kfree(crypt); - ieee->crypt[i] = NULL; - } - } - - ieee80211_networks_free(ieee); - free_netdev(dev); -} - -#ifdef CONFIG_IEEE80211_DEBUG - -u32 ieee80211_debug_level = 0; -static int debug = - /* IEEE80211_DL_INFO | */ - /* IEEE80211_DL_WX | */ - /* IEEE80211_DL_SCAN | */ - /* IEEE80211_DL_STATE | */ - /* IEEE80211_DL_MGMT | */ - /* IEEE80211_DL_FRAG | */ - /* IEEE80211_DL_EAP | */ - /* IEEE80211_DL_DROP | */ - /* IEEE80211_DL_TX | */ - /* IEEE80211_DL_RX | */ - /* IEEE80211_DL_QOS | */ - /* IEEE80211_DL_HT | */ - /* IEEE80211_DL_TS | */ - /* IEEE80211_DL_BA | */ - /* IEEE80211_DL_REORDER | */ - /* IEEE80211_DL_TRACE | */ - /* IEEE80211_DL_DATA | */ - IEEE80211_DL_ERR /* always open this flag to show error out */ - ; -struct proc_dir_entry *ieee80211_proc = NULL; - -static int show_debug_level(char *page, char **start, off_t offset, - int count, int *eof, void *data) -{ - return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); -} - -static int store_debug_level(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - char buf[] = "0x00000000"; - unsigned long len = min(sizeof(buf) - 1, (u32)count); - char *p = (char *)buf; - unsigned long val; - - if (copy_from_user(buf, buffer, len)) - return count; - buf[len] = 0; - if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { - p++; - if (p[0] == 'x' || p[0] == 'X') - p++; - val = simple_strtoul(p, &p, 16); - } else - val = simple_strtoul(p, &p, 10); - if (p == buf) - printk(KERN_INFO DRV_NAME - ": %s is not in hex or decimal form.\n", buf); - else - ieee80211_debug_level = val; - - return strnlen(buf, count); -} - -extern int ieee80211_crypto_init(void); -extern void ieee80211_crypto_deinit(void); -extern int ieee80211_crypto_tkip_init(void); -extern void ieee80211_crypto_tkip_exit(void); -extern int ieee80211_crypto_ccmp_init(void); -extern void ieee80211_crypto_ccmp_exit(void); -extern int ieee80211_crypto_wep_init(void); -extern void ieee80211_crypto_wep_exit(void); - -int __init ieee80211_rtl_init(void) -{ - struct proc_dir_entry *e; - int retval; - - retval = ieee80211_crypto_init(); - if (retval) - return retval; - retval = ieee80211_crypto_tkip_init(); - if (retval) { - ieee80211_crypto_deinit(); - return retval; - } - retval = ieee80211_crypto_ccmp_init(); - if (retval) { - ieee80211_crypto_tkip_exit(); - ieee80211_crypto_deinit(); - return retval; - } - retval = ieee80211_crypto_wep_init(); - if (retval) { - ieee80211_crypto_ccmp_exit(); - ieee80211_crypto_tkip_exit(); - ieee80211_crypto_deinit(); - return retval; - } - - ieee80211_debug_level = debug; - ieee80211_proc = proc_mkdir(DRV_NAME, init_net.proc_net); - if (ieee80211_proc == NULL) { - IEEE80211_ERROR("Unable to create " DRV_NAME - " proc directory\n"); - return -EIO; - } - e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, - ieee80211_proc); - if (!e) { - remove_proc_entry(DRV_NAME, init_net.proc_net); - ieee80211_proc = NULL; - return -EIO; - } - e->read_proc = show_debug_level; - e->write_proc = store_debug_level; - e->data = NULL; - - return 0; -} - -void __exit ieee80211_rtl_exit(void) -{ - if (ieee80211_proc) { - remove_proc_entry("debug_level", ieee80211_proc); - remove_proc_entry(DRV_NAME, init_net.proc_net); - ieee80211_proc = NULL; - } - ieee80211_crypto_wep_exit(); - ieee80211_crypto_ccmp_exit(); - ieee80211_crypto_tkip_exit(); - ieee80211_crypto_deinit(); -} - -#include -module_param(debug, int, 0444); -MODULE_PARM_DESC(debug, "debug output mask"); - - -#endif - diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c deleted file mode 100644 index 022086d2a3f..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c +++ /dev/null @@ -1,2676 +0,0 @@ -/* - * Original code based Host AP (software wireless LAN access point) driver - * for Intersil Prism2/2.5/3 - hostap.o module, common routines - * - * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - * - * Copyright (c) 2002-2003, Jouni Malinen - * Copyright (c) 2004, Intel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. See README and COPYING for - * more details. - ****************************************************************************** - - Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello - - A special thanks goes to Realtek for their support ! - -******************************************************************************/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ieee80211.h" -#ifdef ENABLE_DOT11D -#include "dot11d.h" -#endif -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, - struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats) -{ - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); - - skb->dev = ieee->dev; - skb_reset_mac_header(skb); - - skb_pull(skb, ieee80211_get_hdrlen(fc)); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = __constant_htons(ETH_P_80211_RAW); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); -} - - -/* Called only as a tasklet (software IRQ) */ -static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, - unsigned int frag, u8 tid,u8 *src, u8 *dst) -{ - struct ieee80211_frag_entry *entry; - int i; - - for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) { - entry = &ieee->frag_cache[tid][i]; - if (entry->skb != NULL && - time_after(jiffies, entry->first_frag_time + 2 * HZ)) { - IEEE80211_DEBUG_FRAG( - "expiring fragment cache entry " - "seq=%u last_frag=%u\n", - entry->seq, entry->last_frag); - dev_kfree_skb_any(entry->skb); - entry->skb = NULL; - } - - if (entry->skb != NULL && entry->seq == seq && - (entry->last_frag + 1 == frag || frag == -1) && - memcmp(entry->src_addr, src, ETH_ALEN) == 0 && - memcmp(entry->dst_addr, dst, ETH_ALEN) == 0) - return entry; - } - - return NULL; -} - -/* Called only as a tasklet (software IRQ) */ -static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) -{ - struct sk_buff *skb = NULL; - u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 sc = le16_to_cpu(hdr->seq_ctl); - unsigned int frag = WLAN_GET_SEQ_FRAG(sc); - unsigned int seq = WLAN_GET_SEQ_SEQ(sc); - struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; - u8 tid; - - if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else { - tid = 0; - } - - if (frag == 0) { - /* Reserve enough space to fit maximum frame length */ - skb = dev_alloc_skb(ieee->dev->mtu + - sizeof(struct ieee80211_hdr_4addr) + - 8 /* LLC */ + - 2 /* alignment */ + - 8 /* WEP */ + - ETH_ALEN /* WDS */ + - (IEEE80211_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */); - if (skb == NULL) - return NULL; - - entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]]; - ieee->frag_next_idx[tid]++; - if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN) - ieee->frag_next_idx[tid] = 0; - - if (entry->skb != NULL) - dev_kfree_skb_any(entry->skb); - - entry->first_frag_time = jiffies; - entry->seq = seq; - entry->last_frag = frag; - entry->skb = skb; - memcpy(entry->src_addr, hdr->addr2, ETH_ALEN); - memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN); - } else { - /* received a fragment of a frame for which the head fragment - * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, tid,hdr->addr2, - hdr->addr1); - if (entry != NULL) { - entry->last_frag = frag; - skb = entry->skb; - } - } - - return skb; -} - - -/* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) -{ - u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 sc = le16_to_cpu(hdr->seq_ctl); - unsigned int seq = WLAN_GET_SEQ_SEQ(sc); - struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; - u8 tid; - - if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else { - tid = 0; - } - - entry = ieee80211_frag_cache_find(ieee, seq, -1, tid,hdr->addr2, - hdr->addr1); - - if (entry == NULL) { - IEEE80211_DEBUG_FRAG( - "could not invalidate fragment cache " - "entry (seq=%u)\n", seq); - return -1; - } - - entry->skb = NULL; - return 0; -} - - - -/* ieee80211_rx_frame_mgtmt - * - * Responsible for handling management control frames - * - * Called by ieee80211_rx */ -static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, u16 type, - u16 stype) -{ - /* On the struct stats definition there is written that - * this is not mandatory.... but seems that the probe - * response parser uses it - */ - struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data; - - rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats); - if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames - { - dev_kfree_skb_any(skb); - return 0; - } - - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); - - dev_kfree_skb_any(skb); - - return 0; - - #ifdef NOT_YET - if (ieee->iw_mode == IW_MODE_MASTER) { - printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", - ieee->dev->name); - return 0; - } - - if (ieee->hostapd && type == IEEE80211_TYPE_MGMT) { - if (stype == WLAN_FC_STYPE_BEACON && - ieee->iw_mode == IW_MODE_MASTER) { - struct sk_buff *skb2; - /* Process beacon frames also in kernel driver to - * update STA(AP) table statistics */ - skb2 = skb_clone(skb, GFP_ATOMIC); - if (skb2) - hostap_rx(skb2->dev, skb2, rx_stats); - } - - /* send management frames to the user space daemon for - * processing */ - ieee->apdevstats.rx_packets++; - ieee->apdevstats.rx_bytes += skb->len; - prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT); - return 0; - } - - if (ieee->iw_mode == IW_MODE_MASTER) { - if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) { - printk(KERN_DEBUG "%s: unknown management frame " - "(type=0x%02x, stype=0x%02x) dropped\n", - skb->dev->name, type, stype); - return -1; - } - - hostap_rx(skb->dev, skb, rx_stats); - return 0; - } - - printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame " - "received in non-Host AP mode\n", skb->dev->name); - return -1; - #endif -} - - - -/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ -/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; -/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; -/* No encapsulation header if EtherType < 0x600 (=length) */ - -/* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, - struct sk_buff *skb, size_t hdrlen) -{ - struct net_device *dev = ieee->dev; - u16 fc, ethertype; - struct ieee80211_hdr_4addr *hdr; - u8 *pos; - - if (skb->len < 24) - return 0; - - if (ieee->hwsec_active) - { - cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); - tcb_desc->bHwSec = 1; - - if(ieee->need_sw_enc) - tcb_desc->bHwSec = 0; - } - - hdr = (struct ieee80211_hdr_4addr *) skb->data; - fc = le16_to_cpu(hdr->frame_ctl); - - /* check that the frame is unicast frame to us */ - if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == - IEEE80211_FCTL_TODS && - memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 && - memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) { - /* ToDS frame with own addr BSSID and DA */ - } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == - IEEE80211_FCTL_FROMDS && - memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) { - /* FromDS frame with own addr as DA */ - } else - return 0; - - if (skb->len < 24 + 8) - return 0; - - /* check for port access entity Ethernet type */ - pos = skb->data + hdrlen; - ethertype = (pos[6] << 8) | pos[7]; - if (ethertype == ETH_P_PAE) - return 1; - - return 0; -} - -/* Called only as a tasklet (software IRQ), by ieee80211_rx */ -static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, - struct ieee80211_crypt_data *crypt) -{ - struct ieee80211_hdr_4addr *hdr; - int res, hdrlen; - - if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) - return 0; - - if (ieee->hwsec_active) - { - cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); - tcb_desc->bHwSec = 1; - } - - hdr = (struct ieee80211_hdr_4addr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); - -#ifdef CONFIG_IEEE80211_CRYPT_TKIP - if (ieee->tkip_countermeasures && - strcmp(crypt->ops->name, "TKIP") == 0) { - if (net_ratelimit()) { - printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "received packet from %pM\n", - ieee->dev->name, hdr->addr2); - } - return -1; - } -#endif - - atomic_inc(&crypt->refcnt); - res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); - atomic_dec(&crypt->refcnt); - if (res < 0) { - IEEE80211_DEBUG_DROP( - "decryption failed (SA=%pM" - ") res=%d\n", hdr->addr2, res); - if (res == -2) - IEEE80211_DEBUG_DROP("Decryption failed ICV " - "mismatch (key %d)\n", - skb->data[hdrlen + 3] >> 6); - ieee->ieee_stats.rx_discards_undecryptable++; - return -1; - } - - return res; -} - - -/* Called only as a tasklet (software IRQ), by ieee80211_rx */ -static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, - int keyidx, struct ieee80211_crypt_data *crypt) -{ - struct ieee80211_hdr_4addr *hdr; - int res, hdrlen; - - if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) - return 0; - if (ieee->hwsec_active) - { - cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); - tcb_desc->bHwSec = 1; - - if(ieee->need_sw_enc) - tcb_desc->bHwSec = 0; - - } - - hdr = (struct ieee80211_hdr_4addr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); - - atomic_inc(&crypt->refcnt); - res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); - atomic_dec(&crypt->refcnt); - if (res < 0) { - printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" - " (SA=%pM keyidx=%d)\n", - ieee->dev->name, hdr->addr2, keyidx); - return -1; - } - - return 0; -} - - -/* this function is stolen from ipw2200 driver*/ -#define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header) -{ - u16 fc = le16_to_cpu(header->frame_ctl); - u16 sc = le16_to_cpu(header->seq_ctl); - u16 seq = WLAN_GET_SEQ_SEQ(sc); - u16 frag = WLAN_GET_SEQ_FRAG(sc); - u16 *last_seq, *last_frag; - unsigned long *last_time; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; - u8 tid; - - - //TO2DS and QoS - if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS - hdr_3addrqos = (struct ieee80211_hdr_3addrqos*)header; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; - tid = UP2AC(tid); - tid ++; - } else { // no QoS - tid = 0; - } - - switch (ieee->iw_mode) { - case IW_MODE_ADHOC: - { - struct list_head *p; - struct ieee_ibss_seq *entry = NULL; - u8 *mac = header->addr2; - int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE; - - list_for_each(p, &ieee->ibss_mac_hash[index]) { - entry = list_entry(p, struct ieee_ibss_seq, list); - if (!memcmp(entry->mac, mac, ETH_ALEN)) - break; - } - - if (p == &ieee->ibss_mac_hash[index]) { - entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC); - if (!entry) { - printk(KERN_WARNING "Cannot malloc new mac entry\n"); - return 0; - } - memcpy(entry->mac, mac, ETH_ALEN); - entry->seq_num[tid] = seq; - entry->frag_num[tid] = frag; - entry->packet_time[tid] = jiffies; - list_add(&entry->list, &ieee->ibss_mac_hash[index]); - return 0; - } - last_seq = &entry->seq_num[tid]; - last_frag = &entry->frag_num[tid]; - last_time = &entry->packet_time[tid]; - break; - } - - case IW_MODE_INFRA: - last_seq = &ieee->last_rxseq_num[tid]; - last_frag = &ieee->last_rxfrag_num[tid]; - last_time = &ieee->last_packet_time[tid]; - - break; - default: - return 0; - } - - if ((*last_seq == seq) && - time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { - if (*last_frag == frag){ - goto drop; - - } - if (*last_frag + 1 != frag) - /* out-of-order fragment */ - goto drop; - } else - *last_seq = seq; - - *last_frag = frag; - *last_time = jiffies; - return 0; - -drop: - return 1; -} -bool -AddReorderEntry( - PRX_TS_RECORD pTS, - PRX_REORDER_ENTRY pReorderEntry - ) -{ - struct list_head *pList = &pTS->RxPendingPktList; - - while(pList->next != &pTS->RxPendingPktList) - { - if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) - { - pList = pList->next; - } - else if( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) - { - return false; - } - else - { - break; - } - } - - pReorderEntry->List.next = pList->next; - pReorderEntry->List.next->prev = &pReorderEntry->List; - pReorderEntry->List.prev = pList; - pList->next = &pReorderEntry->List; - - return true; -} - -void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index) -{ - u8 i = 0 , j=0; - u16 ethertype; - - for(j = 0; jnr_subframes; i++) { - struct sk_buff *sub_skb = prxb->subframes[i]; - - /* convert hdr + possible LLC headers into Ethernet header */ - ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; - if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ - skb_pull(sub_skb, SNAP_SIZE); - memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); - } else { - u16 len; - /* Leave Ethernet header part of hdr and full payload */ - len = htons(sub_skb->len); - memcpy(skb_push(sub_skb, 2), &len, 2); - memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); - } - - /* Indicat the packets to upper layer */ - if (sub_skb) { - sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev); - memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); - sub_skb->dev = ieee->dev; - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ - ieee->last_rx_ps_time = jiffies; - netif_rx(sub_skb); - } - } - kfree(prxb); - prxb = NULL; - } -} - - -void RxReorderIndicatePacket( struct ieee80211_device *ieee, - struct ieee80211_rxb* prxb, - PRX_TS_RECORD pTS, - u16 SeqNum) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - PRX_REORDER_ENTRY pReorderEntry = NULL; - struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; - u8 WinSize = pHTInfo->RxReorderWinSize; - u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; - u8 index = 0; - bool bMatchWinStart = false, bPktInBuf = false; - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize); - - /* Rx Reorder initialize condition.*/ - if(pTS->RxIndicateSeq == 0xffff) { - pTS->RxIndicateSeq = SeqNum; - } - - /* Drop out the packet which SeqNum is smaller than WinStart */ - if(SN_LESS(SeqNum, pTS->RxIndicateSeq)) { - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); - pHTInfo->RxReorderDropCounter++; - { - int i; - for(i =0; i < prxb->nr_subframes; i++) { - dev_kfree_skb(prxb->subframes[i]); - } - kfree(prxb); - prxb = NULL; - } - return; - } - - /* - * Sliding window manipulation. Conditions includes: - * 1. Incoming SeqNum is equal to WinStart =>Window shift 1 - * 2. Incoming SeqNum is larger than the WinEnd => Window shift N - */ - if(SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) { - pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; - bMatchWinStart = true; - } else if(SN_LESS(WinEnd, SeqNum)) { - if(SeqNum >= (WinSize - 1)) { - pTS->RxIndicateSeq = SeqNum + 1 -WinSize; - } else { - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; - } - IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); - } - - /* - * Indication process. - * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets - * with the SeqNum smaller than latest WinStart and buffer other packets. - */ - /* For Rx Reorder condition: - * 1. All packets with SeqNum smaller than WinStart => Indicate - * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. - */ - if(bMatchWinStart) { - /* Current packet is going to be indicated.*/ - IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ - pTS->RxIndicateSeq, SeqNum); - prxbIndicateArray[0] = prxb; - index = 1; - } else { - /* Current packet is going to be inserted into pending list.*/ - if(!list_empty(&ieee->RxReorder_Unused_List)) { - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List); - list_del_init(&pReorderEntry->List); - - /* Make a reorder entry and insert into a the packet list.*/ - pReorderEntry->SeqNum = SeqNum; - pReorderEntry->prxb = prxb; - - if(!AddReorderEntry(pTS, pReorderEntry)) { - IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __FUNCTION__, pTS->RxIndicateSeq, SeqNum); - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); - { - int i; - for(i =0; i < prxb->nr_subframes; i++) { - dev_kfree_skb(prxb->subframes[i]); - } - kfree(prxb); - prxb = NULL; - } - } else { - IEEE80211_DEBUG(IEEE80211_DL_REORDER, - "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); - } - } - else { - /* - * Packets are dropped if there is not enough reorder entries. - * This part shall be modified!! We can just indicate all the - * packets in buffer and get reorder entries. - */ - IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); - { - int i; - for(i =0; i < prxb->nr_subframes; i++) { - dev_kfree_skb(prxb->subframes[i]); - } - kfree(prxb); - prxb = NULL; - } - } - } - - /* Check if there is any packet need indicate.*/ - while(!list_empty(&pTS->RxPendingPktList)) { - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__FUNCTION__); -#if 1 - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - { - /* This protect buffer from overflow. */ - if(index >= REORDER_WIN_SIZE) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); - bPktInBuf = true; - break; - } - - list_del_init(&pReorderEntry->List); - - if(SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; - - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); - prxbIndicateArray[index] = pReorderEntry->prxb; - index++; - - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); - } else { - bPktInBuf = true; - break; - } -#endif - } - - /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ - if(index>0) { - // Cancel previous pending timer. - if (timer_pending(&pTS->RxPktPendingTimer)) - del_timer_sync(&pTS->RxPktPendingTimer); - pTS->RxTimeoutIndicateSeq = 0xffff; - - // Indicate packets - if(index>REORDER_WIN_SIZE){ - IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); - return; - } - ieee80211_indicate_packets(ieee, prxbIndicateArray, index); - bPktInBuf = false; - } - - if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { - // Set new pending timer. - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__); - pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; - - mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime)); - } -} - -u8 parse_subframe(struct ieee80211_device* ieee,struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, - struct ieee80211_rxb *rxb,u8* src,u8* dst) -{ - struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr* )skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); - - u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr); - u16 ChkLength; - bool bIsAggregateFrame = false; - u16 nSubframe_Length; - u8 nPadding_Length = 0; - u16 SeqNum=0; - - struct sk_buff *sub_skb; - u8 *data_ptr; - /* just for debug purpose */ - SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); - - if((IEEE80211_QOS_HAS_SEQ(fc))&&\ - (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) { - bIsAggregateFrame = true; - } - - if(IEEE80211_QOS_HAS_SEQ(fc)) { - LLCOffset += 2; - } - - if(rx_stats->bContainHTC) { - LLCOffset += sHTCLng; - } - // Null packet, don't indicate it to upper layer - ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ - - if( skb->len <= ChkLength ) { - return 0; - } - - skb_pull(skb, LLCOffset); - ieee->bIsAggregateFrame = bIsAggregateFrame;//added by amy for Leisure PS - - if(!bIsAggregateFrame) { - rxb->nr_subframes = 1; -#ifdef JOHN_NOCPY - rxb->subframes[0] = skb; -#else - rxb->subframes[0] = skb_copy(skb, GFP_ATOMIC); -#endif - - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); - //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len); - return 1; - } else { - rxb->nr_subframes = 0; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); - while(skb->len > ETHERNET_HEADER_SIZE) { - /* Offset 12 denote 2 mac address */ - nSubframe_Length = *((u16*)(skb->data + 12)); - //==m==>change the length order - nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8); - - if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { - printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ - __FUNCTION__,rxb->nr_subframes); - printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length); - printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); - printk("The Packet SeqNum is %d\n",SeqNum); - return 0; - } - - /* move the data point to data content */ - skb_pull(skb, ETHERNET_HEADER_SIZE); - -#ifdef JOHN_NOCPY - sub_skb = skb_clone(skb, GFP_ATOMIC); - sub_skb->len = nSubframe_Length; - sub_skb->tail = sub_skb->data + nSubframe_Length; -#else - /* Allocate new skb for releasing to upper layer */ - sub_skb = dev_alloc_skb(nSubframe_Length + 12); - skb_reserve(sub_skb, 12); - data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); - memcpy(data_ptr,skb->data,nSubframe_Length); -#endif - rxb->subframes[rxb->nr_subframes++] = sub_skb; - if(rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { - IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); - break; - } - skb_pull(skb,nSubframe_Length); - - if(skb->len != 0) { - nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4); - if(nPadding_Length == 4) { - nPadding_Length = 0; - } - - if(skb->len < nPadding_Length) { - return 0; - } - - skb_pull(skb,nPadding_Length); - } - } -#ifdef JOHN_NOCPY - dev_kfree_skb(skb); -#endif - return rxb->nr_subframes; - } -} - -/* All received frames are sent to this function. @skb contains the frame in - * IEEE 802.11 format, i.e., in the format it was sent over air. - * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats) -{ - struct net_device *dev = ieee->dev; - struct ieee80211_hdr_4addr *hdr; - - size_t hdrlen; - u16 fc, type, stype, sc; - struct net_device_stats *stats; - unsigned int frag; - u8 *payload; - u16 ethertype; - //added by amy for reorder - u8 TID = 0; - u16 SeqNum = 0; - PRX_TS_RECORD pTS = NULL; - bool unicast_packet = false; - //added by amy for reorder -#ifdef NOT_YET - struct net_device *wds = NULL; - struct sk_buff *skb2 = NULL; - struct net_device *wds = NULL; - int frame_authorized = 0; - int from_assoc_ap = 0; - void *sta = NULL; -#endif - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 bssid[ETH_ALEN]; - struct ieee80211_crypt_data *crypt = NULL; - int keyidx = 0; - - int i; - struct ieee80211_rxb* rxb = NULL; - // cheat the the hdr type - hdr = (struct ieee80211_hdr_4addr *)skb->data; - stats = &ieee->stats; - - if (skb->len < 10) { - printk(KERN_INFO "%s: SKB length < 10\n", - dev->name); - goto rx_dropped; - } - - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - stype = WLAN_FC_GET_STYPE(fc); - sc = le16_to_cpu(hdr->seq_ctl); - - frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); - - if(HTCCheck(ieee, skb->data)) - { - if(net_ratelimit()) - printk("find HTCControl\n"); - hdrlen += 4; - rx_stats->bContainHTC = 1; - } - -#ifdef NOT_YET -#if WIRELESS_EXT > 15 - /* Put this code here so that we avoid duplicating it in all - * Rx paths. - Jean II */ -#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */ - /* If spy monitoring on */ - if (iface->spy_data.spy_number > 0) { - struct iw_quality wstats; - wstats.level = rx_stats->rssi; - wstats.noise = rx_stats->noise; - wstats.updated = 6; /* No qual value */ - /* Update spy records */ - wireless_spy_update(dev, hdr->addr2, &wstats); - } -#endif /* IW_WIRELESS_SPY */ -#endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); -#endif - -#if WIRELESS_EXT > 15 - if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); - stats->rx_packets++; - stats->rx_bytes += skb->len; - return 1; - } -#endif - if (ieee->host_decrypt) { - int idx = 0; - if (skb->len >= hdrlen + 3) - idx = skb->data[hdrlen + 3] >> 6; - crypt = ieee->crypt[idx]; -#ifdef NOT_YET - sta = NULL; - - /* Use station specific key to override default keys if the - * receiver address is a unicast address ("individual RA"). If - * bcrx_sta_key parameter is set, station specific key is used - * even with broad/multicast targets (this is against IEEE - * 802.11, but makes it easier to use different keys with - * stations that do not support WEP key mapping). */ - - if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, - &sta); -#endif - - /* allow NULL decrypt to indicate an station specific override - * for default encryption */ - if (crypt && (crypt->ops == NULL || - crypt->ops->decrypt_mpdu == NULL)) - crypt = NULL; - - if (!crypt && (fc & IEEE80211_FCTL_WEP)) { - /* This seems to be triggered by some (multicast?) - * frames from other than current BSS, so just drop the - * frames silently instead of filling system log with - * these reports. */ - IEEE80211_DEBUG_DROP("Decryption failed (not set)" - " (SA=%pM)\n", - hdr->addr2); - ieee->ieee_stats.rx_discards_undecryptable++; - goto rx_dropped; - } - } - - if (skb->len < IEEE80211_DATA_HDR3_LEN) - goto rx_dropped; - - // if QoS enabled, should check the sequence for each of the AC - if( (ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)){ - if (is_duplicate_packet(ieee, hdr)) - goto rx_dropped; - - } - else - { - PRX_TS_RECORD pRxTS = NULL; - - if(GetTs( - ieee, - (PTS_COMMON_INFO*) &pRxTS, - hdr->addr2, - (u8)Frame_QoSTID((u8*)(skb->data)), - RX_DIR, - true)) - { - - if( (fc & (1<<11)) && - (frag == pRxTS->RxLastFragNum) && - (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) ) - { - goto rx_dropped; - } - else - { - pRxTS->RxLastFragNum = frag; - pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); - } - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__FUNCTION__); - goto rx_dropped; - } - } - - if (type == IEEE80211_FTYPE_MGMT) { - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) - goto rx_dropped; - else - goto rx_exit; - } - - /* Data frame - extract src/dst addresses */ - switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { - case IEEE80211_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); - break; - case IEEE80211_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); - break; - case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: - if (skb->len < IEEE80211_DATA_HDR4_LEN) - goto rx_dropped; - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); - break; - case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); - break; - } - -#ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) - goto rx_dropped; - if (wds) { - skb->dev = dev = wds; - stats = hostap_get_stats(dev); - } - - if (ieee->iw_mode == IW_MODE_MASTER && !wds && - (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS && - ieee->stadev && - memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { - /* Frame from BSSID of the AP for which we are a client */ - skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); - from_assoc_ap = 1; - } -#endif - - dev->last_rx = jiffies; - -#ifdef NOT_YET - if ((ieee->iw_mode == IW_MODE_MASTER || - ieee->iw_mode == IW_MODE_REPEAT) && - !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, - wds != NULL)) { - case AP_RX_CONTINUE_NOT_AUTHORIZED: - frame_authorized = 0; - break; - case AP_RX_CONTINUE: - frame_authorized = 1; - break; - case AP_RX_DROP: - goto rx_dropped; - case AP_RX_EXIT: - goto rx_exit; - } - } -#endif - /* Nullfunc frames may have PS-bit set, so they must be passed to - * hostap_handle_sta_rx() before being dropped here. */ - if (stype != IEEE80211_STYPE_DATA && - stype != IEEE80211_STYPE_DATA_CFACK && - stype != IEEE80211_STYPE_DATA_CFPOLL && - stype != IEEE80211_STYPE_DATA_CFACKPOLL&& - stype != IEEE80211_STYPE_QOS_DATA//add by David,2006.8.4 - ) { - if (stype != IEEE80211_STYPE_NULLFUNC) - IEEE80211_DEBUG_DROP( - "RX: dropped data frame " - "with no data (type=0x%02x, " - "subtype=0x%02x, len=%d)\n", - type, stype, skb->len); - goto rx_dropped; - } - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) - goto rx_dropped; - -#ifdef ENABLE_LPS - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == 1) - && (ieee->polling)) { - if (WLAN_FC_MORE_DATA(fc)) { - /* more data bit is set, let's request a new frame from the AP */ - ieee80211_sta_ps_send_pspoll_frame(ieee); - } else { - ieee->polling = false; - } - } -#endif - - ieee->need_sw_enc = 0; - - if((!rx_stats->Decrypted)){ - ieee->need_sw_enc = 1; - } - - /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ - - if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) - { - printk("decrypt frame error\n"); - goto rx_dropped; - } - - - hdr = (struct ieee80211_hdr_4addr *) skb->data; - - /* skb: hdr + (possibly fragmented) plaintext payload */ - // PR: FIXME: hostap has additional conditions in the "if" below: - // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { - int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); - IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); - - if (!frag_skb) { - IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG, - "Rx cannot get skb from fragment " - "cache (morefrag=%d seq=%u frag=%u)\n", - (fc & IEEE80211_FCTL_MOREFRAGS) != 0, - WLAN_GET_SEQ_SEQ(sc), frag); - goto rx_dropped; - } - flen = skb->len; - if (frag != 0) - flen -= hdrlen; - - if (frag_skb->tail + flen > frag_skb->end) { - printk(KERN_WARNING "%s: host decrypted and " - "reassembled frame did not fit skb\n", - dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); - goto rx_dropped; - } - - if (frag == 0) { - /* copy first fragment (including full headers) into - * beginning of the fragment cache skb */ - memcpy(skb_put(frag_skb, flen), skb->data, flen); - } else { - /* append frame payload to the end of the fragment - * cache skb */ - memcpy(skb_put(frag_skb, flen), skb->data + hdrlen, - flen); - } - dev_kfree_skb_any(skb); - skb = NULL; - - if (fc & IEEE80211_FCTL_MOREFRAGS) { - /* more fragments expected - leave the skb in fragment - * cache for now; it will be delivered to upper layers - * after all fragments have been received */ - goto rx_exit; - } - - /* this was the last fragment and the frame will be - * delivered, so remove skb from fragment cache */ - skb = frag_skb; - hdr = (struct ieee80211_hdr_4addr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); - } - - /* skb: hdr + (possible reassembled) full MSDU payload; possibly still - * encrypted/authenticated */ - if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) - { - printk("==>decrypt msdu error\n"); - goto rx_dropped; - } - - //added by amy for AP roaming - ieee->LinkDetectInfo.NumRecvDataInPeriod++; - ieee->LinkDetectInfo.NumRxOkInPeriod++; - - hdr = (struct ieee80211_hdr_4addr *) skb->data; - if((!is_multicast_ether_addr(hdr->addr1)) && (!is_broadcast_ether_addr(hdr->addr1))) - unicast_packet = true; - - if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { - if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { - -#ifdef CONFIG_IEEE80211_DEBUG - /* pass unencrypted EAPOL frames even if encryption is - * configured */ - struct eapol *eap = (struct eapol *)(skb->data + - 24); - IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); -#endif - } else { - IEEE80211_DEBUG_DROP( - "encryption configured, but RX " - "frame not encrypted (SA=%pM)\n", - hdr->addr2); - goto rx_dropped; - } - } - -#ifdef CONFIG_IEEE80211_DEBUG - if (crypt && !(fc & IEEE80211_FCTL_WEP) && - ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { - struct eapol *eap = (struct eapol *)(skb->data + - 24); - IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); - } -#endif - - if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { - IEEE80211_DEBUG_DROP( - "dropped unencrypted RX data " - "frame from %pM" - " (drop_unencrypted=1)\n", - hdr->addr2); - goto rx_dropped; - } -//added by amy for reorder - if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) - && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1)) - { - TID = Frame_QoSTID(skb->data); - SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true); - if(TID !=0 && TID !=3) - { - ieee->bis_any_nonbepkts = true; - } - } - -//added by amy for reorder - /* skb: hdr + (possible reassembled) full plaintext payload */ - payload = skb->data + hdrlen; - - rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC); - if(rxb == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__FUNCTION__); - goto rx_dropped; - } - /* to parse amsdu packets */ - /* qos data packets & reserved bit is 1 */ - if(parse_subframe(ieee, skb,rx_stats,rxb,src,dst) == 0) { - /* only to free rxb, and not submit the packets to upper layer */ - for(i =0; i < rxb->nr_subframes; i++) { - dev_kfree_skb(rxb->subframes[i]); - } - kfree(rxb); - rxb = NULL; - goto rx_dropped; - } - -#ifdef ENABLE_LPS - if(unicast_packet) - { - if (type == IEEE80211_FTYPE_DATA) - { - - if(ieee->bIsAggregateFrame) - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod+=rxb->nr_subframes; - else - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod++; - - // 2009.03.03 Leave DC mode immediately when detect high traffic - if((ieee->state == IEEE80211_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) - { - if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { - if(ieee->LeisurePSLeave) - ieee->LeisurePSLeave(ieee); - } - } - } - } -#endif - - ieee->last_rx_ps_time = jiffies; -//added by amy for reorder - if(ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL){ -//added by amy for reorder - for(i = 0; inr_subframes; i++) { - struct sk_buff *sub_skb = rxb->subframes[i]; - - if (sub_skb) { - /* convert hdr + possible LLC headers into Ethernet header */ - ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; - if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ - skb_pull(sub_skb, SNAP_SIZE); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); - } else { - u16 len; - /* Leave Ethernet header part of hdr and full payload */ - len = htons(sub_skb->len); - memcpy(skb_push(sub_skb, 2), &len, 2); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); - } - - stats->rx_packets++; - stats->rx_bytes += sub_skb->len; - if(is_multicast_ether_addr(dst)) { - stats->multicast++; - } - - /* Indicat the packets to upper layer */ - sub_skb->protocol = eth_type_trans(sub_skb, dev); - memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); - sub_skb->dev = dev; - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ - netif_rx(sub_skb); - } - } - kfree(rxb); - rxb = NULL; - - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__); - RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); - } -#ifndef JOHN_NOCPY - dev_kfree_skb(skb); -#endif - - rx_exit: -#ifdef NOT_YET - if (sta) - hostap_handle_sta_release(sta); -#endif - return 1; - - rx_dropped: - kfree(rxb); - rxb = NULL; - stats->rx_dropped++; - - /* Returning 0 indicates to caller that we have not handled the SKB-- - * so it is still allocated and can be used again by underlying - * hardware as a DMA target */ - return 0; -} - -#define MGMT_FRAME_FIXED_PART_LENGTH 0x24 - -static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; - -/* -* Make the structure we read from the beacon packet to have -* the right values -*/ -static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element - *info_element, int sub_type) -{ - - if (info_element->qui_subtype != sub_type) - return -1; - if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) - return -1; - if (info_element->qui_type != QOS_OUI_TYPE) - return -1; - if (info_element->version != QOS_VERSION_1) - return -1; - - return 0; -} - - -/* - * Parse a QoS parameter element - */ -static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info - *element_param, struct ieee80211_info_element - *info_element) -{ - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; - - if ((info_element == NULL) || (element_param == NULL)) - return -1; - - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = ieee80211_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; -} - -/* - * Parse a QoS information element - */ -static int ieee80211_read_qos_info_element(struct - ieee80211_qos_information_element - *element_info, struct ieee80211_info_element - *info_element) -{ - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_information_element) - 2; - - if (element_info == NULL) - return -1; - if (info_element == NULL) - return -1; - - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; - - if (ret == 0) - ret = ieee80211_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; -} - - -/* - * Write QoS parameters from the ac parameters. - */ -static int ieee80211_qos_convert_ac_to_parameters(struct - ieee80211_qos_parameter_info - *param_elm, struct - ieee80211_qos_parameters - *qos_param) -{ - int rc = 0; - int i; - struct ieee80211_qos_ac_parameter *ac_params; - u8 aci; - - for (i = 0; i < QOS_QUEUE_NUM; i++) { - ac_params = &(param_elm->ac_params_record[i]); - - aci = (ac_params->aci_aifsn & 0x60) >> 5; - - if(aci >= QOS_QUEUE_NUM) - continue; - qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; - - /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; - - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; - - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; - - qos_param->flag[aci] = - (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); - } - return rc; -} - -/* - * we have a generic data element which it may contain QoS information or - * parameters element. check the information element length to decide - * which type to read - */ -static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element - *info_element, - struct ieee80211_network *network) -{ - int rc = 0; - struct ieee80211_qos_parameters *qos_param = NULL; - struct ieee80211_qos_information_element qos_info_element; - - rc = ieee80211_read_qos_info_element(&qos_info_element, info_element); - - if (rc == 0) { - network->qos_data.param_count = qos_info_element.ac_info & 0x0F; - network->flags |= NETWORK_HAS_QOS_INFORMATION; - } else { - struct ieee80211_qos_parameter_info param_element; - - rc = ieee80211_read_qos_param_element(¶m_element, - info_element); - if (rc == 0) { - qos_param = &(network->qos_data.parameters); - ieee80211_qos_convert_ac_to_parameters(¶m_element, - qos_param); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } - } - - if (rc == 0) { - IEEE80211_DEBUG_QOS("QoS is supported\n"); - network->qos_data.supported = 1; - } - return rc; -} - -#ifdef CONFIG_IEEE80211_DEBUG -#define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x - -static const char *get_info_element_string(u16 id) -{ - switch (id) { - MFIE_STRING(SSID); - MFIE_STRING(RATES); - MFIE_STRING(FH_SET); - MFIE_STRING(DS_SET); - MFIE_STRING(CF_SET); - MFIE_STRING(TIM); - MFIE_STRING(IBSS_SET); - MFIE_STRING(COUNTRY); - MFIE_STRING(HOP_PARAMS); - MFIE_STRING(HOP_TABLE); - MFIE_STRING(REQUEST); - MFIE_STRING(CHALLENGE); - MFIE_STRING(POWER_CONSTRAINT); - MFIE_STRING(POWER_CAPABILITY); - MFIE_STRING(TPC_REQUEST); - MFIE_STRING(TPC_REPORT); - MFIE_STRING(SUPP_CHANNELS); - MFIE_STRING(CSA); - MFIE_STRING(MEASURE_REQUEST); - MFIE_STRING(MEASURE_REPORT); - MFIE_STRING(QUIET); - MFIE_STRING(IBSS_DFS); - // MFIE_STRING(ERP_INFO); - MFIE_STRING(RSN); - MFIE_STRING(RATES_EX); - MFIE_STRING(GENERIC); - MFIE_STRING(QOS_PARAMETER); - default: - return "UNKNOWN"; - } -} -#endif - -#ifdef ENABLE_DOT11D -static inline void ieee80211_extract_country_ie( - struct ieee80211_device *ieee, - struct ieee80211_info_element *info_element, - struct ieee80211_network *network, - u8 * addr2 -) -{ - if(IS_DOT11D_ENABLE(ieee)) - { - if(info_element->len!= 0) - { - memcpy(network->CountryIeBuf, info_element->data, info_element->len); - network->CountryIeLen = info_element->len; - - if(!IS_COUNTRY_IE_VALID(ieee)) - { - Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); - } - } - - // - // 070305, rcnjko: I update country IE watch dog here because - // some AP (e.g. Cisco 1242) don't include country IE in their - // probe response frame. - // - if(IS_EQUAL_CIE_SRC(ieee, addr2) ) - { - UPDATE_CIE_WATCHDOG(ieee); - } - } - -} -#endif - -int ieee80211_parse_info_param(struct ieee80211_device *ieee, - struct ieee80211_info_element *info_element, - u16 length, - struct ieee80211_network *network, - struct ieee80211_rx_stats *stats) -{ - u8 i; - short offset; - u16 tmp_htcap_len=0; - u16 tmp_htinfo_len=0; - u16 ht_realtek_agg_len=0; - u8 ht_realtek_agg_buf[MAX_IE_LEN]; -#ifdef CONFIG_IEEE80211_DEBUG - char rates_str[64]; - char *p; -#endif - - while (length >= sizeof(*info_element)) { - if (sizeof(*info_element) + info_element->len > length) { - IEEE80211_DEBUG_MGMT("Info elem: parse failed: " - "info_element->len + 2 > left : " - "info_element->len+2=%zd left=%d, id=%d.\n", - info_element->len + - sizeof(*info_element), - length, info_element->id); - /* We stop processing but don't return an error here - * because some misbehaviour APs break this rule. ie. - * Orinoco AP1000. */ - break; - } - - switch (info_element->id) { - case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, - info_element->len)) { - network->flags |= NETWORK_EMPTY_ESSID; - break; - } - - network->ssid_len = min(info_element->len, - (u8) IW_ESSID_MAX_SIZE); - memcpy(network->ssid, info_element->data, network->ssid_len); - if (network->ssid_len < IW_ESSID_MAX_SIZE) - memset(network->ssid + network->ssid_len, 0, - IW_ESSID_MAX_SIZE - network->ssid_len); - - IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n", - network->ssid, network->ssid_len); - break; - - case MFIE_TYPE_RATES: -#ifdef CONFIG_IEEE80211_DEBUG - p = rates_str; -#endif - network->rates_len = min(info_element->len, - MAX_RATES_LENGTH); - for (i = 0; i < network->rates_len; i++) { - network->rates[i] = info_element->data[i]; -#ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - - (p - rates_str), "%02X ", - network->rates[i]); -#endif - if (ieee80211_is_ofdm_rate - (info_element->data[i])) { - network->flags |= NETWORK_HAS_OFDM; - if (info_element->data[i] & - IEEE80211_BASIC_RATE_MASK) - network->flags &= - ~NETWORK_HAS_CCK; - } - } - - IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n", - rates_str, network->rates_len); - break; - - case MFIE_TYPE_RATES_EX: -#ifdef CONFIG_IEEE80211_DEBUG - p = rates_str; -#endif - network->rates_ex_len = min(info_element->len, - MAX_RATES_EX_LENGTH); - for (i = 0; i < network->rates_ex_len; i++) { - network->rates_ex[i] = info_element->data[i]; -#ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - - (p - rates_str), "%02X ", - network->rates[i]); -#endif - if (ieee80211_is_ofdm_rate - (info_element->data[i])) { - network->flags |= NETWORK_HAS_OFDM; - if (info_element->data[i] & - IEEE80211_BASIC_RATE_MASK) - network->flags &= - ~NETWORK_HAS_CCK; - } - } - - IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n", - rates_str, network->rates_ex_len); - break; - - case MFIE_TYPE_DS_SET: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n", - info_element->data[0]); - network->channel = info_element->data[0]; - break; - - case MFIE_TYPE_FH_SET: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n"); - break; - - case MFIE_TYPE_CF_SET: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n"); - break; - - case MFIE_TYPE_TIM: - if(info_element->len < 4) - break; - - network->tim.tim_count = info_element->data[0]; - network->tim.tim_period = info_element->data[1]; - - network->dtim_period = info_element->data[1]; - if(ieee->state != IEEE80211_LINKED) - break; - //we use jiffies for legacy Power save - network->last_dtim_sta_time[0] = jiffies; - network->last_dtim_sta_time[1] = stats->mac_time[1]; - - network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) - break; - - if(info_element->data[2] & 1) - network->dtim_data |= IEEE80211_DTIM_MBCAST; - - offset = (info_element->data[2] >> 1)*2; - - if(ieee->assoc_id < 8*offset || - ieee->assoc_id > 8*(offset + info_element->len -3)) - - break; - - offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ; - - if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) - network->dtim_data |= IEEE80211_DTIM_UCAST; - - break; - - case MFIE_TYPE_ERP: - network->erp_value = info_element->data[0]; - network->flags |= NETWORK_HAS_ERP_VALUE; - IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n", - network->erp_value); - break; - case MFIE_TYPE_IBSS_SET: - network->atim_window = info_element->data[0]; - IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n", - network->atim_window); - break; - - case MFIE_TYPE_CHALLENGE: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n"); - break; - - case MFIE_TYPE_GENERIC: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n", - info_element->len); - if (!ieee80211_parse_qos_info_param_IE(info_element, - network)) - break; - - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x01) { - network->wpa_ie_len = min(info_element->len + 2, - MAX_WPA_IE_LEN); - memcpy(network->wpa_ie, info_element, - network->wpa_ie_len); - break; - } - -#ifdef THOMAS_TURBO - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) { - network->Turbo_Enable = 1; - } -#endif - - //for HTcap and HTinfo parameters - if(tmp_htcap_len == 0){ - if(info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x033){ - - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if(tmp_htcap_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); - } - } - if(tmp_htcap_len != 0) - network->bssht.bdSupportHT = true; - else - network->bssht.bdSupportHT = false; - } - - - if(tmp_htinfo_len == 0){ - if(info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034){ - - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if(tmp_htinfo_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - if(tmp_htinfo_len){ - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); - } - - } - - } - } - - if(ieee->aggregation){ - if(network->bssht.bdSupportHT){ - if(info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02){ - - ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN); - memcpy(ht_realtek_agg_buf,info_element->data,info_element->len); - - } - if(ht_realtek_agg_len >= 5){ - network->bssht.bdRT2RTAggregation = true; - - if((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; - } - } - - } - - if((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x05 && - info_element->data[2] == 0xb5) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf7) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x10 && - info_element->data[2] == 0x18)){ - - network->broadcom_cap_exist = true; - - } - - if(info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0c && - info_element->data[2] == 0x43) - { - network->ralink_cap_exist = true; - } - else - network->ralink_cap_exist = false; - //added by amy for atheros AP - if((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x03 && - info_element->data[2] == 0x7f) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x13 && - info_element->data[2] == 0x74)) - { - network->atheros_cap_exist = true; - } - else - network->atheros_cap_exist = false; - - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0x43) ) - { - network->marvell_cap_exist = true; - } - - - if(info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96) - { - network->cisco_cap_exist = true; - } - else - network->cisco_cap_exist = false; - //added by amy for LEAP of cisco - if(info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x01) - { - if(info_element->len == 6) - { - memcpy(network->CcxRmState, &info_element[4], 2); - if(network->CcxRmState[0] != 0) - { - network->bCcxRmEnable = true; - } - else - network->bCcxRmEnable = false; - // - // CCXv4 Table 59-1 MBSSID Masks. - // - network->MBssidMask = network->CcxRmState[1] & 0x07; - if(network->MBssidMask != 0) - { - network->bMBssidValid = true; - network->MBssidMask = 0xff << (network->MBssidMask); - cpMacAddr(network->MBssid, network->bssid); - network->MBssid[5] &= network->MBssidMask; - } - else - { - network->bMBssidValid = false; - } - } - else - { - network->bCcxRmEnable = false; - } - } - if(info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x03) - { - if(info_element->len == 5) - { - network->bWithCcxVerNum = true; - network->BssCcxVerNumber = info_element->data[4]; - } - else - { - network->bWithCcxVerNum = false; - network->BssCcxVerNumber = 0; - } - } - break; - - case MFIE_TYPE_RSN: - IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n", - info_element->len); - network->rsn_ie_len = min(info_element->len + 2, - MAX_WPA_IE_LEN); - memcpy(network->rsn_ie, info_element, - network->rsn_ie_len); - break; - - //HT related element. - case MFIE_TYPE_HT_CAP: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", - info_element->len); - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if(tmp_htcap_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); - - //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT() - // windows driver will update WMM parameters each beacon received once connected - // Linux driver is a bit different. - network->bssht.bdSupportHT = true; - } - else - network->bssht.bdSupportHT = false; - break; - - - case MFIE_TYPE_HT_INFO: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", - info_element->len); - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if(tmp_htinfo_len){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); - } - break; - - case MFIE_TYPE_AIRONET: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", - info_element->len); - if(info_element->len >IE_CISCO_FLAG_POSITION) - { - network->bWithAironetIE = true; - - // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23): - // "A Cisco access point advertises support for CKIP in beacon and probe response packets, - // by adding an Aironet element and setting one or both of the CKIP negotiation bits." - if( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || - (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) - { - network->bCkipSupported = true; - } - else - { - network->bCkipSupported = false; - } - } - else - { - network->bWithAironetIE = false; - network->bCkipSupported = false; - } - break; - case MFIE_TYPE_QOS_PARAMETER: - printk(KERN_ERR - "QoS Error need to parse QOS_PARAMETER IE\n"); - break; - -#ifdef ENABLE_DOT11D - case MFIE_TYPE_COUNTRY: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", - info_element->len); - ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP - break; -#endif - - default: - IEEE80211_DEBUG_MGMT - ("Unsupported info element: %s (%d)\n", - get_info_element_string(info_element->id), - info_element->id); - break; - } - - length -= sizeof(*info_element) + info_element->len; - info_element = - (struct ieee80211_info_element *)&info_element-> - data[info_element->len]; - } - - if(!network->atheros_cap_exist && !network->broadcom_cap_exist && - !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation && - !network->marvell_cap_exist) - { - network->unknown_cap_exist = true; - } - else - { - network->unknown_cap_exist = false; - } - return 0; -} - -static inline u8 ieee80211_SignalStrengthTranslate( - u8 CurrSS - ) -{ - u8 RetSS; - - // Step 1. Scale mapping. - if(CurrSS >= 71 && CurrSS <= 100) - { - RetSS = 90 + ((CurrSS - 70) / 3); - } - else if(CurrSS >= 41 && CurrSS <= 70) - { - RetSS = 78 + ((CurrSS - 40) / 3); - } - else if(CurrSS >= 31 && CurrSS <= 40) - { - RetSS = 66 + (CurrSS - 30); - } - else if(CurrSS >= 21 && CurrSS <= 30) - { - RetSS = 54 + (CurrSS - 20); - } - else if(CurrSS >= 5 && CurrSS <= 20) - { - RetSS = 42 + (((CurrSS - 5) * 2) / 3); - } - else if(CurrSS == 4) - { - RetSS = 36; - } - else if(CurrSS == 3) - { - RetSS = 27; - } - else if(CurrSS == 2) - { - RetSS = 18; - } - else if(CurrSS == 1) - { - RetSS = 9; - } - else - { - RetSS = CurrSS; - } - - return RetSS; -} - -long ieee80211_translate_todbm(u8 signal_strength_index )// 0-100 index. -{ - long signal_power; // in dBm. - - // Translate to dBm (x=0.5y-95). - signal_power = (long)((signal_strength_index + 1) >> 1); - signal_power -= 95; - - return signal_power; -} - -static inline int ieee80211_network_init( - struct ieee80211_device *ieee, - struct ieee80211_probe_response *beacon, - struct ieee80211_network *network, - struct ieee80211_rx_stats *stats) -{ - network->qos_data.active = 0; - network->qos_data.supported = 0; - network->qos_data.param_count = 0; - network->qos_data.old_param_count = 0; - - /* Pull out fixed field data */ - memcpy(network->bssid, beacon->header.addr3, ETH_ALEN); - network->capability = le16_to_cpu(beacon->capability); - network->last_scanned = jiffies; - network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]); - network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]); - network->beacon_interval = le32_to_cpu(beacon->beacon_interval); - /* Where to pull this? beacon->listen_interval;*/ - network->listen_interval = 0x0A; - network->rates_len = network->rates_ex_len = 0; - network->last_associate = 0; - network->ssid_len = 0; - network->flags = 0; - network->atim_window = 0; - network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? - 0x3 : 0x0; - network->berp_info_valid = false; - network->broadcom_cap_exist = false; - network->ralink_cap_exist = false; - network->atheros_cap_exist = false; - network->marvell_cap_exist = false; - network->cisco_cap_exist = false; - network->unknown_cap_exist = false; -#ifdef THOMAS_TURBO - network->Turbo_Enable = 0; -#endif -#ifdef ENABLE_DOT11D - network->CountryIeLen = 0; - memset(network->CountryIeBuf, 0, MAX_IE_LEN); -#endif -//Initialize HT parameters - HTInitializeBssDesc(&network->bssht); - if (stats->freq == IEEE80211_52GHZ_BAND) { - /* for A band (No DS info) */ - network->channel = stats->received_channel; - } else - network->flags |= NETWORK_HAS_CCK; - - network->wpa_ie_len = 0; - network->rsn_ie_len = 0; - - if (ieee80211_parse_info_param - (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats)) - return 1; - - network->mode = 0; - if (stats->freq == IEEE80211_52GHZ_BAND) - network->mode = IEEE_A; - else { - if (network->flags & NETWORK_HAS_OFDM) - network->mode |= IEEE_G; - if (network->flags & NETWORK_HAS_CCK) - network->mode |= IEEE_B; - } - - if (network->mode == 0) { - IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' " - "network.\n", - escape_essid(network->ssid, - network->ssid_len), - network->bssid); - return 1; - } - - if(network->bssht.bdSupportHT){ - if(network->mode == IEEE_A) - network->mode = IEEE_N_5G; - else if(network->mode & (IEEE_G | IEEE_B)) - network->mode = IEEE_N_24G; - } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) - network->flags |= NETWORK_EMPTY_ESSID; - - stats->signal = 30 + (stats->SignalStrength * 70) / 100; - stats->noise = ieee80211_translate_todbm((u8)(100-stats->signal)) -25; - - memcpy(&network->stats, stats, sizeof(network->stats)); - - return 0; -} - -static inline int is_same_network(struct ieee80211_network *src, - struct ieee80211_network *dst, struct ieee80211_device* ieee) -{ - /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. - * We treat all with the same BSSID and channel - * as one network */ - return (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && - (src->channel == dst->channel) && - !memcmp(src->bssid, dst->bssid, ETH_ALEN) && - (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && - ((src->capability & WLAN_CAPABILITY_IBSS) == - (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == - (dst->capability & WLAN_CAPABILITY_BSS))); -} - -static inline void update_network(struct ieee80211_network *dst, - struct ieee80211_network *src) -{ - int qos_active; - u8 old_param; - - memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); - dst->capability = src->capability; - memcpy(dst->rates, src->rates, src->rates_len); - dst->rates_len = src->rates_len; - memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); - dst->rates_ex_len = src->rates_ex_len; - if(src->ssid_len > 0) - { - memset(dst->ssid, 0, dst->ssid_len); - dst->ssid_len = src->ssid_len; - memcpy(dst->ssid, src->ssid, src->ssid_len); - } - dst->mode = src->mode; - dst->flags = src->flags; - dst->time_stamp[0] = src->time_stamp[0]; - dst->time_stamp[1] = src->time_stamp[1]; - if (src->flags & NETWORK_HAS_ERP_VALUE) - { - dst->erp_value = src->erp_value; - dst->berp_info_valid = src->berp_info_valid = true; - } - dst->beacon_interval = src->beacon_interval; - dst->listen_interval = src->listen_interval; - dst->atim_window = src->atim_window; - dst->dtim_period = src->dtim_period; - dst->dtim_data = src->dtim_data; - dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; - dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters)); - - dst->bssht.bdSupportHT = src->bssht.bdSupportHT; - dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; - dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; - memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); - dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen; - memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen); - dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer; - dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime; - dst->broadcom_cap_exist = src->broadcom_cap_exist; - dst->ralink_cap_exist = src->ralink_cap_exist; - dst->atheros_cap_exist = src->atheros_cap_exist; - dst->marvell_cap_exist = src->marvell_cap_exist; - dst->cisco_cap_exist = src->cisco_cap_exist; - dst->unknown_cap_exist = src->unknown_cap_exist; - memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); - dst->wpa_ie_len = src->wpa_ie_len; - memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); - dst->rsn_ie_len = src->rsn_ie_len; - - dst->last_scanned = jiffies; - /* qos related parameters */ - qos_active = dst->qos_data.active; - old_param = dst->qos_data.param_count; - if(dst->flags & NETWORK_HAS_QOS_MASK){ - //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB - } - else { - dst->qos_data.supported = src->qos_data.supported; - dst->qos_data.param_count = src->qos_data.param_count; - } - - if(dst->qos_data.supported == 1) { - dst->QoS_Enable = 1; - if(dst->ssid_len) - IEEE80211_DEBUG_QOS - ("QoS the network %s is QoS supported\n", - dst->ssid); - else - IEEE80211_DEBUG_QOS - ("QoS the network is QoS supported\n"); - } - dst->qos_data.active = qos_active; - dst->qos_data.old_param_count = old_param; - - /* dst->last_associate is not overwritten */ - dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame. - if(src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[3].ac_aci_acm_aifsn) { - memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); - } -#ifdef THOMAS_TURBO - dst->Turbo_Enable = src->Turbo_Enable; -#endif - -#ifdef ENABLE_DOT11D - dst->CountryIeLen = src->CountryIeLen; - memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen); -#endif - - //added by amy for LEAP - dst->bWithAironetIE = src->bWithAironetIE; - dst->bCkipSupported = src->bCkipSupported; - memcpy(dst->CcxRmState,src->CcxRmState,2); - dst->bCcxRmEnable = src->bCcxRmEnable; - dst->MBssidMask = src->MBssidMask; - dst->bMBssidValid = src->bMBssidValid; - memcpy(dst->MBssid,src->MBssid,6); - dst->bWithCcxVerNum = src->bWithCcxVerNum; - dst->BssCcxVerNumber = src->BssCcxVerNumber; - -} - -static inline int is_beacon(__le16 fc) -{ - return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON); -} - -static inline void ieee80211_process_probe_response( - struct ieee80211_device *ieee, - struct ieee80211_probe_response *beacon, - struct ieee80211_rx_stats *stats) -{ - struct ieee80211_network network; - struct ieee80211_network *target; - struct ieee80211_network *oldest = NULL; -#ifdef CONFIG_IEEE80211_DEBUG - struct ieee80211_info_element *info_element = &beacon->info_element[0]; -#endif - unsigned long flags; - short renew; - - memset(&network, 0, sizeof(struct ieee80211_network)); - IEEE80211_DEBUG_SCAN( - "'%s' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", - escape_essid(info_element->data, info_element->len), - beacon->header.addr3, - (beacon->capability & (1<<0xf)) ? '1' : '0', - (beacon->capability & (1<<0xe)) ? '1' : '0', - (beacon->capability & (1<<0xd)) ? '1' : '0', - (beacon->capability & (1<<0xc)) ? '1' : '0', - (beacon->capability & (1<<0xb)) ? '1' : '0', - (beacon->capability & (1<<0xa)) ? '1' : '0', - (beacon->capability & (1<<0x9)) ? '1' : '0', - (beacon->capability & (1<<0x8)) ? '1' : '0', - (beacon->capability & (1<<0x7)) ? '1' : '0', - (beacon->capability & (1<<0x6)) ? '1' : '0', - (beacon->capability & (1<<0x5)) ? '1' : '0', - (beacon->capability & (1<<0x4)) ? '1' : '0', - (beacon->capability & (1<<0x3)) ? '1' : '0', - (beacon->capability & (1<<0x2)) ? '1' : '0', - (beacon->capability & (1<<0x1)) ? '1' : '0', - (beacon->capability & (1<<0x0)) ? '1' : '0'); - - if (ieee80211_network_init(ieee, beacon, &network, stats)) { - IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n", - escape_essid(info_element->data, - info_element->len), - beacon->header.addr3, - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - IEEE80211_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); - return; - } - -#ifdef ENABLE_DOT11D - // For Asus EeePc request, - // (1) if wireless adapter receive get any 802.11d country code in AP beacon, - // wireless adapter should follow the country code. - // (2) If there is no any country code in beacon, - // then wireless adapter should do active scan from ch1~11 and - // passive scan from ch12~14 - - if( !IsLegalChannel(ieee, network.channel) ) - return; - if(ieee->bGlobalDomain) - { - if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP) - { - // Case 1: Country code - if(IS_COUNTRY_IE_VALID(ieee) ) - { - if( !IsLegalChannel(ieee, network.channel) ) - { - printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel); - return; - } - } - // Case 2: No any country code. - else - { - // Filter over channel ch12~14 - if(network.channel > 11) - { - printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network.channel); - return; - } - } - } - else - { - // Case 1: Country code - if(IS_COUNTRY_IE_VALID(ieee) ) - { - if( !IsLegalChannel(ieee, network.channel) ) - { - printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel); - return; - } - } - // Case 2: No any country code. - else - { - // Filter over channel ch12~14 - if(network.channel > 14) - { - printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network.channel); - return; - } - } - } - } -#endif - - /* The network parsed correctly -- so now we scan our known networks - * to see if we can find it in our list. - * - * NOTE: This search is definitely not optimized. Once its doing - * the "right thing" we'll optimize it for efficiency if - * necessary */ - - /* Search for this entry in the list and update it if it is - * already there. */ - - spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network, ieee)) { - update_network(&ieee->current_network, &network); - if((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) - && ieee->current_network.berp_info_valid){ - if(ieee->current_network.erp_value& ERP_UseProtection) - ieee->current_network.buseprotection = true; - else - ieee->current_network.buseprotection = false; - } - if(is_beacon(beacon->header.frame_ctl)) - { - if(ieee->state == IEEE80211_LINKED) - ieee->LinkDetectInfo.NumRecvBcnInPeriod++; - } - else //hidden AP - network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & ieee->current_network.flags); - } - - list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network, ieee)) - break; - if ((oldest == NULL) || - (target->last_scanned < oldest->last_scanned)) - oldest = target; - } - - /* If we didn't find a match, then get a new network slot to initialize - * with this beacon's information */ - if (&target->list == &ieee->network_list) { - if (list_empty(&ieee->network_free_list)) { - /* If there are no more slots, expire the oldest */ - list_del(&oldest->list); - target = oldest; - IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from " - "network list.\n", - escape_essid(target->ssid, - target->ssid_len), - target->bssid); - } else { - /* Otherwise just pull from the free list */ - target = list_entry(ieee->network_free_list.next, - struct ieee80211_network, list); - list_del(ieee->network_free_list.next); - } - - -#ifdef CONFIG_IEEE80211_DEBUG - IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n", - escape_essid(network.ssid, - network.ssid_len), - network.bssid, - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - IEEE80211_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); -#endif - memcpy(target, &network, sizeof(*target)); - list_add_tail(&target->list, &ieee->network_list); - } else { - IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n", - escape_essid(target->ssid, - target->ssid_len), - target->bssid, - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - IEEE80211_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); - - /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new - * net and call the new_net handler - */ - renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - //YJ,add,080819,for hidden ap - if(is_beacon(beacon->header.frame_ctl) == 0) - network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & target->flags); - if(((network.flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \ - && (((network.ssid_len > 0) && (strncmp(target->ssid, network.ssid, network.ssid_len)))\ - ||((ieee->current_network.ssid_len == network.ssid_len)&&(strncmp(ieee->current_network.ssid, network.ssid, network.ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK)))) - renew = 1; - //YJ,add,080819,for hidden ap,end - - update_network(target, &network); - } - - spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, &network, ieee)&&\ - (ieee->state == IEEE80211_LINKED)) { - if(ieee->handle_beacon != NULL) { - ieee->handle_beacon(ieee, beacon, &ieee->current_network); - } - } -} - -void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, - struct ieee80211_rx_stats *stats) -{ - if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && - WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) - ieee->last_rx_ps_time = jiffies; - - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - - case IEEE80211_STYPE_BEACON: - IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( - ieee, (struct ieee80211_probe_response *)header, stats); - - if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && - ieee->state == IEEE80211_LINKED)) - { - tasklet_schedule(&ieee->ps_task); - } - - break; - - case IEEE80211_STYPE_PROBE_RESP: - IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( - ieee, (struct ieee80211_probe_response *)header, stats); - break; - - } -} diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c deleted file mode 100644 index 60e9a09d933..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c +++ /dev/null @@ -1,3278 +0,0 @@ -/* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello - * - * Mostly extracted from the rtl8180-sa2400 driver for the - * in-kernel generic ieee802.11 stack. - * - * Few lines might be stolen from other part of the ieee80211 - * stack. Copyright who own it's copyright - * - * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. - * - * released under the GPL - */ - - -#include "ieee80211.h" - -#include -#include -#include -#include -#ifdef ENABLE_DOT11D -#include "dot11d.h" -#endif - -u8 rsn_authen_cipher_suite[16][4] = { - {0x00,0x0F,0xAC,0x00}, //Use group key, //Reserved - {0x00,0x0F,0xAC,0x01}, //WEP-40 //RSNA default - {0x00,0x0F,0xAC,0x02}, //TKIP //NONE //{used just as default} - {0x00,0x0F,0xAC,0x03}, //WRAP-historical - {0x00,0x0F,0xAC,0x04}, //CCMP - {0x00,0x0F,0xAC,0x05}, //WEP-104 -}; - -short ieee80211_is_54g(struct ieee80211_network net) -{ - return ((net.rates_ex_len > 0) || (net.rates_len > 4)); -} - -short ieee80211_is_shortslot(struct ieee80211_network net) -{ - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); -} - -/* returns the total length needed for pleacing the RATE MFIE - * tag and the EXTENDED RATE MFIE tag if needed. - * It encludes two bytes per tag for the tag itself and its len - */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) -{ - unsigned int rate_len = 0; - - if (ieee->modulation & IEEE80211_CCK_MODULATION) - rate_len = IEEE80211_CCK_RATE_LEN + 2; - - if (ieee->modulation & IEEE80211_OFDM_MODULATION) - - rate_len += IEEE80211_OFDM_RATE_LEN + 2; - - return rate_len; -} - -/* pleace the MFIE rate, tag to the memory (double) poined. - * Then it updates the pointer so that - * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - - if (ieee->modulation & IEEE80211_CCK_MODULATION){ - *tag++ = MFIE_TYPE_RATES; - *tag++ = 4; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - } - - /* We may add an option for custom rates that specific HW might support */ - *tag_p = tag; -} - -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - - if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - - *tag++ = MFIE_TYPE_RATES_EX; - *tag++ = 8; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; - *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - } - - /* We may add an option for custom rates that specific HW might support */ - *tag_p = tag; -} - - -void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - - *tag++ = MFIE_TYPE_GENERIC; //0 - *tag++ = 7; - *tag++ = 0x00; - *tag++ = 0x50; - *tag++ = 0xf2; - *tag++ = 0x02;//5 - *tag++ = 0x00; - *tag++ = 0x01; -#ifdef SUPPORT_USPD - if(ieee->current_network.wmm_info & 0x80) { - *tag++ = 0x0f|MAX_SP_Len; - } else { - *tag++ = MAX_SP_Len; - } -#else - *tag++ = MAX_SP_Len; -#endif - *tag_p = tag; -} - -#ifdef THOMAS_TURBO -void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - - *tag++ = MFIE_TYPE_GENERIC; //0 - *tag++ = 7; - *tag++ = 0x00; - *tag++ = 0xe0; - *tag++ = 0x4c; - *tag++ = 0x01;//5 - *tag++ = 0x02; - *tag++ = 0x11; - *tag++ = 0x00; - - *tag_p = tag; - printk(KERN_ALERT "This is enable turbo mode IE process\n"); -} -#endif - -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) -{ - int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - -/* - * if the queue is full but we have newer frames then - * just overwrites the oldest. - * - * if (nh == ieee->mgmt_queue_tail) - * return -1; - */ - ieee->mgmt_queue_head = nh; - ieee->mgmt_queue_ring[nh] = skb; -} - -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) -{ - struct sk_buff *ret; - - if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) - return NULL; - - ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = - (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - - return ret; -} - -void init_mgmt_queue(struct ieee80211_device *ieee) -{ - ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; -} - -u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - u8 rate; - - // 2008/01/25 MH For broadcom, MGNT frame set as OFDM 6M. - if(pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) - rate = 0x0c; - else - rate = ieee->basic_rate & 0x7f; - - if(rate == 0){ - // 2005.01.26, by rcnjko. - if(ieee->mode == IEEE_A|| - ieee->mode== IEEE_N_5G|| - (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) - rate = 0x0c; - else - rate = 0x02; - } - - return rate; -} - - -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); - -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) -{ - unsigned long flags; - short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header= - (struct ieee80211_hdr_3addr *) skb->data; - - cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); - spin_lock_irqsave(&ieee->lock, flags); - - /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - - tcb_desc->queue_index = MGNT_QUEUE; - tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee); - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - - if(single){ - if(ieee->queue_stop){ - enqueue_mgmt(ieee,skb); - }else{ - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate); - } - - spin_unlock_irqrestore(&ieee->lock, flags); - }else{ - spin_unlock_irqrestore(&ieee->lock, flags); - spin_lock(&ieee->mgmt_tx_lock); - - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - /* check wether the managed packet queued greater than 5 */ - if(!ieee->check_nic_enough_desc(ieee, tcb_desc->queue_index)|| - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)|| - (ieee->queue_stop) ) { - /* insert the skb packet to the management queue */ - /* as for the completion function, it does not need - * to check it any more. - * */ - skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); - } else { - ieee->softmac_hard_start_xmit(skb, ieee); - } - spin_unlock(&ieee->mgmt_tx_lock); - } -} - -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) -{ - - short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); - - tcb_desc->queue_index = MGNT_QUEUE; - tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee); - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - if(single){ - - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate); - - }else{ - - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - ieee->softmac_hard_start_xmit(skb, ieee); - - } -} - -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) -{ - unsigned int len,rate_len; - u8 *tag; - struct sk_buff *skb; - struct ieee80211_probe_request *req; - - len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - - skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + - 2 + len + rate_len + ieee->tx_headroom); - if (!skb) - return NULL; - - skb_reserve(skb, ieee->tx_headroom); - - req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); - req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - - memset(req->header.addr1, 0xff, ETH_ALEN); - memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memset(req->header.addr3, 0xff, ETH_ALEN); - - tag = (u8 *) skb_put(skb,len+2+rate_len); - - *tag++ = MFIE_TYPE_SSID; - *tag++ = len; - memcpy(tag, ieee->current_network.ssid, len); - tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); - return skb; -} - -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - if(!ieee->ieee_up) - return; - - skb = ieee80211_get_beacon_(ieee); - - if (skb){ - softmac_mgmt_xmit(skb, ieee); - ieee->softmac_stats.tx_beacons++; - } - - if(ieee->beacon_txing && ieee->ieee_up){ - mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); - } -} - - -void ieee80211_send_beacon_cb(unsigned long _ieee) -{ - struct ieee80211_device *ieee = - (struct ieee80211_device *) _ieee; - unsigned long flags; - - spin_lock_irqsave(&ieee->beacon_lock, flags); - ieee80211_send_beacon(ieee); - spin_unlock_irqrestore(&ieee->beacon_lock, flags); -} - - -void ieee80211_send_probe(struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); - if (skb){ - softmac_mgmt_xmit(skb, ieee); - ieee->softmac_stats.tx_probe_rq++; - } -} - -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) -{ - if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); - } -} - -/* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. - */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) -{ - short ch = 0; -#ifdef ENABLE_DOT11D - u8 channel_map[MAX_CHANNEL_NUMBER+1]; - memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); -#endif - down(&ieee->scan_sem); - - while(1) - { - - do{ - ch++; - if (ch > MAX_CHANNEL_NUMBER) - goto out; /* scan completed */ -#ifdef ENABLE_DOT11D - }while(!channel_map[ch]); -#else - }while(!ieee->channel_map[ch]); -#endif - - /* this function can be called in two situations - * 1- We have switched to ad-hoc mode and we are - * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is - * IEEE80211_NOLINK until we found an interesting cell. - * If so the ieee8021_new_net, called by the RX path - * will set the state to IEEE80211_LINKED, so we stop - * scanning - * 2- We are linked and the root uses run iwlist scan. - * So we switch to IEEE80211_LINKED_SCANNING to remember - * that we are still logically linked (not interested in - * new network events, despite for updating the net list, - * but we are temporarly 'unlinked' as the driver shall - * not filter RX frames and the channel is changing. - * So the only situation in witch are interested is to check - * if the state become LINKED because of the #1 situation - */ - - if (ieee->state == IEEE80211_LINKED) - goto out; - ieee->set_chan(ieee, ch); -#ifdef ENABLE_DOT11D - if(channel_map[ch] == 1) -#endif - ieee80211_send_probe_requests(ieee); - - /* this prevent excessive time wait when we - * need to wait for a syncro scan to end.. - */ - if(ieee->state < IEEE80211_LINKED) - ; - else - if (ieee->sync_scan_hurryup) - goto out; - - - msleep_interruptible_rsl(IEEE80211_SOFTMAC_SCAN_TIME); - - } -out: - if(ieee->state < IEEE80211_LINKED){ - ieee->actscanning = false; - up(&ieee->scan_sem); - } - else{ - ieee->sync_scan_hurryup = 0; -#ifdef ENABLE_DOT11D - if(IS_DOT11D_ENABLE(ieee)) - DOT11D_ScanComplete(ieee); -#endif - up(&ieee->scan_sem); -} -} - - -void ieee80211_softmac_scan_wq(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work, struct delayed_work, work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); - static short watchdog = 0; - u8 last_channel = ieee->current_network.channel; -#ifdef ENABLE_DOT11D - u8 channel_map[MAX_CHANNEL_NUMBER+1]; - memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); -#endif - if(!ieee->ieee_up) - return; - down(&ieee->scan_sem); - do{ - ieee->current_network.channel = - (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) { - /* if current channel is not in channel map, set to default channel. */ -#ifdef ENABLE_DOT11D - if (!channel_map[ieee->current_network.channel]) { -#else - if (!ieee->channel_map[ieee->current_network.channel]) { -#endif - ieee->current_network.channel = 6; - goto out; /* no good chans */ - } - } -#ifdef ENABLE_DOT11D - }while(!channel_map[ieee->current_network.channel]); -#else - }while(!ieee->channel_map[ieee->current_network.channel]); -#endif - if (ieee->scanning == 0 ) - goto out; - ieee->set_chan(ieee, ieee->current_network.channel); -#ifdef ENABLE_DOT11D - if(channel_map[ieee->current_network.channel] == 1) -#endif - ieee80211_send_probe_requests(ieee); - - - queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); - - up(&ieee->scan_sem); - return; -out: -#ifdef ENABLE_DOT11D - if(IS_DOT11D_ENABLE(ieee)) - DOT11D_ScanComplete(ieee); -#endif - ieee->current_network.channel = last_channel; - ieee->actscanning = false; - watchdog = 0; - ieee->scanning = 0; - up(&ieee->scan_sem); -} - -void ieee80211_beacons_start(struct ieee80211_device *ieee) -{ - unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); - - ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - - spin_unlock_irqrestore(&ieee->beacon_lock,flags); -} - -void ieee80211_beacons_stop(struct ieee80211_device *ieee) -{ - unsigned long flags; - - spin_lock_irqsave(&ieee->beacon_lock,flags); - - ieee->beacon_txing = 0; - del_timer_sync(&ieee->beacon_timer); - - spin_unlock_irqrestore(&ieee->beacon_lock,flags); - -} - - -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) -{ - if(ieee->stop_send_beacons) - ieee->stop_send_beacons(ieee); - if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); -} - - -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) -{ - if(ieee->start_send_beacons) - ieee->start_send_beacons(ieee); - if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); -} - - -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - - if (ieee->scanning == 1){ - ieee->scanning = 0; - - cancel_delayed_work(&ieee->softmac_scan_wq); - } - - up(&ieee->scan_sem); -} - -void ieee80211_stop_scan(struct ieee80211_device *ieee) -{ - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); - else - ieee->stop_scan(ieee); -} - -/* called with ieee->lock held */ -void ieee80211_rtl_start_scan(struct ieee80211_device *ieee) -{ -#ifdef ENABLE_IPS - if(ieee->ieee80211_ips_leave_wq != NULL) - ieee->ieee80211_ips_leave_wq(ieee); -#endif - -#ifdef ENABLE_DOT11D - if(IS_DOT11D_ENABLE(ieee) ) - { - if(IS_COUNTRY_IE_VALID(ieee)) - { - RESET_CIE_WATCHDOG(ieee); - } - } -#endif - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ - if (ieee->scanning == 0){ - ieee->scanning = 1; - queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); - } - }else - ieee->start_scan(ieee); - -} - -/* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) -{ -#ifdef ENABLE_DOT11D - if(IS_DOT11D_ENABLE(ieee) ) - { - if(IS_COUNTRY_IE_VALID(ieee)) - { - RESET_CIE_WATCHDOG(ieee); - } - } -#endif - ieee->sync_scan_hurryup = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); - else - ieee->scan_syncro(ieee); - -} - -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, - struct ieee80211_device *ieee, int challengelen) -{ - struct sk_buff *skb; - struct ieee80211_authentication *auth; - int len = sizeof(struct ieee80211_authentication) + challengelen + ieee->tx_headroom; - - - skb = dev_alloc_skb(len); - if (!skb) return NULL; - - skb_reserve(skb, ieee->tx_headroom); - auth = (struct ieee80211_authentication *) - skb_put(skb, sizeof(struct ieee80211_authentication)); - - auth->header.frame_ctl = IEEE80211_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - - auth->header.duration_id = 0x013a; //FIXME - - memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - - if(ieee->auth_mode == 0) - auth->algorithm = WLAN_AUTH_OPEN; - else if(ieee->auth_mode == 1) - auth->algorithm = WLAN_AUTH_SHARED_KEY; - else if(ieee->auth_mode == 2) - auth->algorithm = WLAN_AUTH_OPEN;//0x80; - printk("=================>%s():auth->algorithm is %d\n",__FUNCTION__,auth->algorithm); - auth->transaction = cpu_to_le16(ieee->associate_seq); - ieee->associate_seq++; - - auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - - return skb; - -} - - -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) -{ - u8 *tag; - int beacon_size; - struct ieee80211_probe_response *beacon_buf; - struct sk_buff *skb = NULL; - int encrypt; - int atim_len,erp_len; - struct ieee80211_crypt_data* crypt; - - char *ssid = ieee->current_network.ssid; - int ssid_len = ieee->current_network.ssid_len; - int rate_len = ieee->current_network.rates_len+2; - int rate_ex_len = ieee->current_network.rates_ex_len; - int wpa_ie_len = ieee->wpa_ie_len; - u8 erpinfo_content = 0; - - u8* tmp_ht_cap_buf; - u8 tmp_ht_cap_len=0; - u8* tmp_ht_info_buf; - u8 tmp_ht_info_len=0; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - u8* tmp_generic_ie_buf=NULL; - u8 tmp_generic_ie_len=0; - - if(rate_ex_len > 0) rate_ex_len+=2; - - if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) - atim_len = 4; - else - atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) - erp_len = 3; - else - erp_len = 0; - - crypt = ieee->crypt[ieee->tx_keyidx]; - - - encrypt = ieee->host_encrypt && crypt && crypt->ops && - ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); - //HT ralated element - - tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); - tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); - tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); - HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt); - HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); - - - if(pHTInfo->bRegRT2RTAggregation) - { - tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); - } - - beacon_size = sizeof(struct ieee80211_probe_response)+2+ - ssid_len - +3 //channel - +rate_len - +rate_ex_len - +atim_len - +erp_len - +wpa_ie_len - +ieee->tx_headroom; - skb = dev_alloc_skb(beacon_size); - if (!skb) - return NULL; - skb_reserve(skb, ieee->tx_headroom); - beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); - - beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = - cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - beacon_buf->capability |= - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); //add short preamble here - - if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - - crypt = ieee->crypt[ieee->tx_keyidx]; - if (encrypt) - beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - - beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - beacon_buf->info_element[0].id = MFIE_TYPE_SSID; - beacon_buf->info_element[0].len = ssid_len; - - tag = (u8*) beacon_buf->info_element[0].data; - - memcpy(tag, ssid, ssid_len); - - tag += ssid_len; - - *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; - memcpy(tag,ieee->current_network.rates,rate_len-2); - tag+=rate_len-2; - - *(tag++) = MFIE_TYPE_DS_SET; - *(tag++) = 1; - *(tag++) = ieee->current_network.channel; - - if(atim_len){ - u16 val16; - *(tag++) = MFIE_TYPE_IBSS_SET; - *(tag++) = 2; - val16 = cpu_to_le16(ieee->current_network.atim_window); - memcpy((u8 *)tag, (u8 *)&val16, 2); - tag+=2; - } - - if(erp_len){ - *(tag++) = MFIE_TYPE_ERP; - *(tag++) = 1; - *(tag++) = erpinfo_content; - } - if(rate_ex_len){ - *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; - memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); - tag+=rate_ex_len-2; - } - - if (wpa_ie_len) - { - if (ieee->iw_mode == IW_MODE_ADHOC) - {//as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07 - memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); - } - memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - tag += wpa_ie_len; - } - - return skb; -} - - -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) -{ - struct sk_buff *skb; - u8* tag; - - struct ieee80211_crypt_data* crypt; - struct ieee80211_assoc_response_frame *assoc; - short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len + ieee->tx_headroom; - - skb = dev_alloc_skb(len); - - if (!skb) - return NULL; - - skb_reserve(skb, ieee->tx_headroom); - - assoc = (struct ieee80211_assoc_response_frame *) - skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - - assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); - memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); - memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? - WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - - if(ieee->short_slot) - assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - - if (ieee->host_encrypt) - crypt = ieee->crypt[ieee->tx_keyidx]; - else crypt = NULL; - - encrypt = ( crypt && crypt->ops); - - if (encrypt) - assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - assoc->status = 0; - assoc->aid = cpu_to_le16(ieee->assoc_id); - if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; - else ieee->assoc_id++; - - tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - - return skb; -} - -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) -{ - struct sk_buff *skb; - struct ieee80211_authentication *auth; - int len = ieee->tx_headroom + sizeof(struct ieee80211_authentication)+1; - - skb = dev_alloc_skb(len); - - if (!skb) - return NULL; - - skb->len = sizeof(struct ieee80211_authentication); - - auth = (struct ieee80211_authentication *)skb->data; - - auth->status = cpu_to_le16(status); - auth->transaction = cpu_to_le16(2); - auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - - memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); - return skb; - - -} - -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) -{ - struct sk_buff *skb; - struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) - return NULL; - - hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - - memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); - memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - - return skb; - - -} - -struct sk_buff* ieee80211_pspoll_func(struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - struct ieee80211_pspoll_hdr* hdr; - -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(sizeof(struct ieee80211_pspoll_hdr) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); -#else - skb = dev_alloc_skb(sizeof(struct ieee80211_pspoll_hdr)+ieee->tx_headroom); -#endif - if (!skb) - return NULL; - -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); - - hdr = (struct ieee80211_pspoll_hdr*)skb_put(skb,sizeof(struct ieee80211_pspoll_hdr)); - - memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); - memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); - - hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_CTL |IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM); - - return skb; - -} - - -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) -{ - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); -} - - -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) -{ - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); -} - - -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) -{ - - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - if (buf) - softmac_mgmt_xmit(buf, ieee); -} - - -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - struct ieee80211_assoc_request_frame *hdr; - u8 *tag; - u8* ht_cap_buf = NULL; - u8 ht_cap_len=0; - u8* realtek_ie_buf=NULL; - u8 realtek_ie_len=0; - int wpa_ie_len= ieee->wpa_ie_len; - unsigned int ckip_ie_len=0; - unsigned int ccxrm_ie_len=0; - unsigned int cxvernum_ie_len=0; - struct ieee80211_crypt_data* crypt; - int encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - unsigned int wmm_info_len = beacon->qos_data.supported?9:0; -#ifdef THOMAS_TURBO - unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; -#endif - - int len = 0; - - crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); - - //Include High Throuput capability && Realtek proprietary - if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap); - ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt); - if(ieee->pHTInfo->bCurrentRT2RTAggregation) - { - realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); - - } - } - if(ieee->qos_support){ - wmm_info_len = beacon->qos_data.supported?9:0; - } - - - if(beacon->bCkipSupported) - { - ckip_ie_len = 30+2; - } - if(beacon->bCcxRmEnable) - { - ccxrm_ie_len = 6+2; - } - if( beacon->BssCcxVerNumber >= 2 ) - { - cxvernum_ie_len = 5+2; - } -#ifdef THOMAS_TURBO - len = sizeof(struct ieee80211_assoc_request_frame)+ 2 - + beacon->ssid_len//essid tagged val - + rate_len//rates tagged val - + wpa_ie_len - + wmm_info_len - + turbo_info_len - + ht_cap_len - + realtek_ie_len - + ckip_ie_len - + ccxrm_ie_len - + cxvernum_ie_len - + ieee->tx_headroom; -#else - len = sizeof(struct ieee80211_assoc_request_frame)+ 2 - + beacon->ssid_len//essid tagged val - + rate_len//rates tagged val - + wpa_ie_len - + wmm_info_len - + ht_cap_len - + realtek_ie_len - + ckip_ie_len - + ccxrm_ie_len - + cxvernum_ie_len - + ieee->tx_headroom; -#endif - - skb = dev_alloc_skb(len); - - if (!skb) - return NULL; - - skb_reserve(skb, ieee->tx_headroom); - - hdr = (struct ieee80211_assoc_request_frame *) - skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)+2); - - - hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; //FIXME - memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - - memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);//for HW security, John - - hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) - hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); //add short_preamble here - - if(ieee->short_slot) - hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - if (wmm_info_len) //QOS - hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); - - hdr->listen_interval = 0xa; //FIXME - - hdr->info_element[0].id = MFIE_TYPE_SSID; - - hdr->info_element[0].len = beacon->ssid_len; - tag = skb_put(skb, beacon->ssid_len); - memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - // For CCX 1 S13, CKIP. Added by Annie, 2006-08-14. - if( beacon->bCkipSupported ) - { - static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client" - u8 CcxAironetBuf[30]; - OCTET_STRING osCcxAironetIE; - - memset(CcxAironetBuf, 0,30); - osCcxAironetIE.Octet = CcxAironetBuf; - osCcxAironetIE.Length = sizeof(CcxAironetBuf); - // - // Ref. CCX test plan v3.61, 3.2.3.1 step 13. - // We want to make the device type as "4500-client". 060926, by CCW. - // - memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); - - // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23): - // "The CKIP negotiation is started with the associate request from the client to the access point, - // containing an Aironet element with both the MIC and KP bits set." - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; - tag = skb_put(skb, ckip_ie_len); - *tag++ = MFIE_TYPE_AIRONET; - *tag++ = osCcxAironetIE.Length; - memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); - tag += osCcxAironetIE.Length; - } - - if(beacon->bCcxRmEnable) - { - static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; - OCTET_STRING osCcxRmCap; - - osCcxRmCap.Octet = CcxRmCapBuf; - osCcxRmCap.Length = sizeof(CcxRmCapBuf); - tag = skb_put(skb,ccxrm_ie_len); - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = osCcxRmCap.Length; - memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); - tag += osCcxRmCap.Length; - } - - if( beacon->BssCcxVerNumber >= 2 ) - { - u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; - OCTET_STRING osCcxVerNum; - CcxVerNumBuf[4] = beacon->BssCcxVerNumber; - osCcxVerNum.Octet = CcxVerNumBuf; - osCcxVerNum.Length = sizeof(CcxVerNumBuf); - tag = skb_put(skb,cxvernum_ie_len); - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = osCcxVerNum.Length; - memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); - tag += osCcxVerNum.Length; - } - //HT cap element - if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if(ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) - { - tag = skb_put(skb, ht_cap_len); - *tag++ = MFIE_TYPE_HT_CAP; - *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len -2); - tag += ht_cap_len -2; - } - } - - - //choose what wpa_supplicant gives to associate. - tag = skb_put(skb, wpa_ie_len); - if (wpa_ie_len){ - memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - } - - tag = skb_put(skb,wmm_info_len); - if(wmm_info_len) { - ieee80211_WMM_Info(ieee, &tag); - } -#ifdef THOMAS_TURBO - tag = skb_put(skb,turbo_info_len); - if(turbo_info_len) { - ieee80211_TURBO_Info(ieee, &tag); - } -#endif - - if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if(ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { - tag = skb_put(skb, ht_cap_len); - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len - 2); - tag += ht_cap_len -2; - } - - if(ieee->pHTInfo->bCurrentRT2RTAggregation){ - tag = skb_put(skb, realtek_ie_len); - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = realtek_ie_len - 2; - memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); - } - } - return skb; -} - -void ieee80211_associate_abort(struct ieee80211_device *ieee) -{ - - unsigned long flags; - spin_lock_irqsave(&ieee->lock, flags); - - ieee->associate_seq++; - - /* don't scan, and avoid to have the RX path possibily - * try again to associate. Even do not react to AUTH or - * ASSOC response. Just wait for the retry wq to be scheduled. - * Here we will check if there are good nets to associate - * with, so we retry or just get back to NO_LINK and scanning - */ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); - ieee->softmac_stats.no_auth_rs++; - }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); - ieee->softmac_stats.no_ass_rs++; - } - - ieee->state = IEEE80211_ASSOCIATING_RETRY; - - queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, \ - IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - spin_unlock_irqrestore(&ieee->lock, flags); -} - -void ieee80211_associate_abort_cb(unsigned long dev) -{ - ieee80211_associate_abort((struct ieee80211_device *) dev); -} - - -void ieee80211_associate_step1(struct ieee80211_device *ieee) -{ - struct ieee80211_network *beacon = &ieee->current_network; - struct sk_buff *skb; - - IEEE80211_DEBUG_MGMT("Stopping scan\n"); - - ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ - ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; - IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); - //BUGON when you try to add_timer twice, using mod_timer may be better, john0709 - if(!timer_pending(&ieee->associate_timer)){ - ieee->associate_timer.expires = jiffies + (HZ / 2); - add_timer(&ieee->associate_timer); - } - } -} - -void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) -{ - u8 *c; - struct sk_buff *skb; - struct ieee80211_network *beacon = &ieee->current_network; - - ieee->associate_seq++; - ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); - else{ - c = skb_put(skb, chlen+2); - *(c++) = MFIE_TYPE_CHALLENGE; - *(c++) = chlen; - memcpy(c, challenge, chlen); - - IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); - mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); - } - kfree(challenge); -} - -void ieee80211_associate_step2(struct ieee80211_device *ieee) -{ - struct sk_buff* skb; - struct ieee80211_network *beacon = &ieee->current_network; - - del_timer_sync(&ieee->associate_timer); - - IEEE80211_DEBUG_MGMT("Sending association request\n"); - - ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); - else{ - softmac_mgmt_xmit(skb, ieee); - mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); - } -} -void ieee80211_associate_complete_wq(struct work_struct *work) -{ - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); - printk(KERN_INFO "Associated successfully\n"); - ieee->is_roaming = false; - if(ieee80211_is_54g(ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - - ieee->rate = 108; - printk(KERN_INFO"Using G rates:%d\n", ieee->rate); - }else{ - ieee->rate = 22; - printk(KERN_INFO"Using B rates:%d\n", ieee->rate); - } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - printk("Successfully associated, ht enabled\n"); - HTOnAssocRsp(ieee); - } - else - { - printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); - memset(ieee->dot11HTOperationalRateSet, 0, 16); - } - ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); - // To prevent the immediately calling watch_dog after association. - if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { - ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; - } - ieee->link_change(ieee); - if(ieee->is_silent_reset == 0){ - printk("============>normal associate\n"); - notify_wx_assoc_event(ieee); - } - else if(ieee->is_silent_reset == 1) - { - printk("==================>silent reset associate\n"); - ieee->is_silent_reset = 0; - } - - if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); - netif_carrier_on(ieee->dev); -} - -void ieee80211_associate_complete(struct ieee80211_device *ieee) -{ - del_timer_sync(&ieee->associate_timer); - - ieee->state = IEEE80211_LINKED; - queue_work(ieee->wq, &ieee->associate_complete_wq); -} - -void ieee80211_associate_procedure_wq(struct work_struct *work) -{ - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); - ieee->sync_scan_hurryup = 1; -#ifdef ENABLE_IPS - if(ieee->ieee80211_ips_leave != NULL) - ieee->ieee80211_ips_leave(ieee); -#endif - - down(&ieee->wx_sem); - - if (ieee->data_hard_stop) - ieee->data_hard_stop(ieee); - - ieee80211_stop_scan(ieee); - printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel); - HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - - ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - - up(&ieee->wx_sem); -} - -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) -{ - u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; - int tmp_ssid_len = 0; - - short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated - * and we are not associating / authenticating - */ - if (ieee->state != IEEE80211_NOLINK) - return; - - if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) - return; - - if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) - return; - - - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ - /* if the user specified the AP MAC, we need also the essid - * This could be obtained by beacons or, if the network does not - * broadcast it, it can be put manually. - */ - apset = ieee->wap_set; - ssidset = ieee->ssid_set; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); - ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplyed ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || - /* if the ap is not set, check that the user set the bssid - * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) - ){ - /* if the essid is hidden replace it with the - * essid provided by the user. - */ - if (!ssidbroad){ - strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); - tmp_ssid_len = ieee->current_network.ssid_len; - } - memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - - if (!ssidbroad){ - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - } - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT); - - HTResetIOTSetting(ieee->pHTInfo); - if (ieee->iw_mode == IW_MODE_INFRA){ - /* Join the network for the first time */ - ieee->AsocRetryCount = 0; - //for HT by amy 080514 - if((ieee->current_network.qos_data.supported == 1) && - ieee->current_network.bssht.bdSupportHT) -/*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/ - { - HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); - } - else - { - ieee->pHTInfo->bCurrentHTSupport = false; - } - - ieee->state = IEEE80211_ASSOCIATING; - queue_work(ieee->wq, &ieee->associate_procedure_wq); - }else{ - if(ieee80211_is_54g(ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - ieee->rate = 108; - ieee->SetWirelessMode(ieee, IEEE_G); - printk(KERN_INFO"Using G rates\n"); - }else{ - ieee->rate = 22; - ieee->SetWirelessMode(ieee, IEEE_B); - printk(KERN_INFO"Using B rates\n"); - } - memset(ieee->dot11HTOperationalRateSet, 0, 16); - ieee->state = IEEE80211_LINKED; - } - - } - } - -} - -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) -{ - unsigned long flags; - struct ieee80211_network *target; - - spin_lock_irqsave(&ieee->lock, flags); - - list_for_each_entry(target, &ieee->network_list, list) { - - /* if the state become different that NOLINK means - * we had found what we are searching for - */ - - if (ieee->state != IEEE80211_NOLINK) - break; - - if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); - } - - spin_unlock_irqrestore(&ieee->lock, flags); - -} - - -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) -{ - struct ieee80211_authentication *a; - u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); - return 0xcafe; - } - *challenge = NULL; - a = (struct ieee80211_authentication*) skb->data; - if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ - t = skb->data + sizeof(struct ieee80211_authentication); - - if(*(t++) == MFIE_TYPE_CHALLENGE){ - *chlen = *(t++); - *challenge = kmemdup(t, *chlen, GFP_ATOMIC); - if (!*challenge) - return -ENOMEM; - } - } - - return cpu_to_le16(a->status); - -} - - -int auth_rq_parse(struct sk_buff *skb,u8* dest) -{ - struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); - return -1; - } - a = (struct ieee80211_authentication*) skb->data; - - memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) - return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - - return WLAN_STATUS_SUCCESS; -} - -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) -{ - u8 *tag; - u8 *skbend; - u8 *ssid=NULL; - u8 ssidlen = 0; - - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) - return -1; /* corrupted */ - - memcpy(src,header->addr2, ETH_ALEN); - - skbend = (u8*)skb->data + skb->len; - - tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - - while (tag+1 < skbend){ - if (*tag == 0){ - ssid = tag+2; - ssidlen = *(tag+1); - break; - } - tag++; /* point to the len field */ - tag = tag + *(tag); /* point to the last data byte of the tag */ - tag++; /* point to the next tag */ - } - - if (ssidlen == 0) return 1; - - if (!ssid) return 1; /* ssid not found in tagged param */ - return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - -} - -int assoc_rq_parse(struct sk_buff *skb,u8* dest) -{ - struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - - IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); - return -1; - } - - a = (struct ieee80211_assoc_request_frame*) skb->data; - - memcpy(dest,a->header.addr2,ETH_ALEN); - - return 0; -} - -static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb, int *aid) -{ - struct ieee80211_assoc_response_frame *response_head; - u16 status_code; - - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ - IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); - return 0xcafe; - } - - response_head = (struct ieee80211_assoc_response_frame*) skb->data; - *aid = le16_to_cpu(response_head->aid) & 0x3fff; - - status_code = le16_to_cpu(response_head->status); - if((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& - ((ieee->mode == IEEE_G) && - (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; - }else { - ieee->AsocRetryCount = 0; - } - - return le16_to_cpu(response_head->status); -} - -static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) -{ - u8 dest[ETH_ALEN]; - - ieee->softmac_stats.rx_probe_rq++; - if (probe_rq_parse(ieee, skb, dest)){ - ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); - } -} - -static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) -{ - u8 dest[ETH_ALEN]; - int status; - ieee->softmac_stats.rx_auth_rq++; - - status = auth_rq_parse(skb, dest); - if (status != -1) { - ieee80211_resp_to_auth(ieee, status, dest); - } -} - -static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) -{ - u8 dest[ETH_ALEN]; - - ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); - } - - printk(KERN_INFO"New client associated: %pM\n", dest); -} - - - -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) -{ - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - - if (buf) - softmac_ps_mgmt_xmit(buf, ieee); - -} - -void ieee80211_sta_ps_send_pspoll_frame(struct ieee80211_device *ieee) -{ - - struct sk_buff *buf = ieee80211_pspoll_func(ieee); - - if (buf) - softmac_ps_mgmt_xmit(buf, ieee); - -} - -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ - int timeout = ieee->ps_timeout; - u8 dtim; - - if(ieee->LPSDelayCnt) - { - ieee->LPSDelayCnt --; - return 0; - } - - dtim = ieee->current_network.dtim_data; - if(!(dtim & IEEE80211_DTIM_VALID)) - return 0; - timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval - ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - /* there's no need to nofity AP that I find you buffered with broadcast packet */ - if(dtim & (IEEE80211_DTIM_UCAST & ieee->ps)) - return 2; - - if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ - return 0; - } - if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){ - return 0; - } - if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && - (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) - return 0; - - if(time_l){ - if(ieee->bAwakePktSent == true) { - ieee->LPSAwakeIntvl = 1;//tx wake one beacon - } else { - u8 MaxPeriod = 1; - - if(ieee->LPSAwakeIntvl == 0) - ieee->LPSAwakeIntvl = 1; - if(ieee->RegMaxLPSAwakeIntvl == 0) // Default (0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl) - MaxPeriod = 1; // 1 Beacon interval - else if(ieee->RegMaxLPSAwakeIntvl == 0xFF) // DTIM - MaxPeriod = ieee->current_network.dtim_period; - else - MaxPeriod = ieee->RegMaxLPSAwakeIntvl; - ieee->LPSAwakeIntvl = (ieee->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (ieee->LPSAwakeIntvl + 1); - } - { - u8 LPSAwakeIntvl_tmp = 0; - u8 period = ieee->current_network.dtim_period; - u8 count = ieee->current_network.tim.tim_count; - if(count == 0 ) { - if(ieee->LPSAwakeIntvl > period) - LPSAwakeIntvl_tmp = period + (ieee->LPSAwakeIntvl - period) -((ieee->LPSAwakeIntvl-period)%period); - else - LPSAwakeIntvl_tmp = ieee->LPSAwakeIntvl; - - } else { - if(ieee->LPSAwakeIntvl > ieee->current_network.tim.tim_count) - LPSAwakeIntvl_tmp = count + (ieee->LPSAwakeIntvl - count) -((ieee->LPSAwakeIntvl-count)%period); - else - LPSAwakeIntvl_tmp = ieee->LPSAwakeIntvl; - } - - *time_l = ieee->current_network.last_dtim_sta_time[0] - + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); - } - } - - if(time_h){ - *time_h = ieee->current_network.last_dtim_sta_time[1]; - if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) - *time_h += 1; - } - - return 1; - - -} - -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) -{ - - u32 th,tl; - short sleep; - unsigned long flags; - - spin_lock_irqsave(&ieee->lock, flags); - - if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != IEEE80211_LINKED)){ - - // #warning CHECK_LOCK_HERE - printk("=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", - __FUNCTION__,ieee->ps,ieee->iw_mode,ieee->state); - spin_lock(&ieee->mgmt_tx_lock); - - ieee80211_sta_wakeup(ieee, 1); - - spin_unlock(&ieee->mgmt_tx_lock); - } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); - /* 2 wake, 1 sleep, 0 do nothing */ - if(sleep == 0)//it is not time out or dtim is not valid - { - goto out; - } - if(sleep == 1){ - if(ieee->sta_sleep == 1){ - ieee->enter_sleep_state(ieee, th, tl); - } - - else if(ieee->sta_sleep == 0){ - spin_lock(&ieee->mgmt_tx_lock); - - if (ieee->ps_is_queue_empty(ieee)) { - ieee->sta_sleep = 2; - ieee->ack_tx_to_ieee = 1; - ieee80211_sta_ps_send_null_frame(ieee,1); - ieee->ps_th = th; - ieee->ps_tl = tl; - } - spin_unlock(&ieee->mgmt_tx_lock); - - } - - ieee->bAwakePktSent = false;//after null to power save we set it to false. not listen every beacon. - - }else if(sleep == 2){ - spin_lock(&ieee->mgmt_tx_lock); - - ieee80211_sta_wakeup(ieee,1); - - spin_unlock(&ieee->mgmt_tx_lock); - } - -out: - spin_unlock_irqrestore(&ieee->lock, flags); - -} - -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) -{ - if(ieee->sta_sleep == 0){ - if(nl){ - if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { - ieee->ack_tx_to_ieee = 1; - ieee80211_sta_ps_send_null_frame(ieee, 0); - } - else - { - ieee->ack_tx_to_ieee = 1; - ieee80211_sta_ps_send_pspoll_frame(ieee); - } - } - return; - - } - - if(ieee->sta_sleep == 1) - ieee->sta_wake_up(ieee); - if(nl){ - - if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { - ieee->ack_tx_to_ieee = 1; - ieee80211_sta_ps_send_null_frame(ieee, 0); - } - else - { - ieee->ack_tx_to_ieee = 1; - ieee->polling = true; - //ieee80211_sta_ps_send_null_frame(ieee, 0); - ieee80211_sta_ps_send_pspoll_frame(ieee); - } - - } else { - ieee->sta_sleep = 0; - ieee->polling = false; - } -} - -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) -{ - unsigned long flags; - - spin_lock_irqsave(&ieee->lock, flags); - - if(ieee->sta_sleep == 2){ - /* Null frame with PS bit set */ - if(success){ - ieee->sta_sleep = 1; - ieee->enter_sleep_state(ieee, ieee->ps_th, ieee->ps_tl); - } - } else {/* 21112005 - tx again null without PS bit if lost */ - - if((ieee->sta_sleep == 0) && !success){ - spin_lock(&ieee->mgmt_tx_lock); - //ieee80211_sta_ps_send_null_frame(ieee, 0); - if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { - ieee80211_sta_ps_send_null_frame(ieee, 0); - } - else - { - ieee80211_sta_ps_send_pspoll_frame(ieee); - } - spin_unlock(&ieee->mgmt_tx_lock); - } - } - spin_unlock_irqrestore(&ieee->lock, flags); -} - -void ieee80211_process_action(struct ieee80211_device* ieee, struct sk_buff* skb) -{ - struct ieee80211_hdr* header = (struct ieee80211_hdr*)skb->data; - u8* act = ieee80211_get_payload(header); - u8 tmp = 0; - - if (act == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n"); - return; - } - tmp = *act; - act ++; - switch (tmp) - { - case ACT_CAT_BA: - if (*act == ACT_ADDBAREQ) - ieee80211_rx_ADDBAReq(ieee, skb); - else if (*act == ACT_ADDBARSP) - ieee80211_rx_ADDBARsp(ieee, skb); - else if (*act == ACT_DELBA) - ieee80211_rx_DELBA(ieee, skb); - break; - default: - break; - } - return; - -} -inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, u16 type, - u16 stype) -{ - struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - u16 errcode; - u8* challenge; - int chlen=0; - int aid; - struct ieee80211_assoc_response_frame *assoc_resp; - bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode - - if(!ieee->proto_started) - return 0; - - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - - case IEEE80211_STYPE_ASSOC_RESP: - case IEEE80211_STYPE_REASSOC_RESP: - - IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && - ieee->iw_mode == IW_MODE_INFRA){ - struct ieee80211_network network_resp; - struct ieee80211_network *network = &network_resp; - - if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ - ieee->state=IEEE80211_LINKED; - ieee->assoc_id = aid; - ieee->softmac_stats.rx_ass_ok++; - /* station support qos */ - /* Let the register setting defaultly with Legacy station */ - if(ieee->qos_support) { - assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data; - memset(network, 0, sizeof(*network)); - if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ - return 1; - } - else - { //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. - memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); - } - if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee, (struct ieee80211_assoc_response_frame*)header, network); - } - ieee80211_associate_complete(ieee); - } else { - /* aid could not been allocated */ - ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", - errcode); - IEEE80211_DEBUG_MGMT( - "Association response status code 0x%x\n", - errcode); - if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } else { - ieee80211_associate_abort(ieee); - } - } - } - break; - - case IEEE80211_STYPE_ASSOC_REQ: - case IEEE80211_STYPE_REASSOC_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); - break; - - case IEEE80211_STYPE_AUTH: - - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && - ieee->iw_mode == IW_MODE_INFRA){ - - IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ - if(ieee->open_wep || !challenge){ - ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; - ieee->softmac_stats.rx_auth_rs_ok++; - if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) - { - if (!ieee->GetNmodeSupportBySecCfg(ieee)) - { - // WEP or TKIP encryption - if(IsHTHalfNmodeAPs(ieee)) - { - bSupportNmode = true; - bHalfSupportNmode = true; - } - else - { - bSupportNmode = false; - bHalfSupportNmode = false; - } - printk("==========>to link with AP using SEC(%d, %d)\n", bSupportNmode, bHalfSupportNmode); - } - } - /* Dummy wirless mode setting to avoid encryption issue */ - if(bSupportNmode) { - //N mode setting - ieee->SetWirelessMode(ieee, - ieee->current_network.mode); - }else{ - //b/g mode setting - /*TODO*/ - ieee->SetWirelessMode(ieee, IEEE_G); - } - - if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) - { - printk("===============>entern half N mode\n"); - ieee->bHalfWirelessN24GMode = true; - } - else - ieee->bHalfWirelessN24GMode = false; - - ieee80211_associate_step2(ieee); - }else{ - ieee80211_rtl_auth_challenge(ieee, challenge, chlen); - } - }else{ - ieee->softmac_stats.rx_auth_rs_err++; - IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - - printk("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); - } - - }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); - } - } - break; - - case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == IEEE80211_LINKED)){ - ieee80211_rx_probe_rq(ieee, skb); - } - break; - - case IEEE80211_STYPE_DISASSOC: - case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure - * both for disassociation and deauthentication - */ - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && - ieee->iw_mode == IW_MODE_INFRA){ - - ieee->state = IEEE80211_ASSOCIATING; - ieee->softmac_stats.reassoc++; - ieee->is_roaming = true; - ieee80211_disassociate(ieee); - RemovePeerTS(ieee, header->addr2); - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } - break; - case IEEE80211_STYPE_MANAGE_ACT: - ieee80211_process_action(ieee,skb); - break; - default: - return -1; - break; - } - - return 0; -} - -/* following are for a simpler TX queue management. - * Instead of using netif_[stop/wake]_queue the driver - * will uses these two function (plus a reset one), that - * will internally uses the kernel netif_* and takes - * care of the ieee802.11 fragmentation. - * So the driver receives a fragment per time and might - * call the stop function when it want without take care - * to have enough room to TX an entire packet. - * This might be useful if each fragment need it's own - * descriptor, thus just keep a total free memory > than - * the max fragmentation threshold is not enough.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where - * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD - * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to - * to the driver later, when it wakes the queue. - */ -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) -{ - - unsigned int queue_index = txb->queue_index; - unsigned long flags; - int i; - cb_desc *tcb_desc = NULL; - - spin_lock_irqsave(&ieee->lock,flags); - - /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - - /* update the tx status */ - tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if(tcb_desc->bMulticast) { - ieee->stats.multicast++; - } - - /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ - for(i = 0; i < txb->nr_frags; i++) { -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - if ((skb_queue_len(&ieee->skb_drv_aggQ[queue_index]) != 0) || -#else - if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) || -#endif - (!ieee->check_nic_enough_desc(ieee, queue_index))|| - (ieee->queue_stop)) { - /* insert the skb packet to the wait queue */ - /* as for the completion function, it does not need - * to check it any more. - * */ -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]); -#else - skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); -#endif - }else{ - ieee->softmac_data_hard_start_xmit( - txb->fragments[i], - ieee, ieee->rate); - } - } - - ieee80211_txb_free(txb); - - spin_unlock_irqrestore(&ieee->lock,flags); - -} - -/* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) -{ - int i; - for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - - if (ieee->queue_stop){ - ieee->tx_pending.frag = i; - return; - }else{ - - ieee->softmac_data_hard_start_xmit( - ieee->tx_pending.txb->fragments[i], - ieee, ieee->rate); - ieee->stats.tx_packets++; - } - } - - - ieee80211_txb_free(ieee->tx_pending.txb); - ieee->tx_pending.txb = NULL; -} - - -void ieee80211_reset_queue(struct ieee80211_device *ieee) -{ - unsigned long flags; - - spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); - if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); - ieee->tx_pending.txb = NULL; - } - ieee->queue_stop = 0; - spin_unlock_irqrestore(&ieee->lock,flags); - -} - -void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee) -{ - - unsigned long flags; - struct sk_buff *skb; - struct ieee80211_hdr_3addr *header; - - spin_lock_irqsave(&ieee->lock,flags); - if (! ieee->queue_stop) goto exit; - - ieee->queue_stop = 0; - - if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - - header = (struct ieee80211_hdr_3addr *) skb->data; - - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate); - } - } - if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ - ieee->softmac_stats.swtxawake++; - netif_wake_queue(ieee->dev); - } - -exit : - spin_unlock_irqrestore(&ieee->lock,flags); -} - - -void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee) -{ - if (! netif_queue_stopped(ieee->dev)){ - netif_stop_queue(ieee->dev); - ieee->softmac_stats.swtxstop++; - } - ieee->queue_stop = 1; -} - - -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) -{ - - get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - - /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 - */ - ieee->current_network.bssid[0] &= ~0x01; - ieee->current_network.bssid[0] |= 0x02; -} - -/* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) -{ - ieee->assoc_id = 1; - - if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, - IEEE80211_DEFAULT_TX_ESSID, - IW_ESSID_MAX_SIZE); - - ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); - ieee->ssid_set = 1; - } - - memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - - ieee->set_chan(ieee, ieee->current_network.channel); - ieee->state = IEEE80211_LINKED; - ieee->link_change(ieee); - notify_wx_assoc_event(ieee); - - if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); - - netif_carrier_on(ieee->dev); -} - -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) -{ - if(ieee->raw_tx){ - - if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); - - netif_carrier_on(ieee->dev); - } -} -void ieee80211_start_ibss_wq(struct work_struct *work) -{ - - struct delayed_work *dwork = container_of(work, struct delayed_work, work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq); - /* iwconfig mode ad-hoc will schedule this and return - * on the other hand this will block further iwconfig SET - * operations because of the wx_sem hold. - * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping - * on the semaphore - */ - if(!ieee->proto_started){ - printk("==========oh driver down return\n"); - return; - } - down(&ieee->wx_sem); - - if (ieee->current_network.ssid_len == 0){ - strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); - ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); - ieee->ssid_set = 1; - } - - ieee->state = IEEE80211_NOLINK; - /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - - -#ifdef ENABLE_DOT11D //if creating an ad-hoc, set its channel to 10 temporarily--this is the requirement for ASUS, not 11D, so disable 11d. - if (ieee->state == IEEE80211_NOLINK) - ieee->current_network.channel = 6; -#endif - /* if not then the state is not linked. Maybe the user swithced to - * ad-hoc mode just after being in monitor mode, or just after - * being very few time in managed mode (so the card have had no - * time to scan all the chans..) or we have just run up the iface - * after setting ad-hoc mode. So we have to give another try.. - * Here, in ibss mode, should be safe to do this without extra care - * (in bss mode we had to make sure no-one tryed to associate when - * we had just checked the ieee->state and we was going to start the - * scan) beacause in ibss mode the ieee80211_new_net function, when - * finds a good net, just set the ieee->state to IEEE80211_LINKED, - * so, at worst, we waste a bit of time to initiate an unneeded syncro - * scan, that will stop at the first round because it sees the state - * associated. - */ - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); - - /* the network definitively is not here.. create a new cell */ - if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); - if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - - if(ieee->modulation & IEEE80211_CCK_MODULATION){ - - ieee->current_network.rates_len = 4; - - ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; - ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; - ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; - ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - - }else - ieee->current_network.rates_len = 0; - - if(ieee->modulation & IEEE80211_OFDM_MODULATION){ - ieee->current_network.rates_ex_len = 8; - - ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 108; - }else{ - ieee->current_network.rates_ex_len = 0; - ieee->rate = 22; - } - - // By default, WMM function will be disabled in IBSS mode - ieee->current_network.QoS_Enable = 0; - ieee->SetWirelessMode(ieee, IEEE_G); - ieee->current_network.atim_window = 0; - ieee->current_network.capability = WLAN_CAPABILITY_IBSS; - if(ieee->short_slot) - ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - - } - - ieee->state = IEEE80211_LINKED; - - ieee->set_chan(ieee, ieee->current_network.channel); - ieee->link_change(ieee); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - - if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); - netif_carrier_on(ieee->dev); - - up(&ieee->wx_sem); -} - -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) -{ - queue_delayed_work(ieee->wq, &ieee->start_ibss_wq, 150); -} - -/* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) -{ - unsigned long flags; -#ifdef ENABLE_DOT11D - // - // Ref: 802.11d 11.1.3.3 - // STA shall not start a BSS unless properly formed Beacon frame including a Country IE. - // - if(IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { - if(! ieee->bGlobalDomain) - { - return; - } - } -#endif - /* check if we have already found the net we - * are interested in (if any). - * if not (we are disassociated and we are not - * in associating / authenticating phase) start the background scanning. - */ - ieee80211_softmac_check_all_nets(ieee); - - /* ensure no-one start an associating process (thus setting - * the ieee->state to ieee80211_ASSOCIATING) while we - * have just cheked it and we are going to enable scan. - * The ieee80211_new_net function is always called with - * lock held (from both ieee80211_softmac_check_all_nets and - * the rx path), so we cannot be in the middle of such function - */ - spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state == IEEE80211_NOLINK){ -#ifdef ENABLE_IPS - if(ieee->ieee80211_ips_leave_wq != NULL) - ieee->ieee80211_ips_leave_wq(ieee); -#endif - ieee->actscanning = true; - ieee80211_rtl_start_scan(ieee); - } - spin_unlock_irqrestore(&ieee->lock, flags); -} - -/* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) -{ - - - netif_carrier_off(ieee->dev); - if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - - if (ieee->data_hard_stop) - ieee->data_hard_stop(ieee); -#ifdef ENABLE_DOT11D - if(IS_DOT11D_ENABLE(ieee)) - Dot11d_Reset(ieee); -#endif - ieee->is_set_key = false; - ieee->link_change(ieee); - if (ieee->state == IEEE80211_LINKED || - ieee->state == IEEE80211_ASSOCIATING) { - ieee->state = IEEE80211_NOLINK; - notify_wx_assoc_event(ieee); - } - - ieee->state = IEEE80211_NOLINK; - -} -void ieee80211_associate_retry_wq(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work, struct delayed_work, work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); - unsigned long flags; - - down(&ieee->wx_sem); - if(!ieee->proto_started) - goto exit; - - if(ieee->state != IEEE80211_ASSOCIATING_RETRY) - goto exit; - - /* until we do not set the state to IEEE80211_NOLINK - * there are no possibility to have someone else trying - * to start an association procdure (we get here with - * ieee->state = IEEE80211_ASSOCIATING). - * When we set the state to IEEE80211_NOLINK it is possible - * that the RX path run an attempt to associate, but - * both ieee80211_softmac_check_all_nets and the - * RX path works with ieee->lock held so there are no - * problems. If we are still disassociated then start a scan. - * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the - * state and we are going to start the scan. - */ - ieee->beinretry = true; - ieee->state = IEEE80211_NOLINK; - - ieee80211_softmac_check_all_nets(ieee); - - spin_lock_irqsave(&ieee->lock, flags); - - if(ieee->state == IEEE80211_NOLINK) - { - ieee->is_roaming= false; - ieee->actscanning = true; - ieee80211_rtl_start_scan(ieee); - } - spin_unlock_irqrestore(&ieee->lock, flags); - - ieee->beinretry = false; -exit: - up(&ieee->wx_sem); -} - -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) -{ - u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - - struct sk_buff *skb; - struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) - return NULL; - - b = (struct ieee80211_probe_response *) skb->data; - b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - - return skb; - -} - -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) - return NULL; - - b = (struct ieee80211_probe_response *) skb->data; - b->header.seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - return skb; -} - -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee, u8 shutdown) -{ - ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee, shutdown); - up(&ieee->wx_sem); -} - - -void ieee80211_stop_protocol(struct ieee80211_device *ieee, u8 shutdown) -{ - if (!ieee->proto_started) - return; - - if(shutdown) - ieee->proto_started = 0; - ieee->proto_stoppping = 1; - - ieee80211_stop_send_beacons(ieee); - del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - cancel_delayed_work(&ieee->start_ibss_wq); - ieee80211_stop_scan(ieee); - - ieee80211_disassociate(ieee); - RemoveAllTS(ieee); //added as we disconnect from the previous BSS, Remove all TS - - ieee->proto_stoppping = 0; -} - -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) -{ - ieee->sync_scan_hurryup = 0; - down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); - up(&ieee->wx_sem); -} - -void ieee80211_start_protocol(struct ieee80211_device *ieee) -{ - short ch = 0; - int i = 0; - if (ieee->proto_started) - return; - - ieee->proto_started = 1; - - if (ieee->current_network.channel == 0){ - do{ - ch++; - if (ch > MAX_CHANNEL_NUMBER) - return; /* no channel found */ -#ifdef ENABLE_DOT11D - }while(!GET_DOT11D_INFO(ieee)->channel_map[ch]); -#else - }while(!ieee->channel_map[ch]); -#endif - ieee->current_network.channel = ch; - } - - if (ieee->current_network.beacon_interval == 0) - ieee->current_network.beacon_interval = 100; - - for(i = 0; i < 17; i++) { - ieee->last_rxseq_num[i] = -1; - ieee->last_rxfrag_num[i] = -1; - ieee->last_packet_time[i] = 0; - } - - ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers. - - ieee->state = IEEE80211_NOLINK; - - - /* if the user set the MAC of the ad-hoc cell and then - * switch to managed mode, shall we make sure that association - * attempts does not fail just because the user provide the essid - * and the nic is still checking for the AP MAC ?? - */ - if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - - else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - - else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - - else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); -} - - -#define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) -{ - int i; - memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - - ieee->state = IEEE80211_NOLINK; - ieee->sync_scan_hurryup = 0; - for(i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } -#ifdef ENABLE_DOT11D - ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC); - if (!ieee->pDot11dInfo) - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n"); -#endif - //added for AP roaming - ieee->LinkDetectInfo.SlotNum = 2; - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - ieee->assoc_id = 0; - ieee->queue_stop = 0; - ieee->scanning = 0; - ieee->softmac_features = 0; //so IEEE2100-like driver are happy - ieee->wap_set = 0; - ieee->ssid_set = 0; - ieee->proto_started = 0; - ieee->basic_rate = IEEE80211_DEFAULT_BASIC_RATE; - ieee->rate = 22; - ieee->ps = IEEE80211_PS_DISABLED; - ieee->sta_sleep = 0; - ieee->Regdot11HTOperationalRateSet[0]= 0xff;//support MCS 0~7 - ieee->Regdot11HTOperationalRateSet[1]= 0xff;//support MCS 8~15 - ieee->Regdot11HTOperationalRateSet[4]= 0x01; - //added by amy - ieee->actscanning = false; - ieee->beinretry = false; - ieee->is_set_key = false; - init_mgmt_queue(ieee); - - ieee->sta_edca_param[0] = 0x0000A403; - ieee->sta_edca_param[1] = 0x0000A427; - ieee->sta_edca_param[2] = 0x005E4342; - ieee->sta_edca_param[3] = 0x002F3262; - ieee->aggregation = true; - ieee->enable_rx_imm_BA = 1; - ieee->tx_pending.txb = NULL; - - init_timer(&ieee->associate_timer); - ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; - - init_timer(&ieee->beacon_timer); - ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - - ieee->wq = create_workqueue(DRV_NAME); - - INIT_DELAYED_WORK(&ieee->start_ibss_wq,ieee80211_start_ibss_wq); - INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq); - INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq); - INIT_DELAYED_WORK(&ieee->softmac_scan_wq,ieee80211_softmac_scan_wq); - INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq); - INIT_WORK(&ieee->wx_sync_scan_wq,ieee80211_wx_sync_scan_wq); - - sema_init(&ieee->wx_sem, 1); - sema_init(&ieee->scan_sem, 1); -#ifdef ENABLE_IPS - sema_init(&ieee->ips_sem,1); -#endif - spin_lock_init(&ieee->mgmt_tx_lock); - spin_lock_init(&ieee->beacon_lock); - - tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, - (unsigned long)ieee); - -} - -void ieee80211_softmac_free(struct ieee80211_device *ieee) -{ - down(&ieee->wx_sem); -#ifdef ENABLE_DOT11D - kfree(ieee->pDot11dInfo); - ieee->pDot11dInfo = NULL; -#endif - del_timer_sync(&ieee->associate_timer); - - cancel_delayed_work(&ieee->associate_retry_wq); - destroy_workqueue(ieee->wq); - - up(&ieee->wx_sem); -} - -/******************************************************** - * Start of WPA code. * - * this is stolen from the ipw2200 driver * - ********************************************************/ - - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) -{ - /* This is called when wpa_supplicant loads and closes the driver - * interface. */ - printk("%s WPA\n",value ? "enabling" : "disabling"); - ieee->wpa_enabled = value; - return 0; -} - - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) -{ - /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); - - ieee80211_disassociate(ieee); -} - - -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) -{ - - int ret = 0; - - switch (command) { - case IEEE_MLME_STA_DEAUTH: - // silently ignore - break; - - case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); - break; - - default: - printk("Unknown MLME request: %d\n", command); - ret = -EOPNOTSUPP; - } - - return ret; -} - - -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, - struct ieee_param *param, int plen) -{ - u8 *buf; - - if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || - (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL)) - return -EINVAL; - - if (param->u.wpa_ie.len) { - buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len, - GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; - - kfree(ieee->wpa_ie); - ieee->wpa_ie = buf; - ieee->wpa_ie_len = param->u.wpa_ie.len; - } else { - kfree(ieee->wpa_ie); - ieee->wpa_ie = NULL; - ieee->wpa_ie_len = 0; - } - - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); - return 0; -} - -#define AUTH_ALG_OPEN_SYSTEM 0x1 -#define AUTH_ALG_SHARED_KEY 0x2 - -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) -{ - - struct ieee80211_security sec = { - .flags = SEC_AUTH_MODE, - }; - int ret = 0; - - if (value & AUTH_ALG_SHARED_KEY) { - sec.auth_mode = WLAN_AUTH_SHARED_KEY; - ieee->open_wep = 0; - ieee->auth_mode = 1; - } else if (value & AUTH_ALG_OPEN_SYSTEM){ - sec.auth_mode = WLAN_AUTH_OPEN; - ieee->open_wep = 1; - ieee->auth_mode = 0; - } - else if (value & IW_AUTH_ALG_LEAP){ - sec.auth_mode = WLAN_AUTH_LEAP; - ieee->open_wep = 1; - ieee->auth_mode = 2; - } - - - if (ieee->set_security) - ieee->set_security(ieee, &sec); - - return ret; -} - -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) -{ - int ret=0; - unsigned long flags; - - switch (name) { - case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); - break; - - case IEEE_PARAM_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures=value; - break; - - case IEEE_PARAM_DROP_UNENCRYPTED: { - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ - struct ieee80211_security sec = { - .flags = SEC_ENABLED, - .enabled = value, - }; - ieee->drop_unencrypted = value; - /* We only change SEC_LEVEL for open mode. Others - * are set by ipw_wpa_set_encryption. - */ - if (!value) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_0; - } - else { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } - if (ieee->set_security) - ieee->set_security(ieee, &sec); - break; - } - - case IEEE_PARAM_PRIVACY_INVOKED: - ieee->privacy_invoked=value; - break; - - case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); - break; - - case IEEE_PARAM_IEEE_802_1X: - ieee->ieee802_1x=value; - break; - case IEEE_PARAM_WPAX_SELECT: - // added for WPA2 mixed mode - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); - ieee->wpax_type_set = 1; - ieee->wpax_type_notify = value; - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); - break; - - default: - printk("Unknown WPA param: %d\n",name); - ret = -EOPNOTSUPP; - } - - return ret; -} - -/* implementation borrowed from hostap driver */ - -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, - struct ieee_param *param, int param_len) -{ - int ret = 0; - - struct ieee80211_crypto_ops *ops; - struct ieee80211_crypt_data **crypt; - - struct ieee80211_security sec = { - .flags = 0, - }; - - param->u.crypt.err = 0; - param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - - if (param_len != - (int) ((char *) param->u.crypt.key - (char *) param) + - param->u.crypt.key_len) { - printk("Len mismatch %d, %d\n", param_len, - param->u.crypt.key_len); - return -EINVAL; - } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { - if (param->u.crypt.idx >= WEP_KEYS) - return -EINVAL; - crypt = &ieee->crypt[param->u.crypt.idx]; - } else { - return -EINVAL; - } - - if (strcmp(param->u.crypt.alg, "none") == 0) { - if (crypt) { - sec.enabled = 0; - // FIXME FIXME - //sec.encrypt = 0; - sec.level = SEC_LEVEL_0; - sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); - } - goto done; - } - sec.enabled = 1; -// FIXME FIXME -// sec.encrypt = 1; - sec.flags |= SEC_ENABLED; - - /* IPW HW cannot build TKIP MIC, host decryption still needed. */ - if (!(ieee->host_encrypt || ieee->host_decrypt) && - strcmp(param->u.crypt.alg, "TKIP")) - goto skip_host_crypt; - - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - /* set WEP40 first, it will be modified according to WEP104 or - * WEP40 at other place */ - else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - if (ops == NULL) { - printk("unknown crypto alg '%s'\n", param->u.crypt.alg); - param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; - ret = -EINVAL; - goto done; - } - - if (*crypt == NULL || (*crypt)->ops != ops) { - struct ieee80211_crypt_data *new_crypt; - - ieee80211_crypt_delayed_deinit(ieee, crypt); - - new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ops; - if (new_crypt->ops) - new_crypt->priv = - new_crypt->ops->init(param->u.crypt.idx); - - if (new_crypt->priv == NULL) { - kfree(new_crypt); - param->u.crypt.err = IEEE_CRYPT_ERR_CRYPT_INIT_FAILED; - ret = -EINVAL; - goto done; - } - - *crypt = new_crypt; - } - - if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(param->u.crypt.key, - param->u.crypt.key_len, param->u.crypt.seq, - (*crypt)->priv) < 0) { - printk("key setting failed\n"); - param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; - ret = -EINVAL; - goto done; - } - - skip_host_crypt: - if (param->u.crypt.set_tx) { - ieee->tx_keyidx = param->u.crypt.idx; - sec.active_key = param->u.crypt.idx; - sec.flags |= SEC_ACTIVE_KEY; - } else - sec.flags &= ~SEC_ACTIVE_KEY; - - if (param->u.crypt.alg != NULL) { - memcpy(sec.keys[param->u.crypt.idx], - param->u.crypt.key, - param->u.crypt.key_len); - sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len; - sec.flags |= (1 << param->u.crypt.idx); - - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - } - done: - if (ieee->set_security) - ieee->set_security(ieee, &sec); - - /* Do not reset port if card is in Managed mode since resetting will - * generate new IEEE 802.11 authentication which may end up in looping - * with IEEE 802.1X. If your hardware requires a reset after WEP - * configuration (for example... Prism2), implement the reset_port in - * the callbacks structures used to initialize the 802.11 stack. */ - if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && - ieee->reset_port(ieee)) { - printk("reset_port failed\n"); - param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; - return -EINVAL; - } - - return ret; -} - -inline struct sk_buff *ieee80211_disassociate_skb( - struct ieee80211_network *beacon, - struct ieee80211_device *ieee, - u8 asRsn) -{ - struct sk_buff *skb; - struct ieee80211_disassoc *disass; - - skb = dev_alloc_skb(sizeof(struct ieee80211_disassoc)); - if (!skb) - return NULL; - - disass = (struct ieee80211_disassoc *) skb_put(skb,sizeof(struct ieee80211_disassoc)); - disass->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_DISASSOC); - disass->header.duration_id = 0; - - memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN); - - disass->reason = asRsn; - return skb; -} - - -void -SendDisassociation( - struct ieee80211_device *ieee, - u8* asSta, - u8 asRsn -) -{ - struct ieee80211_network *beacon = &ieee->current_network; - struct sk_buff *skb; - skb = ieee80211_disassociate_skb(beacon,ieee,asRsn); - if (skb){ - softmac_mgmt_xmit(skb, ieee); - //dev_kfree_skb_any(skb);//edit by thomas - } -} - -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) -{ - struct ieee_param *param; - int ret=0; - - down(&ieee->wx_sem); - //IEEE_DEBUG_INFO("wpa_supplicant: len=%d\n", p->length); - - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } - - param = kmalloc(p->length, GFP_KERNEL); - if (param == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - - case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, - param->u.wpa_param.value); - break; - - case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); - break; - - case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); - break; - - case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, - param->u.mlme.reason_code); - break; - - default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); - ret = -EOPNOTSUPP; - break; - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - - kfree(param); -out: - up(&ieee->wx_sem); - - return ret; -} - -void notify_wx_assoc_event(struct ieee80211_device *ieee) -{ - union iwreq_data wrqu; - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - if (ieee->state == IEEE80211_LINKED) - memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - else - memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); - wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); -} diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192e/ieee80211/rtl819x_BAProc.c deleted file mode 100644 index b690cbc5136..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_BAProc.c +++ /dev/null @@ -1,676 +0,0 @@ -/* - * This file is created to process BA Action Frame. According to 802.11 spec, - * there are 3 BA action types at all. And as BA is related to TS, this part - * need some struture defined in QOS side code. Also TX RX is going to be - * resturctured, so how to send ADDBAREQ ADDBARSP and DELBA packet is still - * on consideration. Temporarily use MANAGE QUEUE instead of Normal Queue. - */ -#include "ieee80211.h" -#include "rtl819x_BA.h" - -/* - * Activate BA entry. And if Time is nozero, start timer. - */ -void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time) -{ - pBA->bValid = true; - if(Time != 0) - mod_timer(&pBA->Timer, jiffies + MSECS(Time)); -} - -/* - * deactivate BA entry, including its timer. - */ -void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA) -{ - pBA->bValid = false; - del_timer_sync(&pBA->Timer); -} - -/* - * deactivete BA entry in Tx Ts, and send DELBA. - */ -u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs) -{ - PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure - PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; - u8 bSendDELBA = false; - - // Delete pending BA - if(pPendingBa->bValid) - { - DeActivateBAEntry(ieee, pPendingBa); - bSendDELBA = true; - } - - // Delete admitted BA - if(pAdmittedBa->bValid) - { - DeActivateBAEntry(ieee, pAdmittedBa); - bSendDELBA = true; - } - - return bSendDELBA; -} - -/* - * deactivete BA entry in Tx Ts, and send DELBA. - */ -u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs) -{ - PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; - u8 bSendDELBA = false; - - if(pBa->bValid) - { - DeActivateBAEntry(ieee, pBa); - bSendDELBA = true; - } - - return bSendDELBA; -} - -/* - * reset BA entry - */ -void ResetBaEntry( PBA_RECORD pBA) -{ - pBA->bValid = false; - pBA->BaParamSet.shortData = 0; - pBA->BaTimeoutValue = 0; - pBA->DialogToken = 0; - pBA->BaStartSeqCtrl.ShortData = 0; -} - -/* - * construct ADDBAREQ and ADDBARSP frame here together. - * return constructed skb to xmit - */ -static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) -{ - struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr* BAReq = NULL; - u8* tag = NULL; - u16 tmp = 0; - u16 len = ieee->tx_headroom + 9; - //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2)) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __FUNCTION__, type, Dst, ieee->dev); - if (pBA == NULL||ieee == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); - return NULL; - } - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME - if (skb == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); - return NULL; - } - - memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. - skb_reserve(skb, ieee->tx_headroom); - - BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); - - memcpy(BAReq->addr1, Dst, ETH_ALEN); - memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); - - memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); - - BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame - - //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field - tag = (u8*)skb_put(skb, 9); - *tag ++= ACT_CAT_BA; - *tag ++= type; - // Dialog Token - *tag ++= pBA->DialogToken; - - if (ACT_ADDBARSP == type) - { - // Status Code - printk("=====>to send ADDBARSP\n"); - tmp = cpu_to_le16(StatusCode); - memcpy(tag, (u8*)&tmp, 2); - tag += 2; - } - // BA Parameter Set - tmp = cpu_to_le16(pBA->BaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); - tag += 2; - // BA Timeout Value - tmp = cpu_to_le16(pBA->BaTimeoutValue); - memcpy(tag, (u8*)&tmp, 2); - tag += 2; - - if (ACT_ADDBAREQ == type) - { - // BA Start SeqCtrl - memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2); - tag += 2; - } - - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - return skb; - //return NULL; -} - -/* - * construct DELBA frame - */ -static struct sk_buff* ieee80211_DELBA( - struct ieee80211_device* ieee, - u8* dst, - PBA_RECORD pBA, - TR_SELECT TxRxSelect, - u16 ReasonCode - ) -{ - DELBA_PARAM_SET DelbaParamSet; - struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr* Delba = NULL; - u8* tag = NULL; - u16 tmp = 0; - //len = head len + DELBA Parameter Set(2) + Reason Code(2) - u16 len = 6 + ieee->tx_headroom; - - if (net_ratelimit()) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __FUNCTION__, ReasonCode, dst); - - memset(&DelbaParamSet, 0, 2); - - DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; - DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME - if (skb == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); - return NULL; - } -// memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr)); - skb_reserve(skb, ieee->tx_headroom); - - Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); - - memcpy(Delba->addr1, dst, ETH_ALEN); - memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); - Delba->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame - - tag = (u8*)skb_put(skb, 6); - - *tag ++= ACT_CAT_BA; - *tag ++= ACT_DELBA; - - // DELBA Parameter Set - tmp = cpu_to_le16(DelbaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); - tag += 2; - // Reason Code - tmp = cpu_to_le16(ReasonCode); - memcpy(tag, (u8*)&tmp, 2); - tag += 2; - - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - if (net_ratelimit()) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__); - return skb; -} - -/* - * send ADDBAReq frame out - * If any possible, please hide pBA in ieee. - * And temporarily use Manage Queue as softmac_mgmt_xmit() usually does - */ -void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA) -{ - struct sk_buff *skb = NULL; - skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero. - - if (skb) - { - softmac_mgmt_xmit(skb, ieee); - //add statistic needed here. - //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit() - //WB - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); - } -} - -/* - * send ADDBARSP frame out - * If any possible, please hide pBA in ieee. - * And temporarily use Manage Queue as softmac_mgmt_xmit() usually does - */ -void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode) -{ - struct sk_buff *skb = NULL; - skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames - if (skb) - { - softmac_mgmt_xmit(skb, ieee); - //same above - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); - } -} - -/* - * send ADDBARSP frame out - * If any possible, please hide pBA in ieee. - * And temporarily use Manage Queue as softmac_mgmt_xmit() usually does - */ -void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode) -{ - struct sk_buff *skb = NULL; - skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames - if (skb) - { - softmac_mgmt_xmit(skb, ieee); - //same above - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); - } - return ; -} - -int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb) -{ - struct ieee80211_hdr_3addr* req = NULL; - u16 rc = 0; - u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; - PBA_RECORD pBA = NULL; - PBA_PARAM_SET pBaParamSet = NULL; - u16* pBaTimeoutVal = NULL; - PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; - PRX_TS_RECORD pTS = NULL; - - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); - return -1; - } - - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - - req = ( struct ieee80211_hdr_3addr*) skb->data; - tag = (u8*)req; - dst = (u8*)(&req->addr2[0]); - tag += sizeof( struct ieee80211_hdr_3addr); - pDialogToken = tag + 2; //category+action - pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken - pBaTimeoutVal = (u16*)(tag + 5); - pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7); - - printk("====================>rx ADDBAREQ from :%pM\n", dst); -//some other capability is not ready now. - if( (ieee->current_network.qos_data.active == 0) || - (ieee->pHTInfo->bCurrentHTSupport == false)) //|| - // (ieee->pStaQos->bEnableRxImmBA == false) ) - { - rc = ADDBA_STATUS_REFUSED; - IEEE80211_DEBUG(IEEE80211_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); - goto OnADDBAReq_Fail; - } - // Search for related traffic stream. - // If there is no matched TS, reject the ADDBA request. - if( !GetTs( - ieee, - (PTS_COMMON_INFO*)(&pTS), - dst, - (u8)(pBaParamSet->field.TID), - RX_DIR, - true) ) - { - rc = ADDBA_STATUS_REFUSED; - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__); - goto OnADDBAReq_Fail; - } - pBA = &pTS->RxAdmittedBARecord; - // To Determine the ADDBA Req content - // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl... - // I want to check StartSeqCtrl to make sure when we start aggregation!!! - // - if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { - rc = ADDBA_STATUS_INVALID_PARAM; - IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__); - goto OnADDBAReq_Fail; - } - // Admit the ADDBA Request - // - DeActivateBAEntry(ieee, pBA); - pBA->DialogToken = *pDialogToken; - pBA->BaParamSet = *pBaParamSet; - pBA->BaTimeoutValue = *pBaTimeoutVal; - pBA->BaStartSeqCtrl = *pBaStartSeqCtrl; - //for half N mode we only aggregate 1 frame - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee)) - pBA->BaParamSet.field.BufferSize = 1; - else - pBA->BaParamSet.field.BufferSize = 32; - ActivateBAEntry(ieee, pBA, pBA->BaTimeoutValue); - ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS); - - // End of procedure. - return 0; - -OnADDBAReq_Fail: - { - BA_RECORD BA; - BA.BaParamSet = *pBaParamSet; - BA.BaTimeoutValue = *pBaTimeoutVal; - BA.DialogToken = *pDialogToken; - BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE; - ieee80211_send_ADDBARsp(ieee, dst, &BA, rc); - return 0; //we send RSP out. - } - -} - -int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb) -{ - struct ieee80211_hdr_3addr* rsp = NULL; - PBA_RECORD pPendingBA, pAdmittedBA; - PTX_TS_RECORD pTS = NULL; - u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; - u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; - PBA_PARAM_SET pBaParamSet = NULL; - u16 ReasonCode; - - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); - return -1; - } - rsp = ( struct ieee80211_hdr_3addr*)skb->data; - tag = (u8*)rsp; - dst = (u8*)(&rsp->addr2[0]); - tag += sizeof( struct ieee80211_hdr_3addr); - pDialogToken = tag + 2; - pStatusCode = (u16*)(tag + 3); - pBaParamSet = (PBA_PARAM_SET)(tag + 5); - pBaTimeoutVal = (u16*)(tag + 7); - - // Check the capability - // Since we can always receive A-MPDU, we just check if it is under HT mode. - if( ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); - ReasonCode = DELBA_REASON_UNKNOWN_BA; - goto OnADDBARsp_Reject; - } - - - // - // Search for related TS. - // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame. - // - if (!GetTs( - ieee, - (PTS_COMMON_INFO*)(&pTS), - dst, - (u8)(pBaParamSet->field.TID), - TX_DIR, - false) ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__); - ReasonCode = DELBA_REASON_UNKNOWN_BA; - goto OnADDBARsp_Reject; - } - - pTS->bAddBaReqInProgress = false; - pPendingBA = &pTS->TxPendingBARecord; - pAdmittedBA = &pTS->TxAdmittedBARecord; - - - // - // Check if related BA is waiting for setup. - // If not, reject by sending DELBA frame. - // - if((pAdmittedBA->bValid==true)) - { - // Since BA is already setup, we ignore all other ADDBA Response. - IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); - return -1; - } - else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); - ReasonCode = DELBA_REASON_UNKNOWN_BA; - goto OnADDBARsp_Reject; - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); - DeActivateBAEntry(ieee, pPendingBA); - } - - - if(*pStatusCode == ADDBA_STATUS_SUCCESS) - { - // - // Determine ADDBA Rsp content here. - // We can compare the value of BA parameter set that Peer returned and Self sent. - // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism. - // - if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { - // Since this is a kind of ADDBA failed, we delay next ADDBA process. - pTS->bAddBaReqDelayed = true; - DeActivateBAEntry(ieee, pAdmittedBA); - ReasonCode = DELBA_REASON_END_BA; - goto OnADDBARsp_Reject; - } - - - // - // Admitted condition - // - pAdmittedBA->DialogToken = *pDialogToken; - pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal; - pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl; - pAdmittedBA->BaParamSet = *pBaParamSet; - DeActivateBAEntry(ieee, pAdmittedBA); - ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal); - } - else - { - // Delay next ADDBA process. - pTS->bAddBaReqDelayed = true; - } - - // End of procedure - return 0; - -OnADDBARsp_Reject: - { - BA_RECORD BA; - BA.BaParamSet = *pBaParamSet; - ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); - return 0; - } - -} - -int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb) -{ - struct ieee80211_hdr_3addr* delba = NULL; - PDELBA_PARAM_SET pDelBaParamSet = NULL; - u16* pReasonCode = NULL; - u8* dst = NULL; - - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6)); - return -1; - } - - if(ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); - return -1; - } - - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - delba = ( struct ieee80211_hdr_3addr*)skb->data; - dst = (u8*)(&delba->addr2[0]); - delba += sizeof( struct ieee80211_hdr_3addr); - pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2); - pReasonCode = (u16*)(delba+4); - - if(pDelBaParamSet->field.Initiator == 1) - { - PRX_TS_RECORD pRxTs; - - if( !GetTs( - ieee, - (PTS_COMMON_INFO*)&pRxTs, - dst, - (u8)pDelBaParamSet->field.TID, - RX_DIR, - false) ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__); - return -1; - } - - RxTsDeleteBA(ieee, pRxTs); - } - else - { - PTX_TS_RECORD pTxTs; - - if(!GetTs( - ieee, - (PTS_COMMON_INFO*)&pTxTs, - dst, - (u8)pDelBaParamSet->field.TID, - TX_DIR, - false) ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__); - return -1; - } - - pTxTs->bUsingBa = false; - pTxTs->bAddBaReqInProgress = false; - pTxTs->bAddBaReqDelayed = false; - del_timer_sync(&pTxTs->TsAddBaTimer); - //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer); - TxTsDeleteBA(ieee, pTxTs); - } - return 0; -} - -/* ADDBA initiate. This can only be called by TX side. */ -void -TsInitAddBA( - struct ieee80211_device* ieee, - PTX_TS_RECORD pTS, - u8 Policy, - u8 bOverwritePending - ) -{ - PBA_RECORD pBA = &pTS->TxPendingBARecord; - - if(pBA->bValid==true && bOverwritePending==false) - return; - - // Set parameters to "Pending" variable set - DeActivateBAEntry(ieee, pBA); - - pBA->DialogToken++; // DialogToken: Only keep the latest dialog token - pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! - pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID - // BufferSize: This need to be set according to A-MPDU vector - pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector - pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer - pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later. - - ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); - - ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); -} - -void -TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) -{ - - if(TxRxSelect == TX_DIR) - { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; - - if(TxTsDeleteBA(ieee, pTxTs)) - ieee80211_send_DELBA( - ieee, - pTsCommonInfo->Addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), - TxRxSelect, - DELBA_REASON_END_BA); - } - else if(TxRxSelect == RX_DIR) - { - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo; - if(RxTsDeleteBA(ieee, pRxTs)) - ieee80211_send_DELBA( - ieee, - pTsCommonInfo->Addr, - &pRxTs->RxAdmittedBARecord, - TxRxSelect, - DELBA_REASON_END_BA ); - } -} - -/* - * BA setup timer - * acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer - */ -void BaSetupTimeOut(unsigned long data) -{ - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; - - pTxTs->bAddBaReqInProgress = false; - pTxTs->bAddBaReqDelayed = true; - pTxTs->TxPendingBARecord.bValid = false; -} - -void TxBaInactTimeout(unsigned long data) -{ - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; - struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]); - TxTsDeleteBA(ieee, pTxTs); - ieee80211_send_DELBA( - ieee, - pTxTs->TsCommonInfo.Addr, - &pTxTs->TxAdmittedBARecord, - TX_DIR, - DELBA_REASON_TIMEOUT); -} - -void RxBaInactTimeout(unsigned long data) -{ - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; - struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); - - RxTsDeleteBA(ieee, pRxTs); - ieee80211_send_DELBA( - ieee, - pRxTs->TsCommonInfo.Addr, - &pRxTs->RxAdmittedBARecord, - RX_DIR, - DELBA_REASON_TIMEOUT); -} - diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192e/ieee80211/rtl819x_HTProc.c deleted file mode 100644 index f7a9da3ec82..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_HTProc.c +++ /dev/null @@ -1,1732 +0,0 @@ - -//As this function is mainly ported from Windows driver, so leave the name little changed. If any confusion caused, tell me. Created by WB. 2008.05.08 -#include "ieee80211.h" -#include "rtl819x_HT.h" -u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -u16 MCS_DATA_RATE[2][2][77] = - { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260, - 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520, - 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195, - 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260, - 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, // Long GI, 20MHz - {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, - 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578, - 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217, - 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289, - 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, // Short GI, 20MHz - { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, - 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, - 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, - 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, - 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz - {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, - 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, - 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, - 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600, - 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } // Short GI, 40MHz - }; - -static const u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf}; -static const u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70}; -static const u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e}; -//static u8 NETGEAR834Bv2_BROADCOM[3] = {0x00, 0x1b, 0x2f}; -static const u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; -static const u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf}; -static const u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc}; -static const u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; -static const u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; -static const u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0}; -static const u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; -static const u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; - -// 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we put the -// code in other place?? -//static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96}; -/******************************************************************************************************************** - *function: This function update default settings in pHTInfo structure - * input: PRT_HIGH_THROUGHPUT pHTInfo - * output: none - * return: none - * notice: These value need be modified if any changes. - * *****************************************************************************************************************/ -void HTUpdateDefaultSetting(struct ieee80211_device* ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - // ShortGI support - pHTInfo->bRegShortGI20MHz= 1; - pHTInfo->bRegShortGI40MHz= 1; - - // 40MHz channel support - pHTInfo->bRegBW40MHz = 1; - - // CCK rate support in 40MHz channel - if(pHTInfo->bRegBW40MHz) - pHTInfo->bRegSuppCCK = 1; - else - pHTInfo->bRegSuppCCK = true; - - // AMSDU related - pHTInfo->nAMSDU_MaxSize = 7935UL; - pHTInfo->bAMSDU_Support = 0; - - // AMPDU related - pHTInfo->bAMPDUEnable = 1; - pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k) - pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec - - // MIMO Power Save - pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.) - if(pHTInfo->SelfMimoPs == 2) - pHTInfo->SelfMimoPs = 3; - // 8190 only. Assign rate operation mode to firmware - ieee->bTxDisableRateFallBack = 0; - ieee->bTxUseDriverAssingedRate = 0; - -#ifdef TO_DO_LIST - // 8190 only. Assign duration operation mode to firmware - pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur; -#endif - // 8190 only, Realtek proprietary aggregation mode - // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others - pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others - - // For Rx Reorder Control - pHTInfo->bRegRxReorderEnable = 1; - pHTInfo->RxReorderWinSize = 64; - pHTInfo->RxReorderPendingTime = 30; - -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - pHTInfo->UsbTxAggrNum = 4; -#endif -#ifdef USB_RX_AGGREGATION_SUPPORT - pHTInfo->UsbRxFwAggrEn = 1; - pHTInfo->UsbRxFwAggrPageNum = 24; - pHTInfo->UsbRxFwAggrPacketNum = 8; - pHTInfo->UsbRxFwAggrTimeout = 16; ////usb rx FW aggregation timeout threshold.It's in units of 64us -#endif - - -} -/******************************************************************************************************************** - *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq) - * input: u8* CapIE //Capability IE to be printed out - * u8* TitleString //mainly print out caller function - * output: none - * return: none - * notice: Driver should not print out this message by default. - * *****************************************************************************************************************/ -void HTDebugHTCapability(u8* CapIE, u8* TitleString ) -{ - - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily - PHT_CAPABILITY_ELE pCapELE; - - if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) - { - //EWC IE - IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__); - pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]); - }else - pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]); - - IEEE80211_DEBUG(IEEE80211_DL_HT, ". Called by %s\n", TitleString ); - - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO"); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ - pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); -} -/******************************************************************************************************************** - *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp) - * input: u8* InfoIE //Capability IE to be printed out - * u8* TitleString //mainly print out caller function - * output: none - * return: none - * notice: Driver should not print out this message by default. - * *****************************************************************************************************************/ -void HTDebugHTInfo(u8* InfoIE, u8* TitleString) -{ - - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily - PHT_INFORMATION_ELE pHTInfoEle; - - if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - { - // Not EWC IE - IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__); - pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]); - }else - pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]); - - - IEEE80211_DEBUG(IEEE80211_DL_HT, ". Called by %s\n", TitleString); - - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl); - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSenondary channel ="); - switch(pHTInfoEle->ExtChlOffset) - { - case 0: - IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n"); - break; - case 1: - IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n"); - break; - case 2: - IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n"); - break; - case 3: - IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n"); - break; - } - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz"); - - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = "); - switch(pHTInfoEle->OptMode) - { - case 0: - IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n"); - break; - case 1: - IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n"); - break; - case 2: - IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n"); - break; - case 3: - IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n"); - break; - } - - IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ - pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); -} - -/* -* Return: true if station in half n mode and AP supports 40 bw -*/ -bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee) -{ - bool retValue = false; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode - retValue = false; - else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw - retValue = false; - else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee)) // station in half n mode - retValue = false; - else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw - retValue = true; - else - retValue = false; - - return retValue; -} - -bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz) -{ - bool retValue = false; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode - retValue = false; - else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee)) // station in half n mode - retValue = false; - else if(is40MHz) // ap support 40 bw - { - if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI - retValue = true; - else - retValue = false; - } - else - { - if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI - retValue = true; - else - retValue = false; - } - - return retValue; -} - -u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate) -{ - - u8 is40MHz; - u8 isShortGI; - - is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0; - isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0; - - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; -} - - -u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; - u8 isShortGI = (pHTInfo->bCurBW40MHz)? - ((pHTInfo->bCurShortGI40MHz)?1:0): - ((pHTInfo->bCurShortGI20MHz)?1:0); - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; -} - -/******************************************************************************************************************** - *function: This function returns current datarate. - * input: struct ieee80211_device* ieee - * u8 nDataRate - * output: none - * return: tx rate - * notice: quite unsure about how to use this function //wb - * *****************************************************************************************************************/ -u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate) -{ - //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c}; - u8 is40MHz = 0; - u8 isShortGI = 0; - - if(nDataRate < 12) - { - return CCKOFDMRate[nDataRate]; - } - else - { - if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 ) - { - is40MHz = 0; - isShortGI = 0; - - // nDataRate = nDataRate - 12; - } - else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44) - { - is40MHz = 1; - isShortGI = 0; - - //nDataRate = nDataRate - 28; - } - else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60) - { - is40MHz = 0; - isShortGI = 1; - - //nDataRate = nDataRate - 44; - } - else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76) - { - is40MHz = 1; - isShortGI = 1; - - //nDataRate = nDataRate - 60; - } - return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; - } -} - - - -bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee) -{ - bool retValue = false; - struct ieee80211_network* net = &ieee->current_network; -#if 0 - if(ieee->bHalfNMode == false) - retValue = false; - else -#endif - if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - (net->ralink_cap_exist)) - retValue = true; - else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| - //(memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) || - (net->broadcom_cap_exist)) - retValue = true; - else if(net->bssht.bdRT2RTAggregation) - retValue = true; - else - retValue = false; - - return retValue; -} - -/******************************************************************************************************************** - *function: This function returns peer IOT. - * input: struct ieee80211_device* ieee - * output: none - * return: - * notice: - * *****************************************************************************************************************/ -void HTIOTPeerDetermine(struct ieee80211_device* ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - struct ieee80211_network* net = &ieee->current_network; - if(net->bssht.bdRT2RTAggregation) - pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; - else if(net->broadcom_cap_exist){ - pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - } - else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)){//|| - //(memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ){ - pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - } - else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - net->ralink_cap_exist) - pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; - else if((net->atheros_cap_exist )|| (memcmp(net->bssid, DLINK_ATHEROS, 3) == 0)) - pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; - else if(memcmp(net->bssid, CISCO_BROADCOM, 3)==0) - pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; - else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || - net->marvell_cap_exist){ - pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL; - } - else - pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - - IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); -} -/******************************************************************************************************************** - *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good - * at receiving MCS14~15 frame from some AP. - * input: struct ieee80211_device* ieee - * u8 * PeerMacAddr - * output: none - * return: return 1 if driver should declare MCS13 only(otherwise return 0) - * *****************************************************************************************************************/ -u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr) -{ - u8 ret = 0; -#if 0 - // Apply for 819u only -#if (HAL_CODE_BASE==RTL8192 && DEV_BUS_TYPE==USB_INTERFACE) - if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) - ) - { - ret = 1; - } - - - if(pHTInfo->bCurrentRT2RTAggregation) - { - // The parameter of pHTInfo->bCurrentRT2RTAggregation must be decided previously - ret = 1; - } -#endif -#endif - return ret; - } - -u8 HTIOTActIsForcedCTS2Self(struct ieee80211_device *ieee, struct ieee80211_network *network) -{ - u8 retValue = 0; - //if(network->marvell_cap_exist) - if(ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - { - retValue = 1; - } - - return retValue; -} - - -/** -* Function: HTIOTActIsDisableMCS15 -* -* Overview: Check whether driver should declare capability of receiving MCS15 -* -* Input: -* PADAPTER Adapter, -* -* Output: None -* Return: true if driver should disable MCS15 -* 2008.04.15 Emily -*/ -bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee) -{ - bool retValue = false; - -#ifdef TODO - // Apply for 819u only -#if (HAL_CODE_BASE==RTL8192) - -#if (DEV_BUS_TYPE == USB_INTERFACE) - // Alway disable MCS15 by Jerry Chang's request.by Emily, 2008.04.15 - retValue = true; -#elif (DEV_BUS_TYPE == PCI_INTERFACE) - // Enable MCS15 if the peer is Cisco AP. by Emily, 2008.05.12 -// if(pBssDesc->bCiscoCapExist) -// retValue = false; -// else - retValue = false; -#endif -#endif -#endif - // Jerry Chang suggest that 8190 1x2 does not need to disable MCS15 - - return retValue; -} - -/** -* Function: HTIOTActIsDisableMCSTwoSpatialStream -* -* Overview: Check whether driver should declare capability of receiving All 2 ss packets -* -* Input: -* PADAPTER Adapter, -* -* Output: None -* Return: true if driver should disable all two spatial stream packet -* 2008.04.21 Emily -*/ -bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *PeerMacAddr) -{ - bool retValue = false; - -#ifdef TODO - // Apply for 819u only -//#if (HAL_CODE_BASE==RTL8192) - - //This rule only apply to Belkin(Ralink) AP - if(IS_UNDER_11N_AES_MODE(Adapter)) - { - if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) || - (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) || - (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0)) - { - //Set True to disable this function. Disable by default, Emily, 2008.04.23 - retValue = false; - } - } - -//#endif -#endif - return retValue; -} - -/******************************************************************************************************************** - *function: Check whether driver should disable EDCA turbo mode - * input: struct ieee80211_device* ieee - * u8* PeerMacAddr - * output: none - * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0) - * *****************************************************************************************************************/ -u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr) -{ - u8 retValue = false; // default enable EDCA Turbo mode. - // Set specific EDCA parameter for different AP in DM handler. - - return retValue; -#if 0 - if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0)|| - (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| - (memcmp(PeerMacAddr, NETGEAR834Bv2_BROADCOM, 3)==0)) - - { - retValue = 1; //Linksys disable EDCA turbo mode - } - - return retValue; -#endif -} - -/******************************************************************************************************************** - *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP - * input: struct ieee80211_network *network //current network we live - * output: none - * return: return 1 if true - * *****************************************************************************************************************/ -u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network) -{ - u8 retValue = 0; - - // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP. - // 2008/01/28 MH We must prevent that we select null bssid to link. - - if(network->broadcom_cap_exist) - { - retValue = 1; - } - - return retValue; -} - -u8 HTIOTActIsCCDFsync(u8* PeerMacAddr) -{ - u8 retValue = 0; - if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) || - (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0)) - { - retValue = 1; - } - - return retValue; -} - -// -// Send null data for to tell AP that we are awake. -// -bool -HTIOTActIsNullDataPowerSaving(struct ieee80211_device* ieee,struct ieee80211_network *network) -{ - bool retValue = false; - - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) // ||(pBssDesc->Vender == HT_IOT_PEER_ATHEROS && pBssDesc->SubTypeOfVender == HT_IOT_PEER_ATHEROS_DIR635)) - return true; - - } - return retValue; -} - -void HTResetIOTSetting( - PRT_HIGH_THROUGHPUT pHTInfo -) -{ - pHTInfo->IOTAction = 0; - pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; -} - - -/******************************************************************************************************************** - *function: Construct Capablility Element in Beacon... if HTEnable is turned on - * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Capability Ele - * u8* len //store length of CE - * u8 IsEncrypt //whether encrypt, needed further - * output: none - * return: none - * notice: posHTCap can't be null and should be initialized before. - * *****************************************************************************************************************/ -void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt) -{ - PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; - PHT_CAPABILITY_ELE pCapELE = NULL; - //u8 bIsDeclareMCS13; - - if ((posHTCap == NULL) || (pHT == NULL)) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); - return; - } - memset(posHTCap, 0, *len); - if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { - u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily - memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); - pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]); - }else - { - pCapELE = (PHT_CAPABILITY_ELE)posHTCap; - } - - - //HT capability info - pCapELE->AdvCoding = 0; // This feature is not supported now!! - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee)) - { - pCapELE->ChlWidth = 0; - } - else - { - pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); - } - -// pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); - pCapELE->MimoPwrSave = pHT->SelfMimoPs; - pCapELE->GreenField = 0; // This feature is not supported now!! - pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!! - pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!! - //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r", - //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz); - pCapELE->TxSTBC = 1; - pCapELE->RxSTBC = 0; - pCapELE->DelayBA = 0; // Do not support now!! - pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; - pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); - pCapELE->PSMP = 0; // Do not support now!! - pCapELE->LSigTxopProtect = 0; // Do not support now!! - - - //MAC HT parameters info - // TODO: Nedd to take care of this part - IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); - - if( IsEncrypt) - { - pCapELE->MPDUDensity = 7; // 8us - pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K - } - else - { - pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K - pCapELE->MPDUDensity = 0; // no density - } - - //Supported MCS set - memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16); - if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15) - pCapELE->MCS[1] &= 0x7f; - - if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14) - pCapELE->MCS[1] &= 0xbf; - - if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS) - pCapELE->MCS[1] &= 0x00; - - // 2008.06.12 - // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7. - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee)) - { - int i; - for(i = 1; i< 16; i++) - pCapELE->MCS[i] = 0; - } - - //Extended HT Capability Info - memset(&pCapELE->ExtHTCapInfo, 0, 2); - - - //TXBF Capabilities - memset(pCapELE->TxBFCap, 0, 4); - - //Antenna Selection Capabilities - pCapELE->ASCap = 0; -//add 2 to give space for element ID and len when construct frames - if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC) - *len = 30 + 2; - else - *len = 26 + 2; -} -/******************************************************************************************************************** - *function: Construct Information Element in Beacon... if HTEnable is turned on - * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Information Ele - * u8* len //store len of - * u8 IsEncrypt //whether encrypt, needed further - * output: none - * return: none - * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this - * *****************************************************************************************************************/ -void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) -{ - PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; - PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; - if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); - return; - } - - memset(posHTInfo, 0, *len); - if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported - { - pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: - (ieee->current_network.channel<=6)? - HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); - pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; - pHTInfoEle->RIFS = 0; - pHTInfoEle->PSMPAccessOnly = 0; - pHTInfoEle->SrvIntGranularity = 0; - pHTInfoEle->OptMode = pHT->CurrentOpMode; - pHTInfoEle->NonGFDevPresent = 0; - pHTInfoEle->DualBeacon = 0; - pHTInfoEle->SecondaryBeacon = 0; - pHTInfoEle->LSigTxopProtectFull = 0; - pHTInfoEle->PcoActive = 0; - pHTInfoEle->PcoPhase = 0; - - memset(pHTInfoEle->BasicMSC, 0, 16); - - - *len = 22 + 2; //same above - - } - else - { - //STA should not generate High Throughput Information Element - *len = 0; - } -} - -/* - * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance - * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2 - * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set - * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP - * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently - * at the same time. - * - * Frame Format - * Element ID Length OUI Type1 Reserved - * 1 byte 1 byte 3 bytes 1 byte 1 byte - * - * OUI = 0x00, 0xe0, 0x4c, - * Type = 0x02 - * Reserved = 0x00 - * - * 2007.8.21 by Emily -*/ -/******************************************************************************************************************** - *function: Construct Information Element in Beacon... in RT2RT condition - * input: struct ieee80211_device* ieee - * u8* posRT2RTAgg //pointer to store Information Ele - * u8* len //store len - * output: none - * return: none - * notice: - * *****************************************************************************************************************/ -void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len) -{ - if (posRT2RTAgg == NULL) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); - return; - } - memset(posRT2RTAgg, 0, *len); - *posRT2RTAgg++ = 0x00; - *posRT2RTAgg++ = 0xe0; - *posRT2RTAgg++ = 0x4c; - *posRT2RTAgg++ = 0x02; - *posRT2RTAgg++ = 0x01; - *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02; - - if(ieee->bSupportRemoteWakeUp) { - *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW; - } - - *len = 6 + 2; - return; -#ifdef TODO -#if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE) - /* - //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this - section of code. - if(IS_UNDER_11N_AES_MODE(Adapter)) - { - posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU; - }else - { - posRT2RTAgg->Octet[5] &= 0xfb; - } - */ - -#else - // Do Nothing -#endif - - posRT2RTAgg->Length = 6; -#endif - - - - -} - - -/******************************************************************************************************************** - *function: Pick the right Rate Adaptive table to use - * input: struct ieee80211_device* ieee - * u8* pOperateMCS //A pointer to MCS rate bitmap - * return: always we return true - * notice: - * *****************************************************************************************************************/ -u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS) -{ - u8 i; - if (pOperateMCS == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); - return false; - } - - switch(ieee->mode) - { - case IEEE_A: - case IEEE_B: - case IEEE_G: - //legacy rate routine handled at selectedrate - - //no MCS rate - for(i=0;i<=15;i++){ - pOperateMCS[i] = 0; - } - break; - - case IEEE_N_24G: //assume CCK rate ok - case IEEE_N_5G: - // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G. - // Legacy part shall be handled at SelectRateSet(). - - //HT part - // TODO: may be different if we have different number of antenna - pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7 - pOperateMCS[1] &=RATE_ADPT_2SS_MASK; - pOperateMCS[3] &=RATE_ADPT_MCS32_MASK; - break; - - //should never reach here - default: - - break; - - } - - return true; -} - -/* -* Description: -* This function will get the highest speed rate in input MCS set. -* -* /param Adapter Pionter to Adapter entity -* pMCSRateSet Pointer to MCS rate bitmap -* pMCSFilter Pointer to MCS rate filter -* -* /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter. -* -*/ -/******************************************************************************************************************** - *function: This function will get the highest speed rate in input MCS set. - * input: struct ieee80211_device* ieee - * u8* pMCSRateSet //Pointer to MCS rate bitmap - * u8* pMCSFilter //Pointer to MCS rate filter - * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter - * notice: - * *****************************************************************************************************************/ -u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter) -{ - u8 i, j; - u8 bitMap; - u8 mcsRate = 0; - u8 availableMcsRate[16]; - if (pMCSRateSet == NULL || pMCSFilter == NULL) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); - return false; - } - for(i=0; i<16; i++) - availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i]; - - for(i = 0; i < 16; i++) - { - if(availableMcsRate[i] != 0) - break; - } - if(i == 16) - return false; - - for(i = 0; i < 16; i++) - { - if(availableMcsRate[i] != 0) - { - bitMap = availableMcsRate[i]; - for(j = 0; j < 8; j++) - { - if((bitMap%2) != 0) - { - if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) - mcsRate = (8*i+j); - } - bitMap = bitMap>>1; - } - } - } - return (mcsRate|0x80); -} - - - -/* -** -**1.Filter our operation rate set with AP's rate set -**2.shall reference channel bandwidth, STBC, Antenna number -**3.generate rate adative table for firmware -**David 20060906 -** -** \pHTSupportedCap: the connected STA's supported rate Capability element -*/ -u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS) -{ - - u8 i=0; - - // filter out operational rate set not supported by AP, the lenth of it is 16 - for(i=0;i<=15;i++){ - pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i]; - } - - - // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number - - // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet - // we also shall suggested the first start rate set according to our singal strength - HT_PickMCSRate(ieee, pOperateMCS); - - // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7. - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee)) - pOperateMCS[1] = 0; - - // - // For RTL819X, we support only MCS0~15. - // And also, we do not know how to use MCS32 now. - // - for(i=2; i<=15; i++) - pOperateMCS[i] = 0; - - return true; -} -void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); -void HTOnAssocRsp(struct ieee80211_device *ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - PHT_CAPABILITY_ELE pPeerHTCap = NULL; - PHT_INFORMATION_ELE pPeerHTInfo = NULL; - u16 nMaxAMSDUSize = 0; - u8* pMcsFilter = NULL; - - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily - - if( pHTInfo->bCurrentHTSupport == false ) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); - return; - } - IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); -// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTCapBuf, sizeof(HT_CAPABILITY_ELE)); -// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTInfoBuf, sizeof(HT_INFORMATION_ELE)); - -// HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq"); -// HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq"); - // - if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) - pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]); - else - pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf); - - if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]); - else - pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf); - - - //////////////////////////////////////////////////////// - // Configurations: - //////////////////////////////////////////////////////// - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); -// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE)); - // Config Supported Channel Width setting - // - HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); - -// if(pHTInfo->bCurBW40MHz == true) - pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); - - // - // Update short GI/ long GI setting - // - // TODO: - pHTInfo->bCurShortGI20MHz= - ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false); - pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false); - - // - // Config TX STBC setting - // - // TODO: - - // - // Config DSSS/CCK mode in 40MHz mode - // - // TODO: - pHTInfo->bCurSuppCCK = - ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false); - - - // - // Config and configure A-MSDU setting - // - pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; - if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){ - if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) || - (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) ) - pHTInfo->bCurrentAMPDUEnable = false; - } - - - nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935; - - if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize ) - pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; - else - pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - - - // - // Config A-MPDU setting - // - pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; - - // <1> Decide AMPDU Factor - - // By Emily - if(!pHTInfo->bRegRT2RTAggregation) - { - // Decide AMPDU Factor according to protocol handshake - if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; - else - pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - - }else - { - // Set MPDU density to 2 to Realtek AP, and set it to 0 for others - // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily -#if 0 - osTmp= PacketGetElement( asocpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE); - if(osTmp.Length >= 5) //00:e0:4c:02:00 -#endif - if (ieee->current_network.bssht.bdRT2RTAggregation) - { - if( ieee->pairwise_key_type != KEY_TYPE_NA) - // Realtek may set 32k in security mode and 64k for others - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; - else - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; - }else - { - if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; - else - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; - } - } - - // <2> Set AMPDU Minimum MPDU Start Spacing - // 802.11n 3.0 section 9.7d.3 -#if 1 - if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) - pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; - else - pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; - if(ieee->pairwise_key_type != KEY_TYPE_NA ) - pHTInfo->CurrentMPDUDensity = 7; // 8us -#else - if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) - pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; - else - pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; -#endif - // Force TX AMSDU - - // Lanhsin: mark for tmp to avoid deauth by ap from s3 - //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0) - if(0) - { - - pHTInfo->bCurrentAMPDUEnable = false; - pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; - pHTInfo->ForcedAMSDUMaxSize = 7935; - - pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K; - } - - // Rx Reorder Setting - pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable; - - // - // Filter out unsupported HT rate for this AP - // Update RATR table - // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism. - // - - // Handle Ralink AP bad MCS rate set condition. Joseph. - // This fix the bug of Ralink AP. This may be removed in the future. - if(pPeerHTCap->MCS[0] == 0) - pPeerHTCap->MCS[0] = 0xff; - - HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); - - // - // Config MIMO Power Save setting - // - pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave; - if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC) - pMcsFilter = MCS_FILTER_1SS; - else - pMcsFilter = MCS_FILTER_ALL; - //WB add for MCS8 bug -// pMcsFilter = MCS_FILTER_1SS; - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); - ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; - - // - // Config current operation mode. - // - pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - - - -} - -void HTSetConnectBwModeCallback(struct ieee80211_device* ieee); -/******************************************************************************************************************** - *function: initialize HT info(struct PRT_HIGH_THROUGHPUT) - * input: struct ieee80211_device* ieee - * output: none - * return: none - * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP -********************************************************************************************************************/ -// TODO: Should this funciton be called when receiving of Disassociation? -void HTInitializeHTInfo(struct ieee80211_device* ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - // - // These parameters will be reset when receiving deauthentication packet - // - IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__); - pHTInfo->bCurrentHTSupport = false; - - // 40MHz channel support - pHTInfo->bCurBW40MHz = false; - pHTInfo->bCurTxBW40MHz = false; - - // Short GI support - pHTInfo->bCurShortGI20MHz = false; - pHTInfo->bCurShortGI40MHz = false; - pHTInfo->bForcedShortGI = false; - - // CCK rate support - // This flag is set to true to support CCK rate by default. - // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to - // 11N BSS. - pHTInfo->bCurSuppCCK = true; - - // AMSDU related - pHTInfo->bCurrent_AMSDU_Support = false; - pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - - // AMPUD related - pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; - pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - - - - // Initialize all of the parameters related to 11n - memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); - memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); - memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); - memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); - - pHTInfo->bSwBwInProgress = false; - pHTInfo->ChnlOp = CHNLOP_NONE; - - // Set default IEEE spec for Draft N - pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE; - - // Realtek proprietary aggregation mode - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; - pHTInfo->IOTPeer = 0; - pHTInfo->IOTAction = 0; - - //MCS rate initialized here - { - u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); - RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7 - RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15 - RegHTSuppRateSets[4] = 0x01; //support MCS 32 - } -} -/******************************************************************************************************************** - *function: initialize Bss HT structure(struct PBSS_HT) - * input: PBSS_HT pBssHT //to be initialized - * output: none - * return: none - * notice: This function is called when initialize network structure -********************************************************************************************************************/ -void HTInitializeBssDesc(PBSS_HT pBssHT) -{ - - pBssHT->bdSupportHT = false; - memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf)); - pBssHT->bdHTCapLen = 0; - memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf)); - pBssHT->bdHTInfoLen = 0; - - pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE; - - pBssHT->bdRT2RTAggregation = false; - pBssHT->bdRT2RTLongSlotTime = false; -} -#if 0 -//below function has merged into ieee80211_network_init() in ieee80211_rx.c -void -HTParsingHTCapElement( - IN PADAPTER Adapter, - IN OCTET_STRING HTCapIE, - OUT PRT_WLAN_BSS pBssDesc -) -{ - PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; - - if( HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf) ) - { - RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTCapElement(): HT Capability Element length is too long!\n") ); - return; - } - - // TODO: Check the correctness of HT Cap - //Print each field in detail. Driver should not print out this message by default - if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc) - HTDebugHTCapability(DBG_TRACE, Adapter, &HTCapIE, (pu8)"HTParsingHTCapElement()"); - - HTCapIE.Length = HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf)?\ - sizeof(pBssDesc->BssHT.bdHTCapBuf):HTCapIE.Length; //prevent from overflow - - CopyMem(pBssDesc->BssHT.bdHTCapBuf, HTCapIE.Octet, HTCapIE.Length); - pBssDesc->BssHT.bdHTCapLen = HTCapIE.Length; - -} - - -void -HTParsingHTInfoElement( - PADAPTER Adapter, - OCTET_STRING HTInfoIE, - PRT_WLAN_BSS pBssDesc -) -{ - PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; - - if( HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf)) - { - RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTInfoElement(): HT Information Element length is too long!\n") ); - return; - } - - // TODO: Check the correctness of HT Info - //Print each field in detail. Driver should not print out this message by default - if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc) - HTDebugHTInfo(DBG_TRACE, Adapter, &HTInfoIE, (pu8)"HTParsingHTInfoElement()"); - - HTInfoIE.Length = HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf)?\ - sizeof(pBssDesc->BssHT.bdHTInfoBuf):HTInfoIE.Length; //prevent from overflow - - CopyMem( pBssDesc->BssHT.bdHTInfoBuf, HTInfoIE.Octet, HTInfoIE.Length); - pBssDesc->BssHT.bdHTInfoLen = HTInfoIE.Length; -} - -/* - * Get HT related information from beacon and save it in BssDesc - * - * (1) Parse HTCap, and HTInfo, and record whether it is 11n AP - * (2) If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT() - * (3) Check whether peer is Realtek AP (for Realtek proprietary aggregation mode). - * Input: - * PADAPTER Adapter - * - * Output: - * PRT_TCB BssDesc - * -*/ -void HTGetValueFromBeaconOrProbeRsp( - PADAPTER Adapter, - POCTET_STRING pSRCmmpdu, - PRT_WLAN_BSS bssDesc -) -{ - PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; - PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo); - OCTET_STRING HTCapIE, HTInfoIE, HTRealtekAgg, mmpdu; - OCTET_STRING BroadcomElement, CiscoElement; - - mmpdu.Octet = pSRCmmpdu->Octet; - mmpdu.Length = pSRCmmpdu->Length; - - //2Note: - // Mark for IOT testing using Linksys WRT350N, This AP does not contain WMM IE when - // it is configured at pure-N mode. - // if(bssDesc->BssQos.bdQoSMode & QOS_WMM) - // - - HTInitializeBssDesc (&bssDesc->BssHT); - - //2<1> Parse HTCap, and HTInfo - // Get HT Capability IE: (1) Get IEEE Draft N IE or (2) Get EWC IE - HTCapIE = PacketGetElement(mmpdu, EID_HTCapability, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE); - if(HTCapIE.Length == 0) - { - HTCapIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_CAP, OUI_SUBTYPE_DONT_CARE); - if(HTCapIE.Length != 0) - bssDesc->BssHT.bdHTSpecVer= HT_SPEC_VER_EWC; - } - if(HTCapIE.Length != 0) - HTParsingHTCapElement(Adapter, HTCapIE, bssDesc); - - // Get HT Information IE: (1) Get IEEE Draft N IE or (2) Get EWC IE - HTInfoIE = PacketGetElement(mmpdu, EID_HTInfo, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE); - if(HTInfoIE.Length == 0) - { - HTInfoIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_INFO, OUI_SUBTYPE_DONT_CARE); - if(HTInfoIE.Length != 0) - bssDesc->BssHT.bdHTSpecVer = HT_SPEC_VER_EWC; - } - if(HTInfoIE.Length != 0) - HTParsingHTInfoElement(Adapter, HTInfoIE, bssDesc); - - //2<2>If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT() - if(HTCapIE.Length != 0) - { - bssDesc->BssHT.bdSupportHT = true; - if(bssDesc->BssQos.bdQoSMode == QOS_DISABLE) - QosSetLegacyWMMParamWithHT(Adapter, bssDesc); - } - else - { - bssDesc->BssHT.bdSupportHT = false; - } - - //2<3>Check whether the peer is Realtek AP/STA - if(pHTInfo->bRegRT2RTAggregation) - { - if(bssDesc->BssHT.bdSupportHT) - { - HTRealtekAgg = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE); - if(HTRealtekAgg.Length >=5 ) - { - bssDesc->BssHT.bdRT2RTAggregation = true; - - if((HTRealtekAgg.Octet[4]==1) && (HTRealtekAgg.Octet[5] & 0x02)) - bssDesc->BssHT.bdRT2RTLongSlotTime = true; - } - } - } - - // - // 2008/01/25 MH Get Broadcom AP IE for manamgent frame CCK rate problem. - // AP can not receive CCK managemtn from from 92E. - // - - // Initialize every new bss broadcom cap exist as false.. - bssDesc->bBroadcomCapExist= false; - - if(HTCapIE.Length != 0 || HTInfoIE.Length != 0) - { - u4Byte Length = 0; - - FillOctetString(BroadcomElement, NULL, 0); - - BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_1, OUI_SUBTYPE_DONT_CARE); - Length += BroadcomElement.Length; - BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_2, OUI_SUBTYPE_DONT_CARE); - Length += BroadcomElement.Length; - BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_3, OUI_SUBTYPE_DONT_CARE); - Length += BroadcomElement.Length; - - if(Length > 0) - bssDesc->bBroadcomCapExist = true; - } - - - // For Cisco IOT issue - CiscoElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_CISCO_IE, OUI_SUBTYPE_DONT_CARE); - if(CiscoElement.Length != 0){ // 3: 0x00, 0x40, 0x96 .... - bssDesc->bCiscoCapExist = true; - }else{ - bssDesc->bCiscoCapExist = false; - } -} - - -#endif -/******************************************************************************************************************** - *function: initialize Bss HT structure(struct PBSS_HT) - * input: struct ieee80211_device *ieee - * struct ieee80211_network *pNetwork //usually current network we are live in - * output: none - * return: none - * notice: This function should ONLY be called before association -********************************************************************************************************************/ -void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -// u16 nMaxAMSDUSize; -// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf; -// PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; -// u8* pMcsFilter; - u8 bIOTAction = 0; - - // - // Save Peer Setting before Association - // - IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__); - /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/ -// if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT) - if (pNetwork->bssht.bdSupportHT) - { - pHTInfo->bCurrentHTSupport = true; - pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; - - // Save HTCap and HTInfo information Element - if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) - memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); - - if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) - memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen); - - // Check whether RT to RT aggregation mode is enabled - if(pHTInfo->bRegRT2RTAggregation) - { - pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation; - pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime; - } - else - { - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; - } - - // Determine the IOT Peer Vendor. - HTIOTPeerDetermine(ieee); - - // Decide IOT Action - // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided - pHTInfo->IOTAction = 0; - bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14; - bIOTAction = HTIOTActIsForcedCTS2Self(ieee, pNetwork); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - - bIOTAction = HTIOTActIsDisableMCS15(ieee); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15; - - bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee, pNetwork->bssid); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS; - - - bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; - - bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; - - bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; - - bIOTAction = HTIOTActIsNullDataPowerSaving(ieee, pNetwork); - if(bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_NULL_DATA_POWER_SAVING; - - } - else - { - pHTInfo->bCurrentHTSupport = false; - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; - - pHTInfo->IOTAction = 0; - } - -} - -void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf; - PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; - - if(pHTInfo->bCurrentHTSupport) - { - // - // Config current operation mode. - // - if(pNetwork->bssht.bdHTInfoLen != 0) - pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - - // - // - // - } -} - -void HTUseDefaultSetting(struct ieee80211_device* ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -// u8 regBwOpMode; - - if(pHTInfo->bEnableHT) - { - pHTInfo->bCurrentHTSupport = true; - - pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; - - pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz; - - pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz; - - pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz; - - pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; - - pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - - pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; - - pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - - pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; - - // Set BWOpMode register - - //update RATR index0 - HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet); - //function below is not implemented at all. WB -#ifdef TODO - Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet); -#endif - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); - ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; - - } - else - { - pHTInfo->bCurrentHTSupport = false; - } -} -/******************************************************************************************************************** - *function: check whether HT control field exists - * input: struct ieee80211_device *ieee - * u8* pFrame //coming skb->data - * output: none - * return: return true if HT control field exists(false otherwise) - * notice: -********************************************************************************************************************/ -u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame) -{ - if(ieee->pHTInfo->bCurrentHTSupport) - { - if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) - { - IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n"); - return true; - } - } - return false; -} - -// -// This function set bandwidth mode in protocol layer. -// -void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -// u32 flags = 0; - - if(pHTInfo->bRegBW40MHz == false) - return; - - - - // To reduce dummy operation -// if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) || -// (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset)) -// return; - -// spin_lock_irqsave(&(ieee->bw_spinlock), flags); - if(pHTInfo->bSwBwInProgress) { -// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags); - return; - } - //if in half N mode, set to 20M bandwidth please 09.08.2008 WB. - if (Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee))) - { - // Handle Illegal extension channel offset!! - if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER) - Offset = HT_EXTCHNL_OFFSET_NO_EXT; - if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) { - pHTInfo->bCurBW40MHz = true; - pHTInfo->CurSTAExtChnlOffset = Offset; - } else { - pHTInfo->bCurBW40MHz = false; - pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; - } - } else { - pHTInfo->bCurBW40MHz = false; - pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; - } - - pHTInfo->bSwBwInProgress = true; - - // TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that switching - // bandwidth is executed after scan is finished. It is a temporal solution - // because software should ganrantee the last operation of switching bandwidth - // is executed properlly. - HTSetConnectBwModeCallback(ieee); - -// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags); -} - -void HTSetConnectBwModeCallback(struct ieee80211_device* ieee) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__); - - if(pHTInfo->bCurBW40MHz) - { - if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee, ieee->current_network.channel+2); - else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee, ieee->current_network.channel-2); - else - ieee->set_chan(ieee, ieee->current_network.channel); - - ieee->SetBWModeHandler(ieee, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset); - } else { - ieee->set_chan(ieee, ieee->current_network.channel); - ieee->SetBWModeHandler(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } - - pHTInfo->bSwBwInProgress = false; -} diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h deleted file mode 100644 index d4565ecc7ab..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h +++ /dev/null @@ -1,582 +0,0 @@ -#ifndef __INC_QOS_TYPE_H -#define __INC_QOS_TYPE_H - -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - -#define MAX_WMMELE_LENGTH 64 - -// -// QoS mode. -// enum 0, 1, 2, 4: since we can use the OR(|) operation. -// -// QOS_MODE is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko. -//typedef enum _QOS_MODE{ -// QOS_DISABLE = 0, -// QOS_WMM = 1, -// QOS_EDCA = 2, -// QOS_HCCA = 4, -//}QOS_MODE,*PQOS_MODE; -// -typedef u32 QOS_MODE, *PQOS_MODE; -#define QOS_DISABLE 0 -#define QOS_WMM 1 -#define QOS_WMMSA 2 -#define QOS_EDCA 4 -#define QOS_HCCA 8 -#define QOS_WMM_UAPSD 16 //WMM Power Save, 2006-06-14 Isaiah - -#define AC_PARAM_SIZE 4 -#define WMM_PARAM_ELE_BODY_LEN 18 - -// -// QoS ACK Policy Field Values -// Ref: WMM spec 2.1.6: QoS Control Field, p.10. -// -typedef enum _ACK_POLICY{ - eAckPlc0_ACK = 0x00, - eAckPlc1_NoACK = 0x01, -}ACK_POLICY,*PACK_POLICY; - -#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) - -// -// QoS Control Field -// Ref: -// 1. WMM spec 2.1.6: QoS Control Field, p.9. -// 2. 802.11e/D13.0 7.1.3.5, p.26. -// -typedef union _QOS_CTRL_FIELD{ - u8 charData[2]; - u16 shortData; - - // WMM spec - struct - { - u8 UP:3; - u8 usRsvd1:1; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd2:1; - u8 ucRsvdByte; - }WMM; - - // 802.11e: QoS data type frame sent by non-AP QSTAs. - struct - { - u8 TID:4; - u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size. - u8 AckPolicy:2; - u8 usRsvd:1; - u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size. - }BySta; - - // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC. - struct - { - u8 TID:4; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd:1; - u8 PSBufState; // QAP PS Buffer State. - }ByHc_Data; - - // 802.11e: QoS (+) CF-Poll frames sent by HC. - struct - { - u8 TID:4; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd:1; - u8 TxopLimit; // TXOP Limit. - }ByHc_CFP; - -}QOS_CTRL_FIELD, *PQOS_CTRL_FIELD; - - -// -// QoS Info Field -// Ref: -// 1. WMM spec 2.2.1: WME Information Element, p.11. -// 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h] -// -typedef union _QOS_INFO_FIELD{ - u8 charData; - - struct - { - u8 ucParameterSetCount:4; - u8 ucReserved:4; - }WMM; - - struct - { - //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah - u8 ucAC_VO_UAPSD:1; - u8 ucAC_VI_UAPSD:1; - u8 ucAC_BE_UAPSD:1; - u8 ucAC_BK_UAPSD:1; - u8 ucReserved1:1; - u8 ucMaxSPLen:2; - u8 ucReserved2:1; - - }ByWmmPsSta; - - struct - { - //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah - u8 ucParameterSetCount:4; - u8 ucReserved:3; - u8 ucApUapsd:1; - }ByWmmPsAp; - - struct - { - u8 ucAC3_UAPSD:1; - u8 ucAC2_UAPSD:1; - u8 ucAC1_UAPSD:1; - u8 ucAC0_UAPSD:1; - u8 ucQAck:1; - u8 ucMaxSPLen:2; - u8 ucMoreDataAck:1; - } By11eSta; - - struct - { - u8 ucParameterSetCount:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucReserved:1; - } By11eAp; - - struct - { - u8 ucReserved1:4; - u8 ucQAck:1; - u8 ucReserved2:2; - u8 ucMoreDataAck:1; - } ByWmmsaSta; - - struct - { - u8 ucReserved1:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucReserved2:1; - } ByWmmsaAp; - - struct - { - u8 ucAC3_UAPSD:1; - u8 ucAC2_UAPSD:1; - u8 ucAC1_UAPSD:1; - u8 ucAC0_UAPSD:1; - u8 ucQAck:1; - u8 ucMaxSPLen:2; - u8 ucMoreDataAck:1; - } ByAllSta; - - struct - { - u8 ucParameterSetCount:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucApUapsd:1; - } ByAllAp; - -}QOS_INFO_FIELD, *PQOS_INFO_FIELD; - -// -// ACI to AC coding. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.13. -// -// AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko. -//typedef enum _AC_CODING{ -// AC0_BE = 0, // ACI: 0x00 // Best Effort -// AC1_BK = 1, // ACI: 0x01 // Background -// AC2_VI = 2, // ACI: 0x10 // Video -// AC3_VO = 3, // ACI: 0x11 // Voice -// AC_MAX = 4, // Max: define total number; Should not to be used as a real enum. -//}AC_CODING,*PAC_CODING; -// -typedef u32 AC_CODING; -#define AC0_BE 0 // ACI: 0x00 // Best Effort -#define AC1_BK 1 // ACI: 0x01 // Background -#define AC2_VI 2 // ACI: 0x10 // Video -#define AC3_VO 3 // ACI: 0x11 // Voice -#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum. - -// -// ACI/AIFSN Field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -typedef union _ACI_AIFSN{ - u8 charData; - - struct - { - u8 AIFSN:4; - u8 ACM:1; - u8 ACI:2; - u8 Reserved:1; - }f; // Field -}ACI_AIFSN, *PACI_AIFSN; - -// -// ECWmin/ECWmax field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.13. -// -typedef union _ECW{ - u8 charData; - struct - { - u8 ECWmin:4; - u8 ECWmax:4; - }f; // Field -}ECW, *PECW; - -// -// AC Parameters Record Format. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -typedef union _AC_PARAM{ - u32 longData; - u8 charData[4]; - - struct - { - ACI_AIFSN AciAifsn; - ECW Ecw; - u16 TXOPLimit; - }f; // Field -}AC_PARAM, *PAC_PARAM; - - - -// -// QoS element subtype -// -typedef enum _QOS_ELE_SUBTYPE{ - QOSELE_TYPE_INFO = 0x00, // 0x00: Information element - QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element -}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE; - - -// -// Direction Field Values. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. -// -typedef enum _DIRECTION_VALUE{ - DIR_UP = 0, // 0x00 // UpLink - DIR_DOWN = 1, // 0x01 // DownLink - DIR_DIRECT = 2, // 0x10 // DirectLink - DIR_BI_DIR = 3, // 0x11 // Bi-Direction -}DIRECTION_VALUE,*PDIRECTION_VALUE; - - -// -// TS Info field in WMM TSPEC Element. -// Ref: -// 1. WMM spec 2.2.11: WME TSPEC Element, p.18. -// 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h] -// -typedef union _QOS_TSINFO{ - u8 charData[3]; - struct { - u8 ucTrafficType:1; //WMM is reserved - u8 ucTSID:4; - u8 ucDirection:2; - u8 ucAccessPolicy:2; //WMM: bit8=0, bit7=1 - u8 ucAggregation:1; //WMM is reserved - u8 ucPSB:1; //WMMSA is APSD - u8 ucUP:3; - u8 ucTSInfoAckPolicy:2; //WMM is reserved - u8 ucSchedule:1; //WMM is reserved - u8 ucReserved:7; - }field; -}QOS_TSINFO, *PQOS_TSINFO; - -// -// WMM TSPEC Body. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. -// -typedef union _TSPEC_BODY{ - u8 charData[55]; - - struct - { - QOS_TSINFO TSInfo; //u8 TSInfo[3]; - u16 NominalMSDUsize; - u16 MaxMSDUsize; - u32 MinServiceItv; - u32 MaxServiceItv; - u32 InactivityItv; - u32 SuspenItv; - u32 ServiceStartTime; - u32 MinDataRate; - u32 MeanDataRate; - u32 PeakDataRate; - u32 MaxBurstSize; - u32 DelayBound; - u32 MinPhyRate; - u16 SurplusBandwidthAllowance; - u16 MediumTime; - } f; // Field -}TSPEC_BODY, *PTSPEC_BODY; - - -// -// WMM TSPEC Element. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. -// -typedef struct _WMM_TSPEC{ - u8 ID; - u8 Length; - u8 OUI[3]; - u8 OUI_Type; - u8 OUI_SubType; - u8 Version; - TSPEC_BODY Body; -} WMM_TSPEC, *PWMM_TSPEC; - -// -// ACM implementation method. -// Annie, 2005-12-13. -// -typedef enum _ACM_METHOD{ - eAcmWay0_SwAndHw = 0, // By SW and HW. - eAcmWay1_HW = 1, // By HW. - eAcmWay2_SW = 2, // By SW. -}ACM_METHOD,*PACM_METHOD; - - -typedef struct _ACM{ -// u8 RegEnableACM; - u64 UsedTime; - u64 MediumTime; - u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B). -}ACM, *PACM; - -typedef u8 AC_UAPSD, *PAC_UAPSD; - -#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0) -#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0) - -#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1) -#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1) - -#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2) -#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2) - -#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3) -#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3) - - -//typedef struct _TCLASS{ -// TODO -//} TCLASS, *PTCLASS; -typedef union _QOS_TCLAS{ - - struct _TYPE_GENERAL{ - u8 Priority; - u8 ClassifierType; - u8 Mask; - } TYPE_GENERAL; - - struct _TYPE0_ETH{ - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 SrcAddr[6]; - u8 DstAddr[6]; - u16 Type; - } TYPE0_ETH; - - struct _TYPE1_IPV4{ - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[4]; - u8 DstIP[4]; - u16 SrcPort; - u16 DstPort; - u8 DSCP; - u8 Protocol; - u8 Reserved; - } TYPE1_IPV4; - - struct _TYPE1_IPV6{ - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[16]; - u8 DstIP[16]; - u16 SrcPort; - u16 DstPort; - u8 FlowLabel[3]; - } TYPE1_IPV6; - - struct _TYPE2_8021Q{ - u8 Priority; - u8 ClassifierType; - u8 Mask; - u16 TagType; - } TYPE2_8021Q; -} QOS_TCLAS, *PQOS_TCLAS; - -//typedef struct _WMM_TSTREAM{ -// -//- TSPEC -//- AC (which to mapping) -//} WMM_TSTREAM, *PWMM_TSTREAM; -typedef struct _QOS_TSTREAM{ - u8 AC; - WMM_TSPEC TSpec; - QOS_TCLAS TClass; -} QOS_TSTREAM, *PQOS_TSTREAM; - -//typedef struct _U_APSD{ -//- TriggerEnable [4] -//- MaxSPLength -//- HighestAcBuffered -//} U_APSD, *PU_APSD; - -//joseph TODO: -// UAPSD function should be implemented by 2 data structure -// "Qos control field" and "Qos info field" -//typedef struct _QOS_UAPSD{ -// u8 bTriggerEnable[4]; -// u8 MaxSPLength; -// u8 HighestBufAC; -//} QOS_UAPSD, *PQOS_APSD; - -//---------------------------------------------------------------------------- -// 802.11 Management frame Status Code field -//---------------------------------------------------------------------------- -typedef struct _OCTET_STRING{ - u8 *Octet; - u16 Length; -}OCTET_STRING, *POCTET_STRING; - -// -// STA QoS data. -// Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h] -// -typedef struct _STA_QOS{ - //DECLARE_RT_OBJECT(STA_QOS); - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8* WMMIE; - - // Part 1. Self QoS Mode. - QOS_MODE QosCapability; //QoS Capability, 2006-06-14 Isaiah - QOS_MODE CurrentQosMode; - - // For WMM Power Save Mode : - // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah - AC_UAPSD b4ac_Uapsd; //VoUapsd(bit0), ViUapsd(bit1), BkUapsd(bit2), BeUapsd(bit3), - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; - - // Part 2. EDCA Parameter (perAC) - u8 * pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; - u8 WMMPELength; - - // - //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element. - // By Bruce, 2008-01-30. - // Part 2. EDCA Parameter (perAC) - QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA - QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP - - AC_PARAM CurAcParameters[4]; - - // Part 3. ACM - ACM acm[4]; - ACM_METHOD AcmMethod; - - // Part 4. Per TID (Part 5: TCLASS will be described by TStream) - QOS_TSTREAM TStream[16]; - WMM_TSPEC TSpec; - - u32 QBssWirelessMode; - - // No Ack Setting - u8 bNoAck; - - // Enable/Disable Rx immediate BA capability. - u8 bEnableRxImmBA; - -}STA_QOS, *PSTA_QOS; - -// -// BSS QOS data. -// Ref: BssDscr in 8185 code. [def. in BssDscr.h] -// -typedef struct _BSS_QOS{ - QOS_MODE bdQoSMode; - - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; - u8* bdWMMIE; - - QOS_ELE_SUBTYPE EleSubType; - - u8 * pWMMInfoEle; - u8 * pWMMParamEle; - - QOS_INFO_FIELD QosInfoField; - AC_PARAM AcParameter[4]; -}BSS_QOS, *PBSS_QOS; - - -// -// Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code. -//#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) -// -#define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0) - - -//Added by joseph -//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP -//#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1)) -#define IsACValid(ac) ((ac<=7 )?true:false ) - -#endif // #ifndef __INC_QOS_TYPE_H diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c deleted file mode 100644 index ad6872dcf1c..00000000000 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c +++ /dev/null @@ -1,627 +0,0 @@ -#include "ieee80211.h" -#include -#include -#include "rtl819x_TS.h" - -void TsSetupTimeOut(unsigned long data) -{ - // Not implement yet - // This is used for WMMSA and ACM , that would send ADDTSReq frame. -} - -void TsInactTimeout(unsigned long data) -{ - // Not implement yet - // This is used for WMMSA and ACM. - // This function would be call when TS is no Tx/Rx for some period of time. -} - -/******************************************************************************************************************** - *function: I still not understand this function, so wait for further implementation - * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer - * return: NULL - * notice: -********************************************************************************************************************/ -void RxPktPendingTimeout(unsigned long data) -{ - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; - struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); - - PRX_REORDER_ENTRY pReorderEntry = NULL; - - //u32 flags = 0; - unsigned long flags = 0; - struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; - u8 index = 0; - bool bPktInBuf = false; - - - spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK); - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__FUNCTION__); - if(pRxTs->RxTimeoutIndicateSeq != 0xffff) - { - // Indicate the pending packets sequentially according to SeqNum until meet the gap. - while(!list_empty(&pRxTs->RxPendingPktList)) - { - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - if(index == 0) - pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; - - if( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) - { - list_del_init(&pReorderEntry->List); - - if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) - pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; - - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum); - stats_IndicateArray[index] = pReorderEntry->prxb; - index++; - - list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); - } - else - { - bPktInBuf = true; - break; - } - } - } - - if(index>0) - { - // Set RxTimeoutIndicateSeq to 0xffff to indicate no pending packets in buffer now. - pRxTs->RxTimeoutIndicateSeq = 0xffff; - - // Indicate packets - if(index > REORDER_WIN_SIZE){ - IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); - return; - } - ieee80211_indicate_packets(ieee, stats_IndicateArray, index); - } - - if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)) - { - pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; - mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); - } - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); - //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK); -} - -/******************************************************************************************************************** - *function: Add BA timer function - * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer - * return: NULL - * notice: -********************************************************************************************************************/ -void TsAddBaProcess(unsigned long data) -{ - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; - u8 num = pTxTs->num; - struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); - - TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); -} - - -void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) -{ - memset(pTsCommonInfo->Addr, 0, 6); - memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); - memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); - pTsCommonInfo->TClasProc = 0; - pTsCommonInfo->TClasNum = 0; -} - -void ResetTxTsEntry(PTX_TS_RECORD pTS) -{ - ResetTsCommonInfo(&pTS->TsCommonInfo); - pTS->TxCurSeq = 0; - pTS->bAddBaReqInProgress = false; - pTS->bAddBaReqDelayed = false; - pTS->bUsingBa = false; - ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator - ResetBaEntry(&pTS->TxPendingBARecord); -} - -void ResetRxTsEntry(PRX_TS_RECORD pTS) -{ - ResetTsCommonInfo(&pTS->TsCommonInfo); - pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!! - pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!! - ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recipient -} - -void TSInitialize(struct ieee80211_device *ieee) -{ - PTX_TS_RECORD pTxTS = ieee->TxTsRecord; - PRX_TS_RECORD pRxTS = ieee->RxTsRecord; - PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; - u8 count = 0; - IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __FUNCTION__); - // Initialize Tx TS related info. - INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); - INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); - INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); - - for(count = 0; count < TOTAL_TS_NUM; count++) - { - // - pTxTS->num = count; - // The timers for the operation of Traffic Stream and Block Ack. - // DLS related timer will be add here in the future!! - init_timer(&pTxTS->TsCommonInfo.SetupTimer); - pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS; - pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut; - - init_timer(&pTxTS->TsCommonInfo.InactTimer); - pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS; - pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout; - - init_timer(&pTxTS->TsAddBaTimer); - pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS; - pTxTS->TsAddBaTimer.function = TsAddBaProcess; - - init_timer(&pTxTS->TxPendingBARecord.Timer); - pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS; - pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut; - - init_timer(&pTxTS->TxAdmittedBARecord.Timer); - pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS; - pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout; - - ResetTxTsEntry(pTxTS); - list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List); - pTxTS++; - } - - // Initialize Rx TS related info. - INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); - INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); - INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); - for(count = 0; count < TOTAL_TS_NUM; count++) - { - pRxTS->num = count; - INIT_LIST_HEAD(&pRxTS->RxPendingPktList); - - init_timer(&pRxTS->TsCommonInfo.SetupTimer); - pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS; - pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut; - - init_timer(&pRxTS->TsCommonInfo.InactTimer); - pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS; - pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout; - - init_timer(&pRxTS->RxAdmittedBARecord.Timer); - pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS; - pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout; - - init_timer(&pRxTS->RxPktPendingTimer); - pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS; - pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout; - - ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); - pRxTS++; - } - // Initialize unused Rx Reorder List. - INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); -//#ifdef TO_DO_LIST - for(count = 0; count < REORDER_ENTRY_NUM; count++) - { - list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); - if(count == (REORDER_ENTRY_NUM-1)) - break; - pRxReorderEntry = &ieee->RxReorderEntry[count+1]; - } -//#endif - -} - -void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime) -{ - del_timer_sync(&pTsCommonInfo->SetupTimer); - del_timer_sync(&pTsCommonInfo->InactTimer); - - if(InactTime!=0) - mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); -} - - -PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) -{ - //DIRECTION_VALUE dir; - u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; - struct list_head* psearch_list; //FIXME - PTS_COMMON_INFO pRet = NULL; - if(ieee->iw_mode == IW_MODE_MASTER) //ap mode - { - if(TxRxSelect == TX_DIR) - { - search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; - } - else - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - } - } - else if(ieee->iw_mode == IW_MODE_ADHOC) - { - if(TxRxSelect == TX_DIR) - search_dir[DIR_UP] = true; - else - search_dir[DIR_DOWN] = true; - } - else - { - if(TxRxSelect == TX_DIR) - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; - } - else - { - search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; - } - } - - if(TxRxSelect == TX_DIR) - psearch_list = &ieee->Tx_TS_Admit_List; - else - psearch_list = &ieee->Rx_TS_Admit_List; - - //for(dir = DIR_UP; dir <= DIR_BI_DIR; dir++) - for(dir = 0; dir <= DIR_BI_DIR; dir++) - { - if(search_dir[dir] ==false ) - continue; - list_for_each_entry(pRet, psearch_list, List){ - // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); - if (memcmp(pRet->Addr, Addr, 6) == 0) - if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) - if(pRet->TSpec.f.TSInfo.field.ucDirection == dir) - { - break; - } - - } - if(&pRet->List != psearch_list) - break; - } - - if(&pRet->List != psearch_list){ - return pRet ; - } - else - return NULL; -} - -void MakeTSEntry( - PTS_COMMON_INFO pTsCommonInfo, - u8* Addr, - PTSPEC_BODY pTSPEC, - PQOS_TCLAS pTCLAS, - u8 TCLAS_Num, - u8 TCLAS_Proc - ) -{ - u8 count; - - if(pTsCommonInfo == NULL) - return; - - memcpy(pTsCommonInfo->Addr, Addr, 6); - - if(pTSPEC != NULL) - memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY)); - - for(count = 0; count < TCLAS_Num; count++) - memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS)); - - pTsCommonInfo->TClasProc = TCLAS_Proc; - pTsCommonInfo->TClasNum = TCLAS_Num; -} - - -bool GetTs( - struct ieee80211_device* ieee, - PTS_COMMON_INFO *ppTS, - u8* Addr, - u8 TID, - TR_SELECT TxRxSelect, //Rx:1, Tx:0 - bool bAddNewTs - ) -{ - u8 UP = 0; - // - // We do not build any TS for Broadcast or Multicast stream. - // So reject these kinds of search here. - // - if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "get TS for Broadcast or Multicast\n"); - return false; - } - - if (ieee->current_network.qos_data.supported == 0) - UP = 0; - else - { - // In WMM case: we use 4 TID only - if (!IsACValid(TID)) - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __FUNCTION__, TID); - return false; - } - - switch(TID) - { - case 0: - case 3: - UP = 0; - break; - - case 1: - case 2: - UP = 2; - break; - - case 4: - case 5: - UP = 5; - break; - - case 6: - case 7: - UP = 7; - break; - } - } - - *ppTS = SearchAdmitTRStream( - ieee, - Addr, - UP, - TxRxSelect); - if(*ppTS != NULL) - { - return true; - } - else - { - if(bAddNewTs == false) - { - IEEE80211_DEBUG(IEEE80211_DL_TS, "add new TS failed(tid:%d)\n", UP); - return false; - } - else - { - // - // Create a new Traffic stream for current Tx/Rx - // This is for EDCA and WMM to add a new TS. - // For HCCA or WMMSA, TS cannot be addmit without negotiation. - // - TSPEC_BODY TSpec; - PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo; - struct list_head* pUnusedList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Unused_List): - (&ieee->Rx_TS_Unused_List); - - struct list_head* pAddmitList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Admit_List): - (&ieee->Rx_TS_Admit_List); - - DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)? - ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): - ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); - IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n"); - if(!list_empty(pUnusedList)) - { - (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List); - list_del_init(&(*ppTS)->List); - if(TxRxSelect==TX_DIR) - { - PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); - ResetTxTsEntry(tmp); - } - else{ - PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); - ResetRxTsEntry(tmp); - } - - IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr); - // Prepare TS Info releated field - pTSInfo->field.ucTrafficType = 0; // Traffic type: WMM is reserved in this field - pTSInfo->field.ucTSID = UP; // TSID - pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. - pTSInfo->field.ucAccessPolicy = 1; // Access policy - pTSInfo->field.ucAggregation = 0; // Aggregation - pTSInfo->field.ucPSB = 0; // Aggregation - pTSInfo->field.ucUP = UP; // User priority - pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy - pTSInfo->field.ucSchedule = 0; // Schedule - - MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); - AdmitTS(ieee, *ppTS, 0); - list_add_tail(&((*ppTS)->List), pAddmitList); - // if there is DirectLink, we need to do additional operation here!! - - return true; - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __FUNCTION__); - return false; - } - } - } -} - -void RemoveTsEntry( - struct ieee80211_device* ieee, - PTS_COMMON_INFO pTs, - TR_SELECT TxRxSelect - ) -{ - //u32 flags = 0; - unsigned long flags = 0; - del_timer_sync(&pTs->SetupTimer); - del_timer_sync(&pTs->InactTimer); - TsInitDelBA(ieee, pTs, TxRxSelect); - - if(TxRxSelect == RX_DIR) - { -//#ifdef TO_DO_LIST - PRX_REORDER_ENTRY pRxReorderEntry; - PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; - if(timer_pending(&pRxTS->RxPktPendingTimer)) - del_timer_sync(&pRxTS->RxPktPendingTimer); - - while(!list_empty(&pRxTS->RxPendingPktList)) - { - // PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK); - spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - //pRxReorderEntry = list_entry(&pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - list_del_init(&pRxReorderEntry->List); - { - int i = 0; - struct ieee80211_rxb * prxb = pRxReorderEntry->prxb; - if (unlikely(!prxb)) - { - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); - return; - } - for(i =0; i < prxb->nr_subframes; i++) { - dev_kfree_skb(prxb->subframes[i]); - } - kfree(prxb); - prxb = NULL; - } - list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); - //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); - } - -//#endif - } - else - { - PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs; - del_timer_sync(&pTxTS->TsAddBaTimer); - } -} - -void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr) -{ - PTS_COMMON_INFO pTS, pTmpTS; - - printk("===========>RemovePeerTS,%pM\n", Addr); - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); - } - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - printk("====>remove Tx_TS_admin_list\n"); - RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); - } - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); - } - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); - } - } -} - -void RemoveAllTS(struct ieee80211_device* ieee) -{ - PTS_COMMON_INFO pTS, pTmpTS; - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { - RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { - RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { - RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); - } - - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { - RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); - } -} - -void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS) -{ - if(pTxTS->bAddBaReqInProgress == false) - { - pTxTS->bAddBaReqInProgress = true; - if(pTxTS->bAddBaReqDelayed) - { - IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); - } - else - { - IEEE80211_DEBUG(IEEE80211_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); //set 10 ticks - } - } - else - IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__); -} diff --git a/drivers/staging/rtl8192e/internal.h b/drivers/staging/rtl8192e/internal.h new file mode 100644 index 00000000000..1c39c000e91 --- /dev/null +++ b/drivers/staging/rtl8192e/internal.h @@ -0,0 +1,129 @@ +/* + * Cryptographic API. + * + * Copyright (c) 2002 James Morris + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#ifndef _CRYPTO_INTERNAL_H +#define _CRYPTO_INTERNAL_H + + +#include +#include "rtl_crypto.h" +#include +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) +#include +#else +#include +#include +#endif +#include + +#ifdef BUILT_IN_CRYPTO +#ifdef CONFIG_CRYPTO_HMAC +#undef CONFIG_CRYPTO_HMAC +#endif + +#ifdef CONFIG_KMOD +#undef CONFIG_KMOD +#endif +#endif /* BUILT_IN_CRYPTO */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)) +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + prefetch(pos->member.next); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member), \ + prefetch(pos->member.next)) + +static inline void cond_resched(void) +{ + if (need_resched()) { + set_current_state(TASK_RUNNING); + schedule(); + } +} +#endif + +extern enum km_type crypto_km_types[]; + +static inline enum km_type crypto_kmap_type(int out) +{ + return crypto_km_types[(in_softirq() ? 2 : 0) + out]; +} + +static inline void *crypto_kmap(struct page *page, int out) +{ + return kmap_atomic(page, crypto_kmap_type(out)); +} + +static inline void crypto_kunmap(void *vaddr, int out) +{ + kunmap_atomic(vaddr, crypto_kmap_type(out)); +} + +static inline void crypto_yield(struct crypto_tfm *tfm) +{ + if (!in_softirq()) + cond_resched(); +} + +static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) +{ + return (void *)&tfm[1]; +} + +struct crypto_alg *crypto_alg_lookup(const char *name); + +#ifdef CONFIG_KMOD +void crypto_alg_autoload(const char *name); +struct crypto_alg *crypto_alg_mod_lookup(const char *name); +#else +static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) +{ + return crypto_alg_lookup(name); +} +#endif + +#ifdef CONFIG_CRYPTO_HMAC +int crypto_alloc_hmac_block(struct crypto_tfm *tfm); +void crypto_free_hmac_block(struct crypto_tfm *tfm); +#else +static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm) +{ + return 0; +} + +static inline void crypto_free_hmac_block(struct crypto_tfm *tfm) +{ } +#endif + +#ifdef CONFIG_PROC_FS +void __init crypto_init_proc(void); +#else +static inline void crypto_init_proc(void) +{ } +#endif + +int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); +int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); +int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags); + +int crypto_init_digest_ops(struct crypto_tfm *tfm); +int crypto_init_cipher_ops(struct crypto_tfm *tfm); +int crypto_init_compress_ops(struct crypto_tfm *tfm); + +void crypto_exit_digest_ops(struct crypto_tfm *tfm); +void crypto_exit_cipher_ops(struct crypto_tfm *tfm); +void crypto_exit_compress_ops(struct crypto_tfm *tfm); + +#endif /* _CRYPTO_INTERNAL_H */ diff --git a/drivers/staging/rtl8192e/kmap_types.h b/drivers/staging/rtl8192e/kmap_types.h new file mode 100644 index 00000000000..de67bb01b5f --- /dev/null +++ b/drivers/staging/rtl8192e/kmap_types.h @@ -0,0 +1,20 @@ +#ifndef __KMAP_TYPES_H + +#define __KMAP_TYPES_H + + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_BH_IRQ, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_TYPE_NR +}; + +#define _ASM_KMAP_TYPES_H + +#endif diff --git a/drivers/staging/rtl8192e/license b/drivers/staging/rtl8192e/license new file mode 100644 index 00000000000..4bea9fa60da --- /dev/null +++ b/drivers/staging/rtl8192e/license @@ -0,0 +1,339 @@ + +"This software program is licensed subject to the GNU General Public License +(GPL). Version 2, June 1991, available at + +******************************************************************************/ + + +#ifndef R8190P_DEF_H +#define R8190P_DEF_H + +#include + +#define MAX_SILENT_RESET_RX_SLOT_NUM 10 + +#define RX_MPDU_QUEUE 0 +#define RX_CMD_QUEUE 1 + + +typedef enum _rtl819x_loopback{ + RTL819X_NO_LOOPBACK = 0, + RTL819X_MAC_LOOPBACK = 1, + RTL819X_DMA_LOOPBACK = 2, + RTL819X_CCK_LOOPBACK = 3, +}rtl819x_loopback_e; + + +#define RESET_DELAY_8185 20 + +#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) + +#define DESC90_RATE1M 0x00 +#define DESC90_RATE2M 0x01 +#define DESC90_RATE5_5M 0x02 +#define DESC90_RATE11M 0x03 +#define DESC90_RATE6M 0x04 +#define DESC90_RATE9M 0x05 +#define DESC90_RATE12M 0x06 +#define DESC90_RATE18M 0x07 +#define DESC90_RATE24M 0x08 +#define DESC90_RATE36M 0x09 +#define DESC90_RATE48M 0x0a +#define DESC90_RATE54M 0x0b +#define DESC90_RATEMCS0 0x00 +#define DESC90_RATEMCS1 0x01 +#define DESC90_RATEMCS2 0x02 +#define DESC90_RATEMCS3 0x03 +#define DESC90_RATEMCS4 0x04 +#define DESC90_RATEMCS5 0x05 +#define DESC90_RATEMCS6 0x06 +#define DESC90_RATEMCS7 0x07 +#define DESC90_RATEMCS8 0x08 +#define DESC90_RATEMCS9 0x09 +#define DESC90_RATEMCS10 0x0a +#define DESC90_RATEMCS11 0x0b +#define DESC90_RATEMCS12 0x0c +#define DESC90_RATEMCS13 0x0d +#define DESC90_RATEMCS14 0x0e +#define DESC90_RATEMCS15 0x0f +#define DESC90_RATEMCS32 0x20 + +#define SHORT_SLOT_TIME 9 +#define NON_SHORT_SLOT_TIME 20 + + +#define MAX_LINES_HWCONFIG_TXT 1000 +#define MAX_BYTES_LINE_HWCONFIG_TXT 128 + +#define SW_THREE_WIRE 0 +#define HW_THREE_WIRE 2 + +#define BT_DEMO_BOARD 0 +#define BT_QA_BOARD 1 +#define BT_FPGA 2 + +#define Rx_Smooth_Factor 20 + +#define QSLT_BK 0x1 +#define QSLT_BE 0x0 +#define QSLT_VI 0x4 +#define QSLT_VO 0x6 +#define QSLT_BEACON 0x10 +#define QSLT_HIGH 0x11 +#define QSLT_MGNT 0x12 +#define QSLT_CMD 0x13 + +#define NUM_OF_FIRMWARE_QUEUE 10 +#define NUM_OF_PAGES_IN_FW 0x100 +#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x007 +#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x0aa +#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x024 +#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x007 +#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0 +#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x2 +#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x10 +#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0 +#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4 +#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0xd + +#define NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM 0x026 +#define NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM 0x048 +#define NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM 0x048 +#define NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM 0x026 +#define NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM 0x00 + +#define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000 +#define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00 +#define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08 +#define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10 +#define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18 +#define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10 +#define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00 +#define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08 + +#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 +#define HAL_PRIME_CHNL_OFFSET_LOWER 1 +#define HAL_PRIME_CHNL_OFFSET_UPPER 2 + + +typedef enum _VERSION_8190{ + VERSION_8190_BD=0x3, + VERSION_8190_BE +}VERSION_8190,*PVERSION_8190; + +#define IC_VersionCut_C 0x2 +#define IC_VersionCut_D 0x3 +#define IC_VersionCut_E 0x4 + +typedef enum tag_Rf_OpType +{ + RF_OP_By_SW_3wire = 0, + RF_OP_By_FW, + RF_OP_MAX +}RF_OpType_E; + + +typedef enum _POWER_SAVE_MODE +{ + POWER_SAVE_MODE_ACTIVE, + POWER_SAVE_MODE_SAVE, +}POWER_SAVE_MODE; + +typedef enum _INTERFACE_SELECT_8190PCI{ + INTF_SEL1_MINICARD = 0, + INTF_SEL0_PCIE = 1, + INTF_SEL2_RSV = 2, + INTF_SEL3_RSV = 3, +} INTERFACE_SELECT_8190PCI, *PINTERFACE_SELECT_8190PCI; + +typedef struct _BB_REGISTER_DEFINITION{ + u32 rfintfs; + u32 rfintfi; + u32 rfintfo; + u32 rfintfe; + u32 rf3wireOffset; + u32 rfLSSI_Select; + u32 rfTxGainStage; + u32 rfHSSIPara1; + u32 rfHSSIPara2; + u32 rfSwitchControl; + u32 rfAGCControl1; + u32 rfAGCControl2; + u32 rfRxIQImbalance; + u32 rfRxAFE; + u32 rfTxIQImbalance; + u32 rfTxAFE; + u32 rfLSSIReadBack; + u32 rfLSSIReadBackPi; +}BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T; + +typedef struct _TX_FWINFO_STRUCUTRE{ + u8 TxRate:7; + u8 CtsEnable:1; + u8 RtsRate:7; + u8 RtsEnable:1; + u8 TxHT:1; + u8 Short:1; + u8 TxBandwidth:1; + u8 TxSubCarrier:2; + u8 STBC:2; + u8 AllowAggregation:1; + u8 RtsHT:1; + u8 RtsShort:1; + u8 RtsBandwidth:1; + u8 RtsSubcarrier:2; + u8 RtsSTBC:2; + u8 EnableCPUDur:1; + + u32 RxMF:2; + u32 RxAMD:3; + u32 Reserved1:3; + u32 TxAGCOffset:4; + u32 TxAGCSign:1; + u32 Tx_INFO_RSVD:6; + u32 PacketID:13; +}TX_FWINFO_T; + +typedef struct _TX_FWINFO_8190PCI{ + u8 TxRate:7; + u8 CtsEnable:1; + u8 RtsRate:7; + u8 RtsEnable:1; + u8 TxHT:1; + u8 Short:1; + u8 TxBandwidth:1; + u8 TxSubCarrier:2; + u8 STBC:2; + u8 AllowAggregation:1; + u8 RtsHT:1; + u8 RtsShort:1; + u8 RtsBandwidth:1; + u8 RtsSubcarrier:2; + u8 RtsSTBC:2; + u8 EnableCPUDur:1; + + u32 RxMF:2; + u32 RxAMD:3; + u32 TxPerPktInfoFeedback:1; + u32 Reserved1:2; + u32 TxAGCOffset:4; + u32 TxAGCSign:1; + u32 RAW_TXD:1; + u32 Retry_Limit:4; + u32 Reserved2:1; + u32 PacketID:13; + + +}TX_FWINFO_8190PCI, *PTX_FWINFO_8190PCI; + + +#define TX_DESC_SIZE 32 + +#define TX_DESC_CMD_SIZE 32 + + +#define TX_STATUS_DESC_SIZE 32 + +#define TX_FWINFO_SIZE 8 + + +#define RX_DESC_SIZE 16 + +#define RX_STATUS_DESC_SIZE 16 + +#define RX_DRIVER_INFO_SIZE 8 + +typedef struct _LOG_INTERRUPT_8190 +{ + u32 nIMR_COMDOK; + u32 nIMR_MGNTDOK; + u32 nIMR_HIGH; + u32 nIMR_VODOK; + u32 nIMR_VIDOK; + u32 nIMR_BEDOK; + u32 nIMR_BKDOK; + u32 nIMR_ROK; + u32 nIMR_RCOK; + u32 nIMR_TBDOK; + u32 nIMR_BDOK; + u32 nIMR_RXFOVW; +} LOG_INTERRUPT_8190_T, *PLOG_INTERRUPT_8190_T; + +typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{ + u8 reserved:4; + u8 rxsc:2; + u8 sgi_en:1; + u8 ex_intf_flag:1; +}phy_ofdm_rx_status_rxsc_sgien_exintfflag; + +typedef struct _phy_ofdm_rx_status_report_819xpci +{ + u8 trsw_gain_X[4]; + u8 pwdb_all; + u8 cfosho_X[4]; + u8 cfotail_X[4]; + u8 rxevm_X[2]; + u8 rxsnr_X[4]; + u8 pdsnr_X[2]; + u8 csi_current_X[2]; + u8 csi_target_X[2]; + u8 sigevm; + u8 max_ex_pwr; + u8 sgi_en; + u8 rxsc_sgien_exflg; +}phy_sts_ofdm_819xpci_t; + +typedef struct _phy_cck_rx_status_report_819xpci +{ + u8 adc_pwdb_X[4]; + u8 sq_rpt; + u8 cck_agc_rpt; +}phy_sts_cck_819xpci_t, phy_sts_cck_8192s_t; + + +#define PHY_RSSI_SLID_WIN_MAX 100 +#define PHY_Beacon_RSSI_SLID_WIN_MAX 10 + +typedef struct _tx_desc_819x_pci { + u16 PktSize; + u8 Offset; + u8 Reserved1:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; + + u8 TxFWInfoSize; + u8 RATid:3; + u8 DISFB:1; + u8 USERATE:1; + u8 MOREFRAG:1; + u8 NoEnc:1; + u8 PIFS:1; + u8 QueueSelect:5; + u8 NoACM:1; + u8 Resv:2; + u8 SecCAMID:5; + u8 SecDescAssign:1; + u8 SecType:2; + + u16 TxBufferSize; + u8 PktId:7; + u8 Resv1:1; + u8 Reserved2; + + u32 TxBuffAddr; + + u32 NextDescAddress; + + u32 Reserved5; + u32 Reserved6; + u32 Reserved7; +}tx_desc, *ptx_desc; + + +typedef struct _tx_desc_cmd_819x_pci { + u16 PktSize; + u8 Reserved1; + u8 CmdType:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; + + u16 ElementReport; + u16 Reserved2; + + u16 TxBufferSize; + u16 Reserved3; + + u32 TxBuffAddr; + u32 NextDescAddress; + u32 Reserved4; + u32 Reserved5; + u32 Reserved6; +}tx_desc_cmd, *ptx_desc_cmd; + +typedef struct _rx_desc_819x_pci{ + u16 Length:14; + u16 CRC32:1; + u16 ICV:1; + u8 RxDrvInfoSize; + u8 Shift:2; + u8 PHYStatus:1; + u8 SWDec:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 EOR:1; + u8 OWN:1; + + u32 Reserved2; + + u32 Reserved3; + + u32 BufferAddress; + +}rx_desc, *prx_desc; + + +typedef struct _rx_fwinfo_819x_pci{ + u16 Reserved1:12; + u16 PartAggr:1; + u16 FirstAGGR:1; + u16 Reserved2:2; + + u8 RxRate:7; + u8 RxHT:1; + + u8 BW:1; + u8 SPLCP:1; + u8 Reserved3:2; + u8 PAM:1; + u8 Mcast:1; + u8 Bcast:1; + u8 Reserved4:1; + + u32 TSFL; + +}rx_fwinfo, *prx_fwinfo; + +#endif diff --git a/drivers/staging/rtl8192e/r8190P_hwimg.c b/drivers/staging/rtl8192e/r8190P_hwimg.c new file mode 100644 index 00000000000..d8c575a89de --- /dev/null +++ b/drivers/staging/rtl8192e/r8190P_hwimg.c @@ -0,0 +1,4538 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_R819XU_FIRMWARE_IMG_H +#define __INC_R819XU_FIRMWARE_IMG_H +/*Created on 2008/ 5/19, 6:38*/ + +#include "r8190P_hwimg.h" + +u8 Rtl8190PciFwBootArray[BootArrayLengthPci] = { +0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08, +0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00, +0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, +0x25,0x08,0xd8,0xdc,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff, +0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b, +0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00, +0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, +0x25,0x08,0xd8,0xdc,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0, +0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00, +0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00, +0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff, +0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01, +0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01, +0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24, +0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10, +0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, +0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10, +0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x6b,0x18, +0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,}; + +u8 Rtl8190PciFwMainArray[MainArrayLengthPci] = { +0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x1a,0x35, +0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09, +0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24, +0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0, +0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x94,0x50,0x00,0x85,0x18,0x21, +0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00, +0x27,0x82,0x94,0x5a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00, +0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x94,0x50, +0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x94,0x52,0x24,0x02,0x00,0x04, +0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x94,0x66,0xa3,0x82,0x94,0x58, +0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x94,0x6c,0xa3,0x85,0x94,0x59, +0xa7,0x82,0x94,0x5a,0xa7,0x84,0x94,0x5c,0xaf,0x84,0x94,0x68,0xa3,0x84,0x94,0x51, +0xa3,0x80,0x94,0x53,0xa3,0x80,0x94,0x54,0xa3,0x80,0x94,0x55,0xa3,0x84,0x94,0x56, +0xa3,0x85,0x94,0x57,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00, +0x27,0x84,0x94,0x78,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00, +0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0, +0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00, +0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00, +0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03, +0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11, +0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07, +0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10, +0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b, +0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20, +0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24, +0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54, +0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x74,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18, +0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x94,0x70,0x8c,0xa3,0x00,0x00, +0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a, +0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01, +0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3, +0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40, +0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x94,0x78,0x00,0x0a,0x20,0x0b, +0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01, +0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x94,0x78,0xa0,0x67,0x00,0x01, +0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07, +0x00,0x00,0x00,0x00,0x27,0x83,0x94,0x70,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x94,0x74, +0x27,0x82,0x94,0x70,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00, +0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00, +0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x8c,0x08,0x00,0x00,0xa7, +0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x80,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10, +0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00, +0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03, +0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2, +0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09, +0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x94,0x78, +0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00, +0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04, +0x30,0x43,0x00,0x06,0x93,0x82,0x94,0x90,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21, +0x83,0x82,0x94,0x84,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f, +0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01, +0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4, +0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08, +0x24,0x02,0x00,0x01,0xaf,0x84,0x94,0xa0,0xa3,0x82,0x94,0xb0,0xa7,0x80,0x94,0xa4, +0xa7,0x80,0x94,0xa6,0xaf,0x80,0x94,0xa8,0xaf,0x80,0x94,0xac,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, +0x24,0x42,0x05,0x24,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac, +0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21, +0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x5c,0x27,0xbd,0xff,0xe0, +0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, +0x8f,0x90,0x94,0xa0,0x0c,0x00,0x02,0x90,0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a, +0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01, +0xae,0x02,0x00,0x00,0x97,0x84,0x94,0xa4,0x97,0x82,0x94,0xa6,0x3c,0x03,0xb0,0x02, +0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x94,0xa6,0xa4,0x82,0x00,0x00, +0x8f,0x84,0x94,0xa8,0x8f,0x82,0x94,0xa0,0x93,0x85,0x94,0x52,0x24,0x84,0x00,0x01, +0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03, +0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,0xaf,0x82,0x94,0xa0, +0xaf,0x84,0x94,0xa8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,0x8f,0x83,0x94,0xac, +0x8f,0x84,0x94,0x6c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b, +0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00, +0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x48,0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20, +0x8f,0x90,0x94,0xa0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21, +0x0c,0x00,0x02,0x90,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19, +0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24, +0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,0x97,0x86,0x94,0xa4, +0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00, +0x8f,0x84,0x94,0xa0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x94,0xa6,0x00,0xc2,0x30,0x21, +0x8f,0x82,0x94,0xa8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24, +0x24,0x42,0x00,0x01,0xa7,0x85,0x94,0xa6,0xaf,0x84,0x94,0xa0,0xaf,0x82,0x94,0xa8, +0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, +0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14, +0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc, +0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08, +0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01, +0x00,0x02,0x10,0x80,0x24,0x63,0x08,0x94,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14, +0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x8c,0xa4,0x00,0x00,0x0c,0x00,0x1f,0x4f,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xdc, +0x00,0x00,0x00,0x00,0x0c,0x00,0x2c,0x0d,0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xdc, +0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x06,0x93,0x82,0x80,0x18,0x00,0x00,0x00,0x00, +0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x93,0x83,0x88,0x07,0x24,0x02,0x00,0x01, +0xa3,0x82,0x80,0x11,0xa3,0x83,0x80,0x19,0xa3,0x83,0x80,0x18,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x93,0x82,0x80,0x19,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf6, +0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xf3,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff, +0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,0x8f,0x82,0x80,0x14,0xa3,0x85,0x8b,0xcb, +0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40, +0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0, +0x00,0x05,0x10,0x40,0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00, +0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0, +0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0, +0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40, +0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00, +0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10, +0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21, +0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x86,0x94,0xa0,0x8f,0x82,0x80,0x14, +0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21, +0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,0xa3,0x82,0x8b,0xd3,0xa3,0x83,0x8b,0xd2, +0x27,0x8a,0x8b,0xd0,0x00,0x00,0x20,0x21,0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80, +0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01, +0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00, +0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80, +0x97,0x83,0x94,0xa6,0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c, +0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18, +0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c, +0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00, +0xaf,0x86,0x94,0xa0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e, +0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x8f,0x86,0x94,0xa0,0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08, +0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12, +0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21, +0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, +0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08, +0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x48,0x28,0x24,0x97,0x83,0x94,0xa6, +0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21, +0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, +0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00, +0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x94,0xa0, +0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38, +0x93,0x82,0x94,0xb0,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01, +0x8f,0x82,0x94,0xa8,0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18, +0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x94,0xa4, +0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x94,0xac, +0xa7,0x80,0x94,0xa6,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x8f,0x86,0x94,0xa0,0x8f,0x82,0x94,0xa8, +0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a, +0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,0x27,0x89,0x8b,0xa0,0x24,0xe2,0x00,0x01, +0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a, +0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f, +0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xa6,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, +0xa7,0x82,0x8b,0xa6,0x90,0xa3,0x00,0x15,0x97,0x82,0x8b,0xa8,0x00,0x03,0x1e,0x00, +0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,0xa7,0x82,0x8b,0xa8,0x8c,0xa4,0x00,0x20, +0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54, +0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xac, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xac,0x84,0xa3,0x00,0x06, +0x8f,0x82,0x8b,0xbc,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0xbc, +0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,0xaf,0x82,0x94,0xa8,0x10,0x60,0x00,0x09, +0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05, +0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,0xa3,0x83,0x8b,0xa2,0xa3,0x82,0x8b,0xa3, +0x90,0xa2,0x00,0x18,0x93,0x83,0x8b,0xcb,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0xa7,0x82,0x8b,0xb6,0xa3,0x83,0x8b,0xc4,0x27,0x89,0x8b,0xa0, +0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, +0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a, +0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x94,0xa6, +0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21, +0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, +0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00, +0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x94,0xa0, +0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, +0x0c,0x00,0x02,0x2e,0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xdd, +0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xae,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, +0xa7,0x82,0x8b,0xae,0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0xc0,0x00,0x00,0x00,0x00, +0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0xc0,0x08,0x00,0x02,0xd5,0x25,0x42,0x00,0x01, +0x97,0x82,0x8b,0xaa,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xaa, +0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0xb8,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, +0xaf,0x82,0x8b,0xb8,0x08,0x00,0x02,0xd5,0x25,0x42,0x00,0x01,0x97,0x82,0x8b,0xa4, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xa4,0x08,0x00,0x02,0xbd, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20, +0x8f,0x8a,0x94,0xa0,0x3c,0x02,0x00,0x10,0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21, +0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c, +0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42, +0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25, +0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a, +0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34, +0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18, +0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20, +0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff, +0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, +0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00, +0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,0x97,0x83,0x94,0xa6,0x97,0x85,0x94,0xa4, +0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06, +0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00, +0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24, +0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x8a,0x94,0xa0,0x10,0xa2,0x00,0x03, +0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20, +0x24,0x42,0x0d,0xdc,0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, +0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21, +0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14, +0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08, +0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02, +0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76, +0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, +0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2, +0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, +0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24, +0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04, +0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2, +0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02, +0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26, +0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02, +0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00, +0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00, +0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x92,0x01,0x20,0x20,0x21,0x08,0x00,0x03,0x9d, +0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07, +0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,0x27,0x83,0x94,0x50,0x00,0x43,0x10,0x21, +0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xc4,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40, +0x27,0x83,0x94,0x58,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xc4, +0x00,0x07,0x22,0x02,0x27,0x82,0x94,0x50,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00, +0x08,0x00,0x03,0xc4,0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21, +0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00, +0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e, +0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xc4, +0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00, +0x08,0x00,0x03,0xc3,0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00, +0x08,0x00,0x03,0xc3,0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00, +0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x03,0xf5,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x03,0xfa,0x3c,0x02,0xb0,0x0a, +0x08,0x00,0x03,0xfe,0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08, +0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02, +0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00, +0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24, +0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00, +0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24, +0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02, +0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02, +0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01, +0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69, +0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15, +0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21, +0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24, +0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,0x08,0x00,0x03,0x9d,0x02,0x51,0x10,0x21, +0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24, +0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0x9d, +0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00, +0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, +0x08,0x00,0x03,0x9c,0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21, +0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17, +0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x94,0x50, +0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27, +0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0x9c, +0xac,0x82,0x00,0x18,0x27,0x83,0x94,0x58,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21, +0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24, +0x00,0x45,0x10,0x25,0x08,0x00,0x03,0x9c,0xa4,0x82,0x00,0x02,0x27,0x83,0x94,0x50, +0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x52, +0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f, +0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, +0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x3f, +0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00, +0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x48,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a, +0x08,0x00,0x04,0x75,0x00,0x43,0x18,0x21,0x97,0x85,0x94,0xa4,0x3c,0x07,0xb0,0x02, +0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20, +0x24,0x42,0x12,0x38,0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07, +0x97,0x82,0x94,0xa6,0x97,0x85,0x94,0xa4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8, +0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08, +0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25, +0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x94,0xa0, +0xa7,0x82,0x94,0xa4,0xa7,0x80,0x94,0xa6,0xaf,0x80,0x94,0xa8,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, +0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07, +0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03, +0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14, +0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27, +0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x04,0xd9,0xac,0x62,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, +0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07, +0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a, +0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10, +0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09, +0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, +0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, +0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24, +0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00, +0x30,0xa9,0x00,0xff,0x27,0x83,0x94,0x50,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01, +0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21, +0x00,0x05,0x20,0x40,0x27,0x82,0x94,0x50,0x00,0x05,0x28,0x80,0x27,0x83,0x94,0x58, +0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27, +0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00, +0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18, +0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25, +0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00, +0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00, +0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25, +0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x02,0xb0,0x02, +0x34,0x42,0x00,0x08,0x3c,0x03,0xb0,0x02,0xaf,0x82,0x8c,0x78,0xaf,0x83,0x8c,0x7c, +0xa7,0x80,0x8c,0x80,0xa7,0x80,0x8c,0x82,0xaf,0x80,0x8c,0x84,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xbf,0x00,0x20,0x94,0x82,0x00,0x04, +0x3c,0x05,0xff,0x8f,0x00,0x80,0x18,0x21,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x0a, +0x34,0xa5,0xff,0xff,0x90,0x84,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xfc, +0x00,0x64,0x20,0x21,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x10,0x2b, +0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x0c,0x00,0x07,0xc9,0x00,0x00,0x00,0x00, +0x08,0x00,0x05,0x4a,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c, +0x8f,0x90,0x94,0xa0,0x0c,0x00,0x31,0x0a,0x00,0x80,0x90,0x21,0x00,0x40,0x88,0x21, +0x93,0x82,0x82,0x28,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x24,0x02,0x00,0x01, +0xa3,0x82,0x82,0x28,0x24,0x03,0x00,0x05,0x24,0x02,0x00,0x04,0xa3,0x83,0x8c,0x73, +0xa3,0x82,0x8c,0x72,0xa7,0x80,0x82,0x2a,0x00,0x00,0x28,0x21,0x27,0x86,0x8c,0x70, +0x00,0x05,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, +0x30,0x65,0xff,0xff,0xae,0x04,0x00,0x00,0x10,0xa0,0xff,0xfa,0x00,0x05,0x10,0x80, +0x8f,0x83,0x94,0xa0,0x97,0x82,0x94,0xa6,0x24,0x05,0x8f,0xff,0x24,0x63,0x00,0x04, +0x00,0x65,0x18,0x24,0x26,0x04,0x00,0x04,0x24,0x42,0x00,0x04,0xaf,0x83,0x94,0xa0, +0xa7,0x82,0x94,0xa6,0x00,0x85,0x80,0x24,0x97,0x84,0x82,0x2a,0x27,0x93,0x80,0x34, +0x02,0x40,0x28,0x21,0x00,0x93,0x20,0x21,0x0c,0x00,0x31,0x8e,0x02,0x20,0x30,0x21, +0x97,0x87,0x82,0x2a,0x24,0x02,0x00,0x52,0x00,0xf1,0x18,0x21,0xa7,0x83,0x82,0x2a, +0x82,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x06,0x00,0x60,0x38,0x21, +0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x28,0x82,0x43,0x00,0x01,0x24,0x02,0x00,0x54,0x14,0x62,0xff,0xf8, +0x24,0x02,0x00,0x4c,0x82,0x43,0x00,0x02,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf4, +0x00,0x00,0x00,0x00,0x30,0xe6,0xff,0xff,0x10,0xc0,0x00,0x0c,0x00,0x00,0x28,0x21, +0x02,0x60,0x48,0x21,0x24,0x08,0x8f,0xff,0x00,0xa9,0x10,0x21,0x8c,0x44,0x00,0x00, +0x24,0xa3,0x00,0x04,0x30,0x65,0xff,0xff,0x26,0x02,0x00,0x04,0x00,0xa6,0x18,0x2b, +0xae,0x04,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x48,0x80,0x24,0x97,0x83,0x94,0xa6, +0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x00,0x67,0x18,0x21,0x00,0xa2,0x28,0x21, +0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, +0x8f,0x82,0x94,0xa0,0x8c,0x86,0x00,0x00,0x30,0xe5,0xff,0xff,0x24,0x03,0x8f,0xff, +0x00,0x45,0x10,0x21,0x3c,0x04,0x0f,0x00,0x00,0x43,0x10,0x24,0x00,0xc4,0x30,0x24, +0x3c,0x03,0x04,0x00,0xaf,0x82,0x94,0xa0,0x10,0xc3,0xff,0xd1,0x00,0x00,0x00,0x00, +0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0xa3,0x80,0x82,0x28,0x08,0x00,0x05,0x88, +0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x97,0x83,0x8c,0x80,0x8f,0x87,0x8c,0x78, +0x3c,0x06,0xff,0xff,0xac,0x43,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x3c,0x03,0x80,0x00, +0x24,0xe5,0x00,0x08,0xac,0x43,0x00,0x04,0x8f,0x82,0x8c,0x7c,0x34,0xc6,0x1f,0xff, +0x3c,0x03,0x00,0x40,0x30,0x42,0x0f,0xff,0x3c,0x04,0xb0,0x06,0x00,0x02,0x10,0xc2, +0x00,0x43,0x10,0x25,0x00,0xa6,0x28,0x24,0x34,0x84,0x80,0x18,0x27,0xbd,0xff,0xf8, +0xac,0x82,0x00,0x00,0xaf,0x85,0x8c,0x78,0xaf,0x87,0x8c,0x7c,0xa7,0x80,0x8c,0x80, +0xa7,0x80,0x8c,0x82,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0, +0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x8f,0x91,0x8c,0x78, +0x00,0x80,0x80,0x21,0xaf,0xbf,0x00,0x1c,0x0c,0x00,0x06,0x78,0x00,0xa0,0x90,0x21, +0x97,0x82,0x8c,0x80,0x36,0x10,0x12,0x00,0x26,0x2a,0x00,0x04,0x24,0x4c,0x00,0x14, +0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x0a,0x24,0x09,0x8f,0xff,0x8f,0x82,0x80,0x20, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x80,0x20,0x8f,0xbf,0x00,0x1c, +0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, +0x8e,0x44,0x00,0x1c,0x86,0x47,0x00,0x06,0x97,0x86,0x8c,0x82,0x8c,0x82,0x00,0x08, +0x00,0x07,0x3c,0x00,0x8f,0x85,0x8c,0x78,0x00,0x02,0x11,0x02,0x30,0x42,0x40,0x00, +0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x8c,0x82,0x00,0x04,0x82,0x43,0x00,0x15, +0x01,0x49,0x88,0x24,0x00,0x02,0x14,0xc2,0x00,0x03,0x1a,0x00,0x00,0x02,0x14,0x00, +0x00,0x62,0x80,0x25,0xae,0x30,0x00,0x00,0x92,0x43,0x00,0x13,0x92,0x44,0x00,0x10, +0x96,0x50,0x00,0x1a,0x00,0x03,0x1c,0x00,0x00,0x04,0x26,0x00,0x02,0x03,0x80,0x25, +0x26,0x22,0x00,0x04,0x00,0x49,0x88,0x24,0x02,0x04,0x80,0x25,0xae,0x30,0x00,0x00, +0x92,0x42,0x00,0x0f,0x92,0x43,0x00,0x11,0x26,0x24,0x00,0x04,0x00,0x02,0x12,0x00, +0x00,0x89,0x88,0x24,0x00,0x62,0x80,0x25,0x02,0x07,0x80,0x25,0x26,0x22,0x00,0x04, +0xae,0x30,0x00,0x00,0x00,0x49,0x88,0x24,0xae,0x20,0x00,0x00,0x8f,0x82,0x80,0x1c, +0x24,0xc6,0x00,0x01,0x24,0xa5,0x00,0x14,0x30,0xc8,0xff,0xff,0x3c,0x0b,0xb0,0x03, +0x00,0xa9,0x28,0x24,0x24,0x42,0x00,0x01,0x2d,0x08,0x00,0x0a,0xaf,0x85,0x8c,0x78, +0xa7,0x8c,0x8c,0x80,0xaf,0x82,0x80,0x1c,0xa7,0x86,0x8c,0x82,0x11,0x00,0x00,0x07, +0x35,0x6b,0x01,0x08,0x8f,0x82,0x8c,0x84,0x8d,0x63,0x00,0x00,0x24,0x42,0x04,0x00, +0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xc1,0x00,0x00,0x00,0x00,0x0c,0x00,0x05,0xbd, +0x00,0x00,0x00,0x00,0x08,0x00,0x05,0xf3,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8, +0xaf,0xbf,0x00,0x10,0x0c,0x00,0x06,0x78,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0, +0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c, +0x8f,0x90,0x8c,0x78,0x0c,0x00,0x06,0x78,0x00,0x80,0x90,0x21,0x97,0x82,0x8c,0x80, +0x24,0x11,0x8f,0xff,0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x06,0x26,0x03,0x00,0x04, +0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x71,0x80,0x24, +0xae,0x00,0x00,0x00,0x8e,0x44,0x00,0x08,0x26,0x02,0x00,0x04,0x0c,0x00,0x06,0x86, +0x00,0x51,0x80,0x24,0x97,0x86,0x8c,0x82,0x8f,0x83,0x8c,0x78,0xae,0x02,0x00,0x00, +0x97,0x82,0x8c,0x80,0x24,0xc6,0x00,0x01,0x8e,0x47,0x00,0x0c,0x24,0x63,0x00,0x10, +0x30,0xc5,0xff,0xff,0x26,0x04,0x00,0x04,0x3c,0x08,0xb0,0x03,0x00,0x71,0x18,0x24, +0x00,0x91,0x80,0x24,0x24,0x42,0x00,0x10,0x2c,0xa5,0x00,0x0a,0x35,0x08,0x01,0x08, +0xae,0x07,0x00,0x00,0xaf,0x83,0x8c,0x78,0xa7,0x82,0x8c,0x80,0xa7,0x86,0x8c,0x82, +0x10,0xa0,0x00,0x07,0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x84,0x8d,0x03,0x00,0x00, +0x24,0x42,0x04,0x00,0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00, +0x0c,0x00,0x05,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x06,0x4c,0x00,0x00,0x00,0x00, +0x97,0x82,0x8c,0x82,0x3c,0x03,0xb0,0x03,0x14,0x40,0x00,0x09,0x34,0x63,0x01,0x08, +0x8c,0x62,0x00,0x00,0x8f,0x83,0x8c,0x7c,0xa7,0x80,0x8c,0x80,0xaf,0x82,0x8c,0x84, +0xac,0x60,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x00,0x00,0x00,0x00,0xac,0x40,0x00,0x04, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00, +0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24, +0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08, +0x00,0x44,0x10,0x25,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00,0x10,0x40,0x00,0x0c, +0x00,0x80,0x28,0x21,0x24,0x62,0xff,0x9f,0x30,0x42,0x00,0xff,0x2c,0x42,0x00,0x1a, +0x10,0x40,0x00,0x02,0x24,0x63,0xff,0xe0,0xa0,0xa3,0x00,0x00,0x24,0xa5,0x00,0x01, +0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6,0x00,0x40,0x18,0x21, +0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00, +0x10,0x40,0x00,0x0c,0x00,0x80,0x28,0x21,0x24,0x62,0xff,0xbf,0x30,0x42,0x00,0xff, +0x2c,0x42,0x00,0x1a,0x10,0x40,0x00,0x02,0x24,0x63,0x00,0x20,0xa0,0xa3,0x00,0x00, +0x24,0xa5,0x00,0x01,0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6, +0x00,0x40,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x27,0xbd,0xff,0xe8, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x24,0x10,0xff,0xff,0x0c,0x00,0x2e,0x4a, +0x00,0x00,0x00,0x00,0x10,0x50,0xff,0xfd,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03, +0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x27,0xbd,0xff,0xc8,0xaf,0xb3,0x00,0x1c,0x00,0x00,0x98,0x21,0xaf,0xb1,0x00,0x14, +0x02,0x65,0x88,0x2b,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x34,0xaf,0xbe,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb4,0x00,0x20, +0xaf,0xb2,0x00,0x18,0x00,0xa0,0xb0,0x21,0xaf,0xa4,0x00,0x38,0x00,0xc0,0xa8,0x21, +0x12,0x20,0x00,0x17,0x00,0x80,0x80,0x21,0x24,0x17,0xff,0xff,0x24,0x1e,0x00,0x0a, +0x0c,0x00,0x2e,0x4a,0x00,0x00,0x00,0x00,0x10,0x57,0x00,0x0f,0x00,0x02,0x16,0x00, +0x00,0x02,0x26,0x03,0x10,0x9e,0x00,0x0e,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x34, +0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x25,0x24,0x02,0x00,0x09,0x10,0x82,0x00,0x13, +0x00,0x00,0x90,0x21,0xa2,0x04,0x00,0x00,0x26,0x73,0x00,0x01,0x16,0xa0,0x00,0x0b, +0x26,0x10,0x00,0x01,0x02,0x76,0x88,0x2b,0x16,0x20,0xff,0xed,0x00,0x00,0x00,0x00, +0x7b,0xbe,0x01,0xbc,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x0c,0x00,0x2e,0x3d, +0x02,0x76,0x88,0x2b,0x08,0x00,0x06,0xe6,0x00,0x00,0x00,0x00,0x24,0x14,0x00,0x20, +0xa2,0x14,0x00,0x00,0x26,0x52,0x00,0x01,0x24,0x04,0x00,0x20,0x26,0x73,0x00,0x01, +0x16,0xa0,0x00,0x06,0x26,0x10,0x00,0x01,0x2a,0x42,0x00,0x08,0x10,0x40,0xff,0xea, +0x02,0x76,0x88,0x2b,0x08,0x00,0x06,0xf5,0xa2,0x14,0x00,0x00,0x0c,0x00,0x2e,0x3d, +0x00,0x00,0x00,0x00,0x08,0x00,0x06,0xfb,0x2a,0x42,0x00,0x08,0x8f,0xa2,0x00,0x38, +0x00,0x00,0x00,0x00,0x12,0x02,0xff,0xe0,0x00,0x00,0x00,0x00,0x26,0x10,0xff,0xff, +0x12,0xa0,0xff,0xdc,0x26,0x73,0xff,0xff,0x0c,0x00,0x2e,0x3d,0x24,0x04,0x00,0x08, +0x0c,0x00,0x2e,0x3d,0x24,0x04,0x00,0x20,0x08,0x00,0x06,0xef,0x24,0x04,0x00,0x08, +0x08,0x00,0x06,0xe8,0xa2,0x00,0x00,0x00,0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x16,0x00,0x00,0x30,0x21,0x24,0x07,0x00,0x20, +0x00,0x03,0x1e,0x03,0x10,0x67,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x15, +0x00,0x00,0x00,0x00,0x10,0x67,0x00,0x0b,0x24,0xc6,0x00,0x01,0x10,0x60,0x00,0x0a, +0x00,0x02,0x1e,0x00,0x24,0x05,0x00,0x20,0x24,0x84,0x00,0x01,0x80,0x83,0x00,0x00, +0x90,0x82,0x00,0x00,0x10,0x65,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa, +0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0x14,0x60,0xff,0xed,0x00,0x00,0x00,0x00, +0x28,0xc3,0x00,0x08,0x24,0x02,0x00,0x07,0x00,0x43,0x30,0x0a,0x03,0xe0,0x00,0x08, +0x00,0xc0,0x10,0x21,0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,0x08,0x00,0x07,0x2a, +0x00,0x02,0x1e,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14,0x27,0x91,0x8c,0x88, +0xaf,0xb0,0x00,0x10,0x24,0x06,0x00,0x20,0x00,0x80,0x80,0x21,0x00,0x00,0x28,0x21, +0xaf,0xbf,0x00,0x18,0x0c,0x00,0x31,0x84,0x02,0x20,0x20,0x21,0x82,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1f,0x00,0x00,0x30,0x21,0x02,0x20,0x20,0x21, +0x24,0x09,0x00,0x20,0x24,0x08,0x00,0x20,0x24,0x07,0x00,0x08,0xac,0x90,0x00,0x00, +0x82,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x49,0x00,0x0a,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x08,0x24,0x03,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa, +0x00,0x00,0x00,0x00,0xa2,0x00,0x00,0x00,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, +0x92,0x03,0x00,0x00,0x10,0x48,0x00,0x0c,0x24,0x05,0x00,0x20,0x24,0xc6,0x00,0x01, +0x10,0xc7,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x03,0x16,0x00,0x14,0x40,0xff,0xe7, +0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x27,0x82,0x8c,0x88, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, +0x92,0x03,0x00,0x00,0x10,0x45,0xff,0xfc,0x00,0x00,0x00,0x00,0x08,0x00,0x07,0x5c, +0x24,0xc6,0x00,0x01,0x00,0x80,0x30,0x21,0x90,0x84,0x00,0x00,0x00,0x00,0x38,0x21, +0x10,0x80,0x00,0x19,0x24,0xc6,0x00,0x01,0x24,0x82,0xff,0xd0,0x30,0x42,0x00,0xff, +0x2c,0x43,0x00,0x0a,0x14,0x60,0x00,0x0c,0x00,0x07,0x19,0x00,0x24,0x83,0xff,0x9f, +0x24,0x82,0xff,0xa9,0x24,0x88,0xff,0xc9,0x2c,0x63,0x00,0x06,0x24,0x84,0xff,0xbf, +0x2c,0x84,0x00,0x06,0x14,0x60,0x00,0x03,0x30,0x42,0x00,0xff,0x10,0x80,0x00,0x0e, +0x31,0x02,0x00,0xff,0x00,0x07,0x19,0x00,0x00,0x62,0x18,0x21,0x00,0x67,0x10,0x2b, +0x14,0x40,0x00,0x07,0x00,0x00,0x20,0x21,0x90,0xc4,0x00,0x00,0x00,0x60,0x38,0x21, +0x14,0x80,0xff,0xe9,0x24,0xc6,0x00,0x01,0xac,0xa7,0x00,0x00,0x24,0x04,0x00,0x01, +0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x07,0x8c,0x00,0x00,0x20,0x21, +0x00,0x00,0x20,0x21,0x27,0x85,0x94,0xc0,0x24,0x82,0x00,0x01,0x00,0x04,0x18,0x80, +0x30,0x44,0x00,0xff,0x00,0x65,0x18,0x21,0x2c,0x82,0x00,0x0b,0x14,0x40,0xff,0xfa, +0xac,0x60,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x84,0x8d,0x08, +0xaf,0x85,0x8d,0x0c,0xaf,0x86,0x8d,0x10,0xaf,0x87,0x8d,0x14,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x98,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, +0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0x27,0x84,0x8c,0xa8,0xaf,0x82,0x84,0x98, +0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x80,0x84,0x98,0x0c,0x00,0x07,0xf6, +0x00,0x00,0x00,0x00,0x00,0x40,0x18,0x21,0x28,0x44,0x00,0x08,0x24,0x02,0x00,0x07, +0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x80,0xff,0xf3,0x24,0x02,0x00,0x08, +0x27,0x84,0x8c,0xa8,0x14,0x62,0xff,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0x95, +0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0xa8,0x0c,0x00,0x08,0x54,0x00,0x00,0x00,0x00, +0x8f,0x83,0x84,0x9c,0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01, +0xaf,0x83,0x84,0x9c,0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0x90,0x08,0x00,0x07,0xaa, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xbf,0x00,0x38,0x8c,0x85,0x00,0x0c, +0x8c,0x88,0x00,0x08,0x18,0xa0,0x00,0x0e,0x00,0x00,0x30,0x21,0x24,0x87,0x00,0x08, +0x27,0xa9,0x00,0x10,0x00,0x06,0x10,0x80,0x00,0x06,0x19,0x00,0x00,0x49,0x10,0x21, +0x14,0xc0,0x00,0x1f,0x00,0x83,0x18,0x21,0xaf,0xa7,0x00,0x10,0x24,0xc2,0x00,0x01, +0x30,0x46,0x00,0xff,0x00,0xc5,0x18,0x2a,0x14,0x60,0xff,0xf7,0x00,0x06,0x10,0x80, +0x29,0x02,0x00,0x0a,0x14,0x40,0x00,0x05,0x00,0x08,0x18,0x40,0x8f,0xbf,0x00,0x38, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x00,0x68,0x18,0x21, +0x27,0x82,0x83,0x94,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21,0x8c,0x62,0x00,0x10, +0x01,0x00,0x20,0x21,0x00,0x40,0xf8,0x09,0x27,0xa6,0x00,0x10,0x8f,0x83,0x84,0xb0, +0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01,0xaf,0x83,0x84,0xb0, +0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0xa4,0x08,0x00,0x07,0xdf,0x00,0x00,0x00,0x00, +0x08,0x00,0x07,0xd7,0xac,0x43,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14, +0xaf,0xbf,0x00,0x18,0x00,0x80,0x88,0x21,0x0c,0x00,0x1a,0xb9,0xaf,0xb0,0x00,0x10, +0x00,0x40,0x20,0x21,0x24,0x02,0xff,0xff,0x10,0x82,0x00,0x1f,0x24,0x03,0x00,0x06, +0x8f,0x85,0x84,0xc4,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x0a,0x24,0x02,0x00,0x08, +0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x3b,0x28,0x82,0x00,0x03,0x10,0x40,0x00,0x32, +0x24,0x02,0x00,0x1b,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x13,0x24,0x03,0x00,0x08, +0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x23,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x18, +0x02,0x25,0x10,0x21,0x24,0xa3,0x00,0x01,0xa0,0x44,0x00,0x00,0xaf,0x83,0x84,0xc4, +0x18,0x60,0x00,0x08,0x24,0x02,0x00,0x43,0x82,0x23,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x62,0x00,0x0a,0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x0c,0x00,0x1a,0xb5, +0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x06,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x04,0x80,0x01, +0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xb8,0x08,0x00,0x08,0x1e,0x24,0x03,0x00,0x06, +0xa0,0x40,0x00,0x00,0x24,0xa5,0x00,0x01,0xaf,0x85,0x84,0xc4,0x0c,0x00,0x1a,0xb5, +0x24,0x04,0x00,0x0d,0x24,0x03,0x00,0x07,0xaf,0x80,0x84,0xc4,0x08,0x00,0x08,0x1e, +0x00,0x00,0x00,0x00,0x18,0xa0,0xff,0xeb,0x24,0xa5,0xff,0xff,0xaf,0x85,0x84,0xc4, +0x0c,0x00,0x1a,0xb5,0x24,0x04,0x00,0x08,0x0c,0x00,0x1a,0xb5,0x24,0x04,0x00,0x20, +0x08,0x00,0x08,0x1b,0x24,0x04,0x00,0x08,0x14,0x82,0xff,0xd2,0x24,0x02,0x00,0x08, +0x0c,0x00,0x07,0x90,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0xc4,0x08,0x00,0x08,0x0c, +0x24,0x04,0x00,0x0d,0x0c,0x00,0x31,0x0a,0x02,0x20,0x20,0x21,0xaf,0x82,0x84,0xc4, +0x04,0x40,0x00,0x0d,0x00,0x00,0x80,0x21,0x02,0x30,0x10,0x21,0x90,0x44,0x00,0x00, +0x26,0x10,0x00,0x01,0x00,0x04,0x26,0x00,0x00,0x04,0x26,0x03,0x0c,0x00,0x1a,0xb5, +0x30,0x84,0xff,0xff,0x8f,0x83,0x84,0xc4,0x00,0x00,0x00,0x00,0x00,0x70,0x18,0x2a, +0x10,0x60,0xff,0xf6,0x02,0x30,0x10,0x21,0x08,0x00,0x08,0x2e,0x24,0x03,0x00,0x06, +0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x27,0x83,0x8c,0xe8,0x24,0x02,0x00,0x07, +0x24,0x42,0xff,0xff,0xac,0x60,0x00,0x00,0x04,0x41,0xff,0xfd,0x24,0x63,0x00,0x04, +0x0c,0x00,0x08,0x66,0x00,0x00,0x00,0x00,0x8f,0x84,0x8c,0xe8,0x27,0x86,0x8c,0xe8, +0x0c,0x00,0x08,0x83,0x00,0x40,0x28,0x21,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0,0x00,0x80,0x28,0x21, +0x27,0x84,0x8c,0xc8,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0x0c,0x00,0x31,0x9b, +0xaf,0xb0,0x00,0x10,0x8f,0x85,0x83,0x34,0x27,0x84,0x8c,0xc8,0x0c,0x00,0x31,0x5f, +0x00,0x00,0x88,0x21,0x10,0x40,0x00,0x0c,0x00,0x00,0x00,0x00,0x27,0x90,0x8c,0xe8, +0x8f,0x85,0x83,0x34,0x00,0x00,0x20,0x21,0xae,0x02,0x00,0x00,0x0c,0x00,0x31,0x5f, +0x26,0x31,0x00,0x01,0x26,0x10,0x00,0x04,0x10,0x40,0x00,0x03,0x2a,0x23,0x00,0x64, +0x14,0x60,0xff,0xf7,0x00,0x00,0x00,0x00,0x02,0x20,0x10,0x21,0x8f,0xbf,0x00,0x18, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd0, +0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xbf,0x00,0x2c, +0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, +0x00,0xa0,0xa8,0x21,0x00,0x80,0xa0,0x21,0x00,0xc0,0xb0,0x21,0x10,0xa0,0x00,0x1d, +0x24,0x02,0x00,0x05,0x3c,0x02,0x80,0x00,0x24,0x43,0x2c,0x80,0x8f,0x82,0x83,0xa4, +0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x1e,0x00,0x00,0x88,0x21,0x00,0x60,0x98,0x21, +0x00,0x00,0x90,0x21,0x27,0x90,0x83,0xa4,0x8e,0x05,0xff,0xec,0x02,0x80,0x20,0x21, +0x0c,0x00,0x31,0xa3,0x26,0x10,0x00,0x18,0x10,0x40,0x00,0x06,0x02,0x51,0x18,0x21, +0x8e,0x02,0x00,0x00,0x26,0x31,0x00,0x01,0x14,0x53,0xff,0xf7,0x00,0x11,0x90,0x40, +0x02,0x51,0x18,0x21,0x27,0x82,0x83,0x94,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21, +0x8c,0x62,0x00,0x10,0x02,0x20,0x20,0x21,0x02,0xa0,0x28,0x21,0x00,0x40,0xf8,0x09, +0x02,0xc0,0x30,0x21,0x8f,0xbf,0x00,0x2c,0x8f,0xb6,0x00,0x28,0x7b,0xb4,0x01,0x3c, +0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, +0x08,0x00,0x08,0xa4,0x00,0x00,0x90,0x21,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34, +0xaf,0xb3,0x00,0x2c,0xaf,0xb1,0x00,0x24,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30, +0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0x00,0xc0,0x98,0x21,0x30,0xa5,0x00,0xff, +0xac,0xc0,0x00,0x00,0x24,0x15,0x00,0x0a,0x00,0x00,0x88,0x21,0x27,0xa8,0x00,0x10, +0x00,0x91,0x18,0x21,0x80,0x62,0x00,0x00,0x26,0x27,0x00,0x01,0x10,0x40,0x00,0x0c, +0x01,0x11,0x30,0x21,0x90,0x63,0x00,0x00,0x30,0xf1,0x00,0xff,0x2e,0x22,0x00,0x0a, +0x14,0x40,0xff,0xf7,0xa0,0xc3,0x00,0x00,0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc, +0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, +0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x23,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x1f, +0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x1a,0x00,0x00,0x00,0x00,0x02,0x20,0x90,0x21, +0x12,0x40,0xff,0xf1,0x00,0x00,0x88,0x21,0x27,0xb4,0x00,0x10,0x02,0x91,0x10,0x21, +0x90,0x44,0x00,0x00,0x0c,0x00,0x09,0x0a,0x00,0x00,0x00,0x00,0x02,0x51,0x20,0x23, +0x24,0x84,0xff,0xff,0x30,0x84,0x00,0xff,0x02,0xa0,0x28,0x21,0x0c,0x00,0x08,0xfb, +0x00,0x40,0x80,0x21,0x02,0x02,0x00,0x18,0x8e,0x63,0x00,0x00,0x26,0x22,0x00,0x01, +0x30,0x51,0x00,0xff,0x02,0x32,0x20,0x2b,0x00,0x00,0x80,0x12,0x00,0x70,0x18,0x21, +0x14,0x80,0xff,0xee,0xae,0x63,0x00,0x00,0x08,0x00,0x08,0xce,0x00,0x00,0x00,0x00, +0x80,0x82,0x00,0x00,0x08,0x00,0x08,0xce,0xae,0x62,0x00,0x00,0x08,0x00,0x08,0xdb, +0x24,0x15,0x00,0x10,0x08,0x00,0x08,0xdb,0x24,0x15,0x00,0x0a,0x30,0x84,0x00,0xff, +0x30,0xa5,0x00,0xff,0x24,0x06,0x00,0x01,0x10,0x80,0x00,0x09,0x00,0x00,0x10,0x21, +0x00,0xc5,0x00,0x18,0x24,0x42,0x00,0x01,0x30,0x42,0x00,0xff,0x00,0x44,0x18,0x2b, +0x00,0x00,0x30,0x12,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa,0x00,0xc5,0x00,0x18, +0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x30,0x84,0x00,0xff,0x24,0x83,0xff,0xd0, +0x30,0x62,0x00,0xff,0x2c,0x42,0x00,0x0a,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00, +0x24,0x82,0xff,0xbf,0x2c,0x42,0x00,0x06,0x14,0x40,0x00,0x02,0x24,0x83,0xff,0xc9, +0x24,0x83,0xff,0xa9,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xc8, +0x24,0x02,0x00,0x01,0xaf,0xbf,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28, +0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0x10,0xa2,0x00,0x3e, +0xaf,0xb0,0x00,0x18,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08,0x24,0x05,0x00,0x01, +0x00,0x00,0x10,0x21,0x8f,0xbf,0x00,0x30,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c, +0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8c,0xc4,0x00,0x04, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00, +0x28,0x42,0x00,0x65,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01, +0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xbc,0x08,0x00,0x09,0x25,0x24,0x02,0x00,0x01, +0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xc8,0x8f,0x83,0x83,0xa4, +0x3c,0x02,0x80,0x00,0x24,0x42,0x2c,0x80,0x10,0x62,0xff,0xe5,0x00,0x40,0x90,0x21, +0x3c,0x13,0x80,0x01,0x27,0x95,0x83,0x90,0x3c,0x14,0x80,0x01,0x27,0x90,0x83,0x94, +0x00,0x00,0x88,0x21,0x8e,0x03,0x00,0x08,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00, +0x10,0x62,0x00,0x08,0x26,0x64,0x04,0xd4,0x26,0x10,0x00,0x18,0x8e,0x02,0x00,0x10, +0x00,0x00,0x00,0x00,0x14,0x52,0xff,0xf7,0x26,0x31,0x00,0x18,0x08,0x00,0x09,0x25, +0x00,0x00,0x10,0x21,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x02,0x35,0x10,0x21, +0x8c,0x44,0x00,0x00,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0x95, +0x26,0x84,0x04,0xd8,0x8e,0x04,0x00,0x00,0x0c,0x00,0x1a,0x95,0x26,0x10,0x00,0x18, +0x08,0x00,0x09,0x4b,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95, +0x24,0x84,0x04,0xdc,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0xec, +0x24,0x11,0x00,0x05,0x3c,0x12,0x80,0x01,0x27,0x90,0x88,0x0e,0x86,0x05,0x00,0x00, +0x26,0x44,0x05,0x0c,0x0c,0x00,0x1a,0x82,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xfb, +0x26,0x10,0xff,0xfe,0x08,0x00,0x09,0x25,0x00,0x00,0x10,0x21,0x27,0xbd,0xff,0xd0, +0x28,0xa2,0x00,0x02,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x2c, +0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0x00,0xa0,0x80,0x21, +0x14,0x40,0x00,0x51,0x00,0xc0,0x88,0x21,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x48, +0x24,0x05,0x00,0x01,0x8e,0x24,0x00,0x08,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14, +0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x30,0x42,0x0f,0xff,0xaf,0xa2,0x00,0x14, +0x7b,0xa4,0x00,0xbc,0x0c,0x00,0x0a,0x06,0x24,0x06,0x00,0x04,0x24,0x03,0x00,0x04, +0x10,0x43,0x00,0x2a,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x10,0x3c,0x04,0x80,0x01, +0x24,0x84,0x05,0x10,0x00,0x02,0x19,0x02,0x00,0x03,0x81,0x00,0x8f,0xa3,0x00,0x14, +0x00,0x50,0x10,0x23,0x00,0x02,0x10,0x82,0x00,0x62,0x18,0x21,0x0c,0x00,0x1a,0x95, +0xaf,0xa3,0x00,0x14,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95,0x24,0x84,0x05,0x38, +0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x88,0x21, +0x3c,0x13,0x80,0x01,0x3c,0x12,0x80,0x01,0x3c,0x14,0x80,0x01,0x0c,0x00,0x2e,0xda, +0x24,0x04,0x27,0x10,0x32,0x23,0x00,0x03,0x02,0x00,0x28,0x21,0x10,0x60,0x00,0x1c, +0x26,0x64,0x05,0x64,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x23, +0x28,0x42,0xff,0xfd,0x10,0x40,0x00,0x10,0x26,0x44,0x05,0x70,0x0c,0x00,0x1a,0x95, +0x26,0x10,0x00,0x04,0x8f,0xa2,0x00,0x14,0x26,0x31,0x00,0x01,0x02,0x22,0x10,0x2b, +0x14,0x40,0xff,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x21,0x8f,0xbf,0x00,0x2c, +0x8f,0xb4,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x80,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8e,0x05,0x00,0x00,0x26,0x84,0x05,0x74, +0x0c,0x00,0x1a,0x82,0x26,0x10,0x00,0x04,0x08,0x00,0x09,0xb1,0x00,0x00,0x00,0x00, +0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00,0x08,0x00,0x09,0xa9,0x00,0x00,0x00,0x00, +0x08,0x00,0x09,0x87,0x24,0x02,0x00,0x01,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, +0x08,0x00,0x09,0xb7,0x24,0x04,0x00,0x04,0x27,0xbd,0xff,0xd0,0x28,0xa2,0x00,0x03, +0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x28,0x00,0xa0,0x88,0x21, +0x10,0x40,0x00,0x09,0x00,0xc0,0x80,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, +0x24,0x04,0x00,0x04,0x8f,0xbf,0x00,0x28,0x7b,0xb0,0x01,0x3c,0x00,0x80,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x1b, +0x24,0x05,0x00,0x01,0x8e,0x04,0x00,0x0c,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18, +0x8f,0xa4,0x00,0x10,0x8f,0xa5,0x00,0x18,0x0c,0x00,0x0a,0x06,0x24,0x06,0x00,0x04, +0x24,0x03,0x00,0x04,0x10,0x43,0xff,0xe7,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x18, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,0x00,0x00,0x28,0x21,0x8f,0xa2,0x00,0x10, +0x8f,0xa4,0x00,0x14,0x24,0xa5,0x00,0x01,0xac,0x44,0x00,0x00,0x8f,0xa3,0x00,0x10, +0x8f,0xa2,0x00,0x18,0x24,0x63,0x00,0x04,0x00,0xa2,0x10,0x2b,0x14,0x40,0xff,0xf7, +0xaf,0xa3,0x00,0x10,0x08,0x00,0x09,0xd9,0x00,0x00,0x20,0x21,0x24,0x02,0x00,0x01, +0x08,0x00,0x09,0xec,0xaf,0xa2,0x00,0x18,0x30,0xc6,0x00,0xff,0x00,0xa6,0x00,0x18, +0x00,0x00,0x28,0x12,0x04,0x81,0x00,0x07,0x00,0x00,0x30,0x21,0x3c,0x02,0x80,0x01, +0x00,0x85,0x18,0x21,0x34,0x42,0x7f,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x0b, +0x3c,0x02,0xb0,0x03,0x3c,0x02,0xaf,0xff,0x34,0x42,0xff,0xff,0x00,0x44,0x10,0x2b, +0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x0a,0x00,0x85,0x18,0x21,0x34,0x42,0xff,0xff, +0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0xff,0xff, +0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07,0x3c,0x02,0xb0,0x04, +0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x09,0x3c,0x02,0xb0,0x07, +0x34,0x42,0x00,0x3f,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07, +0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x02,0x00,0x00,0x00,0x00, +0x24,0x06,0x00,0x01,0x14,0xc0,0x00,0x11,0x24,0x02,0x00,0x04,0x3c,0x02,0xb0,0x08, +0x34,0x42,0x0f,0xff,0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x08,0x3c,0x02,0x4f,0xf7, +0x00,0x85,0x20,0x21,0x34,0x42,0xf0,0x00,0x00,0x82,0x20,0x21,0x34,0x03,0xef,0xff, +0x00,0x64,0x18,0x2b,0x14,0x60,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x06,0x00,0x02, +0x10,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,0x24,0x02,0x00,0x02,0xaf,0xb0,0x00,0x18, +0xaf,0xbf,0x00,0x1c,0x10,0xa2,0x00,0x23,0x00,0xc0,0x80,0x21,0x28,0xa2,0x00,0x03, +0x10,0x40,0x00,0x0c,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x04, +0x00,0x00,0x18,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21, +0x8f,0xbf,0x00,0x1c,0x8f,0xb0,0x00,0x18,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x14,0xa2,0xff,0xf7,0x24,0x05,0x00,0x01,0x8c,0xc4,0x00,0x04, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02, +0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x8f,0xa4,0x00,0x10,0x00,0x00,0x00,0x00, +0x2c,0x82,0x00,0x0b,0x10,0x40,0xff,0xee,0x24,0x03,0x00,0x04,0x00,0x04,0x10,0x80, +0x8f,0xa4,0x00,0x14,0x27,0x83,0x94,0xc0,0x00,0x43,0x10,0x21,0x08,0x00,0x0a,0x4f, +0xac,0x44,0x00,0x00,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6, +0x27,0xa6,0x00,0x10,0x8f,0xa5,0x00,0x10,0x27,0x83,0x94,0xc0,0x3c,0x04,0x80,0x01, +0x00,0x05,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x46,0x00,0x00,0x0c,0x00,0x1a,0x82, +0x24,0x84,0x05,0x7c,0x08,0x00,0x0a,0x50,0x00,0x00,0x18,0x21,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xb8,0x28,0xa5,0x00,0x04,0xaf,0xb0,0x00,0x20, +0xaf,0xbf,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34, +0xaf,0xb4,0x00,0x30,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb1,0x00,0x24, +0x10,0xa0,0x00,0x0b,0x00,0xc0,0x80,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x40,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc, +0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48, +0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10, +0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14, +0x8e,0x04,0x00,0x0c,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18, +0x8f,0xa3,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x3a,0x24,0x02,0x00,0x01, +0x10,0x62,0x00,0x33,0x3c,0x04,0x80,0x01,0x97,0xb0,0x00,0x12,0x8f,0xa2,0x00,0x14, +0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x2b,0x10,0x40,0xff,0xe2,0x3c,0x15,0x80,0x01, +0x3c,0x02,0x80,0x01,0x24,0x52,0x05,0xbc,0x3c,0x14,0xb0,0x06,0x24,0x13,0x00,0x01, +0x3c,0x17,0xb0,0x08,0x3c,0x16,0x80,0x01,0x32,0x02,0x00,0x01,0x02,0x00,0x28,0x21, +0x10,0x40,0x00,0x1f,0x26,0xa4,0x05,0xb0,0x8f,0xa3,0x00,0x18,0x00,0x10,0x10,0xc0, +0x00,0x54,0x10,0x21,0x10,0x60,0x00,0x14,0x02,0x40,0x20,0x21,0x00,0x10,0x10,0xc0, +0x00,0x57,0x10,0x21,0x10,0x73,0x00,0x09,0x26,0xc4,0x05,0xc4,0x8f,0xa2,0x00,0x14, +0x26,0x03,0x00,0x01,0x30,0x70,0xff,0xff,0x02,0x02,0x10,0x2b,0x14,0x40,0xff,0xee, +0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0x8d,0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00, +0x00,0x00,0x00,0x00,0x32,0x25,0x00,0xff,0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00, +0x08,0x00,0x0a,0xbf,0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00,0x0c,0x00,0x1a,0x82, +0x00,0x11,0x2c,0x02,0x32,0x25,0x00,0xff,0x08,0x00,0x0a,0xca,0x02,0x40,0x20,0x21, +0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0xb6,0x00,0x00,0x00,0x00, +0x24,0x84,0x05,0x90,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0xa6, +0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,0x08,0x00,0x0a,0xd9,0x24,0x84,0x05,0xd0, +0x00,0xa0,0x10,0x21,0x27,0xbd,0xff,0xd8,0x28,0x42,0x00,0x04,0xaf,0xb0,0x00,0x20, +0xaf,0xbf,0x00,0x24,0x00,0xc0,0x80,0x21,0x24,0x05,0x00,0x01,0x10,0x40,0x00,0x08, +0x27,0xa6,0x00,0x10,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04, +0x8f,0xbf,0x00,0x24,0x8f,0xb0,0x00,0x20,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, +0x8e,0x04,0x00,0x04,0x0c,0x00,0x08,0xb6,0x00,0x00,0x00,0x00,0x8e,0x04,0x00,0x08, +0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x8e,0x04,0x00,0x0c, +0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18,0x08,0x00,0x0a,0xec, +0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x01,0x00,0x65,0x10,0x2a,0x27,0xbd,0xff,0xd8, +0x00,0xa0,0x40,0x21,0x10,0x40,0x00,0x0b,0x00,0xc0,0x38,0x21,0x00,0x03,0x20,0x80, +0x00,0x87,0x10,0x21,0x8c,0x45,0x00,0x00,0x24,0x63,0x00,0x01,0x30,0x63,0x00,0xff, +0x8c,0xa6,0x00,0x00,0x00,0x9d,0x20,0x21,0x00,0x68,0x10,0x2a,0x14,0x40,0xff,0xf7, +0xac,0x86,0xff,0xfc,0x8f,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x0b, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x93,0xa2,0x00,0x07,0x00,0x00,0x00,0x00, +0xa3,0x82,0x87,0x6c,0x08,0x00,0x0b,0x14,0x00,0x00,0x00,0x00,0x93,0xa2,0x00,0x07, +0x00,0x00,0x00,0x00,0xa3,0x82,0x94,0xb0,0x08,0x00,0x0b,0x14,0x00,0x00,0x00,0x00, +0x27,0xbd,0xff,0xe8,0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x10,0x18,0xa0,0x00,0x03, +0x24,0x84,0x05,0xf8,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe8, +0xaf,0xb0,0x00,0x10,0x00,0x80,0x80,0x21,0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x14, +0x0c,0x00,0x1a,0x95,0x24,0x84,0x06,0x0c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, +0x27,0x83,0x83,0x90,0x00,0x02,0x10,0xc0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, +0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x2c,0xf8,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, +0x34,0x84,0x00,0x2c,0x8c,0x86,0x00,0x00,0x3c,0x05,0xb0,0x0a,0x34,0xa5,0x1a,0x00, +0x00,0x06,0x1a,0x02,0x30,0x63,0x0f,0xff,0x00,0x06,0x25,0x02,0x24,0x02,0xff,0xff, +0xac,0xa2,0x00,0x00,0xa7,0x83,0xc5,0x4a,0xa7,0x84,0xc5,0x4c,0xa3,0x86,0xc5,0x48, +0xa7,0x80,0xc5,0x40,0xa7,0x80,0xc5,0x42,0xa7,0x80,0xc5,0x44,0xa7,0x80,0xc5,0x46, +0x00,0xa0,0x38,0x21,0x24,0x03,0x00,0x01,0x8c,0xe2,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0a,0x00,0x8c,0x45,0x00,0x00, +0x3c,0x04,0xb0,0x0a,0x34,0x84,0x1a,0x00,0xa0,0x45,0x00,0x00,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x0a,0x00,0x3c,0x04,0xb0,0x0a,0xa0,0x45,0x00,0x00,0x34,0x84,0x1a,0x00, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x63,0x01,0x08, +0x34,0x84,0x01,0x18,0x8c,0x65,0x00,0x00,0x8c,0x82,0x00,0x00,0xaf,0x85,0xc5,0x50, +0x30,0x42,0x02,0x00,0x10,0x40,0x00,0x06,0x3c,0x02,0x00,0x0f,0x3c,0x02,0x00,0x4c, +0x34,0x42,0x4b,0x40,0xaf,0x82,0xc5,0x54,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x08,0x00,0x0b,0x79,0x34,0x42,0x42,0x40,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x2d,0xf8,0x30,0x84,0x00,0xff,0xac,0x62,0x00,0x00, +0x14,0x80,0x02,0xb3,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x1b,0x40, +0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x0b,0x40,0x8c,0x46,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x1b,0x48, +0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x00,0x06,0x54,0x02, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0b,0x48,0x8c,0x46,0x00,0x00,0x3c,0x03,0xb0,0x0a, +0x34,0x63,0x1b,0x50,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, +0x00,0x06,0x64,0x02,0x30,0xcb,0xff,0xff,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0b,0x50, +0x8c,0x46,0x00,0x00,0x97,0x84,0xc5,0x40,0x97,0x82,0xc5,0x42,0x97,0x83,0xc5,0x46, +0x01,0x44,0x20,0x23,0x01,0x62,0x10,0x23,0x00,0x82,0x20,0x21,0x97,0x82,0xc5,0x44, +0x30,0xcd,0xff,0xff,0x01,0xa3,0x18,0x23,0x01,0x82,0x10,0x23,0x00,0x82,0x20,0x21, +0x93,0x82,0xc5,0x48,0x00,0x83,0x20,0x21,0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b, +0x10,0x40,0x00,0xec,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, +0x8c,0x46,0x00,0x00,0x24,0x02,0x00,0x20,0x30,0xc8,0x00,0x7f,0x11,0x02,0x00,0x4d, +0x2d,0x02,0x00,0x21,0x14,0x40,0x00,0x2b,0x24,0x02,0xff,0x80,0x00,0xc2,0x10,0x24, +0x25,0x08,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0,0x00,0x48,0x30,0x25, +0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xb0, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, +0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0,0x3c,0x04,0xb0,0x0a, +0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x07, +0x24,0x02,0xff,0xff,0xa7,0x8a,0xc5,0x40,0xa7,0x8b,0xc5,0x42,0xa7,0x8c,0xc5,0x44, +0xa7,0x8d,0xc5,0x46,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, +0x34,0x63,0x14,0x58,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x8c,0x69,0x00,0x00,0x3c,0x02,0xff,0xff, +0x34,0x42,0x3f,0xff,0x01,0x22,0x10,0x24,0x34,0x49,0x80,0x00,0x3c,0x04,0xb0,0x0a, +0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0xf9, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x58, +0x8c,0x49,0x00,0x00,0x3c,0x04,0xb0,0x0a,0x34,0x84,0x14,0x58,0x35,0x29,0x40,0x00, +0xac,0x49,0x00,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb0, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb0, +0x8c,0x47,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb8,0x3c,0x05,0xb0,0x0a, +0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x34,0xa5,0x14,0xb8,0x00,0x07,0x1e,0x02, +0x24,0x04,0x00,0x01,0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb8,0x8c,0x47,0x00,0x00,0x00,0x03,0x1a,0x00, +0x30,0xe2,0x00,0xff,0x00,0x62,0x18,0x25,0x2c,0x62,0x00,0x04,0x10,0x40,0x00,0x3a, +0x2c,0x62,0x00,0x11,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10, +0x8c,0x47,0x00,0x00,0x24,0x02,0x00,0x03,0x00,0x07,0x1d,0x82,0x30,0x64,0x00,0x03, +0x10,0x82,0x00,0x1a,0x3c,0x02,0xff,0x3f,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a, +0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x35,0x29,0x80,0x00, +0x34,0x42,0x04,0x58,0x3c,0x04,0xb0,0x0a,0xac,0x49,0x00,0x00,0x34,0x84,0x14,0x58, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x2d,0x02,0x00,0x21,0x08,0x00,0x0b,0xcd,0x00,0x00,0x00,0x00,0x34,0x42,0xff,0xff, +0x3c,0x03,0x00,0x80,0x00,0xe2,0x10,0x24,0x00,0x43,0x38,0x25,0x3c,0x04,0xb0,0x0a, +0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xff,0xff, +0x08,0x00,0x0c,0x60,0x34,0x42,0x3f,0xff,0x14,0x40,0xff,0xd8,0x3c,0x02,0xff,0xff, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00, +0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x02,0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82, +0x14,0x83,0xff,0xc6,0x3c,0x02,0xff,0xff,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, +0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, +0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0c,0x60, +0x34,0x42,0x3f,0xff,0x97,0x82,0xc5,0x4c,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b, +0x10,0x40,0x00,0x74,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0,0x8c,0x46,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0xc8,0x00,0x7f,0x2d,0x02,0x00,0x32,0x10,0x40,0xff,0x3d, +0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x2b,0x24,0x02,0xff,0x80,0x00,0xc2,0x10,0x24, +0x25,0x08,0x00,0x02,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0,0x00,0x48,0x30,0x25, +0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xb0, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, +0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0,0x3c,0x04,0xb0,0x0a, +0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0xf9, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10, +0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x03,0x00,0xe5,0x10,0x24, +0x00,0x02,0x25,0x82,0x10,0x83,0x00,0x0d,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, +0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, +0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, +0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x8c,0x69,0x00,0x00, +0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a, +0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0x80,0x08,0x00,0x0c,0xc0, +0x00,0xc2,0x10,0x24,0x97,0x82,0xc5,0x4a,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b, +0x10,0x40,0x00,0x75,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, +0x8c,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xc8,0x00,0x7f,0x2d,0x02,0x00,0x32, +0x10,0x40,0xfe,0xc4,0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x2b,0x24,0x02,0xff,0x80, +0x00,0xc2,0x10,0x24,0x25,0x08,0x00,0x01,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0, +0x00,0x48,0x30,0x25,0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, +0x34,0x84,0x18,0xb0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a, +0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0, +0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, +0x08,0x00,0x0b,0xf9,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10, +0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x03, +0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82,0x10,0x83,0x00,0x0d,0x3c,0x02,0xff,0x3f, +0x34,0x42,0xff,0xff,0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a, +0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58, +0x8c,0x69,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x01,0x22,0x48,0x24, +0x3c,0x04,0xb0,0x0a,0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0x80, +0x08,0x00,0x0d,0x39,0x00,0xc2,0x10,0x24,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, +0x8c,0x46,0x00,0x00,0x24,0x02,0x00,0x20,0x30,0xc8,0x00,0x7f,0x15,0x02,0xfe,0x51, +0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x58,0x8c,0x49,0x00,0x00, +0x3c,0x04,0xb0,0x0a,0x34,0x84,0x14,0x58,0x35,0x29,0x40,0x00,0xac,0x49,0x00,0x00, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb0,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb0,0x8c,0x47,0x00,0x00, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb8,0x3c,0x05,0xb0,0x0a,0x24,0x02,0xff,0xff, +0xac,0x62,0x00,0x00,0x34,0xa5,0x14,0xb8,0x00,0x07,0x1e,0x02,0x24,0x04,0x00,0x01, +0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x34,0x42,0x04,0xb8,0x8c,0x47,0x00,0x00,0x00,0x03,0x1a,0x00,0x30,0xe2,0x00,0xff, +0x00,0x62,0x18,0x25,0x2c,0x62,0x00,0x04,0x10,0x40,0x00,0x3a,0x2c,0x62,0x00,0x11, +0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, +0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00, +0x24,0x02,0x00,0x03,0x00,0x07,0x1d,0x82,0x30,0x64,0x00,0x03,0x10,0x82,0x00,0x1a, +0x3c,0x02,0xff,0x3f,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x3c,0x03,0xb0,0x0a, +0x34,0x63,0x04,0x58,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a,0xac,0x69,0x00,0x00, +0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x35,0x29,0x80,0x00,0x34,0x42,0x04,0x58, +0x3c,0x04,0xb0,0x0a,0xac,0x49,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, +0x08,0x00,0x0b,0xf9,0x00,0x00,0x00,0x00,0x34,0x42,0xff,0xff,0x3c,0x03,0x00,0x80, +0x00,0xe2,0x10,0x24,0x00,0x43,0x38,0x25,0x3c,0x03,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, +0xac,0x27,0x04,0x10,0x34,0x63,0x14,0x10,0x24,0x04,0x00,0x01,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0d,0xef, +0x34,0x42,0x3f,0xff,0x14,0x40,0xff,0xd8,0x3c,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a, +0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0, +0x24,0x03,0x00,0x02,0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82,0x14,0x83,0xff,0xc6, +0x3c,0x02,0xff,0xff,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xe2,0x10,0x24, +0x00,0x45,0x38,0x25,0x3c,0x03,0xb0,0x0a,0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10, +0x34,0x63,0x14,0x10,0x24,0x04,0x00,0x01,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x44,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0d,0xef,0x34,0x42,0x3f,0xff, +0x10,0x82,0x00,0x03,0x3c,0x03,0xb0,0x0a,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x34,0x63,0x1a,0x00,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, +0xa7,0x80,0xc5,0x40,0xa7,0x80,0xc5,0x42,0xa7,0x80,0xc5,0x44,0xa7,0x80,0xc5,0x46, +0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x0a,0x00,0x8c,0x66,0x00,0x00, +0x3c,0x02,0x08,0x00,0x3c,0x04,0xb0,0x0a,0x00,0xc2,0x10,0x25,0xac,0x62,0x00,0x00, +0x34,0x84,0x1a,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x3c,0x02,0xf7,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x42,0xff,0xff, +0x34,0x63,0x0a,0x00,0x00,0xc2,0x10,0x24,0x3c,0x04,0xb0,0x0a,0xac,0x62,0x00,0x00, +0x34,0x84,0x1a,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x3a,0x00,0x00,0x00,0x00, +0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,0x3c,0x02,0xb0,0x0a, +0x00,0x82,0x20,0x21,0x3c,0x06,0x05,0xf5,0xac,0x85,0x00,0x00,0x24,0x07,0x00,0x01, +0x00,0x00,0x28,0x21,0x34,0xc6,0xe0,0xff,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01, +0x10,0x47,0x00,0x03,0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40, +0x3c,0x02,0xb0,0x0a,0x00,0x83,0x20,0x23,0x00,0x82,0x20,0x21,0x3c,0x06,0x05,0xf5, +0x24,0x02,0xff,0xff,0xac,0x82,0x10,0x00,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x01, +0x34,0xc6,0xe0,0xff,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03, +0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x24,0x42,0x3a,0x28,0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03, +0xac,0xa2,0x00,0x00,0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04, +0xa0,0x80,0x00,0x05,0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08, +0xa0,0x80,0x00,0x09,0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13, +0xa0,0x80,0x00,0x49,0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e, +0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00, +0xa4,0x82,0x00,0x44,0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28, +0xac,0x80,0x00,0x2c,0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38, +0xac,0x80,0x00,0x3c,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c, +0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18, +0x3c,0x02,0x80,0x00,0x24,0x42,0x3a,0xbc,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08, +0x80,0x82,0x00,0x13,0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00, +0x30,0x63,0x00,0x7e,0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00, +0x3c,0x05,0xb0,0x05,0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05, +0x3c,0x08,0xb0,0x05,0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21, +0x34,0xe7,0x04,0x24,0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20, +0xac,0xe6,0x00,0x00,0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00, +0x27,0xbd,0xff,0xa8,0x00,0x07,0x60,0x80,0x27,0x82,0xbd,0x40,0xaf,0xb7,0x00,0x4c, +0xaf,0xb6,0x00,0x48,0xaf,0xb4,0x00,0x40,0xaf,0xb3,0x00,0x3c,0xaf,0xbf,0x00,0x54, +0xaf,0xbe,0x00,0x50,0xaf,0xb5,0x00,0x44,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34, +0xaf,0xb0,0x00,0x30,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21, +0x3c,0x02,0x80,0x00,0x94,0x71,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20, +0x24,0x42,0x3b,0x50,0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28, +0x90,0x67,0x00,0x00,0x00,0x11,0xa0,0xc0,0x02,0x91,0x18,0x21,0x27,0x82,0x99,0x44, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00, +0x28,0xc2,0x00,0x03,0x00,0xc0,0x98,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xb4,0x03, +0x8c,0x68,0x00,0x18,0x02,0x80,0x58,0x21,0x10,0x40,0x01,0x79,0x00,0x07,0xbe,0x03, +0x00,0xd7,0x10,0x07,0x30,0x57,0x00,0x01,0x01,0x71,0x10,0x21,0x27,0x83,0x99,0x48, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00, +0x8d,0x02,0x00,0x04,0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x1c, +0x11,0xa0,0x01,0x69,0xaf,0xa3,0x00,0x18,0x27,0x82,0xbd,0x40,0x01,0x82,0x10,0x21, +0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x63,0x00,0x04,0x14,0x60,0x00,0x12,0x00,0x00,0xa8,0x21,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x01,0x46,0x90,0x43,0x00,0x00,0x2a,0x64,0x00,0x04,0x10,0x80,0x01,0x4e, +0x30,0x65,0x00,0x01,0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x62,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21, +0x12,0xe0,0x00,0x03,0x38,0xf5,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf5,0x00,0x01, +0x01,0x71,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x83,0x99,0x50,0x00,0xc3,0x48,0x21, +0x91,0x25,0x00,0x00,0x8f,0xa3,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x03,0x11,0xc3, +0x2c,0xa3,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x03,0xa8,0x0b,0x12,0xa0,0x00,0xd2, +0xaf,0xa2,0x00,0x20,0x93,0x90,0xc5,0x2a,0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f, +0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xba,0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10, +0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b,0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04, +0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b,0x01,0x71,0x10,0x21,0x27,0x85,0xc4,0x5c, +0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40, +0x01,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x48,0x00,0x43,0x10,0x21, +0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0x9f,0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05, +0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01,0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e, +0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00,0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0, +0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00,0x24,0x16,0x00,0x0e,0x24,0x11,0x01,0x06, +0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00,0x27,0x82,0xbd,0x40,0x01,0x82,0x10,0x21, +0x8c,0x43,0x00,0x00,0x24,0x1e,0x00,0x01,0x00,0x11,0xa0,0xc0,0x90,0x62,0x00,0x16, +0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa5,0x00,0x1c, +0x00,0x10,0x32,0x00,0x00,0x05,0x13,0x43,0x30,0x47,0x00,0x01,0x8f,0xa2,0x00,0x18, +0x8f,0xa5,0x00,0x20,0x00,0x02,0x22,0x02,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0, +0x30,0x84,0x07,0xff,0x00,0x47,0x10,0x21,0x00,0x1e,0x2a,0x80,0x00,0x43,0x10,0x21, +0x00,0x04,0x24,0x80,0x02,0x25,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21, +0x00,0x16,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x60,0x00,0x29, +0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05, +0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28, +0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01, +0x02,0x63,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21, +0x12,0xe0,0x00,0x03,0x02,0x91,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0x91,0x10,0x21, +0x27,0x83,0x99,0x48,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04, +0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x60,0x28,0x21,0x02,0xa0,0x38,0x21, +0x0c,0x00,0x00,0x70,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c, +0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x3d,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x02,0x12,0x62,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03, +0x12,0x62,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x62,0x00,0x19, +0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x12,0x16,0x62,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05, +0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00, +0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x0f,0x86,0x24,0x02,0x00,0x20, +0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, +0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x0f,0x86, +0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05, +0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80, +0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05, +0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28, +0x24,0x02,0x00,0x08,0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10, +0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14, +0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00, +0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, +0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x0f,0x86, +0xac,0x65,0x00,0x00,0x24,0x16,0x00,0x14,0x08,0x00,0x0f,0x5e,0x24,0x11,0x01,0x02, +0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c, +0x26,0x02,0x00,0x04,0x27,0x85,0xc4,0x5c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, +0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, +0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04, +0x08,0x00,0x0f,0x48,0x00,0x46,0x80,0x0a,0x27,0x82,0xbd,0x40,0x01,0x82,0x20,0x21, +0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x99,0x60,0x00,0xc2,0x10,0x21, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x12,0x00,0x00,0x00,0x00, +0x90,0xe3,0x00,0x16,0x27,0x82,0x99,0x48,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20, +0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x16,0x42, +0x30,0x52,0x00,0x3f,0x90,0x83,0x00,0x16,0x24,0x16,0x00,0x18,0x24,0x11,0x01,0x03, +0x30,0x63,0x00,0xfb,0x24,0x1e,0x00,0x01,0x24,0x14,0x08,0x18,0x08,0x00,0x0f,0x67, +0xa0,0x83,0x00,0x16,0x8d,0x02,0x00,0x04,0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10, +0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f,0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e,0x27,0x83,0x99,0x58,0x00,0xc3,0x18,0x21, +0x80,0x64,0x00,0x00,0x27,0x83,0xbe,0xb8,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24, +0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25,0x27,0x85,0xbd,0x40,0x01,0x85,0x28,0x21, +0x8c,0xa6,0x00,0x00,0x01,0x71,0x10,0x21,0x27,0x83,0x99,0x50,0x90,0xc4,0x00,0x16, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00, +0xa0,0xc4,0x00,0x16,0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0x80,0xde,0x00,0x12, +0x90,0x62,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06, +0xa0,0x62,0x00,0x16,0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04, +0x15,0xc2,0xff,0x16,0x00,0x00,0x00,0x00,0x32,0x42,0x00,0x02,0x2e,0x03,0x00,0x0c, +0x14,0x60,0x00,0x0f,0x00,0x02,0x20,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10, +0x00,0x04,0x19,0x00,0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xe0, +0xa0,0x43,0x00,0x00,0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x01,0xfb, +0xaf,0xaf,0x00,0x28,0x8f,0xaf,0x00,0x28,0x08,0x00,0x0f,0x67,0x00,0x00,0x00,0x00, +0x08,0x00,0x10,0x5a,0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xb2, +0x00,0x00,0x00,0x00,0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x62,0x10,0x26, +0x08,0x00,0x0f,0x1e,0x00,0x02,0x28,0x0b,0x08,0x00,0x0f,0x24,0x00,0x00,0xa8,0x21, +0x24,0x02,0x00,0x10,0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x85, +0x00,0x07,0x17,0x83,0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x83,0x00,0x07,0x17,0x43, +0x08,0x00,0x0e,0xfe,0x30,0x57,0x00,0x01,0x08,0x00,0x0e,0xfe,0x00,0x07,0xbf,0xc2, +0x00,0x04,0x10,0x40,0x27,0x83,0x86,0x30,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21, +0x94,0x44,0x00,0x00,0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a, +0x00,0x86,0x00,0x18,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, +0x24,0x42,0x42,0x00,0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12, +0x00,0x04,0x22,0x42,0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b, +0x24,0x82,0x00,0x60,0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03, +0x34,0x63,0x01,0x00,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, +0x00,0x44,0x20,0x04,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28, +0x24,0x83,0x00,0x24,0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14, +0x00,0x60,0x20,0x21,0x08,0x00,0x10,0x97,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x42,0x9c, +0x00,0x80,0x80,0x21,0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37, +0x34,0x84,0x01,0x10,0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21, +0x8c,0x87,0x00,0x00,0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f, +0x34,0x42,0xf0,0x00,0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08, +0x32,0x02,0x00,0x07,0x27,0x83,0x86,0xe0,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00, +0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21, +0x32,0x02,0x00,0x0f,0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01, +0x14,0x40,0x00,0x07,0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xbd,0x90, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c, +0x14,0x40,0x00,0x05,0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00, +0x00,0x82,0x10,0x21,0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20, +0x24,0x06,0x00,0x0e,0x0c,0x00,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04, +0x24,0x02,0x00,0x10,0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01, +0x14,0x60,0x00,0x02,0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff, +0x00,0xc5,0x10,0x21,0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00, +0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c, +0x32,0x02,0x00,0x07,0x27,0x83,0x86,0xd8,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, +0x08,0x00,0x10,0xc5,0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80, +0x27,0x82,0xbd,0x40,0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c, +0xaf,0xbf,0x00,0x44,0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30, +0xaf,0xb2,0x00,0x28,0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21, +0x8c,0xe6,0x00,0x00,0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03, +0x34,0xa5,0x00,0x20,0x24,0x42,0x43,0xf8,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00, +0xa0,0xc3,0x00,0x12,0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16, +0xa4,0xc3,0x00,0x14,0x27,0x83,0x99,0x40,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16, +0x8c,0xe8,0x00,0x00,0xaf,0xa4,0x00,0x48,0x27,0x82,0x99,0x44,0x95,0x11,0x00,0x14, +0x00,0x00,0x00,0x00,0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80, +0x00,0x82,0x10,0x21,0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06, +0x8e,0x45,0x00,0x08,0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82, +0x00,0x06,0x31,0x42,0x27,0x82,0x99,0x50,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01, +0x00,0x82,0x20,0x21,0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18, +0xaf,0xa6,0x00,0x1c,0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06, +0x14,0xe0,0x00,0x47,0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x44,0x02,0x71,0x10,0x21,0x93,0x90,0xc5,0x29,0x00,0x00,0x00,0x00, +0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40, +0x00,0x43,0x10,0x21,0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04, +0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, +0x00,0x80,0x80,0x21,0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21, +0x02,0xc0,0x28,0x21,0x0c,0x00,0x10,0x80,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21, +0x00,0x03,0x88,0x80,0x00,0x40,0xa0,0x21,0x27,0x82,0x99,0x60,0x02,0x22,0x10,0x21, +0x8c,0x44,0x00,0x00,0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21, +0x00,0x04,0x25,0xc2,0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40, +0x03,0xc4,0x20,0x24,0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03, +0x35,0x08,0x00,0x28,0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48, +0x27,0x82,0x99,0x48,0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21, +0xa4,0x54,0x00,0x04,0x00,0xc0,0x38,0x21,0x0c,0x00,0x0e,0xd4,0xad,0x03,0x00,0x00, +0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c, +0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c, +0x8f,0xa6,0x00,0x18,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14,0x08,0x00,0x11,0x63,0x02,0x82,0xa0,0x21, +0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, +0x90,0x50,0x00,0x00,0x08,0x00,0x11,0x4f,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8, +0xaf,0xb1,0x00,0x24,0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x46,0x1c,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c, +0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c, +0x8f,0xb5,0x00,0x58,0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28, +0xaf,0xb0,0x00,0x20,0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21, +0x00,0x00,0xb8,0x21,0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xbd,0x40, +0x00,0x07,0x10,0x80,0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80, +0x00,0x65,0x18,0x21,0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03, +0x14,0x40,0x00,0x2d,0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05, +0x34,0x63,0x01,0x44,0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00, +0x8f,0xa3,0x00,0x4c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01, +0x10,0x40,0x00,0x04,0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09, +0x24,0x05,0x00,0x14,0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc, +0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x48,0x0c,0x00,0x0e,0xaf,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01, +0x08,0x00,0x11,0xc9,0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01, +0x10,0xc2,0x00,0x17,0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21, +0x12,0x20,0xff,0xed,0x02,0x20,0x10,0x21,0x27,0x83,0xbd,0x40,0x00,0x17,0x10,0x80, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28, +0x80,0x86,0x00,0x12,0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03, +0x00,0x46,0x10,0x21,0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21, +0x0c,0x00,0x0e,0xd4,0xac,0x62,0x00,0x00,0x08,0x00,0x11,0xc9,0xaf,0xd1,0x00,0x40, +0x96,0x74,0x00,0x1a,0x08,0x00,0x11,0xdc,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x01,0x08,0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x26,0xb7, +0x02,0x00,0x28,0x21,0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21, +0x0c,0x00,0x26,0xb7,0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00, +0x10,0x80,0x00,0xed,0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01, +0x96,0x63,0x00,0x14,0x96,0x44,0x00,0x14,0x27,0x85,0x99,0x40,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0, +0x8c,0x46,0x00,0x08,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21, +0x00,0x06,0x17,0x02,0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6, +0x00,0x03,0x17,0x02,0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b, +0x24,0x11,0x00,0x02,0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01, +0x12,0x22,0x00,0x5a,0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00, +0x96,0x49,0x00,0x14,0x27,0x82,0x99,0x44,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0, +0x01,0x49,0x18,0x21,0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18, +0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04, +0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01, +0x14,0x40,0x00,0x41,0x30,0x87,0x00,0x01,0x27,0x82,0x99,0x58,0x01,0x02,0x10,0x21, +0x80,0x44,0x00,0x00,0x27,0x82,0xbe,0xb8,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23, +0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21, +0x90,0x45,0x00,0x05,0x27,0x84,0xbd,0xe0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00, +0x10,0xa0,0x00,0x2b,0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21, +0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03, +0xa0,0x22,0x00,0xe1,0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40, +0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04, +0x01,0x49,0x10,0x21,0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08, +0x12,0x02,0x00,0x0b,0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21, +0x0c,0x00,0x27,0x33,0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16, +0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x25,0x08,0x00,0x11,0xdc,0xa2,0x42,0x00,0x16, +0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x26,0xe4,0xaf,0xa0,0x00,0x10, +0x08,0x00,0x12,0x5f,0x30,0x54,0xff,0xff,0x08,0x00,0x12,0x47,0x00,0x60,0x10,0x21, +0x14,0x80,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, +0x08,0x00,0x12,0x47,0x24,0x42,0x00,0x04,0x27,0x82,0x99,0x50,0x01,0x02,0x10,0x21, +0x90,0x43,0x00,0x00,0x08,0x00,0x12,0x57,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14, +0x02,0xc0,0xb8,0x21,0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21, +0x00,0x03,0x40,0x80,0x00,0x40,0x50,0x21,0x27,0x82,0x99,0x44,0x01,0x02,0x10,0x21, +0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c, +0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10, +0x30,0x66,0x00,0x01,0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x99,0x58, +0x01,0x02,0x10,0x21,0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00, +0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80, +0x27,0x83,0xbe,0xb0,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f, +0x00,0x00,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x99,0x50, +0x00,0x85,0x10,0x21,0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42, +0x01,0x49,0x10,0x21,0x27,0x82,0x99,0x58,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00, +0x27,0x82,0xbe,0xb8,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80, +0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05, +0x27,0x84,0xbd,0xe0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c, +0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00, +0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1, +0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21, +0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21, +0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21, +0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08, +0x10,0x82,0x00,0x0c,0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21, +0x0c,0x00,0x27,0x33,0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff, +0x92,0x62,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x11,0xdc, +0xa2,0x62,0x00,0x16,0x02,0x60,0x20,0x21,0x0c,0x00,0x26,0xe4,0xaf,0xa0,0x00,0x10, +0x08,0x00,0x12,0xce,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0xb6,0x00,0x60,0x10,0x21, +0x14,0x80,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, +0x08,0x00,0x12,0xb6,0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21, +0x90,0x43,0x00,0x00,0x08,0x00,0x12,0xc6,0xa0,0x43,0x00,0x03,0x27,0x85,0x99,0x50, +0x08,0x00,0x12,0xe2,0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26, +0x08,0x00,0x12,0x17,0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01, +0x08,0x00,0x12,0x1c,0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x27,0xbd,0xff,0xd0,0x24,0x42,0x4b,0xc8,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05, +0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28, +0xaf,0xb0,0x00,0x18,0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00, +0x00,0x80,0x90,0x21,0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10, +0x12,0x22,0x00,0xcf,0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1, +0x24,0x02,0x00,0x12,0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad, +0xae,0x43,0x00,0x40,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00, +0x3c,0x03,0x00,0x02,0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43, +0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x92,0x00,0x00,0x00,0x00,0x93,0x83,0x94,0x51,0x00,0x00,0x00,0x00, +0x30,0x62,0x00,0x02,0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3, +0x14,0x40,0x00,0x86,0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21, +0x26,0x22,0x00,0x01,0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb, +0x24,0x03,0x00,0x02,0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03, +0x10,0x40,0x00,0x58,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b, +0x02,0x40,0x20,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21, +0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x30,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07, +0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05, +0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec, +0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05, +0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05, +0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc, +0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03, +0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05, +0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc, +0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02, +0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05, +0x8c,0x42,0x02,0x2c,0x08,0x00,0x13,0x38,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04, +0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06, +0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31, +0xae,0x42,0x00,0x24,0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08, +0x16,0x62,0xff,0xa8,0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30, +0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x11,0x87, +0xaf,0xa2,0x00,0x14,0x08,0x00,0x13,0x31,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06, +0x8e,0x43,0x00,0x2c,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21, +0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31, +0xae,0x42,0x00,0x2c,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21, +0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87, +0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x57, +0x24,0x04,0x00,0x01,0x08,0x00,0x13,0x22,0x00,0x00,0x00,0x00,0x8f,0x84,0xbd,0x80, +0xae,0x40,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x00,0x00,0x00,0x00, +0x93,0x83,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69, +0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x08,0x00,0x13,0x1a, +0x00,0x00,0x00,0x00,0x02,0x40,0x20,0x21,0x0c,0x00,0x10,0xfe,0x02,0x20,0x28,0x21, +0x08,0x00,0x13,0x0e,0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0x4a,0x00,0x00,0x00,0x00,0x8f,0x82,0xbd,0x88,0x00,0x00,0x00,0x00, +0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b, +0xae,0x43,0x00,0x3c,0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d, +0x24,0x02,0x00,0x12,0x8f,0x82,0xbd,0x84,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a, +0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b,0xae,0x43,0x00,0x38, +0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11, +0x8f,0x82,0xbd,0x80,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00, +0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x4f,0x7c, +0x3c,0x08,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00, +0xaf,0xbf,0x00,0x18,0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21, +0x24,0x11,0x00,0x0a,0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a, +0x30,0x63,0x00,0x01,0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40, +0x02,0x20,0x40,0x21,0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x48, +0x00,0x43,0x10,0x21,0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06, +0x02,0x23,0x80,0x21,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x10,0x80,0x00,0x00,0x00,0x00, +0x02,0x11,0x18,0x21,0x08,0x00,0x14,0x01,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0, +0xaf,0xbf,0x00,0x28,0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, +0xaf,0xb5,0x00,0x24,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c, +0x3c,0x06,0xb0,0x03,0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, +0x00,0x03,0x18,0x80,0x27,0x82,0x99,0x44,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18, +0x3c,0x02,0x80,0x00,0x24,0x42,0x50,0x2c,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08, +0x27,0x82,0x99,0x48,0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43, +0x32,0x10,0x00,0x01,0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21, +0x02,0x20,0x28,0x21,0x0c,0x00,0x13,0xdf,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21, +0x02,0x00,0x28,0x21,0x24,0x06,0x00,0x14,0x0c,0x00,0x10,0x80,0x00,0x40,0xa0,0x21, +0x86,0x43,0x00,0x0c,0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, +0x80,0x43,0x00,0x06,0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00, +0x24,0x64,0x00,0x03,0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09, +0x00,0x03,0x18,0x80,0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14, +0x34,0xe7,0x01,0x20,0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11, +0x02,0xa3,0xa8,0x21,0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00, +0x00,0x03,0x1c,0x02,0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c, +0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28, +0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x30,0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00, +0x8e,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c, +0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21, +0xac,0xe3,0x00,0x00,0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02, +0x08,0x00,0x14,0x53,0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c, +0x00,0x80,0x90,0x21,0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21, +0x00,0x04,0x20,0x80,0x27,0x82,0x99,0x44,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18, +0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x51,0xa8,0x27,0x83,0x99,0x48, +0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07, +0x34,0x42,0x01,0x00,0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04, +0x24,0x02,0x00,0x10,0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43, +0x30,0x84,0x00,0x01,0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40, +0x02,0x00,0x10,0x21,0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x10,0x80, +0x30,0x50,0x00,0xff,0x86,0x44,0x00,0x0c,0x27,0x85,0x99,0x50,0x3c,0x06,0xb0,0x09, +0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21, +0x80,0x64,0x00,0x06,0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03, +0x28,0x83,0x00,0x00,0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80, +0xa4,0xc2,0x00,0x00,0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x01,0x10,0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x01,0x14,0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08, +0x3c,0x06,0xb0,0x09,0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21, +0x34,0xc6,0x01,0x20,0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09, +0x34,0xa5,0x01,0x24,0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a, +0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04, +0x30,0x42,0xff,0xff,0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x99,0x58, +0x8f,0xbf,0x00,0x1c,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00, +0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x53,0x34, +0x00,0x05,0x2c,0x43,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00, +0x10,0xa0,0x00,0x05,0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0xb6,0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c, +0x00,0x00,0x10,0x21,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09, +0x10,0x40,0x00,0x89,0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79, +0x2a,0x02,0x00,0x03,0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01, +0x12,0x02,0x00,0x5a,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08, +0x3c,0x03,0x80,0x00,0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11, +0x92,0x27,0x00,0x11,0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a, +0x24,0x02,0x00,0x12,0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xbd,0x40, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x94,0x83,0x00,0x14,0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x00,0x40,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03, +0xa2,0x23,0x00,0x10,0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff, +0x27,0x83,0xbd,0x40,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, +0x82,0x23,0x00,0x12,0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42, +0x30,0x42,0x00,0x01,0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18, +0xa2,0x23,0x00,0x12,0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01, +0x96,0x23,0x00,0x0c,0x27,0x84,0x99,0x50,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00, +0x3c,0x02,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00, +0x90,0x62,0x00,0x04,0xa2,0x20,0x00,0x15,0xa3,0x80,0x95,0x14,0x24,0x02,0x00,0x01, +0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, +0x0c,0x00,0x14,0x6a,0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x15,0x1a, +0x00,0x07,0x16,0x00,0x0c,0x00,0x14,0x0b,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c, +0x27,0x84,0x99,0x48,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x44,0x20,0x21,0x90,0x85,0x00,0x07,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, +0xa2,0x25,0x00,0x13,0x90,0x83,0x00,0x07,0x08,0x00,0x15,0x32,0xa0,0x43,0x00,0x02, +0x92,0x26,0x00,0x0a,0x08,0x00,0x14,0xfb,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24, +0x00,0x00,0x00,0x00,0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07, +0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x14,0xee, +0xa2,0x22,0x00,0x04,0x08,0x00,0x15,0x4c,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b, +0x3c,0x02,0xb0,0x05,0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07, +0xa2,0x24,0x00,0x08,0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f, +0xae,0x20,0x00,0x2c,0x08,0x00,0x14,0xee,0xa2,0x22,0x00,0x06,0x08,0x00,0x15,0x5b, +0xa2,0x20,0x00,0x0a,0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01, +0x10,0x44,0x00,0x07,0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a, +0x92,0x22,0x00,0x2b,0xae,0x20,0x00,0x28,0x08,0x00,0x14,0xee,0xa2,0x22,0x00,0x05, +0x08,0x00,0x15,0x67,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41, +0x10,0x40,0x00,0x09,0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b, +0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08, +0x08,0x00,0x14,0xee,0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x10,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x14,0xee, +0xae,0x20,0x00,0x34,0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08, +0x08,0x00,0x14,0xee,0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03, +0x24,0x03,0x00,0x01,0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02, +0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x14,0xee, +0xa2,0x22,0x00,0x07,0x08,0x00,0x15,0x8d,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xbd,0x80, +0xae,0x20,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x32,0x10,0x00,0xff, +0x08,0x00,0x14,0xdf,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x24,0x42,0x56,0x68,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15, +0x3c,0x06,0xb0,0x05,0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x95,0x14, +0x00,0x00,0x00,0x00,0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28, +0x8c,0x82,0x00,0x2c,0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43, +0x30,0x63,0x00,0x01,0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28, +0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28, +0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x27,0xbd,0xff,0xd8,0x34,0x63,0x00,0x20,0x24,0x42,0x56,0xf8,0xac,0x62,0x00,0x00, +0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a, +0x27,0x83,0xbd,0x40,0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21, +0x8c,0x50,0x00,0x00,0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04, +0xa2,0x20,0x00,0x15,0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00, +0x82,0x22,0x00,0x12,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00, +0xa2,0x20,0x00,0x12,0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x60, +0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x63,0x00,0xdf,0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00, +0x14,0x60,0x00,0x45,0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04, +0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a, +0xa2,0x02,0x00,0x17,0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4, +0x10,0x60,0x00,0x03,0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16, +0x11,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00, +0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00, +0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x28,0x96,0x02,0x00,0x00,0x08,0x00,0x16,0x09,0xa6,0x02,0x00,0x14, +0x92,0x07,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x15,0xf5,0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06, +0x27,0x86,0x99,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0, +0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80, +0x00,0x46,0x10,0x21,0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00, +0x00,0xc3,0x20,0x24,0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04, +0x00,0x00,0x18,0x21,0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b, +0x08,0x00,0x15,0xf5,0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b, +0x08,0x00,0x16,0x29,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02, +0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00, +0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x07,0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x06, +0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x69,0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09, +0x92,0x25,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04, +0x10,0x40,0x00,0x3b,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, +0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27, +0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x99,0x44, +0x00,0xa3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01, +0x93,0x82,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a, +0x24,0x05,0x00,0x24,0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x23,0x34, +0x02,0x00,0x20,0x21,0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7, +0x08,0x00,0x15,0xe6,0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12, +0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x3c,0x04,0x00,0x80, +0x96,0x26,0x00,0x0c,0x08,0x00,0x16,0x66,0x00,0x06,0x2c,0x00,0x27,0x83,0x99,0x50, +0x27,0x82,0x99,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00, +0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x29,0x5e, +0xaf,0xa2,0x00,0x10,0x96,0x26,0x00,0x0c,0x08,0x00,0x16,0x60,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0xcd,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, +0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x16,0x4f,0x00,0xa2,0x10,0x07, +0x86,0x26,0x00,0x0c,0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78, +0x94,0x47,0x00,0x00,0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21, +0x3c,0x04,0xb0,0x09,0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x99,0x44, +0x00,0x02,0x10,0x80,0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18, +0xae,0x25,0x00,0x20,0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21, +0x0c,0x00,0x16,0xb6,0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c, +0x8e,0x27,0x00,0x20,0x02,0x20,0x20,0x21,0x0c,0x00,0x24,0x36,0xaf,0xa2,0x00,0x10, +0x08,0x00,0x15,0xe6,0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x15,0xe6, +0xa2,0x22,0x00,0x09,0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00, +0x08,0x00,0x15,0xe6,0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24, +0x00,0x80,0x70,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x5a,0xd8, +0xf1,0x43,0x00,0x06,0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21, +0xac,0x82,0x00,0x00,0x27,0x85,0x99,0x50,0x27,0x82,0x99,0x4f,0x27,0xbd,0xff,0xf8, +0x00,0x62,0x60,0x21,0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc, +0x00,0x00,0x78,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00, +0x80,0x48,0x00,0x04,0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x99,0x44, +0xa3,0xa7,0x00,0x00,0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff, +0x00,0x48,0x40,0x0b,0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06, +0x30,0x63,0x00,0x08,0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00, +0x27,0x82,0x99,0x58,0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50, +0x30,0xe5,0x00,0xff,0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24, +0x90,0x49,0x00,0x00,0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04, +0x10,0xa2,0x00,0x9d,0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c, +0x10,0x40,0x00,0x02,0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff, +0x00,0x04,0x10,0x40,0x27,0x83,0xc4,0x5c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21, +0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00, +0x10,0x60,0x00,0x02,0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00, +0x91,0x65,0x00,0x00,0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b, +0x10,0x40,0x00,0x0e,0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21, +0x30,0xa2,0x00,0x0f,0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21, +0x27,0x83,0xc4,0x5c,0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x05,0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80, +0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xbd,0xe8, +0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c, +0x14,0x60,0x00,0x06,0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21, +0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x17,0x17, +0xa1,0x82,0x00,0x00,0x8f,0x8d,0x87,0x70,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21, +0x00,0x06,0x74,0x82,0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03, +0x00,0xe0,0x10,0x21,0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff, +0xa3,0xa2,0x00,0x00,0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00, +0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23, +0x00,0x64,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xbd,0xe8, +0x00,0x44,0x10,0x21,0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00, +0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18, +0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10, +0x14,0x60,0x00,0x33,0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23,0x27,0x83,0xbe,0xb8,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00, +0x00,0x64,0xc0,0x24,0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f, +0x10,0x40,0x00,0x0f,0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x99,0x40, +0x00,0x44,0x10,0x21,0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41, +0x14,0x60,0x00,0x04,0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00, +0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21, +0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21, +0x24,0x42,0x00,0x04,0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21, +0x90,0x43,0x00,0x00,0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b, +0x14,0x60,0xff,0xad,0x30,0xe2,0x00,0xff,0x08,0x00,0x17,0x04,0x00,0x00,0x00,0x00, +0x08,0x00,0x17,0x65,0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00, +0x10,0x40,0xff,0x73,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xf2,0x00,0x00,0x00,0x00, +0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00, +0x08,0x00,0x16,0xd2,0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x5e,0x78,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00, +0x27,0xbd,0xff,0xc0,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, +0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c, +0xaf,0xbe,0x00,0x38,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c, +0x27,0x93,0x99,0x44,0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, +0x00,0x03,0x18,0x80,0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00, +0x34,0xa5,0x00,0x20,0x24,0x42,0x5e,0x90,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08, +0x27,0x95,0x99,0x50,0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21, +0x90,0x71,0x00,0x00,0x0c,0x00,0x16,0xb6,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21, +0x00,0x10,0x14,0x42,0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82, +0x02,0x80,0x28,0x21,0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c, +0x30,0x50,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x55,0x10,0x21,0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21, +0x8c,0xc7,0x00,0x18,0x27,0x83,0x99,0x40,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04, +0x84,0x46,0x00,0x06,0x00,0x03,0x19,0x42,0x0c,0x00,0x10,0x80,0x30,0x73,0x00,0x01, +0x00,0x40,0x88,0x21,0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10, +0x02,0x00,0x30,0x21,0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0, +0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x99,0x48,0x00,0x62,0x18,0x21, +0xa4,0x71,0x00,0x04,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, +0x86,0xc3,0x00,0x0c,0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06, +0x00,0x00,0x00,0x00,0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21, +0x00,0x07,0x38,0x43,0x00,0x07,0x38,0x40,0x0c,0x00,0x10,0xa7,0x03,0xc7,0x38,0x21, +0x08,0x00,0x17,0xe5,0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x27,0xbd,0xff,0xd0,0x34,0x63,0x00,0x20,0x24,0x42,0x60,0x18,0xaf,0xb2,0x00,0x20, +0xac,0x62,0x00,0x00,0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c, +0xaf,0xb0,0x00,0x18,0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04, +0x94,0x45,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0xbd,0x40,0x00,0x62,0x18,0x21, +0x30,0xa6,0xff,0xff,0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff, +0x00,0x06,0x32,0x02,0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12, +0x00,0x80,0x90,0x21,0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a, +0x10,0x40,0x00,0x14,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c, +0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x99,0x60,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12, +0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16, +0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x30,0x0c,0x00,0x17,0x9e,0x00,0x00,0x00,0x00,0x08,0x00,0x18,0x34, +0x00,0x00,0x00,0x00,0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21, +0x94,0x87,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00, +0x00,0x02,0x14,0x03,0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0, +0x00,0x62,0x18,0x21,0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x99,0x60, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x99,0x48, +0x00,0xa2,0x10,0x21,0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x99,0x50, +0x00,0x08,0x1d,0x02,0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01, +0x01,0x24,0x30,0x0b,0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02, +0x00,0x08,0x14,0x02,0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21, +0x15,0x40,0x00,0x11,0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, +0x30,0xa8,0x00,0xff,0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10, +0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, +0x01,0x02,0x10,0x04,0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c, +0x00,0x00,0x00,0x00,0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x27,0x84,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06, +0x00,0x03,0x1a,0x00,0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21, +0x94,0x82,0x00,0x00,0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06, +0x00,0x02,0x3c,0x03,0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21, +0x34,0xe2,0x08,0x00,0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00, +0x82,0x42,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, +0x86,0x43,0x00,0x0c,0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04, +0x92,0x23,0x00,0x16,0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x18,0x39, +0xa2,0x23,0x00,0x16,0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, +0xa0,0x44,0x00,0x05,0x86,0x45,0x00,0x0c,0x0c,0x00,0x26,0xae,0x02,0x20,0x20,0x21, +0x10,0x40,0x00,0x5a,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, +0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10, +0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, +0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00, +0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33, +0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x0c,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06, +0x08,0x00,0x18,0x34,0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x18,0x34, +0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03, +0x00,0x00,0x00,0x00,0x08,0x00,0x18,0xc3,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00, +0x96,0x25,0x00,0x06,0x27,0x86,0x99,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21, +0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21, +0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08, +0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24, +0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01, +0x00,0x85,0x18,0x2b,0x08,0x00,0x18,0xc3,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd, +0x00,0x85,0x18,0x2b,0x08,0x00,0x18,0xe6,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09, +0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca, +0x00,0x00,0x00,0x00,0x08,0x00,0x18,0xbe,0xa2,0x40,0x00,0x07,0x08,0x00,0x18,0xbe, +0xa2,0x40,0x00,0x06,0x08,0x00,0x18,0xbe,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe, +0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f, +0x24,0x02,0x00,0x80,0x08,0x00,0x18,0xb5,0x00,0xa2,0x10,0x07,0x0c,0x00,0x17,0xa4, +0x02,0x40,0x20,0x21,0x08,0x00,0x18,0x34,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99, +0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, +0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24, +0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff, +0x14,0xa0,0x00,0x80,0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c, +0x27,0x93,0x99,0x44,0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x28,0x80,0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00, +0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64, +0x00,0x00,0x30,0x21,0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18, +0x93,0x82,0x94,0x51,0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42, +0x14,0x40,0x00,0x4d,0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03, +0x0c,0x00,0x23,0x34,0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14, +0x30,0xc5,0xff,0xff,0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x0b,0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00, +0x8c,0x62,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x23,0x34, +0x30,0x50,0x00,0x01,0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff, +0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01, +0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05, +0x00,0x00,0x00,0x00,0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x18,0x33, +0x30,0x42,0x00,0xc3,0x96,0x22,0x00,0x00,0x08,0x00,0x19,0x5a,0xa6,0x22,0x00,0x14, +0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x19,0x55,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff, +0x00,0x05,0x18,0xc0,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21, +0x27,0x84,0x99,0x40,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80, +0x8c,0x45,0x00,0x08,0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00, +0x00,0xa2,0x38,0x24,0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04, +0x00,0x00,0x18,0x21,0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b, +0x08,0x00,0x19,0x55,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b, +0x08,0x00,0x19,0x79,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06, +0x00,0x00,0x28,0x12,0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49, +0x00,0x00,0x20,0x21,0x96,0x47,0x00,0x0c,0x08,0x00,0x19,0x37,0x00,0x07,0x2c,0x00, +0x27,0x83,0x99,0x50,0x27,0x82,0x99,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21, +0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01, +0x0c,0x00,0x29,0x5e,0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x19,0x2a, +0x00,0x07,0x1c,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0x1b, +0xa2,0x40,0x00,0x07,0x08,0x00,0x19,0x1b,0xa2,0x40,0x00,0x06,0x08,0x00,0x19,0x1b, +0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, +0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x19,0x12, +0x00,0xa2,0x10,0x07,0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, +0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x18,0x6d, +0x00,0xa2,0x10,0x07,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21, +0x8c,0x47,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x16,0xb6, +0x00,0x00,0x00,0x00,0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21, +0x00,0x00,0x38,0x21,0x0c,0x00,0x24,0x36,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00, +0x14,0x60,0xfe,0x6b,0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00, +0x14,0x60,0x00,0x40,0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04, +0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a, +0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10, +0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14, +0x92,0x22,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03, +0xa2,0x22,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50, +0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,0x08,0x00,0x18,0x33,0x34,0x42,0x00,0x02, +0x96,0x22,0x00,0x00,0x08,0x00,0x19,0xdc,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a, +0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0xd5, +0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x99,0x40, +0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, +0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, +0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24, +0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, +0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x19,0xd5, +0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x1a,0x04, +0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05, +0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0xcf, +0xa2,0x40,0x00,0x07,0x08,0x00,0x19,0xcf,0xa2,0x40,0x00,0x06,0x08,0x00,0x19,0xcf, +0xa2,0x40,0x00,0x05,0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08, +0x00,0xa2,0x18,0x24,0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02, +0x24,0x02,0x00,0x01,0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x10,0x60,0xff,0xfd,0x00,0xa4,0x10,0x2b,0x08,0x00,0x1a,0x1f,0x00,0x00,0x00,0x00, +0x30,0x82,0xff,0xff,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x99,0x50, +0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00, +0x3c,0x03,0xb0,0x00,0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08, +0x00,0x43,0x10,0x21,0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00, +0xaf,0xbf,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, +0x14,0x40,0x00,0x41,0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03, +0x8e,0x10,0x00,0x00,0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03, +0x32,0x02,0x00,0x20,0x08,0x00,0x1a,0x45,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17, +0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x67,0x00,0xff,0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x99,0x20, +0x00,0x40,0x30,0x21,0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01, +0x24,0x42,0x00,0x02,0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a, +0xa4,0xa2,0x00,0x08,0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xbd,0x40, +0x24,0x11,0x00,0x12,0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x20,0x9b, +0x00,0x00,0x00,0x00,0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24, +0x3c,0x01,0xb0,0x03,0x0c,0x00,0x1a,0xfd,0xac,0x30,0x00,0x00,0x08,0x00,0x1a,0x45, +0x00,0x00,0x00,0x00,0x8f,0x85,0x99,0x20,0x08,0x00,0x1a,0x5b,0x00,0x00,0x00,0x00, +0x24,0x02,0xff,0x95,0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30, +0x3c,0x01,0xb0,0x03,0xac,0x30,0x00,0x00,0x0c,0x00,0x1a,0xc6,0xac,0x60,0x00,0x00, +0x08,0x00,0x1a,0x45,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50, +0x08,0x00,0x1a,0x45,0xac,0x46,0x00,0x00,0xaf,0xa7,0x00,0x0c,0xaf,0xa4,0x00,0x00, +0xaf,0xa5,0x00,0x04,0xaf,0xa6,0x00,0x08,0x27,0xbd,0xfe,0xe8,0x00,0x80,0x28,0x21, +0x27,0xa6,0x01,0x1c,0x27,0xa4,0x00,0x10,0xaf,0xbf,0x01,0x14,0x0c,0x00,0x2e,0xe2, +0xaf,0xb0,0x01,0x10,0x00,0x40,0x80,0x21,0x0c,0x00,0x1a,0x95,0x27,0xa4,0x00,0x10, +0x02,0x00,0x10,0x21,0x8f,0xbf,0x01,0x14,0x8f,0xb0,0x01,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x01,0x18,0x93,0x83,0x87,0x6c,0x27,0xbd,0xff,0xe8,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x14,0x14,0x60,0x00,0x14,0x00,0x80,0x80,0x21,0x80,0x82,0x00,0x00, +0x90,0x84,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x00,0x04,0x26,0x00, +0x00,0x04,0x26,0x03,0x30,0x84,0xff,0xff,0x0c,0x00,0x1a,0xb5,0x26,0x10,0x00,0x01, +0x92,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x60,0x20,0x21, +0x08,0x00,0x1a,0x9f,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x14,0x43,0xff,0xef, +0x00,0x00,0x00,0x00,0x0c,0x00,0x05,0x52,0x00,0x00,0x00,0x00,0x08,0x00,0x1a,0x9f, +0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x48,0x84,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x0c,0x00,0x2e,0x4a, +0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01, +0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0x18, +0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00, +0x3c,0x09,0x80,0x01,0x25,0x29,0x0b,0x90,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00, +0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0x40,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, +0x3c,0x08,0xb0,0x06,0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00, +0x24,0x01,0x00,0x01,0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00, +0x25,0x4a,0x6b,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03, +0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00, +0xac,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0xa8, +0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00, +0x3c,0x03,0x80,0x01,0x24,0x63,0x0b,0x90,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00, +0x00,0x00,0x00,0x00,0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04, +0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0xfd, +0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0xf4,0x3c,0x0b,0xb0,0x03, +0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x0b,0x90,0x3c,0x03,0x80,0x01, +0x24,0x63,0x48,0x64,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08, +0xac,0x40,0x00,0x0c,0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9, +0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6c,0x34,0x3c,0x0b,0xb0,0x03, +0xad,0x6a,0x00,0x20,0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x95,0x20, +0x00,0x00,0x00,0x00,0x27,0x9d,0x99,0x08,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6c,0x58, +0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00, +0x00,0x00,0x00,0x00,0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00, +0x0c,0x00,0x1d,0x43,0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03, +0x00,0x04,0x30,0x40,0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0, +0x24,0x03,0xff,0xff,0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00, +0xaf,0xbf,0x00,0x18,0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01, +0x8c,0x82,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23, +0x3c,0x03,0xb0,0x0a,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x1b,0x7a, +0x02,0x20,0x20,0x21,0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21, +0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, +0x27,0xbd,0xff,0xd8,0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff, +0xaf,0xb3,0x00,0x1c,0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, +0x00,0xc0,0x98,0x21,0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03, +0x00,0x04,0x10,0x40,0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23, +0x3c,0x03,0xb0,0x0a,0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21, +0x24,0x05,0x00,0x01,0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd, +0x3c,0x02,0xb0,0x0a,0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00, +0x0c,0x00,0x1b,0x7a,0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24, +0x00,0x53,0x10,0x04,0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01, +0x8e,0x22,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x28,0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23, +0x3c,0x04,0xb0,0x0a,0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01, +0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00, +0x08,0x00,0x1b,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06, +0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01, +0x2c,0x62,0x00,0x20,0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21, +0x00,0xa0,0x80,0x21,0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24, +0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34, +0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00, +0x00,0x10,0x1c,0x00,0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05, +0x24,0x63,0x16,0x09,0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24, +0x3c,0x06,0xb0,0x05,0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00, +0x34,0xc6,0x02,0x28,0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24, +0xa0,0xc2,0x00,0x00,0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x01,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x01,0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c, +0xa0,0x80,0x00,0x50,0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08, +0xac,0x80,0x00,0x14,0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20, +0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30, +0xa0,0x80,0x00,0x31,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c, +0xac,0x82,0x00,0x10,0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08, +0xac,0x80,0x00,0x4c,0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00, +0x3c,0x02,0x12,0x00,0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b, +0x24,0x02,0xff,0x80,0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00, +0x3c,0x04,0xb0,0x03,0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01, +0x3c,0x06,0x45,0x67,0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04, +0x34,0xc6,0x89,0xaa,0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09, +0x3c,0x07,0x01,0x23,0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00, +0x27,0xbd,0xff,0xe0,0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09, +0xac,0x26,0x00,0x00,0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c, +0x24,0x02,0xcd,0xef,0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09, +0xad,0x67,0x00,0x00,0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18, +0xaf,0xb5,0x00,0x14,0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08, +0xaf,0xb1,0x00,0x04,0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22, +0x35,0xce,0x00,0x14,0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab, +0x3c,0x10,0xb0,0x09,0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09, +0x3c,0x14,0xb0,0x09,0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09, +0xad,0xa8,0x00,0x00,0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18, +0x35,0x29,0xcd,0xee,0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24, +0x36,0x73,0x00,0x28,0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34, +0x36,0xf7,0x00,0x38,0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00, +0xae,0x23,0x00,0x00,0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04, +0xae,0x63,0x00,0x00,0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c, +0xae,0xa3,0x00,0x00,0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14, +0xae,0xe3,0x00,0x00,0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c, +0xa7,0x03,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x70,0xcc,0xac,0x62,0x00,0x00, +0x8c,0x83,0x00,0x34,0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x04, +0x00,0x80,0x28,0x21,0x8c,0x86,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0xc2,0x00,0xf7, +0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x4f, +0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xdd,0xac,0xa2,0x00,0x2c, +0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0xdc,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xc2,0x00,0xca,0x00,0x00,0x00,0x00,0x8c,0xa7,0x00,0x04,0x24,0x02,0x00,0x02, +0x10,0xe2,0x00,0xc0,0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x09,0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05, +0xac,0xa2,0x00,0x14,0x24,0x02,0x00,0x01,0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08, +0xac,0xa0,0x00,0x14,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x61,0x00,0x19,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x05, +0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, +0x14,0x40,0x00,0x12,0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0c,0x3c,0x02,0xb0,0x03, +0x80,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,0x3c,0x02,0xb0,0x03, +0x14,0xc0,0x00,0x07,0x34,0x42,0x00,0x3f,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01, +0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x34,0x42,0x00,0x3f, +0x90,0x44,0x00,0x00,0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x7f,0x3c,0x03,0xb0,0x05, +0x80,0xa2,0x00,0x31,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06, +0x34,0x42,0x80,0x18,0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00, +0x00,0x64,0x18,0x24,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08, +0xac,0xa2,0x00,0x00,0x8c,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05, +0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24, +0x14,0x60,0xff,0xf2,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e, +0x00,0x00,0x00,0x00,0x8c,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10, +0x3c,0x02,0xb0,0x03,0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f, +0xac,0xa2,0x00,0x0c,0x90,0xa3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03, +0x08,0x00,0x1c,0x93,0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80, +0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03, +0x10,0x60,0x00,0x15,0xa0,0xa4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b, +0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x0c,0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04, +0xac,0xa2,0x00,0x10,0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d, +0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10, +0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x38,0x24,0x04,0x00,0x01, +0x10,0x64,0x00,0x2d,0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,0x00,0x00,0x00,0x00, +0x10,0x62,0x00,0x10,0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,0x00,0x00,0x00,0x00, +0xac,0xa0,0x00,0x38,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,0x10,0xe4,0x00,0x07, +0x24,0x02,0x00,0x03,0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x0b, +0xac,0xa3,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,0x08,0x00,0x1c,0xe5, +0xac,0xa2,0x00,0x00,0x10,0xe4,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x0c, +0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x38, +0x10,0xe4,0x00,0x0e,0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,0xac,0xa2,0x00,0x18, +0x24,0x02,0x00,0x02,0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,0x08,0x00,0x1c,0xee, +0x24,0x02,0x00,0x01,0x08,0x00,0x1c,0xfb,0xac,0xa0,0x00,0x00,0x24,0x02,0x00,0x03, +0x08,0x00,0x1c,0xfb,0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,0xac,0xa2,0x00,0x38, +0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x00,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x7d,0x3c,0x02,0xb0,0x05, +0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0x78, +0x00,0x00,0x00,0x00,0x10,0xc0,0xff,0x81,0x24,0x02,0x00,0x0e,0x08,0x00,0x1c,0x88, +0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3e, +0x24,0x02,0x00,0x04,0x08,0x00,0x1c,0x93,0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20, +0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x75,0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05, +0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01, +0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0x14,0x40,0xff,0x2b,0xa4,0xa3,0x00,0x20, +0x08,0x00,0x1c,0x93,0x24,0x02,0x00,0x06,0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0x66,0x24,0x02,0x00,0x05,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c, +0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x1b, +0xac,0xa2,0x00,0x1c,0x08,0x00,0x1c,0x93,0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05, +0x8c,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01, +0x14,0x40,0xff,0x56,0x24,0x02,0x00,0x06,0x08,0x00,0x1c,0x41,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x0a,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xc8, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x27,0x91,0x91,0xf8,0x27,0x90,0x8f,0x38, +0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24, +0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x0c,0x00,0x2d,0xd7,0xaf,0xb2,0x00,0x18, +0x0c,0x00,0x07,0x90,0x00,0x00,0x00,0x00,0xaf,0x91,0x95,0x10,0xaf,0x90,0x99,0x20, +0x48,0x02,0x00,0x00,0x0c,0x00,0x1b,0xd1,0x00,0x00,0x00,0x00,0x0c,0x00,0x1f,0xea, +0x02,0x00,0x20,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00, +0x3a,0x54,0xff,0xff,0xa3,0x83,0x99,0x24,0x0c,0x00,0x00,0x34,0x02,0x80,0xa8,0x21, +0x0c,0x00,0x1b,0xdc,0x02,0x80,0xb0,0x21,0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0xfa, +0x02,0x80,0xb8,0x21,0x93,0x84,0x80,0x10,0x0c,0x00,0x29,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x0e,0x8a,0x02,0x20,0x20,0x21,0x0c,0x00,0x01,0x39,0x00,0x00,0x00,0x00, +0x27,0x84,0x8d,0x20,0x0c,0x00,0x1b,0xba,0x00,0x00,0x00,0x00,0x27,0x82,0x92,0x2c, +0xaf,0x82,0x8d,0x60,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00, +0x34,0x84,0x01,0x68,0x24,0x02,0xc8,0x80,0x34,0xa5,0x01,0x40,0x24,0x03,0x00,0x0a, +0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, +0xaf,0x86,0x8d,0x18,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00,0x0c,0x00,0x07,0xa1, +0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05,0x0c,0x00,0x2d,0xef,0x34,0x84,0x00,0x04, +0x8f,0x83,0x8d,0x20,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x11,0x10,0x40,0xff,0xf7, +0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x08,0xac,0x00,0x43,0x10,0x21, +0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00, +0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0x2f,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, +0x0c,0x00,0x1c,0x33,0x00,0x00,0x00,0x00,0x93,0x83,0x88,0x6d,0x24,0x02,0x00,0x01, +0x10,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x54,0x00,0x00,0x00,0x00, +0x24,0x42,0x00,0x01,0xaf,0x82,0x8d,0x54,0x08,0x00,0x1d,0x83,0x00,0x00,0x00,0x00, +0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0xae,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x9e, +0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x78,0x0c,0x00,0x34,0x90,0x00,0x00,0x00,0x00, +0xa3,0x82,0x8d,0x51,0xaf,0x80,0x8d,0x20,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00, +0x27,0x84,0x8f,0x38,0x0c,0x00,0x21,0x26,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, +0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x24, +0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x4c,0x14,0x40,0x00,0x1e, +0x24,0x02,0x00,0x01,0x8f,0x84,0x8d,0x28,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x1d, +0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x34,0x14,0x40,0x00,0x13,0x24,0x02,0x00,0x01, +0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x01, +0x24,0x03,0x00,0x03,0xaf,0x82,0x8d,0x24,0xaf,0x83,0x8d,0x20,0x08,0x00,0x1d,0x9e, +0x00,0x00,0x00,0x00,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8d,0x40, +0x14,0x40,0xff,0xf3,0x24,0x02,0x00,0x01,0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0xad, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x3c,0x14,0x40,0xff,0xf6, +0x24,0x02,0x00,0x01,0x08,0x00,0x1d,0xc5,0x3c,0x03,0xb0,0x09,0x27,0x84,0x8f,0x38, +0x0c,0x00,0x22,0x9f,0x00,0x00,0x00,0x00,0x83,0x82,0x8d,0x50,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0xed,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x4c, +0x14,0x40,0xff,0xe5,0x24,0x02,0x00,0x02,0x8f,0x84,0x8d,0x28,0x24,0x02,0x00,0x01, +0x10,0x82,0x00,0x12,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x05,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x02,0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x04, +0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01, +0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8d,0x40,0x14,0x40,0xff,0xf4, +0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xde,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05, +0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, +0xaf,0x82,0x8d,0x3c,0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xfe, +0x24,0x02,0x00,0x02,0x27,0x84,0x91,0xf8,0x0c,0x00,0x12,0xf2,0x00,0x00,0x00,0x00, +0x8f,0x83,0x8d,0x24,0xaf,0x82,0x8d,0x3c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a, +0xaf,0x83,0x8d,0x24,0x14,0x40,0x00,0x1f,0x24,0x02,0x00,0x05,0x8f,0x82,0x92,0x38, +0xaf,0x80,0x8d,0x20,0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x8d,0x28, +0x93,0x82,0x92,0x46,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73,0x3c,0x02,0xb0,0x05, +0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,0x00,0x64,0x18,0x24, +0x10,0x60,0xff,0x6d,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa0,0x8c,0x43,0x00,0x00, +0x3c,0x04,0x80,0x00,0xaf,0x80,0x92,0x20,0x24,0x63,0x00,0x01,0xac,0x43,0x00,0x00, +0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,0xaf,0x80,0x92,0x1c,0xaf,0x80,0x92,0x24, +0xaf,0x80,0x92,0x28,0xaf,0x80,0x92,0x34,0xaf,0x80,0x92,0x2c,0x08,0x00,0x1d,0x9e, +0x00,0x00,0x00,0x00,0xaf,0x82,0x8d,0x20,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00, +0x83,0x82,0x8d,0x70,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20, +0xaf,0x82,0x8d,0x3c,0x8f,0x85,0x8d,0x3c,0x27,0x84,0x91,0xf8,0x0c,0x00,0x14,0xcd, +0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0xa3,0x82,0x8d,0x50,0xaf,0x80,0x8d,0x3c, +0x10,0x60,0xff,0x5c,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21, +0xa7,0x83,0x8d,0x40,0x10,0x40,0xff,0xe7,0x24,0x02,0x00,0x06,0x24,0x04,0x00,0x02, +0xaf,0x84,0x8d,0x28,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, +0x27,0x85,0x91,0xf8,0x0c,0x00,0x15,0x9a,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x44, +0xaf,0x80,0x8d,0x4c,0x14,0x40,0x00,0x1a,0x00,0x40,0x18,0x21,0x8f,0x82,0x8d,0x48, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x16,0x24,0x02,0x00,0x02,0x8f,0x83,0x8d,0x28, +0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x01,0x8f,0x83,0x8d,0x24, +0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x06, +0xaf,0x82,0x8d,0x20,0x24,0x04,0x00,0x03,0xaf,0x84,0x8d,0x28,0x08,0x00,0x1d,0x9e, +0x00,0x00,0x00,0x00,0x3c,0x02,0x40,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05, +0xac,0x22,0x00,0x00,0xaf,0x80,0x8d,0x20,0x08,0x00,0x1e,0x76,0x24,0x04,0x00,0x03, +0x10,0x60,0x00,0x10,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20,0x27,0x85,0x91,0xf8, +0x0c,0x00,0x15,0xbe,0x00,0x00,0x00,0x00,0x8f,0x83,0x8d,0x24,0x24,0x02,0x00,0x01, +0xa3,0x80,0x8d,0x50,0xaf,0x80,0x8d,0x28,0x10,0x62,0x00,0x02,0x24,0x02,0x00,0x03, +0x24,0x02,0x00,0x04,0xaf,0x82,0x8d,0x20,0xaf,0x80,0x8d,0x44,0x08,0x00,0x1d,0x9e, +0x00,0x00,0x00,0x00,0x83,0x82,0x8d,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04, +0x00,0x00,0x00,0x00,0x27,0x84,0x91,0xf8,0x0c,0x00,0x18,0x06,0x00,0x00,0x00,0x00, +0x8f,0x82,0x8d,0x24,0xa3,0x80,0x8d,0x50,0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x28, +0x14,0x40,0x00,0x02,0x24,0x02,0x00,0x02,0xaf,0x82,0x8d,0x24,0xaf,0x80,0x8d,0x48, +0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20,0x27,0x85,0x91,0xf8, +0x0c,0x00,0x15,0xbe,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x24,0xa3,0x80,0x8d,0x50, +0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x28,0x14,0x40,0xfe,0xf3,0x24,0x02,0x00,0x02, +0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x27,0x84,0x91,0xf8, +0x0c,0x00,0x18,0x06,0x00,0x00,0x00,0x00,0x08,0x00,0x1e,0xa6,0x00,0x00,0x00,0x00, +0x27,0x84,0x8d,0x78,0x0c,0x00,0x35,0x26,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xac, +0x00,0x00,0x00,0x00,0x0c,0x00,0x2b,0xc9,0x00,0x00,0x00,0x00,0x0c,0x00,0x32,0xa0, +0x00,0x00,0x00,0x00,0x0c,0x00,0x1f,0xdc,0x00,0x00,0x00,0x00,0x93,0x83,0xc5,0x58, +0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x1c,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08, +0x8c,0x44,0x00,0x00,0x8f,0x83,0xc5,0x50,0x8f,0x82,0xc5,0x54,0x00,0x83,0x18,0x23, +0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x14,0x2e,0xa3,0x00,0x01,0x2e,0x82,0x00,0x01, +0x00,0x43,0x10,0x25,0x2e,0xc4,0x00,0x01,0x00,0x44,0x10,0x25,0x2e,0xe3,0x00,0x01, +0x3c,0x05,0xb0,0x03,0x00,0x43,0x10,0x25,0x34,0xa5,0x01,0x18,0x8c,0xa3,0x00,0x00, +0x14,0x40,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x0b,0x7e, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0xc5,0x50,0x0c,0x00,0x01,0xe9,0x00,0x00,0x00,0x00, +0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x54,0x08,0x00,0x1d,0x83,0x00,0x00,0x00,0x00, +0x27,0x90,0xbd,0x40,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x20,0x9b,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6, +0x26,0x10,0x00,0x04,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x8d,0x18,0x00,0x04,0x19,0xc2, +0x00,0x02,0x11,0xc2,0x10,0x62,0xfe,0xb3,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02, +0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05,0xaf,0x84,0x8d,0x18,0x30,0x63,0x00,0xff, +0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21,0x36,0x52,0x02,0x2c,0x27,0x90,0xbd,0x40, +0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06,0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04, +0x00,0x00,0x00,0x00,0x8f,0x85,0x8d,0x18,0x0c,0x00,0x26,0x58,0x02,0x60,0x30,0x21, +0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0xfe,0x95, +0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01,0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec, +0x26,0x10,0x00,0x04,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x8f,0x84,0x8d,0x2c, +0x27,0x85,0x91,0xf8,0x0c,0x00,0x1f,0x6f,0x00,0x00,0x00,0x00,0x8f,0x83,0x8d,0x2c, +0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0x87,0x24,0x02,0x00,0x05,0x08,0x00,0x1e,0x41, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00, +0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x06,0x3c,0x02,0xb0,0x03,0x27,0x84,0x91,0xf8, +0x0c,0x00,0x2b,0xf0,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x05, +0x34,0x42,0x00,0x14,0x8c,0x44,0x00,0x00,0x0c,0x00,0x2c,0x0d,0x00,0x00,0x00,0x00, +0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x05,0x8f,0x82,0x92,0x2c,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xbd,0x80,0xaf,0x80,0x92,0x2c, +0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x00,0x00,0x00,0x00,0x93,0x82,0x94,0x51, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x8f,0x84,0xbd,0x80,0x0c,0x00,0x20,0x9b, +0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x90, +0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01,0x27,0x84,0x91,0xf8, +0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x0e,0x8a,0x00,0x00,0x00,0x00, +0x27,0x84,0x8f,0x38,0x0c,0x00,0x1f,0xea,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, +0x0c,0x00,0x1b,0xba,0x00,0x00,0x00,0x00,0x08,0x00,0x1f,0x56,0x00,0x00,0x00,0x00, +0x8f,0x82,0x92,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x18,0x21, +0x8f,0x82,0x8d,0x28,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00, +0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0, +0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0xc6,0x00,0x5f, +0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x5d, +0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01,0xa0,0xc3,0x00,0x00, +0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21,0x35,0x29,0x00,0x5e, +0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00,0x91,0x03,0x00,0x00, +0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfa, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c,0x24,0x05,0x0f,0x00, +0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x02,0x08,0x00,0x1f,0x90,0x3c,0x02,0xb0,0x03,0x24,0x04,0x08,0x8c, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04,0x24,0x05,0x00,0x0f, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30,0x24,0x06,0x00,0x03, +0x0c,0x00,0x1b,0x40,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21,0x24,0x05,0x00,0x14, +0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x08,0x00,0x1f,0x90,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x87,0x6d, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x87,0x6d, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x7f,0xa8,0x3c,0x04,0xb0,0x03, +0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8,0x8c,0x83,0x00,0x00, +0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21,0xa7,0x82,0x99,0x30, +0x27,0x88,0x99,0x40,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08,0x30,0xc2,0xff,0xff, +0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21,0x00,0x60,0x30,0x21, +0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21,0x00,0x87,0x20,0x21, +0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4,0xa4,0x43,0x00,0x00, +0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c,0x24,0x0a,0x00,0x02, +0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xbd,0x1c,0xac,0x43,0x00,0x00, +0xaf,0x84,0xbd,0x40,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18,0x94,0xc5,0x00,0x00, +0x8f,0x82,0xbd,0x40,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03,0x3c,0x03,0xb0,0x03, +0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xbd,0x44,0xa0,0x88,0x00,0x18, +0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x44,0x25,0xc4,0x00,0x54,0x25,0xc7,0x00,0x78, +0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x48,0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00, +0x8f,0x82,0xbd,0x48,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01,0xa0,0x45,0x00,0x21, +0xaf,0x87,0xbd,0x4c,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00,0x8f,0x82,0xbd,0x4c, +0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21,0xaf,0x88,0xbd,0x50, +0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x50,0x25,0xc4,0x00,0xc0, +0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x54,0xa0,0x89,0x00,0x18, +0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x54,0x25,0xc4,0x00,0xe4,0x34,0xc6,0x00,0x60, +0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x58,0xa0,0x80,0x00,0x18,0x94,0xc5,0x00,0x00, +0x8f,0x82,0xbd,0x58,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c,0xa0,0x45,0x00,0x21, +0xaf,0x83,0xbd,0x5c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00,0x8f,0x82,0xbd,0x5c, +0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21,0x25,0xc6,0x01,0x98, +0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04,0x25,0xcc,0x02,0x28, +0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0xaf,0x87,0xbd,0x60, +0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xbd,0x64,0xa0,0x80,0x00,0x18, +0xaf,0x85,0xbd,0x68,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xbd,0x6c,0xa0,0xc0,0x00,0x18, +0xaf,0x89,0xbd,0x70,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xbd,0x74,0xa1,0x40,0x00,0x18, +0xaf,0x8b,0xbd,0x78,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xbd,0x7c,0xa1,0x80,0x00,0x18, +0xaf,0x8d,0xbd,0x80,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xbd,0x80, +0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x11, +0xaf,0x85,0xbd,0x84,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00, +0x8f,0x82,0xbd,0x84,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21, +0x24,0x02,0x00,0x12,0xaf,0x85,0xbd,0x88,0x34,0x63,0x00,0x6c,0xa0,0xa2,0x00,0x18, +0x94,0x64,0x00,0x00,0x8f,0x82,0xbd,0x88,0x24,0x05,0xff,0xff,0x24,0x07,0x00,0x01, +0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xbd,0x40,0x8c,0x82,0x00,0x00, +0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x00, +0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00,0xa4,0x65,0x00,0x06, +0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x0c, +0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14,0xa0,0x67,0x00,0x17, +0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20,0x04,0xc1,0xff,0xe7, +0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x82,0x6c,0xac,0x43,0x00,0x00, +0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,0x10,0x40,0x00,0x56,0x00,0x00,0x70,0x21, +0x97,0x82,0x99,0x30,0x94,0x8a,0x00,0x0c,0x27,0x87,0x99,0x40,0x00,0x02,0x40,0xc0, +0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x90,0x8b,0x00,0x18, +0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,0x39,0x64,0x00,0x10,0x2c,0x84,0x00,0x01, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x34,0x85,0x00,0x02,0x39,0x63,0x00,0x11, +0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,0x39,0x64,0x00,0x12,0x00,0x02,0x10,0x80, +0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,0x94,0x49,0x00,0x04,0x34,0x64,0x00,0x20, +0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,0x39,0x62,0x00,0x01,0x00,0x82,0x18,0x0b, +0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,0x00,0xc9,0x28,0x21,0x39,0x62,0x00,0x02, +0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,0x00,0x05,0x28,0x80,0x3c,0x02,0xb0,0x08, +0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,0x01,0x02,0x40,0x21,0x34,0x03,0xff,0xff, +0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,0x2d,0x67,0x00,0x13,0xad,0x0a,0x00,0x00, +0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,0xa7,0x89,0x99,0x30,0x10,0xe0,0x00,0x0f, +0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,0x00,0x0b,0x10,0x80,0x24,0x63,0x08,0xf0, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x60,0x94,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x02,0x74,0x03,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,0x93,0x83,0x99,0x24,0x91,0x82,0x00,0x21, +0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,0x00,0x04,0x24,0x00,0x00,0x62,0x18,0x21, +0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,0x00,0x65,0x10,0x2a,0x00,0xa2,0x18,0x0a, +0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,0x24,0x05,0xff,0xff,0x00,0x64,0x18,0x25, +0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,0xa5,0x85,0x00,0x0e,0xa1,0x80,0x00,0x10, +0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x62,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf, +0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x66, +0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x38,0x3c,0x03,0xb0,0x03, +0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x6e,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf, +0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20, +0x24,0x42,0x84,0x34,0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00,0x00,0xa6,0x28,0x21, +0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21,0x10,0x40,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, +0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10,0x24,0xa2,0x00,0x01, +0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,0x08,0x00,0x21,0x1a,0x00,0x47,0x18,0x21, +0x08,0x00,0x21,0x1a,0x24,0xa3,0x00,0x50,0x27,0xbd,0xff,0xc8,0xaf,0xb4,0x00,0x20, +0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x30, +0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb0,0x00,0x10, +0x00,0x80,0x90,0x21,0x84,0x84,0x00,0x08,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0xa5,0x00,0x20,0x24,0x42,0x84,0x98,0x3c,0x03,0xb0,0x06,0x00,0x04,0x20,0x80, +0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x06,0xb0,0x06,0x8c,0x82,0x00,0x00, +0x34,0xc6,0x80,0x24,0x8c,0x88,0x00,0x00,0x8c,0xc4,0x00,0x00,0x96,0x45,0x00,0x08, +0x30,0x53,0xff,0xff,0x00,0x08,0x44,0x02,0x34,0x84,0x01,0x00,0x3c,0x02,0xb0,0x00, +0x00,0x08,0x18,0xc0,0x00,0x13,0x3a,0x00,0xac,0xc4,0x00,0x00,0x00,0xe2,0x38,0x21, +0xae,0x53,0x02,0xb8,0x00,0x68,0x18,0x21,0x24,0xa5,0x00,0x02,0x8c,0xf6,0x00,0x00, +0x30,0xa5,0x01,0xff,0x8c,0xf5,0x00,0x04,0x27,0x86,0x99,0x40,0x00,0x03,0x18,0x80, +0x00,0x13,0xa0,0xc0,0xa6,0x45,0x00,0x08,0x00,0x66,0x18,0x21,0x02,0x93,0x10,0x21, +0x00,0x02,0x48,0x80,0x94,0x65,0x00,0x00,0x01,0x26,0x30,0x21,0x24,0x02,0xff,0xff, +0x00,0x15,0x1a,0x02,0x27,0x84,0x99,0x50,0xa4,0xc2,0x00,0x02,0x30,0x63,0x00,0x1f, +0x24,0x02,0x00,0x10,0x01,0x24,0x20,0x21,0xa4,0xc8,0x00,0x04,0x8c,0xf0,0x00,0x08, +0xa6,0x43,0x00,0x06,0xa6,0x45,0x00,0x0a,0xa0,0x82,0x00,0x06,0x86,0x43,0x00,0x06, +0x27,0x82,0x99,0x44,0x01,0x22,0x88,0x21,0x24,0x02,0x00,0x13,0x10,0x62,0x00,0xee, +0xae,0x27,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,0xa6,0x40,0x00,0x02, +0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08,0x8c,0x45,0x00,0x00, +0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x30,0x63,0x00,0x01,0xac,0xc5,0x00,0x08, +0x10,0x60,0x00,0xc7,0x30,0x97,0x00,0x01,0x00,0x10,0x16,0x82,0x30,0x46,0x00,0x01, +0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02,0x00,0x10,0x2e,0x42, +0x30,0x48,0x00,0x7f,0x24,0x02,0x00,0x01,0x30,0x71,0x00,0x01,0x30,0x84,0x00,0x01, +0x10,0xc2,0x00,0xb3,0x30,0xa3,0x00,0x01,0x00,0x60,0x28,0x21,0x0c,0x00,0x21,0x0d, +0x01,0x00,0x38,0x21,0x02,0x93,0x18,0x21,0x00,0x03,0x18,0x80,0x2c,0x46,0x00,0x54, +0x27,0x85,0x99,0x50,0x27,0x84,0x99,0x48,0x00,0x06,0x10,0x0a,0x00,0x65,0x28,0x21, +0x26,0x26,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02,0xa0,0x66,0x00,0x06, +0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x93,0x28,0x21,0x00,0x05,0x28,0x80, +0x27,0x82,0x99,0x44,0x00,0xa2,0x58,0x21,0x8d,0x64,0x00,0x18,0x00,0x10,0x15,0xc2, +0x30,0x42,0x00,0x01,0x8c,0x83,0x00,0x0c,0x27,0x84,0x99,0x60,0x00,0xa4,0x48,0x21, +0xa6,0x42,0x00,0x00,0xa6,0x56,0x00,0x04,0x8d,0x26,0x00,0x00,0x00,0x03,0x19,0x42, +0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01,0x00,0xc2,0x40,0x24, +0x00,0x03,0x1d,0x00,0x01,0x03,0x40,0x25,0x00,0x08,0x15,0x02,0x00,0x10,0x34,0x42, +0x00,0x10,0x3c,0x82,0x00,0x15,0x19,0x82,0x00,0x15,0x25,0x82,0x00,0x10,0x2c,0x02, +0x30,0x42,0x00,0x01,0x30,0xcd,0x00,0x01,0x30,0x6c,0x00,0x01,0x30,0xe6,0x00,0x01, +0x30,0x8a,0x00,0x03,0x32,0xb1,0x00,0x07,0x30,0xa5,0x00,0x01,0xad,0x28,0x00,0x00, +0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,0x8d,0x64,0x00,0x18,0x3c,0x03,0xff,0xf0, +0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,0x01,0x03,0x18,0x24,0x00,0x02,0x13,0x82, +0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,0x00,0x62,0x18,0x25,0xad,0x23,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x6a,0x00,0x00,0x00,0x00,0x15,0x80,0x00,0x03, +0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x5b,0x24,0x02,0x00,0x01,0x96,0x42,0x00,0x04, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x42,0x00,0x04,0x00,0xa0,0x20,0x21, +0x0c,0x00,0x21,0x0d,0x01,0xa0,0x28,0x21,0x02,0x93,0x18,0x21,0x00,0x03,0x40,0x80, +0x2c,0x45,0x00,0x54,0x27,0x84,0x99,0x50,0x01,0x04,0x20,0x21,0x00,0x05,0x10,0x0a, +0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,0x96,0x43,0x00,0x04, +0x27,0x82,0x99,0x40,0x01,0x02,0x10,0x21,0xa4,0x43,0x00,0x06,0x27,0x82,0x99,0x44, +0x92,0x46,0x00,0x01,0x01,0x02,0x10,0x21,0x8c,0x45,0x00,0x18,0x27,0x83,0x99,0x60, +0x01,0x03,0x18,0x21,0xa0,0x60,0x00,0x00,0xa0,0x86,0x00,0x07,0x94,0xa2,0x00,0x10, +0x24,0x03,0x00,0x04,0x30,0x42,0x00,0x0f,0x10,0x43,0x00,0x36,0x24,0xa5,0x00,0x10, +0x94,0xa3,0x00,0x16,0x27,0x87,0x99,0x58,0x01,0x07,0x10,0x21,0xa4,0x43,0x00,0x02, +0x94,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x24, +0x02,0x93,0x20,0x21,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0xa4,0x30,0x42,0x00,0xff, +0x10,0x43,0x00,0x1f,0x00,0x00,0x00,0x00,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0x88, +0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x14,0x02,0x93,0x18,0x21,0x27,0x84,0x99,0x60, +0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,0x3c,0x04,0x00,0x80, +0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x93,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x47,0x10,0x21,0xa0,0x51,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c, +0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x24,0x02,0x00,0x01, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x94,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xe9,0x02,0x93,0x18,0x21,0x02,0x93,0x20,0x21, +0x27,0x82,0x99,0x60,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21,0x8c,0x83,0x00,0x00, +0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24,0x08,0x00,0x22,0x02, +0xac,0x83,0x00,0x00,0x27,0x87,0x99,0x58,0x01,0x07,0x10,0x21,0x08,0x00,0x21,0xec, +0xa4,0x40,0x00,0x02,0x11,0x42,0x00,0x07,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x02, +0x14,0x40,0xff,0xa7,0x00,0xa0,0x20,0x21,0x96,0x42,0x00,0x04,0x08,0x00,0x21,0xca, +0x24,0x42,0x00,0x0c,0x96,0x42,0x00,0x04,0x08,0x00,0x21,0xca,0x24,0x42,0x00,0x08, +0x16,0xe6,0xff,0x96,0x3c,0x02,0xff,0xfb,0x8d,0x63,0x00,0x18,0x34,0x42,0xff,0xff, +0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x21,0xc3,0x00,0x00,0x30,0x21, +0x16,0xe6,0xff,0x4e,0x00,0x60,0x28,0x21,0x3c,0x02,0xfb,0xff,0x34,0x42,0xff,0xff, +0x02,0x02,0x10,0x24,0xac,0xe2,0x00,0x08,0x08,0x00,0x21,0x82,0x00,0x00,0x30,0x21, +0x93,0x87,0xc4,0x54,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82,0x27,0x82,0x99,0x48, +0x2c,0xe5,0x00,0x0c,0x01,0x22,0x48,0x21,0x30,0x63,0x00,0x01,0x30,0x86,0x00,0x01, +0x14,0xa0,0x00,0x06,0x00,0xe0,0x40,0x21,0x00,0x03,0x10,0x40,0x00,0x46,0x10,0x21, +0x00,0x02,0x11,0x00,0x00,0xe2,0x10,0x21,0x24,0x48,0x00,0x04,0x02,0x93,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x84,0x99,0x50,0x27,0x83,0x99,0x48,0x00,0x44,0x20,0x21, +0x00,0x43,0x10,0x21,0xa1,0x28,0x00,0x07,0xa0,0x40,0x00,0x06,0xa0,0x80,0x00,0x02, +0x08,0x00,0x21,0x92,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01,0x00,0xe0,0x20,0x21, +0x0c,0x00,0x01,0xc2,0xa6,0x42,0x00,0x02,0x8e,0x24,0x00,0x18,0x0c,0x00,0x05,0x39, +0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x06,0x00,0x00,0x00,0x00,0x30,0xa7,0xff,0xff, +0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21,0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x24,0x42,0x89,0x7c,0x27,0x85,0x99,0x50,0x00,0x03,0x18,0x80,0x34,0xc6,0x00,0x20, +0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00,0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21,0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00, +0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01,0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16, +0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04,0x3c,0x03,0xb0,0x03,0x27,0x86,0x99,0x40, +0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20,0x24,0x02,0x00,0x01,0xa0,0xa2,0x00,0x04, +0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08,0xa4,0xa7,0x00,0x00,0x94,0xa4,0x00,0x02, +0x3c,0x02,0x80,0x01,0x24,0x42,0xa1,0x7c,0xac,0x62,0x00,0x00,0x00,0x04,0x18,0xc0, +0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x94,0x62,0x00,0x04, +0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,0x00,0x82,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x00,0x83,0x20,0x21,0xa4,0x47,0x00,0x00, +0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x24,0x42,0x00,0x01, +0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04,0x90,0x82,0x00,0x16,0x24,0x85,0x00,0x06, +0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02,0x14,0x60,0xff,0xda,0xa0,0x82,0x00,0x16, +0x24,0x02,0x00,0x01,0x08,0x00,0x22,0x75,0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8, +0xaf,0xbf,0x00,0x10,0x00,0x80,0x38,0x21,0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x3c,0x0a,0xb0,0x06,0x34,0x63,0x00,0x20,0x24,0x42,0x8a,0x7c, +0x3c,0x0b,0xb0,0x08,0x27,0x89,0x99,0x40,0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20, +0x10,0x80,0x00,0x30,0xac,0x62,0x00,0x00,0x97,0x82,0x99,0x30,0x94,0xe6,0x02,0xba, +0x00,0x02,0x18,0xc0,0x00,0x6b,0x28,0x21,0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8, +0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21, +0xa4,0x66,0x00,0x00,0x00,0x08,0x28,0xc0,0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00, +0x8c,0xe4,0x02,0xb8,0x27,0x82,0x99,0x44,0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0, +0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18, +0x27,0x84,0x99,0x50,0x00,0x64,0x18,0x21,0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06, +0x00,0x05,0x28,0x80,0x30,0x42,0xff,0xff,0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff, +0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04, +0x00,0xa9,0x28,0x21,0x00,0x44,0x10,0x25,0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00, +0xa7,0x88,0x99,0x30,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x84,0xe3,0x00,0x06,0x27,0x82,0xbd,0x40,0x94,0xe5,0x02,0xba, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x0c,0x00,0x22,0x5f, +0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xd9,0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00, +0x00,0x80,0x58,0x21,0x27,0x8a,0x99,0x40,0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21, +0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80,0x3c,0x02,0x80,0x01,0x00,0x6a,0x18,0x21, +0x34,0x84,0x00,0x20,0x24,0x42,0x8b,0x9c,0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00, +0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35,0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04, +0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a,0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21, +0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21,0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d, +0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80, +0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21,0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21, +0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0,0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff, +0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04,0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04, +0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, +0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02,0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00,0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02, +0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01,0x00,0xa3,0x28,0x21,0x24,0x42,0xa1,0x7c, +0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03,0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08, +0x24,0x02,0x00,0x01,0x08,0x00,0x23,0x27,0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04, +0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff,0x30,0x43,0x00,0xff,0x14,0x60,0xff,0xf7, +0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff,0x08,0x00,0x23,0x27,0xa5,0x62,0x00,0x02, +0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21,0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80, +0x27,0x82,0x99,0x44,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20, +0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10,0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18, +0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x01,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20, +0x24,0x42,0x8c,0xd0,0xac,0xa2,0x00,0x00,0x27,0x83,0x99,0x50,0x00,0xc3,0x30,0x21, +0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06,0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff, +0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02, +0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff,0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21,0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00, +0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06,0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21, +0x0c,0x00,0x22,0xe7,0x02,0x00,0x28,0x21,0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08,0x3c,0x09,0x80,0x01,0x27,0x88,0x99,0x40, +0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0,0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80, +0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03, +0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21, +0x00,0xa3,0x28,0x21,0x25,0x26,0xa1,0x7c,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20, +0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00, +0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a,0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21, +0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e, +0x27,0x88,0x99,0x40,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, +0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01, +0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21, +0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20,0x25,0x23,0xa1,0x7c,0xac,0xc3,0x00,0x00, +0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00,0x08,0x00,0x23,0x65,0xa4,0x90,0x00,0x02, +0x08,0x00,0x23,0x5c,0x32,0x50,0xff,0xff,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x24,0x42,0x8e,0x98,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04, +0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21,0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23, +0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff,0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73, +0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0,0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21, +0x03,0x0e,0x20,0x21,0x27,0x8d,0x99,0x40,0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80, +0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21,0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04, +0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02,0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21, +0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21, +0x00,0x6d,0x18,0x21,0x27,0x22,0xa1,0x7c,0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20, +0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57,0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21, +0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21,0x01,0x40,0x38,0x21,0x27,0x8b,0x99,0x44, +0x27,0x8a,0x99,0x50,0x00,0x06,0x40,0xc0,0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21, +0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02,0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01, +0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff,0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02, +0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0,0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03,0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21, +0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08, +0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21,0x27,0x26,0xa1,0x7c,0x34,0x03,0xff,0xff, +0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00, +0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10,0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e, +0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05,0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0, +0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04, +0x34,0xc6,0x00,0x20,0x27,0x27,0xa1,0x7c,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00, +0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00,0xac,0xaf,0x00,0x00,0x08,0x00,0x23,0xf4, +0x03,0x0e,0x20,0x21,0x08,0x00,0x23,0xcf,0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0, +0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x8d,0x99,0x40,0x00,0x4d,0x10,0x21, +0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00, +0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01,0x08,0x00,0x23,0xcf,0xa5,0x82,0x00,0x02, +0x08,0x00,0x23,0xcf,0x3c,0x19,0x80,0x01,0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20,0x24,0x42,0x90,0xd8,0xaf,0xb2,0x00,0x68, +0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60,0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84, +0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c,0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74, +0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c,0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a, +0x27,0x82,0xbd,0x40,0xaf,0xa6,0x00,0x90,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21, +0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94,0x27,0x86,0x99,0x44,0xaf,0xa3,0x00,0x1c, +0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff,0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0, +0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21,0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80, +0x27,0x84,0x99,0x50,0x00,0x64,0x20,0x21,0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21, +0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2, +0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21,0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c, +0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01,0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34, +0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40,0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50, +0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12,0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28, +0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xda,0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82, +0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11,0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98, +0x27,0x82,0x86,0x30,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x05, +0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00,0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a, +0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12, +0x24,0x42,0x00,0x10,0x30,0x42,0xff,0xfc,0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18, +0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff,0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48, +0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21,0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x4e, +0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02,0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21, +0x00,0x12,0x10,0xc0,0x00,0x52,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x40,0xa0,0x21, +0x27,0x82,0x99,0x58,0x00,0x82,0x10,0x21,0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58, +0x27,0x85,0x99,0x40,0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23,0x30,0x63,0x0f,0xff, +0x00,0x85,0x20,0x21,0x28,0x62,0x00,0x20,0x94,0x96,0x00,0x02,0x10,0x40,0x01,0xa1, +0x28,0x62,0x00,0x40,0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x68,0x10,0x06, +0x30,0x43,0x00,0x01,0x24,0x02,0x00,0x01,0x10,0x62,0x01,0x7b,0x3c,0x02,0xb0,0x03, +0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21, +0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80, +0x27,0x82,0x99,0x50,0x27,0x85,0x99,0x48,0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21, +0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff, +0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,0x27,0x82,0x99,0x60,0x00,0x04,0x20,0x80, +0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46, +0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02, +0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02, +0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21, +0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,0x02,0x92,0x10,0x21,0x93,0x82,0x94,0x51, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21, +0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff, +0x16,0xa0,0xff,0xb7,0x02,0xc0,0x90,0x21,0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00, +0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e, +0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a, +0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,0x27,0x84,0x99,0x44,0x94,0xb2,0x00,0x14, +0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21, +0x00,0x02,0x80,0x80,0x27,0x82,0x99,0x50,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06, +0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2, +0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e, +0x00,0xa3,0x38,0x21,0x27,0x82,0x99,0x40,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06, +0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c, +0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38, +0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14, +0x08,0x00,0x25,0x01,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x44,0x93,0x82,0x87,0x6d, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f, +0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87, +0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83, +0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d, +0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50, +0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21, +0x27,0x8c,0x99,0x40,0x3c,0x0b,0x80,0xff,0x24,0x10,0x00,0x04,0x27,0x91,0x99,0x44, +0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,0x27,0x8e,0x99,0x50,0x01,0x80,0x78,0x21, +0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, +0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44, +0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03, +0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, +0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b, +0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff, +0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21, +0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x80,0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04, +0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25, +0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01, +0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c, +0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00, +0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21, +0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88, +0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21, +0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x58,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, +0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,0x08,0x00,0x25,0x07,0x02,0x00,0x10,0x21, +0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,0x00,0x00,0x38,0x21,0x0c,0x00,0x29,0x5e, +0xaf,0xa2,0x00,0x10,0x08,0x00,0x25,0x07,0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff, +0x08,0x00,0x25,0x59,0xaf,0xa3,0x00,0x2c,0x8f,0xa8,0x00,0x44,0x08,0x00,0x25,0x7b, +0x31,0x09,0x00,0x03,0x08,0x00,0x25,0x34,0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44, +0xaf,0xa0,0x00,0x50,0x08,0x00,0x25,0x7b,0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48, +0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x03,0xc0,0x38,0x21,0x0c,0x00,0x23,0xa6, +0xaf,0xb7,0x00,0x10,0x08,0x00,0x24,0xe4,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80, +0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49, +0x00,0x00,0x00,0x00,0x08,0x00,0x24,0xdd,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80, +0x27,0x83,0x99,0x50,0x8f,0xa4,0x00,0x1c,0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01, +0x02,0x40,0x28,0x21,0x0c,0x00,0x26,0xae,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13, +0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48, +0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24, +0x27,0x82,0x99,0x40,0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30, +0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44, +0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04, +0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00, +0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff, +0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80, +0x27,0x82,0x99,0x44,0x00,0xa2,0x10,0x21,0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff, +0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,0x00,0x04,0x25,0x80,0x34,0x63,0xff,0xff, +0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04, +0x8f,0xa8,0x00,0x98,0x27,0x82,0x99,0x50,0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00, +0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb, +0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00, +0x08,0x00,0x24,0xe0,0x26,0xb5,0xff,0xff,0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21, +0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,0x08,0x00,0x25,0xee,0xaf,0xa2,0x00,0x2c, +0x8f,0xa6,0x00,0x1c,0x08,0x00,0x25,0xd8,0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48, +0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x0c,0x00,0x23,0xa6,0xaf,0xb7,0x00,0x10, +0x08,0x00,0x25,0xcf,0x00,0x00,0xb8,0x21,0x0c,0x00,0x1a,0x28,0x00,0x00,0x28,0x21, +0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x63,0x08,0x00,0xa4,0x43,0x00,0x00, +0x08,0x00,0x24,0xd4,0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21,0x00,0x03,0x80,0x80, +0x27,0x82,0x99,0x44,0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00, +0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x10,0x60,0x00,0x09, +0x24,0x06,0x00,0x01,0x93,0x82,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, +0x10,0x40,0xfe,0xa3,0x3c,0x04,0x00,0x80,0x27,0x85,0x99,0x40,0x08,0x00,0x25,0xbf, +0x02,0x05,0x28,0x21,0x27,0x83,0x99,0x58,0x27,0x82,0x99,0x50,0x02,0x03,0x18,0x21, +0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05,0x93,0x83,0x80,0x10, +0x00,0x00,0x38,0x21,0x0c,0x00,0x29,0x5e,0xaf,0xa3,0x00,0x10,0x08,0x00,0x26,0x35, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94, +0x08,0x00,0x24,0xac,0x00,0x64,0x10,0x06,0x08,0x00,0x24,0xad,0x00,0x00,0x18,0x21, +0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7, +0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,0x08,0x00,0x24,0x77,0xaf,0xa2,0x00,0x40, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20, +0x24,0x63,0x99,0x60,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, +0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45, +0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c, +0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, +0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16, +0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00, +0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, +0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a, +0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00, +0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01, +0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,0x08,0x00,0x26,0x82,0xa6,0x03,0x00,0x14, +0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x99,0x40,0x00,0x04,0x10,0xc0, +0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80, +0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, +0x8c,0x44,0x00,0x08,0x0c,0x00,0x1a,0x19,0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff, +0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,0x96,0x02,0x00,0x06,0x08,0x00,0x26,0x82, +0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,0x08,0x00,0x26,0x82,0xa6,0x02,0x00,0x14, +0x96,0x05,0x00,0x00,0x0c,0x00,0x26,0xae,0x02,0x00,0x20,0x21,0x08,0x00,0x26,0x69, +0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,0x0c,0x00,0x26,0xae,0x00,0x00,0x00,0x00, +0x08,0x00,0x26,0x65,0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x63,0x00,0x20,0x24,0x42,0x9a,0xb8,0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00, +0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x9a,0xdc,0xac,0x62,0x00,0x00, +0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21, +0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00, +0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00, +0x94,0xc8,0x00,0x00,0x27,0x83,0x99,0x40,0x93,0x85,0x94,0x50,0x00,0x08,0x10,0xc0, +0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, +0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,0x01,0x44,0x18,0x23,0x8f,0x82,0x94,0x68, +0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, +0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, +0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08, +0x08,0x00,0x26,0xda,0xa4,0xc2,0x00,0x14,0x08,0x00,0x26,0xda,0x00,0x00,0x18,0x21, +0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, +0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c, +0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,0x3c,0x02,0x80,0x01,0x3c,0x04,0xb0,0x03, +0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,0x24,0x42,0x9b,0x90,0x02,0xb1,0x48,0x21, +0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,0x24,0x03,0x00,0x01,0x27,0x82,0x99,0x50, +0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,0x27,0x84,0x99,0x44,0x01,0x24,0x20,0x21, +0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,0x27,0x83,0x99,0x60,0x01,0x23,0x48,0x21, +0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04, +0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2, +0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40, +0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21, +0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21, +0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21, +0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,0x27,0x90,0x99,0x40,0x02,0x30,0x80,0x21, +0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21, +0xa6,0x83,0x00,0x1a,0x27,0x82,0x99,0x48,0x0c,0x00,0x10,0x80,0x02,0x22,0x88,0x21, +0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30, +0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xaf,0xa9,0x00,0x10,0x0c,0x00,0x10,0xa7, +0xaf,0xa0,0x00,0x14,0x08,0x00,0x27,0x18,0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0, +0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, +0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28, +0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03, +0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21, +0x3c,0x02,0x80,0x01,0x00,0x03,0x48,0x80,0x24,0x42,0x9c,0xcc,0x00,0x80,0x98,0x21, +0x27,0x84,0x99,0x50,0x01,0x24,0x20,0x21,0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00, +0x80,0x83,0x00,0x06,0x27,0x82,0x99,0x44,0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18, +0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21, +0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10, +0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21, +0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21, +0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21, +0x27,0x83,0x99,0x58,0x01,0x23,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xbe,0xb0, +0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00, +0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80, +0x24,0x04,0x00,0x01,0x27,0x83,0x99,0x60,0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21, +0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01, +0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,0x02,0xa0,0x20,0x21,0x27,0x82,0x99,0x40, +0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a, +0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, +0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10, +0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14,0x08,0x00,0x27,0x7f,0x00,0x00,0x00,0x00, +0x27,0x83,0x99,0x60,0x01,0x23,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf, +0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d, +0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21, +0x27,0x82,0x86,0x30,0x00,0x15,0x18,0x40,0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00, +0x24,0xa2,0x00,0x05,0x00,0x54,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x10, +0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff, +0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f, +0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20, +0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10, +0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08, +0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef, +0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1, +0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3, +0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a, +0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d, +0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,0x27,0x99,0x99,0x40,0x01,0xf2,0xc0,0x23, +0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04, +0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21, +0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23, +0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff, +0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23, +0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40, +0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00, +0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x99,0x44, +0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x80, +0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,0x00,0x83,0x20,0x24,0x27,0x83,0x99,0x50, +0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04, +0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,0xa0,0xb5,0x00,0x03,0x27,0x84,0x99,0x60, +0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2, +0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a, +0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01, +0x27,0x84,0x99,0x40,0x00,0xc4,0x18,0x21,0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02, +0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23, +0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0, +0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,0x02,0x03,0x80,0x21,0x27,0x82,0x99,0x48, +0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21, +0x01,0x60,0x88,0x21,0x0c,0x00,0x10,0x80,0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21, +0xa6,0x02,0x00,0x04,0x08,0x00,0x27,0x85,0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b, +0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6, +0x01,0x71,0x18,0x21,0x08,0x00,0x27,0xfb,0x25,0x22,0x00,0x01,0x08,0x00,0x28,0x2a, +0x32,0xcc,0x00,0x03,0x08,0x00,0x28,0x2a,0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c, +0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7,0xaf,0xb4,0x00,0x14, +0x92,0x67,0x00,0x04,0x08,0x00,0x27,0x9d,0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff, +0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,0x00,0x04,0x20,0x80,0x27,0x82,0x99,0x40, +0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21, +0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff, +0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,0x27,0x88,0x99,0x40,0x00,0x06,0x30,0x80, +0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03, +0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21, +0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20, +0x24,0x42,0xa1,0x7c,0xac,0xe2,0x00,0x00,0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00, +0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0, +0x00,0x44,0x10,0x21,0x27,0x89,0x99,0x40,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, +0x97,0x83,0x99,0x30,0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0, +0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21, +0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20, +0x34,0x09,0xff,0xff,0x24,0x42,0xa1,0xd8,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00, +0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x99,0x30, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x63,0x00,0x20,0x24,0x42,0xa2,0x58,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, +0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,0x97,0x83,0x87,0x74,0x30,0x42,0xff,0xff, +0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,0xa7,0x82,0x87,0x74,0xaf,0x80,0xbd,0x90, +0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,0x27,0x84,0xbd,0x94,0x25,0x43,0xff,0xff, +0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00, +0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24, +0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14, +0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03, +0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,0x27,0x89,0xbd,0xe0,0x35,0x6b,0x01,0x20, +0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2, +0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6, +0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21, +0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a, +0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff, +0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, +0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40, +0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04, +0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08, +0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0, +0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b, +0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08, +0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5, +0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03, +0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04, +0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x90,0x82,0x00,0x05,0x08,0x00,0x28,0xd1,0xa0,0x82,0x00,0x08,0x97,0x85,0x94,0x5a, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20, +0x24,0x42,0xa4,0x0c,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00, +0x30,0x90,0x00,0xff,0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xbd,0xe4, +0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xbe,0xc4,0x27,0x99,0xbe,0xc0, +0x27,0x8e,0xbe,0xbe,0x27,0x8c,0xbd,0xe8,0x27,0x8d,0xbe,0x40,0x27,0x88,0xbe,0xb8, +0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58, +0x00,0x6e,0x20,0x21,0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00, +0xa1,0x00,0x00,0x04,0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21, +0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00, +0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9, +0x24,0x84,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21, +0x00,0x4c,0x18,0x21,0x27,0x87,0x87,0x78,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04, +0xac,0x82,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01, +0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6, +0x24,0x63,0x00,0x03,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b, +0x25,0x08,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x87,0x74, +0x00,0x00,0x48,0x21,0x27,0x83,0xbd,0x90,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01, +0x29,0x22,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x28,0x96, +0x00,0x00,0x00,0x00,0x2e,0x04,0x00,0x14,0x27,0x83,0xbd,0xe0,0x24,0x09,0x00,0x07, +0x10,0x80,0x00,0x0a,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff, +0xa0,0x62,0x00,0x00,0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6, +0x08,0x00,0x29,0x54,0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00, +0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80, +0x27,0x83,0xbd,0xe0,0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x84,0x00,0x20,0x24,0x42,0xa5,0x78,0x30,0xc6,0x00,0xff,0x93,0xaa,0x00,0x13, +0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xe8, +0x25,0x8f,0x00,0xd0,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc, +0x2c,0x43,0x00,0x18,0x10,0x60,0x00,0xc7,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80, +0x24,0x63,0x09,0x3c,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x1c, +0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x17,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x11,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0c, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0x03,0xe0,0x00,0x08, +0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xe8, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, +0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0x00,0x02, +0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x0a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe9,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, +0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe0, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdb,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,0x14,0x40,0xff,0xc5, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd0, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,0x10,0x40,0xff,0xf1, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb5, +0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf4, +0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xbd, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xb5,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8a,0x24,0x02,0x00,0x03, +0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xae, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xa9,0x24,0x02,0x00,0x02, +0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xc7,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x9c, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x9a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x95,0x24,0x02,0x00,0x03, +0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, +0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x88, +0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xb7,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x17, +0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xf8,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x81, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x76,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x97, +0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0x15, +0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x65,0x24,0x02,0x00,0x03, +0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8c,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xbd, +0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xbb,0x2d,0x42,0x00,0x25,0x08,0x00,0x29,0xf1, +0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x50, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xaa, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,0x00,0x00,0x00,0x00, +0x08,0x00,0x2a,0x3d,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,0x14,0x40,0xff,0xd8, +0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xad,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2c, +0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x81,0x00,0x00,0x00,0x00, +0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff, +0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,0x00,0x04,0x48,0x80,0x01,0x82,0x58,0x21, +0x01,0x89,0x40,0x21,0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60, +0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,0x00,0x00,0x00,0x00,0x27,0x87,0x87,0x78, +0x01,0x27,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60, +0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00, +0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00, +0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00, +0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b, +0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4, +0x27,0x87,0x87,0x78,0x08,0x00,0x2a,0x74,0xa1,0x80,0x00,0xdd,0x27,0x82,0x87,0xe8, +0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01, +0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x02,0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60, +0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, +0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,0x10,0xe0,0x00,0x1d,0x24,0x83,0xff,0xfc, +0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x10,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, +0x24,0x63,0x09,0x9c,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x65, +0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x5a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0xad,0x82,0x00,0xd0, +0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, +0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, +0x93,0x05,0x00,0x01,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05, +0x24,0x02,0x00,0x01,0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08, +0xad,0x80,0x00,0xd8,0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05, +0x00,0x00,0x00,0x00,0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08, +0xa1,0x83,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43, +0xad,0xa2,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x87,0x78,0x8d,0xc5,0x00,0x00, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40, +0x00,0x04,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x2a,0x86, +0xad,0xc5,0x00,0x00,0x97,0x82,0x94,0x5c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a, +0x10,0x40,0xfe,0xab,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x87,0x78, +0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21, +0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80, +0x01,0x82,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, +0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x2a,0xfb,0xa1,0x80,0x00,0xdd, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x2a,0xb7,0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7, +0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa0, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x9d,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x93,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdd,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19, +0x14,0x40,0xff,0x7c,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x83,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b, +0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x14,0xa2,0xff,0x6c,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7, +0x24,0x42,0xff,0xf4,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xbd,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x68, +0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb2, +0x24,0x02,0x00,0x03,0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xae,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5c, +0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x38, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00, +0x08,0x00,0x2b,0x0d,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x9a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x48, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x3b,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x28,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x17,0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x69, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0x81,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x29,0x24,0x02,0x00,0x03, +0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb4,0x00,0x00,0x00,0x00, +0x08,0x00,0x2b,0x86,0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x6a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x18, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb4, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00, +0x08,0x00,0x2b,0x2e,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x2c,0x2d,0x42,0x00,0x25, +0x08,0x00,0x2b,0x62,0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x03,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00, +0x08,0x00,0x2b,0x1b,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad, +0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0xae,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a, +0x14,0x40,0xff,0xd8,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x1e,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x2c,0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xa9, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,0xaf,0xbf,0x00,0x14, +0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,0x8c,0x50,0x00,0x00, +0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,0xa3,0x82,0x80,0x10, +0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09, +0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01, +0xa3,0x82,0xc5,0x58,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x0b,0x3e,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00, +0xa3,0x80,0xc5,0x58,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x2b,0xda, +0x32,0x02,0x08,0x00,0x0c,0x00,0x29,0x03,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff, +0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x2b,0xd7,0x32,0x02,0x01,0x00, +0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18, +0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02, +0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24, +0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff, +0x01,0x00,0x30,0x21,0x0c,0x00,0x2c,0xa6,0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x2c,0xf8, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,0x08,0x00,0x2c,0x03, +0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0x3c,0x02,0xb0,0x03,0xaf,0xb6,0x00,0x30, +0xaf,0xb5,0x00,0x2c,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c, +0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, +0xaf,0xb2,0x00,0x20,0x34,0x42,0x00,0x3f,0x90,0x43,0x00,0x00,0x00,0x80,0x80,0x21, +0x00,0x00,0xb0,0x21,0x00,0x00,0x88,0x21,0x10,0x60,0x00,0x7a,0x00,0x00,0xa8,0x21, +0x3c,0x01,0xb0,0x03,0xa0,0x20,0x00,0x3f,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x47, +0x90,0x44,0x00,0x00,0x00,0x10,0x1a,0x02,0x3c,0x14,0xfd,0xff,0x30,0x84,0x00,0xff, +0xa0,0x50,0x00,0x00,0x30,0x73,0x00,0x0f,0xaf,0xa4,0x00,0x10,0x00,0x00,0x90,0x21, +0x3c,0x17,0x02,0x00,0x36,0x94,0xff,0xff,0x24,0x1e,0x00,0x04,0x0c,0x00,0x0e,0x76, +0x24,0x04,0x00,0x78,0x00,0x57,0x10,0x25,0x00,0x40,0x28,0x21,0x0c,0x00,0x0e,0x64, +0x24,0x04,0x00,0x78,0x00,0x00,0x80,0x21,0x0c,0x00,0x2d,0xc0,0x00,0x00,0x00,0x00, +0x26,0x03,0x00,0x01,0x10,0x40,0x00,0x53,0x30,0x70,0x00,0xff,0x12,0x00,0xff,0xfa, +0x00,0x00,0x00,0x00,0x0c,0x00,0x0e,0x76,0x24,0x04,0x00,0x78,0x00,0x54,0x10,0x24, +0x00,0x40,0x28,0x21,0x0c,0x00,0x0e,0x64,0x24,0x04,0x00,0x78,0x24,0x02,0x00,0x01, +0x12,0x62,0x00,0x44,0x24,0x04,0x00,0xe0,0x12,0x60,0x00,0x42,0x24,0x04,0x00,0xe4, +0x32,0x22,0x00,0x60,0x32,0x23,0x0c,0x00,0x00,0x03,0x1a,0x02,0x3c,0x05,0x00,0x60, +0x00,0x02,0x11,0x42,0x02,0x25,0x20,0x24,0x00,0x43,0x10,0x25,0x3c,0x03,0x04,0x00, +0x02,0x23,0x28,0x24,0x00,0x04,0x24,0x42,0x00,0x44,0x10,0x25,0x00,0x05,0x2d,0x02, +0x00,0x45,0x88,0x25,0x12,0x20,0x00,0x03,0x26,0xc2,0x00,0x01,0x30,0x56,0x00,0xff, +0x02,0xb1,0xa8,0x21,0x12,0x5e,0x00,0x2a,0x3c,0x05,0xb0,0x03,0x02,0x45,0x10,0x21, +0xa0,0x51,0x00,0x34,0x26,0x42,0x00,0x01,0x30,0x52,0x00,0xff,0x2e,0x43,0x00,0x05, +0x14,0x60,0xff,0xce,0x3c,0x02,0xb0,0x03,0x8f,0xa3,0x00,0x10,0x34,0x42,0x01,0x47, +0xa0,0x43,0x00,0x00,0x12,0xa0,0x00,0x0e,0x3c,0x02,0xb0,0x03,0x12,0xc0,0x00,0x0d, +0x34,0x42,0x00,0x3c,0x00,0x15,0x10,0x40,0x00,0x55,0x10,0x21,0x00,0x02,0x10,0xc0, +0x00,0x55,0x10,0x21,0x00,0x02,0xa8,0x80,0x02,0xb6,0x00,0x1b,0x16,0xc0,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0xa8,0x12,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x00,0x3c,0x3c,0x03,0xb0,0x03,0x3c,0x04,0xb0,0x03,0xa4,0x55,0x00,0x00, +0x34,0x63,0x00,0x1c,0x34,0x84,0x00,0x1d,0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00, +0xa0,0x82,0x00,0x00,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3e,0xa0,0x51,0x00,0x00,0x08,0x00,0x2c,0x5e, +0x26,0x42,0x00,0x01,0x0c,0x00,0x0e,0x76,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0x48, +0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x3c,0x3c,0x04,0xb0,0x03, +0x3c,0x05,0xb0,0x03,0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0x1c,0x34,0xa5,0x00,0x1d, +0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x2c,0x7d, +0xa0,0xa3,0x00,0x00,0x0c,0x00,0x1f,0x64,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x87, +0x3c,0x02,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x42,0x00,0x3c,0x34,0x84,0x00,0x14, +0x24,0x03,0x00,0x01,0xa4,0x40,0x00,0x00,0x3c,0x01,0xb0,0x03,0xa0,0x23,0x00,0x3f, +0x08,0x00,0x2c,0x7d,0xac,0x90,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10, +0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, +0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x30,0xb1,0x00,0xff,0x14,0x40,0x00,0x06, +0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14, +0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x38,0x02,0x00,0x30,0x21, +0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,0x3c,0x04,0xb0,0x09,0x00,0x02,0x14,0x00, +0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x2a,0x2a,0x22,0x00,0x02, +0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x20,0x24,0x02,0x00,0x03, +0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,0x16,0x60,0xff,0xe2,0x24,0x02,0x00,0x01, +0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x02, +0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xda,0x00,0x00,0x00,0x00, +0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40,0x3c,0x06,0x0c,0xb8, +0x08,0x00,0x2c,0xb1,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x48, +0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x40, +0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x44,0x24,0x04,0x08,0x4c,0x0c,0x00,0x1b,0x40, +0x24,0x05,0xff,0xff,0x08,0x00,0x2c,0xce,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xe7, +0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xe7, +0x24,0x04,0x08,0x40,0x08,0x00,0x2c,0xe7,0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21, +0x0c,0x00,0x2d,0x38,0x02,0x20,0x28,0x21,0x08,0x00,0x2c,0xbc,0x00,0x40,0x30,0x21, +0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x00,0xc0,0x80,0x21, +0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,0x14,0x40,0x00,0x07,0x00,0x00,0x18,0x21, +0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x00,0x60,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14, +0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x24,0x02,0x00,0x30,0x21, +0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,0x0c,0x00,0x2d,0x75,0x02,0x20,0x20,0x21, +0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x15, +0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x0b, +0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x04, +0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40, +0x3c,0x06,0x0c,0xb8,0x08,0x00,0x2d,0x04,0x02,0x00,0x18,0x21,0x08,0x00,0x2d,0x26, +0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x26, +0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x26,0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21, +0x0c,0x00,0x2d,0x38,0x02,0x20,0x28,0x21,0x08,0x00,0x2d,0x10,0x00,0x40,0x30,0x21, +0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, +0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,0x30,0xa5,0x00,0xff,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x12,0x24,0x02,0x00,0x02, +0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x07,0x24,0x04,0x08,0x4c, +0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40, +0x3c,0x06,0x0d,0xf8,0x08,0x00,0x2d,0x49,0x26,0x10,0xff,0xe2,0x08,0x00,0x2d,0x4e, +0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x4f, +0x24,0x05,0xff,0xff,0x08,0x00,0x2d,0x4e,0x24,0x04,0x08,0x44,0x2c,0xc2,0x00,0x10, +0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x14,0x28,0xa2,0x00,0x02, +0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0a,0x24,0x02,0x00,0x03, +0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,0x08,0x00,0x2d,0x49,0x26,0x10,0xff,0xf1, +0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40,0x3c,0x06,0x0d,0xb8,0x08,0x00,0x2d,0x49, +0x26,0x10,0xff,0xf1,0x08,0x00,0x2d,0x68,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf6, +0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x69,0x24,0x05,0xff,0xff,0x08,0x00,0x2d,0x68, +0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, +0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,0x28,0x82,0x00,0x02,0x14,0x40,0x00,0x27, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x17,0x00,0xa0,0x30,0x21, +0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,0x24,0x04,0x08,0x3c,0x8f,0xbf,0x00,0x10, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x1b,0x40, +0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, +0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,0x0c,0x00,0x1b,0x22,0x24,0x05,0x0f,0xff, +0x08,0x00,0x2d,0x83,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x34,0x0c,0x00,0x1b,0x40, +0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, +0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, +0x24,0x06,0x00,0x01,0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa8,0x14,0x80,0xff,0xdf, +0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,0x0c,0x00,0x1b,0x40,0x3c,0x05,0x3f,0x00, +0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40,0x00,0x00,0x30,0x21, +0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x01, +0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa0,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x2c, +0x0c,0x00,0x1b,0x40,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x1b,0x40,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x01,0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa4, +0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x20,0x3c,0x06,0xc0,0x00, +0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0x34,0xa5,0x17,0x09,0xac,0x45,0x00,0x00, +0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,0x34,0x84,0x02,0x28,0x3c,0x07,0xb0,0x05, +0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,0x34,0xe7,0x04,0x50,0xa0,0x82,0x00,0x00, +0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,0x10,0x40,0xff,0xfc, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8, +0xaf,0xbf,0x00,0x10,0x0c,0x00,0x2e,0x85,0x00,0x00,0x00,0x00,0x0c,0x00,0x2e,0x87, +0x00,0x00,0x00,0x00,0x0c,0x00,0x2e,0xae,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05, +0x34,0x84,0x00,0x04,0x0c,0x00,0x2e,0x8e,0x34,0x05,0x9c,0x40,0x8f,0xbf,0x00,0x10, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x97,0x82,0x88,0x10, +0x00,0x00,0x00,0x00,0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x10, +0x14,0x60,0x00,0x28,0x00,0x80,0x30,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x20,0x00, +0xa7,0x80,0x88,0x10,0x00,0x43,0x10,0x24,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, +0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0x43,0x10,0x25,0x97,0x83,0x88,0x04, +0xac,0x82,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x63,0x00,0x01,0x3c,0x02,0x40,0x64, +0x34,0x42,0x64,0x00,0x00,0x03,0x24,0x00,0x00,0xa2,0x28,0x25,0x00,0x04,0x24,0x03, +0x24,0x02,0x00,0x64,0xac,0xc5,0x00,0x00,0xa7,0x83,0x88,0x04,0x10,0x82,0x00,0x2b, +0x00,0x00,0x00,0x00,0x87,0x82,0x88,0x06,0x24,0x03,0x00,0x3c,0x10,0x43,0x00,0x21, +0x00,0x00,0x00,0x00,0x87,0x82,0x88,0x08,0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x17, +0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x0a,0x24,0x02,0x00,0x18,0x10,0x62,0x00,0x0d, +0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x0c,0x24,0x02,0x01,0x6d,0x10,0x62,0x00,0x03, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0e, +0xa7,0x80,0x88,0x0c,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x0e,0x08,0x00,0x2e,0x1d, +0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0c,0xa7,0x80,0x88,0x0a,0x24,0x42,0x00,0x01, +0xa7,0x82,0x88,0x0c,0x08,0x00,0x2e,0x19,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0a, +0xa7,0x80,0x88,0x08,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x0a,0x08,0x00,0x2e,0x15, +0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x08,0xa7,0x80,0x88,0x06,0x24,0x42,0x00,0x01, +0xa7,0x82,0x88,0x08,0x08,0x00,0x2e,0x11,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x06, +0xa7,0x80,0x88,0x04,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x06,0x08,0x00,0x2e,0x0d, +0x00,0x00,0x00,0x00,0x00,0x04,0x24,0x00,0x3c,0x03,0xb0,0x07,0x00,0x04,0x24,0x03, +0x34,0x63,0x00,0x28,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x40, +0x10,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x01,0xb0,0x07,0xa0,0x24,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x28, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x10,0x60,0x00,0x06, +0x24,0x02,0xff,0xff,0x3c,0x02,0xb0,0x07,0x90,0x42,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x27,0xbd,0xff,0xe0,0xaf,0xb0,0x00,0x10,0x3c,0x10,0x04,0xc4,0x00,0x04,0x11,0x00, +0x36,0x10,0xb4,0x00,0x02,0x02,0x00,0x1b,0xaf,0xb1,0x00,0x14,0x3c,0x11,0xb0,0x07, +0x36,0x31,0x00,0x18,0x24,0x04,0x00,0x0a,0xaf,0xbf,0x00,0x18,0x14,0x40,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x80,0x12,0x0c,0x00,0x2e,0xda, +0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x00,0x24,0x03,0xff,0x80,0x24,0x04,0x00,0x0a, +0x00,0x43,0x10,0x25,0x0c,0x00,0x2e,0xda,0xa2,0x22,0x00,0x00,0x24,0x04,0x00,0x0a, +0x3c,0x01,0xb0,0x07,0xa0,0x30,0x00,0x00,0x0c,0x00,0x2e,0xda,0x00,0x10,0x82,0x03, +0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa0,0x50,0x00,0x00,0x0c,0x00,0x2e,0xda, +0x24,0x04,0x00,0x0a,0x92,0x22,0x00,0x00,0x8f,0xbf,0x00,0x18,0x8f,0xb0,0x00,0x10, +0x30,0x42,0x00,0x7f,0xa2,0x22,0x00,0x00,0x8f,0xb1,0x00,0x14,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x34,0x63,0x00,0x58,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x07,0xa4, +0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xf8,0x00,0x80,0x38,0x21, +0x00,0xa0,0x30,0x21,0x00,0x00,0x18,0x21,0x00,0x63,0x00,0x18,0x00,0x00,0x10,0x12, +0x00,0xc2,0x10,0x2b,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01, +0x2c,0x62,0x01,0x00,0x14,0x40,0xff,0xf9,0x00,0x63,0x00,0x18,0x24,0x63,0xff,0xff, +0x00,0x63,0x00,0x18,0x30,0x63,0x00,0xff,0x8c,0xe4,0x00,0x00,0x00,0x03,0x2a,0x00, +0x00,0x03,0x1c,0x00,0x00,0x00,0x10,0x12,0x00,0xc2,0x10,0x23,0x30,0x42,0x00,0xff, +0x00,0x45,0x10,0x21,0x00,0x43,0x10,0x21,0x00,0x82,0x20,0x25,0xac,0xe4,0x00,0x00, +0x8c,0xe2,0x00,0x00,0x3c,0x03,0x40,0x00,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x27,0xbd,0xff,0xe0,0xaf,0xbf,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, +0x3c,0x06,0xb0,0x03,0x34,0xc6,0x00,0x08,0x34,0x42,0x40,0x00,0xac,0x82,0x00,0x00, +0x8c,0x83,0x00,0x00,0x24,0x02,0xcf,0xff,0x3c,0x11,0xb0,0x07,0x00,0x62,0x18,0x24, +0xac,0x83,0x00,0x00,0x8c,0xc5,0x00,0x00,0x3c,0x02,0x00,0xff,0x24,0x04,0x00,0x0a, +0x00,0xa2,0x28,0x25,0xac,0xc5,0x00,0x00,0x0c,0x00,0x2e,0xda,0x36,0x31,0x00,0x18, +0x24,0x02,0xff,0x83,0x3c,0x04,0x00,0x01,0xa2,0x22,0x00,0x00,0x0c,0x00,0x2e,0x58, +0x34,0x84,0xc2,0x00,0x0c,0x00,0x2e,0xda,0x24,0x04,0x00,0x0a,0x24,0x02,0x00,0x03, +0xa2,0x22,0x00,0x00,0x24,0x04,0x00,0x0a,0x0c,0x00,0x2e,0xda,0x3c,0x10,0xb0,0x07, +0x36,0x10,0x00,0x10,0x24,0x02,0x00,0x06,0xa2,0x02,0x00,0x00,0x0c,0x00,0x2e,0xda, +0x24,0x04,0x00,0x0a,0xa2,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21, +0x24,0x63,0x00,0x01,0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34, +0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30, +0xaf,0xb3,0x00,0x2c,0xaf,0xb1,0x00,0x24,0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00, +0x00,0x80,0xa8,0x21,0x00,0xc0,0x90,0x21,0x00,0x07,0x1e,0x00,0x10,0x60,0x00,0x0f, +0x00,0x80,0x80,0x21,0x00,0x03,0x1e,0x03,0x24,0x02,0x00,0x25,0x10,0x62,0x00,0x13, +0x00,0x00,0x88,0x21,0xa2,0x07,0x00,0x00,0x8f,0xa5,0x00,0x44,0x26,0x10,0x00,0x01, +0x24,0xa5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x07,0x1e,0x00,0x14,0x60,0xff,0xf3,0x00,0x00,0x00,0x00,0x02,0x15,0x10,0x23, +0xa2,0x00,0x00,0x00,0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c, +0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x24,0xa5,0x00,0x01, +0xaf,0xa5,0x00,0x44,0x80,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xe0, +0x2c,0x62,0x00,0x11,0x10,0x40,0x00,0x11,0x00,0xa0,0x38,0x21,0x00,0x03,0x10,0x80, +0x3c,0x03,0x80,0x01,0x24,0x63,0x09,0xfc,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x2f,0x07, +0x36,0x31,0x00,0x10,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x08,0x08,0x00,0x2f,0x07, +0x36,0x31,0x00,0x20,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x04,0x90,0xe4,0x00,0x00, +0x3c,0x02,0x80,0x01,0x24,0x42,0x02,0x1c,0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04,0x14,0x60,0x00,0xfd,0x24,0x14,0xff,0xff, +0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2a,0x10,0x43,0x00,0xee, +0x26,0x42,0x00,0x03,0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x2e,0x10,0x62,0x00,0xcc, +0x24,0x08,0xff,0xff,0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x68,0x10,0x62,0x00,0xc4, +0x24,0x06,0xff,0xff,0x24,0x02,0x00,0x6c,0x10,0x62,0x00,0xc1,0x24,0x02,0x00,0x4c, +0x10,0x62,0x00,0xbf,0x24,0x02,0x00,0x5a,0x10,0x62,0x00,0xbd,0x00,0x00,0x00,0x00, +0x80,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xdb,0x2c,0x62,0x00,0x54, +0x10,0x40,0x00,0xaa,0x24,0x09,0x00,0x0a,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, +0x24,0x63,0x0a,0x40,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09, +0x24,0x02,0xff,0xfc,0x26,0x94,0xff,0xff,0x1a,0x80,0x00,0x05,0x24,0x02,0x00,0x20, +0x26,0x94,0xff,0xff,0xa2,0x02,0x00,0x00,0x1e,0x80,0xff,0xfd,0x26,0x10,0x00,0x01, +0x24,0x02,0xff,0xfc,0x26,0x44,0x00,0x03,0x00,0x82,0x90,0x24,0x92,0x42,0x00,0x03, +0x26,0x94,0xff,0xff,0x26,0x52,0x00,0x04,0xa2,0x02,0x00,0x00,0x1a,0x80,0x00,0x06, +0x26,0x10,0x00,0x01,0x24,0x02,0x00,0x20,0x26,0x94,0xff,0xff,0xa2,0x02,0x00,0x00, +0x1e,0x80,0xff,0xfd,0x26,0x10,0x00,0x01,0x8f,0xa5,0x00,0x44,0x08,0x00,0x2e,0xf9, +0x24,0xa5,0x00,0x01,0x24,0x02,0x00,0x25,0x08,0x00,0x2e,0xf6,0xa2,0x02,0x00,0x00, +0x36,0x31,0x00,0x40,0x24,0x09,0x00,0x10,0x24,0x02,0x00,0x4c,0x10,0xc2,0x00,0x2a, +0x24,0x02,0x00,0x6c,0x10,0xc2,0x00,0x05,0x24,0x02,0x00,0x5a,0x10,0xc2,0x00,0x1f, +0x24,0x02,0x00,0x68,0x10,0xc2,0x00,0x13,0x24,0x02,0xff,0xfc,0x24,0x02,0xff,0xfc, +0x26,0x43,0x00,0x03,0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02,0x8e,0x47,0x00,0x00, +0x00,0x00,0x30,0x21,0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x00,0xe0,0x10,0x21, +0x00,0x02,0x37,0xc3,0x02,0x00,0x20,0x21,0xaf,0xa9,0x00,0x10,0xaf,0xb4,0x00,0x14, +0xaf,0xa8,0x00,0x18,0x0c,0x00,0x30,0x47,0xaf,0xb1,0x00,0x1c,0x08,0x00,0x2f,0x62, +0x00,0x40,0x80,0x21,0x26,0x43,0x00,0x03,0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02, +0x96,0x47,0x00,0x02,0x00,0x00,0x30,0x21,0x10,0x40,0xff,0xf2,0x26,0x52,0x00,0x04, +0x00,0x07,0x14,0x00,0x08,0x00,0x2f,0x7c,0x00,0x02,0x3c,0x03,0x26,0x42,0x00,0x03, +0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x8e,0x47,0x00,0x00,0x00,0x00,0x30,0x21, +0x08,0x00,0x2f,0x7d,0x26,0x52,0x00,0x04,0x26,0x42,0x00,0x07,0x24,0x03,0xff,0xf8, +0x00,0x43,0x90,0x24,0x8e,0x46,0x00,0x00,0x8e,0x47,0x00,0x04,0x08,0x00,0x2f,0x7d, +0x26,0x52,0x00,0x08,0x08,0x00,0x2f,0x6a,0x36,0x31,0x00,0x02,0x26,0x44,0x00,0x03, +0x24,0x02,0xff,0xfc,0x00,0x82,0x90,0x24,0x8e,0x44,0x00,0x00,0x02,0x15,0x10,0x23, +0x26,0x52,0x00,0x04,0x08,0x00,0x2e,0xf8,0xac,0x82,0x00,0x00,0x08,0x00,0x2f,0x6a, +0x24,0x09,0x00,0x08,0x24,0x02,0xff,0xff,0x12,0x82,0x00,0x11,0x00,0x00,0x00,0x00, +0x26,0x43,0x00,0x03,0x24,0x02,0xff,0xfc,0x00,0x62,0x90,0x24,0x8e,0x47,0x00,0x00, +0x02,0x00,0x20,0x21,0x24,0x02,0x00,0x10,0x00,0x00,0x30,0x21,0xaf,0xa2,0x00,0x10, +0xaf,0xb4,0x00,0x14,0xaf,0xa8,0x00,0x18,0x0c,0x00,0x30,0x47,0xaf,0xb1,0x00,0x1c, +0x8f,0xa5,0x00,0x44,0x00,0x40,0x80,0x21,0x08,0x00,0x2e,0xf8,0x26,0x52,0x00,0x04, +0x24,0x14,0x00,0x08,0x08,0x00,0x2f,0xac,0x36,0x31,0x00,0x01,0x26,0x42,0x00,0x03, +0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x8e,0x53,0x00,0x00,0x00,0x00,0x00,0x00, +0x12,0x60,0x00,0x23,0x26,0x52,0x00,0x04,0x02,0x60,0x20,0x21,0x0c,0x00,0x31,0x15, +0x01,0x00,0x28,0x21,0x00,0x40,0x20,0x21,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09, +0x00,0x94,0x10,0x2a,0x10,0x40,0x00,0x07,0x26,0x94,0xff,0xff,0x24,0x03,0x00,0x20, +0x00,0x94,0x10,0x2a,0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff,0x14,0x40,0xff,0xfc, +0x26,0x10,0x00,0x01,0x18,0x80,0x00,0x07,0x00,0x80,0x18,0x21,0x92,0x62,0x00,0x00, +0x24,0x63,0xff,0xff,0x26,0x73,0x00,0x01,0xa2,0x02,0x00,0x00,0x14,0x60,0xff,0xfb, +0x26,0x10,0x00,0x01,0x00,0x94,0x10,0x2a,0x10,0x40,0xff,0x83,0x26,0x94,0xff,0xff, +0x24,0x03,0x00,0x20,0x00,0x94,0x10,0x2a,0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff, +0x14,0x40,0xff,0xfc,0x26,0x10,0x00,0x01,0x08,0x00,0x2f,0x62,0x00,0x00,0x00,0x00, +0x3c,0x02,0x80,0x01,0x08,0x00,0x2f,0xc6,0x24,0x53,0x08,0x04,0x24,0x02,0x00,0x25, +0xa2,0x02,0x00,0x00,0x8f,0xa5,0x00,0x44,0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x00, +0x90,0xa3,0x00,0x00,0x10,0x40,0x00,0x03,0x26,0x10,0x00,0x01,0x08,0x00,0x2e,0xf6, +0xa2,0x03,0x00,0x00,0x24,0xa5,0xff,0xff,0x08,0x00,0x2e,0xf8,0xaf,0xa5,0x00,0x44, +0x80,0xa6,0x00,0x00,0x24,0xa5,0x00,0x01,0x08,0x00,0x2f,0x3c,0xaf,0xa5,0x00,0x44, +0x24,0xa5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x90,0xa4,0x00,0x00,0x3c,0x02,0x80,0x01, +0x24,0x42,0x02,0x1c,0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x63,0x00,0x04,0x14,0x60,0x00,0x0f,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03, +0x24,0x03,0x00,0x2a,0x10,0x43,0x00,0x04,0x26,0x42,0x00,0x03,0x29,0x02,0x00,0x00, +0x08,0x00,0x2f,0x31,0x00,0x02,0x40,0x0b,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24, +0x24,0xa5,0x00,0x01,0x8e,0x48,0x00,0x00,0xaf,0xa5,0x00,0x44,0x08,0x00,0x30,0x0b, +0x26,0x52,0x00,0x04,0x0c,0x00,0x30,0x2b,0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44, +0x08,0x00,0x30,0x0b,0x00,0x40,0x40,0x21,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24, +0x8e,0x54,0x00,0x00,0x24,0xe5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x06,0x81,0xff,0x0d, +0x26,0x52,0x00,0x04,0x00,0x14,0xa0,0x23,0x08,0x00,0x2f,0x2d,0x36,0x31,0x00,0x10, +0x0c,0x00,0x30,0x2b,0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44,0x08,0x00,0x2f,0x2d, +0x00,0x40,0xa0,0x21,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x01,0x8c,0x86,0x00,0x00, +0x3c,0x02,0x80,0x01,0x00,0x80,0x48,0x21,0x90,0xc3,0x00,0x00,0x24,0x44,0x02,0x1c, +0x00,0x64,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x04, +0x10,0x40,0x00,0x10,0x00,0x00,0x38,0x21,0x00,0x80,0x40,0x21,0x24,0xc2,0x00,0x01, +0x80,0xc5,0x00,0x00,0xad,0x22,0x00,0x00,0x90,0x43,0x00,0x00,0x00,0x40,0x30,0x21, +0x00,0x07,0x10,0x80,0x00,0x68,0x18,0x21,0x90,0x64,0x00,0x00,0x00,0x47,0x10,0x21, +0x00,0x02,0x10,0x40,0x00,0x45,0x10,0x21,0x30,0x84,0x00,0x04,0x14,0x80,0xff,0xf3, +0x24,0x47,0xff,0xd0,0x03,0xe0,0x00,0x08,0x00,0xe0,0x10,0x21,0x27,0xbd,0xff,0x98, +0xaf,0xb2,0x00,0x50,0x8f,0xb2,0x00,0x84,0x3c,0x02,0x80,0x01,0xaf,0xb4,0x00,0x58, +0x32,0x43,0x00,0x40,0xaf,0xb1,0x00,0x4c,0xaf,0xb0,0x00,0x48,0xaf,0xb7,0x00,0x64, +0xaf,0xb6,0x00,0x60,0xaf,0xb5,0x00,0x5c,0xaf,0xb3,0x00,0x54,0x00,0x80,0x68,0x21, +0x00,0xc0,0x70,0x21,0x00,0xe0,0x78,0x21,0x8f,0xb0,0x00,0x78,0x8f,0xb8,0x00,0x7c, +0x8f,0xb1,0x00,0x80,0x10,0x60,0x00,0x03,0x24,0x54,0x08,0x0c,0x3c,0x02,0x80,0x01, +0x24,0x54,0x08,0x34,0x32,0x42,0x00,0x10,0x10,0x40,0x00,0x04,0x26,0x02,0xff,0xfe, +0x24,0x02,0xff,0xfe,0x02,0x42,0x90,0x24,0x26,0x02,0xff,0xfe,0x2c,0x42,0x00,0x23, +0x10,0x40,0x00,0x5d,0x00,0x00,0x18,0x21,0x32,0x42,0x00,0x01,0x24,0x15,0x00,0x30, +0x24,0x03,0x00,0x20,0x32,0x44,0x00,0x02,0x00,0x62,0xa8,0x0a,0x10,0x80,0x00,0x07, +0x00,0x00,0xb8,0x21,0x05,0xc0,0x00,0x96,0x32,0x42,0x00,0x04,0x10,0x40,0x00,0x90, +0x32,0x42,0x00,0x08,0x24,0x17,0x00,0x2b,0x27,0x18,0xff,0xff,0x32,0x56,0x00,0x20, +0x12,0xc0,0x00,0x07,0x01,0xcf,0x10,0x25,0x24,0x02,0x00,0x10,0x12,0x02,0x00,0x86, +0x27,0x03,0xff,0xff,0x3a,0x02,0x00,0x08,0x00,0x62,0xc0,0x0a,0x01,0xcf,0x10,0x25, +0x14,0x40,0x00,0x55,0x00,0x00,0xc8,0x21,0x24,0x02,0x00,0x30,0x24,0x19,0x00,0x01, +0xa3,0xa2,0x00,0x00,0x02,0x39,0x10,0x2a,0x03,0x22,0x88,0x0b,0x32,0x43,0x00,0x11, +0x14,0x60,0x00,0x0a,0x03,0x11,0xc0,0x23,0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x07, +0x27,0x18,0xff,0xff,0x24,0x03,0x00,0x20,0x03,0x00,0x10,0x21,0xa1,0xa3,0x00,0x00, +0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,0x12,0xe0,0x00,0x03, +0x00,0x00,0x00,0x00,0xa1,0xb7,0x00,0x00,0x25,0xad,0x00,0x01,0x12,0xc0,0x00,0x07, +0x32,0x42,0x00,0x10,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x38,0x24,0x02,0x00,0x10, +0x12,0x02,0x00,0x30,0x24,0x02,0x00,0x30,0x32,0x42,0x00,0x10,0x14,0x40,0x00,0x0a, +0x03,0x31,0x10,0x2a,0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x06,0x27,0x18,0xff,0xff, +0x03,0x00,0x10,0x21,0xa1,0xb5,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc, +0x25,0xad,0x00,0x01,0x03,0x31,0x10,0x2a,0x10,0x40,0x00,0x07,0x26,0x31,0xff,0xff, +0x24,0x03,0x00,0x30,0x03,0x31,0x10,0x2a,0xa1,0xa3,0x00,0x00,0x26,0x31,0xff,0xff, +0x14,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,0x03,0x20,0x10,0x21,0x18,0x40,0x00,0x08, +0x27,0x39,0xff,0xff,0x03,0xb9,0x10,0x21,0x90,0x43,0x00,0x00,0x03,0x20,0x20,0x21, +0x27,0x39,0xff,0xff,0xa1,0xa3,0x00,0x00,0x1c,0x80,0xff,0xfa,0x25,0xad,0x00,0x01, +0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x07,0x27,0x18,0xff,0xff,0x24,0x03,0x00,0x20, +0x03,0x00,0x10,0x21,0xa1,0xa3,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc, +0x25,0xad,0x00,0x01,0x01,0xa0,0x18,0x21,0x7b,0xb6,0x03,0x3c,0x7b,0xb4,0x02,0xfc, +0x7b,0xb2,0x02,0xbc,0x7b,0xb0,0x02,0x7c,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x68,0xa1,0xa2,0x00,0x00,0x92,0x83,0x00,0x21,0x25,0xad,0x00,0x01, +0xa1,0xa3,0x00,0x00,0x08,0x00,0x30,0x9a,0x25,0xad,0x00,0x01,0x24,0x02,0x00,0x30, +0x08,0x00,0x30,0xcd,0xa1,0xa2,0x00,0x00,0x01,0xcf,0x10,0x25,0x10,0x40,0xff,0xad, +0x00,0x00,0x60,0x21,0x00,0x0e,0x18,0x02,0x03,0x3d,0x98,0x21,0x00,0x60,0x20,0x21, +0x01,0xe0,0x38,0x21,0x10,0x60,0x00,0x04,0x27,0x39,0x00,0x01,0x00,0x70,0x00,0x1b, +0x00,0x00,0x20,0x12,0x00,0x00,0x18,0x10,0x00,0x80,0x48,0x21,0x00,0xe0,0x30,0x21, +0x01,0x80,0x70,0x21,0x01,0x80,0x28,0x21,0x10,0x00,0x00,0x06,0x24,0x04,0x00,0x21, +0x00,0x03,0x08,0x40,0x00,0x03,0x2f,0xc2,0x00,0x22,0x18,0x25,0x00,0x06,0x30,0x40, +0x00,0x0e,0x70,0x40,0x14,0xa0,0x00,0x02,0x00,0x70,0x10,0x2b,0x14,0x40,0x00,0x03, +0x24,0x84,0xff,0xff,0x00,0x70,0x18,0x23,0x25,0xce,0x00,0x01,0x14,0x80,0xff,0xf4, +0x00,0x06,0x17,0xc2,0x02,0x83,0x18,0x21,0x01,0xc0,0x38,0x21,0x00,0x00,0x50,0x21, +0x00,0x09,0x20,0x00,0x00,0x00,0x28,0x21,0x90,0x66,0x00,0x00,0x00,0x8a,0x70,0x25, +0x00,0xa7,0x78,0x25,0x01,0xcf,0x10,0x25,0x14,0x40,0xff,0xda,0xa2,0x66,0x00,0x00, +0x08,0x00,0x30,0x82,0x02,0x39,0x10,0x2a,0x08,0x00,0x30,0x7b,0x27,0x18,0xff,0xfe, +0x10,0x40,0xff,0x73,0x32,0x56,0x00,0x20,0x08,0x00,0x30,0x72,0x24,0x17,0x00,0x20, +0x00,0x0f,0x78,0x23,0x00,0x0e,0x70,0x23,0x00,0x0f,0x10,0x2b,0x01,0xc2,0x70,0x23, +0x08,0x00,0x30,0x72,0x24,0x17,0x00,0x2d,0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x06,0x00,0x80,0x18,0x21,0x24,0x63,0x00,0x01,0x80,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x64,0x10,0x23,0x24,0xa5,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xa2,0x00,0x0d, +0x00,0x80,0x18,0x21,0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, +0x00,0x00,0x00,0x00,0x24,0x06,0xff,0xff,0x24,0xa5,0xff,0xff,0x10,0xa6,0x00,0x05, +0x24,0x63,0x00,0x01,0x80,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x64,0x10,0x23,0x80,0x82,0x00,0x00, +0x90,0x88,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x48,0x21,0x90,0xa3,0x00,0x00, +0x00,0xa0,0x30,0x21,0x10,0x60,0x00,0x0b,0x00,0x60,0x38,0x21,0x00,0x08,0x16,0x00, +0x00,0x02,0x46,0x03,0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,0x11,0x02,0x00,0x05, +0x24,0xc6,0x00,0x01,0x90,0xc3,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf9, +0x00,0x60,0x38,0x21,0x00,0x03,0x16,0x00,0x10,0x40,0x00,0x06,0x00,0x00,0x00,0x00, +0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,0x25,0x29,0x00,0x01,0x14,0x40,0xff,0xeb, +0x00,0x40,0x40,0x21,0x03,0xe0,0x00,0x08,0x01,0x20,0x10,0x21,0x80,0x82,0x00,0x00, +0x90,0x87,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x18,0x21,0x90,0xa2,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x0c,0x00,0xa0,0x30,0x21, +0x00,0x07,0x16,0x00,0x00,0x02,0x3e,0x03,0x00,0x03,0x16,0x03,0x10,0xe2,0x00,0x0d, +0x00,0x80,0x18,0x21,0x24,0xc6,0x00,0x01,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x1e,0x00,0x14,0x60,0xff,0xf9,0x00,0x03,0x16,0x03,0x24,0x84,0x00,0x01, +0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec,0x00,0x40,0x38,0x21, +0x00,0x00,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0, +0xaf,0xb0,0x00,0x10,0x8f,0x90,0xc5,0x5c,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18, +0x00,0x84,0x80,0x0b,0x00,0x00,0x30,0x21,0x12,0x00,0x00,0x0a,0x00,0xa0,0x88,0x21, +0x0c,0x00,0x31,0x27,0x02,0x00,0x20,0x21,0x02,0x02,0x80,0x21,0x82,0x02,0x00,0x00, +0x02,0x20,0x28,0x21,0x02,0x00,0x20,0x21,0x14,0x40,0x00,0x07,0x00,0x00,0x30,0x21, +0xaf,0x80,0xc5,0x5c,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x31,0x43,0x00,0x00,0x00,0x00, +0x00,0x40,0x18,0x21,0x10,0x40,0x00,0x07,0x02,0x00,0x30,0x21,0x80,0x42,0x00,0x00, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0xa0,0x60,0x00,0x00, +0x24,0x63,0x00,0x01,0xaf,0x83,0xc5,0x5c,0x08,0x00,0x31,0x71,0x00,0x00,0x00,0x00, +0x24,0xc6,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xc2,0x00,0x05,0x00,0x80,0x18,0x21, +0x24,0xc6,0xff,0xff,0xa0,0x65,0x00,0x00,0x14,0xc2,0xff,0xfd,0x24,0x63,0x00,0x01, +0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0xc6,0xff,0xff,0x24,0x02,0xff,0xff, +0x10,0xc2,0x00,0x08,0x00,0x80,0x18,0x21,0x24,0x07,0xff,0xff,0x90,0xa2,0x00,0x00, +0x24,0xc6,0xff,0xff,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x00,0x14,0xc7,0xff,0xfb, +0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x00,0x80,0x18,0x21, +0x90,0xa2,0x00,0x00,0x24,0xa5,0x00,0x01,0xa0,0x82,0x00,0x00,0x14,0x40,0xff,0xfc, +0x24,0x84,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x90,0x83,0x00,0x00, +0x90,0xa2,0x00,0x00,0x24,0x84,0x00,0x01,0x00,0x62,0x10,0x23,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0x14,0x40,0x00,0x03,0x24,0xa5,0x00,0x01,0x14,0x60,0xff,0xf7, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x10,0x21,0x93,0x85,0x88,0x6d,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x53, +0x00,0x80,0x40,0x21,0x8c,0x89,0x00,0x04,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21, +0x8c,0xc3,0x00,0x04,0x3c,0x02,0x01,0x00,0x00,0x62,0x10,0x24,0x10,0x40,0x00,0x4b, +0x30,0x62,0x00,0x08,0x10,0x45,0x00,0x59,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38, +0x24,0x03,0x00,0xb4,0x30,0x44,0x00,0xff,0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4, +0x10,0x82,0x00,0x54,0x24,0x02,0x00,0x94,0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00, +0x94,0xc2,0x00,0x38,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff, +0x24,0x02,0x40,0x88,0x14,0x62,0x00,0x39,0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00, +0x10,0x62,0x00,0x38,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00, +0x30,0x47,0xff,0xff,0x30,0xe2,0x00,0x80,0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01, +0x01,0x22,0x30,0x21,0x94,0xc3,0x00,0x60,0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b, +0x00,0x00,0x00,0x00,0x90,0xc2,0x00,0x62,0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02, +0x10,0xe3,0x00,0x15,0x24,0x02,0x00,0x06,0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00, +0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x66,0x27,0x82,0x92,0x48,0x00,0x05,0x28,0x80, +0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00, +0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00, +0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00, +0x08,0x00,0x32,0x17,0xad,0x07,0x00,0x10,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64, +0x27,0x82,0x92,0x48,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21, +0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25, +0x24,0x42,0x00,0x36,0x3c,0x03,0xff,0xff,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24, +0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x50,0x08,0x00,0x31,0xd5,0x30,0x47,0xff,0xff, +0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, +0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e, +0xac,0x82,0x00,0x00,0x24,0x03,0x00,0x2e,0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80, +0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24, +0x34,0x42,0x00,0x0e,0x24,0x03,0x00,0x0e,0x08,0x00,0x32,0x16,0xac,0x82,0x00,0x00, +0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, +0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14, +0x24,0x03,0x00,0x14,0x08,0x00,0x32,0x16,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xc6,0x00,0xff,0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x8b,0xc5,0x70,0x27,0x83,0xc5,0x76,0x00,0x4b,0x40,0x21, +0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x00,0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29, +0x30,0x8a,0xff,0xff,0x95,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82, +0x30,0x42,0x00,0x01,0x10,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x4b,0x30,0x21,0x94,0xc4,0x00,0x02,0x27,0x83,0xc5,0x76, +0x27,0x85,0xc5,0x74,0x00,0x45,0x28,0x21,0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21, +0xa4,0xc4,0x00,0x02,0xa4,0x40,0x00,0x00,0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02, +0x3c,0x04,0xb0,0x01,0x01,0x44,0x20,0x21,0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02, +0xa0,0xc0,0x00,0x00,0x8c,0x82,0x00,0x04,0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24, +0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x04,0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01, +0x00,0xa2,0x10,0x24,0x00,0x47,0x28,0x25,0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02, +0x14,0x82,0xff,0xe2,0x01,0x43,0x18,0x21,0xac,0x65,0x00,0x00,0x08,0x00,0x32,0x44, +0x01,0x26,0x10,0x21,0x08,0x00,0x32,0x44,0x01,0x26,0x10,0x21,0x93,0x83,0x88,0x6d, +0x24,0x02,0x00,0x01,0x14,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04, +0x3c,0x06,0xb0,0x09,0x00,0x82,0x20,0x21,0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04, +0x3c,0x02,0x01,0x00,0x34,0xc6,0x01,0x00,0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05, +0x30,0xa5,0x20,0x00,0x24,0x02,0x00,0x06,0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x09,0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00, +0x24,0x02,0x00,0x0e,0x08,0x00,0x32,0x77,0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01, +0x30,0xa5,0xff,0xff,0x00,0xa2,0x28,0x21,0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00, +0x00,0x80,0x30,0x21,0x00,0x62,0x18,0x24,0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x42,0x80,0x00,0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00, +0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, +0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x93,0x83,0x88,0x6c,0x00,0x02,0x11,0x83, +0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8, +0xa3,0x83,0x88,0x6c,0x8c,0xc4,0x01,0xac,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00, +0x00,0x44,0x10,0x26,0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x88,0x6d, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x88,0x6d, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01, +0x00,0x80,0x50,0x21,0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05, +0x00,0x03,0x1a,0x02,0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07, +0x11,0x22,0x00,0x09,0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b, +0x11,0x22,0x00,0x05,0x24,0x02,0x00,0x01,0x93,0x83,0x88,0x6c,0x3c,0x04,0xb0,0x06, +0x10,0x62,0x00,0x03,0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa, +0x00,0x00,0x00,0x00,0x8d,0x43,0x01,0xa8,0x27,0x82,0x92,0x48,0x00,0x03,0x18,0x80, +0x00,0x6a,0x20,0x21,0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00, +0x00,0xe5,0x28,0x21,0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x93,0x48, +0x01,0x22,0x10,0x24,0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8, +0x00,0x07,0x30,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, +0x00,0x06,0x32,0x00,0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00, +0x3c,0x03,0x80,0x00,0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04, +0xaf,0x87,0xc5,0x60,0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xc5,0x68, +0x8c,0xa3,0x00,0x04,0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8, +0xaf,0x83,0xc5,0x64,0x93,0x85,0x88,0x6c,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, +0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, +0x24,0xa5,0xff,0xff,0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x88,0x6c, +0x08,0x00,0x32,0xc2,0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0xa5,0x00,0x20,0x24,0x42,0xcb,0xe8,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02, +0x24,0x03,0x00,0x20,0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60, +0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c, +0xac,0x80,0x00,0x50,0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58, +0xa0,0x80,0x00,0x5c,0x24,0x42,0xcc,0xac,0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f, +0x24,0xa5,0xff,0xff,0xac,0x62,0x00,0x00,0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04, +0x3c,0x02,0x80,0x01,0x24,0x42,0xcd,0xdc,0xac,0x82,0x00,0x78,0x3c,0x03,0x80,0x01, +0x3c,0x02,0x80,0x01,0x24,0x63,0xcf,0x68,0x24,0x42,0xce,0xd4,0xac,0x83,0x00,0x88, +0xac,0x82,0x00,0x98,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x24,0x63,0xd0,0x10, +0x24,0x42,0xd1,0x28,0xac,0x83,0x00,0xa0,0xac,0x82,0x00,0xa4,0xa0,0x80,0x01,0xba, +0xac,0x80,0x01,0xa8,0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,0xac,0x80,0x01,0xb4, +0xa0,0x80,0x01,0xb8,0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0xcc,0xac,0x03,0xe0,0x00,0x08, +0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8, +0x34,0x63,0x00,0x20,0x24,0x42,0xcc,0xc4,0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00, +0xaf,0xbf,0x00,0x14,0x8c,0x83,0x00,0x10,0x8f,0x82,0x94,0xe8,0x00,0x80,0x80,0x21, +0x3c,0x04,0x80,0x01,0x30,0x46,0x00,0x01,0x10,0x60,0x00,0x11,0x24,0x84,0x08,0x64, +0x8e,0x02,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00, +0x8e,0x05,0x00,0x10,0x8e,0x03,0x00,0x14,0x8e,0x02,0x00,0x04,0x00,0xa3,0x28,0x21, +0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02, +0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04, +0x14,0xc0,0x00,0x0a,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c, +0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x8e,0x05,0x00,0x10, +0x8e,0x07,0x00,0x04,0x8e,0x06,0x00,0x14,0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00, +0x08,0x00,0x33,0x53,0xae,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x63,0x00,0x20,0x24,0x42,0xcd,0x88,0xac,0x62,0x00,0x00,0x8c,0x86,0x00,0x04, +0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21,0x8c,0x45,0x00,0x00, +0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff,0x30,0x42,0x00,0xff, +0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14,0xac,0x85,0x00,0x40, +0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xcd,0xdc, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21,0xae,0x00,0x00,0x00, +0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c, +0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x0c,0x00,0x33,0x62,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0x84,0xae,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, +0x24,0x63,0xce,0x40,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, +0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21, +0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44,0x00,0x62,0x18,0x21, +0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50,0x30,0xa3,0x00,0xff, +0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f,0x30,0x42,0x00,0x03, +0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c,0xae,0x03,0x00,0x30, +0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0x62,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0x9c, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, +0x34,0x42,0x00,0x20,0x24,0x63,0xce,0xd4,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, +0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16, +0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40,0x83,0x85,0x95,0x14, +0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02,0xae,0x04,0x00,0x14, +0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04,0xae,0x03,0x00,0x3c, +0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01,0x24,0x02,0x00,0x01, +0xa3,0x86,0x95,0x14,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0x90,0x00,0x00,0x00,0x00, +0x08,0x00,0x33,0xc1,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, +0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xcf,0x68,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03,0x8c,0x42,0x00,0x00, +0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x95,0x14,0x92,0x05,0x00,0x41, +0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2,0x00,0x03,0x1e,0x02, +0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21,0xae,0x03,0x00,0x18, +0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03,0x24,0x02,0x00,0x01, +0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x95,0x14,0x8f,0xbf,0x00,0x14, +0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x0c,0x00,0x33,0x90,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0xe6,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, +0x24,0x63,0xd0,0x10,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, +0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21, +0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01, +0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04, +0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21, +0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0x92,0x48,0x00,0x62,0x18,0x21, +0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21, +0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80,0x27,0x82,0x93,0x48,0x00,0x62,0x18,0x21, +0x0c,0x00,0x31,0xb1,0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04, +0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40, +0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80, +0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8, +0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x88,0x6c,0x02,0x00,0x20,0x21, +0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x88,0x6c, +0x0c,0x00,0x33,0x31,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0xda,0x00,0x00,0x00,0x00, +0x08,0x00,0x34,0x10,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, +0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xd1,0x28,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44, +0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21, +0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac, +0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80, +0x27,0x82,0x92,0x48,0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04, +0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80, +0x27,0x82,0x93,0x48,0x00,0x62,0x18,0x21,0x0c,0x00,0x31,0xb1,0xac,0x66,0x00,0x00, +0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01, +0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83, +0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21, +0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00, +0x93,0x82,0x88,0x6c,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01, +0xac,0xc3,0x00,0x00,0xa3,0x82,0x88,0x6c,0x0c,0x00,0x33,0x31,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x0c,0x00,0x33,0xda,0x00,0x00,0x00,0x00,0x08,0x00,0x34,0x56,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xd2,0x40, +0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x80,0x21, +0x24,0x52,0xcc,0xac,0x00,0x00,0x88,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x00,0x06, +0x8e,0x06,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x06,0x22,0x02,0x00,0x44,0x10,0x23, +0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a, +0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff,0x10,0x44,0x00,0x68, +0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x01,0x00,0xc2,0x10,0x21,0x8c,0x44,0x00,0x04, +0x3c,0x03,0x7c,0x00,0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24,0xae,0x04,0x00,0x44, +0x8c,0x44,0x00,0x00,0x10,0x60,0x00,0x69,0x00,0x00,0x38,0x21,0x3c,0x09,0xb0,0x03, +0x3c,0x06,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01,0x24,0x08,0x00,0x40, +0x34,0xc6,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38,0x16,0x20,0x00,0x06, +0x24,0xa5,0x00,0x01,0x93,0x82,0x88,0xa0,0x24,0x11,0x00,0x01,0x24,0x42,0x00,0x01, +0xa1,0x22,0x00,0x00,0xa3,0x82,0x88,0xa0,0x8e,0x02,0x00,0x04,0x24,0x07,0x00,0x01, +0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04,0x00,0x4a,0x10,0x21, +0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44,0x8c,0x44,0x00,0x00, +0x10,0xa8,0x00,0x2d,0x00,0x66,0x18,0x24,0x14,0x60,0xff,0xec,0x00,0x8b,0x10,0x24, +0x14,0x4c,0xff,0xea,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x2f,0x3c,0x03,0xb0,0x09, +0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42,0x00,0x02,0x12,0x02, +0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00,0x10,0x44,0x00,0x1a, +0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58,0x00,0x00,0x00,0x00, +0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50, +0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68,0x00,0x00,0x00,0x00, +0x10,0x52,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09,0x02,0x00,0x20,0x21, +0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x60, +0x08,0x00,0x34,0x9e,0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64,0x00,0x00,0x00,0x00, +0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c,0x8f,0xbf,0x00,0x1c, +0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26,0x00,0x02,0x10,0x2b, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x34,0x63,0x00,0x06,0x8e,0x04,0x00,0x04, +0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40, +0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83, +0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x14,0x87,0xff,0xc5,0x00,0x00,0x00,0x00, +0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03,0x14,0x40,0x00,0x05, +0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01,0x08,0x00,0x34,0xfe, +0xa2,0x02,0x00,0x5c,0x08,0x00,0x34,0xfe,0xa2,0x00,0x00,0x5c,0x3c,0x02,0xff,0xff, +0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,0x14,0x43,0xff,0x94,0x24,0x02,0x00,0x01, +0x08,0x00,0x34,0xd6,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, +0x34,0x42,0x00,0x20,0x24,0x63,0xd4,0x98,0xac,0x43,0x00,0x00,0x8c,0x83,0x01,0xa8, +0x8c,0x82,0x01,0xac,0x00,0x80,0x40,0x21,0x10,0x62,0x00,0x20,0x00,0x00,0x20,0x21, +0x93,0x82,0x88,0x6d,0x00,0x03,0x28,0x80,0x3c,0x07,0xb0,0x06,0x00,0xa8,0x18,0x21, +0x24,0x04,0x00,0x01,0x8c,0x66,0x00,0xa8,0x10,0x44,0x00,0x1c,0x34,0xe7,0x80,0x18, +0x3c,0x05,0xb0,0x01,0xaf,0x86,0xc5,0x60,0x00,0xc5,0x28,0x21,0x8c,0xa3,0x00,0x00, +0x00,0x06,0x20,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00,0x00,0x82,0x20,0x25, +0xaf,0x83,0xc5,0x68,0x8c,0xa2,0x00,0x04,0xac,0xe4,0x00,0x00,0x8d,0x03,0x01,0xa8, +0xaf,0x82,0xc5,0x64,0x24,0x64,0x00,0x01,0x04,0x80,0x00,0x0a,0x00,0x80,0x10,0x21, +0x00,0x02,0x11,0x83,0x8d,0x03,0x01,0xac,0x00,0x02,0x11,0x80,0x00,0x82,0x10,0x23, +0x00,0x43,0x18,0x26,0xad,0x02,0x01,0xa8,0x00,0x03,0x20,0x2b,0x03,0xe0,0x00,0x08, +0x00,0x80,0x10,0x21,0x08,0x00,0x35,0x48,0x24,0x62,0x00,0x40,0x27,0x82,0x92,0x48, +0x00,0x06,0x20,0xc2,0x00,0x04,0x22,0x00,0x00,0xa2,0x48,0x21,0x3c,0x02,0x00,0x80, +0x00,0x82,0x58,0x25,0x93,0x82,0x88,0x6c,0x3c,0x0a,0xb0,0x06,0x3c,0x03,0xb0,0x01, +0x2c,0x42,0x00,0x02,0x00,0xc3,0x38,0x21,0x35,0x4a,0x80,0x18,0x14,0x40,0xff,0xef, +0x00,0x00,0x20,0x21,0x8c,0xe5,0x00,0x00,0x8d,0x23,0x00,0x00,0x24,0x02,0xc0,0x00, +0x00,0xa2,0x10,0x24,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00,0x8d,0x04,0x01,0xa8, +0x27,0x83,0x93,0x48,0x8c,0xe5,0x00,0x04,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, +0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0xa2,0x10,0x25,0x00,0x43,0x10,0x25, +0xac,0xe2,0x00,0x04,0xaf,0x86,0xc5,0x60,0x8c,0xe2,0x00,0x00,0x93,0x85,0x88,0x6c, +0xaf,0x82,0xc5,0x68,0x8c,0xe3,0x00,0x04,0xad,0x4b,0x00,0x00,0x8d,0x02,0x01,0xa8, +0xaf,0x83,0xc5,0x64,0x24,0xa5,0xff,0xff,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, +0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, +0x00,0x82,0x20,0x23,0xad,0x04,0x01,0xa8,0xa3,0x85,0x88,0x6c,0x79,0x02,0x0d,0x7c, +0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x26,0x08,0x00,0x35,0x4f,0x00,0x02,0x20,0x2b, +0x90,0x87,0x00,0x00,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x24,0x48,0x02,0x1c, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x01,0x07,0x18,0x21,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x10,0x40,0x00,0x0a,0x00,0x00,0x80,0x21, +0x24,0x84,0x00,0x01,0x90,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x18,0x21, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x14,0x40,0xff,0xf8, +0x00,0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2d, +0x10,0x43,0x00,0x0f,0x00,0x00,0x00,0x00,0x0c,0x00,0x35,0xb3,0x00,0x00,0x00,0x00, +0x00,0x40,0x18,0x21,0x00,0x02,0x10,0x23,0x04,0x61,0x00,0x05,0x00,0x70,0x10,0x0a, +0x16,0x00,0x00,0x03,0x3c,0x02,0x80,0x00,0x3c,0x02,0x7f,0xff,0x34,0x42,0xff,0xff, +0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x24,0x10,0xff,0xff,0x08,0x00,0x35,0xa2,0x24,0x84,0x00,0x01,0x00,0x80,0x38,0x21, +0x90,0x84,0x00,0x00,0x3c,0x02,0x80,0x01,0x24,0x48,0x02,0x1c,0x01,0x04,0x18,0x21, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x10,0x40,0x00,0x0a, +0x00,0x00,0x50,0x21,0x24,0xe7,0x00,0x01,0x90,0xe4,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x04,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20, +0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03, +0x38,0x42,0x00,0x2b,0x24,0xe3,0x00,0x01,0x24,0x04,0x00,0x10,0x10,0xc4,0x00,0x38, +0x00,0x62,0x38,0x0a,0x90,0xe4,0x00,0x00,0x14,0xc0,0x00,0x07,0x00,0x80,0x18,0x21, +0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x30,0x10,0x43,0x00,0x25, +0x24,0x06,0x00,0x0a,0x00,0x80,0x18,0x21,0x00,0x03,0x16,0x00,0x10,0x40,0x00,0x1a, +0x30,0x64,0x00,0xff,0x24,0x82,0xff,0xa9,0x2c,0x83,0x00,0x61,0x30,0x48,0x00,0xff, +0x10,0x60,0x00,0x09,0x2c,0x89,0x00,0x41,0x24,0x82,0xff,0xc9,0x30,0x48,0x00,0xff, +0x11,0x20,0x00,0x05,0x2c,0x83,0x00,0x3a,0x24,0x82,0xff,0xd0,0x14,0x60,0x00,0x02, +0x30,0x48,0x00,0xff,0x24,0x08,0x00,0xff,0x01,0x06,0x10,0x2a,0x10,0x40,0x00,0x0a, +0x01,0x46,0x00,0x18,0x24,0xe7,0x00,0x01,0x00,0x00,0x18,0x12,0x00,0x6a,0x10,0x2b, +0x14,0x40,0x00,0x0a,0x00,0x68,0x50,0x21,0x80,0xe2,0x00,0x00,0x90,0xe3,0x00,0x00, +0x14,0x40,0xff,0xe8,0x30,0x64,0x00,0xff,0x10,0xa0,0x00,0x02,0x00,0x00,0x00,0x00, +0xac,0xa7,0x00,0x00,0x03,0xe0,0x00,0x08,0x01,0x40,0x10,0x21,0x03,0xe0,0x00,0x08, +0x24,0x02,0xff,0xff,0x24,0x06,0x00,0x08,0x80,0xe3,0x00,0x01,0x24,0x02,0x00,0x78, +0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x58,0x14,0x62,0xff,0xd7,0x00,0x80,0x18,0x21, +0x24,0xe7,0x00,0x02,0x90,0xe4,0x00,0x00,0x08,0x00,0x35,0xd5,0x24,0x06,0x00,0x10, +0x80,0xe3,0x00,0x00,0x24,0x02,0x00,0x30,0x90,0xe4,0x00,0x00,0x10,0x62,0xff,0xf2, +0x00,0x00,0x00,0x00,0x08,0x00,0x35,0xce,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x03, +0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01,0x34,0xc6,0x00,0x18,0x34,0x84,0x00,0x20, +0x24,0x42,0xd8,0x2c,0x24,0x03,0xff,0x83,0xac,0x82,0x00,0x00,0xa0,0xc3,0x00,0x00, +0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8,0x3c,0x03,0xb0,0x07,0x24,0x02,0xff,0x82, +0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00,0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07, +0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01,0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00, +0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07,0xa3,0xa3,0x00,0x00,0xa0,0xc2,0x00,0x00, +0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10,0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x07, +0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38,0xa0,0xa2,0x00,0x00,0x90,0x64,0x00,0x00, +0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20,0xa3,0xa4,0x00,0x00,0xa0,0xa0,0x00,0x00, +0x90,0xa3,0x00,0x00,0xaf,0x82,0xc8,0x70,0xa3,0xa3,0x00,0x00,0xa0,0x40,0x00,0x00, +0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,}; + +u8 Rtl8190PciFwDataArray[DataArrayLengthPci] = { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x0d,0x5b,0x43,0x4d,0x50,0x4b,0x5d,0x00,0x00,0x00,0x00, +0x80,0x01,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08, +0x08,0x08,0x08,0x08,0x08,0x28,0x28,0x28,0x28,0x28,0x08,0x08,0x08,0x08,0x08,0x08, +0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xa0,0x10,0x10,0x10, +0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x04,0x04,0x04,0x04, +0x04,0x04,0x04,0x04,0x04,0x04,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x41,0x41,0x41, +0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, +0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,0x10,0x10,0x42,0x42,0x42, +0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, +0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,0x08,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x10,0x10,0x10, +0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, +0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x01,0x01,0x01,0x01, +0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, +0x01,0x01,0x01,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02, +0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, +0x02,0x02,0x02,0x10,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x20,0x09,0x0d,0x0a, +0x00,0x00,0x00,0x00,0x80,0x01,0x03,0x1c,0x00,0x00,0x00,0x00,0x43,0x6e,0x73,0x64, +0x31,0x00,0x00,0x00,0x68,0x65,0x6c,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x72,0x34,0x00,0x00,0x77,0x34,0x00,0x00,0x64,0x62,0x67,0x00,0x72,0x61,0x63,0x74, +0x72,0x6c,0x00,0x00,0x73,0x79,0x73,0x64,0x00,0x00,0x00,0x00,0x73,0x79,0x73,0x63, +0x74,0x72,0x6c,0x00,0x74,0x78,0x74,0x62,0x6c,0x00,0x00,0x00,0x70,0x72,0x61,0x6e, +0x67,0x65,0x00,0x00,0x64,0x6d,0x00,0x00,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x00,0x00, +0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, +0x00,0x00,0x00,0x00,0x80,0x00,0x24,0x5c,0x80,0x01,0x03,0x40,0x80,0x01,0x03,0x3c, +0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x25,0xbc, +0x80,0x01,0x03,0x44,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, +0x00,0x00,0x00,0x00,0x80,0x00,0x27,0x38,0x80,0x01,0x03,0x48,0x80,0x01,0x03,0x3c, +0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0x04, +0x80,0x01,0x03,0x4c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, +0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xdc,0x80,0x01,0x03,0x54,0x80,0x01,0x03,0x3c, +0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xe4, +0x80,0x01,0x03,0x5c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, +0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xec,0x80,0x01,0x03,0x64,0x80,0x01,0x03,0x3c, +0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xf4, +0x80,0x01,0x03,0x6c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, +0x00,0x00,0x00,0x00,0x80,0x00,0x2b,0x80,0x80,0x01,0x03,0x74,0x80,0x01,0x03,0x3c, +0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x2b,0xf4, +0x80,0x01,0x03,0x78,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x0f, +0x00,0x00,0x00,0x01,0x80,0x00,0x2c,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0a,0x0d,0x52,0x54,0x4c,0x38,0x31,0x39,0x58,0x2d,0x25,0x64,0x3e,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x52,0x54,0x4c,0x38,0x31,0x39,0x58,0x2d,0x25,0x64,0x3e,0x0a, +0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72, +0x72,0x20,0x44,0x49,0x52,0x00,0x00,0x00,0x0a,0x0d,0x44,0x42,0x47,0x20,0x43,0x4d, +0x44,0x73,0x3a,0x00,0x0a,0x0d,0x5b,0x00,0x5d,0x2d,0x00,0x00,0x0a,0x0d,0x3c,0x31, +0x2e,0x43,0x4d,0x4e,0x3e,0x20,0x3c,0x32,0x2e,0x3f,0x3e,0x00,0x0a,0x0d,0x20,0x79, +0x65,0x61,0x72,0x2d,0x64,0x61,0x79,0x2d,0x68,0x6f,0x75,0x72,0x2d,0x6d,0x69,0x6e, +0x2d,0x73,0x65,0x63,0x2d,0x31,0x30,0x6d,0x73,0x3d,0x00,0x00,0x25,0x64,0x2d,0x00, +0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x20,0x20,0x20,0x20,0x20,0x20, +0x20,0x30,0x34,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x38,0x20,0x20,0x20,0x20, +0x20,0x20,0x20,0x30,0x43,0x00,0x00,0x00,0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20, +0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d, +0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d, +0x3d,0x3d,0x3d,0x00,0x0d,0x0a,0x20,0x30,0x78,0x25,0x30,0x38,0x58,0x20,0x20,0x00, +0x09,0x00,0x00,0x00,0x25,0x30,0x38,0x58,0x20,0x00,0x00,0x00,0x0a,0x0d,0x44,0x62, +0x67,0x5f,0x46,0x6c,0x61,0x67,0x25,0x64,0x3d,0x30,0x78,0x25,0x30,0x38,0x78,0x00, +0x0a,0x0d,0x54,0x58,0x4c,0x4c,0x54,0x09,0x09,0x4e,0x45,0x58,0x54,0x20,0x20,0x20, +0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4e,0x45,0x58,0x54,0x0a,0x0d,0x00, +0x0a,0x0d,0x20,0x50,0x61,0x67,0x65,0x25,0x33,0x64,0x09,0x00,0x25,0x34,0x64,0x20, +0x20,0x20,0x20,0x00,0x25,0x34,0x64,0x20,0x20,0x20,0x20,0x09,0x00,0x00,0x00,0x00, +0x0a,0x0d,0x54,0x58,0x4f,0x51,0x54,0x09,0x09,0x48,0x65,0x61,0x64,0x20,0x20,0x20, +0x20,0x54,0x61,0x69,0x6c,0x20,0x20,0x20,0x20,0x48,0x65,0x61,0x64,0x20,0x20,0x20, +0x20,0x54,0x61,0x69,0x6c,0x0a,0x0d,0x00,0x0a,0x0d,0x55,0x6e,0x6b,0x6e,0x6f,0x77, +0x20,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72, +0x72,0x20,0x41,0x72,0x67,0x0a,0x0d,0x55,0x53,0x41,0x47,0x45,0x3a,0x00,0x00,0x00, +0x10,0x00,0x08,0x00,0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4, +0x00,0xab,0x00,0x72,0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c, +0x02,0x76,0x01,0x3b,0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f, +0x01,0x3b,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20, +0x01,0x2f,0x00,0x98,0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e, +0x00,0x98,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f, +0x02,0x39,0x01,0x1c,0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39, +0x01,0x1c,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c, +0x01,0x11,0x00,0x89,0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b, +0x00,0x89,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e, +0x02,0xab,0x02,0xab,0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08, +0x04,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x54,0x4c,0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c, +0x5f,0x64,0x61,0x74,0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00, +0x41,0x64,0x45,0x4c,0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00, +0x00,0x00,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78, +0x63,0x43,0x6f,0x64,0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x42,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x4f,0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x01,0x14,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10, +0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48, +0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20, +0x00,0x00,0x01,0x80,0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68, +0x00,0x00,0x00,0x9c,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0, +0x00,0x00,0x01,0xd4,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0, +0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40, +0x00,0x00,0x03,0xa8,0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02, +0x03,0x03,0x04,0x04,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04, +0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x3c,0x4e,0x55,0x4c,0x4c,0x3e,0x00,0x00,0x30,0x31,0x32,0x33, +0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a, +0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a, +0x00,0x00,0x00,0x00,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42, +0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52, +0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x5b,0x52,0x58,0x5d,0x20,0x70,0x6b,0x74,0x5f,0x6c,0x65,0x6e, +0x3d,0x25,0x64,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,0x25,0x64,0x20,0x73,0x74, +0x61,0x72,0x74,0x5f,0x61,0x64,0x64,0x72,0x3d,0x25,0x30,0x38,0x78,0x0a,0x0d,0x00, +0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x6c,0x80,0x00,0x07,0x80,0x80,0x00,0x07,0x80, +0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x94,0x80,0x00,0x76,0x50, +0x80,0x00,0x76,0xa4,0x80,0x00,0x76,0xc0,0x80,0x00,0x77,0xac,0x80,0x00,0x78,0x64, +0x80,0x00,0x79,0x10,0x80,0x00,0x79,0x7c,0x80,0x00,0x7a,0x88,0x80,0x00,0x7a,0xbc, +0x80,0x00,0x7a,0xd0,0x80,0x00,0x7a,0xe4,0x80,0x00,0x7b,0x90,0x80,0x00,0x7b,0xcc, +0x80,0x00,0x7c,0x7c,0x80,0x00,0x7c,0xa4,0x80,0x00,0x76,0x0c,0x80,0x00,0x7c,0xe8, +0x80,0x00,0x83,0x74,0x80,0x00,0x83,0xec,0x80,0x00,0x83,0xf8,0x80,0x00,0x84,0x04, +0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, +0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, +0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, +0x80,0x00,0x84,0x10,0x80,0x00,0x84,0x1c,0x80,0x00,0x84,0x28,0x80,0x00,0xa6,0xb4, +0x80,0x00,0xa6,0xb4,0x80,0x00,0xa6,0xb4,0x80,0x00,0xa6,0xe8,0x80,0x00,0xa7,0x28, +0x80,0x00,0xa7,0x60,0x80,0x00,0xa7,0x90,0x80,0x00,0xa7,0xc0,0x80,0x00,0xa7,0xd4, +0x80,0x00,0xa8,0x3c,0x80,0x00,0xa8,0x50,0x80,0x00,0xa8,0x8c,0x80,0x00,0xa8,0x94, +0x80,0x00,0xa8,0xd0,0x80,0x00,0xa8,0xe4,0x80,0x00,0xa8,0xec,0x80,0x00,0xa8,0xf4, +0x80,0x00,0xa8,0xf4,0x80,0x00,0xa8,0xf4,0x80,0x00,0xa8,0xf4,0x80,0x00,0xa9,0x24, +0x80,0x00,0xa9,0x38,0x80,0x00,0xa9,0x4c,0x80,0x00,0xa5,0xf8,0x80,0x00,0xac,0x78, +0x80,0x00,0xac,0x78,0x80,0x00,0xac,0x78,0x80,0x00,0xac,0xac,0x80,0x00,0xac,0xec, +0x80,0x00,0xad,0x24,0x80,0x00,0xad,0x54,0x80,0x00,0xad,0x84,0x80,0x00,0xad,0x98, +0x80,0x00,0xae,0x00,0x80,0x00,0xae,0x14,0x80,0x00,0xae,0x50,0x80,0x00,0xae,0x58, +0x80,0x00,0xae,0x94,0x80,0x00,0xae,0xa8,0x80,0x00,0xae,0xb0,0x80,0x00,0xae,0xb8, +0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xe8, +0x80,0x00,0xae,0xfc,0x80,0x00,0xaf,0x10,0x80,0x00,0xaa,0x98,0x80,0x00,0xbc,0x64, +0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x6c,0x80,0x00,0xbc,0x7c, +0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c, +0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x74,0x80,0x00,0xbc,0x7c, +0x80,0x00,0xbc,0x5c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xc0,0xa4, +0x80,0x00,0xbd,0x94,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0xa0, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0x28,0x80,0x00,0xbe,0x74, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbe,0x74,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbe,0x7c,0x80,0x00,0xbe,0x9c,0x80,0x00,0xbe,0xa4, +0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbe,0xfc,0x80,0x00,0xbf,0xac, +0x80,0x00,0xbd,0xa8,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0xa4, +}; + + +u32 Rtl8190PciPHY_REGArray[PHY_REGArrayLengthPci] = { +0x800,0x00050060, +0x804,0x00000005, +0x808,0x0000fc00, +0x80c,0x0000001c, +0x810,0x801010aa, +0x814,0x000908c0, +0x818,0x00000000, +0x81c,0x00000000, +0x820,0x00000004, +0x824,0x00690000, +0x828,0x00000004, +0x82c,0x00e90000, +0x830,0x00000004, +0x834,0x00690000, +0x838,0x00000004, +0x83c,0x00e90000, +0x840,0x00000000, +0x844,0x00000000, +0x848,0x00000000, +0x84c,0x00000000, +0x850,0x00000000, +0x854,0x00000000, +0x858,0x65a965a9, +0x85c,0x65a965a9, +0x860,0x001f0010, +0x864,0x007f0010, +0x868,0x001f0010, +0x86c,0x007f0010, +0x870,0x0f100f70, +0x874,0x0f100f70, +0x878,0x00000000, +0x87c,0x00000000, +0x880,0x5c385eb8, +0x884,0x6357060d, +0x888,0x0460c341, +0x88c,0x0000ff00, +0x890,0x00000000, +0x894,0xfffffffe, +0x898,0x4c42382f, +0x89c,0x00656056, +0x8b0,0x00000000, +0x8e0,0x00000000, +0x8e4,0x00000000, +0x900,0x00000000, +0x904,0x00000023, +0x908,0x00000000, +0x90c,0x35541545, +0xa00,0x00d0c7d8, +0xa04,0xab1f0008, +0xa08,0x80cd8300, +0xa0c,0x2e62740f, +0xa10,0x95009b78, +0xa14,0x11145008, +0xa18,0x00881117, +0xa1c,0x89140fa0, +0xa20,0x1a1b0000, +0xa24,0x090e1317, +0xa28,0x00000204, +0xa2c,0x00000000, +0xc00,0x00000040, +0xc04,0x0000500f, +0xc08,0x000000e4, +0xc0c,0x6c6c6c6c, +0xc10,0x08000000, +0xc14,0x40000100, +0xc18,0x08000000, +0xc1c,0x40000100, +0xc20,0x08000000, +0xc24,0x40000100, +0xc28,0x08000000, +0xc2c,0x40000100, +0xc30,0x6de9ac44, +0xc34,0x164052cd, +0xc38,0x00070a14, +0xc3c,0x0a969764, +0xc40,0x1f7c403f, +0xc44,0x000100b7, +0xc48,0xec020000, +0xc4c,0x00000300, +0xc50,0x69543420, +0xc54,0x433c0094, +0xc58,0x69543420, +0xc5c,0x433c0094, +0xc60,0x69543420, +0xc64,0x433c0094, +0xc68,0x69543420, +0xc6c,0x433c0094, +0xc70,0x2c7f000d, +0xc74,0x0186175b, +0xc78,0x0000001f, +0xc7c,0x00b91612, +0xc80,0x40000100, +0xc84,0x00000000, +0xc88,0x40000100, +0xc8c,0x08000000, +0xc90,0x40000100, +0xc94,0x00000000, +0xc98,0x40000100, +0xc9c,0x00000000, +0xca0,0x00492492, +0xca4,0x00000000, +0xca8,0x00000000, +0xcac,0x00000000, +0xcb0,0x00000000, +0xcb4,0x00000000, +0xcb8,0x00000000, +0xcbc,0x00492492, +0xcc0,0x00000000, +0xcc4,0x00000000, +0xcc8,0x00000000, +0xccc,0x00000000, +0xcd0,0x00000000, +0xcd4,0x00000000, +0xcd8,0x64b22427, +0xcdc,0x00766932, +0xce0,0x00222222, +0xd00,0x00000740, +0xd04,0x0000040f, +0xd08,0x0000803f, +0xd0c,0x00000001, +0xd10,0xa0633333, +0xd14,0x33333c63, +0xd18,0x6a8f5b6b, +0xd1c,0x00000000, +0xd20,0x00000000, +0xd24,0x00000000, +0xd28,0x00000000, +0xd2c,0xcc979975, +0xd30,0x00000000, +0xd34,0x00000000, +0xd38,0x00000000, +0xd3c,0x00027293, +0xd40,0x00000000, +0xd44,0x00000000, +0xd48,0x00000000, +0xd4c,0x00000000, +0xd50,0x6437140a, +0xd54,0x024dbd02, +0xd58,0x00000000, +0xd5c,0x14032064, +}; + +u32 Rtl8190PciPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPci] = { +0x800,0x00050060, +0x804,0x00000004, +0x808,0x0000fc00, +0x80c,0x0000001c, +0x810,0x801010aa, +0x814,0x000908c0, +0x818,0x00000000, +0x81c,0x00000000, +0x820,0x00000004, +0x824,0x00690000, +0x828,0x00000004, +0x82c,0x00e90000, +0x830,0x00000004, +0x834,0x00690000, +0x838,0x00000004, +0x83c,0x00e90000, +0x840,0x00000000, +0x844,0x00000000, +0x848,0x00000000, +0x84c,0x00000000, +0x850,0x00000000, +0x854,0x00000000, +0x858,0x65a965a9, +0x85c,0x65a965a9, +0x860,0x001f0000, +0x864,0x007f0000, +0x868,0x001f0010, +0x86c,0x007f0010, +0x870,0x0f100f70, +0x874,0x0f100f70, +0x878,0x00000000, +0x87c,0x00000000, +0x880,0x5c385898, +0x884,0x6357060d, +0x888,0x0460c341, +0x88c,0x0000fc00, +0x890,0x00000000, +0x894,0xfffffffe, +0x898,0x4c42382f, +0x89c,0x00656056, +0x8b0,0x00000000, +0x8e0,0x00000000, +0x8e4,0x00000000, +0x900,0x00000000, +0x904,0x00000023, +0x908,0x00000000, +0x90c,0x34441444, +0xa00,0x00d0c7d8, +0xa04,0x2b1f0008, +0xa08,0x80cd8300, +0xa0c,0x2e62740f, +0xa10,0x95009b78, +0xa14,0x11145008, +0xa18,0x00881117, +0xa1c,0x89140fa0, +0xa20,0x1a1b0000, +0xa24,0x090e1317, +0xa28,0x00000204, +0xa2c,0x00000000, +0xc00,0x00000040, +0xc04,0x0000500c, +0xc08,0x000000e4, +0xc0c,0x6c6c6c6c, +0xc10,0x08000000, +0xc14,0x40000100, +0xc18,0x08000000, +0xc1c,0x40000100, +0xc20,0x08000000, +0xc24,0x40000100, +0xc28,0x08000000, +0xc2c,0x40000100, +0xc30,0x6de9ac44, +0xc34,0x164052cd, +0xc38,0x00070a14, +0xc3c,0x0a969764, +0xc40,0x1f7c403f, +0xc44,0x000100b7, +0xc48,0xec020000, +0xc4c,0x00000300, +0xc50,0x69543420, +0xc54,0x433c0094, +0xc58,0x69543420, +0xc5c,0x433c0094, +0xc60,0x69543420, +0xc64,0x433c0094, +0xc68,0x69543420, +0xc6c,0x433c0094, +0xc70,0x2c7f000d, +0xc74,0x0186175b, +0xc78,0x0000001f, +0xc7c,0x00b91612, +0xc80,0x40000100, +0xc84,0x00000000, +0xc88,0x40000100, +0xc8c,0x08000000, +0xc90,0x40000100, +0xc94,0x00000000, +0xc98,0x40000100, +0xc9c,0x00000000, +0xca0,0x00492492, +0xca4,0x00000000, +0xca8,0x00000000, +0xcac,0x00000000, +0xcb0,0x00000000, +0xcb4,0x00000000, +0xcb8,0x00000000, +0xcbc,0x00492492, +0xcc0,0x00000000, +0xcc4,0x00000000, +0xcc8,0x00000000, +0xccc,0x00000000, +0xcd0,0x00000000, +0xcd4,0x00000000, +0xcd8,0x64b22427, +0xcdc,0x00766932, +0xce0,0x00222222, +0xd00,0x00000740, +0xd04,0x0000040c, +0xd08,0x0000803f, +0xd0c,0x00000001, +0xd10,0xa0633333, +0xd14,0x33333c63, +0xd18,0x6a8f5b6b, +0xd1c,0x00000000, +0xd20,0x00000000, +0xd24,0x00000000, +0xd28,0x00000000, +0xd2c,0xcc979975, +0xd30,0x00000000, +0xd34,0x00000000, +0xd38,0x00000000, +0xd3c,0x00027293, +0xd40,0x00000000, +0xd44,0x00000000, +0xd48,0x00000000, +0xd4c,0x00000000, +0xd50,0x6437140a, +0xd54,0x024dbd02, +0xd58,0x00000000, +0xd5c,0x14032064, +}; + +u32 Rtl8190PciRadioA_Array[RadioA_ArrayLengthPci] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x00000ee0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x009,0x000007f0, +0x00a,0x000009d0, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x00f,0x00000990, +0x012,0x00000806, +0x014,0x000005ab, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000f80, +0x01b,0x00000f5e, +0x01c,0x00000008, +0x01d,0x00000607, +0x01e,0x000006cc, +0x01f,0x00000000, +0x020,0x000001a5, +0x01f,0x00000001, +0x020,0x00000165, +0x01f,0x00000002, +0x020,0x000000c6, +0x01f,0x00000003, +0x020,0x00000086, +0x01f,0x00000004, +0x020,0x00000046, +0x01f,0x00000005, +0x020,0x000001e6, +0x01f,0x00000006, +0x020,0x000001a6, +0x01f,0x00000007, +0x020,0x00000166, +0x01f,0x00000008, +0x020,0x000000c7, +0x01f,0x00000009, +0x020,0x00000087, +0x01f,0x0000000a, +0x020,0x000000f7, +0x01f,0x0000000b, +0x020,0x000000d7, +0x01f,0x0000000c, +0x020,0x000000b7, +0x01f,0x0000000d, +0x020,0x00000097, +0x01f,0x0000000e, +0x020,0x00000077, +0x01f,0x0000000f, +0x020,0x00000057, +0x01f,0x00000010, +0x020,0x00000037, +0x01f,0x00000011, +0x020,0x000000fb, +0x01f,0x00000012, +0x020,0x000000db, +0x01f,0x00000013, +0x020,0x000000bb, +0x01f,0x00000014, +0x020,0x000000ff, +0x01f,0x00000015, +0x020,0x000000e3, +0x01f,0x00000016, +0x020,0x000000c3, +0x01f,0x00000017, +0x020,0x000000a3, +0x01f,0x00000018, +0x020,0x00000083, +0x01f,0x00000019, +0x020,0x00000063, +0x01f,0x0000001a, +0x020,0x00000043, +0x01f,0x0000001b, +0x020,0x00000023, +0x01f,0x0000001c, +0x020,0x00000003, +0x01f,0x0000001d, +0x020,0x000001e3, +0x01f,0x0000001e, +0x020,0x000001c3, +0x01f,0x0000001f, +0x020,0x000001a3, +0x01f,0x00000020, +0x020,0x00000183, +0x01f,0x00000021, +0x020,0x00000163, +0x01f,0x00000022, +0x020,0x00000143, +0x01f,0x00000023, +0x020,0x00000123, +0x01f,0x00000024, +0x020,0x00000103, +0x023,0x00000203, +0x024,0x00000200, +0x00b,0x000001ba, +0x02c,0x000003d7, +0x02d,0x00000ff0, +0x000,0x00000037, +0x004,0x00000160, +0x007,0x00000080, +0x002,0x0000088d, +0x0fe,0x00000000, +0x0fe,0x00000000, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x000,0x000000bf, +0x00d,0x0000001f, +0x00d,0x00000c9f, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8190PciRadioB_Array[RadioB_ArrayLengthPci] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x000006e0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x000,0x000000b7, +0x00a,0x00000850, +0x000,0x000000bf, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000e00, +0x01b,0x00000f5e, +0x01d,0x00000607, +0x01e,0x000006cc, +0x00b,0x000001ba, +0x023,0x00000203, +0x024,0x00000200, +0x000,0x00000037, +0x004,0x00000160, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x00d,0x00000ccc, +0x000,0x000000bf, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8190PciRadioC_Array[RadioC_ArrayLengthPci] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x00000ee0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x009,0x000007f0, +0x00a,0x000009d0, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x00f,0x00000990, +0x012,0x00000806, +0x014,0x000005ab, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000f80, +0x01b,0x00000f5e, +0x01c,0x00000008, +0x01d,0x00000607, +0x01e,0x000006cc, +0x01f,0x00000000, +0x020,0x000001a5, +0x01f,0x00000001, +0x020,0x00000165, +0x01f,0x00000002, +0x020,0x000000c6, +0x01f,0x00000003, +0x020,0x00000086, +0x01f,0x00000004, +0x020,0x00000046, +0x01f,0x00000005, +0x020,0x000001e6, +0x01f,0x00000006, +0x020,0x000001a6, +0x01f,0x00000007, +0x020,0x00000166, +0x01f,0x00000008, +0x020,0x000000c7, +0x01f,0x00000009, +0x020,0x00000087, +0x01f,0x0000000a, +0x020,0x000000f7, +0x01f,0x0000000b, +0x020,0x000000d7, +0x01f,0x0000000c, +0x020,0x000000b7, +0x01f,0x0000000d, +0x020,0x00000097, +0x01f,0x0000000e, +0x020,0x00000077, +0x01f,0x0000000f, +0x020,0x00000057, +0x01f,0x00000010, +0x020,0x00000037, +0x01f,0x00000011, +0x020,0x000000fb, +0x01f,0x00000012, +0x020,0x000000db, +0x01f,0x00000013, +0x020,0x000000bb, +0x01f,0x00000014, +0x020,0x000000ff, +0x01f,0x00000015, +0x020,0x000000e3, +0x01f,0x00000016, +0x020,0x000000c3, +0x01f,0x00000017, +0x020,0x000000a3, +0x01f,0x00000018, +0x020,0x00000083, +0x01f,0x00000019, +0x020,0x00000063, +0x01f,0x0000001a, +0x020,0x00000043, +0x01f,0x0000001b, +0x020,0x00000023, +0x01f,0x0000001c, +0x020,0x00000003, +0x01f,0x0000001d, +0x020,0x000001e3, +0x01f,0x0000001e, +0x020,0x000001c3, +0x01f,0x0000001f, +0x020,0x000001a3, +0x01f,0x00000020, +0x020,0x00000183, +0x01f,0x00000021, +0x020,0x00000163, +0x01f,0x00000022, +0x020,0x00000143, +0x01f,0x00000023, +0x020,0x00000123, +0x01f,0x00000024, +0x020,0x00000103, +0x023,0x00000203, +0x024,0x00000200, +0x00b,0x000001ba, +0x02c,0x000003d7, +0x02d,0x00000ff0, +0x000,0x00000037, +0x004,0x00000160, +0x007,0x00000080, +0x002,0x0000088d, +0x0fe,0x00000000, +0x0fe,0x00000000, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x000,0x000000bf, +0x00d,0x0000001f, +0x00d,0x00000c9f, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8190PciRadioD_Array[RadioD_ArrayLengthPci] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x000006e0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x000,0x000000b7, +0x00a,0x00000850, +0x000,0x000000bf, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000e00, +0x01b,0x00000f5e, +0x01d,0x00000607, +0x01e,0x000006cc, +0x00b,0x000001ba, +0x023,0x00000203, +0x024,0x00000200, +0x000,0x00000037, +0x004,0x00000160, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x00d,0x00000ccc, +0x000,0x000000bf, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8190PciMACPHY_Array[] = { +0x03c,0xffff0000,0x00000f0f, +0x340,0xffffffff,0x161a1a1a, +0x344,0xffffffff,0x12121416, +0x348,0x0000ffff,0x00001818, +0x12c,0xffffffff,0x04000802, +0x318,0x00000fff,0x00000800, +}; + +u32 Rtl8190PciMACPHY_Array_PG[] = { +0x03c,0xffff0000,0x00000f0f, +0x340,0xffffffff,0x0a0c0d0f, +0x344,0xffffffff,0x06070809, +0x344,0xffffffff,0x06070809, +0x348,0x0000ffff,0x00000000, +0x12c,0xffffffff,0x04000802, +0x318,0x00000fff,0x00000800, +}; + +u32 Rtl8190PciAGCTAB_Array[AGCTAB_ArrayLengthPci] = { +0xc78,0x7d000001, +0xc78,0x7d010001, +0xc78,0x7d020001, +0xc78,0x7d030001, +0xc78,0x7c040001, +0xc78,0x7b050001, +0xc78,0x7a060001, +0xc78,0x79070001, +0xc78,0x78080001, +0xc78,0x77090001, +0xc78,0x760a0001, +0xc78,0x750b0001, +0xc78,0x740c0001, +0xc78,0x730d0001, +0xc78,0x720e0001, +0xc78,0x710f0001, +0xc78,0x70100001, +0xc78,0x6f110001, +0xc78,0x6e120001, +0xc78,0x6d130001, +0xc78,0x6c140001, +0xc78,0x6b150001, +0xc78,0x6a160001, +0xc78,0x69170001, +0xc78,0x68180001, +0xc78,0x67190001, +0xc78,0x661a0001, +0xc78,0x651b0001, +0xc78,0x641c0001, +0xc78,0x491d0001, +0xc78,0x481e0001, +0xc78,0x471f0001, +0xc78,0x46200001, +0xc78,0x45210001, +0xc78,0x44220001, +0xc78,0x43230001, +0xc78,0x28240001, +0xc78,0x27250001, +0xc78,0x26260001, +0xc78,0x25270001, +0xc78,0x24280001, +0xc78,0x23290001, +0xc78,0x222a0001, +0xc78,0x212b0001, +0xc78,0x202c0001, +0xc78,0x0a2d0001, +0xc78,0x082e0001, +0xc78,0x062f0001, +0xc78,0x05300001, +0xc78,0x04310001, +0xc78,0x03320001, +0xc78,0x02330001, +0xc78,0x01340001, +0xc78,0x00350001, +0xc78,0x00360001, +0xc78,0x00370001, +0xc78,0x00380001, +0xc78,0x00390001, +0xc78,0x003a0001, +0xc78,0x003b0001, +0xc78,0x003c0001, +0xc78,0x003d0001, +0xc78,0x003e0001, +0xc78,0x003f0001, +0xc78,0x7d400001, +0xc78,0x7d410001, +0xc78,0x7d420001, +0xc78,0x7d430001, +0xc78,0x7c440001, +0xc78,0x7b450001, +0xc78,0x7a460001, +0xc78,0x79470001, +0xc78,0x78480001, +0xc78,0x77490001, +0xc78,0x764a0001, +0xc78,0x754b0001, +0xc78,0x744c0001, +0xc78,0x734d0001, +0xc78,0x724e0001, +0xc78,0x714f0001, +0xc78,0x70500001, +0xc78,0x6f510001, +0xc78,0x6e520001, +0xc78,0x6d530001, +0xc78,0x6c540001, +0xc78,0x6b550001, +0xc78,0x6a560001, +0xc78,0x69570001, +0xc78,0x68580001, +0xc78,0x67590001, +0xc78,0x665a0001, +0xc78,0x655b0001, +0xc78,0x645c0001, +0xc78,0x495d0001, +0xc78,0x485e0001, +0xc78,0x475f0001, +0xc78,0x46600001, +0xc78,0x45610001, +0xc78,0x44620001, +0xc78,0x43630001, +0xc78,0x28640001, +0xc78,0x27650001, +0xc78,0x26660001, +0xc78,0x25670001, +0xc78,0x24680001, +0xc78,0x23690001, +0xc78,0x226a0001, +0xc78,0x216b0001, +0xc78,0x206c0001, +0xc78,0x0a6d0001, +0xc78,0x086e0001, +0xc78,0x066f0001, +0xc78,0x05700001, +0xc78,0x04710001, +0xc78,0x03720001, +0xc78,0x02730001, +0xc78,0x01740001, +0xc78,0x00750001, +0xc78,0x00760001, +0xc78,0x00770001, +0xc78,0x00780001, +0xc78,0x00790001, +0xc78,0x007a0001, +0xc78,0x007b0001, +0xc78,0x007c0001, +0xc78,0x007d0001, +0xc78,0x007e0001, +0xc78,0x007f0001, +0xc78,0x3600001e, +0xc78,0x3601001e, +0xc78,0x3602001e, +0xc78,0x3603001e, +0xc78,0x3604001e, +0xc78,0x3605001e, +0xc78,0x3a06001e, +0xc78,0x3c07001e, +0xc78,0x3e08001e, +0xc78,0x4209001e, +0xc78,0x430a001e, +0xc78,0x450b001e, +0xc78,0x470c001e, +0xc78,0x480d001e, +0xc78,0x490e001e, +0xc78,0x4b0f001e, +0xc78,0x4c10001e, +0xc78,0x4d11001e, +0xc78,0x4d12001e, +0xc78,0x4e13001e, +0xc78,0x4f14001e, +0xc78,0x5015001e, +0xc78,0x5116001e, +0xc78,0x5117001e, +0xc78,0x5218001e, +0xc78,0x5219001e, +0xc78,0x531a001e, +0xc78,0x541b001e, +0xc78,0x541c001e, +0xc78,0x551d001e, +0xc78,0x561e001e, +0xc78,0x561f001e, +0xc78,0x5720001e, +0xc78,0x5821001e, +0xc78,0x5822001e, +0xc78,0x5923001e, +0xc78,0x5924001e, +0xc78,0x5a25001e, +0xc78,0x5b26001e, +0xc78,0x5b27001e, +0xc78,0x5c28001e, +0xc78,0x5c29001e, +0xc78,0x5d2a001e, +0xc78,0x5d2b001e, +0xc78,0x5e2c001e, +0xc78,0x5e2d001e, +0xc78,0x5f2e001e, +0xc78,0x602f001e, +0xc78,0x6030001e, +0xc78,0x6131001e, +0xc78,0x6132001e, +0xc78,0x6233001e, +0xc78,0x6234001e, +0xc78,0x6335001e, +0xc78,0x6336001e, +0xc78,0x6437001e, +0xc78,0x6538001e, +0xc78,0x6639001e, +0xc78,0x663a001e, +0xc78,0x673b001e, +0xc78,0x683c001e, +0xc78,0x693d001e, +0xc78,0x6a3e001e, +0xc78,0x6b3f001e, +}; + +#endif diff --git a/drivers/staging/rtl8192e/r8190P_hwimg.h b/drivers/staging/rtl8192e/r8190P_hwimg.h new file mode 100644 index 00000000000..18aef43737d --- /dev/null +++ b/drivers/staging/rtl8192e/r8190P_hwimg.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_HAL8190Pci_FW_IMG_H +#define __INC_HAL8190Pci_FW_IMG_H + +/*Created on 2008/12/ 3, 3:26*/ + +#include + +#define BootArrayLengthPci 344 +extern u8 Rtl8190PciFwBootArray[BootArrayLengthPci]; +#define MainArrayLengthPci 55388 +extern u8 Rtl8190PciFwMainArray[MainArrayLengthPci]; +#define DataArrayLengthPci 2960 +extern u8 Rtl8190PciFwDataArray[DataArrayLengthPci]; +#define PHY_REGArrayLengthPci 280 +extern u32 Rtl8190PciPHY_REGArray[PHY_REGArrayLengthPci]; +#define PHY_REG_1T2RArrayLengthPci 280 +extern u32 Rtl8190PciPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPci]; +#define RadioA_ArrayLengthPci 246 +extern u32 Rtl8190PciRadioA_Array[RadioA_ArrayLengthPci] ; +#define RadioB_ArrayLengthPci 78 +extern u32 Rtl8190PciRadioB_Array[RadioB_ArrayLengthPci] ; +#define RadioC_ArrayLengthPci 246 +extern u32 Rtl8190PciRadioC_Array[RadioC_ArrayLengthPci] ; +#define RadioD_ArrayLengthPci 78 +extern u32 Rtl8190PciRadioD_Array[RadioD_ArrayLengthPci] ; +#define MACPHY_ArrayLengthPci 18 +extern u32 Rtl8190PciMACPHY_Array[MACPHY_ArrayLengthPci] ; +#define MACPHY_Array_PGLengthPci 21 +extern u32 Rtl8190PciMACPHY_Array_PG[MACPHY_Array_PGLengthPci] ; +#define AGCTAB_ArrayLengthPci 384 +extern u32 Rtl8190PciAGCTAB_Array[AGCTAB_ArrayLengthPci] ; + +#endif diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c new file mode 100644 index 00000000000..26709e5b61c --- /dev/null +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -0,0 +1,366 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#include "rtl_core.h" +#ifdef RTL8192SE +#include "rtl8192s/r8192S_phyreg.h" +#include "rtl8192s/r8192S_phy.h" +#else +#include "r8192E_phyreg.h" +#include "r8192E_phy.h" +#endif +#include "r8190P_rtl8256.h" + +void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) +{ + u8 eRFPath; + struct r8192_priv *priv = rtllib_priv(dev); + + for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { + if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + continue; + + switch (Bandwidth) { + case HT_CHANNEL_WIDTH_20: + if (priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7); + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021); + + } else { + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + } + + break; + case HT_CHANNEL_WIDTH_20_40: + if (priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3ff); + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0e1); + + } else { + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + } + + + break; + default: + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ); + break; + + } + } + return; +} + +bool PHY_RF8256_Config(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool rtStatus = true; + priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH; + rtStatus = phy_RF8256_Config_ParaFile(dev); + + return rtStatus; +} + +bool phy_RF8256_Config_ParaFile(struct net_device* dev) +{ + u32 u4RegValue = 0; + u8 eRFPath; + bool rtStatus = true; + BB_REGISTER_DEFINITION_T *pPhyReg; + struct r8192_priv *priv = rtllib_priv(dev); + u32 RegOffSetToBeCheck = 0x3; + u32 RegValueToBeCheck = 0x7f1; + u32 RF3_Final_Value = 0; + u8 ConstRetryTimes = 5, RetryTimes = 5; + u8 ret = 0; + + for (eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { + if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + continue; + + pPhyReg = &priv->PHYRegDef[eRFPath]; + + + switch (eRFPath) { + case RF90_PATH_A: + case RF90_PATH_C: + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV); + break; + case RF90_PATH_B : + case RF90_PATH_D: + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16); + break; + } + + rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + + rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); + + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); + + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); + + rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath); + if (rtStatus!= true) { + RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); + goto phy_RF8256_Config_ParaFile_Fail; + } + + RetryTimes = ConstRetryTimes; + RF3_Final_Value = 0; + switch (eRFPath) { + case RF90_PATH_A: + while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + RetryTimes--; + } + break; + case RF90_PATH_B: + while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + RetryTimes--; + } + break; + case RF90_PATH_C: + while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + RetryTimes--; + } + break; + case RF90_PATH_D: + while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + RetryTimes--; + } + break; + } + + switch (eRFPath) { + case RF90_PATH_A: + case RF90_PATH_C: + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + break; + case RF90_PATH_B : + case RF90_PATH_D: + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + break; + } + + if (ret) { + RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); + goto phy_RF8256_Config_ParaFile_Fail; + } + + } + + RT_TRACE(COMP_PHY, "PHY Initialization Success\n") ; + return true; + +phy_RF8256_Config_ParaFile_Fail: + RT_TRACE(COMP_ERR, "PHY Initialization failed\n") ; + return false; +} + +#ifndef RTL8192SE +void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) +{ + u32 TxAGC=0; + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef RTL8190P + u8 byte0, byte1; + + TxAGC |= ((powerlevel<<8)|powerlevel); + TxAGC += priv->CCKTxPowerLevelOriginalOffset; + + if (priv->bDynamicTxLowPower == true + /*pMgntInfo->bScanInProgress == true*/ ) + { + if (priv->CustomerID == RT_CID_819x_Netcore) + TxAGC = 0x2222; + else + TxAGC += ((priv->CckPwEnl<<8)|priv->CckPwEnl); + } + + byte0 = (u8)(TxAGC & 0xff); + byte1 = (u8)((TxAGC & 0xff00)>>8); + if (byte0 > 0x24) + byte0 = 0x24; + if (byte1 > 0x24) + byte1 = 0x24; + if (priv->rf_type == RF_2T4R) + { + if (priv->RF_C_TxPwDiff > 0) + { + if ( (byte0 + (u8)priv->RF_C_TxPwDiff) > 0x24) + byte0 = 0x24 - priv->RF_C_TxPwDiff; + if ( (byte1 + (u8)priv->RF_C_TxPwDiff) > 0x24) + byte1 = 0x24 - priv->RF_C_TxPwDiff; + } + } + TxAGC = (byte1<<8) |byte0; + write_nic_dword(dev, CCK_TXAGC, TxAGC); +#else + #ifdef RTL8192E + + TxAGC = powerlevel; + if (priv->bDynamicTxLowPower == true) + { + if (priv->CustomerID == RT_CID_819x_Netcore) + TxAGC = 0x22; + else + TxAGC += priv->CckPwEnl; + } + if (TxAGC > 0x24) + TxAGC = 0x24; + rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC); + #endif +#endif +} + + +void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) +{ + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef RTL8190P + u32 TxAGC1=0, TxAGC2=0, TxAGC2_tmp = 0; + u8 i, byteVal1[4], byteVal2[4], byteVal3[4]; + + if (priv->bDynamicTxHighPower == true) + { + TxAGC1 |= ((powerlevel<<24)|(powerlevel<<16)|(powerlevel<<8)|powerlevel); + TxAGC2_tmp = TxAGC1; + + TxAGC1 += priv->MCSTxPowerLevelOriginalOffset[0]; + TxAGC2 =0x03030303; + + TxAGC2_tmp += priv->MCSTxPowerLevelOriginalOffset[1]; + } + else + { + TxAGC1 |= ((powerlevel<<24)|(powerlevel<<16)|(powerlevel<<8)|powerlevel); + TxAGC2 = TxAGC1; + + TxAGC1 += priv->MCSTxPowerLevelOriginalOffset[0]; + TxAGC2 += priv->MCSTxPowerLevelOriginalOffset[1]; + + TxAGC2_tmp = TxAGC2; + + } + for (i=0; i<4; i++) + { + byteVal1[i] = (u8)( (TxAGC1 & (0xff<<(i*8))) >>(i*8) ); + if (byteVal1[i] > 0x24) + byteVal1[i] = 0x24; + byteVal2[i] = (u8)( (TxAGC2 & (0xff<<(i*8))) >>(i*8) ); + if (byteVal2[i] > 0x24) + byteVal2[i] = 0x24; + + byteVal3[i] = (u8)( (TxAGC2_tmp & (0xff<<(i*8))) >>(i*8) ); + if (byteVal3[i] > 0x24) + byteVal3[i] = 0x24; + } + + if (priv->rf_type == RF_2T4R) + { + if (priv->RF_C_TxPwDiff > 0) + { + for (i=0; i<4; i++) + { + if ( (byteVal1[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) + byteVal1[i] = 0x24 - priv->RF_C_TxPwDiff; + if ( (byteVal2[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) + byteVal2[i] = 0x24 - priv->RF_C_TxPwDiff; + if ( (byteVal3[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) + byteVal3[i] = 0x24 - priv->RF_C_TxPwDiff; + } + } + } + + TxAGC1 = (byteVal1[3]<<24) | (byteVal1[2]<<16) |(byteVal1[1]<<8) |byteVal1[0]; + TxAGC2 = (byteVal2[3]<<24) | (byteVal2[2]<<16) |(byteVal2[1]<<8) |byteVal2[0]; + + TxAGC2_tmp = (byteVal3[3]<<24) | (byteVal3[2]<<16) |(byteVal3[1]<<8) |byteVal3[0]; + priv->Pwr_Track = TxAGC2_tmp; + + write_nic_dword(dev, MCS_TXAGC, TxAGC1); + write_nic_dword(dev, MCS_TXAGC+4, TxAGC2); +#else +#ifdef RTL8192E + u32 writeVal, powerBase0, powerBase1, writeVal_tmp; + u8 index = 0; + u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c}; + u8 byte0, byte1, byte2, byte3; + + powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; + powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0; + powerBase1 = powerlevel; + powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1; + + for (index=0; index<6; index++) + { + writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1)); + byte0 = (u8)(writeVal & 0x7f); + byte1 = (u8)((writeVal & 0x7f00)>>8); + byte2 = (u8)((writeVal & 0x7f0000)>>16); + byte3 = (u8)((writeVal & 0x7f000000)>>24); + if (byte0 > 0x24) + byte0 = 0x24; + if (byte1 > 0x24) + byte1 = 0x24; + if (byte2 > 0x24) + byte2 = 0x24; + if (byte3 > 0x24) + byte3 = 0x24; + + if (index == 3) + { + writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; + priv->Pwr_Track = writeVal_tmp; + } + + if (priv->bDynamicTxHighPower == true) + { + writeVal = 0x03030303; + } + else + { + writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; + } + rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); + } + +#endif +#endif + return; +} + + + +#endif diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h new file mode 100644 index 00000000000..08bcb6213ac --- /dev/null +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -0,0 +1,34 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#ifndef RTL8225H +#define RTL8225H + +#ifdef RTL8190P +#define RTL819X_TOTAL_RF_PATH 4 +#else +#define RTL819X_TOTAL_RF_PATH 2 +#endif +extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); +extern bool PHY_RF8256_Config(struct net_device* dev); +extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); +extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel); +extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel); + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c new file mode 100644 index 00000000000..11506db1f78 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -0,0 +1,478 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#if (defined(RTL8192E) || defined(RTL8190P)) + +#include "rtl_core.h" +#include "r8192E_hw.h" +#include "r8192E_cmdpkt.h" +/*---------------------------Define Local Constant---------------------------*/ +/* Debug constant*/ +#define CMPK_DEBOUNCE_CNT 1 +#define CMPK_PRINT(Address)\ +{\ + unsigned char i;\ + u32 temp[10];\ + \ + memcpy(temp, Address, 40);\ + for (i = 0; i <40; i+=4)\ + printk("\r\n %08x", temp[i]);\ +}\ + +/*---------------------------Define functions---------------------------------*/ + extern bool cmpk_message_handle_tx( + struct net_device *dev, + u8* code_virtual_address, + u32 packettype, + u32 buffer_len) +{ + + bool rt_status = true; + struct r8192_priv *priv = rtllib_priv(dev); + u16 frag_threshold; + u16 frag_length = 0, frag_offset = 0; + rt_firmware *pfirmware = priv->pFirmware; + struct sk_buff *skb; + unsigned char *seg_ptr; + cb_desc *tcb_desc; + u8 bLastIniPkt; + + PTX_FWINFO_8190PCI pTxFwInfo = NULL; + + RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__func__,buffer_len); + firmware_init_param(dev); + frag_threshold = pfirmware->cmdpacket_frag_thresold; + + do { + if ((buffer_len - frag_offset) > frag_threshold) { + frag_length = frag_threshold ; + bLastIniPkt = 0; + + } else { + frag_length =(u16)(buffer_len - frag_offset); + bLastIniPkt = 1; + } + + skb = dev_alloc_skb(frag_length + priv->rtllib->tx_headroom + 4); + + if (skb == NULL) { + rt_status = false; + goto Failed; + } + + memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc->queue_index = TXCMD_QUEUE; + tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; + tcb_desc->bLastIniPkt = bLastIniPkt; + tcb_desc->pkt_size = frag_length; + + seg_ptr = skb_put(skb, priv->rtllib->tx_headroom); + pTxFwInfo = (PTX_FWINFO_8190PCI)seg_ptr; + memset(pTxFwInfo,0,sizeof(TX_FWINFO_8190PCI)); + memset(pTxFwInfo,0x12,8); + + seg_ptr = skb_put(skb, frag_length); + memcpy(seg_ptr, code_virtual_address, (u32)frag_length); + + priv->rtllib->softmac_hard_start_xmit(skb,dev); + + code_virtual_address += frag_length; + frag_offset += frag_length; + + }while(frag_offset < buffer_len); + + write_nic_byte(dev, TPPoll, TPPoll_CQ); +Failed: + return rt_status; +} /* CMPK_Message_Handle_Tx */ + +static void +cmpk_count_txstatistic( + struct net_device *dev, + cmpk_txfb_t *pstx_fb) +{ + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef ENABLE_PS + RT_RF_POWER_STATE rtState; + + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + + if (rtState == eRfOff) + { + return; + } +#endif + +#ifdef TODO + if (pAdapter->bInHctTest) + return; +#endif + if (pstx_fb->tok) + { + priv->stats.txfeedbackok++; + priv->stats.txoktotal++; + priv->stats.txokbytestotal += pstx_fb->pkt_length; + priv->stats.txokinperiod++; + + if (pstx_fb->pkt_type == PACKET_MULTICAST) + { + priv->stats.txmulticast++; + priv->stats.txbytesmulticast += pstx_fb->pkt_length; + } + else if (pstx_fb->pkt_type == PACKET_BROADCAST) + { + priv->stats.txbroadcast++; + priv->stats.txbytesbroadcast += pstx_fb->pkt_length; + } + else + { + priv->stats.txunicast++; + priv->stats.txbytesunicast += pstx_fb->pkt_length; + } + } + else + { + priv->stats.txfeedbackfail++; + priv->stats.txerrtotal++; + priv->stats.txerrbytestotal += pstx_fb->pkt_length; + + if (pstx_fb->pkt_type == PACKET_MULTICAST) + { + priv->stats.txerrmulticast++; + } + else if (pstx_fb->pkt_type == PACKET_BROADCAST) + { + priv->stats.txerrbroadcast++; + } + else + { + priv->stats.txerrunicast++; + } + } + + priv->stats.txretrycount += pstx_fb->retry_cnt; + priv->stats.txfeedbackretry += pstx_fb->retry_cnt; + +} /* cmpk_CountTxStatistic */ + + + +static void +cmpk_handle_tx_feedback( + struct net_device *dev, + u8 * pmsg) +{ + struct r8192_priv *priv = rtllib_priv(dev); + cmpk_txfb_t rx_tx_fb; /* */ + + priv->stats.txfeedback++; + + + memcpy((u8*)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); + cmpk_count_txstatistic(dev, &rx_tx_fb); + +} /* cmpk_Handle_Tx_Feedback */ + +void +cmdpkt_beacontimerinterrupt_819xusb( + struct net_device *dev +) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u16 tx_rate; + { + if ((priv->rtllib->current_network.mode == IEEE_A) || + (priv->rtllib->current_network.mode == IEEE_N_5G) || + ((priv->rtllib->current_network.mode == IEEE_N_24G) && (!priv->rtllib->pHTInfo->bCurSuppCCK))) + { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } + else + { + tx_rate =10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); + } + + + } + +} + +static void +cmpk_handle_interrupt_status( + struct net_device *dev, + u8* pmsg) +{ + cmpk_intr_sta_t rx_intr_status; /* */ + struct r8192_priv *priv = rtllib_priv(dev); + + DMESG("---> cmpk_Handle_Interrupt_Status()\n"); + + + rx_intr_status.length = pmsg[1]; + if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) + { + DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); + return; + } + + + if ( priv->rtllib->iw_mode == IW_MODE_ADHOC) + { + rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); + + DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); + + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) + { + priv->rtllib->bibsscoordinator = true; + priv->stats.txbeaconokint++; + } + else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) + { + priv->rtllib->bibsscoordinator = false; + priv->stats.txbeaconerr++; + } + + if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) + { + cmdpkt_beacontimerinterrupt_819xusb(dev); + } + + } + + + + DMESG("<---- cmpk_handle_interrupt_status()\n"); + +} /* cmpk_handle_interrupt_status */ + + +static void +cmpk_handle_query_config_rx( + struct net_device *dev, + u8* pmsg) +{ + cmpk_query_cfg_t rx_query_cfg; /* */ + + + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); + +} /* cmpk_Handle_Query_Config_Rx */ + + +static void cmpk_count_tx_status( struct net_device *dev, + cmpk_tx_status_t *pstx_status) +{ + struct r8192_priv *priv = rtllib_priv(dev); + +#ifdef ENABLE_PS + + RT_RF_POWER_STATE rtstate; + + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + + if (rtState == eRfOff) + { + return; + } +#endif + + priv->stats.txfeedbackok += pstx_status->txok; + priv->stats.txoktotal += pstx_status->txok; + + priv->stats.txfeedbackfail += pstx_status->txfail; + priv->stats.txerrtotal += pstx_status->txfail; + + priv->stats.txretrycount += pstx_status->txretry; + priv->stats.txfeedbackretry += pstx_status->txretry; + + + priv->stats.txmulticast += pstx_status->txmcok; + priv->stats.txbroadcast += pstx_status->txbcok; + priv->stats.txunicast += pstx_status->txucok; + + priv->stats.txerrmulticast += pstx_status->txmcfail; + priv->stats.txerrbroadcast += pstx_status->txbcfail; + priv->stats.txerrunicast += pstx_status->txucfail; + + priv->stats.txbytesmulticast += pstx_status->txmclength; + priv->stats.txbytesbroadcast += pstx_status->txbclength; + priv->stats.txbytesunicast += pstx_status->txuclength; + + priv->stats.last_packet_rate = pstx_status->rate; +} /* cmpk_CountTxStatus */ + + + +static void +cmpk_handle_tx_status( + struct net_device *dev, + u8* pmsg) +{ + cmpk_tx_status_t rx_tx_sts; /* */ + + memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(cmpk_tx_status_t)); + cmpk_count_tx_status(dev, &rx_tx_sts); + +} + + +static void +cmpk_handle_tx_rate_history( + struct net_device *dev, + u8* pmsg) +{ + cmpk_tx_rahis_t *ptxrate; + u8 i, j; + u16 length = sizeof(cmpk_tx_rahis_t); + u32 *ptemp; + struct r8192_priv *priv = rtllib_priv(dev); + + +#ifdef ENABLE_PS + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + + if (rtState == eRfOff) + { + return; + } +#endif + + ptemp = (u32 *)pmsg; + + for (i = 0; i < (length/4); i++) + { + u16 temp1, temp2; + + temp1 = ptemp[i]&0x0000FFFF; + temp2 = ptemp[i]>>16; + ptemp[i] = (temp1<<16)|temp2; + } + + ptxrate = (cmpk_tx_rahis_t *)pmsg; + + if (ptxrate == NULL ) + { + return; + } + + for (i = 0; i < 16; i++) + { + if (i < 4) + priv->stats.txrate.cck[i] += ptxrate->cck[i]; + + if (i< 8) + priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; + + for (j = 0; j < 4; j++) + priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; + } + +} + + +extern u32 +cmpk_message_handle_rx( + struct net_device *dev, + struct rtllib_rx_stats *pstats) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int total_length; + u8 cmd_length, exe_cnt = 0; + u8 element_id; + u8 *pcmd_buff; + + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx()\n"); + + if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) + { + /* Print error message. */ + /*RT_TRACE(COMP_SEND, DebugLevel, + ("\n\r[CMPK]-->Err queue id or pointer"));*/ + return 0; + } + + total_length = pstats->Length; + + pcmd_buff = pstats->virtual_address; + + element_id = pcmd_buff[0]; + + while (total_length > 0 || exe_cnt++ >100) + { + element_id = pcmd_buff[0]; + + switch (element_id) { + case RX_TX_FEEDBACK: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); + cmpk_handle_tx_feedback (dev, pcmd_buff); + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + case RX_INTERRUPT_STATUS: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); + cmpk_handle_interrupt_status(dev, pcmd_buff); + cmd_length = sizeof(cmpk_intr_sta_t); + break; + case BOTH_QUERY_CONFIG: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); + cmpk_handle_query_config_rx(dev, pcmd_buff); + cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; + break; + case RX_TX_STATUS: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); + cmpk_handle_tx_status(dev, pcmd_buff); + cmd_length = CMPK_RX_TX_STS_SIZE; + break; + case RX_TX_PER_PKT_FEEDBACK: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + case RX_TX_RATE_HISTORY: + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); + cmpk_handle_tx_rate_history(dev, pcmd_buff); + cmd_length = CMPK_TX_RAHIS_SIZE; + break; + default: + + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():unknow CMD Element\n"); + return 1; + } + + priv->stats.rxcmdpkt[element_id]++; + + total_length -= cmd_length; + pcmd_buff += cmd_length; + } + return 1; + + RT_TRACE(COMP_CMDPKT, "<----cmpk_message_handle_rx()\n"); +} + + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h new file mode 100644 index 00000000000..787337064bc --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef R819XUSB_CMDPKT_H +#define R819XUSB_CMDPKT_H +#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) +#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) +#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) +#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) +#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) + +#define ISR_TxBcnOk BIT27 +#define ISR_TxBcnErr BIT26 +#define ISR_BcnTimerIntr BIT13 + + +typedef struct tag_cmd_pkt_tx_feedback +{ + u8 element_id; + u8 length; + u8 TID:4; /* */ + u8 fail_reason:3; /* */ + u8 tok:1; + u8 reserve1:4; /* */ + u8 pkt_type:2; /* */ + u8 bandwidth:1; /* */ + u8 qos_pkt:1; /* */ + + u8 reserve2; /* */ + u8 retry_cnt; /* */ + u16 pkt_id; /* */ + + u16 seq_num; /* */ + u8 s_rate; + u8 f_rate; + + u8 s_rts_rate; /* */ + u8 f_rts_rate; /* */ + u16 pkt_length; /* */ + + u16 reserve3; /* */ + u16 duration; /* */ +}cmpk_txfb_t; + +typedef struct tag_cmd_pkt_interrupt_status +{ + u8 element_id; + u8 length; + u16 reserve; + u32 interrupt_status; +}cmpk_intr_sta_t; + + +typedef struct tag_cmd_pkt_set_configuration +{ + u8 element_id; + u8 length; + u16 reserve1; + u8 cfg_reserve1:3; + u8 cfg_size:2; + u8 cfg_type:2; + u8 cfg_action:1; + u8 cfg_reserve2; + u8 cfg_page:4; + u8 cfg_reserve3:4; + u8 cfg_offset; + u32 value; + u32 mask; +}cmpk_set_cfg_t; + +#define cmpk_query_cfg_t cmpk_set_cfg_t + +typedef struct tag_tx_stats_feedback +{ + u16 reserve1; + u8 length; + u8 element_id; + + u16 txfail; + u16 txok; + + u16 txmcok; + u16 txretry; + + u16 txucok; + u16 txbcok; + + u16 txbcfail; + u16 txmcfail; + + u16 reserve2; + u16 txucfail; + + u32 txmclength; + u32 txbclength; + u32 txuclength; + + u16 reserve3_23; + u8 reserve3_1; + u8 rate; +}__attribute__((packed)) cmpk_tx_status_t; + +typedef struct tag_rx_debug_message_feedback +{ + u16 reserve1; + u8 length; + u8 element_id; + + +}cmpk_rx_dbginfo_t; + +typedef struct tag_tx_rate_history +{ + u8 element_id; + u8 length; + u16 reserved1; + + u16 cck[4]; + + u16 ofdm[8]; + + + + + + u16 ht_mcs[4][16]; + +}__attribute__((packed)) cmpk_tx_rahis_t; + +typedef enum tag_command_packet_directories +{ + RX_TX_FEEDBACK = 0, + RX_INTERRUPT_STATUS = 1, + TX_SET_CONFIG = 2, + BOTH_QUERY_CONFIG = 3, + RX_TX_STATUS = 4, + RX_DBGINFO_FEEDBACK = 5, + RX_TX_PER_PKT_FEEDBACK = 6, + RX_TX_RATE_HISTORY = 7, + RX_CMD_ELE_MAX +}cmpk_element_e; + +extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); +extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); + + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_core.c.porig b/drivers/staging/rtl8192e/r8192E_core.c.porig new file mode 100644 index 00000000000..94d9c8d5d09 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_core.c.porig @@ -0,0 +1,5039 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * Linux device driver for RTL8192E + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Jerry chuang + */ + + +#include +#include +#include +#include +#include +#include "r8192E_hw.h" +#include "r8192E.h" +#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ +#include "r8180_93cx6.h" /* Card EEPROM */ +#include "r8192E_wx.h" +#include "r819xE_phy.h" //added by WB 4.30.2008 +#include "r819xE_phyreg.h" +#include "r819xE_cmdpkt.h" +#include "r8192E_dm.h" + +#ifdef CONFIG_PM +#include "r8192_pm.h" +#endif + +#ifdef ENABLE_DOT11D +#include "ieee80211/dot11d.h" +#endif + +//set here to open your trace code. //WB +u32 rt_global_debug_component = COMP_ERR ; //always open err flags on + +static DEFINE_PCI_DEVICE_TABLE(rtl8192_pci_id_tbl) = { + /* Realtek */ + { PCI_DEVICE(0x10ec, 0x8192) }, + + /* Corega */ + { PCI_DEVICE(0x07aa, 0x0044) }, + { PCI_DEVICE(0x07aa, 0x0047) }, + {} +}; + +static char ifname[IFNAMSIZ] = "wlan%d"; +static int hwwep = 1; //default use hw. set 0 to use software security +static int channels = 0x3fff; + +MODULE_LICENSE("GPL"); +MODULE_VERSION("V 1.1"); +MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); +//MODULE_AUTHOR("Andrea Merello "); +MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); + + +module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +module_param(hwwep,int, S_IRUGO|S_IWUSR); +module_param(channels,int, S_IRUGO|S_IWUSR); + +MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); +MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); +MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); + +static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id); +static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); + +static struct pci_driver rtl8192_pci_driver = { + .name = RTL819xE_MODULE_NAME, /* Driver name */ + .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ + .probe = rtl8192_pci_probe, /* probe fn */ + .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ +#ifdef CONFIG_PM + .suspend = rtl8192E_suspend, /* PM suspend fn */ + .resume = rtl8192E_resume, /* PM resume fn */ +#else + .suspend = NULL, /* PM suspend fn */ + .resume = NULL, /* PM resume fn */ +#endif +}; + +static void rtl8192_start_beacon(struct ieee80211_device *ieee80211); +static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211); +static void rtl819x_watchdog_wqcallback(struct work_struct *work); +static void rtl8192_irq_rx_tasklet(unsigned long arg); +static void rtl8192_irq_tx_tasklet(unsigned long arg); +static void rtl8192_prepare_beacon(unsigned long arg); +static irqreturn_t rtl8192_interrupt(int irq, void *param); +static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb); +static void rtl8192_update_ratr_table(struct r8192_priv *priv); +static void rtl8192_restart(struct work_struct *work); +static void watch_dog_timer_callback(unsigned long data); +static int _rtl8192_up(struct r8192_priv *priv); +static void rtl8192_cancel_deferred_work(struct r8192_priv* priv); +static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb); + +#ifdef ENABLE_DOT11D + +typedef struct _CHANNEL_LIST +{ + u8 Channel[32]; + u8 Len; +}CHANNEL_LIST, *PCHANNEL_LIST; + +static const CHANNEL_LIST ChannelPlan[] = { + {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC + {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC + {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI + {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. + {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. + {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK + {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 + {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. + {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC + {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC + {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 +}; + +static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) +{ + int i, max_chan=-1, min_chan=-1; + struct ieee80211_device* ieee = priv->ieee80211; + switch (channel_plan) + { + case COUNTRY_CODE_FCC: + case COUNTRY_CODE_IC: + case COUNTRY_CODE_ETSI: + case COUNTRY_CODE_SPAIN: + case COUNTRY_CODE_FRANCE: + case COUNTRY_CODE_MKK: + case COUNTRY_CODE_MKK1: + case COUNTRY_CODE_ISRAEL: + case COUNTRY_CODE_TELEC: + case COUNTRY_CODE_MIC: + { + Dot11d_Init(ieee); + ieee->bGlobalDomain = false; + //acturally 8225 & 8256 rf chip only support B,G,24N mode + min_chan = 1; + max_chan = 14; + + if (ChannelPlan[channel_plan].Len != 0){ + // Clear old channel map + memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); + // Set new channel map + for (i=0;i max_chan) + break; + GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; + } + } + break; + } + case COUNTRY_CODE_GLOBAL_DOMAIN: + { + GET_DOT11D_INFO(ieee)->bEnabled = 0; //this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain setting + Dot11d_Reset(ieee); + ieee->bGlobalDomain = true; + break; + } + default: + break; + } +} +#endif + +static inline bool rx_hal_is_cck_rate(prx_fwinfo_819x_pci pdrvinfo) +{ + return (pdrvinfo->RxRate == DESC90_RATE1M || + pdrvinfo->RxRate == DESC90_RATE2M || + pdrvinfo->RxRate == DESC90_RATE5_5M || + pdrvinfo->RxRate == DESC90_RATE11M) && + !pdrvinfo->RxHT; +} + +void CamResetAllEntry(struct r8192_priv* priv) +{ + write_nic_dword(priv, RWCAM, BIT31|BIT30); +} + +void write_cam(struct r8192_priv *priv, u8 addr, u32 data) +{ + write_nic_dword(priv, WCAMI, data); + write_nic_dword(priv, RWCAM, BIT31|BIT16|(addr&0xff) ); +} + +u32 read_cam(struct r8192_priv *priv, u8 addr) +{ + write_nic_dword(priv, RWCAM, 0x80000000|(addr&0xff) ); + return read_nic_dword(priv, 0xa8); +} + +u8 read_nic_byte(struct r8192_priv *priv, int x) +{ + return 0xff & readb(priv->mem_start + x); +} + +u32 read_nic_dword(struct r8192_priv *priv, int x) +{ + return readl(priv->mem_start + x); +} + +u16 read_nic_word(struct r8192_priv *priv, int x) +{ + return readw(priv->mem_start + x); +} + +void write_nic_byte(struct r8192_priv *priv, int x,u8 y) +{ + writeb(y, priv->mem_start + x); + udelay(20); +} + +void write_nic_dword(struct r8192_priv *priv, int x,u32 y) +{ + writel(y, priv->mem_start + x); + udelay(20); +} + +void write_nic_word(struct r8192_priv *priv, int x,u16 y) +{ + writew(y, priv->mem_start + x); + udelay(20); +} + +u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee) +{ + static const u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; + static const u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; + int wpa_ie_len= ieee->wpa_ie_len; + struct ieee80211_crypt_data* crypt; + int encrypt; + + crypt = ieee->crypt[ieee->tx_keyidx]; + + encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) || + (ieee->host_encrypt && crypt && crypt->ops && + (0 == strcmp(crypt->ops->name,"WEP"))); + + /* simply judge */ + if(encrypt && (wpa_ie_len == 0)) { + // wep encryption, no N mode setting */ + return SEC_ALG_WEP; + } else if((wpa_ie_len != 0)) { + // parse pairwise key type */ + if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || + ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) + return SEC_ALG_CCMP; + else + return SEC_ALG_TKIP; + } else { + return SEC_ALG_NONE; + } +} + +void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + + switch(variable) + { + + case HW_VAR_BSSID: + write_nic_dword(priv, BSSIDR, ((u32*)(val))[0]); + write_nic_word(priv, BSSIDR+2, ((u16*)(val+2))[0]); + break; + + case HW_VAR_MEDIA_STATUS: + { + RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); + u8 btMsr = read_nic_byte(priv, MSR); + + btMsr &= 0xfc; + + switch(OpMode) + { + case RT_OP_MODE_INFRASTRUCTURE: + btMsr |= MSR_INFRA; + break; + + case RT_OP_MODE_IBSS: + btMsr |= MSR_ADHOC; + break; + + case RT_OP_MODE_AP: + btMsr |= MSR_AP; + break; + + default: + btMsr |= MSR_NOLINK; + break; + } + + write_nic_byte(priv, MSR, btMsr); + } + break; + + case HW_VAR_CHECK_BSSID: + { + u32 RegRCR, Type; + + Type = ((u8*)(val))[0]; + RegRCR = read_nic_dword(priv, RCR); + priv->ReceiveConfig = RegRCR; + + if (Type == true) + RegRCR |= (RCR_CBSSID); + else if (Type == false) + RegRCR &= (~RCR_CBSSID); + + write_nic_dword(priv, RCR,RegRCR); + priv->ReceiveConfig = RegRCR; + + } + break; + + case HW_VAR_SLOT_TIME: + { + priv->slot_time = val[0]; + write_nic_byte(priv, SLOT_TIME, val[0]); + + } + break; + + case HW_VAR_ACK_PREAMBLE: + { + u32 regTmp = 0; + priv->short_preamble = (bool)(*(u8*)val ); + regTmp = priv->basic_rate; + if (priv->short_preamble) + regTmp |= BRSR_AckShortPmb; + write_nic_dword(priv, RRSR, regTmp); + } + break; + + case HW_VAR_CPU_RST: + write_nic_dword(priv, CPU_GEN, ((u32*)(val))[0]); + break; + + default: + break; + } + +} + +static struct proc_dir_entry *rtl8192_proc = NULL; + +static int proc_get_stats_ap(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct r8192_priv *priv = data; + struct ieee80211_device *ieee = priv->ieee80211; + struct ieee80211_network *target; + int len = 0; + + list_for_each_entry(target, &ieee->network_list, list) { + + len += snprintf(page + len, count - len, + "%s ", target->ssid); + + if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ + len += snprintf(page + len, count - len, + "WPA\n"); + } + else{ + len += snprintf(page + len, count - len, + "non_WPA\n"); + } + + } + + *eof = 1; + return len; +} + +static int proc_get_registers(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct r8192_priv *priv = data; + int len = 0; + int i,n; + int max=0xff; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page 0##################\n "); + + for(n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + + for(i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(priv,n)); + } + len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, + "\n####################page 1##################\n "); + for(n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + + for(i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(priv,0x100|n)); + } + + len += snprintf(page + len, count - len, + "\n####################page 3##################\n "); + for(n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + + for(i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(priv,0x300|n)); + } + + *eof = 1; + return len; + +} + +static int proc_get_stats_tx(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct r8192_priv *priv = data; + + int len = 0; + + len += snprintf(page + len, count - len, + "TX VI priority ok int: %lu\n" + "TX VO priority ok int: %lu\n" + "TX BE priority ok int: %lu\n" + "TX BK priority ok int: %lu\n" + "TX MANAGE priority ok int: %lu\n" + "TX BEACON priority ok int: %lu\n" + "TX BEACON priority error int: %lu\n" + "TX CMDPKT priority ok int: %lu\n" + "TX queue stopped?: %d\n" + "TX fifo overflow: %lu\n" + "TX total data packets %lu\n" + "TX total data bytes :%lu\n", + priv->stats.txviokint, + priv->stats.txvookint, + priv->stats.txbeokint, + priv->stats.txbkokint, + priv->stats.txmanageokint, + priv->stats.txbeaconokint, + priv->stats.txbeaconerr, + priv->stats.txcmdpktokint, + netif_queue_stopped(priv->ieee80211->dev), + priv->stats.txoverflow, + priv->ieee80211->stats.tx_packets, + priv->ieee80211->stats.tx_bytes); + + *eof = 1; + return len; +} + + + +static int proc_get_stats_rx(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct r8192_priv *priv = data; + int len = 0; + + len += snprintf(page + len, count - len, + "RX packets: %lu\n" + "RX desc err: %lu\n" + "RX rx overflow error: %lu\n", + priv->stats.rxint, + priv->stats.rxrdu, + priv->stats.rxoverflow); + + *eof = 1; + return len; +} + +static void rtl8192_proc_module_init(void) +{ + RT_TRACE(COMP_INIT, "Initializing proc filesystem\n"); + rtl8192_proc = proc_mkdir(RTL819xE_MODULE_NAME, init_net.proc_net); +} + + +static void rtl8192_proc_module_remove(void) +{ + remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net); +} + + +static void rtl8192_proc_remove_one(struct r8192_priv *priv) +{ + struct net_device *dev = priv->ieee80211->dev; + + printk("dev name=======> %s\n",dev->name); + + if (priv->dir_dev) { + remove_proc_entry("stats-tx", priv->dir_dev); + remove_proc_entry("stats-rx", priv->dir_dev); + remove_proc_entry("stats-ap", priv->dir_dev); + remove_proc_entry("registers", priv->dir_dev); + remove_proc_entry("wlan0", rtl8192_proc); + priv->dir_dev = NULL; + } +} + + +static void rtl8192_proc_init_one(struct r8192_priv *priv) +{ + struct net_device *dev = priv->ieee80211->dev; + struct proc_dir_entry *e; + + priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); + if (!priv->dir_dev) { + RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", + dev->name); + return; + } + e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_rx, priv); + + if (!e) { + RT_TRACE(COMP_ERR,"Unable to initialize " + "/proc/net/rtl8192/%s/stats-rx\n", + dev->name); + } + + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_tx, priv); + + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/stats-tx\n", + dev->name); + } + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_ap, priv); + + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/stats-ap\n", + dev->name); + } + + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers, priv); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers\n", + dev->name); + } +} + +static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + /* for now we reserve two free descriptor as a safety boundary + * between the tail and the head + */ + return (ring->entries - skb_queue_len(&ring->queue) >= 2); +} + +static void tx_timeout(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + + schedule_work(&priv->reset_wq); + printk("TXTIMEOUT"); +} + +static void rtl8192_irq_enable(struct r8192_priv *priv) +{ + u32 mask; + + mask = IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | + IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | + IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW | + IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER; + + write_nic_dword(priv, INTA_MASK, mask); +} + +static void rtl8192_irq_disable(struct r8192_priv *priv) +{ + write_nic_dword(priv, INTA_MASK, 0); + synchronize_irq(priv->irq); +} + +static void rtl8192_update_msr(struct r8192_priv *priv) +{ + u8 msr; + + msr = read_nic_byte(priv, MSR); + msr &= ~ MSR_LINK_MASK; + + /* do not change in link_state != WLAN_LINK_ASSOCIATED. + * msr must be updated if the state is ASSOCIATING. + * this is intentional and make sense for ad-hoc and + * master (see the create BSS/IBSS func) + */ + if (priv->ieee80211->state == IEEE80211_LINKED){ + + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) + msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) + msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) + msr |= (MSR_LINK_MASTER<dev); + + priv->chan = ch; + + /* need to implement rf set channel here WB */ + + if (priv->rf_set_chan) + priv->rf_set_chan(ieee80211, priv->chan); +} + +static void rtl8192_rx_enable(struct r8192_priv *priv) +{ + write_nic_dword(priv, RDQDA, priv->rx_ring_dma); +} + +/* the TX_DESC_BASE setting is according to the following queue index + * BK_QUEUE ===> 0 + * BE_QUEUE ===> 1 + * VI_QUEUE ===> 2 + * VO_QUEUE ===> 3 + * HCCA_QUEUE ===> 4 + * TXCMD_QUEUE ===> 5 + * MGNT_QUEUE ===> 6 + * HIGH_QUEUE ===> 7 + * BEACON_QUEUE ===> 8 + * */ +static const u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +static void rtl8192_tx_enable(struct r8192_priv *priv) +{ + u32 i; + + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + write_nic_dword(priv, TX_DESC_BASE[i], priv->tx_ring[i].dma); + + ieee80211_reset_queue(priv->ieee80211); +} + + +static void rtl8192_free_rx_ring(struct r8192_priv *priv) +{ + int i; + + for (i = 0; i < priv->rxringcount; i++) { + struct sk_buff *skb = priv->rx_buf[i]; + if (!skb) + continue; + + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } + + pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring) * priv->rxringcount, + priv->rx_ring, priv->rx_ring_dma); + priv->rx_ring = NULL; +} + +static void rtl8192_free_tx_ring(struct r8192_priv *priv, unsigned int prio) +{ + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + while (skb_queue_len(&ring->queue)) { + tx_desc_819x_pci *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + + pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; +} + +void PHY_SetRtl8192eRfOff(struct r8192_priv *priv) +{ + //disable RF-Chip A/B + rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); + //analog to digital off, for power save + rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x0); + //digital to analog off, for power save + rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x0); + //rx antenna off + rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0xf, 0x0); + //rx antenna off + rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0xf, 0x0); + //analog to digital part2 off, for power save + rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x0); + rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x0); + // Analog parameter!!Change bias and Lbus control. + write_nic_byte(priv, ANAPAR_FOR_8192PciE, 0x07); +} + +static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset) +{ + int i; + u8 OpMode; + u32 ulRegRead; + + OpMode = RT_OP_MODE_NO_LINK; + priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode); + + if (!priv->ieee80211->bSupportRemoteWakeUp) { + /* + * disable tx/rx. In 8185 we write 0x10 (Reset bit), + * but here we make reference to WMAC and wirte 0x0 + */ + write_nic_byte(priv, CMDR, 0); + } + + mdelay(20); + + if (!reset) { + mdelay(150); + + priv->bHwRfOffAction = 2; + + /* + * Call MgntActSet_RF_State instead to + * prevent RF config race condition. + */ + if (!priv->ieee80211->bSupportRemoteWakeUp) { + PHY_SetRtl8192eRfOff(priv); + ulRegRead = read_nic_dword(priv, CPU_GEN); + ulRegRead |= CPU_GEN_SYSTEM_RESET; + write_nic_dword(priv,CPU_GEN, ulRegRead); + } else { + /* for WOL */ + write_nic_dword(priv, WFCRC0, 0xffffffff); + write_nic_dword(priv, WFCRC1, 0xffffffff); + write_nic_dword(priv, WFCRC2, 0xffffffff); + + /* Write PMR register */ + write_nic_byte(priv, PMR, 0x5); + /* Disable tx, enanble rx */ + write_nic_byte(priv, MacBlkCtrl, 0xa); + } + } + + for(i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_purge(&priv->ieee80211->skb_waitQ [i]); + } + for(i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_purge(&priv->ieee80211->skb_aggQ [i]); + } + + skb_queue_purge(&priv->skb_queue); +} + +static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211) +{ +} + +static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211) +{ +} + +/* + * this function TX data frames when the ieee80211 stack requires this. + * It checks also if we need to stop the ieee tx queue, eventually do it + */ +static void rtl8192_hard_data_xmit(struct sk_buff *skb, + struct ieee80211_device *ieee80211, int rate) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + int ret; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + u8 queue_index = tcb_desc->queue_index; + + /* shall not be referred by command packet */ + BUG_ON(queue_index == TXCMD_QUEUE); + + if (priv->bHwRadioOff || (!priv->up)) + { + kfree_skb(skb); + return; + } + + skb_push(skb, priv->ieee80211->tx_headroom); + ret = rtl8192_tx(priv, skb); + if (ret != 0) { + kfree_skb(skb); + } + + if (queue_index != MGNT_QUEUE) { + priv->ieee80211->stats.tx_bytes += (skb->len - priv->ieee80211->tx_headroom); + priv->ieee80211->stats.tx_packets++; + } +} + +/* + * This is a rough attempt to TX a frame + * This is called by the ieee 80211 stack to TX management frames. + * If the ring is full packet are dropped (for data frame the queue + * is stopped before this can happen). + */ +static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + int ret; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + u8 queue_index = tcb_desc->queue_index; + + if (queue_index != TXCMD_QUEUE) { + if (priv->bHwRadioOff || (!priv->up)) + { + kfree_skb(skb); + return 0; + } + } + + if (queue_index == TXCMD_QUEUE) { + rtl819xE_tx_cmd(priv, skb); + ret = 0; + return ret; + } else { + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + tcb_desc->bTxEnableFwCalcDur = 1; + skb_push(skb, ieee80211->tx_headroom); + ret = rtl8192_tx(priv, skb); + if (ret != 0) { + kfree_skb(skb); + } + } + + return ret; +} + + +static void rtl8192_tx_isr(struct r8192_priv *priv, int prio) +{ + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + while (skb_queue_len(&ring->queue)) { + tx_desc_819x_pci *entry = &ring->desc[ring->idx]; + struct sk_buff *skb; + + /* + * beacon packet will only use the first descriptor defaultly, + * and the OWN may not be cleared by the hardware + */ + if (prio != BEACON_QUEUE) { + if (entry->OWN) + return; + ring->idx = (ring->idx + 1) % ring->entries; + } + + skb = __skb_dequeue(&ring->queue); + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + + kfree_skb(skb); + } + + if (prio != BEACON_QUEUE) { + /* try to deal with the pending packets */ + tasklet_schedule(&priv->irq_tx_tasklet); + } +} + +static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211) +{ +} + +static void rtl8192_config_rate(struct r8192_priv *priv, u16* rate_config) +{ + struct ieee80211_network *net; + u8 i=0, basic_rate = 0; + net = & priv->ieee80211->current_network; + + for (i=0; irates_len; i++) + { + basic_rate = net->rates[i]&0x7f; + switch(basic_rate) + { + case MGN_1M: *rate_config |= RRSR_1M; break; + case MGN_2M: *rate_config |= RRSR_2M; break; + case MGN_5_5M: *rate_config |= RRSR_5_5M; break; + case MGN_11M: *rate_config |= RRSR_11M; break; + case MGN_6M: *rate_config |= RRSR_6M; break; + case MGN_9M: *rate_config |= RRSR_9M; break; + case MGN_12M: *rate_config |= RRSR_12M; break; + case MGN_18M: *rate_config |= RRSR_18M; break; + case MGN_24M: *rate_config |= RRSR_24M; break; + case MGN_36M: *rate_config |= RRSR_36M; break; + case MGN_48M: *rate_config |= RRSR_48M; break; + case MGN_54M: *rate_config |= RRSR_54M; break; + } + } + for (i=0; irates_ex_len; i++) + { + basic_rate = net->rates_ex[i]&0x7f; + switch(basic_rate) + { + case MGN_1M: *rate_config |= RRSR_1M; break; + case MGN_2M: *rate_config |= RRSR_2M; break; + case MGN_5_5M: *rate_config |= RRSR_5_5M; break; + case MGN_11M: *rate_config |= RRSR_11M; break; + case MGN_6M: *rate_config |= RRSR_6M; break; + case MGN_9M: *rate_config |= RRSR_9M; break; + case MGN_12M: *rate_config |= RRSR_12M; break; + case MGN_18M: *rate_config |= RRSR_18M; break; + case MGN_24M: *rate_config |= RRSR_24M; break; + case MGN_36M: *rate_config |= RRSR_36M; break; + case MGN_48M: *rate_config |= RRSR_48M; break; + case MGN_54M: *rate_config |= RRSR_54M; break; + } + } +} + + +#define SHORT_SLOT_TIME 9 +#define NON_SHORT_SLOT_TIME 20 + +static void rtl8192_update_cap(struct r8192_priv *priv, u16 cap) +{ + u32 tmp = 0; + struct ieee80211_network *net = &priv->ieee80211->current_network; + + priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; + tmp = priv->basic_rate; + if (priv->short_preamble) + tmp |= BRSR_AckShortPmb; + write_nic_dword(priv, RRSR, tmp); + + if (net->mode & (IEEE_G|IEEE_N_24G)) + { + u8 slot_time = 0; + if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) + {//short slot time + slot_time = SHORT_SLOT_TIME; + } + else //long slot time + slot_time = NON_SHORT_SLOT_TIME; + priv->slot_time = slot_time; + write_nic_byte(priv, SLOT_TIME, slot_time); + } + +} + +static void rtl8192_net_update(struct r8192_priv *priv) +{ + struct ieee80211_network *net; + u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; + u16 rate_config = 0; + net = &priv->ieee80211->current_network; + + /* update Basic rate: RR, BRSR */ + rtl8192_config_rate(priv, &rate_config); + + /* + * Select RRSR (in Legacy-OFDM and CCK) + * For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, + * 2M, and 1M from the Basic rate. + * We do not use other rates. + */ + priv->basic_rate = rate_config &= 0x15f; + + /* BSSID */ + write_nic_dword(priv, BSSIDR, ((u32 *)net->bssid)[0]); + write_nic_word(priv, BSSIDR+4, ((u16 *)net->bssid)[2]); + + if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) + { + write_nic_word(priv, ATIMWND, 2); + write_nic_word(priv, BCN_DMATIME, 256); + write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); + /* + * BIT15 of BCN_DRV_EARLY_INT will indicate + * whether software beacon or hw beacon is applied. + */ + write_nic_word(priv, BCN_DRV_EARLY_INT, 10); + write_nic_byte(priv, BCN_ERR_THRESH, 100); + + BcnTimeCfg |= (BcnCW<tx_ring[TXCMD_QUEUE]; + mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + + spin_lock_irqsave(&priv->irq_th_lock,flags); + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + entry = &ring->desc[idx]; + + tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + memset(entry,0,12); + entry->LINIP = tcb_desc->bLastIniPkt; + entry->FirstSeg = 1;//first segment + entry->LastSeg = 1; //last segment + if(tcb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { + entry->CmdInit = DESC_PACKET_TYPE_INIT; + } else { + entry->CmdInit = DESC_PACKET_TYPE_NORMAL; + entry->Offset = sizeof(TX_FWINFO_8190PCI) + 8; + entry->PktSize = (u16)(tcb_desc->pkt_size + entry->Offset); + entry->QueueSelect = QSLT_CMD; + entry->TxFWInfoSize = 0x08; + entry->RATid = (u8)DESC_PACKET_TYPE_INIT; + } + entry->TxBufferSize = skb->len; + entry->TxBuffAddr = cpu_to_le32(mapping); + entry->OWN = 1; + + __skb_queue_tail(&ring->queue, skb); + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + + write_nic_byte(priv, TPPoll, TPPoll_CQ); + + return; +} + +/* + * Mapping Software/Hardware descriptor queue id to "Queue Select Field" + * in TxFwInfo data structure + */ +static u8 MapHwQueueToFirmwareQueue(u8 QueueID) +{ + u8 QueueSelect = 0; + + switch (QueueID) { + case BE_QUEUE: + QueueSelect = QSLT_BE; + break; + + case BK_QUEUE: + QueueSelect = QSLT_BK; + break; + + case VO_QUEUE: + QueueSelect = QSLT_VO; + break; + + case VI_QUEUE: + QueueSelect = QSLT_VI; + break; + + case MGNT_QUEUE: + QueueSelect = QSLT_MGNT; + break; + + case BEACON_QUEUE: + QueueSelect = QSLT_BEACON; + break; + + case TXCMD_QUEUE: + QueueSelect = QSLT_CMD; + break; + + case HIGH_QUEUE: + default: + RT_TRACE(COMP_ERR, "Impossible Queue Selection: %d\n", QueueID); + break; + } + return QueueSelect; +} + +static u8 MRateToHwRate8190Pci(u8 rate) +{ + u8 ret = DESC90_RATE1M; + + switch(rate) { + case MGN_1M: ret = DESC90_RATE1M; break; + case MGN_2M: ret = DESC90_RATE2M; break; + case MGN_5_5M: ret = DESC90_RATE5_5M; break; + case MGN_11M: ret = DESC90_RATE11M; break; + case MGN_6M: ret = DESC90_RATE6M; break; + case MGN_9M: ret = DESC90_RATE9M; break; + case MGN_12M: ret = DESC90_RATE12M; break; + case MGN_18M: ret = DESC90_RATE18M; break; + case MGN_24M: ret = DESC90_RATE24M; break; + case MGN_36M: ret = DESC90_RATE36M; break; + case MGN_48M: ret = DESC90_RATE48M; break; + case MGN_54M: ret = DESC90_RATE54M; break; + + // HT rate since here + case MGN_MCS0: ret = DESC90_RATEMCS0; break; + case MGN_MCS1: ret = DESC90_RATEMCS1; break; + case MGN_MCS2: ret = DESC90_RATEMCS2; break; + case MGN_MCS3: ret = DESC90_RATEMCS3; break; + case MGN_MCS4: ret = DESC90_RATEMCS4; break; + case MGN_MCS5: ret = DESC90_RATEMCS5; break; + case MGN_MCS6: ret = DESC90_RATEMCS6; break; + case MGN_MCS7: ret = DESC90_RATEMCS7; break; + case MGN_MCS8: ret = DESC90_RATEMCS8; break; + case MGN_MCS9: ret = DESC90_RATEMCS9; break; + case MGN_MCS10: ret = DESC90_RATEMCS10; break; + case MGN_MCS11: ret = DESC90_RATEMCS11; break; + case MGN_MCS12: ret = DESC90_RATEMCS12; break; + case MGN_MCS13: ret = DESC90_RATEMCS13; break; + case MGN_MCS14: ret = DESC90_RATEMCS14; break; + case MGN_MCS15: ret = DESC90_RATEMCS15; break; + case (0x80|0x20): ret = DESC90_RATEMCS32; break; + + default: break; + } + return ret; +} + + +static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) +{ + u8 tmp_Short; + + tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); + + if(TxHT==1 && TxRate != DESC90_RATEMCS15) + tmp_Short = 0; + + return tmp_Short; +} + +/* + * The tx procedure is just as following, + * skb->cb will contain all the following information, + * priority, morefrag, rate, &dev. + */ +static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb) +{ + struct rtl8192_tx_ring *ring; + unsigned long flags; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tx_desc_819x_pci *pdesc = NULL; + TX_FWINFO_8190PCI *pTxFwInfo = NULL; + dma_addr_t mapping; + bool multi_addr = false, broad_addr = false, uni_addr = false; + u8 *pda_addr = NULL; + int idx; + + if (priv->bdisable_nic) { + RT_TRACE(COMP_ERR, "Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", + skb->len, tcb_desc->queue_index); + return skb->len; + } + +#ifdef ENABLE_LPS + priv->ieee80211->bAwakePktSent = true; +#endif + + mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + + /* collect the tx packets statitcs */ + pda_addr = ((u8 *)skb->data) + sizeof(TX_FWINFO_8190PCI); + if (is_multicast_ether_addr(pda_addr)) + multi_addr = true; + else if (is_broadcast_ether_addr(pda_addr)) + broad_addr = true; + else + uni_addr = true; + + if (uni_addr) + priv->stats.txbytesunicast += (u8)(skb->len) - sizeof(TX_FWINFO_8190PCI); + + /* fill tx firmware */ + pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; + memset(pTxFwInfo, 0, sizeof(TX_FWINFO_8190PCI)); + pTxFwInfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; + pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)tcb_desc->data_rate); + pTxFwInfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; + pTxFwInfo->Short = QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, tcb_desc); + + /* Aggregation related */ + if (tcb_desc->bAMPDUEnable) { + pTxFwInfo->AllowAggregation = 1; + pTxFwInfo->RxMF = tcb_desc->ampdu_factor; + pTxFwInfo->RxAMD = tcb_desc->ampdu_density; + } else { + pTxFwInfo->AllowAggregation = 0; + pTxFwInfo->RxMF = 0; + pTxFwInfo->RxAMD = 0; + } + + /* Protection mode related */ + pTxFwInfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; + pTxFwInfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; + pTxFwInfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; + pTxFwInfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; + pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); + pTxFwInfo->RtsBandwidth = 0; + pTxFwInfo->RtsSubcarrier = tcb_desc->RTSSC; + pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : (tcb_desc->bRTSUseShortGI? 1 : 0); + + /* Set Bandwidth and sub-channel settings. */ + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { + if (tcb_desc->bPacketBW) { + pTxFwInfo->TxBandwidth = 1; + /* use duplicated mode */ + pTxFwInfo->TxSubCarrier = 0; + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + } + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = 0; + } + + spin_lock_irqsave(&priv->irq_th_lock, flags); + ring = &priv->tx_ring[tcb_desc->queue_index]; + if (tcb_desc->queue_index != BEACON_QUEUE) + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + else + idx = 0; + + pdesc = &ring->desc[idx]; + if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { + RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d,idx = %d,%x\n", + tcb_desc->queue_index, ring->idx, idx, skb->len); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + return skb->len; + } + + /* fill tx descriptor */ + memset(pdesc, 0, 12); + + /*DWORD 0*/ + pdesc->LINIP = 0; + pdesc->CmdInit = 1; + pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; /* We must add 8!! */ + pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); + + /*DWORD 1*/ + pdesc->SecCAMID = 0; + pdesc->RATid = tcb_desc->RATRIndex; + + pdesc->NoEnc = 1; + pdesc->SecType = 0x0; + if (tcb_desc->bHwSec) { + switch (priv->ieee80211->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + pdesc->SecType = 0x1; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_TKIP: + pdesc->SecType = 0x2; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_CCMP: + pdesc->SecType = 0x3; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_NA: + pdesc->SecType = 0x0; + pdesc->NoEnc = 1; + break; + } + } + + /* Set Packet ID */ + pdesc->PktId = 0x0; + + pdesc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); + pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); + + pdesc->DISFB = tcb_desc->bTxDisableRateFallBack; + pdesc->USERATE = tcb_desc->bTxUseDriverAssingedRate; + + pdesc->FirstSeg = 1; + pdesc->LastSeg = 1; + pdesc->TxBufferSize = skb->len; + + pdesc->TxBuffAddr = cpu_to_le32(mapping); + __skb_queue_tail(&ring->queue, skb); + pdesc->OWN = 1; + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + priv->ieee80211->dev->trans_start = jiffies; + write_nic_word(priv, TPPoll, 0x01<queue_index); + return 0; +} + +static short rtl8192_alloc_rx_desc_ring(struct r8192_priv *priv) +{ + rx_desc_819x_pci *entry = NULL; + int i; + + priv->rx_ring = pci_alloc_consistent(priv->pdev, + sizeof(*priv->rx_ring) * priv->rxringcount, &priv->rx_ring_dma); + + if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { + RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); + return -ENOMEM; + } + + memset(priv->rx_ring, 0, sizeof(*priv->rx_ring) * priv->rxringcount); + priv->rx_idx = 0; + + for (i = 0; i < priv->rxringcount; i++) { + struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); + dma_addr_t *mapping; + entry = &priv->rx_ring[i]; + if (!skb) + return 0; + priv->rx_buf[i] = skb; + mapping = (dma_addr_t *)skb->cb; + *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + + entry->BufferAddress = cpu_to_le32(*mapping); + + entry->Length = priv->rxbuffersize; + entry->OWN = 1; + } + + entry->EOR = 1; + return 0; +} + +static int rtl8192_alloc_tx_desc_ring(struct r8192_priv *priv, + unsigned int prio, unsigned int entries) +{ + tx_desc_819x_pci *ring; + dma_addr_t dma; + int i; + + ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + if (!ring || (unsigned long)ring & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); + return -ENOMEM; + } + + memset(ring, 0, sizeof(*ring)*entries); + priv->tx_ring[prio].desc = ring; + priv->tx_ring[prio].dma = dma; + priv->tx_ring[prio].idx = 0; + priv->tx_ring[prio].entries = entries; + skb_queue_head_init(&priv->tx_ring[prio].queue); + + for (i = 0; i < entries; i++) + ring[i].NextDescAddress = + cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); + + return 0; +} + +static short rtl8192_pci_initdescring(struct r8192_priv *priv) +{ + u32 ret; + int i; + + ret = rtl8192_alloc_rx_desc_ring(priv); + if (ret) + return ret; + + /* general process for other queue */ + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + ret = rtl8192_alloc_tx_desc_ring(priv, i, priv->txringcount); + if (ret) + goto err_free_rings; + } + + return 0; + +err_free_rings: + rtl8192_free_rx_ring(priv); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + if (priv->tx_ring[i].desc) + rtl8192_free_tx_ring(priv, i); + return 1; +} + +static void rtl8192_pci_resetdescring(struct r8192_priv *priv) +{ + int i; + + /* force the rx_idx to the first one */ + if(priv->rx_ring) { + rx_desc_819x_pci *entry = NULL; + for (i = 0; i < priv->rxringcount; i++) { + entry = &priv->rx_ring[i]; + entry->OWN = 1; + } + priv->rx_idx = 0; + } + + /* after reset, release previous pending packet, and force the + * tx idx to the first one */ + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if (priv->tx_ring[i].desc) { + struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; + + while (skb_queue_len(&ring->queue)) { + tx_desc_819x_pci *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } +} + +static void rtl8192_link_change(struct ieee80211_device *ieee) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + + if (ieee->state == IEEE80211_LINKED) + { + rtl8192_net_update(priv); + rtl8192_update_ratr_table(priv); + + //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 + if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + EnableHWSecurityConfig8192(priv); + } + else + { + write_nic_byte(priv, 0x173, 0); + } + + rtl8192_update_msr(priv); + + // 2007/10/16 MH MAC Will update TSF according to all received beacon, so we have + // // To set CBSSID bit when link with any AP or STA. + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) + { + u32 reg = 0; + reg = read_nic_dword(priv, RCR); + if (priv->ieee80211->state == IEEE80211_LINKED) + priv->ReceiveConfig = reg |= RCR_CBSSID; + else + priv->ReceiveConfig = reg &= ~RCR_CBSSID; + write_nic_dword(priv, RCR, reg); + } +} + + +static const struct ieee80211_qos_parameters def_qos_parameters = { + {3,3,3,3},/* cw_min */ + {7,7,7,7},/* cw_max */ + {2,2,2,2},/* aifs */ + {0,0,0,0},/* flags */ + {0,0,0,0} /* tx_op_limit */ +}; + +static void rtl8192_update_beacon(struct work_struct * work) +{ + struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); + struct ieee80211_device* ieee = priv->ieee80211; + struct ieee80211_network* net = &ieee->current_network; + + if (ieee->pHTInfo->bCurrentHTSupport) + HTUpdateSelfAndPeerSetting(ieee, net); + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + rtl8192_update_cap(priv, net->capability); +} + +/* +* background support to run QoS activate functionality +*/ +static const int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +static void rtl8192_qos_activate(struct work_struct * work) +{ + struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); + struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; + u8 mode = priv->ieee80211->current_network.mode; + u8 u1bAIFS; + u32 u4bAcParam; + int i; + + mutex_lock(&priv->mutex); + if(priv->ieee80211->state != IEEE80211_LINKED) + goto success; + RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); + /* It better set slot time at first */ + /* For we just support b/g mode at present, let the slot time at 9/20 selection */ + /* update the ac parameter to related registers */ + for(i = 0; i < QOS_QUEUE_NUM; i++) { + //Mode G/A: slotTimeTimer = 9; Mode B: 20 + u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| + (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| + (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + write_nic_dword(priv, WDCAPARA_ADD[i], u4bAcParam); + } + +success: + mutex_unlock(&priv->mutex); +} + +static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, + int active_network, + struct ieee80211_network *network) +{ + int ret = 0; + u32 size = sizeof(struct ieee80211_qos_parameters); + + if(priv->ieee80211->state !=IEEE80211_LINKED) + return ret; + + if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) + return ret; + + if (network->flags & NETWORK_HAS_QOS_MASK) { + if (active_network && + (network->flags & NETWORK_HAS_QOS_PARAMETERS)) + network->qos_data.active = network->qos_data.supported; + + if ((network->qos_data.active == 1) && (active_network == 1) && + (network->flags & NETWORK_HAS_QOS_PARAMETERS) && + (network->qos_data.old_param_count != + network->qos_data.param_count)) { + network->qos_data.old_param_count = + network->qos_data.param_count; + queue_work(priv->priv_wq, &priv->qos_activate); + RT_TRACE (COMP_QOS, "QoS parameters change call " + "qos_activate\n"); + } + } else { + memcpy(&priv->ieee80211->current_network.qos_data.parameters, + &def_qos_parameters, size); + + if ((network->qos_data.active == 1) && (active_network == 1)) { + queue_work(priv->priv_wq, &priv->qos_activate); + RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); + } + network->qos_data.active = 0; + network->qos_data.supported = 0; + } + + return 0; +} + +/* handle manage frame frame beacon and probe response */ +static int rtl8192_handle_beacon(struct ieee80211_device *ieee, + struct ieee80211_beacon * beacon, + struct ieee80211_network * network) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + + rtl8192_qos_handle_probe_response(priv,1,network); + + queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); + return 0; + +} + +/* + * handling the beaconing responses. if we get different QoS setting + * off the network from the associated setting, adjust the QoS setting + */ +static int rtl8192_qos_association_resp(struct r8192_priv *priv, + struct ieee80211_network *network) +{ + int ret = 0; + unsigned long flags; + u32 size = sizeof(struct ieee80211_qos_parameters); + int set_qos_param = 0; + + if ((priv == NULL) || (network == NULL)) + return ret; + + if (priv->ieee80211->state != IEEE80211_LINKED) + return ret; + + if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) + return ret; + + spin_lock_irqsave(&priv->ieee80211->lock, flags); + if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { + memcpy(&priv->ieee80211->current_network.qos_data.parameters, + &network->qos_data.parameters, + sizeof(struct ieee80211_qos_parameters)); + priv->ieee80211->current_network.qos_data.active = 1; + set_qos_param = 1; + /* update qos parameter for current network */ + priv->ieee80211->current_network.qos_data.old_param_count = + priv->ieee80211->current_network.qos_data.param_count; + priv->ieee80211->current_network.qos_data.param_count = + network->qos_data.param_count; + + } else { + memcpy(&priv->ieee80211->current_network.qos_data.parameters, + &def_qos_parameters, size); + priv->ieee80211->current_network.qos_data.active = 0; + priv->ieee80211->current_network.qos_data.supported = 0; + set_qos_param = 1; + } + + spin_unlock_irqrestore(&priv->ieee80211->lock, flags); + + RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __FUNCTION__, + network->flags, priv->ieee80211->current_network.qos_data.active); + if (set_qos_param == 1) + queue_work(priv->priv_wq, &priv->qos_activate); + + return ret; +} + + +static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee, + struct ieee80211_assoc_response_frame *resp, + struct ieee80211_network *network) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + rtl8192_qos_association_resp(priv, network); + return 0; +} + + +/* updateRATRTabel for MCS only. Basic rate is not implemented. */ +static void rtl8192_update_ratr_table(struct r8192_priv* priv) +{ + struct ieee80211_device* ieee = priv->ieee80211; + u8* pMcsRate = ieee->dot11HTOperationalRateSet; + u32 ratr_value = 0; + u8 rate_index = 0; + + rtl8192_config_rate(priv, (u16*)(&ratr_value)); + ratr_value |= (*(u16*)(pMcsRate)) << 12; + + switch (ieee->mode) + { + case IEEE_A: + ratr_value &= 0x00000FF0; + break; + case IEEE_B: + ratr_value &= 0x0000000F; + break; + case IEEE_G: + ratr_value &= 0x00000FF7; + break; + case IEEE_N_24G: + case IEEE_N_5G: + if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC + ratr_value &= 0x0007F007; + else{ + if (priv->rf_type == RF_1T2R) + ratr_value &= 0x000FF007; + else + ratr_value &= 0x0F81F007; + } + break; + default: + break; + } + ratr_value &= 0x0FFFFFFF; + if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ + ratr_value |= 0x80000000; + }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ + ratr_value |= 0x80000000; + } + write_nic_dword(priv, RATR0+rate_index*4, ratr_value); + write_nic_byte(priv, UFWP, 1); +} + +static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee) +{ + return !(ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))); +} + +static void rtl8192_refresh_supportrate(struct r8192_priv* priv) +{ + struct ieee80211_device* ieee = priv->ieee80211; + //we donot consider set support rate for ABG mode, only HT MCS rate is set here. + if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) + { + memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + } + else + memset(ieee->Regdot11HTOperationalRateSet, 0, 16); +} + +static u8 rtl8192_getSupportedWireleeMode(void) +{ + return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B); +} + +static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + u8 bSupportMode = rtl8192_getSupportedWireleeMode(); + + if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0)) + { + if(bSupportMode & WIRELESS_MODE_N_24G) + { + wireless_mode = WIRELESS_MODE_N_24G; + } + else if(bSupportMode & WIRELESS_MODE_N_5G) + { + wireless_mode = WIRELESS_MODE_N_5G; + } + else if((bSupportMode & WIRELESS_MODE_A)) + { + wireless_mode = WIRELESS_MODE_A; + } + else if((bSupportMode & WIRELESS_MODE_G)) + { + wireless_mode = WIRELESS_MODE_G; + } + else if((bSupportMode & WIRELESS_MODE_B)) + { + wireless_mode = WIRELESS_MODE_B; + } + else{ + RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode); + wireless_mode = WIRELESS_MODE_B; + } + } + priv->ieee80211->mode = wireless_mode; + + if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) + priv->ieee80211->pHTInfo->bEnableHT = 1; + else + priv->ieee80211->pHTInfo->bEnableHT = 0; + RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); + rtl8192_refresh_supportrate(priv); +} + +static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee) +{ + return ieee->bHalfWirelessN24GMode; +} + +static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee) +{ + int i=0; + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + + for (i=0; i<=MGNT_QUEUE; i++) + { + if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) + continue; + if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ + printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); + return 0; + } + } + return 1; +} + +static void rtl8192_hw_sleep_down(struct r8192_priv *priv) +{ + MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS); +} + +static void rtl8192_hw_wakeup(struct ieee80211_device *ieee) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS); +} + +static void rtl8192_hw_wakeup_wq (struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work,struct delayed_work,work); + struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); + + rtl8192_hw_wakeup(ieee); +} + +#define MIN_SLEEP_TIME 50 +#define MAX_SLEEP_TIME 10000 +static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl) +{ + struct r8192_priv *priv = ieee80211_priv(ieee->dev); + u32 tmp; + u32 rb = jiffies; + + // Writing HW register with 0 equals to disable + // the timer, that is not really what we want + // + tl -= MSECS(8+16+7); + + // If the interval in witch we are requested to sleep is too + // short then give up and remain awake + // when we sleep after send null frame, the timer will be too short to sleep. + // + if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) + ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + return; + } + + if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| + ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| + ((tlMSECS(MAX_SLEEP_TIME)))) { + printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + return; + } + + tmp = (tl>rb)?(tl-rb):(rb-tl); + queue_delayed_work(priv->ieee80211->wq, + &priv->ieee80211->hw_wakeup_wq,tmp); + + rtl8192_hw_sleep_down(priv); +} + +static void rtl8192_init_priv_variable(struct r8192_priv *priv) +{ + u8 i; + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + + // Default Halt the NIC if RF is OFF. + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_CLK_REQ; + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; + pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; + pPSC->bLeisurePs = true; + priv->ieee80211->RegMaxLPSAwakeIntvl = 5; + priv->bHwRadioOff = false; + + priv->being_init_adapter = false; + priv->txringcount = 64;//32; + priv->rxbuffersize = 9100;//2048;//1024; + priv->rxringcount = MAX_RX_COUNT;//64; + priv->chan = 1; //set to channel 1 + priv->RegWirelessMode = WIRELESS_MODE_AUTO; + priv->RegChannelPlan = 0xf; + priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO + priv->ieee80211->iw_mode = IW_MODE_INFRA; + priv->ieee80211->ieee_up=0; + priv->retry_rts = DEFAULT_RETRY_RTS; + priv->retry_data = DEFAULT_RETRY_DATA; + priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; + priv->ieee80211->rate = 110; //11 mbps + priv->ieee80211->short_slot = 1; + priv->promisc = (priv->ieee80211->dev->flags & IFF_PROMISC) ? 1:0; + priv->bcck_in_ch14 = false; + priv->CCKPresentAttentuation = 0; + priv->rfa_txpowertrackingindex = 0; + priv->rfc_txpowertrackingindex = 0; + priv->CckPwEnl = 6; + //added by amy for silent reset + priv->ResetProgress = RESET_TYPE_NORESET; + priv->bForcedSilentReset = 0; + priv->bDisableNormalResetCheck = false; + priv->force_reset = false; + //added by amy for power save + priv->RfOffReason = 0; + priv->bHwRfOffAction = 0; + priv->PowerSaveControl.bInactivePs = true; + priv->PowerSaveControl.bIPSModeBackup = false; + + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->iw_mode = IW_MODE_INFRA; + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;/* | + IEEE_SOFTMAC_BEACONS;*///added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE; + + priv->ieee80211->active_scan = 1; + priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; + priv->ieee80211->host_encrypt = 1; + priv->ieee80211->host_decrypt = 1; + priv->ieee80211->start_send_beacons = rtl8192_start_beacon; + priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon; + priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; + priv->ieee80211->set_chan = rtl8192_set_chan; + priv->ieee80211->link_change = rtl8192_link_change; + priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; + priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop; + priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume; + priv->ieee80211->init_wmmparam_flag = 0; + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; + priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc; + priv->ieee80211->tx_headroom = sizeof(TX_FWINFO_8190PCI); + priv->ieee80211->qos_support = 1; + priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; + priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; + priv->ieee80211->handle_beacon = rtl8192_handle_beacon; + + priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup; + priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep; + priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty; + priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8190Pci; + priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; + priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xPci; + + priv->ieee80211->InitialGainHandler = InitialGain819xPci; + +#ifdef ENABLE_IPS + priv->ieee80211->ieee80211_ips_leave_wq = ieee80211_ips_leave_wq; + priv->ieee80211->ieee80211_ips_leave = ieee80211_ips_leave; +#endif +#ifdef ENABLE_LPS + priv->ieee80211->LeisurePSLeave = LeisurePSLeave; +#endif + + priv->ieee80211->SetHwRegHandler = rtl8192e_SetHwReg; + priv->ieee80211->rtllib_ap_sec_type = rtl8192e_ap_sec_type; + + priv->ShortRetryLimit = 0x30; + priv->LongRetryLimit = 0x30; + + priv->ReceiveConfig = RCR_ADD3 | + RCR_AMF | RCR_ADF | //accept management/data + RCR_AICV | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. + RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC + RCR_AAP | ((u32)7<pFirmware = vzalloc(sizeof(rt_firmware)); + + /* rx related queue */ + skb_queue_head_init(&priv->skb_queue); + + /* Tx related queue */ + for(i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]); + } + for(i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]); + } + priv->rf_set_chan = rtl8192_phy_SwChnl; +} + +static void rtl8192_init_priv_lock(struct r8192_priv* priv) +{ + spin_lock_init(&priv->irq_th_lock); + spin_lock_init(&priv->rf_ps_lock); + sema_init(&priv->wx_sem,1); + sema_init(&priv->rf_sem,1); + mutex_init(&priv->mutex); +} + +/* init tasklet and wait_queue here */ +#define DRV_NAME "wlan0" +static void rtl8192_init_priv_task(struct r8192_priv *priv) +{ + priv->priv_wq = create_workqueue(DRV_NAME); + +#ifdef ENABLE_IPS + INIT_WORK(&priv->ieee80211->ips_leave_wq, IPSLeave_wq); +#endif + + INIT_WORK(&priv->reset_wq, rtl8192_restart); + INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); + INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); + INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); + INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); + INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); + INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8192_hw_wakeup_wq); + + tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, + (unsigned long) priv); + tasklet_init(&priv->irq_tx_tasklet, rtl8192_irq_tx_tasklet, + (unsigned long) priv); + tasklet_init(&priv->irq_prepare_beacon_tasklet, rtl8192_prepare_beacon, + (unsigned long) priv); +} + +static void rtl8192_get_eeprom_size(struct r8192_priv *priv) +{ + u16 curCR = 0; + RT_TRACE(COMP_INIT, "===========>%s()\n", __FUNCTION__); + curCR = read_nic_dword(priv, EPROM_CMD); + RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); + //whether need I consider BIT5? + priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EPROM_93c56 : EPROM_93c46; + RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype); +} + +/* + * Adapter->EEPROMAddressSize should be set before this function call. + * EEPROM address size can be got through GetEEPROMSize8185() + */ +static void rtl8192_read_eeprom_info(struct r8192_priv *priv) +{ + struct net_device *dev = priv->ieee80211->dev; + u8 tempval; + u8 ICVer8192, ICVer8256; + u16 i,usValue, IC_Version; + u16 EEPROMId; + u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; + RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); + + + // TODO: I don't know if we need to apply EF function to EEPROM read function + + //2 Read EEPROM ID to make sure autoload is success + EEPROMId = eprom_read(priv, 0); + if( EEPROMId != RTL8190_EEPROM_ID ) + { + RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); + priv->AutoloadFailFlag=true; + } + else + { + priv->AutoloadFailFlag=false; + } + + // + // Assign Chip Version ID + // + // Read IC Version && Channel Plan + if(!priv->AutoloadFailFlag) + { + // VID, PID + priv->eeprom_vid = eprom_read(priv, (EEPROM_VID >> 1)); + priv->eeprom_did = eprom_read(priv, (EEPROM_DID >> 1)); + + usValue = eprom_read(priv, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; + priv->eeprom_CustomerID = (u8)( usValue & 0xff); + usValue = eprom_read(priv, (EEPROM_ICVersion_ChannelPlan>>1)); + priv->eeprom_ChannelPlan = usValue&0xff; + IC_Version = ((usValue&0xff00)>>8); + + ICVer8192 = (IC_Version&0xf); //bit0~3; 1:A cut, 2:B cut, 3:C cut... + ICVer8256 = ((IC_Version&0xf0)>>4);//bit4~6, bit7 reserved for other RF chip; 1:A cut, 2:B cut, 3:C cut... + RT_TRACE(COMP_INIT, "ICVer8192 = 0x%x\n", ICVer8192); + RT_TRACE(COMP_INIT, "ICVer8256 = 0x%x\n", ICVer8256); + if(ICVer8192 == 0x2) //B-cut + { + if(ICVer8256 == 0x5) //E-cut + priv->card_8192_version= VERSION_8190_BE; + } + + switch(priv->card_8192_version) + { + case VERSION_8190_BD: + case VERSION_8190_BE: + break; + default: + priv->card_8192_version = VERSION_8190_BD; + break; + } + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); + } + else + { + priv->card_8192_version = VERSION_8190_BD; + priv->eeprom_vid = 0; + priv->eeprom_did = 0; + priv->eeprom_CustomerID = 0; + priv->eeprom_ChannelPlan = 0; + RT_TRACE(COMP_INIT, "IC Version = 0x%x\n", 0xff); + } + + RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); + RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); + RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); + + //2 Read Permanent MAC address + if(!priv->AutoloadFailFlag) + { + for(i = 0; i < 6; i += 2) + { + usValue = eprom_read(priv, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); + *(u16*)(&dev->dev_addr[i]) = usValue; + } + } else { + // when auto load failed, the last address byte set to be a random one. + // added by david woo.2007/11/7 + memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); + } + + RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", dev->dev_addr); + + //2 TX Power Check EEPROM Fail or not + if(priv->card_8192_version > VERSION_8190_BD) { + priv->bTXPowerDataReadFromEEPORM = true; + } else { + priv->bTXPowerDataReadFromEEPORM = false; + } + + // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R + priv->rf_type = RTL819X_DEFAULT_RF_TYPE; + + if(priv->card_8192_version > VERSION_8190_BD) + { + // Read RF-indication and Tx Power gain index diff of legacy to HT OFDM rate. + if(!priv->AutoloadFailFlag) + { + tempval = (eprom_read(priv, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; + priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; // bit[3:0] + + if (tempval&0x80) //RF-indication, bit[7] + priv->rf_type = RF_1T2R; + else + priv->rf_type = RF_2T4R; + } + else + { + priv->EEPROMLegacyHTTxPowerDiff = EEPROM_Default_LegacyHTTxPowerDiff; + } + RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", + priv->EEPROMLegacyHTTxPowerDiff); + + // Read ThermalMeter from EEPROM + if(!priv->AutoloadFailFlag) + { + priv->EEPROMThermalMeter = (u8)(((eprom_read(priv, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); + } + else + { + priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; + } + RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); + //vivi, for tx power track + priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; + + if(priv->epromtype == EPROM_93c46) + { + // Read antenna tx power offset of B/C/D to A and CrystalCap from EEPROM + if(!priv->AutoloadFailFlag) + { + usValue = eprom_read(priv, (EEPROM_TxPwDiff_CrystalCap>>1)); + priv->EEPROMAntPwDiff = (usValue&0x0fff); + priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); + } + else + { + priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + + // + // Get per-channel Tx Power Level + // + for(i=0; i<14; i+=2) + { + if(!priv->AutoloadFailFlag) + { + usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); + } + else + { + usValue = EEPROM_Default_TxPower; + } + *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; + RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); + } + for(i=0; i<14; i+=2) + { + if(!priv->AutoloadFailFlag) + { + usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); + } + else + { + usValue = EEPROM_Default_TxPower; + } + *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); + } + } + + // + // Update HAL variables. + // + if(priv->epromtype == EPROM_93c46) + { + for(i=0; i<14; i++) + { + priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; + priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; + } + priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + // Antenna B gain offset to antenna A, bit0~3 + priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); + // Antenna C gain offset to antenna A, bit4~7 + priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); + // Antenna D gain offset to antenna A, bit8~11 + priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); + // CrystalCap, bit12~15 + priv->CrystalCap = priv->EEPROMCrystalCap; + // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + } + else if(priv->epromtype == EPROM_93c56) + { + for(i=0; i<3; i++) // channel 1~3 use the same Tx Power Level. + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; + } + for(i=3; i<9; i++) // channel 4~9 use the same Tx Power Level + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; + } + for(i=9; i<14; i++) // channel 10~14 use the same Tx Power Level + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; + } + for(i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); + for(i=0; i<14; i++) + RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); + for(i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); + for(i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); + priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = 0; + priv->AntennaTxPwDiff[1] = 0; + priv->AntennaTxPwDiff[2] = 0; + priv->CrystalCap = priv->EEPROMCrystalCap; + // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + } + } + + if(priv->rf_type == RF_1T2R) + { + RT_TRACE(COMP_INIT, "1T2R config\n"); + } + else if (priv->rf_type == RF_2T4R) + { + RT_TRACE(COMP_INIT, "2T4R config\n"); + } + + // 2008/01/16 MH We can only know RF type in the function. So we have to init + // DIG RATR table again. + init_rate_adaptive(priv); + + //1 Make a copy for following variables and we can change them if we want + + if(priv->RegChannelPlan == 0xf) + { + priv->ChannelPlan = priv->eeprom_ChannelPlan; + } + else + { + priv->ChannelPlan = priv->RegChannelPlan; + } + + // + // Used PID and DID to Set CustomerID + // + if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) + { + priv->CustomerID = RT_CID_DLINK; + } + + switch(priv->eeprom_CustomerID) + { + case EEPROM_CID_DEFAULT: + priv->CustomerID = RT_CID_DEFAULT; + break; + case EEPROM_CID_CAMEO: + priv->CustomerID = RT_CID_819x_CAMEO; + break; + case EEPROM_CID_RUNTOP: + priv->CustomerID = RT_CID_819x_RUNTOP; + break; + case EEPROM_CID_NetCore: + priv->CustomerID = RT_CID_819x_Netcore; + break; + case EEPROM_CID_TOSHIBA: // Merge by Jacken, 2008/01/31 + priv->CustomerID = RT_CID_TOSHIBA; + if(priv->eeprom_ChannelPlan&0x80) + priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + else + priv->ChannelPlan = 0x0; + RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", + priv->ChannelPlan); + break; + case EEPROM_CID_Nettronix: + priv->CustomerID = RT_CID_Nettronix; + break; + case EEPROM_CID_Pronet: + priv->CustomerID = RT_CID_PRONET; + break; + case EEPROM_CID_DLINK: + priv->CustomerID = RT_CID_DLINK; + break; + + case EEPROM_CID_WHQL: + break; + default: + // value from RegCustomerID + break; + } + + //Avoid the channel plan array overflow, by Bruce, 2007-08-27. + if(priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) + priv->ChannelPlan = 0; //FCC + + if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) + priv->ieee80211->bSupportRemoteWakeUp = true; + else + priv->ieee80211->bSupportRemoteWakeUp = false; + + + RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); + RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); + RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); +} + + +static short rtl8192_get_channel_map(struct r8192_priv *priv) +{ +#ifdef ENABLE_DOT11D + if(priv->ChannelPlan> COUNTRY_CODE_GLOBAL_DOMAIN){ + printk("rtl8180_init:Error channel plan! Set to default.\n"); + priv->ChannelPlan= 0; + } + RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); + + rtl819x_set_channel_map(priv->ChannelPlan, priv); +#else + int ch,i; + //Set Default Channel Plan + if(!channels){ + DMESG("No channels, aborting"); + return -1; + } + ch=channels; + priv->ChannelPlan= 0;//hikaru + // set channels 1..14 allowed in given locale + for (i=1; i<=14; i++) { + (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); + ch >>= 1; + } +#endif + return 0; +} + +static short rtl8192_init(struct r8192_priv *priv) +{ + struct net_device *dev = priv->ieee80211->dev; + + memset(&(priv->stats),0,sizeof(struct Stats)); + rtl8192_init_priv_variable(priv); + rtl8192_init_priv_lock(priv); + rtl8192_init_priv_task(priv); + rtl8192_get_eeprom_size(priv); + rtl8192_read_eeprom_info(priv); + rtl8192_get_channel_map(priv); + init_hal_dm(priv); + init_timer(&priv->watch_dog_timer); + priv->watch_dog_timer.data = (unsigned long)priv; + priv->watch_dog_timer.function = watch_dog_timer_callback; + if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) { + printk("Error allocating IRQ %d",dev->irq); + return -1; + }else{ + priv->irq=dev->irq; + printk("IRQ %d",dev->irq); + } + if (rtl8192_pci_initdescring(priv) != 0){ + printk("Endopoints initialization failed"); + return -1; + } + + return 0; +} + +/* + * Actually only set RRSR, RATR and BW_OPMODE registers + * not to do all the hw config as its name says + * This part need to modified according to the rate set we filtered + */ +static void rtl8192_hwconfig(struct r8192_priv *priv) +{ + u32 regRATR = 0, regRRSR = 0; + u8 regBwOpMode = 0, regTmp = 0; + +// Set RRSR, RATR, and BW_OPMODE registers + // + switch (priv->ieee80211->mode) + { + case WIRELESS_MODE_B: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK; + regRRSR = RATE_ALL_CCK; + break; + case WIRELESS_MODE_A: + regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regRATR = RATE_ALL_OFDM_AG; + regRRSR = RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_G: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_AUTO: + case WIRELESS_MODE_N_24G: + // It support CCK rate by default. + // CCK rate will be filtered out only when associated AP does not support it. + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_N_5G: + regBwOpMode = BW_OPMODE_5G; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRRSR = RATE_ALL_OFDM_AG; + break; + } + + write_nic_byte(priv, BW_OPMODE, regBwOpMode); + { + u32 ratr_value = 0; + ratr_value = regRATR; + if (priv->rf_type == RF_1T2R) + { + ratr_value &= ~(RATE_ALL_OFDM_2SS); + } + write_nic_dword(priv, RATR0, ratr_value); + write_nic_byte(priv, UFWP, 1); + } + regTmp = read_nic_byte(priv, 0x313); + regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); + write_nic_dword(priv, RRSR, regRRSR); + + // + // Set Retry Limit here + // + write_nic_word(priv, RETRY_LIMIT, + priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | + priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); + // Set Contention Window here + + // Set Tx AGC + + // Set Tx Antenna including Feedback control + + // Set Auto Rate fallback control + + +} + + +static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv) +{ + struct net_device *dev = priv->ieee80211->dev; + u32 ulRegRead; + RT_STATUS rtStatus = RT_STATUS_SUCCESS; + u8 tmpvalue; + u8 ICVersion,SwitchingRegulatorOutput; + bool bfirmwareok = true; + u32 tmpRegA, tmpRegC, TempCCk; + int i =0; + + RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__); + priv->being_init_adapter = true; + rtl8192_pci_resetdescring(priv); + // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W. + priv->Rf_Mode = RF_OP_By_SW_3wire; + + //dPLL on + if(priv->ResetProgress == RESET_TYPE_NORESET) + { + write_nic_byte(priv, ANAPAR, 0x37); + // Accordign to designer's explain, LBUS active will never > 10ms. We delay 10ms + // Joseph increae the time to prevent firmware download fail + mdelay(500); + } + + //PlatformSleepUs(10000); + // For any kind of InitializeAdapter process, we shall use system now!! + priv->pFirmware->firmware_status = FW_STATUS_0_INIT; + + // + //3 //Config CPUReset Register + //3// + //3 Firmware Reset Or Not + ulRegRead = read_nic_dword(priv, CPU_GEN); + if(priv->pFirmware->firmware_status == FW_STATUS_0_INIT) + { //called from MPInitialized. do nothing + ulRegRead |= CPU_GEN_SYSTEM_RESET; + }else if(priv->pFirmware->firmware_status == FW_STATUS_5_READY) + ulRegRead |= CPU_GEN_FIRMWARE_RESET; // Called from MPReset + else + RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status); + + write_nic_dword(priv, CPU_GEN, ulRegRead); + + //3// + //3 //Fix the issue of E-cut high temperature issue + //3// + // TODO: E cut only + ICVersion = read_nic_byte(priv, IC_VERRSION); + if(ICVersion >= 0x4) //E-cut only + { + // HW SD suggest that we should not wirte this register too often, so driver + // should readback this register. This register will be modified only when + // power on reset + SwitchingRegulatorOutput = read_nic_byte(priv, SWREGULATOR); + if(SwitchingRegulatorOutput != 0xb8) + { + write_nic_byte(priv, SWREGULATOR, 0xa8); + mdelay(1); + write_nic_byte(priv, SWREGULATOR, 0xb8); + } + } + + //3// + //3// Initialize BB before MAC + //3// + RT_TRACE(COMP_INIT, "BB Config Start!\n"); + rtStatus = rtl8192_BBConfig(priv); + if(rtStatus != RT_STATUS_SUCCESS) + { + RT_TRACE(COMP_ERR, "BB Config failed\n"); + return rtStatus; + } + RT_TRACE(COMP_INIT,"BB Config Finished!\n"); + + //3//Set Loopback mode or Normal mode + //3// + //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings + // because setting of System_Reset bit reset MAC to default transmission mode. + //Loopback mode or not + priv->LoopbackMode = RTL819X_NO_LOOPBACK; + if(priv->ResetProgress == RESET_TYPE_NORESET) + { + ulRegRead = read_nic_dword(priv, CPU_GEN); + if(priv->LoopbackMode == RTL819X_NO_LOOPBACK) + { + ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); + } + else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) + { + ulRegRead |= CPU_CCK_LOOPBACK; + } + else + { + RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); + } + + //2008.06.03, for WOL + //ulRegRead &= (~(CPU_GEN_GPIO_UART)); + write_nic_dword(priv, CPU_GEN, ulRegRead); + + // 2006.11.29. After reset cpu, we sholud wait for a second, otherwise, it may fail to write registers. Emily + udelay(500); + } + //3Set Hardware(Do nothing now) + rtl8192_hwconfig(priv); + //2======================================================= + // Common Setting for all of the FPGA platform. (part 1) + //2======================================================= + // If there is changes, please make sure it applies to all of the FPGA version + //3 Turn on Tx/Rx + write_nic_byte(priv, CMDR, CR_RE|CR_TE); + + //2Set Tx dma burst + write_nic_byte(priv, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); + write_nic_word(priv, MAC4, ((u16*)(dev->dev_addr + 4))[0]); + //set RCR + write_nic_dword(priv, RCR, priv->ReceiveConfig); + + //3 Initialize Number of Reserved Pages in Firmware Queue + write_nic_dword(priv, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | + NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | + NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | + NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) + rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode); + //----------------------------------------------------------------------------- + // Set up security related. 070106, by rcnjko: + // 1. Clear all H/W keys. + // 2. Enable H/W encryption/decryption. + //----------------------------------------------------------------------------- + CamResetAllEntry(priv); + { + u8 SECR_value = 0x0; + SECR_value |= SCR_TxEncEnable; + SECR_value |= SCR_RxDecEnable; + SECR_value |= SCR_NoSKMC; + write_nic_byte(priv, SECR, SECR_value); + } + //3Beacon related + write_nic_word(priv, ATIMWND, 2); + write_nic_word(priv, BCN_INTERVAL, 100); + for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { + rtl8192_phy_getTxPower(priv); + rtl8192_phy_setTxPower(priv, priv->chan); + } + + //if D or C cut + tmpvalue = read_nic_byte(priv, IC_VERRSION); + priv->IC_Cut = tmpvalue; + RT_TRACE(COMP_INIT, "priv->IC_Cut = 0x%x\n", priv->IC_Cut); + if(priv->IC_Cut >= IC_VersionCut_D) + { + //pHalData->bDcut = TRUE; + if(priv->IC_Cut == IC_VersionCut_D) + RT_TRACE(COMP_INIT, "D-cut\n"); + if(priv->IC_Cut == IC_VersionCut_E) + { + RT_TRACE(COMP_INIT, "E-cut\n"); + // HW SD suggest that we should not wirte this register too often, so driver + // should readback this register. This register will be modified only when + // power on reset + } + } + else + { + //pHalData->bDcut = FALSE; + RT_TRACE(COMP_INIT, "Before C-cut\n"); + } + + //Firmware download + RT_TRACE(COMP_INIT, "Load Firmware!\n"); + bfirmwareok = init_firmware(priv); + if(bfirmwareok != true) { + rtStatus = RT_STATUS_FAILURE; + return rtStatus; + } + RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); + + //RF config + if(priv->ResetProgress == RESET_TYPE_NORESET) + { + RT_TRACE(COMP_INIT, "RF Config Started!\n"); + rtStatus = rtl8192_phy_RFConfig(priv); + if(rtStatus != RT_STATUS_SUCCESS) + { + RT_TRACE(COMP_ERR, "RF Config failed\n"); + return rtStatus; + } + RT_TRACE(COMP_INIT, "RF Config Finished!\n"); + } + rtl8192_phy_updateInitGain(priv); + + /*---- Set CCK and OFDM Block "ON"----*/ + rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn, 0x1); + rtl8192_setBBreg(priv, rFPGA0_RFMOD, bOFDMEn, 0x1); + + //Enable Led + write_nic_byte(priv, 0x87, 0x0); + + //2======================================================= + // RF Power Save + //2======================================================= +#ifdef ENABLE_IPS + +{ + if(priv->RfOffReason > RF_CHANGE_BY_PS) + { // H/W or S/W RF OFF before sleep. + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__,priv->RfOffReason); + MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); + } + else if(priv->RfOffReason >= RF_CHANGE_BY_IPS) + { // H/W or S/W RF OFF before sleep. + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__, priv->RfOffReason); + MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); + } + else + { + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__FUNCTION__); + priv->eRFPowerState = eRfOn; + priv->RfOffReason = 0; + } +} +#endif + // We can force firmware to do RF-R/W + if(priv->ieee80211->FwRWRF) + priv->Rf_Mode = RF_OP_By_FW; + else + priv->Rf_Mode = RF_OP_By_SW_3wire; + + if(priv->ResetProgress == RESET_TYPE_NORESET) + { + dm_initialize_txpower_tracking(priv); + + if(priv->IC_Cut >= IC_VersionCut_D) + { + tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); + tmpRegC = rtl8192_QueryBBReg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord); + for(i = 0; itxbbgain_table[i].txbbgain_value) + { + priv->rfa_txpowertrackingindex= (u8)i; + priv->rfa_txpowertrackingindex_real= (u8)i; + priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + break; + } + } + + TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); + + for(i=0 ; icck_txbbgain_table[i].ccktxbb_valuearray[0]) + { + priv->CCKPresentAttentuation_20Mdefault =(u8) i; + break; + } + } + priv->CCKPresentAttentuation_40Mdefault = 0; + priv->CCKPresentAttentuation_difference = 0; + priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); + priv->btxpower_tracking = FALSE;//TEMPLY DISABLE + } + } + + rtl8192_irq_enable(priv); + priv->being_init_adapter = false; + return rtStatus; + +} + +static void rtl8192_prepare_beacon(unsigned long arg) +{ + struct r8192_priv *priv = (struct r8192_priv*) arg; + struct sk_buff *skb; + cb_desc *tcb_desc; + + skb = ieee80211_get_beacon(priv->ieee80211); + tcb_desc = (cb_desc *)(skb->cb + 8); + /* prepare misc info for the beacon xmit */ + tcb_desc->queue_index = BEACON_QUEUE; + /* IBSS does not support HT yet, use 1M defaultly */ + tcb_desc->data_rate = 2; + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + + skb_push(skb, priv->ieee80211->tx_headroom); + if(skb){ + rtl8192_tx(priv, skb); + } +} + + +/* + * configure registers for beacon tx and enables it via + * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might + * be used to stop beacon transmission + */ +static void rtl8192_start_beacon(struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + struct ieee80211_network *net = &priv->ieee80211->current_network; + u16 BcnTimeCfg = 0; + u16 BcnCW = 6; + u16 BcnIFS = 0xf; + + DMESG("Enabling beacon TX"); + rtl8192_irq_disable(priv); + //rtl8192_beacon_tx_enable(dev); + + /* ATIM window */ + write_nic_word(priv, ATIMWND, 2); + + /* Beacon interval (in unit of TU) */ + write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); + + /* + * DrvErlyInt (in unit of TU). + * (Time to send interrupt to notify driver to c + * hange beacon content) + * */ + write_nic_word(priv, BCN_DRV_EARLY_INT, 10); + + /* + * BcnDMATIM(in unit of us). + * Indicates the time before TBTT to perform beacon queue DMA + * */ + write_nic_word(priv, BCN_DMATIME, 256); + + /* + * Force beacon frame transmission even after receiving + * beacon frame from other ad hoc STA + * */ + write_nic_byte(priv, BCN_ERR_THRESH, 100); + + /* Set CW and IFS */ + BcnTimeCfg |= BcnCW<RxCounter); + // If rssi is small, we should check rx for long time because of bad rx. + // or maybe it will continuous silent reset every 2 seconds. + priv->rx_chk_cnt++; + if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) + { + priv->rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ + } + else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && + ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) || + (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) ) + + { + if(priv->rx_chk_cnt < 2) + { + return bStuck; + } + else + { + priv->rx_chk_cnt = 0; + } + } + else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbCurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbundecorated_smoothed_pwdb >= VeryLowRSSI) + { + if(priv->rx_chk_cnt < 4) + { + return bStuck; + } + else + { + priv->rx_chk_cnt = 0; + } + } + else + { + if(priv->rx_chk_cnt < 8) + { + return bStuck; + } + else + { + priv->rx_chk_cnt = 0; + } + } + if(priv->RxCounter==RegRxCounter) + bStuck = TRUE; + + priv->RxCounter = RegRxCounter; + + return bStuck; +} + +static RESET_TYPE RxCheckStuck(struct r8192_priv *priv) +{ + + if(HalRxCheckStuck8190Pci(priv)) + { + RT_TRACE(COMP_RESET, "RxStuck Condition\n"); + return RESET_TYPE_SILENT; + } + + return RESET_TYPE_NORESET; +} + +static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv) +{ + RESET_TYPE RxResetType = RESET_TYPE_NORESET; + RT_RF_POWER_STATE rfState; + + rfState = priv->eRFPowerState; + + if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { + /* + * If driver is in the status of firmware download failure, + * driver skips RF initialization and RF is in turned off state. + * Driver should check whether Rx stuck and do silent reset. And + * if driver is in firmware download failure status, driver + * should initialize RF in the following silent reset procedure + * + * Driver should not check RX stuck in IBSS mode because it is + * required to set Check BSSID in order to send beacon, however, + * if check BSSID is set, STA cannot hear any packet a all. + */ + RxResetType = RxCheckStuck(priv); + } + + RT_TRACE(COMP_RESET, "%s(): RxResetType is %d\n", __FUNCTION__, RxResetType); + + return RxResetType; +} + +#ifdef ENABLE_IPS +static void InactivePsWorkItemCallback(struct r8192_priv *priv) +{ + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + + RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() --------->\n"); + // + // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem + // is really scheduled. + // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the + // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing + // blocks the IPS procedure of switching RF. + // By Bruce, 2007-12-25. + // + pPSC->bSwRfProcessing = TRUE; + + RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", + pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); + + + MgntActSet_RF_State(priv, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); + + // + // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20. + // + pPSC->bSwRfProcessing = FALSE; + RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <---------\n"); +} + +#ifdef ENABLE_LPS +/* Change current and default preamble mode. */ +bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode) +{ + + // Currently, we do not change power save mode on IBSS mode. + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) + { + return false; + } + + // + // If we make HW to fill up the PwrMgt bit for us, + // some AP will not response to our mgnt frames with PwrMgt bit set, + // e.g. cannot associate the AP. + // So I commented out it. 2005.02.16, by rcnjko. + // +// // Change device's power save mode. +// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); + + // Update power save mode configured. + //RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__FUNCTION__,rtPsMode); + if(!priv->ps_force) { + priv->ieee80211->ps = rtPsMode; + } + + // Awake immediately + if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED) + { + // Notify the AP we awke. + rtl8192_hw_wakeup(priv->ieee80211); + priv->ieee80211->sta_sleep = 0; + + spin_lock(&priv->ieee80211->mgmt_tx_lock); + printk("LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); + ieee80211_sta_ps_send_null_frame(priv->ieee80211, 0); + spin_unlock(&priv->ieee80211->mgmt_tx_lock); + } + + return true; +} + +/* Enter the leisure power save mode. */ +void LeisurePSEnter(struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + + if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) && + (priv->ieee80211->state == IEEE80211_LINKED)) || + (priv->ieee80211->iw_mode == IW_MODE_ADHOC) || + (priv->ieee80211->iw_mode == IW_MODE_MASTER)) + return; + + if (pPSC->bLeisurePs) + { + // Idle for a while if we connect to AP a while ago. + if(pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) // 4 Sec + { + + if(priv->ieee80211->ps == IEEE80211_PS_DISABLED) + { + MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); + + } + } + else + pPSC->LpsIdleCount++; + } +} + + +/* Leave leisure power save mode. */ +void LeisurePSLeave(struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + + if (pPSC->bLeisurePs) + { + if(priv->ieee80211->ps != IEEE80211_PS_DISABLED) + { + // move to lps_wakecomplete() + MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); + + } + } +} +#endif + + +/* Enter the inactive power save mode. RF will be off */ +void IPSEnter(struct r8192_priv *priv) +{ + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + RT_RF_POWER_STATE rtState; + + if (pPSC->bInactivePs) + { + rtState = priv->eRFPowerState; + // + // Added by Bruce, 2007-12-25. + // Do not enter IPS in the following conditions: + // (1) RF is already OFF or Sleep + // (2) bSwRfProcessing (indicates the IPS is still under going) + // (3) Connectted (only disconnected can trigger IPS) + // (4) IBSS (send Beacon) + // (5) AP mode (send Beacon) + // + if (rtState == eRfOn && !pPSC->bSwRfProcessing + && (priv->ieee80211->state != IEEE80211_LINKED) ) + { + RT_TRACE(COMP_RF,"IPSEnter(): Turn off RF.\n"); + pPSC->eInactivePowerState = eRfOff; +// queue_work(priv->priv_wq,&(pPSC->InactivePsWorkItem)); + InactivePsWorkItemCallback(priv); + } + } +} + +// +// Description: +// Leave the inactive power save mode, RF will be on. +// 2007.08.17, by shien chang. +// +void IPSLeave(struct r8192_priv *priv) +{ + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + RT_RF_POWER_STATE rtState; + + if (pPSC->bInactivePs) + { + rtState = priv->eRFPowerState; + if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_POWER, "IPSLeave(): Turn on RF.\n"); + pPSC->eInactivePowerState = eRfOn; + InactivePsWorkItemCallback(priv); + } + } +} + +void IPSLeave_wq(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq); + struct net_device *dev = ieee->dev; + + struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); + down(&priv->ieee80211->ips_sem); + IPSLeave(priv); + up(&priv->ieee80211->ips_sem); +} + +void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + RT_RF_POWER_STATE rtState; + rtState = priv->eRFPowerState; + + if (priv->PowerSaveControl.bInactivePs){ + if(rtState == eRfOff){ + if(priv->RfOffReason > RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); + return; + } + else{ + printk("=========>%s(): IPSLeave\n",__FUNCTION__); + queue_work(priv->ieee80211->wq,&priv->ieee80211->ips_leave_wq); + } + } + } +} +//added by amy 090331 end +void ieee80211_ips_leave(struct ieee80211_device *ieee80211) +{ + struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); + down(&ieee80211->ips_sem); + IPSLeave(priv); + up(&ieee80211->ips_sem); +} +#endif + +static void rtl819x_update_rxcounts( + struct r8192_priv *priv, + u32* TotalRxBcnNum, + u32* TotalRxDataNum +) +{ + u16 SlotIndex; + u8 i; + + *TotalRxBcnNum = 0; + *TotalRxDataNum = 0; + + SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); + priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; + priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; + for( i=0; iieee80211->LinkDetectInfo.SlotNum; i++ ){ + *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; + *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; + } +} + + +static void rtl819x_watchdog_wqcallback(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work,struct delayed_work,work); + struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); + struct ieee80211_device* ieee = priv->ieee80211; + RESET_TYPE ResetType = RESET_TYPE_NORESET; + bool bBusyTraffic = false; + bool bEnterPS = false; + + if ((!priv->up) || priv->bHwRadioOff) + return; + + if(!priv->up) + return; + hal_dm_watchdog(priv); +#ifdef ENABLE_IPS + if(ieee->actscanning == false){ + if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) && + (priv->eRFPowerState == eRfOn) && !ieee->is_set_key && + (!ieee->proto_stoppping) && !ieee->wx_set_enc){ + if (priv->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){ + IPSEnter(priv); + } + } + } +#endif + {//to get busy traffic condition + if(ieee->state == IEEE80211_LINKED) + { + if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || + ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { + bBusyTraffic = true; + } + +#ifdef ENABLE_LPS + //added by amy for Leisure PS + if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) + { + bEnterPS= false; + } + else + { + bEnterPS= true; + } + + // LeisurePS only work in infra mode. + if(bEnterPS) + { + LeisurePSEnter(priv->ieee80211); + } + else + { + LeisurePSLeave(priv->ieee80211); + } +#endif + + } + else + { +#ifdef ENABLE_LPS + LeisurePSLeave(priv->ieee80211); +#endif + } + + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + } + + + //added by amy for AP roaming + if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) + { + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; + + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + if((TotalRxBcnNum+TotalRxDataNum) == 0) + { + if (priv->eRFPowerState == eRfOff) + RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); + printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); + // Dot11d_Reset(dev); + ieee->state = IEEE80211_ASSOCIATING; + notify_wx_assoc_event(priv->ieee80211); + RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); + ieee->is_roaming = true; + ieee->is_set_key = false; + ieee->link_change(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); + } + } + ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; + ieee->LinkDetectInfo.NumRecvDataInPeriod=0; + + //check if reset the driver + if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && + priv->watchdog_last_time != 1) + { + ResetType = rtl819x_check_reset(priv); + priv->watchdog_check_reset_cnt = 3; + } + if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) + { + priv->ResetProgress = RESET_TYPE_NORMAL; + RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__FUNCTION__); + return; + } + /* disable silent reset temply 2008.9.11*/ + + if( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) // This is control by OID set in Pomelo + { + priv->watchdog_last_time = 1; + } + else + priv->watchdog_last_time = 0; + + priv->force_reset = false; + priv->bForcedSilentReset = false; + priv->bResetInProgress = false; + RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); + +} + +void watch_dog_timer_callback(unsigned long data) +{ + struct r8192_priv *priv = (struct r8192_priv *) data; + queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0); + mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); + +} + +static int _rtl8192_up(struct r8192_priv *priv) +{ + RT_STATUS init_status = RT_STATUS_SUCCESS; + struct net_device *dev = priv->ieee80211->dev; + + priv->up=1; + priv->ieee80211->ieee_up=1; + priv->bdisable_nic = false; //YJ,add,091111 + RT_TRACE(COMP_INIT, "Bringing up iface\n"); + + init_status = rtl8192_adapter_start(priv); + if(init_status != RT_STATUS_SUCCESS) + { + RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); + return -1; + } + RT_TRACE(COMP_INIT, "start adapter finished\n"); + + if (priv->eRFPowerState != eRfOn) + MgntActSet_RF_State(priv, eRfOn, priv->RfOffReason); + + if(priv->ieee80211->state != IEEE80211_LINKED) + ieee80211_softmac_start_protocol(priv->ieee80211); + ieee80211_reset_queue(priv->ieee80211); + watch_dog_timer_callback((unsigned long) priv); + if(!netif_queue_stopped(dev)) + netif_start_queue(dev); + else + netif_wake_queue(dev); + + return 0; +} + + +static int rtl8192_open(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + int ret; + + down(&priv->wx_sem); + ret = rtl8192_up(dev); + up(&priv->wx_sem); + return ret; + +} + + +int rtl8192_up(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + + if (priv->up == 1) return -1; + + return _rtl8192_up(priv); +} + + +static int rtl8192_close(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + int ret; + + down(&priv->wx_sem); + + ret = rtl8192_down(dev); + + up(&priv->wx_sem); + + return ret; + +} + +int rtl8192_down(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + + if (priv->up == 0) return -1; + +#ifdef ENABLE_LPS + //LZM for PS-Poll AID issue. 090429 + if(priv->ieee80211->state == IEEE80211_LINKED) + LeisurePSLeave(priv->ieee80211); +#endif + + priv->up=0; + priv->ieee80211->ieee_up = 0; + RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__); +/* FIXME */ + if (!netif_queue_stopped(dev)) + netif_stop_queue(dev); + + rtl8192_irq_disable(priv); + rtl8192_cancel_deferred_work(priv); + deinit_hal_dm(priv); + del_timer_sync(&priv->watch_dog_timer); + + ieee80211_softmac_stop_protocol(priv->ieee80211,true); + + rtl8192_halt_adapter(priv, false); + memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list)); + + RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__); + + return 0; +} + + +void rtl8192_commit(struct r8192_priv *priv) +{ + if (priv->up == 0) return ; + + + ieee80211_softmac_stop_protocol(priv->ieee80211,true); + + rtl8192_irq_disable(priv); + rtl8192_halt_adapter(priv, true); + _rtl8192_up(priv); +} + +static void rtl8192_restart(struct work_struct *work) +{ + struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); + + down(&priv->wx_sem); + + rtl8192_commit(priv); + + up(&priv->wx_sem); +} + +static void r8192_set_multicast(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + + priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; +} + + +static int r8192_set_mac_adr(struct net_device *dev, void *mac) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + struct sockaddr *addr = mac; + + down(&priv->wx_sem); + + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + + schedule_work(&priv->reset_wq); + up(&priv->wx_sem); + + return 0; +} + +static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw) +{ + struct ieee80211_device *ieee = priv->ieee80211; + u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u32 key[4]; + + if (ipw->u.crypt.set_tx) { + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = KEY_TYPE_WEP40; + } else + ieee->pairwise_key_type = KEY_TYPE_NA; + + if (ieee->pairwise_key_type) { + memcpy(key, ipw->u.crypt.key, 16); + EnableHWSecurityConfig8192(priv); + /* + * We fill both index entry and 4th entry for pairwise + * key as in IPW interface, adhoc will only get here, + * so we need index entry for its default key serching! + */ + setKey(priv, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8*)ieee->ap_mac_addr, 0, key); + + /* LEAP WEP will never set this. */ + if (ieee->auth_mode != 2) + setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8*)ieee->ap_mac_addr, 0, key); + } + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && + ieee->pHTInfo->bCurrentHTSupport) { + write_nic_byte(priv, 0x173, 1); /* fix aes bug */ + } + } else { + memcpy(key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type= KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = KEY_TYPE_WEP40; + } else + ieee->group_key_type = KEY_TYPE_NA; + + if (ieee->group_key_type) { + setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, + ieee->group_key_type, broadcast_addr, 0, key); + } + } +} + +/* based on ipw2200 driver */ +static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); + struct iwreq *wrq = (struct iwreq *)rq; + int ret=-1; + struct iw_point *p = &wrq->u.data; + struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer; + + down(&priv->wx_sem); + + + if (p->length < sizeof(struct ieee_param) || !p->pointer){ + ret = -EINVAL; + goto out; + } + + ipw = kmalloc(p->length, GFP_KERNEL); + if (ipw == NULL){ + ret = -ENOMEM; + goto out; + } + if (copy_from_user(ipw, p->pointer, p->length)) { + kfree(ipw); + ret = -EFAULT; + goto out; + } + + switch (cmd) { + case RTL_IOCTL_WPA_SUPPLICANT: + /* parse here for HW security */ + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) + r8192e_set_hw_key(priv, ipw); + ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + break; + + default: + ret = -EOPNOTSUPP; + break; + } + + kfree(ipw); +out: + up(&priv->wx_sem); + + return ret; +} + +static u8 HwRateToMRate90(bool bIsHT, u8 rate) +{ + u8 ret_rate = 0x02; + + if(!bIsHT) { + switch(rate) { + case DESC90_RATE1M: ret_rate = MGN_1M; break; + case DESC90_RATE2M: ret_rate = MGN_2M; break; + case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; + case DESC90_RATE11M: ret_rate = MGN_11M; break; + case DESC90_RATE6M: ret_rate = MGN_6M; break; + case DESC90_RATE9M: ret_rate = MGN_9M; break; + case DESC90_RATE12M: ret_rate = MGN_12M; break; + case DESC90_RATE18M: ret_rate = MGN_18M; break; + case DESC90_RATE24M: ret_rate = MGN_24M; break; + case DESC90_RATE36M: ret_rate = MGN_36M; break; + case DESC90_RATE48M: ret_rate = MGN_48M; break; + case DESC90_RATE54M: ret_rate = MGN_54M; break; + + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; + } + + } else { + switch(rate) { + case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; + case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; + case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; + case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; + case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; + case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; + case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; + case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; + case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; + case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; + case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; + case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; + case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; + case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; + case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; + case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; + case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); + break; + } + } + + return ret_rate; +} + +/* Record the TSF time stamp when receiving a packet */ +static void UpdateRxPktTimeStamp8190(struct r8192_priv *priv, struct ieee80211_rx_stats *stats) +{ + + if(stats->bIsAMPDU && !stats->bFirstMPDU) { + stats->mac_time[0] = priv->LastRxDescTSFLow; + stats->mac_time[1] = priv->LastRxDescTSFHigh; + } else { + priv->LastRxDescTSFLow = stats->mac_time[0]; + priv->LastRxDescTSFHigh = stats->mac_time[1]; + } +} + +static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. +{ + long signal_power; // in dBm. + + // Translate to dBm (x=0.5y-95). + signal_power = (long)((signal_strength_index + 1) >> 1); + signal_power -= 95; + + return signal_power; +} + +/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to + be a local static. Otherwise, it may increase when we return from S3/S4. The + value will be kept in memory or disk. We must delcare the value in adapter + and it will be reinitialized when return from S3/S4. */ +static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats) +{ + bool bcheck = false; + u8 rfpath; + u32 nspatial_stream, tmp_val; + static u32 slide_rssi_index=0, slide_rssi_statistics=0; + static u32 slide_evm_index=0, slide_evm_statistics=0; + static u32 last_rssi=0, last_evm=0; + //cosa add for beacon rssi smoothing + static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; + static u32 last_beacon_adc_pwdb=0; + + struct ieee80211_hdr_3addr *hdr; + u16 sc ; + unsigned int frag,seq; + hdr = (struct ieee80211_hdr_3addr *)buffer; + sc = le16_to_cpu(hdr->seq_ctl); + frag = WLAN_GET_SEQ_FRAG(sc); + seq = WLAN_GET_SEQ_SEQ(sc); + + // + // Check whether we should take the previous packet into accounting + // + if(!pprevious_stats->bIsAMPDU) + { + // if previous packet is not aggregated packet + bcheck = true; + } + + if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) + { + slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; + last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; + priv->stats.slide_rssi_total -= last_rssi; + } + priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; + + priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) + slide_rssi_index = 0; + + // <1> Showed on UI for user, in dbm + tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; + priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); + pcurrent_stats->rssi = priv->stats.signal_strength; + // + // If the previous packet does not match the criteria, neglect it + // + if(!pprevious_stats->bPacketMatchBSSID) + { + if(!pprevious_stats->bToSelfBA) + return; + } + + if(!bcheck) + return; + + // <2> Showed on UI for engineering + // hardware does not provide rssi information for each rf path in CCK + if(!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) + { + for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) + { + if (!rtl8192_phy_CheckIsLegalRFPath(priv, rfpath)) + continue; + RT_TRACE(COMP_DBG, "pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", pprevious_stats->RxMIMOSignalStrength[rfpath]); + //Fixed by Jacken 2008-03-20 + if(priv->stats.rx_rssi_percentage[rfpath] == 0) + { + priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; + } + if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) + { + priv->stats.rx_rssi_percentage[rfpath] = + ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; + } + else + { + priv->stats.rx_rssi_percentage[rfpath] = + ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + } + RT_TRACE(COMP_DBG, "priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" , priv->stats.rx_rssi_percentage[rfpath]); + } + } + + + // + // Check PWDB. + // + //cosa add for beacon rssi smoothing by average. + if(pprevious_stats->bPacketBeacon) + { + /* record the beacon pwdb to the sliding window. */ + if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) + { + slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; + last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; + priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; + // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total); + } + priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; + priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; + slide_beacon_adc_pwdb_index++; + if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) + slide_beacon_adc_pwdb_index = 0; + pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; + if(pprevious_stats->RxPWDBAll >= 3) + pprevious_stats->RxPWDBAll -= 3; + } + + RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", + pprevious_stats->bIsCCK? "CCK": "OFDM", + pprevious_stats->RxPWDBAll); + + if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) + { + if(priv->undecorated_smoothed_pwdb < 0) // initialize + { + priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; + } + + if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) + { + priv->undecorated_smoothed_pwdb = + ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; + } + else + { + priv->undecorated_smoothed_pwdb = + ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + } + } + + // + // Check EVM + // + /* record the general EVM to the sliding window. */ + if(pprevious_stats->SignalQuality == 0) + { + } + else + { + if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ + if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ + slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; + last_evm = priv->stats.slide_evm[slide_evm_index]; + priv->stats.slide_evm_total -= last_evm; + } + + priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + + priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) + slide_evm_index = 0; + + // <1> Showed on UI for user, in percentage. + tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. + } + + // <2> Showed on UI for engineering + if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) + { + for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream + { + if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) + { + if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize + { + priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; + } + priv->stats.rx_evm_percentage[nspatial_stream] = + ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + } + } + } + } + +} + +static u8 rtl819x_query_rxpwrpercentage( + char antpower + ) +{ + if ((antpower <= -100) || (antpower >= 20)) + { + return 0; + } + else if (antpower >= 0) + { + return 100; + } + else + { + return (100+antpower); + } + +} + +static u8 +rtl819x_evm_dbtopercentage( + char value + ) +{ + char ret_val; + + ret_val = value; + + if(ret_val >= 0) + ret_val = 0; + if(ret_val <= -33) + ret_val = -33; + ret_val = 0 - ret_val; + ret_val*=3; + if(ret_val == 99) + ret_val = 100; + return ret_val; +} + +/* We want good-looking for signal strength/quality */ +static long rtl819x_signal_scale_mapping(long currsig) +{ + long retsig; + + // Step 1. Scale mapping. + if(currsig >= 61 && currsig <= 100) + { + retsig = 90 + ((currsig - 60) / 4); + } + else if(currsig >= 41 && currsig <= 60) + { + retsig = 78 + ((currsig - 40) / 2); + } + else if(currsig >= 31 && currsig <= 40) + { + retsig = 66 + (currsig - 30); + } + else if(currsig >= 21 && currsig <= 30) + { + retsig = 54 + (currsig - 20); + } + else if(currsig >= 5 && currsig <= 20) + { + retsig = 42 + (((currsig - 5) * 2) / 3); + } + else if(currsig == 4) + { + retsig = 36; + } + else if(currsig == 3) + { + retsig = 27; + } + else if(currsig == 2) + { + retsig = 18; + } + else if(currsig == 1) + { + retsig = 9; + } + else + { + retsig = currsig; + } + + return retsig; +} + +static void rtl8192_query_rxphystatus( + struct r8192_priv * priv, + struct ieee80211_rx_stats * pstats, + prx_desc_819x_pci pdesc, + prx_fwinfo_819x_pci pdrvinfo, + struct ieee80211_rx_stats * precord_stats, + bool bpacket_match_bssid, + bool bpacket_toself, + bool bPacketBeacon, + bool bToSelfBA + ) +{ + //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status); + phy_sts_ofdm_819xpci_t* pofdm_buf; + phy_sts_cck_819xpci_t * pcck_buf; + phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; + u8 *prxpkt; + u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all=0; + //long rx_avg_pwr = 0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi=0;//, total_evm=0; +// long signal_strength_index = 0; + u8 is_cck_rate=0; + u8 rf_rx_num = 0; + + is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); + + // Record it for next packet processing + memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); + pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; + pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo); + pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; + pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; + /*2007.08.30 requested by SD3 Jerry */ + if (priv->phy_check_reg824 == 0) + { + priv->phy_reg824_bit9 = rtl8192_QueryBBReg(priv, rFPGA0_XA_HSSIParameter2, 0x200); + priv->phy_check_reg824 = 1; + } + + + prxpkt = (u8*)pdrvinfo; + + /* Move pointer to the 16th bytes. Phy status start address. */ + prxpkt += sizeof(rx_fwinfo_819x_pci); + + /* Initial the cck and ofdm buffer pointer */ + pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; + pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; + + pstats->RxMIMOSignalQuality[0] = -1; + pstats->RxMIMOSignalQuality[1] = -1; + precord_stats->RxMIMOSignalQuality[0] = -1; + precord_stats->RxMIMOSignalQuality[1] = -1; + + if(is_cck_rate) + { + // + // (1)Hardware does not provide RSSI for CCK + // + + // + // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) + // + u8 report;//, cck_agc_rpt; + + if (!priv->phy_reg824_bit9) + { + report = pcck_buf->cck_agc_rpt & 0xc0; + report = report>>6; + switch(report) + { + //Fixed by Jacken from Bryant 2008-03-20 + //Original value is -38 , -26 , -14 , -2 + //Fixed value is -35 , -23 , -11 , 6 + case 0x3: + rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x2: + rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x1: + rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x0: + rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + } + } + else + { + report = pcck_buf->cck_agc_rpt & 0x60; + report = report>>5; + switch(report) + { + case 0x3: + rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x2: + rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + break; + case 0x1: + rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x0: + rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + } + } + + pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); + pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; + pstats->RecvSignalPower = rx_pwr_all; + + // + // (3) Get Signal Quality (EVM) + // + if(bpacket_match_bssid) + { + u8 sq; + + if(pstats->RxPWDBAll > 40) + { + sq = 100; + }else + { + sq = pcck_buf->sq_rpt; + + if(pcck_buf->sq_rpt > 64) + sq = 0; + else if (pcck_buf->sq_rpt < 20) + sq = 100; + else + sq = ((64-sq) * 100) / 44; + } + pstats->SignalQuality = precord_stats->SignalQuality = sq; + pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + } + } + else + { + // + // (1)Get RSSI for HT rate + // + for(i=RF90_PATH_A; ibrfpath_rxenable[i]) + rf_rx_num++; + //else + //continue; + + //Fixed by Jacken from Bryant 2008-03-20 + //Original value is 106 + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; + + //Get Rx snr value in DB + tmp_rxsnr = pofdm_buf->rxsnr_X[i]; + rx_snrX = (char)(tmp_rxsnr); + rx_snrX /= 2; + + /* Translate DBM to percentage. */ + RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); + if (priv->brfpath_rxenable[i]) + total_rssi += RSSI; + + /* Record Signal Strength for next packet */ + if(bpacket_match_bssid) + { + pstats->RxMIMOSignalStrength[i] =(u8) RSSI; + precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; + } + } + + + // + // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) + // + //Fixed by Jacken from Bryant 2008-03-20 + //Original value is 106 + rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; + pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); + + pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; + pstats->RxPower = precord_stats->RxPower = rx_pwr_all; + pstats->RecvSignalPower = rx_pwr_all; + // + // (3)EVM of HT rate + // + if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && + pdrvinfo->RxRate<=DESC90_RATEMCS15) + max_spatial_stream = 2; //both spatial stream make sense + else + max_spatial_stream = 1; //only spatial stream 1 makes sense + + for(i=0; irxevm_X[i]; + rx_evmX = (char)(tmp_rxevm); + + // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment + // fill most significant bit to "zero" when doing shifting operation which may change a negative + // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. + rx_evmX /= 2; //dbm + + evm = rtl819x_evm_dbtopercentage(rx_evmX); + if(bpacket_match_bssid) + { + if(i==0) // Fill value in RFD, Get the first spatial stream only + pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); + pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + } + } + + + /* record rx statistics for debug */ + rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; + prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + } + + //UI BSS List signal strength(in percentage), make it good looking, from 0~100. + //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). + if(is_cck_rate) + { + pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL; + + } + else + { + //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u1Byte)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u1Byte)(total_rssi/=RF90_PATH_MAX); + // We can judge RX path number now. + if (rf_rx_num != 0) + pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num))); + } +} + +static void +rtl8192_record_rxdesc_forlateruse( + struct ieee80211_rx_stats * psrc_stats, + struct ieee80211_rx_stats * ptarget_stats +) +{ + ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; + ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; +} + + + +static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv, + struct sk_buff *skb, + struct ieee80211_rx_stats * pstats, + prx_desc_819x_pci pdesc, + prx_fwinfo_819x_pci pdrvinfo) +{ + // TODO: We must only check packet for current MAC address. Not finish + bool bpacket_match_bssid, bpacket_toself; + bool bPacketBeacon=false, bToSelfBA=false; + struct ieee80211_hdr_3addr *hdr; + u16 fc,type; + + // Get Signal Quality for only RX data queue (but not command queue) + + u8* tmp_buf; + u8 *praddr; + + /* Get MAC frame start address. */ + tmp_buf = skb->data; + + hdr = (struct ieee80211_hdr_3addr *)tmp_buf; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + + /* Check if the received packet is acceptabe. */ + bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) && + (!compare_ether_addr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) + && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); + bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)); + + if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON) + { + bPacketBeacon = true; + } + if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK) + { + if (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)) + bToSelfBA = true; + } + + // + // Process PHY information for previous packet (RSSI/PWDB/EVM) + // + // Because phy information is contained in the last packet of AMPDU only, so driver + // should process phy information of previous packet + rtl8192_process_phyinfo(priv, tmp_buf, &priv->previous_stats, pstats); + rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &priv->previous_stats, bpacket_match_bssid, + bpacket_toself ,bPacketBeacon, bToSelfBA); + rtl8192_record_rxdesc_forlateruse(pstats, &priv->previous_stats); + +} + + +static void rtl8192_tx_resume(struct r8192_priv *priv) +{ + struct ieee80211_device *ieee = priv->ieee80211; + struct sk_buff *skb; + int i; + + for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) { + while ((!skb_queue_empty(&ieee->skb_waitQ[i])) && + (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) { + /* 1. dequeue the packet from the wait queue */ + skb = skb_dequeue(&ieee->skb_waitQ[i]); + /* 2. tx the packet directly */ + ieee->softmac_data_hard_start_xmit(skb, ieee, 0); + } + } +} + +static void rtl8192_irq_tx_tasklet(unsigned long arg) +{ + struct r8192_priv *priv = (struct r8192_priv*) arg; + struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE]; + unsigned long flags; + + /* check if we need to report that the management queue is drained */ + spin_lock_irqsave(&priv->irq_th_lock, flags); + + if (!skb_queue_len(&mgnt_ring->queue) && + priv->ieee80211->ack_tx_to_ieee && + rtl8192_is_tx_queue_empty(priv->ieee80211)) { + priv->ieee80211->ack_tx_to_ieee = 0; + ieee80211_ps_tx_ack(priv->ieee80211, 1); + } + + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + + rtl8192_tx_resume(priv); +} + +/* Record the received data rate */ +static void UpdateReceivedRateHistogramStatistics8190( + struct r8192_priv *priv, + struct ieee80211_rx_stats* pstats + ) +{ + u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV + u32 rateIndex; + u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI + + if(pstats->bCRC) + rcvType = 2; + else if(pstats->bICV) + rcvType = 3; + + if(pstats->bShortPreamble) + preamble_guardinterval = 1;// short + else + preamble_guardinterval = 0;// long + + switch(pstats->rate) + { + // + // CCK rate + // + case MGN_1M: rateIndex = 0; break; + case MGN_2M: rateIndex = 1; break; + case MGN_5_5M: rateIndex = 2; break; + case MGN_11M: rateIndex = 3; break; + // + // Legacy OFDM rate + // + case MGN_6M: rateIndex = 4; break; + case MGN_9M: rateIndex = 5; break; + case MGN_12M: rateIndex = 6; break; + case MGN_18M: rateIndex = 7; break; + case MGN_24M: rateIndex = 8; break; + case MGN_36M: rateIndex = 9; break; + case MGN_48M: rateIndex = 10; break; + case MGN_54M: rateIndex = 11; break; + // + // 11n High throughput rate + // + case MGN_MCS0: rateIndex = 12; break; + case MGN_MCS1: rateIndex = 13; break; + case MGN_MCS2: rateIndex = 14; break; + case MGN_MCS3: rateIndex = 15; break; + case MGN_MCS4: rateIndex = 16; break; + case MGN_MCS5: rateIndex = 17; break; + case MGN_MCS6: rateIndex = 18; break; + case MGN_MCS7: rateIndex = 19; break; + case MGN_MCS8: rateIndex = 20; break; + case MGN_MCS9: rateIndex = 21; break; + case MGN_MCS10: rateIndex = 22; break; + case MGN_MCS11: rateIndex = 23; break; + case MGN_MCS12: rateIndex = 24; break; + case MGN_MCS13: rateIndex = 25; break; + case MGN_MCS14: rateIndex = 26; break; + case MGN_MCS15: rateIndex = 27; break; + default: rateIndex = 28; break; + } + priv->stats.received_rate_histogram[0][rateIndex]++; //total + priv->stats.received_rate_histogram[rcvType][rateIndex]++; +} + +static void rtl8192_rx(struct r8192_priv *priv) +{ + struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; + bool unicast_packet = false; + struct ieee80211_rx_stats stats = { + .signal = 0, + .noise = -98, + .rate = 0, + .freq = IEEE80211_24GHZ_BAND, + }; + unsigned int count = priv->rxringcount; + prx_fwinfo_819x_pci pDrvInfo = NULL; + struct sk_buff *new_skb; + + while (count--) { + rx_desc_819x_pci *pdesc = &priv->rx_ring[priv->rx_idx];//rx descriptor + struct sk_buff *skb = priv->rx_buf[priv->rx_idx];//rx pkt + + if (pdesc->OWN) + /* wait data to be filled by hardware */ + return; + + stats.bICV = pdesc->ICV; + stats.bCRC = pdesc->CRC32; + stats.bHwError = pdesc->CRC32 | pdesc->ICV; + + stats.Length = pdesc->Length; + if(stats.Length < 24) + stats.bHwError |= 1; + + if(stats.bHwError) { + stats.bShift = false; + goto done; + } + pDrvInfo = NULL; + new_skb = dev_alloc_skb(priv->rxbuffersize); + + if (unlikely(!new_skb)) + goto done; + + stats.RxDrvInfoSize = pdesc->RxDrvInfoSize; + stats.RxBufShift = ((pdesc->Shift)&0x03); + stats.Decrypted = !pdesc->SWDec; + + pci_dma_sync_single_for_cpu(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); + skb_put(skb, pdesc->Length); + pDrvInfo = (rx_fwinfo_819x_pci *)(skb->data + stats.RxBufShift); + skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); + + stats.rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); + stats.bShortPreamble = pDrvInfo->SPLCP; + + /* it is debug only. It should be disabled in released driver. + * 2007.1.11 by Emily + * */ + UpdateReceivedRateHistogramStatistics8190(priv, &stats); + + stats.bIsAMPDU = (pDrvInfo->PartAggr==1); + stats.bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); + + stats.TimeStampLow = pDrvInfo->TSFL; + stats.TimeStampHigh = read_nic_dword(priv, TSFR+4); + + UpdateRxPktTimeStamp8190(priv, &stats); + + // + // Get Total offset of MPDU Frame Body + // + if((stats.RxBufShift + stats.RxDrvInfoSize) > 0) + stats.bShift = 1; + + /* ???? */ + TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo); + + /* Rx A-MPDU */ + if(pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) + RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", + pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); + skb_trim(skb, skb->len - 4/*sCrcLng*/); + /* rx packets statistics */ + ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; + unicast_packet = false; + + if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) { + //TODO + }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){ + //TODO + }else { + /* unicast packet */ + unicast_packet = true; + } + + if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){ + dev_kfree_skb_any(skb); + } else { + priv->stats.rxok++; + if(unicast_packet) { + priv->stats.rxbytesunicast += skb->len; + } + } + + pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + + skb = new_skb; + priv->rx_buf[priv->rx_idx] = skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + +done: + pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); + pdesc->OWN = 1; + pdesc->Length = priv->rxbuffersize; + if (priv->rx_idx == priv->rxringcount-1) + pdesc->EOR = 1; + priv->rx_idx = (priv->rx_idx + 1) % priv->rxringcount; + } + +} + +static void rtl8192_irq_rx_tasklet(unsigned long arg) +{ + struct r8192_priv *priv = (struct r8192_priv*) arg; + rtl8192_rx(priv); + /* unmask RDU */ + write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) | IMR_RDU); +} + +static const struct net_device_ops rtl8192_netdev_ops = { + .ndo_open = rtl8192_open, + .ndo_stop = rtl8192_close, + .ndo_tx_timeout = tx_timeout, + .ndo_do_ioctl = rtl8192_ioctl, + .ndo_set_multicast_list = r8192_set_multicast, + .ndo_set_mac_address = r8192_set_mac_adr, + .ndo_start_xmit = ieee80211_rtl_xmit, +}; + +static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct net_device *dev = NULL; + struct r8192_priv *priv= NULL; + u8 unit = 0; + int ret = -ENODEV; + unsigned long pmem_start, pmem_len, pmem_flags; + u8 revisionid; + + RT_TRACE(COMP_INIT,"Configuring chip resources\n"); + + if( pci_enable_device (pdev) ){ + RT_TRACE(COMP_ERR,"Failed to enable PCI device"); + return -EIO; + } + + pci_set_master(pdev); + //pci_set_wmi(pdev); + pci_set_dma_mask(pdev, 0xffffff00ULL); + pci_set_consistent_dma_mask(pdev,0xffffff00ULL); + dev = alloc_ieee80211(sizeof(struct r8192_priv)); + if (!dev) { + ret = -ENOMEM; + goto fail_free; + } + + pci_set_drvdata(pdev, dev); + SET_NETDEV_DEV(dev, &pdev->dev); + priv = ieee80211_priv(dev); + priv->ieee80211 = netdev_priv(dev); + priv->pdev=pdev; + if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ + priv->ieee80211->bSupportRemoteWakeUp = 1; + } else + { + priv->ieee80211->bSupportRemoteWakeUp = 0; + } + + pmem_start = pci_resource_start(pdev, 1); + pmem_len = pci_resource_len(pdev, 1); + pmem_flags = pci_resource_flags (pdev, 1); + + if (!(pmem_flags & IORESOURCE_MEM)) { + RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting\n"); + goto fail; + } + + //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); + if( ! request_mem_region(pmem_start, pmem_len, RTL819xE_MODULE_NAME)) { + RT_TRACE(COMP_ERR,"request_mem_region failed!\n"); + goto fail; + } + + priv->mem_start = ioremap_nocache(pmem_start, pmem_len); + if (!priv->mem_start) { + RT_TRACE(COMP_ERR,"ioremap failed!\n"); + goto fail1; + } + + dev->mem_start = (unsigned long) priv->mem_start; + dev->mem_end = (unsigned long) (priv->mem_start + + pci_resource_len(pdev, 0)); + + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, 0x41, 0x00); + + + pci_read_config_byte(pdev, 0x08, &revisionid); + /* If the revisionid is 0x10, the device uses rtl8192se. */ + if (pdev->device == 0x8192 && revisionid == 0x10) + goto fail1; + + pci_read_config_byte(pdev, 0x05, &unit); + pci_write_config_byte(pdev, 0x05, unit & (~0x04)); + + dev->irq = pdev->irq; + priv->irq = 0; + + dev->netdev_ops = &rtl8192_netdev_ops; + + dev->wireless_handlers = &r8192_wx_handlers_def; + dev->type=ARPHRD_ETHER; + + dev->watchdog_timeo = HZ*3; + + if (dev_alloc_name(dev, ifname) < 0){ + RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); + strcpy(ifname, "wlan%d"); + dev_alloc_name(dev, ifname); + } + + RT_TRACE(COMP_INIT, "Driver probe completed1\n"); + if (rtl8192_init(priv)!=0) { + RT_TRACE(COMP_ERR, "Initialization failed\n"); + goto fail; + } + + register_netdev(dev); + RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name); + rtl8192_proc_init_one(priv); + + + RT_TRACE(COMP_INIT, "Driver probe completed\n"); + return 0; + +fail1: + + if (priv->mem_start) { + iounmap(priv->mem_start); + release_mem_region( pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1) ); + } + +fail: + if(dev){ + + if (priv->irq) { + free_irq(priv->irq, priv); + priv->irq = 0; + } + free_ieee80211(dev); + } + +fail_free: + pci_disable_device(pdev); + + DMESG("wlan driver load failed\n"); + pci_set_drvdata(pdev, NULL); + return ret; + +} + +/* detach all the work and timer structure declared or inititialized + * in r8192_init function. + * */ +static void rtl8192_cancel_deferred_work(struct r8192_priv* priv) +{ + /* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code + * is or is newer than 2.6.20 and work structure is defined to be struct work_struct. + * Otherwise call cancel_delayed_work is enough. + * FIXME (2.6.20 should 2.6.22, work_struct should not cancel) + * */ + cancel_delayed_work(&priv->watch_dog_wq); + cancel_delayed_work(&priv->update_beacon_wq); + cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); + cancel_delayed_work(&priv->gpio_change_rf_wq); + cancel_work_sync(&priv->reset_wq); + cancel_work_sync(&priv->qos_activate); +} + + +static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv ; + u32 i; + + if (dev) { + + unregister_netdev(dev); + + priv = ieee80211_priv(dev); + + rtl8192_proc_remove_one(priv); + + rtl8192_down(dev); + if (priv->pFirmware) + { + vfree(priv->pFirmware); + priv->pFirmware = NULL; + } + destroy_workqueue(priv->priv_wq); + + /* free tx/rx rings */ + rtl8192_free_rx_ring(priv); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + rtl8192_free_tx_ring(priv, i); + + if (priv->irq) { + printk("Freeing irq %d\n", priv->irq); + free_irq(priv->irq, priv); + priv->irq = 0; + } + + if (priv->mem_start) { + iounmap(priv->mem_start); + release_mem_region( pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1) ); + } + + free_ieee80211(dev); + } + + pci_disable_device(pdev); + RT_TRACE(COMP_DOWN, "wlan driver removed\n"); +} + +extern int ieee80211_rtl_init(void); +extern void ieee80211_rtl_exit(void); + +static int __init rtl8192_pci_module_init(void) +{ + int retval; + + retval = ieee80211_rtl_init(); + if (retval) + return retval; + + printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); + printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); + RT_TRACE(COMP_INIT, "Initializing module\n"); + rtl8192_proc_module_init(); + if(0!=pci_register_driver(&rtl8192_pci_driver)) + { + DMESG("No device found"); + /*pci_unregister_driver (&rtl8192_pci_driver);*/ + return -ENODEV; + } + return 0; +} + + +static void __exit rtl8192_pci_module_exit(void) +{ + pci_unregister_driver(&rtl8192_pci_driver); + + RT_TRACE(COMP_DOWN, "Exiting\n"); + rtl8192_proc_module_remove(); + ieee80211_rtl_exit(); +} + +static irqreturn_t rtl8192_interrupt(int irq, void *param) +{ + struct r8192_priv *priv = param; + struct net_device *dev = priv->ieee80211->dev; + unsigned long flags; + u32 inta; + irqreturn_t ret = IRQ_HANDLED; + + spin_lock_irqsave(&priv->irq_th_lock, flags); + + /* ISR: 4bytes */ + + inta = read_nic_dword(priv, ISR); /* & priv->IntrMask; */ + write_nic_dword(priv, ISR, inta); /* reset int situation */ + + if (!inta) { + /* + * most probably we can safely return IRQ_NONE, + * but for now is better to avoid problems + */ + goto out_unlock; + } + + if (inta == 0xffff) { + /* HW disappared */ + goto out_unlock; + } + + if (!netif_running(dev)) + goto out_unlock; + + if (inta & IMR_TBDOK) { + RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + rtl8192_tx_isr(priv, BEACON_QUEUE); + priv->stats.txbeaconokint++; + } + + if (inta & IMR_TBDER) { + RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + rtl8192_tx_isr(priv, BEACON_QUEUE); + priv->stats.txbeaconerr++; + } + + if (inta & IMR_MGNTDOK ) { + RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); + priv->stats.txmanageokint++; + rtl8192_tx_isr(priv, MGNT_QUEUE); + } + + if (inta & IMR_COMDOK) + { + priv->stats.txcmdpktokint++; + rtl8192_tx_isr(priv, TXCMD_QUEUE); + } + + if (inta & IMR_ROK) { + priv->stats.rxint++; + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_BcnInt) { + RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); + tasklet_schedule(&priv->irq_prepare_beacon_tasklet); + } + + if (inta & IMR_RDU) { + RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); + priv->stats.rxrdu++; + /* reset int situation */ + write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) & ~IMR_RDU); + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_RXFOVW) { + RT_TRACE(COMP_INTR, "rx overflow !\n"); + priv->stats.rxoverflow++; + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_TXFOVW) + priv->stats.txoverflow++; + + if (inta & IMR_BKDOK) { + RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); + priv->stats.txbkokint++; + priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(priv, BK_QUEUE); + } + + if (inta & IMR_BEDOK) { + RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); + priv->stats.txbeokint++; + priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(priv, BE_QUEUE); + } + + if (inta & IMR_VIDOK) { + RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); + priv->stats.txviokint++; + priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(priv, VI_QUEUE); + } + + if (inta & IMR_VODOK) { + priv->stats.txvookint++; + priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(priv, VO_QUEUE); + } + +out_unlock: + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + + return ret; +} + +void EnableHWSecurityConfig8192(struct r8192_priv *priv) +{ + u8 SECR_value = 0x0; + struct ieee80211_device* ieee = priv->ieee80211; + + SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; + + if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) + { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) + { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + + //add HWSec active enable here. +//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 + ieee->hwsec_active = 1; + + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off + { + ieee->hwsec_active = 0; + SECR_value &= ~SCR_RxDecEnable; + } + + RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, + ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); + { + write_nic_byte(priv, SECR, SECR_value);//SECR_value | SCR_UseDK ); + } + +} +#define TOTAL_CAM_ENTRY 32 +//#define CAM_CONTENT_COUNT 8 +void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, + const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) +{ + u32 TargetCommand = 0; + u32 TargetContent = 0; + u16 usConfig = 0; + u8 i; +#ifdef ENABLE_IPS + RT_RF_POWER_STATE rtState; + + rtState = priv->eRFPowerState; + if (priv->PowerSaveControl.bInactivePs){ + if(rtState == eRfOff){ + if(priv->RfOffReason > RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); + //up(&priv->wx_sem); + return ; + } + else{ + down(&priv->ieee80211->ips_sem); + IPSLeave(priv); + up(&priv->ieee80211->ips_sem); + } + } + } + priv->ieee80211->is_set_key = true; +#endif + if (EntryNo >= TOTAL_CAM_ENTRY) + RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); + + RT_TRACE(COMP_SEC, "====>to setKey(), priv:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", priv, EntryNo, KeyIndex, KeyType, MacAddr); + + if (DefaultKey) + usConfig |= BIT15 | (KeyType<<2); + else + usConfig |= BIT15 | (KeyType<<2) | KeyIndex; +// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; + + + for(i=0 ; iafter set key, usconfig:%x\n", usConfig); +} + +bool NicIFEnableNIC(struct r8192_priv *priv) +{ + RT_STATUS init_status = RT_STATUS_SUCCESS; + PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; + + //YJ,add,091109 + if (priv->up == 0){ + RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__FUNCTION__); + priv->bdisable_nic = false; //YJ,add,091111 + return false; + } + // <1> Reset memory: descriptor, buffer,.. + //NicIFResetMemory(Adapter); + + // <2> Enable Adapter + //priv->bfirst_init = true; + init_status = rtl8192_adapter_start(priv); + if (init_status != RT_STATUS_SUCCESS) { + RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); + priv->bdisable_nic = false; //YJ,add,091111 + return -1; + } + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + //priv->bfirst_init = false; + + // <3> Enable Interrupt + rtl8192_irq_enable(priv); + priv->bdisable_nic = false; + + return (init_status == RT_STATUS_SUCCESS); +} + +bool NicIFDisableNIC(struct r8192_priv *priv) +{ + bool status = true; + u8 tmp_state = 0; + // <1> Disable Interrupt + + priv->bdisable_nic = true; //YJ,move,091109 + tmp_state = priv->ieee80211->state; + + ieee80211_softmac_stop_protocol(priv->ieee80211, false); + + priv->ieee80211->state = tmp_state; + rtl8192_cancel_deferred_work(priv); + rtl8192_irq_disable(priv); + // <2> Stop all timer + + // <3> Disable Adapter + rtl8192_halt_adapter(priv, false); +// priv->bdisable_nic = true; + + return status; +} + +module_init(rtl8192_pci_module_init); +module_exit(rtl8192_pci_module_exit); diff --git a/drivers/staging/rtl8192e/r8192E_core.c.rej b/drivers/staging/rtl8192e/r8192E_core.c.rej new file mode 100644 index 00000000000..351b44cce9a --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_core.c.rej @@ -0,0 +1,5036 @@ +--- drivers/staging/rtl8192e/r8192E_core.c ++++ drivers/staging/rtl8192e/r8192E_core.c +@@ -1,5033 +0,0 @@ +-/****************************************************************************** +- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. +- * Linux device driver for RTL8192E +- * +- * Based on the r8180 driver, which is: +- * Copyright 2004-2005 Andrea Merello , et al. +- * This program is free software; you can redistribute it and/or modify it +- * under the terms of version 2 of the GNU General Public License as +- * published by the Free Software Foundation. +- * +- * This program is distributed in the hope that it will be useful, but WITHOUT +- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +- * more details. +- * +- * You should have received a copy of the GNU General Public License along with +- * this program; if not, write to the Free Software Foundation, Inc., +- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +- * +- * The full GNU General Public License is included in this distribution in the +- * file called LICENSE. +- * +- * Contact Information: +- * Jerry chuang +- */ +- +- +-#include +-#include +-#include +-#include "r8192E_hw.h" +-#include "r8192E.h" +-#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ +-#include "r8180_93cx6.h" /* Card EEPROM */ +-#include "r8192E_wx.h" +-#include "r819xE_phy.h" //added by WB 4.30.2008 +-#include "r819xE_phyreg.h" +-#include "r819xE_cmdpkt.h" +-#include "r8192E_dm.h" +- +-#ifdef CONFIG_PM +-#include "r8192_pm.h" +-#endif +- +-#ifdef ENABLE_DOT11D +-#include "ieee80211/dot11d.h" +-#endif +- +-//set here to open your trace code. //WB +-u32 rt_global_debug_component = COMP_ERR ; //always open err flags on +- +-static DEFINE_PCI_DEVICE_TABLE(rtl8192_pci_id_tbl) = { +- /* Realtek */ +- { PCI_DEVICE(0x10ec, 0x8192) }, +- +- /* Corega */ +- { PCI_DEVICE(0x07aa, 0x0044) }, +- { PCI_DEVICE(0x07aa, 0x0047) }, +- {} +-}; +- +-static char ifname[IFNAMSIZ] = "wlan%d"; +-static int hwwep = 1; //default use hw. set 0 to use software security +-static int channels = 0x3fff; +- +-MODULE_LICENSE("GPL"); +-MODULE_VERSION("V 1.1"); +-MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); +-//MODULE_AUTHOR("Andrea Merello "); +-MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); +- +- +-module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +-module_param(hwwep,int, S_IRUGO|S_IWUSR); +-module_param(channels,int, S_IRUGO|S_IWUSR); +- +-MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); +-MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); +-MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); +- +-static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, +- const struct pci_device_id *id); +-static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); +- +-static struct pci_driver rtl8192_pci_driver = { +- .name = RTL819xE_MODULE_NAME, /* Driver name */ +- .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ +- .probe = rtl8192_pci_probe, /* probe fn */ +- .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ +-#ifdef CONFIG_PM +- .suspend = rtl8192E_suspend, /* PM suspend fn */ +- .resume = rtl8192E_resume, /* PM resume fn */ +-#else +- .suspend = NULL, /* PM suspend fn */ +- .resume = NULL, /* PM resume fn */ +-#endif +-}; +- +-static void rtl8192_start_beacon(struct ieee80211_device *ieee80211); +-static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211); +-static void rtl819x_watchdog_wqcallback(struct work_struct *work); +-static void rtl8192_irq_rx_tasklet(unsigned long arg); +-static void rtl8192_irq_tx_tasklet(unsigned long arg); +-static void rtl8192_prepare_beacon(unsigned long arg); +-static irqreturn_t rtl8192_interrupt(int irq, void *param); +-static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb); +-static void rtl8192_update_ratr_table(struct r8192_priv *priv); +-static void rtl8192_restart(struct work_struct *work); +-static void watch_dog_timer_callback(unsigned long data); +-static int _rtl8192_up(struct r8192_priv *priv); +-static void rtl8192_cancel_deferred_work(struct r8192_priv* priv); +-static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb); +- +-#ifdef ENABLE_DOT11D +- +-typedef struct _CHANNEL_LIST +-{ +- u8 Channel[32]; +- u8 Len; +-}CHANNEL_LIST, *PCHANNEL_LIST; +- +-static const CHANNEL_LIST ChannelPlan[] = { +- {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC +- {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI +- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. +- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 +- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC +- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 +-}; +- +-static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) +-{ +- int i, max_chan=-1, min_chan=-1; +- struct ieee80211_device* ieee = priv->ieee80211; +- switch (channel_plan) +- { +- case COUNTRY_CODE_FCC: +- case COUNTRY_CODE_IC: +- case COUNTRY_CODE_ETSI: +- case COUNTRY_CODE_SPAIN: +- case COUNTRY_CODE_FRANCE: +- case COUNTRY_CODE_MKK: +- case COUNTRY_CODE_MKK1: +- case COUNTRY_CODE_ISRAEL: +- case COUNTRY_CODE_TELEC: +- case COUNTRY_CODE_MIC: +- { +- Dot11d_Init(ieee); +- ieee->bGlobalDomain = false; +- //acturally 8225 & 8256 rf chip only support B,G,24N mode +- min_chan = 1; +- max_chan = 14; +- +- if (ChannelPlan[channel_plan].Len != 0){ +- // Clear old channel map +- memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); +- // Set new channel map +- for (i=0;i max_chan) +- break; +- GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; +- } +- } +- break; +- } +- case COUNTRY_CODE_GLOBAL_DOMAIN: +- { +- GET_DOT11D_INFO(ieee)->bEnabled = 0; //this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain setting +- Dot11d_Reset(ieee); +- ieee->bGlobalDomain = true; +- break; +- } +- default: +- break; +- } +-} +-#endif +- +-static inline bool rx_hal_is_cck_rate(prx_fwinfo_819x_pci pdrvinfo) +-{ +- return (pdrvinfo->RxRate == DESC90_RATE1M || +- pdrvinfo->RxRate == DESC90_RATE2M || +- pdrvinfo->RxRate == DESC90_RATE5_5M || +- pdrvinfo->RxRate == DESC90_RATE11M) && +- !pdrvinfo->RxHT; +-} +- +-void CamResetAllEntry(struct r8192_priv* priv) +-{ +- write_nic_dword(priv, RWCAM, BIT31|BIT30); +-} +- +-void write_cam(struct r8192_priv *priv, u8 addr, u32 data) +-{ +- write_nic_dword(priv, WCAMI, data); +- write_nic_dword(priv, RWCAM, BIT31|BIT16|(addr&0xff) ); +-} +- +-u32 read_cam(struct r8192_priv *priv, u8 addr) +-{ +- write_nic_dword(priv, RWCAM, 0x80000000|(addr&0xff) ); +- return read_nic_dword(priv, 0xa8); +-} +- +-u8 read_nic_byte(struct r8192_priv *priv, int x) +-{ +- return 0xff & readb(priv->mem_start + x); +-} +- +-u32 read_nic_dword(struct r8192_priv *priv, int x) +-{ +- return readl(priv->mem_start + x); +-} +- +-u16 read_nic_word(struct r8192_priv *priv, int x) +-{ +- return readw(priv->mem_start + x); +-} +- +-void write_nic_byte(struct r8192_priv *priv, int x,u8 y) +-{ +- writeb(y, priv->mem_start + x); +- udelay(20); +-} +- +-void write_nic_dword(struct r8192_priv *priv, int x,u32 y) +-{ +- writel(y, priv->mem_start + x); +- udelay(20); +-} +- +-void write_nic_word(struct r8192_priv *priv, int x,u16 y) +-{ +- writew(y, priv->mem_start + x); +- udelay(20); +-} +- +-u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee) +-{ +- static const u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; +- static const u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; +- int wpa_ie_len= ieee->wpa_ie_len; +- struct ieee80211_crypt_data* crypt; +- int encrypt; +- +- crypt = ieee->crypt[ieee->tx_keyidx]; +- +- encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) || +- (ieee->host_encrypt && crypt && crypt->ops && +- (0 == strcmp(crypt->ops->name,"WEP"))); +- +- /* simply judge */ +- if(encrypt && (wpa_ie_len == 0)) { +- // wep encryption, no N mode setting */ +- return SEC_ALG_WEP; +- } else if((wpa_ie_len != 0)) { +- // parse pairwise key type */ +- if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || +- ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) +- return SEC_ALG_CCMP; +- else +- return SEC_ALG_TKIP; +- } else { +- return SEC_ALG_NONE; +- } +-} +- +-void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- +- switch(variable) +- { +- +- case HW_VAR_BSSID: +- write_nic_dword(priv, BSSIDR, ((u32*)(val))[0]); +- write_nic_word(priv, BSSIDR+2, ((u16*)(val+2))[0]); +- break; +- +- case HW_VAR_MEDIA_STATUS: +- { +- RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); +- u8 btMsr = read_nic_byte(priv, MSR); +- +- btMsr &= 0xfc; +- +- switch(OpMode) +- { +- case RT_OP_MODE_INFRASTRUCTURE: +- btMsr |= MSR_INFRA; +- break; +- +- case RT_OP_MODE_IBSS: +- btMsr |= MSR_ADHOC; +- break; +- +- case RT_OP_MODE_AP: +- btMsr |= MSR_AP; +- break; +- +- default: +- btMsr |= MSR_NOLINK; +- break; +- } +- +- write_nic_byte(priv, MSR, btMsr); +- } +- break; +- +- case HW_VAR_CHECK_BSSID: +- { +- u32 RegRCR, Type; +- +- Type = ((u8*)(val))[0]; +- RegRCR = read_nic_dword(priv, RCR); +- priv->ReceiveConfig = RegRCR; +- +- if (Type == true) +- RegRCR |= (RCR_CBSSID); +- else if (Type == false) +- RegRCR &= (~RCR_CBSSID); +- +- write_nic_dword(priv, RCR,RegRCR); +- priv->ReceiveConfig = RegRCR; +- +- } +- break; +- +- case HW_VAR_SLOT_TIME: +- { +- priv->slot_time = val[0]; +- write_nic_byte(priv, SLOT_TIME, val[0]); +- +- } +- break; +- +- case HW_VAR_ACK_PREAMBLE: +- { +- u32 regTmp = 0; +- priv->short_preamble = (bool)(*(u8*)val ); +- regTmp = priv->basic_rate; +- if (priv->short_preamble) +- regTmp |= BRSR_AckShortPmb; +- write_nic_dword(priv, RRSR, regTmp); +- } +- break; +- +- case HW_VAR_CPU_RST: +- write_nic_dword(priv, CPU_GEN, ((u32*)(val))[0]); +- break; +- +- default: +- break; +- } +- +-} +- +-static struct proc_dir_entry *rtl8192_proc = NULL; +- +-static int proc_get_stats_ap(char *page, char **start, +- off_t offset, int count, +- int *eof, void *data) +-{ +- struct r8192_priv *priv = data; +- struct ieee80211_device *ieee = priv->ieee80211; +- struct ieee80211_network *target; +- int len = 0; +- +- list_for_each_entry(target, &ieee->network_list, list) { +- +- len += snprintf(page + len, count - len, +- "%s ", target->ssid); +- +- if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ +- len += snprintf(page + len, count - len, +- "WPA\n"); +- } +- else{ +- len += snprintf(page + len, count - len, +- "non_WPA\n"); +- } +- +- } +- +- *eof = 1; +- return len; +-} +- +-static int proc_get_registers(char *page, char **start, +- off_t offset, int count, +- int *eof, void *data) +-{ +- struct r8192_priv *priv = data; +- int len = 0; +- int i,n; +- int max=0xff; +- +- /* This dump the current register page */ +- len += snprintf(page + len, count - len, +- "\n####################page 0##################\n "); +- +- for(n=0;n<=max;) +- { +- len += snprintf(page + len, count - len, +- "\nD: %2x > ",n); +- +- for(i=0;i<16 && n<=max;i++,n++) +- len += snprintf(page + len, count - len, +- "%2x ",read_nic_byte(priv,n)); +- } +- len += snprintf(page + len, count - len,"\n"); +- len += snprintf(page + len, count - len, +- "\n####################page 1##################\n "); +- for(n=0;n<=max;) +- { +- len += snprintf(page + len, count - len, +- "\nD: %2x > ",n); +- +- for(i=0;i<16 && n<=max;i++,n++) +- len += snprintf(page + len, count - len, +- "%2x ",read_nic_byte(priv,0x100|n)); +- } +- +- len += snprintf(page + len, count - len, +- "\n####################page 3##################\n "); +- for(n=0;n<=max;) +- { +- len += snprintf(page + len, count - len, +- "\nD: %2x > ",n); +- +- for(i=0;i<16 && n<=max;i++,n++) +- len += snprintf(page + len, count - len, +- "%2x ",read_nic_byte(priv,0x300|n)); +- } +- +- *eof = 1; +- return len; +- +-} +- +-static int proc_get_stats_tx(char *page, char **start, +- off_t offset, int count, +- int *eof, void *data) +-{ +- struct r8192_priv *priv = data; +- +- int len = 0; +- +- len += snprintf(page + len, count - len, +- "TX VI priority ok int: %lu\n" +- "TX VO priority ok int: %lu\n" +- "TX BE priority ok int: %lu\n" +- "TX BK priority ok int: %lu\n" +- "TX MANAGE priority ok int: %lu\n" +- "TX BEACON priority ok int: %lu\n" +- "TX BEACON priority error int: %lu\n" +- "TX CMDPKT priority ok int: %lu\n" +- "TX queue stopped?: %d\n" +- "TX fifo overflow: %lu\n" +- "TX total data packets %lu\n" +- "TX total data bytes :%lu\n", +- priv->stats.txviokint, +- priv->stats.txvookint, +- priv->stats.txbeokint, +- priv->stats.txbkokint, +- priv->stats.txmanageokint, +- priv->stats.txbeaconokint, +- priv->stats.txbeaconerr, +- priv->stats.txcmdpktokint, +- netif_queue_stopped(priv->ieee80211->dev), +- priv->stats.txoverflow, +- priv->ieee80211->stats.tx_packets, +- priv->ieee80211->stats.tx_bytes); +- +- *eof = 1; +- return len; +-} +- +- +- +-static int proc_get_stats_rx(char *page, char **start, +- off_t offset, int count, +- int *eof, void *data) +-{ +- struct r8192_priv *priv = data; +- int len = 0; +- +- len += snprintf(page + len, count - len, +- "RX packets: %lu\n" +- "RX desc err: %lu\n" +- "RX rx overflow error: %lu\n", +- priv->stats.rxint, +- priv->stats.rxrdu, +- priv->stats.rxoverflow); +- +- *eof = 1; +- return len; +-} +- +-static void rtl8192_proc_module_init(void) +-{ +- RT_TRACE(COMP_INIT, "Initializing proc filesystem\n"); +- rtl8192_proc=create_proc_entry(RTL819xE_MODULE_NAME, S_IFDIR, init_net.proc_net); +-} +- +- +-static void rtl8192_proc_module_remove(void) +-{ +- remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net); +-} +- +- +-static void rtl8192_proc_remove_one(struct r8192_priv *priv) +-{ +- struct net_device *dev = priv->ieee80211->dev; +- +- printk("dev name=======> %s\n",dev->name); +- +- if (priv->dir_dev) { +- remove_proc_entry("stats-tx", priv->dir_dev); +- remove_proc_entry("stats-rx", priv->dir_dev); +- remove_proc_entry("stats-ap", priv->dir_dev); +- remove_proc_entry("registers", priv->dir_dev); +- remove_proc_entry("wlan0", rtl8192_proc); +- priv->dir_dev = NULL; +- } +-} +- +- +-static void rtl8192_proc_init_one(struct r8192_priv *priv) +-{ +- struct net_device *dev = priv->ieee80211->dev; +- struct proc_dir_entry *e; +- +- priv->dir_dev = create_proc_entry(dev->name, +- S_IFDIR | S_IRUGO | S_IXUGO, +- rtl8192_proc); +- if (!priv->dir_dev) { +- RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", +- dev->name); +- return; +- } +- e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, +- priv->dir_dev, proc_get_stats_rx, priv); +- +- if (!e) { +- RT_TRACE(COMP_ERR,"Unable to initialize " +- "/proc/net/rtl8192/%s/stats-rx\n", +- dev->name); +- } +- +- +- e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, +- priv->dir_dev, proc_get_stats_tx, priv); +- +- if (!e) { +- RT_TRACE(COMP_ERR, "Unable to initialize " +- "/proc/net/rtl8192/%s/stats-tx\n", +- dev->name); +- } +- +- e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, +- priv->dir_dev, proc_get_stats_ap, priv); +- +- if (!e) { +- RT_TRACE(COMP_ERR, "Unable to initialize " +- "/proc/net/rtl8192/%s/stats-ap\n", +- dev->name); +- } +- +- e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, +- priv->dir_dev, proc_get_registers, priv); +- if (!e) { +- RT_TRACE(COMP_ERR, "Unable to initialize " +- "/proc/net/rtl8192/%s/registers\n", +- dev->name); +- } +-} +- +-static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; +- +- /* for now we reserve two free descriptor as a safety boundary +- * between the tail and the head +- */ +- return (ring->entries - skb_queue_len(&ring->queue) >= 2); +-} +- +-static void tx_timeout(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- +- schedule_work(&priv->reset_wq); +- printk("TXTIMEOUT"); +-} +- +-static void rtl8192_irq_enable(struct r8192_priv *priv) +-{ +- u32 mask; +- +- mask = IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | +- IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | +- IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW | +- IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER; +- +- write_nic_dword(priv, INTA_MASK, mask); +-} +- +-static void rtl8192_irq_disable(struct r8192_priv *priv) +-{ +- write_nic_dword(priv, INTA_MASK, 0); +- synchronize_irq(priv->irq); +-} +- +-static void rtl8192_update_msr(struct r8192_priv *priv) +-{ +- u8 msr; +- +- msr = read_nic_byte(priv, MSR); +- msr &= ~ MSR_LINK_MASK; +- +- /* do not change in link_state != WLAN_LINK_ASSOCIATED. +- * msr must be updated if the state is ASSOCIATING. +- * this is intentional and make sense for ad-hoc and +- * master (see the create BSS/IBSS func) +- */ +- if (priv->ieee80211->state == IEEE80211_LINKED){ +- +- if (priv->ieee80211->iw_mode == IW_MODE_INFRA) +- msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) +- msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) +- msr |= (MSR_LINK_MASTER<dev); +- +- priv->chan = ch; +- +- /* need to implement rf set channel here WB */ +- +- if (priv->rf_set_chan) +- priv->rf_set_chan(ieee80211, priv->chan); +-} +- +-static void rtl8192_rx_enable(struct r8192_priv *priv) +-{ +- write_nic_dword(priv, RDQDA, priv->rx_ring_dma); +-} +- +-/* the TX_DESC_BASE setting is according to the following queue index +- * BK_QUEUE ===> 0 +- * BE_QUEUE ===> 1 +- * VI_QUEUE ===> 2 +- * VO_QUEUE ===> 3 +- * HCCA_QUEUE ===> 4 +- * TXCMD_QUEUE ===> 5 +- * MGNT_QUEUE ===> 6 +- * HIGH_QUEUE ===> 7 +- * BEACON_QUEUE ===> 8 +- * */ +-static const u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +-static void rtl8192_tx_enable(struct r8192_priv *priv) +-{ +- u32 i; +- +- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) +- write_nic_dword(priv, TX_DESC_BASE[i], priv->tx_ring[i].dma); +- +- ieee80211_reset_queue(priv->ieee80211); +-} +- +- +-static void rtl8192_free_rx_ring(struct r8192_priv *priv) +-{ +- int i; +- +- for (i = 0; i < priv->rxringcount; i++) { +- struct sk_buff *skb = priv->rx_buf[i]; +- if (!skb) +- continue; +- +- pci_unmap_single(priv->pdev, +- *((dma_addr_t *)skb->cb), +- priv->rxbuffersize, PCI_DMA_FROMDEVICE); +- kfree_skb(skb); +- } +- +- pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring) * priv->rxringcount, +- priv->rx_ring, priv->rx_ring_dma); +- priv->rx_ring = NULL; +-} +- +-static void rtl8192_free_tx_ring(struct r8192_priv *priv, unsigned int prio) +-{ +- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; +- +- while (skb_queue_len(&ring->queue)) { +- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; +- struct sk_buff *skb = __skb_dequeue(&ring->queue); +- +- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), +- skb->len, PCI_DMA_TODEVICE); +- kfree_skb(skb); +- ring->idx = (ring->idx + 1) % ring->entries; +- } +- +- pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, +- ring->desc, ring->dma); +- ring->desc = NULL; +-} +- +-void PHY_SetRtl8192eRfOff(struct r8192_priv *priv) +-{ +- //disable RF-Chip A/B +- rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); +- //analog to digital off, for power save +- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x0); +- //digital to analog off, for power save +- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x0); +- //rx antenna off +- rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0xf, 0x0); +- //rx antenna off +- rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0xf, 0x0); +- //analog to digital part2 off, for power save +- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x0); +- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x0); +- // Analog parameter!!Change bias and Lbus control. +- write_nic_byte(priv, ANAPAR_FOR_8192PciE, 0x07); +-} +- +-static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset) +-{ +- int i; +- u8 OpMode; +- u32 ulRegRead; +- +- OpMode = RT_OP_MODE_NO_LINK; +- priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode); +- +- if (!priv->ieee80211->bSupportRemoteWakeUp) { +- /* +- * disable tx/rx. In 8185 we write 0x10 (Reset bit), +- * but here we make reference to WMAC and wirte 0x0 +- */ +- write_nic_byte(priv, CMDR, 0); +- } +- +- mdelay(20); +- +- if (!reset) { +- mdelay(150); +- +- priv->bHwRfOffAction = 2; +- +- /* +- * Call MgntActSet_RF_State instead to +- * prevent RF config race condition. +- */ +- if (!priv->ieee80211->bSupportRemoteWakeUp) { +- PHY_SetRtl8192eRfOff(priv); +- ulRegRead = read_nic_dword(priv, CPU_GEN); +- ulRegRead |= CPU_GEN_SYSTEM_RESET; +- write_nic_dword(priv,CPU_GEN, ulRegRead); +- } else { +- /* for WOL */ +- write_nic_dword(priv, WFCRC0, 0xffffffff); +- write_nic_dword(priv, WFCRC1, 0xffffffff); +- write_nic_dword(priv, WFCRC2, 0xffffffff); +- +- /* Write PMR register */ +- write_nic_byte(priv, PMR, 0x5); +- /* Disable tx, enanble rx */ +- write_nic_byte(priv, MacBlkCtrl, 0xa); +- } +- } +- +- for(i = 0; i < MAX_QUEUE_SIZE; i++) { +- skb_queue_purge(&priv->ieee80211->skb_waitQ [i]); +- } +- for(i = 0; i < MAX_QUEUE_SIZE; i++) { +- skb_queue_purge(&priv->ieee80211->skb_aggQ [i]); +- } +- +- skb_queue_purge(&priv->skb_queue); +-} +- +-static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211) +-{ +-} +- +-static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211) +-{ +-} +- +-/* +- * this function TX data frames when the ieee80211 stack requires this. +- * It checks also if we need to stop the ieee tx queue, eventually do it +- */ +-static void rtl8192_hard_data_xmit(struct sk_buff *skb, +- struct ieee80211_device *ieee80211, int rate) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- int ret; +- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); +- u8 queue_index = tcb_desc->queue_index; +- +- /* shall not be referred by command packet */ +- BUG_ON(queue_index == TXCMD_QUEUE); +- +- if (priv->bHwRadioOff || (!priv->up)) +- { +- kfree_skb(skb); +- return; +- } +- +- skb_push(skb, priv->ieee80211->tx_headroom); +- ret = rtl8192_tx(priv, skb); +- if (ret != 0) { +- kfree_skb(skb); +- } +- +- if (queue_index != MGNT_QUEUE) { +- priv->ieee80211->stats.tx_bytes += (skb->len - priv->ieee80211->tx_headroom); +- priv->ieee80211->stats.tx_packets++; +- } +-} +- +-/* +- * This is a rough attempt to TX a frame +- * This is called by the ieee 80211 stack to TX management frames. +- * If the ring is full packet are dropped (for data frame the queue +- * is stopped before this can happen). +- */ +-static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- int ret; +- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); +- u8 queue_index = tcb_desc->queue_index; +- +- if (queue_index != TXCMD_QUEUE) { +- if (priv->bHwRadioOff || (!priv->up)) +- { +- kfree_skb(skb); +- return 0; +- } +- } +- +- if (queue_index == TXCMD_QUEUE) { +- rtl819xE_tx_cmd(priv, skb); +- ret = 0; +- return ret; +- } else { +- tcb_desc->RATRIndex = 7; +- tcb_desc->bTxDisableRateFallBack = 1; +- tcb_desc->bTxUseDriverAssingedRate = 1; +- tcb_desc->bTxEnableFwCalcDur = 1; +- skb_push(skb, ieee80211->tx_headroom); +- ret = rtl8192_tx(priv, skb); +- if (ret != 0) { +- kfree_skb(skb); +- } +- } +- +- return ret; +-} +- +- +-static void rtl8192_tx_isr(struct r8192_priv *priv, int prio) +-{ +- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; +- +- while (skb_queue_len(&ring->queue)) { +- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; +- struct sk_buff *skb; +- +- /* +- * beacon packet will only use the first descriptor defaultly, +- * and the OWN may not be cleared by the hardware +- */ +- if (prio != BEACON_QUEUE) { +- if (entry->OWN) +- return; +- ring->idx = (ring->idx + 1) % ring->entries; +- } +- +- skb = __skb_dequeue(&ring->queue); +- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), +- skb->len, PCI_DMA_TODEVICE); +- +- kfree_skb(skb); +- } +- +- if (prio != BEACON_QUEUE) { +- /* try to deal with the pending packets */ +- tasklet_schedule(&priv->irq_tx_tasklet); +- } +-} +- +-static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211) +-{ +-} +- +-static void rtl8192_config_rate(struct r8192_priv *priv, u16* rate_config) +-{ +- struct ieee80211_network *net; +- u8 i=0, basic_rate = 0; +- net = & priv->ieee80211->current_network; +- +- for (i=0; irates_len; i++) +- { +- basic_rate = net->rates[i]&0x7f; +- switch(basic_rate) +- { +- case MGN_1M: *rate_config |= RRSR_1M; break; +- case MGN_2M: *rate_config |= RRSR_2M; break; +- case MGN_5_5M: *rate_config |= RRSR_5_5M; break; +- case MGN_11M: *rate_config |= RRSR_11M; break; +- case MGN_6M: *rate_config |= RRSR_6M; break; +- case MGN_9M: *rate_config |= RRSR_9M; break; +- case MGN_12M: *rate_config |= RRSR_12M; break; +- case MGN_18M: *rate_config |= RRSR_18M; break; +- case MGN_24M: *rate_config |= RRSR_24M; break; +- case MGN_36M: *rate_config |= RRSR_36M; break; +- case MGN_48M: *rate_config |= RRSR_48M; break; +- case MGN_54M: *rate_config |= RRSR_54M; break; +- } +- } +- for (i=0; irates_ex_len; i++) +- { +- basic_rate = net->rates_ex[i]&0x7f; +- switch(basic_rate) +- { +- case MGN_1M: *rate_config |= RRSR_1M; break; +- case MGN_2M: *rate_config |= RRSR_2M; break; +- case MGN_5_5M: *rate_config |= RRSR_5_5M; break; +- case MGN_11M: *rate_config |= RRSR_11M; break; +- case MGN_6M: *rate_config |= RRSR_6M; break; +- case MGN_9M: *rate_config |= RRSR_9M; break; +- case MGN_12M: *rate_config |= RRSR_12M; break; +- case MGN_18M: *rate_config |= RRSR_18M; break; +- case MGN_24M: *rate_config |= RRSR_24M; break; +- case MGN_36M: *rate_config |= RRSR_36M; break; +- case MGN_48M: *rate_config |= RRSR_48M; break; +- case MGN_54M: *rate_config |= RRSR_54M; break; +- } +- } +-} +- +- +-#define SHORT_SLOT_TIME 9 +-#define NON_SHORT_SLOT_TIME 20 +- +-static void rtl8192_update_cap(struct r8192_priv *priv, u16 cap) +-{ +- u32 tmp = 0; +- struct ieee80211_network *net = &priv->ieee80211->current_network; +- +- priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; +- tmp = priv->basic_rate; +- if (priv->short_preamble) +- tmp |= BRSR_AckShortPmb; +- write_nic_dword(priv, RRSR, tmp); +- +- if (net->mode & (IEEE_G|IEEE_N_24G)) +- { +- u8 slot_time = 0; +- if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) +- {//short slot time +- slot_time = SHORT_SLOT_TIME; +- } +- else //long slot time +- slot_time = NON_SHORT_SLOT_TIME; +- priv->slot_time = slot_time; +- write_nic_byte(priv, SLOT_TIME, slot_time); +- } +- +-} +- +-static void rtl8192_net_update(struct r8192_priv *priv) +-{ +- struct ieee80211_network *net; +- u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; +- u16 rate_config = 0; +- net = &priv->ieee80211->current_network; +- +- /* update Basic rate: RR, BRSR */ +- rtl8192_config_rate(priv, &rate_config); +- +- /* +- * Select RRSR (in Legacy-OFDM and CCK) +- * For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, +- * 2M, and 1M from the Basic rate. +- * We do not use other rates. +- */ +- priv->basic_rate = rate_config &= 0x15f; +- +- /* BSSID */ +- write_nic_dword(priv, BSSIDR, ((u32 *)net->bssid)[0]); +- write_nic_word(priv, BSSIDR+4, ((u16 *)net->bssid)[2]); +- +- if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) +- { +- write_nic_word(priv, ATIMWND, 2); +- write_nic_word(priv, BCN_DMATIME, 256); +- write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); +- /* +- * BIT15 of BCN_DRV_EARLY_INT will indicate +- * whether software beacon or hw beacon is applied. +- */ +- write_nic_word(priv, BCN_DRV_EARLY_INT, 10); +- write_nic_byte(priv, BCN_ERR_THRESH, 100); +- +- BcnTimeCfg |= (BcnCW<tx_ring[TXCMD_QUEUE]; +- mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); +- +- spin_lock_irqsave(&priv->irq_th_lock,flags); +- idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; +- entry = &ring->desc[idx]; +- +- tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); +- memset(entry,0,12); +- entry->LINIP = tcb_desc->bLastIniPkt; +- entry->FirstSeg = 1;//first segment +- entry->LastSeg = 1; //last segment +- if(tcb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { +- entry->CmdInit = DESC_PACKET_TYPE_INIT; +- } else { +- entry->CmdInit = DESC_PACKET_TYPE_NORMAL; +- entry->Offset = sizeof(TX_FWINFO_8190PCI) + 8; +- entry->PktSize = (u16)(tcb_desc->pkt_size + entry->Offset); +- entry->QueueSelect = QSLT_CMD; +- entry->TxFWInfoSize = 0x08; +- entry->RATid = (u8)DESC_PACKET_TYPE_INIT; +- } +- entry->TxBufferSize = skb->len; +- entry->TxBuffAddr = cpu_to_le32(mapping); +- entry->OWN = 1; +- +- __skb_queue_tail(&ring->queue, skb); +- spin_unlock_irqrestore(&priv->irq_th_lock,flags); +- +- write_nic_byte(priv, TPPoll, TPPoll_CQ); +- +- return; +-} +- +-/* +- * Mapping Software/Hardware descriptor queue id to "Queue Select Field" +- * in TxFwInfo data structure +- */ +-static u8 MapHwQueueToFirmwareQueue(u8 QueueID) +-{ +- u8 QueueSelect = 0; +- +- switch (QueueID) { +- case BE_QUEUE: +- QueueSelect = QSLT_BE; +- break; +- +- case BK_QUEUE: +- QueueSelect = QSLT_BK; +- break; +- +- case VO_QUEUE: +- QueueSelect = QSLT_VO; +- break; +- +- case VI_QUEUE: +- QueueSelect = QSLT_VI; +- break; +- +- case MGNT_QUEUE: +- QueueSelect = QSLT_MGNT; +- break; +- +- case BEACON_QUEUE: +- QueueSelect = QSLT_BEACON; +- break; +- +- case TXCMD_QUEUE: +- QueueSelect = QSLT_CMD; +- break; +- +- case HIGH_QUEUE: +- default: +- RT_TRACE(COMP_ERR, "Impossible Queue Selection: %d\n", QueueID); +- break; +- } +- return QueueSelect; +-} +- +-static u8 MRateToHwRate8190Pci(u8 rate) +-{ +- u8 ret = DESC90_RATE1M; +- +- switch(rate) { +- case MGN_1M: ret = DESC90_RATE1M; break; +- case MGN_2M: ret = DESC90_RATE2M; break; +- case MGN_5_5M: ret = DESC90_RATE5_5M; break; +- case MGN_11M: ret = DESC90_RATE11M; break; +- case MGN_6M: ret = DESC90_RATE6M; break; +- case MGN_9M: ret = DESC90_RATE9M; break; +- case MGN_12M: ret = DESC90_RATE12M; break; +- case MGN_18M: ret = DESC90_RATE18M; break; +- case MGN_24M: ret = DESC90_RATE24M; break; +- case MGN_36M: ret = DESC90_RATE36M; break; +- case MGN_48M: ret = DESC90_RATE48M; break; +- case MGN_54M: ret = DESC90_RATE54M; break; +- +- // HT rate since here +- case MGN_MCS0: ret = DESC90_RATEMCS0; break; +- case MGN_MCS1: ret = DESC90_RATEMCS1; break; +- case MGN_MCS2: ret = DESC90_RATEMCS2; break; +- case MGN_MCS3: ret = DESC90_RATEMCS3; break; +- case MGN_MCS4: ret = DESC90_RATEMCS4; break; +- case MGN_MCS5: ret = DESC90_RATEMCS5; break; +- case MGN_MCS6: ret = DESC90_RATEMCS6; break; +- case MGN_MCS7: ret = DESC90_RATEMCS7; break; +- case MGN_MCS8: ret = DESC90_RATEMCS8; break; +- case MGN_MCS9: ret = DESC90_RATEMCS9; break; +- case MGN_MCS10: ret = DESC90_RATEMCS10; break; +- case MGN_MCS11: ret = DESC90_RATEMCS11; break; +- case MGN_MCS12: ret = DESC90_RATEMCS12; break; +- case MGN_MCS13: ret = DESC90_RATEMCS13; break; +- case MGN_MCS14: ret = DESC90_RATEMCS14; break; +- case MGN_MCS15: ret = DESC90_RATEMCS15; break; +- case (0x80|0x20): ret = DESC90_RATEMCS32; break; +- +- default: break; +- } +- return ret; +-} +- +- +-static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) +-{ +- u8 tmp_Short; +- +- tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); +- +- if(TxHT==1 && TxRate != DESC90_RATEMCS15) +- tmp_Short = 0; +- +- return tmp_Short; +-} +- +-/* +- * The tx procedure is just as following, +- * skb->cb will contain all the following information, +- * priority, morefrag, rate, &dev. +- */ +-static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb) +-{ +- struct rtl8192_tx_ring *ring; +- unsigned long flags; +- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); +- tx_desc_819x_pci *pdesc = NULL; +- TX_FWINFO_8190PCI *pTxFwInfo = NULL; +- dma_addr_t mapping; +- bool multi_addr = false, broad_addr = false, uni_addr = false; +- u8 *pda_addr = NULL; +- int idx; +- +- if (priv->bdisable_nic) { +- RT_TRACE(COMP_ERR, "Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", +- skb->len, tcb_desc->queue_index); +- return skb->len; +- } +- +-#ifdef ENABLE_LPS +- priv->ieee80211->bAwakePktSent = true; +-#endif +- +- mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); +- +- /* collect the tx packets statitcs */ +- pda_addr = ((u8 *)skb->data) + sizeof(TX_FWINFO_8190PCI); +- if (is_multicast_ether_addr(pda_addr)) +- multi_addr = true; +- else if (is_broadcast_ether_addr(pda_addr)) +- broad_addr = true; +- else +- uni_addr = true; +- +- if (uni_addr) +- priv->stats.txbytesunicast += (u8)(skb->len) - sizeof(TX_FWINFO_8190PCI); +- +- /* fill tx firmware */ +- pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; +- memset(pTxFwInfo, 0, sizeof(TX_FWINFO_8190PCI)); +- pTxFwInfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; +- pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)tcb_desc->data_rate); +- pTxFwInfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; +- pTxFwInfo->Short = QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, tcb_desc); +- +- /* Aggregation related */ +- if (tcb_desc->bAMPDUEnable) { +- pTxFwInfo->AllowAggregation = 1; +- pTxFwInfo->RxMF = tcb_desc->ampdu_factor; +- pTxFwInfo->RxAMD = tcb_desc->ampdu_density; +- } else { +- pTxFwInfo->AllowAggregation = 0; +- pTxFwInfo->RxMF = 0; +- pTxFwInfo->RxAMD = 0; +- } +- +- /* Protection mode related */ +- pTxFwInfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; +- pTxFwInfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; +- pTxFwInfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; +- pTxFwInfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; +- pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); +- pTxFwInfo->RtsBandwidth = 0; +- pTxFwInfo->RtsSubcarrier = tcb_desc->RTSSC; +- pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : (tcb_desc->bRTSUseShortGI? 1 : 0); +- +- /* Set Bandwidth and sub-channel settings. */ +- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { +- if (tcb_desc->bPacketBW) { +- pTxFwInfo->TxBandwidth = 1; +- /* use duplicated mode */ +- pTxFwInfo->TxSubCarrier = 0; +- } else { +- pTxFwInfo->TxBandwidth = 0; +- pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; +- } +- } else { +- pTxFwInfo->TxBandwidth = 0; +- pTxFwInfo->TxSubCarrier = 0; +- } +- +- spin_lock_irqsave(&priv->irq_th_lock, flags); +- ring = &priv->tx_ring[tcb_desc->queue_index]; +- if (tcb_desc->queue_index != BEACON_QUEUE) +- idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; +- else +- idx = 0; +- +- pdesc = &ring->desc[idx]; +- if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { +- RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d,idx = %d,%x\n", +- tcb_desc->queue_index, ring->idx, idx, skb->len); +- spin_unlock_irqrestore(&priv->irq_th_lock, flags); +- return skb->len; +- } +- +- /* fill tx descriptor */ +- memset(pdesc, 0, 12); +- +- /*DWORD 0*/ +- pdesc->LINIP = 0; +- pdesc->CmdInit = 1; +- pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; /* We must add 8!! */ +- pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); +- +- /*DWORD 1*/ +- pdesc->SecCAMID = 0; +- pdesc->RATid = tcb_desc->RATRIndex; +- +- pdesc->NoEnc = 1; +- pdesc->SecType = 0x0; +- if (tcb_desc->bHwSec) { +- switch (priv->ieee80211->pairwise_key_type) { +- case KEY_TYPE_WEP40: +- case KEY_TYPE_WEP104: +- pdesc->SecType = 0x1; +- pdesc->NoEnc = 0; +- break; +- case KEY_TYPE_TKIP: +- pdesc->SecType = 0x2; +- pdesc->NoEnc = 0; +- break; +- case KEY_TYPE_CCMP: +- pdesc->SecType = 0x3; +- pdesc->NoEnc = 0; +- break; +- case KEY_TYPE_NA: +- pdesc->SecType = 0x0; +- pdesc->NoEnc = 1; +- break; +- } +- } +- +- /* Set Packet ID */ +- pdesc->PktId = 0x0; +- +- pdesc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); +- pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); +- +- pdesc->DISFB = tcb_desc->bTxDisableRateFallBack; +- pdesc->USERATE = tcb_desc->bTxUseDriverAssingedRate; +- +- pdesc->FirstSeg = 1; +- pdesc->LastSeg = 1; +- pdesc->TxBufferSize = skb->len; +- +- pdesc->TxBuffAddr = cpu_to_le32(mapping); +- __skb_queue_tail(&ring->queue, skb); +- pdesc->OWN = 1; +- spin_unlock_irqrestore(&priv->irq_th_lock, flags); +- priv->ieee80211->dev->trans_start = jiffies; +- write_nic_word(priv, TPPoll, 0x01<queue_index); +- return 0; +-} +- +-static short rtl8192_alloc_rx_desc_ring(struct r8192_priv *priv) +-{ +- rx_desc_819x_pci *entry = NULL; +- int i; +- +- priv->rx_ring = pci_alloc_consistent(priv->pdev, +- sizeof(*priv->rx_ring) * priv->rxringcount, &priv->rx_ring_dma); +- +- if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { +- RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); +- return -ENOMEM; +- } +- +- memset(priv->rx_ring, 0, sizeof(*priv->rx_ring) * priv->rxringcount); +- priv->rx_idx = 0; +- +- for (i = 0; i < priv->rxringcount; i++) { +- struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); +- dma_addr_t *mapping; +- entry = &priv->rx_ring[i]; +- if (!skb) +- return 0; +- priv->rx_buf[i] = skb; +- mapping = (dma_addr_t *)skb->cb; +- *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), +- priv->rxbuffersize, PCI_DMA_FROMDEVICE); +- +- entry->BufferAddress = cpu_to_le32(*mapping); +- +- entry->Length = priv->rxbuffersize; +- entry->OWN = 1; +- } +- +- entry->EOR = 1; +- return 0; +-} +- +-static int rtl8192_alloc_tx_desc_ring(struct r8192_priv *priv, +- unsigned int prio, unsigned int entries) +-{ +- tx_desc_819x_pci *ring; +- dma_addr_t dma; +- int i; +- +- ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); +- if (!ring || (unsigned long)ring & 0xFF) { +- RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); +- return -ENOMEM; +- } +- +- memset(ring, 0, sizeof(*ring)*entries); +- priv->tx_ring[prio].desc = ring; +- priv->tx_ring[prio].dma = dma; +- priv->tx_ring[prio].idx = 0; +- priv->tx_ring[prio].entries = entries; +- skb_queue_head_init(&priv->tx_ring[prio].queue); +- +- for (i = 0; i < entries; i++) +- ring[i].NextDescAddress = +- cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); +- +- return 0; +-} +- +-static short rtl8192_pci_initdescring(struct r8192_priv *priv) +-{ +- u32 ret; +- int i; +- +- ret = rtl8192_alloc_rx_desc_ring(priv); +- if (ret) +- return ret; +- +- /* general process for other queue */ +- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { +- ret = rtl8192_alloc_tx_desc_ring(priv, i, priv->txringcount); +- if (ret) +- goto err_free_rings; +- } +- +- return 0; +- +-err_free_rings: +- rtl8192_free_rx_ring(priv); +- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) +- if (priv->tx_ring[i].desc) +- rtl8192_free_tx_ring(priv, i); +- return 1; +-} +- +-static void rtl8192_pci_resetdescring(struct r8192_priv *priv) +-{ +- int i; +- +- /* force the rx_idx to the first one */ +- if(priv->rx_ring) { +- rx_desc_819x_pci *entry = NULL; +- for (i = 0; i < priv->rxringcount; i++) { +- entry = &priv->rx_ring[i]; +- entry->OWN = 1; +- } +- priv->rx_idx = 0; +- } +- +- /* after reset, release previous pending packet, and force the +- * tx idx to the first one */ +- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { +- if (priv->tx_ring[i].desc) { +- struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; +- +- while (skb_queue_len(&ring->queue)) { +- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; +- struct sk_buff *skb = __skb_dequeue(&ring->queue); +- +- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), +- skb->len, PCI_DMA_TODEVICE); +- kfree_skb(skb); +- ring->idx = (ring->idx + 1) % ring->entries; +- } +- ring->idx = 0; +- } +- } +-} +- +-static void rtl8192_link_change(struct ieee80211_device *ieee) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- +- if (ieee->state == IEEE80211_LINKED) +- { +- rtl8192_net_update(priv); +- rtl8192_update_ratr_table(priv); +- +- //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 +- if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) +- EnableHWSecurityConfig8192(priv); +- } +- else +- { +- write_nic_byte(priv, 0x173, 0); +- } +- +- rtl8192_update_msr(priv); +- +- // 2007/10/16 MH MAC Will update TSF according to all received beacon, so we have +- // // To set CBSSID bit when link with any AP or STA. +- if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) +- { +- u32 reg = 0; +- reg = read_nic_dword(priv, RCR); +- if (priv->ieee80211->state == IEEE80211_LINKED) +- priv->ReceiveConfig = reg |= RCR_CBSSID; +- else +- priv->ReceiveConfig = reg &= ~RCR_CBSSID; +- write_nic_dword(priv, RCR, reg); +- } +-} +- +- +-static const struct ieee80211_qos_parameters def_qos_parameters = { +- {3,3,3,3},/* cw_min */ +- {7,7,7,7},/* cw_max */ +- {2,2,2,2},/* aifs */ +- {0,0,0,0},/* flags */ +- {0,0,0,0} /* tx_op_limit */ +-}; +- +-static void rtl8192_update_beacon(struct work_struct * work) +-{ +- struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); +- struct ieee80211_device* ieee = priv->ieee80211; +- struct ieee80211_network* net = &ieee->current_network; +- +- if (ieee->pHTInfo->bCurrentHTSupport) +- HTUpdateSelfAndPeerSetting(ieee, net); +- ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; +- rtl8192_update_cap(priv, net->capability); +-} +- +-/* +-* background support to run QoS activate functionality +-*/ +-static const int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +-static void rtl8192_qos_activate(struct work_struct * work) +-{ +- struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); +- struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; +- u8 mode = priv->ieee80211->current_network.mode; +- u8 u1bAIFS; +- u32 u4bAcParam; +- int i; +- +- mutex_lock(&priv->mutex); +- if(priv->ieee80211->state != IEEE80211_LINKED) +- goto success; +- RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); +- /* It better set slot time at first */ +- /* For we just support b/g mode at present, let the slot time at 9/20 selection */ +- /* update the ac parameter to related registers */ +- for(i = 0; i < QOS_QUEUE_NUM; i++) { +- //Mode G/A: slotTimeTimer = 9; Mode B: 20 +- u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; +- u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| +- (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| +- (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| +- ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); +- write_nic_dword(priv, WDCAPARA_ADD[i], u4bAcParam); +- } +- +-success: +- mutex_unlock(&priv->mutex); +-} +- +-static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, +- int active_network, +- struct ieee80211_network *network) +-{ +- int ret = 0; +- u32 size = sizeof(struct ieee80211_qos_parameters); +- +- if(priv->ieee80211->state !=IEEE80211_LINKED) +- return ret; +- +- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) +- return ret; +- +- if (network->flags & NETWORK_HAS_QOS_MASK) { +- if (active_network && +- (network->flags & NETWORK_HAS_QOS_PARAMETERS)) +- network->qos_data.active = network->qos_data.supported; +- +- if ((network->qos_data.active == 1) && (active_network == 1) && +- (network->flags & NETWORK_HAS_QOS_PARAMETERS) && +- (network->qos_data.old_param_count != +- network->qos_data.param_count)) { +- network->qos_data.old_param_count = +- network->qos_data.param_count; +- queue_work(priv->priv_wq, &priv->qos_activate); +- RT_TRACE (COMP_QOS, "QoS parameters change call " +- "qos_activate\n"); +- } +- } else { +- memcpy(&priv->ieee80211->current_network.qos_data.parameters, +- &def_qos_parameters, size); +- +- if ((network->qos_data.active == 1) && (active_network == 1)) { +- queue_work(priv->priv_wq, &priv->qos_activate); +- RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); +- } +- network->qos_data.active = 0; +- network->qos_data.supported = 0; +- } +- +- return 0; +-} +- +-/* handle manage frame frame beacon and probe response */ +-static int rtl8192_handle_beacon(struct ieee80211_device *ieee, +- struct ieee80211_beacon * beacon, +- struct ieee80211_network * network) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- +- rtl8192_qos_handle_probe_response(priv,1,network); +- +- queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); +- return 0; +- +-} +- +-/* +- * handling the beaconing responses. if we get different QoS setting +- * off the network from the associated setting, adjust the QoS setting +- */ +-static int rtl8192_qos_association_resp(struct r8192_priv *priv, +- struct ieee80211_network *network) +-{ +- int ret = 0; +- unsigned long flags; +- u32 size = sizeof(struct ieee80211_qos_parameters); +- int set_qos_param = 0; +- +- if ((priv == NULL) || (network == NULL)) +- return ret; +- +- if (priv->ieee80211->state != IEEE80211_LINKED) +- return ret; +- +- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) +- return ret; +- +- spin_lock_irqsave(&priv->ieee80211->lock, flags); +- if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { +- memcpy(&priv->ieee80211->current_network.qos_data.parameters, +- &network->qos_data.parameters, +- sizeof(struct ieee80211_qos_parameters)); +- priv->ieee80211->current_network.qos_data.active = 1; +- set_qos_param = 1; +- /* update qos parameter for current network */ +- priv->ieee80211->current_network.qos_data.old_param_count = +- priv->ieee80211->current_network.qos_data.param_count; +- priv->ieee80211->current_network.qos_data.param_count = +- network->qos_data.param_count; +- +- } else { +- memcpy(&priv->ieee80211->current_network.qos_data.parameters, +- &def_qos_parameters, size); +- priv->ieee80211->current_network.qos_data.active = 0; +- priv->ieee80211->current_network.qos_data.supported = 0; +- set_qos_param = 1; +- } +- +- spin_unlock_irqrestore(&priv->ieee80211->lock, flags); +- +- RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __FUNCTION__, +- network->flags, priv->ieee80211->current_network.qos_data.active); +- if (set_qos_param == 1) +- queue_work(priv->priv_wq, &priv->qos_activate); +- +- return ret; +-} +- +- +-static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee, +- struct ieee80211_assoc_response_frame *resp, +- struct ieee80211_network *network) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- rtl8192_qos_association_resp(priv, network); +- return 0; +-} +- +- +-/* updateRATRTabel for MCS only. Basic rate is not implemented. */ +-static void rtl8192_update_ratr_table(struct r8192_priv* priv) +-{ +- struct ieee80211_device* ieee = priv->ieee80211; +- u8* pMcsRate = ieee->dot11HTOperationalRateSet; +- u32 ratr_value = 0; +- u8 rate_index = 0; +- +- rtl8192_config_rate(priv, (u16*)(&ratr_value)); +- ratr_value |= (*(u16*)(pMcsRate)) << 12; +- +- switch (ieee->mode) +- { +- case IEEE_A: +- ratr_value &= 0x00000FF0; +- break; +- case IEEE_B: +- ratr_value &= 0x0000000F; +- break; +- case IEEE_G: +- ratr_value &= 0x00000FF7; +- break; +- case IEEE_N_24G: +- case IEEE_N_5G: +- if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC +- ratr_value &= 0x0007F007; +- else{ +- if (priv->rf_type == RF_1T2R) +- ratr_value &= 0x000FF007; +- else +- ratr_value &= 0x0F81F007; +- } +- break; +- default: +- break; +- } +- ratr_value &= 0x0FFFFFFF; +- if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ +- ratr_value |= 0x80000000; +- }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ +- ratr_value |= 0x80000000; +- } +- write_nic_dword(priv, RATR0+rate_index*4, ratr_value); +- write_nic_byte(priv, UFWP, 1); +-} +- +-static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee) +-{ +- return !(ieee->rtllib_ap_sec_type && +- (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))); +-} +- +-static void rtl8192_refresh_supportrate(struct r8192_priv* priv) +-{ +- struct ieee80211_device* ieee = priv->ieee80211; +- //we donot consider set support rate for ABG mode, only HT MCS rate is set here. +- if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) +- { +- memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); +- } +- else +- memset(ieee->Regdot11HTOperationalRateSet, 0, 16); +-} +- +-static u8 rtl8192_getSupportedWireleeMode(void) +-{ +- return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B); +-} +- +-static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- u8 bSupportMode = rtl8192_getSupportedWireleeMode(); +- +- if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0)) +- { +- if(bSupportMode & WIRELESS_MODE_N_24G) +- { +- wireless_mode = WIRELESS_MODE_N_24G; +- } +- else if(bSupportMode & WIRELESS_MODE_N_5G) +- { +- wireless_mode = WIRELESS_MODE_N_5G; +- } +- else if((bSupportMode & WIRELESS_MODE_A)) +- { +- wireless_mode = WIRELESS_MODE_A; +- } +- else if((bSupportMode & WIRELESS_MODE_G)) +- { +- wireless_mode = WIRELESS_MODE_G; +- } +- else if((bSupportMode & WIRELESS_MODE_B)) +- { +- wireless_mode = WIRELESS_MODE_B; +- } +- else{ +- RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode); +- wireless_mode = WIRELESS_MODE_B; +- } +- } +- priv->ieee80211->mode = wireless_mode; +- +- if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) +- priv->ieee80211->pHTInfo->bEnableHT = 1; +- else +- priv->ieee80211->pHTInfo->bEnableHT = 0; +- RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); +- rtl8192_refresh_supportrate(priv); +-} +- +-static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee) +-{ +- return ieee->bHalfWirelessN24GMode; +-} +- +-static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee) +-{ +- int i=0; +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- +- for (i=0; i<=MGNT_QUEUE; i++) +- { +- if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) +- continue; +- if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ +- printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); +- return 0; +- } +- } +- return 1; +-} +- +-static void rtl8192_hw_sleep_down(struct r8192_priv *priv) +-{ +- MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS); +-} +- +-static void rtl8192_hw_wakeup(struct ieee80211_device *ieee) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS); +-} +- +-static void rtl8192_hw_wakeup_wq (struct work_struct *work) +-{ +- struct delayed_work *dwork = container_of(work,struct delayed_work,work); +- struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); +- +- rtl8192_hw_wakeup(ieee); +-} +- +-#define MIN_SLEEP_TIME 50 +-#define MAX_SLEEP_TIME 10000 +-static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee->dev); +- u32 tmp; +- u32 rb = jiffies; +- +- // Writing HW register with 0 equals to disable +- // the timer, that is not really what we want +- // +- tl -= MSECS(8+16+7); +- +- // If the interval in witch we are requested to sleep is too +- // short then give up and remain awake +- // when we sleep after send null frame, the timer will be too short to sleep. +- // +- if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) +- ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { +- printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); +- return; +- } +- +- if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| +- ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| +- ((tlMSECS(MAX_SLEEP_TIME)))) { +- printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); +- return; +- } +- +- tmp = (tl>rb)?(tl-rb):(rb-tl); +- queue_delayed_work(priv->ieee80211->wq, +- &priv->ieee80211->hw_wakeup_wq,tmp); +- +- rtl8192_hw_sleep_down(priv); +-} +- +-static void rtl8192_init_priv_variable(struct r8192_priv *priv) +-{ +- u8 i; +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- +- // Default Halt the NIC if RF is OFF. +- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; +- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_CLK_REQ; +- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; +- pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; +- pPSC->bLeisurePs = true; +- priv->ieee80211->RegMaxLPSAwakeIntvl = 5; +- priv->bHwRadioOff = false; +- +- priv->being_init_adapter = false; +- priv->txringcount = 64;//32; +- priv->rxbuffersize = 9100;//2048;//1024; +- priv->rxringcount = MAX_RX_COUNT;//64; +- priv->chan = 1; //set to channel 1 +- priv->RegWirelessMode = WIRELESS_MODE_AUTO; +- priv->RegChannelPlan = 0xf; +- priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO +- priv->ieee80211->iw_mode = IW_MODE_INFRA; +- priv->ieee80211->ieee_up=0; +- priv->retry_rts = DEFAULT_RETRY_RTS; +- priv->retry_data = DEFAULT_RETRY_DATA; +- priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; +- priv->ieee80211->rate = 110; //11 mbps +- priv->ieee80211->short_slot = 1; +- priv->promisc = (priv->ieee80211->dev->flags & IFF_PROMISC) ? 1:0; +- priv->bcck_in_ch14 = false; +- priv->CCKPresentAttentuation = 0; +- priv->rfa_txpowertrackingindex = 0; +- priv->rfc_txpowertrackingindex = 0; +- priv->CckPwEnl = 6; +- //added by amy for silent reset +- priv->ResetProgress = RESET_TYPE_NORESET; +- priv->bForcedSilentReset = 0; +- priv->bDisableNormalResetCheck = false; +- priv->force_reset = false; +- //added by amy for power save +- priv->RfOffReason = 0; +- priv->bHwRfOffAction = 0; +- priv->PowerSaveControl.bInactivePs = true; +- priv->PowerSaveControl.bIPSModeBackup = false; +- +- priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; +- priv->ieee80211->iw_mode = IW_MODE_INFRA; +- priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | +- IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | +- IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;/* | +- IEEE_SOFTMAC_BEACONS;*///added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE; +- +- priv->ieee80211->active_scan = 1; +- priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; +- priv->ieee80211->host_encrypt = 1; +- priv->ieee80211->host_decrypt = 1; +- priv->ieee80211->start_send_beacons = rtl8192_start_beacon; +- priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon; +- priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; +- priv->ieee80211->set_chan = rtl8192_set_chan; +- priv->ieee80211->link_change = rtl8192_link_change; +- priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; +- priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop; +- priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume; +- priv->ieee80211->init_wmmparam_flag = 0; +- priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; +- priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc; +- priv->ieee80211->tx_headroom = sizeof(TX_FWINFO_8190PCI); +- priv->ieee80211->qos_support = 1; +- priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; +- priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; +- priv->ieee80211->handle_beacon = rtl8192_handle_beacon; +- +- priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup; +- priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep; +- priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty; +- priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8190Pci; +- priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; +- priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xPci; +- +- priv->ieee80211->InitialGainHandler = InitialGain819xPci; +- +-#ifdef ENABLE_IPS +- priv->ieee80211->ieee80211_ips_leave_wq = ieee80211_ips_leave_wq; +- priv->ieee80211->ieee80211_ips_leave = ieee80211_ips_leave; +-#endif +-#ifdef ENABLE_LPS +- priv->ieee80211->LeisurePSLeave = LeisurePSLeave; +-#endif +- +- priv->ieee80211->SetHwRegHandler = rtl8192e_SetHwReg; +- priv->ieee80211->rtllib_ap_sec_type = rtl8192e_ap_sec_type; +- +- priv->ShortRetryLimit = 0x30; +- priv->LongRetryLimit = 0x30; +- +- priv->ReceiveConfig = RCR_ADD3 | +- RCR_AMF | RCR_ADF | //accept management/data +- RCR_AICV | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. +- RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC +- RCR_AAP | ((u32)7<pFirmware = vzalloc(sizeof(rt_firmware)); +- +- /* rx related queue */ +- skb_queue_head_init(&priv->skb_queue); +- +- /* Tx related queue */ +- for(i = 0; i < MAX_QUEUE_SIZE; i++) { +- skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]); +- } +- for(i = 0; i < MAX_QUEUE_SIZE; i++) { +- skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]); +- } +- priv->rf_set_chan = rtl8192_phy_SwChnl; +-} +- +-static void rtl8192_init_priv_lock(struct r8192_priv* priv) +-{ +- spin_lock_init(&priv->irq_th_lock); +- spin_lock_init(&priv->rf_ps_lock); +- sema_init(&priv->wx_sem,1); +- sema_init(&priv->rf_sem,1); +- mutex_init(&priv->mutex); +-} +- +-/* init tasklet and wait_queue here */ +-#define DRV_NAME "wlan0" +-static void rtl8192_init_priv_task(struct r8192_priv *priv) +-{ +- priv->priv_wq = create_workqueue(DRV_NAME); +- +-#ifdef ENABLE_IPS +- INIT_WORK(&priv->ieee80211->ips_leave_wq, IPSLeave_wq); +-#endif +- +- INIT_WORK(&priv->reset_wq, rtl8192_restart); +- INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); +- INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); +- INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); +- INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); +- INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); +- INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8192_hw_wakeup_wq); +- +- tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, +- (unsigned long) priv); +- tasklet_init(&priv->irq_tx_tasklet, rtl8192_irq_tx_tasklet, +- (unsigned long) priv); +- tasklet_init(&priv->irq_prepare_beacon_tasklet, rtl8192_prepare_beacon, +- (unsigned long) priv); +-} +- +-static void rtl8192_get_eeprom_size(struct r8192_priv *priv) +-{ +- u16 curCR = 0; +- RT_TRACE(COMP_INIT, "===========>%s()\n", __FUNCTION__); +- curCR = read_nic_dword(priv, EPROM_CMD); +- RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); +- //whether need I consider BIT5? +- priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EPROM_93c56 : EPROM_93c46; +- RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype); +-} +- +-/* +- * Adapter->EEPROMAddressSize should be set before this function call. +- * EEPROM address size can be got through GetEEPROMSize8185() +- */ +-static void rtl8192_read_eeprom_info(struct r8192_priv *priv) +-{ +- struct net_device *dev = priv->ieee80211->dev; +- u8 tempval; +- u8 ICVer8192, ICVer8256; +- u16 i,usValue, IC_Version; +- u16 EEPROMId; +- u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; +- RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); +- +- +- // TODO: I don't know if we need to apply EF function to EEPROM read function +- +- //2 Read EEPROM ID to make sure autoload is success +- EEPROMId = eprom_read(priv, 0); +- if( EEPROMId != RTL8190_EEPROM_ID ) +- { +- RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); +- priv->AutoloadFailFlag=true; +- } +- else +- { +- priv->AutoloadFailFlag=false; +- } +- +- // +- // Assign Chip Version ID +- // +- // Read IC Version && Channel Plan +- if(!priv->AutoloadFailFlag) +- { +- // VID, PID +- priv->eeprom_vid = eprom_read(priv, (EEPROM_VID >> 1)); +- priv->eeprom_did = eprom_read(priv, (EEPROM_DID >> 1)); +- +- usValue = eprom_read(priv, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; +- priv->eeprom_CustomerID = (u8)( usValue & 0xff); +- usValue = eprom_read(priv, (EEPROM_ICVersion_ChannelPlan>>1)); +- priv->eeprom_ChannelPlan = usValue&0xff; +- IC_Version = ((usValue&0xff00)>>8); +- +- ICVer8192 = (IC_Version&0xf); //bit0~3; 1:A cut, 2:B cut, 3:C cut... +- ICVer8256 = ((IC_Version&0xf0)>>4);//bit4~6, bit7 reserved for other RF chip; 1:A cut, 2:B cut, 3:C cut... +- RT_TRACE(COMP_INIT, "ICVer8192 = 0x%x\n", ICVer8192); +- RT_TRACE(COMP_INIT, "ICVer8256 = 0x%x\n", ICVer8256); +- if(ICVer8192 == 0x2) //B-cut +- { +- if(ICVer8256 == 0x5) //E-cut +- priv->card_8192_version= VERSION_8190_BE; +- } +- +- switch(priv->card_8192_version) +- { +- case VERSION_8190_BD: +- case VERSION_8190_BE: +- break; +- default: +- priv->card_8192_version = VERSION_8190_BD; +- break; +- } +- RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); +- } +- else +- { +- priv->card_8192_version = VERSION_8190_BD; +- priv->eeprom_vid = 0; +- priv->eeprom_did = 0; +- priv->eeprom_CustomerID = 0; +- priv->eeprom_ChannelPlan = 0; +- RT_TRACE(COMP_INIT, "IC Version = 0x%x\n", 0xff); +- } +- +- RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); +- RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); +- RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); +- +- //2 Read Permanent MAC address +- if(!priv->AutoloadFailFlag) +- { +- for(i = 0; i < 6; i += 2) +- { +- usValue = eprom_read(priv, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); +- *(u16*)(&dev->dev_addr[i]) = usValue; +- } +- } else { +- // when auto load failed, the last address byte set to be a random one. +- // added by david woo.2007/11/7 +- memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); +- } +- +- RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", dev->dev_addr); +- +- //2 TX Power Check EEPROM Fail or not +- if(priv->card_8192_version > VERSION_8190_BD) { +- priv->bTXPowerDataReadFromEEPORM = true; +- } else { +- priv->bTXPowerDataReadFromEEPORM = false; +- } +- +- // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R +- priv->rf_type = RTL819X_DEFAULT_RF_TYPE; +- +- if(priv->card_8192_version > VERSION_8190_BD) +- { +- // Read RF-indication and Tx Power gain index diff of legacy to HT OFDM rate. +- if(!priv->AutoloadFailFlag) +- { +- tempval = (eprom_read(priv, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; +- priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; // bit[3:0] +- +- if (tempval&0x80) //RF-indication, bit[7] +- priv->rf_type = RF_1T2R; +- else +- priv->rf_type = RF_2T4R; +- } +- else +- { +- priv->EEPROMLegacyHTTxPowerDiff = EEPROM_Default_LegacyHTTxPowerDiff; +- } +- RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", +- priv->EEPROMLegacyHTTxPowerDiff); +- +- // Read ThermalMeter from EEPROM +- if(!priv->AutoloadFailFlag) +- { +- priv->EEPROMThermalMeter = (u8)(((eprom_read(priv, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); +- } +- else +- { +- priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; +- } +- RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); +- //vivi, for tx power track +- priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; +- +- if(priv->epromtype == EPROM_93c46) +- { +- // Read antenna tx power offset of B/C/D to A and CrystalCap from EEPROM +- if(!priv->AutoloadFailFlag) +- { +- usValue = eprom_read(priv, (EEPROM_TxPwDiff_CrystalCap>>1)); +- priv->EEPROMAntPwDiff = (usValue&0x0fff); +- priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); +- } +- else +- { +- priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; +- priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; +- } +- RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); +- RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); +- +- // +- // Get per-channel Tx Power Level +- // +- for(i=0; i<14; i+=2) +- { +- if(!priv->AutoloadFailFlag) +- { +- usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); +- } +- else +- { +- usValue = EEPROM_Default_TxPower; +- } +- *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; +- RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); +- RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); +- } +- for(i=0; i<14; i+=2) +- { +- if(!priv->AutoloadFailFlag) +- { +- usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); +- } +- else +- { +- usValue = EEPROM_Default_TxPower; +- } +- *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; +- RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); +- RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); +- } +- } +- +- // +- // Update HAL variables. +- // +- if(priv->epromtype == EPROM_93c46) +- { +- for(i=0; i<14; i++) +- { +- priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; +- priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; +- } +- priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; +- // Antenna B gain offset to antenna A, bit0~3 +- priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); +- // Antenna C gain offset to antenna A, bit4~7 +- priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); +- // Antenna D gain offset to antenna A, bit8~11 +- priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); +- // CrystalCap, bit12~15 +- priv->CrystalCap = priv->EEPROMCrystalCap; +- // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 +- priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); +- priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); +- } +- else if(priv->epromtype == EPROM_93c56) +- { +- for(i=0; i<3; i++) // channel 1~3 use the same Tx Power Level. +- { +- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; +- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; +- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; +- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; +- } +- for(i=3; i<9; i++) // channel 4~9 use the same Tx Power Level +- { +- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; +- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; +- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; +- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; +- } +- for(i=9; i<14; i++) // channel 10~14 use the same Tx Power Level +- { +- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; +- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; +- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; +- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; +- } +- for(i=0; i<14; i++) +- RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); +- for(i=0; i<14; i++) +- RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); +- for(i=0; i<14; i++) +- RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); +- for(i=0; i<14; i++) +- RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); +- priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; +- priv->AntennaTxPwDiff[0] = 0; +- priv->AntennaTxPwDiff[1] = 0; +- priv->AntennaTxPwDiff[2] = 0; +- priv->CrystalCap = priv->EEPROMCrystalCap; +- // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 +- priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); +- priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); +- } +- } +- +- if(priv->rf_type == RF_1T2R) +- { +- RT_TRACE(COMP_INIT, "1T2R config\n"); +- } +- else if (priv->rf_type == RF_2T4R) +- { +- RT_TRACE(COMP_INIT, "2T4R config\n"); +- } +- +- // 2008/01/16 MH We can only know RF type in the function. So we have to init +- // DIG RATR table again. +- init_rate_adaptive(priv); +- +- //1 Make a copy for following variables and we can change them if we want +- +- if(priv->RegChannelPlan == 0xf) +- { +- priv->ChannelPlan = priv->eeprom_ChannelPlan; +- } +- else +- { +- priv->ChannelPlan = priv->RegChannelPlan; +- } +- +- // +- // Used PID and DID to Set CustomerID +- // +- if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) +- { +- priv->CustomerID = RT_CID_DLINK; +- } +- +- switch(priv->eeprom_CustomerID) +- { +- case EEPROM_CID_DEFAULT: +- priv->CustomerID = RT_CID_DEFAULT; +- break; +- case EEPROM_CID_CAMEO: +- priv->CustomerID = RT_CID_819x_CAMEO; +- break; +- case EEPROM_CID_RUNTOP: +- priv->CustomerID = RT_CID_819x_RUNTOP; +- break; +- case EEPROM_CID_NetCore: +- priv->CustomerID = RT_CID_819x_Netcore; +- break; +- case EEPROM_CID_TOSHIBA: // Merge by Jacken, 2008/01/31 +- priv->CustomerID = RT_CID_TOSHIBA; +- if(priv->eeprom_ChannelPlan&0x80) +- priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; +- else +- priv->ChannelPlan = 0x0; +- RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", +- priv->ChannelPlan); +- break; +- case EEPROM_CID_Nettronix: +- priv->CustomerID = RT_CID_Nettronix; +- break; +- case EEPROM_CID_Pronet: +- priv->CustomerID = RT_CID_PRONET; +- break; +- case EEPROM_CID_DLINK: +- priv->CustomerID = RT_CID_DLINK; +- break; +- +- case EEPROM_CID_WHQL: +- break; +- default: +- // value from RegCustomerID +- break; +- } +- +- //Avoid the channel plan array overflow, by Bruce, 2007-08-27. +- if(priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) +- priv->ChannelPlan = 0; //FCC +- +- if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) +- priv->ieee80211->bSupportRemoteWakeUp = true; +- else +- priv->ieee80211->bSupportRemoteWakeUp = false; +- +- +- RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); +- RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); +- RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); +-} +- +- +-static short rtl8192_get_channel_map(struct r8192_priv *priv) +-{ +-#ifdef ENABLE_DOT11D +- if(priv->ChannelPlan> COUNTRY_CODE_GLOBAL_DOMAIN){ +- printk("rtl8180_init:Error channel plan! Set to default.\n"); +- priv->ChannelPlan= 0; +- } +- RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); +- +- rtl819x_set_channel_map(priv->ChannelPlan, priv); +-#else +- int ch,i; +- //Set Default Channel Plan +- if(!channels){ +- DMESG("No channels, aborting"); +- return -1; +- } +- ch=channels; +- priv->ChannelPlan= 0;//hikaru +- // set channels 1..14 allowed in given locale +- for (i=1; i<=14; i++) { +- (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); +- ch >>= 1; +- } +-#endif +- return 0; +-} +- +-static short rtl8192_init(struct r8192_priv *priv) +-{ +- struct net_device *dev = priv->ieee80211->dev; +- +- memset(&(priv->stats),0,sizeof(struct Stats)); +- rtl8192_init_priv_variable(priv); +- rtl8192_init_priv_lock(priv); +- rtl8192_init_priv_task(priv); +- rtl8192_get_eeprom_size(priv); +- rtl8192_read_eeprom_info(priv); +- rtl8192_get_channel_map(priv); +- init_hal_dm(priv); +- init_timer(&priv->watch_dog_timer); +- priv->watch_dog_timer.data = (unsigned long)priv; +- priv->watch_dog_timer.function = watch_dog_timer_callback; +- if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) { +- printk("Error allocating IRQ %d",dev->irq); +- return -1; +- }else{ +- priv->irq=dev->irq; +- printk("IRQ %d",dev->irq); +- } +- if (rtl8192_pci_initdescring(priv) != 0){ +- printk("Endopoints initialization failed"); +- return -1; +- } +- +- return 0; +-} +- +-/* +- * Actually only set RRSR, RATR and BW_OPMODE registers +- * not to do all the hw config as its name says +- * This part need to modified according to the rate set we filtered +- */ +-static void rtl8192_hwconfig(struct r8192_priv *priv) +-{ +- u32 regRATR = 0, regRRSR = 0; +- u8 regBwOpMode = 0, regTmp = 0; +- +-// Set RRSR, RATR, and BW_OPMODE registers +- // +- switch (priv->ieee80211->mode) +- { +- case WIRELESS_MODE_B: +- regBwOpMode = BW_OPMODE_20MHZ; +- regRATR = RATE_ALL_CCK; +- regRRSR = RATE_ALL_CCK; +- break; +- case WIRELESS_MODE_A: +- regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; +- regRATR = RATE_ALL_OFDM_AG; +- regRRSR = RATE_ALL_OFDM_AG; +- break; +- case WIRELESS_MODE_G: +- regBwOpMode = BW_OPMODE_20MHZ; +- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; +- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; +- break; +- case WIRELESS_MODE_AUTO: +- case WIRELESS_MODE_N_24G: +- // It support CCK rate by default. +- // CCK rate will be filtered out only when associated AP does not support it. +- regBwOpMode = BW_OPMODE_20MHZ; +- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; +- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; +- break; +- case WIRELESS_MODE_N_5G: +- regBwOpMode = BW_OPMODE_5G; +- regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; +- regRRSR = RATE_ALL_OFDM_AG; +- break; +- } +- +- write_nic_byte(priv, BW_OPMODE, regBwOpMode); +- { +- u32 ratr_value = 0; +- ratr_value = regRATR; +- if (priv->rf_type == RF_1T2R) +- { +- ratr_value &= ~(RATE_ALL_OFDM_2SS); +- } +- write_nic_dword(priv, RATR0, ratr_value); +- write_nic_byte(priv, UFWP, 1); +- } +- regTmp = read_nic_byte(priv, 0x313); +- regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); +- write_nic_dword(priv, RRSR, regRRSR); +- +- // +- // Set Retry Limit here +- // +- write_nic_word(priv, RETRY_LIMIT, +- priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | +- priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); +- // Set Contention Window here +- +- // Set Tx AGC +- +- // Set Tx Antenna including Feedback control +- +- // Set Auto Rate fallback control +- +- +-} +- +- +-static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv) +-{ +- struct net_device *dev = priv->ieee80211->dev; +- u32 ulRegRead; +- RT_STATUS rtStatus = RT_STATUS_SUCCESS; +- u8 tmpvalue; +- u8 ICVersion,SwitchingRegulatorOutput; +- bool bfirmwareok = true; +- u32 tmpRegA, tmpRegC, TempCCk; +- int i =0; +- +- RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__); +- priv->being_init_adapter = true; +- rtl8192_pci_resetdescring(priv); +- // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W. +- priv->Rf_Mode = RF_OP_By_SW_3wire; +- +- //dPLL on +- if(priv->ResetProgress == RESET_TYPE_NORESET) +- { +- write_nic_byte(priv, ANAPAR, 0x37); +- // Accordign to designer's explain, LBUS active will never > 10ms. We delay 10ms +- // Joseph increae the time to prevent firmware download fail +- mdelay(500); +- } +- +- //PlatformSleepUs(10000); +- // For any kind of InitializeAdapter process, we shall use system now!! +- priv->pFirmware->firmware_status = FW_STATUS_0_INIT; +- +- // +- //3 //Config CPUReset Register +- //3// +- //3 Firmware Reset Or Not +- ulRegRead = read_nic_dword(priv, CPU_GEN); +- if(priv->pFirmware->firmware_status == FW_STATUS_0_INIT) +- { //called from MPInitialized. do nothing +- ulRegRead |= CPU_GEN_SYSTEM_RESET; +- }else if(priv->pFirmware->firmware_status == FW_STATUS_5_READY) +- ulRegRead |= CPU_GEN_FIRMWARE_RESET; // Called from MPReset +- else +- RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status); +- +- write_nic_dword(priv, CPU_GEN, ulRegRead); +- +- //3// +- //3 //Fix the issue of E-cut high temperature issue +- //3// +- // TODO: E cut only +- ICVersion = read_nic_byte(priv, IC_VERRSION); +- if(ICVersion >= 0x4) //E-cut only +- { +- // HW SD suggest that we should not wirte this register too often, so driver +- // should readback this register. This register will be modified only when +- // power on reset +- SwitchingRegulatorOutput = read_nic_byte(priv, SWREGULATOR); +- if(SwitchingRegulatorOutput != 0xb8) +- { +- write_nic_byte(priv, SWREGULATOR, 0xa8); +- mdelay(1); +- write_nic_byte(priv, SWREGULATOR, 0xb8); +- } +- } +- +- //3// +- //3// Initialize BB before MAC +- //3// +- RT_TRACE(COMP_INIT, "BB Config Start!\n"); +- rtStatus = rtl8192_BBConfig(priv); +- if(rtStatus != RT_STATUS_SUCCESS) +- { +- RT_TRACE(COMP_ERR, "BB Config failed\n"); +- return rtStatus; +- } +- RT_TRACE(COMP_INIT,"BB Config Finished!\n"); +- +- //3//Set Loopback mode or Normal mode +- //3// +- //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings +- // because setting of System_Reset bit reset MAC to default transmission mode. +- //Loopback mode or not +- priv->LoopbackMode = RTL819X_NO_LOOPBACK; +- if(priv->ResetProgress == RESET_TYPE_NORESET) +- { +- ulRegRead = read_nic_dword(priv, CPU_GEN); +- if(priv->LoopbackMode == RTL819X_NO_LOOPBACK) +- { +- ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); +- } +- else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) +- { +- ulRegRead |= CPU_CCK_LOOPBACK; +- } +- else +- { +- RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); +- } +- +- //2008.06.03, for WOL +- //ulRegRead &= (~(CPU_GEN_GPIO_UART)); +- write_nic_dword(priv, CPU_GEN, ulRegRead); +- +- // 2006.11.29. After reset cpu, we sholud wait for a second, otherwise, it may fail to write registers. Emily +- udelay(500); +- } +- //3Set Hardware(Do nothing now) +- rtl8192_hwconfig(priv); +- //2======================================================= +- // Common Setting for all of the FPGA platform. (part 1) +- //2======================================================= +- // If there is changes, please make sure it applies to all of the FPGA version +- //3 Turn on Tx/Rx +- write_nic_byte(priv, CMDR, CR_RE|CR_TE); +- +- //2Set Tx dma burst +- write_nic_byte(priv, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); +- write_nic_word(priv, MAC4, ((u16*)(dev->dev_addr + 4))[0]); +- //set RCR +- write_nic_dword(priv, RCR, priv->ReceiveConfig); +- +- //3 Initialize Number of Reserved Pages in Firmware Queue +- write_nic_dword(priv, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | +- NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | +- NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | +- NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) +- rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode); +- //----------------------------------------------------------------------------- +- // Set up security related. 070106, by rcnjko: +- // 1. Clear all H/W keys. +- // 2. Enable H/W encryption/decryption. +- //----------------------------------------------------------------------------- +- CamResetAllEntry(priv); +- { +- u8 SECR_value = 0x0; +- SECR_value |= SCR_TxEncEnable; +- SECR_value |= SCR_RxDecEnable; +- SECR_value |= SCR_NoSKMC; +- write_nic_byte(priv, SECR, SECR_value); +- } +- //3Beacon related +- write_nic_word(priv, ATIMWND, 2); +- write_nic_word(priv, BCN_INTERVAL, 100); +- for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { +- rtl8192_phy_getTxPower(priv); +- rtl8192_phy_setTxPower(priv, priv->chan); +- } +- +- //if D or C cut +- tmpvalue = read_nic_byte(priv, IC_VERRSION); +- priv->IC_Cut = tmpvalue; +- RT_TRACE(COMP_INIT, "priv->IC_Cut = 0x%x\n", priv->IC_Cut); +- if(priv->IC_Cut >= IC_VersionCut_D) +- { +- //pHalData->bDcut = TRUE; +- if(priv->IC_Cut == IC_VersionCut_D) +- RT_TRACE(COMP_INIT, "D-cut\n"); +- if(priv->IC_Cut == IC_VersionCut_E) +- { +- RT_TRACE(COMP_INIT, "E-cut\n"); +- // HW SD suggest that we should not wirte this register too often, so driver +- // should readback this register. This register will be modified only when +- // power on reset +- } +- } +- else +- { +- //pHalData->bDcut = FALSE; +- RT_TRACE(COMP_INIT, "Before C-cut\n"); +- } +- +- //Firmware download +- RT_TRACE(COMP_INIT, "Load Firmware!\n"); +- bfirmwareok = init_firmware(priv); +- if(bfirmwareok != true) { +- rtStatus = RT_STATUS_FAILURE; +- return rtStatus; +- } +- RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); +- +- //RF config +- if(priv->ResetProgress == RESET_TYPE_NORESET) +- { +- RT_TRACE(COMP_INIT, "RF Config Started!\n"); +- rtStatus = rtl8192_phy_RFConfig(priv); +- if(rtStatus != RT_STATUS_SUCCESS) +- { +- RT_TRACE(COMP_ERR, "RF Config failed\n"); +- return rtStatus; +- } +- RT_TRACE(COMP_INIT, "RF Config Finished!\n"); +- } +- rtl8192_phy_updateInitGain(priv); +- +- /*---- Set CCK and OFDM Block "ON"----*/ +- rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn, 0x1); +- rtl8192_setBBreg(priv, rFPGA0_RFMOD, bOFDMEn, 0x1); +- +- //Enable Led +- write_nic_byte(priv, 0x87, 0x0); +- +- //2======================================================= +- // RF Power Save +- //2======================================================= +-#ifdef ENABLE_IPS +- +-{ +- if(priv->RfOffReason > RF_CHANGE_BY_PS) +- { // H/W or S/W RF OFF before sleep. +- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__,priv->RfOffReason); +- MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); +- } +- else if(priv->RfOffReason >= RF_CHANGE_BY_IPS) +- { // H/W or S/W RF OFF before sleep. +- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__, priv->RfOffReason); +- MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); +- } +- else +- { +- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__FUNCTION__); +- priv->eRFPowerState = eRfOn; +- priv->RfOffReason = 0; +- } +-} +-#endif +- // We can force firmware to do RF-R/W +- if(priv->ieee80211->FwRWRF) +- priv->Rf_Mode = RF_OP_By_FW; +- else +- priv->Rf_Mode = RF_OP_By_SW_3wire; +- +- if(priv->ResetProgress == RESET_TYPE_NORESET) +- { +- dm_initialize_txpower_tracking(priv); +- +- if(priv->IC_Cut >= IC_VersionCut_D) +- { +- tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); +- tmpRegC = rtl8192_QueryBBReg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord); +- for(i = 0; itxbbgain_table[i].txbbgain_value) +- { +- priv->rfa_txpowertrackingindex= (u8)i; +- priv->rfa_txpowertrackingindex_real= (u8)i; +- priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; +- break; +- } +- } +- +- TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); +- +- for(i=0 ; icck_txbbgain_table[i].ccktxbb_valuearray[0]) +- { +- priv->CCKPresentAttentuation_20Mdefault =(u8) i; +- break; +- } +- } +- priv->CCKPresentAttentuation_40Mdefault = 0; +- priv->CCKPresentAttentuation_difference = 0; +- priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; +- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); +- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); +- RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); +- RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); +- priv->btxpower_tracking = FALSE;//TEMPLY DISABLE +- } +- } +- +- rtl8192_irq_enable(priv); +- priv->being_init_adapter = false; +- return rtStatus; +- +-} +- +-static void rtl8192_prepare_beacon(unsigned long arg) +-{ +- struct r8192_priv *priv = (struct r8192_priv*) arg; +- struct sk_buff *skb; +- cb_desc *tcb_desc; +- +- skb = ieee80211_get_beacon(priv->ieee80211); +- tcb_desc = (cb_desc *)(skb->cb + 8); +- /* prepare misc info for the beacon xmit */ +- tcb_desc->queue_index = BEACON_QUEUE; +- /* IBSS does not support HT yet, use 1M defaultly */ +- tcb_desc->data_rate = 2; +- tcb_desc->RATRIndex = 7; +- tcb_desc->bTxDisableRateFallBack = 1; +- tcb_desc->bTxUseDriverAssingedRate = 1; +- +- skb_push(skb, priv->ieee80211->tx_headroom); +- if(skb){ +- rtl8192_tx(priv, skb); +- } +-} +- +- +-/* +- * configure registers for beacon tx and enables it via +- * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might +- * be used to stop beacon transmission +- */ +-static void rtl8192_start_beacon(struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- struct ieee80211_network *net = &priv->ieee80211->current_network; +- u16 BcnTimeCfg = 0; +- u16 BcnCW = 6; +- u16 BcnIFS = 0xf; +- +- DMESG("Enabling beacon TX"); +- rtl8192_irq_disable(priv); +- //rtl8192_beacon_tx_enable(dev); +- +- /* ATIM window */ +- write_nic_word(priv, ATIMWND, 2); +- +- /* Beacon interval (in unit of TU) */ +- write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); +- +- /* +- * DrvErlyInt (in unit of TU). +- * (Time to send interrupt to notify driver to c +- * hange beacon content) +- * */ +- write_nic_word(priv, BCN_DRV_EARLY_INT, 10); +- +- /* +- * BcnDMATIM(in unit of us). +- * Indicates the time before TBTT to perform beacon queue DMA +- * */ +- write_nic_word(priv, BCN_DMATIME, 256); +- +- /* +- * Force beacon frame transmission even after receiving +- * beacon frame from other ad hoc STA +- * */ +- write_nic_byte(priv, BCN_ERR_THRESH, 100); +- +- /* Set CW and IFS */ +- BcnTimeCfg |= BcnCW<RxCounter); +- // If rssi is small, we should check rx for long time because of bad rx. +- // or maybe it will continuous silent reset every 2 seconds. +- priv->rx_chk_cnt++; +- if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) +- { +- priv->rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ +- } +- else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && +- ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) || +- (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) ) +- +- { +- if(priv->rx_chk_cnt < 2) +- { +- return bStuck; +- } +- else +- { +- priv->rx_chk_cnt = 0; +- } +- } +- else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbCurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbundecorated_smoothed_pwdb >= VeryLowRSSI) +- { +- if(priv->rx_chk_cnt < 4) +- { +- return bStuck; +- } +- else +- { +- priv->rx_chk_cnt = 0; +- } +- } +- else +- { +- if(priv->rx_chk_cnt < 8) +- { +- return bStuck; +- } +- else +- { +- priv->rx_chk_cnt = 0; +- } +- } +- if(priv->RxCounter==RegRxCounter) +- bStuck = TRUE; +- +- priv->RxCounter = RegRxCounter; +- +- return bStuck; +-} +- +-static RESET_TYPE RxCheckStuck(struct r8192_priv *priv) +-{ +- +- if(HalRxCheckStuck8190Pci(priv)) +- { +- RT_TRACE(COMP_RESET, "RxStuck Condition\n"); +- return RESET_TYPE_SILENT; +- } +- +- return RESET_TYPE_NORESET; +-} +- +-static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv) +-{ +- RESET_TYPE RxResetType = RESET_TYPE_NORESET; +- RT_RF_POWER_STATE rfState; +- +- rfState = priv->eRFPowerState; +- +- if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { +- /* +- * If driver is in the status of firmware download failure, +- * driver skips RF initialization and RF is in turned off state. +- * Driver should check whether Rx stuck and do silent reset. And +- * if driver is in firmware download failure status, driver +- * should initialize RF in the following silent reset procedure +- * +- * Driver should not check RX stuck in IBSS mode because it is +- * required to set Check BSSID in order to send beacon, however, +- * if check BSSID is set, STA cannot hear any packet a all. +- */ +- RxResetType = RxCheckStuck(priv); +- } +- +- RT_TRACE(COMP_RESET, "%s(): RxResetType is %d\n", __FUNCTION__, RxResetType); +- +- return RxResetType; +-} +- +-#ifdef ENABLE_IPS +-static void InactivePsWorkItemCallback(struct r8192_priv *priv) +-{ +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- +- RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() --------->\n"); +- // +- // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem +- // is really scheduled. +- // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the +- // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing +- // blocks the IPS procedure of switching RF. +- // By Bruce, 2007-12-25. +- // +- pPSC->bSwRfProcessing = TRUE; +- +- RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", +- pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); +- +- +- MgntActSet_RF_State(priv, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); +- +- // +- // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20. +- // +- pPSC->bSwRfProcessing = FALSE; +- RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <---------\n"); +-} +- +-#ifdef ENABLE_LPS +-/* Change current and default preamble mode. */ +-bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode) +-{ +- +- // Currently, we do not change power save mode on IBSS mode. +- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) +- { +- return false; +- } +- +- // +- // If we make HW to fill up the PwrMgt bit for us, +- // some AP will not response to our mgnt frames with PwrMgt bit set, +- // e.g. cannot associate the AP. +- // So I commented out it. 2005.02.16, by rcnjko. +- // +-// // Change device's power save mode. +-// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); +- +- // Update power save mode configured. +- //RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__FUNCTION__,rtPsMode); +- if(!priv->ps_force) { +- priv->ieee80211->ps = rtPsMode; +- } +- +- // Awake immediately +- if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED) +- { +- // Notify the AP we awke. +- rtl8192_hw_wakeup(priv->ieee80211); +- priv->ieee80211->sta_sleep = 0; +- +- spin_lock(&priv->ieee80211->mgmt_tx_lock); +- printk("LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); +- ieee80211_sta_ps_send_null_frame(priv->ieee80211, 0); +- spin_unlock(&priv->ieee80211->mgmt_tx_lock); +- } +- +- return true; +-} +- +-/* Enter the leisure power save mode. */ +-void LeisurePSEnter(struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- +- if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) && +- (priv->ieee80211->state == IEEE80211_LINKED)) || +- (priv->ieee80211->iw_mode == IW_MODE_ADHOC) || +- (priv->ieee80211->iw_mode == IW_MODE_MASTER)) +- return; +- +- if (pPSC->bLeisurePs) +- { +- // Idle for a while if we connect to AP a while ago. +- if(pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) // 4 Sec +- { +- +- if(priv->ieee80211->ps == IEEE80211_PS_DISABLED) +- { +- MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); +- +- } +- } +- else +- pPSC->LpsIdleCount++; +- } +-} +- +- +-/* Leave leisure power save mode. */ +-void LeisurePSLeave(struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- +- if (pPSC->bLeisurePs) +- { +- if(priv->ieee80211->ps != IEEE80211_PS_DISABLED) +- { +- // move to lps_wakecomplete() +- MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); +- +- } +- } +-} +-#endif +- +- +-/* Enter the inactive power save mode. RF will be off */ +-void IPSEnter(struct r8192_priv *priv) +-{ +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- RT_RF_POWER_STATE rtState; +- +- if (pPSC->bInactivePs) +- { +- rtState = priv->eRFPowerState; +- // +- // Added by Bruce, 2007-12-25. +- // Do not enter IPS in the following conditions: +- // (1) RF is already OFF or Sleep +- // (2) bSwRfProcessing (indicates the IPS is still under going) +- // (3) Connectted (only disconnected can trigger IPS) +- // (4) IBSS (send Beacon) +- // (5) AP mode (send Beacon) +- // +- if (rtState == eRfOn && !pPSC->bSwRfProcessing +- && (priv->ieee80211->state != IEEE80211_LINKED) ) +- { +- RT_TRACE(COMP_RF,"IPSEnter(): Turn off RF.\n"); +- pPSC->eInactivePowerState = eRfOff; +-// queue_work(priv->priv_wq,&(pPSC->InactivePsWorkItem)); +- InactivePsWorkItemCallback(priv); +- } +- } +-} +- +-// +-// Description: +-// Leave the inactive power save mode, RF will be on. +-// 2007.08.17, by shien chang. +-// +-void IPSLeave(struct r8192_priv *priv) +-{ +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- RT_RF_POWER_STATE rtState; +- +- if (pPSC->bInactivePs) +- { +- rtState = priv->eRFPowerState; +- if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) +- { +- RT_TRACE(COMP_POWER, "IPSLeave(): Turn on RF.\n"); +- pPSC->eInactivePowerState = eRfOn; +- InactivePsWorkItemCallback(priv); +- } +- } +-} +- +-void IPSLeave_wq(struct work_struct *work) +-{ +- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq); +- struct net_device *dev = ieee->dev; +- +- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); +- down(&priv->ieee80211->ips_sem); +- IPSLeave(priv); +- up(&priv->ieee80211->ips_sem); +-} +- +-void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- RT_RF_POWER_STATE rtState; +- rtState = priv->eRFPowerState; +- +- if (priv->PowerSaveControl.bInactivePs){ +- if(rtState == eRfOff){ +- if(priv->RfOffReason > RF_CHANGE_BY_IPS) +- { +- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); +- return; +- } +- else{ +- printk("=========>%s(): IPSLeave\n",__FUNCTION__); +- queue_work(priv->ieee80211->wq,&priv->ieee80211->ips_leave_wq); +- } +- } +- } +-} +-//added by amy 090331 end +-void ieee80211_ips_leave(struct ieee80211_device *ieee80211) +-{ +- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); +- down(&ieee80211->ips_sem); +- IPSLeave(priv); +- up(&ieee80211->ips_sem); +-} +-#endif +- +-static void rtl819x_update_rxcounts( +- struct r8192_priv *priv, +- u32* TotalRxBcnNum, +- u32* TotalRxDataNum +-) +-{ +- u16 SlotIndex; +- u8 i; +- +- *TotalRxBcnNum = 0; +- *TotalRxDataNum = 0; +- +- SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); +- priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; +- priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; +- for( i=0; iieee80211->LinkDetectInfo.SlotNum; i++ ){ +- *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; +- *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; +- } +-} +- +- +-static void rtl819x_watchdog_wqcallback(struct work_struct *work) +-{ +- struct delayed_work *dwork = container_of(work,struct delayed_work,work); +- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); +- struct ieee80211_device* ieee = priv->ieee80211; +- RESET_TYPE ResetType = RESET_TYPE_NORESET; +- bool bBusyTraffic = false; +- bool bEnterPS = false; +- +- if ((!priv->up) || priv->bHwRadioOff) +- return; +- +- if(!priv->up) +- return; +- hal_dm_watchdog(priv); +-#ifdef ENABLE_IPS +- if(ieee->actscanning == false){ +- if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) && +- (priv->eRFPowerState == eRfOn) && !ieee->is_set_key && +- (!ieee->proto_stoppping) && !ieee->wx_set_enc){ +- if (priv->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){ +- IPSEnter(priv); +- } +- } +- } +-#endif +- {//to get busy traffic condition +- if(ieee->state == IEEE80211_LINKED) +- { +- if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || +- ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { +- bBusyTraffic = true; +- } +- +-#ifdef ENABLE_LPS +- //added by amy for Leisure PS +- if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || +- (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) +- { +- bEnterPS= false; +- } +- else +- { +- bEnterPS= true; +- } +- +- // LeisurePS only work in infra mode. +- if(bEnterPS) +- { +- LeisurePSEnter(priv->ieee80211); +- } +- else +- { +- LeisurePSLeave(priv->ieee80211); +- } +-#endif +- +- } +- else +- { +-#ifdef ENABLE_LPS +- LeisurePSLeave(priv->ieee80211); +-#endif +- } +- +- ieee->LinkDetectInfo.NumRxOkInPeriod = 0; +- ieee->LinkDetectInfo.NumTxOkInPeriod = 0; +- ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; +- ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; +- } +- +- +- //added by amy for AP roaming +- if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) +- { +- u32 TotalRxBcnNum = 0; +- u32 TotalRxDataNum = 0; +- +- rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); +- if((TotalRxBcnNum+TotalRxDataNum) == 0) +- { +- if (priv->eRFPowerState == eRfOff) +- RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); +- printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); +- // Dot11d_Reset(dev); +- ieee->state = IEEE80211_ASSOCIATING; +- notify_wx_assoc_event(priv->ieee80211); +- RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); +- ieee->is_roaming = true; +- ieee->is_set_key = false; +- ieee->link_change(ieee); +- queue_work(ieee->wq, &ieee->associate_procedure_wq); +- } +- } +- ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; +- ieee->LinkDetectInfo.NumRecvDataInPeriod=0; +- +- //check if reset the driver +- if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && +- priv->watchdog_last_time != 1) +- { +- ResetType = rtl819x_check_reset(priv); +- priv->watchdog_check_reset_cnt = 3; +- } +- if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) +- { +- priv->ResetProgress = RESET_TYPE_NORMAL; +- RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__FUNCTION__); +- return; +- } +- /* disable silent reset temply 2008.9.11*/ +- +- if( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) // This is control by OID set in Pomelo +- { +- priv->watchdog_last_time = 1; +- } +- else +- priv->watchdog_last_time = 0; +- +- priv->force_reset = false; +- priv->bForcedSilentReset = false; +- priv->bResetInProgress = false; +- RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); +- +-} +- +-void watch_dog_timer_callback(unsigned long data) +-{ +- struct r8192_priv *priv = (struct r8192_priv *) data; +- queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0); +- mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); +- +-} +- +-static int _rtl8192_up(struct r8192_priv *priv) +-{ +- RT_STATUS init_status = RT_STATUS_SUCCESS; +- struct net_device *dev = priv->ieee80211->dev; +- +- priv->up=1; +- priv->ieee80211->ieee_up=1; +- priv->bdisable_nic = false; //YJ,add,091111 +- RT_TRACE(COMP_INIT, "Bringing up iface\n"); +- +- init_status = rtl8192_adapter_start(priv); +- if(init_status != RT_STATUS_SUCCESS) +- { +- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); +- return -1; +- } +- RT_TRACE(COMP_INIT, "start adapter finished\n"); +- +- if (priv->eRFPowerState != eRfOn) +- MgntActSet_RF_State(priv, eRfOn, priv->RfOffReason); +- +- if(priv->ieee80211->state != IEEE80211_LINKED) +- ieee80211_softmac_start_protocol(priv->ieee80211); +- ieee80211_reset_queue(priv->ieee80211); +- watch_dog_timer_callback((unsigned long) priv); +- if(!netif_queue_stopped(dev)) +- netif_start_queue(dev); +- else +- netif_wake_queue(dev); +- +- return 0; +-} +- +- +-static int rtl8192_open(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- int ret; +- +- down(&priv->wx_sem); +- ret = rtl8192_up(dev); +- up(&priv->wx_sem); +- return ret; +- +-} +- +- +-int rtl8192_up(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- +- if (priv->up == 1) return -1; +- +- return _rtl8192_up(priv); +-} +- +- +-static int rtl8192_close(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- int ret; +- +- down(&priv->wx_sem); +- +- ret = rtl8192_down(dev); +- +- up(&priv->wx_sem); +- +- return ret; +- +-} +- +-int rtl8192_down(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- +- if (priv->up == 0) return -1; +- +-#ifdef ENABLE_LPS +- //LZM for PS-Poll AID issue. 090429 +- if(priv->ieee80211->state == IEEE80211_LINKED) +- LeisurePSLeave(priv->ieee80211); +-#endif +- +- priv->up=0; +- priv->ieee80211->ieee_up = 0; +- RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__); +-/* FIXME */ +- if (!netif_queue_stopped(dev)) +- netif_stop_queue(dev); +- +- rtl8192_irq_disable(priv); +- rtl8192_cancel_deferred_work(priv); +- deinit_hal_dm(priv); +- del_timer_sync(&priv->watch_dog_timer); +- +- ieee80211_softmac_stop_protocol(priv->ieee80211,true); +- +- rtl8192_halt_adapter(priv, false); +- memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list)); +- +- RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__); +- +- return 0; +-} +- +- +-void rtl8192_commit(struct r8192_priv *priv) +-{ +- if (priv->up == 0) return ; +- +- +- ieee80211_softmac_stop_protocol(priv->ieee80211,true); +- +- rtl8192_irq_disable(priv); +- rtl8192_halt_adapter(priv, true); +- _rtl8192_up(priv); +-} +- +-static void rtl8192_restart(struct work_struct *work) +-{ +- struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); +- +- down(&priv->wx_sem); +- +- rtl8192_commit(priv); +- +- up(&priv->wx_sem); +-} +- +-static void r8192_set_multicast(struct net_device *dev) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- +- priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; +-} +- +- +-static int r8192_set_mac_adr(struct net_device *dev, void *mac) +-{ +- struct r8192_priv *priv = ieee80211_priv(dev); +- struct sockaddr *addr = mac; +- +- down(&priv->wx_sem); +- +- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); +- +- schedule_work(&priv->reset_wq); +- up(&priv->wx_sem); +- +- return 0; +-} +- +-static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw) +-{ +- struct ieee80211_device *ieee = priv->ieee80211; +- u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; +- u32 key[4]; +- +- if (ipw->u.crypt.set_tx) { +- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) +- ieee->pairwise_key_type = KEY_TYPE_CCMP; +- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) +- ieee->pairwise_key_type = KEY_TYPE_TKIP; +- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { +- if (ipw->u.crypt.key_len == 13) +- ieee->pairwise_key_type = KEY_TYPE_WEP104; +- else if (ipw->u.crypt.key_len == 5) +- ieee->pairwise_key_type = KEY_TYPE_WEP40; +- } else +- ieee->pairwise_key_type = KEY_TYPE_NA; +- +- if (ieee->pairwise_key_type) { +- memcpy(key, ipw->u.crypt.key, 16); +- EnableHWSecurityConfig8192(priv); +- /* +- * We fill both index entry and 4th entry for pairwise +- * key as in IPW interface, adhoc will only get here, +- * so we need index entry for its default key serching! +- */ +- setKey(priv, 4, ipw->u.crypt.idx, +- ieee->pairwise_key_type, +- (u8*)ieee->ap_mac_addr, 0, key); +- +- /* LEAP WEP will never set this. */ +- if (ieee->auth_mode != 2) +- setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, +- ieee->pairwise_key_type, +- (u8*)ieee->ap_mac_addr, 0, key); +- } +- if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && +- ieee->pHTInfo->bCurrentHTSupport) { +- write_nic_byte(priv, 0x173, 1); /* fix aes bug */ +- } +- } else { +- memcpy(key, ipw->u.crypt.key, 16); +- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) +- ieee->group_key_type= KEY_TYPE_CCMP; +- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) +- ieee->group_key_type = KEY_TYPE_TKIP; +- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { +- if (ipw->u.crypt.key_len == 13) +- ieee->group_key_type = KEY_TYPE_WEP104; +- else if (ipw->u.crypt.key_len == 5) +- ieee->group_key_type = KEY_TYPE_WEP40; +- } else +- ieee->group_key_type = KEY_TYPE_NA; +- +- if (ieee->group_key_type) { +- setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, +- ieee->group_key_type, broadcast_addr, 0, key); +- } +- } +-} +- +-/* based on ipw2200 driver */ +-static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +-{ +- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); +- struct iwreq *wrq = (struct iwreq *)rq; +- int ret=-1; +- struct iw_point *p = &wrq->u.data; +- struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer; +- +- down(&priv->wx_sem); +- +- +- if (p->length < sizeof(struct ieee_param) || !p->pointer){ +- ret = -EINVAL; +- goto out; +- } +- +- ipw = kmalloc(p->length, GFP_KERNEL); +- if (ipw == NULL){ +- ret = -ENOMEM; +- goto out; +- } +- if (copy_from_user(ipw, p->pointer, p->length)) { +- kfree(ipw); +- ret = -EFAULT; +- goto out; +- } +- +- switch (cmd) { +- case RTL_IOCTL_WPA_SUPPLICANT: +- /* parse here for HW security */ +- if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) +- r8192e_set_hw_key(priv, ipw); +- ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); +- break; +- +- default: +- ret = -EOPNOTSUPP; +- break; +- } +- +- kfree(ipw); +-out: +- up(&priv->wx_sem); +- +- return ret; +-} +- +-static u8 HwRateToMRate90(bool bIsHT, u8 rate) +-{ +- u8 ret_rate = 0x02; +- +- if(!bIsHT) { +- switch(rate) { +- case DESC90_RATE1M: ret_rate = MGN_1M; break; +- case DESC90_RATE2M: ret_rate = MGN_2M; break; +- case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; +- case DESC90_RATE11M: ret_rate = MGN_11M; break; +- case DESC90_RATE6M: ret_rate = MGN_6M; break; +- case DESC90_RATE9M: ret_rate = MGN_9M; break; +- case DESC90_RATE12M: ret_rate = MGN_12M; break; +- case DESC90_RATE18M: ret_rate = MGN_18M; break; +- case DESC90_RATE24M: ret_rate = MGN_24M; break; +- case DESC90_RATE36M: ret_rate = MGN_36M; break; +- case DESC90_RATE48M: ret_rate = MGN_48M; break; +- case DESC90_RATE54M: ret_rate = MGN_54M; break; +- +- default: +- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); +- break; +- } +- +- } else { +- switch(rate) { +- case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; +- case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; +- case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; +- case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; +- case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; +- case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; +- case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; +- case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; +- case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; +- case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; +- case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; +- case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; +- case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; +- case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; +- case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; +- case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; +- case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; +- +- default: +- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); +- break; +- } +- } +- +- return ret_rate; +-} +- +-/* Record the TSF time stamp when receiving a packet */ +-static void UpdateRxPktTimeStamp8190(struct r8192_priv *priv, struct ieee80211_rx_stats *stats) +-{ +- +- if(stats->bIsAMPDU && !stats->bFirstMPDU) { +- stats->mac_time[0] = priv->LastRxDescTSFLow; +- stats->mac_time[1] = priv->LastRxDescTSFHigh; +- } else { +- priv->LastRxDescTSFLow = stats->mac_time[0]; +- priv->LastRxDescTSFHigh = stats->mac_time[1]; +- } +-} +- +-static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. +-{ +- long signal_power; // in dBm. +- +- // Translate to dBm (x=0.5y-95). +- signal_power = (long)((signal_strength_index + 1) >> 1); +- signal_power -= 95; +- +- return signal_power; +-} +- +-/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to +- be a local static. Otherwise, it may increase when we return from S3/S4. The +- value will be kept in memory or disk. We must delcare the value in adapter +- and it will be reinitialized when return from S3/S4. */ +-static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats) +-{ +- bool bcheck = false; +- u8 rfpath; +- u32 nspatial_stream, tmp_val; +- static u32 slide_rssi_index=0, slide_rssi_statistics=0; +- static u32 slide_evm_index=0, slide_evm_statistics=0; +- static u32 last_rssi=0, last_evm=0; +- //cosa add for beacon rssi smoothing +- static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; +- static u32 last_beacon_adc_pwdb=0; +- +- struct ieee80211_hdr_3addr *hdr; +- u16 sc ; +- unsigned int frag,seq; +- hdr = (struct ieee80211_hdr_3addr *)buffer; +- sc = le16_to_cpu(hdr->seq_ctl); +- frag = WLAN_GET_SEQ_FRAG(sc); +- seq = WLAN_GET_SEQ_SEQ(sc); +- +- // +- // Check whether we should take the previous packet into accounting +- // +- if(!pprevious_stats->bIsAMPDU) +- { +- // if previous packet is not aggregated packet +- bcheck = true; +- } +- +- if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) +- { +- slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; +- last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; +- priv->stats.slide_rssi_total -= last_rssi; +- } +- priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; +- +- priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; +- if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) +- slide_rssi_index = 0; +- +- // <1> Showed on UI for user, in dbm +- tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; +- priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); +- pcurrent_stats->rssi = priv->stats.signal_strength; +- // +- // If the previous packet does not match the criteria, neglect it +- // +- if(!pprevious_stats->bPacketMatchBSSID) +- { +- if(!pprevious_stats->bToSelfBA) +- return; +- } +- +- if(!bcheck) +- return; +- +- // <2> Showed on UI for engineering +- // hardware does not provide rssi information for each rf path in CCK +- if(!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) +- { +- for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) +- { +- if (!rtl8192_phy_CheckIsLegalRFPath(priv, rfpath)) +- continue; +- RT_TRACE(COMP_DBG, "pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", pprevious_stats->RxMIMOSignalStrength[rfpath]); +- //Fixed by Jacken 2008-03-20 +- if(priv->stats.rx_rssi_percentage[rfpath] == 0) +- { +- priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; +- } +- if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) +- { +- priv->stats.rx_rssi_percentage[rfpath] = +- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + +- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); +- priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; +- } +- else +- { +- priv->stats.rx_rssi_percentage[rfpath] = +- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + +- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); +- } +- RT_TRACE(COMP_DBG, "priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" , priv->stats.rx_rssi_percentage[rfpath]); +- } +- } +- +- +- // +- // Check PWDB. +- // +- //cosa add for beacon rssi smoothing by average. +- if(pprevious_stats->bPacketBeacon) +- { +- /* record the beacon pwdb to the sliding window. */ +- if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) +- { +- slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; +- last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; +- priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; +- // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total); +- } +- priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; +- priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; +- slide_beacon_adc_pwdb_index++; +- if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) +- slide_beacon_adc_pwdb_index = 0; +- pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; +- if(pprevious_stats->RxPWDBAll >= 3) +- pprevious_stats->RxPWDBAll -= 3; +- } +- +- RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", +- pprevious_stats->bIsCCK? "CCK": "OFDM", +- pprevious_stats->RxPWDBAll); +- +- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) +- { +- if(priv->undecorated_smoothed_pwdb < 0) // initialize +- { +- priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; +- } +- +- if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) +- { +- priv->undecorated_smoothed_pwdb = +- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + +- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); +- priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; +- } +- else +- { +- priv->undecorated_smoothed_pwdb = +- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + +- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); +- } +- } +- +- // +- // Check EVM +- // +- /* record the general EVM to the sliding window. */ +- if(pprevious_stats->SignalQuality == 0) +- { +- } +- else +- { +- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ +- if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ +- slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; +- last_evm = priv->stats.slide_evm[slide_evm_index]; +- priv->stats.slide_evm_total -= last_evm; +- } +- +- priv->stats.slide_evm_total += pprevious_stats->SignalQuality; +- +- priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; +- if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) +- slide_evm_index = 0; +- +- // <1> Showed on UI for user, in percentage. +- tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; +- //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. +- } +- +- // <2> Showed on UI for engineering +- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) +- { +- for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream +- { +- if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) +- { +- if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize +- { +- priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; +- } +- priv->stats.rx_evm_percentage[nspatial_stream] = +- ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + +- (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); +- } +- } +- } +- } +- +-} +- +-static u8 rtl819x_query_rxpwrpercentage( +- char antpower +- ) +-{ +- if ((antpower <= -100) || (antpower >= 20)) +- { +- return 0; +- } +- else if (antpower >= 0) +- { +- return 100; +- } +- else +- { +- return (100+antpower); +- } +- +-} +- +-static u8 +-rtl819x_evm_dbtopercentage( +- char value +- ) +-{ +- char ret_val; +- +- ret_val = value; +- +- if(ret_val >= 0) +- ret_val = 0; +- if(ret_val <= -33) +- ret_val = -33; +- ret_val = 0 - ret_val; +- ret_val*=3; +- if(ret_val == 99) +- ret_val = 100; +- return ret_val; +-} +- +-/* We want good-looking for signal strength/quality */ +-static long rtl819x_signal_scale_mapping(long currsig) +-{ +- long retsig; +- +- // Step 1. Scale mapping. +- if(currsig >= 61 && currsig <= 100) +- { +- retsig = 90 + ((currsig - 60) / 4); +- } +- else if(currsig >= 41 && currsig <= 60) +- { +- retsig = 78 + ((currsig - 40) / 2); +- } +- else if(currsig >= 31 && currsig <= 40) +- { +- retsig = 66 + (currsig - 30); +- } +- else if(currsig >= 21 && currsig <= 30) +- { +- retsig = 54 + (currsig - 20); +- } +- else if(currsig >= 5 && currsig <= 20) +- { +- retsig = 42 + (((currsig - 5) * 2) / 3); +- } +- else if(currsig == 4) +- { +- retsig = 36; +- } +- else if(currsig == 3) +- { +- retsig = 27; +- } +- else if(currsig == 2) +- { +- retsig = 18; +- } +- else if(currsig == 1) +- { +- retsig = 9; +- } +- else +- { +- retsig = currsig; +- } +- +- return retsig; +-} +- +-static void rtl8192_query_rxphystatus( +- struct r8192_priv * priv, +- struct ieee80211_rx_stats * pstats, +- prx_desc_819x_pci pdesc, +- prx_fwinfo_819x_pci pdrvinfo, +- struct ieee80211_rx_stats * precord_stats, +- bool bpacket_match_bssid, +- bool bpacket_toself, +- bool bPacketBeacon, +- bool bToSelfBA +- ) +-{ +- //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status); +- phy_sts_ofdm_819xpci_t* pofdm_buf; +- phy_sts_cck_819xpci_t * pcck_buf; +- phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; +- u8 *prxpkt; +- u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; +- char rx_pwr[4], rx_pwr_all=0; +- //long rx_avg_pwr = 0; +- char rx_snrX, rx_evmX; +- u8 evm, pwdb_all; +- u32 RSSI, total_rssi=0;//, total_evm=0; +-// long signal_strength_index = 0; +- u8 is_cck_rate=0; +- u8 rf_rx_num = 0; +- +- is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); +- +- // Record it for next packet processing +- memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); +- pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; +- pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; +- pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo); +- pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; +- pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; +- /*2007.08.30 requested by SD3 Jerry */ +- if (priv->phy_check_reg824 == 0) +- { +- priv->phy_reg824_bit9 = rtl8192_QueryBBReg(priv, rFPGA0_XA_HSSIParameter2, 0x200); +- priv->phy_check_reg824 = 1; +- } +- +- +- prxpkt = (u8*)pdrvinfo; +- +- /* Move pointer to the 16th bytes. Phy status start address. */ +- prxpkt += sizeof(rx_fwinfo_819x_pci); +- +- /* Initial the cck and ofdm buffer pointer */ +- pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; +- pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; +- +- pstats->RxMIMOSignalQuality[0] = -1; +- pstats->RxMIMOSignalQuality[1] = -1; +- precord_stats->RxMIMOSignalQuality[0] = -1; +- precord_stats->RxMIMOSignalQuality[1] = -1; +- +- if(is_cck_rate) +- { +- // +- // (1)Hardware does not provide RSSI for CCK +- // +- +- // +- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) +- // +- u8 report;//, cck_agc_rpt; +- +- if (!priv->phy_reg824_bit9) +- { +- report = pcck_buf->cck_agc_rpt & 0xc0; +- report = report>>6; +- switch(report) +- { +- //Fixed by Jacken from Bryant 2008-03-20 +- //Original value is -38 , -26 , -14 , -2 +- //Fixed value is -35 , -23 , -11 , 6 +- case 0x3: +- rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); +- break; +- case 0x2: +- rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); +- break; +- case 0x1: +- rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); +- break; +- case 0x0: +- rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); +- break; +- } +- } +- else +- { +- report = pcck_buf->cck_agc_rpt & 0x60; +- report = report>>5; +- switch(report) +- { +- case 0x3: +- rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; +- break; +- case 0x2: +- rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); +- break; +- case 0x1: +- rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; +- break; +- case 0x0: +- rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; +- break; +- } +- } +- +- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); +- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; +- pstats->RecvSignalPower = rx_pwr_all; +- +- // +- // (3) Get Signal Quality (EVM) +- // +- if(bpacket_match_bssid) +- { +- u8 sq; +- +- if(pstats->RxPWDBAll > 40) +- { +- sq = 100; +- }else +- { +- sq = pcck_buf->sq_rpt; +- +- if(pcck_buf->sq_rpt > 64) +- sq = 0; +- else if (pcck_buf->sq_rpt < 20) +- sq = 100; +- else +- sq = ((64-sq) * 100) / 44; +- } +- pstats->SignalQuality = precord_stats->SignalQuality = sq; +- pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; +- pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; +- } +- } +- else +- { +- // +- // (1)Get RSSI for HT rate +- // +- for(i=RF90_PATH_A; ibrfpath_rxenable[i]) +- rf_rx_num++; +- //else +- //continue; +- +- //Fixed by Jacken from Bryant 2008-03-20 +- //Original value is 106 +- rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; +- +- //Get Rx snr value in DB +- tmp_rxsnr = pofdm_buf->rxsnr_X[i]; +- rx_snrX = (char)(tmp_rxsnr); +- rx_snrX /= 2; +- +- /* Translate DBM to percentage. */ +- RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); +- if (priv->brfpath_rxenable[i]) +- total_rssi += RSSI; +- +- /* Record Signal Strength for next packet */ +- if(bpacket_match_bssid) +- { +- pstats->RxMIMOSignalStrength[i] =(u8) RSSI; +- precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; +- } +- } +- +- +- // +- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) +- // +- //Fixed by Jacken from Bryant 2008-03-20 +- //Original value is 106 +- rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; +- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); +- +- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; +- pstats->RxPower = precord_stats->RxPower = rx_pwr_all; +- pstats->RecvSignalPower = rx_pwr_all; +- // +- // (3)EVM of HT rate +- // +- if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && +- pdrvinfo->RxRate<=DESC90_RATEMCS15) +- max_spatial_stream = 2; //both spatial stream make sense +- else +- max_spatial_stream = 1; //only spatial stream 1 makes sense +- +- for(i=0; irxevm_X[i]; +- rx_evmX = (char)(tmp_rxevm); +- +- // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment +- // fill most significant bit to "zero" when doing shifting operation which may change a negative +- // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. +- rx_evmX /= 2; //dbm +- +- evm = rtl819x_evm_dbtopercentage(rx_evmX); +- if(bpacket_match_bssid) +- { +- if(i==0) // Fill value in RFD, Get the first spatial stream only +- pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); +- pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); +- } +- } +- +- +- /* record rx statistics for debug */ +- rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; +- prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; +- } +- +- //UI BSS List signal strength(in percentage), make it good looking, from 0~100. +- //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). +- if(is_cck_rate) +- { +- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL; +- +- } +- else +- { +- //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u1Byte)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u1Byte)(total_rssi/=RF90_PATH_MAX); +- // We can judge RX path number now. +- if (rf_rx_num != 0) +- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num))); +- } +-} +- +-static void +-rtl8192_record_rxdesc_forlateruse( +- struct ieee80211_rx_stats * psrc_stats, +- struct ieee80211_rx_stats * ptarget_stats +-) +-{ +- ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; +- ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; +-} +- +- +- +-static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv, +- struct sk_buff *skb, +- struct ieee80211_rx_stats * pstats, +- prx_desc_819x_pci pdesc, +- prx_fwinfo_819x_pci pdrvinfo) +-{ +- // TODO: We must only check packet for current MAC address. Not finish +- bool bpacket_match_bssid, bpacket_toself; +- bool bPacketBeacon=false, bToSelfBA=false; +- struct ieee80211_hdr_3addr *hdr; +- u16 fc,type; +- +- // Get Signal Quality for only RX data queue (but not command queue) +- +- u8* tmp_buf; +- u8 *praddr; +- +- /* Get MAC frame start address. */ +- tmp_buf = skb->data; +- +- hdr = (struct ieee80211_hdr_3addr *)tmp_buf; +- fc = le16_to_cpu(hdr->frame_ctl); +- type = WLAN_FC_GET_TYPE(fc); +- praddr = hdr->addr1; +- +- /* Check if the received packet is acceptabe. */ +- bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) && +- (!compare_ether_addr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) +- && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); +- bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)); +- +- if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON) +- { +- bPacketBeacon = true; +- } +- if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK) +- { +- if (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)) +- bToSelfBA = true; +- } +- +- // +- // Process PHY information for previous packet (RSSI/PWDB/EVM) +- // +- // Because phy information is contained in the last packet of AMPDU only, so driver +- // should process phy information of previous packet +- rtl8192_process_phyinfo(priv, tmp_buf, &priv->previous_stats, pstats); +- rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &priv->previous_stats, bpacket_match_bssid, +- bpacket_toself ,bPacketBeacon, bToSelfBA); +- rtl8192_record_rxdesc_forlateruse(pstats, &priv->previous_stats); +- +-} +- +- +-static void rtl8192_tx_resume(struct r8192_priv *priv) +-{ +- struct ieee80211_device *ieee = priv->ieee80211; +- struct sk_buff *skb; +- int i; +- +- for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) { +- while ((!skb_queue_empty(&ieee->skb_waitQ[i])) && +- (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) { +- /* 1. dequeue the packet from the wait queue */ +- skb = skb_dequeue(&ieee->skb_waitQ[i]); +- /* 2. tx the packet directly */ +- ieee->softmac_data_hard_start_xmit(skb, ieee, 0); +- } +- } +-} +- +-static void rtl8192_irq_tx_tasklet(unsigned long arg) +-{ +- struct r8192_priv *priv = (struct r8192_priv*) arg; +- struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE]; +- unsigned long flags; +- +- /* check if we need to report that the management queue is drained */ +- spin_lock_irqsave(&priv->irq_th_lock, flags); +- +- if (!skb_queue_len(&mgnt_ring->queue) && +- priv->ieee80211->ack_tx_to_ieee && +- rtl8192_is_tx_queue_empty(priv->ieee80211)) { +- priv->ieee80211->ack_tx_to_ieee = 0; +- ieee80211_ps_tx_ack(priv->ieee80211, 1); +- } +- +- spin_unlock_irqrestore(&priv->irq_th_lock, flags); +- +- rtl8192_tx_resume(priv); +-} +- +-/* Record the received data rate */ +-static void UpdateReceivedRateHistogramStatistics8190( +- struct r8192_priv *priv, +- struct ieee80211_rx_stats* pstats +- ) +-{ +- u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV +- u32 rateIndex; +- u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI +- +- if(pstats->bCRC) +- rcvType = 2; +- else if(pstats->bICV) +- rcvType = 3; +- +- if(pstats->bShortPreamble) +- preamble_guardinterval = 1;// short +- else +- preamble_guardinterval = 0;// long +- +- switch(pstats->rate) +- { +- // +- // CCK rate +- // +- case MGN_1M: rateIndex = 0; break; +- case MGN_2M: rateIndex = 1; break; +- case MGN_5_5M: rateIndex = 2; break; +- case MGN_11M: rateIndex = 3; break; +- // +- // Legacy OFDM rate +- // +- case MGN_6M: rateIndex = 4; break; +- case MGN_9M: rateIndex = 5; break; +- case MGN_12M: rateIndex = 6; break; +- case MGN_18M: rateIndex = 7; break; +- case MGN_24M: rateIndex = 8; break; +- case MGN_36M: rateIndex = 9; break; +- case MGN_48M: rateIndex = 10; break; +- case MGN_54M: rateIndex = 11; break; +- // +- // 11n High throughput rate +- // +- case MGN_MCS0: rateIndex = 12; break; +- case MGN_MCS1: rateIndex = 13; break; +- case MGN_MCS2: rateIndex = 14; break; +- case MGN_MCS3: rateIndex = 15; break; +- case MGN_MCS4: rateIndex = 16; break; +- case MGN_MCS5: rateIndex = 17; break; +- case MGN_MCS6: rateIndex = 18; break; +- case MGN_MCS7: rateIndex = 19; break; +- case MGN_MCS8: rateIndex = 20; break; +- case MGN_MCS9: rateIndex = 21; break; +- case MGN_MCS10: rateIndex = 22; break; +- case MGN_MCS11: rateIndex = 23; break; +- case MGN_MCS12: rateIndex = 24; break; +- case MGN_MCS13: rateIndex = 25; break; +- case MGN_MCS14: rateIndex = 26; break; +- case MGN_MCS15: rateIndex = 27; break; +- default: rateIndex = 28; break; +- } +- priv->stats.received_rate_histogram[0][rateIndex]++; //total +- priv->stats.received_rate_histogram[rcvType][rateIndex]++; +-} +- +-static void rtl8192_rx(struct r8192_priv *priv) +-{ +- struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; +- bool unicast_packet = false; +- struct ieee80211_rx_stats stats = { +- .signal = 0, +- .noise = -98, +- .rate = 0, +- .freq = IEEE80211_24GHZ_BAND, +- }; +- unsigned int count = priv->rxringcount; +- prx_fwinfo_819x_pci pDrvInfo = NULL; +- struct sk_buff *new_skb; +- +- while (count--) { +- rx_desc_819x_pci *pdesc = &priv->rx_ring[priv->rx_idx];//rx descriptor +- struct sk_buff *skb = priv->rx_buf[priv->rx_idx];//rx pkt +- +- if (pdesc->OWN) +- /* wait data to be filled by hardware */ +- return; +- +- stats.bICV = pdesc->ICV; +- stats.bCRC = pdesc->CRC32; +- stats.bHwError = pdesc->CRC32 | pdesc->ICV; +- +- stats.Length = pdesc->Length; +- if(stats.Length < 24) +- stats.bHwError |= 1; +- +- if(stats.bHwError) { +- stats.bShift = false; +- goto done; +- } +- pDrvInfo = NULL; +- new_skb = dev_alloc_skb(priv->rxbuffersize); +- +- if (unlikely(!new_skb)) +- goto done; +- +- stats.RxDrvInfoSize = pdesc->RxDrvInfoSize; +- stats.RxBufShift = ((pdesc->Shift)&0x03); +- stats.Decrypted = !pdesc->SWDec; +- +- pci_dma_sync_single_for_cpu(priv->pdev, +- *((dma_addr_t *)skb->cb), +- priv->rxbuffersize, +- PCI_DMA_FROMDEVICE); +- skb_put(skb, pdesc->Length); +- pDrvInfo = (rx_fwinfo_819x_pci *)(skb->data + stats.RxBufShift); +- skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); +- +- stats.rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); +- stats.bShortPreamble = pDrvInfo->SPLCP; +- +- /* it is debug only. It should be disabled in released driver. +- * 2007.1.11 by Emily +- * */ +- UpdateReceivedRateHistogramStatistics8190(priv, &stats); +- +- stats.bIsAMPDU = (pDrvInfo->PartAggr==1); +- stats.bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); +- +- stats.TimeStampLow = pDrvInfo->TSFL; +- stats.TimeStampHigh = read_nic_dword(priv, TSFR+4); +- +- UpdateRxPktTimeStamp8190(priv, &stats); +- +- // +- // Get Total offset of MPDU Frame Body +- // +- if((stats.RxBufShift + stats.RxDrvInfoSize) > 0) +- stats.bShift = 1; +- +- /* ???? */ +- TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo); +- +- /* Rx A-MPDU */ +- if(pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) +- RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", +- pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); +- skb_trim(skb, skb->len - 4/*sCrcLng*/); +- /* rx packets statistics */ +- ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; +- unicast_packet = false; +- +- if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) { +- //TODO +- }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){ +- //TODO +- }else { +- /* unicast packet */ +- unicast_packet = true; +- } +- +- if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){ +- dev_kfree_skb_any(skb); +- } else { +- priv->stats.rxok++; +- if(unicast_packet) { +- priv->stats.rxbytesunicast += skb->len; +- } +- } +- +- pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb), +- priv->rxbuffersize, PCI_DMA_FROMDEVICE); +- +- skb = new_skb; +- priv->rx_buf[priv->rx_idx] = skb; +- *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); +- +-done: +- pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); +- pdesc->OWN = 1; +- pdesc->Length = priv->rxbuffersize; +- if (priv->rx_idx == priv->rxringcount-1) +- pdesc->EOR = 1; +- priv->rx_idx = (priv->rx_idx + 1) % priv->rxringcount; +- } +- +-} +- +-static void rtl8192_irq_rx_tasklet(unsigned long arg) +-{ +- struct r8192_priv *priv = (struct r8192_priv*) arg; +- rtl8192_rx(priv); +- /* unmask RDU */ +- write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) | IMR_RDU); +-} +- +-static const struct net_device_ops rtl8192_netdev_ops = { +- .ndo_open = rtl8192_open, +- .ndo_stop = rtl8192_close, +- .ndo_tx_timeout = tx_timeout, +- .ndo_do_ioctl = rtl8192_ioctl, +- .ndo_set_multicast_list = r8192_set_multicast, +- .ndo_set_mac_address = r8192_set_mac_adr, +- .ndo_start_xmit = ieee80211_rtl_xmit, +-}; +- +-static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, +- const struct pci_device_id *id) +-{ +- struct net_device *dev = NULL; +- struct r8192_priv *priv= NULL; +- u8 unit = 0; +- int ret = -ENODEV; +- unsigned long pmem_start, pmem_len, pmem_flags; +- +- RT_TRACE(COMP_INIT,"Configuring chip resources\n"); +- +- if( pci_enable_device (pdev) ){ +- RT_TRACE(COMP_ERR,"Failed to enable PCI device"); +- return -EIO; +- } +- +- pci_set_master(pdev); +- //pci_set_wmi(pdev); +- pci_set_dma_mask(pdev, 0xffffff00ULL); +- pci_set_consistent_dma_mask(pdev,0xffffff00ULL); +- dev = alloc_ieee80211(sizeof(struct r8192_priv)); +- if (!dev) { +- ret = -ENOMEM; +- goto fail_free; +- } +- +- pci_set_drvdata(pdev, dev); +- SET_NETDEV_DEV(dev, &pdev->dev); +- priv = ieee80211_priv(dev); +- priv->ieee80211 = netdev_priv(dev); +- priv->pdev=pdev; +- if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ +- priv->ieee80211->bSupportRemoteWakeUp = 1; +- } else +- { +- priv->ieee80211->bSupportRemoteWakeUp = 0; +- } +- +- pmem_start = pci_resource_start(pdev, 1); +- pmem_len = pci_resource_len(pdev, 1); +- pmem_flags = pci_resource_flags (pdev, 1); +- +- if (!(pmem_flags & IORESOURCE_MEM)) { +- RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting\n"); +- goto fail; +- } +- +- //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); +- if( ! request_mem_region(pmem_start, pmem_len, RTL819xE_MODULE_NAME)) { +- RT_TRACE(COMP_ERR,"request_mem_region failed!\n"); +- goto fail; +- } +- +- priv->mem_start = ioremap_nocache(pmem_start, pmem_len); +- if (!priv->mem_start) { +- RT_TRACE(COMP_ERR,"ioremap failed!\n"); +- goto fail1; +- } +- +- dev->mem_start = (unsigned long) priv->mem_start; +- dev->mem_end = (unsigned long) (priv->mem_start + +- pci_resource_len(pdev, 0)); +- +- /* We disable the RETRY_TIMEOUT register (0x41) to keep +- * PCI Tx retries from interfering with C3 CPU state */ +- pci_write_config_byte(pdev, 0x41, 0x00); +- +- +- pci_read_config_byte(pdev, 0x05, &unit); +- pci_write_config_byte(pdev, 0x05, unit & (~0x04)); +- +- dev->irq = pdev->irq; +- priv->irq = 0; +- +- dev->netdev_ops = &rtl8192_netdev_ops; +- +- dev->wireless_handlers = &r8192_wx_handlers_def; +- dev->type=ARPHRD_ETHER; +- +- dev->watchdog_timeo = HZ*3; +- +- if (dev_alloc_name(dev, ifname) < 0){ +- RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); +- strcpy(ifname, "wlan%d"); +- dev_alloc_name(dev, ifname); +- } +- +- RT_TRACE(COMP_INIT, "Driver probe completed1\n"); +- if (rtl8192_init(priv)!=0) { +- RT_TRACE(COMP_ERR, "Initialization failed\n"); +- goto fail; +- } +- +- register_netdev(dev); +- RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name); +- rtl8192_proc_init_one(priv); +- +- +- RT_TRACE(COMP_INIT, "Driver probe completed\n"); +- return 0; +- +-fail1: +- +- if (priv->mem_start) { +- iounmap(priv->mem_start); +- release_mem_region( pci_resource_start(pdev, 1), +- pci_resource_len(pdev, 1) ); +- } +- +-fail: +- if(dev){ +- +- if (priv->irq) { +- free_irq(priv->irq, priv); +- priv->irq = 0; +- } +- free_ieee80211(dev); +- } +- +-fail_free: +- pci_disable_device(pdev); +- +- DMESG("wlan driver load failed\n"); +- pci_set_drvdata(pdev, NULL); +- return ret; +- +-} +- +-/* detach all the work and timer structure declared or inititialized +- * in r8192_init function. +- * */ +-static void rtl8192_cancel_deferred_work(struct r8192_priv* priv) +-{ +- /* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code +- * is or is newer than 2.6.20 and work structure is defined to be struct work_struct. +- * Otherwise call cancel_delayed_work is enough. +- * FIXME (2.6.20 should 2.6.22, work_struct should not cancel) +- * */ +- cancel_delayed_work(&priv->watch_dog_wq); +- cancel_delayed_work(&priv->update_beacon_wq); +- cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); +- cancel_delayed_work(&priv->gpio_change_rf_wq); +- cancel_work_sync(&priv->reset_wq); +- cancel_work_sync(&priv->qos_activate); +-} +- +- +-static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) +-{ +- struct net_device *dev = pci_get_drvdata(pdev); +- struct r8192_priv *priv ; +- u32 i; +- +- if (dev) { +- +- unregister_netdev(dev); +- +- priv = ieee80211_priv(dev); +- +- rtl8192_proc_remove_one(priv); +- +- rtl8192_down(dev); +- if (priv->pFirmware) +- { +- vfree(priv->pFirmware); +- priv->pFirmware = NULL; +- } +- destroy_workqueue(priv->priv_wq); +- +- /* free tx/rx rings */ +- rtl8192_free_rx_ring(priv); +- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) +- rtl8192_free_tx_ring(priv, i); +- +- if (priv->irq) { +- printk("Freeing irq %d\n", priv->irq); +- free_irq(priv->irq, priv); +- priv->irq = 0; +- } +- +- if (priv->mem_start) { +- iounmap(priv->mem_start); +- release_mem_region( pci_resource_start(pdev, 1), +- pci_resource_len(pdev, 1) ); +- } +- +- free_ieee80211(dev); +- } +- +- pci_disable_device(pdev); +- RT_TRACE(COMP_DOWN, "wlan driver removed\n"); +-} +- +-extern int ieee80211_rtl_init(void); +-extern void ieee80211_rtl_exit(void); +- +-static int __init rtl8192_pci_module_init(void) +-{ +- int retval; +- +- retval = ieee80211_rtl_init(); +- if (retval) +- return retval; +- +- printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); +- printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); +- RT_TRACE(COMP_INIT, "Initializing module\n"); +- rtl8192_proc_module_init(); +- if(0!=pci_register_driver(&rtl8192_pci_driver)) +- { +- DMESG("No device found"); +- /*pci_unregister_driver (&rtl8192_pci_driver);*/ +- return -ENODEV; +- } +- return 0; +-} +- +- +-static void __exit rtl8192_pci_module_exit(void) +-{ +- pci_unregister_driver(&rtl8192_pci_driver); +- +- RT_TRACE(COMP_DOWN, "Exiting\n"); +- rtl8192_proc_module_remove(); +- ieee80211_rtl_exit(); +-} +- +-static irqreturn_t rtl8192_interrupt(int irq, void *param) +-{ +- struct r8192_priv *priv = param; +- struct net_device *dev = priv->ieee80211->dev; +- unsigned long flags; +- u32 inta; +- irqreturn_t ret = IRQ_HANDLED; +- +- spin_lock_irqsave(&priv->irq_th_lock, flags); +- +- /* ISR: 4bytes */ +- +- inta = read_nic_dword(priv, ISR); /* & priv->IntrMask; */ +- write_nic_dword(priv, ISR, inta); /* reset int situation */ +- +- if (!inta) { +- /* +- * most probably we can safely return IRQ_NONE, +- * but for now is better to avoid problems +- */ +- goto out_unlock; +- } +- +- if (inta == 0xffff) { +- /* HW disappared */ +- goto out_unlock; +- } +- +- if (!netif_running(dev)) +- goto out_unlock; +- +- if (inta & IMR_TBDOK) { +- RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); +- rtl8192_tx_isr(priv, BEACON_QUEUE); +- priv->stats.txbeaconokint++; +- } +- +- if (inta & IMR_TBDER) { +- RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); +- rtl8192_tx_isr(priv, BEACON_QUEUE); +- priv->stats.txbeaconerr++; +- } +- +- if (inta & IMR_MGNTDOK ) { +- RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); +- priv->stats.txmanageokint++; +- rtl8192_tx_isr(priv, MGNT_QUEUE); +- } +- +- if (inta & IMR_COMDOK) +- { +- priv->stats.txcmdpktokint++; +- rtl8192_tx_isr(priv, TXCMD_QUEUE); +- } +- +- if (inta & IMR_ROK) { +- priv->stats.rxint++; +- tasklet_schedule(&priv->irq_rx_tasklet); +- } +- +- if (inta & IMR_BcnInt) { +- RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); +- tasklet_schedule(&priv->irq_prepare_beacon_tasklet); +- } +- +- if (inta & IMR_RDU) { +- RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); +- priv->stats.rxrdu++; +- /* reset int situation */ +- write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) & ~IMR_RDU); +- tasklet_schedule(&priv->irq_rx_tasklet); +- } +- +- if (inta & IMR_RXFOVW) { +- RT_TRACE(COMP_INTR, "rx overflow !\n"); +- priv->stats.rxoverflow++; +- tasklet_schedule(&priv->irq_rx_tasklet); +- } +- +- if (inta & IMR_TXFOVW) +- priv->stats.txoverflow++; +- +- if (inta & IMR_BKDOK) { +- RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); +- priv->stats.txbkokint++; +- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; +- rtl8192_tx_isr(priv, BK_QUEUE); +- } +- +- if (inta & IMR_BEDOK) { +- RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); +- priv->stats.txbeokint++; +- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; +- rtl8192_tx_isr(priv, BE_QUEUE); +- } +- +- if (inta & IMR_VIDOK) { +- RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); +- priv->stats.txviokint++; +- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; +- rtl8192_tx_isr(priv, VI_QUEUE); +- } +- +- if (inta & IMR_VODOK) { +- priv->stats.txvookint++; +- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; +- rtl8192_tx_isr(priv, VO_QUEUE); +- } +- +-out_unlock: +- spin_unlock_irqrestore(&priv->irq_th_lock, flags); +- +- return ret; +-} +- +-void EnableHWSecurityConfig8192(struct r8192_priv *priv) +-{ +- u8 SECR_value = 0x0; +- struct ieee80211_device* ieee = priv->ieee80211; +- +- SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; +- +- if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) +- { +- SECR_value |= SCR_RxUseDK; +- SECR_value |= SCR_TxUseDK; +- } +- else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) +- { +- SECR_value |= SCR_RxUseDK; +- SECR_value |= SCR_TxUseDK; +- } +- +- //add HWSec active enable here. +-//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 +- ieee->hwsec_active = 1; +- +- if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off +- { +- ieee->hwsec_active = 0; +- SECR_value &= ~SCR_RxDecEnable; +- } +- +- RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, +- ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); +- { +- write_nic_byte(priv, SECR, SECR_value);//SECR_value | SCR_UseDK ); +- } +- +-} +-#define TOTAL_CAM_ENTRY 32 +-//#define CAM_CONTENT_COUNT 8 +-void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, +- const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) +-{ +- u32 TargetCommand = 0; +- u32 TargetContent = 0; +- u16 usConfig = 0; +- u8 i; +-#ifdef ENABLE_IPS +- RT_RF_POWER_STATE rtState; +- +- rtState = priv->eRFPowerState; +- if (priv->PowerSaveControl.bInactivePs){ +- if(rtState == eRfOff){ +- if(priv->RfOffReason > RF_CHANGE_BY_IPS) +- { +- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); +- //up(&priv->wx_sem); +- return ; +- } +- else{ +- down(&priv->ieee80211->ips_sem); +- IPSLeave(priv); +- up(&priv->ieee80211->ips_sem); +- } +- } +- } +- priv->ieee80211->is_set_key = true; +-#endif +- if (EntryNo >= TOTAL_CAM_ENTRY) +- RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); +- +- RT_TRACE(COMP_SEC, "====>to setKey(), priv:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", priv, EntryNo, KeyIndex, KeyType, MacAddr); +- +- if (DefaultKey) +- usConfig |= BIT15 | (KeyType<<2); +- else +- usConfig |= BIT15 | (KeyType<<2) | KeyIndex; +-// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; +- +- +- for(i=0 ; iafter set key, usconfig:%x\n", usConfig); +-} +- +-bool NicIFEnableNIC(struct r8192_priv *priv) +-{ +- RT_STATUS init_status = RT_STATUS_SUCCESS; +- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; +- +- //YJ,add,091109 +- if (priv->up == 0){ +- RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__FUNCTION__); +- priv->bdisable_nic = false; //YJ,add,091111 +- return false; +- } +- // <1> Reset memory: descriptor, buffer,.. +- //NicIFResetMemory(Adapter); +- +- // <2> Enable Adapter +- //priv->bfirst_init = true; +- init_status = rtl8192_adapter_start(priv); +- if (init_status != RT_STATUS_SUCCESS) { +- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); +- priv->bdisable_nic = false; //YJ,add,091111 +- return -1; +- } +- RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); +- //priv->bfirst_init = false; +- +- // <3> Enable Interrupt +- rtl8192_irq_enable(priv); +- priv->bdisable_nic = false; +- +- return (init_status == RT_STATUS_SUCCESS); +-} +- +-bool NicIFDisableNIC(struct r8192_priv *priv) +-{ +- bool status = true; +- u8 tmp_state = 0; +- // <1> Disable Interrupt +- +- priv->bdisable_nic = true; //YJ,move,091109 +- tmp_state = priv->ieee80211->state; +- +- ieee80211_softmac_stop_protocol(priv->ieee80211, false); +- +- priv->ieee80211->state = tmp_state; +- rtl8192_cancel_deferred_work(priv); +- rtl8192_irq_disable(priv); +- // <2> Stop all timer +- +- // <3> Disable Adapter +- rtl8192_halt_adapter(priv, false); +-// priv->bdisable_nic = true; +- +- return status; +-} +- +-module_init(rtl8192_pci_module_init); +-module_exit(rtl8192_pci_module_exit); diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c new file mode 100644 index 00000000000..ba988f0fbd3 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -0,0 +1,2670 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtl_core.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" +#include "r8192E_cmdpkt.h" +#include "rtl_dm.h" +#include "rtl_wx.h" + +extern int WDCAPARA_ADD[]; + +void rtl8192e_start_beacon(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_network *net = &priv->rtllib->current_network; + u16 BcnTimeCfg = 0; + u16 BcnCW = 6; + u16 BcnIFS = 0xf; + + DMESG("Enabling beacon TX"); + rtl8192_irq_disable(dev); + + write_nic_word(dev, ATIMWND, 2); + + write_nic_word(dev, BCN_INTERVAL, net->beacon_interval); + write_nic_word(dev, BCN_DRV_EARLY_INT, 10); + write_nic_word(dev, BCN_DMATIME, 256); + + write_nic_byte(dev, BCN_ERR_THRESH, 100); + + BcnTimeCfg |= BcnCW<rtllib->iw_mode) { + case IW_MODE_INFRA: + if (priv->rtllib->state == RTLLIB_LINKED) + msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT); + else + msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + LedAction = LED_CTL_LINK; + break; + case IW_MODE_ADHOC: + if (priv->rtllib->state == RTLLIB_LINKED) + msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT); + else + msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + break; + case IW_MODE_MASTER: + if (priv->rtllib->state == RTLLIB_LINKED) + msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT); + else + msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + break; + default: + break; + } + + write_nic_byte(dev, MSR, msr); + if (priv->rtllib->LedControlHandler) + priv->rtllib->LedControlHandler(dev, LedAction); +} + +void +rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) +{ + struct r8192_priv* priv = rtllib_priv(dev); + + switch (variable) + { + + case HW_VAR_BSSID: + write_nic_dword(dev, BSSIDR, ((u32*)(val))[0]); + write_nic_word(dev, BSSIDR+2, ((u16*)(val+2))[0]); + break; + + case HW_VAR_MEDIA_STATUS: + { + RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); + LED_CTL_MODE LedAction = LED_CTL_NO_LINK; + u8 btMsr = read_nic_byte(dev, MSR); + + btMsr &= 0xfc; + + switch (OpMode) + { + case RT_OP_MODE_INFRASTRUCTURE: + btMsr |= MSR_INFRA; + LedAction = LED_CTL_LINK; + break; + + case RT_OP_MODE_IBSS: + btMsr |= MSR_ADHOC; + break; + + case RT_OP_MODE_AP: + btMsr |= MSR_AP; + LedAction = LED_CTL_LINK; + break; + + default: + btMsr |= MSR_NOLINK; + break; + } + + write_nic_byte(dev, MSR, btMsr); + + } + break; + + case HW_VAR_CECHK_BSSID: + { + u32 RegRCR, Type; + + Type = ((u8*)(val))[0]; + RegRCR = read_nic_dword(dev,RCR); + priv->ReceiveConfig = RegRCR; + + if (Type == true) + RegRCR |= (RCR_CBSSID); + else if (Type == false) + RegRCR &= (~RCR_CBSSID); + + write_nic_dword(dev, RCR,RegRCR); + priv->ReceiveConfig = RegRCR; + + } + break; + + case HW_VAR_SLOT_TIME: + { + + priv->slot_time = val[0]; + write_nic_byte(dev, SLOT_TIME, val[0]); + +#ifdef MERGE_TO_DO + if (priv->rtllib->current_network.qos_data.supported !=0) + { + for (eACI = 0; eACI < AC_MAX; eACI++) + { + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&eACI)); + } + } + else + { + u8 u1bAIFS = aSifsTime + (2 * priv->slot_time); + + write_nic_byte(dev, EDCAPARA_VO, u1bAIFS); + write_nic_byte(dev, EDCAPARA_VI, u1bAIFS); + write_nic_byte(dev, EDCAPARA_BE, u1bAIFS); + write_nic_byte(dev, EDCAPARA_BK, u1bAIFS); + } +#endif + } + break; + + case HW_VAR_ACK_PREAMBLE: + { + u32 regTmp = 0; + priv->short_preamble = (bool)(*(u8*)val ); + regTmp = priv->basic_rate; + if (priv->short_preamble) + regTmp |= BRSR_AckShortPmb; + write_nic_dword(dev, RRSR, regTmp); + } + break; + + case HW_VAR_CPU_RST: + write_nic_dword(dev, CPU_GEN, ((u32*)(val))[0]); + break; + + case HW_VAR_AC_PARAM: + { + u8 pAcParam = *((u8*)val); +#ifdef MERGE_TO_DO + u32 eACI = GET_WMM_AC_PARAM_ACI(pAcParam); +#else + u32 eACI = pAcParam; +#endif + u8 u1bAIFS; + u32 u4bAcParam; + u8 mode = priv->rtllib->mode; + struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; + + + u1bAIFS = qos_parameters->aifs[pAcParam] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; + + dm_init_edca_turbo(dev); + + u4bAcParam = ( (((u32)(qos_parameters->tx_op_limit[pAcParam])) << AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[pAcParam])) << AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[pAcParam])) << AC_PARAM_ECW_MIN_OFFSET) | + (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET) ); + + RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", __func__,eACI, u4bAcParam); + switch (eACI) + { + case AC1_BK: + write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); + break; + + case AC0_BE: + write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + break; + + case AC2_VI: + write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + break; + + case AC3_VO: + write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + break; + + default: + printk("SetHwReg8185(): invalid ACI: %d !\n", eACI); + break; + } + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, (u8*)(&pAcParam)); + } + break; + + case HW_VAR_ACM_CTRL: + { + struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; + u8 pAcParam = *((u8*)val); +#ifdef MERGE_TO_DO + u32 eACI = GET_WMM_AC_PARAM_ACI(pAciAifsn); +#else + u32 eACI = pAcParam; +#endif + PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); + u8 ACM = pAciAifsn->f.ACM; + u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); + + RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", __func__,eACI); + AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2)?0x0:0x1); + + if ( ACM ) + { + switch (eACI) + { + case AC0_BE: + AcmCtrl |= AcmHw_BeqEn; + break; + + case AC2_VI: + AcmCtrl |= AcmHw_ViqEn; + break; + + case AC3_VO: + AcmCtrl |= AcmHw_VoqEn; + break; + + default: + RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI ); + break; + } + } + else + { + switch (eACI) + { + case AC0_BE: + AcmCtrl &= (~AcmHw_BeqEn); + break; + + case AC2_VI: + AcmCtrl &= (~AcmHw_ViqEn); + break; + + case AC3_VO: + AcmCtrl &= (~AcmHw_BeqEn); + break; + + default: + break; + } + } + + RT_TRACE( COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ); + write_nic_byte(dev, AcmHwCtrl, AcmCtrl ); + } + break; + + case HW_VAR_SIFS: + write_nic_byte(dev, SIFS, val[0]); + write_nic_byte(dev, SIFS+1, val[0]); + break; + + case HW_VAR_RF_TIMING: + { +#ifdef RTL8192E + u8 Rf_Timing = *((u8*)val); + write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); +#endif + } + break; + + default: + break; + } + +} + +static void rtl8192_read_eeprom_info(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + u8 tempval; +#ifdef RTL8192E + u8 ICVer8192, ICVer8256; +#endif + u16 i,usValue, IC_Version; + u16 EEPROMId; +#ifdef RTL8190P + u8 offset; + u8 EepromTxPower[100]; +#endif + u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; + RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); + + + + EEPROMId = eprom_read(dev, 0); + if ( EEPROMId != RTL8190_EEPROM_ID ) + { + RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); + priv->AutoloadFailFlag=true; + } + else + { + priv->AutoloadFailFlag=false; + } + + if (!priv->AutoloadFailFlag) + { + priv->eeprom_vid = eprom_read(dev, (EEPROM_VID >> 1)); + priv->eeprom_did = eprom_read(dev, (EEPROM_DID >> 1)); + + usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; + priv->eeprom_CustomerID = (u8)( usValue & 0xff); + usValue = eprom_read(dev, (EEPROM_ICVersion_ChannelPlan>>1)); + priv->eeprom_ChannelPlan = usValue&0xff; + IC_Version = ((usValue&0xff00)>>8); + +#ifdef RTL8190P + priv->card_8192_version = (VERSION_8190)(IC_Version); +#elif defined RTL8192E + ICVer8192 = (IC_Version&0xf); + ICVer8256 = ((IC_Version&0xf0)>>4); + RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); + RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256); + if (ICVer8192 == 0x2) + { + if (ICVer8256 == 0x5) + priv->card_8192_version= VERSION_8190_BE; + } +#endif + switch (priv->card_8192_version) + { + case VERSION_8190_BD: + case VERSION_8190_BE: + break; + default: + priv->card_8192_version = VERSION_8190_BD; + break; + } + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); + } + else + { + priv->card_8192_version = VERSION_8190_BD; + priv->eeprom_vid = 0; + priv->eeprom_did = 0; + priv->eeprom_CustomerID = 0; + priv->eeprom_ChannelPlan = 0; + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", 0xff); + } + + RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); + RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); + RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); + + if (!priv->AutoloadFailFlag) + { + for (i = 0; i < 6; i += 2) + { + usValue = eprom_read(dev, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); + *(u16*)(&dev->dev_addr[i]) = usValue; + } + } else { + memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); + } + + RT_TRACE(COMP_INIT, "Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", + dev->dev_addr[0], dev->dev_addr[1], + dev->dev_addr[2], dev->dev_addr[3], + dev->dev_addr[4], dev->dev_addr[5]); + + if (priv->card_8192_version > VERSION_8190_BD) { + priv->bTXPowerDataReadFromEEPORM = true; + } else { + priv->bTXPowerDataReadFromEEPORM = false; + } + + priv->rf_type = RTL819X_DEFAULT_RF_TYPE; + + if (priv->card_8192_version > VERSION_8190_BD) + { + if (!priv->AutoloadFailFlag) + { + tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; + priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; + + if (tempval&0x80) + priv->rf_type = RF_1T2R; + else + priv->rf_type = RF_2T4R; + } + else + { + priv->EEPROMLegacyHTTxPowerDiff = 0x04; + } + RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", + priv->EEPROMLegacyHTTxPowerDiff); + + if (!priv->AutoloadFailFlag) + { + priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); + } + else + { + priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; + } + RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); + priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; + + if (priv->epromtype == EEPROM_93C46) + { + if (!priv->AutoloadFailFlag) + { + usValue = eprom_read(dev, (EEPROM_TxPwDiff_CrystalCap>>1)); + priv->EEPROMAntPwDiff = (usValue&0x0fff); + priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); + } + else + { + priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + + for (i=0; i<14; i+=2) + { + if (!priv->AutoloadFailFlag) + { + usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); + } + else + { + usValue = EEPROM_Default_TxPower; + } + *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; + RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); + } + for (i=0; i<14; i+=2) + { + if (!priv->AutoloadFailFlag) + { + usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); + } + else + { + usValue = EEPROM_Default_TxPower; + } + *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); + } + } + else if (priv->epromtype== EEPROM_93C56) + { +#ifdef RTL8190P + if (!priv->AutoloadFailFlag) + { + priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = (u8)(((eprom_read(dev, (EEPROM_C56_CrystalCap>>1))) & 0xf000)>>12); + } + else + { + priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT,"EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + + if (!priv->AutoloadFailFlag) + { + for (i = 0; i < 12; i+=2) + { + if (i <6) + offset = EEPROM_C56_RfA_CCK_Chnl1_TxPwIndex + i; + else + offset = EEPROM_C56_RfC_CCK_Chnl1_TxPwIndex + i - 6; + usValue = eprom_read(dev, (offset>>1)); + *((u16*)(&EepromTxPower[i])) = usValue; + } + + for (i = 0; i < 12; i++) + { + if (i <= 2) + priv->EEPROMRfACCKChnl1TxPwLevel[i] = EepromTxPower[i]; + else if ((i >=3 )&&(i <= 5)) + priv->EEPROMRfAOfdmChnlTxPwLevel[i-3] = EepromTxPower[i]; + else if ((i >=6 )&&(i <= 8)) + priv->EEPROMRfCCCKChnl1TxPwLevel[i-6] = EepromTxPower[i]; + else + priv->EEPROMRfCOfdmChnlTxPwLevel[i-9] = EepromTxPower[i]; + } + } + else + { + priv->EEPROMRfACCKChnl1TxPwLevel[0] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfACCKChnl1TxPwLevel[1] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfACCKChnl1TxPwLevel[2] = EEPROM_Default_TxPowerLevel; + + priv->EEPROMRfAOfdmChnlTxPwLevel[0] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfAOfdmChnlTxPwLevel[1] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfAOfdmChnlTxPwLevel[2] = EEPROM_Default_TxPowerLevel; + + priv->EEPROMRfCCCKChnl1TxPwLevel[0] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfCCCKChnl1TxPwLevel[1] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfCCCKChnl1TxPwLevel[2] = EEPROM_Default_TxPowerLevel; + + priv->EEPROMRfCOfdmChnlTxPwLevel[0] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfCOfdmChnlTxPwLevel[1] = EEPROM_Default_TxPowerLevel; + priv->EEPROMRfCOfdmChnlTxPwLevel[2] = EEPROM_Default_TxPowerLevel; + } + RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[0] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[0]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[1] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[1]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[2] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[2]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[0] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[0]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[1] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[1]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[2] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[2]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[0] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[0]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[1] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[1]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[2] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[2]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[0] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[0]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[1] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[1]); + RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[2] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[2]); +#endif + + } + if (priv->epromtype == EEPROM_93C46) + { + for (i=0; i<14; i++) + { + priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; + priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; + } + priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); + priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); + priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); + priv->CrystalCap = priv->EEPROMCrystalCap; + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + } + else if (priv->epromtype == EEPROM_93C56) + { + + for (i=0; i<3; i++) + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; + } + for (i=3; i<9; i++) + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; + } + for (i=9; i<14; i++) + { + priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; + priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; + } + for (i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); + for (i=0; i<14; i++) + RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); + for (i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); + for (i=0; i<14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); + priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = 0; + priv->AntennaTxPwDiff[1] = 0; + priv->AntennaTxPwDiff[2] = 0; + priv->CrystalCap = priv->EEPROMCrystalCap; + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + } + } + + if (priv->rf_type == RF_1T2R) + { + RT_TRACE(COMP_INIT, "\n1T2R config\n"); + } + else if (priv->rf_type == RF_2T4R) + { + RT_TRACE(COMP_INIT, "\n2T4R config\n"); + } + + init_rate_adaptive(dev); + + + priv->rf_chip= RF_8256; + + if (priv->RegChannelPlan == 0xf) + { + priv->ChannelPlan = priv->eeprom_ChannelPlan; + } + else + { + priv->ChannelPlan = priv->RegChannelPlan; + } + + if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) + { + priv->CustomerID = RT_CID_DLINK; + } + + switch (priv->eeprom_CustomerID) + { + case EEPROM_CID_DEFAULT: + priv->CustomerID = RT_CID_DEFAULT; + break; + case EEPROM_CID_CAMEO: + priv->CustomerID = RT_CID_819x_CAMEO; + break; + case EEPROM_CID_RUNTOP: + priv->CustomerID = RT_CID_819x_RUNTOP; + break; + case EEPROM_CID_NetCore: + priv->CustomerID = RT_CID_819x_Netcore; + break; + case EEPROM_CID_TOSHIBA: + priv->CustomerID = RT_CID_TOSHIBA; + if (priv->eeprom_ChannelPlan&0x80) + priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + else + priv->ChannelPlan = 0x0; + RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", + priv->ChannelPlan); + break; + case EEPROM_CID_Nettronix: + priv->ScanDelay = 100; + priv->CustomerID = RT_CID_Nettronix; + break; + case EEPROM_CID_Pronet: + priv->CustomerID = RT_CID_PRONET; + break; + case EEPROM_CID_DLINK: + priv->CustomerID = RT_CID_DLINK; + break; + + case EEPROM_CID_WHQL: + + + + break; + default: + break; + } + + if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) + priv->ChannelPlan = 0; +#ifdef ENABLE_DOT11D + priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; +#endif + +#ifdef TO_DO_LIST + switch (priv->CustomerID) + { + case RT_CID_DEFAULT: +#ifdef RTL8190P + priv->LedStrategy = HW_LED; +#elif defined RTL8192E + priv->LedStrategy = SW_LED_MODE1; +#endif + break; + + case RT_CID_819x_CAMEO: + priv->LedStrategy = SW_LED_MODE2; + break; + + case RT_CID_819x_RUNTOP: + priv->LedStrategy = SW_LED_MODE3; + break; + + case RT_CID_819x_Netcore: + priv->LedStrategy = SW_LED_MODE4; + break; + + case RT_CID_Nettronix: + priv->LedStrategy = SW_LED_MODE5; + break; + + case RT_CID_PRONET: + priv->LedStrategy = SW_LED_MODE6; + break; + + case RT_CID_TOSHIBA: + + default: +#ifdef RTL8190P + priv->LedStrategy = HW_LED; +#elif defined RTL8192E + priv->LedStrategy = SW_LED_MODE1; +#endif + break; + } + RT_TRACE(COMP_INIT, "LedStrategy = %d \n", priv->LedStrategy); +#endif + + if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) + priv->rtllib->bSupportRemoteWakeUp = true; + else + priv->rtllib->bSupportRemoteWakeUp = false; + + RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); + RT_TRACE(COMP_INIT, "ChannelPlan = %d \n", priv->ChannelPlan); + RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); + + return ; +} + +void rtl8192_get_eeprom_size(struct net_device* dev) +{ + u16 curCR = 0; + struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); + curCR = read_nic_dword(dev, EPROM_CMD); + RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); + priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : EEPROM_93C46; + RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); + rtl8192_read_eeprom_info(dev); +} + +static void rtl8192_hwconfig(struct net_device* dev) +{ + u32 regRATR = 0, regRRSR = 0; + u8 regBwOpMode = 0, regTmp = 0; + struct r8192_priv *priv = rtllib_priv(dev); + + switch (priv->rtllib->mode) + { + case WIRELESS_MODE_B: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK; + regRRSR = RATE_ALL_CCK; + break; + case WIRELESS_MODE_A: + regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regRATR = RATE_ALL_OFDM_AG; + regRRSR = RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_G: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_AUTO: + case WIRELESS_MODE_N_24G: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + break; + case WIRELESS_MODE_N_5G: + regBwOpMode = BW_OPMODE_5G; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRRSR = RATE_ALL_OFDM_AG; + break; + default: + regBwOpMode = BW_OPMODE_20MHZ; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + break; + } + + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + { + u32 ratr_value = 0; + ratr_value = regRATR; + if (priv->rf_type == RF_1T2R) + { + ratr_value &= ~(RATE_ALL_OFDM_2SS); + } + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + } + regTmp = read_nic_byte(dev, 0x313); + regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); + write_nic_dword(dev, RRSR, regRRSR); + + write_nic_word(dev, RETRY_LIMIT, + priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \ + priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); + + + +} + +bool rtl8192_adapter_start(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 ulRegRead; + bool rtStatus = true; + u8 tmpvalue; +#ifdef RTL8192E + u8 ICVersion,SwitchingRegulatorOutput; +#endif + bool bfirmwareok = true; +#ifdef RTL8190P + u8 ucRegRead; +#endif + u32 tmpRegA, tmpRegC, TempCCk; + int i = 0; + u32 retry_times = 0; + + RT_TRACE(COMP_INIT, "====>%s()\n", __func__); + priv->being_init_adapter = true; + +#ifdef CONFIG_ASPM_OR_D3 + RT_DISABLE_ASPM(dev); +#endif + +start: + rtl8192_pci_resetdescring(dev); + priv->Rf_Mode = RF_OP_By_SW_3wire; +#ifdef RTL8192E + if (priv->ResetProgress == RESET_TYPE_NORESET) + { + write_nic_byte(dev, ANAPAR, 0x37); + mdelay(500); + } +#endif + priv->pFirmware->firmware_status = FW_STATUS_0_INIT; + + if (priv->RegRfOff == true) + priv->rtllib->eRFPowerState = eRfOff; + + ulRegRead = read_nic_dword(dev, CPU_GEN); + if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) + { + ulRegRead |= CPU_GEN_SYSTEM_RESET; + }else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) + ulRegRead |= CPU_GEN_FIRMWARE_RESET; + else + RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); + +#ifdef RTL8190P + ulRegRead &= (~(CPU_GEN_GPIO_UART)); +#endif + + write_nic_dword(dev, CPU_GEN, ulRegRead); + +#ifdef RTL8192E + + ICVersion = read_nic_byte(dev, IC_VERRSION); + if (ICVersion >= 0x4) + { + SwitchingRegulatorOutput = read_nic_byte(dev, SWREGULATOR); + if (SwitchingRegulatorOutput != 0xb8) + { + write_nic_byte(dev, SWREGULATOR, 0xa8); + mdelay(1); + write_nic_byte(dev, SWREGULATOR, 0xb8); + } + } +#endif + RT_TRACE(COMP_INIT, "BB Config Start!\n"); + rtStatus = rtl8192_BBConfig(dev); + if (rtStatus != true) + { + RT_TRACE(COMP_ERR, "BB Config failed\n"); + return rtStatus; + } + RT_TRACE(COMP_INIT,"BB Config Finished!\n"); + + priv->LoopbackMode = RTL819X_NO_LOOPBACK; + if (priv->ResetProgress == RESET_TYPE_NORESET) + { + ulRegRead = read_nic_dword(dev, CPU_GEN); + if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) + { + ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); + } + else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) + { + ulRegRead |= CPU_CCK_LOOPBACK; + } + else + { + RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); + } + + write_nic_dword(dev, CPU_GEN, ulRegRead); + + udelay(500); + } + rtl8192_hwconfig(dev); + write_nic_byte(dev, CMDR, CR_RE|CR_TE); + +#ifdef RTL8190P + write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); + write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); + write_nic_dword(dev, RCR, priv->ReceiveConfig); + +#ifdef TO_DO_LIST + if (priv->bInHctTest) + { + write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\ + NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \ + NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \ + NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM <ResetProgress == RESET_TYPE_NORESET) + rtl8192_SetWirelessMode(dev, priv->rtllib->mode); + CamResetAllEntry(dev); + { + u8 SECR_value = 0x0; + SECR_value |= SCR_TxEncEnable; + SECR_value |= SCR_RxDecEnable; + SECR_value |= SCR_NoSKMC; + write_nic_byte(dev, SECR, SECR_value); + } + write_nic_word(dev, ATIMWND, 2); + write_nic_word(dev, BCN_INTERVAL, 100); + { + int i; + for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { + rtl8192_phy_getTxPower(dev); + rtl8192_phy_setTxPower(dev, priv->chan); + } + + tmpvalue = read_nic_byte(dev, IC_VERRSION); + priv->IC_Cut= tmpvalue; + RT_TRACE(COMP_INIT, "priv->IC_Cut= 0x%x\n", priv->IC_Cut); + if (priv->IC_Cut>= IC_VersionCut_D) + { + if (priv->IC_Cut== IC_VersionCut_D) { + RT_TRACE(COMP_INIT, "D-cut\n"); + } else if (priv->IC_Cut== IC_VersionCut_E) { + RT_TRACE(COMP_INIT, "E-cut\n"); + } + } else { + RT_TRACE(COMP_INIT, "Before C-cut\n"); + } + + RT_TRACE(COMP_INIT, "Load Firmware!\n"); + bfirmwareok = init_firmware(dev); + if (!bfirmwareok) { + if (retry_times < 10) { + retry_times++; + goto start; + } else { + rtStatus = false; + goto end; + } + } + RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); + if (priv->ResetProgress == RESET_TYPE_NORESET) { + RT_TRACE(COMP_INIT, "RF Config Started!\n"); + rtStatus = rtl8192_phy_RFConfig(dev); + if (rtStatus != true) { + RT_TRACE(COMP_ERR, "RF Config failed\n"); + return rtStatus; + } + RT_TRACE(COMP_INIT, "RF Config Finished!\n"); + } + rtl8192_phy_updateInitGain(dev); + + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1); + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1); + +#ifdef RTL8192E + write_nic_byte(dev, 0x87, 0x0); +#endif +#ifdef RTL8190P + ucRegRead = read_nic_byte(dev, GPE); + ucRegRead |= BIT0; + write_nic_byte(dev, GPE, ucRegRead); + + ucRegRead = read_nic_byte(dev, GPO); + ucRegRead &= ~BIT0; + write_nic_byte(dev, GPO, ucRegRead); +#endif + + if (priv->RegRfOff == true) { + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW,true); + } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) { + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) { + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + } else { + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__func__); + priv->rtllib->eRFPowerState = eRfOn; + priv->rtllib->RfOffReason = 0; + + + } + + if (priv->rtllib->FwRWRF) + priv->Rf_Mode = RF_OP_By_FW; + else + priv->Rf_Mode = RF_OP_By_SW_3wire; + + if (priv->ResetProgress == RESET_TYPE_NORESET) + { + dm_initialize_txpower_tracking(dev); + + if (priv->IC_Cut>= IC_VersionCut_D) { + tmpRegA= rtl8192_QueryBBReg(dev,rOFDM0_XATxIQImbalance,bMaskDWord); + tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord); + for (i = 0; itxbbgain_table[i].txbbgain_value) { + priv->rfa_txpowertrackingindex= (u8)i; + priv->rfa_txpowertrackingindex_real= (u8)i; + priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + break; + } + } + + TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + + for (i = 0; i < CCKTxBBGainTableLength; i++) { + if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { + priv->CCKPresentAttentuation_20Mdefault =(u8) i; + break; + } + } + priv->CCKPresentAttentuation_40Mdefault = 0; + priv->CCKPresentAttentuation_difference = 0; + priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); + priv->btxpower_tracking = false; + } + } + rtl8192_irq_enable(dev); +end: + priv->being_init_adapter = false; + return rtStatus; +} + +void rtl8192_net_update(struct net_device *dev) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net; + u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; + u16 rate_config = 0; + + net = &priv->rtllib->current_network; + rtl8192_config_rate(dev, &rate_config); + priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; + priv->basic_rate = rate_config &= 0x15f; + write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]); + write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]); + + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + write_nic_word(dev, ATIMWND, 2); + write_nic_word(dev, BCN_DMATIME, 256); + write_nic_word(dev, BCN_INTERVAL, net->beacon_interval); + write_nic_word(dev, BCN_DRV_EARLY_INT, 10); + write_nic_byte(dev, BCN_ERR_THRESH, 100); + + BcnTimeCfg |= (BcnCW<rtllib; + + if (!priv->up) + return; + + if (ieee->state == RTLLIB_LINKED) { + rtl8192_net_update(dev); + priv->ops->update_ratr_table(dev); + if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + EnableHWSecurityConfig8192(dev); + } else { + write_nic_byte(dev, 0x173, 0); + } + rtl8192e_update_msr(dev); + + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { + u32 reg = 0; + reg = read_nic_dword(dev, RCR); + if (priv->rtllib->state == RTLLIB_LINKED) { + if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn) + ; + else + priv->ReceiveConfig = reg |= RCR_CBSSID; + } else + priv->ReceiveConfig = reg &= ~RCR_CBSSID; + + write_nic_dword(dev, RCR, reg); + } +} + +void rtl8192_AllowAllDestAddr(struct net_device* dev, + bool bAllowAllDA, bool WriteIntoReg) +{ + struct r8192_priv* priv = rtllib_priv(dev); + + if (bAllowAllDA) + priv->ReceiveConfig |= RCR_AAP; + else + priv->ReceiveConfig &= ~RCR_AAP; + + if (WriteIntoReg) + write_nic_dword( dev, RCR, priv->ReceiveConfig ); +} + + +static u8 MRateToHwRate8190Pci(u8 rate) +{ + u8 ret = DESC90_RATE1M; + + switch (rate) { + case MGN_1M: + ret = DESC90_RATE1M; + break; + case MGN_2M: + ret = DESC90_RATE2M; + break; + case MGN_5_5M: + ret = DESC90_RATE5_5M; + break; + case MGN_11M: + ret = DESC90_RATE11M; + break; + case MGN_6M: + ret = DESC90_RATE6M; + break; + case MGN_9M: + ret = DESC90_RATE9M; + break; + case MGN_12M: + ret = DESC90_RATE12M; + break; + case MGN_18M: + ret = DESC90_RATE18M; + break; + case MGN_24M: + ret = DESC90_RATE24M; + break; + case MGN_36M: + ret = DESC90_RATE36M; + break; + case MGN_48M: + ret = DESC90_RATE48M; + break; + case MGN_54M: + ret = DESC90_RATE54M; + break; + case MGN_MCS0: + ret = DESC90_RATEMCS0; + break; + case MGN_MCS1: + ret = DESC90_RATEMCS1; + break; + case MGN_MCS2: + ret = DESC90_RATEMCS2; + break; + case MGN_MCS3: + ret = DESC90_RATEMCS3; + break; + case MGN_MCS4: + ret = DESC90_RATEMCS4; + break; + case MGN_MCS5: + ret = DESC90_RATEMCS5; + break; + case MGN_MCS6: + ret = DESC90_RATEMCS6; + break; + case MGN_MCS7: + ret = DESC90_RATEMCS7; + break; + case MGN_MCS8: + ret = DESC90_RATEMCS8; + break; + case MGN_MCS9: + ret = DESC90_RATEMCS9; + break; + case MGN_MCS10: + ret = DESC90_RATEMCS10; + break; + case MGN_MCS11: + ret = DESC90_RATEMCS11; + break; + case MGN_MCS12: + ret = DESC90_RATEMCS12; + break; + case MGN_MCS13: + ret = DESC90_RATEMCS13; + break; + case MGN_MCS14: + ret = DESC90_RATEMCS14; + break; + case MGN_MCS15: + ret = DESC90_RATEMCS15; + break; + case (0x80|0x20): + ret = DESC90_RATEMCS32; + break; + default: + break; + } + return ret; +} + +u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) +{ + u8 QueueSelect = 0x0; + + switch (QueueID) { + case BE_QUEUE: + QueueSelect = QSLT_BE; + break; + + case BK_QUEUE: + QueueSelect = QSLT_BK; + break; + + case VO_QUEUE: + QueueSelect = QSLT_VO; + break; + + case VI_QUEUE: + QueueSelect = QSLT_VI; + break; + case MGNT_QUEUE: + QueueSelect = QSLT_MGNT; + break; + case BEACON_QUEUE: + QueueSelect = QSLT_BEACON; + break; + case TXCMD_QUEUE: + QueueSelect = QSLT_CMD; + break; + case HIGH_QUEUE: + QueueSelect = QSLT_HIGH; + break; + default: + RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection:" + " %d \n", QueueID); + break; + } + return QueueSelect; +} + + +void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb) +{ + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + TX_FWINFO_8190PCI *pTxFwInfo = NULL; + pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; + memset(pTxFwInfo,0,sizeof(TX_FWINFO_8190PCI)); + pTxFwInfo->TxHT = (cb_desc->data_rate&0x80)?1:0; + pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); + pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; + pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, cb_desc); + + if (cb_desc->bAMPDUEnable) { + pTxFwInfo->AllowAggregation = 1; + pTxFwInfo->RxMF = cb_desc->ampdu_factor; + pTxFwInfo->RxAMD = cb_desc->ampdu_density; + } else { + pTxFwInfo->AllowAggregation = 0; + pTxFwInfo->RxMF = 0; + pTxFwInfo->RxAMD = 0; + } + + pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable)?1:0; + pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable)?1:0; + pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC)?1:0; + pTxFwInfo->RtsHT= (cb_desc->rts_rate&0x80)?1:0; + pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); + pTxFwInfo->RtsBandwidth = 0; + pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; + pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT==0)?(cb_desc->bRTSUseShortPreamble?1:0):(cb_desc->bRTSUseShortGI?1:0); + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) + { + if (cb_desc->bPacketBW) + { + pTxFwInfo->TxBandwidth = 1; +#ifdef RTL8190P + pTxFwInfo->TxSubCarrier = 3; +#else + pTxFwInfo->TxSubCarrier = 0; +#endif + } + else + { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + } + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = 0; + } + + memset((u8*)pdesc,0,12); + pdesc->LINIP = 0; + pdesc->CmdInit = 1; + pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; + pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); + + pdesc->SecCAMID= 0; + pdesc->RATid = cb_desc->RATRIndex; + + + pdesc->NoEnc = 1; + pdesc->SecType = 0x0; + if (cb_desc->bHwSec) { + static u8 tmp =0; + if (!tmp) { + RT_TRACE(COMP_DBG, "==>================hw sec\n"); + tmp = 1; + } + switch (priv->rtllib->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + pdesc->SecType = 0x1; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_TKIP: + pdesc->SecType = 0x2; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_CCMP: + pdesc->SecType = 0x3; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_NA: + pdesc->SecType = 0x0; + pdesc->NoEnc = 1; + break; + } + } + + pdesc->PktId = 0x0; + + pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(cb_desc->queue_index, cb_desc->priority); + pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); + + pdesc->DISFB = cb_desc->bTxDisableRateFallBack; + pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; + + pdesc->FirstSeg =1; + pdesc->LastSeg = 1; + pdesc->TxBufferSize = skb->len; + + pdesc->TxBuffAddr = cpu_to_le32(mapping); +} + +void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, + cb_desc * cb_desc, struct sk_buff* skb) +{ + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + + memset(entry,0,12); + entry->LINIP = cb_desc->bLastIniPkt; + entry->FirstSeg = 1; + entry->LastSeg = 1; + if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { + entry->CmdInit = DESC_PACKET_TYPE_INIT; + } else { + tx_desc* entry_tmp = (tx_desc*)entry; + entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; + entry_tmp->Offset = sizeof(TX_FWINFO_8190PCI) + 8; + entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); + entry_tmp->QueueSelect = QSLT_CMD; + entry_tmp->TxFWInfoSize = 0x08; + entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; + } + entry->TxBufferSize = skb->len; + entry->TxBuffAddr = cpu_to_le32(mapping); + entry->OWN = 1; +} + +u8 HwRateToMRate90(bool bIsHT, u8 rate) +{ + u8 ret_rate = 0x02; + + if (!bIsHT) { + switch (rate) { + case DESC90_RATE1M: ret_rate = MGN_1M; break; + case DESC90_RATE2M: ret_rate = MGN_2M; break; + case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; + case DESC90_RATE11M: ret_rate = MGN_11M; break; + case DESC90_RATE6M: ret_rate = MGN_6M; break; + case DESC90_RATE9M: ret_rate = MGN_9M; break; + case DESC90_RATE12M: ret_rate = MGN_12M; break; + case DESC90_RATE18M: ret_rate = MGN_18M; break; + case DESC90_RATE24M: ret_rate = MGN_24M; break; + case DESC90_RATE36M: ret_rate = MGN_36M; break; + case DESC90_RATE48M: ret_rate = MGN_48M; break; + case DESC90_RATE54M: ret_rate = MGN_54M; break; + + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; + } + + } else { + switch (rate) { + case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; + case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; + case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; + case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; + case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; + case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; + case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; + case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; + case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; + case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; + case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; + case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; + case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; + case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; + case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; + case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; + case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); + break; + } + } + + return ret_rate; +} + +long +rtl8192_signal_scale_mapping(struct r8192_priv * priv, + long currsig + ) +{ + long retsig; + +#if defined RTL8192SE || defined RTL8192CE + if (priv->CustomerID == RT_CID_819x_Lenovo) + { + return currsig; + } + else if (priv->CustomerID == RT_CID_819x_Netcore) + { + if (currsig >= 31 && currsig <= 100) + { + retsig = 100; + } + else if (currsig >= 21 && currsig <= 30) + { + retsig = 90 + ((currsig - 20) / 1); + } + else if (currsig >= 11 && currsig <= 20) + { + retsig = 80 + ((currsig - 10) / 1); + } + else if (currsig >= 7 && currsig <= 10) + { + retsig = 69 + (currsig - 7); + } + else if (currsig == 6) + { + retsig = 54; + } + else if (currsig == 5) + { + retsig = 45; + } + else if (currsig == 4) + { + retsig = 36; + } + else if (currsig == 3) + { + retsig = 27; + } + else if (currsig == 2) + { + retsig = 18; + } + else if (currsig == 1) + { + retsig = 9; + } + else + { + retsig = currsig; + } + return retsig; + } +#endif + + if (currsig >= 61 && currsig <= 100) + { + retsig = 90 + ((currsig - 60) / 4); + } + else if (currsig >= 41 && currsig <= 60) + { + retsig = 78 + ((currsig - 40) / 2); + } + else if (currsig >= 31 && currsig <= 40) + { + retsig = 66 + (currsig - 30); + } + else if (currsig >= 21 && currsig <= 30) + { + retsig = 54 + (currsig - 20); + } + else if (currsig >= 5 && currsig <= 20) + { + retsig = 42 + (((currsig - 5) * 2) / 3); + } + else if (currsig == 4) + { + retsig = 36; + } + else if (currsig == 3) + { + retsig = 27; + } + else if (currsig == 2) + { + retsig = 18; + } + else if (currsig == 1) + { + retsig = 9; + } + else + { + retsig = currsig; + } + + return retsig; +} + + +#define rx_hal_is_cck_rate(_pdrvinfo)\ + (_pdrvinfo->RxRate == DESC90_RATE1M ||\ + _pdrvinfo->RxRate == DESC90_RATE2M ||\ + _pdrvinfo->RxRate == DESC90_RATE5_5M ||\ + _pdrvinfo->RxRate == DESC90_RATE11M) &&\ + !_pdrvinfo->RxHT +void rtl8192_query_rxphystatus( + struct r8192_priv * priv, + struct rtllib_rx_stats * pstats, + prx_desc pdesc, + prx_fwinfo pdrvinfo, + struct rtllib_rx_stats * precord_stats, + bool bpacket_match_bssid, + bool bpacket_toself, + bool bPacketBeacon, + bool bToSelfBA + ) +{ + phy_sts_ofdm_819xpci_t* pofdm_buf; + phy_sts_cck_819xpci_t * pcck_buf; + phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; + u8 *prxpkt; + u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all=0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi=0; + u8 is_cck_rate=0; + u8 rf_rx_num = 0; + + static u8 check_reg824 = 0; + static u32 reg824_bit9 = 0; + + priv->stats.numqry_phystatus++; + + + is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); + memset(precord_stats, 0, sizeof(struct rtllib_rx_stats)); + pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; + pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate; + pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; + pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; + if (check_reg824 == 0) + { + reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, rFPGA0_XA_HSSIParameter2, 0x200); + check_reg824 = 1; + } + + + prxpkt = (u8*)pdrvinfo; + + prxpkt += sizeof(rx_fwinfo); + + pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; + pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; + + pstats->RxMIMOSignalQuality[0] = -1; + pstats->RxMIMOSignalQuality[1] = -1; + precord_stats->RxMIMOSignalQuality[0] = -1; + precord_stats->RxMIMOSignalQuality[1] = -1; + + if (is_cck_rate) + { + + u8 report; +#ifdef RTL8190P + u8 tmp_pwdb; + char cck_adc_pwdb[4]; +#endif + priv->stats.numqry_phystatusCCK++; + +#ifdef RTL8190P + if (priv->rf_type == RF_2T4R && DM_RxPathSelTable.Enable && bpacket_match_bssid) + { + for (i=RF90_PATH_A; iadc_pwdb_X[i]; + cck_adc_pwdb[i] = (char)tmp_pwdb; + cck_adc_pwdb[i] /= 2; + pstats->cck_adc_pwdb[i] = precord_stats->cck_adc_pwdb[i] = cck_adc_pwdb[i]; + } + } +#endif + + if (!reg824_bit9) + { + report = pcck_buf->cck_agc_rpt & 0xc0; + report = report>>6; + switch (report) + { + case 0x3: + rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x2: + rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x1: + rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + case 0x0: + rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); + break; + } + } + else + { + report = pcck_buf->cck_agc_rpt & 0x60; + report = report>>5; + switch (report) + { + case 0x3: + rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x2: + rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + break; + case 0x1: + rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x0: + rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; + break; + } + } + + pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); + pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; + pstats->RecvSignalPower = rx_pwr_all; + + if (bpacket_match_bssid) + { + u8 sq; + + if (pstats->RxPWDBAll > 40) + { + sq = 100; + }else + { + sq = pcck_buf->sq_rpt; + + if (pcck_buf->sq_rpt > 64) + sq = 0; + else if (pcck_buf->sq_rpt < 20) + sq = 100; + else + sq = ((64-sq) * 100) / 44; + } + pstats->SignalQuality = precord_stats->SignalQuality = sq; + pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + } + } + else + { + priv->stats.numqry_phystatusHT++; + for (i=RF90_PATH_A; ibrfpath_rxenable[i]) + rf_rx_num++; + +#ifdef RTL8190P + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106; +#else + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; +#endif + + tmp_rxsnr = pofdm_buf->rxsnr_X[i]; + rx_snrX = (char)(tmp_rxsnr); + rx_snrX /= 2; + priv->stats.rxSNRdB[i] = (long)rx_snrX; + + RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); + if (priv->brfpath_rxenable[i]) + total_rssi += RSSI; + + if (bpacket_match_bssid) + { + pstats->RxMIMOSignalStrength[i] =(u8) RSSI; + precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; + } + } + + + rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; + pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); + + pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; + pstats->RxPower = precord_stats->RxPower = rx_pwr_all; + pstats->RecvSignalPower = rx_pwr_all; + if (pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && + pdrvinfo->RxRate<=DESC90_RATEMCS15) + max_spatial_stream = 2; + else + max_spatial_stream = 1; + + for (i=0; irxevm_X[i]; + rx_evmX = (char)(tmp_rxevm); + + rx_evmX /= 2; + + evm = rtl819x_evm_dbtopercentage(rx_evmX); + if (bpacket_match_bssid) + { + if (i==0) + pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); + pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + } + } + + + rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; + prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + if (pdrvinfo->BW) + priv->stats.received_bwtype[1+prxsc->rxsc]++; + else + priv->stats.received_bwtype[0]++; + } + + if (is_cck_rate) + { + pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)pwdb_all)); + + } + else + { + if (rf_rx_num != 0) + pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)(total_rssi/=rf_rx_num))); + } +} + +void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) +{ + bool bcheck = false; + u8 rfpath; + u32 nspatial_stream, tmp_val; + static u32 slide_rssi_index=0, slide_rssi_statistics=0; + static u32 slide_evm_index=0, slide_evm_statistics=0; + static u32 last_rssi=0, last_evm=0; + static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; + static u32 last_beacon_adc_pwdb=0; + + struct rtllib_hdr_3addr *hdr; + u16 sc ; + unsigned int frag,seq; + hdr = (struct rtllib_hdr_3addr *)buffer; + sc = le16_to_cpu(hdr->seq_ctl); + frag = WLAN_GET_SEQ_FRAG(sc); + seq = WLAN_GET_SEQ_SEQ(sc); + pcurrent_stats->Seq_Num = seq; + if (!pprevious_stats->bIsAMPDU) + bcheck = true; + + if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) + { + slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; + last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; + priv->stats.slide_rssi_total -= last_rssi; + } + priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; + + priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) + slide_rssi_index = 0; + + tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; + priv->stats.signal_strength = rtl819x_translate_todbm(priv, (u8)tmp_val); + pcurrent_stats->rssi = priv->stats.signal_strength; + if (!pprevious_stats->bPacketMatchBSSID) + { + if (!pprevious_stats->bToSelfBA) + return; + } + + if (!bcheck) + return; + + rtl819x_process_cck_rxpathsel(priv,pprevious_stats); + + priv->stats.num_process_phyinfo++; + if (!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) + { + for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) + { + if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, rfpath)) + continue; + RT_TRACE(COMP_DBG,"Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath] = %d \n" ,pprevious_stats->RxMIMOSignalStrength[rfpath] ); + if (priv->stats.rx_rssi_percentage[rfpath] == 0) + { + priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; + } + if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) + { + priv->stats.rx_rssi_percentage[rfpath] = + ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; + } + else + { + priv->stats.rx_rssi_percentage[rfpath] = + ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + } + RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); + } + } + + + if (pprevious_stats->bPacketBeacon) + { + if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) + { + slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; + last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; + priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; + } + priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; + priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; + slide_beacon_adc_pwdb_index++; + if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) + slide_beacon_adc_pwdb_index = 0; + pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; + if (pprevious_stats->RxPWDBAll >= 3) + pprevious_stats->RxPWDBAll -= 3; + } + + RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", + pprevious_stats->bIsCCK? "CCK": "OFDM", + pprevious_stats->RxPWDBAll); + + if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) + { + if (priv->undecorated_smoothed_pwdb < 0) + { + priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; + } + if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) + { + priv->undecorated_smoothed_pwdb = + ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; + } + else + { + priv->undecorated_smoothed_pwdb = + ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + + (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + } + rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); + } + + if (pprevious_stats->SignalQuality == 0) + { + } + else + { + if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ + if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ + slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; + last_evm = priv->stats.slide_evm[slide_evm_index]; + priv->stats.slide_evm_total -= last_evm; + } + + priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + + priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) + slide_evm_index = 0; + + tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + priv->stats.signal_quality = tmp_val; + priv->stats.last_signal_strength_inpercent = tmp_val; + } + + if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) + { + for (nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) + { + if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) + { + if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) + { + priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; + } + priv->stats.rx_evm_percentage[nspatial_stream] = + ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + } + } + } + } + +} + + +void rtl8192_TranslateRxSignalStuff(struct net_device *dev, + struct sk_buff *skb, + struct rtllib_rx_stats * pstats, + prx_desc pdesc, + prx_fwinfo pdrvinfo) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + bool bpacket_match_bssid, bpacket_toself; + bool bPacketBeacon=false; + struct rtllib_hdr_3addr *hdr; + bool bToSelfBA=false; + static struct rtllib_rx_stats previous_stats; + u16 fc,type; + + + u8* tmp_buf; + u8 *praddr; + + tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; + + hdr = (struct rtllib_hdr_3addr *)tmp_buf; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + + bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && + (!compare_ether_addr(priv->rtllib->current_network.bssid, + (fc & RTLLIB_FCTL_TODS)? hdr->addr1 : + (fc & RTLLIB_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) + && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); + bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); + if (WLAN_FC_GET_FRAMETYPE(fc)== RTLLIB_STYPE_BEACON) + { + bPacketBeacon = true; + } + if (bpacket_match_bssid) + { + priv->stats.numpacket_matchbssid++; + } + if (bpacket_toself){ + priv->stats.numpacket_toself++; + } + rtl8192_process_phyinfo(priv, tmp_buf,&previous_stats, pstats); + rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &previous_stats, bpacket_match_bssid, + bpacket_toself ,bPacketBeacon, bToSelfBA); + rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); +} + +void rtl8192_UpdateReceivedRateHistogramStatistics( + struct net_device *dev, + struct rtllib_rx_stats* pstats + ) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 rcvType=1; + u32 rateIndex; + u32 preamble_guardinterval; + + if (pstats->bCRC) + rcvType = 2; + else if (pstats->bICV) + rcvType = 3; + + if (pstats->bShortPreamble) + preamble_guardinterval = 1; + else + preamble_guardinterval = 0; + + switch (pstats->rate) + { + case MGN_1M: rateIndex = 0; break; + case MGN_2M: rateIndex = 1; break; + case MGN_5_5M: rateIndex = 2; break; + case MGN_11M: rateIndex = 3; break; + case MGN_6M: rateIndex = 4; break; + case MGN_9M: rateIndex = 5; break; + case MGN_12M: rateIndex = 6; break; + case MGN_18M: rateIndex = 7; break; + case MGN_24M: rateIndex = 8; break; + case MGN_36M: rateIndex = 9; break; + case MGN_48M: rateIndex = 10; break; + case MGN_54M: rateIndex = 11; break; + case MGN_MCS0: rateIndex = 12; break; + case MGN_MCS1: rateIndex = 13; break; + case MGN_MCS2: rateIndex = 14; break; + case MGN_MCS3: rateIndex = 15; break; + case MGN_MCS4: rateIndex = 16; break; + case MGN_MCS5: rateIndex = 17; break; + case MGN_MCS6: rateIndex = 18; break; + case MGN_MCS7: rateIndex = 19; break; + case MGN_MCS8: rateIndex = 20; break; + case MGN_MCS9: rateIndex = 21; break; + case MGN_MCS10: rateIndex = 22; break; + case MGN_MCS11: rateIndex = 23; break; + case MGN_MCS12: rateIndex = 24; break; + case MGN_MCS13: rateIndex = 25; break; + case MGN_MCS14: rateIndex = 26; break; + case MGN_MCS15: rateIndex = 27; break; + default: rateIndex = 28; break; + } + priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; + priv->stats.received_rate_histogram[0][rateIndex]++; + priv->stats.received_rate_histogram[rcvType][rateIndex]++; +} + +bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats* stats, + rx_desc *pdesc, struct sk_buff* skb) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + stats->bICV = pdesc->ICV; + stats->bCRC = pdesc->CRC32; + stats->bHwError = pdesc->CRC32 | pdesc->ICV; + + stats->Length = pdesc->Length; + if (stats->Length < 24) + stats->bHwError |= 1; + + if (stats->bHwError) { + stats->bShift = false; + + if (pdesc->CRC32) { + if (pdesc->Length <500) + priv->stats.rxcrcerrmin++; + else if (pdesc->Length >1000) + priv->stats.rxcrcerrmax++; + else + priv->stats.rxcrcerrmid++; + } + return false; + } else { + prx_fwinfo pDrvInfo = NULL; + stats->RxDrvInfoSize = pdesc->RxDrvInfoSize; + stats->RxBufShift = ((pdesc->Shift)&0x03); + stats->Decrypted = !pdesc->SWDec; + + pDrvInfo = (rx_fwinfo *)(skb->data + stats->RxBufShift); + + stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); + stats->bShortPreamble = pDrvInfo->SPLCP; + + rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats); + + stats->bIsAMPDU = (pDrvInfo->PartAggr==1); + stats->bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); + + stats->TimeStampLow = pDrvInfo->TSFL; + stats->TimeStampHigh = read_nic_dword(dev, TSFR+4); + + rtl819x_UpdateRxPktTimeStamp(dev, stats); + + if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0) + stats->bShift = 1; + + stats->RxIs40MHzPacket = pDrvInfo->BW; + + rtl8192_TranslateRxSignalStuff(dev,skb, stats, pdesc, pDrvInfo); + + if (pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) + RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", + pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); + skb_trim(skb, skb->len - 4/*sCrcLng*/); + + + stats->packetlength = stats->Length-4; + stats->fraglength = stats->packetlength; + stats->fragoffset = 0; + stats->ntotalfrag = 1; + return true; + } +} + +void rtl8192_halt_adapter(struct net_device *dev, bool reset) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int i; + u8 OpMode; + u8 u1bTmp; + u32 ulRegRead; +#ifdef RTL8190P + u8 ucRegRead; +#endif + + OpMode = RT_OP_MODE_NO_LINK; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode); + +#if 1 + if (!priv->rtllib->bSupportRemoteWakeUp) + { + u1bTmp = 0x0; + write_nic_byte(dev, CMDR, u1bTmp); + } +#else + cmd=read_nic_byte(dev,CMDR); + write_nic_byte(dev, CMDR, cmd &~ (CR_TE|CR_RE)); +#endif + + mdelay(20); + + if (!reset) + { + mdelay(150); + +#ifdef RTL8192E + priv->bHwRfOffAction = 2; +#endif + + if (!priv->rtllib->bSupportRemoteWakeUp) + { +#ifdef RTL8190P + { + PHY_SetRtl8190pRfOff(dev); + } +#elif defined RTL8192E + { + PHY_SetRtl8192eRfOff(dev); + } +#endif + ulRegRead = read_nic_dword(dev,CPU_GEN); + ulRegRead|=CPU_GEN_SYSTEM_RESET; + write_nic_dword(dev,CPU_GEN, ulRegRead); + } + else + { + write_nic_dword(dev, WFCRC0, 0xffffffff); + write_nic_dword(dev, WFCRC1, 0xffffffff); + write_nic_dword(dev, WFCRC2, 0xffffffff); + + +#ifdef RTL8190P + { + ucRegRead = read_nic_byte(dev, GPO); + ucRegRead |= BIT0; + write_nic_byte(dev, GPO, ucRegRead); + } +#endif + write_nic_byte(dev, PMR, 0x5); + write_nic_byte(dev, MacBlkCtrl, 0xa); + } + } + + for (i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_purge(&priv->rtllib->skb_waitQ [i]); + } + for (i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_purge(&priv->rtllib->skb_aggQ [i]); + } + + skb_queue_purge(&priv->skb_queue); + return; +} + +void rtl8192_update_ratr_table(struct net_device* dev) +{ + struct r8192_priv* priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + u8* pMcsRate = ieee->dot11HTOperationalRateSet; + u32 ratr_value = 0; + u8 rate_index = 0; + + rtl8192_config_rate(dev, (u16*)(&ratr_value)); + ratr_value |= (*(u16*)(pMcsRate)) << 12; + switch (ieee->mode) + { + case IEEE_A: + ratr_value &= 0x00000FF0; + break; + case IEEE_B: + ratr_value &= 0x0000000F; + break; + case IEEE_G: + case IEEE_G|IEEE_B: + ratr_value &= 0x00000FF7; + break; + case IEEE_N_24G: + case IEEE_N_5G: + if (ieee->pHTInfo->PeerMimoPs == 0) + ratr_value &= 0x0007F007; + else{ + if (priv->rf_type == RF_1T2R) + ratr_value &= 0x000FF007; + else + ratr_value &= 0x0F81F007; + } + break; + default: + break; + } + ratr_value &= 0x0FFFFFFF; + if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ + ratr_value |= 0x80000000; + }else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ + ratr_value |= 0x80000000; + } + write_nic_dword(dev, RATR0+rate_index*4, ratr_value); + write_nic_byte(dev, UFWP, 1); +} + +void +rtl8192_InitializeVariables(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + +#ifdef RTL8190P + strcpy(priv->nick, "rtl8190p"); +#elif defined(RTL8192E) + strcpy(priv->nick, "rtl8192E"); +#endif + +#ifdef _ENABLE_SW_BEACON + priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | + IEEE_SOFTMAC_BEACONS; +#else + priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE /* | + IEEE_SOFTMAC_BEACONS*/; +#endif + + priv->rtllib->tx_headroom = sizeof(TX_FWINFO_8190PCI); + + priv->ShortRetryLimit = 0x30; + priv->LongRetryLimit = 0x30; + + priv->EarlyRxThreshold = 7; + priv->pwrGroupCnt = 0; + + priv->bIgnoreSilentReset = false; + priv->enable_gpio0 = 0; + + priv->TransmitConfig = 0; + + priv->ReceiveConfig = RCR_ADD3 | + RCR_AMF | RCR_ADF | + RCR_AICV | + RCR_AB | RCR_AM | RCR_APM | + RCR_AAP | ((u32)7<irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |\ + IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |\ + IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |\ + IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + + + priv->MidHighPwrTHR_L1 = 0x3B; + priv->MidHighPwrTHR_L2 = 0x40; + priv->PwrDomainProtect = false; + + priv->bfirst_after_down = 0; +} + +void rtl8192_EnableInterrupt(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->irq_enabled = 1; + +#ifdef RTL8192CE + write_nic_dword(dev, REG_HIMR, priv->irq_mask[0]&0xFFFFFFFF); +#else + write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); +#endif + +#ifdef RTL8192SE + write_nic_dword(dev,INTA_MASK+4, priv->irq_mask[1]&0x3F); +#endif + +} + +void rtl8192_DisableInterrupt(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + +#ifdef RTL8192CE + write_nic_dword(dev, REG_HIMR, IMR8190_DISABLED); +#else + write_nic_dword(dev,INTA_MASK,0); +#endif + +#ifdef RTL8192SE + write_nic_dword(dev,INTA_MASK + 4,0); +#endif + priv->irq_enabled = 0; +} + +void rtl8192_ClearInterrupt(struct net_device *dev) +{ + u32 tmp = 0; +#ifdef RTL8192CE + tmp = read_nic_dword(dev, REG_HISR); + write_nic_dword(dev, REG_HISR, tmp); +#else + tmp = read_nic_dword(dev, ISR); + write_nic_dword(dev, ISR, tmp); +#endif + +#ifdef RTL8192SE + tmp = read_nic_dword(dev, ISR+4); + write_nic_dword(dev, ISR+4, tmp); +#endif +} + + +void rtl8192_enable_rx(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + write_nic_dword(dev, RDQDA,priv->rx_ring_dma[RX_MPDU_QUEUE]); +} + +u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +void rtl8192_enable_tx(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 i; + + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); +} + + +void rtl8192_beacon_disable(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 reg; + +#ifdef RTL8192CE + reg = read_nic_dword(priv->rtllib->dev,REG_HIMR); + + reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + write_nic_dword(priv->rtllib->dev, REG_HIMR, reg); +#else + reg = read_nic_dword(priv->rtllib->dev,INTA_MASK); + + reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); +#endif +} + +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) +{ +#ifdef RTL8192SE + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + *p_inta = read_nic_dword(dev, ISR) & priv->irq_mask[0]; +#else + *p_inta = read_nic_dword(dev, ISR) ; +#endif + write_nic_dword(dev,ISR,*p_inta); +#ifdef RTL8192SE + *p_intb = read_nic_dword(dev, ISR+4); + write_nic_dword(dev, ISR+4, *p_intb); +#endif +} + +bool rtl8192_HalRxCheckStuck(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u16 RegRxCounter = read_nic_word(dev, 0x130); + bool bStuck = false; + static u8 rx_chk_cnt = 0; + u32 SlotIndex = 0, TotalRxStuckCount = 0; + u8 i; + u8 SilentResetRxSoltNum = 4; + + RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n", + __func__, RegRxCounter,priv->RxCounter); + + rx_chk_cnt++; + if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) + { + rx_chk_cnt = 0; + } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5)) && + (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) || + ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)))) { + if (rx_chk_cnt < 2) { + return bStuck; + } else { + rx_chk_cnt = 0; + } + } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) || + ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M))) && + priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { + if (rx_chk_cnt < 4) { + return bStuck; + } else { + rx_chk_cnt = 0; + } + } else { + if (rx_chk_cnt < 8) { + return bStuck; + } else { + rx_chk_cnt = 0; + } + } + + + SlotIndex = (priv->SilentResetRxSlotIndex++)%SilentResetRxSoltNum; + + if (priv->RxCounter==RegRxCounter) + { + priv->SilentResetRxStuckEvent[SlotIndex] = 1; + + for ( i = 0; i < SilentResetRxSoltNum ; i++ ) + TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + + if (TotalRxStuckCount == SilentResetRxSoltNum) + { + bStuck = true; + for ( i = 0; i < SilentResetRxSoltNum ; i++ ) + TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + } + + + } else { + priv->SilentResetRxStuckEvent[SlotIndex] = 0; + } + + priv->RxCounter = RegRxCounter; + + return bStuck; +} + +bool rtl8192_HalTxCheckStuck(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool bStuck = false; +#if defined(RTL8192E) || defined(RTL8190P) + u16 RegTxCounter = read_nic_word(dev, 0x128); +#elif defined (RTL8192SE) || defined (RTL8192CE) + u16 RegTxCounter = read_nic_word(dev, 0x366); +#else + u16 RegTxCounter = priv->TxCounter + 1; + WARN_ON(1); +#endif + + RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", + __func__,RegTxCounter,priv->TxCounter); + + if (priv->TxCounter == RegTxCounter) + bStuck = true; + + priv->TxCounter = RegTxCounter; + + return bStuck; +} + +bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) +{ +#ifdef RTL8192SE + return true; +#else + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + if (ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + return false; + } else { + return true; + } +#endif +} + +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) +{ +#ifdef RTL8192SE + return false; +#else + bool Reval; + struct r8192_priv* priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + if (ieee->bHalfWirelessN24GMode == true) + Reval = true; + else + Reval = false; + + return Reval; +#endif +} + +u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) +{ + u8 tmp_Short; + + tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); +#if defined RTL8192SE || defined RTL8192CE + if (TxHT==1 && TxRate != DESC92S_RATEMCS15) +#elif defined RTL8192E || defined RTL8190P + if (TxHT==1 && TxRate != DESC90_RATEMCS15) +#endif + tmp_Short = 0; + + return tmp_Short; +} + +void +ActUpdateChannelAccessSetting( + struct net_device* dev, + WIRELESS_MODE WirelessMode, + PCHANNEL_ACCESS_SETTING ChnlAccessSetting + ) +{ + struct r8192_priv* priv = rtllib_priv(dev); + + return; + + { + u16 SIFS_Timer; + + if (WirelessMode == WIRELESS_MODE_G) + SIFS_Timer = 0x0e0e; + else + SIFS_Timer = priv->SifsTime; + + priv->rtllib->SetHwRegHandler( dev, HW_VAR_SIFS, (u8*)&SIFS_Timer); + } + +} diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h new file mode 100644 index 00000000000..f8021c7a661 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef _RTL8192E_H +#define _RTL8192E_H + +#include "r8190P_def.h" + +u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc); +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev); +bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev); +bool rtl8192_HalTxCheckStuck(struct net_device *dev); +bool rtl8192_HalRxCheckStuck(struct net_device *dev); +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb); +void rtl8192_enable_rx(struct net_device *dev); +void rtl8192_enable_tx(struct net_device *dev); +void rtl8192_EnableInterrupt(struct net_device *dev); +void rtl8192_DisableInterrupt(struct net_device *dev); +void rtl8192_ClearInterrupt(struct net_device *dev); +void rtl8192_InitializeVariables(struct net_device *dev); +void rtl8192e_start_beacon(struct net_device *dev); +void rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val); +void rtl8192_get_eeprom_size(struct net_device* dev); +bool rtl8192_adapter_start(struct net_device *dev); +void rtl8192_link_change(struct net_device *dev); +void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); +void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb_desc, + struct sk_buff* skb); +void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, + cb_desc * cb_desc, struct sk_buff* skb); +bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, + rx_desc *pdesc, struct sk_buff* skb); +void rtl8192_halt_adapter(struct net_device *dev, bool reset); +void rtl8192_update_ratr_table(struct net_device* dev); +#endif diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c new file mode 100644 index 00000000000..6d490292c03 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -0,0 +1,396 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#if (defined(RTL8192E) || defined(RTL8190P)) + +#include "rtl_core.h" +#include "r8192E_hw.h" +#ifdef RTL8190P +#include "r8190P_hwimg.h" +#elif defined RTL8192E +#include "r8192E_hwimg.h" +#endif +#include "r8192E_firmware.h" +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) +#include +#endif + +extern void firmware_init_param(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + rt_firmware *pfirmware = priv->pFirmware; + + pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); +} + +bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool rt_status = true; + u16 frag_threshold; + u16 frag_length, frag_offset = 0; + int i; + + rt_firmware *pfirmware = priv->pFirmware; + struct sk_buff *skb; + unsigned char *seg_ptr; + cb_desc *tcb_desc; + u8 bLastIniPkt; + + firmware_init_param(dev); + frag_threshold = pfirmware->cmdpacket_frag_thresold; + do { + if ((buffer_len - frag_offset) > frag_threshold) { + frag_length = frag_threshold ; + bLastIniPkt = 0; + + } else { + frag_length = buffer_len - frag_offset; + bLastIniPkt = 1; + + } + + skb = dev_alloc_skb(frag_length + 4); + memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc->queue_index = TXCMD_QUEUE; + tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; + tcb_desc->bLastIniPkt = bLastIniPkt; + + seg_ptr = skb->data; + for (i=0 ; i < frag_length; i+=4) { + *seg_ptr++ = ((i+0)txbuf_size= (u16)i; + skb_put(skb, i); + + if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ + (priv->rtllib->queue_stop) ) { + RT_TRACE(COMP_FIRMWARE, "===================> tx full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + } else { + priv->rtllib->softmac_hard_start_xmit(skb,dev); + } + + code_virtual_address += frag_length; + frag_offset += frag_length; + + }while(frag_offset < buffer_len); + + write_nic_byte(dev, TPPoll, TPPoll_CQ); + + return rt_status; +} + +bool +fwSendNullPacket( + struct net_device *dev, + u32 Length +) +{ + bool rtStatus = true; + struct r8192_priv *priv = rtllib_priv(dev); + struct sk_buff *skb; + cb_desc *tcb_desc; + unsigned char *ptr_buf; + bool bLastInitPacket = false; + + + skb = dev_alloc_skb(Length+ 4); + memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc->queue_index = TXCMD_QUEUE; + tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; + tcb_desc->bLastIniPkt = bLastInitPacket; + ptr_buf = skb_put(skb, Length); + memset(ptr_buf,0,Length); + tcb_desc->txbuf_size= (u16)Length; + + if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ + (priv->rtllib->queue_stop) ) { + RT_TRACE(COMP_FIRMWARE,"===================NULL packet================> tx full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + } else { + priv->rtllib->softmac_hard_start_xmit(skb,dev); + } + + write_nic_byte(dev, TPPoll, TPPoll_CQ); + return rtStatus; +} + +bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) +{ + bool rt_status = true; + u32 CPU_status = 0; + unsigned long timeout; + + timeout = jiffies + MSECS(200); + while (time_before(jiffies, timeout)) { + CPU_status = read_nic_dword(dev, CPU_GEN); + if (CPU_status & CPU_GEN_PUT_CODE_OK) + break; + msleep(2); + } + + if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) { + RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n"); + goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; + } else { + RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n"); + } + + CPU_status = read_nic_dword(dev, CPU_GEN); + write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); + mdelay(1); + + timeout = jiffies + MSECS(200); + while (time_before(jiffies, timeout)) { + CPU_status = read_nic_dword(dev, CPU_GEN); + if (CPU_status&CPU_GEN_BOOT_RDY) + break; + msleep(2); + } + + if (!(CPU_status&CPU_GEN_BOOT_RDY)) { + goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; + } else { + RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); + } + + return rt_status; + +CPUCheckMainCodeOKAndTurnOnCPU_Fail: + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); + rt_status = false; + return rt_status; +} + +bool CPUcheck_firmware_ready(struct net_device *dev) +{ + + bool rt_status = true; + u32 CPU_status = 0; + unsigned long timeout; + + timeout = jiffies + MSECS(20); + while (time_before(jiffies, timeout)) { + CPU_status = read_nic_dword(dev, CPU_GEN); + if (CPU_status&CPU_GEN_FIRM_RDY) + break; + msleep(2); + } + + if (!(CPU_status&CPU_GEN_FIRM_RDY)) + goto CPUCheckFirmwareReady_Fail; + else + RT_TRACE(COMP_FIRMWARE, "Download Firmware: Firmware ready!\n"); + + return rt_status; + +CPUCheckFirmwareReady_Fail: + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); + rt_status = false; + return rt_status; + +} + +inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) +{ + struct r8192_priv *priv = rtllib_priv(dev); + rt_firmware *pfirmware = priv->pFirmware; + bool rt_status = true; + + switch (load_fw_status) { + case FW_INIT_STEP0_BOOT: + pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE; +#ifdef RTL8190P + rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET); + if (!rt_status) { + RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n"); + } +#endif + break; + + case FW_INIT_STEP1_MAIN: + pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; + + rt_status = CPUcheck_maincodeok_turnonCPU(dev); + if (rt_status) { + pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; + } else { + RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnonCPU fail!\n"); + } + + break; + + case FW_INIT_STEP2_DATA: + pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE; + mdelay(1); + + rt_status = CPUcheck_firmware_ready(dev); + if (rt_status) { + pfirmware->firmware_status = FW_STATUS_5_READY; + } else { + RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); + } + + break; + default: + rt_status = false; + RT_TRACE(COMP_FIRMWARE, "Unknown firware status"); + break; + } + + return rt_status; +} + +bool init_firmware(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool rt_status = true; + +#ifdef RTL8190P + u8 *firmware_img_buf[3] = { &Rtl8190PciFwBootArray[0], + &Rtl8190PciFwMainArray[0], + &Rtl8190PciFwDataArray[0]}; + + u32 firmware_img_len[3] = { sizeof(Rtl8190PciFwBootArray), + sizeof(Rtl8190PciFwMainArray), + sizeof(Rtl8190PciFwDataArray)}; +#else + u8 *firmware_img_buf[3] = { &Rtl8192PciEFwBootArray[0], + &Rtl8192PciEFwMainArray[0], + &Rtl8192PciEFwDataArray[0]}; + + u32 firmware_img_len[3] = { sizeof(Rtl8192PciEFwBootArray), + sizeof(Rtl8192PciEFwMainArray), + sizeof(Rtl8192PciEFwDataArray)}; +#endif + u32 file_length = 0; + u8 *mapped_file = NULL; + u8 init_step = 0; + opt_rst_type_e rst_opt = OPT_SYSTEM_RESET; + firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT; + + rt_firmware *pfirmware = priv->pFirmware; + + RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); + + if (pfirmware->firmware_status == FW_STATUS_0_INIT ) { + rst_opt = OPT_SYSTEM_RESET; + starting_state = FW_INIT_STEP0_BOOT; + + }else if (pfirmware->firmware_status == FW_STATUS_5_READY) { + rst_opt = OPT_FIRMWARE_RESET; + starting_state = FW_INIT_STEP2_DATA; + }else { + RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n"); + } + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE) + priv->firmware_source = FW_SOURCE_IMG_FILE; +#else + priv->firmware_source = FW_SOURCE_HEADER_FILE; +#endif + for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { + if (rst_opt == OPT_SYSTEM_RESET) { + switch (priv->firmware_source) { + case FW_SOURCE_IMG_FILE: + { +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE) + if (pfirmware->firmware_buf_size[init_step] == 0) { + const char *fw_name[3] = { "RTL8192E/boot.img", + "RTL8192E/main.img", + "RTL8192E/data.img" + }; + const struct firmware *fw_entry; + int rc; + rc = request_firmware(&fw_entry, fw_name[init_step],&priv->pdev->dev); + if (rc < 0 ) { + RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); + goto download_firmware_fail; + } + if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { + RT_TRACE(COMP_FIRMWARE, "img file size exceed the container buffer fail!\n"); + goto download_firmware_fail; + } + + if (init_step != FW_INIT_STEP1_MAIN) { + memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size); + pfirmware->firmware_buf_size[init_step] = fw_entry->size; + + } else { + memset(pfirmware->firmware_buf[init_step],0,128); + memcpy(&pfirmware->firmware_buf[init_step][128],fw_entry->data,fw_entry->size); + pfirmware->firmware_buf_size[init_step] = fw_entry->size+128; + } + + if (rst_opt == OPT_SYSTEM_RESET) { + release_firmware(fw_entry); + } + } + mapped_file = pfirmware->firmware_buf[init_step]; + file_length = pfirmware->firmware_buf_size[init_step]; +#endif + break; + } + case FW_SOURCE_HEADER_FILE: + mapped_file = firmware_img_buf[init_step]; + file_length = firmware_img_len[init_step]; + if (init_step == FW_INIT_STEP2_DATA) { + memcpy(pfirmware->firmware_buf[init_step], mapped_file, file_length); + pfirmware->firmware_buf_size[init_step] = file_length; + } + break; + + default: + break; + } + + + } else if (rst_opt == OPT_FIRMWARE_RESET) { + mapped_file = pfirmware->firmware_buf[init_step]; + file_length = pfirmware->firmware_buf_size[init_step]; + } + + rt_status = fw_download_code(dev,mapped_file,file_length); + if (rt_status != true) { + goto download_firmware_fail; + } + + if (!firmware_check_ready(dev, init_step)) { + goto download_firmware_fail; + } + } + + RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n"); + return rt_status; + +download_firmware_fail: + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); + rt_status = false; + return rt_status; + +} +#endif diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h new file mode 100644 index 00000000000..8819f974474 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -0,0 +1,73 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_FIRMWARE_H +#define __INC_FIRMWARE_H + +#define RTL8190_CPU_START_OFFSET 0x80 + +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) + +typedef enum _firmware_init_step{ + FW_INIT_STEP0_BOOT = 0, + FW_INIT_STEP1_MAIN = 1, + FW_INIT_STEP2_DATA = 2, +}firmware_init_step_e; + +typedef enum _opt_rst_type{ + OPT_SYSTEM_RESET = 0, + OPT_FIRMWARE_RESET = 1, +}opt_rst_type_e; + +typedef enum _desc_packet_type_e{ + DESC_PACKET_TYPE_INIT = 0, + DESC_PACKET_TYPE_NORMAL = 1, +}desc_packet_type_e; + +typedef enum _firmware_source{ + FW_SOURCE_IMG_FILE = 0, + FW_SOURCE_HEADER_FILE = 1, +}firmware_source_e, *pfirmware_source_e; + +typedef enum _firmware_status{ + FW_STATUS_0_INIT = 0, + FW_STATUS_1_MOVE_BOOT_CODE = 1, + FW_STATUS_2_MOVE_MAIN_CODE = 2, + FW_STATUS_3_TURNON_CPU = 3, + FW_STATUS_4_MOVE_DATA_CODE = 4, + FW_STATUS_5_READY = 5, +}firmware_status_e; + +typedef struct _rt_firmare_seg_container { + u16 seg_size; + u8 *seg_ptr; +}fw_seg_container, *pfw_seg_container; + +typedef struct _rt_firmware{ + firmware_status_e firmware_status; + u16 cmdpacket_frag_thresold; +#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 +#define MAX_FW_INIT_STEP 3 + u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; + u16 firmware_buf_size[MAX_FW_INIT_STEP]; +} rt_firmware, *prt_firmware; + +bool init_firmware(struct net_device *dev); +extern void firmware_init_param(struct net_device *dev); + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 24e7303e56a..0b29636c302 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -1,49 +1,36 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ - Parts of this driver are based on the GPL part of the - official Realtek driver. - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - Parts of this driver are based on the Intel Pro Wireless - 2100 GPL driver. - We want to tanks the Authors of those projects - and the Ndiswrapper project Authors. -*/ - -/* Mariusz Matuszek added full registers definition with Realtek's name */ - -/* this file contains register definitions for the rtl8187 MAC controller */ #ifndef R8180_HW #define R8180_HW -typedef enum _VERSION_8190{ - VERSION_8190_BD=0x3, - VERSION_8190_BE -}VERSION_8190,*PVERSION_8190; -//added for different RF type -typedef enum _RT_RF_TYPE_DEF -{ - RF_1T2R = 0, - RF_2T4R, - - RF_819X_MAX_TYPE -}RT_RF_TYPE_DEF; - -typedef enum _BaseBand_Config_Type{ - BaseBand_Config_PHY_REG = 0, //Radio Path A - BaseBand_Config_AGC_TAB = 1, //Radio Path B -}BaseBand_Config_Type, *PBaseBand_Config_Type; +typedef enum _BaseBand_Config_Type { + BaseBand_Config_PHY_REG = 0, + BaseBand_Config_AGC_TAB = 1, +} BaseBand_Config_Type, *PBaseBand_Config_Type; #define RTL8187_REQT_READ 0xc0 #define RTL8187_REQT_WRITE 0x40 #define RTL8187_REQ_GET_REGS 0x05 #define RTL8187_REQ_SET_REGS 0x05 -#define R8180_MAX_RETRY 255 #define MAX_TX_URB 5 #define MAX_RX_URB 16 #define RX_URB_SIZE 9100 @@ -65,14 +52,14 @@ typedef enum _BaseBand_Config_Type{ #define EEPROM_TxPowerDiff 0x1F -#define EEPROM_PwDiff 0x21 //0x21 -#define EEPROM_CrystalCap 0x22 //0x22 +#define EEPROM_PwDiff 0x21 +#define EEPROM_CrystalCap 0x22 -#define EEPROM_TxPwIndex_CCK_V1 0x29 //0x29~0x2B -#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C //0x2C~0x2E -#define EEPROM_TxPwIndex_Ver 0x27 //0x27 +#define EEPROM_TxPwIndex_CCK_V1 0x29 +#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C +#define EEPROM_TxPwIndex_Ver 0x27 #define EEPROM_Default_TxPowerDiff 0x0 #define EEPROM_Default_ThermalMeter 0x77 @@ -81,42 +68,51 @@ typedef enum _BaseBand_Config_Type{ #define EEPROM_Default_PwDiff 0x4 #define EEPROM_Default_CrystalCap 0x5 #define EEPROM_Default_TxPower 0x1010 -#define EEPROM_ICVersion_ChannelPlan 0x7C //0x7C:ChannelPlan, 0x7D:IC_Version -#define EEPROM_Customer_ID 0x7B //0x7B:CustomerID - +#define EEPROM_ICVersion_ChannelPlan 0x7C +#define EEPROM_Customer_ID 0x7B +#ifdef RTL8190P +#define EEPROM_RFInd_PowerDiff 0x14 +#define EEPROM_ThermalMeter 0x15 +#define EEPROM_TxPwDiff_CrystalCap 0x16 +#define EEPROM_TxPwIndex_CCK 0x18 +#define EEPROM_TxPwIndex_OFDM_24G 0x26 +#define EEPROM_TxPwIndex_OFDM_5G 0x34 +#define EEPROM_C56_CrystalCap 0x17 +#define EEPROM_C56_RfA_CCK_Chnl1_TxPwIndex 0x80 +#define EEPROM_C56_RfA_HT_OFDM_TxPwIndex 0x81 +#define EEPROM_C56_RfC_CCK_Chnl1_TxPwIndex 0xbc +#define EEPROM_C56_RfC_HT_OFDM_TxPwIndex 0xb9 +#else +#ifdef RTL8192E #define EEPROM_RFInd_PowerDiff 0x28 #define EEPROM_ThermalMeter 0x29 -#define EEPROM_TxPwDiff_CrystalCap 0x2A //0x2A~0x2B -#define EEPROM_TxPwIndex_CCK 0x2C //0x23 -#define EEPROM_TxPwIndex_OFDM_24G 0x3A //0x24~0x26 - +#define EEPROM_TxPwDiff_CrystalCap 0x2A +#define EEPROM_TxPwIndex_CCK 0x2C +#define EEPROM_TxPwIndex_OFDM_24G 0x3A +#endif +#endif #define EEPROM_Default_TxPowerLevel 0x10 - -#define EEPROM_IC_VER 0x7d //0x7D -#define EEPROM_CRC 0x7e //0x7E~0x7F +#define EEPROM_IC_VER 0x7d +#define EEPROM_CRC 0x7e #define EEPROM_CID_DEFAULT 0x0 #define EEPROM_CID_CAMEO 0x1 #define EEPROM_CID_RUNTOP 0x2 #define EEPROM_CID_Senao 0x3 -#define EEPROM_CID_TOSHIBA 0x4 // Toshiba setting, Merge by Jacken, 2008/01/31 +#define EEPROM_CID_TOSHIBA 0x4 #define EEPROM_CID_NetCore 0x5 #define EEPROM_CID_Nettronix 0x6 #define EEPROM_CID_Pronet 0x7 #define EEPROM_CID_DLINK 0x8 -#define EEPROM_CID_WHQL 0xFE //added by sherry for dtm, 20080728 - +#define EEPROM_CID_WHQL 0xFE enum _RTL8192Pci_HW { - MAC0 = 0x000, - MAC1 = 0x001, - MAC2 = 0x002, - MAC3 = 0x003, - MAC4 = 0x004, - MAC5 = 0x005, - PCIF = 0x009, // PCI Function Register 0x0009h~0x000bh -//---------------------------------------------------------------------------- -// 8190 PCIF bits (Offset 0x009-000b, 24bit) -//---------------------------------------------------------------------------- + MAC0 = 0x000, + MAC1 = 0x001, + MAC2 = 0x002, + MAC3 = 0x003, + MAC4 = 0x004, + MAC5 = 0x005, + PCIF = 0x009, #define MXDMA2_16bytes 0x000 #define MXDMA2_32bytes 0x001 #define MXDMA2_64bytes 0x010 @@ -129,8 +125,8 @@ enum _RTL8192Pci_HW { #define MULRW_SHIFT 3 #define MXDMA2_RX_SHIFT 4 #define MXDMA2_TX_SHIFT 0 - PMR = 0x00c, // Power management register - EPROM_CMD = 0x00e, + PMR = 0x00c, + EPROM_CMD = 0x00e, #define EPROM_CMD_RESERVED_MASK BIT5 #define EPROM_CMD_9356SEL BIT4 #define EPROM_CMD_OPERATING_MODE_SHIFT 6 @@ -151,71 +147,65 @@ enum _RTL8192Pci_HW { ANAPAR = 0x17, #define BB_GLOBAL_RESET_BIT 0x1 - BB_GLOBAL_RESET = 0x020, // BasebandGlobal Reset Register - BSSIDR = 0x02E, // BSSID Register - CMDR = 0x037, // Command register -#define CR_RST 0x10 -#define CR_RE 0x08 -#define CR_TE 0x04 -#define CR_MulRW 0x01 - SIFS = 0x03E, // SIFS register - TCR = 0x040, // Transmit Configuration Register - RCR = 0x044, // Receive Configuration Register -//---------------------------------------------------------------------------- -//// 8190 (RCR) Receive Configuration Register (Offset 0x44~47, 32 bit) -////---------------------------------------------------------------------------- + BB_GLOBAL_RESET = 0x020, + BSSIDR = 0x02E, + CMDR = 0x037, +#define CR_RST 0x10 +#define CR_RE 0x08 +#define CR_TE 0x04 +#define CR_MulRW 0x01 + SIFS = 0x03E, + TCR = 0x040, + RCR = 0x044, #define RCR_FILTER_MASK (BIT0|BIT1|BIT2|BIT3|BIT5|BIT12|BIT18|BIT19|BIT20|BIT21|BIT22|BIT23) -#define RCR_ONLYERLPKT BIT31 // Early Receiving based on Packet Size. -#define RCR_ENCS2 BIT30 // Enable Carrier Sense Detection Method 2 -#define RCR_ENCS1 BIT29 // Enable Carrier Sense Detection Method 1 -#define RCR_ENMBID BIT27 // Enable Multiple BssId. -#define RCR_ACKTXBW (BIT24|BIT25) // TXBW Setting of ACK frames -#define RCR_CBSSID BIT23 // Accept BSSID match packet -#define RCR_APWRMGT BIT22 // Accept power management packet -#define RCR_ADD3 BIT21 // Accept address 3 match packet -#define RCR_AMF BIT20 // Accept management type frame -#define RCR_ACF BIT19 // Accept control type frame -#define RCR_ADF BIT18 // Accept data type frame -#define RCR_RXFTH BIT13 // Rx FIFO Threshold -#define RCR_AICV BIT12 // Accept ICV error packet -#define RCR_ACRC32 BIT5 // Accept CRC32 error packet -#define RCR_AB BIT3 // Accept broadcast packet -#define RCR_AM BIT2 // Accept multicast packet -#define RCR_APM BIT1 // Accept physical match packet -#define RCR_AAP BIT0 // Accept all unicast packet +#define RCR_ONLYERLPKT BIT31 +#define RCR_ENCS2 BIT30 +#define RCR_ENCS1 BIT29 +#define RCR_ENMBID BIT27 +#define RCR_ACKTXBW (BIT24|BIT25) +#define RCR_CBSSID BIT23 +#define RCR_APWRMGT BIT22 +#define RCR_ADD3 BIT21 +#define RCR_AMF BIT20 +#define RCR_ACF BIT19 +#define RCR_ADF BIT18 +#define RCR_RXFTH BIT13 +#define RCR_AICV BIT12 +#define RCR_ACRC32 BIT5 +#define RCR_AB BIT3 +#define RCR_AM BIT2 +#define RCR_APM BIT1 +#define RCR_AAP BIT0 #define RCR_MXDMA_OFFSET 8 #define RCR_FIFO_OFFSET 13 - SLOT_TIME = 0x049, // Slot Time Register - ACK_TIMEOUT = 0x04c, // Ack Timeout Register - PIFS_TIME = 0x04d, // PIFS time - USTIME = 0x04e, // Microsecond Tuning Register, Sets the microsecond time unit used by MAC clock. - EDCAPARA_BE = 0x050, // EDCA Parameter of AC BE - EDCAPARA_BK = 0x054, // EDCA Parameter of AC BK - EDCAPARA_VO = 0x058, // EDCA Parameter of AC VO - EDCAPARA_VI = 0x05C, // EDCA Parameter of AC VI + SLOT_TIME = 0x049, + ACK_TIMEOUT = 0x04c, + PIFS_TIME = 0x04d, + USTIME = 0x04e, + EDCAPARA_BE = 0x050, + EDCAPARA_BK = 0x054, + EDCAPARA_VO = 0x058, + EDCAPARA_VI = 0x05C, #define AC_PARAM_TXOP_LIMIT_OFFSET 16 #define AC_PARAM_ECW_MAX_OFFSET 12 #define AC_PARAM_ECW_MIN_OFFSET 8 #define AC_PARAM_AIFS_OFFSET 0 - RFPC = 0x05F, // Rx FIFO Packet Count - CWRR = 0x060, // Contention Window Report Register - BCN_TCFG = 0x062, // Beacon Time Configuration + RFPC = 0x05F, + CWRR = 0x060, + BCN_TCFG = 0x062, #define BCN_TCFG_CW_SHIFT 8 #define BCN_TCFG_IFS 0 - BCN_INTERVAL = 0x070, // Beacon Interval (TU) - ATIMWND = 0x072, // ATIM Window Size (TU) - BCN_DRV_EARLY_INT = 0x074, // Driver Early Interrupt Time (TU). Time to send interrupt to notify to change beacon content before TBTT + BCN_INTERVAL = 0x070, + ATIMWND = 0x072, + BCN_DRV_EARLY_INT = 0x074, #define BCN_DRV_EARLY_INT_SWBCN_SHIFT 8 #define BCN_DRV_EARLY_INT_TIME_SHIFT 0 - BCN_DMATIME = 0x076, // Beacon DMA and ATIM interrupt time (US). Indicates the time before TBTT to perform beacon queue DMA - BCN_ERR_THRESH = 0x078, // Beacon Error Threshold - RWCAM = 0x0A0, //IN 8190 Data Sheet is called CAMcmd - //---------------------------------------------------------------------------- - //// 8190 CAM Command Register (offset 0xA0, 4 byte) - ////---------------------------------------------------------------------------- -#define CAM_CM_SecCAMPolling BIT31 //Security CAM Polling -#define CAM_CM_SecCAMClr BIT30 //Clear all bits in CAM -#define CAM_CM_SecCAMWE BIT16 //Security CAM enable + BCN_DMATIME = 0x076, + BCN_ERR_THRESH = 0x078, + RWCAM = 0x0A0, +#define CAM_CM_SecCAMPolling BIT31 +#define CAM_CM_SecCAMClr BIT30 +#define CAM_CM_SecCAMWE BIT16 #define CAM_VALID BIT15 #define CAM_NOTVALID 0x0000 #define CAM_USEDK BIT5 @@ -234,68 +224,62 @@ enum _RTL8192Pci_HW { #define CAM_READ 0x00000000 #define CAM_POLLINIG BIT31 #define SCR_UseDK 0x01 - WCAMI = 0x0A4, // Software write CAM input content - RCAMO = 0x0A8, // Software read/write CAM config - SECR = 0x0B0, //Security Configuration Register -#define SCR_TxUseDK BIT0 //Force Tx Use Default Key -#define SCR_RxUseDK BIT1 //Force Rx Use Default Key -#define SCR_TxEncEnable BIT2 //Enable Tx Encryption -#define SCR_RxDecEnable BIT3 //Enable Rx Decryption -#define SCR_SKByA2 BIT4 //Search kEY BY A2 -#define SCR_NoSKMC BIT5 //No Key Search for Multicast - SWREGULATOR = 0x0BD, // Switching Regulator - INTA_MASK = 0x0f4, -//---------------------------------------------------------------------------- -// 8190 IMR/ISR bits (offset 0xfd, 8bits) -//---------------------------------------------------------------------------- + WCAMI = 0x0A4, + RCAMO = 0x0A8, + SECR = 0x0B0, +#define SCR_TxUseDK BIT0 +#define SCR_RxUseDK BIT1 +#define SCR_TxEncEnable BIT2 +#define SCR_RxDecEnable BIT3 +#define SCR_SKByA2 BIT4 +#define SCR_NoSKMC BIT5 + SWREGULATOR = 0x0BD, + INTA_MASK = 0x0f4, #define IMR8190_DISABLED 0x0 -#define IMR_ATIMEND BIT28 // ATIM Window End Interrupt -#define IMR_TBDOK BIT27 // Transmit Beacon OK Interrupt -#define IMR_TBDER BIT26 // Transmit Beacon Error Interrupt -#define IMR_TXFOVW BIT15 // Transmit FIFO Overflow -#define IMR_TIMEOUT0 BIT14 // TimeOut0 -#define IMR_BcnInt BIT13 // Beacon DMA Interrupt 0 -#define IMR_RXFOVW BIT12 // Receive FIFO Overflow -#define IMR_RDU BIT11 // Receive Descriptor Unavailable -#define IMR_RXCMDOK BIT10 // Receive Command Packet OK -#define IMR_BDOK BIT9 // Beacon Queue DMA OK Interrup -#define IMR_HIGHDOK BIT8 // High Queue DMA OK Interrupt -#define IMR_COMDOK BIT7 // Command Queue DMA OK Interrupt -#define IMR_MGNTDOK BIT6 // Management Queue DMA OK Interrupt -#define IMR_HCCADOK BIT5 // HCCA Queue DMA OK Interrupt -#define IMR_BKDOK BIT4 // AC_BK DMA OK Interrupt -#define IMR_BEDOK BIT3 // AC_BE DMA OK Interrupt -#define IMR_VIDOK BIT2 // AC_VI DMA OK Interrupt -#define IMR_VODOK BIT1 // AC_VO DMA Interrupt -#define IMR_ROK BIT0 // Receive DMA OK Interrupt - ISR = 0x0f8, // Interrupt Status Register - TPPoll = 0x0fd, // Transmit priority polling register -#define TPPoll_BKQ BIT0 // BK queue polling -#define TPPoll_BEQ BIT1 // BE queue polling -#define TPPoll_VIQ BIT2 // VI queue polling -#define TPPoll_VOQ BIT3 // VO queue polling -#define TPPoll_BQ BIT4 // Beacon queue polling -#define TPPoll_CQ BIT5 // Command queue polling -#define TPPoll_MQ BIT6 // Management queue polling -#define TPPoll_HQ BIT7 // High queue polling -#define TPPoll_HCCAQ BIT8 // HCCA queue polling -#define TPPoll_StopBK BIT9 // Stop BK queue -#define TPPoll_StopBE BIT10 // Stop BE queue -#define TPPoll_StopVI BIT11 // Stop VI queue -#define TPPoll_StopVO BIT12 // Stop VO queue -#define TPPoll_StopMgt BIT13 // Stop Mgnt queue -#define TPPoll_StopHigh BIT14 // Stop High queue -#define TPPoll_StopHCCA BIT15 // Stop HCCA queue -#define TPPoll_SHIFT 8 // Queue ID mapping +#define IMR_ATIMEND BIT28 +#define IMR_TBDOK BIT27 +#define IMR_TBDER BIT26 +#define IMR_TXFOVW BIT15 +#define IMR_TIMEOUT0 BIT14 +#define IMR_BcnInt BIT13 +#define IMR_RXFOVW BIT12 +#define IMR_RDU BIT11 +#define IMR_RXCMDOK BIT10 +#define IMR_BDOK BIT9 +#define IMR_HIGHDOK BIT8 +#define IMR_COMDOK BIT7 +#define IMR_MGNTDOK BIT6 +#define IMR_HCCADOK BIT5 +#define IMR_BKDOK BIT4 +#define IMR_BEDOK BIT3 +#define IMR_VIDOK BIT2 +#define IMR_VODOK BIT1 +#define IMR_ROK BIT0 + ISR = 0x0f8, + TPPoll = 0x0fd, +#define TPPoll_BKQ BIT0 +#define TPPoll_BEQ BIT1 +#define TPPoll_VIQ BIT2 +#define TPPoll_VOQ BIT3 +#define TPPoll_BQ BIT4 +#define TPPoll_CQ BIT5 +#define TPPoll_MQ BIT6 +#define TPPoll_HQ BIT7 +#define TPPoll_HCCAQ BIT8 +#define TPPoll_StopBK BIT9 +#define TPPoll_StopBE BIT10 +#define TPPoll_StopVI BIT11 +#define TPPoll_StopVO BIT12 +#define TPPoll_StopMgt BIT13 +#define TPPoll_StopHigh BIT14 +#define TPPoll_StopHCCA BIT15 +#define TPPoll_SHIFT 8 - PSR = 0x0ff, // Page Select Register -#define PSR_GEN 0x0 // Page 0 register general MAC Control -#define PSR_CPU 0x1 // Page 1 register for CPU - CPU_GEN = 0x100, // CPU Reset Register - BB_RESET = 0x101, // Baseband Reset -//---------------------------------------------------------------------------- -// 8190 CPU General Register (offset 0x100, 4 byte) -//---------------------------------------------------------------------------- + PSR = 0x0ff, +#define PSR_GEN 0x0 +#define PSR_CPU 0x1 + CPU_GEN = 0x100, + BB_RESET = 0x101, #define CPU_CCK_LOOPBACK 0x00030000 #define CPU_GEN_SYSTEM_RESET 0x00000001 #define CPU_GEN_FIRMWARE_RESET 0x00000008 @@ -304,19 +288,15 @@ enum _RTL8192Pci_HW { #define CPU_GEN_PUT_CODE_OK 0x00000080 #define CPU_GEN_BB_RST 0x00000100 #define CPU_GEN_PWR_STB_CPU 0x00000004 -#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19 -#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1 +#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF +#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 #define CPU_GEN_GPIO_UART 0x00007000 - LED1Cfg = 0x154,// LED1 Configuration Register - LED0Cfg = 0x155,// LED0 Configuration Register + LED1Cfg = 0x154, + LED0Cfg = 0x155, - AcmAvg = 0x170, // ACM Average Period Register - AcmHwCtrl = 0x171, // ACM Hardware Control Register -//---------------------------------------------------------------------------- -// -// 8190 AcmHwCtrl bits (offset 0x171, 1 byte) -//---------------------------------------------------------------------------- + AcmAvg = 0x170, + AcmHwCtrl = 0x171, #define AcmHw_HwEn BIT0 #define AcmHw_BeqEn BIT1 #define AcmHw_ViqEn BIT2 @@ -324,67 +304,65 @@ enum _RTL8192Pci_HW { #define AcmHw_BeqStatus BIT4 #define AcmHw_ViqStatus BIT5 #define AcmHw_VoqStatus BIT6 - AcmFwCtrl = 0x172, // ACM Firmware Control Register + AcmFwCtrl = 0x172, #define AcmFw_BeqStatus BIT0 #define AcmFw_ViqStatus BIT1 #define AcmFw_VoqStatus BIT2 - VOAdmTime = 0x174, // VO Queue Admitted Time Register - VIAdmTime = 0x178, // VI Queue Admitted Time Register - BEAdmTime = 0x17C, // BE Queue Admitted Time Register - RQPN1 = 0x180, // Reserved Queue Page Number , Vo Vi, Be, Bk - RQPN2 = 0x184, // Reserved Queue Page Number, HCCA, Cmd, Mgnt, High - RQPN3 = 0x188, // Reserved Queue Page Number, Bcn, Public, - QPRR = 0x1E0, // Queue Page Report per TID - QPNR = 0x1F0, // Queue Packet Number report per TID -/* there's 9 tx descriptor base address available */ - BQDA = 0x200, // Beacon Queue Descriptor Address - HQDA = 0x204, // High Priority Queue Descriptor Address - CQDA = 0x208, // Command Queue Descriptor Address - MQDA = 0x20C, // Management Queue Descriptor Address - HCCAQDA = 0x210, // HCCA Queue Descriptor Address - VOQDA = 0x214, // VO Queue Descriptor Address - VIQDA = 0x218, // VI Queue Descriptor Address - BEQDA = 0x21C, // BE Queue Descriptor Address - BKQDA = 0x220, // BK Queue Descriptor Address -/* there's 2 rx descriptor base address availalbe */ - RCQDA = 0x224, // Receive command Queue Descriptor Address - RDQDA = 0x228, // Receive Queue Descriptor Start Address + VOAdmTime = 0x174, + VIAdmTime = 0x178, + BEAdmTime = 0x17C, + RQPN1 = 0x180, + RQPN2 = 0x184, + RQPN3 = 0x188, + QPRR = 0x1E0, + QPNR = 0x1F0, + BQDA = 0x200, + HQDA = 0x204, + CQDA = 0x208, + MQDA = 0x20C, + HCCAQDA = 0x210, + VOQDA = 0x214, + VIQDA = 0x218, + BEQDA = 0x21C, + BKQDA = 0x220, + RCQDA = 0x224, + RDQDA = 0x228, - MAR0 = 0x240, // Multicast filter. + MAR0 = 0x240, MAR4 = 0x244, - CCX_PERIOD = 0x250, // CCX Measurement Period Register, in unit of TU. - CLM_RESULT = 0x251, // CCA Busy fraction register. - NHM_PERIOD = 0x252, // NHM Measurement Period register, in unit of TU. + CCX_PERIOD = 0x250, + CLM_RESULT = 0x251, + NHM_PERIOD = 0x252, - NHM_THRESHOLD0 = 0x253, // Noise Histogram Meashorement0. - NHM_THRESHOLD1 = 0x254, // Noise Histogram Meashorement1. - NHM_THRESHOLD2 = 0x255, // Noise Histogram Meashorement2. - NHM_THRESHOLD3 = 0x256, // Noise Histogram Meashorement3. - NHM_THRESHOLD4 = 0x257, // Noise Histogram Meashorement4. - NHM_THRESHOLD5 = 0x258, // Noise Histogram Meashorement5. - NHM_THRESHOLD6 = 0x259, // Noise Histogram Meashorement6 + NHM_THRESHOLD0 = 0x253, + NHM_THRESHOLD1 = 0x254, + NHM_THRESHOLD2 = 0x255, + NHM_THRESHOLD3 = 0x256, + NHM_THRESHOLD4 = 0x257, + NHM_THRESHOLD5 = 0x258, + NHM_THRESHOLD6 = 0x259, - MCTRL = 0x25A, // Measurement Control + MCTRL = 0x25A, - NHM_RPI_COUNTER0 = 0x264, // Noise Histogram RPI counter0, the fraction of signal strength < NHM_THRESHOLD0. - NHM_RPI_COUNTER1 = 0x265, // Noise Histogram RPI counter1, the fraction of signal strength in (NHM_THRESHOLD0, NHM_THRESHOLD1]. - NHM_RPI_COUNTER2 = 0x266, // Noise Histogram RPI counter2, the fraction of signal strength in (NHM_THRESHOLD1, NHM_THRESHOLD2]. - NHM_RPI_COUNTER3 = 0x267, // Noise Histogram RPI counter3, the fraction of signal strength in (NHM_THRESHOLD2, NHM_THRESHOLD3]. - NHM_RPI_COUNTER4 = 0x268, // Noise Histogram RPI counter4, the fraction of signal strength in (NHM_THRESHOLD3, NHM_THRESHOLD4]. - NHM_RPI_COUNTER5 = 0x269, // Noise Histogram RPI counter5, the fraction of signal strength in (NHM_THRESHOLD4, NHM_THRESHOLD5]. - NHM_RPI_COUNTER6 = 0x26A, // Noise Histogram RPI counter6, the fraction of signal strength in (NHM_THRESHOLD5, NHM_THRESHOLD6]. - NHM_RPI_COUNTER7 = 0x26B, // Noise Histogram RPI counter7, the fraction of signal strength in (NHM_THRESHOLD6, NHM_THRESHOLD7]. + NHM_RPI_COUNTER0 = 0x264, + NHM_RPI_COUNTER1 = 0x265, + NHM_RPI_COUNTER2 = 0x266, + NHM_RPI_COUNTER3 = 0x267, + NHM_RPI_COUNTER4 = 0x268, + NHM_RPI_COUNTER5 = 0x269, + NHM_RPI_COUNTER6 = 0x26A, + NHM_RPI_COUNTER7 = 0x26B, WFCRC0 = 0x2f0, WFCRC1 = 0x2f4, WFCRC2 = 0x2f8, - BW_OPMODE = 0x300, // Bandwidth operation mode + BW_OPMODE = 0x300, #define BW_OPMODE_11J BIT0 #define BW_OPMODE_5G BIT1 #define BW_OPMODE_20MHZ BIT2 - IC_VERRSION = 0x301, //IC_VERSION - MSR = 0x303, // Media Status register + IC_VERRSION = 0x301, + MSR = 0x303, #define MSR_LINK_MASK ((1<<0)|(1<<1)) #define MSR_LINK_MANAGED 2 #define MSR_LINK_NONE 0 @@ -392,11 +370,17 @@ enum _RTL8192Pci_HW { #define MSR_LINK_ADHOC 1 #define MSR_LINK_MASTER 3 #define MSR_LINK_ENEDCA (1<<4) - RETRY_LIMIT = 0x304, // Retry Limit [15:8]-short, [7:0]-long + +#define MSR_NOLINK 0x00 +#define MSR_ADHOC 0x01 +#define MSR_INFRA 0x02 +#define MSR_AP 0x03 + + RETRY_LIMIT = 0x304, #define RETRY_LIMIT_SHORT_SHIFT 8 #define RETRY_LIMIT_LONG_SHIFT 0 TSFR = 0x308, - RRSR = 0x310, // Response Rate Set + RRSR = 0x310, #define RRSR_RSC_OFFSET 21 #define RRSR_SHORT_OFFSET 23 #define RRSR_RSC_DUPLICATE 0x600000 @@ -423,18 +407,13 @@ enum _RTL8192Pci_HW { #define RRSR_MCS5 BIT17 #define RRSR_MCS6 BIT18 #define RRSR_MCS7 BIT19 -#define BRSR_AckShortPmb BIT23 // CCK ACK: use Short Preamble or not +#define BRSR_AckShortPmb BIT23 UFWP = 0x318, - RATR0 = 0x320, // Rate Adaptive Table register1 -//---------------------------------------------------------------------------- -// 8190 Rate Adaptive Table Register (offset 0x320, 4 byte) -//---------------------------------------------------------------------------- -//CCK + RATR0 = 0x320, #define RATR_1M 0x00000001 #define RATR_2M 0x00000002 #define RATR_55M 0x00000004 #define RATR_11M 0x00000008 -//OFDM #define RATR_6M 0x00000010 #define RATR_9M 0x00000020 #define RATR_12M 0x00000040 @@ -443,7 +422,6 @@ enum _RTL8192Pci_HW { #define RATR_36M 0x00000200 #define RATR_48M 0x00000400 #define RATR_54M 0x00000800 -//MCS 1 Spatial Stream #define RATR_MCS0 0x00001000 #define RATR_MCS1 0x00002000 #define RATR_MCS2 0x00004000 @@ -452,7 +430,6 @@ enum _RTL8192Pci_HW { #define RATR_MCS5 0x00020000 #define RATR_MCS6 0x00040000 #define RATR_MCS7 0x00080000 -//MCS 2 Spatial Stream #define RATR_MCS8 0x00100000 #define RATR_MCS9 0x00200000 #define RATR_MCS10 0x00400000 @@ -461,7 +438,6 @@ enum _RTL8192Pci_HW { #define RATR_MCS13 0x02000000 #define RATR_MCS14 0x04000000 #define RATR_MCS15 0x08000000 -// ALL CCK Rate #define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M #define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|RATR_36M|RATR_48M|RATR_54M #define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 | \ @@ -470,22 +446,20 @@ enum _RTL8192Pci_HW { RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15 - DRIVER_RSSI = 0x32c, // Driver tell Firmware current RSSI - MCS_TXAGC = 0x340, // MCS AGC - CCK_TXAGC = 0x348, // CCK AGC - MacBlkCtrl = 0x403, // Mac block on/off control register + DRIVER_RSSI = 0x32c, + MCS_TXAGC = 0x340, + CCK_TXAGC = 0x348, + MacBlkCtrl = 0x403, -}; +} +; #define GPI 0x108 #define GPO 0x109 #define GPE 0x10a -#define ANAPAR_FOR_8192PciE 0x17 // Analog parameter register +#define HWSET_MAX_SIZE_92S 128 -#define MSR_NOLINK 0x00 -#define MSR_ADHOC 0x01 -#define MSR_INFRA 0x02 -#define MSR_AP 0x03 +#define ANAPAR_FOR_8192PciE 0x17 #endif diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.c b/drivers/staging/rtl8192e/r8192E_hwimg.c new file mode 100644 index 00000000000..1b42f7335d9 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_hwimg.c @@ -0,0 +1,3337 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +/*Created on 2008/11/18, 3: 7*/ + +#include "r8192E_hwimg.h" + +u8 Rtl8192PciEFwBootArray[BootArrayLengthPciE] = { +0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08, +0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00, +0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, +0x25,0x08,0xa8,0x04,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff, +0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b, +0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00, +0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, +0x25,0x08,0xa8,0x04,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0, +0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00, +0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00, +0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff, +0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01, +0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01, +0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24, +0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10, +0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, +0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10, +0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x4b,0x94, +0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,}; + +u8 Rtl8192PciEFwMainArray[MainArrayLengthPciE] = { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x12,0x98, +0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09, +0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24, +0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0, +0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x8b,0x70,0x00,0x85,0x18,0x21, +0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00, +0x27,0x82,0x8b,0x7a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00, +0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x8b,0x70, +0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x8b,0x72,0x24,0x02,0x00,0x04, +0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x8b,0x86,0xa3,0x82,0x8b,0x78, +0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x8b,0x8c,0xa3,0x85,0x8b,0x79, +0xa7,0x82,0x8b,0x7a,0xa7,0x84,0x8b,0x7c,0xaf,0x84,0x8b,0x88,0xa3,0x84,0x8b,0x71, +0xa3,0x80,0x8b,0x73,0xa3,0x80,0x8b,0x74,0xa3,0x80,0x8b,0x75,0xa3,0x84,0x8b,0x76, +0xa3,0x85,0x8b,0x77,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00, +0x27,0x84,0x8b,0x98,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00, +0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0, +0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00, +0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00, +0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03, +0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11, +0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07, +0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10, +0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b, +0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20, +0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24, +0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54, +0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0x94,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18, +0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x8b,0x90,0x8c,0xa3,0x00,0x00, +0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a, +0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01, +0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3, +0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40, +0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x8b,0x98,0x00,0x0a,0x20,0x0b, +0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01, +0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x8b,0x98,0xa0,0x67,0x00,0x01, +0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07, +0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x90,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x8b,0x94, +0x27,0x82,0x8b,0x90,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00, +0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00, +0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xac,0x08,0x00,0x00,0xa7, +0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xa0,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10, +0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00, +0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03, +0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2, +0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09, +0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x8b,0x98, +0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00, +0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04, +0x30,0x43,0x00,0x06,0x93,0x82,0x8b,0xb0,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21, +0x83,0x82,0x8b,0xa4,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f, +0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01, +0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4, +0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08, +0x24,0x02,0x00,0x01,0xaf,0x84,0x8b,0xc0,0xa3,0x82,0x8b,0xd0,0xa7,0x80,0x8b,0xc4, +0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0xaf,0x80,0x8b,0xcc,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, +0x24,0x42,0x05,0x24,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac, +0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21, +0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x5c,0x27,0xbd,0xff,0xe0, +0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, +0x8f,0x90,0x8b,0xc0,0x0c,0x00,0x02,0x98,0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a, +0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01, +0xae,0x02,0x00,0x00,0x97,0x84,0x8b,0xc4,0x97,0x82,0x8b,0xc6,0x3c,0x03,0xb0,0x02, +0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x8b,0xc6,0xa4,0x82,0x00,0x00, +0x8f,0x84,0x8b,0xc8,0x8f,0x82,0x8b,0xc0,0x93,0x85,0x8b,0x72,0x24,0x84,0x00,0x01, +0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03, +0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,0xaf,0x82,0x8b,0xc0, +0xaf,0x84,0x8b,0xc8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,0x8f,0x83,0x8b,0xcc, +0x8f,0x84,0x8b,0x8c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b, +0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00, +0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x48,0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20, +0x8f,0x90,0x8b,0xc0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21, +0x0c,0x00,0x02,0x98,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19, +0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24, +0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,0x97,0x86,0x8b,0xc4, +0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00, +0x8f,0x84,0x8b,0xc0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x8b,0xc6,0x00,0xc2,0x30,0x21, +0x8f,0x82,0x8b,0xc8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24, +0x24,0x42,0x00,0x01,0xa7,0x85,0x8b,0xc6,0xaf,0x84,0x8b,0xc0,0xaf,0x82,0x8b,0xc8, +0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, +0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14, +0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc, +0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08, +0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01, +0x00,0x02,0x10,0x80,0x24,0x63,0x01,0xe8,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14, +0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x8c,0xa4,0x00,0x00,0x0c,0x00,0x17,0x84,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xdc, +0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x49,0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xdc, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00, +0x8f,0x82,0x80,0x18,0x3c,0x03,0x00,0x0f,0x34,0x63,0x42,0x40,0x00,0x43,0x10,0x21, +0x00,0x82,0x20,0x2b,0x10,0x80,0x00,0x09,0x24,0x03,0x00,0x05,0x8f,0x82,0x83,0x60, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x83,0x60,0x10,0x43,0x00,0x03, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x8c,0x63,0x01,0x08,0x24,0x02,0x00,0x01,0xa3,0x82,0x80,0x11,0xaf,0x80,0x83,0x60, +0xaf,0x83,0x80,0x18,0x08,0x00,0x01,0xf9,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff, +0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,0x8f,0x82,0x80,0x14,0xa3,0x85,0x83,0x93, +0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40, +0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0, +0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00, +0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0, +0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0, +0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40, +0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00, +0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10, +0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21, +0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x80,0x14, +0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21, +0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,0xa3,0x82,0x83,0x9b,0xa3,0x83,0x83,0x9a, +0x27,0x8a,0x83,0x98,0x00,0x00,0x20,0x21,0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80, +0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01, +0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00, +0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80, +0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c, +0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18, +0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c, +0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00, +0xaf,0x86,0x8b,0xc0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96, +0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x8f,0x86,0x8b,0xc0,0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08, +0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12, +0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21, +0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, +0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08, +0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x48,0x28,0x24,0x97,0x83,0x8b,0xc6, +0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21, +0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, +0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00, +0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0, +0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38, +0x93,0x82,0x8b,0xd0,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01, +0x8f,0x82,0x8b,0xc8,0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18, +0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x8b,0xc4, +0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x8b,0xcc, +0xa7,0x80,0x8b,0xc6,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x8b,0xc8, +0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a, +0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,0x27,0x89,0x83,0x68,0x24,0xe2,0x00,0x01, +0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a, +0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f, +0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x6e,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, +0xa7,0x82,0x83,0x6e,0x90,0xa3,0x00,0x15,0x97,0x82,0x83,0x70,0x00,0x03,0x1e,0x00, +0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,0xa7,0x82,0x83,0x70,0x8c,0xa4,0x00,0x20, +0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54, +0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x74, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x74,0x84,0xa3,0x00,0x06, +0x8f,0x82,0x83,0x84,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x84, +0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,0xaf,0x82,0x8b,0xc8,0x10,0x60,0x00,0x09, +0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05, +0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,0xa3,0x83,0x83,0x6a,0xa3,0x82,0x83,0x6b, +0x90,0xa2,0x00,0x18,0x93,0x83,0x83,0x93,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00, +0x00,0x02,0x16,0x03,0xa7,0x82,0x83,0x7e,0xa3,0x83,0x83,0x8c,0x27,0x89,0x83,0x68, +0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, +0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a, +0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x8b,0xc6, +0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21, +0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, +0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00, +0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0, +0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, +0x0c,0x00,0x02,0x36,0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xe5, +0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x76,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, +0xa7,0x82,0x83,0x76,0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x88,0x00,0x00,0x00,0x00, +0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x88,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01, +0x97,0x82,0x83,0x72,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x72, +0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x80,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, +0xaf,0x82,0x83,0x80,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01,0x97,0x82,0x83,0x6c, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x6c,0x08,0x00,0x02,0xc5, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20, +0x8f,0x8a,0x8b,0xc0,0x3c,0x02,0x00,0x10,0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21, +0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c, +0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42, +0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25, +0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a, +0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34, +0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18, +0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20, +0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff, +0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, +0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00, +0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4, +0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06, +0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00, +0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24, +0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x8a,0x8b,0xc0,0x10,0xa2,0x00,0x03, +0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20, +0x24,0x42,0x0d,0xfc,0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, +0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21, +0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14, +0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08, +0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02, +0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76, +0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, +0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2, +0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, +0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24, +0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, +0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04, +0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2, +0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02, +0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26, +0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02, +0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00, +0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00, +0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x92,0x01,0x20,0x20,0x21,0x08,0x00,0x03,0xa5, +0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07, +0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,0x27,0x83,0x8b,0x70,0x00,0x43,0x10,0x21, +0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40, +0x27,0x83,0x8b,0x78,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xcc, +0x00,0x07,0x22,0x02,0x27,0x82,0x8b,0x70,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00, +0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21, +0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00, +0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e, +0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xcc, +0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00, +0x08,0x00,0x03,0xcb,0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00, +0x08,0x00,0x03,0xcb,0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00, +0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x03,0xfd,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x04,0x02,0x3c,0x02,0xb0,0x0a, +0x08,0x00,0x04,0x06,0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08, +0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02, +0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00, +0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24, +0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00, +0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24, +0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02, +0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02, +0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01, +0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69, +0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15, +0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21, +0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24, +0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,0x08,0x00,0x03,0xa5,0x02,0x51,0x10,0x21, +0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24, +0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0xa5, +0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00, +0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, +0x08,0x00,0x03,0xa4,0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21, +0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17, +0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x70, +0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27, +0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4, +0xac,0x82,0x00,0x18,0x27,0x83,0x8b,0x78,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21, +0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24, +0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4,0xa4,0x82,0x00,0x02,0x27,0x83,0x8b,0x70, +0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x5a, +0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f, +0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, +0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x47, +0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00, +0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x50,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a, +0x08,0x00,0x04,0x7d,0x00,0x43,0x18,0x21,0x97,0x85,0x8b,0xc4,0x3c,0x07,0xb0,0x02, +0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20, +0x24,0x42,0x12,0x58,0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07, +0x97,0x82,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8, +0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08, +0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25, +0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x8b,0xc0, +0xa7,0x82,0x8b,0xc4,0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, +0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07, +0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03, +0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14, +0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27, +0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x04,0xe1,0xac,0x62,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, +0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07, +0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a, +0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10, +0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09, +0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, +0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, +0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24, +0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00, +0x30,0xa9,0x00,0xff,0x27,0x83,0x8b,0x70,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01, +0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21, +0x00,0x05,0x20,0x40,0x27,0x82,0x8b,0x70,0x00,0x05,0x28,0x80,0x27,0x83,0x8b,0x78, +0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27, +0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00, +0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18, +0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25, +0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00, +0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00, +0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25, +0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0x14,0xdc, +0x3c,0x04,0xb0,0x03,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00,0xaf,0xb0,0x00,0x10, +0x34,0x84,0x00,0x2c,0x8c,0x83,0x00,0x00,0xa7,0x80,0xbc,0x00,0x00,0x03,0x12,0x02, +0x00,0x03,0x2d,0x02,0x30,0x42,0x0f,0xff,0xa3,0x83,0xbc,0x08,0xa7,0x85,0xbc,0x0c, +0xa7,0x82,0xbc,0x0a,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04,0xa7,0x80,0xbc,0x06, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25, +0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21,0x3c,0x02,0xf7,0xff, +0x34,0x42,0xff,0xff,0x02,0x02,0x80,0x24,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf, +0x24,0x04,0x05,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x42,0x01,0x08, +0x34,0x63,0x01,0x18,0x8c,0x45,0x00,0x00,0x8c,0x64,0x00,0x00,0x3c,0x02,0x00,0x0f, +0x3c,0x03,0x00,0x4c,0x30,0x84,0x02,0x00,0x34,0x63,0x4b,0x40,0xaf,0x85,0xbc,0x10, +0x10,0x80,0x00,0x06,0x34,0x42,0x42,0x40,0xaf,0x83,0xbc,0x14,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x82,0xbc,0x14, +0x08,0x00,0x05,0x67,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x27,0xbd,0xff,0xc8,0x34,0x63,0x00,0x20,0x24,0x42,0x15,0xb8,0x30,0x84,0x00,0xff, +0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24, +0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, +0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00,0x10,0x80,0x00,0x1c,0x24,0x02,0x00,0x02, +0x10,0x82,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c, +0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x38,0xa7,0x80,0xbc,0x00,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04, +0xa7,0x80,0xbc,0x06,0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00, +0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21, +0x3c,0x05,0xf7,0xff,0x34,0xa5,0xff,0xff,0x02,0x05,0x28,0x24,0x0c,0x00,0x06,0xbf, +0x24,0x04,0x05,0x00,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, +0x24,0x04,0x05,0xa0,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0xbc,0x02, +0x24,0x04,0x05,0xa8,0x00,0x02,0xb4,0x02,0x0c,0x00,0x06,0xd1,0x30,0x55,0xff,0xff, +0x00,0x40,0x80,0x21,0x97,0x84,0xbc,0x00,0x97,0x82,0xbc,0x02,0x97,0x83,0xbc,0x06, +0x02,0xe4,0x20,0x23,0x02,0xa2,0x10,0x23,0x00,0x82,0x20,0x21,0x97,0x82,0xbc,0x04, +0x32,0x14,0xff,0xff,0x02,0x83,0x18,0x23,0x02,0xc2,0x10,0x23,0x00,0x82,0x20,0x21, +0x93,0x82,0xbc,0x08,0x00,0x83,0x20,0x21,0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b, +0x14,0x40,0x00,0xaa,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0c,0x00,0x00,0x00,0x00, +0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x7f,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0a, +0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x3a,0x00,0x00,0x00,0x00, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21, +0x2e,0x22,0x00,0x32,0x10,0x40,0x00,0x13,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x17, +0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x26,0x31,0x00,0x01,0x00,0x51,0x80,0x25, +0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x50,0x02,0x00,0x28,0x21, +0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x58,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf, +0x24,0x04,0x04,0x60,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x68,0x0c,0x00,0x06,0xbf, +0x00,0x00,0x00,0x00,0xa7,0x97,0xbc,0x00,0xa7,0x95,0xbc,0x02,0xa7,0x96,0xbc,0x04, +0xa7,0x94,0xbc,0x06,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, +0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24, +0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00, +0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25, +0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, +0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24, +0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x05,0xc9, +0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f, +0x24,0x02,0x00,0x20,0x16,0x22,0xff,0xdb,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, +0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf, +0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c, +0x0c,0x00,0x06,0xd1,0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00, +0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x1d,0x2c,0x42,0x00,0x11, +0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff, +0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf, +0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,0x08,0x00,0x05,0xd7,0x24,0x04,0x02,0x2c, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21, +0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xee, +0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25, +0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x08,0x00,0x06,0x13,0x3c,0x02,0xff,0xff, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82, +0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,0x14,0x43,0xff,0xdf,0x3c,0x02,0xff,0x3f, +0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x3c,0x03,0x00,0x80,0x08,0x00,0x06,0x28, +0x00,0x43,0x28,0x25,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f, +0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,0x10,0x40,0xff,0x9a,0x24,0x02,0x00,0x20, +0x12,0x22,0x00,0x04,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x08,0x00,0x05,0xcb, +0x26,0x31,0x00,0x02,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0, +0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03, +0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, +0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff, +0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf, +0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x42,0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1, +0x24,0x04,0x04,0x50,0x00,0x40,0x80,0x21,0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20, +0x12,0x22,0x00,0x1d,0x2e,0x22,0x00,0x21,0x14,0x40,0xff,0x72,0x24,0x02,0xff,0x80, +0x02,0x02,0x10,0x24,0x26,0x31,0xff,0xff,0x00,0x51,0x80,0x25,0x24,0x04,0x04,0x50, +0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x58,0x0c,0x00,0x06,0xbf, +0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x60,0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21, +0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x68,0x24,0x02,0x00,0x20, +0x16,0x22,0xff,0x60,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, +0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x10,0x24, +0x08,0x00,0x06,0x19,0x34,0x52,0x80,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, +0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,0x0c,0x00,0x06,0xd1, +0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25, +0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x20,0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0d, +0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24, +0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf,0x36,0x52,0x80,0x00, +0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x66, +0x2e,0x22,0x00,0x21,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0, +0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02, +0x14,0x43,0xff,0xec,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, +0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08, +0x08,0x00,0x06,0x96,0x3c,0x02,0xff,0xff,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08, +0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03, +0x14,0x43,0xff,0xdc,0x3c,0x03,0x00,0x80,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, +0x00,0xa2,0x10,0x24,0x08,0x00,0x06,0xae,0x00,0x43,0x28,0x25,0x30,0x83,0x00,0x03, +0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x00,0x82,0x20,0x21, +0x3c,0x06,0x00,0x01,0xac,0x85,0x00,0x00,0x24,0x07,0x00,0x01,0x00,0x00,0x28,0x21, +0x34,0xc6,0x86,0x9f,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03, +0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x3c,0x02,0xb0,0x0a, +0x00,0x83,0x20,0x23,0x00,0x82,0x20,0x21,0x3c,0x06,0x00,0x01,0x24,0x02,0xff,0xff, +0xac,0x82,0x10,0x00,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x01,0x34,0xc6,0x86,0x9f, +0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03,0x00,0xc5,0x18,0x2b, +0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x1b,0x94, +0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03,0xac,0xa2,0x00,0x00, +0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05, +0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08,0xa0,0x80,0x00,0x09, +0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13,0xa0,0x80,0x00,0x49, +0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e,0x00,0x02,0x14,0x00, +0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00,0xa4,0x82,0x00,0x44, +0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c, +0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xac,0x80,0x00,0x3c, +0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c,0x3c,0x07,0xb0,0x03, +0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18,0x3c,0x02,0x80,0x00, +0x24,0x42,0x1c,0x28,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08,0x80,0x82,0x00,0x13, +0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00,0x30,0x63,0x00,0x7e, +0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00,0x3c,0x05,0xb0,0x05, +0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05,0x3c,0x08,0xb0,0x05, +0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21,0x34,0xe7,0x04,0x24, +0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20,0xac,0xe6,0x00,0x00, +0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00,0x27,0xbd,0xff,0xa8, +0x00,0x07,0x60,0x80,0x27,0x82,0xb4,0x00,0xaf,0xbe,0x00,0x50,0xaf,0xb7,0x00,0x4c, +0xaf,0xb5,0x00,0x44,0xaf,0xb4,0x00,0x40,0xaf,0xbf,0x00,0x54,0xaf,0xb6,0x00,0x48, +0xaf,0xb3,0x00,0x3c,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34,0xaf,0xb0,0x00,0x30, +0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21,0x3c,0x02,0x80,0x00, +0x94,0x73,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x24,0x42,0x1c,0xbc, +0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28,0x90,0x67,0x00,0x00, +0x00,0x13,0xa8,0xc0,0x02,0xb3,0x18,0x21,0x27,0x82,0x90,0x04,0x00,0x03,0x18,0x80, +0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00,0x28,0xc2,0x00,0x03, +0x00,0xc0,0xa0,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xbc,0x03,0x8c,0x68,0x00,0x18, +0x02,0xa0,0x58,0x21,0x10,0x40,0x01,0x81,0x00,0x07,0xf6,0x03,0x00,0xde,0x10,0x07, +0x30,0x5e,0x00,0x01,0x01,0x73,0x10,0x21,0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00,0x8d,0x02,0x00,0x04, +0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x20,0x11,0xa0,0x01,0x71, +0xaf,0xa3,0x00,0x18,0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x44,0x00,0x00, +0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04, +0x14,0x60,0x00,0x12,0x00,0x00,0xb0,0x21,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46, +0x90,0x43,0x00,0x00,0x2a,0x84,0x00,0x04,0x10,0x80,0x01,0x56,0x30,0x65,0x00,0x01, +0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x82,0x00,0x02,0x00,0x00,0x00,0x00, +0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21,0x13,0xc0,0x00,0x03, +0x38,0xf6,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf6,0x00,0x01,0x01,0x73,0x10,0x21, +0x00,0x02,0x30,0x80,0x27,0x83,0x90,0x10,0x00,0xc3,0x48,0x21,0x91,0x25,0x00,0x00, +0x8f,0xa4,0x00,0x20,0x2c,0xa3,0x00,0x04,0x00,0x04,0x11,0xc3,0x30,0x42,0x00,0x01, +0x00,0x03,0xb0,0x0b,0x12,0xc0,0x00,0xd8,0xaf,0xa2,0x00,0x24,0x93,0x90,0xbb,0xea, +0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f,0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xc0, +0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10,0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b, +0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04,0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b, +0x01,0x73,0x10,0x21,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, +0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, +0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x01,0x73,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21,0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0xa5, +0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05,0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01, +0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e,0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00, +0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0,0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00, +0x24,0x17,0x00,0x0e,0x24,0x13,0x01,0x06,0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00, +0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x24,0x05,0x00,0x01, +0xaf,0xa5,0x00,0x1c,0x90,0x62,0x00,0x16,0x00,0x13,0xa8,0xc0,0x32,0x51,0x00,0x02, +0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa3,0x00,0x20,0x8f,0xa4,0x00,0x18, +0x00,0x03,0x13,0x43,0x00,0x04,0x1a,0x02,0x30,0x47,0x00,0x01,0x12,0x20,0x00,0x04, +0x30,0x64,0x07,0xff,0x2e,0x03,0x00,0x04,0x32,0x42,0x00,0x33,0x00,0x43,0x90,0x0b, +0x8f,0xa5,0x00,0x24,0x8f,0xa6,0x00,0x1c,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0, +0x00,0x47,0x10,0x21,0x00,0x06,0x2a,0x80,0x00,0x43,0x10,0x21,0x00,0x10,0x32,0x00, +0x00,0x04,0x24,0x80,0x02,0x65,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21, +0x00,0x17,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x80,0x00,0x29, +0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05, +0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28, +0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09, +0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01, +0x02,0x83,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21, +0x13,0xc0,0x00,0x03,0x02,0xb3,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0xb3,0x10,0x21, +0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04, +0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x80,0x28,0x21,0x02,0xc0,0x38,0x21, +0x0c,0x00,0x00,0x70,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c, +0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x3d,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x02,0x12,0x82,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03, +0x12,0x82,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x82,0x00,0x19, +0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x82,0x00,0x0d,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x12,0x16,0x82,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05, +0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00, +0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x07,0xe6,0x24,0x02,0x00,0x20, +0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, +0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x07,0xe6, +0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05, +0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80, +0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05, +0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28, +0x24,0x02,0x00,0x08,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10, +0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14, +0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00, +0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, +0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x07,0xe6, +0xac,0x65,0x00,0x00,0x24,0x17,0x00,0x14,0x08,0x00,0x07,0xb8,0x24,0x13,0x01,0x02, +0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c, +0x26,0x02,0x00,0x04,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, +0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, +0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04, +0x08,0x00,0x07,0xa2,0x00,0x46,0x80,0x0a,0x27,0x82,0xb4,0x00,0x01,0x82,0x20,0x21, +0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x20,0x00,0xc2,0x10,0x21, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x14,0x00,0x00,0x00,0x00, +0x90,0xe3,0x00,0x16,0x27,0x82,0x90,0x08,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20, +0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x1e,0x42, +0x24,0x06,0x00,0x01,0x90,0x82,0x00,0x16,0x30,0x71,0x00,0x02,0x30,0x72,0x00,0x3f, +0x30,0x42,0x00,0xfb,0x24,0x17,0x00,0x18,0x24,0x13,0x01,0x03,0x24,0x15,0x08,0x18, +0xaf,0xa6,0x00,0x1c,0x08,0x00,0x07,0xc2,0xa0,0x82,0x00,0x16,0x8d,0x02,0x00,0x04, +0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10,0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f, +0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e, +0x27,0x83,0x90,0x18,0x00,0xc3,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x78, +0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04, +0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24,0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25, +0x27,0x85,0xb4,0x00,0x01,0x85,0x28,0x21,0x8c,0xa6,0x00,0x00,0x01,0x73,0x10,0x21, +0x27,0x83,0x90,0x10,0x90,0xc4,0x00,0x16,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00,0xa0,0xc4,0x00,0x16,0x80,0xc6,0x00,0x12, +0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0xaf,0xa6,0x00,0x1c,0x90,0x62,0x00,0x16, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06,0xa0,0x62,0x00,0x16, +0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04,0x15,0xc2,0xff,0x0e, +0x32,0x51,0x00,0x02,0x32,0x51,0x00,0x02,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x0f, +0x00,0x11,0x18,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10,0x00,0x03,0x19,0x00, +0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xe0,0xa0,0x43,0x00,0x00, +0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x02,0x03,0xaf,0xaf,0x00,0x28, +0x8f,0xaf,0x00,0x28,0x08,0x00,0x07,0xc2,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0xbd, +0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xaa,0x00,0x00,0x00,0x00, +0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x82,0x10,0x26,0x08,0x00,0x07,0x79, +0x00,0x02,0x28,0x0b,0x08,0x00,0x07,0x7f,0x00,0x00,0xb0,0x21,0x24,0x02,0x00,0x10, +0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x7d,0x00,0x07,0x17,0x83, +0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x7b,0x00,0x07,0x17,0x43,0x08,0x00,0x07,0x59, +0x30,0x5e,0x00,0x01,0x08,0x00,0x07,0x59,0x00,0x07,0xf7,0xc2,0x00,0x04,0x10,0x40, +0x27,0x83,0x80,0x1c,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21,0x94,0x44,0x00,0x00, +0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a,0x00,0x86,0x00,0x18, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x23,0x8c, +0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12,0x00,0x04,0x22,0x42, +0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b,0x24,0x82,0x00,0x60, +0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x00,0x44,0x20,0x04, +0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28,0x24,0x83,0x00,0x24, +0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14,0x00,0x60,0x20,0x21, +0x08,0x00,0x08,0xfa,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x24,0x28,0x00,0x80,0x80,0x21, +0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, +0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37,0x34,0x84,0x01,0x10, +0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21,0x8c,0x87,0x00,0x00, +0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f,0x34,0x42,0xf0,0x00, +0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08,0x32,0x02,0x00,0x07, +0x27,0x83,0x80,0xcc,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00, +0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21,0x32,0x02,0x00,0x0f, +0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x07, +0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xb4,0x50,0x00,0x43,0x10,0x21, +0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c,0x14,0x40,0x00,0x05, +0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21, +0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20,0x24,0x06,0x00,0x0e, +0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04,0x24,0x02,0x00,0x10, +0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01,0x14,0x60,0x00,0x02, +0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff,0x00,0xc5,0x10,0x21, +0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00,0x8f,0xbf,0x00,0x1c, +0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c,0x32,0x02,0x00,0x07, +0x27,0x83,0x80,0xc4,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x08,0x00,0x09,0x28, +0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80,0x27,0x82,0xb4,0x00, +0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c,0xaf,0xbf,0x00,0x44, +0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xb2,0x00,0x28, +0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21,0x8c,0xe6,0x00,0x00, +0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20, +0x24,0x42,0x25,0x84,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,0xa0,0xc3,0x00,0x12, +0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16,0xa4,0xc3,0x00,0x14, +0x27,0x83,0x90,0x00,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16,0x8c,0xe8,0x00,0x00, +0xaf,0xa4,0x00,0x48,0x27,0x82,0x90,0x04,0x95,0x11,0x00,0x14,0x00,0x00,0x00,0x00, +0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x82,0x10,0x21, +0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06,0x8e,0x45,0x00,0x08, +0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82,0x00,0x06,0x31,0x42, +0x27,0x82,0x90,0x10,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01,0x00,0x82,0x20,0x21, +0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18,0xaf,0xa6,0x00,0x1c, +0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06,0x14,0xe0,0x00,0x47, +0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x44, +0x02,0x71,0x10,0x21,0x93,0x90,0xbb,0xe9,0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c, +0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40,0x00,0x43,0x10,0x21, +0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04,0x02,0x71,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x00,0x80,0x80,0x21, +0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21, +0x0c,0x00,0x08,0xe3,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21,0x00,0x03,0x88,0x80, +0x00,0x40,0xa0,0x21,0x27,0x82,0x90,0x20,0x02,0x22,0x10,0x21,0x8c,0x44,0x00,0x00, +0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x04,0x25,0xc2, +0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40,0x03,0xc4,0x20,0x24, +0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x28, +0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48,0x27,0x82,0x90,0x08, +0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21,0xa4,0x54,0x00,0x04, +0x00,0xc0,0x38,0x21,0x0c,0x00,0x07,0x2f,0xad,0x03,0x00,0x00,0x7b,0xbe,0x02,0x3c, +0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c,0x8f,0xa6,0x00,0x18, +0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0x0a, +0xaf,0xa0,0x00,0x14,0x08,0x00,0x09,0xc6,0x02,0x82,0xa0,0x21,0x02,0x71,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00, +0x08,0x00,0x09,0xb2,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8,0xaf,0xb1,0x00,0x24, +0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, +0x24,0x42,0x27,0xa8,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38, +0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c,0x8f,0xb5,0x00,0x58, +0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20, +0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21,0x00,0x00,0xb8,0x21, +0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xb4,0x00,0x00,0x07,0x10,0x80, +0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80,0x00,0x65,0x18,0x21, +0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x2d, +0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03, +0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05,0x34,0x63,0x01,0x44, +0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00,0x8f,0xa3,0x00,0x4c, +0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x04, +0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09,0x24,0x05,0x00,0x14, +0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc, +0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48, +0x0c,0x00,0x07,0x0a,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x2c, +0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x17, +0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21,0x12,0x20,0xff,0xed, +0x02,0x20,0x10,0x21,0x27,0x83,0xb4,0x00,0x00,0x17,0x10,0x80,0x00,0x43,0x10,0x21, +0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28,0x80,0x86,0x00,0x12, +0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03,0x00,0x46,0x10,0x21, +0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21,0x0c,0x00,0x07,0x2f, +0xac,0x62,0x00,0x00,0x08,0x00,0x0a,0x2c,0xaf,0xd1,0x00,0x40,0x96,0x74,0x00,0x1a, +0x08,0x00,0x0a,0x3f,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08, +0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x1e,0xf3,0x02,0x00,0x28,0x21, +0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1e,0xf3, +0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0xed, +0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01,0x96,0x63,0x00,0x14, +0x96,0x44,0x00,0x14,0x27,0x85,0x90,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0,0x8c,0x46,0x00,0x08, +0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x00,0x06,0x17,0x02, +0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6,0x00,0x03,0x17,0x02, +0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b,0x24,0x11,0x00,0x02, +0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x5a, +0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00,0x96,0x49,0x00,0x14, +0x27,0x82,0x90,0x04,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0,0x01,0x49,0x18,0x21, +0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00, +0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42, +0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x14,0x40,0x00,0x41, +0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21,0x80,0x44,0x00,0x00, +0x27,0x82,0xb5,0x78,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80, +0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05, +0x27,0x84,0xb4,0xa0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2b, +0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00, +0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1, +0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21, +0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21, +0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21, +0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x0b, +0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x6f, +0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00, +0x02,0x02,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x42,0x00,0x16,0x00,0x60,0x28,0x21, +0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0a,0xc2, +0x30,0x54,0xff,0xff,0x08,0x00,0x0a,0xaa,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd, +0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0a,0xaa, +0x24,0x42,0x00,0x04,0x27,0x82,0x90,0x10,0x01,0x02,0x10,0x21,0x90,0x43,0x00,0x00, +0x08,0x00,0x0a,0xba,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14,0x02,0xc0,0xb8,0x21, +0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21,0x00,0x03,0x40,0x80, +0x00,0x40,0x50,0x21,0x27,0x82,0x90,0x04,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18, +0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04, +0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01, +0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21, +0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00,0x00,0x43,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xb5,0x70, +0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f,0x00,0x00,0x00,0x00, +0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x90,0x10,0x00,0x85,0x10,0x21, +0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42,0x01,0x49,0x10,0x21, +0x27,0x82,0x90,0x18,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00,0x27,0x82,0xb5,0x78, +0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23, +0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,0x27,0x84,0xb4,0xa0, +0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c,0x2c,0x64,0x00,0x0c, +0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, +0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1,0x14,0x80,0x00,0x06, +0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00, +0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,0x27,0x83,0x90,0x10, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03, +0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x0c, +0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x6f, +0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff,0x92,0x62,0x00,0x16, +0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x62,0x00,0x16, +0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0b,0x31, +0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0x19,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd, +0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0b,0x19, +0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x90,0x43,0x00,0x00, +0x08,0x00,0x0b,0x29,0xa0,0x43,0x00,0x03,0x27,0x85,0x90,0x10,0x08,0x00,0x0b,0x45, +0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26,0x08,0x00,0x0a,0x7a, +0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x7f, +0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0, +0x24,0x42,0x2d,0x54,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05,0xaf,0xb3,0x00,0x24, +0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28,0xaf,0xb0,0x00,0x18, +0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00,0x00,0x80,0x90,0x21, +0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10,0x12,0x22,0x00,0xcf, +0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1,0x24,0x02,0x00,0x12, +0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad,0xae,0x43,0x00,0x40, +0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00,0x3c,0x03,0x00,0x02, +0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43,0x10,0x40,0x00,0x05, +0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x92, +0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02, +0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3,0x14,0x40,0x00,0x86, +0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21,0x26,0x22,0x00,0x01, +0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb,0x24,0x03,0x00,0x02, +0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03,0x10,0x40,0x00,0x58, +0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b,0x02,0x40,0x20,0x21, +0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x28, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, +0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x02,0x40,0x20,0x21, +0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, +0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, +0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec,0x02,0x00,0x10,0x21, +0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05,0x02,0x40,0x20,0x21, +0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, +0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, +0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc,0x02,0x00,0x10,0x21, +0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03,0x02,0x40,0x20,0x21, +0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, +0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, +0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc,0x02,0x00,0x10,0x21, +0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02,0x02,0x40,0x20,0x21, +0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, +0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, +0x08,0x00,0x0b,0x9b,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24, +0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x24, +0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08,0x16,0x62,0xff,0xa8, +0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30,0x24,0x05,0x00,0x03, +0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa2,0x00,0x14, +0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c, +0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10, +0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x2c, +0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01, +0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14, +0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x57,0x24,0x04,0x00,0x01, +0x08,0x00,0x0b,0x85,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40,0xae,0x40,0x00,0x34, +0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71, +0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69,0x00,0x00,0x00,0x00, +0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x08,0x00,0x0b,0x7d,0x00,0x00,0x00,0x00, +0x02,0x40,0x20,0x21,0x0c,0x00,0x09,0x61,0x02,0x20,0x28,0x21,0x08,0x00,0x0b,0x71, +0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x4a, +0x00,0x00,0x00,0x00,0x8f,0x82,0xb4,0x48,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a, +0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x3c, +0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d,0x24,0x02,0x00,0x12, +0x8f,0x82,0xb4,0x44,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00, +0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x38,0x8e,0x42,0x00,0x34, +0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11,0x8f,0x82,0xb4,0x40, +0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b, +0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x31,0x08,0x3c,0x08,0xb0,0x03, +0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00,0xaf,0xbf,0x00,0x18, +0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21,0x24,0x11,0x00,0x0a, +0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a,0x30,0x63,0x00,0x01, +0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40,0x02,0x20,0x40,0x21, +0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21, +0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06,0x02,0x23,0x80,0x21, +0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x02,0x11,0x18,0x21, +0x08,0x00,0x0c,0x64,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28, +0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb5,0x00,0x24, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c,0x3c,0x06,0xb0,0x03, +0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, +0x27,0x82,0x90,0x04,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18,0x3c,0x02,0x80,0x00, +0x24,0x42,0x31,0xb8,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08,0x27,0x82,0x90,0x08, +0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43,0x32,0x10,0x00,0x01, +0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21,0x02,0x20,0x28,0x21, +0x0c,0x00,0x0c,0x42,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21,0x02,0x00,0x28,0x21, +0x24,0x06,0x00,0x14,0x0c,0x00,0x08,0xe3,0x00,0x40,0xa0,0x21,0x86,0x43,0x00,0x0c, +0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x80,0x43,0x00,0x06, +0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00,0x24,0x64,0x00,0x03, +0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09,0x00,0x03,0x18,0x80, +0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14,0x34,0xe7,0x01,0x20, +0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11,0x02,0xa3,0xa8,0x21, +0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00,0x00,0x03,0x1c,0x02, +0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28,0x7b,0xb4,0x01,0x3c, +0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, +0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00,0x8e,0xa4,0x00,0x08, +0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c,0x00,0x00,0x00,0x00, +0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21,0xac,0xe3,0x00,0x00, +0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02,0x08,0x00,0x0c,0xb6, +0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c,0x00,0x80,0x90,0x21, +0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, +0x27,0x82,0x90,0x04,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18,0x3c,0x02,0x80,0x00, +0x34,0xa5,0x00,0x20,0x24,0x42,0x33,0x34,0x27,0x83,0x90,0x08,0xac,0xa2,0x00,0x00, +0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07,0x34,0x42,0x01,0x00, +0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04,0x24,0x02,0x00,0x10, +0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43,0x30,0x84,0x00,0x01, +0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40,0x02,0x00,0x10,0x21, +0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x08,0xe3,0x30,0x50,0x00,0xff, +0x86,0x44,0x00,0x0c,0x27,0x85,0x90,0x10,0x3c,0x06,0xb0,0x09,0x00,0x04,0x18,0xc0, +0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x80,0x64,0x00,0x06, +0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03,0x28,0x83,0x00,0x00, +0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80,0xa4,0xc2,0x00,0x00, +0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x10, +0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x14, +0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08,0x3c,0x06,0xb0,0x09, +0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21,0x34,0xc6,0x01,0x20, +0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x24, +0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a,0x3c,0x03,0xb0,0x09, +0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, +0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x90,0x18,0x8f,0xbf,0x00,0x1c, +0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x3c,0x05,0xb0,0x09, +0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, +0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0xaf,0xb0,0x00,0x10, +0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x34,0xc0,0x00,0x05,0x2c,0x43, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x10,0xa0,0x00,0x05, +0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0xb6, +0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c,0x00,0x00,0x10,0x21, +0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09,0x10,0x40,0x00,0x89, +0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79,0x2a,0x02,0x00,0x03, +0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x02,0x00,0x5a, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08,0x3c,0x03,0x80,0x00, +0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11,0x92,0x27,0x00,0x11, +0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a,0x24,0x02,0x00,0x12, +0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x83,0x00,0x14, +0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x40, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03,0xa2,0x23,0x00,0x10, +0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x82,0x23,0x00,0x12, +0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x30,0x42,0x00,0x01, +0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18,0xa2,0x23,0x00,0x12, +0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01,0x96,0x23,0x00,0x0c, +0x27,0x84,0x90,0x10,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,0x3c,0x02,0xb0,0x00, +0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00,0x90,0x62,0x00,0x04, +0xa2,0x20,0x00,0x15,0xa3,0x80,0x8b,0xd4,0x24,0x02,0x00,0x01,0x8f,0xbf,0x00,0x18, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x0c,0xcd, +0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x0d,0x7d,0x00,0x07,0x16,0x00, +0x0c,0x00,0x0c,0x6e,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c,0x27,0x84,0x90,0x08, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x20,0x21, +0x90,0x85,0x00,0x07,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa2,0x25,0x00,0x13, +0x90,0x83,0x00,0x07,0x08,0x00,0x0d,0x95,0xa0,0x43,0x00,0x02,0x92,0x26,0x00,0x0a, +0x08,0x00,0x0d,0x5e,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24,0x00,0x00,0x00,0x00, +0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07,0xa2,0x22,0x00,0x0a, +0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x04, +0x08,0x00,0x0d,0xaf,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b,0x3c,0x02,0xb0,0x05, +0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07,0xa2,0x24,0x00,0x08, +0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f,0xae,0x20,0x00,0x2c, +0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x06,0x08,0x00,0x0d,0xbe,0xa2,0x20,0x00,0x0a, +0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01,0x10,0x44,0x00,0x07, +0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2b, +0xae,0x20,0x00,0x28,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x05,0x08,0x00,0x0d,0xca, +0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41,0x10,0x40,0x00,0x09, +0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b,0x3c,0x02,0xb0,0x05, +0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51, +0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10, +0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51,0xae,0x20,0x00,0x34, +0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51, +0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03,0x24,0x03,0x00,0x01, +0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02,0xa2,0x22,0x00,0x0a, +0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x07, +0x08,0x00,0x0d,0xf0,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xb4,0x40,0xae,0x20,0x00,0x34, +0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x32,0x10,0x00,0xff,0x08,0x00,0x0d,0x42, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x37,0xf4, +0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15,0x3c,0x06,0xb0,0x05, +0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x8b,0xd4,0x00,0x00,0x00,0x00, +0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42, +0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28,0x8c,0x82,0x00,0x2c, +0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43,0x30,0x63,0x00,0x01, +0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08, +0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, +0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08, +0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd8, +0x34,0x63,0x00,0x20,0x24,0x42,0x38,0x84,0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x1c, +0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a,0x27,0x83,0xb4,0x00, +0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00, +0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04,0xa2,0x20,0x00,0x15, +0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x12, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x12, +0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20,0x00,0x43,0x10,0x21, +0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0xdf, +0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20, +0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x45, +0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04,0x00,0x00,0x00,0x00, +0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a,0xa2,0x02,0x00,0x17, +0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4,0x10,0x60,0x00,0x03, +0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x11,0x00,0x00,0x05, +0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02, +0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x08, +0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x02,0x00,0x14, +0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, +0x96,0x02,0x00,0x00,0x08,0x00,0x0e,0x6c,0xa6,0x02,0x00,0x14,0x92,0x07,0x00,0x0a, +0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x58, +0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00, +0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, +0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, +0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xc3,0x20,0x24, +0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, +0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x58, +0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x8c, +0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05, +0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x52, +0xa2,0x20,0x00,0x07,0x08,0x00,0x0e,0x52,0xa2,0x20,0x00,0x06,0x08,0x00,0x0e,0x52, +0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x69, +0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09,0x92,0x25,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x3b, +0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, +0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24, +0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x90,0x04,0x00,0xa3,0x18,0x21, +0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01,0x93,0x82,0x8b,0x71, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a,0x24,0x05,0x00,0x24, +0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66,0x02,0x00,0x20,0x21, +0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7,0x08,0x00,0x0e,0x49, +0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12,0x27,0x82,0x90,0x00, +0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x3c,0x04,0x00,0x80,0x96,0x26,0x00,0x0c, +0x08,0x00,0x0e,0xc9,0x00,0x06,0x2c,0x00,0x27,0x83,0x90,0x10,0x27,0x82,0x90,0x18, +0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05, +0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa2,0x00,0x10, +0x96,0x26,0x00,0x0c,0x08,0x00,0x0e,0xc3,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xcd, +0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f, +0x24,0x02,0x00,0x80,0x08,0x00,0x0e,0xb2,0x00,0xa2,0x10,0x07,0x86,0x26,0x00,0x0c, +0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78,0x94,0x47,0x00,0x00, +0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21,0x3c,0x04,0xb0,0x09, +0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x90,0x04,0x00,0x02,0x10,0x80, +0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18,0xae,0x25,0x00,0x20, +0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21,0x0c,0x00,0x0f,0x19, +0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c,0x8e,0x27,0x00,0x20, +0x02,0x20,0x20,0x21,0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x08,0x00,0x0e,0x49, +0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x0e,0x49,0xa2,0x22,0x00,0x09, +0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00,0x08,0x00,0x0e,0x49, +0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24,0x00,0x80,0x70,0x21, +0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x3c,0x64,0xf1,0x43,0x00,0x06, +0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21,0xac,0x82,0x00,0x00, +0x27,0x85,0x90,0x10,0x27,0x82,0x90,0x0f,0x27,0xbd,0xff,0xf8,0x00,0x62,0x60,0x21, +0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc,0x00,0x00,0x78,0x21, +0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00,0x80,0x48,0x00,0x04, +0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x90,0x04,0xa3,0xa7,0x00,0x00, +0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff,0x00,0x48,0x40,0x0b, +0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06,0x30,0x63,0x00,0x08, +0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00,0x27,0x82,0x90,0x18, +0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50,0x30,0xe5,0x00,0xff, +0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24,0x90,0x49,0x00,0x00, +0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04,0x10,0xa2,0x00,0x9d, +0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c,0x10,0x40,0x00,0x02, +0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff,0x00,0x04,0x10,0x40, +0x27,0x83,0xbb,0x1c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21,0x90,0x47,0x00,0x00, +0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00,0x10,0x60,0x00,0x02, +0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00,0x91,0x65,0x00,0x00, +0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b,0x10,0x40,0x00,0x0e, +0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21,0x30,0xa2,0x00,0x0f, +0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21,0x27,0x83,0xbb,0x1c, +0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05, +0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xb4,0xa8,0x00,0x43,0x10,0x21, +0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c,0x14,0x60,0x00,0x06, +0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00, +0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x0f,0x7a,0xa1,0x82,0x00,0x00, +0x8f,0x8d,0x81,0x5c,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21,0x00,0x06,0x74,0x82, +0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0xe0,0x10,0x21, +0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff,0xa3,0xa2,0x00,0x00, +0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23,0x00,0x64,0x18,0x21, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xb4,0xa8,0x00,0x44,0x10,0x21, +0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00,0x00,0x0a,0x1c,0x00, +0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00, +0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0x00,0x33, +0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80, +0x00,0x49,0x10,0x23,0x27,0x83,0xb5,0x78,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, +0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x64,0xc0,0x24, +0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f,0x10,0x40,0x00,0x0f, +0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x00,0x00,0x44,0x10,0x21, +0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41,0x14,0x60,0x00,0x04, +0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00,0x30,0xe2,0x00,0xff, +0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21,0x00,0x18,0x10,0x40, +0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21,0x24,0x42,0x00,0x04, +0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00, +0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b,0x14,0x60,0xff,0xad, +0x30,0xe2,0x00,0xff,0x08,0x00,0x0f,0x67,0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0xc8, +0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73, +0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0x55,0x00,0x00,0x00,0x00,0x00,0x0a,0x1c,0x00, +0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00,0x08,0x00,0x0f,0x35, +0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, +0x24,0x42,0x40,0x04,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0, +0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28, +0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38, +0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c,0x27,0x93,0x90,0x04, +0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20, +0x24,0x42,0x40,0x1c,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08,0x27,0x95,0x90,0x10, +0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21,0x90,0x71,0x00,0x00, +0x0c,0x00,0x0f,0x19,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21,0x00,0x10,0x14,0x42, +0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82,0x02,0x80,0x28,0x21, +0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c,0x30,0x50,0x00,0x01, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21, +0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, +0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21,0x8c,0xc7,0x00,0x18, +0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04,0x84,0x46,0x00,0x06, +0x00,0x03,0x19,0x42,0x0c,0x00,0x08,0xe3,0x30,0x73,0x00,0x01,0x00,0x40,0x88,0x21, +0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10,0x02,0x00,0x30,0x21, +0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, +0x00,0x03,0x18,0x80,0x27,0x82,0x90,0x08,0x00,0x62,0x18,0x21,0xa4,0x71,0x00,0x04, +0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c, +0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x86,0xc3,0x00,0x0c, +0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06,0x00,0x00,0x00,0x00, +0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21,0x00,0x07,0x38,0x43, +0x00,0x07,0x38,0x40,0x0c,0x00,0x09,0x0a,0x03,0xc7,0x38,0x21,0x08,0x00,0x10,0x48, +0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0, +0x34,0x63,0x00,0x20,0x24,0x42,0x41,0xa4,0xaf,0xb2,0x00,0x20,0xac,0x62,0x00,0x00, +0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18, +0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04,0x94,0x45,0x00,0x00, +0x00,0x03,0x18,0x80,0x27,0x82,0xb4,0x00,0x00,0x62,0x18,0x21,0x30,0xa6,0xff,0xff, +0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff,0x00,0x06,0x32,0x02, +0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12,0x00,0x80,0x90,0x21, +0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a,0x10,0x40,0x00,0x14, +0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20, +0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12,0x92,0x22,0x00,0x16, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x28, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, +0x0c,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00, +0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21,0x94,0x87,0x00,0x0c, +0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03, +0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, +0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x90,0x20,0x00,0x03,0x18,0x80, +0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x08,0x00,0xa2,0x10,0x21, +0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x90,0x10,0x00,0x08,0x1d,0x02, +0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01,0x01,0x24,0x30,0x0b, +0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02,0x00,0x08,0x14,0x02, +0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21,0x15,0x40,0x00,0x11, +0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa8,0x00,0xff, +0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10,0x3c,0x04,0xb0,0x05, +0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x01,0x02,0x10,0x04, +0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c,0x00,0x00,0x00,0x00, +0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x27,0x84,0x90,0x10, +0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00, +0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21,0x94,0x82,0x00,0x00, +0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06,0x00,0x02,0x3c,0x03, +0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21,0x34,0xe2,0x08,0x00, +0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03, +0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00,0x82,0x42,0x00,0x10, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x86,0x43,0x00,0x0c, +0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04,0x92,0x23,0x00,0x16, +0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x10,0x9c,0xa2,0x23,0x00,0x16, +0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x05, +0x86,0x45,0x00,0x0c,0x0c,0x00,0x1e,0xea,0x02,0x20,0x20,0x21,0x10,0x40,0x00,0x5a, +0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff, +0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05, +0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04, +0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08, +0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33,0x24,0x02,0x00,0x01, +0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0c, +0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x08,0x00,0x10,0x97, +0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x10,0x97,0xa6,0x22,0x00,0x14, +0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x11,0x26,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06, +0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0, +0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80, +0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00, +0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04, +0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b, +0x08,0x00,0x11,0x26,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b, +0x08,0x00,0x11,0x49,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02, +0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca,0x00,0x00,0x00,0x00, +0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x07,0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x06, +0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe,0x3c,0x04,0xb0,0x05, +0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80, +0x08,0x00,0x11,0x18,0x00,0xa2,0x10,0x07,0x0c,0x00,0x10,0x07,0x02,0x40,0x20,0x21, +0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, +0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99,0x2c,0xc2,0x00,0x10, +0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, +0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00, +0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x80, +0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c,0x27,0x93,0x90,0x04, +0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80, +0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64,0x00,0x00,0x30,0x21, +0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18,0x93,0x82,0x8b,0x71, +0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42,0x14,0x40,0x00,0x4d, +0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66, +0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14,0x30,0xc5,0xff,0xff, +0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b, +0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x62,0x00,0x04, +0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x1b,0x66,0x30,0x50,0x00,0x01, +0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff,0x92,0x22,0x00,0x04, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17, +0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, +0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x30,0x42,0x00,0xc3, +0x96,0x22,0x00,0x00,0x08,0x00,0x11,0xbd,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0xb8, +0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff,0x00,0x05,0x18,0xc0, +0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x27,0x84,0x90,0x00, +0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80,0x8c,0x45,0x00,0x08, +0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00,0x00,0xa2,0x38,0x24, +0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, +0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xb8, +0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xdc, +0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06,0x00,0x00,0x28,0x12, +0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x00,0x00,0x20,0x21, +0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x9a,0x00,0x07,0x2c,0x00,0x27,0x83,0x90,0x10, +0x27,0x82,0x90,0x18,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00, +0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01,0x0c,0x00,0x21,0x9a, +0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x8d,0x00,0x07,0x1c,0x00, +0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03, +0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x07, +0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x06,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x05, +0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, +0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x11,0x75,0x00,0xa2,0x10,0x07, +0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, +0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x10,0xd0,0x00,0xa2,0x10,0x07, +0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18, +0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x0f,0x19,0x00,0x00,0x00,0x00, +0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21,0x00,0x00,0x38,0x21, +0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00,0x14,0x60,0xfe,0x6b, +0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x40, +0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04,0x00,0x00,0x00,0x00, +0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a,0xa2,0x22,0x00,0x17, +0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10,0x00,0x00,0x00,0x00, +0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x16, +0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03,0xa2,0x22,0x00,0x16, +0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50,0x00,0x00,0x00,0x00, +0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x34,0x42,0x00,0x02,0x96,0x22,0x00,0x00, +0x08,0x00,0x12,0x3f,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a,0x00,0x00,0x00,0x00, +0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x38,0xa2,0x20,0x00,0x17, +0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0, +0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80, +0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, +0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08, +0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02, +0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x38,0xa2,0x23,0x00,0x17, +0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x67,0x00,0x00,0x00,0x00, +0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03, +0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x07, +0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x06,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x05, +0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0xa2,0x18,0x24, +0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02,0x24,0x02,0x00,0x01, +0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xfd, +0x00,0xa4,0x10,0x2b,0x08,0x00,0x12,0x82,0x00,0x00,0x00,0x00,0x30,0x82,0xff,0xff, +0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x90,0x10,0x00,0x03,0x18,0x80, +0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00,0x3c,0x03,0xb0,0x00, +0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08,0x00,0x43,0x10,0x21, +0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00,0xaf,0xbf,0x00,0x1c, +0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x14,0x40,0x00,0x41, +0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03,0x8e,0x10,0x00,0x00, +0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03,0x32,0x02,0x00,0x20, +0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x06, +0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x67,0x00,0xff, +0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x8f,0xe0,0x00,0x40,0x30,0x21, +0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01,0x24,0x42,0x00,0x02, +0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a,0xa4,0xa2,0x00,0x08, +0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xb4,0x00,0x24,0x11,0x00,0x12, +0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00, +0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24,0x3c,0x01,0xb0,0x03, +0x0c,0x00,0x13,0x1c,0xac,0x30,0x00,0x00,0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00, +0x8f,0x85,0x8f,0xe0,0x08,0x00,0x12,0xbe,0x00,0x00,0x00,0x00,0x24,0x02,0xff,0x95, +0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30,0x3c,0x01,0xb0,0x03, +0xac,0x30,0x00,0x00,0x0c,0x00,0x12,0xe5,0xac,0x60,0x00,0x00,0x08,0x00,0x12,0xa8, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50,0x08,0x00,0x12,0xa8, +0xac,0x46,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0x94,0x3c,0x0b,0xb0,0x03, +0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00,0x3c,0x09,0x80,0x01, +0x25,0x29,0x03,0x50,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00, +0x25,0x4a,0x4b,0xbc,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0xb0,0x06, +0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00, +0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x01, +0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0xf8, +0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00,0xac,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x24,0x3c,0x0b,0xb0,0x03, +0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00,0x3c,0x03,0x80,0x01, +0x24,0x63,0x03,0x50,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00,0x00,0x00,0x00,0x00, +0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x43,0x08,0x2a, +0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0x1c,0x00,0x00,0x00,0x00, +0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x70,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, +0x3c,0x02,0x80,0x01,0x24,0x42,0x03,0x50,0x3c,0x03,0x80,0x01,0x24,0x63,0x3f,0x24, +0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08,0xac,0x40,0x00,0x0c, +0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00, +0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xb0,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, +0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x8b,0xe0,0x00,0x00,0x00,0x00, +0x27,0x9d,0x8f,0xc8,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xd4,0x3c,0x0b,0xb0,0x03, +0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00,0x00,0x00,0x00,0x00, +0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x15,0x62, +0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03,0x00,0x04,0x30,0x40, +0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0,0x24,0x03,0xff,0xff, +0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00,0xaf,0xbf,0x00,0x18, +0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x10,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23,0x3c,0x03,0xb0,0x0a, +0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x13,0x99,0x02,0x20,0x20,0x21, +0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8, +0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff,0xaf,0xb3,0x00,0x1c, +0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x00,0xc0,0x98,0x21, +0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x10,0x40, +0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23,0x3c,0x03,0xb0,0x0a, +0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21,0x24,0x05,0x00,0x01, +0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd,0x3c,0x02,0xb0,0x0a, +0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00,0x0c,0x00,0x13,0x99, +0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24,0x00,0x53,0x10,0x04, +0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01,0x8e,0x22,0x10,0x00, +0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20, +0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, +0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23,0x3c,0x04,0xb0,0x0a, +0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01,0x8c,0x62,0x10,0x00, +0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x87, +0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06,0x30,0x42,0x00,0x01, +0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x20, +0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, +0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21,0x00,0xa0,0x80,0x21, +0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00,0x00,0x10,0x1c,0x00, +0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05,0x24,0x63,0x16,0x09, +0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24,0x3c,0x06,0xb0,0x05, +0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00,0x34,0xc6,0x02,0x28, +0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24,0xa0,0xc2,0x00,0x00, +0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01, +0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01, +0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c,0xa0,0x80,0x00,0x50, +0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x14, +0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20,0xac,0x80,0x00,0x24, +0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30,0xa0,0x80,0x00,0x31, +0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c,0xac,0x82,0x00,0x10, +0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x4c, +0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00,0x3c,0x02,0x12,0x00, +0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b,0x24,0x02,0xff,0x80, +0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00,0x3c,0x04,0xb0,0x03, +0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01,0x3c,0x06,0x45,0x67, +0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04,0x34,0xc6,0x89,0xaa, +0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09,0x3c,0x07,0x01,0x23, +0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00,0x27,0xbd,0xff,0xe0, +0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09,0xac,0x26,0x00,0x00, +0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c,0x24,0x02,0xcd,0xef, +0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09,0xad,0x67,0x00,0x00, +0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18,0xaf,0xb5,0x00,0x14, +0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08,0xaf,0xb1,0x00,0x04, +0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22,0x35,0xce,0x00,0x14, +0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab,0x3c,0x10,0xb0,0x09, +0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09,0x3c,0x14,0xb0,0x09, +0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09,0xad,0xa8,0x00,0x00, +0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18,0x35,0x29,0xcd,0xee, +0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24,0x36,0x73,0x00,0x28, +0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34,0x36,0xf7,0x00,0x38, +0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00,0xae,0x23,0x00,0x00, +0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04,0xae,0x63,0x00,0x00, +0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c,0xae,0xa3,0x00,0x00, +0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14,0xae,0xe3,0x00,0x00, +0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c,0xa7,0x03,0x00,0x00, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x51,0x48,0xac,0x62,0x00,0x00,0x8c,0x83,0x00,0x34, +0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x04,0x00,0x80,0x28,0x21, +0x8c,0x86,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0xc2,0x00,0xf7,0x00,0x00,0x00,0x00, +0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x4f,0x24,0x02,0x00,0x06, +0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xdd,0xac,0xa2,0x00,0x2c,0x24,0x02,0x00,0x01, +0x10,0xc2,0x00,0xdc,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0xca, +0x00,0x00,0x00,0x00,0x8c,0xa7,0x00,0x04,0x24,0x02,0x00,0x02,0x10,0xe2,0x00,0xc0, +0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x09, +0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xa2,0x00,0x14, +0x24,0x02,0x00,0x01,0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x14, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x61,0x00,0x19,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2e, +0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x12, +0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0c,0x3c,0x02,0xb0,0x03,0x80,0xa2,0x00,0x50, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,0x3c,0x02,0xb0,0x03,0x14,0xc0,0x00,0x07, +0x34,0x42,0x00,0x3f,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00, +0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00, +0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x7f,0x3c,0x03,0xb0,0x05,0x80,0xa2,0x00,0x31, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, +0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24, +0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x00, +0x8c,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c, +0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24,0x14,0x60,0xff,0xf2, +0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, +0x8c,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10,0x3c,0x02,0xb0,0x03, +0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0xac,0xa2,0x00,0x0c, +0x90,0xa3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03,0x08,0x00,0x14,0xb2, +0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80,0x90,0x44,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03,0x10,0x60,0x00,0x15, +0xa0,0xa4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x02, +0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x8c,0xa2,0x00,0x0c,0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04,0xac,0xa2,0x00,0x10, +0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d,0xac,0xa2,0x00,0x00, +0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10,0x03,0xe0,0x00,0x08, +0xac,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x38,0x24,0x04,0x00,0x01,0x10,0x64,0x00,0x2d, +0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x10, +0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,0x00,0x00,0x00,0x00,0xac,0xa0,0x00,0x38, +0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,0x10,0xe4,0x00,0x07,0x24,0x02,0x00,0x03, +0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x0b,0xac,0xa3,0x00,0x00, +0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,0x08,0x00,0x15,0x04,0xac,0xa2,0x00,0x00, +0x10,0xe4,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x0c,0xac,0xa2,0x00,0x00, +0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x38,0x10,0xe4,0x00,0x0e, +0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,0xac,0xa2,0x00,0x18,0x24,0x02,0x00,0x02, +0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,0x08,0x00,0x15,0x0d,0x24,0x02,0x00,0x01, +0x08,0x00,0x15,0x1a,0xac,0xa0,0x00,0x00,0x24,0x02,0x00,0x03,0x08,0x00,0x15,0x1a, +0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,0xac,0xa2,0x00,0x38,0x03,0xe0,0x00,0x08, +0xac,0xa3,0x00,0x00,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x7d,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0x78,0x00,0x00,0x00,0x00, +0x10,0xc0,0xff,0x81,0x24,0x02,0x00,0x0e,0x08,0x00,0x14,0xa7,0x00,0x00,0x00,0x00, +0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3e,0x24,0x02,0x00,0x04, +0x08,0x00,0x14,0xb2,0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20,0x00,0x00,0x00,0x00, +0x10,0x40,0xff,0x75,0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff, +0x00,0x60,0x10,0x21,0x14,0x40,0xff,0x2b,0xa4,0xa3,0x00,0x20,0x08,0x00,0x14,0xb2, +0x24,0x02,0x00,0x06,0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x66, +0x24,0x02,0x00,0x05,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x1b,0xac,0xa2,0x00,0x1c, +0x08,0x00,0x14,0xb2,0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x56, +0x24,0x02,0x00,0x06,0x08,0x00,0x14,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0a, +0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10, +0x27,0x90,0x86,0x58,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, +0x0c,0x00,0x29,0xd5,0xaf,0xb1,0x00,0x14,0xaf,0x90,0x8f,0xe0,0x48,0x02,0x00,0x00, +0x0c,0x00,0x13,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x1f,0x02,0x00,0x20,0x21, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0xa3,0x83,0x8f,0xe4,0x0c,0x00,0x00,0x34,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0xfb, +0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x59,0x00,0x00,0x00,0x00, +0x93,0x84,0x80,0x10,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18, +0x0c,0x00,0x06,0xe5,0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x39,0x00,0x00,0x00,0x00, +0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x27,0x82,0x89,0x4c, +0xaf,0x82,0x84,0x80,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00, +0x34,0x84,0x01,0x68,0x34,0xa5,0x01,0x40,0x24,0x02,0xc8,0x80,0x24,0x03,0x00,0x0a, +0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, +0x8f,0x85,0x84,0x40,0xaf,0x86,0x84,0x38,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x58,0x8c,0x43,0x00,0x00,0x2c,0xa4,0x00,0x11, +0x34,0x63,0x01,0x00,0xac,0x43,0x00,0x00,0x10,0x80,0xff,0xfa,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x00,0x05,0x10,0x80,0x24,0x63,0x02,0x00,0x00,0x43,0x10,0x21, +0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00, +0x27,0x84,0x84,0x98,0x0c,0x00,0x26,0x8e,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40, +0x0c,0x00,0x14,0x52,0x00,0x00,0x00,0x00,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01, +0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x40,0x8f,0x82,0x84,0x74, +0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9d, +0x3c,0x02,0xb0,0x03,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x0d,0x00,0x00,0x00,0x00, +0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x28,0xdd, +0x00,0x00,0x00,0x00,0xa3,0x82,0x84,0x71,0x8f,0x82,0x84,0x74,0xaf,0x80,0x84,0x40, +0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21, +0x27,0x84,0x86,0x58,0x0c,0x00,0x19,0x5b,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, +0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x44, +0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0x00,0x20, +0x24,0x02,0x00,0x01,0x8f,0x84,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x20, +0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x54,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x01, +0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x03, +0x24,0x02,0x00,0x01,0xaf,0x82,0x84,0x44,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb6, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21, +0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c,0x14,0x40,0xff,0xf5,0x24,0x02,0x00,0x01, +0x08,0x00,0x15,0xe1,0x3c,0x03,0xb0,0x09,0x27,0x84,0x86,0x58,0x0c,0x00,0x1a,0xd1, +0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec, +0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0xff,0xe4, +0x24,0x02,0x00,0x02,0x8f,0x84,0x84,0x48,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x12, +0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x04, +0x08,0x00,0x15,0xed,0x24,0x02,0x00,0x02,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e, +0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff, +0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf4,0x00,0x00,0x00,0x00, +0x08,0x00,0x15,0xfc,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c, +0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c, +0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x1d,0x24,0x02,0x00,0x02, +0x27,0x84,0x89,0x18,0x0c,0x00,0x0b,0x55,0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44, +0xaf,0x82,0x84,0x5c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a,0xaf,0x83,0x84,0x44, +0x14,0x40,0xff,0xad,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x58,0xaf,0x80,0x84,0x40, +0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x84,0x48,0x93,0x82,0x89,0x66, +0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x6c,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05, +0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,0x00,0x64,0x18,0x24, +0x10,0x60,0xff,0x65,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa0, +0x8c,0x43,0x00,0x00,0x3c,0x04,0x80,0x00,0xaf,0x80,0x89,0x40,0x24,0x63,0x00,0x01, +0xac,0x43,0x00,0x00,0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,0xaf,0x80,0x89,0x3c, +0xaf,0x80,0x89,0x44,0xaf,0x80,0x89,0x48,0xaf,0x80,0x89,0x54,0xaf,0x80,0x89,0x4c, +0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20,0xaf,0x82,0x84,0x5c,0x8f,0x85,0x84,0x5c, +0x27,0x84,0x89,0x18,0x0c,0x00,0x0d,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00, +0xa3,0x82,0x84,0x70,0xaf,0x80,0x84,0x5c,0x10,0x60,0xff,0x8e,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60, +0x10,0x40,0x00,0x04,0x24,0x04,0x00,0x02,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xfd, +0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x06,0x27,0x84,0x84,0x40, +0x27,0x85,0x89,0x18,0x0c,0x00,0x0d,0xfd,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x64, +0xaf,0x80,0x84,0x6c,0x14,0x40,0x00,0x19,0x00,0x40,0x18,0x21,0x8f,0x82,0x84,0x68, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x02,0x8f,0x83,0x84,0x48, +0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x3c,0x02,0x40,0x00,0x8f,0x83,0x84,0x44, +0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x06, +0xaf,0x85,0x84,0x40,0x24,0x04,0x00,0x03,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xb6, +0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05,0xac,0x22,0x00,0x00, +0xaf,0x80,0x84,0x40,0x08,0x00,0x16,0x96,0x24,0x04,0x00,0x03,0x10,0x60,0x00,0x10, +0x00,0x00,0x00,0x00,0x27,0x85,0x89,0x18,0x27,0x84,0x84,0x40,0x0c,0x00,0x0e,0x21, +0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44,0x24,0x02,0x00,0x01,0xa3,0x80,0x84,0x70, +0xaf,0x80,0x84,0x48,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x04, +0xaf,0x85,0x84,0x40,0xaf,0x80,0x84,0x64,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, +0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00, +0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44, +0xa3,0x80,0x84,0x70,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0x00,0x03, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x68, +0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40,0x27,0x85,0x89,0x18, +0x0c,0x00,0x0e,0x21,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44,0xa3,0x80,0x84,0x70, +0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0xfe,0xeb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, +0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xc6, +0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x29,0x73,0x00,0x00,0x00,0x00, +0x08,0x00,0x15,0xc5,0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x05,0x00,0x00,0x00,0x00, +0x0c,0x00,0x26,0xff,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x11,0x00,0x00,0x00,0x00, +0x93,0x83,0xbc,0x18,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x2b,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x83,0xbc,0x10,0x8f,0x82,0xbc,0x14, +0x00,0x83,0x18,0x23,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x23,0x3c,0x02,0xb0,0x03, +0x24,0x04,0x05,0xa0,0x34,0x42,0x01,0x18,0x8c,0x42,0x00,0x00,0x0c,0x00,0x06,0xd1, +0x00,0x00,0x00,0x00,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0x84,0x02, +0x30,0x51,0xff,0xff,0x24,0x04,0x05,0xa8,0x00,0x02,0x94,0x02,0x0c,0x00,0x06,0xd1, +0x3a,0x10,0xff,0xff,0x3a,0x31,0xff,0xff,0x30,0x42,0xff,0xff,0x2e,0x10,0x00,0x01, +0x2e,0x31,0x00,0x01,0x3a,0x52,0xff,0xff,0x02,0x11,0x80,0x25,0x2e,0x52,0x00,0x01, +0x38,0x42,0xff,0xff,0x02,0x12,0x80,0x25,0x2c,0x42,0x00,0x01,0x02,0x02,0x80,0x25, +0x16,0x00,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x05,0x6e, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0xaf,0x83,0xbc,0x10,0x0c,0x00,0x01,0xe9,0x00,0x00,0x00,0x00, +0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21, +0x27,0x90,0xb4,0x00,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, +0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6, +0x26,0x10,0x00,0x04,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x28,0x21, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x84,0x38, +0x00,0x04,0x19,0xc2,0x00,0x02,0x11,0xc2,0x10,0x62,0xff,0xf6,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02,0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05, +0xaf,0x84,0x84,0x38,0x30,0x63,0x00,0xff,0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21, +0x36,0x52,0x02,0x2c,0x27,0x90,0xb4,0x00,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06, +0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x38, +0x0c,0x00,0x1e,0x94,0x02,0x60,0x30,0x21,0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0xff,0x14,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01, +0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec,0x26,0x10,0x00,0x04,0x08,0x00,0x17,0x21, +0x00,0x00,0x00,0x00,0x8f,0x84,0x84,0x4c,0x27,0x85,0x89,0x18,0x0c,0x00,0x17,0xa4, +0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x4c,0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0xa5, +0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x05,0x3c,0x02,0xb0,0x03, +0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00,0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x08, +0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18,0x0c,0x00,0x24,0x2c,0x00,0x00,0x00,0x00, +0x24,0x05,0x00,0x05,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x14,0x8c,0x44,0x00,0x00,0x0c,0x00,0x24,0x49, +0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x65,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x4c, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40, +0xaf,0x80,0x89,0x4c,0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00, +0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03, +0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x8f,0x84,0xb4,0x40, +0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x21,0x00,0x00,0x00,0x00, +0x3c,0x02,0xff,0x90,0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01, +0x27,0x84,0x89,0x18,0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x06,0xe5, +0x00,0x00,0x00,0x00,0x27,0x84,0x86,0x58,0x0c,0x00,0x18,0x1f,0x00,0x00,0x00,0x00, +0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x8b, +0x00,0x00,0x00,0x00,0x8f,0x82,0x89,0x58,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05, +0x00,0x00,0x18,0x21,0x8f,0x82,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02, +0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, +0x27,0xbd,0xff,0xe0,0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, +0x34,0xc6,0x00,0x5f,0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03, +0x34,0xe7,0x00,0x5d,0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01, +0xa0,0xc3,0x00,0x00,0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21, +0x35,0x29,0x00,0x5e,0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00, +0x91,0x03,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01, +0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c, +0x24,0x05,0x0f,0x00,0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x08,0x00,0x17,0xc5,0x3c,0x02,0xb0,0x03, +0x24,0x04,0x08,0x8c,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80, +0x24,0x05,0x1e,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04, +0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04, +0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24, +0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c, +0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34, +0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30, +0x24,0x06,0x00,0x03,0x0c,0x00,0x13,0x5f,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21, +0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x08,0x00,0x17,0xc5, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00, +0xa3,0x80,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0xa3,0x82,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x60,0x7c, +0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8, +0x8c,0x83,0x00,0x00,0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21, +0xa7,0x82,0x8f,0xf0,0x27,0x88,0x90,0x00,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08, +0x30,0xc2,0xff,0xff,0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21, +0x00,0x60,0x30,0x21,0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21, +0x00,0x87,0x20,0x21,0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4, +0xa4,0x43,0x00,0x00,0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c, +0x24,0x0a,0x00,0x02,0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xb3,0xdc, +0xac,0x43,0x00,0x00,0xaf,0x84,0xb4,0x00,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18, +0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x00,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03, +0x3c,0x03,0xb0,0x03,0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xb4,0x04, +0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x04,0x25,0xc4,0x00,0x54, +0x25,0xc7,0x00,0x78,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x08,0xa0,0x88,0x00,0x18, +0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x08,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01, +0xa0,0x45,0x00,0x21,0xaf,0x87,0xb4,0x0c,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00, +0x8f,0x82,0xb4,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21, +0xaf,0x88,0xb4,0x10,0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x10, +0x25,0xc4,0x00,0xc0,0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x14, +0xa0,0x89,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x14,0x25,0xc4,0x00,0xe4, +0x34,0xc6,0x00,0x60,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x18,0xa0,0x80,0x00,0x18, +0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x18,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c, +0xa0,0x45,0x00,0x21,0xaf,0x83,0xb4,0x1c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00, +0x8f,0x82,0xb4,0x1c,0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21, +0x25,0xc6,0x01,0x98,0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04, +0x25,0xcc,0x02,0x28,0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03, +0xaf,0x87,0xb4,0x20,0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xb4,0x24, +0xa0,0x80,0x00,0x18,0xaf,0x85,0xb4,0x28,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xb4,0x2c, +0xa0,0xc0,0x00,0x18,0xaf,0x89,0xb4,0x30,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xb4,0x34, +0xa1,0x40,0x00,0x18,0xaf,0x8b,0xb4,0x38,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xb4,0x3c, +0xa1,0x80,0x00,0x18,0xaf,0x8d,0xb4,0x40,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00, +0x8f,0x82,0xb4,0x40,0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21, +0x24,0x02,0x00,0x11,0xaf,0x85,0xb4,0x44,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18, +0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x44,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03, +0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x12,0xaf,0x85,0xb4,0x48,0x34,0x63,0x00,0x6c, +0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x48,0x24,0x05,0xff,0xff, +0x24,0x07,0x00,0x01,0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xb4,0x00, +0x8c,0x82,0x00,0x00,0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00, +0xa4,0x45,0x00,0x00,0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00, +0xa4,0x65,0x00,0x06,0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00, +0xa4,0x45,0x00,0x0c,0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14, +0xa0,0x67,0x00,0x17,0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20, +0x04,0xc1,0xff,0xe7,0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x63,0x40, +0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,0x10,0x40,0x00,0x56, +0x00,0x00,0x70,0x21,0x97,0x82,0x8f,0xf0,0x94,0x8a,0x00,0x0c,0x27,0x87,0x90,0x00, +0x00,0x02,0x40,0xc0,0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21, +0x90,0x8b,0x00,0x18,0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,0x39,0x64,0x00,0x10, +0x2c,0x84,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x34,0x85,0x00,0x02, +0x39,0x63,0x00,0x11,0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,0x39,0x64,0x00,0x12, +0x00,0x02,0x10,0x80,0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,0x94,0x49,0x00,0x04, +0x34,0x64,0x00,0x20,0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,0x39,0x62,0x00,0x01, +0x00,0x82,0x18,0x0b,0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,0x00,0xc9,0x28,0x21, +0x39,0x62,0x00,0x02,0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,0x00,0x05,0x28,0x80, +0x3c,0x02,0xb0,0x08,0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,0x01,0x02,0x40,0x21, +0x34,0x03,0xff,0xff,0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,0x2d,0x67,0x00,0x13, +0xad,0x0a,0x00,0x00,0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,0xa7,0x89,0x8f,0xf0, +0x10,0xe0,0x00,0x0f,0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,0x00,0x0b,0x10,0x80, +0x24,0x63,0x02,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x60, +0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x02,0x74,0x03, +0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,0x93,0x83,0x8f,0xe4, +0x91,0x82,0x00,0x21,0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,0x00,0x04,0x24,0x00, +0x00,0x62,0x18,0x21,0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,0x00,0x65,0x10,0x2a, +0x00,0xa2,0x18,0x0a,0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,0x24,0x05,0xff,0xff, +0x00,0x64,0x18,0x25,0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,0xa5,0x85,0x00,0x0e, +0xa1,0x80,0x00,0x10,0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x62,0x3c,0x03,0xb0,0x03, +0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14, +0x34,0x63,0x00,0x66,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x38, +0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6e,0x3c,0x03,0xb0,0x03, +0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x65,0x08,0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00, +0x00,0xa6,0x28,0x21,0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21, +0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08, +0x00,0x60,0x10,0x21,0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10, +0x24,0xa2,0x00,0x01,0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,0x08,0x00,0x19,0x4f, +0x00,0x47,0x18,0x21,0x08,0x00,0x19,0x4f,0x24,0xa3,0x00,0x50,0x27,0xbd,0xff,0xc8, +0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x30, +0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, +0xaf,0xb0,0x00,0x10,0x00,0x80,0x88,0x21,0x84,0x84,0x00,0x08,0x3c,0x05,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x65,0x6c,0x3c,0x03,0xb0,0x06, +0x00,0x04,0x20,0x80,0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x06,0xb0,0x06, +0x8c,0x82,0x00,0x00,0x34,0xc6,0x80,0x24,0x8c,0x88,0x00,0x00,0x8c,0xc4,0x00,0x00, +0x96,0x25,0x00,0x08,0x30,0x52,0xff,0xff,0x00,0x08,0x44,0x02,0x34,0x84,0x01,0x00, +0x3c,0x02,0xb0,0x00,0x00,0x08,0x18,0xc0,0x00,0x12,0x3a,0x00,0xac,0xc4,0x00,0x00, +0x00,0xe2,0x38,0x21,0xae,0x32,0x02,0xb8,0x00,0x68,0x18,0x21,0x24,0xa5,0x00,0x02, +0x8c,0xf6,0x00,0x00,0x30,0xa5,0x01,0xff,0x8c,0xf4,0x00,0x04,0x27,0x86,0x90,0x00, +0x00,0x03,0x18,0x80,0x00,0x12,0x98,0xc0,0xa6,0x25,0x00,0x08,0x00,0x66,0x18,0x21, +0x02,0x72,0x10,0x21,0x94,0x65,0x00,0x00,0x00,0x02,0x48,0x80,0x01,0x26,0x30,0x21, +0x24,0x02,0xff,0xff,0x00,0x14,0x1a,0x02,0x27,0x84,0x90,0x10,0xa4,0xc2,0x00,0x02, +0x30,0x63,0x00,0x1f,0x24,0x02,0x00,0x10,0x01,0x24,0x20,0x21,0xa4,0xc8,0x00,0x04, +0x8c,0xf0,0x00,0x08,0xa6,0x23,0x00,0x06,0xa6,0x25,0x00,0x0a,0xa0,0x82,0x00,0x06, +0x86,0x25,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x24,0x03,0x00,0x13, +0x10,0xa3,0x00,0xee,0xac,0x47,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00, +0xa6,0x20,0x00,0x02,0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08, +0x8c,0x45,0x00,0x00,0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x30,0x63,0x00,0x01, +0xac,0xc5,0x00,0x08,0x10,0x60,0x00,0xc7,0x30,0x97,0x00,0x01,0x00,0x10,0x16,0x82, +0x30,0x46,0x00,0x01,0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02, +0x00,0x10,0x2e,0x42,0x30,0x48,0x00,0x7f,0x24,0x02,0x00,0x01,0x30,0x75,0x00,0x01, +0x30,0x84,0x00,0x01,0x10,0xc2,0x00,0xb3,0x30,0xa3,0x00,0x01,0x00,0x60,0x28,0x21, +0x0c,0x00,0x19,0x42,0x01,0x00,0x38,0x21,0x02,0x72,0x18,0x21,0x00,0x03,0x18,0x80, +0x2c,0x46,0x00,0x54,0x27,0x85,0x90,0x10,0x27,0x84,0x90,0x08,0x00,0x06,0x10,0x0a, +0x00,0x65,0x28,0x21,0x26,0xa6,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02, +0xa0,0x66,0x00,0x06,0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x72,0x28,0x21, +0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x04,0x00,0xa2,0x58,0x21,0x8d,0x64,0x00,0x18, +0x00,0x10,0x15,0xc2,0x30,0x42,0x00,0x01,0x8c,0x83,0x00,0x0c,0x27,0x84,0x90,0x20, +0x00,0xa4,0x48,0x21,0xa6,0x22,0x00,0x00,0xa6,0x36,0x00,0x04,0x8d,0x26,0x00,0x00, +0x00,0x03,0x19,0x42,0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01, +0x00,0xc2,0x40,0x24,0x00,0x03,0x1d,0x00,0x01,0x03,0x40,0x25,0x00,0x08,0x15,0x02, +0x00,0x14,0x19,0x82,0x00,0x14,0x25,0x82,0x00,0x10,0x34,0x42,0x00,0x10,0x3c,0x82, +0x00,0x10,0x2c,0x02,0x30,0x42,0x00,0x01,0x30,0xcd,0x00,0x01,0x30,0x6c,0x00,0x01, +0x30,0xe6,0x00,0x01,0x30,0x8a,0x00,0x03,0x32,0x94,0x00,0x07,0x30,0xa5,0x00,0x01, +0xad,0x28,0x00,0x00,0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,0x8d,0x64,0x00,0x18, +0x3c,0x03,0xff,0xf0,0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,0x01,0x03,0x18,0x24, +0x00,0x02,0x13,0x82,0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,0x00,0x62,0x18,0x25, +0xad,0x23,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x6a,0x00,0x00,0x00,0x00, +0x15,0x80,0x00,0x03,0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x5b,0x24,0x02,0x00,0x01, +0x96,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x22,0x00,0x04, +0x00,0xa0,0x20,0x21,0x0c,0x00,0x19,0x42,0x01,0xa0,0x28,0x21,0x02,0x72,0x18,0x21, +0x00,0x03,0x40,0x80,0x2c,0x45,0x00,0x54,0x27,0x84,0x90,0x10,0x01,0x04,0x20,0x21, +0x00,0x05,0x10,0x0a,0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05, +0x96,0x23,0x00,0x04,0x27,0x82,0x90,0x00,0x01,0x02,0x10,0x21,0xa4,0x43,0x00,0x06, +0x27,0x82,0x90,0x04,0x92,0x26,0x00,0x01,0x01,0x02,0x10,0x21,0x8c,0x45,0x00,0x18, +0x27,0x83,0x90,0x20,0x01,0x03,0x18,0x21,0xa0,0x60,0x00,0x00,0xa0,0x86,0x00,0x07, +0x94,0xa2,0x00,0x10,0x24,0x03,0x00,0x04,0x30,0x42,0x00,0x0f,0x10,0x43,0x00,0x36, +0x24,0xa5,0x00,0x10,0x94,0xa3,0x00,0x16,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21, +0xa4,0x43,0x00,0x02,0x94,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, +0x14,0x40,0x00,0x24,0x02,0x72,0x20,0x21,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0xa4, +0x30,0x42,0x00,0xff,0x10,0x43,0x00,0x1f,0x00,0x00,0x00,0x00,0x94,0xa2,0x00,0x00, +0x24,0x03,0x00,0x88,0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x14,0x02,0x72,0x18,0x21, +0x27,0x84,0x90,0x20,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00, +0x3c,0x04,0x00,0x80,0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x72,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0xa0,0x54,0x00,0x00,0x8f,0xbf,0x00,0x30, +0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, +0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x94,0xa2,0x00,0x18, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xe9,0x02,0x72,0x18,0x21, +0x02,0x72,0x20,0x21,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21, +0x8c,0x83,0x00,0x00,0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24, +0x08,0x00,0x1a,0x37,0xac,0x83,0x00,0x00,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21, +0x08,0x00,0x1a,0x21,0xa4,0x40,0x00,0x02,0x11,0x42,0x00,0x07,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x02,0x14,0x40,0xff,0xa7,0x00,0xa0,0x20,0x21,0x96,0x22,0x00,0x04, +0x08,0x00,0x19,0xff,0x24,0x42,0x00,0x0c,0x96,0x22,0x00,0x04,0x08,0x00,0x19,0xff, +0x24,0x42,0x00,0x08,0x16,0xe6,0xff,0x96,0x3c,0x02,0xff,0xfb,0x8d,0x63,0x00,0x18, +0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x19,0xf8, +0x00,0x00,0x30,0x21,0x16,0xe6,0xff,0x4e,0x00,0x60,0x28,0x21,0x3c,0x02,0xfb,0xff, +0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0xe2,0x00,0x08,0x08,0x00,0x19,0xb7, +0x00,0x00,0x30,0x21,0x93,0x87,0xbb,0x14,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82, +0x27,0x82,0x90,0x08,0x2c,0xe5,0x00,0x0c,0x01,0x22,0x48,0x21,0x30,0x63,0x00,0x01, +0x30,0x86,0x00,0x01,0x14,0xa0,0x00,0x06,0x00,0xe0,0x40,0x21,0x00,0x03,0x10,0x40, +0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0xe2,0x10,0x21,0x24,0x48,0x00,0x04, +0x02,0x72,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x10,0x27,0x83,0x90,0x08, +0x00,0x44,0x20,0x21,0x00,0x43,0x10,0x21,0xa1,0x28,0x00,0x07,0xa0,0x40,0x00,0x06, +0xa0,0x80,0x00,0x02,0x08,0x00,0x19,0xc7,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01, +0xa6,0x22,0x00,0x02,0x0c,0x00,0x01,0xc2,0x00,0xe0,0x20,0x21,0x08,0x00,0x1a,0x3b, +0x00,0x00,0x00,0x00,0x30,0xa7,0xff,0xff,0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21, +0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6a,0x44,0x27,0x85,0x90,0x10, +0x00,0x03,0x18,0x80,0x34,0xc6,0x00,0x20,0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00, +0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21, +0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01, +0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16,0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04, +0x3c,0x03,0xb0,0x03,0x27,0x86,0x90,0x00,0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20, +0x24,0x02,0x00,0x01,0xa0,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08, +0xa4,0xa7,0x00,0x00,0x94,0xa4,0x00,0x02,0x3c,0x02,0x80,0x01,0x24,0x42,0x82,0x6c, +0xac,0x62,0x00,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x66,0x18,0x21,0x94,0x62,0x00,0x04,0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08, +0x00,0x02,0x20,0xc0,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, +0x00,0x83,0x20,0x21,0xa4,0x47,0x00,0x00,0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04, +0xa4,0xa7,0x00,0x02,0x24,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04, +0x90,0x82,0x00,0x16,0x24,0x85,0x00,0x06,0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02, +0x14,0x60,0xff,0xda,0xa0,0x82,0x00,0x16,0x24,0x02,0x00,0x01,0x08,0x00,0x1a,0xa7, +0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0x80,0x38,0x21, +0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x3c,0x0a,0xb0,0x06, +0x34,0x63,0x00,0x20,0x24,0x42,0x6b,0x44,0x3c,0x0b,0xb0,0x08,0x27,0x89,0x90,0x00, +0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20,0x10,0x80,0x00,0x30,0xac,0x62,0x00,0x00, +0x97,0x82,0x8f,0xf0,0x94,0xe6,0x02,0xba,0x00,0x02,0x18,0xc0,0x00,0x6b,0x28,0x21, +0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, +0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21,0xa4,0x66,0x00,0x00,0x00,0x08,0x28,0xc0, +0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x27,0x82,0x90,0x04, +0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80, +0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18,0x27,0x84,0x90,0x10,0x00,0x64,0x18,0x21, +0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06,0x00,0x05,0x28,0x80,0x30,0x42,0xff,0xff, +0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02, +0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04,0x00,0xa9,0x28,0x21,0x00,0x44,0x10,0x25, +0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00,0xa7,0x88,0x8f,0xf0,0x8f,0xbf,0x00,0x10, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x84,0xe3,0x00,0x06, +0x27,0x82,0xb4,0x00,0x94,0xe5,0x02,0xba,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21, +0x8c,0x64,0x00,0x00,0x0c,0x00,0x1a,0x91,0x00,0x00,0x00,0x00,0x08,0x00,0x1b,0x0b, +0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00,0x00,0x80,0x58,0x21,0x27,0x8a,0x90,0x00, +0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21,0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80, +0x3c,0x02,0x80,0x00,0x00,0x6a,0x18,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x6c,0x64, +0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00,0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35, +0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a, +0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21,0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21, +0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d,0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0, +0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21, +0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21,0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0, +0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff,0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04, +0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02, +0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00, +0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02,0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01, +0x00,0xa3,0x28,0x21,0x24,0x42,0x82,0x6c,0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03, +0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x08,0x00,0x1b,0x59, +0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04,0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff, +0x30,0x43,0x00,0xff,0x14,0x60,0xff,0xf7,0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff, +0x08,0x00,0x1b,0x59,0xa5,0x62,0x00,0x02,0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21, +0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80,0x27,0x82,0x90,0x04,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10, +0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18,0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x00, +0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,0x24,0x42,0x6d,0x98,0xac,0xa2,0x00,0x00, +0x27,0x83,0x90,0x10,0x00,0xc3,0x30,0x21,0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06, +0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff, +0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02,0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff, +0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21, +0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06, +0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21,0x0c,0x00,0x1b,0x19,0x02,0x00,0x28,0x21, +0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08, +0x3c,0x09,0x80,0x01,0x27,0x88,0x90,0x00,0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0, +0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04, +0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21,0x00,0xa3,0x28,0x21,0x25,0x26,0x82,0x6c, +0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02, +0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a, +0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21,0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10, +0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16, +0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00, +0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16, +0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e,0x27,0x88,0x90,0x00,0x00,0x02,0x20,0xc0, +0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04, +0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, +0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20, +0x25,0x23,0x82,0x6c,0xac,0xc3,0x00,0x00,0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00, +0x08,0x00,0x1b,0x97,0xa4,0x90,0x00,0x02,0x08,0x00,0x1b,0x8e,0x32,0x50,0xff,0xff, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6f,0x60,0x34,0x63,0x00,0x20, +0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04,0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21, +0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23,0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff, +0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73,0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0, +0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x03,0x0e,0x20,0x21,0x27,0x8d,0x90,0x00, +0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21, +0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04,0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02, +0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21,0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08, +0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21,0x00,0x6d,0x18,0x21,0x27,0x22,0x82,0x6c, +0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20,0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57, +0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21,0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21, +0x01,0x40,0x38,0x21,0x27,0x8b,0x90,0x04,0x27,0x8a,0x90,0x10,0x00,0x06,0x40,0xc0, +0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18, +0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02, +0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01,0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff, +0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21, +0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02,0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0, +0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03, +0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21, +0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0, +0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21, +0x27,0x26,0x82,0x6c,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00, +0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10, +0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e,0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05, +0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd, +0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e, +0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, +0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x34,0xc6,0x00,0x20,0x27,0x27,0x82,0x6c, +0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21, +0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00,0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00, +0xac,0xaf,0x00,0x00,0x08,0x00,0x1c,0x26,0x03,0x0e,0x20,0x21,0x08,0x00,0x1c,0x01, +0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0,0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x8d,0x90,0x00,0x00,0x4d,0x10,0x21,0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff, +0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00,0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01, +0x08,0x00,0x1c,0x01,0xa5,0x82,0x00,0x02,0x08,0x00,0x1c,0x01,0x3c,0x19,0x80,0x01, +0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20, +0x24,0x42,0x71,0xa0,0xaf,0xb2,0x00,0x68,0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60, +0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84,0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c, +0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74,0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c, +0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a,0x27,0x82,0xb4,0x00,0xaf,0xa6,0x00,0x90, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94, +0x27,0x86,0x90,0x04,0xaf,0xa3,0x00,0x1c,0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff, +0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0,0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21, +0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80,0x27,0x84,0x90,0x10,0x00,0x64,0x20,0x21, +0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21,0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, +0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2,0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21, +0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c,0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01, +0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34,0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40, +0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50,0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12, +0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28,0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xe4, +0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82,0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11, +0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98,0x27,0x82,0x80,0x1c,0x00,0x04,0x18,0x40, +0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x06,0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00, +0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00, +0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x42,0xff,0xfc, +0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18,0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff, +0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48,0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21, +0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x48,0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02, +0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21,0x00,0x12,0x10,0xc0,0x00,0x52,0x18,0x21, +0x00,0x03,0x80,0x80,0x27,0x85,0x90,0x00,0x02,0x40,0x20,0x21,0x00,0x40,0xa0,0x21, +0x02,0x05,0x10,0x21,0x94,0x56,0x00,0x02,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21, +0x90,0x42,0x00,0x00,0x24,0x03,0x00,0x08,0x30,0x42,0x00,0x0c,0x10,0x43,0x01,0x9e, +0x24,0x04,0x00,0x01,0x24,0x02,0x00,0x01,0x10,0x82,0x01,0x7c,0x3c,0x02,0xb0,0x03, +0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21, +0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80, +0x27,0x82,0x90,0x10,0x27,0x85,0x90,0x08,0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21, +0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff, +0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80, +0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46, +0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02, +0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02, +0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21, +0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,0x02,0x92,0x10,0x21,0x93,0x82,0x8b,0x71, +0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21, +0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff, +0x16,0xa0,0xff,0xbd,0x02,0xc0,0x90,0x21,0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00, +0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e, +0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a, +0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,0x27,0x84,0x90,0x04,0x94,0xb2,0x00,0x14, +0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21, +0x00,0x02,0x80,0x80,0x27,0x82,0x90,0x10,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06, +0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2, +0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e, +0x00,0xa3,0x38,0x21,0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06, +0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c, +0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38, +0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14, +0x08,0x00,0x1d,0x2d,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x44,0x93,0x82,0x81,0x58, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f, +0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87, +0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83, +0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d, +0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50, +0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21, +0x27,0x8c,0x90,0x00,0x3c,0x0b,0x80,0xff,0x24,0x10,0x00,0x04,0x27,0x91,0x90,0x04, +0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,0x27,0x8e,0x90,0x10,0x01,0x80,0x78,0x21, +0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, +0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44, +0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03, +0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, +0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b, +0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff, +0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21, +0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x40,0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04, +0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25, +0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01, +0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c, +0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00, +0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21, +0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88, +0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00, +0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04, +0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04, +0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21, +0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21, +0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x18,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, +0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21, +0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a, +0xaf,0xa2,0x00,0x10,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff, +0x08,0x00,0x1d,0x85,0xaf,0xa3,0x00,0x2c,0x8f,0xa8,0x00,0x44,0x08,0x00,0x1d,0xa7, +0x31,0x09,0x00,0x03,0x08,0x00,0x1d,0x60,0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44, +0xaf,0xa0,0x00,0x50,0x08,0x00,0x1d,0xa7,0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48, +0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x03,0xc0,0x38,0x21,0x0c,0x00,0x1b,0xd8, +0xaf,0xb7,0x00,0x10,0x08,0x00,0x1d,0x10,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80, +0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49, +0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x09,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80, +0x27,0x83,0x90,0x10,0x8f,0xa4,0x00,0x1c,0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01, +0x02,0x40,0x28,0x21,0x0c,0x00,0x1e,0xea,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13, +0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24, +0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48, +0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24, +0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30, +0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44, +0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04, +0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00, +0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff, +0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80, +0x27,0x82,0x90,0x04,0x00,0xa2,0x10,0x21,0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff, +0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,0x00,0x04,0x25,0x40,0x34,0x63,0xff,0xff, +0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04, +0x8f,0xa8,0x00,0x98,0x27,0x82,0x90,0x10,0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00, +0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb, +0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00, +0x08,0x00,0x1d,0x0c,0x26,0xb5,0xff,0xff,0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21, +0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,0x08,0x00,0x1e,0x1a,0xaf,0xa2,0x00,0x2c, +0x8f,0xa6,0x00,0x1c,0x08,0x00,0x1e,0x04,0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48, +0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x0c,0x00,0x1b,0xd8,0xaf,0xb7,0x00,0x10, +0x08,0x00,0x1d,0xfb,0x00,0x00,0xb8,0x21,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21, +0x00,0x40,0x18,0x21,0x94,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x08,0x00, +0xa4,0x62,0x00,0x00,0x08,0x00,0x1d,0x00,0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21, +0x00,0x03,0x80,0x80,0x27,0x82,0x90,0x04,0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18, +0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10, +0x10,0x60,0x00,0x09,0x24,0x06,0x00,0x01,0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00, +0x30,0x42,0x00,0x01,0x10,0x40,0xfe,0xa2,0x3c,0x04,0x00,0x80,0x27,0x85,0x90,0x00, +0x08,0x00,0x1d,0xeb,0x02,0x05,0x28,0x21,0x27,0x83,0x90,0x18,0x27,0x82,0x90,0x10, +0x02,0x03,0x18,0x21,0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05, +0x93,0x83,0x80,0x10,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa3,0x00,0x10, +0x08,0x00,0x1e,0x62,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x18,0x02,0x02,0x10,0x21, +0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58,0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23, +0x30,0x63,0x0f,0xff,0x28,0x62,0x00,0x20,0x10,0x40,0x00,0x06,0x28,0x62,0x00,0x40, +0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x68,0x10,0x06,0x08,0x00,0x1c,0xd9, +0x30,0x44,0x00,0x01,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94, +0x08,0x00,0x1e,0x83,0x00,0x64,0x10,0x06,0x08,0x00,0x1c,0xd9,0x00,0x00,0x20,0x21, +0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a, +0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,0x08,0x00,0x1c,0xa9,0xaf,0xa2,0x00,0x40, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20, +0x24,0x63,0x7a,0x50,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, +0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45, +0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c, +0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, +0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16, +0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00, +0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, +0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a, +0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00, +0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01, +0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,0x08,0x00,0x1e,0xbe,0xa6,0x03,0x00,0x14, +0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x10,0xc0, +0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80, +0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, +0x8c,0x44,0x00,0x08,0x0c,0x00,0x12,0x7c,0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff, +0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,0x96,0x02,0x00,0x06,0x08,0x00,0x1e,0xbe, +0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,0x08,0x00,0x1e,0xbe,0xa6,0x02,0x00,0x14, +0x96,0x05,0x00,0x00,0x0c,0x00,0x1e,0xea,0x02,0x00,0x20,0x21,0x08,0x00,0x1e,0xa5, +0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,0x0c,0x00,0x1e,0xea,0x00,0x00,0x00,0x00, +0x08,0x00,0x1e,0xa1,0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, +0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xa8,0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00, +0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xcc,0xac,0x62,0x00,0x00, +0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21, +0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00, +0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00, +0x94,0xc8,0x00,0x00,0x27,0x83,0x90,0x00,0x93,0x85,0x8b,0x70,0x00,0x08,0x10,0xc0, +0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, +0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,0x01,0x44,0x18,0x23,0x8f,0x82,0x8b,0x88, +0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, +0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, +0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08, +0x08,0x00,0x1f,0x16,0xa4,0xc2,0x00,0x14,0x08,0x00,0x1f,0x16,0x00,0x00,0x18,0x21, +0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, +0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c, +0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03, +0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,0x24,0x42,0x7c,0x80,0x02,0xb1,0x48,0x21, +0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,0x24,0x03,0x00,0x01,0x27,0x82,0x90,0x10, +0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,0x27,0x84,0x90,0x04,0x01,0x24,0x20,0x21, +0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,0x27,0x83,0x90,0x20,0x01,0x23,0x48,0x21, +0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04, +0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2, +0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40, +0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21, +0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21, +0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21, +0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,0x27,0x90,0x90,0x00,0x02,0x30,0x80,0x21, +0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21, +0xa6,0x83,0x00,0x1a,0x27,0x82,0x90,0x08,0x0c,0x00,0x08,0xe3,0x02,0x22,0x88,0x21, +0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30, +0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xaf,0xa9,0x00,0x10,0x0c,0x00,0x09,0x0a, +0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0x54,0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0, +0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, +0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28, +0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03, +0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21, +0x3c,0x02,0x80,0x00,0x00,0x03,0x48,0x80,0x24,0x42,0x7d,0xbc,0x00,0x80,0x98,0x21, +0x27,0x84,0x90,0x10,0x01,0x24,0x20,0x21,0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00, +0x80,0x83,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18, +0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21, +0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10, +0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21, +0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21, +0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21, +0x27,0x83,0x90,0x18,0x01,0x23,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x70, +0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, +0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00, +0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80, +0x24,0x04,0x00,0x01,0x27,0x83,0x90,0x20,0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21, +0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01, +0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,0x02,0xa0,0x20,0x21,0x27,0x82,0x90,0x00, +0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a, +0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, +0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, +0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10, +0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0xbb,0x00,0x00,0x00,0x00, +0x27,0x83,0x90,0x20,0x01,0x23,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf, +0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d, +0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21, +0x27,0x82,0x80,0x1c,0x00,0x15,0x18,0x40,0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00, +0x24,0xa2,0x00,0x06,0x00,0x54,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02, +0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20, +0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80, +0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff, +0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f, +0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20, +0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10, +0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08, +0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef, +0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1, +0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3, +0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a, +0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d, +0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,0x27,0x99,0x90,0x00,0x01,0xf2,0xc0,0x23, +0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04, +0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21, +0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23, +0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff, +0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23, +0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40, +0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00, +0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x90,0x04, +0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x40, +0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,0x00,0x83,0x20,0x24,0x27,0x83,0x90,0x10, +0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04, +0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,0xa0,0xb5,0x00,0x03,0x27,0x84,0x90,0x20, +0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2, +0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a, +0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, +0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, +0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01, +0x27,0x84,0x90,0x00,0x00,0xc4,0x18,0x21,0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02, +0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23, +0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0, +0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,0x02,0x03,0x80,0x21,0x27,0x82,0x90,0x08, +0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21, +0x01,0x60,0x88,0x21,0x0c,0x00,0x08,0xe3,0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21, +0xa6,0x02,0x00,0x04,0x08,0x00,0x1f,0xc1,0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b, +0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6, +0x01,0x71,0x18,0x21,0x08,0x00,0x20,0x37,0x25,0x22,0x00,0x01,0x08,0x00,0x20,0x66, +0x32,0xcc,0x00,0x03,0x08,0x00,0x20,0x66,0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c, +0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xb4,0x00,0x14, +0x92,0x67,0x00,0x04,0x08,0x00,0x1f,0xd9,0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff, +0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,0x00,0x04,0x20,0x80,0x27,0x82,0x90,0x00, +0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21, +0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff, +0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,0x27,0x88,0x90,0x00,0x00,0x06,0x30,0x80, +0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03, +0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21, +0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20, +0x24,0x42,0x82,0x6c,0xac,0xe2,0x00,0x00,0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00, +0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0, +0x00,0x44,0x10,0x21,0x27,0x89,0x90,0x00,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, +0x97,0x83,0x8f,0xf0,0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0, +0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21, +0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20, +0x34,0x09,0xff,0xff,0x24,0x42,0x82,0xc8,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00, +0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x8f,0xf0, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x63,0x00,0x20,0x24,0x42,0x83,0x48,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, +0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,0x97,0x83,0x81,0x60,0x30,0x42,0xff,0xff, +0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,0xa7,0x82,0x81,0x60,0xaf,0x80,0xb4,0x50, +0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,0x27,0x84,0xb4,0x54,0x25,0x43,0xff,0xff, +0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00, +0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24, +0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14, +0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03, +0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,0x27,0x89,0xb4,0xa0,0x35,0x6b,0x01,0x20, +0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2, +0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6, +0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21, +0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a, +0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff, +0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, +0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40, +0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04, +0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08, +0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0, +0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b, +0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08, +0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5, +0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03, +0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04, +0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x90,0x82,0x00,0x05,0x08,0x00,0x21,0x0d,0xa0,0x82,0x00,0x08,0x97,0x85,0x8b,0x7a, +0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20, +0x24,0x42,0x84,0xfc,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00, +0x30,0x90,0x00,0xff,0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xb4,0xa4, +0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xb5,0x84,0x27,0x99,0xb5,0x80, +0x27,0x8e,0xb5,0x7e,0x27,0x8c,0xb4,0xa8,0x27,0x8d,0xb5,0x00,0x27,0x88,0xb5,0x78, +0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58, +0x00,0x6e,0x20,0x21,0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00, +0xa1,0x00,0x00,0x04,0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21, +0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00, +0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9, +0x24,0x84,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21, +0x00,0x4c,0x18,0x21,0x27,0x87,0x81,0x64,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04, +0xac,0x82,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01, +0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6, +0x24,0x63,0x00,0x03,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b, +0x25,0x08,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x81,0x60, +0x00,0x00,0x48,0x21,0x27,0x83,0xb4,0x50,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01, +0x29,0x22,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x20,0xd2, +0x00,0x00,0x00,0x00,0x2e,0x04,0x00,0x14,0x27,0x83,0xb4,0xa0,0x24,0x09,0x00,0x07, +0x10,0x80,0x00,0x0a,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff, +0xa0,0x62,0x00,0x00,0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6, +0x08,0x00,0x21,0x90,0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00, +0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80, +0x27,0x83,0xb4,0xa0,0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x84,0x00,0x20,0x24,0x42,0x86,0x68,0x30,0xc6,0x00,0xff,0x93,0xaa,0x00,0x13, +0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xe8, +0x25,0x8f,0x00,0xd0,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc, +0x2c,0x43,0x00,0x18,0x10,0x60,0x00,0xc7,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80, +0x24,0x63,0x02,0x90,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x1c, +0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x17,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x11,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0c, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0x03,0xe0,0x00,0x08, +0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xe8, +0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, +0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0x00,0x02, +0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x0a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe9,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, +0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe0, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdb,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,0x14,0x40,0xff,0xc5, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd0, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,0x10,0x40,0xff,0xf1, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb5, +0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf4, +0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xbd, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xb5,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc6,0x24,0x02,0x00,0x03, +0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xae, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xa9,0x24,0x02,0x00,0x02, +0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x03,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xd8, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x9a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x95,0x24,0x02,0x00,0x03, +0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, +0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x88, +0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf3,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x17, +0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x34,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x81, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x76,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x97, +0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x51, +0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6a, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x65,0x24,0x02,0x00,0x03, +0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf9, +0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf7,0x2d,0x42,0x00,0x25,0x08,0x00,0x22,0x2d, +0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x50, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe6, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,0x00,0x00,0x00,0x00, +0x08,0x00,0x22,0x79,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,0x14,0x40,0xff,0xd8, +0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe9,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2c, +0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xbd,0x00,0x00,0x00,0x00, +0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff, +0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,0x00,0x04,0x48,0x80,0x01,0x82,0x58,0x21, +0x01,0x89,0x40,0x21,0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60, +0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd, +0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,0x00,0x00,0x00,0x00,0x27,0x87,0x81,0x64, +0x01,0x27,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60, +0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00, +0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00, +0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00, +0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b, +0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4, +0x27,0x87,0x81,0x64,0x08,0x00,0x22,0xb0,0xa1,0x80,0x00,0xdd,0x27,0x82,0x81,0xd4, +0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01, +0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x02,0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60, +0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, +0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,0x10,0xe0,0x00,0x1d,0x24,0x83,0xff,0xfc, +0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x10,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, +0x24,0x63,0x02,0xf0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x65, +0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x5a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0xad,0x82,0x00,0xd0, +0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, +0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, +0x93,0x05,0x00,0x01,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05, +0x24,0x02,0x00,0x01,0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08, +0xad,0x80,0x00,0xd8,0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05, +0x00,0x00,0x00,0x00,0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08, +0xa1,0x83,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43, +0xad,0xa2,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,0x8d,0xc5,0x00,0x00, +0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40, +0x00,0x04,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x22,0xc2, +0xad,0xc5,0x00,0x00,0x97,0x82,0x8b,0x7c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a, +0x10,0x40,0xfe,0xab,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00, +0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64, +0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21, +0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80, +0x01,0x82,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, +0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x23,0x37,0xa1,0x80,0x00,0xdd, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x22,0xf3,0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3, +0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa0, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x9d,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x93,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdd,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19, +0x14,0x40,0xff,0x7c,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x83,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00, +0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b, +0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x14,0xa2,0xff,0x6c,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3, +0x24,0x42,0xff,0xf4,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xbd,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x68, +0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xee, +0x24,0x02,0x00,0x03,0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0xae,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5c, +0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x74, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00, +0x08,0x00,0x23,0x49,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x9a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x48, +0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, +0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x3b,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x64,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x17,0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xa5, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00, +0x10,0xa0,0xff,0x81,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x29,0x24,0x02,0x00,0x03, +0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0,0x00,0x00,0x00,0x00, +0x08,0x00,0x23,0xc2,0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde, +0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, +0x10,0xa2,0xff,0x6a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x18, +0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0, +0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00, +0x08,0x00,0x23,0x6a,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x68,0x2d,0x42,0x00,0x25, +0x08,0x00,0x23,0x9e,0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00, +0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, +0x10,0xa2,0xff,0x03,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00, +0x08,0x00,0x23,0x57,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad, +0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xea,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a, +0x14,0x40,0xff,0xd8,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x5a,0x00,0x00,0x00,0x00, +0x2d,0x42,0x00,0x2c,0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xe5, +0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,0xaf,0xbf,0x00,0x14, +0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,0x8c,0x50,0x00,0x00, +0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,0xa3,0x82,0x80,0x10, +0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09, +0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01, +0xa3,0x82,0xbc,0x18,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x05,0x37,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00, +0xa3,0x80,0xbc,0x18,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x16, +0x32,0x02,0x08,0x00,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff, +0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x13,0x32,0x02,0x01,0x00, +0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18, +0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02, +0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24, +0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff, +0x01,0x00,0x30,0x21,0x0c,0x00,0x24,0xdf,0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18, +0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x25,0x31, +0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,0x08,0x00,0x24,0x3f, +0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0x3c,0x02,0xb0,0x03,0xaf,0xbe,0x00,0x38, +0xaf,0xb5,0x00,0x2c,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c, +0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, +0xaf,0xb2,0x00,0x20,0x34,0x42,0x00,0x3f,0x90,0x43,0x00,0x00,0x00,0x80,0x80,0x21, +0x00,0x00,0xf0,0x21,0x00,0x00,0x88,0x21,0x10,0x60,0x00,0x76,0x00,0x00,0xa8,0x21, +0x3c,0x01,0xb0,0x03,0xa0,0x20,0x00,0x3f,0x00,0x10,0x12,0x02,0x24,0x04,0x06,0x14, +0x0c,0x00,0x06,0xd1,0x30,0x54,0x00,0x0f,0x24,0x04,0x06,0x14,0x0c,0x00,0x06,0xd1, +0xaf,0xa2,0x00,0x10,0x3c,0x03,0x00,0xff,0x34,0x63,0xff,0xff,0x32,0x10,0x00,0x7f, +0x00,0x43,0x10,0x24,0x00,0x10,0x86,0x00,0x02,0x02,0x80,0x25,0x02,0x00,0x28,0x21, +0x24,0x04,0x06,0x14,0x3c,0x13,0xbf,0xff,0x0c,0x00,0x06,0xbf,0x3c,0x16,0xb0,0x03, +0x00,0x00,0x90,0x21,0x3c,0x17,0x40,0x00,0x36,0x73,0xff,0xff,0x36,0xd6,0x00,0x3e, +0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00,0x00,0x57,0x10,0x25,0x00,0x40,0x28,0x21, +0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00,0x00,0x00,0x80,0x21,0x0c,0x00,0x25,0xf9, +0x00,0x00,0x00,0x00,0x26,0x03,0x00,0x01,0x10,0x40,0x00,0x46,0x30,0x70,0x00,0xff, +0x12,0x00,0xff,0xfa,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00, +0x00,0x53,0x10,0x24,0x00,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00, +0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x37,0x00,0x00,0x00,0x00,0x12,0x80,0x00,0x35, +0x00,0x00,0x00,0x00,0x32,0x31,0x00,0x7f,0x12,0x20,0x00,0x04,0x24,0x03,0x00,0x04, +0x27,0xc2,0x00,0x01,0x30,0x5e,0x00,0xff,0x02,0xb1,0xa8,0x21,0x12,0x43,0x00,0x2a, +0x3c,0x03,0xb0,0x03,0x02,0x43,0x10,0x21,0xa0,0x51,0x00,0x34,0x26,0x42,0x00,0x01, +0x30,0x52,0x00,0xff,0x2e,0x43,0x00,0x05,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00, +0x8f,0xa5,0x00,0x10,0x0c,0x00,0x06,0xbf,0x24,0x04,0x06,0x14,0x12,0xa0,0x00,0x0e, +0x3c,0x02,0xb0,0x03,0x13,0xc0,0x00,0x0d,0x34,0x42,0x00,0x3c,0x00,0x15,0x10,0x40, +0x00,0x55,0x10,0x21,0x00,0x02,0x10,0xc0,0x00,0x55,0x10,0x21,0x00,0x02,0xa8,0x80, +0x02,0xbe,0x00,0x1b,0x17,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d, +0x00,0x00,0xa8,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3c,0x3c,0x03,0xb0,0x03, +0x3c,0x04,0xb0,0x03,0xa4,0x55,0x00,0x00,0x34,0x63,0x00,0x1c,0x34,0x84,0x00,0x1d, +0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00,0xa0,0x82,0x00,0x00,0x7b,0xbe,0x01,0xfc, +0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0xa2,0xd1,0x00,0x00,0x08,0x00,0x24,0x98, +0x26,0x42,0x00,0x01,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0xfc,0x08,0x00,0x24,0x8d, +0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x3c,0x3c,0x04,0xb0,0x03, +0x3c,0x05,0xb0,0x03,0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0x1c,0x34,0xa5,0x00,0x1d, +0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x24,0xb7, +0xa0,0xa3,0x00,0x00,0x0c,0x00,0x17,0x99,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x8b, +0x00,0x10,0x12,0x02,0x3c,0x02,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x42,0x00,0x3c, +0x34,0x84,0x00,0x14,0x24,0x03,0x00,0x01,0xa4,0x40,0x00,0x00,0x3c,0x01,0xb0,0x03, +0xa0,0x23,0x00,0x3f,0x08,0x00,0x24,0xb7,0xac,0x90,0x00,0x00,0x27,0xbd,0xff,0xd8, +0xaf,0xb0,0x00,0x10,0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x30,0xb1,0x00,0xff, +0x14,0x40,0x00,0x06,0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc, +0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10, +0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x38, +0x02,0x00,0x30,0x21,0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,0x3c,0x04,0xb0,0x09, +0x00,0x02,0x14,0x00,0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,0x90,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x2a, +0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x20, +0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,0x16,0x60,0xff,0xe2, +0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0d, +0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xda, +0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f, +0x3c,0x06,0x0c,0xb8,0x08,0x00,0x24,0xea,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12, +0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12, +0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x12,0x24,0x04,0x08,0x44,0x24,0x04,0x08,0x4c, +0x0c,0x00,0x13,0x5f,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x07,0x00,0x00,0x00,0x00, +0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,0x00,0x00,0x00,0x00, +0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x44, +0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x24,0xf5, +0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,0xaf,0xb2,0x00,0x18, +0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c, +0x00,0xc0,0x80,0x21,0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,0x14,0x40,0x00,0x07, +0x00,0x00,0x18,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, +0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10, +0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x24, +0x02,0x00,0x30,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00, +0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,0x0c,0x00,0x25,0xae, +0x02,0x20,0x20,0x21,0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,0x24,0x02,0x00,0x01, +0x12,0x22,0x00,0x15,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02, +0x12,0x22,0x00,0x0b,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,0x00,0x00,0x00,0x00, +0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff, +0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0c,0xb8,0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21, +0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,0x00,0x00,0x00,0x00, +0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x44, +0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x25,0x49, +0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x14,0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,0x30,0xa5,0x00,0xff, +0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x12, +0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x07, +0x24,0x04,0x08,0x4c,0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x05,0xff,0xff, +0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xf8,0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xe2, +0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,0x24,0x04,0x08,0x40, +0x08,0x00,0x25,0x88,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x44, +0x2c,0xc2,0x00,0x10,0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x14, +0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0a, +0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,0x08,0x00,0x25,0x82, +0x26,0x10,0xff,0xf1,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xb8, +0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xf1,0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x48, +0x14,0xa0,0xff,0xf6,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xa2,0x24,0x05,0xff,0xff, +0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,0x30,0x84,0x00,0xff, +0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,0x28,0x82,0x00,0x02, +0x14,0x40,0x00,0x27,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x17, +0x00,0xa0,0x30,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,0x24,0x04,0x08,0x3c, +0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, +0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,0x0c,0x00,0x13,0x41, +0x24,0x05,0x0f,0xff,0x08,0x00,0x25,0xbc,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x34, +0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00, +0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa8, +0x14,0x80,0xff,0xdf,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,0x0c,0x00,0x13,0x5f, +0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f, +0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f, +0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa0,0x00,0xa0,0x30,0x21, +0x24,0x04,0x08,0x2c,0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c, +0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x2c, +0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb, +0x24,0x04,0x08,0xa4,0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x20, +0x3c,0x06,0xc0,0x00,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0x34,0xa5,0x17,0x09, +0xac,0x45,0x00,0x00,0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,0x34,0x84,0x02,0x28, +0x3c,0x07,0xb0,0x05,0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,0x34,0xe7,0x04,0x50, +0xa0,0x82,0x00,0x00,0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03, +0x10,0x40,0xff,0xfc,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x93,0x85,0x81,0xf1,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x53,0x00,0x80,0x40,0x21, +0x8c,0x89,0x00,0x04,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21,0x8c,0xc3,0x00,0x04, +0x3c,0x02,0x01,0x00,0x00,0x62,0x10,0x24,0x10,0x40,0x00,0x4b,0x30,0x62,0x00,0x08, +0x10,0x45,0x00,0x59,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,0x24,0x03,0x00,0xb4, +0x30,0x44,0x00,0xff,0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4,0x10,0x82,0x00,0x54, +0x24,0x02,0x00,0x94,0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38, +0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff,0x24,0x02,0x40,0x88, +0x14,0x62,0x00,0x39,0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00,0x10,0x62,0x00,0x38, +0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff, +0x30,0xe2,0x00,0x80,0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21, +0x94,0xc3,0x00,0x60,0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b,0x00,0x00,0x00,0x00, +0x90,0xc2,0x00,0x62,0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02,0x10,0xe3,0x00,0x15, +0x24,0x02,0x00,0x06,0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00,0x8d,0x05,0x01,0xac, +0x94,0xc4,0x00,0x66,0x27,0x82,0x89,0x68,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff, +0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02, +0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00,0x30,0x47,0xff,0xff, +0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0x08,0x00,0x26,0x76, +0xad,0x07,0x00,0x10,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64,0x27,0x82,0x89,0x68, +0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00, +0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x36, +0x3c,0x03,0xff,0xff,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25, +0xac,0xa4,0x00,0x00,0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x94,0xc2,0x00,0x50,0x08,0x00,0x26,0x34,0x30,0x47,0xff,0xff,0x8d,0x04,0x01,0xac, +0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00, +0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e,0xac,0x82,0x00,0x00, +0x24,0x03,0x00,0x2e,0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x8d,0x04,0x01,0xac,0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, +0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x0e, +0x24,0x03,0x00,0x0e,0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x8d,0x04,0x01,0xac, +0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00, +0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14,0x24,0x03,0x00,0x14, +0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x30,0xc6,0x00,0xff,0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80, +0x27,0x8b,0xbc,0x30,0x27,0x83,0xbc,0x36,0x00,0x4b,0x40,0x21,0x00,0x43,0x10,0x21, +0x94,0x47,0x00,0x00,0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29,0x30,0x8a,0xff,0xff, +0x95,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82,0x30,0x42,0x00,0x01, +0x10,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80, +0x00,0x4b,0x30,0x21,0x94,0xc4,0x00,0x02,0x27,0x83,0xbc,0x36,0x27,0x85,0xbc,0x34, +0x00,0x45,0x28,0x21,0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21,0xa4,0xc4,0x00,0x02, +0xa4,0x40,0x00,0x00,0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02,0x3c,0x04,0xb0,0x01, +0x01,0x44,0x20,0x21,0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02,0xa0,0xc0,0x00,0x00, +0x8c,0x82,0x00,0x04,0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24,0x03,0xe0,0x00,0x08, +0xac,0x82,0x00,0x04,0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01,0x00,0xa2,0x10,0x24, +0x00,0x47,0x28,0x25,0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02,0x14,0x82,0xff,0xe2, +0x01,0x43,0x18,0x21,0xac,0x65,0x00,0x00,0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21, +0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01, +0x14,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04,0x3c,0x06,0xb0,0x09, +0x00,0x82,0x20,0x21,0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04,0x3c,0x02,0x01,0x00, +0x34,0xc6,0x01,0x00,0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05,0x30,0xa5,0x20,0x00, +0x24,0x02,0x00,0x06,0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, +0x3c,0x03,0xb0,0x09,0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00,0x24,0x02,0x00,0x0e, +0x08,0x00,0x26,0xd6,0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01,0x30,0xa5,0xff,0xff, +0x00,0xa2,0x28,0x21,0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00,0x00,0x80,0x30,0x21, +0x00,0x62,0x18,0x24,0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04,0x00,0x00,0x00,0x00, +0x30,0x42,0x80,0x00,0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00,0x8c,0xc2,0x01,0xa8, +0x00,0x00,0x00,0x00,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40, +0x00,0x83,0x10,0x0a,0x93,0x83,0x81,0xf0,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, +0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8,0xa3,0x83,0x81,0xf0, +0x8c,0xc4,0x01,0xac,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x26, +0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, +0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, +0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x81,0xf1,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x81,0xf1,0x03,0xe0,0x00,0x08, +0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01,0x00,0x80,0x50,0x21, +0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05,0x00,0x03,0x1a,0x02, +0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07,0x11,0x22,0x00,0x09, +0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b,0x11,0x22,0x00,0x05, +0x24,0x02,0x00,0x01,0x93,0x83,0x81,0xf0,0x3c,0x04,0xb0,0x06,0x10,0x62,0x00,0x03, +0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00, +0x8d,0x43,0x01,0xa8,0x27,0x82,0x89,0x68,0x00,0x03,0x18,0x80,0x00,0x6a,0x20,0x21, +0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00,0x00,0xe5,0x28,0x21, +0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x8a,0x68,0x01,0x22,0x10,0x24, +0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8,0x00,0x07,0x30,0xc2, +0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x00,0x06,0x32,0x00, +0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00, +0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04,0xaf,0x87,0xbc,0x20, +0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xbc,0x28,0x8c,0xa3,0x00,0x04, +0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8,0xaf,0x83,0xbc,0x24, +0x93,0x85,0x81,0xf0,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40, +0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0xa5,0xff,0xff, +0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x81,0xf0,0x08,0x00,0x27,0x21, +0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0xa5,0x00,0x20, +0x24,0x42,0x9d,0x64,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x20, +0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60,0xac,0x80,0x00,0x00, +0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c,0xac,0x80,0x00,0x50, +0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58,0xa0,0x80,0x00,0x5c, +0x24,0x42,0x9e,0x28,0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f,0x24,0xa5,0xff,0xff, +0xac,0x62,0x00,0x00,0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04,0x3c,0x02,0x80,0x01, +0x24,0x42,0x9f,0x10,0xac,0x82,0x00,0x78,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01, +0x24,0x63,0xa0,0x9c,0x24,0x42,0xa0,0x08,0xac,0x83,0x00,0x88,0xac,0x82,0x00,0x98, +0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x24,0x63,0xa1,0x44,0x24,0x42,0xa2,0x5c, +0xac,0x83,0x00,0xa0,0xac,0x82,0x00,0xa4,0xa0,0x80,0x01,0xba,0xac,0x80,0x01,0xa8, +0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,0xac,0x80,0x01,0xb4,0xa0,0x80,0x01,0xb8, +0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, +0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0x28,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x9e,0x40, +0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11, +0x00,0x80,0x28,0x21,0x8c,0x82,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d, +0x00,0x00,0x00,0x00,0x8c,0x84,0x00,0x10,0x8c,0xa3,0x00,0x14,0x8c,0xa2,0x00,0x04, +0x00,0x83,0x20,0x21,0x00,0x44,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b, +0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff, +0xac,0xa2,0x00,0x04,0xac,0xa0,0x00,0x00,0xac,0xa0,0x00,0x4c,0xac,0xa0,0x00,0x50, +0xac,0xa0,0x00,0x54,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x0c,0x3c,0x03,0xb0,0x03, +0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0xbc,0xac,0x62,0x00,0x00, +0x8c,0x86,0x00,0x04,0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21, +0x8c,0x45,0x00,0x00,0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff, +0x30,0x42,0x00,0xff,0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14, +0xac,0x85,0x00,0x40,0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08, +0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, +0x24,0x63,0x9f,0x10,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, +0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21, +0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54, +0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00,0x08,0x00,0x27,0xd1, +0xae,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, +0x34,0x42,0x00,0x20,0x24,0x63,0x9f,0x74,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, +0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16, +0x00,0x80,0x80,0x21,0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44, +0x00,0x62,0x18,0x21,0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50, +0x30,0xa3,0x00,0xff,0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f, +0x30,0x42,0x00,0x03,0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c, +0xae,0x03,0x00,0x30,0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, +0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00, +0x08,0x00,0x27,0xe9,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, +0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x08,0xaf,0xb0,0x00,0x10, +0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00, +0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40, +0x83,0x85,0x8b,0xd4,0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02, +0xae,0x04,0x00,0x14,0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04, +0xae,0x03,0x00,0x3c,0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01, +0x24,0x02,0x00,0x01,0xa3,0x86,0x8b,0xd4,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd, +0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x0e,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x9c, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03, +0x8c,0x42,0x00,0x00,0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x8b,0xd4, +0x92,0x05,0x00,0x41,0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2, +0x00,0x03,0x1e,0x02,0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21, +0xae,0x03,0x00,0x18,0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03, +0x24,0x02,0x00,0x01,0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x8b,0xd4, +0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x33, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, +0x34,0x42,0x00,0x20,0x24,0x63,0xa1,0x44,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, +0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37, +0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00, +0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25, +0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21, +0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68, +0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac, +0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68, +0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10,0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac, +0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00, +0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, +0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac, +0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0, +0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00, +0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14, +0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27, +0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x5d,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa2,0x5c, +0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54, +0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04, +0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10, +0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04, +0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00, +0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68,0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00, +0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04, +0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68,0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10, +0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03, +0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a, +0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23, +0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30, +0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01, +0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90, +0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0xa3, +0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20, +0x24,0x63,0xa3,0x74,0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01, +0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c, +0x00,0x80,0x80,0x21,0x24,0x52,0x9e,0x28,0x00,0x00,0x88,0x21,0x3c,0x03,0xb0,0x09, +0x34,0x63,0x00,0x06,0x8e,0x06,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x06,0x22,0x02, +0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f, +0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff, +0x10,0x44,0x00,0x68,0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x01,0x00,0xc2,0x10,0x21, +0x8c,0x44,0x00,0x04,0x3c,0x03,0x7c,0x00,0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24, +0xae,0x04,0x00,0x44,0x8c,0x44,0x00,0x00,0x10,0x60,0x00,0x69,0x00,0x00,0x38,0x21, +0x3c,0x09,0xb0,0x03,0x3c,0x06,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01, +0x24,0x08,0x00,0x40,0x34,0xc6,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38, +0x16,0x20,0x00,0x06,0x24,0xa5,0x00,0x01,0x93,0x82,0x81,0xf6,0x24,0x11,0x00,0x01, +0x24,0x42,0x00,0x01,0xa1,0x22,0x00,0x00,0xa3,0x82,0x81,0xf6,0x8e,0x02,0x00,0x04, +0x24,0x07,0x00,0x01,0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04, +0x00,0x4a,0x10,0x21,0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44, +0x8c,0x44,0x00,0x00,0x10,0xa8,0x00,0x2d,0x00,0x66,0x18,0x24,0x14,0x60,0xff,0xec, +0x00,0x8b,0x10,0x24,0x14,0x4c,0xff,0xea,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x2f, +0x3c,0x03,0xb0,0x09,0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42, +0x00,0x02,0x12,0x02,0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00, +0x10,0x44,0x00,0x1a,0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58, +0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c, +0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68, +0x00,0x00,0x00,0x00,0x10,0x52,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09, +0x02,0x00,0x20,0x21,0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xae,0x03,0x00,0x60,0x08,0x00,0x28,0xeb,0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64, +0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c, +0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26, +0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x34,0x63,0x00,0x06, +0x8e,0x04,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,0x00,0x44,0x10,0x23, +0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a, +0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x14,0x87,0xff,0xc5, +0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03, +0x14,0x40,0x00,0x05,0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01, +0x08,0x00,0x29,0x4b,0xa2,0x02,0x00,0x5c,0x08,0x00,0x29,0x4b,0xa2,0x00,0x00,0x5c, +0x3c,0x02,0xff,0xff,0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,0x14,0x43,0xff,0x94, +0x24,0x02,0x00,0x01,0x08,0x00,0x29,0x23,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, +0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xa5,0xcc,0xac,0x43,0x00,0x00, +0x8c,0x83,0x01,0xa8,0x8c,0x82,0x01,0xac,0x00,0x80,0x40,0x21,0x10,0x62,0x00,0x20, +0x00,0x00,0x20,0x21,0x93,0x82,0x81,0xf1,0x00,0x03,0x28,0x80,0x3c,0x07,0xb0,0x06, +0x00,0xa8,0x18,0x21,0x24,0x04,0x00,0x01,0x8c,0x66,0x00,0xa8,0x10,0x44,0x00,0x1c, +0x34,0xe7,0x80,0x18,0x3c,0x05,0xb0,0x01,0xaf,0x86,0xbc,0x20,0x00,0xc5,0x28,0x21, +0x8c,0xa3,0x00,0x00,0x00,0x06,0x20,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00, +0x00,0x82,0x20,0x25,0xaf,0x83,0xbc,0x28,0x8c,0xa2,0x00,0x04,0xac,0xe4,0x00,0x00, +0x8d,0x03,0x01,0xa8,0xaf,0x82,0xbc,0x24,0x24,0x64,0x00,0x01,0x04,0x80,0x00,0x0a, +0x00,0x80,0x10,0x21,0x00,0x02,0x11,0x83,0x8d,0x03,0x01,0xac,0x00,0x02,0x11,0x80, +0x00,0x82,0x10,0x23,0x00,0x43,0x18,0x26,0xad,0x02,0x01,0xa8,0x00,0x03,0x20,0x2b, +0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x29,0x95,0x24,0x62,0x00,0x40, +0x27,0x82,0x89,0x68,0x00,0x06,0x20,0xc2,0x00,0x04,0x22,0x00,0x00,0xa2,0x48,0x21, +0x3c,0x02,0x00,0x80,0x00,0x82,0x58,0x25,0x93,0x82,0x81,0xf0,0x3c,0x0a,0xb0,0x06, +0x3c,0x03,0xb0,0x01,0x2c,0x42,0x00,0x02,0x00,0xc3,0x38,0x21,0x35,0x4a,0x80,0x18, +0x14,0x40,0xff,0xef,0x00,0x00,0x20,0x21,0x8c,0xe5,0x00,0x00,0x8d,0x23,0x00,0x00, +0x24,0x02,0xc0,0x00,0x00,0xa2,0x10,0x24,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00, +0x8d,0x04,0x01,0xa8,0x27,0x83,0x8a,0x68,0x8c,0xe5,0x00,0x04,0x00,0x04,0x20,0x80, +0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0xa2,0x10,0x25, +0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x04,0xaf,0x86,0xbc,0x20,0x8c,0xe2,0x00,0x00, +0x93,0x85,0x81,0xf0,0xaf,0x82,0xbc,0x28,0x8c,0xe3,0x00,0x04,0xad,0x4b,0x00,0x00, +0x8d,0x02,0x01,0xa8,0xaf,0x83,0xbc,0x24,0x24,0xa5,0xff,0xff,0x24,0x44,0x00,0x01, +0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83, +0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0xad,0x04,0x01,0xa8,0xa3,0x85,0x81,0xf0, +0x79,0x02,0x0d,0x7c,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x26,0x08,0x00,0x29,0x9c, +0x00,0x02,0x20,0x2b,0x3c,0x04,0xb0,0x03,0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01, +0x34,0xc6,0x00,0x18,0x34,0x84,0x00,0x20,0x24,0x42,0xa7,0x54,0x24,0x03,0xff,0x83, +0xac,0x82,0x00,0x00,0xa0,0xc3,0x00,0x00,0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8, +0x3c,0x03,0xb0,0x07,0x24,0x02,0xff,0x82,0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00, +0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01, +0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07, +0xa3,0xa3,0x00,0x00,0xa0,0xc2,0x00,0x00,0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10, +0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x07,0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38, +0xa0,0xa2,0x00,0x00,0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20, +0xa3,0xa4,0x00,0x00,0xa0,0xa0,0x00,0x00,0x90,0xa3,0x00,0x00,0xaf,0x82,0xbf,0x30, +0xa3,0xa3,0x00,0x00,0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08, +0x27,0xbd,0x00,0x08,}; + +u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00, +0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4,0x00,0xab,0x00,0x72, +0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x02,0x76,0x01,0x3b, +0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f,0x01,0x3b,0x00,0x9e, +0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20,0x01,0x2f,0x00,0x98, +0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e,0x00,0x98,0x00,0x4c, +0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f,0x02,0x39,0x01,0x1c, +0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39,0x01,0x1c,0x00,0x8e, +0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c,0x01,0x11,0x00,0x89, +0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b,0x00,0x89,0x00,0x44, +0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e,0x02,0xab,0x02,0xab, +0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08,0x04,0x06,0x07,0x08, +0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x4c, +0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c,0x5f,0x64,0x61,0x74, +0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x64,0x45,0x4c, +0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00,0x00,0x00,0x00,0x00, +0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64, +0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x76,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x0b,0x63, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x2c, +0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x60, +0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20,0x00,0x00,0x01,0x80, +0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x9c, +0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x01,0xd4, +0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38, +0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40,0x00,0x00,0x03,0xa8, +0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04, +0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x08, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x6c,0x80,0x00,0x07,0x80, +0x80,0x00,0x07,0x80,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x94, +0x80,0x00,0x56,0xb0,0x80,0x00,0x57,0x08,0x80,0x00,0x57,0x30,0x80,0x00,0x58,0x28, +0x80,0x00,0x58,0xe0,0x80,0x00,0x59,0x88,0x80,0x00,0x59,0xfc,0x80,0x00,0x5b,0x08, +0x80,0x00,0x5b,0x40,0x80,0x00,0x5b,0x54,0x80,0x00,0x5b,0x68,0x80,0x00,0x5c,0x50, +0x80,0x00,0x5c,0x90,0x80,0x00,0x5d,0x44,0x80,0x00,0x5d,0x6c,0x80,0x00,0x56,0x70, +0x80,0x00,0x5d,0xbc,0x80,0x00,0x64,0x48,0x80,0x00,0x64,0xc0,0x80,0x00,0x64,0xcc, +0x80,0x00,0x64,0xd8,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, +0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, +0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, +0x80,0x00,0x64,0x60,0x80,0x00,0x64,0xe4,0x80,0x00,0x64,0xf0,0x80,0x00,0x64,0xfc, +0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xd8, +0x80,0x00,0x88,0x18,0x80,0x00,0x88,0x50,0x80,0x00,0x88,0x80,0x80,0x00,0x88,0xb0, +0x80,0x00,0x88,0xc4,0x80,0x00,0x89,0x2c,0x80,0x00,0x89,0x40,0x80,0x00,0x89,0x7c, +0x80,0x00,0x89,0x84,0x80,0x00,0x89,0xc0,0x80,0x00,0x89,0xd4,0x80,0x00,0x89,0xdc, +0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4, +0x80,0x00,0x8a,0x14,0x80,0x00,0x8a,0x28,0x80,0x00,0x8a,0x3c,0x80,0x00,0x86,0xe8, +0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x9c, +0x80,0x00,0x8d,0xdc,0x80,0x00,0x8e,0x14,0x80,0x00,0x8e,0x44,0x80,0x00,0x8e,0x74, +0x80,0x00,0x8e,0x88,0x80,0x00,0x8e,0xf0,0x80,0x00,0x8f,0x04,0x80,0x00,0x8f,0x40, +0x80,0x00,0x8f,0x48,0x80,0x00,0x8f,0x84,0x80,0x00,0x8f,0x98,0x80,0x00,0x8f,0xa0, +0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8, +0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88, +}; + +u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = { +0x0, }; + +u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = { +0x800,0x00000000, +0x804,0x00000001, +0x808,0x0000fc00, +0x80c,0x0000001c, +0x810,0x801010aa, +0x814,0x008514d0, +0x818,0x00000040, +0x81c,0x00000000, +0x820,0x00000004, +0x824,0x00690000, +0x828,0x00000004, +0x82c,0x00e90000, +0x830,0x00000004, +0x834,0x00690000, +0x838,0x00000004, +0x83c,0x00e90000, +0x840,0x00000000, +0x844,0x00000000, +0x848,0x00000000, +0x84c,0x00000000, +0x850,0x00000000, +0x854,0x00000000, +0x858,0x65a965a9, +0x85c,0x65a965a9, +0x860,0x001f0010, +0x864,0x007f0010, +0x868,0x001f0010, +0x86c,0x007f0010, +0x870,0x0f100f70, +0x874,0x0f100f70, +0x878,0x00000000, +0x87c,0x00000000, +0x880,0x6870e36c, +0x884,0xe3573600, +0x888,0x4260c340, +0x88c,0x0000ff00, +0x890,0x00000000, +0x894,0xfffffffe, +0x898,0x4c42382f, +0x89c,0x00656056, +0x8b0,0x00000000, +0x8e0,0x00000000, +0x8e4,0x00000000, +0x900,0x00000000, +0x904,0x00000023, +0x908,0x00000000, +0x90c,0x31121311, +0xa00,0x00d0c7d8, +0xa04,0x811f0008, +0xa08,0x80cd8300, +0xa0c,0x2e62740f, +0xa10,0x95009b78, +0xa14,0x11145008, +0xa18,0x00881117, +0xa1c,0x89140fa0, +0xa20,0x1a1b0000, +0xa24,0x090e1317, +0xa28,0x00000204, +0xa2c,0x00000000, +0xc00,0x00000040, +0xc04,0x00005433, +0xc08,0x000000e4, +0xc0c,0x6c6c6c6c, +0xc10,0x08800000, +0xc14,0x40000100, +0xc18,0x08000000, +0xc1c,0x40000100, +0xc20,0x08000000, +0xc24,0x40000100, +0xc28,0x08000000, +0xc2c,0x40000100, +0xc30,0x6de9ac44, +0xc34,0x465c52cd, +0xc38,0x497f5994, +0xc3c,0x0a969764, +0xc40,0x1f7c403f, +0xc44,0x000100b7, +0xc48,0xec020000, +0xc4c,0x00000300, +0xc50,0x69543420, +0xc54,0x433c0094, +0xc58,0x69543420, +0xc5c,0x433c0094, +0xc60,0x69543420, +0xc64,0x433c0094, +0xc68,0x69543420, +0xc6c,0x433c0094, +0xc70,0x2c7f000d, +0xc74,0x0186175b, +0xc78,0x0000001f, +0xc7c,0x00b91612, +0xc80,0x40000100, +0xc84,0x20000000, +0xc88,0x40000100, +0xc8c,0x20200000, +0xc90,0x40000100, +0xc94,0x00000000, +0xc98,0x40000100, +0xc9c,0x00000000, +0xca0,0x00492492, +0xca4,0x00000000, +0xca8,0x00000000, +0xcac,0x00000000, +0xcb0,0x00000000, +0xcb4,0x00000000, +0xcb8,0x00000000, +0xcbc,0x00492492, +0xcc0,0x00000000, +0xcc4,0x00000000, +0xcc8,0x00000000, +0xccc,0x00000000, +0xcd0,0x00000000, +0xcd4,0x00000000, +0xcd8,0x64b22427, +0xcdc,0x00766932, +0xce0,0x00222222, +0xd00,0x00000750, +0xd04,0x00000403, +0xd08,0x0000907f, +0xd0c,0x00000001, +0xd10,0xa0633333, +0xd14,0x33333c63, +0xd18,0x6a8f5b6b, +0xd1c,0x00000000, +0xd20,0x00000000, +0xd24,0x00000000, +0xd28,0x00000000, +0xd2c,0xcc979975, +0xd30,0x00000000, +0xd34,0x00000000, +0xd38,0x00000000, +0xd3c,0x00027293, +0xd40,0x00000000, +0xd44,0x00000000, +0xd48,0x00000000, +0xd4c,0x00000000, +0xd50,0x6437140a, +0xd54,0x024dbd02, +0xd58,0x00000000, +0xd5c,0x04032064, +0xe00,0x161a1a1a, +0xe04,0x12121416, +0xe08,0x00001800, +0xe0c,0x00000000, +0xe10,0x161a1a1a, +0xe14,0x12121416, +0xe18,0x161a1a1a, +0xe1c,0x12121416, +}; + +u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x00000ee0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x009,0x000007f0, +0x00a,0x000009d0, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x00f,0x00000990, +0x012,0x00000806, +0x014,0x000005ab, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000f80, +0x01b,0x00000f5e, +0x01c,0x00000008, +0x01d,0x00000607, +0x01e,0x000006cc, +0x01f,0x00000000, +0x020,0x000001a5, +0x01f,0x00000001, +0x020,0x00000165, +0x01f,0x00000002, +0x020,0x000000c6, +0x01f,0x00000003, +0x020,0x00000086, +0x01f,0x00000004, +0x020,0x00000046, +0x01f,0x00000005, +0x020,0x000001e6, +0x01f,0x00000006, +0x020,0x000001a6, +0x01f,0x00000007, +0x020,0x00000166, +0x01f,0x00000008, +0x020,0x000000c7, +0x01f,0x00000009, +0x020,0x00000087, +0x01f,0x0000000a, +0x020,0x000000f7, +0x01f,0x0000000b, +0x020,0x000000d7, +0x01f,0x0000000c, +0x020,0x000000b7, +0x01f,0x0000000d, +0x020,0x00000097, +0x01f,0x0000000e, +0x020,0x00000077, +0x01f,0x0000000f, +0x020,0x00000057, +0x01f,0x00000010, +0x020,0x00000037, +0x01f,0x00000011, +0x020,0x000000fb, +0x01f,0x00000012, +0x020,0x000000db, +0x01f,0x00000013, +0x020,0x000000bb, +0x01f,0x00000014, +0x020,0x000000ff, +0x01f,0x00000015, +0x020,0x000000e3, +0x01f,0x00000016, +0x020,0x000000c3, +0x01f,0x00000017, +0x020,0x000000a3, +0x01f,0x00000018, +0x020,0x00000083, +0x01f,0x00000019, +0x020,0x00000063, +0x01f,0x0000001a, +0x020,0x00000043, +0x01f,0x0000001b, +0x020,0x00000023, +0x01f,0x0000001c, +0x020,0x00000003, +0x01f,0x0000001d, +0x020,0x000001e3, +0x01f,0x0000001e, +0x020,0x000001c3, +0x01f,0x0000001f, +0x020,0x000001a3, +0x01f,0x00000020, +0x020,0x00000183, +0x01f,0x00000021, +0x020,0x00000163, +0x01f,0x00000022, +0x020,0x00000143, +0x01f,0x00000023, +0x020,0x00000123, +0x01f,0x00000024, +0x020,0x00000103, +0x023,0x00000203, +0x024,0x00000100, +0x00b,0x000001ba, +0x02c,0x000003d7, +0x02d,0x00000ff0, +0x000,0x00000037, +0x004,0x00000160, +0x007,0x00000080, +0x002,0x0000088d, +0x0fe,0x00000000, +0x0fe,0x00000000, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x000,0x000000bf, +0x00d,0x0000001f, +0x00d,0x00000c9f, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] = { +0x019,0x00000003, +0x000,0x000000bf, +0x001,0x000006e0, +0x002,0x0000004c, +0x003,0x000007f1, +0x004,0x00000975, +0x005,0x00000c58, +0x006,0x00000ae6, +0x007,0x000000ca, +0x008,0x00000e1c, +0x000,0x000000b7, +0x00a,0x00000850, +0x000,0x000000bf, +0x00b,0x000001ba, +0x00c,0x00000240, +0x00e,0x00000020, +0x015,0x00000f80, +0x016,0x00000020, +0x017,0x00000597, +0x018,0x0000050a, +0x01a,0x00000e00, +0x01b,0x00000f5e, +0x01d,0x00000607, +0x01e,0x000006cc, +0x00b,0x000001ba, +0x023,0x00000203, +0x024,0x00000100, +0x000,0x00000037, +0x004,0x00000160, +0x016,0x00000200, +0x016,0x00000380, +0x016,0x00000020, +0x016,0x000001a0, +0x00d,0x00000ccc, +0x000,0x000000bf, +0x002,0x0000004d, +0x000,0x00000cbf, +0x004,0x00000975, +0x007,0x00000700, +}; + +u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] = { +0x0, }; + +u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] = { +0x0, }; + +u32 Rtl8192PciEMACPHY_Array[] = { +0x03c,0xffff0000,0x00000f0f, +0x340,0xffffffff,0x161a1a1a, +0x344,0xffffffff,0x12121416, +0x348,0x0000ffff,0x00001818, +0x12c,0xffffffff,0x04000802, +0x318,0x00000fff,0x00000100, +}; + +u32 Rtl8192PciEMACPHY_Array_PG[] = { +0x03c,0xffff0000,0x00000f0f, +0xe00,0xffffffff,0x06090909, +0xe04,0xffffffff,0x00030306, +0xe08,0x0000ff00,0x00000000, +0xe10,0xffffffff,0x0a0c0d0f, +0xe14,0xffffffff,0x06070809, +0xe18,0xffffffff,0x0a0c0d0f, +0xe1c,0xffffffff,0x06070809, +0x12c,0xffffffff,0x04000802, +0x318,0x00000fff,0x00000800, +}; + +u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] = { +0xc78,0x7d000001, +0xc78,0x7d010001, +0xc78,0x7d020001, +0xc78,0x7d030001, +0xc78,0x7d040001, +0xc78,0x7d050001, +0xc78,0x7c060001, +0xc78,0x7b070001, +0xc78,0x7a080001, +0xc78,0x79090001, +0xc78,0x780a0001, +0xc78,0x770b0001, +0xc78,0x760c0001, +0xc78,0x750d0001, +0xc78,0x740e0001, +0xc78,0x730f0001, +0xc78,0x72100001, +0xc78,0x71110001, +0xc78,0x70120001, +0xc78,0x6f130001, +0xc78,0x6e140001, +0xc78,0x6d150001, +0xc78,0x6c160001, +0xc78,0x6b170001, +0xc78,0x6a180001, +0xc78,0x69190001, +0xc78,0x681a0001, +0xc78,0x671b0001, +0xc78,0x661c0001, +0xc78,0x651d0001, +0xc78,0x641e0001, +0xc78,0x491f0001, +0xc78,0x48200001, +0xc78,0x47210001, +0xc78,0x46220001, +0xc78,0x45230001, +0xc78,0x44240001, +0xc78,0x43250001, +0xc78,0x28260001, +0xc78,0x27270001, +0xc78,0x26280001, +0xc78,0x25290001, +0xc78,0x242a0001, +0xc78,0x232b0001, +0xc78,0x222c0001, +0xc78,0x212d0001, +0xc78,0x202e0001, +0xc78,0x0a2f0001, +0xc78,0x08300001, +0xc78,0x06310001, +0xc78,0x05320001, +0xc78,0x04330001, +0xc78,0x03340001, +0xc78,0x02350001, +0xc78,0x01360001, +0xc78,0x00370001, +0xc78,0x00380001, +0xc78,0x00390001, +0xc78,0x003a0001, +0xc78,0x003b0001, +0xc78,0x003c0001, +0xc78,0x003d0001, +0xc78,0x003e0001, +0xc78,0x003f0001, +0xc78,0x7d400001, +0xc78,0x7d410001, +0xc78,0x7d420001, +0xc78,0x7d430001, +0xc78,0x7d440001, +0xc78,0x7d450001, +0xc78,0x7c460001, +0xc78,0x7b470001, +0xc78,0x7a480001, +0xc78,0x79490001, +0xc78,0x784a0001, +0xc78,0x774b0001, +0xc78,0x764c0001, +0xc78,0x754d0001, +0xc78,0x744e0001, +0xc78,0x734f0001, +0xc78,0x72500001, +0xc78,0x71510001, +0xc78,0x70520001, +0xc78,0x6f530001, +0xc78,0x6e540001, +0xc78,0x6d550001, +0xc78,0x6c560001, +0xc78,0x6b570001, +0xc78,0x6a580001, +0xc78,0x69590001, +0xc78,0x685a0001, +0xc78,0x675b0001, +0xc78,0x665c0001, +0xc78,0x655d0001, +0xc78,0x645e0001, +0xc78,0x495f0001, +0xc78,0x48600001, +0xc78,0x47610001, +0xc78,0x46620001, +0xc78,0x45630001, +0xc78,0x44640001, +0xc78,0x43650001, +0xc78,0x28660001, +0xc78,0x27670001, +0xc78,0x26680001, +0xc78,0x25690001, +0xc78,0x246a0001, +0xc78,0x236b0001, +0xc78,0x226c0001, +0xc78,0x216d0001, +0xc78,0x206e0001, +0xc78,0x0a6f0001, +0xc78,0x08700001, +0xc78,0x06710001, +0xc78,0x05720001, +0xc78,0x04730001, +0xc78,0x03740001, +0xc78,0x02750001, +0xc78,0x01760001, +0xc78,0x00770001, +0xc78,0x00780001, +0xc78,0x00790001, +0xc78,0x007a0001, +0xc78,0x007b0001, +0xc78,0x007c0001, +0xc78,0x007d0001, +0xc78,0x007e0001, +0xc78,0x007f0001, +0xc78,0x2e00001e, +0xc78,0x2e01001e, +0xc78,0x2e02001e, +0xc78,0x2e03001e, +0xc78,0x2e04001e, +0xc78,0x2e05001e, +0xc78,0x3006001e, +0xc78,0x3407001e, +0xc78,0x3908001e, +0xc78,0x3c09001e, +0xc78,0x3f0a001e, +0xc78,0x420b001e, +0xc78,0x440c001e, +0xc78,0x450d001e, +0xc78,0x460e001e, +0xc78,0x460f001e, +0xc78,0x4710001e, +0xc78,0x4811001e, +0xc78,0x4912001e, +0xc78,0x4a13001e, +0xc78,0x4b14001e, +0xc78,0x4b15001e, +0xc78,0x4c16001e, +0xc78,0x4d17001e, +0xc78,0x4e18001e, +0xc78,0x4f19001e, +0xc78,0x4f1a001e, +0xc78,0x501b001e, +0xc78,0x511c001e, +0xc78,0x521d001e, +0xc78,0x521e001e, +0xc78,0x531f001e, +0xc78,0x5320001e, +0xc78,0x5421001e, +0xc78,0x5522001e, +0xc78,0x5523001e, +0xc78,0x5624001e, +0xc78,0x5725001e, +0xc78,0x5726001e, +0xc78,0x5827001e, +0xc78,0x5828001e, +0xc78,0x5929001e, +0xc78,0x592a001e, +0xc78,0x5a2b001e, +0xc78,0x5b2c001e, +0xc78,0x5c2d001e, +0xc78,0x5c2e001e, +0xc78,0x5d2f001e, +0xc78,0x5e30001e, +0xc78,0x5f31001e, +0xc78,0x6032001e, +0xc78,0x6033001e, +0xc78,0x6134001e, +0xc78,0x6235001e, +0xc78,0x6336001e, +0xc78,0x6437001e, +0xc78,0x6438001e, +0xc78,0x6539001e, +0xc78,0x663a001e, +0xc78,0x673b001e, +0xc78,0x673c001e, +0xc78,0x683d001e, +0xc78,0x693e001e, +0xc78,0x6a3f001e, +}; diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.h b/drivers/staging/rtl8192e/r8192E_hwimg.h new file mode 100644 index 00000000000..061a9c34ac8 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_hwimg.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_HAL8192PciE_FW_IMG_H +#define __INC_HAL8192PciE_FW_IMG_H + +/*Created on 2008/11/18, 3: 7*/ + +#include + +#define BootArrayLengthPciE 344 +extern u8 Rtl8192PciEFwBootArray[BootArrayLengthPciE]; +#define MainArrayLengthPciE 43012 +extern u8 Rtl8192PciEFwMainArray[MainArrayLengthPciE]; +#define DataArrayLengthPciE 848 +extern u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE]; +#define PHY_REGArrayLengthPciE 1 +extern u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE]; +#define PHY_REG_1T2RArrayLengthPciE 296 +extern u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE]; +#define RadioA_ArrayLengthPciE 246 +extern u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] ; +#define RadioB_ArrayLengthPciE 78 +extern u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] ; +#define RadioC_ArrayLengthPciE 1 +extern u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] ; +#define RadioD_ArrayLengthPciE 1 +extern u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] ; +#define MACPHY_ArrayLengthPciE 18 +extern u32 Rtl8192PciEMACPHY_Array[MACPHY_ArrayLengthPciE] ; +#define MACPHY_Array_PGLengthPciE 30 +extern u32 Rtl8192PciEMACPHY_Array_PG[MACPHY_Array_PGLengthPciE] ; +#define AGCTAB_ArrayLengthPciE 384 +extern u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] ; + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c new file mode 100644 index 00000000000..a20451b6ee6 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -0,0 +1,1963 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#if (defined(RTL8192E) || defined(RTL8190P)) + + +#include "rtl_core.h" +#include "r8192E_hw.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" +#include "r8192E_phy.h" +#include "rtl_dm.h" +#ifdef ENABLE_DOT11D +#include "dot11d.h" +#endif + +#ifdef RTL8190P +#include "r8190P_hwimg.h" +#endif + +#ifdef RTL8192E +#include "r8192E_hwimg.h" +#endif + +static u32 RF_CHANNEL_TABLE_ZEBRA[] = { + 0, + 0x085c, + 0x08dc, + 0x095c, + 0x09dc, + 0x0a5c, + 0x0adc, + 0x0b5c, + 0x0bdc, + 0x0c5c, + 0x0cdc, + 0x0d5c, + 0x0ddc, + 0x0e5c, + 0x0f72, +}; + +/*************************Define local function prototype**********************/ + +static u32 phy_FwRFSerialRead(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset); +static void phy_FwRFSerialWrite(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset,u32 Data); +u32 rtl8192_CalculateBitShift(u32 dwBitMask) +{ + u32 i; + for (i=0; i<=31; i++) + { + if (((dwBitMask>>i)&0x1) == 1) + break; + } + return i; +} +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) +{ + u8 ret = 1; + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef RTL8190P + if (priv->rf_type == RF_2T4R) + { + ret= 1; + } + else if (priv->rf_type == RF_1T2R) + { + if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) + ret = 0; + else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) + ret = 1; + } +#else + #ifdef RTL8192E + if (priv->rf_type == RF_2T4R) + ret = 0; + else if (priv->rf_type == RF_1T2R) + { + if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) + ret = 1; + else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) + ret = 0; + } + #endif +#endif + return ret; +} +void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) +{ + + u32 OriginalValue, BitShift, NewValue; + + if (dwBitMask!= bMaskDWord) + { + OriginalValue = read_nic_dword(dev, dwRegAddr); + BitShift = rtl8192_CalculateBitShift(dwBitMask); + NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift)); + write_nic_dword(dev, dwRegAddr, NewValue); + }else + write_nic_dword(dev, dwRegAddr, dwData); + return; +} +u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) +{ + u32 Ret = 0, OriginalValue, BitShift; + + OriginalValue = read_nic_dword(dev, dwRegAddr); + BitShift = rtl8192_CalculateBitShift(dwBitMask); + Ret = (OriginalValue & dwBitMask) >> BitShift; + + return (Ret); +} +u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 ret = 0; + u32 NewOffset = 0; + BB_REGISTER_DEFINITION_T* pPhyReg = &priv->PHYRegDef[eRFPath]; + Offset &= 0x3f; + + if (priv->rf_chip == RF_8256) + { +#ifdef RTL8190P + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); + #endif +#endif + if (Offset >= 31) + { + priv->RfReg0Value[eRFPath] |= 0x140; + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); + NewOffset = Offset -30; + } + else if (Offset >= 16) + { + priv->RfReg0Value[eRFPath] |= 0x100; + priv->RfReg0Value[eRFPath] &= (~0x40); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); + + NewOffset = Offset - 15; + } + else + NewOffset = Offset; + } + else + { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + NewOffset = Offset; + } + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1); + + + msleep(1); + + ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); + + + if (priv->rf_chip == RF_8256) + { + priv->RfReg0Value[eRFPath] &= 0xebf; + + rtl8192_setBBreg( + dev, + pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); + +#ifdef RTL8190P + if (priv->rf_type == RF_2T4R) + { + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); + } + else if (priv->rf_type == RF_1T2R) + { + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); + } +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); + #endif +#endif + } + + + return ret; + +} + +void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 DataAndAddr = 0, NewOffset = 0; + BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; + + Offset &= 0x3f; + if (priv->rf_chip == RF_8256) + { + +#ifdef RTL8190P + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); + #endif +#endif + + if (Offset >= 31) + { + priv->RfReg0Value[eRFPath] |= 0x140; + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); + NewOffset = Offset - 30; + } + else if (Offset >= 16) + { + priv->RfReg0Value[eRFPath] |= 0x100; + priv->RfReg0Value[eRFPath] &= (~0x40); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16)); + NewOffset = Offset - 15; + } + else + NewOffset = Offset; + } + else + { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + NewOffset = Offset; + } + + DataAndAddr = (Data<<16) | (NewOffset&0x3f); + + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); + + + if (Offset==0x0) + priv->RfReg0Value[eRFPath] = Data; + + if (priv->rf_chip == RF_8256) + { + if (Offset != 0) + { + priv->RfReg0Value[eRFPath] &= 0xebf; + rtl8192_setBBreg( + dev, + pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); + } +#ifdef RTL8190P + if (priv->rf_type == RF_2T4R) + { + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); + } + else if (priv->rf_type == RF_1T2R) + { + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); + } +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); + #endif +#endif + } + + return; +} + +void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 Original_Value, BitShift, New_Value; + + if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + return; +#ifdef RTL8192E + if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) + return; +#endif + + RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); + if (priv->Rf_Mode == RF_OP_By_FW) + { + if (BitMask != bMask12Bits) + { + Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); + BitShift = rtl8192_CalculateBitShift(BitMask); + New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + + phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value); + }else + phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data); + udelay(200); + + } + else + { + if (BitMask != bMask12Bits) + { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); + BitShift = rtl8192_CalculateBitShift(BitMask); + New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + + rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value); + }else + rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data); + } + return; +} + +u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask) +{ + u32 Original_Value, Readback_Value, BitShift; + struct r8192_priv *priv = rtllib_priv(dev); + if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + return 0; +#ifdef RTL8192E + if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) + return 0; +#endif + down(&priv->rf_sem); + if (priv->Rf_Mode == RF_OP_By_FW) + { + Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); + udelay(200); + } + else + { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); + + } + BitShift = rtl8192_CalculateBitShift(BitMask); + Readback_Value = (Original_Value & BitMask) >> BitShift; + up(&priv->rf_sem); + return (Readback_Value); +} + +static u32 phy_FwRFSerialRead( + struct net_device* dev, + RF90_RADIO_PATH_E eRFPath, + u32 Offset ) +{ + u32 retValue = 0; + u32 Data = 0; + u8 time = 0; + Data |= ((Offset&0xFF)<<12); + Data |= ((eRFPath&0x3)<<20); + Data |= 0x80000000; + while (read_nic_dword(dev, QPNR)&0x80000000) + { + if (time++ < 100) + { + udelay(10); + } + else + break; + } + write_nic_dword(dev, QPNR, Data); + while (read_nic_dword(dev, QPNR)&0x80000000) + { + if (time++ < 100) + { + udelay(10); + } + else + return (0); + } + retValue = read_nic_dword(dev, RF_DATA); + + return (retValue); + +} /* phy_FwRFSerialRead */ + +static void +phy_FwRFSerialWrite( + struct net_device* dev, + RF90_RADIO_PATH_E eRFPath, + u32 Offset, + u32 Data ) +{ + u8 time = 0; + + + Data |= ((Offset&0xFF)<<12); + Data |= ((eRFPath&0x3)<<20); + Data |= 0x400000; + Data |= 0x80000000; + + while (read_nic_dword(dev, QPNR)&0x80000000) + { + if (time++ < 100) + { + udelay(10); + } + else + break; + } + write_nic_dword(dev, QPNR, Data); + +} /* phy_FwRFSerialWrite */ + + +void rtl8192_phy_configmac(struct net_device* dev) +{ + u32 dwArrayLen = 0, i = 0; + u32* pdwArray = NULL; + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef TO_DO_LIST +if (dev->bInHctTest) + { + RT_TRACE(COMP_PHY, "Rtl819XMACPHY_ArrayDTM\n"); + dwArrayLen = MACPHY_ArrayLengthDTM; + pdwArray = Rtl819XMACPHY_ArrayDTM; + } + else if (priv->bTXPowerDataReadFromEEPORM) +#endif + if (priv->bTXPowerDataReadFromEEPORM) + { + RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); + dwArrayLen = MACPHY_Array_PGLength; + pdwArray = Rtl819XMACPHY_Array_PG; + + } + else + { + RT_TRACE(COMP_PHY,"Read rtl819XMACPHY_Array\n"); + dwArrayLen = MACPHY_ArrayLength; + pdwArray = Rtl819XMACPHY_Array; + } + for (i = 0; ibInHctTest) + { + AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM; + Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM; + + if (priv->RF_Type == RF_2T4R) + { + PHY_REGArrayLen = PHY_REGArrayLengthDTM; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArrayDTM; + } + else if (priv->RF_Type == RF_1T2R) + { + PHY_REGArrayLen = PHY_REG_1T2RArrayLengthDTM; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArrayDTM; + } + } + else +#endif + { + AGCTAB_ArrayLen = AGCTAB_ArrayLength; + Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; + if (priv->rf_type == RF_2T4R) + { + PHY_REGArrayLen = PHY_REGArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; + } + else if (priv->rf_type == RF_1T2R) + { + PHY_REGArrayLen = PHY_REG_1T2RArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; + } + } + + if (ConfigType == BaseBand_Config_PHY_REG) + { + for (i=0; iPHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; + priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; + priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; + priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW; + + priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; + priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB; + priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB; + priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB; + + priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE; + + priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE; + priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE; + + priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; + priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter; + priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter; + + priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; + priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; + priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; + priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; + + priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; + priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; + priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; + priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; + + priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; + priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; + priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; + priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; + + priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; + priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; + priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; + priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; + + priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; + priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; + priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; + priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; + + priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; + priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; + priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; + priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; + + priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; + priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; + priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; + priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; + + priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; + priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; + priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; + priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; + + priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE; + priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; + priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; + priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; + + priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; + priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; + priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; + priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; + + priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE; + priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; + priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; + priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; + + priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; + priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; + +} +bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath) +{ + bool ret = true; + u32 i, CheckTimes = 4, dwRegRead = 0; + u32 WriteAddr[4]; + u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f}; + WriteAddr[HW90_BLOCK_MAC] = 0x100; + WriteAddr[HW90_BLOCK_PHY0] = 0x900; + WriteAddr[HW90_BLOCK_PHY1] = 0x800; + WriteAddr[HW90_BLOCK_RF] = 0x3; + RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, CheckBlock); + for (i=0 ; i < CheckTimes ; i++) + { + + switch (CheckBlock) + { + case HW90_BLOCK_MAC: + RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!"); + break; + + case HW90_BLOCK_PHY0: + case HW90_BLOCK_PHY1: + write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]); + dwRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]); + break; + + case HW90_BLOCK_RF: + WriteData[i] &= 0xfff; + rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); + mdelay(10); + dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord); + mdelay(10); + break; + + default: + ret = false; + break; + } + + + if (dwRegRead != WriteData[i]) + { + RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, WriteData: %x \n", dwRegRead, WriteData[i]); + ret = false; + break; + } + } + + return ret; +} + +bool rtl8192_BB_Config_ParaFile(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool rtStatus = true; + u8 bRegValue = 0, eCheckItem = 0; + u32 dwRegValue = 0; + /************************************** + **************************************/ + + bRegValue = read_nic_byte(dev, BB_GLOBAL_RESET); + write_nic_byte(dev, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT)); + + dwRegValue = read_nic_dword(dev, CPU_GEN); + write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); + + for (eCheckItem=(HW90_BLOCK_E)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) + { + rtStatus = rtl8192_phy_checkBBAndRF(dev, (HW90_BLOCK_E)eCheckItem, (RF90_RADIO_PATH_E)0); + if (rtStatus != true) + { + RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); + return rtStatus; + } + } + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn|bOFDMEn, 0x0); + rtl8192_phyConfigBB(dev, BaseBand_Config_PHY_REG); + + dwRegValue = read_nic_dword(dev, CPU_GEN); + write_nic_dword(dev, CPU_GEN, (dwRegValue|CPU_GEN_BB_RST)); + + rtl8192_phyConfigBB(dev, BaseBand_Config_AGC_TAB); + + if (priv->IC_Cut > VERSION_8190_BD) + { + if (priv->rf_type == RF_2T4R) + { + dwRegValue = ( priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); + } + else + dwRegValue = 0x0; + rtl8192_setBBreg(dev, rFPGA0_TxGainStage, + (bXBTxAGC|bXCTxAGC|bXDTxAGC), dwRegValue); + + +#ifdef RTL8190P + dwRegValue = priv->CrystalCap & 0x3; + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap01, dwRegValue); + dwRegValue = ((priv->CrystalCap & 0xc)>>2); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, bXtalCap23, dwRegValue); +#else + #ifdef RTL8192E + dwRegValue = priv->CrystalCap; + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); + #endif +#endif + + } + + return rtStatus; +} +bool rtl8192_BBConfig(struct net_device* dev) +{ + bool rtStatus = true; + rtl8192_InitBBRFRegDef(dev); + rtStatus = rtl8192_BB_Config_ParaFile(dev); + return rtStatus; +} + +void rtl8192_phy_getTxPower(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); +#ifdef RTL8190P + priv->MCSTxPowerLevelOriginalOffset[0] = + read_nic_dword(dev, MCS_TXAGC); + priv->MCSTxPowerLevelOriginalOffset[1] = + read_nic_dword(dev, (MCS_TXAGC+4)); + priv->CCKTxPowerLevelOriginalOffset = + read_nic_dword(dev, CCK_TXAGC); +#else + #ifdef RTL8192E + priv->MCSTxPowerLevelOriginalOffset[0] = + read_nic_dword(dev, rTxAGC_Rate18_06); + priv->MCSTxPowerLevelOriginalOffset[1] = + read_nic_dword(dev, rTxAGC_Rate54_24); + priv->MCSTxPowerLevelOriginalOffset[2] = + read_nic_dword(dev, rTxAGC_Mcs03_Mcs00); + priv->MCSTxPowerLevelOriginalOffset[3] = + read_nic_dword(dev, rTxAGC_Mcs07_Mcs04); + priv->MCSTxPowerLevelOriginalOffset[4] = + read_nic_dword(dev, rTxAGC_Mcs11_Mcs08); + priv->MCSTxPowerLevelOriginalOffset[5] = + read_nic_dword(dev, rTxAGC_Mcs15_Mcs12); + #endif +#endif + + priv->DefaultInitialGain[0] = read_nic_byte(dev, rOFDM0_XAAGCCore1); + priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); + priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1); + priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1); + RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n", + priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], + priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); + + priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3); + priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2); + RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n", + rOFDM0_RxDetector3, priv->framesync); + priv->SifsTime = read_nic_word(dev, SIFS); + return; +} + +void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 powerlevel = 0,powerlevelOFDM24G = 0; + char ant_pwr_diff; + u32 u4RegValue; + + if (priv->epromtype == EEPROM_93C46) + { + powerlevel = priv->TxPowerLevelCCK[channel-1]; + powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; + } + else if (priv->epromtype == EEPROM_93C56) + { + if (priv->rf_type == RF_1T2R) + { + powerlevel = priv->TxPowerLevelCCK_C[channel-1]; + powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; + } + else if (priv->rf_type == RF_2T4R) + { + powerlevel = priv->TxPowerLevelCCK_A[channel-1]; + powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; + + ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] + -priv->TxPowerLevelOFDM24G_A[channel-1]; + + priv->RF_C_TxPwDiff = ant_pwr_diff; + + ant_pwr_diff &= 0xf; + + priv->AntennaTxPwDiff[2] = 0; + priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); + priv->AntennaTxPwDiff[0] = 0; + + u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); + + rtl8192_setBBreg(dev, rFPGA0_TxGainStage, + (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); + } + } +#ifdef TODO + if ( pMgntInfo->OpMode == RT_OP_MODE_INFRASTRUCTURE && + pMgntInfo->bWithCcxCellPwr && + channel == pMgntInfo->dot11CurrentChannelNumber) + { + u8 CckCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_B, pMgntInfo->CcxCellPwr); + u8 LegacyOfdmCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_G, pMgntInfo->CcxCellPwr); + u8 OfdmCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, pMgntInfo->CcxCellPwr); + + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("CCX Cell Limit: %d dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", + pMgntInfo->CcxCellPwr, CckCellPwrIdx, LegacyOfdmCellPwrIdx, OfdmCellPwrIdx)); + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", + channel, powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); + + if (powerlevel > CckCellPwrIdx) + powerlevel = CckCellPwrIdx; + if (powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff > OfdmCellPwrIdx) + { + if ((OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff) > 0) + { + powerlevelOFDM24G = OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff; + } + else + { + LegacyOfdmCellPwrIdx = 0; + } + } + + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n", + powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); + } + + pHalData->CurrentCckTxPwrIdx = powerlevel; + pHalData->CurrentOfdm24GTxPwrIdx = powerlevelOFDM24G; + + RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_GET_CHANNEL, &channel, &pChannelInfo); + + if (pChannelInfo) + { + if (pChannelInfo->MaxTxPwrDbm != UNSPECIFIED_PWR_DBM) + { + u1Byte CckMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, pChannelInfo->MaxTxPwrDbm); + u1Byte LegacyOfdmMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_G, pChannelInfo->MaxTxPwrDbm); + u1Byte OfdmMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, pChannelInfo->MaxTxPwrDbm); + + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("CCX Cell Limit: %ld dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", + pChannelInfo->MaxTxPwrDbm, CckMaxPwrIdx, LegacyOfdmMaxPwrIdx, OfdmMaxPwrIdx)); + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", + channel, powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); + + if (powerlevel > CckMaxPwrIdx) + powerlevel = CckMaxPwrIdx; + if (powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff > OfdmMaxPwrIdx) + { + if ((OfdmMaxPwrIdx - pHalData->LegacyHTTxPowerDiff) > 0) + { + powerlevelOFDM24G = OfdmMaxPwrIdx - pHalData->LegacyHTTxPowerDiff; + } + else + { + LegacyOfdmMaxPwrIdx = 0; + } + } + + RT_TRACE(COMP_TXAGC, DBG_LOUD, + ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n", + powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); + } + } +#endif + switch (priv->rf_chip) + { + case RF_8225: + break; + case RF_8256: + PHY_SetRF8256CCKTxPower(dev, powerlevel); + PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G); + break; + case RF_8258: + break; + default: + RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", __func__); + break; + } + return; +} + +bool rtl8192_phy_RFConfig(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + bool rtStatus = true; + switch (priv->rf_chip) + { + case RF_8225: + break; + case RF_8256: + rtStatus = PHY_RF8256_Config(dev); + break; + + case RF_8258: + break; + case RF_PSEUDO_11N: + break; + + default: + RT_TRACE(COMP_ERR, "error chip id\n"); + break; + } + return rtStatus; +} + +void rtl8192_phy_updateInitGain(struct net_device* dev) +{ + return; +} + +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath) +{ + + int i; + u8 ret = 0; + + switch (eRFPath){ + case RF90_PATH_A: + for (i = 0;iTxPowerLevelCCK[channel-1]; + u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; + + switch (priv->rf_chip) + { + case RF_8225: +#ifdef TO_DO_LIST + PHY_SetRF8225CckTxPower(dev, powerlevel); + PHY_SetRF8225OfdmTxPower(dev, powerlevelOFDM24G); +#endif + break; + + case RF_8256: + PHY_SetRF8256CCKTxPower(dev, powerlevel); + PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G); + break; + + case RF_8258: + break; + default: + RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n"); + break; + } + return; +} +u8 rtl8192_phy_SetSwChnlCmdArray( + SwChnlCmd* CmdTable, + u32 CmdTableIdx, + u32 CmdTableSz, + SwChnlCmdID CmdID, + u32 Para1, + u32 Para2, + u32 msDelay + ) +{ + SwChnlCmd* pCmd; + + if (CmdTable == NULL) + { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); + return false; + } + if (CmdTableIdx >= CmdTableSz) + { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", + CmdTableIdx, CmdTableSz); + return false; + } + + pCmd = CmdTable + CmdTableIdx; + pCmd->CmdID = CmdID; + pCmd->Para1 = Para1; + pCmd->Para2 = Para2; + pCmd->msDelay = msDelay; + + return true; +} +u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay) +{ + struct r8192_priv *priv = rtllib_priv(dev); + SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; + u32 PreCommonCmdCnt; + SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; + u32 PostCommonCmdCnt; + SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; + u32 RfDependCmdCnt; + SwChnlCmd *CurrentCmd = NULL; + u8 eRFPath; + + RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); + +#ifdef ENABLE_DOT11D + if (!IsLegalChannel(priv->rtllib, channel)) + { + RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); + return true; + } +#endif + + { + PreCommonCmdCnt = 0; + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, + CmdID_SetTxPowerLevel, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, + CmdID_End, 0, 0, 0); + + PostCommonCmdCnt = 0; + + rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, + CmdID_End, 0, 0, 0); + + RfDependCmdCnt = 0; + switch ( priv->rf_chip ) + { + case RF_8225: + if (!(channel >= 1 && channel <= 14)) + { + RT_TRACE(COMP_ERR, "illegal channel for Zebra 8225: %d\n", channel); + return false; + } + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_End, 0, 0, 0); + break; + + case RF_8256: + if (!(channel >= 1 && channel <= 14)) + { + RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel); + return false; + } + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_End, 0, 0, 0); + break; + + case RF_8258: + break; + + default: + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + return false; + break; + } + + + do{ + switch (*stage) + { + case 0: + CurrentCmd=&PreCommonCmd[*step]; + break; + case 1: + CurrentCmd=&RfDependCmd[*step]; + break; + case 2: + CurrentCmd=&PostCommonCmd[*step]; + break; + } + + if (CurrentCmd->CmdID==CmdID_End) + { + if ((*stage)==2) + { + return true; + } + else + { + (*stage)++; + (*step)=0; + continue; + } + } + + switch (CurrentCmd->CmdID) + { + case CmdID_SetTxPowerLevel: + if (priv->IC_Cut > (u8)VERSION_8190_BD) + rtl8192_SetTxPowerLevel(dev,channel); + break; + case CmdID_WritePortUlong: + write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); + break; + case CmdID_WritePortUshort: + write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); + break; + case CmdID_WritePortUchar: + write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); + break; + case CmdID_RF_WriteReg: + for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) + rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); + break; + default: + break; + } + + break; + }while(true); + }/*for (Number of RF paths)*/ + + (*delay)=CurrentCmd->msDelay; + (*step)++; + return false; +} + +void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 delay = 0; + + while(!rtl8192_phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay)) + { + if (delay>0) + msleep(delay); + if (IS_NIC_DOWN(priv)) + break; + } +} +void rtl8192_SwChnl_WorkItem(struct net_device *dev) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + + RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); + + RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, priv->chan, priv); + + rtl8192_phy_FinishSwChnlNow(dev , priv->chan); + + RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); +} + +u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) +{ + struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); + if (IS_NIC_DOWN(priv)) + { + RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n",__func__); + return false; + } + if (priv->SwChnlInProgress) + return false; + + + switch (priv->rtllib->mode) + { + case WIRELESS_MODE_A: + case WIRELESS_MODE_N_5G: + if (channel<=14){ + RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14"); + return false; + } + break; + case WIRELESS_MODE_B: + if (channel>14){ + RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14"); + return false; + } + break; + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + if (channel>14){ + RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14"); + return false; + } + break; + } + + priv->SwChnlInProgress = true; + if (channel == 0) + channel = 1; + + priv->chan=channel; + + priv->SwChnlStage=0; + priv->SwChnlStep=0; + + if (!IS_NIC_DOWN(priv)){ + rtl8192_SwChnl_WorkItem(dev); + } + priv->SwChnlInProgress = false; + return true; +} + +static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev ) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + switch (priv->CurrentChannelBW) + { + case HT_CHANNEL_WIDTH_20: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); + + if (priv->rtllib->current_network.channel== 14 && !priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + break; + + case HT_CHANNEL_WIDTH_20_40: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; + + RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + break; + } +} + +#ifndef RTL8190P +static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + priv->bcck_in_ch14 = true; + else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + priv->bcck_in_ch14 = false; + + switch (priv->CurrentChannelBW) + { + case HT_CHANNEL_WIDTH_20: + if (priv->Record_CCK_20Mindex == 0) + priv->Record_CCK_20Mindex = 6; + priv->CCK_index = priv->Record_CCK_20Mindex; + RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n", priv->CCK_index); + break; + + case HT_CHANNEL_WIDTH_20_40: + priv->CCK_index = priv->Record_CCK_40Mindex; + RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n", priv->CCK_index); + break; + } + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); +} +#endif + +static void CCK_Tx_Power_Track_BW_Switch(struct net_device *dev) +{ +#ifdef RTL8192E + struct r8192_priv *priv = rtllib_priv(dev); +#endif + +#ifdef RTL8190P + CCK_Tx_Power_Track_BW_Switch_TSSI(dev); +#else + if (priv->IC_Cut >= IC_VersionCut_D) + CCK_Tx_Power_Track_BW_Switch_TSSI(dev); + else + CCK_Tx_Power_Track_BW_Switch_ThermalMeter(dev); +#endif +} + +void rtl8192_SetBWModeWorkItem(struct net_device *dev) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + u8 regBwOpMode; + + RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \ + priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz") + + + if (priv->rf_chip== RF_PSEUDO_11N) + { + priv->SetBWModeInProgress= false; + return; + } + if (IS_NIC_DOWN(priv)){ + RT_TRACE(COMP_ERR,"%s(): ERR!! driver is not up\n",__func__); + return; + } + regBwOpMode = read_nic_byte(dev, BW_OPMODE); + + switch (priv->CurrentChannelBW) + { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; + + case HT_CHANNEL_WIDTH_20_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; + + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW); + break; + } + + switch (priv->CurrentChannelBW) + { + case HT_CHANNEL_WIDTH_20: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); + + if (!priv->btxpower_tracking) + { + write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); + } + else + CCK_Tx_Power_Track_BW_Switch(dev); + +#ifdef RTL8190P + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 1); + rtl8192_setBBreg(dev, rOFDM0_RxDetector1, bMaskByte0, 0x44); +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); + #endif +#endif + + break; + case HT_CHANNEL_WIDTH_20_40: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); + + if (!priv->btxpower_tracking) + { + write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); + } + else + CCK_Tx_Power_Track_BW_Switch(dev); + + rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); + rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); + + +#ifdef RTL8190P + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 0); + rtl8192_setBBreg(dev, rOFDM0_RxDetector1, bMaskByte0, 0x42); + + if (priv->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + { + rtl8192_setBBreg(dev, rFPGA0_RFMOD, (BIT6|BIT5), 0x01); + }else if (priv->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + { + rtl8192_setBBreg(dev, rFPGA0_RFMOD, (BIT6|BIT5), 0x02); + } + +#else + #ifdef RTL8192E + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); + #endif +#endif + break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); + break; + + } + +#if 1 + switch ( priv->rf_chip ) + { + case RF_8225: +#ifdef TO_DO_LIST + PHY_SetRF8225Bandwidth(dev, pHalData->CurrentChannelBW); +#endif + break; + + case RF_8256: + PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); + break; + + case RF_8258: + break; + + case RF_PSEUDO_11N: + break; + + default: + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + break; + } +#endif + atomic_dec(&(priv->rtllib->atm_swbw)); + priv->SetBWModeInProgress= false; + + RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); +} + +void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + + if (priv->SetBWModeInProgress) + return; + + atomic_inc(&(priv->rtllib->atm_swbw)); + priv->SetBWModeInProgress= true; + + priv->CurrentChannelBW = Bandwidth; + + if (Offset==HT_EXTCHNL_OFFSET_LOWER) + priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; + else if (Offset==HT_EXTCHNL_OFFSET_UPPER) + priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; + else + priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + rtl8192_SetBWModeWorkItem(dev); + +} + + +void InitialGain819xPci(struct net_device *dev, u8 Operation) +{ +#define SCAN_RX_INITIAL_GAIN 0x17 +#define POWER_DETECTION_TH 0x08 + struct r8192_priv *priv = rtllib_priv(dev); + u32 BitMask; + u8 initial_gain; + + if (!IS_NIC_DOWN(priv)){ + switch (Operation) + { + case IG_Backup: + RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n"); + initial_gain = SCAN_RX_INITIAL_GAIN; + BitMask = bMaskByte0; + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask); + priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask); + priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask); + priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask); + BitMask = bMaskByte2; + priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask); + + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + + RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain); + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH); + write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); + break; + case IG_Restore: + RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n"); + BitMask = 0x7f; + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1); + BitMask = bMaskByte2; + rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); + + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + + rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + + + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + break; + default: + RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n"); + break; + } + } +} + +#if defined RTL8190P +extern void +PHY_SetRtl8190pRfOff(struct net_device* dev ) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->rf_type == RF_2T4R) + { + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); + } + rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e0, 0x0); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0x0); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e00, 0x0); + +} +#endif + +#if defined RTL8192E +extern void +PHY_SetRtl8192eRfOff(struct net_device* dev ) +{ + + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x0); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0x0); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x4, 0x0); + write_nic_byte(dev, ANAPAR_FOR_8192PciE, 0x07); + +} +#endif + +#ifndef RTL8192SE +bool +SetRFPowerState8190( + struct net_device* dev, + RT_RF_POWER_STATE eRFPowerState + ) +{ + struct r8192_priv *priv = rtllib_priv(dev); +#if defined RTL8192E + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); +#endif + bool bResult = true; + u8 i = 0, QueueID = 0; + struct rtl8192_tx_ring *ring = NULL; + + if (priv->SetRFPowerStateInProgress == true) + return false; + RT_TRACE(COMP_PS, "===========> SetRFPowerState8190()!\n"); + priv->SetRFPowerStateInProgress = true; + + switch (priv->rf_chip) + { + case RF_8256: + switch ( eRFPowerState ) + { + case eRfOn: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn !\n"); + #ifdef RTL8190P + if (priv->rf_type == RF_2T4R) + { + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e0, 0xf); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0xf); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0xf); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e00, 0xf); + } + else if (priv->rf_type == RF_1T2R) + { + rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x180, 0x3); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xc, 0x3); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xc, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1800, 0x3); + } + else if (priv->rf_type == RF_1T1R) + { + rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x400, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x80, 0x1); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x4, 0x1); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x800, 0x1); + } + +#elif defined RTL8192E + if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) + { + bool rtstatus = true; + u32 InitilizeCount = 3; + do + { + InitilizeCount--; + priv->RegRfOff = false; + rtstatus = NicIFEnableNIC(dev); + }while( (rtstatus != true) &&(InitilizeCount >0) ); + + if (rtstatus != true) + { + RT_TRACE(COMP_ERR,"%s():Initialize Adapter fail,return\n",__func__); + priv->SetRFPowerStateInProgress = false; + return false; + } + + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } else { + write_nic_byte(dev, ANAPAR, 0x37); + mdelay(1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x4, 0x1); + priv->bHwRfOffAction = 0; + + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x3); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, 0x3); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); + + } + + #endif + break; + + case eRfSleep: + { + if (priv->rtllib->eRFPowerState == eRfOff) + break; + + + { + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) + { + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } +#ifdef TO_DO_LIST + else if (IsLowPowerState(Adapter)) + { + RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID); + break; + } +#endif + else + { + RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); + udelay(10); + i++; + } + + if (i >= MAX_DOZE_WAITING_TIMES_9x) + { + RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! SetRFPowerState8190(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); + break; + } + } + } + +#ifdef RTL8190P + { + PHY_SetRtl8190pRfOff(dev); + } +#elif defined RTL8192E + { + PHY_SetRtl8192eRfOff(dev); + } +#endif + } + break; + + case eRfOff: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/Sleep !\n"); + + + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } +#ifdef TO_DO_LIST + else if (IsLowPowerState(Adapter)) + { + RT_TRACE(COMP_POWER, + "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID); + break; + } +#endif + else + { + RT_TRACE(COMP_POWER, + "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); + udelay(10); + i++; + } + + if (i >= MAX_DOZE_WAITING_TIMES_9x) + { + RT_TRACE(COMP_POWER, "\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); + break; + } + } + +#if defined RTL8190P + { + PHY_SetRtl8190pRfOff(dev); + } +#elif defined RTL8192E + { + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) + { + + NicIFDisableNIC(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } + else if (!(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC)) + { + PHY_SetRtl8192eRfOff(dev); + } +#ifdef TO_DO_LIST + if (pMgntInfo->RfOffReason == RF_CHANGE_BY_IPS ) + { + Adapter->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK); + } + else + { + Adapter->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF); + } +#endif + } +#else + else + { + RT_TRACE(COMP_DBG,DBG_TRACE,("It is not 8190Pci and 8192PciE \n")); + } + #endif + + break; + + default: + bResult = false; + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state to set: 0x%X!!!\n", eRFPowerState); + break; + } + + break; + + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; + } + + if (bResult) { + priv->rtllib->eRFPowerState = eRFPowerState; + + switch (priv->rf_chip ) + { + case RF_8256: + switch (priv->rtllib->eRFPowerState) + { + case eRfOff: + if (priv->rtllib->RfOffReason==RF_CHANGE_BY_IPS ) { + #ifdef TO_DO + dev->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK); + #endif + } else { + #ifdef TO_DO + dev->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF); + #endif + } + break; + + case eRfOn: + if ( priv->rtllib->state == RTLLIB_LINKED) { + #ifdef TO_DO + dev->HalFunc.LedControlHandler(dev, LED_CTL_LINK); + #endif + } else { + #ifdef TO_DO + dev->HalFunc.LedControlHandler(dev, LED_CTL_NO_LINK); + #endif + } + break; + + default: + break; + } + + break; + + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; + } + } + + priv->SetRFPowerStateInProgress = false; + RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", bResult); + return bResult; +} + + + +bool +SetRFPowerState( + struct net_device* dev, + RT_RF_POWER_STATE eRFPowerState + ) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + bool bResult = false; + + RT_TRACE(COMP_PS,"---------> SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState); + if (eRFPowerState == priv->rtllib->eRFPowerState && priv->bHwRfOffAction == 0) { + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState); + return bResult; + } + + bResult = SetRFPowerState8190(dev, eRFPowerState); + + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", bResult); + + return bResult; +} +#endif + +extern void +PHY_ScanOperationBackup8192( + struct net_device* dev, + u8 Operation + ) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->up) { + switch (Operation) { + case SCAN_OPT_BACKUP: + priv->rtllib->InitialGainHandler(dev,IG_Backup); + break; + + case SCAN_OPT_RESTORE: + priv->rtllib->InitialGainHandler(dev,IG_Restore); + break; + + default: + RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation. \n"); + break; + } + } + +} + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h new file mode 100644 index 00000000000..ad0b9fd9d25 --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef _R819XU_PHY_H +#define _R819XU_PHY_H + +#define MAX_DOZE_WAITING_TIMES_9x 64 + +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + +#ifdef RTL8190P +#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPci +#define MACPHY_ArrayLength MACPHY_ArrayLengthPci +#define RadioA_ArrayLength RadioA_ArrayLengthPci +#define RadioB_ArrayLength RadioB_ArrayLengthPci +#define MACPHY_Array_PGLength MACPHY_Array_PGLengthPci +#define RadioC_ArrayLength RadioC_ArrayLengthPci +#define RadioD_ArrayLength RadioD_ArrayLengthPci +#define PHY_REGArrayLength PHY_REGArrayLengthPci +#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPci + +#define Rtl819XMACPHY_Array_PG Rtl8190PciMACPHY_Array_PG +#define Rtl819XMACPHY_Array Rtl8190PciMACPHY_Array +#define Rtl819XRadioA_Array Rtl8190PciRadioA_Array +#define Rtl819XRadioB_Array Rtl8190PciRadioB_Array +#define Rtl819XRadioC_Array Rtl8190PciRadioC_Array +#define Rtl819XRadioD_Array Rtl8190PciRadioD_Array +#define Rtl819XAGCTAB_Array Rtl8190PciAGCTAB_Array +#define Rtl819XPHY_REGArray Rtl8190PciPHY_REGArray +#define Rtl819XPHY_REG_1T2RArray Rtl8190PciPHY_REG_1T2RArray +#endif + +#ifdef RTL8192E +#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE +#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE +#define RadioA_ArrayLength RadioA_ArrayLengthPciE +#define RadioB_ArrayLength RadioB_ArrayLengthPciE +#define MACPHY_Array_PGLength MACPHY_Array_PGLengthPciE +#define RadioC_ArrayLength RadioC_ArrayLengthPciE +#define RadioD_ArrayLength RadioD_ArrayLengthPciE +#define PHY_REGArrayLength PHY_REGArrayLengthPciE +#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE + +#define Rtl819XMACPHY_Array_PG Rtl8192PciEMACPHY_Array_PG +#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array +#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array +#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array +#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array +#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array +#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array +#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray +#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray +#endif + + + +typedef enum _SwChnlCmdID{ + CmdID_End, + CmdID_SetTxPowerLevel, + CmdID_BBRegWrite10, + CmdID_WritePortUlong, + CmdID_WritePortUshort, + CmdID_WritePortUchar, + CmdID_RF_WriteReg, +}SwChnlCmdID; + +/*--------------------------------Define structure--------------------------------*/ +typedef struct _SwChnlCmd{ + SwChnlCmdID CmdID; + u32 Para1; + u32 Para2; + u32 msDelay; +}__attribute__ ((packed)) SwChnlCmd; + +extern u32 rtl819XMACPHY_Array_PG[]; +extern u32 rtl819XPHY_REG_1T2RArray[]; +extern u32 rtl819XAGCTAB_Array[]; +extern u32 rtl819XRadioA_Array[]; +extern u32 rtl819XRadioB_Array[]; +extern u32 rtl819XRadioC_Array[]; +extern u32 rtl819XRadioD_Array[]; + +typedef enum _HW90_BLOCK{ + HW90_BLOCK_MAC = 0, + HW90_BLOCK_PHY0 = 1, + HW90_BLOCK_PHY1 = 2, + HW90_BLOCK_RF = 3, + HW90_BLOCK_MAXIMUM = 4, +}HW90_BLOCK_E, *PHW90_BLOCK_E; + +typedef enum _RF90_RADIO_PATH{ + RF90_PATH_A = 0, + RF90_PATH_B = 1, + RF90_PATH_C = 2, + RF90_PATH_D = 3, + RF90_PATH_MAX +}RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; + +#define bMaskByte0 0xff +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff + +extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath); +extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData); +extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask); +extern void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data); +extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask); +extern void rtl8192_phy_configmac(struct net_device* dev); +extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); +extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); +extern bool rtl8192_BBConfig(struct net_device* dev); +extern void rtl8192_phy_getTxPower(struct net_device* dev); +extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); +extern bool rtl8192_phy_RFConfig(struct net_device* dev); +extern void rtl8192_phy_updateInitGain(struct net_device* dev); +extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath); + +extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); +extern void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); +extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); +extern void InitialGain819xPci(struct net_device *dev, u8 Operation); + +#if defined RTL8190P +extern void +PHY_SetRtl8190pRfOff(struct net_device* dev ); +#endif + +#if defined RTL8192E +extern void +PHY_SetRtl8192eRfOff(struct net_device* dev ); +#endif + +bool +SetRFPowerState( + struct net_device* dev, + RT_RF_POWER_STATE eRFPowerState + ); +#define PHY_SetRFPowerState SetRFPowerState + +extern void PHY_ScanOperationBackup8192(struct net_device* dev,u8 Operation); + +#endif diff --git a/drivers/staging/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/r8192E_phyreg.h new file mode 100644 index 00000000000..7899dd538dc --- /dev/null +++ b/drivers/staging/rtl8192e/r8192E_phyreg.h @@ -0,0 +1,852 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef _R819XU_PHYREG_H +#define _R819XU_PHYREG_H + + +#define RF_DATA 0x1d4 + +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c + +#define MCS_TXAGC 0x340 +#define CCK_TXAGC 0x348 + +/*---------------------0x400~0x4ff----------------------*/ +#define MacBlkCtrl 0x403 + +#define rFPGA0_RFMOD 0x800 +#define rFPGA0_TxInfo 0x804 +#define rFPGA0_PSDFunction 0x808 +#define rFPGA0_TxGainStage 0x80c +#define rFPGA0_RFTiming1 0x810 +#define rFPGA0_RFTiming2 0x814 +#define rFPGA0_XA_HSSIParameter1 0x820 +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c +#define rFPGA0_XC_HSSIParameter1 0x830 +#define rFPGA0_XC_HSSIParameter2 0x834 +#define rFPGA0_XD_HSSIParameter1 0x838 +#define rFPGA0_XD_HSSIParameter2 0x83c +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 +#define rFPGA0_XC_LSSIParameter 0x848 +#define rFPGA0_XD_LSSIParameter 0x84c +#define rFPGA0_RFWakeUpParameter 0x850 +#define rFPGA0_RFSleepUpParameter 0x854 +#define rFPGA0_XAB_SwitchControl 0x858 +#define rFPGA0_XCD_SwitchControl 0x85c +#define rFPGA0_XA_RFInterfaceOE 0x860 +#define rFPGA0_XB_RFInterfaceOE 0x864 +#define rFPGA0_XC_RFInterfaceOE 0x868 +#define rFPGA0_XD_RFInterfaceOE 0x86c +#define rFPGA0_XAB_RFInterfaceSW 0x870 +#define rFPGA0_XCD_RFInterfaceSW 0x874 +#define rFPGA0_XAB_RFParameter 0x878 +#define rFPGA0_XCD_RFParameter 0x87c +#define rFPGA0_AnalogParameter1 0x880 +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 +#define rFPGA0_AnalogParameter4 0x88c +#define rFPGA0_XA_LSSIReadBack 0x8a0 +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac +#define rFPGA0_PSDReport 0x8b4 +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 + +#define rFPGA1_RFMOD 0x900 +#define rFPGA1_TxBlock 0x904 +#define rFPGA1_DebugSelect 0x908 +#define rFPGA1_TxInfo 0x90c + +#define rCCK0_System 0xa00 +#define rCCK0_AFESetting 0xa04 +#define rCCK0_CCA 0xa08 +#define rCCK0_RxAGC1 0xa0c +#define rCCK0_RxAGC2 0xa10 +#define rCCK0_RxHP 0xa14 +#define rCCK0_DSPParameter1 0xa18 +#define rCCK0_DSPParameter2 0xa1c +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 +#define rCCK0_FalseAlarmReport 0xa2c +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 +#define rCCK0_FACounterLower 0xa5c +#define rCCK0_FACounterUpper 0xa58 + +#define rOFDM0_LSTF 0xc00 +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c +#define rOFDM0_XARxAFE 0xc10 +#define rOFDM0_XARxIQImbalance 0xc14 +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c +#define rOFDM0_RxDetector1 0xc30 +#define rOFDM0_RxDetector2 0xc34 +#define rOFDM0_RxDetector3 0xc38 +#define rOFDM0_RxDetector4 0xc3c +#define rOFDM0_RxDSP 0xc40 +#define rOFDM0_CFOandDAGC 0xc44 +#define rOFDM0_CCADropThreshold 0xc48 +#define rOFDM0_ECCAThreshold 0xc4c +#define rOFDM0_XAAGCCore1 0xc50 +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c +#define rOFDM0_XATxIQImbalance 0xc80 +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 + + +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 +#define rOFDM1_CFO 0xd08 +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_PseudoNoiseStateAB 0xd50 +#define rOFDM1_PseudoNoiseStateCD 0xd54 +#define rOFDM1_RxPseudoNoiseWgt 0xd58 +#define rOFDM_PHYCounter1 0xda0 +#define rOFDM_PHYCounter2 0xda4 +#define rOFDM_PHYCounter3 0xda8 +#define rOFDM_ShortCFOAB 0xdac +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc + +#define rTxAGC_Rate18_06 0xe00 +#define rTxAGC_Rate54_24 0xe04 +#define rTxAGC_CCK_Mcs32 0xe08 +#define rTxAGC_Mcs03_Mcs00 0xe10 +#define rTxAGC_Mcs07_Mcs04 0xe14 +#define rTxAGC_Mcs11_Mcs08 0xe18 +#define rTxAGC_Mcs15_Mcs12 0xe1c + + +#define rZebra1_HSSIEnable 0x0 +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +#define rZebra1_Channel 0x7 +#define rZebra1_TxGain 0x8 +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc + +#define rGlobalCtrl 0 +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 + +#define rRTL8258_TxLPF 0x11 +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa + +#define bBBResetB 0x100 +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 + +#define bRFMOD 0x1 +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 +#define bOFDMRxADCPhase 0x10000 +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f +#define bXBTxAGC 0xf00 +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 +#define bPAStart 0xf0000000 +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 +#define b3WireDataLength 0x800 +#define b3WireAddressLength 0x400 +#define b3WireRFPowerDown 0x1 +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf +#define bRFSI_RFENV 0x10 +#define bRFSI_TRSW 0x20 +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 +#define bLSSIReadAddress 0x3f000000 +#define bLSSIReadEdge 0x80000000 +#define bLSSIReadBackData 0xfff +#define bLSSIReadOKFlag 0x1000 +#define bCCKSampleRate 0x8 + +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 +#define bADClkPhase 0x4000000 +#define b80MClkDelay 0x18000000 +#define bAFEWatchDogEnable 0x20000000 +#define bXtalCap 0x0f000000 +#define bXtalCap01 0xc0000000 +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bIntDifClkEnable 0x400 +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 + +#define bCCKRxAGCFormat 0x200 + +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff + +#define bOFDMTxSC 0x30000000 +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff +#define bDebugItem 0xff +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 + +#define bCCKBBMode 0x3 +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 +#define bCCKSideBand 0x10 +#define bCCKScramble 0x8 +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 + +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 + +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 + +#define bNumOfSTF 0x3 +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 0x4 +#define bRxHP_Ini 0x7 +#define bRxHP_TRLNA 0x70 +#define bRxHP_RSSI 0x700 +#define bRxHP_BBP1 0x7000 +#define bRxHP_BBP2 0x70000 +#define bRxHP_BBP3 0x700000 +#define bRSSI_H 0x7f0000 +#define bRSSI_Gen 0x7f000000 +#define bRxSettle_TRSW 0x7 +#define bRxSettle_LNA 0x38 +#define bRxSettle_RSSI 0x1c0 +#define bRxSettle_BBP 0xe00 +#define bRxSettle_RxHP 0x7000 +#define bRxSettle_AntSW_RSSI 0x38000 +#define bRxSettle_AntSW 0xc0000 +#define bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 0x3800 +#define bRxPD_Delay_TH1 0x38 +#define bRxPD_Delay_TH2 0x1c0 +#define bRxPD_DC_COUNT_MAX 0x600 +#define bRxPD_Delay_TH 0x8000 +#define bRxProcess_Delay 0xf0000 +#define bRxSearchrange_GI2_Early 0x700000 +#define bRxFrame_Guard_Counter_L 0x3800000 +#define bRxSGI_Guard_L 0xc000000 +#define bRxSGI_Search_L 0x30000000 +#define bRxSGI_TH 0xc0000000 +#define bDFSCnt0 0xff +#define bDFSCnt1 0xff00 +#define bDFSFlag 0xf0000 + +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 + +#define bDAFormat 0x40000 + +#define bTxChEmuEnable 0x01000000 + +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 + +#define bExtLNAGain 0x7c00 + +#define bSTBCEn 0x4 +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +#define bHTDetect 0x100 +#define bCFOEn 0x10000 +#define bCFOValue 0xfff00000 +#define bSigTone_Re 0x3f +#define bSigTone_Im 0x7f00 +#define bCounter_CCA 0xffff +#define bCounter_ParityFail 0xffff0000 +#define bCounter_RateIllegal 0xffff +#define bCounter_CRC8Fail 0xffff0000 +#define bCounter_MCSNoSupport 0xffff +#define bCounter_FastSync 0xffff +#define bShortCFO 0xfff +#define bShortCFOTLength 12 +#define bShortCFOFLength 11 +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 + +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 3 +#define bRx_HT_BW 0x1 +#define bRxSC 0x6 +#define bRx_HT 0x8 + +#define bNB_intf_det_on 0x1 +#define bIntf_win_len_cfg 0x30 +#define bNB_Intf_TH_cfg 0x1c0 + +#define bRFGain 0x3f +#define bTableSel 0x40 +#define bTRSW 0x80 + +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 + +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 + +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 + +#define bSFactorQAM1 0xf +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 + +#define bNoiseLvlTopSet 0x3 +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 + +#define bLoopFitType 0x1 +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 + +#define bTxAGCRate18_06 0x7f7f7f7f +#define bTxAGCRate54_24 0x7f7f7f7f +#define bTxAGCRateMCS32 0x7f +#define bTxAGCRateCCK 0x7f00 +#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f +#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f +#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f +#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f + + +#define bRxPesudoNoiseOn 0x20000000 +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 + +#define bZebra1_HSSIEnable 0x8 +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 + +#define bRTL8256RegModeCtrl1 0x100 +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 + +#define bRTL8258_TxLPFBW 0xc +#define bRTL8258_RxLPFBW 0xc00 +#define bRTL8258_RSSILPFBW 0xc0 + +#define bByte0 0x1 +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf + +#define bMaskByte0 0xff +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff + +#define bMask12Bits 0xfff + +#define bEnable 0x1 +#define bDisable 0x0 + +#define LeftAntenna 0x0 +#define RightAntenna 0x1 + +#define tCheckTxStatus 500 +#define tUpdateRxCounter 100 + +#define rateCCK 0 +#define rateOFDM 1 +#define rateHT 2 + +#define bPMAC_End 0x1ff +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff + + +#define bPMACControl 0x0 +#define bWMACControl 0x1 +#define bWNICControl 0x2 + +#define PathA 0x0 +#define PathB 0x1 +#define PathC 0x2 +#define PathD 0x3 + +#define rRTL8256RxMixerPole 0xb +#define bZebraRxMixerPole 0x6 +#define rRTL8256TxBBOPBias 0x9 +#define bRTL8256TxBBOPBias 0x400 +#define rRTL8256TxBBBW 19 +#define bRTL8256TxBBBW 0x18 + +#endif diff --git a/drivers/staging/rtl8192e/readme b/drivers/staging/rtl8192e/readme new file mode 100644 index 00000000000..10a66f56560 --- /dev/null +++ b/drivers/staging/rtl8192e/readme @@ -0,0 +1,160 @@ +What this layer should do + +- It mantain the old mechanism as alternative, so the + ipw2100 driver works with really few changes. +- Encapsulate / Decapsulate rtllib packet +- Handle fragmentation +- Optionally provide an alterantive mechanism for netif queue stop/wake, + so that the rtllib layer will pass one fragment per time instead of + one txb struct per time. so the driver can stop the queue in the middle + of a packet. +- Provide two different TX interfaces for cards that can handle management + frames on one HW queue, and data on another, and for cards that have only + one HW queue (the latter untested and very, very rough). +- Optionally provide the logic for handling IBSS/MASTER/MONITOR/BSS modes + and for the channel, essid and wap get/set wireless extension requests. + so that the driver has only to change channel when the ieee stack tell it. +- Optionally provide a scanning mechanism so that the driver has not to + worry about this, just implement the set channel calback and pass + frames to the upper layer +- Optionally provide the bss client protocol handshaking (just with open + authentication) +- Optionally provide the probe request send mechanism +- Optionally provide the bss master mode logic to handle association + protocol (only open authentication) and probe responses. +- SW wep encryption (with open authentication) +- It collects some stats +- It provides beacons to the card when it ask for them + +What this layer doesn't do (yet) +- Perform shared authentication +- Have full support for master mode (the AP should loop back in the air + frames from an associated client to another. This could be done easily + with few lines of code, and it is done in my previous version of the + stach, but a table of association must be keept and a disassociation + policy must be decided and implemented. +- Handle cleanly the full ieee 802.11 protocol. In AP mode it never + disassociate clients, and it is really prone to always allow access. + In bss client mode it is a bit rough with AP deauth and disassoc requests. +- It has not any entry point to view the collected stats. +- Altought it takes care of the card supported rates in the management frame + it sends, support for rate changing on TXed packet is not complete. +- Give up once associated in bss client mode (it never detect a + signal loss condition to disassociate and restart scanning) +- Provide a mechanism for enabling the TX in monitor mode, so + userspace programs can TX raw packets. +- Provide a mechanism for cards that need that the SW take care of beacon + TX completely, in sense that the SW has to enqueue by itself beacons + to the card so it TX them (if any...) +APIs + +Callback functions in the original stack has been mantained. +following has been added (from rtllib.h) + + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that + * one might want to use for data and management frames + * the option to have two callbacks might be useful. + * This fucntion can't sleep. + */ + int (*softmac_hard_start_xmit)(struct sk_buff *skb, + struct net_device *dev); + + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) + * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data + * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set + * then also management frames are sent via this callback. + * This function can't sleep. + */ + void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, + struct net_device *dev); + + /* stops the HW queue for DATA frames. Useful to avoid + * waste time to TX data frame when we are reassociating + * This function can sleep. + */ + void (*data_hard_stop)(struct net_device *dev); + + /* OK this is complementar to data_poll_hard_stop */ + void (*data_hard_resume)(struct net_device *dev); + + /* ask to the driver to retune the radio . + * This function can sleep. the driver should ensure + * the radio has been swithced before return. + */ + void (*set_chan)(struct net_device *dev,short ch); + + /* These are not used if the ieee stack takes care of + * scanning (IEEE_SOFTMAC_SCAN feature set). + * In this case only the set_chan is used. + * + * The syncro version is similar to the start_scan but + * does not return until all channels has been scanned. + * this is called in user context and should sleep, + * it is called in a work_queue when swithcing to ad-hoc mode + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. + * the fucntion stop_scan should stop both the syncro and + * background scanning and can sleep. + * The fucntion start_scan should initiate the background + * scanning and can't sleep. + */ + void (*scan_syncro)(struct net_device *dev); + void (*start_scan)(struct net_device *dev); + void (*stop_scan)(struct net_device *dev); + + /* indicate the driver that the link state is changed + * for example it may indicate the card is associated now. + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led + */ + void (*link_change)(struct net_device *dev); + +Functions hard_data_[resume/stop] are optional and should not be used +if the driver decides to uses data+management frames enqueue in a +single HQ queue (thus using just the softmac_hard_data_start_xmit +callback). + +Function that the driver can use are: + +rtllib_get_beacon - this is called by the driver when + the HW needs a beacon. +rtllib_softmac_start_protocol - this should normally be called in the + driver open function +rtllib_softmac_stop_protocol - the opposite of the above +rtllib_wake_queue - this is similar to netif_wake_queue +rtllib_reset_queue - this throw away fragments pending(if any) +rtllib_stop_queue - this is similar to netif_stop_queue + + +known BUGS: +- When performing syncro scan (possiblily when swithcing to ad-hoc mode + and when running iwlist scan when associated) there is still an odd + behaviour.. I have not looked in this more accurately (yet). + +locking: +locking is done by means of three structures. +1- ieee->lock (by means of spin_[un]lock_irq[save/restore] +2- ieee->wx_sem +3- ieee->scan_sem + +the lock 1 is what protect most of the critical sections in the ieee stack. +the lock 2 is used to avoid that more than one of the SET wireless extension +handlers (as well as start/stop protocol function) are running at the same time. +the lock 1 is used when we need to modify or read the shared data in the wx handlers. +In other words the lock 2 will prevent one SET action will run across another SET +action (by make sleep the 2nd one) but allow GET actions, while the lock 1 +make atomic those little shared data access in both GET and SET operation. +So get operation will be never be delayed really: they will never sleep.. +Furthermore in the top of some SET operations a flag is set before acquiring +the lock. This is an help to make the previous running SET operation to +finish faster if needed (just in case the second one will totally undo the +first, so there is not need to complete the 1st really.. ). +The background scanning mechaninsm is protected by the lock 1 except for the +workqueue. this wq is here just to let the set_chan callback sleep (I thinked it +might be appreciated by USB network card driver developer). In this case the lock 3 +take its turn. +Thus the stop function needs both the locks. +Funny in the syncro scan the lock 2 play its role (as both the syncro_scan +function and the stop scan function are called with this semaphore held). diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h similarity index 56% rename from drivers/staging/rtl8192e/ieee80211/rtl819x_BA.h rename to drivers/staging/rtl8192e/rtl819x_BA.h index 8ddc8bf9dc2..bf8fdea991c 100644 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -1,7 +1,25 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ #ifndef _BATYPE_H_ #define _BATYPE_H_ -#define TOTAL_TXBA_NUM 16 +#define TOTAL_TXBA_NUM 16 #define TOTAL_RXBA_NUM 16 #define BA_SETUP_TIMEOUT 200 @@ -18,14 +36,6 @@ #define DELBA_REASON_END_BA 37 #define DELBA_REASON_UNKNOWN_BA 38 #define DELBA_REASON_TIMEOUT 39 -/* whether need define BA Action frames here? -struct ieee80211_ADDBA_Req{ - struct ieee80211_header_data header; - u8 category; - u8 -} __attribute__ ((packed)); -*/ -//Is this need?I put here just to make it easier to define structure BA_RECORD //WB typedef union _SEQUENCE_CONTROL{ u16 ShortData; struct @@ -65,5 +75,4 @@ typedef struct _BA_RECORD { SEQUENCE_CONTROL BaStartSeqCtrl; } BA_RECORD, *PBA_RECORD; -#endif //end _BATYPE_H_ - +#endif diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c new file mode 100644 index 00000000000..08b90678539 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -0,0 +1,618 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtllib.h" +#include "rtl819x_BA.h" +#include "rtl_core.h" +#ifdef RTK_DMP_PLATFORM +#include +#endif + +void ActivateBAEntry(struct rtllib_device* ieee, PBA_RECORD pBA, u16 Time) +{ + pBA->bValid = true; + if (Time != 0) + mod_timer(&pBA->Timer, jiffies + MSECS(Time)); +} + +void DeActivateBAEntry( struct rtllib_device* ieee, PBA_RECORD pBA) +{ + pBA->bValid = false; + del_timer_sync(&pBA->Timer); +} +u8 TxTsDeleteBA( struct rtllib_device* ieee, PTX_TS_RECORD pTxTs) +{ + PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; + PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; + u8 bSendDELBA = false; + + if (pPendingBa->bValid) + { + DeActivateBAEntry(ieee, pPendingBa); + bSendDELBA = true; + } + + if (pAdmittedBa->bValid) + { + DeActivateBAEntry(ieee, pAdmittedBa); + bSendDELBA = true; + } + + return bSendDELBA; +} + +u8 RxTsDeleteBA( struct rtllib_device* ieee, PRX_TS_RECORD pRxTs) +{ + PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; + u8 bSendDELBA = false; + + if (pBa->bValid) + { + DeActivateBAEntry(ieee, pBa); + bSendDELBA = true; + } + + return bSendDELBA; +} + +void ResetBaEntry( PBA_RECORD pBA) +{ + pBA->bValid = false; + pBA->BaParamSet.shortData = 0; + pBA->BaTimeoutValue = 0; + pBA->DialogToken = 0; + pBA->BaStartSeqCtrl.ShortData = 0; +} +static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) +{ + struct sk_buff *skb = NULL; + struct rtllib_hdr_3addr* BAReq = NULL; + u8* tag = NULL; + u16 tmp = 0; + u16 len = ieee->tx_headroom + 9; + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, type, MAC_ARG(Dst), ieee->dev); + if (pBA == NULL||ieee == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); + return NULL; + } +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr) + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); +#endif + if (skb == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); + return NULL; + } + + memset(skb->data, 0, sizeof( struct rtllib_hdr_3addr)); + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + BAReq = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + + memcpy(BAReq->addr1, Dst, ETH_ALEN); + memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); + + memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); + BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); + + tag = (u8*)skb_put(skb, 9); + *tag ++= ACT_CAT_BA; + *tag ++= type; + *tag ++= pBA->DialogToken; + + if (ACT_ADDBARSP == type) + { + RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); + tmp = cpu_to_le16(StatusCode); + memcpy(tag, (u8*)&tmp, 2); + tag += 2; + } + tmp = cpu_to_le16(pBA->BaParamSet.shortData); + memcpy(tag, (u8*)&tmp, 2); + tag += 2; + tmp = cpu_to_le16(pBA->BaTimeoutValue); + memcpy(tag, (u8*)&tmp, 2); + tag += 2; + + if (ACT_ADDBAREQ == type) + { + memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2); + tag += 2; + } + + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); + return skb; +} + +static struct sk_buff* rtllib_DELBA( + struct rtllib_device* ieee, + u8* dst, + PBA_RECORD pBA, + TR_SELECT TxRxSelect, + u16 ReasonCode + ) +{ + DELBA_PARAM_SET DelbaParamSet; + struct sk_buff *skb = NULL; + struct rtllib_hdr_3addr* Delba = NULL; + u8* tag = NULL; + u16 tmp = 0; + u16 len = 6 + ieee->tx_headroom; + + if (net_ratelimit()) + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __func__, ReasonCode, MAC_ARG(dst)); + + memset(&DelbaParamSet, 0, 2); + + DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; + DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr) + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); +#endif + if (skb == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); + return NULL; + } + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + skb_reserve(skb, ieee->tx_headroom); + + Delba = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + + memcpy(Delba->addr1, dst, ETH_ALEN); + memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); + Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); + + tag = (u8*)skb_put(skb, 6); + + *tag ++= ACT_CAT_BA; + *tag ++= ACT_DELBA; + + tmp = cpu_to_le16(DelbaParamSet.shortData); + memcpy(tag, (u8*)&tmp, 2); + tag += 2; + tmp = cpu_to_le16(ReasonCode); + memcpy(tag, (u8*)&tmp, 2); + tag += 2; + + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); + if (net_ratelimit()) + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", __func__); + return skb; +} + +void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA) +{ + struct sk_buff *skb = NULL; + skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); + + if (skb) { + RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); + softmac_mgmt_xmit(skb, ieee); + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + } + return; +} + +void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode) +{ + struct sk_buff *skb = NULL; + skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); + if (skb) + softmac_mgmt_xmit(skb, ieee); + else + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + + return; + +} + +void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode) +{ + struct sk_buff *skb = NULL; + skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); + if (skb) + { + softmac_mgmt_xmit(skb, ieee); + } + else + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + } + return ; +} + +int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) +{ + struct rtllib_hdr_3addr* req = NULL; + u16 rc = 0; + u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; + PBA_RECORD pBA = NULL; + PBA_PARAM_SET pBaParamSet = NULL; + u16* pBaTimeoutVal = NULL; + PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; + PRX_TS_RECORD pTS = NULL; + + if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n",(int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + return -1; + } + + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); + + req = ( struct rtllib_hdr_3addr*) skb->data; + tag = (u8*)req; + dst = (u8*)(&req->addr2[0]); + tag += sizeof( struct rtllib_hdr_3addr); + pDialogToken = tag + 2; + pBaParamSet = (PBA_PARAM_SET)(tag + 3); + pBaTimeoutVal = (u16*)(tag + 5); + pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7); + + RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); + if (ieee->current_network.qos_data.active == 0 || + (ieee->pHTInfo->bCurrentHTSupport == false) || + (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { + rc = ADDBA_STATUS_REFUSED; + RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + goto OnADDBAReq_Fail; + } + if (!GetTs( + ieee, + (PTS_COMMON_INFO*)(&pTS), + dst, + (u8)(pBaParamSet->field.TID), + RX_DIR, + true) ) + { + rc = ADDBA_STATUS_REFUSED; + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); + goto OnADDBAReq_Fail; + } + pBA = &pTS->RxAdmittedBARecord; + + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) + { + rc = ADDBA_STATUS_INVALID_PARAM; + RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in %s()\n", __func__); + goto OnADDBAReq_Fail; + } + + + rtllib_FlushRxTsPendingPkts(ieee, pTS); + + DeActivateBAEntry(ieee, pBA); + pBA->DialogToken = *pDialogToken; + pBA->BaParamSet = *pBaParamSet; + pBA->BaTimeoutValue = *pBaTimeoutVal; + pBA->BaStartSeqCtrl = *pBaStartSeqCtrl; + + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)|| + (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) + pBA->BaParamSet.field.BufferSize = 1; + else + pBA->BaParamSet.field.BufferSize = 32; + + ActivateBAEntry(ieee, pBA, 0); + rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS); + + return 0; + +OnADDBAReq_Fail: + { + BA_RECORD BA; + BA.BaParamSet = *pBaParamSet; + BA.BaTimeoutValue = *pBaTimeoutVal; + BA.DialogToken = *pDialogToken; + BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE; + rtllib_send_ADDBARsp(ieee, dst, &BA, rc); + return 0; + } + +} + +int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) +{ + struct rtllib_hdr_3addr* rsp = NULL; + PBA_RECORD pPendingBA, pAdmittedBA; + PTX_TS_RECORD pTS = NULL; + u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; + u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; + PBA_PARAM_SET pBaParamSet = NULL; + u16 ReasonCode; + + if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + return -1; + } + rsp = ( struct rtllib_hdr_3addr*)skb->data; + tag = (u8*)rsp; + dst = (u8*)(&rsp->addr2[0]); + tag += sizeof( struct rtllib_hdr_3addr); + pDialogToken = tag + 2; + pStatusCode = (u16*)(tag + 3); + pBaParamSet = (PBA_PARAM_SET)(tag + 5); + pBaTimeoutVal = (u16*)(tag + 7); + + RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); + if ( + ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false || + ieee->pHTInfo->bCurrentAMPDUEnable == false ) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); + ReasonCode = DELBA_REASON_UNKNOWN_BA; + goto OnADDBARsp_Reject; + } + + + if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, + (u8)(pBaParamSet->field.TID), TX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); + ReasonCode = DELBA_REASON_UNKNOWN_BA; + goto OnADDBARsp_Reject; + } + + pTS->bAddBaReqInProgress = false; + pPendingBA = &pTS->TxPendingBARecord; + pAdmittedBA = &pTS->TxAdmittedBARecord; + + + if ((pAdmittedBA->bValid==true)) + { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); + return -1; + } + else if ((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); + ReasonCode = DELBA_REASON_UNKNOWN_BA; + goto OnADDBARsp_Reject; + } + else + { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); + DeActivateBAEntry(ieee, pPendingBA); + } + + + if (*pStatusCode == ADDBA_STATUS_SUCCESS) + { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) + { + pTS->bAddBaReqDelayed = true; + DeActivateBAEntry(ieee, pAdmittedBA); + ReasonCode = DELBA_REASON_END_BA; + goto OnADDBARsp_Reject; + } + + + pAdmittedBA->DialogToken = *pDialogToken; + pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal; + pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl; + pAdmittedBA->BaParamSet = *pBaParamSet; + DeActivateBAEntry(ieee, pAdmittedBA); + ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal); + } else { + pTS->bAddBaReqDelayed = true; + pTS->bDisable_AddBa = true; + ReasonCode = DELBA_REASON_END_BA; + goto OnADDBARsp_Reject; + } + + return 0; + +OnADDBARsp_Reject: + { + BA_RECORD BA; + BA.BaParamSet = *pBaParamSet; + rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); + return 0; + } + +} + +int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) +{ + struct rtllib_hdr_3addr* delba = NULL; + PDELBA_PARAM_SET pDelBaParamSet = NULL; + u16* pReasonCode = NULL; + u8* dst = NULL; + + if (skb->len < sizeof( struct rtllib_hdr_3addr) + 6) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 6)); + return -1; + } + + if ( + ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false ) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + return -1; + } + + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); + delba = ( struct rtllib_hdr_3addr*)skb->data; + dst = (u8*)(&delba->addr2[0]); + delba += sizeof( struct rtllib_hdr_3addr); + pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2); + pReasonCode = (u16*)(delba+4); + + if (pDelBaParamSet->field.Initiator == 1) + { + PRX_TS_RECORD pRxTs; + + if ( !GetTs( + ieee, + (PTS_COMMON_INFO*)&pRxTs, + dst, + (u8)pDelBaParamSet->field.TID, + RX_DIR, + false) ) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in %s().dst:"MAC_FMT" TID:%d\n", __func__, MAC_ARG(dst), (u8)pDelBaParamSet->field.TID); + return -1; + } + + RxTsDeleteBA(ieee, pRxTs); + } + else + { + PTX_TS_RECORD pTxTs; + + if (!GetTs( + ieee, + (PTS_COMMON_INFO*)&pTxTs, + dst, + (u8)pDelBaParamSet->field.TID, + TX_DIR, + false) ) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); + return -1; + } + + pTxTs->bUsingBa = false; + pTxTs->bAddBaReqInProgress = false; + pTxTs->bAddBaReqDelayed = false; + del_timer_sync(&pTxTs->TsAddBaTimer); + TxTsDeleteBA(ieee, pTxTs); + } + return 0; +} + +void +TsInitAddBA( + struct rtllib_device* ieee, + PTX_TS_RECORD pTS, + u8 Policy, + u8 bOverwritePending + ) +{ + PBA_RECORD pBA = &pTS->TxPendingBARecord; + + if (pBA->bValid==true && bOverwritePending==false) + return; + + DeActivateBAEntry(ieee, pBA); + + pBA->DialogToken++; + pBA->BaParamSet.field.AMSDU_Support = 0; + pBA->BaParamSet.field.BAPolicy = Policy; + pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; + pBA->BaParamSet.field.BufferSize = 32; + pBA->BaTimeoutValue = 0; + pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; + + ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); + + rtllib_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); +} + +void +TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) +{ + + if (TxRxSelect == TX_DIR) + { + PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; + + if (TxTsDeleteBA(ieee, pTxTs)) + rtllib_send_DELBA( + ieee, + pTsCommonInfo->Addr, + (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), + TxRxSelect, + DELBA_REASON_END_BA); + } + else if (TxRxSelect == RX_DIR) + { + PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo; + if (RxTsDeleteBA(ieee, pRxTs)) + rtllib_send_DELBA( + ieee, + pTsCommonInfo->Addr, + &pRxTs->RxAdmittedBARecord, + TxRxSelect, + DELBA_REASON_END_BA ); + } +} +void BaSetupTimeOut(unsigned long data) +{ + PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + + pTxTs->bAddBaReqInProgress = false; + pTxTs->bAddBaReqDelayed = true; + pTxTs->TxPendingBARecord.bValid = false; +} + +void TxBaInactTimeout(unsigned long data) +{ + PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[pTxTs->num]); + TxTsDeleteBA(ieee, pTxTs); + rtllib_send_DELBA( + ieee, + pTxTs->TsCommonInfo.Addr, + &pTxTs->TxAdmittedBARecord, + TX_DIR, + DELBA_REASON_TIMEOUT); +} + +void RxBaInactTimeout(unsigned long data) +{ + PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + + RxTsDeleteBA(ieee, pRxTs); + rtllib_send_DELBA( + ieee, + pRxTs->TsCommonInfo.Addr, + &pRxTs->RxAdmittedBARecord, + RX_DIR, + DELBA_REASON_TIMEOUT); + return ; +} diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h similarity index 56% rename from drivers/staging/rtl8192e/ieee80211/rtl819x_HT.h rename to drivers/staging/rtl8192e/rtl819x_HT.h index 56a120cf629..15878ad01d7 100644 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -1,31 +1,35 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ #ifndef _RTL819XU_HTTYPE_H_ #define _RTL819XU_HTTYPE_H_ -//------------------------------------------------------------ -// The HT Capability element is present in beacons, association request, -// reassociation request and probe response frames -//------------------------------------------------------------ -// -// Operation mode value -// #define HT_OPMODE_NO_PROTECT 0 #define HT_OPMODE_OPTIONAL 1 #define HT_OPMODE_40MHZ_PROTECT 2 #define HT_OPMODE_MIXED 3 -// -// MIMO Power Save Setings -// #define MIMO_PS_STATIC 0 #define MIMO_PS_DYNAMIC 1 #define MIMO_PS_NOLIMIT 3 -// -// There should be 128 bits to cover all of the MCS rates. However, since -// 8190 does not support too much rates, one integer is quite enough. -// #define sHTCLng 4 @@ -52,21 +56,13 @@ typedef enum _HT_MCS_RATE{ HT_MCS13 = 0x00002000, HT_MCS14 = 0x00004000, HT_MCS15 = 0x00008000, - // Do not define MCS32 here although 8190 support MCS32 }HT_MCS_RATE,*PHT_MCS_RATE; -// -// Represent Channel Width in HT Capabilities -// typedef enum _HT_CHANNEL_WIDTH{ HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_20_40 = 1, }HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; -// -// Represent Extension Channel Offset in HT Capabilities -// This is available only in 40Mhz mode. -// typedef enum _HT_EXTCHNL_OFFSET{ HT_EXTCHNL_OFFSET_NO_EXT = 0, HT_EXTCHNL_OFFSET_UPPER = 1, @@ -75,15 +71,14 @@ typedef enum _HT_EXTCHNL_OFFSET{ }HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; typedef enum _CHNLOP{ - CHNLOP_NONE = 0, // No Action now - CHNLOP_SCAN = 1, // Scan in progress - CHNLOP_SWBW = 2, // Bandwidth switching in progress - CHNLOP_SWCHNL = 3, // Software Channel switching in progress + CHNLOP_NONE = 0, + CHNLOP_SCAN = 1, + CHNLOP_SWBW = 2, + CHNLOP_SWCHNL = 3, } CHNLOP, *PCHNLOP; -// Determine if the Channel Operation is in progress #define CHHLOP_IN_PROGRESS(_pHTInfo) \ - ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE + ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false /* typedef union _HT_CAPABILITY{ @@ -121,7 +116,7 @@ typedef union _HT_CAPABILITY_MACPARA{ typedef enum _HT_ACTION{ ACT_RECOMMAND_WIDTH = 0, - ACT_MIMO_PWR_SAVE = 1, + ACT_MIMO_PWR_SAVE = 1, ACT_PSMP = 2, ACT_SET_PCO_PHASE = 3, ACT_MIMO_CHL_MEASURE = 4, @@ -133,7 +128,6 @@ typedef enum _HT_ACTION{ } HT_ACTION, *PHT_ACTION; -/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */ typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{ SC_MODE_DUPLICATE = 0, SC_MODE_LOWER = 1, @@ -143,7 +137,6 @@ typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{ typedef struct _HT_CAPABILITY_ELE{ - //HT capability info u8 AdvCoding:1; u8 ChlWidth:1; u8 MimoPwrSave:2; @@ -159,30 +152,21 @@ typedef struct _HT_CAPABILITY_ELE{ u8 Rsvd1:1; u8 LSigTxopProtect:1; - //MAC HT parameters info u8 MaxRxAMPDUFactor:2; u8 MPDUDensity:3; u8 Rsvd2:3; - //Supported MCS set u8 MCS[16]; - //Extended HT Capability Info u16 ExtHTCapInfo; - //TXBF Capabilities u8 TxBFCap[4]; - //Antenna Selection Capabilities u8 ASCap; } __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE; -//------------------------------------------------------------ -// The HT Information element is present in beacons -// Only AP is required to include this element -//------------------------------------------------------------ typedef struct _HT_INFORMATION_ELE{ u8 ControlChl; @@ -211,10 +195,6 @@ typedef struct _HT_INFORMATION_ELE{ u8 BasicMSC[16]; } __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE; -// -// MIMO Power Save control field. -// This is appear in MIMO Power Save Action Frame -// typedef struct _MIMOPS_CTRL{ u8 MimoPsEnable:1; u8 MimoPsMode:1; @@ -232,62 +212,49 @@ typedef enum _HT_AGGRE_MODE_E{ HT_AGG_FORCE_DISABLE = 2, }HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; -//------------------------------------------------------------ -// The Data structure is used to keep HT related variables when card is -// configured as non-AP STA mode. **Note** Current_xxx should be set -// to default value in HTInitializeHTInfo() -//------------------------------------------------------------ typedef struct _RT_HIGH_THROUGHPUT{ u8 bEnableHT; u8 bCurrentHTSupport; - u8 bRegBW40MHz; // Tx 40MHz channel capablity - u8 bCurBW40MHz; // Tx 40MHz channel capability + u8 bRegBW40MHz; + u8 bCurBW40MHz; - u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz - u8 bCurShortGI40MHz; // Tx Short GI for 40MHz + u8 bRegShortGI40MHz; + u8 bCurShortGI40MHz; - u8 bRegShortGI20MHz; // Tx Short GI for 20MHz - u8 bCurShortGI20MHz; // Tx Short GI for 20MHz + u8 bRegShortGI20MHz; + u8 bCurShortGI20MHz; - u8 bRegSuppCCK; // Tx CCK rate capability - u8 bCurSuppCCK; // Tx CCK rate capability + u8 bRegSuppCCK; + u8 bCurSuppCCK; - // 802.11n spec version for "peer" HT_SPEC_VER ePeerHTSpecVer; - // HT related information for "Self" - HT_CAPABILITY_ELE SelfHTCap; // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities. - HT_INFORMATION_ELE SelfHTInfo; // This is HT info element sent to peer STA, which also indicate HT Rx capabilities. + HT_CAPABILITY_ELE SelfHTCap; + HT_INFORMATION_ELE SelfHTInfo; - // HT related information for "Peer" u8 PeerHTCapBuf[32]; u8 PeerHTInfoBuf[32]; - // A-MSDU related - u8 bAMSDU_Support; // This indicates Tx A-MSDU capability - u16 nAMSDU_MaxSize; // This indicates Tx A-MSDU capability - u8 bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability - u16 nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability + u8 bAMSDU_Support; + u16 nAMSDU_MaxSize; + u8 bCurrent_AMSDU_Support; + u16 nCurrent_AMSDU_MaxSize; + u8 bAMPDUEnable; + u8 bCurrentAMPDUEnable; + u8 AMPDU_Factor; + u8 CurrentAMPDUFactor; + u8 MPDU_Density; + u8 CurrentMPDUDensity; - // AMPDU related <2006.08.10 Emily> - u8 bAMPDUEnable; // This indicate Tx A-MPDU capability - u8 bCurrentAMPDUEnable; // This indicate Tx A-MPDU capability - u8 AMPDU_Factor; // This indicate Tx A-MPDU capability - u8 CurrentAMPDUFactor; // This indicate Tx A-MPDU capability - u8 MPDU_Density; // This indicate Tx A-MPDU capability - u8 CurrentMPDUDensity; // This indicate Tx A-MPDU capability - - // Forced A-MPDU enable HT_AGGRE_MODE_E ForcedAMPDUMode; u8 ForcedAMPDUFactor; u8 ForcedMPDUDensity; - // Forced A-MSDU enable HT_AGGRE_MODE_E ForcedAMSDUMode; u16 ForcedAMSDUMaxSize; @@ -295,28 +262,23 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 CurrentOpMode; - // MIMO PS related u8 SelfMimoPs; u8 PeerMimoPs; - // 40MHz Channel Offset settings. HT_EXTCHNL_OFFSET CurSTAExtChnlOffset; - u8 bCurTxBW40MHz; // If we use 40 MHz to Tx + u8 bCurTxBW40MHz; u8 PeerBandwidth; - // For Bandwidth Switching u8 bSwBwInProgress; - CHNLOP ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15. + CHNLOP ChnlOp; u8 SwBwStep; - //struct timer_list SwBwTimer; //moved to ieee80211_device. as timer_list need include some header file here. - // For Realtek proprietary A-MPDU factor for aggregation u8 bRegRT2RTAggregation; + u8 RT2RT_HT_Mode; u8 bCurrentRT2RTAggregation; u8 bCurrentRT2RTLongSlotTime; u8 szRT2RTAggBuffer[10]; - // Rx Reorder control u8 bRegRxReorderEnable; u8 bCurRxReorderEnable; u8 RxReorderWinSize; @@ -331,21 +293,26 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 UsbRxFwAggrPageNum; u8 UsbRxFwAggrPacketNum; u8 UsbRxFwAggrTimeout; + u8 UsbRxPageSize; #endif - // Add for Broadcom(Linksys) IOT. Joseph u8 bIsPeerBcm; - // For IOT issue. u8 IOTPeer; u32 IOTAction; + u8 IOTRaFunc; + + u8 bWAIotBroadcom; + u8 WAIotTH; + +#ifdef RTL8192CE + u8 bRDGEnable; +#endif + + u8 bAcceptAddbaReq; } __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT; -//------------------------------------------------------------ -// The Data structure is used to keep HT related variable for "each Sta" -// when card is configured as "AP mode" -//------------------------------------------------------------ typedef struct _RT_HTINFO_STA_ENTRY{ u8 bEnableHT; @@ -361,10 +328,19 @@ typedef struct _RT_HTINFO_STA_ENTRY{ u8 bBw40MHz; + u8 bCurTxBW40MHz; + + u8 bCurShortGI20MHz; + + u8 bCurShortGI40MHz; + u8 MimoPs; u8 McsRateSet[16]; + u8 bCurRxReorderEnable; + + u16 nAMSDU_MaxSize; }RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY; @@ -372,35 +348,31 @@ typedef struct _RT_HTINFO_STA_ENTRY{ -//------------------------------------------------------------ -// The Data structure is used to keep HT related variable for "each AP" -// when card is configured as "STA mode" -//------------------------------------------------------------ typedef struct _BSS_HT{ u8 bdSupportHT; - // HT related elements u8 bdHTCapBuf[32]; u16 bdHTCapLen; u8 bdHTInfoBuf[32]; u16 bdHTInfoLen; HT_SPEC_VER bdHTSpecVer; - //HT_CAPABILITY_ELE bdHTCapEle; - //HT_INFORMATION_ELE bdHTInfoEle; + HT_CHANNEL_WIDTH bdBandWidth; u8 bdRT2RTAggregation; u8 bdRT2RTLongSlotTime; + u8 RT2RT_HT_Mode; + u8 bdHT1R; } __attribute__ ((packed)) BSS_HT, *PBSS_HT; typedef struct _MIMO_RSSI{ u32 EnableAntenna; u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; + u32 AntennaB; + u32 AntennaC; + u32 AntennaD; u32 Average; }MIMO_RSSI, *PMIMO_RSSI; @@ -411,8 +383,11 @@ typedef struct _MIMO_EVM{ typedef struct _FALSE_ALARM_STATISTICS{ u32 Cnt_Parity_Fail; - u32 Cnt_Rate_Illegal; + u32 Cnt_Rate_Illegal; u32 Cnt_Crc8_fail; + u32 Cnt_Mcs_fail; + u32 Cnt_Ofdm_fail; + u32 Cnt_Cck_fail; u32 Cnt_all; }FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS; @@ -420,12 +395,8 @@ typedef struct _FALSE_ALARM_STATISTICS{ extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; -/* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set - STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We have - to add a macro to judge wireless mode. */ #define PICK_RATE(_nLegacyRate, _nMcsRate) \ (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate) -/* 2007/07/12 MH We only define legacy and HT wireless mode now. */ #define LEGACY_WIRELESS_MODE IEEE_MODE_MASK #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \ @@ -435,12 +406,11 @@ extern u8 MCS_FILTER_1SS[16]; -// MCS Bw 40 {1~7, 12~15,32} -#define RATE_ADPT_1SS_MASK 0xFF -#define RATE_ADPT_2SS_MASK 0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily +#define RATE_ADPT_1SS_MASK 0xFF +#define RATE_ADPT_2SS_MASK 0xF0 #define RATE_ADPT_MCS32_MASK 0x01 -#define IS_11N_MCS_RATE(rate) (rate&0x80) +#define IS_11N_MCS_RATE(rate) (rate&0x80) typedef enum _HT_AGGRE_SIZE{ HT_AGG_SIZE_8K = 0, @@ -449,22 +419,27 @@ typedef enum _HT_AGGRE_SIZE{ HT_AGG_SIZE_64K = 3, }HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E; -/* Indicate different AP vendor for IOT issue */ typedef enum _HT_IOT_PEER { HT_IOT_PEER_UNKNOWN = 0, HT_IOT_PEER_REALTEK = 1, - HT_IOT_PEER_BROADCOM = 2, - HT_IOT_PEER_RALINK = 3, - HT_IOT_PEER_ATHEROS = 4, - HT_IOT_PEER_CISCO= 5, - HT_IOT_PEER_MARVELL=6, - HT_IOT_PEER_MAX = 7 + HT_IOT_PEER_REALTEK_92SE = 2, + HT_IOT_PEER_BROADCOM = 3, + HT_IOT_PEER_RALINK = 4, + HT_IOT_PEER_ATHEROS = 5, + HT_IOT_PEER_CISCO= 6, + HT_IOT_PEER_MARVELL=7, + HT_IOT_PEER_92U_SOFTAP = 8, + HT_IOT_PEER_SELF_SOFTAP = 9, + HT_IOT_PEER_AIRGO = 10, + HT_IOT_PEER_MAX = 11, }HT_IOT_PEER_E, *PHTIOT_PEER_E; -// -// IOT Action for different AP -// +typedef enum _HT_IOT_PEER_SUBTYPE +{ + HT_IOT_PEER_ATHEROS_DIR635 = 0, +}HT_IOT_PEER_SUBTYPE_E, *PHTIOT_PEER_SUBTYPE_E; + typedef enum _HT_IOT_ACTION{ HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001, HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002, @@ -476,8 +451,43 @@ typedef enum _HT_IOT_ACTION{ HT_IOT_ACT_CDD_FSYNC = 0x00000080, HT_IOT_ACT_PURE_N_MODE = 0x00000100, HT_IOT_ACT_FORCED_CTS2SELF = 0x00000200, - HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, + HT_IOT_ACT_FORCED_RTS = 0x00000400, + HT_IOT_ACT_AMSDU_ENABLE = 0x00000800, + HT_IOT_ACT_REJECT_ADDBA_REQ = 0x00001000, + HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT = 0x00002000, + HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00004000, + + HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000, + HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000, + HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000, + HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000, + HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000, + HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000, + + HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, + HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, + + HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, + HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000, + HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000, + + HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI = 0x08000000, + }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; -#endif //_RTL819XU_HTTYPE_H_ +typedef enum _HT_IOT_RAFUNC{ + HT_IOT_RAFUNC_DISABLE_ALL = 0x00, + HT_IOT_RAFUNC_PEER_1R = 0x01, + HT_IOT_RAFUNC_TX_AMSDU = 0x02, +}HT_IOT_RAFUNC, *PHT_IOT_RAFUNC; +typedef enum _RT_HT_CAP{ + RT_HT_CAP_USE_TURBO_AGGR = 0x01, + RT_HT_CAP_USE_LONG_PREAMBLE = 0x02, + RT_HT_CAP_USE_AMPDU = 0x04, + RT_HT_CAP_USE_WOW = 0x8, + RT_HT_CAP_USE_SOFTAP = 0x10, + RT_HT_CAP_USE_92SE = 0x20, +}RT_HT_CAPBILITY, *PRT_HT_CAPBILITY; + +#endif diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c new file mode 100644 index 00000000000..eaf73676f95 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -0,0 +1,1531 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtllib.h" +#include "rtl819x_HT.h" +u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +u16 MCS_DATA_RATE[2][2][77] = + { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260, + 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520, + 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195, + 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260, + 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, + {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, + 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578, + 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217, + 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289, + 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, + { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, + 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, + 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, + 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, + 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, + {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, + 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, + 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, + 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600, + 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } + }; + +static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf}; +static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70}; +static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e}; +static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; +static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf}; +static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc}; +static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; +static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; +static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0}; +static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91}; +static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; +#if defined(RTL8192SU) +static u8 NETGEAR_BROADCOM[3] = {0x00, 0x1f, 0x33}; +#endif +static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; +void HTUpdateDefaultSetting(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + +#ifdef RTL8192CE + pHTInfo->bRDGEnable = 0; +#endif + + pHTInfo->bAcceptAddbaReq = 1; + + pHTInfo->bRegShortGI20MHz= 1; + pHTInfo->bRegShortGI40MHz= 1; + + pHTInfo->bRegBW40MHz = 1; + + if (pHTInfo->bRegBW40MHz) + pHTInfo->bRegSuppCCK = 1; + else + pHTInfo->bRegSuppCCK = true; + + pHTInfo->nAMSDU_MaxSize = 7935UL; + pHTInfo->bAMSDU_Support = 0; + + pHTInfo->bAMPDUEnable = 1; + pHTInfo->AMPDU_Factor = 2; + pHTInfo->MPDU_Density = 0; + + pHTInfo->SelfMimoPs = 3; + if (pHTInfo->SelfMimoPs == 2) + pHTInfo->SelfMimoPs = 3; + ieee->bTxDisableRateFallBack = 0; + ieee->bTxUseDriverAssingedRate = 0; + + ieee->bTxEnableFwCalcDur = 1; + + pHTInfo->bRegRT2RTAggregation = 1; + + pHTInfo->bRegRxReorderEnable = 1; + pHTInfo->RxReorderWinSize = 64; + pHTInfo->RxReorderPendingTime = 30; + +#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE + pHTInfo->UsbTxAggrNum = 4; +#endif +#ifdef USB_RX_AGGREGATION_SUPPORT +#ifdef RTL8192SU + pHTInfo->UsbRxFwAggrEn = 1; + pHTInfo->UsbRxFwAggrPageNum = 48; + pHTInfo->UsbRxFwAggrPacketNum = 8; + pHTInfo->UsbRxFwAggrTimeout = 4; + pHTInfo->UsbRxPageSize= 128; +#else + pHTInfo->UsbRxFwAggrEn = 1; + pHTInfo->UsbRxFwAggrPageNum = 24; + pHTInfo->UsbRxFwAggrPacketNum = 8; + pHTInfo->UsbRxFwAggrTimeout = 8; +#endif +#endif + + +} +void HTDebugHTCapability(u8* CapIE, u8* TitleString ) +{ + + static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + PHT_CAPABILITY_ELE pCapELE; + + if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) + { + RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); + pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]); + }else + pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]); + + RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString ); + + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ + pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); + return; + +} +void HTDebugHTInfo(u8* InfoIE, u8* TitleString) +{ + + static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; + PHT_INFORMATION_ELE pHTInfoEle; + + if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) + { + RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); + pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]); + }else + pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]); + + + RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString); + + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel ="); + switch (pHTInfoEle->ExtChlOffset) + { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); + break; + } + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz"); + + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = "); + switch (pHTInfoEle->OptMode) + { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); + break; + } + + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ + pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); + return; +} + +bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) +{ + bool retValue = false; + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + if (pHTInfo->bCurrentHTSupport == false ) + retValue = false; + else if (pHTInfo->bRegBW40MHz == false) + retValue = false; + else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + retValue = false; + else if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) + retValue = true; + else + retValue = false; + + return retValue; +} + +bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) +{ + bool retValue = false; + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + if (pHTInfo->bCurrentHTSupport == false ) + retValue = false; + else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + retValue = false; + else if (is40MHz) + { + if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) + retValue = true; + else + retValue = false; + } + else + { + if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) + retValue = true; + else + retValue = false; + } + + return retValue; +} + +u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate) +{ + + u8 is40MHz; + u8 isShortGI; + + is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0; + isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0; + + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; +} + + +u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; + u8 isShortGI = (pHTInfo->bCurBW40MHz)? + ((pHTInfo->bCurShortGI40MHz)?1:0): + ((pHTInfo->bCurShortGI20MHz)?1:0); + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; +} + +u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate) +{ + u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c}; + u8 is40MHz = 0; + u8 isShortGI = 0; + + if (nDataRate < 12) + { + return CCKOFDMRate[nDataRate]; + } + else + { + if (nDataRate >= 0x10 && nDataRate <= 0x1f) + { + is40MHz = 0; + isShortGI = 0; + + } + else if (nDataRate >=0x20 && nDataRate <= 0x2f ) + { + is40MHz = 1; + isShortGI = 0; + + } + else if (nDataRate >= 0x30 && nDataRate <= 0x3f ) + { + is40MHz = 0; + isShortGI = 1; + + } + else if (nDataRate >= 0x40 && nDataRate <= 0x4f ) + { + is40MHz = 1; + isShortGI = 1; + + } + return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; + } +} + + + +bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) +{ + bool retValue = false; + struct rtllib_network* net = &ieee->current_network; + + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || + (memcmp(net->bssid, PCI_RALINK, 3)==0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || + (net->ralink_cap_exist)) + retValue = true; + else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || + (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| + (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| + (net->broadcom_cap_exist)) + retValue = true; + else if (net->bssht.bdRT2RTAggregation) + retValue = true; + else + retValue = false; + + return retValue; +} + +void HTIOTPeerDetermine(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rtllib_network* net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation){ + pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){ + pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE; + } + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){ + pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP; + } + } + else if (net->broadcom_cap_exist) + pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; + else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || + (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| + (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)/*|| + (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) */) + pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; + else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || + (memcmp(net->bssid, PCI_RALINK, 3)==0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || + net->ralink_cap_exist) + pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; + else if ((net->atheros_cap_exist )|| + (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)|| + (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) + pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; + else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist) + pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; + else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || + net->marvell_cap_exist) + pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL; + else if (net->airgo_cap_exist) + pHTInfo->IOTPeer = HT_IOT_PEER_AIRGO; + else + pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; + + RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); +} + +u8 HTIOTActIsDisableMCS14(struct rtllib_device* ieee, u8* PeerMacAddr) +{ + return 0; + } + + +bool HTIOTActIsDisableMCS15(struct rtllib_device* ieee) +{ + bool retValue = false; + +#if defined(RTL8192U) + if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) + retValue = true; + else + retValue = false; +#endif + + + return retValue; +} + +bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) +{ + bool retValue = false; +#ifdef RTL8192U + struct rtllib_network* net = &ieee->current_network; + + if ((ieee->pHTInfo->bCurrentHTSupport == true) && (ieee->pairwise_key_type == KEY_TYPE_CCMP)) + { + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || + (memcmp(net->bssid, PCI_RALINK, 3)==0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3)==0)) + { + retValue = false; + } + } +#endif +#if defined(RTL8192SU) || defined RTL8192CE + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if (ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) + { + if ( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) && + (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) && + (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) && + (pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE) && + (pHTInfo->IOTPeer != HT_IOT_PEER_RALINK) ) + retValue = true; + } +#elif defined(RTL8192SE) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if (ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) { + if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK){ + retValue = true; + } + } +#endif + return retValue; +} + +u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device* ieee, u8* PeerMacAddr) +{ + return false; +} + + +bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) +{ + bool retValue = false; + +#if defined RTL8192SU + if (ieee->mode == IEEE_G) + retValue = true; +#elif defined RTL8192CE + if (ieee->mode == IEEE_G || + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) + retValue = true; +#endif + + return retValue; +} + + +u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; + + +#if (defined RTL8192U || defined RTL8192E || defined RTL8190P) + { + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + retValue = 1; + } + } +#endif + + return retValue; +} + +u8 +HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + u8 retValue = false; + u8 boundary=59; + + pHTInfo->bWAIotBroadcom = false; + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) + { + if (!(pHTInfo->bRegBW40MHz)) + { + if (ieee->current_network.mode != WIRELESS_MODE_B) + { + pHTInfo->bWAIotBroadcom = true; + + if (ieee->b_customer_lenovo_id == true) + boundary = 30; + + if ( ieee->current_network.RSSI >= boundary) + retValue = true; + } + }else{ + ; + } + } + } + return retValue; +} + +u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *network) +{ + u8 retValue = 0; +#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) + if ((ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) ||(ieee->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ) +#else + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) +#endif + { + retValue = 1; + } + + return retValue; +} + +u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, struct rtllib_network *network) +{ + u8 retValue = 0; +#if defined(RTL8192SE) || defined(RTL8192SU) + if (ieee->pHTInfo->bCurrentHTSupport) + { + if ((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&& + (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE)) + { + if ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0) + retValue = 1; + } + } +#endif + return retValue; +} + +u8 +HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *network) +{ + u8 retValue = 0; + + return retValue; +} + +u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) +{ + u8 retValue = 0; +#if (defined RTL8190P || defined RTL8192U || defined RTL8192SU) + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + retValue = 1; + } +#endif + return retValue; +} + +u8 +HTIOCActRejcectADDBARequest(struct rtllib_network *network) +{ + u8 retValue = 0; +#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) + { + + + } +#endif + + return retValue; + +} + +u8 + HTIOTActIsEDCABiasRx(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; +#ifdef RTL8192SU + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + { + if (pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS || + pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM || + pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) + return 1; + + } +#elif defined RTL8192CE + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + { + if (pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS || + pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) + return 1; + + } +#elif defined RTL8192SE + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + { + if (ieee->rtllib_ap_sec_type != NULL) + if (ieee->rtllib_ap_sec_type(ieee) == SEC_ALG_CCMP) + if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK){ + return 1; + } + + } +#endif + return retValue; +} + +u8 +HTIOTActDisableShortGI(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) + { + retValue = 1; + } + + return retValue; +} + +u8 +HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; +#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; +#endif + +#ifdef RTL8192SU + if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK || + pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK || + pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK_92SE) + { + retValue = 1; + } +#elif defined RTL8192SE || defined RTL8192CE + if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK || + pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ) + { + retValue = 1; + } +#endif + return retValue; +} + +void +HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; + + if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss) + pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R; + + if (pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE) + pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU; + +} + + +u8 +HTIOTActIsDisableTx40MHz(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; + +#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->group_key_type) || + (KEY_TYPE_WEP40 == ieee->group_key_type) || + (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) + { + if ((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT)) + retValue = 1; + } +#endif + + return retValue; +} + +u8 +HTIOTActIsTxNoAggregation(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; + +#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->group_key_type) || + (KEY_TYPE_WEP40 == ieee->group_key_type) || + (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) + { + if (pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) + retValue = 1; + } +#endif + + return retValue; +} + + +u8 +HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network) +{ + u8 retValue = 0; + +#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->group_key_type) || + (KEY_TYPE_WEP40 == ieee->group_key_type) || + (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) + { + if ((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT)) + retValue = 1; + } +#endif + + return retValue; +} + + +bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network *network) +{ + bool retValue = false; +#if defined(RTL8192SU) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + if ((memcmp(network->bssid, NETGEAR_BROADCOM, 3)==0) + && (network->bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40)) + return true; + } +#endif + return retValue; +} + +bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device* ieee,struct rtllib_network *network) +{ + bool retValue = false; +#if defined(RTL8192SE) || defined(RTL8192SU) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + { + if (ieee->VersionID<2) + if (pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) + return true; + + } +#endif + return retValue; +} + +bool +HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network *network) +{ + bool retValue = false; +#if defined(RTL8192SE) || defined(RTL8192SU) + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + { + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + return true; + + } +#endif + return retValue; +} + +void HTResetIOTSetting( + PRT_HIGH_THROUGHPUT pHTInfo +) +{ + pHTInfo->IOTAction = 0; + pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; + pHTInfo->IOTRaFunc = 0; +} + + +void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) +{ + PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; + PHT_CAPABILITY_ELE pCapELE = NULL; + + if ((posHTCap == NULL) || (pHT == NULL)) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + return; + } + memset(posHTCap, 0, *len); + + if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) + { + u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); + pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]); + *len = 30 + 2; + }else + { + pCapELE = (PHT_CAPABILITY_ELE)posHTCap; + *len = 26 + 2; + } + + pCapELE->AdvCoding = 0; + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + pCapELE->ChlWidth = 0; + else + pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); + + pCapELE->MimoPwrSave = pHT->SelfMimoPs; + pCapELE->GreenField = 0; + pCapELE->ShortGI20Mhz = 1; + pCapELE->ShortGI40Mhz = 1; + + pCapELE->TxSTBC = 1; +#if defined RTL8192SE || defined RTL8192CE + pCapELE->TxSTBC = 0; +#endif + pCapELE->RxSTBC = 0; + pCapELE->DelayBA = 0; + pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; + pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); + pCapELE->PSMP = 0; + pCapELE->LSigTxopProtect = 0; + + + RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); + + if ( IsEncrypt) + { + pCapELE->MPDUDensity = 7; + pCapELE->MaxRxAMPDUFactor = 2; + } + else + { + pCapELE->MaxRxAMPDUFactor = 3; + pCapELE->MPDUDensity = 0; + } + + memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16); + memset(&pCapELE->ExtHTCapInfo, 0, 2); + memset(pCapELE->TxBFCap, 0, 4); + + pCapELE->ASCap = 0; + + if (bAssoc) { + if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15) + pCapELE->MCS[1] &= 0x7f; + + if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14) + pCapELE->MCS[1] &= 0xbf; + + if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS) + pCapELE->MCS[1] &= 0x00; + + if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) + pCapELE->ShortGI40Mhz = 0; + + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + { + pCapELE->ChlWidth = 0; + + pCapELE->MCS[1] = 0; + } + } + + + + + + return; + +} +void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) +{ + PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; + PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; + if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + return; + } + + memset(posHTInfo, 0, *len); + if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) + { + pHTInfoEle->ControlChl = ieee->current_network.channel; + pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: + (ieee->current_network.channel<=6)? + HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); + pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; + pHTInfoEle->RIFS = 0; + pHTInfoEle->PSMPAccessOnly = 0; + pHTInfoEle->SrvIntGranularity = 0; + pHTInfoEle->OptMode = pHT->CurrentOpMode; + pHTInfoEle->NonGFDevPresent = 0; + pHTInfoEle->DualBeacon = 0; + pHTInfoEle->SecondaryBeacon = 0; + pHTInfoEle->LSigTxopProtectFull = 0; + pHTInfoEle->PcoActive = 0; + pHTInfoEle->PcoPhase = 0; + + memset(pHTInfoEle->BasicMSC, 0, 16); + + + *len = 22 + 2; + + } + else + { + *len = 0; + } + return; +} + +void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len) +{ + if (posRT2RTAgg == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + return; + } + memset(posRT2RTAgg, 0, *len); + *posRT2RTAgg++ = 0x00; + *posRT2RTAgg++ = 0xe0; + *posRT2RTAgg++ = 0x4c; + *posRT2RTAgg++ = 0x02; + *posRT2RTAgg++ = 0x01; + +#ifdef RTL8192CE + *posRT2RTAgg = 0x70; +#else + *posRT2RTAgg = 0x30; +#endif + + if (ieee->bSupportRemoteWakeUp) { + *posRT2RTAgg |= RT_HT_CAP_USE_WOW; + } + + *len = 6 + 2; + + return; + +#ifdef TODO + posRT2RTAgg->Length = 6; +#endif + + + + +} + +u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) +{ + u8 i; + if (pOperateMCS == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); + return false; + } + + switch (ieee->mode) { + case IEEE_A: + case IEEE_B: + case IEEE_G: + for (i=0;i<=15;i++) + pOperateMCS[i] = 0; + break; + case IEEE_N_24G: + case IEEE_N_5G: + pOperateMCS[0] &=RATE_ADPT_1SS_MASK; + pOperateMCS[1] &=RATE_ADPT_2SS_MASK; + pOperateMCS[3] &=RATE_ADPT_MCS32_MASK; + break; + default: + break; + + } + + return true; +} + +u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter) +{ + u8 i, j; + u8 bitMap; + u8 mcsRate = 0; + u8 availableMcsRate[16]; + if (pMCSRateSet == NULL || pMCSFilter == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + return false; + } + for (i=0; i<16; i++) + availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i]; + + for (i = 0; i < 16; i++) + { + if (availableMcsRate[i] != 0) + break; + } + if (i == 16) + return false; + + for (i = 0; i < 16; i++) + { + if (availableMcsRate[i] != 0) + { + bitMap = availableMcsRate[i]; + for (j = 0; j < 8; j++) + { + if ((bitMap%2) != 0) + { + if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) + mcsRate = (8*i+j); + } + bitMap = bitMap>>1; + } + } + } + return (mcsRate|0x80); +} + +u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS) +{ + + u8 i=0; + + for (i=0;i<=15;i++){ + pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i]&pSupportMCS[i]; + } + + + + HT_PickMCSRate(ieee, pOperateMCS); + + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + pOperateMCS[1] = 0; + + for (i=2; i<=15; i++) + pOperateMCS[i] = 0; + + return true; +} +void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTOnAssocRsp(struct rtllib_device *ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + PHT_CAPABILITY_ELE pPeerHTCap = NULL; + PHT_INFORMATION_ELE pPeerHTInfo = NULL; + u16 nMaxAMSDUSize = 0; + u8* pMcsFilter = NULL; + + static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; + + if ( pHTInfo->bCurrentHTSupport == false ) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); + return; + } + RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); + + if (!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) + pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]); + else + pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf); + + if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) + pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]); + else + pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf); + + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); + HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); + pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); + + pHTInfo->bCurShortGI20MHz= + ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false); + pHTInfo->bCurShortGI40MHz= + ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false); + + pHTInfo->bCurSuppCCK = + ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false); + + + pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; + + nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935; + + if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize ) + pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; + else + pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; + + pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; + if (ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){ + if ( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) || + (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) ) + pHTInfo->bCurrentAMPDUEnable = false; + } + + if (!pHTInfo->bRegRT2RTAggregation) + { + if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) + pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + else + pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; + + } else { + if (ieee->current_network.bssht.bdRT2RTAggregation) + { + if ( ieee->pairwise_key_type != KEY_TYPE_NA) + pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + else + pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; + }else + { + if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) + pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + else + pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; + } + } + if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) + pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; + else + pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; +#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) + if (ieee->SetHwRegHandler != NULL) { + ieee->SetHwRegHandler( ieee->dev, HW_VAR_SHORTGI_DENSITY, (u8*)(&ieee->MaxMssDensity)); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); + } +#elif defined RTL8192CE + if (ieee->SetHwRegHandler != NULL) { + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); + } +#endif +#ifndef RTL8190P + if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) +#else + if ( 0 ) +#endif + { + pHTInfo->bCurrentAMPDUEnable = false; + pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; + pHTInfo->ForcedAMSDUMaxSize = 7935; + } + pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable; + + if (pPeerHTCap->MCS[0] == 0) + pPeerHTCap->MCS[0] = 0xff; + + HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0)); + + HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); + + pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave; + if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC) + pMcsFilter = MCS_FILTER_1SS; + else + pMcsFilter = MCS_FILTER_ALL; + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); + ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; + + pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; + +} + +void HTSetConnectBwModeCallback(struct rtllib_device* ieee); +void HTInitializeHTInfo(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "===========>%s()\n", __func__); + pHTInfo->bCurrentHTSupport = false; + + pHTInfo->bCurBW40MHz = false; + pHTInfo->bCurTxBW40MHz = false; + + pHTInfo->bCurShortGI20MHz = false; + pHTInfo->bCurShortGI40MHz = false; + pHTInfo->bForcedShortGI = false; + + pHTInfo->bCurSuppCCK = true; + + pHTInfo->bCurrent_AMSDU_Support = false; + pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; + pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; + pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; + + memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); + memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); + memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); + memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); + + pHTInfo->bSwBwInProgress = false; + pHTInfo->ChnlOp = CHNLOP_NONE; + + pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE; + + pHTInfo->bCurrentRT2RTAggregation = false; + pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + + pHTInfo->IOTPeer = 0; + pHTInfo->IOTAction = 0; + pHTInfo->IOTRaFunc = 0; + + { + u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + RegHTSuppRateSets[0] = 0xFF; + RegHTSuppRateSets[1] = 0xFF; + RegHTSuppRateSets[4] = 0x01; + } +} +void HTInitializeBssDesc(PBSS_HT pBssHT) +{ + + pBssHT->bdSupportHT = false; + memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf)); + pBssHT->bdHTCapLen = 0; + memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf)); + pBssHT->bdHTInfoLen = 0; + + pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE; + + pBssHT->bdRT2RTAggregation = false; + pBssHT->bdRT2RTLongSlotTime = false; + pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; +} + +void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + u8 bIOTAction = 0; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); + /*unmark bEnableHT flag here is the same reason why unmarked in function rtllib_softmac_new_net. WB 2008.09.10*/ + if (pNetwork->bssht.bdSupportHT) + { + pHTInfo->bCurrentHTSupport = true; + pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; + + if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) + memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); + + if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) + memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen); + + if (pHTInfo->bRegRT2RTAggregation) + { + pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation; + pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime; + pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode; + } + else + { + pHTInfo->bCurrentRT2RTAggregation = false; + pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + } + + HTIOTPeerDetermine(ieee); + + pHTInfo->IOTAction = 0; + bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14; + + bIOTAction = HTIOTActIsDisableMCS15(ieee); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15; + + bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS; + + + bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; + +#if defined(RTL8190P) || defined(RTL8192E) || defined(RTL8192U) + bIOTAction = HTIOTActIsMgntUseCCK6M(ieee,pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; +#elif defined(RTL8192SE) || defined(RTL8192SU) || defined RTL8192CE + bIOTAction = HTIOTActWAIOTBroadcom(ieee); + if (bIOTAction) + { + pHTInfo->IOTAction |= HT_IOT_ACT_WA_IOT_Broadcom; + } +#endif + bIOTAction = HTIOTActIsCCDFsync(ieee); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; +#if defined(RTL8192SU) || defined(RTL8192SE) || defined RTL8192CE + bIOTAction = HTIOTActIsForcedCTS2Self(ieee,pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; + + + bIOTAction = HTIOTActIsEnableBETxOPLimit(ieee); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_ENABLE_BE_TXOP; + +#if defined(RTL8192SU) + bIOTAction = HTIOCActRejcectADDBARequest(pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ; +#endif + + bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT; + + bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX; + +#if defined(RTL8192SU) + bIOTAction = HTIOCActIsDisableCckRate(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_CCK_RATE; +#endif + bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI; + + bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER; + + + bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K; + +#if defined(RTL8192SU) + bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION; + + bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ; + + bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS; +#endif + + bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS; + + bIOTAction = HTIOTActIsNullDataPowerSaving(ieee, pNetwork); + if (bIOTAction) + pHTInfo->IOTAction |= HT_IOT_ACT_NULL_DATA_POWER_SAVING; +#endif + + } else { + pHTInfo->bCurrentHTSupport = false; + pHTInfo->bCurrentRT2RTAggregation = false; + pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + + pHTInfo->IOTAction = 0; + pHTInfo->IOTRaFunc = 0; + } + +} + +void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; + + if (pHTInfo->bCurrentHTSupport) + { + if (pNetwork->bssht.bdHTInfoLen != 0) + pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; + + } +} + +void HTUseDefaultSetting(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + if (pHTInfo->bEnableHT) + { + pHTInfo->bCurrentHTSupport = true; + pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; + + pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz; + pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz; + + pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz; + + if (ieee->iw_mode == IW_MODE_ADHOC) + { + ieee->current_network.qos_data.active = ieee->current_network.qos_data.supported; + } + pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; + pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; + + pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; + pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; + + pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; + + + HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); +#ifdef TODO + Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet); +#endif + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); + ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; + +#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) + if (ieee->SetHwRegHandler != NULL) { + ieee->SetHwRegHandler( ieee->dev, HW_VAR_SHORTGI_DENSITY, (u8*)(&ieee->MaxMssDensity)); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); + } +#endif + + } + else + { + pHTInfo->bCurrentHTSupport = false; + } + return; +} +u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) +{ + if (ieee->pHTInfo->bCurrentHTSupport) + { + if ( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) + { + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED EXIST!!\n"); + return true; + } + } + return false; +} + +void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + if (pHTInfo->bRegBW40MHz == false) + return; + + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + Bandwidth=HT_CHANNEL_WIDTH_20; + + + if (pHTInfo->bSwBwInProgress) { + printk("%s: bSwBwInProgress!!\n", __func__); + return; + } + if (Bandwidth==HT_CHANNEL_WIDTH_20_40) + { + if (ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER) + Offset = HT_EXTCHNL_OFFSET_NO_EXT; + if (Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) { + pHTInfo->bCurBW40MHz = true; + pHTInfo->CurSTAExtChnlOffset = Offset; + } else { + pHTInfo->bCurBW40MHz = false; + pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; + } + } else { + pHTInfo->bCurBW40MHz = false; + pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; + } + + printk("%s():pHTInfo->bCurBW40MHz:%x\n", __func__, pHTInfo->bCurBW40MHz); + + pHTInfo->bSwBwInProgress = true; + + HTSetConnectBwModeCallback(ieee); + +} + +void HTSetConnectBwModeCallback(struct rtllib_device* ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); + if (pHTInfo->bCurBW40MHz) + { + if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER) + ieee->set_chan(ieee->dev, ieee->current_network.channel+2); + else if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER) + ieee->set_chan(ieee->dev, ieee->current_network.channel-2); + else + ieee->set_chan(ieee->dev, ieee->current_network.channel); + + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset); + } else { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + } + + pHTInfo->bSwBwInProgress = false; +} diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h new file mode 100644 index 00000000000..4c89a769915 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -0,0 +1,422 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __INC_QOS_TYPE_H +#define __INC_QOS_TYPE_H + +#include "rtllib_endianfree.h" + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 + +#ifndef RTK_DMP_PLATFORM +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) +#ifndef bool +typedef enum{false = 0, true} bool; +#endif +#endif +#endif + +typedef union _QOS_TSINFO{ + u8 charData[3]; + struct { + u8 ucTrafficType:1; + u8 ucTSID:4; + u8 ucDirection:2; + u8 ucAccessPolicy:2; + u8 ucAggregation:1; + u8 ucPSB:1; + u8 ucUP:3; + u8 ucTSInfoAckPolicy:2; + u8 ucSchedule:1; + u8 ucReserved:7; + }field; +}QOS_TSINFO, *PQOS_TSINFO; +typedef union _TSPEC_BODY{ + u8 charData[55]; + + struct + { + QOS_TSINFO TSInfo; + u16 NominalMSDUsize; + u16 MaxMSDUsize; + u32 MinServiceItv; + u32 MaxServiceItv; + u32 InactivityItv; + u32 SuspenItv; + u32 ServiceStartTime; + u32 MinDataRate; + u32 MeanDataRate; + u32 PeakDataRate; + u32 MaxBurstSize; + u32 DelayBound; + u32 MinPhyRate; + u16 SurplusBandwidthAllowance; + u16 MediumTime; + } f; +}TSPEC_BODY, *PTSPEC_BODY; + +typedef struct _WMM_TSPEC{ + u8 ID; + u8 Length; + u8 OUI[3]; + u8 OUI_Type; + u8 OUI_SubType; + u8 Version; + TSPEC_BODY Body; +} WMM_TSPEC, *PWMM_TSPEC; + +typedef struct _OCTET_STRING{ + u8 *Octet; + u16 Length; +}OCTET_STRING, *POCTET_STRING; +#define MAX_WMMELE_LENGTH 64 + +typedef u32 QOS_MODE, *PQOS_MODE; +#define QOS_DISABLE 0 +#define QOS_WMM 1 +#define QOS_WMMSA 2 +#define QOS_EDCA 4 +#define QOS_HCCA 8 +#define QOS_WMM_UAPSD 16 + +#define WMM_PARAM_ELE_BODY_LEN 18 + +#define MAX_STA_TS_COUNT 16 +#define MAX_AP_TS_COUNT 32 +#define QOS_TSTREAM_KEY_SIZE 13 + +#define WMM_ACTION_CATEGORY_CODE 17 +#define WMM_PARAM_ELE_BODY_LEN 18 + +#define MAX_TSPEC_TSID 15 +#define SESSION_REJECT_TSID 0xfe +#define DEFAULT_TSID 0xff + +#define ADDTS_TIME_SLOT 100 + +#define ACM_TIMEOUT 1000 +#define SESSION_REJECT_TIMEOUT 60000 + +typedef enum _ACK_POLICY{ + eAckPlc0_ACK = 0x00, + eAckPlc1_NoACK = 0x01, +}ACK_POLICY,*PACK_POLICY; + + +#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) + +#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4) +#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) + +#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1) +#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) + +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) + +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) + +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) + +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) + +#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) +#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) + +typedef enum { + QOSIE_SRC_ADDTSREQ, + QOSIE_SRC_ADDTSRSP, + QOSIE_SRC_REASOCREQ, + QOSIE_SRC_REASOCRSP, + QOSIE_SRC_DELTS, +} QOSIE_SOURCE; + + +typedef u32 AC_CODING; +#define AC0_BE 0 +#define AC1_BK 1 +#define AC2_VI 2 +#define AC3_VO 3 +#define AC_MAX 4 + + +#define AC_PARAM_SIZE 4 + +#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) ) +#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) + +#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) ) +#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) + +#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) ) +#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) + +#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) ) +#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) + +#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) ) +#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) + +#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) ) +#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) + +#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) ) +#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) + + + +#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) + +typedef enum _QOS_ELE_SUBTYPE{ + QOSELE_TYPE_INFO = 0x00, + QOSELE_TYPE_PARAM = 0x01, +}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE; + + +typedef enum _DIRECTION_VALUE{ + DIR_UP = 0, + DIR_DOWN = 1, + DIR_DIRECT = 2, + DIR_BI_DIR = 3, +}DIRECTION_VALUE,*PDIRECTION_VALUE; + +typedef enum _ACM_METHOD{ + eAcmWay0_SwAndHw = 0, + eAcmWay1_HW = 1, + eAcmWay2_SW = 2, +}ACM_METHOD,*PACM_METHOD; + + +typedef struct _ACM{ + u64 UsedTime; + u64 MediumTime; + u8 HwAcmCtl; +}ACM, *PACM; + + + +typedef u8 AC_UAPSD, *PAC_UAPSD; + +#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0) +#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0) + +#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1) +#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1) + +#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2) +#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2) + +#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3) +#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3) + +typedef union _QOS_TCLAS{ + + struct _TYPE_GENERAL{ + u8 Priority; + u8 ClassifierType; + u8 Mask; + } TYPE_GENERAL; + + struct _TYPE0_ETH{ + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 SrcAddr[6]; + u8 DstAddr[6]; + u16 Type; + } TYPE0_ETH; + + struct _TYPE1_IPV4{ + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 Version; + u8 SrcIP[4]; + u8 DstIP[4]; + u16 SrcPort; + u16 DstPort; + u8 DSCP; + u8 Protocol; + u8 Reserved; + } TYPE1_IPV4; + + struct _TYPE1_IPV6{ + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 Version; + u8 SrcIP[16]; + u8 DstIP[16]; + u16 SrcPort; + u16 DstPort; + u8 FlowLabel[3]; + } TYPE1_IPV6; + + struct _TYPE2_8021Q{ + u8 Priority; + u8 ClassifierType; + u8 Mask; + u16 TagType; + } TYPE2_8021Q; +} QOS_TCLAS, *PQOS_TCLAS; + +typedef struct _QOS_TSTREAM{ + + bool bUsed; + u16 MsduLifetime; + bool bEstablishing; + u8 TimeSlotCount; + u8 DialogToken; + WMM_TSPEC TSpec; + WMM_TSPEC OutStandingTSpec; + u8 NominalPhyRate; +} QOS_TSTREAM, *PQOS_TSTREAM; + +typedef struct _STA_QOS{ + u8 WMMIEBuf[MAX_WMMELE_LENGTH]; + u8* WMMIE; + + QOS_MODE QosCapability; + QOS_MODE CurrentQosMode; + + AC_UAPSD b4ac_Uapsd; + AC_UAPSD Curr4acUapsd; + u8 bInServicePeriod; + u8 MaxSPLength; + int NumBcnBeforeTrigger; + + u8 * pWMMInfoEle; + u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; + + ACM acm[4]; + ACM_METHOD AcmMethod; + + QOS_TSTREAM StaTsArray[MAX_STA_TS_COUNT]; + u8 DialogToken; + WMM_TSPEC TSpec; + + u8 QBssWirelessMode; + + bool bNoAck; + + bool bEnableRxImmBA; + +}STA_QOS, *PSTA_QOS; + +#define QBSS_LOAD_SIZE 5 +#define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) +#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value) +#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2) +#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value) +#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3) +#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value) + +typedef struct _BSS_QOS{ + + QOS_MODE bdQoSMode; + u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; + OCTET_STRING bdWMMIE; + + QOS_ELE_SUBTYPE EleSubType; + + u8* pWMMInfoEle; + u8* pWMMParamEle; + + u8 QBssLoad[QBSS_LOAD_SIZE]; + bool bQBssLoadValid; +}BSS_QOS, *PBSS_QOS; + +#define sQoSCtlLng 2 +#define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) + + +#define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false ) + + +typedef union _ACI_AIFSN{ + u8 charData; + + struct + { + u8 AIFSN:4; + u8 ACM:1; + u8 ACI:2; + u8 Reserved:1; + }f; +}ACI_AIFSN, *PACI_AIFSN; + +typedef union _ECW{ + u8 charData; + struct + { + u8 ECWmin:4; + u8 ECWmax:4; + }f; +}ECW, *PECW; + +typedef union _AC_PARAM{ + u32 longData; + u8 charData[4]; + + struct + { + ACI_AIFSN AciAifsn; + ECW Ecw; + u16 TXOPLimit; + }f; +}AC_PARAM, *PAC_PARAM; + + + + + +#endif diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h similarity index 50% rename from drivers/staging/rtl8192e/ieee80211/rtl819x_TS.h rename to drivers/staging/rtl8192e/rtl819x_TS.h index e7e26fd9639..095edfde6db 100644 --- a/drivers/staging/rtl8192e/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -1,14 +1,31 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ #ifndef _TSTYPE_H_ #define _TSTYPE_H_ #include "rtl819x_Qos.h" -#define TS_SETUP_TIMEOUT 60 // In millisecond +#define TS_SETUP_TIMEOUT 60 #define TS_INACT_TIMEOUT 60 #define TS_ADDBA_DELAY 60 #define TOTAL_TS_NUM 16 #define TCLAS_NUM 4 -// This define the Tx/Rx directions typedef enum _TR_SELECT { TX_DIR = 0, RX_DIR = 1, @@ -28,12 +45,12 @@ typedef struct _TS_COMMON_INFO{ typedef struct _TX_TS_RECORD{ TS_COMMON_INFO TsCommonInfo; u16 TxCurSeq; - BA_RECORD TxPendingBARecord; // For BA Originator - BA_RECORD TxAdmittedBARecord; // For BA Originator -// QOS_DL_RECORD DLRecord; + BA_RECORD TxPendingBARecord; + BA_RECORD TxAdmittedBARecord; u8 bAddBaReqInProgress; u8 bAddBaReqDelayed; u8 bUsingBa; + u8 bDisable_AddBa; struct timer_list TsAddBaTimer; u8 num; } TX_TS_RECORD, *PTX_TS_RECORD; @@ -44,13 +61,11 @@ typedef struct _RX_TS_RECORD { u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; struct timer_list RxPktPendingTimer; - BA_RECORD RxAdmittedBARecord; // For BA Recipient + BA_RECORD RxAdmittedBARecord; u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; -// QOS_DL_RECORD DLRecord; } RX_TS_RECORD, *PRX_TS_RECORD; #endif - diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c new file mode 100644 index 00000000000..0900bfa5fad --- /dev/null +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -0,0 +1,647 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtllib.h" +#include +#include "rtl819x_TS.h" +extern void _setup_timer( struct timer_list*, void*, unsigned long); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) +#endif +void TsSetupTimeOut(unsigned long data) +{ +} + +void TsInactTimeout(unsigned long data) +{ +} + +void RxPktPendingTimeout(unsigned long data) +{ + PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + + PRX_REORDER_ENTRY pReorderEntry = NULL; + + unsigned long flags = 0; + struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; + u8 index = 0; + bool bPktInBuf = false; + + spin_lock_irqsave(&(ieee->reorder_spinlock), flags); + if (pRxTs->RxTimeoutIndicateSeq != 0xffff) + { + while(!list_empty(&pRxTs->RxPendingPktList)) + { + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + if (index == 0) + pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; + + if ( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) + { + list_del_init(&pReorderEntry->List); + + if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) + pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; + + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, pReorderEntry->SeqNum); + stats_IndicateArray[index] = pReorderEntry->prxb; + index++; + + list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); + } + else + { + bPktInBuf = true; + break; + } + } + } + + if (index>0){ + pRxTs->RxTimeoutIndicateSeq = 0xffff; + + if (index > REORDER_WIN_SIZE){ + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + return; + } + rtllib_indicate_packets(ieee, stats_IndicateArray, index); + bPktInBuf = false; + } + + if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){ + pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; + mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); + } + spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); +} + +void TsAddBaProcess(unsigned long data) +{ + PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + u8 num = pTxTs->num; + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]); + + TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); +} + + +void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) +{ + memset(pTsCommonInfo->Addr, 0, 6); + memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); + memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); + pTsCommonInfo->TClasProc = 0; + pTsCommonInfo->TClasNum = 0; +} + +void ResetTxTsEntry(PTX_TS_RECORD pTS) +{ + ResetTsCommonInfo(&pTS->TsCommonInfo); + pTS->TxCurSeq = 0; + pTS->bAddBaReqInProgress = false; + pTS->bAddBaReqDelayed = false; + pTS->bUsingBa = false; + pTS->bDisable_AddBa = false; + ResetBaEntry(&pTS->TxAdmittedBARecord); + ResetBaEntry(&pTS->TxPendingBARecord); +} + +void ResetRxTsEntry(PRX_TS_RECORD pTS) +{ + ResetTsCommonInfo(&pTS->TsCommonInfo); + pTS->RxIndicateSeq = 0xffff; + pTS->RxTimeoutIndicateSeq = 0xffff; + ResetBaEntry(&pTS->RxAdmittedBARecord); +} +#ifdef _RTL8192_EXT_PATCH_ +void ResetAdmitTRStream(struct rtllib_device *ieee, u8 *Addr) +{ + u8 dir; + bool search_dir[4] = {0, 0, 0, 0}; + struct list_head* psearch_list; + PTS_COMMON_INFO pRet = NULL; + PRX_TS_RECORD pRxTS = NULL; + PTX_TS_RECORD pTxTS = NULL; + + if (ieee->iw_mode != IW_MODE_MESH) + return; + + search_dir[DIR_DOWN] = true; + psearch_list = &ieee->Rx_TS_Admit_List; + for (dir = 0; dir <= DIR_BI_DIR; dir++) + { + if (search_dir[dir] ==false ) + continue; + list_for_each_entry(pRet, psearch_list, List){ + if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir)) + { + pRxTS = (PRX_TS_RECORD)pRet; + pRxTS->RxIndicateSeq = 0xffff; + pRxTS->RxTimeoutIndicateSeq = 0xffff; + } + + } + } + search_dir[DIR_UP] = true; + psearch_list = &ieee->Tx_TS_Admit_List; + for (dir = 0; dir <= DIR_BI_DIR; dir++) + { + if (search_dir[dir] ==false ) + continue; + list_for_each_entry(pRet, psearch_list, List){ + if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir)) + { + pTxTS = (PTX_TS_RECORD)pRet; + pTxTS->TxCurSeq = 0xffff; + } + + } + } + + return; +} +#endif + +void TSInitialize(struct rtllib_device *ieee) +{ + PTX_TS_RECORD pTxTS = ieee->TxTsRecord; + PRX_TS_RECORD pRxTS = ieee->RxTsRecord; + PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; + u8 count = 0; + RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__); + INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); + INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); + INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); + + for (count = 0; count < TOTAL_TS_NUM; count++) + { + pTxTS->num = count; + _setup_timer(&pTxTS->TsCommonInfo.SetupTimer, + TsSetupTimeOut, + (unsigned long) pTxTS); + + _setup_timer(&pTxTS->TsCommonInfo.InactTimer, + TsInactTimeout, + (unsigned long) pTxTS); + + _setup_timer(&pTxTS->TsAddBaTimer, + TsAddBaProcess, + (unsigned long) pTxTS); + + _setup_timer(&pTxTS->TxPendingBARecord.Timer, + BaSetupTimeOut, + (unsigned long) pTxTS); + _setup_timer(&pTxTS->TxAdmittedBARecord.Timer, + TxBaInactTimeout, + (unsigned long) pTxTS); + + ResetTxTsEntry(pTxTS); + list_add_tail(&pTxTS->TsCommonInfo.List, + &ieee->Tx_TS_Unused_List); + pTxTS++; + } + + INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); + INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); + INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); + for (count = 0; count < TOTAL_TS_NUM; count++) + { + pRxTS->num = count; + INIT_LIST_HEAD(&pRxTS->RxPendingPktList); + + _setup_timer(&pRxTS->TsCommonInfo.SetupTimer, + TsSetupTimeOut, + (unsigned long) pRxTS); + + _setup_timer(&pRxTS->TsCommonInfo.InactTimer, + TsInactTimeout, + (unsigned long) pRxTS); + + _setup_timer(&pRxTS->RxAdmittedBARecord.Timer, + RxBaInactTimeout, + (unsigned long) pRxTS); + + _setup_timer(&pRxTS->RxPktPendingTimer, + RxPktPendingTimeout, + (unsigned long) pRxTS); + + ResetRxTsEntry(pRxTS); + list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); + pRxTS++; + } + INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); + for (count = 0; count < REORDER_ENTRY_NUM; count++) + { + list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + if (count == (REORDER_ENTRY_NUM-1)) + break; + pRxReorderEntry = &ieee->RxReorderEntry[count+1]; + } + +} + +void AdmitTS(struct rtllib_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime) +{ + del_timer_sync(&pTsCommonInfo->SetupTimer); + del_timer_sync(&pTsCommonInfo->InactTimer); + + if (InactTime!=0) + mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); +} + + +PTS_COMMON_INFO SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) +{ + u8 dir; + bool search_dir[4] = {0, 0, 0, 0}; + struct list_head* psearch_list; + PTS_COMMON_INFO pRet = NULL; + if (ieee->iw_mode == IW_MODE_MASTER) + { + if (TxRxSelect == TX_DIR) + { + search_dir[DIR_DOWN] = true; + search_dir[DIR_BI_DIR]= true; + } + else + { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR]= true; + } + } + else if (ieee->iw_mode == IW_MODE_ADHOC) + { + if (TxRxSelect == TX_DIR) + search_dir[DIR_UP] = true; + else + search_dir[DIR_DOWN] = true; + } + else + { + if (TxRxSelect == TX_DIR) + { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR]= true; + search_dir[DIR_DIRECT]= true; + } + else + { + search_dir[DIR_DOWN] = true; + search_dir[DIR_BI_DIR]= true; + search_dir[DIR_DIRECT]= true; + } + } + + if (TxRxSelect == TX_DIR) + psearch_list = &ieee->Tx_TS_Admit_List; + else + psearch_list = &ieee->Rx_TS_Admit_List; + + for (dir = 0; dir <= DIR_BI_DIR; dir++) + { + if (search_dir[dir] ==false ) + continue; + list_for_each_entry(pRet, psearch_list, List){ + if (memcmp(pRet->Addr, Addr, 6) == 0) + if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) + if (pRet->TSpec.f.TSInfo.field.ucDirection == dir) + { + break; + } + + } + if (&pRet->List != psearch_list) + break; + } + + if (&pRet->List != psearch_list){ + return pRet ; + } + else + return NULL; +} + +void MakeTSEntry( + PTS_COMMON_INFO pTsCommonInfo, + u8* Addr, + PTSPEC_BODY pTSPEC, + PQOS_TCLAS pTCLAS, + u8 TCLAS_Num, + u8 TCLAS_Proc + ) +{ + u8 count; + + if (pTsCommonInfo == NULL) + return; + + memcpy(pTsCommonInfo->Addr, Addr, 6); + + if (pTSPEC != NULL) + memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY)); + + for (count = 0; count < TCLAS_Num; count++) + memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS)); + + pTsCommonInfo->TClasProc = TCLAS_Proc; + pTsCommonInfo->TClasNum = TCLAS_Num; +} + +#ifdef _RTL8192_EXT_PATCH_ +void dump_ts_list(struct list_head * ts_list) +{ + PTS_COMMON_INFO pRet = NULL; + u8 i=0; + list_for_each_entry(pRet, ts_list, List){ + printk("i=%d ADD:"MAC_FMT", TID:%d, dir:%d\n",i,MAC_ARG(pRet->Addr), pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); + i++; + } + +} +#endif + +bool GetTs( + struct rtllib_device* ieee, + PTS_COMMON_INFO *ppTS, + u8* Addr, + u8 TID, + TR_SELECT TxRxSelect, + bool bAddNewTs) +{ + u8 UP = 0; + if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n"); + return false; + } + if (ieee->current_network.qos_data.supported == 0) { + UP = 0; + } else { + if (!IsACValid(TID)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __func__, TID); + return false; + } + + switch (TID) { + case 0: + case 3: + UP = 0; + break; + case 1: + case 2: + UP = 2; + break; + case 4: + case 5: + UP = 5; + break; + case 6: + case 7: + UP = 7; + break; + } + } + + *ppTS = SearchAdmitTRStream( + ieee, + Addr, + UP, + TxRxSelect); + if (*ppTS != NULL) + { + return true; + } + else + { + if (bAddNewTs == false) + { + RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP); + return false; + } + else + { + TSPEC_BODY TSpec; + PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo; + struct list_head* pUnusedList = + (TxRxSelect == TX_DIR)? + (&ieee->Tx_TS_Unused_List): + (&ieee->Rx_TS_Unused_List); + + struct list_head* pAddmitList = + (TxRxSelect == TX_DIR)? + (&ieee->Tx_TS_Admit_List): + (&ieee->Rx_TS_Admit_List); + + DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)? + ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): + ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); + RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); + if (!list_empty(pUnusedList)) + { + (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List); + list_del_init(&(*ppTS)->List); + if (TxRxSelect==TX_DIR) + { + PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); + ResetTxTsEntry(tmp); + } + else{ + PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); + ResetRxTsEntry(tmp); + } + + RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS); + pTSInfo->field.ucTrafficType = 0; + pTSInfo->field.ucTSID = UP; + pTSInfo->field.ucDirection = Dir; + pTSInfo->field.ucAccessPolicy = 1; + pTSInfo->field.ucAggregation = 0; + pTSInfo->field.ucPSB = 0; + pTSInfo->field.ucUP = UP; + pTSInfo->field.ucTSInfoAckPolicy = 0; + pTSInfo->field.ucSchedule = 0; + + MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); + AdmitTS(ieee, *ppTS, 0); + list_add_tail(&((*ppTS)->List), pAddmitList); + + return true; + } + else + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __func__,Dir); + return false; + } + } + } +} + +void RemoveTsEntry( + struct rtllib_device* ieee, + PTS_COMMON_INFO pTs, + TR_SELECT TxRxSelect + ) +{ + del_timer_sync(&pTs->SetupTimer); + del_timer_sync(&pTs->InactTimer); + TsInitDelBA(ieee, pTs, TxRxSelect); + + if (TxRxSelect == RX_DIR) + { + PRX_REORDER_ENTRY pRxReorderEntry; + PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; + + if (timer_pending(&pRxTS->RxPktPendingTimer)) + del_timer_sync(&pRxTS->RxPktPendingTimer); + + while(!list_empty(&pRxTS->RxPendingPktList)){ + pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + list_del_init(&pRxReorderEntry->List); + { + int i = 0; + struct rtllib_rxb * prxb = pRxReorderEntry->prxb; + if (unlikely(!prxb)){ + return; + } + for (i =0; i < prxb->nr_subframes; i++) { + dev_kfree_skb(prxb->subframes[i]); + } + kfree(prxb); + prxb = NULL; + } + list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + } + } + else{ + PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs; + del_timer_sync(&pTxTS->TsAddBaTimer); + } +} + +void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) +{ + PTS_COMMON_INFO pTS, pTmpTS; + printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); +#if 1 + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) + { + if (memcmp(pTS->Addr, Addr, 6) == 0) + { + RemoveTsEntry(ieee, pTS, TX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + } + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) + { + if (memcmp(pTS->Addr, Addr, 6) == 0) + { + printk("====>remove Tx_TS_admin_list\n"); + RemoveTsEntry(ieee, pTS, TX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + } + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) + { + if (memcmp(pTS->Addr, Addr, 6) == 0) + { + RemoveTsEntry(ieee, pTS, RX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + } + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) + { + if (memcmp(pTS->Addr, Addr, 6) == 0) + { + RemoveTsEntry(ieee, pTS, RX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + } + } +#endif +} + +void RemoveAllTS(struct rtllib_device* ieee) +{ + PTS_COMMON_INFO pTS, pTmpTS; +#if 1 + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) + { + RemoveTsEntry(ieee, pTS, TX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) + { + RemoveTsEntry(ieee, pTS, TX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) + { + RemoveTsEntry(ieee, pTS, RX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + } + + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) + { + RemoveTsEntry(ieee, pTS, RX_DIR); + list_del_init(&pTS->List); + list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + } +#endif +} + +void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS) +{ + if (pTxTS->bAddBaReqInProgress == false) + { + pTxTS->bAddBaReqInProgress = true; +#if 1 + if (pTxTS->bAddBaReqDelayed) + { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); + mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); + } + else + { + RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); + } +#endif + } + else + RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__); +} diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c new file mode 100644 index 00000000000..c2d51bc5a87 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -0,0 +1,379 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtl_core.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */ +#include "r8192E_cmdpkt.h" + +extern int hwwep; +void CamResetAllEntry(struct net_device *dev) +{ + u32 ulcommand = 0; + + ulcommand |= BIT31|BIT30; + write_nic_dword(dev, RWCAM, ulcommand); +} + +void write_cam(struct net_device *dev, u8 addr, u32 data) +{ + write_nic_dword(dev, WCAMI, data); + write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) ); +} + +u32 read_cam(struct net_device *dev, u8 addr) +{ + write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) ); + return read_nic_dword(dev, 0xa8); +} + +void EnableHWSecurityConfig8192(struct net_device *dev) +{ + u8 SECR_value = 0x0; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; + if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->rtllib->auth_mode != 2)) + { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) + { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + + + ieee->hwsec_active = 1; + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) + { + ieee->hwsec_active = 0; + SECR_value &= ~SCR_RxDecEnable; + } + + RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__, \ + ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); + { + write_nic_byte(dev, SECR, SECR_value); + } +} + +void set_swcam(struct net_device *dev, + u8 EntryNo, + u8 KeyIndex, + u16 KeyType, + u8 *MacAddr, + u8 DefaultKey, + u32 *KeyContent, + u8 is_mesh) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is " + "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo, + KeyIndex, KeyType, is_mesh); + if (is_mesh){ + } else { + ieee->swcamtable[EntryNo].bused=true; + ieee->swcamtable[EntryNo].key_index=KeyIndex; + ieee->swcamtable[EntryNo].key_type=KeyType; + memcpy(ieee->swcamtable[EntryNo].macaddr,MacAddr,6); + ieee->swcamtable[EntryNo].useDK=DefaultKey; + memcpy(ieee->swcamtable[EntryNo].key_buf,(u8*)KeyContent,16); + } +} + +void setKey(struct net_device *dev, + u8 EntryNo, + u8 KeyIndex, + u16 KeyType, + u8 *MacAddr, + u8 DefaultKey, + u32 *KeyContent ) +{ + u32 TargetCommand = 0; + u32 TargetContent = 0; + u16 usConfig = 0; + u8 i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + RT_RF_POWER_STATE rtState; + rtState = priv->rtllib->eRFPowerState; + if (priv->rtllib->PowerSaveControl.bInactivePs){ + if (rtState == eRfOff){ + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + return ; + } + else{ + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); } + } + } + priv->rtllib->is_set_key = true; + if (EntryNo >= TOTAL_CAM_ENTRY) + RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); + + RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," + "KeyType:%d, MacAddr"MAC_FMT"\n", dev,EntryNo, KeyIndex, + KeyType, MAC_ARG(MacAddr)); + + if (DefaultKey) + usConfig |= BIT15 | (KeyType<<2); + else + usConfig |= BIT15 | (KeyType<<2) | KeyIndex; + + + for (i = 0; i < CAM_CONTENT_COUNT; i++) { + TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; + TargetCommand |= BIT31|BIT16; + + if (i == 0) { + TargetContent = (u32)(*(MacAddr+0)) << 16| + (u32)(*(MacAddr+1)) << 24| + (u32)usConfig; + + write_nic_dword(dev, WCAMI, TargetContent); + write_nic_dword(dev, RWCAM, TargetCommand); + } else if (i == 1) { + TargetContent = (u32)(*(MacAddr+2)) | + (u32)(*(MacAddr+3)) << 8| + (u32)(*(MacAddr+4)) << 16| + (u32)(*(MacAddr+5)) << 24; + write_nic_dword(dev, WCAMI, TargetContent); + write_nic_dword(dev, RWCAM, TargetCommand); + } else { + if (KeyContent != NULL) { + write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); + write_nic_dword(dev, RWCAM, TargetCommand); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) + udelay(100); +#endif + } + } + } + RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig); +} + +void CAM_read_entry(struct net_device *dev, u32 iIndex) +{ + u32 target_command=0; + u32 target_content=0; + u8 entry_i=0; + u32 ulStatus; + s32 i=100; + for (entry_i=0;entry_i=0) + { + ulStatus = read_nic_dword(dev, RWCAM); + if (ulStatus & BIT31){ + continue; + } + else{ + break; + } + } + write_nic_dword(dev, RWCAM, target_command); + RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command); + target_content = read_nic_dword(dev, RCAMO); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content); + } + printk("\n"); +} + +void CamRestoreAllEntry( struct net_device *dev) +{ + u8 EntryId = 0; + struct r8192_priv *priv = rtllib_priv(dev); + u8* MacAddr = priv->rtllib->current_network.bssid; + + static u8 CAM_CONST_ADDR[4][6] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}; + static u8 CAM_CONST_BROAD[] = + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n"); + + + if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40)|| + (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) + { + + for (EntryId=0; EntryId<4; EntryId++) + { + { + MacAddr = CAM_CONST_ADDR[EntryId]; + if (priv->rtllib->swcamtable[EntryId].bused ) + { + setKey(dev, + EntryId , + EntryId, + priv->rtllib->pairwise_key_type, + MacAddr, + 0, + (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) + ); + } + } + } + + } + else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) + { + + { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + { + setKey(dev, + 4, + 0, + priv->rtllib->pairwise_key_type, + (u8*)dev->dev_addr, + 0, + (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) + ); + } + else + { + setKey(dev, + 4, + 0, + priv->rtllib->pairwise_key_type, + MacAddr, + 0, + (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) + ); + } + + } + } + else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) + { + + { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + { + setKey(dev, + 4, + 0, + priv->rtllib->pairwise_key_type, + (u8*)dev->dev_addr, + 0, + (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) + ); + } + else + { + setKey(dev, + 4, + 0, + priv->rtllib->pairwise_key_type, + MacAddr, + 0, + (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) + ); + } + } + } + + + + if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) + { + MacAddr = CAM_CONST_BROAD; + for (EntryId=1 ; EntryId<4 ; EntryId++) + { + if (priv->rtllib->swcamtable[EntryId].bused ) + { + setKey(dev, + EntryId, + EntryId, + priv->rtllib->group_key_type, + MacAddr, + 0, + (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) + ); + } + } + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + { + if (priv->rtllib->swcamtable[0].bused ){ + setKey(dev, + 0, + 0, + priv->rtllib->group_key_type, + CAM_CONST_ADDR[0], + 0, + (u32*)(&priv->rtllib->swcamtable[0].key_buf[0]) + ); + } + else + { + RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",__func__); + return; + } + } + } else if (priv->rtllib->group_key_type == KEY_TYPE_CCMP) { + MacAddr = CAM_CONST_BROAD; + for (EntryId=1; EntryId<4 ; EntryId++) + { + if (priv->rtllib->swcamtable[EntryId].bused ) + { + setKey(dev, + EntryId , + EntryId, + priv->rtllib->group_key_type, + MacAddr, + 0, + (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); + } + } + + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + if (priv->rtllib->swcamtable[0].bused) { + setKey(dev, + 0 , + 0, + priv->rtllib->group_key_type, + CAM_CONST_ADDR[0], + 0, + (u32*)(&priv->rtllib->swcamtable[0].key_buf[0])); + } else { + RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n", + __func__); + return; + } + } + } +} diff --git a/drivers/staging/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl_cam.h new file mode 100644 index 00000000000..9e4d0edb21b --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_cam.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef _RTL_CAM_H +#define _RTL_CAM_H + +#include +struct net_device; + +void CamResetAllEntry(struct net_device* dev); +void EnableHWSecurityConfig8192(struct net_device *dev); +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent ); +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); +void CamPrintDbgReg(struct net_device* dev); + +u32 read_cam(struct net_device *dev, u8 addr); +void write_cam(struct net_device *dev, u8 addr, u32 data); + +void CamRestoreAllEntry(struct net_device *dev); + +void CAM_read_entry(struct net_device *dev, u32 iIndex); + +#endif diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c new file mode 100644 index 00000000000..81cb13fce6f --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -0,0 +1,4084 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#undef LOOP_TEST +#undef RX_DONT_PASS_UL +#undef DEBUG_EPROM +#undef DEBUG_RX_VERBOSE +#undef DUMMY_RX +#undef DEBUG_ZERO_RX +#undef DEBUG_RX_SKB +#undef DEBUG_TX_FRAG +#undef DEBUG_RX_FRAG +#undef DEBUG_TX_FILLDESC +#undef DEBUG_TX +#undef DEBUG_IRQ +#undef DEBUG_RX +#undef DEBUG_RXALLOC +#undef DEBUG_REGISTERS +#undef DEBUG_RING +#undef DEBUG_IRQ_TASKLET +#undef DEBUG_TX_ALLOC +#undef DEBUG_TX_DESC + +#include +#include +#include "rtl_core.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" +#include "r8192E_cmdpkt.h" + +#include "rtl_wx.h" +#ifndef RTL8192CE +#include "rtl_dm.h" +#endif + +#ifdef CONFIG_PM_RTL +#include "rtl_pm.h" +#endif + +int hwwep = 1; +static int channels = 0x3fff; +char* ifname = "wlan%d"; + + +struct rtl819x_ops rtl819xp_ops = { + .nic_type = NIC_8192E, + .get_eeprom_size = rtl8192_get_eeprom_size, + .init_adapter_variable = rtl8192_InitializeVariables, + .initialize_adapter = rtl8192_adapter_start, + .link_change = rtl8192_link_change, + .tx_fill_descriptor = rtl8192_tx_fill_desc, + .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, + .rx_query_status_descriptor = rtl8192_rx_query_status_desc, + .rx_command_packet_handler = NULL, + .stop_adapter = rtl8192_halt_adapter, + .update_ratr_table = rtl8192_update_ratr_table, + .irq_enable = rtl8192_EnableInterrupt, + .irq_disable = rtl8192_DisableInterrupt, + .irq_clear = rtl8192_ClearInterrupt, + .rx_enable = rtl8192_enable_rx, + .tx_enable = rtl8192_enable_tx, + .interrupt_recognized = rtl8192_interrupt_recognized, + .TxCheckStuckHandler = rtl8192_HalTxCheckStuck, + .RxCheckStuckHandler = rtl8192_HalRxCheckStuck, +}; + +static struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = { + {RTL_PCI_DEVICE(0x10ec, 0x8192, rtl819xp_ops)}, + {RTL_PCI_DEVICE(0x07aa, 0x0044, rtl819xp_ops)}, + {RTL_PCI_DEVICE(0x07aa, 0x0047, rtl819xp_ops)}, + {} +}; + +MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); + +static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id); +static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); + +static struct pci_driver rtl8192_pci_driver = { + .name = DRV_NAME, /* Driver name */ + .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ + .probe = rtl8192_pci_probe, /* probe fn */ + .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ + .suspend = rtl8192E_suspend, /* PM suspend fn */ + .resume = rtl8192E_resume, /* PM resume fn */ +}; + +/**************************************************************************** + -----------------------------IO STUFF------------------------- +*****************************************************************************/ +bool +PlatformIOCheckPageLegalAndGetRegMask( + u32 u4bPage, + u8* pu1bPageMask +) +{ + bool bReturn = false; + *pu1bPageMask = 0xfe; + + switch (u4bPage) + { + case 1: case 2: case 3: case 4: + case 8: case 9: case 10: case 12: case 13: + bReturn = true; + *pu1bPageMask = 0xf0; + break; + + default: + bReturn = false; + break; + } + + return bReturn; +} + +void write_nic_io_byte(struct net_device *dev, int x,u8 y) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + + if (u4bPage == 0) + { + outb(y&0xff,dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, (x & 0xff), y); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + + +} + +void write_nic_io_word(struct net_device *dev, int x,u16 y) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + + if (u4bPage == 0) + { + outw(y,dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_word(dev, (x & 0xff), y); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + +} + +void write_nic_io_dword(struct net_device *dev, int x,u32 y) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + + if (u4bPage == 0) + { + outl(y,dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_dword(dev, (x & 0xff), y); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + +} +u8 read_nic_io_byte(struct net_device *dev, int x) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + u8 Data = 0; + + if (u4bPage == 0) + { + return 0xff&inb(dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + Data = read_nic_io_byte(dev, (x & 0xff)); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + + return Data; +} + +u16 read_nic_io_word(struct net_device *dev, int x) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + u16 Data = 0; + + if (u4bPage == 0) + { + return inw(dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + Data = read_nic_io_word(dev, (x & 0xff)); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + + return Data; +} + +u32 read_nic_io_dword(struct net_device *dev, int x) +{ + u32 u4bPage = (x >> 8); + u8 u1PageMask = 0; + bool bIsLegalPage = false; + u32 Data = 0; + + if (u4bPage == 0) + { + return inl(dev->base_addr +x); + }else + { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); + if (bIsLegalPage) + { + u8 u1bPsr = read_nic_io_byte(dev, PSR); + + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + Data = read_nic_io_dword(dev, (x & 0xff)); + write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); + + }else + { + ; + } + } + + return Data; +} + +u8 read_nic_byte(struct net_device *dev, int x) +{ +#ifdef CONFIG_RTL8192_IO_MAP + return read_nic_io_byte(dev, x); +#else + return 0xff&readb((u8*)dev->mem_start +x); +#endif +} + +u32 read_nic_dword(struct net_device *dev, int x) +{ +#ifdef CONFIG_RTL8192_IO_MAP + return read_nic_io_dword(dev, x); +#else + return readl((u8*)dev->mem_start +x); +#endif +} + +u16 read_nic_word(struct net_device *dev, int x) +{ +#ifdef CONFIG_RTL8192_IO_MAP + return read_nic_io_word(dev, x); +#else + return readw((u8*)dev->mem_start +x); +#endif +} + +void write_nic_byte(struct net_device *dev, int x,u8 y) +{ +#ifdef CONFIG_RTL8192_IO_MAP + write_nic_io_byte(dev, x, y); +#else + writeb(y,(u8*)dev->mem_start +x); + +#if !(defined RTL8192SE || defined RTL8192CE) + udelay(20); +#endif + +#if defined RTL8192CE + read_nic_byte(dev, x); +#endif + +#endif +} + +void write_nic_dword(struct net_device *dev, int x,u32 y) +{ +#ifdef CONFIG_RTL8192_IO_MAP + write_nic_io_dword(dev, x, y); +#else + writel(y,(u8*)dev->mem_start +x); + +#if !(defined RTL8192SE || defined RTL8192CE) + udelay(20); +#endif + +#if defined RTL8192CE + read_nic_dword(dev, x); +#endif + +#endif +} + +void write_nic_word(struct net_device *dev, int x,u16 y) +{ +#ifdef CONFIG_RTL8192_IO_MAP + write_nic_io_word(dev, x, y); +#else + writew(y,(u8*)dev->mem_start +x); + +#if !(defined RTL8192SE || defined RTL8192CE) + udelay(20); +#endif + +#if defined RTL8192CE + read_nic_word(dev, x); +#endif + +#endif +} + +/**************************************************************************** + -----------------------------GENERAL FUNCTION------------------------- +*****************************************************************************/ +bool +MgntActSet_RF_State( + struct net_device* dev, + RT_RF_POWER_STATE StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot + ) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device * ieee = priv->rtllib; + bool bActionAllowed = false; + bool bConnectBySSID = false; + RT_RF_POWER_STATE rtState; + u16 RFWaitCounter = 0; + unsigned long flag; + RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); + +#ifndef RTL8192CE + ProtectOrNot = false; +#endif + + + if (!ProtectOrNot) + { + while(true) + { + spin_lock_irqsave(&priv->rf_ps_lock,flag); + if (priv->RFChangeInProgress) + { + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet); + #if 1 + while(priv->RFChangeInProgress) + { + RFWaitCounter ++; + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Wait 1 ms (%d times)...\n", RFWaitCounter); + mdelay(1); + + if (RFWaitCounter > 100) + { + RT_TRACE(COMP_ERR, "MgntActSet_RF_State(): Wait too logn to set RF\n"); + return false; + } + } + #endif + } + else + { + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + break; + } + } + } + + rtState = priv->rtllib->eRFPowerState; + + switch (StateToSet) + { + case eRfOn: + + priv->rtllib->RfOffReason &= (~ChangeSource); + + if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == true)){ + priv->bHwRadioOff = false; + } + + if (! priv->rtllib->RfOffReason) + { + priv->rtllib->RfOffReason = 0; + bActionAllowed = true; + + + if (rtState == eRfOff && ChangeSource >=RF_CHANGE_BY_HW ) + { + bConnectBySSID = true; + } + } + else{ + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", priv->rtllib->RfOffReason, ChangeSource); + } + + break; + + case eRfOff: + + if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || (priv->rtllib->iw_mode == IW_MODE_ADHOC)) + { + if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || (ChangeSource > RF_CHANGE_BY_IPS)) + { + if (ieee->state == RTLLIB_LINKED) + priv->blinked_ingpio = true; + else + priv->blinked_ingpio = false; + rtllib_MgntDisconnect(priv->rtllib,disas_lv_ss); + + + + } + } + if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == false)){ + priv->bHwRadioOff = true; + } + priv->rtllib->RfOffReason |= ChangeSource; + bActionAllowed = true; + break; + + case eRfSleep: + priv->rtllib->RfOffReason |= ChangeSource; + bActionAllowed = true; + break; + + default: + break; + } + + if (bActionAllowed) + { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->rtllib->RfOffReason); + PHY_SetRFPowerState(dev, StateToSet); + if (StateToSet == eRfOn) + { + + if (bConnectBySSID && (priv->blinked_ingpio == true)) + { + queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + priv->blinked_ingpio = false; + + } + } + } else { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->rtllib->RfOffReason); + } + + if (!ProtectOrNot) + { + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + } + + RT_TRACE((COMP_PS && COMP_RF), "<===MgntActSet_RF_State()\n"); + return bActionAllowed; +} + + +short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + /* For now, we reserved two free descriptor as a safety boundary + * between the tail and the head + */ + if ((prio == MGNT_QUEUE) &&(skb_queue_len(&ring->queue)>10)) + RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d queue_len=%d---------\n", + prio,ring->idx, skb_queue_len(&ring->queue)); + return skb_queue_len(&ring->queue); +} + +short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + if (ring->entries - skb_queue_len(&ring->queue) >= 2) { + return 1; + } else { + return 0; + } +} + +void rtl8192_tx_timeout(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) + schedule_work(&priv->reset_wq); +#else + schedule_task(&priv->reset_wq); +#endif + printk("TXTIMEOUT"); +} + +void rtl8192_irq_enable(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->irq_enabled = 1; + + priv->ops->irq_enable(dev); +} + +void rtl8192_irq_disable(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + priv->ops->irq_disable(dev); + + priv->irq_enabled = 0; +} + +void rtl8192_irq_clear(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + priv->ops->irq_clear(dev); +} + + +void rtl8192_set_chan(struct net_device *dev,short ch) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); + if (priv->chan_forced) + return; + + priv->chan = ch; + + +#ifndef LOOP_TEST + + + if (priv->rf_set_chan) + priv->rf_set_chan(dev,priv->chan); + +#ifdef CONFIG_FW_SETCHAN + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_CHAN_SET); +#endif + +#endif +} + +void rtl8192_update_cap(struct net_device* dev, u16 cap) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net = &priv->rtllib->current_network; + + + { + bool ShortPreamble; + + if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) + { + if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) + { + ShortPreamble = true; + priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); + } + } + else + { + if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) + { + ShortPreamble = false; + priv->dot11CurrentPreambleMode = PREAMBLE_LONG; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); + } + } + } + +#ifdef RTL8192CE + if ( net->mode & IEEE_G) +#elif defined RTL8192SE || defined RTL8192E || defined RTL8190P + if (net->mode & (IEEE_G|IEEE_N_24G)) +#endif + { + u8 slot_time_val; + u8 CurSlotTime = priv->slot_time; + +#ifdef RTL8192CE + if ( (cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!(priv->rtllib->pHTInfo->RT2RT_HT_Mode & RT_HT_CAP_USE_LONG_PREAMBLE))) +#elif defined RTL8192SE || defined RTL8192E || defined RTL8190P + if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) +#endif + { + if (CurSlotTime != SHORT_SLOT_TIME) + { + slot_time_val = SHORT_SLOT_TIME; + priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + } + } + else + { + if (CurSlotTime != NON_SHORT_SLOT_TIME) + { + slot_time_val = NON_SHORT_SLOT_TIME; + priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + } + } + } +} + +static struct rtllib_qos_parameters def_qos_parameters = { + {3,3,3,3}, + {7,7,7,7}, + {2,2,2,2}, + {0,0,0,0}, + {0,0,0,0} +}; + +void rtl8192_update_beacon(void *data) +{ +#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20) + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + struct rtllib_device* ieee = priv->rtllib; + struct rtllib_network* net = &ieee->current_network; + + if (ieee->pHTInfo->bCurrentHTSupport) + HTUpdateSelfAndPeerSetting(ieee, net); + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode; + rtl8192_update_cap(dev, net->capability); +} + +#define MOVE_INTO_HANDLER +#ifdef RTL8192CE +int WDCAPARA_ADD[] = {REG_EDCA_BE_PARAM,REG_EDCA_BK_PARAM,REG_EDCA_VI_PARAM,REG_EDCA_VO_PARAM}; +#else +int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +#endif +void rtl8192_qos_activate(void *data) +{ +#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20) + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif +#ifndef MOVE_INTO_HANDLER + struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; + u8 mode = priv->rtllib->current_network.mode; + u8 u1bAIFS; + u32 u4bAcParam; +#endif + int i; + + if (priv == NULL) + return; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) + down(&priv->mutex); +#else + mutex_lock(&priv->mutex); +#endif + if (priv->rtllib->state != RTLLIB_LINKED) + goto success; + RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); + + for (i = 0; i < QOS_QUEUE_NUM; i++) { +#ifndef MOVE_INTO_HANDLER + u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| + (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| + (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + RT_TRACE(COMP_DBG, "===>ACI:%d:u4bAcParam:%x\n", i, u4bAcParam); + write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); +#else + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&i)); +#endif + } + +success: +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) + up(&priv->mutex); +#else + mutex_unlock(&priv->mutex); +#endif +} + +static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, + int active_network, + struct rtllib_network *network) +{ + int ret = 0; + u32 size = sizeof(struct rtllib_qos_parameters); + + if (priv->rtllib->state !=RTLLIB_LINKED) + return ret; + + if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) + return ret; + + if (network->flags & NETWORK_HAS_QOS_MASK) { + if (active_network && + (network->flags & NETWORK_HAS_QOS_PARAMETERS)) + network->qos_data.active = network->qos_data.supported; + + if ((network->qos_data.active == 1) && (active_network == 1) && + (network->flags & NETWORK_HAS_QOS_PARAMETERS) && + (network->qos_data.old_param_count != + network->qos_data.param_count)) { + network->qos_data.old_param_count = + network->qos_data.param_count; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + queue_work_rsl(priv->priv_wq, &priv->qos_activate); + RT_TRACE (COMP_QOS, "QoS parameters change call " + "qos_activate\n"); + } + } else { + memcpy(&priv->rtllib->current_network.qos_data.parameters,\ + &def_qos_parameters, size); + + if ((network->qos_data.active == 1) && (active_network == 1)) { + queue_work_rsl(priv->priv_wq, &priv->qos_activate); + RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n"); + } + network->qos_data.active = 0; + network->qos_data.supported = 0; + } + + return 0; +} + +static int rtl8192_handle_beacon(struct net_device * dev, + struct rtllib_beacon * beacon, + struct rtllib_network * network) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + rtl8192_qos_handle_probe_response(priv,1,network); + + queue_delayed_work_rsl(priv->priv_wq, &priv->update_beacon_wq, 0); + return 0; + +} + +static int rtl8192_qos_association_resp(struct r8192_priv *priv, + struct rtllib_network *network) +{ + int ret = 0; + unsigned long flags; + u32 size = sizeof(struct rtllib_qos_parameters); + int set_qos_param = 0; + + if ((priv == NULL) || (network == NULL)) + return ret; + + if (priv->rtllib->state !=RTLLIB_LINKED) + return ret; + + if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) + return ret; + + spin_lock_irqsave(&priv->rtllib->lock, flags); + if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { + memcpy(&priv->rtllib->current_network.qos_data.parameters,\ + &network->qos_data.parameters,\ + sizeof(struct rtllib_qos_parameters)); + priv->rtllib->current_network.qos_data.active = 1; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + set_qos_param = 1; + priv->rtllib->current_network.qos_data.old_param_count = + priv->rtllib->current_network.qos_data.param_count; + priv->rtllib->current_network.qos_data.param_count = + network->qos_data.param_count; + } else { + memcpy(&priv->rtllib->current_network.qos_data.parameters, + &def_qos_parameters, size); + priv->rtllib->current_network.qos_data.active = 0; + priv->rtllib->current_network.qos_data.supported = 0; + set_qos_param = 1; + } + + spin_unlock_irqrestore(&priv->rtllib->lock, flags); + + RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, + network->flags ,priv->rtllib->current_network.qos_data.active); + if (set_qos_param == 1) { + dm_init_edca_turbo(priv->rtllib->dev); + queue_work_rsl(priv->priv_wq, &priv->qos_activate); + } + return ret; +} + +static int rtl8192_handle_assoc_response(struct net_device *dev, + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network) +{ + struct r8192_priv *priv = rtllib_priv(dev); + rtl8192_qos_association_resp(priv, network); + return 0; +} + +void rtl8192_prepare_beacon(struct r8192_priv *priv) +{ + struct net_device *dev = priv->rtllib->dev; + struct sk_buff *pskb = NULL, *pnewskb = NULL; + cb_desc *tcb_desc = NULL; + struct rtl8192_tx_ring *ring = NULL; + tx_desc *pdesc = NULL; + + ring = &priv->tx_ring[BEACON_QUEUE]; + pskb = __skb_dequeue(&ring->queue); + if (pskb) + kfree_skb(pskb); + + pnewskb = rtllib_get_beacon(priv->rtllib); + if (!pnewskb) + return; + + tcb_desc = (cb_desc *)(pnewskb->cb + 8); + tcb_desc->queue_index = BEACON_QUEUE; + tcb_desc->data_rate = 2; + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + skb_push(pnewskb, priv->rtllib->tx_headroom); + + pdesc = &ring->desc[0]; + priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, pnewskb); + __skb_queue_tail(&ring->queue, pnewskb); + pdesc->OWN = 1; + + return; +} + +void rtl8192_stop_beacon(struct net_device *dev) +{ +} + +void rtl8192_config_rate(struct net_device* dev, u16* rate_config) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net; + u8 i=0, basic_rate = 0; + net = & priv->rtllib->current_network; + + for (i = 0; i < net->rates_len; i++) { + basic_rate = net->rates[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } + + for (i = 0; i < net->rates_ex_len; i++) { + basic_rate = net->rates_ex[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } +} + +void rtl8192_refresh_supportrate(struct r8192_priv* priv) +{ + struct rtllib_device* ieee = priv->rtllib; + if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) { + memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + memcpy(ieee->Regdot11TxHTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + +#ifdef RTL8192CE + if (priv->rf_type == RF_1T1R) { + ieee->Regdot11HTOperationalRateSet[1] = 0; + } +#endif + +#ifdef RTL8192SE + if (priv->rf_type == RF_1T1R) { + ieee->Regdot11HTOperationalRateSet[1] = 0; + } + if (priv->rf_type == RF_1T1R || priv->rf_type == RF_1T2R) + { + ieee->Regdot11TxHTOperationalRateSet[1] = 0; + } + + if (priv->rtllib->b1SSSupport == true) { + ieee->Regdot11HTOperationalRateSet[1] = 0; + } +#endif + } else { + memset(ieee->Regdot11HTOperationalRateSet, 0, 16); + } + return; +} + +u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 ret = 0; + + switch (priv->rf_chip) { + case RF_8225: + case RF_8256: + case RF_6052: + case RF_PSEUDO_11N: + ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G | WIRELESS_MODE_B); + break; + case RF_8258: + ret = (WIRELESS_MODE_A | WIRELESS_MODE_N_5G); + break; + default: + ret = WIRELESS_MODE_B; + break; + } + return ret; +} + +void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev); + + if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) { + if (bSupportMode & WIRELESS_MODE_N_24G) { + wireless_mode = WIRELESS_MODE_N_24G; + } else if (bSupportMode & WIRELESS_MODE_N_5G) { + wireless_mode = WIRELESS_MODE_N_5G; + } else if ((bSupportMode & WIRELESS_MODE_A)) { + wireless_mode = WIRELESS_MODE_A; + } else if ((bSupportMode & WIRELESS_MODE_G)) { + wireless_mode = WIRELESS_MODE_G; + } else if ((bSupportMode & WIRELESS_MODE_B)) { + wireless_mode = WIRELESS_MODE_B; + } else { + RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported (%x)!!!\n", + __func__, bSupportMode); + wireless_mode = WIRELESS_MODE_B; + } + } + + if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == (WIRELESS_MODE_G | WIRELESS_MODE_B)) + wireless_mode = WIRELESS_MODE_G; + + priv->rtllib->mode = wireless_mode; + + ActUpdateChannelAccessSetting( dev, wireless_mode, &priv->ChannelAccessSetting); + + if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)){ + priv->rtllib->pHTInfo->bEnableHT = 1; + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", __func__,wireless_mode); + }else{ + priv->rtllib->pHTInfo->bEnableHT = 0; + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", __func__,wireless_mode); + } + + RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); + rtl8192_refresh_supportrate(priv); +} + +int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + bool init_status = true; + priv->bDriverIsGoingToUnload = false; + priv->bdisable_nic = false; + + priv->up=1; + priv->rtllib->ieee_up=1; + + priv->up_first_time = 0; + RT_TRACE(COMP_INIT, "Bringing up iface"); + priv->bfirst_init = true; + init_status = priv->ops->initialize_adapter(dev); + if (init_status != true) + { + RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + priv->bfirst_init = false; + return -1; + } + + RT_TRACE(COMP_INIT, "start adapter finished\n"); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + priv->bfirst_init = false; +#if defined RTL8192SE || defined RTL8192CE + if (priv->rtllib->eRFPowerState!=eRfOn) + MgntActSet_RF_State(dev, eRfOn, priv->rtllib->RfOffReason,true); +#endif + +#ifdef ENABLE_GPIO_RADIO_CTL + if (priv->polling_timer_on == 0){ + check_rfctrl_gpio_timer((unsigned long)dev); + } +#endif + + if (priv->rtllib->state != RTLLIB_LINKED) +#ifndef CONFIG_MP + rtllib_softmac_start_protocol(priv->rtllib, 0); +#endif + rtllib_reset_queue(priv->rtllib); +#ifndef CONFIG_MP + watch_dog_timer_callback((unsigned long) dev); +#endif + + + if (!netif_queue_stopped(dev)) + netif_start_queue(dev); + else + netif_wake_queue(dev); + + return 0; +} + +int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) +{ + struct r8192_priv *priv = rtllib_priv(dev); + unsigned long flags = 0; + u8 RFInProgressTimeOut = 0; + + if (priv->up == 0) return -1; + + if (priv->rtllib->rtllib_ips_leave != NULL) + priv->rtllib->rtllib_ips_leave(dev); + + if (priv->rtllib->state == RTLLIB_LINKED) + LeisurePSLeave(dev); + + priv->bDriverIsGoingToUnload = true; + priv->up=0; + priv->rtllib->ieee_up = 0; + priv->bfirst_after_down = 1; + RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__); + if (!netif_queue_stopped(dev)) + netif_stop_queue(dev); + + priv->rtllib->wpa_ie_len = 0; + if (priv->rtllib->wpa_ie) + kfree(priv->rtllib->wpa_ie); + priv->rtllib->wpa_ie = NULL; + CamResetAllEntry(dev); + memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + rtl8192_irq_disable(dev); + + del_timer_sync(&priv->watch_dog_timer); + rtl8192_cancel_deferred_work(priv); +#ifndef RTL8190P +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + cancel_delayed_work(&priv->rtllib->hw_wakeup_wq); +#endif +#endif + + rtllib_softmac_stop_protocol(priv->rtllib, 0, true); + spin_lock_irqsave(&priv->rf_ps_lock,flags); + while(priv->RFChangeInProgress) + { + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + if (RFInProgressTimeOut > 100) + { + spin_lock_irqsave(&priv->rf_ps_lock,flags); + break; + } + RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait until rf chang is done.\n",__func__); + mdelay(1); + RFInProgressTimeOut ++; + spin_lock_irqsave(&priv->rf_ps_lock,flags); + } + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + priv->ops->stop_adapter(dev, false); + spin_lock_irqsave(&priv->rf_ps_lock,flags); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + udelay(100); + memset(&priv->rtllib->current_network, 0 , offsetof(struct rtllib_network, list)); +#ifdef CONFIG_ASPM_OR_D3 + RT_ENABLE_ASPM(dev); +#endif + RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); + + return 0; +} + +static void rtl8192_init_priv_handler(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->rtllib->softmac_hard_start_xmit = rtl8192_hard_start_xmit; + priv->rtllib->set_chan = rtl8192_set_chan; + priv->rtllib->link_change = priv->ops->link_change; + priv->rtllib->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; + priv->rtllib->data_hard_stop = rtl8192_data_hard_stop; + priv->rtllib->data_hard_resume = rtl8192_data_hard_resume; + priv->rtllib->check_nic_enough_desc = rtl8192_check_nic_enough_desc; + priv->rtllib->get_nic_desc_num = rtl8192_get_nic_desc_num; + priv->rtllib->handle_assoc_response = rtl8192_handle_assoc_response; + priv->rtllib->handle_beacon = rtl8192_handle_beacon; + priv->rtllib->SetWirelessMode = rtl8192_SetWirelessMode; + priv->rtllib->LeisurePSLeave = LeisurePSLeave; + priv->rtllib->SetBWModeHandler = rtl8192_SetBWMode; + priv->rf_set_chan = rtl8192_phy_SwChnl; + +#ifdef _ENABLE_SW_BEACON + priv->rtllib->start_send_beacons = NULL; + priv->rtllib->stop_send_beacons = NULL; +#else + priv->rtllib->start_send_beacons = rtl8192e_start_beacon; + priv->rtllib->stop_send_beacons = rtl8192_stop_beacon; +#endif + + priv->rtllib->sta_wake_up = rtl8192_hw_wakeup; + priv->rtllib->enter_sleep_state = rtl8192_hw_to_sleep; + priv->rtllib->ps_is_queue_empty = rtl8192_is_tx_queue_empty; + + priv->rtllib->GetNmodeSupportBySecCfg = rtl8192_GetNmodeSupportBySecCfg; + priv->rtllib->GetHalfNmodeSupportByAPsHandler = rtl8192_GetHalfNmodeSupportByAPs; + + priv->rtllib->SetHwRegHandler = rtl8192e_SetHwReg; + priv->rtllib->AllowAllDestAddrHandler = rtl8192_AllowAllDestAddr; + priv->rtllib->SetFwCmdHandler = NULL; + priv->rtllib->InitialGainHandler = InitialGain819xPci; + priv->rtllib->rtllib_ips_leave_wq = rtllib_ips_leave_wq; + priv->rtllib->rtllib_ips_leave = rtllib_ips_leave; + + priv->rtllib->LedControlHandler = NULL; + priv->rtllib->UpdateBeaconInterruptHandler = NULL; + + priv->rtllib->ScanOperationBackupHandler = PHY_ScanOperationBackup8192; + +#ifdef CONFIG_RTL_RFKILL + priv->rtllib->rtllib_rfkill_poll = rtl8192_rfkill_poll; +#else + priv->rtllib->rtllib_rfkill_poll = NULL; +#endif +} + +static void rtl8192_init_priv_constant(struct net_device* dev) +{ +#if defined RTL8192SE || defined RTL8192CE || defined RTL8192E + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); +#endif + +#if defined RTL8192SE || defined RTL8192CE || defined RTL8192E + pPSC->RegMaxLPSAwakeIntvl = 5; +#endif + +#ifdef RTL8192CE + priv->bWEPinNmodeFromReg = 0; + priv->bTKIPinNmodeFromReg = 0; + + priv->RegAMDPciASPM = 0; + + priv->RegPciASPM = 3; + + priv->RegDevicePciASPMSetting = 0x03; + + priv->RegHostPciASPMSetting = 0x02; + + priv->RegHwSwRfOffD3 = 0; + + priv->RegSupportPciASPM = 1; + +#elif defined RTL8192SE + priv->RegPciASPM = 2; + + priv->RegDevicePciASPMSetting = 0x03; + + priv->RegHostPciASPMSetting = 0x02; + + priv->RegHwSwRfOffD3 = 2; + + priv->RegSupportPciASPM = 2; + +#elif defined RTL8192E + priv->RegPciASPM = 2; + + priv->RegDevicePciASPMSetting = 0x03; + + priv->RegHostPciASPMSetting = 0x02; + + priv->RegHwSwRfOffD3 = 2; + + priv->RegSupportPciASPM = 2; + +#elif defined RTL8190P +#endif +} + + +static void rtl8192_init_priv_variable(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 i; + + priv->AcmMethod = eAcmWay2_SW; + priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; + priv->rtllib->hwscan_sem_up = 1; + priv->rtllib->status = 0; + priv->H2CTxCmdSeq = 0; + priv->bDisableFrameBursting = 0; + priv->bDMInitialGainEnable = 1; + priv->polling_timer_on = 0; + priv->up_first_time = 1; + priv->blinked_ingpio = false; + priv->bDriverIsGoingToUnload = false; + priv->being_init_adapter = false; + priv->initialized_at_probe = false; + priv->sw_radio_on = true; + priv->bdisable_nic = false; + priv->bfirst_init = false; + priv->txringcount = 64; + priv->rxbuffersize = 9100; + priv->rxringcount = MAX_RX_COUNT; + priv->irq_enabled=0; + priv->chan = 1; + priv->RegWirelessMode = WIRELESS_MODE_AUTO; + priv->RegChannelPlan = 0xf; + priv->nrxAMPDU_size = 0; + priv->nrxAMPDU_aggr_num = 0; + priv->last_rxdesc_tsf_high = 0; + priv->last_rxdesc_tsf_low = 0; + priv->rtllib->mode = WIRELESS_MODE_AUTO; + priv->rtllib->iw_mode = IW_MODE_INFRA; + priv->rtllib->bNetPromiscuousMode = false; + priv->rtllib->IntelPromiscuousModeInfo.bPromiscuousOn = false; + priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = false; + priv->rtllib->ieee_up=0; + priv->retry_rts = DEFAULT_RETRY_RTS; + priv->retry_data = DEFAULT_RETRY_DATA; + priv->rtllib->rts = DEFAULT_RTS_THRESHOLD; + priv->rtllib->rate = 110; + priv->rtllib->short_slot = 1; + priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; + priv->bcck_in_ch14 = false; + priv->bfsync_processing = false; + priv->CCKPresentAttentuation = 0; + priv->rfa_txpowertrackingindex = 0; + priv->rfc_txpowertrackingindex = 0; + priv->CckPwEnl = 6; + priv->ScanDelay = 50; + priv->ResetProgress = RESET_TYPE_NORESET; + priv->bForcedSilentReset = 0; + priv->bDisableNormalResetCheck = false; + priv->force_reset = false; + memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + + memset(&priv->InterruptLog,0,sizeof(LOG_INTERRUPT_8190_T)); + priv->RxCounter = 0; + priv->rtllib->wx_set_enc = 0; + priv->bHwRadioOff = false; + priv->RegRfOff = 0; + priv->isRFOff = false; + priv->bInPowerSaveMode = false; + priv->rtllib->RfOffReason = 0; + priv->RFChangeInProgress = false; + priv->bHwRfOffAction = 0; + priv->SetRFPowerStateInProgress = false; + priv->rtllib->PowerSaveControl.bInactivePs = true; + priv->rtllib->PowerSaveControl.bIPSModeBackup = false; + priv->rtllib->PowerSaveControl.bLeisurePs = true; + priv->rtllib->PowerSaveControl.bFwCtrlLPS = false; + priv->rtllib->LPSDelayCnt = 0; + priv->rtllib->sta_sleep = LPS_IS_WAKE; + priv->rtllib->eRFPowerState = eRfOn; + + priv->txpower_checkcnt = 0; + priv->thermal_readback_index =0; + priv->txpower_tracking_callback_cnt = 0; + priv->ccktxpower_adjustcnt_ch14 = 0; + priv->ccktxpower_adjustcnt_not_ch14 = 0; + +#if defined RTL8192SE + for (i = 0; irtllib->peer_assoc_list[i]=NULL; + priv->rtllib->AvailableAIDTable[i] = 99; + } + priv->RATRTableBitmap = 0; + priv->rtllib->amsdu_in_process = 0; +#endif + + priv->rtllib->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->rtllib->iw_mode = IW_MODE_INFRA; + priv->rtllib->active_scan = 1; + priv->rtllib->be_scan_inprogress = false; + priv->rtllib->modulation = RTLLIB_CCK_MODULATION | RTLLIB_OFDM_MODULATION; + priv->rtllib->host_encrypt = 1; + priv->rtllib->host_decrypt = 1; + + priv->rtllib->dot11PowerSaveMode = eActive; + priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD; + priv->rtllib->MaxMssDensity = 0; + priv->rtllib->MinSpaceCfg = 0; + + priv->card_type = PCI; + + priv->AcmControl = 0; + priv->pFirmware = (rt_firmware*)vmalloc(sizeof(rt_firmware)); + if (priv->pFirmware) + memset(priv->pFirmware, 0, sizeof(rt_firmware)); + + skb_queue_head_init(&priv->rx_queue); + skb_queue_head_init(&priv->skb_queue); + + for (i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_head_init(&priv->rtllib->skb_waitQ [i]); + } + for (i = 0; i < MAX_QUEUE_SIZE; i++) { + skb_queue_head_init(&priv->rtllib->skb_aggQ [i]); + } + +} + +static void rtl8192_init_priv_lock(struct r8192_priv* priv) +{ + spin_lock_init(&priv->fw_scan_lock); + spin_lock_init(&priv->tx_lock); + spin_lock_init(&priv->irq_lock); + spin_lock_init(&priv->irq_th_lock); + spin_lock_init(&priv->rf_ps_lock); + spin_lock_init(&priv->ps_lock); + spin_lock_init(&priv->rf_lock); + spin_lock_init(&priv->rt_h2c_lock); +#ifdef CONFIG_ASPM_OR_D3 + spin_lock_init(&priv->D3_lock); +#endif + sema_init(&priv->wx_sem,1); + sema_init(&priv->rf_sem,1); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) + sema_init(&priv->mutex, 1); +#else + mutex_init(&priv->mutex); +#endif +} + +static void rtl8192_init_priv_task(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + +#ifdef PF_SYNCTHREAD + priv->priv_wq = create_workqueue(DRV_NAME,0); +#else + priv->priv_wq = create_workqueue(DRV_NAME); +#endif + INIT_WORK_RSL(&priv->reset_wq, (void*)rtl8192_restart, dev); + INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void*)IPSLeave_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev); + INIT_WORK_RSL(&priv->qos_activate, (void*)rtl8192_qos_activate, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev); + tasklet_init(&priv->irq_rx_tasklet, + (void(*)(unsigned long))rtl8192_irq_rx_tasklet, + (unsigned long)priv); + tasklet_init(&priv->irq_tx_tasklet, + (void(*)(unsigned long))rtl8192_irq_tx_tasklet, + (unsigned long)priv); + tasklet_init(&priv->irq_prepare_beacon_tasklet, + (void(*)(unsigned long))rtl8192_prepare_beacon, + (unsigned long)priv); +} + +short rtl8192_get_channel_map(struct net_device * dev) +{ + int i; + +#ifdef ENABLE_DOT11D + struct r8192_priv *priv = rtllib_priv(dev); + if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) + && (priv->rf_chip != RF_6052)) { + RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel map\n", __func__); + return -1; + } + + if (priv->ChannelPlan > COUNTRY_CODE_MAX) { + printk("rtl819x_init:Error channel plan! Set to default.\n"); + priv->ChannelPlan= COUNTRY_CODE_FCC; + } + RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); + Dot11d_Init(priv->rtllib); +#ifndef CONFIG_CRDA + Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); +#endif +#else + struct r8192_priv *priv = rtllib_priv(dev); + int ch; + if (!channels){ + DMESG("No channels, aborting"); + return -1; + } + + ch = channels; + priv->ChannelPlan = 0; + for (i = 1; i <= 14; i++) { + (priv->rtllib->channel_map)[i] = (u8)(ch & 0x01); + ch >>= 1; + } + priv->rtllib->IbssStartChnl= 10; + priv->rtllib->ibss_maxjoin_chal = 11; +#endif + for (i = 1; i <= 11; i++) { + (priv->rtllib->active_channel_map)[i] = 1; + } + (priv->rtllib->active_channel_map)[12] = 2; + (priv->rtllib->active_channel_map)[13] = 2; + + return 0; +} + +short rtl8192_init(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + memset(&(priv->stats),0,sizeof(struct Stats)); +#ifdef CONFIG_MP + rtl8192_init_mp(dev); +#endif + + rtl8192_dbgp_flag_init(dev); + + rtl8192_init_priv_handler(dev); + rtl8192_init_priv_constant(dev); + rtl8192_init_priv_variable(dev); + rtl8192_init_priv_lock(priv); + rtl8192_init_priv_task(dev); + priv->ops->get_eeprom_size(dev); + priv->ops->init_adapter_variable(dev); + rtl8192_get_channel_map(dev); + +#ifdef CONFIG_CFG_80211 + /* channel map setting for the cfg80211 style */ + { + struct r8192_priv* priv = rtllib_priv(dev); + rtllib_set_geo(priv); + } +#endif + + init_hal_dm(dev); + +#if defined RTL8192SE || defined RTL8192CE + InitSwLeds(dev); +#endif + init_timer(&priv->watch_dog_timer); + setup_timer(&priv->watch_dog_timer, + watch_dog_timer_callback, + (unsigned long) dev); + + init_timer(&priv->gpio_polling_timer); + setup_timer(&priv->gpio_polling_timer, + check_rfctrl_gpio_timer, + (unsigned long)dev); + + rtl8192_irq_disable(dev); +#if defined(IRQF_SHARED) + if (request_irq(dev->irq, (void*)rtl8192_interrupt_rsl, IRQF_SHARED, dev->name, dev)) +#else + if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, SA_SHIRQ, dev->name, dev)) +#endif + { + printk("Error allocating IRQ %d",dev->irq); + return -1; + } else { + priv->irq=dev->irq; + RT_TRACE(COMP_INIT, "IRQ %d\n",dev->irq); + } + + if (rtl8192_pci_initdescring(dev) != 0) { + printk("Endopoints initialization failed"); + return -1; + } + + return 0; +} + +#if defined CONFIG_ASPM_OR_D3 +static void +rtl8192_update_default_setting(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + pPSC->RegRfPsLevel = 0; + priv->bSupportASPM = 0; + + + pPSC->RegAMDPciASPM = priv->RegAMDPciASPM ; + switch (priv->RegPciASPM) + { + case 0: + break; + + case 1: + pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; + break; + + case 2: + pPSC->RegRfPsLevel |= (RT_RF_LPS_LEVEL_ASPM | RT_RF_OFF_LEVL_CLK_REQ); + break; + + case 3: + pPSC->RegRfPsLevel &= ~(RT_RF_LPS_LEVEL_ASPM); + pPSC->RegRfPsLevel |= (RT_RF_PS_LEVEL_ALWAYS_ASPM | RT_RF_OFF_LEVL_CLK_REQ); + break; + + case 4: + pPSC->RegRfPsLevel &= ~(RT_RF_LPS_LEVEL_ASPM | RT_RF_OFF_LEVL_CLK_REQ); + pPSC->RegRfPsLevel |= RT_RF_PS_LEVEL_ALWAYS_ASPM; + break; + } + + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; + + switch (priv->RegHwSwRfOffD3) + { + case 1: + if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; + break; + + case 2: + if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; + break; + + case 3: + pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_PCI_D3; + break; + } + + + switch (priv->RegSupportPciASPM) + { + case 0: + { + bool bSupportASPM = false; + priv->bSupportASPM = bSupportASPM; + } + break; + + case 1: + { + bool bSupportASPM = true; + priv->bSupportASPM = bSupportASPM; + } + break; + + case 2: + if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_INTEL) + { + bool bSupportASPM = true; + priv->bSupportASPM = bSupportASPM; + } + break; + + default: + break; + } +} +#endif + +#if defined CONFIG_ASPM_OR_D3 +static void +rtl8192_initialize_adapter_common(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + rtl8192_update_default_setting(dev); + +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_PS_LEVEL_ALWAYS_ASPM) + { + RT_ENABLE_ASPM(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_PS_LEVEL_ALWAYS_ASPM); + } +#endif +} +#endif + +/*************************************************************************** + -------------------------------WATCHDOG STUFF--------------------------- +***************************************************************************/ +short rtl8192_is_tx_queue_empty(struct net_device *dev) +{ + int i=0; + struct r8192_priv *priv = rtllib_priv(dev); + for (i=0; i<=MGNT_QUEUE; i++) + { + if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) + continue; + if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ + printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); + return 0; + } + } + return 1; +} + +RESET_TYPE +rtl819x_TxCheckStuck(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 QueueID; + u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + bool bCheckFwTxCnt = false; + struct rtl8192_tx_ring *ring = NULL; + struct sk_buff* skb = NULL; + cb_desc * tcb_desc = NULL; + unsigned long flags = 0; + + switch (priv->rtllib->ps) + { + case RTLLIB_PS_DISABLED: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; + break; + case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; + default: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; + } + spin_lock_irqsave(&priv->irq_th_lock,flags); + for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) + { + if (QueueID == TXCMD_QUEUE) + continue; + + if (QueueID == BEACON_QUEUE) + continue; + + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) + continue; + else + { + skb = (&ring->queue)->next; + tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc->nStuckCount++; + bCheckFwTxCnt = true; + if (tcb_desc->nStuckCount > 1) + printk("%s: QueueID=%d tcb_desc->nStuckCount=%d\n",__func__,QueueID,tcb_desc->nStuckCount); +#if defined RTL8192SE || defined RTL8192CE + if (tcb_desc->nStuckCount > ResetThreshold) + { + RT_TRACE( COMP_RESET, "TxCheckStuck(): Need silent reset because nStuckCount > ResetThreshold.\n" ); + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + return RESET_TYPE_SILENT; + } + bCheckFwTxCnt = false; + #endif + } + } + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + + if (bCheckFwTxCnt) { + if (priv->ops->TxCheckStuckHandler(dev)) + { + RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n"); + return RESET_TYPE_SILENT; + } + } + + return RESET_TYPE_NORESET; +} + +RESET_TYPE rtl819x_RxCheckStuck(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->ops->RxCheckStuckHandler(dev)) + { + RT_TRACE(COMP_RESET, "RxStuck Condition\n"); + return RESET_TYPE_SILENT; + } + + return RESET_TYPE_NORESET; +} + +RESET_TYPE +rtl819x_ifcheck_resetornot(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + RESET_TYPE TxResetType = RESET_TYPE_NORESET; + RESET_TYPE RxResetType = RESET_TYPE_NORESET; + RT_RF_POWER_STATE rfState; + + rfState = priv->rtllib->eRFPowerState; + + if (rfState == eRfOn) + TxResetType = rtl819x_TxCheckStuck(dev); + + if ( rfState == eRfOn && + (priv->rtllib->iw_mode == IW_MODE_INFRA) && + (priv->rtllib->state == RTLLIB_LINKED)) { + + RxResetType = rtl819x_RxCheckStuck(dev); + } + + if (TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL){ + printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + return RESET_TYPE_NORMAL; + } else if (TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){ + printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + return RESET_TYPE_SILENT; + } else { + return RESET_TYPE_NORESET; + } + +} + +void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) +{ +} + +void rtl819x_ifsilentreset(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 reset_times = 0; + int reset_status = 0; + struct rtllib_device *ieee = priv->rtllib; + unsigned long flag; + + u8 IsPortal = 0; + + + if (priv->ResetProgress==RESET_TYPE_NORESET) { + + RT_TRACE(COMP_RESET,"=========>Reset progress!! \n"); + + priv->ResetProgress = RESET_TYPE_SILENT; + + spin_lock_irqsave(&priv->rf_ps_lock,flag); + if (priv->RFChangeInProgress) + { + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + goto END; + } + priv->RFChangeInProgress = true; + priv->bResetInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + +RESET_START: + + down(&priv->wx_sem); + + if (priv->rtllib->state == RTLLIB_LINKED) + LeisurePSLeave(dev); + + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__func__); + up(&priv->wx_sem); + return ; + } + priv->up = 0; + + RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__func__); + mdelay(1000); + RT_TRACE(COMP_RESET,"%s():111111111111111111111111======>start to down the driver\n",__func__); + + if (!netif_queue_stopped(dev)) + netif_stop_queue(dev); + + rtl8192_irq_disable(dev); + del_timer_sync(&priv->watch_dog_timer); + rtl8192_cancel_deferred_work(priv); + deinit_hal_dm(dev); + rtllib_stop_scan_syncro(ieee); + + if (ieee->state == RTLLIB_LINKED) { + SEM_DOWN_IEEE_WX(&ieee->wx_sem); + printk("ieee->state is RTLLIB_LINKED\n"); + rtllib_stop_send_beacons(priv->rtllib); + del_timer_sync(&ieee->associate_timer); + cancel_delayed_work(&ieee->associate_retry_wq); + rtllib_stop_scan(ieee); + netif_carrier_off(dev); + SEM_UP_IEEE_WX(&ieee->wx_sem); + } else { + printk("ieee->state is NOT LINKED\n"); + rtllib_softmac_stop_protocol(priv->rtllib, 0 ,true); + } + +#if !(defined RTL8192SE || defined RTL8192CE) + dm_backup_dynamic_mechanism_state(dev); +#endif + +#ifdef RTL8190P + priv->ops->stop_adapter(dev, true); +#endif + + up(&priv->wx_sem); + RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); + + RT_TRACE(COMP_RESET,"%s():<===========up process start\n",__func__); + reset_status = _rtl8192_up(dev,true); + + RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__func__); + if (reset_status == -1) { + if (reset_times < 3) { + reset_times++; + goto RESET_START; + } else { + RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n",__func__); + } + } + + ieee->is_silent_reset = 1; + + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + + EnableHWSecurityConfig8192(dev); + + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + + queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); + + } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->link_change(ieee->dev); + + notify_wx_assoc_event(ieee); + + rtllib_start_send_beacons(ieee); + + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + netif_carrier_on(ieee->dev); + } else if (ieee->iw_mode == IW_MODE_MESH) { + rtl819x_silentreset_mesh_bk(dev, IsPortal); + } + + CamRestoreAllEntry(dev); +#if !(defined RTL8192SE || defined RTL8192CE) + dm_restore_dynamic_mechanism_state(dev); +#endif +END: + priv->ResetProgress = RESET_TYPE_NORESET; + priv->reset_count++; + + priv->bForcedSilentReset =false; + priv->bResetInProgress = false; + +#if !(defined RTL8192SE || defined RTL8192CE) + write_nic_byte(dev, UFWP, 1); +#endif + RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); + } +} + +void rtl819x_update_rxcounts(struct r8192_priv *priv, + u32 *TotalRxBcnNum, + u32 *TotalRxDataNum) +{ + u16 SlotIndex; + u8 i; + + *TotalRxBcnNum = 0; + *TotalRxDataNum = 0; + + SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++)%(priv->rtllib->LinkDetectInfo.SlotNum); + priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; + priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; + for (i = 0; i < priv->rtllib->LinkDetectInfo.SlotNum; i++) { + *TotalRxBcnNum += priv->rtllib->LinkDetectInfo.RxBcnNum[i]; + *TotalRxDataNum += priv->rtllib->LinkDetectInfo.RxDataNum[i]; + } +} + + +void rtl819x_watchdog_wqcallback(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,watch_dog_wq); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + struct rtllib_device* ieee = priv->rtllib; + RESET_TYPE ResetType = RESET_TYPE_NORESET; + static u8 check_reset_cnt = 0; + unsigned long flags; + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + bool bBusyTraffic = false; + bool bHigherBusyTraffic = false; + bool bHigherBusyRxTraffic = false; + bool bEnterPS = false; + + if (IS_NIC_DOWN(priv) || (priv->bHwRadioOff == true)) + return; + + if (priv->rtllib->state >= RTLLIB_LINKED) { + if (priv->rtllib->CntAfterLink<2) + priv->rtllib->CntAfterLink++; + } else { + priv->rtllib->CntAfterLink = 0; + } + + hal_dm_watchdog(dev); + + if (rtllib_act_scanning(priv->rtllib,false) == false){ + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) &&\ + (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\ + (!ieee->proto_stoppping) && !ieee->wx_set_enc +#ifdef CONFIG_RTLWIFI_DEBUGFS + && (!priv->debug->hw_holding) +#endif + ){ + if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE)&& + (!ieee->bNetPromiscuousMode)) + { + RT_TRACE(COMP_PS, "====================>haha:IPSEnter()\n"); + IPSEnter(dev); + } + } + } + { + if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) + { + if ( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || + ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { + bBusyTraffic = true; + } + + + if ( ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 4000 ) + { + bHigherBusyTraffic = true; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) + bHigherBusyRxTraffic = true; + else + bHigherBusyRxTraffic = false; + } + + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS= false; + else + bEnterPS= true; + + if (ieee->current_network.beacon_interval < 95) + bEnterPS= false; + + if (bEnterPS) + LeisurePSEnter(dev); + else + LeisurePSLeave(dev); + + } else { + RT_TRACE(COMP_LPS,"====>no link LPS leave\n"); + LeisurePSLeave(dev); + } + + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + + ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + + } + + { +#if defined RTL8192SE + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + IbssAgeFunction(ieee); +#endif + + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) + { + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; + + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + + if ((TotalRxBcnNum+TotalRxDataNum) == 0) + priv->check_roaming_cnt ++; + else + priv->check_roaming_cnt = 0; + + + if (priv->check_roaming_cnt > 0) + { + if ( ieee->eRFPowerState == eRfOff) + RT_TRACE(COMP_ERR,"========>%s()\n",__func__); + + printk("===>%s(): AP is power off,chan:%d, connect another one\n",__func__, priv->chan); + + ieee->state = RTLLIB_ASSOCIATING; + + RemovePeerTS(priv->rtllib,priv->rtllib->current_network.bssid); + ieee->is_roaming = true; + ieee->is_set_key = false; + ieee->link_change(dev); + if (ieee->LedControlHandler) + ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + + notify_wx_assoc_event(ieee); + + if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + + priv->check_roaming_cnt = 0; + } + } + ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; + ieee->LinkDetectInfo.NumRecvDataInPeriod=0; + + } + + spin_lock_irqsave(&priv->tx_lock,flags); + if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) && + (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) + { + ResetType = rtl819x_ifcheck_resetornot(dev); + check_reset_cnt = 3; + } + spin_unlock_irqrestore(&priv->tx_lock,flags); + + if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) + { + priv->ResetProgress = RESET_TYPE_NORMAL; + RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__func__); + return; + } + + if ( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) + { + rtl819x_ifsilentreset(dev); + } + priv->force_reset = false; + priv->bForcedSilentReset = false; + priv->bResetInProgress = false; + RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); +} + +void watch_dog_timer_callback(unsigned long data) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *) data); + queue_delayed_work_rsl(priv->priv_wq,&priv->watch_dog_wq,0); + mod_timer(&priv->watch_dog_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); +} + +/**************************************************************************** + ---------------------------- NIC TX/RX STUFF--------------------------- +*****************************************************************************/ +void rtl8192_rx_enable(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->ops->rx_enable(dev); +} + +void rtl8192_tx_enable(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + priv->ops->tx_enable(dev); + + rtllib_reset_queue(priv->rtllib); +} + + +static void rtl8192_free_rx_ring(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int i,rx_queue_idx; + + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (i = 0; i < priv->rxringcount; i++) { + struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i]; + if (!skb) + continue; + + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } + + pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, + priv->rx_ring[rx_queue_idx], priv->rx_ring_dma[rx_queue_idx]); + priv->rx_ring[rx_queue_idx] = NULL; + } +} + +static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + while (skb_queue_len(&ring->queue)) { + tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + + pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; +} + +void rtl8192_data_hard_stop(struct net_device *dev) +{ +} + + +void rtl8192_data_hard_resume(struct net_device *dev) +{ +} + +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + int ret; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + u8 queue_index = tcb_desc->queue_index; + + if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || priv->bResetInProgress){ + kfree_skb(skb); + return; + } + + assert(queue_index != TXCMD_QUEUE); + + + memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + skb_push(skb, priv->rtllib->tx_headroom); + ret = rtl8192_tx(dev, skb); + if (ret != 0) { + kfree_skb(skb); + }; + + if (queue_index!=MGNT_QUEUE) { + priv->rtllib->stats.tx_bytes+=(skb->len - priv->rtllib->tx_headroom); + priv->rtllib->stats.tx_packets++; + } + + + return; +} + +int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + int ret; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + u8 queue_index = tcb_desc->queue_index; + + if (queue_index != TXCMD_QUEUE){ + if ((priv->rtllib->eRFPowerState == eRfOff) ||IS_NIC_DOWN(priv) || priv->bResetInProgress){ + kfree_skb(skb); + return 0; + } + } + + memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + if (queue_index == TXCMD_QUEUE) { + rtl8192_tx_cmd(dev, skb); + ret = 0; + return ret; + } else { + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + tcb_desc->bTxEnableFwCalcDur = 1; + skb_push(skb, priv->rtllib->tx_headroom); + ret = rtl8192_tx(dev, skb); + if (ret != 0) { + kfree_skb(skb); + }; + } + + + + return ret; + +} + +void rtl8192_tx_isr(struct net_device *dev, int prio) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + + while (skb_queue_len(&ring->queue)) { + tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb; + + if (prio != BEACON_QUEUE) { + if (entry->OWN) + return; + ring->idx = (ring->idx + 1) % ring->entries; + } + + skb = __skb_dequeue(&ring->queue); + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + + kfree_skb(skb); + } + if (prio != BEACON_QUEUE) { + tasklet_schedule(&priv->irq_tx_tasklet); + } + +} + +void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring; + tx_desc_cmd* entry; + unsigned int idx; + cb_desc *tcb_desc; + unsigned long flags; + + spin_lock_irqsave(&priv->irq_th_lock,flags); + ring = &priv->tx_ring[TXCMD_QUEUE]; + + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + entry = (tx_desc_cmd*) &ring->desc[idx]; + + tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + + priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); + + __skb_queue_tail(&ring->queue, skb); + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + + return; +} + +short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring; + unsigned long flags; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tx_desc *pdesc = NULL; + struct rtllib_hdr_1addr * header = NULL; + u16 fc=0, type=0,stype=0; + bool multi_addr=false,broad_addr=false,uni_addr=false; + u8* pda_addr = NULL; + int idx; + u32 fwinfo_size = 0; + + if (priv->bdisable_nic){ + RT_TRACE(COMP_ERR,"%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", __func__, skb->len, tcb_desc->queue_index); + return skb->len; + } + + priv->rtllib->bAwakePktSent = true; + +#if defined RTL8192SE || defined RTL8192CE + fwinfo_size = 0; +#else + fwinfo_size = sizeof(TX_FWINFO_8190PCI); +#endif + + header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); + fc = header->frame_ctl; + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + pda_addr = header->addr1; + + if (is_multicast_ether_addr(pda_addr)) + multi_addr = true; + else if (is_broadcast_ether_addr(pda_addr)) + broad_addr = true; + else { + uni_addr = true; + } + + if (uni_addr) + priv->stats.txbytesunicast += skb->len - fwinfo_size; + else if (multi_addr) + priv->stats.txbytesmulticast += skb->len - fwinfo_size; + else + priv->stats.txbytesbroadcast += skb->len - fwinfo_size; + + spin_lock_irqsave(&priv->irq_th_lock,flags); + ring = &priv->tx_ring[tcb_desc->queue_index]; + if (tcb_desc->queue_index != BEACON_QUEUE) { + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + } else { +#ifdef _ENABLE_SW_BEACON + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; +#else + idx = 0; +#endif + } + + pdesc = &ring->desc[idx]; + if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { + RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d, skblen = 0x%x queuelen=%d", \ + tcb_desc->queue_index,ring->idx, idx,skb->len, skb_queue_len(&ring->queue)); + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + return skb->len; + } + + if (tcb_desc->queue_index == MGNT_QUEUE){ + } + + if (type == RTLLIB_FTYPE_DATA){ + if (priv->rtllib->LedControlHandler) + priv->rtllib->LedControlHandler(dev, LED_CTL_TX); + } + priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, skb); + __skb_queue_tail(&ring->queue, skb); + pdesc->OWN = 1; + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + dev->trans_start = jiffies; + +#ifdef RTL8192CE + if (tcb_desc->queue_index == BEACON_QUEUE){ + write_nic_word(dev, REG_PCIE_CTRL_REG, BIT4); + }else{ + write_nic_word(dev, REG_PCIE_CTRL_REG, BIT0<<(tcb_desc->queue_index)); + } +#else + write_nic_word(dev,TPPoll,0x01<queue_index); +#endif + return 0; +} + +short rtl8192_alloc_rx_desc_ring(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + rx_desc *entry = NULL; + int i, rx_queue_idx; + + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + priv->rx_ring[rx_queue_idx] = pci_alloc_consistent(priv->pdev, + sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); + + if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { + RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); + return -ENOMEM; + } + + memset(priv->rx_ring[rx_queue_idx], 0, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount); + priv->rx_idx[rx_queue_idx] = 0; + + for (i = 0; i < priv->rxringcount; i++) { + struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); + dma_addr_t *mapping; + entry = &priv->rx_ring[rx_queue_idx][i]; + if (!skb) + return 0; + skb->dev = dev; + priv->rx_buf[rx_queue_idx][i] = skb; + mapping = (dma_addr_t *)skb->cb; + *mapping = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + + entry->BufferAddress = cpu_to_le32(*mapping); + + entry->Length = priv->rxbuffersize; + entry->OWN = 1; + } + + entry->EOR = 1; + } + return 0; +} + +static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, + unsigned int prio, unsigned int entries) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + tx_desc *ring; + dma_addr_t dma; + int i; + + ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + if (!ring || (unsigned long)ring & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); + return -ENOMEM; + } + + memset(ring, 0, sizeof(*ring)*entries); + priv->tx_ring[prio].desc = ring; + priv->tx_ring[prio].dma = dma; + priv->tx_ring[prio].idx = 0; + priv->tx_ring[prio].entries = entries; + skb_queue_head_init(&priv->tx_ring[prio].queue); + + for (i = 0; i < entries; i++) + ring[i].NextDescAddress = + cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); + + return 0; +} + + +short rtl8192_pci_initdescring(struct net_device *dev) +{ + u32 ret; + int i; + struct r8192_priv *priv = rtllib_priv(dev); + + ret = rtl8192_alloc_rx_desc_ring(dev); + if (ret) { + return ret; + } + + + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if ((ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount))) + goto err_free_rings; + } + + return 0; + +err_free_rings: + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + if (priv->tx_ring[i].desc) + rtl8192_free_tx_ring(dev, i); + return 1; +} + +void rtl8192_pci_resetdescring(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int i,rx_queue_idx; + unsigned long flags = 0; + + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + if (priv->rx_ring[rx_queue_idx]) { + rx_desc *entry = NULL; + for (i = 0; i < priv->rxringcount; i++) { + entry = &priv->rx_ring[rx_queue_idx][i]; + entry->OWN = 1; + } + priv->rx_idx[rx_queue_idx] = 0; + } + } + + spin_lock_irqsave(&priv->irq_th_lock,flags); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if (priv->tx_ring[i].desc) { + struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; + + while (skb_queue_len(&ring->queue)) { + tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } + spin_unlock_irqrestore(&priv->irq_th_lock,flags); +} + +void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + if (stats->bIsAMPDU && !stats->bFirstMPDU) { + stats->mac_time[0] = priv->LastRxDescTSFLow; + stats->mac_time[1] = priv->LastRxDescTSFHigh; + } else { + priv->LastRxDescTSFLow = stats->mac_time[0]; + priv->LastRxDescTSFHigh = stats->mac_time[1]; + } +} + +long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) +{ + long signal_power; + + signal_power = (long)((signal_strength_index + 1) >> 1); + signal_power -= 95; + + return signal_power; +} + + +void +rtl819x_update_rxsignalstatistics8190pci( + struct r8192_priv * priv, + struct rtllib_rx_stats * pprevious_stats + ) +{ + int weighting = 0; + + + if (priv->stats.recv_signal_power == 0) + priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; + + if (pprevious_stats->RecvSignalPower > priv->stats.recv_signal_power) + weighting = 5; + else if (pprevious_stats->RecvSignalPower < priv->stats.recv_signal_power) + weighting = (-5); + priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + pprevious_stats->RecvSignalPower + weighting) / 6; +} + +void +rtl819x_process_cck_rxpathsel( + struct r8192_priv * priv, + struct rtllib_rx_stats * pprevious_stats + ) +{ +#ifdef RTL8190P + char last_cck_adc_pwdb[4]={0,0,0,0}; + u8 i; + if (priv->rf_type == RF_2T4R && DM_RxPathSelTable.Enable) + { + if (pprevious_stats->bIsCCK && + (pprevious_stats->bPacketToSelf ||pprevious_stats->bPacketBeacon)) + { + if (priv->stats.cck_adc_pwdb.TotalNum++ >= PHY_RSSI_SLID_WIN_MAX) + { + priv->stats.cck_adc_pwdb.TotalNum = PHY_RSSI_SLID_WIN_MAX; + for (i=RF90_PATH_A; istats.cck_adc_pwdb.elements[i][priv->stats.cck_adc_pwdb.index]; + priv->stats.cck_adc_pwdb.TotalVal[i] -= last_cck_adc_pwdb[i]; + } + } + for (i=RF90_PATH_A; istats.cck_adc_pwdb.TotalVal[i] += pprevious_stats->cck_adc_pwdb[i]; + priv->stats.cck_adc_pwdb.elements[i][priv->stats.cck_adc_pwdb.index] = pprevious_stats->cck_adc_pwdb[i]; + } + priv->stats.cck_adc_pwdb.index++; + if (priv->stats.cck_adc_pwdb.index >= PHY_RSSI_SLID_WIN_MAX) + priv->stats.cck_adc_pwdb.index = 0; + + for (i=RF90_PATH_A; istats.cck_adc_pwdb.TotalVal[i]/priv->stats.cck_adc_pwdb.TotalNum; + } + + for (i=RF90_PATH_A; icck_adc_pwdb[i] > (char)priv->undecorated_smoothed_cck_adc_pwdb[i]) + { + priv->undecorated_smoothed_cck_adc_pwdb[i] = + ( (priv->undecorated_smoothed_cck_adc_pwdb[i]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->cck_adc_pwdb[i])) /(Rx_Smooth_Factor); + priv->undecorated_smoothed_cck_adc_pwdb[i] = priv->undecorated_smoothed_cck_adc_pwdb[i] + 1; + } + else + { + priv->undecorated_smoothed_cck_adc_pwdb[i] = + ( (priv->undecorated_smoothed_cck_adc_pwdb[i]*(Rx_Smooth_Factor-1)) + + (pprevious_stats->cck_adc_pwdb[i])) /(Rx_Smooth_Factor); + } + } + } + } +#endif +} + + +u8 rtl819x_query_rxpwrpercentage( + char antpower + ) +{ + if ((antpower <= -100) || (antpower >= 20)) + { + return 0; + } + else if (antpower >= 0) + { + return 100; + } + else + { + return (100+antpower); + } + +} /* QueryRxPwrPercentage */ + +u8 +rtl819x_evm_dbtopercentage( + char value + ) +{ + char ret_val; + + ret_val = value; + + if (ret_val >= 0) + ret_val = 0; + if (ret_val <= -33) + ret_val = -33; + ret_val = 0 - ret_val; + ret_val*=3; + if (ret_val == 99) + ret_val = 100; + return(ret_val); +} + +void +rtl8192_record_rxdesc_forlateruse( + struct rtllib_rx_stats * psrc_stats, + struct rtllib_rx_stats * ptarget_stats +) +{ + ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; + ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; +} + + + +void rtl8192_rx_normal(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_hdr_1addr *rtllib_hdr = NULL; + bool unicast_packet = false; + bool bLedBlinking=true; + u16 fc=0, type=0; + u32 skb_len = 0; + int rx_queue_idx = RX_MPDU_QUEUE; + + struct rtllib_rx_stats stats = { + .signal = 0, + .noise = -98, + .rate = 0, + .freq = RTLLIB_24GHZ_BAND, + }; + unsigned int count = priv->rxringcount; + + stats.nic_type = NIC_8192E; + + while (count--) { + rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + + if (pdesc->OWN){ + return; + } else { + + struct sk_buff *new_skb = NULL; + if (!priv->ops->rx_query_status_descriptor(dev, &stats, pdesc, skb)) + goto done; + + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); + + skb_put(skb, pdesc->Length); + skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); + skb_trim(skb, skb->len - 4/*sCrcLng*/); + rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; + if (is_broadcast_ether_addr(rtllib_hdr->addr1)) { + }else if (is_multicast_ether_addr(rtllib_hdr->addr1)){ + }else { + /* unicast packet */ + unicast_packet = true; + } + fc = le16_to_cpu(rtllib_hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + if (type == RTLLIB_FTYPE_MGMT) + { + bLedBlinking = false; + } + if (bLedBlinking) + if (priv->rtllib->LedControlHandler) + priv->rtllib->LedControlHandler(dev, LED_CTL_RX); + + if (stats.bCRC) { + if (type != RTLLIB_FTYPE_MGMT) + priv->stats.rxdatacrcerr ++; + else + priv->stats.rxmgmtcrcerr ++; + } + + skb_len = skb->len; + +#ifdef RTL8192CE + if (!stats.bCRC) +#else + if (1) +#endif + { + if (!rtllib_rx(priv->rtllib, skb, &stats)){ + dev_kfree_skb_any(skb); + } else { + priv->stats.rxok++; + if (unicast_packet) { + priv->stats.rxbytesunicast += skb_len; + } + } + }else{ + dev_kfree_skb_any(skb); + } +#if 1 + new_skb = dev_alloc_skb(priv->rxbuffersize); + if (unlikely(!new_skb)) + { + printk("==========>can't alloc skb for rx\n"); + goto done; + } + skb=new_skb; + skb->dev = dev; +#endif + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + + } +done: + pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); + pdesc->OWN = 1; + pdesc->Length = priv->rxbuffersize; + if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) + pdesc->EOR = 1; + priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; + } + +} + +void rtl8192_rx_cmd(struct net_device *dev) +{ +#ifdef RTL8192SE + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + unsigned int count = priv->rxringcount; + int rx_queue_idx = RX_CMD_QUEUE; + + struct rtllib_rx_stats stats = { + .signal = 0, + .noise = -98, + .rate = 0, + .freq = RTLLIB_24GHZ_BAND, + }; + stats.nic_type = NIC_8192E; + + while (count--) { + rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + + if (pdesc->OWN){ + return; + } else { + struct sk_buff *new_skb = NULL; + + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); + + skb_put(skb, pdesc->Length); + + if (pdesc->MACID == 0x1e) { + + pdesc->Length = pdesc->Length - 32; + pdesc->DrvInfoSize = 4; + printk(">>>>%s()CMD PKT RX, beacon_len:%d payload_len:%d\n",__func__, pdesc->Length,skb->len); + + + priv->ops->rx_query_status_descriptor(dev, &stats, pdesc, skb); + skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); + } + + skb_trim(skb, skb->len - 4/*sCrcLng*/); + + if (pdesc->MACID == 0x1e){ + if (!rtllib_rx(priv->rtllib, skb, &stats)){ + dev_kfree_skb_any(skb); + } + }else{ + if (priv->ops->rx_command_packet_handler != NULL) + priv->ops->rx_command_packet_handler(dev, skb, pdesc); + dev_kfree_skb_any(skb); + } + + + new_skb = dev_alloc_skb(priv->rxbuffersize); + if (unlikely(!new_skb)) + { + printk("==========>can't alloc skb for rx\n"); + goto done; + } + skb=new_skb; + skb->dev = dev; + + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + + } +done: + pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); + pdesc->OWN = 1; + pdesc->Length = priv->rxbuffersize; + if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) + pdesc->EOR = 1; + priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; + } +#endif +} + + +void rtl8192_tx_resume(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + struct sk_buff *skb; + int queue_index; + + for (queue_index = BK_QUEUE; queue_index < MAX_QUEUE_SIZE;queue_index++) { + while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&& + (priv->rtllib->check_nic_enough_desc(dev,queue_index) > 0)) { + skb = skb_dequeue(&ieee->skb_waitQ[queue_index]); + ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/); + } + } +} + +void rtl8192_irq_tx_tasklet(struct r8192_priv *priv) +{ + rtl8192_tx_resume(priv->rtllib->dev); +} + +void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) +{ + rtl8192_rx_normal(priv->rtllib->dev); + + if (MAX_RX_QUEUE > 1) + rtl8192_rx_cmd(priv->rtllib->dev); + +#ifndef RTL8192CE + write_nic_dword(priv->rtllib->dev, INTA_MASK,read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); +#endif +} + +/**************************************************************************** + ---------------------------- NIC START/CLOSE STUFF--------------------------- +*****************************************************************************/ +void rtl8192_cancel_deferred_work(struct r8192_priv* priv) +{ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + cancel_delayed_work(&priv->watch_dog_wq); + cancel_delayed_work(&priv->update_beacon_wq); +#ifndef RTL8190P + cancel_delayed_work(&priv->rtllib->hw_sleep_wq); +#endif +#if defined RTL8192SE + cancel_delayed_work(&priv->check_hw_scan_wq); + cancel_delayed_work(&priv->hw_scan_simu_wq); + cancel_delayed_work(&priv->start_hw_scan_wq); + cancel_delayed_work(&priv->rtllib->update_assoc_sta_info_wq); + cancel_delayed_work(&priv->rtllib->check_tsf_wq); +#endif +#endif + +#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,22) + cancel_work_sync(&priv->reset_wq); + cancel_work_sync(&priv->qos_activate); +#elif ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))) + cancel_delayed_work(&priv->reset_wq); + cancel_delayed_work(&priv->qos_activate); +#if defined RTL8192SE + cancel_delayed_work(&priv->rtllib->update_assoc_sta_info_wq); + cancel_delayed_work(&priv->rtllib->check_tsf_wq); +#endif +#endif + +} + +int _rtl8192_up(struct net_device *dev,bool is_silent_reset) +{ + if (_rtl8192_sta_up(dev, is_silent_reset) == -1) + return -1; + return 0; +} + + +int rtl8192_open(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int ret; + + down(&priv->wx_sem); + ret = rtl8192_up(dev); + up(&priv->wx_sem); + return ret; + +} + + +int rtl8192_up(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->up == 1) return -1; + return _rtl8192_up(dev,false); +} + + +int rtl8192_close(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int ret; + + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + rtllib_stop_scan(priv->rtllib); + } + + down(&priv->wx_sem); + + ret = rtl8192_down(dev,true); + + up(&priv->wx_sem); + + return ret; + +} + +int rtl8192_down(struct net_device *dev, bool shutdownrf) +{ +#ifdef CONFIG_MP + struct r8192_priv *priv = rtllib_priv(dev); +#endif + + if (rtl8192_sta_down(dev, shutdownrf) == -1) + return -1; + +#ifdef CONFIG_MP + if (priv->bCckContTx) { + RT_TRACE(COMP_DBG, "####RTL819X MP####stop single cck continious TX\n"); + mpt_StopCckCoNtTx(dev); + } + if (priv->bOfdmContTx) { + RT_TRACE(COMP_DBG, "####RTL819X MP####stop single ofdm continious TX\n"); + mpt_StopOfdmContTx(dev); + } + if (priv->bSingleCarrier) { + RT_TRACE(COMP_DBG, "####RTL819X MP####stop single carrier mode\n"); + MPT_ProSetSingleCarrier(dev, false); + } +#endif + return 0; +} + +void rtl8192_commit(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->up == 0) return ; + rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); + rtl8192_irq_disable(dev); + priv->ops->stop_adapter(dev, true); + _rtl8192_up(dev,false); +} + +void rtl8192_restart(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, reset_wq); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + + down(&priv->wx_sem); + + rtl8192_commit(dev); + + up(&priv->wx_sem); +} + +static void r8192_set_multicast(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + short promisc; + + + + promisc = (dev->flags & IFF_PROMISC) ? 1:0; + + if (promisc != priv->promisc) { + ; + } + + priv->promisc = promisc; + +} + + +int r8192_set_mac_adr(struct net_device *dev, void *mac) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct sockaddr *addr = mac; + + down(&priv->wx_sem); + + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) + schedule_work(&priv->reset_wq); +#else + schedule_task(&priv->reset_wq); +#endif + up(&priv->wx_sem); + + return 0; +} + +/* based on ipw2200 driver */ +int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct iwreq *wrq = (struct iwreq *)rq; + int ret=-1; + struct rtllib_device *ieee = priv->rtllib; + u32 key[4]; + u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 zero_addr[6] = {0}; + struct iw_point *p = &wrq->u.data; + + down(&priv->wx_sem); + + switch (cmd) { + case RTL_IOCTL_WPA_SUPPLICANT: + { + struct ieee_param *ipw = NULL; + if (p->length < sizeof(struct ieee_param) || !p->pointer){ + ret = -EINVAL; + goto out; + } + + ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); + if (ipw == NULL){ + ret = -ENOMEM; + goto out; + } + if (copy_from_user(ipw, p->pointer, p->length)) { + kfree(ipw); + ret = -EFAULT; + goto out; + } + + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) + { + if (ipw->u.crypt.set_tx) + { + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) + { + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = KEY_TYPE_WEP40; + } + else + ieee->pairwise_key_type = KEY_TYPE_NA; + + if (ieee->pairwise_key_type) + { + if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0) + ieee->iw_mode = IW_MODE_ADHOC; + + memcpy((u8*)key, ipw->u.crypt.key, 16); + EnableHWSecurityConfig8192(dev); + set_swcam(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); + setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); + if (ieee->iw_mode == IW_MODE_ADHOC){ + set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); + setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); + } + } +#ifdef RTL8192E + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ + write_nic_byte(dev, 0x173, 1); + } +#endif + + } + else + { + memcpy((u8*)key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type= KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) + { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = KEY_TYPE_WEP40; + } + else + ieee->group_key_type = KEY_TYPE_NA; + + if (ieee->group_key_type) + { + set_swcam( dev, + ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, + 0, + key, + 0); + setKey( dev, + ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, + 0, + key); + } + } + } +#ifdef JOHN_DEBUG + { + int i; + RT_TRACE(COMP_DBG, "@@ wrq->u pointer = "); + for (i=0;iu.data.length;i++){ + if (i%10==0) RT_TRACE(COMP_DBG, "\n"); + RT_TRACE(COMP_DBG, "%8x|", ((u32*)wrq->u.data.pointer)[i] ); + } + RT_TRACE(COMP_DBG, "\n"); + } +#endif + ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, 0); + kfree(ipw); + break; + } + default: + ret = -EOPNOTSUPP; + break; + } + +out: + up(&priv->wx_sem); + + return ret; +} + +void FairBeacon(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_network *net = &priv->rtllib->current_network; + static u8 i=100; + static u8 forceturn =0; + u16 beaconint = net->beacon_interval; + + if (priv->rtllib->iw_mode != IW_MODE_ADHOC) + return; + + if (priv->bIbssCoordinator){ + i--; + + if (forceturn ==2){ + forceturn =0; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); + i=100; + } + + if (i<=94){ + beaconint=beaconint+2; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); + forceturn =1; + } + } else { + i++; + + if (forceturn ==1){ + forceturn =0; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); + i=100; + } + + if (i>=106){ + beaconint=beaconint-2; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); + forceturn =2; + } + } +} + + +irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) +{ + struct net_device *dev = (struct net_device *) netdev; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + unsigned long flags; + u32 inta; + u32 intb; + intb = 0; + + if (priv->irq_enabled == 0){ + goto done; + } + + spin_lock_irqsave(&priv->irq_th_lock,flags); + + priv->ops->interrupt_recognized(dev, &inta, &intb); + priv->stats.shints++; + + if (!inta) { + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + goto done; + } + + if (inta == 0xffff) { + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + goto done; + } + + priv->stats.ints++; + + if (!netif_running(dev)) { + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + goto done; + } + +#if defined RTL8192SE + if (intb & IMR_TBDOK){ + RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + priv->stats.txbeaconokint++; + priv->bIbssCoordinator = true; + } + + if (intb & IMR_TBDER){ + RT_TRACE(COMP_INTR, "beacon error interrupt!\n"); + priv->stats.txbeaconerr++; + priv->bIbssCoordinator = false; + } + + if ((intb & IMR_TBDOK) ||(intb & IMR_TBDER)) + FairBeacon(dev); +#else + if (inta & IMR_TBDOK){ + RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + priv->stats.txbeaconokint++; + } + + if (inta & IMR_TBDER){ + RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + priv->stats.txbeaconerr++; + } +#endif + + if (inta & IMR_BDOK) { + RT_TRACE(COMP_INTR, "beacon interrupt!\n"); +#ifdef _ENABLE_SW_BEACON + rtl8192_tx_isr(dev, BEACON_QUEUE); +#endif + } + + if (inta & IMR_MGNTDOK ) { + RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); + priv->stats.txmanageokint++; + rtl8192_tx_isr(dev,MGNT_QUEUE); + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + if (priv->rtllib->ack_tx_to_ieee){ + if (rtl8192_is_tx_queue_empty(dev)){ + priv->rtllib->ack_tx_to_ieee = 0; + rtllib_ps_tx_ack(priv->rtllib, 1); + } + } + spin_lock_irqsave(&priv->irq_th_lock,flags); + } + +#ifndef RTL8192CE + if (inta & IMR_COMDOK) { + priv->stats.txcmdpktokint++; + rtl8192_tx_isr(dev,TXCMD_QUEUE); + } +#endif + + if (inta & IMR_HIGHDOK) { + rtl8192_tx_isr(dev,HIGH_QUEUE); + } + +#ifdef RTL8192SE + if ((inta & IMR_ROK) || (inta & IMR_RXCMDOK)) +#else + if (inta & IMR_ROK) +#endif + { + priv->stats.rxint++; + priv->InterruptLog.nIMR_ROK++; + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_BcnInt) { + RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); +#ifndef _ENABLE_SW_BEACON + tasklet_schedule(&priv->irq_prepare_beacon_tasklet); +#endif + } + + if (inta & IMR_RDU) { + RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); + priv->stats.rxrdu++; +#ifndef RTL8192CE + write_nic_dword(dev,INTA_MASK,read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); +#endif + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_RXFOVW) { + RT_TRACE(COMP_INTR, "rx overflow !\n"); + priv->stats.rxoverflow++; + tasklet_schedule(&priv->irq_rx_tasklet); + } + + if (inta & IMR_TXFOVW) priv->stats.txoverflow++; + + if (inta & IMR_BKDOK) { + RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); + priv->stats.txbkokint++; + priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(dev,BK_QUEUE); + } + + if (inta & IMR_BEDOK) { + RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); + priv->stats.txbeokint++; + priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(dev,BE_QUEUE); + } + + if (inta & IMR_VIDOK) { + RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); + priv->stats.txviokint++; + priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(dev,VI_QUEUE); + } + + if (inta & IMR_VODOK) { + priv->stats.txvookint++; + RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n"); + priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; + rtl8192_tx_isr(dev,VO_QUEUE); + } + + spin_unlock_irqrestore(&priv->irq_th_lock,flags); + +done: + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + return; +#else + return IRQ_HANDLED; +#endif +} + + + +/**************************************************************************** + ---------------------------- PCI_STUFF--------------------------- +*****************************************************************************/ +#ifdef HAVE_NET_DEVICE_OPS +static const struct net_device_ops rtl8192_netdev_ops = { + .ndo_open = rtl8192_open, + .ndo_stop = rtl8192_close, + .ndo_tx_timeout = rtl8192_tx_timeout, + .ndo_do_ioctl = rtl8192_ioctl, + .ndo_set_multicast_list = r8192_set_multicast, + .ndo_set_mac_address = r8192_set_mac_adr, + .ndo_validate_addr = eth_validate_addr, + .ndo_change_mtu = eth_change_mtu, + .ndo_start_xmit = rtllib_xmit, +}; +#endif + +static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + unsigned long ioaddr = 0; + struct net_device *dev = NULL; + struct r8192_priv *priv= NULL; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); +#endif + +#ifdef CONFIG_RTL8192_IO_MAP + unsigned long pio_start, pio_len, pio_flags; +#else + unsigned long pmem_start, pmem_len, pmem_flags; +#endif + int err = 0; + bool bdma64 = false; + + RT_TRACE(COMP_INIT,"Configuring chip resources"); + + if ( pci_enable_device (pdev) ){ + RT_TRACE(COMP_ERR,"Failed to enable PCI device"); + return -EIO; + } + + pci_set_master(pdev); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL < (n)) -1)) +#endif + +#ifdef CONFIG_64BIT_DMA + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { + printk("RTL819xCE: Using 64bit DMA\n"); + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) { + printk( "Unable to obtain 64bit DMA for consistent allocations\n"); + pci_disable_device(pdev); + return -ENOMEM; + } + bdma64 = true; + } else +#endif + { + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + printk( "Unable to obtain 32bit DMA for consistent allocations\n"); + pci_disable_device(pdev); + return -ENOMEM; + } +#endif + } + } + dev = alloc_rtllib(sizeof(struct r8192_priv)); + if (!dev) + return -ENOMEM; + + if (bdma64){ + dev->features |= NETIF_F_HIGHDMA; + } + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) + SET_MODULE_OWNER(dev); +#endif + + pci_set_drvdata(pdev, dev); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + SET_NETDEV_DEV(dev, &pdev->dev); +#endif + priv = rtllib_priv(dev); + priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev); + priv->pdev=pdev; + priv->rtllib->pdev=pdev; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ + priv->rtllib->bSupportRemoteWakeUp = 1; + } else +#endif + { + priv->rtllib->bSupportRemoteWakeUp = 0; + } + +#ifdef CONFIG_RTL8192_IO_MAP + pio_start = (unsigned long)pci_resource_start (pdev, 0); + pio_len = (unsigned long)pci_resource_len (pdev, 0); + pio_flags = (unsigned long)pci_resource_flags (pdev, 0); + + if (!(pio_flags & IORESOURCE_IO)) { + RT_TRACE(COMP_ERR,"region #0 not a PIO resource, aborting"); + goto fail; + } + + printk("Io mapped space start: 0x%08lx \n", pio_start ); + if ( ! request_region( pio_start, pio_len, DRV_NAME ) ){ + RT_TRACE(COMP_ERR,"request_region failed!"); + goto fail; + } + + ioaddr = pio_start; + dev->base_addr = ioaddr; +#else +#ifdef RTL8192CE + pmem_start = pci_resource_start(pdev, 2); + pmem_len = pci_resource_len(pdev, 2); + pmem_flags = pci_resource_flags (pdev, 2); +#else + pmem_start = pci_resource_start(pdev, 1); + pmem_len = pci_resource_len(pdev, 1); + pmem_flags = pci_resource_flags (pdev, 1); +#endif + + if (!(pmem_flags & IORESOURCE_MEM)) { + RT_TRACE(COMP_ERR,"region #1 not a MMIO resource, aborting"); + goto fail; + } + + printk("Memory mapped space start: 0x%08lx \n", pmem_start); + if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { + RT_TRACE(COMP_ERR,"request_mem_region failed!"); + goto fail; + } + + + ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); + if ( ioaddr == (unsigned long)NULL ){ + RT_TRACE(COMP_ERR,"ioremap failed!"); + goto fail1; + } + + dev->mem_start = ioaddr; + dev->mem_end = ioaddr + pci_resource_len(pdev, 0); + +#endif +#if defined RTL8192SE || defined RTL8192CE + pci_write_config_byte(pdev, 0x81,0); + pci_write_config_byte(pdev,0x44,0); + pci_write_config_byte(pdev,0x04,0x06); + pci_write_config_byte(pdev,0x04,0x07); +#endif + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + priv->ops = ops; +#else +#if defined RTL8190P || defined RTL8192E + priv->ops = &rtl819xp_ops; +#else + priv->ops = &rtl8192se_ops; +#endif +#endif + + if (rtl8192_pci_findadapter(pdev, dev) == false) + goto fail1; + + dev->irq = pdev->irq; + priv->irq = 0; + +#ifdef HAVE_NET_DEVICE_OPS + dev->netdev_ops = &rtl8192_netdev_ops; +#else + dev->open = rtl8192_open; + dev->stop = rtl8192_close; + dev->tx_timeout = rtl8192_tx_timeout; + dev->do_ioctl = rtl8192_ioctl; + dev->set_multicast_list = r8192_set_multicast; + dev->set_mac_address = r8192_set_mac_adr; + dev->hard_start_xmit = rtllib_xmit; +#endif + +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 + dev->get_wireless_stats = r8192_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; +#endif +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + dev->ethtool_ops = &rtl819x_ethtool_ops; +#endif + + dev->type = ARPHRD_ETHER; + dev->watchdog_timeo = HZ*3; + + if (dev_alloc_name(dev, ifname) < 0){ + RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); + dev_alloc_name(dev, ifname); + } + + RT_TRACE(COMP_INIT, "Driver probe completed1\n"); + if (rtl8192_init(dev)!=0){ + RT_TRACE(COMP_ERR, "Initialization failed"); + goto fail1; + } + +#ifdef CONFIG_CFG_80211 + if (!rtl8192_register_wiphy_dev(dev)) + goto fail1; +#endif + + netif_carrier_off(dev); + netif_stop_queue(dev); + + register_netdev(dev); + RT_TRACE(COMP_INIT, "dev name: %s\n",dev->name); + err = rtl_debug_module_init(priv, dev->name); + if (err) { + RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring error: %d\n", err); + } + rtl8192_proc_init_one(dev); + +#ifdef ENABLE_GPIO_RADIO_CTL + if (priv->polling_timer_on == 0){ + check_rfctrl_gpio_timer((unsigned long)dev); + } +#endif +#ifdef CONFIG_RTL_RFKILL + if (priv->ops->init_before_adapter_start) { + priv->ops->init_before_adapter_start(dev); + priv->initialized_at_probe = true; + } + if (!rtl8192_rfkill_init(dev)) { + goto fail1; + } +#endif + +#if defined CONFIG_ASPM_OR_D3 + rtl8192_initialize_adapter_common(dev); +#endif + + RT_TRACE(COMP_INIT, "Driver probe completed\n"); + return 0; + +fail1: +#ifdef CONFIG_RTL8192_IO_MAP + + if ( dev->base_addr != 0 ){ + + release_region(dev->base_addr, + pci_resource_len(pdev, 0) ); + } +#else + if ( dev->mem_start != (unsigned long)NULL ){ + iounmap( (void *)dev->mem_start ); + release_mem_region( pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1) ); + } +#endif + +fail: + if (dev){ + + if (priv->irq) { + free_irq(dev->irq, dev); + dev->irq=0; + } + free_rtllib(dev); + } + + pci_disable_device(pdev); + + DMESG("wlan driver load failed\n"); + pci_set_drvdata(pdev, NULL); + return -ENODEV; + +} + +static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv ; + if (dev){ +#ifdef CONFIG_RTL_RFKILL + rtl8192_rfkill_exit(dev); +#endif + unregister_netdev(dev); + + priv = rtllib_priv(dev); + +#ifdef ENABLE_GPIO_RADIO_CTL + del_timer_sync(&priv->gpio_polling_timer); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + cancel_delayed_work(&priv->gpio_change_rf_wq); +#endif + priv->polling_timer_on = 0; +#endif + rtl_debug_module_remove(priv); + rtl8192_proc_remove_one(dev); + rtl8192_down(dev,true); + deinit_hal_dm(dev); +#ifdef CONFIG_ASPM_OR_D3 + ; +#endif + if (priv->pFirmware) + { + vfree(priv->pFirmware); + priv->pFirmware = NULL; + } +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + destroy_workqueue(priv->priv_wq); +#endif + { + u32 i; + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + rtl8192_free_tx_ring(dev, i); + } + } + + if (priv->irq){ + + printk("Freeing irq %d\n",dev->irq); + free_irq(dev->irq, dev); + priv->irq=0; + + } +#ifdef CONFIG_RTL8192_IO_MAP + if ( dev->base_addr != 0 ){ + + release_region(dev->base_addr, + pci_resource_len(pdev, 0) ); + } +#else + if ( dev->mem_start != (unsigned long)NULL ){ + iounmap( (void *)dev->mem_start ); +#ifdef RTL8192CE + release_mem_region( pci_resource_start(pdev, 2), + pci_resource_len(pdev, 2) ); +#else + release_mem_region( pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1) ); +#endif + } +#endif /*end #ifdef RTL_IO_MAP*/ + free_rtllib(dev); + + if (priv->scan_cmd) + kfree(priv->scan_cmd); + + } else{ + priv=rtllib_priv(dev); + } + + pci_disable_device(pdev); +#ifdef RTL8192SE + pci_write_config_byte(pdev, 0x81,1); + pci_write_config_byte(pdev,0x44,3); +#endif + RT_TRACE(COMP_DOWN, "wlan driver removed\n"); +} + +bool NicIFEnableNIC(struct net_device* dev) +{ + bool init_status = true; + struct r8192_priv* priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + if (IS_NIC_DOWN(priv)){ + RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__func__); + priv->bdisable_nic = false; + return RT_STATUS_FAILURE; + } + + RT_TRACE(COMP_PS, "===========>%s()\n",__func__); + priv->bfirst_init = true; + init_status = priv->ops->initialize_adapter(dev); + if (init_status != true) { + RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + priv->bdisable_nic = false; + return -1; + } + RT_TRACE(COMP_INIT, "start adapter finished\n"); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + priv->bfirst_init = false; + + rtl8192_irq_enable(dev); + priv->bdisable_nic = false; + RT_TRACE(COMP_PS,"<===========%s()\n",__func__); + return init_status; +} +bool NicIFDisableNIC(struct net_device* dev) +{ + bool status = true; + struct r8192_priv* priv = rtllib_priv(dev); + u8 tmp_state = 0; + RT_TRACE(COMP_PS, "=========>%s()\n",__func__); + priv->bdisable_nic = true; + tmp_state = priv->rtllib->state; + rtllib_softmac_stop_protocol(priv->rtllib, 0, false); + priv->rtllib->state = tmp_state; + rtl8192_cancel_deferred_work(priv); + rtl8192_irq_disable(dev); + + priv->ops->stop_adapter(dev, false); + RT_TRACE(COMP_PS, "<=========%s()\n",__func__); + + return status; +} + +static int __init rtl8192_pci_module_init(void) +{ + int ret; + int error; + +#ifdef BUILT_IN_CRYPTO + ret = arc4_init(); + if (ret) { + printk(KERN_ERR "arc4_init() failed %d\n", ret); + return ret; + } + + + ret = michael_mic_init(); + if (ret) { + printk(KERN_ERR "michael_mic_init() failed %d\n", ret); + return ret; + } + + ret = aes_init(); + if (ret) { + printk(KERN_ERR "aes_init() failed %d\n", ret); + return ret; + } +#endif + ret = rtllib_init(); + if (ret) { + printk(KERN_ERR "rtllib_init() failed %d\n", ret); + return ret; + } + ret = rtllib_crypto_init(); + if (ret) { + printk(KERN_ERR "rtllib_crypto_init() failed %d\n", ret); + return ret; + } + ret = rtllib_crypto_tkip_init(); + if (ret) { + printk(KERN_ERR "rtllib_crypto_tkip_init() failed %d\n", ret); + return ret; + } + ret = rtllib_crypto_ccmp_init(); + if (ret) { + printk(KERN_ERR "rtllib_crypto_ccmp_init() failed %d\n", ret); + return ret; + } + ret = rtllib_crypto_wep_init(); + if (ret) { + printk(KERN_ERR "rtllib_crypto_wep_init() failed %d\n", ret); + return ret; + } +#ifdef BUILT_IN_MSHCLASS + ret = msh_init(); + if (ret) { + printk(KERN_ERR "msh_init() failed %d\n", ret); + return ret; + } +#endif + printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n"); + printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n"); + RT_TRACE(COMP_INIT, "Initializing module"); + RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); + + error = rtl_create_debugfs_root(); + if (error) { + RT_TRACE(COMP_DBG, "Create debugfs root fail: %d\n", error); + goto err_out; + } + + rtl8192_proc_module_init(); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) + if (0!=pci_module_init(&rtl8192_pci_driver)) +#else + if (0!=pci_register_driver(&rtl8192_pci_driver)) +#endif + { + DMESG("No device found"); + /*pci_unregister_driver (&rtl8192_pci_driver);*/ + return -ENODEV; + } + return 0; +err_out: + return error; + +} + +static void __exit rtl8192_pci_module_exit(void) +{ + pci_unregister_driver(&rtl8192_pci_driver); + + RT_TRACE(COMP_DOWN, "Exiting"); + rtl8192_proc_module_remove(); + rtl_remove_debugfs_root(); + rtllib_crypto_tkip_exit(); + rtllib_crypto_ccmp_exit(); + rtllib_crypto_wep_exit(); + rtllib_crypto_deinit(); + rtllib_exit(); +#ifdef BUILT_IN_CRYPTO + arc4_exit(); + michael_mic_exit(); + aes_fini(); +#endif +#ifdef BUILT_IN_MSHCLASS + msh_exit(); +#endif + +} + +void check_rfctrl_gpio_timer(unsigned long data) +{ + struct r8192_priv* priv = rtllib_priv((struct net_device *)data); + + priv->polling_timer_on = 1; + + queue_delayed_work_rsl(priv->priv_wq,&priv->gpio_change_rf_wq,0); + + mod_timer(&priv->gpio_polling_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); +} + +/*************************************************************************** + ------------------- module init / exit stubs ---------------- +****************************************************************************/ +module_init(rtl8192_pci_module_init); +module_exit(rtl8192_pci_module_exit); + +MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) +MODULE_VERSION(DRV_VERSION); +#endif +MODULE_LICENSE("GPL"); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) +module_param(ifname, charp, S_IRUGO|S_IWUSR ); +module_param(hwwep,int, S_IRUGO|S_IWUSR); +module_param(channels,int, S_IRUGO|S_IWUSR); +#else +MODULE_PARM(ifname, "s"); +MODULE_PARM(hwwep,"i"); +MODULE_PARM(channels,"i"); +#endif + +MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); +MODULE_PARM_DESC(hwwep," Try to use hardware WEP support(default use hw. set 0 to use software security)"); +MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h new file mode 100644 index 00000000000..d858cc9eacb --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -0,0 +1,1190 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#ifndef _RTL_CORE_H +#define _RTL_CORE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) +#include +#endif +#include "rtllib.h" + +#ifdef ENABLE_DOT11D +#include "dot11d.h" +#endif + +#include "r8192E_firmware.h" +#include "r8192E_hw.h" + +#include "r8190P_def.h" +#include "r8192E_dev.h" + +#ifdef CONFIG_CFG_80211 +#include "rtl_regd.h" +#endif + +#ifdef CONFIG_RTL_RFKILL +#include "rtl_rfkill.h" +#endif + +#include "rtl_debug.h" +#include "rtl_eeprom.h" +#include "rtl_ps.h" +#include "rtl_pci.h" +#include "rtl_cam.h" + +#define DRV_COPYRIGHT "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" +#define DRV_AUTHOR "" +#define DRV_VERSION "0014.0401.2010" + +#define DRV_NAME "rtl819xE" + +#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8190P)||\ + (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192E)) +#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192SE) +#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192CE) +#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192CU) +#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192DE) +#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192DU) + +#define RTL_PCI_DEVICE(vend, dev, cfg) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice =PCI_ANY_ID , \ + .driver_data = (kernel_ulong_t)&(cfg) + typedef irqreturn_t irqreturn_type; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) + +#if !defined(PCI_CAP_ID_EXP) +#define PCI_CAP_ID_EXP 0x10 +#endif +#if !defined(PCI_EXP_LNKCTL) +#define PCI_EXP_LNKCTL 0x10 +#endif + +typedef int __bitwise pci_power_t; +#define PCI_D0 ((pci_power_t __force) 0) +#define PCI_D1 ((pci_power_t __force) 1) +#define PCI_D2 ((pci_power_t __force) 2) +#define PCI_D3hot ((pci_power_t __force) 3) +#define PCI_D3cold ((pci_power_t __force) 4) +#define PCI_UNKNOWN ((pci_power_t __force) 5) +#define PCI_POWER_ERROR ((pci_power_t __force) -1) + +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) + #define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y,z) +#else + #define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) +#endif + +#define RTL_MAX_SCAN_SIZE 128 + +#define RTL_RATE_MAX 30 + +#define TOTAL_CAM_ENTRY 32 +#define CAM_CONTENT_COUNT 8 + +#ifndef BIT +#define BIT(_i) (1<<(_i)) +#endif + +#define IS_NIC_DOWN(priv) (!(priv)->up) + +#define IS_ADAPTER_SENDS_BEACON(dev) 0 + +#define IS_UNDER_11N_AES_MODE(_rtllib) ((_rtllib->pHTInfo->bCurrentHTSupport == true) &&\ + (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) + +#define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI 0x1000 +#define HAL_HW_PCI_REVISION_ID_8190PCI 0x00 +#define HAL_MEMORY_MAPPED_IO_RANGE_8192PCIE 0x4000 +#define HAL_HW_PCI_REVISION_ID_8192PCIE 0x01 +#define HAL_MEMORY_MAPPED_IO_RANGE_8192SE 0x4000 +#define HAL_HW_PCI_REVISION_ID_8192SE 0x10 +#define HAL_HW_PCI_REVISION_ID_8192CE 0x1 +#define HAL_MEMORY_MAPPED_IO_RANGE_8192CE 0x4000 +#define HAL_HW_PCI_REVISION_ID_8192DE 0x0 +#define HAL_MEMORY_MAPPED_IO_RANGE_8192DE 0x4000 + +#define HAL_HW_PCI_8180_DEVICE_ID 0x8180 +#define HAL_HW_PCI_8185_DEVICE_ID 0x8185 +#define HAL_HW_PCI_8188_DEVICE_ID 0x8188 +#define HAL_HW_PCI_8198_DEVICE_ID 0x8198 +#define HAL_HW_PCI_8190_DEVICE_ID 0x8190 +#define HAL_HW_PCI_8192_DEVICE_ID 0x8192 +#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 +#define HAL_HW_PCI_8174_DEVICE_ID 0x8174 +#define HAL_HW_PCI_8173_DEVICE_ID 0x8173 +#define HAL_HW_PCI_8172_DEVICE_ID 0x8172 +#define HAL_HW_PCI_8171_DEVICE_ID 0x8171 +#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 +#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 +#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 +#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 +#define HAL_HW_PCI_700F_DEVICE_ID 0x700F +#define HAL_HW_PCI_701F_DEVICE_ID 0x701F +#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 +#define HAL_HW_PCI_8192CET_DEVICE_ID 0x8191 +#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 +#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 +#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 +#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 +#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D + +#define RTL819X_DEFAULT_RF_TYPE RF_1T2R + +#define RTLLIB_WATCH_DOG_TIME 2000 + +#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */ +#define MAX_FIRMWARE_INFORMATION_SIZE 32 +#define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) +#define ENCRYPTION_MAX_OVERHEAD 128 +#define MAX_FRAGMENT_COUNT 8 +#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) + +#define scrclng 4 + +#define DEFAULT_FRAG_THRESHOLD 2342U +#define MIN_FRAG_THRESHOLD 256U +#define DEFAULT_BEACONINTERVAL 0x64U + +#define DEFAULT_SSID "" +#define DEFAULT_RETRY_RTS 7 +#define DEFAULT_RETRY_DATA 7 +#define PRISM_HDR_SIZE 64 + +#define PHY_RSSI_SLID_WIN_MAX 100 + +#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 + +#define TxBBGainTableLength 37 +#define CCKTxBBGainTableLength 23 + +#define CHANNEL_PLAN_LEN 10 +#define sCrcLng 4 + +#define NIC_SEND_HANG_THRESHOLD_NORMAL 4 +#define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 + +#define MAX_TX_QUEUE 9 + +#define MAX_RX_QUEUE 1 + +#define MAX_RX_COUNT 64 +#define MAX_TX_QUEUE_COUNT 9 + +enum RTL819x_PHY_PARAM { + RTL819X_PHY_MACPHY_REG = 0, + RTL819X_PHY_MACPHY_REG_PG = 1, + RTL8188C_PHY_MACREG =2, + RTL8192C_PHY_MACREG =3, + RTL819X_PHY_REG = 4, + RTL819X_PHY_REG_1T2R = 5, + RTL819X_PHY_REG_to1T1R = 6, + RTL819X_PHY_REG_to1T2R = 7, + RTL819X_PHY_REG_to2T2R = 8, + RTL819X_PHY_REG_PG = 9, + RTL819X_AGC_TAB = 10, + RTL819X_PHY_RADIO_A =11, + RTL819X_PHY_RADIO_A_1T =12, + RTL819X_PHY_RADIO_A_2T =13, + RTL819X_PHY_RADIO_B =14, + RTL819X_PHY_RADIO_B_GM =15, + RTL819X_PHY_RADIO_C =16, + RTL819X_PHY_RADIO_D =17, + RTL819X_EEPROM_MAP =18, + RTL819X_EFUSE_MAP =19, +}; + +enum RTL_DEBUG { + COMP_TRACE = BIT0, + COMP_DBG = BIT1, + COMP_INIT = BIT2, + COMP_RECV = BIT3, + COMP_SEND = BIT4, + COMP_CMD = BIT5, + COMP_POWER = BIT6, + COMP_EPROM = BIT7, + COMP_SWBW = BIT8, + COMP_SEC = BIT9, + COMP_LPS = BIT10, + COMP_QOS = BIT11, + COMP_RATE = BIT12, + COMP_RXDESC = BIT13, + COMP_PHY = BIT14, + COMP_DIG = BIT15, + COMP_TXAGC = BIT16, + COMP_HALDM = BIT17, + COMP_POWER_TRACKING = BIT18, + COMP_CH = BIT19, + COMP_RF = BIT20, + COMP_FIRMWARE = BIT21, + COMP_HT = BIT22, + COMP_RESET = BIT23, + COMP_CMDPKT = BIT24, + COMP_SCAN = BIT25, + COMP_PS = BIT26, + COMP_DOWN = BIT27, + COMP_INTR = BIT28, + COMP_LED = BIT29, + COMP_MLME = BIT30, + COMP_ERR = BIT31 +}; + +typedef enum{ + NIC_UNKNOWN = 0, + NIC_8192E = 1, + NIC_8190P = 2, + NIC_8192SE = 4, + NIC_8192CE = 5, + NIC_8192CU = 6, + NIC_8192DE = 7, + NIC_8192DU = 8, + } nic_t; + +typedef enum _RT_EEPROM_TYPE{ + EEPROM_93C46, + EEPROM_93C56, + EEPROM_BOOT_EFUSE, +}RT_EEPROM_TYPE,*PRT_EEPROM_TYPE; + +typedef enum _tag_TxCmd_Config_Index{ + TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, + TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, + TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, + TXCMD_SET_TX_DURATION = 0xFF900003, + TXCMD_SET_RX_RSSI = 0xFF900004, + TXCMD_SET_TX_PWR_TRACKING = 0xFF900005, + TXCMD_XXXX_CTRL, +}DCMD_TXCMD_OP; + +typedef enum _RT_RF_TYPE_819xU{ + RF_TYPE_MIN = 0, + RF_8225, + RF_8256, + RF_8258, + RF_6052=4, + RF_PSEUDO_11N = 5, +}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; + +typedef enum tag_Rf_Operatetion_State +{ + RF_STEP_INIT = 0, + RF_STEP_NORMAL, + RF_STEP_MAX +}RF_STEP_E; + +typedef enum _RT_STATUS{ + RT_STATUS_SUCCESS, + RT_STATUS_FAILURE, + RT_STATUS_PENDING, + RT_STATUS_RESOURCE +}RT_STATUS,*PRT_STATUS; + +typedef enum _RT_CUSTOMER_ID +{ + RT_CID_DEFAULT = 0, + RT_CID_8187_ALPHA0 = 1, + RT_CID_8187_SERCOMM_PS = 2, + RT_CID_8187_HW_LED = 3, + RT_CID_8187_NETGEAR = 4, + RT_CID_WHQL = 5, + RT_CID_819x_CAMEO = 6, + RT_CID_819x_RUNTOP = 7, + RT_CID_819x_Senao = 8, + RT_CID_TOSHIBA = 9, + RT_CID_819x_Netcore = 10, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, + RT_CID_819x_ALPHA = 15, + RT_CID_819x_Sitecom = 16, + RT_CID_CCX = 17, + RT_CID_819x_Lenovo = 18, + RT_CID_819x_QMI = 19, + RT_CID_819x_Edimax_Belkin = 20, + RT_CID_819x_Sercomm_Belkin = 21, + RT_CID_819x_CAMEO1 = 22, + RT_CID_819x_MSI = 23, + RT_CID_819x_Acer = 24, + RT_CID_819x_HP =27, + RT_CID_819x_CLEVO = 28, + RT_CID_819x_Arcadyan_Belkin = 29, + RT_CID_819x_SAMSUNG = 30, + RT_CID_819x_WNC_COREGA = 31, +}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; + +typedef enum _RESET_TYPE { + RESET_TYPE_NORESET = 0x00, + RESET_TYPE_NORMAL = 0x01, + RESET_TYPE_SILENT = 0x02 +} RESET_TYPE; + +typedef enum _IC_INFERIORITY_8192S{ + IC_INFERIORITY_A = 0, + IC_INFERIORITY_B = 1, +}IC_INFERIORITY_8192S, *PIC_INFERIORITY_8192S; + +typedef enum _PCI_BRIDGE_VENDOR { + PCI_BRIDGE_VENDOR_INTEL = 0x0, + PCI_BRIDGE_VENDOR_ATI, + PCI_BRIDGE_VENDOR_AMD, + PCI_BRIDGE_VENDOR_SIS , + PCI_BRIDGE_VENDOR_UNKNOWN, + PCI_BRIDGE_VENDOR_MAX , +} PCI_BRIDGE_VENDOR; + +typedef struct buffer +{ + struct buffer *next; + u32 *buf; + dma_addr_t dma; + +} buffer; + +typedef struct rtl_reg_debug{ + unsigned int cmd; + struct { + unsigned char type; + unsigned char addr; + unsigned char page; + unsigned char length; + } head; + unsigned char buf[0xff]; +}rtl_reg_debug; + +typedef struct _rt_9x_tx_rate_history { + u32 cck[4]; + u32 ofdm[8]; + u32 ht_mcs[4][16]; +}rt_tx_rahis_t, *prt_tx_rahis_t; + +typedef struct _RT_SMOOTH_DATA_4RF { + char elements[4][100]; + u32 index; + u32 TotalNum; + u32 TotalVal[4]; +}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF; + +typedef struct Stats +{ + unsigned long txrdu; + unsigned long rxrdu; + unsigned long rxok; + unsigned long rxframgment; + unsigned long rxcmdpkt[4]; + unsigned long rxurberr; + unsigned long rxstaterr; + unsigned long rxdatacrcerr; + unsigned long rxmgmtcrcerr; + unsigned long rxcrcerrmin; + unsigned long rxcrcerrmid; + unsigned long rxcrcerrmax; + unsigned long received_rate_histogram[4][32]; + unsigned long received_preamble_GI[2][32]; + unsigned long rx_AMPDUsize_histogram[5]; + unsigned long rx_AMPDUnum_histogram[5]; + unsigned long numpacket_matchbssid; + unsigned long numpacket_toself; + unsigned long num_process_phyinfo; + unsigned long numqry_phystatus; + unsigned long numqry_phystatusCCK; + unsigned long numqry_phystatusHT; + unsigned long received_bwtype[5]; + unsigned long txnperr; + unsigned long txnpdrop; + unsigned long txresumed; + unsigned long rxoverflow; + unsigned long rxint; + unsigned long txnpokint; + unsigned long ints; + unsigned long shints; + unsigned long txoverflow; + unsigned long txlpokint; + unsigned long txlpdrop; + unsigned long txlperr; + unsigned long txbeokint; + unsigned long txbedrop; + unsigned long txbeerr; + unsigned long txbkokint; + unsigned long txbkdrop; + unsigned long txbkerr; + unsigned long txviokint; + unsigned long txvidrop; + unsigned long txvierr; + unsigned long txvookint; + unsigned long txvodrop; + unsigned long txvoerr; + unsigned long txbeaconokint; + unsigned long txbeacondrop; + unsigned long txbeaconerr; + unsigned long txmanageokint; + unsigned long txmanagedrop; + unsigned long txmanageerr; + unsigned long txcmdpktokint; + unsigned long txdatapkt; + unsigned long txfeedback; + unsigned long txfeedbackok; + unsigned long txoktotal; + unsigned long txokbytestotal; + unsigned long txokinperiod; + unsigned long txmulticast; + unsigned long txbytesmulticast; + unsigned long txbroadcast; + unsigned long txbytesbroadcast; + unsigned long txunicast; + unsigned long txbytesunicast; + unsigned long rxbytesunicast; + unsigned long txfeedbackfail; + unsigned long txerrtotal; + unsigned long txerrbytestotal; + unsigned long txerrmulticast; + unsigned long txerrbroadcast; + unsigned long txerrunicast; + unsigned long txretrycount; + unsigned long txfeedbackretry; + u8 last_packet_rate; + unsigned long slide_signal_strength[100]; + unsigned long slide_evm[100]; + unsigned long slide_rssi_total; + unsigned long slide_evm_total; + long signal_strength; + long signal_quality; + long last_signal_strength_inpercent; + long recv_signal_power; + u8 rx_rssi_percentage[4]; + u8 rx_evm_percentage[2]; + long rxSNRdB[4]; + rt_tx_rahis_t txrate; + u32 Slide_Beacon_pwdb[100]; + u32 Slide_Beacon_Total; + RT_SMOOTH_DATA_4RF cck_adc_pwdb; + u32 CurrentShowTxate; +} Stats; + +typedef struct ChnlAccessSetting { + u16 SIFS_Timer; + u16 DIFS_Timer; + u16 SlotTimeTimer; + u16 EIFS_Timer; + u16 CWminIndex; + u16 CWmaxIndex; +}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING; + +typedef enum _TWO_PORT_STATUS +{ + TWO_PORT_STATUS__DEFAULT_ONLY, + TWO_PORT_STATUS__EXTENSION_ONLY, + TWO_PORT_STATUS__EXTENSION_FOLLOW_DEFAULT, + TWO_PORT_STATUS__DEFAULT_G_EXTENSION_N20, + TWO_PORT_STATUS__ADHOC, + TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE +}TWO_PORT_STATUS; + +typedef struct _txbbgain_struct +{ + long txbb_iq_amplifygain; + u32 txbbgain_value; +} txbbgain_struct, *ptxbbgain_struct; + +typedef struct _ccktxbbgain_struct +{ + u8 ccktxbb_valuearray[8]; +} ccktxbbgain_struct,*pccktxbbgain_struct; + +typedef struct _init_gain +{ + u8 xaagccore1; + u8 xbagccore1; + u8 xcagccore1; + u8 xdagccore1; + u8 cca; + +} init_gain, *pinit_gain; + +typedef struct _tx_ring{ + u32 * desc; + u8 nStuckCount; + struct _tx_ring * next; +}__attribute__ ((packed)) tx_ring, * ptx_ring; + +struct rtl8192_tx_ring { + tx_desc *desc; + dma_addr_t dma; + unsigned int idx; + unsigned int entries; + struct sk_buff_head queue; +}; + + + +struct rtl819x_ops{ + nic_t nic_type; + void (* get_eeprom_size)(struct net_device* dev); + void (* init_adapter_variable)(struct net_device* dev); + void (* init_before_adapter_start)(struct net_device* dev); + bool (* initialize_adapter)(struct net_device* dev); + void (*link_change)(struct net_device* dev); + void (* tx_fill_descriptor)(struct net_device* dev, tx_desc * tx_desc, cb_desc * cb_desc, struct sk_buff *skb); + void (* tx_fill_cmd_descriptor)(struct net_device* dev, tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); + bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, rx_desc *pdesc, struct sk_buff* skb); + bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, rx_desc *pdesc); + void (* stop_adapter)(struct net_device *dev, bool reset); + void (* update_ratr_table)(struct net_device* dev); + void (* irq_enable)(struct net_device* dev); + void (* irq_disable)(struct net_device* dev); + void (* irq_clear)(struct net_device* dev); + void (* rx_enable)(struct net_device* dev); + void (* tx_enable)(struct net_device* dev); + void (* interrupt_recognized)(struct net_device *dev, u32 *p_inta, u32 *p_intb); + bool (* TxCheckStuckHandler)(struct net_device* dev); + bool (* RxCheckStuckHandler)(struct net_device* dev); +}; + +typedef struct r8192_priv +{ + struct pci_dev *pdev; + struct pci_dev *bridge_pdev; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) + u32 pci_state; +#endif + + bool bfirst_init; + bool bfirst_after_down; + bool initialized_at_probe; + bool being_init_adapter; + bool bDriverIsGoingToUnload; + + int irq; + short irq_enabled; + + short up; + short up_first_time; + delayed_work_struct_rsl update_beacon_wq; + delayed_work_struct_rsl watch_dog_wq; + delayed_work_struct_rsl txpower_tracking_wq; + delayed_work_struct_rsl rfpath_check_wq; + delayed_work_struct_rsl gpio_change_rf_wq; + delayed_work_struct_rsl initialgain_operate_wq; + delayed_work_struct_rsl check_hw_scan_wq; + delayed_work_struct_rsl hw_scan_simu_wq; + delayed_work_struct_rsl start_hw_scan_wq; + + struct workqueue_struct *priv_wq; + + CHANNEL_ACCESS_SETTING ChannelAccessSetting; + + mp_adapter NdisAdapter; + + struct rtl819x_ops *ops; + struct rtllib_device *rtllib; + +#ifdef CONFIG_BT_30 + struct BT30Info BtInfo; +#endif + +#ifdef CONFIG_RTLWIFI_DEBUGFS + rtl_fs_debug *debug; +#endif /* CONFIG_IWLWIFI_DEBUGFS */ + + work_struct_rsl reset_wq; + + LOG_INTERRUPT_8190_T InterruptLog; + + RT_CUSTOMER_ID CustomerID; + + + RT_RF_TYPE_819xU rf_chip; + IC_INFERIORITY_8192S IC_Class; + HT_CHANNEL_WIDTH CurrentChannelBW; + BB_REGISTER_DEFINITION_T PHYRegDef[4]; + rate_adaptive rate_adaptive; + + ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength]; + ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; + + txbbgain_struct txbbgain_table[TxBBGainTableLength]; + + ACM_METHOD AcmMethod; + + prt_firmware pFirmware; + rtl819x_loopback_e LoopbackMode; + firmware_source_e firmware_source; + + struct timer_list watch_dog_timer; + struct timer_list fsync_timer; + struct timer_list gpio_polling_timer; + + spinlock_t fw_scan_lock; + spinlock_t irq_lock; + spinlock_t irq_th_lock; + spinlock_t tx_lock; + spinlock_t rf_ps_lock; + spinlock_t rw_lock; + spinlock_t rt_h2c_lock; +#ifdef CONFIG_ASPM_OR_D3 + spinlock_t D3_lock; +#endif + spinlock_t rf_lock; + spinlock_t ps_lock; + + struct sk_buff_head rx_queue; + struct sk_buff_head skb_queue; + + struct tasklet_struct irq_rx_tasklet; + struct tasklet_struct irq_tx_tasklet; + struct tasklet_struct irq_prepare_beacon_tasklet; + + struct semaphore wx_sem; + struct semaphore rf_sem; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) + struct semaphore mutex; +#else + struct mutex mutex; +#endif + + struct Stats stats; + struct iw_statistics wstats; + struct proc_dir_entry *dir_dev; + + short (*rf_set_sens)(struct net_device *dev,short sens); + u8 (*rf_set_chan)(struct net_device *dev,u8 ch); + void (*rf_close)(struct net_device *dev); + void (*rf_init)(struct net_device *dev); + +#ifdef CONFIG_CFG_80211 + struct ieee80211_rate rates[IEEE80211_NUM_BANDS][RTL_RATE_MAX]; + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; +#endif + + rx_desc *rx_ring[MAX_RX_QUEUE]; + struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT]; + dma_addr_t rx_ring_dma[MAX_RX_QUEUE]; + unsigned int rx_idx[MAX_RX_QUEUE]; + int rxringcount; + u16 rxbuffersize; + + u32 LastRxDescTSFHigh; + u32 LastRxDescTSFLow; + + u16 EarlyRxThreshold; + u32 ReceiveConfig; + u8 AcmControl; + u8 RFProgType; + u8 retry_data; + u8 retry_rts; + u16 rts; + + struct rtl8192_tx_ring tx_ring[MAX_TX_QUEUE_COUNT]; + int txringcount; + int txbuffsize; + int txfwbuffersize; + atomic_t tx_pending[0x10]; + + u16 ShortRetryLimit; + u16 LongRetryLimit; + u32 TransmitConfig; + u8 RegCWinMin; + u8 keepAliveLevel; + +#ifdef CONFIG_RTL_RFKILL + bool rfkill_off; +#endif + bool sw_radio_on; + bool bHwRadioOff; + bool pwrdown; + bool blinked_ingpio; + u8 polling_timer_on; + + /**********************************************************/ + + enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type; + + work_struct_rsl qos_activate; + + u8 bIbssCoordinator; + + short promisc; + short crcmon; + + int txbeaconcount; + + short chan; + short sens; + short max_sens; + u32 rx_prevlen; + + u8 ScanDelay; + bool ps_force; + + u32 irq_mask[2]; + + u8 Rf_Mode; + nic_t card_8192; + u8 card_8192_version; + + short enable_gpio0; + + u8 rf_type; + u8 IC_Cut; + char nick[IW_ESSID_MAX_SIZE + 1]; + + u8 RegBcnCtrlVal; + bool bHwAntDiv; + + bool bTKIPinNmodeFromReg; + bool bWEPinNmodeFromReg; + + bool bLedOpenDrain; + + u8 check_roaming_cnt; + + bool bIgnoreSilentReset; + u32 SilentResetRxSoltNum; + u32 SilentResetRxSlotIndex; + u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; + + void *scan_cmd; + u8 hwscan_bw_40; + + u16 nrxAMPDU_size; + u8 nrxAMPDU_aggr_num; + + u32 last_rxdesc_tsf_high; + u32 last_rxdesc_tsf_low; + + + u16 basic_rate; + u8 short_preamble; + u8 dot11CurrentPreambleMode; + u8 slot_time; + u16 SifsTime; + + u8 RegWirelessMode; + + u8 firmware_version; + u16 FirmwareSubVersion; + u16 rf_pathmap; + bool AutoloadFailFlag; + + u8 RegPciASPM; + u8 RegAMDPciASPM; + u8 RegHwSwRfOffD3; + u8 RegSupportPciASPM; + bool bSupportASPM; + + u32 RfRegChnlVal[2]; + + u8 ShowRateMode; + u8 RATRTableBitmap; + + u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; + u16 EfuseUsedBytes; + u8 EfuseUsedPercentage; + +#ifdef EFUSE_REPG_WORKAROUND + bool efuse_RePGSec1Flag; + u8 efuse_RePGData[8]; +#endif + + short epromtype; + u16 eeprom_vid; + u16 eeprom_did; + u16 eeprom_svid; + u16 eeprom_smid; + u8 eeprom_CustomerID; + u16 eeprom_ChannelPlan; + u8 eeprom_version; + + u8 EEPROMRegulatory; + u8 EEPROMPwrGroup[2][3]; + u8 EEPROMOptional; + +#if (EEPROM_OLD_FORMAT_SUPPORT == 1) + u8 EEPROMTxPowerLevelCCK[14]; + u8 EEPROMTxPowerLevelOFDM24G[14]; + u8 EEPROMTxPowerLevelOFDM5G[24]; +#else + u8 RfCckChnlAreaTxPwr[2][3]; + u8 RfOfdmChnlAreaTxPwr1T[2][3]; + u8 RfOfdmChnlAreaTxPwr2T[2][3]; +#endif + u8 EEPROMRfACCKChnl1TxPwLevel[3]; + u8 EEPROMRfAOfdmChnlTxPwLevel[3]; + u8 EEPROMRfCCCKChnl1TxPwLevel[3]; + u8 EEPROMRfCOfdmChnlTxPwLevel[3]; + u16 EEPROMTxPowerDiff; + u16 EEPROMAntPwDiff; + u8 EEPROMThermalMeter; + u8 EEPROMPwDiff; + u8 EEPROMCrystalCap; + + u8 EEPROMBluetoothCoexist; + u8 EEPROMBluetoothType; + u8 EEPROMBluetoothAntNum; + u8 EEPROMBluetoothAntIsolation; + u8 EEPROMBluetoothRadioShared; + + + u8 EEPROMSupportWoWLAN; + u8 EEPROMBoardType; + u8 EEPROM_Def_Ver; + u8 EEPROMHT2T_TxPwr[6]; + u8 EEPROMTSSI_A; + u8 EEPROMTSSI_B; + u8 EEPROMTxPowerLevelCCK_V1[3]; + u8 EEPROMLegacyHTTxPowerDiff; + + u8 BluetoothCoexist; + + u8 CrystalCap; + u8 ThermalMeter[2]; + + u16 FwCmdIOMap; + u32 FwCmdIOParam; + + u8 SwChnlInProgress; + u8 SwChnlStage; + u8 SwChnlStep; + u8 SetBWModeInProgress; + + u8 nCur40MhzPrimeSC; + + u32 RfReg0Value[4]; + u8 NumTotalRFPath; + bool brfpath_rxenable[4]; + + bool bTXPowerDataReadFromEEPORM; + + u16 RegChannelPlan; + u16 ChannelPlan; + bool bChnlPlanFromHW; + + bool RegRfOff; + bool isRFOff; + bool bInPowerSaveMode; + u8 bHwRfOffAction; + + bool aspm_clkreq_enable; + u32 pci_bridge_vendor; + u8 RegHostPciASPMSetting; + u8 RegDevicePciASPMSetting; + + bool RFChangeInProgress; + bool SetRFPowerStateInProgress; + bool bdisable_nic; + + u8 pwrGroupCnt; + + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + bool bRfPiEnable; + + u32 APKoutput[2][2]; + bool bAPKdone; + + long RegE94; + long RegE9C; + long RegEB4; + long RegEBC; + + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 ADDA_backup[16]; + u32 IQK_MAC_backup[3]; + + bool SetFwCmdInProgress; + u8 CurrentFwCmdIO; + + u8 rssi_level; + + bool bInformFWDriverControlDM; + u8 PwrGroupHT20[2][14]; + u8 PwrGroupHT40[2][14]; + + u8 ThermalValue; + long EntryMinUndecoratedSmoothedPWDB; + long EntryMaxUndecoratedSmoothedPWDB; + u8 DynamicTxHighPowerLvl; + u8 LastDTPLvl; + u32 CurrentRATR0; + FALSE_ALARM_STATISTICS FalseAlmCnt; + + u8 DMFlag; + u8 DM_Type; + + u8 CckPwEnl; + u16 TSSI_13dBm; + u32 Pwr_Track; + u8 CCKPresentAttentuation_20Mdefault; + u8 CCKPresentAttentuation_40Mdefault; + char CCKPresentAttentuation_difference; + char CCKPresentAttentuation; + u8 bCckHighPower; + long undecorated_smoothed_pwdb; + long undecorated_smoothed_cck_adc_pwdb[4]; + + u32 MCSTxPowerLevelOriginalOffset[6]; + u32 CCKTxPowerLevelOriginalOffset; + u8 TxPowerLevelCCK[14]; + u8 TxPowerLevelCCK_A[14]; + u8 TxPowerLevelCCK_C[14]; + u8 TxPowerLevelOFDM24G[14]; + u8 TxPowerLevelOFDM5G[14]; + u8 TxPowerLevelOFDM24G_A[14]; + u8 TxPowerLevelOFDM24G_C[14]; + u8 LegacyHTTxPowerDiff; + u8 TxPowerDiff; + s8 RF_C_TxPwDiff; + s8 RF_B_TxPwDiff; + u8 RfTxPwrLevelCck[2][14]; + u8 RfTxPwrLevelOfdm1T[2][14]; + u8 RfTxPwrLevelOfdm2T[2][14]; + u8 AntennaTxPwDiff[3]; + u8 TxPwrHt20Diff[2][14]; + u8 TxPwrLegacyHtDiff[2][14]; + u8 TxPwrSafetyFlag; + u8 HT2T_TxPwr_A[14]; + u8 HT2T_TxPwr_B[14]; + u8 CurrentCckTxPwrIdx; + u8 CurrentOfdm24GTxPwrIdx; + + bool bdynamic_txpower; + bool bDynamicTxHighPower; + bool bDynamicTxLowPower; + bool bLastDTPFlag_High; + bool bLastDTPFlag_Low; + + bool bstore_last_dtpflag; + bool bstart_txctrl_bydtp; + + u8 rfa_txpowertrackingindex; + u8 rfa_txpowertrackingindex_real; + u8 rfa_txpowertracking_default; + u8 rfc_txpowertrackingindex; + u8 rfc_txpowertrackingindex_real; + u8 rfc_txpowertracking_default; + bool btxpower_tracking; + bool bcck_in_ch14; + + u8 TxPowerTrackControl; + u8 txpower_count; + bool btxpower_trackingInit; + + u8 OFDM_index[2]; + u8 CCK_index; + + u8 Record_CCK_20Mindex; + u8 Record_CCK_40Mindex; + + init_gain initgain_backup; + u8 DefaultInitialGain[4]; + bool bis_any_nonbepkts; + bool bcurrent_turbo_EDCA; + bool bis_cur_rdlstate; + + bool bCCKinCH14; + + u8 MidHighPwrTHR_L1; + u8 MidHighPwrTHR_L2; + + bool bfsync_processing; + u32 rate_record; + u32 rateCountDiffRecord; + u32 ContiuneDiffCount; + bool bswitch_fsync; + u8 framesync; + u32 framesyncC34; + u8 framesyncMonitor; + + bool bDMInitialGainEnable; + bool MutualAuthenticationFail; + + bool bDisableFrameBursting; + + u32 reset_count; + bool bpbc_pressed; + + u32 txpower_checkcnt; + u32 txpower_tracking_callback_cnt; + u8 thermal_read_val[40]; + u8 thermal_readback_index; + u32 ccktxpower_adjustcnt_not_ch14; + u32 ccktxpower_adjustcnt_ch14; + + RESET_TYPE ResetProgress; + bool bForcedSilentReset; + bool bDisableNormalResetCheck; + u16 TxCounter; + u16 RxCounter; + int IrpPendingCount; + bool bResetInProgress; + bool force_reset; + bool force_lps; + u8 InitialGainOperateType; + + bool chan_forced; + bool bSingleCarrier; + bool RegBoard; + bool bCckContTx; + bool bOfdmContTx; + bool bStartContTx; + u8 RegPaModel; + u8 btMpCckTxPower; + u8 btMpOfdmTxPower; + + u32 MptActType; + u32 MptIoOffset; + u32 MptIoValue; + u32 MptRfPath; + + u32 MptBandWidth; + u32 MptRateIndex; + u8 MptChannelToSw; + u32 MptRCR; + + u8 PwrDomainProtect; + u8 H2CTxCmdSeq; + + +}r8192_priv; + +extern const struct ethtool_ops rtl819x_ethtool_ops; + +void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb); +short rtl8192_tx(struct net_device *dev, struct sk_buff* skb); + +u8 read_nic_io_byte(struct net_device *dev, int x); +u32 read_nic_io_dword(struct net_device *dev, int x); +u16 read_nic_io_word(struct net_device *dev, int x) ; +void write_nic_io_byte(struct net_device *dev, int x,u8 y); +void write_nic_io_word(struct net_device *dev, int x,u16 y); +void write_nic_io_dword(struct net_device *dev, int x,u32 y); + +u8 read_nic_byte(struct net_device *dev, int x); +u32 read_nic_dword(struct net_device *dev, int x); +u16 read_nic_word(struct net_device *dev, int x) ; +void write_nic_byte(struct net_device *dev, int x,u8 y); +void write_nic_word(struct net_device *dev, int x,u16 y); +void write_nic_dword(struct net_device *dev, int x,u32 y); + +void force_pci_posting(struct net_device *dev); + +void rtl8192_rx_enable(struct net_device *); +void rtl8192_tx_enable(struct net_device *); + +int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev); +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate); +void rtl8192_data_hard_stop(struct net_device *dev); +void rtl8192_data_hard_resume(struct net_device *dev); +void rtl8192_restart(void *data); +void rtl819x_watchdog_wqcallback(void *data); +void rtl8192_hw_sleep_wq (void *data); +void watch_dog_timer_callback(unsigned long data); +void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); +void rtl8192_irq_tx_tasklet(struct r8192_priv *priv); +int rtl8192_down(struct net_device *dev,bool shutdownrf); +int rtl8192_up(struct net_device *dev); +void rtl8192_commit(struct net_device *dev); +void rtl8192_set_chan(struct net_device *dev,short ch); + +void check_rfctrl_gpio_timer(unsigned long data); + +void rtl8192_hw_wakeup_wq(void *data); +irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); + +short rtl8192_pci_initdescring(struct net_device *dev); + +void rtl8192_cancel_deferred_work(struct r8192_priv* priv); + +int _rtl8192_up(struct net_device *dev,bool is_silent_reset); + +short rtl8192_is_tx_queue_empty(struct net_device *dev); +void rtl8192_irq_disable(struct net_device *dev); + +void rtl8192_tx_timeout(struct net_device *dev); +void rtl8192_pci_resetdescring(struct net_device *dev); +void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode); +void rtl8192_irq_enable(struct net_device *dev); +void rtl8192_config_rate(struct net_device* dev, u16* rate_config); +void rtl8192_update_cap(struct net_device* dev, u16 cap); +void rtl8192_irq_disable(struct net_device *dev); + +void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats); +long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ); +void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); +u8 rtl819x_evm_dbtopercentage(char value); +void rtl819x_process_cck_rxpathsel(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); +u8 rtl819x_query_rxpwrpercentage( char antpower ); +void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats * psrc_stats,struct rtllib_rx_stats * ptarget_stats); + +bool NicIFEnableNIC(struct net_device* dev); +bool NicIFDisableNIC(struct net_device* dev); + +bool +MgntActSet_RF_State( + struct net_device* dev, + RT_RF_POWER_STATE StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot + ); +void +ActUpdateChannelAccessSetting( + struct net_device* dev, + WIRELESS_MODE WirelessMode, + PCHANNEL_ACCESS_SETTING ChnlAccessSetting + ); + +#ifdef CONFIG_CFG_80211 +struct net_device *wiphy_to_net_device(struct wiphy *wiphy); +#endif + +#endif diff --git a/drivers/staging/rtl8192e/ieee80211/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h similarity index 97% rename from drivers/staging/rtl8192e/ieee80211/rtl_crypto.h rename to drivers/staging/rtl8192e/rtl_crypto.h index ccf6ae76357..6f445c58dc0 100644 --- a/drivers/staging/rtl8192e/ieee80211/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -24,6 +24,16 @@ #include #include +#ifdef BUILT_IN_CRYPTO +#ifdef CONFIG_CRYPTO_HMAC +#undef CONFIG_CRYPTO_HMAC +#endif + +#ifdef CONFIG_KMOD +#undef CONFIG_KMOD +#endif +#endif /* BUILT_IN_CRYPTO */ + #define crypto_register_alg crypto_register_alg_rsl #define crypto_unregister_alg crypto_unregister_alg_rsl #define crypto_alloc_tfm crypto_alloc_tfm_rsl @@ -52,10 +62,10 @@ #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 -#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 -#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 -#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000 -#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000 +#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 +#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 +#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000 +#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000 /* * Miscellaneous stuff. @@ -396,4 +406,3 @@ void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen, #endif /* CONFIG_CRYPTO_HMAC */ #endif /* _LINUX_CRYPTO_H */ - diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c new file mode 100644 index 00000000000..68839944083 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -0,0 +1,1339 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtl_debug.h" +#include "rtl_core.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */ +#include "r8192E_cmdpkt.h" + +u32 rt_global_debug_component = \ + COMP_ERR ; + +/*------------------Declare variable-----------------------*/ +u32 DBGP_Type[DBGP_TYPE_MAX]; + +/*----------------------------------------------------------------------------- + * Function: DBGP_Flag_Init + * + * Overview: Refresh all debug print control flag content to zero. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 10/20/2006 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void rtl8192_dbgp_flag_init(struct net_device *dev) +{ + u8 i; + + for (i = 0; i < DBGP_TYPE_MAX; i++) + { + DBGP_Type[i] = 0; + } + + +} /* DBGP_Flag_Init */ + +/* this is only for debugging */ +void print_buffer(u32 *buffer, int len) +{ + int i; + u8 *buf =(u8*)buffer; + + printk("ASCII BUFFER DUMP (len: %x):\n",len); + + for (i=0;i ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + printk("%2x ", read_nic_byte(dev, n)); + } + printk("\n"); +} + +#ifdef CONFIG_RTLWIFI_DEBUGFS +/* debugfs related stuff */ +static struct dentry *rtl_debugfs_root; +static int rtl_dbgfs_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t rtl_dbgfs_register_write(struct file *file, + const char __user *user_buf, + size_t count, + loff_t *ppos) +{ + struct r8192_priv *priv = (struct r8192_priv *)file->private_data; + char buf[32]; + int buf_size; + u32 type, offset; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (sscanf(buf, "%x,%x", &type, &offset ) == 2) { + priv->debug->hw_type = type; + priv->debug->hw_offset = offset; + } else { + priv->debug->hw_type = 0; + priv->debug->hw_offset = 0; + } + + return count; +} + +void rtl_hardware_grab(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int t = 0; + int timeout = 20; + u32 mask = RF_CHANGE_BY_HW|RF_CHANGE_BY_PS|RF_CHANGE_BY_IPS; + + priv->debug->hw_holding = true; + rtllib_ips_leave_wq(dev); + do { + if ((priv->rtllib->RfOffReason & mask)) { + msleep(100); + t++; + } else { + return; + } + } while (t < timeout); + + return; +} + +static ssize_t rtl_dbgfs_register_read(struct file *file, + char __user *user_buf, + size_t count, + loff_t *ppos) +{ + struct r8192_priv *priv = (struct r8192_priv *)file->private_data; + struct net_device *dev = priv->rtllib->dev; + ssize_t ret = 0; + char buf[2048]; + int n,i; + u32 len = 0; + u32 max = 0xff; + u32 page_no, path; + + rtl_hardware_grab(dev); + + if (!priv->debug->hw_type) { + page_no = (priv->debug->hw_offset > 0x0f)? 0x0f: priv->debug->hw_offset; +#ifdef RTL8192SE + if (page_no >= 0x08 ) { + len += snprintf(buf + len, count - len, + "\n#################### BB page- %x##################\n ", page_no); + for (n=0;n<=max;) + { + len += snprintf(buf + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(buf + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page_no << 8|n), + bMaskDWord)); + } + + } else +#endif + { + len += snprintf(buf + len,count - len, + "\n#################### MAC page- %x##################\n ", page_no); + for (n=0;n<=max;) { + len += snprintf(buf + len, count - len, "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(buf + len, count - len, + "%2.2x ",read_nic_byte(dev,((page_no<<8)|n))); + } + } + } else { + path = (priv->debug->hw_offset < RF90_PATH_MAX)? priv->debug->hw_offset:(RF90_PATH_MAX - 1); + len += snprintf(buf + len, count - len, + "\n#################### RF-PATH-%x ##################\n ", 0x0a+path); + for (n=0;n<=max;) { + len += snprintf(buf+ len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(buf + len, count - len, + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)path,\ + n, bMaskDWord)); + } + } + + priv->debug->hw_holding = false; + + len += snprintf(buf + len, count - len, "\n"); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); + return ret; +} + +static const struct file_operations rtl_register_debug = { + .read = rtl_dbgfs_register_read, + .write = rtl_dbgfs_register_write, + .open = rtl_dbgfs_open, + .owner = THIS_MODULE +}; + +int rtl_debug_module_init(struct r8192_priv *priv, const char *name) +{ + rtl_fs_debug *debug; + int ret = 0; + + if (!rtl_debugfs_root) + return -ENOENT; + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) + debug = kzalloc(sizeof(rtl_fs_debug), GFP_KERNEL); +#else + rtl_fs_debug = kmalloc(sizeof(*rtl_fs_debug), GFP_KERNEL); + memset(rtl_fs_debug,0,sizeof(*rtl_fs_debug)); +#endif + if (!debug) { + ret = -ENOMEM; + goto err; + } + priv->debug = debug; + + debug->name = name; + debug->dir_drv = debugfs_create_dir(name, rtl_debugfs_root); + if (!debug->dir_drv ) { + ret = -ENOENT; + goto err; + } + + debug->debug_register = debugfs_create_file("debug_register", S_IRUGO, + debug->dir_drv, priv, &rtl_register_debug); + if (!debug->debug_register) { + ret = -ENOENT; + goto err; + } + + return 0; +err: + RT_TRACE(COMP_DBG, "Can't open the debugfs directory\n"); + rtl_debug_module_remove(priv); + return ret; + +} + +void rtl_debug_module_remove(struct r8192_priv *priv) +{ + if (!priv->debug) + return; + debugfs_remove(priv->debug->debug_register); + debugfs_remove(priv->debug->dir_drv); + kfree(priv->debug); + priv->debug = NULL; +} + +int rtl_create_debugfs_root(void) +{ + rtl_debugfs_root = debugfs_create_dir(DRV_NAME, NULL); + if (!rtl_debugfs_root) + return -ENOENT; + + return 0; +} + +void rtl_remove_debugfs_root(void) +{ + debugfs_remove(rtl_debugfs_root); + rtl_debugfs_root = NULL; +} +#endif + +/**************************************************************************** + -----------------------------PROCFS STUFF------------------------- +*****************************************************************************/ +/*This part is related to PROC, which will record some statistics. */ +static struct proc_dir_entry *rtl8192_proc = NULL; + +static int proc_get_stats_ap(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + struct rtllib_network *target; + + int len = 0; + + list_for_each_entry(target, &ieee->network_list, list) { + + len += snprintf(page + len, count - len, + "%s ", target->ssid); + + if (target->wpa_ie_len>0 || target->rsn_ie_len>0){ + len += snprintf(page + len, count - len, + "WPA\n"); + } + else{ + len += snprintf(page + len, count - len, + "non_WPA\n"); + } + + } + + *eof = 1; + return len; +} + +static int proc_get_registers_0(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x000; + +#ifdef RTL8192SE + /* This dump the current register page */ + if (!IS_BB_REG_OFFSET_92S(page0)){ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + }else +#endif + { + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;n++,i++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x100; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x200; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x300; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_4(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x400; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_5(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x500; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_6(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x600; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_7(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x700; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, + "\nD: %2x > ",n); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2.2x ",read_nic_byte(dev,(page0|n))); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_8(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x800; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; + +} +static int proc_get_registers_9(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0x900; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_registers_a(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0xa00; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_registers_b(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0xb00; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_registers_c(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0xc00; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_registers_d(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0xd00; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_registers_e(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n,page0; + + int max=0xff; + page0 = 0xe00; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", (page0>>8)); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_reg_rf_a(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n; + + int max=0xff; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### RF-A ##################\n "); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,n, bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_reg_rf_b(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n; + + int max=0xff; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### RF-B ##################\n "); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_B, n, bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_reg_rf_c(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n; + + int max=0xff; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### RF-C ##################\n "); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_C, n, bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_reg_rf_d(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + + int len = 0; + int i,n; + + int max=0xff; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### RF-D ##################\n "); + for (n=0;n<=max;) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",n); + for (i=0;i<4 && n<=max;n+=4,i++) + len += snprintf(page + len, count - len, + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_D, n, bMaskDWord)); + } + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_cam_register_1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + u32 target_command=0; + u32 target_content=0; + u8 entry_i=0; + u32 ulStatus; + int len = 0; + int i=100, j = 0; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### SECURITY CAM (0-10) ##################\n "); + for (j=0; j<11; j++) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",j); + for (entry_i=0;entry_i=0) + { + ulStatus = read_nic_dword(dev, RWCAM); + if (ulStatus & BIT31){ + continue; + } + else{ + break; + } + } + write_nic_dword(dev, RWCAM, target_command); + target_content = read_nic_dword(dev, RCAMO); + len += snprintf(page + len, count - len,"%8.8x ",target_content); + } + } + + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_cam_register_2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + u32 target_command=0; + u32 target_content=0; + u8 entry_i=0; + u32 ulStatus; + int len = 0; + int i=100, j = 0; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### SECURITY CAM (11-21) ##################\n "); + for (j=11; j<22; j++) + { + len += snprintf(page + len, count - len, "\nD: %2x > ",j); + for (entry_i=0;entry_i=0) + { + ulStatus = read_nic_dword(dev, RWCAM); + if (ulStatus & BIT31){ + continue; + } + else{ + break; + } + } + write_nic_dword(dev, RWCAM, target_command); + target_content = read_nic_dword(dev, RCAMO); + len += snprintf(page + len, count - len,"%8.8x ",target_content); + } + } + + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} + +static int proc_get_cam_register_3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + u32 target_command=0; + u32 target_content=0; + u8 entry_i=0; + u32 ulStatus; + int len = 0; + int i=100, j = 0; + + /* This dump the current register page */ + len += snprintf(page + len, count - len, + "\n#################### SECURITY CAM (22-31) ##################\n "); + for (j=22; j ",j); + for (entry_i=0;entry_i=0) + { + ulStatus = read_nic_dword(dev, RWCAM); + if (ulStatus & BIT31){ + continue; + } + else{ + break; + } + } + write_nic_dword(dev, RWCAM, target_command); + target_content = read_nic_dword(dev, RCAMO); + len += snprintf(page + len, count - len,"%8.8x ",target_content); + } + } + + len += snprintf(page + len, count - len,"\n"); + *eof = 1; + return len; +} +static int proc_get_stats_tx(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + int len = 0; + + len += snprintf(page + len, count - len, + "TX VI priority ok int: %lu\n" + "TX VO priority ok int: %lu\n" + "TX BE priority ok int: %lu\n" + "TX BK priority ok int: %lu\n" + "TX MANAGE priority ok int: %lu\n" + "TX BEACON priority ok int: %lu\n" + "TX BEACON priority error int: %lu\n" + "TX CMDPKT priority ok int: %lu\n" + "TX queue stopped?: %d\n" + "TX fifo overflow: %lu\n" + "TX total data packets %lu\n" + "TX total data bytes :%lu\n", + priv->stats.txviokint, + priv->stats.txvookint, + priv->stats.txbeokint, + priv->stats.txbkokint, + priv->stats.txmanageokint, + priv->stats.txbeaconokint, + priv->stats.txbeaconerr, + priv->stats.txcmdpktokint, + netif_queue_stopped(dev), + priv->stats.txoverflow, + priv->rtllib->stats.tx_packets, + priv->rtllib->stats.tx_bytes + + + ); + + *eof = 1; + return len; +} + + + +static int proc_get_stats_rx(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + int len = 0; + + len += snprintf(page + len, count - len, + "RX packets: %lu\n" + "RX data crc err: %lu\n" + "RX mgmt crc err: %lu\n" + "RX desc err: %lu\n" + "RX rx overflow error: %lu\n", + priv->stats.rxint, + priv->stats.rxdatacrcerr, + priv->stats.rxmgmtcrcerr, + priv->stats.rxrdu, + priv->stats.rxoverflow); + + *eof = 1; + return len; +} + +void rtl8192_proc_module_init(void) +{ + RT_TRACE(COMP_INIT, "Initializing proc filesystem"); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, proc_net); +#else + rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); +#endif +} + + +void rtl8192_proc_module_remove(void) +{ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + remove_proc_entry(DRV_NAME, proc_net); +#else + remove_proc_entry(DRV_NAME, init_net.proc_net); +#endif +} + + +void rtl8192_proc_remove_one(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + printk("dev name %s\n",dev->name); + + if (priv->dir_dev) { + remove_proc_entry("stats-tx", priv->dir_dev); + remove_proc_entry("stats-rx", priv->dir_dev); + remove_proc_entry("stats-ap", priv->dir_dev); + remove_proc_entry("registers-0", priv->dir_dev); + remove_proc_entry("registers-1", priv->dir_dev); + remove_proc_entry("registers-2", priv->dir_dev); + remove_proc_entry("registers-3", priv->dir_dev); + remove_proc_entry("registers-4", priv->dir_dev); + remove_proc_entry("registers-5", priv->dir_dev); + remove_proc_entry("registers-6", priv->dir_dev); + remove_proc_entry("registers-7", priv->dir_dev); + remove_proc_entry("registers-8", priv->dir_dev); + remove_proc_entry("registers-9", priv->dir_dev); + remove_proc_entry("registers-a", priv->dir_dev); + remove_proc_entry("registers-b", priv->dir_dev); + remove_proc_entry("registers-c", priv->dir_dev); + remove_proc_entry("registers-d", priv->dir_dev); + remove_proc_entry("registers-e", priv->dir_dev); + remove_proc_entry("RF-A", priv->dir_dev); + remove_proc_entry("RF-B", priv->dir_dev); + remove_proc_entry("RF-C", priv->dir_dev); + remove_proc_entry("RF-D", priv->dir_dev); + remove_proc_entry("SEC-CAM-1", priv->dir_dev); + remove_proc_entry("SEC-CAM-2", priv->dir_dev); + remove_proc_entry("SEC-CAM-3", priv->dir_dev); + remove_proc_entry("wlan0", rtl8192_proc); + priv->dir_dev = NULL; + } +} + + +void rtl8192_proc_init_one(struct net_device *dev) +{ + struct proc_dir_entry *e; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, + rtl8192_proc); + if (!priv->dir_dev) { + RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", + dev->name); + return; + } + e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_rx, dev); + + if (!e) { + RT_TRACE(COMP_ERR,"Unable to initialize " + "/proc/net/rtl8192/%s/stats-rx\n", + dev->name); + } + + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_tx, dev); + + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/stats-tx\n", + dev->name); + } + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_stats_ap, dev); + + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/stats-ap\n", + dev->name); + } + + e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_0, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-0\n", + dev->name); + } + e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_1, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-1\n", + dev->name); + } + e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_2, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-2\n", + dev->name); + } + e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_3, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-3\n", + dev->name); + } + e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_4, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-4\n", + dev->name); + } + e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_5, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-5\n", + dev->name); + } + e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_6, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-6\n", + dev->name); + } + e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_7, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-7\n", + dev->name); + } + e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_8, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-8\n", + dev->name); + } + e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_9, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-9\n", + dev->name); + } + e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_a, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-a\n", + dev->name); + } + e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_b, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-b\n", + dev->name); + } + e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_c, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-c\n", + dev->name); + } + e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_d, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-d\n", + dev->name); + } + e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_registers_e, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/registers-e\n", + dev->name); + } + e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_reg_rf_a, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/RF-A\n", + dev->name); + } + e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_reg_rf_b, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/RF-B\n", + dev->name); + } + e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_reg_rf_c, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/RF-C\n", + dev->name); + } + e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_reg_rf_d, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/RF-D\n", + dev->name); + } + e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_cam_register_1, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/SEC-CAM-1\n", + dev->name); + } + e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_cam_register_2, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/SEC-CAM-2\n", + dev->name); + } + e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_cam_register_3, dev); + if (!e) { + RT_TRACE(COMP_ERR, "Unable to initialize " + "/proc/net/rtl8192/%s/SEC-CAM-3\n", + dev->name); + } +} diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h new file mode 100644 index 00000000000..5ae7c7d07de --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -0,0 +1,319 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef _RTL_DEBUG_H +#define _RTL_DEBUG_H +#include +#include +#include +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)) +#include +#endif + +struct r8192_priv; +struct _tx_desc_8192se; +struct _TX_DESC_8192CE; +struct net_device; + +#define DBG_LOUD 4 + +#define RT_ASSERT(_Exp,Fmt) \ + if (!(_Exp)) \ + { \ + printk("Rtl819x: "); \ + printk Fmt; \ + } + +typedef enum tag_DBGP_Flag_Type_Definition +{ + FQoS = 0, + FTX = 1, + FRX = 2, + FSEC = 3, + FMGNT = 4, + FMLME = 5, + FRESOURCE = 6, + FBEACON = 7, + FISR = 8, + FPHY = 9, + FMP = 10, + FEEPROM = 11, + FPWR = 12, + FDM = 13, + FDBGCtrl = 14, + FC2H = 15, + FBT = 16, + FINIT = 17, + FIOCTL = 18, + DBGP_TYPE_MAX +}DBGP_FLAG_E; + +#define QoS_INIT BIT0 +#define QoS_VISTA BIT1 + +#define TX_DESC BIT0 +#define TX_DESC_TID BIT1 + +#define RX_DATA BIT0 +#define RX_PHY_STS BIT1 +#define RX_PHY_SS BIT2 +#define RX_PHY_SQ BIT3 +#define RX_PHY_ASTS BIT4 +#define RX_ERR_LEN BIT5 +#define RX_DEFRAG BIT6 +#define RX_ERR_RATE BIT7 + + + +#define MEDIA_STS BIT0 +#define LINK_STS BIT1 + +#define OS_CHK BIT0 + +#define BCN_SHOW BIT0 +#define BCN_PEER BIT1 + +#define ISR_CHK BIT0 + +#define PHY_BBR BIT0 +#define PHY_BBW BIT1 +#define PHY_RFR BIT2 +#define PHY_RFW BIT3 +#define PHY_MACR BIT4 +#define PHY_MACW BIT5 +#define PHY_ALLR BIT6 +#define PHY_ALLW BIT7 +#define PHY_TXPWR BIT8 +#define PHY_PWRDIFF BIT9 + +#define MP_RX BIT0 +#define MP_SWICH_CH BIT1 + +#define EEPROM_W BIT0 +#define EFUSE_PG BIT1 +#define EFUSE_READ_ALL BIT2 + +#define LPS BIT0 +#define IPS BIT1 +#define PWRSW BIT2 +#define PWRHW BIT3 +#define PWRHAL BIT4 + +#define WA_IOT BIT0 +#define DM_PWDB BIT1 +#define DM_Monitor BIT2 +#define DM_DIG BIT3 +#define DM_EDCA_Turbo BIT4 + +#define DbgCtrl_Trace BIT0 +#define DbgCtrl_InbandNoise BIT1 + +#define BT_TRACE BIT0 +#define BT_RFPoll BIT1 + +#define C2H_Summary BIT0 +#define C2H_PacketData BIT1 +#define C2H_ContentData BIT2 +#define BT_TRACE BIT0 +#define BT_RFPoll BIT1 + +#define INIT_EEPROM BIT0 +#define INIT_TxPower BIT1 +#define INIT_IQK BIT2 +#define INIT_RF BIT3 + +#define IOCTL_TRACE BIT0 +#define IOCTL_BT_EVENT BIT1 +#define IOCTL_BT_EVENT_DETAIL BIT2 +#define IOCTL_BT_TX_ACLDATA BIT3 +#define IOCTL_BT_TX_ACLDATA_DETAIL BIT4 +#define IOCTL_BT_RX_ACLDATA BIT5 +#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 +#define IOCTL_BT_HCICMD BIT7 +#define IOCTL_BT_HCICMD_DETAIL BIT8 +#define IOCTL_IRP BIT9 +#define IOCTL_IRP_DETAIL BIT10 +#define IOCTL_CALLBACK_FUN BIT11 +#define IOCTL_STATE BIT12 +#define IOCTL_BT_TP BIT13 +#define IOCTL_BT_LOGO BIT14 + +/* 2007/07/13 MH ------For DeBuG Print modeue------*/ +/*------------------------------Define structure----------------------------*/ + + +/*------------------------Export Marco Definition---------------------------*/ +#define DEBUG_PRINT 1 + +#if (DEBUG_PRINT == 1) +#define RTPRINT(dbgtype, dbgflag, printstr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag)\ + { \ + printk printstr; \ + } \ +} + +#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\ +{\ + if (DBGP_Type[dbgtype] & dbgflag)\ + {\ + int __i; \ + u8* ptr = (u8*)_Ptr; \ + printk printstr; \ + printk(" "); \ + for ( __i=0; __i<6; __i++ ) \ + printk("%02X%s", ptr[__i], (__i==5)?"":"-"); \ + printk("\n"); \ + }\ +} + +#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\ +{\ + if (DBGP_Type[dbgtype] & dbgflag)\ + {\ + int __i; \ + u8* ptr = (u8*)_HexData; \ + printk(_TitleString); \ + for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ + { \ + printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\ + if (((__i + 1) % 16) == 0) printk("\n");\ + } \ + printk("\n"); \ + }\ +} +#else +#define RTPRINT(dbgtype, dbgflag, printstr) +#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) +#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) +#endif + +extern u32 DBGP_Type[DBGP_TYPE_MAX]; + +#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ +do {\ + if (((_Comp) & rt_global_debug_component ) && (_Level <= rt_global_debug_component )) \ + { \ + int __i; \ + u8* ptr = (u8*)_HexData; \ + printk("Rtl819x: "); \ + printk(_TitleString); \ + for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ + { \ + printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \ + if (((__i + 1) % 16) == 0) printk("\n"); \ + } \ + printk("\n"); \ + } \ +}while(0); + +#define DMESG(x,a...) +#define DMESGW(x,a...) +#define DMESGE(x,a...) +extern u32 rt_global_debug_component; +#define RT_TRACE(component, x, args...) \ +do { if (rt_global_debug_component & component) \ + printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ + ##args);\ +}while(0); + +#define RTL819x_DEBUG +#ifdef RTL819x_DEBUG +#define assert(expr) \ + if (!(expr)) { \ + printk( "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr,__FILE__,__func__,__LINE__); \ + } +#define RT_DEBUG_DATA(level, data, datalen) \ + do{ if ((rt_global_debug_component & (level)) == (level)) \ + { \ + int _i; \ + u8* _pdata = (u8*) data; \ + printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ + for (_i=0; _i<(int)(datalen); _i++) \ + { \ + printk("%2x ", _pdata[_i]); \ + if ((_i+1)%16 == 0) printk("\n"); \ + } \ + printk("\n"); \ + } \ + } while (0) +#else +#define assert(expr) do {} while (0) +#define RT_DEBUG_DATA(level, data, datalen) do {} while(0) +#endif + +typedef struct _rtl_fs_debug +{ + const char *name; + struct dentry *dir_drv; + struct dentry *debug_register; + u32 hw_type; + u32 hw_offset; +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)) + bool hw_holding; +#else + u8 hw_holding; +#endif +} rtl_fs_debug; + +void print_buffer(u32 *buffer, int len); +void dump_eprom(struct net_device *dev); +void rtl8192_dump_reg(struct net_device *dev); + +#ifdef RTL8192SE +void rtl8192se_dump_tx_desc(struct _tx_desc_8192se *pDesc); +#endif +#ifdef RTL8192CE +void rtl8192ce_dump_tx_desc(struct _TX_DESC_8192CE *pDesc); +#endif + +/* debugfs stuff */ +#ifdef CONFIG_RTLWIFI_DEBUGFS +int rtl_debug_module_init(struct r8192_priv *priv, const char *name); +void rtl_debug_module_remove(struct r8192_priv *priv); +int rtl_create_debugfs_root(void); +void rtl_remove_debugfs_root(void); +#else +static inline int rtl_debug_module_init(struct r8192_priv *priv, const char *name) { + return 0; +} +static inline void rtl_debug_module_remove(struct r8192_priv *priv) { + +} +static inline int rtl_create_debugfs_root(void) { + return 0; +} +static inline void rtl_remove_debugfs_root(void) { +} +#endif + +/* proc stuff */ +void rtl8192_proc_init_one(struct net_device *dev); +void rtl8192_proc_remove_one(struct net_device *dev); +void rtl8192_proc_module_init(void); +void rtl8192_proc_module_remove(void); +void rtl8192_dbgp_flag_init(struct net_device *dev); +#endif diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c new file mode 100644 index 00000000000..5ea11c520c0 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -0,0 +1,4854 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtl_core.h" +#include "rtl_dm.h" +#include "r8192E_hw.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" +#include "r8192E_cmdpkt.h" + +/*---------------------------Define Local Constant---------------------------*/ +#ifdef RTL8190P +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0x5e4322, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 + }; + +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0x5e4322, + 0x5e4322, + 0x5e4322 +}; + +#elif defined RTL8192E +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0x5e4322, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4332 + }; + +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0x5e4322, + 0x5e4322, + 0x5e4332 +}; + +#elif defined(RTL8192SE) +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = +{ 0xa44f, + 0x5ea44f, + 0x5ea44f, + 0xa630, + 0xa44f, + 0xa630, + 0xa630, + 0xa42b, + 0x5e4322, + 0x5e4322 + }; + +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = + +{ 0x4322, + 0xa44f, + 0x5ea44f, + 0xa42b, + 0x5e4322, + 0x4322, + 0xa430, + 0x5ea44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = +{ 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5ea322, + 0x5ea422, + 0x5ea322, + 0x3ea44f, + 0x5ea44f, + 0x5e4322, + 0x5e4322 + }; +#endif + +#define RTK_UL_EDCA 0xa44f +#define RTK_DL_EDCA 0x5e4322 +/*---------------------------Define Local Constant---------------------------*/ + + +/*------------------------Define global variable-----------------------------*/ +dig_t dm_digtable; +u8 dm_shadow[16][256] = {{0}}; +DRxPathSel DM_RxPathSelTable; +/*------------------------Define global variable-----------------------------*/ + + +/*------------------------Define local variable------------------------------*/ +/*------------------------Define local variable------------------------------*/ + + +/*--------------------Define export function prototype-----------------------*/ +extern void init_hal_dm(struct net_device *dev); +extern void deinit_hal_dm(struct net_device *dev); + +extern void hal_dm_watchdog(struct net_device *dev); + + +extern void init_rate_adaptive(struct net_device *dev); +extern void dm_txpower_trackingcallback(void *data); + +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value); +extern void DM_ChangeFsyncSetting(struct net_device *dev, + s32 DM_Type, + s32 DM_Value); +extern void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, + u32 force_value); +extern void dm_init_edca_turbo(struct net_device *dev); +extern void dm_rf_operation_test_callback(unsigned long data); +extern void dm_rf_pathcheck_workitemcallback(void *data); +extern void dm_fsync_timer_callback(unsigned long data); +extern void dm_check_fsync(struct net_device *dev); +extern void dm_shadow_init(struct net_device *dev); +extern void dm_initialize_txpower_tracking(struct net_device *dev); + +#if (defined RTL8192E || defined RTL8192SE) +extern void dm_CheckRfCtrlGPIO(void *data); +#endif + +#ifdef RTL8192SE +extern void DM_TXPowerTracking92SDirectCall(struct net_device *dev); +static void dm_CtrlInitGainByTwoPort(struct net_device *dev); +static void dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(struct net_device *dev); +static void dm_initial_gain_STABeforeConnect(struct net_device *dev); + +void dm_InitRateAdaptiveMask(struct net_device *dev); +void Adhoc_InitRateAdaptive(struct net_device *dev,struct sta_info *pEntry); +#endif + +/*--------------------Define export function prototype-----------------------*/ + + +/*---------------------Define local function prototype-----------------------*/ +static void dm_check_rate_adaptive(struct net_device *dev); + +static void dm_init_bandwidth_autoswitch (struct net_device *dev); +static void dm_bandwidth_autoswitch ( struct net_device *dev); + + +static void dm_check_txpower_tracking(struct net_device *dev); + + + + + +#if defined(RTL8192E)||defined(RTL8190P) +static void dm_bb_initialgain_restore(struct net_device *dev); + + +static void dm_bb_initialgain_backup(struct net_device *dev); +#endif + +static void dm_dig_init(struct net_device *dev); +static void dm_ctrl_initgain_byrssi(struct net_device *dev); +static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev); +static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev); +static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev); +static void dm_initial_gain(struct net_device *dev); +static void dm_pd_th(struct net_device *dev); +static void dm_cs_ratio(struct net_device *dev); + +static void dm_init_ctstoself(struct net_device *dev); +static void dm_Init_WA_Broadcom_IOT(struct net_device *dev); +#ifdef RTL8192SE +static void dm_WA_Broadcom_IOT(struct net_device *dev); +#endif + +static void dm_check_edca_turbo(struct net_device *dev); + +#ifndef RTL8190P +#endif +static void dm_check_pbc_gpio(struct net_device *dev); + + +static void dm_check_rx_path_selection(struct net_device *dev); +static void dm_init_rxpath_selection(struct net_device *dev); +static void dm_rxpath_sel_byrssi(struct net_device *dev); + + +static void dm_init_fsync(struct net_device *dev); +static void dm_deInit_fsync(struct net_device *dev); + +static void dm_check_txrateandretrycount(struct net_device *dev); +static void dm_check_ac_dc_power(struct net_device *dev); + +/*---------------------Define local function prototype-----------------------*/ + +static void dm_init_dynamic_txpower(struct net_device *dev); +static void dm_dynamic_txpower(struct net_device *dev); + + +static void dm_send_rssi_tofw(struct net_device *dev); +static void dm_ctstoself(struct net_device *dev); +#if defined RTL8192SE +static void dm_RefreshRateAdaptiveMask(struct net_device *dev); +#endif +/*---------------------------Define function prototype------------------------*/ + +extern void +init_hal_dm(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + priv->DM_Type = DM_Type_ByDriver; + + priv->undecorated_smoothed_pwdb = -1; + + dm_init_dynamic_txpower(dev); + +#ifdef RTL8192SE + if (IS_HARDWARE_TYPE_8192SE(dev)) + dm_InitRateAdaptiveMask(dev); + else +#endif + init_rate_adaptive(dev); + + dm_dig_init(dev); + dm_init_edca_turbo(dev); + dm_init_bandwidth_autoswitch (dev); + dm_init_fsync(dev); + dm_init_rxpath_selection(dev); + dm_init_ctstoself(dev); + if (IS_HARDWARE_TYPE_8192SE(dev)) + dm_Init_WA_Broadcom_IOT(dev); + +#if (defined RTL8192E || defined RTL8192SE) + INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO,dev); +#endif + +} + +extern void deinit_hal_dm(struct net_device *dev) +{ + + dm_deInit_fsync(dev); + +} + + +#ifdef USB_RX_AGGREGATION_SUPPORT +void dm_CheckRxAggregation(struct net_device *dev) { + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + static unsigned long lastTxOkCnt = 0; + static unsigned long lastRxOkCnt = 0; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; + + curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; + curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; + + if ((curTxOkCnt + curRxOkCnt) < 15000000) { + return; + } + + if (curTxOkCnt > 4*curRxOkCnt) { + if (priv->bCurrentRxAggrEnable) { + write_nic_dword(dev, 0x1a8, 0); + priv->bCurrentRxAggrEnable = false; + } + }else{ + if (!priv->bCurrentRxAggrEnable && !pHTInfo->bCurrentRT2RTAggregation) { + u32 ulValue; + ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) | + (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout); + write_nic_dword(dev, 0x1a8, ulValue); + priv->bCurrentRxAggrEnable = true; + } + } + + lastTxOkCnt = priv->stats.txbytesunicast; + lastRxOkCnt = priv->stats.rxbytesunicast; +} +#endif + + + +extern void hal_dm_watchdog(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + if (priv->being_init_adapter) + return; + + dm_check_ac_dc_power(dev); + + dm_check_pbc_gpio(dev); + dm_check_txrateandretrycount(dev); + dm_check_edca_turbo(dev); + + if (IS_HARDWARE_TYPE_8192SE(dev)){ +#ifdef RTL8192SE + dm_RefreshRateAdaptiveMask(dev); + dm_WA_Broadcom_IOT(dev); + return; +#endif + } + dm_check_rate_adaptive(dev); + dm_dynamic_txpower(dev); + dm_check_txpower_tracking(dev); + + dm_ctrl_initgain_byrssi(dev); + dm_bandwidth_autoswitch (dev); + + dm_check_rx_path_selection(dev); + dm_check_fsync(dev); + + dm_send_rssi_tofw(dev); + dm_ctstoself(dev); + +#ifdef USB_RX_AGGREGATION_SUPPORT + dm_CheckRxAggregation(dev); +#endif +} + +void dm_check_ac_dc_power(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; + char *argv[] = {ac_dc_check_script_path,DRV_NAME,NULL}; + static char *envp[] = {"HOME=/", + "TERM=linux", + "PATH=/usr/bin:/bin", + NULL}; + + if (priv->ResetProgress == RESET_TYPE_SILENT) + { + RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); + return; + } + + if (priv->rtllib->state != RTLLIB_LINKED) { + return; + } + call_usermodehelper(ac_dc_check_script_path,argv,envp,1); + + return; +}; + + +extern void init_rate_adaptive(struct net_device * dev) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; + + pra->ratr_state = DM_RATR_STA_MAX; + pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; + pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; + pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; + + pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; + pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; + pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; + + if (priv->CustomerID == RT_CID_819x_Netcore) + pra->ping_rssi_enable = 1; + else + pra->ping_rssi_enable = 0; + pra->ping_rssi_thresh_for_ra = 15; + + + if (priv->rf_type == RF_2T4R) + { + pra->upper_rssi_threshold_ratr = 0x8f0f0000; + pra->middle_rssi_threshold_ratr = 0x8f0ff000; + pra->low_rssi_threshold_ratr = 0x8f0ff001; + pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; + pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; + pra->ping_rssi_ratr = 0x0000000d; + } + else if (priv->rf_type == RF_1T2R) + { + pra->upper_rssi_threshold_ratr = 0x000fc000; + pra->middle_rssi_threshold_ratr = 0x000ff000; + pra->low_rssi_threshold_ratr = 0x000ff001; + pra->low_rssi_threshold_ratr_40M = 0x000ff005; + pra->low_rssi_threshold_ratr_20M = 0x000ff001; + pra->ping_rssi_ratr = 0x0000000d; + } + +} + + +static void dm_check_rate_adaptive(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; + u32 currentRATR, targetRATR = 0; + u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; + bool bshort_gi_enabled = false; + static u8 ping_rssi_state=0; + + if (IS_NIC_DOWN(priv)){ + RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); + return; + } + + if (pra->rate_adaptive_disabled) + return; + + if ( !(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; + + if ( priv->rtllib->state == RTLLIB_LINKED ) + { + + bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || + (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); + + + pra->upper_rssi_threshold_ratr = + (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + + pra->middle_rssi_threshold_ratr = + (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + pra->low_rssi_threshold_ratr = + (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + } + else + { + pra->low_rssi_threshold_ratr = + (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + } + pra->ping_rssi_ratr = + (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + + if (pra->ratr_state == DM_RATR_STA_HIGH) + { + HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? + (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); + } + else if (pra->ratr_state == DM_RATR_STA_LOW) + { + HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? + (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); + } + else + { + HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? + (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); + } + + if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) + { + pra->ratr_state = DM_RATR_STA_HIGH; + targetRATR = pra->upper_rssi_threshold_ratr; + }else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) + { + pra->ratr_state = DM_RATR_STA_MIDDLE; + targetRATR = pra->middle_rssi_threshold_ratr; + }else + { + pra->ratr_state = DM_RATR_STA_LOW; + targetRATR = pra->low_rssi_threshold_ratr; + } + + if (pra->ping_rssi_enable) + { + if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) + { + if ( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || + ping_rssi_state ) + { + pra->ratr_state = DM_RATR_STA_LOW; + targetRATR = pra->ping_rssi_ratr; + ping_rssi_state = 1; + } + } + else + { + ping_rssi_state = 0; + } + } + +#if 1 + if (priv->rtllib->GetHalfNmodeSupportByAPsHandler(dev)) + targetRATR &= 0xf00fffff; +#endif + + currentRATR = read_nic_dword(dev, RATR0); + if ( targetRATR != currentRATR ) + { + u32 ratr_value; + ratr_value = targetRATR; + RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR); + if (priv->rf_type == RF_1T2R) + { + ratr_value &= ~(RATE_ALL_OFDM_2SS); + } + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + + pra->last_ratr = targetRATR; + } + + } + else + { + pra->ratr_state = DM_RATR_STA_MAX; + } + +} + +static void dm_init_bandwidth_autoswitch (struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH; + priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW; + priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; + priv->rtllib->bandwidth_auto_switch.bautoswitch_enable = false; + +} + + +static void dm_bandwidth_autoswitch (struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->rtllib->bandwidth_auto_switch.bautoswitch_enable){ + return; + }else{ + if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false){ + if (priv->undecorated_smoothed_pwdb <= priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) + priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true; + }else{ + if (priv->undecorated_smoothed_pwdb >= priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) + priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; + + } + } +} + +#ifdef Rtl8192SE +u32 OFDMSwingTable[OFDM_Table_Length] = { + 0x7f8001fe, + 0x788001e2, + 0x71c001c7, + 0x6b8001ae, + 0x65400195, + 0x5fc0017f, + 0x5a400169, + 0x55400155, + 0x50800142, + 0x4c000130, + 0x47c0011f, + 0x43c0010f, + 0x40000100, + 0x3c8000f2, + 0x390000e4, + 0x35c000d7, + 0x32c000cb, + 0x300000c0, + 0x2d4000b5, + 0x2ac000ab, + 0x288000a2, + 0x26000098, + 0x24000090, + 0x22000088, + 0x20000080, + 0x1e400079, + 0x1c800072, + 0x1b00006c, + 0x19800066, + 0x18000060, + 0x16c0005b, + 0x15800056, + 0x14400051, + 0x1300004c, + 0x12000048, + 0x11000044, + 0x10000040, +}; + +u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, + {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, + {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, + {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, + {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, + {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, + {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, + {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, + {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, + {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, + {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, + {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, + {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, + {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, + {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, + {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, + {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, + {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, + {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, + {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, + {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, + {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} +}; + + +u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, + {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, + {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, + {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, + {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, + {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, + {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, + {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, + {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, + {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, + {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, + {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, + {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, + {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, + {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, + {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, + {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, + {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, + {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, + {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, + {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, + {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} +}; +#elif defined RTL8192E +static u32 OFDMSwingTable[OFDM_Table_Length] = { + 0x7f8001fe, + 0x71c001c7, + 0x65400195, + 0x5a400169, + 0x50800142, + 0x47c0011f, + 0x40000100, + 0x390000e4, + 0x32c000cb, + 0x2d4000b5, + 0x288000a2, + 0x24000090, + 0x20000080, + 0x1c800072, + 0x19800066, + 0x26c0005b, + 0x24400051, + 0x12000048, + 0x10000040 +}; +static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} +}; + +static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} +}; +#endif +#define Pw_Track_Flag 0x11d +#define Tssi_Mea_Value 0x13c +#define Tssi_Report_Value1 0x134 +#define Tssi_Report_Value2 0x13e +#define FW_Busy_Flag 0x13f + +#ifndef RTL8192SE +static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) + { + struct r8192_priv *priv = rtllib_priv(dev); + bool bHighpowerstate, viviflag = false; + DCMD_TXCMD_T tx_cmd; + u8 powerlevelOFDM24G; + int i =0, j = 0, k = 0; + u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; + u32 Value; + u8 Pwr_Flag; + u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; +#ifdef RTL8192U + RT_STATUS rtStatus = RT_STATUS_SUCCESS; +#endif + u32 delta=0; + RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + priv->rtllib->bdynamic_txpower_enable = false; + bHighpowerstate = priv->bDynamicTxHighPower; + + powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24); + RF_Type = priv->rf_type; + Value = (RF_Type<<8) | powerlevelOFDM24G; + + RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); + + +#ifdef RTL8190P + for (j = 0; j<1; j++) +#else + for (j = 0; j<=30; j++) +#endif +{ + + tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; + tx_cmd.Length = 4; + tx_cmd.Value = Value; +#ifdef RTL8192U + rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12); + if (rtStatus == RT_STATUS_FAILURE) + { + RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n"); + } +#else + cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); +#endif + mdelay(1); + for (i = 0;i <= 30; i++) + { + Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); + + if (Pwr_Flag == 0) + { + mdelay(1); + + if (priv->bResetInProgress) + { + RT_TRACE(COMP_POWER_TRACKING, "we are in slient reset progress, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } +#ifdef RTL8192E + if ((priv->rtllib->eRFPowerState != eRfOn)) + { + RT_TRACE(COMP_POWER_TRACKING, "we are in power save, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + +#endif + continue; + } + + Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + + if (Avg_TSSI_Meas == 0) + { + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + + for (k = 0;k < 5; k++) + { + if (k !=4) + tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value1+k); + else + tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value2); + + RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]); + + { + if (tmp_report[k] <= 20) + { + viviflag =true; + break; + } + } + } + + if (viviflag ==true) + { + write_nic_byte(dev, Pw_Track_Flag, 0); + viviflag = false; + RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); + for (k = 0;k < 5; k++) + tmp_report[k] = 0; + break; + } + + for (k = 0;k < 5; k++) + { + Avg_TSSI_Meas_from_driver += tmp_report[k]; + } + + Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; + RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); + TSSI_13dBm = priv->TSSI_13dBm; + RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); + + if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) + delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; + else + delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; + + if (delta <= E_FOR_TX_POWER_TRACK) + { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); +#ifdef RTL8190P + RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real); +#endif + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); + return; + } + else + { + if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) + { + if (RF_Type == RF_2T4R) + { + + if ((priv->rfa_txpowertrackingindex > 0) &&(priv->rfc_txpowertrackingindex > 0)) + { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) + { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + + priv->rfc_txpowertrackingindex--; + if (priv->rfc_txpowertrackingindex_real > 4) + { + priv->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + } + else + { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } + } + else + { + { +#ifdef RTL8190P + { + if (priv->rfc_txpowertrackingindex > 0) + { + priv->rfc_txpowertrackingindex--; + if (priv->rfc_txpowertrackingindex_real > 4) + { + priv->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + } + else + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } +#endif +#ifdef RTL8192E + { + if (priv->rfa_txpowertrackingindex > 0) + { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) + { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + } + else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } +#endif + } + + } + } + else + { + if (RF_Type == RF_2T4R) + { + if ((priv->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&(priv->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) + { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + priv->rfc_txpowertrackingindex++; + priv->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + else + { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } + else + { + { +#ifdef RTL8190P + { + if (priv->rfc_txpowertrackingindex < (TxBBGainTableLength - 1)) + { + priv->rfc_txpowertrackingindex++; + priv->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + else + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } +#endif +#ifdef RTL8192E + { + if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) + { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } +#endif + } + } + } + if (RF_Type == RF_2T4R){ + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; + }else{ + { +#ifdef RTL8190P + priv->CCKPresentAttentuation_difference + = priv->rfc_txpowertrackingindex - priv->rfc_txpowertracking_default; +#endif +#ifdef RTL8192E + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; +#endif + } + } + + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + priv->CCKPresentAttentuation + = priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; + else + priv->CCKPresentAttentuation + = priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + if (priv->CCKPresentAttentuation > -1&&priv->CCKPresentAttentuation < CCKTxBBGainTableLength) + { + if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + else + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + } + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); +#ifdef RTL8190P + RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real); +#endif + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); + + if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24) + { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); + return; + } + + + } + write_nic_byte(dev, Pw_Track_Flag, 0); + Avg_TSSI_Meas_from_driver = 0; + for (k = 0;k < 5; k++) + tmp_report[k] = 0; + break; + } + write_nic_byte(dev, FW_Busy_Flag, 0); +} + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); +} +#endif + +#ifdef RTL8192E +static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) +{ +#define ThermalMeterVal 9 + struct r8192_priv *priv = rtllib_priv(dev); + u32 tmpRegA, TempCCk; + u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; + int i =0, CCKSwingNeedUpdate=0; + + if (!priv->btxpower_trackingInit) + { + tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + for (i=0; iOFDM_index[0]= (u8)i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n", + rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]); + } + } + + TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + for (i=0 ; iCCK_index =(u8) i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n", + rCCK0_TxFilter1, TempCCk, priv->CCK_index); + break; + } +} + priv->btxpower_trackingInit = true; + return; + } + + tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); + RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA); + if (tmpRegA < 3 || tmpRegA > 13) + return; + if (tmpRegA >= 12) + tmpRegA = 12; + RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA); + priv->ThermalMeter[0] = ThermalMeterVal; + priv->ThermalMeter[1] = ThermalMeterVal; + + if (priv->ThermalMeter[0] >= (u8)tmpRegA) + { + tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA); + tmpCCK40Mindex = tmpCCK20Mindex - 6; + if (tmpOFDMindex >= OFDM_Table_Length) + tmpOFDMindex = OFDM_Table_Length-1; + if (tmpCCK20Mindex >= CCK_Table_length) + tmpCCK20Mindex = CCK_Table_length-1; + if (tmpCCK40Mindex >= CCK_Table_length) + tmpCCK40Mindex = CCK_Table_length-1; + } + else + { + tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]); + if (tmpval >= 6) + tmpOFDMindex = tmpCCK20Mindex = 0; + else + tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval; + tmpCCK40Mindex = 0; + } + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + tmpCCKindex = tmpCCK40Mindex; + else + tmpCCKindex = tmpCCK20Mindex; + + priv->Record_CCK_20Mindex = tmpCCK20Mindex; + priv->Record_CCK_40Mindex = tmpCCK40Mindex; + RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", + priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); + + if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = true; + CCKSwingNeedUpdate = 1; + } + else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + { + priv->bcck_in_ch14 = false; + CCKSwingNeedUpdate = 1; + } + + if (priv->CCK_index != tmpCCKindex) +{ + priv->CCK_index = tmpCCKindex; + CCKSwingNeedUpdate = 1; + } + + if (CCKSwingNeedUpdate) + { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } + if (priv->OFDM_index[0] != tmpOFDMindex) + { + priv->OFDM_index[0] = tmpOFDMindex; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index[0]]); + RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", + priv->OFDM_index[0], OFDMSwingTable[priv->OFDM_index[0]]); + } + priv->txpower_count = 0; +} +#elif defined (RTL8192SE) +static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 ThermalValue=0; + u32 FwCmdVal=0; + + priv->btxpower_trackingInit = true; + + + ThermalValue = (u8)rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, RF_T_METER, 0x1f); + RT_TRACE(COMP_POWER_TRACKING, "Readback Thermal Meter = 0x%x\n", ThermalValue); + printk("%s()Readback Thermal Meter = 0x%x\n", __func__,ThermalValue); + if (ThermalValue) + { + priv->ThermalValue = ThermalValue; + if (priv->pFirmware->FirmwareVersion >= 0x35) + { + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_TXPWR_TRACK_THERMAL); + } + else + { + FwCmdVal = (FW_TXPWR_TRACK_THERMAL| + (priv->ThermalMeter[0]<<8)|(ThermalValue<<16)); + RT_TRACE(COMP_POWER_TRACKING, "Write to FW Thermal Val = 0x%x\n", FwCmdVal); + write_nic_dword(dev, WFM5, FwCmdVal); + ChkFwCmdIoDone(dev); + } + } + + priv->txpower_count = 0; +} +#endif + +void dm_txpower_trackingcallback(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,txpower_tracking_wq); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + +#ifdef RTL8190P + dm_TXPowerTrackingCallback_TSSI(dev); +#elif defined(RTL8192E) + if (priv->IC_Cut >= IC_VersionCut_D) + dm_TXPowerTrackingCallback_TSSI(dev); + else + dm_TXPowerTrackingCallback_ThermalMeter(dev); +#elif defined(RTL8192SE) + dm_TXPowerTrackingCallback_ThermalMeter(dev); +#endif +} + +#ifndef RTL8192SE +static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + + priv->txbbgain_table[0].txbb_iq_amplifygain = 12; + priv->txbbgain_table[0].txbbgain_value=0x7f8001fe; + priv->txbbgain_table[1].txbb_iq_amplifygain = 11; + priv->txbbgain_table[1].txbbgain_value=0x788001e2; + priv->txbbgain_table[2].txbb_iq_amplifygain = 10; + priv->txbbgain_table[2].txbbgain_value=0x71c001c7; + priv->txbbgain_table[3].txbb_iq_amplifygain = 9; + priv->txbbgain_table[3].txbbgain_value=0x6b8001ae; + priv->txbbgain_table[4].txbb_iq_amplifygain = 8; + priv->txbbgain_table[4].txbbgain_value=0x65400195; + priv->txbbgain_table[5].txbb_iq_amplifygain = 7; + priv->txbbgain_table[5].txbbgain_value=0x5fc0017f; + priv->txbbgain_table[6].txbb_iq_amplifygain = 6; + priv->txbbgain_table[6].txbbgain_value=0x5a400169; + priv->txbbgain_table[7].txbb_iq_amplifygain = 5; + priv->txbbgain_table[7].txbbgain_value=0x55400155; + priv->txbbgain_table[8].txbb_iq_amplifygain = 4; + priv->txbbgain_table[8].txbbgain_value=0x50800142; + priv->txbbgain_table[9].txbb_iq_amplifygain = 3; + priv->txbbgain_table[9].txbbgain_value=0x4c000130; + priv->txbbgain_table[10].txbb_iq_amplifygain = 2; + priv->txbbgain_table[10].txbbgain_value=0x47c0011f; + priv->txbbgain_table[11].txbb_iq_amplifygain = 1; + priv->txbbgain_table[11].txbbgain_value=0x43c0010f; + priv->txbbgain_table[12].txbb_iq_amplifygain = 0; + priv->txbbgain_table[12].txbbgain_value=0x40000100; + priv->txbbgain_table[13].txbb_iq_amplifygain = -1; + priv->txbbgain_table[13].txbbgain_value=0x3c8000f2; + priv->txbbgain_table[14].txbb_iq_amplifygain = -2; + priv->txbbgain_table[14].txbbgain_value=0x390000e4; + priv->txbbgain_table[15].txbb_iq_amplifygain = -3; + priv->txbbgain_table[15].txbbgain_value=0x35c000d7; + priv->txbbgain_table[16].txbb_iq_amplifygain = -4; + priv->txbbgain_table[16].txbbgain_value=0x32c000cb; + priv->txbbgain_table[17].txbb_iq_amplifygain = -5; + priv->txbbgain_table[17].txbbgain_value=0x300000c0; + priv->txbbgain_table[18].txbb_iq_amplifygain = -6; + priv->txbbgain_table[18].txbbgain_value=0x2d4000b5; + priv->txbbgain_table[19].txbb_iq_amplifygain = -7; + priv->txbbgain_table[19].txbbgain_value=0x2ac000ab; + priv->txbbgain_table[20].txbb_iq_amplifygain = -8; + priv->txbbgain_table[20].txbbgain_value=0x288000a2; + priv->txbbgain_table[21].txbb_iq_amplifygain = -9; + priv->txbbgain_table[21].txbbgain_value=0x26000098; + priv->txbbgain_table[22].txbb_iq_amplifygain = -10; + priv->txbbgain_table[22].txbbgain_value=0x24000090; + priv->txbbgain_table[23].txbb_iq_amplifygain = -11; + priv->txbbgain_table[23].txbbgain_value=0x22000088; + priv->txbbgain_table[24].txbb_iq_amplifygain = -12; + priv->txbbgain_table[24].txbbgain_value=0x20000080; + priv->txbbgain_table[25].txbb_iq_amplifygain = -13; + priv->txbbgain_table[25].txbbgain_value=0x1a00006c; + priv->txbbgain_table[26].txbb_iq_amplifygain = -14; + priv->txbbgain_table[26].txbbgain_value=0x1c800072; + priv->txbbgain_table[27].txbb_iq_amplifygain = -15; + priv->txbbgain_table[27].txbbgain_value=0x18000060; + priv->txbbgain_table[28].txbb_iq_amplifygain = -16; + priv->txbbgain_table[28].txbbgain_value=0x19800066; + priv->txbbgain_table[29].txbb_iq_amplifygain = -17; + priv->txbbgain_table[29].txbbgain_value=0x15800056; + priv->txbbgain_table[30].txbb_iq_amplifygain = -18; + priv->txbbgain_table[30].txbbgain_value=0x26c0005b; + priv->txbbgain_table[31].txbb_iq_amplifygain = -19; + priv->txbbgain_table[31].txbbgain_value=0x14400051; + priv->txbbgain_table[32].txbb_iq_amplifygain = -20; + priv->txbbgain_table[32].txbbgain_value=0x24400051; + priv->txbbgain_table[33].txbb_iq_amplifygain = -21; + priv->txbbgain_table[33].txbbgain_value=0x1300004c; + priv->txbbgain_table[34].txbb_iq_amplifygain = -22; + priv->txbbgain_table[34].txbbgain_value=0x12000048; + priv->txbbgain_table[35].txbb_iq_amplifygain = -23; + priv->txbbgain_table[35].txbbgain_value=0x11000044; + priv->txbbgain_table[36].txbb_iq_amplifygain = -24; + priv->txbbgain_table[36].txbbgain_value=0x10000040; + + priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09; + priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04; + + priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08; + priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04; + + priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08; + priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08; + priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07; + priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07; + priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06; + priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06; + priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03; + + priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06; + priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05; + priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05; + priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05; + priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04; + priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04; + priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04; + priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04; + priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04; + priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02; + + priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03; + priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01; + + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00; + + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00; + priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00; + + priv->btxpower_tracking = true; + priv->txpower_count = 0; + priv->btxpower_trackingInit = false; + +} +#endif +#ifndef RTL8190P +static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + +#ifdef RTL8192SE + priv->btxpower_tracking = false; + priv->txpower_count = 0; + priv->btxpower_trackingInit = false; +#else + + if (priv->rtllib->FwRWRF) + priv->btxpower_tracking = true; + else + priv->btxpower_tracking = false; + priv->txpower_count = 0; + priv->btxpower_trackingInit = false; +#endif + RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", priv->btxpower_tracking); +} +#endif + +void dm_initialize_txpower_tracking(struct net_device *dev) +{ +#ifdef RTL8192E + struct r8192_priv *priv = rtllib_priv(dev); +#endif +#ifdef RTL8190P + dm_InitializeTXPowerTracking_TSSI(dev); +#elif defined RTL8192E + if (priv->IC_Cut >= IC_VersionCut_D) + dm_InitializeTXPowerTracking_TSSI(dev); + else + dm_InitializeTXPowerTracking_ThermalMeter(dev); +#elif defined RTL8192SE + dm_InitializeTXPowerTracking_ThermalMeter(dev); +#endif +} + +#if (defined RTL8192E || defined RTL8190P) +static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u32 tx_power_track_counter = 0; + RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); + if (read_nic_byte(dev, 0x11e) ==1) + return; + if (!priv->btxpower_tracking) + return; + tx_power_track_counter++; + + + if (tx_power_track_counter >= 180) + { + queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); + tx_power_track_counter =0; + } + +} +#endif +#ifndef RTL8190P +static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u8 TM_Trigger=0; + u8 TxPowerCheckCnt = 0; + + if (IS_HARDWARE_TYPE_8192SE(dev)) + TxPowerCheckCnt = 5; + else + TxPowerCheckCnt = 2; + if (!priv->btxpower_tracking){ + return; + } else { + if (priv->txpower_count <= TxPowerCheckCnt) { + priv->txpower_count++; + return; + } + } + + if (!TM_Trigger) + { +#ifdef RTL8192SE + if (IS_HARDWARE_TYPE_8192SE(dev)) + { + rtl8192_phy_SetRFReg(dev, RF90_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60); + RT_TRACE(COMP_POWER_TRACKING, "Trigger 92S Thermal Meter!!\n"); + } + else +#endif + { + rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); + rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); + rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); + rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); + } + TM_Trigger = 1; + return; + } else { + printk("===============>Schedule TxPowerTrackingWorkItem\n"); +#ifdef RTL8192SE + DM_TXPowerTracking92SDirectCall(dev); +#else + + queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); +#endif + TM_Trigger = 0; + } + + } +#endif + +#ifdef RTL8192SE +void DM_TXPowerTracking92SDirectCall(struct net_device *dev) +{ + dm_TXPowerTrackingCallback_ThermalMeter(dev); + } +#endif + +static void dm_check_txpower_tracking(struct net_device *dev) +{ +#ifdef RTL8192E + struct r8192_priv *priv = rtllib_priv(dev); +#endif +#ifdef RTL8190P + dm_CheckTXPowerTracking_TSSI(dev); +#elif defined RTL8192E + if (priv->IC_Cut >= IC_VersionCut_D) + dm_CheckTXPowerTracking_TSSI(dev); + else + dm_CheckTXPowerTracking_ThermalMeter(dev); +#elif defined RTL8192SE + dm_CheckTXPowerTracking_ThermalMeter(dev); +#endif + +} + +#ifndef RTL8192SE +static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) +{ + u32 TempVal; + struct r8192_priv *priv = rtllib_priv(dev); + TempVal = 0; + if (!bInCH14){ + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + + rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + TempVal = 0; + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = 0; + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + + rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); + } + else + { + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + + rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + TempVal = 0; + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = 0; + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + + rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); + } + + +} +#endif +#ifdef RTL8192E +static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14) +{ + u32 TempVal; + struct r8192_priv *priv = rtllib_priv(dev); + + TempVal = 0; + if (!bInCH14) + { + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", + rCCK0_TxFilter1, TempVal); + TempVal = 0; + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", + rCCK0_TxFilter2, TempVal); + TempVal = 0; + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ; + + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", + rCCK0_DebugPort, TempVal); + } + else + { + TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + + (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; + + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", + rCCK0_TxFilter1, TempVal); + TempVal = 0; + TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", + rCCK0_TxFilter2, TempVal); + TempVal = 0; + TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; + + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); + RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n", + rCCK0_DebugPort, TempVal); + } + } +#endif + +#ifndef RTL8192SE +extern void dm_cck_txpower_adjust( + struct net_device *dev, + bool binch14 +) +{ +#ifndef RTL8190P + struct r8192_priv *priv = rtllib_priv(dev); +#endif +#ifdef RTL8190P + dm_CCKTxPowerAdjust_TSSI(dev, binch14); +#else + if (priv->IC_Cut >= IC_VersionCut_D) + dm_CCKTxPowerAdjust_TSSI(dev, binch14); + else + dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); +#endif +} +#endif + + +#if defined(RTL8192E)||defined(RTL8190P) +static void dm_txpower_reset_recovery( + struct net_device *dev +) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->CCKPresentAttentuation); + dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); + +} + +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 reg_ratr = priv->rate_adaptive.last_ratr; + + if (IS_NIC_DOWN(priv)){ + RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); + return; + } + + if (priv->rate_adaptive.rate_adaptive_disabled) + return; + if ( !(priv->rtllib->mode==WIRELESS_MODE_N_24G || + priv->rtllib->mode==WIRELESS_MODE_N_5G)) + return; + { + u32 ratr_value; + ratr_value = reg_ratr; + if (priv->rf_type == RF_1T2R) + { + ratr_value &=~ (RATE_ALL_OFDM_2SS); + } + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + } + if (priv->btxpower_trackingInit && priv->btxpower_tracking){ + dm_txpower_reset_recovery(dev); + } + + dm_bb_initialgain_restore(dev); + +} + +static void dm_bb_initialgain_restore(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 bit_mask = 0x7f; + + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI) + return; + + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1); + bit_mask = bMaskByte2; + rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); + + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + +} + + +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->bswitch_fsync = false; + priv->bfsync_processing = false; + dm_bb_initialgain_backup(dev); + +} + + +static void dm_bb_initialgain_backup(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 bit_mask = bMaskByte0; + + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI) + return; + + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bit_mask); + priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bit_mask); + priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bit_mask); + priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bit_mask); + bit_mask = bMaskByte2; + priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask); + + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + +} + +#endif +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value) +{ +#ifdef RTL8192SE + struct r8192_priv *priv = rtllib_priv(dev); + if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) + priv->MidHighPwrTHR_L2 = (u8)dm_value; + else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW) + priv->MidHighPwrTHR_L1 = (u8)dm_value; + return; +#endif + if (dm_type == DIG_TYPE_THRESH_HIGH) + { + dm_digtable.rssi_high_thresh = dm_value; + } + else if (dm_type == DIG_TYPE_THRESH_LOW) + { + dm_digtable.rssi_low_thresh = dm_value; + } + else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) + { + dm_digtable.rssi_high_power_highthresh = dm_value; + } + else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) + { + dm_digtable.rssi_high_power_highthresh = dm_value; + } + else if (dm_type == DIG_TYPE_ENABLE) + { + dm_digtable.dig_state = DM_STA_DIG_MAX; + dm_digtable.dig_enable_flag = true; + } + else if (dm_type == DIG_TYPE_DISABLE) + { + dm_digtable.dig_state = DM_STA_DIG_MAX; + dm_digtable.dig_enable_flag = false; + } + else if (dm_type == DIG_TYPE_DBG_MODE) + { + if (dm_value >= DM_DBG_MAX) + dm_value = DM_DBG_OFF; + dm_digtable.dbg_mode = (u8)dm_value; + } + else if (dm_type == DIG_TYPE_RSSI) + { + if (dm_value > 100) + dm_value = 30; + dm_digtable.rssi_val = (long)dm_value; + } + else if (dm_type == DIG_TYPE_ALGORITHM) + { + if (dm_value >= DIG_ALGO_MAX) + dm_value = DIG_ALGO_BY_FALSE_ALARM; + if (dm_digtable.dig_algorithm != (u8)dm_value) + dm_digtable.dig_algorithm_switch = 1; + dm_digtable.dig_algorithm = (u8)dm_value; + } + else if (dm_type == DIG_TYPE_BACKOFF) + { + if (dm_value > 30) + dm_value = 30; + dm_digtable.backoff_val = (u8)dm_value; + } + else if (dm_type == DIG_TYPE_RX_GAIN_MIN) + { + if (dm_value == 0) + dm_value = 0x1; + dm_digtable.rx_gain_range_min = (u8)dm_value; + } + else if (dm_type == DIG_TYPE_RX_GAIN_MAX) + { + if (dm_value > 0x50) + dm_value = 0x50; + dm_digtable.rx_gain_range_max = (u8)dm_value; + } +} +extern void +dm_change_fsync_setting( + struct net_device *dev, + s32 DM_Type, + s32 DM_Value) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (DM_Type == 0) + { + if (DM_Value > 1) + DM_Value = 1; + priv->framesyncMonitor = (u8)DM_Value; + } +} + +extern void +dm_change_rxpath_selection_setting( + struct net_device *dev, + s32 DM_Type, + s32 DM_Value) +{ + struct r8192_priv *priv = rtllib_priv(dev); + prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive); + + + if (DM_Type == 0) + { + if (DM_Value > 1) + DM_Value = 1; + DM_RxPathSelTable.Enable = (u8)DM_Value; + } + else if (DM_Type == 1) + { + if (DM_Value > 1) + DM_Value = 1; + DM_RxPathSelTable.DbgMode = (u8)DM_Value; + } + else if (DM_Type == 2) + { + if (DM_Value > 40) + DM_Value = 40; + DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; + } + else if (DM_Type == 3) + { + if (DM_Value > 25) + DM_Value = 25; + DM_RxPathSelTable.diff_TH = (u8)DM_Value; + } + else if (DM_Type == 4) + { + if (DM_Value >= CCK_Rx_Version_MAX) + DM_Value = CCK_Rx_Version_1; + DM_RxPathSelTable.cck_method= (u8)DM_Value; + } + else if (DM_Type == 10) + { + if (DM_Value > 100) + DM_Value = 50; + DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; + } + else if (DM_Type == 11) + { + if (DM_Value > 100) + DM_Value = 50; + DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; + } + else if (DM_Type == 12) + { + if (DM_Value > 100) + DM_Value = 50; + DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; + } + else if (DM_Type == 13) + { + if (DM_Value > 100) + DM_Value = 50; + DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; + } + else if (DM_Type == 20) + { + if (DM_Value > 1) + DM_Value = 1; + pRA->ping_rssi_enable = (u8)DM_Value; + } + else if (DM_Type == 21) + { + if (DM_Value > 30) + DM_Value = 30; + pRA->ping_rssi_thresh_for_ra = DM_Value; + } +} + +static void dm_dig_init(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + dm_digtable.dig_enable_flag = true; + dm_digtable.Backoff_Enable_Flag = true; + +#ifdef RTL8192SE + if ((priv->DM_Type == DM_Type_ByDriver) && (priv->pFirmware->FirmwareVersion >= 0x3c)) + dm_digtable.dig_algorithm = DIG_ALGO_BY_TOW_PORT; + else + dm_digtable.dig_algorithm = DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM; +#else + dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; +#endif + + dm_digtable.Dig_TwoPort_Algorithm = DIG_TWO_PORT_ALGO_RSSI; + dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; + dm_digtable.dbg_mode = DM_DBG_OFF; + dm_digtable.dig_algorithm_switch = 0; + + dm_digtable.dig_state = DM_STA_DIG_MAX; + dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; + dm_digtable.CurSTAConnectState = dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT; + dm_digtable.CurAPConnectState = dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT; + dm_digtable.initialgain_lowerbound_state = false; + + dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; + dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; + + dm_digtable.FALowThresh = DM_FALSEALARM_THRESH_LOW; + dm_digtable.FAHighThresh = DM_FALSEALARM_THRESH_HIGH; + + dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW; + dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH; + + dm_digtable.rssi_val = 50; + dm_digtable.backoff_val = DM_DIG_BACKOFF; + dm_digtable.rx_gain_range_max = DM_DIG_MAX; + if (priv->CustomerID == RT_CID_819x_Netcore) + dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; + else + dm_digtable.rx_gain_range_min = DM_DIG_MIN; + + dm_digtable.BackoffVal_range_max = DM_DIG_BACKOFF_MAX; + dm_digtable.BackoffVal_range_min = DM_DIG_BACKOFF_MIN; +} + +void dm_FalseAlarmCounterStatistics(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 ret_value; + PFALSE_ALARM_STATISTICS FalseAlmCnt = &(priv->FalseAlmCnt); + + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + + FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; + + ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); + FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); + FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Parity_Fail + + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Cck_fail); + + RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", + FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail , FalseAlmCnt->Cnt_all); +} + +#ifdef RTL8192SE +static void dm_CtrlInitGainAPByFalseAlarm(struct net_device *dev) +{ + static u8 binitialized = false; + + { + binitialized = false; + dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; + return; + } +} +#endif + +static void dm_ctrl_initgain_byrssi(struct net_device *dev) +{ + + if (dm_digtable.dig_enable_flag == false) + return; + + if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) + dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev); + else if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI) + dm_ctrl_initgain_byrssi_by_driverrssi(dev); +#ifdef RTL8192SE + else if (dm_digtable.dig_algorithm == DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM) + dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(dev); + else if (dm_digtable.dig_algorithm == DIG_ALGO_BY_TOW_PORT) + dm_CtrlInitGainByTwoPort(dev); +#endif + else + return; +} + +#ifdef RTL8192SE +static void dm_CtrlInitGainByTwoPort(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (rtllib_act_scanning(priv->rtllib,true) == true) + return; + + if ((priv->rtllib->state > RTLLIB_NOLINK) && (priv->rtllib->state < RTLLIB_LINKED)) + dm_digtable.CurSTAConnectState = DIG_STA_BEFORE_CONNECT; + else if ((priv->rtllib->state == RTLLIB_LINKED) ||(priv->rtllib->state == RTLLIB_LINKED_SCANNING)) + dm_digtable.CurSTAConnectState = DIG_STA_CONNECT; + else + dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; + + dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; + + if (dm_digtable.CurSTAConnectState != DIG_STA_DISCONNECT) + { + if (dm_digtable.Dig_TwoPort_Algorithm == DIG_TWO_PORT_ALGO_FALSE_ALARM) + { + dm_digtable.Dig_TwoPort_Algorithm = DIG_TWO_PORT_ALGO_RSSI; + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_MODE_SS); + } + } + + dm_FalseAlarmCounterStatistics(dev); + dm_initial_gain_STABeforeConnect(dev); + dm_CtrlInitGainAPByFalseAlarm(dev); + + dm_digtable.PreSTAConnectState = dm_digtable.CurSTAConnectState; +} +#endif + +/*----------------------------------------------------------------------------- + * Function: dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm() + * + * Overview: Driver monitor RSSI and False Alarm to change initial gain. + Only change initial gain during link in progress. + * + * Input: IN PADAPTER pAdapter + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 03/04/2009 hpfan Create Version 0. + * + *---------------------------------------------------------------------------*/ + +#ifdef RTL8192SE +static void dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (rtllib_act_scanning(priv->rtllib,true) == true) + return; + + if ((priv->rtllib->state > RTLLIB_NOLINK) && (priv->rtllib->state < RTLLIB_LINKED)) + dm_digtable.CurSTAConnectState = DIG_STA_BEFORE_CONNECT; + else if ((priv->rtllib->state == RTLLIB_LINKED) ||(priv->rtllib->state == RTLLIB_LINKED_SCANNING)) + dm_digtable.CurSTAConnectState = DIG_STA_CONNECT; + else + dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; + + if (dm_digtable.dbg_mode == DM_DBG_OFF) + dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; + + dm_FalseAlarmCounterStatistics(dev); + dm_initial_gain_STABeforeConnect(dev); + dm_digtable.PreSTAConnectState = dm_digtable.CurSTAConnectState; + +} +#endif +static void dm_ctrl_initgain_byrssi_by_driverrssi( + struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 i; + static u8 fw_dig=0; + + if (dm_digtable.dig_enable_flag == false) + return; + + if (dm_digtable.dig_algorithm_switch) + fw_dig = 0; + if (fw_dig <= 3) + { + for (i=0; i<3; i++) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + fw_dig++; + dm_digtable.dig_state = DM_STA_DIG_OFF; + } + + if (priv->rtllib->state == RTLLIB_LINKED) + dm_digtable.CurSTAConnectState = DIG_STA_CONNECT; + else + dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; + + + if (dm_digtable.dbg_mode == DM_DBG_OFF) + dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; + dm_initial_gain(dev); + dm_pd_th(dev); + dm_cs_ratio(dev); + if (dm_digtable.dig_algorithm_switch) + dm_digtable.dig_algorithm_switch = 0; + dm_digtable.PreSTAConnectState = dm_digtable.CurSTAConnectState; + +} + +static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( + struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u32 reset_cnt = 0; + u8 i; + + if (dm_digtable.dig_enable_flag == false) + return; + + if (dm_digtable.dig_algorithm_switch) + { + dm_digtable.dig_state = DM_STA_DIG_MAX; + for (i=0; i<3; i++) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + dm_digtable.dig_algorithm_switch = 0; + } + + if (priv->rtllib->state != RTLLIB_LINKED) + return; + + if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) && + (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh)) + { + return; + } + if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) + { + if (dm_digtable.dig_state == DM_STA_DIG_OFF && + (priv->reset_count == reset_cnt)) + { + return; + } + else + { + reset_cnt = priv->reset_count; + } + + dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; + dm_digtable.dig_state = DM_STA_DIG_OFF; + + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x17); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x17); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x17); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17); + + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); + #endif + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40); + */ + + + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + + write_nic_byte(dev, 0xa0a, 0x08); + + return; + + } + + if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) ) + { + u8 reset_flag = 0; + + if (dm_digtable.dig_state == DM_STA_DIG_ON && + (priv->reset_count == reset_cnt)) + { + dm_ctrl_initgain_byrssi_highpwr(dev); + return; + } + else + { + if (priv->reset_count != reset_cnt) + reset_flag = 1; + + reset_cnt = priv->reset_count; + } + + dm_digtable.dig_state = DM_STA_DIG_ON; + + if (reset_flag == 1) + { + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c); + } + else + { + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); + } + + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + #endif + /* + else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + */ + + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + + write_nic_byte(dev, 0xa0a, 0xcd); + + + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + + } + + dm_ctrl_initgain_byrssi_highpwr(dev); + +} + + +static void dm_ctrl_initgain_byrssi_highpwr( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u32 reset_cnt_highpwr = 0; + + if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && + (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) + { + return; + } + + if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) + { + if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && + (priv->reset_count == reset_cnt_highpwr)) + return; + else + dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; + + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); + #endif + + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); + */ + + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); + } + else + { + if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&& + (priv->reset_count == reset_cnt_highpwr)) + return; + else + dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; + + if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && + priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) + { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + #endif + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + */ + + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + } + } + + reset_cnt_highpwr = priv->reset_count; + +} + + +static void dm_initial_gain( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 initial_gain=0; + static u8 initialized=0, force_write=0; + static u32 reset_cnt=0; + + if (dm_digtable.dig_algorithm_switch) + { + initialized = 0; + reset_cnt = 0; + } + + if (rtllib_act_scanning(priv->rtllib,true) == true) + { + force_write = 1; + return; + } + + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) + { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) + { + if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) + dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; + else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) + dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; + else + dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + } + else + { + if (dm_digtable.cur_ig_value == 0) + dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; + else + dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; + } + } + else + { + dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; + dm_digtable.pre_ig_value = 0; + } + + if (priv->reset_count != reset_cnt) + { + force_write = 1; + reset_cnt = priv->reset_count; + } + + if (dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1)) + force_write = 1; + + { + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) + || !initialized || force_write) + { + initial_gain = (u8)dm_digtable.cur_ig_value; + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; + initialized = 1; + force_write = 0; + } + } +} + +void dm_initial_gain_STABeforeConnect( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 initial_gain=0; + static u8 initialized=0, force_write=0; + + RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", + dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); + + + if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || + (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) + { + if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) + { + if (priv->rtllib->eRFPowerState != eRfOn) + return; + + if (dm_digtable.Backoff_Enable_Flag == true) + { + if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) + { + if ((dm_digtable.backoff_val -6) < dm_digtable.BackoffVal_range_min) + dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; + else + dm_digtable.backoff_val -= 6; + } + else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) + { + if ((dm_digtable.backoff_val+6) > dm_digtable.BackoffVal_range_max) + dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; + else + dm_digtable.backoff_val +=6; + } + } + else + dm_digtable.backoff_val =DM_DIG_BACKOFF; + + if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) + dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; + else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) + dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; + else + dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + + if (priv->FalseAlmCnt.Cnt_all > 10000) + dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value>0x33)?dm_digtable.cur_ig_value:0x33; + + if (priv->FalseAlmCnt.Cnt_all > 16000) + dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; + + } + else + { + return; + } + } + else + { + dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); + + dm_digtable.backoff_val = DM_DIG_BACKOFF; + dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; + dm_digtable.pre_ig_value = 0; + return; + } + + if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0)) + force_write = 1; + + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || !initialized || force_write) + { + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); + + initial_gain = (u8)dm_digtable.cur_ig_value; + + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, initial_gain); + dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; + initialized = 1; + force_write = 0; + } + + RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, backoff_val = %d\n", + dm_digtable.cur_ig_value, dm_digtable.pre_ig_value, dm_digtable.backoff_val); + +} + +static void dm_pd_th( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u8 initialized=0, force_write=0; + static u32 reset_cnt = 0; + + if (dm_digtable.dig_algorithm_switch) + { + initialized = 0; + reset_cnt = 0; + } + + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) + { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) + { + if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) + dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; + else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) + dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; + else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) && + (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh)) + dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; + else + dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; + } + else + { + dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; + } + } + else + { + dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; + } + + if (priv->reset_count != reset_cnt) + { + force_write = 1; + reset_cnt = priv->reset_count; + } + + { + if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || + (initialized<=3) || force_write) + { + if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) + { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); + #endif + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); + */ + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + } + else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) + { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + #endif + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + */ + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + } + else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) + { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); + #else + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); + #endif + /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) + write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); + */ + } + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); + } + dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; + if (initialized <= 3) + initialized++; + force_write = 0; + } + } +} + +static void dm_cs_ratio( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + static u8 initialized=0,force_write=0; + static u32 reset_cnt = 0; + + if (dm_digtable.dig_algorithm_switch) + { + initialized = 0; + reset_cnt = 0; + } + + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) + { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) + { + if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) + dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; + else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) ) + dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER; + else + dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state; + } + else + { + dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; + } + } + else + { + dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; + } + + if (priv->reset_count != reset_cnt) + { + force_write = 1; + reset_cnt = priv->reset_count; + } + + + { + if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || + !initialized || force_write) + { + if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) + { + write_nic_byte(dev, 0xa0a, 0x08); + } + else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) + { + write_nic_byte(dev, 0xa0a, 0xcd); + } + dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; + initialized = 1; + force_write = 0; + } + } +} + +extern void dm_init_edca_turbo(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->bcurrent_turbo_EDCA = false; + priv->rtllib->bis_any_nonbepkts = false; + priv->bis_cur_rdlstate = false; +} + +#if 1 +static void dm_check_edca_turbo( + struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + + static unsigned long lastTxOkCnt = 0; + static unsigned long lastRxOkCnt = 0; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; + + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + { + goto dm_CheckEdcaTurbo_EXIT; + } + if (priv->rtllib->state != RTLLIB_LINKED) + { + goto dm_CheckEdcaTurbo_EXIT; + } + if (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) + { + goto dm_CheckEdcaTurbo_EXIT; + } + + { + u8* peername[11] = {"unknown", "realtek_90", "realtek_92se","broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"}; + static int wb_tmp = 0; + if (wb_tmp == 0){ + printk("%s():iot peer is %s, bssid:"MAC_FMT"\n",__func__,peername[pHTInfo->IOTPeer], MAC_ARG(priv->rtllib->current_network.bssid)); + wb_tmp = 1; + } + } + if (!priv->rtllib->bis_any_nonbepkts) + { + curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; + curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; + if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) + { + if (curTxOkCnt > 4*curRxOkCnt) + { + if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) + { + write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = false; + } + } + else + { + if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) + { + if (priv->rtllib->mode == WIRELESS_MODE_G) + write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); + else + write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = true; + } + } + priv->bcurrent_turbo_EDCA = true; + } + else + { + if (curRxOkCnt > 4*curTxOkCnt) + { + if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) + { + if (priv->rtllib->mode == WIRELESS_MODE_G) + write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); + else + write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = true; + } + } + else + { + if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) + { + write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = false; + } + + } + + priv->bcurrent_turbo_EDCA = true; + } + } + else + { + if (priv->bcurrent_turbo_EDCA) + { + + u8 tmp = AC0_BE; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&tmp) ); + priv->bcurrent_turbo_EDCA = false; + } + } + + +dm_CheckEdcaTurbo_EXIT: + priv->rtllib->bis_any_nonbepkts = false; + lastTxOkCnt = priv->stats.txbytesunicast; + lastRxOkCnt = priv->stats.rxbytesunicast; +} +#endif + +extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + + if (DM_Type == 0) + { + if (DM_Value > 1) + DM_Value = 1; + priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; + } + else if (DM_Type == 1) + { + if (DM_Value >= 50) + DM_Value = 50; + priv->rtllib->CTSToSelfTH = (u8)DM_Value; + } +} + +static void dm_init_ctstoself(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + + priv->rtllib->bCTSToSelfEnable = true; + priv->rtllib->CTSToSelfTH = CTSToSelfTHVal; +} + +static void dm_ctstoself(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + static unsigned long lastTxOkCnt = 0; + static unsigned long lastRxOkCnt = 0; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; + + if (priv->rtllib->bCTSToSelfEnable != true) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; + return; + } + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; + curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; + if (curRxOkCnt > 4*curTxOkCnt) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; + } + else + { + #if 1 + pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; + #else + if (priv->undecorated_smoothed_pwdb < priv->rtllib->CTSToSelfTH) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; + } + else if (priv->undecorated_smoothed_pwdb >= (priv->rtllib->CTSToSelfTH+5)) + { + pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; + } + #endif + } + + lastTxOkCnt = priv->stats.txbytesunicast; + lastRxOkCnt = priv->stats.rxbytesunicast; + } +} + + +static void +dm_Init_WA_Broadcom_IOT(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + + pHTInfo->bWAIotBroadcom = false; + pHTInfo->WAIotTH = WAIotTHVal; +} + +#ifdef RTL8192SE +static void +dm_WA_Broadcom_IOT(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); + PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + u8 update=0; + static enum rtllib_state connectState = RTLLIB_NOLINK; + + if ( (pHTInfo->bWAIotBroadcom != true) || + (priv->rtllib->mode == WIRELESS_MODE_B) || + (pHTInfo->bCurBW40MHz)) + { + if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; + update = 1; + printk(" dm_WA_Broadcom_IOT(), disable HT_IOT_ACT_WA_IOT_Broadcom\n"); + } + else + return; + } + + if (connectState == RTLLIB_LINKED && priv->rtllib->state == RTLLIB_LINKED) + { + if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; + update = 1; + pHTInfo->bWAIotBroadcom = false; + printk("dm_WA_Broadcom_IOT(), from connect to disconnected, disable HT_IOT_ACT_WA_IOT_Broadcom\n"); + } + } + connectState = priv->rtllib->state; + + if (!update && pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + if (priv->undecorated_smoothed_pwdb < pHTInfo->WAIotTH) + { + if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) + { + pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; + update = 1; + printk("dm_WA_Broadcom_IOT() ==> WA_IOT enable cck rates\n"); + } + } + else if (priv->undecorated_smoothed_pwdb >= (priv->rtllib->CTSToSelfTH+5)) + { + if ((pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) == 0) + { + pHTInfo->IOTAction |= HT_IOT_ACT_WA_IOT_Broadcom; + update = 1; + printk("dm_WA_Broadcom_IOT() ==> WA_IOT disable cck rates\n"); + } + } + } + + if (update){ + if (priv->rtllib->bUseRAMask){ + priv->rtllib->UpdateHalRAMaskHandler( + dev, + false, + 0, + priv->rtllib->pHTInfo->PeerMimoPs, + priv->rtllib->mode, + priv->rtllib->pHTInfo->bCurTxBW40MHz, + 0); + }else{ + priv->ops->update_ratr_table(dev, priv->rtllib->dot11HTOperationalRateSet, NULL); + } + priv->rtllib->SetHwRegHandler( dev, HW_VAR_BASIC_RATE, (u8*)(&priv->basic_rate)); + } +} +#endif + +static void dm_check_pbc_gpio(struct net_device *dev) +{ +#ifdef RTL8192U + struct r8192_priv *priv = rtllib_priv(dev); + u8 tmp1byte; + + + tmp1byte = read_nic_byte(dev,GPI); + if (tmp1byte == 0xff) + return; + + if (tmp1byte&BIT6 || tmp1byte&BIT0) + { + RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n"); + priv->bpbc_pressed = true; + } +#endif + +} + +#ifdef RTL8192E + +extern void dm_CheckRfCtrlGPIO(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,gpio_change_rf_wq); + struct net_device *dev = priv->rtllib->dev; +#else + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); + struct net_device *dev = priv->rtllib->dev; +#endif + u8 tmp1byte; + RT_RF_POWER_STATE eRfPowerStateToSet; + bool bActuallySet = false; + + char *argv[3]; + static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; + static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; + + bActuallySet=false; + + if ((priv->up_first_time == 1) || (priv->being_init_adapter)) + { + return; + } + + if (priv->bfirst_after_down){ + priv->bfirst_after_down = 1; + return; + } + + + + { + tmp1byte = read_nic_byte(dev,GPI); + + eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; + + if ( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) + { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); + printk("gpiochangeRF - HW Radio ON\n"); + priv->bHwRadioOff = false; + bActuallySet = true; + } + else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) + { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); + printk("gpiochangeRF - HW Radio OFF\n"); + priv->bHwRadioOff = true; + bActuallySet = true; + } + + if (bActuallySet) + { + mdelay(1000); + priv->bHwRfOffAction = 1; + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); + { + if (priv->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + + argv[0] = RadioPowerPath; + argv[2] = NULL; + call_usermodehelper(RadioPowerPath,argv,envp,1); + } + + } + } + +} +#elif defined RTL8192SE +extern void Power_DomainInit92SE(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 tmpU1b; + u16 tmpU2b; + + + + priv->PwrDomainProtect = true; + + tmpU1b = read_nic_byte(dev, (SYS_CLKR + 1)); + if (tmpU1b & BIT7) + { + tmpU1b &= ~(BIT6 | BIT7); + if (!HalSetSysClk8192SE(dev, tmpU1b)){ + priv->PwrDomainProtect = false; + return; + } + } + + write_nic_byte(dev, AFE_PLL_CTRL, 0x0); + write_nic_byte(dev, LDOA15_CTRL, 0x34); + + tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1); + if (priv->rtllib->RfOffReason & (RF_CHANGE_BY_IPS | RF_CHANGE_BY_HW)) { + tmpU1b &= 0xFB; + } else { + tmpU1b &= 0x73; + } + + write_nic_byte(dev, SYS_FUNC_EN+1, tmpU1b); + udelay(1000); + + write_nic_byte(dev, CMDR, 0); + write_nic_byte(dev, TCR, 0); + + tmpU1b = read_nic_byte(dev, 0x562); + tmpU1b |= 0x08; + write_nic_byte(dev, 0x562, tmpU1b); + tmpU1b &= ~(BIT3); + write_nic_byte(dev, 0x562, tmpU1b); + + tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL); + write_nic_byte(dev, AFE_XTAL_CTRL, (tmpU1b|0x01)); + udelay(1500); + tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL+1); + write_nic_byte(dev, AFE_XTAL_CTRL+1, (tmpU1b&0xfb)); + + + tmpU1b = read_nic_byte(dev, AFE_MISC); + write_nic_byte(dev, AFE_MISC, (tmpU1b|BIT0)); + udelay(1000); + + tmpU1b = read_nic_byte(dev, AFE_MISC); + write_nic_byte(dev, AFE_MISC, (tmpU1b|0x02)); + udelay(1000); + + tmpU1b = read_nic_byte(dev, LDOA15_CTRL); + write_nic_byte(dev, LDOA15_CTRL, (tmpU1b|BIT0)); + + tmpU2b = read_nic_word(dev, SYS_ISO_CTRL); + write_nic_word(dev, SYS_ISO_CTRL, (tmpU2b|BIT11)); + + + tmpU2b = read_nic_word(dev, SYS_FUNC_EN); + write_nic_word(dev, SYS_FUNC_EN, (tmpU2b |BIT13)); + + write_nic_byte(dev, SYS_ISO_CTRL+1, 0x68); + + tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL); + write_nic_byte(dev, AFE_PLL_CTRL, (tmpU1b|BIT0|BIT4)); + tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL+1); + write_nic_byte(dev, AFE_PLL_CTRL+1, (tmpU1b|BIT0)); + udelay(1000); + + write_nic_byte(dev, SYS_ISO_CTRL, 0xA6); + + tmpU2b = read_nic_word(dev, SYS_CLKR); + write_nic_word(dev, SYS_CLKR, (tmpU2b|BIT12|BIT11)); + + tmpU2b = read_nic_word(dev, SYS_FUNC_EN); + write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|BIT11)); + write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|BIT11|BIT15)); + + tmpU2b = read_nic_word(dev, SYS_CLKR); + write_nic_word(dev, SYS_CLKR, (tmpU2b&(~BIT2))); + + tmpU1b = read_nic_byte(dev, (SYS_CLKR + 1)); + tmpU1b = ((tmpU1b | BIT7) & (~BIT6)); + if (!HalSetSysClk8192SE(dev, tmpU1b)) + { + priv->PwrDomainProtect = false; + return; + } + + write_nic_word(dev, CMDR, 0x37FC); + + gen_RefreshLedState(dev); + + priv->PwrDomainProtect = false; + +} + +void SET_RTL8192SE_RF_HALT(struct net_device *dev) +{ + u8 u1bTmp; + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->rtllib->RfOffReason == RF_CHANGE_BY_IPS && priv->LedStrategy == SW_LED_MODE8) + { + SET_RTL8192SE_RF_SLEEP(dev); + return; + } + + u1bTmp = read_nic_byte(dev, LDOV12D_CTRL); + u1bTmp |= BIT0; + write_nic_byte(dev, LDOV12D_CTRL, u1bTmp); + write_nic_byte(dev, SPS1_CTRL, 0x0); + write_nic_byte(dev, TXPAUSE, 0xFF); + write_nic_word(dev, CMDR, 0x57FC); + udelay(100); + write_nic_word(dev, CMDR, 0x77FC); + write_nic_byte(dev, PHY_CCA, 0x0); + udelay(10); + write_nic_word(dev, CMDR, 0x37FC); + udelay(10); + write_nic_word(dev, CMDR, 0x77FC); + udelay(10); + write_nic_word(dev, CMDR, 0x57FC); + write_nic_word(dev, CMDR, 0x0000); + u1bTmp = read_nic_byte(dev, (SYS_CLKR + 1)); + if (u1bTmp & BIT7) + { + u1bTmp &= ~(BIT6 | BIT7); + if (!HalSetSysClk8192SE(dev, u1bTmp)) + return; + } + if (priv->rtllib->RfOffReason==RF_CHANGE_BY_IPS ) + { + write_nic_byte(dev, 0x03, 0xF9); + } + else + { + write_nic_byte(dev, 0x03, 0x71); + } + write_nic_byte(dev, SYS_CLKR+1, 0x70); + write_nic_byte(dev, AFE_PLL_CTRL+1, 0x68); + write_nic_byte(dev, AFE_PLL_CTRL, 0x00); + write_nic_byte(dev, LDOA15_CTRL, 0x34); + write_nic_byte(dev, AFE_XTAL_CTRL, 0x0E); + +} + +u8 RfOnOffDetect(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 u1Tmp; + u8 retval=eRfOn; + + if (priv->pwrdown) + { + u1Tmp = read_nic_byte(dev, 0x06); + printk("pwrdown, 0x6(BIT6)=%02x\n", u1Tmp); + retval = (u1Tmp & BIT6) ? eRfOn: eRfOff; + } + else + { +#ifdef CONFIG_BT_COEXIST + if (pHalData->bt_coexist.BluetoothCoexist) + { + if (pHalData->bt_coexist.BT_CoexistType == BT_2Wire) + { + PlatformEFIOWrite1Byte(pAdapter, MAC_PINMUX_CFG, 0xa); + u1Tmp = PlatformEFIORead1Byte(pAdapter, GPIO_IO_SEL); + delay_us(100); + u1Tmp = PlatformEFIORead1Byte(pAdapter, GPIO_IN); + RTPRINT(FPWR, PWRHW, ("GPIO_IN=%02x\n", u1Tmp)); + retval = (u1Tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? eRfOn : eRfOff; + } + else if ( (pHalData->bt_coexist.BT_CoexistType == BT_ISSC_3Wire) || + (pHalData->bt_coexist.BT_CoexistType == BT_Accel) || + (pHalData->bt_coexist.BT_CoexistType == BT_CSR) ) + { + u4tmp = PHY_QueryBBReg(pAdapter, 0x87c, bMaskDWord); + if ((u4tmp & BIT17) != 0) + { + PHY_SetBBReg(pAdapter, 0x87c, bMaskDWord, u4tmp & ~BIT17); + delay_us(50); + RTPRINT(FBT, BT_RFPoll, ("BT write 0x87c (~BIT17) = 0x%x\n", u4tmp &~BIT17)); + } + u4tmp = PHY_QueryBBReg(pAdapter, 0x8e0, bMaskDWord); + RTPRINT(FBT, BT_RFPoll, ("BT read 0x8e0 (BIT24)= 0x%x\n", u4tmp)); + retval = (u4tmp & BIT24) ? eRfOn : eRfOff; + RTPRINT(FBT, BT_RFPoll, ("BT check RF state to %s\n", (retval==eRfOn)? "ON":"OFF")); + } + } + else +#endif + { + write_nic_byte(dev, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO)); + u1Tmp = read_nic_byte(dev, GPIO_IO_SEL); + + u1Tmp &= HAL_8192S_HW_GPIO_OFF_MASK; + write_nic_byte(dev, GPIO_IO_SEL, u1Tmp); + + mdelay(10); + + u1Tmp = read_nic_byte(dev, GPIO_IN); + retval = (u1Tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? eRfOn : eRfOff; + } + } + + return retval; +} + +extern void dm_CheckRfCtrlGPIO(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,gpio_change_rf_wq); + struct net_device *dev = priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + + RT_RF_POWER_STATE eRfPowerStateToSet, CurRfState; + bool bActuallySet = false; + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + unsigned long flag = 0; + bool turnonbypowerdomain = false; + + +#ifdef CONFIG_RTL_RFKILL + return; +#endif + if ((priv->up_first_time == 1) || (priv->being_init_adapter)) + { + ; + return; + } + + if (priv->ResetProgress == RESET_TYPE_SILENT) + { + RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); + return; + } + + + if (pPSC->bSwRfProcessing) + { + RT_TRACE(COMP_SCAN, "GPIOChangeRFWorkItemCallBack(): Rf is in switching state.\n"); + return; + } + + RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack() ---------> \n"); + + spin_lock_irqsave(&priv->rf_ps_lock,flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack(): RF Change in progress! \n"); + return; + } else { + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + } + CurRfState = priv->rtllib->eRFPowerState; +#ifdef CONFIG_ASPM_OR_D3 + if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) + { + RT_DISABLE_ASPM(dev); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } + else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) + { +#ifdef TODO + RT_LEAVE_D3(dev, false); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); +#endif + } + +#endif + if (RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) + { + Power_DomainInit92SE(dev); + turnonbypowerdomain = true; + } + + eRfPowerStateToSet = RfOnOffDetect(dev); + if (priv->bResetInProgress) { + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + return; + } + + if ( (priv->bHwRadioOff == true) && \ + (((eRfPowerStateToSet == eRfOn)&&(priv->sw_radio_on == true)) +#ifdef CONFIG_RTLWIFI_DEBUGFS + ||priv->debug->hw_holding +#endif + )) + { + RT_TRACE(COMP_RF, "GPIOChangeRF - HW Radio ON, RF ON\n"); + printk("GPIOChangeRF - HW Radio ON, RF ON\n"); + eRfPowerStateToSet = eRfOn; + bActuallySet = true; + } else if ((priv->bHwRadioOff == false) && + ((eRfPowerStateToSet == eRfOff) || (priv->sw_radio_on == false))) + { + RT_TRACE(COMP_RF, "GPIOChangeRF - HW Radio OFF\n"); + printk("GPIOChangeRF - HW Radio OFF\n"); + eRfPowerStateToSet = eRfOff; + bActuallySet = true; + } + + if (bActuallySet) { + priv->bHwRfOffAction = 1; +#ifdef CONFIG_ASPM_OR_D3 + if (eRfPowerStateToSet == eRfOn) + { + if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) + { + RT_DISABLE_ASPM(dev); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } +#ifdef TODO + else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) + { + RT_LEAVE_D3(dev, false); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); + } +#endif + } +#endif + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); + + { +#ifdef CONFIG_CFG_80211 + struct wireless_dev *wdev = &priv->rtllib->wdev; + wiphy_rfkill_set_hw_state(wdev->wiphy, priv->bHwRadioOff); +#else + char *argv[3]; + static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; + static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; + + if (priv->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + + argv[0] = RadioPowerPath; + argv[2] = NULL; + call_usermodehelper(RadioPowerPath,argv,envp,1); + +#endif + } + + if (eRfPowerStateToSet == eRfOff) + { + if (priv->pwrdown){ + + write_nic_byte(dev, SYS_FUNC_EN+1, 0x31); + } +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) + { + RT_ENABLE_ASPM(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } +#ifdef TODO + else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) + { + RT_ENTER_D3(dev, false); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); + } +#endif +#endif + } + } + else if (eRfPowerStateToSet == eRfOff || CurRfState == eRfOff || priv->bDriverIsGoingToUnload) + { + + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && turnonbypowerdomain) + { + PHY_SetRtl8192seRfHalt(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) + { + RT_ENABLE_ASPM(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } +#ifdef TODO + else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) + { + RT_ENTER_D3(dev, false); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); + } +#endif +#endif + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + } + else + { + spin_lock_irqsave(&priv->rf_ps_lock,flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + } + RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack() <--------- \n"); +} +#endif +void dm_rf_pathcheck_workitemcallback(void *data) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,rfpath_check_wq); + struct net_device *dev =priv->rtllib->dev; +#else + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv(dev); +#endif + u8 rfpath = 0, i; + + + rfpath = read_nic_byte(dev, 0xc04); + + for (i = 0; i < RF90_PATH_MAX; i++) + { + if (rfpath & (0x01<brfpath_rxenable[i] = 1; + else + priv->brfpath_rxenable[i] = 0; + } + if (!DM_RxPathSelTable.Enable) + return; + + dm_rxpath_sel_byrssi(dev); +} + +static void dm_init_rxpath_selection(struct net_device * dev) +{ + u8 i; + struct r8192_priv *priv = rtllib_priv(dev); + DM_RxPathSelTable.Enable = 1; + DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; + DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; + if (priv->CustomerID == RT_CID_819x_Netcore) + DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; + else + DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; + DM_RxPathSelTable.DbgMode = DM_DBG_OFF; + DM_RxPathSelTable.disabledRF = 0; + for (i=0; i<4; i++) + { + DM_RxPathSelTable.rf_rssi[i] = 50; + DM_RxPathSelTable.cck_pwdb_sta[i] = -64; + DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; + } +} + +static void dm_rxpath_sel_byrssi(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0; + u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0; + u8 cck_default_Rx=0x2; + u8 cck_optional_Rx=0x3; + long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0; + u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; + u8 cur_rf_rssi; + long cur_cck_pwdb; + static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; + u8 update_cck_rx_path; + + if (priv->rf_type != RF_2T4R) + return; + + if (!cck_Rx_Path_initialized) + { + DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf); + cck_Rx_Path_initialized = 1; + } + + DM_RxPathSelTable.disabledRF = 0xf; + DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04)); + + if (priv->rtllib->mode == WIRELESS_MODE_B) + { + DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; + } + + for (i=0; istats.rx_rssi_percentage[i]; + + if (priv->brfpath_rxenable[i]) + { + rf_num++; + cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; + + if (rf_num == 1) + { + max_rssi_index = min_rssi_index = sec_rssi_index = i; + tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; + } + else if (rf_num == 2) + { + if (cur_rf_rssi >= tmp_max_rssi) + { + tmp_max_rssi = cur_rf_rssi; + max_rssi_index = i; + } + else + { + tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; + sec_rssi_index = min_rssi_index = i; + } + } + else + { + if (cur_rf_rssi > tmp_max_rssi) + { + tmp_sec_rssi = tmp_max_rssi; + sec_rssi_index = max_rssi_index; + tmp_max_rssi = cur_rf_rssi; + max_rssi_index = i; + } + else if (cur_rf_rssi == tmp_max_rssi) + { + tmp_sec_rssi = cur_rf_rssi; + sec_rssi_index = i; + } + else if ((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi)) + { + tmp_sec_rssi = cur_rf_rssi; + sec_rssi_index = i; + } + else if (cur_rf_rssi == tmp_sec_rssi) + { + if (tmp_sec_rssi == tmp_min_rssi) + { + tmp_sec_rssi = cur_rf_rssi; + sec_rssi_index = i; + } + else + { + } + } + else if ((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi)) + { + } + else if (cur_rf_rssi == tmp_min_rssi) + { + if (tmp_sec_rssi == tmp_min_rssi) + { + tmp_min_rssi = cur_rf_rssi; + min_rssi_index = i; + } + else + { + } + } + else if (cur_rf_rssi < tmp_min_rssi) + { + tmp_min_rssi = cur_rf_rssi; + min_rssi_index = i; + } + } + } + } + + rf_num = 0; + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) + { + for (i=0; ibrfpath_rxenable[i]) + { + rf_num++; + cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; + + if (rf_num == 1) + { + cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i; + tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb; + } + else if (rf_num == 2) + { + if (cur_cck_pwdb >= tmp_cck_max_pwdb) + { + tmp_cck_max_pwdb = cur_cck_pwdb; + cck_rx_ver2_max_index = i; + } + else + { + tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i; + } + } + else + { + if (cur_cck_pwdb > tmp_cck_max_pwdb) + { + tmp_cck_sec_pwdb = tmp_cck_max_pwdb; + cck_rx_ver2_sec_index = cck_rx_ver2_max_index; + tmp_cck_max_pwdb = cur_cck_pwdb; + cck_rx_ver2_max_index = i; + } + else if (cur_cck_pwdb == tmp_cck_max_pwdb) + { + tmp_cck_sec_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + } + else if ((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb)) + { + tmp_cck_sec_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + } + else if (cur_cck_pwdb == tmp_cck_sec_pwdb) + { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) + { + tmp_cck_sec_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + } + else + { + } + } + else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb)) + { + } + else if (cur_cck_pwdb == tmp_cck_min_pwdb) + { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) + { + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_min_index = i; + } + else + { + } + } + else if (cur_cck_pwdb < tmp_cck_min_pwdb) + { + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_min_index = i; + } + } + + } + } + } + + + update_cck_rx_path = 0; + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) + { + cck_default_Rx = cck_rx_ver2_max_index; + cck_optional_Rx = cck_rx_ver2_sec_index; + if (tmp_cck_max_pwdb != -64) + update_cck_rx_path = 1; + } + + if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) + { + if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) + { + DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<>i) & 0x1) + { + if (tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) + { + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<priv_wq,&priv->rfpath_check_wq,0); +} + + +static void dm_init_fsync (struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->rtllib->fsync_time_interval = 500; + priv->rtllib->fsync_rate_bitmap = 0x0f000800; + priv->rtllib->fsync_rssi_threshold = 30; +#ifdef RTL8190P + priv->rtllib->bfsync_enable = true; +#elif defined RTL8192E || defined RTL8192SE + priv->rtllib->bfsync_enable = false; +#endif + priv->rtllib->fsync_multiple_timeinterval = 3; + priv->rtllib->fsync_firstdiff_ratethreshold= 100; + priv->rtllib->fsync_seconddiff_ratethreshold= 200; + priv->rtllib->fsync_state = Default_Fsync; + +#ifdef RTL8192SE + priv->framesyncMonitor = 0; +#elif defined RTL8192E || defined RTL8190P + priv->framesyncMonitor = 1; +#endif + + init_timer(&priv->fsync_timer); + setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,(unsigned long) dev); +} + + +static void dm_deInit_fsync(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + del_timer_sync(&priv->fsync_timer); +} + +extern void dm_fsync_timer_callback(unsigned long data) +{ + struct net_device *dev = (struct net_device *)data; + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); + u32 rate_index, rate_count = 0, rate_count_diff=0; + bool bSwitchFromCountDiff = false; + bool bDoubleTimeInterval = false; + + if ( priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->bfsync_enable && + (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) + { + u32 rate_bitmap; + for (rate_index = 0; rate_index <= 27; rate_index++) + { + rate_bitmap = 1 << rate_index; + if (priv->rtllib->fsync_rate_bitmap & rate_bitmap) + rate_count+= priv->stats.received_rate_histogram[1][rate_index]; + } + + if (rate_count < priv->rate_record) + rate_count_diff = 0xffffffff - rate_count + priv->rate_record; + else + rate_count_diff = rate_count - priv->rate_record; + if (rate_count_diff < priv->rateCountDiffRecord) + { + + u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff; + if (DiffNum >= priv->rtllib->fsync_seconddiff_ratethreshold) + priv->ContiuneDiffCount++; + else + priv->ContiuneDiffCount = 0; + + if (priv->ContiuneDiffCount >=2) + { + bSwitchFromCountDiff = true; + priv->ContiuneDiffCount = 0; + } + } + else + { + priv->ContiuneDiffCount = 0; + } + + if (rate_count_diff <= priv->rtllib->fsync_firstdiff_ratethreshold) + { + bSwitchFromCountDiff = true; + priv->ContiuneDiffCount = 0; + } + priv->rate_record = rate_count; + priv->rateCountDiffRecord = rate_count_diff; + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); + if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) + { + bDoubleTimeInterval = true; + priv->bswitch_fsync = !priv->bswitch_fsync; + if (priv->bswitch_fsync) + { + #ifdef RTL8190P + write_nic_byte(dev,0xC36, 0x00); +#elif defined RTL8192E + write_nic_byte(dev,0xC36, 0x1c); + #endif + write_nic_byte(dev, 0xC3e, 0x90); + } + else + { + #ifdef RTL8190P + write_nic_byte(dev, 0xC36, 0x40); + #else + write_nic_byte(dev, 0xC36, 0x5c); + #endif + write_nic_byte(dev, 0xC3e, 0x96); + } + } + else if (priv->undecorated_smoothed_pwdb <= priv->rtllib->fsync_rssi_threshold) + { + if (priv->bswitch_fsync) + { + priv->bswitch_fsync = false; + #ifdef RTL8190P + write_nic_byte(dev, 0xC36, 0x40); +#elif defined RTL8192E + write_nic_byte(dev, 0xC36, 0x5c); + #endif + write_nic_byte(dev, 0xC3e, 0x96); + } + } + if (bDoubleTimeInterval){ + if (timer_pending(&priv->fsync_timer)) + del_timer_sync(&priv->fsync_timer); + priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval*priv->rtllib->fsync_multiple_timeinterval); + add_timer(&priv->fsync_timer); + } + else{ + if (timer_pending(&priv->fsync_timer)) + del_timer_sync(&priv->fsync_timer); + priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + add_timer(&priv->fsync_timer); + } + } + else + { + if (priv->bswitch_fsync) + { + priv->bswitch_fsync = false; + #ifdef RTL8190P + write_nic_byte(dev, 0xC36, 0x40); +#elif defined RTL8192E + write_nic_byte(dev, 0xC36, 0x5c); + #endif + write_nic_byte(dev, 0xC3e, 0x96); + } + priv->ContiuneDiffCount = 0; + #ifdef RTL8190P + write_nic_dword(dev, rOFDM0_RxDetector2, 0x164052cd); +#elif defined RTL8192E + write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); + #endif + } + RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); +} + +static void dm_StartHWFsync(struct net_device *dev) +{ +#if defined RTL8192E + u8 rf_timing = 0x77; + struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_HALDM, "%s\n", __func__); + write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + write_nic_byte(dev, 0xc3b, 0x41); +#elif defined RTL8192SE + write_nic_byte(dev, rOFDM0_RxDetector3, 0x96); +#endif +} + +static void dm_EndHWFsync(struct net_device *dev) +{ +#if defined RTL8192E + u8 rf_timing = 0xaa; + struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_HALDM,"%s\n", __func__); + write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + write_nic_byte(dev, 0xc3b, 0x49); +#elif defined RTL8192SE + write_nic_byte(dev, rOFDM0_RxDetector3, 0x94); +#endif + +} + +static void dm_EndSWFsync(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + RT_TRACE(COMP_HALDM, "%s\n", __func__); + del_timer_sync(&(priv->fsync_timer)); + + if (priv->bswitch_fsync) + { + priv->bswitch_fsync = false; + + #ifdef RTL8190P + write_nic_byte(dev, 0xC36, 0x40); +#elif defined RTL8192E + write_nic_byte(dev, 0xC36, 0x5c); +#endif + + write_nic_byte(dev, 0xC3e, 0x96); + } + + priv->ContiuneDiffCount = 0; +#ifdef RTL8192E + write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); +#endif + +} + +static void dm_StartSWFsync(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u32 rateIndex; + u32 rateBitmap; + + RT_TRACE(COMP_HALDM,"%s\n", __func__); + priv->rate_record = 0; + priv->ContiuneDiffCount = 0; + priv->rateCountDiffRecord = 0; + priv->bswitch_fsync = false; + + if (priv->rtllib->mode == WIRELESS_MODE_N_24G) + { + priv->rtllib->fsync_firstdiff_ratethreshold= 600; + priv->rtllib->fsync_seconddiff_ratethreshold = 0xffff; + } + else + { + priv->rtllib->fsync_firstdiff_ratethreshold= 200; + priv->rtllib->fsync_seconddiff_ratethreshold = 200; + } + for (rateIndex = 0; rateIndex <= 27; rateIndex++) + { + rateBitmap = 1 << rateIndex; + if (priv->rtllib->fsync_rate_bitmap & rateBitmap) + priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex]; + } + if (timer_pending(&priv->fsync_timer)) + del_timer_sync(&priv->fsync_timer); + priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + add_timer(&priv->fsync_timer); + +#ifdef RTL8192E + write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd); +#endif + +} + +void dm_check_fsync(struct net_device *dev) +{ +#define RegC38_Default 0 +#define RegC38_NonFsync_Other_AP 1 +#define RegC38_Fsync_AP_BCM 2 + struct r8192_priv *priv = rtllib_priv(dev); + static u8 reg_c38_State=RegC38_Default; + static u32 reset_cnt=0; + + RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->rtllib->fsync_rssi_threshold, priv->rtllib->fsync_time_interval, priv->rtllib->fsync_multiple_timeinterval); + RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, priv->rtllib->fsync_firstdiff_ratethreshold, priv->rtllib->fsync_seconddiff_ratethreshold); + + if ( priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) + { + if (priv->rtllib->bfsync_enable == 0) + { + switch (priv->rtllib->fsync_state) + { + case Default_Fsync: + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case SW_Fsync: + dm_EndSWFsync(dev); + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case HW_Fsync: + default: + break; + } + } + else + { + switch (priv->rtllib->fsync_state) + { + case Default_Fsync: + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case HW_Fsync: + dm_EndHWFsync(dev); + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case SW_Fsync: + default: + break; + + } + } + if (priv->framesyncMonitor) + { + if (reg_c38_State != RegC38_Fsync_AP_BCM) + { + #ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector3, 0x15); + #else + write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); + #endif + + reg_c38_State = RegC38_Fsync_AP_BCM; + } + } + } else { + switch (priv->rtllib->fsync_state) { + case HW_Fsync: + dm_EndHWFsync(dev); + priv->rtllib->fsync_state = Default_Fsync; + break; + case SW_Fsync: + dm_EndSWFsync(dev); + priv->rtllib->fsync_state = Default_Fsync; + break; + case Default_Fsync: + default: + break; + } + + if (priv->framesyncMonitor) { + if (priv->rtllib->state == RTLLIB_LINKED) { + if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { + if (reg_c38_State != RegC38_NonFsync_Other_AP) { +#ifdef RTL8190P + write_nic_byte(dev, rOFDM0_RxDetector3, 0x10); +#else + write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); +#endif + + reg_c38_State = RegC38_NonFsync_Other_AP; + } + } else if (priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) { + if (reg_c38_State) { + write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + reg_c38_State = RegC38_Default; + } + } + } else { + if (reg_c38_State) { + write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + reg_c38_State = RegC38_Default; + } + } + } + } + if (priv->framesyncMonitor) { + if (priv->reset_count != reset_cnt) { + write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + reg_c38_State = RegC38_Default; + reset_cnt = priv->reset_count; + } + } else { + if (reg_c38_State) { + write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + reg_c38_State = RegC38_Default; + } + } +} + +extern void dm_shadow_init(struct net_device *dev) +{ + u8 page; + u16 offset; + + for (page = 0; page < 5; page++) + for (offset = 0; offset < 256; offset++) + dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + + for (page = 8; page < 11; page++) + for (offset = 0; offset < 256; offset++) + dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + + for (page = 12; page < 15; page++) + for (offset = 0; offset < 256; offset++) + dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + +} + +/*---------------------------Define function prototype------------------------*/ +static void dm_init_dynamic_txpower(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + priv->rtllib->bdynamic_txpower_enable = true; + priv->bLastDTPFlag_High = false; + priv->bLastDTPFlag_Low = false; + priv->bDynamicTxHighPower = false; + priv->bDynamicTxLowPower = false; +} + +static void dm_dynamic_txpower(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + unsigned int txhipower_threshhold=0; + unsigned int txlowpower_threshold=0; + if (priv->rtllib->bdynamic_txpower_enable != true) + { + priv->bDynamicTxHighPower = false; + priv->bDynamicTxLowPower = false; + return; + } + if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && (priv->rtllib->mode == IEEE_G)){ + txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; + txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; + } + else + { + txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; + txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; + } + + + RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb); + + if (priv->rtllib->state == RTLLIB_LINKED) + { + if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) + { + priv->bDynamicTxHighPower = true; + priv->bDynamicTxLowPower = false; + } + else + { + if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) + { + priv->bDynamicTxHighPower = false; + } + if (priv->undecorated_smoothed_pwdb < 35) + { + priv->bDynamicTxLowPower = true; + } + else if (priv->undecorated_smoothed_pwdb >= 40) + { + priv->bDynamicTxLowPower = false; + } + } + } + else + { + priv->bDynamicTxHighPower = false; + priv->bDynamicTxLowPower = false; + } + + if ( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) || + (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) ) + { + RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->rtllib->current_network.channel); + + rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + } + priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; + priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; + +} + +static void dm_check_txrateandretrycount(struct net_device * dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg); + + ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg); + + ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg); +} + +static void dm_send_rssi_tofw(struct net_device *dev) +{ + DCMD_TXCMD_T tx_cmd; + struct r8192_priv *priv = rtllib_priv(dev); + + write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); + return; + tx_cmd.Op = TXCMD_SET_RX_RSSI; + tx_cmd.Length = 4; + tx_cmd.Value = priv->undecorated_smoothed_pwdb; + + cmpk_message_handle_tx(dev, (u8*)&tx_cmd, + DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); +} + +#if defined RTL8192SE +/*----------------------------------------------------------------------------- + * Function: dm_RefreshRateAdaptiveMask() + * + * Overview: Update rate table mask according to rssi + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 05/27/2009 hpfan Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void dm_RefreshRateAdaptiveMask(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + prate_adaptive pRA = (prate_adaptive)&priv->rate_adaptive; + u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; + u8 rssi_level; + + if (IS_NIC_DOWN(priv)){ + RT_TRACE(COMP_RATE,"<---- dm_RefreshRateAdaptiveMask(): driver is going to unload\n"); + return; + } + + if (!priv->rtllib->bUseRAMask){ + return; + } + + if (priv->pFirmware->FirmwareVersion >= 61 && !priv->bInformFWDriverControlDM){ + RT_TRACE(COMP_RATE, "<---- dm_RefreshRateAdaptiveMask(): inform fw driver control dm\n"); + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_CTRL_DM_BY_DRIVER); + priv->bInformFWDriverControlDM = true; + } + + if ((priv->rtllib->state == RTLLIB_LINKED && + (priv->rtllib->iw_mode == IW_MODE_INFRA))) { + + switch (pRA->PreRATRState){ + case DM_RATR_STA_HIGH: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 20; + break; + case DM_RATR_STA_MIDDLE: + HighRSSIThreshForRA = 55; + LowRSSIThreshForRA = 20; + break; + case DM_RATR_STA_LOW: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 25; + break; + default: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 20; + break; + } + + if (priv->undecorated_smoothed_pwdb > (long)HighRSSIThreshForRA) { + pRA->ratr_state = DM_RATR_STA_HIGH; + rssi_level = 1; + } else if (priv->undecorated_smoothed_pwdb > (long)LowRSSIThreshForRA) { + pRA->ratr_state = DM_RATR_STA_MIDDLE; + rssi_level = 2; + } else { + pRA->ratr_state = DM_RATR_STA_LOW; + rssi_level = 3; + } + if ((pRA->PreRATRState != pRA->ratr_state) || + ((pRA->PreRATRState == pRA->ratr_state) && + (rssi_level != priv->rssi_level))) { + RT_TRACE(COMP_RATE, "Target AP addr : "MAC_FMT"\n", + MAC_ARG(priv->rtllib->current_network.bssid)); + RT_TRACE(COMP_RATE, "RSSI = %ld\n", + priv->undecorated_smoothed_pwdb); + RT_TRACE(COMP_RATE, "RSSI_LEVEL = %d\n", rssi_level); + RT_TRACE(COMP_RATE, "PreState = %d, CurState = %d\n", + pRA->PreRATRState, pRA->ratr_state); + priv->rtllib->UpdateHalRAMaskHandler(dev, false, 0, + priv->rtllib->pHTInfo->PeerMimoPs, + priv->rtllib->mode, + priv->rtllib->pHTInfo->bCurTxBW40MHz, + rssi_level); + priv->rssi_level = rssi_level; + pRA->PreRATRState = pRA->ratr_state; + } + } + if ((priv->rtllib->state == RTLLIB_LINKED) && + (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { + int i; + struct sta_info *pEntry; + + for (i = 0; i < PEER_MAX_ASSOC; i++) { + pEntry = priv->rtllib->peer_assoc_list[i]; + if (NULL != pEntry) { + pRA = &pEntry->rate_adaptive; + switch (pRA->PreRATRState){ + case DM_RATR_STA_HIGH: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 20; + break; + case DM_RATR_STA_MIDDLE: + HighRSSIThreshForRA = 55; + LowRSSIThreshForRA = 20; + break; + case DM_RATR_STA_LOW: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 25; + break; + default: + HighRSSIThreshForRA = 50; + LowRSSIThreshForRA = 20; + break; + } + + if (pEntry->rssi_stat.UndecoratedSmoothedPWDB > HighRSSIThreshForRA) { + pRA->ratr_state = DM_RATR_STA_HIGH; + rssi_level = 1; + } else if (pEntry->rssi_stat.UndecoratedSmoothedPWDB > LowRSSIThreshForRA) { + pRA->ratr_state = DM_RATR_STA_MIDDLE; + rssi_level = 2; + } else { + pRA->ratr_state = DM_RATR_STA_LOW; + rssi_level = 3; + } + + if (pRA->PreRATRState != pRA->ratr_state) { + RT_TRACE(COMP_RATE, "AsocEntry addr : " + MAC_FMT"\n", + MAC_ARG(pEntry->macaddr)); + RT_TRACE(COMP_RATE, "RSSI = %ld\n", + pEntry->rssi_stat.UndecoratedSmoothedPWDB); + RT_TRACE(COMP_RATE, + "RSSI_LEVEL = %d\n", + rssi_level); + RT_TRACE(COMP_RATE, + "PreState = %d, CurState = %d\n", + pRA->PreRATRState, + pRA->ratr_state); + priv->rtllib->UpdateHalRAMaskHandler( + dev, false, + pEntry->aid+1, + pEntry->htinfo.MimoPs, + pEntry->wireless_mode, + pEntry->htinfo.bCurTxBW40MHz, + rssi_level); + pRA->PreRATRState = pRA->ratr_state; + } + + } + } + } +} + +void Adhoc_InitRateAdaptive(struct net_device *dev,struct sta_info *pEntry) +{ + prate_adaptive pRA = (prate_adaptive)&pEntry->rate_adaptive; + struct r8192_priv *priv = rtllib_priv(dev); + + pRA->ratr_state = DM_RATR_STA_MAX; + pRA->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; + pRA->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; + pRA->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; + + pRA->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; + pRA->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; + pRA->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; + + if (priv->rf_type == RF_2T4R) { + /* 2008/01/11 MH Modify 2T RATR table for different RSSI. */ + pRA->upper_rssi_threshold_ratr = 0x8f0f0000; + pRA->middle_rssi_threshold_ratr = 0x8d0ff000; + pRA->low_rssi_threshold_ratr = 0x8f0ff003; + pRA->low_rssi_threshold_ratr_40M = 0x8f0ff007; + pRA->low_rssi_threshold_ratr_20M = 0x8f0ff003; + } + else if (priv->rf_type == RF_1T2R) + { + pRA->upper_rssi_threshold_ratr = 0x000f0000; + pRA->middle_rssi_threshold_ratr = 0x000ff000; + pRA->low_rssi_threshold_ratr = 0x000ff003; + pRA->low_rssi_threshold_ratr_40M = 0x000ff007; + pRA->low_rssi_threshold_ratr_20M = 0x000ff003; + } + +} + + +void Adhoc_InitRateAdaptiveState(struct net_device *dev,struct sta_info *pEntry) +{ + prate_adaptive pRA = (prate_adaptive)&pEntry->rate_adaptive; + + pRA->ratr_state = DM_RATR_STA_MAX; + pRA->PreRATRState = DM_RATR_STA_MAX; +} + + +#endif +/*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h new file mode 100644 index 00000000000..1af0dc3b1cc --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -0,0 +1,331 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#ifndef __R8192UDM_H__ +#define __R8192UDM_H__ + + +/*--------------------------Define Parameters-------------------------------*/ +#define OFDM_Table_Length 19 +#define CCK_Table_length 12 + +#define DM_DIG_THRESH_HIGH 40 +#define DM_DIG_THRESH_LOW 35 + +#define DM_FALSEALARM_THRESH_LOW 40 +#define DM_FALSEALARM_THRESH_HIGH 1000 + +#define DM_DIG_HIGH_PWR_THRESH_HIGH 75 +#define DM_DIG_HIGH_PWR_THRESH_LOW 70 + +#define BW_AUTO_SWITCH_HIGH_LOW 25 +#define BW_AUTO_SWITCH_LOW_HIGH 30 + +#define DM_check_fsync_time_interval 500 + + +#define DM_DIG_BACKOFF 12 +#ifdef RTL8192SE +#define DM_DIG_MAX 0x3e +#elif defined RTL8190P || defined RTL8192E +#define DM_DIG_MAX 0x36 +#endif +#define DM_DIG_MIN 0x1c +#define DM_DIG_MIN_Netcore 0x12 + +#define DM_DIG_BACKOFF_MAX 12 +#define DM_DIG_BACKOFF_MIN -4 + +#define RxPathSelection_SS_TH_low 30 +#define RxPathSelection_diff_TH 18 + +#define RateAdaptiveTH_High 50 +#define RateAdaptiveTH_Low_20M 30 +#define RateAdaptiveTH_Low_40M 10 +#define VeryLowRSSI 15 + +#ifdef RTL8192SE +#define CTSToSelfTHVal 30 +#elif defined RTL8190P || defined RTL8192E +#define CTSToSelfTHVal 35 +#endif + +#define WAIotTHVal 25 + +#define E_FOR_TX_POWER_TRACK 300 +#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 +#define TX_POWER_NEAR_FIELD_THRESH_LOW 62 +#define TX_POWER_ATHEROAP_THRESH_HIGH 78 +#define TX_POWER_ATHEROAP_THRESH_LOW 72 + +#define Current_Tx_Rate_Reg 0x1e0 +#define Initial_Tx_Rate_Reg 0x1e1 +#define Tx_Retry_Count_Reg 0x1ac +#define RegC38_TH 20 + +#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 +#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 + +#define TxHighPwrLevel_Normal 0 +#define TxHighPwrLevel_Level1 1 +#define TxHighPwrLevel_Level2 2 + +#define DM_Type_ByFW 0 +#define DM_Type_ByDriver 1 + +/*--------------------------Define Parameters-------------------------------*/ + + +/*------------------------------Define structure----------------------------*/ +typedef struct _dynamic_initial_gain_threshold_ +{ + u8 dig_enable_flag; + u8 dig_algorithm; + u8 Dig_TwoPort_Algorithm; + u8 Dig_Ext_Port_Stage; + u8 dbg_mode; + u8 dig_algorithm_switch; + + long rssi_low_thresh; + long rssi_high_thresh; + + u32 FALowThresh; + u32 FAHighThresh; + + long rssi_high_power_lowthresh; + long rssi_high_power_highthresh; + + u8 dig_state; + u8 dig_highpwr_state; + u8 CurSTAConnectState; + u8 PreSTAConnectState; + u8 CurAPConnectState; + u8 PreAPConnectState; + + u8 curpd_thstate; + u8 prepd_thstate; + u8 curcs_ratio_state; + u8 precs_ratio_state; + + u32 pre_ig_value; + u32 cur_ig_value; + + u8 Backoff_Enable_Flag; + u8 backoff_val; + char BackoffVal_range_max; + char BackoffVal_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + bool initialgain_lowerbound_state; + + long rssi_val; +}dig_t; + +typedef enum tag_dynamic_init_gain_state_definition +{ + DM_STA_DIG_OFF = 0, + DM_STA_DIG_ON, + DM_STA_DIG_MAX +}dm_dig_sta_e; + + +typedef enum tag_dynamic_ratr_state_definition +{ + DM_RATR_STA_HIGH = 0, + DM_RATR_STA_MIDDLE = 1, + DM_RATR_STA_LOW = 2, + DM_RATR_STA_MAX +}dm_ratr_sta_e; + +typedef enum tag_dynamic_init_gain_operation_type_definition +{ + DIG_TYPE_THRESH_HIGH = 0, + DIG_TYPE_THRESH_LOW = 1, + DIG_TYPE_THRESH_HIGHPWR_HIGH = 2, + DIG_TYPE_THRESH_HIGHPWR_LOW = 3, + DIG_TYPE_DBG_MODE = 4, + DIG_TYPE_RSSI = 5, + DIG_TYPE_ALGORITHM = 6, + DIG_TYPE_BACKOFF = 7, + DIG_TYPE_PWDB_FACTOR = 8, + DIG_TYPE_RX_GAIN_MIN = 9, + DIG_TYPE_RX_GAIN_MAX = 10, + DIG_TYPE_ENABLE = 20, + DIG_TYPE_DISABLE = 30, + DIG_OP_TYPE_MAX +}dm_dig_op_e; + +typedef enum tag_dig_algorithm_definition +{ + DIG_ALGO_BY_FALSE_ALARM = 0, + DIG_ALGO_BY_RSSI = 1, + DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM = 2, + DIG_ALGO_BY_TOW_PORT = 3, + DIG_ALGO_MAX +}dm_dig_alg_e; + +typedef enum tag_DIG_TWO_PORT_ALGO_Definition +{ + DIG_TWO_PORT_ALGO_RSSI = 0, + DIG_TWO_PORT_ALGO_FALSE_ALARM = 1, +}DM_DIG_TWO_PORT_ALG_E; + + +typedef enum tag_DIG_EXT_PORT_ALGO_Definition +{ + DIG_EXT_PORT_STAGE_0 = 0, + DIG_EXT_PORT_STAGE_1 = 1, + DIG_EXT_PORT_STAGE_2 = 2, + DIG_EXT_PORT_STAGE_3 = 3, + DIG_EXT_PORT_STAGE_MAX = 4, +}DM_DIG_EXT_PORT_ALG_E; + +typedef enum tag_dig_dbgmode_definition +{ + DIG_DBG_OFF = 0, + DIG_DBG_ON = 1, + DIG_DBG_MAX +}dm_dig_dbg_e; + +typedef enum tag_dig_connect_definition +{ + DIG_STA_DISCONNECT = 0, + DIG_STA_CONNECT = 1, + DIG_STA_BEFORE_CONNECT = 2, + DIG_AP_DISCONNECT = 3, + DIG_AP_CONNECT = 4, + DIG_AP_ADD_STATION = 5, + DIG_CONNECT_MAX +}dm_dig_connect_e; + +typedef enum tag_dig_packetdetection_threshold_definition +{ + DIG_PD_AT_LOW_POWER = 0, + DIG_PD_AT_NORMAL_POWER = 1, + DIG_PD_AT_HIGH_POWER = 2, + DIG_PD_MAX +}dm_dig_pd_th_e; + +typedef enum tag_dig_cck_cs_ratio_state_definition +{ + DIG_CS_RATIO_LOWER = 0, + DIG_CS_RATIO_HIGHER = 1, + DIG_CS_MAX +}dm_dig_cs_ratio_e; +typedef struct _Dynamic_Rx_Path_Selection_ +{ + u8 Enable; + u8 DbgMode; + u8 cck_method; + u8 cck_Rx_path; + + u8 SS_TH_low; + u8 diff_TH; + u8 disabledRF; + u8 reserved; + + u8 rf_rssi[4]; + u8 rf_enable_rssi_th[4]; + long cck_pwdb_sta[4]; +}DRxPathSel; + +typedef enum tag_CCK_Rx_Path_Method_Definition +{ + CCK_Rx_Version_1 = 0, + CCK_Rx_Version_2= 1, + CCK_Rx_Version_MAX +}DM_CCK_Rx_Path_Method; + + +typedef enum tag_DM_DbgMode_Definition +{ + DM_DBG_OFF = 0, + DM_DBG_ON = 1, + DM_DBG_MAX +}DM_DBG_E; + +typedef struct tag_Tx_Config_Cmd_Format +{ + u32 Op; + u32 Length; + u32 Value; +}DCMD_TXCMD_T, *PDCMD_TXCMD_T; +/*------------------------------Define structure----------------------------*/ + + +/*------------------------Export global variable----------------------------*/ +extern dig_t dm_digtable; +extern u8 dm_shadow[16][256]; +extern DRxPathSel DM_RxPathSelTable; + +extern u8 test_flag; +/*------------------------Export global variable----------------------------*/ + + +/*------------------------Export Marco Definition---------------------------*/ +#define DM_APInitGainChangeNotify(Event) {dm_digtable.CurAPConnectState = Event;} +/*------------------------Export Marco Definition---------------------------*/ + + +/*--------------------------Exported Function prototype---------------------*/ +/*--------------------------Exported Function prototype---------------------*/ +extern void init_hal_dm(struct net_device *dev); +extern void deinit_hal_dm(struct net_device *dev); + +extern void hal_dm_watchdog(struct net_device *dev); + + +extern void init_rate_adaptive(struct net_device *dev); +extern void dm_txpower_trackingcallback(void *data); + +#ifndef RTL8192SE +extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14); +#endif + +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value); +extern void DM_ChangeFsyncSetting(struct net_device *dev, + s32 DM_Type, + s32 DM_Value); +extern void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, + u32 force_value); +extern void dm_init_edca_turbo(struct net_device *dev); +extern void dm_rf_operation_test_callback(unsigned long data); +extern void dm_rf_pathcheck_workitemcallback(void *data); +extern void dm_fsync_timer_callback(unsigned long data); +extern void dm_check_fsync(struct net_device *dev); +extern void dm_shadow_init(struct net_device *dev); +extern void dm_initialize_txpower_tracking(struct net_device *dev); + +#if (defined RTL8192E || defined RTL8192SE) +extern void dm_CheckRfCtrlGPIO(void *data); +#endif + +#ifdef RTL8192SE +extern void Power_DomainInit92SE(struct net_device *dev); +#endif + +extern void dm_InitRateAdaptiveMask(struct net_device * dev); + +#endif /*__R8192UDM_H__ */ + +/* End of r8192U_dm.h */ diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c new file mode 100644 index 00000000000..14a8c1d13e2 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -0,0 +1,141 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ +#include "rtl_core.h" +#include "rtl_eeprom.h" + +void eprom_cs(struct net_device *dev, short bit) +{ + if (bit) + write_nic_byte(dev, EPROM_CMD, + (1<epromtype==EEPROM_93C56){ + addr_str[7]=addr & 1; + addr_str[6]=addr & (1<<1); + addr_str[5]=addr & (1<<2); + addr_str[4]=addr & (1<<3); + addr_str[3]=addr & (1<<4); + addr_str[2]=addr & (1<<5); + addr_str[1]=addr & (1<<6); + addr_str[0]=addr & (1<<7); + addr_len=8; + }else{ + addr_str[5]=addr & 1; + addr_str[4]=addr & (1<<1); + addr_str[3]=addr & (1<<2); + addr_str[2]=addr & (1<<3); + addr_str[1]=addr & (1<<4); + addr_str[0]=addr & (1<<5); + addr_len=6; + } + eprom_cs(dev, 1); + eprom_ck_cycle(dev); + eprom_send_bits_string(dev, read_cmd, 3); + eprom_send_bits_string(dev, addr_str, addr_len); + + eprom_w(dev, 0); + + for (i = 0; i < 16; i++){ + eprom_ck_cycle(dev); + ret |= (eprom_r(dev)<<(15-i)); + } + + eprom_cs(dev, 0); + eprom_ck_cycle(dev); + + write_nic_byte(dev, EPROM_CMD, + (EPROM_CMD_NORMAL<, et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + + +#define EPROM_DELAY 10 + +u32 eprom_read(struct net_device *dev,u32 addr); diff --git a/drivers/staging/rtl8192e/rtl_ethtool.c b/drivers/staging/rtl8192e/rtl_ethtool.c new file mode 100644 index 00000000000..6c732e18540 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_ethtool.c @@ -0,0 +1,59 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + ***************************************************************************** + */ +#include +#include +#include + +#include "rtl_core.h" + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) +static void rtl819x_ethtool_get_drvinfo(struct net_device *dev, + struct ethtool_drvinfo *info) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + strcpy(info->driver, DRV_NAME); + strcpy(info->version, DRV_VERSION); +#if defined RTL8192SE + snprintf(info->fw_version, sizeof(info->fw_version), "%d", + priv->pFirmware->FirmwareVersion); +#endif + strcpy(info->bus_info, pci_name(priv->pdev)); +} + +static u32 rtl819x_ethtool_get_link(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + return ((priv->rtllib->state == RTLLIB_LINKED) || + (priv->rtllib->state == RTLLIB_LINKED_SCANNING)); +} + +const struct ethtool_ops rtl819x_ethtool_ops = { + .get_drvinfo = rtl819x_ethtool_get_drvinfo, + .get_link = rtl819x_ethtool_get_link, +}; +#endif diff --git a/drivers/staging/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl_pci.c new file mode 100644 index 00000000000..39b96c12af5 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_pci.c @@ -0,0 +1,444 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + *****************************************************************************/ +#include "rtl_pci.h" +#include "rtl_core.h" + +#if defined RTL8192CE || defined RTL8192SE +bool +rtl8192_get_LinkControl_field( + struct net_device *dev, + u8 BusNum, + u8 DevNum, + u8 FuncNum + ) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + RT_PCI_CAPABILITIES_HEADER CapabilityHdr; + unsigned char CapabilityOffset, Num4Bytes; + u32 PciCfgAddrPort=0; + u8 LinkCtrlReg; + bool Status = false; + + if ( BusNum == 0xff && DevNum == 0xff && FuncNum == 0xff ){ + printk("GetLinkControlField(): Fail to find PCIe Capability\n"); + return false; + } + + + PciCfgAddrPort= (BusNum<< 16)|(DevNum << 11)|(FuncNum << 8)|(1 << 31); + + + Num4Bytes = 0x34/4; + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+( Num4Bytes<< 2)); + NdisRawReadPortUchar(PCI_CONF_DATA, &CapabilityOffset); + + + while (CapabilityOffset != 0) + { + Num4Bytes = CapabilityOffset/4; + + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+( Num4Bytes<< 2)); + NdisRawReadPortUshort(PCI_CONF_DATA, (u16*)&CapabilityHdr); + + if (CapabilityHdr.CapabilityID == PCI_CAPABILITY_ID_PCI_EXPRESS) + { + break; + } + else + { + CapabilityOffset = CapabilityHdr.Next; + } + } + + + if (CapabilityHdr.CapabilityID == PCI_CAPABILITY_ID_PCI_EXPRESS) + { + Num4Bytes = (CapabilityOffset+0x10)/4; + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); + NdisRawReadPortUchar(PCI_CONF_DATA, &LinkCtrlReg); + + priv->NdisAdapter.PciBridgePCIeHdrOffset = CapabilityOffset; + priv->NdisAdapter.PciBridgeLinkCtrlReg = LinkCtrlReg; + + Status = true; + } + else + { + printk("GetLinkControlField(): Cannot Find PCIe Capability\n"); + } + + return Status; +} + +bool +rtl8192_get_pci_BusInfo( + struct net_device *dev, + u16 VendorId, + u16 DeviceId, + u8 IRQL, + u8 BaseCode, + u8 SubClass, + u8 filed19val, + u8* BusNum, + u8* DevNum, + u8* FuncNum + ) +{ + + u8 busNumIdx, deviceNumIdx, functionNumIdx; + u32 PciCfgAddrPort=0; + u32 devVenID = 0, classCode, field19, headertype; + u16 venId, devId; + u8 basec, subc, irqLine; + u16 RegOffset; + bool bSingleFunc = false; + bool bBridgeChk = false; + + *BusNum = 0xFF; + *DevNum = 0xFF; + *FuncNum = 0xFF; + + if ((BaseCode == PCI_CLASS_BRIDGE_DEV) && (SubClass==PCI_SUBCLASS_BR_PCI_TO_PCI) && (filed19val==U1DONTCARE)) + bBridgeChk = true; + + for (busNumIdx = 0; busNumIdx < PCI_MAX_BRIDGE_NUMBER ; busNumIdx++) + { + for (deviceNumIdx = 0; deviceNumIdx < PCI_MAX_DEVICES; deviceNumIdx ++) + { + bSingleFunc = false; + for (functionNumIdx = 0; functionNumIdx < PCI_MAX_FUNCTION; functionNumIdx++) + { + + if (functionNumIdx == 0) + { + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (3 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &headertype); + headertype = ((headertype >> 16) & 0x0080) >> 7; + if ( headertype == 0) + bSingleFunc = true; + } + else + { + if (bSingleFunc == true) break; + } + + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); + NdisRawReadPortUlong(PCI_CONF_DATA, &devVenID); + + if ( devVenID == 0xFFFFFFFF||devVenID == 0 ) continue; + + RegOffset = 0x3C; + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31)|(RegOffset & 0xFFFFFFFC); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); + NdisRawReadPortUchar((PCI_CONF_DATA+ (RegOffset & 0x3)), &irqLine); + + venId = (u16)(devVenID >> 0)& 0xFFFF; + devId = (u16)(devVenID >> 16)& 0xFFFF; + + if (!bBridgeChk && (venId != VendorId) && (VendorId != U2DONTCARE)) + continue; + + if (!bBridgeChk && (devId != DeviceId) && (DeviceId != U2DONTCARE)) + continue; + + if (!bBridgeChk && (irqLine != IRQL) && (IRQL != U1DONTCARE)) + continue; + + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (2 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &classCode); + classCode = classCode >> 8; + + basec = (u8)(classCode >>16 ) & 0xFF; + subc = (u8)(classCode >>8 ) & 0xFF; + if (bBridgeChk && (venId != VendorId) &&(basec == BaseCode) && (subc== SubClass ) ) + return true; + + if (bBridgeChk && (venId != VendorId) && (VendorId != U2DONTCARE)) + continue; + + if (bBridgeChk && (devId != DeviceId) && (DeviceId != U2DONTCARE)) + continue; + + if (bBridgeChk && (irqLine != IRQL) && (IRQL != U1DONTCARE)) + continue; + + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (6 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &field19); + field19 = (field19 >> 8)& 0xFF; + + if ((basec == BaseCode) && (subc== SubClass ) && ((field19 == filed19val) ||(filed19val==U1DONTCARE) )) + { + *BusNum = busNumIdx; + *DevNum = deviceNumIdx; + *FuncNum = functionNumIdx; + + printk( "GetPciBusInfo(): Find Device(%X:%X) bus=%d dev=%d, func=%d\n",VendorId, DeviceId, busNumIdx, deviceNumIdx, functionNumIdx); + return true; + } + } + } + } + + printk( "GetPciBusInfo(): Cannot Find Device(%X:%X:%X)\n",VendorId, DeviceId, devVenID); + return false; +} + +bool rtl8192_get_pci_BridegInfo( + struct net_device *dev, + u8 BaseCode, + u8 SubClass, + u8 filed19val, + u8* BusNum, + u8* DevNum, + u8* FuncNum, + u16* VendorId, + u16* DeviceId + ) + +{ + + u8 busNumIdx, deviceNumIdx, functionNumIdx; + u32 PciCfgAddrPort=0; + u32 devVenID, classCode, field19, headertype; + u16 venId, devId; + u8 basec, subc, irqLine; + u16 RegOffset; + bool bSingleFunc = false; + + *BusNum = 0xFF; + *DevNum = 0xFF; + *FuncNum = 0xFF; + + for (busNumIdx = 0; busNumIdx < PCI_MAX_BRIDGE_NUMBER ; busNumIdx++) + { + for (deviceNumIdx = 0; deviceNumIdx < PCI_MAX_DEVICES; deviceNumIdx ++) + { + bSingleFunc = false; + for (functionNumIdx = 0; functionNumIdx < PCI_MAX_FUNCTION; functionNumIdx++) + { + + if (functionNumIdx == 0) + { + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (3 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &headertype); + headertype = ((headertype >> 16) & 0x0080) >> 7; + if ( headertype == 0) + bSingleFunc = true; + } + else + { + if ( bSingleFunc ==true ) break; + } + + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); + NdisRawReadPortUlong(PCI_CONF_DATA, &devVenID); + + RegOffset = 0x3C; + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31)|(RegOffset & 0xFFFFFFFC); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); + NdisRawReadPortUchar((PCI_CONF_DATA+ (RegOffset & 0x3)), &irqLine); + + venId = (u16)(devVenID >> 0)& 0xFFFF; + devId = (u16)(devVenID >> 16)& 0xFFFF; + + PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (2 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &classCode); + classCode = classCode >> 8; + + basec = (u8)(classCode >>16 ) & 0xFF; + subc = (u8)(classCode >>8 ) & 0xFF; + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (6 << 2)); + NdisRawReadPortUlong(PCI_CONF_DATA, &field19); + field19 = (field19 >> 8)& 0xFF; + + if ((basec == BaseCode) && (subc== SubClass ) && ((field19 == filed19val) ||(filed19val==U1DONTCARE) )) + { + *BusNum = busNumIdx; + *DevNum = deviceNumIdx; + *FuncNum = functionNumIdx; + *VendorId = venId; + *DeviceId = devId; + + printk("GetPciBridegInfo : Find Device(%X:%X) bus=%d dev=%d, func=%d\n", + venId, devId, busNumIdx, deviceNumIdx, functionNumIdx); + + return true; + } + } + } + } + + printk( "GetPciBridegInfo(): Cannot Find PciBridge for Device\n"); + + return false; +} + + +static u16 PciBridgeVendorArray[PCI_BRIDGE_VENDOR_MAX] + = {INTEL_VENDOR_ID,ATI_VENDOR_ID,AMD_VENDOR_ID,SIS_VENDOR_ID}; + +void +rtl8192_pci_find_BridgeInfo(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + u8 PciBridgeBusNum = 0xff; + u8 PciBridgeDevNum = 0xff; + u8 PciBridgeFuncNum = 0xff; + u16 PciBridgeVendorId= 0xff; + u16 PciBridgeDeviceId = 0xff; + u8 tmp = 0; + + rtl8192_get_pci_BridegInfo(dev, + PCI_CLASS_BRIDGE_DEV, + PCI_SUBCLASS_BR_PCI_TO_PCI , + priv->NdisAdapter.BusNumber, + &PciBridgeBusNum, + &PciBridgeDevNum, + &PciBridgeFuncNum, + &PciBridgeVendorId, + &PciBridgeDeviceId); + + + priv->NdisAdapter.PciBridgeVendor = PCI_BRIDGE_VENDOR_UNKNOWN; + + for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) { + if (PciBridgeVendorId == PciBridgeVendorArray[tmp]) { + priv->NdisAdapter.PciBridgeVendor = tmp; + printk("Pci Bridge Vendor is found index: %d\n",tmp); + break; + } + } + printk("Pci Bridge Vendor is %x\n",PciBridgeVendorArray[tmp]); + + priv->NdisAdapter.PciBridgeBusNum = PciBridgeBusNum; + priv->NdisAdapter.PciBridgeDevNum = PciBridgeDevNum; + priv->NdisAdapter.PciBridgeFuncNum = PciBridgeFuncNum; + priv->NdisAdapter.PciBridgeVendorId = PciBridgeVendorId; + priv->NdisAdapter.PciBridgeDeviceId = PciBridgeDeviceId; + + +} +#endif + +static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + u8 tmp; + int pos; + u8 LinkCtrlReg; + + pos = pci_find_capability(priv->pdev, PCI_CAP_ID_EXP); + pci_read_config_byte(priv->pdev, pos + PCI_EXP_LNKCTL, &LinkCtrlReg); + priv->NdisAdapter.LinkCtrlReg = LinkCtrlReg; + + RT_TRACE(COMP_INIT, "Link Control Register =%x\n", priv->NdisAdapter.LinkCtrlReg); + + pci_read_config_byte(pdev, 0x98, &tmp); + tmp |=BIT4; + pci_write_config_byte(pdev, 0x98, tmp); + + tmp = 0x17; + pci_write_config_byte(pdev, 0x70f, tmp); +} + +bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u16 VenderID; + u16 DeviceID; + u8 RevisionID; + u16 IrqLine; + + VenderID = pdev->vendor; + DeviceID = pdev->device; + RevisionID = pdev->revision; + pci_read_config_word(pdev, 0x3C, &IrqLine); + + priv->card_8192 = priv->ops->nic_type; + + if (DeviceID == 0x8172) { + switch (RevisionID) { + case HAL_HW_PCI_REVISION_ID_8192PCIE: + printk("Adapter(8192 PCI-E) is found - DeviceID=%x\n", DeviceID); + priv->card_8192 = NIC_8192E; + break; + case HAL_HW_PCI_REVISION_ID_8192SE: + printk("Adapter(8192SE) is found - DeviceID=%x\n", DeviceID); + priv->card_8192 = NIC_8192SE; + break; + default: + printk("UNKNOWN nic type(%4x:%4x)\n", pdev->vendor, pdev->device); + priv->card_8192 = NIC_UNKNOWN; + return false; + } + } + + if (priv->ops->nic_type != priv->card_8192) { + printk("Detect info(%x) and hardware info(%x) not match!\n", + priv->ops->nic_type, priv->card_8192); + printk("Please select proper driver before install!!!!\n"); + return false; + } + +#if defined RTL8192CE || defined RTL8192SE + rtl8192_get_pci_BusInfo(dev, + VenderID, + DeviceID, + (u8)IrqLine, + 0x02,0x80, U1DONTCARE, + &priv->NdisAdapter.BusNumber, + &priv->NdisAdapter.DevNumber, + &priv->NdisAdapter.FuncNumber); + + rtl8192_pci_find_BridgeInfo(dev); + +#ifdef RTL8192SE + if (priv->NdisAdapter.PciBridgeVendor != PCI_BRIDGE_VENDOR_UNKNOWN) +#endif + { + rtl8192_get_LinkControl_field(dev, priv->NdisAdapter.PciBridgeBusNum, + priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum); + } +#endif + + rtl8192_parse_pci_configuration(pdev, dev); + + return true; +} diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h new file mode 100644 index 00000000000..22662725b40 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -0,0 +1,104 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + ******************************************************************************/ +#ifndef _RTL_PCI_H +#define _RTL_PCI_H + +#include +#include +#include "rtllib.h" + +static inline void NdisRawWritePortUlong(u32 port, u32 val) +{ + outl(val, port); +} + +static inline void NdisRawWritePortUchar(u32 port, u8 val) +{ + outb(val, port); +} + +static inline void NdisRawReadPortUchar(u32 port, u8 *pval) +{ + *pval = inb(port); +} + +static inline void NdisRawReadPortUshort(u32 port, u16 *pval) +{ + *pval = inw(port); +} + +static inline void NdisRawReadPortUlong(u32 port, u32 *pval) +{ + *pval = inl(port); +} + +typedef struct _mp_adapter{ + u8 LinkCtrlReg; + + u8 BusNumber; + u8 DevNumber; + u8 FuncNumber; + + u8 PciBridgeBusNum; + u8 PciBridgeDevNum; + u8 PciBridgeFuncNum; + u8 PciBridgeVendor; + u16 PciBridgeVendorId; + u16 PciBridgeDeviceId; + u8 PciBridgePCIeHdrOffset; + u8 PciBridgeLinkCtrlReg; +}mp_adapter,*pmp_adapter; + +typedef struct _RT_PCI_CAPABILITIES_HEADER { + unsigned char CapabilityID; + unsigned char Next; +} RT_PCI_CAPABILITIES_HEADER, *PRT_PCI_CAPABILITIES_HEADER; + +#define PCI_MAX_BRIDGE_NUMBER 255 +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 + +#define PCI_CONF_ADDRESS 0x0CF8 +#define PCI_CONF_DATA 0x0CFC + +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 + +#define U1DONTCARE 0xFF +#define U2DONTCARE 0xFFFF +#define U4DONTCARE 0xFFFFFFFF + +#define INTEL_VENDOR_ID 0x8086 +#define SIS_VENDOR_ID 0x1039 +#define ATI_VENDOR_ID 0x1002 +#define ATI_DEVICE_ID 0x7914 +#define AMD_VENDOR_ID 0x1022 + +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 + +struct net_device; +bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev); + +#endif diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c new file mode 100644 index 00000000000..4fbe819b59c --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -0,0 +1,168 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#ifdef CONFIG_PM_RTL +#include "rtl_core.h" +#include "r8192E_hw.h" +#include "r8190P_rtl8256.h" +#include "rtl_pm.h" + +int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state) +{ + printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); + return(-EAGAIN); +} + + +int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv = rtllib_priv(dev); +#if !(defined RTL8192SE || defined RTL8192CE) + u32 ulRegRead; +#endif + + RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); + printk("============> r8192E suspend call.\n"); +#ifdef ENABLE_GPIO_RADIO_CTL + del_timer_sync(&priv->gpio_polling_timer); + cancel_delayed_work(&priv->gpio_change_rf_wq); + priv->polling_timer_on = 0; +#endif + + if (!netif_running(dev)){ + printk("RTL819XE:UI is open out of suspend function\n"); + goto out_pci_suspend; + } + +#ifdef HAVE_NET_DEVICE_OPS + if (dev->netdev_ops->ndo_stop) + dev->netdev_ops->ndo_stop(dev); +#else + dev->stop(dev); +#endif + netif_device_detach(dev); + +#if !(defined RTL8192SE || defined RTL8192CE) + if (!priv->rtllib->bSupportRemoteWakeUp) { + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT,true); + ulRegRead = read_nic_dword(dev, CPU_GEN); + ulRegRead|=CPU_GEN_SYSTEM_RESET; + write_nic_dword(dev, CPU_GEN, ulRegRead); + } else { + write_nic_dword(dev, WFCRC0, 0xffffffff); + write_nic_dword(dev, WFCRC1, 0xffffffff); + write_nic_dword(dev, WFCRC2, 0xffffffff); +#ifdef RTL8190P + { + u8 ucRegRead; + ucRegRead = read_nic_byte(dev, GPO); + ucRegRead |= BIT0; + write_nic_byte(dev, GPO, ucRegRead); + } +#endif + write_nic_byte(dev, PMR, 0x5); + write_nic_byte(dev, MacBlkCtrl, 0xa); + } +#endif +out_pci_suspend: + RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); + printk("r8192E support WOL call??????????????????????\n"); + if (priv->rtllib->bSupportRemoteWakeUp) { + RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); + } + pci_save_state(pdev); + pci_disable_device(pdev); + pci_enable_wake(pdev, pci_choose_state(pdev,state),\ + priv->rtllib->bSupportRemoteWakeUp?1:0); + pci_set_power_state(pdev,pci_choose_state(pdev,state)); + + mdelay(20); + + return 0; +} + +int rtl8192E_resume (struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); +#if defined ENABLE_GPIO_RADIO_CTL || !(defined RTL8192SE || defined RTL8192CE) + struct r8192_priv *priv = rtllib_priv(dev); +#endif + int err; + u32 val; + + RT_TRACE(COMP_POWER, "================>r8192E resume call."); + printk("================>r8192E resume call.\n"); + + pci_set_power_state(pdev, PCI_D0); + + err = pci_enable_device(pdev); + if (err) { + printk(KERN_ERR "%s: pci_enable_device failed on resume\n", + dev->name); + return err; + } + pci_restore_state(pdev); + + pci_read_config_dword(pdev, 0x40, &val); + if ((val & 0x0000ff00) != 0) { + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); + } + + pci_enable_wake(pdev, PCI_D0, 0); + +#ifdef ENABLE_GPIO_RADIO_CTL + if (priv->polling_timer_on == 0){ + check_rfctrl_gpio_timer((unsigned long)dev); + } +#endif + + if (!netif_running(dev)){ + printk("RTL819XE:UI is open out of resume function\n"); + goto out; + } + + netif_device_attach(dev); +#ifdef HAVE_NET_DEVICE_OPS + if (dev->netdev_ops->ndo_open) + dev->netdev_ops->ndo_open(dev); +#else + dev->open(dev); +#endif + +#if !(defined RTL8192SE || defined RTL8192CE) + if (!priv->rtllib->bSupportRemoteWakeUp) { + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT,true); + } +#endif + +out: + RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); + return 0; +} + + +int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) +{ + printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", + state.event, enable); + return(-EAGAIN); +} + +#endif diff --git a/drivers/staging/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl_pm.h new file mode 100644 index 00000000000..edf8427dd81 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_pm.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#ifdef CONFIG_PM_RTL + +#ifndef R8192E_PM_H +#define R8192E_PM_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +#define pm_message_t u32 +#endif + +int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); +int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); +int rtl8192E_resume (struct pci_dev *dev); +int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); + +#endif + +#endif diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c new file mode 100644 index 00000000000..cf401352c62 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -0,0 +1,649 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + *****************************************************************************/ +#include "rtl_ps.h" +#include "rtl_core.h" +#include "r8192E_phy.h" +#include "r8192E_phyreg.h" +#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */ +#include "r8192E_cmdpkt.h" + +void rtl8192_hw_sleep_down(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + unsigned long flags = 0; +#ifdef CONFIG_ASPM_OR_D3 + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); +#endif + spin_lock_irqsave(&priv->rf_ps_lock,flags); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in progress! \n"); + return; + } + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); + +#ifdef CONFIG_RTLWIFI_DEBUGFS + if (priv->debug->hw_holding) { + return; + } +#endif + MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) + { + RT_ENABLE_ASPM(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); + } +#endif +} + +void rtl8192_hw_sleep_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_sleep_wq); + struct net_device *dev = ieee->dev; + rtl8192_hw_sleep_down(dev); +} + +void rtl8192_hw_wakeup(struct net_device* dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + unsigned long flags = 0; +#ifdef CONFIG_ASPM_OR_D3 + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); +#endif + spin_lock_irqsave(&priv->rf_ps_lock,flags); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in progress! \n"); + queue_delayed_work_rsl(priv->rtllib->wq,&priv->rtllib->hw_wakeup_wq,MSECS(10)); + return; + } + spin_unlock_irqrestore(&priv->rf_ps_lock,flags); +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) { + RT_DISABLE_ASPM(dev); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); + } +#endif + RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS,false); +} + +void rtl8192_hw_wakeup_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_wakeup_wq); + struct net_device *dev = ieee->dev; + rtl8192_hw_wakeup(dev); + +} + +#define MIN_SLEEP_TIME 50 +#define MAX_SLEEP_TIME 10000 +void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + u32 rb = jiffies; + unsigned long flags; + + spin_lock_irqsave(&priv->ps_lock,flags); + + tl -= MSECS(8+16+7); + + if (((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) + ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + spin_unlock_irqrestore(&priv->ps_lock,flags); + printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + return; + } + + if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| + ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| + ((tlMSECS(MAX_SLEEP_TIME)))) { + printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + spin_unlock_irqrestore(&priv->ps_lock,flags); + return; + } + { + u32 tmp = (tl>rb)?(tl-rb):(rb-tl); + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq,tmp); + } + queue_delayed_work_rsl(priv->rtllib->wq, + (void *)&priv->rtllib->hw_sleep_wq,0); + spin_unlock_irqrestore(&priv->ps_lock,flags); +} + +void InactivePsWorkItemCallback(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() ---------> \n"); + pPSC->bSwRfProcessing = true; + + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", \ + pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->eInactivePowerState == eRfOn) + { + + if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) + { + RT_DISABLE_ASPM(dev); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } +#ifdef TODO + else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) + { + RT_LEAVE_D3(dev, false); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); + } +#endif + } +#endif + MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); + +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->eInactivePowerState == eRfOff) + { + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) + { + RT_ENABLE_ASPM(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); + } +#ifdef TODO + else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) + { + RT_ENTER_D3(dev, false); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); + } +#endif + } +#endif + + pPSC->bSwRfProcessing = false; + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <--------- \n"); +} + +void +IPSEnter(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + RT_RF_POWER_STATE rtState; + + if (pPSC->bInactivePs) + { + rtState = priv->rtllib->eRFPowerState; + if (rtState == eRfOn && !pPSC->bSwRfProcessing &&\ + (priv->rtllib->state != RTLLIB_LINKED)&&\ + (priv->rtllib->iw_mode != IW_MODE_MASTER)) + { + RT_TRACE(COMP_PS,"IPSEnter(): Turn off RF.\n"); + pPSC->eInactivePowerState = eRfOff; + priv->isRFOff = true; + priv->bInPowerSaveMode = true; + InactivePsWorkItemCallback(dev); + } + } +} + +void +IPSLeave(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + RT_RF_POWER_STATE rtState; + + if (pPSC->bInactivePs) + { + rtState = priv->rtllib->eRFPowerState; + if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_PS, "IPSLeave(): Turn on RF.\n"); + pPSC->eInactivePowerState = eRfOn; + priv->bInPowerSaveMode = false; + InactivePsWorkItemCallback(dev); + } + } +} +void IPSLeave_wq(void *data) +{ + struct rtllib_device *ieee = container_of_work_rsl(data,struct rtllib_device,ips_leave_wq); + struct net_device *dev = ieee->dev; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); +} + +void rtllib_ips_leave_wq(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + RT_RF_POWER_STATE rtState; + rtState = priv->rtllib->eRFPowerState; + + if (priv->rtllib->PowerSaveControl.bInactivePs){ + if (rtState == eRfOff){ + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + return; + } + else{ + printk("=========>%s(): IPSLeave\n",__func__); + queue_work_rsl(priv->rtllib->wq,&priv->rtllib->ips_leave_wq); + } + } + } +} +void rtllib_ips_leave(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); +} + +bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) + return false; + + RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__func__,rtPsMode); + if (!priv->ps_force) { + priv->rtllib->ps = rtPsMode; + } + if (priv->rtllib->sta_sleep != LPS_IS_WAKE && rtPsMode == RTLLIB_PS_DISABLED) { + unsigned long flags; + + rtl8192_hw_wakeup(dev); + priv->rtllib->sta_sleep = LPS_IS_WAKE; + + spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); + RT_TRACE(COMP_DBG, "LPS leave: notify AP we are awaked" + " ++++++++++ SendNullFunctionData\n"); + rtllib_sta_ps_send_null_frame(priv->rtllib, 0); + spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); + } + + return true; +} + + +void LeisurePSEnter(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + RT_TRACE(COMP_PS, "LeisurePSEnter()...\n"); + RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", + pPSC->bLeisurePs, priv->rtllib->ps,pPSC->LpsIdleCount,RT_CHECK_FOR_HANG_PERIOD); + + if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) + || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || (priv->rtllib->iw_mode == IW_MODE_MASTER)) + return; + + if (pPSC->bLeisurePs) { + if (pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) { + + if (priv->rtllib->ps == RTLLIB_PS_DISABLED) { + + RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter 802.11 power save mode...\n"); + + if (!pPSC->bFwCtrlLPS) { + if (priv->rtllib->SetFwCmdHandler) + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_ENTER); + } + MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST); + } + } else + pPSC->LpsIdleCount++; + } +} + + +void LeisurePSLeave(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + + RT_TRACE(COMP_PS, "LeisurePSLeave()...\n"); + RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d\n", + pPSC->bLeisurePs, priv->rtllib->ps); + + if (pPSC->bLeisurePs) + { + if (priv->rtllib->ps != RTLLIB_PS_DISABLED) + { +#ifdef CONFIG_ASPM_OR_D3 + if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM && RT_IN_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM)) + { + RT_DISABLE_ASPM(dev); + RT_CLEAR_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); + } +#endif + RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n"); + MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_DISABLED); + + if (!pPSC->bFwCtrlLPS) + { + if (priv->rtllib->SetFwCmdHandler) + { + priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_LEAVE); + } + } + } + } +} + +#ifdef CONFIG_ASPM_OR_D3 + +void +PlatformDisableHostL0s(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 PciCfgAddrPort=0; + u8 Num4Bytes; + u8 uPciBridgeASPMSetting = 0; + + + if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || + (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) + { + printk("PlatformDisableHostL0s(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); + return; + } + + PciCfgAddrPort= (priv->NdisAdapter.PciBridgeBusNum << 16)|(priv->NdisAdapter.PciBridgeDevNum<< 11)|(priv->NdisAdapter.PciBridgeFuncNum << 8)|(1 << 31); + Num4Bytes = (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10)/4; + + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); + + NdisRawReadPortUchar(PCI_CONF_DATA, &uPciBridgeASPMSetting); + + if (uPciBridgeASPMSetting & BIT0) + uPciBridgeASPMSetting &= ~(BIT0); + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); + NdisRawWritePortUchar(PCI_CONF_DATA, uPciBridgeASPMSetting); + + udelay(50); + + printk("PlatformDisableHostL0s():PciBridge BusNumber[%x], DevNumbe[%x], FuncNumber[%x], Write reg[%x] = %x\n", + priv->NdisAdapter.PciBridgeBusNum, priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum, + (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10), (priv->NdisAdapter.PciBridgeLinkCtrlReg | (priv->RegDevicePciASPMSetting&~BIT0))); +} + +bool +PlatformEnable92CEBackDoor(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + bool bResult = true; + u8 value; + + if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || + (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) + { + RT_TRACE(COMP_INIT, "PlatformEnableASPM(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); + return false; + } + + pci_read_config_byte(priv->pdev, 0x70f, &value); + + if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_INTEL) + { + value |= BIT7; + } + else + { + value = 0x23; + } + + pci_write_config_byte(priv->pdev, 0x70f, value); + + + pci_read_config_byte(priv->pdev, 0x719, &value); + value |= (BIT3|BIT4); + pci_write_config_byte(priv->pdev, 0x719, value); + + + return bResult; +} + +bool PlatformSwitchDevicePciASPM(struct net_device *dev, u8 value) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + bool bResult = false; + + pci_write_config_byte(priv->pdev, 0x80, value); + + return bResult; +} + +bool PlatformSwitchClkReq(struct net_device *dev, u8 value) +{ + bool bResult = false; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u8 Buffer; + + Buffer= value; + +#ifdef MERGE_TO_DO + if (Adapter->bDriverIsGoingToPnpSetPowerSleep && pDevice->RegSupportLowPowerState + && value == 0x0) + return false; +#endif + + pci_write_config_byte(priv->pdev,0x81,value); + bResult = true; + +#ifdef TODO + if (Buffer) { + priv->ClkReqState = true; + } else { + priv->ClkReqState = false; + } +#endif + +#ifdef RTL8192SE + udelay(100); +#endif + + return bResult; +} + +void +PlatformDisableASPM(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); +#if 1 + u32 PciCfgAddrPort=0; + u8 Num4Bytes; +#endif + u8 LinkCtrlReg; + u16 PciBridgeLinkCtrlReg, ASPMLevel=0; + + if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_UNKNOWN) + { + RT_TRACE(COMP_POWER, "%s(): Disable ASPM. Recognize the Bus of PCI(Bridge) as UNKNOWN.\n",__func__); + } + + + LinkCtrlReg = priv->NdisAdapter.LinkCtrlReg; + PciBridgeLinkCtrlReg = priv->NdisAdapter.PciBridgeLinkCtrlReg; + + ASPMLevel |= BIT0|BIT1; + LinkCtrlReg &=~ASPMLevel; + PciBridgeLinkCtrlReg &=~(BIT0|BIT1); + + if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || + (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) + { + } else { + PciCfgAddrPort= (priv->NdisAdapter.PciBridgeBusNum << 16)|(priv->NdisAdapter.PciBridgeDevNum<< 11)|(priv->NdisAdapter.PciBridgeFuncNum << 8)|(1 << 31); + Num4Bytes = (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10)/4; + + NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); + + NdisRawWritePortUchar(PCI_CONF_DATA, PciBridgeLinkCtrlReg); + RT_TRACE(COMP_POWER, "PlatformDisableASPM():PciBridge BusNumber[%x], DevNumbe[%x], FuncNumber[%x], Write reg[%x] = %x\n", + priv->NdisAdapter.PciBridgeBusNum, priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum, + (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10), PciBridgeLinkCtrlReg); + + udelay(50); + } +} + +void PlatformEnableASPM(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + u16 ASPMLevel = 0; + u32 PciCfgAddrPort=0; + u8 Num4Bytes; + u8 uPciBridgeASPMSetting = 0; + u8 uDeviceASPMSetting = 0; + + + if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || + (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) + { + RT_TRACE(COMP_INIT, "PlatformEnableASPM(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); + return; + } + +#ifdef RTL8192SE + if (priv->NdisAdapter.PciBridgeVendor != PCI_BRIDGE_VENDOR_INTEL ) + { + RT_TRACE(COMP_POWER, "%s(): Dont modify ASPM for non intel chipset. For Bridge Vendor %d.\n" + ,__func__,priv->NdisAdapter.PciBridgeVendor); + return; + } +#endif + + ASPMLevel |= priv->RegDevicePciASPMSetting; + uDeviceASPMSetting = priv->NdisAdapter.LinkCtrlReg; + + uDeviceASPMSetting |= ASPMLevel; + + PlatformSwitchDevicePciASPM(dev, uDeviceASPMSetting); + + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_CLK_REQ) { + PlatformSwitchClkReq(dev,(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_CLK_REQ); + } + udelay(100); + + udelay(100); +} + +u32 PlatformResetPciSpace(struct net_device *dev,u8 Value) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + + pci_write_config_byte(priv->pdev,0x04,Value); + + return 1; + +} +bool PlatformSetPMCSR(struct net_device *dev,u8 value,bool bTempSetting) +{ + bool bResult = false; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u8 Buffer; + bool bActuallySet=false, bSetFunc=false; + unsigned long flag; + + Buffer= value; + spin_lock_irqsave(&priv->D3_lock,flag); +#ifdef TODO + if (bTempSetting) + { + if (Buffer==0x00) + { + priv->LeaveD3Cnt++; + + { + bActuallySet =true; + } + } + else + { + priv->LeaveD3Cnt--; + + if (priv->LeaveD3Cnt == 0) + { + bActuallySet=true; + } + } + } + else + { + priv->LeaveD3Cnt=0; + bActuallySet=true; + bSetFunc=true; + } +#endif + if (bActuallySet) { + if (Buffer) { + PlatformSwitchClkReq(dev, 0x01); + } else { + PlatformSwitchClkReq(dev, 0x00); + } + + pci_write_config_byte(priv->pdev,0x44,Buffer); + RT_TRACE(COMP_POWER, "PlatformSetPMCSR(): D3(value: %d)\n", Buffer); + + bResult = true; + if (!Buffer) { + PlatformResetPciSpace(dev, 0x06); + PlatformResetPciSpace(dev, 0x07); + } + + if (bSetFunc) { + if (Buffer) { +#ifdef TO_DO_LIST + RT_DISABLE_FUNC(Adapter, DF_IO_D3_BIT); +#endif + } else { +#ifdef TO_DO_LIST + RT_ENABLE_FUNC(Adapter, DF_IO_D3_BIT); +#endif + } + } + + } + spin_unlock_irqrestore(&priv->D3_lock,flag); + return bResult; +} +#endif diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h new file mode 100644 index 00000000000..71f20424278 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -0,0 +1,64 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * Based on the r8180 driver, which is: + * Copyright 2004-2005 Andrea Merello , et al. + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + ******************************************************************************/ +#ifndef _RTL_PS_H +#define _RTL_PS_H + +#include +#include "rtllib.h" +struct net_device; + +#define RT_CHECK_FOR_HANG_PERIOD 2 +#define INIT_DEFAULT_CHAN 1 + +#if defined CONFIG_ASPM_OR_D3 +#define RT_DISABLE_ASPM(dev) PlatformDisableASPM(dev) +#define RT_ENABLE_ASPM(dev) PlatformEnableASPM(dev) +#define RT_ENTER_D3(dev, _bTempSetting) PlatformSetPMCSR(dev, 0x03, _bTempSetting) +#define RT_LEAVE_D3(dev, _bTempSetting) PlatformSetPMCSR(dev, 0, _bTempSetting) + +#define RT_DISABLE_HOST_L0S(_PADAPTER) PlatformDisableHostL0s(dev) + +void PlatformDisableHostL0s(struct net_device *dev); +bool PlatformEnable92CEBackDoor(struct net_device *dev); +void PlatformDisableASPM(struct net_device *dev); +void PlatformEnableASPM(struct net_device *dev); +u32 PlatformResetPciSpace(struct net_device *dev,u8 Value); +#endif + +#if defined(RTL8192E) || defined(RTL8192SE) || defined RTL8192CE +void rtl8192_hw_wakeup(struct net_device *dev); +void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); +void rtllib_ips_leave_wq(struct net_device *dev); +void rtllib_ips_leave(struct net_device *dev); +void IPSLeave_wq (void *data); +#endif + +void IPSEnter(struct net_device *dev); +void IPSLeave(struct net_device *dev); + +void LeisurePSEnter(struct net_device *dev); +void LeisurePSLeave(struct net_device *dev); + +#endif diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c new file mode 100644 index 00000000000..79ac60decbe --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -0,0 +1,1509 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#include +#include "rtl_core.h" +#ifdef ENABLE_DOT11D +#include "dot11d.h" +#endif + +#ifdef CONFIG_MP +#include "r8192S_mp.h" +#endif + +#define RATE_COUNT 12 +u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, + 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; + + +#ifndef ENETDOWN +#define ENETDOWN 1 +#endif +extern int hwwep; + +static int r8192_wx_get_freq(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + return rtllib_wx_get_freq(priv->rtllib,a,wrqu,b); +} + + +static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct r8192_priv *priv=rtllib_priv(dev); + + return rtllib_wx_get_mode(priv->rtllib,a,wrqu,b); +} + +static int r8192_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + return rtllib_wx_get_rate(priv->rtllib,info,wrqu,extra); +} + + + +static int r8192_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + ret = rtllib_wx_set_rate(priv->rtllib,info,wrqu,extra); + + up(&priv->wx_sem); + + return ret; +} + + +static int r8192_wx_set_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + ret = rtllib_wx_set_rts(priv->rtllib,info,wrqu,extra); + + up(&priv->wx_sem); + + return ret; +} + +static int r8192_wx_get_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + return rtllib_wx_get_rts(priv->rtllib,info,wrqu,extra); +} + +static int r8192_wx_set_power(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true){ + RT_TRACE(COMP_ERR,"%s():Hw is Radio Off, we can't set Power,return\n",__func__); + return 0; + } + down(&priv->wx_sem); + + ret = rtllib_wx_set_power(priv->rtllib,info,wrqu,extra); + + up(&priv->wx_sem); + + return ret; +} + +static int r8192_wx_get_power(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + return rtllib_wx_get_power(priv->rtllib,info,wrqu,extra); +} + +static int r8192_wx_set_rawtx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int ret; + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + ret = rtllib_wx_set_rawtx(priv->rtllib, info, wrqu, extra); + + up(&priv->wx_sem); + + return ret; + +} + +static int r8192_wx_force_reset(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + down(&priv->wx_sem); + + RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", __func__, *extra); + priv->force_reset = *extra; + up(&priv->wx_sem); + return 0; + +} + +static int r8192_wx_force_mic_error(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + down(&priv->wx_sem); + + RT_TRACE(COMP_DBG, "%s(): force mic error ! \n", __func__); + ieee->force_mic_error = true; + up(&priv->wx_sem); + return 0; + +} + +#define MAX_ADHOC_PEER_NUM 64 +typedef struct +{ + unsigned char MacAddr[ETH_ALEN]; + unsigned char WirelessMode; + unsigned char bCurTxBW40MHz; +} adhoc_peer_entry_t, *p_adhoc_peer_entry_t; +typedef struct +{ + adhoc_peer_entry_t Entry[MAX_ADHOC_PEER_NUM]; + unsigned char num; +} adhoc_peers_info_t, *p_adhoc_peers_info_t; +int r8192_wx_get_adhoc_peers(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ +#ifndef RTL8192SE + return 0; +#else + struct r8192_priv *priv = rtllib_priv(dev); + struct sta_info * psta = NULL; + adhoc_peers_info_t adhoc_peers_info; + p_adhoc_peers_info_t padhoc_peers_info = &adhoc_peers_info; + p_adhoc_peer_entry_t padhoc_peer_entry = NULL; + int k=0; + + + memset(extra, 0, 2047); + padhoc_peers_info->num = 0; + + down(&priv->wx_sem); + + for (k=0; krtllib->peer_assoc_list[k]; + if (NULL != psta) + { + padhoc_peer_entry = &padhoc_peers_info->Entry[padhoc_peers_info->num]; + memset(padhoc_peer_entry,0, sizeof(adhoc_peer_entry_t)); + memcpy(padhoc_peer_entry->MacAddr, psta->macaddr, ETH_ALEN); + padhoc_peer_entry->WirelessMode = psta->wireless_mode; + padhoc_peer_entry->bCurTxBW40MHz = psta->htinfo.bCurTxBW40MHz; + padhoc_peers_info->num ++; + printk("[%d] MacAddr:"MAC_FMT" \tWirelessMode:%d \tBW40MHz:%d \n", \ + k, MAC_ARG(padhoc_peer_entry->MacAddr), padhoc_peer_entry->WirelessMode, padhoc_peer_entry->bCurTxBW40MHz); + sprintf(extra, "[%d] MacAddr:"MAC_FMT" \tWirelessMode:%d \tBW40MHz:%d \n", \ + k, MAC_ARG(padhoc_peer_entry->MacAddr), padhoc_peer_entry->WirelessMode, padhoc_peer_entry->bCurTxBW40MHz); + } + } + + up(&priv->wx_sem); + + wrqu->data.length = strlen(extra); + wrqu->data.flags = 0; + return 0; + +#endif +} + + +static int r8191se_wx_get_firm_version(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *wrqu, char *extra) +{ + return 0; +} + +static int r8192_wx_adapter_power_status(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rtllib_device* ieee = priv->rtllib; + + down(&priv->wx_sem); + + RT_TRACE(COMP_POWER, "%s(): %s\n",__func__, (*extra == 6)?"DC power":"AC power"); + if (*extra || priv->force_lps) { + priv->ps_force = false; + pPSC->bLeisurePs = true; + } else { + if (priv->rtllib->state == RTLLIB_LINKED) + LeisurePSLeave(dev); + + priv->ps_force = true; + pPSC->bLeisurePs = false; + ieee->ps = *extra; + } + + up(&priv->wx_sem); + + return 0; +} + +static int r8192se_wx_set_radio(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + down(&priv->wx_sem); + + printk("%s(): set radio ! extra is %d\n",__func__, *extra); + if ((*extra != 0) && (*extra != 1)) + { + RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",__func__); + return -1; + } + priv->sw_radio_on = *extra; + up(&priv->wx_sem); + return 0; + +} + +static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + + down(&priv->wx_sem); + + printk("%s(): set lps awake interval ! extra is %d\n",__func__, *extra); + + pPSC->RegMaxLPSAwakeIntvl = *extra; + up(&priv->wx_sem); + return 0; + +} + +static int r8192se_wx_set_force_lps(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + down(&priv->wx_sem); + + printk("%s(): force LPS ! extra is %d (1 is open 0 is close)\n",__func__, *extra); + priv->force_lps = *extra; + up(&priv->wx_sem); + return 0; + +} + +static int r8192_wx_set_debugflag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + u8 c = *extra; + + if (priv->bHwRadioOff == true) + return 0; + + printk("=====>%s(), *extra:%x, debugflag:%x\n", __func__, *extra, rt_global_debug_component); + if (c > 0) { + rt_global_debug_component |= (1<bHwRadioOff == true) + return 0; + rtState = priv->rtllib->eRFPowerState; + down(&priv->wx_sem); + if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR + || ieee->bNetPromiscuousMode ) + { + if (priv->rtllib->PowerSaveControl.bInactivePs){ + if (rtState == eRfOff){ + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) + { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + up(&priv->wx_sem); + return -1; + } else { + printk("=========>%s(): IPSLeave\n",__func__); + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); + } + } + } + } + ret = rtllib_wx_set_mode(priv->rtllib,a,wrqu,b); + + up(&priv->wx_sem); + return ret; +} + +struct iw_range_with_scan_capa +{ + /* Informative stuff (to choose between different interface) */ + __u32 throughput; /* To give an idea... */ + /* In theory this value should be the maximum benchmarked + * TCP/IP throughput, because with most of these devices the + * bit rate is meaningless (overhead an co) to estimate how + * fast the connection will go and pick the fastest one. + * I suggest people to play with Netperf or any benchmark... + */ + + /* NWID (or domain id) */ + __u32 min_nwid; /* Minimal NWID we are able to set */ + __u32 max_nwid; /* Maximal NWID we are able to set */ + + /* Old Frequency (backward compat - moved lower ) */ + __u16 old_num_channels; + __u8 old_num_frequency; + + /* Scan capabilities */ + __u8 scan_capa; +}; + +static int rtl8192_wx_get_range(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct iw_range *range = (struct iw_range *)extra; + struct r8192_priv *priv = rtllib_priv(dev); + u16 val; + int i; + + wrqu->data.length = sizeof(*range); + memset(range, 0, sizeof(*range)); + + /* ~130 Mb/s real (802.11n) */ + range->throughput = 130 * 1000 * 1000; + + if (priv->rf_set_sens != NULL) + range->sensitivity = priv->max_sens; /* signal level threshold range */ + + range->max_qual.qual = 100; + range->max_qual.level = 0; + range->max_qual.noise = 0; + range->max_qual.updated = 7; /* Updated all three */ + + range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ + range->avg_qual.level = 0; + range->avg_qual.noise = 0; + range->avg_qual.updated = 7; /* Updated all three */ + + range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES); + + for (i = 0; i < range->num_bitrates; i++) { + range->bitrate[i] = rtl8192_rates[i]; + } + + range->max_rts = DEFAULT_RTS_THRESHOLD; + range->min_frag = MIN_FRAG_THRESHOLD; + range->max_frag = MAX_FRAG_THRESHOLD; + + range->min_pmp = 0; + range->max_pmp = 5000000; + range->min_pmt = 0; + range->max_pmt = 65535*1000; + range->pmp_flags = IW_POWER_PERIOD; + range->pmt_flags = IW_POWER_TIMEOUT; + range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; + range->we_version_compiled = WIRELESS_EXT; + range->we_version_source = 18; + + for (i = 0, val = 0; i < 14; i++) { + if ((priv->rtllib->active_channel_map)[i+1]) { + range->freq[val].i = i + 1; + range->freq[val].m = rtllib_wlan_frequencies[i] * 100000; + range->freq[val].e = 1; + val++; + } else { + } + + if (val == IW_MAX_FREQUENCIES) + break; + } + range->num_frequency = val; + range->num_channels = val; +#if WIRELESS_EXT > 17 + range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2| + IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; +#endif + range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; + + /* Event capability (kernel + driver) */ + + return 0; +} + +static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + RT_RF_POWER_STATE rtState; + int ret; + +#ifdef CONFIG_MP + printk("######################%s(): In MP Test Can not Scan\n",__func__); + return 0; +#endif + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + if ((ieee->state >= RTLLIB_ASSOCIATING) && (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)){ + return 0; + } + if ((priv->rtllib->state == RTLLIB_LINKED) && (priv->rtllib->CntAfterLink<2)){ + return 0; + } + } + + if (priv->bHwRadioOff == true){ + printk("================>%s(): hwradio off\n",__func__); + return 0; + } + rtState = priv->rtllib->eRFPowerState; + if (!priv->up) return -ENETDOWN; + if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) + return -EAGAIN; + +#if WIRELESS_EXT > 17 + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) + { + struct iw_scan_req* req = (struct iw_scan_req*)b; + if (req->essid_len) + { + ieee->current_network.ssid_len = req->essid_len; + memcpy(ieee->current_network.ssid, req->essid, req->essid_len); + } + } +#endif + + down(&priv->wx_sem); + + priv->rtllib->FirstIe_InScan = true; + + if (priv->rtllib->state != RTLLIB_LINKED){ + if (priv->rtllib->PowerSaveControl.bInactivePs){ + if (rtState == eRfOff){ + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS){ + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + up(&priv->wx_sem); + return -1; + }else{ + RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",__func__); + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); + } + } + } + rtllib_stop_scan(priv->rtllib); + if (priv->rtllib->LedControlHandler) + priv->rtllib->LedControlHandler(dev, LED_CTL_SITE_SURVEY); + + if (priv->rtllib->eRFPowerState != eRfOff){ + priv->rtllib->actscanning = true; + + if (ieee->ScanOperationBackupHandler) + ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + + rtllib_start_scan_syncro(priv->rtllib, 0); + + if (ieee->ScanOperationBackupHandler) + ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); + } + ret = 0; + } else { + priv->rtllib->actscanning = true; + ret = rtllib_wx_set_scan(priv->rtllib,a,wrqu,b); + } + + up(&priv->wx_sem); + return ret; +} + + +static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if (!priv->up) return -ENETDOWN; + + if (priv->bHwRadioOff == true) + return 0; + + + down(&priv->wx_sem); + + ret = rtllib_wx_get_scan(priv->rtllib,a,wrqu,b); + + up(&priv->wx_sem); + + return ret; +} + +static int r8192_wx_set_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int ret; + + if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + ; + } +#ifdef CONFIG_MP + printk("######################%s(): In MP Test Can not Set Essid\n",__func__); + return 0; +#endif + if (priv->bHwRadioOff == true){ + printk("=========>%s():hw radio off,or Rf state is eRfOff, return\n",__func__); + return 0; + } + down(&priv->wx_sem); + ret = rtllib_wx_set_essid(priv->rtllib,a,wrqu,b); + + up(&priv->wx_sem); + + return ret; +} + +static int r8192_wx_get_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + down(&priv->wx_sem); + + ret = rtllib_wx_get_essid(priv->rtllib, a, wrqu, b); + + up(&priv->wx_sem); + + return ret; +} + +static int r8192_wx_set_nick(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (wrqu->data.length > IW_ESSID_MAX_SIZE) + return -E2BIG; + down(&priv->wx_sem); + wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick)); + memset(priv->nick, 0, sizeof(priv->nick)); + memcpy(priv->nick, extra, wrqu->data.length); + up(&priv->wx_sem); + return 0; + +} + +static int r8192_wx_get_nick(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + down(&priv->wx_sem); + wrqu->data.length = strlen(priv->nick); + memcpy(extra, priv->nick, wrqu->data.length); + wrqu->data.flags = 1; /* active */ + up(&priv->wx_sem); + return 0; +} + +static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + ret = rtllib_wx_set_freq(priv->rtllib, a, wrqu, b); + + up(&priv->wx_sem); + return ret; +} + +static int r8192_wx_get_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + return rtllib_wx_get_name(priv->rtllib, info, wrqu, extra); +} + + +static int r8192_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + if (wrqu->frag.disabled) + priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD; + else { + if (wrqu->frag.value < MIN_FRAG_THRESHOLD || + wrqu->frag.value > MAX_FRAG_THRESHOLD) + return -EINVAL; + + priv->rtllib->fts = wrqu->frag.value & ~0x1; + } + + return 0; +} + + +static int r8192_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + wrqu->frag.value = priv->rtllib->fts; + wrqu->frag.fixed = 0; /* no auto select */ + wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD); + + return 0; +} + + +static int r8192_wx_set_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) +{ + + int ret; + struct r8192_priv *priv = rtllib_priv(dev); + + if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + ; + } + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + ret = rtllib_wx_set_wap(priv->rtllib,info,awrq,extra); + + up(&priv->wx_sem); + + return ret; + +} + + +static int r8192_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + return rtllib_wx_get_wap(priv->rtllib,info,wrqu,extra); +} + + +static int r8192_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + return rtllib_wx_get_encode(priv->rtllib, info, wrqu, key); +} + +static int r8192_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int ret; + + struct rtllib_device *ieee = priv->rtllib; + u32 hwkey[4]={0,0,0,0}; + u8 mask=0xff; + u32 key_idx=0; + u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x01}, + {0x00,0x00,0x00,0x00,0x00,0x02}, + {0x00,0x00,0x00,0x00,0x00,0x03} }; + int i; + + if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + ; + } +#ifdef CONFIG_MP + printk("######################%s(): In MP Test Can not Set Enc\n",__func__); + return 0; +#endif + if (priv->bHwRadioOff == true) + return 0; + + if (!priv->up) return -ENETDOWN; + + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); + down(&priv->wx_sem); + + RT_TRACE(COMP_SEC, "Setting SW wep key"); + ret = rtllib_wx_set_encode(priv->rtllib,info,wrqu,key); + up(&priv->wx_sem); + + + if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { + ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; + CamResetAllEntry(dev); + memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + goto end_hw_sec; + } + if (wrqu->encoding.length!=0){ + + for (i=0 ; i<4 ; i++){ + hwkey[i] |= key[4*i+0]&mask; + if (i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; + if (i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; + hwkey[i] |= (key[4*i+1]&mask)<<8; + hwkey[i] |= (key[4*i+2]&mask)<<16; + hwkey[i] |= (key[4*i+3]&mask)<<24; + } + + #define CONF_WEP40 0x4 + #define CONF_WEP104 0x14 + + switch (wrqu->encoding.flags & IW_ENCODE_INDEX){ + case 0: key_idx = ieee->tx_keyidx; break; + case 1: key_idx = 0; break; + case 2: key_idx = 1; break; + case 3: key_idx = 2; break; + case 4: key_idx = 3; break; + default: break; + } + if (wrqu->encoding.length==0x5){ + ieee->pairwise_key_type = KEY_TYPE_WEP40; + EnableHWSecurityConfig8192(dev); + } + + else if (wrqu->encoding.length==0xd){ + ieee->pairwise_key_type = KEY_TYPE_WEP104; + EnableHWSecurityConfig8192(dev); + setKey( dev, + key_idx, + key_idx, + KEY_TYPE_WEP104, + zero_addr[key_idx], + 0, + hwkey); + set_swcam( dev, + key_idx, + key_idx, + KEY_TYPE_WEP104, + zero_addr[key_idx], + 0, + hwkey, + 0); + } else { + printk("wrong type in WEP, not WEP40 and WEP104\n"); + } + } + +end_hw_sec: + priv->rtllib->wx_set_enc = 0; + return ret; +} + + +static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union + iwreq_data *wrqu, char *p){ + + struct r8192_priv *priv = rtllib_priv(dev); + int *parms=(int*)p; + int mode=parms[0]; + + if (priv->bHwRadioOff == true) + return 0; + + priv->rtllib->active_scan = mode; + + return 1; +} + + + +#define R8192_MAX_RETRY 255 +static int r8192_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + int err = 0; + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || + wrqu->retry.disabled){ + err = -EINVAL; + goto exit; + } + if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ + err = -EINVAL; + goto exit; + } + + if (wrqu->retry.value > R8192_MAX_RETRY){ + err= -EINVAL; + goto exit; + } + if (wrqu->retry.flags & IW_RETRY_MAX) { + priv->retry_rts = wrqu->retry.value; + DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); + + }else { + priv->retry_data = wrqu->retry.value; + DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); + } + + + rtl8192_commit(dev); + /* + if (priv->up){ + rtl8180_halt_adapter(dev); + rtl8180_rx_enable(dev); + rtl8180_tx_enable(dev); + + } + */ +exit: + up(&priv->wx_sem); + + return err; +} + +static int r8192_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + + + wrqu->retry.disabled = 0; /* can't be disabled */ + + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) + return -EINVAL; + + if (wrqu->retry.flags & IW_RETRY_MAX) { + wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; + wrqu->retry.value = priv->retry_rts; + } else { + wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN; + wrqu->retry.value = priv->retry_data; + } + + + return 0; +} + +static int r8192_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + if (priv->rf_set_sens == NULL) + return -1; /* we have not this support for this radio */ + wrqu->sens.value = priv->sens; + return 0; +} + + +static int r8192_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + + struct r8192_priv *priv = rtllib_priv(dev); + + short err = 0; + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + if (priv->rf_set_sens == NULL) { + err= -1; /* we have not this support for this radio */ + goto exit; + } + if (priv->rf_set_sens(dev, wrqu->sens.value) == 0) + priv->sens = wrqu->sens.value; + else + err= -EINVAL; + +exit: + up(&priv->wx_sem); + + return err; +} + +#if (WIRELESS_EXT >= 18) + +static int r8192_wx_set_enc_ext(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret=0; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); + + ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra); + + { + u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 zero[6] = {0}; + u32 key[4] = {0}; + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; + struct iw_point *encoding = &wrqu->encoding; + u8 idx = 0, alg = 0, group = 0; + if ((encoding->flags & IW_ENCODE_DISABLED) || + ext->alg == IW_ENCODE_ALG_NONE) + { + ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; + CamResetAllEntry(dev); + memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + goto end_hw_sec; + } + alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; + idx = encoding->flags & IW_ENCODE_INDEX; + if (idx) + idx --; + group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; + + if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) + { + if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) + alg = KEY_TYPE_WEP104; + ieee->pairwise_key_type = alg; + EnableHWSecurityConfig8192(dev); + } + memcpy((u8*)key, ext->key, 16); + + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) + { + if (ext->key_len == 13) + ieee->pairwise_key_type = alg = KEY_TYPE_WEP104; + setKey( dev, + idx, + idx, + alg, + zero, + 0, + key); + set_swcam( dev, + idx, + idx, + alg, + zero, + 0, + key, + 0); + } + else if (group) + { + ieee->group_key_type = alg; + setKey( dev, + idx, + idx, + alg, + broadcast_addr, + 0, + key); + set_swcam( dev, + idx, + idx, + alg, + broadcast_addr, + 0, + key, + 0); + } + else + { + #ifdef RTL8192E + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ + write_nic_byte(dev, 0x173, 1); + } + #endif + setKey( dev, + 4, + idx, + alg, + (u8*)ieee->ap_mac_addr, + 0, + key); + set_swcam( dev, + 4, + idx, + alg, + (u8*)ieee->ap_mac_addr, + 0, + key, + 0); + } + + + } + +end_hw_sec: + priv->rtllib->wx_set_enc = 0; + up(&priv->wx_sem); + return ret; + +} +static int r8192_wx_set_auth(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *data, char *extra) +{ + int ret=0; + + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + ret = rtllib_wx_set_auth(priv->rtllib, info, &(data->param), extra); + up(&priv->wx_sem); + return ret; +} + +static int r8192_wx_set_mlme(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + + int ret=0; + + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + ret = rtllib_wx_set_mlme(priv->rtllib, info, wrqu, extra); + up(&priv->wx_sem); + return ret; +} +#endif + +static int r8192_wx_set_gen_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *data, char *extra) +{ + int ret = 0; + + struct r8192_priv *priv = rtllib_priv(dev); + + if (priv->bHwRadioOff == true) + return 0; + + down(&priv->wx_sem); + ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); + up(&priv->wx_sem); + return ret; +} + +static int r8192_wx_get_gen_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *data, char *extra) +{ + int ret = 0; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { + data->data.length = 0; + return 0; + } + + if (data->data.length < ieee->wpa_ie_len) { + return -E2BIG; + } + + data->data.length = ieee->wpa_ie_len; + memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); + return ret; +} + +#define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6 + +static int r8192_wx_set_PromiscuousMode(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + u32 *info_buf = (u32*)(wrqu->data.pointer); + + u32 oid = info_buf[0]; + u32 bPromiscuousOn = info_buf[1]; + u32 bFilterSourceStationFrame = info_buf[2]; + + if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) + { + ieee->IntelPromiscuousModeInfo.bPromiscuousOn = + (bPromiscuousOn)? (true) : (false); + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame = + (bFilterSourceStationFrame)? (true) : (false); + + (bPromiscuousOn) ? (rtllib_EnableIntelPromiscuousMode(dev, false)) : + (rtllib_DisableIntelPromiscuousMode(dev, false)); + + printk("=======>%s(), on = %d, filter src sta = %d\n", __func__, + bPromiscuousOn, bFilterSourceStationFrame); + } else { + return -1; + } + + return 0; +} + + +static int r8192_wx_get_PromiscuousMode(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + + down(&priv->wx_sem); + + snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",\ + ieee->IntelPromiscuousModeInfo.bPromiscuousOn,\ + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); + wrqu->data.length = strlen(extra) + 1; + + up(&priv->wx_sem); + + return 0; +} + + +#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] +static iw_handler r8192_wx_handlers[] = +{ + IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, + IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, + IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, + IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, + IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, + IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick, + IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, + IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, + IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, + IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, +#if (WIRELESS_EXT >= 18) + IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, + IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, + IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, + IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth, + IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext, +#endif +}; + +/* + * the following rule need to be follwing, + * Odd : get (world access), + * even : set (root access) + * */ +static const struct iw_priv_args r8192_private_args[] = { + { + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag" + }, + { + SIOCIWFIRSTPRIV + 0x1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + }, + { + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + } + , + { + SIOCIWFIRSTPRIV + 0x3, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" + } + , + { + SIOCIWFIRSTPRIV + 0x4, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error" + } + , + { + SIOCIWFIRSTPRIV + 0x5, + IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1, + "firm_ver" + } + , + { + SIOCIWFIRSTPRIV + 0x6, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, + "set_power" + } + , + { + SIOCIWFIRSTPRIV + 0x9, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, + "radio" + } + , + { + SIOCIWFIRSTPRIV + 0xa, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, + "lps_interv" + } + , + { + SIOCIWFIRSTPRIV + 0xb, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, + "lps_force" + } + , + { + SIOCIWFIRSTPRIV + 0xc, + 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" + } +#ifdef CONFIG_MP + , + { + SIOCIWFIRSTPRIV + 0xe, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetChan" + } + , + { + SIOCIWFIRSTPRIV + 0xf, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetRate" + } + , + { + SIOCIWFIRSTPRIV + 0x10, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetTxPower" + } + , + { + SIOCIWFIRSTPRIV + 0x11, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetBW" + } + , + { + SIOCIWFIRSTPRIV + 0x12, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "TxStart" + } + , + { + SIOCIWFIRSTPRIV + 0x13, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,0, "SetSingleCarrier" + } + , + { + SIOCIWFIRSTPRIV + 0x14, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "WriteRF" + } + , + { + SIOCIWFIRSTPRIV + 0x15, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "WriteMAC" + } +#endif + , + { + SIOCIWFIRSTPRIV + 0x16, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" + } + , + { + SIOCIWFIRSTPRIV + 0x17, + 0,IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" + } + +}; + +static iw_handler r8192_private_handler[] = { + (iw_handler)r8192_wx_set_debugflag, /*SIOCIWSECONDPRIV*/ + (iw_handler)r8192_wx_set_scan_type, + (iw_handler)r8192_wx_set_rawtx, + (iw_handler)r8192_wx_force_reset, + (iw_handler)r8192_wx_force_mic_error, + (iw_handler)r8191se_wx_get_firm_version, + (iw_handler)r8192_wx_adapter_power_status, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)r8192se_wx_set_radio, + (iw_handler)r8192se_wx_set_lps_awake_interval, + (iw_handler)r8192se_wx_set_force_lps, + (iw_handler)r8192_wx_get_adhoc_peers, + (iw_handler)NULL, +#ifdef CONFIG_MP + (iw_handler)r8192_wx_mp_set_chan, + (iw_handler)r8192_wx_mp_set_txrate, + (iw_handler)r8192_wx_mp_set_txpower, + (iw_handler)r8192_wx_mp_set_bw, + (iw_handler)r8192_wx_mp_set_txstart, + (iw_handler)r8192_wx_mp_set_singlecarrier, + (iw_handler)r8192_wx_mp_write_rf, + (iw_handler)r8192_wx_mp_write_mac, +#else + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, + (iw_handler)NULL, +#endif + (iw_handler)r8192_wx_set_PromiscuousMode, + (iw_handler)r8192_wx_get_PromiscuousMode, +}; + +struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) +{ + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device* ieee = priv->rtllib; + struct iw_statistics* wstats = &priv->wstats; + int tmp_level = 0; + int tmp_qual = 0; + int tmp_noise = 0; + if (ieee->state < RTLLIB_LINKED) + { + wstats->qual.qual = 10; + wstats->qual.level = 0; + wstats->qual.noise = -100; + wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + return wstats; + } + + tmp_level = (&ieee->current_network)->stats.rssi; + tmp_qual = (&ieee->current_network)->stats.signal; + tmp_noise = (&ieee->current_network)->stats.noise; + + wstats->qual.level = tmp_level; + wstats->qual.qual = tmp_qual; + wstats->qual.noise = tmp_noise; + wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + return wstats; +} + +struct iw_handler_def r8192_wx_handlers_def={ + .standard = r8192_wx_handlers, + .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), + .private = r8192_private_handler, + .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), + .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), +#if WIRELESS_EXT >= 17 + .get_wireless_stats = r8192_get_wireless_stats, +#endif + .private_args = (struct iw_priv_args *)r8192_private_args, +}; diff --git a/drivers/staging/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl_wx.h new file mode 100644 index 00000000000..94d42a82211 --- /dev/null +++ b/drivers/staging/rtl8192e/rtl_wx.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae +******************************************************************************/ + +#ifndef R819x_WX_H +#define R819x_WX_H + +struct net_device; +struct iw_handler_def; +struct iw_statistics; + +extern struct iw_handler_def r8192_wx_handlers_def; +struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); +u16 rtl8192_11n_user_show_rates(struct net_device* dev); + +#endif diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h new file mode 100644 index 00000000000..61780a2caa2 --- /dev/null +++ b/drivers/staging/rtl8192e/rtllib.h @@ -0,0 +1,3452 @@ +/* + * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11 + * remains copyright by the original authors + * + * Portions of the merged code are based on Host AP (software wireless + * LAN access point) driver for Intersil Prism2/2.5/3. + * + * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen + * + * Copyright (c) 2002-2003, Jouni Malinen + * + * Adaption to a generic IEEE 802.11 stack by James Ketrenos + * + * Copyright (c) 2004, Intel Corporation + * + * Modified for Realtek's wi-fi cards by Andrea Merello + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. See README and COPYING for + * more details. + */ +#ifndef RTLLIB_H +#define RTLLIB_H +#include /* ETH_ALEN */ +#include /* ARRAY_SIZE */ +#include +#include +#include +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) +#include +#else +#include +#include +#endif +#include +#include + +#include +#include + +#ifdef CONFIG_CFG_80211 +#include +#endif + +#include "rtl819x_HT.h" +#include "rtl819x_BA.h" +#include "rtl819x_TS.h" + +#include +#include /* ARPHRD_ETHER */ + +#ifndef WIRELESS_SPY +#define WIRELESS_SPY +#endif +#include + +#ifndef IEEE80211_RADIOTAP_F_BADFCS +#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */ +#endif + +#ifndef IW_MODE_MONITOR +#define IW_MODE_MONITOR 6 +#endif + +#ifndef IWEVCUSTOM +#define IWEVCUSTOM 0x8c02 +#endif + +#ifndef IW_CUSTOM_MAX +/* Max number of char in custom event - use multiple of them if needed */ +#define IW_CUSTOM_MAX 256 /* In bytes */ +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#define jiffies_to_msecs(t) ((t) * 1000 / HZ) +#ifndef __bitwise +#define __bitwise __attribute__((bitwise)) +#endif +typedef __u16 __le16; + +#if (WIRELESS_EXT < 16) +struct iw_spy_data{ + /* --- Standard spy support --- */ + int spy_number; + u_char spy_address[IW_MAX_SPY][ETH_ALEN]; + struct iw_quality spy_stat[IW_MAX_SPY]; + /* --- Enhanced spy support (event) */ + struct iw_quality spy_thr_low; /* Low threshold */ + struct iw_quality spy_thr_high; /* High threshold */ + u_char spy_thr_under[IW_MAX_SPY]; +}; +#endif +#endif + +#ifndef container_of +/** + * container_of - cast a member of a structure out to the containing structure + * + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#endif + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)) +#define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) +#else +#define skb_tail_pointer_rsl(skb) skb->tail +#endif + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) + #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) +#else + #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL_NOVERS(x) +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data) +{ + task->routine = func; + task->data = data; + INIT_LIST_HEAD(&task->list); + task->sync = 0; +} +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +static inline void setup_timer(struct timer_list * timer, void(*function)(unsigned long), unsigned long data) +{ + timer->function = function; + timer->data = data; +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + typedef struct delayed_work delayed_work_struct_rsl; + #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) + #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) + typedef struct tq_struct delayed_work_struct_rsl; + #define queue_delayed_work_rsl(x,y,z) schedule_task(y) + #define INIT_DELAYED_WORK_RSL(x,y,z) tq_init(x,y,z) +#else + typedef struct work_struct delayed_work_struct_rsl; + #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) + #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_WORK(x,y,z) +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + typedef struct work_struct work_struct_rsl; + #define queue_work_rsl(x,y) queue_work(x,y) + #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) + typedef struct tq_struct work_struct_rsl; + #define queue_work_rsl(x,y) schedule_task(y) + #define INIT_WORK_RSL(x,y,z) tq_init(x,y,z) +#else + typedef struct work_struct work_struct_rsl; + #define queue_work_rsl(x,y) queue_work(x,y) + #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y,z) +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + #define container_of_work_rsl(x,y,z) container_of(x,y,z) + #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z) +#else + #define container_of_work_rsl(x,y,z) (x) + #define container_of_dwork_rsl(x,y,z) (x) +#endif + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +static inline char * +iwe_stream_add_event_rsl(struct iw_request_info *info, + char * stream, /* Stream of events */ + char * ends, /* End of stream */ + struct iw_event *iwe, /* Payload */ + int event_len) /* Real size of payload */ +{ + /* Check if it's possible */ + if ((stream + event_len) < ends) { + iwe->len = event_len; + ndelay(1); + memcpy(stream, (char *) iwe, event_len); + stream += event_len; + } + return stream; +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) + #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len) +#else + #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(start,stop,iwe,len) +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) + #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p) +#else + #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(start,stop,iwe,p) +#endif + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y) + #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y) +#else + #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x) + #define usb_submit_urb_rsl(x,y) usb_submit_urb(x) +#endif + +static inline void *netdev_priv_rsl(struct net_device *dev) +{ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + return netdev_priv(dev); +#else + return dev->priv; +#endif +} + +#define KEY_TYPE_NA 0x0 +#define KEY_TYPE_WEP40 0x1 +#define KEY_TYPE_TKIP 0x2 +#define KEY_TYPE_CCMP 0x4 +#define KEY_TYPE_WEP104 0x5 +/* added for rtl819x tx procedure */ +#define MAX_QUEUE_SIZE 0x10 + +#if defined(RTL8192SU) || defined(RTL8190P) ||defined(RTL8192U) ||defined(RTL8192E) +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define HCCA_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define BEACON_QUEUE 8 +#elif defined(RTL8192SE) +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define BEACON_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define HCCA_QUEUE 8 + +#endif + +#define LOW_QUEUE BE_QUEUE +#define NORMAL_QUEUE MGNT_QUEUE + +#ifndef IW_MODE_MESH +#define IW_MODE_MESH 7 +#endif +#define AMSDU_SUBHEADER_LEN 14 +#define SWRF_TIMEOUT 50 + +#define IE_CISCO_FLAG_POSITION 0x08 +#define SUPPORT_CKIP_MIC 0x08 +#define SUPPORT_CKIP_PK 0x10 +#define RT_RF_OFF_LEVL_ASPM BIT0 +#define RT_RF_OFF_LEVL_CLK_REQ BIT1 +#define RT_RF_OFF_LEVL_PCI_D3 BIT2 +#define RT_RF_OFF_LEVL_HALT_NIC BIT3 +#define RT_RF_OFF_LEVL_FREE_FW BIT4 +#define RT_RF_OFF_LEVL_FW_32K BIT5 +#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 +#define RT_RF_LPS_DISALBE_2R BIT30 +#define RT_RF_LPS_LEVEL_ASPM BIT31 +#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG))) +#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) + +/* defined for skb cb field */ +/* At most 28 byte */ +typedef struct cb_desc { + /* Tx Desc Related flags (8-9) */ + u8 bLastIniPkt:1; + u8 bCmdOrInit:1; + u8 bFirstSeg:1; + u8 bLastSeg:1; + u8 bEncrypt:1; + u8 bTxDisableRateFallBack:1; + u8 bTxUseDriverAssingedRate:1; + u8 bHwSec:1; + + u8 nStuckCount; + + /* Tx Firmware Relaged flags (10-11)*/ + u8 bCTSEnable:1; + u8 bRTSEnable:1; + u8 bUseShortGI:1; + u8 bUseShortPreamble:1; + u8 bTxEnableFwCalcDur:1; + u8 bAMPDUEnable:1; + u8 bRTSSTBC:1; + u8 RTSSC:1; + + u8 bRTSBW:1; + u8 bPacketBW:1; + u8 bRTSUseShortPreamble:1; + u8 bRTSUseShortGI:1; + u8 bMulticast:1; + u8 bBroadcast:1; + u8 drv_agg_enable:1; + u8 reserved2:1; + + /* Tx Desc related element(12-19) */ + u8 rata_index; + u8 queue_index; + u16 txbuf_size; + u8 RATRIndex; + u8 bAMSDU:1; + u8 bFromAggrQ:1; + u8 reserved6:6; + u8 macId; + u8 priority; + + /* Tx firmware related element(20-27) */ + u8 data_rate; + u8 rts_rate; + u8 ampdu_factor; + u8 ampdu_density; + u8 DrvAggrNum; + u8 bdhcp; + u16 pkt_size; + u8 bIsSpecialDataFrame; + + u8 bBTTxPacket; + u8 bIsBTProbRsp; +}cb_desc, *pcb_desc; + +/*--------------------------Define -------------------------------------------*/ +#define MGN_1M 0x02 +#define MGN_2M 0x04 +#define MGN_5_5M 0x0b +#define MGN_11M 0x16 + +#define MGN_6M 0x0c +#define MGN_9M 0x12 +#define MGN_12M 0x18 +#define MGN_18M 0x24 +#define MGN_24M 0x30 +#define MGN_36M 0x48 +#define MGN_48M 0x60 +#define MGN_54M 0x6c + +#define MGN_MCS0 0x80 +#define MGN_MCS1 0x81 +#define MGN_MCS2 0x82 +#define MGN_MCS3 0x83 +#define MGN_MCS4 0x84 +#define MGN_MCS5 0x85 +#define MGN_MCS6 0x86 +#define MGN_MCS7 0x87 +#define MGN_MCS8 0x88 +#define MGN_MCS9 0x89 +#define MGN_MCS10 0x8a +#define MGN_MCS11 0x8b +#define MGN_MCS12 0x8c +#define MGN_MCS13 0x8d +#define MGN_MCS14 0x8e +#define MGN_MCS15 0x8f +#define MGN_MCS0_SG 0x90 +#define MGN_MCS1_SG 0x91 +#define MGN_MCS2_SG 0x92 +#define MGN_MCS3_SG 0x93 +#define MGN_MCS4_SG 0x94 +#define MGN_MCS5_SG 0x95 +#define MGN_MCS6_SG 0x96 +#define MGN_MCS7_SG 0x97 +#define MGN_MCS8_SG 0x98 +#define MGN_MCS9_SG 0x99 +#define MGN_MCS10_SG 0x9a +#define MGN_MCS11_SG 0x9b +#define MGN_MCS12_SG 0x9c +#define MGN_MCS13_SG 0x9d +#define MGN_MCS14_SG 0x9e +#define MGN_MCS15_SG 0x9f + + +enum _ReasonCode{ + unspec_reason = 0x1, + auth_not_valid = 0x2, + deauth_lv_ss = 0x3, + inactivity = 0x4, + ap_overload = 0x5, + class2_err = 0x6, + class3_err = 0x7, + disas_lv_ss = 0x8, + asoc_not_auth = 0x9, + + mic_failure = 0xe, + + invalid_IE = 0x0d, + four_way_tmout = 0x0f, + two_way_tmout = 0x10, + IE_dismatch = 0x11, + invalid_Gcipher = 0x12, + invalid_Pcipher = 0x13, + invalid_AKMP = 0x14, + unsup_RSNIEver = 0x15, + invalid_RSNIE = 0x16, + auth_802_1x_fail= 0x17, + ciper_reject = 0x18, + + QoS_unspec = 0x20, + QAP_bandwidth = 0x21, + poor_condition = 0x22, + no_facility = 0x23, + req_declined = 0x25, + invalid_param = 0x26, + req_not_honored= 0x27, + TS_not_created = 0x2F, + DL_not_allowed = 0x30, + dest_not_exist = 0x31, + dest_not_QSTA = 0x32, +}; + +typedef enum _HAL_DEF_VARIABLE{ + HAL_DEF_TPC_ENABLE, + HAL_DEF_INIT_GAIN, + HAL_DEF_PROT_IMP_MODE, + HAL_DEF_HIGH_POWER_MECHANISM, + HAL_DEF_RATE_ADAPTIVE_MECHANISM, + HAL_DEF_ANTENNA_DIVERSITY_MECHANISM, + HAL_DEF_LED, + HAL_DEF_CW_MAX_MIN, + + HAL_DEF_WOWLAN, + HAL_DEF_ENDPOINTS, + HAL_DEF_MIN_TX_POWER_DBM, + HAL_DEF_MAX_TX_POWER_DBM, + HW_DEF_EFUSE_REPG_SECTION1_FLAG, + HW_DEF_EFUSE_REPG_DATA, + HW_DEF_GPIO, + HAL_DEF_PCI_SUPPORT_ASPM, + HAL_DEF_THERMAL_VALUE, + HAL_DEF_USB_IN_TOKEN_REV, +}HAL_DEF_VARIABLE; + + +typedef enum _HW_VARIABLES{ + HW_VAR_ETHER_ADDR, + HW_VAR_MULTICAST_REG, + HW_VAR_BASIC_RATE, + HW_VAR_BSSID, + HW_VAR_MEDIA_STATUS, + HW_VAR_SECURITY_CONF, + HW_VAR_BEACON_INTERVAL, + HW_VAR_ATIM_WINDOW, + HW_VAR_LISTEN_INTERVAL, + HW_VAR_CS_COUNTER, + HW_VAR_DEFAULTKEY0, + HW_VAR_DEFAULTKEY1, + HW_VAR_DEFAULTKEY2, + HW_VAR_DEFAULTKEY3, + HW_VAR_SIFS, + HW_VAR_DIFS, + HW_VAR_EIFS, + HW_VAR_SLOT_TIME, + HW_VAR_ACK_PREAMBLE, + HW_VAR_CW_CONFIG, + HW_VAR_CW_VALUES, + HW_VAR_RATE_FALLBACK_CONTROL, + HW_VAR_CONTENTION_WINDOW, + HW_VAR_RETRY_COUNT, + HW_VAR_TR_SWITCH, + HW_VAR_COMMAND, + HW_VAR_WPA_CONFIG, + HW_VAR_AMPDU_MIN_SPACE, + HW_VAR_SHORTGI_DENSITY, + HW_VAR_AMPDU_FACTOR, + HW_VAR_MCS_RATE_AVAILABLE, + HW_VAR_AC_PARAM, + HW_VAR_ACM_CTRL, + HW_VAR_DIS_Req_Qsize, + HW_VAR_CCX_CHNL_LOAD, + HW_VAR_CCX_NOISE_HISTOGRAM, + HW_VAR_CCX_CLM_NHM, + HW_VAR_TxOPLimit, + HW_VAR_TURBO_MODE, + HW_VAR_RF_STATE, + HW_VAR_RF_OFF_BY_HW, + HW_VAR_BUS_SPEED, + HW_VAR_SET_DEV_POWER, + + HW_VAR_RCR, + HW_VAR_RATR_0, + HW_VAR_RRSR, + HW_VAR_CPU_RST, + HW_VAR_CECHK_BSSID, + HW_VAR_LBK_MODE, + HW_VAR_AES_11N_FIX, + HW_VAR_USB_RX_AGGR, + HW_VAR_USER_CONTROL_TURBO_MODE, + HW_VAR_RETRY_LIMIT, + HW_VAR_INIT_TX_RATE, + HW_VAR_TX_RATE_REG, + HW_VAR_EFUSE_USAGE, + HW_VAR_EFUSE_BYTES, + HW_VAR_AUTOLOAD_STATUS, + HW_VAR_RF_2R_DISABLE, + HW_VAR_SET_RPWM, + HW_VAR_H2C_FW_PWRMODE, + HW_VAR_H2C_FW_JOINBSSRPT, + HW_VAR_1X1_RECV_COMBINE, + HW_VAR_STOP_SEND_BEACON, + HW_VAR_TSF_TIMER, + HW_VAR_IO_CMD, + + HW_VAR_RF_RECOVERY, + HW_VAR_H2C_FW_UPDATE_GTK, + HW_VAR_WF_MASK, + HW_VAR_WF_CRC, + HW_VAR_WF_IS_MAC_ADDR, + HW_VAR_H2C_FW_OFFLOAD, + HW_VAR_RESET_WFCRC, + + HW_VAR_HANDLE_FW_C2H, + HW_VAR_DL_FW_RSVD_PAGE, + HW_VAR_AID, + HW_VAR_HW_SEQ_ENABLE, + HW_VAR_CORRECT_TSF, + HW_VAR_BCN_VALID, + HW_VAR_FWLPS_RF_ON, + HW_VAR_DUAL_TSF_RST, + HW_VAR_SWITCH_EPHY_WoWLAN, + HW_VAR_INT_MIGRATION, + HW_VAR_INT_AC, + HW_VAR_RF_TIMING, +}HW_VARIABLES; + +typedef enum _RT_OP_MODE{ + RT_OP_MODE_AP, + RT_OP_MODE_INFRASTRUCTURE, + RT_OP_MODE_IBSS, + RT_OP_MODE_NO_LINK, +}RT_OP_MODE, *PRT_OP_MODE; + + +#define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) + +#define MGMT_QUEUE_NUM 5 + +#define IEEE_CMD_SET_WPA_PARAM 1 +#define IEEE_CMD_SET_WPA_IE 2 +#define IEEE_CMD_SET_ENCRYPTION 3 +#define IEEE_CMD_MLME 4 + +#define IEEE_PARAM_WPA_ENABLED 1 +#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 +#define IEEE_PARAM_DROP_UNENCRYPTED 3 +#define IEEE_PARAM_PRIVACY_INVOKED 4 +#define IEEE_PARAM_AUTH_ALGS 5 +#define IEEE_PARAM_IEEE_802_1X 6 +#define IEEE_PARAM_WPAX_SELECT 7 +#define IEEE_PROTO_WPA 1 +#define IEEE_PROTO_RSN 2 +#define IEEE_WPAX_USEGROUP 0 +#define IEEE_WPAX_WEP40 1 +#define IEEE_WPAX_TKIP 2 +#define IEEE_WPAX_WRAP 3 +#define IEEE_WPAX_CCMP 4 +#define IEEE_WPAX_WEP104 5 + +#define IEEE_KEY_MGMT_IEEE8021X 1 +#define IEEE_KEY_MGMT_PSK 2 + +#define IEEE_MLME_STA_DEAUTH 1 +#define IEEE_MLME_STA_DISASSOC 2 + + +#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 +#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 +#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 +#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 +#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 +#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 +#define IEEE_CRYPT_ALG_NAME_LEN 16 + +#define MAX_IE_LEN 0xff +#ifdef ENABLE_NULL_PT_DEBUG +#define RT_ASSERT_RET(_Exp) \ + if (!(_Exp)) \ + { \ + printk("Rtl819x: "); \ + printk( "Assertion failed! %s,%s,line=%d\n", \ + #_Exp,__func__,__LINE__); \ + return; \ + } +#define RT_ASSERT_RET_VALUE(_Exp,Ret) \ + if (!(_Exp)) \ + { \ + printk("Rtl819x: "); \ + printk( "Assertion failed! %s,%s,line=%d\n", \ + #_Exp,__func__,__LINE__); \ + return (Ret); \ + } +#else +#define RT_ASSERT_RET(_Exp) do {} while(0) +#define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) +#endif + +typedef struct ieee_param { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + union { + struct { + u8 name; + u32 value; + } wpa_param; + struct { + u32 len; + u8 reserved[32]; + u8 data[0]; + } wpa_ie; + struct{ + int command; + int reason_code; + } mlme; + struct { + u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; + u8 set_tx; + u32 err; + u8 idx; + u8 seq[8]; /* sequence counter (set: RX, get: TX) */ + u16 key_len; + u8 key[0]; + } crypt; + } u; +}ieee_param; + + +#if WIRELESS_EXT < 17 +#define IW_QUAL_QUAL_INVALID 0x10 +#define IW_QUAL_LEVEL_INVALID 0x20 +#define IW_QUAL_NOISE_INVALID 0x40 +#define IW_QUAL_QUAL_UPDATED 0x1 +#define IW_QUAL_LEVEL_UPDATED 0x2 +#define IW_QUAL_NOISE_UPDATED 0x4 +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)) +#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) +static inline unsigned long msleep_interruptible_rsl(unsigned int msecs) +{ + unsigned long timeout = MSECS(msecs) + 1; + + while (timeout) { + set_current_state(TASK_INTERRUPTIBLE); + timeout = schedule_timeout(timeout); + } + return timeout; +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31)) +static inline void msleep(unsigned int msecs) +{ + unsigned long timeout = MSECS(msecs) + 1; + + while (timeout) { + set_current_state(TASK_UNINTERRUPTIBLE); + timeout = schedule_timeout(timeout); + } +} +#endif +#else +#define MSECS(t) msecs_to_jiffies(t) +#define msleep_interruptible_rsl msleep_interruptible +#endif + +#define RTLLIB_DATA_LEN 2304 +/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section + 6.2.1.1.2. + + The figure in section 7.1.2 suggests a body size of up to 2312 + bytes is allowed, which is a bit confusing, I suspect this + represents the 2304 bytes of real data, plus a possible 8 bytes of + WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ +#define RTLLIB_1ADDR_LEN 10 +#define RTLLIB_2ADDR_LEN 16 +#define RTLLIB_3ADDR_LEN 24 +#define RTLLIB_4ADDR_LEN 30 +#define RTLLIB_FCS_LEN 4 +#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) +#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) +#define RTLLIB_MGMT_HDR_LEN 24 +#define RTLLIB_DATA_HDR3_LEN 24 +#define RTLLIB_DATA_HDR4_LEN 30 + +#define RTLLIB_SKBBUFFER_SIZE 2500 + +#define MIN_FRAG_THRESHOLD 256U +#define MAX_FRAG_THRESHOLD 2346U +#define MAX_HT_DATA_FRAG_THRESHOLD 0x2000 + +#define HT_AMSDU_SIZE_4K 3839 +#define HT_AMSDU_SIZE_8K 7935 + +/* Frame control field constants */ +#define RTLLIB_FCTL_VERS 0x0003 +#define RTLLIB_FCTL_FTYPE 0x000c +#define RTLLIB_FCTL_STYPE 0x00f0 +#define RTLLIB_FCTL_FRAMETYPE 0x00fc +#define RTLLIB_FCTL_TODS 0x0100 +#define RTLLIB_FCTL_FROMDS 0x0200 +#define RTLLIB_FCTL_DSTODS 0x0300 +#define RTLLIB_FCTL_MOREFRAGS 0x0400 +#define RTLLIB_FCTL_RETRY 0x0800 +#define RTLLIB_FCTL_PM 0x1000 +#define RTLLIB_FCTL_MOREDATA 0x2000 +#define RTLLIB_FCTL_WEP 0x4000 +#define RTLLIB_FCTL_ORDER 0x8000 + +#define RTLLIB_FTYPE_MGMT 0x0000 +#define RTLLIB_FTYPE_CTL 0x0004 +#define RTLLIB_FTYPE_DATA 0x0008 + +/* management */ +#define RTLLIB_STYPE_ASSOC_REQ 0x0000 +#define RTLLIB_STYPE_ASSOC_RESP 0x0010 +#define RTLLIB_STYPE_REASSOC_REQ 0x0020 +#define RTLLIB_STYPE_REASSOC_RESP 0x0030 +#define RTLLIB_STYPE_PROBE_REQ 0x0040 +#define RTLLIB_STYPE_PROBE_RESP 0x0050 +#define RTLLIB_STYPE_BEACON 0x0080 +#define RTLLIB_STYPE_ATIM 0x0090 +#define RTLLIB_STYPE_DISASSOC 0x00A0 +#define RTLLIB_STYPE_AUTH 0x00B0 +#define RTLLIB_STYPE_DEAUTH 0x00C0 +#define RTLLIB_STYPE_MANAGE_ACT 0x00D0 + +/* control */ +#define RTLLIB_STYPE_PSPOLL 0x00A0 +#define RTLLIB_STYPE_RTS 0x00B0 +#define RTLLIB_STYPE_CTS 0x00C0 +#define RTLLIB_STYPE_ACK 0x00D0 +#define RTLLIB_STYPE_CFEND 0x00E0 +#define RTLLIB_STYPE_CFENDACK 0x00F0 +#define RTLLIB_STYPE_BLOCKACK 0x0094 + +/* data */ +#define RTLLIB_STYPE_DATA 0x0000 +#define RTLLIB_STYPE_DATA_CFACK 0x0010 +#define RTLLIB_STYPE_DATA_CFPOLL 0x0020 +#define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030 +#define RTLLIB_STYPE_NULLFUNC 0x0040 +#define RTLLIB_STYPE_CFACK 0x0050 +#define RTLLIB_STYPE_CFPOLL 0x0060 +#define RTLLIB_STYPE_CFACKPOLL 0x0070 +#define RTLLIB_STYPE_QOS_DATA 0x0080 +#define RTLLIB_STYPE_QOS_NULL 0x00C0 + +#define RTLLIB_SCTL_FRAG 0x000F +#define RTLLIB_SCTL_SEQ 0xFFF0 + +/* QOS control */ +#define RTLLIB_QCTL_TID 0x000F + +#define FC_QOS_BIT BIT7 +#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) +#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER) +#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define SN_EQUAL(a, b) (a == b) +#define MAX_DEV_ADDR_SIZE 8 + +typedef enum _ACT_CATEGORY{ + ACT_CAT_QOS = 1, + ACT_CAT_DLS = 2, + ACT_CAT_BA = 3, + ACT_CAT_HT = 7, + ACT_CAT_WMM = 17, +} ACT_CATEGORY, *PACT_CATEGORY; + +typedef enum _TS_ACTION{ + ACT_ADDTSREQ = 0, + ACT_ADDTSRSP = 1, + ACT_DELTS = 2, + ACT_SCHEDULE = 3, +} TS_ACTION, *PTS_ACTION; + +typedef enum _BA_ACTION{ + ACT_ADDBAREQ = 0, + ACT_ADDBARSP = 1, + ACT_DELBA = 2, +} BA_ACTION, *PBA_ACTION; + +typedef enum _InitialGainOpType{ + IG_Backup=0, + IG_Restore, + IG_Max +}InitialGainOpType; +typedef enum _LED_CTL_MODE{ + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, + LED_CTL_STOP_WPS_FAIL = 12, + LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, +}LED_CTL_MODE; + +typedef enum _RT_RF_TYPE_DEF +{ + RF_1T2R = 0, + RF_2T4R, + RF_2T2R, + RF_1T1R, + RF_2T2R_GREEN, + RF_819X_MAX_TYPE +}RT_RF_TYPE_DEF; + +typedef enum _WIRELESS_MODE { + WIRELESS_MODE_UNKNOWN = 0x00, + WIRELESS_MODE_A = 0x01, + WIRELESS_MODE_B = 0x02, + WIRELESS_MODE_G = 0x04, + WIRELESS_MODE_AUTO = 0x08, + WIRELESS_MODE_N_24G = 0x10, + WIRELESS_MODE_N_5G = 0x20 +} WIRELESS_MODE; + +typedef enum _NETWORK_TYPE{ + WIRELESS_11B = 1, + WIRELESS_11G = 2, + WIRELESS_11A = 4, + WIRELESS_11N = 8 +} WIRELESS_NETWORK_TYPE; + +#define OUI_SUBTYPE_WMM_INFO 0 +#define OUI_SUBTYPE_WMM_PARAM 1 +#define OUI_SUBTYPE_QOS_CAPABI 5 + +/* debug macros */ +#define CONFIG_RTLLIB_DEBUG +#ifdef CONFIG_RTLLIB_DEBUG +extern u32 rtllib_debug_level; +#define RTLLIB_DEBUG(level, fmt, args...) \ +do { if (rtllib_debug_level & (level)) \ + printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0) +#define RTLLIB_DEBUG_DATA(level, data, datalen) \ + do{ if ((rtllib_debug_level & (level)) == (level)) \ + { \ + int i; \ + u8* pdata = (u8*) data; \ + printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ + for (i=0; i<(int)(datalen); i++) \ + { \ + printk("%2.2x ", pdata[i]); \ + if ((i+1)%16 == 0) printk("\n"); \ + } \ + printk("\n"); \ + } \ + } while (0) +#else +#define RTLLIB_DEBUG(level, fmt, args...) do {} while (0) +#define RTLLIB_DEBUG_DATA(level, data, datalen) do {} while(0) +#endif /* CONFIG_RTLLIB_DEBUG */ + +/* debug macros not dependent on CONFIG_RTLLIB_DEBUG */ + +#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" +#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] + +/* + * To use the debug system; + * + * If you are defining a new debug classification, simply add it to the #define + * list here in the form of: + * + * #define RTLLIB_DL_xxxx VALUE + * + * shifting value to the left one bit from the previous entry. xxxx should be + * the name of the classification (for example, WEP) + * + * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your + * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want + * to send output to that classification. + * + * To add your debug level to the list of levels seen when you perform + * + * % cat /proc/net/ipw/debug_level + * + * you simply need to add your entry to the ipw_debug_levels array. + * + * If you do not see debug_level in /proc/net/ipw then you do not have + * CONFIG_RTLLIB_DEBUG defined in your kernel configuration + * + */ + +#define RTLLIB_DL_INFO (1<<0) +#define RTLLIB_DL_WX (1<<1) +#define RTLLIB_DL_SCAN (1<<2) +#define RTLLIB_DL_STATE (1<<3) +#define RTLLIB_DL_MGMT (1<<4) +#define RTLLIB_DL_FRAG (1<<5) +#define RTLLIB_DL_EAP (1<<6) +#define RTLLIB_DL_DROP (1<<7) + +#define RTLLIB_DL_TX (1<<8) +#define RTLLIB_DL_RX (1<<9) + +#define RTLLIB_DL_HT (1<<10) +#define RTLLIB_DL_BA (1<<11) +#define RTLLIB_DL_TS (1<<12) +#define RTLLIB_DL_QOS (1<<13) +#define RTLLIB_DL_REORDER (1<<14) +#define RTLLIB_DL_IOT (1<<15) +#define RTLLIB_DL_IPS (1<<16) +#define RTLLIB_DL_TRACE (1<<29) +#define RTLLIB_DL_DATA (1<<30) +#define RTLLIB_DL_ERR (1<<31) +#define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a) +#define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a) +#define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) + +#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a) +#define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a) +#define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a) +#define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) +#define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a) +#define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a) +#define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a) +#define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a) +#define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a) +#define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a) + +#ifdef CONFIG_RTLLIB_DEBUG +/* Added by Annie, 2005-11-22. */ +#define MAX_STR_LEN 64 +/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ +#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') +#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ + if ((_Comp) & level) \ + { \ + int __i; \ + u8 buffer[MAX_STR_LEN]; \ + int length = (_Len\n", _Len, buffer); \ + } +#else +#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0) +#endif + +#ifndef ETH_P_PAE +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#endif /* ETH_P_PAE */ + +#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ + +#ifndef ETH_P_80211_RAW +#define ETH_P_80211_RAW (ETH_P_ECONET + 1) +#endif + +/* IEEE 802.11 defines */ + +#define P80211_OUI_LEN 3 + +struct rtllib_snap_hdr { + + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ + +} __attribute__ ((packed)); + +enum _REG_PREAMBLE_MODE{ + PREAMBLE_LONG = 1, + PREAMBLE_AUTO = 2, + PREAMBLE_SHORT= 3, +}; + +#define SNAP_SIZE sizeof(struct rtllib_snap_hdr) + +#define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS) +#define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE) +#define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA) + +#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE) +#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG) +#define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4) + +#ifndef CONFIG_CFG_80211 +/* Authentication algorithms */ +#define WLAN_AUTH_OPEN 0 +#define WLAN_AUTH_SHARED_KEY 1 +#define WLAN_AUTH_LEAP 128 + +#define WLAN_AUTH_CHALLENGE_LEN 128 + +#define WLAN_CAPABILITY_ESS (1<<0) +#define WLAN_CAPABILITY_IBSS (1<<1) +#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) +#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) +#define WLAN_CAPABILITY_PRIVACY (1<<4) +#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) +#define WLAN_CAPABILITY_PBCC (1<<6) +#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) +#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) +#define WLAN_CAPABILITY_QOS (1<<9) +#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) +#define WLAN_CAPABILITY_DSSS_OFDM (1<<13) + +/* 802.11g ERP information element */ +#define WLAN_ERP_NON_ERP_PRESENT (1<<0) +#define WLAN_ERP_USE_PROTECTION (1<<1) +#define WLAN_ERP_BARKER_PREAMBLE (1<<2) + +/* Status codes */ +enum rtllib_statuscode { + WLAN_STATUS_SUCCESS = 0, + WLAN_STATUS_UNSPECIFIED_FAILURE = 1, + WLAN_STATUS_CAPS_UNSUPPORTED = 10, + WLAN_STATUS_REASSOC_NO_ASSOC = 11, + WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, + WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, + WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, + WLAN_STATUS_CHALLENGE_FAIL = 15, + WLAN_STATUS_AUTH_TIMEOUT = 16, + WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, + WLAN_STATUS_ASSOC_DENIED_RATES = 18, + /* 802.11b */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, + WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, + WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, + /* 802.11h */ + WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, + WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, + WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, + /* 802.11g */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, + WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, + /* 802.11i */ + WLAN_STATUS_INVALID_IE = 40, + WLAN_STATUS_INVALID_GROUP_CIPHER = 41, + WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, + WLAN_STATUS_INVALID_AKMP = 43, + WLAN_STATUS_UNSUPP_RSN_VERSION = 44, + WLAN_STATUS_INVALID_RSN_IE_CAP = 45, + WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, +}; + +/* Reason codes */ +enum rtllib_reasoncode { + WLAN_REASON_UNSPECIFIED = 1, + WLAN_REASON_PREV_AUTH_NOT_VALID = 2, + WLAN_REASON_DEAUTH_LEAVING = 3, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, + WLAN_REASON_DISASSOC_AP_BUSY = 5, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, + WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, + /* 802.11h */ + WLAN_REASON_DISASSOC_BAD_POWER = 10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, + /* 802.11i */ + WLAN_REASON_INVALID_IE = 13, + WLAN_REASON_MIC_FAILURE = 14, + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, + WLAN_REASON_IE_DIFFERENT = 17, + WLAN_REASON_INVALID_GROUP_CIPHER = 18, + WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, + WLAN_REASON_INVALID_AKMP = 20, + WLAN_REASON_UNSUPP_RSN_VERSION = 21, + WLAN_REASON_INVALID_RSN_IE_CAP = 22, + WLAN_REASON_IEEE8021X_FAILED = 23, + WLAN_REASON_CIPHER_SUITE_REJECTED = 24, +}; +#endif + +#define RTLLIB_STATMASK_SIGNAL (1<<0) +#define RTLLIB_STATMASK_RSSI (1<<1) +#define RTLLIB_STATMASK_NOISE (1<<2) +#define RTLLIB_STATMASK_RATE (1<<3) +#define RTLLIB_STATMASK_WEMASK 0x7 + +#define RTLLIB_CCK_MODULATION (1<<0) +#define RTLLIB_OFDM_MODULATION (1<<1) + +#define RTLLIB_24GHZ_BAND (1<<0) +#define RTLLIB_52GHZ_BAND (1<<1) + +#define RTLLIB_CCK_RATE_LEN 4 +#define RTLLIB_CCK_RATE_1MB 0x02 +#define RTLLIB_CCK_RATE_2MB 0x04 +#define RTLLIB_CCK_RATE_5MB 0x0B +#define RTLLIB_CCK_RATE_11MB 0x16 +#define RTLLIB_OFDM_RATE_LEN 8 +#define RTLLIB_OFDM_RATE_6MB 0x0C +#define RTLLIB_OFDM_RATE_9MB 0x12 +#define RTLLIB_OFDM_RATE_12MB 0x18 +#define RTLLIB_OFDM_RATE_18MB 0x24 +#define RTLLIB_OFDM_RATE_24MB 0x30 +#define RTLLIB_OFDM_RATE_36MB 0x48 +#define RTLLIB_OFDM_RATE_48MB 0x60 +#define RTLLIB_OFDM_RATE_54MB 0x6C +#define RTLLIB_BASIC_RATE_MASK 0x80 + +#define RTLLIB_CCK_RATE_1MB_MASK (1<<0) +#define RTLLIB_CCK_RATE_2MB_MASK (1<<1) +#define RTLLIB_CCK_RATE_5MB_MASK (1<<2) +#define RTLLIB_CCK_RATE_11MB_MASK (1<<3) +#define RTLLIB_OFDM_RATE_6MB_MASK (1<<4) +#define RTLLIB_OFDM_RATE_9MB_MASK (1<<5) +#define RTLLIB_OFDM_RATE_12MB_MASK (1<<6) +#define RTLLIB_OFDM_RATE_18MB_MASK (1<<7) +#define RTLLIB_OFDM_RATE_24MB_MASK (1<<8) +#define RTLLIB_OFDM_RATE_36MB_MASK (1<<9) +#define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) +#define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) + +#define RTLLIB_CCK_RATES_MASK 0x0000000F +#define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ + RTLLIB_CCK_RATE_2MB_MASK) +#define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ + RTLLIB_CCK_RATE_5MB_MASK | \ + RTLLIB_CCK_RATE_11MB_MASK) + +#define RTLLIB_OFDM_RATES_MASK 0x00000FF0 +#define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ + RTLLIB_OFDM_RATE_12MB_MASK | \ + RTLLIB_OFDM_RATE_24MB_MASK) +#define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \ + RTLLIB_OFDM_RATE_9MB_MASK | \ + RTLLIB_OFDM_RATE_18MB_MASK | \ + RTLLIB_OFDM_RATE_36MB_MASK | \ + RTLLIB_OFDM_RATE_48MB_MASK | \ + RTLLIB_OFDM_RATE_54MB_MASK) +#define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ + RTLLIB_CCK_DEFAULT_RATES_MASK) + +#define RTLLIB_NUM_OFDM_RATES 8 +#define RTLLIB_NUM_CCK_RATES 4 +#define RTLLIB_OFDM_SHIFT_MASK_A 4 + + +/* this is stolen and modified from the madwifi driver*/ +#define RTLLIB_FC0_TYPE_MASK 0x0c +#define RTLLIB_FC0_TYPE_DATA 0x08 +#define RTLLIB_FC0_SUBTYPE_MASK 0xB0 +#define RTLLIB_FC0_SUBTYPE_QOS 0x80 + +#define RTLLIB_QOS_HAS_SEQ(fc) \ + (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \ + (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS)) + +/* this is stolen from ipw2200 driver */ +#define IEEE_IBSS_MAC_HASH_SIZE 31 +struct ieee_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num[17]; + u16 frag_num[17]; + unsigned long packet_time[17]; + struct list_head list; +}; + +/* NOTE: This data is for statistical purposes; not all hardware provides this + * information for frames received. Not setting these will not cause + * any adverse affects. */ +struct rtllib_rx_stats { +#if 1 + u32 mac_time[2]; + s8 rssi; + u8 signal; + u8 noise; + u16 rate; /* in 100 kbps */ + u8 received_channel; + u8 control; + u8 mask; + u8 freq; + u16 len; + u64 tsf; + u32 beacon_time; + u8 nic_type; + u16 Length; + u8 SignalQuality; + s32 RecvSignalPower; + s8 RxPower; + u8 SignalStrength; + u16 bHwError:1; + u16 bCRC:1; + u16 bICV:1; + u16 bShortPreamble:1; + u16 Antenna:1; + u16 Decrypted:1; + u16 Wakeup:1; + u16 Reserved0:1; + u8 AGC; + u32 TimeStampLow; + u32 TimeStampHigh; + bool bShift; + bool bIsQosData; + u8 UserPriority; + + u8 RxDrvInfoSize; + u8 RxBufShift; + bool bIsAMPDU; + bool bFirstMPDU; + bool bContainHTC; + bool RxIs40MHzPacket; + u32 RxPWDBAll; + u8 RxMIMOSignalStrength[4]; + s8 RxMIMOSignalQuality[2]; + bool bPacketMatchBSSID; + bool bIsCCK; + bool bPacketToSelf; + u8* virtual_address; + u16 packetlength; + u16 fraglength; + u16 fragoffset; + u16 ntotalfrag; + bool bisrxaggrsubframe; + bool bPacketBeacon; + bool bToSelfBA; + char cck_adc_pwdb[4]; + u16 Seq_Num; + u8 nTotalAggPkt; +#ifdef TCP_CSUM_OFFLOAD_RX + u8 tcp_csum_valid; +#endif +#endif + +}; + +/* IEEE 802.11 requires that STA supports concurrent reception of at least + * three fragmented frames. This define can be increased to support more + * concurrent frames, but it should be noted that each entry can consume about + * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ +#define RTLLIB_FRAG_CACHE_LEN 4 + +struct rtllib_frag_entry { + unsigned long first_frag_time; + unsigned int seq; + unsigned int last_frag; + struct sk_buff *skb; + u8 src_addr[ETH_ALEN]; + u8 dst_addr[ETH_ALEN]; +}; + +struct rtllib_stats { + unsigned int tx_unicast_frames; + unsigned int tx_multicast_frames; + unsigned int tx_fragments; + unsigned int tx_unicast_octets; + unsigned int tx_multicast_octets; + unsigned int tx_deferred_transmissions; + unsigned int tx_single_retry_frames; + unsigned int tx_multiple_retry_frames; + unsigned int tx_retry_limit_exceeded; + unsigned int tx_discards; + unsigned int rx_unicast_frames; + unsigned int rx_multicast_frames; + unsigned int rx_fragments; + unsigned int rx_unicast_octets; + unsigned int rx_multicast_octets; + unsigned int rx_fcs_errors; + unsigned int rx_discards_no_buffer; + unsigned int tx_discards_wrong_sa; + unsigned int rx_discards_undecryptable; + unsigned int rx_message_in_msg_fragments; + unsigned int rx_message_in_bad_msg_fragments; +}; + +struct rtllib_device; + +#include "rtllib_crypt.h" + +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) +#define SEC_ACTIVE_KEY (1<<4) +#define SEC_AUTH_MODE (1<<5) +#define SEC_UNICAST_GROUP (1<<6) +#define SEC_LEVEL (1<<7) +#define SEC_ENABLED (1<<8) +#define SEC_ENCRYPT (1<<9) + +#define SEC_LEVEL_0 0 /* None */ +#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ +#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ +#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ +#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ + +#define SEC_ALG_NONE 0 +#define SEC_ALG_WEP 1 +#define SEC_ALG_TKIP 2 +#define SEC_ALG_CCMP 4 + +#define WEP_KEYS 4 +#define WEP_KEY_LEN 13 +#define SCM_KEY_LEN 32 +#define SCM_TEMPORAL_KEY_LENGTH 16 + +struct rtllib_security { + u16 active_key:2, + enabled:1, + auth_mode:2, + auth_algo:4, + unicast_uses_group:1, + encrypt:1; + u8 key_sizes[WEP_KEYS]; + u8 keys[WEP_KEYS][SCM_KEY_LEN]; + u8 level; + u16 flags; +} __attribute__ ((packed)); + + +/* + 802.11 data frame from AP + ,-------------------------------------------------------------------. +Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | + |------|------|---------|---------|---------|------|---------|------| +Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | + | | tion | (BSSID) | | | ence | data | | + `-------------------------------------------------------------------' +Total: 28-2340 bytes +*/ + +/* Management Frame Information Element Types */ +enum rtllib_mfie { + MFIE_TYPE_SSID = 0, + MFIE_TYPE_RATES = 1, + MFIE_TYPE_FH_SET = 2, + MFIE_TYPE_DS_SET = 3, + MFIE_TYPE_CF_SET = 4, + MFIE_TYPE_TIM = 5, + MFIE_TYPE_IBSS_SET = 6, + MFIE_TYPE_COUNTRY = 7, + MFIE_TYPE_HOP_PARAMS = 8, + MFIE_TYPE_HOP_TABLE = 9, + MFIE_TYPE_REQUEST = 10, + MFIE_TYPE_CHALLENGE = 16, + MFIE_TYPE_POWER_CONSTRAINT = 32, + MFIE_TYPE_POWER_CAPABILITY = 33, + MFIE_TYPE_TPC_REQUEST = 34, + MFIE_TYPE_TPC_REPORT = 35, + MFIE_TYPE_SUPP_CHANNELS = 36, + MFIE_TYPE_CSA = 37, + MFIE_TYPE_MEASURE_REQUEST = 38, + MFIE_TYPE_MEASURE_REPORT = 39, + MFIE_TYPE_QUIET = 40, + MFIE_TYPE_IBSS_DFS = 41, + MFIE_TYPE_ERP = 42, + MFIE_TYPE_HT_CAP= 45, + MFIE_TYPE_RSN = 48, + MFIE_TYPE_RATES_EX = 50, + MFIE_TYPE_HT_INFO= 61, + MFIE_TYPE_AIRONET=133, + MFIE_TYPE_GENERIC = 221, + MFIE_TYPE_QOS_PARAMETER = 222, +}; + +/* Minimal header; can be used for passing 802.11 frames with sufficient + * information to determine what type of underlying data type is actually + * stored in the data. */ +struct rtllib_pspoll_hdr { + __le16 frame_ctl; + __le16 aid; + u8 bssid[ETH_ALEN]; + u8 ta[ETH_ALEN]; +} __attribute__ ((packed)); + +struct rtllib_hdr { + __le16 frame_ctl; + __le16 duration_id; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_1addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_2addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_3addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + __le16 seq_ctl; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_4addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + __le16 seq_ctl; + u8 addr4[ETH_ALEN]; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_3addrqos { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + __le16 seq_ctl; + __le16 qos_ctl; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_hdr_4addrqos { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + __le16 seq_ctl; + u8 addr4[ETH_ALEN]; + __le16 qos_ctl; + u8 payload[0]; +} __attribute__ ((packed)); + +struct rtllib_info_element { + u8 id; + u8 len; + u8 data[0]; +} __attribute__ ((packed)); + +struct rtllib_authentication { + struct rtllib_hdr_3addr header; + __le16 algorithm; + __le16 transaction; + __le16 status; + /*challenge*/ + struct rtllib_info_element info_element[0]; +} __attribute__ ((packed)); + +struct rtllib_disauth { + struct rtllib_hdr_3addr header; + __le16 reason; +} __attribute__ ((packed)); + +struct rtllib_disassoc { + struct rtllib_hdr_3addr header; + __le16 reason; +} __attribute__ ((packed)); + +struct rtllib_probe_request { + struct rtllib_hdr_3addr header; + /* SSID, supported rates */ + struct rtllib_info_element info_element[0]; +} __attribute__ ((packed)); + +struct rtllib_probe_response { + struct rtllib_hdr_3addr header; + u32 time_stamp[2]; + __le16 beacon_interval; + __le16 capability; + /* SSID, supported rates, FH params, DS params, + * CF params, IBSS params, TIM (if beacon), RSN */ + struct rtllib_info_element info_element[0]; +} __attribute__ ((packed)); + +/* Alias beacon for probe_response */ +#define rtllib_beacon rtllib_probe_response + +struct rtllib_assoc_request_frame { + struct rtllib_hdr_3addr header; + __le16 capability; + __le16 listen_interval; + /* SSID, supported rates, RSN */ + struct rtllib_info_element info_element[0]; +} __attribute__ ((packed)); + +struct rtllib_reassoc_request_frame { + struct rtllib_hdr_3addr header; + __le16 capability; + __le16 listen_interval; + u8 current_ap[ETH_ALEN]; + /* SSID, supported rates, RSN */ + struct rtllib_info_element info_element[0]; +} __attribute__ ((packed)); + +struct rtllib_assoc_response_frame { + struct rtllib_hdr_3addr header; + __le16 capability; + __le16 status; + __le16 aid; + struct rtllib_info_element info_element[0]; /* supported rates */ +} __attribute__ ((packed)); + +struct rtllib_txb { + u8 nr_frags; + u8 encrypted; + u8 queue_index; + u8 rts_included; + u16 reserved; + __le16 frag_size; + __le16 payload_size; + struct sk_buff *fragments[0]; +}; + +#define MAX_TX_AGG_COUNT 16 +struct rtllib_drv_agg_txb { + u8 nr_drv_agg_frames; + struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; +}__attribute__((packed)); + +#define MAX_SUBFRAME_COUNT 64 +struct rtllib_rxb { + u8 nr_subframes; + struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; + u8 dst[ETH_ALEN]; + u8 src[ETH_ALEN]; +#ifdef TCP_CSUM_OFFLOAD_RX + u8 tcp_csum_valid; +#endif +}__attribute__((packed)); + +typedef union _frameqos { + u16 shortdata; + u8 chardata[2]; + struct { + u16 tid:4; + u16 eosp:1; + u16 ack_policy:2; + u16 reserved:1; + u16 txop:8; + }field; +}frameqos,*pframeqos; + +/* SWEEP TABLE ENTRIES NUMBER*/ +#define MAX_SWEEP_TAB_ENTRIES 42 +#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 +/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs + * only use 8, and then use extended rates for the remaining supported + * rates. Other APs, however, stick all of their supported rates on the + * main rates information element... */ +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#define MAX_NETWORK_COUNT 16 +#else +#define MAX_NETWORK_COUNT 96 +#endif + +#define MAX_CHANNEL_NUMBER 161 +#define RTLLIB_SOFTMAC_SCAN_TIME 100 +#define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) + +#define CRC_LENGTH 4U + +#define MAX_WPA_IE_LEN 64 +#define MAX_WZC_IE_LEN 256 + +#define NETWORK_EMPTY_ESSID (1<<0) +#define NETWORK_HAS_OFDM (1<<1) +#define NETWORK_HAS_CCK (1<<2) + +/* QoS structure */ +#define NETWORK_HAS_QOS_PARAMETERS (1<<3) +#define NETWORK_HAS_QOS_INFORMATION (1<<4) +#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ + NETWORK_HAS_QOS_INFORMATION) +/* 802.11h */ +#define NETWORK_HAS_POWER_CONSTRAINT (1<<5) +#define NETWORK_HAS_CSA (1<<6) +#define NETWORK_HAS_QUIET (1<<7) +#define NETWORK_HAS_IBSS_DFS (1<<8) +#define NETWORK_HAS_TPC_REPORT (1<<9) + +#define NETWORK_HAS_ERP_VALUE (1<<10) + +#define QOS_QUEUE_NUM 4 +#define QOS_OUI_LEN 3 +#define QOS_OUI_TYPE 2 +#define QOS_ELEMENT_ID 221 +#define QOS_OUI_INFO_SUB_TYPE 0 +#define QOS_OUI_PARAM_SUB_TYPE 1 +#define QOS_VERSION_1 1 +#define QOS_AIFSN_MIN_VALUE 2 +#if 1 +struct rtllib_qos_information_element { + u8 elementID; + u8 length; + u8 qui[QOS_OUI_LEN]; + u8 qui_type; + u8 qui_subtype; + u8 version; + u8 ac_info; +} __attribute__ ((packed)); + +struct rtllib_qos_ac_parameter { + u8 aci_aifsn; + u8 ecw_min_max; + __le16 tx_op_limit; +} __attribute__ ((packed)); + +struct rtllib_qos_parameter_info { + struct rtllib_qos_information_element info_element; + u8 reserved; + struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; +} __attribute__ ((packed)); + +struct rtllib_qos_parameters { + __le16 cw_min[QOS_QUEUE_NUM]; + __le16 cw_max[QOS_QUEUE_NUM]; + u8 aifs[QOS_QUEUE_NUM]; + u8 flag[QOS_QUEUE_NUM]; + __le16 tx_op_limit[QOS_QUEUE_NUM]; +} __attribute__ ((packed)); + +struct rtllib_qos_data { + struct rtllib_qos_parameters parameters; + unsigned int wmm_acm; + int active; + int supported; + u8 param_count; + u8 old_param_count; +}; + +struct rtllib_tim_parameters { + u8 tim_count; + u8 tim_period; +} __attribute__ ((packed)); + +struct rtllib_wmm_ac_param { + u8 ac_aci_acm_aifsn; + u8 ac_ecwmin_ecwmax; + u16 ac_txop_limit; +}; + +struct rtllib_wmm_ts_info { + u8 ac_dir_tid; + u8 ac_up_psb; + u8 reserved; +} __attribute__ ((packed)); + +struct rtllib_wmm_tspec_elem { + struct rtllib_wmm_ts_info ts_info; + u16 norm_msdu_size; + u16 max_msdu_size; + u32 min_serv_inter; + u32 max_serv_inter; + u32 inact_inter; + u32 suspen_inter; + u32 serv_start_time; + u32 min_data_rate; + u32 mean_data_rate; + u32 peak_data_rate; + u32 max_burst_size; + u32 delay_bound; + u32 min_phy_rate; + u16 surp_band_allow; + u16 medium_time; +}__attribute__((packed)); +#endif +enum eap_type { + EAP_PACKET = 0, + EAPOL_START, + EAPOL_LOGOFF, + EAPOL_KEY, + EAPOL_ENCAP_ASF_ALERT +}; + +static const char *eap_types[] = { + [EAP_PACKET] = "EAP-Packet", + [EAPOL_START] = "EAPOL-Start", + [EAPOL_LOGOFF] = "EAPOL-Logoff", + [EAPOL_KEY] = "EAPOL-Key", + [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert" +}; + +static inline const char *eap_get_type(int type) +{ + return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; +} +static inline u8 Frame_QoSTID(u8* buf) +{ + struct rtllib_hdr_3addr *hdr; + u16 fc; + hdr = (struct rtllib_hdr_3addr *)buf; + fc = le16_to_cpu(hdr->frame_ctl); + return (u8)((frameqos*)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; +} + + +struct eapol { + u8 snap[6]; + u16 ethertype; + u8 version; + u8 type; + u16 length; +} __attribute__ ((packed)); + +struct rtllib_softmac_stats{ + unsigned int rx_ass_ok; + unsigned int rx_ass_err; + unsigned int rx_probe_rq; + unsigned int tx_probe_rs; + unsigned int tx_beacons; + unsigned int rx_auth_rq; + unsigned int rx_auth_rs_ok; + unsigned int rx_auth_rs_err; + unsigned int tx_auth_rq; + unsigned int no_auth_rs; + unsigned int no_ass_rs; + unsigned int tx_ass_rq; + unsigned int rx_ass_rq; + unsigned int tx_probe_rq; + unsigned int reassoc; + unsigned int swtxstop; + unsigned int swtxawake; + unsigned char CurrentShowTxate; + unsigned char last_packet_rate; + unsigned int txretrycount; +}; + +#define BEACON_PROBE_SSID_ID_POSITION 12 + +struct rtllib_info_element_hdr { + u8 id; + u8 len; +} __attribute__ ((packed)); + +/* + * These are the data types that can make up management packets + * + u16 auth_algorithm; + u16 auth_sequence; + u16 beacon_interval; + u16 capability; + u8 current_ap[ETH_ALEN]; + u16 listen_interval; + struct { + u16 association_id:14, reserved:2; + } __attribute__ ((packed)); + u32 time_stamp[2]; + u16 reason; + u16 status; +*/ + +#define RTLLIB_DEFAULT_TX_ESSID "Penguin" +#define RTLLIB_DEFAULT_BASIC_RATE 2 + +enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; +#define MAX_SP_Len (WMM_all_frame << 4) +#define RTLLIB_QOS_TID 0x0f +#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5) + +#define RTLLIB_DTIM_MBCAST 4 +#define RTLLIB_DTIM_UCAST 2 +#define RTLLIB_DTIM_VALID 1 +#define RTLLIB_DTIM_INVALID 0 + +#define RTLLIB_PS_DISABLED 0 +#define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST +#define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST + +#ifdef WMM_Hang_8187 +#undef WMM_Hang_8187 +#endif + +#define WME_AC_BK 0x00 +#define WME_AC_BE 0x01 +#define WME_AC_VI 0x02 +#define WME_AC_VO 0x03 +#define WME_ACI_MASK 0x03 +#define WME_AIFSN_MASK 0x03 +#define WME_AC_PRAM_LEN 16 + +#define MAX_RECEIVE_BUFFER_SIZE 9100 + +#if 1 +#define UP2AC(up) ( \ + ((up) < 1) ? WME_AC_BE : \ + ((up) < 3) ? WME_AC_BK : \ + ((up) < 4) ? WME_AC_BE : \ + ((up) < 6) ? WME_AC_VI : \ + WME_AC_VO) +#endif +#define AC2UP(_ac) ( \ + ((_ac) == WME_AC_VO) ? 6 : \ + ((_ac) == WME_AC_VI) ? 5 : \ + ((_ac) == WME_AC_BK) ? 1 : \ + 0) + +#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ +#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/ + +struct ether_header { + u8 ether_dhost[ETHER_ADDR_LEN]; + u8 ether_shost[ETHER_ADDR_LEN]; + u16 ether_type; +} __attribute__((packed)); + +#ifndef ETHERTYPE_PAE +#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ +#endif +#ifndef ETHERTYPE_IP +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#endif + + +typedef enum _erp_t{ + ERP_NonERPpresent = 0x01, + ERP_UseProtection = 0x02, + ERP_BarkerPreambleMode = 0x04, +} erp_t; + +struct rtllib_network { + /* These entries are used to identify a unique network */ + u8 bssid[ETH_ALEN]; + u8 channel; + /* Ensure null-terminated for any debug msgs */ + u8 ssid[IW_ESSID_MAX_SIZE + 1]; + u8 ssid_len; + u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1]; + u8 hidden_ssid_len; + struct rtllib_qos_data qos_data; + + bool bWithAironetIE; + bool bCkipSupported; + bool bCcxRmEnable; + u16 CcxRmState[2]; + bool bMBssidValid; + u8 MBssidMask; + u8 MBssid[6]; + bool bWithCcxVerNum; + u8 BssCcxVerNumber; + /* These are network statistics */ + struct rtllib_rx_stats stats; + u16 capability; + u8 rates[MAX_RATES_LENGTH]; + u8 rates_len; + u8 rates_ex[MAX_RATES_EX_LENGTH]; + u8 rates_ex_len; + unsigned long last_scanned; + u8 mode; + u32 flags; + u32 last_associate; + u32 time_stamp[2]; + u16 beacon_interval; + u16 listen_interval; + u16 atim_window; + u8 erp_value; + u8 wpa_ie[MAX_WPA_IE_LEN]; + size_t wpa_ie_len; + u8 rsn_ie[MAX_WPA_IE_LEN]; + size_t rsn_ie_len; + u8 wzc_ie[MAX_WZC_IE_LEN]; + size_t wzc_ie_len; + + struct rtllib_tim_parameters tim; + u8 dtim_period; + u8 dtim_data; + u32 last_dtim_sta_time[2]; + + u8 wmm_info; + struct rtllib_wmm_ac_param wmm_param[4]; + u8 Turbo_Enable; +#ifdef ENABLE_DOT11D + u16 CountryIeLen; + u8 CountryIeBuf[MAX_IE_LEN]; +#endif + BSS_HT bssht; + bool broadcom_cap_exist; + bool realtek_cap_exit; + bool marvell_cap_exist; + bool ralink_cap_exist; + bool atheros_cap_exist; + bool cisco_cap_exist; + bool airgo_cap_exist; + bool unknown_cap_exist; + bool berp_info_valid; + bool buseprotection; + bool bIsNetgear854T; + u8 SignalStrength; + u8 RSSI; + struct list_head list; +}; + +#if 1 +enum rtllib_state { + + /* the card is not linked at all */ + RTLLIB_NOLINK = 0, + + /* RTLLIB_ASSOCIATING* are for BSS client mode + * the driver shall not perform RX filtering unless + * the state is LINKED. + * The driver shall just check for the state LINKED and + * defaults to NOLINK for ALL the other states (including + * LINKED_SCANNING) + */ + + /* the association procedure will start (wq scheduling)*/ + RTLLIB_ASSOCIATING, + RTLLIB_ASSOCIATING_RETRY, + + /* the association procedure is sending AUTH request*/ + RTLLIB_ASSOCIATING_AUTHENTICATING, + + /* the association procedure has successfully authentcated + * and is sending association request + */ + RTLLIB_ASSOCIATING_AUTHENTICATED, + + /* the link is ok. the card associated to a BSS or linked + * to a ibss cell or acting as an AP and creating the bss + */ + RTLLIB_LINKED, + + /* same as LINKED, but the driver shall apply RX filter + * rules as we are in NO_LINK mode. As the card is still + * logically linked, but it is doing a syncro site survey + * then it will be back to LINKED state. + */ + RTLLIB_LINKED_SCANNING, +}; +#else +enum rtllib_state { + RTLLIB_UNINITIALIZED = 0, + RTLLIB_INITIALIZED, + RTLLIB_ASSOCIATING, + RTLLIB_ASSOCIATED, + RTLLIB_AUTHENTICATING, + RTLLIB_AUTHENTICATED, + RTLLIB_SHUTDOWN +}; +#endif + +#define DEFAULT_MAX_SCAN_AGE (15 * HZ) +#define DEFAULT_FTS 2346 + +#define CFG_RTLLIB_RESERVE_FCS (1<<0) +#define CFG_RTLLIB_COMPUTE_FCS (1<<1) +#define CFG_RTLLIB_RTS (1<<2) + +#define RTLLIB_24GHZ_MIN_CHANNEL 1 +#define RTLLIB_24GHZ_MAX_CHANNEL 14 +#define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ + RTLLIB_24GHZ_MIN_CHANNEL + 1) + +#define RTLLIB_52GHZ_MIN_CHANNEL 34 +#define RTLLIB_52GHZ_MAX_CHANNEL 165 +#define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ + RTLLIB_52GHZ_MIN_CHANNEL + 1) + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) +extern inline int is_multicast_ether_addr(const u8 *addr) +{ + return ((addr[0] != 0xff) && (0x01 & addr[0])); +} +#endif + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) +extern inline int is_broadcast_ether_addr(const u8 *addr) +{ + return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ + (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); +} +#endif +#ifndef eqMacAddr +#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) +#endif +typedef struct tx_pending_t{ + int frag; + struct rtllib_txb *txb; +}tx_pending_t; + +typedef struct _bandwidth_autoswitch +{ + long threshold_20Mhzto40Mhz; + long threshold_40Mhzto20Mhz; + bool bforced_tx20Mhz; + bool bautoswitch_enable; +}bandwidth_autoswitch,*pbandwidth_autoswitch; + + + +#define REORDER_WIN_SIZE 128 +#define REORDER_ENTRY_NUM 128 +typedef struct _RX_REORDER_ENTRY +{ + struct list_head List; + u16 SeqNum; + struct rtllib_rxb* prxb; +} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; +typedef enum _Fsync_State{ + Default_Fsync, + HW_Fsync, + SW_Fsync +}Fsync_State; + +typedef enum _RT_PS_MODE +{ + eActive, + eMaxPs, + eFastPs, + eAutoPs, +}RT_PS_MODE; + +typedef enum _IPS_CALLBACK_FUNCION +{ + IPS_CALLBACK_NONE = 0, + IPS_CALLBACK_MGNT_LINK_REQUEST = 1, + IPS_CALLBACK_JOIN_REQUEST = 2, +}IPS_CALLBACK_FUNCION; + +typedef enum _RT_JOIN_ACTION{ + RT_JOIN_INFRA = 1, + RT_JOIN_IBSS = 2, + RT_START_IBSS = 3, + RT_NO_ACTION = 4, +}RT_JOIN_ACTION; + +typedef struct _IbssParms{ + u16 atimWin; +}IbssParms, *PIbssParms; +#define MAX_NUM_RATES 264 + +typedef enum _RT_RF_POWER_STATE +{ + eRfOn, + eRfSleep, + eRfOff +}RT_RF_POWER_STATE; + +#define MAX_SUPPORT_WOL_PATTERN_NUM 8 + +#define MAX_WOL_BIT_MASK_SIZE 16 +#define MAX_WOL_PATTERN_SIZE 128 + +typedef enum _WOLPATTERN_TYPE +{ + eNetBIOS = 0, + eIPv4IPv6ARP, + eIPv4IPv6TCPSYN, + eMACIDOnly, + eNoDefined, +}WOLPATTERN_TYPE; + +typedef struct _RT_PM_WOL_PATTERN_INFO +{ + u32 PatternId; + u32 Mask[4]; + u16 CrcRemainder; + u8 WFMIndex; + WOLPATTERN_TYPE PatternType; +}RT_PM_WOL_PATTERN_INFO, *PRT_PM_WOL_PATTERN_INFO; + +typedef struct _RT_POWER_SAVE_CONTROL +{ + + bool bInactivePs; + bool bIPSModeBackup; + bool bHaltAdapterClkRQ; + bool bSwRfProcessing; + RT_RF_POWER_STATE eInactivePowerState; + work_struct_rsl InactivePsWorkItem; + struct timer_list InactivePsTimer; + + IPS_CALLBACK_FUNCION ReturnPoint; + + bool bTmpBssDesc; + RT_JOIN_ACTION tmpJoinAction; + struct rtllib_network tmpBssDesc; + + bool bTmpScanOnly; + bool bTmpActiveScan; + bool bTmpFilterHiddenAP; + bool bTmpUpdateParms; + u8 tmpSsidBuf[33]; + OCTET_STRING tmpSsid2Scan; + bool bTmpSsid2Scan; + u8 tmpNetworkType; + u8 tmpChannelNumber; + u16 tmpBcnPeriod; + u8 tmpDtimPeriod; + u16 tmpmCap; + OCTET_STRING tmpSuppRateSet; + u8 tmpSuppRateBuf[MAX_NUM_RATES]; + bool bTmpSuppRate; + IbssParms tmpIbpm; + bool bTmpIbpm; + + bool bLeisurePs; + u32 PowerProfile; + u8 LpsIdleCount; + u8 RegMaxLPSAwakeIntvl; + u8 LPSAwakeIntvl; + + u32 CurPsLevel; + u32 RegRfPsLevel; + + bool bFwCtrlLPS; + u8 FWCtrlPSMode; + + bool LinkReqInIPSRFOffPgs; + bool BufConnectinfoBefore; + + + bool bGpioRfSw; + + u8 RegAMDPciASPM; + + u8 oWLANMode; + RT_PM_WOL_PATTERN_INFO PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; + +}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL; + +typedef u32 RT_RF_CHANGE_SOURCE; +#define RF_CHANGE_BY_SW BIT31 +#define RF_CHANGE_BY_HW BIT30 +#define RF_CHANGE_BY_PS BIT29 +#define RF_CHANGE_BY_IPS BIT28 +#define RF_CHANGE_BY_INIT 0 + +typedef enum +{ + COUNTRY_CODE_FCC = 0, + COUNTRY_CODE_IC = 1, + COUNTRY_CODE_ETSI = 2, + COUNTRY_CODE_SPAIN = 3, + COUNTRY_CODE_FRANCE = 4, + COUNTRY_CODE_MKK = 5, + COUNTRY_CODE_MKK1 = 6, + COUNTRY_CODE_ISRAEL = 7, + COUNTRY_CODE_TELEC = 8, + COUNTRY_CODE_MIC = 9, + COUNTRY_CODE_GLOBAL_DOMAIN = 10, + COUNTRY_CODE_WORLD_WIDE_13 = 11, + COUNTRY_CODE_TELEC_NETGEAR = 12, + COUNTRY_CODE_MAX +}country_code_type_t; + +typedef enum _SCAN_OPERATION_BACKUP_OPT{ + SCAN_OPT_BACKUP=0, + SCAN_OPT_RESTORE, + SCAN_OPT_MAX +}SCAN_OPERATION_BACKUP_OPT; + +typedef enum _FW_CMD_IO_TYPE{ + FW_CMD_DIG_ENABLE = 0, + FW_CMD_DIG_DISABLE = 1, + FW_CMD_DIG_HALT = 2, + FW_CMD_DIG_RESUME = 3, + FW_CMD_HIGH_PWR_ENABLE = 4, + FW_CMD_HIGH_PWR_DISABLE = 5, + FW_CMD_RA_RESET = 6, + FW_CMD_RA_ACTIVE= 7, + FW_CMD_RA_REFRESH_N= 8, + FW_CMD_RA_REFRESH_BG= 9, + FW_CMD_RA_INIT= 10, + FW_CMD_IQK_ENABLE = 11, + FW_CMD_TXPWR_TRACK_ENABLE = 12, + FW_CMD_TXPWR_TRACK_DISABLE = 13, + FW_CMD_TXPWR_TRACK_THERMAL = 14, + FW_CMD_PAUSE_DM_BY_SCAN = 15, + FW_CMD_RESUME_DM_BY_SCAN = 16, + FW_CMD_RA_REFRESH_N_COMB = 17, + FW_CMD_RA_REFRESH_BG_COMB = 18, + FW_CMD_ANTENNA_SW_ENABLE = 19, + FW_CMD_ANTENNA_SW_DISABLE = 20, + FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21, + FW_CMD_LPS_ENTER = 22, + FW_CMD_LPS_LEAVE = 23, + FW_CMD_DIG_MODE_SS = 24, + FW_CMD_DIG_MODE_FA = 25, + FW_CMD_ADD_A2_ENTRY = 26, + FW_CMD_CTRL_DM_BY_DRIVER = 27, + FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28, + FW_CMD_PAPE_CONTROL = 29, + FW_CMD_CHAN_SET = 30, +}FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE; + +#define RT_MAX_LD_SLOT_NUM 10 +typedef struct _RT_LINK_DETECT_T{ + + u32 NumRecvBcnInPeriod; + u32 NumRecvDataInPeriod; + + u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; + u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; + u16 SlotNum; + u16 SlotIndex; + + u32 NumTxOkInPeriod; + u32 NumRxOkInPeriod; + u32 NumRxUnicastOkInPeriod; + bool bBusyTraffic; + bool bHigherBusyTraffic; + bool bHigherBusyRxTraffic; + u8 IdleCount; + u32 NumTxUnicastOkInPeriod; + u32 LastNumTxUnicast; + u32 LastNumRxUnicast; +}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; + +typedef struct _SW_CAM_TABLE{ + + u8 macaddr[6]; + bool bused; + u8 key_buf[16]; + u16 key_type; + u8 useDK; + u8 key_index; + +}SW_CAM_TABLE,*PSW_CAM_TABLE; +#define TOTAL_CAM_ENTRY 32 +typedef struct _rate_adaptive +{ + u8 rate_adaptive_disabled; + u8 ratr_state; + u16 reserve; + + u32 high_rssi_thresh_for_ra; + u32 high2low_rssi_thresh_for_ra; + u8 low2high_rssi_thresh_for_ra40M; + u32 low_rssi_thresh_for_ra40M; + u8 low2high_rssi_thresh_for_ra20M; + u32 low_rssi_thresh_for_ra20M; + u32 upper_rssi_threshold_ratr; + u32 middle_rssi_threshold_ratr; + u32 low_rssi_threshold_ratr; + u32 low_rssi_threshold_ratr_40M; + u32 low_rssi_threshold_ratr_20M; + u8 ping_rssi_enable; + u32 ping_rssi_ratr; + u32 ping_rssi_thresh_for_ra; + u32 last_ratr; + u8 PreRATRState; + +} rate_adaptive, *prate_adaptive; +typedef enum _RATR_TABLE_MODE_8192S{ + RATR_INX_WIRELESS_NGB = 0, + RATR_INX_WIRELESS_NG = 1, + RATR_INX_WIRELESS_NB = 2, + RATR_INX_WIRELESS_N = 3, + RATR_INX_WIRELESS_GB = 4, + RATR_INX_WIRELESS_G = 5, + RATR_INX_WIRELESS_B = 6, + RATR_INX_WIRELESS_MC = 7, + RATR_INX_WIRELESS_A = 8, +}RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S; + +#define NUM_PMKID_CACHE 16 +typedef struct _RT_PMKID_LIST +{ + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8* ssid_octet; + u16 ssid_length; +} RT_PMKID_LIST, *PRT_PMKID_LIST; + +#ifdef CONFIG_CFG_80211 +enum { + LIBIPW_CH_PASSIVE_ONLY = (1 << 0), + LIBIPW_CH_80211H_RULES = (1 << 1), + LIBIPW_CH_B_ONLY = (1 << 2), + LIBIPW_CH_NO_IBSS = (1 << 3), + LIBIPW_CH_UNIFORM_SPREADING = (1 << 4), + LIBIPW_CH_RADAR_DETECT = (1 << 5), + LIBIPW_CH_INVALID = (1 << 6), +}; +struct rtllib_channel { + u32 freq; + u8 channel; + u8 flags; + u8 max_power; +}; + +#define RTLLIB_24GHZ_MIN_CHANNEL 1 +#define RTLLIB_24GHZ_MAX_CHANNEL 14 +#define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ + RTLLIB_24GHZ_MIN_CHANNEL + 1) + +struct reg_dmn_pair_mapping { + u16 regDmnEnum; + u16 reg_5ghz_ctl; + u16 reg_2ghz_ctl; +}; + +struct rtl_regulatory { + char alpha2[2]; + u16 country_code; + u16 max_power_level; + u32 tp_scale; + u16 current_rd; + u16 current_rd_ext; + int16_t power_limit; + struct reg_dmn_pair_mapping *regpair; +}; + +struct ieee80211_bss { + /* Yes, this is a hack */ + struct cfg80211_bss cbss; + + /* don't want to look up all the time */ + size_t ssid_len; + u8 ssid[IEEE80211_MAX_SSID_LEN]; + + u8 dtim_period; + + bool wmm_used; + + unsigned long last_probe_resp; + +#ifdef CONFIG_MAC80211_MESH + u8 *mesh_id; + size_t mesh_id_len; + u8 *mesh_cfg; +#endif + + #define IEEE80211_MAX_SUPP_RATES 32 + u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; + size_t supp_rates_len; + + /* + * During assocation, we save an ERP value from a probe response so + * that we can feed ERP info to the driver when handling the + * association completes. these fields probably won't be up-to-date + * otherwise, you probably don't want to use them. + */ + bool has_erp_value; + u8 erp_value; +}; + +/* Parsed Information Elements */ +struct ieee802_11_elems { + u8 *ie_start; + size_t total_len; + + /* pointers to IEs */ + u8 *ssid; + u8 *supp_rates; + u8 *fh_params; + u8 *ds_params; + u8 *cf_params; + struct ieee80211_tim_ie *tim; + u8 *ibss_params; + u8 *challenge; + u8 *wpa; + u8 *rsn; + u8 *erp_info; + u8 *ext_supp_rates; + u8 *wmm_info; + u8 *wmm_param; + struct ieee80211_ht_cap *ht_cap_elem; + struct ieee80211_ht_info *ht_info_elem; + u8 *mesh_config; + u8 *mesh_id; + u8 *peer_link; + u8 *preq; + u8 *prep; + u8 *perr; + u8 *ch_switch_elem; + u8 *country_elem; + u8 *pwr_constr_elem; + u8 *quiet_elem; /* first quite element */ + u8 *timeout_int; + + /* length of them, respectively */ + u8 ssid_len; + u8 supp_rates_len; + u8 fh_params_len; + u8 ds_params_len; + u8 cf_params_len; + u8 tim_len; + u8 ibss_params_len; + u8 challenge_len; + u8 wpa_len; + u8 rsn_len; + u8 erp_info_len; + u8 ext_supp_rates_len; + u8 wmm_info_len; + u8 wmm_param_len; + u8 mesh_config_len; + u8 mesh_id_len; + u8 peer_link_len; + u8 preq_len; + u8 prep_len; + u8 perr_len; + u8 ch_switch_elem_len; + u8 country_elem_len; + u8 pwr_constr_elem_len; + u8 quiet_elem_len; + u8 num_of_quiet_elem; /* can be more the one */ + u8 timeout_int_len; +}; + +#endif + + +typedef struct _RT_INTEL_PROMISCUOUS_MODE_INFO { + bool bPromiscuousOn; + bool bFilterSourceStationFrame; +} RT_INTEL_PROMISCUOUS_MODE_INFO, *PRT_INTEL_PROMISCUOUS_MODE_INFO; + + +/*************** DRIVER STATUS *****/ +#define STATUS_SCANNING 0 +#define STATUS_SCAN_HW 1 +#define STATUS_SCAN_ABORTING 2 +#define STATUS_SETTING_CHAN 3 +/*************** DRIVER STATUS *****/ + +enum { + NO_USE = 0, + USED = 1, + HW_SEC = 2, + SW_SEC = 3, +}; + +enum { + LPS_IS_WAKE = 0, + LPS_IS_SLEEP = 1, + LPS_WAIT_NULL_DATA_SEND =2, +}; + +struct rtllib_device { + struct pci_dev *pdev; + struct net_device *dev; + struct rtllib_security sec; + + bool disable_mgnt_queue; + + unsigned long status; + short hwscan_ch_bk; + HT_EXTCHNL_OFFSET chan_offset_bk; + HT_CHANNEL_WIDTH bandwidth_bk; + u8 hwscan_sem_up; +#ifdef CONFIG_CFG_80211 + struct wireless_dev wdev; + struct rtl_regulatory regulatory; +#endif + u8 CntAfterLink; + + RT_OP_MODE OpMode; + + u8 VersionID; + /* The last AssocReq/Resp IEs */ + u8 *assocreq_ies, *assocresp_ies; + size_t assocreq_ies_len, assocresp_ies_len; + + bool b_customer_lenovo_id; + bool bForcedShowRxRate; + bool bForcedShowRateStill; + u8 SystemQueryDataRateCount; + bool bForcedBgMode; + bool bUseRAMask; + bool b1x1RecvCombine; + u8 RF_Type; + bool b1SSSupport; + + u8 hwsec_active; + bool is_silent_reset; + bool force_mic_error; + bool is_roaming; + bool ieee_up; + bool cannot_notify; + bool bSupportRemoteWakeUp; + RT_PS_MODE dot11PowerSaveMode; + bool actscanning; + bool FirstIe_InScan; + bool be_scan_inprogress; + bool beinretry; + RT_RF_POWER_STATE eRFPowerState; + RT_RF_CHANGE_SOURCE RfOffReason; + bool is_set_key; + bool wx_set_enc; + PRT_HIGH_THROUGHPUT pHTInfo; + spinlock_t bw_spinlock; + + spinlock_t reorder_spinlock; + u8 Regdot11HTOperationalRateSet[16]; + u8 Regdot11TxHTOperationalRateSet[16]; + u8 dot11HTOperationalRateSet[16]; + u8 RegHTSuppRateSet[16]; + u8 HTCurrentOperaRate; + u8 HTHighestOperaRate; + u8 MinSpaceCfg; + u8 MaxMssDensity; + u8 bTxDisableRateFallBack; + u8 bTxUseDriverAssingedRate; + u8 bTxEnableFwCalcDur; + atomic_t atm_chnlop; + atomic_t atm_swbw; + + struct list_head Tx_TS_Admit_List; + struct list_head Tx_TS_Pending_List; + struct list_head Tx_TS_Unused_List; + TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM]; + struct list_head Rx_TS_Admit_List; + struct list_head Rx_TS_Pending_List; + struct list_head Rx_TS_Unused_List; + RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM]; + RX_REORDER_ENTRY RxReorderEntry[128]; + struct list_head RxReorder_Unused_List; + u8 ForcedPriority; + + + /* Bookkeeping structures */ + struct net_device_stats stats; + struct rtllib_stats ieee_stats; + struct rtllib_softmac_stats softmac_stats; + + /* Probe / Beacon management */ + struct list_head network_free_list; + struct list_head network_list; +#ifdef RTL8192U + struct list_head network_bssid_free_list; + struct list_head network_bssid_list; +#endif + struct rtllib_network *networks; + int scans; + int scan_age; + + int iw_mode; /* operating mode (IW_MODE_*) */ + bool bNetPromiscuousMode; + RT_INTEL_PROMISCUOUS_MODE_INFO IntelPromiscuousModeInfo; + + struct iw_spy_data spy_data; + + spinlock_t lock; + spinlock_t wpax_suitlist_lock; + + int tx_headroom; /* Set to size of any additional room needed at front + * of allocated Tx SKBs */ + u32 config; + + /* WEP and other encryption related settings at the device level */ + int open_wep; /* Set to 1 to allow unencrypted frames */ + int auth_mode; + int reset_on_keychange; /* Set to 1 if the HW needs to be reset on + * WEP key changes */ + + /* If the host performs {en,de}cryption, then set to 1 */ + int host_encrypt; + int host_encrypt_msdu; + int host_decrypt; + /* host performs multicast decryption */ + int host_mc_decrypt; + + /* host should strip IV and ICV from protected frames */ + /* meaningful only when hardware decryption is being used */ + int host_strip_iv_icv; + + int host_open_frag; + int host_build_iv; + int ieee802_1x; /* is IEEE 802.1X used */ + + /* WPA data */ + bool bHalfNMode; + bool bHalfWirelessN24GMode; + int wpa_enabled; + int drop_unencrypted; + int tkip_countermeasures; + int privacy_invoked; + size_t wpa_ie_len; + u8 *wpa_ie; + size_t wps_ie_len; + u8 *wps_ie; + u8 ap_mac_addr[6]; + u16 pairwise_key_type; + u16 group_key_type; + struct list_head crypt_deinit_list; + struct rtllib_crypt_data *crypt[WEP_KEYS]; + + int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ + SW_CAM_TABLE swcamtable[TOTAL_CAM_ENTRY]; + struct timer_list crypt_deinit_timer; + int crypt_quiesced; + + int bcrx_sta_key; /* use individual keys to override default keys even + * with RX of broad/multicast frames */ + + RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE]; + + /* Fragmentation structures */ + struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN]; + unsigned int frag_next_idx[17]; + u16 fts; /* Fragmentation Threshold */ +#define DEFAULT_RTS_THRESHOLD 2346U +#define MIN_RTS_THRESHOLD 1 +#define MAX_RTS_THRESHOLD 2346U + u16 rts; /* RTS threshold */ + + /* Association info */ + u8 bssid[ETH_ALEN]; + + /* This stores infos for the current network. + * Either the network we are associated in INFRASTRUCTURE + * or the network that we are creating in MASTER mode. + * ad-hoc is a mixture ;-). + * Note that in infrastructure mode, even when not associated, + * fields bssid and essid may be valid (if wpa_set and essid_set + * are true) as thy carry the value set by the user via iwconfig + */ + struct rtllib_network current_network; + + enum rtllib_state state; + + int short_slot; + int reg_mode; + int mode; /* A, B, G */ + int modulation; /* CCK, OFDM */ + int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ + int abg_true; /* ABG flag */ + + /* used for forcing the ibss workqueue to terminate + * without wait for the syncro scan to terminate + */ + short sync_scan_hurryup; + u16 scan_watch_dog; + int perfect_rssi; + int worst_rssi; + + u16 prev_seq_ctl; /* used to drop duplicate frames */ + + /* map of allowed channels. 0 is dummy */ +#ifdef ENABLE_DOT11D + void* pDot11dInfo; + bool bGlobalDomain; +#else + u8 channel_map[MAX_CHANNEL_NUMBER+1]; +#endif + u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; + + u8 IbssStartChnl; + u8 ibss_maxjoin_chal; + + int rate; /* current rate */ + int basic_rate; + u32 currentRate; + + short active_scan; + + /* this contains flags for selectively enable softmac support */ + u16 softmac_features; + + /* if the sequence control field is not filled by HW */ + u16 seq_ctrl[5]; + + /* association procedure transaction sequence number */ + u16 associate_seq; + + /* AID for RTXed association responses */ + u16 assoc_id; + + /* power save mode related*/ + u8 ack_tx_to_ieee; + short ps; + short sta_sleep; + int ps_timeout; + int ps_period; + struct tasklet_struct ps_task; + u32 ps_th; + u32 ps_tl; + bool polling; + + short raw_tx; + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ + short queue_stop; + short scanning_continue ; + short proto_started; + short proto_stoppping; + + struct semaphore wx_sem; + struct semaphore scan_sem; + struct semaphore ips_sem; + + spinlock_t mgmt_tx_lock; + spinlock_t beacon_lock; + + short beacon_txing; + + short wap_set; + short ssid_set; + + /* set on initialization */ + u8 qos_support; + unsigned int wmm_acm; + + /* for discarding duplicated packets in IBSS */ + struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; + + /* for discarding duplicated packets in BSS */ + u16 last_rxseq_num[17]; /* rx seq previous per-tid */ + u16 last_rxfrag_num[17];/* tx frag previous per-tid */ + unsigned long last_packet_time[17]; + + /* for PS mode */ + unsigned long last_rx_ps_time; + bool bAwakePktSent; + u8 LPSDelayCnt; + + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ + struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; + int mgmt_queue_head; + int mgmt_queue_tail; +#define RTLLIB_QUEUE_LIMIT 128 + u8 AsocRetryCount; + unsigned int hw_header; + struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; + struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; + struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE]; + u32 sta_edca_param[4]; + bool aggregation; + bool enable_rx_imm_BA; + bool bibsscoordinator; + + bool bdynamic_txpower_enable; + + bool bCTSToSelfEnable; + u8 CTSToSelfTH; + + u32 fsync_time_interval; + u32 fsync_rate_bitmap; + u8 fsync_rssi_threshold; + bool bfsync_enable; + + u8 fsync_multiple_timeinterval; + u32 fsync_firstdiff_ratethreshold; + u32 fsync_seconddiff_ratethreshold; + Fsync_State fsync_state; + bool bis_any_nonbepkts; + bandwidth_autoswitch bandwidth_auto_switch; + bool FwRWRF; + + RT_LINK_DETECT_T LinkDetectInfo; + bool bIsAggregateFrame; + RT_POWER_SAVE_CONTROL PowerSaveControl; + u8 amsdu_in_process; + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ + struct tx_pending_t tx_pending; + + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ + struct timer_list associate_timer; + + /* used if IEEE_SOFTMAC_BEACONS is set */ + struct timer_list beacon_timer; + u8 need_sw_enc; + work_struct_rsl associate_complete_wq; + work_struct_rsl ips_leave_wq; + delayed_work_struct_rsl associate_procedure_wq; + delayed_work_struct_rsl softmac_scan_wq; + delayed_work_struct_rsl softmac_hint11d_wq; + delayed_work_struct_rsl associate_retry_wq; + delayed_work_struct_rsl start_ibss_wq; + delayed_work_struct_rsl hw_wakeup_wq; + delayed_work_struct_rsl hw_sleep_wq; + delayed_work_struct_rsl link_change_wq; + work_struct_rsl wx_sync_scan_wq; + + struct workqueue_struct *wq; + + /* Callback functions */ + void (*set_security)(struct net_device *dev, + struct rtllib_security *sec); + + /* Used to TX data frame by using txb structs. + * this is not used if in the softmac_features + * is set the flag IEEE_SOFTMAC_TX_QUEUE + */ + int (*hard_start_xmit)(struct rtllib_txb *txb, + struct net_device *dev); + + int (*reset_port)(struct net_device *dev); + int (*is_queue_full) (struct net_device * dev, int pri); + + int (*handle_management) (struct net_device * dev, + struct rtllib_network * network, u16 type); + int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that + * one might want to use for data and management frames + * the option to have two callbacks might be useful. + * This fucntion can't sleep. + */ + int (*softmac_hard_start_xmit)(struct sk_buff *skb, + struct net_device *dev); + + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) + * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data + * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set + * then also management frames are sent via this callback. + * This function can't sleep. + */ + void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, + struct net_device *dev,int rate); + + /* stops the HW queue for DATA frames. Useful to avoid + * waste time to TX data frame when we are reassociating + * This function can sleep. + */ + void (*data_hard_stop)(struct net_device *dev); + + /* OK this is complementar to data_poll_hard_stop */ + void (*data_hard_resume)(struct net_device *dev); + + /* ask to the driver to retune the radio . + * This function can sleep. the driver should ensure + * the radio has been swithced before return. + */ + void (*set_chan)(struct net_device *dev,short ch); + + /* These are not used if the ieee stack takes care of + * scanning (IEEE_SOFTMAC_SCAN feature set). + * In this case only the set_chan is used. + * + * The syncro version is similar to the start_scan but + * does not return until all channels has been scanned. + * this is called in user context and should sleep, + * it is called in a work_queue when swithcing to ad-hoc mode + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. + * the fucntion stop_scan should stop both the syncro and + * background scanning and can sleep. + * The fucntion start_scan should initiate the background + * scanning and can't sleep. + */ + void (*scan_syncro)(struct net_device *dev); + void (*start_scan)(struct net_device *dev); + void (*stop_scan)(struct net_device *dev); + + void (*rtllib_start_hw_scan)(struct net_device *dev); + void (*rtllib_stop_hw_scan)(struct net_device *dev); + + /* indicate the driver that the link state is changed + * for example it may indicate the card is associated now. + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led + */ + void (*link_change)(struct net_device *dev); + + /* these two function indicates to the HW when to start + * and stop to send beacons. This is used when the + * IEEE_SOFTMAC_BEACONS is not set. For now the + * stop_send_bacons is NOT guaranteed to be called only + * after start_send_beacons. + */ + void (*start_send_beacons) (struct net_device *dev); + void (*stop_send_beacons) (struct net_device *dev); + + /* power save mode related */ + void (*sta_wake_up) (struct net_device *dev); + void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); + short (*ps_is_queue_empty) (struct net_device *dev); + int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); + int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); + + + /* check whether Tx hw resouce available */ + short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); + short (*get_nic_desc_num)(struct net_device *dev, int queue_index); + void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); + bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); + void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); + bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); + u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); + void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); + void (*InitialGainHandler)(struct net_device *dev, u8 Operation); + bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO); + void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level); + void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start); + void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); + u16 (*rtl_11n_user_show_rates)(struct net_device *dev); + void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); + void (*LedControlHandler)(struct net_device * dev, LED_CTL_MODE LedAction); + void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); + void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); + + void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg); + + void (*rtllib_ips_leave_wq) (struct net_device *dev); + void (*rtllib_ips_leave)(struct net_device *dev); + void (*LeisurePSLeave)(struct net_device *dev); + void (*rtllib_rfkill_poll)(struct net_device *dev); + + /* This must be the last item so that it points to the data + * allocated beyond this structure by alloc_rtllib */ + u8 priv[0]; +}; + +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) +#define IEEE_N_24G (1<<4) +#define IEEE_N_5G (1<<5) +#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) + +/* Generate a 802.11 header */ + +/* Uses the channel change callback directly + * instead of [start/stop] scan callbacks + */ +#define IEEE_SOFTMAC_SCAN (1<<2) + +/* Perform authentication and association handshake */ +#define IEEE_SOFTMAC_ASSOCIATE (1<<3) + +/* Generate probe requests */ +#define IEEE_SOFTMAC_PROBERQ (1<<4) + +/* Generate respones to probe requests */ +#define IEEE_SOFTMAC_PROBERS (1<<5) + +/* The ieee802.11 stack will manages the netif queue + * wake/stop for the driver, taking care of 802.11 + * fragmentation. See softmac.c for details. */ +#define IEEE_SOFTMAC_TX_QUEUE (1<<7) + +/* Uses only the softmac_data_hard_start_xmit + * even for TX management frames. + */ +#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) + +/* Generate beacons. The stack will enqueue beacons + * to the card + */ +#define IEEE_SOFTMAC_BEACONS (1<<6) + + +static inline void *rtllib_priv(struct net_device *dev) +{ + return ((struct rtllib_device *)netdev_priv(dev))->priv; +} + +extern inline int rtllib_is_empty_essid(const char *essid, int essid_len) +{ + /* Single white space is for Linksys APs */ + if (essid_len == 1 && essid[0] == ' ') + return 1; + + /* Otherwise, if the entire essid is 0, we assume it is hidden */ + while (essid_len) { + essid_len--; + if (essid[essid_len] != '\0') + return 0; + } + + return 1; +} + +extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode) +{ + /* + * It is possible for both access points and our device to support + * combinations of modes, so as long as there is one valid combination + * of ap/device supported modes, then return success + * + */ + if ((mode & IEEE_A) && + (ieee->modulation & RTLLIB_OFDM_MODULATION) && + (ieee->freq_band & RTLLIB_52GHZ_BAND)) + return 1; + + if ((mode & IEEE_G) && + (ieee->modulation & RTLLIB_OFDM_MODULATION) && + (ieee->freq_band & RTLLIB_24GHZ_BAND)) + return 1; + + if ((mode & IEEE_B) && + (ieee->modulation & RTLLIB_CCK_MODULATION) && + (ieee->freq_band & RTLLIB_24GHZ_BAND)) + return 1; + + return 0; +} + +extern inline int rtllib_get_hdrlen(u16 fc) +{ + int hdrlen = RTLLIB_3ADDR_LEN; + + switch (WLAN_FC_GET_TYPE(fc)) { + case RTLLIB_FTYPE_DATA: + if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS)) + hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */ + if (RTLLIB_QOS_HAS_SEQ(fc)) + hdrlen += 2; /* QOS ctrl*/ + break; + case RTLLIB_FTYPE_CTL: + switch (WLAN_FC_GET_STYPE(fc)) { + case RTLLIB_STYPE_CTS: + case RTLLIB_STYPE_ACK: + hdrlen = RTLLIB_1ADDR_LEN; + break; + default: + hdrlen = RTLLIB_2ADDR_LEN; + break; + } + break; + } + + return hdrlen; +} + +static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr) +{ + switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { + case RTLLIB_1ADDR_LEN: + return ((struct rtllib_hdr_1addr *)hdr)->payload; + case RTLLIB_2ADDR_LEN: + return ((struct rtllib_hdr_2addr *)hdr)->payload; + case RTLLIB_3ADDR_LEN: + return ((struct rtllib_hdr_3addr *)hdr)->payload; + case RTLLIB_4ADDR_LEN: + return ((struct rtllib_hdr_4addr *)hdr)->payload; + } + return NULL; +} + +static inline int rtllib_is_ofdm_rate(u8 rate) +{ + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_OFDM_RATE_6MB: + case RTLLIB_OFDM_RATE_9MB: + case RTLLIB_OFDM_RATE_12MB: + case RTLLIB_OFDM_RATE_18MB: + case RTLLIB_OFDM_RATE_24MB: + case RTLLIB_OFDM_RATE_36MB: + case RTLLIB_OFDM_RATE_48MB: + case RTLLIB_OFDM_RATE_54MB: + return 1; + } + return 0; +} + +static inline int rtllib_is_cck_rate(u8 rate) +{ + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_CCK_RATE_1MB: + case RTLLIB_CCK_RATE_2MB: + case RTLLIB_CCK_RATE_5MB: + case RTLLIB_CCK_RATE_11MB: + return 1; + } + return 0; +} + + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2) +{ + const u16 *a = (const u16 *) addr1; + const u16 *b = (const u16 *) addr2; + + BUILD_BUG_ON(ETH_ALEN != 6); + return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; +} +#endif + +/* rtllib.c */ +extern void free_rtllib(struct net_device *dev); +extern struct net_device *alloc_rtllib(int sizeof_priv); + +extern int rtllib_set_encryption(struct rtllib_device *ieee); + +/* rtllib_tx.c */ + +extern int rtllib_encrypt_fragment( + struct rtllib_device *ieee, + struct sk_buff *frag, + int hdr_len); + +extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev); +extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev); +extern void rtllib_txb_free(struct rtllib_txb *); + +/* rtllib_rx.c */ +extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats); +extern void rtllib_rx_mgt(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *stats); +extern void rtllib_rx_probe_rq(struct rtllib_device *ieee, + struct sk_buff *skb); +extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel); + +/* rtllib_wx.c */ +extern int rtllib_wx_get_scan(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key); +extern int rtllib_wx_set_encode(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key); +extern int rtllib_wx_get_encode(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key); +#if WIRELESS_EXT >= 18 +extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data* wrqu, char *extra); +extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data* wrqu, char *extra); +#endif +extern int rtllib_wx_set_auth(struct rtllib_device *ieee, + struct iw_request_info *info, + struct iw_param *data, char *extra); +extern int rtllib_wx_set_mlme(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); +extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); + +/* rtllib_softmac.c */ +extern short rtllib_is_54g(struct rtllib_network *net); +extern short rtllib_is_shortslot(struct rtllib_network net); +extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype); +extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net); + +void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); +extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee); + +extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); +extern void notify_wx_assoc_event(struct rtllib_device *ieee); +extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee); +extern void rtllib_start_bss(struct rtllib_device *ieee); +extern void rtllib_start_master_bss(struct rtllib_device *ieee); +extern void rtllib_start_ibss(struct rtllib_device *ieee); +extern void rtllib_softmac_init(struct rtllib_device *ieee); +extern void rtllib_softmac_free(struct rtllib_device *ieee); +extern void rtllib_associate_abort(struct rtllib_device *ieee); +extern void rtllib_disassociate(struct rtllib_device *ieee); +extern void rtllib_stop_scan(struct rtllib_device *ieee); +extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan); +extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); +extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); +extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); +extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); +extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); +extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); +extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); +extern void rtllib_check_all_nets(struct rtllib_device *ieee); +extern void rtllib_start_protocol(struct rtllib_device *ieee); +extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); + +extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState); +extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState); +extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState); +extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState); +extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh); + +extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown); +extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag); + +extern void rtllib_reset_queue(struct rtllib_device *ieee); +extern void rtllib_wake_queue(struct rtllib_device *ieee); +extern void rtllib_stop_queue(struct rtllib_device *ieee); +extern void rtllib_wake_all_queues(struct rtllib_device *ieee); +extern void rtllib_stop_all_queues(struct rtllib_device *ieee); +extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); +extern void rtllib_start_send_beacons(struct rtllib_device *ieee); +extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); +extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh); + +extern void notify_wx_assoc_event(struct rtllib_device *ieee); +extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success); + +extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee); +extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst); +extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); + +/* rtllib_crypt_ccmp&tkip&wep.c */ +extern void rtllib_tkip_null(void); +extern void rtllib_wep_null(void); +extern void rtllib_ccmp_null(void); + +/* rtllib_softmac_wx.c */ + +extern int rtllib_wx_get_wap(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *ext); + +extern int rtllib_wx_set_wap(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra); + +extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int rtllib_wx_set_rate(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_get_rate(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b); + +extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b); + +extern int rtllib_wx_set_essid(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b); + +extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b); + +extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b); +extern void rtllib_wx_sync_scan_wq(void *data); + +extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_get_name(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_set_power(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_get_power(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_set_rts(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + +extern int rtllib_wx_get_rts(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); +#define MAX_RECEIVE_BUFFER_SIZE 9100 +extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); +extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); + +void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); +extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); +extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); +extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len); +extern void HTOnAssocRsp(struct rtllib_device *ieee); +extern void HTInitializeHTInfo(struct rtllib_device* ieee); +extern void HTInitializeBssDesc(PBSS_HT pBssHT); +extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); +extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); +extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); +extern u8 MCS_FILTER_ALL[]; +extern u16 MCS_DATA_RATE[2][2][77] ; +extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame); +extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); +extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee); +extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate); +extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate); +extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate); +extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); +extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); +extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); +extern void TsInitAddBA( struct rtllib_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); +extern void TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); +extern void BaSetupTimeOut(unsigned long data); +extern void TxBaInactTimeout(unsigned long data); +extern void RxBaInactTimeout(unsigned long data); +extern void ResetBaEntry( PBA_RECORD pBA); +extern bool GetTs( + struct rtllib_device* ieee, + PTS_COMMON_INFO *ppTS, + u8* Addr, + u8 TID, + TR_SELECT TxRxSelect, + bool bAddNewTs + ); +extern void TSInitialize(struct rtllib_device *ieee); +extern void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS); +extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr); +extern void RemoveAllTS(struct rtllib_device* ieee); +void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); + +extern const long rtllib_wlan_frequencies[]; + +extern inline void rtllib_increment_scans(struct rtllib_device *ieee) +{ + ieee->scans++; +} + +extern inline int rtllib_get_scans(struct rtllib_device *ieee) +{ + return ieee->scans; +} + +static inline const char *escape_essid(const char *essid, u8 essid_len) { + static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; + const char *s = essid; + char *d = escaped; + + if (rtllib_is_empty_essid(essid, essid_len)) { + memcpy(escaped, "", sizeof("")); + return escaped; + } + + essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE); + while (essid_len--) { + if (*s == '\0') { + *d++ = '\\'; + *d++ = '0'; + s++; + } else { + *d++ = *s++; + } + } + *d = '\0'; + return escaped; +} + +#define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE +#include #include #include #include #include #include -#include "ieee80211.h" +#include "rtllib.h" -//MODULE_AUTHOR("Jouni Malinen"); -//MODULE_DESCRIPTION("HostAP crypto"); -//MODULE_LICENSE("GPL"); - -struct ieee80211_crypto_alg { +struct rtllib_crypto_alg { struct list_head list; - struct ieee80211_crypto_ops *ops; + struct rtllib_crypto_ops *ops; }; -struct ieee80211_crypto { +struct rtllib_crypto { struct list_head algs; spinlock_t lock; }; -static struct ieee80211_crypto *hcrypt; +static struct rtllib_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void rtllib_crypt_deinit_entries(struct rtllib_device *ieee, int force) { struct list_head *ptr, *n; - struct ieee80211_crypt_data *entry; + struct rtllib_crypt_data *entry; for (ptr = ieee->crypt_deinit_list.next, n = ptr->next; ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) { - entry = list_entry(ptr, struct ieee80211_crypt_data, list); + entry = list_entry(ptr, struct rtllib_crypt_data, list); if (atomic_read(&entry->refcnt) != 0 && !force) continue; @@ -58,13 +54,13 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void rtllib_crypt_deinit_handler(unsigned long data) { - struct ieee80211_device *ieee = (struct ieee80211_device *)data; + struct rtllib_device *ieee = (struct rtllib_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + rtllib_crypt_deinit_entries(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -75,10 +71,10 @@ void ieee80211_crypt_deinit_handler(unsigned long data) } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, - struct ieee80211_crypt_data **crypt) +void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, + struct rtllib_crypt_data **crypt) { - struct ieee80211_crypt_data *tmp; + struct rtllib_crypt_data *tmp; unsigned long flags; if (*crypt == NULL) @@ -100,43 +96,44 @@ void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops) { unsigned long flags; - struct ieee80211_crypto_alg *alg; + struct rtllib_crypto_alg *alg; if (hcrypt == NULL) return -1; - alg = kzalloc(sizeof(*alg), GFP_KERNEL); + alg = kmalloc(sizeof(*alg), GFP_KERNEL); if (alg == NULL) return -ENOMEM; + memset(alg, 0, sizeof(*alg)); alg->ops = ops; spin_lock_irqsave(&hcrypt->lock, flags); list_add(&alg->list, &hcrypt->algs); spin_unlock_irqrestore(&hcrypt->lock, flags); - printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n", + printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n", ops->name); return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; - struct ieee80211_crypto_alg *del_alg = NULL; + struct rtllib_crypto_alg *del_alg = NULL; if (hcrypt == NULL) return -1; spin_lock_irqsave(&hcrypt->lock, flags); for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { - struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + struct rtllib_crypto_alg *alg = + (struct rtllib_crypto_alg *) ptr; if (alg->ops == ops) { list_del(&alg->list); del_alg = alg; @@ -146,7 +143,7 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) spin_unlock_irqrestore(&hcrypt->lock, flags); if (del_alg) { - printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm " + printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm " "'%s'\n", ops->name); kfree(del_alg); } @@ -155,19 +152,19 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name) { unsigned long flags; struct list_head *ptr; - struct ieee80211_crypto_alg *found_alg = NULL; + struct rtllib_crypto_alg *found_alg = NULL; if (hcrypt == NULL) return NULL; spin_lock_irqsave(&hcrypt->lock, flags); for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { - struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + struct rtllib_crypto_alg *alg = + (struct rtllib_crypto_alg *) ptr; if (strcmp(alg->ops->name, name) == 0) { found_alg = alg; break; @@ -182,13 +179,13 @@ struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * rtllib_crypt_null_init(int keyidx) { return (void *) 1; } +static void rtllib_crypt_null_deinit(void *priv) {} -static struct ieee80211_crypto_ops ieee80211_crypt_null = { +static struct rtllib_crypto_ops rtllib_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = rtllib_crypt_null_init, + .deinit = rtllib_crypt_null_deinit, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -201,18 +198,19 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = { }; -int __init ieee80211_crypto_init(void) +int __init rtllib_crypto_init(void) { int ret = -ENOMEM; - hcrypt = kzalloc(sizeof(*hcrypt), GFP_KERNEL); + hcrypt = kmalloc(sizeof(*hcrypt), GFP_KERNEL); if (!hcrypt) goto out; + memset(hcrypt, 0, sizeof(*hcrypt)); INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = rtllib_register_crypto_ops(&rtllib_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -222,7 +220,7 @@ out: } -void ieee80211_crypto_deinit(void) +void __exit rtllib_crypto_deinit(void) { struct list_head *ptr, *n; @@ -231,14 +229,13 @@ void ieee80211_crypto_deinit(void) for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs; ptr = n, n = ptr->next) { - struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + struct rtllib_crypto_alg *alg = + (struct rtllib_crypto_alg *) ptr; list_del(ptr); - printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm " + printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm " "'%s' (deinit)\n", alg->ops->name); kfree(alg); } kfree(hcrypt); } - diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h similarity index 72% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_crypt.h rename to drivers/staging/rtl8192e/rtllib_crypt.h index ca7dd0dda82..5f8990c2ae0 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -18,14 +18,14 @@ */ /* - * This file defines the interface to the ieee80211 crypto module. + * This file defines the interface to the rtllib crypto module. */ -#ifndef IEEE80211_CRYPT_H -#define IEEE80211_CRYPT_H +#ifndef RTLLIB_CRYPT_H +#define RTLLIB_CRYPT_H #include -struct ieee80211_crypto_ops { +struct rtllib_crypto_ops { const char *name; /* init new crypto context (e.g., allocate private data space, @@ -49,7 +49,7 @@ struct ieee80211_crypto_ops { * These can be NULL if full MSDU operations are not needed. */ int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv); int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len, - void *priv); + void *priv, struct rtllib_device* ieee); int (*set_key)(void *key, int len, u8 *seq, void *priv); int (*get_key)(void *key, int len, u8 *seq, void *priv); @@ -68,18 +68,26 @@ struct ieee80211_crypto_ops { struct module *owner; }; -struct ieee80211_crypt_data { +struct rtllib_crypt_data { struct list_head list; /* delayed deletion list */ - struct ieee80211_crypto_ops *ops; + struct rtllib_crypto_ops *ops; void *priv; atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, - struct ieee80211_crypt_data **crypt); +int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops); +int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops); +struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name); +void rtllib_crypt_deinit_entries(struct rtllib_device *, int); +void rtllib_crypt_deinit_handler(unsigned long); +void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, + struct rtllib_crypt_data **crypt); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31)) +#define crypto_alloc_tfm crypto_alloc_tfm_rsl +#define crypto_free_tfm crypto_free_tfm_rsl +#endif + #endif diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c similarity index 66% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_ccmp.c rename to drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 48267a058d1..80b56b4e60b 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -9,7 +9,7 @@ * more details. */ -//#include +#include #include #include #include @@ -20,19 +20,18 @@ #include #include #include +#include "rtllib.h" -#include "ieee80211.h" - +#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#include "rtl_crypto.h" +#else #include +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else #include - -MODULE_AUTHOR("Jouni Malinen"); -MODULE_DESCRIPTION("Host AP crypt: CCMP"); -MODULE_LICENSE("GPL"); - -#ifndef OPENSUSE_SLED -#define OPENSUSE_SLED 0 #endif #define AES_BLOCK_LEN 16 @@ -41,7 +40,7 @@ MODULE_LICENSE("GPL"); #define CCMP_TK_LEN 16 #define CCMP_PN_LEN 6 -struct ieee80211_ccmp_data { +struct rtllib_ccmp_data { u8 key[CCMP_TK_LEN]; int key_set; @@ -62,34 +61,68 @@ struct ieee80211_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + struct scatterlist src, dst; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + src.page = virt_to_page(pt); + src.offset = offset_in_page(pt); + src.length = AES_BLOCK_LEN; + + dst.page = virt_to_page(ct); + dst.offset = offset_in_page(ct); + dst.length = AES_BLOCK_LEN; + +#else + sg_init_one(&src, pt, AES_BLOCK_LEN); + sg_init_one(&dst, ct, AES_BLOCK_LEN); +#endif + + crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); +#else crypto_cipher_encrypt_one((void*)tfm, ct, pt); +#endif } -static void * ieee80211_ccmp_init(int key_idx) +static void * rtllib_ccmp_init(int key_idx) { - struct ieee80211_ccmp_data *priv; + struct rtllib_ccmp_data *priv; - priv = kzalloc(sizeof(*priv), GFP_ATOMIC); + priv = kmalloc(sizeof(*priv), GFP_ATOMIC); if (priv == NULL) goto fail; + memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + priv->tfm = crypto_alloc_tfm("aes", 0); + if (priv->tfm == NULL) { + printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " + "crypto API aes\n"); + goto fail; + } + #else priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { - printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " "crypto API aes\n"); priv->tfm = NULL; goto fail; } + #endif return priv; fail: if (priv) { if (priv->tfm) + #if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + crypto_free_tfm(priv->tfm); + #else crypto_free_cipher((void*)priv->tfm); + #endif kfree(priv); } @@ -97,11 +130,15 @@ fail: } -static void ieee80211_ccmp_deinit(void *priv) +static void rtllib_ccmp_deinit(void *priv) { - struct ieee80211_ccmp_data *_priv = priv; + struct rtllib_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + crypto_free_tfm(_priv->tfm); +#else crypto_free_cipher((void*)_priv->tfm); +#endif kfree(priv); } @@ -116,7 +153,7 @@ static inline void xor_block(u8 *b, u8 *a, size_t len) static void ccmp_init_blocks(struct crypto_tfm *tfm, - struct ieee80211_hdr_4addr *hdr, + struct rtllib_hdr_4addr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) { @@ -127,14 +164,13 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, u8 aad[2 * AES_BLOCK_LEN]; fc = le16_to_cpu(hdr->frame_ctl); - a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == - (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)); + a4_included = ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) == + (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)); /* - qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) && + qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x08)); */ - // fixed by David :2006.9.6 - qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) && + qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x80)); aad_len = 22; if (a4_included) @@ -183,26 +219,25 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); + rtllib_ccmp_aes_encrypt(tfm, b0, auth); xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + rtllib_ccmp_aes_encrypt(tfm, auth, auth); xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + rtllib_ccmp_aes_encrypt(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + rtllib_ccmp_aes_encrypt(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) { - struct ieee80211_ccmp_data *key = priv; + struct rtllib_ccmp_data *key = priv; int data_len, i; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - if (skb_headroom(skb) < CCMP_HDR_LEN || skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) @@ -212,7 +247,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) pos = skb_push(skb, CCMP_HDR_LEN); memmove(pos, pos + CCMP_HDR_LEN, hdr_len); pos += hdr_len; -// mic = skb_put(skb, CCMP_MIC_LEN); i = CCMP_PN_LEN - 1; while (i >= 0) { @@ -232,9 +266,8 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = key->tx_pn[0]; - hdr = (struct ieee80211_hdr_4addr *) skb->data; - if (!tcb_desc->bHwSec) - { + hdr = (struct rtllib_hdr_4addr *) skb->data; + if (!tcb_desc->bHwSec) { int blocks, last, len; u8 *mic; u8 *b0 = key->tx_b0; @@ -242,7 +275,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 *e = key->tx_e; u8 *s0 = key->tx_s0; - //mic is moved to here by john mic = skb_put(skb, CCMP_MIC_LEN); ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); @@ -254,11 +286,11 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + rtllib_ccmp_aes_encrypt(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); + rtllib_ccmp_aes_encrypt(key->tfm, b0, e); xor_block(pos, e, len); pos += len; } @@ -270,11 +302,11 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) { - struct ieee80211_ccmp_data *key = priv; + struct rtllib_ccmp_data *key = priv; u8 keyidx, *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 pn[6]; @@ -283,13 +315,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtllib_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from %pM\n", hdr->addr2); + " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; @@ -302,9 +334,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from %pM" + printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT " with keyid=%d that does not have a configured" - " key\n", hdr->addr2, keyidx); + " key\n", MAC_ARG(hdr->addr2), keyidx); } return -3; } @@ -316,13 +348,11 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) pn[4] = pos[1]; pn[5] = pos[0]; pos += 8; - if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) { key->dot11RSNAStatsCCMPReplays++; return -4; } - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; u8 *b0 = key->rx_b0; @@ -342,18 +372,18 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); + rtllib_ccmp_aes_encrypt(key->tfm, b0, b); xor_block(pos, b, len); /* Authentication */ xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + rtllib_ccmp_aes_encrypt(key->tfm, a, a); pos += len; } if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - "%pM\n", hdr->addr2); + MAC_FMT "\n", MAC_ARG(hdr->addr2)); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -370,9 +400,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) { - struct ieee80211_ccmp_data *data = priv; + struct rtllib_ccmp_data *data = priv; int keyidx; struct crypto_tfm *tfm = data->tfm; @@ -401,9 +431,9 @@ static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) { - struct ieee80211_ccmp_data *data = priv; + struct rtllib_ccmp_data *data = priv; if (len < CCMP_TK_LEN) return -1; @@ -425,22 +455,15 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * rtllib_ccmp_print_stats(char *p, void *priv) { - struct ieee80211_ccmp_data *ccmp = priv; - int i; - - p += sprintf(p, "key[%d] alg=CCMP key_set=%d tx_pn=", - ccmp->key_idx, ccmp->key_set); - - for (i = 0; i < ARRAY_SIZE(ccmp->tx_pn); i++) - p += sprintf(p, "%02x", ccmp->tx_pn[i]); - - sprintf(p, " rx_pn="); - for (i = 0; i < ARRAY_SIZE(ccmp->rx_pn); i++) - p += sprintf(p, "%02x", ccmp->tx_pn[i]); - - p += sprintf(p, " format_errors=%d replays=%d decrypt_errors=%d\n", + struct rtllib_ccmp_data *ccmp = priv; + p += sprintf(p, "key[%d] alg=CCMP key_set=%d " + "tx_pn=%02x%02x%02x%02x%02x%02x " + "rx_pn=%02x%02x%02x%02x%02x%02x " + "format_errors=%d replays=%d decrypt_errors=%d\n", + ccmp->key_idx, ccmp->key_set, + MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn), ccmp->dot11RSNAStatsCCMPFormatErrors, ccmp->dot11RSNAStatsCCMPReplays, ccmp->dot11RSNAStatsCCMPDecryptErrors); @@ -448,36 +471,35 @@ static char * ieee80211_ccmp_print_stats(char *p, void *priv) return p; } -void ieee80211_ccmp_null(void) +void rtllib_ccmp_null(void) { return; } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct rtllib_crypto_ops rtllib_crypt_ccmp = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = rtllib_ccmp_init, + .deinit = rtllib_ccmp_deinit, + .encrypt_mpdu = rtllib_ccmp_encrypt, + .decrypt_mpdu = rtllib_ccmp_decrypt, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = rtllib_ccmp_set_key, + .get_key = rtllib_ccmp_get_key, + .print_stats = rtllib_ccmp_print_stats, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -int __init ieee80211_crypto_ccmp_init(void) +int __init rtllib_crypto_ccmp_init(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return rtllib_register_crypto_ops(&rtllib_crypt_ccmp); } -void ieee80211_crypto_ccmp_exit(void) +void __exit rtllib_crypto_ccmp_exit(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + rtllib_unregister_crypto_ops(&rtllib_crypt_ccmp); } - diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c similarity index 61% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c rename to drivers/staging/rtl8192e/rtllib_crypt_tkip.c index ed623a911e4..ad9a62f4c39 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -9,7 +9,7 @@ * more details. */ -//#include +#include #include #include #include @@ -19,24 +19,23 @@ #include #include #include - -#include "ieee80211.h" +#include "rtllib.h" +#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#include "rtl_crypto.h" +#else #include -#include +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -MODULE_AUTHOR("Jouni Malinen"); -MODULE_DESCRIPTION("Host AP crypt: TKIP"); -MODULE_LICENSE("GPL"); - -#ifndef OPENSUSE_SLED -#define OPENSUSE_SLED 0 -#endif - -struct ieee80211_tkip_data { +struct rtllib_tkip_data { #define TKIP_KEY_LEN 32 u8 key[TKIP_KEY_LEN]; int key_set; @@ -48,6 +47,7 @@ struct ieee80211_tkip_data { u32 rx_iv32; u16 rx_iv16; + bool initialized; u16 rx_ttak[5]; int rx_phase1_done; u32 rx_iv32_new; @@ -58,26 +58,63 @@ struct ieee80211_tkip_data { u32 dot11RSNAStatsTKIPLocalMICFailures; int key_idx; +#if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct crypto_blkcipher *rx_tfm_arc4; struct crypto_hash *rx_tfm_michael; struct crypto_blkcipher *tx_tfm_arc4; struct crypto_hash *tx_tfm_michael; +#else + struct crypto_tfm *tx_tfm_arc4; + struct crypto_tfm *tx_tfm_michael; + struct crypto_tfm *rx_tfm_arc4; + struct crypto_tfm *rx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * rtllib_tkip_init(int key_idx) { - struct ieee80211_tkip_data *priv; + struct rtllib_tkip_data *priv; - priv = kzalloc(sizeof(*priv), GFP_ATOMIC); + priv = kmalloc(sizeof(*priv), GFP_ATOMIC); if (priv == NULL) goto fail; + memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); + if (priv->tx_tfm_arc4 == NULL) { + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " + "crypto API arc4\n"); + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); + if (priv->tx_tfm_michael == NULL) { + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); + if (priv->rx_tfm_arc4 == NULL) { + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " + "crypto API arc4\n"); + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); + if (priv->rx_tfm_michael == NULL) { + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + goto fail; + } +#else priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_arc4)) { - printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " "crypto API arc4\n"); priv->tx_tfm_arc4 = NULL; goto fail; @@ -86,7 +123,7 @@ static void * ieee80211_tkip_init(int key_idx) priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_michael)) { - printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " "crypto API michael_mic\n"); priv->tx_tfm_michael = NULL; goto fail; @@ -95,7 +132,7 @@ static void * ieee80211_tkip_init(int key_idx) priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->rx_tfm_arc4)) { - printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " "crypto API arc4\n"); priv->rx_tfm_arc4 = NULL; goto fail; @@ -104,15 +141,27 @@ static void * ieee80211_tkip_init(int key_idx) priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->rx_tfm_michael)) { - printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " "crypto API michael_mic\n"); priv->rx_tfm_michael = NULL; goto fail; } +#endif return priv; fail: if (priv) { +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + if (priv->tx_tfm_michael) + crypto_free_tfm(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_tfm(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_tfm(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_tfm(priv->rx_tfm_arc4); + +#else if (priv->tx_tfm_michael) crypto_free_hash(priv->tx_tfm_michael); if (priv->tx_tfm_arc4) @@ -121,6 +170,7 @@ fail: crypto_free_hash(priv->rx_tfm_michael); if (priv->rx_tfm_arc4) crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -128,9 +178,19 @@ fail: } -static void ieee80211_tkip_deinit(void *priv) +static void rtllib_tkip_deinit(void *priv) { - struct ieee80211_tkip_data *_priv = priv; + struct rtllib_tkip_data *_priv = priv; +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + if (_priv->tx_tfm_michael) + crypto_free_tfm(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_tfm(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_tfm(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_tfm(_priv->rx_tfm_arc4); +#else if (_priv) { if (_priv->tx_tfm_michael) crypto_free_hash(_priv->tx_tfm_michael); @@ -141,6 +201,7 @@ static void ieee80211_tkip_deinit(void *priv) if (_priv->rx_tfm_arc4) crypto_free_blkcipher(_priv->rx_tfm_arc4); } +#endif kfree(priv); } @@ -303,16 +364,18 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; int len; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; + #endif u8 rc4key[16], *icv; u32 crc; struct scatterlist sg; @@ -321,18 +384,16 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) skb->len < hdr_len) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtllib_hdr_4addr *) skb->data; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { if (!tkey->tx_phase1_done) { tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); - } - else + } else tkey->tx_phase1_done = 1; @@ -341,14 +402,11 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) memmove(pos, pos + 8, hdr_len); pos += hdr_len; - if (tcb_desc->bHwSec) - { + if (tcb_desc->bHwSec) { *pos++ = Hi8(tkey->tx_iv16); *pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F; *pos++ = Lo8(tkey->tx_iv16); - } - else - { + } else { *pos++ = rc4key[0]; *pos++ = rc4key[1]; *pos++ = rc4key[2]; @@ -360,17 +418,30 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = (tkey->tx_iv32 >> 16) & 0xff; *pos++ = (tkey->tx_iv32 >> 24) & 0xff; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { icv = skb_put(skb, 4); crc = ~crc32_le(~0, pos, len); icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; icv[3] = crc >> 24; - crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + sg.page = virt_to_page(pos); + sg.offset = offset_in_page(pos); + sg.length = len + 4; +#else sg_init_one(&sg, pos, len+4); +#endif + + +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); + crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -381,22 +452,28 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tcb_desc->bHwSec) + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + return 0; + #else return ret; + #endif else - return 0; + return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; u8 keyidx, *pos; u32 iv32; u16 iv16; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; + #endif u8 rc4key[16]; u8 icv[4]; u32 crc; @@ -405,13 +482,13 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (skb->len < hdr_len + 8 + 4) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtllib_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: received packet without ExtIV" - " flag from %pM\n", hdr->addr2); + " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); } return -2; } @@ -423,9 +500,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: received packet from %pM" + printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT " with keyid=%d that does not have a configured" - " key\n", hdr->addr2, keyidx); + " key\n", MAC_ARG(hdr->addr2), keyidx); } return -3; } @@ -433,19 +510,20 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); pos += 8; - if (!tcb_desc->bHwSec) + if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) { - if (iv32 < tkey->rx_iv32 || - (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) { + if ((iv32 < tkey->rx_iv32 || + (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16))&&tkey->initialized) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: replay detected: STA=%pM" + printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT " previous TSC %08x%04x received TSC " - "%08x%04x\n", hdr->addr2, + "%08x%04x\n", MAC_ARG(hdr->addr2), tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; return -4; } + tkey->initialized = true; if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); @@ -455,18 +533,34 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) plen = skb->len - hdr_len - 12; - crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + sg.page = virt_to_page(pos); + sg.offset = offset_in_page(pos); + sg.length = plen + 4; +#else sg_init_one(&sg, pos, plen+4); +#endif + +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); + crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from %pM\n", - hdr->addr2); + "received packet from " MAC_FMT "\n", + MAC_ARG(hdr->addr2)); } return -7; } +#endif + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, plen); + #else + crc = ~ether_crc_le(plen, pos); + #endif icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; @@ -479,9 +573,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->rx_phase1_done = 0; } if (net_ratelimit()) { - printk(KERN_DEBUG - "TKIP: ICV error detected: STA=%pM\n", - hdr->addr2); + printk(KERN_DEBUG "TKIP: ICV error detected: STA=" + MAC_FMT "\n", MAC_ARG(hdr->addr2)); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -499,10 +592,66 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) skb_pull(skb, 8); skb_trim(skb, skb->len - 4); +#ifdef JOHN_DUMP +if ( ((u16*)skb->data)[0] & 0x4000){ + printk("@@ rx decrypted skb->data"); + int i; + for (i = 0; i < skb->len; i++) { + if ( (i%24)==0 ) printk("\n"); + printk("%2x ", ((u8*)skb->data)[i]); + } + printk("\n"); +} +#endif /*JOHN_DUMP*/ return keyidx; } +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) +static int michael_mic(struct crypto_tfm * tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct scatterlist sg[2]; +#if ( !defined(BUILT_IN_CRYPTO) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) ) + struct hash_desc desc; + int ret = 0; +#endif + + if (tfm_michael == NULL){ + printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); + return -1; + } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) + sg[0].page = virt_to_page(hdr); + sg[0].offset = offset_in_page(hdr); + sg[0].length = 16; + + sg[1].page = virt_to_page(data); + sg[1].offset = offset_in_page(data); + sg[1].length = data_len; +#else + sg_init_table(sg, 2); + sg_set_buf(&sg[0], hdr, 16); + sg_set_buf(&sg[1], data, data_len); +#endif + +#if ( defined(BUILT_IN_CRYPTO) || LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) ) + crypto_digest_init(tfm_michael); + crypto_digest_setkey(tfm_michael, key, 8); + crypto_digest_update(tfm_michael, sg, 2); + crypto_digest_final(tfm_michael, mic); + return 0; +#else +if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; + + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); + return ret; +#endif +} +#else static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, u8 * data, size_t data_len, u8 * mic) { @@ -513,9 +662,19 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) + sg[0].page = virt_to_page(hdr); + sg[0].offset = offset_in_page(hdr); + sg[0].length = 16; + + sg[1].page = virt_to_page(data); + sg[1].offset = offset_in_page(data); + sg[1].length = data_len; +#else sg_init_table(sg, 2); sg_set_buf(&sg[0], hdr, 16); sg_set_buf(&sg[1], data, data_len); +#endif if (crypto_hash_setkey(tfm_michael, key, 8)) return -1; @@ -524,25 +683,26 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, desc.flags = 0; return crypto_hash_digest(&desc, sg, data_len + 16, mic); } +#endif static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) { - struct ieee80211_hdr_4addr *hdr11; + struct rtllib_hdr_4addr *hdr11; - hdr11 = (struct ieee80211_hdr_4addr *) skb->data; + hdr11 = (struct rtllib_hdr_4addr *) skb->data; switch (le16_to_cpu(hdr11->frame_ctl) & - (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { - case IEEE80211_FCTL_TODS: + (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { + case RTLLIB_FCTL_TODS: memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ break; - case IEEE80211_FCTL_FROMDS: + case RTLLIB_FCTL_FROMDS: memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ break; - case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ break; @@ -558,13 +718,13 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtllib_hdr_4addr *) skb->data; if (skb_tailroom(skb) < 8 || skb->len < hdr_len) { printk(KERN_DEBUG "Invalid packet for Michael MIC add " @@ -575,15 +735,17 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri michael_mic_hdr(skb, tkey->tx_hdr); - // { david, 2006.9.1 - // fix the wpa process with wmm enabled. - if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } - // } pos = skb_put(skb, 8); +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) +#else + if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) +#endif return -1; return 0; @@ -591,8 +753,8 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr_4addr *hdr, +static void rtllib_michael_mic_failure(struct net_device *dev, + struct rtllib_hdr_4addr *hdr, int keyidx) { union iwreq_data wrqu; @@ -612,8 +774,8 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr_4addr *hdr, +static void rtllib_michael_mic_failure(struct net_device *dev, + struct rtllib_hdr_4addr *hdr, int keyidx) { union iwreq_data wrqu; @@ -621,53 +783,61 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, /* TODO: needed parameters: count, keyid, key type, TSC */ sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" - "%pM)", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni", - hdr->addr2); + MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni", + MAC_ARG(hdr->addr2)); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = strlen(buf); wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr_4addr *hdr, +static inline void rtllib_michael_mic_failure(struct net_device *dev, + struct rtllib_hdr_4addr *hdr, int keyidx) { } #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv) +static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, + int hdr_len, void *priv, struct rtllib_device* ieee) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; u8 mic[8]; - struct ieee80211_hdr_4addr *hdr; + struct rtllib_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtllib_hdr_4addr *) skb->data; if (!tkey->key_set) return -1; michael_mic_hdr(skb, tkey->rx_hdr); - // { david, 2006.9.1 - // fix the wpa process with wmm enabled. - if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } - // } +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) - return -1; - if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { - struct ieee80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; +#else + if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) +#endif + return -1; + + if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { + struct rtllib_hdr_4addr *hdr; + hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " - "MSDU from %pM keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", hdr->addr2, + "MSDU from " MAC_FMT " keyidx=%d\n", + skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); - if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + printk("%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ + ieee->force_mic_error); + if (skb->dev) { + printk("skb->dev != NULL\n"); + rtllib_michael_mic_failure(skb->dev, hdr, keyidx); + } tkey->dot11RSNAStatsTKIPLocalMICFailures++; + ieee->force_mic_error = false; return -1; } @@ -682,22 +852,36 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int rtllib_tkip_set_key(void *key, int len, u8 *seq, void *priv) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; int keyidx; +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + struct crypto_tfm *tfm = tkey->tx_tfm_michael; + struct crypto_tfm *tfm2 = tkey->tx_tfm_arc4; + struct crypto_tfm *tfm3 = tkey->rx_tfm_michael; + struct crypto_tfm *tfm4 = tkey->rx_tfm_arc4; +#else struct crypto_hash *tfm = tkey->tx_tfm_michael; struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; struct crypto_hash *tfm3 = tkey->rx_tfm_michael; struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) tkey->tx_tfm_michael = tfm; tkey->tx_tfm_arc4 = tfm2; tkey->rx_tfm_michael = tfm3; tkey->rx_tfm_arc4 = tfm4; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); @@ -717,9 +901,9 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv) { - struct ieee80211_tkip_data *tkey = priv; + struct rtllib_tkip_data *tkey = priv; if (len < TKIP_KEY_LEN) return -1; @@ -747,9 +931,9 @@ static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * rtllib_tkip_print_stats(char *p, void *priv) { - struct ieee80211_tkip_data *tkip = priv; + struct rtllib_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " "tx_pn=%02x%02x%02x%02x%02x%02x " "rx_pn=%02x%02x%02x%02x%02x%02x " @@ -774,36 +958,35 @@ static char * ieee80211_tkip_print_stats(char *p, void *priv) } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct rtllib_crypto_ops rtllib_crypt_tkip = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = rtllib_tkip_init, + .deinit = rtllib_tkip_deinit, + .encrypt_mpdu = rtllib_tkip_encrypt, + .decrypt_mpdu = rtllib_tkip_decrypt, + .encrypt_msdu = rtllib_michael_mic_add, + .decrypt_msdu = rtllib_michael_mic_verify, + .set_key = rtllib_tkip_set_key, + .get_key = rtllib_tkip_get_key, + .print_stats = rtllib_tkip_print_stats, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -int __init ieee80211_crypto_tkip_init(void) +int __init rtllib_crypto_tkip_init(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return rtllib_register_crypto_ops(&rtllib_crypt_tkip); } -void ieee80211_crypto_tkip_exit(void) +void __exit rtllib_crypto_tkip_exit(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + rtllib_unregister_crypto_ops(&rtllib_crypt_tkip); } -void ieee80211_tkip_null(void) +void rtllib_tkip_null(void) { return; } - diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c similarity index 67% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c rename to drivers/staging/rtl8192e/rtllib_crypt_wep.c index 55043913afc..38679223fa5 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -9,36 +9,53 @@ * more details. */ +#include #include #include #include #include #include #include +#include "rtllib.h" -#include "ieee80211.h" - - -#include - -#include -#include - -MODULE_AUTHOR("Jouni Malinen"); -MODULE_DESCRIPTION("Host AP crypt: WEP"); -MODULE_LICENSE("GPL"); -#ifndef OPENSUSE_SLED -#define OPENSUSE_SLED 0 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)) #endif + +#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#include "rtl_crypto.h" +#else +#include +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif +#include +/* +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +#include "rtl_crypto.h" +#else +#include +#endif + +#include +#include +*/ struct prism2_wep_data { u32 iv; #define WEP_KEY_LEN 13 u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + struct crypto_tfm *tfm; + #else struct crypto_blkcipher *tx_tfm; struct crypto_blkcipher *rx_tfm; + #endif }; @@ -46,25 +63,35 @@ static void * prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; - priv = kzalloc(sizeof(*priv), GFP_ATOMIC); + priv = kmalloc(sizeof(*priv), GFP_ATOMIC); if (priv == NULL) goto fail; + memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + priv->tfm = crypto_alloc_tfm("arc4", 0); + if (priv->tfm == NULL) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + goto fail; + } + #else priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm)) { - printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " "crypto API arc4\n"); priv->tx_tfm = NULL; goto fail; } priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->rx_tfm)) { - printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " "crypto API arc4\n"); priv->rx_tfm = NULL; goto fail; } + #endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -72,6 +99,13 @@ static void * prism2_wep_init(int keyidx) return priv; fail: + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + if (priv) { + if (priv->tfm) + crypto_free_tfm(priv->tfm); + kfree(priv); + } + #else if (priv) { if (priv->tx_tfm) crypto_free_blkcipher(priv->tx_tfm); @@ -79,6 +113,7 @@ fail: crypto_free_blkcipher(priv->rx_tfm); kfree(priv); } + #endif return NULL; } @@ -86,12 +121,17 @@ fail: static void prism2_wep_deinit(void *priv) { struct prism2_wep_data *_priv = priv; + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + if (_priv && _priv->tfm) + crypto_free_tfm(_priv->tfm); + #else if (_priv) { if (_priv->tx_tfm) crypto_free_blkcipher(_priv->tx_tfm); if (_priv->rx_tfm) crypto_free_blkcipher(_priv->rx_tfm); } + #endif kfree(priv); } @@ -108,14 +148,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 key[WEP_KEY_LEN + 3]; u8 *pos; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; + #endif u32 crc; u8 *icv; struct scatterlist sg; if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || - skb->len < hdr_len) + skb->len < hdr_len){ + printk("Error!!!headroom=%d tailroom=%d skblen=%d hdr_len=%d\n",skb_headroom(skb),skb_tailroom(skb),skb->len,hdr_len); return -1; - + } len = skb->len - hdr_len; pos = skb_push(skb, 4); memmove(pos, pos + 4, hdr_len); @@ -147,16 +190,32 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) { /* Append little-endian CRC32 and encrypt it to produce ICV */ + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, len); + #else + crc = ~ether_crc_le(len, pos); + #endif icv = skb_put(skb, 4); icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; icv[3] = crc >> 24; - crypto_blkcipher_setkey(wep->tx_tfm, key, klen); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + sg.page = virt_to_page(pos); + sg.offset = offset_in_page(pos); + sg.length = len + 4; + #else sg_init_one(&sg, pos, len+4); + #endif + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + crypto_cipher_setkey(wep->tfm, key, klen); + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); + return 0; + #else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); + #endif } return 0; @@ -177,7 +236,9 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; + #endif u32 crc; u8 icv[4]; struct scatterlist sg; @@ -202,11 +263,26 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!tcb_desc->bHwSec) { - crypto_blkcipher_setkey(wep->rx_tfm, key, klen); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + sg.page = virt_to_page(pos); + sg.offset = offset_in_page(pos); + sg.length = plen + 4; + #else sg_init_one(&sg, pos, plen+4); + #endif + #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) + crypto_cipher_setkey(wep->tfm, key, klen); + crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); + #else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) return -7; + #endif + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, plen); + #else + crc = ~ether_crc_le(plen, pos); + #endif icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; @@ -261,7 +337,7 @@ static char * prism2_wep_print_stats(char *p, void *priv) } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct rtllib_crypto_ops rtllib_crypt_wep = { .name = "WEP", .init = prism2_wep_init, .deinit = prism2_wep_deinit, @@ -278,19 +354,18 @@ static struct ieee80211_crypto_ops ieee80211_crypt_wep = { }; -int __init ieee80211_crypto_wep_init(void) +int __init rtllib_crypto_wep_init(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return rtllib_register_crypto_ops(&rtllib_crypt_wep); } -void __exit ieee80211_crypto_wep_exit(void) +void __exit rtllib_crypto_wep_exit(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + rtllib_unregister_crypto_ops(&rtllib_crypt_wep); } -void ieee80211_wep_null(void) +void rtllib_wep_null(void) { return; } - diff --git a/drivers/staging/rtl8192e/rtllib_endianfree.h b/drivers/staging/rtl8192e/rtllib_endianfree.h new file mode 100644 index 00000000000..46d8f196248 --- /dev/null +++ b/drivers/staging/rtl8192e/rtllib_endianfree.h @@ -0,0 +1,156 @@ +#ifndef __INC_ENDIANFREE_H +#define __INC_ENDIANFREE_H + +/* + * Call endian free function when + * 1. Read/write packet content. + * 2. Before write integer to IO. + * 3. After read integer from IO. + */ + +#define __MACHINE_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define __MACHINE_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net, ppc */ + +#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN + +#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) ((u16)(_val)) +#define EF4Byte(_val) ((u32)(_val)) + +#else +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) +#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8)|\ + ((((u32)(_val))&0x00ff0000)>>8)|\ + ((((u32)(_val))&0xff000000)>>24)) +#endif + +#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr))) +#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr))) +#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr))) + +#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val) +#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val) +#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val) +#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN +#define H2N1BYTE(_val) ((u8)(_val)) +#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ + ((((u16)(_val))&0xff00)>>8)) +#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8) |\ + ((((u32)(_val))&0x00ff0000)>>8) |\ + ((((u32)(_val))&0xff000000)>>24)) +#else +#define H2N1BYTE(_val) ((u8)(_val)) +#define H2N2BYTE(_val) ((u16)(_val)) +#define H2N4BYTE(_val) ((u32)(_val)) +#endif + +#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN +#define N2H1BYTE(_val) ((u8)(_val)) +#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ + ((((u16)(_val))&0xff00)>>8)) +#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8) |\ + ((((u32)(_val))&0x00ff0000)>>8) |\ + ((((u32)(_val))&0xff000000)>>24)) +#else +#define N2H1BYTE(_val) ((u8)(_val)) +#define N2H2BYTE(_val) ((u16)(_val)) +#define N2H4BYTE(_val) ((u32)(_val)) +#endif + +#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen))) +#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) + +#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart)))) + +#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \ + & \ + BIT_LEN_MASK_32(__BitLen) \ + ) + +#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + LE_P4BYTE_TO_HOST_4BYTE(__pStart) \ + & \ + ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \ + ) + +#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u32 *)(__pStart)) = \ + EF4Byte( \ + LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ + | \ + ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \ + ); + + +#define BIT_LEN_MASK_16(__BitLen) \ + (0xFFFF >> (16 - (__BitLen))) + +#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \ + (BIT_LEN_MASK_16(__BitLen) << (__BitOffset)) + +#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ + (EF2Byte(*((u16 *)(__pStart)))) + +#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \ + & \ + BIT_LEN_MASK_16(__BitLen) \ + ) + +#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ + & \ + ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \ + ) + +#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u16 *)(__pStart)) = \ + EF2Byte( \ + LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ + | \ + ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \ + ); + +#define BIT_LEN_MASK_8(__BitLen) \ + (0xFF >> (8 - (__BitLen))) + +#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \ + (BIT_LEN_MASK_8(__BitLen) << (__BitOffset)) + +#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ + (EF1Byte(*((u8 *)(__pStart)))) + +#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \ + & \ + BIT_LEN_MASK_8(__BitLen) \ + ) + +#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ + ( \ + LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ + & \ + ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \ + ) + +#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u8 *)(__pStart)) = \ + EF1Byte( \ + LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ + | \ + ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \ + ); + +#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment)) +#endif diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c new file mode 100644 index 00000000000..5373de60ab0 --- /dev/null +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -0,0 +1,374 @@ +/******************************************************************************* + + Copyright(c) 2004 Intel Corporation. All rights reserved. + + Portions of this file are based on the WEP enablement code provided by the + Host AP project hostap-drivers v0.1.3 + Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen + + Copyright (c) 2002-2003, Jouni Malinen + + This program is free software; you can redistribute it and/or modify it + under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 + Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + The full GNU General Public License is included in this distribution in the + file called LICENSE. + + Contact Information: + James P. Ketrenos + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rtllib.h" + + +#define DRV_NAME "rtllib_92e" + +#ifdef CONFIG_CFG_80211 +#ifdef CONFIG_RTL_RFKILL +static inline void rtllib_rfkill_poll(struct wiphy *wiphy) +{ + struct rtllib_device *rtllib = NULL; + + rtllib = (struct rtllib_device *)wiphy_priv(wiphy); + + rtllib = (struct rtllib_device *)netdev_priv_rsl(rtllib->dev); + + if (rtllib->rtllib_rfkill_poll) + rtllib->rtllib_rfkill_poll(rtllib->dev); +} +#else +static inline void rtllib_rfkill_poll(struct wiphy *wiphy) {} +#endif +struct cfg80211_ops rtllib_config_ops = {.rfkill_poll = rtllib_rfkill_poll }; +void *rtllib_wiphy_privid = &rtllib_wiphy_privid; +#endif + +void _setup_timer( struct timer_list* ptimer, void* fun, unsigned long data ) +{ + ptimer->function = fun; + ptimer->data = data; + init_timer( ptimer ); +} + +static inline int rtllib_networks_allocate(struct rtllib_device *ieee) +{ + if (ieee->networks) + return 0; + +#ifndef RTK_DMP_PLATFORM + ieee->networks = kmalloc( + MAX_NETWORK_COUNT * sizeof(struct rtllib_network), + GFP_KERNEL); +#else + ieee->networks = dvr_malloc(MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); +#endif + if (!ieee->networks) { + printk(KERN_WARNING "%s: Out of memory allocating beacons\n", + ieee->dev->name); + return -ENOMEM; + } + + memset(ieee->networks, 0, + MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); + + return 0; +} + +static inline void rtllib_networks_free(struct rtllib_device *ieee) +{ + if (!ieee->networks) + return; +#ifndef RTK_DMP_PLATFORM + kfree(ieee->networks); +#else + dvr_free(ieee->networks); +#endif + ieee->networks = NULL; +} + +static inline void rtllib_networks_initialize(struct rtllib_device *ieee) +{ + int i; + + INIT_LIST_HEAD(&ieee->network_free_list); + INIT_LIST_HEAD(&ieee->network_list); + for (i = 0; i < MAX_NETWORK_COUNT; i++) + list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); +} + +#if defined CONFIG_CFG_80211 +static bool rtllib_wdev_alloc(struct rtllib_device *ieee, int sizeof_priv) +{ + int priv_size; + struct rtllib_device *rtllib = NULL; + + priv_size = ALIGN(sizeof(struct rtllib_device),NETDEV_ALIGN) + sizeof_priv; + + ieee->wdev.wiphy = wiphy_new(&rtllib_config_ops, priv_size); + if (!ieee->wdev.wiphy) { + RTLLIB_ERROR("Unable to allocate wiphy.\n"); + goto out_err_new; + } + + rtllib = (struct rtllib_device *)wiphy_priv(ieee->wdev.wiphy); + rtllib->dev = ieee->dev; + + ieee->dev->ieee80211_ptr = &ieee->wdev; + ieee->wdev.iftype = NL80211_IFTYPE_STATION; + + /* Fill-out wiphy structure bits we know... Not enough info + * here to call set_wiphy_dev or set MAC address or channel info + * -- have to do that in ->ndo_init... */ + ieee->wdev.wiphy->privid = rtllib_wiphy_privid; + + ieee->wdev.wiphy->max_scan_ssids = 1; + ieee->wdev.wiphy->max_scan_ie_len = 0; + ieee->wdev.wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); + + return true; + +out_err_new: + wiphy_free(ieee->wdev.wiphy); + return false; +} +#endif + +struct net_device *alloc_rtllib(int sizeof_priv) +{ + struct rtllib_device *ieee = NULL; + struct net_device *dev; + int i,err; + + RTLLIB_DEBUG_INFO("Initializing...\n"); + + dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv); + if (!dev) { + RTLLIB_ERROR("Unable to network device.\n"); + goto failed; + } + ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv); + ieee->dev = dev; + +#ifdef CONFIG_CFG_80211 + if (!rtllib_wdev_alloc(ieee, sizeof_priv)) + goto failed; +#endif + err = rtllib_networks_allocate(ieee); + if (err) { + RTLLIB_ERROR("Unable to allocate beacon storage: %d\n", + err); + goto failed; + } + rtllib_networks_initialize(ieee); + + + /* Default fragmentation threshold is maximum payload size */ + ieee->fts = DEFAULT_FTS; + ieee->scan_age = DEFAULT_MAX_SCAN_AGE; + ieee->open_wep = 1; + + /* Default to enabling full open WEP with host based encrypt/decrypt */ + ieee->host_encrypt = 1; + ieee->host_decrypt = 1; + ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ + + INIT_LIST_HEAD(&ieee->crypt_deinit_list); + _setup_timer(&ieee->crypt_deinit_timer, + rtllib_crypt_deinit_handler, + (unsigned long) ieee); + ieee->rtllib_ap_sec_type = rtllib_ap_sec_type; + + spin_lock_init(&ieee->lock); + spin_lock_init(&ieee->wpax_suitlist_lock); + spin_lock_init(&ieee->bw_spinlock); + spin_lock_init(&ieee->reorder_spinlock); + atomic_set(&(ieee->atm_chnlop), 0); + atomic_set(&(ieee->atm_swbw), 0); + + ieee->bHalfNMode = false; + ieee->wpa_enabled = 0; + ieee->tkip_countermeasures = 0; + ieee->drop_unencrypted = 0; + ieee->privacy_invoked = 0; + ieee->ieee802_1x = 1; + ieee->raw_tx = 0; + ieee->hwsec_active = 0; + + memset(ieee->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + rtllib_softmac_init(ieee); + + ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); + if (ieee->pHTInfo == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); + return NULL; + } + HTUpdateDefaultSetting(ieee); + HTInitializeHTInfo(ieee); + TSInitialize(ieee); + for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) + INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); + + for (i = 0; i < 17; i++) { + ieee->last_rxseq_num[i] = -1; + ieee->last_rxfrag_num[i] = -1; + ieee->last_packet_time[i] = 0; + } + + rtllib_tkip_null(); + rtllib_wep_null(); + rtllib_ccmp_null(); + + return dev; + + failed: + if (dev) + free_netdev(dev); + return NULL; +} + + +void free_rtllib(struct net_device *dev) +{ + struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + int i; + if (ieee->pHTInfo != NULL) { + kfree(ieee->pHTInfo); + ieee->pHTInfo = NULL; + } + rtllib_softmac_free(ieee); + del_timer_sync(&ieee->crypt_deinit_timer); + rtllib_crypt_deinit_entries(ieee, 1); + + for (i = 0; i < WEP_KEYS; i++) { + struct rtllib_crypt_data *crypt = ieee->crypt[i]; + if (crypt) { + if (crypt->ops) + crypt->ops->deinit(crypt->priv); + kfree(crypt); + ieee->crypt[i] = NULL; + } + } + + rtllib_networks_free(ieee); +#ifdef CONFIG_CFG_80211 + wiphy_unregister(ieee->wdev.wiphy); + wiphy_free(ieee->wdev.wiphy); +#endif + free_netdev(dev); +} + +#ifdef CONFIG_RTLLIB_DEBUG + +u32 rtllib_debug_level = 0; +static int debug = \ + RTLLIB_DL_ERR + ; +struct proc_dir_entry *rtllib_proc = NULL; + +static int show_debug_level(char *page, char **start, off_t offset, + int count, int *eof, void *data) +{ + return snprintf(page, count, "0x%08X\n", rtllib_debug_level); +} + +static int store_debug_level(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + char buf[] = "0x00000000"; + unsigned long len = min((unsigned long)sizeof(buf) - 1, count); + char *p = (char *)buf; + unsigned long val; + + if (copy_from_user(buf, buffer, len)) + return count; + buf[len] = 0; + if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { + p++; + if (p[0] == 'x' || p[0] == 'X') + p++; + val = simple_strtoul(p, &p, 16); + } else + val = simple_strtoul(p, &p, 10); + if (p == buf) + printk(KERN_INFO DRV_NAME + ": %s is not in hex or decimal form.\n", buf); + else + rtllib_debug_level = val; + + return strnlen(buf, count); +} + +int __init rtllib_init(void) +{ +#ifdef CONFIG_RTLLIB_DEBUG + struct proc_dir_entry *e; + + rtllib_debug_level = debug; + rtllib_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); + if (rtllib_proc == NULL) { + RTLLIB_ERROR("Unable to create " DRV_NAME + " proc directory\n"); + return -EIO; + } + e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, + rtllib_proc); + if (!e) { + remove_proc_entry(DRV_NAME, init_net.proc_net); + rtllib_proc = NULL; + return -EIO; + } + e->read_proc = show_debug_level; + e->write_proc = store_debug_level; + e->data = NULL; +#endif + + return 0; +} + +void __exit rtllib_exit(void) +{ +#ifdef CONFIG_RTLLIB_DEBUG + if (rtllib_proc) { + remove_proc_entry("debug_level", rtllib_proc); + remove_proc_entry(DRV_NAME, init_net.proc_net); + rtllib_proc = NULL; + } +#endif +} + +#endif diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c new file mode 100644 index 00000000000..2a7133c6ef3 --- /dev/null +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -0,0 +1,4234 @@ +/* + * Original code based Host AP (software wireless LAN access point) driver + * for Intersil Prism2/2.5/3 - hostap.o module, common routines + * + * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen + * + * Copyright (c) 2002-2003, Jouni Malinen + * Copyright (c) 2004, Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. See README and COPYING for + * more details. + ****************************************************************************** + + Few modifications for Realtek's Wi-Fi drivers by + Andrea Merello + + A special thanks goes to Realtek for their support ! + +******************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rtllib.h" +#ifdef ENABLE_DOT11D +#include "dot11d.h" +#endif + +#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) +#include +#endif + +#if defined CONFIG_CFG_80211 +#include + +struct ieee80211_channel *rtllib_get_channel(struct wiphy *wiphy, + int freq) +{ + enum ieee80211_band band; + struct ieee80211_supported_band *sband; + int i; + + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { + sband = wiphy->bands[band]; + + if (!sband) + continue; + + for (i = 0; i < sband->n_channels; i++) { + if (sband->channels[i].center_freq == freq) + return &sband->channels[i]; + } + } + + return NULL; +} + +int rtllib_channel_to_frequency(int chan) +{ + if (chan < 14) + return 2407 + chan * 5; + + if (chan == 14) + return 2484; + + /* FIXME: 802.11j 17.3.8.3.2 */ + return (chan + 1000) * 5; +} + +u32 rtllib_parse_elems_crc(u8 *start, size_t len, + struct ieee802_11_elems *elems, + u64 filter, u32 crc) +{ + size_t left = len; + u8 *pos = start; + bool calc_crc = filter != 0; + + memset(elems, 0, sizeof(*elems)); + elems->ie_start = start; + elems->total_len = len; + + while (left >= 2) { + u8 id, elen; + + id = *pos++; + elen = *pos++; + left -= 2; + + if (elen > left) + break; + + if (calc_crc && id < 64 && (filter & BIT(id))) + crc = crc32_be(crc, pos - 2, elen + 2); + + switch (id) { + case WLAN_EID_SSID: + elems->ssid = pos; + elems->ssid_len = elen; + break; + case WLAN_EID_SUPP_RATES: + elems->supp_rates = pos; + elems->supp_rates_len = elen; + break; + case WLAN_EID_FH_PARAMS: + elems->fh_params = pos; + elems->fh_params_len = elen; + break; + case WLAN_EID_DS_PARAMS: + elems->ds_params = pos; + elems->ds_params_len = elen; + break; + case WLAN_EID_CF_PARAMS: + elems->cf_params = pos; + elems->cf_params_len = elen; + break; + case WLAN_EID_TIM: + if (elen >= sizeof(struct ieee80211_tim_ie)) { + elems->tim = (void *)pos; + elems->tim_len = elen; + } + break; + case WLAN_EID_IBSS_PARAMS: + elems->ibss_params = pos; + elems->ibss_params_len = elen; + break; + case WLAN_EID_CHALLENGE: + elems->challenge = pos; + elems->challenge_len = elen; + break; + case WLAN_EID_VENDOR_SPECIFIC: + if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 && + pos[2] == 0xf2) { + /* Microsoft OUI (00:50:F2) */ + + if (calc_crc) + crc = crc32_be(crc, pos - 2, elen + 2); + + if (pos[3] == 1) { + /* OUI Type 1 - WPA IE */ + elems->wpa = pos; + elems->wpa_len = elen; + } else if (elen >= 5 && pos[3] == 2) { + /* OUI Type 2 - WMM IE */ + if (pos[4] == 0) { + elems->wmm_info = pos; + elems->wmm_info_len = elen; + } else if (pos[4] == 1) { + elems->wmm_param = pos; + elems->wmm_param_len = elen; + } + } + } + break; + case WLAN_EID_RSN: + elems->rsn = pos; + elems->rsn_len = elen; + break; + case WLAN_EID_ERP_INFO: + elems->erp_info = pos; + elems->erp_info_len = elen; + break; + case WLAN_EID_EXT_SUPP_RATES: + elems->ext_supp_rates = pos; + elems->ext_supp_rates_len = elen; + break; + case WLAN_EID_HT_CAPABILITY: + if (elen >= sizeof(struct ieee80211_ht_cap)) + elems->ht_cap_elem = (void *)pos; + break; + case WLAN_EID_HT_INFORMATION: + if (elen >= sizeof(struct ieee80211_ht_info)) + elems->ht_info_elem = (void *)pos; + break; + case WLAN_EID_MESH_ID: + elems->mesh_id = pos; + elems->mesh_id_len = elen; + break; + case WLAN_EID_MESH_CONFIG: + elems->mesh_config = pos; + elems->mesh_config_len = elen; + break; + case WLAN_EID_PEER_LINK: + elems->peer_link = pos; + elems->peer_link_len = elen; + break; + case WLAN_EID_PREQ: + elems->preq = pos; + elems->preq_len = elen; + break; + case WLAN_EID_PREP: + elems->prep = pos; + elems->prep_len = elen; + break; + case WLAN_EID_PERR: + elems->perr = pos; + elems->perr_len = elen; + break; + case WLAN_EID_CHANNEL_SWITCH: + elems->ch_switch_elem = pos; + elems->ch_switch_elem_len = elen; + break; + case WLAN_EID_QUIET: + if (!elems->quiet_elem) { + elems->quiet_elem = pos; + elems->quiet_elem_len = elen; + } + elems->num_of_quiet_elem++; + break; + case WLAN_EID_COUNTRY: + elems->country_elem = pos; + elems->country_elem_len = elen; + break; + case WLAN_EID_PWR_CONSTRAINT: + elems->pwr_constr_elem = pos; + elems->pwr_constr_elem_len = elen; + break; + case WLAN_EID_TIMEOUT_INTERVAL: + elems->timeout_int = pos; + elems->timeout_int_len = elen; + break; + default: + break; + } + + left -= elen; + pos += elen; + } + + return crc; +} + +void rtllib_parse_elems(u8 *start, size_t len, + struct ieee802_11_elems *elems) +{ + rtllib_parse_elems_crc(start, len, elems, 0, 0); +} + +void ieee80211_scan_rx(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_status) +{ + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; + struct ieee80211_mgmt *mgmt; + struct ieee80211_bss *bss; + u8 *elements; + struct ieee80211_channel *channel; + size_t baselen; + int freq; + __le16 fc; + bool presp, beacon = false; + struct ieee802_11_elems elems; + s32 signal = 0; + + if (skb->len < 2) + return; + + mgmt = (struct ieee80211_mgmt *) skb->data; + fc = mgmt->frame_control; + + if (skb->len < 24) + return; + + presp = (WLAN_FC_GET_STYPE(header->frame_ctl) == RTLLIB_STYPE_PROBE_RESP); + if (presp) { + /* ignore ProbeResp to foreign address */ + if (memcmp(mgmt->da, ieee->dev->dev_addr, ETH_ALEN)) + return ;; + + presp = true; + elements = mgmt->u.probe_resp.variable; + baselen = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + } else { + beacon = (WLAN_FC_GET_STYPE(header->frame_ctl) == RTLLIB_STYPE_BEACON); + baselen = offsetof(struct ieee80211_mgmt, u.beacon.variable); + elements = mgmt->u.beacon.variable; + } + + if (!presp && !beacon) + return; + + if (baselen > skb->len) + return; + + rtllib_parse_elems(elements, skb->len - baselen, &elems); + + if (elems.ds_params && elems.ds_params_len == 1) + freq = rtllib_channel_to_frequency(elems.ds_params[0]); + else + return; + + channel = rtllib_get_channel(ieee->wdev.wiphy, freq); + + if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) + return; + + signal = rx_status->signal * 100; + + bss = (void *)cfg80211_inform_bss_frame(ieee->wdev.wiphy, channel, + mgmt, skb->len, signal, GFP_ATOMIC); + + return; +} +#endif + + +#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) +static int rtllib_rx_radiotap_len(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_status) +{ + int len; + + /* always present fields */ + len = sizeof(struct ieee80211_radiotap_header) + + 8 + /* TSFT */ + 1 + /* FLAGS */ + 1 + /* RATE */ + 2 + /* CHANNEL IN MHZ */ + 2 + /* CHANNEL BITFIELD */ + 1 + /* HW SIGNAL DBM */ + 1 + /* HW NOISE DBM */ + 1; /* ANTENNA NUMBER */ + + + if (len & 1) /* padding for RX_FLAGS if necessary */ + len++; + + /* make sure radiotap starts at a naturally aligned address */ + if (len % 8) + len = roundup(len, 8); + + return len; +} + +static void rtllib_add_rx_radiotap_header(struct rtllib_device *ieee, + struct sk_buff *skb, int rtap_len, struct rtllib_rx_stats *rx_status) +{ + struct ieee80211_radiotap_header *rthdr; + unsigned char *pos; + printk("add header!\n"); + rthdr = (struct ieee80211_radiotap_header *)skb_push(skb, rtap_len); + memset(rthdr, 0, rtap_len); + + rthdr->it_version = PKTHDR_RADIOTAP_VERSION; + rthdr->it_pad = 0; + rthdr->it_len = cpu_to_le16(rtap_len); + /* radiotap header, set always present flags */ + rthdr->it_present = cpu_to_le32( + (1 << IEEE80211_RADIOTAP_TSFT) | + (1 << IEEE80211_RADIOTAP_FLAGS) | + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_CHANNEL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | + (1 << IEEE80211_RADIOTAP_ANTENNA)); + + pos = (unsigned char *)(rthdr+1); + /* the order of the following fields is important */ + /* IEEE80211_RADIOTAP_TSFT */ + *(__le64 *)pos = cpu_to_le64(rx_status->TimeStampLow); + pos += 8; + + /* IEEE80211_RADIOTAP_FLAGS */ + if (rx_status->bCRC) + *pos |= IEEE80211_RADIOTAP_F_BADFCS; + if (rx_status->bShortPreamble) + *pos |= IEEE80211_RADIOTAP_F_SHORTPRE; + pos++; + + /* IEEE80211_RADIOTAP_RATE */ + *pos = rx_status->rate / 5; + pos++; + + /* IEEE80211_RADIOTAP_CHANNEL */ + *(__le16 *)pos = cpu_to_le16(rx_status->received_channel); + pos += 2; + pos += 2; + + + /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ + *pos = rx_status->RxPower; + pos++; + + /* IEEE80211_RADIOTAP_DBM_ANTNOISE */ + *pos = rx_status->noise; + pos++; + + /* IEEE80211_RADIOTAP_ANTENNA */ + *pos = rx_status->Antenna; + pos++; + + /* IEEE80211_RADIOTAP_DB_ANTNOISE is not used */ + + /* IEEE80211_RADIOTAP_RX_FLAGS */ + /* ensure 2 byte alignment for the 2 byte field as required */ +} +#endif + +static inline void rtllib_monitor_rx(struct rtllib_device *ieee, + struct sk_buff *skb,struct rtllib_rx_stats *rx_status, + size_t hdr_length) +{ + +#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) + int needed_headroom = 0; + struct sk_buff *radiotap_skb; + + needed_headroom = rtllib_rx_radiotap_len(ieee, rx_status); + printk("needed_headroom = %d\n", needed_headroom); + radiotap_skb = skb_copy_expand(skb, needed_headroom, 0, GFP_ATOMIC); + dev_kfree_skb(skb); + if (!radiotap_skb) { + return; + } + + rtllib_add_rx_radiotap_header(ieee, radiotap_skb, needed_headroom, rx_status); + radiotap_skb->dev = ieee->dev; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) + skb_reset_mac_header(radiotap_skb); +#else + radiotap_skb->mac.raw = radiotap_skb->data; +#endif + radiotap_skb->ip_summed = CHECKSUM_UNNECESSARY; + radiotap_skb->pkt_type = PACKET_OTHERHOST; + radiotap_skb->protocol = htons(ETH_P_802_2); + memset(radiotap_skb->cb, 0, sizeof(radiotap_skb->cb)); + netif_rx(radiotap_skb); +#else + skb->dev = ieee->dev; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) + skb_reset_mac_header(skb); +#else + skb->mac.raw = skb->data; +#endif + skb_pull(skb, hdr_length); + skb->pkt_type = PACKET_OTHERHOST; + skb->protocol = __constant_htons(ETH_P_80211_RAW); + memset(skb->cb, 0, sizeof(skb->cb)); + netif_rx(skb); +#endif +} + +/* Called only as a tasklet (software IRQ) */ +static struct rtllib_frag_entry * +rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, + unsigned int frag, u8 tid,u8 *src, u8 *dst) +{ + struct rtllib_frag_entry *entry; + int i; + + for (i = 0; i < RTLLIB_FRAG_CACHE_LEN; i++) { + entry = &ieee->frag_cache[tid][i]; + if (entry->skb != NULL && + time_after(jiffies, entry->first_frag_time + 2 * HZ)) { + RTLLIB_DEBUG_FRAG( + "expiring fragment cache entry " + "seq=%u last_frag=%u\n", + entry->seq, entry->last_frag); + dev_kfree_skb_any(entry->skb); + entry->skb = NULL; + } + + if (entry->skb != NULL && entry->seq == seq && + (entry->last_frag + 1 == frag || frag == -1) && + memcmp(entry->src_addr, src, ETH_ALEN) == 0 && + memcmp(entry->dst_addr, dst, ETH_ALEN) == 0) + return entry; + } + + return NULL; +} + +/* Called only as a tasklet (software IRQ) */ +static struct sk_buff * +rtllib_frag_cache_get(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr) +{ + struct sk_buff *skb = NULL; + u16 fc = le16_to_cpu(hdr->frame_ctl); + u16 sc = le16_to_cpu(hdr->seq_ctl); + unsigned int frag = WLAN_GET_SEQ_FRAG(sc); + unsigned int seq = WLAN_GET_SEQ_SEQ(sc); + struct rtllib_frag_entry *entry; + struct rtllib_hdr_3addrqos *hdr_3addrqos; + struct rtllib_hdr_4addrqos *hdr_4addrqos; + u8 tid; + + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else if (RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else { + tid = 0; + } + + if (frag == 0) { + /* Reserve enough space to fit maximum frame length */ + skb = dev_alloc_skb(ieee->dev->mtu + + sizeof(struct rtllib_hdr_4addr) + + 8 /* LLC */ + + 2 /* alignment */ + + 8 /* WEP */ + + ETH_ALEN /* WDS */ + + (RTLLIB_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */); + if (skb == NULL) + return NULL; + + entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]]; + ieee->frag_next_idx[tid]++; + if (ieee->frag_next_idx[tid] >= RTLLIB_FRAG_CACHE_LEN) + ieee->frag_next_idx[tid] = 0; + + if (entry->skb != NULL) + dev_kfree_skb_any(entry->skb); + + entry->first_frag_time = jiffies; + entry->seq = seq; + entry->last_frag = frag; + entry->skb = skb; + memcpy(entry->src_addr, hdr->addr2, ETH_ALEN); + memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN); + } else { + /* received a fragment of a frame for which the head fragment + * should have already been received */ + entry = rtllib_frag_cache_find(ieee, seq, frag, tid,hdr->addr2, + hdr->addr1); + if (entry != NULL) { + entry->last_frag = frag; + skb = entry->skb; + } + } + + return skb; +} + + +/* Called only as a tasklet (software IRQ) */ +static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr) +{ + u16 fc = le16_to_cpu(hdr->frame_ctl); + u16 sc = le16_to_cpu(hdr->seq_ctl); + unsigned int seq = WLAN_GET_SEQ_SEQ(sc); + struct rtllib_frag_entry *entry; + struct rtllib_hdr_3addrqos *hdr_3addrqos; + struct rtllib_hdr_4addrqos *hdr_4addrqos; + u8 tid; + + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else if (RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else { + tid = 0; + } + + entry = rtllib_frag_cache_find(ieee, seq, -1, tid,hdr->addr2, + hdr->addr1); + + if (entry == NULL) { + RTLLIB_DEBUG_FRAG( + "could not invalidate fragment cache " + "entry (seq=%u)\n", seq); + return -1; + } + + entry->skb = NULL; + return 0; +} + + + +/* rtllib_rx_frame_mgtmt + * + * Responsible for handling management control frames + * + * Called by rtllib_rx */ +static inline int +rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype) +{ + /* On the struct stats definition there is written that + * this is not mandatory.... but seems that the probe + * response parser uses it + */ + struct rtllib_hdr_3addr * hdr = (struct rtllib_hdr_3addr *)skb->data; + + rx_stats->len = skb->len; + rtllib_rx_mgt(ieee,skb,rx_stats); + if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) { + dev_kfree_skb_any(skb); + return 0; + } + rtllib_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + + dev_kfree_skb_any(skb); + + return 0; + +#ifdef NOT_YET + if (ieee->iw_mode == IW_MODE_MASTER) { + printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", + ieee->dev->name); + return 0; +/* + hostap_update_sta_ps(ieee, (struct hostap_rtllib_hdr_4addr *) + skb->data);*/ + } + + if (ieee->hostapd && type == RTLLIB_TYPE_MGMT) { + if (stype == WLAN_FC_STYPE_BEACON && + ieee->iw_mode == IW_MODE_MASTER) { + struct sk_buff *skb2; + /* Process beacon frames also in kernel driver to + * update STA(AP) table statistics */ + skb2 = skb_clone(skb, GFP_ATOMIC); + if (skb2) + hostap_rx(skb2->dev, skb2, rx_stats); + } + + /* send management frames to the user space daemon for + * processing */ + ieee->apdevstats.rx_packets++; + ieee->apdevstats.rx_bytes += skb->len; + prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT); + return 0; + } + + if (ieee->iw_mode == IW_MODE_MASTER) { + if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) { + printk(KERN_DEBUG "%s: unknown management frame " + "(type=0x%02x, stype=0x%02x) dropped\n", + skb->dev->name, type, stype); + return -1; + } + + hostap_rx(skb->dev, skb, rx_stats); + return 0; + } + + printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame " + "received in non-Host AP mode\n", skb->dev->name); + return -1; +#endif +} + +#ifndef CONFIG_CFG_80211 +/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ +/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ +static unsigned char rfc1042_header[] = +{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ +static unsigned char bridge_tunnel_header[] = +{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; +/* No encapsulation header if EtherType < 0x600 (=length) */ +#endif + +/* Called by rtllib_rx_frame_decrypt */ +static int rtllib_is_eapol_frame(struct rtllib_device *ieee, + struct sk_buff *skb, size_t hdrlen) +{ + struct net_device *dev = ieee->dev; + u16 fc, ethertype; + struct rtllib_hdr_4addr *hdr; + u8 *pos; + + if (skb->len < 24) + return 0; + + hdr = (struct rtllib_hdr_4addr *) skb->data; + fc = le16_to_cpu(hdr->frame_ctl); + + /* check that the frame is unicast frame to us */ + if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) == + RTLLIB_FCTL_TODS && + memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 && + memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) { + /* ToDS frame with own addr BSSID and DA */ + } else if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) == + RTLLIB_FCTL_FROMDS && + memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) { + /* FromDS frame with own addr as DA */ + } else + return 0; + + if (skb->len < 24 + 8) + return 0; + + /* check for port access entity Ethernet type */ + pos = skb->data + hdrlen; + ethertype = (pos[6] << 8) | pos[7]; + if (ethertype == ETH_P_PAE) + return 1; + + return 0; +} + +/* Called only as a tasklet (software IRQ), by rtllib_rx */ +static inline int +rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, + struct rtllib_crypt_data *crypt) +{ + struct rtllib_hdr_4addr *hdr; + int res, hdrlen; + + if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) + return 0; +#if 1 + if (ieee->hwsec_active) + { + cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + tcb_desc->bHwSec = 1; + + if (ieee->need_sw_enc) + tcb_desc->bHwSec = 0; + } +#endif + hdr = (struct rtllib_hdr_4addr *) skb->data; + hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + +#ifdef CONFIG_RTLLIB_CRYPT_TKIP + if (ieee->tkip_countermeasures && + strcmp(crypt->ops->name, "TKIP") == 0) { + if (net_ratelimit()) { + printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " + "received packet from " MAC_FMT "\n", + ieee->dev->name, MAC_ARG(hdr->addr2)); + } + return -1; + } +#endif + + atomic_inc(&crypt->refcnt); + res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); + atomic_dec(&crypt->refcnt); + if (res < 0) { + RTLLIB_DEBUG_DROP( + "decryption failed (SA=" MAC_FMT + ") res=%d\n", MAC_ARG(hdr->addr2), res); + if (res == -2) + RTLLIB_DEBUG_DROP("Decryption failed ICV " + "mismatch (key %d)\n", + skb->data[hdrlen + 3] >> 6); + ieee->ieee_stats.rx_discards_undecryptable++; + return -1; + } + + return res; +} + + +/* Called only as a tasklet (software IRQ), by rtllib_rx */ +static inline int +rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, + int keyidx, struct rtllib_crypt_data *crypt) +{ + struct rtllib_hdr_4addr *hdr; + int res, hdrlen; + + if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) + return 0; + if (ieee->hwsec_active) + { + cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + tcb_desc->bHwSec = 1; + + if (ieee->need_sw_enc) + tcb_desc->bHwSec = 0; + } + + hdr = (struct rtllib_hdr_4addr *) skb->data; + hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + + atomic_inc(&crypt->refcnt); + res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv,ieee); + atomic_dec(&crypt->refcnt); + if (res < 0) { + printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" + " (SA=" MAC_FMT " keyidx=%d)\n", + ieee->dev->name, MAC_ARG(hdr->addr2), keyidx); + return -1; + } + + return 0; +} + + +/* this function is stolen from ipw2200 driver*/ +#define IEEE_PACKET_RETRY_TIME (5*HZ) +static int is_duplicate_packet(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *header) +{ + u16 fc = le16_to_cpu(header->frame_ctl); + u16 sc = le16_to_cpu(header->seq_ctl); + u16 seq = WLAN_GET_SEQ_SEQ(sc); + u16 frag = WLAN_GET_SEQ_FRAG(sc); + u16 *last_seq, *last_frag; + unsigned long *last_time; + struct rtllib_hdr_3addrqos *hdr_3addrqos; + struct rtllib_hdr_4addrqos *hdr_4addrqos; + u8 tid; + + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else if (RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_3addrqos = (struct rtllib_hdr_3addrqos*)header; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid ++; + } else { + tid = 0; + } + + switch (ieee->iw_mode) { + case IW_MODE_ADHOC: + { + struct list_head *p; + struct ieee_ibss_seq *entry = NULL; + u8 *mac = header->addr2; + int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE; + list_for_each(p, &ieee->ibss_mac_hash[index]) { + entry = list_entry(p, struct ieee_ibss_seq, list); + if (!memcmp(entry->mac, mac, ETH_ALEN)) + break; + } + if (p == &ieee->ibss_mac_hash[index]) { + entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC); + if (!entry) { + printk(KERN_WARNING "Cannot malloc new mac entry\n"); + return 0; + } + memcpy(entry->mac, mac, ETH_ALEN); + entry->seq_num[tid] = seq; + entry->frag_num[tid] = frag; + entry->packet_time[tid] = jiffies; + list_add(&entry->list, &ieee->ibss_mac_hash[index]); + return 0; + } + last_seq = &entry->seq_num[tid]; + last_frag = &entry->frag_num[tid]; + last_time = &entry->packet_time[tid]; + break; + } + + case IW_MODE_INFRA: + last_seq = &ieee->last_rxseq_num[tid]; + last_frag = &ieee->last_rxfrag_num[tid]; + last_time = &ieee->last_packet_time[tid]; + break; + default: + return 0; + } + + if ((*last_seq == seq) && + time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { + if (*last_frag == frag){ + goto drop; + + } + if (*last_frag + 1 != frag) + /* out-of-order fragment */ + goto drop; + } else + *last_seq = seq; + + *last_frag = frag; + *last_time = jiffies; + return 0; + +drop: + + return 1; +} +bool +AddReorderEntry( + PRX_TS_RECORD pTS, + PRX_REORDER_ENTRY pReorderEntry + ) +{ + struct list_head *pList = &pTS->RxPendingPktList; + + while(pList->next != &pTS->RxPendingPktList) + { + if ( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) + { + pList = pList->next; + } + else if ( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) + { + return false; + } + else + { + break; + } + } + pReorderEntry->List.next = pList->next; + pReorderEntry->List.next->prev = &pReorderEntry->List; + pReorderEntry->List.prev = pList; + pList->next = &pReorderEntry->List; + + return true; +} + +void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index) +{ + struct net_device_stats *stats = &ieee->stats; + u8 i = 0 , j=0; + u16 ethertype; + for (j = 0; j < index; j++) { + struct rtllib_rxb* prxb = prxbIndicateArray[j]; + for (i = 0; inr_subframes; i++) { + struct sk_buff *sub_skb = prxb->subframes[i]; + + /* convert hdr + possible LLC headers into Ethernet header */ + ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; + if (sub_skb->len >= 8 && + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and + * replace EtherType */ + skb_pull(sub_skb, SNAP_SIZE); + memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); + } else { + u16 len; + /* Leave Ethernet header part of hdr and full payload */ + len = htons(sub_skb->len); + memcpy(skb_push(sub_skb, 2), &len, 2); + memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); + } + + /* Indicat the packets to upper layer */ + if (sub_skb) { + stats->rx_packets++; + stats->rx_bytes += sub_skb->len; + + memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); + sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev); + sub_skb->dev = ieee->dev; + sub_skb->dev->stats.rx_packets++; + sub_skb->dev->stats.rx_bytes += sub_skb->len; +#ifdef TCP_CSUM_OFFLOAD_RX + if ( prxb->tcp_csum_valid) + sub_skb->ip_summed = CHECKSUM_UNNECESSARY; + else + sub_skb->ip_summed = CHECKSUM_NONE; + +#else + sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ +#endif + ieee->last_rx_ps_time = jiffies; + netif_rx(sub_skb); + } + } + kfree(prxb); + prxb = NULL; + } +} + +void +rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS) +{ + PRX_REORDER_ENTRY pRxReorderEntry; + struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; + u8 RfdCnt = 0; + + + del_timer_sync(&pTS->RxPktPendingTimer); + while(!list_empty(&pTS->RxPendingPktList)) + { + if (RfdCnt >= REORDER_WIN_SIZE){ + printk("-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); + break; + } + + pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + list_del_init(&pRxReorderEntry->List); + + RfdArray[RfdCnt] = pRxReorderEntry->prxb; + + RfdCnt = RfdCnt + 1; + list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List); + } + rtllib_indicate_packets(ieee, RfdArray, RfdCnt); + + pTS->RxIndicateSeq = 0xffff; + +#ifdef MERGE_TO_DO +#endif +} + + +void RxReorderIndicatePacket( struct rtllib_device *ieee, + struct rtllib_rxb* prxb, + PRX_TS_RECORD pTS, + u16 SeqNum) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + PRX_REORDER_ENTRY pReorderEntry = NULL; + struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; + u8 WinSize = pHTInfo->RxReorderWinSize; + u16 WinEnd = 0; + u8 index = 0; + bool bMatchWinStart = false, bPktInBuf = false; + unsigned long flags; + + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); + + spin_lock_irqsave(&(ieee->reorder_spinlock), flags); + + WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; + /* Rx Reorder initialize condition.*/ + if (pTS->RxIndicateSeq == 0xffff) { + pTS->RxIndicateSeq = SeqNum; + } + + /* Drop out the packet which SeqNum is smaller than WinStart */ + if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); + pHTInfo->RxReorderDropCounter++; + { + int i; + for (i =0; i < prxb->nr_subframes; i++) { + dev_kfree_skb(prxb->subframes[i]); + } + kfree(prxb); + prxb = NULL; + } + spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + return; + } + + /* + * Sliding window manipulation. Conditions includes: + * 1. Incoming SeqNum is equal to WinStart =>Window shift 1 + * 2. Incoming SeqNum is larger than the WinEnd => Window shift N + */ + if (SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) { + pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; + bMatchWinStart = true; + } else if (SN_LESS(WinEnd, SeqNum)) { + if (SeqNum >= (WinSize - 1)) { + pTS->RxIndicateSeq = SeqNum + 1 -WinSize; + } else { + pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; + } + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + } + + /* + * Indication process. + * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets + * with the SeqNum smaller than latest WinStart and buffer other packets. + */ + /* For Rx Reorder condition: + * 1. All packets with SeqNum smaller than WinStart => Indicate + * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. + */ + if (bMatchWinStart) { + /* Current packet is going to be indicated.*/ + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ + pTS->RxIndicateSeq, SeqNum); + prxbIndicateArray[0] = prxb; + index = 1; + } else { + /* Current packet is going to be inserted into pending list.*/ + if (!list_empty(&ieee->RxReorder_Unused_List)) { + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List); + list_del_init(&pReorderEntry->List); + + /* Make a reorder entry and insert into a the packet list.*/ + pReorderEntry->SeqNum = SeqNum; + pReorderEntry->prxb = prxb; + +#if 1 + if (!AddReorderEntry(pTS, pReorderEntry)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", + __func__, pTS->RxIndicateSeq, SeqNum); + list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); + { + int i; + for (i =0; i < prxb->nr_subframes; i++) { + dev_kfree_skb(prxb->subframes[i]); + } + kfree(prxb); + prxb = NULL; + } + } else { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, + "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + } +#endif + } + else { + /* + * Packets are dropped if there is not enough reorder entries. + * This part shall be modified!! We can just indicate all the + * packets in buffer and get reorder entries. + */ + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); + { + int i; + for (i =0; i < prxb->nr_subframes; i++) { + dev_kfree_skb(prxb->subframes[i]); + } + kfree(prxb); + prxb = NULL; + } + } + } + + /* Check if there is any packet need indicate.*/ + while(!list_empty(&pTS->RxPendingPktList)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); +#if 1 + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) + { + /* This protect buffer from overflow. */ + if (index >= REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); + bPktInBuf = true; + break; + } + + list_del_init(&pReorderEntry->List); + + if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) + pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; + + prxbIndicateArray[index] = pReorderEntry->prxb; + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pReorderEntry->SeqNum); + index++; + + list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); + } else { + bPktInBuf = true; + break; + } +#endif + } + + /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ + if (index>0) { + if (timer_pending(&pTS->RxPktPendingTimer)){ + del_timer_sync(&pTS->RxPktPendingTimer); + } + pTS->RxTimeoutIndicateSeq = 0xffff; + + if (index>REORDER_WIN_SIZE){ + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + return; + } + rtllib_indicate_packets(ieee, prxbIndicateArray, index); + bPktInBuf = false; + } + + if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); + pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; + mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime)); + } + spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); +} + +u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb,u8* src,u8* dst) +{ + struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr* )skb->data; + u16 fc = le16_to_cpu(hdr->frame_ctl); + + u16 LLCOffset= sizeof(struct rtllib_hdr_3addr); + u16 ChkLength; + bool bIsAggregateFrame = false; + u16 nSubframe_Length; + u8 nPadding_Length = 0; + u16 SeqNum=0; + struct sk_buff *sub_skb; + u8 *data_ptr; + /* just for debug purpose */ + SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); + if ((RTLLIB_QOS_HAS_SEQ(fc))&&\ + (((frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { + bIsAggregateFrame = true; + } + + if (RTLLIB_QOS_HAS_SEQ(fc)) { + LLCOffset += 2; + } + if (rx_stats->bContainHTC) { + LLCOffset += sHTCLng; + } + + ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ + + if ( skb->len <= ChkLength ) { + return 0; + } + + skb_pull(skb, LLCOffset); + ieee->bIsAggregateFrame = bIsAggregateFrame; + if (!bIsAggregateFrame) { + rxb->nr_subframes = 1; + + /* altered by clark 3/30/2010 + * The buffer size of the skb indicated to upper layer + * must be less than 5000, or the defraged IP datagram + * in the IP layer will exceed "ipfrag_high_tresh" and be + * discarded. so there must not use the function + * "skb_copy" and "skb_clone" for "skb". + */ + + /* Allocate new skb for releasing to upper layer */ + sub_skb = dev_alloc_skb(RTLLIB_SKBBUFFER_SIZE); + skb_reserve(sub_skb, 12); + data_ptr = (u8 *)skb_put(sub_skb, skb->len); + memcpy(data_ptr, skb->data, skb->len); + sub_skb->dev = ieee->dev; + + rxb->subframes[0] = sub_skb; + + memcpy(rxb->src,src,ETH_ALEN); + memcpy(rxb->dst,dst,ETH_ALEN); + rxb->subframes[0]->dev = ieee->dev; + return 1; + } else { + rxb->nr_subframes = 0; + memcpy(rxb->src,src,ETH_ALEN); + memcpy(rxb->dst,dst,ETH_ALEN); + while(skb->len > ETHERNET_HEADER_SIZE) { + /* Offset 12 denote 2 mac address */ + nSubframe_Length = *((u16*)(skb->data + 12)); + nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8); + + if (skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { + printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ + __func__,rxb->nr_subframes); + printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length); + printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); + printk("The Packet SeqNum is %d\n",SeqNum); + return 0; + } + + /* move the data point to data content */ + skb_pull(skb, ETHERNET_HEADER_SIZE); + + /* altered by clark 3/30/2010 + * The buffer size of the skb indicated to upper layer + * must be less than 5000, or the defraged IP datagram + * in the IP layer will exceed "ipfrag_high_tresh" and be + * discarded. so there must not use the function + * "skb_copy" and "skb_clone" for "skb". + */ + + /* Allocate new skb for releasing to upper layer */ + sub_skb = dev_alloc_skb(nSubframe_Length + 12); + skb_reserve(sub_skb, 12); + data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); + memcpy(data_ptr,skb->data,nSubframe_Length); + + sub_skb->dev = ieee->dev; + rxb->subframes[rxb->nr_subframes++] = sub_skb; + if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { + RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + break; + } + skb_pull(skb,nSubframe_Length); + + if (skb->len != 0) { + nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4); + if (nPadding_Length == 4) { + nPadding_Length = 0; + } + + if (skb->len < nPadding_Length) { + return 0; + } + + skb_pull(skb,nPadding_Length); + } + } + + return rxb->nr_subframes; + } +} + + +size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; + u16 fc = le16_to_cpu(hdr->frame_ctl); + size_t hdrlen = 0; + + hdrlen = rtllib_get_hdrlen(fc); + if (HTCCheck(ieee, skb->data)) { + if (net_ratelimit()) + printk("%s: find HTCControl!\n", __func__); + hdrlen += 4; + rx_stats->bContainHTC = 1; + } + + if (RTLLIB_QOS_HAS_SEQ(fc)) + rx_stats->bIsQosData = 1; + + return hdrlen; +} + +int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u8 multicast) +{ + struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; + u16 fc, sc; + u8 frag, type, stype; + + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + sc = le16_to_cpu(hdr->seq_ctl); + frag = WLAN_GET_SEQ_FRAG(sc); + + if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || + !ieee->current_network.qos_data.active || + !IsDataFrame(skb->data) || + IsLegacyDataFrame(skb->data)) { + if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ + if (is_duplicate_packet(ieee, hdr)){ + return -1; + } + } + } else { + PRX_TS_RECORD pRxTS = NULL; + if (GetTs(ieee, (PTS_COMMON_INFO*) &pRxTS, hdr->addr2, + (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { + if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && + (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { + return -1; + } else { + pRxTS->RxLastFragNum = frag; + pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); + } + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); + return -1; + } + } + + return 0; +} +void rtllib_rx_extract_addr(struct rtllib_device *ieee, struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, u8 *bssid) +{ + u16 fc = le16_to_cpu(hdr->frame_ctl); + + switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { + case RTLLIB_FCTL_FROMDS: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr3, ETH_ALEN); + memcpy(bssid, hdr->addr2, ETH_ALEN); + break; + case RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr1, ETH_ALEN); + break; + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr4, ETH_ALEN); + memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + break; + case 0: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr3, ETH_ALEN); + break; + } +} +int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, u8 *bssid, u8 *addr2) +{ + u8 zero_addr[ETH_ALEN] = {0}; + u8 type, stype; + + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + + /* Filter frames from different BSS */ + if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) + && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) + && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { + return -1; + } + + /* Filter packets sent by an STA that will be forwarded by AP */ + if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { + if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && + (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && + (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { + return -1; + } + } + + /* Nullfunc frames may have PS-bit set, so they must be passed to + * hostap_handle_sta_rx() before being dropped here. */ + if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn){ + if (stype != RTLLIB_STYPE_DATA && + stype != RTLLIB_STYPE_DATA_CFACK && + stype != RTLLIB_STYPE_DATA_CFPOLL && + stype != RTLLIB_STYPE_DATA_CFACKPOLL&& + stype != RTLLIB_STYPE_QOS_DATA + ) { + if (stype != RTLLIB_STYPE_NULLFUNC) + RTLLIB_DEBUG_DROP( + "RX: dropped data frame " + "with no data (type=0x%02x, " + "subtype=0x%02x)\n", + type, stype); + return -1; + } + } + + if (ieee->iw_mode != IW_MODE_MESH) { + /* packets from our adapter are dropped (echo) */ + if (!memcmp(src, ieee->dev->dev_addr, ETH_ALEN)) + return -1; + + /* {broad,multi}cast packets to our BSS go through */ + if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) { + if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) { + return -1; + } + } + } + return 0; +} +int rtllib_rx_get_crypt( + struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_crypt_data **crypt, + size_t hdrlen) +{ + struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; + u16 fc = le16_to_cpu(hdr->frame_ctl); + int idx = 0; + + if (ieee->host_decrypt) { + if (skb->len >= hdrlen + 3) + idx = skb->data[hdrlen + 3] >> 6; + + *crypt = ieee->crypt[idx]; + /* allow NULL decrypt to indicate an station specific override + * for default encryption */ + if (*crypt && ((*crypt)->ops == NULL || + (*crypt)->ops->decrypt_mpdu == NULL)) + *crypt = NULL; + + if (!*crypt && (fc & RTLLIB_FCTL_WEP)) { + /* This seems to be triggered by some (multicast?) + * frames from other than current BSS, so just drop the + * frames silently instead of filling system log with + * these reports. */ + RTLLIB_DEBUG_DROP("Decryption failed (not set)" + " (SA=" MAC_FMT ")\n", + MAC_ARG(hdr->addr2)); + ieee->ieee_stats.rx_discards_undecryptable++; + return -1; + } + } + + return 0; +} +int rtllib_rx_decrypt( + struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_crypt_data *crypt, + size_t hdrlen) +{ + struct rtllib_hdr_4addr *hdr; + int keyidx = 0; + u16 fc, sc; + u8 frag; + + hdr = (struct rtllib_hdr_4addr *)skb->data; + fc = le16_to_cpu(hdr->frame_ctl); + sc = le16_to_cpu(hdr->seq_ctl); + frag = WLAN_GET_SEQ_FRAG(sc); + + if ((!rx_stats->Decrypted)){ + ieee->need_sw_enc = 1; + }else{ + ieee->need_sw_enc = 0; + } + + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && + ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { + printk("%s: decrypt frame error\n", __func__); + return -1; + } + + hdr = (struct rtllib_hdr_4addr *) skb->data; + if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) { + int flen; + struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr); + RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); + + if (!frag_skb) { + RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG, + "Rx cannot get skb from fragment " + "cache (morefrag=%d seq=%u frag=%u)\n", + (fc & RTLLIB_FCTL_MOREFRAGS) != 0, + WLAN_GET_SEQ_SEQ(sc), frag); + return -1; + } + flen = skb->len; + if (frag != 0) + flen -= hdrlen; + + if (frag_skb->tail + flen > frag_skb->end) { + printk(KERN_WARNING "%s: host decrypted and " + "reassembled frame did not fit skb\n", + __func__); + rtllib_frag_cache_invalidate(ieee, hdr); + return -1; + } + + if (frag == 0) { + /* copy first fragment (including full headers) into + * beginning of the fragment cache skb */ + memcpy(skb_put(frag_skb, flen), skb->data, flen); + } else { + /* append frame payload to the end of the fragment + * cache skb */ + memcpy(skb_put(frag_skb, flen), skb->data + hdrlen, + flen); + } + dev_kfree_skb_any(skb); + skb = NULL; + + if (fc & RTLLIB_FCTL_MOREFRAGS) { + /* more fragments expected - leave the skb in fragment + * cache for now; it will be delivered to upper layers + * after all fragments have been received */ + return -2; + } + + /* this was the last fragment and the frame will be + * delivered, so remove skb from fragment cache */ + skb = frag_skb; + hdr = (struct rtllib_hdr_4addr *) skb->data; + rtllib_frag_cache_invalidate(ieee, hdr); + } + + /* skb: hdr + (possible reassembled) full MSDU payload; possibly still + * encrypted/authenticated */ + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && + rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + { + printk("%s: ==>decrypt msdu error\n", __func__); + return -1; + } + + hdr = (struct rtllib_hdr_4addr *) skb->data; + if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep) { + if (/*ieee->ieee802_1x &&*/ + rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + +#ifdef CONFIG_RTLLIB_DEBUG + /* pass unencrypted EAPOL frames even if encryption is + * configured */ + struct eapol *eap = (struct eapol *)(skb->data + + 24); + RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); +#endif + } else { + RTLLIB_DEBUG_DROP( + "encryption configured, but RX " + "frame not encrypted (SA=" MAC_FMT ")\n", + MAC_ARG(hdr->addr2)); + return -1; + } + } + +#ifdef CONFIG_RTLLIB_DEBUG + if (crypt && !(fc & RTLLIB_FCTL_WEP) && + rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + struct eapol *eap = (struct eapol *)(skb->data + + 24); + RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); + } +#endif + + if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep && + !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + RTLLIB_DEBUG_DROP( + "dropped unencrypted RX data " + "frame from " MAC_FMT + " (drop_unencrypted=1)\n", + MAC_ARG(hdr->addr2)); + return -1; + } + + if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + printk(KERN_WARNING "RX: IEEE802.1X EAPOL frame!\n"); + } + + return 0; +} +void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) +{ +#if !defined(RTL8192SU) && !defined(RTL8192U) + if (unicast){ + + if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) + { + if ( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) + { + if (ieee->LeisurePSLeave) + ieee->LeisurePSLeave(ieee->dev); + } + } + } +#endif + ieee->last_rx_ps_time = jiffies; +} +void rtllib_rx_indicate_pkt_legacy( + struct rtllib_device *ieee, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb* rxb, + u8 *dst, + u8 *src) +{ + struct net_device *dev = ieee->dev; + u16 ethertype; + int i = 0; + + if (rxb == NULL){ + printk("%s: rxb is NULL!!\n", __func__); + return ; + } + + for (i = 0; inr_subframes; i++) { + struct sk_buff *sub_skb = rxb->subframes[i]; + + if (sub_skb) { + /* convert hdr + possible LLC headers into Ethernet header */ + ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; + if (sub_skb->len >= 8 && + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and + * replace EtherType */ + skb_pull(sub_skb, SNAP_SIZE); + memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + } else { + u16 len; + /* Leave Ethernet header part of hdr and full payload */ + len = htons(sub_skb->len); + memcpy(skb_push(sub_skb, 2), &len, 2); + memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + } + + ieee->stats.rx_packets++; + ieee->stats.rx_bytes += sub_skb->len; + + if (is_multicast_ether_addr(dst)) { + ieee->stats.multicast++; + } + + /* Indicat the packets to upper layer */ + memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); + sub_skb->protocol = eth_type_trans(sub_skb, dev); + sub_skb->dev = dev; + sub_skb->dev->stats.rx_packets++; + sub_skb->dev->stats.rx_bytes += sub_skb->len; +#ifdef TCP_CSUM_OFFLOAD_RX + if ( rx_stats->tcp_csum_valid) + sub_skb->ip_summed = CHECKSUM_UNNECESSARY; + else + sub_skb->ip_summed = CHECKSUM_NONE; +#else + sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ +#endif + netif_rx(sub_skb); + } + } + kfree(rxb); + rxb = NULL; +} +int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + struct net_device *dev = ieee->dev; + struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; + struct rtllib_crypt_data *crypt = NULL; +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + struct sta_info * psta = NULL; +#endif + struct rtllib_rxb* rxb = NULL; + PRX_TS_RECORD pTS = NULL; + u16 fc, sc, SeqNum = 0; + u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; + u8 dst[ETH_ALEN], src[ETH_ALEN], bssid[ETH_ALEN] = {0}, *payload; + size_t hdrlen = 0; + bool bToOtherSTA = false; + int ret = 0, i = 0; + + hdr = (struct rtllib_hdr_4addr *)skb->data; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + sc = le16_to_cpu(hdr->seq_ctl); + + /*Filter pkt not to me*/ + multicast = is_multicast_ether_addr(hdr->addr1)|is_broadcast_ether_addr(hdr->addr1); + unicast = !multicast; + if (unicast && (compare_ether_addr(dev->dev_addr, hdr->addr1) != 0)) { + if (ieee->bNetPromiscuousMode) + bToOtherSTA = true; + else + goto rx_dropped; + } + + /*Filter pkt has too small length */ + hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats); + if (skb->len < hdrlen){ + printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); + goto rx_dropped; + } + + /* Filter Duplicate pkt */ + ret = rtllib_rx_check_duplicate(ieee, skb, multicast); + if (ret < 0) + goto rx_dropped; + + /* Filter CTRL Frame */ + if (type == RTLLIB_FTYPE_CTL) { + goto rx_dropped; + } + + /* Filter MGNT Frame */ + if (type == RTLLIB_FTYPE_MGMT) { + if (bToOtherSTA) + goto rx_dropped; + if (rtllib_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + goto rx_dropped; + else + goto rx_exit; + } + + /* Filter WAPI DATA Frame */ + + /* Update statstics for AP roaming */ + if (!bToOtherSTA){ + ieee->LinkDetectInfo.NumRecvDataInPeriod++; + ieee->LinkDetectInfo.NumRxOkInPeriod++; + } + dev->last_rx = jiffies; + + /* Data frame - extract src/dst addresses */ + rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid); + + /* Filter Data frames */ + ret = rtllib_rx_data_filter(ieee, fc, dst, src, bssid, hdr->addr2); + if (ret < 0) + goto rx_dropped; + + if (skb->len == hdrlen){ + goto rx_dropped; + } + + /* Send pspoll based on moredata */ + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) + && (ieee->polling) && (!bToOtherSTA)) { + if (WLAN_FC_MORE_DATA(fc)) { + /* more data bit is set, let's request a new frame from the AP */ + rtllib_sta_ps_send_pspoll_frame(ieee); + } else { + ieee->polling = false; + } + } + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (ieee->iw_mode == IW_MODE_ADHOC){ + psta = GetStaInfo(ieee, src); + if (NULL != psta) + psta->LastActiveTime = jiffies; + } +#endif + + /* Get crypt if encrypted */ + ret = rtllib_rx_get_crypt(ieee, skb, &crypt, hdrlen); + if (ret == -1) + goto rx_dropped; + + /* Decrypt data frame (including reassemble) */ + ret = rtllib_rx_decrypt(ieee, skb, rx_stats, crypt, hdrlen); + if (ret == -1) + goto rx_dropped; + else if (ret == -2) + goto rx_exit; + + /* Get TS for Rx Reorder */ + hdr = (struct rtllib_hdr_4addr *) skb->data; + if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) + && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1) + && (!bToOtherSTA)) + { + TID = Frame_QoSTID(skb->data); + SeqNum = WLAN_GET_SEQ_SEQ(sc); + GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true); + if (TID !=0 && TID !=3){ + ieee->bis_any_nonbepkts = true; + } + } + + /* Parse rx data frame (For AMSDU) */ + /* skb: hdr + (possible reassembled) full plaintext payload */ + payload = skb->data + hdrlen; + rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); + if (rxb == NULL) + { + RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); + goto rx_dropped; + } + /* to parse amsdu packets */ + /* qos data packets & reserved bit is 1 */ + if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { + /* only to free rxb, and not submit the packets to upper layer */ + for (i =0; i < rxb->nr_subframes; i++) { + dev_kfree_skb(rxb->subframes[i]); + } + kfree(rxb); + rxb = NULL; + goto rx_dropped; + } + + /* Update WAPI PN */ + + /* Check if leave LPS */ + if (!bToOtherSTA){ + if (ieee->bIsAggregateFrame) + nr_subframes = rxb->nr_subframes; + else + nr_subframes = 1; + if (unicast) + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod += nr_subframes; + rtllib_rx_check_leave_lps(ieee, unicast, nr_subframes); + } + + /* Indicate packets to upper layer or Rx Reorder */ + if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA){ + rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); + }else{ +#ifdef TCP_CSUM_OFFLOAD_RX + rxb->tcp_csum_valid = rx_stats->tcp_csum_valid; +#endif + RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); + } + + dev_kfree_skb(skb); + + rx_exit: + return 1; + + rx_dropped: + if (rxb != NULL) + { + kfree(rxb); + rxb = NULL; + } + ieee->stats.rx_dropped++; + + /* Returning 0 indicates to caller that we have not handled the SKB-- + * so it is still allocated and can be used again by underlying + * hardware as a DMA target */ + return 0; +} + +int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + return 0; +} +int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; + u16 fc = le16_to_cpu(hdr->frame_ctl); + size_t hdrlen = rtllib_get_hdrlen(fc); + + if (skb->len < hdrlen){ + printk("%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); + return 0; + } + + if (HTCCheck(ieee, skb->data)) { + if (net_ratelimit()) + printk("%s: Find HTCControl!\n", __func__); + hdrlen += 4; + } + +#if WIRELESS_EXT > 15 + rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen); + ieee->stats.rx_packets++; + ieee->stats.rx_bytes += skb->len; +#endif + return 1; +} + +int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + return 0; +} + +#if 1 +/* All received frames are sent to this function. @skb contains the frame in + * IEEE 802.11 format, i.e., in the format it was sent over air. + * This function is called only as a tasklet (software IRQ). */ +int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + int ret = 0; + + if ((NULL==ieee) || (NULL==skb) || (NULL==rx_stats)){ + printk(KERN_INFO "%s: Input parameters NULL!\n", __func__); + goto rx_dropped; + } + if (skb->len < 10) { + printk(KERN_INFO "%s: SKB length < 10 \n", __func__); + goto rx_dropped; + } + + switch (ieee->iw_mode) { + case IW_MODE_ADHOC: + case IW_MODE_INFRA: + ret = rtllib_rx_InfraAdhoc(ieee, skb, rx_stats); + break; + case IW_MODE_MASTER: + case IW_MODE_REPEAT: + ret = rtllib_rx_Master(ieee, skb, rx_stats); + break; + case IW_MODE_MONITOR: + ret = rtllib_rx_Monitor(ieee, skb, rx_stats); + break; + case IW_MODE_MESH: + ret = rtllib_rx_Mesh(ieee, skb, rx_stats); + break; + default: + printk(KERN_INFO"%s: ERR iw mode!!!\n", __func__); + break; + } + + return ret; + + rx_dropped: + ieee->stats.rx_dropped++; + return 0; +} +#else +int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) +{ + struct net_device *dev = ieee->dev; + struct rtllib_hdr_4addr *hdr; + size_t hdrlen; + u16 fc, type, stype, sc; + struct net_device_stats *stats = NULL; + unsigned int frag; + u8 *payload; + u16 ethertype; + u8 TID = 0; + u16 SeqNum = 0; + PRX_TS_RECORD pTS = NULL; +#ifdef NOT_YET + struct net_device *wds = NULL; + struct sk_buff *skb2 = NULL; + struct net_device *wds = NULL; + int frame_authorized = 0; + int from_assoc_ap = 0; + void *sta = NULL; +#endif + u8 dst[ETH_ALEN]; + u8 src[ETH_ALEN]; + u8 bssid[ETH_ALEN] = {0}; + u8 zero_addr[ETH_ALEN] = {0}; + struct rtllib_crypt_data *crypt = NULL; + int keyidx = 0; +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + struct sta_info * psta = NULL; +#endif + bool unicast_packet = false; + int i; + struct rtllib_rxb* rxb = NULL; + int multicast = 0; + bool tmp_dump = false; + bool bToOtherSTA = false; + hdr = (struct rtllib_hdr_4addr *)skb->data; + stats = &ieee->stats; + + multicast = is_multicast_ether_addr(hdr->addr1)|is_broadcast_ether_addr(hdr->addr1); + if (!multicast && (compare_ether_addr(dev->dev_addr, hdr->addr1) != 0)) { + if ((ieee->iw_mode == IW_MODE_MONITOR) || ieee->bNetPromiscuousMode){ + bToOtherSTA = true; + }else{ + goto rx_dropped; + } + } + + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + sc = le16_to_cpu(hdr->seq_ctl); + frag = WLAN_GET_SEQ_FRAG(sc); + + ieee->need_sw_enc = 0; + + hdrlen = rtllib_get_hdrlen(fc); + if (skb->len < hdrlen){ + printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); + goto rx_dropped; + } + + if (HTCCheck(ieee, skb->data)) { + if (net_ratelimit()) + printk("find HTCControl\n"); + hdrlen += 4; + rx_stats->bContainHTC = 1; + } + if (RTLLIB_QOS_HAS_SEQ(fc)) + rx_stats->bIsQosData = 1; + if ((0) && (type == RTLLIB_FTYPE_DATA) && ((is_broadcast_ether_addr(hdr->addr1)) || (compare_ether_addr(dev->dev_addr, hdr->addr1) == 0))) { + printk("===>RX data before decrypt\n"); + tmp_dump = true; + dump_buf(skb->data,skb->len); + } +#ifdef NOT_YET + hostap_update_rx_stats(local->ap, hdr, rx_stats); +#endif + + if (ieee->host_decrypt) { + int idx = 0; + if (skb->len >= hdrlen + 3) + idx = skb->data[hdrlen + 3] >> 6; + crypt = ieee->crypt[idx]; +#ifdef NOT_YET + sta = NULL; + + /* Use station specific key to override default keys if the + * receiver address is a unicast address ("individual RA"). If + * bcrx_sta_key parameter is set, station specific key is used + * even with broad/multicast targets (this is against IEEE + * 802.11, but makes it easier to use different keys with + * stations that do not support WEP key mapping). */ + + if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) + (void) hostap_handle_sta_crypto(local, hdr, &crypt, + &sta); +#endif + + /* allow NULL decrypt to indicate an station specific override + * for default encryption */ + if (crypt && (crypt->ops == NULL || + crypt->ops->decrypt_mpdu == NULL)) + crypt = NULL; + + if (!crypt && (fc & RTLLIB_FCTL_WEP)) { + /* This seems to be triggered by some (multicast?) + * frames from other than current BSS, so just drop the + * frames silently instead of filling system log with + * these reports. */ + RTLLIB_DEBUG_DROP("Decryption failed (not set)" + " (SA=" MAC_FMT ")\n", + MAC_ARG(hdr->addr2)); + ieee->ieee_stats.rx_discards_undecryptable++; + goto rx_dropped; + } + } + + if (skb->len < RTLLIB_DATA_HDR3_LEN) + goto rx_dropped; + + if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || + !ieee->current_network.qos_data.active || + !IsDataFrame(skb->data) || + IsLegacyDataFrame(skb->data)) { + if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ + if (is_duplicate_packet(ieee, hdr)){ + goto rx_dropped; + } + } + } else { + PRX_TS_RECORD pRxTS = NULL; + if (GetTs(ieee, (PTS_COMMON_INFO*) &pRxTS, hdr->addr2, + (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { + if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && + (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { + goto rx_dropped; + } else { + pRxTS->RxLastFragNum = frag; + pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); + } + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); + goto rx_dropped; + } + } + if (type == RTLLIB_FTYPE_MGMT) { + if (bToOtherSTA) + goto rx_dropped; + if (rtllib_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + goto rx_dropped; + else + goto rx_exit; + } + if (type == RTLLIB_FTYPE_CTL) { + goto rx_dropped; + } + /* Data frame - extract src/dst addresses */ + switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { + case RTLLIB_FCTL_FROMDS: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr3, ETH_ALEN); + memcpy(bssid, hdr->addr2, ETH_ALEN); + break; + case RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr1, ETH_ALEN); + break; + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: + if (skb->len < RTLLIB_DATA_HDR4_LEN) + goto rx_dropped; + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr4, ETH_ALEN); + memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + break; + case 0: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr3, ETH_ALEN); + break; + } + + /* Filter frames from different BSS */ + if ((type != RTLLIB_FTYPE_CTL) && ((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) + && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { + goto rx_dropped; + } + + /* Filter packets sent by an STA that will be forwarded by AP */ + if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { + if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && + (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && + (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { + goto rx_dropped; + } + } + +#ifdef NOT_YET + if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + goto rx_dropped; + if (wds) { + skb->dev = dev = wds; + stats = hostap_get_stats(dev); + } + + if (ieee->iw_mode == IW_MODE_MASTER && !wds && + (fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) == RTLLIB_FCTL_FROMDS && + ieee->stadev && + memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { + /* Frame from BSSID of the AP for which we are a client */ + skb->dev = dev = ieee->stadev; + stats = hostap_get_stats(dev); + from_assoc_ap = 1; + } +#endif + + dev->last_rx = jiffies; + +#ifdef NOT_YET + if ((ieee->iw_mode == IW_MODE_MASTER || + ieee->iw_mode == IW_MODE_REPEAT) && + !from_assoc_ap) { + switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + wds != NULL)) { + case AP_RX_CONTINUE_NOT_AUTHORIZED: + frame_authorized = 0; + break; + case AP_RX_CONTINUE: + frame_authorized = 1; + break; + case AP_RX_DROP: + goto rx_dropped; + case AP_RX_EXIT: + goto rx_exit; + } + } +#endif + /* Nullfunc frames may have PS-bit set, so they must be passed to + * hostap_handle_sta_rx() before being dropped here. */ + if (stype != RTLLIB_STYPE_DATA && + stype != RTLLIB_STYPE_DATA_CFACK && + stype != RTLLIB_STYPE_DATA_CFPOLL && + stype != RTLLIB_STYPE_DATA_CFACKPOLL&& + stype != RTLLIB_STYPE_QOS_DATA + ) { + if (stype != RTLLIB_STYPE_NULLFUNC) + RTLLIB_DEBUG_DROP( + "RX: dropped data frame " + "with no data (type=0x%02x, " + "subtype=0x%02x, len=%d)\n", + type, stype, skb->len); + goto rx_dropped; + } + + if (skb->len == hdrlen){ + goto rx_dropped; + } + + { + /* network filter more precisely */ + switch (ieee->iw_mode) { + case IW_MODE_ADHOC: + /* packets from our adapter are dropped (echo) */ + if (!memcmp(hdr->addr2, dev->dev_addr, ETH_ALEN)) + goto rx_dropped; + + /* {broad,multi}cast packets to our BSSID go through */ + if (is_multicast_ether_addr(hdr->addr1)) { + if (!memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)) + break; + else + goto rx_dropped; + } + + /* packets not to our adapter, just discard it */ + if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { + if (bToOtherSTA) + break; + else + goto rx_dropped; + } + + break; + + case IW_MODE_INFRA: + /* packets from our adapter are dropped (echo) */ + if (!memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) + goto rx_dropped; + + /* {broad,multi}cast packets to our BSS go through */ + if (is_multicast_ether_addr(hdr->addr1)) { + if (!memcmp(hdr->addr2, ieee->current_network.bssid, ETH_ALEN)) + break; + else + goto rx_dropped; + } + + /* packets to our adapter go through */ + if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { + if (bToOtherSTA) + break; + else + goto rx_dropped; + } + + break; + } + + + } + + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) + && (ieee->polling)) { + if (WLAN_FC_MORE_DATA(fc)) { + /* more data bit is set, let's request a new frame from the AP */ + rtllib_sta_ps_send_pspoll_frame(ieee); + } else { + ieee->polling = false; + } + } + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (ieee->iw_mode == IW_MODE_ADHOC){ + psta = GetStaInfo(ieee, src); + if (NULL != psta) + psta->LastActiveTime = jiffies; + } +#endif + /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ + if ((!rx_stats->Decrypted)){ + ieee->need_sw_enc = 1; + } + + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && + ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { + printk("decrypt frame error\n"); + goto rx_dropped; + } + if (tmp_dump) { + printk("************after decrypt\n"); + dump_buf(skb->data,skb->len); + } + hdr = (struct rtllib_hdr_4addr *) skb->data; + + /* skb: hdr + (possibly fragmented) plaintext payload */ + if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) { + int flen; + struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr); + RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); + + if (!frag_skb) { + RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG, + "Rx cannot get skb from fragment " + "cache (morefrag=%d seq=%u frag=%u)\n", + (fc & RTLLIB_FCTL_MOREFRAGS) != 0, + WLAN_GET_SEQ_SEQ(sc), frag); + goto rx_dropped; + } + flen = skb->len; + if (frag != 0) + flen -= hdrlen; + + if (frag_skb->tail + flen > frag_skb->end) { + printk(KERN_WARNING "%s: host decrypted and " + "reassembled frame did not fit skb\n", + dev->name); + rtllib_frag_cache_invalidate(ieee, hdr); + goto rx_dropped; + } + + if (frag == 0) { + /* copy first fragment (including full headers) into + * beginning of the fragment cache skb */ + memcpy(skb_put(frag_skb, flen), skb->data, flen); + } else { + /* append frame payload to the end of the fragment + * cache skb */ + memcpy(skb_put(frag_skb, flen), skb->data + hdrlen, + flen); + } + dev_kfree_skb_any(skb); + skb = NULL; + + if (fc & RTLLIB_FCTL_MOREFRAGS) { + /* more fragments expected - leave the skb in fragment + * cache for now; it will be delivered to upper layers + * after all fragments have been received */ + goto rx_exit; + } + + /* this was the last fragment and the frame will be + * delivered, so remove skb from fragment cache */ + skb = frag_skb; + hdr = (struct rtllib_hdr_4addr *) skb->data; + rtllib_frag_cache_invalidate(ieee, hdr); + } + + /* skb: hdr + (possible reassembled) full MSDU payload; possibly still + * encrypted/authenticated */ + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && + rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) { + printk("==>decrypt msdu error\n"); + goto rx_dropped; + } + + ieee->LinkDetectInfo.NumRecvDataInPeriod++; + ieee->LinkDetectInfo.NumRxOkInPeriod++; + + hdr = (struct rtllib_hdr_4addr *) skb->data; + if ((!is_multicast_ether_addr(hdr->addr1)) && (!is_broadcast_ether_addr(hdr->addr1))) + unicast_packet = true; + if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep) { + if (/*ieee->ieee802_1x &&*/ + rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + +#ifdef CONFIG_RTLLIB_DEBUG + /* pass unencrypted EAPOL frames even if encryption is + * configured */ + struct eapol *eap = (struct eapol *)(skb->data + + 24); + RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); +#endif + } else { + RTLLIB_DEBUG_DROP( + "encryption configured, but RX " + "frame not encrypted (SA=" MAC_FMT ")\n", + MAC_ARG(hdr->addr2)); + goto rx_dropped; + } + } + +#ifdef CONFIG_RTLLIB_DEBUG + if (crypt && !(fc & RTLLIB_FCTL_WEP) && + rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + struct eapol *eap = (struct eapol *)(skb->data + + 24); + RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); + } +#endif + + if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep && + !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + RTLLIB_DEBUG_DROP( + "dropped unencrypted RX data " + "frame from " MAC_FMT + " (drop_unencrypted=1)\n", + MAC_ARG(hdr->addr2)); + goto rx_dropped; + } + if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) + && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1)) { + TID = Frame_QoSTID(skb->data); + SeqNum = WLAN_GET_SEQ_SEQ(sc); + GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true); + if (TID !=0 && TID !=3) + ieee->bis_any_nonbepkts = true; + } + /* skb: hdr + (possible reassembled) full plaintext payload */ + payload = skb->data + hdrlen; + rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); + if (rxb == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); + goto rx_dropped; + } + /* to parse amsdu packets */ + /* qos data packets & reserved bit is 1 */ + if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { + /* only to free rxb, and not submit the packets to upper layer */ + for (i =0; i < rxb->nr_subframes; i++) { + dev_kfree_skb(rxb->subframes[i]); + } + kfree(rxb); + rxb = NULL; + goto rx_dropped; + } +#if !defined(RTL8192SU) && !defined(RTL8192U) + if (unicast_packet) { + if (type == RTLLIB_FTYPE_DATA) { + if (ieee->bIsAggregateFrame) + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod+=rxb->nr_subframes; + else + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod++; + + if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) { + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { + if (ieee->LeisurePSLeave) + ieee->LeisurePSLeave(dev); + } + } + } + } +#endif + ieee->last_rx_ps_time = jiffies; + if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA ){ + for (i = 0; inr_subframes; i++) { + struct sk_buff *sub_skb = rxb->subframes[i]; + + if (sub_skb) { + /* convert hdr + possible LLC headers into Ethernet header */ + ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; + if (sub_skb->len >= 8 && + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and + * replace EtherType */ + skb_pull(sub_skb, SNAP_SIZE); + memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + } else { + u16 len; + /* Leave Ethernet header part of hdr and full payload */ + len = htons(sub_skb->len); + memcpy(skb_push(sub_skb, 2), &len, 2); + memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + } + + stats->rx_packets++; + stats->rx_bytes += sub_skb->len; + + if (is_multicast_ether_addr(dst)) { + stats->multicast++; + } + + /* Indicat the packets to upper layer */ + memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); + sub_skb->protocol = eth_type_trans(sub_skb, dev); + sub_skb->dev = dev; + sub_skb->dev->stats.rx_packets++; + sub_skb->dev->stats.rx_bytes += sub_skb->len; +#ifdef TCP_CSUM_OFFLOAD_RX + if ( rx_stats->tcp_csum_valid) + sub_skb->ip_summed = CHECKSUM_UNNECESSARY; + else + sub_skb->ip_summed = CHECKSUM_NONE; +#else + sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ +#endif + + netif_rx(sub_skb); + } + } + kfree(rxb); + rxb = NULL; + + } + else + { + RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__func__); +#ifdef TCP_CSUM_OFFLOAD_RX + rxb->tcp_csum_valid = rx_stats->tcp_csum_valid; +#endif + RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); + } +#ifndef JOHN_NOCPY + dev_kfree_skb(skb); +#endif + + rx_exit: +#ifdef NOT_YET + if (sta) + hostap_handle_sta_release(sta); +#endif + return 1; + + rx_dropped: + if (rxb != NULL) + { + kfree(rxb); + rxb = NULL; + } + stats->rx_dropped++; + + /* Returning 0 indicates to caller that we have not handled the SKB-- + * so it is still allocated and can be used again by underlying + * hardware as a DMA target */ + return 0; +} +#endif + +#define MGMT_FRAME_FIXED_PART_LENGTH 0x24 + +static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; + +/* +* Make ther structure we read from the beacon packet has +* the right values +*/ +static int rtllib_verify_qos_info(struct rtllib_qos_information_element + *info_element, int sub_type) +{ + + if (info_element->qui_subtype != sub_type) + return -1; + if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) + return -1; + if (info_element->qui_type != QOS_OUI_TYPE) + return -1; + if (info_element->version != QOS_VERSION_1) + return -1; + + return 0; +} + + +/* + * Parse a QoS parameter element + */ +static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info + *element_param, struct rtllib_info_element + *info_element) +{ + int ret = 0; + u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; + + if ((info_element == NULL) || (element_param == NULL)) + return -1; + + if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { + memcpy(element_param->info_element.qui, info_element->data, + info_element->len); + element_param->info_element.elementID = info_element->id; + element_param->info_element.length = info_element->len; + } else + ret = -1; + if (ret == 0) + ret = rtllib_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); + return ret; +} + +/* + * Parse a QoS information element + */ +static int rtllib_read_qos_info_element(struct + rtllib_qos_information_element + *element_info, struct rtllib_info_element + *info_element) +{ + int ret = 0; + u16 size = sizeof(struct rtllib_qos_information_element) - 2; + + if (element_info == NULL) + return -1; + if (info_element == NULL) + return -1; + + if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + memcpy(element_info->qui, info_element->data, + info_element->len); + element_info->elementID = info_element->id; + element_info->length = info_element->len; + } else + ret = -1; + + if (ret == 0) + ret = rtllib_verify_qos_info(element_info, + QOS_OUI_INFO_SUB_TYPE); + return ret; +} + + +/* + * Write QoS parameters from the ac parameters. + */ +static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm, + struct rtllib_qos_data *qos_data) +{ + struct rtllib_qos_ac_parameter *ac_params; + struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); + int rc = 0; + int i; + u8 aci; + u8 acm; + + qos_data->wmm_acm = 0; + for (i = 0; i < QOS_QUEUE_NUM; i++) { + ac_params = &(param_elm->ac_params_record[i]); + + aci = (ac_params->aci_aifsn & 0x60) >> 5; + acm = (ac_params->aci_aifsn & 0x10) >> 4; + + if (aci >= QOS_QUEUE_NUM) + continue; + switch (aci) { + case 1: + /* BIT(0) | BIT(3) */ + if (acm) + qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); + break; + case 2: + /* BIT(4) | BIT(5) */ + if (acm) + qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); + break; + case 3: + /* BIT(6) | BIT(7) */ + if (acm) + qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); + break; + case 0: + default: + /* BIT(1) | BIT(2) */ + if (acm) + qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); + break; + } + + qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; + + /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ + qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; + + qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; + + qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; + + qos_param->flag[aci] = + (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; + qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); + } + return rc; +} + +/* + * we have a generic data element which it may contain QoS information or + * parameters element. check the information element length to decide + * which type to read + */ +static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element + *info_element, + struct rtllib_network *network) +{ + int rc = 0; + struct rtllib_qos_information_element qos_info_element; + + rc = rtllib_read_qos_info_element(&qos_info_element, info_element); + + if (rc == 0) { + network->qos_data.param_count = qos_info_element.ac_info & 0x0F; + network->flags |= NETWORK_HAS_QOS_INFORMATION; + } else { + struct rtllib_qos_parameter_info param_element; + + rc = rtllib_read_qos_param_element(¶m_element, + info_element); + if (rc == 0) { + rtllib_qos_convert_ac_to_parameters(¶m_element, + &(network->qos_data)); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; + } + } + + if (rc == 0) { + RTLLIB_DEBUG_QOS("QoS is supported\n"); + network->qos_data.supported = 1; + } + return rc; +} + +#ifdef CONFIG_RTLLIB_DEBUG +#define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x + +static const char *get_info_element_string(u16 id) +{ + switch (id) { + MFIE_STRING(SSID); + MFIE_STRING(RATES); + MFIE_STRING(FH_SET); + MFIE_STRING(DS_SET); + MFIE_STRING(CF_SET); + MFIE_STRING(TIM); + MFIE_STRING(IBSS_SET); + MFIE_STRING(COUNTRY); + MFIE_STRING(HOP_PARAMS); + MFIE_STRING(HOP_TABLE); + MFIE_STRING(REQUEST); + MFIE_STRING(CHALLENGE); + MFIE_STRING(POWER_CONSTRAINT); + MFIE_STRING(POWER_CAPABILITY); + MFIE_STRING(TPC_REQUEST); + MFIE_STRING(TPC_REPORT); + MFIE_STRING(SUPP_CHANNELS); + MFIE_STRING(CSA); + MFIE_STRING(MEASURE_REQUEST); + MFIE_STRING(MEASURE_REPORT); + MFIE_STRING(QUIET); + MFIE_STRING(IBSS_DFS); + MFIE_STRING(RSN); + MFIE_STRING(RATES_EX); + MFIE_STRING(GENERIC); + MFIE_STRING(QOS_PARAMETER); + default: + return "UNKNOWN"; + } +} +#endif + +#ifdef ENABLE_DOT11D +static inline void rtllib_extract_country_ie( + struct rtllib_device *ieee, + struct rtllib_info_element *info_element, + struct rtllib_network *network, + u8 * addr2) +{ + if (IS_DOT11D_ENABLE(ieee)) { + if (info_element->len!= 0) { + memcpy(network->CountryIeBuf, info_element->data, info_element->len); + network->CountryIeLen = info_element->len; + + if (!IS_COUNTRY_IE_VALID(ieee)) + { + if ((rtllib_act_scanning(ieee,false) == true) && (ieee->FirstIe_InScan == 1)) + printk("Received beacon ContryIE, SSID: <%s>\n",network->ssid); + Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); + } + } + + if (IS_EQUAL_CIE_SRC(ieee, addr2)) { + UPDATE_CIE_WATCHDOG(ieee); + } + } + +} +#endif + +int rtllib_parse_info_param(struct rtllib_device *ieee, + struct rtllib_info_element *info_element, + u16 length, + struct rtllib_network *network, + struct rtllib_rx_stats *stats) +{ + u8 i; + short offset; + u16 tmp_htcap_len=0; + u16 tmp_htinfo_len=0; + u16 ht_realtek_agg_len=0; + u8 ht_realtek_agg_buf[MAX_IE_LEN]; +#ifdef CONFIG_RTLLIB_DEBUG + char rates_str[64]; + char *p; +#endif + while (length >= sizeof(*info_element)) { + if (sizeof(*info_element) + info_element->len > length) { + RTLLIB_DEBUG_MGMT("Info elem: parse failed: " + "info_element->len + 2 > left : " + "info_element->len+2=%zd left=%d, id=%d.\n", + info_element->len + + sizeof(*info_element), + length, info_element->id); + /* We stop processing but don't return an error here + * because some misbehaviour APs break this rule. ie. + * Orinoco AP1000. */ + break; + } + + switch (info_element->id) { + case MFIE_TYPE_SSID: + if (rtllib_is_empty_essid(info_element->data, + info_element->len)) { + network->flags |= NETWORK_EMPTY_ESSID; + break; + } + + network->ssid_len = min(info_element->len, + (u8) IW_ESSID_MAX_SIZE); + memcpy(network->ssid, info_element->data, network->ssid_len); + if (network->ssid_len < IW_ESSID_MAX_SIZE) + memset(network->ssid + network->ssid_len, 0, + IW_ESSID_MAX_SIZE - network->ssid_len); + + RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n", + network->ssid, network->ssid_len); + break; + + case MFIE_TYPE_RATES: +#ifdef CONFIG_RTLLIB_DEBUG + p = rates_str; +#endif + network->rates_len = min(info_element->len, + MAX_RATES_LENGTH); + for (i = 0; i < network->rates_len; i++) { + network->rates[i] = info_element->data[i]; +#ifdef CONFIG_RTLLIB_DEBUG + p += snprintf(p, sizeof(rates_str) - + (p - rates_str), "%02X ", + network->rates[i]); +#endif + if (rtllib_is_ofdm_rate + (info_element->data[i])) { + network->flags |= NETWORK_HAS_OFDM; + if (info_element->data[i] & + RTLLIB_BASIC_RATE_MASK) + network->flags &= + ~NETWORK_HAS_CCK; + } + + if (rtllib_is_cck_rate + (info_element->data[i])) { + network->flags |= NETWORK_HAS_CCK; + } + } + + RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n", + rates_str, network->rates_len); + break; + + case MFIE_TYPE_RATES_EX: +#ifdef CONFIG_RTLLIB_DEBUG + p = rates_str; +#endif + network->rates_ex_len = min(info_element->len, + MAX_RATES_EX_LENGTH); + for (i = 0; i < network->rates_ex_len; i++) { + network->rates_ex[i] = info_element->data[i]; +#ifdef CONFIG_RTLLIB_DEBUG + p += snprintf(p, sizeof(rates_str) - + (p - rates_str), "%02X ", + network->rates[i]); +#endif + if (rtllib_is_ofdm_rate + (info_element->data[i])) { + network->flags |= NETWORK_HAS_OFDM; + if (info_element->data[i] & + RTLLIB_BASIC_RATE_MASK) + network->flags &= + ~NETWORK_HAS_CCK; + } + } + + RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n", + rates_str, network->rates_ex_len); + break; + + case MFIE_TYPE_DS_SET: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n", + info_element->data[0]); + network->channel = info_element->data[0]; + break; + + case MFIE_TYPE_FH_SET: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n"); + break; + + case MFIE_TYPE_CF_SET: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n"); + break; + + case MFIE_TYPE_TIM: + if (info_element->len < 4) + break; + + network->tim.tim_count = info_element->data[0]; + network->tim.tim_period = info_element->data[1]; + + network->dtim_period = info_element->data[1]; + if (ieee->state != RTLLIB_LINKED) + break; + network->last_dtim_sta_time[0] = jiffies; + network->last_dtim_sta_time[1] = stats->mac_time[1]; + + network->dtim_data = RTLLIB_DTIM_VALID; + + + if (info_element->data[2] & 1) + network->dtim_data |= RTLLIB_DTIM_MBCAST; + +#if 1 + offset = (info_element->data[2] >> 1)*2; + + + if (ieee->assoc_id < 8*offset || + ieee->assoc_id > 8*(offset + info_element->len -3)) + + break; + + offset = (ieee->assoc_id / 8) - offset; + if (info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) + network->dtim_data |= RTLLIB_DTIM_UCAST; +#else + { + u16 numSta = 0; + u16 offset_byte = 0; + u16 offset_bit = 0; + + numSta = (info_element->data[2] &0xFE)*8; + + if (ieee->assoc_id < numSta || + ieee->assoc_id > (numSta + (info_element->len -3)*8)) + break; + + offset = ieee->assoc_id - numSta; + offset_byte = offset / 8; + offset_bit = offset % 8; + if (info_element->data[3+offset_byte] & (0x01<dtim_data |= RTLLIB_DTIM_UCAST; + } +#endif + + network->listen_interval = network->dtim_period; + break; + + case MFIE_TYPE_ERP: + network->erp_value = info_element->data[0]; + network->flags |= NETWORK_HAS_ERP_VALUE; + RTLLIB_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n", + network->erp_value); + break; + case MFIE_TYPE_IBSS_SET: + network->atim_window = info_element->data[0]; + RTLLIB_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n", + network->atim_window); + break; + + case MFIE_TYPE_CHALLENGE: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n"); + break; + + case MFIE_TYPE_GENERIC: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n", + info_element->len); + if (!rtllib_parse_qos_info_param_IE(info_element, + network)) + break; + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x01) { + network->wpa_ie_len = min(info_element->len + 2, + MAX_WPA_IE_LEN); + memcpy(network->wpa_ie, info_element, + network->wpa_ie_len); + break; + } + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) + network->Turbo_Enable = 1; + + if (tmp_htcap_len == 0) { + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x033) { + + tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); + if (tmp_htcap_len != 0){ + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ + sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + } + } + if (tmp_htcap_len != 0){ + network->bssht.bdSupportHT = true; + network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + }else{ + network->bssht.bdSupportHT = false; + network->bssht.bdHT1R = false; + } + } + + + if (tmp_htinfo_len == 0){ + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034){ + + tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); + if (tmp_htinfo_len != 0){ + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + if (tmp_htinfo_len){ + network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ + sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); + } + + } + + } + } + + if (ieee->aggregation){ + if (network->bssht.bdSupportHT){ + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02){ + + ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN); + memcpy(ht_realtek_agg_buf,info_element->data,info_element->len); + + } + if (ht_realtek_agg_len >= 5){ + network->realtek_cap_exit = true; + network->bssht.bdRT2RTAggregation = true; + + if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) + network->bssht.bdRT2RTLongSlotTime = true; + + if ((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) + { + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; + } + } + } + if (ht_realtek_agg_len >= 5){ + if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; + } + } + + { + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x05 && + info_element->data[2] == 0xb5) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf7) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x10 && + info_element->data[2] == 0x18)){ + + network->broadcom_cap_exist = true; + + } + } + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0c && + info_element->data[2] == 0x43) + { + network->ralink_cap_exist = true; + } + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x03 && + info_element->data[2] == 0x7f) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x13 && + info_element->data[2] == 0x74)) + { + network->atheros_cap_exist = true; + } + + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0x43) ) + { + network->marvell_cap_exist = true; + } + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96) + { + network->cisco_cap_exist = true; + } + + + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf5) + { + network->airgo_cap_exist = true; + } + + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) + { + if (info_element->len == 6) + { + memcpy(network->CcxRmState, &info_element[4], 2); + if (network->CcxRmState[0] != 0) + { + network->bCcxRmEnable = true; + } + else + network->bCcxRmEnable = false; + network->MBssidMask = network->CcxRmState[1] & 0x07; + if (network->MBssidMask != 0) + { + network->bMBssidValid = true; + network->MBssidMask = 0xff << (network->MBssidMask); + memcpy(network->MBssid, network->bssid, ETH_ALEN); + network->MBssid[5] &= network->MBssidMask; + } + else + { + network->bMBssidValid = false; + } + } + else + { + network->bCcxRmEnable = false; + } + } + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x03) + { + if (info_element->len == 5) + { + network->bWithCcxVerNum = true; + network->BssCcxVerNumber = info_element->data[4]; + } + else + { + network->bWithCcxVerNum = false; + network->BssCcxVerNumber = 0; + } + } + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x04) + { + RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", + info_element->len); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + network->wzc_ie_len = min(info_element->len+2, + MAX_WZC_IE_LEN); + memcpy(network->wzc_ie, info_element, + network->wzc_ie_len); +#endif + } + break; + + case MFIE_TYPE_RSN: + RTLLIB_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n", + info_element->len); + network->rsn_ie_len = min(info_element->len + 2, + MAX_WPA_IE_LEN); + memcpy(network->rsn_ie, info_element, + network->rsn_ie_len); + break; + + case MFIE_TYPE_HT_CAP: + RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", + info_element->len); + tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); + if (tmp_htcap_len != 0){ + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ + sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + + network->bssht.bdSupportHT = true; + network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + + network->bssht.bdBandWidth = (HT_CHANNEL_WIDTH)(((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->ChlWidth); + } + else{ + network->bssht.bdSupportHT = false; + network->bssht.bdHT1R = false; + network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20 ; + } + break; + + + case MFIE_TYPE_HT_INFO: + RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", + info_element->len); + tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); + if (tmp_htinfo_len){ + network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; + network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ + sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); + } + break; + + case MFIE_TYPE_AIRONET: + RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", + info_element->len); + if (info_element->len >IE_CISCO_FLAG_POSITION) + { + network->bWithAironetIE = true; + + if ( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || + (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) + { + network->bCkipSupported = true; + } + else + { + network->bCkipSupported = false; + } + } + else + { + network->bWithAironetIE = false; + network->bCkipSupported = false; + } + break; + case MFIE_TYPE_QOS_PARAMETER: + printk(KERN_ERR + "QoS Error need to parse QOS_PARAMETER IE\n"); + break; + +#ifdef ENABLE_DOT11D + case MFIE_TYPE_COUNTRY: + RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", + info_element->len); + rtllib_extract_country_ie(ieee, info_element, network, network->bssid); + break; +#endif +/* TODO */ + default: + RTLLIB_DEBUG_MGMT + ("Unsupported info element: %s (%d)\n", + get_info_element_string(info_element->id), + info_element->id); + break; + } + + length -= sizeof(*info_element) + info_element->len; + info_element = + (struct rtllib_info_element *)&info_element-> + data[info_element->len]; + } + + if (!network->atheros_cap_exist && !network->broadcom_cap_exist && + !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation) + { + network->unknown_cap_exist = true; + } + else + { + network->unknown_cap_exist = false; + } + return 0; +} + +static inline u8 rtllib_SignalStrengthTranslate( + u8 CurrSS + ) +{ + u8 RetSS; + + if (CurrSS >= 71 && CurrSS <= 100) + { + RetSS = 90 + ((CurrSS - 70) / 3); + } + else if (CurrSS >= 41 && CurrSS <= 70) + { + RetSS = 78 + ((CurrSS - 40) / 3); + } + else if (CurrSS >= 31 && CurrSS <= 40) + { + RetSS = 66 + (CurrSS - 30); + } + else if (CurrSS >= 21 && CurrSS <= 30) + { + RetSS = 54 + (CurrSS - 20); + } + else if (CurrSS >= 5 && CurrSS <= 20) + { + RetSS = 42 + (((CurrSS - 5) * 2) / 3); + } + else if (CurrSS == 4) + { + RetSS = 36; + } + else if (CurrSS == 3) + { + RetSS = 27; + } + else if (CurrSS == 2) + { + RetSS = 18; + } + else if (CurrSS == 1) + { + RetSS = 9; + } + else + { + RetSS = CurrSS; + } + + + + return RetSS; +} + +long rtllib_translate_todbm(u8 signal_strength_index ) +{ + long signal_power; + + signal_power = (long)((signal_strength_index + 1) >> 1); + signal_power -= 95; + + return signal_power; +} + +static inline int rtllib_network_init( + struct rtllib_device *ieee, + struct rtllib_probe_response *beacon, + struct rtllib_network *network, + struct rtllib_rx_stats *stats) +{ +#ifdef CONFIG_RTLLIB_DEBUG +#endif + + /* + network->qos_data.active = 0; + network->qos_data.supported = 0; + network->qos_data.param_count = 0; + network->qos_data.old_param_count = 0; + */ + memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data)); + + /* Pull out fixed field data */ + memcpy(network->bssid, beacon->header.addr3, ETH_ALEN); + network->capability = le16_to_cpu(beacon->capability); + network->last_scanned = jiffies; + network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]); + network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]); + network->beacon_interval = le32_to_cpu(beacon->beacon_interval); + /* Where to pull this? beacon->listen_interval;*/ + network->listen_interval = 0x0A; + network->rates_len = network->rates_ex_len = 0; + network->last_associate = 0; + network->ssid_len = 0; + network->hidden_ssid_len = 0; + memset(network->hidden_ssid, 0, sizeof(network->hidden_ssid)); + network->flags = 0; + network->atim_window = 0; + network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? + 0x3 : 0x0; + network->berp_info_valid = false; + network->broadcom_cap_exist = false; + network->ralink_cap_exist = false; + network->atheros_cap_exist = false; + network->cisco_cap_exist = false; + network->unknown_cap_exist = false; + network->realtek_cap_exit = false; + network->marvell_cap_exist = false; + network->airgo_cap_exist = false; + network->Turbo_Enable = 0; + network->SignalStrength = stats->SignalStrength; + network->RSSI = stats->SignalStrength; +#ifdef ENABLE_DOT11D + network->CountryIeLen = 0; + memset(network->CountryIeBuf, 0, MAX_IE_LEN); +#endif + HTInitializeBssDesc(&network->bssht); + if (stats->freq == RTLLIB_52GHZ_BAND) { + /* for A band (No DS info) */ + network->channel = stats->received_channel; + } else + network->flags |= NETWORK_HAS_CCK; + + network->wpa_ie_len = 0; + network->rsn_ie_len = 0; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + network->wzc_ie_len = 0; +#endif + + if (rtllib_parse_info_param(ieee, + beacon->info_element, + (stats->len - sizeof(*beacon)), + network, + stats)) + return 1; + + network->mode = 0; + if (stats->freq == RTLLIB_52GHZ_BAND) + network->mode = IEEE_A; + else { + if (network->flags & NETWORK_HAS_OFDM) + network->mode |= IEEE_G; + if (network->flags & NETWORK_HAS_CCK) + network->mode |= IEEE_B; + } + + if (network->mode == 0) { + RTLLIB_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' " + "network.\n", + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid)); + return 1; + } + + if (network->bssht.bdSupportHT){ + if (network->mode == IEEE_A) + network->mode = IEEE_N_5G; + else if (network->mode & (IEEE_G | IEEE_B)) + network->mode = IEEE_N_24G; + } + if (rtllib_is_empty_essid(network->ssid, network->ssid_len)) + network->flags |= NETWORK_EMPTY_ESSID; + stats->signal = 30 + (stats->SignalStrength * 70) / 100; + stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) -25; + + memcpy(&network->stats, stats, sizeof(network->stats)); + + return 0; +} + +static inline int is_same_network(struct rtllib_network *src, + struct rtllib_network *dst, u8 ssidbroad) +{ + /* A network is only a duplicate if the channel, BSSID, ESSID + * and the capability field (in particular IBSS and BSS) all match. + * We treat all with the same BSSID and channel + * as one network */ + return + (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && + (src->channel == dst->channel) && + !memcmp(src->bssid, dst->bssid, ETH_ALEN) && + (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (!ssidbroad)) && + ((src->capability & WLAN_CAPABILITY_IBSS) == + (dst->capability & WLAN_CAPABILITY_IBSS)) && + ((src->capability & WLAN_CAPABILITY_ESS) == + (dst->capability & WLAN_CAPABILITY_ESS))); +} + +static inline void update_ibss_network(struct rtllib_network *dst, + struct rtllib_network *src) +{ + memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats)); + dst->last_scanned = jiffies; +} + + +static inline void update_network(struct rtllib_network *dst, + struct rtllib_network *src) +{ + int qos_active; + u8 old_param; + + memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats)); + dst->capability = src->capability; + memcpy(dst->rates, src->rates, src->rates_len); + dst->rates_len = src->rates_len; + memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); + dst->rates_ex_len = src->rates_ex_len; + if (src->ssid_len > 0) + { + if (dst->ssid_len == 0) + { + memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid)); + dst->hidden_ssid_len = src->ssid_len; + memcpy(dst->hidden_ssid, src->ssid, src->ssid_len); + }else{ + memset(dst->ssid, 0, dst->ssid_len); + dst->ssid_len = src->ssid_len; + memcpy(dst->ssid, src->ssid, src->ssid_len); + } + } + dst->mode = src->mode; + dst->flags = src->flags; + dst->time_stamp[0] = src->time_stamp[0]; + dst->time_stamp[1] = src->time_stamp[1]; + if (src->flags & NETWORK_HAS_ERP_VALUE) + { + dst->erp_value = src->erp_value; + dst->berp_info_valid = src->berp_info_valid = true; + } + dst->beacon_interval = src->beacon_interval; + dst->listen_interval = src->listen_interval; + dst->atim_window = src->atim_window; + dst->dtim_period = src->dtim_period; + dst->dtim_data = src->dtim_data; + dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; + dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; + memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); + + dst->bssht.bdSupportHT = src->bssht.bdSupportHT; + dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; + dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; + memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); + dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen; + memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen); + dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer; + dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime; + dst->broadcom_cap_exist = src->broadcom_cap_exist; + dst->ralink_cap_exist = src->ralink_cap_exist; + dst->atheros_cap_exist = src->atheros_cap_exist; + dst->realtek_cap_exit = src->realtek_cap_exit; + dst->marvell_cap_exist = src->marvell_cap_exist; + dst->cisco_cap_exist = src->cisco_cap_exist; + dst->airgo_cap_exist = src->airgo_cap_exist; + dst->unknown_cap_exist = src->unknown_cap_exist; + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); + dst->wpa_ie_len = src->wpa_ie_len; + memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); + dst->rsn_ie_len = src->rsn_ie_len; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + memcpy(dst->wzc_ie, src->wzc_ie, src->wzc_ie_len); + dst->wzc_ie_len = src->wzc_ie_len; +#endif + + dst->last_scanned = jiffies; + /* qos related parameters */ + qos_active = dst->qos_data.active; + old_param = dst->qos_data.param_count; + dst->qos_data.supported = src->qos_data.supported; + if (dst->flags & NETWORK_HAS_QOS_PARAMETERS) + memcpy(&dst->qos_data, &src->qos_data, sizeof(struct rtllib_qos_data)); + if (dst->qos_data.supported == 1) { + if (dst->ssid_len) + RTLLIB_DEBUG_QOS + ("QoS the network %s is QoS supported\n", + dst->ssid); + else + RTLLIB_DEBUG_QOS + ("QoS the network is QoS supported\n"); + } + dst->qos_data.active = qos_active; + dst->qos_data.old_param_count = old_param; + + /* dst->last_associate is not overwritten */ + dst->wmm_info = src->wmm_info; + if (src->wmm_param[0].ac_aci_acm_aifsn|| \ + src->wmm_param[1].ac_aci_acm_aifsn|| \ + src->wmm_param[2].ac_aci_acm_aifsn|| \ + src->wmm_param[1].ac_aci_acm_aifsn) { + memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); + } + + dst->SignalStrength = src->SignalStrength; + dst->RSSI = src->RSSI; + dst->Turbo_Enable = src->Turbo_Enable; + +#ifdef ENABLE_DOT11D + dst->CountryIeLen = src->CountryIeLen; + memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen); +#endif + + dst->bWithAironetIE = src->bWithAironetIE; + dst->bCkipSupported = src->bCkipSupported; + memcpy(dst->CcxRmState,src->CcxRmState,2); + dst->bCcxRmEnable = src->bCcxRmEnable; + dst->MBssidMask = src->MBssidMask; + dst->bMBssidValid = src->bMBssidValid; + memcpy(dst->MBssid,src->MBssid,6); + dst->bWithCcxVerNum = src->bWithCcxVerNum; + dst->BssCcxVerNumber = src->BssCcxVerNumber; + +} +static inline int is_beacon(__le16 fc) +{ + return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); +} + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) +u8 AsocEntry_ComputeSum(u8 *paddr) +{ + u32 sum; + + sum = paddr[0]+ + paddr[1]+ + paddr[2]+ + paddr[3]+ + paddr[4]+ + paddr[5]; + + return (u8)(sum % PEER_MAX_ASSOC); +} +u8 AsocEntry_AssignAvailableAID(struct rtllib_device *ieee, u8 *paddr) +{ + int i; + + for (i = 0; i < PEER_MAX_ASSOC; i++) + { + if (ieee->AvailableAIDTable[i] == 99) + { + ieee->AvailableAIDTable[i] = AsocEntry_ComputeSum(paddr); + return i+1; + } + } + + return 1; +} + +void InitStaInfo(struct rtllib_device *ieee,int index) +{ + int idx = index; + ieee->peer_assoc_list[idx]->StaDataRate = 0; + ieee->peer_assoc_list[idx]->StaSS = 0; + ieee->peer_assoc_list[idx]->RetryFrameCnt = 0; + ieee->peer_assoc_list[idx]->NoRetryFrameCnt = 0; + ieee->peer_assoc_list[idx]->LastRetryCnt = 0; + ieee->peer_assoc_list[idx]->LastNoRetryCnt = 0; + ieee->peer_assoc_list[idx]->AvgRetryRate = 0; + ieee->peer_assoc_list[idx]->LastRetryRate = 0; + ieee->peer_assoc_list[idx]->txRateIndex = 11; + ieee->peer_assoc_list[idx]->APDataRate = 0x2; + ieee->peer_assoc_list[idx]->ForcedDataRate = 0x2; + +} +static u8 IsStaInfoExist(struct rtllib_device *ieee, u8 *addr) +{ + int k=0; + struct sta_info * psta = NULL; + u8 sta_idx = PEER_MAX_ASSOC; + + for (k=0; kpeer_assoc_list[k]; + if (NULL != psta) + { + if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0) + { + sta_idx = k; + break; + } + } + } + return sta_idx; +} +static u8 GetFreeStaInfoIdx(struct rtllib_device *ieee, u8 *addr) +{ + int k = 0; + while((ieee->peer_assoc_list[k] != NULL) && (k < PEER_MAX_ASSOC)) + k++; + printk("%s: addr:"MAC_FMT" index: %d\n", __func__, MAC_ARG(addr), k); + return k; +} +struct sta_info *GetStaInfo(struct rtllib_device *ieee, u8 *addr) +{ + int k=0; + struct sta_info * psta = NULL; + struct sta_info * psta_find = NULL; + + for (k=0; kpeer_assoc_list[k]; + if (NULL != psta) + { + if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0) + { + psta_find = psta; + break; + } + } + } + return psta_find; +} +void DelStaInfoList(struct rtllib_device *ieee) +{ + int idx = 0; + struct sta_info * AsocEntry = NULL; + + atomic_set(&ieee->AsocEntryNum, 0); + for (idx=0; idxpeer_assoc_list[idx]; + if (NULL != AsocEntry){ + kfree(AsocEntry); + ieee->peer_assoc_list[idx] = NULL; + } + ieee->AvailableAIDTable[idx] = 99; + } +} +void DelStaInfo(struct rtllib_device *ieee, u8 *addr) +{ + struct sta_info * psta = NULL; + int k=0; + + for (k=0; kpeer_assoc_list[k]; + if (NULL != psta){ + if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0){ + if (psta->aid > 0 && psta->aid-1 < PEER_MAX_ASSOC) + ieee->AvailableAIDTable[psta->aid-1] = 99; + else + printk("%s(): clear non-existing entry AID\n", __func__); + + kfree(psta); + ieee->peer_assoc_list[k] = NULL; + atomic_dec(&ieee->AsocEntryNum); + } + } + } +} +void IbssAgeFunction(struct rtllib_device *ieee) +{ + struct sta_info* AsocEntry = NULL; + int idx; + unsigned long CurrentTime; + signed long TimeDifference; + struct rtllib_network *target; + + CurrentTime = jiffies; + + for (idx = 0; idx < PEER_MAX_ASSOC; idx++) + { + AsocEntry = ieee->peer_assoc_list[idx]; + if (AsocEntry) + { + TimeDifference = jiffies_to_msecs(CurrentTime - AsocEntry->LastActiveTime); + + if (TimeDifference > 20000) + { + printk("IbssAgeFunction(): "MAC_FMT" timeout\n", MAC_ARG(AsocEntry->macaddr)); + kfree(AsocEntry); + ieee->peer_assoc_list[idx] = NULL; + atomic_dec(&ieee->AsocEntryNum); + + if (atomic_read(&ieee->AsocEntryNum) == 0){ + + down(&ieee->wx_sem); + rtllib_stop_protocol(ieee,true); + + list_for_each_entry(target, &ieee->network_list, list) { + if (is_same_network(target, &ieee->current_network,(target->ssid_len?1:0))){ + printk("delete sta of previous Ad-hoc\n"); + list_del(&target->list); + break; + } + } + + rtllib_start_protocol(ieee); + up(&ieee->wx_sem); + } + } + } + } + +#ifdef TO_DO_LIST + if (AsocEntry_AnyStationAssociated(pMgntInfo)==false) + DrvIFIndicateDisassociation(Adapter, unspec_reason); + + if (pMgntInfo->dot11CurrentWirelessMode == WIRELESS_MODE_G || + (IS_WIRELESS_MODE_N_24G(Adapter) && pMgntInfo->pHTInfo->bCurSuppCCK) ) + { + if (nBModeStaCnt == 0) + { + pMgntInfo->bUseProtection = false; + ActUpdate_mCapInfo(Adapter, pMgntInfo->mCap); + } + } + + if (IS_WIRELESS_MODE_N_24G(Adapter) || IS_WIRELESS_MODE_N_5G(Adapter) ) + { + if (nLegacyStaCnt > 0) + { + pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_MIXED; + } + else + { + if ((pMgntInfo->pHTInfo->bCurBW40MHz) && (n20MHzStaCnt > 0)) + pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_40MHZ_PROTECT; + else + pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_NO_PROTECT; + + } + } + + if (IS_WIRELESS_MODE_G(Adapter) || + (IS_WIRELESS_MODE_N_24G(Adapter) && pMgntInfo->pHTInfo->bCurSuppCCK)) + { + if (pMgntInfo->bUseProtection) + { + u8 CckRate[4] = { MGN_1M, MGN_2M, MGN_5_5M, MGN_11M }; + OCTET_STRING osCckRate; + FillOctetString(osCckRate, CckRate, 4); + FilterSupportRate(pMgntInfo->mBrates, &osCckRate, false); + Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_BASIC_RATE, (pu1Byte)&osCckRate); + } + else + { + Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_BASIC_RATE, (pu1Byte)(&pMgntInfo->mBrates) ); + } + } +#endif +} +#endif + +static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) +{ + if (MAX_CHANNEL_NUMBER < channel) { + printk("%s(): Invalid Channel\n", __func__); + return 0; + } + + if (rtllib->active_channel_map[channel] == 2) + return 1; + + return 0; +} + +int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) +{ + if (MAX_CHANNEL_NUMBER < channel) { + printk("%s(): Invalid Channel\n", __func__); + return 0; + } + if (rtllib->active_channel_map[channel] > 0) + return 1; + + return 0; +} + + +static inline void rtllib_process_probe_response( + struct rtllib_device *ieee, + struct rtllib_probe_response *beacon, + struct rtllib_rx_stats *stats) +{ + struct rtllib_network *target; + struct rtllib_network *oldest = NULL; +#ifdef CONFIG_RTLLIB_DEBUG + struct rtllib_info_element *info_element = &beacon->info_element[0]; +#endif + unsigned long flags; + short renew; +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) + struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); +#else + struct rtllib_network *network = kmalloc(sizeof(*network), GFP_ATOMIC); + memset(network,0,sizeof(*network)); +#endif + + if (!network) { + return; + } + + RTLLIB_DEBUG_SCAN( + "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + escape_essid(info_element->data, info_element->len), + MAC_ARG(beacon->header.addr3), + (beacon->capability & (1<<0xf)) ? '1' : '0', + (beacon->capability & (1<<0xe)) ? '1' : '0', + (beacon->capability & (1<<0xd)) ? '1' : '0', + (beacon->capability & (1<<0xc)) ? '1' : '0', + (beacon->capability & (1<<0xb)) ? '1' : '0', + (beacon->capability & (1<<0xa)) ? '1' : '0', + (beacon->capability & (1<<0x9)) ? '1' : '0', + (beacon->capability & (1<<0x8)) ? '1' : '0', + (beacon->capability & (1<<0x7)) ? '1' : '0', + (beacon->capability & (1<<0x6)) ? '1' : '0', + (beacon->capability & (1<<0x5)) ? '1' : '0', + (beacon->capability & (1<<0x4)) ? '1' : '0', + (beacon->capability & (1<<0x3)) ? '1' : '0', + (beacon->capability & (1<<0x2)) ? '1' : '0', + (beacon->capability & (1<<0x1)) ? '1' : '0', + (beacon->capability & (1<<0x0)) ? '1' : '0'); + + if (rtllib_network_init(ieee, beacon, network, stats)) { + RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", + escape_essid(info_element->data, + info_element->len), + MAC_ARG(beacon->header.addr3), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); + goto free_network; + } + + + if (!IsLegalChannel(ieee, network->channel)) + goto free_network; + + if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP) { + if (IsPassiveChannel(ieee, network->channel)) { + printk("GetScanInfo(): For Global Domain, " + "filter probe response at channel(%d).\n", network->channel); + goto free_network; + } + } + + /* The network parsed correctly -- so now we scan our known networks + * to see if we can find it in our list. + * + * NOTE: This search is definitely not optimized. Once its doing + * the "right thing" we'll optimize it for efficiency if + * necessary */ + + /* Search for this entry in the list and update it if it is + * already there. */ + + spin_lock_irqsave(&ieee->lock, flags); +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (is_beacon(beacon->header.frame_ctl)){ + if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->state == RTLLIB_LINKED)) + { + if ((network->ssid_len == ieee->current_network.ssid_len) + && (!memcmp(network->ssid,ieee->current_network.ssid,ieee->current_network.ssid_len)) + && (network->channel == ieee->current_network.channel) + && (ieee->current_network.channel > 0) + && (ieee->current_network.channel <= 14)) + { + if (!memcmp(ieee->current_network.bssid,network->bssid,6)) + { + int idx = 0; + struct rtllib_hdr_3addr* header = NULL; + int idx_exist = 0; + if (timer_pending(&ieee->ibss_wait_timer)) + del_timer_sync(&ieee->ibss_wait_timer); + header = (struct rtllib_hdr_3addr*)&(beacon->header); + idx_exist = IsStaInfoExist(ieee,header->addr2); + if (idx_exist >= PEER_MAX_ASSOC) { + idx = GetFreeStaInfoIdx(ieee, header->addr2); + } else { + ieee->peer_assoc_list[idx_exist]->LastActiveTime = jiffies; + goto no_alloc; + } + if (idx >= PEER_MAX_ASSOC - 1) { + printk("\n%s():ERR!!!Buffer overflow - could not append!!!",__func__); + goto free_network; + } else { + ieee->peer_assoc_list[idx] = (struct sta_info *)kmalloc(sizeof(struct sta_info), GFP_ATOMIC); + memset(ieee->peer_assoc_list[idx], 0, sizeof(struct sta_info)); + ieee->peer_assoc_list[idx]->LastActiveTime = jiffies; + memcpy(ieee->peer_assoc_list[idx]->macaddr,header->addr2,ETH_ALEN); + ieee->peer_assoc_list[idx]->ratr_index = 8; + InitStaInfo(ieee,idx); + atomic_inc(&ieee->AsocEntryNum); + ieee->peer_assoc_list[idx]->aid = AsocEntry_AssignAvailableAID(ieee, ieee->peer_assoc_list[idx]->macaddr); + ieee->check_ht_cap(ieee->dev,ieee->peer_assoc_list[idx],network); + queue_delayed_work_rsl(ieee->wq, &ieee->update_assoc_sta_info_wq, 0); + ieee->Adhoc_InitRateAdaptive(ieee->dev,ieee->peer_assoc_list[idx]); + } + } + } + } + } + if (ieee->iw_mode == IW_MODE_ADHOC){ + if ((network->ssid_len == ieee->current_network.ssid_len) + && (!memcmp(network->ssid,ieee->current_network.ssid,ieee->current_network.ssid_len)) + && (network->capability & WLAN_CAPABILITY_IBSS) + && (ieee->state == RTLLIB_LINKED_SCANNING)) + { + if (memcmp(ieee->current_network.bssid,network->bssid,6)) + { + printk("%s(): SSID matched but BSSID mismatched.\n",__func__); + + ieee->TargetTsf = beacon->time_stamp[1]; + ieee->TargetTsf <<= 32; + ieee->TargetTsf |= beacon->time_stamp[0]; + + ieee->CurrTsf = stats->TimeStampLow; + + queue_delayed_work_rsl(ieee->wq, &ieee->check_tsf_wq, 0); + } + } + } +#endif +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) +no_alloc: + if (ieee->iw_mode == IW_MODE_INFRA) +#endif + { + if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { + update_network(&ieee->current_network, network); + if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) + && ieee->current_network.berp_info_valid){ + if (ieee->current_network.erp_value& ERP_UseProtection) + ieee->current_network.buseprotection = true; + else + ieee->current_network.buseprotection = false; + } + if (is_beacon(beacon->header.frame_ctl)) + { + if (ieee->state >= RTLLIB_LINKED) + ieee->LinkDetectInfo.NumRecvBcnInPeriod++; + } + } + } +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + else if (ieee->iw_mode == IW_MODE_ADHOC) + { + if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { + update_ibss_network(&ieee->current_network, network); + } + } +#endif + list_for_each_entry(target, &ieee->network_list, list) { + if (is_same_network(target, network,(target->ssid_len?1:0))) + break; + if ((oldest == NULL) || + (target->last_scanned < oldest->last_scanned)) + oldest = target; + } + + /* If we didn't find a match, then get a new network slot to initialize + * with this beacon's information */ + if (&target->list == &ieee->network_list) { + if (list_empty(&ieee->network_free_list)) { + /* If there are no more slots, expire the oldest */ + list_del(&oldest->list); + target = oldest; + RTLLIB_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from " + "network list.\n", + escape_essid(target->ssid, + target->ssid_len), + MAC_ARG(target->bssid)); + } else { + /* Otherwise just pull from the free list */ + target = list_entry(ieee->network_free_list.next, + struct rtllib_network, list); + list_del(ieee->network_free_list.next); + } + + +#ifdef CONFIG_RTLLIB_DEBUG + RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); +#endif + memcpy(target, network, sizeof(*target)); + list_add_tail(&target->list, &ieee->network_list); + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) + rtllib_softmac_new_net(ieee, network); + } else { + RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", + escape_essid(target->ssid, + target->ssid_len), + MAC_ARG(target->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); + + /* we have an entry and we are going to update it. But this entry may + * be already expired. In this case we do the same as we found a new + * net and call the new_net handler + */ + renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); + if ((!target->ssid_len) && + (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) + || ((ieee->current_network.ssid_len == network->ssid_len) && + (strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0) && + (ieee->state == RTLLIB_NOLINK))) + ) { + renew = 1; + } + update_network(target, network); + if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) + rtllib_softmac_new_net(ieee, network); + } + + spin_unlock_irqrestore(&ieee->lock, flags); + if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))&&\ + (ieee->state == RTLLIB_LINKED)) { + if (ieee->handle_beacon != NULL) { + ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); + } + } +free_network: + kfree(network); + return; +} + +void rtllib_rx_mgt(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *stats) +{ + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; + if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && + WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) + ieee->last_rx_ps_time = jiffies; + + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + + case RTLLIB_STYPE_BEACON: + RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Beacon\n"); + rtllib_process_probe_response( + ieee, (struct rtllib_probe_response *)header, stats); + + if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && + ieee->iw_mode == IW_MODE_INFRA && + ieee->state == RTLLIB_LINKED)) + tasklet_schedule(&ieee->ps_task); + + break; + + case RTLLIB_STYPE_PROBE_RESP: + RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe response\n"); + rtllib_process_probe_response( + ieee, (struct rtllib_probe_response *)header, stats); + break; + case RTLLIB_STYPE_PROBE_REQ: + RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe request\n"); + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == RTLLIB_LINKED)){ + rtllib_rx_probe_rq(ieee, skb); + } + break; + } + +} diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c new file mode 100644 index 00000000000..a843de99ed3 --- /dev/null +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -0,0 +1,4150 @@ +/* IEEE 802.11 SoftMAC layer + * Copyright (c) 2005 Andrea Merello + * + * Mostly extracted from the rtl8180-sa2400 driver for the + * in-kernel generic ieee802.11 stack. + * + * Few lines might be stolen from other part of the rtllib + * stack. Copyright who own it's copyright + * + * WPA code stolen from the ipw2200 driver. + * Copyright who own it's copyright. + * + * released under the GPL + */ + + +#include "rtllib.h" +#include "rtl_core.h" + +#include +#include +#include +#include +#ifdef ENABLE_DOT11D +#include "dot11d.h" +#endif + +#ifdef RTK_DMP_PLATFORM +#include +#endif +extern void _setup_timer( struct timer_list*, void*, unsigned long ); +u8 rsn_authen_cipher_suite[16][4] = { + {0x00,0x0F,0xAC,0x00}, + {0x00,0x0F,0xAC,0x01}, + {0x00,0x0F,0xAC,0x02}, + {0x00,0x0F,0xAC,0x03}, + {0x00,0x0F,0xAC,0x04}, + {0x00,0x0F,0xAC,0x05}, +}; + +short rtllib_is_54g(struct rtllib_network *net) +{ + return ((net->rates_ex_len > 0) || (net->rates_len > 4)); +} + +short rtllib_is_shortslot(struct rtllib_network net) +{ + return (net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME); +} + +/* returns the total length needed for pleacing the RATE MFIE + * tag and the EXTENDED RATE MFIE tag if needed. + * It encludes two bytes per tag for the tag itself and its len + */ +unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) +{ + unsigned int rate_len = 0; + + if (ieee->modulation & RTLLIB_CCK_MODULATION) + rate_len = RTLLIB_CCK_RATE_LEN + 2; + + if (ieee->modulation & RTLLIB_OFDM_MODULATION) + + rate_len += RTLLIB_OFDM_RATE_LEN + 2; + + return rate_len; +} + +/* pleace the MFIE rate, tag to the memory (double) poined. + * Then it updates the pointer so that + * it points after the new MFIE tag added. + */ +void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + + if (ieee->modulation & RTLLIB_CCK_MODULATION){ + *tag++ = MFIE_TYPE_RATES; + *tag++ = 4; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; + } + + /* We may add an option for custom rates that specific HW might support */ + *tag_p = tag; +} + +void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + + if (ieee->modulation & RTLLIB_OFDM_MODULATION){ + + *tag++ = MFIE_TYPE_RATES_EX; + *tag++ = 8; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; + *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB; + + } + + /* We may add an option for custom rates that specific HW might support */ + *tag_p = tag; +} + +void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { + u8 *tag = *tag_p; + + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = 7; + *tag++ = 0x00; + *tag++ = 0x50; + *tag++ = 0xf2; + *tag++ = 0x02; + *tag++ = 0x00; + *tag++ = 0x01; +#ifdef SUPPORT_USPD + if (ieee->current_network.wmm_info & 0x80) { + *tag++ = 0x0f|MAX_SP_Len; + } else { + *tag++ = MAX_SP_Len; + } +#else + *tag++ = MAX_SP_Len; +#endif + *tag_p = tag; +} + +void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { + u8 *tag = *tag_p; + + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = 7; + *tag++ = 0x00; + *tag++ = 0xe0; + *tag++ = 0x4c; + *tag++ = 0x01; + *tag++ = 0x02; + *tag++ = 0x11; + *tag++ = 0x00; + + *tag_p = tag; + printk(KERN_ALERT "This is enable turbo mode IE process\n"); +} + +void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) +{ + int nh; + nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + +/* + * if the queue is full but we have newer frames then + * just overwrites the oldest. + * + * if (nh == ieee->mgmt_queue_tail) + * return -1; + */ + ieee->mgmt_queue_head = nh; + ieee->mgmt_queue_ring[nh] = skb; + +} + +struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) +{ + struct sk_buff *ret; + + if (ieee->mgmt_queue_tail == ieee->mgmt_queue_head) + return NULL; + + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; + + ieee->mgmt_queue_tail = + (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; + + return ret; +} + +void init_mgmt_queue(struct rtllib_device *ieee) +{ + ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; +} + + +u8 +MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) +{ + u16 i; + u8 QueryRate = 0; + u8 BasicRate; + + + for ( i = 0; i < ieee->current_network.rates_len; i++) + { + BasicRate = ieee->current_network.rates[i]&0x7F; + if (!rtllib_is_cck_rate(BasicRate)) + { + if (QueryRate == 0) + { + QueryRate = BasicRate; + } + else + { + if (BasicRate < QueryRate) + { + QueryRate = BasicRate; + } + } + } + } + + if (QueryRate == 0) + { + QueryRate = 12; + printk("No BasicRate found!!\n"); + } + return QueryRate; +} + +u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + u8 rate; + + if (pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) + rate = 0x0c; + else + rate = ieee->basic_rate & 0x7f; + + if (rate == 0){ + if (ieee->mode == IEEE_A|| + ieee->mode== IEEE_N_5G|| + (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + rate = 0x0c; + else + rate = 0x02; + } + + return rate; +} + + +void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); + +inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) +{ + unsigned long flags; + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; + struct rtllib_hdr_3addr *header= + (struct rtllib_hdr_3addr *) skb->data; + + cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); + spin_lock_irqsave(&ieee->lock, flags); + + /* called with 2nd param 0, no mgmt lock required */ + rtllib_sta_wakeup(ieee,0); + + if (header->frame_ctl == RTLLIB_STYPE_BEACON) + tcb_desc->queue_index = BEACON_QUEUE; + else + tcb_desc->queue_index = MGNT_QUEUE; + + if (ieee->disable_mgnt_queue) + tcb_desc->queue_index = HIGH_QUEUE; + + tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee); + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + if (single) { + if (ieee->queue_stop){ + enqueue_mgmt(ieee,skb); + }else{ + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + + /* avoid watchdog triggers */ + ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + } + + spin_unlock_irqrestore(&ieee->lock, flags); + }else{ + spin_unlock_irqrestore(&ieee->lock, flags); + spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); + + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + + /* check wether the managed packet queued greater than 5 */ + if (!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ + (ieee->queue_stop) ) { + /* insert the skb packet to the management queue */ + /* as for the completion function, it does not need + * to check it any more. + * */ + printk("%s():insert to waitqueue, queue_index:%d!\n",__func__,tcb_desc->queue_index); + skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); + } else { + ieee->softmac_hard_start_xmit(skb,ieee->dev); + } + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); + } +} + +inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, + struct rtllib_device *ieee) +{ + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; + struct rtllib_hdr_3addr *header = + (struct rtllib_hdr_3addr *) skb->data; + u16 fc,type,stype; + cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); + + fc = header->frame_ctl; + type = WLAN_FC_GET_TYPE(fc); + stype = WLAN_FC_GET_STYPE(fc); + + + if (stype != RTLLIB_STYPE_PSPOLL) + tcb_desc->queue_index = MGNT_QUEUE; + else + tcb_desc->queue_index = HIGH_QUEUE; + + if (ieee->disable_mgnt_queue) + tcb_desc->queue_index = HIGH_QUEUE; + + + tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee); + tcb_desc->RATRIndex = 7; + tcb_desc->bTxDisableRateFallBack = 1; + tcb_desc->bTxUseDriverAssingedRate = 1; + if (single) { + if (type != RTLLIB_FTYPE_CTL) { + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + + } + /* avoid watchdog triggers */ + ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + + } else { + if (type != RTLLIB_FTYPE_CTL) { + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + } + ieee->softmac_hard_start_xmit(skb,ieee->dev); + + } +} + +inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) +{ + unsigned int len,rate_len; + u8 *tag; + struct sk_buff *skb; + struct rtllib_probe_request *req; + + len = ieee->current_network.ssid_len; + + rate_len = rtllib_MFIE_rate_len(ieee); + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr; + int alignment; + skb = dev_alloc_skb(sizeof(struct rtllib_probe_request) + + 2 + len + rate_len + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(sizeof(struct rtllib_probe_request) + + 2 + len + rate_len + ieee->tx_headroom); +#endif + + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); + req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ); + req->header.duration_id = 0; + + memset(req->header.addr1, 0xff, ETH_ALEN); + memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memset(req->header.addr3, 0xff, ETH_ALEN); + + tag = (u8 *) skb_put(skb,len+2+rate_len); + + *tag++ = MFIE_TYPE_SSID; + *tag++ = len; + memcpy(tag, ieee->current_network.ssid, len); + tag += len; + + rtllib_MFIE_Brate(ieee,&tag); + rtllib_MFIE_Grate(ieee,&tag); + + return skb; +} + +struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee); + +void rtllib_send_beacon(struct rtllib_device *ieee) +{ + struct sk_buff *skb; + if (!ieee->ieee_up) + return; + skb = rtllib_get_beacon_(ieee); + + if (skb){ + softmac_mgmt_xmit(skb, ieee); + ieee->softmac_stats.tx_beacons++; + } + + if (ieee->beacon_txing && ieee->ieee_up){ + mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); + } +} + + +void rtllib_send_beacon_cb(unsigned long _ieee) +{ + struct rtllib_device *ieee = + (struct rtllib_device *) _ieee; + unsigned long flags; + + spin_lock_irqsave(&ieee->beacon_lock, flags); + rtllib_send_beacon(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); +} + +/* + * Description: + * Enable network monitor mode, all rx packets will be received. + */ +void rtllib_EnableNetMonitorMode(struct net_device* dev, + bool bInitState) +{ + struct rtllib_device* ieee = netdev_priv_rsl(dev); + + printk("========>Enter Monitor Mode\n"); + + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); +} + + +/* + * Description: + * Disable network network monitor mode, only packets destinated to + * us will be received. + */ +void rtllib_DisableNetMonitorMode(struct net_device* dev, + bool bInitState) +{ + struct rtllib_device* ieee = netdev_priv_rsl(dev); + + printk("========>Exit Monitor Mode\n"); + + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); +} + + +/* + * Description: + * This enables the specialized promiscuous mode required by Intel. + * In this mode, Intel intends to hear traffics from/to other STAs in the same BSS. + * Therefore we don't have to disable checking BSSID and we only need to allow all dest. + * BUT: if we enable checking BSSID then we can't recv packets from other STA. + */ +void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, + bool bInitState) +{ + bool bFilterOutNonAssociatedBSSID = false; + + struct rtllib_device* ieee = netdev_priv_rsl(dev); + + printk("========>Enter Intel Promiscuous Mode\n"); + + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + + ieee->bNetPromiscuousMode = true; +} + + +/* + * Description: + * This disables the specialized promiscuous mode required by Intel. + * See MgntEnableIntelPromiscuousMode for detail. + */ +void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, + bool bInitState) +{ + bool bFilterOutNonAssociatedBSSID = true; + + struct rtllib_device* ieee = netdev_priv_rsl(dev); + + printk("========>Exit Intel Promiscuous Mode\n"); + + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + + ieee->bNetPromiscuousMode = false; +} + +void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) +{ + struct sk_buff *skb; + skb = rtllib_probe_req(ieee); + if (skb){ + softmac_mgmt_xmit(skb, ieee); + ieee->softmac_stats.tx_probe_rq++; + } +} + + +void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) +{ + if (ieee->active_scan && (ieee->softmac_features & + IEEE_SOFTMAC_PROBERQ)) { + rtllib_send_probe(ieee, 0); + rtllib_send_probe(ieee, 0); + } +} + +void rtllib_softmac_hint11d_wq(void *data) +{ +#ifdef CONFIG_CRDA + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_hint11d_wq); + PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); + struct wireless_dev *wdev = &ieee->wdev; + + regulatory_hint_11d(wdev->wiphy, pDot11dInfo->CountryIeBuf, pDot11dInfo->CountryIeLen); +#endif +} + +void rtllib_update_active_chan_map(struct rtllib_device *ieee) +{ +#ifdef ENABLE_DOT11D + memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); +#else + memcpy(ieee->active_channel_map, ieee->channel_map, MAX_CHANNEL_NUMBER+1); +#endif +} + +/* this performs syncro scan blocking the caller until all channels + * in the allowed channel map has been checked. + */ +void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) +{ + short ch = 0; + + rtllib_update_active_chan_map(ieee); + + ieee->be_scan_inprogress = true; + + down(&ieee->scan_sem); + + while(1) + { + + do { + ch++; + if (ch > MAX_CHANNEL_NUMBER) + goto out; /* scan completed */ + } while(!ieee->active_channel_map[ch]); + + /* this fuction can be called in two situations + * 1- We have switched to ad-hoc mode and we are + * performing a complete syncro scan before conclude + * there are no interesting cell and to create a + * new one. In this case the link state is + * RTLLIB_NOLINK until we found an interesting cell. + * If so the ieee8021_new_net, called by the RX path + * will set the state to RTLLIB_LINKED, so we stop + * scanning + * 2- We are linked and the root uses run iwlist scan. + * So we switch to RTLLIB_LINKED_SCANNING to remember + * that we are still logically linked (not interested in + * new network events, despite for updating the net list, + * but we are temporarly 'unlinked' as the driver shall + * not filter RX frames and the channel is changing. + * So the only situation in witch are interested is to check + * if the state become LINKED because of the #1 situation + */ + + if (ieee->state == RTLLIB_LINKED) + goto out; + if (ieee->sync_scan_hurryup){ + printk("============>sync_scan_hurryup out\n"); + goto out; + } + + ieee->set_chan(ieee->dev, ch); + if (ieee->active_channel_map[ch] == 1) + rtllib_send_probe_requests(ieee, 0); + + /* this prevent excessive time wait when we + * need to wait for a syncro scan to end.. + */ + msleep_interruptible_rsl(RTLLIB_SOFTMAC_SCAN_TIME); + } +out: + ieee->actscanning = false; + ieee->sync_scan_hurryup = 0; + + if (ieee->state >= RTLLIB_LINKED){ +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee)) + DOT11D_ScanComplete(ieee); +#endif + } + up(&ieee->scan_sem); + + ieee->be_scan_inprogress = false; + +#ifndef FOR_MOBLIN + { + union iwreq_data wrqu; + memset(&wrqu, 0, sizeof(wrqu)); + wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); + } +#endif +} + +void rtllib_softmac_scan_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); + u8 last_channel = ieee->current_network.channel; + + rtllib_update_active_chan_map(ieee); + + if (!ieee->ieee_up) + return; + if (rtllib_act_scanning(ieee,true) == true) + return; + + down(&ieee->scan_sem); + + if (ieee->eRFPowerState == eRfOff) + { + printk("======>%s():rf state is eRfOff, return\n",__func__); + goto out1; + } + + do{ + ieee->current_network.channel = + (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; + if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) + { + if (!ieee->active_channel_map[ieee->current_network.channel]) + ieee->current_network.channel = 6; + goto out; /* no good chans */ + } + } while(!ieee->active_channel_map[ieee->current_network.channel]); + + if (ieee->scanning_continue == 0 ) + goto out; + + ieee->set_chan(ieee->dev, ieee->current_network.channel); + + if (ieee->active_channel_map[ieee->current_network.channel] == 1) + rtllib_send_probe_requests(ieee, 0); + + queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); + + up(&ieee->scan_sem); + return; + +out: +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee)) + DOT11D_ScanComplete(ieee); +#endif + ieee->current_network.channel = last_channel; + +out1: + ieee->actscanning = false; + ieee->scan_watch_dog = 0; + ieee->scanning_continue = 0; + up(&ieee->scan_sem); +} + + + +void rtllib_beacons_start(struct rtllib_device *ieee) +{ + unsigned long flags; + spin_lock_irqsave(&ieee->beacon_lock,flags); + + ieee->beacon_txing = 1; + rtllib_send_beacon(ieee); + + spin_unlock_irqrestore(&ieee->beacon_lock,flags); +} + +void rtllib_beacons_stop(struct rtllib_device *ieee) +{ + unsigned long flags; + + spin_lock_irqsave(&ieee->beacon_lock,flags); + + ieee->beacon_txing = 0; + del_timer_sync(&ieee->beacon_timer); + + spin_unlock_irqrestore(&ieee->beacon_lock,flags); + +} + + +void rtllib_stop_send_beacons(struct rtllib_device *ieee) +{ + if (ieee->stop_send_beacons) + ieee->stop_send_beacons(ieee->dev); + if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) + rtllib_beacons_stop(ieee); +} + + +void rtllib_start_send_beacons(struct rtllib_device *ieee) +{ + if (ieee->start_send_beacons) + ieee->start_send_beacons(ieee->dev); + if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) + rtllib_beacons_start(ieee); +} + + +void rtllib_softmac_stop_scan(struct rtllib_device *ieee) +{ + + + down(&ieee->scan_sem); + ieee->scan_watch_dog = 0; + if (ieee->scanning_continue == 1){ + ieee->scanning_continue = 0; + ieee->actscanning = 0; + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,40) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,67) + cancel_delayed_work(&ieee->softmac_scan_wq); +#endif +#else + del_timer_sync(&ieee->scan_timer); +#endif + } + + up(&ieee->scan_sem); +} + +void rtllib_stop_scan(struct rtllib_device *ieee) +{ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + rtllib_softmac_stop_scan(ieee); + }else{ + if (ieee->rtllib_stop_hw_scan) + ieee->rtllib_stop_hw_scan(ieee->dev); + } +} + +void rtllib_stop_scan_syncro(struct rtllib_device *ieee) +{ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + ieee->sync_scan_hurryup = 1; + }else{ + if (ieee->rtllib_stop_hw_scan) + ieee->rtllib_stop_hw_scan(ieee->dev); + } +} + +bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) +{ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (sync_scan){ + return ieee->be_scan_inprogress; + }else{ + return (ieee->actscanning ||ieee->be_scan_inprogress); + } + }else{ + return test_bit(STATUS_SCANNING, &ieee->status); + } +} + +/* called with ieee->lock held */ +void rtllib_start_scan(struct rtllib_device *ieee) +{ + RT_TRACE(COMP_DBG, "===>%s()\n",__func__); + if (ieee->rtllib_ips_leave_wq != NULL) + ieee->rtllib_ips_leave_wq(ieee->dev); + + +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee) ) + { + if (IS_COUNTRY_IE_VALID(ieee)) + { + RESET_CIE_WATCHDOG(ieee); + } + } +#endif + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { + if (ieee->scanning_continue == 0) { + ieee->actscanning = true; + ieee->scanning_continue = 1; + queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, 0); + } + } else { + if (ieee->rtllib_start_hw_scan) + ieee->rtllib_start_hw_scan(ieee->dev); + } + +} + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) +void rtllib_softmac_scan_cb(unsigned long _dev) +{ + unsigned long flags; + struct rtllib_device *ieee = (struct rtllib_device *)_dev; + + spin_lock_irqsave(&ieee->lock, flags); + rtllib_start_scan(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); +} +#endif + +/* called with wx_sem held */ +void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) +{ +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee) ) + { + if (IS_COUNTRY_IE_VALID(ieee)) + { + RESET_CIE_WATCHDOG(ieee); + } + } +#endif + ieee->sync_scan_hurryup = 0; + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + rtllib_softmac_scan_syncro(ieee, is_mesh); + }else{ + if (ieee->rtllib_start_hw_scan) + ieee->rtllib_start_hw_scan(ieee->dev); + } + +} + +inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, + struct rtllib_device *ieee, int challengelen,u8 * daddr) +{ + struct sk_buff *skb; + struct rtllib_authentication *auth; + int len = 0; + len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr; + int alignment; + skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len); +#endif + + if (!skb) return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + auth = (struct rtllib_authentication *) + skb_put(skb, sizeof(struct rtllib_authentication)); + + auth->header.frame_ctl = RTLLIB_STYPE_AUTH; + if (challengelen) auth->header.frame_ctl |= RTLLIB_FCTL_WEP; + + auth->header.duration_id = 0x013a; + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); + if (ieee->auth_mode == 0) + auth->algorithm = WLAN_AUTH_OPEN; + else if (ieee->auth_mode == 1) + auth->algorithm = WLAN_AUTH_SHARED_KEY; + else if (ieee->auth_mode == 2) + auth->algorithm = WLAN_AUTH_OPEN; + auth->transaction = cpu_to_le16(ieee->associate_seq); + ieee->associate_seq++; + + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); + + return skb; + +} + +void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) +{ + u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; + + if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) + { + szQoSOUI[0] = 46; + szQoSOUI[1] = *wmm_len; + memcpy(wmmie,szQoSOUI,3); + *wmm_len = 3; + } + else + { + szQoSOUI[1] = *wmm_len + 6; + szQoSOUI[6] = oui_subtype; + memcpy(wmmie, szQoSOUI, 8); + *(wmmie+8) = 0; + *wmm_len = 9; + } +} + +static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +{ + u8 *tag; + int beacon_size; + struct rtllib_probe_response *beacon_buf; + struct sk_buff *skb = NULL; + int encrypt; + int atim_len,erp_len; + struct rtllib_crypt_data* crypt; + + char *ssid = ieee->current_network.ssid; + int ssid_len = ieee->current_network.ssid_len; + int rate_len = ieee->current_network.rates_len+2; + int rate_ex_len = ieee->current_network.rates_ex_len; + int wpa_ie_len = ieee->wpa_ie_len; + u8 erpinfo_content = 0; + + u8* tmp_ht_cap_buf = NULL; + u8 tmp_ht_cap_len = 0; + u8* tmp_ht_info_buf = NULL; + u8 tmp_ht_info_len = 0; + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + u8* tmp_generic_ie_buf = NULL; + u8 tmp_generic_ie_len = 0; + + if (rate_ex_len > 0) + rate_ex_len+=2; + + if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) + atim_len = 4; + else + atim_len = 0; + + if ((ieee->current_network.mode == IEEE_G) + ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) { + erp_len = 3; + erpinfo_content = 0; + if (ieee->current_network.buseprotection) + erpinfo_content |= ERP_UseProtection; + } + else + erp_len = 0; + + crypt = ieee->crypt[ieee->tx_keyidx]; + encrypt = ieee->host_encrypt && crypt && crypt->ops && + ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); + if (ieee->pHTInfo->bCurrentHTSupport){ + tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); + tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); + tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); + HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt, false); + HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); + + + if (pHTInfo->bRegRT2RTAggregation) + { + tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; + tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); + } + } + + beacon_size = sizeof(struct rtllib_probe_response)+2+ + ssid_len + +3 + +rate_len + +rate_ex_len + +atim_len + +erp_len + +wpa_ie_len + +ieee->tx_headroom; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(beacon_size + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(beacon_size); +#endif + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); + memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + + beacon_buf->header.duration_id = 0; + beacon_buf->beacon_interval = + cpu_to_le16(ieee->current_network.beacon_interval); + beacon_buf->capability = + cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); + beacon_buf->capability |= + cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); + + if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME)); + + crypt = ieee->crypt[ieee->tx_keyidx]; + if (encrypt) + beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); + + + beacon_buf->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_RESP); + beacon_buf->info_element[0].id = MFIE_TYPE_SSID; + beacon_buf->info_element[0].len = ssid_len; + + tag = (u8*) beacon_buf->info_element[0].data; + + memcpy(tag, ssid, ssid_len); + + tag += ssid_len; + + *(tag++) = MFIE_TYPE_RATES; + *(tag++) = rate_len-2; + memcpy(tag,ieee->current_network.rates,rate_len-2); + tag+=rate_len-2; + + *(tag++) = MFIE_TYPE_DS_SET; + *(tag++) = 1; + *(tag++) = ieee->current_network.channel; + + if (atim_len){ + u16 val16; + *(tag++) = MFIE_TYPE_IBSS_SET; + *(tag++) = 2; + val16 = cpu_to_le16(ieee->current_network.atim_window); + memcpy((u8 *)tag, (u8 *)&val16, 2); + tag+=2; + } + + if (erp_len){ + *(tag++) = MFIE_TYPE_ERP; + *(tag++) = 1; + *(tag++) = erpinfo_content; + } +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (tmp_ht_cap_len){ + *(tag++) = MFIE_TYPE_HT_CAP; + *(tag++) = tmp_ht_cap_len - 2; + memcpy(tag, tmp_ht_cap_buf, tmp_ht_cap_len - 2); + tag += tmp_ht_cap_len - 2; + } +#endif + if (rate_ex_len){ + *(tag++) = MFIE_TYPE_RATES_EX; + *(tag++) = rate_ex_len-2; + memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); + tag+=rate_ex_len-2; + } + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (tmp_ht_info_len){ + *(tag++) = MFIE_TYPE_HT_INFO; + *(tag++) = tmp_ht_info_len - 2; + memcpy(tag, tmp_ht_info_buf, tmp_ht_info_len -2); + tag += tmp_ht_info_len - 2; + } +#endif + + if (wpa_ie_len) + { + if (ieee->iw_mode == IW_MODE_ADHOC) + { + memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); + } + memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); + tag += ieee->wpa_ie_len; + } + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (tmp_generic_ie_len) + { + (*tag++) = 0xdd; + (*tag++) = tmp_generic_ie_len - 2; + memcpy(tag,tmp_generic_ie_buf,tmp_generic_ie_len -2); + tag += tmp_generic_ie_len -2; + + } +#endif + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (wmm_len) { + memcpy(tag,wmmie,wmm_len); + tag += wmm_len; + } +#endif + return skb; +} + +struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +{ + struct sk_buff *skb; + u8* tag; + + struct rtllib_crypt_data* crypt; + struct rtllib_assoc_response_frame *assoc; + short encrypt; + + unsigned int rate_len = rtllib_MFIE_rate_len(ieee); + int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len); +#endif + + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + assoc = (struct rtllib_assoc_response_frame *) + skb_put(skb,sizeof(struct rtllib_assoc_response_frame)); + + assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); + memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); + memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS); + + + if (ieee->short_slot) + assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); + + if (ieee->host_encrypt) + crypt = ieee->crypt[ieee->tx_keyidx]; + else + crypt = NULL; + + encrypt = ( crypt && crypt->ops); + + if (encrypt) + assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); + + assoc->status = 0; + assoc->aid = cpu_to_le16(ieee->assoc_id); + if (ieee->assoc_id == 0x2007) + ieee->assoc_id=0; + else + ieee->assoc_id++; + + tag = (u8*) skb_put(skb, rate_len); + rtllib_MFIE_Brate(ieee, &tag); + rtllib_MFIE_Grate(ieee, &tag); + + return skb; +} + +struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest) +{ + struct sk_buff *skb = NULL; + struct rtllib_authentication *auth; + int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len); +#endif + if (!skb) + return NULL; + + skb->len = sizeof(struct rtllib_authentication); + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + auth = (struct rtllib_authentication *) + skb_put(skb, sizeof(struct rtllib_authentication)); + + auth->status = cpu_to_le16(status); + auth->transaction = cpu_to_le16(2); + auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); + + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); + memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(auth->header.addr1, dest, ETH_ALEN); + auth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_AUTH); + return skb; + + +} + +struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) +{ + struct sk_buff *skb; + struct rtllib_hdr_3addr* hdr; + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); +#endif + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + skb_reserve(skb, ieee->tx_headroom); + + hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); + + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); + memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); + + hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | + RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | + (pwr ? RTLLIB_FCTL_PM:0)); + + return skb; + + +} + +struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) +{ + struct sk_buff *skb; + struct rtllib_pspoll_hdr* hdr; + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); +#endif + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + skb_reserve(skb, ieee->tx_headroom); + + hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); + + memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); + memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); + + hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); + hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL |RTLLIB_STYPE_PSPOLL | RTLLIB_FCTL_PM); + + return skb; + +} + +void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) +{ + struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); + + if (buf) + softmac_mgmt_xmit(buf, ieee); +} + + +void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8* dest) +{ + struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); + + if (buf) + softmac_mgmt_xmit(buf, ieee); +} + + +void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) +{ + + struct sk_buff *buf = rtllib_probe_resp(ieee, dest); + if (buf) + softmac_mgmt_xmit(buf, ieee); +} + + +inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid) +{ + int i = 0; + + do + { + if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) + { + break; + } + else + { + i++; + } + } while (i < NUM_PMKID_CACHE); + + if (i == NUM_PMKID_CACHE) + { + i = -1; + } + else + { + } + + return (i); + +} + + +inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,struct rtllib_device *ieee) +{ + struct sk_buff *skb; + + struct rtllib_assoc_request_frame *hdr; + u8 *tag, *ies; + int i; + u8* ht_cap_buf = NULL; + u8 ht_cap_len=0; + u8* realtek_ie_buf=NULL; + u8 realtek_ie_len=0; + int wpa_ie_len= ieee->wpa_ie_len; + int wps_ie_len = ieee->wps_ie_len; + unsigned int ckip_ie_len=0; + unsigned int ccxrm_ie_len=0; + unsigned int cxvernum_ie_len=0; + struct rtllib_crypt_data* crypt; + int encrypt; + int PMKCacheIdx; + + unsigned int rate_len = (beacon->rates_len?(beacon->rates_len+2):0) + (beacon->rates_ex_len?(beacon->rates_ex_len)+2:0); + + unsigned int wmm_info_len = beacon->qos_data.supported?9:0; + unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; + + int len = 0; + crypt = ieee->crypt[ieee->tx_keyidx]; + if (crypt != NULL) { + encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); + } else { + encrypt = 0; + } + +#ifdef ENABLE_TKIP11N + if (ieee->bForcedBgMode == true) +#else + if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) +#endif + { + ieee->pHTInfo->bEnableHT = 0; + ieee->mode = WIRELESS_MODE_G; + } + + if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) + { + ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap); + ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); + HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); + if (ieee->pHTInfo->bCurrentRT2RTAggregation) { + realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; + realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); + + } + } + + if (beacon->bCkipSupported) + { + ckip_ie_len = 30+2; + } + if (beacon->bCcxRmEnable) + { + ccxrm_ie_len = 6+2; + } + if ( beacon->BssCcxVerNumber >= 2 ) + { + cxvernum_ie_len = 5+2; + } + + PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); + if (PMKCacheIdx >= 0) + { + wpa_ie_len += 18; + printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); + } + len = sizeof(struct rtllib_assoc_request_frame)+ 2 + + beacon->ssid_len + + rate_len + + wpa_ie_len + + wps_ie_len + + wmm_info_len + + turbo_info_len + + ht_cap_len + + realtek_ie_len + + ckip_ie_len + + ccxrm_ie_len + + cxvernum_ie_len + + ieee->tx_headroom; + +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); +#else + skb = dev_alloc_skb(len); +#endif + + if (!skb) + return NULL; + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + + skb_reserve(skb, ieee->tx_headroom); + + hdr = (struct rtllib_assoc_request_frame *) + skb_put(skb, sizeof(struct rtllib_assoc_request_frame)+2); + + + hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; + hdr->header.duration_id= 37; + memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); + + memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); + + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); + + if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + + if (ieee->short_slot && (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); + + + hdr->listen_interval = beacon->listen_interval; + + hdr->info_element[0].id = MFIE_TYPE_SSID; + + hdr->info_element[0].len = beacon->ssid_len; + tag = skb_put(skb, beacon->ssid_len); + memcpy(tag, beacon->ssid, beacon->ssid_len); + + tag = skb_put(skb, rate_len); + + if (beacon->rates_len){ + *tag++ = MFIE_TYPE_RATES; + *tag++ = beacon->rates_len; + for (i=0;irates_len;i++){ + *tag++ = beacon->rates[i]; + } + } + + if (beacon->rates_ex_len){ + *tag++ = MFIE_TYPE_RATES_EX; + *tag++ = beacon->rates_ex_len; + for (i=0;irates_ex_len;i++){ + *tag++ = beacon->rates_ex[i]; + } + } + + if ( beacon->bCkipSupported ) + { + static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; + u8 CcxAironetBuf[30]; + OCTET_STRING osCcxAironetIE; + + memset(CcxAironetBuf, 0,30); + osCcxAironetIE.Octet = CcxAironetBuf; + osCcxAironetIE.Length = sizeof(CcxAironetBuf); + memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); + + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; + tag = skb_put(skb, ckip_ie_len); + *tag++ = MFIE_TYPE_AIRONET; + *tag++ = osCcxAironetIE.Length; + memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); + tag += osCcxAironetIE.Length; + } + + if (beacon->bCcxRmEnable) + { + static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; + OCTET_STRING osCcxRmCap; + + osCcxRmCap.Octet = CcxRmCapBuf; + osCcxRmCap.Length = sizeof(CcxRmCapBuf); + tag = skb_put(skb,ccxrm_ie_len); + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = osCcxRmCap.Length; + memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); + tag += osCcxRmCap.Length; + } + + if ( beacon->BssCcxVerNumber >= 2 ) + { + u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; + OCTET_STRING osCcxVerNum; + CcxVerNumBuf[4] = beacon->BssCcxVerNumber; + osCcxVerNum.Octet = CcxVerNumBuf; + osCcxVerNum.Length = sizeof(CcxVerNumBuf); + tag = skb_put(skb,cxvernum_ie_len); + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = osCcxVerNum.Length; + memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); + tag += osCcxVerNum.Length; + } + if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ + if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) + { + tag = skb_put(skb, ht_cap_len); + *tag++ = MFIE_TYPE_HT_CAP; + *tag++ = ht_cap_len - 2; + memcpy(tag, ht_cap_buf,ht_cap_len -2); + tag += ht_cap_len -2; + } + } + + + if (wpa_ie_len){ + tag = skb_put(skb, ieee->wpa_ie_len); + memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); + + if (PMKCacheIdx >= 0) + { + tag = skb_put(skb, 18); + *tag = 1; + *(tag + 1) = 0; + memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16); + } + } + if (wmm_info_len) { + tag = skb_put(skb,wmm_info_len); + rtllib_WMM_Info(ieee, &tag); + } + + if (wps_ie_len && ieee->wps_ie) { + tag = skb_put(skb, wps_ie_len); + memcpy(tag, ieee->wps_ie, wps_ie_len); + } + + tag = skb_put(skb,turbo_info_len); + if (turbo_info_len) + rtllib_TURBO_Info(ieee, &tag); + + if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) + { + tag = skb_put(skb, ht_cap_len); + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = ht_cap_len - 2; + memcpy(tag, ht_cap_buf,ht_cap_len - 2); + tag += ht_cap_len -2; + } + + if (ieee->pHTInfo->bCurrentRT2RTAggregation){ + tag = skb_put(skb, realtek_ie_len); + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = realtek_ie_len - 2; + memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); + } + } + + if (ieee->assocreq_ies){ + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; + } + ies = &(hdr->info_element[0].id); + ieee->assocreq_ies_len = (skb->data + skb->len) - ies; + ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); + if (ieee->assocreq_ies) + memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); + else{ + printk("%s()Warning: can't alloc memory for assocreq_ies\n", __func__); + ieee->assocreq_ies_len = 0; + } + + return skb; +} + +void rtllib_associate_abort(struct rtllib_device *ieee) +{ + + unsigned long flags; + spin_lock_irqsave(&ieee->lock, flags); + + ieee->associate_seq++; + + /* don't scan, and avoid to have the RX path possibily + * try again to associate. Even do not react to AUTH or + * ASSOC response. Just wait for the retry wq to be scheduled. + * Here we will check if there are good nets to associate + * with, so we retry or just get back to NO_LINK and scanning + */ + if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING){ + RTLLIB_DEBUG_MGMT("Authentication failed\n"); + ieee->softmac_stats.no_auth_rs++; + }else{ + RTLLIB_DEBUG_MGMT("Association failed\n"); + ieee->softmac_stats.no_ass_rs++; + } + + ieee->state = RTLLIB_ASSOCIATING_RETRY; + + queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, \ + RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); + + spin_unlock_irqrestore(&ieee->lock, flags); +} + +void rtllib_associate_abort_cb(unsigned long dev) +{ + rtllib_associate_abort((struct rtllib_device *) dev); +} + +void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) +{ + struct rtllib_network *beacon = &ieee->current_network; + struct sk_buff *skb; + + RTLLIB_DEBUG_MGMT("Stopping scan\n"); + + ieee->softmac_stats.tx_auth_rq++; + + skb=rtllib_authentication_req(beacon, ieee, 0,daddr); + + if (!skb) + rtllib_associate_abort(ieee); + else{ + ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ; + RTLLIB_DEBUG_MGMT("Sending authentication request\n"); + softmac_mgmt_xmit(skb, ieee); + if (!timer_pending(&ieee->associate_timer)){ + ieee->associate_timer.expires = jiffies + (HZ / 2); + add_timer(&ieee->associate_timer); + } + } +} + +void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) +{ + u8 *c; + struct sk_buff *skb; + struct rtllib_network *beacon = &ieee->current_network; + + ieee->associate_seq++; + ieee->softmac_stats.tx_auth_rq++; + + skb = rtllib_authentication_req(beacon, ieee, chlen+2,beacon->bssid); + + if (!skb) + rtllib_associate_abort(ieee); + else{ + c = skb_put(skb, chlen+2); + *(c++) = MFIE_TYPE_CHALLENGE; + *(c++) = chlen; + memcpy(c, challenge, chlen); + + RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); + + rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr )); + + softmac_mgmt_xmit(skb, ieee); + mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); + } + kfree(challenge); +} + +void rtllib_associate_step2(struct rtllib_device *ieee) +{ + struct sk_buff* skb; + struct rtllib_network *beacon = &ieee->current_network; + + del_timer_sync(&ieee->associate_timer); + + RTLLIB_DEBUG_MGMT("Sending association request\n"); + + ieee->softmac_stats.tx_ass_rq++; + skb=rtllib_association_req(beacon, ieee); + if (!skb) + rtllib_associate_abort(ieee); + else{ + softmac_mgmt_xmit(skb, ieee); + mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); + } +} + +#define CANCELLED 2 +void rtllib_associate_complete_wq(void *data) +{ + struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(ieee->PowerSaveControl)); + printk(KERN_INFO "Associated successfully\n"); + if (ieee->is_silent_reset == 0){ + printk("normal associate\n"); + notify_wx_assoc_event(ieee); + } + + netif_carrier_on(ieee->dev); + ieee->is_roaming = false; + if (rtllib_is_54g(&ieee->current_network) && + (ieee->modulation & RTLLIB_OFDM_MODULATION)){ + + ieee->rate = 108; + printk(KERN_INFO"Using G rates:%d\n", ieee->rate); + }else{ + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates:%d\n", ieee->rate); + } + if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) + { + printk("Successfully associated, ht enabled\n"); + HTOnAssocRsp(ieee); + } else { + printk("Successfully associated, ht not enabled(%d, %d)\n", + ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); + memset(ieee->dot11HTOperationalRateSet, 0, 16); + } + ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) + { + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + } + pPSC->LpsIdleCount = 0; + ieee->link_change(ieee->dev); + + if (ieee->is_silent_reset == 1) { + printk("silent reset associate\n"); + ieee->is_silent_reset = 0; + } + + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + +#ifdef RTK_DMP_PLATFORM + kobject_hotplug(&ieee->dev->class_dev.kobj, KOBJ_LINKUP); +#endif +} + +static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) +{ + char *buf; + size_t len; + int i; + union iwreq_data wrqu; + + return; + + + buf = kmalloc(50 + 2 * (ieee->assocreq_ies_len + ieee->assocresp_ies_len), GFP_ATOMIC); + if (!buf) + return; + + len = sprintf(buf, "ASSOCINFO("); + if (ieee->assocreq_ies) { + len += sprintf(buf + len, "ReqIEs="); + for (i = 0; i < ieee->assocreq_ies_len; i++) { + len += sprintf(buf + len, "%02x", ieee->assocreq_ies[i]); + } + } + if (ieee->assocresp_ies) { + if (ieee->assocreq_ies) + len += sprintf(buf + len, " "); + len += sprintf(buf + len, "RespIEs="); + for (i = 0; i < ieee->assocresp_ies_len; i++) { + len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); + } + } + len += sprintf(buf + len, ")"); + + if (len > IW_CUSTOM_MAX) { + len = sprintf(buf, "ASSOCRESPIE="); + for (i = 0; i < ieee->assocresp_ies_len; i++) { + len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); + } + } + + if (len <= IW_CUSTOM_MAX) { + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = len; + wireless_send_event(ieee->dev, IWEVCUSTOM, &wrqu, buf); + } + + kfree(buf); +} + +void rtllib_associate_complete(struct rtllib_device *ieee) +{ + del_timer_sync(&ieee->associate_timer); + + ieee->state = RTLLIB_LINKED; + rtllib_sta_send_associnfo(ieee); + + queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); +} + +void rtllib_associate_procedure_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_procedure_wq); + rtllib_stop_scan_syncro(ieee); + if (ieee->rtllib_ips_leave != NULL) + ieee->rtllib_ips_leave(ieee->dev); + down(&ieee->wx_sem); + + if (ieee->data_hard_stop) + ieee->data_hard_stop(ieee->dev); + + rtllib_stop_scan(ieee); + RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, ieee->current_network.channel); + HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + if (ieee->eRFPowerState == eRfOff) + { + RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__func__); + if (ieee->rtllib_ips_leave_wq != NULL) + ieee->rtllib_ips_leave_wq(ieee->dev); + up(&ieee->wx_sem); + return; + } + ieee->associate_seq = 1; + + rtllib_associate_step1(ieee, ieee->current_network.bssid); + + up(&ieee->wx_sem); +} + +inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net) +{ + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; + int tmp_ssid_len = 0; + + short apset,ssidset,ssidbroad,apmatch,ssidmatch; + + /* we are interested in new new only if we are not associated + * and we are not associating / authenticating + */ + if (ieee->state != RTLLIB_NOLINK) + return; + + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_ESS)) + return; + + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) + return; + + if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal)) { + return; + } + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) + { + /* if the user specified the AP MAC, we need also the essid + * This could be obtained by beacons or, if the network does not + * broadcast it, it can be put manually. + */ + apset = ieee->wap_set; + ssidset = ieee->ssid_set; + ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); + if (!ssidbroad){ + ssidmatch = (ieee->current_network.ssid_len == net->hidden_ssid_len)&&\ + (!strncmp(ieee->current_network.ssid, net->hidden_ssid, net->hidden_ssid_len)); + if (net->hidden_ssid_len > 0) + { + strncpy(net->ssid, net->hidden_ssid, net->hidden_ssid_len); + net->ssid_len = net->hidden_ssid_len; + ssidbroad = 1; + } + } + else + ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ + (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + + if ( /* if the user set the AP check if match. + * if the network does not broadcast essid we check the user supplyed ANY essid + * if the network does broadcast and the user does not set essid it is OK + * if the network does broadcast and the user did set essid chech if essid match + */ + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) + /* if the ap is not set, check that the user set the bssid + * and the network does bradcast and that those two bssid matches + */ + || (!apset && ssidset && ssidbroad && ssidmatch) || (ieee->is_roaming && ssidset && ssidbroad && ssidmatch) + ){ + /* if the essid is hidden replace it with the + * essid provided by the user. + */ + if (!ssidbroad){ + strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); + tmp_ssid_len = ieee->current_network.ssid_len; + } + memcpy(&ieee->current_network, net, sizeof(struct rtllib_network)); + if (!ssidbroad){ + strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; + } + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode, ieee->current_network.flags); + + if ((rtllib_act_scanning(ieee, false)) && !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + rtllib_stop_scan_syncro(ieee); + } + + ieee->hwscan_ch_bk = ieee->current_network.channel; + HTResetIOTSetting(ieee->pHTInfo); + ieee->wmm_acm = 0; + if (ieee->iw_mode == IW_MODE_INFRA) { + /* Join the network for the first time */ + ieee->AsocRetryCount = 0; + if ((ieee->current_network.qos_data.supported == 1) && + ieee->current_network.bssht.bdSupportHT) + HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); + else + ieee->pHTInfo->bCurrentHTSupport = false; + + ieee->state = RTLLIB_ASSOCIATING; + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + } else { + if (rtllib_is_54g(&ieee->current_network) && + (ieee->modulation & RTLLIB_OFDM_MODULATION)){ + ieee->rate = 108; + ieee->SetWirelessMode(ieee->dev, IEEE_G); + printk(KERN_INFO"Using G rates\n"); + }else{ + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates\n"); + } + memset(ieee->dot11HTOperationalRateSet, 0, 16); + ieee->state = RTLLIB_LINKED; + } + + } + } + +} + +void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) +{ + unsigned long flags; + struct rtllib_network *target; + + spin_lock_irqsave(&ieee->lock, flags); + + list_for_each_entry(target, &ieee->network_list, list) { + + /* if the state become different that NOLINK means + * we had found what we are searching for + */ + + if (ieee->state != RTLLIB_NOLINK) + break; + + if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) + rtllib_softmac_new_net(ieee, target); + } + + spin_unlock_irqrestore(&ieee->lock, flags); + +} + + +static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +{ + struct rtllib_authentication *a; + u8 *t; + if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ + RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + return 0xcafe; + } + *challenge = NULL; + a = (struct rtllib_authentication*) skb->data; + if (skb->len > (sizeof(struct rtllib_authentication) +3)){ + t = skb->data + sizeof(struct rtllib_authentication); + + if (*(t++) == MFIE_TYPE_CHALLENGE){ + *chlen = *(t++); + *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); + memcpy(*challenge, t, *chlen); + } + } + + return cpu_to_le16(a->status); + +} + + +int auth_rq_parse(struct sk_buff *skb,u8* dest) +{ + struct rtllib_authentication *a; + + if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ + RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + return -1; + } + a = (struct rtllib_authentication*) skb->data; + + memcpy(dest,a->header.addr2, ETH_ALEN); + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; + + return WLAN_STATUS_SUCCESS; +} + +static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 *src) +{ + u8 *tag; + u8 *skbend; + u8 *ssid=NULL; + u8 ssidlen = 0; + + struct rtllib_hdr_3addr *header = + (struct rtllib_hdr_3addr *) skb->data; + + if (skb->len < sizeof (struct rtllib_hdr_3addr )) + return -1; /* corrupted */ + if ((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&& + (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) { + return -1; + } + + if (memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) { + } + + if (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) { + } + memcpy(src,header->addr2, ETH_ALEN); + + skbend = (u8*)skb->data + skb->len; + + tag = skb->data + sizeof (struct rtllib_hdr_3addr ); + + while (tag+1 < skbend){ + if (*tag == 0){ + ssid = tag+2; + ssidlen = *(tag+1); + break; + } + tag++; /* point to the len field */ + tag = tag + *(tag); /* point to the last data byte of the tag */ + tag++; /* point to the next tag */ + } + + if (ssidlen == 0) return 1; + + if (!ssid) return 1; /* ssid not found in tagged param */ + return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); + +} + +int assoc_rq_parse(struct sk_buff *skb,u8* dest) +{ + struct rtllib_assoc_request_frame *a; + + if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - + sizeof(struct rtllib_info_element))) { + + RTLLIB_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); + return -1; + } + + a = (struct rtllib_assoc_request_frame*) skb->data; + + memcpy(dest,a->header.addr2,ETH_ALEN); + + return 0; +} + +static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, int *aid) +{ + struct rtllib_assoc_response_frame *response_head; + u16 status_code; + + if (skb->len < sizeof(struct rtllib_assoc_response_frame)){ + RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); + return 0xcafe; + } + + response_head = (struct rtllib_assoc_response_frame*) skb->data; + *aid = le16_to_cpu(response_head->aid) & 0x3fff; + + status_code = le16_to_cpu(response_head->status); + if ((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ + status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& + ((ieee->mode == IEEE_G) && + (ieee->current_network.mode == IEEE_N_24G) && + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + }else { + ieee->AsocRetryCount = 0; + } + + return le16_to_cpu(response_head->status); +} + +void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb) +{ + u8 dest[ETH_ALEN]; +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + struct sta_info *psta = NULL; +#endif + ieee->softmac_stats.rx_probe_rq++; + if (probe_rq_parse(ieee, skb, dest) > 0){ + ieee->softmac_stats.tx_probe_rs++; + rtllib_resp_to_probe(ieee, dest); +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if (ieee->iw_mode == IW_MODE_ADHOC){ + psta = GetStaInfo(ieee, dest); + if (NULL != psta) + psta->LastActiveTime = jiffies; + } +#endif + } +} + +static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, struct sk_buff *skb) +{ + u8 dest[ETH_ALEN]; + int status; + ieee->softmac_stats.rx_auth_rq++; + + if ((status = auth_rq_parse(skb, dest))!= -1){ + rtllib_resp_to_auth(ieee, status, dest); + } + +} + +static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) +{ + + u8 dest[ETH_ALEN]; + + ieee->softmac_stats.rx_ass_rq++; + if (assoc_rq_parse(skb,dest) != -1){ + rtllib_resp_to_assoc_rq(ieee, dest); + } + + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); +} + + +void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) +{ + + struct sk_buff *buf = rtllib_null_func(ieee, pwr); + + if (buf) + softmac_ps_mgmt_xmit(buf, ieee); + +} + +void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) +{ + + struct sk_buff *buf = rtllib_pspoll_func(ieee); + + if (buf) + softmac_ps_mgmt_xmit(buf, ieee); + +} + +short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) +{ + int timeout = ieee->ps_timeout; + u8 dtim; + PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(ieee->PowerSaveControl)); + /*if (ieee->ps == RTLLIB_PS_DISABLED || + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != RTLLIB_LINKED) + + return 0; + */ + + if (ieee->LPSDelayCnt) + { + ieee->LPSDelayCnt --; + return 0; + } + + dtim = ieee->current_network.dtim_data; + if (!(dtim & RTLLIB_DTIM_VALID)) + return 0; + timeout = ieee->current_network.beacon_interval; + ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID; + /* there's no need to nofity AP that I find you buffered with broadcast packet */ + if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps)) + return 2; + + if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ + return 0; + } + if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){ + return 0; + } + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && + (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) + return 0; + + if (time_l){ + if (ieee->bAwakePktSent == true) { + pPSC->LPSAwakeIntvl = 1; + } else { + u8 MaxPeriod = 1; + + if (pPSC->LPSAwakeIntvl == 0) + pPSC->LPSAwakeIntvl = 1; + if (pPSC->RegMaxLPSAwakeIntvl == 0) + MaxPeriod = 1; + else if (pPSC->RegMaxLPSAwakeIntvl == 0xFF) + MaxPeriod = ieee->current_network.dtim_period; + else + MaxPeriod = pPSC->RegMaxLPSAwakeIntvl; + pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1); + } + { + u8 LPSAwakeIntvl_tmp = 0; + u8 period = ieee->current_network.dtim_period; + u8 count = ieee->current_network.tim.tim_count; + if (count == 0 ) { + if (pPSC->LPSAwakeIntvl > period) + LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period); + else + LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; + + } else { + if (pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count) + LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period); + else + LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; + } + + *time_l = ieee->current_network.last_dtim_sta_time[0] + + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); + } + } + + if (time_h) { + *time_h = ieee->current_network.last_dtim_sta_time[1]; + if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) + *time_h += 1; + } + + return 1; + + +} + +inline void rtllib_sta_ps(struct rtllib_device *ieee) +{ + + u32 th,tl; + short sleep; + + unsigned long flags,flags2; + + spin_lock_irqsave(&ieee->lock, flags); + + if ((ieee->ps == RTLLIB_PS_DISABLED || + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != RTLLIB_LINKED)){ + + RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", + __func__,ieee->ps,ieee->iw_mode,ieee->state); + spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); + + rtllib_sta_wakeup(ieee, 1); + + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); + } + + sleep = rtllib_sta_ps_sleep(ieee,&th, &tl); + /* 2 wake, 1 sleep, 0 do nothing */ + if (sleep == 0) + { + goto out; + } + if (sleep == 1){ + if (ieee->sta_sleep == LPS_IS_SLEEP){ + ieee->enter_sleep_state(ieee->dev,th,tl); + } + + else if (ieee->sta_sleep == LPS_IS_WAKE){ + spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); + + if (ieee->ps_is_queue_empty(ieee->dev)){ + ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; + ieee->ack_tx_to_ieee = 1; + rtllib_sta_ps_send_null_frame(ieee,1); + ieee->ps_th = th; + ieee->ps_tl = tl; + } + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); + + } + + ieee->bAwakePktSent = false; + + }else if (sleep == 2){ + spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); + + rtllib_sta_wakeup(ieee,1); + + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); + } + +out: + spin_unlock_irqrestore(&ieee->lock, flags); + +} + +void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) +{ + if (ieee->sta_sleep == LPS_IS_WAKE){ + if (nl){ + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) + { + ieee->ack_tx_to_ieee = 1; + rtllib_sta_ps_send_null_frame(ieee, 0); + } + else + { + ieee->ack_tx_to_ieee = 1; + rtllib_sta_ps_send_pspoll_frame(ieee); + } + } + return; + + } + + if (ieee->sta_sleep == LPS_IS_SLEEP) + ieee->sta_wake_up(ieee->dev); + if (nl){ + /* + ieee->ack_tx_to_ieee = 1; + printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__); + rtllib_sta_ps_send_null_frame(ieee, 0); + */ + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) + { + ieee->ack_tx_to_ieee = 1; + rtllib_sta_ps_send_null_frame(ieee, 0); + } + else + { + ieee->ack_tx_to_ieee = 1; + ieee->polling = true; + rtllib_sta_ps_send_pspoll_frame(ieee); + } + + } else { + ieee->sta_sleep = LPS_IS_WAKE; + ieee->polling = false; + } +} + +void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) +{ + unsigned long flags,flags2; + + spin_lock_irqsave(&ieee->lock, flags); + + if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND){ + /* Null frame with PS bit set */ + if (success){ + ieee->sta_sleep = LPS_IS_SLEEP; + ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + } + /* if the card report not success we can't be sure the AP + * has not RXed so we can't assume the AP believe us awake + */ + } else {/* 21112005 - tx again null without PS bit if lost */ + + if ((ieee->sta_sleep == LPS_IS_WAKE) && !success){ + spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) + { + rtllib_sta_ps_send_null_frame(ieee, 0); + } + else + { + rtllib_sta_ps_send_pspoll_frame(ieee); + } + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); + } + } + spin_unlock_irqrestore(&ieee->lock, flags); +} + +void rtllib_process_action(struct rtllib_device* ieee, struct sk_buff* skb) +{ + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + u8* act = rtllib_get_payload((struct rtllib_hdr *)header); + u8 category = 0; + + if (act == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of action frame\n"); + return; + } + + category = *act; + act ++; + switch (category) { + case ACT_CAT_BA: + switch (*act) { + case ACT_ADDBAREQ: + rtllib_rx_ADDBAReq(ieee, skb); + break; + case ACT_ADDBARSP: + rtllib_rx_ADDBARsp(ieee, skb); + break; + case ACT_DELBA: + rtllib_rx_DELBA(ieee, skb); + break; + } + break; + default: + break; + } + return; +} + +inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +{ + u16 errcode; + int aid; + u8* ies; + struct rtllib_assoc_response_frame *assoc_resp; + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + + RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && + (ieee->iw_mode == IW_MODE_INFRA)) + { + if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ + struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + + if (!network) + return 1; + memset(network,0,sizeof(*network)); + ieee->state=RTLLIB_LINKED; + ieee->assoc_id = aid; + ieee->softmac_stats.rx_ass_ok++; + /* station support qos */ + /* Let the register setting defaultly with Legacy station */ + assoc_resp = (struct rtllib_assoc_response_frame*)skb->data; + if (ieee->current_network.qos_data.supported == 1) { + if (rtllib_parse_info_param(ieee,assoc_resp->info_element,\ + rx_stats->len - sizeof(*assoc_resp),\ + network,rx_stats)){ + kfree(network); + return 1; + } + else + { + memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); + } + if (ieee->handle_assoc_response != NULL) + ieee->handle_assoc_response(ieee->dev, (struct rtllib_assoc_response_frame*)header, network); + kfree(network); + } + + if (ieee->assocresp_ies){ + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + } + ies = &(assoc_resp->info_element[0].id); + ieee->assocresp_ies_len = (skb->data + skb->len) - ies; + ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, GFP_ATOMIC); + if (ieee->assocresp_ies) + memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); + else{ + printk("%s()Warning: can't alloc memory for assocresp_ies\n", __func__); + ieee->assocresp_ies_len = 0; + } + rtllib_associate_complete(ieee); + } else { + /* aid could not been allocated */ + ieee->softmac_stats.rx_ass_err++; + printk( + "Association response status code 0x%x\n", + errcode); + RTLLIB_DEBUG_MGMT( + "Association response status code 0x%x\n", + errcode); + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { + queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + } else { + rtllib_associate_abort(ieee); + } + } + } + + return 0; +} + +inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +{ + u16 errcode; + u8* challenge; + int chlen=0; + bool bSupportNmode = true, bHalfSupportNmode = false; + + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && + (ieee->iw_mode == IW_MODE_INFRA)) { + RTLLIB_DEBUG_MGMT("Received authentication response"); + + if (0 == (errcode=auth_parse(skb, &challenge, &chlen))) { + if (ieee->open_wep || !challenge){ + ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; + ieee->softmac_stats.rx_auth_rs_ok++; + if (!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) + { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) + { + if (IsHTHalfNmodeAPs(ieee)) + { + bSupportNmode = true; + bHalfSupportNmode = true; + } + else + { + bSupportNmode = false; + bHalfSupportNmode = false; + } + } + } + /* Dummy wirless mode setting to avoid encryption issue */ + if (bSupportNmode) { + ieee->SetWirelessMode(ieee->dev, \ + ieee->current_network.mode); + }else{ + /*TODO*/ + ieee->SetWirelessMode(ieee->dev, IEEE_G); + } + + if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) + { + printk("===============>entern half N mode\n"); + ieee->bHalfWirelessN24GMode = true; + } + else + ieee->bHalfWirelessN24GMode = false; + + rtllib_associate_step2(ieee); + }else{ + rtllib_auth_challenge(ieee, challenge, chlen); + } + }else{ + ieee->softmac_stats.rx_auth_rs_err++; + RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); + + printk("Authentication respose status code 0x%x",errcode); + rtllib_associate_abort(ieee); + } + + }else if (ieee->iw_mode == IW_MODE_MASTER){ + rtllib_rx_auth_rq(ieee, skb); + } + } + + return 0; +} + +inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) +{ + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + + if (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) + return 0; + + /* FIXME for now repeat all the association procedure + * both for disassociation and deauthentication + */ + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->state == RTLLIB_LINKED && + (ieee->iw_mode == IW_MODE_INFRA)) { + printk(KERN_INFO "==========>received disassoc/deauth(%x) " + "frame, reason code:%x\n", + WLAN_FC_GET_STYPE(header->frame_ctl), + ((struct rtllib_disassoc*)skb->data)->reason); + ieee->state = RTLLIB_ASSOCIATING; + ieee->softmac_stats.reassoc++; + ieee->is_roaming = true; + ieee->LinkDetectInfo.bBusyTraffic = false; + rtllib_disassociate(ieee); + RemovePeerTS(ieee, header->addr2); + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + + if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 5); + } + + return 0; +} + +inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype) +{ + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + + if (!ieee->proto_started) + return 0; + + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + + case RTLLIB_STYPE_ASSOC_RESP: + case RTLLIB_STYPE_REASSOC_RESP: + + if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) + return 1; + + break; + + case RTLLIB_STYPE_ASSOC_REQ: + case RTLLIB_STYPE_REASSOC_REQ: + + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->iw_mode == IW_MODE_MASTER) + + rtllib_rx_assoc_rq(ieee, skb); + break; + + case RTLLIB_STYPE_AUTH: + + rtllib_rx_auth(ieee, skb, rx_stats); + + break; + case RTLLIB_STYPE_DISASSOC: + case RTLLIB_STYPE_DEAUTH: + + rtllib_rx_deauth(ieee, skb); + + break; + + case RTLLIB_STYPE_MANAGE_ACT: + rtllib_process_action(ieee,skb); + break; +#ifdef COMPATIBLE_WITH_RALINK_MESH + case RTLLIB_STYPE_MESH_ACT: + rtllib_process_action_mesh(ieee,skb,rx_stats); + break; +#endif + default: + return -1; + break; + } + + return 0; +} + +/* following are for a simplier TX queue management. + * Instead of using netif_[stop/wake]_queue the driver + * will uses these two function (plus a reset one), that + * will internally uses the kernel netif_* and takes + * care of the ieee802.11 fragmentation. + * So the driver receives a fragment per time and might + * call the stop function when it want without take care + * to have enought room to TX an entire packet. + * This might be useful if each fragment need it's own + * descriptor, thus just keep a total free memory > than + * the max fragmentation treshold is not enought.. If the + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where + * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD + * In this way you need just one and the 802.11 stack + * will take care of buffering fragments and pass them to + * to the driver later, when it wakes the queue. + */ +void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) +{ + + unsigned int queue_index = txb->queue_index; + unsigned long flags; + int i; + cb_desc *tcb_desc = NULL; + unsigned long queue_len = 0; + + spin_lock_irqsave(&ieee->lock,flags); + + /* called with 2nd parm 0, no tx mgmt lock required */ + rtllib_sta_wakeup(ieee,0); + + /* update the tx status */ + tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + if (tcb_desc->bMulticast) { + ieee->stats.multicast++; + } +#if 1 + /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ + for (i = 0; i < txb->nr_frags; i++) { +#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE + queue_len = skb_queue_len(&ieee->skb_drv_aggQ[queue_index]); +#else + queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); +#endif + if ((queue_len != 0) ||\ + (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ + (ieee->queue_stop)) { + /* insert the skb packet to the wait queue */ + /* as for the completion function, it does not need + * to check it any more. + * */ +#ifdef WIFI_TEST + if (1) +#else + if (queue_len < 200) +#endif + { +#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE + skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]); +#else + skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); +#endif + }else{ + kfree_skb(txb->fragments[i]); + } + }else{ + ieee->softmac_data_hard_start_xmit( + txb->fragments[i], + ieee->dev,ieee->rate); + } + } +#endif + rtllib_txb_free(txb); + + spin_unlock_irqrestore(&ieee->lock,flags); + +} + +/* called with ieee->lock acquired */ +void rtllib_resume_tx(struct rtllib_device *ieee) +{ + int i; + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + + if (ieee->queue_stop){ + ieee->tx_pending.frag = i; + return; + }else{ + + ieee->softmac_data_hard_start_xmit( + ieee->tx_pending.txb->fragments[i], + ieee->dev,ieee->rate); + ieee->stats.tx_packets++; + } + } + + rtllib_txb_free(ieee->tx_pending.txb); + ieee->tx_pending.txb = NULL; +} + + +void rtllib_reset_queue(struct rtllib_device *ieee) +{ + unsigned long flags; + + spin_lock_irqsave(&ieee->lock,flags); + init_mgmt_queue(ieee); + if (ieee->tx_pending.txb){ + rtllib_txb_free(ieee->tx_pending.txb); + ieee->tx_pending.txb = NULL; + } + ieee->queue_stop = 0; + spin_unlock_irqrestore(&ieee->lock,flags); + +} + +void rtllib_wake_queue(struct rtllib_device *ieee) +{ + + unsigned long flags; + struct sk_buff *skb; + struct rtllib_hdr_3addr *header; + + spin_lock_irqsave(&ieee->lock,flags); + if (! ieee->queue_stop) goto exit; + + ieee->queue_stop = 0; + + if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ + while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + + header = (struct rtllib_hdr_3addr *) skb->data; + + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + + ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + } + } + if (!ieee->queue_stop && ieee->tx_pending.txb) + rtllib_resume_tx(ieee); + + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ + ieee->softmac_stats.swtxawake++; + netif_wake_queue(ieee->dev); + } + +exit : + spin_unlock_irqrestore(&ieee->lock,flags); +} + + +void rtllib_stop_queue(struct rtllib_device *ieee) +{ + + if (! netif_queue_stopped(ieee->dev)){ + netif_stop_queue(ieee->dev); + ieee->softmac_stats.swtxstop++; + } + ieee->queue_stop = 1; + +} + +void rtllib_stop_all_queues(struct rtllib_device *ieee) +{ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30) + unsigned int i; + for (i=0; i < ieee->dev->num_tx_queues; i++) + netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; +#else + ieee->dev->trans_start = jiffies; +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) + netif_carrier_off(ieee->dev); +#else + netif_tx_stop_all_queues(ieee->dev); +#endif +} + +void rtllib_wake_all_queues(struct rtllib_device *ieee) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) + netif_carrier_on(ieee->dev); +#else + netif_tx_wake_all_queues(ieee->dev); +#endif +} + +inline void rtllib_randomize_cell(struct rtllib_device *ieee) +{ + + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); + + /* an IBSS cell address must have the two less significant + * bits of the first byte = 2 + */ + ieee->current_network.bssid[0] &= ~0x01; + ieee->current_network.bssid[0] |= 0x02; +} + +/* called in user context only */ +void rtllib_start_master_bss(struct rtllib_device *ieee) +{ + ieee->assoc_id = 1; + + if (ieee->current_network.ssid_len == 0){ + strncpy(ieee->current_network.ssid, + RTLLIB_DEFAULT_TX_ESSID, + IW_ESSID_MAX_SIZE); + + ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); + ieee->ssid_set = 1; + } + + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); + + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->state = RTLLIB_LINKED; + ieee->link_change(ieee->dev); + notify_wx_assoc_event(ieee); + + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); +} + +void rtllib_start_monitor_mode(struct rtllib_device *ieee) +{ + /* reset hardware status */ + if (ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } +} + +void rtllib_start_ibss_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); + /* iwconfig mode ad-hoc will schedule this and return + * on the other hand this will block further iwconfig SET + * operations because of the wx_sem hold. + * Anyway some most set operations set a flag to speed-up + * (abort) this wq (when syncro scanning) before sleeping + * on the semaphore + */ + if (!ieee->proto_started){ + printk("==========oh driver down return\n"); + return; + } + down(&ieee->wx_sem); + + if (ieee->current_network.ssid_len == 0){ + strcpy(ieee->current_network.ssid,RTLLIB_DEFAULT_TX_ESSID); + ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); + ieee->ssid_set = 1; + } + + ieee->state = RTLLIB_NOLINK; +#ifdef ADHOC_11N + ieee->mode = IEEE_N_24G; +#else + ieee->mode = IEEE_G; +#endif + /* check if we have this cell in our network list */ + rtllib_softmac_check_all_nets(ieee); + + + /* if not then the state is not linked. Maybe the user swithced to + * ad-hoc mode just after being in monitor mode, or just after + * being very few time in managed mode (so the card have had no + * time to scan all the chans..) or we have just run up the iface + * after setting ad-hoc mode. So we have to give another try.. + * Here, in ibss mode, should be safe to do this without extra care + * (in bss mode we had to make sure no-one tryed to associate when + * we had just checked the ieee->state and we was going to start the + * scan) beacause in ibss mode the rtllib_new_net function, when + * finds a good net, just set the ieee->state to RTLLIB_LINKED, + * so, at worst, we waste a bit of time to initiate an unneeded syncro + * scan, that will stop at the first round because it sees the state + * associated. + */ + if (ieee->state == RTLLIB_NOLINK) + rtllib_start_scan_syncro(ieee, 0); + + /* the network definitively is not here.. create a new cell */ + if (ieee->state == RTLLIB_NOLINK){ + printk("creating new IBSS cell\n"); + ieee->current_network.channel = ieee->IbssStartChnl; + if (!ieee->wap_set) + rtllib_randomize_cell(ieee); + + if (ieee->modulation & RTLLIB_CCK_MODULATION){ + + ieee->current_network.rates_len = 4; + + ieee->current_network.rates[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; + ieee->current_network.rates[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; + ieee->current_network.rates[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; + ieee->current_network.rates[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; + + }else + ieee->current_network.rates_len = 0; + + if (ieee->modulation & RTLLIB_OFDM_MODULATION){ + ieee->current_network.rates_ex_len = 8; + + /*ieee->current_network.rates_ex[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; + ieee->current_network.rates_ex[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; + ieee->current_network.rates_ex[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; + ieee->current_network.rates_ex[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; + ieee->current_network.rates_ex[4] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; + ieee->current_network.rates_ex[5] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; + ieee->current_network.rates_ex[6] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; + ieee->current_network.rates_ex[7] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;*/ + + ieee->current_network.rates_ex[0] = RTLLIB_OFDM_RATE_6MB; + ieee->current_network.rates_ex[1] = RTLLIB_OFDM_RATE_9MB; + ieee->current_network.rates_ex[2] = RTLLIB_OFDM_RATE_12MB; + ieee->current_network.rates_ex[3] = RTLLIB_OFDM_RATE_18MB; + ieee->current_network.rates_ex[4] = RTLLIB_OFDM_RATE_24MB; + ieee->current_network.rates_ex[5] = RTLLIB_OFDM_RATE_36MB; + ieee->current_network.rates_ex[6] = RTLLIB_OFDM_RATE_48MB; + ieee->current_network.rates_ex[7] = RTLLIB_OFDM_RATE_54MB; + + ieee->rate = 108; + }else{ + ieee->current_network.rates_ex_len = 0; + ieee->rate = 22; + } + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) +#ifdef ADHOC_11N + ieee->current_network.qos_data.supported = 1; +#else + ieee->current_network.qos_data.supported = 0; +#endif + ieee->SetWirelessMode(ieee->dev, ieee->mode); +#else + ieee->current_network.qos_data.supported = 0; + ieee->SetWirelessMode(ieee->dev, IEEE_G); +#endif + ieee->current_network.mode = ieee->mode; + ieee->current_network.atim_window = 0; + ieee->current_network.capability = WLAN_CAPABILITY_IBSS; + } + + printk("%s(): ieee->mode = %d\n", __func__, ieee->mode); + if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G)) + HTUseDefaultSetting(ieee); + else + ieee->pHTInfo->bCurrentHTSupport = false; + + ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&ieee->state)); + + ieee->state = RTLLIB_LINKED; + ieee->link_change(ieee->dev); + + HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev,LED_CTL_LINK); + + rtllib_start_send_beacons(ieee); + + notify_wx_assoc_event(ieee); + + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + + up(&ieee->wx_sem); +} + +inline void rtllib_start_ibss(struct rtllib_device *ieee) +{ + queue_delayed_work_rsl(ieee->wq, &ieee->start_ibss_wq, MSECS(150)); +} + +/* this is called only in user context, with wx_sem held */ +void rtllib_start_bss(struct rtllib_device *ieee) +{ + unsigned long flags; +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) + { + if (! ieee->bGlobalDomain) + { + return; + } + } +#endif + /* check if we have already found the net we + * are interested in (if any). + * if not (we are disassociated and we are not + * in associating / authenticating phase) start the background scanning. + */ + rtllib_softmac_check_all_nets(ieee); + + /* ensure no-one start an associating process (thus setting + * the ieee->state to rtllib_ASSOCIATING) while we + * have just cheked it and we are going to enable scan. + * The rtllib_new_net function is always called with + * lock held (from both rtllib_softmac_check_all_nets and + * the rx path), so we cannot be in the middle of such function + */ + spin_lock_irqsave(&ieee->lock, flags); + + if (ieee->state == RTLLIB_NOLINK) { + rtllib_start_scan(ieee); + } + spin_unlock_irqrestore(&ieee->lock, flags); +} + +void rtllib_link_change_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); + ieee->link_change(ieee->dev); +} +/* called only in userspace context */ +void rtllib_disassociate(struct rtllib_device *ieee) +{ + netif_carrier_off(ieee->dev); + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) + rtllib_reset_queue(ieee); + + if (ieee->data_hard_stop) + ieee->data_hard_stop(ieee->dev); +#ifdef ENABLE_DOT11D + if (IS_DOT11D_ENABLE(ieee)) + Dot11d_Reset(ieee); +#endif + ieee->state = RTLLIB_NOLINK; + ieee->is_set_key = false; + ieee->wap_set = 0; + + queue_delayed_work_rsl(ieee->wq, &ieee->link_change_wq, 0); + + +#ifndef FOR_ANDROID_X86 + notify_wx_assoc_event(ieee); +#endif +} + +void rtllib_associate_retry_wq(void *data) +{ + struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); + unsigned long flags; + + down(&ieee->wx_sem); + if (!ieee->proto_started) + goto exit; + + if (ieee->state != RTLLIB_ASSOCIATING_RETRY) + goto exit; + + /* until we do not set the state to RTLLIB_NOLINK + * there are no possibility to have someone else trying + * to start an association procdure (we get here with + * ieee->state = RTLLIB_ASSOCIATING). + * When we set the state to RTLLIB_NOLINK it is possible + * that the RX path run an attempt to associate, but + * both rtllib_softmac_check_all_nets and the + * RX path works with ieee->lock held so there are no + * problems. If we are still disassociated then start a scan. + * the lock here is necessary to ensure no one try to start + * an association procedure when we have just checked the + * state and we are going to start the scan. + */ + ieee->beinretry = true; + ieee->state = RTLLIB_NOLINK; + + rtllib_softmac_check_all_nets(ieee); + + spin_lock_irqsave(&ieee->lock, flags); + + if (ieee->state == RTLLIB_NOLINK) + { + rtllib_start_scan(ieee); + } + spin_unlock_irqrestore(&ieee->lock, flags); + + ieee->beinretry = false; +exit: + up(&ieee->wx_sem); +} + +struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) +{ + u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; + + struct sk_buff *skb; + struct rtllib_probe_response *b; + skb = rtllib_probe_resp(ieee, broadcast_addr); + + if (!skb) + return NULL; + + b = (struct rtllib_probe_response *) skb->data; + b->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_BEACON); + + return skb; + +} + +struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee) +{ + struct sk_buff *skb; + struct rtllib_probe_response *b; + + skb = rtllib_get_beacon_(ieee); + if (!skb) + return NULL; + + b = (struct rtllib_probe_response *) skb->data; + b->header.seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); + + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; + + return skb; +} + +void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) +{ + rtllib_stop_scan_syncro(ieee); + down(&ieee->wx_sem); + rtllib_stop_protocol(ieee,shutdown); + up(&ieee->wx_sem); +} + + +void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) +{ + if (!ieee->proto_started) + return; + + if (shutdown){ + ieee->proto_started = 0; + ieee->proto_stoppping = 1; + if (ieee->rtllib_ips_leave != NULL) + ieee->rtllib_ips_leave(ieee->dev); + } + + rtllib_stop_send_beacons(ieee); + del_timer_sync(&ieee->associate_timer); + cancel_delayed_work(&ieee->associate_retry_wq); + cancel_delayed_work(&ieee->start_ibss_wq); + cancel_delayed_work(&ieee->link_change_wq); + rtllib_stop_scan(ieee); + + if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) + ieee->state = RTLLIB_NOLINK; + + if (ieee->state == RTLLIB_LINKED){ + if (ieee->iw_mode == IW_MODE_INFRA) + SendDisassociation(ieee,1,deauth_lv_ss); + rtllib_disassociate(ieee); + } + + if (shutdown){ + RemoveAllTS(ieee); + ieee->proto_stoppping = 0; + } + if (ieee->assocreq_ies) { + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; + ieee->assocreq_ies_len = 0; + } + if (ieee->assocresp_ies) { + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + ieee->assocresp_ies_len = 0; + } +} + +void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) +{ + down(&ieee->wx_sem); + rtllib_start_protocol(ieee); + up(&ieee->wx_sem); +} + +void rtllib_start_protocol(struct rtllib_device *ieee) +{ + short ch = 0; + int i = 0; + + rtllib_update_active_chan_map(ieee); + + if (ieee->proto_started) + return; + + ieee->proto_started = 1; + + if (ieee->current_network.channel == 0) { + do { + ch++; + if (ch > MAX_CHANNEL_NUMBER) + return; /* no channel found */ + } while(!ieee->active_channel_map[ch]); + ieee->current_network.channel = ch; + } + + if (ieee->current_network.beacon_interval == 0) + ieee->current_network.beacon_interval = 100; + + for (i = 0; i < 17; i++) { + ieee->last_rxseq_num[i] = -1; + ieee->last_rxfrag_num[i] = -1; + ieee->last_packet_time[i] = 0; + } + + if (ieee->UpdateBeaconInterruptHandler) + ieee->UpdateBeaconInterruptHandler(ieee->dev, false); + + ieee->wmm_acm = 0; + /* if the user set the MAC of the ad-hoc cell and then + * switch to managed mode, shall we make sure that association + * attempts does not fail just because the user provide the essid + * and the nic is still checking for the AP MAC ?? + */ + if (ieee->iw_mode == IW_MODE_INFRA) { + rtllib_start_bss(ieee); + } else if (ieee->iw_mode == IW_MODE_ADHOC) { + if (ieee->UpdateBeaconInterruptHandler) + ieee->UpdateBeaconInterruptHandler(ieee->dev, true); + + rtllib_start_ibss(ieee); + + } else if (ieee->iw_mode == IW_MODE_MASTER) { + rtllib_start_master_bss(ieee); + } else if (ieee->iw_mode == IW_MODE_MONITOR) { + rtllib_start_monitor_mode(ieee); + } +} + +void rtllib_softmac_init(struct rtllib_device *ieee) +{ + int i; + memset(&ieee->current_network, 0, sizeof(struct rtllib_network)); + + ieee->state = RTLLIB_NOLINK; + for (i = 0; i < 5; i++) { + ieee->seq_ctrl[i] = 0; + } +#ifdef ENABLE_DOT11D + ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); + if (!ieee->pDot11dInfo) + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); + memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); +#endif + ieee->LinkDetectInfo.SlotIndex = 0; + ieee->LinkDetectInfo.SlotNum = 2; + ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; + ieee->LinkDetectInfo.NumRecvDataInPeriod=0; + ieee->LinkDetectInfo.NumTxOkInPeriod =0; + ieee->LinkDetectInfo.NumRxOkInPeriod =0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod=0; + ieee->bIsAggregateFrame = false; + ieee->assoc_id = 0; + ieee->queue_stop = 0; + ieee->scanning_continue = 0; + ieee->softmac_features = 0; + ieee->wap_set = 0; + ieee->ssid_set = 0; + ieee->proto_started = 0; + ieee->proto_stoppping = 0; + ieee->basic_rate = RTLLIB_DEFAULT_BASIC_RATE; + ieee->rate = 22; + ieee->ps = RTLLIB_PS_DISABLED; + ieee->sta_sleep = LPS_IS_WAKE; + + ieee->Regdot11HTOperationalRateSet[0]= 0xff; + ieee->Regdot11HTOperationalRateSet[1]= 0xff; + ieee->Regdot11HTOperationalRateSet[4]= 0x01; + + ieee->Regdot11TxHTOperationalRateSet[0]= 0xff; + ieee->Regdot11TxHTOperationalRateSet[1]= 0xff; + ieee->Regdot11TxHTOperationalRateSet[4]= 0x01; + + ieee->FirstIe_InScan = false; + ieee->actscanning = false; + ieee->beinretry = false; + ieee->is_set_key = false; + init_mgmt_queue(ieee); + + ieee->sta_edca_param[0] = 0x0000A403; + ieee->sta_edca_param[1] = 0x0000A427; + ieee->sta_edca_param[2] = 0x005E4342; + ieee->sta_edca_param[3] = 0x002F3262; + ieee->aggregation = true; + ieee->enable_rx_imm_BA = 1; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) + _setup_timer(&ieee->scan_timer, + rtllib_softmac_scan_cb, + (unsigned long) ieee); +#endif + ieee->tx_pending.txb = NULL; + + _setup_timer(&ieee->associate_timer, + rtllib_associate_abort_cb, + (unsigned long) ieee); + + _setup_timer(&ieee->beacon_timer, + rtllib_send_beacon_cb, + (unsigned long) ieee); + +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + _setup_timer(&ieee->ibss_wait_timer, + rtllib_ibss_wait_timeout, + (unsigned long) ieee); +#endif + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) +#ifdef PF_SYNCTHREAD + ieee->wq = create_workqueue(DRV_NAME,0); +#else + ieee->wq = create_workqueue(DRV_NAME); +#endif +#endif + + INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); + INIT_WORK_RSL(&ieee->associate_complete_wq, (void*)rtllib_associate_complete_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, (void*)rtllib_associate_procedure_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,(void*)rtllib_softmac_scan_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,(void*)rtllib_softmac_hint11d_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void*)rtllib_associate_retry_wq,ieee); + INIT_WORK_RSL(&ieee->wx_sync_scan_wq,(void*)rtllib_wx_sync_scan_wq,ieee); + + sema_init(&ieee->wx_sem, 1); + sema_init(&ieee->scan_sem, 1); + sema_init(&ieee->ips_sem,1); + + spin_lock_init(&ieee->mgmt_tx_lock); + spin_lock_init(&ieee->beacon_lock); + + tasklet_init(&ieee->ps_task, + (void(*)(unsigned long)) rtllib_sta_ps, + (unsigned long)ieee); + +} + +void rtllib_softmac_free(struct rtllib_device *ieee) +{ + down(&ieee->wx_sem); +#ifdef ENABLE_DOT11D + if (NULL != ieee->pDot11dInfo) + { + kfree(ieee->pDot11dInfo); + ieee->pDot11dInfo = NULL; + } +#endif + del_timer_sync(&ieee->associate_timer); + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) + cancel_delayed_work(&ieee->associate_retry_wq); + destroy_workqueue(ieee->wq); +#endif + + up(&ieee->wx_sem); +} + +/******************************************************** + * Start of WPA code. * + * this is stolen from the ipw2200 driver * + ********************************************************/ + + +static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) +{ + /* This is called when wpa_supplicant loads and closes the driver + * interface. */ + printk("%s WPA\n",value ? "enabling" : "disabling"); + ieee->wpa_enabled = value; + memset(ieee->ap_mac_addr, 0, 6); + return 0; +} + + +void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, int wpa_ie_len) +{ + /* make sure WPA is enabled */ + rtllib_wpa_enable(ieee, 1); + + rtllib_disassociate(ieee); +} + + +static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason) +{ + + int ret = 0; + + switch (command) { + case IEEE_MLME_STA_DEAUTH: + break; + + case IEEE_MLME_STA_DISASSOC: + rtllib_disassociate(ieee); + break; + + default: + printk("Unknown MLME request: %d\n", command); + ret = -EOPNOTSUPP; + } + + return ret; +} + + +static int rtllib_wpa_set_wpa_ie(struct rtllib_device *ieee, + struct ieee_param *param, int plen) +{ + u8 *buf; + + if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || + (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL)) + return -EINVAL; + + if (param->u.wpa_ie.len) { + buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + memcpy(buf, param->u.wpa_ie.data, param->u.wpa_ie.len); + kfree(ieee->wpa_ie); + ieee->wpa_ie = buf; + ieee->wpa_ie_len = param->u.wpa_ie.len; + } else { + kfree(ieee->wpa_ie); + ieee->wpa_ie = NULL; + ieee->wpa_ie_len = 0; + } + + rtllib_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + return 0; +} + +#define AUTH_ALG_OPEN_SYSTEM 0x1 +#define AUTH_ALG_SHARED_KEY 0x2 +#define AUTH_ALG_LEAP 0x4 +static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) +{ + + struct rtllib_security sec = { + .flags = SEC_AUTH_MODE, + }; + int ret = 0; + + if (value & AUTH_ALG_SHARED_KEY) { + sec.auth_mode = WLAN_AUTH_SHARED_KEY; + ieee->open_wep = 0; + ieee->auth_mode = 1; + } else if (value & AUTH_ALG_OPEN_SYSTEM){ + sec.auth_mode = WLAN_AUTH_OPEN; + ieee->open_wep = 1; + ieee->auth_mode = 0; + } + else if (value & AUTH_ALG_LEAP){ + sec.auth_mode = WLAN_AUTH_LEAP >> 6; + ieee->open_wep = 1; + ieee->auth_mode = 2; + } + + + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); + + return ret; +} + +static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) +{ + int ret=0; + unsigned long flags; + + switch (name) { + case IEEE_PARAM_WPA_ENABLED: + ret = rtllib_wpa_enable(ieee, value); + break; + + case IEEE_PARAM_TKIP_COUNTERMEASURES: + ieee->tkip_countermeasures=value; + break; + + case IEEE_PARAM_DROP_UNENCRYPTED: + { + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + struct rtllib_security sec = { + .flags = SEC_ENABLED, + .enabled = value, + }; + ieee->drop_unencrypted = value; + /* We only change SEC_LEVEL for open mode. Others + * are set by ipw_wpa_set_encryption. + */ + if (!value) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_0; + } + else { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); + break; + } + + case IEEE_PARAM_PRIVACY_INVOKED: + ieee->privacy_invoked=value; + break; + + case IEEE_PARAM_AUTH_ALGS: + ret = rtllib_wpa_set_auth_algs(ieee, value); + break; + + case IEEE_PARAM_IEEE_802_1X: + ieee->ieee802_1x=value; + break; + case IEEE_PARAM_WPAX_SELECT: + spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); + spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); + break; + + default: + printk("Unknown WPA param: %d\n",name); + ret = -EOPNOTSUPP; + } + + return ret; +} + +/* implementation borrowed from hostap driver */ +static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, + struct ieee_param *param, int param_len, u8 is_mesh) +{ + int ret = 0; + struct rtllib_crypto_ops *ops; + struct rtllib_crypt_data **crypt; + + struct rtllib_security sec = { + .flags = 0, + }; + + param->u.crypt.err = 0; + param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; + + if (param_len != + (int) ((char *) param->u.crypt.key - (char *) param) + + param->u.crypt.key_len) { + printk("Len mismatch %d, %d\n", param_len, + param->u.crypt.key_len); + return -EINVAL; + } + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) + return -EINVAL; + crypt = &ieee->crypt[param->u.crypt.idx]; + } else { + return -EINVAL; + } + + if (strcmp(param->u.crypt.alg, "none") == 0) { + if (crypt) { + sec.enabled = 0; + sec.level = SEC_LEVEL_0; + sec.flags |= SEC_ENABLED | SEC_LEVEL; + rtllib_crypt_delayed_deinit(ieee, crypt); + } + goto done; + } + sec.enabled = 1; + sec.flags |= SEC_ENABLED; + + /* IPW HW cannot build TKIP MIC, host decryption still needed. */ + if (!(ieee->host_encrypt || ieee->host_decrypt) && + strcmp(param->u.crypt.alg, "TKIP")) + goto skip_host_crypt; + + ops = rtllib_get_crypto_ops(param->u.crypt.alg); + if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { + request_module("rtllib_crypt_wep"); + ops = rtllib_get_crypto_ops(param->u.crypt.alg); + } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { + request_module("rtllib_crypt_tkip"); + ops = rtllib_get_crypto_ops(param->u.crypt.alg); + } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { + request_module("rtllib_crypt_ccmp"); + ops = rtllib_get_crypto_ops(param->u.crypt.alg); + } + if (ops == NULL) { + printk("unknown crypto alg '%s'\n", param->u.crypt.alg); + param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; + ret = -EINVAL; + goto done; + } + if (*crypt == NULL || (*crypt)->ops != ops) { + struct rtllib_crypt_data *new_crypt; + + rtllib_crypt_delayed_deinit(ieee, crypt); + + new_crypt = (struct rtllib_crypt_data *) + kmalloc(sizeof(*new_crypt), GFP_KERNEL); + if (new_crypt == NULL) { + ret = -ENOMEM; + goto done; + } + memset(new_crypt, 0, sizeof(struct rtllib_crypt_data)); + new_crypt->ops = ops; + if (new_crypt->ops) + new_crypt->priv = + new_crypt->ops->init(param->u.crypt.idx); + + if (new_crypt->priv == NULL) { + kfree(new_crypt); + param->u.crypt.err = IEEE_CRYPT_ERR_CRYPT_INIT_FAILED; + ret = -EINVAL; + goto done; + } + + *crypt = new_crypt; + } + + if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key && + (*crypt)->ops->set_key(param->u.crypt.key, + param->u.crypt.key_len, param->u.crypt.seq, + (*crypt)->priv) < 0) { + printk("key setting failed\n"); + param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; + ret = -EINVAL; + goto done; + } + + skip_host_crypt: + if (param->u.crypt.set_tx) { + ieee->tx_keyidx = param->u.crypt.idx; + sec.active_key = param->u.crypt.idx; + sec.flags |= SEC_ACTIVE_KEY; + } else + sec.flags &= ~SEC_ACTIVE_KEY; + + if (param->u.crypt.alg != NULL) { + memcpy(sec.keys[param->u.crypt.idx], + param->u.crypt.key, + param->u.crypt.key_len); + sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len; + sec.flags |= (1 << param->u.crypt.idx); + + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_2; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_3; + } + } + done: + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); + + /* Do not reset port if card is in Managed mode since resetting will + * generate new IEEE 802.11 authentication which may end up in looping + * with IEEE 802.1X. If your hardware requires a reset after WEP + * configuration (for example... Prism2), implement the reset_port in + * the callbacks structures used to initialize the 802.11 stack. */ + if (ieee->reset_on_keychange && + ieee->iw_mode != IW_MODE_INFRA && + ieee->reset_port && + ieee->reset_port(ieee->dev)) { + printk("reset_port failed\n"); + param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; + return -EINVAL; + } + + return ret; +} + +inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, + struct rtllib_device *ieee, u16 asRsn) +{ + struct sk_buff *skb; + struct rtllib_disauth *disauth; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE; +#else + int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; + +#endif + skb = dev_alloc_skb(len); + if (!skb) { + return NULL; + } + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + skb_reserve(skb, ieee->tx_headroom); + + disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); + disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); + disauth->header.duration_id = 0; + + memcpy(disauth->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(disauth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(disauth->header.addr3, beacon->bssid, ETH_ALEN); + + disauth->reason = cpu_to_le16(asRsn); + return skb; +} + +inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, + struct rtllib_device *ieee, u16 asRsn) +{ + struct sk_buff *skb; + struct rtllib_disassoc *disass; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; + int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE; +#else + int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; +#endif + skb = dev_alloc_skb(len); + + if (!skb) { + return NULL; + } + +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)skb->data; + alignment = Tmpaddr & 0x1ff; + skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif + skb_reserve(skb, ieee->tx_headroom); + + disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); + disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); + disass->header.duration_id = 0; + + memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN); + + disass->reason = cpu_to_le16(asRsn); + return skb; +} + +void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) +{ + struct rtllib_network *beacon = &ieee->current_network; + struct sk_buff *skb; + + if (deauth) { + skb = rtllib_disauth_skb(beacon,ieee,asRsn); + } else { + skb = rtllib_disassociate_skb(beacon,ieee,asRsn); + } + + if (skb){ + softmac_mgmt_xmit(skb, ieee); + } +} + +u8 rtllib_ap_sec_type(struct rtllib_device *ieee) +{ + static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; + static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; + int wpa_ie_len= ieee->wpa_ie_len; + struct rtllib_crypt_data* crypt; + int encrypt; + + crypt = ieee->crypt[ieee->tx_keyidx]; + encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\ + (ieee->host_encrypt && crypt && crypt->ops && \ + (0 == strcmp(crypt->ops->name,"WEP"))); + + /* simply judge */ + if (encrypt && (wpa_ie_len == 0)) { + return SEC_ALG_WEP; + } else if ((wpa_ie_len != 0)) { + if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || + ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) + return SEC_ALG_CCMP; + else + return SEC_ALG_TKIP; + } else { + return SEC_ALG_NONE; + } +} + +int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh) +{ + struct ieee_param *param; + int ret=0; + + down(&ieee->wx_sem); + + if (p->length < sizeof(struct ieee_param) || !p->pointer){ + ret = -EINVAL; + goto out; + } + + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); + if (param == NULL){ + ret = -ENOMEM; + goto out; + } + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + ret = -EFAULT; + goto out; + } + + switch (param->cmd) { + + case IEEE_CMD_SET_WPA_PARAM: + ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name, + param->u.wpa_param.value); + break; + + case IEEE_CMD_SET_WPA_IE: + ret = rtllib_wpa_set_wpa_ie(ieee, param, p->length); + break; + + case IEEE_CMD_SET_ENCRYPTION: + ret = rtllib_wpa_set_encryption(ieee, param, p->length, 0); + break; + + case IEEE_CMD_MLME: + ret = rtllib_wpa_mlme(ieee, param->u.mlme.command, + param->u.mlme.reason_code); + break; + + default: + printk("Unknown WPA supplicant request: %d\n",param->cmd); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + + kfree(param); +out: + up(&ieee->wx_sem); + + return ret; +} + +void +rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) +{ + u8 OpMode; + u8 i; + bool bFilterOutNonAssociatedBSSID = false; + + rtllib->state = RTLLIB_NOLINK; + + for (i=0;i<6;i++) rtllib->current_network.bssid[i]= 0x55; + + rtllib->OpMode = RT_OP_MODE_NO_LINK; + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + OpMode = RT_OP_MODE_NO_LINK; + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode); + rtllib_stop_send_beacons(rtllib); + + bFilterOutNonAssociatedBSSID = false; + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); + notify_wx_assoc_event(rtllib); + +} + +void +rtllib_MlmeDisassociateRequest( + struct rtllib_device* rtllib, + u8* asSta, + u8 asRsn + ) +{ + u8 i; + u8 OpMode; + + RemovePeerTS(rtllib, asSta); + + + if (memcpy(rtllib->current_network.bssid,asSta,6) == 0) + { + rtllib->state = RTLLIB_NOLINK; + + for (i=0;i<6;i++) rtllib->current_network.bssid[i] = 0x22; + OpMode = RT_OP_MODE_NO_LINK; + rtllib->OpMode = RT_OP_MODE_NO_LINK; + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&OpMode) ); + rtllib_disassociate(rtllib); + + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + + } + +} + +void +rtllib_MgntDisconnectAP( + struct rtllib_device* rtllib, + u8 asRsn +) +{ + bool bFilterOutNonAssociatedBSSID = false; + + +#ifdef TO_DO + if ( pMgntInfo->SecurityInfo.AuthMode > RT_802_11AuthModeAutoSwitch || + (pMgntInfo->bAPSuportCCKM && pMgntInfo->bCCX8021xenable) ) + { + SecClearAllKeys(rtllib->dev); + RT_TRACE(COMP_SEC, DBG_LOUD,("======>CCKM clear key...")) + } +#endif + bFilterOutNonAssociatedBSSID = false; + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); + rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); + + rtllib->state = RTLLIB_NOLINK; +} + +bool +rtllib_MgntDisconnect( + struct rtllib_device* rtllib, + u8 asRsn +) +{ + if (rtllib->ps != RTLLIB_PS_DISABLED) + { +#ifndef RTL8190P + rtllib->sta_wake_up(rtllib->dev); +#endif + } + +#ifdef TO_DO + if (pMgntInfo->mActingAsAp) + { + RT_TRACE(COMP_MLME, DBG_LOUD, ("MgntDisconnect() ===> AP_DisassociateAllStation\n")); + AP_DisassociateAllStation(rtllib->dev, unspec_reason); + return true; + } +#endif + + if ( rtllib->state == RTLLIB_LINKED ) + { + if ( rtllib->iw_mode == IW_MODE_ADHOC ) + { + rtllib_MgntDisconnectIBSS(rtllib); + } + if ( rtllib->iw_mode == IW_MODE_INFRA ) + { +#ifdef TO_DO_LIST + SecClearAllKeys(Adapter); +#endif + rtllib_MgntDisconnectAP(rtllib, asRsn); + } + + } + + return true; +} + +void notify_wx_assoc_event(struct rtllib_device *ieee) +{ + union iwreq_data wrqu; + + if (ieee->cannot_notify) + return; + + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + if (ieee->state == RTLLIB_LINKED) + memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); + else{ + + printk("%s(): Tell user space disconnected\n",__func__); + memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); + } + wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); +} diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c similarity index 55% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_softmac_wx.c rename to drivers/staging/rtl8192e/rtllib_softmac_wx.c index d8a068e32e5..7cda2908bae 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -14,13 +14,14 @@ */ -#include "ieee80211.h" +#include "rtllib.h" +#include "rtl_core.h" #ifdef ENABLE_DOT11D #include "dot11d.h" #endif /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { +const long rtllib_wlan_frequencies[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, @@ -28,7 +29,7 @@ const long ieee80211_wlan_frequencies[] = { }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; @@ -36,8 +37,8 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info down(&ieee->wx_sem); - if(ieee->iw_mode == IW_MODE_INFRA){ - ret = -EOPNOTSUPP; + if (ieee->iw_mode == IW_MODE_INFRA){ + ret = 0; goto out; } @@ -48,7 +49,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info int f = fwrq->m / 100000; int c = 0; - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + while ((c < 14) && (f != rtllib_wlan_frequencies[c])) c++; /* hack to fall through */ @@ -64,19 +65,19 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info }else { /* Set the channel */ #ifdef ENABLE_DOT11D - if (!(GET_DOT11D_INFO(ieee)->channel_map)[fwrq->m]) { + if (ieee->active_channel_map[fwrq->m] != 1) { ret = -EINVAL; goto out; } #endif ieee->current_network.channel = fwrq->m; - ieee->set_chan(ieee, ieee->current_network.channel); + ieee->set_chan(ieee->dev, ieee->current_network.channel); - if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - if(ieee->state == IEEE80211_LINKED){ + if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) + if (ieee->state == RTLLIB_LINKED){ - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + rtllib_stop_send_beacons(ieee); + rtllib_start_send_beacons(ieee); } } @@ -87,7 +88,7 @@ out: } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -95,18 +96,17 @@ int ieee80211_wx_get_freq(struct ieee80211_device *ieee, if (ieee->current_network.channel == 0) return -1; - //NM 0.7.0 will not accept channel any more. - fwrq->m = ieee80211_wlan_frequencies[ieee->current_network.channel-1] * 100000; + fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * 100000; fwrq->e = 1; - return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +int rtllib_wx_get_wap(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; if (ieee->iw_mode == IW_MODE_MONITOR) @@ -115,8 +115,8 @@ int ieee80211_wx_get_wap(struct ieee80211_device *ieee, /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state != IEEE80211_LINKED && - ieee->state != IEEE80211_LINKED_SCANNING && + if (ieee->state != RTLLIB_LINKED && + ieee->state != RTLLIB_LINKED_SCANNING && ieee->wap_set == 0) memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); @@ -130,7 +130,7 @@ int ieee80211_wx_get_wap(struct ieee80211_device *ieee, } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int rtllib_wx_set_wap(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) @@ -140,10 +140,10 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee, u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - short ifup = ieee->proto_started;//dev->flags & IFF_UP; + short ifup = ieee->proto_started; struct sockaddr *temp = (struct sockaddr *)awrq; - ieee->sync_scan_hurryup = 1; + rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); /* use ifconfig hw ether */ @@ -157,27 +157,38 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee, goto out; } + if (memcmp(temp->sa_data, zero,ETH_ALEN) == 0){ + spin_lock_irqsave(&ieee->lock, flags); + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ieee->wap_set = 0; + spin_unlock_irqrestore(&ieee->lock, flags); + ret = -1; + goto out; + } + + if (ifup) - ieee80211_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee,true); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); + ieee->cannot_notify = false; memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; + ieee->wap_set = (memcmp(temp->sa_data, zero,ETH_ALEN)!=0); spin_unlock_irqrestore(&ieee->lock, flags); if (ifup) - ieee80211_start_protocol(ieee); + rtllib_start_protocol(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; @@ -194,8 +205,8 @@ out: goto out; } - if (ieee->state != IEEE80211_LINKED && - ieee->state != IEEE80211_LINKED_SCANNING && + if (ieee->state != RTLLIB_LINKED && + ieee->state != RTLLIB_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; goto out; @@ -212,7 +223,7 @@ out: } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int rtllib_wx_set_rate(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,26 +231,37 @@ int ieee80211_wx_set_rate(struct ieee80211_device *ieee, u32 target_rate = wrqu->bitrate.value; ieee->rate = target_rate/100000; - //FIXME: we might want to limit rate also in management protocols. return 0; } - - -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +int rtllib_wx_get_rate(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - u32 tmp_rate; - tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); - + u32 tmp_rate = 0; +#if defined RTL8192SU + if (ieee->mode & (IEEE_A | IEEE_B | IEEE_G)) + tmp_rate = ieee->rate; + else if (ieee->mode & IEEE_N_5G) + tmp_rate = 580; + else if (ieee->mode & IEEE_N_24G) { + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) + tmp_rate = HTHalfMcsToDataRate(ieee, 15); + else + tmp_rate = HTMcsToDataRate(ieee, 15); + } +#elif defined RTL8192SE || defined RTL8192CE + tmp_rate = ieee->rtl_11n_user_show_rates(ieee->dev); +#else + tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); +#endif wrqu->bitrate.value = tmp_rate * 500000; return 0; } -int ieee80211_wx_set_rts(struct ieee80211_device *ieee, +int rtllib_wx_set_rts(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -255,7 +277,7 @@ int ieee80211_wx_set_rts(struct ieee80211_device *ieee, return 0; } -int ieee80211_wx_get_rts(struct ieee80211_device *ieee, +int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -264,113 +286,145 @@ int ieee80211_wx_get_rts(struct ieee80211_device *ieee, wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { + int set_mode_status = 0; - ieee->sync_scan_hurryup = 1; - + rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); + switch (wrqu->mode) { + case IW_MODE_MONITOR: + case IW_MODE_ADHOC: + case IW_MODE_INFRA: + break; + case IW_MODE_AUTO: + wrqu->mode = IW_MODE_INFRA; + break; + default: + set_mode_status = -EINVAL; + goto out; + } if (wrqu->mode == ieee->iw_mode) goto out; - if (wrqu->mode == IW_MODE_MONITOR){ - + if (wrqu->mode == IW_MODE_MONITOR) { +#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) + ieee->dev->type = ARPHRD_IEEE80211_RADIOTAP; +#else ieee->dev->type = ARPHRD_IEEE80211; - }else{ +#endif + rtllib_EnableNetMonitorMode(ieee->dev,false); + + } else { ieee->dev->type = ARPHRD_ETHER; + if (ieee->iw_mode == IW_MODE_MONITOR) + rtllib_DisableNetMonitorMode(ieee->dev,false); } - if (!ieee->proto_started){ + if (!ieee->proto_started) { ieee->iw_mode = wrqu->mode; - }else{ - ieee80211_stop_protocol(ieee,true); + } else { + rtllib_stop_protocol(ieee,true); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + rtllib_start_protocol(ieee); } out: up(&ieee->wx_sem); - return 0; + return set_mode_status; } -void ieee80211_wx_sync_scan_wq(struct work_struct *work) +void rtllib_wx_sync_scan_wq(void *data) { - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); short chan; HT_EXTCHNL_OFFSET chan_offset=0; HT_CHANNEL_WIDTH bandwidth=0; int b40M = 0; static int count = 0; - chan = ieee->current_network.channel; -#ifdef ENABLE_LPS - if (ieee->LeisurePSLeave) { - ieee->LeisurePSLeave(ieee); + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + rtllib_start_scan_syncro(ieee, 0); + goto out; } + chan = ieee->current_network.channel; + + if (ieee->LeisurePSLeave) + ieee->LeisurePSLeave(ieee->dev); /* notify AP to be in PS mode */ - ieee80211_sta_ps_send_null_frame(ieee, 1); - ieee80211_sta_ps_send_null_frame(ieee, 1); -#endif + rtllib_sta_ps_send_null_frame(ieee, 1); + rtllib_sta_ps_send_null_frame(ieee, 1); + + rtllib_stop_all_queues(ieee); if (ieee->data_hard_stop) - ieee->data_hard_stop(ieee); + ieee->data_hard_stop(ieee->dev); + rtllib_stop_send_beacons(ieee); + ieee->state = RTLLIB_LINKED_SCANNING; + ieee->link_change(ieee->dev); + /* wait for ps packet to be kicked out successfully */ + msleep(50); - ieee80211_stop_send_beacons(ieee); + if (ieee->ScanOperationBackupHandler) + ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); - ieee->state = IEEE80211_LINKED_SCANNING; - ieee->link_change(ieee); - ieee->InitialGainHandler(ieee, IG_Backup); if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; bandwidth = (HT_CHANNEL_WIDTH)ieee->pHTInfo->bCurBW40MHz; - printk("Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); - ieee->SetBWModeHandler(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } - ieee80211_start_scan_syncro(ieee); + + rtllib_start_scan_syncro(ieee, 0); + if (b40M) { - printk("Scan in 20M, back to 40M\n"); + RT_TRACE(COMP_DBG, "Scan in 20M, back to 40M\n"); if (chan_offset == HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee, chan + 2); + ieee->set_chan(ieee->dev, chan + 2); else if (chan_offset == HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee, chan - 2); + ieee->set_chan(ieee->dev, chan - 2); else - ieee->set_chan(ieee, chan); - ieee->SetBWModeHandler(ieee, bandwidth, chan_offset); + ieee->set_chan(ieee->dev, chan); + ieee->SetBWModeHandler(ieee->dev, bandwidth, chan_offset); } else { - ieee->set_chan(ieee, chan); + ieee->set_chan(ieee->dev, chan); } - ieee->InitialGainHandler(ieee, IG_Restore); - ieee->state = IEEE80211_LINKED; - ieee->link_change(ieee); + if (ieee->ScanOperationBackupHandler) + ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); + + ieee->state = RTLLIB_LINKED; + ieee->link_change(ieee->dev); -#ifdef ENABLE_LPS /* Notify AP that I wake up again */ - ieee80211_sta_ps_send_null_frame(ieee, 0); -#endif + rtllib_sta_ps_send_null_frame(ieee, 0); - // To prevent the immediately calling watch_dog after scan. - if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; } - if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); - if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) + rtllib_start_send_beacons(ieee); + + rtllib_wake_all_queues(ieee); count = 0; +out: up(&ieee->wx_sem); } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; @@ -382,8 +436,8 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info goto out; } - if ( ieee->state == IEEE80211_LINKED){ - queue_work(ieee->wq, &ieee->wx_sync_scan_wq); + if ( ieee->state == RTLLIB_LINKED){ + queue_work_rsl(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } @@ -393,21 +447,27 @@ out: return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - int ret=0,len; + int ret=0,len,i; short proto_started; unsigned long flags; - ieee->sync_scan_hurryup = 1; + rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); proto_started = ieee->proto_started; - if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; +#else + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; +#endif + + if (len > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } @@ -417,10 +477,16 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, goto out; } - if(proto_started){ - ieee80211_stop_protocol(ieee,true); + for (i=0; ilock, flags); if (wrqu->essid.flags && wrqu->essid.length) { - //first flush current network.ssid - len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - strncpy(ieee->current_network.ssid, extra, len+1); - ieee->current_network.ssid_len = len+1; + strncpy(ieee->current_network.ssid, extra, len); + ieee->current_network.ssid_len = len; + ieee->cannot_notify = false; ieee->ssid_set = 1; } else{ @@ -442,21 +507,20 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, spin_unlock_irqrestore(&ieee->lock, flags); if (proto_started) - ieee80211_start_protocol(ieee); + rtllib_start_protocol(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - wrqu->mode = ieee->iw_mode; return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, + int rtllib_wx_set_rawtx(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -467,7 +531,7 @@ out: down(&ieee->wx_sem); - if(enable) + if (enable) ieee->raw_tx = 1; else ieee->raw_tx = 0; @@ -475,16 +539,16 @@ out: printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); - if(ieee->iw_mode == IW_MODE_MONITOR) + if (ieee->iw_mode == IW_MODE_MONITOR) { - if(prev == 0 && ieee->raw_tx){ + if (prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) - ieee->data_hard_resume(ieee); + ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } - if(prev && ieee->raw_tx == 1) + if (prev && ieee->raw_tx == 1) netif_carrier_off(ieee->dev); } @@ -493,14 +557,15 @@ out: return 0; } -int ieee80211_wx_get_name(struct ieee80211_device *ieee, +int rtllib_wx_get_name(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); - if(ieee->modulation & IEEE80211_CCK_MODULATION) + + if (ieee->modulation & RTLLIB_CCK_MODULATION) strcat(wrqu->name, "b"); - if(ieee->modulation & IEEE80211_OFDM_MODULATION) + if (ieee->modulation & RTLLIB_OFDM_MODULATION) strcat(wrqu->name, "g"); if (ieee->mode & (IEEE_N_24G | IEEE_N_5G)) strcat(wrqu->name, "n"); @@ -509,42 +574,48 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee, /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int rtllib_wx_set_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret = 0; - - if( +#if 1 + if ( (!ieee->sta_wake_up) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ + RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): PS mode is tryied to be use but driver missed a callback\n\n",__func__); + return -1; } - +#endif down(&ieee->wx_sem); if (wrqu->power.disabled){ - ieee->ps = IEEE80211_PS_DISABLED; + RT_TRACE(COMP_DBG, "===>%s(): power disable\n",__func__); + ieee->ps = RTLLIB_PS_DISABLED; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { ieee->ps_timeout = wrqu->power.value / 1000; + RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n",__func__,ieee->ps_timeout); } if (wrqu->power.flags & IW_POWER_PERIOD) { + ieee->ps_period = wrqu->power.value / 1000; + } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: - ieee->ps = IEEE80211_PS_UNICAST; + ieee->ps = RTLLIB_PS_UNICAST; break; case IW_POWER_MULTICAST_R: - ieee->ps = IEEE80211_PS_MBCAST; + ieee->ps = RTLLIB_PS_MBCAST; break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = RTLLIB_PS_UNICAST | RTLLIB_PS_MBCAST; break; case IW_POWER_ON: @@ -562,7 +633,7 @@ exit: } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -570,7 +641,7 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, down(&ieee->wx_sem); - if(ieee->ps == IEEE80211_PS_DISABLED){ + if (ieee->ps == RTLLIB_PS_DISABLED) { wrqu->power.disabled = 1; goto exit; } @@ -585,9 +656,9 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, wrqu->power.value = ieee->ps_period * 1000; } - if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) - wrqu->power.flags |= IW_POWER_ALL_R; - else if (ieee->ps & IEEE80211_PS_MBCAST) + if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) + wrqu->power.flags |= IW_POWER_ALL_R; + else if (ieee->ps & RTLLIB_PS_MBCAST) wrqu->power.flags |= IW_POWER_MULTICAST_R; else wrqu->power.flags |= IW_POWER_UNICAST_R; @@ -597,4 +668,3 @@ exit: return ret; } - diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c similarity index 56% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_tx.c rename to drivers/staging/rtl8192e/rtllib_tx.c index 424dd48da66..3cc066eb530 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -46,13 +46,17 @@ #include #include #include +#include #include #include #include #include -#include "ieee80211.h" +#include "rtllib.h" +#ifdef RTK_DMP_PLATFORM +#include +#endif /* @@ -154,12 +158,12 @@ payload of each frame is reduced to 492 bytes. static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +inline int rtllib_put_snap(u8 *data, u16 h_proto) { - struct ieee80211_snap_hdr *snap; + struct rtllib_snap_hdr *snap; u8 *oui; - snap = (struct ieee80211_snap_hdr *)data; + snap = (struct rtllib_snap_hdr *)data; snap->dsap = 0xaa; snap->ssap = 0xaa; snap->ctrl = 0x03; @@ -177,29 +181,31 @@ static inline int ieee80211_put_snap(u8 *data, u16 h_proto) return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( - struct ieee80211_device *ieee, +int rtllib_encrypt_fragment( + struct rtllib_device *ieee, struct sk_buff *frag, int hdr_len) { - struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx]; + struct rtllib_crypt_data* crypt = NULL; int res; + crypt = ieee->crypt[ieee->tx_keyidx]; + if (!(crypt && crypt->ops)) { - printk("=========>%s(), crypt is null\n", __FUNCTION__); + printk("=========>%s(), crypt is null\n", __func__); return -1; } -#ifdef CONFIG_IEEE80211_CRYPT_TKIP - struct ieee80211_hdr *header; +#ifdef CONFIG_RTLLIB_CRYPT_TKIP + struct rtllib_hdr_1addr *header; if (ieee->tkip_countermeasures && crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { - header = (struct ieee80211_hdr *) frag->data; + header = (struct rtllib_hdr_1addr *) frag->data; if (net_ratelimit()) { printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "TX packet to %pM\n", - ieee->dev->name, header->addr1); + "TX packet to " MAC_FMT "\n", + ieee->dev->name, MAC_ARG(header->addr1)); } return -1; } @@ -207,7 +213,6 @@ int ieee80211_encrypt_fragment( /* To encrypt, frame format is: * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */ - // PR: FIXME: Copied from hostap. Check fragmentation/MSDU/MPDU encryption. /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so * call both MSDU and MPDU encryption functions from here. */ atomic_inc(&crypt->refcnt); @@ -229,33 +234,46 @@ int ieee80211_encrypt_fragment( } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void rtllib_txb_free(struct rtllib_txb *txb) { if (unlikely(!txb)) return; kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, int gfp_mask) { - struct ieee80211_txb *txb; +#ifdef USB_USE_ALIGNMENT + u32 Tmpaddr=0; + int alignment=0; +#endif + struct rtllib_txb *txb; int i; txb = kmalloc( - sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags), + sizeof(struct rtllib_txb) + (sizeof(u8*) * nr_frags), gfp_mask); if (!txb) return NULL; - memset(txb, 0, sizeof(struct ieee80211_txb)); + memset(txb, 0, sizeof(struct rtllib_txb)); txb->nr_frags = nr_frags; txb->frag_size = txb_size; for (i = 0; i < nr_frags; i++) { +#ifdef USB_USE_ALIGNMENT + txb->fragments[i] = dev_alloc_skb(txb_size+USB_512B_ALIGNMENT_SIZE); +#else txb->fragments[i] = dev_alloc_skb(txb_size); +#endif if (unlikely(!txb->fragments[i])) { i--; break; } +#ifdef USB_USE_ALIGNMENT + Tmpaddr = (u32)(txb->fragments[i]->data); + alignment = Tmpaddr & 0x1ff; + skb_reserve(txb->fragments[i],(USB_512B_ALIGNMENT_SIZE - alignment)); +#endif memset(txb->fragments[i]->cb, 0, sizeof(txb->fragments[i]->cb)); } if (unlikely(i != nr_frags)) { @@ -267,107 +285,97 @@ struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, return txb; } -// Classify the to-be send data packet -// Need to acquire the sent queue index. -static int -ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network) +int +rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) { struct ethhdr *eth; struct iphdr *ip; + eth = (struct ethhdr *)skb->data; if (eth->h_proto != htons(ETH_P_IP)) return 0; + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA, skb->data, skb->len); ip = ip_hdr(skb); switch (ip->tos & 0xfc) { - case 0x20: - return 2; - case 0x40: - return 1; - case 0x60: - return 3; - case 0x80: - return 4; - case 0xa0: - return 5; - case 0xc0: - return 6; - case 0xe0: - return 7; - default: - return 0; + case 0x20: + return 2; + case 0x40: + return 1; + case 0x60: + return 3; + case 0x80: + return 4; + case 0xa0: + return 5; + case 0xc0: + return 6; + case 0xe0: + return 7; + default: + return 0; } } #define SN_LESS(a, b) (((a-b)&0x800)!=0) -void ieee80211_tx_query_agg_cap(struct ieee80211_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc) +void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; PTX_TS_RECORD pTxTs = NULL; - struct ieee80211_hdr_1addr* hdr = (struct ieee80211_hdr_1addr*)skb->data; + struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; + + if (rtllib_act_scanning(ieee,false)) + return; if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; if (!IsQoSDataFrame(skb->data)) return; - if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1)) return; - //check packet and mode later #ifdef TO_DO_LIST - if(pTcb->PacketLength >= 4096) + if (pTcb->PacketLength >= 4096) return; - // For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation. - if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter)) + if (!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter)) return; #endif - if(tcb_desc->bdhcp)// || ieee->CntAfterLink<2) - { - return; - } - - -#if 1 - if (!ieee->GetNmodeSupportBySecCfg(ieee)) - { + if (tcb_desc->bdhcp || ieee->CntAfterLink<2) return; - } -#endif - if(pHTInfo->bCurrentAMPDUEnable) - { - if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) - { - printk("===>can't get TS\n"); + + if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) + return; + + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) + return; + if (pHTInfo->bCurrentAMPDUEnable){ + if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ + printk("%s: can't get TS\n", __func__); return; } - if (pTxTs->TxAdmittedBARecord.bValid == false) - { - //as some AP will refuse our action frame until key handshake has been finished. WB - if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA)) - ; - else - TsStartAddBaProcess(ieee, pTxTs); + if (pTxTs->TxAdmittedBARecord.bValid == false){ + if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA)) { + ; + } else if (tcb_desc->bdhcp == 1){ + ; + } else if (!pTxTs->bDisable_AddBa){ + TsStartAddBaProcess(ieee, pTxTs); + } goto FORCED_AGG_SETTING; - } - else if (pTxTs->bUsingBa == false) - { + } else if (pTxTs->bUsingBa == false) { if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; } - - if (ieee->iw_mode == IW_MODE_INFRA) - { + if (ieee->iw_mode == IW_MODE_INFRA) { tcb_desc->bAMPDUEnable = true; tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor; tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity; } } FORCED_AGG_SETTING: - switch(pHTInfo->ForcedAMPDUMode ) - { + switch (pHTInfo->ForcedAMPDUMode) { case HT_AGG_AUTO: break; @@ -387,11 +395,11 @@ FORCED_AGG_SETTING: return; } -extern void ieee80211_qurey_ShortPreambleMode(struct ieee80211_device* ieee, cb_desc* tcb_desc) +extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, cb_desc* tcb_desc) { tcb_desc->bUseShortPreamble = false; if (tcb_desc->data_rate == 2) - {//// 1M can only use Long Preamble. 11B spec + { return; } else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) @@ -400,69 +408,110 @@ extern void ieee80211_qurey_ShortPreambleMode(struct ieee80211_device* ieee, cb_ } return; } + extern void -ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, cb_desc *tcb_desc) +rtllib_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - tcb_desc->bUseShortGI = false; + tcb_desc->bUseShortGI = false; - if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; - if(pHTInfo->bForcedShortGI) + if (pHTInfo->bForcedShortGI) { tcb_desc->bUseShortGI = true; return; } - if((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz) + if ((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz) tcb_desc->bUseShortGI = true; - else if((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz) + else if ((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz) tcb_desc->bUseShortGI = true; } -void ieee80211_query_BandwidthMode(struct ieee80211_device* ieee, cb_desc *tcb_desc) +void rtllib_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; tcb_desc->bPacketBW = false; - if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; - if(tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->bMulticast || tcb_desc->bBroadcast) return; - if((tcb_desc->data_rate & 0x80)==0) // If using legacy rate, it shall use 20MHz channel. + if ((tcb_desc->data_rate & 0x80)==0) return; - //BandWidthAutoSwitch is for auto switch to 20 or 40 in long distance - if(pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) + if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) tcb_desc->bPacketBW = true; return; } - -void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb) +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) +extern void rtllib_ibss_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc,u8 is_peer_shortGI_40M,u8 is_peer_shortGI_20M) { - // Common Settings - tcb_desc->bRTSSTBC = false; - tcb_desc->bRTSUseShortGI = false; // Since protection frames are always sent by legacy rate, ShortGI will never be used. - tcb_desc->bCTSEnable = false; // Most of protection using RTS/CTS - tcb_desc->RTSSC = 0; // 20MHz: Don't care; 40MHz: Duplicate. - tcb_desc->bRTSBW = false; // RTS frame bandwidth is always 20MHz + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if(tcb_desc->bBroadcast || tcb_desc->bMulticast)//only unicast frame will use rts/cts - return; + tcb_desc->bUseShortGI = false; - if (is_broadcast_ether_addr(skb->data+16)) //check addr3 as infrastructure add3 is DA. - return; - - if (ieee->mode < IEEE_N_24G) //b, g mode + if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT || (ieee->iw_mode != IW_MODE_ADHOC)) + { + return; + } + + if (pHTInfo->bForcedShortGI) + { + tcb_desc->bUseShortGI = true; + return; + } + if ((pHTInfo->bCurBW40MHz==true) && is_peer_shortGI_40M) + tcb_desc->bUseShortGI = true; + else if ((pHTInfo->bCurBW40MHz==false) && is_peer_shortGI_20M) + tcb_desc->bUseShortGI = true; +} +void rtllib_ibss_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc, u8 is_peer_40M) +{ + PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + + tcb_desc->bPacketBW = false; + + if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT || (ieee->iw_mode != IW_MODE_ADHOC)) + { + return; + } + + if (tcb_desc->bMulticast || tcb_desc->bBroadcast) + { + return; + } + + if ((tcb_desc->data_rate & 0x80)==0) + { + return; + } + if (pHTInfo->bCurBW40MHz && is_peer_40M && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) + tcb_desc->bPacketBW = true; + return; +} +#endif +void rtllib_query_protectionmode(struct rtllib_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb) +{ + tcb_desc->bRTSSTBC = false; + tcb_desc->bRTSUseShortGI = false; + tcb_desc->bCTSEnable = false; + tcb_desc->RTSSC = 0; + tcb_desc->bRTSBW = false; + + if (tcb_desc->bBroadcast || tcb_desc->bMulticast) + return; + + if (is_broadcast_ether_addr(skb->data+16)) + return; + + if (ieee->mode < IEEE_N_24G) { - // (1) RTS_Threshold is compared to the MPDU, not MSDU. - // (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. - // Other fragments are protected by previous fragment. - // So we only need to check the length of first fragment. if (skb->len > ieee->rts) { tcb_desc->bRTSEnable = true; @@ -470,78 +519,72 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_ } else if (ieee->current_network.buseprotection) { - // Use CTS-to-SELF in protection mode. tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; } - //otherwise return; return; } else - {// 11n High throughput case. + { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; while (true) { - //check ERP protection + if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) + { + tcb_desc->bCTSEnable = true; + tcb_desc->rts_rate = MGN_24M; + tcb_desc->bRTSEnable = true; + break; + } + else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE)) + { + tcb_desc->bRTSEnable = true; + tcb_desc->rts_rate = MGN_24M; + break; + } if (ieee->current_network.buseprotection) - {// CTS-to-SELF + { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - //check HT op mode - if(pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) + if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { u8 HTOpMode = pHTInfo->CurrentOpMode; - if((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || + if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || (!pHTInfo->bCurBW40MHz && HTOpMode == 3) ) { - tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps. + tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } } - //check rts if (skb->len > ieee->rts) { - tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps. + tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } - //to do list: check MIMO power save condition. - //check AMPDU aggregation for TXOP - if(tcb_desc->bAMPDUEnable) + if (tcb_desc->bAMPDUEnable) { - tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps. - // According to 8190 design, firmware sends CF-End only if RTS/CTS is enabled. However, it degrads - // throughput around 10M, so we disable of this mechanism. 2007.08.03 by Emily + tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = false; break; } - //check IOT action - if(pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) - { - tcb_desc->bCTSEnable = true; - tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; - break; - } - // Totally no protection case!! goto NO_PROTECTION; } } - // For test , CTS replace with RTS - if( 0 ) + if ( 0 ) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; + tcb_desc->bRTSEnable = true; } if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) tcb_desc->bUseShortPreamble = true; - if (ieee->mode == IW_MODE_MASTER) + if (ieee->iw_mode == IW_MODE_MASTER) goto NO_PROTECTION; return; NO_PROTECTION: @@ -553,75 +596,104 @@ NO_PROTECTION: } -void ieee80211_txrate_selectmode(struct ieee80211_device* ieee, cb_desc* tcb_desc) +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) +void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc,struct sta_info *psta) +#else +void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc) +#endif { #ifdef TO_DO_LIST - if(!IsDataFrame(pFrame)) + if (!IsDataFrame(pFrame)) { - pTcb->bTxDisableRateFallBack = TRUE; - pTcb->bTxUseDriverAssingedRate = TRUE; + pTcb->bTxDisableRateFallBack = true; + pTcb->bTxUseDriverAssingedRate = true; pTcb->RATRIndex = 7; return; } - if(pMgntInfo->ForcedDataRate!= 0) + if (pMgntInfo->ForcedDataRate!= 0) { - pTcb->bTxDisableRateFallBack = TRUE; - pTcb->bTxUseDriverAssingedRate = TRUE; + pTcb->bTxDisableRateFallBack = true; + pTcb->bTxUseDriverAssingedRate = true; return; } #endif - if(ieee->bTxDisableRateFallBack) + if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; - if(ieee->bTxUseDriverAssingedRate) + if (ieee->bTxUseDriverAssingedRate) tcb_desc->bTxUseDriverAssingedRate = true; - if(!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) + if (!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) { if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) tcb_desc->RATRIndex = 0; } } -void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u8* dst) +u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) { + u16 seqnum = 0; + if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) - return; - if (IsQoSDataFrame(skb->data)) //we deal qos data only + return 0; + if (IsQoSDataFrame(skb->data)) { PTX_TS_RECORD pTS = NULL; if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, skb->priority, TX_DIR, true)) { - return; + return 0; } + seqnum = pTS->TxCurSeq; pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; + return seqnum; + } + return 0; +} + +static int wme_downgrade_ac(struct sk_buff *skb) +{ + switch (skb->priority) { + case 6: + case 7: + skb->priority = 5; /* VO -> VI */ + return 0; + case 4: + case 5: + skb->priority = 3; /* VI -> BE */ + return 0; + case 0: + case 3: + skb->priority = 1; /* BE -> BK */ + return 0; + default: + return -1; } } -int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) +int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) { - struct ieee80211_device *ieee = netdev_priv(dev); - struct ieee80211_txb *txb = NULL; - struct ieee80211_hdr_3addrqos *frag_hdr; + struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_txb *txb = NULL; + struct rtllib_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; unsigned long flags; struct net_device_stats *stats = &ieee->stats; int ether_type = 0, encrypt; int bytes, fc, qos_ctl = 0, hdr_len; struct sk_buff *skb_frag; - struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */ + struct rtllib_hdr_3addrqos header = { /* Ensure zero initialized */ .duration_id = 0, .seq_ctl = 0, .qos_ctl = 0 }; u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; - - struct ieee80211_crypt_data* crypt; - bool bdhcp =false; - + struct rtllib_crypt_data* crypt = NULL; cb_desc *tcb_desc; + u8 bIsMulticast = false; + u8 IsAmsdu = false; + bool bdhcp =false; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother @@ -634,92 +706,101 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) } - if(likely(ieee->raw_tx == 0)){ + if (likely(ieee->raw_tx == 0)){ if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } + /* Save source and destination addresses */ + memcpy(dest, skb->data, ETH_ALEN); + memcpy(src, skb->data+ETH_ALEN, ETH_ALEN); memset(skb->cb, 0, sizeof(skb->cb)); ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - crypt = ieee->crypt[ieee->tx_keyidx]; + if (ieee->iw_mode == IW_MODE_MONITOR) + { + txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); + if (unlikely(!txb)) { + printk(KERN_WARNING "%s: Could not allocate TXB\n", + ieee->dev->name); + goto failed; + } + txb->encrypted = 0; + txb->payload_size = skb->len; + memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + + goto success; + } + + if (skb->len > 282){ + if (ETH_P_IP == ether_type) { + const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); + if (IPPROTO_UDP == ip->protocol) { + struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); + if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || + ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { + printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]); + + bdhcp = true; + ieee->LPSDelayCnt = 200; + } + } + }else if (ETH_P_ARP == ether_type){ + printk("=================>DHCP Protocol start tx ARP pkt!!\n"); + bdhcp = true; + ieee->LPSDelayCnt = ieee->current_network.tim.tim_count; + + + } + } + + skb->priority = rtllib_classify(skb, IsAmsdu); + crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - #ifdef CONFIG_IEEE80211_DEBUG + #ifdef CONFIG_RTLLIB_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); - IEEE80211_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", + RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", eap_get_type(eap->type)); } #endif - // The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time - // to prevent DHCP protocol fail - if (skb->len > 282){//MINIMUM_DHCP_PACKET_SIZE) { - if (ETH_P_IP == ether_type) {// IP header - const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); - if (IPPROTO_UDP == ip->protocol) {//FIXME windows is 11 but here UDP in linux kernel is 17. - struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); - if(((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || - ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { - // 68 : UDP BOOTP client - // 67 : UDP BOOTP server - printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]); - - bdhcp = true; -#ifdef _RTL8192_EXT_PATCH_ - ieee->LPSDelayCnt = 100;//pPSC->LPSAwakeIntvl*2; //AMY,090701 -#else - ieee->LPSDelayCnt = 100;//pPSC->LPSAwakeIntvl*2; -#endif - } - } - }else if(ETH_P_ARP == ether_type){// IP ARP packet - printk("=================>DHCP Protocol start tx ARP pkt!!\n"); - bdhcp = true; - ieee->LPSDelayCnt = ieee->current_network.tim.tim_count; - - } - } - - /* Save source and destination addresses */ - memcpy(&dest, skb->data, ETH_ALEN); - memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - - /* Advance the SKB to the start of the payload */ - skb_pull(skb, sizeof(struct ethhdr)); + /* Advance the SKB to the start of the payload */ + skb_pull(skb, sizeof(struct ethhdr)); /* Determine total amount of storage required for TXB packets */ - bytes = skb->len + SNAP_SIZE + sizeof(u16); + bytes = skb->len + SNAP_SIZE + sizeof(u16); if (encrypt) - fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_WEP; + fc = RTLLIB_FTYPE_DATA | RTLLIB_FCTL_WEP; else + fc = RTLLIB_FTYPE_DATA; - fc = IEEE80211_FTYPE_DATA; - - if(qos_actived) - fc |= IEEE80211_STYPE_QOS_DATA; + if (qos_actived) + fc |= RTLLIB_STYPE_QOS_DATA; else - fc |= IEEE80211_STYPE_DATA; + fc |= RTLLIB_STYPE_DATA; if (ieee->iw_mode == IW_MODE_INFRA) { - fc |= IEEE80211_FCTL_TODS; + fc |= RTLLIB_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */ memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(&header.addr2, &src, ETH_ALEN); - memcpy(&header.addr3, &dest, ETH_ALEN); + if (IsAmsdu) + memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + else + memcpy(&header.addr3, &dest, ETH_ALEN); } else if (ieee->iw_mode == IW_MODE_ADHOC) { /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */ @@ -728,29 +809,35 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } + bIsMulticast = is_broadcast_ether_addr(header.addr1) ||is_multicast_ether_addr(header.addr1); + header.frame_ctl = cpu_to_le16(fc); /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ - if (is_multicast_ether_addr(header.addr1) || - is_broadcast_ether_addr(header.addr1)) { + if (bIsMulticast) { frag_size = MAX_FRAG_THRESHOLD; qos_ctl |= QOS_CTL_NOTCONTAIN_ACK; - } - else { - frag_size = ieee->fts;//default:392 + } else { + frag_size = ieee->fts; qos_ctl = 0; } - if(qos_actived) - { - hdr_len = IEEE80211_3ADDR_LEN + 2; + if (qos_actived) { + hdr_len = RTLLIB_3ADDR_LEN + 2; - skb->priority = ieee80211_classify(skb, &ieee->current_network); - qos_ctl |= skb->priority; //set in the ieee80211_classify - header.qos_ctl = cpu_to_le16(qos_ctl & IEEE80211_QOS_TID); + /* in case we are a client verify acm is not set for this ac */ + while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { + printk("skb->priority = %x\n", skb->priority); + if (wme_downgrade_ac(skb)) { + break; + } + printk("converted skb->priority = %x\n", skb->priority); + } + qos_ctl |= skb->priority; + header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); } else { - hdr_len = IEEE80211_3ADDR_LEN; + hdr_len = RTLLIB_3ADDR_LEN; } /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will @@ -758,14 +845,14 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) * it when determining the amount of payload space. */ bytes_per_frag = frag_size - hdr_len; if (ieee->config & - (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) - bytes_per_frag -= IEEE80211_FCS_LEN; + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + bytes_per_frag -= RTLLIB_FCS_LEN; - /* Each fragment may need to have room for encryption pre/postfix */ - if (encrypt) + /* Each fragment may need to have room for encryptiong pre/postfix */ + if (encrypt) { bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + } /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -778,7 +865,7 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC); + txb = rtllib_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -787,24 +874,22 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) txb->encrypted = encrypt; txb->payload_size = bytes; - if(qos_actived) + if (qos_actived) { txb->queue_index = UP2AC(skb->priority); } else { - txb->queue_index = WME_AC_BK; + txb->queue_index = WME_AC_BE;; } - - for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; tcb_desc = (cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); - if(qos_actived){ - skb_frag->priority = skb->priority;//UP2AC(skb->priority); + if (qos_actived){ + skb_frag->priority = skb->priority; tcb_desc->queue_index = UP2AC(skb->priority); } else { - skb_frag->priority = WME_AC_BK; - tcb_desc->queue_index = WME_AC_BK; + skb_frag->priority = WME_AC_BE; + tcb_desc->queue_index = WME_AC_BE; } skb_reserve(skb_frag, ieee->tx_headroom); @@ -814,37 +899,33 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) else tcb_desc->bHwSec = 0; skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - } - else - { + } else { tcb_desc->bHwSec = 0; } - frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtllib_hdr_3addrqos *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( - fc | IEEE80211_FCTL_MOREFRAGS); + fc | RTLLIB_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - - if(qos_actived) + if ((qos_actived) && (!bIsMulticast)) { - // add 1 only indicate to corresponding seq number control 2006/7/12 - frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[UP2AC(skb->priority)+1]<<4 | i); + frag_hdr->seq_ctl = rtllib_query_seqnum(ieee, skb_frag, header.addr1); + frag_hdr->seq_ctl = cpu_to_le16(frag_hdr->seq_ctl<<4 | i); } else { frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); } - /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + rtllib_put_snap( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -858,33 +939,32 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + rtllib_encrypt_fragment(ieee, skb_frag, hdr_len); if (ieee->config & - (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) skb_put(skb_frag, 4); } - if(qos_actived) - { + if ((qos_actived) && (!bIsMulticast)) { if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; else ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; } else { - if (ieee->seq_ctrl[0] == 0xFFF) + if (ieee->seq_ctrl[0] == 0xFFF) ieee->seq_ctrl[0] = 0; else ieee->seq_ctrl[0]++; } }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); - if(!txb){ + txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); + if (!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; @@ -896,50 +976,132 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) } success: -//WB add to fill data tcb_desc here. only first fragment is considered, need to change, and you may remove to other place. if (txb) { +#if 1 cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; - if (is_multicast_ether_addr(header.addr1)) - tcb_desc->bMulticast = 1; - if (is_broadcast_ether_addr(header.addr1)) - tcb_desc->bBroadcast = 1; - ieee80211_txrate_selectmode(ieee, tcb_desc); - if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) - tcb_desc->data_rate = ieee->basic_rate; - else - tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + tcb_desc->priority = skb->priority; - if(bdhcp == true){ - tcb_desc->data_rate = MGN_1M; + if (ether_type == ETH_P_PAE) { + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) + { + tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + tcb_desc->bTxDisableRateFallBack = false; + }else{ + tcb_desc->data_rate = ieee->basic_rate; tcb_desc->bTxDisableRateFallBack = 1; + } + tcb_desc->RATRIndex = 7; tcb_desc->bTxUseDriverAssingedRate = 1; - tcb_desc->bdhcp = 1; + } else { + if (is_multicast_ether_addr(header.addr1)) + tcb_desc->bMulticast = 1; + if (is_broadcast_ether_addr(header.addr1)) + tcb_desc->bBroadcast = 1; +#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) + if ( tcb_desc->bMulticast || tcb_desc->bBroadcast){ + rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); + tcb_desc->data_rate = ieee->basic_rate; + } + else + { + if (ieee->iw_mode == IW_MODE_ADHOC) + { + u8 is_peer_shortGI_40M = 0; + u8 is_peer_shortGI_20M = 0; + u8 is_peer_BW_40M = 0; + p_sta = GetStaInfo(ieee, header.addr1); + if (NULL == p_sta) + { + rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); + tcb_desc->data_rate = ieee->rate; + } + else + { + rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); + tcb_desc->data_rate = CURRENT_RATE(p_sta->wireless_mode, p_sta->CurDataRate, p_sta->htinfo.HTHighestOperaRate); + is_peer_shortGI_40M = p_sta->htinfo.bCurShortGI40MHz; + is_peer_shortGI_20M = p_sta->htinfo.bCurShortGI20MHz; + is_peer_BW_40M = p_sta->htinfo.bCurTxBW40MHz; + } + rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_ibss_query_HTCapShortGI(ieee, tcb_desc,is_peer_shortGI_40M,is_peer_shortGI_20M); + rtllib_ibss_query_BandwidthMode(ieee, tcb_desc,is_peer_BW_40M); + rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); + } + else { + rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); + tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + if (bdhcp == true){ + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = MGN_1M; + tcb_desc->bTxDisableRateFallBack = false; + }else{ + tcb_desc->data_rate = MGN_1M; + tcb_desc->bTxDisableRateFallBack = 1; + } + + tcb_desc->RATRIndex = 7; + tcb_desc->bTxUseDriverAssingedRate = 1; + tcb_desc->bdhcp = 1; + } + rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_query_HTCapShortGI(ieee, tcb_desc); + rtllib_query_BandwidthMode(ieee, tcb_desc); + rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); + } + } +#else + rtllib_txrate_selectmode(ieee, tcb_desc); + if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) + tcb_desc->data_rate = ieee->basic_rate; + else + tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + + if (bdhcp == true){ + if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) + { + tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + tcb_desc->bTxDisableRateFallBack = false; + }else{ + tcb_desc->data_rate = MGN_1M; + tcb_desc->bTxDisableRateFallBack = 1; + } + + + tcb_desc->RATRIndex = 7; + tcb_desc->bTxUseDriverAssingedRate = 1; + tcb_desc->bdhcp = 1; + } + + rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_query_HTCapShortGI(ieee, tcb_desc); + rtllib_query_BandwidthMode(ieee, tcb_desc); + rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); +#endif } - - - ieee80211_qurey_ShortPreambleMode(ieee, tcb_desc); - ieee80211_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); - ieee80211_query_HTCapShortGI(ieee, tcb_desc); - ieee80211_query_BandwidthMode(ieee, tcb_desc); - ieee80211_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); - ieee80211_query_seqnum(ieee, txb->fragments[0], header.addr1); +#endif } spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + dev->stats.tx_packets++; + dev->stats.tx_bytes += txb->payload_size; + rtllib_softmac_xmit(txb, ieee); }else{ - if ((*ieee->hard_start_xmit)(txb, ieee) == 0) { + if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + rtllib_txb_free(txb); } } @@ -952,4 +1114,8 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev) return 1; } - +int rtllib_xmit(struct sk_buff *skb, struct net_device *dev) +{ + memset(skb->cb, 0, sizeof(skb->cb)); + return rtllib_xmit_inter(skb, dev); +} diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c similarity index 69% rename from drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c rename to drivers/staging/rtl8192e/rtllib_wx.c index 6530d9b6829..7f3f5b05840 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -32,16 +32,14 @@ #include #include #include -#include #include -#include "ieee80211.h" - +#include "rtllib.h" struct modes_unit { char *mode_string; int mode_size; }; -struct modes_unit ieee80211_modes[] = { +static struct modes_unit rtllib_modes[] = { {"a",1}, {"b",1}, {"g",1}, @@ -50,12 +48,10 @@ struct modes_unit ieee80211_modes[] = { {"N-5G",4}, }; -#define iwe_stream_add_event_rsl iwe_stream_add_event - #define MAX_CUSTOM_LEN 64 -static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, - char *start, char *stop, - struct ieee80211_network *network, +static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, + char *start, char *stop, + struct rtllib_network *network, struct iw_request_info *info) { char custom[MAX_CUSTOM_LEN]; @@ -77,20 +73,22 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; -// if (network->flags & NETWORK_EMPTY_ESSID) { - if (network->ssid_len == 0) { - iwe.u.data.length = sizeof(""); - start = iwe_stream_add_point(info, start, stop, &iwe, ""); - } else { + if (network->ssid_len > 0){ iwe.u.data.length = min(network->ssid_len, (u8)32); - start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); - } + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); + }else if (network->hidden_ssid_len == 0){ + iwe.u.data.length = sizeof(""); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, ""); + }else { + iwe.u.data.length = min(network->hidden_ssid_len, (u8)32); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->hidden_ssid); + } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - for(i=0; imode&(1<mode&(1<capability & - (WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) { - if (network->capability & WLAN_CAPABILITY_BSS) + (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { + if (network->capability & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN); } /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; -/* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode); +/* iwe.u.freq.m = rtllib_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN); + /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; if (network->capability & WLAN_CAPABILITY_PRIVACY) @@ -122,7 +121,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); /* Add basic and extended rates */ max_rate = 0; p = custom; @@ -147,7 +146,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, max_rate = rate; } - if (network->mode >= IEEE_N_24G)//add N rate here; + if (network->mode >= IEEE_N_24G) { PHT_CAPABILITY_ELE ht_cap = NULL; bool is40M = false, isShortGI = false; @@ -169,33 +168,33 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, iwe.cmd = SIOCGIWRATE; iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; iwe.u.bitrate.value = max_rate * 500000; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_PARAM_LEN); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); /* Add quality statistics */ /* TODO: Fix these values... */ iwe.cmd = IWEVQUAL; iwe.u.qual.qual = network->stats.signal; iwe.u.qual.level = network->stats.rssi; iwe.u.qual.noise = network->stats.noise; - iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK; - if (!(network->stats.mask & IEEE80211_STATMASK_RSSI)) + iwe.u.qual.updated = network->stats.mask & RTLLIB_STATMASK_WEMASK; + if (!(network->stats.mask & RTLLIB_STATMASK_RSSI)) iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID; - if (!(network->stats.mask & IEEE80211_STATMASK_NOISE)) + if (!(network->stats.mask & RTLLIB_STATMASK_NOISE)) iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID; - if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL)) + if (!(network->stats.mask & RTLLIB_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; iwe.u.qual.updated = 7; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN); + iwe.cmd = IWEVCUSTOM; p = custom; - iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); #if (WIRELESS_EXT < 18) if (ieee->wpa_enabled && network->wpa_ie_len){ char buf[MAX_WPA_IE_LEN * 2 + 30]; @@ -208,7 +207,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } if (ieee->wpa_enabled && network->rsn_ie_len){ @@ -223,7 +222,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } #else memset(&iwe, 0, sizeof(iwe)); @@ -233,7 +232,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, memcpy(buf, network->wpa_ie, network->wpa_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wpa_ie_len; - start = iwe_stream_add_point(info, start, stop, &iwe, buf); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } memset(&iwe, 0, sizeof(iwe)); if (network->rsn_ie_len) @@ -242,10 +241,22 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, memcpy(buf, network->rsn_ie, network->rsn_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->rsn_ie_len; - start = iwe_stream_add_point(info, start, stop, &iwe, buf); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); + } + +#ifndef CUSTOMER_ID_INTEL_CMPC + /* add info for WZC */ + memset(&iwe, 0, sizeof(iwe)); + if (network->wzc_ie_len) + { + char buf[MAX_WZC_IE_LEN]; + memcpy(buf, network->wzc_ie, network->wzc_ie_len); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = network->wzc_ie_len; + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } #endif - +#endif /* Add EXTRA: Age to display seconds since last beacon/probe response * for given network. */ @@ -255,31 +266,29 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int rtllib_wx_get_scan(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct ieee80211_network *network; + struct rtllib_network *network; unsigned long flags; char *ev = extra; -// char *stop = ev + IW_SCAN_MAX_DATA; - char *stop = ev + wrqu->data.length;//IW_SCAN_MAX_DATA; - //char *stop = ev + IW_SCAN_MAX_DATA; + char *stop = ev + wrqu->data.length; int i = 0; int err = 0; - IEEE80211_DEBUG_WX("Getting scan\n"); + RTLLIB_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; - if((stop-ev)<200) + if ((stop-ev)<200) { err = -E2BIG; break; @@ -288,12 +297,12 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, time_after(network->last_scanned + ieee->scan_age, jiffies)) ev = rtl819x_translate_scan(ieee, ev, stop, network, info); else - IEEE80211_DEBUG_SCAN( + RTLLIB_DEBUG_SCAN( "Not showing network '%s (" - "%pM)' due to age (%lums).\n", + MAC_FMT ")' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), - network->bssid, + MAC_ARG(network->bssid), (jiffies - network->last_scanned) / (HZ / 100)); } @@ -302,24 +311,24 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, wrqu->data.length = ev - extra; wrqu->data.flags = 0; - IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i); + RTLLIB_DEBUG_WX("exit: %d networks returned.\n", i); return err; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int rtllib_wx_set_encode(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { struct iw_point *erq = &(wrqu->encoding); struct net_device *dev = ieee->dev; - struct ieee80211_security sec = { + struct rtllib_security sec = { .flags = 0 }; int i, key, key_provided, len; - struct ieee80211_crypt_data **crypt; + struct rtllib_crypt_data **crypt; - IEEE80211_DEBUG_WX("SET_ENCODE\n"); + RTLLIB_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; if (key) { @@ -332,17 +341,16 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, key = ieee->tx_keyidx; } - IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? + RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? "provided" : "default"); crypt = &ieee->crypt[key]; - if (erq->flags & IW_ENCODE_DISABLED) { if (key_provided && *crypt) { - IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", + RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); } else - IEEE80211_DEBUG_WX("Disabling encryption.\n"); + RTLLIB_DEBUG_WX("Disabling encryption.\n"); /* Check all the keys to see if any are still configured, * and if no key index was provided, de-init them all */ @@ -350,8 +358,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( - ieee, &ieee->crypt[i]); + rtllib_crypt_delayed_deinit(ieee, &ieee->crypt[i]); } } @@ -373,20 +380,24 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); } if (*crypt == NULL) { - struct ieee80211_crypt_data *new_crypt; + struct rtllib_crypt_data *new_crypt; /* take WEP into use */ - new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), + new_crypt = kmalloc(sizeof(struct rtllib_crypt_data), GFP_KERNEL); if (new_crypt == NULL) return -ENOMEM; - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); - if (!new_crypt->ops) - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + memset(new_crypt, 0, sizeof(struct rtllib_crypt_data)); + new_crypt->ops = rtllib_get_crypto_ops("WEP"); + if (!new_crypt->ops) { + request_module("rtllib_crypt_wep"); + new_crypt->ops = rtllib_get_crypto_ops("WEP"); + } + if (new_crypt->ops) new_crypt->priv = new_crypt->ops->init(key); @@ -395,7 +406,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module rtllib_crypt_wep\n", dev->name); return -EOPNOTSUPP; } @@ -409,11 +420,11 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, if (len > erq->length) memset(sec.keys[key] + erq->length, 0, len - erq->length); - IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", + RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", key, escape_essid(sec.keys[key], len), erq->length, len); sec.key_sizes[key] = len; - (*crypt)->ops->set_key(sec.keys[key], len, NULL, + (*crypt)->ops->set_key(sec.keys[key], len, NULL, (*crypt)->priv); sec.flags |= (1 << key); /* This ensures a key will be activated if no key is @@ -430,7 +441,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, printk("Setting key %d to all zero.\n", key); - IEEE80211_DEBUG_WX("Setting key %d to all zero.\n", + RTLLIB_DEBUG_WX("Setting key %d to all zero.\n", key); memset(sec.keys[key], 0, 13); (*crypt)->ops->set_key(sec.keys[key], 13, NULL, @@ -441,20 +452,19 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, /* No key data - just set the default TX key index */ if (key_provided) { - IEEE80211_DEBUG_WX( + RTLLIB_DEBUG_WX( "Setting key %d to default Tx key.\n", key); ieee->tx_keyidx = key; sec.active_key = key; sec.flags |= SEC_ACTIVE_KEY; } } - done: ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; - IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? + RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? "OPEN" : "SHARED KEY"); /* For now we just support WEP, so only set that security level... @@ -463,7 +473,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */ if (ieee->set_security) - ieee->set_security(ieee, &sec); + ieee->set_security(dev, &sec); /* Do not reset port if card is in Managed mode since resetting will * generate new IEEE 802.11 authentication which may end up in looping @@ -472,24 +482,24 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, * the callbacks structures used to initialize the 802.11 stack. */ if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(ieee)) { + ieee->reset_port && ieee->reset_port(dev)) { printk(KERN_DEBUG "%s: reset_port failed\n", dev->name); return -EINVAL; } return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int rtllib_wx_get_encode(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { struct iw_point *erq = &(wrqu->encoding); int len, key; - struct ieee80211_crypt_data *crypt; + struct rtllib_crypt_data *crypt; - IEEE80211_DEBUG_WX("GET_ENCODE\n"); + RTLLIB_DEBUG_WX("GET_ENCODE\n"); - if(ieee->iw_mode == IW_MODE_MONITOR) + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; key = erq->flags & IW_ENCODE_INDEX; @@ -497,10 +507,11 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, if (key > WEP_KEYS) return -EINVAL; key--; - } else + } else { key = ieee->tx_keyidx; - + } crypt = ieee->crypt[key]; + erq->flags = key + 1; if (crypt == NULL || crypt->ops == NULL) { @@ -508,15 +519,6 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, erq->flags |= IW_ENCODE_DISABLED; return 0; } -#if 0 - if (strcmp(crypt->ops->name, "WEP") != 0) { - /* only WEP is supported with wireless extensions, so just - * report that encryption is used */ - erq->length = 0; - erq->flags |= IW_ENCODE_ENABLED; - return 0; - } -#endif len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv); erq->length = (len >= 0 ? len : 0); @@ -530,7 +532,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, return 0; } #if (WIRELESS_EXT >= 18) -int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, +int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -540,11 +542,11 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; int i, idx; int group_key = 0; - const char *alg; - struct ieee80211_crypto_ops *ops; - struct ieee80211_crypt_data **crypt; + const char *alg, *module; + struct rtllib_crypto_ops *ops; + struct rtllib_crypt_data **crypt; - struct ieee80211_security sec = { + struct rtllib_security sec = { .flags = 0, }; idx = encoding->flags & IW_ENCODE_INDEX; @@ -552,78 +554,73 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, if (idx < 1 || idx > WEP_KEYS) return -EINVAL; idx--; - } else - idx = ieee->tx_keyidx; - - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { - - crypt = &ieee->crypt[idx]; - - group_key = 1; - } else { - /* some Cisco APs use idx>0 for unicast in dynamic WEP */ - if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) + } else{ + idx = ieee->tx_keyidx; + } + if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { + crypt = &ieee->crypt[idx]; + group_key = 1; + } else { + /* some Cisco APs use idx>0 for unicast in dynamic WEP */ + if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) return -EINVAL; - if (ieee->iw_mode == IW_MODE_INFRA) + if (ieee->iw_mode == IW_MODE_INFRA) + crypt = &ieee->crypt[idx]; + else + return -EINVAL; + } - crypt = &ieee->crypt[idx]; - - else - return -EINVAL; - } - - sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT; - if ((encoding->flags & IW_ENCODE_DISABLED) || + sec.flags |= SEC_ENABLED; + if ((encoding->flags & IW_ENCODE_DISABLED) || ext->alg == IW_ENCODE_ALG_NONE) { - if (*crypt) - ieee80211_crypt_delayed_deinit(ieee, crypt); - - for (i = 0; i < WEP_KEYS; i++) + if (*crypt) + rtllib_crypt_delayed_deinit(ieee, crypt); + for (i = 0; i < WEP_KEYS; i++) { if (ieee->crypt[i] != NULL) - - break; - - if (i == WEP_KEYS) { - sec.enabled = 0; - // sec.encrypt = 0; - sec.level = SEC_LEVEL_0; - sec.flags |= SEC_LEVEL; - } - goto done; - } + break; + } + if (i == WEP_KEYS) { + sec.enabled = 0; + sec.level = SEC_LEVEL_0; + sec.flags |= SEC_LEVEL; + } + goto done; + } sec.enabled = 1; - // sec.encrypt = 1; -#if 0 - if (group_key ? !ieee->host_mc_decrypt : - !(ieee->host_encrypt || ieee->host_decrypt || - ieee->host_encrypt_msdu)) - goto skip_host_crypt; -#endif switch (ext->alg) { case IW_ENCODE_ALG_WEP: alg = "WEP"; + module = "rtllib_crypt_wep"; break; case IW_ENCODE_ALG_TKIP: alg = "TKIP"; + module = "rtllib_crypt_tkip"; break; case IW_ENCODE_ALG_CCMP: alg = "CCMP"; + module = "rtllib_crypt_ccmp"; break; default: - IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", dev->name, ext->alg); ret = -EINVAL; goto done; } printk("alg name:%s\n",alg); - ops = ieee80211_get_crypto_ops(alg); - if (ops == NULL) - ops = ieee80211_get_crypto_ops(alg); + ops = rtllib_get_crypto_ops(alg); if (ops == NULL) { - IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", + char tempbuf[100]; + + memset( tempbuf, 0x00, 100 ); + sprintf( tempbuf, "%s", module); + request_module("%s",tempbuf); + ops = rtllib_get_crypto_ops(alg); + } + if (ops == NULL) { + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", dev->name, ext->alg); printk("========>unknown crypto alg %d\n", ext->alg); ret = -EINVAL; @@ -631,23 +628,19 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, } if (*crypt == NULL || (*crypt)->ops != ops) { - struct ieee80211_crypt_data *new_crypt; + struct rtllib_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); -#else - new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL); - memset(new_crypt,0,sizeof(*new_crypt)); -#endif if (new_crypt == NULL) { ret = -ENOMEM; goto done; } new_crypt->ops = ops; - if (new_crypt->ops) + if (new_crypt->ops) new_crypt->priv = new_crypt->ops->init(idx); + if (new_crypt->priv == NULL) { kfree(new_crypt); ret = -EINVAL; @@ -655,37 +648,31 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, } *crypt = new_crypt; - } + } if (ext->key_len > 0 && (*crypt)->ops->set_key && (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, (*crypt)->priv) < 0) { - IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); + RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); printk("key setting failed\n"); ret = -EINVAL; goto done; } -#if 1 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { ieee->tx_keyidx = idx; sec.active_key = idx; sec.flags |= SEC_ACTIVE_KEY; } - if (ext->alg != IW_ENCODE_ALG_NONE) { - //memcpy(sec.keys[idx], ext->key, ext->key_len); sec.key_sizes[idx] = ext->key_len; sec.flags |= (1 << idx); if (ext->alg == IW_ENCODE_ALG_WEP) { - // sec.encode_alg[idx] = SEC_ALG_WEP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - // sec.encode_alg[idx] = SEC_ALG_TKIP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_2; } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - // sec.encode_alg[idx] = SEC_ALG_CCMP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_3; } @@ -693,27 +680,26 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, if (group_key) sec.flags &= ~SEC_LEVEL; } -#endif done: if (ieee->set_security) - ieee->set_security(ieee, &sec); + ieee->set_security(ieee->dev, &sec); if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(ieee)) { - IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name); + ieee->reset_port && ieee->reset_port(dev)) { + RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); return -EINVAL; } return ret; } -int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, +int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_point *encoding = &wrqu->encoding; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - struct ieee80211_crypt_data *crypt; + struct rtllib_crypt_data *crypt; int idx, max_key_len; max_key_len = encoding->length - sizeof(*ext); @@ -725,15 +711,16 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, if (idx < 1 || idx > WEP_KEYS) return -EINVAL; idx--; - } else + } else { idx = ieee->tx_keyidx; - + } if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && - ext->alg != IW_ENCODE_ALG_WEP) - if (idx != 0 || ieee->iw_mode != IW_MODE_INFRA) + (ext->alg != IW_ENCODE_ALG_WEP)) + if (idx != 0 || (ieee->iw_mode != IW_MODE_INFRA)) return -EINVAL; crypt = ieee->crypt[idx]; + encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); @@ -762,37 +749,67 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, return 0; } -int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, +int rtllib_wx_set_mlme(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { + u8 i = 0; + bool deauth = false; struct iw_mlme *mlme = (struct iw_mlme *) extra; + + if (ieee->state != RTLLIB_LINKED) + return -ENOLINK; + + down(&ieee->wx_sem); + switch (mlme->cmd) { - case IW_MLME_DEAUTH: - case IW_MLME_DISASSOC: - ieee80211_disassociate(ieee); + case IW_MLME_DEAUTH: + deauth = true; + /* leave break out intentionly */ + + case IW_MLME_DISASSOC: + if (deauth == true) + printk("disauth packet !\n"); + else + printk("dis associate packet!\n"); + + ieee->cannot_notify = true; + + SendDisassociation(ieee,deauth,mlme->reason_code); + rtllib_disassociate(ieee); + + ieee->wap_set = 0; + for (i = 0; i < 6; i++) + ieee->current_network.bssid[i]= 0x55; + + ieee->ssid_set = 0; + ieee->current_network.ssid[0] = '\0'; + ieee->current_network.ssid_len = 0; break; - default: - return -EOPNOTSUPP; - } + default: + up(&ieee->wx_sem); + return -EOPNOTSUPP; + } + + up(&ieee->wx_sem); + return 0; } -int ieee80211_wx_set_auth(struct ieee80211_device *ieee, +int rtllib_wx_set_auth(struct rtllib_device *ieee, struct iw_request_info *info, struct iw_param *data, char *extra) { switch (data->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: - /*need to support wpa2 here*/ break; case IW_AUTH_CIPHER_PAIRWISE: case IW_AUTH_CIPHER_GROUP: case IW_AUTH_KEY_MGMT: - /* - * * Host AP driver does not use these parameters and allows - * * wpa_supplicant to control them internally. - * */ + /* + * Host AP driver does not use these parameters and allows + * wpa_supplicant to control them internally. + */ break; case IW_AUTH_TKIP_COUNTERMEASURES: ieee->tkip_countermeasures = data->value; @@ -802,15 +819,15 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, break; case IW_AUTH_80211_AUTH_ALG: - if(data->value & IW_AUTH_ALG_SHARED_KEY){ + if (data->value & IW_AUTH_ALG_SHARED_KEY){ ieee->open_wep = 0; ieee->auth_mode = 1; } - else if(data->value & IW_AUTH_ALG_OPEN_SYSTEM){ + else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM){ ieee->open_wep = 1; ieee->auth_mode = 0; } - else if(data->value & IW_AUTH_ALG_LEAP){ + else if (data->value & IW_AUTH_ALG_LEAP){ ieee->open_wep = 1; ieee->auth_mode = 2; } @@ -818,12 +835,10 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, return -EINVAL; break; -#if 1 case IW_AUTH_WPA_ENABLED: ieee->wpa_enabled = (data->value)?1:0; break; -#endif case IW_AUTH_RX_UNENCRYPTED_EAPOL: ieee->ieee802_1x = data->value; break; @@ -836,37 +851,51 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, return 0; } #endif -#if 1 -int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) -{ - u8 *buf; - if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) - { - return -EINVAL; +int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) +{ +#if (WIRELESS_EXT >= 18 ) + u8 *buf; + u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; + + if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { + return -EINVAL; } + if (len) { + eid = ie[0]; + if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) { - if (len) - { - if (len != ie[1]+2) - { - printk("len:%zu, ie:%d\n", len, ie[1]); + ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len):(MAX_WZC_IE_LEN); + buf = kmalloc(ieee->wps_ie_len, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + memcpy(buf, ie, ieee->wps_ie_len); + ieee->wps_ie = buf; + return 0; + } + } + ieee->wps_ie_len = 0; + if (ieee->wps_ie) + kfree(ieee->wps_ie); + ieee->wps_ie = NULL; + if (len) { + if (len != ie[1]+2) { return -EINVAL; } - buf = kmemdup(ie, len, GFP_KERNEL); + buf = kmalloc(len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; + memcpy(buf, ie, len); kfree(ieee->wpa_ie); ieee->wpa_ie = buf; ieee->wpa_ie_len = len; - } - else{ + } else { + if (ieee->wpa_ie) kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; } - return 0; - -} #endif + return 0; +} From 1ec3e2f255c597c4bff693d0b045a49b12c5bb90 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:20 +0900 Subject: [PATCH 0275/1519] rtl8192e: reject rtl8192se cards with same PCI ID Signed-off-by: Larry Finger Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/rtl_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 81cb13fce6f..9551c5ed784 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3558,6 +3558,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, #endif int err = 0; bool bdma64 = false; + u8 revision_id; RT_TRACE(COMP_INIT,"Configuring chip resources"); @@ -3681,6 +3682,11 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, pci_write_config_byte(pdev,0x04,0x07); #endif + pci_read_config_byte(pdev, 0x08, &revision_id); + /* If the revisionid is 0x10, the device uses rtl8192se. */ + if (pdev->device == 0x8192 && revision_id == 0x10) + goto fail1; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) priv->ops = ops; #else From cb76215448947ddcc133c4b1c2ff2d4a77e851e0 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:20 +0900 Subject: [PATCH 0276/1519] rtl8192e: Remove extra ifdefs Signed-off-by: Larry Finger Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/internal.h | 21 - drivers/staging/rtl8192e/r8192E_cmdpkt.c | 30 +- drivers/staging/rtl8192e/r8192E_firmware.c | 15 - drivers/staging/rtl8192e/r8192E_phy.c | 78 +--- drivers/staging/rtl8192e/rtl819x_HTProc.c | 27 +- drivers/staging/rtl8192e/rtl819x_Qos.h | 8 - drivers/staging/rtl8192e/rtl819x_TSProc.c | 8 +- drivers/staging/rtl8192e/rtl_cam.c | 2 - drivers/staging/rtl8192e/rtl_core.c | 129 +----- drivers/staging/rtl8192e/rtl_core.h | 36 +- drivers/staging/rtl8192e/rtl_debug.c | 13 - drivers/staging/rtl8192e/rtl_debug.h | 6 - drivers/staging/rtl8192e/rtl_dm.c | 394 +------------------ drivers/staging/rtl8192e/rtl_ethtool.c | 6 - drivers/staging/rtl8192e/rtl_pci.c | 352 ----------------- drivers/staging/rtl8192e/rtl_pm.c | 16 - drivers/staging/rtl8192e/rtl_pm.h | 4 - drivers/staging/rtl8192e/rtl_ps.c | 63 --- drivers/staging/rtl8192e/rtllib.h | 167 +------- drivers/staging/rtl8192e/rtllib_crypt.h | 8 - drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 49 +-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 189 +-------- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 91 +---- drivers/staging/rtl8192e/rtllib_rx.c | 141 +------ drivers/staging/rtl8192e/rtllib_softmac.c | 49 +-- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 - 26 files changed, 39 insertions(+), 1872 deletions(-) diff --git a/drivers/staging/rtl8192e/internal.h b/drivers/staging/rtl8192e/internal.h index 1c39c000e91..3041f0fa5cb 100644 --- a/drivers/staging/rtl8192e/internal.h +++ b/drivers/staging/rtl8192e/internal.h @@ -19,12 +19,8 @@ #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) -#include -#else #include #include -#endif #include #ifdef BUILT_IN_CRYPTO @@ -37,23 +33,6 @@ #endif #endif /* BUILT_IN_CRYPTO */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)) -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - prefetch(pos->member.next); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member), \ - prefetch(pos->member.next)) - -static inline void cond_resched(void) -{ - if (need_resched()) { - set_current_state(TASK_RUNNING); - schedule(); - } -} -#endif - extern enum km_type crypto_km_types[]; static inline enum km_type crypto_kmap_type(int out) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 11506db1f78..ea9fa579832 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -114,56 +114,36 @@ cmpk_count_txstatistic( pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif -#ifdef TODO - if (pAdapter->bInHctTest) - return; -#endif - if (pstx_fb->tok) - { + if (pstx_fb->tok) { priv->stats.txfeedbackok++; priv->stats.txoktotal++; priv->stats.txokbytestotal += pstx_fb->pkt_length; priv->stats.txokinperiod++; - if (pstx_fb->pkt_type == PACKET_MULTICAST) - { + if (pstx_fb->pkt_type == PACKET_MULTICAST) { priv->stats.txmulticast++; priv->stats.txbytesmulticast += pstx_fb->pkt_length; - } - else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { + } else if (pstx_fb->pkt_type == PACKET_BROADCAST) { priv->stats.txbroadcast++; priv->stats.txbytesbroadcast += pstx_fb->pkt_length; - } - else - { + } else { priv->stats.txunicast++; priv->stats.txbytesunicast += pstx_fb->pkt_length; } - } - else - { + } else { priv->stats.txfeedbackfail++; priv->stats.txerrtotal++; priv->stats.txerrbytestotal += pstx_fb->pkt_length; if (pstx_fb->pkt_type == PACKET_MULTICAST) - { priv->stats.txerrmulticast++; - } else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { priv->stats.txerrbroadcast++; - } else - { priv->stats.txerrunicast++; - } } priv->stats.txretrycount += pstx_fb->retry_cnt; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 6d490292c03..8c77d133ad0 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -17,19 +17,11 @@ * wlanfae ******************************************************************************/ -#if (defined(RTL8192E) || defined(RTL8190P)) - #include "rtl_core.h" #include "r8192E_hw.h" -#ifdef RTL8190P -#include "r8190P_hwimg.h" -#elif defined RTL8192E #include "r8192E_hwimg.h" -#endif #include "r8192E_firmware.h" -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) #include -#endif extern void firmware_init_param(struct net_device *dev) { @@ -308,17 +300,12 @@ bool init_firmware(struct net_device *dev) RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n"); } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE) priv->firmware_source = FW_SOURCE_IMG_FILE; -#else - priv->firmware_source = FW_SOURCE_HEADER_FILE; -#endif for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { if (rst_opt == OPT_SYSTEM_RESET) { switch (priv->firmware_source) { case FW_SOURCE_IMG_FILE: { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE) if (pfirmware->firmware_buf_size[init_step] == 0) { const char *fw_name[3] = { "RTL8192E/boot.img", "RTL8192E/main.img", @@ -352,7 +339,6 @@ bool init_firmware(struct net_device *dev) } mapped_file = pfirmware->firmware_buf[init_step]; file_length = pfirmware->firmware_buf_size[init_step]; -#endif break; } case FW_SOURCE_HEADER_FILE: @@ -393,4 +379,3 @@ download_firmware_fail: return rt_status; } -#endif diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index a20451b6ee6..78395a1a998 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -815,83 +815,7 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); } } -#ifdef TODO - if ( pMgntInfo->OpMode == RT_OP_MODE_INFRASTRUCTURE && - pMgntInfo->bWithCcxCellPwr && - channel == pMgntInfo->dot11CurrentChannelNumber) - { - u8 CckCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_B, pMgntInfo->CcxCellPwr); - u8 LegacyOfdmCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_G, pMgntInfo->CcxCellPwr); - u8 OfdmCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, pMgntInfo->CcxCellPwr); - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("CCX Cell Limit: %d dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - pMgntInfo->CcxCellPwr, CckCellPwrIdx, LegacyOfdmCellPwrIdx, OfdmCellPwrIdx)); - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - channel, powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - - if (powerlevel > CckCellPwrIdx) - powerlevel = CckCellPwrIdx; - if (powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff > OfdmCellPwrIdx) - { - if ((OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff) > 0) - { - powerlevelOFDM24G = OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff; - } - else - { - LegacyOfdmCellPwrIdx = 0; - } - } - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n", - powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - } - - pHalData->CurrentCckTxPwrIdx = powerlevel; - pHalData->CurrentOfdm24GTxPwrIdx = powerlevelOFDM24G; - - RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_GET_CHANNEL, &channel, &pChannelInfo); - - if (pChannelInfo) - { - if (pChannelInfo->MaxTxPwrDbm != UNSPECIFIED_PWR_DBM) - { - u1Byte CckMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, pChannelInfo->MaxTxPwrDbm); - u1Byte LegacyOfdmMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_G, pChannelInfo->MaxTxPwrDbm); - u1Byte OfdmMaxPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, pChannelInfo->MaxTxPwrDbm); - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("CCX Cell Limit: %ld dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - pChannelInfo->MaxTxPwrDbm, CckMaxPwrIdx, LegacyOfdmMaxPwrIdx, OfdmMaxPwrIdx)); - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - channel, powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - - if (powerlevel > CckMaxPwrIdx) - powerlevel = CckMaxPwrIdx; - if (powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff > OfdmMaxPwrIdx) - { - if ((OfdmMaxPwrIdx - pHalData->LegacyHTTxPowerDiff) > 0) - { - powerlevelOFDM24G = OfdmMaxPwrIdx - pHalData->LegacyHTTxPowerDiff; - } - else - { - LegacyOfdmMaxPwrIdx = 0; - } - } - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n", - powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - } - } -#endif - switch (priv->rf_chip) - { + switch (priv->rf_chip) { case RF_8225: break; case RF_8256: diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index eaf73676f95..1aa7d80e8de 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -958,14 +958,6 @@ void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* *len = 6 + 2; return; - -#ifdef TODO - posRT2RTAgg->Length = 6; -#endif - - - - } u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) @@ -1410,8 +1402,7 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if (pHTInfo->bEnableHT) - { + if (pHTInfo->bEnableHT) { pHTInfo->bCurrentHTSupport = true; pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; @@ -1434,27 +1425,15 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); -#ifdef TODO - Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet); -#endif ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; -#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) - if (ieee->SetHwRegHandler != NULL) { - ieee->SetHwRegHandler( ieee->dev, HW_VAR_SHORTGI_DENSITY, (u8*)(&ieee->MaxMssDensity)); - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); - } -#endif - - } - else - { + } else { pHTInfo->bCurrentHTSupport = false; } return; } + u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) { if (ieee->pHTInfo->bCurrentHTSupport) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 4c89a769915..8f5e0fdd2f3 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -54,14 +54,6 @@ #define BIT30 0x40000000 #define BIT31 0x80000000 -#ifndef RTK_DMP_PLATFORM -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) -#ifndef bool -typedef enum{false = 0, true} bool; -#endif -#endif -#endif - typedef union _QOS_TSINFO{ u8 charData[3]; struct { diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 0900bfa5fad..4159cb85a8b 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -20,13 +20,7 @@ #include #include "rtl819x_TS.h" extern void _setup_timer( struct timer_list*, void*, unsigned long); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) -#endif + void TsSetupTimeOut(unsigned long data) { } diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index c2d51bc5a87..31f198c8252 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -170,9 +170,7 @@ void setKey(struct net_device *dev, if (KeyContent != NULL) { write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); write_nic_dword(dev, RWCAM, TargetCommand); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) udelay(100); -#endif } } } diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 9551c5ed784..18030d6d9f0 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -570,11 +570,7 @@ void rtl8192_tx_timeout(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) schedule_work(&priv->reset_wq); -#else - schedule_task(&priv->reset_wq); -#endif printk("TXTIMEOUT"); } @@ -700,13 +696,8 @@ static struct rtllib_qos_parameters def_qos_parameters = { void rtl8192_update_beacon(void *data) { -#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20) struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); struct net_device *dev = priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif struct rtllib_device* ieee = priv->rtllib; struct rtllib_network* net = &ieee->current_network; @@ -718,20 +709,12 @@ void rtl8192_update_beacon(void *data) } #define MOVE_INTO_HANDLER -#ifdef RTL8192CE -int WDCAPARA_ADD[] = {REG_EDCA_BE_PARAM,REG_EDCA_BK_PARAM,REG_EDCA_VI_PARAM,REG_EDCA_VO_PARAM}; -#else int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; -#endif + void rtl8192_qos_activate(void *data) { -#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20) struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); struct net_device *dev = priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif #ifndef MOVE_INTO_HANDLER struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; u8 mode = priv->rtllib->current_network.mode; @@ -743,11 +726,7 @@ void rtl8192_qos_activate(void *data) if (priv == NULL) return; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) - down(&priv->mutex); -#else mutex_lock(&priv->mutex); -#endif if (priv->rtllib->state != RTLLIB_LINKED) goto success; RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); @@ -767,11 +746,7 @@ void rtl8192_qos_activate(void *data) } success: -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) - up(&priv->mutex); -#else mutex_unlock(&priv->mutex); -#endif } static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, @@ -1199,11 +1174,7 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) del_timer_sync(&priv->watch_dog_timer); rtl8192_cancel_deferred_work(priv); -#ifndef RTL8190P -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) cancel_delayed_work(&priv->rtllib->hw_wakeup_wq); -#endif -#endif rtllib_softmac_stop_protocol(priv->rtllib, 0, true); spin_lock_irqsave(&priv->rf_ps_lock,flags); @@ -1481,11 +1452,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv* priv) #endif sema_init(&priv->wx_sem,1); sema_init(&priv->rf_sem,1); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) - sema_init(&priv->mutex, 1); -#else mutex_init(&priv->mutex); -#endif } static void rtl8192_init_priv_task(struct net_device* dev) @@ -2032,13 +1999,8 @@ void rtl819x_update_rxcounts(struct r8192_priv *priv, void rtl819x_watchdog_wqcallback(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,watch_dog_wq); struct net_device *dev = priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif struct rtllib_device* ieee = priv->rtllib; RESET_TYPE ResetType = RESET_TYPE_NORESET; static u8 check_reset_cnt = 0; @@ -3005,33 +2967,11 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) *****************************************************************************/ void rtl8192_cancel_deferred_work(struct r8192_priv* priv) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) cancel_delayed_work(&priv->watch_dog_wq); cancel_delayed_work(&priv->update_beacon_wq); -#ifndef RTL8190P cancel_delayed_work(&priv->rtllib->hw_sleep_wq); -#endif -#if defined RTL8192SE - cancel_delayed_work(&priv->check_hw_scan_wq); - cancel_delayed_work(&priv->hw_scan_simu_wq); - cancel_delayed_work(&priv->start_hw_scan_wq); - cancel_delayed_work(&priv->rtllib->update_assoc_sta_info_wq); - cancel_delayed_work(&priv->rtllib->check_tsf_wq); -#endif -#endif - -#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,22) cancel_work_sync(&priv->reset_wq); cancel_work_sync(&priv->qos_activate); -#elif ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))) - cancel_delayed_work(&priv->reset_wq); - cancel_delayed_work(&priv->qos_activate); -#if defined RTL8192SE - cancel_delayed_work(&priv->rtllib->update_assoc_sta_info_wq); - cancel_delayed_work(&priv->rtllib->check_tsf_wq); -#endif -#endif - } int _rtl8192_up(struct net_device *dev,bool is_silent_reset) @@ -3123,13 +3063,8 @@ void rtl8192_commit(struct net_device *dev) void rtl8192_restart(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, reset_wq); struct net_device *dev = priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif down(&priv->wx_sem); @@ -3165,11 +3100,7 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac) memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) schedule_work(&priv->reset_wq); -#else - schedule_task(&priv->reset_wq); -#endif up(&priv->wx_sem); return 0; @@ -3515,11 +3446,7 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) done: -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - return; -#else return IRQ_HANDLED; -#endif } @@ -3547,9 +3474,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, unsigned long ioaddr = 0; struct net_device *dev = NULL; struct r8192_priv *priv= NULL; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); -#endif #ifdef CONFIG_RTL8192_IO_MAP unsigned long pio_start, pio_len, pio_flags; @@ -3569,10 +3494,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, pci_set_master(pdev); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL < (n)) -1)) -#endif - #ifdef CONFIG_64BIT_DMA if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { printk("RTL819xCE: Using 64bit DMA\n"); @@ -3586,13 +3507,11 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, #endif { if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { printk( "Unable to obtain 32bit DMA for consistent allocations\n"); pci_disable_device(pdev); return -ENOMEM; } -#endif } } dev = alloc_rtllib(sizeof(struct r8192_priv)); @@ -3603,26 +3522,16 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->features |= NETIF_F_HIGHDMA; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - SET_MODULE_OWNER(dev); -#endif - pci_set_drvdata(pdev, dev); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) SET_NETDEV_DEV(dev, &pdev->dev); -#endif priv = rtllib_priv(dev); priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev); priv->pdev=pdev; priv->rtllib->pdev=pdev; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) - if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ + if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)) priv->rtllib->bSupportRemoteWakeUp = 1; - } else -#endif - { + else priv->rtllib->bSupportRemoteWakeUp = 0; - } #ifdef CONFIG_RTL8192_IO_MAP pio_start = (unsigned long)pci_resource_start (pdev, 0); @@ -3687,15 +3596,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, if (pdev->device == 0x8192 && revision_id == 0x10) goto fail1; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) priv->ops = ops; -#else -#if defined RTL8190P || defined RTL8192E - priv->ops = &rtl819xp_ops; -#else - priv->ops = &rtl8192se_ops; -#endif -#endif if (rtl8192_pci_findadapter(pdev, dev) == false) goto fail1; @@ -3721,9 +3622,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, #endif dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; #endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) dev->ethtool_ops = &rtl819x_ethtool_ops; -#endif dev->type = ARPHRD_ETHER; dev->watchdog_timeo = HZ*3; @@ -3825,9 +3724,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) #ifdef ENABLE_GPIO_RADIO_CTL del_timer_sync(&priv->gpio_polling_timer); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) cancel_delayed_work(&priv->gpio_change_rf_wq); -#endif priv->polling_timer_on = 0; #endif rtl_debug_module_remove(priv); @@ -3837,14 +3734,11 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) #ifdef CONFIG_ASPM_OR_D3 ; #endif - if (priv->pFirmware) - { + if (priv->pFirmware) { vfree(priv->pFirmware); priv->pFirmware = NULL; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) destroy_workqueue(priv->priv_wq); -#endif { u32 i; rtl8192_free_rx_ring(dev); @@ -4012,12 +3906,7 @@ static int __init rtl8192_pci_module_init(void) } rtl8192_proc_module_init(); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) - if (0!=pci_module_init(&rtl8192_pci_driver)) -#else - if (0!=pci_register_driver(&rtl8192_pci_driver)) -#endif - { + if (0!=pci_register_driver(&rtl8192_pci_driver)) { DMESG("No device found"); /*pci_unregister_driver (&rtl8192_pci_driver);*/ return -ENODEV; @@ -4070,20 +3959,12 @@ module_exit(rtl8192_pci_module_exit); MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) MODULE_VERSION(DRV_VERSION); -#endif MODULE_LICENSE("GPL"); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) module_param(ifname, charp, S_IRUGO|S_IWUSR ); module_param(hwwep,int, S_IRUGO|S_IWUSR); module_param(channels,int, S_IRUGO|S_IWUSR); -#else -MODULE_PARM(ifname, "s"); -MODULE_PARM(hwwep,"i"); -MODULE_PARM(channels,"i"); -#endif MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); MODULE_PARM_DESC(hwwep," Try to use hardware WEP support(default use hw. set 0 to use software security)"); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d858cc9eacb..1e56ceb874e 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -46,9 +46,6 @@ #include #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) -#include -#endif #include "rtllib.h" #ifdef ENABLE_DOT11D @@ -95,31 +92,8 @@ .driver_data = (kernel_ulong_t)&(cfg) typedef irqreturn_t irqreturn_type; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -#if !defined(PCI_CAP_ID_EXP) -#define PCI_CAP_ID_EXP 0x10 -#endif -#if !defined(PCI_EXP_LNKCTL) -#define PCI_EXP_LNKCTL 0x10 -#endif - -typedef int __bitwise pci_power_t; -#define PCI_D0 ((pci_power_t __force) 0) -#define PCI_D1 ((pci_power_t __force) 1) -#define PCI_D2 ((pci_power_t __force) 2) -#define PCI_D3hot ((pci_power_t __force) 3) -#define PCI_D3cold ((pci_power_t __force) 4) -#define PCI_UNKNOWN ((pci_power_t __force) 5) -#define PCI_POWER_ERROR ((pci_power_t __force) -1) - -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) - #define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y,z) -#else - #define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) -#endif +#define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) #define RTL_MAX_SCAN_SIZE 128 @@ -592,10 +566,6 @@ typedef struct r8192_priv struct pci_dev *pdev; struct pci_dev *bridge_pdev; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) - u32 pci_state; -#endif - bool bfirst_init; bool bfirst_after_down; bool initialized_at_probe; @@ -684,11 +654,7 @@ typedef struct r8192_priv struct semaphore wx_sem; struct semaphore rf_sem; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) - struct semaphore mutex; -#else struct mutex mutex; -#endif struct Stats stats; struct iw_statistics wstats; diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 68839944083..cec8998abfa 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -243,12 +243,7 @@ int rtl_debug_module_init(struct r8192_priv *priv, const char *name) if (!rtl_debugfs_root) return -ENOENT; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) debug = kzalloc(sizeof(rtl_fs_debug), GFP_KERNEL); -#else - rtl_fs_debug = kmalloc(sizeof(*rtl_fs_debug), GFP_KERNEL); - memset(rtl_fs_debug,0,sizeof(*rtl_fs_debug)); -#endif if (!debug) { ret = -ENOMEM; goto err; @@ -1086,21 +1081,13 @@ static int proc_get_stats_rx(char *page, char **start, void rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, proc_net); -#else rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); -#endif } void rtl8192_proc_module_remove(void) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - remove_proc_entry(DRV_NAME, proc_net); -#else remove_proc_entry(DRV_NAME, init_net.proc_net); -#endif } diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 5ae7c7d07de..8d85979d313 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -27,9 +27,7 @@ #include #include #include -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)) #include -#endif struct r8192_priv; struct _tx_desc_8192se; @@ -272,11 +270,7 @@ typedef struct _rtl_fs_debug struct dentry *debug_register; u32 hw_type; u32 hw_offset; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)) bool hw_holding; -#else - u8 hw_holding; -#endif } rtl_fs_debug; void print_buffer(u32 *buffer, int len); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 5ea11c520c0..e864acb2c0b 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -25,41 +25,6 @@ #include "r8192E_cmdpkt.h" /*---------------------------Define Local Constant---------------------------*/ -#ifdef RTL8190P -static u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4322 - }; - -static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4322 -}; - -static u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0xa44f, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0x5e4322, - 0x5e4322, - 0x5e4322 -}; - -#elif defined RTL8192E static u32 edca_setting_DL[HT_IOT_PEER_MAX] = { 0x5e4322, 0x5e4322, @@ -93,48 +58,6 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = 0x5e4332 }; -#elif defined(RTL8192SE) -static u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0xa44f, - 0x5ea44f, - 0x5ea44f, - 0xa630, - 0xa44f, - 0xa630, - 0xa630, - 0xa42b, - 0x5e4322, - 0x5e4322 - }; - -static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = - -{ 0x4322, - 0xa44f, - 0x5ea44f, - 0xa42b, - 0x5e4322, - 0x4322, - 0xa430, - 0x5ea44f, - 0x5e4322, - 0x5e4322 -}; - -static u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0xa44f, - 0x5ea44f, - 0x5ea322, - 0x5ea422, - 0x5ea322, - 0x3ea44f, - 0x5ea44f, - 0x5e4322, - 0x5e4322 - }; -#endif - #define RTK_UL_EDCA 0xa44f #define RTK_DL_EDCA 0x5e4322 /*---------------------------Define Local Constant---------------------------*/ @@ -1255,24 +1178,13 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) void dm_txpower_trackingcallback(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif -#ifdef RTL8190P - dm_TXPowerTrackingCallback_TSSI(dev); -#elif defined(RTL8192E) if (priv->IC_Cut >= IC_VersionCut_D) dm_TXPowerTrackingCallback_TSSI(dev); else dm_TXPowerTrackingCallback_ThermalMeter(dev); -#elif defined(RTL8192SE) - dm_TXPowerTrackingCallback_ThermalMeter(dev); -#endif } #ifndef RTL8192SE @@ -1776,16 +1688,10 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) } #endif -#ifndef RTL8190P static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8192SE - priv->btxpower_tracking = false; - priv->txpower_count = 0; - priv->btxpower_trackingInit = false; -#else if (priv->rtllib->FwRWRF) priv->btxpower_tracking = true; @@ -1793,16 +1699,12 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) priv->btxpower_tracking = false; priv->txpower_count = 0; priv->btxpower_trackingInit = false; -#endif RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", priv->btxpower_tracking); } -#endif void dm_initialize_txpower_tracking(struct net_device *dev) { -#ifdef RTL8192E struct r8192_priv *priv = rtllib_priv(dev); -#endif #ifdef RTL8190P dm_InitializeTXPowerTracking_TSSI(dev); #elif defined RTL8192E @@ -3365,13 +3267,8 @@ static void dm_check_pbc_gpio(struct net_device *dev) extern void dm_CheckRfCtrlGPIO(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,gpio_change_rf_wq); struct net_device *dev = priv->rtllib->dev; -#else - struct r8192_priv *priv = rtllib_priv((struct net_device *)data); - struct net_device *dev = priv->rtllib->dev; -#endif u8 tmp1byte; RT_RF_POWER_STATE eRfPowerStateToSet; bool bActuallySet = false; @@ -3652,13 +3549,8 @@ u8 RfOnOffDetect(struct net_device *dev) extern void dm_CheckRfCtrlGPIO(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) - struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,gpio_change_rf_wq); - struct net_device *dev = priv->rtllib->dev; -#else struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv(dev); -#endif RT_RF_POWER_STATE eRfPowerStateToSet, CurRfState; bool bActuallySet = false; @@ -3707,13 +3599,6 @@ extern void dm_CheckRfCtrlGPIO(void *data) RT_DISABLE_ASPM(dev); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } - else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) - { -#ifdef TODO - RT_LEAVE_D3(dev, false); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); -#endif - } #endif if (RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) @@ -3753,20 +3638,12 @@ extern void dm_CheckRfCtrlGPIO(void *data) if (bActuallySet) { priv->bHwRfOffAction = 1; #ifdef CONFIG_ASPM_OR_D3 - if (eRfPowerStateToSet == eRfOn) - { - if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) - { + if (eRfPowerStateToSet == eRfOn) { + if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && + RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) { RT_DISABLE_ASPM(dev); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } -#ifdef TODO - else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) - { - RT_LEAVE_D3(dev, false); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); - } -#endif } #endif spin_lock_irqsave(&priv->rf_ps_lock,flag); @@ -3797,54 +3674,33 @@ extern void dm_CheckRfCtrlGPIO(void *data) if (eRfPowerStateToSet == eRfOff) { - if (priv->pwrdown){ - + if (priv->pwrdown) write_nic_byte(dev, SYS_FUNC_EN+1, 0x31); - } #ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) - { + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) { RT_ENABLE_ASPM(dev); RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } -#ifdef TODO - else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) - { - RT_ENTER_D3(dev, false); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); - } -#endif #endif } - } - else if (eRfPowerStateToSet == eRfOff || CurRfState == eRfOff || priv->bDriverIsGoingToUnload) - { + } else if (eRfPowerStateToSet == eRfOff || CurRfState == eRfOff || + priv->bDriverIsGoingToUnload) { - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && turnonbypowerdomain) - { + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && + turnonbypowerdomain) { PHY_SetRtl8192seRfHalt(dev); RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); } #ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) - { + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) { RT_ENABLE_ASPM(dev); RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } -#ifdef TODO - else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) - { - RT_ENTER_D3(dev, false); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); - } -#endif #endif spin_lock_irqsave(&priv->rf_ps_lock,flag); priv->RFChangeInProgress = false; spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - } - else - { + } else { spin_lock_irqsave(&priv->rf_ps_lock,flag); priv->RFChangeInProgress = false; spin_unlock_irqrestore(&priv->rf_ps_lock,flag); @@ -3854,20 +3710,13 @@ extern void dm_CheckRfCtrlGPIO(void *data) #endif void dm_rf_pathcheck_workitemcallback(void *data) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,rfpath_check_wq); struct net_device *dev =priv->rtllib->dev; -#else - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); -#endif u8 rfpath = 0, i; - rfpath = read_nic_byte(dev, 0xc04); - for (i = 0; i < RF90_PATH_MAX; i++) - { + for (i = 0; i < RF90_PATH_MAX; i++) { if (rfpath & (0x01<brfpath_rxenable[i] = 1; else @@ -4161,21 +4010,12 @@ static void dm_init_fsync (struct net_device *dev) priv->rtllib->fsync_time_interval = 500; priv->rtllib->fsync_rate_bitmap = 0x0f000800; priv->rtllib->fsync_rssi_threshold = 30; -#ifdef RTL8190P - priv->rtllib->bfsync_enable = true; -#elif defined RTL8192E || defined RTL8192SE priv->rtllib->bfsync_enable = false; -#endif priv->rtllib->fsync_multiple_timeinterval = 3; priv->rtllib->fsync_firstdiff_ratethreshold= 100; priv->rtllib->fsync_seconddiff_ratethreshold= 200; priv->rtllib->fsync_state = Default_Fsync; - -#ifdef RTL8192SE - priv->framesyncMonitor = 0; -#elif defined RTL8192E || defined RTL8190P priv->framesyncMonitor = 1; -#endif init_timer(&priv->fsync_timer); setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,(unsigned long) dev); @@ -4314,31 +4154,22 @@ extern void dm_fsync_timer_callback(unsigned long data) static void dm_StartHWFsync(struct net_device *dev) { -#if defined RTL8192E u8 rf_timing = 0x77; struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); write_nic_byte(dev, 0xc3b, 0x41); -#elif defined RTL8192SE - write_nic_byte(dev, rOFDM0_RxDetector3, 0x96); -#endif } static void dm_EndHWFsync(struct net_device *dev) { -#if defined RTL8192E u8 rf_timing = 0xaa; struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_HALDM,"%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); write_nic_byte(dev, 0xc3b, 0x49); -#elif defined RTL8192SE - write_nic_byte(dev, rOFDM0_RxDetector3, 0x94); -#endif - } static void dm_EndSWFsync(struct net_device *dev) @@ -4650,205 +4481,4 @@ static void dm_send_rssi_tofw(struct net_device *dev) DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); } -#if defined RTL8192SE -/*----------------------------------------------------------------------------- - * Function: dm_RefreshRateAdaptiveMask() - * - * Overview: Update rate table mask according to rssi - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 05/27/2009 hpfan Create Version 0. - * - *---------------------------------------------------------------------------*/ -static void dm_RefreshRateAdaptiveMask(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - prate_adaptive pRA = (prate_adaptive)&priv->rate_adaptive; - u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; - u8 rssi_level; - - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_RATE,"<---- dm_RefreshRateAdaptiveMask(): driver is going to unload\n"); - return; - } - - if (!priv->rtllib->bUseRAMask){ - return; - } - - if (priv->pFirmware->FirmwareVersion >= 61 && !priv->bInformFWDriverControlDM){ - RT_TRACE(COMP_RATE, "<---- dm_RefreshRateAdaptiveMask(): inform fw driver control dm\n"); - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_CTRL_DM_BY_DRIVER); - priv->bInformFWDriverControlDM = true; - } - - if ((priv->rtllib->state == RTLLIB_LINKED && - (priv->rtllib->iw_mode == IW_MODE_INFRA))) { - - switch (pRA->PreRATRState){ - case DM_RATR_STA_HIGH: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 20; - break; - case DM_RATR_STA_MIDDLE: - HighRSSIThreshForRA = 55; - LowRSSIThreshForRA = 20; - break; - case DM_RATR_STA_LOW: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 25; - break; - default: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 20; - break; - } - - if (priv->undecorated_smoothed_pwdb > (long)HighRSSIThreshForRA) { - pRA->ratr_state = DM_RATR_STA_HIGH; - rssi_level = 1; - } else if (priv->undecorated_smoothed_pwdb > (long)LowRSSIThreshForRA) { - pRA->ratr_state = DM_RATR_STA_MIDDLE; - rssi_level = 2; - } else { - pRA->ratr_state = DM_RATR_STA_LOW; - rssi_level = 3; - } - if ((pRA->PreRATRState != pRA->ratr_state) || - ((pRA->PreRATRState == pRA->ratr_state) && - (rssi_level != priv->rssi_level))) { - RT_TRACE(COMP_RATE, "Target AP addr : "MAC_FMT"\n", - MAC_ARG(priv->rtllib->current_network.bssid)); - RT_TRACE(COMP_RATE, "RSSI = %ld\n", - priv->undecorated_smoothed_pwdb); - RT_TRACE(COMP_RATE, "RSSI_LEVEL = %d\n", rssi_level); - RT_TRACE(COMP_RATE, "PreState = %d, CurState = %d\n", - pRA->PreRATRState, pRA->ratr_state); - priv->rtllib->UpdateHalRAMaskHandler(dev, false, 0, - priv->rtllib->pHTInfo->PeerMimoPs, - priv->rtllib->mode, - priv->rtllib->pHTInfo->bCurTxBW40MHz, - rssi_level); - priv->rssi_level = rssi_level; - pRA->PreRATRState = pRA->ratr_state; - } - } - if ((priv->rtllib->state == RTLLIB_LINKED) && - (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { - int i; - struct sta_info *pEntry; - - for (i = 0; i < PEER_MAX_ASSOC; i++) { - pEntry = priv->rtllib->peer_assoc_list[i]; - if (NULL != pEntry) { - pRA = &pEntry->rate_adaptive; - switch (pRA->PreRATRState){ - case DM_RATR_STA_HIGH: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 20; - break; - case DM_RATR_STA_MIDDLE: - HighRSSIThreshForRA = 55; - LowRSSIThreshForRA = 20; - break; - case DM_RATR_STA_LOW: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 25; - break; - default: - HighRSSIThreshForRA = 50; - LowRSSIThreshForRA = 20; - break; - } - - if (pEntry->rssi_stat.UndecoratedSmoothedPWDB > HighRSSIThreshForRA) { - pRA->ratr_state = DM_RATR_STA_HIGH; - rssi_level = 1; - } else if (pEntry->rssi_stat.UndecoratedSmoothedPWDB > LowRSSIThreshForRA) { - pRA->ratr_state = DM_RATR_STA_MIDDLE; - rssi_level = 2; - } else { - pRA->ratr_state = DM_RATR_STA_LOW; - rssi_level = 3; - } - - if (pRA->PreRATRState != pRA->ratr_state) { - RT_TRACE(COMP_RATE, "AsocEntry addr : " - MAC_FMT"\n", - MAC_ARG(pEntry->macaddr)); - RT_TRACE(COMP_RATE, "RSSI = %ld\n", - pEntry->rssi_stat.UndecoratedSmoothedPWDB); - RT_TRACE(COMP_RATE, - "RSSI_LEVEL = %d\n", - rssi_level); - RT_TRACE(COMP_RATE, - "PreState = %d, CurState = %d\n", - pRA->PreRATRState, - pRA->ratr_state); - priv->rtllib->UpdateHalRAMaskHandler( - dev, false, - pEntry->aid+1, - pEntry->htinfo.MimoPs, - pEntry->wireless_mode, - pEntry->htinfo.bCurTxBW40MHz, - rssi_level); - pRA->PreRATRState = pRA->ratr_state; - } - - } - } - } -} - -void Adhoc_InitRateAdaptive(struct net_device *dev,struct sta_info *pEntry) -{ - prate_adaptive pRA = (prate_adaptive)&pEntry->rate_adaptive; - struct r8192_priv *priv = rtllib_priv(dev); - - pRA->ratr_state = DM_RATR_STA_MAX; - pRA->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; - pRA->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; - pRA->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; - - pRA->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; - pRA->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; - pRA->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; - - if (priv->rf_type == RF_2T4R) { - /* 2008/01/11 MH Modify 2T RATR table for different RSSI. */ - pRA->upper_rssi_threshold_ratr = 0x8f0f0000; - pRA->middle_rssi_threshold_ratr = 0x8d0ff000; - pRA->low_rssi_threshold_ratr = 0x8f0ff003; - pRA->low_rssi_threshold_ratr_40M = 0x8f0ff007; - pRA->low_rssi_threshold_ratr_20M = 0x8f0ff003; - } - else if (priv->rf_type == RF_1T2R) - { - pRA->upper_rssi_threshold_ratr = 0x000f0000; - pRA->middle_rssi_threshold_ratr = 0x000ff000; - pRA->low_rssi_threshold_ratr = 0x000ff003; - pRA->low_rssi_threshold_ratr_40M = 0x000ff007; - pRA->low_rssi_threshold_ratr_20M = 0x000ff003; - } - -} - - -void Adhoc_InitRateAdaptiveState(struct net_device *dev,struct sta_info *pEntry) -{ - prate_adaptive pRA = (prate_adaptive)&pEntry->rate_adaptive; - - pRA->ratr_state = DM_RATR_STA_MAX; - pRA->PreRATRState = DM_RATR_STA_MAX; -} - - -#endif /*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_ethtool.c b/drivers/staging/rtl8192e/rtl_ethtool.c index 6c732e18540..36452fb7cef 100644 --- a/drivers/staging/rtl8192e/rtl_ethtool.c +++ b/drivers/staging/rtl8192e/rtl_ethtool.c @@ -29,7 +29,6 @@ #include "rtl_core.h" -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) static void rtl819x_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -37,10 +36,6 @@ static void rtl819x_ethtool_get_drvinfo(struct net_device *dev, strcpy(info->driver, DRV_NAME); strcpy(info->version, DRV_VERSION); -#if defined RTL8192SE - snprintf(info->fw_version, sizeof(info->fw_version), "%d", - priv->pFirmware->FirmwareVersion); -#endif strcpy(info->bus_info, pci_name(priv->pdev)); } @@ -56,4 +51,3 @@ const struct ethtool_ops rtl819x_ethtool_ops = { .get_drvinfo = rtl819x_ethtool_get_drvinfo, .get_link = rtl819x_ethtool_get_link, }; -#endif diff --git a/drivers/staging/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl_pci.c index 39b96c12af5..2416db13217 100644 --- a/drivers/staging/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl_pci.c @@ -25,337 +25,6 @@ #include "rtl_pci.h" #include "rtl_core.h" -#if defined RTL8192CE || defined RTL8192SE -bool -rtl8192_get_LinkControl_field( - struct net_device *dev, - u8 BusNum, - u8 DevNum, - u8 FuncNum - ) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - RT_PCI_CAPABILITIES_HEADER CapabilityHdr; - unsigned char CapabilityOffset, Num4Bytes; - u32 PciCfgAddrPort=0; - u8 LinkCtrlReg; - bool Status = false; - - if ( BusNum == 0xff && DevNum == 0xff && FuncNum == 0xff ){ - printk("GetLinkControlField(): Fail to find PCIe Capability\n"); - return false; - } - - - PciCfgAddrPort= (BusNum<< 16)|(DevNum << 11)|(FuncNum << 8)|(1 << 31); - - - Num4Bytes = 0x34/4; - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+( Num4Bytes<< 2)); - NdisRawReadPortUchar(PCI_CONF_DATA, &CapabilityOffset); - - - while (CapabilityOffset != 0) - { - Num4Bytes = CapabilityOffset/4; - - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+( Num4Bytes<< 2)); - NdisRawReadPortUshort(PCI_CONF_DATA, (u16*)&CapabilityHdr); - - if (CapabilityHdr.CapabilityID == PCI_CAPABILITY_ID_PCI_EXPRESS) - { - break; - } - else - { - CapabilityOffset = CapabilityHdr.Next; - } - } - - - if (CapabilityHdr.CapabilityID == PCI_CAPABILITY_ID_PCI_EXPRESS) - { - Num4Bytes = (CapabilityOffset+0x10)/4; - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); - NdisRawReadPortUchar(PCI_CONF_DATA, &LinkCtrlReg); - - priv->NdisAdapter.PciBridgePCIeHdrOffset = CapabilityOffset; - priv->NdisAdapter.PciBridgeLinkCtrlReg = LinkCtrlReg; - - Status = true; - } - else - { - printk("GetLinkControlField(): Cannot Find PCIe Capability\n"); - } - - return Status; -} - -bool -rtl8192_get_pci_BusInfo( - struct net_device *dev, - u16 VendorId, - u16 DeviceId, - u8 IRQL, - u8 BaseCode, - u8 SubClass, - u8 filed19val, - u8* BusNum, - u8* DevNum, - u8* FuncNum - ) -{ - - u8 busNumIdx, deviceNumIdx, functionNumIdx; - u32 PciCfgAddrPort=0; - u32 devVenID = 0, classCode, field19, headertype; - u16 venId, devId; - u8 basec, subc, irqLine; - u16 RegOffset; - bool bSingleFunc = false; - bool bBridgeChk = false; - - *BusNum = 0xFF; - *DevNum = 0xFF; - *FuncNum = 0xFF; - - if ((BaseCode == PCI_CLASS_BRIDGE_DEV) && (SubClass==PCI_SUBCLASS_BR_PCI_TO_PCI) && (filed19val==U1DONTCARE)) - bBridgeChk = true; - - for (busNumIdx = 0; busNumIdx < PCI_MAX_BRIDGE_NUMBER ; busNumIdx++) - { - for (deviceNumIdx = 0; deviceNumIdx < PCI_MAX_DEVICES; deviceNumIdx ++) - { - bSingleFunc = false; - for (functionNumIdx = 0; functionNumIdx < PCI_MAX_FUNCTION; functionNumIdx++) - { - - if (functionNumIdx == 0) - { - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (3 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &headertype); - headertype = ((headertype >> 16) & 0x0080) >> 7; - if ( headertype == 0) - bSingleFunc = true; - } - else - { - if (bSingleFunc == true) break; - } - - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); - NdisRawReadPortUlong(PCI_CONF_DATA, &devVenID); - - if ( devVenID == 0xFFFFFFFF||devVenID == 0 ) continue; - - RegOffset = 0x3C; - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31)|(RegOffset & 0xFFFFFFFC); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); - NdisRawReadPortUchar((PCI_CONF_DATA+ (RegOffset & 0x3)), &irqLine); - - venId = (u16)(devVenID >> 0)& 0xFFFF; - devId = (u16)(devVenID >> 16)& 0xFFFF; - - if (!bBridgeChk && (venId != VendorId) && (VendorId != U2DONTCARE)) - continue; - - if (!bBridgeChk && (devId != DeviceId) && (DeviceId != U2DONTCARE)) - continue; - - if (!bBridgeChk && (irqLine != IRQL) && (IRQL != U1DONTCARE)) - continue; - - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (2 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &classCode); - classCode = classCode >> 8; - - basec = (u8)(classCode >>16 ) & 0xFF; - subc = (u8)(classCode >>8 ) & 0xFF; - if (bBridgeChk && (venId != VendorId) &&(basec == BaseCode) && (subc== SubClass ) ) - return true; - - if (bBridgeChk && (venId != VendorId) && (VendorId != U2DONTCARE)) - continue; - - if (bBridgeChk && (devId != DeviceId) && (DeviceId != U2DONTCARE)) - continue; - - if (bBridgeChk && (irqLine != IRQL) && (IRQL != U1DONTCARE)) - continue; - - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (6 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &field19); - field19 = (field19 >> 8)& 0xFF; - - if ((basec == BaseCode) && (subc== SubClass ) && ((field19 == filed19val) ||(filed19val==U1DONTCARE) )) - { - *BusNum = busNumIdx; - *DevNum = deviceNumIdx; - *FuncNum = functionNumIdx; - - printk( "GetPciBusInfo(): Find Device(%X:%X) bus=%d dev=%d, func=%d\n",VendorId, DeviceId, busNumIdx, deviceNumIdx, functionNumIdx); - return true; - } - } - } - } - - printk( "GetPciBusInfo(): Cannot Find Device(%X:%X:%X)\n",VendorId, DeviceId, devVenID); - return false; -} - -bool rtl8192_get_pci_BridegInfo( - struct net_device *dev, - u8 BaseCode, - u8 SubClass, - u8 filed19val, - u8* BusNum, - u8* DevNum, - u8* FuncNum, - u16* VendorId, - u16* DeviceId - ) - -{ - - u8 busNumIdx, deviceNumIdx, functionNumIdx; - u32 PciCfgAddrPort=0; - u32 devVenID, classCode, field19, headertype; - u16 venId, devId; - u8 basec, subc, irqLine; - u16 RegOffset; - bool bSingleFunc = false; - - *BusNum = 0xFF; - *DevNum = 0xFF; - *FuncNum = 0xFF; - - for (busNumIdx = 0; busNumIdx < PCI_MAX_BRIDGE_NUMBER ; busNumIdx++) - { - for (deviceNumIdx = 0; deviceNumIdx < PCI_MAX_DEVICES; deviceNumIdx ++) - { - bSingleFunc = false; - for (functionNumIdx = 0; functionNumIdx < PCI_MAX_FUNCTION; functionNumIdx++) - { - - if (functionNumIdx == 0) - { - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (3 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &headertype); - headertype = ((headertype >> 16) & 0x0080) >> 7; - if ( headertype == 0) - bSingleFunc = true; - } - else - { - if ( bSingleFunc ==true ) break; - } - - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); - NdisRawReadPortUlong(PCI_CONF_DATA, &devVenID); - - RegOffset = 0x3C; - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31)|(RegOffset & 0xFFFFFFFC); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort); - NdisRawReadPortUchar((PCI_CONF_DATA+ (RegOffset & 0x3)), &irqLine); - - venId = (u16)(devVenID >> 0)& 0xFFFF; - devId = (u16)(devVenID >> 16)& 0xFFFF; - - PciCfgAddrPort= (busNumIdx << 16)|(deviceNumIdx << 11)|(functionNumIdx << 8)|(1 << 31); - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (2 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &classCode); - classCode = classCode >> 8; - - basec = (u8)(classCode >>16 ) & 0xFF; - subc = (u8)(classCode >>8 ) & 0xFF; - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort + (6 << 2)); - NdisRawReadPortUlong(PCI_CONF_DATA, &field19); - field19 = (field19 >> 8)& 0xFF; - - if ((basec == BaseCode) && (subc== SubClass ) && ((field19 == filed19val) ||(filed19val==U1DONTCARE) )) - { - *BusNum = busNumIdx; - *DevNum = deviceNumIdx; - *FuncNum = functionNumIdx; - *VendorId = venId; - *DeviceId = devId; - - printk("GetPciBridegInfo : Find Device(%X:%X) bus=%d dev=%d, func=%d\n", - venId, devId, busNumIdx, deviceNumIdx, functionNumIdx); - - return true; - } - } - } - } - - printk( "GetPciBridegInfo(): Cannot Find PciBridge for Device\n"); - - return false; -} - - -static u16 PciBridgeVendorArray[PCI_BRIDGE_VENDOR_MAX] - = {INTEL_VENDOR_ID,ATI_VENDOR_ID,AMD_VENDOR_ID,SIS_VENDOR_ID}; - -void -rtl8192_pci_find_BridgeInfo(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - u8 PciBridgeBusNum = 0xff; - u8 PciBridgeDevNum = 0xff; - u8 PciBridgeFuncNum = 0xff; - u16 PciBridgeVendorId= 0xff; - u16 PciBridgeDeviceId = 0xff; - u8 tmp = 0; - - rtl8192_get_pci_BridegInfo(dev, - PCI_CLASS_BRIDGE_DEV, - PCI_SUBCLASS_BR_PCI_TO_PCI , - priv->NdisAdapter.BusNumber, - &PciBridgeBusNum, - &PciBridgeDevNum, - &PciBridgeFuncNum, - &PciBridgeVendorId, - &PciBridgeDeviceId); - - - priv->NdisAdapter.PciBridgeVendor = PCI_BRIDGE_VENDOR_UNKNOWN; - - for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) { - if (PciBridgeVendorId == PciBridgeVendorArray[tmp]) { - priv->NdisAdapter.PciBridgeVendor = tmp; - printk("Pci Bridge Vendor is found index: %d\n",tmp); - break; - } - } - printk("Pci Bridge Vendor is %x\n",PciBridgeVendorArray[tmp]); - - priv->NdisAdapter.PciBridgeBusNum = PciBridgeBusNum; - priv->NdisAdapter.PciBridgeDevNum = PciBridgeDevNum; - priv->NdisAdapter.PciBridgeFuncNum = PciBridgeFuncNum; - priv->NdisAdapter.PciBridgeVendorId = PciBridgeVendorId; - priv->NdisAdapter.PciBridgeDeviceId = PciBridgeDeviceId; - - -} -#endif - static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -417,27 +86,6 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) return false; } -#if defined RTL8192CE || defined RTL8192SE - rtl8192_get_pci_BusInfo(dev, - VenderID, - DeviceID, - (u8)IrqLine, - 0x02,0x80, U1DONTCARE, - &priv->NdisAdapter.BusNumber, - &priv->NdisAdapter.DevNumber, - &priv->NdisAdapter.FuncNumber); - - rtl8192_pci_find_BridgeInfo(dev); - -#ifdef RTL8192SE - if (priv->NdisAdapter.PciBridgeVendor != PCI_BRIDGE_VENDOR_UNKNOWN) -#endif - { - rtl8192_get_LinkControl_field(dev, priv->NdisAdapter.PciBridgeBusNum, - priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum); - } -#endif - rtl8192_parse_pci_configuration(pdev, dev); return true; diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c index 4fbe819b59c..bcefe2d6e04 100644 --- a/drivers/staging/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -34,9 +34,7 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); -#if !(defined RTL8192SE || defined RTL8192CE) u32 ulRegRead; -#endif RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); printk("============> r8192E suspend call.\n"); @@ -59,7 +57,6 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) #endif netif_device_detach(dev); -#if !(defined RTL8192SE || defined RTL8192CE) if (!priv->rtllib->bSupportRemoteWakeUp) { MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT,true); ulRegRead = read_nic_dword(dev, CPU_GEN); @@ -69,18 +66,9 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) write_nic_dword(dev, WFCRC0, 0xffffffff); write_nic_dword(dev, WFCRC1, 0xffffffff); write_nic_dword(dev, WFCRC2, 0xffffffff); -#ifdef RTL8190P - { - u8 ucRegRead; - ucRegRead = read_nic_byte(dev, GPO); - ucRegRead |= BIT0; - write_nic_byte(dev, GPO, ucRegRead); - } -#endif write_nic_byte(dev, PMR, 0x5); write_nic_byte(dev, MacBlkCtrl, 0xa); } -#endif out_pci_suspend: RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); printk("r8192E support WOL call??????????????????????\n"); @@ -101,9 +89,7 @@ out_pci_suspend: int rtl8192E_resume (struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); -#if defined ENABLE_GPIO_RADIO_CTL || !(defined RTL8192SE || defined RTL8192CE) struct r8192_priv *priv = rtllib_priv(dev); -#endif int err; u32 val; @@ -146,11 +132,9 @@ int rtl8192E_resume (struct pci_dev *pdev) dev->open(dev); #endif -#if !(defined RTL8192SE || defined RTL8192CE) if (!priv->rtllib->bSupportRemoteWakeUp) { MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT,true); } -#endif out: RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); diff --git a/drivers/staging/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl_pm.h index edf8427dd81..22df2908181 100644 --- a/drivers/staging/rtl8192e/rtl_pm.h +++ b/drivers/staging/rtl8192e/rtl_pm.h @@ -25,10 +25,6 @@ #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -#define pm_message_t u32 -#endif - int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); int rtl8192E_resume (struct pci_dev *dev); diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index cf401352c62..65bb397154e 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -156,13 +156,6 @@ void InactivePsWorkItemCallback(struct net_device *dev) RT_DISABLE_ASPM(dev); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } -#ifdef TODO - else if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3)) - { - RT_LEAVE_D3(dev, false); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); - } -#endif } #endif MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); @@ -175,13 +168,6 @@ void InactivePsWorkItemCallback(struct net_device *dev) RT_ENABLE_ASPM(dev); RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); } -#ifdef TODO - else if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_PCI_D3) - { - RT_ENTER_D3(dev, false); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_PCI_D3); - } -#endif } #endif @@ -466,18 +452,6 @@ bool PlatformSwitchClkReq(struct net_device *dev, u8 value) pci_write_config_byte(priv->pdev,0x81,value); bResult = true; -#ifdef TODO - if (Buffer) { - priv->ClkReqState = true; - } else { - priv->ClkReqState = false; - } -#endif - -#ifdef RTL8192SE - udelay(100); -#endif - return bResult; } @@ -542,15 +516,6 @@ void PlatformEnableASPM(struct net_device *dev) return; } -#ifdef RTL8192SE - if (priv->NdisAdapter.PciBridgeVendor != PCI_BRIDGE_VENDOR_INTEL ) - { - RT_TRACE(COMP_POWER, "%s(): Dont modify ASPM for non intel chipset. For Bridge Vendor %d.\n" - ,__func__,priv->NdisAdapter.PciBridgeVendor); - return; - } -#endif - ASPMLevel |= priv->RegDevicePciASPMSetting; uDeviceASPMSetting = priv->NdisAdapter.LinkCtrlReg; @@ -586,34 +551,6 @@ bool PlatformSetPMCSR(struct net_device *dev,u8 value,bool bTempSetting) Buffer= value; spin_lock_irqsave(&priv->D3_lock,flag); -#ifdef TODO - if (bTempSetting) - { - if (Buffer==0x00) - { - priv->LeaveD3Cnt++; - - { - bActuallySet =true; - } - } - else - { - priv->LeaveD3Cnt--; - - if (priv->LeaveD3Cnt == 0) - { - bActuallySet=true; - } - } - } - else - { - priv->LeaveD3Cnt=0; - bActuallySet=true; - bSetFunc=true; - } -#endif if (bActuallySet) { if (Buffer) { PlatformSwitchClkReq(dev, 0x01); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 61780a2caa2..c2eae51ec0d 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -28,12 +28,7 @@ #include #include #include -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) #include -#else -#include -#include -#endif #include #include @@ -73,27 +68,6 @@ #define IW_CUSTOM_MAX 256 /* In bytes */ #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define jiffies_to_msecs(t) ((t) * 1000 / HZ) -#ifndef __bitwise -#define __bitwise __attribute__((bitwise)) -#endif -typedef __u16 __le16; - -#if (WIRELESS_EXT < 16) -struct iw_spy_data{ - /* --- Standard spy support --- */ - int spy_number; - u_char spy_address[IW_MAX_SPY][ETH_ALEN]; - struct iw_quality spy_stat[IW_MAX_SPY]; - /* --- Enhanced spy support (event) */ - struct iw_quality spy_thr_low; /* Low threshold */ - struct iw_quality spy_thr_high; /* High threshold */ - u_char spy_thr_under[IW_MAX_SPY]; -}; -#endif -#endif - #ifndef container_of /** * container_of - cast a member of a structure out to the containing structure @@ -108,115 +82,32 @@ struct iw_spy_data{ (type *)( (char *)__mptr - offsetof(type,member) );}) #endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)) #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) -#else -#define skb_tail_pointer_rsl(skb) skb->tail -#endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) - #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) -#else - #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL_NOVERS(x) -#endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data) -{ - task->routine = func; - task->data = data; - INIT_LIST_HEAD(&task->list); - task->sync = 0; -} -#endif +#define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -static inline void setup_timer(struct timer_list * timer, void(*function)(unsigned long), unsigned long data) -{ - timer->function = function; - timer->data = data; -} -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) typedef struct delayed_work delayed_work_struct_rsl; #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) -#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) - typedef struct tq_struct delayed_work_struct_rsl; - #define queue_delayed_work_rsl(x,y,z) schedule_task(y) - #define INIT_DELAYED_WORK_RSL(x,y,z) tq_init(x,y,z) -#else - typedef struct work_struct delayed_work_struct_rsl; - #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) - #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_WORK(x,y,z) -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) typedef struct work_struct work_struct_rsl; #define queue_work_rsl(x,y) queue_work(x,y) #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) -#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) - typedef struct tq_struct work_struct_rsl; - #define queue_work_rsl(x,y) schedule_task(y) - #define INIT_WORK_RSL(x,y,z) tq_init(x,y,z) -#else - typedef struct work_struct work_struct_rsl; - #define queue_work_rsl(x,y) queue_work(x,y) - #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y,z) -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) #define container_of_work_rsl(x,y,z) container_of(x,y,z) #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z) -#else - #define container_of_work_rsl(x,y,z) (x) - #define container_of_dwork_rsl(x,y,z) (x) -#endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -static inline char * -iwe_stream_add_event_rsl(struct iw_request_info *info, - char * stream, /* Stream of events */ - char * ends, /* End of stream */ - struct iw_event *iwe, /* Payload */ - int event_len) /* Real size of payload */ -{ - /* Check if it's possible */ - if ((stream + event_len) < ends) { - iwe->len = event_len; - ndelay(1); - memcpy(stream, (char *) iwe, event_len); - stream += event_len; - } - return stream; -} -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len) -#else - #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(start,stop,iwe,len) -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p) -#else - #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(start,stop,iwe,p) -#endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y) #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y) -#else - #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x) - #define usb_submit_urb_rsl(x,y) usb_submit_urb(x) -#endif static inline void *netdev_priv_rsl(struct net_device *dev) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) return netdev_priv(dev); -#else - return dev->priv; -#endif } #define KEY_TYPE_NA 0x0 @@ -645,34 +536,8 @@ typedef struct ieee_param { #define IW_QUAL_NOISE_UPDATED 0x4 #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)) -#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) -static inline unsigned long msleep_interruptible_rsl(unsigned int msecs) -{ - unsigned long timeout = MSECS(msecs) + 1; - - while (timeout) { - set_current_state(TASK_INTERRUPTIBLE); - timeout = schedule_timeout(timeout); - } - return timeout; -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31)) -static inline void msleep(unsigned int msecs) -{ - unsigned long timeout = MSECS(msecs) + 1; - - while (timeout) { - set_current_state(TASK_UNINTERRUPTIBLE); - timeout = schedule_timeout(timeout); - } -} -#endif -#else #define MSECS(t) msecs_to_jiffies(t) #define msleep_interruptible_rsl msleep_interruptible -#endif #define RTLLIB_DATA_LEN 2304 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section @@ -1572,11 +1437,7 @@ typedef union _frameqos { * main rates information element... */ #define MAX_RATES_LENGTH ((u8)12) #define MAX_RATES_EX_LENGTH ((u8)16) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define MAX_NETWORK_COUNT 16 -#else #define MAX_NETWORK_COUNT 96 -#endif #define MAX_CHANNEL_NUMBER 161 #define RTLLIB_SOFTMAC_SCAN_TIME 100 @@ -1980,21 +1841,6 @@ enum rtllib_state { #define RTLLIB_52GHZ_MAX_CHANNEL 165 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ RTLLIB_52GHZ_MIN_CHANNEL + 1) - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) -{ - return ((addr[0] != 0xff) && (0x01 & addr[0])); -} -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) -{ - return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ - (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); -} -#endif #ifndef eqMacAddr #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) #endif @@ -3080,17 +2926,6 @@ static inline int rtllib_is_cck_rate(u8 rate) } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2) -{ - const u16 *a = (const u16 *) addr1; - const u16 *b = (const u16 *) addr2; - - BUILD_BUG_ON(ETH_ALEN != 6); - return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; -} -#endif - /* rtllib.c */ extern void free_rtllib(struct net_device *dev); extern struct net_device *alloc_rtllib(int sizeof_priv); diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h index 5f8990c2ae0..5772252af53 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -82,12 +82,4 @@ void rtllib_crypt_deinit_entries(struct rtllib_device *, int); void rtllib_crypt_deinit_handler(unsigned long); void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, struct rtllib_crypt_data **crypt); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) -#endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31)) -#define crypto_alloc_tfm crypto_alloc_tfm_rsl -#define crypto_free_tfm crypto_free_tfm_rsl -#endif - #endif diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 80b56b4e60b..ef17c999009 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -22,17 +22,9 @@ #include #include "rtllib.h" -#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include "rtl_crypto.h" -#else #include -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - #include -#else - #include -#endif +#include #define AES_BLOCK_LEN 16 #define CCMP_HDR_LEN 8 @@ -64,27 +56,7 @@ struct rtllib_ccmp_data { void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - struct scatterlist src, dst; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - src.page = virt_to_page(pt); - src.offset = offset_in_page(pt); - src.length = AES_BLOCK_LEN; - - dst.page = virt_to_page(ct); - dst.offset = offset_in_page(ct); - dst.length = AES_BLOCK_LEN; - -#else - sg_init_one(&src, pt, AES_BLOCK_LEN); - sg_init_one(&dst, ct, AES_BLOCK_LEN); -#endif - - crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); -#else crypto_cipher_encrypt_one((void*)tfm, ct, pt); -#endif } static void * rtllib_ccmp_init(int key_idx) @@ -97,32 +69,19 @@ static void * rtllib_ccmp_init(int key_idx) memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - priv->tfm = crypto_alloc_tfm("aes", 0); - if (priv->tfm == NULL) { - printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " - "crypto API aes\n"); - goto fail; - } - #else - priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " "crypto API aes\n"); priv->tfm = NULL; goto fail; } - #endif return priv; fail: if (priv) { if (priv->tfm) - #if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) - crypto_free_tfm(priv->tfm); - #else crypto_free_cipher((void*)priv->tfm); - #endif kfree(priv); } @@ -134,11 +93,7 @@ static void rtllib_ccmp_deinit(void *priv) { struct rtllib_ccmp_data *_priv = priv; if (_priv && _priv->tfm) -#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) - crypto_free_tfm(_priv->tfm); -#else crypto_free_cipher((void*)_priv->tfm); -#endif kfree(priv); } diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index ad9a62f4c39..366c94325a7 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -22,16 +22,8 @@ #include "rtllib.h" -#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include "rtl_crypto.h" -#else #include -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - #include -#else - #include -#endif +#include #include @@ -58,17 +50,10 @@ struct rtllib_tkip_data { u32 dot11RSNAStatsTKIPLocalMICFailures; int key_idx; -#if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct crypto_blkcipher *rx_tfm_arc4; struct crypto_hash *rx_tfm_michael; struct crypto_blkcipher *tx_tfm_arc4; struct crypto_hash *tx_tfm_michael; -#else - struct crypto_tfm *tx_tfm_arc4; - struct crypto_tfm *tx_tfm_michael; - struct crypto_tfm *rx_tfm_arc4; - struct crypto_tfm *rx_tfm_michael; -#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; @@ -82,35 +67,6 @@ static void * rtllib_tkip_init(int key_idx) goto fail; memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); - if (priv->tx_tfm_arc4 == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API arc4\n"); - goto fail; - } - - priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); - if (priv->tx_tfm_michael == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API michael_mic\n"); - goto fail; - } - - priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); - if (priv->rx_tfm_arc4 == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API arc4\n"); - goto fail; - } - - priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); - if (priv->rx_tfm_michael == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API michael_mic\n"); - goto fail; - } -#else priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_arc4)) { @@ -146,22 +102,10 @@ static void * rtllib_tkip_init(int key_idx) priv->rx_tfm_michael = NULL; goto fail; } -#endif return priv; fail: if (priv) { -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (priv->tx_tfm_michael) - crypto_free_tfm(priv->tx_tfm_michael); - if (priv->tx_tfm_arc4) - crypto_free_tfm(priv->tx_tfm_arc4); - if (priv->rx_tfm_michael) - crypto_free_tfm(priv->rx_tfm_michael); - if (priv->rx_tfm_arc4) - crypto_free_tfm(priv->rx_tfm_arc4); - -#else if (priv->tx_tfm_michael) crypto_free_hash(priv->tx_tfm_michael); if (priv->tx_tfm_arc4) @@ -170,7 +114,6 @@ fail: crypto_free_hash(priv->rx_tfm_michael); if (priv->rx_tfm_arc4) crypto_free_blkcipher(priv->rx_tfm_arc4); -#endif kfree(priv); } @@ -181,16 +124,7 @@ fail: static void rtllib_tkip_deinit(void *priv) { struct rtllib_tkip_data *_priv = priv; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (_priv->tx_tfm_michael) - crypto_free_tfm(_priv->tx_tfm_michael); - if (_priv->tx_tfm_arc4) - crypto_free_tfm(_priv->tx_tfm_arc4); - if (_priv->rx_tfm_michael) - crypto_free_tfm(_priv->rx_tfm_michael); - if (_priv->rx_tfm_arc4) - crypto_free_tfm(_priv->rx_tfm_arc4); -#else + if (_priv) { if (_priv->tx_tfm_michael) crypto_free_hash(_priv->tx_tfm_michael); @@ -201,7 +135,6 @@ static void rtllib_tkip_deinit(void *priv) if (_priv->rx_tfm_arc4) crypto_free_blkcipher(_priv->rx_tfm_arc4); } -#endif kfree(priv); } @@ -371,11 +304,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 *pos; struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; - #endif u8 rc4key[16], *icv; u32 crc; struct scatterlist sg; @@ -426,23 +356,11 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) icv[2] = crc >> 16; icv[3] = crc >> 24; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = len + 4; -#else sg_init_one(&sg, pos, len+4); -#endif -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); - crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4); -#else crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); -#endif - } tkey->tx_iv16++; @@ -452,11 +370,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tcb_desc->bHwSec) - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - return 0; - #else return ret; - #endif else return 0; @@ -471,9 +385,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u16 iv16; struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; - #endif u8 rc4key[16]; u8 icv[4]; u32 crc; @@ -533,18 +445,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) plen = skb->len - hdr_len - 12; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = plen + 4; -#else sg_init_one(&sg, pos, plen+4); -#endif -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); - crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4); -#else crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { @@ -554,13 +456,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } return -7; } -#endif - #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, plen); - #else - crc = ~ether_crc_le(plen, pos); - #endif icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; @@ -607,51 +504,6 @@ if ( ((u16*)skb->data)[0] & 0x4000){ } -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) -static int michael_mic(struct crypto_tfm * tfm_michael, u8 *key, u8 *hdr, - u8 *data, size_t data_len, u8 *mic) -{ - struct scatterlist sg[2]; -#if ( !defined(BUILT_IN_CRYPTO) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) ) - struct hash_desc desc; - int ret = 0; -#endif - - if (tfm_michael == NULL){ - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - sg[0].page = virt_to_page(hdr); - sg[0].offset = offset_in_page(hdr); - sg[0].length = 16; - - sg[1].page = virt_to_page(data); - sg[1].offset = offset_in_page(data); - sg[1].length = data_len; -#else - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); -#endif - -#if ( defined(BUILT_IN_CRYPTO) || LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) ) - crypto_digest_init(tfm_michael); - crypto_digest_setkey(tfm_michael, key, 8); - crypto_digest_update(tfm_michael, sg, 2); - crypto_digest_final(tfm_michael, mic); - return 0; -#else -if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) - return -1; - - desc.tfm = tkey->tfm_michael; - desc.flags = 0; - ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); - return ret; -#endif -} -#else static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, u8 * data, size_t data_len, u8 * mic) { @@ -662,19 +514,9 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - sg[0].page = virt_to_page(hdr); - sg[0].offset = offset_in_page(hdr); - sg[0].length = 16; - - sg[1].page = virt_to_page(data); - sg[1].offset = offset_in_page(data); - sg[1].length = data_len; -#else sg_init_table(sg, 2); sg_set_buf(&sg[0], hdr, 16); sg_set_buf(&sg[1], data, data_len); -#endif if (crypto_hash_setkey(tfm_michael, key, 8)) return -1; @@ -683,9 +525,6 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, desc.flags = 0; return crypto_hash_digest(&desc, sg, data_len + 16, mic); } -#endif - - static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) { @@ -739,13 +578,8 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } pos = skb_put(skb, 8); -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) -#else - if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) -#endif return -1; return 0; @@ -814,13 +648,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) -#else - if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) -#endif return -1; if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { @@ -856,32 +685,18 @@ static int rtllib_tkip_set_key(void *key, int len, u8 *seq, void *priv) { struct rtllib_tkip_data *tkey = priv; int keyidx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - struct crypto_tfm *tfm = tkey->tx_tfm_michael; - struct crypto_tfm *tfm2 = tkey->tx_tfm_arc4; - struct crypto_tfm *tfm3 = tkey->rx_tfm_michael; - struct crypto_tfm *tfm4 = tkey->rx_tfm_arc4; -#else struct crypto_hash *tfm = tkey->tx_tfm_michael; struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; struct crypto_hash *tfm3 = tkey->rx_tfm_michael; struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; -#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) tkey->tx_tfm_michael = tfm; tkey->tx_tfm_arc4 = tfm2; tkey->rx_tfm_michael = tfm3; tkey->rx_tfm_arc4 = tfm4; -#else - tkey->tx_tfm_michael = tfm; - tkey->tx_tfm_arc4 = tfm2; - tkey->rx_tfm_michael = tfm3; - tkey->rx_tfm_arc4 = tfm4; -#endif if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 38679223fa5..201e2ec5d3a 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -18,44 +18,19 @@ #include #include "rtllib.h" -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)) -#endif - - -#if defined(BUILT_IN_CRYPTO) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include "rtl_crypto.h" -#else #include -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - #include -#else - #include -#endif +#include #include -/* -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include "rtl_crypto.h" -#else -#include -#endif -#include -#include -*/ struct prism2_wep_data { u32 iv; #define WEP_KEY_LEN 13 u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - struct crypto_tfm *tfm; - #else struct crypto_blkcipher *tx_tfm; struct crypto_blkcipher *rx_tfm; - #endif }; @@ -69,14 +44,6 @@ static void * prism2_wep_init(int keyidx) memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - priv->tfm = crypto_alloc_tfm("arc4", 0); - if (priv->tfm == NULL) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - goto fail; - } - #else priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm)) { printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " @@ -91,7 +58,6 @@ static void * prism2_wep_init(int keyidx) priv->rx_tfm = NULL; goto fail; } - #endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -99,13 +65,6 @@ static void * prism2_wep_init(int keyidx) return priv; fail: - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (priv) { - if (priv->tfm) - crypto_free_tfm(priv->tfm); - kfree(priv); - } - #else if (priv) { if (priv->tx_tfm) crypto_free_blkcipher(priv->tx_tfm); @@ -113,7 +72,6 @@ fail: crypto_free_blkcipher(priv->rx_tfm); kfree(priv); } - #endif return NULL; } @@ -121,17 +79,13 @@ fail: static void prism2_wep_deinit(void *priv) { struct prism2_wep_data *_priv = priv; - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (_priv && _priv->tfm) - crypto_free_tfm(_priv->tfm); - #else + if (_priv) { if (_priv->tx_tfm) crypto_free_blkcipher(_priv->tx_tfm); if (_priv->rx_tfm) crypto_free_blkcipher(_priv->rx_tfm); } - #endif kfree(priv); } @@ -148,9 +102,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 key[WEP_KEY_LEN + 3]; u8 *pos; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; - #endif u32 crc; u8 *icv; struct scatterlist sg; @@ -186,36 +138,19 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Copy rest of the WEP key (the secret part) */ memcpy(key + 3, wep->key, wep->key_len); - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { /* Append little-endian CRC32 and encrypt it to produce ICV */ - #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, len); - #else - crc = ~ether_crc_le(len, pos); - #endif icv = skb_put(skb, 4); icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; icv[3] = crc >> 24; - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = len + 4; - #else sg_init_one(&sg, pos, len+4); - #endif - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(wep->tfm, key, klen); - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); - return 0; - #else crypto_blkcipher_setkey(wep->tx_tfm, key, klen); return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); - #endif } return 0; @@ -236,9 +171,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; - #endif u32 crc; u8 icv[4]; struct scatterlist sg; @@ -261,28 +194,12 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; - if (!tcb_desc->bHwSec) - { - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = plen + 4; - #else + if (!tcb_desc->bHwSec) { sg_init_one(&sg, pos, plen+4); - #endif - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(wep->tfm, key, klen); - crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); - #else crypto_blkcipher_setkey(wep->rx_tfm, key, klen); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) return -7; - #endif - #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, plen); - #else - crc = ~ether_crc_le(plen, pos); - #endif icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 2a7133c6ef3..7f033815f24 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -47,10 +47,6 @@ #include "dot11d.h" #endif -#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) -#include -#endif - #if defined CONFIG_CFG_80211 #include @@ -321,140 +317,17 @@ void ieee80211_scan_rx(struct rtllib_device *ieee, struct sk_buff *skb, struct r } #endif - -#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) -static int rtllib_rx_radiotap_len(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_status) -{ - int len; - - /* always present fields */ - len = sizeof(struct ieee80211_radiotap_header) + - 8 + /* TSFT */ - 1 + /* FLAGS */ - 1 + /* RATE */ - 2 + /* CHANNEL IN MHZ */ - 2 + /* CHANNEL BITFIELD */ - 1 + /* HW SIGNAL DBM */ - 1 + /* HW NOISE DBM */ - 1; /* ANTENNA NUMBER */ - - - if (len & 1) /* padding for RX_FLAGS if necessary */ - len++; - - /* make sure radiotap starts at a naturally aligned address */ - if (len % 8) - len = roundup(len, 8); - - return len; -} - -static void rtllib_add_rx_radiotap_header(struct rtllib_device *ieee, - struct sk_buff *skb, int rtap_len, struct rtllib_rx_stats *rx_status) -{ - struct ieee80211_radiotap_header *rthdr; - unsigned char *pos; - printk("add header!\n"); - rthdr = (struct ieee80211_radiotap_header *)skb_push(skb, rtap_len); - memset(rthdr, 0, rtap_len); - - rthdr->it_version = PKTHDR_RADIOTAP_VERSION; - rthdr->it_pad = 0; - rthdr->it_len = cpu_to_le16(rtap_len); - /* radiotap header, set always present flags */ - rthdr->it_present = cpu_to_le32( - (1 << IEEE80211_RADIOTAP_TSFT) | - (1 << IEEE80211_RADIOTAP_FLAGS) | - (1 << IEEE80211_RADIOTAP_RATE) | - (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | - (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | - (1 << IEEE80211_RADIOTAP_ANTENNA)); - - pos = (unsigned char *)(rthdr+1); - /* the order of the following fields is important */ - /* IEEE80211_RADIOTAP_TSFT */ - *(__le64 *)pos = cpu_to_le64(rx_status->TimeStampLow); - pos += 8; - - /* IEEE80211_RADIOTAP_FLAGS */ - if (rx_status->bCRC) - *pos |= IEEE80211_RADIOTAP_F_BADFCS; - if (rx_status->bShortPreamble) - *pos |= IEEE80211_RADIOTAP_F_SHORTPRE; - pos++; - - /* IEEE80211_RADIOTAP_RATE */ - *pos = rx_status->rate / 5; - pos++; - - /* IEEE80211_RADIOTAP_CHANNEL */ - *(__le16 *)pos = cpu_to_le16(rx_status->received_channel); - pos += 2; - pos += 2; - - - /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ - *pos = rx_status->RxPower; - pos++; - - /* IEEE80211_RADIOTAP_DBM_ANTNOISE */ - *pos = rx_status->noise; - pos++; - - /* IEEE80211_RADIOTAP_ANTENNA */ - *pos = rx_status->Antenna; - pos++; - - /* IEEE80211_RADIOTAP_DB_ANTNOISE is not used */ - - /* IEEE80211_RADIOTAP_RX_FLAGS */ - /* ensure 2 byte alignment for the 2 byte field as required */ -} -#endif - static inline void rtllib_monitor_rx(struct rtllib_device *ieee, struct sk_buff *skb,struct rtllib_rx_stats *rx_status, size_t hdr_length) { - -#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) - int needed_headroom = 0; - struct sk_buff *radiotap_skb; - - needed_headroom = rtllib_rx_radiotap_len(ieee, rx_status); - printk("needed_headroom = %d\n", needed_headroom); - radiotap_skb = skb_copy_expand(skb, needed_headroom, 0, GFP_ATOMIC); - dev_kfree_skb(skb); - if (!radiotap_skb) { - return; - } - - rtllib_add_rx_radiotap_header(ieee, radiotap_skb, needed_headroom, rx_status); - radiotap_skb->dev = ieee->dev; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) - skb_reset_mac_header(radiotap_skb); -#else - radiotap_skb->mac.raw = radiotap_skb->data; -#endif - radiotap_skb->ip_summed = CHECKSUM_UNNECESSARY; - radiotap_skb->pkt_type = PACKET_OTHERHOST; - radiotap_skb->protocol = htons(ETH_P_802_2); - memset(radiotap_skb->cb, 0, sizeof(radiotap_skb->cb)); - netif_rx(radiotap_skb); -#else skb->dev = ieee->dev; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) skb_reset_mac_header(skb); -#else - skb->mac.raw = skb->data; -#endif skb_pull(skb, hdr_length); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); netif_rx(skb); -#endif } /* Called only as a tasklet (software IRQ) */ @@ -3252,12 +3125,10 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, { RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", info_element->len); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN); memcpy(network->wzc_ie, info_element, network->wzc_ie_len); -#endif } break; @@ -3489,9 +3360,7 @@ static inline int rtllib_network_init( network->wpa_ie_len = 0; network->rsn_ie_len = 0; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) network->wzc_ie_len = 0; -#endif if (rtllib_parse_info_param(ieee, beacon->info_element, @@ -3624,10 +3493,8 @@ static inline void update_network(struct rtllib_network *dst, dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); dst->rsn_ie_len = src->rsn_ie_len; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) memcpy(dst->wzc_ie, src->wzc_ie, src->wzc_ie_len); dst->wzc_ie_len = src->wzc_ie_len; -#endif dst->last_scanned = jiffies; /* qos related parameters */ @@ -3945,16 +3812,10 @@ static inline void rtllib_process_probe_response( #endif unsigned long flags; short renew; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); -#else - struct rtllib_network *network = kmalloc(sizeof(*network), GFP_ATOMIC); - memset(network,0,sizeof(*network)); -#endif - if (!network) { + if (!network) return; - } RTLLIB_DEBUG_SCAN( "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a843de99ed3..3ac740a7c0d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -754,21 +754,13 @@ void rtllib_start_send_beacons(struct rtllib_device *ieee) void rtllib_softmac_stop_scan(struct rtllib_device *ieee) { - - down(&ieee->scan_sem); ieee->scan_watch_dog = 0; - if (ieee->scanning_continue == 1){ + if (ieee->scanning_continue == 1) { ieee->scanning_continue = 0; ieee->actscanning = 0; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,40) -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,67) cancel_delayed_work(&ieee->softmac_scan_wq); -#endif -#else - del_timer_sync(&ieee->scan_timer); -#endif } up(&ieee->scan_sem); @@ -837,18 +829,6 @@ void rtllib_start_scan(struct rtllib_device *ieee) } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) -void rtllib_softmac_scan_cb(unsigned long _dev) -{ - unsigned long flags; - struct rtllib_device *ieee = (struct rtllib_device *)_dev; - - spin_lock_irqsave(&ieee->lock, flags); - rtllib_start_scan(ieee); - spin_unlock_irqrestore(&ieee->lock, flags); -} -#endif - /* called with wx_sem held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { @@ -2903,28 +2883,16 @@ void rtllib_stop_queue(struct rtllib_device *ieee) void rtllib_stop_all_queues(struct rtllib_device *ieee) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30) unsigned int i; for (i=0; i < ieee->dev->num_tx_queues; i++) netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; -#else - ieee->dev->trans_start = jiffies; -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - netif_carrier_off(ieee->dev); -#else netif_tx_stop_all_queues(ieee->dev); -#endif } void rtllib_wake_all_queues(struct rtllib_device *ieee) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - netif_carrier_on(ieee->dev); -#else netif_tx_wake_all_queues(ieee->dev); -#endif } inline void rtllib_randomize_cell(struct rtllib_device *ieee) @@ -3436,11 +3404,6 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->sta_edca_param[3] = 0x002F3262; ieee->aggregation = true; ieee->enable_rx_imm_BA = 1; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,40) - _setup_timer(&ieee->scan_timer, - rtllib_softmac_scan_cb, - (unsigned long) ieee); -#endif ieee->tx_pending.txb = NULL; _setup_timer(&ieee->associate_timer, @@ -3451,18 +3414,11 @@ void rtllib_softmac_init(struct rtllib_device *ieee) rtllib_send_beacon_cb, (unsigned long) ieee); -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - _setup_timer(&ieee->ibss_wait_timer, - rtllib_ibss_wait_timeout, - (unsigned long) ieee); -#endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); #else ieee->wq = create_workqueue(DRV_NAME); -#endif #endif INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); @@ -3499,11 +3455,8 @@ void rtllib_softmac_free(struct rtllib_device *ieee) #endif del_timer_sync(&ieee->associate_timer); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); -#endif - up(&ieee->wx_sem); } diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 7cda2908bae..863b2851657 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -311,13 +311,8 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, goto out; if (wrqu->mode == IW_MODE_MONITOR) { -#if defined(RTLLIB_RADIOTAP) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)) - ieee->dev->type = ARPHRD_IEEE80211_RADIOTAP; -#else ieee->dev->type = ARPHRD_IEEE80211; -#endif rtllib_EnableNetMonitorMode(ieee->dev,false); - } else { ieee->dev->type = ARPHRD_ETHER; if (ieee->iw_mode == IW_MODE_MONITOR) @@ -461,11 +456,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, proto_started = ieee->proto_started; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) - len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; -#else len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; -#endif if (len > IW_ESSID_MAX_SIZE){ ret= -E2BIG; From 5ad60c9794dce03cbc80b4dddf8622fa51965f57 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:20 +0900 Subject: [PATCH 0277/1519] rtl8192e: Remove CONFIG_RTL8192_IO_MAP Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/rtl_core.c | 79 ----------------------------- 1 file changed, 79 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 18030d6d9f0..d62bfb5aea1 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -312,36 +312,21 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { -#ifdef CONFIG_RTL8192_IO_MAP - return read_nic_io_byte(dev, x); -#else return 0xff&readb((u8*)dev->mem_start +x); -#endif } u32 read_nic_dword(struct net_device *dev, int x) { -#ifdef CONFIG_RTL8192_IO_MAP - return read_nic_io_dword(dev, x); -#else return readl((u8*)dev->mem_start +x); -#endif } u16 read_nic_word(struct net_device *dev, int x) { -#ifdef CONFIG_RTL8192_IO_MAP - return read_nic_io_word(dev, x); -#else return readw((u8*)dev->mem_start +x); -#endif } void write_nic_byte(struct net_device *dev, int x,u8 y) { -#ifdef CONFIG_RTL8192_IO_MAP - write_nic_io_byte(dev, x, y); -#else writeb(y,(u8*)dev->mem_start +x); #if !(defined RTL8192SE || defined RTL8192CE) @@ -351,15 +336,10 @@ void write_nic_byte(struct net_device *dev, int x,u8 y) #if defined RTL8192CE read_nic_byte(dev, x); #endif - -#endif } void write_nic_dword(struct net_device *dev, int x,u32 y) { -#ifdef CONFIG_RTL8192_IO_MAP - write_nic_io_dword(dev, x, y); -#else writel(y,(u8*)dev->mem_start +x); #if !(defined RTL8192SE || defined RTL8192CE) @@ -369,15 +349,10 @@ void write_nic_dword(struct net_device *dev, int x,u32 y) #if defined RTL8192CE read_nic_dword(dev, x); #endif - -#endif } void write_nic_word(struct net_device *dev, int x,u16 y) { -#ifdef CONFIG_RTL8192_IO_MAP - write_nic_io_word(dev, x, y); -#else writew(y,(u8*)dev->mem_start +x); #if !(defined RTL8192SE || defined RTL8192CE) @@ -387,8 +362,6 @@ void write_nic_word(struct net_device *dev, int x,u16 y) #if defined RTL8192CE read_nic_word(dev, x); #endif - -#endif } /**************************************************************************** @@ -3475,12 +3448,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, struct net_device *dev = NULL; struct r8192_priv *priv= NULL; struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); - -#ifdef CONFIG_RTL8192_IO_MAP - unsigned long pio_start, pio_len, pio_flags; -#else unsigned long pmem_start, pmem_len, pmem_flags; -#endif int err = 0; bool bdma64 = false; u8 revision_id; @@ -3533,25 +3501,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, else priv->rtllib->bSupportRemoteWakeUp = 0; -#ifdef CONFIG_RTL8192_IO_MAP - pio_start = (unsigned long)pci_resource_start (pdev, 0); - pio_len = (unsigned long)pci_resource_len (pdev, 0); - pio_flags = (unsigned long)pci_resource_flags (pdev, 0); - - if (!(pio_flags & IORESOURCE_IO)) { - RT_TRACE(COMP_ERR,"region #0 not a PIO resource, aborting"); - goto fail; - } - - printk("Io mapped space start: 0x%08lx \n", pio_start ); - if ( ! request_region( pio_start, pio_len, DRV_NAME ) ){ - RT_TRACE(COMP_ERR,"request_region failed!"); - goto fail; - } - - ioaddr = pio_start; - dev->base_addr = ioaddr; -#else #ifdef RTL8192CE pmem_start = pci_resource_start(pdev, 2); pmem_len = pci_resource_len(pdev, 2); @@ -3583,7 +3532,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->mem_start = ioaddr; dev->mem_end = ioaddr + pci_resource_len(pdev, 0); -#endif #if defined RTL8192SE || defined RTL8192CE pci_write_config_byte(pdev, 0x81,0); pci_write_config_byte(pdev,0x44,0); @@ -3677,20 +3625,11 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, return 0; fail1: -#ifdef CONFIG_RTL8192_IO_MAP - - if ( dev->base_addr != 0 ){ - - release_region(dev->base_addr, - pci_resource_len(pdev, 0) ); - } -#else if ( dev->mem_start != (unsigned long)NULL ){ iounmap( (void *)dev->mem_start ); release_mem_region( pci_resource_start(pdev, 1), pci_resource_len(pdev, 1) ); } -#endif fail: if (dev){ @@ -3754,24 +3693,6 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) priv->irq=0; } -#ifdef CONFIG_RTL8192_IO_MAP - if ( dev->base_addr != 0 ){ - - release_region(dev->base_addr, - pci_resource_len(pdev, 0) ); - } -#else - if ( dev->mem_start != (unsigned long)NULL ){ - iounmap( (void *)dev->mem_start ); -#ifdef RTL8192CE - release_mem_region( pci_resource_start(pdev, 2), - pci_resource_len(pdev, 2) ); -#else - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); -#endif - } -#endif /*end #ifdef RTL_IO_MAP*/ free_rtllib(dev); if (priv->scan_cmd) From 3591733d287446edbeb14bbc36fb6f23a9f8cefd Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:03 +0900 Subject: [PATCH 0278/1519] rtl8192e: Remove WIRELESS_EXT macro checks Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/rtl_core.c | 7 ---- drivers/staging/rtl8192e/rtl_wx.c | 21 +++--------- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 24 -------------- drivers/staging/rtl8192e/rtllib_rx.c | 3 +- drivers/staging/rtl8192e/rtllib_wx.c | 35 +------------------- 5 files changed, 7 insertions(+), 83 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index d62bfb5aea1..fd21c253d6e 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3564,12 +3564,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->hard_start_xmit = rtllib_xmit; #endif -#if WIRELESS_EXT >= 12 -#if WIRELESS_EXT < 17 - dev->get_wireless_stats = r8192_get_wireless_stats; -#endif dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; -#endif dev->ethtool_ops = &rtl819x_ethtool_ops; dev->type = ARPHRD_ETHER; @@ -3817,8 +3812,6 @@ static int __init rtl8192_pci_module_init(void) #endif printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n"); printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n"); - RT_TRACE(COMP_INIT, "Initializing module"); - RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); error = rtl_create_debugfs_root(); if (error) { diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 79ac60decbe..cc6bcc6b023 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -480,10 +480,8 @@ static int rtl8192_wx_get_range(struct net_device *dev, } range->num_frequency = val; range->num_channels = val; -#if WIRELESS_EXT > 17 range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2| IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; -#endif range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; /* Event capability (kernel + driver) */ @@ -521,7 +519,6 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; -#if WIRELESS_EXT > 17 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { struct iw_scan_req* req = (struct iw_scan_req*)b; @@ -531,7 +528,6 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, memcpy(ieee->current_network.ssid, req->essid, req->essid_len); } } -#endif down(&priv->wx_sem); @@ -1018,8 +1014,6 @@ exit: return err; } -#if (WIRELESS_EXT >= 18) - static int r8192_wx_set_enc_ext(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -1176,7 +1170,6 @@ static int r8192_wx_set_mlme(struct net_device *dev, up(&priv->wx_sem); return ret; } -#endif static int r8192_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, @@ -1303,13 +1296,11 @@ static iw_handler r8192_wx_handlers[] = IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, -#if (WIRELESS_EXT >= 18) - IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, - IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, - IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, - IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth, - IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext, -#endif + IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, + IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, + IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, + IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth, + IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext, }; /* @@ -1502,8 +1493,6 @@ struct iw_handler_def r8192_wx_handlers_def={ .private = r8192_private_handler, .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 .get_wireless_stats = r8192_get_wireless_stats, -#endif .private_args = (struct iw_priv_args *)r8192_private_args, }; diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 366c94325a7..b75b2b4f4f9 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -586,7 +586,6 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) } -#if WIRELESS_EXT >= 18 static void rtllib_michael_mic_failure(struct net_device *dev, struct rtllib_hdr_4addr *hdr, int keyidx) @@ -607,29 +606,6 @@ static void rtllib_michael_mic_failure(struct net_device *dev, wrqu.data.length = sizeof(ev); wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } -#elif WIRELESS_EXT >= 15 -static void rtllib_michael_mic_failure(struct net_device *dev, - struct rtllib_hdr_4addr *hdr, - int keyidx) -{ - union iwreq_data wrqu; - char buf[128]; - - /* TODO: needed parameters: count, keyid, key type, TSC */ - sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" - MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni", - MAC_ARG(hdr->addr2)); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); -} -#else /* WIRELESS_EXT >= 15 */ -static inline void rtllib_michael_mic_failure(struct net_device *dev, - struct rtllib_hdr_4addr *hdr, - int keyidx) -{ -} -#endif /* WIRELESS_EXT >= 15 */ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, int hdr_len, void *priv, struct rtllib_device* ieee) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 7f033815f24..9d8b2770b0e 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1818,11 +1818,10 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen += 4; } -#if WIRELESS_EXT > 15 rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen); ieee->stats.rx_packets++; ieee->stats.rx_bytes += skb->len; -#endif + return 1; } diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 7f3f5b05840..0855ad8a0f6 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -195,36 +195,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.u.data.length = p - custom; if (iwe.u.data.length) start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); -#if (WIRELESS_EXT < 18) - if (ieee->wpa_enabled && network->wpa_ie_len){ - char buf[MAX_WPA_IE_LEN * 2 + 30]; - u8 *p = buf; - p += sprintf(p, "wpa_ie="); - for (i = 0; i < network->wpa_ie_len; i++) { - p += sprintf(p, "%02x", network->wpa_ie[i]); - } - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } - - if (ieee->wpa_enabled && network->rsn_ie_len){ - char buf[MAX_WPA_IE_LEN * 2 + 30]; - - u8 *p = buf; - p += sprintf(p, "rsn_ie="); - for (i = 0; i < network->rsn_ie_len; i++) { - p += sprintf(p, "%02x", network->rsn_ie[i]); - } - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } -#else memset(&iwe, 0, sizeof(iwe)); if (network->wpa_ie_len) { @@ -255,7 +226,6 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.u.data.length = network->wzc_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } -#endif #endif /* Add EXTRA: Age to display seconds since last beacon/probe response @@ -531,7 +501,7 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, return 0; } -#if (WIRELESS_EXT >= 18) + int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -850,11 +820,9 @@ int rtllib_wx_set_auth(struct rtllib_device *ieee, } return 0; } -#endif int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) { -#if (WIRELESS_EXT >= 18 ) u8 *buf; u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; @@ -896,6 +864,5 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; } -#endif return 0; } From 4f6807e8d2e972393009830d305ecec2d80c0449 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:20 +0900 Subject: [PATCH 0279/1519] rtl8192e: Remove occurences of #if 1 Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/r8192E_phy.c | 3 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 9 +- drivers/staging/rtl8192e/rtl_core.c | 7 +- drivers/staging/rtl8192e/rtl_dm.c | 15 - drivers/staging/rtl8192e/rtl_ps.c | 2 - drivers/staging/rtl8192e/rtllib_rx.c | 619 +------------------ drivers/staging/rtl8192e/rtllib_softmac.c | 4 +- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 +- drivers/staging/rtl8192e/rtllib_tx.c | 2 - 9 files changed, 14 insertions(+), 651 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 78395a1a998..7ec00c218c4 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1394,7 +1394,6 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) } -#if 1 switch ( priv->rf_chip ) { case RF_8225: @@ -1417,7 +1416,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); break; } -#endif + atomic_dec(&(priv->rtllib->atm_swbw)); priv->SetBWModeInProgress= false; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 4159cb85a8b..3fbf91c8cbf 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -540,7 +540,7 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) { PTS_COMMON_INFO pTS, pTmpTS; printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); -#if 1 + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { if (memcmp(pTS->Addr, Addr, 6) == 0) @@ -581,13 +581,12 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } -#endif } void RemoveAllTS(struct rtllib_device* ieee) { PTS_COMMON_INFO pTS, pTmpTS; -#if 1 + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); @@ -615,7 +614,6 @@ void RemoveAllTS(struct rtllib_device* ieee) list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } -#endif } void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS) @@ -623,7 +621,7 @@ void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS) if (pTxTS->bAddBaReqInProgress == false) { pTxTS->bAddBaReqInProgress = true; -#if 1 + if (pTxTS->bAddBaReqDelayed) { RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); @@ -634,7 +632,6 @@ void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS) RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); } -#endif } else RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index fd21c253d6e..240b59b2d54 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -398,7 +398,7 @@ MgntActSet_RF_State( { spin_unlock_irqrestore(&priv->rf_ps_lock,flag); RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet); - #if 1 + while(priv->RFChangeInProgress) { RFWaitCounter ++; @@ -411,7 +411,6 @@ MgntActSet_RF_State( return false; } } - #endif } else { @@ -2796,7 +2795,7 @@ void rtl8192_rx_normal(struct net_device *dev) }else{ dev_kfree_skb_any(skb); } -#if 1 + new_skb = dev_alloc_skb(priv->rxbuffersize); if (unlikely(!new_skb)) { @@ -2805,7 +2804,7 @@ void rtl8192_rx_normal(struct net_device *dev) } skb=new_skb; skb->dev = dev; -#endif + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index e864acb2c0b..9f32e30f319 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -469,10 +469,8 @@ static void dm_check_rate_adaptive(struct net_device * dev) } } -#if 1 if (priv->rtllib->GetHalfNmodeSupportByAPsHandler(dev)) targetRATR &= 0xf00fffff; -#endif currentRATR = read_nic_dword(dev, RATR0); if ( targetRATR != currentRATR ) @@ -2983,7 +2981,6 @@ extern void dm_init_edca_turbo(struct net_device * dev) priv->bis_cur_rdlstate = false; } -#if 1 static void dm_check_edca_turbo( struct net_device * dev) { @@ -3086,7 +3083,6 @@ dm_CheckEdcaTurbo_EXIT: lastTxOkCnt = priv->stats.txbytesunicast; lastRxOkCnt = priv->stats.rxbytesunicast; } -#endif extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value) { @@ -3138,18 +3134,7 @@ static void dm_ctstoself(struct net_device *dev) } else { - #if 1 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - #else - if (priv->undecorated_smoothed_pwdb < priv->rtllib->CTSToSelfTH) - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - } - else if (priv->undecorated_smoothed_pwdb >= (priv->rtllib->CTSToSelfTH+5)) - { - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - } - #endif } lastTxOkCnt = priv->stats.txbytesunicast; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 65bb397154e..786106f0d8c 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -460,10 +460,8 @@ PlatformDisableASPM(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); -#if 1 u32 PciCfgAddrPort=0; u8 Num4Bytes; -#endif u8 LinkCtrlReg; u16 PciBridgeLinkCtrlReg, ASPMLevel=0; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 9d8b2770b0e..4c3590b4a96 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -608,7 +608,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) return 0; -#if 1 + if (ieee->hwsec_active) { cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); @@ -617,7 +617,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (ieee->need_sw_enc) tcb_desc->bHwSec = 0; } -#endif + hdr = (struct rtllib_hdr_4addr *) skb->data; hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); @@ -983,7 +983,6 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pReorderEntry->SeqNum = SeqNum; pReorderEntry->prxb = prxb; -#if 1 if (!AddReorderEntry(pTS, pReorderEntry)) { RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", __func__, pTS->RxIndicateSeq, SeqNum); @@ -1000,7 +999,6 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); } -#endif } else { /* @@ -1023,7 +1021,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, /* Check if there is any packet need indicate.*/ while(!list_empty(&pTS->RxPendingPktList)) { RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); -#if 1 + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) @@ -1049,7 +1047,6 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, bPktInBuf = true; break; } -#endif } /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ @@ -1831,7 +1828,6 @@ int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -#if 1 /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ @@ -1875,595 +1871,6 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, ieee->stats.rx_dropped++; return 0; } -#else -int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats) -{ - struct net_device *dev = ieee->dev; - struct rtllib_hdr_4addr *hdr; - size_t hdrlen; - u16 fc, type, stype, sc; - struct net_device_stats *stats = NULL; - unsigned int frag; - u8 *payload; - u16 ethertype; - u8 TID = 0; - u16 SeqNum = 0; - PRX_TS_RECORD pTS = NULL; -#ifdef NOT_YET - struct net_device *wds = NULL; - struct sk_buff *skb2 = NULL; - struct net_device *wds = NULL; - int frame_authorized = 0; - int from_assoc_ap = 0; - void *sta = NULL; -#endif - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 bssid[ETH_ALEN] = {0}; - u8 zero_addr[ETH_ALEN] = {0}; - struct rtllib_crypt_data *crypt = NULL; - int keyidx = 0; -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - struct sta_info * psta = NULL; -#endif - bool unicast_packet = false; - int i; - struct rtllib_rxb* rxb = NULL; - int multicast = 0; - bool tmp_dump = false; - bool bToOtherSTA = false; - hdr = (struct rtllib_hdr_4addr *)skb->data; - stats = &ieee->stats; - - multicast = is_multicast_ether_addr(hdr->addr1)|is_broadcast_ether_addr(hdr->addr1); - if (!multicast && (compare_ether_addr(dev->dev_addr, hdr->addr1) != 0)) { - if ((ieee->iw_mode == IW_MODE_MONITOR) || ieee->bNetPromiscuousMode){ - bToOtherSTA = true; - }else{ - goto rx_dropped; - } - } - - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - stype = WLAN_FC_GET_STYPE(fc); - sc = le16_to_cpu(hdr->seq_ctl); - frag = WLAN_GET_SEQ_FRAG(sc); - - ieee->need_sw_enc = 0; - - hdrlen = rtllib_get_hdrlen(fc); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); - goto rx_dropped; - } - - if (HTCCheck(ieee, skb->data)) { - if (net_ratelimit()) - printk("find HTCControl\n"); - hdrlen += 4; - rx_stats->bContainHTC = 1; - } - if (RTLLIB_QOS_HAS_SEQ(fc)) - rx_stats->bIsQosData = 1; - if ((0) && (type == RTLLIB_FTYPE_DATA) && ((is_broadcast_ether_addr(hdr->addr1)) || (compare_ether_addr(dev->dev_addr, hdr->addr1) == 0))) { - printk("===>RX data before decrypt\n"); - tmp_dump = true; - dump_buf(skb->data,skb->len); - } -#ifdef NOT_YET - hostap_update_rx_stats(local->ap, hdr, rx_stats); -#endif - - if (ieee->host_decrypt) { - int idx = 0; - if (skb->len >= hdrlen + 3) - idx = skb->data[hdrlen + 3] >> 6; - crypt = ieee->crypt[idx]; -#ifdef NOT_YET - sta = NULL; - - /* Use station specific key to override default keys if the - * receiver address is a unicast address ("individual RA"). If - * bcrx_sta_key parameter is set, station specific key is used - * even with broad/multicast targets (this is against IEEE - * 802.11, but makes it easier to use different keys with - * stations that do not support WEP key mapping). */ - - if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, - &sta); -#endif - - /* allow NULL decrypt to indicate an station specific override - * for default encryption */ - if (crypt && (crypt->ops == NULL || - crypt->ops->decrypt_mpdu == NULL)) - crypt = NULL; - - if (!crypt && (fc & RTLLIB_FCTL_WEP)) { - /* This seems to be triggered by some (multicast?) - * frames from other than current BSS, so just drop the - * frames silently instead of filling system log with - * these reports. */ - RTLLIB_DEBUG_DROP("Decryption failed (not set)" - " (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); - ieee->ieee_stats.rx_discards_undecryptable++; - goto rx_dropped; - } - } - - if (skb->len < RTLLIB_DATA_HDR3_LEN) - goto rx_dropped; - - if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || - !ieee->current_network.qos_data.active || - !IsDataFrame(skb->data) || - IsLegacyDataFrame(skb->data)) { - if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ - if (is_duplicate_packet(ieee, hdr)){ - goto rx_dropped; - } - } - } else { - PRX_TS_RECORD pRxTS = NULL; - if (GetTs(ieee, (PTS_COMMON_INFO*) &pRxTS, hdr->addr2, - (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { - if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && - (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { - goto rx_dropped; - } else { - pRxTS->RxLastFragNum = frag; - pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); - } - } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); - goto rx_dropped; - } - } - if (type == RTLLIB_FTYPE_MGMT) { - if (bToOtherSTA) - goto rx_dropped; - if (rtllib_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) - goto rx_dropped; - else - goto rx_exit; - } - if (type == RTLLIB_FTYPE_CTL) { - goto rx_dropped; - } - /* Data frame - extract src/dst addresses */ - switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { - case RTLLIB_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); - break; - case RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); - break; - case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - if (skb->len < RTLLIB_DATA_HDR4_LEN) - goto rx_dropped; - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); - break; - case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); - break; - } - - /* Filter frames from different BSS */ - if ((type != RTLLIB_FTYPE_CTL) && ((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) - && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { - goto rx_dropped; - } - - /* Filter packets sent by an STA that will be forwarded by AP */ - if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { - if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && - (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && - (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { - goto rx_dropped; - } - } - -#ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) - goto rx_dropped; - if (wds) { - skb->dev = dev = wds; - stats = hostap_get_stats(dev); - } - - if (ieee->iw_mode == IW_MODE_MASTER && !wds && - (fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) == RTLLIB_FCTL_FROMDS && - ieee->stadev && - memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { - /* Frame from BSSID of the AP for which we are a client */ - skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); - from_assoc_ap = 1; - } -#endif - - dev->last_rx = jiffies; - -#ifdef NOT_YET - if ((ieee->iw_mode == IW_MODE_MASTER || - ieee->iw_mode == IW_MODE_REPEAT) && - !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, - wds != NULL)) { - case AP_RX_CONTINUE_NOT_AUTHORIZED: - frame_authorized = 0; - break; - case AP_RX_CONTINUE: - frame_authorized = 1; - break; - case AP_RX_DROP: - goto rx_dropped; - case AP_RX_EXIT: - goto rx_exit; - } - } -#endif - /* Nullfunc frames may have PS-bit set, so they must be passed to - * hostap_handle_sta_rx() before being dropped here. */ - if (stype != RTLLIB_STYPE_DATA && - stype != RTLLIB_STYPE_DATA_CFACK && - stype != RTLLIB_STYPE_DATA_CFPOLL && - stype != RTLLIB_STYPE_DATA_CFACKPOLL&& - stype != RTLLIB_STYPE_QOS_DATA - ) { - if (stype != RTLLIB_STYPE_NULLFUNC) - RTLLIB_DEBUG_DROP( - "RX: dropped data frame " - "with no data (type=0x%02x, " - "subtype=0x%02x, len=%d)\n", - type, stype, skb->len); - goto rx_dropped; - } - - if (skb->len == hdrlen){ - goto rx_dropped; - } - - { - /* network filter more precisely */ - switch (ieee->iw_mode) { - case IW_MODE_ADHOC: - /* packets from our adapter are dropped (echo) */ - if (!memcmp(hdr->addr2, dev->dev_addr, ETH_ALEN)) - goto rx_dropped; - - /* {broad,multi}cast packets to our BSSID go through */ - if (is_multicast_ether_addr(hdr->addr1)) { - if (!memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)) - break; - else - goto rx_dropped; - } - - /* packets not to our adapter, just discard it */ - if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { - if (bToOtherSTA) - break; - else - goto rx_dropped; - } - - break; - - case IW_MODE_INFRA: - /* packets from our adapter are dropped (echo) */ - if (!memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) - goto rx_dropped; - - /* {broad,multi}cast packets to our BSS go through */ - if (is_multicast_ether_addr(hdr->addr1)) { - if (!memcmp(hdr->addr2, ieee->current_network.bssid, ETH_ALEN)) - break; - else - goto rx_dropped; - } - - /* packets to our adapter go through */ - if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { - if (bToOtherSTA) - break; - else - goto rx_dropped; - } - - break; - } - - - } - - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) - && (ieee->polling)) { - if (WLAN_FC_MORE_DATA(fc)) { - /* more data bit is set, let's request a new frame from the AP */ - rtllib_sta_ps_send_pspoll_frame(ieee); - } else { - ieee->polling = false; - } - } - -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (ieee->iw_mode == IW_MODE_ADHOC){ - psta = GetStaInfo(ieee, src); - if (NULL != psta) - psta->LastActiveTime = jiffies; - } -#endif - /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ - if ((!rx_stats->Decrypted)){ - ieee->need_sw_enc = 1; - } - - if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { - printk("decrypt frame error\n"); - goto rx_dropped; - } - if (tmp_dump) { - printk("************after decrypt\n"); - dump_buf(skb->data,skb->len); - } - hdr = (struct rtllib_hdr_4addr *) skb->data; - - /* skb: hdr + (possibly fragmented) plaintext payload */ - if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) { - int flen; - struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr); - RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); - - if (!frag_skb) { - RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG, - "Rx cannot get skb from fragment " - "cache (morefrag=%d seq=%u frag=%u)\n", - (fc & RTLLIB_FCTL_MOREFRAGS) != 0, - WLAN_GET_SEQ_SEQ(sc), frag); - goto rx_dropped; - } - flen = skb->len; - if (frag != 0) - flen -= hdrlen; - - if (frag_skb->tail + flen > frag_skb->end) { - printk(KERN_WARNING "%s: host decrypted and " - "reassembled frame did not fit skb\n", - dev->name); - rtllib_frag_cache_invalidate(ieee, hdr); - goto rx_dropped; - } - - if (frag == 0) { - /* copy first fragment (including full headers) into - * beginning of the fragment cache skb */ - memcpy(skb_put(frag_skb, flen), skb->data, flen); - } else { - /* append frame payload to the end of the fragment - * cache skb */ - memcpy(skb_put(frag_skb, flen), skb->data + hdrlen, - flen); - } - dev_kfree_skb_any(skb); - skb = NULL; - - if (fc & RTLLIB_FCTL_MOREFRAGS) { - /* more fragments expected - leave the skb in fragment - * cache for now; it will be delivered to upper layers - * after all fragments have been received */ - goto rx_exit; - } - - /* this was the last fragment and the frame will be - * delivered, so remove skb from fragment cache */ - skb = frag_skb; - hdr = (struct rtllib_hdr_4addr *) skb->data; - rtllib_frag_cache_invalidate(ieee, hdr); - } - - /* skb: hdr + (possible reassembled) full MSDU payload; possibly still - * encrypted/authenticated */ - if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) { - printk("==>decrypt msdu error\n"); - goto rx_dropped; - } - - ieee->LinkDetectInfo.NumRecvDataInPeriod++; - ieee->LinkDetectInfo.NumRxOkInPeriod++; - - hdr = (struct rtllib_hdr_4addr *) skb->data; - if ((!is_multicast_ether_addr(hdr->addr1)) && (!is_broadcast_ether_addr(hdr->addr1))) - unicast_packet = true; - if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep) { - if (/*ieee->ieee802_1x &&*/ - rtllib_is_eapol_frame(ieee, skb, hdrlen)) { - -#ifdef CONFIG_RTLLIB_DEBUG - /* pass unencrypted EAPOL frames even if encryption is - * configured */ - struct eapol *eap = (struct eapol *)(skb->data + - 24); - RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); -#endif - } else { - RTLLIB_DEBUG_DROP( - "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); - goto rx_dropped; - } - } - -#ifdef CONFIG_RTLLIB_DEBUG - if (crypt && !(fc & RTLLIB_FCTL_WEP) && - rtllib_is_eapol_frame(ieee, skb, hdrlen)) { - struct eapol *eap = (struct eapol *)(skb->data + - 24); - RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); - } -#endif - - if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep && - !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { - RTLLIB_DEBUG_DROP( - "dropped unencrypted RX data " - "frame from " MAC_FMT - " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); - goto rx_dropped; - } - if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) - && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1)) { - TID = Frame_QoSTID(skb->data); - SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true); - if (TID !=0 && TID !=3) - ieee->bis_any_nonbepkts = true; - } - /* skb: hdr + (possible reassembled) full plaintext payload */ - payload = skb->data + hdrlen; - rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); - if (rxb == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); - goto rx_dropped; - } - /* to parse amsdu packets */ - /* qos data packets & reserved bit is 1 */ - if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { - /* only to free rxb, and not submit the packets to upper layer */ - for (i =0; i < rxb->nr_subframes; i++) { - dev_kfree_skb(rxb->subframes[i]); - } - kfree(rxb); - rxb = NULL; - goto rx_dropped; - } -#if !defined(RTL8192SU) && !defined(RTL8192U) - if (unicast_packet) { - if (type == RTLLIB_FTYPE_DATA) { - if (ieee->bIsAggregateFrame) - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod+=rxb->nr_subframes; - else - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod++; - - if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) { - if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { - if (ieee->LeisurePSLeave) - ieee->LeisurePSLeave(dev); - } - } - } - } -#endif - ieee->last_rx_ps_time = jiffies; - if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA ){ - for (i = 0; inr_subframes; i++) { - struct sk_buff *sub_skb = rxb->subframes[i]; - - if (sub_skb) { - /* convert hdr + possible LLC headers into Ethernet header */ - ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; - if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ - skb_pull(sub_skb, SNAP_SIZE); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); - } else { - u16 len; - /* Leave Ethernet header part of hdr and full payload */ - len = htons(sub_skb->len); - memcpy(skb_push(sub_skb, 2), &len, 2); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); - } - - stats->rx_packets++; - stats->rx_bytes += sub_skb->len; - - if (is_multicast_ether_addr(dst)) { - stats->multicast++; - } - - /* Indicat the packets to upper layer */ - memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); - sub_skb->protocol = eth_type_trans(sub_skb, dev); - sub_skb->dev = dev; - sub_skb->dev->stats.rx_packets++; - sub_skb->dev->stats.rx_bytes += sub_skb->len; -#ifdef TCP_CSUM_OFFLOAD_RX - if ( rx_stats->tcp_csum_valid) - sub_skb->ip_summed = CHECKSUM_UNNECESSARY; - else - sub_skb->ip_summed = CHECKSUM_NONE; -#else - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ -#endif - - netif_rx(sub_skb); - } - } - kfree(rxb); - rxb = NULL; - - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__func__); -#ifdef TCP_CSUM_OFFLOAD_RX - rxb->tcp_csum_valid = rx_stats->tcp_csum_valid; -#endif - RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); - } -#ifndef JOHN_NOCPY - dev_kfree_skb(skb); -#endif - - rx_exit: -#ifdef NOT_YET - if (sta) - hostap_handle_sta_release(sta); -#endif - return 1; - - rx_dropped: - if (rxb != NULL) - { - kfree(rxb); - rxb = NULL; - } - stats->rx_dropped++; - - /* Returning 0 indicates to caller that we have not handled the SKB-- - * so it is still allocated and can be used again by underlying - * hardware as a DMA target */ - return 0; -} -#endif - -#define MGMT_FRAME_FIXED_PART_LENGTH 0x24 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; @@ -2852,7 +2259,6 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, if (info_element->data[2] & 1) network->dtim_data |= RTLLIB_DTIM_MBCAST; -#if 1 offset = (info_element->data[2] >> 1)*2; @@ -2864,25 +2270,6 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, offset = (ieee->assoc_id / 8) - offset; if (info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= RTLLIB_DTIM_UCAST; -#else - { - u16 numSta = 0; - u16 offset_byte = 0; - u16 offset_bit = 0; - - numSta = (info_element->data[2] &0xFE)*8; - - if (ieee->assoc_id < numSta || - ieee->assoc_id > (numSta + (info_element->len -3)*8)) - break; - - offset = ieee->assoc_id - numSta; - offset_byte = offset / 8; - offset_bit = offset % 8; - if (info_element->data[3+offset_byte] & (0x01<dtim_data |= RTLLIB_DTIM_UCAST; - } -#endif network->listen_interval = network->dtim_period; break; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 3ac740a7c0d..1b2e6c44cd1 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2750,7 +2750,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) if (tcb_desc->bMulticast) { ieee->stats.multicast++; } -#if 1 + /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ for (i = 0; i < txb->nr_frags; i++) { #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE @@ -2785,7 +2785,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) ieee->dev,ieee->rate); } } -#endif + rtllib_txb_free(txb); spin_unlock_irqrestore(&ieee->lock,flags); diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 863b2851657..d88bb109a31 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -570,7 +570,7 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, union iwreq_data *wrqu, char *extra) { int ret = 0; -#if 1 + if ( (!ieee->sta_wake_up) || (!ieee->enter_sleep_state) || @@ -580,7 +580,7 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, return -1; } -#endif + down(&ieee->wx_sem); if (wrqu->power.disabled){ diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 3cc066eb530..78b1707b12a 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -978,7 +978,6 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) success: if (txb) { -#if 1 cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; tcb_desc->priority = skb->priority; @@ -1086,7 +1085,6 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); #endif } -#endif } spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); From 2246698303be8ffb36fc19f4daff1052521e7ea1 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:37 +0900 Subject: [PATCH 0280/1519] rtl8192e: Remove unused debug code Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/rtl_core.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 240b59b2d54..38481a23518 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3188,17 +3188,7 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } } } -#ifdef JOHN_DEBUG - { - int i; - RT_TRACE(COMP_DBG, "@@ wrq->u pointer = "); - for (i=0;iu.data.length;i++){ - if (i%10==0) RT_TRACE(COMP_DBG, "\n"); - RT_TRACE(COMP_DBG, "%8x|", ((u32*)wrq->u.data.pointer)[i] ); - } - RT_TRACE(COMP_DBG, "\n"); - } -#endif + ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, 0); kfree(ipw); break; From d6f2deb3461688b308e5b1e9179f51e36edcdc01 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 11 Jul 2011 08:56:55 +0900 Subject: [PATCH 0281/1519] rtl8192e: Add a TODO Signed-off-by: Mike McCormack --- drivers/staging/rtl8192e/TODO | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 drivers/staging/rtl8192e/TODO diff --git a/drivers/staging/rtl8192e/TODO b/drivers/staging/rtl8192e/TODO new file mode 100644 index 00000000000..d51f159d1ad --- /dev/null +++ b/drivers/staging/rtl8192e/TODO @@ -0,0 +1,2 @@ +* merge into drivers/net/wireless/rtllib/rtl8192e +* clean up function naming From 175159c537312f95150508655256645c8daa86a0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 11 Jul 2011 18:34:09 -0500 Subject: [PATCH 0282/1519] staging: rtl8192e: Remove code dependent on RTL8190P The vendor code can conditionally generate drivers for a number of devices. Remove any code that depends on RTL8190P being set. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_rtl8256.c | 100 ------------- drivers/staging/rtl8192e/r8190P_rtl8256.h | 4 - drivers/staging/rtl8192e/r8192E_cmdpkt.c | 4 - drivers/staging/rtl8192e/r8192E_dev.c | 164 --------------------- drivers/staging/rtl8192e/r8192E_firmware.c | 16 -- drivers/staging/rtl8192e/r8192E_hw.h | 14 -- drivers/staging/rtl8192e/r8192E_phy.c | 162 -------------------- drivers/staging/rtl8192e/r8192E_phy.h | 27 ---- drivers/staging/rtl8192e/rtl819x_HTProc.c | 18 --- drivers/staging/rtl8192e/rtl_core.c | 62 -------- drivers/staging/rtl8192e/rtl_dm.c | 161 -------------------- drivers/staging/rtl8192e/rtl_dm.h | 8 - drivers/staging/rtl8192e/rtllib.h | 13 -- drivers/staging/rtl8192e/rtllib_softmac.c | 2 - 14 files changed, 755 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index 26709e5b61c..ac06d41ab65 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -193,40 +193,6 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) { u32 TxAGC=0; struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - u8 byte0, byte1; - - TxAGC |= ((powerlevel<<8)|powerlevel); - TxAGC += priv->CCKTxPowerLevelOriginalOffset; - - if (priv->bDynamicTxLowPower == true - /*pMgntInfo->bScanInProgress == true*/ ) - { - if (priv->CustomerID == RT_CID_819x_Netcore) - TxAGC = 0x2222; - else - TxAGC += ((priv->CckPwEnl<<8)|priv->CckPwEnl); - } - - byte0 = (u8)(TxAGC & 0xff); - byte1 = (u8)((TxAGC & 0xff00)>>8); - if (byte0 > 0x24) - byte0 = 0x24; - if (byte1 > 0x24) - byte1 = 0x24; - if (priv->rf_type == RF_2T4R) - { - if (priv->RF_C_TxPwDiff > 0) - { - if ( (byte0 + (u8)priv->RF_C_TxPwDiff) > 0x24) - byte0 = 0x24 - priv->RF_C_TxPwDiff; - if ( (byte1 + (u8)priv->RF_C_TxPwDiff) > 0x24) - byte1 = 0x24 - priv->RF_C_TxPwDiff; - } - } - TxAGC = (byte1<<8) |byte0; - write_nic_dword(dev, CCK_TXAGC, TxAGC); -#else #ifdef RTL8192E TxAGC = powerlevel; @@ -241,77 +207,12 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) TxAGC = 0x24; rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC); #endif -#endif } void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - u32 TxAGC1=0, TxAGC2=0, TxAGC2_tmp = 0; - u8 i, byteVal1[4], byteVal2[4], byteVal3[4]; - - if (priv->bDynamicTxHighPower == true) - { - TxAGC1 |= ((powerlevel<<24)|(powerlevel<<16)|(powerlevel<<8)|powerlevel); - TxAGC2_tmp = TxAGC1; - - TxAGC1 += priv->MCSTxPowerLevelOriginalOffset[0]; - TxAGC2 =0x03030303; - - TxAGC2_tmp += priv->MCSTxPowerLevelOriginalOffset[1]; - } - else - { - TxAGC1 |= ((powerlevel<<24)|(powerlevel<<16)|(powerlevel<<8)|powerlevel); - TxAGC2 = TxAGC1; - - TxAGC1 += priv->MCSTxPowerLevelOriginalOffset[0]; - TxAGC2 += priv->MCSTxPowerLevelOriginalOffset[1]; - - TxAGC2_tmp = TxAGC2; - - } - for (i=0; i<4; i++) - { - byteVal1[i] = (u8)( (TxAGC1 & (0xff<<(i*8))) >>(i*8) ); - if (byteVal1[i] > 0x24) - byteVal1[i] = 0x24; - byteVal2[i] = (u8)( (TxAGC2 & (0xff<<(i*8))) >>(i*8) ); - if (byteVal2[i] > 0x24) - byteVal2[i] = 0x24; - - byteVal3[i] = (u8)( (TxAGC2_tmp & (0xff<<(i*8))) >>(i*8) ); - if (byteVal3[i] > 0x24) - byteVal3[i] = 0x24; - } - - if (priv->rf_type == RF_2T4R) - { - if (priv->RF_C_TxPwDiff > 0) - { - for (i=0; i<4; i++) - { - if ( (byteVal1[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) - byteVal1[i] = 0x24 - priv->RF_C_TxPwDiff; - if ( (byteVal2[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) - byteVal2[i] = 0x24 - priv->RF_C_TxPwDiff; - if ( (byteVal3[i] + (u8)priv->RF_C_TxPwDiff) > 0x24) - byteVal3[i] = 0x24 - priv->RF_C_TxPwDiff; - } - } - } - - TxAGC1 = (byteVal1[3]<<24) | (byteVal1[2]<<16) |(byteVal1[1]<<8) |byteVal1[0]; - TxAGC2 = (byteVal2[3]<<24) | (byteVal2[2]<<16) |(byteVal2[1]<<8) |byteVal2[0]; - - TxAGC2_tmp = (byteVal3[3]<<24) | (byteVal3[2]<<16) |(byteVal3[1]<<8) |byteVal3[0]; - priv->Pwr_Track = TxAGC2_tmp; - - write_nic_dword(dev, MCS_TXAGC, TxAGC1); - write_nic_dword(dev, MCS_TXAGC+4, TxAGC2); -#else #ifdef RTL8192E u32 writeVal, powerBase0, powerBase1, writeVal_tmp; u8 index = 0; @@ -356,7 +257,6 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); } -#endif #endif return; } diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h index 08bcb6213ac..32d2822dcf5 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -20,11 +20,7 @@ #ifndef RTL8225H #define RTL8225H -#ifdef RTL8190P -#define RTL819X_TOTAL_RF_PATH 4 -#else #define RTL819X_TOTAL_RF_PATH 2 -#endif extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); extern bool PHY_RF8256_Config(struct net_device* dev); extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index ea9fa579832..de65f4064c1 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -16,7 +16,6 @@ * Contact Information: * wlanfae ******************************************************************************/ -#if (defined(RTL8192E) || defined(RTL8190P)) #include "rtl_core.h" #include "r8192E_hw.h" @@ -453,6 +452,3 @@ cmpk_message_handle_rx( RT_TRACE(COMP_CMDPKT, "<----cmpk_message_handle_rx()\n"); } - - -#endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index ba988f0fbd3..16f2cef29b2 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -345,10 +345,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) #endif u16 i,usValue, IC_Version; u16 EEPROMId; -#ifdef RTL8190P - u8 offset; - u8 EepromTxPower[100]; -#endif u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); @@ -376,9 +372,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) priv->eeprom_ChannelPlan = usValue&0xff; IC_Version = ((usValue&0xff00)>>8); -#ifdef RTL8190P - priv->card_8192_version = (VERSION_8190)(IC_Version); -#elif defined RTL8192E ICVer8192 = (IC_Version&0xf); ICVer8256 = ((IC_Version&0xf0)>>4); RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); @@ -388,7 +381,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) if (ICVer8256 == 0x5) priv->card_8192_version= VERSION_8190_BE; } -#endif switch (priv->card_8192_version) { case VERSION_8190_BD: @@ -515,75 +507,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) } else if (priv->epromtype== EEPROM_93C56) { -#ifdef RTL8190P - if (!priv->AutoloadFailFlag) - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = (u8)(((eprom_read(dev, (EEPROM_C56_CrystalCap>>1))) & 0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT,"EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); - - if (!priv->AutoloadFailFlag) - { - for (i = 0; i < 12; i+=2) - { - if (i <6) - offset = EEPROM_C56_RfA_CCK_Chnl1_TxPwIndex + i; - else - offset = EEPROM_C56_RfC_CCK_Chnl1_TxPwIndex + i - 6; - usValue = eprom_read(dev, (offset>>1)); - *((u16*)(&EepromTxPower[i])) = usValue; - } - - for (i = 0; i < 12; i++) - { - if (i <= 2) - priv->EEPROMRfACCKChnl1TxPwLevel[i] = EepromTxPower[i]; - else if ((i >=3 )&&(i <= 5)) - priv->EEPROMRfAOfdmChnlTxPwLevel[i-3] = EepromTxPower[i]; - else if ((i >=6 )&&(i <= 8)) - priv->EEPROMRfCCCKChnl1TxPwLevel[i-6] = EepromTxPower[i]; - else - priv->EEPROMRfCOfdmChnlTxPwLevel[i-9] = EepromTxPower[i]; - } - } - else - { - priv->EEPROMRfACCKChnl1TxPwLevel[0] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfACCKChnl1TxPwLevel[1] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfACCKChnl1TxPwLevel[2] = EEPROM_Default_TxPowerLevel; - - priv->EEPROMRfAOfdmChnlTxPwLevel[0] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfAOfdmChnlTxPwLevel[1] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfAOfdmChnlTxPwLevel[2] = EEPROM_Default_TxPowerLevel; - - priv->EEPROMRfCCCKChnl1TxPwLevel[0] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfCCCKChnl1TxPwLevel[1] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfCCCKChnl1TxPwLevel[2] = EEPROM_Default_TxPowerLevel; - - priv->EEPROMRfCOfdmChnlTxPwLevel[0] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfCOfdmChnlTxPwLevel[1] = EEPROM_Default_TxPowerLevel; - priv->EEPROMRfCOfdmChnlTxPwLevel[2] = EEPROM_Default_TxPowerLevel; - } - RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[0] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[0]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[1] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[1]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfACCKChnl1TxPwLevel[2] = 0x%x\n", priv->EEPROMRfACCKChnl1TxPwLevel[2]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[0] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[0]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[1] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[1]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfAOfdmChnlTxPwLevel[2] = 0x%x\n", priv->EEPROMRfAOfdmChnlTxPwLevel[2]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[0] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[0]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[1] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[1]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCCCKChnl1TxPwLevel[2] = 0x%x\n", priv->EEPROMRfCCCKChnl1TxPwLevel[2]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[0] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[0]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[1] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[1]); - RT_TRACE(COMP_INIT, "priv->EEPROMRfCOfdmChnlTxPwLevel[2] = 0x%x\n", priv->EEPROMRfCOfdmChnlTxPwLevel[2]); -#endif } if (priv->epromtype == EEPROM_93C46) @@ -724,11 +647,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) switch (priv->CustomerID) { case RT_CID_DEFAULT: -#ifdef RTL8190P - priv->LedStrategy = HW_LED; -#elif defined RTL8192E priv->LedStrategy = SW_LED_MODE1; -#endif break; case RT_CID_819x_CAMEO: @@ -754,11 +673,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) case RT_CID_TOSHIBA: default: -#ifdef RTL8190P - priv->LedStrategy = HW_LED; -#elif defined RTL8192E priv->LedStrategy = SW_LED_MODE1; -#endif break; } RT_TRACE(COMP_INIT, "LedStrategy = %d \n", priv->LedStrategy); @@ -862,9 +777,6 @@ bool rtl8192_adapter_start(struct net_device *dev) u8 ICVersion,SwitchingRegulatorOutput; #endif bool bfirmwareok = true; -#ifdef RTL8190P - u8 ucRegRead; -#endif u32 tmpRegA, tmpRegC, TempCCk; int i = 0; u32 retry_times = 0; @@ -900,9 +812,6 @@ start: else RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); -#ifdef RTL8190P - ulRegRead &= (~(CPU_GEN_GPIO_UART)); -#endif write_nic_dword(dev, CPU_GEN, ulRegRead); @@ -953,14 +862,8 @@ start: rtl8192_hwconfig(dev); write_nic_byte(dev, CMDR, CR_RE|CR_TE); -#ifdef RTL8190P - write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); write_nic_dword(dev, RCR, priv->ReceiveConfig); @@ -1067,15 +970,6 @@ start: #ifdef RTL8192E write_nic_byte(dev, 0x87, 0x0); #endif -#ifdef RTL8190P - ucRegRead = read_nic_byte(dev, GPE); - ucRegRead |= BIT0; - write_nic_byte(dev, GPE, ucRegRead); - - ucRegRead = read_nic_byte(dev, GPO); - ucRegRead &= ~BIT0; - write_nic_byte(dev, GPO, ucRegRead); -#endif if (priv->RegRfOff == true) { RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); @@ -1390,11 +1284,7 @@ void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb if (cb_desc->bPacketBW) { pTxFwInfo->TxBandwidth = 1; -#ifdef RTL8190P - pTxFwInfo->TxSubCarrier = 3; -#else pTxFwInfo->TxSubCarrier = 0; -#endif } else { @@ -1712,25 +1602,6 @@ void rtl8192_query_rxphystatus( { u8 report; -#ifdef RTL8190P - u8 tmp_pwdb; - char cck_adc_pwdb[4]; -#endif - priv->stats.numqry_phystatusCCK++; - -#ifdef RTL8190P - if (priv->rf_type == RF_2T4R && DM_RxPathSelTable.Enable && bpacket_match_bssid) - { - for (i=RF90_PATH_A; iadc_pwdb_X[i]; - cck_adc_pwdb[i] = (char)tmp_pwdb; - cck_adc_pwdb[i] /= 2; - pstats->cck_adc_pwdb[i] = precord_stats->cck_adc_pwdb[i] = cck_adc_pwdb[i]; - } - } -#endif - if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; @@ -1807,11 +1678,7 @@ void rtl8192_query_rxphystatus( if (priv->brfpath_rxenable[i]) rf_rx_num++; -#ifdef RTL8190P - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106; -#else rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; -#endif tmp_rxsnr = pofdm_buf->rxsnr_X[i]; rx_snrX = (char)(tmp_rxsnr); @@ -2224,9 +2091,6 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) u8 OpMode; u8 u1bTmp; u32 ulRegRead; -#ifdef RTL8190P - u8 ucRegRead; -#endif OpMode = RT_OP_MODE_NO_LINK; priv->rtllib->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode); @@ -2254,15 +2118,9 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) if (!priv->rtllib->bSupportRemoteWakeUp) { -#ifdef RTL8190P - { - PHY_SetRtl8190pRfOff(dev); - } -#elif defined RTL8192E { PHY_SetRtl8192eRfOff(dev); } -#endif ulRegRead = read_nic_dword(dev,CPU_GEN); ulRegRead|=CPU_GEN_SYSTEM_RESET; write_nic_dword(dev,CPU_GEN, ulRegRead); @@ -2274,13 +2132,6 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) write_nic_dword(dev, WFCRC2, 0xffffffff); -#ifdef RTL8190P - { - ucRegRead = read_nic_byte(dev, GPO); - ucRegRead |= BIT0; - write_nic_byte(dev, GPO, ucRegRead); - } -#endif write_nic_byte(dev, PMR, 0x5); write_nic_byte(dev, MacBlkCtrl, 0xa); } @@ -2348,11 +2199,7 @@ rtl8192_InitializeVariables(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - strcpy(priv->nick, "rtl8190p"); -#elif defined(RTL8192E) strcpy(priv->nick, "rtl8192E"); -#endif #ifdef _ENABLE_SW_BEACON priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | @@ -2576,14 +2423,7 @@ bool rtl8192_HalTxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool bStuck = false; -#if defined(RTL8192E) || defined(RTL8190P) u16 RegTxCounter = read_nic_word(dev, 0x128); -#elif defined (RTL8192SE) || defined (RTL8192CE) - u16 RegTxCounter = read_nic_word(dev, 0x366); -#else - u16 RegTxCounter = priv->TxCounter + 1; - WARN_ON(1); -#endif RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__,RegTxCounter,priv->TxCounter); @@ -2635,11 +2475,7 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) u8 tmp_Short; tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); -#if defined RTL8192SE || defined RTL8192CE - if (TxHT==1 && TxRate != DESC92S_RATEMCS15) -#elif defined RTL8192E || defined RTL8190P if (TxHT==1 && TxRate != DESC90_RATEMCS15) -#endif tmp_Short = 0; return tmp_Short; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 8c77d133ad0..f7d191736d0 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -216,12 +216,6 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu switch (load_fw_status) { case FW_INIT_STEP0_BOOT: pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE; -#ifdef RTL8190P - rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET); - if (!rt_status) { - RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n"); - } -#endif break; case FW_INIT_STEP1_MAIN: @@ -262,15 +256,6 @@ bool init_firmware(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; -#ifdef RTL8190P - u8 *firmware_img_buf[3] = { &Rtl8190PciFwBootArray[0], - &Rtl8190PciFwMainArray[0], - &Rtl8190PciFwDataArray[0]}; - - u32 firmware_img_len[3] = { sizeof(Rtl8190PciFwBootArray), - sizeof(Rtl8190PciFwMainArray), - sizeof(Rtl8190PciFwDataArray)}; -#else u8 *firmware_img_buf[3] = { &Rtl8192PciEFwBootArray[0], &Rtl8192PciEFwMainArray[0], &Rtl8192PciEFwDataArray[0]}; @@ -278,7 +263,6 @@ bool init_firmware(struct net_device *dev) u32 firmware_img_len[3] = { sizeof(Rtl8192PciEFwBootArray), sizeof(Rtl8192PciEFwMainArray), sizeof(Rtl8192PciEFwDataArray)}; -#endif u32 file_length = 0; u8 *mapped_file = NULL; u8 init_step = 0; diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 0b29636c302..6c16888a626 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -70,19 +70,6 @@ typedef enum _BaseBand_Config_Type { #define EEPROM_Default_TxPower 0x1010 #define EEPROM_ICVersion_ChannelPlan 0x7C #define EEPROM_Customer_ID 0x7B -#ifdef RTL8190P -#define EEPROM_RFInd_PowerDiff 0x14 -#define EEPROM_ThermalMeter 0x15 -#define EEPROM_TxPwDiff_CrystalCap 0x16 -#define EEPROM_TxPwIndex_CCK 0x18 -#define EEPROM_TxPwIndex_OFDM_24G 0x26 -#define EEPROM_TxPwIndex_OFDM_5G 0x34 -#define EEPROM_C56_CrystalCap 0x17 -#define EEPROM_C56_RfA_CCK_Chnl1_TxPwIndex 0x80 -#define EEPROM_C56_RfA_HT_OFDM_TxPwIndex 0x81 -#define EEPROM_C56_RfC_CCK_Chnl1_TxPwIndex 0xbc -#define EEPROM_C56_RfC_HT_OFDM_TxPwIndex 0xb9 -#else #ifdef RTL8192E #define EEPROM_RFInd_PowerDiff 0x28 #define EEPROM_ThermalMeter 0x29 @@ -90,7 +77,6 @@ typedef enum _BaseBand_Config_Type { #define EEPROM_TxPwIndex_CCK 0x2C #define EEPROM_TxPwIndex_OFDM_24G 0x3A #endif -#endif #define EEPROM_Default_TxPowerLevel 0x10 #define EEPROM_IC_VER 0x7d #define EEPROM_CRC 0x7e diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 7ec00c218c4..ff88330a267 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -16,8 +16,6 @@ * Contact Information: * wlanfae ******************************************************************************/ -#if (defined(RTL8192E) || defined(RTL8190P)) - #include "rtl_core.h" #include "r8192E_hw.h" @@ -29,10 +27,6 @@ #include "dot11d.h" #endif -#ifdef RTL8190P -#include "r8190P_hwimg.h" -#endif - #ifdef RTL8192E #include "r8192E_hwimg.h" #endif @@ -73,19 +67,6 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) { u8 ret = 1; struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - if (priv->rf_type == RF_2T4R) - { - ret= 1; - } - else if (priv->rf_type == RF_1T2R) - { - if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) - ret = 0; - else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) - ret = 1; - } -#else #ifdef RTL8192E if (priv->rf_type == RF_2T4R) ret = 0; @@ -97,7 +78,6 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) ret = 0; } #endif -#endif return ret; } void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) @@ -135,13 +115,9 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, if (priv->rf_chip == RF_8256) { -#ifdef RTL8190P - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); #endif -#endif if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; @@ -184,20 +160,9 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); -#ifdef RTL8190P - if (priv->rf_type == RF_2T4R) - { - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); - } - else if (priv->rf_type == RF_1T2R) - { - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); - } -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); #endif -#endif } @@ -215,13 +180,9 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath if (priv->rf_chip == RF_8256) { -#ifdef RTL8190P - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); #endif -#endif if (Offset >= 31) { @@ -264,20 +225,9 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); } -#ifdef RTL8190P - if (priv->rf_type == RF_2T4R) - { - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); - } - else if (priv->rf_type == RF_1T2R) - { - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); - } -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); #endif -#endif } return; @@ -705,17 +655,10 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) (bXBTxAGC|bXCTxAGC|bXDTxAGC), dwRegValue); -#ifdef RTL8190P - dwRegValue = priv->CrystalCap & 0x3; - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap01, dwRegValue); - dwRegValue = ((priv->CrystalCap & 0xc)>>2); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, bXtalCap23, dwRegValue); -#else #ifdef RTL8192E dwRegValue = priv->CrystalCap; rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); #endif -#endif } @@ -732,14 +675,6 @@ bool rtl8192_BBConfig(struct net_device* dev) void rtl8192_phy_getTxPower(struct net_device* dev) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - priv->MCSTxPowerLevelOriginalOffset[0] = - read_nic_dword(dev, MCS_TXAGC); - priv->MCSTxPowerLevelOriginalOffset[1] = - read_nic_dword(dev, (MCS_TXAGC+4)); - priv->CCKTxPowerLevelOriginalOffset = - read_nic_dword(dev, CCK_TXAGC); -#else #ifdef RTL8192E priv->MCSTxPowerLevelOriginalOffset[0] = read_nic_dword(dev, rTxAGC_Rate18_06); @@ -754,7 +689,6 @@ void rtl8192_phy_getTxPower(struct net_device* dev) priv->MCSTxPowerLevelOriginalOffset[5] = read_nic_dword(dev, rTxAGC_Mcs15_Mcs12); #endif -#endif priv->DefaultInitialGain[0] = read_nic_byte(dev, rOFDM0_XAAGCCore1); priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); @@ -1246,7 +1180,6 @@ static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev ) } } -#ifndef RTL8190P static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1272,7 +1205,6 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) } dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } -#endif static void CCK_Tx_Power_Track_BW_Switch(struct net_device *dev) { @@ -1280,14 +1212,10 @@ static void CCK_Tx_Power_Track_BW_Switch(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); #endif -#ifdef RTL8190P - CCK_Tx_Power_Track_BW_Switch_TSSI(dev); -#else if (priv->IC_Cut >= IC_VersionCut_D) CCK_Tx_Power_Track_BW_Switch_TSSI(dev); else CCK_Tx_Power_Track_BW_Switch_ThermalMeter(dev); -#endif } void rtl8192_SetBWModeWorkItem(struct net_device *dev) @@ -1343,14 +1271,9 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) else CCK_Tx_Power_Track_BW_Switch(dev); -#ifdef RTL8190P - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 1); - rtl8192_setBBreg(dev, rOFDM0_RxDetector1, bMaskByte0, 0x44); -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); #endif -#endif break; case HT_CHANNEL_WIDTH_20_40: @@ -1370,23 +1293,9 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); -#ifdef RTL8190P - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 0); - rtl8192_setBBreg(dev, rOFDM0_RxDetector1, bMaskByte0, 0x42); - - if (priv->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) - { - rtl8192_setBBreg(dev, rFPGA0_RFMOD, (BIT6|BIT5), 0x01); - }else if (priv->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) - { - rtl8192_setBBreg(dev, rFPGA0_RFMOD, (BIT6|BIT5), 0x02); - } - -#else #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); #endif -#endif break; default: RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); @@ -1518,26 +1427,6 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation) } } -#if defined RTL8190P -extern void -PHY_SetRtl8190pRfOff(struct net_device* dev ) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (priv->rf_type == RF_2T4R) - { - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); - } - rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x0); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e0, 0x0); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0x0); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e00, 0x0); - -} -#endif - #if defined RTL8192E extern void PHY_SetRtl8192eRfOff(struct net_device* dev ) @@ -1582,37 +1471,6 @@ SetRFPowerState8190( { case eRfOn: RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn !\n"); - #ifdef RTL8190P - if (priv->rf_type == RF_2T4R) - { - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e0, 0xf); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0xf); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0xf); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1e00, 0xf); - } - else if (priv->rf_type == RF_1T2R) - { - rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xc00, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x180, 0x3); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xc, 0x3); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xc, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x1800, 0x3); - } - else if (priv->rf_type == RF_1T1R) - { - rtl8192_setBBreg(dev, rFPGA0_XC_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x400, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x80, 0x1); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x4, 0x1); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x800, 0x1); - } - -#elif defined RTL8192E if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { bool rtstatus = true; @@ -1647,7 +1505,6 @@ SetRFPowerState8190( } - #endif break; case eRfSleep: @@ -1687,15 +1544,9 @@ SetRFPowerState8190( } } -#ifdef RTL8190P - { - PHY_SetRtl8190pRfOff(dev); - } -#elif defined RTL8192E { PHY_SetRtl8192eRfOff(dev); } -#endif } break; @@ -1733,11 +1584,6 @@ SetRFPowerState8190( } } -#if defined RTL8190P - { - PHY_SetRtl8190pRfOff(dev); - } -#elif defined RTL8192E { if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { @@ -1760,12 +1606,6 @@ SetRFPowerState8190( } #endif } -#else - else - { - RT_TRACE(COMP_DBG,DBG_TRACE,("It is not 8190Pci and 8192PciE \n")); - } - #endif break; @@ -1882,5 +1722,3 @@ PHY_ScanOperationBackup8192( } } - -#endif diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index ad0b9fd9d25..fe900aa5767 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -25,28 +25,6 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -#ifdef RTL8190P -#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPci -#define MACPHY_ArrayLength MACPHY_ArrayLengthPci -#define RadioA_ArrayLength RadioA_ArrayLengthPci -#define RadioB_ArrayLength RadioB_ArrayLengthPci -#define MACPHY_Array_PGLength MACPHY_Array_PGLengthPci -#define RadioC_ArrayLength RadioC_ArrayLengthPci -#define RadioD_ArrayLength RadioD_ArrayLengthPci -#define PHY_REGArrayLength PHY_REGArrayLengthPci -#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPci - -#define Rtl819XMACPHY_Array_PG Rtl8190PciMACPHY_Array_PG -#define Rtl819XMACPHY_Array Rtl8190PciMACPHY_Array -#define Rtl819XRadioA_Array Rtl8190PciRadioA_Array -#define Rtl819XRadioB_Array Rtl8190PciRadioB_Array -#define Rtl819XRadioC_Array Rtl8190PciRadioC_Array -#define Rtl819XRadioD_Array Rtl8190PciRadioD_Array -#define Rtl819XAGCTAB_Array Rtl8190PciAGCTAB_Array -#define Rtl819XPHY_REGArray Rtl8190PciPHY_REGArray -#define Rtl819XPHY_REG_1T2RArray Rtl8190PciPHY_REG_1T2RArray -#endif - #ifdef RTL8192E #define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE #define MACPHY_ArrayLength MACPHY_ArrayLengthPciE @@ -142,11 +120,6 @@ extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); -#if defined RTL8190P -extern void -PHY_SetRtl8190pRfOff(struct net_device* dev ); -#endif - #if defined RTL8192E extern void PHY_SetRtl8192eRfOff(struct net_device* dev ); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 1aa7d80e8de..a212a972ec6 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -476,14 +476,10 @@ u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *netw u8 retValue = 0; -#if (defined RTL8192U || defined RTL8192E || defined RTL8190P) - { if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { retValue = 1; } - } -#endif return retValue; } @@ -563,12 +559,10 @@ HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *netwo u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; -#if (defined RTL8190P || defined RTL8192U || defined RTL8192SU) if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { retValue = 1; } -#endif return retValue; } @@ -1149,11 +1143,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); } #endif -#ifndef RTL8190P if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) -#else - if ( 0 ) -#endif { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; @@ -1294,17 +1284,9 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; -#if defined(RTL8190P) || defined(RTL8192E) || defined(RTL8192U) bIOTAction = HTIOTActIsMgntUseCCK6M(ieee,pNetwork); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; -#elif defined(RTL8192SE) || defined(RTL8192SU) || defined RTL8192CE - bIOTAction = HTIOTActWAIOTBroadcom(ieee); - if (bIOTAction) - { - pHTInfo->IOTAction |= HT_IOT_ACT_WA_IOT_Broadcom; - } -#endif bIOTAction = HTIOTActIsCCDFsync(ieee); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 38481a23518..406986c8beb 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -626,20 +626,12 @@ void rtl8192_update_cap(struct net_device* dev, u16 cap) } } -#ifdef RTL8192CE - if ( net->mode & IEEE_G) -#elif defined RTL8192SE || defined RTL8192E || defined RTL8190P if (net->mode & (IEEE_G|IEEE_N_24G)) -#endif { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; -#ifdef RTL8192CE - if ( (cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!(priv->rtllib->pHTInfo->RT2RT_HT_Mode & RT_HT_CAP_USE_LONG_PREAMBLE))) -#elif defined RTL8192SE || defined RTL8192E || defined RTL8190P if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) -#endif { if (CurSlotTime != SHORT_SLOT_TIME) { @@ -1281,7 +1273,6 @@ static void rtl8192_init_priv_constant(struct net_device* dev) priv->RegSupportPciASPM = 2; -#elif defined RTL8190P #endif } @@ -1883,9 +1874,6 @@ RESET_START: dm_backup_dynamic_mechanism_state(dev); #endif -#ifdef RTL8190P - priv->ops->stop_adapter(dev, true); -#endif up(&priv->wx_sem); RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); @@ -2608,56 +2596,6 @@ rtl819x_process_cck_rxpathsel( struct rtllib_rx_stats * pprevious_stats ) { -#ifdef RTL8190P - char last_cck_adc_pwdb[4]={0,0,0,0}; - u8 i; - if (priv->rf_type == RF_2T4R && DM_RxPathSelTable.Enable) - { - if (pprevious_stats->bIsCCK && - (pprevious_stats->bPacketToSelf ||pprevious_stats->bPacketBeacon)) - { - if (priv->stats.cck_adc_pwdb.TotalNum++ >= PHY_RSSI_SLID_WIN_MAX) - { - priv->stats.cck_adc_pwdb.TotalNum = PHY_RSSI_SLID_WIN_MAX; - for (i=RF90_PATH_A; istats.cck_adc_pwdb.elements[i][priv->stats.cck_adc_pwdb.index]; - priv->stats.cck_adc_pwdb.TotalVal[i] -= last_cck_adc_pwdb[i]; - } - } - for (i=RF90_PATH_A; istats.cck_adc_pwdb.TotalVal[i] += pprevious_stats->cck_adc_pwdb[i]; - priv->stats.cck_adc_pwdb.elements[i][priv->stats.cck_adc_pwdb.index] = pprevious_stats->cck_adc_pwdb[i]; - } - priv->stats.cck_adc_pwdb.index++; - if (priv->stats.cck_adc_pwdb.index >= PHY_RSSI_SLID_WIN_MAX) - priv->stats.cck_adc_pwdb.index = 0; - - for (i=RF90_PATH_A; istats.cck_adc_pwdb.TotalVal[i]/priv->stats.cck_adc_pwdb.TotalNum; - } - - for (i=RF90_PATH_A; icck_adc_pwdb[i] > (char)priv->undecorated_smoothed_cck_adc_pwdb[i]) - { - priv->undecorated_smoothed_cck_adc_pwdb[i] = - ( (priv->undecorated_smoothed_cck_adc_pwdb[i]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->cck_adc_pwdb[i])) /(Rx_Smooth_Factor); - priv->undecorated_smoothed_cck_adc_pwdb[i] = priv->undecorated_smoothed_cck_adc_pwdb[i] + 1; - } - else - { - priv->undecorated_smoothed_cck_adc_pwdb[i] = - ( (priv->undecorated_smoothed_cck_adc_pwdb[i]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->cck_adc_pwdb[i])) /(Rx_Smooth_Factor); - } - } - } - } -#endif } diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 9f32e30f319..c494505d91c 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -133,12 +133,10 @@ static void dm_check_txpower_tracking(struct net_device *dev); -#if defined(RTL8192E)||defined(RTL8190P) static void dm_bb_initialgain_restore(struct net_device *dev); static void dm_bb_initialgain_backup(struct net_device *dev); -#endif static void dm_dig_init(struct net_device *dev); static void dm_ctrl_initgain_byrssi(struct net_device *dev); @@ -157,8 +155,6 @@ static void dm_WA_Broadcom_IOT(struct net_device *dev); static void dm_check_edca_turbo(struct net_device *dev); -#ifndef RTL8190P -#endif static void dm_check_pbc_gpio(struct net_device *dev); @@ -726,11 +722,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); -#ifdef RTL8190P - for (j = 0; j<1; j++) -#else for (j = 0; j<=30; j++) -#endif { tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; @@ -834,10 +826,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); -#ifdef RTL8190P - RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real); -#endif RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); return; @@ -874,21 +862,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else { { -#ifdef RTL8190P - { - if (priv->rfc_txpowertrackingindex > 0) - { - priv->rfc_txpowertrackingindex--; - if (priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } -#endif #ifdef RTL8192E { if (priv->rfa_txpowertrackingindex > 0) @@ -930,18 +903,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else { { -#ifdef RTL8190P - { - if (priv->rfc_txpowertrackingindex < (TxBBGainTableLength - 1)) - { - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } -#endif #ifdef RTL8192E { if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) @@ -962,10 +923,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; }else{ { -#ifdef RTL8190P - priv->CCKPresentAttentuation_difference - = priv->rfc_txpowertrackingindex - priv->rfc_txpowertracking_default; -#endif #ifdef RTL8192E priv->CCKPresentAttentuation_difference = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; @@ -1002,10 +959,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) } RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); -#ifdef RTL8190P - RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real); -#endif RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); @@ -1703,19 +1656,12 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) void dm_initialize_txpower_tracking(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8190P - dm_InitializeTXPowerTracking_TSSI(dev); -#elif defined RTL8192E if (priv->IC_Cut >= IC_VersionCut_D) dm_InitializeTXPowerTracking_TSSI(dev); else dm_InitializeTXPowerTracking_ThermalMeter(dev); -#elif defined RTL8192SE - dm_InitializeTXPowerTracking_ThermalMeter(dev); -#endif } -#if (defined RTL8192E || defined RTL8190P) static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1735,8 +1681,6 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) } } -#endif -#ifndef RTL8190P static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1786,7 +1730,6 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) } } -#endif #ifdef RTL8192SE void DM_TXPowerTracking92SDirectCall(struct net_device *dev) @@ -1800,17 +1743,10 @@ static void dm_check_txpower_tracking(struct net_device *dev) #ifdef RTL8192E struct r8192_priv *priv = rtllib_priv(dev); #endif -#ifdef RTL8190P - dm_CheckTXPowerTracking_TSSI(dev); -#elif defined RTL8192E if (priv->IC_Cut >= IC_VersionCut_D) dm_CheckTXPowerTracking_TSSI(dev); else dm_CheckTXPowerTracking_ThermalMeter(dev); -#elif defined RTL8192SE - dm_CheckTXPowerTracking_ThermalMeter(dev); -#endif - } #ifndef RTL8192SE @@ -1921,22 +1857,14 @@ extern void dm_cck_txpower_adjust( bool binch14 ) { -#ifndef RTL8190P struct r8192_priv *priv = rtllib_priv(dev); -#endif -#ifdef RTL8190P - dm_CCKTxPowerAdjust_TSSI(dev, binch14); -#else if (priv->IC_Cut >= IC_VersionCut_D) dm_CCKTxPowerAdjust_TSSI(dev, binch14); else dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); -#endif } #endif - -#if defined(RTL8192E)||defined(RTL8190P) static void dm_txpower_reset_recovery( struct net_device *dev ) @@ -2052,7 +1980,6 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } -#endif extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, u32 dm_value) @@ -2497,16 +2424,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - #endif - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40); - */ - - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); @@ -2554,16 +2472,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - #endif - /* - else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - */ - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); @@ -2602,16 +2511,7 @@ static void dm_ctrl_initgain_byrssi_highpwr( if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - #endif - - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); - */ - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); @@ -2629,15 +2529,7 @@ static void dm_ctrl_initgain_byrssi_highpwr( { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - #endif - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - */ - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); @@ -2860,14 +2752,7 @@ static void dm_pd_th( { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - #endif - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x40); - */ } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); @@ -2876,14 +2761,7 @@ static void dm_pd_th( { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - #endif - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - */ } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); @@ -2892,14 +2770,7 @@ static void dm_pd_th( { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); - #else write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - #endif - /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P) - write_nic_byte(dev, rOFDM0_RxDetector1, 0x41); - */ } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); @@ -4071,20 +3942,12 @@ extern void dm_fsync_timer_callback(unsigned long data) priv->bswitch_fsync = !priv->bswitch_fsync; if (priv->bswitch_fsync) { - #ifdef RTL8190P - write_nic_byte(dev,0xC36, 0x00); -#elif defined RTL8192E write_nic_byte(dev,0xC36, 0x1c); - #endif write_nic_byte(dev, 0xC3e, 0x90); } else { - #ifdef RTL8190P - write_nic_byte(dev, 0xC36, 0x40); - #else write_nic_byte(dev, 0xC36, 0x5c); - #endif write_nic_byte(dev, 0xC3e, 0x96); } } @@ -4093,11 +3956,7 @@ extern void dm_fsync_timer_callback(unsigned long data) if (priv->bswitch_fsync) { priv->bswitch_fsync = false; - #ifdef RTL8190P - write_nic_byte(dev, 0xC36, 0x40); -#elif defined RTL8192E write_nic_byte(dev, 0xC36, 0x5c); - #endif write_nic_byte(dev, 0xC3e, 0x96); } } @@ -4119,19 +3978,11 @@ extern void dm_fsync_timer_callback(unsigned long data) if (priv->bswitch_fsync) { priv->bswitch_fsync = false; - #ifdef RTL8190P - write_nic_byte(dev, 0xC36, 0x40); -#elif defined RTL8192E write_nic_byte(dev, 0xC36, 0x5c); - #endif write_nic_byte(dev, 0xC3e, 0x96); } priv->ContiuneDiffCount = 0; - #ifdef RTL8190P - write_nic_dword(dev, rOFDM0_RxDetector2, 0x164052cd); -#elif defined RTL8192E write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); - #endif } RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); @@ -4168,11 +4019,7 @@ static void dm_EndSWFsync(struct net_device *dev) { priv->bswitch_fsync = false; - #ifdef RTL8190P - write_nic_byte(dev, 0xC36, 0x40); -#elif defined RTL8192E write_nic_byte(dev, 0xC36, 0x5c); -#endif write_nic_byte(dev, 0xC3e, 0x96); } @@ -4279,11 +4126,7 @@ void dm_check_fsync(struct net_device *dev) { if (reg_c38_State != RegC38_Fsync_AP_BCM) { - #ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector3, 0x15); - #else write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); - #endif reg_c38_State = RegC38_Fsync_AP_BCM; } @@ -4307,11 +4150,7 @@ void dm_check_fsync(struct net_device *dev) if (priv->rtllib->state == RTLLIB_LINKED) { if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { if (reg_c38_State != RegC38_NonFsync_Other_AP) { -#ifdef RTL8190P - write_nic_byte(dev, rOFDM0_RxDetector3, 0x10); -#else write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); -#endif reg_c38_State = RegC38_NonFsync_Other_AP; } diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 1af0dc3b1cc..967a5e426e2 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -40,11 +40,7 @@ #define DM_DIG_BACKOFF 12 -#ifdef RTL8192SE -#define DM_DIG_MAX 0x3e -#elif defined RTL8190P || defined RTL8192E #define DM_DIG_MAX 0x36 -#endif #define DM_DIG_MIN 0x1c #define DM_DIG_MIN_Netcore 0x12 @@ -59,11 +55,7 @@ #define RateAdaptiveTH_Low_40M 10 #define VeryLowRSSI 15 -#ifdef RTL8192SE -#define CTSToSelfTHVal 30 -#elif defined RTL8190P || defined RTL8192E #define CTSToSelfTHVal 35 -#endif #define WAIotTHVal 25 diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c2eae51ec0d..ad1e8106d6a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -118,7 +118,6 @@ static inline void *netdev_priv_rsl(struct net_device *dev) /* added for rtl819x tx procedure */ #define MAX_QUEUE_SIZE 0x10 -#if defined(RTL8192SU) || defined(RTL8190P) ||defined(RTL8192U) ||defined(RTL8192E) #define BK_QUEUE 0 #define BE_QUEUE 1 #define VI_QUEUE 2 @@ -128,18 +127,6 @@ static inline void *netdev_priv_rsl(struct net_device *dev) #define MGNT_QUEUE 6 #define HIGH_QUEUE 7 #define BEACON_QUEUE 8 -#elif defined(RTL8192SE) -#define BK_QUEUE 0 -#define BE_QUEUE 1 -#define VI_QUEUE 2 -#define VO_QUEUE 3 -#define BEACON_QUEUE 4 -#define TXCMD_QUEUE 5 -#define MGNT_QUEUE 6 -#define HIGH_QUEUE 7 -#define HCCA_QUEUE 8 - -#endif #define LOW_QUEUE BE_QUEUE #define NORMAL_QUEUE MGNT_QUEUE diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 1b2e6c44cd1..dadb5430bfa 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -4051,9 +4051,7 @@ rtllib_MgntDisconnect( { if (rtllib->ps != RTLLIB_PS_DISABLED) { -#ifndef RTL8190P rtllib->sta_wake_up(rtllib->dev); -#endif } #ifdef TO_DO From 1e71e6d0cf764841cdf60dec4a40849ff41be75c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 11 Jul 2011 22:25:07 -0500 Subject: [PATCH 0283/1519] staging: rtl8192e: Remove dead code associated with RTL8192SE The vendor code will generate several different drivers. As the RTL8192SE is covered by a mac80211 driver in mainline, eliminate that code heere. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_rtl8256.c | 10 - drivers/staging/rtl8192e/r8192E_dev.c | 83 --- drivers/staging/rtl8192e/r8192E_phy.c | 2 - drivers/staging/rtl8192e/rtl819x_HTProc.c | 184 ------ drivers/staging/rtl8192e/rtl_core.c | 183 ------ drivers/staging/rtl8192e/rtl_debug.c | 30 - drivers/staging/rtl8192e/rtl_debug.h | 3 - drivers/staging/rtl8192e/rtl_dm.c | 640 +------------------ drivers/staging/rtl8192e/rtl_dm.h | 8 - drivers/staging/rtl8192e/rtl_ps.h | 2 - drivers/staging/rtl8192e/rtl_wx.c | 41 +- drivers/staging/rtl8192e/rtllib.h | 6 - drivers/staging/rtl8192e/rtllib_rx.c | 314 --------- drivers/staging/rtl8192e/rtllib_softmac.c | 53 -- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 15 - drivers/staging/rtl8192e/rtllib_tx.c | 107 ---- 16 files changed, 4 insertions(+), 1677 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index ac06d41ab65..d4ba36e8ac2 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -18,13 +18,8 @@ ******************************************************************************/ #include "rtl_core.h" -#ifdef RTL8192SE -#include "rtl8192s/r8192S_phyreg.h" -#include "rtl8192s/r8192S_phy.h" -#else #include "r8192E_phyreg.h" #include "r8192E_phy.h" -#endif #include "r8190P_rtl8256.h" void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) @@ -188,7 +183,6 @@ phy_RF8256_Config_ParaFile_Fail: return false; } -#ifndef RTL8192SE void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) { u32 TxAGC=0; @@ -260,7 +254,3 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) #endif return; } - - - -#endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 16f2cef29b2..7ec2fd97ebe 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1436,61 +1436,6 @@ rtl8192_signal_scale_mapping(struct r8192_priv * priv, { long retsig; -#if defined RTL8192SE || defined RTL8192CE - if (priv->CustomerID == RT_CID_819x_Lenovo) - { - return currsig; - } - else if (priv->CustomerID == RT_CID_819x_Netcore) - { - if (currsig >= 31 && currsig <= 100) - { - retsig = 100; - } - else if (currsig >= 21 && currsig <= 30) - { - retsig = 90 + ((currsig - 20) / 1); - } - else if (currsig >= 11 && currsig <= 20) - { - retsig = 80 + ((currsig - 10) / 1); - } - else if (currsig >= 7 && currsig <= 10) - { - retsig = 69 + (currsig - 7); - } - else if (currsig == 6) - { - retsig = 54; - } - else if (currsig == 5) - { - retsig = 45; - } - else if (currsig == 4) - { - retsig = 36; - } - else if (currsig == 3) - { - retsig = 27; - } - else if (currsig == 2) - { - retsig = 18; - } - else if (currsig == 1) - { - retsig = 9; - } - else - { - retsig = currsig; - } - return retsig; - } -#endif - if (currsig >= 61 && currsig <= 100) { retsig = 90 + ((currsig - 60) / 4); @@ -2257,10 +2202,6 @@ void rtl8192_EnableInterrupt(struct net_device *dev) write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); #endif -#ifdef RTL8192SE - write_nic_dword(dev,INTA_MASK+4, priv->irq_mask[1]&0x3F); -#endif - } void rtl8192_DisableInterrupt(struct net_device *dev) @@ -2273,9 +2214,6 @@ void rtl8192_DisableInterrupt(struct net_device *dev) write_nic_dword(dev,INTA_MASK,0); #endif -#ifdef RTL8192SE - write_nic_dword(dev,INTA_MASK + 4,0); -#endif priv->irq_enabled = 0; } @@ -2290,10 +2228,6 @@ void rtl8192_ClearInterrupt(struct net_device *dev) write_nic_dword(dev, ISR, tmp); #endif -#ifdef RTL8192SE - tmp = read_nic_dword(dev, ISR+4); - write_nic_dword(dev, ISR+4, tmp); -#endif } @@ -2334,17 +2268,8 @@ void rtl8192_beacon_disable(struct net_device *dev) void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) { -#ifdef RTL8192SE - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - *p_inta = read_nic_dword(dev, ISR) & priv->irq_mask[0]; -#else *p_inta = read_nic_dword(dev, ISR) ; -#endif write_nic_dword(dev,ISR,*p_inta); -#ifdef RTL8192SE - *p_intb = read_nic_dword(dev, ISR+4); - write_nic_dword(dev, ISR+4, *p_intb); -#endif } bool rtl8192_HalRxCheckStuck(struct net_device *dev) @@ -2438,9 +2363,6 @@ bool rtl8192_HalTxCheckStuck(struct net_device *dev) bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) { -#ifdef RTL8192SE - return true; -#else struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; if (ieee->rtllib_ap_sec_type && @@ -2449,14 +2371,10 @@ bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) } else { return true; } -#endif } bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) { -#ifdef RTL8192SE - return false; -#else bool Reval; struct r8192_priv* priv = rtllib_priv(dev); struct rtllib_device* ieee = priv->rtllib; @@ -2467,7 +2385,6 @@ bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) Reval = false; return Reval; -#endif } u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index ff88330a267..defd6976677 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1444,7 +1444,6 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) } #endif -#ifndef RTL8192SE bool SetRFPowerState8190( struct net_device* dev, @@ -1695,7 +1694,6 @@ SetRFPowerState( return bResult; } -#endif extern void PHY_ScanOperationBackup8192( diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index a212a972ec6..62dd0976e44 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -436,14 +436,6 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) (pHTInfo->IOTPeer != HT_IOT_PEER_RALINK) ) retValue = true; } -#elif defined(RTL8192SE) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) { - if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK){ - retValue = true; - } - } #endif return retValue; } @@ -519,11 +511,7 @@ HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *network) { u8 retValue = 0; -#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) - if ((ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) ||(ieee->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ) -#else if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) -#endif { retValue = 1; } @@ -534,17 +522,6 @@ u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *n u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, struct rtllib_network *network) { u8 retValue = 0; -#if defined(RTL8192SE) || defined(RTL8192SU) - if (ieee->pHTInfo->bCurrentHTSupport) - { - if ((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&& - (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE)) - { - if ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0) - retValue = 1; - } - } -#endif return retValue; } @@ -570,12 +547,6 @@ u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) { u8 retValue = 0; -#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) - { - - - } -#endif return retValue; @@ -601,16 +572,6 @@ u8 pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) return 1; - } -#elif defined RTL8192SE - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if (ieee->rtllib_ap_sec_type != NULL) - if (ieee->rtllib_ap_sec_type(ieee) == SEC_ALG_CCMP) - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK){ - return 1; - } - } #endif return retValue; @@ -634,9 +595,6 @@ u8 HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *network) { u8 retValue = 0; -#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -#endif #ifdef RTL8192SU if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK || @@ -645,12 +603,6 @@ HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *netwo { retValue = 1; } -#elif defined RTL8192SE || defined RTL8192CE - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK || - pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ) - { - retValue = 1; - } #endif return retValue; } @@ -675,19 +627,6 @@ HTIOTActIsDisableTx40MHz(struct rtllib_device* ieee,struct rtllib_network *netwo { u8 retValue = 0; -#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP104 == ieee->group_key_type) || - (KEY_TYPE_WEP40 == ieee->group_key_type) || - (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) - { - if ((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT)) - retValue = 1; - } -#endif - return retValue; } @@ -696,19 +635,6 @@ HTIOTActIsTxNoAggregation(struct rtllib_device* ieee,struct rtllib_network *netw { u8 retValue = 0; -#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP104 == ieee->group_key_type) || - (KEY_TYPE_WEP40 == ieee->group_key_type) || - (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) - { - if (pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) - retValue = 1; - } -#endif - return retValue; } @@ -718,19 +644,6 @@ HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network { u8 retValue = 0; -#if (defined RTL8192SU || defined RTL8192SE || defined RTL8192CE) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if ( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP40 == ieee->pairwise_key_type) || - (KEY_TYPE_WEP104 == ieee->group_key_type) || - (KEY_TYPE_WEP40 == ieee->group_key_type) || - (KEY_TYPE_TKIP == ieee->pairwise_key_type) ) - { - if ((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT)) - retValue = 1; - } -#endif - return retValue; } @@ -753,15 +666,6 @@ bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network * bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device* ieee,struct rtllib_network *network) { bool retValue = false; -#if defined(RTL8192SE) || defined(RTL8192SU) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if (ieee->VersionID<2) - if (pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - return true; - - } -#endif return retValue; } @@ -769,14 +673,6 @@ bool HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network *network) { bool retValue = false; -#if defined(RTL8192SE) || defined(RTL8192SU) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - return true; - - } -#endif return retValue; } @@ -826,9 +722,6 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* pCapELE->ShortGI40Mhz = 1; pCapELE->TxSTBC = 1; -#if defined RTL8192SE || defined RTL8192CE - pCapELE->TxSTBC = 0; -#endif pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; @@ -1131,18 +1024,6 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; else pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; -#if (defined RTL8192SE || defined RTL8192SU || defined RTL8192CE) - if (ieee->SetHwRegHandler != NULL) { - ieee->SetHwRegHandler( ieee->dev, HW_VAR_SHORTGI_DENSITY, (u8*)(&ieee->MaxMssDensity)); - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); - } -#elif defined RTL8192CE - if (ieee->SetHwRegHandler != NULL) { - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_FACTOR, &pHTInfo->CurrentAMPDUFactor); - ieee->SetHwRegHandler(ieee->dev, HW_VAR_AMPDU_MIN_SPACE, &pHTInfo->CurrentMPDUDensity); - } -#endif if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; @@ -1290,71 +1171,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net bIOTAction = HTIOTActIsCCDFsync(ieee); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; -#if defined(RTL8192SU) || defined(RTL8192SE) || defined RTL8192CE - bIOTAction = HTIOTActIsForcedCTS2Self(ieee,pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - - - bIOTAction = HTIOTActIsEnableBETxOPLimit(ieee); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_ENABLE_BE_TXOP; - -#if defined(RTL8192SU) - bIOTAction = HTIOCActRejcectADDBARequest(pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ; -#endif - - bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT; - - bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX; - -#if defined(RTL8192SU) - bIOTAction = HTIOCActIsDisableCckRate(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_CCK_RATE; -#endif - bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI; - - bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER; - - - bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K; - -#if defined(RTL8192SU) - bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION; - - bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ; - - bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS; -#endif - - bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS; - - bIOTAction = HTIOTActIsNullDataPowerSaving(ieee, pNetwork); - if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_NULL_DATA_POWER_SAVING; -#endif - } else { pHTInfo->bCurrentHTSupport = false; pHTInfo->bCurrentRT2RTAggregation = false; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 406986c8beb..372f946de70 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -329,9 +329,7 @@ void write_nic_byte(struct net_device *dev, int x,u8 y) { writeb(y,(u8*)dev->mem_start +x); -#if !(defined RTL8192SE || defined RTL8192CE) udelay(20); -#endif #if defined RTL8192CE read_nic_byte(dev, x); @@ -342,9 +340,7 @@ void write_nic_dword(struct net_device *dev, int x,u32 y) { writel(y,(u8*)dev->mem_start +x); -#if !(defined RTL8192SE || defined RTL8192CE) udelay(20); -#endif #if defined RTL8192CE read_nic_dword(dev, x); @@ -355,9 +351,7 @@ void write_nic_word(struct net_device *dev, int x,u16 y) { writew(y,(u8*)dev->mem_start +x); -#if !(defined RTL8192SE || defined RTL8192CE) udelay(20); -#endif #if defined RTL8192CE read_nic_word(dev, x); @@ -969,19 +963,6 @@ void rtl8192_refresh_supportrate(struct r8192_priv* priv) } #endif -#ifdef RTL8192SE - if (priv->rf_type == RF_1T1R) { - ieee->Regdot11HTOperationalRateSet[1] = 0; - } - if (priv->rf_type == RF_1T1R || priv->rf_type == RF_1T2R) - { - ieee->Regdot11TxHTOperationalRateSet[1] = 0; - } - - if (priv->rtllib->b1SSSupport == true) { - ieee->Regdot11HTOperationalRateSet[1] = 0; - } -#endif } else { memset(ieee->Regdot11HTOperationalRateSet, 0, 16); } @@ -1077,10 +1058,6 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) RT_TRACE(COMP_INIT, "start adapter finished\n"); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; -#if defined RTL8192SE || defined RTL8192CE - if (priv->rtllib->eRFPowerState!=eRfOn) - MgntActSet_RF_State(dev, eRfOn, priv->rtllib->RfOffReason,true); -#endif #ifdef ENABLE_GPIO_RADIO_CTL if (priv->polling_timer_on == 0){ @@ -1226,14 +1203,10 @@ static void rtl8192_init_priv_handler(struct net_device* dev) static void rtl8192_init_priv_constant(struct net_device* dev) { -#if defined RTL8192SE || defined RTL8192CE || defined RTL8192E struct r8192_priv *priv = rtllib_priv(dev); PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); -#endif -#if defined RTL8192SE || defined RTL8192CE || defined RTL8192E pPSC->RegMaxLPSAwakeIntvl = 5; -#endif #ifdef RTL8192CE priv->bWEPinNmodeFromReg = 0; @@ -1251,17 +1224,6 @@ static void rtl8192_init_priv_constant(struct net_device* dev) priv->RegSupportPciASPM = 1; -#elif defined RTL8192SE - priv->RegPciASPM = 2; - - priv->RegDevicePciASPMSetting = 0x03; - - priv->RegHostPciASPMSetting = 0x02; - - priv->RegHwSwRfOffD3 = 2; - - priv->RegSupportPciASPM = 2; - #elif defined RTL8192E priv->RegPciASPM = 2; @@ -1359,15 +1321,6 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->ccktxpower_adjustcnt_ch14 = 0; priv->ccktxpower_adjustcnt_not_ch14 = 0; -#if defined RTL8192SE - for (i = 0; irtllib->peer_assoc_list[i]=NULL; - priv->rtllib->AvailableAIDTable[i] = 99; - } - priv->RATRTableBitmap = 0; - priv->rtllib->amsdu_in_process = 0; -#endif - priv->rtllib->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->active_scan = 1; @@ -1524,9 +1477,6 @@ short rtl8192_init(struct net_device *dev) init_hal_dm(dev); -#if defined RTL8192SE || defined RTL8192CE - InitSwLeds(dev); -#endif init_timer(&priv->watch_dog_timer); setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback, @@ -1729,15 +1679,6 @@ rtl819x_TxCheckStuck(struct net_device *dev) bCheckFwTxCnt = true; if (tcb_desc->nStuckCount > 1) printk("%s: QueueID=%d tcb_desc->nStuckCount=%d\n",__func__,QueueID,tcb_desc->nStuckCount); -#if defined RTL8192SE || defined RTL8192CE - if (tcb_desc->nStuckCount > ResetThreshold) - { - RT_TRACE( COMP_RESET, "TxCheckStuck(): Need silent reset because nStuckCount > ResetThreshold.\n" ); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - return RESET_TYPE_SILENT; - } - bCheckFwTxCnt = false; - #endif } } spin_unlock_irqrestore(&priv->irq_th_lock,flags); @@ -1870,10 +1811,7 @@ RESET_START: rtllib_softmac_stop_protocol(priv->rtllib, 0 ,true); } -#if !(defined RTL8192SE || defined RTL8192CE) dm_backup_dynamic_mechanism_state(dev); -#endif - up(&priv->wx_sem); RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); @@ -1920,9 +1858,7 @@ RESET_START: } CamRestoreAllEntry(dev); -#if !(defined RTL8192SE || defined RTL8192CE) dm_restore_dynamic_mechanism_state(dev); -#endif END: priv->ResetProgress = RESET_TYPE_NORESET; priv->reset_count++; @@ -1930,9 +1866,7 @@ END: priv->bForcedSilentReset =false; priv->bResetInProgress = false; -#if !(defined RTL8192SE || defined RTL8192CE) write_nic_byte(dev, UFWP, 1); -#endif RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); } } @@ -2048,11 +1982,6 @@ void rtl819x_watchdog_wqcallback(void *data) } { -#if defined RTL8192SE - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - IbssAgeFunction(ieee); -#endif - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { u32 TotalRxBcnNum = 0; @@ -2341,11 +2270,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) priv->rtllib->bAwakePktSent = true; -#if defined RTL8192SE || defined RTL8192CE - fwinfo_size = 0; -#else fwinfo_size = sizeof(TX_FWINFO_8190PCI); -#endif header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); fc = header->frame_ctl; @@ -2760,82 +2685,6 @@ done: void rtl8192_rx_cmd(struct net_device *dev) { -#ifdef RTL8192SE - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - unsigned int count = priv->rxringcount; - int rx_queue_idx = RX_CMD_QUEUE; - - struct rtllib_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - .freq = RTLLIB_24GHZ_BAND, - }; - stats.nic_type = NIC_8192E; - - while (count--) { - rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - - if (pdesc->OWN){ - return; - } else { - struct sk_buff *new_skb = NULL; - - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); - - skb_put(skb, pdesc->Length); - - if (pdesc->MACID == 0x1e) { - - pdesc->Length = pdesc->Length - 32; - pdesc->DrvInfoSize = 4; - printk(">>>>%s()CMD PKT RX, beacon_len:%d payload_len:%d\n",__func__, pdesc->Length,skb->len); - - - priv->ops->rx_query_status_descriptor(dev, &stats, pdesc, skb); - skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); - } - - skb_trim(skb, skb->len - 4/*sCrcLng*/); - - if (pdesc->MACID == 0x1e){ - if (!rtllib_rx(priv->rtllib, skb, &stats)){ - dev_kfree_skb_any(skb); - } - }else{ - if (priv->ops->rx_command_packet_handler != NULL) - priv->ops->rx_command_packet_handler(dev, skb, pdesc); - dev_kfree_skb_any(skb); - } - - - new_skb = dev_alloc_skb(priv->rxbuffersize); - if (unlikely(!new_skb)) - { - printk("==========>can't alloc skb for rx\n"); - goto done; - } - skb=new_skb; - skb->dev = dev; - - priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); - - } -done: - pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); - pdesc->OWN = 1; - pdesc->Length = priv->rxbuffersize; - if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) - pdesc->EOR = 1; - priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; - } -#endif } @@ -3220,22 +3069,6 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) goto done; } -#if defined RTL8192SE - if (intb & IMR_TBDOK){ - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); - priv->stats.txbeaconokint++; - priv->bIbssCoordinator = true; - } - - if (intb & IMR_TBDER){ - RT_TRACE(COMP_INTR, "beacon error interrupt!\n"); - priv->stats.txbeaconerr++; - priv->bIbssCoordinator = false; - } - - if ((intb & IMR_TBDOK) ||(intb & IMR_TBDER)) - FairBeacon(dev); -#else if (inta & IMR_TBDOK){ RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconokint++; @@ -3245,7 +3078,6 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconerr++; } -#endif if (inta & IMR_BDOK) { RT_TRACE(COMP_INTR, "beacon interrupt!\n"); @@ -3279,11 +3111,7 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) rtl8192_tx_isr(dev,HIGH_QUEUE); } -#ifdef RTL8192SE - if ((inta & IMR_ROK) || (inta & IMR_RXCMDOK)) -#else if (inta & IMR_ROK) -#endif { priv->stats.rxint++; priv->InterruptLog.nIMR_ROK++; @@ -3459,13 +3287,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->mem_start = ioaddr; dev->mem_end = ioaddr + pci_resource_len(pdev, 0); -#if defined RTL8192SE || defined RTL8192CE - pci_write_config_byte(pdev, 0x81,0); - pci_write_config_byte(pdev,0x44,0); - pci_write_config_byte(pdev,0x04,0x06); - pci_write_config_byte(pdev,0x04,0x07); -#endif - pci_read_config_byte(pdev, 0x08, &revision_id); /* If the revisionid is 0x10, the device uses rtl8192se. */ if (pdev->device == 0x8192 && revision_id == 0x10) @@ -3625,10 +3446,6 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) } pci_disable_device(pdev); -#ifdef RTL8192SE - pci_write_config_byte(pdev, 0x81,1); - pci_write_config_byte(pdev,0x44,3); -#endif RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index cec8998abfa..7381fd6a3bc 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -183,21 +183,6 @@ static ssize_t rtl_dbgfs_register_read(struct file *file, if (!priv->debug->hw_type) { page_no = (priv->debug->hw_offset > 0x0f)? 0x0f: priv->debug->hw_offset; -#ifdef RTL8192SE - if (page_no >= 0x08 ) { - len += snprintf(buf + len, count - len, - "\n#################### BB page- %x##################\n ", page_no); - for (n=0;n<=max;) - { - len += snprintf(buf + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) - len += snprintf(buf + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page_no << 8|n), - bMaskDWord)); - } - - } else -#endif { len += snprintf(buf + len,count - len, "\n#################### MAC page- %x##################\n ", page_no); @@ -347,21 +332,6 @@ static int proc_get_registers_0(char *page, char **start, int max=0xff; page0 = 0x000; -#ifdef RTL8192SE - /* This dump the current register page */ - if (!IS_BB_REG_OFFSET_92S(page0)){ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - }else -#endif { len += snprintf(page + len, count - len, "\n####################page %x##################\n ", (page0>>8)); diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 8d85979d313..20127926662 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -277,9 +277,6 @@ void print_buffer(u32 *buffer, int len); void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); -#ifdef RTL8192SE -void rtl8192se_dump_tx_desc(struct _tx_desc_8192se *pDesc); -#endif #ifdef RTL8192CE void rtl8192ce_dump_tx_desc(struct _TX_DESC_8192CE *pDesc); #endif diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index c494505d91c..b0442e49517 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -103,19 +103,8 @@ extern void dm_check_fsync(struct net_device *dev); extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); -#if (defined RTL8192E || defined RTL8192SE) extern void dm_CheckRfCtrlGPIO(void *data); -#endif -#ifdef RTL8192SE -extern void DM_TXPowerTracking92SDirectCall(struct net_device *dev); -static void dm_CtrlInitGainByTwoPort(struct net_device *dev); -static void dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(struct net_device *dev); -static void dm_initial_gain_STABeforeConnect(struct net_device *dev); - -void dm_InitRateAdaptiveMask(struct net_device *dev); -void Adhoc_InitRateAdaptive(struct net_device *dev,struct sta_info *pEntry); -#endif /*--------------------Define export function prototype-----------------------*/ @@ -149,9 +138,6 @@ static void dm_cs_ratio(struct net_device *dev); static void dm_init_ctstoself(struct net_device *dev); static void dm_Init_WA_Broadcom_IOT(struct net_device *dev); -#ifdef RTL8192SE -static void dm_WA_Broadcom_IOT(struct net_device *dev); -#endif static void dm_check_edca_turbo(struct net_device *dev); @@ -177,9 +163,6 @@ static void dm_dynamic_txpower(struct net_device *dev); static void dm_send_rssi_tofw(struct net_device *dev); static void dm_ctstoself(struct net_device *dev); -#if defined RTL8192SE -static void dm_RefreshRateAdaptiveMask(struct net_device *dev); -#endif /*---------------------------Define function prototype------------------------*/ extern void @@ -192,12 +175,7 @@ init_hal_dm(struct net_device *dev) dm_init_dynamic_txpower(dev); -#ifdef RTL8192SE - if (IS_HARDWARE_TYPE_8192SE(dev)) - dm_InitRateAdaptiveMask(dev); - else -#endif - init_rate_adaptive(dev); + init_rate_adaptive(dev); dm_dig_init(dev); dm_init_edca_turbo(dev); @@ -208,10 +186,7 @@ init_hal_dm(struct net_device *dev) if (IS_HARDWARE_TYPE_8192SE(dev)) dm_Init_WA_Broadcom_IOT(dev); -#if (defined RTL8192E || defined RTL8192SE) INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO,dev); -#endif - } extern void deinit_hal_dm(struct net_device *dev) @@ -272,13 +247,6 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_check_txrateandretrycount(dev); dm_check_edca_turbo(dev); - if (IS_HARDWARE_TYPE_8192SE(dev)){ -#ifdef RTL8192SE - dm_RefreshRateAdaptiveMask(dev); - dm_WA_Broadcom_IOT(dev); - return; -#endif - } dm_check_rate_adaptive(dev); dm_dynamic_txpower(dev); dm_check_txpower_tracking(dev); @@ -693,7 +661,6 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { #define Tssi_Report_Value2 0x13e #define FW_Busy_Flag 0x13f -#ifndef RTL8192SE static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -984,7 +951,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) priv->rtllib->bdynamic_txpower_enable = true; write_nic_byte(dev, Pw_Track_Flag, 0); } -#endif #ifdef RTL8192E static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) @@ -1093,38 +1059,6 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) } priv->txpower_count = 0; } -#elif defined (RTL8192SE) -static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 ThermalValue=0; - u32 FwCmdVal=0; - - priv->btxpower_trackingInit = true; - - - ThermalValue = (u8)rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, RF_T_METER, 0x1f); - RT_TRACE(COMP_POWER_TRACKING, "Readback Thermal Meter = 0x%x\n", ThermalValue); - printk("%s()Readback Thermal Meter = 0x%x\n", __func__,ThermalValue); - if (ThermalValue) - { - priv->ThermalValue = ThermalValue; - if (priv->pFirmware->FirmwareVersion >= 0x35) - { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_TXPWR_TRACK_THERMAL); - } - else - { - FwCmdVal = (FW_TXPWR_TRACK_THERMAL| - (priv->ThermalMeter[0]<<8)|(ThermalValue<<16)); - RT_TRACE(COMP_POWER_TRACKING, "Write to FW Thermal Val = 0x%x\n", FwCmdVal); - write_nic_dword(dev, WFM5, FwCmdVal); - ChkFwCmdIoDone(dev); - } - } - - priv->txpower_count = 0; -} #endif void dm_txpower_trackingcallback(void *data) @@ -1138,7 +1072,6 @@ void dm_txpower_trackingcallback(void *data) dm_TXPowerTrackingCallback_ThermalMeter(dev); } -#ifndef RTL8192SE static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) { @@ -1638,7 +1571,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) priv->btxpower_trackingInit = false; } -#endif + static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1702,14 +1635,6 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) if (!TM_Trigger) { -#ifdef RTL8192SE - if (IS_HARDWARE_TYPE_8192SE(dev)) - { - rtl8192_phy_SetRFReg(dev, RF90_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60); - RT_TRACE(COMP_POWER_TRACKING, "Trigger 92S Thermal Meter!!\n"); - } - else -#endif { rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); @@ -1720,36 +1645,23 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) return; } else { printk("===============>Schedule TxPowerTrackingWorkItem\n"); -#ifdef RTL8192SE - DM_TXPowerTracking92SDirectCall(dev); -#else queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); -#endif TM_Trigger = 0; } } -#ifdef RTL8192SE -void DM_TXPowerTracking92SDirectCall(struct net_device *dev) -{ - dm_TXPowerTrackingCallback_ThermalMeter(dev); - } -#endif - static void dm_check_txpower_tracking(struct net_device *dev) { -#ifdef RTL8192E struct r8192_priv *priv = rtllib_priv(dev); -#endif + if (priv->IC_Cut >= IC_VersionCut_D) dm_CheckTXPowerTracking_TSSI(dev); else dm_CheckTXPowerTracking_ThermalMeter(dev); } -#ifndef RTL8192SE static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) { u32 TempVal; @@ -1793,7 +1705,6 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) } -#endif #ifdef RTL8192E static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14) { @@ -1851,7 +1762,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH } #endif -#ifndef RTL8192SE extern void dm_cck_txpower_adjust( struct net_device *dev, bool binch14 @@ -1863,7 +1773,6 @@ extern void dm_cck_txpower_adjust( else dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); } -#endif static void dm_txpower_reset_recovery( struct net_device *dev @@ -1984,14 +1893,6 @@ extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, u32 dm_value) { -#ifdef RTL8192SE - struct r8192_priv *priv = rtllib_priv(dev); - if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - priv->MidHighPwrTHR_L2 = (u8)dm_value; - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW) - priv->MidHighPwrTHR_L1 = (u8)dm_value; - return; -#endif if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; @@ -2157,14 +2058,7 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.dig_enable_flag = true; dm_digtable.Backoff_Enable_Flag = true; -#ifdef RTL8192SE - if ((priv->DM_Type == DM_Type_ByDriver) && (priv->pFirmware->FirmwareVersion >= 0x3c)) - dm_digtable.dig_algorithm = DIG_ALGO_BY_TOW_PORT; - else - dm_digtable.dig_algorithm = DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM; -#else dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; -#endif dm_digtable.Dig_TwoPort_Algorithm = DIG_TWO_PORT_ALGO_RSSI; dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; @@ -2228,19 +2122,6 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail , FalseAlmCnt->Cnt_all); } -#ifdef RTL8192SE -static void dm_CtrlInitGainAPByFalseAlarm(struct net_device *dev) -{ - static u8 binitialized = false; - - { - binitialized = false; - dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; - return; - } -} -#endif - static void dm_ctrl_initgain_byrssi(struct net_device *dev) { @@ -2251,50 +2132,10 @@ static void dm_ctrl_initgain_byrssi(struct net_device *dev) dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev); else if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI) dm_ctrl_initgain_byrssi_by_driverrssi(dev); -#ifdef RTL8192SE - else if (dm_digtable.dig_algorithm == DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM) - dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(dev); - else if (dm_digtable.dig_algorithm == DIG_ALGO_BY_TOW_PORT) - dm_CtrlInitGainByTwoPort(dev); -#endif else return; } -#ifdef RTL8192SE -static void dm_CtrlInitGainByTwoPort(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (rtllib_act_scanning(priv->rtllib,true) == true) - return; - - if ((priv->rtllib->state > RTLLIB_NOLINK) && (priv->rtllib->state < RTLLIB_LINKED)) - dm_digtable.CurSTAConnectState = DIG_STA_BEFORE_CONNECT; - else if ((priv->rtllib->state == RTLLIB_LINKED) ||(priv->rtllib->state == RTLLIB_LINKED_SCANNING)) - dm_digtable.CurSTAConnectState = DIG_STA_CONNECT; - else - dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; - - dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; - - if (dm_digtable.CurSTAConnectState != DIG_STA_DISCONNECT) - { - if (dm_digtable.Dig_TwoPort_Algorithm == DIG_TWO_PORT_ALGO_FALSE_ALARM) - { - dm_digtable.Dig_TwoPort_Algorithm = DIG_TWO_PORT_ALGO_RSSI; - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_MODE_SS); - } - } - - dm_FalseAlarmCounterStatistics(dev); - dm_initial_gain_STABeforeConnect(dev); - dm_CtrlInitGainAPByFalseAlarm(dev); - - dm_digtable.PreSTAConnectState = dm_digtable.CurSTAConnectState; -} -#endif - /*----------------------------------------------------------------------------- * Function: dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm() * @@ -2313,30 +2154,6 @@ static void dm_CtrlInitGainByTwoPort(struct net_device *dev) * *---------------------------------------------------------------------------*/ -#ifdef RTL8192SE -static void dm_CtrlInitGainBeforeConnectByRssiAndFalseAlarm(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (rtllib_act_scanning(priv->rtllib,true) == true) - return; - - if ((priv->rtllib->state > RTLLIB_NOLINK) && (priv->rtllib->state < RTLLIB_LINKED)) - dm_digtable.CurSTAConnectState = DIG_STA_BEFORE_CONNECT; - else if ((priv->rtllib->state == RTLLIB_LINKED) ||(priv->rtllib->state == RTLLIB_LINKED_SCANNING)) - dm_digtable.CurSTAConnectState = DIG_STA_CONNECT; - else - dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; - - if (dm_digtable.dbg_mode == DM_DBG_OFF) - dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; - - dm_FalseAlarmCounterStatistics(dev); - dm_initial_gain_STABeforeConnect(dev); - dm_digtable.PreSTAConnectState = dm_digtable.CurSTAConnectState; - -} -#endif static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev) { @@ -3024,81 +2841,6 @@ dm_Init_WA_Broadcom_IOT(struct net_device * dev) pHTInfo->WAIotTH = WAIotTHVal; } -#ifdef RTL8192SE -static void -dm_WA_Broadcom_IOT(struct net_device * dev) -{ - struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; - u8 update=0; - static enum rtllib_state connectState = RTLLIB_NOLINK; - - if ( (pHTInfo->bWAIotBroadcom != true) || - (priv->rtllib->mode == WIRELESS_MODE_B) || - (pHTInfo->bCurBW40MHz)) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; - update = 1; - printk(" dm_WA_Broadcom_IOT(), disable HT_IOT_ACT_WA_IOT_Broadcom\n"); - } - else - return; - } - - if (connectState == RTLLIB_LINKED && priv->rtllib->state == RTLLIB_LINKED) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; - update = 1; - pHTInfo->bWAIotBroadcom = false; - printk("dm_WA_Broadcom_IOT(), from connect to disconnected, disable HT_IOT_ACT_WA_IOT_Broadcom\n"); - } - } - connectState = priv->rtllib->state; - - if (!update && pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (priv->undecorated_smoothed_pwdb < pHTInfo->WAIotTH) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_WA_IOT_Broadcom; - update = 1; - printk("dm_WA_Broadcom_IOT() ==> WA_IOT enable cck rates\n"); - } - } - else if (priv->undecorated_smoothed_pwdb >= (priv->rtllib->CTSToSelfTH+5)) - { - if ((pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) == 0) - { - pHTInfo->IOTAction |= HT_IOT_ACT_WA_IOT_Broadcom; - update = 1; - printk("dm_WA_Broadcom_IOT() ==> WA_IOT disable cck rates\n"); - } - } - } - - if (update){ - if (priv->rtllib->bUseRAMask){ - priv->rtllib->UpdateHalRAMaskHandler( - dev, - false, - 0, - priv->rtllib->pHTInfo->PeerMimoPs, - priv->rtllib->mode, - priv->rtllib->pHTInfo->bCurTxBW40MHz, - 0); - }else{ - priv->ops->update_ratr_table(dev, priv->rtllib->dot11HTOperationalRateSet, NULL); - } - priv->rtllib->SetHwRegHandler( dev, HW_VAR_BASIC_RATE, (u8*)(&priv->basic_rate)); - } -} -#endif - static void dm_check_pbc_gpio(struct net_device *dev) { #ifdef RTL8192U @@ -3187,382 +2929,6 @@ extern void dm_CheckRfCtrlGPIO(void *data) } } -#elif defined RTL8192SE -extern void Power_DomainInit92SE(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 tmpU1b; - u16 tmpU2b; - - - - priv->PwrDomainProtect = true; - - tmpU1b = read_nic_byte(dev, (SYS_CLKR + 1)); - if (tmpU1b & BIT7) - { - tmpU1b &= ~(BIT6 | BIT7); - if (!HalSetSysClk8192SE(dev, tmpU1b)){ - priv->PwrDomainProtect = false; - return; - } - } - - write_nic_byte(dev, AFE_PLL_CTRL, 0x0); - write_nic_byte(dev, LDOA15_CTRL, 0x34); - - tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1); - if (priv->rtllib->RfOffReason & (RF_CHANGE_BY_IPS | RF_CHANGE_BY_HW)) { - tmpU1b &= 0xFB; - } else { - tmpU1b &= 0x73; - } - - write_nic_byte(dev, SYS_FUNC_EN+1, tmpU1b); - udelay(1000); - - write_nic_byte(dev, CMDR, 0); - write_nic_byte(dev, TCR, 0); - - tmpU1b = read_nic_byte(dev, 0x562); - tmpU1b |= 0x08; - write_nic_byte(dev, 0x562, tmpU1b); - tmpU1b &= ~(BIT3); - write_nic_byte(dev, 0x562, tmpU1b); - - tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL); - write_nic_byte(dev, AFE_XTAL_CTRL, (tmpU1b|0x01)); - udelay(1500); - tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL+1); - write_nic_byte(dev, AFE_XTAL_CTRL+1, (tmpU1b&0xfb)); - - - tmpU1b = read_nic_byte(dev, AFE_MISC); - write_nic_byte(dev, AFE_MISC, (tmpU1b|BIT0)); - udelay(1000); - - tmpU1b = read_nic_byte(dev, AFE_MISC); - write_nic_byte(dev, AFE_MISC, (tmpU1b|0x02)); - udelay(1000); - - tmpU1b = read_nic_byte(dev, LDOA15_CTRL); - write_nic_byte(dev, LDOA15_CTRL, (tmpU1b|BIT0)); - - tmpU2b = read_nic_word(dev, SYS_ISO_CTRL); - write_nic_word(dev, SYS_ISO_CTRL, (tmpU2b|BIT11)); - - - tmpU2b = read_nic_word(dev, SYS_FUNC_EN); - write_nic_word(dev, SYS_FUNC_EN, (tmpU2b |BIT13)); - - write_nic_byte(dev, SYS_ISO_CTRL+1, 0x68); - - tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL); - write_nic_byte(dev, AFE_PLL_CTRL, (tmpU1b|BIT0|BIT4)); - tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL+1); - write_nic_byte(dev, AFE_PLL_CTRL+1, (tmpU1b|BIT0)); - udelay(1000); - - write_nic_byte(dev, SYS_ISO_CTRL, 0xA6); - - tmpU2b = read_nic_word(dev, SYS_CLKR); - write_nic_word(dev, SYS_CLKR, (tmpU2b|BIT12|BIT11)); - - tmpU2b = read_nic_word(dev, SYS_FUNC_EN); - write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|BIT11)); - write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|BIT11|BIT15)); - - tmpU2b = read_nic_word(dev, SYS_CLKR); - write_nic_word(dev, SYS_CLKR, (tmpU2b&(~BIT2))); - - tmpU1b = read_nic_byte(dev, (SYS_CLKR + 1)); - tmpU1b = ((tmpU1b | BIT7) & (~BIT6)); - if (!HalSetSysClk8192SE(dev, tmpU1b)) - { - priv->PwrDomainProtect = false; - return; - } - - write_nic_word(dev, CMDR, 0x37FC); - - gen_RefreshLedState(dev); - - priv->PwrDomainProtect = false; - -} - -void SET_RTL8192SE_RF_HALT(struct net_device *dev) -{ - u8 u1bTmp; - struct r8192_priv *priv = rtllib_priv(dev); - - if (priv->rtllib->RfOffReason == RF_CHANGE_BY_IPS && priv->LedStrategy == SW_LED_MODE8) - { - SET_RTL8192SE_RF_SLEEP(dev); - return; - } - - u1bTmp = read_nic_byte(dev, LDOV12D_CTRL); - u1bTmp |= BIT0; - write_nic_byte(dev, LDOV12D_CTRL, u1bTmp); - write_nic_byte(dev, SPS1_CTRL, 0x0); - write_nic_byte(dev, TXPAUSE, 0xFF); - write_nic_word(dev, CMDR, 0x57FC); - udelay(100); - write_nic_word(dev, CMDR, 0x77FC); - write_nic_byte(dev, PHY_CCA, 0x0); - udelay(10); - write_nic_word(dev, CMDR, 0x37FC); - udelay(10); - write_nic_word(dev, CMDR, 0x77FC); - udelay(10); - write_nic_word(dev, CMDR, 0x57FC); - write_nic_word(dev, CMDR, 0x0000); - u1bTmp = read_nic_byte(dev, (SYS_CLKR + 1)); - if (u1bTmp & BIT7) - { - u1bTmp &= ~(BIT6 | BIT7); - if (!HalSetSysClk8192SE(dev, u1bTmp)) - return; - } - if (priv->rtllib->RfOffReason==RF_CHANGE_BY_IPS ) - { - write_nic_byte(dev, 0x03, 0xF9); - } - else - { - write_nic_byte(dev, 0x03, 0x71); - } - write_nic_byte(dev, SYS_CLKR+1, 0x70); - write_nic_byte(dev, AFE_PLL_CTRL+1, 0x68); - write_nic_byte(dev, AFE_PLL_CTRL, 0x00); - write_nic_byte(dev, LDOA15_CTRL, 0x34); - write_nic_byte(dev, AFE_XTAL_CTRL, 0x0E); - -} - -u8 RfOnOffDetect(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 u1Tmp; - u8 retval=eRfOn; - - if (priv->pwrdown) - { - u1Tmp = read_nic_byte(dev, 0x06); - printk("pwrdown, 0x6(BIT6)=%02x\n", u1Tmp); - retval = (u1Tmp & BIT6) ? eRfOn: eRfOff; - } - else - { -#ifdef CONFIG_BT_COEXIST - if (pHalData->bt_coexist.BluetoothCoexist) - { - if (pHalData->bt_coexist.BT_CoexistType == BT_2Wire) - { - PlatformEFIOWrite1Byte(pAdapter, MAC_PINMUX_CFG, 0xa); - u1Tmp = PlatformEFIORead1Byte(pAdapter, GPIO_IO_SEL); - delay_us(100); - u1Tmp = PlatformEFIORead1Byte(pAdapter, GPIO_IN); - RTPRINT(FPWR, PWRHW, ("GPIO_IN=%02x\n", u1Tmp)); - retval = (u1Tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? eRfOn : eRfOff; - } - else if ( (pHalData->bt_coexist.BT_CoexistType == BT_ISSC_3Wire) || - (pHalData->bt_coexist.BT_CoexistType == BT_Accel) || - (pHalData->bt_coexist.BT_CoexistType == BT_CSR) ) - { - u4tmp = PHY_QueryBBReg(pAdapter, 0x87c, bMaskDWord); - if ((u4tmp & BIT17) != 0) - { - PHY_SetBBReg(pAdapter, 0x87c, bMaskDWord, u4tmp & ~BIT17); - delay_us(50); - RTPRINT(FBT, BT_RFPoll, ("BT write 0x87c (~BIT17) = 0x%x\n", u4tmp &~BIT17)); - } - u4tmp = PHY_QueryBBReg(pAdapter, 0x8e0, bMaskDWord); - RTPRINT(FBT, BT_RFPoll, ("BT read 0x8e0 (BIT24)= 0x%x\n", u4tmp)); - retval = (u4tmp & BIT24) ? eRfOn : eRfOff; - RTPRINT(FBT, BT_RFPoll, ("BT check RF state to %s\n", (retval==eRfOn)? "ON":"OFF")); - } - } - else -#endif - { - write_nic_byte(dev, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO)); - u1Tmp = read_nic_byte(dev, GPIO_IO_SEL); - - u1Tmp &= HAL_8192S_HW_GPIO_OFF_MASK; - write_nic_byte(dev, GPIO_IO_SEL, u1Tmp); - - mdelay(10); - - u1Tmp = read_nic_byte(dev, GPIO_IN); - retval = (u1Tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? eRfOn : eRfOff; - } - } - - return retval; -} - -extern void dm_CheckRfCtrlGPIO(void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct r8192_priv *priv = rtllib_priv(dev); - - RT_RF_POWER_STATE eRfPowerStateToSet, CurRfState; - bool bActuallySet = false; - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); - unsigned long flag = 0; - bool turnonbypowerdomain = false; - - -#ifdef CONFIG_RTL_RFKILL - return; -#endif - if ((priv->up_first_time == 1) || (priv->being_init_adapter)) - { - ; - return; - } - - if (priv->ResetProgress == RESET_TYPE_SILENT) - { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); - return; - } - - - if (pPSC->bSwRfProcessing) - { - RT_TRACE(COMP_SCAN, "GPIOChangeRFWorkItemCallBack(): Rf is in switching state.\n"); - return; - } - - RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack() ---------> \n"); - - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack(): RF Change in progress! \n"); - return; - } else { - priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - } - CurRfState = priv->rtllib->eRFPowerState; -#ifdef CONFIG_ASPM_OR_D3 - if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) - { - RT_DISABLE_ASPM(dev); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } - -#endif - if (RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - Power_DomainInit92SE(dev); - turnonbypowerdomain = true; - } - - eRfPowerStateToSet = RfOnOffDetect(dev); - if (priv->bResetInProgress) { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - return; - } - - if ( (priv->bHwRadioOff == true) && \ - (((eRfPowerStateToSet == eRfOn)&&(priv->sw_radio_on == true)) -#ifdef CONFIG_RTLWIFI_DEBUGFS - ||priv->debug->hw_holding -#endif - )) - { - RT_TRACE(COMP_RF, "GPIOChangeRF - HW Radio ON, RF ON\n"); - printk("GPIOChangeRF - HW Radio ON, RF ON\n"); - eRfPowerStateToSet = eRfOn; - bActuallySet = true; - } else if ((priv->bHwRadioOff == false) && - ((eRfPowerStateToSet == eRfOff) || (priv->sw_radio_on == false))) - { - RT_TRACE(COMP_RF, "GPIOChangeRF - HW Radio OFF\n"); - printk("GPIOChangeRF - HW Radio OFF\n"); - eRfPowerStateToSet = eRfOff; - bActuallySet = true; - } - - if (bActuallySet) { - priv->bHwRfOffAction = 1; -#ifdef CONFIG_ASPM_OR_D3 - if (eRfPowerStateToSet == eRfOn) { - if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && - RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) { - RT_DISABLE_ASPM(dev); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } - } -#endif - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); - - { -#ifdef CONFIG_CFG_80211 - struct wireless_dev *wdev = &priv->rtllib->wdev; - wiphy_rfkill_set_hw_state(wdev->wiphy, priv->bHwRadioOff); -#else - char *argv[3]; - static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; - static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - - if (priv->bHwRadioOff == true) - argv[1] = "RFOFF"; - else - argv[1] = "RFON"; - - argv[0] = RadioPowerPath; - argv[2] = NULL; - call_usermodehelper(RadioPowerPath,argv,envp,1); - -#endif - } - - if (eRfPowerStateToSet == eRfOff) - { - if (priv->pwrdown) - write_nic_byte(dev, SYS_FUNC_EN+1, 0x31); -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) { - RT_ENABLE_ASPM(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } -#endif - } - } else if (eRfPowerStateToSet == eRfOff || CurRfState == eRfOff || - priv->bDriverIsGoingToUnload) { - - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && - turnonbypowerdomain) { - PHY_SetRtl8192seRfHalt(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) { - RT_ENABLE_ASPM(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } -#endif - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - } else { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - } - RT_TRACE(COMP_RF, "GPIOChangeRFWorkItemCallBack() <--------- \n"); -} #endif void dm_rf_pathcheck_workitemcallback(void *data) { diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 967a5e426e2..6f59097873c 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -285,9 +285,7 @@ extern void hal_dm_watchdog(struct net_device *dev); extern void init_rate_adaptive(struct net_device *dev); extern void dm_txpower_trackingcallback(void *data); -#ifndef RTL8192SE extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14); -#endif extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); @@ -308,13 +306,7 @@ extern void dm_check_fsync(struct net_device *dev); extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); -#if (defined RTL8192E || defined RTL8192SE) extern void dm_CheckRfCtrlGPIO(void *data); -#endif - -#ifdef RTL8192SE -extern void Power_DomainInit92SE(struct net_device *dev); -#endif extern void dm_InitRateAdaptiveMask(struct net_device * dev); diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index 71f20424278..be85ac9022f 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -47,13 +47,11 @@ void PlatformEnableASPM(struct net_device *dev); u32 PlatformResetPciSpace(struct net_device *dev,u8 Value); #endif -#if defined(RTL8192E) || defined(RTL8192SE) || defined RTL8192CE void rtl8192_hw_wakeup(struct net_device *dev); void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); void IPSLeave_wq (void *data); -#endif void IPSEnter(struct net_device *dev); void IPSLeave(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index cc6bcc6b023..673382b560c 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -203,51 +203,12 @@ typedef struct adhoc_peer_entry_t Entry[MAX_ADHOC_PEER_NUM]; unsigned char num; } adhoc_peers_info_t, *p_adhoc_peers_info_t; + int r8192_wx_get_adhoc_peers(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { -#ifndef RTL8192SE return 0; -#else - struct r8192_priv *priv = rtllib_priv(dev); - struct sta_info * psta = NULL; - adhoc_peers_info_t adhoc_peers_info; - p_adhoc_peers_info_t padhoc_peers_info = &adhoc_peers_info; - p_adhoc_peer_entry_t padhoc_peer_entry = NULL; - int k=0; - - - memset(extra, 0, 2047); - padhoc_peers_info->num = 0; - - down(&priv->wx_sem); - - for (k=0; krtllib->peer_assoc_list[k]; - if (NULL != psta) - { - padhoc_peer_entry = &padhoc_peers_info->Entry[padhoc_peers_info->num]; - memset(padhoc_peer_entry,0, sizeof(adhoc_peer_entry_t)); - memcpy(padhoc_peer_entry->MacAddr, psta->macaddr, ETH_ALEN); - padhoc_peer_entry->WirelessMode = psta->wireless_mode; - padhoc_peer_entry->bCurTxBW40MHz = psta->htinfo.bCurTxBW40MHz; - padhoc_peers_info->num ++; - printk("[%d] MacAddr:"MAC_FMT" \tWirelessMode:%d \tBW40MHz:%d \n", \ - k, MAC_ARG(padhoc_peer_entry->MacAddr), padhoc_peer_entry->WirelessMode, padhoc_peer_entry->bCurTxBW40MHz); - sprintf(extra, "[%d] MacAddr:"MAC_FMT" \tWirelessMode:%d \tBW40MHz:%d \n", \ - k, MAC_ARG(padhoc_peer_entry->MacAddr), padhoc_peer_entry->WirelessMode, padhoc_peer_entry->bCurTxBW40MHz); - } - } - - up(&priv->wx_sem); - - wrqu->data.length = strlen(extra); - wrqu->data.flags = 0; - return 0; - -#endif } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index ad1e8106d6a..16571aa2083 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -3210,12 +3210,6 @@ extern int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_rx_stats *stats); void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index); -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -extern void IbssAgeFunction(struct rtllib_device *ieee); -extern struct sta_info *GetStaInfo(struct rtllib_device *ieee, u8 *addr); -extern void DelStaInfoList(struct rtllib_device *ieee); -extern void DelStaInfo(struct rtllib_device *ieee, u8 *addr); -#endif extern u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS); extern void HTUseDefaultSetting(struct rtllib_device* ieee); #define RT_ASOC_RETRY_LIMIT 5 diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 4c3590b4a96..e11d9a3d9ff 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1608,9 +1608,6 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct net_device *dev = ieee->dev; struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; struct rtllib_crypt_data *crypt = NULL; -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - struct sta_info * psta = NULL; -#endif struct rtllib_rxb* rxb = NULL; PRX_TS_RECORD pTS = NULL; u16 fc, sc, SeqNum = 0; @@ -1695,14 +1692,6 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (ieee->iw_mode == IW_MODE_ADHOC){ - psta = GetStaInfo(ieee, src); - if (NULL != psta) - psta->LastActiveTime = jiffies; - } -#endif - /* Get crypt if encrypted */ ret = rtllib_rx_get_crypt(ieee, skb, &crypt, hdrlen); if (ret == -1) @@ -2935,231 +2924,6 @@ static inline int is_beacon(__le16 fc) return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -u8 AsocEntry_ComputeSum(u8 *paddr) -{ - u32 sum; - - sum = paddr[0]+ - paddr[1]+ - paddr[2]+ - paddr[3]+ - paddr[4]+ - paddr[5]; - - return (u8)(sum % PEER_MAX_ASSOC); -} -u8 AsocEntry_AssignAvailableAID(struct rtllib_device *ieee, u8 *paddr) -{ - int i; - - for (i = 0; i < PEER_MAX_ASSOC; i++) - { - if (ieee->AvailableAIDTable[i] == 99) - { - ieee->AvailableAIDTable[i] = AsocEntry_ComputeSum(paddr); - return i+1; - } - } - - return 1; -} - -void InitStaInfo(struct rtllib_device *ieee,int index) -{ - int idx = index; - ieee->peer_assoc_list[idx]->StaDataRate = 0; - ieee->peer_assoc_list[idx]->StaSS = 0; - ieee->peer_assoc_list[idx]->RetryFrameCnt = 0; - ieee->peer_assoc_list[idx]->NoRetryFrameCnt = 0; - ieee->peer_assoc_list[idx]->LastRetryCnt = 0; - ieee->peer_assoc_list[idx]->LastNoRetryCnt = 0; - ieee->peer_assoc_list[idx]->AvgRetryRate = 0; - ieee->peer_assoc_list[idx]->LastRetryRate = 0; - ieee->peer_assoc_list[idx]->txRateIndex = 11; - ieee->peer_assoc_list[idx]->APDataRate = 0x2; - ieee->peer_assoc_list[idx]->ForcedDataRate = 0x2; - -} -static u8 IsStaInfoExist(struct rtllib_device *ieee, u8 *addr) -{ - int k=0; - struct sta_info * psta = NULL; - u8 sta_idx = PEER_MAX_ASSOC; - - for (k=0; kpeer_assoc_list[k]; - if (NULL != psta) - { - if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0) - { - sta_idx = k; - break; - } - } - } - return sta_idx; -} -static u8 GetFreeStaInfoIdx(struct rtllib_device *ieee, u8 *addr) -{ - int k = 0; - while((ieee->peer_assoc_list[k] != NULL) && (k < PEER_MAX_ASSOC)) - k++; - printk("%s: addr:"MAC_FMT" index: %d\n", __func__, MAC_ARG(addr), k); - return k; -} -struct sta_info *GetStaInfo(struct rtllib_device *ieee, u8 *addr) -{ - int k=0; - struct sta_info * psta = NULL; - struct sta_info * psta_find = NULL; - - for (k=0; kpeer_assoc_list[k]; - if (NULL != psta) - { - if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0) - { - psta_find = psta; - break; - } - } - } - return psta_find; -} -void DelStaInfoList(struct rtllib_device *ieee) -{ - int idx = 0; - struct sta_info * AsocEntry = NULL; - - atomic_set(&ieee->AsocEntryNum, 0); - for (idx=0; idxpeer_assoc_list[idx]; - if (NULL != AsocEntry){ - kfree(AsocEntry); - ieee->peer_assoc_list[idx] = NULL; - } - ieee->AvailableAIDTable[idx] = 99; - } -} -void DelStaInfo(struct rtllib_device *ieee, u8 *addr) -{ - struct sta_info * psta = NULL; - int k=0; - - for (k=0; kpeer_assoc_list[k]; - if (NULL != psta){ - if (memcmp(addr, psta->macaddr, ETH_ALEN) == 0){ - if (psta->aid > 0 && psta->aid-1 < PEER_MAX_ASSOC) - ieee->AvailableAIDTable[psta->aid-1] = 99; - else - printk("%s(): clear non-existing entry AID\n", __func__); - - kfree(psta); - ieee->peer_assoc_list[k] = NULL; - atomic_dec(&ieee->AsocEntryNum); - } - } - } -} -void IbssAgeFunction(struct rtllib_device *ieee) -{ - struct sta_info* AsocEntry = NULL; - int idx; - unsigned long CurrentTime; - signed long TimeDifference; - struct rtllib_network *target; - - CurrentTime = jiffies; - - for (idx = 0; idx < PEER_MAX_ASSOC; idx++) - { - AsocEntry = ieee->peer_assoc_list[idx]; - if (AsocEntry) - { - TimeDifference = jiffies_to_msecs(CurrentTime - AsocEntry->LastActiveTime); - - if (TimeDifference > 20000) - { - printk("IbssAgeFunction(): "MAC_FMT" timeout\n", MAC_ARG(AsocEntry->macaddr)); - kfree(AsocEntry); - ieee->peer_assoc_list[idx] = NULL; - atomic_dec(&ieee->AsocEntryNum); - - if (atomic_read(&ieee->AsocEntryNum) == 0){ - - down(&ieee->wx_sem); - rtllib_stop_protocol(ieee,true); - - list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &ieee->current_network,(target->ssid_len?1:0))){ - printk("delete sta of previous Ad-hoc\n"); - list_del(&target->list); - break; - } - } - - rtllib_start_protocol(ieee); - up(&ieee->wx_sem); - } - } - } - } - -#ifdef TO_DO_LIST - if (AsocEntry_AnyStationAssociated(pMgntInfo)==false) - DrvIFIndicateDisassociation(Adapter, unspec_reason); - - if (pMgntInfo->dot11CurrentWirelessMode == WIRELESS_MODE_G || - (IS_WIRELESS_MODE_N_24G(Adapter) && pMgntInfo->pHTInfo->bCurSuppCCK) ) - { - if (nBModeStaCnt == 0) - { - pMgntInfo->bUseProtection = false; - ActUpdate_mCapInfo(Adapter, pMgntInfo->mCap); - } - } - - if (IS_WIRELESS_MODE_N_24G(Adapter) || IS_WIRELESS_MODE_N_5G(Adapter) ) - { - if (nLegacyStaCnt > 0) - { - pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_MIXED; - } - else - { - if ((pMgntInfo->pHTInfo->bCurBW40MHz) && (n20MHzStaCnt > 0)) - pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_40MHZ_PROTECT; - else - pMgntInfo->pHTInfo->CurrentOpMode = HT_OPMODE_NO_PROTECT; - - } - } - - if (IS_WIRELESS_MODE_G(Adapter) || - (IS_WIRELESS_MODE_N_24G(Adapter) && pMgntInfo->pHTInfo->bCurSuppCCK)) - { - if (pMgntInfo->bUseProtection) - { - u8 CckRate[4] = { MGN_1M, MGN_2M, MGN_5_5M, MGN_11M }; - OCTET_STRING osCckRate; - FillOctetString(osCckRate, CckRate, 4); - FilterSupportRate(pMgntInfo->mBrates, &osCckRate, false); - Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_BASIC_RATE, (pu1Byte)&osCckRate); - } - else - { - Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_BASIC_RATE, (pu1Byte)(&pMgntInfo->mBrates) ); - } - } -#endif -} -#endif - static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { @@ -3258,76 +3022,6 @@ static inline void rtllib_process_probe_response( * already there. */ spin_lock_irqsave(&ieee->lock, flags); -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (is_beacon(beacon->header.frame_ctl)){ - if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->state == RTLLIB_LINKED)) - { - if ((network->ssid_len == ieee->current_network.ssid_len) - && (!memcmp(network->ssid,ieee->current_network.ssid,ieee->current_network.ssid_len)) - && (network->channel == ieee->current_network.channel) - && (ieee->current_network.channel > 0) - && (ieee->current_network.channel <= 14)) - { - if (!memcmp(ieee->current_network.bssid,network->bssid,6)) - { - int idx = 0; - struct rtllib_hdr_3addr* header = NULL; - int idx_exist = 0; - if (timer_pending(&ieee->ibss_wait_timer)) - del_timer_sync(&ieee->ibss_wait_timer); - header = (struct rtllib_hdr_3addr*)&(beacon->header); - idx_exist = IsStaInfoExist(ieee,header->addr2); - if (idx_exist >= PEER_MAX_ASSOC) { - idx = GetFreeStaInfoIdx(ieee, header->addr2); - } else { - ieee->peer_assoc_list[idx_exist]->LastActiveTime = jiffies; - goto no_alloc; - } - if (idx >= PEER_MAX_ASSOC - 1) { - printk("\n%s():ERR!!!Buffer overflow - could not append!!!",__func__); - goto free_network; - } else { - ieee->peer_assoc_list[idx] = (struct sta_info *)kmalloc(sizeof(struct sta_info), GFP_ATOMIC); - memset(ieee->peer_assoc_list[idx], 0, sizeof(struct sta_info)); - ieee->peer_assoc_list[idx]->LastActiveTime = jiffies; - memcpy(ieee->peer_assoc_list[idx]->macaddr,header->addr2,ETH_ALEN); - ieee->peer_assoc_list[idx]->ratr_index = 8; - InitStaInfo(ieee,idx); - atomic_inc(&ieee->AsocEntryNum); - ieee->peer_assoc_list[idx]->aid = AsocEntry_AssignAvailableAID(ieee, ieee->peer_assoc_list[idx]->macaddr); - ieee->check_ht_cap(ieee->dev,ieee->peer_assoc_list[idx],network); - queue_delayed_work_rsl(ieee->wq, &ieee->update_assoc_sta_info_wq, 0); - ieee->Adhoc_InitRateAdaptive(ieee->dev,ieee->peer_assoc_list[idx]); - } - } - } - } - } - if (ieee->iw_mode == IW_MODE_ADHOC){ - if ((network->ssid_len == ieee->current_network.ssid_len) - && (!memcmp(network->ssid,ieee->current_network.ssid,ieee->current_network.ssid_len)) - && (network->capability & WLAN_CAPABILITY_IBSS) - && (ieee->state == RTLLIB_LINKED_SCANNING)) - { - if (memcmp(ieee->current_network.bssid,network->bssid,6)) - { - printk("%s(): SSID matched but BSSID mismatched.\n",__func__); - - ieee->TargetTsf = beacon->time_stamp[1]; - ieee->TargetTsf <<= 32; - ieee->TargetTsf |= beacon->time_stamp[0]; - - ieee->CurrTsf = stats->TimeStampLow; - - queue_delayed_work_rsl(ieee->wq, &ieee->check_tsf_wq, 0); - } - } - } -#endif -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -no_alloc: - if (ieee->iw_mode == IW_MODE_INFRA) -#endif { if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { update_network(&ieee->current_network, network); @@ -3345,14 +3039,6 @@ no_alloc: } } } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - else if (ieee->iw_mode == IW_MODE_ADHOC) - { - if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { - update_ibss_network(&ieee->current_network, network); - } - } -#endif list_for_each_entry(target, &ieee->network_list, list) { if (is_same_network(target, network,(target->ssid_len?1:0))) break; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index dadb5430bfa..c9c5df4c994 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1066,14 +1066,6 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) *(tag++) = 1; *(tag++) = erpinfo_content; } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (tmp_ht_cap_len){ - *(tag++) = MFIE_TYPE_HT_CAP; - *(tag++) = tmp_ht_cap_len - 2; - memcpy(tag, tmp_ht_cap_buf, tmp_ht_cap_len - 2); - tag += tmp_ht_cap_len - 2; - } -#endif if (rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; *(tag++) = rate_ex_len-2; @@ -1081,15 +1073,6 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) tag+=rate_ex_len-2; } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (tmp_ht_info_len){ - *(tag++) = MFIE_TYPE_HT_INFO; - *(tag++) = tmp_ht_info_len - 2; - memcpy(tag, tmp_ht_info_buf, tmp_ht_info_len -2); - tag += tmp_ht_info_len - 2; - } -#endif - if (wpa_ie_len) { if (ieee->iw_mode == IW_MODE_ADHOC) @@ -1100,23 +1083,6 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) tag += ieee->wpa_ie_len; } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (tmp_generic_ie_len) - { - (*tag++) = 0xdd; - (*tag++) = tmp_generic_ie_len - 2; - memcpy(tag,tmp_generic_ie_buf,tmp_generic_ie_len -2); - tag += tmp_generic_ie_len -2; - - } -#endif - -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (wmm_len) { - memcpy(tag,wmmie,wmm_len); - tag += wmm_len; - } -#endif return skb; } @@ -2154,20 +2120,10 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, i void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - struct sta_info *psta = NULL; -#endif ieee->softmac_stats.rx_probe_rq++; if (probe_rq_parse(ieee, skb, dest) > 0){ ieee->softmac_stats.tx_probe_rs++; rtllib_resp_to_probe(ieee, dest); -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if (ieee->iw_mode == IW_MODE_ADHOC){ - psta = GetStaInfo(ieee, dest); - if (NULL != psta) - psta->LastActiveTime = jiffies; - } -#endif } } @@ -3040,17 +2996,8 @@ void rtllib_start_ibss_wq(void *data) ieee->rate = 22; } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -#ifdef ADHOC_11N - ieee->current_network.qos_data.supported = 1; -#else - ieee->current_network.qos_data.supported = 0; -#endif - ieee->SetWirelessMode(ieee->dev, ieee->mode); -#else ieee->current_network.qos_data.supported = 0; ieee->SetWirelessMode(ieee->dev, IEEE_G); -#endif ieee->current_network.mode = ieee->mode; ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index d88bb109a31..01f22045000 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -239,22 +239,7 @@ int rtllib_wx_get_rate(struct rtllib_device *ieee, union iwreq_data *wrqu, char *extra) { u32 tmp_rate = 0; -#if defined RTL8192SU - if (ieee->mode & (IEEE_A | IEEE_B | IEEE_G)) - tmp_rate = ieee->rate; - else if (ieee->mode & IEEE_N_5G) - tmp_rate = 580; - else if (ieee->mode & IEEE_N_24G) { - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - tmp_rate = HTHalfMcsToDataRate(ieee, 15); - else - tmp_rate = HTMcsToDataRate(ieee, 15); - } -#elif defined RTL8192SE || defined RTL8192CE - tmp_rate = ieee->rtl_11n_user_show_rates(ieee->dev); -#else tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); -#endif wrqu->bitrate.value = tmp_rate * 500000; return 0; diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 78b1707b12a..7662bf5bf3e 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -449,53 +449,7 @@ void rtllib_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc) tcb_desc->bPacketBW = true; return; } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -extern void rtllib_ibss_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc,u8 is_peer_shortGI_40M,u8 is_peer_shortGI_20M) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - tcb_desc->bUseShortGI = false; - - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT || (ieee->iw_mode != IW_MODE_ADHOC)) - { - return; - } - - if (pHTInfo->bForcedShortGI) - { - tcb_desc->bUseShortGI = true; - return; - } - if ((pHTInfo->bCurBW40MHz==true) && is_peer_shortGI_40M) - tcb_desc->bUseShortGI = true; - else if ((pHTInfo->bCurBW40MHz==false) && is_peer_shortGI_20M) - tcb_desc->bUseShortGI = true; -} -void rtllib_ibss_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc, u8 is_peer_40M) -{ - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - - tcb_desc->bPacketBW = false; - - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT || (ieee->iw_mode != IW_MODE_ADHOC)) - { - return; - } - - if (tcb_desc->bMulticast || tcb_desc->bBroadcast) - { - return; - } - - if ((tcb_desc->data_rate & 0x80)==0) - { - return; - } - if (pHTInfo->bCurBW40MHz && is_peer_40M && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) - tcb_desc->bPacketBW = true; - return; -} -#endif void rtllib_query_protectionmode(struct rtllib_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb) { tcb_desc->bRTSSTBC = false; @@ -596,11 +550,7 @@ NO_PROTECTION: } -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) -void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc,struct sta_info *psta) -#else void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc) -#endif { #ifdef TO_DO_LIST if (!IsDataFrame(pFrame)) @@ -1000,62 +950,6 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) tcb_desc->bMulticast = 1; if (is_broadcast_ether_addr(header.addr1)) tcb_desc->bBroadcast = 1; -#if defined(RTL8192U) || defined(RTL8192SU) || defined(RTL8192SE) - if ( tcb_desc->bMulticast || tcb_desc->bBroadcast){ - rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); - tcb_desc->data_rate = ieee->basic_rate; - } - else - { - if (ieee->iw_mode == IW_MODE_ADHOC) - { - u8 is_peer_shortGI_40M = 0; - u8 is_peer_shortGI_20M = 0; - u8 is_peer_BW_40M = 0; - p_sta = GetStaInfo(ieee, header.addr1); - if (NULL == p_sta) - { - rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); - tcb_desc->data_rate = ieee->rate; - } - else - { - rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); - tcb_desc->data_rate = CURRENT_RATE(p_sta->wireless_mode, p_sta->CurDataRate, p_sta->htinfo.HTHighestOperaRate); - is_peer_shortGI_40M = p_sta->htinfo.bCurShortGI40MHz; - is_peer_shortGI_20M = p_sta->htinfo.bCurShortGI20MHz; - is_peer_BW_40M = p_sta->htinfo.bCurTxBW40MHz; - } - rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); - rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); - rtllib_ibss_query_HTCapShortGI(ieee, tcb_desc,is_peer_shortGI_40M,is_peer_shortGI_20M); - rtllib_ibss_query_BandwidthMode(ieee, tcb_desc,is_peer_BW_40M); - rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); - } - else { - rtllib_txrate_selectmode(ieee, tcb_desc, p_sta); - tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); - if (bdhcp == true){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) { - tcb_desc->data_rate = MGN_1M; - tcb_desc->bTxDisableRateFallBack = false; - }else{ - tcb_desc->data_rate = MGN_1M; - tcb_desc->bTxDisableRateFallBack = 1; - } - - tcb_desc->RATRIndex = 7; - tcb_desc->bTxUseDriverAssingedRate = 1; - tcb_desc->bdhcp = 1; - } - rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); - rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); - rtllib_query_HTCapShortGI(ieee, tcb_desc); - rtllib_query_BandwidthMode(ieee, tcb_desc); - rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); - } - } -#else rtllib_txrate_selectmode(ieee, tcb_desc); if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) tcb_desc->data_rate = ieee->basic_rate; @@ -1083,7 +977,6 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) rtllib_query_HTCapShortGI(ieee, tcb_desc); rtllib_query_BandwidthMode(ieee, tcb_desc); rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); -#endif } } spin_unlock_irqrestore(&ieee->lock, flags); From b355c1d0bceee3276b406327c6f1765c73901ab0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 11 Jul 2011 22:37:27 -0500 Subject: [PATCH 0284/1519] staging: rtl8192e: Remove dead code associated with RTL8192CE The vendor code will generate several different drivers. As the RTL8192CE is covered by a mac80211 driver in mainline, eliminate that code here. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 21 ------- drivers/staging/rtl8192e/rtl819x_HT.h | 4 -- drivers/staging/rtl8192e/rtl819x_HTProc.c | 33 ----------- drivers/staging/rtl8192e/rtl_core.c | 67 +---------------------- drivers/staging/rtl8192e/rtl_debug.h | 4 -- 5 files changed, 1 insertion(+), 128 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 7ec2fd97ebe..3ced5d2fff9 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -2196,11 +2196,7 @@ void rtl8192_EnableInterrupt(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->irq_enabled = 1; -#ifdef RTL8192CE - write_nic_dword(dev, REG_HIMR, priv->irq_mask[0]&0xFFFFFFFF); -#else write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); -#endif } @@ -2208,11 +2204,7 @@ void rtl8192_DisableInterrupt(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); -#ifdef RTL8192CE - write_nic_dword(dev, REG_HIMR, IMR8190_DISABLED); -#else write_nic_dword(dev,INTA_MASK,0); -#endif priv->irq_enabled = 0; } @@ -2220,14 +2212,8 @@ void rtl8192_DisableInterrupt(struct net_device *dev) void rtl8192_ClearInterrupt(struct net_device *dev) { u32 tmp = 0; -#ifdef RTL8192CE - tmp = read_nic_dword(dev, REG_HISR); - write_nic_dword(dev, REG_HISR, tmp); -#else tmp = read_nic_dword(dev, ISR); write_nic_dword(dev, ISR, tmp); -#endif - } @@ -2253,17 +2239,10 @@ void rtl8192_beacon_disable(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u32 reg; -#ifdef RTL8192CE - reg = read_nic_dword(priv->rtllib->dev,REG_HIMR); - - reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - write_nic_dword(priv->rtllib->dev, REG_HIMR, reg); -#else reg = read_nic_dword(priv->rtllib->dev,INTA_MASK); reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); -#endif } void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 15878ad01d7..703d9dde570 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -305,10 +305,6 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 bWAIotBroadcom; u8 WAIotTH; -#ifdef RTL8192CE - u8 bRDGEnable; -#endif - u8 bAcceptAddbaReq; } __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 62dd0976e44..0e7f078c05c 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -64,10 +64,6 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; -#ifdef RTL8192CE - pHTInfo->bRDGEnable = 0; -#endif - pHTInfo->bAcceptAddbaReq = 1; pHTInfo->bRegShortGI20MHz= 1; @@ -423,19 +419,6 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) retValue = false; } } -#endif -#if defined(RTL8192SU) || defined RTL8192CE - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) - { - if ( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) && - (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) && - (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) && - (pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE) && - (pHTInfo->IOTPeer != HT_IOT_PEER_RALINK) ) - retValue = true; - } #endif return retValue; } @@ -453,10 +436,6 @@ bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) #if defined RTL8192SU if (ieee->mode == IEEE_G) retValue = true; -#elif defined RTL8192CE - if (ieee->mode == IEEE_G || - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) - retValue = true; #endif return retValue; @@ -564,14 +543,6 @@ u8 pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) return 1; - } -#elif defined RTL8192CE - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if (pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS || - pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) - return 1; - } #endif return retValue; @@ -832,11 +803,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* *posRT2RTAgg++ = 0x02; *posRT2RTAgg++ = 0x01; -#ifdef RTL8192CE - *posRT2RTAgg = 0x70; -#else *posRT2RTAgg = 0x30; -#endif if (ieee->bSupportRemoteWakeUp) { *posRT2RTAgg |= RT_HT_CAP_USE_WOW; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 372f946de70..5dbf3740195 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -51,9 +51,7 @@ #include "r8192E_cmdpkt.h" #include "rtl_wx.h" -#ifndef RTL8192CE #include "rtl_dm.h" -#endif #ifdef CONFIG_PM_RTL #include "rtl_pm.h" @@ -330,10 +328,6 @@ void write_nic_byte(struct net_device *dev, int x,u8 y) writeb(y,(u8*)dev->mem_start +x); udelay(20); - -#if defined RTL8192CE - read_nic_byte(dev, x); -#endif } void write_nic_dword(struct net_device *dev, int x,u32 y) @@ -341,10 +335,6 @@ void write_nic_dword(struct net_device *dev, int x,u32 y) writel(y,(u8*)dev->mem_start +x); udelay(20); - -#if defined RTL8192CE - read_nic_dword(dev, x); -#endif } void write_nic_word(struct net_device *dev, int x,u16 y) @@ -352,10 +342,6 @@ void write_nic_word(struct net_device *dev, int x,u16 y) writew(y,(u8*)dev->mem_start +x); udelay(20); - -#if defined RTL8192CE - read_nic_word(dev, x); -#endif } /**************************************************************************** @@ -378,9 +364,7 @@ MgntActSet_RF_State( unsigned long flag; RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); -#ifndef RTL8192CE ProtectOrNot = false; -#endif if (!ProtectOrNot) @@ -957,12 +941,6 @@ void rtl8192_refresh_supportrate(struct r8192_priv* priv) memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); memcpy(ieee->Regdot11TxHTOperationalRateSet, ieee->RegHTSuppRateSet, 16); -#ifdef RTL8192CE - if (priv->rf_type == RF_1T1R) { - ieee->Regdot11HTOperationalRateSet[1] = 0; - } -#endif - } else { memset(ieee->Regdot11HTOperationalRateSet, 0, 16); } @@ -1208,23 +1186,6 @@ static void rtl8192_init_priv_constant(struct net_device* dev) pPSC->RegMaxLPSAwakeIntvl = 5; -#ifdef RTL8192CE - priv->bWEPinNmodeFromReg = 0; - priv->bTKIPinNmodeFromReg = 0; - - priv->RegAMDPciASPM = 0; - - priv->RegPciASPM = 3; - - priv->RegDevicePciASPMSetting = 0x03; - - priv->RegHostPciASPMSetting = 0x02; - - priv->RegHwSwRfOffD3 = 0; - - priv->RegSupportPciASPM = 1; - -#elif defined RTL8192E priv->RegPciASPM = 2; priv->RegDevicePciASPMSetting = 0x03; @@ -1234,8 +1195,6 @@ static void rtl8192_init_priv_constant(struct net_device* dev) priv->RegHwSwRfOffD3 = 2; priv->RegSupportPciASPM = 2; - -#endif } @@ -2326,15 +2285,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) spin_unlock_irqrestore(&priv->irq_th_lock,flags); dev->trans_start = jiffies; -#ifdef RTL8192CE - if (tcb_desc->queue_index == BEACON_QUEUE){ - write_nic_word(dev, REG_PCIE_CTRL_REG, BIT4); - }else{ - write_nic_word(dev, REG_PCIE_CTRL_REG, BIT0<<(tcb_desc->queue_index)); - } -#else - write_nic_word(dev,TPPoll,0x01<queue_index); -#endif + write_nic_word(dev,TPPoll,0x01<queue_index); return 0; } @@ -2641,11 +2592,7 @@ void rtl8192_rx_normal(struct net_device *dev) skb_len = skb->len; -#ifdef RTL8192CE - if (!stats.bCRC) -#else if (1) -#endif { if (!rtllib_rx(priv->rtllib, skb, &stats)){ dev_kfree_skb_any(skb); @@ -2716,9 +2663,7 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) if (MAX_RX_QUEUE > 1) rtl8192_rx_cmd(priv->rtllib->dev); -#ifndef RTL8192CE write_nic_dword(priv->rtllib->dev, INTA_MASK,read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); -#endif } /**************************************************************************** @@ -3100,12 +3045,10 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) spin_lock_irqsave(&priv->irq_th_lock,flags); } -#ifndef RTL8192CE if (inta & IMR_COMDOK) { priv->stats.txcmdpktokint++; rtl8192_tx_isr(dev,TXCMD_QUEUE); } -#endif if (inta & IMR_HIGHDOK) { rtl8192_tx_isr(dev,HIGH_QUEUE); @@ -3128,9 +3071,7 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_RDU) { RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); priv->stats.rxrdu++; -#ifndef RTL8192CE write_nic_dword(dev,INTA_MASK,read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); -#endif tasklet_schedule(&priv->irq_rx_tasklet); } @@ -3256,15 +3197,9 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, else priv->rtllib->bSupportRemoteWakeUp = 0; -#ifdef RTL8192CE - pmem_start = pci_resource_start(pdev, 2); - pmem_len = pci_resource_len(pdev, 2); - pmem_flags = pci_resource_flags (pdev, 2); -#else pmem_start = pci_resource_start(pdev, 1); pmem_len = pci_resource_len(pdev, 1); pmem_flags = pci_resource_flags (pdev, 1); -#endif if (!(pmem_flags & IORESOURCE_MEM)) { RT_TRACE(COMP_ERR,"region #1 not a MMIO resource, aborting"); diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 20127926662..511d96c9141 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -277,10 +277,6 @@ void print_buffer(u32 *buffer, int len); void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); -#ifdef RTL8192CE -void rtl8192ce_dump_tx_desc(struct _TX_DESC_8192CE *pDesc); -#endif - /* debugfs stuff */ #ifdef CONFIG_RTLWIFI_DEBUGFS int rtl_debug_module_init(struct r8192_priv *priv, const char *name); From 8df91dae5d258ad72a666af32d54e20e29ead6fb Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 11 Jul 2011 22:43:02 -0500 Subject: [PATCH 0285/1519] staging: rtl8192e: Remove dead code associated with RTL8192SU The vendor code will generate several different drivers. Eliminate code used to generate code for the RTL8192SU devices. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HTProc.c | 42 ----------------------- drivers/staging/rtl8192e/rtllib_rx.c | 2 -- 2 files changed, 44 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 0e7f078c05c..8bb51e215de 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -56,9 +56,6 @@ static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0}; static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91}; static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; -#if defined(RTL8192SU) -static u8 NETGEAR_BROADCOM[3] = {0x00, 0x1f, 0x33}; -#endif static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; void HTUpdateDefaultSetting(struct rtllib_device* ieee) { @@ -101,19 +98,11 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->UsbTxAggrNum = 4; #endif #ifdef USB_RX_AGGREGATION_SUPPORT -#ifdef RTL8192SU - pHTInfo->UsbRxFwAggrEn = 1; - pHTInfo->UsbRxFwAggrPageNum = 48; - pHTInfo->UsbRxFwAggrPacketNum = 8; - pHTInfo->UsbRxFwAggrTimeout = 4; - pHTInfo->UsbRxPageSize= 128; -#else pHTInfo->UsbRxFwAggrEn = 1; pHTInfo->UsbRxFwAggrPageNum = 24; pHTInfo->UsbRxFwAggrPacketNum = 8; pHTInfo->UsbRxFwAggrTimeout = 8; #endif -#endif } @@ -433,11 +422,6 @@ bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) { bool retValue = false; -#if defined RTL8192SU - if (ieee->mode == IEEE_G) - retValue = true; -#endif - return retValue; } @@ -535,16 +519,7 @@ u8 HTIOTActIsEDCABiasRx(struct rtllib_device* ieee,struct rtllib_network *network) { u8 retValue = 0; -#ifdef RTL8192SU - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - { - if (pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS || - pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM || - pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) - return 1; - } -#endif return retValue; } @@ -567,14 +542,6 @@ HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *netwo { u8 retValue = 0; -#ifdef RTL8192SU - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK || - pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK || - pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK_92SE) - { - retValue = 1; - } -#endif return retValue; } @@ -622,15 +589,6 @@ HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network *network) { bool retValue = false; -#if defined(RTL8192SU) - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if ((memcmp(network->bssid, NETGEAR_BROADCOM, 3)==0) - && (network->bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40)) - return true; - } -#endif return retValue; } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index e11d9a3d9ff..96f824ba812 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1519,7 +1519,6 @@ int rtllib_rx_decrypt( } void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { -#if !defined(RTL8192SU) && !defined(RTL8192U) if (unicast){ if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) @@ -1532,7 +1531,6 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub } } } -#endif ieee->last_rx_ps_time = jiffies; } void rtllib_rx_indicate_pkt_legacy( From eb378025999a336e9d2730a66ac924f9b91ed118 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 11 Jul 2011 22:52:12 -0500 Subject: [PATCH 0286/1519] staging: rtl8192e: Remove dead code associated with RTL8192U Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HTProc.c | 21 ------------------ drivers/staging/rtl8192e/rtl_dm.c | 27 ----------------------- drivers/staging/rtl8192e/rtllib.h | 4 ---- 3 files changed, 52 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 8bb51e215de..0f5410c2c16 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -382,33 +382,12 @@ bool HTIOTActIsDisableMCS15(struct rtllib_device* ieee) { bool retValue = false; -#if defined(RTL8192U) - if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) - retValue = true; - else - retValue = false; -#endif - - return retValue; } bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) { bool retValue = false; -#ifdef RTL8192U - struct rtllib_network* net = &ieee->current_network; - - if ((ieee->pHTInfo->bCurrentHTSupport == true) && (ieee->pairwise_key_type == KEY_TYPE_CCMP)) - { - if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0)) - { - retValue = false; - } - } -#endif return retValue; } diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index b0442e49517..a738f666e70 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -672,9 +672,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) u32 Value; u8 Pwr_Flag; u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; -#ifdef RTL8192U - RT_STATUS rtStatus = RT_STATUS_SUCCESS; -#endif u32 delta=0; RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); write_nic_byte(dev, Pw_Track_Flag, 0); @@ -695,15 +692,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; tx_cmd.Length = 4; tx_cmd.Value = Value; -#ifdef RTL8192U - rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12); - if (rtStatus == RT_STATUS_FAILURE) - { - RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n"); - } -#else cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); -#endif mdelay(1); for (i = 0;i <= 30; i++) { @@ -2843,22 +2832,6 @@ dm_Init_WA_Broadcom_IOT(struct net_device * dev) static void dm_check_pbc_gpio(struct net_device *dev) { -#ifdef RTL8192U - struct r8192_priv *priv = rtllib_priv(dev); - u8 tmp1byte; - - - tmp1byte = read_nic_byte(dev,GPI); - if (tmp1byte == 0xff) - return; - - if (tmp1byte&BIT6 || tmp1byte&BIT0) - { - RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n"); - priv->bpbc_pressed = true; - } -#endif - } #ifdef RTL8192E diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 16571aa2083..25ecf30910e 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2378,10 +2378,6 @@ struct rtllib_device { /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; -#ifdef RTL8192U - struct list_head network_bssid_free_list; - struct list_head network_bssid_list; -#endif struct rtllib_network *networks; int scans; int scan_age; From f8f3b8a5857fb67afe1b0d6ec2a84a8a14beb4b0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 11:12:56 -0500 Subject: [PATCH 0287/1519] staging: rtl8192e: Remove internal references to RTL8192E Now that the code can only generate a driver for RTL8192E, the internal ifdef's are no longer needed. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 3 - drivers/staging/rtl8192e/r8190P_rtl8256.c | 4 - drivers/staging/rtl8192e/r8192E_dev.c | 16 +-- drivers/staging/rtl8192e/r8192E_hw.h | 2 - drivers/staging/rtl8192e/r8192E_phy.c | 32 ----- drivers/staging/rtl8192e/r8192E_phy.h | 19 ++- drivers/staging/rtl8192e/rtl_core.c | 2 - drivers/staging/rtl8192e/rtl_dm.c | 136 +--------------------- drivers/staging/rtl8192e/rtl_wx.c | 2 - 9 files changed, 10 insertions(+), 206 deletions(-) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index 7cf7a52875e..594abc0a95f 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -1,6 +1,3 @@ -NIC_SELECT = RTL8192E - -ccflags-y += -DRTL8192E ccflags-y += -DEEPROM_OLD_FORMAT_SUPPORT=1 ccflags-y += -DUSE_FW_SOURCE_IMG_FILE ccflags-y += -DENABLE_GPIO_RADIO_CTL diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index d4ba36e8ac2..b6587000f93 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -187,7 +187,6 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) { u32 TxAGC=0; struct r8192_priv *priv = rtllib_priv(dev); - #ifdef RTL8192E TxAGC = powerlevel; if (priv->bDynamicTxLowPower == true) @@ -200,14 +199,12 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) if (TxAGC > 0x24) TxAGC = 0x24; rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC); - #endif } void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef RTL8192E u32 writeVal, powerBase0, powerBase1, writeVal_tmp; u8 index = 0; u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c}; @@ -251,6 +248,5 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); } -#endif return; } diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 3ced5d2fff9..0e66d261bc7 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -322,10 +322,8 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) case HW_VAR_RF_TIMING: { -#ifdef RTL8192E u8 Rf_Timing = *((u8*)val); write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); -#endif } break; @@ -340,9 +338,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) struct r8192_priv *priv = rtllib_priv(dev); u8 tempval; -#ifdef RTL8192E u8 ICVer8192, ICVer8256; -#endif u16 i,usValue, IC_Version; u16 EEPROMId; u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; @@ -773,9 +769,7 @@ bool rtl8192_adapter_start(struct net_device *dev) u32 ulRegRead; bool rtStatus = true; u8 tmpvalue; -#ifdef RTL8192E u8 ICVersion,SwitchingRegulatorOutput; -#endif bool bfirmwareok = true; u32 tmpRegA, tmpRegC, TempCCk; int i = 0; @@ -791,13 +785,11 @@ bool rtl8192_adapter_start(struct net_device *dev) start: rtl8192_pci_resetdescring(dev); priv->Rf_Mode = RF_OP_By_SW_3wire; -#ifdef RTL8192E if (priv->ResetProgress == RESET_TYPE_NORESET) { write_nic_byte(dev, ANAPAR, 0x37); mdelay(500); } -#endif priv->pFirmware->firmware_status = FW_STATUS_0_INIT; if (priv->RegRfOff == true) @@ -815,7 +807,6 @@ start: write_nic_dword(dev, CPU_GEN, ulRegRead); -#ifdef RTL8192E ICVersion = read_nic_byte(dev, IC_VERRSION); if (ICVersion >= 0x4) @@ -828,7 +819,6 @@ start: write_nic_byte(dev, SWREGULATOR, 0xb8); } } -#endif RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl8192_BBConfig(dev); if (rtStatus != true) @@ -967,9 +957,7 @@ start: rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1); rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1); -#ifdef RTL8192E write_nic_byte(dev, 0x87, 0x0); -#endif if (priv->RegRfOff == true) { RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); @@ -2057,9 +2045,7 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) { mdelay(150); -#ifdef RTL8192E - priv->bHwRfOffAction = 2; -#endif + priv->bHwRfOffAction = 2; if (!priv->rtllib->bSupportRemoteWakeUp) { diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 6c16888a626..ec1e746e13f 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -70,13 +70,11 @@ typedef enum _BaseBand_Config_Type { #define EEPROM_Default_TxPower 0x1010 #define EEPROM_ICVersion_ChannelPlan 0x7C #define EEPROM_Customer_ID 0x7B -#ifdef RTL8192E #define EEPROM_RFInd_PowerDiff 0x28 #define EEPROM_ThermalMeter 0x29 #define EEPROM_TxPwDiff_CrystalCap 0x2A #define EEPROM_TxPwIndex_CCK 0x2C #define EEPROM_TxPwIndex_OFDM_24G 0x3A -#endif #define EEPROM_Default_TxPowerLevel 0x10 #define EEPROM_IC_VER 0x7d #define EEPROM_CRC 0x7e diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index defd6976677..d03eb60d17a 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -27,9 +27,7 @@ #include "dot11d.h" #endif -#ifdef RTL8192E #include "r8192E_hwimg.h" -#endif static u32 RF_CHANNEL_TABLE_ZEBRA[] = { 0, @@ -67,7 +65,6 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) { u8 ret = 1; struct r8192_priv *priv = rtllib_priv(dev); - #ifdef RTL8192E if (priv->rf_type == RF_2T4R) ret = 0; else if (priv->rf_type == RF_1T2R) @@ -77,7 +74,6 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) ret = 0; } - #endif return ret; } void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) @@ -115,9 +111,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, if (priv->rf_chip == RF_8256) { - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - #endif if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; @@ -160,9 +154,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); - #endif } @@ -179,10 +171,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath Offset &= 0x3f; if (priv->rf_chip == RF_8256) { - - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - #endif if (Offset >= 31) { @@ -225,9 +214,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); } - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); - #endif } return; @@ -240,10 +227,8 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) return; -#ifdef RTL8192E if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) return; -#endif RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); if (priv->Rf_Mode == RF_OP_By_FW) @@ -281,10 +266,8 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u3 struct r8192_priv *priv = rtllib_priv(dev); if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) return 0; -#ifdef RTL8192E if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) return 0; -#endif down(&priv->rf_sem); if (priv->Rf_Mode == RF_OP_By_FW) { @@ -655,11 +638,8 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) (bXBTxAGC|bXCTxAGC|bXDTxAGC), dwRegValue); - #ifdef RTL8192E dwRegValue = priv->CrystalCap; rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); - #endif - } return rtStatus; @@ -675,7 +655,6 @@ bool rtl8192_BBConfig(struct net_device* dev) void rtl8192_phy_getTxPower(struct net_device* dev) { struct r8192_priv *priv = rtllib_priv(dev); - #ifdef RTL8192E priv->MCSTxPowerLevelOriginalOffset[0] = read_nic_dword(dev, rTxAGC_Rate18_06); priv->MCSTxPowerLevelOriginalOffset[1] = @@ -688,7 +667,6 @@ void rtl8192_phy_getTxPower(struct net_device* dev) read_nic_dword(dev, rTxAGC_Mcs11_Mcs08); priv->MCSTxPowerLevelOriginalOffset[5] = read_nic_dword(dev, rTxAGC_Mcs15_Mcs12); - #endif priv->DefaultInitialGain[0] = read_nic_byte(dev, rOFDM0_XAAGCCore1); priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); @@ -1208,9 +1186,7 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) static void CCK_Tx_Power_Track_BW_Switch(struct net_device *dev) { -#ifdef RTL8192E struct r8192_priv *priv = rtllib_priv(dev); -#endif if (priv->IC_Cut >= IC_VersionCut_D) CCK_Tx_Power_Track_BW_Switch_TSSI(dev); @@ -1271,9 +1247,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) else CCK_Tx_Power_Track_BW_Switch(dev); - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); - #endif break; case HT_CHANNEL_WIDTH_20_40: @@ -1293,9 +1267,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); - #ifdef RTL8192E rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); - #endif break; default: RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); @@ -1427,7 +1399,6 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation) } } -#if defined RTL8192E extern void PHY_SetRtl8192eRfOff(struct net_device* dev ) { @@ -1442,7 +1413,6 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) write_nic_byte(dev, ANAPAR_FOR_8192PciE, 0x07); } -#endif bool SetRFPowerState8190( @@ -1451,9 +1421,7 @@ SetRFPowerState8190( ) { struct r8192_priv *priv = rtllib_priv(dev); -#if defined RTL8192E PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); -#endif bool bResult = true; u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index fe900aa5767..d6020c0f98f 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -25,7 +25,6 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -#ifdef RTL8192E #define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE #define MACPHY_ArrayLength MACPHY_ArrayLengthPciE #define RadioA_ArrayLength RadioA_ArrayLengthPciE @@ -45,11 +44,10 @@ #define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array #define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray #define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray -#endif -typedef enum _SwChnlCmdID{ +typedef enum _SwChnlCmdID { CmdID_End, CmdID_SetTxPowerLevel, CmdID_BBRegWrite10, @@ -57,15 +55,15 @@ typedef enum _SwChnlCmdID{ CmdID_WritePortUshort, CmdID_WritePortUchar, CmdID_RF_WriteReg, -}SwChnlCmdID; +} SwChnlCmdID; /*--------------------------------Define structure--------------------------------*/ -typedef struct _SwChnlCmd{ +typedef struct _SwChnlCmd { SwChnlCmdID CmdID; u32 Para1; u32 Para2; u32 msDelay; -}__attribute__ ((packed)) SwChnlCmd; +} __attribute__ ((packed)) SwChnlCmd; extern u32 rtl819XMACPHY_Array_PG[]; extern u32 rtl819XPHY_REG_1T2RArray[]; @@ -75,13 +73,13 @@ extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; -typedef enum _HW90_BLOCK{ +typedef enum _HW90_BLOCK { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, HW90_BLOCK_PHY1 = 2, HW90_BLOCK_RF = 3, HW90_BLOCK_MAXIMUM = 4, -}HW90_BLOCK_E, *PHW90_BLOCK_E; +} HW90_BLOCK_E, *PHW90_BLOCK_E; typedef enum _RF90_RADIO_PATH{ RF90_PATH_A = 0, @@ -120,10 +118,7 @@ extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); -#if defined RTL8192E -extern void -PHY_SetRtl8192eRfOff(struct net_device* dev ); -#endif +extern void PHY_SetRtl8192eRfOff(struct net_device *dev); bool SetRFPowerState( diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 5dbf3740195..d8504e4d941 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2876,11 +2876,9 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); } } -#ifdef RTL8192E if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ write_nic_byte(dev, 0x173, 1); } -#endif } else diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index a738f666e70..dba17a18592 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -490,120 +490,6 @@ static void dm_bandwidth_autoswitch (struct net_device * dev) } } -#ifdef Rtl8192SE -u32 OFDMSwingTable[OFDM_Table_Length] = { - 0x7f8001fe, - 0x788001e2, - 0x71c001c7, - 0x6b8001ae, - 0x65400195, - 0x5fc0017f, - 0x5a400169, - 0x55400155, - 0x50800142, - 0x4c000130, - 0x47c0011f, - 0x43c0010f, - 0x40000100, - 0x3c8000f2, - 0x390000e4, - 0x35c000d7, - 0x32c000cb, - 0x300000c0, - 0x2d4000b5, - 0x2ac000ab, - 0x288000a2, - 0x26000098, - 0x24000090, - 0x22000088, - 0x20000080, - 0x1e400079, - 0x1c800072, - 0x1b00006c, - 0x19800066, - 0x18000060, - 0x16c0005b, - 0x15800056, - 0x14400051, - 0x1300004c, - 0x12000048, - 0x11000044, - 0x10000040, -}; - -u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { - {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, - {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, - {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, - {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, - {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, - {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, - {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, - {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, - {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, - {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, - {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, - {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, - {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, - {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, - {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, - {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, - {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, - {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, - {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, - {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, - {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, - {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, - {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, - {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, - {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, - {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, - {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, - {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, - {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, - {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, - {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, - {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, - {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} -}; - - -u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { - {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, - {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, - {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, - {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, - {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, - {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, - {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, - {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, - {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, - {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, - {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, - {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, - {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, - {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, - {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, - {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, - {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, - {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, - {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, - {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, - {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, - {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, - {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, - {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, - {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, - {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, - {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, - {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, - {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, - {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, - {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, - {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, - {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} -}; -#elif defined RTL8192E static u32 OFDMSwingTable[OFDM_Table_Length] = { 0x7f8001fe, 0x71c001c7, @@ -654,7 +540,6 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} }; -#endif #define Pw_Track_Flag 0x11d #define Tssi_Mea_Value 0x13c #define Tssi_Report_Value1 0x134 @@ -709,7 +594,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) write_nic_byte(dev, FW_Busy_Flag, 0); return; } -#ifdef RTL8192E if ((priv->rtllib->eRFPowerState != eRfOn)) { RT_TRACE(COMP_POWER_TRACKING, "we are in power save, so return\n"); @@ -718,7 +602,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) return; } -#endif continue; } @@ -818,7 +701,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else { { -#ifdef RTL8192E { if (priv->rfa_txpowertrackingindex > 0) { @@ -832,7 +714,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); } -#endif } } @@ -859,7 +740,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else { { -#ifdef RTL8192E { if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { @@ -870,7 +750,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) else rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); } -#endif } } } @@ -879,10 +758,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; }else{ { -#ifdef RTL8192E priv->CCKPresentAttentuation_difference = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; -#endif } } @@ -941,7 +818,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) write_nic_byte(dev, Pw_Track_Flag, 0); } -#ifdef RTL8192E static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) { #define ThermalMeterVal 9 @@ -1048,7 +924,6 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) } priv->txpower_count = 0; } -#endif void dm_txpower_trackingcallback(void *data) { @@ -1694,7 +1569,7 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) } -#ifdef RTL8192E + static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14) { u32 TempVal; @@ -1749,7 +1624,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rCCK0_DebugPort, TempVal); } } -#endif extern void dm_cck_txpower_adjust( struct net_device *dev, @@ -2834,7 +2708,6 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } -#ifdef RTL8192E extern void dm_CheckRfCtrlGPIO(void *data) { @@ -2902,7 +2775,7 @@ extern void dm_CheckRfCtrlGPIO(void *data) } } -#endif + void dm_rf_pathcheck_workitemcallback(void *data) { struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,rfpath_check_wq); @@ -3364,10 +3237,7 @@ static void dm_EndSWFsync(struct net_device *dev) } priv->ContiuneDiffCount = 0; -#ifdef RTL8192E write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); -#endif - } static void dm_StartSWFsync(struct net_device *dev) @@ -3403,9 +3273,7 @@ static void dm_StartSWFsync(struct net_device *dev) priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); -#ifdef RTL8192E write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd); -#endif } diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 673382b560c..910a375af51 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -1066,11 +1066,9 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, } else { - #ifdef RTL8192E if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ write_nic_byte(dev, 0x173, 1); } - #endif setKey( dev, 4, idx, From b1d5ee7004c85558f3e8330235db2d7b4f7a6a3e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 11:06:34 -0500 Subject: [PATCH 0288/1519] staging: rtl8192e: Fix edit error in removal of dead code associated with RTL8190P One too many lines were removed in an earlier patch. Rather than resubmit as a V2, this line is added back here. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 0e66d261bc7..9d13705ad4b 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1535,6 +1535,8 @@ void rtl8192_query_rxphystatus( { u8 report; + + priv->stats.numqry_phystatusCCK++; if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; From 82a7fc6d4cde3584c8c637d2482994853b44243d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 11:06:34 -0500 Subject: [PATCH 0289/1519] staging: rtl8192e: Fix kernel panics due to RX skb allocation failures This driver uses RX skb's of O(2), thus it is possible for memory fragmentation to prevent the allocation of a new one to replace a newly-received buffer. When such a failure occurs, the kernel panics. The fix is to drop an incoming packet whenever such an allocation fails. This fix matches the one done in rtlwifi for other Realtek PCI devices. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 44 +++++++++++++---------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index d8504e4d941..49f787e0550 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2550,12 +2550,18 @@ void rtl8192_rx_normal(struct net_device *dev) rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - if (pdesc->OWN){ + if (pdesc->OWN) { return; } else { + struct sk_buff *new_skb; - struct sk_buff *new_skb = NULL; - if (!priv->ops->rx_query_status_descriptor(dev, &stats, pdesc, skb)) + if (!priv->ops->rx_query_status_descriptor(dev, &stats, + pdesc, skb)) + goto done; + new_skb = dev_alloc_skb(priv->rxbuffersize); + /* if allocation of new skb failed - drop current packet + * and reuse skb */ + if (unlikely(!new_skb)) goto done; pci_unmap_single(priv->pdev, @@ -2564,24 +2570,24 @@ void rtl8192_rx_normal(struct net_device *dev) PCI_DMA_FROMDEVICE); skb_put(skb, pdesc->Length); - skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); + skb_reserve(skb, stats.RxDrvInfoSize + + stats.RxBufShift); skb_trim(skb, skb->len - 4/*sCrcLng*/); rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; - if (is_broadcast_ether_addr(rtllib_hdr->addr1)) { - }else if (is_multicast_ether_addr(rtllib_hdr->addr1)){ - }else { + if (!is_broadcast_ether_addr(rtllib_hdr->addr1) && + !is_multicast_ether_addr(rtllib_hdr->addr1)) { /* unicast packet */ unicast_packet = true; } fc = le16_to_cpu(rtllib_hdr->frame_ctl); type = WLAN_FC_GET_TYPE(fc); if (type == RTLLIB_FTYPE_MGMT) - { bLedBlinking = false; - } + if (bLedBlinking) if (priv->rtllib->LedControlHandler) - priv->rtllib->LedControlHandler(dev, LED_CTL_RX); + priv->rtllib->LedControlHandler(dev, + LED_CTL_RX); if (stats.bCRC) { if (type != RTLLIB_FTYPE_MGMT) @@ -2592,28 +2598,16 @@ void rtl8192_rx_normal(struct net_device *dev) skb_len = skb->len; - if (1) - { if (!rtllib_rx(priv->rtllib, skb, &stats)){ dev_kfree_skb_any(skb); } else { priv->stats.rxok++; - if (unicast_packet) { + if (unicast_packet) priv->stats.rxbytesunicast += skb_len; - } - } - }else{ - dev_kfree_skb_any(skb); } - new_skb = dev_alloc_skb(priv->rxbuffersize); - if (unlikely(!new_skb)) - { - printk("==========>can't alloc skb for rx\n"); - goto done; - } - skb=new_skb; - skb->dev = dev; + skb = new_skb; + skb->dev = dev; priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); From 6e1acf20a7a17ef7f0442ab0a2da640477720424 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 21:46:30 -0500 Subject: [PATCH 0290/1519] staging: rtl8192e: Remove dead code associated with CONFIG_MP Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 25 ----------- drivers/staging/rtl8192e/rtl_wx.c | 69 ----------------------------- 2 files changed, 94 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 49f787e0550..8be9be508a0 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1044,13 +1044,9 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) #endif if (priv->rtllib->state != RTLLIB_LINKED) -#ifndef CONFIG_MP rtllib_softmac_start_protocol(priv->rtllib, 0); -#endif rtllib_reset_queue(priv->rtllib); -#ifndef CONFIG_MP watch_dog_timer_callback((unsigned long) dev); -#endif if (!netif_queue_stopped(dev)) @@ -1411,9 +1407,6 @@ short rtl8192_init(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); memset(&(priv->stats),0,sizeof(struct Stats)); -#ifdef CONFIG_MP - rtl8192_init_mp(dev); -#endif rtl8192_dbgp_flag_init(dev); @@ -2724,27 +2717,9 @@ int rtl8192_close(struct net_device *dev) int rtl8192_down(struct net_device *dev, bool shutdownrf) { -#ifdef CONFIG_MP - struct r8192_priv *priv = rtllib_priv(dev); -#endif - if (rtl8192_sta_down(dev, shutdownrf) == -1) return -1; -#ifdef CONFIG_MP - if (priv->bCckContTx) { - RT_TRACE(COMP_DBG, "####RTL819X MP####stop single cck continious TX\n"); - mpt_StopCckCoNtTx(dev); - } - if (priv->bOfdmContTx) { - RT_TRACE(COMP_DBG, "####RTL819X MP####stop single ofdm continious TX\n"); - mpt_StopOfdmContTx(dev); - } - if (priv->bSingleCarrier) { - RT_TRACE(COMP_DBG, "####RTL819X MP####stop single carrier mode\n"); - MPT_ProSetSingleCarrier(dev, false); - } -#endif return 0; } diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 910a375af51..9cdc5eac33e 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -23,10 +23,6 @@ #include "dot11d.h" #endif -#ifdef CONFIG_MP -#include "r8192S_mp.h" -#endif - #define RATE_COUNT 12 u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; @@ -458,10 +454,6 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, RT_RF_POWER_STATE rtState; int ret; -#ifdef CONFIG_MP - printk("######################%s(): In MP Test Can not Scan\n",__func__); - return 0; -#endif if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ if ((ieee->state >= RTLLIB_ASSOCIATING) && (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)){ return 0; @@ -567,10 +559,6 @@ static int r8192_wx_set_essid(struct net_device *dev, if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ ; } -#ifdef CONFIG_MP - printk("######################%s(): In MP Test Can not Set Essid\n",__func__); - return 0; -#endif if (priv->bHwRadioOff == true){ printk("=========>%s():hw radio off,or Rf state is eRfOff, return\n",__func__); return 0; @@ -759,10 +747,6 @@ static int r8192_wx_set_enc(struct net_device *dev, if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ ; } -#ifdef CONFIG_MP - printk("######################%s(): In MP Test Can not Set Enc\n",__func__); - return 0; -#endif if (priv->bHwRadioOff == true) return 0; @@ -1325,48 +1309,6 @@ static const struct iw_priv_args r8192_private_args[] = { SIOCIWFIRSTPRIV + 0xc, 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" } -#ifdef CONFIG_MP - , - { - SIOCIWFIRSTPRIV + 0xe, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetChan" - } - , - { - SIOCIWFIRSTPRIV + 0xf, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetRate" - } - , - { - SIOCIWFIRSTPRIV + 0x10, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetTxPower" - } - , - { - SIOCIWFIRSTPRIV + 0x11, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "SetBW" - } - , - { - SIOCIWFIRSTPRIV + 0x12, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "TxStart" - } - , - { - SIOCIWFIRSTPRIV + 0x13, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,0, "SetSingleCarrier" - } - , - { - SIOCIWFIRSTPRIV + 0x14, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "WriteRF" - } - , - { - SIOCIWFIRSTPRIV + 0x15, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "WriteMAC" - } -#endif , { SIOCIWFIRSTPRIV + 0x16, @@ -1395,16 +1337,6 @@ static iw_handler r8192_private_handler[] = { (iw_handler)r8192se_wx_set_force_lps, (iw_handler)r8192_wx_get_adhoc_peers, (iw_handler)NULL, -#ifdef CONFIG_MP - (iw_handler)r8192_wx_mp_set_chan, - (iw_handler)r8192_wx_mp_set_txrate, - (iw_handler)r8192_wx_mp_set_txpower, - (iw_handler)r8192_wx_mp_set_bw, - (iw_handler)r8192_wx_mp_set_txstart, - (iw_handler)r8192_wx_mp_set_singlecarrier, - (iw_handler)r8192_wx_mp_write_rf, - (iw_handler)r8192_wx_mp_write_mac, -#else (iw_handler)NULL, (iw_handler)NULL, (iw_handler)NULL, @@ -1413,7 +1345,6 @@ static iw_handler r8192_private_handler[] = { (iw_handler)NULL, (iw_handler)NULL, (iw_handler)NULL, -#endif (iw_handler)r8192_wx_set_PromiscuousMode, (iw_handler)r8192_wx_get_PromiscuousMode, }; From 34a7eb3db27f3bcb6e1544523e283a9bf6acfd0d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 21:54:48 -0500 Subject: [PATCH 0291/1519] staging: rtl8192e: Remove dead code inside 'ifdef MERGE_TO_DO' Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 26 -------------------------- drivers/staging/rtl8192e/rtl_ps.c | 6 ------ drivers/staging/rtl8192e/rtllib_rx.c | 3 --- 3 files changed, 35 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 9d13705ad4b..267efb421f5 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -166,24 +166,6 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) priv->slot_time = val[0]; write_nic_byte(dev, SLOT_TIME, val[0]); -#ifdef MERGE_TO_DO - if (priv->rtllib->current_network.qos_data.supported !=0) - { - for (eACI = 0; eACI < AC_MAX; eACI++) - { - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&eACI)); - } - } - else - { - u8 u1bAIFS = aSifsTime + (2 * priv->slot_time); - - write_nic_byte(dev, EDCAPARA_VO, u1bAIFS); - write_nic_byte(dev, EDCAPARA_VI, u1bAIFS); - write_nic_byte(dev, EDCAPARA_BE, u1bAIFS); - write_nic_byte(dev, EDCAPARA_BK, u1bAIFS); - } -#endif } break; @@ -205,11 +187,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) case HW_VAR_AC_PARAM: { u8 pAcParam = *((u8*)val); -#ifdef MERGE_TO_DO - u32 eACI = GET_WMM_AC_PARAM_ACI(pAcParam); -#else u32 eACI = pAcParam; -#endif u8 u1bAIFS; u32 u4bAcParam; u8 mode = priv->rtllib->mode; @@ -256,11 +234,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) { struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; u8 pAcParam = *((u8*)val); -#ifdef MERGE_TO_DO - u32 eACI = GET_WMM_AC_PARAM_ACI(pAciAifsn); -#else u32 eACI = pAcParam; -#endif PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); u8 ACM = pAciAifsn->f.ACM; u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 786106f0d8c..5c990076212 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -443,12 +443,6 @@ bool PlatformSwitchClkReq(struct net_device *dev, u8 value) Buffer= value; -#ifdef MERGE_TO_DO - if (Adapter->bDriverIsGoingToPnpSetPowerSleep && pDevice->RegSupportLowPowerState - && value == 0x0) - return false; -#endif - pci_write_config_byte(priv->pdev,0x81,value); bResult = true; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 96f824ba812..7e0fabad64d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -894,9 +894,6 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS) rtllib_indicate_packets(ieee, RfdArray, RfdCnt); pTS->RxIndicateSeq = 0xffff; - -#ifdef MERGE_TO_DO -#endif } From 15e7650e880b410d0a4c80aa586b5b2f96be3a61 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:04:11 -0500 Subject: [PATCH 0292/1519] staging: rtl8192e: Remove dead code involved with TO_DO_LIST Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 50 ------------------- drivers/staging/rtl8192e/r8192E_phy.c | 61 ----------------------- drivers/staging/rtl8192e/rtl_ps.c | 6 --- drivers/staging/rtl8192e/rtllib_softmac.c | 3 -- drivers/staging/rtl8192e/rtllib_tx.c | 22 -------- 5 files changed, 142 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 267efb421f5..83f8589ef72 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -613,42 +613,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; #endif -#ifdef TO_DO_LIST - switch (priv->CustomerID) - { - case RT_CID_DEFAULT: - priv->LedStrategy = SW_LED_MODE1; - break; - - case RT_CID_819x_CAMEO: - priv->LedStrategy = SW_LED_MODE2; - break; - - case RT_CID_819x_RUNTOP: - priv->LedStrategy = SW_LED_MODE3; - break; - - case RT_CID_819x_Netcore: - priv->LedStrategy = SW_LED_MODE4; - break; - - case RT_CID_Nettronix: - priv->LedStrategy = SW_LED_MODE5; - break; - - case RT_CID_PRONET: - priv->LedStrategy = SW_LED_MODE6; - break; - - case RT_CID_TOSHIBA: - - default: - priv->LedStrategy = SW_LED_MODE1; - break; - } - RT_TRACE(COMP_INIT, "LedStrategy = %d \n", priv->LedStrategy); -#endif - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; else @@ -832,20 +796,6 @@ start: write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); write_nic_dword(dev, RCR, priv->ReceiveConfig); -#ifdef TO_DO_LIST - if (priv->bInHctTest) - { - write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\ - NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM <bInHctTest) - { - RT_TRACE(COMP_PHY, "Rtl819XMACPHY_ArrayDTM\n"); - dwArrayLen = MACPHY_ArrayLengthDTM; - pdwArray = Rtl819XMACPHY_ArrayDTM; - } - else if (priv->bTXPowerDataReadFromEEPORM) -#endif if (priv->bTXPowerDataReadFromEEPORM) { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); @@ -397,26 +388,6 @@ void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType) u32* Rtl819XAGCTAB_Array_Table = NULL; u16 AGCTAB_ArrayLen, PHY_REGArrayLen = 0; struct r8192_priv *priv = rtllib_priv(dev); -#ifdef TO_DO_LIST - u32 *rtl8192PhyRegArrayTable = NULL, *rtl8192AgcTabArrayTable = NULL; - if (dev->bInHctTest) - { - AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM; - Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM; - - if (priv->RF_Type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLengthDTM; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArrayDTM; - } - else if (priv->RF_Type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLengthDTM; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArrayDTM; - } - } - else -#endif { AGCTAB_ArrayLen = AGCTAB_ArrayLength; Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; @@ -839,10 +810,6 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) switch (priv->rf_chip) { case RF_8225: -#ifdef TO_DO_LIST - PHY_SetRF8225CckTxPower(dev, powerlevel); - PHY_SetRF8225OfdmTxPower(dev, powerlevelOFDM24G); -#endif break; case RF_8256: @@ -1278,9 +1245,6 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) switch ( priv->rf_chip ) { case RF_8225: -#ifdef TO_DO_LIST - PHY_SetRF8225Bandwidth(dev, pHalData->CurrentChannelBW); -#endif break; case RF_8256: @@ -1489,13 +1453,6 @@ SetRFPowerState8190( QueueID++; continue; } -#ifdef TO_DO_LIST - else if (IsLowPowerState(Adapter)) - { - RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID); - break; - } -#endif else { RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); @@ -1528,14 +1485,6 @@ SetRFPowerState8190( QueueID++; continue; } -#ifdef TO_DO_LIST - else if (IsLowPowerState(Adapter)) - { - RT_TRACE(COMP_POWER, - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID); - break; - } -#endif else { RT_TRACE(COMP_POWER, @@ -1562,16 +1511,6 @@ SetRFPowerState8190( { PHY_SetRtl8192eRfOff(dev); } -#ifdef TO_DO_LIST - if (pMgntInfo->RfOffReason == RF_CHANGE_BY_IPS ) - { - Adapter->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK); - } - else - { - Adapter->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF); - } -#endif } break; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 5c990076212..dfdf3492206 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -561,13 +561,7 @@ bool PlatformSetPMCSR(struct net_device *dev,u8 value,bool bTempSetting) if (bSetFunc) { if (Buffer) { -#ifdef TO_DO_LIST - RT_DISABLE_FUNC(Adapter, DF_IO_D3_BIT); -#endif } else { -#ifdef TO_DO_LIST - RT_ENABLE_FUNC(Adapter, DF_IO_D3_BIT); -#endif } } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index c9c5df4c994..9f7227eb6d8 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -4018,9 +4018,6 @@ rtllib_MgntDisconnect( } if ( rtllib->iw_mode == IW_MODE_INFRA ) { -#ifdef TO_DO_LIST - SecClearAllKeys(Adapter); -#endif rtllib_MgntDisconnectAP(rtllib, asRsn); } diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 7662bf5bf3e..3aa6756f07a 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -333,12 +333,6 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb return; if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1)) return; -#ifdef TO_DO_LIST - if (pTcb->PacketLength >= 4096) - return; - if (!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter)) - return; -#endif if (tcb_desc->bdhcp || ieee->CntAfterLink<2) return; @@ -552,22 +546,6 @@ NO_PROTECTION: void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc) { -#ifdef TO_DO_LIST - if (!IsDataFrame(pFrame)) - { - pTcb->bTxDisableRateFallBack = true; - pTcb->bTxUseDriverAssingedRate = true; - pTcb->RATRIndex = 7; - return; - } - - if (pMgntInfo->ForcedDataRate!= 0) - { - pTcb->bTxDisableRateFallBack = true; - pTcb->bTxUseDriverAssingedRate = true; - return; - } -#endif if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; From d064307a1a67c564caf69e1555d1aa62662217fb Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:08:32 -0500 Subject: [PATCH 0293/1519] staging: rtl8192e: Remove dead code involved with TO_DO Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 41 +++-------------------- drivers/staging/rtl8192e/rtllib_softmac.c | 18 ---------- 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 6c2e44f956d..8224a56aa9c 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1531,44 +1531,13 @@ SetRFPowerState8190( if (bResult) { priv->rtllib->eRFPowerState = eRFPowerState; - switch (priv->rf_chip ) - { - case RF_8256: - switch (priv->rtllib->eRFPowerState) - { - case eRfOff: - if (priv->rtllib->RfOffReason==RF_CHANGE_BY_IPS ) { - #ifdef TO_DO - dev->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK); - #endif - } else { - #ifdef TO_DO - dev->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF); - #endif - } - break; - - case eRfOn: - if ( priv->rtllib->state == RTLLIB_LINKED) { - #ifdef TO_DO - dev->HalFunc.LedControlHandler(dev, LED_CTL_LINK); - #endif - } else { - #ifdef TO_DO - dev->HalFunc.LedControlHandler(dev, LED_CTL_NO_LINK); - #endif - } - break; - - default: - break; - } - + switch (priv->rf_chip) { + case RF_8256: break; - default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); - break; + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; } } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9f7227eb6d8..b2244688725 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3974,15 +3974,6 @@ rtllib_MgntDisconnectAP( { bool bFilterOutNonAssociatedBSSID = false; - -#ifdef TO_DO - if ( pMgntInfo->SecurityInfo.AuthMode > RT_802_11AuthModeAutoSwitch || - (pMgntInfo->bAPSuportCCKM && pMgntInfo->bCCX8021xenable) ) - { - SecClearAllKeys(rtllib->dev); - RT_TRACE(COMP_SEC, DBG_LOUD,("======>CCKM clear key...")) - } -#endif bFilterOutNonAssociatedBSSID = false; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); @@ -4001,15 +3992,6 @@ rtllib_MgntDisconnect( rtllib->sta_wake_up(rtllib->dev); } -#ifdef TO_DO - if (pMgntInfo->mActingAsAp) - { - RT_TRACE(COMP_MLME, DBG_LOUD, ("MgntDisconnect() ===> AP_DisassociateAllStation\n")); - AP_DisassociateAllStation(rtllib->dev, unspec_reason); - return true; - } -#endif - if ( rtllib->state == RTLLIB_LINKED ) { if ( rtllib->iw_mode == IW_MODE_ADHOC ) From a97dc3afc0d1f33fb8fff8e57f3644b3d09bacd0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:16:06 -0500 Subject: [PATCH 0294/1519] staging: rtl8192e: Remove dead code associated with USB_USE_ALIGNMENT Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 23 ----- drivers/staging/rtl8192e/rtllib_softmac.c | 117 ---------------------- drivers/staging/rtl8192e/rtllib_tx.c | 13 --- 3 files changed, 153 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 08b90678539..3d9f7601e87 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -91,13 +91,7 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, PBA_REC RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); return NULL; } -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr) + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); -#endif if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); @@ -106,12 +100,6 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, PBA_REC memset(skb->data, 0, sizeof( struct rtllib_hdr_3addr)); -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); BAReq = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); @@ -174,24 +162,13 @@ static struct sk_buff* rtllib_DELBA( DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr) + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); -#endif if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif skb_reserve(skb, ieee->tx_headroom); Delba = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b2244688725..a3a0397e10f 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -382,25 +382,12 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) rate_len = rtllib_MFIE_rate_len(ieee); -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr; - int alignment; - skb = dev_alloc_skb(sizeof(struct rtllib_probe_request) + - 2 + len + rate_len + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(sizeof(struct rtllib_probe_request) + 2 + len + rate_len + ieee->tx_headroom); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); @@ -858,22 +845,10 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, struct rtllib_authentication *auth; int len = 0; len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr; - int alignment; - skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); auth = (struct rtllib_authentication *) @@ -994,22 +969,10 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +erp_len +wpa_ie_len +ieee->tx_headroom; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(beacon_size + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(beacon_size); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); @@ -1098,23 +1061,11 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) unsigned int rate_len = rtllib_MFIE_rate_len(ieee); int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); assoc = (struct rtllib_assoc_response_frame *) @@ -1160,24 +1111,12 @@ struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest struct sk_buff *skb = NULL; struct rtllib_authentication *auth; int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len); -#endif if (!skb) return NULL; skb->len = sizeof(struct rtllib_authentication); -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); auth = (struct rtllib_authentication *) @@ -1201,21 +1140,10 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) struct sk_buff *skb; struct rtllib_hdr_3addr* hdr; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); @@ -1238,21 +1166,10 @@ struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) struct sk_buff *skb; struct rtllib_pspoll_hdr* hdr; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); @@ -1412,23 +1329,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru + cxvernum_ie_len + ieee->tx_headroom; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - skb = dev_alloc_skb(len + USB_512B_ALIGNMENT_SIZE); -#else skb = dev_alloc_skb(len); -#endif if (!skb) return NULL; -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif - skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_assoc_request_frame *) @@ -3743,24 +3648,13 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, { struct sk_buff *skb; struct rtllib_disauth *disauth; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE; -#else int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; -#endif skb = dev_alloc_skb(len); if (!skb) { return NULL; } -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif skb_reserve(skb, ieee->tx_headroom); disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); @@ -3780,24 +3674,13 @@ inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, { struct sk_buff *skb; struct rtllib_disassoc *disass; -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; - int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom + USB_512B_ALIGNMENT_SIZE; -#else int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; -#endif skb = dev_alloc_skb(len); if (!skb) { return NULL; } -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)skb->data; - alignment = Tmpaddr & 0x1ff; - skb_reserve(skb,(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif skb_reserve(skb, ieee->tx_headroom); disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 3aa6756f07a..f93530e53af 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -243,10 +243,6 @@ void rtllib_txb_free(struct rtllib_txb *txb) { struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, int gfp_mask) { -#ifdef USB_USE_ALIGNMENT - u32 Tmpaddr=0; - int alignment=0; -#endif struct rtllib_txb *txb; int i; txb = kmalloc( @@ -260,20 +256,11 @@ struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, txb->frag_size = txb_size; for (i = 0; i < nr_frags; i++) { -#ifdef USB_USE_ALIGNMENT - txb->fragments[i] = dev_alloc_skb(txb_size+USB_512B_ALIGNMENT_SIZE); -#else txb->fragments[i] = dev_alloc_skb(txb_size); -#endif if (unlikely(!txb->fragments[i])) { i--; break; } -#ifdef USB_USE_ALIGNMENT - Tmpaddr = (u32)(txb->fragments[i]->data); - alignment = Tmpaddr & 0x1ff; - skb_reserve(txb->fragments[i],(USB_512B_ALIGNMENT_SIZE - alignment)); -#endif memset(txb->fragments[i]->cb, 0, sizeof(txb->fragments[i]->cb)); } if (unlikely(i != nr_frags)) { From 2e94b0bbbc247049da6e7bd5b3299e7c78df748d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:23:27 -0500 Subject: [PATCH 0295/1519] staging: rtl8192e: Remove dead code associated with CONFIG_ASPM_OR_D3 Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 4 - drivers/staging/rtl8192e/rtl_core.c | 119 ------------ drivers/staging/rtl8192e/rtl_core.h | 3 - drivers/staging/rtl8192e/rtl_ps.c | 269 -------------------------- drivers/staging/rtl8192e/rtl_ps.h | 15 -- 5 files changed, 410 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 83f8589ef72..180869272f8 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -716,10 +716,6 @@ bool rtl8192_adapter_start(struct net_device *dev) RT_TRACE(COMP_INIT, "====>%s()\n", __func__); priv->being_init_adapter = true; -#ifdef CONFIG_ASPM_OR_D3 - RT_DISABLE_ASPM(dev); -#endif - start: rtl8192_pci_resetdescring(dev); priv->Rf_Mode = RF_OP_By_SW_3wire; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 8be9be508a0..976d17bdeed 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1114,9 +1114,6 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) spin_unlock_irqrestore(&priv->rf_ps_lock,flags); udelay(100); memset(&priv->rtllib->current_network, 0 , offsetof(struct rtllib_network, list)); -#ifdef CONFIG_ASPM_OR_D3 - RT_ENABLE_ASPM(dev); -#endif RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; @@ -1318,9 +1315,6 @@ static void rtl8192_init_priv_lock(struct r8192_priv* priv) spin_lock_init(&priv->ps_lock); spin_lock_init(&priv->rf_lock); spin_lock_init(&priv->rt_h2c_lock); -#ifdef CONFIG_ASPM_OR_D3 - spin_lock_init(&priv->D3_lock); -#endif sema_init(&priv->wx_sem,1); sema_init(&priv->rf_sem,1); mutex_init(&priv->mutex); @@ -1461,112 +1455,6 @@ short rtl8192_init(struct net_device *dev) return 0; } -#if defined CONFIG_ASPM_OR_D3 -static void -rtl8192_update_default_setting(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); - - pPSC->RegRfPsLevel = 0; - priv->bSupportASPM = 0; - - - pPSC->RegAMDPciASPM = priv->RegAMDPciASPM ; - switch (priv->RegPciASPM) - { - case 0: - break; - - case 1: - pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; - break; - - case 2: - pPSC->RegRfPsLevel |= (RT_RF_LPS_LEVEL_ASPM | RT_RF_OFF_LEVL_CLK_REQ); - break; - - case 3: - pPSC->RegRfPsLevel &= ~(RT_RF_LPS_LEVEL_ASPM); - pPSC->RegRfPsLevel |= (RT_RF_PS_LEVEL_ALWAYS_ASPM | RT_RF_OFF_LEVL_CLK_REQ); - break; - - case 4: - pPSC->RegRfPsLevel &= ~(RT_RF_LPS_LEVEL_ASPM | RT_RF_OFF_LEVL_CLK_REQ); - pPSC->RegRfPsLevel |= RT_RF_PS_LEVEL_ALWAYS_ASPM; - break; - } - - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; - - switch (priv->RegHwSwRfOffD3) - { - case 1: - if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; - break; - - case 2: - if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; - break; - - case 3: - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_PCI_D3; - break; - } - - - switch (priv->RegSupportPciASPM) - { - case 0: - { - bool bSupportASPM = false; - priv->bSupportASPM = bSupportASPM; - } - break; - - case 1: - { - bool bSupportASPM = true; - priv->bSupportASPM = bSupportASPM; - } - break; - - case 2: - if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_INTEL) - { - bool bSupportASPM = true; - priv->bSupportASPM = bSupportASPM; - } - break; - - default: - break; - } -} -#endif - -#if defined CONFIG_ASPM_OR_D3 -static void -rtl8192_initialize_adapter_common(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); - - rtl8192_update_default_setting(dev); - -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_PS_LEVEL_ALWAYS_ASPM) - { - RT_ENABLE_ASPM(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_PS_LEVEL_ALWAYS_ASPM); - } -#endif -} -#endif - /*************************************************************************** -------------------------------WATCHDOG STUFF--------------------------- ***************************************************************************/ @@ -3262,10 +3150,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, } #endif -#if defined CONFIG_ASPM_OR_D3 - rtl8192_initialize_adapter_common(dev); -#endif - RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; @@ -3315,9 +3199,6 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) rtl8192_proc_remove_one(dev); rtl8192_down(dev,true); deinit_hal_dm(dev); -#ifdef CONFIG_ASPM_OR_D3 - ; -#endif if (priv->pFirmware) { vfree(priv->pFirmware); priv->pFirmware = NULL; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 1e56ceb874e..239c46e8bfa 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -639,9 +639,6 @@ typedef struct r8192_priv spinlock_t rf_ps_lock; spinlock_t rw_lock; spinlock_t rt_h2c_lock; -#ifdef CONFIG_ASPM_OR_D3 - spinlock_t D3_lock; -#endif spinlock_t rf_lock; spinlock_t ps_lock; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index dfdf3492206..39baa596e29 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -33,9 +33,6 @@ void rtl8192_hw_sleep_down(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; -#ifdef CONFIG_ASPM_OR_D3 - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); -#endif spin_lock_irqsave(&priv->rf_ps_lock,flags); if (priv->RFChangeInProgress) { spin_unlock_irqrestore(&priv->rf_ps_lock,flags); @@ -51,13 +48,6 @@ void rtl8192_hw_sleep_down(struct net_device *dev) } #endif MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) - { - RT_ENABLE_ASPM(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); - } -#endif } void rtl8192_hw_sleep_wq(void *data) @@ -71,9 +61,6 @@ void rtl8192_hw_wakeup(struct net_device* dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; -#ifdef CONFIG_ASPM_OR_D3 - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); -#endif spin_lock_irqsave(&priv->rf_ps_lock,flags); if (priv->RFChangeInProgress) { spin_unlock_irqrestore(&priv->rf_ps_lock,flags); @@ -82,12 +69,6 @@ void rtl8192_hw_wakeup(struct net_device* dev) return; } spin_unlock_irqrestore(&priv->rf_ps_lock,flags); -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM) { - RT_DISABLE_ASPM(dev); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); - } -#endif RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS,false); } @@ -147,30 +128,8 @@ void InactivePsWorkItemCallback(struct net_device *dev) RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", \ pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->eInactivePowerState == eRfOn) - { - - if ((pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM)) - { - RT_DISABLE_ASPM(dev); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } - } -#endif MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->eInactivePowerState == eRfOff) - { - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_ASPM) - { - RT_ENABLE_ASPM(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_ASPM); - } - } -#endif - pPSC->bSwRfProcessing = false; RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <--------- \n"); } @@ -329,13 +288,6 @@ void LeisurePSLeave(struct net_device *dev) { if (priv->rtllib->ps != RTLLIB_PS_DISABLED) { -#ifdef CONFIG_ASPM_OR_D3 - if (pPSC->RegRfPsLevel & RT_RF_LPS_LEVEL_ASPM && RT_IN_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM)) - { - RT_DISABLE_ASPM(dev); - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_LPS_LEVEL_ASPM); - } -#endif RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n"); MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_DISABLED); @@ -349,224 +301,3 @@ void LeisurePSLeave(struct net_device *dev) } } } - -#ifdef CONFIG_ASPM_OR_D3 - -void -PlatformDisableHostL0s(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 PciCfgAddrPort=0; - u8 Num4Bytes; - u8 uPciBridgeASPMSetting = 0; - - - if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || - (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) - { - printk("PlatformDisableHostL0s(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); - return; - } - - PciCfgAddrPort= (priv->NdisAdapter.PciBridgeBusNum << 16)|(priv->NdisAdapter.PciBridgeDevNum<< 11)|(priv->NdisAdapter.PciBridgeFuncNum << 8)|(1 << 31); - Num4Bytes = (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10)/4; - - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); - - NdisRawReadPortUchar(PCI_CONF_DATA, &uPciBridgeASPMSetting); - - if (uPciBridgeASPMSetting & BIT0) - uPciBridgeASPMSetting &= ~(BIT0); - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); - NdisRawWritePortUchar(PCI_CONF_DATA, uPciBridgeASPMSetting); - - udelay(50); - - printk("PlatformDisableHostL0s():PciBridge BusNumber[%x], DevNumbe[%x], FuncNumber[%x], Write reg[%x] = %x\n", - priv->NdisAdapter.PciBridgeBusNum, priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum, - (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10), (priv->NdisAdapter.PciBridgeLinkCtrlReg | (priv->RegDevicePciASPMSetting&~BIT0))); -} - -bool -PlatformEnable92CEBackDoor(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - bool bResult = true; - u8 value; - - if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || - (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) - { - RT_TRACE(COMP_INIT, "PlatformEnableASPM(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); - return false; - } - - pci_read_config_byte(priv->pdev, 0x70f, &value); - - if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_INTEL) - { - value |= BIT7; - } - else - { - value = 0x23; - } - - pci_write_config_byte(priv->pdev, 0x70f, value); - - - pci_read_config_byte(priv->pdev, 0x719, &value); - value |= (BIT3|BIT4); - pci_write_config_byte(priv->pdev, 0x719, value); - - - return bResult; -} - -bool PlatformSwitchDevicePciASPM(struct net_device *dev, u8 value) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - bool bResult = false; - - pci_write_config_byte(priv->pdev, 0x80, value); - - return bResult; -} - -bool PlatformSwitchClkReq(struct net_device *dev, u8 value) -{ - bool bResult = false; - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u8 Buffer; - - Buffer= value; - - pci_write_config_byte(priv->pdev,0x81,value); - bResult = true; - - return bResult; -} - -void -PlatformDisableASPM(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); - u32 PciCfgAddrPort=0; - u8 Num4Bytes; - u8 LinkCtrlReg; - u16 PciBridgeLinkCtrlReg, ASPMLevel=0; - - if (priv->NdisAdapter.PciBridgeVendor == PCI_BRIDGE_VENDOR_UNKNOWN) - { - RT_TRACE(COMP_POWER, "%s(): Disable ASPM. Recognize the Bus of PCI(Bridge) as UNKNOWN.\n",__func__); - } - - - LinkCtrlReg = priv->NdisAdapter.LinkCtrlReg; - PciBridgeLinkCtrlReg = priv->NdisAdapter.PciBridgeLinkCtrlReg; - - ASPMLevel |= BIT0|BIT1; - LinkCtrlReg &=~ASPMLevel; - PciBridgeLinkCtrlReg &=~(BIT0|BIT1); - - if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || - (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) - { - } else { - PciCfgAddrPort= (priv->NdisAdapter.PciBridgeBusNum << 16)|(priv->NdisAdapter.PciBridgeDevNum<< 11)|(priv->NdisAdapter.PciBridgeFuncNum << 8)|(1 << 31); - Num4Bytes = (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10)/4; - - NdisRawWritePortUlong(PCI_CONF_ADDRESS , PciCfgAddrPort+(Num4Bytes << 2)); - - NdisRawWritePortUchar(PCI_CONF_DATA, PciBridgeLinkCtrlReg); - RT_TRACE(COMP_POWER, "PlatformDisableASPM():PciBridge BusNumber[%x], DevNumbe[%x], FuncNumber[%x], Write reg[%x] = %x\n", - priv->NdisAdapter.PciBridgeBusNum, priv->NdisAdapter.PciBridgeDevNum, priv->NdisAdapter.PciBridgeFuncNum, - (priv->NdisAdapter.PciBridgePCIeHdrOffset+0x10), PciBridgeLinkCtrlReg); - - udelay(50); - } -} - -void PlatformEnableASPM(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); - u16 ASPMLevel = 0; - u32 PciCfgAddrPort=0; - u8 Num4Bytes; - u8 uPciBridgeASPMSetting = 0; - u8 uDeviceASPMSetting = 0; - - - if ( (priv->NdisAdapter.BusNumber == 0xff && priv->NdisAdapter.DevNumber == 0xff && priv->NdisAdapter.FuncNumber == 0xff) || - (priv->NdisAdapter.PciBridgeBusNum == 0xff && priv->NdisAdapter.PciBridgeDevNum == 0xff && priv->NdisAdapter.PciBridgeFuncNum == 0xff) ) - { - RT_TRACE(COMP_INIT, "PlatformEnableASPM(): Fail to enable ASPM. Cannot find the Bus of PCI(Bridge).\n"); - return; - } - - ASPMLevel |= priv->RegDevicePciASPMSetting; - uDeviceASPMSetting = priv->NdisAdapter.LinkCtrlReg; - - uDeviceASPMSetting |= ASPMLevel; - - PlatformSwitchDevicePciASPM(dev, uDeviceASPMSetting); - - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_CLK_REQ) { - PlatformSwitchClkReq(dev,(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_CLK_REQ); - } - udelay(100); - - udelay(100); -} - -u32 PlatformResetPciSpace(struct net_device *dev,u8 Value) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - pci_write_config_byte(priv->pdev,0x04,Value); - - return 1; - -} -bool PlatformSetPMCSR(struct net_device *dev,u8 value,bool bTempSetting) -{ - bool bResult = false; - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u8 Buffer; - bool bActuallySet=false, bSetFunc=false; - unsigned long flag; - - Buffer= value; - spin_lock_irqsave(&priv->D3_lock,flag); - if (bActuallySet) { - if (Buffer) { - PlatformSwitchClkReq(dev, 0x01); - } else { - PlatformSwitchClkReq(dev, 0x00); - } - - pci_write_config_byte(priv->pdev,0x44,Buffer); - RT_TRACE(COMP_POWER, "PlatformSetPMCSR(): D3(value: %d)\n", Buffer); - - bResult = true; - if (!Buffer) { - PlatformResetPciSpace(dev, 0x06); - PlatformResetPciSpace(dev, 0x07); - } - - if (bSetFunc) { - if (Buffer) { - } else { - } - } - - } - spin_unlock_irqrestore(&priv->D3_lock,flag); - return bResult; -} -#endif diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index be85ac9022f..d97a6edd1e8 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -32,21 +32,6 @@ struct net_device; #define RT_CHECK_FOR_HANG_PERIOD 2 #define INIT_DEFAULT_CHAN 1 -#if defined CONFIG_ASPM_OR_D3 -#define RT_DISABLE_ASPM(dev) PlatformDisableASPM(dev) -#define RT_ENABLE_ASPM(dev) PlatformEnableASPM(dev) -#define RT_ENTER_D3(dev, _bTempSetting) PlatformSetPMCSR(dev, 0x03, _bTempSetting) -#define RT_LEAVE_D3(dev, _bTempSetting) PlatformSetPMCSR(dev, 0, _bTempSetting) - -#define RT_DISABLE_HOST_L0S(_PADAPTER) PlatformDisableHostL0s(dev) - -void PlatformDisableHostL0s(struct net_device *dev); -bool PlatformEnable92CEBackDoor(struct net_device *dev); -void PlatformDisableASPM(struct net_device *dev); -void PlatformEnableASPM(struct net_device *dev); -u32 PlatformResetPciSpace(struct net_device *dev,u8 Value); -#endif - void rtl8192_hw_wakeup(struct net_device *dev); void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); void rtllib_ips_leave_wq(struct net_device *dev); From 4ebba6d6e34796bdc5ead494111fb19c619eb599 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:26:33 -0500 Subject: [PATCH 0296/1519] staging: rtl8192e: Remove dead code associated with COMPATIBLE_WITH_RALINK_MESH Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a3a0397e10f..281d51bdc54 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2561,11 +2561,6 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *s case RTLLIB_STYPE_MANAGE_ACT: rtllib_process_action(ieee,skb); break; -#ifdef COMPATIBLE_WITH_RALINK_MESH - case RTLLIB_STYPE_MESH_ACT: - rtllib_process_action_mesh(ieee,skb,rx_stats); - break; -#endif default: return -1; break; From 0e3b1830591d7d5460e2346cdb535d209de2cab9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 12 Jul 2011 22:30:01 -0500 Subject: [PATCH 0297/1519] staging: rtl8192e: Remove dead code associated with PF_SYNCTHREAD Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 4 ---- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 976d17bdeed..db3c64974a7 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1324,11 +1324,7 @@ static void rtl8192_init_priv_task(struct net_device* dev) { struct r8192_priv *priv = rtllib_priv(dev); -#ifdef PF_SYNCTHREAD - priv->priv_wq = create_workqueue(DRV_NAME,0); -#else priv->priv_wq = create_workqueue(DRV_NAME); -#endif INIT_WORK_RSL(&priv->reset_wq, (void*)rtl8192_restart, dev); INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void*)IPSLeave_wq, dev); INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 281d51bdc54..3cbfdeb6290 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3262,11 +3262,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) (unsigned long) ieee); -#ifdef PF_SYNCTHREAD - ieee->wq = create_workqueue(DRV_NAME,0); -#else ieee->wq = create_workqueue(DRV_NAME); -#endif INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); From e755463c216b76f07692a83c6cd7197fa31e5d89 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 00:13:20 -0500 Subject: [PATCH 0298/1519] staging: rtl8192e: Remove dead code from removal of ENABLE_TKIP11N Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 3cbfdeb6290..1d350446354 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1273,11 +1273,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru encrypt = 0; } -#ifdef ENABLE_TKIP11N - if (ieee->bForcedBgMode == true) -#else if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) -#endif { ieee->pHTInfo->bEnableHT = 0; ieee->mode = WIRELESS_MODE_G; From 5b774ec296657f219890adb274e7455ec2e21af6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 00:16:54 -0500 Subject: [PATCH 0299/1519] staging: rtl8192e: Remove references to ENABLE_GPIO_RADIO_CTL This configuration variable is set in the make file. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 1 - drivers/staging/rtl8192e/rtl_core.c | 6 ------ drivers/staging/rtl8192e/rtl_pm.c | 4 ---- 3 files changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index 594abc0a95f..9ad6b4e4469 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -1,6 +1,5 @@ ccflags-y += -DEEPROM_OLD_FORMAT_SUPPORT=1 ccflags-y += -DUSE_FW_SOURCE_IMG_FILE -ccflags-y += -DENABLE_GPIO_RADIO_CTL ccflags-y += -DCONFIG_PM_RTL ccflags-y += -DCONFIG_PM ccflags-y += -DENABLE_DOT11D diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index db3c64974a7..062e19bad64 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1037,11 +1037,9 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; -#ifdef ENABLE_GPIO_RADIO_CTL if (priv->polling_timer_on == 0){ check_rfctrl_gpio_timer((unsigned long)dev); } -#endif if (priv->rtllib->state != RTLLIB_LINKED) rtllib_softmac_start_protocol(priv->rtllib, 0); @@ -3131,11 +3129,9 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, } rtl8192_proc_init_one(dev); -#ifdef ENABLE_GPIO_RADIO_CTL if (priv->polling_timer_on == 0){ check_rfctrl_gpio_timer((unsigned long)dev); } -#endif #ifdef CONFIG_RTL_RFKILL if (priv->ops->init_before_adapter_start) { priv->ops->init_before_adapter_start(dev); @@ -3186,11 +3182,9 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) priv = rtllib_priv(dev); -#ifdef ENABLE_GPIO_RADIO_CTL del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; -#endif rtl_debug_module_remove(priv); rtl8192_proc_remove_one(dev); rtl8192_down(dev,true); diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c index bcefe2d6e04..af1c8201e01 100644 --- a/drivers/staging/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -38,11 +38,9 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); printk("============> r8192E suspend call.\n"); -#ifdef ENABLE_GPIO_RADIO_CTL del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; -#endif if (!netif_running(dev)){ printk("RTL819XE:UI is open out of suspend function\n"); @@ -113,11 +111,9 @@ int rtl8192E_resume (struct pci_dev *pdev) pci_enable_wake(pdev, PCI_D0, 0); -#ifdef ENABLE_GPIO_RADIO_CTL if (priv->polling_timer_on == 0){ check_rfctrl_gpio_timer((unsigned long)dev); } -#endif if (!netif_running(dev)){ printk("RTL819XE:UI is open out of resume function\n"); From 2b259bd38fdfdf6a4103234172eafc13d7f774b6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 09:35:45 -0500 Subject: [PATCH 0300/1519] staging: rtl8192e: Remove ifdefs that depend on ENABLE_DOT11D This configuration parameter is selected in the Makefile, thus the conditional code can be removed. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 1 - drivers/staging/rtl8192e/r8192E_dev.c | 2 -- drivers/staging/rtl8192e/r8192E_phy.c | 4 ---- drivers/staging/rtl8192e/rtl_core.c | 18 ---------------- drivers/staging/rtl8192e/rtl_core.h | 2 -- drivers/staging/rtl8192e/rtl_wx.c | 2 -- drivers/staging/rtl8192e/rtllib.h | 6 ------ drivers/staging/rtl8192e/rtllib_rx.c | 10 --------- drivers/staging/rtl8192e/rtllib_softmac.c | 22 -------------------- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ---- 10 files changed, 71 deletions(-) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index 9ad6b4e4469..a56900f8341 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -2,7 +2,6 @@ ccflags-y += -DEEPROM_OLD_FORMAT_SUPPORT=1 ccflags-y += -DUSE_FW_SOURCE_IMG_FILE ccflags-y += -DCONFIG_PM_RTL ccflags-y += -DCONFIG_PM -ccflags-y += -DENABLE_DOT11D ccflags-y += -DHAVE_NET_DEVICE_OPS ccflags-y += -DENABLE_DOT11D diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 180869272f8..51195325424 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -609,9 +609,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) priv->ChannelPlan = 0; -#ifdef ENABLE_DOT11D priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; -#endif if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 8224a56aa9c..c462d74c4de 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -23,9 +23,7 @@ #include "r8190P_rtl8256.h" #include "r8192E_phy.h" #include "rtl_dm.h" -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif #include "r8192E_hwimg.h" @@ -871,13 +869,11 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); -#ifdef ENABLE_DOT11D if (!IsLegalChannel(priv->rtllib, channel)) { RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); return true; } -#endif { PreCommonCmdCnt = 0; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 062e19bad64..93850042514 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1347,7 +1347,6 @@ short rtl8192_get_channel_map(struct net_device * dev) { int i; -#ifdef ENABLE_DOT11D struct r8192_priv *priv = rtllib_priv(dev); if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && (priv->rf_chip != RF_6052)) { @@ -1363,23 +1362,6 @@ short rtl8192_get_channel_map(struct net_device * dev) Dot11d_Init(priv->rtllib); #ifndef CONFIG_CRDA Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); -#endif -#else - struct r8192_priv *priv = rtllib_priv(dev); - int ch; - if (!channels){ - DMESG("No channels, aborting"); - return -1; - } - - ch = channels; - priv->ChannelPlan = 0; - for (i = 1; i <= 14; i++) { - (priv->rtllib->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } - priv->rtllib->IbssStartChnl= 10; - priv->rtllib->ibss_maxjoin_chal = 11; #endif for (i = 1; i <= 11; i++) { (priv->rtllib->active_channel_map)[i] = 1; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 239c46e8bfa..526a2599b19 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -48,9 +48,7 @@ #include #include "rtllib.h" -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif #include "r8192E_firmware.h" #include "r8192E_hw.h" diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 9cdc5eac33e..44c49d508c7 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -19,9 +19,7 @@ #include #include "rtl_core.h" -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif #define RATE_COUNT 12 u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 25ecf30910e..b9284a220e4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1741,10 +1741,8 @@ struct rtllib_network { u8 wmm_info; struct rtllib_wmm_ac_param wmm_param[4]; u8 Turbo_Enable; -#ifdef ENABLE_DOT11D u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; -#endif BSS_HT bssht; bool broadcom_cap_exist; bool realtek_cap_exit; @@ -2485,12 +2483,8 @@ struct rtllib_device { u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ -#ifdef ENABLE_DOT11D void* pDot11dInfo; bool bGlobalDomain; -#else - u8 channel_map[MAX_CHANNEL_NUMBER+1]; -#endif u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; u8 IbssStartChnl; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 7e0fabad64d..10ec50cf58b 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -43,9 +43,7 @@ #include #include "rtllib.h" -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif #if defined CONFIG_CFG_80211 #include @@ -2074,7 +2072,6 @@ static const char *get_info_element_string(u16 id) } #endif -#ifdef ENABLE_DOT11D static inline void rtllib_extract_country_ie( struct rtllib_device *ieee, struct rtllib_info_element *info_element, @@ -2100,7 +2097,6 @@ static inline void rtllib_extract_country_ie( } } -#endif int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_info_element *info_element, @@ -2574,13 +2570,11 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, "QoS Error need to parse QOS_PARAMETER IE\n"); break; -#ifdef ENABLE_DOT11D case MFIE_TYPE_COUNTRY: RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", info_element->len); rtllib_extract_country_ie(ieee, info_element, network, network->bssid); break; -#endif /* TODO */ default: RTLLIB_DEBUG_MGMT @@ -2717,10 +2711,8 @@ static inline int rtllib_network_init( network->Turbo_Enable = 0; network->SignalStrength = stats->SignalStrength; network->RSSI = stats->SignalStrength; -#ifdef ENABLE_DOT11D network->CountryIeLen = 0; memset(network->CountryIeBuf, 0, MAX_IE_LEN); -#endif HTInitializeBssDesc(&network->bssht); if (stats->freq == RTLLIB_52GHZ_BAND) { /* for A band (No DS info) */ @@ -2898,10 +2890,8 @@ static inline void update_network(struct rtllib_network *dst, dst->RSSI = src->RSSI; dst->Turbo_Enable = src->Turbo_Enable; -#ifdef ENABLE_DOT11D dst->CountryIeLen = src->CountryIeLen; memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen); -#endif dst->bWithAironetIE = src->bWithAironetIE; dst->bCkipSupported = src->bCkipSupported; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 1d350446354..9d881f480ce 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -21,9 +21,7 @@ #include #include #include -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif #ifdef RTK_DMP_PLATFORM #include @@ -549,11 +547,7 @@ void rtllib_softmac_hint11d_wq(void *data) void rtllib_update_active_chan_map(struct rtllib_device *ieee) { -#ifdef ENABLE_DOT11D memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); -#else - memcpy(ieee->active_channel_map, ieee->channel_map, MAX_CHANNEL_NUMBER+1); -#endif } /* this performs syncro scan blocking the caller until all channels @@ -618,10 +612,8 @@ out: ieee->sync_scan_hurryup = 0; if (ieee->state >= RTLLIB_LINKED){ -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); -#endif } up(&ieee->scan_sem); @@ -681,10 +673,8 @@ void rtllib_softmac_scan_wq(void *data) return; out: -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); -#endif ieee->current_network.channel = last_channel; out1: @@ -794,7 +784,6 @@ void rtllib_start_scan(struct rtllib_device *ieee) ieee->rtllib_ips_leave_wq(ieee->dev); -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee) ) { if (IS_COUNTRY_IE_VALID(ieee)) @@ -802,7 +791,6 @@ void rtllib_start_scan(struct rtllib_device *ieee) RESET_CIE_WATCHDOG(ieee); } } -#endif if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { if (ieee->scanning_continue == 0) { ieee->actscanning = true; @@ -819,7 +807,6 @@ void rtllib_start_scan(struct rtllib_device *ieee) /* called with wx_sem held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee) ) { if (IS_COUNTRY_IE_VALID(ieee)) @@ -827,7 +814,6 @@ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) RESET_CIE_WATCHDOG(ieee); } } -#endif ieee->sync_scan_hurryup = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ rtllib_softmac_scan_syncro(ieee, is_mesh); @@ -2935,7 +2921,6 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee) void rtllib_start_bss(struct rtllib_device *ieee) { unsigned long flags; -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { if (! ieee->bGlobalDomain) @@ -2943,7 +2928,6 @@ void rtllib_start_bss(struct rtllib_device *ieee) return; } } -#endif /* check if we have already found the net we * are interested in (if any). * if not (we are disassociated and we are not @@ -2980,10 +2964,8 @@ void rtllib_disassociate(struct rtllib_device *ieee) if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); -#ifdef ENABLE_DOT11D if (IS_DOT11D_ENABLE(ieee)) Dot11d_Reset(ieee); -#endif ieee->state = RTLLIB_NOLINK; ieee->is_set_key = false; ieee->wap_set = 0; @@ -3200,12 +3182,10 @@ void rtllib_softmac_init(struct rtllib_device *ieee) for (i = 0; i < 5; i++) { ieee->seq_ctrl[i] = 0; } -#ifdef ENABLE_DOT11D ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); if (!ieee->pDot11dInfo) RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); -#endif ieee->LinkDetectInfo.SlotIndex = 0; ieee->LinkDetectInfo.SlotNum = 2; ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; @@ -3285,13 +3265,11 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { down(&ieee->wx_sem); -#ifdef ENABLE_DOT11D if (NULL != ieee->pDot11dInfo) { kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; } -#endif del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 01f22045000..fc3dafc5079 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -16,9 +16,7 @@ #include "rtllib.h" #include "rtl_core.h" -#ifdef ENABLE_DOT11D #include "dot11d.h" -#endif /* FIXME: add A freqs */ const long rtllib_wlan_frequencies[] = { @@ -64,12 +62,10 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, }else { /* Set the channel */ -#ifdef ENABLE_DOT11D if (ieee->active_channel_map[fwrq->m] != 1) { ret = -EINVAL; goto out; } -#endif ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); From 68aee8036c04145742a9e7a00eb78e4da1b35fdc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 09:38:53 -0500 Subject: [PATCH 0301/1519] staging: rtl8192e: Remove code dependent of JOHN_DUMP Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index b75b2b4f4f9..8918aa5760a 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -489,17 +489,6 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) skb_pull(skb, 8); skb_trim(skb, skb->len - 4); -#ifdef JOHN_DUMP -if ( ((u16*)skb->data)[0] & 0x4000){ - printk("@@ rx decrypted skb->data"); - int i; - for (i = 0; i < skb->len; i++) { - if ( (i%24)==0 ) printk("\n"); - printk("%2x ", ((u8*)skb->data)[i]); - } - printk("\n"); -} -#endif /*JOHN_DUMP*/ return keyidx; } From bf474281e98171b7491a8b759491f400bd6b1863 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 09:43:35 -0500 Subject: [PATCH 0302/1519] staging: rtl8192e: Remove dead code associated with USB_TX_DRIVER_AGGREGATION_ENABLE Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 3 --- drivers/staging/rtl8192e/rtl819x_HTProc.c | 3 --- drivers/staging/rtl8192e/rtllib_softmac.c | 8 -------- 3 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 703d9dde570..abebedac281 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -285,9 +285,6 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 RxReorderPendingTime; u16 RxReorderDropCounter; -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - u8 UsbTxAggrNum; -#endif #ifdef USB_RX_AGGREGATION_SUPPORT u8 UsbRxFwAggrEn; u8 UsbRxFwAggrPageNum; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 0f5410c2c16..cb144610489 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -94,9 +94,6 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->RxReorderWinSize = 64; pHTInfo->RxReorderPendingTime = 30; -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - pHTInfo->UsbTxAggrNum = 4; -#endif #ifdef USB_RX_AGGREGATION_SUPPORT pHTInfo->UsbRxFwAggrEn = 1; pHTInfo->UsbRxFwAggrPageNum = 24; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9d881f480ce..b4279d7049e 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2591,11 +2591,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ for (i = 0; i < txb->nr_frags; i++) { -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - queue_len = skb_queue_len(&ieee->skb_drv_aggQ[queue_index]); -#else queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); -#endif if ((queue_len != 0) ||\ (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ (ieee->queue_stop)) { @@ -2609,11 +2605,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) if (queue_len < 200) #endif { -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]); -#else skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); -#endif }else{ kfree_skb(txb->fragments[i]); } From 94114a5ad75c6c9dcc931170855d2a90eea53d97 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 18:47:44 -0500 Subject: [PATCH 0303/1519] staging: rtl8192e: Remove dead code associated with TCP_CSUM_OFFLOAD_RX Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 ------ drivers/staging/rtl8192e/rtllib_rx.c | 18 ------------------ 2 files changed, 24 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b9284a220e4..cb83fffd4a1 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1095,9 +1095,6 @@ struct rtllib_rx_stats { char cck_adc_pwdb[4]; u16 Seq_Num; u8 nTotalAggPkt; -#ifdef TCP_CSUM_OFFLOAD_RX - u8 tcp_csum_valid; -#endif #endif }; @@ -1398,9 +1395,6 @@ struct rtllib_rxb { struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; u8 dst[ETH_ALEN]; u8 src[ETH_ALEN]; -#ifdef TCP_CSUM_OFFLOAD_RX - u8 tcp_csum_valid; -#endif }__attribute__((packed)); typedef union _frameqos { diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 10ec50cf58b..d2659d2b69c 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -846,15 +846,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx sub_skb->dev = ieee->dev; sub_skb->dev->stats.rx_packets++; sub_skb->dev->stats.rx_bytes += sub_skb->len; -#ifdef TCP_CSUM_OFFLOAD_RX - if ( prxb->tcp_csum_valid) - sub_skb->ip_summed = CHECKSUM_UNNECESSARY; - else - sub_skb->ip_summed = CHECKSUM_NONE; - -#else sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ -#endif ieee->last_rx_ps_time = jiffies; netif_rx(sub_skb); } @@ -1581,14 +1573,7 @@ void rtllib_rx_indicate_pkt_legacy( sub_skb->dev = dev; sub_skb->dev->stats.rx_packets++; sub_skb->dev->stats.rx_bytes += sub_skb->len; -#ifdef TCP_CSUM_OFFLOAD_RX - if ( rx_stats->tcp_csum_valid) - sub_skb->ip_summed = CHECKSUM_UNNECESSARY; - else - sub_skb->ip_summed = CHECKSUM_NONE; -#else sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ -#endif netif_rx(sub_skb); } } @@ -1749,9 +1734,6 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA){ rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); }else{ -#ifdef TCP_CSUM_OFFLOAD_RX - rxb->tcp_csum_valid = rx_stats->tcp_csum_valid; -#endif RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); } From 02525969666f1fe4718705d372afaafa9d12b612 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 18:50:46 -0500 Subject: [PATCH 0304/1519] staging: rtl8192e: Remove dead code associated with SUPPORT_USPD Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b4279d7049e..b9b5a1053e5 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -119,15 +119,7 @@ void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { *tag++ = 0x02; *tag++ = 0x00; *tag++ = 0x01; -#ifdef SUPPORT_USPD - if (ieee->current_network.wmm_info & 0x80) { - *tag++ = 0x0f|MAX_SP_Len; - } else { - *tag++ = MAX_SP_Len; - } -#else *tag++ = MAX_SP_Len; -#endif *tag_p = tag; } From bfb74db3e58c6362d877b299e5b68c512fc500db Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 18:54:50 -0500 Subject: [PATCH 0305/1519] staging: rtl8192e: Remove dead code associated with USB_RX_AGGREGATION_SUPPORT Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 8 ----- drivers/staging/rtl8192e/rtl819x_HTProc.c | 9 ----- drivers/staging/rtl8192e/rtl_dm.c | 43 ----------------------- 3 files changed, 60 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index abebedac281..3918705d07f 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -285,14 +285,6 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 RxReorderPendingTime; u16 RxReorderDropCounter; -#ifdef USB_RX_AGGREGATION_SUPPORT - u8 UsbRxFwAggrEn; - u8 UsbRxFwAggrPageNum; - u8 UsbRxFwAggrPacketNum; - u8 UsbRxFwAggrTimeout; - u8 UsbRxPageSize; -#endif - u8 bIsPeerBcm; u8 IOTPeer; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index cb144610489..a457e302abc 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -93,15 +93,6 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->bRegRxReorderEnable = 1; pHTInfo->RxReorderWinSize = 64; pHTInfo->RxReorderPendingTime = 30; - -#ifdef USB_RX_AGGREGATION_SUPPORT - pHTInfo->UsbRxFwAggrEn = 1; - pHTInfo->UsbRxFwAggrPageNum = 24; - pHTInfo->UsbRxFwAggrPacketNum = 8; - pHTInfo->UsbRxFwAggrTimeout = 8; -#endif - - } void HTDebugHTCapability(u8* CapIE, u8* TitleString ) { diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index dba17a18592..ca3001b257c 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -196,45 +196,6 @@ extern void deinit_hal_dm(struct net_device *dev) } - -#ifdef USB_RX_AGGREGATION_SUPPORT -void dm_CheckRxAggregation(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; - - curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; - curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - - if ((curTxOkCnt + curRxOkCnt) < 15000000) { - return; - } - - if (curTxOkCnt > 4*curRxOkCnt) { - if (priv->bCurrentRxAggrEnable) { - write_nic_dword(dev, 0x1a8, 0); - priv->bCurrentRxAggrEnable = false; - } - }else{ - if (!priv->bCurrentRxAggrEnable && !pHTInfo->bCurrentRT2RTAggregation) { - u32 ulValue; - ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) | - (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout); - write_nic_dword(dev, 0x1a8, ulValue); - priv->bCurrentRxAggrEnable = true; - } - } - - lastTxOkCnt = priv->stats.txbytesunicast; - lastRxOkCnt = priv->stats.rxbytesunicast; -} -#endif - - - extern void hal_dm_watchdog(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -259,10 +220,6 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_send_rssi_tofw(dev); dm_ctstoself(dev); - -#ifdef USB_RX_AGGREGATION_SUPPORT - dm_CheckRxAggregation(dev); -#endif } void dm_check_ac_dc_power(struct net_device *dev) From 6e2c538f8fbca87276a83eec5ac9212bbbfa13fa Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 21:58:46 -0500 Subject: [PATCH 0306/1519] staging: rtl8192e: Remove dead code associated with RTK_DMP_PLATFORM Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 3 --- drivers/staging/rtl8192e/rtllib_module.c | 8 -------- drivers/staging/rtl8192e/rtllib_softmac.c | 6 ------ drivers/staging/rtl8192e/rtllib_tx.c | 4 ---- 4 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 3d9f7601e87..ce5343e5245 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -19,9 +19,6 @@ #include "rtllib.h" #include "rtl819x_BA.h" #include "rtl_core.h" -#ifdef RTK_DMP_PLATFORM -#include -#endif void ActivateBAEntry(struct rtllib_device* ieee, PBA_RECORD pBA, u16 Time) { diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 5373de60ab0..2182e56f0d2 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -88,13 +88,9 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) if (ieee->networks) return 0; -#ifndef RTK_DMP_PLATFORM ieee->networks = kmalloc( MAX_NETWORK_COUNT * sizeof(struct rtllib_network), GFP_KERNEL); -#else - ieee->networks = dvr_malloc(MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); -#endif if (!ieee->networks) { printk(KERN_WARNING "%s: Out of memory allocating beacons\n", ieee->dev->name); @@ -111,11 +107,7 @@ static inline void rtllib_networks_free(struct rtllib_device *ieee) { if (!ieee->networks) return; -#ifndef RTK_DMP_PLATFORM kfree(ieee->networks); -#else - dvr_free(ieee->networks); -#endif ieee->networks = NULL; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b9b5a1053e5..a0cd746778a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -23,9 +23,6 @@ #include #include "dot11d.h" -#ifdef RTK_DMP_PLATFORM -#include -#endif extern void _setup_timer( struct timer_list*, void*, unsigned long ); u8 rsn_authen_cipher_suite[16][4] = { {0x00,0x0F,0xAC,0x00}, @@ -1634,9 +1631,6 @@ void rtllib_associate_complete_wq(void *data) if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); -#ifdef RTK_DMP_PLATFORM - kobject_hotplug(&ieee->dev->class_dev.kobj, KOBJ_LINKUP); -#endif } static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f93530e53af..0f724caaf6f 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -54,10 +54,6 @@ #include "rtllib.h" -#ifdef RTK_DMP_PLATFORM -#include -#endif - /* From e11fd5132459f0b1b534faa15a0224723ecdafb0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 22:01:59 -0500 Subject: [PATCH 0307/1519] staging: rtl8192e: Remove dead code associated with NOT_YET Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_rx.c | 46 ---------------------------- 1 file changed, 46 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index d2659d2b69c..f4f7ec509b3 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -497,52 +497,6 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, dev_kfree_skb_any(skb); return 0; - -#ifdef NOT_YET - if (ieee->iw_mode == IW_MODE_MASTER) { - printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", - ieee->dev->name); - return 0; -/* - hostap_update_sta_ps(ieee, (struct hostap_rtllib_hdr_4addr *) - skb->data);*/ - } - - if (ieee->hostapd && type == RTLLIB_TYPE_MGMT) { - if (stype == WLAN_FC_STYPE_BEACON && - ieee->iw_mode == IW_MODE_MASTER) { - struct sk_buff *skb2; - /* Process beacon frames also in kernel driver to - * update STA(AP) table statistics */ - skb2 = skb_clone(skb, GFP_ATOMIC); - if (skb2) - hostap_rx(skb2->dev, skb2, rx_stats); - } - - /* send management frames to the user space daemon for - * processing */ - ieee->apdevstats.rx_packets++; - ieee->apdevstats.rx_bytes += skb->len; - prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT); - return 0; - } - - if (ieee->iw_mode == IW_MODE_MASTER) { - if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) { - printk(KERN_DEBUG "%s: unknown management frame " - "(type=0x%02x, stype=0x%02x) dropped\n", - skb->dev->name, type, stype); - return -1; - } - - hostap_rx(skb->dev, skb, rx_stats); - return 0; - } - - printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame " - "received in non-Host AP mode\n", skb->dev->name); - return -1; -#endif } #ifndef CONFIG_CFG_80211 From f1c22567693a8c01a0bda0e3e29243eff3e5f196 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 22:04:15 -0500 Subject: [PATCH 0308/1519] staging: rtl8192e: Remove dead code associated with WIFI_TEST Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a0cd746778a..a5267b24630 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2585,11 +2585,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) /* as for the completion function, it does not need * to check it any more. * */ -#ifdef WIFI_TEST - if (1) -#else if (queue_len < 200) -#endif { skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); }else{ From 07f432338accafb2002911a34309d822e168074a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 22:05:57 -0500 Subject: [PATCH 0309/1519] staging: rtl8192e: Remove dead code associated with ADHOC_11N Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a5267b24630..420ba4398bc 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2780,11 +2780,7 @@ void rtllib_start_ibss_wq(void *data) } ieee->state = RTLLIB_NOLINK; -#ifdef ADHOC_11N - ieee->mode = IEEE_N_24G; -#else ieee->mode = IEEE_G; -#endif /* check if we have this cell in our network list */ rtllib_softmac_check_all_nets(ieee); From eae78ca6896715f05e3db2c47f6ac7cec2904f35 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 13 Jul 2011 22:07:44 -0500 Subject: [PATCH 0310/1519] staging: rtl8192e: Remove dead code associated with BUILT_IN_MSHCLASS Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 93850042514..72ec73751cc 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3302,13 +3302,6 @@ static int __init rtl8192_pci_module_init(void) printk(KERN_ERR "rtllib_crypto_wep_init() failed %d\n", ret); return ret; } -#ifdef BUILT_IN_MSHCLASS - ret = msh_init(); - if (ret) { - printk(KERN_ERR "msh_init() failed %d\n", ret); - return ret; - } -#endif printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n"); printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n"); @@ -3347,9 +3340,6 @@ static void __exit rtl8192_pci_module_exit(void) michael_mic_exit(); aes_fini(); #endif -#ifdef BUILT_IN_MSHCLASS - msh_exit(); -#endif } From eccf634fc84c2e441b34a2c0bc4706616b8ff005 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 09:43:36 -0500 Subject: [PATCH 0311/1519] staging: rtl8192e: Remove dead code associated with WMM_Hang_8187 This patch also removes an "#if 1 .... #endif" that survived an earlier edit. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index cb83fffd4a1..a138e52f6a5 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1633,10 +1633,6 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST -#ifdef WMM_Hang_8187 -#undef WMM_Hang_8187 -#endif - #define WME_AC_BK 0x00 #define WME_AC_BE 0x01 #define WME_AC_VI 0x02 @@ -1647,14 +1643,13 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define MAX_RECEIVE_BUFFER_SIZE 9100 -#if 1 #define UP2AC(up) ( \ ((up) < 1) ? WME_AC_BE : \ ((up) < 3) ? WME_AC_BK : \ ((up) < 4) ? WME_AC_BE : \ ((up) < 6) ? WME_AC_VI : \ WME_AC_VO) -#endif + #define AC2UP(_ac) ( \ ((_ac) == WME_AC_VO) ? 6 : \ ((_ac) == WME_AC_VI) ? 5 : \ From d32ddcba9d67b7d647576df9f8f62934956c60b9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 09:58:36 -0500 Subject: [PATCH 0312/1519] staging: rtl8192e: Remove dead code associated with FOR_ANDROID_X86 and FOR_MOBLIN Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 420ba4398bc..5f65b58286c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -608,13 +608,11 @@ out: ieee->be_scan_inprogress = false; -#ifndef FOR_MOBLIN { union iwreq_data wrqu; memset(&wrqu, 0, sizeof(wrqu)); wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); } -#endif } void rtllib_softmac_scan_wq(void *data) @@ -2942,10 +2940,7 @@ void rtllib_disassociate(struct rtllib_device *ieee) queue_delayed_work_rsl(ieee->wq, &ieee->link_change_wq, 0); - -#ifndef FOR_ANDROID_X86 notify_wx_assoc_event(ieee); -#endif } void rtllib_associate_retry_wq(void *data) From ce403a6ac41ff2e745ddb415d83275eaf2207082 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 10:19:49 -0500 Subject: [PATCH 0313/1519] staging: rtl8192e: Remove dead code associated with CUSTOMER_ID_INTEL_CMPC and CONFIG_CRDA Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2 -- drivers/staging/rtl8192e/rtllib_softmac.c | 7 ------- drivers/staging/rtl8192e/rtllib_wx.c | 2 -- 3 files changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 72ec73751cc..7fb33c9baa0 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1360,9 +1360,7 @@ short rtl8192_get_channel_map(struct net_device * dev) } RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); Dot11d_Init(priv->rtllib); -#ifndef CONFIG_CRDA Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); -#endif for (i = 1; i <= 11; i++) { (priv->rtllib->active_channel_map)[i] = 1; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 5f65b58286c..e4fdcbd376d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -525,13 +525,6 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) void rtllib_softmac_hint11d_wq(void *data) { -#ifdef CONFIG_CRDA - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_hint11d_wq); - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); - struct wireless_dev *wdev = &ieee->wdev; - - regulatory_hint_11d(wdev->wiphy, pDot11dInfo->CountryIeBuf, pDot11dInfo->CountryIeLen); -#endif } void rtllib_update_active_chan_map(struct rtllib_device *ieee) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 0855ad8a0f6..db4c5684a4e 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -215,7 +215,6 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } -#ifndef CUSTOMER_ID_INTEL_CMPC /* add info for WZC */ memset(&iwe, 0, sizeof(iwe)); if (network->wzc_ie_len) @@ -226,7 +225,6 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.u.data.length = network->wzc_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); } -#endif /* Add EXTRA: Age to display seconds since last beacon/probe response * for given network. */ From 954b609b54d4c08a3bd77d81567209ce5d81d9ba Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 16:50:08 -0500 Subject: [PATCH 0314/1519] staging: rtl8192e: IEEE80211_RADIOTAP_F_BADFCS is defined in kernel, do not duplicate Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index a138e52f6a5..1e99c7bcfac 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -51,10 +51,6 @@ #endif #include -#ifndef IEEE80211_RADIOTAP_F_BADFCS -#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */ -#endif - #ifndef IW_MODE_MONITOR #define IW_MODE_MONITOR 6 #endif From dc5de47c8182f92d61d237827d739b6c52cfcd90 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 16:54:46 -0500 Subject: [PATCH 0315/1519] staging: rtl8192e: Remove dead code associated with BUILT_IN_CRYPTO Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/internal.h | 10 ---------- drivers/staging/rtl8192e/rtl_core.c | 26 -------------------------- drivers/staging/rtl8192e/rtl_crypto.h | 10 ---------- 3 files changed, 46 deletions(-) diff --git a/drivers/staging/rtl8192e/internal.h b/drivers/staging/rtl8192e/internal.h index 3041f0fa5cb..00139c271e0 100644 --- a/drivers/staging/rtl8192e/internal.h +++ b/drivers/staging/rtl8192e/internal.h @@ -23,16 +23,6 @@ #include #include -#ifdef BUILT_IN_CRYPTO -#ifdef CONFIG_CRYPTO_HMAC -#undef CONFIG_CRYPTO_HMAC -#endif - -#ifdef CONFIG_KMOD -#undef CONFIG_KMOD -#endif -#endif /* BUILT_IN_CRYPTO */ - extern enum km_type crypto_km_types[]; static inline enum km_type crypto_kmap_type(int out) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7fb33c9baa0..7c89ed87f3b 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3255,26 +3255,6 @@ static int __init rtl8192_pci_module_init(void) int ret; int error; -#ifdef BUILT_IN_CRYPTO - ret = arc4_init(); - if (ret) { - printk(KERN_ERR "arc4_init() failed %d\n", ret); - return ret; - } - - - ret = michael_mic_init(); - if (ret) { - printk(KERN_ERR "michael_mic_init() failed %d\n", ret); - return ret; - } - - ret = aes_init(); - if (ret) { - printk(KERN_ERR "aes_init() failed %d\n", ret); - return ret; - } -#endif ret = rtllib_init(); if (ret) { printk(KERN_ERR "rtllib_init() failed %d\n", ret); @@ -3333,12 +3313,6 @@ static void __exit rtl8192_pci_module_exit(void) rtllib_crypto_wep_exit(); rtllib_crypto_deinit(); rtllib_exit(); -#ifdef BUILT_IN_CRYPTO - arc4_exit(); - michael_mic_exit(); - aes_fini(); -#endif - } void check_rfctrl_gpio_timer(unsigned long data) diff --git a/drivers/staging/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h index 6f445c58dc0..a8df4101bf2 100644 --- a/drivers/staging/rtl8192e/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -24,16 +24,6 @@ #include #include -#ifdef BUILT_IN_CRYPTO -#ifdef CONFIG_CRYPTO_HMAC -#undef CONFIG_CRYPTO_HMAC -#endif - -#ifdef CONFIG_KMOD -#undef CONFIG_KMOD -#endif -#endif /* BUILT_IN_CRYPTO */ - #define crypto_register_alg crypto_register_alg_rsl #define crypto_unregister_alg crypto_unregister_alg_rsl #define crypto_alloc_tfm crypto_alloc_tfm_rsl From 1bd7bcfc633eeb821b85a90067be2bea79510d39 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:08:46 -0500 Subject: [PATCH 0316/1519] staging: rtl8192e: Remove dead code associated with CONFIG_CFG_80211 Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 13 -- drivers/staging/rtl8192e/rtl_core.h | 13 -- drivers/staging/rtl8192e/rtllib.h | 149 ------------- drivers/staging/rtl8192e/rtllib_module.c | 65 ------ drivers/staging/rtl8192e/rtllib_rx.c | 272 ----------------------- 5 files changed, 512 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7c89ed87f3b..59bf9b15043 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1387,14 +1387,6 @@ short rtl8192_init(struct net_device *dev) priv->ops->init_adapter_variable(dev); rtl8192_get_channel_map(dev); -#ifdef CONFIG_CFG_80211 - /* channel map setting for the cfg80211 style */ - { - struct r8192_priv* priv = rtllib_priv(dev); - rtllib_set_geo(priv); - } -#endif - init_hal_dm(dev); init_timer(&priv->watch_dog_timer); @@ -3093,11 +3085,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, goto fail1; } -#ifdef CONFIG_CFG_80211 - if (!rtl8192_register_wiphy_dev(dev)) - goto fail1; -#endif - netif_carrier_off(dev); netif_stop_queue(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 526a2599b19..ec977870f5d 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -56,10 +56,6 @@ #include "r8190P_def.h" #include "r8192E_dev.h" -#ifdef CONFIG_CFG_80211 -#include "rtl_regd.h" -#endif - #ifdef CONFIG_RTL_RFKILL #include "rtl_rfkill.h" #endif @@ -660,11 +656,6 @@ typedef struct r8192_priv void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); -#ifdef CONFIG_CFG_80211 - struct ieee80211_rate rates[IEEE80211_NUM_BANDS][RTL_RATE_MAX]; - struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; -#endif - rx_desc *rx_ring[MAX_RX_QUEUE]; struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT]; dma_addr_t rx_ring_dma[MAX_RX_QUEUE]; @@ -1144,8 +1135,4 @@ ActUpdateChannelAccessSetting( PCHANNEL_ACCESS_SETTING ChnlAccessSetting ); -#ifdef CONFIG_CFG_80211 -struct net_device *wiphy_to_net_device(struct wiphy *wiphy); -#endif - #endif diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 1e99c7bcfac..4ecfe5f0e08 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -35,10 +35,6 @@ #include #include -#ifdef CONFIG_CFG_80211 -#include -#endif - #include "rtl819x_HT.h" #include "rtl819x_BA.h" #include "rtl819x_TS.h" @@ -854,7 +850,6 @@ enum _REG_PREAMBLE_MODE{ #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG) #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4) -#ifndef CONFIG_CFG_80211 /* Authentication algorithms */ #define WLAN_AUTH_OPEN 0 #define WLAN_AUTH_SHARED_KEY 1 @@ -942,7 +937,6 @@ enum rtllib_reasoncode { WLAN_REASON_IEEE8021X_FAILED = 23, WLAN_REASON_CIPHER_SUITE_REJECTED = 24, }; -#endif #define RTLLIB_STATMASK_SIGNAL (1<<0) #define RTLLIB_STATMASK_RSSI (1<<1) @@ -2106,145 +2100,6 @@ typedef struct _RT_PMKID_LIST u16 ssid_length; } RT_PMKID_LIST, *PRT_PMKID_LIST; -#ifdef CONFIG_CFG_80211 -enum { - LIBIPW_CH_PASSIVE_ONLY = (1 << 0), - LIBIPW_CH_80211H_RULES = (1 << 1), - LIBIPW_CH_B_ONLY = (1 << 2), - LIBIPW_CH_NO_IBSS = (1 << 3), - LIBIPW_CH_UNIFORM_SPREADING = (1 << 4), - LIBIPW_CH_RADAR_DETECT = (1 << 5), - LIBIPW_CH_INVALID = (1 << 6), -}; -struct rtllib_channel { - u32 freq; - u8 channel; - u8 flags; - u8 max_power; -}; - -#define RTLLIB_24GHZ_MIN_CHANNEL 1 -#define RTLLIB_24GHZ_MAX_CHANNEL 14 -#define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ - RTLLIB_24GHZ_MIN_CHANNEL + 1) - -struct reg_dmn_pair_mapping { - u16 regDmnEnum; - u16 reg_5ghz_ctl; - u16 reg_2ghz_ctl; -}; - -struct rtl_regulatory { - char alpha2[2]; - u16 country_code; - u16 max_power_level; - u32 tp_scale; - u16 current_rd; - u16 current_rd_ext; - int16_t power_limit; - struct reg_dmn_pair_mapping *regpair; -}; - -struct ieee80211_bss { - /* Yes, this is a hack */ - struct cfg80211_bss cbss; - - /* don't want to look up all the time */ - size_t ssid_len; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - - u8 dtim_period; - - bool wmm_used; - - unsigned long last_probe_resp; - -#ifdef CONFIG_MAC80211_MESH - u8 *mesh_id; - size_t mesh_id_len; - u8 *mesh_cfg; -#endif - - #define IEEE80211_MAX_SUPP_RATES 32 - u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; - size_t supp_rates_len; - - /* - * During assocation, we save an ERP value from a probe response so - * that we can feed ERP info to the driver when handling the - * association completes. these fields probably won't be up-to-date - * otherwise, you probably don't want to use them. - */ - bool has_erp_value; - u8 erp_value; -}; - -/* Parsed Information Elements */ -struct ieee802_11_elems { - u8 *ie_start; - size_t total_len; - - /* pointers to IEs */ - u8 *ssid; - u8 *supp_rates; - u8 *fh_params; - u8 *ds_params; - u8 *cf_params; - struct ieee80211_tim_ie *tim; - u8 *ibss_params; - u8 *challenge; - u8 *wpa; - u8 *rsn; - u8 *erp_info; - u8 *ext_supp_rates; - u8 *wmm_info; - u8 *wmm_param; - struct ieee80211_ht_cap *ht_cap_elem; - struct ieee80211_ht_info *ht_info_elem; - u8 *mesh_config; - u8 *mesh_id; - u8 *peer_link; - u8 *preq; - u8 *prep; - u8 *perr; - u8 *ch_switch_elem; - u8 *country_elem; - u8 *pwr_constr_elem; - u8 *quiet_elem; /* first quite element */ - u8 *timeout_int; - - /* length of them, respectively */ - u8 ssid_len; - u8 supp_rates_len; - u8 fh_params_len; - u8 ds_params_len; - u8 cf_params_len; - u8 tim_len; - u8 ibss_params_len; - u8 challenge_len; - u8 wpa_len; - u8 rsn_len; - u8 erp_info_len; - u8 ext_supp_rates_len; - u8 wmm_info_len; - u8 wmm_param_len; - u8 mesh_config_len; - u8 mesh_id_len; - u8 peer_link_len; - u8 preq_len; - u8 prep_len; - u8 perr_len; - u8 ch_switch_elem_len; - u8 country_elem_len; - u8 pwr_constr_elem_len; - u8 quiet_elem_len; - u8 num_of_quiet_elem; /* can be more the one */ - u8 timeout_int_len; -}; - -#endif - - typedef struct _RT_INTEL_PROMISCUOUS_MODE_INFO { bool bPromiscuousOn; bool bFilterSourceStationFrame; @@ -2283,10 +2138,6 @@ struct rtllib_device { HT_EXTCHNL_OFFSET chan_offset_bk; HT_CHANNEL_WIDTH bandwidth_bk; u8 hwscan_sem_up; -#ifdef CONFIG_CFG_80211 - struct wireless_dev wdev; - struct rtl_regulatory regulatory; -#endif u8 CntAfterLink; RT_OP_MODE OpMode; diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 2182e56f0d2..6a33bff11dc 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -56,26 +56,6 @@ #define DRV_NAME "rtllib_92e" -#ifdef CONFIG_CFG_80211 -#ifdef CONFIG_RTL_RFKILL -static inline void rtllib_rfkill_poll(struct wiphy *wiphy) -{ - struct rtllib_device *rtllib = NULL; - - rtllib = (struct rtllib_device *)wiphy_priv(wiphy); - - rtllib = (struct rtllib_device *)netdev_priv_rsl(rtllib->dev); - - if (rtllib->rtllib_rfkill_poll) - rtllib->rtllib_rfkill_poll(rtllib->dev); -} -#else -static inline void rtllib_rfkill_poll(struct wiphy *wiphy) {} -#endif -struct cfg80211_ops rtllib_config_ops = {.rfkill_poll = rtllib_rfkill_poll }; -void *rtllib_wiphy_privid = &rtllib_wiphy_privid; -#endif - void _setup_timer( struct timer_list* ptimer, void* fun, unsigned long data ) { ptimer->function = fun; @@ -121,43 +101,6 @@ static inline void rtllib_networks_initialize(struct rtllib_device *ieee) list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); } -#if defined CONFIG_CFG_80211 -static bool rtllib_wdev_alloc(struct rtllib_device *ieee, int sizeof_priv) -{ - int priv_size; - struct rtllib_device *rtllib = NULL; - - priv_size = ALIGN(sizeof(struct rtllib_device),NETDEV_ALIGN) + sizeof_priv; - - ieee->wdev.wiphy = wiphy_new(&rtllib_config_ops, priv_size); - if (!ieee->wdev.wiphy) { - RTLLIB_ERROR("Unable to allocate wiphy.\n"); - goto out_err_new; - } - - rtllib = (struct rtllib_device *)wiphy_priv(ieee->wdev.wiphy); - rtllib->dev = ieee->dev; - - ieee->dev->ieee80211_ptr = &ieee->wdev; - ieee->wdev.iftype = NL80211_IFTYPE_STATION; - - /* Fill-out wiphy structure bits we know... Not enough info - * here to call set_wiphy_dev or set MAC address or channel info - * -- have to do that in ->ndo_init... */ - ieee->wdev.wiphy->privid = rtllib_wiphy_privid; - - ieee->wdev.wiphy->max_scan_ssids = 1; - ieee->wdev.wiphy->max_scan_ie_len = 0; - ieee->wdev.wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - - return true; - -out_err_new: - wiphy_free(ieee->wdev.wiphy); - return false; -} -#endif - struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; @@ -175,10 +118,6 @@ struct net_device *alloc_rtllib(int sizeof_priv) memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv); ieee->dev = dev; -#ifdef CONFIG_CFG_80211 - if (!rtllib_wdev_alloc(ieee, sizeof_priv)) - goto failed; -#endif err = rtllib_networks_allocate(ieee); if (err) { RTLLIB_ERROR("Unable to allocate beacon storage: %d\n", @@ -277,10 +216,6 @@ void free_rtllib(struct net_device *dev) } rtllib_networks_free(ieee); -#ifdef CONFIG_CFG_80211 - wiphy_unregister(ieee->wdev.wiphy); - wiphy_free(ieee->wdev.wiphy); -#endif free_netdev(dev); } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index f4f7ec509b3..cef04e59515 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -45,276 +45,6 @@ #include "rtllib.h" #include "dot11d.h" -#if defined CONFIG_CFG_80211 -#include - -struct ieee80211_channel *rtllib_get_channel(struct wiphy *wiphy, - int freq) -{ - enum ieee80211_band band; - struct ieee80211_supported_band *sband; - int i; - - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { - sband = wiphy->bands[band]; - - if (!sband) - continue; - - for (i = 0; i < sband->n_channels; i++) { - if (sband->channels[i].center_freq == freq) - return &sband->channels[i]; - } - } - - return NULL; -} - -int rtllib_channel_to_frequency(int chan) -{ - if (chan < 14) - return 2407 + chan * 5; - - if (chan == 14) - return 2484; - - /* FIXME: 802.11j 17.3.8.3.2 */ - return (chan + 1000) * 5; -} - -u32 rtllib_parse_elems_crc(u8 *start, size_t len, - struct ieee802_11_elems *elems, - u64 filter, u32 crc) -{ - size_t left = len; - u8 *pos = start; - bool calc_crc = filter != 0; - - memset(elems, 0, sizeof(*elems)); - elems->ie_start = start; - elems->total_len = len; - - while (left >= 2) { - u8 id, elen; - - id = *pos++; - elen = *pos++; - left -= 2; - - if (elen > left) - break; - - if (calc_crc && id < 64 && (filter & BIT(id))) - crc = crc32_be(crc, pos - 2, elen + 2); - - switch (id) { - case WLAN_EID_SSID: - elems->ssid = pos; - elems->ssid_len = elen; - break; - case WLAN_EID_SUPP_RATES: - elems->supp_rates = pos; - elems->supp_rates_len = elen; - break; - case WLAN_EID_FH_PARAMS: - elems->fh_params = pos; - elems->fh_params_len = elen; - break; - case WLAN_EID_DS_PARAMS: - elems->ds_params = pos; - elems->ds_params_len = elen; - break; - case WLAN_EID_CF_PARAMS: - elems->cf_params = pos; - elems->cf_params_len = elen; - break; - case WLAN_EID_TIM: - if (elen >= sizeof(struct ieee80211_tim_ie)) { - elems->tim = (void *)pos; - elems->tim_len = elen; - } - break; - case WLAN_EID_IBSS_PARAMS: - elems->ibss_params = pos; - elems->ibss_params_len = elen; - break; - case WLAN_EID_CHALLENGE: - elems->challenge = pos; - elems->challenge_len = elen; - break; - case WLAN_EID_VENDOR_SPECIFIC: - if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 && - pos[2] == 0xf2) { - /* Microsoft OUI (00:50:F2) */ - - if (calc_crc) - crc = crc32_be(crc, pos - 2, elen + 2); - - if (pos[3] == 1) { - /* OUI Type 1 - WPA IE */ - elems->wpa = pos; - elems->wpa_len = elen; - } else if (elen >= 5 && pos[3] == 2) { - /* OUI Type 2 - WMM IE */ - if (pos[4] == 0) { - elems->wmm_info = pos; - elems->wmm_info_len = elen; - } else if (pos[4] == 1) { - elems->wmm_param = pos; - elems->wmm_param_len = elen; - } - } - } - break; - case WLAN_EID_RSN: - elems->rsn = pos; - elems->rsn_len = elen; - break; - case WLAN_EID_ERP_INFO: - elems->erp_info = pos; - elems->erp_info_len = elen; - break; - case WLAN_EID_EXT_SUPP_RATES: - elems->ext_supp_rates = pos; - elems->ext_supp_rates_len = elen; - break; - case WLAN_EID_HT_CAPABILITY: - if (elen >= sizeof(struct ieee80211_ht_cap)) - elems->ht_cap_elem = (void *)pos; - break; - case WLAN_EID_HT_INFORMATION: - if (elen >= sizeof(struct ieee80211_ht_info)) - elems->ht_info_elem = (void *)pos; - break; - case WLAN_EID_MESH_ID: - elems->mesh_id = pos; - elems->mesh_id_len = elen; - break; - case WLAN_EID_MESH_CONFIG: - elems->mesh_config = pos; - elems->mesh_config_len = elen; - break; - case WLAN_EID_PEER_LINK: - elems->peer_link = pos; - elems->peer_link_len = elen; - break; - case WLAN_EID_PREQ: - elems->preq = pos; - elems->preq_len = elen; - break; - case WLAN_EID_PREP: - elems->prep = pos; - elems->prep_len = elen; - break; - case WLAN_EID_PERR: - elems->perr = pos; - elems->perr_len = elen; - break; - case WLAN_EID_CHANNEL_SWITCH: - elems->ch_switch_elem = pos; - elems->ch_switch_elem_len = elen; - break; - case WLAN_EID_QUIET: - if (!elems->quiet_elem) { - elems->quiet_elem = pos; - elems->quiet_elem_len = elen; - } - elems->num_of_quiet_elem++; - break; - case WLAN_EID_COUNTRY: - elems->country_elem = pos; - elems->country_elem_len = elen; - break; - case WLAN_EID_PWR_CONSTRAINT: - elems->pwr_constr_elem = pos; - elems->pwr_constr_elem_len = elen; - break; - case WLAN_EID_TIMEOUT_INTERVAL: - elems->timeout_int = pos; - elems->timeout_int_len = elen; - break; - default: - break; - } - - left -= elen; - pos += elen; - } - - return crc; -} - -void rtllib_parse_elems(u8 *start, size_t len, - struct ieee802_11_elems *elems) -{ - rtllib_parse_elems_crc(start, len, elems, 0, 0); -} - -void ieee80211_scan_rx(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_status) -{ - struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - struct ieee80211_mgmt *mgmt; - struct ieee80211_bss *bss; - u8 *elements; - struct ieee80211_channel *channel; - size_t baselen; - int freq; - __le16 fc; - bool presp, beacon = false; - struct ieee802_11_elems elems; - s32 signal = 0; - - if (skb->len < 2) - return; - - mgmt = (struct ieee80211_mgmt *) skb->data; - fc = mgmt->frame_control; - - if (skb->len < 24) - return; - - presp = (WLAN_FC_GET_STYPE(header->frame_ctl) == RTLLIB_STYPE_PROBE_RESP); - if (presp) { - /* ignore ProbeResp to foreign address */ - if (memcmp(mgmt->da, ieee->dev->dev_addr, ETH_ALEN)) - return ;; - - presp = true; - elements = mgmt->u.probe_resp.variable; - baselen = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - } else { - beacon = (WLAN_FC_GET_STYPE(header->frame_ctl) == RTLLIB_STYPE_BEACON); - baselen = offsetof(struct ieee80211_mgmt, u.beacon.variable); - elements = mgmt->u.beacon.variable; - } - - if (!presp && !beacon) - return; - - if (baselen > skb->len) - return; - - rtllib_parse_elems(elements, skb->len - baselen, &elems); - - if (elems.ds_params && elems.ds_params_len == 1) - freq = rtllib_channel_to_frequency(elems.ds_params[0]); - else - return; - - channel = rtllib_get_channel(ieee->wdev.wiphy, freq); - - if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) - return; - - signal = rx_status->signal * 100; - - bss = (void *)cfg80211_inform_bss_frame(ieee->wdev.wiphy, channel, - mgmt, skb->len, signal, GFP_ATOMIC); - - return; -} -#endif - static inline void rtllib_monitor_rx(struct rtllib_device *ieee, struct sk_buff *skb,struct rtllib_rx_stats *rx_status, size_t hdr_length) @@ -499,7 +229,6 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -#ifndef CONFIG_CFG_80211 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ static unsigned char rfc1042_header[] = @@ -508,7 +237,6 @@ static unsigned char rfc1042_header[] = static unsigned char bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; /* No encapsulation header if EtherType < 0x600 (=length) */ -#endif /* Called by rtllib_rx_frame_decrypt */ static int rtllib_is_eapol_frame(struct rtllib_device *ieee, From a616feed4ec15a937f2af90ba07527158eee9191 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:14:28 -0500 Subject: [PATCH 0317/1519] staging: rtl8192e: Remove dead code associated with IRQF_SHARED This symbol is defined in the kernel. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 59bf9b15043..ae983a2237b 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1400,11 +1400,7 @@ short rtl8192_init(struct net_device *dev) (unsigned long)dev); rtl8192_irq_disable(dev); -#if defined(IRQF_SHARED) if (request_irq(dev->irq, (void*)rtl8192_interrupt_rsl, IRQF_SHARED, dev->name, dev)) -#else - if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, SA_SHIRQ, dev->name, dev)) -#endif { printk("Error allocating IRQ %d",dev->irq); return -1; From 69dbddce03e40650fb28fc5954c3ccd59a53d201 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:18:14 -0500 Subject: [PATCH 0318/1519] staging: rtl8192e: Remove dead code associated with CONFIG_RTLLIB_CRYPT_TKIP Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_rx.c | 12 ------------ drivers/staging/rtl8192e/rtllib_tx.c | 14 -------------- 2 files changed, 26 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index cef04e59515..b6e23a2ab08 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -301,18 +301,6 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, hdr = (struct rtllib_hdr_4addr *) skb->data; hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); -#ifdef CONFIG_RTLLIB_CRYPT_TKIP - if (ieee->tkip_countermeasures && - strcmp(crypt->ops->name, "TKIP") == 0) { - if (net_ratelimit()) { - printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "received packet from " MAC_FMT "\n", - ieee->dev->name, MAC_ARG(hdr->addr2)); - } - return -1; - } -#endif - atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); atomic_dec(&crypt->refcnt); diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 0f724caaf6f..ae9f7727ed3 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -192,20 +192,6 @@ int rtllib_encrypt_fragment( printk("=========>%s(), crypt is null\n", __func__); return -1; } -#ifdef CONFIG_RTLLIB_CRYPT_TKIP - struct rtllib_hdr_1addr *header; - - if (ieee->tkip_countermeasures && - crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { - header = (struct rtllib_hdr_1addr *) frag->data; - if (net_ratelimit()) { - printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "TX packet to " MAC_FMT "\n", - ieee->dev->name, MAC_ARG(header->addr1)); - } - return -1; - } -#endif /* To encrypt, frame format is: * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */ From af7daa15f7ab1c43091e6fc437bd2b4b5e7df60a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:20:32 -0500 Subject: [PATCH 0319/1519] staging: rtl8192e: Remove dead code associated with CONFIG_64BIT_DMA Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index ae983a2237b..3711eb431f0 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2975,17 +2975,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, pci_set_master(pdev); -#ifdef CONFIG_64BIT_DMA - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { - printk("RTL819xCE: Using 64bit DMA\n"); - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) { - printk( "Unable to obtain 64bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; - } - bdma64 = true; - } else -#endif { if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { From 438af18e9278157a94b4f1ecb50cf9aa9437ebc2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:22:17 -0500 Subject: [PATCH 0320/1519] staging: rtl8192e: Remove dead code associated with ENABLE_NULL_PT_DEBUG Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 4ecfe5f0e08..352ee474bbf 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -454,27 +454,8 @@ typedef enum _RT_OP_MODE{ #define IEEE_CRYPT_ALG_NAME_LEN 16 #define MAX_IE_LEN 0xff -#ifdef ENABLE_NULL_PT_DEBUG -#define RT_ASSERT_RET(_Exp) \ - if (!(_Exp)) \ - { \ - printk("Rtl819x: "); \ - printk( "Assertion failed! %s,%s,line=%d\n", \ - #_Exp,__func__,__LINE__); \ - return; \ - } -#define RT_ASSERT_RET_VALUE(_Exp,Ret) \ - if (!(_Exp)) \ - { \ - printk("Rtl819x: "); \ - printk( "Assertion failed! %s,%s,line=%d\n", \ - #_Exp,__func__,__LINE__); \ - return (Ret); \ - } -#else #define RT_ASSERT_RET(_Exp) do {} while(0) #define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) -#endif typedef struct ieee_param { u32 cmd; From c29fed1e5c1d0c31dceddc539f75c668b469f50b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 17:24:17 -0500 Subject: [PATCH 0321/1519] staging: rtl8192e: Remove dead code associated with CONFIG_BT_30 Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index ec977870f5d..99a40a00d31 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -590,10 +590,6 @@ typedef struct r8192_priv struct rtl819x_ops *ops; struct rtllib_device *rtllib; -#ifdef CONFIG_BT_30 - struct BT30Info BtInfo; -#endif - #ifdef CONFIG_RTLWIFI_DEBUGFS rtl_fs_debug *debug; #endif /* CONFIG_IWLWIFI_DEBUGFS */ From 76de64db13d0f05401d984bce45dbcf9a805cd84 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 18:33:33 -0500 Subject: [PATCH 0322/1519] staging: rtl8192e: Remove dead code associated with CONFIG_CRYPTO_HMAC Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/internal.h | 5 ----- drivers/staging/rtl8192e/rtl_crypto.h | 16 ---------------- 2 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8192e/internal.h b/drivers/staging/rtl8192e/internal.h index 00139c271e0..dab7aa26319 100644 --- a/drivers/staging/rtl8192e/internal.h +++ b/drivers/staging/rtl8192e/internal.h @@ -63,10 +63,6 @@ static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) } #endif -#ifdef CONFIG_CRYPTO_HMAC -int crypto_alloc_hmac_block(struct crypto_tfm *tfm); -void crypto_free_hmac_block(struct crypto_tfm *tfm); -#else static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm) { return 0; @@ -74,7 +70,6 @@ static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm) static inline void crypto_free_hmac_block(struct crypto_tfm *tfm) { } -#endif #ifdef CONFIG_PROC_FS void __init crypto_init_proc(void); diff --git a/drivers/staging/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h index a8df4101bf2..7b4551db961 100644 --- a/drivers/staging/rtl8192e/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -168,9 +168,6 @@ struct digest_tfm { unsigned int nsg, u8 *out); int (*dit_setkey)(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); -#ifdef CONFIG_CRYPTO_HMAC - void *dit_hmac_block; -#endif }; struct compress_tfm { @@ -382,17 +379,4 @@ static inline int crypto_comp_decompress(struct crypto_tfm *tfm, return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); } -/* - * HMAC support. - */ -#ifdef CONFIG_CRYPTO_HMAC -void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen); -void crypto_hmac_update(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); -void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key, - unsigned int *keylen, u8 *out); -void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen, - struct scatterlist *sg, unsigned int nsg, u8 *out); -#endif /* CONFIG_CRYPTO_HMAC */ - #endif /* _LINUX_CRYPTO_H */ From 1bb9d9a9cbb438b6b060a8daa572ac6d80ef415f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 18:38:19 -0500 Subject: [PATCH 0323/1519] staging: rtl8192e: Remove dead code associated with _ENABLE_SW_BEACON Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 7 ------- drivers/staging/rtl8192e/rtl_core.c | 14 -------------- 2 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 51195325424..d441a540132 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -2052,17 +2052,10 @@ rtl8192_InitializeVariables(struct net_device *dev) strcpy(priv->nick, "rtl8192E"); -#ifdef _ENABLE_SW_BEACON - priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - IEEE_SOFTMAC_BEACONS; -#else priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE /* | IEEE_SOFTMAC_BEACONS*/; -#endif priv->rtllib->tx_headroom = sizeof(TX_FWINFO_8190PCI); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 3711eb431f0..217b298a9e8 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1136,13 +1136,8 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->SetBWModeHandler = rtl8192_SetBWMode; priv->rf_set_chan = rtl8192_phy_SwChnl; -#ifdef _ENABLE_SW_BEACON - priv->rtllib->start_send_beacons = NULL; - priv->rtllib->stop_send_beacons = NULL; -#else priv->rtllib->start_send_beacons = rtl8192e_start_beacon; priv->rtllib->stop_send_beacons = rtl8192_stop_beacon; -#endif priv->rtllib->sta_wake_up = rtl8192_hw_wakeup; priv->rtllib->enter_sleep_state = rtl8192_hw_to_sleep; @@ -2100,11 +2095,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) if (tcb_desc->queue_index != BEACON_QUEUE) { idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; } else { -#ifdef _ENABLE_SW_BEACON - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; -#else idx = 0; -#endif } pdesc = &ring->desc[idx]; @@ -2843,9 +2834,6 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_BDOK) { RT_TRACE(COMP_INTR, "beacon interrupt!\n"); -#ifdef _ENABLE_SW_BEACON - rtl8192_tx_isr(dev, BEACON_QUEUE); -#endif } if (inta & IMR_MGNTDOK ) { @@ -2880,9 +2868,7 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_BcnInt) { RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); -#ifndef _ENABLE_SW_BEACON tasklet_schedule(&priv->irq_prepare_beacon_tasklet); -#endif } if (inta & IMR_RDU) { From 9ab2da30490c095834332aeb3c0a01d1f1ed0fb9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 18:41:10 -0500 Subject: [PATCH 0324/1519] staging: rtl8192e: Remove dead code associated with RTL819x_DEBUG Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_debug.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 511d96c9141..2e23bf65a8d 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -237,8 +237,6 @@ do { if (rt_global_debug_component & component) \ ##args);\ }while(0); -#define RTL819x_DEBUG -#ifdef RTL819x_DEBUG #define assert(expr) \ if (!(expr)) { \ printk( "Assertion failed! %s,%s,%s,line=%d\n", \ @@ -258,10 +256,6 @@ do { if (rt_global_debug_component & component) \ printk("\n"); \ } \ } while (0) -#else -#define assert(expr) do {} while (0) -#define RT_DEBUG_DATA(level, data, datalen) do {} while(0) -#endif typedef struct _rtl_fs_debug { From 8cc638e95bcef31d5f8896bbe5ca06fd52fa7947 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 18:48:38 -0500 Subject: [PATCH 0325/1519] staging: rtl8192e: Remove ifdefs for CONFIG_RTLLIB_DEBUG This symbol is unconditionally defined in a header file, thus tests for it can be removed. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 15 --------------- drivers/staging/rtl8192e/rtllib_module.c | 8 -------- drivers/staging/rtl8192e/rtllib_rx.c | 23 +---------------------- drivers/staging/rtl8192e/rtllib_tx.c | 2 -- 4 files changed, 1 insertion(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 352ee474bbf..d1c35503879 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -670,8 +670,6 @@ typedef enum _NETWORK_TYPE{ #define OUI_SUBTYPE_QOS_CAPABI 5 /* debug macros */ -#define CONFIG_RTLLIB_DEBUG -#ifdef CONFIG_RTLLIB_DEBUG extern u32 rtllib_debug_level; #define RTLLIB_DEBUG(level, fmt, args...) \ do { if (rtllib_debug_level & (level)) \ @@ -690,12 +688,6 @@ do { if (rtllib_debug_level & (level)) \ printk("\n"); \ } \ } while (0) -#else -#define RTLLIB_DEBUG(level, fmt, args...) do {} while (0) -#define RTLLIB_DEBUG_DATA(level, data, datalen) do {} while(0) -#endif /* CONFIG_RTLLIB_DEBUG */ - -/* debug macros not dependent on CONFIG_RTLLIB_DEBUG */ #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] @@ -721,8 +713,6 @@ do { if (rtllib_debug_level & (level)) \ * * you simply need to add your entry to the ipw_debug_levels array. * - * If you do not see debug_level in /proc/net/ipw then you do not have - * CONFIG_RTLLIB_DEBUG defined in your kernel configuration * */ @@ -763,7 +753,6 @@ do { if (rtllib_debug_level & (level)) \ #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a) #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a) -#ifdef CONFIG_RTLLIB_DEBUG /* Added by Annie, 2005-11-22. */ #define MAX_STR_LEN 64 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ @@ -785,10 +774,6 @@ do { if (rtllib_debug_level & (level)) \ printk(_TitleString); \ printk(": %d, <%s>\n", _Len, buffer); \ } -#else -#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0) -#endif - #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 6a33bff11dc..3462e44ce23 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -219,8 +219,6 @@ void free_rtllib(struct net_device *dev) free_netdev(dev); } -#ifdef CONFIG_RTLLIB_DEBUG - u32 rtllib_debug_level = 0; static int debug = \ RTLLIB_DL_ERR @@ -262,7 +260,6 @@ static int store_debug_level(struct file *file, const char *buffer, int __init rtllib_init(void) { -#ifdef CONFIG_RTLLIB_DEBUG struct proc_dir_entry *e; rtllib_debug_level = debug; @@ -282,20 +279,15 @@ int __init rtllib_init(void) e->read_proc = show_debug_level; e->write_proc = store_debug_level; e->data = NULL; -#endif return 0; } void __exit rtllib_exit(void) { -#ifdef CONFIG_RTLLIB_DEBUG if (rtllib_proc) { remove_proc_entry("debug_level", rtllib_proc); remove_proc_entry(DRV_NAME, init_net.proc_net); rtllib_proc = NULL; } -#endif } - -#endif diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index b6e23a2ab08..2c4e777f3c0 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1131,14 +1131,12 @@ int rtllib_rx_decrypt( if (/*ieee->ieee802_1x &&*/ rtllib_is_eapol_frame(ieee, skb, hdrlen)) { -#ifdef CONFIG_RTLLIB_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ struct eapol *eap = (struct eapol *)(skb->data + 24); RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", eap_get_type(eap->type)); -#endif } else { RTLLIB_DEBUG_DROP( "encryption configured, but RX " @@ -1148,7 +1146,6 @@ int rtllib_rx_decrypt( } } -#ifdef CONFIG_RTLLIB_DEBUG if (crypt && !(fc & RTLLIB_FCTL_WEP) && rtllib_is_eapol_frame(ieee, skb, hdrlen)) { struct eapol *eap = (struct eapol *)(skb->data + @@ -1156,7 +1153,6 @@ int rtllib_rx_decrypt( RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", eap_get_type(eap->type)); } -#endif if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep && !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { @@ -1686,7 +1682,6 @@ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element return rc; } -#ifdef CONFIG_RTLLIB_DEBUG #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x static const char *get_info_element_string(u16 id) @@ -1722,7 +1717,6 @@ static const char *get_info_element_string(u16 id) return "UNKNOWN"; } } -#endif static inline void rtllib_extract_country_ie( struct rtllib_device *ieee, @@ -1762,10 +1756,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, u16 tmp_htinfo_len=0; u16 ht_realtek_agg_len=0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; -#ifdef CONFIG_RTLLIB_DEBUG char rates_str[64]; char *p; -#endif + while (length >= sizeof(*info_element)) { if (sizeof(*info_element) + info_element->len > length) { RTLLIB_DEBUG_MGMT("Info elem: parse failed: " @@ -1800,18 +1793,14 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; case MFIE_TYPE_RATES: -#ifdef CONFIG_RTLLIB_DEBUG p = rates_str; -#endif network->rates_len = min(info_element->len, MAX_RATES_LENGTH); for (i = 0; i < network->rates_len; i++) { network->rates[i] = info_element->data[i]; -#ifdef CONFIG_RTLLIB_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); -#endif if (rtllib_is_ofdm_rate (info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; @@ -1832,18 +1821,14 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; case MFIE_TYPE_RATES_EX: -#ifdef CONFIG_RTLLIB_DEBUG p = rates_str; -#endif network->rates_ex_len = min(info_element->len, MAX_RATES_EX_LENGTH); for (i = 0; i < network->rates_ex_len; i++) { network->rates_ex[i] = info_element->data[i]; -#ifdef CONFIG_RTLLIB_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); -#endif if (rtllib_is_ofdm_rate (info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; @@ -2322,8 +2307,6 @@ static inline int rtllib_network_init( struct rtllib_network *network, struct rtllib_rx_stats *stats) { -#ifdef CONFIG_RTLLIB_DEBUG -#endif /* network->qos_data.active = 0; @@ -2594,9 +2577,7 @@ static inline void rtllib_process_probe_response( { struct rtllib_network *target; struct rtllib_network *oldest = NULL; -#ifdef CONFIG_RTLLIB_DEBUG struct rtllib_info_element *info_element = &beacon->info_element[0]; -#endif unsigned long flags; short renew; struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); @@ -2704,7 +2685,6 @@ static inline void rtllib_process_probe_response( } -#ifdef CONFIG_RTLLIB_DEBUG RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", escape_essid(network->ssid, network->ssid_len), @@ -2712,7 +2692,6 @@ static inline void rtllib_process_probe_response( WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); -#endif memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index ae9f7727ed3..0a59720f9cb 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -663,14 +663,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) stats->tx_dropped++; goto success; } - #ifdef CONFIG_RTLLIB_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", eap_get_type(eap->type)); } - #endif /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); From 25d289fbb6a36a15d268aa4b6a6471e0ec2e7c25 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 18:56:16 -0500 Subject: [PATCH 0326/1519] staging: rtl8192e: Remove dead code associated with _RTL8192_EXT_PATCH_ --- drivers/staging/rtl8192e/rtl819x_TSProc.c | 61 ----------------------- 1 file changed, 61 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 3fbf91c8cbf..942c6f80a2f 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -130,54 +130,6 @@ void ResetRxTsEntry(PRX_TS_RECORD pTS) pTS->RxTimeoutIndicateSeq = 0xffff; ResetBaEntry(&pTS->RxAdmittedBARecord); } -#ifdef _RTL8192_EXT_PATCH_ -void ResetAdmitTRStream(struct rtllib_device *ieee, u8 *Addr) -{ - u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; - struct list_head* psearch_list; - PTS_COMMON_INFO pRet = NULL; - PRX_TS_RECORD pRxTS = NULL; - PTX_TS_RECORD pTxTS = NULL; - - if (ieee->iw_mode != IW_MODE_MESH) - return; - - search_dir[DIR_DOWN] = true; - psearch_list = &ieee->Rx_TS_Admit_List; - for (dir = 0; dir <= DIR_BI_DIR; dir++) - { - if (search_dir[dir] ==false ) - continue; - list_for_each_entry(pRet, psearch_list, List){ - if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir)) - { - pRxTS = (PRX_TS_RECORD)pRet; - pRxTS->RxIndicateSeq = 0xffff; - pRxTS->RxTimeoutIndicateSeq = 0xffff; - } - - } - } - search_dir[DIR_UP] = true; - psearch_list = &ieee->Tx_TS_Admit_List; - for (dir = 0; dir <= DIR_BI_DIR; dir++) - { - if (search_dir[dir] ==false ) - continue; - list_for_each_entry(pRet, psearch_list, List){ - if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir)) - { - pTxTS = (PTX_TS_RECORD)pRet; - pTxTS->TxCurSeq = 0xffff; - } - - } - } - - return; -} -#endif void TSInitialize(struct rtllib_device *ieee) { @@ -364,19 +316,6 @@ void MakeTSEntry( pTsCommonInfo->TClasNum = TCLAS_Num; } -#ifdef _RTL8192_EXT_PATCH_ -void dump_ts_list(struct list_head * ts_list) -{ - PTS_COMMON_INFO pRet = NULL; - u8 i=0; - list_for_each_entry(pRet, ts_list, List){ - printk("i=%d ADD:"MAC_FMT", TID:%d, dir:%d\n",i,MAC_ARG(pRet->Addr), pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); - i++; - } - -} -#endif - bool GetTs( struct rtllib_device* ieee, PTS_COMMON_INFO *ppTS, From 5c9e4285b5dac303d0ceffbab5f56d400f6aab1b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 19:03:29 -0500 Subject: [PATCH 0327/1519] staging: rtl8192e: Remove dead code associated with CONFIG_RTLWIFI_DEBUGFS Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 3 - drivers/staging/rtl8192e/rtl_core.h | 4 - drivers/staging/rtl8192e/rtl_debug.c | 174 --------------------------- drivers/staging/rtl8192e/rtl_debug.h | 7 -- drivers/staging/rtl8192e/rtl_ps.c | 5 - 5 files changed, 193 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 217b298a9e8..babaf27e8f4 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1718,9 +1718,6 @@ void rtl819x_watchdog_wqcallback(void *data) if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) &&\ (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\ (!ieee->proto_stoppping) && !ieee->wx_set_enc -#ifdef CONFIG_RTLWIFI_DEBUGFS - && (!priv->debug->hw_holding) -#endif ){ if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE)&& (!ieee->bNetPromiscuousMode)) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 99a40a00d31..c7e2f87268e 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -590,10 +590,6 @@ typedef struct r8192_priv struct rtl819x_ops *ops; struct rtllib_device *rtllib; -#ifdef CONFIG_RTLWIFI_DEBUGFS - rtl_fs_debug *debug; -#endif /* CONFIG_IWLWIFI_DEBUGFS */ - work_struct_rsl reset_wq; LOG_INTERRUPT_8190_T InterruptLog; diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 7381fd6a3bc..91b2daa523a 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -109,180 +109,6 @@ void rtl8192_dump_reg(struct net_device *dev) printk("\n"); } -#ifdef CONFIG_RTLWIFI_DEBUGFS -/* debugfs related stuff */ -static struct dentry *rtl_debugfs_root; -static int rtl_dbgfs_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static ssize_t rtl_dbgfs_register_write(struct file *file, - const char __user *user_buf, - size_t count, - loff_t *ppos) -{ - struct r8192_priv *priv = (struct r8192_priv *)file->private_data; - char buf[32]; - int buf_size; - u32 type, offset; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - if (sscanf(buf, "%x,%x", &type, &offset ) == 2) { - priv->debug->hw_type = type; - priv->debug->hw_offset = offset; - } else { - priv->debug->hw_type = 0; - priv->debug->hw_offset = 0; - } - - return count; -} - -void rtl_hardware_grab(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - int t = 0; - int timeout = 20; - u32 mask = RF_CHANGE_BY_HW|RF_CHANGE_BY_PS|RF_CHANGE_BY_IPS; - - priv->debug->hw_holding = true; - rtllib_ips_leave_wq(dev); - do { - if ((priv->rtllib->RfOffReason & mask)) { - msleep(100); - t++; - } else { - return; - } - } while (t < timeout); - - return; -} - -static ssize_t rtl_dbgfs_register_read(struct file *file, - char __user *user_buf, - size_t count, - loff_t *ppos) -{ - struct r8192_priv *priv = (struct r8192_priv *)file->private_data; - struct net_device *dev = priv->rtllib->dev; - ssize_t ret = 0; - char buf[2048]; - int n,i; - u32 len = 0; - u32 max = 0xff; - u32 page_no, path; - - rtl_hardware_grab(dev); - - if (!priv->debug->hw_type) { - page_no = (priv->debug->hw_offset > 0x0f)? 0x0f: priv->debug->hw_offset; - { - len += snprintf(buf + len,count - len, - "\n#################### MAC page- %x##################\n ", page_no); - for (n=0;n<=max;) { - len += snprintf(buf + len, count - len, "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(buf + len, count - len, - "%2.2x ",read_nic_byte(dev,((page_no<<8)|n))); - } - } - } else { - path = (priv->debug->hw_offset < RF90_PATH_MAX)? priv->debug->hw_offset:(RF90_PATH_MAX - 1); - len += snprintf(buf + len, count - len, - "\n#################### RF-PATH-%x ##################\n ", 0x0a+path); - for (n=0;n<=max;) { - len += snprintf(buf+ len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) - len += snprintf(buf + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)path,\ - n, bMaskDWord)); - } - } - - priv->debug->hw_holding = false; - - len += snprintf(buf + len, count - len, "\n"); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); - return ret; -} - -static const struct file_operations rtl_register_debug = { - .read = rtl_dbgfs_register_read, - .write = rtl_dbgfs_register_write, - .open = rtl_dbgfs_open, - .owner = THIS_MODULE -}; - -int rtl_debug_module_init(struct r8192_priv *priv, const char *name) -{ - rtl_fs_debug *debug; - int ret = 0; - - if (!rtl_debugfs_root) - return -ENOENT; - - debug = kzalloc(sizeof(rtl_fs_debug), GFP_KERNEL); - if (!debug) { - ret = -ENOMEM; - goto err; - } - priv->debug = debug; - - debug->name = name; - debug->dir_drv = debugfs_create_dir(name, rtl_debugfs_root); - if (!debug->dir_drv ) { - ret = -ENOENT; - goto err; - } - - debug->debug_register = debugfs_create_file("debug_register", S_IRUGO, - debug->dir_drv, priv, &rtl_register_debug); - if (!debug->debug_register) { - ret = -ENOENT; - goto err; - } - - return 0; -err: - RT_TRACE(COMP_DBG, "Can't open the debugfs directory\n"); - rtl_debug_module_remove(priv); - return ret; - -} - -void rtl_debug_module_remove(struct r8192_priv *priv) -{ - if (!priv->debug) - return; - debugfs_remove(priv->debug->debug_register); - debugfs_remove(priv->debug->dir_drv); - kfree(priv->debug); - priv->debug = NULL; -} - -int rtl_create_debugfs_root(void) -{ - rtl_debugfs_root = debugfs_create_dir(DRV_NAME, NULL); - if (!rtl_debugfs_root) - return -ENOENT; - - return 0; -} - -void rtl_remove_debugfs_root(void) -{ - debugfs_remove(rtl_debugfs_root); - rtl_debugfs_root = NULL; -} -#endif - /**************************************************************************** -----------------------------PROCFS STUFF------------------------- *****************************************************************************/ diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 2e23bf65a8d..db8be0e3435 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -272,12 +272,6 @@ void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); /* debugfs stuff */ -#ifdef CONFIG_RTLWIFI_DEBUGFS -int rtl_debug_module_init(struct r8192_priv *priv, const char *name); -void rtl_debug_module_remove(struct r8192_priv *priv); -int rtl_create_debugfs_root(void); -void rtl_remove_debugfs_root(void); -#else static inline int rtl_debug_module_init(struct r8192_priv *priv, const char *name) { return 0; } @@ -289,7 +283,6 @@ static inline int rtl_create_debugfs_root(void) { } static inline void rtl_remove_debugfs_root(void) { } -#endif /* proc stuff */ void rtl8192_proc_init_one(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 39baa596e29..00306293f77 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -42,11 +42,6 @@ void rtl8192_hw_sleep_down(struct net_device *dev) spin_unlock_irqrestore(&priv->rf_ps_lock,flags); RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); -#ifdef CONFIG_RTLWIFI_DEBUGFS - if (priv->debug->hw_holding) { - return; - } -#endif MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); } From ff02d6bf972254710aa41dfdafab1d8ede3083a8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 21:58:52 -0500 Subject: [PATCH 0328/1519] staging: rtl8192e: Remove dead code associated with CONFIG_FW_SETCHAN Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index babaf27e8f4..2a842f42556 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -566,10 +566,6 @@ void rtl8192_set_chan(struct net_device *dev,short ch) if (priv->rf_set_chan) priv->rf_set_chan(dev,priv->chan); -#ifdef CONFIG_FW_SETCHAN - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_CHAN_SET); -#endif - #endif } From 2e8bb570266e5e89837f117c08c0636f4b3e3d2b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 22:01:47 -0500 Subject: [PATCH 0329/1519] staging: rtl8192e: Remove LOOP_TEST as parameter Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 2a842f42556..7a7e91efebc 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -22,7 +22,6 @@ * Contact Information: * wlanfae ******************************************************************************/ -#undef LOOP_TEST #undef RX_DONT_PASS_UL #undef DEBUG_EPROM #undef DEBUG_RX_VERBOSE @@ -559,14 +558,8 @@ void rtl8192_set_chan(struct net_device *dev,short ch) priv->chan = ch; - -#ifndef LOOP_TEST - - if (priv->rf_set_chan) priv->rf_set_chan(dev,priv->chan); - -#endif } void rtl8192_update_cap(struct net_device* dev, u16 cap) From d22a33646965656d800e4c7afa8c1b54a4ba63fe Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 22:03:46 -0500 Subject: [PATCH 0330/1519] staging: rtl8192e: Remove dead code associated with EFUSE_REPG_WORKAROUND Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index c7e2f87268e..ae858eb253b 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -773,11 +773,6 @@ typedef struct r8192_priv u16 EfuseUsedBytes; u8 EfuseUsedPercentage; -#ifdef EFUSE_REPG_WORKAROUND - bool efuse_RePGSec1Flag; - u8 efuse_RePGData[8]; -#endif - short epromtype; u16 eeprom_vid; u16 eeprom_did; From c9d9a8016daab38681b498b094e6cac876a12fc4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 22:06:21 -0500 Subject: [PATCH 0331/1519] staging: rtl8192e: Remove conditional code associated with EEPROM_OLD_FORMAT_SUPPORT Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 1 - drivers/staging/rtl8192e/rtl_core.h | 6 ------ 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index a56900f8341..fb007491c5f 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -1,4 +1,3 @@ -ccflags-y += -DEEPROM_OLD_FORMAT_SUPPORT=1 ccflags-y += -DUSE_FW_SOURCE_IMG_FILE ccflags-y += -DCONFIG_PM_RTL ccflags-y += -DCONFIG_PM diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index ae858eb253b..a853bee6b2d 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -786,15 +786,9 @@ typedef struct r8192_priv u8 EEPROMPwrGroup[2][3]; u8 EEPROMOptional; -#if (EEPROM_OLD_FORMAT_SUPPORT == 1) u8 EEPROMTxPowerLevelCCK[14]; u8 EEPROMTxPowerLevelOFDM24G[14]; u8 EEPROMTxPowerLevelOFDM5G[24]; -#else - u8 RfCckChnlAreaTxPwr[2][3]; - u8 RfOfdmChnlAreaTxPwr1T[2][3]; - u8 RfOfdmChnlAreaTxPwr2T[2][3]; -#endif u8 EEPROMRfACCKChnl1TxPwLevel[3]; u8 EEPROMRfAOfdmChnlTxPwLevel[3]; u8 EEPROMRfCCCKChnl1TxPwLevel[3]; From f60949901cc5f1c02268938f63306ac5a36c9cba Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 14 Jul 2011 23:58:27 -0500 Subject: [PATCH 0332/1519] staging: rtl8192e: Remove dead code associated with CONFIG_RTL_RFKILL Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 16 ---------------- drivers/staging/rtl8192e/rtl_core.h | 7 ------- 2 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7a7e91efebc..f8040acb91d 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1147,11 +1147,7 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->ScanOperationBackupHandler = PHY_ScanOperationBackup8192; -#ifdef CONFIG_RTL_RFKILL - priv->rtllib->rtllib_rfkill_poll = rtl8192_rfkill_poll; -#else priv->rtllib->rtllib_rfkill_poll = NULL; -#endif } static void rtl8192_init_priv_constant(struct net_device* dev) @@ -3056,15 +3052,6 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, if (priv->polling_timer_on == 0){ check_rfctrl_gpio_timer((unsigned long)dev); } -#ifdef CONFIG_RTL_RFKILL - if (priv->ops->init_before_adapter_start) { - priv->ops->init_before_adapter_start(dev); - priv->initialized_at_probe = true; - } - if (!rtl8192_rfkill_init(dev)) { - goto fail1; - } -#endif RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; @@ -3099,9 +3086,6 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv ; if (dev){ -#ifdef CONFIG_RTL_RFKILL - rtl8192_rfkill_exit(dev); -#endif unregister_netdev(dev); priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index a853bee6b2d..ffbfb290866 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -56,10 +56,6 @@ #include "r8190P_def.h" #include "r8192E_dev.h" -#ifdef CONFIG_RTL_RFKILL -#include "rtl_rfkill.h" -#endif - #include "rtl_debug.h" #include "rtl_eeprom.h" #include "rtl_ps.h" @@ -678,9 +674,6 @@ typedef struct r8192_priv u8 RegCWinMin; u8 keepAliveLevel; -#ifdef CONFIG_RTL_RFKILL - bool rfkill_off; -#endif bool sw_radio_on; bool bHwRadioOff; bool pwrdown; From 66898177e7e5486dc77a4ba742efa4e2e9e900a4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 15 Jul 2011 12:32:41 -0500 Subject: [PATCH 0333/1519] staging: rtl8192e: Fix unload/reload problem The driver is not releasing the memory region that was mapped. As a result, the driver cannot be unloaded and reloaded. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index f8040acb91d..f8a13d95985 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -3122,6 +3122,11 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) if (priv->scan_cmd) kfree(priv->scan_cmd); + if (dev->mem_start != 0) { + iounmap((void *)dev->mem_start); + release_mem_region(pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1)); + } } else{ priv=rtllib_priv(dev); } From bca54c0184b3b3913ee9660f01e42ccb40abdac4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 15 Jul 2011 16:01:32 -0500 Subject: [PATCH 0334/1519] staging: rtl8192e: Fix compilation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the driver is compiled, the following messages result: CC [M] drivers/staging/rtl8192e/r8192E_phy.o drivers/staging/rtl8192e/r8192E_phy.c: In function ‘rtl8192_phy_ConfigRFWithHeaderFile’: drivers/staging/rtl8192e/r8192E_phy.c:791:25: warning: array subscript is above array bounds drivers/staging/rtl8192e/r8192E_phy.c:780:25: warning: array subscript is above array bounds Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_hwimg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.h b/drivers/staging/rtl8192e/r8192E_hwimg.h index 061a9c34ac8..019836bb36c 100644 --- a/drivers/staging/rtl8192e/r8192E_hwimg.h +++ b/drivers/staging/rtl8192e/r8192E_hwimg.h @@ -37,9 +37,9 @@ extern u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE]; extern u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] ; #define RadioB_ArrayLengthPciE 78 extern u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] ; -#define RadioC_ArrayLengthPciE 1 +#define RadioC_ArrayLengthPciE 2 extern u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] ; -#define RadioD_ArrayLengthPciE 1 +#define RadioD_ArrayLengthPciE 2 extern u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] ; #define MACPHY_ArrayLengthPciE 18 extern u32 Rtl8192PciEMACPHY_Array[MACPHY_ArrayLengthPciE] ; From 0157d2e55c04a6fc7b69e4f9f0daed48c3597415 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:04:31 -0500 Subject: [PATCH 0335/1519] staging: rtl8192e: Convert typedef BSS_QOS to struct bss_qos Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 8f5e0fdd2f3..49e49cb9df7 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -352,7 +352,7 @@ typedef struct _STA_QOS{ #define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3) #define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value) -typedef struct _BSS_QOS{ +struct bss_qos { QOS_MODE bdQoSMode; u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; @@ -365,7 +365,7 @@ typedef struct _BSS_QOS{ u8 QBssLoad[QBSS_LOAD_SIZE]; bool bQBssLoadValid; -}BSS_QOS, *PBSS_QOS; +};//, *struct bss_qos *; #define sQoSCtlLng 2 #define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) From 60554f2bdb1579ca54631e99642025797f860eb7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:10:03 -0500 Subject: [PATCH 0336/1519] staging: rtl8192e: Convert typedef TX_TS_RECORD to struct tx_ts_record Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 14 +++++++------- drivers/staging/rtl8192e/rtl819x_TS.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TSProc.c | 12 ++++++------ drivers/staging/rtl8192e/rtllib.h | 6 +++--- drivers/staging/rtl8192e/rtllib_tx.c | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index ce5343e5245..e35bc52afe1 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -32,7 +32,7 @@ void DeActivateBAEntry( struct rtllib_device* ieee, PBA_RECORD pBA) pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA( struct rtllib_device* ieee, PTX_TS_RECORD pTxTs) +u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) { PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; @@ -329,7 +329,7 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr* rsp = NULL; PBA_RECORD pPendingBA, pAdmittedBA; - PTX_TS_RECORD pTS = NULL; + struct tx_ts_record *pTS = NULL; u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; PBA_PARAM_SET pBaParamSet = NULL; @@ -475,7 +475,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) } else { - PTX_TS_RECORD pTxTs; + struct tx_ts_record *pTxTs; if (!GetTs( ieee, @@ -501,7 +501,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) void TsInitAddBA( struct rtllib_device* ieee, - PTX_TS_RECORD pTS, + struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending ) @@ -532,7 +532,7 @@ TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELEC if (TxRxSelect == TX_DIR) { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; + struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo; if (TxTsDeleteBA(ieee, pTxTs)) rtllib_send_DELBA( @@ -556,7 +556,7 @@ TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELEC } void BaSetupTimeOut(unsigned long data) { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; pTxTs->bAddBaReqInProgress = false; pTxTs->bAddBaReqDelayed = true; @@ -565,7 +565,7 @@ void BaSetupTimeOut(unsigned long data) void TxBaInactTimeout(unsigned long data) { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); rtllib_send_DELBA( diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 095edfde6db..75006c06b87 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -42,7 +42,7 @@ typedef struct _TS_COMMON_INFO{ u8 TClasNum; } TS_COMMON_INFO, *PTS_COMMON_INFO; -typedef struct _TX_TS_RECORD{ +struct tx_ts_record { TS_COMMON_INFO TsCommonInfo; u16 TxCurSeq; BA_RECORD TxPendingBARecord; @@ -53,7 +53,7 @@ typedef struct _TX_TS_RECORD{ u8 bDisable_AddBa; struct timer_list TsAddBaTimer; u8 num; -} TX_TS_RECORD, *PTX_TS_RECORD; +}; typedef struct _RX_TS_RECORD { TS_COMMON_INFO TsCommonInfo; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 942c6f80a2f..ca5effae57b 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -93,7 +93,7 @@ void RxPktPendingTimeout(unsigned long data) void TsAddBaProcess(unsigned long data) { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; + struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]); @@ -111,7 +111,7 @@ void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) pTsCommonInfo->TClasNum = 0; } -void ResetTxTsEntry(PTX_TS_RECORD pTS) +void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->TxCurSeq = 0; @@ -133,7 +133,7 @@ void ResetRxTsEntry(PRX_TS_RECORD pTS) void TSInitialize(struct rtllib_device *ieee) { - PTX_TS_RECORD pTxTS = ieee->TxTsRecord; + struct tx_ts_record *pTxTS = ieee->TxTsRecord; PRX_TS_RECORD pRxTS = ieee->RxTsRecord; PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; @@ -398,7 +398,7 @@ bool GetTs( list_del_init(&(*ppTS)->List); if (TxRxSelect==TX_DIR) { - PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); + struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); ResetTxTsEntry(tmp); } else{ @@ -470,7 +470,7 @@ void RemoveTsEntry( } } else{ - PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs; + struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; del_timer_sync(&pTxTS->TsAddBaTimer); } } @@ -555,7 +555,7 @@ void RemoveAllTS(struct rtllib_device* ieee) } } -void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS) +void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS) { if (pTxTS->bAddBaReqInProgress == false) { diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d1c35503879..ade98889235 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2160,7 +2160,7 @@ struct rtllib_device { struct list_head Tx_TS_Admit_List; struct list_head Tx_TS_Pending_List; struct list_head Tx_TS_Unused_List; - TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM]; + struct tx_ts_record TxTsRecord[TOTAL_TS_NUM]; struct list_head Rx_TS_Admit_List; struct list_head Rx_TS_Pending_List; struct list_head Rx_TS_Unused_List; @@ -2913,7 +2913,7 @@ extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate); extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); -extern void TsInitAddBA( struct rtllib_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); +extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); extern void TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); @@ -2928,7 +2928,7 @@ extern bool GetTs( bool bAddNewTs ); extern void TSInitialize(struct rtllib_device *ieee); -extern void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD pTxTS); +extern void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS); extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr); extern void RemoveAllTS(struct rtllib_device* ieee); void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 0a59720f9cb..09032594cfa 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -290,7 +290,7 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - PTX_TS_RECORD pTxTs = NULL; + struct tx_ts_record *pTxTs = NULL; struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; if (rtllib_act_scanning(ieee,false)) @@ -535,7 +535,7 @@ u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) return 0; if (IsQoSDataFrame(skb->data)) { - PTX_TS_RECORD pTS = NULL; + struct tx_ts_record *pTS = NULL; if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, skb->priority, TX_DIR, true)) { return 0; From 2c47ae282a4bbaebfdbba614fb6133db520212ba Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:11:56 -0500 Subject: [PATCH 0337/1519] staging: rtl8192e: Convert typedef RX_TS_RECORD to struct rx_ts_record Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192e/rtl819x_TS.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TSProc.c | 10 +++++----- drivers/staging/rtl8192e/rtllib.h | 4 ++-- drivers/staging/rtl8192e/rtllib_rx.c | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index e35bc52afe1..42e66a5380c 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -53,7 +53,7 @@ u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) return bSendDELBA; } -u8 RxTsDeleteBA( struct rtllib_device* ieee, PRX_TS_RECORD pRxTs) +u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) { PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; @@ -244,7 +244,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) PBA_PARAM_SET pBaParamSet = NULL; u16* pBaTimeoutVal = NULL; PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; - PRX_TS_RECORD pTS = NULL; + struct rx_ts_record *pTS = NULL; if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) { @@ -457,7 +457,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) if (pDelBaParamSet->field.Initiator == 1) { - PRX_TS_RECORD pRxTs; + struct rx_ts_record *pRxTs; if ( !GetTs( ieee, @@ -544,7 +544,7 @@ TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELEC } else if (TxRxSelect == RX_DIR) { - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo; + struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo; if (RxTsDeleteBA(ieee, pRxTs)) rtllib_send_DELBA( ieee, @@ -578,7 +578,7 @@ void TxBaInactTimeout(unsigned long data) void RxBaInactTimeout(unsigned long data) { - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; + struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 75006c06b87..aa758a6d73d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -55,7 +55,7 @@ struct tx_ts_record { u8 num; }; -typedef struct _RX_TS_RECORD { +struct rx_ts_record { TS_COMMON_INFO TsCommonInfo; u16 RxIndicateSeq; u16 RxTimeoutIndicateSeq; @@ -65,7 +65,7 @@ typedef struct _RX_TS_RECORD { u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; -} RX_TS_RECORD, *PRX_TS_RECORD; +}; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index ca5effae57b..2ddb65226e8 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -31,7 +31,7 @@ void TsInactTimeout(unsigned long data) void RxPktPendingTimeout(unsigned long data) { - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; + struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); PRX_REORDER_ENTRY pReorderEntry = NULL; @@ -123,7 +123,7 @@ void ResetTxTsEntry(struct tx_ts_record *pTS) ResetBaEntry(&pTS->TxPendingBARecord); } -void ResetRxTsEntry(PRX_TS_RECORD pTS) +void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->RxIndicateSeq = 0xffff; @@ -134,7 +134,7 @@ void ResetRxTsEntry(PRX_TS_RECORD pTS) void TSInitialize(struct rtllib_device *ieee) { struct tx_ts_record *pTxTS = ieee->TxTsRecord; - PRX_TS_RECORD pRxTS = ieee->RxTsRecord; + struct rx_ts_record *pRxTS = ieee->RxTsRecord; PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__); @@ -402,7 +402,7 @@ bool GetTs( ResetTxTsEntry(tmp); } else{ - PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); + struct rx_ts_record *tmp = container_of(*ppTS, struct rx_ts_record, TsCommonInfo); ResetRxTsEntry(tmp); } @@ -445,7 +445,7 @@ void RemoveTsEntry( if (TxRxSelect == RX_DIR) { PRX_REORDER_ENTRY pRxReorderEntry; - PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; + struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if (timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index ade98889235..4fd0e0c12b5 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2164,7 +2164,7 @@ struct rtllib_device { struct list_head Rx_TS_Admit_List; struct list_head Rx_TS_Pending_List; struct list_head Rx_TS_Unused_List; - RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM]; + struct rx_ts_record RxTsRecord[TOTAL_TS_NUM]; RX_REORDER_ENTRY RxReorderEntry[128]; struct list_head RxReorder_Unused_List; u8 ForcedPriority; @@ -2993,7 +2993,7 @@ bool rtllib_MgntDisconnect(struct rtllib_device* rtllib,u8 asRsn); * ieee handler to refer to it. */ extern void rtllib_update_active_chan_map(struct rtllib_device *ieee); -extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS); +extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS); extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev); extern int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_info_element *info_element, diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 2c4e777f3c0..35715315c67 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -447,7 +447,7 @@ drop: } bool AddReorderEntry( - PRX_TS_RECORD pTS, + struct rx_ts_record *pTS, PRX_REORDER_ENTRY pReorderEntry ) { @@ -527,7 +527,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx } void -rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS) +rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { PRX_REORDER_ENTRY pRxReorderEntry; struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; @@ -559,7 +559,7 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, PRX_TS_RECORD pTS) void RxReorderIndicatePacket( struct rtllib_device *ieee, struct rtllib_rxb* prxb, - PRX_TS_RECORD pTS, + struct rx_ts_record *pTS, u16 SeqNum) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -896,7 +896,7 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u } } } else { - PRX_TS_RECORD pRxTS = NULL; + struct rx_ts_record *pRxTS = NULL; if (GetTs(ieee, (PTS_COMMON_INFO*) &pRxTS, hdr->addr2, (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && @@ -1253,7 +1253,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; struct rtllib_crypt_data *crypt = NULL; struct rtllib_rxb* rxb = NULL; - PRX_TS_RECORD pTS = NULL; + struct rx_ts_record *pTS = NULL; u16 fc, sc, SeqNum = 0; u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; u8 dst[ETH_ALEN], src[ETH_ALEN], bssid[ETH_ALEN] = {0}, *payload; From 74724de1c40192d74a213e615b945df8de935ca2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:19:19 -0500 Subject: [PATCH 0338/1519] staging: rtl8192e: Convert typedef TS_COMMON_INFO to struct ts_common_info Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192e/rtl819x_TS.h | 8 ++++---- drivers/staging/rtl8192e/rtl819x_TSProc.c | 20 ++++++++++---------- drivers/staging/rtl8192e/rtllib.h | 4 ++-- drivers/staging/rtl8192e/rtllib_rx.c | 4 ++-- drivers/staging/rtl8192e/rtllib_tx.c | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 42e66a5380c..165bfae1910 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -273,7 +273,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) } if (!GetTs( ieee, - (PTS_COMMON_INFO*)(&pTS), + (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), RX_DIR, @@ -361,7 +361,7 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) } - if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), TX_DIR, false)) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; @@ -461,7 +461,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) if ( !GetTs( ieee, - (PTS_COMMON_INFO*)&pRxTs, + (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, @@ -479,7 +479,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) if (!GetTs( ieee, - (PTS_COMMON_INFO*)&pTxTs, + (struct ts_common_info **)&pTxTs, dst, (u8)pDelBaParamSet->field.TID, TX_DIR, @@ -527,7 +527,7 @@ TsInitAddBA( } void -TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) +TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, TR_SELECT TxRxSelect) { if (TxRxSelect == TX_DIR) diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index aa758a6d73d..20f8486c5fe 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -31,7 +31,7 @@ typedef enum _TR_SELECT { RX_DIR = 1, } TR_SELECT, *PTR_SELECT; -typedef struct _TS_COMMON_INFO{ +struct ts_common_info { struct list_head List; struct timer_list SetupTimer; struct timer_list InactTimer; @@ -40,10 +40,10 @@ typedef struct _TS_COMMON_INFO{ QOS_TCLAS TClass[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; -} TS_COMMON_INFO, *PTS_COMMON_INFO; +}; struct tx_ts_record { - TS_COMMON_INFO TsCommonInfo; + struct ts_common_info TsCommonInfo; u16 TxCurSeq; BA_RECORD TxPendingBARecord; BA_RECORD TxAdmittedBARecord; @@ -56,7 +56,7 @@ struct tx_ts_record { }; struct rx_ts_record { - TS_COMMON_INFO TsCommonInfo; + struct ts_common_info TsCommonInfo; u16 RxIndicateSeq; u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 2ddb65226e8..6c60df074b7 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -102,7 +102,7 @@ void TsAddBaProcess(unsigned long data) } -void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) +void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); @@ -209,7 +209,7 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime) +void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); @@ -219,12 +219,12 @@ void AdmitTS(struct rtllib_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 Inac } -PTS_COMMON_INFO SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) +struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) { u8 dir; bool search_dir[4] = {0, 0, 0, 0}; struct list_head* psearch_list; - PTS_COMMON_INFO pRet = NULL; + struct ts_common_info *pRet = NULL; if (ieee->iw_mode == IW_MODE_MASTER) { if (TxRxSelect == TX_DIR) @@ -291,7 +291,7 @@ PTS_COMMON_INFO SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID } void MakeTSEntry( - PTS_COMMON_INFO pTsCommonInfo, + struct ts_common_info *pTsCommonInfo, u8* Addr, PTSPEC_BODY pTSPEC, PQOS_TCLAS pTCLAS, @@ -318,7 +318,7 @@ void MakeTSEntry( bool GetTs( struct rtllib_device* ieee, - PTS_COMMON_INFO *ppTS, + struct ts_common_info **ppTS, u8* Addr, u8 TID, TR_SELECT TxRxSelect, @@ -394,7 +394,7 @@ bool GetTs( RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); if (!list_empty(pUnusedList)) { - (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List); + (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); list_del_init(&(*ppTS)->List); if (TxRxSelect==TX_DIR) { @@ -434,7 +434,7 @@ bool GetTs( void RemoveTsEntry( struct rtllib_device* ieee, - PTS_COMMON_INFO pTs, + struct ts_common_info *pTs, TR_SELECT TxRxSelect ) { @@ -477,7 +477,7 @@ void RemoveTsEntry( void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) { - PTS_COMMON_INFO pTS, pTmpTS; + struct ts_common_info *pTS, *pTmpTS; printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) @@ -524,7 +524,7 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) void RemoveAllTS(struct rtllib_device* ieee) { - PTS_COMMON_INFO pTS, pTmpTS; + struct ts_common_info *pTS, *pTmpTS; list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 4fd0e0c12b5..e9317d267f3 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2914,14 +2914,14 @@ extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct rtllib_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); +extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, TR_SELECT TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); extern void ResetBaEntry( PBA_RECORD pBA); extern bool GetTs( struct rtllib_device* ieee, - PTS_COMMON_INFO *ppTS, + struct ts_common_info **ppTS, u8* Addr, u8 TID, TR_SELECT TxRxSelect, diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 35715315c67..3c8c11c9923 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -897,7 +897,7 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u } } else { struct rx_ts_record *pRxTS = NULL; - if (GetTs(ieee, (PTS_COMMON_INFO*) &pRxTS, hdr->addr2, + if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2, (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { @@ -1356,7 +1356,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true); + GetTs(ieee,(struct ts_common_info **) &pTS,hdr->addr2,TID,RX_DIR,true); if (TID !=0 && TID !=3){ ieee->bis_any_nonbepkts = true; } diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 09032594cfa..dae5df4c732 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -312,7 +312,7 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) return; if (pHTInfo->bCurrentAMPDUEnable){ - if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ printk("%s: can't get TS\n", __func__); return; } @@ -536,7 +536,7 @@ u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) if (IsQoSDataFrame(skb->data)) { struct tx_ts_record *pTS = NULL; - if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, skb->priority, TX_DIR, true)) + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) { return 0; } From 7796d93eae46054d5a3bb5411fde735801998dc5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:22:19 -0500 Subject: [PATCH 0339/1519] staging: rtl8192e: Convert typedef RT_HIGH_THROUGHPUT to struct rt_hi_throughput Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 +-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 36 +++++++++++------------ drivers/staging/rtl8192e/rtl_dm.c | 8 ++--- drivers/staging/rtl8192e/rtllib.h | 4 +-- drivers/staging/rtl8192e/rtllib_module.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 +-- drivers/staging/rtl8192e/rtllib_tx.c | 8 ++--- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 3918705d07f..cfa7e81beea 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -213,7 +213,7 @@ typedef enum _HT_AGGRE_MODE_E{ }HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; -typedef struct _RT_HIGH_THROUGHPUT{ +struct rt_hi_throughput { u8 bEnableHT; u8 bCurrentHTSupport; @@ -295,7 +295,7 @@ typedef struct _RT_HIGH_THROUGHPUT{ u8 WAIotTH; u8 bAcceptAddbaReq; -} __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT; +} __packed; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index a457e302abc..94ec155c7ba 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -59,7 +59,7 @@ static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; void HTUpdateDefaultSetting(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->bAcceptAddbaReq = 1; @@ -182,7 +182,7 @@ void HTDebugHTInfo(u8* InfoIE, u8* TitleString) bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) { bool retValue = false; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; if (pHTInfo->bCurrentHTSupport == false ) retValue = false; @@ -201,7 +201,7 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) { bool retValue = false; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; if (pHTInfo->bCurrentHTSupport == false ) retValue = false; @@ -240,7 +240,7 @@ u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate) u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; u8 isShortGI = (pHTInfo->bCurBW40MHz)? @@ -318,7 +318,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) void HTIOTPeerDetermine(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rtllib_network* net = &ieee->current_network; if (net->bssht.bdRT2RTAggregation){ pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; @@ -409,7 +409,7 @@ u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *netw u8 HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 retValue = false; u8 boundary=59; @@ -494,7 +494,7 @@ u8 HTIOTActDisableShortGI(struct rtllib_device* ieee,struct rtllib_network *network) { u8 retValue = 0; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) { @@ -515,7 +515,7 @@ HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *netwo void HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss) @@ -573,7 +573,7 @@ HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network * } void HTResetIOTSetting( - PRT_HIGH_THROUGHPUT pHTInfo + struct rt_hi_throughput *pHTInfo ) { pHTInfo->IOTAction = 0; @@ -584,7 +584,7 @@ void HTResetIOTSetting( void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) { - PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; + struct rt_hi_throughput *pHT = ieee->pHTInfo; PHT_CAPABILITY_ELE pCapELE = NULL; if ((posHTCap == NULL) || (pHT == NULL)) @@ -675,7 +675,7 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* } void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) { - PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; + struct rt_hi_throughput *pHT = ieee->pHTInfo; PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { @@ -834,7 +834,7 @@ u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTOnAssocRsp(struct rtllib_device *ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; PHT_CAPABILITY_ELE pPeerHTCap = NULL; PHT_INFORMATION_ELE pPeerHTInfo = NULL; u16 nMaxAMSDUSize = 0; @@ -946,7 +946,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) void HTSetConnectBwModeCallback(struct rtllib_device* ieee); void HTInitializeHTInfo(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; RTLLIB_DEBUG(RTLLIB_DL_HT, "===========>%s()\n", __func__); pHTInfo->bCurrentHTSupport = false; @@ -1008,7 +1008,7 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 bIOTAction = 0; RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); @@ -1077,7 +1077,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; if (pHTInfo->bCurrentHTSupport) @@ -1090,7 +1090,7 @@ void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_networ void HTUseDefaultSetting(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; if (pHTInfo->bEnableHT) { pHTInfo->bCurrentHTSupport = true; @@ -1139,7 +1139,7 @@ u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; if (pHTInfo->bRegBW40MHz == false) return; @@ -1178,7 +1178,7 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, void HTSetConnectBwModeCallback(struct rtllib_device* ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); if (pHTInfo->bCurBW40MHz) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index ca3001b257c..696e6c260c5 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -294,7 +294,7 @@ extern void init_rate_adaptive(struct net_device * dev) static void dm_check_rate_adaptive(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; u32 currentRATR, targetRATR = 0; u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; @@ -2493,7 +2493,7 @@ static void dm_check_edca_turbo( struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; static unsigned long lastTxOkCnt = 0; static unsigned long lastRxOkCnt = 0; @@ -2621,7 +2621,7 @@ static void dm_init_ctstoself(struct net_device * dev) static void dm_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; static unsigned long lastTxOkCnt = 0; static unsigned long lastRxOkCnt = 0; unsigned long curTxOkCnt = 0; @@ -2655,7 +2655,7 @@ static void dm_Init_WA_Broadcom_IOT(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - PRT_HIGH_THROUGHPUT pHTInfo = priv->rtllib->pHTInfo; + struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; pHTInfo->bWAIotBroadcom = false; pHTInfo->WAIotTH = WAIotTHVal; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index e9317d267f3..40e20db3795 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2139,7 +2139,7 @@ struct rtllib_device { RT_RF_CHANGE_SOURCE RfOffReason; bool is_set_key; bool wx_set_enc; - PRT_HIGH_THROUGHPUT pHTInfo; + struct rt_hi_throughput *pHTInfo; spinlock_t bw_spinlock; spinlock_t reorder_spinlock; @@ -2905,7 +2905,7 @@ extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* p extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame); -extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); +extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo); extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee); extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate); extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate); diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 3462e44ce23..65034a4588d 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -162,7 +162,7 @@ struct net_device *alloc_rtllib(int sizeof_priv) memset(ieee->swcamtable,0,sizeof(SW_CAM_TABLE)*32); rtllib_softmac_init(ieee); - ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); + ieee->pHTInfo = (struct rt_hi_throughput*)kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); if (ieee->pHTInfo == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 3c8c11c9923..a6a27847ada 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -562,7 +562,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, struct rx_ts_record *pTS, u16 SeqNum) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; PRX_REORDER_ENTRY pReorderEntry = NULL; struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; u8 WinSize = pHTInfo->RxReorderWinSize; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index e4fdcbd376d..7930a963757 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -212,7 +212,7 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 rate; if (pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) @@ -884,7 +884,7 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) u8 tmp_ht_cap_len = 0; u8* tmp_ht_info_buf = NULL; u8 tmp_ht_info_len = 0; - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8* tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index dae5df4c732..dd89b0bebec 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -289,7 +289,7 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) #define SN_LESS(a, b) (((a-b)&0x800)!=0) void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; @@ -375,7 +375,7 @@ extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, cb_desc* extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bUseShortGI = false; @@ -396,7 +396,7 @@ rtllib_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc) void rtllib_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc) { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bPacketBW = false; @@ -444,7 +444,7 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, cb_desc* tcb_desc, } else { - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; while (true) { if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) From 9801b9f5d740257f8cd19fe21b8c7ffe598b18af Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:24:02 -0500 Subject: [PATCH 0340/1519] staging: rtl8192e: Convert typedef RT_HTINFO_STA_ENTRY to struct rt_htinfo_sta_entry Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index cfa7e81beea..c3eaea4931b 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -299,7 +299,7 @@ struct rt_hi_throughput { -typedef struct _RT_HTINFO_STA_ENTRY{ +struct rt_htinfo_sta_entry { u8 bEnableHT; u8 bSupportCck; @@ -327,7 +327,7 @@ typedef struct _RT_HTINFO_STA_ENTRY{ u16 nAMSDU_MaxSize; -}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY; +};//, *struct rt_htinfo_sta_entry *; From a15e76ad063248ec1d06baee423881e7aa73066b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:26:49 -0500 Subject: [PATCH 0341/1519] staging: rtl8192e: Convert typedef BSS_HT to struct bss_ht Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index c3eaea4931b..d327a52a9d6 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -334,7 +334,7 @@ struct rt_htinfo_sta_entry { -typedef struct _BSS_HT{ +struct bss_ht { u8 bdSupportHT; @@ -350,7 +350,7 @@ typedef struct _BSS_HT{ u8 bdRT2RTLongSlotTime; u8 RT2RT_HT_Mode; u8 bdHT1R; -} __attribute__ ((packed)) BSS_HT, *PBSS_HT; +}; typedef struct _MIMO_RSSI{ u32 EnableAntenna; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 94ec155c7ba..c319ad5c1bd 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -990,7 +990,7 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) RegHTSuppRateSets[4] = 0x01; } } -void HTInitializeBssDesc(PBSS_HT pBssHT) +void HTInitializeBssDesc(struct bss_ht *pBssHT) { pBssHT->bdSupportHT = false; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 40e20db3795..4b8bd097638 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1688,7 +1688,7 @@ struct rtllib_network { u8 Turbo_Enable; u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; - BSS_HT bssht; + struct bss_ht bssht; bool broadcom_cap_exist; bool realtek_cap_exit; bool marvell_cap_exist; @@ -2898,7 +2898,7 @@ extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8 extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len); extern void HTOnAssocRsp(struct rtllib_device *ieee); extern void HTInitializeHTInfo(struct rtllib_device* ieee); -extern void HTInitializeBssDesc(PBSS_HT pBssHT); +extern void HTInitializeBssDesc(struct bss_ht *pBssHT); extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); From 039a34122a79acb999b47d655471720a7b2b0950 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:27:45 -0500 Subject: [PATCH 0342/1519] staging: rtl8192e: Convert typedef MIMO_RSSI to struct mimo_rssi Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index d327a52a9d6..afc12fb652a 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -352,14 +352,14 @@ struct bss_ht { u8 bdHT1R; }; -typedef struct _MIMO_RSSI{ +struct mimo_rssi { u32 EnableAntenna; u32 AntennaA; u32 AntennaB; u32 AntennaC; u32 AntennaD; u32 Average; -}MIMO_RSSI, *PMIMO_RSSI; +};//, *struct mimo_rssi *; typedef struct _MIMO_EVM{ u32 EVM1; From 7f5e8a0ab632fa900f2b744f0f392e3c456c3ef3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:28:52 -0500 Subject: [PATCH 0343/1519] staging: rtl8192e: Convert typedef MIMOPS_CTRL to struct mimops_ctrl Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index afc12fb652a..c5725051a74 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -195,11 +195,11 @@ typedef struct _HT_INFORMATION_ELE{ u8 BasicMSC[16]; } __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE; -typedef struct _MIMOPS_CTRL{ +struct mimops_ctrl { u8 MimoPsEnable:1; u8 MimoPsMode:1; u8 Reserved:6; -} MIMOPS_CTRL, *PMIMOPS_CTRL; +}; typedef enum _HT_SPEC_VER{ HT_SPEC_VER_IEEE = 0, From 407e998e593d379a30e32e71d10e4f589404d0f2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:31:44 -0500 Subject: [PATCH 0344/1519] staging: rtl8192e: Convert typedef HT_INFORMATION_ELE to struct ht_info_ele Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_HTProc.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index c5725051a74..505789710a0 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -168,7 +168,7 @@ typedef struct _HT_CAPABILITY_ELE{ } __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE; -typedef struct _HT_INFORMATION_ELE{ +struct ht_info_ele { u8 ControlChl; u8 ExtChlOffset:2; @@ -193,7 +193,7 @@ typedef struct _HT_INFORMATION_ELE{ u8 Rsvd4:4; u8 BasicMSC[16]; -} __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE; +} __packed; struct mimops_ctrl { u8 MimoPsEnable:1; @@ -233,7 +233,7 @@ struct rt_hi_throughput { HT_CAPABILITY_ELE SelfHTCap; - HT_INFORMATION_ELE SelfHTInfo; + struct ht_info_ele SelfHTInfo; u8 PeerHTCapBuf[32]; u8 PeerHTInfoBuf[32]; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index c319ad5c1bd..3ac68917181 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -126,14 +126,14 @@ void HTDebugHTInfo(u8* InfoIE, u8* TitleString) { static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; - PHT_INFORMATION_ELE pHTInfoEle; + struct ht_info_ele *pHTInfoEle; if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); - pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]); + pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]); }else - pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]); + pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]); RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString); @@ -676,7 +676,7 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) { struct rt_hi_throughput *pHT = ieee->pHTInfo; - PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; + struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo; if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); @@ -836,7 +836,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; PHT_CAPABILITY_ELE pPeerHTCap = NULL; - PHT_INFORMATION_ELE pPeerHTInfo = NULL; + struct ht_info_ele *pPeerHTInfo = NULL; u16 nMaxAMSDUSize = 0; u8* pMcsFilter = NULL; @@ -856,9 +856,9 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf); if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]); + pPeerHTInfo = (struct ht_info_ele *)(&pHTInfo->PeerHTInfoBuf[4]); else - pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf); + pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); @@ -1078,7 +1078,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; + struct ht_info_ele *pPeerHTInfo = (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; if (pHTInfo->bCurrentHTSupport) { From e92b71d571dfc08ae0ac792ffa463c0a601c32a5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 20:34:19 -0500 Subject: [PATCH 0345/1519] staging: rtl8192e: Convert typedef HT_CAPABILITY_ELE to struct ht_capab_ele Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_HTProc.c | 26 +++++++++++------------ drivers/staging/rtl8192e/rtllib_rx.c | 6 +++--- drivers/staging/rtl8192e/rtllib_wx.c | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 505789710a0..f2916e667b9 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -135,7 +135,7 @@ typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{ SC_MODE_FULL40MHZ = 3, }HT_BW40_SC_E; -typedef struct _HT_CAPABILITY_ELE{ +struct ht_capab_ele { u8 AdvCoding:1; u8 ChlWidth:1; @@ -165,7 +165,7 @@ typedef struct _HT_CAPABILITY_ELE{ u8 ASCap; -} __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE; +} __packed; struct ht_info_ele { @@ -232,7 +232,7 @@ struct rt_hi_throughput { HT_SPEC_VER ePeerHTSpecVer; - HT_CAPABILITY_ELE SelfHTCap; + struct ht_capab_ele SelfHTCap; struct ht_info_ele SelfHTInfo; u8 PeerHTCapBuf[32]; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 3ac68917181..10cce89b10e 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -98,14 +98,14 @@ void HTDebugHTCapability(u8* CapIE, u8* TitleString ) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; - PHT_CAPABILITY_ELE pCapELE; + struct ht_capab_ele *pCapELE; if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); - pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]); + pCapELE = (struct ht_capab_ele *)(&CapIE[4]); }else - pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]); + pCapELE = (struct ht_capab_ele *)(&CapIE[0]); RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString ); @@ -190,7 +190,7 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) retValue = false; else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) retValue = false; - else if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) + else if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ChlWidth) retValue = true; else retValue = false; @@ -209,14 +209,14 @@ bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) retValue = false; else if (is40MHz) { - if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) + if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) retValue = true; else retValue = false; } else { - if (((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) + if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) retValue = true; else retValue = false; @@ -585,7 +585,7 @@ void HTResetIOTSetting( void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) { struct rt_hi_throughput *pHT = ieee->pHTInfo; - PHT_CAPABILITY_ELE pCapELE = NULL; + struct ht_capab_ele *pCapELE = NULL; if ((posHTCap == NULL) || (pHT == NULL)) { @@ -598,11 +598,11 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* { u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); - pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]); + pCapELE = (struct ht_capab_ele *)&(posHTCap[4]); *len = 30 + 2; }else { - pCapELE = (PHT_CAPABILITY_ELE)posHTCap; + pCapELE = (struct ht_capab_ele *)posHTCap; *len = 26 + 2; } @@ -835,7 +835,7 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - PHT_CAPABILITY_ELE pPeerHTCap = NULL; + struct ht_capab_ele *pPeerHTCap = NULL; struct ht_info_ele *pPeerHTInfo = NULL; u16 nMaxAMSDUSize = 0; u8* pMcsFilter = NULL; @@ -851,16 +851,16 @@ void HTOnAssocRsp(struct rtllib_device *ieee) RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); if (!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) - pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]); + pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]); else - pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf); + pPeerHTCap = (struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf); if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) pPeerHTInfo = (struct ht_info_ele *)(&pHTInfo->PeerHTInfoBuf[4]); else pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index a6a27847ada..ff69523a79d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1949,7 +1949,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } if (tmp_htcap_len != 0){ network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); }else{ network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; @@ -2155,9 +2155,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - network->bssht.bdBandWidth = (HT_CHANNEL_WIDTH)(((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->ChlWidth); + network->bssht.bdBandWidth = (HT_CHANNEL_WIDTH)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); } else{ network->bssht.bdSupportHT = false; diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index db4c5684a4e..39c6644f11b 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -148,13 +148,13 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, if (network->mode >= IEEE_N_24G) { - PHT_CAPABILITY_ELE ht_cap = NULL; + struct ht_capab_ele *ht_cap = NULL; bool is40M = false, isShortGI = false; u8 max_mcs = 0; if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4)) - ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[4]; + ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[4]; else - ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[0]; + ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[0]; is40M = (ht_cap->ChlWidth)?1:0; isShortGI = (ht_cap->ChlWidth)? ((ht_cap->ShortGI40Mhz)?1:0): From 8cf33316817d8349fa3125584a0f4767b3e4b72d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:03:22 -0500 Subject: [PATCH 0346/1519] staging: rtl8192e: Convert typedef BA_RECORD to struct ba_record Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 4 +-- drivers/staging/rtl8192e/rtl819x_BAProc.c | 32 +++++++++++------------ drivers/staging/rtl8192e/rtl819x_TS.h | 6 ++--- drivers/staging/rtl8192e/rtllib.h | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index bf8fdea991c..a0c46c5a693 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -66,13 +66,13 @@ typedef union _DELBA_PARAM_SET { } field; } DELBA_PARAM_SET, *PDELBA_PARAM_SET; -typedef struct _BA_RECORD { +struct ba_record { struct timer_list Timer; u8 bValid; u8 DialogToken; BA_PARAM_SET BaParamSet; u16 BaTimeoutValue; SEQUENCE_CONTROL BaStartSeqCtrl; -} BA_RECORD, *PBA_RECORD; +}; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 165bfae1910..f721d286c82 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,22 +20,22 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device* ieee, PBA_RECORD pBA, u16 Time) +void ActivateBAEntry(struct rtllib_device* ieee, struct ba_record *pBA, u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry( struct rtllib_device* ieee, PBA_RECORD pBA) +void DeActivateBAEntry( struct rtllib_device* ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) { - PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; - PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; + struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; + struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; u8 bSendDELBA = false; if (pPendingBa->bValid) @@ -55,7 +55,7 @@ u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) { - PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; + struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; if (pBa->bValid) @@ -67,7 +67,7 @@ u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) return bSendDELBA; } -void ResetBaEntry( PBA_RECORD pBA) +void ResetBaEntry( struct ba_record *pBA) { pBA->bValid = false; pBA->BaParamSet.shortData = 0; @@ -75,7 +75,7 @@ void ResetBaEntry( PBA_RECORD pBA) pBA->DialogToken = 0; pBA->BaStartSeqCtrl.ShortData = 0; } -static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) +static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct ba_record *pBA, u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; struct rtllib_hdr_3addr* BAReq = NULL; @@ -139,7 +139,7 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, PBA_REC static struct sk_buff* rtllib_DELBA( struct rtllib_device* ieee, u8* dst, - PBA_RECORD pBA, + struct ba_record *pBA, TR_SELECT TxRxSelect, u16 ReasonCode ) @@ -193,7 +193,7 @@ static struct sk_buff* rtllib_DELBA( return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA) +void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -207,7 +207,7 @@ void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA) return; } -void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode) +void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); @@ -220,7 +220,7 @@ void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA, u } -void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode) +void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, TR_SELECT TxRxSelect, u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); @@ -240,7 +240,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) struct rtllib_hdr_3addr* req = NULL; u16 rc = 0; u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; - PBA_RECORD pBA = NULL; + struct ba_record *pBA = NULL; PBA_PARAM_SET pBaParamSet = NULL; u16* pBaTimeoutVal = NULL; PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; @@ -314,7 +314,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) OnADDBAReq_Fail: { - BA_RECORD BA; + struct ba_record BA; BA.BaParamSet = *pBaParamSet; BA.BaTimeoutValue = *pBaTimeoutVal; BA.DialogToken = *pDialogToken; @@ -328,7 +328,7 @@ OnADDBAReq_Fail: int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr* rsp = NULL; - PBA_RECORD pPendingBA, pAdmittedBA; + struct ba_record *pPendingBA, *pAdmittedBA; struct tx_ts_record *pTS = NULL; u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; @@ -419,7 +419,7 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) OnADDBARsp_Reject: { - BA_RECORD BA; + struct ba_record BA; BA.BaParamSet = *pBaParamSet; rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); return 0; @@ -506,7 +506,7 @@ TsInitAddBA( u8 bOverwritePending ) { - PBA_RECORD pBA = &pTS->TxPendingBARecord; + struct ba_record *pBA = &pTS->TxPendingBARecord; if (pBA->bValid==true && bOverwritePending==false) return; diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 20f8486c5fe..0baf888e545 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -45,8 +45,8 @@ struct ts_common_info { struct tx_ts_record { struct ts_common_info TsCommonInfo; u16 TxCurSeq; - BA_RECORD TxPendingBARecord; - BA_RECORD TxAdmittedBARecord; + struct ba_record TxPendingBARecord; + struct ba_record TxAdmittedBARecord; u8 bAddBaReqInProgress; u8 bAddBaReqDelayed; u8 bUsingBa; @@ -61,7 +61,7 @@ struct rx_ts_record { u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; struct timer_list RxPktPendingTimer; - BA_RECORD RxAdmittedBARecord; + struct ba_record RxAdmittedBARecord; u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 4b8bd097638..ffa3fe5fdb4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2918,7 +2918,7 @@ extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsC extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry( PBA_RECORD pBA); +extern void ResetBaEntry( struct ba_record *pBA); extern bool GetTs( struct rtllib_device* ieee, struct ts_common_info **ppTS, From d6a15cb8a0aea26f1165876c7ef1db159cb4b229 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:04:37 -0500 Subject: [PATCH 0347/1519] staging: rtl8192e: Convert typedef MIMO_EVM to struct mimo_evm Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index f2916e667b9..4b69c6ec1b1 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -361,10 +361,10 @@ struct mimo_rssi { u32 Average; };//, *struct mimo_rssi *; -typedef struct _MIMO_EVM{ +struct mimo_evm { u32 EVM1; u32 EVM2; -}MIMO_EVM, *PMIMO_EVM; +};//, *struct mimo_evm *; typedef struct _FALSE_ALARM_STATISTICS{ u32 Cnt_Parity_Fail; From 38b1f67d9dffd8adebf5558d790c7fc5a5b5dc80 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:06:43 -0500 Subject: [PATCH 0348/1519] staging: rtl8192e: Convert typedef FALSE_ALARM_STATISTICS to struct false_alarm_stats Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtl_dm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 4b69c6ec1b1..f85415ff3f1 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -366,7 +366,7 @@ struct mimo_evm { u32 EVM2; };//, *struct mimo_evm *; -typedef struct _FALSE_ALARM_STATISTICS{ +struct false_alarm_stats { u32 Cnt_Parity_Fail; u32 Cnt_Rate_Illegal; u32 Cnt_Crc8_fail; @@ -374,7 +374,7 @@ typedef struct _FALSE_ALARM_STATISTICS{ u32 Cnt_Ofdm_fail; u32 Cnt_Cck_fail; u32 Cnt_all; -}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS; +};//, *struct false_alarm_stats *; extern u8 MCS_FILTER_ALL[16]; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index ffbfb290866..a199cfdc30e 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -882,7 +882,7 @@ typedef struct r8192_priv u8 DynamicTxHighPowerLvl; u8 LastDTPLvl; u32 CurrentRATR0; - FALSE_ALARM_STATISTICS FalseAlmCnt; + struct false_alarm_stats FalseAlmCnt; u8 DMFlag; u8 DM_Type; diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 696e6c260c5..74868b84f04 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -1916,7 +1916,7 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret_value; - PFALSE_ALARM_STATISTICS FalseAlmCnt = &(priv->FalseAlmCnt); + struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); From 9bf6e4c146a9da9d44f7bdb259c233db28b64003 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:16:51 -0500 Subject: [PATCH 0349/1519] staging: rtl8192e: Convert typedef BB_REGISTER_DEFINITION_T to struct bb_reg_definition Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8190P_rtl8256.c | 2 +- drivers/staging/rtl8192e/r8192E_phy.c | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 52c00a1c14b..f2ad86218d7 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -159,7 +159,7 @@ typedef enum _INTERFACE_SELECT_8190PCI{ INTF_SEL3_RSV = 3, } INTERFACE_SELECT_8190PCI, *PINTERFACE_SELECT_8190PCI; -typedef struct _BB_REGISTER_DEFINITION{ +struct bb_reg_definition { u32 rfintfs; u32 rfintfi; u32 rfintfo; @@ -178,7 +178,7 @@ typedef struct _BB_REGISTER_DEFINITION{ u32 rfTxAFE; u32 rfLSSIReadBack; u32 rfLSSIReadBackPi; -}BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T; +};//, *struct bb_reg_definition *; typedef struct _TX_FWINFO_STRUCUTRE{ u8 TxRate:7; diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index b6587000f93..da1cdb5da1c 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -79,7 +79,7 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) u32 u4RegValue = 0; u8 eRFPath; bool rtStatus = true; - BB_REGISTER_DEFINITION_T *pPhyReg; + struct bb_reg_definition *pPhyReg; struct r8192_priv *priv = rtllib_priv(dev); u32 RegOffSetToBeCheck = 0x3; u32 RegValueToBeCheck = 0x7f1; diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index c462d74c4de..566eea1337a 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -104,7 +104,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; u32 NewOffset = 0; - BB_REGISTER_DEFINITION_T* pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition* pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; if (priv->rf_chip == RF_8256) @@ -164,7 +164,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; - BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; if (priv->rf_chip == RF_8256) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index a199cfdc30e..4fc78aa2368 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -596,7 +596,7 @@ typedef struct r8192_priv RT_RF_TYPE_819xU rf_chip; IC_INFERIORITY_8192S IC_Class; HT_CHANNEL_WIDTH CurrentChannelBW; - BB_REGISTER_DEFINITION_T PHYRegDef[4]; + struct bb_reg_definition PHYRegDef[4]; rate_adaptive rate_adaptive; ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength]; From 22a2f51027de74b519a0c87715722921cb8dc751 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:26:10 -0500 Subject: [PATCH 0350/1519] staging: rtl8192e: Convert typedef TX_FWINFO_T to struct tx_fwinfo Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index f2ad86218d7..fdd647a05f3 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -180,7 +180,7 @@ struct bb_reg_definition { u32 rfLSSIReadBackPi; };//, *struct bb_reg_definition *; -typedef struct _TX_FWINFO_STRUCUTRE{ +struct tx_fwinfo { u8 TxRate:7; u8 CtsEnable:1; u8 RtsRate:7; @@ -205,7 +205,7 @@ typedef struct _TX_FWINFO_STRUCUTRE{ u32 TxAGCSign:1; u32 Tx_INFO_RSVD:6; u32 PacketID:13; -}TX_FWINFO_T; +};//; typedef struct _TX_FWINFO_8190PCI{ u8 TxRate:7; From a07dc3d145334fec51f1b773a47e84cd1d36c3ec Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:27:34 -0500 Subject: [PATCH 0351/1519] staging: rtl8192e: Convert typedef TX_FWINFO_8190PCI to struct tx_fwinfo_8190pci Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 6 +++--- drivers/staging/rtl8192e/r8192E_dev.c | 16 ++++++++-------- drivers/staging/rtl8192e/rtl_core.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index fdd647a05f3..4bb71238964 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -207,7 +207,7 @@ struct tx_fwinfo { u32 PacketID:13; };//; -typedef struct _TX_FWINFO_8190PCI{ +struct tx_fwinfo_8190pci { u8 TxRate:7; u8 CtsEnable:1; u8 RtsRate:7; @@ -237,7 +237,7 @@ typedef struct _TX_FWINFO_8190PCI{ u32 PacketID:13; -}TX_FWINFO_8190PCI, *PTX_FWINFO_8190PCI; +};//, *struct tx_fwinfo_8190pci *; #define TX_DESC_SIZE 32 diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index de65f4064c1..2ff69ef9129 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -51,7 +51,7 @@ cb_desc *tcb_desc; u8 bLastIniPkt; - PTX_FWINFO_8190PCI pTxFwInfo = NULL; + struct tx_fwinfo_8190pci *pTxFwInfo = NULL; RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__func__,buffer_len); firmware_init_param(dev); @@ -82,8 +82,8 @@ tcb_desc->pkt_size = frag_length; seg_ptr = skb_put(skb, priv->rtllib->tx_headroom); - pTxFwInfo = (PTX_FWINFO_8190PCI)seg_ptr; - memset(pTxFwInfo,0,sizeof(TX_FWINFO_8190PCI)); + pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr; + memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); memset(pTxFwInfo,0x12,8); seg_ptr = skb_put(skb, frag_length); diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index d441a540132..e41736b43fa 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1159,9 +1159,9 @@ void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb { struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - TX_FWINFO_8190PCI *pTxFwInfo = NULL; - pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; - memset(pTxFwInfo,0,sizeof(TX_FWINFO_8190PCI)); + struct tx_fwinfo_8190pci *pTxFwInfo = NULL; + pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; + memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); pTxFwInfo->TxHT = (cb_desc->data_rate&0x80)?1:0; pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; @@ -1205,8 +1205,8 @@ void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb memset((u8*)pdesc,0,12); pdesc->LINIP = 0; pdesc->CmdInit = 1; - pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; - pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); + pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); pdesc->SecCAMID= 0; pdesc->RATid = cb_desc->RATRIndex; @@ -1244,7 +1244,7 @@ void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb pdesc->PktId = 0x0; pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(cb_desc->queue_index, cb_desc->priority); - pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); + pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); pdesc->DISFB = cb_desc->bTxDisableRateFallBack; pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; @@ -1271,7 +1271,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, } else { tx_desc* entry_tmp = (tx_desc*)entry; entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry_tmp->Offset = sizeof(TX_FWINFO_8190PCI) + 8; + entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); entry_tmp->QueueSelect = QSLT_CMD; entry_tmp->TxFWInfoSize = 0x08; @@ -2057,7 +2057,7 @@ rtl8192_InitializeVariables(struct net_device *dev) IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE /* | IEEE_SOFTMAC_BEACONS*/; - priv->rtllib->tx_headroom = sizeof(TX_FWINFO_8190PCI); + priv->rtllib->tx_headroom = sizeof(struct tx_fwinfo_8190pci); priv->ShortRetryLimit = 0x30; priv->LongRetryLimit = 0x30; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index f8a13d95985..4e4ad7a4ad1 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2049,7 +2049,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) priv->rtllib->bAwakePktSent = true; - fwinfo_size = sizeof(TX_FWINFO_8190PCI); + fwinfo_size = sizeof(struct tx_fwinfo_8190pci); header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); fc = header->frame_ctl; From c13ac63b6096f87e5be41893a3a4e7a1848a20ae Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:32:47 -0500 Subject: [PATCH 0352/1519] staging: rtl8192e: Convert typedef LOG_INTERRUPT_8190_T to struct log_int_8190 Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 5 ++--- drivers/staging/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtl_core.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 4bb71238964..888da4b716a 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -256,8 +256,7 @@ struct tx_fwinfo_8190pci { #define RX_DRIVER_INFO_SIZE 8 -typedef struct _LOG_INTERRUPT_8190 -{ +struct log_int_8190 { u32 nIMR_COMDOK; u32 nIMR_MGNTDOK; u32 nIMR_HIGH; @@ -270,7 +269,7 @@ typedef struct _LOG_INTERRUPT_8190 u32 nIMR_TBDOK; u32 nIMR_BDOK; u32 nIMR_RXFOVW; -} LOG_INTERRUPT_8190_T, *PLOG_INTERRUPT_8190_T; +}; typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{ u8 reserved:4; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 4e4ad7a4ad1..7861c362e9c 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1226,7 +1226,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->force_reset = false; memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); - memset(&priv->InterruptLog,0,sizeof(LOG_INTERRUPT_8190_T)); + memset(&priv->InterruptLog,0,sizeof(struct log_int_8190)); priv->RxCounter = 0; priv->rtllib->wx_set_enc = 0; priv->bHwRadioOff = false; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 4fc78aa2368..77b46bfaebb 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -588,7 +588,7 @@ typedef struct r8192_priv work_struct_rsl reset_wq; - LOG_INTERRUPT_8190_T InterruptLog; + struct log_int_8190 InterruptLog; RT_CUSTOMER_ID CustomerID; From 910d9e5c2deec0a9068cef5f3ae8c336f6321537 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:34:49 -0500 Subject: [PATCH 0353/1519] staging: rtl8192e: Convert typedef phy_ofdm_rx_status_rxsc_sgien_exintfflag to struct phy_ofdm_rx_status_rxsc_sgien_exintfflag Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 888da4b716a..cd259258924 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -271,12 +271,12 @@ struct log_int_8190 { u32 nIMR_RXFOVW; }; -typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{ +struct phy_ofdm_rx_status_rxsc_sgien_exintfflag { u8 reserved:4; u8 rxsc:2; u8 sgi_en:1; u8 ex_intf_flag:1; -}phy_ofdm_rx_status_rxsc_sgien_exintfflag; +};//; typedef struct _phy_ofdm_rx_status_report_819xpci { diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index e41736b43fa..f55548aa6b0 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1407,7 +1407,7 @@ void rtl8192_query_rxphystatus( { phy_sts_ofdm_819xpci_t* pofdm_buf; phy_sts_cck_819xpci_t * pcck_buf; - phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; + struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; u8 *prxpkt; u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; char rx_pwr[4], rx_pwr_all=0; @@ -1580,7 +1580,7 @@ void rtl8192_query_rxphystatus( rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; if (pdrvinfo->BW) priv->stats.received_bwtype[1+prxsc->rxsc]++; else From 2ae7ea8cf099f0c68292c5e890dbfcc205a35f3e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:42:14 -0500 Subject: [PATCH 0354/1519] staging: rtl8192e: Convert typedef phy_sts_ofdm_819xpci_t to struct phy_sts_ofdm_819xpci Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 5 ++--- drivers/staging/rtl8192e/r8192E_dev.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index cd259258924..d91c3180d01 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -278,8 +278,7 @@ struct phy_ofdm_rx_status_rxsc_sgien_exintfflag { u8 ex_intf_flag:1; };//; -typedef struct _phy_ofdm_rx_status_report_819xpci -{ +struct phy_sts_ofdm_819xpci { u8 trsw_gain_X[4]; u8 pwdb_all; u8 cfosho_X[4]; @@ -293,7 +292,7 @@ typedef struct _phy_ofdm_rx_status_report_819xpci u8 max_ex_pwr; u8 sgi_en; u8 rxsc_sgien_exflg; -}phy_sts_ofdm_819xpci_t; +};//; typedef struct _phy_cck_rx_status_report_819xpci { diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index f55548aa6b0..9bff1d03360 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1405,7 +1405,7 @@ void rtl8192_query_rxphystatus( bool bToSelfBA ) { - phy_sts_ofdm_819xpci_t* pofdm_buf; + struct phy_sts_ofdm_819xpci* pofdm_buf; phy_sts_cck_819xpci_t * pcck_buf; struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; u8 *prxpkt; @@ -1442,7 +1442,7 @@ void rtl8192_query_rxphystatus( prxpkt += sizeof(rx_fwinfo); pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; - pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; + pofdm_buf = (struct phy_sts_ofdm_819xpci *)prxpkt; pstats->RxMIMOSignalQuality[0] = -1; pstats->RxMIMOSignalQuality[1] = -1; From 95ce5fc94759fe4c17c9c3afb1cf897045736fa1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:55:05 -0500 Subject: [PATCH 0355/1519] staging: rtl8192e: Convert typedef WMM_TSPEC to struct wmm_tspec Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 49e49cb9df7..e9eea5aba98 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -93,7 +93,7 @@ typedef union _TSPEC_BODY{ } f; }TSPEC_BODY, *PTSPEC_BODY; -typedef struct _WMM_TSPEC{ +struct wmm_tspec { u8 ID; u8 Length; u8 OUI[3]; @@ -101,7 +101,7 @@ typedef struct _WMM_TSPEC{ u8 OUI_SubType; u8 Version; TSPEC_BODY Body; -} WMM_TSPEC, *PWMM_TSPEC; +}; typedef struct _OCTET_STRING{ u8 *Octet; @@ -308,8 +308,8 @@ typedef struct _QOS_TSTREAM{ bool bEstablishing; u8 TimeSlotCount; u8 DialogToken; - WMM_TSPEC TSpec; - WMM_TSPEC OutStandingTSpec; + struct wmm_tspec TSpec; + struct wmm_tspec OutStandingTSpec; u8 NominalPhyRate; } QOS_TSTREAM, *PQOS_TSTREAM; @@ -334,7 +334,7 @@ typedef struct _STA_QOS{ QOS_TSTREAM StaTsArray[MAX_STA_TS_COUNT]; u8 DialogToken; - WMM_TSPEC TSpec; + struct wmm_tspec TSpec; u8 QBssWirelessMode; From 8310b6c05c65dfe699dd62be5d71c246ddaefd96 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:57:13 -0500 Subject: [PATCH 0356/1519] staging: rtl8192e: Convert typedef OCTET_STRING to struct octet_string Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- drivers/staging/rtl8192e/rtllib.h | 4 ++-- drivers/staging/rtl8192e/rtllib_softmac.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index e9eea5aba98..1b889f226b1 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -103,10 +103,10 @@ struct wmm_tspec { TSPEC_BODY Body; }; -typedef struct _OCTET_STRING{ +struct octet_string { u8 *Octet; u16 Length; -}OCTET_STRING, *POCTET_STRING; +};//, *struct octet_string *; #define MAX_WMMELE_LENGTH 64 typedef u32 QOS_MODE, *PQOS_MODE; @@ -356,7 +356,7 @@ struct bss_qos { QOS_MODE bdQoSMode; u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; - OCTET_STRING bdWMMIE; + struct octet_string bdWMMIE; QOS_ELE_SUBTYPE EleSubType; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index ffa3fe5fdb4..9a9f3d3e363 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1882,14 +1882,14 @@ typedef struct _RT_POWER_SAVE_CONTROL bool bTmpFilterHiddenAP; bool bTmpUpdateParms; u8 tmpSsidBuf[33]; - OCTET_STRING tmpSsid2Scan; + struct octet_string tmpSsid2Scan; bool bTmpSsid2Scan; u8 tmpNetworkType; u8 tmpChannelNumber; u16 tmpBcnPeriod; u8 tmpDtimPeriod; u16 tmpmCap; - OCTET_STRING tmpSuppRateSet; + struct octet_string tmpSuppRateSet; u8 tmpSuppRateBuf[MAX_NUM_RATES]; bool bTmpSuppRate; IbssParms tmpIbpm; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 7930a963757..8cf42f0302f 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1351,7 +1351,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; u8 CcxAironetBuf[30]; - OCTET_STRING osCcxAironetIE; + struct octet_string osCcxAironetIE; memset(CcxAironetBuf, 0,30); osCcxAironetIE.Octet = CcxAironetBuf; @@ -1369,7 +1369,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; - OCTET_STRING osCcxRmCap; + struct octet_string osCcxRmCap; osCcxRmCap.Octet = CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); @@ -1383,7 +1383,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru if ( beacon->BssCcxVerNumber >= 2 ) { u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; - OCTET_STRING osCcxVerNum; + struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; osCcxVerNum.Octet = CcxVerNumBuf; osCcxVerNum.Length = sizeof(CcxVerNumBuf); From 1d2a55fb6fd806b67cbec191b1a2b5b32c7764a0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 21:58:49 -0500 Subject: [PATCH 0357/1519] staging: rtl8192e: Convert typedef QOS_TSTREAM to struct qos_tstream Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 1b889f226b1..7f55454a46f 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -301,7 +301,7 @@ typedef union _QOS_TCLAS{ } TYPE2_8021Q; } QOS_TCLAS, *PQOS_TCLAS; -typedef struct _QOS_TSTREAM{ +struct qos_tstream { bool bUsed; u16 MsduLifetime; @@ -311,7 +311,7 @@ typedef struct _QOS_TSTREAM{ struct wmm_tspec TSpec; struct wmm_tspec OutStandingTSpec; u8 NominalPhyRate; -} QOS_TSTREAM, *PQOS_TSTREAM; +}; typedef struct _STA_QOS{ u8 WMMIEBuf[MAX_WMMELE_LENGTH]; @@ -332,7 +332,7 @@ typedef struct _STA_QOS{ ACM acm[4]; ACM_METHOD AcmMethod; - QOS_TSTREAM StaTsArray[MAX_STA_TS_COUNT]; + struct qos_tstream StaTsArray[MAX_STA_TS_COUNT]; u8 DialogToken; struct wmm_tspec TSpec; From 0db427997a1dd486a4b93700398fe7076eb201e7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:01:50 -0500 Subject: [PATCH 0358/1519] staging: rtl8192e: Convert typedef STA_QOS to struct sta_qos Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 7f55454a46f..93a9c13f4e3 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -313,7 +313,7 @@ struct qos_tstream { u8 NominalPhyRate; }; -typedef struct _STA_QOS{ +struct sta_qos { u8 WMMIEBuf[MAX_WMMELE_LENGTH]; u8* WMMIE; @@ -342,7 +342,7 @@ typedef struct _STA_QOS{ bool bEnableRxImmBA; -}STA_QOS, *PSTA_QOS; +};//, *struct sta_qos *; #define QBSS_LOAD_SIZE 5 #define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) From 9d94bbb8c83dd21099ddcf5f127a7c2a1a87da7b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:03:27 -0500 Subject: [PATCH 0359/1519] staging: rtl8192e: Convert typedef RT_SMOOTH_DATA_4RF to struct rt_smooth_data_4rf Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 77b46bfaebb..a764f18aa24 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -369,12 +369,12 @@ typedef struct _rt_9x_tx_rate_history { u32 ht_mcs[4][16]; }rt_tx_rahis_t, *prt_tx_rahis_t; -typedef struct _RT_SMOOTH_DATA_4RF { +struct rt_smooth_data_4rf { char elements[4][100]; u32 index; u32 TotalNum; u32 TotalVal[4]; -}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF; +};//, *struct rt_smooth_data_4rf *; typedef struct Stats { @@ -468,7 +468,7 @@ typedef struct Stats rt_tx_rahis_t txrate; u32 Slide_Beacon_pwdb[100]; u32 Slide_Beacon_Total; - RT_SMOOTH_DATA_4RF cck_adc_pwdb; + struct rt_smooth_data_4rf cck_adc_pwdb; u32 CurrentShowTxate; } Stats; From 628c30e852e775d98ebce006f51e64a58e3fd76b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:05:16 -0500 Subject: [PATCH 0360/1519] staging: rtl8192e: Convert typedef RT_PM_WOL_PATTERN_INFO to struct rt_pm_wol_info Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 9a9f3d3e363..7ae24d50afc 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1851,14 +1851,13 @@ typedef enum _WOLPATTERN_TYPE eNoDefined, }WOLPATTERN_TYPE; -typedef struct _RT_PM_WOL_PATTERN_INFO -{ +struct rt_pm_wol_info { u32 PatternId; u32 Mask[4]; u16 CrcRemainder; u8 WFMIndex; WOLPATTERN_TYPE PatternType; -}RT_PM_WOL_PATTERN_INFO, *PRT_PM_WOL_PATTERN_INFO; +};//, *struct rt_pm_wol_info *; typedef struct _RT_POWER_SAVE_CONTROL { @@ -1916,7 +1915,7 @@ typedef struct _RT_POWER_SAVE_CONTROL u8 RegAMDPciASPM; u8 oWLANMode; - RT_PM_WOL_PATTERN_INFO PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; + struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; }RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL; From ca9900116fb3b758d226d08c1f5c792285941fb9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:06:47 -0500 Subject: [PATCH 0361/1519] staging: rtl8192e: Convert typedef RT_POWER_SAVE_CONTROL to struct rt_pwr_save_ctrl Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/rtl_core.c | 8 ++++---- drivers/staging/rtl8192e/rtl_ps.c | 10 +++++----- drivers/staging/rtl8192e/rtl_wx.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 7 +++---- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 566eea1337a..22ab5635215 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1381,7 +1381,7 @@ SetRFPowerState8190( ) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); bool bResult = true; u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7861c362e9c..cb25212f873 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1003,7 +1003,7 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); bool init_status = true; priv->bDriverIsGoingToUnload = false; priv->bdisable_nic = false; @@ -1153,7 +1153,7 @@ static void rtl8192_init_priv_handler(struct net_device* dev) static void rtl8192_init_priv_constant(struct net_device* dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); pPSC->RegMaxLPSAwakeIntvl = 5; @@ -1681,7 +1681,7 @@ void rtl819x_watchdog_wqcallback(void *data) RESET_TYPE ResetType = RESET_TYPE_NORESET; static u8 check_reset_cnt = 0; unsigned long flags; - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); bool bBusyTraffic = false; bool bHigherBusyTraffic = false; bool bHigherBusyRxTraffic = false; @@ -3139,7 +3139,7 @@ bool NicIFEnableNIC(struct net_device* dev) { bool init_status = true; struct r8192_priv* priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); if (IS_NIC_DOWN(priv)){ RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__func__); diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 00306293f77..1f69c377618 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -116,7 +116,7 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() ---------> \n"); pPSC->bSwRfProcessing = true; @@ -133,7 +133,7 @@ void IPSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); RT_RF_POWER_STATE rtState; if (pPSC->bInactivePs) @@ -156,7 +156,7 @@ void IPSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); RT_RF_POWER_STATE rtState; if (pPSC->bInactivePs) @@ -240,7 +240,7 @@ bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) void LeisurePSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); RT_TRACE(COMP_PS, "LeisurePSEnter()...\n"); RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", @@ -272,7 +272,7 @@ void LeisurePSEnter(struct net_device *dev) void LeisurePSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); RT_TRACE(COMP_PS, "LeisurePSLeave()...\n"); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 44c49d508c7..2079ae8ec84 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -218,7 +218,7 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); struct rtllib_device* ieee = priv->rtllib; down(&priv->wx_sem); @@ -266,7 +266,7 @@ static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); down(&priv->wx_sem); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 7ae24d50afc..dd9ad6ed556 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1859,8 +1859,7 @@ struct rt_pm_wol_info { WOLPATTERN_TYPE PatternType; };//, *struct rt_pm_wol_info *; -typedef struct _RT_POWER_SAVE_CONTROL -{ +struct rt_pwr_save_ctrl { bool bInactivePs; bool bIPSModeBackup; @@ -1917,7 +1916,7 @@ typedef struct _RT_POWER_SAVE_CONTROL u8 oWLANMode; struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; -}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL; +};//,*struct rt_pwr_save_ctrl *; typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_SW BIT31 @@ -2391,7 +2390,7 @@ struct rtllib_device { RT_LINK_DETECT_T LinkDetectInfo; bool bIsAggregateFrame; - RT_POWER_SAVE_CONTROL PowerSaveControl; + struct rt_pwr_save_ctrl PowerSaveControl; u8 amsdu_in_process; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 8cf42f0302f..64574acc0fd 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1577,7 +1577,7 @@ void rtllib_associate_step2(struct rtllib_device *ieee) void rtllib_associate_complete_wq(void *data) { struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(ieee->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); printk(KERN_INFO "Associated successfully\n"); if (ieee->is_silent_reset == 0){ printk("normal associate\n"); @@ -2041,7 +2041,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) { int timeout = ieee->ps_timeout; u8 dtim; - PRT_POWER_SAVE_CONTROL pPSC = (PRT_POWER_SAVE_CONTROL)(&(ieee->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); /*if (ieee->ps == RTLLIB_PS_DISABLED || ieee->iw_mode != IW_MODE_INFRA || ieee->state != RTLLIB_LINKED) From 0e86753fe3faae9c24ca52218678b614ccf04f03 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:08:19 -0500 Subject: [PATCH 0362/1519] staging: rtl8192e: Convert typedef RT_LINK_DETECT_T to struct rt_link_detect Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index dd9ad6ed556..6102c929a0c 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1984,7 +1984,7 @@ typedef enum _FW_CMD_IO_TYPE{ }FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE; #define RT_MAX_LD_SLOT_NUM 10 -typedef struct _RT_LINK_DETECT_T{ +struct rt_link_detect { u32 NumRecvBcnInPeriod; u32 NumRecvDataInPeriod; @@ -2004,7 +2004,7 @@ typedef struct _RT_LINK_DETECT_T{ u32 NumTxUnicastOkInPeriod; u32 LastNumTxUnicast; u32 LastNumRxUnicast; -}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; +};//, *struct rt_link_detect *; typedef struct _SW_CAM_TABLE{ @@ -2388,7 +2388,7 @@ struct rtllib_device { bandwidth_autoswitch bandwidth_auto_switch; bool FwRWRF; - RT_LINK_DETECT_T LinkDetectInfo; + struct rt_link_detect LinkDetectInfo; bool bIsAggregateFrame; struct rt_pwr_save_ctrl PowerSaveControl; u8 amsdu_in_process; From 5ea0448047ce05da0ee10775510a581b5f71cc82 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:09:44 -0500 Subject: [PATCH 0363/1519] staging: rtl8192e: Convert typedef SW_CAM_TABLE to struct sw_cam_table Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 4 ++-- drivers/staging/rtl8192e/rtl_wx.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 6 +++--- drivers/staging/rtl8192e/rtllib_module.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index cb25212f873..b7eebf42b52 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1071,7 +1071,7 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) kfree(priv->rtllib->wpa_ie); priv->rtllib->wpa_ie = NULL; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); rtl8192_irq_disable(dev); del_timer_sync(&priv->watch_dog_timer); @@ -1224,7 +1224,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->bForcedSilentReset = 0; priv->bDisableNormalResetCheck = false; priv->force_reset = false; - memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); memset(&priv->InterruptLog,0,sizeof(struct log_int_8190)); priv->RxCounter = 0; diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 2079ae8ec84..3a0fcfc3401 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -764,7 +764,7 @@ static int r8192_wx_set_enc(struct net_device *dev, if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); goto end_hw_sec; } if (wrqu->encoding.length!=0){ @@ -989,7 +989,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, { ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); goto end_hw_sec; } alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 6102c929a0c..28e6e62e2b4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2006,7 +2006,7 @@ struct rt_link_detect { u32 LastNumRxUnicast; };//, *struct rt_link_detect *; -typedef struct _SW_CAM_TABLE{ +struct sw_cam_table { u8 macaddr[6]; bool bused; @@ -2015,7 +2015,7 @@ typedef struct _SW_CAM_TABLE{ u8 useDK; u8 key_index; -}SW_CAM_TABLE,*PSW_CAM_TABLE; +};//,*struct sw_cam_table *; #define TOTAL_CAM_ENTRY 32 typedef struct _rate_adaptive { @@ -2232,7 +2232,7 @@ struct rtllib_device { struct rtllib_crypt_data *crypt[WEP_KEYS]; int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ - SW_CAM_TABLE swcamtable[TOTAL_CAM_ENTRY]; + struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; struct timer_list crypt_deinit_timer; int crypt_quiesced; diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 65034a4588d..5daaabd3321 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -159,7 +159,7 @@ struct net_device *alloc_rtllib(int sizeof_priv) ieee->raw_tx = 0; ieee->hwsec_active = 0; - memset(ieee->swcamtable,0,sizeof(SW_CAM_TABLE)*32); + memset(ieee->swcamtable,0,sizeof(struct sw_cam_table)*32); rtllib_softmac_init(ieee); ieee->pHTInfo = (struct rt_hi_throughput*)kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); From 74d0497b84280ff5278fc7f12047a1e1421af443 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:11:20 -0500 Subject: [PATCH 0364/1519] staging: rtl8192e: Convert typedef RT_PMKID_LIST to struct rt_pmkid_list Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 28e6e62e2b4..7de5360280a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2054,15 +2054,14 @@ typedef enum _RATR_TABLE_MODE_8192S{ }RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S; #define NUM_PMKID_CACHE 16 -typedef struct _RT_PMKID_LIST -{ +struct rt_pmkid_list { u8 bUsed; u8 Bssid[6]; u8 PMKID[16]; u8 SsidBuf[33]; u8* ssid_octet; u16 ssid_length; -} RT_PMKID_LIST, *PRT_PMKID_LIST; +}; typedef struct _RT_INTEL_PROMISCUOUS_MODE_INFO { bool bPromiscuousOn; @@ -2239,7 +2238,7 @@ struct rtllib_device { int bcrx_sta_key; /* use individual keys to override default keys even * with RX of broad/multicast frames */ - RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE]; + struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; /* Fragmentation structures */ struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN]; From ca39405519df5c53f2b2c1c635e638085538086c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:13:13 -0500 Subject: [PATCH 0365/1519] staging: rtl8192e: Convert typedef RT_INTEL_PROMISCUOUS_MODE_INFO to struct rt_intel_promisc_mode Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 7de5360280a..2834e78e27d 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2063,10 +2063,10 @@ struct rt_pmkid_list { u16 ssid_length; }; -typedef struct _RT_INTEL_PROMISCUOUS_MODE_INFO { +struct rt_intel_promisc_mode { bool bPromiscuousOn; bool bFilterSourceStationFrame; -} RT_INTEL_PROMISCUOUS_MODE_INFO, *PRT_INTEL_PROMISCUOUS_MODE_INFO; +}; /*************** DRIVER STATUS *****/ @@ -2181,7 +2181,7 @@ struct rtllib_device { int iw_mode; /* operating mode (IW_MODE_*) */ bool bNetPromiscuousMode; - RT_INTEL_PROMISCUOUS_MODE_INFO IntelPromiscuousModeInfo; + struct rt_intel_promisc_mode IntelPromiscuousModeInfo; struct iw_spy_data spy_data; From f9db5f906569933779a02f77d3a6b7d811514d02 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:15:00 -0500 Subject: [PATCH 0366/1519] staging: rtl8192e: Convert typedef RT_PCI_CAPABILITIES_HEADER to struct rt_pci_capab_header Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_pci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h index 22662725b40..890034aca4e 100644 --- a/drivers/staging/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -71,10 +71,10 @@ typedef struct _mp_adapter{ u8 PciBridgeLinkCtrlReg; }mp_adapter,*pmp_adapter; -typedef struct _RT_PCI_CAPABILITIES_HEADER { +struct rt_pci_capab_header { unsigned char CapabilityID; unsigned char Next; -} RT_PCI_CAPABILITIES_HEADER, *PRT_PCI_CAPABILITIES_HEADER; +}; #define PCI_MAX_BRIDGE_NUMBER 255 #define PCI_MAX_DEVICES 32 From 8cba1432cee4c88668160750f1892aa09a2ba56a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:16:48 -0500 Subject: [PATCH 0367/1519] staging: rtl8192e: Convert typedef RX_REORDER_ENTRY to struct rx_reorder_entry Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_TSProc.c | 10 +++++----- drivers/staging/rtl8192e/rtllib.h | 7 +++---- drivers/staging/rtl8192e/rtllib_rx.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 6c60df074b7..d2043612462 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -34,7 +34,7 @@ void RxPktPendingTimeout(unsigned long data) struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); - PRX_REORDER_ENTRY pReorderEntry = NULL; + struct rx_reorder_entry *pReorderEntry = NULL; unsigned long flags = 0; struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; @@ -46,7 +46,7 @@ void RxPktPendingTimeout(unsigned long data) { while(!list_empty(&pRxTs->RxPendingPktList)) { - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + pReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTs->RxPendingPktList.prev,struct rx_reorder_entry,List); if (index == 0) pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; @@ -135,7 +135,7 @@ void TSInitialize(struct rtllib_device *ieee) { struct tx_ts_record *pTxTS = ieee->TxTsRecord; struct rx_ts_record *pRxTS = ieee->RxTsRecord; - PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; + struct rx_reorder_entry *pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__); INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); @@ -444,14 +444,14 @@ void RemoveTsEntry( if (TxRxSelect == RX_DIR) { - PRX_REORDER_ENTRY pRxReorderEntry; + struct rx_reorder_entry *pRxReorderEntry; struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if (timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); while(!list_empty(&pRxTS->RxPendingPktList)){ - pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTS->RxPendingPktList.prev,struct rx_reorder_entry,List); RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); { diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2834e78e27d..69cf46887b4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1791,12 +1791,11 @@ typedef struct _bandwidth_autoswitch #define REORDER_WIN_SIZE 128 #define REORDER_ENTRY_NUM 128 -typedef struct _RX_REORDER_ENTRY -{ +struct rx_reorder_entry { struct list_head List; u16 SeqNum; struct rtllib_rxb* prxb; -} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; +}; typedef enum _Fsync_State{ Default_Fsync, HW_Fsync, @@ -2162,7 +2161,7 @@ struct rtllib_device { struct list_head Rx_TS_Pending_List; struct list_head Rx_TS_Unused_List; struct rx_ts_record RxTsRecord[TOTAL_TS_NUM]; - RX_REORDER_ENTRY RxReorderEntry[128]; + struct rx_reorder_entry RxReorderEntry[128]; struct list_head RxReorder_Unused_List; u8 ForcedPriority; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index ff69523a79d..03e9df1e918 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -448,18 +448,18 @@ drop: bool AddReorderEntry( struct rx_ts_record *pTS, - PRX_REORDER_ENTRY pReorderEntry + struct rx_reorder_entry *pReorderEntry ) { struct list_head *pList = &pTS->RxPendingPktList; while(pList->next != &pTS->RxPendingPktList) { - if ( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) + if ( SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) { pList = pList->next; } - else if ( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) + else if ( SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) { return false; } @@ -529,7 +529,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { - PRX_REORDER_ENTRY pRxReorderEntry; + struct rx_reorder_entry *pRxReorderEntry; struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; u8 RfdCnt = 0; @@ -542,7 +542,7 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS break; } - pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); @@ -563,7 +563,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - PRX_REORDER_ENTRY pReorderEntry = NULL; + struct rx_reorder_entry *pReorderEntry = NULL; struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; u8 WinSize = pHTInfo->RxReorderWinSize; u16 WinEnd = 0; @@ -633,7 +633,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, } else { /* Current packet is going to be inserted into pending list.*/ if (!list_empty(&ieee->RxReorder_Unused_List)) { - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List); + pReorderEntry = (struct rx_reorder_entry *)list_entry(ieee->RxReorder_Unused_List.next,struct rx_reorder_entry,List); list_del_init(&pReorderEntry->List); /* Make a reorder entry and insert into a the packet list.*/ @@ -679,7 +679,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, while(!list_empty(&pTS->RxPendingPktList)) { RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { From b0d7de7314d359ec52d8ba3660e1d5c729e44161 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:21:17 -0500 Subject: [PATCH 0368/1519] staging: rtl8192e: Convert typedef ACM to struct acm Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 6 +++--- drivers/staging/rtl8192e/rtl819x_Qos.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 9bff1d03360..2b3da4dbd5a 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -236,13 +236,13 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) u8 pAcParam = *((u8*)val); u32 eACI = pAcParam; PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); - u8 ACM = pAciAifsn->f.ACM; + u8 acm = pAciAifsn->f.acm; u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", __func__,eACI); AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2)?0x0:0x1); - if ( ACM ) + if (acm) { switch (eACI) { @@ -259,7 +259,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) break; default: - RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI ); + RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n", eACI ); break; } } diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 93a9c13f4e3..1a85a9cb403 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -228,11 +228,11 @@ typedef enum _ACM_METHOD{ }ACM_METHOD,*PACM_METHOD; -typedef struct _ACM{ +struct acm { u64 UsedTime; u64 MediumTime; u8 HwAcmCtl; -}ACM, *PACM; +};//, *struct acm *; @@ -329,7 +329,7 @@ struct sta_qos { u8 * pWMMInfoEle; u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; - ACM acm[4]; + struct acm acm[4]; ACM_METHOD AcmMethod; struct qos_tstream StaTsArray[MAX_STA_TS_COUNT]; @@ -380,7 +380,7 @@ typedef union _ACI_AIFSN{ struct { u8 AIFSN:4; - u8 ACM:1; + u8 acm:1; u8 ACI:2; u8 Reserved:1; }f; From bc27e89b27e9b96075c1dc1d93c848b65aee3b3f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:27:06 -0500 Subject: [PATCH 0369/1519] staging: rtl8192e: Convert typedef tx_desc to struct tx_desc Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 6 +++--- drivers/staging/rtl8192e/r8192E_dev.c | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.h | 2 +- drivers/staging/rtl8192e/rtl_core.c | 12 ++++++------ drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index d91c3180d01..e481455a8f6 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -305,7 +305,7 @@ typedef struct _phy_cck_rx_status_report_819xpci #define PHY_RSSI_SLID_WIN_MAX 100 #define PHY_Beacon_RSSI_SLID_WIN_MAX 10 -typedef struct _tx_desc_819x_pci { +struct tx_desc { u16 PktSize; u8 Offset; u8 Reserved1:3; @@ -341,10 +341,10 @@ typedef struct _tx_desc_819x_pci { u32 Reserved5; u32 Reserved6; u32 Reserved7; -}tx_desc, *ptx_desc; +};//, *ptx_desc; -typedef struct _tx_desc_cmd_819x_pci { +typedef struct tx_desc_cmd_819x_pci { u16 PktSize; u8 Reserved1; u8 CmdType:3; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 2b3da4dbd5a..688b4f536bc 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1155,7 +1155,7 @@ u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) } -void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb) { struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); @@ -1269,7 +1269,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { entry->CmdInit = DESC_PACKET_TYPE_INIT; } else { - tx_desc* entry_tmp = (tx_desc*)entry; + struct tx_desc * entry_tmp = (struct tx_desc *)entry; entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index f8021c7a661..93d915318fc 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -45,7 +45,7 @@ void rtl8192_get_eeprom_size(struct net_device* dev); bool rtl8192_adapter_start(struct net_device *dev); void rtl8192_link_change(struct net_device *dev); void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); -void rtl8192_tx_fill_desc(struct net_device* dev, tx_desc * pdesc, cb_desc * cb_desc, +void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb); void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff* skb); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index b7eebf42b52..a44161d82ec 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -800,7 +800,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) struct sk_buff *pskb = NULL, *pnewskb = NULL; cb_desc *tcb_desc = NULL; struct rtl8192_tx_ring *ring = NULL; - tx_desc *pdesc = NULL; + struct tx_desc *pdesc = NULL; ring = &priv->tx_ring[BEACON_QUEUE]; pskb = __skb_dequeue(&ring->queue); @@ -1884,7 +1884,7 @@ static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio) struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; while (skb_queue_len(&ring->queue)) { - tx_desc *entry = &ring->desc[ring->idx]; + struct tx_desc *entry = &ring->desc[ring->idx]; struct sk_buff *skb = __skb_dequeue(&ring->queue); pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), @@ -1982,7 +1982,7 @@ void rtl8192_tx_isr(struct net_device *dev, int prio) struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; while (skb_queue_len(&ring->queue)) { - tx_desc *entry = &ring->desc[ring->idx]; + struct tx_desc *entry = &ring->desc[ring->idx]; struct sk_buff *skb; if (prio != BEACON_QUEUE) { @@ -2034,7 +2034,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) struct rtl8192_tx_ring *ring; unsigned long flags; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tx_desc *pdesc = NULL; + struct tx_desc *pdesc = NULL; struct rtllib_hdr_1addr * header = NULL; u16 fc=0, type=0,stype=0; bool multi_addr=false,broad_addr=false,uni_addr=false; @@ -2150,7 +2150,7 @@ static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, unsigned int prio, unsigned int entries) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - tx_desc *ring; + struct tx_desc *ring; dma_addr_t dma; int i; @@ -2225,7 +2225,7 @@ void rtl8192_pci_resetdescring(struct net_device *dev) struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; while (skb_queue_len(&ring->queue)) { - tx_desc *entry = &ring->desc[ring->idx]; + struct tx_desc *entry = &ring->desc[ring->idx]; struct sk_buff *skb = __skb_dequeue(&ring->queue); pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index a764f18aa24..c4d70e3ccd8 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -519,7 +519,7 @@ typedef struct _tx_ring{ }__attribute__ ((packed)) tx_ring, * ptx_ring; struct rtl8192_tx_ring { - tx_desc *desc; + struct tx_desc *desc; dma_addr_t dma; unsigned int idx; unsigned int entries; @@ -535,7 +535,7 @@ struct rtl819x_ops{ void (* init_before_adapter_start)(struct net_device* dev); bool (* initialize_adapter)(struct net_device* dev); void (*link_change)(struct net_device* dev); - void (* tx_fill_descriptor)(struct net_device* dev, tx_desc * tx_desc, cb_desc * cb_desc, struct sk_buff *skb); + void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, cb_desc * cb_desc, struct sk_buff *skb); void (* tx_fill_cmd_descriptor)(struct net_device* dev, tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, rx_desc *pdesc, struct sk_buff* skb); bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, rx_desc *pdesc); From e91dbf030128ddd975a336a6e11f76874f5c3985 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:30:34 -0500 Subject: [PATCH 0370/1519] staging: rtl8192e: Convert typedef CHANNEL_ACCESS_SETTING to struct channel_access_setting Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl_core.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 688b4f536bc..b5324a3fc35 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -2280,7 +2280,7 @@ void ActUpdateChannelAccessSetting( struct net_device* dev, WIRELESS_MODE WirelessMode, - PCHANNEL_ACCESS_SETTING ChnlAccessSetting + struct channel_access_setting *ChnlAccessSetting ) { struct r8192_priv* priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index c4d70e3ccd8..9ffac40acda 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -472,14 +472,14 @@ typedef struct Stats u32 CurrentShowTxate; } Stats; -typedef struct ChnlAccessSetting { +struct channel_access_setting { u16 SIFS_Timer; u16 DIFS_Timer; u16 SlotTimeTimer; u16 EIFS_Timer; u16 CWminIndex; u16 CWmaxIndex; -}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING; +}; typedef enum _TWO_PORT_STATUS { @@ -579,7 +579,7 @@ typedef struct r8192_priv struct workqueue_struct *priv_wq; - CHANNEL_ACCESS_SETTING ChannelAccessSetting; + struct channel_access_setting ChannelAccessSetting; mp_adapter NdisAdapter; @@ -1106,7 +1106,7 @@ void ActUpdateChannelAccessSetting( struct net_device* dev, WIRELESS_MODE WirelessMode, - PCHANNEL_ACCESS_SETTING ChnlAccessSetting + struct channel_access_setting *ChnlAccessSetting ); #endif From 9c109856322a4eacd69cc4b20aaa12fbe70e319f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:32:55 -0500 Subject: [PATCH 0371/1519] staging: rtl8192e: Convert typedef rt_tx_rahis_t to struct rt_tx_rahis Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 9ffac40acda..63b9e6c7e5f 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -363,11 +363,11 @@ typedef struct rtl_reg_debug{ unsigned char buf[0xff]; }rtl_reg_debug; -typedef struct _rt_9x_tx_rate_history { +struct rt_tx_rahis { u32 cck[4]; u32 ofdm[8]; u32 ht_mcs[4][16]; -}rt_tx_rahis_t, *prt_tx_rahis_t; +};//, *prt_tx_rahis_t; struct rt_smooth_data_4rf { char elements[4][100]; @@ -465,7 +465,7 @@ typedef struct Stats u8 rx_rssi_percentage[4]; u8 rx_evm_percentage[2]; long rxSNRdB[4]; - rt_tx_rahis_t txrate; + struct rt_tx_rahis txrate; u32 Slide_Beacon_pwdb[100]; u32 Slide_Beacon_Total; struct rt_smooth_data_4rf cck_adc_pwdb; From ececd694df70a74a329a2958feed1aa8cfd706c5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:36:06 -0500 Subject: [PATCH 0372/1519] staging: rtl8192e: Convert typedef phy_sts_cck_819xpci_t to struct phy_sts_cck_819xpci Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 5 ++--- drivers/staging/rtl8192e/r8192E_dev.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index e481455a8f6..f3b6d7103a0 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -294,12 +294,11 @@ struct phy_sts_ofdm_819xpci { u8 rxsc_sgien_exflg; };//; -typedef struct _phy_cck_rx_status_report_819xpci -{ +struct phy_sts_cck_819xpci { u8 adc_pwdb_X[4]; u8 sq_rpt; u8 cck_agc_rpt; -}phy_sts_cck_819xpci_t, phy_sts_cck_8192s_t; +};//; #define PHY_RSSI_SLID_WIN_MAX 100 diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index b5324a3fc35..fb42ac224dc 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1406,7 +1406,7 @@ void rtl8192_query_rxphystatus( ) { struct phy_sts_ofdm_819xpci* pofdm_buf; - phy_sts_cck_819xpci_t * pcck_buf; + struct phy_sts_cck_819xpci * pcck_buf; struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; u8 *prxpkt; u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; @@ -1441,7 +1441,7 @@ void rtl8192_query_rxphystatus( prxpkt += sizeof(rx_fwinfo); - pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; + pcck_buf = (struct phy_sts_cck_819xpci *)prxpkt; pofdm_buf = (struct phy_sts_ofdm_819xpci *)prxpkt; pstats->RxMIMOSignalQuality[0] = -1; From 3215312bc286dc840c90ce91f29d2628d2019a4f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:38:16 -0500 Subject: [PATCH 0373/1519] staging: rtl8192e: Convert typedef tx_desc_cmd to struct tx_desc_cmd Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/r8192E_dev.h | 2 +- drivers/staging/rtl8192e/rtl_core.c | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index f3b6d7103a0..a62d34143ff 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -343,7 +343,7 @@ struct tx_desc { };//, *ptx_desc; -typedef struct tx_desc_cmd_819x_pci { +struct tx_desc_cmd { u16 PktSize; u8 Reserved1; u8 CmdType:3; @@ -364,7 +364,7 @@ typedef struct tx_desc_cmd_819x_pci { u32 Reserved4; u32 Reserved5; u32 Reserved6; -}tx_desc_cmd, *ptx_desc_cmd; +};//, *ptx_desc_cmd; typedef struct _rx_desc_819x_pci{ u16 Length:14; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index fb42ac224dc..53be813b85f 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1256,7 +1256,7 @@ void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_de pdesc->TxBuffAddr = cpu_to_le32(mapping); } -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, +void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff* skb) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 93d915318fc..20652edc49b 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -47,7 +47,7 @@ void rtl8192_link_change(struct net_device *dev); void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb); -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, tx_desc_cmd * entry, +void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff* skb); bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, rx_desc *pdesc, struct sk_buff* skb); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index a44161d82ec..7fd8e5d36d3 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2007,7 +2007,7 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring; - tx_desc_cmd* entry; + struct tx_desc_cmd * entry; unsigned int idx; cb_desc *tcb_desc; unsigned long flags; @@ -2016,7 +2016,7 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) ring = &priv->tx_ring[TXCMD_QUEUE]; idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = (tx_desc_cmd*) &ring->desc[idx]; + entry = (struct tx_desc_cmd *) &ring->desc[idx]; tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 63b9e6c7e5f..fdfab03a2cf 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -536,7 +536,7 @@ struct rtl819x_ops{ bool (* initialize_adapter)(struct net_device* dev); void (*link_change)(struct net_device* dev); void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, cb_desc * cb_desc, struct sk_buff *skb); - void (* tx_fill_cmd_descriptor)(struct net_device* dev, tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); + void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, rx_desc *pdesc, struct sk_buff* skb); bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, rx_desc *pdesc); void (* stop_adapter)(struct net_device *dev, bool reset); From 4f534b36afb6fe540c151a5bc0b49f15cc208eac Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:52:12 -0500 Subject: [PATCH 0374/1519] staging: rtl8192e: Convert typedef rx_desc to struct rx_desc Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.c | 6 +++--- drivers/staging/rtl8192e/r8192E_dev.h | 2 +- drivers/staging/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index a62d34143ff..228998a4a11 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -366,7 +366,7 @@ struct tx_desc_cmd { u32 Reserved6; };//, *ptx_desc_cmd; -typedef struct _rx_desc_819x_pci{ +struct rx_desc { u16 Length:14; u16 CRC32:1; u16 ICV:1; @@ -385,7 +385,7 @@ typedef struct _rx_desc_819x_pci{ u32 BufferAddress; -}rx_desc, *prx_desc; +};//, *prx_desc; typedef struct _rx_fwinfo_819x_pci{ diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 53be813b85f..41f5add3dd1 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1396,7 +1396,7 @@ rtl8192_signal_scale_mapping(struct r8192_priv * priv, void rtl8192_query_rxphystatus( struct r8192_priv * priv, struct rtllib_rx_stats * pstats, - prx_desc pdesc, + struct rx_desc *pdesc, prx_fwinfo pdrvinfo, struct rtllib_rx_stats * precord_stats, bool bpacket_match_bssid, @@ -1768,7 +1768,7 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct rtllib_ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, struct rtllib_rx_stats * pstats, - prx_desc pdesc, + struct rx_desc *pdesc, prx_fwinfo pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -1871,7 +1871,7 @@ void rtl8192_UpdateReceivedRateHistogramStatistics( } bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats* stats, - rx_desc *pdesc, struct sk_buff* skb) + struct rx_desc *pdesc, struct sk_buff* skb) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 20652edc49b..3843c8d1550 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -50,7 +50,7 @@ void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_de void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff* skb); bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, - rx_desc *pdesc, struct sk_buff* skb); + struct rx_desc *pdesc, struct sk_buff* skb); void rtl8192_halt_adapter(struct net_device *dev, bool reset); void rtl8192_update_ratr_table(struct net_device* dev); #endif diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7fd8e5d36d3..321b6856efa 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2108,7 +2108,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) short rtl8192_alloc_rx_desc_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - rx_desc *entry = NULL; + struct rx_desc *entry = NULL; int i, rx_queue_idx; for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ @@ -2210,7 +2210,7 @@ void rtl8192_pci_resetdescring(struct net_device *dev) for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ if (priv->rx_ring[rx_queue_idx]) { - rx_desc *entry = NULL; + struct rx_desc *entry = NULL; for (i = 0; i < priv->rxringcount; i++) { entry = &priv->rx_ring[rx_queue_idx][i]; entry->OWN = 1; @@ -2363,7 +2363,7 @@ void rtl8192_rx_normal(struct net_device *dev) stats.nic_type = NIC_8192E; while (count--) { - rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; if (pdesc->OWN) { diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index fdfab03a2cf..9dc1249a4a4 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -537,8 +537,8 @@ struct rtl819x_ops{ void (*link_change)(struct net_device* dev); void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, cb_desc * cb_desc, struct sk_buff *skb); void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); - bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, rx_desc *pdesc, struct sk_buff* skb); - bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, rx_desc *pdesc); + bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, struct rx_desc *pdesc, struct sk_buff* skb); + bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, struct rx_desc *pdesc); void (* stop_adapter)(struct net_device *dev, bool reset); void (* update_ratr_table)(struct net_device* dev); void (* irq_enable)(struct net_device* dev); @@ -644,7 +644,7 @@ typedef struct r8192_priv void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); - rx_desc *rx_ring[MAX_RX_QUEUE]; + struct rx_desc *rx_ring[MAX_RX_QUEUE]; struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT]; dma_addr_t rx_ring_dma[MAX_RX_QUEUE]; unsigned int rx_idx[MAX_RX_QUEUE]; From 6f22c62010122f73be5793e981db89401005a407 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:56:46 -0500 Subject: [PATCH 0375/1519] staging: rtl8192e: Convert typedef rx_fwinfo to struct rx_fwinfo Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 228998a4a11..8fcb9ce1996 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -388,7 +388,7 @@ struct rx_desc { };//, *prx_desc; -typedef struct _rx_fwinfo_819x_pci{ +struct rx_fwinfo { u16 Reserved1:12; u16 PartAggr:1; u16 FirstAGGR:1; @@ -407,6 +407,6 @@ typedef struct _rx_fwinfo_819x_pci{ u32 TSFL; -}rx_fwinfo, *prx_fwinfo; +};//, *prx_fwinfo; #endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 41f5add3dd1..1935c30da8a 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1397,7 +1397,7 @@ void rtl8192_query_rxphystatus( struct r8192_priv * priv, struct rtllib_rx_stats * pstats, struct rx_desc *pdesc, - prx_fwinfo pdrvinfo, + struct rx_fwinfo *pdrvinfo, struct rtllib_rx_stats * precord_stats, bool bpacket_match_bssid, bool bpacket_toself, @@ -1439,7 +1439,7 @@ void rtl8192_query_rxphystatus( prxpkt = (u8*)pdrvinfo; - prxpkt += sizeof(rx_fwinfo); + prxpkt += sizeof(struct rx_fwinfo); pcck_buf = (struct phy_sts_cck_819xpci *)prxpkt; pofdm_buf = (struct phy_sts_ofdm_819xpci *)prxpkt; @@ -1769,7 +1769,7 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, struct rtllib_rx_stats * pstats, struct rx_desc *pdesc, - prx_fwinfo pdrvinfo) + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); bool bpacket_match_bssid, bpacket_toself; @@ -1896,12 +1896,12 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats } return false; } else { - prx_fwinfo pDrvInfo = NULL; + struct rx_fwinfo *pDrvInfo = NULL; stats->RxDrvInfoSize = pdesc->RxDrvInfoSize; stats->RxBufShift = ((pdesc->Shift)&0x03); stats->Decrypted = !pdesc->SWDec; - pDrvInfo = (rx_fwinfo *)(skb->data + stats->RxBufShift); + pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift); stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); stats->bShortPreamble = pDrvInfo->SPLCP; From d3ab7211bd49b4df8e1469f73aa17662319d6c66 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 22:59:06 -0500 Subject: [PATCH 0376/1519] staging: rtl8192e: Convert typedef cmpk_txfb_t to struct cmpk_txfb Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 6 +++--- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 2ff69ef9129..026e3996655 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -104,7 +104,7 @@ Failed: static void cmpk_count_txstatistic( struct net_device *dev, - cmpk_txfb_t *pstx_fb) + struct cmpk_txfb *pstx_fb) { struct r8192_priv *priv = rtllib_priv(dev); #ifdef ENABLE_PS @@ -158,12 +158,12 @@ cmpk_handle_tx_feedback( u8 * pmsg) { struct r8192_priv *priv = rtllib_priv(dev); - cmpk_txfb_t rx_tx_fb; /* */ + struct cmpk_txfb rx_tx_fb; /* */ priv->stats.txfeedback++; - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); + memcpy((u8*)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); cmpk_count_txstatistic(dev, &rx_tx_fb); } /* cmpk_Handle_Tx_Feedback */ diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 787337064bc..e3278434b1f 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -18,7 +18,7 @@ ******************************************************************************/ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) +#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) #define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) @@ -30,8 +30,7 @@ #define ISR_BcnTimerIntr BIT13 -typedef struct tag_cmd_pkt_tx_feedback -{ +struct cmpk_txfb { u8 element_id; u8 length; u8 TID:4; /* */ @@ -56,7 +55,7 @@ typedef struct tag_cmd_pkt_tx_feedback u16 reserve3; /* */ u16 duration; /* */ -}cmpk_txfb_t; +};//; typedef struct tag_cmd_pkt_interrupt_status { From a76d98497eb5b8f2ad723cfcaa58d6f7653243af Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:00:34 -0500 Subject: [PATCH 0377/1519] staging: rtl8192e: Convert typedef cmpk_intr_sta_t to struct cmpk_intr_sta Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 6 +++--- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 026e3996655..4ead08dee3f 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -199,14 +199,14 @@ cmpk_handle_interrupt_status( struct net_device *dev, u8* pmsg) { - cmpk_intr_sta_t rx_intr_status; /* */ + struct cmpk_intr_sta rx_intr_status; /* */ struct r8192_priv *priv = rtllib_priv(dev); DMESG("---> cmpk_Handle_Interrupt_Status()\n"); rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) + if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; @@ -416,7 +416,7 @@ cmpk_message_handle_rx( case RX_INTERRUPT_STATUS: RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); cmpk_handle_interrupt_status(dev, pcmd_buff); - cmd_length = sizeof(cmpk_intr_sta_t); + cmd_length = sizeof(struct cmpk_intr_sta); break; case BOTH_QUERY_CONFIG: RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index e3278434b1f..9e92d7b88fa 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -57,13 +57,12 @@ struct cmpk_txfb { u16 duration; /* */ };//; -typedef struct tag_cmd_pkt_interrupt_status -{ +struct cmpk_intr_sta { u8 element_id; u8 length; u16 reserve; u32 interrupt_status; -}cmpk_intr_sta_t; +};//; typedef struct tag_cmd_pkt_set_configuration From fb6209640b94087672aa42b5e5806ea0c5525339 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:02:01 -0500 Subject: [PATCH 0378/1519] staging: rtl8192e: Convert typedef cmpk_set_cfg_t to struct cmpk_set_cfg Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 9e92d7b88fa..07c69f22893 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -19,8 +19,8 @@ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H #define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) -#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) +#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) #define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) @@ -65,8 +65,7 @@ struct cmpk_intr_sta { };//; -typedef struct tag_cmd_pkt_set_configuration -{ +struct cmpk_set_cfg { u8 element_id; u8 length; u16 reserve1; @@ -80,9 +79,9 @@ typedef struct tag_cmd_pkt_set_configuration u8 cfg_offset; u32 value; u32 mask; -}cmpk_set_cfg_t; +};//; -#define cmpk_query_cfg_t cmpk_set_cfg_t +#define cmpk_query_cfg_t struct cmpk_set_cfg typedef struct tag_tx_stats_feedback { From 7f6aa06ca2155dd1e6ca62f5ca81c09fbb9a8cb3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:03:38 -0500 Subject: [PATCH 0379/1519] staging: rtl8192e: Convert typedef cmpk_tx_status_t to struct cmpk_tx_status Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 6 +++--- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 4ead08dee3f..46efaa32236 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -266,7 +266,7 @@ cmpk_handle_query_config_rx( static void cmpk_count_tx_status( struct net_device *dev, - cmpk_tx_status_t *pstx_status) + struct cmpk_tx_status *pstx_status) { struct r8192_priv *priv = rtllib_priv(dev); @@ -314,9 +314,9 @@ cmpk_handle_tx_status( struct net_device *dev, u8* pmsg) { - cmpk_tx_status_t rx_tx_sts; /* */ + struct cmpk_tx_status rx_tx_sts; /* */ - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(cmpk_tx_status_t)); + memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(struct cmpk_tx_status)); cmpk_count_tx_status(dev, &rx_tx_sts); } diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 07c69f22893..4c34f6e3fd3 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -21,7 +21,7 @@ #define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) #define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) +#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) #define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) @@ -83,8 +83,7 @@ struct cmpk_set_cfg { #define cmpk_query_cfg_t struct cmpk_set_cfg -typedef struct tag_tx_stats_feedback -{ +struct cmpk_tx_status { u16 reserve1; u8 length; u8 element_id; @@ -111,7 +110,7 @@ typedef struct tag_tx_stats_feedback u16 reserve3_23; u8 reserve3_1; u8 rate; -}__attribute__((packed)) cmpk_tx_status_t; +}__packed; typedef struct tag_rx_debug_message_feedback { From acf08e1a0197f5366fbcfebb8a1245dc67f1d64c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:05:00 -0500 Subject: [PATCH 0380/1519] staging: rtl8192e: Convert typedef cmpk_rx_dbginfo_t to struct cmpk_rx_dbginfo Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 4c34f6e3fd3..c70694e4671 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -22,7 +22,7 @@ #define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) #define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) -#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) +#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) #define ISR_TxBcnOk BIT27 @@ -112,14 +112,13 @@ struct cmpk_tx_status { u8 rate; }__packed; -typedef struct tag_rx_debug_message_feedback -{ +struct cmpk_rx_dbginfo { u16 reserve1; u8 length; u8 element_id; -}cmpk_rx_dbginfo_t; +};//; typedef struct tag_tx_rate_history { From 1b419253af60f87c6844c17ef0c0b24d0676cf26 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:06:46 -0500 Subject: [PATCH 0381/1519] staging: rtl8192e: Convert typedef cmpk_tx_rahis_t to struct cmpk_tx_rahis Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 6 +++--- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 46efaa32236..6782f320fad 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -327,9 +327,9 @@ cmpk_handle_tx_rate_history( struct net_device *dev, u8* pmsg) { - cmpk_tx_rahis_t *ptxrate; + struct cmpk_tx_rahis *ptxrate; u8 i, j; - u16 length = sizeof(cmpk_tx_rahis_t); + u16 length = sizeof(struct cmpk_tx_rahis); u32 *ptemp; struct r8192_priv *priv = rtllib_priv(dev); @@ -354,7 +354,7 @@ cmpk_handle_tx_rate_history( ptemp[i] = (temp1<<16)|temp2; } - ptxrate = (cmpk_tx_rahis_t *)pmsg; + ptxrate = (struct cmpk_tx_rahis *)pmsg; if (ptxrate == NULL ) { diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index c70694e4671..6fc37b66c29 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -23,7 +23,7 @@ #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) #define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) #define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) -#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) +#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) #define ISR_TxBcnOk BIT27 #define ISR_TxBcnErr BIT26 @@ -120,8 +120,7 @@ struct cmpk_rx_dbginfo { };//; -typedef struct tag_tx_rate_history -{ +struct cmpk_tx_rahis { u8 element_id; u8 length; u16 reserved1; @@ -136,7 +135,7 @@ typedef struct tag_tx_rate_history u16 ht_mcs[4][16]; -}__attribute__((packed)) cmpk_tx_rahis_t; +} __packed; typedef enum tag_command_packet_directories { From b25765ce99920834b11498b9f5adf3bfe2007a08 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:08:06 -0500 Subject: [PATCH 0382/1519] staging: rtl8192e: Convert typedef fw_seg_container to struct fw_seg_container Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 8819f974474..6fd1419ee78 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -53,10 +53,10 @@ typedef enum _firmware_status{ FW_STATUS_5_READY = 5, }firmware_status_e; -typedef struct _rt_firmare_seg_container { +struct fw_seg_container { u16 seg_size; u8 *seg_ptr; -}fw_seg_container, *pfw_seg_container; +};//, *pfw_seg_container; typedef struct _rt_firmware{ firmware_status_e firmware_status; From 5aca114d91e726db89d28e56f260b811cc76a3dd Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:10:50 -0500 Subject: [PATCH 0383/1519] staging: rtl8192e: Convert typedef rt_firmware to struct rt_firmware Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 2 +- drivers/staging/rtl8192e/r8192E_firmware.c | 8 ++++---- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- drivers/staging/rtl8192e/rtl_core.c | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 6782f320fad..aa15255cffa 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -45,7 +45,7 @@ struct r8192_priv *priv = rtllib_priv(dev); u16 frag_threshold; u16 frag_length = 0, frag_offset = 0; - rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->pFirmware; struct sk_buff *skb; unsigned char *seg_ptr; cb_desc *tcb_desc; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index f7d191736d0..574d8dcc24c 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -26,7 +26,7 @@ extern void firmware_init_param(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->pFirmware; pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); } @@ -39,7 +39,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff u16 frag_length, frag_offset = 0; int i; - rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->pFirmware; struct sk_buff *skb; unsigned char *seg_ptr; cb_desc *tcb_desc; @@ -210,7 +210,7 @@ CPUCheckFirmwareReady_Fail: inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) { struct r8192_priv *priv = rtllib_priv(dev); - rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->pFirmware; bool rt_status = true; switch (load_fw_status) { @@ -269,7 +269,7 @@ bool init_firmware(struct net_device *dev) opt_rst_type_e rst_opt = OPT_SYSTEM_RESET; firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT; - rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->pFirmware; RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 6fd1419ee78..cb34b2bee19 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -58,14 +58,14 @@ struct fw_seg_container { u8 *seg_ptr; };//, *pfw_seg_container; -typedef struct _rt_firmware{ +struct rt_firmware { firmware_status_e firmware_status; u16 cmdpacket_frag_thresold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 #define MAX_FW_INIT_STEP 3 u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; u16 firmware_buf_size[MAX_FW_INIT_STEP]; -} rt_firmware, *prt_firmware; +}; bool init_firmware(struct net_device *dev); extern void firmware_init_param(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 321b6856efa..5fe3e8ee9c0 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1267,9 +1267,9 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = (rt_firmware*)vmalloc(sizeof(rt_firmware)); + priv->pFirmware = (struct rt_firmware *)vmalloc(sizeof(struct rt_firmware)); if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(rt_firmware)); + memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 9dc1249a4a4..720d1afffbb 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -606,7 +606,7 @@ typedef struct r8192_priv ACM_METHOD AcmMethod; - prt_firmware pFirmware; + struct rt_firmware *pFirmware; rtl819x_loopback_e LoopbackMode; firmware_source_e firmware_source; From 51ce231f6a77ffc42677e9dea57c5f1d31240ee3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:12:54 -0500 Subject: [PATCH 0384/1519] staging: rtl8192e: Convert typedef SwChnlCmd to struct sw_chnl_cmd Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 12 ++++++------ drivers/staging/rtl8192e/r8192E_phy.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 22ab5635215..517eab38b96 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -824,7 +824,7 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) return; } u8 rtl8192_phy_SetSwChnlCmdArray( - SwChnlCmd* CmdTable, + struct sw_chnl_cmd* CmdTable, u32 CmdTableIdx, u32 CmdTableSz, SwChnlCmdID CmdID, @@ -833,7 +833,7 @@ u8 rtl8192_phy_SetSwChnlCmdArray( u32 msDelay ) { - SwChnlCmd* pCmd; + struct sw_chnl_cmd* pCmd; if (CmdTable == NULL) { @@ -858,13 +858,13 @@ u8 rtl8192_phy_SetSwChnlCmdArray( u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay) { struct r8192_priv *priv = rtllib_priv(dev); - SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; + struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; u32 PreCommonCmdCnt; - SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; + struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT]; u32 PostCommonCmdCnt; - SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; + struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; u32 RfDependCmdCnt; - SwChnlCmd *CurrentCmd = NULL; + struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index d6020c0f98f..8a9b4914085 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -58,12 +58,12 @@ typedef enum _SwChnlCmdID { } SwChnlCmdID; /*--------------------------------Define structure--------------------------------*/ -typedef struct _SwChnlCmd { +struct sw_chnl_cmd { SwChnlCmdID CmdID; u32 Para1; u32 Para2; u32 msDelay; -} __attribute__ ((packed)) SwChnlCmd; +} __packed; extern u32 rtl819XMACPHY_Array_PG[]; extern u32 rtl819XPHY_REG_1T2RArray[]; From ebbef649f97c1d92321bdd2dc91b9babc21b2b26 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:14:59 -0500 Subject: [PATCH 0385/1519] staging: rtl8192e: Convert typedef rtl_reg_debug to struct rtl_reg_debug Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 720d1afffbb..d6e2975e65f 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -352,7 +352,7 @@ typedef struct buffer } buffer; -typedef struct rtl_reg_debug{ +struct rtl_reg_debug { unsigned int cmd; struct { unsigned char type; @@ -361,7 +361,7 @@ typedef struct rtl_reg_debug{ unsigned char length; } head; unsigned char buf[0xff]; -}rtl_reg_debug; +};//; struct rt_tx_rahis { u32 cck[4]; From 031189ec7693c57bdd016089a6cd007ea1e7a5b6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:17:46 -0500 Subject: [PATCH 0386/1519] staging: rtl8192e: Convert typedef txbbgain_struct to struct txbbgain_struct Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d6e2975e65f..394f3a753cc 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -491,11 +491,10 @@ typedef enum _TWO_PORT_STATUS TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE }TWO_PORT_STATUS; -typedef struct _txbbgain_struct -{ +struct txbbgain_struct { long txbb_iq_amplifygain; u32 txbbgain_value; -} txbbgain_struct, *ptxbbgain_struct; +}; typedef struct _ccktxbbgain_struct { @@ -602,7 +601,7 @@ typedef struct r8192_priv ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength]; ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; - txbbgain_struct txbbgain_table[TxBBGainTableLength]; + struct txbbgain_struct txbbgain_table[TxBBGainTableLength]; ACM_METHOD AcmMethod; From b7a14040dad80adbaf3a8b479952cac8334b9d9d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:29:22 -0500 Subject: [PATCH 0387/1519] staging: rtl8192e: Convert typedef tx_ring to struct tx_ring Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 394f3a753cc..d2056ed068e 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -511,11 +511,11 @@ typedef struct _init_gain } init_gain, *pinit_gain; -typedef struct _tx_ring{ +struct tx_ring { u32 * desc; u8 nStuckCount; - struct _tx_ring * next; -}__attribute__ ((packed)) tx_ring, * ptx_ring; + struct tx_ring * next; +} __packed; struct rtl8192_tx_ring { struct tx_desc *desc; From d514e3452a5f32e11586dfe29290beb9fb88a6cd Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:33:12 -0500 Subject: [PATCH 0388/1519] staging: rtl8192e: Convert typedef ccktxbbgain_struct to struct ccktxbbgain Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d2056ed068e..c71d4d2b43f 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -496,10 +496,9 @@ struct txbbgain_struct { u32 txbbgain_value; }; -typedef struct _ccktxbbgain_struct -{ +struct ccktxbbgain { u8 ccktxbb_valuearray[8]; -} ccktxbbgain_struct,*pccktxbbgain_struct; +}; typedef struct _init_gain { @@ -598,8 +597,8 @@ typedef struct r8192_priv struct bb_reg_definition PHYRegDef[4]; rate_adaptive rate_adaptive; - ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength]; - ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; + struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength]; + struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; struct txbbgain_struct txbbgain_table[TxBBGainTableLength]; From 8e8b90c60be8963a312118f435314a47f64160f2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:36:26 -0500 Subject: [PATCH 0389/1519] staging: rtl8192e: Convert typedef DRxPathSel to struct drx_path_sel Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.c | 2 +- drivers/staging/rtl8192e/rtl_dm.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 74868b84f04..160df4ad744 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -66,7 +66,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = /*------------------------Define global variable-----------------------------*/ dig_t dm_digtable; u8 dm_shadow[16][256] = {{0}}; -DRxPathSel DM_RxPathSelTable; +struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 6f59097873c..b2aad3ca6b2 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -219,8 +219,7 @@ typedef enum tag_dig_cck_cs_ratio_state_definition DIG_CS_RATIO_HIGHER = 1, DIG_CS_MAX }dm_dig_cs_ratio_e; -typedef struct _Dynamic_Rx_Path_Selection_ -{ +struct drx_path_sel { u8 Enable; u8 DbgMode; u8 cck_method; @@ -234,7 +233,7 @@ typedef struct _Dynamic_Rx_Path_Selection_ u8 rf_rssi[4]; u8 rf_enable_rssi_th[4]; long cck_pwdb_sta[4]; -}DRxPathSel; +};//; typedef enum tag_CCK_Rx_Path_Method_Definition { @@ -263,7 +262,7 @@ typedef struct tag_Tx_Config_Cmd_Format /*------------------------Export global variable----------------------------*/ extern dig_t dm_digtable; extern u8 dm_shadow[16][256]; -extern DRxPathSel DM_RxPathSelTable; +extern struct drx_path_sel DM_RxPathSelTable; extern u8 test_flag; /*------------------------Export global variable----------------------------*/ From 7204b51e0a071a968a2357a8737772f33934da2f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:38:55 -0500 Subject: [PATCH 0390/1519] staging: rtl8192e: Convert typedef dig_t to struct dig_t Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.c | 2 +- drivers/staging/rtl8192e/rtl_dm.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 160df4ad744..c2c31800b44 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -64,7 +64,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = /*------------------------Define global variable-----------------------------*/ -dig_t dm_digtable; +struct dig_t dm_digtable; u8 dm_shadow[16][256] = {{0}}; struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index b2aad3ca6b2..4884e82116b 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -84,8 +84,7 @@ /*------------------------------Define structure----------------------------*/ -typedef struct _dynamic_initial_gain_threshold_ -{ +struct dig_t { u8 dig_enable_flag; u8 dig_algorithm; u8 Dig_TwoPort_Algorithm; @@ -126,7 +125,7 @@ typedef struct _dynamic_initial_gain_threshold_ bool initialgain_lowerbound_state; long rssi_val; -}dig_t; +};//; typedef enum tag_dynamic_init_gain_state_definition { @@ -260,7 +259,7 @@ typedef struct tag_Tx_Config_Cmd_Format /*------------------------Export global variable----------------------------*/ -extern dig_t dm_digtable; +extern struct dig_t dm_digtable; extern u8 dm_shadow[16][256]; extern struct drx_path_sel DM_RxPathSelTable; From bdc632bc940f0122968f7f705860ad187975e646 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:40:46 -0500 Subject: [PATCH 0391/1519] staging: rtl8192e: Convert typedef DCMD_TXCMD_T to struct dcmd_txcmd Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.c | 8 ++++---- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index c2c31800b44..91edd466291 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -507,7 +507,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); bool bHighpowerstate, viviflag = false; - DCMD_TXCMD_T tx_cmd; + struct dcmd_txcmd tx_cmd; u8 powerlevelOFDM24G; int i =0, j = 0, k = 0; u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; @@ -534,7 +534,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; tx_cmd.Length = 4; tx_cmd.Value = Value; - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); + cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); mdelay(1); for (i = 0;i <= 30; i++) { @@ -3456,7 +3456,7 @@ static void dm_check_txrateandretrycount(struct net_device * dev) static void dm_send_rssi_tofw(struct net_device *dev) { - DCMD_TXCMD_T tx_cmd; + struct dcmd_txcmd tx_cmd; struct r8192_priv *priv = rtllib_priv(dev); write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); @@ -3466,7 +3466,7 @@ static void dm_send_rssi_tofw(struct net_device *dev) tx_cmd.Value = priv->undecorated_smoothed_pwdb; cmpk_message_handle_tx(dev, (u8*)&tx_cmd, - DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); + DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); } /*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 4884e82116b..a9aa09f13f5 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -249,12 +249,11 @@ typedef enum tag_DM_DbgMode_Definition DM_DBG_MAX }DM_DBG_E; -typedef struct tag_Tx_Config_Cmd_Format -{ +struct dcmd_txcmd { u32 Op; u32 Length; u32 Value; -}DCMD_TXCMD_T, *PDCMD_TXCMD_T; +};//, *struct dcmd_txcmd *; /*------------------------------Define structure----------------------------*/ From 2278a29d7a05a3fad9b07f3b84b14da8dd588031 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:42:24 -0500 Subject: [PATCH 0392/1519] staging: rtl8192e: Convert typedef rtl_fs_debug to struct rtl_fs_debug Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_debug.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index db8be0e3435..1d4177ef131 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -257,15 +257,14 @@ do { if (rt_global_debug_component & component) \ } \ } while (0) -typedef struct _rtl_fs_debug -{ +struct rtl_fs_debug { const char *name; struct dentry *dir_drv; struct dentry *debug_register; u32 hw_type; u32 hw_offset; bool hw_holding; -} rtl_fs_debug; +}; void print_buffer(u32 *buffer, int len); void dump_eprom(struct net_device *dev); From 0ce600451d9d5543cba5b4c0478ecd02ffd3e399 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:44:27 -0500 Subject: [PATCH 0393/1519] staging: rtl8192e: Convert typedef tx_pending_t to struct tx_pending Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 69cf46887b4..1f405cdccc5 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1774,10 +1774,10 @@ enum rtllib_state { #ifndef eqMacAddr #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) #endif -typedef struct tx_pending_t{ +struct tx_pending { int frag; struct rtllib_txb *txb; -}tx_pending_t; +};//; typedef struct _bandwidth_autoswitch { @@ -2392,7 +2392,7 @@ struct rtllib_device { u8 amsdu_in_process; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ - struct tx_pending_t tx_pending; + struct tx_pending tx_pending; /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; From 7152e7ec339bf187109d559089712f882291fb98 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:48:44 -0500 Subject: [PATCH 0394/1519] staging: rtl8192e: Convert typedef IbssParms to struct ibss_parms Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 1f405cdccc5..2bf090c41c1 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1824,9 +1824,9 @@ typedef enum _RT_JOIN_ACTION{ RT_NO_ACTION = 4, }RT_JOIN_ACTION; -typedef struct _IbssParms{ +struct ibss_parms { u16 atimWin; -}IbssParms, *PIbssParms; +};//, *struct ibss_parms *; #define MAX_NUM_RATES 264 typedef enum _RT_RF_POWER_STATE @@ -1889,7 +1889,7 @@ struct rt_pwr_save_ctrl { struct octet_string tmpSuppRateSet; u8 tmpSuppRateBuf[MAX_NUM_RATES]; bool bTmpSuppRate; - IbssParms tmpIbpm; + struct ibss_parms tmpIbpm; bool bTmpIbpm; bool bLeisurePs; From 43267fef107b44b3b3e73a02cfc6027b8e6336fb Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 18 Jul 2011 23:51:09 -0500 Subject: [PATCH 0395/1519] staging: rtl8192e: Convert typedef init_gain to struct init_gain Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index c71d4d2b43f..cb287923643 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -500,15 +500,14 @@ struct ccktxbbgain { u8 ccktxbb_valuearray[8]; }; -typedef struct _init_gain -{ +struct init_gain { u8 xaagccore1; u8 xbagccore1; u8 xcagccore1; u8 xdagccore1; u8 cca; -} init_gain, *pinit_gain; +}; struct tx_ring { u32 * desc; @@ -949,7 +948,7 @@ typedef struct r8192_priv u8 Record_CCK_20Mindex; u8 Record_CCK_40Mindex; - init_gain initgain_backup; + struct init_gain initgain_backup; u8 DefaultInitialGain[4]; bool bis_any_nonbepkts; bool bcurrent_turbo_EDCA; From 3b83db43ccbb26863f38caccc1e7fae370f31e57 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:01:29 -0500 Subject: [PATCH 0396/1519] staging: rtl8192e: Convert typedef cb_desc to struct cb_desc Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 4 ++-- drivers/staging/rtl8192e/r8192E_dev.c | 6 +++--- drivers/staging/rtl8192e/r8192E_dev.h | 6 +++--- drivers/staging/rtl8192e/r8192E_firmware.c | 8 ++++---- drivers/staging/rtl8192e/rtl_core.c | 18 +++++++++--------- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 4 ++-- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 4 ++-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 4 ++-- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 4 ++-- drivers/staging/rtl8192e/rtllib_rx.c | 4 ++-- drivers/staging/rtl8192e/rtllib_softmac.c | 8 ++++---- drivers/staging/rtl8192e/rtllib_tx.c | 18 +++++++++--------- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index aa15255cffa..d306e1034cf 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -48,7 +48,7 @@ struct rt_firmware *pfirmware = priv->pFirmware; struct sk_buff *skb; unsigned char *seg_ptr; - cb_desc *tcb_desc; + struct cb_desc *tcb_desc; u8 bLastIniPkt; struct tx_fwinfo_8190pci *pTxFwInfo = NULL; @@ -75,7 +75,7 @@ } memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); - tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; tcb_desc->bLastIniPkt = bLastIniPkt; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 1935c30da8a..5da21855f77 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1155,7 +1155,7 @@ u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) } -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_desc * cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, struct sk_buff* skb) { struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); @@ -1257,7 +1257,7 @@ void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_de } void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - cb_desc * cb_desc, struct sk_buff* skb) + struct cb_desc *cb_desc, struct sk_buff* skb) { struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); @@ -2265,7 +2265,7 @@ bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) return Reval; } -u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) +u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) { u8 tmp_Short; diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 3843c8d1550..4f31307c1fa 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -27,7 +27,7 @@ #include "r8190P_def.h" -u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc); +u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc); bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev); bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev); bool rtl8192_HalTxCheckStuck(struct net_device *dev); @@ -45,10 +45,10 @@ void rtl8192_get_eeprom_size(struct net_device* dev); bool rtl8192_adapter_start(struct net_device *dev); void rtl8192_link_change(struct net_device *dev); void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, cb_desc * cb_desc, +void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, struct sk_buff* skb); void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - cb_desc * cb_desc, struct sk_buff* skb); + struct cb_desc *cb_desc, struct sk_buff* skb); bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, struct rx_desc *pdesc, struct sk_buff* skb); void rtl8192_halt_adapter(struct net_device *dev, bool reset); diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 574d8dcc24c..41a6144a343 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -42,7 +42,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff struct rt_firmware *pfirmware = priv->pFirmware; struct sk_buff *skb; unsigned char *seg_ptr; - cb_desc *tcb_desc; + struct cb_desc *tcb_desc; u8 bLastIniPkt; firmware_init_param(dev); @@ -60,7 +60,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff skb = dev_alloc_skb(frag_length + 4); memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); - tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastIniPkt; @@ -103,14 +103,14 @@ fwSendNullPacket( bool rtStatus = true; struct r8192_priv *priv = rtllib_priv(dev); struct sk_buff *skb; - cb_desc *tcb_desc; + struct cb_desc *tcb_desc; unsigned char *ptr_buf; bool bLastInitPacket = false; skb = dev_alloc_skb(Length+ 4); memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); - tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastInitPacket; diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 5fe3e8ee9c0..e8e6d601479 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -798,7 +798,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) { struct net_device *dev = priv->rtllib->dev; struct sk_buff *pskb = NULL, *pnewskb = NULL; - cb_desc *tcb_desc = NULL; + struct cb_desc *tcb_desc = NULL; struct rtl8192_tx_ring *ring = NULL; struct tx_desc *pdesc = NULL; @@ -811,7 +811,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) if (!pnewskb) return; - tcb_desc = (cb_desc *)(pnewskb->cb + 8); + tcb_desc = (struct cb_desc *)(pnewskb->cb + 8); tcb_desc->queue_index = BEACON_QUEUE; tcb_desc->data_rate = 2; tcb_desc->RATRIndex = 7; @@ -1425,7 +1425,7 @@ rtl819x_TxCheckStuck(struct net_device *dev) bool bCheckFwTxCnt = false; struct rtl8192_tx_ring *ring = NULL; struct sk_buff* skb = NULL; - cb_desc * tcb_desc = NULL; + struct cb_desc * tcb_desc = NULL; unsigned long flags = 0; switch (priv->rtllib->ps) @@ -1456,7 +1456,7 @@ rtl819x_TxCheckStuck(struct net_device *dev) else { skb = (&ring->queue)->next; - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->nStuckCount++; bCheckFwTxCnt = true; if (tcb_desc->nStuckCount > 1) @@ -1911,7 +1911,7 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || priv->bResetInProgress){ @@ -1942,7 +1942,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; if (queue_index != TXCMD_QUEUE){ @@ -2009,7 +2009,7 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) struct rtl8192_tx_ring *ring; struct tx_desc_cmd * entry; unsigned int idx; - cb_desc *tcb_desc; + struct cb_desc *tcb_desc; unsigned long flags; spin_lock_irqsave(&priv->irq_th_lock,flags); @@ -2018,7 +2018,7 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; entry = (struct tx_desc_cmd *) &ring->desc[idx]; - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); @@ -2033,7 +2033,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring; unsigned long flags; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct tx_desc *pdesc = NULL; struct rtllib_hdr_1addr * header = NULL; u16 fc=0, type=0,stype=0; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index cb287923643..705ccdee0db 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -532,8 +532,8 @@ struct rtl819x_ops{ void (* init_before_adapter_start)(struct net_device* dev); bool (* initialize_adapter)(struct net_device* dev); void (*link_change)(struct net_device* dev); - void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, cb_desc * cb_desc, struct sk_buff *skb); - void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, cb_desc * cb_desc, struct sk_buff *skb); + void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, struct cb_desc *cb_desc, struct sk_buff *skb); + void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, struct cb_desc *cb_desc, struct sk_buff *skb); bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, struct rx_desc *pdesc, struct sk_buff* skb); bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, struct rx_desc *pdesc); void (* stop_adapter)(struct net_device *dev, bool reset); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2bf090c41c1..4b1a6d8dcc2 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -147,7 +147,7 @@ static inline void *netdev_priv_rsl(struct net_device *dev) /* defined for skb cb field */ /* At most 28 byte */ -typedef struct cb_desc { +struct cb_desc { /* Tx Desc Related flags (8-9) */ u8 bLastIniPkt:1; u8 bCmdOrInit:1; @@ -202,7 +202,7 @@ typedef struct cb_desc { u8 bBTTxPacket; u8 bIsBTProbRsp; -}cb_desc, *pcb_desc; +};//, *pcb_desc; /*--------------------------Define -------------------------------------------*/ #define MGN_1M 0x02 diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index ef17c999009..9e640c24b89 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -192,7 +192,7 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int data_len, i; u8 *pos; struct rtllib_hdr_4addr *hdr; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) @@ -262,7 +262,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) struct rtllib_ccmp_data *key = priv; u8 keyidx, *pos; struct rtllib_hdr_4addr *hdr; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 pn[6]; if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 8918aa5760a..89da28de571 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -303,7 +303,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int len; u8 *pos; struct rtllib_hdr_4addr *hdr; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; u8 rc4key[16], *icv; @@ -384,7 +384,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 iv32; u16 iv16; struct rtllib_hdr_4addr *hdr; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; u8 icv[4]; diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 201e2ec5d3a..05aa2e2a90e 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -101,7 +101,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; u32 crc; u8 *icv; @@ -170,7 +170,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; u32 crc; u8 icv[4]; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 03e9df1e918..909a2f5e8de 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -291,7 +291,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (ieee->hwsec_active) { - cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -332,7 +332,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, return 0; if (ieee->hwsec_active) { - cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 64574acc0fd..11433c61bda 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -242,7 +242,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) struct rtllib_hdr_3addr *header= (struct rtllib_hdr_3addr *) skb->data; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ @@ -311,7 +311,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; u16 fc,type,stype; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); fc = header->frame_ctl; type = WLAN_FC_GET_TYPE(fc); @@ -2552,7 +2552,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) unsigned int queue_index = txb->queue_index; unsigned long flags; int i; - cb_desc *tcb_desc = NULL; + struct cb_desc *tcb_desc = NULL; unsigned long queue_len = 0; spin_lock_irqsave(&ieee->lock,flags); @@ -2561,7 +2561,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) rtllib_sta_wakeup(ieee,0); /* update the tx status */ - tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); if (tcb_desc->bMulticast) { ieee->stats.multicast++; } diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index dd89b0bebec..d03b5aa02cc 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -287,7 +287,7 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } #define SN_LESS(a, b) (((a-b)&0x800)!=0) -void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc) +void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; @@ -358,7 +358,7 @@ FORCED_AGG_SETTING: return; } -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, cb_desc* tcb_desc) +extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) { tcb_desc->bUseShortPreamble = false; if (tcb_desc->data_rate == 2) @@ -373,7 +373,7 @@ extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, cb_desc* } extern void -rtllib_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc) +rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -394,7 +394,7 @@ rtllib_query_HTCapShortGI(struct rtllib_device *ieee, cb_desc *tcb_desc) tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc) +void rtllib_query_BandwidthMode(struct rtllib_device* ieee, struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -413,7 +413,7 @@ void rtllib_query_BandwidthMode(struct rtllib_device* ieee, cb_desc *tcb_desc) return; } -void rtllib_query_protectionmode(struct rtllib_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb) +void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc, struct sk_buff* skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -513,7 +513,7 @@ NO_PROTECTION: } -void rtllib_txrate_selectmode(struct rtllib_device* ieee, cb_desc* tcb_desc) +void rtllib_txrate_selectmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; @@ -586,7 +586,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; struct rtllib_crypt_data* crypt = NULL; - cb_desc *tcb_desc; + struct cb_desc *tcb_desc; u8 bIsMulticast = false; u8 IsAmsdu = false; @@ -778,7 +778,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - tcb_desc = (cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); if (qos_actived){ skb_frag->priority = skb->priority; tcb_desc->queue_index = UP2AC(skb->priority); @@ -873,7 +873,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) success: if (txb) { - cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; tcb_desc->priority = skb->priority; From dca0eb1e15fa7cf1f4e5fae3d2c32512e24f1742 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:04:08 -0500 Subject: [PATCH 0397/1519] staging: rtl8192e: Convert typedef bandwidth_autoswitch to struct bandwidth_autoswitch Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 4b1a6d8dcc2..c06185c0d96 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1779,13 +1779,12 @@ struct tx_pending { struct rtllib_txb *txb; };//; -typedef struct _bandwidth_autoswitch -{ +struct bandwidth_autoswitch { long threshold_20Mhzto40Mhz; long threshold_40Mhzto20Mhz; bool bforced_tx20Mhz; bool bautoswitch_enable; -}bandwidth_autoswitch,*pbandwidth_autoswitch; +};//,*pbandwidth_autoswitch; @@ -2383,7 +2382,7 @@ struct rtllib_device { u32 fsync_seconddiff_ratethreshold; Fsync_State fsync_state; bool bis_any_nonbepkts; - bandwidth_autoswitch bandwidth_auto_switch; + struct bandwidth_autoswitch bandwidth_auto_switch; bool FwRWRF; struct rt_link_detect LinkDetectInfo; From 9be6f10ed3867b1b89c34e4cd3cb5c00c0bc5282 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:09:03 -0500 Subject: [PATCH 0398/1519] staging: rtl8192e: Convert typedef rate_adaptive to struct rate_adaptive Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtl_dm.c | 6 +++--- drivers/staging/rtl8192e/rtllib.h | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 705ccdee0db..2747f0dce63 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -594,7 +594,7 @@ typedef struct r8192_priv IC_INFERIORITY_8192S IC_Class; HT_CHANNEL_WIDTH CurrentChannelBW; struct bb_reg_definition PHYRegDef[4]; - rate_adaptive rate_adaptive; + struct rate_adaptive rate_adaptive; struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength]; struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 91edd466291..ecd81774087 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -251,7 +251,7 @@ extern void init_rate_adaptive(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); - prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; + struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; pra->ratr_state = DM_RATR_STA_MAX; pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; @@ -295,7 +295,7 @@ static void dm_check_rate_adaptive(struct net_device * dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; + struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; u32 currentRATR, targetRATR = 0; u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; bool bshort_gi_enabled = false; @@ -1801,7 +1801,7 @@ dm_change_rxpath_selection_setting( s32 DM_Value) { struct r8192_priv *priv = rtllib_priv(dev); - prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive); + struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); if (DM_Type == 0) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c06185c0d96..20c91e41405 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2015,8 +2015,7 @@ struct sw_cam_table { };//,*struct sw_cam_table *; #define TOTAL_CAM_ENTRY 32 -typedef struct _rate_adaptive -{ +struct rate_adaptive { u8 rate_adaptive_disabled; u8 ratr_state; u16 reserve; @@ -2038,7 +2037,7 @@ typedef struct _rate_adaptive u32 last_ratr; u8 PreRATRState; -} rate_adaptive, *prate_adaptive; +}; typedef enum _RATR_TABLE_MODE_8192S{ RATR_INX_WIRELESS_NGB = 0, RATR_INX_WIRELESS_NG = 1, From 1897a50c8f86018905449be2b59875bf2fedecb9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:11:20 -0500 Subject: [PATCH 0399/1519] staging: rtl8192e: Convert typedef mp_adapter to struct mp_adapter Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtl_pci.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 2747f0dce63..803cfe870ec 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -578,7 +578,7 @@ typedef struct r8192_priv struct channel_access_setting ChannelAccessSetting; - mp_adapter NdisAdapter; + struct mp_adapter NdisAdapter; struct rtl819x_ops *ops; struct rtllib_device *rtllib; diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h index 890034aca4e..b4efc7c4db0 100644 --- a/drivers/staging/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -54,7 +54,7 @@ static inline void NdisRawReadPortUlong(u32 port, u32 *pval) *pval = inl(port); } -typedef struct _mp_adapter{ +struct mp_adapter { u8 LinkCtrlReg; u8 BusNumber; @@ -69,7 +69,7 @@ typedef struct _mp_adapter{ u16 PciBridgeDeviceId; u8 PciBridgePCIeHdrOffset; u8 PciBridgeLinkCtrlReg; -}mp_adapter,*pmp_adapter; +};//,*pmp_adapter; struct rt_pci_capab_header { unsigned char CapabilityID; From 65dab9a0e1672b97feb9a44d75e88a263b8db575 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:14:16 -0500 Subject: [PATCH 0400/1519] staging: rtl8192e: Convert typedef ieee_param to struct ieee_param Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 20c91e41405..94120ab6147 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -457,7 +457,7 @@ typedef enum _RT_OP_MODE{ #define RT_ASSERT_RET(_Exp) do {} while(0) #define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) -typedef struct ieee_param { +struct ieee_param { u32 cmd; u8 sta_addr[ETH_ALEN]; union { @@ -484,7 +484,7 @@ typedef struct ieee_param { u8 key[0]; } crypt; } u; -}ieee_param; +};//; #if WIRELESS_EXT < 17 From f0a1f2924b2698ec9eb58a2739fab633dd2b29cc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:16:51 -0500 Subject: [PATCH 0401/1519] staging: rtl8192e: Convert typedef adhoc_peer_entry_t to struct adhoc_peer_entry Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_wx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 3a0fcfc3401..31a492672a7 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -186,15 +186,14 @@ static int r8192_wx_force_mic_error(struct net_device *dev, } #define MAX_ADHOC_PEER_NUM 64 -typedef struct -{ +struct adhoc_peer_entry { unsigned char MacAddr[ETH_ALEN]; unsigned char WirelessMode; unsigned char bCurTxBW40MHz; -} adhoc_peer_entry_t, *p_adhoc_peer_entry_t; +}; typedef struct { - adhoc_peer_entry_t Entry[MAX_ADHOC_PEER_NUM]; + struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM]; unsigned char num; } adhoc_peers_info_t, *p_adhoc_peers_info_t; From 49f4e74a94920807bfa5d952954c5b08b2d33359 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:19:05 -0500 Subject: [PATCH 0402/1519] staging: rtl8192e: Convert typedef adhoc_peers_info_t to struct adhoc_peers_info Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_wx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 31a492672a7..1eb2559765f 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -191,11 +191,10 @@ struct adhoc_peer_entry { unsigned char WirelessMode; unsigned char bCurTxBW40MHz; }; -typedef struct -{ +struct adhoc_peers_info { struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM]; unsigned char num; -} adhoc_peers_info_t, *p_adhoc_peers_info_t; +}; int r8192_wx_get_adhoc_peers(struct net_device *dev, struct iw_request_info *info, From 2fac6fc46d7bf8f92b0174d12c4fb2385e592a19 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:21:31 -0500 Subject: [PATCH 0403/1519] staging: rtl8192e: Convert typedef Stats to struct rt_stats Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtl_core.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index e8e6d601479..578c3c807e6 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1354,7 +1354,7 @@ short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - memset(&(priv->stats),0,sizeof(struct Stats)); + memset(&(priv->stats),0,sizeof(struct rt_stats)); rtl8192_dbgp_flag_init(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 803cfe870ec..1271e3dea93 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -376,8 +376,7 @@ struct rt_smooth_data_4rf { u32 TotalVal[4]; };//, *struct rt_smooth_data_4rf *; -typedef struct Stats -{ +struct rt_stats { unsigned long txrdu; unsigned long rxrdu; unsigned long rxok; @@ -470,7 +469,7 @@ typedef struct Stats u32 Slide_Beacon_Total; struct rt_smooth_data_4rf cck_adc_pwdb; u32 CurrentShowTxate; -} Stats; +}; struct channel_access_setting { u16 SIFS_Timer; @@ -632,7 +631,7 @@ typedef struct r8192_priv struct semaphore rf_sem; struct mutex mutex; - struct Stats stats; + struct rt_stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; From e3e3762996b7c089c44db5ace166563e66957bd0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:26:41 -0500 Subject: [PATCH 0404/1519] staging: rtl8192e: Convert typedef r8192_priv to struct r8192_priv Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 2 +- drivers/staging/rtl8192e/r8192E_dev.c | 10 +++++----- drivers/staging/rtl8192e/r8192E_firmware.c | 10 +++++----- drivers/staging/rtl8192e/rtl_core.c | 14 +++++++------- drivers/staging/rtl8192e/rtl_core.h | 21 ++++++++++----------- drivers/staging/rtl8192e/rtl_dm.c | 6 +++--- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index d306e1034cf..90cbb5b45f6 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -42,7 +42,7 @@ { bool rt_status = true; - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); u16 frag_threshold; u16 frag_length = 0, frag_offset = 0; struct rt_firmware *pfirmware = priv->pFirmware; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 5da21855f77..830616ad6be 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -97,7 +97,7 @@ void rtl8192e_update_msr(struct net_device *dev) void rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) { - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); switch (variable) { @@ -1004,7 +1004,7 @@ void rtl8192_link_change(struct net_device *dev) void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg) { - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); if (bAllowAllDA) priv->ReceiveConfig |= RCR_AAP; @@ -2001,7 +2001,7 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) void rtl8192_update_ratr_table(struct net_device* dev) { - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); struct rtllib_device* ieee = priv->rtllib; u8* pMcsRate = ieee->dot11HTOperationalRateSet; u32 ratr_value = 0; @@ -2254,7 +2254,7 @@ bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) { bool Reval; - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); struct rtllib_device* ieee = priv->rtllib; if (ieee->bHalfWirelessN24GMode == true) @@ -2283,7 +2283,7 @@ ActUpdateChannelAccessSetting( struct channel_access_setting *ChnlAccessSetting ) { - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); return; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 41a6144a343..bacee9e9e2a 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -25,7 +25,7 @@ extern void firmware_init_param(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); @@ -33,7 +33,7 @@ extern void firmware_init_param(struct net_device *dev) bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; u16 frag_threshold; u16 frag_length, frag_offset = 0; @@ -101,7 +101,7 @@ fwSendNullPacket( ) { bool rtStatus = true; - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct sk_buff *skb; struct cb_desc *tcb_desc; unsigned char *ptr_buf; @@ -209,7 +209,7 @@ CPUCheckFirmwareReady_Fail: inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; bool rt_status = true; @@ -253,7 +253,7 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu bool init_firmware(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; u8 *firmware_img_buf[3] = { &Rtl8192PciEFwBootArray[0], diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 578c3c807e6..ce649a560a3 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -923,7 +923,7 @@ void rtl8192_config_rate(struct net_device* dev, u16* rate_config) } } -void rtl8192_refresh_supportrate(struct r8192_priv* priv) +void rtl8192_refresh_supportrate(struct r8192_priv * priv) { struct rtllib_device* ieee = priv->rtllib; if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) { @@ -1283,7 +1283,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) } -static void rtl8192_init_priv_lock(struct r8192_priv* priv) +static void rtl8192_init_priv_lock(struct r8192_priv * priv) { spin_lock_init(&priv->fw_scan_lock); spin_lock_init(&priv->tx_lock); @@ -1675,7 +1675,7 @@ void rtl819x_update_rxcounts(struct r8192_priv *priv, void rtl819x_watchdog_wqcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,watch_dog_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->rtllib->dev; struct rtllib_device* ieee = priv->rtllib; RESET_TYPE ResetType = RESET_TYPE_NORESET; @@ -2479,7 +2479,7 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) /**************************************************************************** ---------------------------- NIC START/CLOSE STUFF--------------------------- *****************************************************************************/ -void rtl8192_cancel_deferred_work(struct r8192_priv* priv) +void rtl8192_cancel_deferred_work(struct r8192_priv * priv) { cancel_delayed_work(&priv->watch_dog_wq); cancel_delayed_work(&priv->update_beacon_wq); @@ -3138,7 +3138,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) bool NicIFEnableNIC(struct net_device* dev) { bool init_status = true; - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); if (IS_NIC_DOWN(priv)){ @@ -3167,7 +3167,7 @@ bool NicIFEnableNIC(struct net_device* dev) bool NicIFDisableNIC(struct net_device* dev) { bool status = true; - struct r8192_priv* priv = rtllib_priv(dev); + struct r8192_priv * priv = rtllib_priv(dev); u8 tmp_state = 0; RT_TRACE(COMP_PS, "=========>%s()\n",__func__); priv->bdisable_nic = true; @@ -3250,7 +3250,7 @@ static void __exit rtl8192_pci_module_exit(void) void check_rfctrl_gpio_timer(unsigned long data) { - struct r8192_priv* priv = rtllib_priv((struct net_device *)data); + struct r8192_priv * priv = rtllib_priv((struct net_device *)data); priv->polling_timer_on = 1; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 1271e3dea93..e0c56b9fa3c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -68,13 +68,13 @@ #define DRV_NAME "rtl819xE" -#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8190P)||\ - (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192E)) -#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192SE) -#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192CE) -#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192CU) -#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192DE) -#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv*)rtllib_priv(dev))->card_8192==NIC_8192DU) +#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8190P)||\ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192E)) +#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192SE) +#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CE) +#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CU) +#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DE) +#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DU) #define RTL_PCI_DEVICE(vend, dev, cfg) \ .vendor = (vend), .device = (dev), \ @@ -547,8 +547,7 @@ struct rtl819x_ops{ bool (* RxCheckStuckHandler)(struct net_device* dev); }; -typedef struct r8192_priv -{ +struct r8192_priv { struct pci_dev *pdev; struct pci_dev *bridge_pdev; @@ -1017,7 +1016,7 @@ typedef struct r8192_priv u8 H2CTxCmdSeq; -}r8192_priv; +};//; extern const struct ethtool_ops rtl819x_ethtool_ops; @@ -1065,7 +1064,7 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); short rtl8192_pci_initdescring(struct net_device *dev); -void rtl8192_cancel_deferred_work(struct r8192_priv* priv); +void rtl8192_cancel_deferred_work(struct r8192_priv * priv); int _rtl8192_up(struct net_device *dev,bool is_silent_reset); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index ecd81774087..a8e2678c1a5 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -884,7 +884,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) void dm_txpower_trackingcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,txpower_tracking_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; if (priv->IC_Cut >= IC_VersionCut_D) @@ -2668,7 +2668,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) extern void dm_CheckRfCtrlGPIO(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,gpio_change_rf_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,gpio_change_rf_wq); struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; RT_RF_POWER_STATE eRfPowerStateToSet; @@ -2735,7 +2735,7 @@ extern void dm_CheckRfCtrlGPIO(void *data) void dm_rf_pathcheck_workitemcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data,struct r8192_priv,rfpath_check_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,rfpath_check_wq); struct net_device *dev =priv->rtllib->dev; u8 rfpath = 0, i; From fc22c052e20496935ee165609ed814eed336cd4a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:32:34 -0500 Subject: [PATCH 0405/1519] staging: rtl8192e: Convert typedef buffer to struct buffer Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/r8192E_firmware.c | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- drivers/staging/rtl8192e/rtl_core.h | 5 ++--- drivers/staging/rtl8192e/rtllib.h | 12 ++++++------ drivers/staging/rtl8192e/rtllib_crypt.h | 2 +- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 14 +++++++------- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 830616ad6be..d610de92b1d 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1599,7 +1599,7 @@ void rtl8192_query_rxphystatus( } } -void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) +void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) { bool bcheck = false; u8 rfpath; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index bacee9e9e2a..7d204219408 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -303,7 +303,7 @@ bool init_firmware(struct net_device *dev) goto download_firmware_fail; } if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, "img file size exceed the container buffer fail!\n"); + RT_TRACE(COMP_FIRMWARE, "img file size exceed the container struct buffer fail!\n"); goto download_firmware_fail; } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index d2043612462..172ee46087f 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -76,7 +76,7 @@ void RxPktPendingTimeout(unsigned long data) pRxTs->RxTimeoutIndicateSeq = 0xffff; if (index > REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; } diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index e0c56b9fa3c..9f576ffc231 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -344,13 +344,12 @@ typedef enum _PCI_BRIDGE_VENDOR { PCI_BRIDGE_VENDOR_MAX , } PCI_BRIDGE_VENDOR; -typedef struct buffer -{ +struct buffer { struct buffer *next; u32 *buf; dma_addr_t dma; -} buffer; +}; struct rtl_reg_debug { unsigned int cmd; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 94120ab6147..296488ef4f9 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -761,18 +761,18 @@ do { if (rtllib_debug_level & (level)) \ if ((_Comp) & level) \ { \ int __i; \ - u8 buffer[MAX_STR_LEN]; \ + u8 struct buffer[MAX_STR_LEN]; \ int length = (_Len\n", _Len, buffer); \ + printk(": %d, <%s>\n", _Len, struct buffer); \ } #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h index 5772252af53..b01410550c4 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -61,7 +61,7 @@ struct rtllib_crypto_ops { /* maximum number of bytes added by encryption; encrypt buf is * allocated with extra_prefix_len bytes, copy of in_buf, and * extra_postfix_len; encrypt need not use all this space, but - * the result must start at the beginning of the buffer and correct + * the result must start at the beginning of the struct buffer and correct * length must be returned */ int extra_prefix_len, extra_postfix_len; diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 05aa2e2a90e..78a749f5efa 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -157,7 +157,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } -/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of +/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP part of * the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. * diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 909a2f5e8de..68f4aeed9e5 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -618,7 +618,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, /* * Indication process. * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets - * with the SeqNum smaller than latest WinStart and buffer other packets. + * with the SeqNum smaller than latest WinStart and struct buffer other packets. */ /* For Rx Reorder condition: * 1. All packets with SeqNum smaller than WinStart => Indicate @@ -654,14 +654,14 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, } } else { RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); } } else { /* * Packets are dropped if there is not enough reorder entries. * This part shall be modified!! We can just indicate all the - * packets in buffer and get reorder entries. + * packets in struct buffer and get reorder entries. */ RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); { @@ -683,7 +683,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { - /* This protect buffer from overflow. */ + /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); bPktInBuf = true; @@ -714,7 +714,7 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxTimeoutIndicateSeq = 0xffff; if (index>REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; } @@ -771,7 +771,7 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, rxb->nr_subframes = 1; /* altered by clark 3/30/2010 - * The buffer size of the skb indicated to upper layer + * The struct buffer size of the skb indicated to upper layer * must be less than 5000, or the defraged IP datagram * in the IP layer will exceed "ipfrag_high_tresh" and be * discarded. so there must not use the function @@ -813,7 +813,7 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, skb_pull(skb, ETHERNET_HEADER_SIZE); /* altered by clark 3/30/2010 - * The buffer size of the skb indicated to upper layer + * The struct buffer size of the skb indicated to upper layer * must be less than 5000, or the defraged IP datagram * in the IP layer will exceed "ipfrag_high_tresh" and be * discarded. so there must not use the function From edc4b2c5708547de030ff73ffc771ad498209206 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 00:46:24 -0500 Subject: [PATCH 0406/1519] staging: rtl8192e: Convert delayed_work_struct_rsl to struct delayed_work and work_struct_rsl to struct work_struct Remove typedef from struct. Rename struct. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 22 +++++++++++----------- drivers/staging/rtl8192e/rtllib.h | 26 ++++++++++++-------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 9f576ffc231..1038ed85562 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -561,15 +561,15 @@ struct r8192_priv { short up; short up_first_time; - delayed_work_struct_rsl update_beacon_wq; - delayed_work_struct_rsl watch_dog_wq; - delayed_work_struct_rsl txpower_tracking_wq; - delayed_work_struct_rsl rfpath_check_wq; - delayed_work_struct_rsl gpio_change_rf_wq; - delayed_work_struct_rsl initialgain_operate_wq; - delayed_work_struct_rsl check_hw_scan_wq; - delayed_work_struct_rsl hw_scan_simu_wq; - delayed_work_struct_rsl start_hw_scan_wq; + struct delayed_work update_beacon_wq; + struct delayed_work watch_dog_wq; + struct delayed_work txpower_tracking_wq; + struct delayed_work rfpath_check_wq; + struct delayed_work gpio_change_rf_wq; + struct delayed_work initialgain_operate_wq; + struct delayed_work check_hw_scan_wq; + struct delayed_work hw_scan_simu_wq; + struct delayed_work start_hw_scan_wq; struct workqueue_struct *priv_wq; @@ -580,7 +580,7 @@ struct r8192_priv { struct rtl819x_ops *ops; struct rtllib_device *rtllib; - work_struct_rsl reset_wq; + struct work_struct reset_wq; struct log_int_8190 InterruptLog; @@ -678,7 +678,7 @@ struct r8192_priv { enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type; - work_struct_rsl qos_activate; + struct work_struct qos_activate; u8 bIbssCoordinator; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 296488ef4f9..08b6770dca6 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -79,11 +79,9 @@ #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) - typedef struct delayed_work delayed_work_struct_rsl; #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) - typedef struct work_struct work_struct_rsl; #define queue_work_rsl(x,y) queue_work(x,y) #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) @@ -1864,7 +1862,7 @@ struct rt_pwr_save_ctrl { bool bHaltAdapterClkRQ; bool bSwRfProcessing; RT_RF_POWER_STATE eInactivePowerState; - work_struct_rsl InactivePsWorkItem; + struct work_struct InactivePsWorkItem; struct timer_list InactivePsTimer; IPS_CALLBACK_FUNCION ReturnPoint; @@ -2398,17 +2396,17 @@ struct rtllib_device { /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; u8 need_sw_enc; - work_struct_rsl associate_complete_wq; - work_struct_rsl ips_leave_wq; - delayed_work_struct_rsl associate_procedure_wq; - delayed_work_struct_rsl softmac_scan_wq; - delayed_work_struct_rsl softmac_hint11d_wq; - delayed_work_struct_rsl associate_retry_wq; - delayed_work_struct_rsl start_ibss_wq; - delayed_work_struct_rsl hw_wakeup_wq; - delayed_work_struct_rsl hw_sleep_wq; - delayed_work_struct_rsl link_change_wq; - work_struct_rsl wx_sync_scan_wq; + struct work_struct associate_complete_wq; + struct work_struct ips_leave_wq; + struct delayed_work associate_procedure_wq; + struct delayed_work softmac_scan_wq; + struct delayed_work softmac_hint11d_wq; + struct delayed_work associate_retry_wq; + struct delayed_work start_ibss_wq; + struct delayed_work hw_wakeup_wq; + struct delayed_work hw_sleep_wq; + struct delayed_work link_change_wq; + struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; From 7baf9546daf78de5760bf0b120b1da39ace855b1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:11:23 -0500 Subject: [PATCH 0407/1519] staging: rtl8192e: Convert typedef SEQUENCE_CONTROL to union sequence_control Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index a0c46c5a693..a868d659f68 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -36,14 +36,14 @@ #define DELBA_REASON_END_BA 37 #define DELBA_REASON_UNKNOWN_BA 38 #define DELBA_REASON_TIMEOUT 39 -typedef union _SEQUENCE_CONTROL{ +union sequence_control { u16 ShortData; struct { u16 FragNum:4; u16 SeqNum:12; }field; -}SEQUENCE_CONTROL, *PSEQUENCE_CONTROL; +}; typedef union _BA_PARAM_SET { u8 charData[2]; @@ -72,7 +72,7 @@ struct ba_record { u8 DialogToken; BA_PARAM_SET BaParamSet; u16 BaTimeoutValue; - SEQUENCE_CONTROL BaStartSeqCtrl; + union sequence_control BaStartSeqCtrl; }; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index f721d286c82..608ea2d7b4a 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -243,7 +243,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) struct ba_record *pBA = NULL; PBA_PARAM_SET pBaParamSet = NULL; u16* pBaTimeoutVal = NULL; - PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; + union sequence_control *pBaStartSeqCtrl = NULL; struct rx_ts_record *pTS = NULL; if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) @@ -261,7 +261,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) pDialogToken = tag + 2; pBaParamSet = (PBA_PARAM_SET)(tag + 3); pBaTimeoutVal = (u16*)(tag + 5); - pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7); + pBaStartSeqCtrl = (union sequence_control *)(req + 7); RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); if (ieee->current_network.qos_data.active == 0 || From 6857f36710863716dc60c49e33769dd694aacda6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:14:55 -0500 Subject: [PATCH 0408/1519] staging: rtl8192e: Convert typedef BA_PARAM_SET to union ba_param_set Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_BAProc.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index a868d659f68..1e2cc2e344a 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -45,7 +45,7 @@ union sequence_control { }field; }; -typedef union _BA_PARAM_SET { +union ba_param_set { u8 charData[2]; u16 shortData; struct { @@ -54,7 +54,7 @@ typedef union _BA_PARAM_SET { u16 TID:4; u16 BufferSize:10; } field; -} BA_PARAM_SET, *PBA_PARAM_SET; +}; typedef union _DELBA_PARAM_SET { u8 charData[2]; @@ -70,7 +70,7 @@ struct ba_record { struct timer_list Timer; u8 bValid; u8 DialogToken; - BA_PARAM_SET BaParamSet; + union ba_param_set BaParamSet; u16 BaTimeoutValue; union sequence_control BaStartSeqCtrl; }; diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 608ea2d7b4a..6a5d68664e6 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -241,7 +241,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) u16 rc = 0; u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; struct ba_record *pBA = NULL; - PBA_PARAM_SET pBaParamSet = NULL; + union ba_param_set *pBaParamSet = NULL; u16* pBaTimeoutVal = NULL; union sequence_control *pBaStartSeqCtrl = NULL; struct rx_ts_record *pTS = NULL; @@ -259,7 +259,7 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) dst = (u8*)(&req->addr2[0]); tag += sizeof( struct rtllib_hdr_3addr); pDialogToken = tag + 2; - pBaParamSet = (PBA_PARAM_SET)(tag + 3); + pBaParamSet = (union ba_param_set *)(tag + 3); pBaTimeoutVal = (u16*)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); @@ -332,7 +332,7 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) struct tx_ts_record *pTS = NULL; u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; - PBA_PARAM_SET pBaParamSet = NULL; + union ba_param_set *pBaParamSet = NULL; u16 ReasonCode; if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) @@ -346,7 +346,7 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) tag += sizeof( struct rtllib_hdr_3addr); pDialogToken = tag + 2; pStatusCode = (u16*)(tag + 3); - pBaParamSet = (PBA_PARAM_SET)(tag + 5); + pBaParamSet = (union ba_param_set *)(tag + 5); pBaTimeoutVal = (u16*)(tag + 7); RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); From f198db0c985ca627f9d068a00f6836c40ef4e737 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:17:01 -0500 Subject: [PATCH 0409/1519] staging: rtl8192e: Convert typedef DELBA_PARAM_SET to union delba_param_set Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_BAProc.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index 1e2cc2e344a..d2020b39018 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -56,7 +56,7 @@ union ba_param_set { } field; }; -typedef union _DELBA_PARAM_SET { +union delba_param_set { u8 charData[2]; u16 shortData; struct { @@ -64,7 +64,7 @@ typedef union _DELBA_PARAM_SET { u16 Initiator:1; u16 TID:4; } field; -} DELBA_PARAM_SET, *PDELBA_PARAM_SET; +}; struct ba_record { struct timer_list Timer; diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 6a5d68664e6..f82d577c37b 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -144,7 +144,7 @@ static struct sk_buff* rtllib_DELBA( u16 ReasonCode ) { - DELBA_PARAM_SET DelbaParamSet; + union delba_param_set DelbaParamSet; struct sk_buff *skb = NULL; struct rtllib_hdr_3addr* Delba = NULL; u8* tag = NULL; @@ -430,7 +430,7 @@ OnADDBARsp_Reject: int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) { struct rtllib_hdr_3addr* delba = NULL; - PDELBA_PARAM_SET pDelBaParamSet = NULL; + union delba_param_set *pDelBaParamSet = NULL; u16* pReasonCode = NULL; u8* dst = NULL; @@ -452,7 +452,7 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) delba = ( struct rtllib_hdr_3addr*)skb->data; dst = (u8*)(&delba->addr2[0]); delba += sizeof( struct rtllib_hdr_3addr); - pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2); + pDelBaParamSet = (union delba_param_set *)(delba+2); pReasonCode = (u16*)(delba+4); if (pDelBaParamSet->field.Initiator == 1) From 7d5693b2211b7d7639fce4d2edcb3c410e499554 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:19:43 -0500 Subject: [PATCH 0410/1519] staging: rtl8192e: Convert typedef HT_CAPABILITY to union ht_capability Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index f85415ff3f1..113ee98540a 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -81,7 +81,7 @@ typedef enum _CHNLOP{ ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false /* -typedef union _HT_CAPABILITY{ +union ht_capability { u16 ShortData; u8 CharData[2]; struct @@ -100,7 +100,7 @@ typedef union _HT_CAPABILITY{ u16 PSMP:1; u16 Rsvd:3; }Field; -}HT_CAPABILITY, *PHT_CAPABILITY; +}; typedef union _HT_CAPABILITY_MACPARA{ u8 ShortData; From a3e9909916abfdfe8863d8d67ab1ef49e3ded53c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:21:36 -0500 Subject: [PATCH 0411/1519] staging: rtl8192e: Convert typedef HT_CAPABILITY_MACPARA to union ht_capability_macpara Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 113ee98540a..eeee72ac1f5 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -102,7 +102,7 @@ union ht_capability { }Field; }; -typedef union _HT_CAPABILITY_MACPARA{ +union ht_capability_macpara { u8 ShortData; u8 CharData[1]; struct @@ -111,7 +111,7 @@ typedef union _HT_CAPABILITY_MACPARA{ u8 MPDUDensity:2; u8 Rsvd:4; }Field; -}HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA; +}; */ typedef enum _HT_ACTION{ From 42c53e7aaec108cf12431d6aca9ddac90b39d573 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:24:09 -0500 Subject: [PATCH 0412/1519] staging: rtl8192e: Convert typedef QOS_TSINFO to union qos_tsinfo Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 7 ++++--- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 1a85a9cb403..31f4d69ca21 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -54,7 +54,7 @@ #define BIT30 0x40000000 #define BIT31 0x80000000 -typedef union _QOS_TSINFO{ +union qos_tsinfo { u8 charData[3]; struct { u8 ucTrafficType:1; @@ -68,13 +68,14 @@ typedef union _QOS_TSINFO{ u8 ucSchedule:1; u8 ucReserved:7; }field; -}QOS_TSINFO, *PQOS_TSINFO; +}; + typedef union _TSPEC_BODY{ u8 charData[55]; struct { - QOS_TSINFO TSInfo; + union qos_tsinfo TSInfo; u16 NominalMSDUsize; u16 MaxMSDUsize; u32 MinServiceItv; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 172ee46087f..e1634055a4f 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -377,7 +377,7 @@ bool GetTs( else { TSPEC_BODY TSpec; - PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo; + union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; struct list_head* pUnusedList = (TxRxSelect == TX_DIR)? (&ieee->Tx_TS_Unused_List): From ed306e486d673a3ba4f9b0f2ab15afab0a6ba171 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:25:55 -0500 Subject: [PATCH 0413/1519] staging: rtl8192e: Convert typedef TSPEC_BODY to union tspec_body Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_TS.h | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 31f4d69ca21..be5400c99d7 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -70,7 +70,7 @@ union qos_tsinfo { }field; }; -typedef union _TSPEC_BODY{ +union tspec_body { u8 charData[55]; struct @@ -92,7 +92,7 @@ typedef union _TSPEC_BODY{ u16 SurplusBandwidthAllowance; u16 MediumTime; } f; -}TSPEC_BODY, *PTSPEC_BODY; +}; struct wmm_tspec { u8 ID; @@ -101,7 +101,7 @@ struct wmm_tspec { u8 OUI_Type; u8 OUI_SubType; u8 Version; - TSPEC_BODY Body; + union tspec_body Body; }; struct octet_string { diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 0baf888e545..b885f405c28 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -36,7 +36,7 @@ struct ts_common_info { struct timer_list SetupTimer; struct timer_list InactTimer; u8 Addr[6]; - TSPEC_BODY TSpec; + union tspec_body TSpec; QOS_TCLAS TClass[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index e1634055a4f..00dbc2e85f8 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -105,7 +105,7 @@ void TsAddBaProcess(unsigned long data) void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); - memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); + memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body)); memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; pTsCommonInfo->TClasNum = 0; @@ -293,7 +293,7 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, void MakeTSEntry( struct ts_common_info *pTsCommonInfo, u8* Addr, - PTSPEC_BODY pTSPEC, + union tspec_body *pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num, u8 TCLAS_Proc @@ -307,7 +307,7 @@ void MakeTSEntry( memcpy(pTsCommonInfo->Addr, Addr, 6); if (pTSPEC != NULL) - memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY)); + memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(union tspec_body)); for (count = 0; count < TCLAS_Num; count++) memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS)); @@ -376,7 +376,7 @@ bool GetTs( } else { - TSPEC_BODY TSpec; + union tspec_body TSpec; union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; struct list_head* pUnusedList = (TxRxSelect == TX_DIR)? From 626f951d76279823711fd0f9b876fafee39c3dec Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:27:46 -0500 Subject: [PATCH 0414/1519] staging: rtl8192e: Convert typedef QOS_TCLAS to union qos_tclas Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TS.h | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index be5400c99d7..e063ed812c9 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -251,7 +251,7 @@ typedef u8 AC_UAPSD, *PAC_UAPSD; #define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3) #define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3) -typedef union _QOS_TCLAS{ +union qos_tclas { struct _TYPE_GENERAL{ u8 Priority; @@ -300,7 +300,7 @@ typedef union _QOS_TCLAS{ u8 Mask; u16 TagType; } TYPE2_8021Q; -} QOS_TCLAS, *PQOS_TCLAS; +}; struct qos_tstream { diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index b885f405c28..279b1cc9a2d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -37,7 +37,7 @@ struct ts_common_info { struct timer_list InactTimer; u8 Addr[6]; union tspec_body TSpec; - QOS_TCLAS TClass[TCLAS_NUM]; + union qos_tclas TClass[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; }; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 00dbc2e85f8..7947e376e05 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -106,7 +106,7 @@ void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body)); - memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); + memset(&pTsCommonInfo->TClass, 0, sizeof(union qos_tclas)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; pTsCommonInfo->TClasNum = 0; } @@ -294,7 +294,7 @@ void MakeTSEntry( struct ts_common_info *pTsCommonInfo, u8* Addr, union tspec_body *pTSPEC, - PQOS_TCLAS pTCLAS, + union qos_tclas *pTCLAS, u8 TCLAS_Num, u8 TCLAS_Proc ) @@ -310,7 +310,7 @@ void MakeTSEntry( memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(union tspec_body)); for (count = 0; count < TCLAS_Num; count++) - memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS)); + memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(union qos_tclas)); pTsCommonInfo->TClasProc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; From 44a4004670a47135fa4dcc0473d3d28c8fb3e922 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:29:41 -0500 Subject: [PATCH 0415/1519] staging: rtl8192e: Convert typedef ACI_AIFSN to union aci_aifsn Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index d610de92b1d..0c06e7b8440 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -235,7 +235,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; u8 pAcParam = *((u8*)val); u32 eACI = pAcParam; - PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); + union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); u8 acm = pAciAifsn->f.acm; u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index e063ed812c9..af5c627941a 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -375,7 +375,7 @@ struct bss_qos { #define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false ) -typedef union _ACI_AIFSN{ +union aci_aifsn { u8 charData; struct @@ -385,7 +385,7 @@ typedef union _ACI_AIFSN{ u8 ACI:2; u8 Reserved:1; }f; -}ACI_AIFSN, *PACI_AIFSN; +}; typedef union _ECW{ u8 charData; @@ -402,7 +402,7 @@ typedef union _AC_PARAM{ struct { - ACI_AIFSN AciAifsn; + union aci_aifsn AciAifsn; ECW Ecw; u16 TXOPLimit; }f; From a33be1e842d6fef31cc5e88bc92541552a448286 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:31:43 -0500 Subject: [PATCH 0416/1519] staging: rtl8192e: Convert typedef ECW to union ecw Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index af5c627941a..1bf1016f77b 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -387,14 +387,14 @@ union aci_aifsn { }f; }; -typedef union _ECW{ +union ecw { u8 charData; struct { u8 ECWmin:4; u8 ECWmax:4; }f; -}ECW, *PECW; +}; typedef union _AC_PARAM{ u32 longData; @@ -403,7 +403,7 @@ typedef union _AC_PARAM{ struct { union aci_aifsn AciAifsn; - ECW Ecw; + union ecw Ecw; u16 TXOPLimit; }f; }AC_PARAM, *PAC_PARAM; From eb85e4689631ce116b74a87ce8929d07ba9b7601 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:35:19 -0500 Subject: [PATCH 0417/1519] staging: rtl8192e: Convert typedef AC_PARAM to union ac_param Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 1bf1016f77b..d4902d81d57 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -396,7 +396,7 @@ union ecw { }f; }; -typedef union _AC_PARAM{ +union ac_param { u32 longData; u8 charData[4]; @@ -406,10 +406,6 @@ typedef union _AC_PARAM{ union ecw Ecw; u16 TXOPLimit; }f; -}AC_PARAM, *PAC_PARAM; - - - - +}; #endif From 66ba443abf111ab8e8df86e6eb0fb8d87fd5dc21 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 10:37:34 -0500 Subject: [PATCH 0418/1519] staging: rtl8192e: Convert typedef frameqos to union frameqos Remove typedef from union. Rename union. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 08b6770dca6..aadaa951685 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1351,7 +1351,7 @@ struct rtllib_rxb { u8 src[ETH_ALEN]; }__attribute__((packed)); -typedef union _frameqos { +union frameqos { u16 shortdata; u8 chardata[2]; struct { @@ -1361,7 +1361,7 @@ typedef union _frameqos { u16 reserved:1; u16 txop:8; }field; -}frameqos,*pframeqos; +}; /* SWEEP TABLE ENTRIES NUMBER*/ #define MAX_SWEEP_TAB_ENTRIES 42 @@ -1511,7 +1511,7 @@ static inline u8 Frame_QoSTID(u8* buf) u16 fc; hdr = (struct rtllib_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((frameqos*)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 68f4aeed9e5..ee05d7685f9 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -748,7 +748,7 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, /* just for debug purpose */ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); if ((RTLLIB_QOS_HAS_SEQ(fc))&&\ - (((frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { + (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { bIsAggregateFrame = true; } From d3b2c172518dceed0d1d68f5b90dde5a2f6a438d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 12:50:41 -0500 Subject: [PATCH 0419/1519] staging: rtl8192e: Prepare header files to ease use of typedef enum conversion The tool that I am using fails for certain conditions. This patch makes trivial changes to the source to allow the tool to work for all cases. I also remove some artifacts left from the typedef struct conversion. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 30 ++++++------ drivers/staging/rtl8192e/r8192E_cmdpkt.h | 12 ++--- drivers/staging/rtl8192e/r8192E_firmware.h | 20 ++++---- drivers/staging/rtl8192e/r8192E_phy.h | 6 +-- drivers/staging/rtl8192e/rtl819x_HT.h | 40 ++++++++-------- drivers/staging/rtl8192e/rtl819x_Qos.h | 18 +++---- drivers/staging/rtl8192e/rtl_core.h | 30 ++++++------ drivers/staging/rtl8192e/rtl_debug.h | 4 +- drivers/staging/rtl8192e/rtl_dm.h | 55 +++++++++++----------- drivers/staging/rtl8192e/rtllib.h | 55 +++++++++++----------- 10 files changed, 136 insertions(+), 134 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 8fcb9ce1996..a1b49674d96 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -29,12 +29,12 @@ #define RX_CMD_QUEUE 1 -typedef enum _rtl819x_loopback{ +typedef enum _rtl819x_loopback_e{ RTL819X_NO_LOOPBACK = 0, RTL819X_MAC_LOOPBACK = 1, RTL819X_DMA_LOOPBACK = 2, RTL819X_CCK_LOOPBACK = 3, -}rtl819x_loopback_e; +} rtl819x_loopback_e; #define RESET_DELAY_8185 20 @@ -132,7 +132,7 @@ typedef enum _rtl819x_loopback{ typedef enum _VERSION_8190{ VERSION_8190_BD=0x3, VERSION_8190_BE -}VERSION_8190,*PVERSION_8190; +} VERSION_8190,*PVERSION_8190; #define IC_VersionCut_C 0x2 #define IC_VersionCut_D 0x3 @@ -143,14 +143,14 @@ typedef enum tag_Rf_OpType RF_OP_By_SW_3wire = 0, RF_OP_By_FW, RF_OP_MAX -}RF_OpType_E; +} RF_OpType_E; typedef enum _POWER_SAVE_MODE { POWER_SAVE_MODE_ACTIVE, POWER_SAVE_MODE_SAVE, -}POWER_SAVE_MODE; +} POWER_SAVE_MODE; typedef enum _INTERFACE_SELECT_8190PCI{ INTF_SEL1_MINICARD = 0, @@ -178,7 +178,7 @@ struct bb_reg_definition { u32 rfTxAFE; u32 rfLSSIReadBack; u32 rfLSSIReadBackPi; -};//, *struct bb_reg_definition *; +}; struct tx_fwinfo { u8 TxRate:7; @@ -205,7 +205,7 @@ struct tx_fwinfo { u32 TxAGCSign:1; u32 Tx_INFO_RSVD:6; u32 PacketID:13; -};//; +}; struct tx_fwinfo_8190pci { u8 TxRate:7; @@ -237,7 +237,7 @@ struct tx_fwinfo_8190pci { u32 PacketID:13; -};//, *struct tx_fwinfo_8190pci *; +}; #define TX_DESC_SIZE 32 @@ -276,7 +276,7 @@ struct phy_ofdm_rx_status_rxsc_sgien_exintfflag { u8 rxsc:2; u8 sgi_en:1; u8 ex_intf_flag:1; -};//; +}; struct phy_sts_ofdm_819xpci { u8 trsw_gain_X[4]; @@ -292,13 +292,13 @@ struct phy_sts_ofdm_819xpci { u8 max_ex_pwr; u8 sgi_en; u8 rxsc_sgien_exflg; -};//; +}; struct phy_sts_cck_819xpci { u8 adc_pwdb_X[4]; u8 sq_rpt; u8 cck_agc_rpt; -};//; +}; #define PHY_RSSI_SLID_WIN_MAX 100 @@ -340,7 +340,7 @@ struct tx_desc { u32 Reserved5; u32 Reserved6; u32 Reserved7; -};//, *ptx_desc; +}; struct tx_desc_cmd { @@ -364,7 +364,7 @@ struct tx_desc_cmd { u32 Reserved4; u32 Reserved5; u32 Reserved6; -};//, *ptx_desc_cmd; +}; struct rx_desc { u16 Length:14; @@ -385,7 +385,7 @@ struct rx_desc { u32 BufferAddress; -};//, *prx_desc; +}; struct rx_fwinfo { @@ -407,6 +407,6 @@ struct rx_fwinfo { u32 TSFL; -};//, *prx_fwinfo; +}; #endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 6fc37b66c29..97cc7b3be73 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -55,14 +55,14 @@ struct cmpk_txfb { u16 reserve3; /* */ u16 duration; /* */ -};//; +}; struct cmpk_intr_sta { u8 element_id; u8 length; u16 reserve; u32 interrupt_status; -};//; +}; struct cmpk_set_cfg { @@ -79,7 +79,7 @@ struct cmpk_set_cfg { u8 cfg_offset; u32 value; u32 mask; -};//; +}; #define cmpk_query_cfg_t struct cmpk_set_cfg @@ -118,7 +118,7 @@ struct cmpk_rx_dbginfo { u8 element_id; -};//; +}; struct cmpk_tx_rahis { u8 element_id; @@ -137,7 +137,7 @@ struct cmpk_tx_rahis { } __packed; -typedef enum tag_command_packet_directories +typedef enum _cmpk_element_e { RX_TX_FEEDBACK = 0, RX_INTERRUPT_STATUS = 1, @@ -148,7 +148,7 @@ typedef enum tag_command_packet_directories RX_TX_PER_PKT_FEEDBACK = 6, RX_TX_RATE_HISTORY = 7, RX_CMD_ELE_MAX -}cmpk_element_e; +} cmpk_element_e; extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index cb34b2bee19..64cc3627d1b 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -23,40 +23,40 @@ #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) -typedef enum _firmware_init_step{ +typedef enum _firmware_init_step_e{ FW_INIT_STEP0_BOOT = 0, FW_INIT_STEP1_MAIN = 1, FW_INIT_STEP2_DATA = 2, -}firmware_init_step_e; +} firmware_init_step_e; -typedef enum _opt_rst_type{ +typedef enum _opt_rst_type_e{ OPT_SYSTEM_RESET = 0, OPT_FIRMWARE_RESET = 1, -}opt_rst_type_e; +} opt_rst_type_e; typedef enum _desc_packet_type_e{ DESC_PACKET_TYPE_INIT = 0, DESC_PACKET_TYPE_NORMAL = 1, -}desc_packet_type_e; +} desc_packet_type_e; -typedef enum _firmware_source{ +typedef enum _firmware_source_e{ FW_SOURCE_IMG_FILE = 0, FW_SOURCE_HEADER_FILE = 1, -}firmware_source_e, *pfirmware_source_e; +} firmware_source_e, *pfirmware_source_e; -typedef enum _firmware_status{ +typedef enum _firmware_status_e{ FW_STATUS_0_INIT = 0, FW_STATUS_1_MOVE_BOOT_CODE = 1, FW_STATUS_2_MOVE_MAIN_CODE = 2, FW_STATUS_3_TURNON_CPU = 3, FW_STATUS_4_MOVE_DATA_CODE = 4, FW_STATUS_5_READY = 5, -}firmware_status_e; +} firmware_status_e; struct fw_seg_container { u16 seg_size; u8 *seg_ptr; -};//, *pfw_seg_container; +}; struct rt_firmware { firmware_status_e firmware_status; diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 8a9b4914085..29bf6c683a2 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -73,7 +73,7 @@ extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; -typedef enum _HW90_BLOCK { +typedef enum _HW90_BLOCK_E { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, HW90_BLOCK_PHY1 = 2, @@ -81,13 +81,13 @@ typedef enum _HW90_BLOCK { HW90_BLOCK_MAXIMUM = 4, } HW90_BLOCK_E, *PHW90_BLOCK_E; -typedef enum _RF90_RADIO_PATH{ +typedef enum _RF90_RADIO_PATH_E{ RF90_PATH_A = 0, RF90_PATH_B = 1, RF90_PATH_C = 2, RF90_PATH_D = 3, RF90_PATH_MAX -}RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; +} RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; #define bMaskByte0 0xff #define bMaskByte1 0xff00 diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index eeee72ac1f5..7a538723102 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -56,19 +56,19 @@ typedef enum _HT_MCS_RATE{ HT_MCS13 = 0x00002000, HT_MCS14 = 0x00004000, HT_MCS15 = 0x00008000, -}HT_MCS_RATE,*PHT_MCS_RATE; +} HT_MCS_RATE,*PHT_MCS_RATE; typedef enum _HT_CHANNEL_WIDTH{ HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_20_40 = 1, -}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; +} HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; typedef enum _HT_EXTCHNL_OFFSET{ HT_EXTCHNL_OFFSET_NO_EXT = 0, HT_EXTCHNL_OFFSET_UPPER = 1, HT_EXTCHNL_OFFSET_NO_DEF = 2, HT_EXTCHNL_OFFSET_LOWER = 3, -}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; +} HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; typedef enum _CHNLOP{ CHNLOP_NONE = 0, @@ -204,13 +204,13 @@ struct mimops_ctrl { typedef enum _HT_SPEC_VER{ HT_SPEC_VER_IEEE = 0, HT_SPEC_VER_EWC = 1, -}HT_SPEC_VER, *PHT_SPEC_VER; +} HT_SPEC_VER, *PHT_SPEC_VER; typedef enum _HT_AGGRE_MODE_E{ HT_AGG_AUTO = 0, HT_AGG_FORCE_ENABLE = 1, HT_AGG_FORCE_DISABLE = 2, -}HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; +} HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; struct rt_hi_throughput { @@ -327,7 +327,7 @@ struct rt_htinfo_sta_entry { u16 nAMSDU_MaxSize; -};//, *struct rt_htinfo_sta_entry *; +}; @@ -359,12 +359,12 @@ struct mimo_rssi { u32 AntennaC; u32 AntennaD; u32 Average; -};//, *struct mimo_rssi *; +}; struct mimo_evm { u32 EVM1; u32 EVM2; -};//, *struct mimo_evm *; +}; struct false_alarm_stats { u32 Cnt_Parity_Fail; @@ -374,7 +374,7 @@ struct false_alarm_stats { u32 Cnt_Ofdm_fail; u32 Cnt_Cck_fail; u32 Cnt_all; -};//, *struct false_alarm_stats *; +}; extern u8 MCS_FILTER_ALL[16]; @@ -397,14 +397,14 @@ extern u8 MCS_FILTER_1SS[16]; #define IS_11N_MCS_RATE(rate) (rate&0x80) -typedef enum _HT_AGGRE_SIZE{ +typedef enum _HT_AGGRE_SIZE_E{ HT_AGG_SIZE_8K = 0, HT_AGG_SIZE_16K = 1, HT_AGG_SIZE_32K = 2, HT_AGG_SIZE_64K = 3, -}HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E; +} HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E; -typedef enum _HT_IOT_PEER +typedef enum _HT_IOT_PEER_E { HT_IOT_PEER_UNKNOWN = 0, HT_IOT_PEER_REALTEK = 1, @@ -418,14 +418,14 @@ typedef enum _HT_IOT_PEER HT_IOT_PEER_SELF_SOFTAP = 9, HT_IOT_PEER_AIRGO = 10, HT_IOT_PEER_MAX = 11, -}HT_IOT_PEER_E, *PHTIOT_PEER_E; +} HT_IOT_PEER_E, *PHTIOT_PEER_E; -typedef enum _HT_IOT_PEER_SUBTYPE +typedef enum _HT_IOT_PEER_SUBTYPE_E { HT_IOT_PEER_ATHEROS_DIR635 = 0, -}HT_IOT_PEER_SUBTYPE_E, *PHTIOT_PEER_SUBTYPE_E; +} HT_IOT_PEER_SUBTYPE_E, *PHTIOT_PEER_SUBTYPE_E; -typedef enum _HT_IOT_ACTION{ +typedef enum _HT_IOT_ACTION_E{ HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001, HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002, HT_IOT_ACT_DISABLE_MCS14 = 0x00000004, @@ -458,21 +458,21 @@ typedef enum _HT_IOT_ACTION{ HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI = 0x08000000, -}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; +} HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; typedef enum _HT_IOT_RAFUNC{ HT_IOT_RAFUNC_DISABLE_ALL = 0x00, HT_IOT_RAFUNC_PEER_1R = 0x01, HT_IOT_RAFUNC_TX_AMSDU = 0x02, -}HT_IOT_RAFUNC, *PHT_IOT_RAFUNC; +} HT_IOT_RAFUNC, *PHT_IOT_RAFUNC; -typedef enum _RT_HT_CAP{ +typedef enum _RT_HT_CAPBILITY{ RT_HT_CAP_USE_TURBO_AGGR = 0x01, RT_HT_CAP_USE_LONG_PREAMBLE = 0x02, RT_HT_CAP_USE_AMPDU = 0x04, RT_HT_CAP_USE_WOW = 0x8, RT_HT_CAP_USE_SOFTAP = 0x10, RT_HT_CAP_USE_92SE = 0x20, -}RT_HT_CAPBILITY, *PRT_HT_CAPBILITY; +} RT_HT_CAPBILITY, *PRT_HT_CAPBILITY; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index d4902d81d57..1a8267d708d 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -107,7 +107,7 @@ struct wmm_tspec { struct octet_string { u8 *Octet; u16 Length; -};//, *struct octet_string *; +}; #define MAX_WMMELE_LENGTH 64 typedef u32 QOS_MODE, *PQOS_MODE; @@ -139,7 +139,7 @@ typedef u32 QOS_MODE, *PQOS_MODE; typedef enum _ACK_POLICY{ eAckPlc0_ACK = 0x00, eAckPlc1_NoACK = 0x01, -}ACK_POLICY,*PACK_POLICY; +} ACK_POLICY,*PACK_POLICY; #define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) @@ -165,7 +165,7 @@ typedef enum _ACK_POLICY{ #define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) #define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) -typedef enum { +typedef enum _QOSIE_SOURCE{ QOSIE_SRC_ADDTSREQ, QOSIE_SRC_ADDTSRSP, QOSIE_SRC_REASOCREQ, @@ -212,7 +212,7 @@ typedef u32 AC_CODING; typedef enum _QOS_ELE_SUBTYPE{ QOSELE_TYPE_INFO = 0x00, QOSELE_TYPE_PARAM = 0x01, -}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE; +} QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE; typedef enum _DIRECTION_VALUE{ @@ -220,20 +220,20 @@ typedef enum _DIRECTION_VALUE{ DIR_DOWN = 1, DIR_DIRECT = 2, DIR_BI_DIR = 3, -}DIRECTION_VALUE,*PDIRECTION_VALUE; +} DIRECTION_VALUE,*PDIRECTION_VALUE; typedef enum _ACM_METHOD{ eAcmWay0_SwAndHw = 0, eAcmWay1_HW = 1, eAcmWay2_SW = 2, -}ACM_METHOD,*PACM_METHOD; +} ACM_METHOD,*PACM_METHOD; struct acm { u64 UsedTime; u64 MediumTime; u8 HwAcmCtl; -};//, *struct acm *; +}; @@ -343,7 +343,7 @@ struct sta_qos { bool bEnableRxImmBA; -};//, *struct sta_qos *; +}; #define QBSS_LOAD_SIZE 5 #define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) @@ -366,7 +366,7 @@ struct bss_qos { u8 QBssLoad[QBSS_LOAD_SIZE]; bool bQBssLoadValid; -};//, *struct bss_qos *; +}; #define sQoSCtlLng 2 #define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 1038ed85562..16fbb933c76 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -240,7 +240,7 @@ enum RTL_DEBUG { COMP_ERR = BIT31 }; -typedef enum{ +typedef enum _nic_t{ NIC_UNKNOWN = 0, NIC_8192E = 1, NIC_8190P = 2, @@ -255,9 +255,9 @@ typedef enum _RT_EEPROM_TYPE{ EEPROM_93C46, EEPROM_93C56, EEPROM_BOOT_EFUSE, -}RT_EEPROM_TYPE,*PRT_EEPROM_TYPE; +} RT_EEPROM_TYPE,*PRT_EEPROM_TYPE; -typedef enum _tag_TxCmd_Config_Index{ +typedef enum _DCMD_TXCMD_OP{ TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, @@ -265,7 +265,7 @@ typedef enum _tag_TxCmd_Config_Index{ TXCMD_SET_RX_RSSI = 0xFF900004, TXCMD_SET_TX_PWR_TRACKING = 0xFF900005, TXCMD_XXXX_CTRL, -}DCMD_TXCMD_OP; +} DCMD_TXCMD_OP; typedef enum _RT_RF_TYPE_819xU{ RF_TYPE_MIN = 0, @@ -274,21 +274,21 @@ typedef enum _RT_RF_TYPE_819xU{ RF_8258, RF_6052=4, RF_PSEUDO_11N = 5, -}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; +} RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; -typedef enum tag_Rf_Operatetion_State +typedef enum _RF_STEP_E { RF_STEP_INIT = 0, RF_STEP_NORMAL, RF_STEP_MAX -}RF_STEP_E; +} RF_STEP_E; typedef enum _RT_STATUS{ RT_STATUS_SUCCESS, RT_STATUS_FAILURE, RT_STATUS_PENDING, RT_STATUS_RESOURCE -}RT_STATUS,*PRT_STATUS; +} RT_STATUS,*PRT_STATUS; typedef enum _RT_CUSTOMER_ID { @@ -322,7 +322,7 @@ typedef enum _RT_CUSTOMER_ID RT_CID_819x_Arcadyan_Belkin = 29, RT_CID_819x_SAMSUNG = 30, RT_CID_819x_WNC_COREGA = 31, -}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; +} RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; typedef enum _RESET_TYPE { RESET_TYPE_NORESET = 0x00, @@ -333,7 +333,7 @@ typedef enum _RESET_TYPE { typedef enum _IC_INFERIORITY_8192S{ IC_INFERIORITY_A = 0, IC_INFERIORITY_B = 1, -}IC_INFERIORITY_8192S, *PIC_INFERIORITY_8192S; +} IC_INFERIORITY_8192S, *PIC_INFERIORITY_8192S; typedef enum _PCI_BRIDGE_VENDOR { PCI_BRIDGE_VENDOR_INTEL = 0x0, @@ -360,20 +360,20 @@ struct rtl_reg_debug { unsigned char length; } head; unsigned char buf[0xff]; -};//; +}; struct rt_tx_rahis { u32 cck[4]; u32 ofdm[8]; u32 ht_mcs[4][16]; -};//, *prt_tx_rahis_t; +}; struct rt_smooth_data_4rf { char elements[4][100]; u32 index; u32 TotalNum; u32 TotalVal[4]; -};//, *struct rt_smooth_data_4rf *; +}; struct rt_stats { unsigned long txrdu; @@ -487,7 +487,7 @@ typedef enum _TWO_PORT_STATUS TWO_PORT_STATUS__DEFAULT_G_EXTENSION_N20, TWO_PORT_STATUS__ADHOC, TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE -}TWO_PORT_STATUS; +} TWO_PORT_STATUS; struct txbbgain_struct { long txbb_iq_amplifygain; @@ -1015,7 +1015,7 @@ struct r8192_priv { u8 H2CTxCmdSeq; -};//; +}; extern const struct ethtool_ops rtl819x_ethtool_ops; diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 1d4177ef131..2c32ece2e58 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -43,7 +43,7 @@ struct net_device; printk Fmt; \ } -typedef enum tag_DBGP_Flag_Type_Definition +typedef enum _DBGP_FLAG_E { FQoS = 0, FTX = 1, @@ -65,7 +65,7 @@ typedef enum tag_DBGP_Flag_Type_Definition FINIT = 17, FIOCTL = 18, DBGP_TYPE_MAX -}DBGP_FLAG_E; +} DBGP_FLAG_E; #define QoS_INIT BIT0 #define QoS_VISTA BIT1 diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index a9aa09f13f5..219e4af2b3d 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -125,25 +125,25 @@ struct dig_t { bool initialgain_lowerbound_state; long rssi_val; -};//; +}; -typedef enum tag_dynamic_init_gain_state_definition +typedef enum _dm_dig_sta_e { DM_STA_DIG_OFF = 0, DM_STA_DIG_ON, DM_STA_DIG_MAX -}dm_dig_sta_e; +} dm_dig_sta_e; -typedef enum tag_dynamic_ratr_state_definition +typedef enum _dm_ratr_sta_e { DM_RATR_STA_HIGH = 0, DM_RATR_STA_MIDDLE = 1, DM_RATR_STA_LOW = 2, DM_RATR_STA_MAX -}dm_ratr_sta_e; +} dm_ratr_sta_e; -typedef enum tag_dynamic_init_gain_operation_type_definition +typedef enum _dm_dig_op_e { DIG_TYPE_THRESH_HIGH = 0, DIG_TYPE_THRESH_LOW = 1, @@ -159,41 +159,41 @@ typedef enum tag_dynamic_init_gain_operation_type_definition DIG_TYPE_ENABLE = 20, DIG_TYPE_DISABLE = 30, DIG_OP_TYPE_MAX -}dm_dig_op_e; +} dm_dig_op_e; -typedef enum tag_dig_algorithm_definition +typedef enum _dm_dig_alg_e { DIG_ALGO_BY_FALSE_ALARM = 0, DIG_ALGO_BY_RSSI = 1, DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM = 2, DIG_ALGO_BY_TOW_PORT = 3, DIG_ALGO_MAX -}dm_dig_alg_e; +} dm_dig_alg_e; -typedef enum tag_DIG_TWO_PORT_ALGO_Definition +typedef enum _DM_DIG_TWO_PORT_ALG_E { DIG_TWO_PORT_ALGO_RSSI = 0, DIG_TWO_PORT_ALGO_FALSE_ALARM = 1, -}DM_DIG_TWO_PORT_ALG_E; +} DM_DIG_TWO_PORT_ALG_E; -typedef enum tag_DIG_EXT_PORT_ALGO_Definition +typedef enum _DM_DIG_EXT_PORT_ALG_E { DIG_EXT_PORT_STAGE_0 = 0, DIG_EXT_PORT_STAGE_1 = 1, DIG_EXT_PORT_STAGE_2 = 2, DIG_EXT_PORT_STAGE_3 = 3, DIG_EXT_PORT_STAGE_MAX = 4, -}DM_DIG_EXT_PORT_ALG_E; +} DM_DIG_EXT_PORT_ALG_E; -typedef enum tag_dig_dbgmode_definition +typedef enum _dm_dig_dbg_e { DIG_DBG_OFF = 0, DIG_DBG_ON = 1, DIG_DBG_MAX -}dm_dig_dbg_e; +} dm_dig_dbg_e; -typedef enum tag_dig_connect_definition +typedef enum _dm_dig_connect_e { DIG_STA_DISCONNECT = 0, DIG_STA_CONNECT = 1, @@ -202,22 +202,23 @@ typedef enum tag_dig_connect_definition DIG_AP_CONNECT = 4, DIG_AP_ADD_STATION = 5, DIG_CONNECT_MAX -}dm_dig_connect_e; +} dm_dig_connect_e; -typedef enum tag_dig_packetdetection_threshold_definition +typedef enum _dm_dig_pd_th_e { DIG_PD_AT_LOW_POWER = 0, DIG_PD_AT_NORMAL_POWER = 1, DIG_PD_AT_HIGH_POWER = 2, DIG_PD_MAX -}dm_dig_pd_th_e; +} dm_dig_pd_th_e; -typedef enum tag_dig_cck_cs_ratio_state_definition +typedef enum _dm_dig_cs_ratio_e { DIG_CS_RATIO_LOWER = 0, DIG_CS_RATIO_HIGHER = 1, DIG_CS_MAX -}dm_dig_cs_ratio_e; +} dm_dig_cs_ratio_e; + struct drx_path_sel { u8 Enable; u8 DbgMode; @@ -232,28 +233,28 @@ struct drx_path_sel { u8 rf_rssi[4]; u8 rf_enable_rssi_th[4]; long cck_pwdb_sta[4]; -};//; +}; -typedef enum tag_CCK_Rx_Path_Method_Definition +typedef enum _DM_CCK_Rx_Path_Method { CCK_Rx_Version_1 = 0, CCK_Rx_Version_2= 1, CCK_Rx_Version_MAX -}DM_CCK_Rx_Path_Method; +} DM_CCK_Rx_Path_Method; -typedef enum tag_DM_DbgMode_Definition +typedef enum _DM_DBG_E { DM_DBG_OFF = 0, DM_DBG_ON = 1, DM_DBG_MAX -}DM_DBG_E; +} DM_DBG_E; struct dcmd_txcmd { u32 Op; u32 Length; u32 Value; -};//, *struct dcmd_txcmd *; +}; /*------------------------------Define structure----------------------------*/ diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index aadaa951685..b5ee8e565a4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -200,7 +200,7 @@ struct cb_desc { u8 bBTTxPacket; u8 bIsBTProbRsp; -};//, *pcb_desc; +}; /*--------------------------Define -------------------------------------------*/ #define MGN_1M 0x02 @@ -309,7 +309,7 @@ typedef enum _HAL_DEF_VARIABLE{ HAL_DEF_PCI_SUPPORT_ASPM, HAL_DEF_THERMAL_VALUE, HAL_DEF_USB_IN_TOKEN_REV, -}HAL_DEF_VARIABLE; +} HAL_DEF_VARIABLE; typedef enum _HW_VARIABLES{ @@ -401,14 +401,14 @@ typedef enum _HW_VARIABLES{ HW_VAR_INT_MIGRATION, HW_VAR_INT_AC, HW_VAR_RF_TIMING, -}HW_VARIABLES; +} HW_VARIABLES; typedef enum _RT_OP_MODE{ RT_OP_MODE_AP, RT_OP_MODE_INFRASTRUCTURE, RT_OP_MODE_IBSS, RT_OP_MODE_NO_LINK, -}RT_OP_MODE, *PRT_OP_MODE; +} RT_OP_MODE, *PRT_OP_MODE; #define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) @@ -482,7 +482,7 @@ struct ieee_param { u8 key[0]; } crypt; } u; -};//; +}; #if WIRELESS_EXT < 17 @@ -619,7 +619,8 @@ typedef enum _InitialGainOpType{ IG_Backup=0, IG_Restore, IG_Max -}InitialGainOpType; +} InitialGainOpType; + typedef enum _LED_CTL_MODE{ LED_CTL_POWER_ON = 1, LED_CTL_LINK = 2, @@ -634,7 +635,7 @@ typedef enum _LED_CTL_MODE{ LED_CTL_START_WPS_BOTTON = 11, LED_CTL_STOP_WPS_FAIL = 12, LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, -}LED_CTL_MODE; +} LED_CTL_MODE; typedef enum _RT_RF_TYPE_DEF { @@ -644,7 +645,7 @@ typedef enum _RT_RF_TYPE_DEF RF_1T1R, RF_2T2R_GREEN, RF_819X_MAX_TYPE -}RT_RF_TYPE_DEF; +} RT_RF_TYPE_DEF; typedef enum _WIRELESS_MODE { WIRELESS_MODE_UNKNOWN = 0x00, @@ -656,7 +657,7 @@ typedef enum _WIRELESS_MODE { WIRELESS_MODE_N_5G = 0x20 } WIRELESS_MODE; -typedef enum _NETWORK_TYPE{ +typedef enum _WIRELESS_NETWORK_TYPE{ WIRELESS_11B = 1, WIRELESS_11G = 2, WIRELESS_11A = 4, @@ -1775,14 +1776,14 @@ enum rtllib_state { struct tx_pending { int frag; struct rtllib_txb *txb; -};//; +}; struct bandwidth_autoswitch { long threshold_20Mhzto40Mhz; long threshold_40Mhzto20Mhz; bool bforced_tx20Mhz; bool bautoswitch_enable; -};//,*pbandwidth_autoswitch; +}; @@ -1797,7 +1798,7 @@ typedef enum _Fsync_State{ Default_Fsync, HW_Fsync, SW_Fsync -}Fsync_State; +} Fsync_State; typedef enum _RT_PS_MODE { @@ -1805,25 +1806,25 @@ typedef enum _RT_PS_MODE eMaxPs, eFastPs, eAutoPs, -}RT_PS_MODE; +} RT_PS_MODE; typedef enum _IPS_CALLBACK_FUNCION { IPS_CALLBACK_NONE = 0, IPS_CALLBACK_MGNT_LINK_REQUEST = 1, IPS_CALLBACK_JOIN_REQUEST = 2, -}IPS_CALLBACK_FUNCION; +} IPS_CALLBACK_FUNCION; typedef enum _RT_JOIN_ACTION{ RT_JOIN_INFRA = 1, RT_JOIN_IBSS = 2, RT_START_IBSS = 3, RT_NO_ACTION = 4, -}RT_JOIN_ACTION; +} RT_JOIN_ACTION; struct ibss_parms { u16 atimWin; -};//, *struct ibss_parms *; +}; #define MAX_NUM_RATES 264 typedef enum _RT_RF_POWER_STATE @@ -1831,7 +1832,7 @@ typedef enum _RT_RF_POWER_STATE eRfOn, eRfSleep, eRfOff -}RT_RF_POWER_STATE; +} RT_RF_POWER_STATE; #define MAX_SUPPORT_WOL_PATTERN_NUM 8 @@ -1845,7 +1846,7 @@ typedef enum _WOLPATTERN_TYPE eIPv4IPv6TCPSYN, eMACIDOnly, eNoDefined, -}WOLPATTERN_TYPE; +} WOLPATTERN_TYPE; struct rt_pm_wol_info { u32 PatternId; @@ -1853,7 +1854,7 @@ struct rt_pm_wol_info { u16 CrcRemainder; u8 WFMIndex; WOLPATTERN_TYPE PatternType; -};//, *struct rt_pm_wol_info *; +}; struct rt_pwr_save_ctrl { @@ -1912,7 +1913,7 @@ struct rt_pwr_save_ctrl { u8 oWLANMode; struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; -};//,*struct rt_pwr_save_ctrl *; +}; typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_SW BIT31 @@ -1921,7 +1922,7 @@ typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_IPS BIT28 #define RF_CHANGE_BY_INIT 0 -typedef enum +typedef enum _country_code_type_t { COUNTRY_CODE_FCC = 0, COUNTRY_CODE_IC = 1, @@ -1937,13 +1938,13 @@ typedef enum COUNTRY_CODE_WORLD_WIDE_13 = 11, COUNTRY_CODE_TELEC_NETGEAR = 12, COUNTRY_CODE_MAX -}country_code_type_t; +} country_code_type_t; typedef enum _SCAN_OPERATION_BACKUP_OPT{ SCAN_OPT_BACKUP=0, SCAN_OPT_RESTORE, SCAN_OPT_MAX -}SCAN_OPERATION_BACKUP_OPT; +} SCAN_OPERATION_BACKUP_OPT; typedef enum _FW_CMD_IO_TYPE{ FW_CMD_DIG_ENABLE = 0, @@ -1977,7 +1978,7 @@ typedef enum _FW_CMD_IO_TYPE{ FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28, FW_CMD_PAPE_CONTROL = 29, FW_CMD_CHAN_SET = 30, -}FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE; +} FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE; #define RT_MAX_LD_SLOT_NUM 10 struct rt_link_detect { @@ -2000,7 +2001,7 @@ struct rt_link_detect { u32 NumTxUnicastOkInPeriod; u32 LastNumTxUnicast; u32 LastNumRxUnicast; -};//, *struct rt_link_detect *; +}; struct sw_cam_table { @@ -2011,7 +2012,7 @@ struct sw_cam_table { u8 useDK; u8 key_index; -};//,*struct sw_cam_table *; +}; #define TOTAL_CAM_ENTRY 32 struct rate_adaptive { u8 rate_adaptive_disabled; @@ -2046,7 +2047,7 @@ typedef enum _RATR_TABLE_MODE_8192S{ RATR_INX_WIRELESS_B = 6, RATR_INX_WIRELESS_MC = 7, RATR_INX_WIRELESS_A = 8, -}RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S; +} RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S; #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { From 70f9f79c481d41f9a18b29aff9859534d6868d4c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 12:54:24 -0500 Subject: [PATCH 0420/1519] staging: rtl8192e: Convert typedef rtl819x_loopback_e to enum rtl819x_loopback Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index a1b49674d96..87d91e2cf2b 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -29,12 +29,12 @@ #define RX_CMD_QUEUE 1 -typedef enum _rtl819x_loopback_e{ +enum rtl819x_loopback { RTL819X_NO_LOOPBACK = 0, RTL819X_MAC_LOOPBACK = 1, RTL819X_DMA_LOOPBACK = 2, RTL819X_CCK_LOOPBACK = 3, -} rtl819x_loopback_e; +}; #define RESET_DELAY_8185 20 diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 16fbb933c76..31279a95ac8 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -601,7 +601,7 @@ struct r8192_priv { ACM_METHOD AcmMethod; struct rt_firmware *pFirmware; - rtl819x_loopback_e LoopbackMode; + enum rtl819x_loopback LoopbackMode; firmware_source_e firmware_source; struct timer_list watch_dog_timer; From 1238aa49ef9d4898f1e8d1208191eeb23790eeb2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 12:56:14 -0500 Subject: [PATCH 0421/1519] staging: rtl8192e: Convert typedef VERSION_8190 to enum version_8190_loopback Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 87d91e2cf2b..d742f85ee85 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -129,10 +129,10 @@ enum rtl819x_loopback { #define HAL_PRIME_CHNL_OFFSET_UPPER 2 -typedef enum _VERSION_8190{ +enum version_8190_loopback { VERSION_8190_BD=0x3, VERSION_8190_BE -} VERSION_8190,*PVERSION_8190; +}; #define IC_VersionCut_C 0x2 #define IC_VersionCut_D 0x3 From 0ad0141d18d5215d4f6f267bf33ff43f7d568212 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:03:47 -0500 Subject: [PATCH 0422/1519] staging: rtl8192e: Convert typedef RF_OpType_E to enum rf_optype Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index d742f85ee85..72d4e0e5757 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -138,12 +138,11 @@ enum version_8190_loopback { #define IC_VersionCut_D 0x3 #define IC_VersionCut_E 0x4 -typedef enum tag_Rf_OpType -{ +enum rf_optype { RF_OP_By_SW_3wire = 0, RF_OP_By_FW, RF_OP_MAX -} RF_OpType_E; +}; typedef enum _POWER_SAVE_MODE From 12f5bc97f4c195c3ec013ca87a26a6f10fcc8932 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:05:16 -0500 Subject: [PATCH 0423/1519] staging: rtl8192e: Convert typedef POWER_SAVE_MODE to enum power_save_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 72d4e0e5757..1b6721f763b 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -145,11 +145,10 @@ enum rf_optype { }; -typedef enum _POWER_SAVE_MODE -{ +enum power_save_mode { POWER_SAVE_MODE_ACTIVE, POWER_SAVE_MODE_SAVE, -} POWER_SAVE_MODE; +}; typedef enum _INTERFACE_SELECT_8190PCI{ INTF_SEL1_MINICARD = 0, From 97844d156299726500e1d28ea85d897f700780d8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:07:19 -0500 Subject: [PATCH 0424/1519] staging: rtl8192e: Convert typedef INTERFACE_SELECT_8190PCI to enum interface_select_8190pci Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 1b6721f763b..2355766bb32 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -150,12 +150,12 @@ enum power_save_mode { POWER_SAVE_MODE_SAVE, }; -typedef enum _INTERFACE_SELECT_8190PCI{ +enum interface_select_8190pci { INTF_SEL1_MINICARD = 0, INTF_SEL0_PCIE = 1, INTF_SEL2_RSV = 2, INTF_SEL3_RSV = 3, -} INTERFACE_SELECT_8190PCI, *PINTERFACE_SELECT_8190PCI; +}; struct bb_reg_definition { u32 rfintfs; From 8fa81ed4c99eadf09c112187e9275aacd0ae1836 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:09:50 -0500 Subject: [PATCH 0425/1519] staging: rtl8192e: Convert typedef cmpk_element_e to enum cmpk_element Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index 97cc7b3be73..b55d075d6cd 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -137,8 +137,7 @@ struct cmpk_tx_rahis { } __packed; -typedef enum _cmpk_element_e -{ +enum cmpk_element { RX_TX_FEEDBACK = 0, RX_INTERRUPT_STATUS = 1, TX_SET_CONFIG = 2, @@ -148,7 +147,7 @@ typedef enum _cmpk_element_e RX_TX_PER_PKT_FEEDBACK = 6, RX_TX_RATE_HISTORY = 7, RX_CMD_ELE_MAX -} cmpk_element_e; +}; extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); From cec076954213e2fa72991512d557fb37376055c0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:11:41 -0500 Subject: [PATCH 0426/1519] staging: rtl8192e: Convert typedef firmware_init_step_e to enum firmware_init_step Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.c | 2 +- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 7d204219408..125d66e1914 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -267,7 +267,7 @@ bool init_firmware(struct net_device *dev) u8 *mapped_file = NULL; u8 init_step = 0; opt_rst_type_e rst_opt = OPT_SYSTEM_RESET; - firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT; + enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT; struct rt_firmware *pfirmware = priv->pFirmware; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 64cc3627d1b..52b1f342fde 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -23,11 +23,11 @@ #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) -typedef enum _firmware_init_step_e{ +enum firmware_init_step { FW_INIT_STEP0_BOOT = 0, FW_INIT_STEP1_MAIN = 1, FW_INIT_STEP2_DATA = 2, -} firmware_init_step_e; +}; typedef enum _opt_rst_type_e{ OPT_SYSTEM_RESET = 0, From 6bf04003c79665119b5bc14aef58e205d3567da1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:13:24 -0500 Subject: [PATCH 0427/1519] staging: rtl8192e: Convert typedef opt_rst_type_e to enum opt_rst_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.c | 2 +- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index 125d66e1914..d284d422b64 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -266,7 +266,7 @@ bool init_firmware(struct net_device *dev) u32 file_length = 0; u8 *mapped_file = NULL; u8 init_step = 0; - opt_rst_type_e rst_opt = OPT_SYSTEM_RESET; + enum opt_rst_type rst_opt = OPT_SYSTEM_RESET; enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT; struct rt_firmware *pfirmware = priv->pFirmware; diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 52b1f342fde..019a5a281f2 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -29,10 +29,10 @@ enum firmware_init_step { FW_INIT_STEP2_DATA = 2, }; -typedef enum _opt_rst_type_e{ +enum opt_rst_type { OPT_SYSTEM_RESET = 0, OPT_FIRMWARE_RESET = 1, -} opt_rst_type_e; +}; typedef enum _desc_packet_type_e{ DESC_PACKET_TYPE_INIT = 0, From 8ce50cf33a6b67843f57f01da3f3c35421310911 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:33:44 -0500 Subject: [PATCH 0428/1519] staging: rtl8192e: Convert typedef desc_packet_type_e to enum desc_packet_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 019a5a281f2..98ac58bdef2 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -34,10 +34,10 @@ enum opt_rst_type { OPT_FIRMWARE_RESET = 1, }; -typedef enum _desc_packet_type_e{ +enum desc_packet_type { DESC_PACKET_TYPE_INIT = 0, DESC_PACKET_TYPE_NORMAL = 1, -} desc_packet_type_e; +}; typedef enum _firmware_source_e{ FW_SOURCE_IMG_FILE = 0, From 9659e7f527b4e7b768e1f256bc048b676ee42266 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 13:36:21 -0500 Subject: [PATCH 0429/1519] staging: rtl8192e: Convert typedef firmware_source_e to enum firmware_source Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.h | 4 ++-- drivers/staging/rtl8192e/rtl_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 98ac58bdef2..803eff58f39 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -39,10 +39,10 @@ enum desc_packet_type { DESC_PACKET_TYPE_NORMAL = 1, }; -typedef enum _firmware_source_e{ +enum firmware_source { FW_SOURCE_IMG_FILE = 0, FW_SOURCE_HEADER_FILE = 1, -} firmware_source_e, *pfirmware_source_e; +}; typedef enum _firmware_status_e{ FW_STATUS_0_INIT = 0, diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 31279a95ac8..f12fe4cd293 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -602,7 +602,7 @@ struct r8192_priv { struct rt_firmware *pFirmware; enum rtl819x_loopback LoopbackMode; - firmware_source_e firmware_source; + enum firmware_source firmware_source; struct timer_list watch_dog_timer; struct timer_list fsync_timer; From d4b8c17703418c376b025bc6d45a58a9429330d6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 17:28:55 -0500 Subject: [PATCH 0430/1519] staging: rtl8192e: Convert typedef firmware_status_e to enum firmware_status Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_firmware.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index 803eff58f39..c7d4c994a29 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -44,14 +44,14 @@ enum firmware_source { FW_SOURCE_HEADER_FILE = 1, }; -typedef enum _firmware_status_e{ +enum firmware_status { FW_STATUS_0_INIT = 0, FW_STATUS_1_MOVE_BOOT_CODE = 1, FW_STATUS_2_MOVE_MAIN_CODE = 2, FW_STATUS_3_TURNON_CPU = 3, FW_STATUS_4_MOVE_DATA_CODE = 4, FW_STATUS_5_READY = 5, -} firmware_status_e; +}; struct fw_seg_container { u16 seg_size; @@ -59,7 +59,7 @@ struct fw_seg_container { }; struct rt_firmware { - firmware_status_e firmware_status; + enum firmware_status firmware_status; u16 cmdpacket_frag_thresold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 #define MAX_FW_INIT_STEP 3 From 800119e7fa1fd3f9df3396e99aa5d4bba8e24f03 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:10:40 -0500 Subject: [PATCH 0431/1519] staging: rtl8192e: Convert typedef BaseBand_Config_Type to enum baseband_config Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_hw.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index ec1e746e13f..9a3c4084faf 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -21,10 +21,10 @@ #ifndef R8180_HW #define R8180_HW -typedef enum _BaseBand_Config_Type { +enum baseband_config { BaseBand_Config_PHY_REG = 0, BaseBand_Config_AGC_TAB = 1, -} BaseBand_Config_Type, *PBaseBand_Config_Type; +}; #define RTL8187_REQT_READ 0xc0 #define RTL8187_REQT_WRITE 0x40 From e75c3c4a8c53f3ee72e5a696f9792a341744128d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:12:15 -0500 Subject: [PATCH 0432/1519] staging: rtl8192e: Convert typedef SwChnlCmdID to enum sw_chnl_cmd_id Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/r8192E_phy.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 517eab38b96..1717ca31dd0 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -827,7 +827,7 @@ u8 rtl8192_phy_SetSwChnlCmdArray( struct sw_chnl_cmd* CmdTable, u32 CmdTableIdx, u32 CmdTableSz, - SwChnlCmdID CmdID, + enum sw_chnl_cmd_id CmdID, u32 Para1, u32 Para2, u32 msDelay diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 29bf6c683a2..e214ee7b140 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -47,7 +47,7 @@ -typedef enum _SwChnlCmdID { +enum sw_chnl_cmd_id { CmdID_End, CmdID_SetTxPowerLevel, CmdID_BBRegWrite10, @@ -55,11 +55,11 @@ typedef enum _SwChnlCmdID { CmdID_WritePortUshort, CmdID_WritePortUchar, CmdID_RF_WriteReg, -} SwChnlCmdID; +}; /*--------------------------------Define structure--------------------------------*/ struct sw_chnl_cmd { - SwChnlCmdID CmdID; + enum sw_chnl_cmd_id CmdID; u32 Para1; u32 Para2; u32 msDelay; From afa087ddd80ff5d1ebc0080de18935be723ff3b7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:13:46 -0500 Subject: [PATCH 0433/1519] staging: rtl8192e: Convert typedef HW90_BLOCK_E to enum hw90_block Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 6 +++--- drivers/staging/rtl8192e/r8192E_phy.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 1717ca31dd0..0a64658abd5 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -510,7 +510,7 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } -bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath) +bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, RF90_RADIO_PATH_E eRFPath) { bool ret = true; u32 i, CheckTimes = 4, dwRegRead = 0; @@ -576,9 +576,9 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) dwRegValue = read_nic_dword(dev, CPU_GEN); write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); - for (eCheckItem=(HW90_BLOCK_E)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) + for (eCheckItem=(enum hw90_block)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) { - rtStatus = rtl8192_phy_checkBBAndRF(dev, (HW90_BLOCK_E)eCheckItem, (RF90_RADIO_PATH_E)0); + rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (RF90_RADIO_PATH_E)0); if (rtStatus != true) { RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index e214ee7b140..9f5560b8c1f 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -73,13 +73,13 @@ extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; -typedef enum _HW90_BLOCK_E { +enum hw90_block { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, HW90_BLOCK_PHY1 = 2, HW90_BLOCK_RF = 3, HW90_BLOCK_MAXIMUM = 4, -} HW90_BLOCK_E, *PHW90_BLOCK_E; +}; typedef enum _RF90_RADIO_PATH_E{ RF90_PATH_A = 0, @@ -104,7 +104,7 @@ extern void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPa extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask); extern void rtl8192_phy_configmac(struct net_device* dev); extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); -extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); +extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, RF90_RADIO_PATH_E eRFPath); extern bool rtl8192_BBConfig(struct net_device* dev); extern void rtl8192_phy_getTxPower(struct net_device* dev); extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); From 43602f2c505d951879a54617c4121acf40d28ea7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:15:50 -0500 Subject: [PATCH 0434/1519] staging: rtl8192e: Convert typedef RF90_RADIO_PATH_E to enum rf90_radio_path Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_rtl8256.c | 34 +++++++++++------------ drivers/staging/rtl8192e/r8192E_phy.c | 24 ++++++++-------- drivers/staging/rtl8192e/r8192E_phy.h | 12 ++++---- drivers/staging/rtl8192e/rtl_debug.c | 8 +++--- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index da1cdb5da1c..08c913c0454 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -34,9 +34,9 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: if (priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x100); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3d7); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x021); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); @@ -45,9 +45,9 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) break; case HT_CHANNEL_WIDTH_20_40: if (priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3ff); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0e1); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x300); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3ff); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x0e1); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); @@ -87,7 +87,7 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; - for (eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; @@ -112,9 +112,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, bMask12Bits, 0xbf); - rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath); + rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path)eRFPath); if (rtStatus!= true) { RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; @@ -125,32 +125,32 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 0a64658abd5..8a48d5b37dd 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -47,8 +47,8 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { /*************************Define local function prototype**********************/ -static u32 phy_FwRFSerialRead(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset); -static void phy_FwRFSerialWrite(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset,u32 Data); +static u32 phy_FwRFSerialRead(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset); +static void phy_FwRFSerialWrite(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset,u32 Data); u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; @@ -99,7 +99,7 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) return (Ret); } -u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset) +u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; @@ -160,7 +160,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, } -void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data) +void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; @@ -218,7 +218,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath return; } -void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 Original_Value, BitShift, New_Value; @@ -258,7 +258,7 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 return; } -u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask) +u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask) { u32 Original_Value, Readback_Value, BitShift; struct r8192_priv *priv = rtllib_priv(dev); @@ -285,7 +285,7 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u3 static u32 phy_FwRFSerialRead( struct net_device* dev, - RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path eRFPath, u32 Offset ) { u32 retValue = 0; @@ -322,7 +322,7 @@ static u32 phy_FwRFSerialRead( static void phy_FwRFSerialWrite( struct net_device* dev, - RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path eRFPath, u32 Offset, u32 Data ) { @@ -510,7 +510,7 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } -bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, RF90_RADIO_PATH_E eRFPath) +bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath) { bool ret = true; u32 i, CheckTimes = 4, dwRegRead = 0; @@ -578,7 +578,7 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) for (eCheckItem=(enum hw90_block)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) { - rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (RF90_RADIO_PATH_E)0); + rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (enum rf90_radio_path)0); if (rtStatus != true) { RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); @@ -741,7 +741,7 @@ void rtl8192_phy_updateInitGain(struct net_device* dev) return; } -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath) +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath) { int i; @@ -969,7 +969,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u break; case CmdID_RF_WriteReg: for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); break; default: break; diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 9f5560b8c1f..60892ff39a8 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -81,13 +81,13 @@ enum hw90_block { HW90_BLOCK_MAXIMUM = 4, }; -typedef enum _RF90_RADIO_PATH_E{ +enum rf90_radio_path { RF90_PATH_A = 0, RF90_PATH_B = 1, RF90_PATH_C = 2, RF90_PATH_D = 3, RF90_PATH_MAX -} RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; +}; #define bMaskByte0 0xff #define bMaskByte1 0xff00 @@ -100,17 +100,17 @@ typedef enum _RF90_RADIO_PATH_E{ extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath); extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData); extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask); -extern void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask); +extern void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); +extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask); extern void rtl8192_phy_configmac(struct net_device* dev); extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); -extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, RF90_RADIO_PATH_E eRFPath); +extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath); extern bool rtl8192_BBConfig(struct net_device* dev); extern void rtl8192_phy_getTxPower(struct net_device* dev); extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); extern bool rtl8192_phy_RFConfig(struct net_device* dev); extern void rtl8192_phy_updateInitGain(struct net_device* dev); -extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath); +extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); extern void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 91b2daa523a..5c2d01c8b45 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -589,7 +589,7 @@ static int proc_get_reg_rf_a(char *page, char **start, len += snprintf(page + len, count - len, "\nD: %2x > ",n); for (i=0;i<4 && n<=max;n+=4,i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,n, bMaskDWord)); + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_A,n, bMaskDWord)); } len += snprintf(page + len, count - len,"\n"); *eof = 1; @@ -615,7 +615,7 @@ static int proc_get_reg_rf_b(char *page, char **start, len += snprintf(page + len, count - len, "\nD: %2x > ",n); for (i=0;i<4 && n<=max;n+=4,i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_B, n, bMaskDWord)); + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_B, n, bMaskDWord)); } len += snprintf(page + len, count - len,"\n"); *eof = 1; @@ -641,7 +641,7 @@ static int proc_get_reg_rf_c(char *page, char **start, len += snprintf(page + len, count - len, "\nD: %2x > ",n); for (i=0;i<4 && n<=max;n+=4,i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_C, n, bMaskDWord)); + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_C, n, bMaskDWord)); } len += snprintf(page + len, count - len,"\n"); *eof = 1; @@ -667,7 +667,7 @@ static int proc_get_reg_rf_d(char *page, char **start, len += snprintf(page + len, count - len, "\nD: %2x > ",n); for (i=0;i<4 && n<=max;n+=4,i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_D, n, bMaskDWord)); + "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_D, n, bMaskDWord)); } len += snprintf(page + len, count - len,"\n"); *eof = 1; From cc8abb261dc543b59930c60bc5bd1dbba3fdb70a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:17:06 -0500 Subject: [PATCH 0435/1519] staging: rtl8192e: Convert typedef HT_MCS_RATE to enum ht_mcs_rate Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 7a538723102..430d064b1e6 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -39,7 +39,7 @@ #define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP -typedef enum _HT_MCS_RATE{ +enum ht_mcs_rate { HT_MCS0 = 0x00000001, HT_MCS1 = 0x00000002, HT_MCS2 = 0x00000004, @@ -56,7 +56,7 @@ typedef enum _HT_MCS_RATE{ HT_MCS13 = 0x00002000, HT_MCS14 = 0x00004000, HT_MCS15 = 0x00008000, -} HT_MCS_RATE,*PHT_MCS_RATE; +}; typedef enum _HT_CHANNEL_WIDTH{ HT_CHANNEL_WIDTH_20 = 0, From 6e579119b104967e91e506de2c7ac7ec1ac4d213 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:20:30 -0500 Subject: [PATCH 0436/1519] staging: rtl8192e: Convert typedef HT_CHANNEL_WIDTH to enum ht_channel_width Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_rtl8256.c | 2 +- drivers/staging/rtl8192e/r8190P_rtl8256.h | 2 +- drivers/staging/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/r8192E_phy.h | 2 +- drivers/staging/rtl8192e/rtl819x_HT.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_HTProc.c | 6 +++--- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 6 +++--- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index 08c913c0454..e8bef59a798 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -22,7 +22,7 @@ #include "r8192E_phy.h" #include "r8190P_rtl8256.h" -void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) +void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth) { u8 eRFPath; struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h index 32d2822dcf5..00fe5a1bb7e 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -21,7 +21,7 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 -extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); +extern void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth); extern bool PHY_RF8256_Config(struct net_device* dev); extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel); diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 8a48d5b37dd..f93c7808213 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1264,7 +1264,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 60892ff39a8..9ba402ef9e8 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -113,7 +113,7 @@ extern void rtl8192_phy_updateInitGain(struct net_device* dev); extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 430d064b1e6..c8f7cf5f6e7 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -58,10 +58,10 @@ enum ht_mcs_rate { HT_MCS15 = 0x00008000, }; -typedef enum _HT_CHANNEL_WIDTH{ +enum ht_channel_width { HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_20_40 = 1, -} HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; +}; typedef enum _HT_EXTCHNL_OFFSET{ HT_EXTCHNL_OFFSET_NO_EXT = 0, @@ -344,7 +344,7 @@ struct bss_ht { u16 bdHTInfoLen; HT_SPEC_VER bdHTSpecVer; - HT_CHANNEL_WIDTH bdBandWidth; + enum ht_channel_width bdBandWidth; u8 bdRT2RTAggregation; u8 bdRT2RTLongSlotTime; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 10cce89b10e..2f6c223c79b 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -831,7 +831,7 @@ u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS return true; } -void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -861,7 +861,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); - HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); pHTInfo->bCurShortGI20MHz= @@ -1137,7 +1137,7 @@ u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) return false; } -void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index f12fe4cd293..46d8fb99e70 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -589,7 +589,7 @@ struct r8192_priv { RT_RF_TYPE_819xU rf_chip; IC_INFERIORITY_8192S IC_Class; - HT_CHANNEL_WIDTH CurrentChannelBW; + enum ht_channel_width CurrentChannelBW; struct bb_reg_definition PHYRegDef[4]; struct rate_adaptive rate_adaptive; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b5ee8e565a4..3890b088b75 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2095,7 +2095,7 @@ struct rtllib_device { unsigned long status; short hwscan_ch_bk; HT_EXTCHNL_OFFSET chan_offset_bk; - HT_CHANNEL_WIDTH bandwidth_bk; + enum ht_channel_width bandwidth_bk; u8 hwscan_sem_up; u8 CntAfterLink; @@ -2512,7 +2512,7 @@ struct rtllib_device { /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); short (*get_nic_desc_num)(struct net_device *dev, int queue_index); - void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); + void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); @@ -2884,7 +2884,7 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee, extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); -void HTSetConnectBwMode(struct rtllib_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index ee05d7685f9..24ad9713d0b 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2157,7 +2157,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->bssht.bdSupportHT = true; network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - network->bssht.bdBandWidth = (HT_CHANNEL_WIDTH)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); + network->bssht.bdBandWidth = (enum ht_channel_width)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); } else{ network->bssht.bdSupportHT = false; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index fc3dafc5079..bef454c32d3 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -318,7 +318,7 @@ void rtllib_wx_sync_scan_wq(void *data) struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); short chan; HT_EXTCHNL_OFFSET chan_offset=0; - HT_CHANNEL_WIDTH bandwidth=0; + enum ht_channel_width bandwidth=0; int b40M = 0; static int count = 0; @@ -351,7 +351,7 @@ void rtllib_wx_sync_scan_wq(void *data) if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; - bandwidth = (HT_CHANNEL_WIDTH)ieee->pHTInfo->bCurBW40MHz; + bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } From b678bd1ff579f9e6233911fe5ce5fce31c5242e0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:22:07 -0500 Subject: [PATCH 0437/1519] staging: rtl8192e: Convert typedef HT_EXTCHNL_OFFSET to enum ht_extchnl_offset Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/r8192E_phy.h | 2 +- drivers/staging/rtl8192e/rtl819x_HT.h | 6 +++--- drivers/staging/rtl8192e/rtl819x_HTProc.c | 6 +++--- drivers/staging/rtl8192e/rtllib.h | 6 +++--- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index f93c7808213..45073b34027 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1264,7 +1264,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 9ba402ef9e8..b0d1f7e6679 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -113,7 +113,7 @@ extern void rtl8192_phy_updateInitGain(struct net_device* dev); extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); +extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index c8f7cf5f6e7..459753fbe7c 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -63,12 +63,12 @@ enum ht_channel_width { HT_CHANNEL_WIDTH_20_40 = 1, }; -typedef enum _HT_EXTCHNL_OFFSET{ +enum ht_extchnl_offset { HT_EXTCHNL_OFFSET_NO_EXT = 0, HT_EXTCHNL_OFFSET_UPPER = 1, HT_EXTCHNL_OFFSET_NO_DEF = 2, HT_EXTCHNL_OFFSET_LOWER = 3, -} HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; +}; typedef enum _CHNLOP{ CHNLOP_NONE = 0, @@ -265,7 +265,7 @@ struct rt_hi_throughput { u8 SelfMimoPs; u8 PeerMimoPs; - HT_EXTCHNL_OFFSET CurSTAExtChnlOffset; + enum ht_extchnl_offset CurSTAExtChnlOffset; u8 bCurTxBW40MHz; u8 PeerBandwidth; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 2f6c223c79b..ed7a6b44591 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -831,7 +831,7 @@ u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS return true; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -861,7 +861,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); - HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); pHTInfo->bCurShortGI20MHz= @@ -1137,7 +1137,7 @@ u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) return false; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 3890b088b75..a1c96e63ba1 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2094,7 +2094,7 @@ struct rtllib_device { unsigned long status; short hwscan_ch_bk; - HT_EXTCHNL_OFFSET chan_offset_bk; + enum ht_extchnl_offset chan_offset_bk; enum ht_channel_width bandwidth_bk; u8 hwscan_sem_up; u8 CntAfterLink; @@ -2512,7 +2512,7 @@ struct rtllib_device { /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); short (*get_nic_desc_num)(struct net_device *dev, int queue_index); - void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); + void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); @@ -2884,7 +2884,7 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee, extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index bef454c32d3..e6702a14165 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -317,7 +317,7 @@ void rtllib_wx_sync_scan_wq(void *data) { struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); short chan; - HT_EXTCHNL_OFFSET chan_offset=0; + enum ht_extchnl_offset chan_offset=0; enum ht_channel_width bandwidth=0; int b40M = 0; static int count = 0; From c1c5d0741697637422197ee8926e856fbda091c4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:23:23 -0500 Subject: [PATCH 0438/1519] staging: rtl8192e: Convert typedef CHNLOP to enum chnl_op Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 459753fbe7c..0b48dc76c49 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -70,12 +70,12 @@ enum ht_extchnl_offset { HT_EXTCHNL_OFFSET_LOWER = 3, }; -typedef enum _CHNLOP{ +enum chnl_op { CHNLOP_NONE = 0, CHNLOP_SCAN = 1, CHNLOP_SWBW = 2, CHNLOP_SWCHNL = 3, -} CHNLOP, *PCHNLOP; +}; #define CHHLOP_IN_PROGRESS(_pHTInfo) \ ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false @@ -270,7 +270,7 @@ struct rt_hi_throughput { u8 PeerBandwidth; u8 bSwBwInProgress; - CHNLOP ChnlOp; + enum chnl_op ChnlOp; u8 SwBwStep; u8 bRegRT2RTAggregation; From c4e6d760d813e89b0efd99c7520d6331ba84565b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 18:24:28 -0500 Subject: [PATCH 0439/1519] staging: rtl8192e: Convert typedef HT_ACTION to enum ht_action Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 0b48dc76c49..f4cb7530825 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -114,7 +114,7 @@ union ht_capability_macpara { }; */ -typedef enum _HT_ACTION{ +enum ht_action { ACT_RECOMMAND_WIDTH = 0, ACT_MIMO_PWR_SAVE = 1, ACT_PSMP = 2, @@ -125,7 +125,7 @@ typedef enum _HT_ACTION{ ACT_MIMO_NOCOMPR_STEER = 7, ACT_MIMO_COMPR_STEER = 8, ACT_ANTENNA_SELECT = 9, -} HT_ACTION, *PHT_ACTION; +}; typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{ From 11b639c3e23d54be8e909a5d054678d3f2d883d8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:03:53 -0500 Subject: [PATCH 0440/1519] staging: rtl8192e: Convert typedef HT_BW40_SC_E to enum ht_bw40_sc Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index f4cb7530825..9f43a8a4fa0 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -128,12 +128,12 @@ enum ht_action { }; -typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{ +enum ht_bw40_sc { SC_MODE_DUPLICATE = 0, SC_MODE_LOWER = 1, SC_MODE_UPPER = 2, SC_MODE_FULL40MHZ = 3, -}HT_BW40_SC_E; +}; struct ht_capab_ele { From d2eff5c3bf87256817ad7e2495a4e9226dbec0e8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:05:23 -0500 Subject: [PATCH 0441/1519] staging: rtl8192e: Convert typedef HT_SPEC_VER to enum ht_spec_ver Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 9f43a8a4fa0..175c8184c8f 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -201,10 +201,10 @@ struct mimops_ctrl { u8 Reserved:6; }; -typedef enum _HT_SPEC_VER{ +enum ht_spec_ver { HT_SPEC_VER_IEEE = 0, HT_SPEC_VER_EWC = 1, -} HT_SPEC_VER, *PHT_SPEC_VER; +}; typedef enum _HT_AGGRE_MODE_E{ HT_AGG_AUTO = 0, @@ -229,7 +229,7 @@ struct rt_hi_throughput { u8 bRegSuppCCK; u8 bCurSuppCCK; - HT_SPEC_VER ePeerHTSpecVer; + enum ht_spec_ver ePeerHTSpecVer; struct ht_capab_ele SelfHTCap; @@ -343,7 +343,7 @@ struct bss_ht { u8 bdHTInfoBuf[32]; u16 bdHTInfoLen; - HT_SPEC_VER bdHTSpecVer; + enum ht_spec_ver bdHTSpecVer; enum ht_channel_width bdBandWidth; u8 bdRT2RTAggregation; From d1936afc52d81f84cb5f2b896094dbd9a0f40479 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:06:51 -0500 Subject: [PATCH 0442/1519] staging: rtl8192e: Convert typedef HT_AGGRE_MODE_E to enum ht_aggre_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 175c8184c8f..56c82fd2abb 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -206,11 +206,11 @@ enum ht_spec_ver { HT_SPEC_VER_EWC = 1, }; -typedef enum _HT_AGGRE_MODE_E{ +enum ht_aggre_mode { HT_AGG_AUTO = 0, HT_AGG_FORCE_ENABLE = 1, HT_AGG_FORCE_DISABLE = 2, -} HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; +}; struct rt_hi_throughput { @@ -251,11 +251,11 @@ struct rt_hi_throughput { u8 MPDU_Density; u8 CurrentMPDUDensity; - HT_AGGRE_MODE_E ForcedAMPDUMode; + enum ht_aggre_mode ForcedAMPDUMode; u8 ForcedAMPDUFactor; u8 ForcedMPDUDensity; - HT_AGGRE_MODE_E ForcedAMSDUMode; + enum ht_aggre_mode ForcedAMSDUMode; u16 ForcedAMSDUMaxSize; u8 bForcedShortGI; From a866534606836d509f3dbf6000352a19ad6f2f6e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:12:22 -0500 Subject: [PATCH 0443/1519] staging: rtl8192e: Convert typedef HT_IOT_PEER_E to enum ht_iot_peer Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 56c82fd2abb..1e9c49629ef 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -404,8 +404,7 @@ typedef enum _HT_AGGRE_SIZE_E{ HT_AGG_SIZE_64K = 3, } HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E; -typedef enum _HT_IOT_PEER_E -{ +enum ht_iot_peer { HT_IOT_PEER_UNKNOWN = 0, HT_IOT_PEER_REALTEK = 1, HT_IOT_PEER_REALTEK_92SE = 2, @@ -418,7 +417,7 @@ typedef enum _HT_IOT_PEER_E HT_IOT_PEER_SELF_SOFTAP = 9, HT_IOT_PEER_AIRGO = 10, HT_IOT_PEER_MAX = 11, -} HT_IOT_PEER_E, *PHTIOT_PEER_E; +}; typedef enum _HT_IOT_PEER_SUBTYPE_E { From dd8f8ba26223d2b0c28835ae390dcc2c77a8c8fe Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:16:30 -0500 Subject: [PATCH 0444/1519] staging: rtl8192e: Convert typedef HT_IOT_ACTION_E to enum ht_iot_action Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 1e9c49629ef..e74cb4f2b78 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -419,12 +419,11 @@ enum ht_iot_peer { HT_IOT_PEER_MAX = 11, }; -typedef enum _HT_IOT_PEER_SUBTYPE_E -{ +enum ht_iot_peer_subtype { HT_IOT_PEER_ATHEROS_DIR635 = 0, -} HT_IOT_PEER_SUBTYPE_E, *PHTIOT_PEER_SUBTYPE_E; +}; -typedef enum _HT_IOT_ACTION_E{ +enum ht_iot_action { HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001, HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002, HT_IOT_ACT_DISABLE_MCS14 = 0x00000004, @@ -457,7 +456,7 @@ typedef enum _HT_IOT_ACTION_E{ HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI = 0x08000000, -} HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; +}; typedef enum _HT_IOT_RAFUNC{ HT_IOT_RAFUNC_DISABLE_ALL = 0x00, From d745c1074aff818bc1263c05fd3a81adc40e5c9a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:18:03 -0500 Subject: [PATCH 0445/1519] staging: rtl8192e: Convert typedef HT_IOT_RAFUNC to enum ht_iot_rafunc Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index e74cb4f2b78..396e9ed2451 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -458,11 +458,11 @@ enum ht_iot_action { }; -typedef enum _HT_IOT_RAFUNC{ +enum ht_iot_rafunc { HT_IOT_RAFUNC_DISABLE_ALL = 0x00, HT_IOT_RAFUNC_PEER_1R = 0x01, HT_IOT_RAFUNC_TX_AMSDU = 0x02, -} HT_IOT_RAFUNC, *PHT_IOT_RAFUNC; +}; typedef enum _RT_HT_CAPBILITY{ RT_HT_CAP_USE_TURBO_AGGR = 0x01, From bb9a7b3f239c0a7ab9b05690b8fa7df8eba16dfe Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:22:37 -0500 Subject: [PATCH 0446/1519] staging: rtl8192e: Convert typedef RT_HT_CAPBILITY to enum rt_ht_capability Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 396e9ed2451..108b27cc95c 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -464,13 +464,13 @@ enum ht_iot_rafunc { HT_IOT_RAFUNC_TX_AMSDU = 0x02, }; -typedef enum _RT_HT_CAPBILITY{ +enum rt_ht_capability { RT_HT_CAP_USE_TURBO_AGGR = 0x01, RT_HT_CAP_USE_LONG_PREAMBLE = 0x02, RT_HT_CAP_USE_AMPDU = 0x04, RT_HT_CAP_USE_WOW = 0x8, RT_HT_CAP_USE_SOFTAP = 0x10, RT_HT_CAP_USE_92SE = 0x20, -} RT_HT_CAPBILITY, *PRT_HT_CAPBILITY; +}; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index ed7a6b44591..825b90805b4 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -977,7 +977,7 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; - pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; pHTInfo->IOTPeer = 0; pHTInfo->IOTAction = 0; @@ -1003,7 +1003,7 @@ void HTInitializeBssDesc(struct bss_ht *pBssHT) pBssHT->bdRT2RTAggregation = false; pBssHT->bdRT2RTLongSlotTime = false; - pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0; } void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) @@ -1034,7 +1034,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net { pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; - pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; } HTIOTPeerDetermine(ieee); @@ -1067,7 +1067,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net pHTInfo->bCurrentHTSupport = false; pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; - pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0; + pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; pHTInfo->IOTAction = 0; pHTInfo->IOTRaFunc = 0; From 4164e4de6c90e06dafe07d6390b591d886a0c080 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:24:06 -0500 Subject: [PATCH 0447/1519] staging: rtl8192e: Convert typedef ACK_POLICY to enum ack_policy Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 1a8267d708d..547baeab30e 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -136,10 +136,10 @@ typedef u32 QOS_MODE, *PQOS_MODE; #define ACM_TIMEOUT 1000 #define SESSION_REJECT_TIMEOUT 60000 -typedef enum _ACK_POLICY{ +enum ack_policy { eAckPlc0_ACK = 0x00, eAckPlc1_NoACK = 0x01, -} ACK_POLICY,*PACK_POLICY; +}; #define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) From f58a1cd97e727317ff316f7783592019606b4bc7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:27:05 -0500 Subject: [PATCH 0448/1519] staging: rtl8192e: Convert typedef QOS_ELE_SUBTYPE to enum qos_ele_subtype Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 547baeab30e..b4290c41c6e 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -165,13 +165,13 @@ enum ack_policy { #define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) #define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) -typedef enum _QOSIE_SOURCE{ +enum qos_ie_source { QOSIE_SRC_ADDTSREQ, QOSIE_SRC_ADDTSRSP, QOSIE_SRC_REASOCREQ, QOSIE_SRC_REASOCRSP, QOSIE_SRC_DELTS, -} QOSIE_SOURCE; +}; typedef u32 AC_CODING; @@ -209,10 +209,10 @@ typedef u32 AC_CODING; #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) -typedef enum _QOS_ELE_SUBTYPE{ +enum qos_ele_subtype { QOSELE_TYPE_INFO = 0x00, QOSELE_TYPE_PARAM = 0x01, -} QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE; +}; typedef enum _DIRECTION_VALUE{ @@ -359,7 +359,7 @@ struct bss_qos { u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; struct octet_string bdWMMIE; - QOS_ELE_SUBTYPE EleSubType; + enum qos_ele_subtype EleSubType; u8* pWMMInfoEle; u8* pWMMParamEle; From f12dfcb016044ec1c08bb8186255bfb58bbd84f4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:28:39 -0500 Subject: [PATCH 0449/1519] staging: rtl8192e: Convert typedef DIRECTION_VALUE to enum direction_value Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index b4290c41c6e..19f10e8cdae 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -215,12 +215,12 @@ enum qos_ele_subtype { }; -typedef enum _DIRECTION_VALUE{ +enum direction_value { DIR_UP = 0, DIR_DOWN = 1, DIR_DIRECT = 2, DIR_BI_DIR = 3, -} DIRECTION_VALUE,*PDIRECTION_VALUE; +}; typedef enum _ACM_METHOD{ eAcmWay0_SwAndHw = 0, diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 7947e376e05..6cec575d8d2 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -388,7 +388,7 @@ bool GetTs( (&ieee->Tx_TS_Admit_List): (&ieee->Rx_TS_Admit_List); - DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)? + enum direction_value Dir = (ieee->iw_mode == IW_MODE_MASTER)? ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); From 379a20fb29f9328d132cc1839192153149858940 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:30:04 -0500 Subject: [PATCH 0450/1519] staging: rtl8192e: Convert typedef ACM_METHOD to enum acm_method Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 6 +++--- drivers/staging/rtl8192e/rtl_core.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 19f10e8cdae..59ab0b87227 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -222,11 +222,11 @@ enum direction_value { DIR_BI_DIR = 3, }; -typedef enum _ACM_METHOD{ +enum acm_method { eAcmWay0_SwAndHw = 0, eAcmWay1_HW = 1, eAcmWay2_SW = 2, -} ACM_METHOD,*PACM_METHOD; +}; struct acm { @@ -331,7 +331,7 @@ struct sta_qos { u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; struct acm acm[4]; - ACM_METHOD AcmMethod; + enum acm_method AcmMethod; struct qos_tstream StaTsArray[MAX_STA_TS_COUNT]; u8 DialogToken; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 46d8fb99e70..3e046aa799d 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -598,7 +598,7 @@ struct r8192_priv { struct txbbgain_struct txbbgain_table[TxBBGainTableLength]; - ACM_METHOD AcmMethod; + enum acm_method AcmMethod; struct rt_firmware *pFirmware; enum rtl819x_loopback LoopbackMode; From 39b2a4aed05d872a713e2fdbe5cfa535c75a173e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:31:37 -0500 Subject: [PATCH 0451/1519] staging: rtl8192e: Convert typedef TR_SELECT to enum tr_select Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 6 +++--- drivers/staging/rtl8192e/rtl819x_TS.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TSProc.c | 6 +++--- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index f82d577c37b..aeb8a4b5d05 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -140,7 +140,7 @@ static struct sk_buff* rtllib_DELBA( struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, - TR_SELECT TxRxSelect, + enum tr_select TxRxSelect, u16 ReasonCode ) { @@ -220,7 +220,7 @@ void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, struct ba_record } -void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, TR_SELECT TxRxSelect, u16 ReasonCode) +void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, enum tr_select TxRxSelect, u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); @@ -527,7 +527,7 @@ TsInitAddBA( } void -TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, TR_SELECT TxRxSelect) +TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) { if (TxRxSelect == TX_DIR) diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 279b1cc9a2d..b4bebab3632 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -26,10 +26,10 @@ #define TOTAL_TS_NUM 16 #define TCLAS_NUM 4 -typedef enum _TR_SELECT { +enum tr_select { TX_DIR = 0, RX_DIR = 1, -} TR_SELECT, *PTR_SELECT; +}; struct ts_common_info { struct list_head List; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 6cec575d8d2..a6dbd26c691 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -219,7 +219,7 @@ void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, u } -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) +struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, enum tr_select TxRxSelect) { u8 dir; bool search_dir[4] = {0, 0, 0, 0}; @@ -321,7 +321,7 @@ bool GetTs( struct ts_common_info **ppTS, u8* Addr, u8 TID, - TR_SELECT TxRxSelect, + enum tr_select TxRxSelect, bool bAddNewTs) { u8 UP = 0; @@ -435,7 +435,7 @@ bool GetTs( void RemoveTsEntry( struct rtllib_device* ieee, struct ts_common_info *pTs, - TR_SELECT TxRxSelect + enum tr_select TxRxSelect ) { del_timer_sync(&pTs->SetupTimer); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index a1c96e63ba1..9dc15b8d6d3 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2907,7 +2907,7 @@ extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, TR_SELECT TxRxSelect); +extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); @@ -2917,7 +2917,7 @@ extern bool GetTs( struct ts_common_info **ppTS, u8* Addr, u8 TID, - TR_SELECT TxRxSelect, + enum tr_select TxRxSelect, bool bAddNewTs ); extern void TSInitialize(struct rtllib_device *ieee); From b55941afbf1aa02d38a9dff2700fdc9138b36121 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:33:00 -0500 Subject: [PATCH 0452/1519] staging: rtl8192e: Convert typedef nic_t to enum nic_t Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 3e046aa799d..3a876b5ac81 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -240,7 +240,7 @@ enum RTL_DEBUG { COMP_ERR = BIT31 }; -typedef enum _nic_t{ +enum nic_t { NIC_UNKNOWN = 0, NIC_8192E = 1, NIC_8190P = 2, @@ -249,7 +249,7 @@ typedef enum _nic_t{ NIC_8192CU = 6, NIC_8192DE = 7, NIC_8192DU = 8, - } nic_t; + }; typedef enum _RT_EEPROM_TYPE{ EEPROM_93C46, @@ -524,7 +524,7 @@ struct rtl8192_tx_ring { struct rtl819x_ops{ - nic_t nic_type; + enum nic_t nic_type; void (* get_eeprom_size)(struct net_device* dev); void (* init_adapter_variable)(struct net_device* dev); void (* init_before_adapter_start)(struct net_device* dev); @@ -698,7 +698,7 @@ struct r8192_priv { u32 irq_mask[2]; u8 Rf_Mode; - nic_t card_8192; + enum nic_t card_8192; u8 card_8192_version; short enable_gpio0; From e9463775edd1456c47fc8d4d726871ad50dffd14 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:34:33 -0500 Subject: [PATCH 0453/1519] staging: rtl8192e: Convert typedef RT_EEPROM_TYPE to enum rt_eeprom_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 3a876b5ac81..e9e32246fdd 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -251,11 +251,11 @@ enum nic_t { NIC_8192DU = 8, }; -typedef enum _RT_EEPROM_TYPE{ +enum rt_eeprom_type { EEPROM_93C46, EEPROM_93C56, EEPROM_BOOT_EFUSE, -} RT_EEPROM_TYPE,*PRT_EEPROM_TYPE; +}; typedef enum _DCMD_TXCMD_OP{ TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, From aec1148c5bf077502dbde23f4ea491adc81fa307 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:36:07 -0500 Subject: [PATCH 0454/1519] staging: rtl8192e: Convert typedef DCMD_TXCMD_OP to enum dcmg_txcmd_op Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index e9e32246fdd..4d6857cce21 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -257,7 +257,7 @@ enum rt_eeprom_type { EEPROM_BOOT_EFUSE, }; -typedef enum _DCMD_TXCMD_OP{ +enum dcmg_txcmd_op { TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, @@ -265,7 +265,7 @@ typedef enum _DCMD_TXCMD_OP{ TXCMD_SET_RX_RSSI = 0xFF900004, TXCMD_SET_TX_PWR_TRACKING = 0xFF900005, TXCMD_XXXX_CTRL, -} DCMD_TXCMD_OP; +}; typedef enum _RT_RF_TYPE_819xU{ RF_TYPE_MIN = 0, From fc6094f6703d16591dda4d2849b17c1751dbb099 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:37:46 -0500 Subject: [PATCH 0455/1519] staging: rtl8192e: Convert typedef RT_RF_TYPE_819xU to enum rt_rf_type_819xu Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 4d6857cce21..8a71d2dadb8 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -267,14 +267,14 @@ enum dcmg_txcmd_op { TXCMD_XXXX_CTRL, }; -typedef enum _RT_RF_TYPE_819xU{ +enum rt_rf_type_819xu { RF_TYPE_MIN = 0, RF_8225, RF_8256, RF_8258, RF_6052=4, RF_PSEUDO_11N = 5, -} RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; +}; typedef enum _RF_STEP_E { @@ -587,7 +587,7 @@ struct r8192_priv { RT_CUSTOMER_ID CustomerID; - RT_RF_TYPE_819xU rf_chip; + enum rt_rf_type_819xu rf_chip; IC_INFERIORITY_8192S IC_Class; enum ht_channel_width CurrentChannelBW; struct bb_reg_definition PHYRegDef[4]; From 6f44d2bdfc4ae223a18afc9ba264bdc0b172d194 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:39:12 -0500 Subject: [PATCH 0456/1519] staging: rtl8192e: Convert typedef RF_STEP_E to enum rf_step Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 8a71d2dadb8..107400eed27 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -276,12 +276,11 @@ enum rt_rf_type_819xu { RF_PSEUDO_11N = 5, }; -typedef enum _RF_STEP_E -{ +enum rf_step { RF_STEP_INIT = 0, RF_STEP_NORMAL, RF_STEP_MAX -} RF_STEP_E; +}; typedef enum _RT_STATUS{ RT_STATUS_SUCCESS, From 0fd44425863d355119b2469f49a66083c1f15cf6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:41:16 -0500 Subject: [PATCH 0457/1519] staging: rtl8192e: Convert typedef RT_STATUS to enum rt_status Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 107400eed27..d25de728e90 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -282,12 +282,12 @@ enum rf_step { RF_STEP_MAX }; -typedef enum _RT_STATUS{ +enum rt_status { RT_STATUS_SUCCESS, RT_STATUS_FAILURE, RT_STATUS_PENDING, RT_STATUS_RESOURCE -} RT_STATUS,*PRT_STATUS; +}; typedef enum _RT_CUSTOMER_ID { From ed8eac2f92932cf8e02f98950224c673eceb9b4f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:42:55 -0500 Subject: [PATCH 0458/1519] staging: rtl8192e: Convert typedef RT_CUSTOMER_ID to enum rt_customer_id Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d25de728e90..d8bd8187554 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -289,8 +289,7 @@ enum rt_status { RT_STATUS_RESOURCE }; -typedef enum _RT_CUSTOMER_ID -{ +enum rt_customer_id { RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, RT_CID_8187_SERCOMM_PS = 2, @@ -321,7 +320,7 @@ typedef enum _RT_CUSTOMER_ID RT_CID_819x_Arcadyan_Belkin = 29, RT_CID_819x_SAMSUNG = 30, RT_CID_819x_WNC_COREGA = 31, -} RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; +}; typedef enum _RESET_TYPE { RESET_TYPE_NORESET = 0x00, @@ -583,7 +582,7 @@ struct r8192_priv { struct log_int_8190 InterruptLog; - RT_CUSTOMER_ID CustomerID; + enum rt_customer_id CustomerID; enum rt_rf_type_819xu rf_chip; From ab0d7ccaf733d064bd8e0f1d1a0eb67be79232ee Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:49:51 -0500 Subject: [PATCH 0459/1519] staging: rtl8192e: Convert typedef RESET_TYPE to enum reset_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 12 ++++++------ drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index ce649a560a3..3066fc80f66 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1416,7 +1416,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev) return 1; } -RESET_TYPE +enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1476,7 +1476,7 @@ rtl819x_TxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -RESET_TYPE rtl819x_RxCheckStuck(struct net_device *dev) +enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1489,12 +1489,12 @@ RESET_TYPE rtl819x_RxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -RESET_TYPE +enum reset_type rtl819x_ifcheck_resetornot(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - RESET_TYPE TxResetType = RESET_TYPE_NORESET; - RESET_TYPE RxResetType = RESET_TYPE_NORESET; + enum reset_type TxResetType = RESET_TYPE_NORESET; + enum reset_type RxResetType = RESET_TYPE_NORESET; RT_RF_POWER_STATE rfState; rfState = priv->rtllib->eRFPowerState; @@ -1678,7 +1678,7 @@ void rtl819x_watchdog_wqcallback(void *data) struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->rtllib->dev; struct rtllib_device* ieee = priv->rtllib; - RESET_TYPE ResetType = RESET_TYPE_NORESET; + enum reset_type ResetType = RESET_TYPE_NORESET; static u8 check_reset_cnt = 0; unsigned long flags; struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d8bd8187554..b3bba7dae20 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -322,11 +322,11 @@ enum rt_customer_id { RT_CID_819x_WNC_COREGA = 31, }; -typedef enum _RESET_TYPE { +enum reset_type { RESET_TYPE_NORESET = 0x00, RESET_TYPE_NORMAL = 0x01, RESET_TYPE_SILENT = 0x02 -} RESET_TYPE; +}; typedef enum _IC_INFERIORITY_8192S{ IC_INFERIORITY_A = 0, @@ -978,7 +978,7 @@ struct r8192_priv { u32 ccktxpower_adjustcnt_not_ch14; u32 ccktxpower_adjustcnt_ch14; - RESET_TYPE ResetProgress; + enum reset_type ResetProgress; bool bForcedSilentReset; bool bDisableNormalResetCheck; u16 TxCounter; From 456419dbb389498042ea2808600d25b67f687716 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:52:21 -0500 Subject: [PATCH 0460/1519] staging: rtl8192e: Convert typedef IC_INFERIORITY_8192S to enum ic_inferiority_8192s Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index b3bba7dae20..aca9bf3648c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -328,10 +328,10 @@ enum reset_type { RESET_TYPE_SILENT = 0x02 }; -typedef enum _IC_INFERIORITY_8192S{ +enum ic_inferiority_8192s { IC_INFERIORITY_A = 0, IC_INFERIORITY_B = 1, -} IC_INFERIORITY_8192S, *PIC_INFERIORITY_8192S; +}; typedef enum _PCI_BRIDGE_VENDOR { PCI_BRIDGE_VENDOR_INTEL = 0x0, @@ -586,7 +586,7 @@ struct r8192_priv { enum rt_rf_type_819xu rf_chip; - IC_INFERIORITY_8192S IC_Class; + enum ic_inferiority_8192s IC_Class; enum ht_channel_width CurrentChannelBW; struct bb_reg_definition PHYRegDef[4]; struct rate_adaptive rate_adaptive; From 2f4178151aa52e7b41c5c5082d5c385ceac0e3ea Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:53:52 -0500 Subject: [PATCH 0461/1519] staging: rtl8192e: Convert typedef PCI_BRIDGE_VENDOR to enum pci_bridge_vendor Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index aca9bf3648c..3a2cfa0cfab 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -333,14 +333,14 @@ enum ic_inferiority_8192s { IC_INFERIORITY_B = 1, }; -typedef enum _PCI_BRIDGE_VENDOR { +enum pci_bridge_vendor { PCI_BRIDGE_VENDOR_INTEL = 0x0, PCI_BRIDGE_VENDOR_ATI, PCI_BRIDGE_VENDOR_AMD, PCI_BRIDGE_VENDOR_SIS , PCI_BRIDGE_VENDOR_UNKNOWN, PCI_BRIDGE_VENDOR_MAX , -} PCI_BRIDGE_VENDOR; +}; struct buffer { struct buffer *next; From ebc95dd01c53e464b62fb2e7e0502825893aef96 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:55:35 -0500 Subject: [PATCH 0462/1519] staging: rtl8192e: Convert typedef TWO_PORT_STATUS to enum two_port_status Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 3a2cfa0cfab..f81680814fb 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -477,15 +477,14 @@ struct channel_access_setting { u16 CWmaxIndex; }; -typedef enum _TWO_PORT_STATUS -{ +enum two_port_status { TWO_PORT_STATUS__DEFAULT_ONLY, TWO_PORT_STATUS__EXTENSION_ONLY, TWO_PORT_STATUS__EXTENSION_FOLLOW_DEFAULT, TWO_PORT_STATUS__DEFAULT_G_EXTENSION_N20, TWO_PORT_STATUS__ADHOC, TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE -} TWO_PORT_STATUS; +}; struct txbbgain_struct { long txbb_iq_amplifygain; From 85cdd997c82383b9df2ece60584d878499f9060a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:57:24 -0500 Subject: [PATCH 0463/1519] staging: rtl8192e: Convert typedef DBGP_FLAG_E to enum dbgp_flag Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_debug.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 2c32ece2e58..415dfca6b37 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -43,8 +43,7 @@ struct net_device; printk Fmt; \ } -typedef enum _DBGP_FLAG_E -{ +enum dbgp_flag { FQoS = 0, FTX = 1, FRX = 2, @@ -65,7 +64,7 @@ typedef enum _DBGP_FLAG_E FINIT = 17, FIOCTL = 18, DBGP_TYPE_MAX -} DBGP_FLAG_E; +}; #define QoS_INIT BIT0 #define QoS_VISTA BIT1 From 3a74e8b369bd7af91de80eb48f4e761f78d45c0d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 19:59:11 -0500 Subject: [PATCH 0464/1519] staging: rtl8192e: Convert typedef dm_dig_sta_e to enum dm_dig_sta Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 219e4af2b3d..88b63285a6e 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -127,12 +127,11 @@ struct dig_t { long rssi_val; }; -typedef enum _dm_dig_sta_e -{ +enum dm_dig_sta { DM_STA_DIG_OFF = 0, DM_STA_DIG_ON, DM_STA_DIG_MAX -} dm_dig_sta_e; +}; typedef enum _dm_ratr_sta_e From a672b1f1df4e50d975b05edadb141931ca4b128e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:01:24 -0500 Subject: [PATCH 0465/1519] staging: rtl8192e: Convert typedef dm_ratr_sta_e to enum dm_ratr_sta Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 88b63285a6e..2624d18e363 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -134,13 +134,12 @@ enum dm_dig_sta { }; -typedef enum _dm_ratr_sta_e -{ +enum dm_ratr_sta { DM_RATR_STA_HIGH = 0, DM_RATR_STA_MIDDLE = 1, DM_RATR_STA_LOW = 2, DM_RATR_STA_MAX -} dm_ratr_sta_e; +}; typedef enum _dm_dig_op_e { From 3f67ad4e5732a6ea9357401b91d7ed87ebbd0f7b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:02:56 -0500 Subject: [PATCH 0466/1519] staging: rtl8192e: Convert typedef dm_dig_op_e to enum dm_dig_op_sta Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 2624d18e363..c1fb5027bd6 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -141,8 +141,7 @@ enum dm_ratr_sta { DM_RATR_STA_MAX }; -typedef enum _dm_dig_op_e -{ +enum dm_dig_op_sta { DIG_TYPE_THRESH_HIGH = 0, DIG_TYPE_THRESH_LOW = 1, DIG_TYPE_THRESH_HIGHPWR_HIGH = 2, @@ -157,7 +156,7 @@ typedef enum _dm_dig_op_e DIG_TYPE_ENABLE = 20, DIG_TYPE_DISABLE = 30, DIG_OP_TYPE_MAX -} dm_dig_op_e; +}; typedef enum _dm_dig_alg_e { From ba7b6556fdadf357ef4bcdd4ff694dde8ae9560a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:04:17 -0500 Subject: [PATCH 0467/1519] staging: rtl8192e: Convert typedef dm_dig_alg_e to enum dm_dig_alg Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index c1fb5027bd6..550ec308392 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -158,14 +158,13 @@ enum dm_dig_op_sta { DIG_OP_TYPE_MAX }; -typedef enum _dm_dig_alg_e -{ +enum dm_dig_alg { DIG_ALGO_BY_FALSE_ALARM = 0, DIG_ALGO_BY_RSSI = 1, DIG_ALGO_BEFORE_CONNECT_BY_RSSI_AND_ALARM = 2, DIG_ALGO_BY_TOW_PORT = 3, DIG_ALGO_MAX -} dm_dig_alg_e; +}; typedef enum _DM_DIG_TWO_PORT_ALG_E { From defb880b7dd0ddf76597b189c45caf3efee3e65d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:05:53 -0500 Subject: [PATCH 0468/1519] staging: rtl8192e: Convert typedef DM_DIG_TWO_PORT_ALG_E to enum dm_dig_two_port_alg Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 550ec308392..9a64fe397cd 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -166,11 +166,10 @@ enum dm_dig_alg { DIG_ALGO_MAX }; -typedef enum _DM_DIG_TWO_PORT_ALG_E -{ +enum dm_dig_two_port_alg { DIG_TWO_PORT_ALGO_RSSI = 0, DIG_TWO_PORT_ALGO_FALSE_ALARM = 1, -} DM_DIG_TWO_PORT_ALG_E; +}; typedef enum _DM_DIG_EXT_PORT_ALG_E From 89cc54bc78bca0a885f16e84f77e5e85afee7103 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:07:22 -0500 Subject: [PATCH 0469/1519] staging: rtl8192e: Convert typedef DM_DIG_EXT_PORT_ALG_E to enum dm_dig_ext_port_alg Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 9a64fe397cd..f446451c2e5 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -172,14 +172,13 @@ enum dm_dig_two_port_alg { }; -typedef enum _DM_DIG_EXT_PORT_ALG_E -{ +enum dm_dig_ext_port_alg { DIG_EXT_PORT_STAGE_0 = 0, DIG_EXT_PORT_STAGE_1 = 1, DIG_EXT_PORT_STAGE_2 = 2, DIG_EXT_PORT_STAGE_3 = 3, DIG_EXT_PORT_STAGE_MAX = 4, -} DM_DIG_EXT_PORT_ALG_E; +}; typedef enum _dm_dig_dbg_e { From 811ad0fdacdc9fe699ad5b524a9b7a3d09799f4d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:08:51 -0500 Subject: [PATCH 0470/1519] staging: rtl8192e: Convert typedef dm_dig_dbg_e to enum dm_dig_dbg Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index f446451c2e5..451ffe9ccdc 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -180,12 +180,11 @@ enum dm_dig_ext_port_alg { DIG_EXT_PORT_STAGE_MAX = 4, }; -typedef enum _dm_dig_dbg_e -{ +enum dm_dig_dbg { DIG_DBG_OFF = 0, DIG_DBG_ON = 1, DIG_DBG_MAX -} dm_dig_dbg_e; +}; typedef enum _dm_dig_connect_e { From 4777da736e92706639df6c58967ebb7d901174e7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:14:21 -0500 Subject: [PATCH 0471/1519] staging: rtl8192e: Convert typedef dm_dig_connect_e to enum dm_dig_connect Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 451ffe9ccdc..5f521624867 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -186,8 +186,7 @@ enum dm_dig_dbg { DIG_DBG_MAX }; -typedef enum _dm_dig_connect_e -{ +enum dm_dig_connect { DIG_STA_DISCONNECT = 0, DIG_STA_CONNECT = 1, DIG_STA_BEFORE_CONNECT = 2, @@ -195,7 +194,7 @@ typedef enum _dm_dig_connect_e DIG_AP_CONNECT = 4, DIG_AP_ADD_STATION = 5, DIG_CONNECT_MAX -} dm_dig_connect_e; +}; typedef enum _dm_dig_pd_th_e { From 5d1703aee6af5aa2270d3e548e9f8ca258f54d07 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:15:45 -0500 Subject: [PATCH 0472/1519] staging: rtl8192e: Convert typedef dm_dig_pd_th_e to enum dm_dig_pd_th Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 5f521624867..1299091d338 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -196,13 +196,12 @@ enum dm_dig_connect { DIG_CONNECT_MAX }; -typedef enum _dm_dig_pd_th_e -{ +enum dm_dig_pd_th { DIG_PD_AT_LOW_POWER = 0, DIG_PD_AT_NORMAL_POWER = 1, DIG_PD_AT_HIGH_POWER = 2, DIG_PD_MAX -} dm_dig_pd_th_e; +}; typedef enum _dm_dig_cs_ratio_e { From 2fa7c962435809e13f076b6cf247826518f19ef1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:17:05 -0500 Subject: [PATCH 0473/1519] staging: rtl8192e: Convert typedef dm_dig_cs_ratio_e to enum dm_dig_cs_ratio Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 1299091d338..817bb7ecc3f 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -203,12 +203,11 @@ enum dm_dig_pd_th { DIG_PD_MAX }; -typedef enum _dm_dig_cs_ratio_e -{ +enum dm_dig_cs_ratio { DIG_CS_RATIO_LOWER = 0, DIG_CS_RATIO_HIGHER = 1, DIG_CS_MAX -} dm_dig_cs_ratio_e; +}; struct drx_path_sel { u8 Enable; From fe5cd9c21bb12a07710160577a6911111fef560a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:19:00 -0500 Subject: [PATCH 0474/1519] staging: rtl8192e: Convert typedef DM_CCK_Rx_Path_Method to enum dm_cck_rx_path_method Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 817bb7ecc3f..593f010327d 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -225,12 +225,11 @@ struct drx_path_sel { long cck_pwdb_sta[4]; }; -typedef enum _DM_CCK_Rx_Path_Method -{ +enum dm_cck_rx_path_method { CCK_Rx_Version_1 = 0, CCK_Rx_Version_2= 1, CCK_Rx_Version_MAX -} DM_CCK_Rx_Path_Method; +}; typedef enum _DM_DBG_E From a3120de6c4ebd68e5b2ed0e2eadc51e706b8733a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:20:23 -0500 Subject: [PATCH 0475/1519] staging: rtl8192e: Convert typedef DM_DBG_E to enum dm_dbg Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 593f010327d..64fa749cfb4 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -232,12 +232,11 @@ enum dm_cck_rx_path_method { }; -typedef enum _DM_DBG_E -{ +enum dm_dbg { DM_DBG_OFF = 0, DM_DBG_ON = 1, DM_DBG_MAX -} DM_DBG_E; +}; struct dcmd_txcmd { u32 Op; From 839370c5723a42cde6537fced66af1d2736054aa Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:21:54 -0500 Subject: [PATCH 0476/1519] staging: rtl8192e: Convert typedef HAL_DEF_VARIABLE to enum hal_def_variable Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 9dc15b8d6d3..f35bfe24d70 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -289,7 +289,7 @@ enum _ReasonCode{ dest_not_QSTA = 0x32, }; -typedef enum _HAL_DEF_VARIABLE{ +enum hal_def_variable { HAL_DEF_TPC_ENABLE, HAL_DEF_INIT_GAIN, HAL_DEF_PROT_IMP_MODE, @@ -309,7 +309,7 @@ typedef enum _HAL_DEF_VARIABLE{ HAL_DEF_PCI_SUPPORT_ASPM, HAL_DEF_THERMAL_VALUE, HAL_DEF_USB_IN_TOKEN_REV, -} HAL_DEF_VARIABLE; +}; typedef enum _HW_VARIABLES{ From bb5e482246e0f41c3b39f758c61bdf75f191cbcc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:23:18 -0500 Subject: [PATCH 0477/1519] staging: rtl8192e: Convert typedef HW_VARIABLES to enum hw_variables Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index f35bfe24d70..a27c58f203b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -312,7 +312,7 @@ enum hal_def_variable { }; -typedef enum _HW_VARIABLES{ +enum hw_variables { HW_VAR_ETHER_ADDR, HW_VAR_MULTICAST_REG, HW_VAR_BASIC_RATE, @@ -401,7 +401,7 @@ typedef enum _HW_VARIABLES{ HW_VAR_INT_MIGRATION, HW_VAR_INT_AC, HW_VAR_RF_TIMING, -} HW_VARIABLES; +}; typedef enum _RT_OP_MODE{ RT_OP_MODE_AP, From e93e0f6aabd51652fcfa943ca8e8ec2f4947156e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:24:49 -0500 Subject: [PATCH 0478/1519] staging: rtl8192e: Convert typedef RT_OP_MODE to enum rt_op_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 0c06e7b8440..cb894b6d2e7 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -109,7 +109,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) case HW_VAR_MEDIA_STATUS: { - RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); + enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); LED_CTL_MODE LedAction = LED_CTL_NO_LINK; u8 btMsr = read_nic_byte(dev, MSR); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index a27c58f203b..8fc3056f369 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -403,12 +403,12 @@ enum hw_variables { HW_VAR_RF_TIMING, }; -typedef enum _RT_OP_MODE{ +enum rt_op_mode { RT_OP_MODE_AP, RT_OP_MODE_INFRASTRUCTURE, RT_OP_MODE_IBSS, RT_OP_MODE_NO_LINK, -} RT_OP_MODE, *PRT_OP_MODE; +}; #define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) @@ -2099,7 +2099,7 @@ struct rtllib_device { u8 hwscan_sem_up; u8 CntAfterLink; - RT_OP_MODE OpMode; + enum rt_op_mode OpMode; u8 VersionID; /* The last AssocReq/Resp IEs */ From 09ced23df6a3345f1923b70d0e799105777f1546 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:26:18 -0500 Subject: [PATCH 0479/1519] staging: rtl8192e: Convert typedef ACT_CATEGORY to enum act_category Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 8fc3056f369..8b11e76047c 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -594,13 +594,13 @@ struct ieee_param { #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 -typedef enum _ACT_CATEGORY{ +enum act_category { ACT_CAT_QOS = 1, ACT_CAT_DLS = 2, ACT_CAT_BA = 3, ACT_CAT_HT = 7, ACT_CAT_WMM = 17, -} ACT_CATEGORY, *PACT_CATEGORY; +}; typedef enum _TS_ACTION{ ACT_ADDTSREQ = 0, From 5a604053a9ae947bf9b2e265e74f2ec65e64a77f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:27:45 -0500 Subject: [PATCH 0480/1519] staging: rtl8192e: Convert typedef TS_ACTION to enum ts_action Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 8b11e76047c..6c73c73765b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -602,12 +602,12 @@ enum act_category { ACT_CAT_WMM = 17, }; -typedef enum _TS_ACTION{ +enum ts_action { ACT_ADDTSREQ = 0, ACT_ADDTSRSP = 1, ACT_DELTS = 2, ACT_SCHEDULE = 3, -} TS_ACTION, *PTS_ACTION; +}; typedef enum _BA_ACTION{ ACT_ADDBAREQ = 0, From 07276bac0f49a1fc94799ff840b9a98bc6b01133 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:29:12 -0500 Subject: [PATCH 0481/1519] staging: rtl8192e: Convert typedef BA_ACTION to enum ba_action Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 6c73c73765b..1b99f45309b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -609,11 +609,11 @@ enum ts_action { ACT_SCHEDULE = 3, }; -typedef enum _BA_ACTION{ +enum ba_action { ACT_ADDBAREQ = 0, ACT_ADDBARSP = 1, ACT_DELBA = 2, -} BA_ACTION, *PBA_ACTION; +}; typedef enum _InitialGainOpType{ IG_Backup=0, From 062de0a9dfd996a37f0053886e9eff4c509133e2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:46:02 -0500 Subject: [PATCH 0482/1519] staging: rtl8192e: Convert typedef InitialGainOpType to enum init_gain_op_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 1b99f45309b..a147d905f93 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -615,11 +615,11 @@ enum ba_action { ACT_DELBA = 2, }; -typedef enum _InitialGainOpType{ +enum init_gain_op_type { IG_Backup=0, IG_Restore, IG_Max -} InitialGainOpType; +}; typedef enum _LED_CTL_MODE{ LED_CTL_POWER_ON = 1, From 4fd7cedc5135a7cc5df3c0d9348b1c32b33bdb96 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:47:28 -0500 Subject: [PATCH 0483/1519] staging: rtl8192e: Convert typedef LED_CTL_MODE to enum led_ctl_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index cb894b6d2e7..a3a269ba5d2 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -61,7 +61,7 @@ void rtl8192e_update_msr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 msr; - LED_CTL_MODE LedAction = LED_CTL_NO_LINK; + enum led_ctl_mode LedAction = LED_CTL_NO_LINK; msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; @@ -110,7 +110,7 @@ rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) case HW_VAR_MEDIA_STATUS: { enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); - LED_CTL_MODE LedAction = LED_CTL_NO_LINK; + enum led_ctl_mode LedAction = LED_CTL_NO_LINK; u8 btMsr = read_nic_byte(dev, MSR); btMsr &= 0xfc; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index a147d905f93..9966be22a9e 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -621,7 +621,7 @@ enum init_gain_op_type { IG_Max }; -typedef enum _LED_CTL_MODE{ +enum led_ctl_mode { LED_CTL_POWER_ON = 1, LED_CTL_LINK = 2, LED_CTL_NO_LINK = 3, @@ -635,7 +635,7 @@ typedef enum _LED_CTL_MODE{ LED_CTL_START_WPS_BOTTON = 11, LED_CTL_STOP_WPS_FAIL = 12, LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, -} LED_CTL_MODE; +}; typedef enum _RT_RF_TYPE_DEF { @@ -2525,7 +2525,7 @@ struct rtllib_device { void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); u16 (*rtl_11n_user_show_rates)(struct net_device *dev); void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); - void (*LedControlHandler)(struct net_device * dev, LED_CTL_MODE LedAction); + void (*LedControlHandler)(struct net_device * dev, enum led_ctl_mode LedAction); void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); From e608063303979ae4241455bd4752f2c6928e1219 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:48:58 -0500 Subject: [PATCH 0484/1519] staging: rtl8192e: Convert typedef RT_RF_TYPE_DEF to enum rt_rf_type_def Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 9966be22a9e..71bf821bad5 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -637,15 +637,14 @@ enum led_ctl_mode { LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, }; -typedef enum _RT_RF_TYPE_DEF -{ +enum rt_rf_type_def { RF_1T2R = 0, RF_2T4R, RF_2T2R, RF_1T1R, RF_2T2R_GREEN, RF_819X_MAX_TYPE -} RT_RF_TYPE_DEF; +}; typedef enum _WIRELESS_MODE { WIRELESS_MODE_UNKNOWN = 0x00, From dc20a3265e242a307810a5f327206d934e4552fc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:50:21 -0500 Subject: [PATCH 0485/1519] staging: rtl8192e: Convert typedef WIRELESS_MODE to enum wireless_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index a3a269ba5d2..453481959ff 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -2279,7 +2279,7 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) void ActUpdateChannelAccessSetting( struct net_device* dev, - WIRELESS_MODE WirelessMode, + enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting ) { diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index f81680814fb..d09c62aa63c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -1096,7 +1096,7 @@ MgntActSet_RF_State( void ActUpdateChannelAccessSetting( struct net_device* dev, - WIRELESS_MODE WirelessMode, + enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting ); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 71bf821bad5..6bba2a54a78 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -646,7 +646,7 @@ enum rt_rf_type_def { RF_819X_MAX_TYPE }; -typedef enum _WIRELESS_MODE { +enum wireless_mode { WIRELESS_MODE_UNKNOWN = 0x00, WIRELESS_MODE_A = 0x01, WIRELESS_MODE_B = 0x02, @@ -654,7 +654,7 @@ typedef enum _WIRELESS_MODE { WIRELESS_MODE_AUTO = 0x08, WIRELESS_MODE_N_24G = 0x10, WIRELESS_MODE_N_5G = 0x20 -} WIRELESS_MODE; +}; typedef enum _WIRELESS_NETWORK_TYPE{ WIRELESS_11B = 1, From 80f839d43960c7f1dbd4dbcda63efaaa8cffc2b2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:51:54 -0500 Subject: [PATCH 0486/1519] staging: rtl8192e: Convert typedef WIRELESS_NETWORK_TYPE to enum wireless_network_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 6bba2a54a78..07cde96344f 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -656,12 +656,12 @@ enum wireless_mode { WIRELESS_MODE_N_5G = 0x20 }; -typedef enum _WIRELESS_NETWORK_TYPE{ +enum wireless_network_type { WIRELESS_11B = 1, WIRELESS_11G = 2, WIRELESS_11A = 4, WIRELESS_11N = 8 -} WIRELESS_NETWORK_TYPE; +}; #define OUI_SUBTYPE_WMM_INFO 0 #define OUI_SUBTYPE_WMM_PARAM 1 From 3b45eb8309ab7e31c31ca046e36033ff9b90a336 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:53:13 -0500 Subject: [PATCH 0487/1519] staging: rtl8192e: Convert typedef erp_t to enum erp_t Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 07cde96344f..00d6862c309 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1627,11 +1627,11 @@ struct ether_header { #endif -typedef enum _erp_t{ +enum erp_t { ERP_NonERPpresent = 0x01, ERP_UseProtection = 0x02, ERP_BarkerPreambleMode = 0x04, -} erp_t; +}; struct rtllib_network { /* These entries are used to identify a unique network */ From 3c093c2ba168ec4a4bfd638c4c35cf748ea329a9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:54:40 -0500 Subject: [PATCH 0488/1519] staging: rtl8192e: Convert typedef Fsync_State to enum fsync_state Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 00d6862c309..d53293782fb 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1793,11 +1793,11 @@ struct rx_reorder_entry { u16 SeqNum; struct rtllib_rxb* prxb; }; -typedef enum _Fsync_State{ +enum fsync_state { Default_Fsync, HW_Fsync, SW_Fsync -} Fsync_State; +}; typedef enum _RT_PS_MODE { @@ -2377,7 +2377,7 @@ struct rtllib_device { u8 fsync_multiple_timeinterval; u32 fsync_firstdiff_ratethreshold; u32 fsync_seconddiff_ratethreshold; - Fsync_State fsync_state; + enum fsync_state fsync_state; bool bis_any_nonbepkts; struct bandwidth_autoswitch bandwidth_auto_switch; bool FwRWRF; From f6e3d4f4c2fd00a58561db35d6fc6e060ebbebff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:56:03 -0500 Subject: [PATCH 0489/1519] staging: rtl8192e: Convert typedef RT_PS_MODE to enum rt_ps_mode Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d53293782fb..23c362545d0 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1799,13 +1799,12 @@ enum fsync_state { SW_Fsync }; -typedef enum _RT_PS_MODE -{ +enum rt_ps_mode { eActive, eMaxPs, eFastPs, eAutoPs, -} RT_PS_MODE; +}; typedef enum _IPS_CALLBACK_FUNCION { @@ -2122,7 +2121,7 @@ struct rtllib_device { bool ieee_up; bool cannot_notify; bool bSupportRemoteWakeUp; - RT_PS_MODE dot11PowerSaveMode; + enum rt_ps_mode dot11PowerSaveMode; bool actscanning; bool FirstIe_InScan; bool be_scan_inprogress; From 8304cc64dc242f4b410899256c929b9a93108a92 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:57:34 -0500 Subject: [PATCH 0490/1519] staging: rtl8192e: Convert typedef IPS_CALLBACK_FUNCION to enum ips_callback_function Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 23c362545d0..8afe29589c4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1806,12 +1806,11 @@ enum rt_ps_mode { eAutoPs, }; -typedef enum _IPS_CALLBACK_FUNCION -{ +enum ips_callback_function { IPS_CALLBACK_NONE = 0, IPS_CALLBACK_MGNT_LINK_REQUEST = 1, IPS_CALLBACK_JOIN_REQUEST = 2, -} IPS_CALLBACK_FUNCION; +}; typedef enum _RT_JOIN_ACTION{ RT_JOIN_INFRA = 1, @@ -1864,7 +1863,7 @@ struct rt_pwr_save_ctrl { struct work_struct InactivePsWorkItem; struct timer_list InactivePsTimer; - IPS_CALLBACK_FUNCION ReturnPoint; + enum ips_callback_function ReturnPoint; bool bTmpBssDesc; RT_JOIN_ACTION tmpJoinAction; From f6ce577e381e248fbcdad0d9d7e51e5337b6a6a0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 20:59:09 -0500 Subject: [PATCH 0491/1519] staging: rtl8192e: Convert typedef RT_JOIN_ACTION to enum rt_join_action Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 8afe29589c4..b1e19cdaa04 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1812,12 +1812,12 @@ enum ips_callback_function { IPS_CALLBACK_JOIN_REQUEST = 2, }; -typedef enum _RT_JOIN_ACTION{ +enum rt_join_action { RT_JOIN_INFRA = 1, RT_JOIN_IBSS = 2, RT_START_IBSS = 3, RT_NO_ACTION = 4, -} RT_JOIN_ACTION; +}; struct ibss_parms { u16 atimWin; @@ -1866,7 +1866,7 @@ struct rt_pwr_save_ctrl { enum ips_callback_function ReturnPoint; bool bTmpBssDesc; - RT_JOIN_ACTION tmpJoinAction; + enum rt_join_action tmpJoinAction; struct rtllib_network tmpBssDesc; bool bTmpScanOnly; From de7c885a248ad79380bf1b3425738e436a7790ff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:00:33 -0500 Subject: [PATCH 0492/1519] staging: rtl8192e: Convert typedef RT_RF_POWER_STATE to enum rt_rf_power_state Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 4 ++-- drivers/staging/rtl8192e/r8192E_phy.c | 4 ++-- drivers/staging/rtl8192e/r8192E_phy.h | 2 +- drivers/staging/rtl8192e/rtl_cam.c | 2 +- drivers/staging/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtl_dm.c | 2 +- drivers/staging/rtl8192e/rtl_ps.c | 6 +++--- drivers/staging/rtl8192e/rtl_wx.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 9 ++++----- 10 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 90cbb5b45f6..edca4d55f58 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -108,7 +108,7 @@ cmpk_count_txstatistic( { struct r8192_priv *priv = rtllib_priv(dev); #ifdef ENABLE_PS - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); @@ -272,7 +272,7 @@ static void cmpk_count_tx_status( struct net_device *dev, #ifdef ENABLE_PS - RT_RF_POWER_STATE rtstate; + enum rt_rf_power_state rtstate; pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 45073b34027..9c1d16b5fb6 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -1377,7 +1377,7 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) bool SetRFPowerState8190( struct net_device* dev, - RT_RF_POWER_STATE eRFPowerState + enum rt_rf_power_state eRFPowerState ) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1547,7 +1547,7 @@ SetRFPowerState8190( bool SetRFPowerState( struct net_device* dev, - RT_RF_POWER_STATE eRFPowerState + enum rt_rf_power_state eRFPowerState ) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index b0d1f7e6679..79adc8096bd 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -123,7 +123,7 @@ extern void PHY_SetRtl8192eRfOff(struct net_device *dev); bool SetRFPowerState( struct net_device* dev, - RT_RF_POWER_STATE eRFPowerState + enum rt_rf_power_state eRFPowerState ); #define PHY_SetRFPowerState SetRFPowerState diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index 31f198c8252..4a11b30d184 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -119,7 +119,7 @@ void setKey(struct net_device *dev, u16 usConfig = 0; u8 i; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; if (priv->rtllib->PowerSaveControl.bInactivePs){ if (rtState == eRfOff){ diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 3066fc80f66..e633f0b074e 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -349,7 +349,7 @@ void write_nic_word(struct net_device *dev, int x,u16 y) bool MgntActSet_RF_State( struct net_device* dev, - RT_RF_POWER_STATE StateToSet, + enum rt_rf_power_state StateToSet, RT_RF_CHANGE_SOURCE ChangeSource, bool ProtectOrNot ) @@ -358,7 +358,7 @@ MgntActSet_RF_State( struct rtllib_device * ieee = priv->rtllib; bool bActionAllowed = false; bool bConnectBySSID = false; - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; u16 RFWaitCounter = 0; unsigned long flag; RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); @@ -1495,7 +1495,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); enum reset_type TxResetType = RESET_TYPE_NORESET; enum reset_type RxResetType = RESET_TYPE_NORESET; - RT_RF_POWER_STATE rfState; + enum rt_rf_power_state rfState; rfState = priv->rtllib->eRFPowerState; diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index d09c62aa63c..462bd73a495 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -1089,7 +1089,7 @@ bool NicIFDisableNIC(struct net_device* dev); bool MgntActSet_RF_State( struct net_device* dev, - RT_RF_POWER_STATE StateToSet, + enum rt_rf_power_state StateToSet, RT_RF_CHANGE_SOURCE ChangeSource, bool ProtectOrNot ); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index a8e2678c1a5..3ab71c78634 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -2671,7 +2671,7 @@ extern void dm_CheckRfCtrlGPIO(void *data) struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,gpio_change_rf_wq); struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; - RT_RF_POWER_STATE eRfPowerStateToSet; + enum rt_rf_power_state eRfPowerStateToSet; bool bActuallySet = false; char *argv[3]; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 1f69c377618..58966e07be7 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -134,7 +134,7 @@ IPSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; if (pPSC->bInactivePs) { @@ -157,7 +157,7 @@ IPSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; if (pPSC->bInactivePs) { @@ -184,7 +184,7 @@ void IPSLeave_wq(void *data) void rtllib_ips_leave_wq(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; if (priv->rtllib->PowerSaveControl.bInactivePs){ diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 1eb2559765f..bc096c096cf 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -316,7 +316,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device* ieee = netdev_priv_rsl(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; int ret; if (priv->bHwRadioOff == true) @@ -447,7 +447,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device* ieee = priv->rtllib; - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; int ret; if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b1e19cdaa04..a96093f4e91 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1824,12 +1824,11 @@ struct ibss_parms { }; #define MAX_NUM_RATES 264 -typedef enum _RT_RF_POWER_STATE -{ +enum rt_rf_power_state { eRfOn, eRfSleep, eRfOff -} RT_RF_POWER_STATE; +}; #define MAX_SUPPORT_WOL_PATTERN_NUM 8 @@ -1859,7 +1858,7 @@ struct rt_pwr_save_ctrl { bool bIPSModeBackup; bool bHaltAdapterClkRQ; bool bSwRfProcessing; - RT_RF_POWER_STATE eInactivePowerState; + enum rt_rf_power_state eInactivePowerState; struct work_struct InactivePsWorkItem; struct timer_list InactivePsTimer; @@ -2125,7 +2124,7 @@ struct rtllib_device { bool FirstIe_InScan; bool be_scan_inprogress; bool beinretry; - RT_RF_POWER_STATE eRFPowerState; + enum rt_rf_power_state eRFPowerState; RT_RF_CHANGE_SOURCE RfOffReason; bool is_set_key; bool wx_set_enc; From d45c88a63b1142ef88b732c48c9ed49838b670da Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:02:02 -0500 Subject: [PATCH 0493/1519] staging: rtl8192e: Convert typedef WOLPATTERN_TYPE to enum wol_pattern_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index a96093f4e91..5afe7dee46c 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1835,21 +1835,20 @@ enum rt_rf_power_state { #define MAX_WOL_BIT_MASK_SIZE 16 #define MAX_WOL_PATTERN_SIZE 128 -typedef enum _WOLPATTERN_TYPE -{ +enum wol_pattern_type { eNetBIOS = 0, eIPv4IPv6ARP, eIPv4IPv6TCPSYN, eMACIDOnly, eNoDefined, -} WOLPATTERN_TYPE; +}; struct rt_pm_wol_info { u32 PatternId; u32 Mask[4]; u16 CrcRemainder; u8 WFMIndex; - WOLPATTERN_TYPE PatternType; + enum wol_pattern_type PatternType; }; struct rt_pwr_save_ctrl { From 569e59595541ee4721eed7a5cb6c13a4ef525bea Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:03:26 -0500 Subject: [PATCH 0494/1519] staging: rtl8192e: Convert typedef country_code_type_t to enum country_code_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 5afe7dee46c..69909cd6eb2 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1917,8 +1917,7 @@ typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_IPS BIT28 #define RF_CHANGE_BY_INIT 0 -typedef enum _country_code_type_t -{ +enum country_code_type { COUNTRY_CODE_FCC = 0, COUNTRY_CODE_IC = 1, COUNTRY_CODE_ETSI = 2, @@ -1933,7 +1932,7 @@ typedef enum _country_code_type_t COUNTRY_CODE_WORLD_WIDE_13 = 11, COUNTRY_CODE_TELEC_NETGEAR = 12, COUNTRY_CODE_MAX -} country_code_type_t; +}; typedef enum _SCAN_OPERATION_BACKUP_OPT{ SCAN_OPT_BACKUP=0, From 472ba3265503203f70012d2decff4007fed270db Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:04:56 -0500 Subject: [PATCH 0495/1519] staging: rtl8192e: Convert typedef SCAN_OPERATION_BACKUP_OPT to enum scan_op_backup_opt Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 69909cd6eb2..76c372c5f06 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1934,11 +1934,11 @@ enum country_code_type { COUNTRY_CODE_MAX }; -typedef enum _SCAN_OPERATION_BACKUP_OPT{ +enum scan_op_backup_opt { SCAN_OPT_BACKUP=0, SCAN_OPT_RESTORE, SCAN_OPT_MAX -} SCAN_OPERATION_BACKUP_OPT; +}; typedef enum _FW_CMD_IO_TYPE{ FW_CMD_DIG_ENABLE = 0, From 74082c929d07ced0d7cad5ce94230a97880ed0bc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:06:24 -0500 Subject: [PATCH 0496/1519] staging: rtl8192e: Convert typedef FW_CMD_IO_TYPE to enum fw_cmd_io_type Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 76c372c5f06..461c150d3a2 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1940,7 +1940,7 @@ enum scan_op_backup_opt { SCAN_OPT_MAX }; -typedef enum _FW_CMD_IO_TYPE{ +enum fw_cmd_io_type { FW_CMD_DIG_ENABLE = 0, FW_CMD_DIG_DISABLE = 1, FW_CMD_DIG_HALT = 2, @@ -1972,7 +1972,7 @@ typedef enum _FW_CMD_IO_TYPE{ FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28, FW_CMD_PAPE_CONTROL = 29, FW_CMD_CHAN_SET = 30, -} FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE; +}; #define RT_MAX_LD_SLOT_NUM 10 struct rt_link_detect { @@ -2513,7 +2513,7 @@ struct rtllib_device { u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); - bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO); + bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO); void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level); void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start); void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); From d0df281309e40f21f7a9d9633c2dd78f55edd5f4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:07:59 -0500 Subject: [PATCH 0497/1519] staging: rtl8192e: Convert typedef RATR_TABLE_MODE_8192S to enum ratr_table_mode_8192s Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 461c150d3a2..63eb5b58437 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2031,7 +2031,7 @@ struct rate_adaptive { u8 PreRATRState; }; -typedef enum _RATR_TABLE_MODE_8192S{ +enum ratr_table_mode_8192s { RATR_INX_WIRELESS_NGB = 0, RATR_INX_WIRELESS_NG = 1, RATR_INX_WIRELESS_NB = 2, @@ -2041,7 +2041,7 @@ typedef enum _RATR_TABLE_MODE_8192S{ RATR_INX_WIRELESS_B = 6, RATR_INX_WIRELESS_MC = 7, RATR_INX_WIRELESS_A = 8, -} RATR_TABLE_MODE_8192S, *PRATR_TABLE_MODE_8192S; +}; #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { From e6605947508968e4020702f8dbe4d0bcad2028ae Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:10:02 -0500 Subject: [PATCH 0498/1519] staging: rtl8192e: Convert typedef HT_AGGRE_SIZE_E to enum ht_aggre_size Remove typedef from enum. Rename enum. Rename uses. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_HT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 108b27cc95c..891714fb182 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -397,12 +397,12 @@ extern u8 MCS_FILTER_1SS[16]; #define IS_11N_MCS_RATE(rate) (rate&0x80) -typedef enum _HT_AGGRE_SIZE_E{ +enum ht_aggre_size { HT_AGG_SIZE_8K = 0, HT_AGG_SIZE_16K = 1, HT_AGG_SIZE_32K = 2, HT_AGG_SIZE_64K = 3, -} HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E; +}; enum ht_iot_peer { HT_IOT_PEER_UNKNOWN = 0, From 9de9f962c71ad2c512c40e30b84aca5392a89630 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 19 Jul 2011 21:17:25 -0500 Subject: [PATCH 0499/1519] staging: rtl8192e: Convert typedefs that can be replaced with #define Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 8 +++++--- drivers/staging/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 59ab0b87227..0d2f8bff474 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -110,7 +110,8 @@ struct octet_string { }; #define MAX_WMMELE_LENGTH 64 -typedef u32 QOS_MODE, *PQOS_MODE; +#define QOS_MODE u32 + #define QOS_DISABLE 0 #define QOS_WMM 1 #define QOS_WMMSA 2 @@ -174,7 +175,8 @@ enum qos_ie_source { }; -typedef u32 AC_CODING; +#define AC_CODING u32 + #define AC0_BE 0 #define AC1_BK 1 #define AC2_VI 2 @@ -237,7 +239,7 @@ struct acm { -typedef u8 AC_UAPSD, *PAC_UAPSD; +#define AC_UAPSD u8 #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0) #define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 462bd73a495..22b0a438b9d 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -80,8 +80,8 @@ .vendor = (vend), .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice =PCI_ANY_ID , \ .driver_data = (kernel_ulong_t)&(cfg) - typedef irqreturn_t irqreturn_type; +#define irqreturn_type irqreturn_t #define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 63eb5b58437..2ab1e6cb639 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1910,7 +1910,8 @@ struct rt_pwr_save_ctrl { }; -typedef u32 RT_RF_CHANGE_SOURCE; +#define RT_RF_CHANGE_SOURCE u32 + #define RF_CHANGE_BY_SW BIT31 #define RF_CHANGE_BY_HW BIT30 #define RF_CHANGE_BY_PS BIT29 From eae5bcc278655182a1469d2702c0bfdf09ba6f94 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Aug 2011 14:19:17 -0700 Subject: [PATCH 0500/1519] staging: rts5139: add vmalloc.h to some files to fix the build. This is needed to fix the build on alpha and ppc at the least. Reported-by: Andrew Morton Reported-by: Stephen Rothwell Cc: edwin_rong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/ms.c | 1 + drivers/staging/rts5139/rts51x_scsi.c | 1 + drivers/staging/rts5139/xd.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c index 63f191dd031..b0e9071c8e5 100644 --- a/drivers/staging/rts5139/ms.c +++ b/drivers/staging/rts5139/ms.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "debug.h" #include "trace.h" diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c index f6044937e33..3b32f9e6e4f 100644 --- a/drivers/staging/rts5139/rts51x_scsi.c +++ b/drivers/staging/rts5139/rts51x_scsi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/rts5139/xd.c b/drivers/staging/rts5139/xd.c index 39c45240816..5820605d180 100644 --- a/drivers/staging/rts5139/xd.c +++ b/drivers/staging/rts5139/xd.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "debug.h" #include "trace.h" From 6f4ebab56870db3c7d76010dc30410211580461f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Aug 2011 14:21:48 -0700 Subject: [PATCH 0501/1519] staging: iio: adis16220_core.c: add module.h This is needed and makes the linux-next merge easier. Reported-by: Stephen Rothwell Cc: Paul Gortmaker Cc: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16220_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 075e40fabf4..18b0830b82f 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" From 5f9c035cae18be30b70efc88c3c88b34283db62f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:33 +0100 Subject: [PATCH 0502/1519] staging:iio:triggers. Add a reference get to the core for triggers. This is to do with dynamically allocated triggers and the need to ensure the underlying structures don't go away when a consumer is using them. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index ebacfdadee1..89a993430d1 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -8,7 +8,6 @@ */ #include -#include #include #include #include @@ -478,6 +477,7 @@ struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) IRQ_NOPROBE); } iio_get(); + get_device(&trig->dev); } return trig; } @@ -501,6 +501,9 @@ EXPORT_SYMBOL(iio_device_register_trigger_consumer); int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) { + /* Clean up and associated but not attached triggers references */ + if (dev_info->trig) + iio_put_trigger(dev_info->trig); sysfs_remove_group(&dev_info->dev.kobj, &iio_trigger_consumer_attr_group); return 0; From 82db4249a2bd8b19c734e1ec4db0d6a56849b9a0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:34 +0100 Subject: [PATCH 0503/1519] staging:iio:triggers reorder module put and device put to ensure that the ops are still there if put results in device deletion. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 325e086e9e6..234c7743343 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -104,14 +104,14 @@ static inline struct iio_trigger *to_iio_trigger(struct device *d) static inline void iio_put_trigger(struct iio_trigger *trig) { - put_device(&trig->dev); module_put(trig->ops->owner); + put_device(&trig->dev); }; static inline void iio_get_trigger(struct iio_trigger *trig) { - __module_get(trig->ops->owner); get_device(&trig->dev); + __module_get(trig->ops->owner); }; /** From 9c0c22bd1699a800771370f85ee97c9ab388247e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:35 +0100 Subject: [PATCH 0504/1519] staging:iio:trigger:sysfs trigger: Add a release function to avoid warning on module removal. The device is static and should never actually be deleted. The release is just to avoid a warning from the kernel. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/iio-trig-sysfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/trigger/iio-trig-sysfs.c b/drivers/staging/iio/trigger/iio-trig-sysfs.c index 346b30c2f7f..174dc65709d 100644 --- a/drivers/staging/iio/trigger/iio-trig-sysfs.c +++ b/drivers/staging/iio/trigger/iio-trig-sysfs.c @@ -77,9 +77,16 @@ static const struct attribute_group *iio_sysfs_trig_groups[] = { NULL }; + +/* Nothing to actually do upon release */ +static void iio_trigger_sysfs_release(struct device *dev) +{ +} + static struct device iio_sysfs_trig_dev = { .bus = &iio_bus_type, .groups = iio_sysfs_trig_groups, + .release = &iio_trigger_sysfs_release, }; static ssize_t iio_sysfs_trigger_poll(struct device *dev, From e65bc6ac6fa54959ac0b3712b0f35bbf073c073e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:36 +0100 Subject: [PATCH 0505/1519] staging:iio:pollfunc: Make explicit that private data is always pointer to a struct iio_dev. This is always true, so lets make it explicit. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 2 +- drivers/staging/iio/accel/adis16203_ring.c | 2 +- drivers/staging/iio/accel/adis16204_ring.c | 2 +- drivers/staging/iio/accel/adis16209_ring.c | 2 +- drivers/staging/iio/accel/adis16240_ring.c | 2 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7298_ring.c | 2 +- drivers/staging/iio/adc/ad7476_ring.c | 2 +- drivers/staging/iio/adc/ad7606_ring.c | 3 +-- drivers/staging/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7887_ring.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 2 +- drivers/staging/iio/adc/max1363_ring.c | 2 +- drivers/staging/iio/gyro/adis16260_ring.c | 2 +- drivers/staging/iio/imu/adis16400_ring.c | 2 +- drivers/staging/iio/industrialio-trigger.c | 4 ++-- drivers/staging/iio/meter/ade7758_ring.c | 2 +- drivers/staging/iio/trigger.h | 6 +++--- 19 files changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 9925785a9c8..880c4901b0f 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -59,7 +59,7 @@ static int adis16201_read_ring_data(struct iio_dev *indio_dev, u8 *rx) static irqreturn_t adis16201_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16201_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index 049174d73b6..4398fd90a17 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -59,7 +59,7 @@ static int adis16203_read_ring_data(struct device *dev, u8 *rx) static irqreturn_t adis16203_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16203_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index b1738562efb..385e3503f96 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -57,7 +57,7 @@ static int adis16204_read_ring_data(struct device *dev, u8 *rx) static irqreturn_t adis16204_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16204_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; int i = 0; diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 7547ddb1460..1652f15afa4 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -57,7 +57,7 @@ static int adis16209_read_ring_data(struct device *dev, u8 *rx) static irqreturn_t adis16209_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16209_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 9bb4ff80dbc..9d4ba15e138 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -54,7 +54,7 @@ static int adis16240_read_ring_data(struct device *dev, u8 *rx) static irqreturn_t adis16240_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16240_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index c53985e70b8..7f7dca46eca 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -160,7 +160,7 @@ static int lis3l02dq_get_ring_element(struct iio_dev *indio_dev, static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct iio_ring_buffer *ring = indio_dev->ring; int len = 0; size_t datasize = ring->access->get_bytes_per_datum(ring); diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index c5a8b50ddf4..1b07b6300b9 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -537,7 +537,7 @@ static int ad7192_ring_postdisable(struct iio_dev *indio_dev) static irqreturn_t ad7192_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct iio_ring_buffer *ring = indio_dev->ring; struct ad7192_state *st = iio_priv(indio_dev); s64 dat64[2]; diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 7423d4a9c0d..ab828a952fb 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -117,7 +117,7 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev) static irqreturn_t ad7298_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct ad7298_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; s64 time_ns; diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index 86bbba87f32..2597fdaa50c 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -76,7 +76,7 @@ static int ad7476_ring_preenable(struct iio_dev *indio_dev) static irqreturn_t ad7476_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct ad7476_state *st = iio_priv(indio_dev); s64 time_ns; __u8 *rxbuf; diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index f8f574a52fd..52b0c1dbbc0 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -80,8 +80,7 @@ static int ad7606_ring_preenable(struct iio_dev *indio_dev) static irqreturn_t ad7606_trigger_handler_th_bh(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; - struct ad7606_state *st = iio_priv(indio_dev); + struct ad7606_state *st = iio_priv(pf->indio_dev); gpio_set_value(st->pdata->gpio_convst, 1); diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index ab6f10932be..aab752886c9 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -401,7 +401,7 @@ static int ad7793_ring_postdisable(struct iio_dev *indio_dev) static irqreturn_t ad7793_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct iio_ring_buffer *ring = indio_dev->ring; struct ad7793_state *st = iio_priv(indio_dev); s64 dat64[2]; diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index b77b120bdd1..05ae4a09426 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -112,7 +112,7 @@ static int ad7887_ring_postdisable(struct iio_dev *indio_dev) static irqreturn_t ad7887_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct ad7887_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; s64 time_ns; diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index d84efd65f6b..7980fe54bd6 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -105,7 +105,7 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev) static irqreturn_t ad799x_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct ad799x_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; s64 time_ns; diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 696676fa25a..caa63cb07ab 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -104,7 +104,7 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev) static irqreturn_t max1363_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct max1363_state *st = iio_priv(indio_dev); s64 time_ns; __u8 *rxbuf; diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 92d1facf3c7..36f72c32d35 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -60,7 +60,7 @@ static int adis16260_read_ring_data(struct device *dev, u8 *rx) static irqreturn_t adis16260_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16260_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; int i = 0; diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index ef3847746ec..56385d3baeb 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -111,7 +111,7 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) static irqreturn_t adis16400_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct adis16400_state *st = iio_priv(indio_dev); struct iio_ring_buffer *ring = indio_dev->ring; int i = 0, j, ret = 0; diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 89a993430d1..ccfd558d090 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -274,7 +274,7 @@ struct iio_poll_func *iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), int type, - void *private, + struct iio_dev *indio_dev, const char *fmt, ...) { @@ -294,7 +294,7 @@ struct iio_poll_func pf->h = h; pf->thread = thread; pf->type = type; - pf->private_data = private; + pf->indio_dev = indio_dev; return pf; } diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index c9271d01317..c29beec5e21 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -60,7 +60,7 @@ out: static irqreturn_t ade7758_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; + struct iio_dev *indio_dev = pf->indio_dev; struct iio_ring_buffer *ring = indio_dev->ring; struct ade7758_state *st = iio_priv(indio_dev); s64 dat64[2]; diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 234c7743343..010da1ddde3 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -76,7 +76,7 @@ struct iio_trigger { /** * struct iio_poll_func - poll function pair * - * @private_data: data specific to device (passed into poll func) + * @indio_dev: data specific to device (passed into poll func) * @h: the function that is actually run on trigger * @thread: threaded interrupt part * @type: the type of interrupt (basically if oneshot) @@ -88,7 +88,7 @@ struct iio_trigger { * passes it via here. **/ struct iio_poll_func { - void *private_data; + struct iio_dev *indio_dev; irqreturn_t (*h)(int irq, void *p); irqreturn_t (*thread)(int irq, void *p); int type; @@ -180,7 +180,7 @@ struct iio_poll_func *iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), int type, - void *private, + struct iio_dev *indio_dev, const char *fmt, ...); void iio_dealloc_pollfunc(struct iio_poll_func *pf); From f60c4a02aa05817f00408ecefdf221f44781e08a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:37 +0100 Subject: [PATCH 0506/1519] staging:iio: prevent removal of module connected to trigger. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7192.c | 6 ------ drivers/staging/iio/adc/ad7298_ring.c | 5 ----- drivers/staging/iio/adc/ad7476_ring.c | 6 ------ drivers/staging/iio/adc/ad7606_ring.c | 5 ----- drivers/staging/iio/adc/ad7793.c | 6 ------ drivers/staging/iio/adc/ad7887_ring.c | 6 ------ drivers/staging/iio/adc/ad799x_ring.c | 6 ------ drivers/staging/iio/adc/max1363_ring.c | 5 ----- drivers/staging/iio/industrialio-trigger.c | 3 +++ drivers/staging/iio/meter/ade7758_ring.c | 6 ------ 10 files changed, 3 insertions(+), 51 deletions(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 1b07b6300b9..fd379082878 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -605,12 +605,6 @@ error_ret: static void ad7192_ring_cleanup(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index ab828a952fb..5b87926ca7d 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -189,11 +189,6 @@ error_ret: void ad7298_ring_cleanup(struct iio_dev *indio_dev) { - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index 2597fdaa50c..41d6b8d59dd 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -152,12 +152,6 @@ error_ret: void ad7476_ring_cleanup(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 52b0c1dbbc0..1c563ec22ac 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -197,11 +197,6 @@ error_ret: void ad7606_ring_cleanup(struct iio_dev *indio_dev) { - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index aab752886c9..8a5857c0d80 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -469,12 +469,6 @@ error_ret: static void ad7793_ring_cleanup(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 05ae4a09426..cc39eee6b9c 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -188,12 +188,6 @@ error_ret: void ad7887_ring_cleanup(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 7980fe54bd6..e268a61269e 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -204,12 +204,6 @@ error_ret: void ad799x_ring_cleanup(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index caa63cb07ab..d4db91d6e06 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -195,11 +195,6 @@ error_ret: void max1363_ring_cleanup(struct iio_dev *indio_dev) { /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index ccfd558d090..7012f8ce8fd 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -230,6 +230,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, bool notinuse = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); + /* Prevent the module being removed whilst attached to a trigger */ + __module_get(pf->indio_dev->info->driver_module); pf->irq = iio_trigger_get_irq(trig); ret = request_threaded_irq(pf->irq, pf->h, pf->thread, pf->type, pf->name, @@ -256,6 +258,7 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, } iio_trigger_put_irq(trig, pf->irq); free_irq(pf->irq, pf); + module_put(pf->indio_dev->info->driver_module); error_ret: return ret; diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index c29beec5e21..2dec53220ef 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -127,12 +127,6 @@ static const struct iio_ring_setup_ops ade7758_ring_setup_ops = { void ade7758_unconfigure_ring(struct iio_dev *indio_dev) { - /* ensure that the trigger has been detached */ - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); iio_sw_rb_free(indio_dev->ring); } From 6aea1c364cde5b28b551844b7b8925f523310a18 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:38 +0100 Subject: [PATCH 0507/1519] staging:iio:rename trigger_consumer.h to indicate it is core only. Need this out the way to create a trigger_consumer.h that actually is for trigger consumers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/{trigger_consumer.h => iio_core_trigger.h} | 0 drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/industrialio-trigger.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename drivers/staging/iio/{trigger_consumer.h => iio_core_trigger.h} (100%) diff --git a/drivers/staging/iio/trigger_consumer.h b/drivers/staging/iio/iio_core_trigger.h similarity index 100% rename from drivers/staging/iio/trigger_consumer.h rename to drivers/staging/iio/iio_core_trigger.h diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index cf268bc2ee1..ed8a6df5bf4 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -22,8 +22,8 @@ #include #include #include "iio.h" -#include "trigger_consumer.h" #include "iio_core.h" +#include "iio_core_trigger.h" #define IIO_ID_PREFIX "device" #define IIO_ID_FORMAT IIO_ID_PREFIX "%d" diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 7012f8ce8fd..8fafeb8a8b8 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -18,7 +18,7 @@ #include "iio.h" #include "trigger.h" #include "iio_core.h" -#include "trigger_consumer.h" +#include "iio_core_trigger.h" /* RFC - Question of approach * Make the common case (single sensor single trigger) From 3f72395ee595a2a2fe1ed01c006c4f0cce313512 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:39 +0100 Subject: [PATCH 0508/1519] staging:iio: spit trigger.h into provider and consumer parts. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 2 +- drivers/staging/iio/accel/adis16203_ring.c | 2 +- drivers/staging/iio/accel/adis16204_ring.c | 2 +- drivers/staging/iio/accel/adis16209_ring.c | 2 +- drivers/staging/iio/accel/adis16240_ring.c | 2 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 1 + drivers/staging/iio/adc/ad7192.c | 1 + drivers/staging/iio/adc/ad7298_ring.c | 2 +- drivers/staging/iio/adc/ad7476_ring.c | 2 +- drivers/staging/iio/adc/ad7606_ring.c | 2 +- drivers/staging/iio/adc/ad7793.c | 1 + drivers/staging/iio/adc/ad7887_ring.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 2 +- drivers/staging/iio/adc/max1363_ring.c | 2 +- drivers/staging/iio/gyro/adis16260_ring.c | 2 +- drivers/staging/iio/imu/adis16400_ring.c | 2 +- drivers/staging/iio/industrialio-trigger.c | 1 + drivers/staging/iio/meter/ade7758_ring.c | 2 +- drivers/staging/iio/trigger.h | 42 +---------------- drivers/staging/iio/trigger_consumer.h | 52 ++++++++++++++++++++++ 20 files changed, 71 insertions(+), 55 deletions(-) create mode 100644 drivers/staging/iio/trigger_consumer.h diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 880c4901b0f..4b433c53e5c 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16201.h" diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index 4398fd90a17..993e239f942 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16203.h" /** diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 385e3503f96..847f43858f5 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16204.h" /** diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 1652f15afa4..f889fe72f33 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16209.h" /** diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 9d4ba15e138..051ba643d34 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16240.h" /** diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 7f7dca46eca..5c6fe13408b 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -9,6 +9,7 @@ #include "../ring_sw.h" #include "../kfifo_buf.h" #include "../trigger.h" +#include "../trigger_consumer.h" #include "lis3l02dq.h" /** diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index fd379082878..adf6d95dd34 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -22,6 +22,7 @@ #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7192.h" diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 5b87926ca7d..741818c0b82 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -14,7 +14,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7298.h" diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index 41d6b8d59dd..b109afb8984 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -16,7 +16,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7476.h" diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 1c563ec22ac..e6424300c8e 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -14,7 +14,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7606.h" diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 8a5857c0d80..1bcb3ebb1bc 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -22,6 +22,7 @@ #include "../ring_generic.h" #include "../ring_sw.h" #include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7793.h" diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index cc39eee6b9c..6b3daf41e0c 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -15,7 +15,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ad7887.h" diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index e268a61269e..8f1fc52560f 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -19,7 +19,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ad799x.h" diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index d4db91d6e06..be601e07639 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../ring_generic.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "max1363.h" diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 36f72c32d35..10f8a666226 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -6,7 +6,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16260.h" /** diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 56385d3baeb..3fc24037db2 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -7,7 +7,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "adis16400.h" /** diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 8fafeb8a8b8..1013442e228 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -19,6 +19,7 @@ #include "trigger.h" #include "iio_core.h" #include "iio_core_trigger.h" +#include "trigger_consumer.h" /* RFC - Question of approach * Make the common case (single sensor single trigger) diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 2dec53220ef..1e2a09643a3 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -13,7 +13,7 @@ #include "../iio.h" #include "../ring_sw.h" -#include "../trigger.h" +#include "../trigger_consumer.h" #include "ade7758.h" /** diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 010da1ddde3..56f8bafa3a3 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -73,29 +73,6 @@ struct iio_trigger { struct mutex pool_lock; }; -/** - * struct iio_poll_func - poll function pair - * - * @indio_dev: data specific to device (passed into poll func) - * @h: the function that is actually run on trigger - * @thread: threaded interrupt part - * @type: the type of interrupt (basically if oneshot) - * @name: name used to identify the trigger consumer. - * @irq: the corresponding irq as allocated from the - * trigger pool - * @timestamp: some devices need a timestamp grabbed as soon - * as possible after the trigger - hence handler - * passes it via here. - **/ -struct iio_poll_func { - struct iio_dev *indio_dev; - irqreturn_t (*h)(int irq, void *p); - irqreturn_t (*thread)(int irq, void *p); - int type; - char *name; - int irq; - s64 timestamp; -}; static inline struct iio_trigger *to_iio_trigger(struct device *d) { @@ -151,7 +128,7 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, **/ void iio_trigger_poll(struct iio_trigger *trig, s64 time); void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time); -void iio_trigger_notify_done(struct iio_trigger *trig); + irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); @@ -176,23 +153,6 @@ static inline void iio_trigger_put_irq(struct iio_trigger *trig, int irq) mutex_unlock(&trig->pool_lock); }; -struct iio_poll_func -*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), - irqreturn_t (*thread)(int irq, void *p), - int type, - struct iio_dev *indio_dev, - const char *fmt, - ...); -void iio_dealloc_pollfunc(struct iio_poll_func *pf); -irqreturn_t iio_pollfunc_store_time(int irq, void *p); - -/* - * Two functions for common case where all that happens is a pollfunc - * is attached and detached from a trigger - */ -int iio_triggered_ring_postenable(struct iio_dev *indio_dev); -int iio_triggered_ring_predisable(struct iio_dev *indio_dev); - struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) __attribute__((format(printf, 1, 2))); void iio_free_trigger(struct iio_trigger *trig); diff --git a/drivers/staging/iio/trigger_consumer.h b/drivers/staging/iio/trigger_consumer.h new file mode 100644 index 00000000000..418e0bd5f4c --- /dev/null +++ b/drivers/staging/iio/trigger_consumer.h @@ -0,0 +1,52 @@ +/* The industrial I/O core, trigger consumer functions + * + * Copyright (c) 2008-2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +/** + * struct iio_poll_func - poll function pair + * + * @indio_dev: data specific to device (passed into poll func) + * @h: the function that is actually run on trigger + * @thread: threaded interrupt part + * @type: the type of interrupt (basically if oneshot) + * @name: name used to identify the trigger consumer. + * @irq: the corresponding irq as allocated from the + * trigger pool + * @timestamp: some devices need a timestamp grabbed as soon + * as possible after the trigger - hence handler + * passes it via here. + **/ +struct iio_poll_func { + struct iio_dev *indio_dev; + irqreturn_t (*h)(int irq, void *p); + irqreturn_t (*thread)(int irq, void *p); + int type; + char *name; + int irq; + s64 timestamp; +}; + + +struct iio_poll_func +*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), + irqreturn_t (*thread)(int irq, void *p), + int type, + struct iio_dev *indio_dev, + const char *fmt, + ...); +void iio_dealloc_pollfunc(struct iio_poll_func *pf); +irqreturn_t iio_pollfunc_store_time(int irq, void *p); + +void iio_trigger_notify_done(struct iio_trigger *trig); + +/* + * Two functions for common case where all that happens is a pollfunc + * is attached and detached from a trigger + */ +int iio_triggered_ring_postenable(struct iio_dev *indio_dev); +int iio_triggered_ring_predisable(struct iio_dev *indio_dev); From cb6c89a094df3823a1797b880e5dfda2fbfcd584 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:40 +0100 Subject: [PATCH 0509/1519] staging:iio:trigger core. Trivial code cleanups. Stop exporting functions only intended for core usage. Return void from function which can never return anything other than 0. Trivial stype cleanups. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core_trigger.h | 5 ++--- drivers/staging/iio/industrialio-trigger.c | 22 +++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/iio/iio_core_trigger.h b/drivers/staging/iio/iio_core_trigger.h index 9d52d963777..3e5195a82bc 100644 --- a/drivers/staging/iio/iio_core_trigger.h +++ b/drivers/staging/iio/iio_core_trigger.h @@ -19,7 +19,7 @@ int iio_device_register_trigger_consumer(struct iio_dev *dev_info); * iio_device_unregister_trigger_consumer() - reverse the registration process * @dev_info: iio_dev associated with the device that consumed the trigger **/ -int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info); +void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info); #else @@ -36,9 +36,8 @@ static int iio_device_register_trigger_consumer(struct iio_dev *dev_info) * iio_device_unregister_trigger_consumer() - reverse the registration process * @dev_info: iio_dev associated with the device that consumed the trigger **/ -static int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +static void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) { - return 0; }; #endif /* CONFIG_TRIGGER_CONSUMER */ diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 1013442e228..72ea1067cc3 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -174,13 +174,12 @@ static struct iio_trigger *iio_trigger_find_by_name(const char *name, void iio_trigger_poll(struct iio_trigger *trig, s64 time) { int i; - if (!trig->use_count) { + if (!trig->use_count) for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) if (trig->subirqs[i].enabled) { trig->use_count++; generic_handle_irq(trig->subirq_base + i); } - } } EXPORT_SYMBOL(iio_trigger_poll); @@ -322,12 +321,10 @@ static ssize_t iio_trigger_read_current(struct device *dev, char *buf) { struct iio_dev *dev_info = dev_get_drvdata(dev); - int len = 0; + if (dev_info->trig) - len = sprintf(buf, - "%s\n", - dev_info->trig->name); - return len; + return sprintf(buf, "%s\n", dev_info->trig->name); + return 0; } /** @@ -496,23 +493,18 @@ EXPORT_SYMBOL(iio_free_trigger); int iio_device_register_trigger_consumer(struct iio_dev *dev_info) { - int ret; - ret = sysfs_create_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); - return ret; + return sysfs_create_group(&dev_info->dev.kobj, + &iio_trigger_consumer_attr_group); } -EXPORT_SYMBOL(iio_device_register_trigger_consumer); -int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) { /* Clean up and associated but not attached triggers references */ if (dev_info->trig) iio_put_trigger(dev_info->trig); sysfs_remove_group(&dev_info->dev.kobj, &iio_trigger_consumer_attr_group); - return 0; } -EXPORT_SYMBOL(iio_device_unregister_trigger_consumer); int iio_triggered_ring_postenable(struct iio_dev *indio_dev) { From 208b813c04ef7e628783cc62eeb1a140ae25bd19 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:41 +0100 Subject: [PATCH 0510/1519] staging:iio:trigger push functions that don't need to be generaly available down into the core. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 30 +++++++++++++---- drivers/staging/iio/trigger.h | 39 ---------------------- 2 files changed, 24 insertions(+), 45 deletions(-) diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 72ea1067cc3..f1ece8619e8 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -215,6 +215,26 @@ void iio_trigger_notify_done(struct iio_trigger *trig) EXPORT_SYMBOL(iio_trigger_notify_done); /* Trigger Consumer related functions */ +static int iio_trigger_get_irq(struct iio_trigger *trig) +{ + int ret; + mutex_lock(&trig->pool_lock); + ret = bitmap_find_free_region(trig->pool, + CONFIG_IIO_CONSUMERS_PER_TRIGGER, + ilog2(1)); + mutex_unlock(&trig->pool_lock); + if (ret >= 0) + ret += trig->subirq_base; + + return ret; +} + +static void iio_trigger_put_irq(struct iio_trigger *trig, int irq) +{ + mutex_lock(&trig->pool_lock); + clear_bit(irq - trig->subirq_base, trig->pool); + mutex_unlock(&trig->pool_lock); +} /* Complexity in here. With certain triggers (datardy) an acknowledgement * may be needed if the pollfuncs do not include the data read for the @@ -223,8 +243,8 @@ EXPORT_SYMBOL(iio_trigger_notify_done); * the relevant function is in there may be the best option. */ /* Worth protecting against double additions?*/ -int iio_trigger_attach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf) +static int iio_trigger_attach_poll_func(struct iio_trigger *trig, + struct iio_poll_func *pf) { int ret = 0; bool notinuse @@ -241,10 +261,9 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, return ret; } -EXPORT_SYMBOL(iio_trigger_attach_poll_func); -int iio_trigger_dettach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf) +static int iio_trigger_dettach_poll_func(struct iio_trigger *trig, + struct iio_poll_func *pf) { int ret = 0; bool no_other_users @@ -263,7 +282,6 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, error_ret: return ret; } -EXPORT_SYMBOL(iio_trigger_dettach_poll_func); irqreturn_t iio_pollfunc_store_time(int irq, void *p) { diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 56f8bafa3a3..722fc338f36 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -103,23 +103,6 @@ int iio_trigger_register(struct iio_trigger *trig_info); **/ void iio_trigger_unregister(struct iio_trigger *trig_info); -/** - * iio_trigger_attach_poll_func() - add a function pair to be run on trigger - * @trig: trigger to which the function pair are being added - * @pf: poll function pair - **/ -int iio_trigger_attach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf); - -/** - * iio_trigger_dettach_poll_func() - remove function pair from those to be - * run on trigger - * @trig: trigger from which the function is being removed - * @pf: poll function pair - **/ -int iio_trigger_dettach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf); - /** * iio_trigger_poll() - called on a trigger occurring * @trig: trigger which occurred @@ -129,30 +112,8 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, void iio_trigger_poll(struct iio_trigger *trig, s64 time); void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time); - irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); -static inline int iio_trigger_get_irq(struct iio_trigger *trig) -{ - int ret; - mutex_lock(&trig->pool_lock); - ret = bitmap_find_free_region(trig->pool, - CONFIG_IIO_CONSUMERS_PER_TRIGGER, - ilog2(1)); - mutex_unlock(&trig->pool_lock); - if (ret >= 0) - ret += trig->subirq_base; - - return ret; -}; - -static inline void iio_trigger_put_irq(struct iio_trigger *trig, int irq) -{ - mutex_lock(&trig->pool_lock); - clear_bit(irq - trig->subirq_base, trig->pool); - mutex_unlock(&trig->pool_lock); -}; - struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) __attribute__((format(printf, 1, 2))); void iio_free_trigger(struct iio_trigger *trig); From f686e9affba24cfdf94fb155aaeb36a1e14719f1 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Wed, 24 Aug 2011 20:23:07 +0200 Subject: [PATCH 0511/1519] staging: nvec: convert to use platform register and mfdcells This patch converts the nvec to use mfd cells and improves the registration of the platform driver. The child drivers are also converted to use mfd cells and platform registration. Signed-off-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 168 +++++++++++++++++++------------- drivers/staging/nvec/nvec.h | 13 +-- drivers/staging/nvec/nvec_kbd.c | 19 +++- drivers/staging/nvec/nvec_ps2.c | 19 +++- 4 files changed, 138 insertions(+), 81 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 72258e8c64c..efdc8dbbac6 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "nvec.h" static unsigned char EC_DISABLE_EVENT_REPORTING[] = {'\x04','\x00','\x00'}; @@ -30,6 +31,25 @@ static unsigned char EC_GET_FIRMWARE_VERSION[] = {'\x07','\x15'}; static struct nvec_chip *nvec_power_handle; +static struct mfd_cell nvec_devices[] = { + { + .name = "nvec-kbd", + .id = 1, + }, + { + .name = "nvec-mouse", + .id = 1, + }, + { + .name = "nvec-power", + .id = 1, + }, + { + .name = "nvec-power", + .id = 2, + }, +}; + int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, unsigned int events) { @@ -139,7 +159,7 @@ static void nvec_dispatch(struct work_struct *work) } else { parse_msg(nvec, msg); if((!msg) || (!msg->data)) - dev_warn(nvec->dev, "attempt access zero pointer"); + dev_warn(nvec->dev, "attempt access zero pointer\n"); else { kfree(msg->data); kfree(msg); @@ -148,16 +168,16 @@ static void nvec_dispatch(struct work_struct *work) } } -static irqreturn_t i2c_interrupt(int irq, void *dev) +static irqreturn_t nvec_interrupt(int irq, void *dev) { unsigned long status; unsigned long received; unsigned char to_send; struct nvec_msg *msg; struct nvec_chip *nvec = (struct nvec_chip *)dev; - unsigned char *i2c_regs = nvec->i2c_regs; + void __iomem *base = nvec->base; - status = readl(i2c_regs + I2C_SL_STATUS); + status = readl(base + I2C_SL_STATUS); if(!(status & I2C_SL_IRQ)) { @@ -222,7 +242,7 @@ static irqreturn_t i2c_interrupt(int irq, void *dev) nvec->state = NVEC_WAIT; } } - writel(to_send, i2c_regs + I2C_SL_RCVD); + writel(to_send, base + I2C_SL_RCVD); gpio_set_value(nvec->gpio, 1); @@ -230,10 +250,10 @@ static irqreturn_t i2c_interrupt(int irq, void *dev) goto handled; } else { - received = readl(i2c_regs + I2C_SL_RCVD); + received = readl(base + I2C_SL_RCVD); //Workaround? if(status & RCVD) { - writel(0, i2c_regs + I2C_SL_RCVD); + writel(0, base + I2C_SL_RCVD); goto handled; } @@ -258,37 +278,26 @@ handled: return IRQ_HANDLED; } -static int __devinit nvec_add_subdev(struct nvec_chip *nvec, struct nvec_subdev *subdev) -{ - struct platform_device *pdev; - - pdev = platform_device_alloc(subdev->name, subdev->id); - pdev->dev.parent = nvec->dev; - pdev->dev.platform_data = subdev->platform_data; - - return platform_device_add(pdev); -} - -static void tegra_init_i2c_slave(struct nvec_platform_data *pdata, unsigned char *i2c_regs, - struct clk *i2c_clk) +static void tegra_init_i2c_slave(struct nvec_chip *nvec) { u32 val; - clk_enable(i2c_clk); - tegra_periph_reset_assert(i2c_clk); + clk_enable(nvec->i2c_clk); + + tegra_periph_reset_assert(nvec->i2c_clk); udelay(2); - tegra_periph_reset_deassert(i2c_clk); + tegra_periph_reset_deassert(nvec->i2c_clk); - writel(pdata->i2c_addr>>1, i2c_regs + I2C_SL_ADDR1); - writel(0, i2c_regs + I2C_SL_ADDR2); + writel(nvec->i2c_addr>>1, nvec->base + I2C_SL_ADDR1); + writel(0, nvec->base + I2C_SL_ADDR2); - writel(0x1E, i2c_regs + I2C_SL_DELAY_COUNT); + writel(0x1E, nvec->base + I2C_SL_DELAY_COUNT); val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN | (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT); - writel(val, i2c_regs + I2C_CNFG); - writel(I2C_SL_NEWL, i2c_regs + I2C_SL_CNFG); + writel(val, nvec->base + I2C_CNFG); + writel(I2C_SL_NEWL, nvec->base + I2C_SL_CNFG); - clk_disable(i2c_clk); + clk_disable(nvec->i2c_clk); } static void nvec_power_off(void) @@ -299,12 +308,14 @@ static void nvec_power_off(void) static int __devinit tegra_nvec_probe(struct platform_device *pdev) { - int err, i, ret; + int err, ret; struct clk *i2c_clk; struct nvec_platform_data *pdata = pdev->dev.platform_data; struct nvec_chip *nvec; struct nvec_msg *msg; - unsigned char *i2c_regs; + struct resource *res; + struct resource *iomem; + void __iomem *base; nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL); if(nvec == NULL) { @@ -314,49 +325,51 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) platform_set_drvdata(pdev, nvec); nvec->dev = &pdev->dev; nvec->gpio = pdata->gpio; - nvec->irq = pdata->irq; + nvec->i2c_addr = pdata->i2c_addr; -/* - i2c_clk=clk_get_sys(NULL, "i2c"); - if(IS_ERR_OR_NULL(i2c_clk)) - printk(KERN_ERR"No such clock tegra-i2c.2\n"); - else - clk_enable(i2c_clk); -*/ - i2c_regs = ioremap(pdata->base, pdata->size); - if(!i2c_regs) { - dev_err(nvec->dev, "failed to ioremap registers\n"); - goto failed; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "no mem resource?\n"); + return -ENODEV; } - nvec->i2c_regs = i2c_regs; - - i2c_clk = clk_get_sys(pdata->clock, NULL); - if(IS_ERR_OR_NULL(i2c_clk)) { - dev_err(nvec->dev, "failed to get clock tegra-i2c.2\n"); - goto failed; + iomem = request_mem_region(res->start, resource_size(res), pdev->name); + if (!iomem) { + dev_err(&pdev->dev, "I2C region already claimed\n"); + return -EBUSY; } - tegra_init_i2c_slave(pdata, i2c_regs, i2c_clk); + base = ioremap(iomem->start, resource_size(iomem)); + if (!base) { + dev_err(&pdev->dev, "Can't ioremap I2C region\n"); + return -ENOMEM; + } - err = request_irq(nvec->irq, i2c_interrupt, IRQF_DISABLED, "nvec", nvec); - if(err) { - dev_err(nvec->dev, "couldn't request irq"); - goto failed; + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!res) { + dev_err(&pdev->dev, "no irq resource?\n"); + ret = -ENODEV; + goto err_iounmap; + } + + i2c_clk = clk_get_sys("tegra-i2c.2", NULL); + if (IS_ERR(i2c_clk)) { + dev_err(nvec->dev, "failed to get controller clock\n"); + goto err_iounmap; } clk_enable(i2c_clk); clk_set_rate(i2c_clk, 8*80000); + nvec->base = base; + nvec->irq = res->start; + nvec->i2c_clk = i2c_clk; + /* Set the gpio to low when we've got something to say */ err = gpio_request(nvec->gpio, "nvec gpio"); if(err < 0) dev_err(nvec->dev, "couldn't request gpio\n"); - tegra_gpio_enable(nvec->gpio); - gpio_direction_output(nvec->gpio, 1); - gpio_set_value(nvec->gpio, 1); - ATOMIC_INIT_NOTIFIER_HEAD(&nvec->notifier_list); init_completion(&nvec->sync_write); @@ -366,20 +379,21 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) INIT_WORK(&nvec->rx_work, nvec_dispatch); INIT_WORK(&nvec->tx_work, nvec_request_master); + err = request_irq(nvec->irq, nvec_interrupt, 0, "nvec", nvec); + if (err) { + dev_err(nvec->dev, "couldn't request irq\n"); + goto failed; + } + + tegra_init_i2c_slave(nvec); + + gpio_direction_output(nvec->gpio, 1); + gpio_set_value(nvec->gpio, 1); + /* enable event reporting */ nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, sizeof(EC_ENABLE_EVENT_REPORTING)); - nvec_kbd_init(nvec); -#ifdef CONFIG_SERIO_NVEC_PS2 - nvec_ps2(nvec); -#endif - - /* setup subdevs */ - for (i = 0; i < pdata->num_subdevs; i++) { - ret = nvec_add_subdev(nvec, &pdata->subdevs[i]); - } - nvec->nvec_status_notifier.notifier_call = nvec_status_notifier; nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0); @@ -396,6 +410,11 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) kfree(msg->data); kfree(msg); + ret = mfd_add_devices(nvec->dev, -1, nvec_devices, + ARRAY_SIZE(nvec_devices), base, 0); + if(ret) + dev_err(nvec->dev, "error adding subdevices\n"); + /* unmute speakers? */ nvec_write_async(nvec, "\x0d\x10\x59\x94", 4); @@ -407,6 +426,8 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) return 0; +err_iounmap: + iounmap(base); failed: kfree(nvec); return -ENOMEM; @@ -414,7 +435,15 @@ failed: static int __devexit tegra_nvec_remove(struct platform_device *pdev) { - // TODO: unregister + struct nvec_chip *nvec = platform_get_drvdata(pdev); + + nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3); + mfd_remove_devices(nvec->dev); + free_irq(nvec->irq, &nvec_interrupt); + iounmap(nvec->base); + gpio_free(nvec->gpio); + kfree(nvec); + return 0; } @@ -436,6 +465,7 @@ static int tegra_nvec_resume(struct platform_device *pdev) { struct nvec_chip *nvec = platform_get_drvdata(pdev); dev_dbg(nvec->dev, "resuming\n"); + tegra_init_i2c_slave(nvec); nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3); return 0; diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index a2d82dce62d..d9ff721d1d8 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -45,21 +45,17 @@ struct nvec_subdev { }; struct nvec_platform_data { - int num_subdevs; int i2c_addr; int gpio; - int irq; - int base; - int size; - char clock[16]; - struct nvec_subdev *subdevs; }; struct nvec_chip { struct device *dev; int gpio; int irq; - unsigned char *i2c_regs; + int i2c_addr; + void __iomem *base; + struct clk *i2c_clk; nvec_state state; struct atomic_notifier_head notifier_list; struct list_head rx_data, tx_data; @@ -84,9 +80,6 @@ extern int nvec_unregister_notifier(struct device *dev, const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data)); -extern int nvec_ps2(struct nvec_chip *nvec); -extern int nvec_kbd_init(struct nvec_chip *nvec); - #define I2C_CNFG 0x00 #define I2C_CNFG_PACKET_MODE_EN (1<<10) #define I2C_CNFG_NEW_MASTER_SFM (1<<11) diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 04bd285cfe0..347a38c4687 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "nvec-keytable.h" #include "nvec.h" @@ -66,8 +67,9 @@ static int nvec_kbd_event(struct input_dev *dev, unsigned int type, return 0; } -int __init nvec_kbd_init(struct nvec_chip *nvec) +static int __devinit nvec_kbd_probe(struct platform_device *pdev) { + struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); int i, j, err; struct input_dev *idev; @@ -120,3 +122,18 @@ fail: input_free_device(idev); return err; } + +static struct platform_driver nvec_kbd_driver = { + .probe = nvec_kbd_probe, + .driver = { + .name = "nvec-kbd", + .owner = THIS_MODULE, + }, +}; + +static int __init nvec_kbd_init(void) +{ + return platform_driver_register(&nvec_kbd_driver); +} + +module_init(nvec_kbd_init); diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 6bb9430f352..0d3149b3e85 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "nvec.h" #define START_STREAMING {'\x06','\x03','\x01'} @@ -77,8 +78,9 @@ static int nvec_ps2_notifier(struct notifier_block *nb, } -int __init nvec_ps2(struct nvec_chip *nvec) +static int __devinit nvec_mouse_probe(struct platform_device *pdev) { + struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL); ser_dev->id.type=SERIO_8042; @@ -101,3 +103,18 @@ int __init nvec_ps2(struct nvec_chip *nvec) return 0; } + +static struct platform_driver nvec_mouse_driver = { + .probe = nvec_mouse_probe, + .driver = { + .name = "nvec-mouse", + .owner = THIS_MODULE, + }, +}; + +static int __init nvec_mouse_init(void) +{ + return platform_driver_register(&nvec_mouse_driver); +} + +module_init(nvec_mouse_init); From 883dac41534b3a16e490be36fb995f17e93bf210 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 24 Aug 2011 18:21:50 +0300 Subject: [PATCH 0512/1519] staging: xgifb: delete write-only variables Delete couple write-only variables. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 8 -------- drivers/staging/xgifb/XGI_main_26.c | 10 ---------- 2 files changed, 18 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 39893ca7814..a0c2bdb4f86 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -179,7 +179,6 @@ static int XGIfb_userom ; /*static int XGIfb_useoem = -1; */ /* global flags */ -static int XGIfb_registered; static int XGIfb_tvmode; static int XGIfb_pdc; static int enable_dstn; @@ -193,13 +192,6 @@ static int XGIfb_crt2type = -1; /* PR: Tv plug type (for overriding autodetection) */ static int XGIfb_tvplug = -1; -static unsigned char XGIfb_detectedpdc; - -static unsigned char XGIfb_detectedlcda = 0xff; - - - - /* TW: For ioctl XGIFB_GET_INFO */ /* XGIfb_info XGIfbinfo; */ diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 4415d4aedbe..847d246ef6f 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2046,8 +2046,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (XGIfb_off) return -ENXIO; - XGIfb_registered = 0; - memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); if (!fb_info) @@ -2307,12 +2305,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } } - XGIfb_detectedpdc = 0; - - XGIfb_detectedlcda = 0xff; - - /* TW: Try to find about LCDA */ - if ((XGIhw_ext.ujVBChipID == VB_CHIP_302B) || (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) || (XGIhw_ext.ujVBChipID == VB_CHIP_302LV)) { @@ -2476,8 +2468,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error_1; } - XGIfb_registered = 1; - printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); From 8145f9febb46a4feb61cd42bdfaecb4c78d787e1 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 24 Aug 2011 18:21:51 +0300 Subject: [PATCH 0513/1519] staging: xgifb: delete driver version information Delete version information, it's just noise and serves no purpose. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 4 ---- drivers/staging/xgifb/XGI_main_26.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index a0c2bdb4f86..af95ad71d0f 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -11,10 +11,6 @@ #define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while (0) -#define VER_MAJOR 0 -#define VER_MINOR 8 -#define VER_LEVEL 1 - #ifndef PCI_VENDOR_ID_XG #define PCI_VENDOR_ID_XG 0x18CA #endif diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 847d246ef6f..922acbc52ed 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2468,9 +2468,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error_1; } - printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", - fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); - dumpVGAReg(); return 0; From b64aa655c2a74716c00f7ee60d86a3d715ba1ca6 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 24 Aug 2011 18:21:52 +0300 Subject: [PATCH 0514/1519] staging: xgifb: delete an empty string Delete a string which is always empty. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index af95ad71d0f..59f741136cf 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -163,7 +163,6 @@ static struct fb_fix_screeninfo XGIfb_fix = { .xpanstep = 1, .ypanstep = 1, }; -static char myid[20]; static u32 pseudo_palette[17]; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 922acbc52ed..7b36b7ea464 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1481,8 +1481,6 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, DEBUGPRN("inside get_fix"); memset(fix, 0, sizeof(struct fb_fix_screeninfo)); - strcpy(fix->id, myid); - fix->smem_start = xgi_video_info.video_base; fix->smem_len = xgi_video_info.video_size; From 1ec3ba93c5fad9dca0dab272491c625fe6a2f67d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Aug 2011 14:44:13 -0700 Subject: [PATCH 0515/1519] Staging: remove drivers/char/scc.h as it should have gone a while ago This was needed by one of the generic serial drivers that was removed a while ago. No one even noticed that the driver could not be built properly while it was in the staging directory. So this removed the unneeded .h file. Reported-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/scc.h | 613 --------------------------------------------- 1 file changed, 613 deletions(-) delete mode 100644 drivers/char/scc.h diff --git a/drivers/char/scc.h b/drivers/char/scc.h deleted file mode 100644 index 341b1142bea..00000000000 --- a/drivers/char/scc.h +++ /dev/null @@ -1,613 +0,0 @@ -/* - * atari_SCC.h: Definitions for the Am8530 Serial Communications Controller - * - * Copyright 1994 Roman Hodek - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive - * for more details. - * - */ - - -#ifndef _SCC_H -#define _SCC_H - -#include - -/* Special configuration ioctls for the Atari SCC5380 Serial - * Communications Controller - */ - -/* ioctl command codes */ - -#define TIOCGATSCC 0x54c0 /* get SCC configuration */ -#define TIOCSATSCC 0x54c1 /* set SCC configuration */ -#define TIOCDATSCC 0x54c2 /* reset configuration to defaults */ - -/* Clock sources */ - -#define CLK_RTxC 0 -#define CLK_TRxC 1 -#define CLK_PCLK 2 - -/* baud_bases for the common clocks in the Atari. These are the real - * frequencies divided by 16. - */ - -#define SCC_BAUD_BASE_TIMC 19200 /* 0.3072 MHz from TT-MFP, Timer C */ -#define SCC_BAUD_BASE_BCLK 153600 /* 2.4576 MHz */ -#define SCC_BAUD_BASE_PCLK4 229500 /* 3.6720 MHz */ -#define SCC_BAUD_BASE_PCLK 503374 /* 8.0539763 MHz */ -#define SCC_BAUD_BASE_NONE 0 /* for not connected or unused - * clock sources */ - -/* The SCC clock configuration structure */ - -struct scc_clock_config { - unsigned RTxC_base; /* base_baud of RTxC */ - unsigned TRxC_base; /* base_baud of TRxC */ - unsigned PCLK_base; /* base_baud of PCLK, both channels! */ - struct { - unsigned clksrc; /* CLK_RTxC, CLK_TRxC or CLK_PCLK */ - unsigned divisor; /* divisor for base baud, valid values: - * see below */ - } baud_table[17]; /* For 50, 75, 110, 135, 150, 200, 300, - * 600, 1200, 1800, 2400, 4800, 9600, - * 19200, 38400, 57600 and 115200 bps. - * The last two could be replaced by - * other rates > 38400 if they're not - * possible. - */ -}; - -/* The following divisors are valid: - * - * - CLK_RTxC: 1 or even (1, 2 and 4 are the direct modes, > 4 use - * the BRG) - * - * - CLK_TRxC: 1, 2 or 4 (no BRG, only direct modes possible) - * - * - CLK_PCLK: >= 4 and even (no direct modes, only BRG) - * - */ - -struct scc_port { - struct gs_port gs; - volatile unsigned char *ctrlp; - volatile unsigned char *datap; - int x_char; /* xon/xoff character */ - int c_dcd; - int channel; - struct scc_port *port_a; /* Reference to port A and B */ - struct scc_port *port_b; /* structs for reg access */ -}; - -#define SCC_MAGIC 0x52696368 - -/***********************************************************************/ -/* */ -/* Register Names */ -/* */ -/***********************************************************************/ - -/* The SCC documentation gives no explicit names to the registers, - * they're just called WR0..15 and RR0..15. To make the source code - * better readable and make the transparent write reg read access (see - * below) possible, I christen them here with self-invented names. - * Note that (real) read registers are assigned numbers 16..31. WR7' - * has number 33. - */ - -#define COMMAND_REG 0 /* wo */ -#define INT_AND_DMA_REG 1 /* wo */ -#define INT_VECTOR_REG 2 /* rw, common to both channels */ -#define RX_CTRL_REG 3 /* rw */ -#define AUX1_CTRL_REG 4 /* rw */ -#define TX_CTRL_REG 5 /* rw */ -#define SYNC_ADR_REG 6 /* wo */ -#define SYNC_CHAR_REG 7 /* wo */ -#define SDLC_OPTION_REG 33 /* wo */ -#define TX_DATA_REG 8 /* wo */ -#define MASTER_INT_CTRL 9 /* wo, common to both channels */ -#define AUX2_CTRL_REG 10 /* rw */ -#define CLK_CTRL_REG 11 /* wo */ -#define TIMER_LOW_REG 12 /* rw */ -#define TIMER_HIGH_REG 13 /* rw */ -#define DPLL_CTRL_REG 14 /* wo */ -#define INT_CTRL_REG 15 /* rw */ - -#define STATUS_REG 16 /* ro */ -#define SPCOND_STATUS_REG 17 /* wo */ -/* RR2 is WR2 for Channel A, Channel B gives vector + current status: */ -#define CURR_VECTOR_REG 18 /* Ch. B only, Ch. A for rw */ -#define INT_PENDING_REG 19 /* Channel A only! */ -/* RR4 is WR4, if b6(MR7') == 1 */ -/* RR5 is WR5, if b6(MR7') == 1 */ -#define FS_FIFO_LOW_REG 22 /* ro */ -#define FS_FIFO_HIGH_REG 23 /* ro */ -#define RX_DATA_REG 24 /* ro */ -/* RR9 is WR3, if b6(MR7') == 1 */ -#define DPLL_STATUS_REG 26 /* ro */ -/* RR11 is WR10, if b6(MR7') == 1 */ -/* RR12 is WR12 */ -/* RR13 is WR13 */ -/* RR14 not present */ -/* RR15 is WR15 */ - - -/***********************************************************************/ -/* */ -/* Register Values */ -/* */ -/***********************************************************************/ - - -/* WR0: COMMAND_REG "CR" */ - -#define CR_RX_CRC_RESET 0x40 -#define CR_TX_CRC_RESET 0x80 -#define CR_TX_UNDERRUN_RESET 0xc0 - -#define CR_EXTSTAT_RESET 0x10 -#define CR_SEND_ABORT 0x18 -#define CR_ENAB_INT_NEXT_RX 0x20 -#define CR_TX_PENDING_RESET 0x28 -#define CR_ERROR_RESET 0x30 -#define CR_HIGHEST_IUS_RESET 0x38 - - -/* WR1: INT_AND_DMA_REG "IDR" */ - -#define IDR_EXTSTAT_INT_ENAB 0x01 -#define IDR_TX_INT_ENAB 0x02 -#define IDR_PARERR_AS_SPCOND 0x04 - -#define IDR_RX_INT_DISAB 0x00 -#define IDR_RX_INT_FIRST 0x08 -#define IDR_RX_INT_ALL 0x10 -#define IDR_RX_INT_SPCOND 0x18 -#define IDR_RX_INT_MASK 0x18 - -#define IDR_WAITREQ_RX 0x20 -#define IDR_WAITREQ_IS_REQ 0x40 -#define IDR_WAITREQ_ENAB 0x80 - - -/* WR3: RX_CTRL_REG "RCR" */ - -#define RCR_RX_ENAB 0x01 -#define RCR_DISCARD_SYNC_CHARS 0x02 -#define RCR_ADDR_SEARCH 0x04 -#define RCR_CRC_ENAB 0x08 -#define RCR_SEARCH_MODE 0x10 -#define RCR_AUTO_ENAB_MODE 0x20 - -#define RCR_CHSIZE_MASK 0xc0 -#define RCR_CHSIZE_5 0x00 -#define RCR_CHSIZE_6 0x40 -#define RCR_CHSIZE_7 0x80 -#define RCR_CHSIZE_8 0xc0 - - -/* WR4: AUX1_CTRL_REG "A1CR" */ - -#define A1CR_PARITY_MASK 0x03 -#define A1CR_PARITY_NONE 0x00 -#define A1CR_PARITY_ODD 0x01 -#define A1CR_PARITY_EVEN 0x03 - -#define A1CR_MODE_MASK 0x0c -#define A1CR_MODE_SYNCR 0x00 -#define A1CR_MODE_ASYNC_1 0x04 -#define A1CR_MODE_ASYNC_15 0x08 -#define A1CR_MODE_ASYNC_2 0x0c - -#define A1CR_SYNCR_MODE_MASK 0x30 -#define A1CR_SYNCR_MONOSYNC 0x00 -#define A1CR_SYNCR_BISYNC 0x10 -#define A1CR_SYNCR_SDLC 0x20 -#define A1CR_SYNCR_EXTCSYNC 0x30 - -#define A1CR_CLKMODE_MASK 0xc0 -#define A1CR_CLKMODE_x1 0x00 -#define A1CR_CLKMODE_x16 0x40 -#define A1CR_CLKMODE_x32 0x80 -#define A1CR_CLKMODE_x64 0xc0 - - -/* WR5: TX_CTRL_REG "TCR" */ - -#define TCR_TX_CRC_ENAB 0x01 -#define TCR_RTS 0x02 -#define TCR_USE_CRC_CCITT 0x00 -#define TCR_USE_CRC_16 0x04 -#define TCR_TX_ENAB 0x08 -#define TCR_SEND_BREAK 0x10 - -#define TCR_CHSIZE_MASK 0x60 -#define TCR_CHSIZE_5 0x00 -#define TCR_CHSIZE_6 0x20 -#define TCR_CHSIZE_7 0x40 -#define TCR_CHSIZE_8 0x60 - -#define TCR_DTR 0x80 - - -/* WR7': SLDC_OPTION_REG "SOR" */ - -#define SOR_AUTO_TX_ENAB 0x01 -#define SOR_AUTO_EOM_RESET 0x02 -#define SOR_AUTO_RTS_MODE 0x04 -#define SOR_NRZI_DISAB_HIGH 0x08 -#define SOR_ALT_DTRREQ_TIMING 0x10 -#define SOR_READ_CRC_CHARS 0x20 -#define SOR_EXTENDED_REG_ACCESS 0x40 - - -/* WR9: MASTER_INT_CTRL "MIC" */ - -#define MIC_VEC_INCL_STAT 0x01 -#define MIC_NO_VECTOR 0x02 -#define MIC_DISAB_LOWER_CHAIN 0x04 -#define MIC_MASTER_INT_ENAB 0x08 -#define MIC_STATUS_HIGH 0x10 -#define MIC_IGN_INTACK 0x20 - -#define MIC_NO_RESET 0x00 -#define MIC_CH_A_RESET 0x40 -#define MIC_CH_B_RESET 0x80 -#define MIC_HARD_RESET 0xc0 - - -/* WR10: AUX2_CTRL_REG "A2CR" */ - -#define A2CR_SYNC_6 0x01 -#define A2CR_LOOP_MODE 0x02 -#define A2CR_ABORT_ON_UNDERRUN 0x04 -#define A2CR_MARK_IDLE 0x08 -#define A2CR_GO_ACTIVE_ON_POLL 0x10 - -#define A2CR_CODING_MASK 0x60 -#define A2CR_CODING_NRZ 0x00 -#define A2CR_CODING_NRZI 0x20 -#define A2CR_CODING_FM1 0x40 -#define A2CR_CODING_FM0 0x60 - -#define A2CR_PRESET_CRC_1 0x80 - - -/* WR11: CLK_CTRL_REG "CCR" */ - -#define CCR_TRxCOUT_MASK 0x03 -#define CCR_TRxCOUT_XTAL 0x00 -#define CCR_TRxCOUT_TXCLK 0x01 -#define CCR_TRxCOUT_BRG 0x02 -#define CCR_TRxCOUT_DPLL 0x03 - -#define CCR_TRxC_OUTPUT 0x04 - -#define CCR_TXCLK_MASK 0x18 -#define CCR_TXCLK_RTxC 0x00 -#define CCR_TXCLK_TRxC 0x08 -#define CCR_TXCLK_BRG 0x10 -#define CCR_TXCLK_DPLL 0x18 - -#define CCR_RXCLK_MASK 0x60 -#define CCR_RXCLK_RTxC 0x00 -#define CCR_RXCLK_TRxC 0x20 -#define CCR_RXCLK_BRG 0x40 -#define CCR_RXCLK_DPLL 0x60 - -#define CCR_RTxC_XTAL 0x80 - - -/* WR14: DPLL_CTRL_REG "DCR" */ - -#define DCR_BRG_ENAB 0x01 -#define DCR_BRG_USE_PCLK 0x02 -#define DCR_DTRREQ_IS_REQ 0x04 -#define DCR_AUTO_ECHO 0x08 -#define DCR_LOCAL_LOOPBACK 0x10 - -#define DCR_DPLL_EDGE_SEARCH 0x20 -#define DCR_DPLL_ERR_RESET 0x40 -#define DCR_DPLL_DISAB 0x60 -#define DCR_DPLL_CLK_BRG 0x80 -#define DCR_DPLL_CLK_RTxC 0xa0 -#define DCR_DPLL_FM 0xc0 -#define DCR_DPLL_NRZI 0xe0 - - -/* WR15: INT_CTRL_REG "ICR" */ - -#define ICR_OPTIONREG_SELECT 0x01 -#define ICR_ENAB_BRG_ZERO_INT 0x02 -#define ICR_USE_FS_FIFO 0x04 -#define ICR_ENAB_DCD_INT 0x08 -#define ICR_ENAB_SYNC_INT 0x10 -#define ICR_ENAB_CTS_INT 0x20 -#define ICR_ENAB_UNDERRUN_INT 0x40 -#define ICR_ENAB_BREAK_INT 0x80 - - -/* RR0: STATUS_REG "SR" */ - -#define SR_CHAR_AVAIL 0x01 -#define SR_BRG_ZERO 0x02 -#define SR_TX_BUF_EMPTY 0x04 -#define SR_DCD 0x08 -#define SR_SYNC_ABORT 0x10 -#define SR_CTS 0x20 -#define SR_TX_UNDERRUN 0x40 -#define SR_BREAK 0x80 - - -/* RR1: SPCOND_STATUS_REG "SCSR" */ - -#define SCSR_ALL_SENT 0x01 -#define SCSR_RESIDUAL_MASK 0x0e -#define SCSR_PARITY_ERR 0x10 -#define SCSR_RX_OVERRUN 0x20 -#define SCSR_CRC_FRAME_ERR 0x40 -#define SCSR_END_OF_FRAME 0x80 - - -/* RR3: INT_PENDING_REG "IPR" */ - -#define IPR_B_EXTSTAT 0x01 -#define IPR_B_TX 0x02 -#define IPR_B_RX 0x04 -#define IPR_A_EXTSTAT 0x08 -#define IPR_A_TX 0x10 -#define IPR_A_RX 0x20 - - -/* RR7: FS_FIFO_HIGH_REG "FFHR" */ - -#define FFHR_CNT_MASK 0x3f -#define FFHR_IS_FROM_FIFO 0x40 -#define FFHR_FIFO_OVERRUN 0x80 - - -/* RR10: DPLL_STATUS_REG "DSR" */ - -#define DSR_ON_LOOP 0x02 -#define DSR_ON_LOOP_SENDING 0x10 -#define DSR_TWO_CLK_MISSING 0x40 -#define DSR_ONE_CLK_MISSING 0x80 - -/***********************************************************************/ -/* */ -/* Register Access */ -/* */ -/***********************************************************************/ - - -/* The SCC needs 3.5 PCLK cycles recovery time between to register - * accesses. PCLK runs with 8 MHz on an Atari, so this delay is 3.5 * - * 125 ns = 437.5 ns. This is too short for udelay(). - * 10/16/95: A tstb st_mfp.par_dt_reg takes 600ns (sure?) and thus should be - * quite right - */ - -#define scc_reg_delay() \ - do { \ - if (MACH_IS_MVME16x || MACH_IS_BVME6000 || MACH_IS_MVME147) \ - __asm__ __volatile__ ( " nop; nop"); \ - else if (MACH_IS_ATARI) \ - __asm__ __volatile__ ( "tstb %0" : : "g" (*_scc_del) : "cc" );\ - } while (0) - -static unsigned char scc_shadow[2][16]; - -/* The following functions should relax the somehow complicated - * register access of the SCC. _SCCwrite() stores all written values - * (except for WR0 and WR8) in shadow registers for later recall. This - * removes the burden of remembering written values as needed. The - * extra work of storing the value doesn't count, since a delay is - * needed after a SCC access anyway. Additionally, _SCCwrite() manages - * writes to WR0 and WR8 differently, because these can be accessed - * directly with less overhead. Another special case are WR7 and WR7'. - * _SCCwrite automatically checks what of this registers is selected - * and changes b0 of WR15 if needed. - * - * _SCCread() for standard read registers is straightforward, except - * for RR2 (split into two "virtual" registers: one for the value - * written to WR2 (from the shadow) and one for the vector including - * status from RR2, Ch. B) and RR3. The latter must be read from - * Channel A, because it reads as all zeros on Ch. B. RR0 and RR8 can - * be accessed directly as before. - * - * The two inline function contain complicated switch statements. But - * I rely on regno and final_delay being constants, so gcc can reduce - * the whole stuff to just some assembler statements. - * - * _SCCwrite and _SCCread aren't intended to be used directly under - * normal circumstances. The macros SCCread[_ND] and SCCwrite[_ND] are - * for that purpose. They assume that a local variable 'port' is - * declared and pointing to the port's scc_struct entry. The - * variants with "_NB" appended should be used if no other SCC - * accesses follow immediately (within 0.5 usecs). They just skip the - * final delay nops. - * - * Please note that accesses to SCC registers should only take place - * when interrupts are turned off (at least if SCC interrupts are - * enabled). Otherwise, an interrupt could interfere with the - * two-stage accessing process. - * - */ - - -static __inline__ void _SCCwrite( - struct scc_port *port, - unsigned char *shadow, - volatile unsigned char *_scc_del, - int regno, - unsigned char val, int final_delay ) -{ - switch( regno ) { - - case COMMAND_REG: - /* WR0 can be written directly without pointing */ - *port->ctrlp = val; - break; - - case SYNC_CHAR_REG: - /* For WR7, first set b0 of WR15 to 0, if needed */ - if (shadow[INT_CTRL_REG] & ICR_OPTIONREG_SELECT) { - *port->ctrlp = 15; - shadow[INT_CTRL_REG] &= ~ICR_OPTIONREG_SELECT; - scc_reg_delay(); - *port->ctrlp = shadow[INT_CTRL_REG]; - scc_reg_delay(); - } - goto normal_case; - - case SDLC_OPTION_REG: - /* For WR7', first set b0 of WR15 to 1, if needed */ - if (!(shadow[INT_CTRL_REG] & ICR_OPTIONREG_SELECT)) { - *port->ctrlp = 15; - shadow[INT_CTRL_REG] |= ICR_OPTIONREG_SELECT; - scc_reg_delay(); - *port->ctrlp = shadow[INT_CTRL_REG]; - scc_reg_delay(); - } - *port->ctrlp = 7; - shadow[8] = val; /* WR7' shadowed at WR8 */ - scc_reg_delay(); - *port->ctrlp = val; - break; - - case TX_DATA_REG: /* WR8 */ - /* TX_DATA_REG can be accessed directly on some h/w */ - if (MACH_IS_MVME16x || MACH_IS_BVME6000 || MACH_IS_MVME147) - { - *port->ctrlp = regno; - scc_reg_delay(); - *port->ctrlp = val; - } - else - *port->datap = val; - break; - - case MASTER_INT_CTRL: - *port->ctrlp = regno; - val &= 0x3f; /* bits 6..7 are the reset commands */ - scc_shadow[0][regno] = val; - scc_reg_delay(); - *port->ctrlp = val; - break; - - case DPLL_CTRL_REG: - *port->ctrlp = regno; - val &= 0x1f; /* bits 5..7 are the DPLL commands */ - shadow[regno] = val; - scc_reg_delay(); - *port->ctrlp = val; - break; - - case 1 ... 6: - case 10 ... 13: - case 15: - normal_case: - *port->ctrlp = regno; - shadow[regno] = val; - scc_reg_delay(); - *port->ctrlp = val; - break; - - default: - printk( "Bad SCC write access to WR%d\n", regno ); - break; - - } - - if (final_delay) - scc_reg_delay(); -} - - -static __inline__ unsigned char _SCCread( - struct scc_port *port, - unsigned char *shadow, - volatile unsigned char *_scc_del, - int regno, int final_delay ) -{ - unsigned char rv; - - switch( regno ) { - - /* --- real read registers --- */ - case STATUS_REG: - rv = *port->ctrlp; - break; - - case INT_PENDING_REG: - /* RR3: read only from Channel A! */ - port = port->port_a; - goto normal_case; - - case RX_DATA_REG: - /* RR8 can be accessed directly on some h/w */ - if (MACH_IS_MVME16x || MACH_IS_BVME6000 || MACH_IS_MVME147) - { - *port->ctrlp = 8; - scc_reg_delay(); - rv = *port->ctrlp; - } - else - rv = *port->datap; - break; - - case CURR_VECTOR_REG: - /* RR2 (vector including status) from Ch. B */ - port = port->port_b; - goto normal_case; - - /* --- reading write registers: access the shadow --- */ - case 1 ... 7: - case 10 ... 15: - return shadow[regno]; /* no final delay! */ - - /* WR7' is special, because it is shadowed at the place of WR8 */ - case SDLC_OPTION_REG: - return shadow[8]; /* no final delay! */ - - /* WR9 is special too, because it is common for both channels */ - case MASTER_INT_CTRL: - return scc_shadow[0][9]; /* no final delay! */ - - default: - printk( "Bad SCC read access to %cR%d\n", (regno & 16) ? 'R' : 'W', - regno & ~16 ); - break; - - case SPCOND_STATUS_REG: - case FS_FIFO_LOW_REG: - case FS_FIFO_HIGH_REG: - case DPLL_STATUS_REG: - normal_case: - *port->ctrlp = regno & 0x0f; - scc_reg_delay(); - rv = *port->ctrlp; - break; - - } - - if (final_delay) - scc_reg_delay(); - return rv; -} - -#define SCC_ACCESS_INIT(port) \ - unsigned char *_scc_shadow = &scc_shadow[port->channel][0] - -#define SCCwrite(reg,val) _SCCwrite(port,_scc_shadow,scc_del,(reg),(val),1) -#define SCCwrite_NB(reg,val) _SCCwrite(port,_scc_shadow,scc_del,(reg),(val),0) -#define SCCread(reg) _SCCread(port,_scc_shadow,scc_del,(reg),1) -#define SCCread_NB(reg) _SCCread(port,_scc_shadow,scc_del,(reg),0) - -#define SCCmod(reg,and,or) SCCwrite((reg),(SCCread(reg)&(and))|(or)) - -#endif /* _SCC_H */ From 09505184ec3d99e5993966864a4eb3b770642597 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 24 Aug 2011 19:29:57 -0500 Subject: [PATCH 0516/1519] staging: rtl8192e: Remove files that are not used For the most part, these extra files came from the previous version of the RTL8192E driver. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/internal.h | 93 - drivers/staging/rtl8192e/kmap_types.h | 20 - drivers/staging/rtl8192e/r8180_93cx6.c | 141 - drivers/staging/rtl8192e/r8180_93cx6.h | 41 - drivers/staging/rtl8192e/r8190P_hwimg.c | 4538 ---------------- drivers/staging/rtl8192e/r8190P_hwimg.h | 51 - drivers/staging/rtl8192e/r8190_rtl8256.c | 677 --- drivers/staging/rtl8192e/r8190_rtl8256.h | 29 - drivers/staging/rtl8192e/r8192E.h | 1148 ---- drivers/staging/rtl8192e/r8192E_core.c | 5039 ------------------ drivers/staging/rtl8192e/r8192E_core.c.porig | 5039 ------------------ drivers/staging/rtl8192e/r8192E_core.c.rej | 5036 ----------------- drivers/staging/rtl8192e/r8192E_dm.c | 2554 --------- drivers/staging/rtl8192e/r8192E_dm.h | 228 - drivers/staging/rtl8192e/r8192E_wx.c | 1163 ---- drivers/staging/rtl8192e/r8192E_wx.h | 18 - drivers/staging/rtl8192e/r8192_pm.c | 123 - drivers/staging/rtl8192e/r8192_pm.h | 24 - drivers/staging/rtl8192e/r819xE_cmdpkt.c | 444 -- drivers/staging/rtl8192e/r819xE_cmdpkt.h | 207 - drivers/staging/rtl8192e/r819xE_firmware.c | 351 -- drivers/staging/rtl8192e/r819xE_phy.c | 2225 -------- drivers/staging/rtl8192e/r819xE_phy.h | 131 - drivers/staging/rtl8192e/readme | 160 - 24 files changed, 29480 deletions(-) delete mode 100644 drivers/staging/rtl8192e/internal.h delete mode 100644 drivers/staging/rtl8192e/kmap_types.h delete mode 100644 drivers/staging/rtl8192e/r8180_93cx6.c delete mode 100644 drivers/staging/rtl8192e/r8180_93cx6.h delete mode 100644 drivers/staging/rtl8192e/r8190P_hwimg.c delete mode 100644 drivers/staging/rtl8192e/r8190P_hwimg.h delete mode 100644 drivers/staging/rtl8192e/r8190_rtl8256.c delete mode 100644 drivers/staging/rtl8192e/r8190_rtl8256.h delete mode 100644 drivers/staging/rtl8192e/r8192E.h delete mode 100644 drivers/staging/rtl8192e/r8192E_core.c delete mode 100644 drivers/staging/rtl8192e/r8192E_core.c.porig delete mode 100644 drivers/staging/rtl8192e/r8192E_core.c.rej delete mode 100644 drivers/staging/rtl8192e/r8192E_dm.c delete mode 100644 drivers/staging/rtl8192e/r8192E_dm.h delete mode 100644 drivers/staging/rtl8192e/r8192E_wx.c delete mode 100644 drivers/staging/rtl8192e/r8192E_wx.h delete mode 100644 drivers/staging/rtl8192e/r8192_pm.c delete mode 100644 drivers/staging/rtl8192e/r8192_pm.h delete mode 100644 drivers/staging/rtl8192e/r819xE_cmdpkt.c delete mode 100644 drivers/staging/rtl8192e/r819xE_cmdpkt.h delete mode 100644 drivers/staging/rtl8192e/r819xE_firmware.c delete mode 100644 drivers/staging/rtl8192e/r819xE_phy.c delete mode 100644 drivers/staging/rtl8192e/r819xE_phy.h delete mode 100644 drivers/staging/rtl8192e/readme diff --git a/drivers/staging/rtl8192e/internal.h b/drivers/staging/rtl8192e/internal.h deleted file mode 100644 index dab7aa26319..00000000000 --- a/drivers/staging/rtl8192e/internal.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Cryptographic API. - * - * Copyright (c) 2002 James Morris - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#ifndef _CRYPTO_INTERNAL_H -#define _CRYPTO_INTERNAL_H - - -#include -#include "rtl_crypto.h" -#include -#include -#include - -#include -#include -#include - -extern enum km_type crypto_km_types[]; - -static inline enum km_type crypto_kmap_type(int out) -{ - return crypto_km_types[(in_softirq() ? 2 : 0) + out]; -} - -static inline void *crypto_kmap(struct page *page, int out) -{ - return kmap_atomic(page, crypto_kmap_type(out)); -} - -static inline void crypto_kunmap(void *vaddr, int out) -{ - kunmap_atomic(vaddr, crypto_kmap_type(out)); -} - -static inline void crypto_yield(struct crypto_tfm *tfm) -{ - if (!in_softirq()) - cond_resched(); -} - -static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) -{ - return (void *)&tfm[1]; -} - -struct crypto_alg *crypto_alg_lookup(const char *name); - -#ifdef CONFIG_KMOD -void crypto_alg_autoload(const char *name); -struct crypto_alg *crypto_alg_mod_lookup(const char *name); -#else -static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) -{ - return crypto_alg_lookup(name); -} -#endif - -static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm) -{ - return 0; -} - -static inline void crypto_free_hmac_block(struct crypto_tfm *tfm) -{ } - -#ifdef CONFIG_PROC_FS -void __init crypto_init_proc(void); -#else -static inline void crypto_init_proc(void) -{ } -#endif - -int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); -int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); -int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags); - -int crypto_init_digest_ops(struct crypto_tfm *tfm); -int crypto_init_cipher_ops(struct crypto_tfm *tfm); -int crypto_init_compress_ops(struct crypto_tfm *tfm); - -void crypto_exit_digest_ops(struct crypto_tfm *tfm); -void crypto_exit_cipher_ops(struct crypto_tfm *tfm); -void crypto_exit_compress_ops(struct crypto_tfm *tfm); - -#endif /* _CRYPTO_INTERNAL_H */ diff --git a/drivers/staging/rtl8192e/kmap_types.h b/drivers/staging/rtl8192e/kmap_types.h deleted file mode 100644 index de67bb01b5f..00000000000 --- a/drivers/staging/rtl8192e/kmap_types.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __KMAP_TYPES_H - -#define __KMAP_TYPES_H - - -enum km_type { - KM_BOUNCE_READ, - KM_SKB_SUNRPC_DATA, - KM_SKB_DATA_SOFTIRQ, - KM_USER0, - KM_USER1, - KM_BH_IRQ, - KM_SOFTIRQ0, - KM_SOFTIRQ1, - KM_TYPE_NR -}; - -#define _ASM_KMAP_TYPES_H - -#endif diff --git a/drivers/staging/rtl8192e/r8180_93cx6.c b/drivers/staging/rtl8192e/r8180_93cx6.c deleted file mode 100644 index 55d4f56dc42..00000000000 --- a/drivers/staging/rtl8192e/r8180_93cx6.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - This files contains card eeprom (93c46 or 93c56) programming routines, - memory is addressed by 16 bits words. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#include "r8180_93cx6.h" - -static void eprom_cs(struct r8192_priv *priv, short bit) -{ - if (bit) - write_nic_byte(priv, EPROM_CMD, - (1<epromtype == EPROM_93c56) { - addr_str[7] = addr & 1; - addr_str[6] = addr & (1<<1); - addr_str[5] = addr & (1<<2); - addr_str[4] = addr & (1<<3); - addr_str[3] = addr & (1<<4); - addr_str[2] = addr & (1<<5); - addr_str[1] = addr & (1<<6); - addr_str[0] = addr & (1<<7); - addr_len = 8; - } else { - addr_str[5] = addr & 1; - addr_str[4] = addr & (1<<1); - addr_str[3] = addr & (1<<2); - addr_str[2] = addr & (1<<3); - addr_str[1] = addr & (1<<4); - addr_str[0] = addr & (1<<5); - addr_len = 6; - } - eprom_cs(priv, 1); - eprom_ck_cycle(priv); - eprom_send_bits_string(priv, read_cmd, 3); - eprom_send_bits_string(priv, addr_str, addr_len); - - //keep chip pin D to low state while reading. - //I'm unsure if it is necessary, but anyway shouldn't hurt - eprom_w(priv, 0); - - for (i = 0; i < 16; i++) { - //eeprom needs a clk cycle between writing opcode&adr - //and reading data. (eeprom outs a dummy 0) - eprom_ck_cycle(priv); - ret |= (eprom_r(priv)<<(15-i)); - } - - eprom_cs(priv, 0); - eprom_ck_cycle(priv); - - //disable EPROM programming - write_nic_byte(priv, EPROM_CMD, - (EPROM_CMD_NORMAL< - * Released under the terms of GPL (General Public Licence) - * Parts of this driver are based on the GPL part of the official realtek driver - * - * Parts of this driver are based on the rtl8180 driver skeleton from - * Patric Schenke & Andres Salomon. - * - * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - * - * We want to thank the authors of the above mentioned projects and to - * the authors of the Ndiswrapper project. - */ - -#include "r8192E.h" -#include "r8192E_hw.h" - -#define EPROM_DELAY 10 - -#define EPROM_ANAPARAM_ADDRLWORD 0xd -#define EPROM_ANAPARAM_ADDRHWORD 0xe - -#define EPROM_RFCHIPID 0x6 -#define EPROM_TXPW_BASE 0x05 -#define EPROM_RFCHIPID_RTL8225U 5 -#define EPROM_RF_PARAM 0x4 -#define EPROM_CONFIG2 0xc - -#define EPROM_VERSION 0x1E -#define MAC_ADR 0x7 - -#define CIS 0x18 - -#define EPROM_TXPW0 0x16 -#define EPROM_TXPW2 0x1b -#define EPROM_TXPW1 0x3d - -/* Reads a 16 bits word. */ -u32 eprom_read(struct r8192_priv *priv, u32 addr); diff --git a/drivers/staging/rtl8192e/r8190P_hwimg.c b/drivers/staging/rtl8192e/r8190P_hwimg.c deleted file mode 100644 index d8c575a89de..00000000000 --- a/drivers/staging/rtl8192e/r8190P_hwimg.c +++ /dev/null @@ -1,4538 +0,0 @@ -/****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae -******************************************************************************/ -#ifndef __INC_R819XU_FIRMWARE_IMG_H -#define __INC_R819XU_FIRMWARE_IMG_H -/*Created on 2008/ 5/19, 6:38*/ - -#include "r8190P_hwimg.h" - -u8 Rtl8190PciFwBootArray[BootArrayLengthPci] = { -0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08, -0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00, -0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, -0x25,0x08,0xd8,0xdc,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff, -0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b, -0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00, -0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, -0x25,0x08,0xd8,0xdc,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0, -0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00, -0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00, -0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff, -0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01, -0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01, -0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24, -0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10, -0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, -0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10, -0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x6b,0x18, -0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,}; - -u8 Rtl8190PciFwMainArray[MainArrayLengthPci] = { -0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x1a,0x35, -0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09, -0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24, -0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0, -0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x94,0x50,0x00,0x85,0x18,0x21, -0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00, -0x27,0x82,0x94,0x5a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00, -0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x94,0x50, -0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x94,0x52,0x24,0x02,0x00,0x04, -0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x94,0x66,0xa3,0x82,0x94,0x58, -0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x94,0x6c,0xa3,0x85,0x94,0x59, -0xa7,0x82,0x94,0x5a,0xa7,0x84,0x94,0x5c,0xaf,0x84,0x94,0x68,0xa3,0x84,0x94,0x51, -0xa3,0x80,0x94,0x53,0xa3,0x80,0x94,0x54,0xa3,0x80,0x94,0x55,0xa3,0x84,0x94,0x56, -0xa3,0x85,0x94,0x57,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00, -0x27,0x84,0x94,0x78,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00, -0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0, -0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00, -0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00, -0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03, -0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11, -0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07, -0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10, -0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b, -0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20, -0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24, -0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54, -0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x74,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18, -0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x94,0x70,0x8c,0xa3,0x00,0x00, -0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a, -0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01, -0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3, -0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40, -0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x94,0x78,0x00,0x0a,0x20,0x0b, -0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01, -0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x94,0x78,0xa0,0x67,0x00,0x01, -0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07, -0x00,0x00,0x00,0x00,0x27,0x83,0x94,0x70,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x94,0x74, -0x27,0x82,0x94,0x70,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00, -0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00, -0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x8c,0x08,0x00,0x00,0xa7, -0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0x94,0x80,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10, -0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00, -0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03, -0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2, -0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09, -0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x94,0x78, -0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00, -0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04, -0x30,0x43,0x00,0x06,0x93,0x82,0x94,0x90,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21, -0x83,0x82,0x94,0x84,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f, -0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01, -0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4, -0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08, -0x24,0x02,0x00,0x01,0xaf,0x84,0x94,0xa0,0xa3,0x82,0x94,0xb0,0xa7,0x80,0x94,0xa4, -0xa7,0x80,0x94,0xa6,0xaf,0x80,0x94,0xa8,0xaf,0x80,0x94,0xac,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, -0x24,0x42,0x05,0x24,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac, -0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21, -0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x5c,0x27,0xbd,0xff,0xe0, -0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, -0x8f,0x90,0x94,0xa0,0x0c,0x00,0x02,0x90,0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a, -0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01, -0xae,0x02,0x00,0x00,0x97,0x84,0x94,0xa4,0x97,0x82,0x94,0xa6,0x3c,0x03,0xb0,0x02, -0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x94,0xa6,0xa4,0x82,0x00,0x00, -0x8f,0x84,0x94,0xa8,0x8f,0x82,0x94,0xa0,0x93,0x85,0x94,0x52,0x24,0x84,0x00,0x01, -0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03, -0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,0xaf,0x82,0x94,0xa0, -0xaf,0x84,0x94,0xa8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,0x8f,0x83,0x94,0xac, -0x8f,0x84,0x94,0x6c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b, -0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00, -0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x48,0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20, -0x8f,0x90,0x94,0xa0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21, -0x0c,0x00,0x02,0x90,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19, -0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24, -0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,0x97,0x86,0x94,0xa4, -0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00, -0x8f,0x84,0x94,0xa0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x94,0xa6,0x00,0xc2,0x30,0x21, -0x8f,0x82,0x94,0xa8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24, -0x24,0x42,0x00,0x01,0xa7,0x85,0x94,0xa6,0xaf,0x84,0x94,0xa0,0xaf,0x82,0x94,0xa8, -0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, -0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14, -0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc, -0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08, -0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01, -0x00,0x02,0x10,0x80,0x24,0x63,0x08,0x94,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14, -0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x8c,0xa4,0x00,0x00,0x0c,0x00,0x1f,0x4f,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xdc, -0x00,0x00,0x00,0x00,0x0c,0x00,0x2c,0x0d,0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xdc, -0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x06,0x93,0x82,0x80,0x18,0x00,0x00,0x00,0x00, -0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x93,0x83,0x88,0x07,0x24,0x02,0x00,0x01, -0xa3,0x82,0x80,0x11,0xa3,0x83,0x80,0x19,0xa3,0x83,0x80,0x18,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x93,0x82,0x80,0x19,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf6, -0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xf3,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff, -0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,0x8f,0x82,0x80,0x14,0xa3,0x85,0x8b,0xcb, -0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40, -0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0, -0x00,0x05,0x10,0x40,0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00, -0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0, -0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0, -0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40, -0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00, -0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10, -0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,0x27,0x84,0x8b,0xd4,0x00,0x44,0x10,0x21, -0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x86,0x94,0xa0,0x8f,0x82,0x80,0x14, -0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21, -0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,0xa3,0x82,0x8b,0xd3,0xa3,0x83,0x8b,0xd2, -0x27,0x8a,0x8b,0xd0,0x00,0x00,0x20,0x21,0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80, -0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01, -0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00, -0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80, -0x97,0x83,0x94,0xa6,0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c, -0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18, -0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c, -0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00, -0xaf,0x86,0x94,0xa0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e, -0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x8f,0x86,0x94,0xa0,0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08, -0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12, -0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21, -0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, -0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08, -0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x48,0x28,0x24,0x97,0x83,0x94,0xa6, -0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21, -0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, -0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00, -0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x94,0xa0, -0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38, -0x93,0x82,0x94,0xb0,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01, -0x8f,0x82,0x94,0xa8,0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18, -0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x94,0xa4, -0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x94,0xac, -0xa7,0x80,0x94,0xa6,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x8f,0x86,0x94,0xa0,0x8f,0x82,0x94,0xa8, -0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a, -0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,0x27,0x89,0x8b,0xa0,0x24,0xe2,0x00,0x01, -0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a, -0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f, -0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xa6,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, -0xa7,0x82,0x8b,0xa6,0x90,0xa3,0x00,0x15,0x97,0x82,0x8b,0xa8,0x00,0x03,0x1e,0x00, -0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,0xa7,0x82,0x8b,0xa8,0x8c,0xa4,0x00,0x20, -0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54, -0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xac, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xac,0x84,0xa3,0x00,0x06, -0x8f,0x82,0x8b,0xbc,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0xbc, -0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,0xaf,0x82,0x94,0xa8,0x10,0x60,0x00,0x09, -0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05, -0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,0xa3,0x83,0x8b,0xa2,0xa3,0x82,0x8b,0xa3, -0x90,0xa2,0x00,0x18,0x93,0x83,0x8b,0xcb,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0xa7,0x82,0x8b,0xb6,0xa3,0x83,0x8b,0xc4,0x27,0x89,0x8b,0xa0, -0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, -0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a, -0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x94,0xa6, -0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21, -0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, -0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00, -0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x94,0xa0, -0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, -0x0c,0x00,0x02,0x2e,0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xdd, -0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0xae,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, -0xa7,0x82,0x8b,0xae,0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0xc0,0x00,0x00,0x00,0x00, -0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0xc0,0x08,0x00,0x02,0xd5,0x25,0x42,0x00,0x01, -0x97,0x82,0x8b,0xaa,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xaa, -0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0xb8,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, -0xaf,0x82,0x8b,0xb8,0x08,0x00,0x02,0xd5,0x25,0x42,0x00,0x01,0x97,0x82,0x8b,0xa4, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0xa4,0x08,0x00,0x02,0xbd, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20, -0x8f,0x8a,0x94,0xa0,0x3c,0x02,0x00,0x10,0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21, -0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c, -0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42, -0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25, -0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a, -0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34, -0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18, -0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20, -0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff, -0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, -0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00, -0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,0x97,0x83,0x94,0xa6,0x97,0x85,0x94,0xa4, -0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06, -0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00, -0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24, -0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x8a,0x94,0xa0,0x10,0xa2,0x00,0x03, -0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20, -0x24,0x42,0x0d,0xdc,0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, -0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21, -0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14, -0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08, -0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02, -0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76, -0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, -0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2, -0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, -0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24, -0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04, -0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2, -0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02, -0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26, -0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02, -0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00, -0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00, -0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x92,0x01,0x20,0x20,0x21,0x08,0x00,0x03,0x9d, -0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07, -0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,0x27,0x83,0x94,0x50,0x00,0x43,0x10,0x21, -0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xc4,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40, -0x27,0x83,0x94,0x58,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xc4, -0x00,0x07,0x22,0x02,0x27,0x82,0x94,0x50,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00, -0x08,0x00,0x03,0xc4,0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21, -0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00, -0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e, -0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xc4, -0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00, -0x08,0x00,0x03,0xc3,0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00, -0x08,0x00,0x03,0xc3,0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00, -0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x03,0xf5,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x03,0xfa,0x3c,0x02,0xb0,0x0a, -0x08,0x00,0x03,0xfe,0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08, -0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02, -0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00, -0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24, -0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00, -0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24, -0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02, -0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02, -0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01, -0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69, -0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15, -0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21, -0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24, -0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,0x08,0x00,0x03,0x9d,0x02,0x51,0x10,0x21, -0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24, -0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0x9d, -0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00, -0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, -0x08,0x00,0x03,0x9c,0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21, -0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17, -0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x94,0x50, -0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27, -0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0x9c, -0xac,0x82,0x00,0x18,0x27,0x83,0x94,0x58,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21, -0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24, -0x00,0x45,0x10,0x25,0x08,0x00,0x03,0x9c,0xa4,0x82,0x00,0x02,0x27,0x83,0x94,0x50, -0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x52, -0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f, -0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, -0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x3f, -0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00, -0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x48,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a, -0x08,0x00,0x04,0x75,0x00,0x43,0x18,0x21,0x97,0x85,0x94,0xa4,0x3c,0x07,0xb0,0x02, -0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20, -0x24,0x42,0x12,0x38,0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07, -0x97,0x82,0x94,0xa6,0x97,0x85,0x94,0xa4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8, -0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08, -0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25, -0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x94,0xa0, -0xa7,0x82,0x94,0xa4,0xa7,0x80,0x94,0xa6,0xaf,0x80,0x94,0xa8,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, -0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07, -0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03, -0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14, -0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27, -0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x04,0xd9,0xac,0x62,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, -0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07, -0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a, -0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10, -0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09, -0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, -0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, -0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24, -0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00, -0x30,0xa9,0x00,0xff,0x27,0x83,0x94,0x50,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01, -0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21, -0x00,0x05,0x20,0x40,0x27,0x82,0x94,0x50,0x00,0x05,0x28,0x80,0x27,0x83,0x94,0x58, -0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27, -0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00, -0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18, -0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25, -0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00, -0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00, -0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25, -0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x02,0xb0,0x02, -0x34,0x42,0x00,0x08,0x3c,0x03,0xb0,0x02,0xaf,0x82,0x8c,0x78,0xaf,0x83,0x8c,0x7c, -0xa7,0x80,0x8c,0x80,0xa7,0x80,0x8c,0x82,0xaf,0x80,0x8c,0x84,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xbf,0x00,0x20,0x94,0x82,0x00,0x04, -0x3c,0x05,0xff,0x8f,0x00,0x80,0x18,0x21,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x0a, -0x34,0xa5,0xff,0xff,0x90,0x84,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xfc, -0x00,0x64,0x20,0x21,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x10,0x2b, -0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x0c,0x00,0x07,0xc9,0x00,0x00,0x00,0x00, -0x08,0x00,0x05,0x4a,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c, -0x8f,0x90,0x94,0xa0,0x0c,0x00,0x31,0x0a,0x00,0x80,0x90,0x21,0x00,0x40,0x88,0x21, -0x93,0x82,0x82,0x28,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x24,0x02,0x00,0x01, -0xa3,0x82,0x82,0x28,0x24,0x03,0x00,0x05,0x24,0x02,0x00,0x04,0xa3,0x83,0x8c,0x73, -0xa3,0x82,0x8c,0x72,0xa7,0x80,0x82,0x2a,0x00,0x00,0x28,0x21,0x27,0x86,0x8c,0x70, -0x00,0x05,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, -0x30,0x65,0xff,0xff,0xae,0x04,0x00,0x00,0x10,0xa0,0xff,0xfa,0x00,0x05,0x10,0x80, -0x8f,0x83,0x94,0xa0,0x97,0x82,0x94,0xa6,0x24,0x05,0x8f,0xff,0x24,0x63,0x00,0x04, -0x00,0x65,0x18,0x24,0x26,0x04,0x00,0x04,0x24,0x42,0x00,0x04,0xaf,0x83,0x94,0xa0, -0xa7,0x82,0x94,0xa6,0x00,0x85,0x80,0x24,0x97,0x84,0x82,0x2a,0x27,0x93,0x80,0x34, -0x02,0x40,0x28,0x21,0x00,0x93,0x20,0x21,0x0c,0x00,0x31,0x8e,0x02,0x20,0x30,0x21, -0x97,0x87,0x82,0x2a,0x24,0x02,0x00,0x52,0x00,0xf1,0x18,0x21,0xa7,0x83,0x82,0x2a, -0x82,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x06,0x00,0x60,0x38,0x21, -0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x28,0x82,0x43,0x00,0x01,0x24,0x02,0x00,0x54,0x14,0x62,0xff,0xf8, -0x24,0x02,0x00,0x4c,0x82,0x43,0x00,0x02,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf4, -0x00,0x00,0x00,0x00,0x30,0xe6,0xff,0xff,0x10,0xc0,0x00,0x0c,0x00,0x00,0x28,0x21, -0x02,0x60,0x48,0x21,0x24,0x08,0x8f,0xff,0x00,0xa9,0x10,0x21,0x8c,0x44,0x00,0x00, -0x24,0xa3,0x00,0x04,0x30,0x65,0xff,0xff,0x26,0x02,0x00,0x04,0x00,0xa6,0x18,0x2b, -0xae,0x04,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x48,0x80,0x24,0x97,0x83,0x94,0xa6, -0x97,0x85,0x94,0xa4,0x3c,0x02,0xb0,0x02,0x00,0x67,0x18,0x21,0x00,0xa2,0x28,0x21, -0x3c,0x04,0xb0,0x06,0xa7,0x83,0x94,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, -0x8f,0x82,0x94,0xa0,0x8c,0x86,0x00,0x00,0x30,0xe5,0xff,0xff,0x24,0x03,0x8f,0xff, -0x00,0x45,0x10,0x21,0x3c,0x04,0x0f,0x00,0x00,0x43,0x10,0x24,0x00,0xc4,0x30,0x24, -0x3c,0x03,0x04,0x00,0xaf,0x82,0x94,0xa0,0x10,0xc3,0xff,0xd1,0x00,0x00,0x00,0x00, -0x0c,0x00,0x04,0x8e,0x00,0x00,0x00,0x00,0xa3,0x80,0x82,0x28,0x08,0x00,0x05,0x88, -0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x97,0x83,0x8c,0x80,0x8f,0x87,0x8c,0x78, -0x3c,0x06,0xff,0xff,0xac,0x43,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x3c,0x03,0x80,0x00, -0x24,0xe5,0x00,0x08,0xac,0x43,0x00,0x04,0x8f,0x82,0x8c,0x7c,0x34,0xc6,0x1f,0xff, -0x3c,0x03,0x00,0x40,0x30,0x42,0x0f,0xff,0x3c,0x04,0xb0,0x06,0x00,0x02,0x10,0xc2, -0x00,0x43,0x10,0x25,0x00,0xa6,0x28,0x24,0x34,0x84,0x80,0x18,0x27,0xbd,0xff,0xf8, -0xac,0x82,0x00,0x00,0xaf,0x85,0x8c,0x78,0xaf,0x87,0x8c,0x7c,0xa7,0x80,0x8c,0x80, -0xa7,0x80,0x8c,0x82,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0, -0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x8f,0x91,0x8c,0x78, -0x00,0x80,0x80,0x21,0xaf,0xbf,0x00,0x1c,0x0c,0x00,0x06,0x78,0x00,0xa0,0x90,0x21, -0x97,0x82,0x8c,0x80,0x36,0x10,0x12,0x00,0x26,0x2a,0x00,0x04,0x24,0x4c,0x00,0x14, -0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x0a,0x24,0x09,0x8f,0xff,0x8f,0x82,0x80,0x20, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x80,0x20,0x8f,0xbf,0x00,0x1c, -0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, -0x8e,0x44,0x00,0x1c,0x86,0x47,0x00,0x06,0x97,0x86,0x8c,0x82,0x8c,0x82,0x00,0x08, -0x00,0x07,0x3c,0x00,0x8f,0x85,0x8c,0x78,0x00,0x02,0x11,0x02,0x30,0x42,0x40,0x00, -0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x8c,0x82,0x00,0x04,0x82,0x43,0x00,0x15, -0x01,0x49,0x88,0x24,0x00,0x02,0x14,0xc2,0x00,0x03,0x1a,0x00,0x00,0x02,0x14,0x00, -0x00,0x62,0x80,0x25,0xae,0x30,0x00,0x00,0x92,0x43,0x00,0x13,0x92,0x44,0x00,0x10, -0x96,0x50,0x00,0x1a,0x00,0x03,0x1c,0x00,0x00,0x04,0x26,0x00,0x02,0x03,0x80,0x25, -0x26,0x22,0x00,0x04,0x00,0x49,0x88,0x24,0x02,0x04,0x80,0x25,0xae,0x30,0x00,0x00, -0x92,0x42,0x00,0x0f,0x92,0x43,0x00,0x11,0x26,0x24,0x00,0x04,0x00,0x02,0x12,0x00, -0x00,0x89,0x88,0x24,0x00,0x62,0x80,0x25,0x02,0x07,0x80,0x25,0x26,0x22,0x00,0x04, -0xae,0x30,0x00,0x00,0x00,0x49,0x88,0x24,0xae,0x20,0x00,0x00,0x8f,0x82,0x80,0x1c, -0x24,0xc6,0x00,0x01,0x24,0xa5,0x00,0x14,0x30,0xc8,0xff,0xff,0x3c,0x0b,0xb0,0x03, -0x00,0xa9,0x28,0x24,0x24,0x42,0x00,0x01,0x2d,0x08,0x00,0x0a,0xaf,0x85,0x8c,0x78, -0xa7,0x8c,0x8c,0x80,0xaf,0x82,0x80,0x1c,0xa7,0x86,0x8c,0x82,0x11,0x00,0x00,0x07, -0x35,0x6b,0x01,0x08,0x8f,0x82,0x8c,0x84,0x8d,0x63,0x00,0x00,0x24,0x42,0x04,0x00, -0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xc1,0x00,0x00,0x00,0x00,0x0c,0x00,0x05,0xbd, -0x00,0x00,0x00,0x00,0x08,0x00,0x05,0xf3,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8, -0xaf,0xbf,0x00,0x10,0x0c,0x00,0x06,0x78,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0, -0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c, -0x8f,0x90,0x8c,0x78,0x0c,0x00,0x06,0x78,0x00,0x80,0x90,0x21,0x97,0x82,0x8c,0x80, -0x24,0x11,0x8f,0xff,0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x06,0x26,0x03,0x00,0x04, -0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x71,0x80,0x24, -0xae,0x00,0x00,0x00,0x8e,0x44,0x00,0x08,0x26,0x02,0x00,0x04,0x0c,0x00,0x06,0x86, -0x00,0x51,0x80,0x24,0x97,0x86,0x8c,0x82,0x8f,0x83,0x8c,0x78,0xae,0x02,0x00,0x00, -0x97,0x82,0x8c,0x80,0x24,0xc6,0x00,0x01,0x8e,0x47,0x00,0x0c,0x24,0x63,0x00,0x10, -0x30,0xc5,0xff,0xff,0x26,0x04,0x00,0x04,0x3c,0x08,0xb0,0x03,0x00,0x71,0x18,0x24, -0x00,0x91,0x80,0x24,0x24,0x42,0x00,0x10,0x2c,0xa5,0x00,0x0a,0x35,0x08,0x01,0x08, -0xae,0x07,0x00,0x00,0xaf,0x83,0x8c,0x78,0xa7,0x82,0x8c,0x80,0xa7,0x86,0x8c,0x82, -0x10,0xa0,0x00,0x07,0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x84,0x8d,0x03,0x00,0x00, -0x24,0x42,0x04,0x00,0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00, -0x0c,0x00,0x05,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x06,0x4c,0x00,0x00,0x00,0x00, -0x97,0x82,0x8c,0x82,0x3c,0x03,0xb0,0x03,0x14,0x40,0x00,0x09,0x34,0x63,0x01,0x08, -0x8c,0x62,0x00,0x00,0x8f,0x83,0x8c,0x7c,0xa7,0x80,0x8c,0x80,0xaf,0x82,0x8c,0x84, -0xac,0x60,0x00,0x00,0x8f,0x82,0x8c,0x7c,0x00,0x00,0x00,0x00,0xac,0x40,0x00,0x04, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00, -0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24, -0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08, -0x00,0x44,0x10,0x25,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00,0x10,0x40,0x00,0x0c, -0x00,0x80,0x28,0x21,0x24,0x62,0xff,0x9f,0x30,0x42,0x00,0xff,0x2c,0x42,0x00,0x1a, -0x10,0x40,0x00,0x02,0x24,0x63,0xff,0xe0,0xa0,0xa3,0x00,0x00,0x24,0xa5,0x00,0x01, -0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6,0x00,0x40,0x18,0x21, -0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00, -0x10,0x40,0x00,0x0c,0x00,0x80,0x28,0x21,0x24,0x62,0xff,0xbf,0x30,0x42,0x00,0xff, -0x2c,0x42,0x00,0x1a,0x10,0x40,0x00,0x02,0x24,0x63,0x00,0x20,0xa0,0xa3,0x00,0x00, -0x24,0xa5,0x00,0x01,0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6, -0x00,0x40,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x27,0xbd,0xff,0xe8, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x24,0x10,0xff,0xff,0x0c,0x00,0x2e,0x4a, -0x00,0x00,0x00,0x00,0x10,0x50,0xff,0xfd,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03, -0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x27,0xbd,0xff,0xc8,0xaf,0xb3,0x00,0x1c,0x00,0x00,0x98,0x21,0xaf,0xb1,0x00,0x14, -0x02,0x65,0x88,0x2b,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x34,0xaf,0xbe,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb4,0x00,0x20, -0xaf,0xb2,0x00,0x18,0x00,0xa0,0xb0,0x21,0xaf,0xa4,0x00,0x38,0x00,0xc0,0xa8,0x21, -0x12,0x20,0x00,0x17,0x00,0x80,0x80,0x21,0x24,0x17,0xff,0xff,0x24,0x1e,0x00,0x0a, -0x0c,0x00,0x2e,0x4a,0x00,0x00,0x00,0x00,0x10,0x57,0x00,0x0f,0x00,0x02,0x16,0x00, -0x00,0x02,0x26,0x03,0x10,0x9e,0x00,0x0e,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x34, -0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x25,0x24,0x02,0x00,0x09,0x10,0x82,0x00,0x13, -0x00,0x00,0x90,0x21,0xa2,0x04,0x00,0x00,0x26,0x73,0x00,0x01,0x16,0xa0,0x00,0x0b, -0x26,0x10,0x00,0x01,0x02,0x76,0x88,0x2b,0x16,0x20,0xff,0xed,0x00,0x00,0x00,0x00, -0x7b,0xbe,0x01,0xbc,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x0c,0x00,0x2e,0x3d, -0x02,0x76,0x88,0x2b,0x08,0x00,0x06,0xe6,0x00,0x00,0x00,0x00,0x24,0x14,0x00,0x20, -0xa2,0x14,0x00,0x00,0x26,0x52,0x00,0x01,0x24,0x04,0x00,0x20,0x26,0x73,0x00,0x01, -0x16,0xa0,0x00,0x06,0x26,0x10,0x00,0x01,0x2a,0x42,0x00,0x08,0x10,0x40,0xff,0xea, -0x02,0x76,0x88,0x2b,0x08,0x00,0x06,0xf5,0xa2,0x14,0x00,0x00,0x0c,0x00,0x2e,0x3d, -0x00,0x00,0x00,0x00,0x08,0x00,0x06,0xfb,0x2a,0x42,0x00,0x08,0x8f,0xa2,0x00,0x38, -0x00,0x00,0x00,0x00,0x12,0x02,0xff,0xe0,0x00,0x00,0x00,0x00,0x26,0x10,0xff,0xff, -0x12,0xa0,0xff,0xdc,0x26,0x73,0xff,0xff,0x0c,0x00,0x2e,0x3d,0x24,0x04,0x00,0x08, -0x0c,0x00,0x2e,0x3d,0x24,0x04,0x00,0x20,0x08,0x00,0x06,0xef,0x24,0x04,0x00,0x08, -0x08,0x00,0x06,0xe8,0xa2,0x00,0x00,0x00,0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x16,0x00,0x00,0x30,0x21,0x24,0x07,0x00,0x20, -0x00,0x03,0x1e,0x03,0x10,0x67,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x15, -0x00,0x00,0x00,0x00,0x10,0x67,0x00,0x0b,0x24,0xc6,0x00,0x01,0x10,0x60,0x00,0x0a, -0x00,0x02,0x1e,0x00,0x24,0x05,0x00,0x20,0x24,0x84,0x00,0x01,0x80,0x83,0x00,0x00, -0x90,0x82,0x00,0x00,0x10,0x65,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa, -0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0x14,0x60,0xff,0xed,0x00,0x00,0x00,0x00, -0x28,0xc3,0x00,0x08,0x24,0x02,0x00,0x07,0x00,0x43,0x30,0x0a,0x03,0xe0,0x00,0x08, -0x00,0xc0,0x10,0x21,0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,0x08,0x00,0x07,0x2a, -0x00,0x02,0x1e,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14,0x27,0x91,0x8c,0x88, -0xaf,0xb0,0x00,0x10,0x24,0x06,0x00,0x20,0x00,0x80,0x80,0x21,0x00,0x00,0x28,0x21, -0xaf,0xbf,0x00,0x18,0x0c,0x00,0x31,0x84,0x02,0x20,0x20,0x21,0x82,0x02,0x00,0x00, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1f,0x00,0x00,0x30,0x21,0x02,0x20,0x20,0x21, -0x24,0x09,0x00,0x20,0x24,0x08,0x00,0x20,0x24,0x07,0x00,0x08,0xac,0x90,0x00,0x00, -0x82,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x49,0x00,0x0a,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x08,0x24,0x03,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, -0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa, -0x00,0x00,0x00,0x00,0xa2,0x00,0x00,0x00,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, -0x92,0x03,0x00,0x00,0x10,0x48,0x00,0x0c,0x24,0x05,0x00,0x20,0x24,0xc6,0x00,0x01, -0x10,0xc7,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x03,0x16,0x00,0x14,0x40,0xff,0xe7, -0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x27,0x82,0x8c,0x88, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00, -0x92,0x03,0x00,0x00,0x10,0x45,0xff,0xfc,0x00,0x00,0x00,0x00,0x08,0x00,0x07,0x5c, -0x24,0xc6,0x00,0x01,0x00,0x80,0x30,0x21,0x90,0x84,0x00,0x00,0x00,0x00,0x38,0x21, -0x10,0x80,0x00,0x19,0x24,0xc6,0x00,0x01,0x24,0x82,0xff,0xd0,0x30,0x42,0x00,0xff, -0x2c,0x43,0x00,0x0a,0x14,0x60,0x00,0x0c,0x00,0x07,0x19,0x00,0x24,0x83,0xff,0x9f, -0x24,0x82,0xff,0xa9,0x24,0x88,0xff,0xc9,0x2c,0x63,0x00,0x06,0x24,0x84,0xff,0xbf, -0x2c,0x84,0x00,0x06,0x14,0x60,0x00,0x03,0x30,0x42,0x00,0xff,0x10,0x80,0x00,0x0e, -0x31,0x02,0x00,0xff,0x00,0x07,0x19,0x00,0x00,0x62,0x18,0x21,0x00,0x67,0x10,0x2b, -0x14,0x40,0x00,0x07,0x00,0x00,0x20,0x21,0x90,0xc4,0x00,0x00,0x00,0x60,0x38,0x21, -0x14,0x80,0xff,0xe9,0x24,0xc6,0x00,0x01,0xac,0xa7,0x00,0x00,0x24,0x04,0x00,0x01, -0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x07,0x8c,0x00,0x00,0x20,0x21, -0x00,0x00,0x20,0x21,0x27,0x85,0x94,0xc0,0x24,0x82,0x00,0x01,0x00,0x04,0x18,0x80, -0x30,0x44,0x00,0xff,0x00,0x65,0x18,0x21,0x2c,0x82,0x00,0x0b,0x14,0x40,0xff,0xfa, -0xac,0x60,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x84,0x8d,0x08, -0xaf,0x85,0x8d,0x0c,0xaf,0x86,0x8d,0x10,0xaf,0x87,0x8d,0x14,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x98,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, -0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0x27,0x84,0x8c,0xa8,0xaf,0x82,0x84,0x98, -0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x80,0x84,0x98,0x0c,0x00,0x07,0xf6, -0x00,0x00,0x00,0x00,0x00,0x40,0x18,0x21,0x28,0x44,0x00,0x08,0x24,0x02,0x00,0x07, -0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x80,0xff,0xf3,0x24,0x02,0x00,0x08, -0x27,0x84,0x8c,0xa8,0x14,0x62,0xff,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0x95, -0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0xa8,0x0c,0x00,0x08,0x54,0x00,0x00,0x00,0x00, -0x8f,0x83,0x84,0x9c,0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01, -0xaf,0x83,0x84,0x9c,0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0x90,0x08,0x00,0x07,0xaa, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xbf,0x00,0x38,0x8c,0x85,0x00,0x0c, -0x8c,0x88,0x00,0x08,0x18,0xa0,0x00,0x0e,0x00,0x00,0x30,0x21,0x24,0x87,0x00,0x08, -0x27,0xa9,0x00,0x10,0x00,0x06,0x10,0x80,0x00,0x06,0x19,0x00,0x00,0x49,0x10,0x21, -0x14,0xc0,0x00,0x1f,0x00,0x83,0x18,0x21,0xaf,0xa7,0x00,0x10,0x24,0xc2,0x00,0x01, -0x30,0x46,0x00,0xff,0x00,0xc5,0x18,0x2a,0x14,0x60,0xff,0xf7,0x00,0x06,0x10,0x80, -0x29,0x02,0x00,0x0a,0x14,0x40,0x00,0x05,0x00,0x08,0x18,0x40,0x8f,0xbf,0x00,0x38, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x00,0x68,0x18,0x21, -0x27,0x82,0x83,0x94,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21,0x8c,0x62,0x00,0x10, -0x01,0x00,0x20,0x21,0x00,0x40,0xf8,0x09,0x27,0xa6,0x00,0x10,0x8f,0x83,0x84,0xb0, -0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01,0xaf,0x83,0x84,0xb0, -0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0xa4,0x08,0x00,0x07,0xdf,0x00,0x00,0x00,0x00, -0x08,0x00,0x07,0xd7,0xac,0x43,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14, -0xaf,0xbf,0x00,0x18,0x00,0x80,0x88,0x21,0x0c,0x00,0x1a,0xb9,0xaf,0xb0,0x00,0x10, -0x00,0x40,0x20,0x21,0x24,0x02,0xff,0xff,0x10,0x82,0x00,0x1f,0x24,0x03,0x00,0x06, -0x8f,0x85,0x84,0xc4,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x0a,0x24,0x02,0x00,0x08, -0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x3b,0x28,0x82,0x00,0x03,0x10,0x40,0x00,0x32, -0x24,0x02,0x00,0x1b,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x13,0x24,0x03,0x00,0x08, -0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x23,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x18, -0x02,0x25,0x10,0x21,0x24,0xa3,0x00,0x01,0xa0,0x44,0x00,0x00,0xaf,0x83,0x84,0xc4, -0x18,0x60,0x00,0x08,0x24,0x02,0x00,0x43,0x82,0x23,0x00,0x00,0x00,0x00,0x00,0x00, -0x10,0x62,0x00,0x0a,0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x0c,0x00,0x1a,0xb5, -0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x06,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x04,0x80,0x01, -0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xb8,0x08,0x00,0x08,0x1e,0x24,0x03,0x00,0x06, -0xa0,0x40,0x00,0x00,0x24,0xa5,0x00,0x01,0xaf,0x85,0x84,0xc4,0x0c,0x00,0x1a,0xb5, -0x24,0x04,0x00,0x0d,0x24,0x03,0x00,0x07,0xaf,0x80,0x84,0xc4,0x08,0x00,0x08,0x1e, -0x00,0x00,0x00,0x00,0x18,0xa0,0xff,0xeb,0x24,0xa5,0xff,0xff,0xaf,0x85,0x84,0xc4, -0x0c,0x00,0x1a,0xb5,0x24,0x04,0x00,0x08,0x0c,0x00,0x1a,0xb5,0x24,0x04,0x00,0x20, -0x08,0x00,0x08,0x1b,0x24,0x04,0x00,0x08,0x14,0x82,0xff,0xd2,0x24,0x02,0x00,0x08, -0x0c,0x00,0x07,0x90,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0xc4,0x08,0x00,0x08,0x0c, -0x24,0x04,0x00,0x0d,0x0c,0x00,0x31,0x0a,0x02,0x20,0x20,0x21,0xaf,0x82,0x84,0xc4, -0x04,0x40,0x00,0x0d,0x00,0x00,0x80,0x21,0x02,0x30,0x10,0x21,0x90,0x44,0x00,0x00, -0x26,0x10,0x00,0x01,0x00,0x04,0x26,0x00,0x00,0x04,0x26,0x03,0x0c,0x00,0x1a,0xb5, -0x30,0x84,0xff,0xff,0x8f,0x83,0x84,0xc4,0x00,0x00,0x00,0x00,0x00,0x70,0x18,0x2a, -0x10,0x60,0xff,0xf6,0x02,0x30,0x10,0x21,0x08,0x00,0x08,0x2e,0x24,0x03,0x00,0x06, -0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x27,0x83,0x8c,0xe8,0x24,0x02,0x00,0x07, -0x24,0x42,0xff,0xff,0xac,0x60,0x00,0x00,0x04,0x41,0xff,0xfd,0x24,0x63,0x00,0x04, -0x0c,0x00,0x08,0x66,0x00,0x00,0x00,0x00,0x8f,0x84,0x8c,0xe8,0x27,0x86,0x8c,0xe8, -0x0c,0x00,0x08,0x83,0x00,0x40,0x28,0x21,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0,0x00,0x80,0x28,0x21, -0x27,0x84,0x8c,0xc8,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0x0c,0x00,0x31,0x9b, -0xaf,0xb0,0x00,0x10,0x8f,0x85,0x83,0x34,0x27,0x84,0x8c,0xc8,0x0c,0x00,0x31,0x5f, -0x00,0x00,0x88,0x21,0x10,0x40,0x00,0x0c,0x00,0x00,0x00,0x00,0x27,0x90,0x8c,0xe8, -0x8f,0x85,0x83,0x34,0x00,0x00,0x20,0x21,0xae,0x02,0x00,0x00,0x0c,0x00,0x31,0x5f, -0x26,0x31,0x00,0x01,0x26,0x10,0x00,0x04,0x10,0x40,0x00,0x03,0x2a,0x23,0x00,0x64, -0x14,0x60,0xff,0xf7,0x00,0x00,0x00,0x00,0x02,0x20,0x10,0x21,0x8f,0xbf,0x00,0x18, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd0, -0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xbf,0x00,0x2c, -0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, -0x00,0xa0,0xa8,0x21,0x00,0x80,0xa0,0x21,0x00,0xc0,0xb0,0x21,0x10,0xa0,0x00,0x1d, -0x24,0x02,0x00,0x05,0x3c,0x02,0x80,0x00,0x24,0x43,0x2c,0x80,0x8f,0x82,0x83,0xa4, -0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x1e,0x00,0x00,0x88,0x21,0x00,0x60,0x98,0x21, -0x00,0x00,0x90,0x21,0x27,0x90,0x83,0xa4,0x8e,0x05,0xff,0xec,0x02,0x80,0x20,0x21, -0x0c,0x00,0x31,0xa3,0x26,0x10,0x00,0x18,0x10,0x40,0x00,0x06,0x02,0x51,0x18,0x21, -0x8e,0x02,0x00,0x00,0x26,0x31,0x00,0x01,0x14,0x53,0xff,0xf7,0x00,0x11,0x90,0x40, -0x02,0x51,0x18,0x21,0x27,0x82,0x83,0x94,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21, -0x8c,0x62,0x00,0x10,0x02,0x20,0x20,0x21,0x02,0xa0,0x28,0x21,0x00,0x40,0xf8,0x09, -0x02,0xc0,0x30,0x21,0x8f,0xbf,0x00,0x2c,0x8f,0xb6,0x00,0x28,0x7b,0xb4,0x01,0x3c, -0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, -0x08,0x00,0x08,0xa4,0x00,0x00,0x90,0x21,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34, -0xaf,0xb3,0x00,0x2c,0xaf,0xb1,0x00,0x24,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30, -0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0x00,0xc0,0x98,0x21,0x30,0xa5,0x00,0xff, -0xac,0xc0,0x00,0x00,0x24,0x15,0x00,0x0a,0x00,0x00,0x88,0x21,0x27,0xa8,0x00,0x10, -0x00,0x91,0x18,0x21,0x80,0x62,0x00,0x00,0x26,0x27,0x00,0x01,0x10,0x40,0x00,0x0c, -0x01,0x11,0x30,0x21,0x90,0x63,0x00,0x00,0x30,0xf1,0x00,0xff,0x2e,0x22,0x00,0x0a, -0x14,0x40,0xff,0xf7,0xa0,0xc3,0x00,0x00,0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc, -0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, -0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x23,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x1f, -0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x1a,0x00,0x00,0x00,0x00,0x02,0x20,0x90,0x21, -0x12,0x40,0xff,0xf1,0x00,0x00,0x88,0x21,0x27,0xb4,0x00,0x10,0x02,0x91,0x10,0x21, -0x90,0x44,0x00,0x00,0x0c,0x00,0x09,0x0a,0x00,0x00,0x00,0x00,0x02,0x51,0x20,0x23, -0x24,0x84,0xff,0xff,0x30,0x84,0x00,0xff,0x02,0xa0,0x28,0x21,0x0c,0x00,0x08,0xfb, -0x00,0x40,0x80,0x21,0x02,0x02,0x00,0x18,0x8e,0x63,0x00,0x00,0x26,0x22,0x00,0x01, -0x30,0x51,0x00,0xff,0x02,0x32,0x20,0x2b,0x00,0x00,0x80,0x12,0x00,0x70,0x18,0x21, -0x14,0x80,0xff,0xee,0xae,0x63,0x00,0x00,0x08,0x00,0x08,0xce,0x00,0x00,0x00,0x00, -0x80,0x82,0x00,0x00,0x08,0x00,0x08,0xce,0xae,0x62,0x00,0x00,0x08,0x00,0x08,0xdb, -0x24,0x15,0x00,0x10,0x08,0x00,0x08,0xdb,0x24,0x15,0x00,0x0a,0x30,0x84,0x00,0xff, -0x30,0xa5,0x00,0xff,0x24,0x06,0x00,0x01,0x10,0x80,0x00,0x09,0x00,0x00,0x10,0x21, -0x00,0xc5,0x00,0x18,0x24,0x42,0x00,0x01,0x30,0x42,0x00,0xff,0x00,0x44,0x18,0x2b, -0x00,0x00,0x30,0x12,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa,0x00,0xc5,0x00,0x18, -0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x30,0x84,0x00,0xff,0x24,0x83,0xff,0xd0, -0x30,0x62,0x00,0xff,0x2c,0x42,0x00,0x0a,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00, -0x24,0x82,0xff,0xbf,0x2c,0x42,0x00,0x06,0x14,0x40,0x00,0x02,0x24,0x83,0xff,0xc9, -0x24,0x83,0xff,0xa9,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xc8, -0x24,0x02,0x00,0x01,0xaf,0xbf,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28, -0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0x10,0xa2,0x00,0x3e, -0xaf,0xb0,0x00,0x18,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08,0x24,0x05,0x00,0x01, -0x00,0x00,0x10,0x21,0x8f,0xbf,0x00,0x30,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c, -0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8c,0xc4,0x00,0x04, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00, -0x28,0x42,0x00,0x65,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01, -0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xbc,0x08,0x00,0x09,0x25,0x24,0x02,0x00,0x01, -0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95,0x24,0x84,0x04,0xc8,0x8f,0x83,0x83,0xa4, -0x3c,0x02,0x80,0x00,0x24,0x42,0x2c,0x80,0x10,0x62,0xff,0xe5,0x00,0x40,0x90,0x21, -0x3c,0x13,0x80,0x01,0x27,0x95,0x83,0x90,0x3c,0x14,0x80,0x01,0x27,0x90,0x83,0x94, -0x00,0x00,0x88,0x21,0x8e,0x03,0x00,0x08,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00, -0x10,0x62,0x00,0x08,0x26,0x64,0x04,0xd4,0x26,0x10,0x00,0x18,0x8e,0x02,0x00,0x10, -0x00,0x00,0x00,0x00,0x14,0x52,0xff,0xf7,0x26,0x31,0x00,0x18,0x08,0x00,0x09,0x25, -0x00,0x00,0x10,0x21,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x02,0x35,0x10,0x21, -0x8c,0x44,0x00,0x00,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0x95, -0x26,0x84,0x04,0xd8,0x8e,0x04,0x00,0x00,0x0c,0x00,0x1a,0x95,0x26,0x10,0x00,0x18, -0x08,0x00,0x09,0x4b,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95, -0x24,0x84,0x04,0xdc,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x82,0x24,0x84,0x04,0xec, -0x24,0x11,0x00,0x05,0x3c,0x12,0x80,0x01,0x27,0x90,0x88,0x0e,0x86,0x05,0x00,0x00, -0x26,0x44,0x05,0x0c,0x0c,0x00,0x1a,0x82,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xfb, -0x26,0x10,0xff,0xfe,0x08,0x00,0x09,0x25,0x00,0x00,0x10,0x21,0x27,0xbd,0xff,0xd0, -0x28,0xa2,0x00,0x02,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x2c, -0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0x00,0xa0,0x80,0x21, -0x14,0x40,0x00,0x51,0x00,0xc0,0x88,0x21,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x48, -0x24,0x05,0x00,0x01,0x8e,0x24,0x00,0x08,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14, -0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x30,0x42,0x0f,0xff,0xaf,0xa2,0x00,0x14, -0x7b,0xa4,0x00,0xbc,0x0c,0x00,0x0a,0x06,0x24,0x06,0x00,0x04,0x24,0x03,0x00,0x04, -0x10,0x43,0x00,0x2a,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x10,0x3c,0x04,0x80,0x01, -0x24,0x84,0x05,0x10,0x00,0x02,0x19,0x02,0x00,0x03,0x81,0x00,0x8f,0xa3,0x00,0x14, -0x00,0x50,0x10,0x23,0x00,0x02,0x10,0x82,0x00,0x62,0x18,0x21,0x0c,0x00,0x1a,0x95, -0xaf,0xa3,0x00,0x14,0x3c,0x04,0x80,0x01,0x0c,0x00,0x1a,0x95,0x24,0x84,0x05,0x38, -0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x88,0x21, -0x3c,0x13,0x80,0x01,0x3c,0x12,0x80,0x01,0x3c,0x14,0x80,0x01,0x0c,0x00,0x2e,0xda, -0x24,0x04,0x27,0x10,0x32,0x23,0x00,0x03,0x02,0x00,0x28,0x21,0x10,0x60,0x00,0x1c, -0x26,0x64,0x05,0x64,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x23, -0x28,0x42,0xff,0xfd,0x10,0x40,0x00,0x10,0x26,0x44,0x05,0x70,0x0c,0x00,0x1a,0x95, -0x26,0x10,0x00,0x04,0x8f,0xa2,0x00,0x14,0x26,0x31,0x00,0x01,0x02,0x22,0x10,0x2b, -0x14,0x40,0xff,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x21,0x8f,0xbf,0x00,0x2c, -0x8f,0xb4,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x80,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8e,0x05,0x00,0x00,0x26,0x84,0x05,0x74, -0x0c,0x00,0x1a,0x82,0x26,0x10,0x00,0x04,0x08,0x00,0x09,0xb1,0x00,0x00,0x00,0x00, -0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00,0x08,0x00,0x09,0xa9,0x00,0x00,0x00,0x00, -0x08,0x00,0x09,0x87,0x24,0x02,0x00,0x01,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, -0x08,0x00,0x09,0xb7,0x24,0x04,0x00,0x04,0x27,0xbd,0xff,0xd0,0x28,0xa2,0x00,0x03, -0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x28,0x00,0xa0,0x88,0x21, -0x10,0x40,0x00,0x09,0x00,0xc0,0x80,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, -0x24,0x04,0x00,0x04,0x8f,0xbf,0x00,0x28,0x7b,0xb0,0x01,0x3c,0x00,0x80,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x1b, -0x24,0x05,0x00,0x01,0x8e,0x04,0x00,0x0c,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18, -0x8f,0xa4,0x00,0x10,0x8f,0xa5,0x00,0x18,0x0c,0x00,0x0a,0x06,0x24,0x06,0x00,0x04, -0x24,0x03,0x00,0x04,0x10,0x43,0xff,0xe7,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x18, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,0x00,0x00,0x28,0x21,0x8f,0xa2,0x00,0x10, -0x8f,0xa4,0x00,0x14,0x24,0xa5,0x00,0x01,0xac,0x44,0x00,0x00,0x8f,0xa3,0x00,0x10, -0x8f,0xa2,0x00,0x18,0x24,0x63,0x00,0x04,0x00,0xa2,0x10,0x2b,0x14,0x40,0xff,0xf7, -0xaf,0xa3,0x00,0x10,0x08,0x00,0x09,0xd9,0x00,0x00,0x20,0x21,0x24,0x02,0x00,0x01, -0x08,0x00,0x09,0xec,0xaf,0xa2,0x00,0x18,0x30,0xc6,0x00,0xff,0x00,0xa6,0x00,0x18, -0x00,0x00,0x28,0x12,0x04,0x81,0x00,0x07,0x00,0x00,0x30,0x21,0x3c,0x02,0x80,0x01, -0x00,0x85,0x18,0x21,0x34,0x42,0x7f,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x0b, -0x3c,0x02,0xb0,0x03,0x3c,0x02,0xaf,0xff,0x34,0x42,0xff,0xff,0x00,0x44,0x10,0x2b, -0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x0a,0x00,0x85,0x18,0x21,0x34,0x42,0xff,0xff, -0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0xff,0xff, -0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07,0x3c,0x02,0xb0,0x04, -0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x09,0x3c,0x02,0xb0,0x07, -0x34,0x42,0x00,0x3f,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07, -0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x02,0x00,0x00,0x00,0x00, -0x24,0x06,0x00,0x01,0x14,0xc0,0x00,0x11,0x24,0x02,0x00,0x04,0x3c,0x02,0xb0,0x08, -0x34,0x42,0x0f,0xff,0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x08,0x3c,0x02,0x4f,0xf7, -0x00,0x85,0x20,0x21,0x34,0x42,0xf0,0x00,0x00,0x82,0x20,0x21,0x34,0x03,0xef,0xff, -0x00,0x64,0x18,0x2b,0x14,0x60,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x06,0x00,0x02, -0x10,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,0x24,0x02,0x00,0x02,0xaf,0xb0,0x00,0x18, -0xaf,0xbf,0x00,0x1c,0x10,0xa2,0x00,0x23,0x00,0xc0,0x80,0x21,0x28,0xa2,0x00,0x03, -0x10,0x40,0x00,0x0c,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x04, -0x00,0x00,0x18,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21, -0x8f,0xbf,0x00,0x1c,0x8f,0xb0,0x00,0x18,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x14,0xa2,0xff,0xf7,0x24,0x05,0x00,0x01,0x8c,0xc4,0x00,0x04, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02, -0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x8f,0xa4,0x00,0x10,0x00,0x00,0x00,0x00, -0x2c,0x82,0x00,0x0b,0x10,0x40,0xff,0xee,0x24,0x03,0x00,0x04,0x00,0x04,0x10,0x80, -0x8f,0xa4,0x00,0x14,0x27,0x83,0x94,0xc0,0x00,0x43,0x10,0x21,0x08,0x00,0x0a,0x4f, -0xac,0x44,0x00,0x00,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6, -0x27,0xa6,0x00,0x10,0x8f,0xa5,0x00,0x10,0x27,0x83,0x94,0xc0,0x3c,0x04,0x80,0x01, -0x00,0x05,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x46,0x00,0x00,0x0c,0x00,0x1a,0x82, -0x24,0x84,0x05,0x7c,0x08,0x00,0x0a,0x50,0x00,0x00,0x18,0x21,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xb8,0x28,0xa5,0x00,0x04,0xaf,0xb0,0x00,0x20, -0xaf,0xbf,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34, -0xaf,0xb4,0x00,0x30,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb1,0x00,0x24, -0x10,0xa0,0x00,0x0b,0x00,0xc0,0x80,0x21,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x40,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc, -0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48, -0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x10, -0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14, -0x8e,0x04,0x00,0x0c,0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18, -0x8f,0xa3,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x3a,0x24,0x02,0x00,0x01, -0x10,0x62,0x00,0x33,0x3c,0x04,0x80,0x01,0x97,0xb0,0x00,0x12,0x8f,0xa2,0x00,0x14, -0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x2b,0x10,0x40,0xff,0xe2,0x3c,0x15,0x80,0x01, -0x3c,0x02,0x80,0x01,0x24,0x52,0x05,0xbc,0x3c,0x14,0xb0,0x06,0x24,0x13,0x00,0x01, -0x3c,0x17,0xb0,0x08,0x3c,0x16,0x80,0x01,0x32,0x02,0x00,0x01,0x02,0x00,0x28,0x21, -0x10,0x40,0x00,0x1f,0x26,0xa4,0x05,0xb0,0x8f,0xa3,0x00,0x18,0x00,0x10,0x10,0xc0, -0x00,0x54,0x10,0x21,0x10,0x60,0x00,0x14,0x02,0x40,0x20,0x21,0x00,0x10,0x10,0xc0, -0x00,0x57,0x10,0x21,0x10,0x73,0x00,0x09,0x26,0xc4,0x05,0xc4,0x8f,0xa2,0x00,0x14, -0x26,0x03,0x00,0x01,0x30,0x70,0xff,0xff,0x02,0x02,0x10,0x2b,0x14,0x40,0xff,0xee, -0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0x8d,0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00, -0x00,0x00,0x00,0x00,0x32,0x25,0x00,0xff,0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00, -0x08,0x00,0x0a,0xbf,0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00,0x0c,0x00,0x1a,0x82, -0x00,0x11,0x2c,0x02,0x32,0x25,0x00,0xff,0x08,0x00,0x0a,0xca,0x02,0x40,0x20,0x21, -0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0xb6,0x00,0x00,0x00,0x00, -0x24,0x84,0x05,0x90,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x08,0x00,0x0a,0xa6, -0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,0x08,0x00,0x0a,0xd9,0x24,0x84,0x05,0xd0, -0x00,0xa0,0x10,0x21,0x27,0xbd,0xff,0xd8,0x28,0x42,0x00,0x04,0xaf,0xb0,0x00,0x20, -0xaf,0xbf,0x00,0x24,0x00,0xc0,0x80,0x21,0x24,0x05,0x00,0x01,0x10,0x40,0x00,0x08, -0x27,0xa6,0x00,0x10,0x0c,0x00,0x0b,0x2b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04, -0x8f,0xbf,0x00,0x24,0x8f,0xb0,0x00,0x20,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, -0x8e,0x04,0x00,0x04,0x0c,0x00,0x08,0xb6,0x00,0x00,0x00,0x00,0x8e,0x04,0x00,0x08, -0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x14,0x8e,0x04,0x00,0x0c, -0x24,0x05,0x00,0x01,0x0c,0x00,0x08,0xb6,0x27,0xa6,0x00,0x18,0x08,0x00,0x0a,0xec, -0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x01,0x00,0x65,0x10,0x2a,0x27,0xbd,0xff,0xd8, -0x00,0xa0,0x40,0x21,0x10,0x40,0x00,0x0b,0x00,0xc0,0x38,0x21,0x00,0x03,0x20,0x80, -0x00,0x87,0x10,0x21,0x8c,0x45,0x00,0x00,0x24,0x63,0x00,0x01,0x30,0x63,0x00,0xff, -0x8c,0xa6,0x00,0x00,0x00,0x9d,0x20,0x21,0x00,0x68,0x10,0x2a,0x14,0x40,0xff,0xf7, -0xac,0x86,0xff,0xfc,0x8f,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x0b, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x93,0xa2,0x00,0x07,0x00,0x00,0x00,0x00, -0xa3,0x82,0x87,0x6c,0x08,0x00,0x0b,0x14,0x00,0x00,0x00,0x00,0x93,0xa2,0x00,0x07, -0x00,0x00,0x00,0x00,0xa3,0x82,0x94,0xb0,0x08,0x00,0x0b,0x14,0x00,0x00,0x00,0x00, -0x27,0xbd,0xff,0xe8,0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x10,0x18,0xa0,0x00,0x03, -0x24,0x84,0x05,0xf8,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe8, -0xaf,0xb0,0x00,0x10,0x00,0x80,0x80,0x21,0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x14, -0x0c,0x00,0x1a,0x95,0x24,0x84,0x06,0x0c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, -0x27,0x83,0x83,0x90,0x00,0x02,0x10,0xc0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, -0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x2c,0xf8,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, -0x34,0x84,0x00,0x2c,0x8c,0x86,0x00,0x00,0x3c,0x05,0xb0,0x0a,0x34,0xa5,0x1a,0x00, -0x00,0x06,0x1a,0x02,0x30,0x63,0x0f,0xff,0x00,0x06,0x25,0x02,0x24,0x02,0xff,0xff, -0xac,0xa2,0x00,0x00,0xa7,0x83,0xc5,0x4a,0xa7,0x84,0xc5,0x4c,0xa3,0x86,0xc5,0x48, -0xa7,0x80,0xc5,0x40,0xa7,0x80,0xc5,0x42,0xa7,0x80,0xc5,0x44,0xa7,0x80,0xc5,0x46, -0x00,0xa0,0x38,0x21,0x24,0x03,0x00,0x01,0x8c,0xe2,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0a,0x00,0x8c,0x45,0x00,0x00, -0x3c,0x04,0xb0,0x0a,0x34,0x84,0x1a,0x00,0xa0,0x45,0x00,0x00,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x0a,0x00,0x3c,0x04,0xb0,0x0a,0xa0,0x45,0x00,0x00,0x34,0x84,0x1a,0x00, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x63,0x01,0x08, -0x34,0x84,0x01,0x18,0x8c,0x65,0x00,0x00,0x8c,0x82,0x00,0x00,0xaf,0x85,0xc5,0x50, -0x30,0x42,0x02,0x00,0x10,0x40,0x00,0x06,0x3c,0x02,0x00,0x0f,0x3c,0x02,0x00,0x4c, -0x34,0x42,0x4b,0x40,0xaf,0x82,0xc5,0x54,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x08,0x00,0x0b,0x79,0x34,0x42,0x42,0x40,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x2d,0xf8,0x30,0x84,0x00,0xff,0xac,0x62,0x00,0x00, -0x14,0x80,0x02,0xb3,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x1b,0x40, -0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x0b,0x40,0x8c,0x46,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x1b,0x48, -0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x00,0x06,0x54,0x02, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0b,0x48,0x8c,0x46,0x00,0x00,0x3c,0x03,0xb0,0x0a, -0x34,0x63,0x1b,0x50,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, -0x00,0x06,0x64,0x02,0x30,0xcb,0xff,0xff,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x0b,0x50, -0x8c,0x46,0x00,0x00,0x97,0x84,0xc5,0x40,0x97,0x82,0xc5,0x42,0x97,0x83,0xc5,0x46, -0x01,0x44,0x20,0x23,0x01,0x62,0x10,0x23,0x00,0x82,0x20,0x21,0x97,0x82,0xc5,0x44, -0x30,0xcd,0xff,0xff,0x01,0xa3,0x18,0x23,0x01,0x82,0x10,0x23,0x00,0x82,0x20,0x21, -0x93,0x82,0xc5,0x48,0x00,0x83,0x20,0x21,0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b, -0x10,0x40,0x00,0xec,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, -0x8c,0x46,0x00,0x00,0x24,0x02,0x00,0x20,0x30,0xc8,0x00,0x7f,0x11,0x02,0x00,0x4d, -0x2d,0x02,0x00,0x21,0x14,0x40,0x00,0x2b,0x24,0x02,0xff,0x80,0x00,0xc2,0x10,0x24, -0x25,0x08,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0,0x00,0x48,0x30,0x25, -0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xb0, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, -0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0,0x3c,0x04,0xb0,0x0a, -0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x07, -0x24,0x02,0xff,0xff,0xa7,0x8a,0xc5,0x40,0xa7,0x8b,0xc5,0x42,0xa7,0x8c,0xc5,0x44, -0xa7,0x8d,0xc5,0x46,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, -0x34,0x63,0x14,0x58,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x8c,0x69,0x00,0x00,0x3c,0x02,0xff,0xff, -0x34,0x42,0x3f,0xff,0x01,0x22,0x10,0x24,0x34,0x49,0x80,0x00,0x3c,0x04,0xb0,0x0a, -0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0xf9, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x58, -0x8c,0x49,0x00,0x00,0x3c,0x04,0xb0,0x0a,0x34,0x84,0x14,0x58,0x35,0x29,0x40,0x00, -0xac,0x49,0x00,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb0, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb0, -0x8c,0x47,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb8,0x3c,0x05,0xb0,0x0a, -0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x34,0xa5,0x14,0xb8,0x00,0x07,0x1e,0x02, -0x24,0x04,0x00,0x01,0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb8,0x8c,0x47,0x00,0x00,0x00,0x03,0x1a,0x00, -0x30,0xe2,0x00,0xff,0x00,0x62,0x18,0x25,0x2c,0x62,0x00,0x04,0x10,0x40,0x00,0x3a, -0x2c,0x62,0x00,0x11,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10, -0x8c,0x47,0x00,0x00,0x24,0x02,0x00,0x03,0x00,0x07,0x1d,0x82,0x30,0x64,0x00,0x03, -0x10,0x82,0x00,0x1a,0x3c,0x02,0xff,0x3f,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a, -0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x35,0x29,0x80,0x00, -0x34,0x42,0x04,0x58,0x3c,0x04,0xb0,0x0a,0xac,0x49,0x00,0x00,0x34,0x84,0x14,0x58, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x2d,0x02,0x00,0x21,0x08,0x00,0x0b,0xcd,0x00,0x00,0x00,0x00,0x34,0x42,0xff,0xff, -0x3c,0x03,0x00,0x80,0x00,0xe2,0x10,0x24,0x00,0x43,0x38,0x25,0x3c,0x04,0xb0,0x0a, -0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xff,0xff, -0x08,0x00,0x0c,0x60,0x34,0x42,0x3f,0xff,0x14,0x40,0xff,0xd8,0x3c,0x02,0xff,0xff, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00, -0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x02,0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82, -0x14,0x83,0xff,0xc6,0x3c,0x02,0xff,0xff,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, -0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, -0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0c,0x60, -0x34,0x42,0x3f,0xff,0x97,0x82,0xc5,0x4c,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b, -0x10,0x40,0x00,0x74,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0,0x8c,0x46,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0xc8,0x00,0x7f,0x2d,0x02,0x00,0x32,0x10,0x40,0xff,0x3d, -0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x2b,0x24,0x02,0xff,0x80,0x00,0xc2,0x10,0x24, -0x25,0x08,0x00,0x02,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0,0x00,0x48,0x30,0x25, -0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xb0, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, -0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0,0x3c,0x04,0xb0,0x0a, -0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0xf9, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10, -0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x03,0x00,0xe5,0x10,0x24, -0x00,0x02,0x25,0x82,0x10,0x83,0x00,0x0d,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, -0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, -0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, -0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58,0x8c,0x69,0x00,0x00, -0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a, -0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0x80,0x08,0x00,0x0c,0xc0, -0x00,0xc2,0x10,0x24,0x97,0x82,0xc5,0x4a,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b, -0x10,0x40,0x00,0x75,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, -0x8c,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xc8,0x00,0x7f,0x2d,0x02,0x00,0x32, -0x10,0x40,0xfe,0xc4,0x24,0x02,0x00,0x20,0x11,0x02,0x00,0x2b,0x24,0x02,0xff,0x80, -0x00,0xc2,0x10,0x24,0x25,0x08,0x00,0x01,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x08,0xa0, -0x00,0x48,0x30,0x25,0x3c,0x04,0xb0,0x0a,0xac,0x66,0x00,0x00,0x34,0x84,0x18,0xa0, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xb0,0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00, -0x34,0x84,0x18,0xb0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xc0,0x3c,0x04,0xb0,0x0a, -0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xc0,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xd0, -0x3c,0x04,0xb0,0x0a,0xac,0x46,0x00,0x00,0x34,0x84,0x18,0xd0,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, -0x08,0x00,0x0b,0xf9,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10, -0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0,0x24,0x03,0x00,0x03, -0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82,0x10,0x83,0x00,0x0d,0x3c,0x02,0xff,0x3f, -0x34,0x42,0xff,0xff,0x00,0xe2,0x10,0x24,0x00,0x45,0x38,0x25,0x3c,0x04,0xb0,0x0a, -0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10,0x34,0x84,0x14,0x10,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x04,0x58, -0x8c,0x69,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x01,0x22,0x48,0x24, -0x3c,0x04,0xb0,0x0a,0xac,0x69,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x24,0x02,0xff,0x80, -0x08,0x00,0x0d,0x39,0x00,0xc2,0x10,0x24,0x34,0x63,0x18,0xa0,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x08,0xa0, -0x8c,0x46,0x00,0x00,0x24,0x02,0x00,0x20,0x30,0xc8,0x00,0x7f,0x15,0x02,0xfe,0x51, -0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x58,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x58,0x8c,0x49,0x00,0x00, -0x3c,0x04,0xb0,0x0a,0x34,0x84,0x14,0x58,0x35,0x29,0x40,0x00,0xac,0x49,0x00,0x00, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x24,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb0,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0xb0,0x8c,0x47,0x00,0x00, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0xb8,0x3c,0x05,0xb0,0x0a,0x24,0x02,0xff,0xff, -0xac,0x62,0x00,0x00,0x34,0xa5,0x14,0xb8,0x00,0x07,0x1e,0x02,0x24,0x04,0x00,0x01, -0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x34,0x42,0x04,0xb8,0x8c,0x47,0x00,0x00,0x00,0x03,0x1a,0x00,0x30,0xe2,0x00,0xff, -0x00,0x62,0x18,0x25,0x2c,0x62,0x00,0x04,0x10,0x40,0x00,0x3a,0x2c,0x62,0x00,0x11, -0x3c,0x03,0xb0,0x0a,0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00, -0x00,0x60,0x20,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00, -0x24,0x02,0x00,0x03,0x00,0x07,0x1d,0x82,0x30,0x64,0x00,0x03,0x10,0x82,0x00,0x1a, -0x3c,0x02,0xff,0x3f,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x3c,0x03,0xb0,0x0a, -0x34,0x63,0x04,0x58,0x01,0x22,0x48,0x24,0x3c,0x04,0xb0,0x0a,0xac,0x69,0x00,0x00, -0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xb0,0x0a,0x35,0x29,0x80,0x00,0x34,0x42,0x04,0x58, -0x3c,0x04,0xb0,0x0a,0xac,0x49,0x00,0x00,0x34,0x84,0x14,0x58,0x24,0x03,0x00,0x01, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, -0x08,0x00,0x0b,0xf9,0x00,0x00,0x00,0x00,0x34,0x42,0xff,0xff,0x3c,0x03,0x00,0x80, -0x00,0xe2,0x10,0x24,0x00,0x43,0x38,0x25,0x3c,0x03,0xb0,0x0a,0x3c,0x01,0xb0,0x0a, -0xac,0x27,0x04,0x10,0x34,0x63,0x14,0x10,0x24,0x04,0x00,0x01,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0d,0xef, -0x34,0x42,0x3f,0xff,0x14,0x40,0xff,0xd8,0x3c,0x02,0xff,0xff,0x3c,0x03,0xb0,0x0a, -0x34,0x63,0x14,0x10,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x34,0x42,0x04,0x10,0x8c,0x47,0x00,0x00,0x3c,0x05,0x00,0xc0, -0x24,0x03,0x00,0x02,0x00,0xe5,0x10,0x24,0x00,0x02,0x25,0x82,0x14,0x83,0xff,0xc6, -0x3c,0x02,0xff,0xff,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xe2,0x10,0x24, -0x00,0x45,0x38,0x25,0x3c,0x03,0xb0,0x0a,0x3c,0x01,0xb0,0x0a,0xac,0x27,0x04,0x10, -0x34,0x63,0x14,0x10,0x24,0x04,0x00,0x01,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x44,0xff,0xfd,0x3c,0x02,0xff,0xff,0x08,0x00,0x0d,0xef,0x34,0x42,0x3f,0xff, -0x10,0x82,0x00,0x03,0x3c,0x03,0xb0,0x0a,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x34,0x63,0x1a,0x00,0x24,0x02,0xff,0xff,0xac,0x62,0x00,0x00,0x00,0x60,0x20,0x21, -0xa7,0x80,0xc5,0x40,0xa7,0x80,0xc5,0x42,0xa7,0x80,0xc5,0x44,0xa7,0x80,0xc5,0x46, -0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x34,0x63,0x0a,0x00,0x8c,0x66,0x00,0x00, -0x3c,0x02,0x08,0x00,0x3c,0x04,0xb0,0x0a,0x00,0xc2,0x10,0x25,0xac,0x62,0x00,0x00, -0x34,0x84,0x1a,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x3c,0x02,0xf7,0xff,0x3c,0x03,0xb0,0x0a,0x34,0x42,0xff,0xff, -0x34,0x63,0x0a,0x00,0x00,0xc2,0x10,0x24,0x3c,0x04,0xb0,0x0a,0xac,0x62,0x00,0x00, -0x34,0x84,0x1a,0x00,0x24,0x03,0x00,0x01,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x3a,0x00,0x00,0x00,0x00, -0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,0x3c,0x02,0xb0,0x0a, -0x00,0x82,0x20,0x21,0x3c,0x06,0x05,0xf5,0xac,0x85,0x00,0x00,0x24,0x07,0x00,0x01, -0x00,0x00,0x28,0x21,0x34,0xc6,0xe0,0xff,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01, -0x10,0x47,0x00,0x03,0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40, -0x3c,0x02,0xb0,0x0a,0x00,0x83,0x20,0x23,0x00,0x82,0x20,0x21,0x3c,0x06,0x05,0xf5, -0x24,0x02,0xff,0xff,0xac,0x82,0x10,0x00,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x01, -0x34,0xc6,0xe0,0xff,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03, -0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x24,0x42,0x3a,0x28,0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03, -0xac,0xa2,0x00,0x00,0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04, -0xa0,0x80,0x00,0x05,0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08, -0xa0,0x80,0x00,0x09,0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13, -0xa0,0x80,0x00,0x49,0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e, -0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00, -0xa4,0x82,0x00,0x44,0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28, -0xac,0x80,0x00,0x2c,0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38, -0xac,0x80,0x00,0x3c,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c, -0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18, -0x3c,0x02,0x80,0x00,0x24,0x42,0x3a,0xbc,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08, -0x80,0x82,0x00,0x13,0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00, -0x30,0x63,0x00,0x7e,0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00, -0x3c,0x05,0xb0,0x05,0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05, -0x3c,0x08,0xb0,0x05,0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21, -0x34,0xe7,0x04,0x24,0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20, -0xac,0xe6,0x00,0x00,0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00, -0x27,0xbd,0xff,0xa8,0x00,0x07,0x60,0x80,0x27,0x82,0xbd,0x40,0xaf,0xb7,0x00,0x4c, -0xaf,0xb6,0x00,0x48,0xaf,0xb4,0x00,0x40,0xaf,0xb3,0x00,0x3c,0xaf,0xbf,0x00,0x54, -0xaf,0xbe,0x00,0x50,0xaf,0xb5,0x00,0x44,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34, -0xaf,0xb0,0x00,0x30,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21, -0x3c,0x02,0x80,0x00,0x94,0x71,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20, -0x24,0x42,0x3b,0x50,0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28, -0x90,0x67,0x00,0x00,0x00,0x11,0xa0,0xc0,0x02,0x91,0x18,0x21,0x27,0x82,0x99,0x44, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00, -0x28,0xc2,0x00,0x03,0x00,0xc0,0x98,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xb4,0x03, -0x8c,0x68,0x00,0x18,0x02,0x80,0x58,0x21,0x10,0x40,0x01,0x79,0x00,0x07,0xbe,0x03, -0x00,0xd7,0x10,0x07,0x30,0x57,0x00,0x01,0x01,0x71,0x10,0x21,0x27,0x83,0x99,0x48, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00, -0x8d,0x02,0x00,0x04,0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x1c, -0x11,0xa0,0x01,0x69,0xaf,0xa3,0x00,0x18,0x27,0x82,0xbd,0x40,0x01,0x82,0x10,0x21, -0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x63,0x00,0x04,0x14,0x60,0x00,0x12,0x00,0x00,0xa8,0x21,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x01,0x46,0x90,0x43,0x00,0x00,0x2a,0x64,0x00,0x04,0x10,0x80,0x01,0x4e, -0x30,0x65,0x00,0x01,0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x62,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21, -0x12,0xe0,0x00,0x03,0x38,0xf5,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf5,0x00,0x01, -0x01,0x71,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x83,0x99,0x50,0x00,0xc3,0x48,0x21, -0x91,0x25,0x00,0x00,0x8f,0xa3,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x03,0x11,0xc3, -0x2c,0xa3,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x03,0xa8,0x0b,0x12,0xa0,0x00,0xd2, -0xaf,0xa2,0x00,0x20,0x93,0x90,0xc5,0x2a,0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f, -0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xba,0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10, -0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b,0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04, -0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b,0x01,0x71,0x10,0x21,0x27,0x85,0xc4,0x5c, -0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40, -0x01,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x48,0x00,0x43,0x10,0x21, -0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0x9f,0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05, -0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01,0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e, -0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00,0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0, -0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00,0x24,0x16,0x00,0x0e,0x24,0x11,0x01,0x06, -0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00,0x27,0x82,0xbd,0x40,0x01,0x82,0x10,0x21, -0x8c,0x43,0x00,0x00,0x24,0x1e,0x00,0x01,0x00,0x11,0xa0,0xc0,0x90,0x62,0x00,0x16, -0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa5,0x00,0x1c, -0x00,0x10,0x32,0x00,0x00,0x05,0x13,0x43,0x30,0x47,0x00,0x01,0x8f,0xa2,0x00,0x18, -0x8f,0xa5,0x00,0x20,0x00,0x02,0x22,0x02,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0, -0x30,0x84,0x07,0xff,0x00,0x47,0x10,0x21,0x00,0x1e,0x2a,0x80,0x00,0x43,0x10,0x21, -0x00,0x04,0x24,0x80,0x02,0x25,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21, -0x00,0x16,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x60,0x00,0x29, -0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05, -0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28, -0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01, -0x02,0x63,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21, -0x12,0xe0,0x00,0x03,0x02,0x91,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0x91,0x10,0x21, -0x27,0x83,0x99,0x48,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04, -0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x60,0x28,0x21,0x02,0xa0,0x38,0x21, -0x0c,0x00,0x00,0x70,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c, -0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x3d,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x02,0x12,0x62,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03, -0x12,0x62,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x62,0x00,0x19, -0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x12,0x16,0x62,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05, -0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00, -0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x0f,0x86,0x24,0x02,0x00,0x20, -0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, -0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x0f,0x86, -0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05, -0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80, -0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05, -0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28, -0x24,0x02,0x00,0x08,0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10, -0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14, -0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x0f,0x86,0xac,0x65,0x00,0x00, -0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, -0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x0f,0x86, -0xac,0x65,0x00,0x00,0x24,0x16,0x00,0x14,0x08,0x00,0x0f,0x5e,0x24,0x11,0x01,0x02, -0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c, -0x26,0x02,0x00,0x04,0x27,0x85,0xc4,0x5c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, -0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, -0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04, -0x08,0x00,0x0f,0x48,0x00,0x46,0x80,0x0a,0x27,0x82,0xbd,0x40,0x01,0x82,0x20,0x21, -0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x99,0x60,0x00,0xc2,0x10,0x21, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x12,0x00,0x00,0x00,0x00, -0x90,0xe3,0x00,0x16,0x27,0x82,0x99,0x48,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20, -0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x16,0x42, -0x30,0x52,0x00,0x3f,0x90,0x83,0x00,0x16,0x24,0x16,0x00,0x18,0x24,0x11,0x01,0x03, -0x30,0x63,0x00,0xfb,0x24,0x1e,0x00,0x01,0x24,0x14,0x08,0x18,0x08,0x00,0x0f,0x67, -0xa0,0x83,0x00,0x16,0x8d,0x02,0x00,0x04,0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10, -0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f,0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e,0x27,0x83,0x99,0x58,0x00,0xc3,0x18,0x21, -0x80,0x64,0x00,0x00,0x27,0x83,0xbe,0xb8,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24, -0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25,0x27,0x85,0xbd,0x40,0x01,0x85,0x28,0x21, -0x8c,0xa6,0x00,0x00,0x01,0x71,0x10,0x21,0x27,0x83,0x99,0x50,0x90,0xc4,0x00,0x16, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00, -0xa0,0xc4,0x00,0x16,0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0x80,0xde,0x00,0x12, -0x90,0x62,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06, -0xa0,0x62,0x00,0x16,0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04, -0x15,0xc2,0xff,0x16,0x00,0x00,0x00,0x00,0x32,0x42,0x00,0x02,0x2e,0x03,0x00,0x0c, -0x14,0x60,0x00,0x0f,0x00,0x02,0x20,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10, -0x00,0x04,0x19,0x00,0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xe0, -0xa0,0x43,0x00,0x00,0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x01,0xfb, -0xaf,0xaf,0x00,0x28,0x8f,0xaf,0x00,0x28,0x08,0x00,0x0f,0x67,0x00,0x00,0x00,0x00, -0x08,0x00,0x10,0x5a,0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xb2, -0x00,0x00,0x00,0x00,0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x62,0x10,0x26, -0x08,0x00,0x0f,0x1e,0x00,0x02,0x28,0x0b,0x08,0x00,0x0f,0x24,0x00,0x00,0xa8,0x21, -0x24,0x02,0x00,0x10,0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x85, -0x00,0x07,0x17,0x83,0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x83,0x00,0x07,0x17,0x43, -0x08,0x00,0x0e,0xfe,0x30,0x57,0x00,0x01,0x08,0x00,0x0e,0xfe,0x00,0x07,0xbf,0xc2, -0x00,0x04,0x10,0x40,0x27,0x83,0x86,0x30,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21, -0x94,0x44,0x00,0x00,0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a, -0x00,0x86,0x00,0x18,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, -0x24,0x42,0x42,0x00,0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12, -0x00,0x04,0x22,0x42,0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b, -0x24,0x82,0x00,0x60,0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03, -0x34,0x63,0x01,0x00,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, -0x00,0x44,0x20,0x04,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28, -0x24,0x83,0x00,0x24,0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14, -0x00,0x60,0x20,0x21,0x08,0x00,0x10,0x97,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x42,0x9c, -0x00,0x80,0x80,0x21,0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37, -0x34,0x84,0x01,0x10,0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21, -0x8c,0x87,0x00,0x00,0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f, -0x34,0x42,0xf0,0x00,0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08, -0x32,0x02,0x00,0x07,0x27,0x83,0x86,0xe0,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00, -0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21, -0x32,0x02,0x00,0x0f,0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01, -0x14,0x40,0x00,0x07,0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xbd,0x90, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c, -0x14,0x40,0x00,0x05,0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00, -0x00,0x82,0x10,0x21,0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20, -0x24,0x06,0x00,0x0e,0x0c,0x00,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04, -0x24,0x02,0x00,0x10,0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01, -0x14,0x60,0x00,0x02,0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff, -0x00,0xc5,0x10,0x21,0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00, -0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c, -0x32,0x02,0x00,0x07,0x27,0x83,0x86,0xd8,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, -0x08,0x00,0x10,0xc5,0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80, -0x27,0x82,0xbd,0x40,0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c, -0xaf,0xbf,0x00,0x44,0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30, -0xaf,0xb2,0x00,0x28,0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21, -0x8c,0xe6,0x00,0x00,0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03, -0x34,0xa5,0x00,0x20,0x24,0x42,0x43,0xf8,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00, -0xa0,0xc3,0x00,0x12,0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16, -0xa4,0xc3,0x00,0x14,0x27,0x83,0x99,0x40,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16, -0x8c,0xe8,0x00,0x00,0xaf,0xa4,0x00,0x48,0x27,0x82,0x99,0x44,0x95,0x11,0x00,0x14, -0x00,0x00,0x00,0x00,0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80, -0x00,0x82,0x10,0x21,0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06, -0x8e,0x45,0x00,0x08,0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82, -0x00,0x06,0x31,0x42,0x27,0x82,0x99,0x50,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01, -0x00,0x82,0x20,0x21,0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18, -0xaf,0xa6,0x00,0x1c,0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06, -0x14,0xe0,0x00,0x47,0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x44,0x02,0x71,0x10,0x21,0x93,0x90,0xc5,0x29,0x00,0x00,0x00,0x00, -0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40, -0x00,0x43,0x10,0x21,0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04, -0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, -0x00,0x80,0x80,0x21,0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21, -0x02,0xc0,0x28,0x21,0x0c,0x00,0x10,0x80,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21, -0x00,0x03,0x88,0x80,0x00,0x40,0xa0,0x21,0x27,0x82,0x99,0x60,0x02,0x22,0x10,0x21, -0x8c,0x44,0x00,0x00,0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21, -0x00,0x04,0x25,0xc2,0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40, -0x03,0xc4,0x20,0x24,0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03, -0x35,0x08,0x00,0x28,0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48, -0x27,0x82,0x99,0x48,0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21, -0xa4,0x54,0x00,0x04,0x00,0xc0,0x38,0x21,0x0c,0x00,0x0e,0xd4,0xad,0x03,0x00,0x00, -0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c, -0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c, -0x8f,0xa6,0x00,0x18,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14,0x08,0x00,0x11,0x63,0x02,0x82,0xa0,0x21, -0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, -0x90,0x50,0x00,0x00,0x08,0x00,0x11,0x4f,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8, -0xaf,0xb1,0x00,0x24,0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x46,0x1c,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c, -0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c, -0x8f,0xb5,0x00,0x58,0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28, -0xaf,0xb0,0x00,0x20,0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21, -0x00,0x00,0xb8,0x21,0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xbd,0x40, -0x00,0x07,0x10,0x80,0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80, -0x00,0x65,0x18,0x21,0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03, -0x14,0x40,0x00,0x2d,0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05, -0x34,0x63,0x01,0x44,0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00, -0x8f,0xa3,0x00,0x4c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01, -0x10,0x40,0x00,0x04,0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09, -0x24,0x05,0x00,0x14,0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc, -0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x48,0x0c,0x00,0x0e,0xaf,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01, -0x08,0x00,0x11,0xc9,0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01, -0x10,0xc2,0x00,0x17,0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21, -0x12,0x20,0xff,0xed,0x02,0x20,0x10,0x21,0x27,0x83,0xbd,0x40,0x00,0x17,0x10,0x80, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28, -0x80,0x86,0x00,0x12,0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03, -0x00,0x46,0x10,0x21,0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21, -0x0c,0x00,0x0e,0xd4,0xac,0x62,0x00,0x00,0x08,0x00,0x11,0xc9,0xaf,0xd1,0x00,0x40, -0x96,0x74,0x00,0x1a,0x08,0x00,0x11,0xdc,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x01,0x08,0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x26,0xb7, -0x02,0x00,0x28,0x21,0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21, -0x0c,0x00,0x26,0xb7,0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00, -0x10,0x80,0x00,0xed,0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01, -0x96,0x63,0x00,0x14,0x96,0x44,0x00,0x14,0x27,0x85,0x99,0x40,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0, -0x8c,0x46,0x00,0x08,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21, -0x00,0x06,0x17,0x02,0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6, -0x00,0x03,0x17,0x02,0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b, -0x24,0x11,0x00,0x02,0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01, -0x12,0x22,0x00,0x5a,0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00, -0x96,0x49,0x00,0x14,0x27,0x82,0x99,0x44,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0, -0x01,0x49,0x18,0x21,0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18, -0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04, -0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01, -0x14,0x40,0x00,0x41,0x30,0x87,0x00,0x01,0x27,0x82,0x99,0x58,0x01,0x02,0x10,0x21, -0x80,0x44,0x00,0x00,0x27,0x82,0xbe,0xb8,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23, -0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21, -0x90,0x45,0x00,0x05,0x27,0x84,0xbd,0xe0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00, -0x10,0xa0,0x00,0x2b,0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21, -0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03, -0xa0,0x22,0x00,0xe1,0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40, -0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04, -0x01,0x49,0x10,0x21,0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08, -0x12,0x02,0x00,0x0b,0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21, -0x0c,0x00,0x27,0x33,0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16, -0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x25,0x08,0x00,0x11,0xdc,0xa2,0x42,0x00,0x16, -0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x26,0xe4,0xaf,0xa0,0x00,0x10, -0x08,0x00,0x12,0x5f,0x30,0x54,0xff,0xff,0x08,0x00,0x12,0x47,0x00,0x60,0x10,0x21, -0x14,0x80,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, -0x08,0x00,0x12,0x47,0x24,0x42,0x00,0x04,0x27,0x82,0x99,0x50,0x01,0x02,0x10,0x21, -0x90,0x43,0x00,0x00,0x08,0x00,0x12,0x57,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14, -0x02,0xc0,0xb8,0x21,0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21, -0x00,0x03,0x40,0x80,0x00,0x40,0x50,0x21,0x27,0x82,0x99,0x44,0x01,0x02,0x10,0x21, -0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c, -0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10, -0x30,0x66,0x00,0x01,0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x99,0x58, -0x01,0x02,0x10,0x21,0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00, -0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80, -0x27,0x83,0xbe,0xb0,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f, -0x00,0x00,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x99,0x50, -0x00,0x85,0x10,0x21,0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42, -0x01,0x49,0x10,0x21,0x27,0x82,0x99,0x58,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00, -0x27,0x82,0xbe,0xb8,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80, -0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05, -0x27,0x84,0xbd,0xe0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c, -0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00, -0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1, -0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21, -0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21, -0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21, -0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08, -0x10,0x82,0x00,0x0c,0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21, -0x0c,0x00,0x27,0x33,0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff, -0x92,0x62,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x11,0xdc, -0xa2,0x62,0x00,0x16,0x02,0x60,0x20,0x21,0x0c,0x00,0x26,0xe4,0xaf,0xa0,0x00,0x10, -0x08,0x00,0x12,0xce,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0xb6,0x00,0x60,0x10,0x21, -0x14,0x80,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, -0x08,0x00,0x12,0xb6,0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21, -0x90,0x43,0x00,0x00,0x08,0x00,0x12,0xc6,0xa0,0x43,0x00,0x03,0x27,0x85,0x99,0x50, -0x08,0x00,0x12,0xe2,0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26, -0x08,0x00,0x12,0x17,0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01, -0x08,0x00,0x12,0x1c,0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x27,0xbd,0xff,0xd0,0x24,0x42,0x4b,0xc8,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05, -0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28, -0xaf,0xb0,0x00,0x18,0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00, -0x00,0x80,0x90,0x21,0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10, -0x12,0x22,0x00,0xcf,0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1, -0x24,0x02,0x00,0x12,0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad, -0xae,0x43,0x00,0x40,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00, -0x3c,0x03,0x00,0x02,0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43, -0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x92,0x00,0x00,0x00,0x00,0x93,0x83,0x94,0x51,0x00,0x00,0x00,0x00, -0x30,0x62,0x00,0x02,0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3, -0x14,0x40,0x00,0x86,0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21, -0x26,0x22,0x00,0x01,0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb, -0x24,0x03,0x00,0x02,0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03, -0x10,0x40,0x00,0x58,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b, -0x02,0x40,0x20,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21, -0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x30,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07, -0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05, -0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec, -0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05, -0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05, -0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc, -0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03, -0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05, -0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc, -0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02, -0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05, -0x8c,0x42,0x02,0x2c,0x08,0x00,0x13,0x38,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04, -0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06, -0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31, -0xae,0x42,0x00,0x24,0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08, -0x16,0x62,0xff,0xa8,0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30, -0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x11,0x87, -0xaf,0xa2,0x00,0x14,0x08,0x00,0x13,0x31,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06, -0x8e,0x43,0x00,0x2c,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21, -0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87,0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31, -0xae,0x42,0x00,0x2c,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21, -0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x11,0x87, -0xaf,0xa3,0x00,0x14,0x08,0x00,0x13,0x31,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x57, -0x24,0x04,0x00,0x01,0x08,0x00,0x13,0x22,0x00,0x00,0x00,0x00,0x8f,0x84,0xbd,0x80, -0xae,0x40,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x00,0x00,0x00,0x00, -0x93,0x83,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69, -0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x08,0x00,0x13,0x1a, -0x00,0x00,0x00,0x00,0x02,0x40,0x20,0x21,0x0c,0x00,0x10,0xfe,0x02,0x20,0x28,0x21, -0x08,0x00,0x13,0x0e,0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0x4a,0x00,0x00,0x00,0x00,0x8f,0x82,0xbd,0x88,0x00,0x00,0x00,0x00, -0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b, -0xae,0x43,0x00,0x3c,0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d, -0x24,0x02,0x00,0x12,0x8f,0x82,0xbd,0x84,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a, -0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b,0xae,0x43,0x00,0x38, -0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11, -0x8f,0x82,0xbd,0x80,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00, -0x00,0x02,0x18,0x2b,0x08,0x00,0x13,0x0b,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x4f,0x7c, -0x3c,0x08,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00, -0xaf,0xbf,0x00,0x18,0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21, -0x24,0x11,0x00,0x0a,0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a, -0x30,0x63,0x00,0x01,0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40, -0x02,0x20,0x40,0x21,0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x48, -0x00,0x43,0x10,0x21,0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06, -0x02,0x23,0x80,0x21,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x10,0x80,0x00,0x00,0x00,0x00, -0x02,0x11,0x18,0x21,0x08,0x00,0x14,0x01,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0, -0xaf,0xbf,0x00,0x28,0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, -0xaf,0xb5,0x00,0x24,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c, -0x3c,0x06,0xb0,0x03,0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, -0x00,0x03,0x18,0x80,0x27,0x82,0x99,0x44,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18, -0x3c,0x02,0x80,0x00,0x24,0x42,0x50,0x2c,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08, -0x27,0x82,0x99,0x48,0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43, -0x32,0x10,0x00,0x01,0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21, -0x02,0x20,0x28,0x21,0x0c,0x00,0x13,0xdf,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21, -0x02,0x00,0x28,0x21,0x24,0x06,0x00,0x14,0x0c,0x00,0x10,0x80,0x00,0x40,0xa0,0x21, -0x86,0x43,0x00,0x0c,0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, -0x80,0x43,0x00,0x06,0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00, -0x24,0x64,0x00,0x03,0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09, -0x00,0x03,0x18,0x80,0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14, -0x34,0xe7,0x01,0x20,0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11, -0x02,0xa3,0xa8,0x21,0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00, -0x00,0x03,0x1c,0x02,0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c, -0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28, -0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x30,0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00, -0x8e,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c, -0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21, -0xac,0xe3,0x00,0x00,0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02, -0x08,0x00,0x14,0x53,0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c, -0x00,0x80,0x90,0x21,0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21, -0x00,0x04,0x20,0x80,0x27,0x82,0x99,0x44,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18, -0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x51,0xa8,0x27,0x83,0x99,0x48, -0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07, -0x34,0x42,0x01,0x00,0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04, -0x24,0x02,0x00,0x10,0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43, -0x30,0x84,0x00,0x01,0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40, -0x02,0x00,0x10,0x21,0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x10,0x80, -0x30,0x50,0x00,0xff,0x86,0x44,0x00,0x0c,0x27,0x85,0x99,0x50,0x3c,0x06,0xb0,0x09, -0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21, -0x80,0x64,0x00,0x06,0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03, -0x28,0x83,0x00,0x00,0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80, -0xa4,0xc2,0x00,0x00,0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x01,0x10,0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x01,0x14,0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08, -0x3c,0x06,0xb0,0x09,0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21, -0x34,0xc6,0x01,0x20,0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09, -0x34,0xa5,0x01,0x24,0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a, -0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04, -0x30,0x42,0xff,0xff,0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x99,0x58, -0x8f,0xbf,0x00,0x1c,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00, -0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x53,0x34, -0x00,0x05,0x2c,0x43,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00, -0x10,0xa0,0x00,0x05,0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0xb6,0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c, -0x00,0x00,0x10,0x21,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09, -0x10,0x40,0x00,0x89,0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79, -0x2a,0x02,0x00,0x03,0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01, -0x12,0x02,0x00,0x5a,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08, -0x3c,0x03,0x80,0x00,0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11, -0x92,0x27,0x00,0x11,0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a, -0x24,0x02,0x00,0x12,0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xbd,0x40, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x94,0x83,0x00,0x14,0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x00,0x40,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03, -0xa2,0x23,0x00,0x10,0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff, -0x27,0x83,0xbd,0x40,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, -0x82,0x23,0x00,0x12,0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42, -0x30,0x42,0x00,0x01,0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18, -0xa2,0x23,0x00,0x12,0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01, -0x96,0x23,0x00,0x0c,0x27,0x84,0x99,0x50,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00, -0x3c,0x02,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00, -0x90,0x62,0x00,0x04,0xa2,0x20,0x00,0x15,0xa3,0x80,0x95,0x14,0x24,0x02,0x00,0x01, -0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, -0x0c,0x00,0x14,0x6a,0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x15,0x1a, -0x00,0x07,0x16,0x00,0x0c,0x00,0x14,0x0b,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c, -0x27,0x84,0x99,0x48,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x44,0x20,0x21,0x90,0x85,0x00,0x07,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, -0xa2,0x25,0x00,0x13,0x90,0x83,0x00,0x07,0x08,0x00,0x15,0x32,0xa0,0x43,0x00,0x02, -0x92,0x26,0x00,0x0a,0x08,0x00,0x14,0xfb,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24, -0x00,0x00,0x00,0x00,0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07, -0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x14,0xee, -0xa2,0x22,0x00,0x04,0x08,0x00,0x15,0x4c,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b, -0x3c,0x02,0xb0,0x05,0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07, -0xa2,0x24,0x00,0x08,0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f, -0xae,0x20,0x00,0x2c,0x08,0x00,0x14,0xee,0xa2,0x22,0x00,0x06,0x08,0x00,0x15,0x5b, -0xa2,0x20,0x00,0x0a,0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01, -0x10,0x44,0x00,0x07,0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a, -0x92,0x22,0x00,0x2b,0xae,0x20,0x00,0x28,0x08,0x00,0x14,0xee,0xa2,0x22,0x00,0x05, -0x08,0x00,0x15,0x67,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41, -0x10,0x40,0x00,0x09,0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b, -0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08, -0x08,0x00,0x14,0xee,0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x10,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x14,0xee, -0xae,0x20,0x00,0x34,0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08, -0x08,0x00,0x14,0xee,0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03, -0x24,0x03,0x00,0x01,0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02, -0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x14,0xee, -0xa2,0x22,0x00,0x07,0x08,0x00,0x15,0x8d,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xbd,0x80, -0xae,0x20,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x32,0x10,0x00,0xff, -0x08,0x00,0x14,0xdf,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x24,0x42,0x56,0x68,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15, -0x3c,0x06,0xb0,0x05,0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x95,0x14, -0x00,0x00,0x00,0x00,0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28, -0x8c,0x82,0x00,0x2c,0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43, -0x30,0x63,0x00,0x01,0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28, -0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28, -0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x27,0xbd,0xff,0xd8,0x34,0x63,0x00,0x20,0x24,0x42,0x56,0xf8,0xac,0x62,0x00,0x00, -0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a, -0x27,0x83,0xbd,0x40,0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21, -0x8c,0x50,0x00,0x00,0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04, -0xa2,0x20,0x00,0x15,0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00, -0x82,0x22,0x00,0x12,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00, -0xa2,0x20,0x00,0x12,0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x60, -0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x63,0x00,0xdf,0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00, -0x14,0x60,0x00,0x45,0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04, -0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a, -0xa2,0x02,0x00,0x17,0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4, -0x10,0x60,0x00,0x03,0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16, -0x11,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00, -0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00, -0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x28,0x96,0x02,0x00,0x00,0x08,0x00,0x16,0x09,0xa6,0x02,0x00,0x14, -0x92,0x07,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x15,0xf5,0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06, -0x27,0x86,0x99,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0, -0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80, -0x00,0x46,0x10,0x21,0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00, -0x00,0xc3,0x20,0x24,0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04, -0x00,0x00,0x18,0x21,0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b, -0x08,0x00,0x15,0xf5,0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b, -0x08,0x00,0x16,0x29,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02, -0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00, -0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x07,0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x06, -0x08,0x00,0x15,0xef,0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x69,0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09, -0x92,0x25,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04, -0x10,0x40,0x00,0x3b,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, -0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27, -0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x99,0x44, -0x00,0xa3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01, -0x93,0x82,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a, -0x24,0x05,0x00,0x24,0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x23,0x34, -0x02,0x00,0x20,0x21,0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7, -0x08,0x00,0x15,0xe6,0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12, -0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x3c,0x04,0x00,0x80, -0x96,0x26,0x00,0x0c,0x08,0x00,0x16,0x66,0x00,0x06,0x2c,0x00,0x27,0x83,0x99,0x50, -0x27,0x82,0x99,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00, -0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x29,0x5e, -0xaf,0xa2,0x00,0x10,0x96,0x26,0x00,0x0c,0x08,0x00,0x16,0x60,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0xcd,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, -0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x16,0x4f,0x00,0xa2,0x10,0x07, -0x86,0x26,0x00,0x0c,0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78, -0x94,0x47,0x00,0x00,0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21, -0x3c,0x04,0xb0,0x09,0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x99,0x44, -0x00,0x02,0x10,0x80,0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18, -0xae,0x25,0x00,0x20,0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21, -0x0c,0x00,0x16,0xb6,0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c, -0x8e,0x27,0x00,0x20,0x02,0x20,0x20,0x21,0x0c,0x00,0x24,0x36,0xaf,0xa2,0x00,0x10, -0x08,0x00,0x15,0xe6,0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x15,0xe6, -0xa2,0x22,0x00,0x09,0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00, -0x08,0x00,0x15,0xe6,0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24, -0x00,0x80,0x70,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x5a,0xd8, -0xf1,0x43,0x00,0x06,0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21, -0xac,0x82,0x00,0x00,0x27,0x85,0x99,0x50,0x27,0x82,0x99,0x4f,0x27,0xbd,0xff,0xf8, -0x00,0x62,0x60,0x21,0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc, -0x00,0x00,0x78,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00, -0x80,0x48,0x00,0x04,0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x99,0x44, -0xa3,0xa7,0x00,0x00,0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff, -0x00,0x48,0x40,0x0b,0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06, -0x30,0x63,0x00,0x08,0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00, -0x27,0x82,0x99,0x58,0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50, -0x30,0xe5,0x00,0xff,0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24, -0x90,0x49,0x00,0x00,0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04, -0x10,0xa2,0x00,0x9d,0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c, -0x10,0x40,0x00,0x02,0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff, -0x00,0x04,0x10,0x40,0x27,0x83,0xc4,0x5c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21, -0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00, -0x10,0x60,0x00,0x02,0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00, -0x91,0x65,0x00,0x00,0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b, -0x10,0x40,0x00,0x0e,0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21, -0x30,0xa2,0x00,0x0f,0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21, -0x27,0x83,0xc4,0x5c,0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x05,0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80, -0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xbd,0xe8, -0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c, -0x14,0x60,0x00,0x06,0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21, -0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x17,0x17, -0xa1,0x82,0x00,0x00,0x8f,0x8d,0x87,0x70,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21, -0x00,0x06,0x74,0x82,0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03, -0x00,0xe0,0x10,0x21,0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff, -0xa3,0xa2,0x00,0x00,0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00, -0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23, -0x00,0x64,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xbd,0xe8, -0x00,0x44,0x10,0x21,0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00, -0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18, -0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10, -0x14,0x60,0x00,0x33,0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23,0x27,0x83,0xbe,0xb8,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00, -0x00,0x64,0xc0,0x24,0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f, -0x10,0x40,0x00,0x0f,0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x99,0x40, -0x00,0x44,0x10,0x21,0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41, -0x14,0x60,0x00,0x04,0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00, -0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21, -0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21, -0x24,0x42,0x00,0x04,0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21, -0x90,0x43,0x00,0x00,0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b, -0x14,0x60,0xff,0xad,0x30,0xe2,0x00,0xff,0x08,0x00,0x17,0x04,0x00,0x00,0x00,0x00, -0x08,0x00,0x17,0x65,0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00, -0x10,0x40,0xff,0x73,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xf2,0x00,0x00,0x00,0x00, -0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00, -0x08,0x00,0x16,0xd2,0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x5e,0x78,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00, -0x27,0xbd,0xff,0xc0,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, -0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c, -0xaf,0xbe,0x00,0x38,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c, -0x27,0x93,0x99,0x44,0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, -0x00,0x03,0x18,0x80,0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00, -0x34,0xa5,0x00,0x20,0x24,0x42,0x5e,0x90,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08, -0x27,0x95,0x99,0x50,0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21, -0x90,0x71,0x00,0x00,0x0c,0x00,0x16,0xb6,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21, -0x00,0x10,0x14,0x42,0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82, -0x02,0x80,0x28,0x21,0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c, -0x30,0x50,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x55,0x10,0x21,0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21, -0x8c,0xc7,0x00,0x18,0x27,0x83,0x99,0x40,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04, -0x84,0x46,0x00,0x06,0x00,0x03,0x19,0x42,0x0c,0x00,0x10,0x80,0x30,0x73,0x00,0x01, -0x00,0x40,0x88,0x21,0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10, -0x02,0x00,0x30,0x21,0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0, -0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x99,0x48,0x00,0x62,0x18,0x21, -0xa4,0x71,0x00,0x04,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, -0x86,0xc3,0x00,0x0c,0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06, -0x00,0x00,0x00,0x00,0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21, -0x00,0x07,0x38,0x43,0x00,0x07,0x38,0x40,0x0c,0x00,0x10,0xa7,0x03,0xc7,0x38,0x21, -0x08,0x00,0x17,0xe5,0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x27,0xbd,0xff,0xd0,0x34,0x63,0x00,0x20,0x24,0x42,0x60,0x18,0xaf,0xb2,0x00,0x20, -0xac,0x62,0x00,0x00,0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c, -0xaf,0xb0,0x00,0x18,0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04, -0x94,0x45,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0xbd,0x40,0x00,0x62,0x18,0x21, -0x30,0xa6,0xff,0xff,0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff, -0x00,0x06,0x32,0x02,0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12, -0x00,0x80,0x90,0x21,0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a, -0x10,0x40,0x00,0x14,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c, -0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x99,0x60,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12, -0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16, -0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x30,0x0c,0x00,0x17,0x9e,0x00,0x00,0x00,0x00,0x08,0x00,0x18,0x34, -0x00,0x00,0x00,0x00,0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21, -0x94,0x87,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00, -0x00,0x02,0x14,0x03,0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0, -0x00,0x62,0x18,0x21,0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x99,0x60, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x99,0x48, -0x00,0xa2,0x10,0x21,0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x99,0x50, -0x00,0x08,0x1d,0x02,0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01, -0x01,0x24,0x30,0x0b,0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02, -0x00,0x08,0x14,0x02,0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21, -0x15,0x40,0x00,0x11,0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, -0x30,0xa8,0x00,0xff,0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10, -0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, -0x01,0x02,0x10,0x04,0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c, -0x00,0x00,0x00,0x00,0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x27,0x84,0x99,0x50,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06, -0x00,0x03,0x1a,0x00,0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21, -0x94,0x82,0x00,0x00,0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06, -0x00,0x02,0x3c,0x03,0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21, -0x34,0xe2,0x08,0x00,0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00, -0x82,0x42,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, -0x86,0x43,0x00,0x0c,0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04, -0x92,0x23,0x00,0x16,0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x18,0x39, -0xa2,0x23,0x00,0x16,0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21, -0xa0,0x44,0x00,0x05,0x86,0x45,0x00,0x0c,0x0c,0x00,0x26,0xae,0x02,0x20,0x20,0x21, -0x10,0x40,0x00,0x5a,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, -0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10, -0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, -0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00, -0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33, -0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x0c,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06, -0x08,0x00,0x18,0x34,0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x18,0x34, -0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03, -0x00,0x00,0x00,0x00,0x08,0x00,0x18,0xc3,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00, -0x96,0x25,0x00,0x06,0x27,0x86,0x99,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21, -0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21, -0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08, -0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24, -0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01, -0x00,0x85,0x18,0x2b,0x08,0x00,0x18,0xc3,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd, -0x00,0x85,0x18,0x2b,0x08,0x00,0x18,0xe6,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09, -0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca, -0x00,0x00,0x00,0x00,0x08,0x00,0x18,0xbe,0xa2,0x40,0x00,0x07,0x08,0x00,0x18,0xbe, -0xa2,0x40,0x00,0x06,0x08,0x00,0x18,0xbe,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe, -0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f, -0x24,0x02,0x00,0x80,0x08,0x00,0x18,0xb5,0x00,0xa2,0x10,0x07,0x0c,0x00,0x17,0xa4, -0x02,0x40,0x20,0x21,0x08,0x00,0x18,0x34,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99, -0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, -0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24, -0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff, -0x14,0xa0,0x00,0x80,0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c, -0x27,0x93,0x99,0x44,0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x28,0x80,0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00, -0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64, -0x00,0x00,0x30,0x21,0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18, -0x93,0x82,0x94,0x51,0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42, -0x14,0x40,0x00,0x4d,0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03, -0x0c,0x00,0x23,0x34,0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14, -0x30,0xc5,0xff,0xff,0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x0b,0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00, -0x8c,0x62,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x23,0x34, -0x30,0x50,0x00,0x01,0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff, -0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01, -0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05, -0x00,0x00,0x00,0x00,0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x18,0x33, -0x30,0x42,0x00,0xc3,0x96,0x22,0x00,0x00,0x08,0x00,0x19,0x5a,0xa6,0x22,0x00,0x14, -0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x19,0x55,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff, -0x00,0x05,0x18,0xc0,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21, -0x27,0x84,0x99,0x40,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80, -0x8c,0x45,0x00,0x08,0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00, -0x00,0xa2,0x38,0x24,0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04, -0x00,0x00,0x18,0x21,0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b, -0x08,0x00,0x19,0x55,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b, -0x08,0x00,0x19,0x79,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06, -0x00,0x00,0x28,0x12,0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49, -0x00,0x00,0x20,0x21,0x96,0x47,0x00,0x0c,0x08,0x00,0x19,0x37,0x00,0x07,0x2c,0x00, -0x27,0x83,0x99,0x50,0x27,0x82,0x99,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21, -0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01, -0x0c,0x00,0x29,0x5e,0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x19,0x2a, -0x00,0x07,0x1c,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0x1b, -0xa2,0x40,0x00,0x07,0x08,0x00,0x19,0x1b,0xa2,0x40,0x00,0x06,0x08,0x00,0x19,0x1b, -0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, -0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x19,0x12, -0x00,0xa2,0x10,0x07,0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29, -0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x18,0x6d, -0x00,0xa2,0x10,0x07,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44,0x00,0x43,0x10,0x21, -0x8c,0x47,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x16,0xb6, -0x00,0x00,0x00,0x00,0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21, -0x00,0x00,0x38,0x21,0x0c,0x00,0x24,0x36,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00, -0x14,0x60,0xfe,0x6b,0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00, -0x14,0x60,0x00,0x40,0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04, -0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a, -0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10, -0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14, -0x92,0x22,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03, -0xa2,0x22,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50, -0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,0x08,0x00,0x18,0x33,0x34,0x42,0x00,0x02, -0x96,0x22,0x00,0x00,0x08,0x00,0x19,0xdc,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a, -0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0xd5, -0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x99,0x40, -0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, -0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, -0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24, -0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, -0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x19,0xd5, -0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x1a,0x04, -0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05, -0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x19,0xcf, -0xa2,0x40,0x00,0x07,0x08,0x00,0x19,0xcf,0xa2,0x40,0x00,0x06,0x08,0x00,0x19,0xcf, -0xa2,0x40,0x00,0x05,0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08, -0x00,0xa2,0x18,0x24,0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02, -0x24,0x02,0x00,0x01,0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x10,0x60,0xff,0xfd,0x00,0xa4,0x10,0x2b,0x08,0x00,0x1a,0x1f,0x00,0x00,0x00,0x00, -0x30,0x82,0xff,0xff,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x99,0x50, -0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00, -0x3c,0x03,0xb0,0x00,0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08, -0x00,0x43,0x10,0x21,0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00, -0xaf,0xbf,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, -0x14,0x40,0x00,0x41,0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03, -0x8e,0x10,0x00,0x00,0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03, -0x32,0x02,0x00,0x20,0x08,0x00,0x1a,0x45,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17, -0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x67,0x00,0xff,0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x99,0x20, -0x00,0x40,0x30,0x21,0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01, -0x24,0x42,0x00,0x02,0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a, -0xa4,0xa2,0x00,0x08,0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xbd,0x40, -0x24,0x11,0x00,0x12,0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x20,0x9b, -0x00,0x00,0x00,0x00,0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24, -0x3c,0x01,0xb0,0x03,0x0c,0x00,0x1a,0xfd,0xac,0x30,0x00,0x00,0x08,0x00,0x1a,0x45, -0x00,0x00,0x00,0x00,0x8f,0x85,0x99,0x20,0x08,0x00,0x1a,0x5b,0x00,0x00,0x00,0x00, -0x24,0x02,0xff,0x95,0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30, -0x3c,0x01,0xb0,0x03,0xac,0x30,0x00,0x00,0x0c,0x00,0x1a,0xc6,0xac,0x60,0x00,0x00, -0x08,0x00,0x1a,0x45,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50, -0x08,0x00,0x1a,0x45,0xac,0x46,0x00,0x00,0xaf,0xa7,0x00,0x0c,0xaf,0xa4,0x00,0x00, -0xaf,0xa5,0x00,0x04,0xaf,0xa6,0x00,0x08,0x27,0xbd,0xfe,0xe8,0x00,0x80,0x28,0x21, -0x27,0xa6,0x01,0x1c,0x27,0xa4,0x00,0x10,0xaf,0xbf,0x01,0x14,0x0c,0x00,0x2e,0xe2, -0xaf,0xb0,0x01,0x10,0x00,0x40,0x80,0x21,0x0c,0x00,0x1a,0x95,0x27,0xa4,0x00,0x10, -0x02,0x00,0x10,0x21,0x8f,0xbf,0x01,0x14,0x8f,0xb0,0x01,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x01,0x18,0x93,0x83,0x87,0x6c,0x27,0xbd,0xff,0xe8,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x14,0x14,0x60,0x00,0x14,0x00,0x80,0x80,0x21,0x80,0x82,0x00,0x00, -0x90,0x84,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x00,0x04,0x26,0x00, -0x00,0x04,0x26,0x03,0x30,0x84,0xff,0xff,0x0c,0x00,0x1a,0xb5,0x26,0x10,0x00,0x01, -0x92,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x60,0x20,0x21, -0x08,0x00,0x1a,0x9f,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x14,0x43,0xff,0xef, -0x00,0x00,0x00,0x00,0x0c,0x00,0x05,0x52,0x00,0x00,0x00,0x00,0x08,0x00,0x1a,0x9f, -0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x48,0x84,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x0c,0x00,0x2e,0x4a, -0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01, -0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0x18, -0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00, -0x3c,0x09,0x80,0x01,0x25,0x29,0x0b,0x90,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00, -0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0x40,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, -0x3c,0x08,0xb0,0x06,0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00, -0x24,0x01,0x00,0x01,0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00, -0x25,0x4a,0x6b,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03, -0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00, -0xac,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0xa8, -0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00, -0x3c,0x03,0x80,0x01,0x24,0x63,0x0b,0x90,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00, -0x00,0x00,0x00,0x00,0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04, -0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0xfd, -0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6b,0xf4,0x3c,0x0b,0xb0,0x03, -0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x0b,0x90,0x3c,0x03,0x80,0x01, -0x24,0x63,0x48,0x64,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08, -0xac,0x40,0x00,0x0c,0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9, -0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6c,0x34,0x3c,0x0b,0xb0,0x03, -0xad,0x6a,0x00,0x20,0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x95,0x20, -0x00,0x00,0x00,0x00,0x27,0x9d,0x99,0x08,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x6c,0x58, -0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00, -0x00,0x00,0x00,0x00,0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00, -0x0c,0x00,0x1d,0x43,0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03, -0x00,0x04,0x30,0x40,0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0, -0x24,0x03,0xff,0xff,0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00, -0xaf,0xbf,0x00,0x18,0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01, -0x8c,0x82,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23, -0x3c,0x03,0xb0,0x0a,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x1b,0x7a, -0x02,0x20,0x20,0x21,0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21, -0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, -0x27,0xbd,0xff,0xd8,0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff, -0xaf,0xb3,0x00,0x1c,0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, -0x00,0xc0,0x98,0x21,0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03, -0x00,0x04,0x10,0x40,0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23, -0x3c,0x03,0xb0,0x0a,0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21, -0x24,0x05,0x00,0x01,0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd, -0x3c,0x02,0xb0,0x0a,0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00, -0x0c,0x00,0x1b,0x7a,0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24, -0x00,0x53,0x10,0x04,0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01, -0x8e,0x22,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x28,0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23, -0x3c,0x04,0xb0,0x0a,0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01, -0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00, -0x08,0x00,0x1b,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06, -0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01, -0x2c,0x62,0x00,0x20,0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21, -0x00,0xa0,0x80,0x21,0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24, -0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34, -0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00, -0x00,0x10,0x1c,0x00,0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05, -0x24,0x63,0x16,0x09,0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24, -0x3c,0x06,0xb0,0x05,0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00, -0x34,0xc6,0x02,0x28,0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24, -0xa0,0xc2,0x00,0x00,0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x01,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x01,0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c, -0xa0,0x80,0x00,0x50,0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08, -0xac,0x80,0x00,0x14,0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20, -0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30, -0xa0,0x80,0x00,0x31,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c, -0xac,0x82,0x00,0x10,0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08, -0xac,0x80,0x00,0x4c,0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00, -0x3c,0x02,0x12,0x00,0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b, -0x24,0x02,0xff,0x80,0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00, -0x3c,0x04,0xb0,0x03,0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01, -0x3c,0x06,0x45,0x67,0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04, -0x34,0xc6,0x89,0xaa,0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09, -0x3c,0x07,0x01,0x23,0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00, -0x27,0xbd,0xff,0xe0,0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09, -0xac,0x26,0x00,0x00,0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c, -0x24,0x02,0xcd,0xef,0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09, -0xad,0x67,0x00,0x00,0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18, -0xaf,0xb5,0x00,0x14,0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08, -0xaf,0xb1,0x00,0x04,0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22, -0x35,0xce,0x00,0x14,0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab, -0x3c,0x10,0xb0,0x09,0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09, -0x3c,0x14,0xb0,0x09,0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09, -0xad,0xa8,0x00,0x00,0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18, -0x35,0x29,0xcd,0xee,0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24, -0x36,0x73,0x00,0x28,0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34, -0x36,0xf7,0x00,0x38,0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00, -0xae,0x23,0x00,0x00,0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04, -0xae,0x63,0x00,0x00,0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c, -0xae,0xa3,0x00,0x00,0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14, -0xae,0xe3,0x00,0x00,0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c, -0xa7,0x03,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x70,0xcc,0xac,0x62,0x00,0x00, -0x8c,0x83,0x00,0x34,0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x04, -0x00,0x80,0x28,0x21,0x8c,0x86,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0xc2,0x00,0xf7, -0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x4f, -0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xdd,0xac,0xa2,0x00,0x2c, -0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0xdc,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xc2,0x00,0xca,0x00,0x00,0x00,0x00,0x8c,0xa7,0x00,0x04,0x24,0x02,0x00,0x02, -0x10,0xe2,0x00,0xc0,0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x09,0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05, -0xac,0xa2,0x00,0x14,0x24,0x02,0x00,0x01,0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08, -0xac,0xa0,0x00,0x14,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x04,0x61,0x00,0x19,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x05, -0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, -0x14,0x40,0x00,0x12,0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0c,0x3c,0x02,0xb0,0x03, -0x80,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,0x3c,0x02,0xb0,0x03, -0x14,0xc0,0x00,0x07,0x34,0x42,0x00,0x3f,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01, -0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x34,0x42,0x00,0x3f, -0x90,0x44,0x00,0x00,0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x7f,0x3c,0x03,0xb0,0x05, -0x80,0xa2,0x00,0x31,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06, -0x34,0x42,0x80,0x18,0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00, -0x00,0x64,0x18,0x24,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08, -0xac,0xa2,0x00,0x00,0x8c,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05, -0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24, -0x14,0x60,0xff,0xf2,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e, -0x00,0x00,0x00,0x00,0x8c,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10, -0x3c,0x02,0xb0,0x03,0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f, -0xac,0xa2,0x00,0x0c,0x90,0xa3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03, -0x08,0x00,0x1c,0x93,0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80, -0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03, -0x10,0x60,0x00,0x15,0xa0,0xa4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b, -0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x0c,0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04, -0xac,0xa2,0x00,0x10,0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d, -0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10, -0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x38,0x24,0x04,0x00,0x01, -0x10,0x64,0x00,0x2d,0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,0x00,0x00,0x00,0x00, -0x10,0x62,0x00,0x10,0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,0x00,0x00,0x00,0x00, -0xac,0xa0,0x00,0x38,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,0x10,0xe4,0x00,0x07, -0x24,0x02,0x00,0x03,0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x0b, -0xac,0xa3,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,0x08,0x00,0x1c,0xe5, -0xac,0xa2,0x00,0x00,0x10,0xe4,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x0c, -0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x38, -0x10,0xe4,0x00,0x0e,0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,0xac,0xa2,0x00,0x18, -0x24,0x02,0x00,0x02,0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,0x08,0x00,0x1c,0xee, -0x24,0x02,0x00,0x01,0x08,0x00,0x1c,0xfb,0xac,0xa0,0x00,0x00,0x24,0x02,0x00,0x03, -0x08,0x00,0x1c,0xfb,0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,0xac,0xa2,0x00,0x38, -0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x00,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x7d,0x3c,0x02,0xb0,0x05, -0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0x78, -0x00,0x00,0x00,0x00,0x10,0xc0,0xff,0x81,0x24,0x02,0x00,0x0e,0x08,0x00,0x1c,0x88, -0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3e, -0x24,0x02,0x00,0x04,0x08,0x00,0x1c,0x93,0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20, -0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x75,0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05, -0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01, -0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0x14,0x40,0xff,0x2b,0xa4,0xa3,0x00,0x20, -0x08,0x00,0x1c,0x93,0x24,0x02,0x00,0x06,0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0x66,0x24,0x02,0x00,0x05,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c, -0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x1b, -0xac,0xa2,0x00,0x1c,0x08,0x00,0x1c,0x93,0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05, -0x8c,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01, -0x14,0x40,0xff,0x56,0x24,0x02,0x00,0x06,0x08,0x00,0x1c,0x41,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x0a,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xc8, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x27,0x91,0x91,0xf8,0x27,0x90,0x8f,0x38, -0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24, -0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x0c,0x00,0x2d,0xd7,0xaf,0xb2,0x00,0x18, -0x0c,0x00,0x07,0x90,0x00,0x00,0x00,0x00,0xaf,0x91,0x95,0x10,0xaf,0x90,0x99,0x20, -0x48,0x02,0x00,0x00,0x0c,0x00,0x1b,0xd1,0x00,0x00,0x00,0x00,0x0c,0x00,0x1f,0xea, -0x02,0x00,0x20,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00, -0x3a,0x54,0xff,0xff,0xa3,0x83,0x99,0x24,0x0c,0x00,0x00,0x34,0x02,0x80,0xa8,0x21, -0x0c,0x00,0x1b,0xdc,0x02,0x80,0xb0,0x21,0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0xfa, -0x02,0x80,0xb8,0x21,0x93,0x84,0x80,0x10,0x0c,0x00,0x29,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x0e,0x8a,0x02,0x20,0x20,0x21,0x0c,0x00,0x01,0x39,0x00,0x00,0x00,0x00, -0x27,0x84,0x8d,0x20,0x0c,0x00,0x1b,0xba,0x00,0x00,0x00,0x00,0x27,0x82,0x92,0x2c, -0xaf,0x82,0x8d,0x60,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00, -0x34,0x84,0x01,0x68,0x24,0x02,0xc8,0x80,0x34,0xa5,0x01,0x40,0x24,0x03,0x00,0x0a, -0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, -0xaf,0x86,0x8d,0x18,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00,0x0c,0x00,0x07,0xa1, -0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05,0x0c,0x00,0x2d,0xef,0x34,0x84,0x00,0x04, -0x8f,0x83,0x8d,0x20,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x11,0x10,0x40,0xff,0xf7, -0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x08,0xac,0x00,0x43,0x10,0x21, -0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00, -0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0x2f,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, -0x0c,0x00,0x1c,0x33,0x00,0x00,0x00,0x00,0x93,0x83,0x88,0x6d,0x24,0x02,0x00,0x01, -0x10,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x54,0x00,0x00,0x00,0x00, -0x24,0x42,0x00,0x01,0xaf,0x82,0x8d,0x54,0x08,0x00,0x1d,0x83,0x00,0x00,0x00,0x00, -0x27,0x84,0x8d,0x78,0x0c,0x00,0x32,0xae,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x9e, -0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x78,0x0c,0x00,0x34,0x90,0x00,0x00,0x00,0x00, -0xa3,0x82,0x8d,0x51,0xaf,0x80,0x8d,0x20,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00, -0x27,0x84,0x8f,0x38,0x0c,0x00,0x21,0x26,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, -0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x24, -0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x4c,0x14,0x40,0x00,0x1e, -0x24,0x02,0x00,0x01,0x8f,0x84,0x8d,0x28,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x1d, -0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x34,0x14,0x40,0x00,0x13,0x24,0x02,0x00,0x01, -0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x01, -0x24,0x03,0x00,0x03,0xaf,0x82,0x8d,0x24,0xaf,0x83,0x8d,0x20,0x08,0x00,0x1d,0x9e, -0x00,0x00,0x00,0x00,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8d,0x40, -0x14,0x40,0xff,0xf3,0x24,0x02,0x00,0x01,0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0xad, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x3c,0x14,0x40,0xff,0xf6, -0x24,0x02,0x00,0x01,0x08,0x00,0x1d,0xc5,0x3c,0x03,0xb0,0x09,0x27,0x84,0x8f,0x38, -0x0c,0x00,0x22,0x9f,0x00,0x00,0x00,0x00,0x83,0x82,0x8d,0x50,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0xed,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8d,0x4c, -0x14,0x40,0xff,0xe5,0x24,0x02,0x00,0x02,0x8f,0x84,0x8d,0x28,0x24,0x02,0x00,0x01, -0x10,0x82,0x00,0x12,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x05,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x02,0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x04, -0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01, -0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8d,0x40,0x14,0x40,0xff,0xf4, -0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xde,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05, -0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, -0xaf,0x82,0x8d,0x3c,0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xfe, -0x24,0x02,0x00,0x02,0x27,0x84,0x91,0xf8,0x0c,0x00,0x12,0xf2,0x00,0x00,0x00,0x00, -0x8f,0x83,0x8d,0x24,0xaf,0x82,0x8d,0x3c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a, -0xaf,0x83,0x8d,0x24,0x14,0x40,0x00,0x1f,0x24,0x02,0x00,0x05,0x8f,0x82,0x92,0x38, -0xaf,0x80,0x8d,0x20,0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x8d,0x28, -0x93,0x82,0x92,0x46,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73,0x3c,0x02,0xb0,0x05, -0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,0x00,0x64,0x18,0x24, -0x10,0x60,0xff,0x6d,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa0,0x8c,0x43,0x00,0x00, -0x3c,0x04,0x80,0x00,0xaf,0x80,0x92,0x20,0x24,0x63,0x00,0x01,0xac,0x43,0x00,0x00, -0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,0xaf,0x80,0x92,0x1c,0xaf,0x80,0x92,0x24, -0xaf,0x80,0x92,0x28,0xaf,0x80,0x92,0x34,0xaf,0x80,0x92,0x2c,0x08,0x00,0x1d,0x9e, -0x00,0x00,0x00,0x00,0xaf,0x82,0x8d,0x20,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00, -0x83,0x82,0x8d,0x70,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20, -0xaf,0x82,0x8d,0x3c,0x8f,0x85,0x8d,0x3c,0x27,0x84,0x91,0xf8,0x0c,0x00,0x14,0xcd, -0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0xa3,0x82,0x8d,0x50,0xaf,0x80,0x8d,0x3c, -0x10,0x60,0xff,0x5c,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21, -0xa7,0x83,0x8d,0x40,0x10,0x40,0xff,0xe7,0x24,0x02,0x00,0x06,0x24,0x04,0x00,0x02, -0xaf,0x84,0x8d,0x28,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, -0x27,0x85,0x91,0xf8,0x0c,0x00,0x15,0x9a,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x44, -0xaf,0x80,0x8d,0x4c,0x14,0x40,0x00,0x1a,0x00,0x40,0x18,0x21,0x8f,0x82,0x8d,0x48, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x16,0x24,0x02,0x00,0x02,0x8f,0x83,0x8d,0x28, -0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x01,0x8f,0x83,0x8d,0x24, -0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x06, -0xaf,0x82,0x8d,0x20,0x24,0x04,0x00,0x03,0xaf,0x84,0x8d,0x28,0x08,0x00,0x1d,0x9e, -0x00,0x00,0x00,0x00,0x3c,0x02,0x40,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05, -0xac,0x22,0x00,0x00,0xaf,0x80,0x8d,0x20,0x08,0x00,0x1e,0x76,0x24,0x04,0x00,0x03, -0x10,0x60,0x00,0x10,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20,0x27,0x85,0x91,0xf8, -0x0c,0x00,0x15,0xbe,0x00,0x00,0x00,0x00,0x8f,0x83,0x8d,0x24,0x24,0x02,0x00,0x01, -0xa3,0x80,0x8d,0x50,0xaf,0x80,0x8d,0x28,0x10,0x62,0x00,0x02,0x24,0x02,0x00,0x03, -0x24,0x02,0x00,0x04,0xaf,0x82,0x8d,0x20,0xaf,0x80,0x8d,0x44,0x08,0x00,0x1d,0x9e, -0x00,0x00,0x00,0x00,0x83,0x82,0x8d,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04, -0x00,0x00,0x00,0x00,0x27,0x84,0x91,0xf8,0x0c,0x00,0x18,0x06,0x00,0x00,0x00,0x00, -0x8f,0x82,0x8d,0x24,0xa3,0x80,0x8d,0x50,0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x28, -0x14,0x40,0x00,0x02,0x24,0x02,0x00,0x02,0xaf,0x82,0x8d,0x24,0xaf,0x80,0x8d,0x48, -0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20,0x27,0x85,0x91,0xf8, -0x0c,0x00,0x15,0xbe,0x00,0x00,0x00,0x00,0x8f,0x82,0x8d,0x24,0xa3,0x80,0x8d,0x50, -0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x28,0x14,0x40,0xfe,0xf3,0x24,0x02,0x00,0x02, -0xaf,0x82,0x8d,0x24,0x08,0x00,0x1d,0x9e,0x00,0x00,0x00,0x00,0x27,0x84,0x91,0xf8, -0x0c,0x00,0x18,0x06,0x00,0x00,0x00,0x00,0x08,0x00,0x1e,0xa6,0x00,0x00,0x00,0x00, -0x27,0x84,0x8d,0x78,0x0c,0x00,0x35,0x26,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xac, -0x00,0x00,0x00,0x00,0x0c,0x00,0x2b,0xc9,0x00,0x00,0x00,0x00,0x0c,0x00,0x32,0xa0, -0x00,0x00,0x00,0x00,0x0c,0x00,0x1f,0xdc,0x00,0x00,0x00,0x00,0x93,0x83,0xc5,0x58, -0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x1c,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08, -0x8c,0x44,0x00,0x00,0x8f,0x83,0xc5,0x50,0x8f,0x82,0xc5,0x54,0x00,0x83,0x18,0x23, -0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x14,0x2e,0xa3,0x00,0x01,0x2e,0x82,0x00,0x01, -0x00,0x43,0x10,0x25,0x2e,0xc4,0x00,0x01,0x00,0x44,0x10,0x25,0x2e,0xe3,0x00,0x01, -0x3c,0x05,0xb0,0x03,0x00,0x43,0x10,0x25,0x34,0xa5,0x01,0x18,0x8c,0xa3,0x00,0x00, -0x14,0x40,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x0b,0x7e, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0xc5,0x50,0x0c,0x00,0x01,0xe9,0x00,0x00,0x00,0x00, -0xaf,0x80,0x8d,0x20,0xaf,0x80,0x8d,0x54,0x08,0x00,0x1d,0x83,0x00,0x00,0x00,0x00, -0x27,0x90,0xbd,0x40,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, -0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x20,0x9b,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6, -0x26,0x10,0x00,0x04,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x8d,0x18,0x00,0x04,0x19,0xc2, -0x00,0x02,0x11,0xc2,0x10,0x62,0xfe,0xb3,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02, -0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05,0xaf,0x84,0x8d,0x18,0x30,0x63,0x00,0xff, -0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21,0x36,0x52,0x02,0x2c,0x27,0x90,0xbd,0x40, -0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06,0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04, -0x00,0x00,0x00,0x00,0x8f,0x85,0x8d,0x18,0x0c,0x00,0x26,0x58,0x02,0x60,0x30,0x21, -0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0xfe,0x95, -0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01,0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec, -0x26,0x10,0x00,0x04,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x8f,0x84,0x8d,0x2c, -0x27,0x85,0x91,0xf8,0x0c,0x00,0x1f,0x6f,0x00,0x00,0x00,0x00,0x8f,0x83,0x8d,0x2c, -0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0x87,0x24,0x02,0x00,0x05,0x08,0x00,0x1e,0x41, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00, -0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x06,0x3c,0x02,0xb0,0x03,0x27,0x84,0x91,0xf8, -0x0c,0x00,0x2b,0xf0,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x05, -0x34,0x42,0x00,0x14,0x8c,0x44,0x00,0x00,0x0c,0x00,0x2c,0x0d,0x00,0x00,0x00,0x00, -0x08,0x00,0x1d,0xd2,0x24,0x03,0x00,0x05,0x8f,0x82,0x92,0x2c,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xbd,0x80,0xaf,0x80,0x92,0x2c, -0x94,0x85,0x00,0x14,0x0c,0x00,0x23,0x34,0x00,0x00,0x00,0x00,0x93,0x82,0x94,0x51, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x8f,0x84,0xbd,0x80,0x0c,0x00,0x20,0x9b, -0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0xad,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x90, -0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01,0x27,0x84,0x91,0xf8, -0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x0e,0x8a,0x00,0x00,0x00,0x00, -0x27,0x84,0x8f,0x38,0x0c,0x00,0x1f,0xea,0x00,0x00,0x00,0x00,0x27,0x84,0x8d,0x20, -0x0c,0x00,0x1b,0xba,0x00,0x00,0x00,0x00,0x08,0x00,0x1f,0x56,0x00,0x00,0x00,0x00, -0x8f,0x82,0x92,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x18,0x21, -0x8f,0x82,0x8d,0x28,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00, -0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0, -0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0xc6,0x00,0x5f, -0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x5d, -0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01,0xa0,0xc3,0x00,0x00, -0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21,0x35,0x29,0x00,0x5e, -0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00,0x91,0x03,0x00,0x00, -0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfa, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c,0x24,0x05,0x0f,0x00, -0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x02,0x08,0x00,0x1f,0x90,0x3c,0x02,0xb0,0x03,0x24,0x04,0x08,0x8c, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04,0x24,0x05,0x00,0x0f, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30,0x24,0x06,0x00,0x03, -0x0c,0x00,0x1b,0x40,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21,0x24,0x05,0x00,0x14, -0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x08,0x00,0x1f,0x90,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x87,0x6d, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x87,0x6d, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x7f,0xa8,0x3c,0x04,0xb0,0x03, -0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8,0x8c,0x83,0x00,0x00, -0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21,0xa7,0x82,0x99,0x30, -0x27,0x88,0x99,0x40,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08,0x30,0xc2,0xff,0xff, -0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21,0x00,0x60,0x30,0x21, -0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21,0x00,0x87,0x20,0x21, -0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4,0xa4,0x43,0x00,0x00, -0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c,0x24,0x0a,0x00,0x02, -0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xbd,0x1c,0xac,0x43,0x00,0x00, -0xaf,0x84,0xbd,0x40,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18,0x94,0xc5,0x00,0x00, -0x8f,0x82,0xbd,0x40,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03,0x3c,0x03,0xb0,0x03, -0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xbd,0x44,0xa0,0x88,0x00,0x18, -0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x44,0x25,0xc4,0x00,0x54,0x25,0xc7,0x00,0x78, -0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x48,0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00, -0x8f,0x82,0xbd,0x48,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01,0xa0,0x45,0x00,0x21, -0xaf,0x87,0xbd,0x4c,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00,0x8f,0x82,0xbd,0x4c, -0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21,0xaf,0x88,0xbd,0x50, -0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x50,0x25,0xc4,0x00,0xc0, -0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x54,0xa0,0x89,0x00,0x18, -0x94,0x65,0x00,0x00,0x8f,0x82,0xbd,0x54,0x25,0xc4,0x00,0xe4,0x34,0xc6,0x00,0x60, -0xa0,0x45,0x00,0x21,0xaf,0x84,0xbd,0x58,0xa0,0x80,0x00,0x18,0x94,0xc5,0x00,0x00, -0x8f,0x82,0xbd,0x58,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c,0xa0,0x45,0x00,0x21, -0xaf,0x83,0xbd,0x5c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00,0x8f,0x82,0xbd,0x5c, -0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21,0x25,0xc6,0x01,0x98, -0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04,0x25,0xcc,0x02,0x28, -0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0xaf,0x87,0xbd,0x60, -0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xbd,0x64,0xa0,0x80,0x00,0x18, -0xaf,0x85,0xbd,0x68,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xbd,0x6c,0xa0,0xc0,0x00,0x18, -0xaf,0x89,0xbd,0x70,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xbd,0x74,0xa1,0x40,0x00,0x18, -0xaf,0x8b,0xbd,0x78,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xbd,0x7c,0xa1,0x80,0x00,0x18, -0xaf,0x8d,0xbd,0x80,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xbd,0x80, -0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x11, -0xaf,0x85,0xbd,0x84,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00, -0x8f,0x82,0xbd,0x84,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21, -0x24,0x02,0x00,0x12,0xaf,0x85,0xbd,0x88,0x34,0x63,0x00,0x6c,0xa0,0xa2,0x00,0x18, -0x94,0x64,0x00,0x00,0x8f,0x82,0xbd,0x88,0x24,0x05,0xff,0xff,0x24,0x07,0x00,0x01, -0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xbd,0x40,0x8c,0x82,0x00,0x00, -0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x00, -0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00,0xa4,0x65,0x00,0x06, -0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x0c, -0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14,0xa0,0x67,0x00,0x17, -0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20,0x04,0xc1,0xff,0xe7, -0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x82,0x6c,0xac,0x43,0x00,0x00, -0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,0x10,0x40,0x00,0x56,0x00,0x00,0x70,0x21, -0x97,0x82,0x99,0x30,0x94,0x8a,0x00,0x0c,0x27,0x87,0x99,0x40,0x00,0x02,0x40,0xc0, -0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x90,0x8b,0x00,0x18, -0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,0x39,0x64,0x00,0x10,0x2c,0x84,0x00,0x01, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x34,0x85,0x00,0x02,0x39,0x63,0x00,0x11, -0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,0x39,0x64,0x00,0x12,0x00,0x02,0x10,0x80, -0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,0x94,0x49,0x00,0x04,0x34,0x64,0x00,0x20, -0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,0x39,0x62,0x00,0x01,0x00,0x82,0x18,0x0b, -0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,0x00,0xc9,0x28,0x21,0x39,0x62,0x00,0x02, -0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,0x00,0x05,0x28,0x80,0x3c,0x02,0xb0,0x08, -0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,0x01,0x02,0x40,0x21,0x34,0x03,0xff,0xff, -0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,0x2d,0x67,0x00,0x13,0xad,0x0a,0x00,0x00, -0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,0xa7,0x89,0x99,0x30,0x10,0xe0,0x00,0x0f, -0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,0x00,0x0b,0x10,0x80,0x24,0x63,0x08,0xf0, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x60,0x94,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x02,0x74,0x03,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,0x93,0x83,0x99,0x24,0x91,0x82,0x00,0x21, -0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,0x00,0x04,0x24,0x00,0x00,0x62,0x18,0x21, -0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,0x00,0x65,0x10,0x2a,0x00,0xa2,0x18,0x0a, -0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,0x24,0x05,0xff,0xff,0x00,0x64,0x18,0x25, -0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,0xa5,0x85,0x00,0x0e,0xa1,0x80,0x00,0x10, -0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x62,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf, -0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x66, -0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x38,0x3c,0x03,0xb0,0x03, -0x08,0x00,0x20,0xdf,0x34,0x63,0x00,0x6e,0x3c,0x03,0xb0,0x03,0x08,0x00,0x20,0xdf, -0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20, -0x24,0x42,0x84,0x34,0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00,0x00,0xa6,0x28,0x21, -0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21,0x10,0x40,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, -0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10,0x24,0xa2,0x00,0x01, -0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,0x08,0x00,0x21,0x1a,0x00,0x47,0x18,0x21, -0x08,0x00,0x21,0x1a,0x24,0xa3,0x00,0x50,0x27,0xbd,0xff,0xc8,0xaf,0xb4,0x00,0x20, -0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x30, -0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb0,0x00,0x10, -0x00,0x80,0x90,0x21,0x84,0x84,0x00,0x08,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0xa5,0x00,0x20,0x24,0x42,0x84,0x98,0x3c,0x03,0xb0,0x06,0x00,0x04,0x20,0x80, -0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x06,0xb0,0x06,0x8c,0x82,0x00,0x00, -0x34,0xc6,0x80,0x24,0x8c,0x88,0x00,0x00,0x8c,0xc4,0x00,0x00,0x96,0x45,0x00,0x08, -0x30,0x53,0xff,0xff,0x00,0x08,0x44,0x02,0x34,0x84,0x01,0x00,0x3c,0x02,0xb0,0x00, -0x00,0x08,0x18,0xc0,0x00,0x13,0x3a,0x00,0xac,0xc4,0x00,0x00,0x00,0xe2,0x38,0x21, -0xae,0x53,0x02,0xb8,0x00,0x68,0x18,0x21,0x24,0xa5,0x00,0x02,0x8c,0xf6,0x00,0x00, -0x30,0xa5,0x01,0xff,0x8c,0xf5,0x00,0x04,0x27,0x86,0x99,0x40,0x00,0x03,0x18,0x80, -0x00,0x13,0xa0,0xc0,0xa6,0x45,0x00,0x08,0x00,0x66,0x18,0x21,0x02,0x93,0x10,0x21, -0x00,0x02,0x48,0x80,0x94,0x65,0x00,0x00,0x01,0x26,0x30,0x21,0x24,0x02,0xff,0xff, -0x00,0x15,0x1a,0x02,0x27,0x84,0x99,0x50,0xa4,0xc2,0x00,0x02,0x30,0x63,0x00,0x1f, -0x24,0x02,0x00,0x10,0x01,0x24,0x20,0x21,0xa4,0xc8,0x00,0x04,0x8c,0xf0,0x00,0x08, -0xa6,0x43,0x00,0x06,0xa6,0x45,0x00,0x0a,0xa0,0x82,0x00,0x06,0x86,0x43,0x00,0x06, -0x27,0x82,0x99,0x44,0x01,0x22,0x88,0x21,0x24,0x02,0x00,0x13,0x10,0x62,0x00,0xee, -0xae,0x27,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,0xa6,0x40,0x00,0x02, -0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08,0x8c,0x45,0x00,0x00, -0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x30,0x63,0x00,0x01,0xac,0xc5,0x00,0x08, -0x10,0x60,0x00,0xc7,0x30,0x97,0x00,0x01,0x00,0x10,0x16,0x82,0x30,0x46,0x00,0x01, -0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02,0x00,0x10,0x2e,0x42, -0x30,0x48,0x00,0x7f,0x24,0x02,0x00,0x01,0x30,0x71,0x00,0x01,0x30,0x84,0x00,0x01, -0x10,0xc2,0x00,0xb3,0x30,0xa3,0x00,0x01,0x00,0x60,0x28,0x21,0x0c,0x00,0x21,0x0d, -0x01,0x00,0x38,0x21,0x02,0x93,0x18,0x21,0x00,0x03,0x18,0x80,0x2c,0x46,0x00,0x54, -0x27,0x85,0x99,0x50,0x27,0x84,0x99,0x48,0x00,0x06,0x10,0x0a,0x00,0x65,0x28,0x21, -0x26,0x26,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02,0xa0,0x66,0x00,0x06, -0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x93,0x28,0x21,0x00,0x05,0x28,0x80, -0x27,0x82,0x99,0x44,0x00,0xa2,0x58,0x21,0x8d,0x64,0x00,0x18,0x00,0x10,0x15,0xc2, -0x30,0x42,0x00,0x01,0x8c,0x83,0x00,0x0c,0x27,0x84,0x99,0x60,0x00,0xa4,0x48,0x21, -0xa6,0x42,0x00,0x00,0xa6,0x56,0x00,0x04,0x8d,0x26,0x00,0x00,0x00,0x03,0x19,0x42, -0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01,0x00,0xc2,0x40,0x24, -0x00,0x03,0x1d,0x00,0x01,0x03,0x40,0x25,0x00,0x08,0x15,0x02,0x00,0x10,0x34,0x42, -0x00,0x10,0x3c,0x82,0x00,0x15,0x19,0x82,0x00,0x15,0x25,0x82,0x00,0x10,0x2c,0x02, -0x30,0x42,0x00,0x01,0x30,0xcd,0x00,0x01,0x30,0x6c,0x00,0x01,0x30,0xe6,0x00,0x01, -0x30,0x8a,0x00,0x03,0x32,0xb1,0x00,0x07,0x30,0xa5,0x00,0x01,0xad,0x28,0x00,0x00, -0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,0x8d,0x64,0x00,0x18,0x3c,0x03,0xff,0xf0, -0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,0x01,0x03,0x18,0x24,0x00,0x02,0x13,0x82, -0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,0x00,0x62,0x18,0x25,0xad,0x23,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x6a,0x00,0x00,0x00,0x00,0x15,0x80,0x00,0x03, -0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x5b,0x24,0x02,0x00,0x01,0x96,0x42,0x00,0x04, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x42,0x00,0x04,0x00,0xa0,0x20,0x21, -0x0c,0x00,0x21,0x0d,0x01,0xa0,0x28,0x21,0x02,0x93,0x18,0x21,0x00,0x03,0x40,0x80, -0x2c,0x45,0x00,0x54,0x27,0x84,0x99,0x50,0x01,0x04,0x20,0x21,0x00,0x05,0x10,0x0a, -0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,0x96,0x43,0x00,0x04, -0x27,0x82,0x99,0x40,0x01,0x02,0x10,0x21,0xa4,0x43,0x00,0x06,0x27,0x82,0x99,0x44, -0x92,0x46,0x00,0x01,0x01,0x02,0x10,0x21,0x8c,0x45,0x00,0x18,0x27,0x83,0x99,0x60, -0x01,0x03,0x18,0x21,0xa0,0x60,0x00,0x00,0xa0,0x86,0x00,0x07,0x94,0xa2,0x00,0x10, -0x24,0x03,0x00,0x04,0x30,0x42,0x00,0x0f,0x10,0x43,0x00,0x36,0x24,0xa5,0x00,0x10, -0x94,0xa3,0x00,0x16,0x27,0x87,0x99,0x58,0x01,0x07,0x10,0x21,0xa4,0x43,0x00,0x02, -0x94,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x24, -0x02,0x93,0x20,0x21,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0xa4,0x30,0x42,0x00,0xff, -0x10,0x43,0x00,0x1f,0x00,0x00,0x00,0x00,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0x88, -0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x14,0x02,0x93,0x18,0x21,0x27,0x84,0x99,0x60, -0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,0x3c,0x04,0x00,0x80, -0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x93,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x47,0x10,0x21,0xa0,0x51,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c, -0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x24,0x02,0x00,0x01, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x94,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xe9,0x02,0x93,0x18,0x21,0x02,0x93,0x20,0x21, -0x27,0x82,0x99,0x60,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21,0x8c,0x83,0x00,0x00, -0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24,0x08,0x00,0x22,0x02, -0xac,0x83,0x00,0x00,0x27,0x87,0x99,0x58,0x01,0x07,0x10,0x21,0x08,0x00,0x21,0xec, -0xa4,0x40,0x00,0x02,0x11,0x42,0x00,0x07,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x02, -0x14,0x40,0xff,0xa7,0x00,0xa0,0x20,0x21,0x96,0x42,0x00,0x04,0x08,0x00,0x21,0xca, -0x24,0x42,0x00,0x0c,0x96,0x42,0x00,0x04,0x08,0x00,0x21,0xca,0x24,0x42,0x00,0x08, -0x16,0xe6,0xff,0x96,0x3c,0x02,0xff,0xfb,0x8d,0x63,0x00,0x18,0x34,0x42,0xff,0xff, -0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x21,0xc3,0x00,0x00,0x30,0x21, -0x16,0xe6,0xff,0x4e,0x00,0x60,0x28,0x21,0x3c,0x02,0xfb,0xff,0x34,0x42,0xff,0xff, -0x02,0x02,0x10,0x24,0xac,0xe2,0x00,0x08,0x08,0x00,0x21,0x82,0x00,0x00,0x30,0x21, -0x93,0x87,0xc4,0x54,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82,0x27,0x82,0x99,0x48, -0x2c,0xe5,0x00,0x0c,0x01,0x22,0x48,0x21,0x30,0x63,0x00,0x01,0x30,0x86,0x00,0x01, -0x14,0xa0,0x00,0x06,0x00,0xe0,0x40,0x21,0x00,0x03,0x10,0x40,0x00,0x46,0x10,0x21, -0x00,0x02,0x11,0x00,0x00,0xe2,0x10,0x21,0x24,0x48,0x00,0x04,0x02,0x93,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x84,0x99,0x50,0x27,0x83,0x99,0x48,0x00,0x44,0x20,0x21, -0x00,0x43,0x10,0x21,0xa1,0x28,0x00,0x07,0xa0,0x40,0x00,0x06,0xa0,0x80,0x00,0x02, -0x08,0x00,0x21,0x92,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01,0x00,0xe0,0x20,0x21, -0x0c,0x00,0x01,0xc2,0xa6,0x42,0x00,0x02,0x8e,0x24,0x00,0x18,0x0c,0x00,0x05,0x39, -0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x06,0x00,0x00,0x00,0x00,0x30,0xa7,0xff,0xff, -0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21,0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x24,0x42,0x89,0x7c,0x27,0x85,0x99,0x50,0x00,0x03,0x18,0x80,0x34,0xc6,0x00,0x20, -0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00,0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21,0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00, -0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01,0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16, -0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04,0x3c,0x03,0xb0,0x03,0x27,0x86,0x99,0x40, -0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20,0x24,0x02,0x00,0x01,0xa0,0xa2,0x00,0x04, -0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08,0xa4,0xa7,0x00,0x00,0x94,0xa4,0x00,0x02, -0x3c,0x02,0x80,0x01,0x24,0x42,0xa1,0x7c,0xac,0x62,0x00,0x00,0x00,0x04,0x18,0xc0, -0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x94,0x62,0x00,0x04, -0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,0x00,0x82,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x00,0x83,0x20,0x21,0xa4,0x47,0x00,0x00, -0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x24,0x42,0x00,0x01, -0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04,0x90,0x82,0x00,0x16,0x24,0x85,0x00,0x06, -0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02,0x14,0x60,0xff,0xda,0xa0,0x82,0x00,0x16, -0x24,0x02,0x00,0x01,0x08,0x00,0x22,0x75,0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8, -0xaf,0xbf,0x00,0x10,0x00,0x80,0x38,0x21,0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x3c,0x0a,0xb0,0x06,0x34,0x63,0x00,0x20,0x24,0x42,0x8a,0x7c, -0x3c,0x0b,0xb0,0x08,0x27,0x89,0x99,0x40,0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20, -0x10,0x80,0x00,0x30,0xac,0x62,0x00,0x00,0x97,0x82,0x99,0x30,0x94,0xe6,0x02,0xba, -0x00,0x02,0x18,0xc0,0x00,0x6b,0x28,0x21,0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8, -0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21, -0xa4,0x66,0x00,0x00,0x00,0x08,0x28,0xc0,0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00, -0x8c,0xe4,0x02,0xb8,0x27,0x82,0x99,0x44,0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0, -0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18, -0x27,0x84,0x99,0x50,0x00,0x64,0x18,0x21,0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06, -0x00,0x05,0x28,0x80,0x30,0x42,0xff,0xff,0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff, -0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04, -0x00,0xa9,0x28,0x21,0x00,0x44,0x10,0x25,0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00, -0xa7,0x88,0x99,0x30,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x84,0xe3,0x00,0x06,0x27,0x82,0xbd,0x40,0x94,0xe5,0x02,0xba, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x0c,0x00,0x22,0x5f, -0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xd9,0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00, -0x00,0x80,0x58,0x21,0x27,0x8a,0x99,0x40,0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21, -0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80,0x3c,0x02,0x80,0x01,0x00,0x6a,0x18,0x21, -0x34,0x84,0x00,0x20,0x24,0x42,0x8b,0x9c,0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00, -0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35,0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04, -0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a,0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21, -0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21,0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d, -0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80, -0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21,0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21, -0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0,0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff, -0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04,0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04, -0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, -0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02,0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00,0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02, -0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01,0x00,0xa3,0x28,0x21,0x24,0x42,0xa1,0x7c, -0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03,0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08, -0x24,0x02,0x00,0x01,0x08,0x00,0x23,0x27,0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04, -0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff,0x30,0x43,0x00,0xff,0x14,0x60,0xff,0xf7, -0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff,0x08,0x00,0x23,0x27,0xa5,0x62,0x00,0x02, -0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21,0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80, -0x27,0x82,0x99,0x44,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20, -0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10,0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18, -0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x01,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20, -0x24,0x42,0x8c,0xd0,0xac,0xa2,0x00,0x00,0x27,0x83,0x99,0x50,0x00,0xc3,0x30,0x21, -0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06,0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff, -0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02, -0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff,0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x99,0x50,0x00,0x43,0x10,0x21,0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00, -0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06,0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21, -0x0c,0x00,0x22,0xe7,0x02,0x00,0x28,0x21,0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08,0x3c,0x09,0x80,0x01,0x27,0x88,0x99,0x40, -0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0,0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80, -0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03, -0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21, -0x00,0xa3,0x28,0x21,0x25,0x26,0xa1,0x7c,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20, -0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00, -0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a,0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21, -0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e, -0x27,0x88,0x99,0x40,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, -0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01, -0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21, -0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20,0x25,0x23,0xa1,0x7c,0xac,0xc3,0x00,0x00, -0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00,0x08,0x00,0x23,0x65,0xa4,0x90,0x00,0x02, -0x08,0x00,0x23,0x5c,0x32,0x50,0xff,0xff,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x24,0x42,0x8e,0x98,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04, -0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21,0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23, -0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff,0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73, -0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0,0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21, -0x03,0x0e,0x20,0x21,0x27,0x8d,0x99,0x40,0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80, -0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21,0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04, -0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02,0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21, -0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21, -0x00,0x6d,0x18,0x21,0x27,0x22,0xa1,0x7c,0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20, -0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57,0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21, -0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21,0x01,0x40,0x38,0x21,0x27,0x8b,0x99,0x44, -0x27,0x8a,0x99,0x50,0x00,0x06,0x40,0xc0,0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21, -0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02,0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01, -0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff,0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02, -0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0,0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03,0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21, -0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08, -0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21,0x27,0x26,0xa1,0x7c,0x34,0x03,0xff,0xff, -0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00, -0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10,0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e, -0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05,0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0, -0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04, -0x34,0xc6,0x00,0x20,0x27,0x27,0xa1,0x7c,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00, -0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00,0xac,0xaf,0x00,0x00,0x08,0x00,0x23,0xf4, -0x03,0x0e,0x20,0x21,0x08,0x00,0x23,0xcf,0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0, -0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x8d,0x99,0x40,0x00,0x4d,0x10,0x21, -0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00, -0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01,0x08,0x00,0x23,0xcf,0xa5,0x82,0x00,0x02, -0x08,0x00,0x23,0xcf,0x3c,0x19,0x80,0x01,0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20,0x24,0x42,0x90,0xd8,0xaf,0xb2,0x00,0x68, -0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60,0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84, -0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c,0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74, -0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c,0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a, -0x27,0x82,0xbd,0x40,0xaf,0xa6,0x00,0x90,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21, -0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94,0x27,0x86,0x99,0x44,0xaf,0xa3,0x00,0x1c, -0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff,0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0, -0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21,0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80, -0x27,0x84,0x99,0x50,0x00,0x64,0x20,0x21,0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21, -0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2, -0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21,0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c, -0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01,0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34, -0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40,0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50, -0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12,0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28, -0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xda,0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82, -0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11,0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98, -0x27,0x82,0x86,0x30,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x05, -0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00,0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a, -0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12, -0x24,0x42,0x00,0x10,0x30,0x42,0xff,0xfc,0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18, -0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff,0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48, -0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21,0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x4e, -0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02,0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21, -0x00,0x12,0x10,0xc0,0x00,0x52,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x40,0xa0,0x21, -0x27,0x82,0x99,0x58,0x00,0x82,0x10,0x21,0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58, -0x27,0x85,0x99,0x40,0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23,0x30,0x63,0x0f,0xff, -0x00,0x85,0x20,0x21,0x28,0x62,0x00,0x20,0x94,0x96,0x00,0x02,0x10,0x40,0x01,0xa1, -0x28,0x62,0x00,0x40,0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x68,0x10,0x06, -0x30,0x43,0x00,0x01,0x24,0x02,0x00,0x01,0x10,0x62,0x01,0x7b,0x3c,0x02,0xb0,0x03, -0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21, -0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80, -0x27,0x82,0x99,0x50,0x27,0x85,0x99,0x48,0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21, -0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff, -0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,0x27,0x82,0x99,0x60,0x00,0x04,0x20,0x80, -0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46, -0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02, -0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02, -0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21, -0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,0x02,0x92,0x10,0x21,0x93,0x82,0x94,0x51, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21, -0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff, -0x16,0xa0,0xff,0xb7,0x02,0xc0,0x90,0x21,0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00, -0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e, -0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a, -0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,0x27,0x84,0x99,0x44,0x94,0xb2,0x00,0x14, -0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21, -0x00,0x02,0x80,0x80,0x27,0x82,0x99,0x50,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06, -0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2, -0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e, -0x00,0xa3,0x38,0x21,0x27,0x82,0x99,0x40,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06, -0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c, -0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38, -0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14, -0x08,0x00,0x25,0x01,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x44,0x93,0x82,0x87,0x6d, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f, -0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87, -0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83, -0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d, -0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50, -0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21, -0x27,0x8c,0x99,0x40,0x3c,0x0b,0x80,0xff,0x24,0x10,0x00,0x04,0x27,0x91,0x99,0x44, -0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,0x27,0x8e,0x99,0x50,0x01,0x80,0x78,0x21, -0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, -0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44, -0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03, -0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, -0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b, -0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff, -0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21, -0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x80,0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04, -0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25, -0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01, -0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c, -0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00, -0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21, -0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88, -0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x44, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21, -0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x99,0x58,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, -0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,0x08,0x00,0x25,0x07,0x02,0x00,0x10,0x21, -0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,0x00,0x00,0x38,0x21,0x0c,0x00,0x29,0x5e, -0xaf,0xa2,0x00,0x10,0x08,0x00,0x25,0x07,0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff, -0x08,0x00,0x25,0x59,0xaf,0xa3,0x00,0x2c,0x8f,0xa8,0x00,0x44,0x08,0x00,0x25,0x7b, -0x31,0x09,0x00,0x03,0x08,0x00,0x25,0x34,0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44, -0xaf,0xa0,0x00,0x50,0x08,0x00,0x25,0x7b,0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48, -0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x03,0xc0,0x38,0x21,0x0c,0x00,0x23,0xa6, -0xaf,0xb7,0x00,0x10,0x08,0x00,0x24,0xe4,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80, -0x27,0x82,0x99,0x40,0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49, -0x00,0x00,0x00,0x00,0x08,0x00,0x24,0xdd,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80, -0x27,0x83,0x99,0x50,0x8f,0xa4,0x00,0x1c,0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01, -0x02,0x40,0x28,0x21,0x0c,0x00,0x26,0xae,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13, -0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48, -0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24, -0x27,0x82,0x99,0x40,0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30, -0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44, -0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04, -0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00, -0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff, -0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80, -0x27,0x82,0x99,0x44,0x00,0xa2,0x10,0x21,0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff, -0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,0x00,0x04,0x25,0x80,0x34,0x63,0xff,0xff, -0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04, -0x8f,0xa8,0x00,0x98,0x27,0x82,0x99,0x50,0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00, -0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb, -0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00, -0x08,0x00,0x24,0xe0,0x26,0xb5,0xff,0xff,0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21, -0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,0x08,0x00,0x25,0xee,0xaf,0xa2,0x00,0x2c, -0x8f,0xa6,0x00,0x1c,0x08,0x00,0x25,0xd8,0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48, -0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x0c,0x00,0x23,0xa6,0xaf,0xb7,0x00,0x10, -0x08,0x00,0x25,0xcf,0x00,0x00,0xb8,0x21,0x0c,0x00,0x1a,0x28,0x00,0x00,0x28,0x21, -0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x63,0x08,0x00,0xa4,0x43,0x00,0x00, -0x08,0x00,0x24,0xd4,0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21,0x00,0x03,0x80,0x80, -0x27,0x82,0x99,0x44,0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00, -0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x10,0x60,0x00,0x09, -0x24,0x06,0x00,0x01,0x93,0x82,0x94,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, -0x10,0x40,0xfe,0xa3,0x3c,0x04,0x00,0x80,0x27,0x85,0x99,0x40,0x08,0x00,0x25,0xbf, -0x02,0x05,0x28,0x21,0x27,0x83,0x99,0x58,0x27,0x82,0x99,0x50,0x02,0x03,0x18,0x21, -0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05,0x93,0x83,0x80,0x10, -0x00,0x00,0x38,0x21,0x0c,0x00,0x29,0x5e,0xaf,0xa3,0x00,0x10,0x08,0x00,0x26,0x35, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94, -0x08,0x00,0x24,0xac,0x00,0x64,0x10,0x06,0x08,0x00,0x24,0xad,0x00,0x00,0x18,0x21, -0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7, -0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,0x08,0x00,0x24,0x77,0xaf,0xa2,0x00,0x40, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20, -0x24,0x63,0x99,0x60,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, -0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45, -0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c, -0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, -0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16, -0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00, -0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, -0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a, -0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00, -0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01, -0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,0x08,0x00,0x26,0x82,0xa6,0x03,0x00,0x14, -0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x99,0x40,0x00,0x04,0x10,0xc0, -0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80, -0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, -0x8c,0x44,0x00,0x08,0x0c,0x00,0x1a,0x19,0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff, -0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,0x96,0x02,0x00,0x06,0x08,0x00,0x26,0x82, -0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,0x08,0x00,0x26,0x82,0xa6,0x02,0x00,0x14, -0x96,0x05,0x00,0x00,0x0c,0x00,0x26,0xae,0x02,0x00,0x20,0x21,0x08,0x00,0x26,0x69, -0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,0x0c,0x00,0x26,0xae,0x00,0x00,0x00,0x00, -0x08,0x00,0x26,0x65,0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x63,0x00,0x20,0x24,0x42,0x9a,0xb8,0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00, -0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x9a,0xdc,0xac,0x62,0x00,0x00, -0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21, -0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00, -0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00, -0x94,0xc8,0x00,0x00,0x27,0x83,0x99,0x40,0x93,0x85,0x94,0x50,0x00,0x08,0x10,0xc0, -0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, -0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,0x01,0x44,0x18,0x23,0x8f,0x82,0x94,0x68, -0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, -0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, -0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08, -0x08,0x00,0x26,0xda,0xa4,0xc2,0x00,0x14,0x08,0x00,0x26,0xda,0x00,0x00,0x18,0x21, -0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, -0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c, -0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,0x3c,0x02,0x80,0x01,0x3c,0x04,0xb0,0x03, -0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,0x24,0x42,0x9b,0x90,0x02,0xb1,0x48,0x21, -0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,0x24,0x03,0x00,0x01,0x27,0x82,0x99,0x50, -0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,0x27,0x84,0x99,0x44,0x01,0x24,0x20,0x21, -0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,0x27,0x83,0x99,0x60,0x01,0x23,0x48,0x21, -0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04, -0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2, -0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40, -0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21, -0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21, -0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21, -0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,0x27,0x90,0x99,0x40,0x02,0x30,0x80,0x21, -0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21, -0xa6,0x83,0x00,0x1a,0x27,0x82,0x99,0x48,0x0c,0x00,0x10,0x80,0x02,0x22,0x88,0x21, -0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30, -0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xaf,0xa9,0x00,0x10,0x0c,0x00,0x10,0xa7, -0xaf,0xa0,0x00,0x14,0x08,0x00,0x27,0x18,0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0, -0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, -0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28, -0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03, -0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21, -0x3c,0x02,0x80,0x01,0x00,0x03,0x48,0x80,0x24,0x42,0x9c,0xcc,0x00,0x80,0x98,0x21, -0x27,0x84,0x99,0x50,0x01,0x24,0x20,0x21,0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00, -0x80,0x83,0x00,0x06,0x27,0x82,0x99,0x44,0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18, -0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21, -0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10, -0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21, -0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21, -0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21, -0x27,0x83,0x99,0x58,0x01,0x23,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xbe,0xb0, -0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00, -0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80, -0x24,0x04,0x00,0x01,0x27,0x83,0x99,0x60,0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21, -0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01, -0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,0x02,0xa0,0x20,0x21,0x27,0x82,0x99,0x40, -0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a, -0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, -0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10, -0x0c,0x00,0x10,0xa7,0xaf,0xa0,0x00,0x14,0x08,0x00,0x27,0x7f,0x00,0x00,0x00,0x00, -0x27,0x83,0x99,0x60,0x01,0x23,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf, -0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d, -0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21, -0x27,0x82,0x86,0x30,0x00,0x15,0x18,0x40,0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00, -0x24,0xa2,0x00,0x05,0x00,0x54,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x10, -0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,0x27,0x83,0x99,0x50,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff, -0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f, -0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20, -0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10, -0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08, -0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef, -0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1, -0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3, -0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a, -0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d, -0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,0x27,0x99,0x99,0x40,0x01,0xf2,0xc0,0x23, -0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04, -0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21, -0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23, -0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff, -0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23, -0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40, -0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00, -0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x99,0x44, -0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x80, -0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,0x00,0x83,0x20,0x24,0x27,0x83,0x99,0x50, -0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04, -0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,0xa0,0xb5,0x00,0x03,0x27,0x84,0x99,0x60, -0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2, -0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a, -0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01, -0x27,0x84,0x99,0x40,0x00,0xc4,0x18,0x21,0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02, -0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23, -0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0, -0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,0x02,0x03,0x80,0x21,0x27,0x82,0x99,0x48, -0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21, -0x01,0x60,0x88,0x21,0x0c,0x00,0x10,0x80,0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21, -0xa6,0x02,0x00,0x04,0x08,0x00,0x27,0x85,0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b, -0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6, -0x01,0x71,0x18,0x21,0x08,0x00,0x27,0xfb,0x25,0x22,0x00,0x01,0x08,0x00,0x28,0x2a, -0x32,0xcc,0x00,0x03,0x08,0x00,0x28,0x2a,0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c, -0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x10,0xa7,0xaf,0xb4,0x00,0x14, -0x92,0x67,0x00,0x04,0x08,0x00,0x27,0x9d,0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff, -0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,0x00,0x04,0x20,0x80,0x27,0x82,0x99,0x40, -0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21, -0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff, -0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,0x27,0x88,0x99,0x40,0x00,0x06,0x30,0x80, -0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03, -0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21, -0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20, -0x24,0x42,0xa1,0x7c,0xac,0xe2,0x00,0x00,0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00, -0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0, -0x00,0x44,0x10,0x21,0x27,0x89,0x99,0x40,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, -0x97,0x83,0x99,0x30,0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0, -0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21, -0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20, -0x34,0x09,0xff,0xff,0x24,0x42,0xa1,0xd8,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00, -0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x99,0x30, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x63,0x00,0x20,0x24,0x42,0xa2,0x58,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, -0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,0x97,0x83,0x87,0x74,0x30,0x42,0xff,0xff, -0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,0xa7,0x82,0x87,0x74,0xaf,0x80,0xbd,0x90, -0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,0x27,0x84,0xbd,0x94,0x25,0x43,0xff,0xff, -0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00, -0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24, -0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14, -0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03, -0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,0x27,0x89,0xbd,0xe0,0x35,0x6b,0x01,0x20, -0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2, -0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6, -0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21, -0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a, -0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff, -0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, -0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40, -0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04, -0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08, -0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0, -0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b, -0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08, -0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5, -0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03, -0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04, -0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x90,0x82,0x00,0x05,0x08,0x00,0x28,0xd1,0xa0,0x82,0x00,0x08,0x97,0x85,0x94,0x5a, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20, -0x24,0x42,0xa4,0x0c,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00, -0x30,0x90,0x00,0xff,0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xbd,0xe4, -0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xbe,0xc4,0x27,0x99,0xbe,0xc0, -0x27,0x8e,0xbe,0xbe,0x27,0x8c,0xbd,0xe8,0x27,0x8d,0xbe,0x40,0x27,0x88,0xbe,0xb8, -0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58, -0x00,0x6e,0x20,0x21,0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00, -0xa1,0x00,0x00,0x04,0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21, -0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00, -0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9, -0x24,0x84,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21, -0x00,0x4c,0x18,0x21,0x27,0x87,0x87,0x78,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04, -0xac,0x82,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01, -0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6, -0x24,0x63,0x00,0x03,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b, -0x25,0x08,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x87,0x74, -0x00,0x00,0x48,0x21,0x27,0x83,0xbd,0x90,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01, -0x29,0x22,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x28,0x96, -0x00,0x00,0x00,0x00,0x2e,0x04,0x00,0x14,0x27,0x83,0xbd,0xe0,0x24,0x09,0x00,0x07, -0x10,0x80,0x00,0x0a,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff, -0xa0,0x62,0x00,0x00,0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6, -0x08,0x00,0x29,0x54,0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00, -0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80, -0x27,0x83,0xbd,0xe0,0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x84,0x00,0x20,0x24,0x42,0xa5,0x78,0x30,0xc6,0x00,0xff,0x93,0xaa,0x00,0x13, -0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xe8, -0x25,0x8f,0x00,0xd0,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc, -0x2c,0x43,0x00,0x18,0x10,0x60,0x00,0xc7,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80, -0x24,0x63,0x09,0x3c,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x1c, -0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x17,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x11,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0c, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0x03,0xe0,0x00,0x08, -0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xe8, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, -0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0x00,0x02, -0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x0a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe9,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, -0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe0, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdb,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,0x14,0x40,0xff,0xc5, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd0, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,0x10,0x40,0xff,0xf1, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb5, -0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f,0x24,0x42,0xff,0xf4, -0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xbd, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xb5,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8a,0x24,0x02,0x00,0x03, -0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xae, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xa9,0x24,0x02,0x00,0x02, -0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xc7,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x9c, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x9a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x95,0x24,0x02,0x00,0x03, -0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x29,0x8f, -0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x88, -0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xb7,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x17, -0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xf8,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x81, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x76,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x97, -0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0x15, -0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x65,0x24,0x02,0x00,0x03, -0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x8c,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xbd, -0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xbb,0x2d,0x42,0x00,0x25,0x08,0x00,0x29,0xf1, -0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x50, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xaa, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,0x00,0x00,0x00,0x00, -0x08,0x00,0x2a,0x3d,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,0x14,0x40,0xff,0xd8, -0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xad,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2c, -0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0x81,0x00,0x00,0x00,0x00, -0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff, -0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,0x00,0x04,0x48,0x80,0x01,0x82,0x58,0x21, -0x01,0x89,0x40,0x21,0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60, -0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,0x00,0x00,0x00,0x00,0x27,0x87,0x87,0x78, -0x01,0x27,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60, -0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00, -0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00, -0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00, -0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b, -0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4, -0x27,0x87,0x87,0x78,0x08,0x00,0x2a,0x74,0xa1,0x80,0x00,0xdd,0x27,0x82,0x87,0xe8, -0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01, -0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x02,0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60, -0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, -0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,0x10,0xe0,0x00,0x1d,0x24,0x83,0xff,0xfc, -0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x10,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, -0x24,0x63,0x09,0x9c,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x65, -0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x5a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0xad,0x82,0x00,0xd0, -0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, -0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, -0x93,0x05,0x00,0x01,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05, -0x24,0x02,0x00,0x01,0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08, -0xad,0x80,0x00,0xd8,0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05, -0x00,0x00,0x00,0x00,0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08, -0xa1,0x83,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43, -0xad,0xa2,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x87,0x78,0x8d,0xc5,0x00,0x00, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40, -0x00,0x04,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x2a,0x86, -0xad,0xc5,0x00,0x00,0x97,0x82,0x94,0x5c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a, -0x10,0x40,0xfe,0xab,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x87,0x78, -0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21, -0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80, -0x01,0x82,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, -0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x2a,0xfb,0xa1,0x80,0x00,0xdd, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x2a,0xb7,0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7, -0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa0, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x9d,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x93,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdd,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19, -0x14,0x40,0xff,0x7c,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x83,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b, -0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x14,0xa2,0xff,0x6c,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x2a,0xb7, -0x24,0x42,0xff,0xf4,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xbd,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x68, -0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb2, -0x24,0x02,0x00,0x03,0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xae,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5c, -0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x38, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00, -0x08,0x00,0x2b,0x0d,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x9a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x48, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x2a,0xb7,0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x3b,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x28,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x17,0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x69, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0x81,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x29,0x24,0x02,0x00,0x03, -0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb4,0x00,0x00,0x00,0x00, -0x08,0x00,0x2b,0x86,0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x6a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x18, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xb4, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00, -0x08,0x00,0x2b,0x2e,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x2c,0x2d,0x42,0x00,0x25, -0x08,0x00,0x2b,0x62,0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x03,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00, -0x08,0x00,0x2b,0x1b,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad, -0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0xae,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a, -0x14,0x40,0xff,0xd8,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x1e,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x2c,0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0xa9, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,0xaf,0xbf,0x00,0x14, -0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,0x8c,0x50,0x00,0x00, -0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,0xa3,0x82,0x80,0x10, -0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09, -0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01, -0xa3,0x82,0xc5,0x58,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x0b,0x3e,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00, -0xa3,0x80,0xc5,0x58,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x2b,0xda, -0x32,0x02,0x08,0x00,0x0c,0x00,0x29,0x03,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff, -0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x2b,0xd7,0x32,0x02,0x01,0x00, -0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18, -0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02, -0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24, -0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff, -0x01,0x00,0x30,0x21,0x0c,0x00,0x2c,0xa6,0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x2c,0xf8, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,0x08,0x00,0x2c,0x03, -0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0x3c,0x02,0xb0,0x03,0xaf,0xb6,0x00,0x30, -0xaf,0xb5,0x00,0x2c,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c, -0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, -0xaf,0xb2,0x00,0x20,0x34,0x42,0x00,0x3f,0x90,0x43,0x00,0x00,0x00,0x80,0x80,0x21, -0x00,0x00,0xb0,0x21,0x00,0x00,0x88,0x21,0x10,0x60,0x00,0x7a,0x00,0x00,0xa8,0x21, -0x3c,0x01,0xb0,0x03,0xa0,0x20,0x00,0x3f,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x47, -0x90,0x44,0x00,0x00,0x00,0x10,0x1a,0x02,0x3c,0x14,0xfd,0xff,0x30,0x84,0x00,0xff, -0xa0,0x50,0x00,0x00,0x30,0x73,0x00,0x0f,0xaf,0xa4,0x00,0x10,0x00,0x00,0x90,0x21, -0x3c,0x17,0x02,0x00,0x36,0x94,0xff,0xff,0x24,0x1e,0x00,0x04,0x0c,0x00,0x0e,0x76, -0x24,0x04,0x00,0x78,0x00,0x57,0x10,0x25,0x00,0x40,0x28,0x21,0x0c,0x00,0x0e,0x64, -0x24,0x04,0x00,0x78,0x00,0x00,0x80,0x21,0x0c,0x00,0x2d,0xc0,0x00,0x00,0x00,0x00, -0x26,0x03,0x00,0x01,0x10,0x40,0x00,0x53,0x30,0x70,0x00,0xff,0x12,0x00,0xff,0xfa, -0x00,0x00,0x00,0x00,0x0c,0x00,0x0e,0x76,0x24,0x04,0x00,0x78,0x00,0x54,0x10,0x24, -0x00,0x40,0x28,0x21,0x0c,0x00,0x0e,0x64,0x24,0x04,0x00,0x78,0x24,0x02,0x00,0x01, -0x12,0x62,0x00,0x44,0x24,0x04,0x00,0xe0,0x12,0x60,0x00,0x42,0x24,0x04,0x00,0xe4, -0x32,0x22,0x00,0x60,0x32,0x23,0x0c,0x00,0x00,0x03,0x1a,0x02,0x3c,0x05,0x00,0x60, -0x00,0x02,0x11,0x42,0x02,0x25,0x20,0x24,0x00,0x43,0x10,0x25,0x3c,0x03,0x04,0x00, -0x02,0x23,0x28,0x24,0x00,0x04,0x24,0x42,0x00,0x44,0x10,0x25,0x00,0x05,0x2d,0x02, -0x00,0x45,0x88,0x25,0x12,0x20,0x00,0x03,0x26,0xc2,0x00,0x01,0x30,0x56,0x00,0xff, -0x02,0xb1,0xa8,0x21,0x12,0x5e,0x00,0x2a,0x3c,0x05,0xb0,0x03,0x02,0x45,0x10,0x21, -0xa0,0x51,0x00,0x34,0x26,0x42,0x00,0x01,0x30,0x52,0x00,0xff,0x2e,0x43,0x00,0x05, -0x14,0x60,0xff,0xce,0x3c,0x02,0xb0,0x03,0x8f,0xa3,0x00,0x10,0x34,0x42,0x01,0x47, -0xa0,0x43,0x00,0x00,0x12,0xa0,0x00,0x0e,0x3c,0x02,0xb0,0x03,0x12,0xc0,0x00,0x0d, -0x34,0x42,0x00,0x3c,0x00,0x15,0x10,0x40,0x00,0x55,0x10,0x21,0x00,0x02,0x10,0xc0, -0x00,0x55,0x10,0x21,0x00,0x02,0xa8,0x80,0x02,0xb6,0x00,0x1b,0x16,0xc0,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0xa8,0x12,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x00,0x3c,0x3c,0x03,0xb0,0x03,0x3c,0x04,0xb0,0x03,0xa4,0x55,0x00,0x00, -0x34,0x63,0x00,0x1c,0x34,0x84,0x00,0x1d,0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00, -0xa0,0x82,0x00,0x00,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3e,0xa0,0x51,0x00,0x00,0x08,0x00,0x2c,0x5e, -0x26,0x42,0x00,0x01,0x0c,0x00,0x0e,0x76,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0x48, -0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x3c,0x3c,0x04,0xb0,0x03, -0x3c,0x05,0xb0,0x03,0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0x1c,0x34,0xa5,0x00,0x1d, -0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x2c,0x7d, -0xa0,0xa3,0x00,0x00,0x0c,0x00,0x1f,0x64,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x87, -0x3c,0x02,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x42,0x00,0x3c,0x34,0x84,0x00,0x14, -0x24,0x03,0x00,0x01,0xa4,0x40,0x00,0x00,0x3c,0x01,0xb0,0x03,0xa0,0x23,0x00,0x3f, -0x08,0x00,0x2c,0x7d,0xac,0x90,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10, -0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, -0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x30,0xb1,0x00,0xff,0x14,0x40,0x00,0x06, -0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14, -0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x38,0x02,0x00,0x30,0x21, -0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,0x3c,0x04,0xb0,0x09,0x00,0x02,0x14,0x00, -0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x2a,0x2a,0x22,0x00,0x02, -0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x20,0x24,0x02,0x00,0x03, -0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,0x16,0x60,0xff,0xe2,0x24,0x02,0x00,0x01, -0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x02, -0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xda,0x00,0x00,0x00,0x00, -0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40,0x3c,0x06,0x0c,0xb8, -0x08,0x00,0x2c,0xb1,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x48, -0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x40, -0x08,0x00,0x2c,0xd9,0x24,0x04,0x08,0x44,0x24,0x04,0x08,0x4c,0x0c,0x00,0x1b,0x40, -0x24,0x05,0xff,0xff,0x08,0x00,0x2c,0xce,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xe7, -0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xe7, -0x24,0x04,0x08,0x40,0x08,0x00,0x2c,0xe7,0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21, -0x0c,0x00,0x2d,0x38,0x02,0x20,0x28,0x21,0x08,0x00,0x2c,0xbc,0x00,0x40,0x30,0x21, -0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x00,0xc0,0x80,0x21, -0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,0x14,0x40,0x00,0x07,0x00,0x00,0x18,0x21, -0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x00,0x60,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14, -0x0c,0x00,0x1b,0x85,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x24,0x02,0x00,0x30,0x21, -0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,0x0c,0x00,0x2d,0x75,0x02,0x20,0x20,0x21, -0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x15, -0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x0b, -0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x04, -0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40, -0x3c,0x06,0x0c,0xb8,0x08,0x00,0x2d,0x04,0x02,0x00,0x18,0x21,0x08,0x00,0x2d,0x26, -0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x26, -0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x26,0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21, -0x0c,0x00,0x2d,0x38,0x02,0x20,0x28,0x21,0x08,0x00,0x2d,0x10,0x00,0x40,0x30,0x21, -0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, -0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,0x30,0xa5,0x00,0xff,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x12,0x24,0x02,0x00,0x02, -0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x07,0x24,0x04,0x08,0x4c, -0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40, -0x3c,0x06,0x0d,0xf8,0x08,0x00,0x2d,0x49,0x26,0x10,0xff,0xe2,0x08,0x00,0x2d,0x4e, -0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x4f, -0x24,0x05,0xff,0xff,0x08,0x00,0x2d,0x4e,0x24,0x04,0x08,0x44,0x2c,0xc2,0x00,0x10, -0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x14,0x28,0xa2,0x00,0x02, -0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0a,0x24,0x02,0x00,0x03, -0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,0x08,0x00,0x2d,0x49,0x26,0x10,0xff,0xf1, -0x24,0x05,0xff,0xff,0x0c,0x00,0x1b,0x40,0x3c,0x06,0x0d,0xb8,0x08,0x00,0x2d,0x49, -0x26,0x10,0xff,0xf1,0x08,0x00,0x2d,0x68,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf6, -0x24,0x04,0x08,0x40,0x08,0x00,0x2d,0x69,0x24,0x05,0xff,0xff,0x08,0x00,0x2d,0x68, -0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, -0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,0x28,0x82,0x00,0x02,0x14,0x40,0x00,0x27, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x17,0x00,0xa0,0x30,0x21, -0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,0x24,0x04,0x08,0x3c,0x8f,0xbf,0x00,0x10, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x1b,0x40, -0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, -0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,0x0c,0x00,0x1b,0x22,0x24,0x05,0x0f,0xff, -0x08,0x00,0x2d,0x83,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x34,0x0c,0x00,0x1b,0x40, -0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, -0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40, -0x24,0x06,0x00,0x01,0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa8,0x14,0x80,0xff,0xdf, -0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,0x0c,0x00,0x1b,0x40,0x3c,0x05,0x3f,0x00, -0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40,0x00,0x00,0x30,0x21, -0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x01, -0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa0,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x2c, -0x0c,0x00,0x1b,0x40,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x1b,0x40,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x1b,0x40,0x24,0x06,0x00,0x01,0x08,0x00,0x2d,0x92,0x24,0x04,0x08,0xa4, -0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x20,0x3c,0x06,0xc0,0x00, -0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0x34,0xa5,0x17,0x09,0xac,0x45,0x00,0x00, -0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,0x34,0x84,0x02,0x28,0x3c,0x07,0xb0,0x05, -0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,0x34,0xe7,0x04,0x50,0xa0,0x82,0x00,0x00, -0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,0x10,0x40,0xff,0xfc, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8, -0xaf,0xbf,0x00,0x10,0x0c,0x00,0x2e,0x85,0x00,0x00,0x00,0x00,0x0c,0x00,0x2e,0x87, -0x00,0x00,0x00,0x00,0x0c,0x00,0x2e,0xae,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05, -0x34,0x84,0x00,0x04,0x0c,0x00,0x2e,0x8e,0x34,0x05,0x9c,0x40,0x8f,0xbf,0x00,0x10, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x97,0x82,0x88,0x10, -0x00,0x00,0x00,0x00,0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x10, -0x14,0x60,0x00,0x28,0x00,0x80,0x30,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x20,0x00, -0xa7,0x80,0x88,0x10,0x00,0x43,0x10,0x24,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, -0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0x43,0x10,0x25,0x97,0x83,0x88,0x04, -0xac,0x82,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x63,0x00,0x01,0x3c,0x02,0x40,0x64, -0x34,0x42,0x64,0x00,0x00,0x03,0x24,0x00,0x00,0xa2,0x28,0x25,0x00,0x04,0x24,0x03, -0x24,0x02,0x00,0x64,0xac,0xc5,0x00,0x00,0xa7,0x83,0x88,0x04,0x10,0x82,0x00,0x2b, -0x00,0x00,0x00,0x00,0x87,0x82,0x88,0x06,0x24,0x03,0x00,0x3c,0x10,0x43,0x00,0x21, -0x00,0x00,0x00,0x00,0x87,0x82,0x88,0x08,0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x17, -0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x0a,0x24,0x02,0x00,0x18,0x10,0x62,0x00,0x0d, -0x00,0x00,0x00,0x00,0x87,0x83,0x88,0x0c,0x24,0x02,0x01,0x6d,0x10,0x62,0x00,0x03, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0e, -0xa7,0x80,0x88,0x0c,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x0e,0x08,0x00,0x2e,0x1d, -0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0c,0xa7,0x80,0x88,0x0a,0x24,0x42,0x00,0x01, -0xa7,0x82,0x88,0x0c,0x08,0x00,0x2e,0x19,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x0a, -0xa7,0x80,0x88,0x08,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x0a,0x08,0x00,0x2e,0x15, -0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x08,0xa7,0x80,0x88,0x06,0x24,0x42,0x00,0x01, -0xa7,0x82,0x88,0x08,0x08,0x00,0x2e,0x11,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x06, -0xa7,0x80,0x88,0x04,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x06,0x08,0x00,0x2e,0x0d, -0x00,0x00,0x00,0x00,0x00,0x04,0x24,0x00,0x3c,0x03,0xb0,0x07,0x00,0x04,0x24,0x03, -0x34,0x63,0x00,0x28,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x40, -0x10,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x01,0xb0,0x07,0xa0,0x24,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x28, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x10,0x60,0x00,0x06, -0x24,0x02,0xff,0xff,0x3c,0x02,0xb0,0x07,0x90,0x42,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x27,0xbd,0xff,0xe0,0xaf,0xb0,0x00,0x10,0x3c,0x10,0x04,0xc4,0x00,0x04,0x11,0x00, -0x36,0x10,0xb4,0x00,0x02,0x02,0x00,0x1b,0xaf,0xb1,0x00,0x14,0x3c,0x11,0xb0,0x07, -0x36,0x31,0x00,0x18,0x24,0x04,0x00,0x0a,0xaf,0xbf,0x00,0x18,0x14,0x40,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x80,0x12,0x0c,0x00,0x2e,0xda, -0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x00,0x24,0x03,0xff,0x80,0x24,0x04,0x00,0x0a, -0x00,0x43,0x10,0x25,0x0c,0x00,0x2e,0xda,0xa2,0x22,0x00,0x00,0x24,0x04,0x00,0x0a, -0x3c,0x01,0xb0,0x07,0xa0,0x30,0x00,0x00,0x0c,0x00,0x2e,0xda,0x00,0x10,0x82,0x03, -0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa0,0x50,0x00,0x00,0x0c,0x00,0x2e,0xda, -0x24,0x04,0x00,0x0a,0x92,0x22,0x00,0x00,0x8f,0xbf,0x00,0x18,0x8f,0xb0,0x00,0x10, -0x30,0x42,0x00,0x7f,0xa2,0x22,0x00,0x00,0x8f,0xb1,0x00,0x14,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x34,0x63,0x00,0x58,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x07,0xa4, -0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xf8,0x00,0x80,0x38,0x21, -0x00,0xa0,0x30,0x21,0x00,0x00,0x18,0x21,0x00,0x63,0x00,0x18,0x00,0x00,0x10,0x12, -0x00,0xc2,0x10,0x2b,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01, -0x2c,0x62,0x01,0x00,0x14,0x40,0xff,0xf9,0x00,0x63,0x00,0x18,0x24,0x63,0xff,0xff, -0x00,0x63,0x00,0x18,0x30,0x63,0x00,0xff,0x8c,0xe4,0x00,0x00,0x00,0x03,0x2a,0x00, -0x00,0x03,0x1c,0x00,0x00,0x00,0x10,0x12,0x00,0xc2,0x10,0x23,0x30,0x42,0x00,0xff, -0x00,0x45,0x10,0x21,0x00,0x43,0x10,0x21,0x00,0x82,0x20,0x25,0xac,0xe4,0x00,0x00, -0x8c,0xe2,0x00,0x00,0x3c,0x03,0x40,0x00,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x27,0xbd,0xff,0xe0,0xaf,0xbf,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, -0x3c,0x06,0xb0,0x03,0x34,0xc6,0x00,0x08,0x34,0x42,0x40,0x00,0xac,0x82,0x00,0x00, -0x8c,0x83,0x00,0x00,0x24,0x02,0xcf,0xff,0x3c,0x11,0xb0,0x07,0x00,0x62,0x18,0x24, -0xac,0x83,0x00,0x00,0x8c,0xc5,0x00,0x00,0x3c,0x02,0x00,0xff,0x24,0x04,0x00,0x0a, -0x00,0xa2,0x28,0x25,0xac,0xc5,0x00,0x00,0x0c,0x00,0x2e,0xda,0x36,0x31,0x00,0x18, -0x24,0x02,0xff,0x83,0x3c,0x04,0x00,0x01,0xa2,0x22,0x00,0x00,0x0c,0x00,0x2e,0x58, -0x34,0x84,0xc2,0x00,0x0c,0x00,0x2e,0xda,0x24,0x04,0x00,0x0a,0x24,0x02,0x00,0x03, -0xa2,0x22,0x00,0x00,0x24,0x04,0x00,0x0a,0x0c,0x00,0x2e,0xda,0x3c,0x10,0xb0,0x07, -0x36,0x10,0x00,0x10,0x24,0x02,0x00,0x06,0xa2,0x02,0x00,0x00,0x0c,0x00,0x2e,0xda, -0x24,0x04,0x00,0x0a,0xa2,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21, -0x24,0x63,0x00,0x01,0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34, -0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30, -0xaf,0xb3,0x00,0x2c,0xaf,0xb1,0x00,0x24,0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00, -0x00,0x80,0xa8,0x21,0x00,0xc0,0x90,0x21,0x00,0x07,0x1e,0x00,0x10,0x60,0x00,0x0f, -0x00,0x80,0x80,0x21,0x00,0x03,0x1e,0x03,0x24,0x02,0x00,0x25,0x10,0x62,0x00,0x13, -0x00,0x00,0x88,0x21,0xa2,0x07,0x00,0x00,0x8f,0xa5,0x00,0x44,0x26,0x10,0x00,0x01, -0x24,0xa5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x07,0x1e,0x00,0x14,0x60,0xff,0xf3,0x00,0x00,0x00,0x00,0x02,0x15,0x10,0x23, -0xa2,0x00,0x00,0x00,0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c, -0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x24,0xa5,0x00,0x01, -0xaf,0xa5,0x00,0x44,0x80,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xe0, -0x2c,0x62,0x00,0x11,0x10,0x40,0x00,0x11,0x00,0xa0,0x38,0x21,0x00,0x03,0x10,0x80, -0x3c,0x03,0x80,0x01,0x24,0x63,0x09,0xfc,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x2f,0x07, -0x36,0x31,0x00,0x10,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x08,0x08,0x00,0x2f,0x07, -0x36,0x31,0x00,0x20,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x04,0x90,0xe4,0x00,0x00, -0x3c,0x02,0x80,0x01,0x24,0x42,0x02,0x1c,0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04,0x14,0x60,0x00,0xfd,0x24,0x14,0xff,0xff, -0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2a,0x10,0x43,0x00,0xee, -0x26,0x42,0x00,0x03,0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x2e,0x10,0x62,0x00,0xcc, -0x24,0x08,0xff,0xff,0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x68,0x10,0x62,0x00,0xc4, -0x24,0x06,0xff,0xff,0x24,0x02,0x00,0x6c,0x10,0x62,0x00,0xc1,0x24,0x02,0x00,0x4c, -0x10,0x62,0x00,0xbf,0x24,0x02,0x00,0x5a,0x10,0x62,0x00,0xbd,0x00,0x00,0x00,0x00, -0x80,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xdb,0x2c,0x62,0x00,0x54, -0x10,0x40,0x00,0xaa,0x24,0x09,0x00,0x0a,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, -0x24,0x63,0x0a,0x40,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09, -0x24,0x02,0xff,0xfc,0x26,0x94,0xff,0xff,0x1a,0x80,0x00,0x05,0x24,0x02,0x00,0x20, -0x26,0x94,0xff,0xff,0xa2,0x02,0x00,0x00,0x1e,0x80,0xff,0xfd,0x26,0x10,0x00,0x01, -0x24,0x02,0xff,0xfc,0x26,0x44,0x00,0x03,0x00,0x82,0x90,0x24,0x92,0x42,0x00,0x03, -0x26,0x94,0xff,0xff,0x26,0x52,0x00,0x04,0xa2,0x02,0x00,0x00,0x1a,0x80,0x00,0x06, -0x26,0x10,0x00,0x01,0x24,0x02,0x00,0x20,0x26,0x94,0xff,0xff,0xa2,0x02,0x00,0x00, -0x1e,0x80,0xff,0xfd,0x26,0x10,0x00,0x01,0x8f,0xa5,0x00,0x44,0x08,0x00,0x2e,0xf9, -0x24,0xa5,0x00,0x01,0x24,0x02,0x00,0x25,0x08,0x00,0x2e,0xf6,0xa2,0x02,0x00,0x00, -0x36,0x31,0x00,0x40,0x24,0x09,0x00,0x10,0x24,0x02,0x00,0x4c,0x10,0xc2,0x00,0x2a, -0x24,0x02,0x00,0x6c,0x10,0xc2,0x00,0x05,0x24,0x02,0x00,0x5a,0x10,0xc2,0x00,0x1f, -0x24,0x02,0x00,0x68,0x10,0xc2,0x00,0x13,0x24,0x02,0xff,0xfc,0x24,0x02,0xff,0xfc, -0x26,0x43,0x00,0x03,0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02,0x8e,0x47,0x00,0x00, -0x00,0x00,0x30,0x21,0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x00,0xe0,0x10,0x21, -0x00,0x02,0x37,0xc3,0x02,0x00,0x20,0x21,0xaf,0xa9,0x00,0x10,0xaf,0xb4,0x00,0x14, -0xaf,0xa8,0x00,0x18,0x0c,0x00,0x30,0x47,0xaf,0xb1,0x00,0x1c,0x08,0x00,0x2f,0x62, -0x00,0x40,0x80,0x21,0x26,0x43,0x00,0x03,0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02, -0x96,0x47,0x00,0x02,0x00,0x00,0x30,0x21,0x10,0x40,0xff,0xf2,0x26,0x52,0x00,0x04, -0x00,0x07,0x14,0x00,0x08,0x00,0x2f,0x7c,0x00,0x02,0x3c,0x03,0x26,0x42,0x00,0x03, -0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x8e,0x47,0x00,0x00,0x00,0x00,0x30,0x21, -0x08,0x00,0x2f,0x7d,0x26,0x52,0x00,0x04,0x26,0x42,0x00,0x07,0x24,0x03,0xff,0xf8, -0x00,0x43,0x90,0x24,0x8e,0x46,0x00,0x00,0x8e,0x47,0x00,0x04,0x08,0x00,0x2f,0x7d, -0x26,0x52,0x00,0x08,0x08,0x00,0x2f,0x6a,0x36,0x31,0x00,0x02,0x26,0x44,0x00,0x03, -0x24,0x02,0xff,0xfc,0x00,0x82,0x90,0x24,0x8e,0x44,0x00,0x00,0x02,0x15,0x10,0x23, -0x26,0x52,0x00,0x04,0x08,0x00,0x2e,0xf8,0xac,0x82,0x00,0x00,0x08,0x00,0x2f,0x6a, -0x24,0x09,0x00,0x08,0x24,0x02,0xff,0xff,0x12,0x82,0x00,0x11,0x00,0x00,0x00,0x00, -0x26,0x43,0x00,0x03,0x24,0x02,0xff,0xfc,0x00,0x62,0x90,0x24,0x8e,0x47,0x00,0x00, -0x02,0x00,0x20,0x21,0x24,0x02,0x00,0x10,0x00,0x00,0x30,0x21,0xaf,0xa2,0x00,0x10, -0xaf,0xb4,0x00,0x14,0xaf,0xa8,0x00,0x18,0x0c,0x00,0x30,0x47,0xaf,0xb1,0x00,0x1c, -0x8f,0xa5,0x00,0x44,0x00,0x40,0x80,0x21,0x08,0x00,0x2e,0xf8,0x26,0x52,0x00,0x04, -0x24,0x14,0x00,0x08,0x08,0x00,0x2f,0xac,0x36,0x31,0x00,0x01,0x26,0x42,0x00,0x03, -0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x8e,0x53,0x00,0x00,0x00,0x00,0x00,0x00, -0x12,0x60,0x00,0x23,0x26,0x52,0x00,0x04,0x02,0x60,0x20,0x21,0x0c,0x00,0x31,0x15, -0x01,0x00,0x28,0x21,0x00,0x40,0x20,0x21,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09, -0x00,0x94,0x10,0x2a,0x10,0x40,0x00,0x07,0x26,0x94,0xff,0xff,0x24,0x03,0x00,0x20, -0x00,0x94,0x10,0x2a,0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff,0x14,0x40,0xff,0xfc, -0x26,0x10,0x00,0x01,0x18,0x80,0x00,0x07,0x00,0x80,0x18,0x21,0x92,0x62,0x00,0x00, -0x24,0x63,0xff,0xff,0x26,0x73,0x00,0x01,0xa2,0x02,0x00,0x00,0x14,0x60,0xff,0xfb, -0x26,0x10,0x00,0x01,0x00,0x94,0x10,0x2a,0x10,0x40,0xff,0x83,0x26,0x94,0xff,0xff, -0x24,0x03,0x00,0x20,0x00,0x94,0x10,0x2a,0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff, -0x14,0x40,0xff,0xfc,0x26,0x10,0x00,0x01,0x08,0x00,0x2f,0x62,0x00,0x00,0x00,0x00, -0x3c,0x02,0x80,0x01,0x08,0x00,0x2f,0xc6,0x24,0x53,0x08,0x04,0x24,0x02,0x00,0x25, -0xa2,0x02,0x00,0x00,0x8f,0xa5,0x00,0x44,0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x00, -0x90,0xa3,0x00,0x00,0x10,0x40,0x00,0x03,0x26,0x10,0x00,0x01,0x08,0x00,0x2e,0xf6, -0xa2,0x03,0x00,0x00,0x24,0xa5,0xff,0xff,0x08,0x00,0x2e,0xf8,0xaf,0xa5,0x00,0x44, -0x80,0xa6,0x00,0x00,0x24,0xa5,0x00,0x01,0x08,0x00,0x2f,0x3c,0xaf,0xa5,0x00,0x44, -0x24,0xa5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x90,0xa4,0x00,0x00,0x3c,0x02,0x80,0x01, -0x24,0x42,0x02,0x1c,0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x63,0x00,0x04,0x14,0x60,0x00,0x0f,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03, -0x24,0x03,0x00,0x2a,0x10,0x43,0x00,0x04,0x26,0x42,0x00,0x03,0x29,0x02,0x00,0x00, -0x08,0x00,0x2f,0x31,0x00,0x02,0x40,0x0b,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24, -0x24,0xa5,0x00,0x01,0x8e,0x48,0x00,0x00,0xaf,0xa5,0x00,0x44,0x08,0x00,0x30,0x0b, -0x26,0x52,0x00,0x04,0x0c,0x00,0x30,0x2b,0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44, -0x08,0x00,0x30,0x0b,0x00,0x40,0x40,0x21,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24, -0x8e,0x54,0x00,0x00,0x24,0xe5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x06,0x81,0xff,0x0d, -0x26,0x52,0x00,0x04,0x00,0x14,0xa0,0x23,0x08,0x00,0x2f,0x2d,0x36,0x31,0x00,0x10, -0x0c,0x00,0x30,0x2b,0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44,0x08,0x00,0x2f,0x2d, -0x00,0x40,0xa0,0x21,0x08,0x00,0x2f,0x07,0x36,0x31,0x00,0x01,0x8c,0x86,0x00,0x00, -0x3c,0x02,0x80,0x01,0x00,0x80,0x48,0x21,0x90,0xc3,0x00,0x00,0x24,0x44,0x02,0x1c, -0x00,0x64,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x04, -0x10,0x40,0x00,0x10,0x00,0x00,0x38,0x21,0x00,0x80,0x40,0x21,0x24,0xc2,0x00,0x01, -0x80,0xc5,0x00,0x00,0xad,0x22,0x00,0x00,0x90,0x43,0x00,0x00,0x00,0x40,0x30,0x21, -0x00,0x07,0x10,0x80,0x00,0x68,0x18,0x21,0x90,0x64,0x00,0x00,0x00,0x47,0x10,0x21, -0x00,0x02,0x10,0x40,0x00,0x45,0x10,0x21,0x30,0x84,0x00,0x04,0x14,0x80,0xff,0xf3, -0x24,0x47,0xff,0xd0,0x03,0xe0,0x00,0x08,0x00,0xe0,0x10,0x21,0x27,0xbd,0xff,0x98, -0xaf,0xb2,0x00,0x50,0x8f,0xb2,0x00,0x84,0x3c,0x02,0x80,0x01,0xaf,0xb4,0x00,0x58, -0x32,0x43,0x00,0x40,0xaf,0xb1,0x00,0x4c,0xaf,0xb0,0x00,0x48,0xaf,0xb7,0x00,0x64, -0xaf,0xb6,0x00,0x60,0xaf,0xb5,0x00,0x5c,0xaf,0xb3,0x00,0x54,0x00,0x80,0x68,0x21, -0x00,0xc0,0x70,0x21,0x00,0xe0,0x78,0x21,0x8f,0xb0,0x00,0x78,0x8f,0xb8,0x00,0x7c, -0x8f,0xb1,0x00,0x80,0x10,0x60,0x00,0x03,0x24,0x54,0x08,0x0c,0x3c,0x02,0x80,0x01, -0x24,0x54,0x08,0x34,0x32,0x42,0x00,0x10,0x10,0x40,0x00,0x04,0x26,0x02,0xff,0xfe, -0x24,0x02,0xff,0xfe,0x02,0x42,0x90,0x24,0x26,0x02,0xff,0xfe,0x2c,0x42,0x00,0x23, -0x10,0x40,0x00,0x5d,0x00,0x00,0x18,0x21,0x32,0x42,0x00,0x01,0x24,0x15,0x00,0x30, -0x24,0x03,0x00,0x20,0x32,0x44,0x00,0x02,0x00,0x62,0xa8,0x0a,0x10,0x80,0x00,0x07, -0x00,0x00,0xb8,0x21,0x05,0xc0,0x00,0x96,0x32,0x42,0x00,0x04,0x10,0x40,0x00,0x90, -0x32,0x42,0x00,0x08,0x24,0x17,0x00,0x2b,0x27,0x18,0xff,0xff,0x32,0x56,0x00,0x20, -0x12,0xc0,0x00,0x07,0x01,0xcf,0x10,0x25,0x24,0x02,0x00,0x10,0x12,0x02,0x00,0x86, -0x27,0x03,0xff,0xff,0x3a,0x02,0x00,0x08,0x00,0x62,0xc0,0x0a,0x01,0xcf,0x10,0x25, -0x14,0x40,0x00,0x55,0x00,0x00,0xc8,0x21,0x24,0x02,0x00,0x30,0x24,0x19,0x00,0x01, -0xa3,0xa2,0x00,0x00,0x02,0x39,0x10,0x2a,0x03,0x22,0x88,0x0b,0x32,0x43,0x00,0x11, -0x14,0x60,0x00,0x0a,0x03,0x11,0xc0,0x23,0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x07, -0x27,0x18,0xff,0xff,0x24,0x03,0x00,0x20,0x03,0x00,0x10,0x21,0xa1,0xa3,0x00,0x00, -0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,0x12,0xe0,0x00,0x03, -0x00,0x00,0x00,0x00,0xa1,0xb7,0x00,0x00,0x25,0xad,0x00,0x01,0x12,0xc0,0x00,0x07, -0x32,0x42,0x00,0x10,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x38,0x24,0x02,0x00,0x10, -0x12,0x02,0x00,0x30,0x24,0x02,0x00,0x30,0x32,0x42,0x00,0x10,0x14,0x40,0x00,0x0a, -0x03,0x31,0x10,0x2a,0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x06,0x27,0x18,0xff,0xff, -0x03,0x00,0x10,0x21,0xa1,0xb5,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc, -0x25,0xad,0x00,0x01,0x03,0x31,0x10,0x2a,0x10,0x40,0x00,0x07,0x26,0x31,0xff,0xff, -0x24,0x03,0x00,0x30,0x03,0x31,0x10,0x2a,0xa1,0xa3,0x00,0x00,0x26,0x31,0xff,0xff, -0x14,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,0x03,0x20,0x10,0x21,0x18,0x40,0x00,0x08, -0x27,0x39,0xff,0xff,0x03,0xb9,0x10,0x21,0x90,0x43,0x00,0x00,0x03,0x20,0x20,0x21, -0x27,0x39,0xff,0xff,0xa1,0xa3,0x00,0x00,0x1c,0x80,0xff,0xfa,0x25,0xad,0x00,0x01, -0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x07,0x27,0x18,0xff,0xff,0x24,0x03,0x00,0x20, -0x03,0x00,0x10,0x21,0xa1,0xa3,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc, -0x25,0xad,0x00,0x01,0x01,0xa0,0x18,0x21,0x7b,0xb6,0x03,0x3c,0x7b,0xb4,0x02,0xfc, -0x7b,0xb2,0x02,0xbc,0x7b,0xb0,0x02,0x7c,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x68,0xa1,0xa2,0x00,0x00,0x92,0x83,0x00,0x21,0x25,0xad,0x00,0x01, -0xa1,0xa3,0x00,0x00,0x08,0x00,0x30,0x9a,0x25,0xad,0x00,0x01,0x24,0x02,0x00,0x30, -0x08,0x00,0x30,0xcd,0xa1,0xa2,0x00,0x00,0x01,0xcf,0x10,0x25,0x10,0x40,0xff,0xad, -0x00,0x00,0x60,0x21,0x00,0x0e,0x18,0x02,0x03,0x3d,0x98,0x21,0x00,0x60,0x20,0x21, -0x01,0xe0,0x38,0x21,0x10,0x60,0x00,0x04,0x27,0x39,0x00,0x01,0x00,0x70,0x00,0x1b, -0x00,0x00,0x20,0x12,0x00,0x00,0x18,0x10,0x00,0x80,0x48,0x21,0x00,0xe0,0x30,0x21, -0x01,0x80,0x70,0x21,0x01,0x80,0x28,0x21,0x10,0x00,0x00,0x06,0x24,0x04,0x00,0x21, -0x00,0x03,0x08,0x40,0x00,0x03,0x2f,0xc2,0x00,0x22,0x18,0x25,0x00,0x06,0x30,0x40, -0x00,0x0e,0x70,0x40,0x14,0xa0,0x00,0x02,0x00,0x70,0x10,0x2b,0x14,0x40,0x00,0x03, -0x24,0x84,0xff,0xff,0x00,0x70,0x18,0x23,0x25,0xce,0x00,0x01,0x14,0x80,0xff,0xf4, -0x00,0x06,0x17,0xc2,0x02,0x83,0x18,0x21,0x01,0xc0,0x38,0x21,0x00,0x00,0x50,0x21, -0x00,0x09,0x20,0x00,0x00,0x00,0x28,0x21,0x90,0x66,0x00,0x00,0x00,0x8a,0x70,0x25, -0x00,0xa7,0x78,0x25,0x01,0xcf,0x10,0x25,0x14,0x40,0xff,0xda,0xa2,0x66,0x00,0x00, -0x08,0x00,0x30,0x82,0x02,0x39,0x10,0x2a,0x08,0x00,0x30,0x7b,0x27,0x18,0xff,0xfe, -0x10,0x40,0xff,0x73,0x32,0x56,0x00,0x20,0x08,0x00,0x30,0x72,0x24,0x17,0x00,0x20, -0x00,0x0f,0x78,0x23,0x00,0x0e,0x70,0x23,0x00,0x0f,0x10,0x2b,0x01,0xc2,0x70,0x23, -0x08,0x00,0x30,0x72,0x24,0x17,0x00,0x2d,0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x06,0x00,0x80,0x18,0x21,0x24,0x63,0x00,0x01,0x80,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x64,0x10,0x23,0x24,0xa5,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xa2,0x00,0x0d, -0x00,0x80,0x18,0x21,0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, -0x00,0x00,0x00,0x00,0x24,0x06,0xff,0xff,0x24,0xa5,0xff,0xff,0x10,0xa6,0x00,0x05, -0x24,0x63,0x00,0x01,0x80,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x64,0x10,0x23,0x80,0x82,0x00,0x00, -0x90,0x88,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x48,0x21,0x90,0xa3,0x00,0x00, -0x00,0xa0,0x30,0x21,0x10,0x60,0x00,0x0b,0x00,0x60,0x38,0x21,0x00,0x08,0x16,0x00, -0x00,0x02,0x46,0x03,0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,0x11,0x02,0x00,0x05, -0x24,0xc6,0x00,0x01,0x90,0xc3,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf9, -0x00,0x60,0x38,0x21,0x00,0x03,0x16,0x00,0x10,0x40,0x00,0x06,0x00,0x00,0x00,0x00, -0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,0x25,0x29,0x00,0x01,0x14,0x40,0xff,0xeb, -0x00,0x40,0x40,0x21,0x03,0xe0,0x00,0x08,0x01,0x20,0x10,0x21,0x80,0x82,0x00,0x00, -0x90,0x87,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x18,0x21,0x90,0xa2,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x0c,0x00,0xa0,0x30,0x21, -0x00,0x07,0x16,0x00,0x00,0x02,0x3e,0x03,0x00,0x03,0x16,0x03,0x10,0xe2,0x00,0x0d, -0x00,0x80,0x18,0x21,0x24,0xc6,0x00,0x01,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x1e,0x00,0x14,0x60,0xff,0xf9,0x00,0x03,0x16,0x03,0x24,0x84,0x00,0x01, -0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec,0x00,0x40,0x38,0x21, -0x00,0x00,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0, -0xaf,0xb0,0x00,0x10,0x8f,0x90,0xc5,0x5c,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18, -0x00,0x84,0x80,0x0b,0x00,0x00,0x30,0x21,0x12,0x00,0x00,0x0a,0x00,0xa0,0x88,0x21, -0x0c,0x00,0x31,0x27,0x02,0x00,0x20,0x21,0x02,0x02,0x80,0x21,0x82,0x02,0x00,0x00, -0x02,0x20,0x28,0x21,0x02,0x00,0x20,0x21,0x14,0x40,0x00,0x07,0x00,0x00,0x30,0x21, -0xaf,0x80,0xc5,0x5c,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x31,0x43,0x00,0x00,0x00,0x00, -0x00,0x40,0x18,0x21,0x10,0x40,0x00,0x07,0x02,0x00,0x30,0x21,0x80,0x42,0x00,0x00, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0xa0,0x60,0x00,0x00, -0x24,0x63,0x00,0x01,0xaf,0x83,0xc5,0x5c,0x08,0x00,0x31,0x71,0x00,0x00,0x00,0x00, -0x24,0xc6,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xc2,0x00,0x05,0x00,0x80,0x18,0x21, -0x24,0xc6,0xff,0xff,0xa0,0x65,0x00,0x00,0x14,0xc2,0xff,0xfd,0x24,0x63,0x00,0x01, -0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0xc6,0xff,0xff,0x24,0x02,0xff,0xff, -0x10,0xc2,0x00,0x08,0x00,0x80,0x18,0x21,0x24,0x07,0xff,0xff,0x90,0xa2,0x00,0x00, -0x24,0xc6,0xff,0xff,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x00,0x14,0xc7,0xff,0xfb, -0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x00,0x80,0x18,0x21, -0x90,0xa2,0x00,0x00,0x24,0xa5,0x00,0x01,0xa0,0x82,0x00,0x00,0x14,0x40,0xff,0xfc, -0x24,0x84,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x90,0x83,0x00,0x00, -0x90,0xa2,0x00,0x00,0x24,0x84,0x00,0x01,0x00,0x62,0x10,0x23,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0x14,0x40,0x00,0x03,0x24,0xa5,0x00,0x01,0x14,0x60,0xff,0xf7, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x10,0x21,0x93,0x85,0x88,0x6d,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x53, -0x00,0x80,0x40,0x21,0x8c,0x89,0x00,0x04,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21, -0x8c,0xc3,0x00,0x04,0x3c,0x02,0x01,0x00,0x00,0x62,0x10,0x24,0x10,0x40,0x00,0x4b, -0x30,0x62,0x00,0x08,0x10,0x45,0x00,0x59,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38, -0x24,0x03,0x00,0xb4,0x30,0x44,0x00,0xff,0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4, -0x10,0x82,0x00,0x54,0x24,0x02,0x00,0x94,0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00, -0x94,0xc2,0x00,0x38,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff, -0x24,0x02,0x40,0x88,0x14,0x62,0x00,0x39,0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00, -0x10,0x62,0x00,0x38,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00, -0x30,0x47,0xff,0xff,0x30,0xe2,0x00,0x80,0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01, -0x01,0x22,0x30,0x21,0x94,0xc3,0x00,0x60,0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b, -0x00,0x00,0x00,0x00,0x90,0xc2,0x00,0x62,0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02, -0x10,0xe3,0x00,0x15,0x24,0x02,0x00,0x06,0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00, -0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x66,0x27,0x82,0x92,0x48,0x00,0x05,0x28,0x80, -0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00, -0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00, -0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00, -0x08,0x00,0x32,0x17,0xad,0x07,0x00,0x10,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64, -0x27,0x82,0x92,0x48,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21, -0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25, -0x24,0x42,0x00,0x36,0x3c,0x03,0xff,0xff,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24, -0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x50,0x08,0x00,0x31,0xd5,0x30,0x47,0xff,0xff, -0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, -0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e, -0xac,0x82,0x00,0x00,0x24,0x03,0x00,0x2e,0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80, -0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24, -0x34,0x42,0x00,0x0e,0x24,0x03,0x00,0x0e,0x08,0x00,0x32,0x16,0xac,0x82,0x00,0x00, -0x8d,0x04,0x01,0xac,0x27,0x83,0x92,0x48,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, -0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14, -0x24,0x03,0x00,0x14,0x08,0x00,0x32,0x16,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xc6,0x00,0xff,0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x8b,0xc5,0x70,0x27,0x83,0xc5,0x76,0x00,0x4b,0x40,0x21, -0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x00,0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29, -0x30,0x8a,0xff,0xff,0x95,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82, -0x30,0x42,0x00,0x01,0x10,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x4b,0x30,0x21,0x94,0xc4,0x00,0x02,0x27,0x83,0xc5,0x76, -0x27,0x85,0xc5,0x74,0x00,0x45,0x28,0x21,0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21, -0xa4,0xc4,0x00,0x02,0xa4,0x40,0x00,0x00,0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02, -0x3c,0x04,0xb0,0x01,0x01,0x44,0x20,0x21,0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02, -0xa0,0xc0,0x00,0x00,0x8c,0x82,0x00,0x04,0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24, -0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x04,0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01, -0x00,0xa2,0x10,0x24,0x00,0x47,0x28,0x25,0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02, -0x14,0x82,0xff,0xe2,0x01,0x43,0x18,0x21,0xac,0x65,0x00,0x00,0x08,0x00,0x32,0x44, -0x01,0x26,0x10,0x21,0x08,0x00,0x32,0x44,0x01,0x26,0x10,0x21,0x93,0x83,0x88,0x6d, -0x24,0x02,0x00,0x01,0x14,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04, -0x3c,0x06,0xb0,0x09,0x00,0x82,0x20,0x21,0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04, -0x3c,0x02,0x01,0x00,0x34,0xc6,0x01,0x00,0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05, -0x30,0xa5,0x20,0x00,0x24,0x02,0x00,0x06,0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x09,0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00, -0x24,0x02,0x00,0x0e,0x08,0x00,0x32,0x77,0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01, -0x30,0xa5,0xff,0xff,0x00,0xa2,0x28,0x21,0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00, -0x00,0x80,0x30,0x21,0x00,0x62,0x18,0x24,0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x42,0x80,0x00,0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00, -0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, -0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x93,0x83,0x88,0x6c,0x00,0x02,0x11,0x83, -0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8, -0xa3,0x83,0x88,0x6c,0x8c,0xc4,0x01,0xac,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00, -0x00,0x44,0x10,0x26,0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x88,0x6d, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x88,0x6d, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01, -0x00,0x80,0x50,0x21,0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05, -0x00,0x03,0x1a,0x02,0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07, -0x11,0x22,0x00,0x09,0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b, -0x11,0x22,0x00,0x05,0x24,0x02,0x00,0x01,0x93,0x83,0x88,0x6c,0x3c,0x04,0xb0,0x06, -0x10,0x62,0x00,0x03,0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa, -0x00,0x00,0x00,0x00,0x8d,0x43,0x01,0xa8,0x27,0x82,0x92,0x48,0x00,0x03,0x18,0x80, -0x00,0x6a,0x20,0x21,0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00, -0x00,0xe5,0x28,0x21,0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x93,0x48, -0x01,0x22,0x10,0x24,0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8, -0x00,0x07,0x30,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, -0x00,0x06,0x32,0x00,0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00, -0x3c,0x03,0x80,0x00,0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04, -0xaf,0x87,0xc5,0x60,0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xc5,0x68, -0x8c,0xa3,0x00,0x04,0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8, -0xaf,0x83,0xc5,0x64,0x93,0x85,0x88,0x6c,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, -0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, -0x24,0xa5,0xff,0xff,0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x88,0x6c, -0x08,0x00,0x32,0xc2,0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0xa5,0x00,0x20,0x24,0x42,0xcb,0xe8,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02, -0x24,0x03,0x00,0x20,0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60, -0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c, -0xac,0x80,0x00,0x50,0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58, -0xa0,0x80,0x00,0x5c,0x24,0x42,0xcc,0xac,0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f, -0x24,0xa5,0xff,0xff,0xac,0x62,0x00,0x00,0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04, -0x3c,0x02,0x80,0x01,0x24,0x42,0xcd,0xdc,0xac,0x82,0x00,0x78,0x3c,0x03,0x80,0x01, -0x3c,0x02,0x80,0x01,0x24,0x63,0xcf,0x68,0x24,0x42,0xce,0xd4,0xac,0x83,0x00,0x88, -0xac,0x82,0x00,0x98,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x24,0x63,0xd0,0x10, -0x24,0x42,0xd1,0x28,0xac,0x83,0x00,0xa0,0xac,0x82,0x00,0xa4,0xa0,0x80,0x01,0xba, -0xac,0x80,0x01,0xa8,0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,0xac,0x80,0x01,0xb4, -0xa0,0x80,0x01,0xb8,0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0xcc,0xac,0x03,0xe0,0x00,0x08, -0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8, -0x34,0x63,0x00,0x20,0x24,0x42,0xcc,0xc4,0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00, -0xaf,0xbf,0x00,0x14,0x8c,0x83,0x00,0x10,0x8f,0x82,0x94,0xe8,0x00,0x80,0x80,0x21, -0x3c,0x04,0x80,0x01,0x30,0x46,0x00,0x01,0x10,0x60,0x00,0x11,0x24,0x84,0x08,0x64, -0x8e,0x02,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00, -0x8e,0x05,0x00,0x10,0x8e,0x03,0x00,0x14,0x8e,0x02,0x00,0x04,0x00,0xa3,0x28,0x21, -0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02, -0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04, -0x14,0xc0,0x00,0x0a,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c, -0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x8e,0x05,0x00,0x10, -0x8e,0x07,0x00,0x04,0x8e,0x06,0x00,0x14,0x0c,0x00,0x1a,0x82,0x00,0x00,0x00,0x00, -0x08,0x00,0x33,0x53,0xae,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x63,0x00,0x20,0x24,0x42,0xcd,0x88,0xac,0x62,0x00,0x00,0x8c,0x86,0x00,0x04, -0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21,0x8c,0x45,0x00,0x00, -0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff,0x30,0x42,0x00,0xff, -0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14,0xac,0x85,0x00,0x40, -0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xcd,0xdc, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21,0xae,0x00,0x00,0x00, -0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c, -0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x0c,0x00,0x33,0x62,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0x84,0xae,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, -0x24,0x63,0xce,0x40,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, -0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21, -0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44,0x00,0x62,0x18,0x21, -0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50,0x30,0xa3,0x00,0xff, -0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f,0x30,0x42,0x00,0x03, -0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c,0xae,0x03,0x00,0x30, -0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0x62,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0x9c, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, -0x34,0x42,0x00,0x20,0x24,0x63,0xce,0xd4,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, -0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16, -0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40,0x83,0x85,0x95,0x14, -0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02,0xae,0x04,0x00,0x14, -0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04,0xae,0x03,0x00,0x3c, -0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01,0x24,0x02,0x00,0x01, -0xa3,0x86,0x95,0x14,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0x90,0x00,0x00,0x00,0x00, -0x08,0x00,0x33,0xc1,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, -0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xcf,0x68,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03,0x8c,0x42,0x00,0x00, -0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x95,0x14,0x92,0x05,0x00,0x41, -0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2,0x00,0x03,0x1e,0x02, -0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21,0xae,0x03,0x00,0x18, -0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03,0x24,0x02,0x00,0x01, -0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x95,0x14,0x8f,0xbf,0x00,0x14, -0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x0c,0x00,0x33,0x90,0x00,0x00,0x00,0x00,0x08,0x00,0x33,0xe6,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, -0x24,0x63,0xd0,0x10,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, -0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21, -0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01, -0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04, -0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21, -0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0x92,0x48,0x00,0x62,0x18,0x21, -0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21, -0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80,0x27,0x82,0x93,0x48,0x00,0x62,0x18,0x21, -0x0c,0x00,0x31,0xb1,0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04, -0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40, -0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80, -0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8, -0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x88,0x6c,0x02,0x00,0x20,0x21, -0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x88,0x6c, -0x0c,0x00,0x33,0x31,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x33,0xda,0x00,0x00,0x00,0x00, -0x08,0x00,0x34,0x10,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, -0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xd1,0x28,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44, -0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21, -0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac, -0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80, -0x27,0x82,0x92,0x48,0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04, -0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80, -0x27,0x82,0x93,0x48,0x00,0x62,0x18,0x21,0x0c,0x00,0x31,0xb1,0xac,0x66,0x00,0x00, -0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01, -0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83, -0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21, -0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00, -0x93,0x82,0x88,0x6c,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01, -0xac,0xc3,0x00,0x00,0xa3,0x82,0x88,0x6c,0x0c,0x00,0x33,0x31,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x0c,0x00,0x33,0xda,0x00,0x00,0x00,0x00,0x08,0x00,0x34,0x56,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xd2,0x40, -0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x80,0x21, -0x24,0x52,0xcc,0xac,0x00,0x00,0x88,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x00,0x06, -0x8e,0x06,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x06,0x22,0x02,0x00,0x44,0x10,0x23, -0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a, -0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff,0x10,0x44,0x00,0x68, -0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x01,0x00,0xc2,0x10,0x21,0x8c,0x44,0x00,0x04, -0x3c,0x03,0x7c,0x00,0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24,0xae,0x04,0x00,0x44, -0x8c,0x44,0x00,0x00,0x10,0x60,0x00,0x69,0x00,0x00,0x38,0x21,0x3c,0x09,0xb0,0x03, -0x3c,0x06,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01,0x24,0x08,0x00,0x40, -0x34,0xc6,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38,0x16,0x20,0x00,0x06, -0x24,0xa5,0x00,0x01,0x93,0x82,0x88,0xa0,0x24,0x11,0x00,0x01,0x24,0x42,0x00,0x01, -0xa1,0x22,0x00,0x00,0xa3,0x82,0x88,0xa0,0x8e,0x02,0x00,0x04,0x24,0x07,0x00,0x01, -0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04,0x00,0x4a,0x10,0x21, -0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44,0x8c,0x44,0x00,0x00, -0x10,0xa8,0x00,0x2d,0x00,0x66,0x18,0x24,0x14,0x60,0xff,0xec,0x00,0x8b,0x10,0x24, -0x14,0x4c,0xff,0xea,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x2f,0x3c,0x03,0xb0,0x09, -0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42,0x00,0x02,0x12,0x02, -0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00,0x10,0x44,0x00,0x1a, -0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58,0x00,0x00,0x00,0x00, -0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50, -0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68,0x00,0x00,0x00,0x00, -0x10,0x52,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09,0x02,0x00,0x20,0x21, -0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x60, -0x08,0x00,0x34,0x9e,0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64,0x00,0x00,0x00,0x00, -0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c,0x8f,0xbf,0x00,0x1c, -0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26,0x00,0x02,0x10,0x2b, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x34,0x63,0x00,0x06,0x8e,0x04,0x00,0x04, -0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40, -0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83, -0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x14,0x87,0xff,0xc5,0x00,0x00,0x00,0x00, -0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03,0x14,0x40,0x00,0x05, -0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01,0x08,0x00,0x34,0xfe, -0xa2,0x02,0x00,0x5c,0x08,0x00,0x34,0xfe,0xa2,0x00,0x00,0x5c,0x3c,0x02,0xff,0xff, -0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,0x14,0x43,0xff,0x94,0x24,0x02,0x00,0x01, -0x08,0x00,0x34,0xd6,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, -0x34,0x42,0x00,0x20,0x24,0x63,0xd4,0x98,0xac,0x43,0x00,0x00,0x8c,0x83,0x01,0xa8, -0x8c,0x82,0x01,0xac,0x00,0x80,0x40,0x21,0x10,0x62,0x00,0x20,0x00,0x00,0x20,0x21, -0x93,0x82,0x88,0x6d,0x00,0x03,0x28,0x80,0x3c,0x07,0xb0,0x06,0x00,0xa8,0x18,0x21, -0x24,0x04,0x00,0x01,0x8c,0x66,0x00,0xa8,0x10,0x44,0x00,0x1c,0x34,0xe7,0x80,0x18, -0x3c,0x05,0xb0,0x01,0xaf,0x86,0xc5,0x60,0x00,0xc5,0x28,0x21,0x8c,0xa3,0x00,0x00, -0x00,0x06,0x20,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00,0x00,0x82,0x20,0x25, -0xaf,0x83,0xc5,0x68,0x8c,0xa2,0x00,0x04,0xac,0xe4,0x00,0x00,0x8d,0x03,0x01,0xa8, -0xaf,0x82,0xc5,0x64,0x24,0x64,0x00,0x01,0x04,0x80,0x00,0x0a,0x00,0x80,0x10,0x21, -0x00,0x02,0x11,0x83,0x8d,0x03,0x01,0xac,0x00,0x02,0x11,0x80,0x00,0x82,0x10,0x23, -0x00,0x43,0x18,0x26,0xad,0x02,0x01,0xa8,0x00,0x03,0x20,0x2b,0x03,0xe0,0x00,0x08, -0x00,0x80,0x10,0x21,0x08,0x00,0x35,0x48,0x24,0x62,0x00,0x40,0x27,0x82,0x92,0x48, -0x00,0x06,0x20,0xc2,0x00,0x04,0x22,0x00,0x00,0xa2,0x48,0x21,0x3c,0x02,0x00,0x80, -0x00,0x82,0x58,0x25,0x93,0x82,0x88,0x6c,0x3c,0x0a,0xb0,0x06,0x3c,0x03,0xb0,0x01, -0x2c,0x42,0x00,0x02,0x00,0xc3,0x38,0x21,0x35,0x4a,0x80,0x18,0x14,0x40,0xff,0xef, -0x00,0x00,0x20,0x21,0x8c,0xe5,0x00,0x00,0x8d,0x23,0x00,0x00,0x24,0x02,0xc0,0x00, -0x00,0xa2,0x10,0x24,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00,0x8d,0x04,0x01,0xa8, -0x27,0x83,0x93,0x48,0x8c,0xe5,0x00,0x04,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, -0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0xa2,0x10,0x25,0x00,0x43,0x10,0x25, -0xac,0xe2,0x00,0x04,0xaf,0x86,0xc5,0x60,0x8c,0xe2,0x00,0x00,0x93,0x85,0x88,0x6c, -0xaf,0x82,0xc5,0x68,0x8c,0xe3,0x00,0x04,0xad,0x4b,0x00,0x00,0x8d,0x02,0x01,0xa8, -0xaf,0x83,0xc5,0x64,0x24,0xa5,0xff,0xff,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00, -0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, -0x00,0x82,0x20,0x23,0xad,0x04,0x01,0xa8,0xa3,0x85,0x88,0x6c,0x79,0x02,0x0d,0x7c, -0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x26,0x08,0x00,0x35,0x4f,0x00,0x02,0x20,0x2b, -0x90,0x87,0x00,0x00,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x24,0x48,0x02,0x1c, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x01,0x07,0x18,0x21,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x10,0x40,0x00,0x0a,0x00,0x00,0x80,0x21, -0x24,0x84,0x00,0x01,0x90,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x18,0x21, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x14,0x40,0xff,0xf8, -0x00,0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2d, -0x10,0x43,0x00,0x0f,0x00,0x00,0x00,0x00,0x0c,0x00,0x35,0xb3,0x00,0x00,0x00,0x00, -0x00,0x40,0x18,0x21,0x00,0x02,0x10,0x23,0x04,0x61,0x00,0x05,0x00,0x70,0x10,0x0a, -0x16,0x00,0x00,0x03,0x3c,0x02,0x80,0x00,0x3c,0x02,0x7f,0xff,0x34,0x42,0xff,0xff, -0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x24,0x10,0xff,0xff,0x08,0x00,0x35,0xa2,0x24,0x84,0x00,0x01,0x00,0x80,0x38,0x21, -0x90,0x84,0x00,0x00,0x3c,0x02,0x80,0x01,0x24,0x48,0x02,0x1c,0x01,0x04,0x18,0x21, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x10,0x40,0x00,0x0a, -0x00,0x00,0x50,0x21,0x24,0xe7,0x00,0x01,0x90,0xe4,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x04,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20, -0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03, -0x38,0x42,0x00,0x2b,0x24,0xe3,0x00,0x01,0x24,0x04,0x00,0x10,0x10,0xc4,0x00,0x38, -0x00,0x62,0x38,0x0a,0x90,0xe4,0x00,0x00,0x14,0xc0,0x00,0x07,0x00,0x80,0x18,0x21, -0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x30,0x10,0x43,0x00,0x25, -0x24,0x06,0x00,0x0a,0x00,0x80,0x18,0x21,0x00,0x03,0x16,0x00,0x10,0x40,0x00,0x1a, -0x30,0x64,0x00,0xff,0x24,0x82,0xff,0xa9,0x2c,0x83,0x00,0x61,0x30,0x48,0x00,0xff, -0x10,0x60,0x00,0x09,0x2c,0x89,0x00,0x41,0x24,0x82,0xff,0xc9,0x30,0x48,0x00,0xff, -0x11,0x20,0x00,0x05,0x2c,0x83,0x00,0x3a,0x24,0x82,0xff,0xd0,0x14,0x60,0x00,0x02, -0x30,0x48,0x00,0xff,0x24,0x08,0x00,0xff,0x01,0x06,0x10,0x2a,0x10,0x40,0x00,0x0a, -0x01,0x46,0x00,0x18,0x24,0xe7,0x00,0x01,0x00,0x00,0x18,0x12,0x00,0x6a,0x10,0x2b, -0x14,0x40,0x00,0x0a,0x00,0x68,0x50,0x21,0x80,0xe2,0x00,0x00,0x90,0xe3,0x00,0x00, -0x14,0x40,0xff,0xe8,0x30,0x64,0x00,0xff,0x10,0xa0,0x00,0x02,0x00,0x00,0x00,0x00, -0xac,0xa7,0x00,0x00,0x03,0xe0,0x00,0x08,0x01,0x40,0x10,0x21,0x03,0xe0,0x00,0x08, -0x24,0x02,0xff,0xff,0x24,0x06,0x00,0x08,0x80,0xe3,0x00,0x01,0x24,0x02,0x00,0x78, -0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x58,0x14,0x62,0xff,0xd7,0x00,0x80,0x18,0x21, -0x24,0xe7,0x00,0x02,0x90,0xe4,0x00,0x00,0x08,0x00,0x35,0xd5,0x24,0x06,0x00,0x10, -0x80,0xe3,0x00,0x00,0x24,0x02,0x00,0x30,0x90,0xe4,0x00,0x00,0x10,0x62,0xff,0xf2, -0x00,0x00,0x00,0x00,0x08,0x00,0x35,0xce,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x03, -0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01,0x34,0xc6,0x00,0x18,0x34,0x84,0x00,0x20, -0x24,0x42,0xd8,0x2c,0x24,0x03,0xff,0x83,0xac,0x82,0x00,0x00,0xa0,0xc3,0x00,0x00, -0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8,0x3c,0x03,0xb0,0x07,0x24,0x02,0xff,0x82, -0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00,0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07, -0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01,0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00, -0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07,0xa3,0xa3,0x00,0x00,0xa0,0xc2,0x00,0x00, -0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10,0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x07, -0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38,0xa0,0xa2,0x00,0x00,0x90,0x64,0x00,0x00, -0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20,0xa3,0xa4,0x00,0x00,0xa0,0xa0,0x00,0x00, -0x90,0xa3,0x00,0x00,0xaf,0x82,0xc8,0x70,0xa3,0xa3,0x00,0x00,0xa0,0x40,0x00,0x00, -0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,}; - -u8 Rtl8190PciFwDataArray[DataArrayLengthPci] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x0a,0x0d,0x5b,0x43,0x4d,0x50,0x4b,0x5d,0x00,0x00,0x00,0x00, -0x80,0x01,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08, -0x08,0x08,0x08,0x08,0x08,0x28,0x28,0x28,0x28,0x28,0x08,0x08,0x08,0x08,0x08,0x08, -0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xa0,0x10,0x10,0x10, -0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x04,0x04,0x04,0x04, -0x04,0x04,0x04,0x04,0x04,0x04,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x41,0x41,0x41, -0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, -0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,0x10,0x10,0x42,0x42,0x42, -0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, -0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,0x08,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x10,0x10,0x10, -0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, -0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x01,0x01,0x01,0x01, -0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, -0x01,0x01,0x01,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02, -0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, -0x02,0x02,0x02,0x10,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x20,0x09,0x0d,0x0a, -0x00,0x00,0x00,0x00,0x80,0x01,0x03,0x1c,0x00,0x00,0x00,0x00,0x43,0x6e,0x73,0x64, -0x31,0x00,0x00,0x00,0x68,0x65,0x6c,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x72,0x34,0x00,0x00,0x77,0x34,0x00,0x00,0x64,0x62,0x67,0x00,0x72,0x61,0x63,0x74, -0x72,0x6c,0x00,0x00,0x73,0x79,0x73,0x64,0x00,0x00,0x00,0x00,0x73,0x79,0x73,0x63, -0x74,0x72,0x6c,0x00,0x74,0x78,0x74,0x62,0x6c,0x00,0x00,0x00,0x70,0x72,0x61,0x6e, -0x67,0x65,0x00,0x00,0x64,0x6d,0x00,0x00,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x00,0x00, -0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0x00,0x80,0x00,0x24,0x5c,0x80,0x01,0x03,0x40,0x80,0x01,0x03,0x3c, -0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x25,0xbc, -0x80,0x01,0x03,0x44,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0x00,0x80,0x00,0x27,0x38,0x80,0x01,0x03,0x48,0x80,0x01,0x03,0x3c, -0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0x04, -0x80,0x01,0x03,0x4c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xdc,0x80,0x01,0x03,0x54,0x80,0x01,0x03,0x3c, -0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xe4, -0x80,0x01,0x03,0x5c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xec,0x80,0x01,0x03,0x64,0x80,0x01,0x03,0x3c, -0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x29,0xf4, -0x80,0x01,0x03,0x6c,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0x00,0x80,0x00,0x2b,0x80,0x80,0x01,0x03,0x74,0x80,0x01,0x03,0x3c, -0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x2b,0xf4, -0x80,0x01,0x03,0x78,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x3c,0x00,0x00,0x00,0x0f, -0x00,0x00,0x00,0x01,0x80,0x00,0x2c,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x0a,0x0d,0x52,0x54,0x4c,0x38,0x31,0x39,0x58,0x2d,0x25,0x64,0x3e,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x52,0x54,0x4c,0x38,0x31,0x39,0x58,0x2d,0x25,0x64,0x3e,0x0a, -0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72, -0x72,0x20,0x44,0x49,0x52,0x00,0x00,0x00,0x0a,0x0d,0x44,0x42,0x47,0x20,0x43,0x4d, -0x44,0x73,0x3a,0x00,0x0a,0x0d,0x5b,0x00,0x5d,0x2d,0x00,0x00,0x0a,0x0d,0x3c,0x31, -0x2e,0x43,0x4d,0x4e,0x3e,0x20,0x3c,0x32,0x2e,0x3f,0x3e,0x00,0x0a,0x0d,0x20,0x79, -0x65,0x61,0x72,0x2d,0x64,0x61,0x79,0x2d,0x68,0x6f,0x75,0x72,0x2d,0x6d,0x69,0x6e, -0x2d,0x73,0x65,0x63,0x2d,0x31,0x30,0x6d,0x73,0x3d,0x00,0x00,0x25,0x64,0x2d,0x00, -0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x20,0x20,0x20,0x20,0x20,0x20, -0x20,0x30,0x34,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x38,0x20,0x20,0x20,0x20, -0x20,0x20,0x20,0x30,0x43,0x00,0x00,0x00,0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20, -0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d, -0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d, -0x3d,0x3d,0x3d,0x00,0x0d,0x0a,0x20,0x30,0x78,0x25,0x30,0x38,0x58,0x20,0x20,0x00, -0x09,0x00,0x00,0x00,0x25,0x30,0x38,0x58,0x20,0x00,0x00,0x00,0x0a,0x0d,0x44,0x62, -0x67,0x5f,0x46,0x6c,0x61,0x67,0x25,0x64,0x3d,0x30,0x78,0x25,0x30,0x38,0x78,0x00, -0x0a,0x0d,0x54,0x58,0x4c,0x4c,0x54,0x09,0x09,0x4e,0x45,0x58,0x54,0x20,0x20,0x20, -0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4e,0x45,0x58,0x54,0x0a,0x0d,0x00, -0x0a,0x0d,0x20,0x50,0x61,0x67,0x65,0x25,0x33,0x64,0x09,0x00,0x25,0x34,0x64,0x20, -0x20,0x20,0x20,0x00,0x25,0x34,0x64,0x20,0x20,0x20,0x20,0x09,0x00,0x00,0x00,0x00, -0x0a,0x0d,0x54,0x58,0x4f,0x51,0x54,0x09,0x09,0x48,0x65,0x61,0x64,0x20,0x20,0x20, -0x20,0x54,0x61,0x69,0x6c,0x20,0x20,0x20,0x20,0x48,0x65,0x61,0x64,0x20,0x20,0x20, -0x20,0x54,0x61,0x69,0x6c,0x0a,0x0d,0x00,0x0a,0x0d,0x55,0x6e,0x6b,0x6e,0x6f,0x77, -0x20,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72, -0x72,0x20,0x41,0x72,0x67,0x0a,0x0d,0x55,0x53,0x41,0x47,0x45,0x3a,0x00,0x00,0x00, -0x10,0x00,0x08,0x00,0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4, -0x00,0xab,0x00,0x72,0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c, -0x02,0x76,0x01,0x3b,0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f, -0x01,0x3b,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20, -0x01,0x2f,0x00,0x98,0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e, -0x00,0x98,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f, -0x02,0x39,0x01,0x1c,0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39, -0x01,0x1c,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c, -0x01,0x11,0x00,0x89,0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b, -0x00,0x89,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e, -0x02,0xab,0x02,0xab,0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08, -0x04,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x54,0x4c,0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c, -0x5f,0x64,0x61,0x74,0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00, -0x41,0x64,0x45,0x4c,0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00, -0x00,0x00,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78, -0x63,0x43,0x6f,0x64,0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x42,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x4f,0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x80,0x01,0x14,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10, -0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48, -0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20, -0x00,0x00,0x01,0x80,0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68, -0x00,0x00,0x00,0x9c,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0, -0x00,0x00,0x01,0xd4,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0, -0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40, -0x00,0x00,0x03,0xa8,0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02, -0x03,0x03,0x04,0x04,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04, -0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x3c,0x4e,0x55,0x4c,0x4c,0x3e,0x00,0x00,0x30,0x31,0x32,0x33, -0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a, -0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a, -0x00,0x00,0x00,0x00,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42, -0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52, -0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x5b,0x52,0x58,0x5d,0x20,0x70,0x6b,0x74,0x5f,0x6c,0x65,0x6e, -0x3d,0x25,0x64,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,0x25,0x64,0x20,0x73,0x74, -0x61,0x72,0x74,0x5f,0x61,0x64,0x64,0x72,0x3d,0x25,0x30,0x38,0x78,0x0a,0x0d,0x00, -0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x6c,0x80,0x00,0x07,0x80,0x80,0x00,0x07,0x80, -0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x94,0x80,0x00,0x76,0x50, -0x80,0x00,0x76,0xa4,0x80,0x00,0x76,0xc0,0x80,0x00,0x77,0xac,0x80,0x00,0x78,0x64, -0x80,0x00,0x79,0x10,0x80,0x00,0x79,0x7c,0x80,0x00,0x7a,0x88,0x80,0x00,0x7a,0xbc, -0x80,0x00,0x7a,0xd0,0x80,0x00,0x7a,0xe4,0x80,0x00,0x7b,0x90,0x80,0x00,0x7b,0xcc, -0x80,0x00,0x7c,0x7c,0x80,0x00,0x7c,0xa4,0x80,0x00,0x76,0x0c,0x80,0x00,0x7c,0xe8, -0x80,0x00,0x83,0x74,0x80,0x00,0x83,0xec,0x80,0x00,0x83,0xf8,0x80,0x00,0x84,0x04, -0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, -0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, -0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c,0x80,0x00,0x83,0x8c, -0x80,0x00,0x84,0x10,0x80,0x00,0x84,0x1c,0x80,0x00,0x84,0x28,0x80,0x00,0xa6,0xb4, -0x80,0x00,0xa6,0xb4,0x80,0x00,0xa6,0xb4,0x80,0x00,0xa6,0xe8,0x80,0x00,0xa7,0x28, -0x80,0x00,0xa7,0x60,0x80,0x00,0xa7,0x90,0x80,0x00,0xa7,0xc0,0x80,0x00,0xa7,0xd4, -0x80,0x00,0xa8,0x3c,0x80,0x00,0xa8,0x50,0x80,0x00,0xa8,0x8c,0x80,0x00,0xa8,0x94, -0x80,0x00,0xa8,0xd0,0x80,0x00,0xa8,0xe4,0x80,0x00,0xa8,0xec,0x80,0x00,0xa8,0xf4, -0x80,0x00,0xa8,0xf4,0x80,0x00,0xa8,0xf4,0x80,0x00,0xa8,0xf4,0x80,0x00,0xa9,0x24, -0x80,0x00,0xa9,0x38,0x80,0x00,0xa9,0x4c,0x80,0x00,0xa5,0xf8,0x80,0x00,0xac,0x78, -0x80,0x00,0xac,0x78,0x80,0x00,0xac,0x78,0x80,0x00,0xac,0xac,0x80,0x00,0xac,0xec, -0x80,0x00,0xad,0x24,0x80,0x00,0xad,0x54,0x80,0x00,0xad,0x84,0x80,0x00,0xad,0x98, -0x80,0x00,0xae,0x00,0x80,0x00,0xae,0x14,0x80,0x00,0xae,0x50,0x80,0x00,0xae,0x58, -0x80,0x00,0xae,0x94,0x80,0x00,0xae,0xa8,0x80,0x00,0xae,0xb0,0x80,0x00,0xae,0xb8, -0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xb8,0x80,0x00,0xae,0xe8, -0x80,0x00,0xae,0xfc,0x80,0x00,0xaf,0x10,0x80,0x00,0xaa,0x98,0x80,0x00,0xbc,0x64, -0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x6c,0x80,0x00,0xbc,0x7c, -0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c, -0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x74,0x80,0x00,0xbc,0x7c, -0x80,0x00,0xbc,0x5c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xbc,0x7c,0x80,0x00,0xc0,0xa4, -0x80,0x00,0xbd,0x94,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0xa0, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0x28,0x80,0x00,0xbe,0x74, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbe,0x74,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbe,0x7c,0x80,0x00,0xbe,0x9c,0x80,0x00,0xbe,0xa4, -0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbe,0xfc,0x80,0x00,0xbf,0xac, -0x80,0x00,0xbd,0xa8,0x80,0x00,0xbf,0xac,0x80,0x00,0xbf,0xac,0x80,0x00,0xbd,0xa4, -}; - - -u32 Rtl8190PciPHY_REGArray[PHY_REGArrayLengthPci] = { -0x800,0x00050060, -0x804,0x00000005, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x000908c0, -0x818,0x00000000, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x5c385eb8, -0x884,0x6357060d, -0x888,0x0460c341, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x35541545, -0xa00,0x00d0c7d8, -0xa04,0xab1f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x0000500f, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08000000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x164052cd, -0xc38,0x00070a14, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x00000000, -0xc88,0x40000100, -0xc8c,0x08000000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000740, -0xd04,0x0000040f, -0xd08,0x0000803f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x14032064, -}; - -u32 Rtl8190PciPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPci] = { -0x800,0x00050060, -0x804,0x00000004, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x000908c0, -0x818,0x00000000, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0000, -0x864,0x007f0000, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x5c385898, -0x884,0x6357060d, -0x888,0x0460c341, -0x88c,0x0000fc00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x34441444, -0xa00,0x00d0c7d8, -0xa04,0x2b1f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x0000500c, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08000000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x164052cd, -0xc38,0x00070a14, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x00000000, -0xc88,0x40000100, -0xc8c,0x08000000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000740, -0xd04,0x0000040c, -0xd08,0x0000803f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x14032064, -}; - -u32 Rtl8190PciRadioA_Array[RadioA_ArrayLengthPci] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000200, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; - -u32 Rtl8190PciRadioB_Array[RadioB_ArrayLengthPci] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000200, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; - -u32 Rtl8190PciRadioC_Array[RadioC_ArrayLengthPci] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000200, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; - -u32 Rtl8190PciRadioD_Array[RadioD_ArrayLengthPci] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000200, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; - -u32 Rtl8190PciMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, -}; - -u32 Rtl8190PciMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x0a0c0d0f, -0x344,0xffffffff,0x06070809, -0x344,0xffffffff,0x06070809, -0x348,0x0000ffff,0x00000000, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, -}; - -u32 Rtl8190PciAGCTAB_Array[AGCTAB_ArrayLengthPci] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7c040001, -0xc78,0x7b050001, -0xc78,0x7a060001, -0xc78,0x79070001, -0xc78,0x78080001, -0xc78,0x77090001, -0xc78,0x760a0001, -0xc78,0x750b0001, -0xc78,0x740c0001, -0xc78,0x730d0001, -0xc78,0x720e0001, -0xc78,0x710f0001, -0xc78,0x70100001, -0xc78,0x6f110001, -0xc78,0x6e120001, -0xc78,0x6d130001, -0xc78,0x6c140001, -0xc78,0x6b150001, -0xc78,0x6a160001, -0xc78,0x69170001, -0xc78,0x68180001, -0xc78,0x67190001, -0xc78,0x661a0001, -0xc78,0x651b0001, -0xc78,0x641c0001, -0xc78,0x491d0001, -0xc78,0x481e0001, -0xc78,0x471f0001, -0xc78,0x46200001, -0xc78,0x45210001, -0xc78,0x44220001, -0xc78,0x43230001, -0xc78,0x28240001, -0xc78,0x27250001, -0xc78,0x26260001, -0xc78,0x25270001, -0xc78,0x24280001, -0xc78,0x23290001, -0xc78,0x222a0001, -0xc78,0x212b0001, -0xc78,0x202c0001, -0xc78,0x0a2d0001, -0xc78,0x082e0001, -0xc78,0x062f0001, -0xc78,0x05300001, -0xc78,0x04310001, -0xc78,0x03320001, -0xc78,0x02330001, -0xc78,0x01340001, -0xc78,0x00350001, -0xc78,0x00360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7c440001, -0xc78,0x7b450001, -0xc78,0x7a460001, -0xc78,0x79470001, -0xc78,0x78480001, -0xc78,0x77490001, -0xc78,0x764a0001, -0xc78,0x754b0001, -0xc78,0x744c0001, -0xc78,0x734d0001, -0xc78,0x724e0001, -0xc78,0x714f0001, -0xc78,0x70500001, -0xc78,0x6f510001, -0xc78,0x6e520001, -0xc78,0x6d530001, -0xc78,0x6c540001, -0xc78,0x6b550001, -0xc78,0x6a560001, -0xc78,0x69570001, -0xc78,0x68580001, -0xc78,0x67590001, -0xc78,0x665a0001, -0xc78,0x655b0001, -0xc78,0x645c0001, -0xc78,0x495d0001, -0xc78,0x485e0001, -0xc78,0x475f0001, -0xc78,0x46600001, -0xc78,0x45610001, -0xc78,0x44620001, -0xc78,0x43630001, -0xc78,0x28640001, -0xc78,0x27650001, -0xc78,0x26660001, -0xc78,0x25670001, -0xc78,0x24680001, -0xc78,0x23690001, -0xc78,0x226a0001, -0xc78,0x216b0001, -0xc78,0x206c0001, -0xc78,0x0a6d0001, -0xc78,0x086e0001, -0xc78,0x066f0001, -0xc78,0x05700001, -0xc78,0x04710001, -0xc78,0x03720001, -0xc78,0x02730001, -0xc78,0x01740001, -0xc78,0x00750001, -0xc78,0x00760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x3600001e, -0xc78,0x3601001e, -0xc78,0x3602001e, -0xc78,0x3603001e, -0xc78,0x3604001e, -0xc78,0x3605001e, -0xc78,0x3a06001e, -0xc78,0x3c07001e, -0xc78,0x3e08001e, -0xc78,0x4209001e, -0xc78,0x430a001e, -0xc78,0x450b001e, -0xc78,0x470c001e, -0xc78,0x480d001e, -0xc78,0x490e001e, -0xc78,0x4b0f001e, -0xc78,0x4c10001e, -0xc78,0x4d11001e, -0xc78,0x4d12001e, -0xc78,0x4e13001e, -0xc78,0x4f14001e, -0xc78,0x5015001e, -0xc78,0x5116001e, -0xc78,0x5117001e, -0xc78,0x5218001e, -0xc78,0x5219001e, -0xc78,0x531a001e, -0xc78,0x541b001e, -0xc78,0x541c001e, -0xc78,0x551d001e, -0xc78,0x561e001e, -0xc78,0x561f001e, -0xc78,0x5720001e, -0xc78,0x5821001e, -0xc78,0x5822001e, -0xc78,0x5923001e, -0xc78,0x5924001e, -0xc78,0x5a25001e, -0xc78,0x5b26001e, -0xc78,0x5b27001e, -0xc78,0x5c28001e, -0xc78,0x5c29001e, -0xc78,0x5d2a001e, -0xc78,0x5d2b001e, -0xc78,0x5e2c001e, -0xc78,0x5e2d001e, -0xc78,0x5f2e001e, -0xc78,0x602f001e, -0xc78,0x6030001e, -0xc78,0x6131001e, -0xc78,0x6132001e, -0xc78,0x6233001e, -0xc78,0x6234001e, -0xc78,0x6335001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6538001e, -0xc78,0x6639001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x683c001e, -0xc78,0x693d001e, -0xc78,0x6a3e001e, -0xc78,0x6b3f001e, -}; - -#endif diff --git a/drivers/staging/rtl8192e/r8190P_hwimg.h b/drivers/staging/rtl8192e/r8190P_hwimg.h deleted file mode 100644 index 18aef43737d..00000000000 --- a/drivers/staging/rtl8192e/r8190P_hwimg.h +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae -******************************************************************************/ -#ifndef __INC_HAL8190Pci_FW_IMG_H -#define __INC_HAL8190Pci_FW_IMG_H - -/*Created on 2008/12/ 3, 3:26*/ - -#include - -#define BootArrayLengthPci 344 -extern u8 Rtl8190PciFwBootArray[BootArrayLengthPci]; -#define MainArrayLengthPci 55388 -extern u8 Rtl8190PciFwMainArray[MainArrayLengthPci]; -#define DataArrayLengthPci 2960 -extern u8 Rtl8190PciFwDataArray[DataArrayLengthPci]; -#define PHY_REGArrayLengthPci 280 -extern u32 Rtl8190PciPHY_REGArray[PHY_REGArrayLengthPci]; -#define PHY_REG_1T2RArrayLengthPci 280 -extern u32 Rtl8190PciPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPci]; -#define RadioA_ArrayLengthPci 246 -extern u32 Rtl8190PciRadioA_Array[RadioA_ArrayLengthPci] ; -#define RadioB_ArrayLengthPci 78 -extern u32 Rtl8190PciRadioB_Array[RadioB_ArrayLengthPci] ; -#define RadioC_ArrayLengthPci 246 -extern u32 Rtl8190PciRadioC_Array[RadioC_ArrayLengthPci] ; -#define RadioD_ArrayLengthPci 78 -extern u32 Rtl8190PciRadioD_Array[RadioD_ArrayLengthPci] ; -#define MACPHY_ArrayLengthPci 18 -extern u32 Rtl8190PciMACPHY_Array[MACPHY_ArrayLengthPci] ; -#define MACPHY_Array_PGLengthPci 21 -extern u32 Rtl8190PciMACPHY_Array_PG[MACPHY_Array_PGLengthPci] ; -#define AGCTAB_ArrayLengthPci 384 -extern u32 Rtl8190PciAGCTAB_Array[AGCTAB_ArrayLengthPci] ; - -#endif diff --git a/drivers/staging/rtl8192e/r8190_rtl8256.c b/drivers/staging/rtl8192e/r8190_rtl8256.c deleted file mode 100644 index 286462cc819..00000000000 --- a/drivers/staging/rtl8192e/r8190_rtl8256.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - This is part of the rtl8192 driver - released under the GPL (See file COPYING for details). - - This files contains programming code for the rtl8256 - radio frontend. - - *Many* thanks to Realtek Corp. for their great support! - -*/ - -#include "r8192E.h" -#include "r8192E_hw.h" -#include "r819xE_phyreg.h" -#include "r819xE_phy.h" -#include "r8190_rtl8256.h" - -/*-------------------------------------------------------------------------- - * Overview: set RF band width (20M or 40M) - * Input: struct net_device* dev - * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M - * Output: NONE - * Return: NONE - * Note: 8226 support both 20M and 40 MHz - *---------------------------------------------------------------------------*/ -void PHY_SetRF8256Bandwidth(struct r8192_priv *priv, HT_CHANNEL_WIDTH Bandwidth) //20M or 40M -{ - u8 eRFPath; - - //for(eRFPath = RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) - for(eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv, eRFPath)) - continue; - - switch(Bandwidth) - { - case HT_CHANNEL_WIDTH_20: - if(priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE)// 8256 D-cut, E-cut, xiong: consider it later! - { - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); //phy para:1ba - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7); - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021); - - //cosa add for sd3's request 01/23/2008 - //rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); - } - else - { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); - } - - break; - case HT_CHANNEL_WIDTH_20_40: - if(priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE)// 8256 D-cut, E-cut, xiong: consider it later! - { - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); //phy para:3ba - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3ff); - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0e1); - - } - else - { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); - } - - - break; - default: - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ); - break; - - } - } -} -/*-------------------------------------------------------------------------- - * Overview: Interface to config 8256 - * Input: struct net_device* dev - * Output: NONE - * Return: NONE - *---------------------------------------------------------------------------*/ -RT_STATUS PHY_RF8256_Config(struct r8192_priv *priv) -{ - // Initialize general global value - // - RT_STATUS rtStatus = RT_STATUS_SUCCESS; - // TODO: Extend RF_PATH_C and RF_PATH_D in the future - priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH; - // Config BB and RF - rtStatus = phy_RF8256_Config_ParaFile(priv); - - return rtStatus; -} - -/*-------------------------------------------------------------------------- - * Overview: Interface to config 8256 - * Input: struct net_device* dev - * Output: NONE - * Return: NONE - *---------------------------------------------------------------------------*/ -RT_STATUS phy_RF8256_Config_ParaFile(struct r8192_priv *priv) -{ - u32 u4RegValue = 0; - u8 eRFPath; - RT_STATUS rtStatus = RT_STATUS_SUCCESS; - BB_REGISTER_DEFINITION_T *pPhyReg; - u32 RegOffSetToBeCheck = 0x3; - u32 RegValueToBeCheck = 0x7f1; - u32 RF3_Final_Value = 0; - u8 ConstRetryTimes = 5, RetryTimes = 5; - u8 ret = 0; - - //3//----------------------------------------------------------------- - //3// <2> Initialize RF - //3//----------------------------------------------------------------- - for(eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv, eRFPath)) - continue; - - pPhyReg = &priv->PHYRegDef[eRFPath]; - - /*----Store original RFENV control type----*/ - switch(eRFPath) - { - case RF90_PATH_A: - case RF90_PATH_C: - u4RegValue = rtl8192_QueryBBReg(priv, pPhyReg->rfintfs, bRFSI_RFENV); - break; - case RF90_PATH_B : - case RF90_PATH_D: - u4RegValue = rtl8192_QueryBBReg(priv, pPhyReg->rfintfs, bRFSI_RFENV<<16); - break; - } - - /*----Set RF_ENV enable----*/ - rtl8192_setBBreg(priv, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); - - /*----Set RF_ENV output high----*/ - rtl8192_setBBreg(priv, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - - /* Set bit number of Address and Data for RF register */ - rtl8192_setBBreg(priv, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258 - rtl8192_setBBreg(priv, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ??? - - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); - - /*----Check RF block (for FPGA platform only)----*/ - // TODO: this function should be removed on ASIC , Emily 2007.2.2 - rtStatus = rtl8192_phy_checkBBAndRF(priv, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath); - if(rtStatus!= RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); - goto phy_RF8256_Config_ParaFile_Fail; - } - - RetryTimes = ConstRetryTimes; - RF3_Final_Value = 0; - /*----Initialize RF fom connfiguration file----*/ - switch(eRFPath) - { - case RF90_PATH_A: - while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0) - { - ret = rtl8192_phy_ConfigRFWithHeaderFile(priv,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); - RetryTimes--; - } - break; - case RF90_PATH_B: - while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0) - { - ret = rtl8192_phy_ConfigRFWithHeaderFile(priv,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); - RetryTimes--; - } - break; - case RF90_PATH_C: - while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0) - { - ret = rtl8192_phy_ConfigRFWithHeaderFile(priv,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); - RetryTimes--; - } - break; - case RF90_PATH_D: - while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0) - { - ret = rtl8192_phy_ConfigRFWithHeaderFile(priv,(RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); - RetryTimes--; - } - break; - } - - /*----Restore RFENV control type----*/; - switch(eRFPath) - { - case RF90_PATH_A: - case RF90_PATH_C: - rtl8192_setBBreg(priv, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); - break; - case RF90_PATH_B : - case RF90_PATH_D: - rtl8192_setBBreg(priv, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); - break; - } - - if(ret){ - RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); - goto phy_RF8256_Config_ParaFile_Fail; - } - - } - - RT_TRACE(COMP_PHY, "PHY Initialization Success\n") ; - return RT_STATUS_SUCCESS; - -phy_RF8256_Config_ParaFile_Fail: - RT_TRACE(COMP_ERR, "PHY Initialization failed\n") ; - return RT_STATUS_FAILURE; -} - - -void PHY_SetRF8256CCKTxPower(struct r8192_priv *priv, u8 powerlevel) -{ - u32 TxAGC=0; - - TxAGC = powerlevel; - if(priv->bDynamicTxLowPower == true)//cosa 04282008 for cck long range - { - if(priv->CustomerID == RT_CID_819x_Netcore) - TxAGC = 0x22; - else - TxAGC += priv->CckPwEnl; - } - if(TxAGC > 0x24) - TxAGC = 0x24; - rtl8192_setBBreg(priv, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC); -} - - -void PHY_SetRF8256OFDMTxPower(struct r8192_priv *priv, u8 powerlevel) -{ - - u32 writeVal, powerBase0, powerBase1, writeVal_tmp; - u8 index = 0; - u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c}; - u8 byte0, byte1, byte2, byte3; - - powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; //OFDM rates - powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0; - powerBase1 = powerlevel; //MCS rates - powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1; - - for(index=0; index<6; index++) - { - writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1); - byte0 = (u8)(writeVal & 0x7f); - byte1 = (u8)((writeVal & 0x7f00)>>8); - byte2 = (u8)((writeVal & 0x7f0000)>>16); - byte3 = (u8)((writeVal & 0x7f000000)>>24); - if(byte0 > 0x24) // Max power index = 0x24 - byte0 = 0x24; - if(byte1 > 0x24) - byte1 = 0x24; - if(byte2 > 0x24) - byte2 = 0x24; - if(byte3 > 0x24) - byte3 = 0x24; - - if(index == 3) - { - writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; - priv->Pwr_Track = writeVal_tmp; - } - - if(priv->bDynamicTxHighPower == true) //Add by Jacken 2008/03/06 //when DM implement, add this - { - writeVal = 0x03030303; - } - else - { - writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; - } - rtl8192_setBBreg(priv, RegOffset[index], 0x7f7f7f7f, writeVal); - } -} - -#define MAX_DOZE_WAITING_TIMES_9x 64 -static void r8192e_drain_tx_queues(struct r8192_priv *priv) -{ - u8 i, QueueID; - - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - struct rtl8192_tx_ring *ring = &priv->tx_ring[QueueID]; - - if(skb_queue_len(&ring->queue) == 0) - { - QueueID++; - continue; - } - - udelay(10); - i++; - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "r8192e_drain_tx_queues() timeout queue %d\n", QueueID); - break; - } - } -} - -static bool SetRFPowerState8190(struct r8192_priv *priv, - RT_RF_POWER_STATE eRFPowerState) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - bool bResult = true; - - if (eRFPowerState == priv->eRFPowerState && - priv->bHwRfOffAction == 0) { - bResult = false; - goto out; - } - - switch( eRFPowerState ) - { - case eRfOn: - - // turn on RF - if ((priv->eRFPowerState == eRfOff) && - RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - /* - * The current RF state is OFF and the RF OFF level - * is halting the NIC, re-initialize the NIC. - */ - if (!NicIFEnableNIC(priv)) { - RT_TRACE(COMP_ERR, "%s(): NicIFEnableNIC failed\n",__FUNCTION__); - bResult = false; - goto out; - } - - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } else { - write_nic_byte(priv, ANAPAR, 0x37);//160MHz - mdelay(1); - //enable clock 80/88 MHz - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x1); // 0x880[2] - priv->bHwRfOffAction = 0; - - //RF-A, RF-B - //enable RF-Chip A/B - rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); // 0x860[4] - //analog to digital on - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x3);// 0x88c[9:8] - //digital to analog on - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x3); // 0x880[4:3] - //rx antenna on - rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0x3, 0x3);// 0xc04[1:0] - //rx antenna on - rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0x3, 0x3);// 0xd04[1:0] - //analog to digital part2 on - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x3); // 0x880[6:5] - - } - - break; - - // - // In current solution, RFSleep=RFOff in order to save power under 802.11 power save. - // By Bruce, 2008-01-16. - // - case eRfSleep: - - // HW setting had been configured with deeper mode. - if(priv->eRFPowerState == eRfOff) - break; - - r8192e_drain_tx_queues(priv); - - PHY_SetRtl8192eRfOff(priv); - - break; - - case eRfOff: - - // - // Disconnect with Any AP or STA. - // - r8192e_drain_tx_queues(priv); - - - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - /* Disable all components. */ - NicIFDisableNIC(priv); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } - else if (!(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC)) - { - /* Normal case - IPS should go to this. */ - PHY_SetRtl8192eRfOff(priv); - } - break; - - default: - bResult = false; - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state to set: 0x%X!!!\n", eRFPowerState); - break; - } - - if(bResult) - { - // Update current RF state variable. - priv->eRFPowerState = eRFPowerState; - } - -out: - return bResult; -} - - - - - -static void MgntDisconnectIBSS(struct r8192_priv *priv) -{ - u8 i; - bool bFilterOutNonAssociatedBSSID = false; - - priv->ieee80211->state = IEEE80211_NOLINK; - - for(i=0;i<6;i++) priv->ieee80211->current_network.bssid[i]= 0x55; - priv->OpMode = RT_OP_MODE_NO_LINK; - write_nic_word(priv, BSSIDR, ((u16*)priv->ieee80211->current_network.bssid)[0]); - write_nic_dword(priv, BSSIDR+2, ((u32*)(priv->ieee80211->current_network.bssid+2))[0]); - { - RT_OP_MODE OpMode = priv->OpMode; - u8 btMsr = read_nic_byte(priv, MSR); - - btMsr &= 0xfc; - - switch(OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_LINK_MANAGED; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_LINK_ADHOC; - // led link set separate - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_LINK_MASTER; - break; - - default: - btMsr |= MSR_LINK_NONE; - break; - } - - write_nic_byte(priv, MSR, btMsr); - } - ieee80211_stop_send_beacons(priv->ieee80211); - - // If disconnect, clear RCR CBSSID bit - bFilterOutNonAssociatedBSSID = false; - { - u32 RegRCR, Type; - Type = bFilterOutNonAssociatedBSSID; - RegRCR = read_nic_dword(priv, RCR); - priv->ReceiveConfig = RegRCR; - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); - - { - write_nic_dword(priv, RCR, RegRCR); - priv->ReceiveConfig = RegRCR; - } - - } - notify_wx_assoc_event(priv->ieee80211); - -} - -static void MlmeDisassociateRequest(struct r8192_priv *priv, u8 *asSta, - u8 asRsn) -{ - u8 i; - - RemovePeerTS(priv->ieee80211, asSta); - - SendDisassociation( priv->ieee80211, asSta, asRsn ); - - if(memcpy(priv->ieee80211->current_network.bssid,asSta,6) == NULL) - { - //ShuChen TODO: change media status. - //ShuChen TODO: What to do when disassociate. - priv->ieee80211->state = IEEE80211_NOLINK; - for(i=0;i<6;i++) priv->ieee80211->current_network.bssid[i] = 0x22; - priv->OpMode = RT_OP_MODE_NO_LINK; - { - RT_OP_MODE OpMode = priv->OpMode; - u8 btMsr = read_nic_byte(priv, MSR); - - btMsr &= 0xfc; - - switch(OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_LINK_MANAGED; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_LINK_ADHOC; - // led link set separate - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_LINK_MASTER; - break; - - default: - btMsr |= MSR_LINK_NONE; - break; - } - - write_nic_byte(priv, MSR, btMsr); - } - ieee80211_disassociate(priv->ieee80211); - - write_nic_word(priv, BSSIDR, ((u16*)priv->ieee80211->current_network.bssid)[0]); - write_nic_dword(priv, BSSIDR+2, ((u32*)(priv->ieee80211->current_network.bssid+2))[0]); - - } - -} - - -static void MgntDisconnectAP(struct r8192_priv *priv, u8 asRsn) -{ - bool bFilterOutNonAssociatedBSSID = false; - u32 RegRCR, Type; - - /* If disconnect, clear RCR CBSSID bit */ - bFilterOutNonAssociatedBSSID = false; - - Type = bFilterOutNonAssociatedBSSID; - RegRCR = read_nic_dword(priv, RCR); - priv->ReceiveConfig = RegRCR; - - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); - - write_nic_dword(priv, RCR, RegRCR); - priv->ReceiveConfig = RegRCR; - - MlmeDisassociateRequest(priv, priv->ieee80211->current_network.bssid, asRsn); - - priv->ieee80211->state = IEEE80211_NOLINK; -} - - -static bool MgntDisconnect(struct r8192_priv *priv, u8 asRsn) -{ - // In adhoc mode, update beacon frame. - if( priv->ieee80211->state == IEEE80211_LINKED ) - { - if( priv->ieee80211->iw_mode == IW_MODE_ADHOC ) - { - MgntDisconnectIBSS(priv); - } - if( priv->ieee80211->iw_mode == IW_MODE_INFRA ) - { - // We clear key here instead of MgntDisconnectAP() because that - // MgntActSet_802_11_DISASSOCIATE() is an interface called by OS, - // e.g. OID_802_11_DISASSOCIATE in Windows while as MgntDisconnectAP() is - // used to handle disassociation related things to AP, e.g. send Disassoc - // frame to AP. 2005.01.27, by rcnjko. - MgntDisconnectAP(priv, asRsn); - } - } - - return true; -} - -// -// Description: -// Chang RF Power State. -// Note that, only MgntActSet_RF_State() is allowed to set HW_VAR_RF_STATE. -// -// Assumption: -// PASSIVE LEVEL. -// -bool MgntActSet_RF_State(struct r8192_priv *priv, RT_RF_POWER_STATE StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource) -{ - bool bActionAllowed = false; - bool bConnectBySSID = false; - RT_RF_POWER_STATE rtState; - - RT_TRACE(COMP_POWER, "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); - - spin_lock(&priv->rf_ps_lock); - - rtState = priv->eRFPowerState; - - switch(StateToSet) - { - case eRfOn: - priv->RfOffReason &= (~ChangeSource); - - if (!priv->RfOffReason) - { - priv->RfOffReason = 0; - bActionAllowed = true; - - - if(rtState == eRfOff && ChangeSource >=RF_CHANGE_BY_HW ) - { - bConnectBySSID = true; - } - } - else - RT_TRACE(COMP_POWER, "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", priv->RfOffReason, ChangeSource); - - break; - - case eRfOff: - - if (priv->RfOffReason > RF_CHANGE_BY_IPS) - { - // Disconnect to current BSS when radio off. Asked by QuanTa. - MgntDisconnect(priv, disas_lv_ss); - } - - priv->RfOffReason |= ChangeSource; - bActionAllowed = true; - break; - - case eRfSleep: - priv->RfOffReason |= ChangeSource; - bActionAllowed = true; - break; - } - - if (bActionAllowed) - { - RT_TRACE(COMP_POWER, "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->RfOffReason); - // Config HW to the specified mode. - SetRFPowerState8190(priv, StateToSet); - } - else - { - RT_TRACE(COMP_POWER, "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->RfOffReason); - } - - // Release RF spinlock - spin_unlock(&priv->rf_ps_lock); - - RT_TRACE(COMP_POWER, "<===MgntActSet_RF_State()\n"); - return bActionAllowed; -} - - diff --git a/drivers/staging/rtl8192e/r8190_rtl8256.h b/drivers/staging/rtl8192e/r8190_rtl8256.h deleted file mode 100644 index 58f92903fca..00000000000 --- a/drivers/staging/rtl8192e/r8190_rtl8256.h +++ /dev/null @@ -1,29 +0,0 @@ -/* r8190_rtl8256.h - rtl8256 radio frontend - * - * This is part of the rtl8180-sa2400 driver - * released under the GPL (See file COPYING for details). - * Copyright (c) 2005 Andrea Merello - * - * Many thanks to Realtek Corp. for their great support! - */ - -#ifndef RTL8225_H -#define RTL8225_H - -#define RTL819X_TOTAL_RF_PATH 2 /* for 8192E */ - -void PHY_SetRF8256Bandwidth(struct r8192_priv *priv, - HT_CHANNEL_WIDTH Bandwidth); - -RT_STATUS PHY_RF8256_Config(struct r8192_priv *priv); - -RT_STATUS phy_RF8256_Config_ParaFile(struct r8192_priv *priv); - -void PHY_SetRF8256CCKTxPower(struct r8192_priv *priv, u8 powerlevel); -void PHY_SetRF8256OFDMTxPower(struct r8192_priv *priv, u8 powerlevel); - -bool MgntActSet_RF_State(struct r8192_priv *priv, - RT_RF_POWER_STATE StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource); - -#endif /* RTL8225_H */ diff --git a/drivers/staging/rtl8192e/r8192E.h b/drivers/staging/rtl8192e/r8192E.h deleted file mode 100644 index 137f66b034b..00000000000 --- a/drivers/staging/rtl8192e/r8192E.h +++ /dev/null @@ -1,1148 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8192 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#ifndef R819xU_H -#define R819xU_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include //for rtnl_lock() -#include -#include -#include // Necessary because we use the proc fs -#include -#include -#include -#include -#include "ieee80211/rtl819x_HT.h" -#include "ieee80211/ieee80211.h" - - - - -#define RTL819xE_MODULE_NAME "rtl819xE" - -#define FALSE 0 -#define TRUE 1 -#define MAX_KEY_LEN 61 -#define KEY_BUF_SIZE 5 - -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 -// Rx smooth factor -#define Rx_Smooth_Factor 20 -/* 2007/06/04 MH Define sliding window for RSSI history. */ -#define PHY_RSSI_SLID_WIN_MAX 100 -#define PHY_Beacon_RSSI_SLID_WIN_MAX 10 - -#define IC_VersionCut_D 0x3 -#define IC_VersionCut_E 0x4 - -#if 0 //we need to use RT_TRACE instead DMESG as RT_TRACE will clearly show debug level wb. -#define DMESG(x,a...) printk(KERN_INFO RTL819xE_MODULE_NAME ": " x "\n", ## a) -#else -#define DMESG(x,a...) -extern u32 rt_global_debug_component; -#define RT_TRACE(component, x, args...) \ -do { if(rt_global_debug_component & component) \ - printk(KERN_DEBUG RTL819xE_MODULE_NAME ":" x , \ - ##args);\ -}while(0); - -#define COMP_TRACE BIT0 // For function call tracing. -#define COMP_DBG BIT1 // Only for temporary debug message. -#define COMP_INIT BIT2 // during driver initialization / halt / reset. - - -#define COMP_RECV BIT3 // Reveive part data path. -#define COMP_SEND BIT4 // Send part path. -#define COMP_IO BIT5 // I/O Related. Added by Annie, 2006-03-02. -#define COMP_POWER BIT6 // 802.11 Power Save mode or System/Device Power state related. -#define COMP_EPROM BIT7 // 802.11 link related: join/start BSS, leave BSS. -#define COMP_SWBW BIT8 // For bandwidth switch. -#define COMP_SEC BIT9// For Security. - - -#define COMP_TURBO BIT10 // For Turbo Mode related. By Annie, 2005-10-21. -#define COMP_QOS BIT11 // For QoS. - -#define COMP_RATE BIT12 // For Rate Adaptive mechanism, 2006.07.02, by rcnjko. #define COMP_EVENTS 0x00000080 // Event handling -#define COMP_RXDESC BIT13 // Show Rx desc information for SD3 debug. Added by Annie, 2006-07-15. -#define COMP_PHY BIT14 -#define COMP_DIG BIT15 // For DIG, 2006.09.25, by rcnjko. -#define COMP_TXAGC BIT16 // For Tx power, 060928, by rcnjko. -#define COMP_HALDM BIT17 // For HW Dynamic Mechanism, 061010, by rcnjko. -#define COMP_POWER_TRACKING BIT18 //FOR 8190 TX POWER TRACKING -#define COMP_EVENTS BIT19 // Event handling - -#define COMP_RF BIT20 // For RF. - -/* 11n or 8190 specific code should be put below this line */ - - -#define COMP_FIRMWARE BIT21 //for firmware downloading -#define COMP_HT BIT22 // For 802.11n HT related information. by Emily 2006-8-11 - -#define COMP_RESET BIT23 -#define COMP_CMDPKT BIT24 -#define COMP_SCAN BIT25 -#define COMP_IPS BIT26 -#define COMP_DOWN BIT27 // for rm driver module -#define COMP_INTR BIT28 // for interrupt -#define COMP_ERR BIT31 // for error out, always on -#endif - - -// -// Queue Select Value in TxDesc -// -#define QSLT_BK 0x1 -#define QSLT_BE 0x0 -#define QSLT_VI 0x4 -#define QSLT_VO 0x6 -#define QSLT_BEACON 0x10 -#define QSLT_HIGH 0x11 -#define QSLT_MGNT 0x12 -#define QSLT_CMD 0x13 - -#define DESC90_RATE1M 0x00 -#define DESC90_RATE2M 0x01 -#define DESC90_RATE5_5M 0x02 -#define DESC90_RATE11M 0x03 -#define DESC90_RATE6M 0x04 -#define DESC90_RATE9M 0x05 -#define DESC90_RATE12M 0x06 -#define DESC90_RATE18M 0x07 -#define DESC90_RATE24M 0x08 -#define DESC90_RATE36M 0x09 -#define DESC90_RATE48M 0x0a -#define DESC90_RATE54M 0x0b -#define DESC90_RATEMCS0 0x00 -#define DESC90_RATEMCS1 0x01 -#define DESC90_RATEMCS2 0x02 -#define DESC90_RATEMCS3 0x03 -#define DESC90_RATEMCS4 0x04 -#define DESC90_RATEMCS5 0x05 -#define DESC90_RATEMCS6 0x06 -#define DESC90_RATEMCS7 0x07 -#define DESC90_RATEMCS8 0x08 -#define DESC90_RATEMCS9 0x09 -#define DESC90_RATEMCS10 0x0a -#define DESC90_RATEMCS11 0x0b -#define DESC90_RATEMCS12 0x0c -#define DESC90_RATEMCS13 0x0d -#define DESC90_RATEMCS14 0x0e -#define DESC90_RATEMCS15 0x0f -#define DESC90_RATEMCS32 0x20 - -#define RTL819X_DEFAULT_RF_TYPE RF_1T2R -#define EEPROM_Default_LegacyHTTxPowerDiff 0x4 -#define IEEE80211_WATCH_DOG_TIME 2000 - -typedef u32 RT_RF_CHANGE_SOURCE; -#define RF_CHANGE_BY_SW BIT31 -#define RF_CHANGE_BY_HW BIT30 -#define RF_CHANGE_BY_PS BIT29 -#define RF_CHANGE_BY_IPS BIT28 -#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17. - -// RF state. -typedef enum _RT_RF_POWER_STATE { - eRfOn, - eRfSleep, - eRfOff -} RT_RF_POWER_STATE; - -typedef enum _RT_JOIN_ACTION { - RT_JOIN_INFRA = 1, - RT_JOIN_IBSS = 2, - RT_START_IBSS = 3, - RT_NO_ACTION = 4, -} RT_JOIN_ACTION; - -typedef enum _IPS_CALLBACK_FUNCION { - IPS_CALLBACK_NONE = 0, - IPS_CALLBACK_MGNT_LINK_REQUEST = 1, - IPS_CALLBACK_JOIN_REQUEST = 2, -} IPS_CALLBACK_FUNCION; - -typedef struct _RT_POWER_SAVE_CONTROL { - /* Inactive Power Save(IPS) : Disable RF when disconnected */ - bool bInactivePs; - bool bIPSModeBackup; - bool bSwRfProcessing; - RT_RF_POWER_STATE eInactivePowerState; - struct work_struct InactivePsWorkItem; - struct timer_list InactivePsTimer; - - /* Return point for join action */ - IPS_CALLBACK_FUNCION ReturnPoint; - - /* Recored Parameters for rescheduled JoinRequest */ - bool bTmpBssDesc; - RT_JOIN_ACTION tmpJoinAction; - struct ieee80211_network tmpBssDesc; - - /* Recored Parameters for rescheduled MgntLinkRequest */ - bool bTmpScanOnly; - bool bTmpActiveScan; - bool bTmpFilterHiddenAP; - bool bTmpUpdateParms; - u8 tmpSsidBuf[33]; - OCTET_STRING tmpSsid2Scan; - bool bTmpSsid2Scan; - u8 tmpNetworkType; - u8 tmpChannelNumber; - u16 tmpBcnPeriod; - u8 tmpDtimPeriod; - u16 tmpmCap; - OCTET_STRING tmpSuppRateSet; - u8 tmpSuppRateBuf[MAX_NUM_RATES]; - bool bTmpSuppRate; - IbssParms tmpIbpm; - bool bTmpIbpm; - - /* - * Leisure Power Save: - * Disable RF if connected but traffic is not busy - */ - bool bLeisurePs; - u32 PowerProfile; - u8 LpsIdleCount; - - u32 CurPsLevel; - u32 RegRfPsLevel; - - bool bFwCtrlLPS; - u8 FWCtrlPSMode; - - bool LinkReqInIPSRFOffPgs; - bool BufConnectinfoBefore; -} RT_POWER_SAVE_CONTROL, *PRT_POWER_SAVE_CONTROL; - -/* For rtl819x */ -typedef struct _tx_desc_819x_pci { - //DWORD 0 - u16 PktSize; - u8 Offset; - u8 Reserved1:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; - - //DWORD 1 - u8 TxFWInfoSize; - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Resv:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; - - //DWORD 2 - u16 TxBufferSize; - u8 PktId:7; - u8 Resv1:1; - u8 Reserved2; - - //DWORD 3 - u32 TxBuffAddr; - - //DWORD 4 - u32 NextDescAddress; - - //DWORD 5,6,7 - u32 Reserved5; - u32 Reserved6; - u32 Reserved7; -}tx_desc_819x_pci, *ptx_desc_819x_pci; - - -typedef struct _tx_desc_cmd_819x_pci { - //DWORD 0 - u16 PktSize; - u8 Reserved1; - u8 CmdType:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; - - //DOWRD 1 - u16 ElementReport; - u16 Reserved2; - - //DOWRD 2 - u16 TxBufferSize; - u16 Reserved3; - - //DWORD 3,4,5 - u32 TxBufferAddr; - u32 NextDescAddress; - u32 Reserved4; - u32 Reserved5; - u32 Reserved6; -}tx_desc_cmd_819x_pci, *ptx_desc_cmd_819x_pci; - - -typedef struct _tx_fwinfo_819x_pci { - //DOWRD 0 - u8 TxRate:7; - u8 CtsEnable:1; - u8 RtsRate:7; - u8 RtsEnable:1; - u8 TxHT:1; - u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 TxBandwidth:1; // This is used for HT MCS rate only. - u8 TxSubCarrier:2; // This is used for legacy OFDM rate only. - u8 STBC:2; - u8 AllowAggregation:1; - u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate - u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 RtsBandwidth:1; // This is used for HT MCS rate only. - u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only. - u8 RtsSTBC:2; - u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration - - //DWORD 1 - u8 RxMF:2; - u8 RxAMD:3; - u8 Reserved1:3; - u8 Reserved2; - u8 Reserved3; - u8 Reserved4; - - //u32 Reserved; -}tx_fwinfo_819x_pci, *ptx_fwinfo_819x_pci; - -typedef struct _rx_desc_819x_pci{ - //DOWRD 0 - u16 Length:14; - u16 CRC32:1; - u16 ICV:1; - u8 RxDrvInfoSize; - u8 Shift:2; - u8 PHYStatus:1; - u8 SWDec:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 EOR:1; - u8 OWN:1; - - //DWORD 1 - u32 Reserved2; - - //DWORD 2 - u32 Reserved3; - - //DWORD 3 - u32 BufferAddress; - -}rx_desc_819x_pci, *prx_desc_819x_pci; - -typedef struct _rx_fwinfo_819x_pci{ - //DWORD 0 - u16 Reserved1:12; - u16 PartAggr:1; - u16 FirstAGGR:1; - u16 Reserved2:2; - - u8 RxRate:7; - u8 RxHT:1; - - u8 BW:1; - u8 SPLCP:1; - u8 Reserved3:2; - u8 PAM:1; - u8 Mcast:1; - u8 Bcast:1; - u8 Reserved4:1; - - //DWORD 1 - u32 TSFL; - -}rx_fwinfo_819x_pci, *prx_fwinfo_819x_pci; - -#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */ -#define MAX_FIRMWARE_INFORMATION_SIZE 32 /*2006/04/30 by Emily forRTL8190*/ -#define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) -#define ENCRYPTION_MAX_OVERHEAD 128 -#define MAX_FRAGMENT_COUNT 8 -#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) - -#define scrclng 4 // octets for crc32 (FCS, ICV) -/* 8190 Loopback Mode definition */ -typedef enum _rtl819x_loopback{ - RTL819X_NO_LOOPBACK = 0, - RTL819X_MAC_LOOPBACK = 1, - RTL819X_DMA_LOOPBACK = 2, - RTL819X_CCK_LOOPBACK = 3, -}rtl819x_loopback_e; - -/* due to rtl8192 firmware */ -typedef enum _desc_packet_type_e{ - DESC_PACKET_TYPE_INIT = 0, - DESC_PACKET_TYPE_NORMAL = 1, -}desc_packet_type_e; - -typedef enum _firmware_status{ - FW_STATUS_0_INIT = 0, - FW_STATUS_1_MOVE_BOOT_CODE = 1, - FW_STATUS_2_MOVE_MAIN_CODE = 2, - FW_STATUS_3_TURNON_CPU = 3, - FW_STATUS_4_MOVE_DATA_CODE = 4, - FW_STATUS_5_READY = 5, -}firmware_status_e; - -typedef struct _rt_firmware{ - firmware_status_e firmware_status; - u16 cmdpacket_frag_thresold; -#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k -#define MAX_FW_INIT_STEP 3 - u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; - u16 firmware_buf_size[MAX_FW_INIT_STEP]; -}rt_firmware, *prt_firmware; - -#define MAX_RECEIVE_BUFFER_SIZE 9100 // Add this to 9100 bytes to receive A-MSDU from RT-AP - -/* Firmware Queue Layout */ -#define NUM_OF_FIRMWARE_QUEUE 10 -#define NUM_OF_PAGES_IN_FW 0x100 -#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x0aa -#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x007 -#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x024 -#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x007 -#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0 -#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x2 -#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x10 -#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0 -#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4 -#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0xd -#define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000 -#define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00 -#define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08 -#define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10 -#define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18 -#define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10 -#define RSVD_FW_QUEUE_PAGE_CMD_SHIFT 0x08 -#define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00 -#define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08 - -#define DCAM 0xAC // Debug CAM Interface -#define AESMSK_FC 0xB2 // AES Mask register for frame control (0xB2~0xB3). Added by Annie, 2006-03-06. - - -#define CAM_CONTENT_COUNT 8 -#define CFG_VALID BIT15 -#define EPROM_93c46 0 -#define EPROM_93c56 1 - -#define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U -#define DEFAULT_BEACONINTERVAL 0x64U - -#define DEFAULT_RETRY_RTS 7 -#define DEFAULT_RETRY_DATA 7 - -#define PHY_RSSI_SLID_WIN_MAX 100 - - -typedef enum _WIRELESS_MODE { - WIRELESS_MODE_UNKNOWN = 0x00, - WIRELESS_MODE_A = 0x01, - WIRELESS_MODE_B = 0x02, - WIRELESS_MODE_G = 0x04, - WIRELESS_MODE_AUTO = 0x08, - WIRELESS_MODE_N_24G = 0x10, - WIRELESS_MODE_N_5G = 0x20 -} WIRELESS_MODE; - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -typedef struct buffer -{ - struct buffer *next; - u32 *buf; - dma_addr_t dma; - -} buffer; - -typedef struct _rt_9x_tx_rate_history { - u32 cck[4]; - u32 ofdm[8]; - // HT_MCS[0][]: BW=0 SG=0 - // HT_MCS[1][]: BW=1 SG=0 - // HT_MCS[2][]: BW=0 SG=1 - // HT_MCS[3][]: BW=1 SG=1 - u32 ht_mcs[4][16]; -}rt_tx_rahis_t, *prt_tx_rahis_t; - -typedef struct _RT_SMOOTH_DATA_4RF { - char elements[4][100];//array to store values - u32 index; //index to current array to store - u32 TotalNum; //num of valid elements - u32 TotalVal[4]; //sum of valid elements -}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF; - -typedef enum _tag_TxCmd_Config_Index{ - TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, - TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, - TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, - TXCMD_SET_TX_DURATION = 0xFF900003, - TXCMD_SET_RX_RSSI = 0xFF900004, - TXCMD_SET_TX_PWR_TRACKING = 0xFF900005, - TXCMD_XXXX_CTRL, -}DCMD_TXCMD_OP; - -typedef struct Stats -{ - unsigned long rxrdu; - unsigned long rxok; - unsigned long received_rate_histogram[4][32]; //0: Total, 1:OK, 2:CRC, 3:ICV - unsigned long rxoverflow; - unsigned long rxint; - unsigned long txoverflow; - unsigned long txbeokint; - unsigned long txbkokint; - unsigned long txviokint; - unsigned long txvookint; - unsigned long txbeaconokint; - unsigned long txbeaconerr; - unsigned long txmanageokint; - unsigned long txcmdpktokint; - unsigned long txfeedback; - unsigned long txfeedbackok; - unsigned long txoktotal; - unsigned long txbytesunicast; - unsigned long rxbytesunicast; - - unsigned long slide_signal_strength[100]; - unsigned long slide_evm[100]; - unsigned long slide_rssi_total; // For recording sliding window's RSSI value - unsigned long slide_evm_total; // For recording sliding window's EVM value - long signal_strength; // Transformed, in dbm. Beautified signal strength for UI, not correct. - u8 rx_rssi_percentage[4]; - u8 rx_evm_percentage[2]; - u32 Slide_Beacon_pwdb[100]; - u32 Slide_Beacon_Total; - RT_SMOOTH_DATA_4RF cck_adc_pwdb; -} Stats; - - -// Bandwidth Offset -#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 -#define HAL_PRIME_CHNL_OFFSET_LOWER 1 -#define HAL_PRIME_CHNL_OFFSET_UPPER 2 - -typedef struct ChnlAccessSetting { - u16 SIFS_Timer; - u16 DIFS_Timer; - u16 SlotTimeTimer; - u16 EIFS_Timer; - u16 CWminIndex; - u16 CWmaxIndex; -}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING; - -typedef struct _BB_REGISTER_DEFINITION{ - u32 rfintfs; // set software control: // 0x870~0x877[8 bytes] - u32 rfintfi; // readback data: // 0x8e0~0x8e7[8 bytes] - u32 rfintfo; // output data: // 0x860~0x86f [16 bytes] - u32 rfintfe; // output enable: // 0x860~0x86f [16 bytes] - u32 rf3wireOffset; // LSSI data: // 0x840~0x84f [16 bytes] - u32 rfLSSI_Select; // BB Band Select: // 0x878~0x87f [8 bytes] - u32 rfTxGainStage; // Tx gain stage: // 0x80c~0x80f [4 bytes] - u32 rfHSSIPara1; // wire parameter control1 : // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes] - u32 rfHSSIPara2; // wire parameter control2 : // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes] - u32 rfSwitchControl; //Tx Rx antenna control : // 0x858~0x85f [16 bytes] - u32 rfAGCControl1; //AGC parameter control1 : // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes] - u32 rfAGCControl2; //AGC parameter control2 : // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes] - u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix : // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes] - u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes] - u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes] - u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes] - u32 rfLSSIReadBack; //LSSI RF readback data // 0x8a0~0x8af [16 bytes] -}BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T; - -typedef struct _rate_adaptive -{ - u8 rate_adaptive_disabled; - u8 ratr_state; - u16 reserve; - - u32 high_rssi_thresh_for_ra; - u32 high2low_rssi_thresh_for_ra; - u8 low2high_rssi_thresh_for_ra40M; - u32 low_rssi_thresh_for_ra40M; - u8 low2high_rssi_thresh_for_ra20M; - u32 low_rssi_thresh_for_ra20M; - u32 upper_rssi_threshold_ratr; - u32 middle_rssi_threshold_ratr; - u32 low_rssi_threshold_ratr; - u32 low_rssi_threshold_ratr_40M; - u32 low_rssi_threshold_ratr_20M; - u8 ping_rssi_enable; //cosa add for test - u32 ping_rssi_ratr; //cosa add for test - u32 ping_rssi_thresh_for_ra;//cosa add for test - u32 last_ratr; - -} rate_adaptive, *prate_adaptive; -#define TxBBGainTableLength 37 -#define CCKTxBBGainTableLength 23 -typedef struct _txbbgain_struct -{ - long txbb_iq_amplifygain; - u32 txbbgain_value; -} txbbgain_struct, *ptxbbgain_struct; - -typedef struct _ccktxbbgain_struct -{ - //The Value is from a22 to a29 one Byte one time is much Safer - u8 ccktxbb_valuearray[8]; -} ccktxbbgain_struct,*pccktxbbgain_struct; - - -typedef struct _init_gain -{ - u8 xaagccore1; - u8 xbagccore1; - u8 xcagccore1; - u8 xdagccore1; - u8 cca; - -} init_gain, *pinit_gain; - -/* 2007/11/02 MH Define RF mode temporarily for test. */ -typedef enum tag_Rf_Operatetion_State -{ - RF_STEP_INIT = 0, - RF_STEP_NORMAL, - RF_STEP_MAX -}RF_STEP_E; - -typedef enum _RT_STATUS{ - RT_STATUS_SUCCESS, - RT_STATUS_FAILURE, - RT_STATUS_PENDING, - RT_STATUS_RESOURCE -}RT_STATUS,*PRT_STATUS; - -typedef enum _RT_CUSTOMER_ID -{ - RT_CID_DEFAULT = 0, - RT_CID_8187_ALPHA0 = 1, - RT_CID_8187_SERCOMM_PS = 2, - RT_CID_8187_HW_LED = 3, - RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, - RT_CID_819x_CAMEO = 6, - RT_CID_819x_RUNTOP = 7, - RT_CID_819x_Senao = 8, - RT_CID_TOSHIBA = 9, // Merge by Jacken, 2008/01/31. - RT_CID_819x_Netcore = 10, - RT_CID_Nettronix = 11, - RT_CID_DLINK = 12, - RT_CID_PRONET = 13, - RT_CID_COREGA = 14, -}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; - -/* LED customization. */ - -typedef enum _LED_STRATEGY_8190{ - SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option. - SW_LED_MODE1, // SW control for PCI Express - SW_LED_MODE2, // SW control for Cameo. - SW_LED_MODE3, // SW contorl for RunTop. - SW_LED_MODE4, // SW control for Netcore - SW_LED_MODE5, //added by vivi, for led new mode, DLINK - SW_LED_MODE6, //added by vivi, for led new mode, PRONET - HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes) -}LED_STRATEGY_8190, *PLED_STRATEGY_8190; - -#define CHANNEL_PLAN_LEN 10 - -#define sCrcLng 4 - -typedef struct _TX_FWINFO_STRUCUTRE{ - //DOWRD 0 - u8 TxRate:7; - u8 CtsEnable:1; - u8 RtsRate:7; - u8 RtsEnable:1; - u8 TxHT:1; - u8 Short:1; - u8 TxBandwidth:1; - u8 TxSubCarrier:2; - u8 STBC:2; - u8 AllowAggregation:1; - u8 RtsHT:1; - u8 RtsShort:1; - u8 RtsBandwidth:1; - u8 RtsSubcarrier:2; - u8 RtsSTBC:2; - u8 EnableCPUDur:1; - - //DWORD 1 - u32 RxMF:2; - u32 RxAMD:3; - u32 Reserved1:3; - u32 TxAGCOffset:4; - u32 TxAGCSign:1; - u32 Tx_INFO_RSVD:6; - u32 PacketID:13; -}TX_FWINFO_T; - - -typedef struct _TX_FWINFO_8190PCI{ - //DOWRD 0 - u8 TxRate:7; - u8 CtsEnable:1; - u8 RtsRate:7; - u8 RtsEnable:1; - u8 TxHT:1; - u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 TxBandwidth:1; // This is used for HT MCS rate only. - u8 TxSubCarrier:2; // This is used for legacy OFDM rate only. - u8 STBC:2; - u8 AllowAggregation:1; - u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate - u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 RtsBandwidth:1; // This is used for HT MCS rate only. - u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only. - u8 RtsSTBC:2; - u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration - - //DWORD 1 - u32 RxMF:2; - u32 RxAMD:3; - u32 TxPerPktInfoFeedback:1; // 1: indicate that the transimission info of this packet should be gathered by Firmware and retured by Rx Cmd. - u32 Reserved1:2; - u32 TxAGCOffset:4; // Only 90 support - u32 TxAGCSign:1; // Only 90 support - u32 RAW_TXD:1; // MAC will send data in txpktbuffer without any processing,such as CRC check - u32 Retry_Limit:4; // CCX Support relative retry limit FW page only support 4 bits now. - u32 Reserved2:1; - u32 PacketID:13; - - // DW 2 - -}TX_FWINFO_8190PCI, *PTX_FWINFO_8190PCI; - -typedef struct _phy_ofdm_rx_status_report_819xpci -{ - u8 trsw_gain_X[4]; - u8 pwdb_all; - u8 cfosho_X[4]; - u8 cfotail_X[4]; - u8 rxevm_X[2]; - u8 rxsnr_X[4]; - u8 pdsnr_X[2]; - u8 csi_current_X[2]; - u8 csi_target_X[2]; - u8 sigevm; - u8 max_ex_pwr; - u8 sgi_en; - u8 rxsc_sgien_exflg; -}phy_sts_ofdm_819xpci_t; - -typedef struct _phy_cck_rx_status_report_819xpci -{ - /* For CCK rate descriptor. This is a unsigned 8:1 variable. LSB bit presend - 0.5. And MSB 7 bts presend a signed value. Range from -64~+63.5. */ - u8 adc_pwdb_X[4]; - u8 sq_rpt; - u8 cck_agc_rpt; -}phy_sts_cck_819xpci_t; - -typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{ - u8 reserved:4; - u8 rxsc:2; - u8 sgi_en:1; - u8 ex_intf_flag:1; -}phy_ofdm_rx_status_rxsc_sgien_exintfflag; - -typedef enum _RT_OP_MODE{ - RT_OP_MODE_AP, - RT_OP_MODE_INFRASTRUCTURE, - RT_OP_MODE_IBSS, - RT_OP_MODE_NO_LINK, -}RT_OP_MODE, *PRT_OP_MODE; - - -/* 2007/11/02 MH Define RF mode temporarily for test. */ -typedef enum tag_Rf_OpType -{ - RF_OP_By_SW_3wire = 0, - RF_OP_By_FW, - RF_OP_MAX -}RF_OpType_E; - -typedef enum _RESET_TYPE { - RESET_TYPE_NORESET = 0x00, - RESET_TYPE_NORMAL = 0x01, - RESET_TYPE_SILENT = 0x02 -} RESET_TYPE; - -typedef struct _tx_ring{ - u32 * desc; - u8 nStuckCount; - struct _tx_ring * next; -}__attribute__ ((packed)) tx_ring, * ptx_ring; - -struct rtl8192_tx_ring { - tx_desc_819x_pci *desc; - dma_addr_t dma; - unsigned int idx; - unsigned int entries; - struct sk_buff_head queue; -}; - -#define NIC_SEND_HANG_THRESHOLD_NORMAL 4 -#define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 -#define MAX_TX_QUEUE 9 // BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. - -#define MAX_RX_COUNT 64 -#define MAX_TX_QUEUE_COUNT 9 - -typedef struct r8192_priv -{ - struct pci_dev *pdev; - u8 *mem_start; - - /* maintain info from eeprom */ - short epromtype; - u16 eeprom_vid; - u16 eeprom_did; - u8 eeprom_CustomerID; - u16 eeprom_ChannelPlan; - RT_CUSTOMER_ID CustomerID; - u8 IC_Cut; - int irq; - struct ieee80211_device *ieee80211; -#ifdef ENABLE_LPS - bool ps_force; - bool force_lps; - bool bdisable_nic; -#endif - bool being_init_adapter; - u8 Rf_Mode; - u8 card_8192_version; /* if TCR reports card V B/C this discriminates */ - spinlock_t irq_th_lock; - spinlock_t rf_ps_lock; - struct mutex mutex; - - short chan; - short sens; - /* RX stuff */ - rx_desc_819x_pci *rx_ring; - dma_addr_t rx_ring_dma; - unsigned int rx_idx; - struct sk_buff *rx_buf[MAX_RX_COUNT]; - int rxringcount; - u16 rxbuffersize; - - /* TX stuff */ - struct rtl8192_tx_ring tx_ring[MAX_TX_QUEUE_COUNT]; - int txringcount; - - struct tasklet_struct irq_rx_tasklet; - struct tasklet_struct irq_tx_tasklet; - struct tasklet_struct irq_prepare_beacon_tasklet; - - short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode - struct semaphore wx_sem; - struct semaphore rf_sem; //used to lock rf write operation added by wb, modified by david - u8 rf_type; /* 0 means 1T2R, 1 means 2T4R */ - - short (*rf_set_sens)(struct net_device *dev, short sens); - u8 (*rf_set_chan)(struct ieee80211_device *ieee80211, u8 ch); - short promisc; - /* stats */ - struct Stats stats; - struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; - struct ieee80211_rx_stats previous_stats; - - /* RX stuff */ - struct sk_buff_head skb_queue; - struct work_struct qos_activate; - - //2 Tx Related variables - u16 ShortRetryLimit; - u16 LongRetryLimit; - - u32 LastRxDescTSFHigh; - u32 LastRxDescTSFLow; - - - //2 Rx Related variables - u32 ReceiveConfig; - - u8 retry_data; - u8 retry_rts; - - struct work_struct reset_wq; - u8 rx_chk_cnt; - -//for rtl819xPci - // Data Rate Config. Added by Annie, 2006-04-13. - u16 basic_rate; - u8 short_preamble; - u8 slot_time; - u16 SifsTime; -/* WirelessMode*/ - u8 RegWirelessMode; -/*Firmware*/ - prt_firmware pFirmware; - rtl819x_loopback_e LoopbackMode; - bool AutoloadFailFlag; - u16 EEPROMAntPwDiff; // Antenna gain offset from B/C/D to A - u8 EEPROMThermalMeter; - u8 EEPROMCrystalCap; - u8 EEPROMTxPowerLevelCCK[14];// CCK channel 1~14 - // The following definition is for eeprom 93c56 - u8 EEPROMRfACCKChnl1TxPwLevel[3]; //RF-A CCK Tx Power Level at channel 7 - u8 EEPROMRfAOfdmChnlTxPwLevel[3];//RF-A CCK Tx Power Level at [0],[1],[2] = channel 1,7,13 - u8 EEPROMRfCCCKChnl1TxPwLevel[3]; //RF-C CCK Tx Power Level at channel 7 - u8 EEPROMRfCOfdmChnlTxPwLevel[3];//RF-C CCK Tx Power Level at [0],[1],[2] = channel 1,7,13 - u8 EEPROMTxPowerLevelOFDM24G[14]; // OFDM 2.4G channel 1~14 - u8 EEPROMLegacyHTTxPowerDiff; // Legacy to HT rate power diff - bool bTXPowerDataReadFromEEPORM; -/*channel plan*/ - u16 RegChannelPlan; // Channel Plan specifed by user, 15: following setting of EEPROM, 0-14: default channel plan index specified by user. - u16 ChannelPlan; -/*PS related*/ - // Rf off action for power save - u8 bHwRfOffAction; //0:No action, 1:By GPIO, 2:By Disable -/*PHY related*/ - BB_REGISTER_DEFINITION_T PHYRegDef[4]; //Radio A/B/C/D - // Read/write are allow for following hardware information variables - u32 MCSTxPowerLevelOriginalOffset[6]; - u32 CCKTxPowerLevelOriginalOffset; - u8 TxPowerLevelCCK[14]; // CCK channel 1~14 - u8 TxPowerLevelCCK_A[14]; // RF-A, CCK channel 1~14 - u8 TxPowerLevelCCK_C[14]; - u8 TxPowerLevelOFDM24G[14]; // OFDM 2.4G channel 1~14 - u8 TxPowerLevelOFDM5G[14]; // OFDM 5G - u8 TxPowerLevelOFDM24G_A[14]; // RF-A, OFDM 2.4G channel 1~14 - u8 TxPowerLevelOFDM24G_C[14]; // RF-C, OFDM 2.4G channel 1~14 - u8 LegacyHTTxPowerDiff; // Legacy to HT rate power diff - u8 AntennaTxPwDiff[3]; // Antenna gain offset, index 0 for B, 1 for C, and 2 for D - u8 CrystalCap; // CrystalCap. - u8 ThermalMeter[2]; // ThermalMeter, index 0 for RFIC0, and 1 for RFIC1 - //05/27/2008 cck power enlarge - u8 CckPwEnl; - u16 TSSI_13dBm; - u32 Pwr_Track; - u8 CCKPresentAttentuation_20Mdefault; - u8 CCKPresentAttentuation_40Mdefault; - char CCKPresentAttentuation_difference; - char CCKPresentAttentuation; - // Use to calculate PWBD. - RT_RF_POWER_STATE eRFPowerState; - RT_RF_CHANGE_SOURCE RfOffReason; - RT_POWER_SAVE_CONTROL PowerSaveControl; - u8 bCckHighPower; - long undecorated_smoothed_pwdb; - long undecorated_smoothed_cck_adc_pwdb[4]; - //for set channel - u8 SwChnlInProgress; - u8 SwChnlStage; - u8 SwChnlStep; - u8 SetBWModeInProgress; - HT_CHANNEL_WIDTH CurrentChannelBW; - - // 8190 40MHz mode - // - u8 nCur40MhzPrimeSC; // Control channel sub-carrier - // Joseph test for shorten RF configuration time. - // We save RF reg0 in this variable to reduce RF reading. - // - u32 RfReg0Value[4]; - u8 NumTotalRFPath; - bool brfpath_rxenable[4]; -//+by amy 080507 - struct timer_list watch_dog_timer; - u8 watchdog_last_time; - u8 watchdog_check_reset_cnt; - -//+by amy 080515 for dynamic mechenism - //Add by amy Tx Power Control for Near/Far Range 2008/05/15 - bool bDynamicTxHighPower; // Tx high power state - bool bDynamicTxLowPower; // Tx low power state - bool bLastDTPFlag_High; - bool bLastDTPFlag_Low; - - /* OFDM RSSI. For high power or not */ - u8 phy_check_reg824; - u32 phy_reg824_bit9; - - //Add by amy for Rate Adaptive - rate_adaptive rate_adaptive; - //Add by amy for TX power tracking - //2008/05/15 Mars OPEN/CLOSE TX POWER TRACKING - const txbbgain_struct * txbbgain_table; - u8 txpower_count;//For 6 sec do tracking again - bool btxpower_trackingInit; - u8 OFDM_index; - u8 CCK_index; - u8 Record_CCK_20Mindex; - u8 Record_CCK_40Mindex; - //2007/09/10 Mars Add CCK TX Power Tracking - const ccktxbbgain_struct *cck_txbbgain_table; - const ccktxbbgain_struct *cck_txbbgain_ch14_table; - u8 rfa_txpowertrackingindex; - u8 rfa_txpowertrackingindex_real; - u8 rfa_txpowertracking_default; - u8 rfc_txpowertrackingindex; - u8 rfc_txpowertrackingindex_real; - u8 rfc_txpowertracking_default; - bool btxpower_tracking; - bool bcck_in_ch14; - - //For Backup Initial Gain - init_gain initgain_backup; - u8 DefaultInitialGain[4]; - // For EDCA Turbo mode, Added by amy 080515. - bool bis_any_nonbepkts; - bool bcurrent_turbo_EDCA; - - bool bis_cur_rdlstate; - struct timer_list fsync_timer; - u32 rate_record; - u32 rateCountDiffRecord; - u32 ContiuneDiffCount; - bool bswitch_fsync; - - u8 framesync; - u32 framesyncC34; - u8 framesyncMonitor; - - //by amy for gpio - bool bHwRadioOff; - //by amy for ps - RT_OP_MODE OpMode; - //by amy for reset_count - u32 reset_count; - - //by amy for silent reset - RESET_TYPE ResetProgress; - bool bForcedSilentReset; - bool bDisableNormalResetCheck; - u16 TxCounter; - u16 RxCounter; - int IrpPendingCount; - bool bResetInProgress; - bool force_reset; - u8 InitialGainOperateType; - - //define work item by amy 080526 - struct delayed_work update_beacon_wq; - struct delayed_work watch_dog_wq; - struct delayed_work txpower_tracking_wq; - struct delayed_work rfpath_check_wq; - struct delayed_work gpio_change_rf_wq; - struct delayed_work initialgain_operate_wq; - struct workqueue_struct *priv_wq; -}r8192_priv; - -bool init_firmware(struct r8192_priv *priv); -u32 read_cam(struct r8192_priv *priv, u8 addr); -void write_cam(struct r8192_priv *priv, u8 addr, u32 data); -u8 read_nic_byte(struct r8192_priv *priv, int x); -u32 read_nic_dword(struct r8192_priv *priv, int x); -u16 read_nic_word(struct r8192_priv *priv, int x) ; -void write_nic_byte(struct r8192_priv *priv, int x,u8 y); -void write_nic_word(struct r8192_priv *priv, int x,u16 y); -void write_nic_dword(struct r8192_priv *priv, int x,u32 y); - -int rtl8192_down(struct net_device *dev); -int rtl8192_up(struct net_device *dev); -void rtl8192_commit(struct r8192_priv *priv); -void write_phy(struct net_device *dev, u8 adr, u8 data); -void CamResetAllEntry(struct r8192_priv *priv); -void EnableHWSecurityConfig8192(struct r8192_priv *priv); -void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, - const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); -void firmware_init_param(struct r8192_priv *priv); -RT_STATUS cmpk_message_handle_tx(struct r8192_priv *priv, u8 *codevirtualaddress, u32 packettype, u32 buffer_len); - -#ifdef ENABLE_IPS -void IPSEnter(struct r8192_priv *priv); -void IPSLeave(struct r8192_priv *priv); -void IPSLeave_wq(struct work_struct *work); -void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211); -void ieee80211_ips_leave(struct ieee80211_device *ieee80211); -#endif -#ifdef ENABLE_LPS -void LeisurePSEnter(struct ieee80211_device *ieee80211); -void LeisurePSLeave(struct ieee80211_device *ieee80211); -#endif - -bool NicIFEnableNIC(struct r8192_priv *priv); -bool NicIFDisableNIC(struct r8192_priv *priv); - -void PHY_SetRtl8192eRfOff(struct r8192_priv *priv); -#endif diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c deleted file mode 100644 index 94d9c8d5d09..00000000000 --- a/drivers/staging/rtl8192e/r8192E_core.c +++ /dev/null @@ -1,5039 +0,0 @@ -/****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. - * Linux device driver for RTL8192E - * - * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Jerry chuang - */ - - -#include -#include -#include -#include -#include -#include "r8192E_hw.h" -#include "r8192E.h" -#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8192E_wx.h" -#include "r819xE_phy.h" //added by WB 4.30.2008 -#include "r819xE_phyreg.h" -#include "r819xE_cmdpkt.h" -#include "r8192E_dm.h" - -#ifdef CONFIG_PM -#include "r8192_pm.h" -#endif - -#ifdef ENABLE_DOT11D -#include "ieee80211/dot11d.h" -#endif - -//set here to open your trace code. //WB -u32 rt_global_debug_component = COMP_ERR ; //always open err flags on - -static DEFINE_PCI_DEVICE_TABLE(rtl8192_pci_id_tbl) = { - /* Realtek */ - { PCI_DEVICE(0x10ec, 0x8192) }, - - /* Corega */ - { PCI_DEVICE(0x07aa, 0x0044) }, - { PCI_DEVICE(0x07aa, 0x0047) }, - {} -}; - -static char ifname[IFNAMSIZ] = "wlan%d"; -static int hwwep = 1; //default use hw. set 0 to use software security -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); -//MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); - - -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); -module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); - -MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); -static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); - -static struct pci_driver rtl8192_pci_driver = { - .name = RTL819xE_MODULE_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = rtl8192_pci_probe, /* probe fn */ - .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ -#ifdef CONFIG_PM - .suspend = rtl8192E_suspend, /* PM suspend fn */ - .resume = rtl8192E_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - -static void rtl8192_start_beacon(struct ieee80211_device *ieee80211); -static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211); -static void rtl819x_watchdog_wqcallback(struct work_struct *work); -static void rtl8192_irq_rx_tasklet(unsigned long arg); -static void rtl8192_irq_tx_tasklet(unsigned long arg); -static void rtl8192_prepare_beacon(unsigned long arg); -static irqreturn_t rtl8192_interrupt(int irq, void *param); -static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb); -static void rtl8192_update_ratr_table(struct r8192_priv *priv); -static void rtl8192_restart(struct work_struct *work); -static void watch_dog_timer_callback(unsigned long data); -static int _rtl8192_up(struct r8192_priv *priv); -static void rtl8192_cancel_deferred_work(struct r8192_priv* priv); -static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb); - -#ifdef ENABLE_DOT11D - -typedef struct _CHANNEL_LIST -{ - u8 Channel[32]; - u8 Len; -}CHANNEL_LIST, *PCHANNEL_LIST; - -static const CHANNEL_LIST ChannelPlan[] = { - {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC - {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 -}; - -static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) -{ - int i, max_chan=-1, min_chan=-1; - struct ieee80211_device* ieee = priv->ieee80211; - switch (channel_plan) - { - case COUNTRY_CODE_FCC: - case COUNTRY_CODE_IC: - case COUNTRY_CODE_ETSI: - case COUNTRY_CODE_SPAIN: - case COUNTRY_CODE_FRANCE: - case COUNTRY_CODE_MKK: - case COUNTRY_CODE_MKK1: - case COUNTRY_CODE_ISRAEL: - case COUNTRY_CODE_TELEC: - case COUNTRY_CODE_MIC: - { - Dot11d_Init(ieee); - ieee->bGlobalDomain = false; - //acturally 8225 & 8256 rf chip only support B,G,24N mode - min_chan = 1; - max_chan = 14; - - if (ChannelPlan[channel_plan].Len != 0){ - // Clear old channel map - memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); - // Set new channel map - for (i=0;i max_chan) - break; - GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; - } - } - break; - } - case COUNTRY_CODE_GLOBAL_DOMAIN: - { - GET_DOT11D_INFO(ieee)->bEnabled = 0; //this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain setting - Dot11d_Reset(ieee); - ieee->bGlobalDomain = true; - break; - } - default: - break; - } -} -#endif - -static inline bool rx_hal_is_cck_rate(prx_fwinfo_819x_pci pdrvinfo) -{ - return (pdrvinfo->RxRate == DESC90_RATE1M || - pdrvinfo->RxRate == DESC90_RATE2M || - pdrvinfo->RxRate == DESC90_RATE5_5M || - pdrvinfo->RxRate == DESC90_RATE11M) && - !pdrvinfo->RxHT; -} - -void CamResetAllEntry(struct r8192_priv* priv) -{ - write_nic_dword(priv, RWCAM, BIT31|BIT30); -} - -void write_cam(struct r8192_priv *priv, u8 addr, u32 data) -{ - write_nic_dword(priv, WCAMI, data); - write_nic_dword(priv, RWCAM, BIT31|BIT16|(addr&0xff) ); -} - -u32 read_cam(struct r8192_priv *priv, u8 addr) -{ - write_nic_dword(priv, RWCAM, 0x80000000|(addr&0xff) ); - return read_nic_dword(priv, 0xa8); -} - -u8 read_nic_byte(struct r8192_priv *priv, int x) -{ - return 0xff & readb(priv->mem_start + x); -} - -u32 read_nic_dword(struct r8192_priv *priv, int x) -{ - return readl(priv->mem_start + x); -} - -u16 read_nic_word(struct r8192_priv *priv, int x) -{ - return readw(priv->mem_start + x); -} - -void write_nic_byte(struct r8192_priv *priv, int x,u8 y) -{ - writeb(y, priv->mem_start + x); - udelay(20); -} - -void write_nic_dword(struct r8192_priv *priv, int x,u32 y) -{ - writel(y, priv->mem_start + x); - udelay(20); -} - -void write_nic_word(struct r8192_priv *priv, int x,u16 y) -{ - writew(y, priv->mem_start + x); - udelay(20); -} - -u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee) -{ - static const u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; - static const u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; - int wpa_ie_len= ieee->wpa_ie_len; - struct ieee80211_crypt_data* crypt; - int encrypt; - - crypt = ieee->crypt[ieee->tx_keyidx]; - - encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) || - (ieee->host_encrypt && crypt && crypt->ops && - (0 == strcmp(crypt->ops->name,"WEP"))); - - /* simply judge */ - if(encrypt && (wpa_ie_len == 0)) { - // wep encryption, no N mode setting */ - return SEC_ALG_WEP; - } else if((wpa_ie_len != 0)) { - // parse pairwise key type */ - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || - ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) - return SEC_ALG_CCMP; - else - return SEC_ALG_TKIP; - } else { - return SEC_ALG_NONE; - } -} - -void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - - switch(variable) - { - - case HW_VAR_BSSID: - write_nic_dword(priv, BSSIDR, ((u32*)(val))[0]); - write_nic_word(priv, BSSIDR+2, ((u16*)(val+2))[0]); - break; - - case HW_VAR_MEDIA_STATUS: - { - RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); - u8 btMsr = read_nic_byte(priv, MSR); - - btMsr &= 0xfc; - - switch(OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_INFRA; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_ADHOC; - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_AP; - break; - - default: - btMsr |= MSR_NOLINK; - break; - } - - write_nic_byte(priv, MSR, btMsr); - } - break; - - case HW_VAR_CHECK_BSSID: - { - u32 RegRCR, Type; - - Type = ((u8*)(val))[0]; - RegRCR = read_nic_dword(priv, RCR); - priv->ReceiveConfig = RegRCR; - - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); - - write_nic_dword(priv, RCR,RegRCR); - priv->ReceiveConfig = RegRCR; - - } - break; - - case HW_VAR_SLOT_TIME: - { - priv->slot_time = val[0]; - write_nic_byte(priv, SLOT_TIME, val[0]); - - } - break; - - case HW_VAR_ACK_PREAMBLE: - { - u32 regTmp = 0; - priv->short_preamble = (bool)(*(u8*)val ); - regTmp = priv->basic_rate; - if (priv->short_preamble) - regTmp |= BRSR_AckShortPmb; - write_nic_dword(priv, RRSR, regTmp); - } - break; - - case HW_VAR_CPU_RST: - write_nic_dword(priv, CPU_GEN, ((u32*)(val))[0]); - break; - - default: - break; - } - -} - -static struct proc_dir_entry *rtl8192_proc = NULL; - -static int proc_get_stats_ap(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - struct ieee80211_device *ieee = priv->ieee80211; - struct ieee80211_network *target; - int len = 0; - - list_for_each_entry(target, &ieee->network_list, list) { - - len += snprintf(page + len, count - len, - "%s ", target->ssid); - - if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } - - } - - *eof = 1; - return len; -} - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - int len = 0; - int i,n; - int max=0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page 0##################\n "); - - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,n)); - } - len += snprintf(page + len, count - len,"\n"); - len += snprintf(page + len, count - len, - "\n####################page 1##################\n "); - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,0x100|n)); - } - - len += snprintf(page + len, count - len, - "\n####################page 3##################\n "); - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,0x300|n)); - } - - *eof = 1; - return len; - -} - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - - int len = 0; - - len += snprintf(page + len, count - len, - "TX VI priority ok int: %lu\n" - "TX VO priority ok int: %lu\n" - "TX BE priority ok int: %lu\n" - "TX BK priority ok int: %lu\n" - "TX MANAGE priority ok int: %lu\n" - "TX BEACON priority ok int: %lu\n" - "TX BEACON priority error int: %lu\n" - "TX CMDPKT priority ok int: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" - "TX total data packets %lu\n" - "TX total data bytes :%lu\n", - priv->stats.txviokint, - priv->stats.txvookint, - priv->stats.txbeokint, - priv->stats.txbkokint, - priv->stats.txmanageokint, - priv->stats.txbeaconokint, - priv->stats.txbeaconerr, - priv->stats.txcmdpktokint, - netif_queue_stopped(priv->ieee80211->dev), - priv->stats.txoverflow, - priv->ieee80211->stats.tx_packets, - priv->ieee80211->stats.tx_bytes); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX desc err: %lu\n" - "RX rx overflow error: %lu\n", - priv->stats.rxint, - priv->stats.rxrdu, - priv->stats.rxoverflow); - - *eof = 1; - return len; -} - -static void rtl8192_proc_module_init(void) -{ - RT_TRACE(COMP_INIT, "Initializing proc filesystem\n"); - rtl8192_proc = proc_mkdir(RTL819xE_MODULE_NAME, init_net.proc_net); -} - - -static void rtl8192_proc_module_remove(void) -{ - remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net); -} - - -static void rtl8192_proc_remove_one(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - - printk("dev name=======> %s\n",dev->name); - - if (priv->dir_dev) { - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry("wlan0", rtl8192_proc); - priv->dir_dev = NULL; - } -} - - -static void rtl8192_proc_init_one(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - struct proc_dir_entry *e; - - priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); - if (!priv->dir_dev) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); - return; - } - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, priv); - - if (!e) { - RT_TRACE(COMP_ERR,"Unable to initialize " - "/proc/net/rtl8192/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, priv); - - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-tx\n", - dev->name); - } - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, priv); - - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-ap\n", - dev->name); - } - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, priv); - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers\n", - dev->name); - } -} - -static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - /* for now we reserve two free descriptor as a safety boundary - * between the tail and the head - */ - return (ring->entries - skb_queue_len(&ring->queue) >= 2); -} - -static void tx_timeout(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - schedule_work(&priv->reset_wq); - printk("TXTIMEOUT"); -} - -static void rtl8192_irq_enable(struct r8192_priv *priv) -{ - u32 mask; - - mask = IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | - IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | - IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW | - IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER; - - write_nic_dword(priv, INTA_MASK, mask); -} - -static void rtl8192_irq_disable(struct r8192_priv *priv) -{ - write_nic_dword(priv, INTA_MASK, 0); - synchronize_irq(priv->irq); -} - -static void rtl8192_update_msr(struct r8192_priv *priv) -{ - u8 msr; - - msr = read_nic_byte(priv, MSR); - msr &= ~ MSR_LINK_MASK; - - /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. - * this is intentional and make sense for ad-hoc and - * master (see the create BSS/IBSS func) - */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<dev); - - priv->chan = ch; - - /* need to implement rf set channel here WB */ - - if (priv->rf_set_chan) - priv->rf_set_chan(ieee80211, priv->chan); -} - -static void rtl8192_rx_enable(struct r8192_priv *priv) -{ - write_nic_dword(priv, RDQDA, priv->rx_ring_dma); -} - -/* the TX_DESC_BASE setting is according to the following queue index - * BK_QUEUE ===> 0 - * BE_QUEUE ===> 1 - * VI_QUEUE ===> 2 - * VO_QUEUE ===> 3 - * HCCA_QUEUE ===> 4 - * TXCMD_QUEUE ===> 5 - * MGNT_QUEUE ===> 6 - * HIGH_QUEUE ===> 7 - * BEACON_QUEUE ===> 8 - * */ -static const u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; -static void rtl8192_tx_enable(struct r8192_priv *priv) -{ - u32 i; - - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - write_nic_dword(priv, TX_DESC_BASE[i], priv->tx_ring[i].dma); - - ieee80211_reset_queue(priv->ieee80211); -} - - -static void rtl8192_free_rx_ring(struct r8192_priv *priv) -{ - int i; - - for (i = 0; i < priv->rxringcount; i++) { - struct sk_buff *skb = priv->rx_buf[i]; - if (!skb) - continue; - - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - kfree_skb(skb); - } - - pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring) * priv->rxringcount, - priv->rx_ring, priv->rx_ring_dma); - priv->rx_ring = NULL; -} - -static void rtl8192_free_tx_ring(struct r8192_priv *priv, unsigned int prio) -{ - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); - - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - - pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; -} - -void PHY_SetRtl8192eRfOff(struct r8192_priv *priv) -{ - //disable RF-Chip A/B - rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); - //analog to digital off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x0); - //digital to analog off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x0); - //rx antenna off - rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0xf, 0x0); - //rx antenna off - rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0xf, 0x0); - //analog to digital part2 off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x0); - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x0); - // Analog parameter!!Change bias and Lbus control. - write_nic_byte(priv, ANAPAR_FOR_8192PciE, 0x07); -} - -static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset) -{ - int i; - u8 OpMode; - u32 ulRegRead; - - OpMode = RT_OP_MODE_NO_LINK; - priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode); - - if (!priv->ieee80211->bSupportRemoteWakeUp) { - /* - * disable tx/rx. In 8185 we write 0x10 (Reset bit), - * but here we make reference to WMAC and wirte 0x0 - */ - write_nic_byte(priv, CMDR, 0); - } - - mdelay(20); - - if (!reset) { - mdelay(150); - - priv->bHwRfOffAction = 2; - - /* - * Call MgntActSet_RF_State instead to - * prevent RF config race condition. - */ - if (!priv->ieee80211->bSupportRemoteWakeUp) { - PHY_SetRtl8192eRfOff(priv); - ulRegRead = read_nic_dword(priv, CPU_GEN); - ulRegRead |= CPU_GEN_SYSTEM_RESET; - write_nic_dword(priv,CPU_GEN, ulRegRead); - } else { - /* for WOL */ - write_nic_dword(priv, WFCRC0, 0xffffffff); - write_nic_dword(priv, WFCRC1, 0xffffffff); - write_nic_dword(priv, WFCRC2, 0xffffffff); - - /* Write PMR register */ - write_nic_byte(priv, PMR, 0x5); - /* Disable tx, enanble rx */ - write_nic_byte(priv, MacBlkCtrl, 0xa); - } - } - - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->ieee80211->skb_waitQ [i]); - } - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->ieee80211->skb_aggQ [i]); - } - - skb_queue_purge(&priv->skb_queue); -} - -static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211) -{ -} - -static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211) -{ -} - -/* - * this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -static void rtl8192_hard_data_xmit(struct sk_buff *skb, - struct ieee80211_device *ieee80211, int rate) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - u8 queue_index = tcb_desc->queue_index; - - /* shall not be referred by command packet */ - BUG_ON(queue_index == TXCMD_QUEUE); - - if (priv->bHwRadioOff || (!priv->up)) - { - kfree_skb(skb); - return; - } - - skb_push(skb, priv->ieee80211->tx_headroom); - ret = rtl8192_tx(priv, skb); - if (ret != 0) { - kfree_skb(skb); - } - - if (queue_index != MGNT_QUEUE) { - priv->ieee80211->stats.tx_bytes += (skb->len - priv->ieee80211->tx_headroom); - priv->ieee80211->stats.tx_packets++; - } -} - -/* - * This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - u8 queue_index = tcb_desc->queue_index; - - if (queue_index != TXCMD_QUEUE) { - if (priv->bHwRadioOff || (!priv->up)) - { - kfree_skb(skb); - return 0; - } - } - - if (queue_index == TXCMD_QUEUE) { - rtl819xE_tx_cmd(priv, skb); - ret = 0; - return ret; - } else { - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - tcb_desc->bTxEnableFwCalcDur = 1; - skb_push(skb, ieee80211->tx_headroom); - ret = rtl8192_tx(priv, skb); - if (ret != 0) { - kfree_skb(skb); - } - } - - return ret; -} - - -static void rtl8192_tx_isr(struct r8192_priv *priv, int prio) -{ - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb; - - /* - * beacon packet will only use the first descriptor defaultly, - * and the OWN may not be cleared by the hardware - */ - if (prio != BEACON_QUEUE) { - if (entry->OWN) - return; - ring->idx = (ring->idx + 1) % ring->entries; - } - - skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - - kfree_skb(skb); - } - - if (prio != BEACON_QUEUE) { - /* try to deal with the pending packets */ - tasklet_schedule(&priv->irq_tx_tasklet); - } -} - -static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211) -{ -} - -static void rtl8192_config_rate(struct r8192_priv *priv, u16* rate_config) -{ - struct ieee80211_network *net; - u8 i=0, basic_rate = 0; - net = & priv->ieee80211->current_network; - - for (i=0; irates_len; i++) - { - basic_rate = net->rates[i]&0x7f; - switch(basic_rate) - { - case MGN_1M: *rate_config |= RRSR_1M; break; - case MGN_2M: *rate_config |= RRSR_2M; break; - case MGN_5_5M: *rate_config |= RRSR_5_5M; break; - case MGN_11M: *rate_config |= RRSR_11M; break; - case MGN_6M: *rate_config |= RRSR_6M; break; - case MGN_9M: *rate_config |= RRSR_9M; break; - case MGN_12M: *rate_config |= RRSR_12M; break; - case MGN_18M: *rate_config |= RRSR_18M; break; - case MGN_24M: *rate_config |= RRSR_24M; break; - case MGN_36M: *rate_config |= RRSR_36M; break; - case MGN_48M: *rate_config |= RRSR_48M; break; - case MGN_54M: *rate_config |= RRSR_54M; break; - } - } - for (i=0; irates_ex_len; i++) - { - basic_rate = net->rates_ex[i]&0x7f; - switch(basic_rate) - { - case MGN_1M: *rate_config |= RRSR_1M; break; - case MGN_2M: *rate_config |= RRSR_2M; break; - case MGN_5_5M: *rate_config |= RRSR_5_5M; break; - case MGN_11M: *rate_config |= RRSR_11M; break; - case MGN_6M: *rate_config |= RRSR_6M; break; - case MGN_9M: *rate_config |= RRSR_9M; break; - case MGN_12M: *rate_config |= RRSR_12M; break; - case MGN_18M: *rate_config |= RRSR_18M; break; - case MGN_24M: *rate_config |= RRSR_24M; break; - case MGN_36M: *rate_config |= RRSR_36M; break; - case MGN_48M: *rate_config |= RRSR_48M; break; - case MGN_54M: *rate_config |= RRSR_54M; break; - } - } -} - - -#define SHORT_SLOT_TIME 9 -#define NON_SHORT_SLOT_TIME 20 - -static void rtl8192_update_cap(struct r8192_priv *priv, u16 cap) -{ - u32 tmp = 0; - struct ieee80211_network *net = &priv->ieee80211->current_network; - - priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; - tmp = priv->basic_rate; - if (priv->short_preamble) - tmp |= BRSR_AckShortPmb; - write_nic_dword(priv, RRSR, tmp); - - if (net->mode & (IEEE_G|IEEE_N_24G)) - { - u8 slot_time = 0; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) - {//short slot time - slot_time = SHORT_SLOT_TIME; - } - else //long slot time - slot_time = NON_SHORT_SLOT_TIME; - priv->slot_time = slot_time; - write_nic_byte(priv, SLOT_TIME, slot_time); - } - -} - -static void rtl8192_net_update(struct r8192_priv *priv) -{ - struct ieee80211_network *net; - u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; - u16 rate_config = 0; - net = &priv->ieee80211->current_network; - - /* update Basic rate: RR, BRSR */ - rtl8192_config_rate(priv, &rate_config); - - /* - * Select RRSR (in Legacy-OFDM and CCK) - * For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, - * 2M, and 1M from the Basic rate. - * We do not use other rates. - */ - priv->basic_rate = rate_config &= 0x15f; - - /* BSSID */ - write_nic_dword(priv, BSSIDR, ((u32 *)net->bssid)[0]); - write_nic_word(priv, BSSIDR+4, ((u16 *)net->bssid)[2]); - - if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { - write_nic_word(priv, ATIMWND, 2); - write_nic_word(priv, BCN_DMATIME, 256); - write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); - /* - * BIT15 of BCN_DRV_EARLY_INT will indicate - * whether software beacon or hw beacon is applied. - */ - write_nic_word(priv, BCN_DRV_EARLY_INT, 10); - write_nic_byte(priv, BCN_ERR_THRESH, 100); - - BcnTimeCfg |= (BcnCW<tx_ring[TXCMD_QUEUE]; - mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - - spin_lock_irqsave(&priv->irq_th_lock,flags); - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = &ring->desc[idx]; - - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - memset(entry,0,12); - entry->LINIP = tcb_desc->bLastIniPkt; - entry->FirstSeg = 1;//first segment - entry->LastSeg = 1; //last segment - if(tcb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { - entry->CmdInit = DESC_PACKET_TYPE_INIT; - } else { - entry->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry->Offset = sizeof(TX_FWINFO_8190PCI) + 8; - entry->PktSize = (u16)(tcb_desc->pkt_size + entry->Offset); - entry->QueueSelect = QSLT_CMD; - entry->TxFWInfoSize = 0x08; - entry->RATid = (u8)DESC_PACKET_TYPE_INIT; - } - entry->TxBufferSize = skb->len; - entry->TxBuffAddr = cpu_to_le32(mapping); - entry->OWN = 1; - - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - - write_nic_byte(priv, TPPoll, TPPoll_CQ); - - return; -} - -/* - * Mapping Software/Hardware descriptor queue id to "Queue Select Field" - * in TxFwInfo data structure - */ -static u8 MapHwQueueToFirmwareQueue(u8 QueueID) -{ - u8 QueueSelect = 0; - - switch (QueueID) { - case BE_QUEUE: - QueueSelect = QSLT_BE; - break; - - case BK_QUEUE: - QueueSelect = QSLT_BK; - break; - - case VO_QUEUE: - QueueSelect = QSLT_VO; - break; - - case VI_QUEUE: - QueueSelect = QSLT_VI; - break; - - case MGNT_QUEUE: - QueueSelect = QSLT_MGNT; - break; - - case BEACON_QUEUE: - QueueSelect = QSLT_BEACON; - break; - - case TXCMD_QUEUE: - QueueSelect = QSLT_CMD; - break; - - case HIGH_QUEUE: - default: - RT_TRACE(COMP_ERR, "Impossible Queue Selection: %d\n", QueueID); - break; - } - return QueueSelect; -} - -static u8 MRateToHwRate8190Pci(u8 rate) -{ - u8 ret = DESC90_RATE1M; - - switch(rate) { - case MGN_1M: ret = DESC90_RATE1M; break; - case MGN_2M: ret = DESC90_RATE2M; break; - case MGN_5_5M: ret = DESC90_RATE5_5M; break; - case MGN_11M: ret = DESC90_RATE11M; break; - case MGN_6M: ret = DESC90_RATE6M; break; - case MGN_9M: ret = DESC90_RATE9M; break; - case MGN_12M: ret = DESC90_RATE12M; break; - case MGN_18M: ret = DESC90_RATE18M; break; - case MGN_24M: ret = DESC90_RATE24M; break; - case MGN_36M: ret = DESC90_RATE36M; break; - case MGN_48M: ret = DESC90_RATE48M; break; - case MGN_54M: ret = DESC90_RATE54M; break; - - // HT rate since here - case MGN_MCS0: ret = DESC90_RATEMCS0; break; - case MGN_MCS1: ret = DESC90_RATEMCS1; break; - case MGN_MCS2: ret = DESC90_RATEMCS2; break; - case MGN_MCS3: ret = DESC90_RATEMCS3; break; - case MGN_MCS4: ret = DESC90_RATEMCS4; break; - case MGN_MCS5: ret = DESC90_RATEMCS5; break; - case MGN_MCS6: ret = DESC90_RATEMCS6; break; - case MGN_MCS7: ret = DESC90_RATEMCS7; break; - case MGN_MCS8: ret = DESC90_RATEMCS8; break; - case MGN_MCS9: ret = DESC90_RATEMCS9; break; - case MGN_MCS10: ret = DESC90_RATEMCS10; break; - case MGN_MCS11: ret = DESC90_RATEMCS11; break; - case MGN_MCS12: ret = DESC90_RATEMCS12; break; - case MGN_MCS13: ret = DESC90_RATEMCS13; break; - case MGN_MCS14: ret = DESC90_RATEMCS14; break; - case MGN_MCS15: ret = DESC90_RATEMCS15; break; - case (0x80|0x20): ret = DESC90_RATEMCS32; break; - - default: break; - } - return ret; -} - - -static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) -{ - u8 tmp_Short; - - tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); - - if(TxHT==1 && TxRate != DESC90_RATEMCS15) - tmp_Short = 0; - - return tmp_Short; -} - -/* - * The tx procedure is just as following, - * skb->cb will contain all the following information, - * priority, morefrag, rate, &dev. - */ -static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb) -{ - struct rtl8192_tx_ring *ring; - unsigned long flags; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tx_desc_819x_pci *pdesc = NULL; - TX_FWINFO_8190PCI *pTxFwInfo = NULL; - dma_addr_t mapping; - bool multi_addr = false, broad_addr = false, uni_addr = false; - u8 *pda_addr = NULL; - int idx; - - if (priv->bdisable_nic) { - RT_TRACE(COMP_ERR, "Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", - skb->len, tcb_desc->queue_index); - return skb->len; - } - -#ifdef ENABLE_LPS - priv->ieee80211->bAwakePktSent = true; -#endif - - mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - - /* collect the tx packets statitcs */ - pda_addr = ((u8 *)skb->data) + sizeof(TX_FWINFO_8190PCI); - if (is_multicast_ether_addr(pda_addr)) - multi_addr = true; - else if (is_broadcast_ether_addr(pda_addr)) - broad_addr = true; - else - uni_addr = true; - - if (uni_addr) - priv->stats.txbytesunicast += (u8)(skb->len) - sizeof(TX_FWINFO_8190PCI); - - /* fill tx firmware */ - pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; - memset(pTxFwInfo, 0, sizeof(TX_FWINFO_8190PCI)); - pTxFwInfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; - pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)tcb_desc->data_rate); - pTxFwInfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; - pTxFwInfo->Short = QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, tcb_desc); - - /* Aggregation related */ - if (tcb_desc->bAMPDUEnable) { - pTxFwInfo->AllowAggregation = 1; - pTxFwInfo->RxMF = tcb_desc->ampdu_factor; - pTxFwInfo->RxAMD = tcb_desc->ampdu_density; - } else { - pTxFwInfo->AllowAggregation = 0; - pTxFwInfo->RxMF = 0; - pTxFwInfo->RxAMD = 0; - } - - /* Protection mode related */ - pTxFwInfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; - pTxFwInfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; - pTxFwInfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; - pTxFwInfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; - pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); - pTxFwInfo->RtsBandwidth = 0; - pTxFwInfo->RtsSubcarrier = tcb_desc->RTSSC; - pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : (tcb_desc->bRTSUseShortGI? 1 : 0); - - /* Set Bandwidth and sub-channel settings. */ - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { - if (tcb_desc->bPacketBW) { - pTxFwInfo->TxBandwidth = 1; - /* use duplicated mode */ - pTxFwInfo->TxSubCarrier = 0; - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = 0; - } - - spin_lock_irqsave(&priv->irq_th_lock, flags); - ring = &priv->tx_ring[tcb_desc->queue_index]; - if (tcb_desc->queue_index != BEACON_QUEUE) - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - else - idx = 0; - - pdesc = &ring->desc[idx]; - if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d,idx = %d,%x\n", - tcb_desc->queue_index, ring->idx, idx, skb->len); - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - return skb->len; - } - - /* fill tx descriptor */ - memset(pdesc, 0, 12); - - /*DWORD 0*/ - pdesc->LINIP = 0; - pdesc->CmdInit = 1; - pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; /* We must add 8!! */ - pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); - - /*DWORD 1*/ - pdesc->SecCAMID = 0; - pdesc->RATid = tcb_desc->RATRIndex; - - pdesc->NoEnc = 1; - pdesc->SecType = 0x0; - if (tcb_desc->bHwSec) { - switch (priv->ieee80211->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - pdesc->SecType = 0x1; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - pdesc->SecType = 0x2; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - pdesc->SecType = 0x3; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_NA: - pdesc->SecType = 0x0; - pdesc->NoEnc = 1; - break; - } - } - - /* Set Packet ID */ - pdesc->PktId = 0x0; - - pdesc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); - pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); - - pdesc->DISFB = tcb_desc->bTxDisableRateFallBack; - pdesc->USERATE = tcb_desc->bTxUseDriverAssingedRate; - - pdesc->FirstSeg = 1; - pdesc->LastSeg = 1; - pdesc->TxBufferSize = skb->len; - - pdesc->TxBuffAddr = cpu_to_le32(mapping); - __skb_queue_tail(&ring->queue, skb); - pdesc->OWN = 1; - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - priv->ieee80211->dev->trans_start = jiffies; - write_nic_word(priv, TPPoll, 0x01<queue_index); - return 0; -} - -static short rtl8192_alloc_rx_desc_ring(struct r8192_priv *priv) -{ - rx_desc_819x_pci *entry = NULL; - int i; - - priv->rx_ring = pci_alloc_consistent(priv->pdev, - sizeof(*priv->rx_ring) * priv->rxringcount, &priv->rx_ring_dma); - - if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { - RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); - return -ENOMEM; - } - - memset(priv->rx_ring, 0, sizeof(*priv->rx_ring) * priv->rxringcount); - priv->rx_idx = 0; - - for (i = 0; i < priv->rxringcount; i++) { - struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); - dma_addr_t *mapping; - entry = &priv->rx_ring[i]; - if (!skb) - return 0; - priv->rx_buf[i] = skb; - mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - - entry->BufferAddress = cpu_to_le32(*mapping); - - entry->Length = priv->rxbuffersize; - entry->OWN = 1; - } - - entry->EOR = 1; - return 0; -} - -static int rtl8192_alloc_tx_desc_ring(struct r8192_priv *priv, - unsigned int prio, unsigned int entries) -{ - tx_desc_819x_pci *ring; - dma_addr_t dma; - int i; - - ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); - if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); - return -ENOMEM; - } - - memset(ring, 0, sizeof(*ring)*entries); - priv->tx_ring[prio].desc = ring; - priv->tx_ring[prio].dma = dma; - priv->tx_ring[prio].idx = 0; - priv->tx_ring[prio].entries = entries; - skb_queue_head_init(&priv->tx_ring[prio].queue); - - for (i = 0; i < entries; i++) - ring[i].NextDescAddress = - cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); - - return 0; -} - -static short rtl8192_pci_initdescring(struct r8192_priv *priv) -{ - u32 ret; - int i; - - ret = rtl8192_alloc_rx_desc_ring(priv); - if (ret) - return ret; - - /* general process for other queue */ - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - ret = rtl8192_alloc_tx_desc_ring(priv, i, priv->txringcount); - if (ret) - goto err_free_rings; - } - - return 0; - -err_free_rings: - rtl8192_free_rx_ring(priv); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - if (priv->tx_ring[i].desc) - rtl8192_free_tx_ring(priv, i); - return 1; -} - -static void rtl8192_pci_resetdescring(struct r8192_priv *priv) -{ - int i; - - /* force the rx_idx to the first one */ - if(priv->rx_ring) { - rx_desc_819x_pci *entry = NULL; - for (i = 0; i < priv->rxringcount; i++) { - entry = &priv->rx_ring[i]; - entry->OWN = 1; - } - priv->rx_idx = 0; - } - - /* after reset, release previous pending packet, and force the - * tx idx to the first one */ - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if (priv->tx_ring[i].desc) { - struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); - - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - ring->idx = 0; - } - } -} - -static void rtl8192_link_change(struct ieee80211_device *ieee) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - if (ieee->state == IEEE80211_LINKED) - { - rtl8192_net_update(priv); - rtl8192_update_ratr_table(priv); - - //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) - EnableHWSecurityConfig8192(priv); - } - else - { - write_nic_byte(priv, 0x173, 0); - } - - rtl8192_update_msr(priv); - - // 2007/10/16 MH MAC Will update TSF according to all received beacon, so we have - // // To set CBSSID bit when link with any AP or STA. - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { - u32 reg = 0; - reg = read_nic_dword(priv, RCR); - if (priv->ieee80211->state == IEEE80211_LINKED) - priv->ReceiveConfig = reg |= RCR_CBSSID; - else - priv->ReceiveConfig = reg &= ~RCR_CBSSID; - write_nic_dword(priv, RCR, reg); - } -} - - -static const struct ieee80211_qos_parameters def_qos_parameters = { - {3,3,3,3},/* cw_min */ - {7,7,7,7},/* cw_max */ - {2,2,2,2},/* aifs */ - {0,0,0,0},/* flags */ - {0,0,0,0} /* tx_op_limit */ -}; - -static void rtl8192_update_beacon(struct work_struct * work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); - struct ieee80211_device* ieee = priv->ieee80211; - struct ieee80211_network* net = &ieee->current_network; - - if (ieee->pHTInfo->bCurrentHTSupport) - HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; - rtl8192_update_cap(priv, net->capability); -} - -/* -* background support to run QoS activate functionality -*/ -static const int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; -static void rtl8192_qos_activate(struct work_struct * work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); - struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; - u8 mode = priv->ieee80211->current_network.mode; - u8 u1bAIFS; - u32 u4bAcParam; - int i; - - mutex_lock(&priv->mutex); - if(priv->ieee80211->state != IEEE80211_LINKED) - goto success; - RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); - /* It better set slot time at first */ - /* For we just support b/g mode at present, let the slot time at 9/20 selection */ - /* update the ac parameter to related registers */ - for(i = 0; i < QOS_QUEUE_NUM; i++) { - //Mode G/A: slotTimeTimer = 9; Mode B: 20 - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); - write_nic_dword(priv, WDCAPARA_ADD[i], u4bAcParam); - } - -success: - mutex_unlock(&priv->mutex); -} - -static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, - int active_network, - struct ieee80211_network *network) -{ - int ret = 0; - u32 size = sizeof(struct ieee80211_qos_parameters); - - if(priv->ieee80211->state !=IEEE80211_LINKED) - return ret; - - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) - return ret; - - if (network->flags & NETWORK_HAS_QOS_MASK) { - if (active_network && - (network->flags & NETWORK_HAS_QOS_PARAMETERS)) - network->qos_data.active = network->qos_data.supported; - - if ((network->qos_data.active == 1) && (active_network == 1) && - (network->flags & NETWORK_HAS_QOS_PARAMETERS) && - (network->qos_data.old_param_count != - network->qos_data.param_count)) { - network->qos_data.old_param_count = - network->qos_data.param_count; - queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE (COMP_QOS, "QoS parameters change call " - "qos_activate\n"); - } - } else { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &def_qos_parameters, size); - - if ((network->qos_data.active == 1) && (active_network == 1)) { - queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); - } - network->qos_data.active = 0; - network->qos_data.supported = 0; - } - - return 0; -} - -/* handle manage frame frame beacon and probe response */ -static int rtl8192_handle_beacon(struct ieee80211_device *ieee, - struct ieee80211_beacon * beacon, - struct ieee80211_network * network) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - rtl8192_qos_handle_probe_response(priv,1,network); - - queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); - return 0; - -} - -/* - * handling the beaconing responses. if we get different QoS setting - * off the network from the associated setting, adjust the QoS setting - */ -static int rtl8192_qos_association_resp(struct r8192_priv *priv, - struct ieee80211_network *network) -{ - int ret = 0; - unsigned long flags; - u32 size = sizeof(struct ieee80211_qos_parameters); - int set_qos_param = 0; - - if ((priv == NULL) || (network == NULL)) - return ret; - - if (priv->ieee80211->state != IEEE80211_LINKED) - return ret; - - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) - return ret; - - spin_lock_irqsave(&priv->ieee80211->lock, flags); - if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &network->qos_data.parameters, - sizeof(struct ieee80211_qos_parameters)); - priv->ieee80211->current_network.qos_data.active = 1; - set_qos_param = 1; - /* update qos parameter for current network */ - priv->ieee80211->current_network.qos_data.old_param_count = - priv->ieee80211->current_network.qos_data.param_count; - priv->ieee80211->current_network.qos_data.param_count = - network->qos_data.param_count; - - } else { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &def_qos_parameters, size); - priv->ieee80211->current_network.qos_data.active = 0; - priv->ieee80211->current_network.qos_data.supported = 0; - set_qos_param = 1; - } - - spin_unlock_irqrestore(&priv->ieee80211->lock, flags); - - RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __FUNCTION__, - network->flags, priv->ieee80211->current_network.qos_data.active); - if (set_qos_param == 1) - queue_work(priv->priv_wq, &priv->qos_activate); - - return ret; -} - - -static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee, - struct ieee80211_assoc_response_frame *resp, - struct ieee80211_network *network) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - rtl8192_qos_association_resp(priv, network); - return 0; -} - - -/* updateRATRTabel for MCS only. Basic rate is not implemented. */ -static void rtl8192_update_ratr_table(struct r8192_priv* priv) -{ - struct ieee80211_device* ieee = priv->ieee80211; - u8* pMcsRate = ieee->dot11HTOperationalRateSet; - u32 ratr_value = 0; - u8 rate_index = 0; - - rtl8192_config_rate(priv, (u16*)(&ratr_value)); - ratr_value |= (*(u16*)(pMcsRate)) << 12; - - switch (ieee->mode) - { - case IEEE_A: - ratr_value &= 0x00000FF0; - break; - case IEEE_B: - ratr_value &= 0x0000000F; - break; - case IEEE_G: - ratr_value &= 0x00000FF7; - break; - case IEEE_N_24G: - case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC - ratr_value &= 0x0007F007; - else{ - if (priv->rf_type == RF_1T2R) - ratr_value &= 0x000FF007; - else - ratr_value &= 0x0F81F007; - } - break; - default: - break; - } - ratr_value &= 0x0FFFFFFF; - if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ - ratr_value |= 0x80000000; - }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ - ratr_value |= 0x80000000; - } - write_nic_dword(priv, RATR0+rate_index*4, ratr_value); - write_nic_byte(priv, UFWP, 1); -} - -static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee) -{ - return !(ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))); -} - -static void rtl8192_refresh_supportrate(struct r8192_priv* priv) -{ - struct ieee80211_device* ieee = priv->ieee80211; - //we donot consider set support rate for ABG mode, only HT MCS rate is set here. - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) - { - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); - } - else - memset(ieee->Regdot11HTOperationalRateSet, 0, 16); -} - -static u8 rtl8192_getSupportedWireleeMode(void) -{ - return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B); -} - -static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - u8 bSupportMode = rtl8192_getSupportedWireleeMode(); - - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0)) - { - if(bSupportMode & WIRELESS_MODE_N_24G) - { - wireless_mode = WIRELESS_MODE_N_24G; - } - else if(bSupportMode & WIRELESS_MODE_N_5G) - { - wireless_mode = WIRELESS_MODE_N_5G; - } - else if((bSupportMode & WIRELESS_MODE_A)) - { - wireless_mode = WIRELESS_MODE_A; - } - else if((bSupportMode & WIRELESS_MODE_G)) - { - wireless_mode = WIRELESS_MODE_G; - } - else if((bSupportMode & WIRELESS_MODE_B)) - { - wireless_mode = WIRELESS_MODE_B; - } - else{ - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode); - wireless_mode = WIRELESS_MODE_B; - } - } - priv->ieee80211->mode = wireless_mode; - - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) - priv->ieee80211->pHTInfo->bEnableHT = 1; - else - priv->ieee80211->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); - rtl8192_refresh_supportrate(priv); -} - -static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee) -{ - return ieee->bHalfWirelessN24GMode; -} - -static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee) -{ - int i=0; - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - for (i=0; i<=MGNT_QUEUE; i++) - { - if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) - continue; - if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ - printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); - return 0; - } - } - return 1; -} - -static void rtl8192_hw_sleep_down(struct r8192_priv *priv) -{ - MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS); -} - -static void rtl8192_hw_wakeup(struct ieee80211_device *ieee) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS); -} - -static void rtl8192_hw_wakeup_wq (struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); - - rtl8192_hw_wakeup(ieee); -} - -#define MIN_SLEEP_TIME 50 -#define MAX_SLEEP_TIME 10000 -static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - u32 tmp; - u32 rb = jiffies; - - // Writing HW register with 0 equals to disable - // the timer, that is not really what we want - // - tl -= MSECS(8+16+7); - - // If the interval in witch we are requested to sleep is too - // short then give up and remain awake - // when we sleep after send null frame, the timer will be too short to sleep. - // - if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); - return; - } - - if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); - return; - } - - tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work(priv->ieee80211->wq, - &priv->ieee80211->hw_wakeup_wq,tmp); - - rtl8192_hw_sleep_down(priv); -} - -static void rtl8192_init_priv_variable(struct r8192_priv *priv) -{ - u8 i; - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - // Default Halt the NIC if RF is OFF. - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_CLK_REQ; - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; - pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; - pPSC->bLeisurePs = true; - priv->ieee80211->RegMaxLPSAwakeIntvl = 5; - priv->bHwRadioOff = false; - - priv->being_init_adapter = false; - priv->txringcount = 64;//32; - priv->rxbuffersize = 9100;//2048;//1024; - priv->rxringcount = MAX_RX_COUNT;//64; - priv->chan = 1; //set to channel 1 - priv->RegWirelessMode = WIRELESS_MODE_AUTO; - priv->RegChannelPlan = 0xf; - priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->ieee_up=0; - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->promisc = (priv->ieee80211->dev->flags & IFF_PROMISC) ? 1:0; - priv->bcck_in_ch14 = false; - priv->CCKPresentAttentuation = 0; - priv->rfa_txpowertrackingindex = 0; - priv->rfc_txpowertrackingindex = 0; - priv->CckPwEnl = 6; - //added by amy for silent reset - priv->ResetProgress = RESET_TYPE_NORESET; - priv->bForcedSilentReset = 0; - priv->bDisableNormalResetCheck = false; - priv->force_reset = false; - //added by amy for power save - priv->RfOffReason = 0; - priv->bHwRfOffAction = 0; - priv->PowerSaveControl.bInactivePs = true; - priv->PowerSaveControl.bIPSModeBackup = false; - - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;/* | - IEEE_SOFTMAC_BEACONS;*///added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8192_start_beacon; - priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon; - priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; - priv->ieee80211->set_chan = rtl8192_set_chan; - priv->ieee80211->link_change = rtl8192_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume; - priv->ieee80211->init_wmmparam_flag = 0; - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc; - priv->ieee80211->tx_headroom = sizeof(TX_FWINFO_8190PCI); - priv->ieee80211->qos_support = 1; - priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; - priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; - priv->ieee80211->handle_beacon = rtl8192_handle_beacon; - - priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup; - priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep; - priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty; - priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8190Pci; - priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; - priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xPci; - - priv->ieee80211->InitialGainHandler = InitialGain819xPci; - -#ifdef ENABLE_IPS - priv->ieee80211->ieee80211_ips_leave_wq = ieee80211_ips_leave_wq; - priv->ieee80211->ieee80211_ips_leave = ieee80211_ips_leave; -#endif -#ifdef ENABLE_LPS - priv->ieee80211->LeisurePSLeave = LeisurePSLeave; -#endif - - priv->ieee80211->SetHwRegHandler = rtl8192e_SetHwReg; - priv->ieee80211->rtllib_ap_sec_type = rtl8192e_ap_sec_type; - - priv->ShortRetryLimit = 0x30; - priv->LongRetryLimit = 0x30; - - priv->ReceiveConfig = RCR_ADD3 | - RCR_AMF | RCR_ADF | //accept management/data - RCR_AICV | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. - RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - RCR_AAP | ((u32)7<pFirmware = vzalloc(sizeof(rt_firmware)); - - /* rx related queue */ - skb_queue_head_init(&priv->skb_queue); - - /* Tx related queue */ - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]); - } - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]); - } - priv->rf_set_chan = rtl8192_phy_SwChnl; -} - -static void rtl8192_init_priv_lock(struct r8192_priv* priv) -{ - spin_lock_init(&priv->irq_th_lock); - spin_lock_init(&priv->rf_ps_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_sem,1); - mutex_init(&priv->mutex); -} - -/* init tasklet and wait_queue here */ -#define DRV_NAME "wlan0" -static void rtl8192_init_priv_task(struct r8192_priv *priv) -{ - priv->priv_wq = create_workqueue(DRV_NAME); - -#ifdef ENABLE_IPS - INIT_WORK(&priv->ieee80211->ips_leave_wq, IPSLeave_wq); -#endif - - INIT_WORK(&priv->reset_wq, rtl8192_restart); - INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); - INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); - INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); - INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); - INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); - INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8192_hw_wakeup_wq); - - tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, - (unsigned long) priv); - tasklet_init(&priv->irq_tx_tasklet, rtl8192_irq_tx_tasklet, - (unsigned long) priv); - tasklet_init(&priv->irq_prepare_beacon_tasklet, rtl8192_prepare_beacon, - (unsigned long) priv); -} - -static void rtl8192_get_eeprom_size(struct r8192_priv *priv) -{ - u16 curCR = 0; - RT_TRACE(COMP_INIT, "===========>%s()\n", __FUNCTION__); - curCR = read_nic_dword(priv, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); - //whether need I consider BIT5? - priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EPROM_93c56 : EPROM_93c46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype); -} - -/* - * Adapter->EEPROMAddressSize should be set before this function call. - * EEPROM address size can be got through GetEEPROMSize8185() - */ -static void rtl8192_read_eeprom_info(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - u8 tempval; - u8 ICVer8192, ICVer8256; - u16 i,usValue, IC_Version; - u16 EEPROMId; - u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; - RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); - - - // TODO: I don't know if we need to apply EF function to EEPROM read function - - //2 Read EEPROM ID to make sure autoload is success - EEPROMId = eprom_read(priv, 0); - if( EEPROMId != RTL8190_EEPROM_ID ) - { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); - priv->AutoloadFailFlag=true; - } - else - { - priv->AutoloadFailFlag=false; - } - - // - // Assign Chip Version ID - // - // Read IC Version && Channel Plan - if(!priv->AutoloadFailFlag) - { - // VID, PID - priv->eeprom_vid = eprom_read(priv, (EEPROM_VID >> 1)); - priv->eeprom_did = eprom_read(priv, (EEPROM_DID >> 1)); - - usValue = eprom_read(priv, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; - priv->eeprom_CustomerID = (u8)( usValue & 0xff); - usValue = eprom_read(priv, (EEPROM_ICVersion_ChannelPlan>>1)); - priv->eeprom_ChannelPlan = usValue&0xff; - IC_Version = ((usValue&0xff00)>>8); - - ICVer8192 = (IC_Version&0xf); //bit0~3; 1:A cut, 2:B cut, 3:C cut... - ICVer8256 = ((IC_Version&0xf0)>>4);//bit4~6, bit7 reserved for other RF chip; 1:A cut, 2:B cut, 3:C cut... - RT_TRACE(COMP_INIT, "ICVer8192 = 0x%x\n", ICVer8192); - RT_TRACE(COMP_INIT, "ICVer8256 = 0x%x\n", ICVer8256); - if(ICVer8192 == 0x2) //B-cut - { - if(ICVer8256 == 0x5) //E-cut - priv->card_8192_version= VERSION_8190_BE; - } - - switch(priv->card_8192_version) - { - case VERSION_8190_BD: - case VERSION_8190_BE: - break; - default: - priv->card_8192_version = VERSION_8190_BD; - break; - } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); - } - else - { - priv->card_8192_version = VERSION_8190_BD; - priv->eeprom_vid = 0; - priv->eeprom_did = 0; - priv->eeprom_CustomerID = 0; - priv->eeprom_ChannelPlan = 0; - RT_TRACE(COMP_INIT, "IC Version = 0x%x\n", 0xff); - } - - RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); - RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); - - //2 Read Permanent MAC address - if(!priv->AutoloadFailFlag) - { - for(i = 0; i < 6; i += 2) - { - usValue = eprom_read(priv, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); - *(u16*)(&dev->dev_addr[i]) = usValue; - } - } else { - // when auto load failed, the last address byte set to be a random one. - // added by david woo.2007/11/7 - memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); - } - - RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", dev->dev_addr); - - //2 TX Power Check EEPROM Fail or not - if(priv->card_8192_version > VERSION_8190_BD) { - priv->bTXPowerDataReadFromEEPORM = true; - } else { - priv->bTXPowerDataReadFromEEPORM = false; - } - - // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R - priv->rf_type = RTL819X_DEFAULT_RF_TYPE; - - if(priv->card_8192_version > VERSION_8190_BD) - { - // Read RF-indication and Tx Power gain index diff of legacy to HT OFDM rate. - if(!priv->AutoloadFailFlag) - { - tempval = (eprom_read(priv, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; - priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; // bit[3:0] - - if (tempval&0x80) //RF-indication, bit[7] - priv->rf_type = RF_1T2R; - else - priv->rf_type = RF_2T4R; - } - else - { - priv->EEPROMLegacyHTTxPowerDiff = EEPROM_Default_LegacyHTTxPowerDiff; - } - RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", - priv->EEPROMLegacyHTTxPowerDiff); - - // Read ThermalMeter from EEPROM - if(!priv->AutoloadFailFlag) - { - priv->EEPROMThermalMeter = (u8)(((eprom_read(priv, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); - } - else - { - priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - } - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); - //vivi, for tx power track - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; - - if(priv->epromtype == EPROM_93c46) - { - // Read antenna tx power offset of B/C/D to A and CrystalCap from EEPROM - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (EEPROM_TxPwDiff_CrystalCap>>1)); - priv->EEPROMAntPwDiff = (usValue&0x0fff); - priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); - - // - // Get per-channel Tx Power Level - // - for(i=0; i<14; i+=2) - { - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); - } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); - } - for(i=0; i<14; i+=2) - { - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); - } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); - } - } - - // - // Update HAL variables. - // - if(priv->epromtype == EPROM_93c46) - { - for(i=0; i<14; i++) - { - priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; - } - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - // Antenna B gain offset to antenna A, bit0~3 - priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); - // Antenna C gain offset to antenna A, bit4~7 - priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); - // Antenna D gain offset to antenna A, bit8~11 - priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); - // CrystalCap, bit12~15 - priv->CrystalCap = priv->EEPROMCrystalCap; - // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - else if(priv->epromtype == EPROM_93c56) - { - for(i=0; i<3; i++) // channel 1~3 use the same Tx Power Level. - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; - } - for(i=3; i<9; i++) // channel 4~9 use the same Tx Power Level - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; - } - for(i=9; i<14; i++) // channel 10~14 use the same Tx Power Level - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; - } - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = 0; - priv->AntennaTxPwDiff[1] = 0; - priv->AntennaTxPwDiff[2] = 0; - priv->CrystalCap = priv->EEPROMCrystalCap; - // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - } - - if(priv->rf_type == RF_1T2R) - { - RT_TRACE(COMP_INIT, "1T2R config\n"); - } - else if (priv->rf_type == RF_2T4R) - { - RT_TRACE(COMP_INIT, "2T4R config\n"); - } - - // 2008/01/16 MH We can only know RF type in the function. So we have to init - // DIG RATR table again. - init_rate_adaptive(priv); - - //1 Make a copy for following variables and we can change them if we want - - if(priv->RegChannelPlan == 0xf) - { - priv->ChannelPlan = priv->eeprom_ChannelPlan; - } - else - { - priv->ChannelPlan = priv->RegChannelPlan; - } - - // - // Used PID and DID to Set CustomerID - // - if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) - { - priv->CustomerID = RT_CID_DLINK; - } - - switch(priv->eeprom_CustomerID) - { - case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; - break; - case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; - break; - case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; - break; - case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; - break; - case EEPROM_CID_TOSHIBA: // Merge by Jacken, 2008/01/31 - priv->CustomerID = RT_CID_TOSHIBA; - if(priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; - else - priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); - break; - case EEPROM_CID_Nettronix: - priv->CustomerID = RT_CID_Nettronix; - break; - case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; - break; - case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; - break; - - case EEPROM_CID_WHQL: - break; - default: - // value from RegCustomerID - break; - } - - //Avoid the channel plan array overflow, by Bruce, 2007-08-27. - if(priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) - priv->ChannelPlan = 0; //FCC - - if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) - priv->ieee80211->bSupportRemoteWakeUp = true; - else - priv->ieee80211->bSupportRemoteWakeUp = false; - - - RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); - RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); -} - - -static short rtl8192_get_channel_map(struct r8192_priv *priv) -{ -#ifdef ENABLE_DOT11D - if(priv->ChannelPlan> COUNTRY_CODE_GLOBAL_DOMAIN){ - printk("rtl8180_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan= 0; - } - RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); - - rtl819x_set_channel_map(priv->ChannelPlan, priv); -#else - int ch,i; - //Set Default Channel Plan - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - priv->ChannelPlan= 0;//hikaru - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } -#endif - return 0; -} - -static short rtl8192_init(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - - memset(&(priv->stats),0,sizeof(struct Stats)); - rtl8192_init_priv_variable(priv); - rtl8192_init_priv_lock(priv); - rtl8192_init_priv_task(priv); - rtl8192_get_eeprom_size(priv); - rtl8192_read_eeprom_info(priv); - rtl8192_get_channel_map(priv); - init_hal_dm(priv); - init_timer(&priv->watch_dog_timer); - priv->watch_dog_timer.data = (unsigned long)priv; - priv->watch_dog_timer.function = watch_dog_timer_callback; - if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) { - printk("Error allocating IRQ %d",dev->irq); - return -1; - }else{ - priv->irq=dev->irq; - printk("IRQ %d",dev->irq); - } - if (rtl8192_pci_initdescring(priv) != 0){ - printk("Endopoints initialization failed"); - return -1; - } - - return 0; -} - -/* - * Actually only set RRSR, RATR and BW_OPMODE registers - * not to do all the hw config as its name says - * This part need to modified according to the rate set we filtered - */ -static void rtl8192_hwconfig(struct r8192_priv *priv) -{ - u32 regRATR = 0, regRRSR = 0; - u8 regBwOpMode = 0, regTmp = 0; - -// Set RRSR, RATR, and BW_OPMODE registers - // - switch (priv->ieee80211->mode) - { - case WIRELESS_MODE_B: - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK; - regRRSR = RATE_ALL_CCK; - break; - case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; - regRATR = RATE_ALL_OFDM_AG; - regRRSR = RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_G: - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_AUTO: - case WIRELESS_MODE_N_24G: - // It support CCK rate by default. - // CCK rate will be filtered out only when associated AP does not support it. - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_N_5G: - regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_OFDM_AG; - break; - } - - write_nic_byte(priv, BW_OPMODE, regBwOpMode); - { - u32 ratr_value = 0; - ratr_value = regRATR; - if (priv->rf_type == RF_1T2R) - { - ratr_value &= ~(RATE_ALL_OFDM_2SS); - } - write_nic_dword(priv, RATR0, ratr_value); - write_nic_byte(priv, UFWP, 1); - } - regTmp = read_nic_byte(priv, 0x313); - regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); - write_nic_dword(priv, RRSR, regRRSR); - - // - // Set Retry Limit here - // - write_nic_word(priv, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | - priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - // Set Contention Window here - - // Set Tx AGC - - // Set Tx Antenna including Feedback control - - // Set Auto Rate fallback control - - -} - - -static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - u32 ulRegRead; - RT_STATUS rtStatus = RT_STATUS_SUCCESS; - u8 tmpvalue; - u8 ICVersion,SwitchingRegulatorOutput; - bool bfirmwareok = true; - u32 tmpRegA, tmpRegC, TempCCk; - int i =0; - - RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__); - priv->being_init_adapter = true; - rtl8192_pci_resetdescring(priv); - // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W. - priv->Rf_Mode = RF_OP_By_SW_3wire; - - //dPLL on - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - write_nic_byte(priv, ANAPAR, 0x37); - // Accordign to designer's explain, LBUS active will never > 10ms. We delay 10ms - // Joseph increae the time to prevent firmware download fail - mdelay(500); - } - - //PlatformSleepUs(10000); - // For any kind of InitializeAdapter process, we shall use system now!! - priv->pFirmware->firmware_status = FW_STATUS_0_INIT; - - // - //3 //Config CPUReset Register - //3// - //3 Firmware Reset Or Not - ulRegRead = read_nic_dword(priv, CPU_GEN); - if(priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - { //called from MPInitialized. do nothing - ulRegRead |= CPU_GEN_SYSTEM_RESET; - }else if(priv->pFirmware->firmware_status == FW_STATUS_5_READY) - ulRegRead |= CPU_GEN_FIRMWARE_RESET; // Called from MPReset - else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status); - - write_nic_dword(priv, CPU_GEN, ulRegRead); - - //3// - //3 //Fix the issue of E-cut high temperature issue - //3// - // TODO: E cut only - ICVersion = read_nic_byte(priv, IC_VERRSION); - if(ICVersion >= 0x4) //E-cut only - { - // HW SD suggest that we should not wirte this register too often, so driver - // should readback this register. This register will be modified only when - // power on reset - SwitchingRegulatorOutput = read_nic_byte(priv, SWREGULATOR); - if(SwitchingRegulatorOutput != 0xb8) - { - write_nic_byte(priv, SWREGULATOR, 0xa8); - mdelay(1); - write_nic_byte(priv, SWREGULATOR, 0xb8); - } - } - - //3// - //3// Initialize BB before MAC - //3// - RT_TRACE(COMP_INIT, "BB Config Start!\n"); - rtStatus = rtl8192_BBConfig(priv); - if(rtStatus != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR, "BB Config failed\n"); - return rtStatus; - } - RT_TRACE(COMP_INIT,"BB Config Finished!\n"); - - //3//Set Loopback mode or Normal mode - //3// - //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings - // because setting of System_Reset bit reset MAC to default transmission mode. - //Loopback mode or not - priv->LoopbackMode = RTL819X_NO_LOOPBACK; - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - ulRegRead = read_nic_dword(priv, CPU_GEN); - if(priv->LoopbackMode == RTL819X_NO_LOOPBACK) - { - ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); - } - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) - { - ulRegRead |= CPU_CCK_LOOPBACK; - } - else - { - RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); - } - - //2008.06.03, for WOL - //ulRegRead &= (~(CPU_GEN_GPIO_UART)); - write_nic_dword(priv, CPU_GEN, ulRegRead); - - // 2006.11.29. After reset cpu, we sholud wait for a second, otherwise, it may fail to write registers. Emily - udelay(500); - } - //3Set Hardware(Do nothing now) - rtl8192_hwconfig(priv); - //2======================================================= - // Common Setting for all of the FPGA platform. (part 1) - //2======================================================= - // If there is changes, please make sure it applies to all of the FPGA version - //3 Turn on Tx/Rx - write_nic_byte(priv, CMDR, CR_RE|CR_TE); - - //2Set Tx dma burst - write_nic_byte(priv, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); - write_nic_word(priv, MAC4, ((u16*)(dev->dev_addr + 4))[0]); - //set RCR - write_nic_dword(priv, RCR, priv->ReceiveConfig); - - //3 Initialize Number of Reserved Pages in Firmware Queue - write_nic_dword(priv, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) - rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode); - //----------------------------------------------------------------------------- - // Set up security related. 070106, by rcnjko: - // 1. Clear all H/W keys. - // 2. Enable H/W encryption/decryption. - //----------------------------------------------------------------------------- - CamResetAllEntry(priv); - { - u8 SECR_value = 0x0; - SECR_value |= SCR_TxEncEnable; - SECR_value |= SCR_RxDecEnable; - SECR_value |= SCR_NoSKMC; - write_nic_byte(priv, SECR, SECR_value); - } - //3Beacon related - write_nic_word(priv, ATIMWND, 2); - write_nic_word(priv, BCN_INTERVAL, 100); - for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { - rtl8192_phy_getTxPower(priv); - rtl8192_phy_setTxPower(priv, priv->chan); - } - - //if D or C cut - tmpvalue = read_nic_byte(priv, IC_VERRSION); - priv->IC_Cut = tmpvalue; - RT_TRACE(COMP_INIT, "priv->IC_Cut = 0x%x\n", priv->IC_Cut); - if(priv->IC_Cut >= IC_VersionCut_D) - { - //pHalData->bDcut = TRUE; - if(priv->IC_Cut == IC_VersionCut_D) - RT_TRACE(COMP_INIT, "D-cut\n"); - if(priv->IC_Cut == IC_VersionCut_E) - { - RT_TRACE(COMP_INIT, "E-cut\n"); - // HW SD suggest that we should not wirte this register too often, so driver - // should readback this register. This register will be modified only when - // power on reset - } - } - else - { - //pHalData->bDcut = FALSE; - RT_TRACE(COMP_INIT, "Before C-cut\n"); - } - - //Firmware download - RT_TRACE(COMP_INIT, "Load Firmware!\n"); - bfirmwareok = init_firmware(priv); - if(bfirmwareok != true) { - rtStatus = RT_STATUS_FAILURE; - return rtStatus; - } - RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); - - //RF config - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - RT_TRACE(COMP_INIT, "RF Config Started!\n"); - rtStatus = rtl8192_phy_RFConfig(priv); - if(rtStatus != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR, "RF Config failed\n"); - return rtStatus; - } - RT_TRACE(COMP_INIT, "RF Config Finished!\n"); - } - rtl8192_phy_updateInitGain(priv); - - /*---- Set CCK and OFDM Block "ON"----*/ - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn, 0x1); - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bOFDMEn, 0x1); - - //Enable Led - write_nic_byte(priv, 0x87, 0x0); - - //2======================================================= - // RF Power Save - //2======================================================= -#ifdef ENABLE_IPS - -{ - if(priv->RfOffReason > RF_CHANGE_BY_PS) - { // H/W or S/W RF OFF before sleep. - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__,priv->RfOffReason); - MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); - } - else if(priv->RfOffReason >= RF_CHANGE_BY_IPS) - { // H/W or S/W RF OFF before sleep. - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__, priv->RfOffReason); - MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); - } - else - { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__FUNCTION__); - priv->eRFPowerState = eRfOn; - priv->RfOffReason = 0; - } -} -#endif - // We can force firmware to do RF-R/W - if(priv->ieee80211->FwRWRF) - priv->Rf_Mode = RF_OP_By_FW; - else - priv->Rf_Mode = RF_OP_By_SW_3wire; - - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - dm_initialize_txpower_tracking(priv); - - if(priv->IC_Cut >= IC_VersionCut_D) - { - tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); - tmpRegC = rtl8192_QueryBBReg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord); - for(i = 0; itxbbgain_table[i].txbbgain_value) - { - priv->rfa_txpowertrackingindex= (u8)i; - priv->rfa_txpowertrackingindex_real= (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; - break; - } - } - - TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); - - for(i=0 ; icck_txbbgain_table[i].ccktxbb_valuearray[0]) - { - priv->CCKPresentAttentuation_20Mdefault =(u8) i; - break; - } - } - priv->CCKPresentAttentuation_40Mdefault = 0; - priv->CCKPresentAttentuation_difference = 0; - priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); - priv->btxpower_tracking = FALSE;//TEMPLY DISABLE - } - } - - rtl8192_irq_enable(priv); - priv->being_init_adapter = false; - return rtStatus; - -} - -static void rtl8192_prepare_beacon(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - struct sk_buff *skb; - cb_desc *tcb_desc; - - skb = ieee80211_get_beacon(priv->ieee80211); - tcb_desc = (cb_desc *)(skb->cb + 8); - /* prepare misc info for the beacon xmit */ - tcb_desc->queue_index = BEACON_QUEUE; - /* IBSS does not support HT yet, use 1M defaultly */ - tcb_desc->data_rate = 2; - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - - skb_push(skb, priv->ieee80211->tx_headroom); - if(skb){ - rtl8192_tx(priv, skb); - } -} - - -/* - * configure registers for beacon tx and enables it via - * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might - * be used to stop beacon transmission - */ -static void rtl8192_start_beacon(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - struct ieee80211_network *net = &priv->ieee80211->current_network; - u16 BcnTimeCfg = 0; - u16 BcnCW = 6; - u16 BcnIFS = 0xf; - - DMESG("Enabling beacon TX"); - rtl8192_irq_disable(priv); - //rtl8192_beacon_tx_enable(dev); - - /* ATIM window */ - write_nic_word(priv, ATIMWND, 2); - - /* Beacon interval (in unit of TU) */ - write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); - - /* - * DrvErlyInt (in unit of TU). - * (Time to send interrupt to notify driver to c - * hange beacon content) - * */ - write_nic_word(priv, BCN_DRV_EARLY_INT, 10); - - /* - * BcnDMATIM(in unit of us). - * Indicates the time before TBTT to perform beacon queue DMA - * */ - write_nic_word(priv, BCN_DMATIME, 256); - - /* - * Force beacon frame transmission even after receiving - * beacon frame from other ad hoc STA - * */ - write_nic_byte(priv, BCN_ERR_THRESH, 100); - - /* Set CW and IFS */ - BcnTimeCfg |= BcnCW<RxCounter); - // If rssi is small, we should check rx for long time because of bad rx. - // or maybe it will continuous silent reset every 2 seconds. - priv->rx_chk_cnt++; - if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) - { - priv->rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ - } - else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && - ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) || - (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) ) - - { - if(priv->rx_chk_cnt < 2) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbCurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbundecorated_smoothed_pwdb >= VeryLowRSSI) - { - if(priv->rx_chk_cnt < 4) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - else - { - if(priv->rx_chk_cnt < 8) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - if(priv->RxCounter==RegRxCounter) - bStuck = TRUE; - - priv->RxCounter = RegRxCounter; - - return bStuck; -} - -static RESET_TYPE RxCheckStuck(struct r8192_priv *priv) -{ - - if(HalRxCheckStuck8190Pci(priv)) - { - RT_TRACE(COMP_RESET, "RxStuck Condition\n"); - return RESET_TYPE_SILENT; - } - - return RESET_TYPE_NORESET; -} - -static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv) -{ - RESET_TYPE RxResetType = RESET_TYPE_NORESET; - RT_RF_POWER_STATE rfState; - - rfState = priv->eRFPowerState; - - if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { - /* - * If driver is in the status of firmware download failure, - * driver skips RF initialization and RF is in turned off state. - * Driver should check whether Rx stuck and do silent reset. And - * if driver is in firmware download failure status, driver - * should initialize RF in the following silent reset procedure - * - * Driver should not check RX stuck in IBSS mode because it is - * required to set Check BSSID in order to send beacon, however, - * if check BSSID is set, STA cannot hear any packet a all. - */ - RxResetType = RxCheckStuck(priv); - } - - RT_TRACE(COMP_RESET, "%s(): RxResetType is %d\n", __FUNCTION__, RxResetType); - - return RxResetType; -} - -#ifdef ENABLE_IPS -static void InactivePsWorkItemCallback(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() --------->\n"); - // - // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem - // is really scheduled. - // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the - // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing - // blocks the IPS procedure of switching RF. - // By Bruce, 2007-12-25. - // - pPSC->bSwRfProcessing = TRUE; - - RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", - pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); - - - MgntActSet_RF_State(priv, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); - - // - // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20. - // - pPSC->bSwRfProcessing = FALSE; - RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <---------\n"); -} - -#ifdef ENABLE_LPS -/* Change current and default preamble mode. */ -bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode) -{ - - // Currently, we do not change power save mode on IBSS mode. - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { - return false; - } - - // - // If we make HW to fill up the PwrMgt bit for us, - // some AP will not response to our mgnt frames with PwrMgt bit set, - // e.g. cannot associate the AP. - // So I commented out it. 2005.02.16, by rcnjko. - // -// // Change device's power save mode. -// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); - - // Update power save mode configured. - //RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__FUNCTION__,rtPsMode); - if(!priv->ps_force) { - priv->ieee80211->ps = rtPsMode; - } - - // Awake immediately - if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED) - { - // Notify the AP we awke. - rtl8192_hw_wakeup(priv->ieee80211); - priv->ieee80211->sta_sleep = 0; - - spin_lock(&priv->ieee80211->mgmt_tx_lock); - printk("LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); - ieee80211_sta_ps_send_null_frame(priv->ieee80211, 0); - spin_unlock(&priv->ieee80211->mgmt_tx_lock); - } - - return true; -} - -/* Enter the leisure power save mode. */ -void LeisurePSEnter(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) && - (priv->ieee80211->state == IEEE80211_LINKED)) || - (priv->ieee80211->iw_mode == IW_MODE_ADHOC) || - (priv->ieee80211->iw_mode == IW_MODE_MASTER)) - return; - - if (pPSC->bLeisurePs) - { - // Idle for a while if we connect to AP a while ago. - if(pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) // 4 Sec - { - - if(priv->ieee80211->ps == IEEE80211_PS_DISABLED) - { - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); - - } - } - else - pPSC->LpsIdleCount++; - } -} - - -/* Leave leisure power save mode. */ -void LeisurePSLeave(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - if (pPSC->bLeisurePs) - { - if(priv->ieee80211->ps != IEEE80211_PS_DISABLED) - { - // move to lps_wakecomplete() - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); - - } - } -} -#endif - - -/* Enter the inactive power save mode. RF will be off */ -void IPSEnter(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - RT_RF_POWER_STATE rtState; - - if (pPSC->bInactivePs) - { - rtState = priv->eRFPowerState; - // - // Added by Bruce, 2007-12-25. - // Do not enter IPS in the following conditions: - // (1) RF is already OFF or Sleep - // (2) bSwRfProcessing (indicates the IPS is still under going) - // (3) Connectted (only disconnected can trigger IPS) - // (4) IBSS (send Beacon) - // (5) AP mode (send Beacon) - // - if (rtState == eRfOn && !pPSC->bSwRfProcessing - && (priv->ieee80211->state != IEEE80211_LINKED) ) - { - RT_TRACE(COMP_RF,"IPSEnter(): Turn off RF.\n"); - pPSC->eInactivePowerState = eRfOff; -// queue_work(priv->priv_wq,&(pPSC->InactivePsWorkItem)); - InactivePsWorkItemCallback(priv); - } - } -} - -// -// Description: -// Leave the inactive power save mode, RF will be on. -// 2007.08.17, by shien chang. -// -void IPSLeave(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - RT_RF_POWER_STATE rtState; - - if (pPSC->bInactivePs) - { - rtState = priv->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_POWER, "IPSLeave(): Turn on RF.\n"); - pPSC->eInactivePowerState = eRfOn; - InactivePsWorkItemCallback(priv); - } - } -} - -void IPSLeave_wq(struct work_struct *work) -{ - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq); - struct net_device *dev = ieee->dev; - - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -} - -void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - RT_RF_POWER_STATE rtState; - rtState = priv->eRFPowerState; - - if (priv->PowerSaveControl.bInactivePs){ - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - return; - } - else{ - printk("=========>%s(): IPSLeave\n",__FUNCTION__); - queue_work(priv->ieee80211->wq,&priv->ieee80211->ips_leave_wq); - } - } - } -} -//added by amy 090331 end -void ieee80211_ips_leave(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - down(&ieee80211->ips_sem); - IPSLeave(priv); - up(&ieee80211->ips_sem); -} -#endif - -static void rtl819x_update_rxcounts( - struct r8192_priv *priv, - u32* TotalRxBcnNum, - u32* TotalRxDataNum -) -{ - u16 SlotIndex; - u8 i; - - *TotalRxBcnNum = 0; - *TotalRxDataNum = 0; - - SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); - priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; - priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; - for( i=0; iieee80211->LinkDetectInfo.SlotNum; i++ ){ - *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; - *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; - } -} - - -static void rtl819x_watchdog_wqcallback(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); - struct ieee80211_device* ieee = priv->ieee80211; - RESET_TYPE ResetType = RESET_TYPE_NORESET; - bool bBusyTraffic = false; - bool bEnterPS = false; - - if ((!priv->up) || priv->bHwRadioOff) - return; - - if(!priv->up) - return; - hal_dm_watchdog(priv); -#ifdef ENABLE_IPS - if(ieee->actscanning == false){ - if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) && - (priv->eRFPowerState == eRfOn) && !ieee->is_set_key && - (!ieee->proto_stoppping) && !ieee->wx_set_enc){ - if (priv->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){ - IPSEnter(priv); - } - } - } -#endif - {//to get busy traffic condition - if(ieee->state == IEEE80211_LINKED) - { - if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { - bBusyTraffic = true; - } - -#ifdef ENABLE_LPS - //added by amy for Leisure PS - if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { - bEnterPS= false; - } - else - { - bEnterPS= true; - } - - // LeisurePS only work in infra mode. - if(bEnterPS) - { - LeisurePSEnter(priv->ieee80211); - } - else - { - LeisurePSLeave(priv->ieee80211); - } -#endif - - } - else - { -#ifdef ENABLE_LPS - LeisurePSLeave(priv->ieee80211); -#endif - } - - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - } - - - //added by amy for AP roaming - if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - if((TotalRxBcnNum+TotalRxDataNum) == 0) - { - if (priv->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); - printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); - // Dot11d_Reset(dev); - ieee->state = IEEE80211_ASSOCIATING; - notify_wx_assoc_event(priv->ieee80211); - RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); - ieee->is_roaming = true; - ieee->is_set_key = false; - ieee->link_change(ieee); - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } - } - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - //check if reset the driver - if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && - priv->watchdog_last_time != 1) - { - ResetType = rtl819x_check_reset(priv); - priv->watchdog_check_reset_cnt = 3; - } - if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) - { - priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__FUNCTION__); - return; - } - /* disable silent reset temply 2008.9.11*/ - - if( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) // This is control by OID set in Pomelo - { - priv->watchdog_last_time = 1; - } - else - priv->watchdog_last_time = 0; - - priv->force_reset = false; - priv->bForcedSilentReset = false; - priv->bResetInProgress = false; - RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); - -} - -void watch_dog_timer_callback(unsigned long data) -{ - struct r8192_priv *priv = (struct r8192_priv *) data; - queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); - -} - -static int _rtl8192_up(struct r8192_priv *priv) -{ - RT_STATUS init_status = RT_STATUS_SUCCESS; - struct net_device *dev = priv->ieee80211->dev; - - priv->up=1; - priv->ieee80211->ieee_up=1; - priv->bdisable_nic = false; //YJ,add,091111 - RT_TRACE(COMP_INIT, "Bringing up iface\n"); - - init_status = rtl8192_adapter_start(priv); - if(init_status != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); - return -1; - } - RT_TRACE(COMP_INIT, "start adapter finished\n"); - - if (priv->eRFPowerState != eRfOn) - MgntActSet_RF_State(priv, eRfOn, priv->RfOffReason); - - if(priv->ieee80211->state != IEEE80211_LINKED) - ieee80211_softmac_start_protocol(priv->ieee80211); - ieee80211_reset_queue(priv->ieee80211); - watch_dog_timer_callback((unsigned long) priv); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -static int rtl8192_open(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8192_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8192_up(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8192_up(priv); -} - - -static int rtl8192_close(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8192_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8192_down(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - -#ifdef ENABLE_LPS - //LZM for PS-Poll AID issue. 090429 - if(priv->ieee80211->state == IEEE80211_LINKED) - LeisurePSLeave(priv->ieee80211); -#endif - - priv->up=0; - priv->ieee80211->ieee_up = 0; - RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__); -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8192_irq_disable(priv); - rtl8192_cancel_deferred_work(priv); - deinit_hal_dm(priv); - del_timer_sync(&priv->watch_dog_timer); - - ieee80211_softmac_stop_protocol(priv->ieee80211,true); - - rtl8192_halt_adapter(priv, false); - memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list)); - - RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__); - - return 0; -} - - -void rtl8192_commit(struct r8192_priv *priv) -{ - if (priv->up == 0) return ; - - - ieee80211_softmac_stop_protocol(priv->ieee80211,true); - - rtl8192_irq_disable(priv); - rtl8192_halt_adapter(priv, true); - _rtl8192_up(priv); -} - -static void rtl8192_restart(struct work_struct *work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); - - down(&priv->wx_sem); - - rtl8192_commit(priv); - - up(&priv->wx_sem); -} - -static void r8192_set_multicast(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; -} - - -static int r8192_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - up(&priv->wx_sem); - - return 0; -} - -static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw) -{ - struct ieee80211_device *ieee = priv->ieee80211; - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; - u32 key[4]; - - if (ipw->u.crypt.set_tx) { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) { - memcpy(key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(priv); - /* - * We fill both index entry and 4th entry for pairwise - * key as in IPW interface, adhoc will only get here, - * so we need index entry for its default key serching! - */ - setKey(priv, 4, ipw->u.crypt.idx, - ieee->pairwise_key_type, - (u8*)ieee->ap_mac_addr, 0, key); - - /* LEAP WEP will never set this. */ - if (ieee->auth_mode != 2) - setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, - ieee->pairwise_key_type, - (u8*)ieee->ap_mac_addr, 0, key); - } - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && - ieee->pHTInfo->bCurrentHTSupport) { - write_nic_byte(priv, 0x173, 1); /* fix aes bug */ - } - } else { - memcpy(key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } else - ieee->group_key_type = KEY_TYPE_NA; - - if (ieee->group_key_type) { - setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, - ieee->group_key_type, broadcast_addr, 0, key); - } - } -} - -/* based on ipw2200 driver */ -static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - struct iwreq *wrq = (struct iwreq *)rq; - int ret=-1; - struct iw_point *p = &wrq->u.data; - struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer; - - down(&priv->wx_sem); - - - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } - - ipw = kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; - goto out; - } - - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - /* parse here for HW security */ - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) - r8192e_set_hw_key(priv, ipw); - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - kfree(ipw); -out: - up(&priv->wx_sem); - - return ret; -} - -static u8 HwRateToMRate90(bool bIsHT, u8 rate) -{ - u8 ret_rate = 0x02; - - if(!bIsHT) { - switch(rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; - - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; - } - - } else { - switch(rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; - - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; - } - } - - return ret_rate; -} - -/* Record the TSF time stamp when receiving a packet */ -static void UpdateRxPktTimeStamp8190(struct r8192_priv *priv, struct ieee80211_rx_stats *stats) -{ - - if(stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } -} - -static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. -{ - long signal_power; // in dBm. - - // Translate to dBm (x=0.5y-95). - signal_power = (long)((signal_strength_index + 1) >> 1); - signal_power -= 95; - - return signal_power; -} - -/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to - be a local static. Otherwise, it may increase when we return from S3/S4. The - value will be kept in memory or disk. We must delcare the value in adapter - and it will be reinitialized when return from S3/S4. */ -static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats) -{ - bool bcheck = false; - u8 rfpath; - u32 nspatial_stream, tmp_val; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; - //cosa add for beacon rssi smoothing - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; - - struct ieee80211_hdr_3addr *hdr; - u16 sc ; - unsigned int frag,seq; - hdr = (struct ieee80211_hdr_3addr *)buffer; - sc = le16_to_cpu(hdr->seq_ctl); - frag = WLAN_GET_SEQ_FRAG(sc); - seq = WLAN_GET_SEQ_SEQ(sc); - - // - // Check whether we should take the previous packet into accounting - // - if(!pprevious_stats->bIsAMPDU) - { - // if previous packet is not aggregated packet - bcheck = true; - } - - if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) - { - slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; - last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; - priv->stats.slide_rssi_total -= last_rssi; - } - priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; - - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; - if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) - slide_rssi_index = 0; - - // <1> Showed on UI for user, in dbm - tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; - priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); - pcurrent_stats->rssi = priv->stats.signal_strength; - // - // If the previous packet does not match the criteria, neglect it - // - if(!pprevious_stats->bPacketMatchBSSID) - { - if(!pprevious_stats->bToSelfBA) - return; - } - - if(!bcheck) - return; - - // <2> Showed on UI for engineering - // hardware does not provide rssi information for each rf path in CCK - if(!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) - { - for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv, rfpath)) - continue; - RT_TRACE(COMP_DBG, "pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", pprevious_stats->RxMIMOSignalStrength[rfpath]); - //Fixed by Jacken 2008-03-20 - if(priv->stats.rx_rssi_percentage[rfpath] == 0) - { - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; - } - if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) - { - priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); - priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; - } - else - { - priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); - } - RT_TRACE(COMP_DBG, "priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" , priv->stats.rx_rssi_percentage[rfpath]); - } - } - - - // - // Check PWDB. - // - //cosa add for beacon rssi smoothing by average. - if(pprevious_stats->bPacketBeacon) - { - /* record the beacon pwdb to the sliding window. */ - if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) - { - slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; - priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; - // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total); - } - priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; - slide_beacon_adc_pwdb_index++; - if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) - slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; - if(pprevious_stats->RxPWDBAll >= 3) - pprevious_stats->RxPWDBAll -= 3; - } - - RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - pprevious_stats->bIsCCK? "CCK": "OFDM", - pprevious_stats->RxPWDBAll); - - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - if(priv->undecorated_smoothed_pwdb < 0) // initialize - { - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; - } - - if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) - { - priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); - priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; - } - else - { - priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); - } - } - - // - // Check EVM - // - /* record the general EVM to the sliding window. */ - if(pprevious_stats->SignalQuality == 0) - { - } - else - { - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ - if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ - slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; - last_evm = priv->stats.slide_evm[slide_evm_index]; - priv->stats.slide_evm_total -= last_evm; - } - - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; - - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; - if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) - slide_evm_index = 0; - - // <1> Showed on UI for user, in percentage. - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; - //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. - } - - // <2> Showed on UI for engineering - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream - { - if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) - { - if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize - { - priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; - } - priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); - } - } - } - } - -} - -static u8 rtl819x_query_rxpwrpercentage( - char antpower - ) -{ - if ((antpower <= -100) || (antpower >= 20)) - { - return 0; - } - else if (antpower >= 0) - { - return 100; - } - else - { - return (100+antpower); - } - -} - -static u8 -rtl819x_evm_dbtopercentage( - char value - ) -{ - char ret_val; - - ret_val = value; - - if(ret_val >= 0) - ret_val = 0; - if(ret_val <= -33) - ret_val = -33; - ret_val = 0 - ret_val; - ret_val*=3; - if(ret_val == 99) - ret_val = 100; - return ret_val; -} - -/* We want good-looking for signal strength/quality */ -static long rtl819x_signal_scale_mapping(long currsig) -{ - long retsig; - - // Step 1. Scale mapping. - if(currsig >= 61 && currsig <= 100) - { - retsig = 90 + ((currsig - 60) / 4); - } - else if(currsig >= 41 && currsig <= 60) - { - retsig = 78 + ((currsig - 40) / 2); - } - else if(currsig >= 31 && currsig <= 40) - { - retsig = 66 + (currsig - 30); - } - else if(currsig >= 21 && currsig <= 30) - { - retsig = 54 + (currsig - 20); - } - else if(currsig >= 5 && currsig <= 20) - { - retsig = 42 + (((currsig - 5) * 2) / 3); - } - else if(currsig == 4) - { - retsig = 36; - } - else if(currsig == 3) - { - retsig = 27; - } - else if(currsig == 2) - { - retsig = 18; - } - else if(currsig == 1) - { - retsig = 9; - } - else - { - retsig = currsig; - } - - return retsig; -} - -static void rtl8192_query_rxphystatus( - struct r8192_priv * priv, - struct ieee80211_rx_stats * pstats, - prx_desc_819x_pci pdesc, - prx_fwinfo_819x_pci pdrvinfo, - struct ieee80211_rx_stats * precord_stats, - bool bpacket_match_bssid, - bool bpacket_toself, - bool bPacketBeacon, - bool bToSelfBA - ) -{ - //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status); - phy_sts_ofdm_819xpci_t* pofdm_buf; - phy_sts_cck_819xpci_t * pcck_buf; - phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; - u8 *prxpkt; - u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all=0; - //long rx_avg_pwr = 0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi=0;//, total_evm=0; -// long signal_strength_index = 0; - u8 is_cck_rate=0; - u8 rf_rx_num = 0; - - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); - - // Record it for next packet processing - memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; - pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; - pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo); - pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; - pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; - /*2007.08.30 requested by SD3 Jerry */ - if (priv->phy_check_reg824 == 0) - { - priv->phy_reg824_bit9 = rtl8192_QueryBBReg(priv, rFPGA0_XA_HSSIParameter2, 0x200); - priv->phy_check_reg824 = 1; - } - - - prxpkt = (u8*)pdrvinfo; - - /* Move pointer to the 16th bytes. Phy status start address. */ - prxpkt += sizeof(rx_fwinfo_819x_pci); - - /* Initial the cck and ofdm buffer pointer */ - pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; - pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; - - pstats->RxMIMOSignalQuality[0] = -1; - pstats->RxMIMOSignalQuality[1] = -1; - precord_stats->RxMIMOSignalQuality[0] = -1; - precord_stats->RxMIMOSignalQuality[1] = -1; - - if(is_cck_rate) - { - // - // (1)Hardware does not provide RSSI for CCK - // - - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // - u8 report;//, cck_agc_rpt; - - if (!priv->phy_reg824_bit9) - { - report = pcck_buf->cck_agc_rpt & 0xc0; - report = report>>6; - switch(report) - { - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is -38 , -26 , -14 , -2 - //Fixed value is -35 , -23 , -11 , 6 - case 0x3: - rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - } - } - else - { - report = pcck_buf->cck_agc_rpt & 0x60; - report = report>>5; - switch(report) - { - case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x0: - rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - } - } - - pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); - pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; - pstats->RecvSignalPower = rx_pwr_all; - - // - // (3) Get Signal Quality (EVM) - // - if(bpacket_match_bssid) - { - u8 sq; - - if(pstats->RxPWDBAll > 40) - { - sq = 100; - }else - { - sq = pcck_buf->sq_rpt; - - if(pcck_buf->sq_rpt > 64) - sq = 0; - else if (pcck_buf->sq_rpt < 20) - sq = 100; - else - sq = ((64-sq) * 100) / 44; - } - pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; - } - } - else - { - // - // (1)Get RSSI for HT rate - // - for(i=RF90_PATH_A; ibrfpath_rxenable[i]) - rf_rx_num++; - //else - //continue; - - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; - - //Get Rx snr value in DB - tmp_rxsnr = pofdm_buf->rxsnr_X[i]; - rx_snrX = (char)(tmp_rxsnr); - rx_snrX /= 2; - - /* Translate DBM to percentage. */ - RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); - if (priv->brfpath_rxenable[i]) - total_rssi += RSSI; - - /* Record Signal Strength for next packet */ - if(bpacket_match_bssid) - { - pstats->RxMIMOSignalStrength[i] =(u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; - } - } - - - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; - pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); - - pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; - pstats->RxPower = precord_stats->RxPower = rx_pwr_all; - pstats->RecvSignalPower = rx_pwr_all; - // - // (3)EVM of HT rate - // - if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && - pdrvinfo->RxRate<=DESC90_RATEMCS15) - max_spatial_stream = 2; //both spatial stream make sense - else - max_spatial_stream = 1; //only spatial stream 1 makes sense - - for(i=0; irxevm_X[i]; - rx_evmX = (char)(tmp_rxevm); - - // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment - // fill most significant bit to "zero" when doing shifting operation which may change a negative - // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. - rx_evmX /= 2; //dbm - - evm = rtl819x_evm_dbtopercentage(rx_evmX); - if(bpacket_match_bssid) - { - if(i==0) // Fill value in RFD, Get the first spatial stream only - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); - } - } - - - /* record rx statistics for debug */ - rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; - } - - //UI BSS List signal strength(in percentage), make it good looking, from 0~100. - //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). - if(is_cck_rate) - { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL; - - } - else - { - //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u1Byte)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u1Byte)(total_rssi/=RF90_PATH_MAX); - // We can judge RX path number now. - if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num))); - } -} - -static void -rtl8192_record_rxdesc_forlateruse( - struct ieee80211_rx_stats * psrc_stats, - struct ieee80211_rx_stats * ptarget_stats -) -{ - ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; - ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; -} - - - -static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv, - struct sk_buff *skb, - struct ieee80211_rx_stats * pstats, - prx_desc_819x_pci pdesc, - prx_fwinfo_819x_pci pdrvinfo) -{ - // TODO: We must only check packet for current MAC address. Not finish - bool bpacket_match_bssid, bpacket_toself; - bool bPacketBeacon=false, bToSelfBA=false; - struct ieee80211_hdr_3addr *hdr; - u16 fc,type; - - // Get Signal Quality for only RX data queue (but not command queue) - - u8* tmp_buf; - u8 *praddr; - - /* Get MAC frame start address. */ - tmp_buf = skb->data; - - hdr = (struct ieee80211_hdr_3addr *)tmp_buf; - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - - /* Check if the received packet is acceptabe. */ - bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) && - (!compare_ether_addr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) - && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)); - - if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON) - { - bPacketBeacon = true; - } - if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK) - { - if (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)) - bToSelfBA = true; - } - - // - // Process PHY information for previous packet (RSSI/PWDB/EVM) - // - // Because phy information is contained in the last packet of AMPDU only, so driver - // should process phy information of previous packet - rtl8192_process_phyinfo(priv, tmp_buf, &priv->previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &priv->previous_stats, bpacket_match_bssid, - bpacket_toself ,bPacketBeacon, bToSelfBA); - rtl8192_record_rxdesc_forlateruse(pstats, &priv->previous_stats); - -} - - -static void rtl8192_tx_resume(struct r8192_priv *priv) -{ - struct ieee80211_device *ieee = priv->ieee80211; - struct sk_buff *skb; - int i; - - for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) { - while ((!skb_queue_empty(&ieee->skb_waitQ[i])) && - (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) { - /* 1. dequeue the packet from the wait queue */ - skb = skb_dequeue(&ieee->skb_waitQ[i]); - /* 2. tx the packet directly */ - ieee->softmac_data_hard_start_xmit(skb, ieee, 0); - } - } -} - -static void rtl8192_irq_tx_tasklet(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE]; - unsigned long flags; - - /* check if we need to report that the management queue is drained */ - spin_lock_irqsave(&priv->irq_th_lock, flags); - - if (!skb_queue_len(&mgnt_ring->queue) && - priv->ieee80211->ack_tx_to_ieee && - rtl8192_is_tx_queue_empty(priv->ieee80211)) { - priv->ieee80211->ack_tx_to_ieee = 0; - ieee80211_ps_tx_ack(priv->ieee80211, 1); - } - - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - - rtl8192_tx_resume(priv); -} - -/* Record the received data rate */ -static void UpdateReceivedRateHistogramStatistics8190( - struct r8192_priv *priv, - struct ieee80211_rx_stats* pstats - ) -{ - u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV - u32 rateIndex; - u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI - - if(pstats->bCRC) - rcvType = 2; - else if(pstats->bICV) - rcvType = 3; - - if(pstats->bShortPreamble) - preamble_guardinterval = 1;// short - else - preamble_guardinterval = 0;// long - - switch(pstats->rate) - { - // - // CCK rate - // - case MGN_1M: rateIndex = 0; break; - case MGN_2M: rateIndex = 1; break; - case MGN_5_5M: rateIndex = 2; break; - case MGN_11M: rateIndex = 3; break; - // - // Legacy OFDM rate - // - case MGN_6M: rateIndex = 4; break; - case MGN_9M: rateIndex = 5; break; - case MGN_12M: rateIndex = 6; break; - case MGN_18M: rateIndex = 7; break; - case MGN_24M: rateIndex = 8; break; - case MGN_36M: rateIndex = 9; break; - case MGN_48M: rateIndex = 10; break; - case MGN_54M: rateIndex = 11; break; - // - // 11n High throughput rate - // - case MGN_MCS0: rateIndex = 12; break; - case MGN_MCS1: rateIndex = 13; break; - case MGN_MCS2: rateIndex = 14; break; - case MGN_MCS3: rateIndex = 15; break; - case MGN_MCS4: rateIndex = 16; break; - case MGN_MCS5: rateIndex = 17; break; - case MGN_MCS6: rateIndex = 18; break; - case MGN_MCS7: rateIndex = 19; break; - case MGN_MCS8: rateIndex = 20; break; - case MGN_MCS9: rateIndex = 21; break; - case MGN_MCS10: rateIndex = 22; break; - case MGN_MCS11: rateIndex = 23; break; - case MGN_MCS12: rateIndex = 24; break; - case MGN_MCS13: rateIndex = 25; break; - case MGN_MCS14: rateIndex = 26; break; - case MGN_MCS15: rateIndex = 27; break; - default: rateIndex = 28; break; - } - priv->stats.received_rate_histogram[0][rateIndex]++; //total - priv->stats.received_rate_histogram[rcvType][rateIndex]++; -} - -static void rtl8192_rx(struct r8192_priv *priv) -{ - struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; - bool unicast_packet = false; - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - .freq = IEEE80211_24GHZ_BAND, - }; - unsigned int count = priv->rxringcount; - prx_fwinfo_819x_pci pDrvInfo = NULL; - struct sk_buff *new_skb; - - while (count--) { - rx_desc_819x_pci *pdesc = &priv->rx_ring[priv->rx_idx];//rx descriptor - struct sk_buff *skb = priv->rx_buf[priv->rx_idx];//rx pkt - - if (pdesc->OWN) - /* wait data to be filled by hardware */ - return; - - stats.bICV = pdesc->ICV; - stats.bCRC = pdesc->CRC32; - stats.bHwError = pdesc->CRC32 | pdesc->ICV; - - stats.Length = pdesc->Length; - if(stats.Length < 24) - stats.bHwError |= 1; - - if(stats.bHwError) { - stats.bShift = false; - goto done; - } - pDrvInfo = NULL; - new_skb = dev_alloc_skb(priv->rxbuffersize); - - if (unlikely(!new_skb)) - goto done; - - stats.RxDrvInfoSize = pdesc->RxDrvInfoSize; - stats.RxBufShift = ((pdesc->Shift)&0x03); - stats.Decrypted = !pdesc->SWDec; - - pci_dma_sync_single_for_cpu(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); - skb_put(skb, pdesc->Length); - pDrvInfo = (rx_fwinfo_819x_pci *)(skb->data + stats.RxBufShift); - skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); - - stats.rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); - stats.bShortPreamble = pDrvInfo->SPLCP; - - /* it is debug only. It should be disabled in released driver. - * 2007.1.11 by Emily - * */ - UpdateReceivedRateHistogramStatistics8190(priv, &stats); - - stats.bIsAMPDU = (pDrvInfo->PartAggr==1); - stats.bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); - - stats.TimeStampLow = pDrvInfo->TSFL; - stats.TimeStampHigh = read_nic_dword(priv, TSFR+4); - - UpdateRxPktTimeStamp8190(priv, &stats); - - // - // Get Total offset of MPDU Frame Body - // - if((stats.RxBufShift + stats.RxDrvInfoSize) > 0) - stats.bShift = 1; - - /* ???? */ - TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo); - - /* Rx A-MPDU */ - if(pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); - skb_trim(skb, skb->len - 4/*sCrcLng*/); - /* rx packets statistics */ - ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; - unicast_packet = false; - - if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) { - //TODO - }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){ - //TODO - }else { - /* unicast packet */ - unicast_packet = true; - } - - if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){ - dev_kfree_skb_any(skb); - } else { - priv->stats.rxok++; - if(unicast_packet) { - priv->stats.rxbytesunicast += skb->len; - } - } - - pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - - skb = new_skb; - priv->rx_buf[priv->rx_idx] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); - -done: - pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); - pdesc->OWN = 1; - pdesc->Length = priv->rxbuffersize; - if (priv->rx_idx == priv->rxringcount-1) - pdesc->EOR = 1; - priv->rx_idx = (priv->rx_idx + 1) % priv->rxringcount; - } - -} - -static void rtl8192_irq_rx_tasklet(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - rtl8192_rx(priv); - /* unmask RDU */ - write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) | IMR_RDU); -} - -static const struct net_device_ops rtl8192_netdev_ops = { - .ndo_open = rtl8192_open, - .ndo_stop = rtl8192_close, - .ndo_tx_timeout = tx_timeout, - .ndo_do_ioctl = rtl8192_ioctl, - .ndo_set_multicast_list = r8192_set_multicast, - .ndo_set_mac_address = r8192_set_mac_adr, - .ndo_start_xmit = ieee80211_rtl_xmit, -}; - -static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) -{ - struct net_device *dev = NULL; - struct r8192_priv *priv= NULL; - u8 unit = 0; - int ret = -ENODEV; - unsigned long pmem_start, pmem_len, pmem_flags; - u8 revisionid; - - RT_TRACE(COMP_INIT,"Configuring chip resources\n"); - - if( pci_enable_device (pdev) ){ - RT_TRACE(COMP_ERR,"Failed to enable PCI device"); - return -EIO; - } - - pci_set_master(pdev); - //pci_set_wmi(pdev); - pci_set_dma_mask(pdev, 0xffffff00ULL); - pci_set_consistent_dma_mask(pdev,0xffffff00ULL); - dev = alloc_ieee80211(sizeof(struct r8192_priv)); - if (!dev) { - ret = -ENOMEM; - goto fail_free; - } - - pci_set_drvdata(pdev, dev); - SET_NETDEV_DEV(dev, &pdev->dev); - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - priv->pdev=pdev; - if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ - priv->ieee80211->bSupportRemoteWakeUp = 1; - } else - { - priv->ieee80211->bSupportRemoteWakeUp = 0; - } - - pmem_start = pci_resource_start(pdev, 1); - pmem_len = pci_resource_len(pdev, 1); - pmem_flags = pci_resource_flags (pdev, 1); - - if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting\n"); - goto fail; - } - - //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); - if( ! request_mem_region(pmem_start, pmem_len, RTL819xE_MODULE_NAME)) { - RT_TRACE(COMP_ERR,"request_mem_region failed!\n"); - goto fail; - } - - priv->mem_start = ioremap_nocache(pmem_start, pmem_len); - if (!priv->mem_start) { - RT_TRACE(COMP_ERR,"ioremap failed!\n"); - goto fail1; - } - - dev->mem_start = (unsigned long) priv->mem_start; - dev->mem_end = (unsigned long) (priv->mem_start + - pci_resource_len(pdev, 0)); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, 0x41, 0x00); - - - pci_read_config_byte(pdev, 0x08, &revisionid); - /* If the revisionid is 0x10, the device uses rtl8192se. */ - if (pdev->device == 0x8192 && revisionid == 0x10) - goto fail1; - - pci_read_config_byte(pdev, 0x05, &unit); - pci_write_config_byte(pdev, 0x05, unit & (~0x04)); - - dev->irq = pdev->irq; - priv->irq = 0; - - dev->netdev_ops = &rtl8192_netdev_ops; - - dev->wireless_handlers = &r8192_wx_handlers_def; - dev->type=ARPHRD_ETHER; - - dev->watchdog_timeo = HZ*3; - - if (dev_alloc_name(dev, ifname) < 0){ - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - strcpy(ifname, "wlan%d"); - dev_alloc_name(dev, ifname); - } - - RT_TRACE(COMP_INIT, "Driver probe completed1\n"); - if (rtl8192_init(priv)!=0) { - RT_TRACE(COMP_ERR, "Initialization failed\n"); - goto fail; - } - - register_netdev(dev); - RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name); - rtl8192_proc_init_one(priv); - - - RT_TRACE(COMP_INIT, "Driver probe completed\n"); - return 0; - -fail1: - - if (priv->mem_start) { - iounmap(priv->mem_start); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); - } - -fail: - if(dev){ - - if (priv->irq) { - free_irq(priv->irq, priv); - priv->irq = 0; - } - free_ieee80211(dev); - } - -fail_free: - pci_disable_device(pdev); - - DMESG("wlan driver load failed\n"); - pci_set_drvdata(pdev, NULL); - return ret; - -} - -/* detach all the work and timer structure declared or inititialized - * in r8192_init function. - * */ -static void rtl8192_cancel_deferred_work(struct r8192_priv* priv) -{ - /* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code - * is or is newer than 2.6.20 and work structure is defined to be struct work_struct. - * Otherwise call cancel_delayed_work is enough. - * FIXME (2.6.20 should 2.6.22, work_struct should not cancel) - * */ - cancel_delayed_work(&priv->watch_dog_wq); - cancel_delayed_work(&priv->update_beacon_wq); - cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); - cancel_delayed_work(&priv->gpio_change_rf_wq); - cancel_work_sync(&priv->reset_wq); - cancel_work_sync(&priv->qos_activate); -} - - -static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv ; - u32 i; - - if (dev) { - - unregister_netdev(dev); - - priv = ieee80211_priv(dev); - - rtl8192_proc_remove_one(priv); - - rtl8192_down(dev); - if (priv->pFirmware) - { - vfree(priv->pFirmware); - priv->pFirmware = NULL; - } - destroy_workqueue(priv->priv_wq); - - /* free tx/rx rings */ - rtl8192_free_rx_ring(priv); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - rtl8192_free_tx_ring(priv, i); - - if (priv->irq) { - printk("Freeing irq %d\n", priv->irq); - free_irq(priv->irq, priv); - priv->irq = 0; - } - - if (priv->mem_start) { - iounmap(priv->mem_start); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); - } - - free_ieee80211(dev); - } - - pci_disable_device(pdev); - RT_TRACE(COMP_DOWN, "wlan driver removed\n"); -} - -extern int ieee80211_rtl_init(void); -extern void ieee80211_rtl_exit(void); - -static int __init rtl8192_pci_module_init(void) -{ - int retval; - - retval = ieee80211_rtl_init(); - if (retval) - return retval; - - printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); - RT_TRACE(COMP_INIT, "Initializing module\n"); - rtl8192_proc_module_init(); - if(0!=pci_register_driver(&rtl8192_pci_driver)) - { - DMESG("No device found"); - /*pci_unregister_driver (&rtl8192_pci_driver);*/ - return -ENODEV; - } - return 0; -} - - -static void __exit rtl8192_pci_module_exit(void) -{ - pci_unregister_driver(&rtl8192_pci_driver); - - RT_TRACE(COMP_DOWN, "Exiting\n"); - rtl8192_proc_module_remove(); - ieee80211_rtl_exit(); -} - -static irqreturn_t rtl8192_interrupt(int irq, void *param) -{ - struct r8192_priv *priv = param; - struct net_device *dev = priv->ieee80211->dev; - unsigned long flags; - u32 inta; - irqreturn_t ret = IRQ_HANDLED; - - spin_lock_irqsave(&priv->irq_th_lock, flags); - - /* ISR: 4bytes */ - - inta = read_nic_dword(priv, ISR); /* & priv->IntrMask; */ - write_nic_dword(priv, ISR, inta); /* reset int situation */ - - if (!inta) { - /* - * most probably we can safely return IRQ_NONE, - * but for now is better to avoid problems - */ - goto out_unlock; - } - - if (inta == 0xffff) { - /* HW disappared */ - goto out_unlock; - } - - if (!netif_running(dev)) - goto out_unlock; - - if (inta & IMR_TBDOK) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); - rtl8192_tx_isr(priv, BEACON_QUEUE); - priv->stats.txbeaconokint++; - } - - if (inta & IMR_TBDER) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); - rtl8192_tx_isr(priv, BEACON_QUEUE); - priv->stats.txbeaconerr++; - } - - if (inta & IMR_MGNTDOK ) { - RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); - priv->stats.txmanageokint++; - rtl8192_tx_isr(priv, MGNT_QUEUE); - } - - if (inta & IMR_COMDOK) - { - priv->stats.txcmdpktokint++; - rtl8192_tx_isr(priv, TXCMD_QUEUE); - } - - if (inta & IMR_ROK) { - priv->stats.rxint++; - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_BcnInt) { - RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); - tasklet_schedule(&priv->irq_prepare_beacon_tasklet); - } - - if (inta & IMR_RDU) { - RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); - priv->stats.rxrdu++; - /* reset int situation */ - write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) & ~IMR_RDU); - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_RXFOVW) { - RT_TRACE(COMP_INTR, "rx overflow !\n"); - priv->stats.rxoverflow++; - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_TXFOVW) - priv->stats.txoverflow++; - - if (inta & IMR_BKDOK) { - RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); - priv->stats.txbkokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, BK_QUEUE); - } - - if (inta & IMR_BEDOK) { - RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); - priv->stats.txbeokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, BE_QUEUE); - } - - if (inta & IMR_VIDOK) { - RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); - priv->stats.txviokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, VI_QUEUE); - } - - if (inta & IMR_VODOK) { - priv->stats.txvookint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, VO_QUEUE); - } - -out_unlock: - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - - return ret; -} - -void EnableHWSecurityConfig8192(struct r8192_priv *priv) -{ - u8 SECR_value = 0x0; - struct ieee80211_device* ieee = priv->ieee80211; - - SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; - - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; - } - - //add HWSec active enable here. -//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 - ieee->hwsec_active = 1; - - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off - { - ieee->hwsec_active = 0; - SECR_value &= ~SCR_RxDecEnable; - } - - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(priv, SECR, SECR_value);//SECR_value | SCR_UseDK ); - } - -} -#define TOTAL_CAM_ENTRY 32 -//#define CAM_CONTENT_COUNT 8 -void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, - const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) -{ - u32 TargetCommand = 0; - u32 TargetContent = 0; - u16 usConfig = 0; - u8 i; -#ifdef ENABLE_IPS - RT_RF_POWER_STATE rtState; - - rtState = priv->eRFPowerState; - if (priv->PowerSaveControl.bInactivePs){ - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - //up(&priv->wx_sem); - return ; - } - else{ - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); - } - } - } - priv->ieee80211->is_set_key = true; -#endif - if (EntryNo >= TOTAL_CAM_ENTRY) - RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); - - RT_TRACE(COMP_SEC, "====>to setKey(), priv:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", priv, EntryNo, KeyIndex, KeyType, MacAddr); - - if (DefaultKey) - usConfig |= BIT15 | (KeyType<<2); - else - usConfig |= BIT15 | (KeyType<<2) | KeyIndex; -// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; - - - for(i=0 ; iafter set key, usconfig:%x\n", usConfig); -} - -bool NicIFEnableNIC(struct r8192_priv *priv) -{ - RT_STATUS init_status = RT_STATUS_SUCCESS; - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - //YJ,add,091109 - if (priv->up == 0){ - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__FUNCTION__); - priv->bdisable_nic = false; //YJ,add,091111 - return false; - } - // <1> Reset memory: descriptor, buffer,.. - //NicIFResetMemory(Adapter); - - // <2> Enable Adapter - //priv->bfirst_init = true; - init_status = rtl8192_adapter_start(priv); - if (init_status != RT_STATUS_SUCCESS) { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); - priv->bdisable_nic = false; //YJ,add,091111 - return -1; - } - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - //priv->bfirst_init = false; - - // <3> Enable Interrupt - rtl8192_irq_enable(priv); - priv->bdisable_nic = false; - - return (init_status == RT_STATUS_SUCCESS); -} - -bool NicIFDisableNIC(struct r8192_priv *priv) -{ - bool status = true; - u8 tmp_state = 0; - // <1> Disable Interrupt - - priv->bdisable_nic = true; //YJ,move,091109 - tmp_state = priv->ieee80211->state; - - ieee80211_softmac_stop_protocol(priv->ieee80211, false); - - priv->ieee80211->state = tmp_state; - rtl8192_cancel_deferred_work(priv); - rtl8192_irq_disable(priv); - // <2> Stop all timer - - // <3> Disable Adapter - rtl8192_halt_adapter(priv, false); -// priv->bdisable_nic = true; - - return status; -} - -module_init(rtl8192_pci_module_init); -module_exit(rtl8192_pci_module_exit); diff --git a/drivers/staging/rtl8192e/r8192E_core.c.porig b/drivers/staging/rtl8192e/r8192E_core.c.porig deleted file mode 100644 index 94d9c8d5d09..00000000000 --- a/drivers/staging/rtl8192e/r8192E_core.c.porig +++ /dev/null @@ -1,5039 +0,0 @@ -/****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. - * Linux device driver for RTL8192E - * - * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Jerry chuang - */ - - -#include -#include -#include -#include -#include -#include "r8192E_hw.h" -#include "r8192E.h" -#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8192E_wx.h" -#include "r819xE_phy.h" //added by WB 4.30.2008 -#include "r819xE_phyreg.h" -#include "r819xE_cmdpkt.h" -#include "r8192E_dm.h" - -#ifdef CONFIG_PM -#include "r8192_pm.h" -#endif - -#ifdef ENABLE_DOT11D -#include "ieee80211/dot11d.h" -#endif - -//set here to open your trace code. //WB -u32 rt_global_debug_component = COMP_ERR ; //always open err flags on - -static DEFINE_PCI_DEVICE_TABLE(rtl8192_pci_id_tbl) = { - /* Realtek */ - { PCI_DEVICE(0x10ec, 0x8192) }, - - /* Corega */ - { PCI_DEVICE(0x07aa, 0x0044) }, - { PCI_DEVICE(0x07aa, 0x0047) }, - {} -}; - -static char ifname[IFNAMSIZ] = "wlan%d"; -static int hwwep = 1; //default use hw. set 0 to use software security -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); -//MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); - - -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); -module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); - -MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); -static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); - -static struct pci_driver rtl8192_pci_driver = { - .name = RTL819xE_MODULE_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = rtl8192_pci_probe, /* probe fn */ - .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ -#ifdef CONFIG_PM - .suspend = rtl8192E_suspend, /* PM suspend fn */ - .resume = rtl8192E_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - -static void rtl8192_start_beacon(struct ieee80211_device *ieee80211); -static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211); -static void rtl819x_watchdog_wqcallback(struct work_struct *work); -static void rtl8192_irq_rx_tasklet(unsigned long arg); -static void rtl8192_irq_tx_tasklet(unsigned long arg); -static void rtl8192_prepare_beacon(unsigned long arg); -static irqreturn_t rtl8192_interrupt(int irq, void *param); -static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb); -static void rtl8192_update_ratr_table(struct r8192_priv *priv); -static void rtl8192_restart(struct work_struct *work); -static void watch_dog_timer_callback(unsigned long data); -static int _rtl8192_up(struct r8192_priv *priv); -static void rtl8192_cancel_deferred_work(struct r8192_priv* priv); -static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb); - -#ifdef ENABLE_DOT11D - -typedef struct _CHANNEL_LIST -{ - u8 Channel[32]; - u8 Len; -}CHANNEL_LIST, *PCHANNEL_LIST; - -static const CHANNEL_LIST ChannelPlan[] = { - {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC - {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 -}; - -static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) -{ - int i, max_chan=-1, min_chan=-1; - struct ieee80211_device* ieee = priv->ieee80211; - switch (channel_plan) - { - case COUNTRY_CODE_FCC: - case COUNTRY_CODE_IC: - case COUNTRY_CODE_ETSI: - case COUNTRY_CODE_SPAIN: - case COUNTRY_CODE_FRANCE: - case COUNTRY_CODE_MKK: - case COUNTRY_CODE_MKK1: - case COUNTRY_CODE_ISRAEL: - case COUNTRY_CODE_TELEC: - case COUNTRY_CODE_MIC: - { - Dot11d_Init(ieee); - ieee->bGlobalDomain = false; - //acturally 8225 & 8256 rf chip only support B,G,24N mode - min_chan = 1; - max_chan = 14; - - if (ChannelPlan[channel_plan].Len != 0){ - // Clear old channel map - memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); - // Set new channel map - for (i=0;i max_chan) - break; - GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; - } - } - break; - } - case COUNTRY_CODE_GLOBAL_DOMAIN: - { - GET_DOT11D_INFO(ieee)->bEnabled = 0; //this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain setting - Dot11d_Reset(ieee); - ieee->bGlobalDomain = true; - break; - } - default: - break; - } -} -#endif - -static inline bool rx_hal_is_cck_rate(prx_fwinfo_819x_pci pdrvinfo) -{ - return (pdrvinfo->RxRate == DESC90_RATE1M || - pdrvinfo->RxRate == DESC90_RATE2M || - pdrvinfo->RxRate == DESC90_RATE5_5M || - pdrvinfo->RxRate == DESC90_RATE11M) && - !pdrvinfo->RxHT; -} - -void CamResetAllEntry(struct r8192_priv* priv) -{ - write_nic_dword(priv, RWCAM, BIT31|BIT30); -} - -void write_cam(struct r8192_priv *priv, u8 addr, u32 data) -{ - write_nic_dword(priv, WCAMI, data); - write_nic_dword(priv, RWCAM, BIT31|BIT16|(addr&0xff) ); -} - -u32 read_cam(struct r8192_priv *priv, u8 addr) -{ - write_nic_dword(priv, RWCAM, 0x80000000|(addr&0xff) ); - return read_nic_dword(priv, 0xa8); -} - -u8 read_nic_byte(struct r8192_priv *priv, int x) -{ - return 0xff & readb(priv->mem_start + x); -} - -u32 read_nic_dword(struct r8192_priv *priv, int x) -{ - return readl(priv->mem_start + x); -} - -u16 read_nic_word(struct r8192_priv *priv, int x) -{ - return readw(priv->mem_start + x); -} - -void write_nic_byte(struct r8192_priv *priv, int x,u8 y) -{ - writeb(y, priv->mem_start + x); - udelay(20); -} - -void write_nic_dword(struct r8192_priv *priv, int x,u32 y) -{ - writel(y, priv->mem_start + x); - udelay(20); -} - -void write_nic_word(struct r8192_priv *priv, int x,u16 y) -{ - writew(y, priv->mem_start + x); - udelay(20); -} - -u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee) -{ - static const u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; - static const u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; - int wpa_ie_len= ieee->wpa_ie_len; - struct ieee80211_crypt_data* crypt; - int encrypt; - - crypt = ieee->crypt[ieee->tx_keyidx]; - - encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) || - (ieee->host_encrypt && crypt && crypt->ops && - (0 == strcmp(crypt->ops->name,"WEP"))); - - /* simply judge */ - if(encrypt && (wpa_ie_len == 0)) { - // wep encryption, no N mode setting */ - return SEC_ALG_WEP; - } else if((wpa_ie_len != 0)) { - // parse pairwise key type */ - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || - ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) - return SEC_ALG_CCMP; - else - return SEC_ALG_TKIP; - } else { - return SEC_ALG_NONE; - } -} - -void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - - switch(variable) - { - - case HW_VAR_BSSID: - write_nic_dword(priv, BSSIDR, ((u32*)(val))[0]); - write_nic_word(priv, BSSIDR+2, ((u16*)(val+2))[0]); - break; - - case HW_VAR_MEDIA_STATUS: - { - RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); - u8 btMsr = read_nic_byte(priv, MSR); - - btMsr &= 0xfc; - - switch(OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_INFRA; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_ADHOC; - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_AP; - break; - - default: - btMsr |= MSR_NOLINK; - break; - } - - write_nic_byte(priv, MSR, btMsr); - } - break; - - case HW_VAR_CHECK_BSSID: - { - u32 RegRCR, Type; - - Type = ((u8*)(val))[0]; - RegRCR = read_nic_dword(priv, RCR); - priv->ReceiveConfig = RegRCR; - - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); - - write_nic_dword(priv, RCR,RegRCR); - priv->ReceiveConfig = RegRCR; - - } - break; - - case HW_VAR_SLOT_TIME: - { - priv->slot_time = val[0]; - write_nic_byte(priv, SLOT_TIME, val[0]); - - } - break; - - case HW_VAR_ACK_PREAMBLE: - { - u32 regTmp = 0; - priv->short_preamble = (bool)(*(u8*)val ); - regTmp = priv->basic_rate; - if (priv->short_preamble) - regTmp |= BRSR_AckShortPmb; - write_nic_dword(priv, RRSR, regTmp); - } - break; - - case HW_VAR_CPU_RST: - write_nic_dword(priv, CPU_GEN, ((u32*)(val))[0]); - break; - - default: - break; - } - -} - -static struct proc_dir_entry *rtl8192_proc = NULL; - -static int proc_get_stats_ap(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - struct ieee80211_device *ieee = priv->ieee80211; - struct ieee80211_network *target; - int len = 0; - - list_for_each_entry(target, &ieee->network_list, list) { - - len += snprintf(page + len, count - len, - "%s ", target->ssid); - - if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } - - } - - *eof = 1; - return len; -} - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - int len = 0; - int i,n; - int max=0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page 0##################\n "); - - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,n)); - } - len += snprintf(page + len, count - len,"\n"); - len += snprintf(page + len, count - len, - "\n####################page 1##################\n "); - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,0x100|n)); - } - - len += snprintf(page + len, count - len, - "\n####################page 3##################\n "); - for(n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(priv,0x300|n)); - } - - *eof = 1; - return len; - -} - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - - int len = 0; - - len += snprintf(page + len, count - len, - "TX VI priority ok int: %lu\n" - "TX VO priority ok int: %lu\n" - "TX BE priority ok int: %lu\n" - "TX BK priority ok int: %lu\n" - "TX MANAGE priority ok int: %lu\n" - "TX BEACON priority ok int: %lu\n" - "TX BEACON priority error int: %lu\n" - "TX CMDPKT priority ok int: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" - "TX total data packets %lu\n" - "TX total data bytes :%lu\n", - priv->stats.txviokint, - priv->stats.txvookint, - priv->stats.txbeokint, - priv->stats.txbkokint, - priv->stats.txmanageokint, - priv->stats.txbeaconokint, - priv->stats.txbeaconerr, - priv->stats.txcmdpktokint, - netif_queue_stopped(priv->ieee80211->dev), - priv->stats.txoverflow, - priv->ieee80211->stats.tx_packets, - priv->ieee80211->stats.tx_bytes); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct r8192_priv *priv = data; - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX desc err: %lu\n" - "RX rx overflow error: %lu\n", - priv->stats.rxint, - priv->stats.rxrdu, - priv->stats.rxoverflow); - - *eof = 1; - return len; -} - -static void rtl8192_proc_module_init(void) -{ - RT_TRACE(COMP_INIT, "Initializing proc filesystem\n"); - rtl8192_proc = proc_mkdir(RTL819xE_MODULE_NAME, init_net.proc_net); -} - - -static void rtl8192_proc_module_remove(void) -{ - remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net); -} - - -static void rtl8192_proc_remove_one(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - - printk("dev name=======> %s\n",dev->name); - - if (priv->dir_dev) { - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry("wlan0", rtl8192_proc); - priv->dir_dev = NULL; - } -} - - -static void rtl8192_proc_init_one(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - struct proc_dir_entry *e; - - priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); - if (!priv->dir_dev) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); - return; - } - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, priv); - - if (!e) { - RT_TRACE(COMP_ERR,"Unable to initialize " - "/proc/net/rtl8192/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, priv); - - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-tx\n", - dev->name); - } - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, priv); - - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-ap\n", - dev->name); - } - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, priv); - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers\n", - dev->name); - } -} - -static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - /* for now we reserve two free descriptor as a safety boundary - * between the tail and the head - */ - return (ring->entries - skb_queue_len(&ring->queue) >= 2); -} - -static void tx_timeout(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - schedule_work(&priv->reset_wq); - printk("TXTIMEOUT"); -} - -static void rtl8192_irq_enable(struct r8192_priv *priv) -{ - u32 mask; - - mask = IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | - IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | - IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW | - IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER; - - write_nic_dword(priv, INTA_MASK, mask); -} - -static void rtl8192_irq_disable(struct r8192_priv *priv) -{ - write_nic_dword(priv, INTA_MASK, 0); - synchronize_irq(priv->irq); -} - -static void rtl8192_update_msr(struct r8192_priv *priv) -{ - u8 msr; - - msr = read_nic_byte(priv, MSR); - msr &= ~ MSR_LINK_MASK; - - /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. - * this is intentional and make sense for ad-hoc and - * master (see the create BSS/IBSS func) - */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<dev); - - priv->chan = ch; - - /* need to implement rf set channel here WB */ - - if (priv->rf_set_chan) - priv->rf_set_chan(ieee80211, priv->chan); -} - -static void rtl8192_rx_enable(struct r8192_priv *priv) -{ - write_nic_dword(priv, RDQDA, priv->rx_ring_dma); -} - -/* the TX_DESC_BASE setting is according to the following queue index - * BK_QUEUE ===> 0 - * BE_QUEUE ===> 1 - * VI_QUEUE ===> 2 - * VO_QUEUE ===> 3 - * HCCA_QUEUE ===> 4 - * TXCMD_QUEUE ===> 5 - * MGNT_QUEUE ===> 6 - * HIGH_QUEUE ===> 7 - * BEACON_QUEUE ===> 8 - * */ -static const u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; -static void rtl8192_tx_enable(struct r8192_priv *priv) -{ - u32 i; - - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - write_nic_dword(priv, TX_DESC_BASE[i], priv->tx_ring[i].dma); - - ieee80211_reset_queue(priv->ieee80211); -} - - -static void rtl8192_free_rx_ring(struct r8192_priv *priv) -{ - int i; - - for (i = 0; i < priv->rxringcount; i++) { - struct sk_buff *skb = priv->rx_buf[i]; - if (!skb) - continue; - - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - kfree_skb(skb); - } - - pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring) * priv->rxringcount, - priv->rx_ring, priv->rx_ring_dma); - priv->rx_ring = NULL; -} - -static void rtl8192_free_tx_ring(struct r8192_priv *priv, unsigned int prio) -{ - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); - - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - - pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; -} - -void PHY_SetRtl8192eRfOff(struct r8192_priv *priv) -{ - //disable RF-Chip A/B - rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); - //analog to digital off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x0); - //digital to analog off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x0); - //rx antenna off - rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0xf, 0x0); - //rx antenna off - rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0xf, 0x0); - //analog to digital part2 off, for power save - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x0); - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x0); - // Analog parameter!!Change bias and Lbus control. - write_nic_byte(priv, ANAPAR_FOR_8192PciE, 0x07); -} - -static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset) -{ - int i; - u8 OpMode; - u32 ulRegRead; - - OpMode = RT_OP_MODE_NO_LINK; - priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode); - - if (!priv->ieee80211->bSupportRemoteWakeUp) { - /* - * disable tx/rx. In 8185 we write 0x10 (Reset bit), - * but here we make reference to WMAC and wirte 0x0 - */ - write_nic_byte(priv, CMDR, 0); - } - - mdelay(20); - - if (!reset) { - mdelay(150); - - priv->bHwRfOffAction = 2; - - /* - * Call MgntActSet_RF_State instead to - * prevent RF config race condition. - */ - if (!priv->ieee80211->bSupportRemoteWakeUp) { - PHY_SetRtl8192eRfOff(priv); - ulRegRead = read_nic_dword(priv, CPU_GEN); - ulRegRead |= CPU_GEN_SYSTEM_RESET; - write_nic_dword(priv,CPU_GEN, ulRegRead); - } else { - /* for WOL */ - write_nic_dword(priv, WFCRC0, 0xffffffff); - write_nic_dword(priv, WFCRC1, 0xffffffff); - write_nic_dword(priv, WFCRC2, 0xffffffff); - - /* Write PMR register */ - write_nic_byte(priv, PMR, 0x5); - /* Disable tx, enanble rx */ - write_nic_byte(priv, MacBlkCtrl, 0xa); - } - } - - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->ieee80211->skb_waitQ [i]); - } - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->ieee80211->skb_aggQ [i]); - } - - skb_queue_purge(&priv->skb_queue); -} - -static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211) -{ -} - -static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211) -{ -} - -/* - * this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -static void rtl8192_hard_data_xmit(struct sk_buff *skb, - struct ieee80211_device *ieee80211, int rate) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - u8 queue_index = tcb_desc->queue_index; - - /* shall not be referred by command packet */ - BUG_ON(queue_index == TXCMD_QUEUE); - - if (priv->bHwRadioOff || (!priv->up)) - { - kfree_skb(skb); - return; - } - - skb_push(skb, priv->ieee80211->tx_headroom); - ret = rtl8192_tx(priv, skb); - if (ret != 0) { - kfree_skb(skb); - } - - if (queue_index != MGNT_QUEUE) { - priv->ieee80211->stats.tx_bytes += (skb->len - priv->ieee80211->tx_headroom); - priv->ieee80211->stats.tx_packets++; - } -} - -/* - * This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - int ret; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - u8 queue_index = tcb_desc->queue_index; - - if (queue_index != TXCMD_QUEUE) { - if (priv->bHwRadioOff || (!priv->up)) - { - kfree_skb(skb); - return 0; - } - } - - if (queue_index == TXCMD_QUEUE) { - rtl819xE_tx_cmd(priv, skb); - ret = 0; - return ret; - } else { - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - tcb_desc->bTxEnableFwCalcDur = 1; - skb_push(skb, ieee80211->tx_headroom); - ret = rtl8192_tx(priv, skb); - if (ret != 0) { - kfree_skb(skb); - } - } - - return ret; -} - - -static void rtl8192_tx_isr(struct r8192_priv *priv, int prio) -{ - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb; - - /* - * beacon packet will only use the first descriptor defaultly, - * and the OWN may not be cleared by the hardware - */ - if (prio != BEACON_QUEUE) { - if (entry->OWN) - return; - ring->idx = (ring->idx + 1) % ring->entries; - } - - skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - - kfree_skb(skb); - } - - if (prio != BEACON_QUEUE) { - /* try to deal with the pending packets */ - tasklet_schedule(&priv->irq_tx_tasklet); - } -} - -static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211) -{ -} - -static void rtl8192_config_rate(struct r8192_priv *priv, u16* rate_config) -{ - struct ieee80211_network *net; - u8 i=0, basic_rate = 0; - net = & priv->ieee80211->current_network; - - for (i=0; irates_len; i++) - { - basic_rate = net->rates[i]&0x7f; - switch(basic_rate) - { - case MGN_1M: *rate_config |= RRSR_1M; break; - case MGN_2M: *rate_config |= RRSR_2M; break; - case MGN_5_5M: *rate_config |= RRSR_5_5M; break; - case MGN_11M: *rate_config |= RRSR_11M; break; - case MGN_6M: *rate_config |= RRSR_6M; break; - case MGN_9M: *rate_config |= RRSR_9M; break; - case MGN_12M: *rate_config |= RRSR_12M; break; - case MGN_18M: *rate_config |= RRSR_18M; break; - case MGN_24M: *rate_config |= RRSR_24M; break; - case MGN_36M: *rate_config |= RRSR_36M; break; - case MGN_48M: *rate_config |= RRSR_48M; break; - case MGN_54M: *rate_config |= RRSR_54M; break; - } - } - for (i=0; irates_ex_len; i++) - { - basic_rate = net->rates_ex[i]&0x7f; - switch(basic_rate) - { - case MGN_1M: *rate_config |= RRSR_1M; break; - case MGN_2M: *rate_config |= RRSR_2M; break; - case MGN_5_5M: *rate_config |= RRSR_5_5M; break; - case MGN_11M: *rate_config |= RRSR_11M; break; - case MGN_6M: *rate_config |= RRSR_6M; break; - case MGN_9M: *rate_config |= RRSR_9M; break; - case MGN_12M: *rate_config |= RRSR_12M; break; - case MGN_18M: *rate_config |= RRSR_18M; break; - case MGN_24M: *rate_config |= RRSR_24M; break; - case MGN_36M: *rate_config |= RRSR_36M; break; - case MGN_48M: *rate_config |= RRSR_48M; break; - case MGN_54M: *rate_config |= RRSR_54M; break; - } - } -} - - -#define SHORT_SLOT_TIME 9 -#define NON_SHORT_SLOT_TIME 20 - -static void rtl8192_update_cap(struct r8192_priv *priv, u16 cap) -{ - u32 tmp = 0; - struct ieee80211_network *net = &priv->ieee80211->current_network; - - priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; - tmp = priv->basic_rate; - if (priv->short_preamble) - tmp |= BRSR_AckShortPmb; - write_nic_dword(priv, RRSR, tmp); - - if (net->mode & (IEEE_G|IEEE_N_24G)) - { - u8 slot_time = 0; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) - {//short slot time - slot_time = SHORT_SLOT_TIME; - } - else //long slot time - slot_time = NON_SHORT_SLOT_TIME; - priv->slot_time = slot_time; - write_nic_byte(priv, SLOT_TIME, slot_time); - } - -} - -static void rtl8192_net_update(struct r8192_priv *priv) -{ - struct ieee80211_network *net; - u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; - u16 rate_config = 0; - net = &priv->ieee80211->current_network; - - /* update Basic rate: RR, BRSR */ - rtl8192_config_rate(priv, &rate_config); - - /* - * Select RRSR (in Legacy-OFDM and CCK) - * For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, - * 2M, and 1M from the Basic rate. - * We do not use other rates. - */ - priv->basic_rate = rate_config &= 0x15f; - - /* BSSID */ - write_nic_dword(priv, BSSIDR, ((u32 *)net->bssid)[0]); - write_nic_word(priv, BSSIDR+4, ((u16 *)net->bssid)[2]); - - if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { - write_nic_word(priv, ATIMWND, 2); - write_nic_word(priv, BCN_DMATIME, 256); - write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); - /* - * BIT15 of BCN_DRV_EARLY_INT will indicate - * whether software beacon or hw beacon is applied. - */ - write_nic_word(priv, BCN_DRV_EARLY_INT, 10); - write_nic_byte(priv, BCN_ERR_THRESH, 100); - - BcnTimeCfg |= (BcnCW<tx_ring[TXCMD_QUEUE]; - mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - - spin_lock_irqsave(&priv->irq_th_lock,flags); - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = &ring->desc[idx]; - - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - memset(entry,0,12); - entry->LINIP = tcb_desc->bLastIniPkt; - entry->FirstSeg = 1;//first segment - entry->LastSeg = 1; //last segment - if(tcb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { - entry->CmdInit = DESC_PACKET_TYPE_INIT; - } else { - entry->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry->Offset = sizeof(TX_FWINFO_8190PCI) + 8; - entry->PktSize = (u16)(tcb_desc->pkt_size + entry->Offset); - entry->QueueSelect = QSLT_CMD; - entry->TxFWInfoSize = 0x08; - entry->RATid = (u8)DESC_PACKET_TYPE_INIT; - } - entry->TxBufferSize = skb->len; - entry->TxBuffAddr = cpu_to_le32(mapping); - entry->OWN = 1; - - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - - write_nic_byte(priv, TPPoll, TPPoll_CQ); - - return; -} - -/* - * Mapping Software/Hardware descriptor queue id to "Queue Select Field" - * in TxFwInfo data structure - */ -static u8 MapHwQueueToFirmwareQueue(u8 QueueID) -{ - u8 QueueSelect = 0; - - switch (QueueID) { - case BE_QUEUE: - QueueSelect = QSLT_BE; - break; - - case BK_QUEUE: - QueueSelect = QSLT_BK; - break; - - case VO_QUEUE: - QueueSelect = QSLT_VO; - break; - - case VI_QUEUE: - QueueSelect = QSLT_VI; - break; - - case MGNT_QUEUE: - QueueSelect = QSLT_MGNT; - break; - - case BEACON_QUEUE: - QueueSelect = QSLT_BEACON; - break; - - case TXCMD_QUEUE: - QueueSelect = QSLT_CMD; - break; - - case HIGH_QUEUE: - default: - RT_TRACE(COMP_ERR, "Impossible Queue Selection: %d\n", QueueID); - break; - } - return QueueSelect; -} - -static u8 MRateToHwRate8190Pci(u8 rate) -{ - u8 ret = DESC90_RATE1M; - - switch(rate) { - case MGN_1M: ret = DESC90_RATE1M; break; - case MGN_2M: ret = DESC90_RATE2M; break; - case MGN_5_5M: ret = DESC90_RATE5_5M; break; - case MGN_11M: ret = DESC90_RATE11M; break; - case MGN_6M: ret = DESC90_RATE6M; break; - case MGN_9M: ret = DESC90_RATE9M; break; - case MGN_12M: ret = DESC90_RATE12M; break; - case MGN_18M: ret = DESC90_RATE18M; break; - case MGN_24M: ret = DESC90_RATE24M; break; - case MGN_36M: ret = DESC90_RATE36M; break; - case MGN_48M: ret = DESC90_RATE48M; break; - case MGN_54M: ret = DESC90_RATE54M; break; - - // HT rate since here - case MGN_MCS0: ret = DESC90_RATEMCS0; break; - case MGN_MCS1: ret = DESC90_RATEMCS1; break; - case MGN_MCS2: ret = DESC90_RATEMCS2; break; - case MGN_MCS3: ret = DESC90_RATEMCS3; break; - case MGN_MCS4: ret = DESC90_RATEMCS4; break; - case MGN_MCS5: ret = DESC90_RATEMCS5; break; - case MGN_MCS6: ret = DESC90_RATEMCS6; break; - case MGN_MCS7: ret = DESC90_RATEMCS7; break; - case MGN_MCS8: ret = DESC90_RATEMCS8; break; - case MGN_MCS9: ret = DESC90_RATEMCS9; break; - case MGN_MCS10: ret = DESC90_RATEMCS10; break; - case MGN_MCS11: ret = DESC90_RATEMCS11; break; - case MGN_MCS12: ret = DESC90_RATEMCS12; break; - case MGN_MCS13: ret = DESC90_RATEMCS13; break; - case MGN_MCS14: ret = DESC90_RATEMCS14; break; - case MGN_MCS15: ret = DESC90_RATEMCS15; break; - case (0x80|0x20): ret = DESC90_RATEMCS32; break; - - default: break; - } - return ret; -} - - -static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) -{ - u8 tmp_Short; - - tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); - - if(TxHT==1 && TxRate != DESC90_RATEMCS15) - tmp_Short = 0; - - return tmp_Short; -} - -/* - * The tx procedure is just as following, - * skb->cb will contain all the following information, - * priority, morefrag, rate, &dev. - */ -static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb) -{ - struct rtl8192_tx_ring *ring; - unsigned long flags; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tx_desc_819x_pci *pdesc = NULL; - TX_FWINFO_8190PCI *pTxFwInfo = NULL; - dma_addr_t mapping; - bool multi_addr = false, broad_addr = false, uni_addr = false; - u8 *pda_addr = NULL; - int idx; - - if (priv->bdisable_nic) { - RT_TRACE(COMP_ERR, "Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", - skb->len, tcb_desc->queue_index); - return skb->len; - } - -#ifdef ENABLE_LPS - priv->ieee80211->bAwakePktSent = true; -#endif - - mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - - /* collect the tx packets statitcs */ - pda_addr = ((u8 *)skb->data) + sizeof(TX_FWINFO_8190PCI); - if (is_multicast_ether_addr(pda_addr)) - multi_addr = true; - else if (is_broadcast_ether_addr(pda_addr)) - broad_addr = true; - else - uni_addr = true; - - if (uni_addr) - priv->stats.txbytesunicast += (u8)(skb->len) - sizeof(TX_FWINFO_8190PCI); - - /* fill tx firmware */ - pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; - memset(pTxFwInfo, 0, sizeof(TX_FWINFO_8190PCI)); - pTxFwInfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; - pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)tcb_desc->data_rate); - pTxFwInfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; - pTxFwInfo->Short = QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, tcb_desc); - - /* Aggregation related */ - if (tcb_desc->bAMPDUEnable) { - pTxFwInfo->AllowAggregation = 1; - pTxFwInfo->RxMF = tcb_desc->ampdu_factor; - pTxFwInfo->RxAMD = tcb_desc->ampdu_density; - } else { - pTxFwInfo->AllowAggregation = 0; - pTxFwInfo->RxMF = 0; - pTxFwInfo->RxAMD = 0; - } - - /* Protection mode related */ - pTxFwInfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; - pTxFwInfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; - pTxFwInfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; - pTxFwInfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; - pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); - pTxFwInfo->RtsBandwidth = 0; - pTxFwInfo->RtsSubcarrier = tcb_desc->RTSSC; - pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : (tcb_desc->bRTSUseShortGI? 1 : 0); - - /* Set Bandwidth and sub-channel settings. */ - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { - if (tcb_desc->bPacketBW) { - pTxFwInfo->TxBandwidth = 1; - /* use duplicated mode */ - pTxFwInfo->TxSubCarrier = 0; - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = 0; - } - - spin_lock_irqsave(&priv->irq_th_lock, flags); - ring = &priv->tx_ring[tcb_desc->queue_index]; - if (tcb_desc->queue_index != BEACON_QUEUE) - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - else - idx = 0; - - pdesc = &ring->desc[idx]; - if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d,idx = %d,%x\n", - tcb_desc->queue_index, ring->idx, idx, skb->len); - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - return skb->len; - } - - /* fill tx descriptor */ - memset(pdesc, 0, 12); - - /*DWORD 0*/ - pdesc->LINIP = 0; - pdesc->CmdInit = 1; - pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; /* We must add 8!! */ - pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); - - /*DWORD 1*/ - pdesc->SecCAMID = 0; - pdesc->RATid = tcb_desc->RATRIndex; - - pdesc->NoEnc = 1; - pdesc->SecType = 0x0; - if (tcb_desc->bHwSec) { - switch (priv->ieee80211->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - pdesc->SecType = 0x1; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - pdesc->SecType = 0x2; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - pdesc->SecType = 0x3; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_NA: - pdesc->SecType = 0x0; - pdesc->NoEnc = 1; - break; - } - } - - /* Set Packet ID */ - pdesc->PktId = 0x0; - - pdesc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); - pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); - - pdesc->DISFB = tcb_desc->bTxDisableRateFallBack; - pdesc->USERATE = tcb_desc->bTxUseDriverAssingedRate; - - pdesc->FirstSeg = 1; - pdesc->LastSeg = 1; - pdesc->TxBufferSize = skb->len; - - pdesc->TxBuffAddr = cpu_to_le32(mapping); - __skb_queue_tail(&ring->queue, skb); - pdesc->OWN = 1; - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - priv->ieee80211->dev->trans_start = jiffies; - write_nic_word(priv, TPPoll, 0x01<queue_index); - return 0; -} - -static short rtl8192_alloc_rx_desc_ring(struct r8192_priv *priv) -{ - rx_desc_819x_pci *entry = NULL; - int i; - - priv->rx_ring = pci_alloc_consistent(priv->pdev, - sizeof(*priv->rx_ring) * priv->rxringcount, &priv->rx_ring_dma); - - if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { - RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); - return -ENOMEM; - } - - memset(priv->rx_ring, 0, sizeof(*priv->rx_ring) * priv->rxringcount); - priv->rx_idx = 0; - - for (i = 0; i < priv->rxringcount; i++) { - struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); - dma_addr_t *mapping; - entry = &priv->rx_ring[i]; - if (!skb) - return 0; - priv->rx_buf[i] = skb; - mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - - entry->BufferAddress = cpu_to_le32(*mapping); - - entry->Length = priv->rxbuffersize; - entry->OWN = 1; - } - - entry->EOR = 1; - return 0; -} - -static int rtl8192_alloc_tx_desc_ring(struct r8192_priv *priv, - unsigned int prio, unsigned int entries) -{ - tx_desc_819x_pci *ring; - dma_addr_t dma; - int i; - - ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); - if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); - return -ENOMEM; - } - - memset(ring, 0, sizeof(*ring)*entries); - priv->tx_ring[prio].desc = ring; - priv->tx_ring[prio].dma = dma; - priv->tx_ring[prio].idx = 0; - priv->tx_ring[prio].entries = entries; - skb_queue_head_init(&priv->tx_ring[prio].queue); - - for (i = 0; i < entries; i++) - ring[i].NextDescAddress = - cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); - - return 0; -} - -static short rtl8192_pci_initdescring(struct r8192_priv *priv) -{ - u32 ret; - int i; - - ret = rtl8192_alloc_rx_desc_ring(priv); - if (ret) - return ret; - - /* general process for other queue */ - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - ret = rtl8192_alloc_tx_desc_ring(priv, i, priv->txringcount); - if (ret) - goto err_free_rings; - } - - return 0; - -err_free_rings: - rtl8192_free_rx_ring(priv); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - if (priv->tx_ring[i].desc) - rtl8192_free_tx_ring(priv, i); - return 1; -} - -static void rtl8192_pci_resetdescring(struct r8192_priv *priv) -{ - int i; - - /* force the rx_idx to the first one */ - if(priv->rx_ring) { - rx_desc_819x_pci *entry = NULL; - for (i = 0; i < priv->rxringcount; i++) { - entry = &priv->rx_ring[i]; - entry->OWN = 1; - } - priv->rx_idx = 0; - } - - /* after reset, release previous pending packet, and force the - * tx idx to the first one */ - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if (priv->tx_ring[i].desc) { - struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; - - while (skb_queue_len(&ring->queue)) { - tx_desc_819x_pci *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); - - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - ring->idx = 0; - } - } -} - -static void rtl8192_link_change(struct ieee80211_device *ieee) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - if (ieee->state == IEEE80211_LINKED) - { - rtl8192_net_update(priv); - rtl8192_update_ratr_table(priv); - - //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) - EnableHWSecurityConfig8192(priv); - } - else - { - write_nic_byte(priv, 0x173, 0); - } - - rtl8192_update_msr(priv); - - // 2007/10/16 MH MAC Will update TSF according to all received beacon, so we have - // // To set CBSSID bit when link with any AP or STA. - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { - u32 reg = 0; - reg = read_nic_dword(priv, RCR); - if (priv->ieee80211->state == IEEE80211_LINKED) - priv->ReceiveConfig = reg |= RCR_CBSSID; - else - priv->ReceiveConfig = reg &= ~RCR_CBSSID; - write_nic_dword(priv, RCR, reg); - } -} - - -static const struct ieee80211_qos_parameters def_qos_parameters = { - {3,3,3,3},/* cw_min */ - {7,7,7,7},/* cw_max */ - {2,2,2,2},/* aifs */ - {0,0,0,0},/* flags */ - {0,0,0,0} /* tx_op_limit */ -}; - -static void rtl8192_update_beacon(struct work_struct * work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); - struct ieee80211_device* ieee = priv->ieee80211; - struct ieee80211_network* net = &ieee->current_network; - - if (ieee->pHTInfo->bCurrentHTSupport) - HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; - rtl8192_update_cap(priv, net->capability); -} - -/* -* background support to run QoS activate functionality -*/ -static const int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; -static void rtl8192_qos_activate(struct work_struct * work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); - struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; - u8 mode = priv->ieee80211->current_network.mode; - u8 u1bAIFS; - u32 u4bAcParam; - int i; - - mutex_lock(&priv->mutex); - if(priv->ieee80211->state != IEEE80211_LINKED) - goto success; - RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); - /* It better set slot time at first */ - /* For we just support b/g mode at present, let the slot time at 9/20 selection */ - /* update the ac parameter to related registers */ - for(i = 0; i < QOS_QUEUE_NUM; i++) { - //Mode G/A: slotTimeTimer = 9; Mode B: 20 - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); - write_nic_dword(priv, WDCAPARA_ADD[i], u4bAcParam); - } - -success: - mutex_unlock(&priv->mutex); -} - -static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, - int active_network, - struct ieee80211_network *network) -{ - int ret = 0; - u32 size = sizeof(struct ieee80211_qos_parameters); - - if(priv->ieee80211->state !=IEEE80211_LINKED) - return ret; - - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) - return ret; - - if (network->flags & NETWORK_HAS_QOS_MASK) { - if (active_network && - (network->flags & NETWORK_HAS_QOS_PARAMETERS)) - network->qos_data.active = network->qos_data.supported; - - if ((network->qos_data.active == 1) && (active_network == 1) && - (network->flags & NETWORK_HAS_QOS_PARAMETERS) && - (network->qos_data.old_param_count != - network->qos_data.param_count)) { - network->qos_data.old_param_count = - network->qos_data.param_count; - queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE (COMP_QOS, "QoS parameters change call " - "qos_activate\n"); - } - } else { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &def_qos_parameters, size); - - if ((network->qos_data.active == 1) && (active_network == 1)) { - queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); - } - network->qos_data.active = 0; - network->qos_data.supported = 0; - } - - return 0; -} - -/* handle manage frame frame beacon and probe response */ -static int rtl8192_handle_beacon(struct ieee80211_device *ieee, - struct ieee80211_beacon * beacon, - struct ieee80211_network * network) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - rtl8192_qos_handle_probe_response(priv,1,network); - - queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); - return 0; - -} - -/* - * handling the beaconing responses. if we get different QoS setting - * off the network from the associated setting, adjust the QoS setting - */ -static int rtl8192_qos_association_resp(struct r8192_priv *priv, - struct ieee80211_network *network) -{ - int ret = 0; - unsigned long flags; - u32 size = sizeof(struct ieee80211_qos_parameters); - int set_qos_param = 0; - - if ((priv == NULL) || (network == NULL)) - return ret; - - if (priv->ieee80211->state != IEEE80211_LINKED) - return ret; - - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) - return ret; - - spin_lock_irqsave(&priv->ieee80211->lock, flags); - if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &network->qos_data.parameters, - sizeof(struct ieee80211_qos_parameters)); - priv->ieee80211->current_network.qos_data.active = 1; - set_qos_param = 1; - /* update qos parameter for current network */ - priv->ieee80211->current_network.qos_data.old_param_count = - priv->ieee80211->current_network.qos_data.param_count; - priv->ieee80211->current_network.qos_data.param_count = - network->qos_data.param_count; - - } else { - memcpy(&priv->ieee80211->current_network.qos_data.parameters, - &def_qos_parameters, size); - priv->ieee80211->current_network.qos_data.active = 0; - priv->ieee80211->current_network.qos_data.supported = 0; - set_qos_param = 1; - } - - spin_unlock_irqrestore(&priv->ieee80211->lock, flags); - - RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __FUNCTION__, - network->flags, priv->ieee80211->current_network.qos_data.active); - if (set_qos_param == 1) - queue_work(priv->priv_wq, &priv->qos_activate); - - return ret; -} - - -static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee, - struct ieee80211_assoc_response_frame *resp, - struct ieee80211_network *network) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - rtl8192_qos_association_resp(priv, network); - return 0; -} - - -/* updateRATRTabel for MCS only. Basic rate is not implemented. */ -static void rtl8192_update_ratr_table(struct r8192_priv* priv) -{ - struct ieee80211_device* ieee = priv->ieee80211; - u8* pMcsRate = ieee->dot11HTOperationalRateSet; - u32 ratr_value = 0; - u8 rate_index = 0; - - rtl8192_config_rate(priv, (u16*)(&ratr_value)); - ratr_value |= (*(u16*)(pMcsRate)) << 12; - - switch (ieee->mode) - { - case IEEE_A: - ratr_value &= 0x00000FF0; - break; - case IEEE_B: - ratr_value &= 0x0000000F; - break; - case IEEE_G: - ratr_value &= 0x00000FF7; - break; - case IEEE_N_24G: - case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC - ratr_value &= 0x0007F007; - else{ - if (priv->rf_type == RF_1T2R) - ratr_value &= 0x000FF007; - else - ratr_value &= 0x0F81F007; - } - break; - default: - break; - } - ratr_value &= 0x0FFFFFFF; - if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ - ratr_value |= 0x80000000; - }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ - ratr_value |= 0x80000000; - } - write_nic_dword(priv, RATR0+rate_index*4, ratr_value); - write_nic_byte(priv, UFWP, 1); -} - -static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee) -{ - return !(ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))); -} - -static void rtl8192_refresh_supportrate(struct r8192_priv* priv) -{ - struct ieee80211_device* ieee = priv->ieee80211; - //we donot consider set support rate for ABG mode, only HT MCS rate is set here. - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) - { - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); - } - else - memset(ieee->Regdot11HTOperationalRateSet, 0, 16); -} - -static u8 rtl8192_getSupportedWireleeMode(void) -{ - return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B); -} - -static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - u8 bSupportMode = rtl8192_getSupportedWireleeMode(); - - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0)) - { - if(bSupportMode & WIRELESS_MODE_N_24G) - { - wireless_mode = WIRELESS_MODE_N_24G; - } - else if(bSupportMode & WIRELESS_MODE_N_5G) - { - wireless_mode = WIRELESS_MODE_N_5G; - } - else if((bSupportMode & WIRELESS_MODE_A)) - { - wireless_mode = WIRELESS_MODE_A; - } - else if((bSupportMode & WIRELESS_MODE_G)) - { - wireless_mode = WIRELESS_MODE_G; - } - else if((bSupportMode & WIRELESS_MODE_B)) - { - wireless_mode = WIRELESS_MODE_B; - } - else{ - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode); - wireless_mode = WIRELESS_MODE_B; - } - } - priv->ieee80211->mode = wireless_mode; - - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) - priv->ieee80211->pHTInfo->bEnableHT = 1; - else - priv->ieee80211->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); - rtl8192_refresh_supportrate(priv); -} - -static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee) -{ - return ieee->bHalfWirelessN24GMode; -} - -static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee) -{ - int i=0; - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - for (i=0; i<=MGNT_QUEUE; i++) - { - if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) - continue; - if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ - printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); - return 0; - } - } - return 1; -} - -static void rtl8192_hw_sleep_down(struct r8192_priv *priv) -{ - MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS); -} - -static void rtl8192_hw_wakeup(struct ieee80211_device *ieee) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS); -} - -static void rtl8192_hw_wakeup_wq (struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); - - rtl8192_hw_wakeup(ieee); -} - -#define MIN_SLEEP_TIME 50 -#define MAX_SLEEP_TIME 10000 -static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - u32 tmp; - u32 rb = jiffies; - - // Writing HW register with 0 equals to disable - // the timer, that is not really what we want - // - tl -= MSECS(8+16+7); - - // If the interval in witch we are requested to sleep is too - // short then give up and remain awake - // when we sleep after send null frame, the timer will be too short to sleep. - // - if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); - return; - } - - if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); - return; - } - - tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work(priv->ieee80211->wq, - &priv->ieee80211->hw_wakeup_wq,tmp); - - rtl8192_hw_sleep_down(priv); -} - -static void rtl8192_init_priv_variable(struct r8192_priv *priv) -{ - u8 i; - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - // Default Halt the NIC if RF is OFF. - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_CLK_REQ; - pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; - pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; - pPSC->bLeisurePs = true; - priv->ieee80211->RegMaxLPSAwakeIntvl = 5; - priv->bHwRadioOff = false; - - priv->being_init_adapter = false; - priv->txringcount = 64;//32; - priv->rxbuffersize = 9100;//2048;//1024; - priv->rxringcount = MAX_RX_COUNT;//64; - priv->chan = 1; //set to channel 1 - priv->RegWirelessMode = WIRELESS_MODE_AUTO; - priv->RegChannelPlan = 0xf; - priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->ieee_up=0; - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->promisc = (priv->ieee80211->dev->flags & IFF_PROMISC) ? 1:0; - priv->bcck_in_ch14 = false; - priv->CCKPresentAttentuation = 0; - priv->rfa_txpowertrackingindex = 0; - priv->rfc_txpowertrackingindex = 0; - priv->CckPwEnl = 6; - //added by amy for silent reset - priv->ResetProgress = RESET_TYPE_NORESET; - priv->bForcedSilentReset = 0; - priv->bDisableNormalResetCheck = false; - priv->force_reset = false; - //added by amy for power save - priv->RfOffReason = 0; - priv->bHwRfOffAction = 0; - priv->PowerSaveControl.bInactivePs = true; - priv->PowerSaveControl.bIPSModeBackup = false; - - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;/* | - IEEE_SOFTMAC_BEACONS;*///added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8192_start_beacon; - priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon; - priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; - priv->ieee80211->set_chan = rtl8192_set_chan; - priv->ieee80211->link_change = rtl8192_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume; - priv->ieee80211->init_wmmparam_flag = 0; - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc; - priv->ieee80211->tx_headroom = sizeof(TX_FWINFO_8190PCI); - priv->ieee80211->qos_support = 1; - priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; - priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; - priv->ieee80211->handle_beacon = rtl8192_handle_beacon; - - priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup; - priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep; - priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty; - priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8190Pci; - priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; - priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xPci; - - priv->ieee80211->InitialGainHandler = InitialGain819xPci; - -#ifdef ENABLE_IPS - priv->ieee80211->ieee80211_ips_leave_wq = ieee80211_ips_leave_wq; - priv->ieee80211->ieee80211_ips_leave = ieee80211_ips_leave; -#endif -#ifdef ENABLE_LPS - priv->ieee80211->LeisurePSLeave = LeisurePSLeave; -#endif - - priv->ieee80211->SetHwRegHandler = rtl8192e_SetHwReg; - priv->ieee80211->rtllib_ap_sec_type = rtl8192e_ap_sec_type; - - priv->ShortRetryLimit = 0x30; - priv->LongRetryLimit = 0x30; - - priv->ReceiveConfig = RCR_ADD3 | - RCR_AMF | RCR_ADF | //accept management/data - RCR_AICV | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. - RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - RCR_AAP | ((u32)7<pFirmware = vzalloc(sizeof(rt_firmware)); - - /* rx related queue */ - skb_queue_head_init(&priv->skb_queue); - - /* Tx related queue */ - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]); - } - for(i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]); - } - priv->rf_set_chan = rtl8192_phy_SwChnl; -} - -static void rtl8192_init_priv_lock(struct r8192_priv* priv) -{ - spin_lock_init(&priv->irq_th_lock); - spin_lock_init(&priv->rf_ps_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_sem,1); - mutex_init(&priv->mutex); -} - -/* init tasklet and wait_queue here */ -#define DRV_NAME "wlan0" -static void rtl8192_init_priv_task(struct r8192_priv *priv) -{ - priv->priv_wq = create_workqueue(DRV_NAME); - -#ifdef ENABLE_IPS - INIT_WORK(&priv->ieee80211->ips_leave_wq, IPSLeave_wq); -#endif - - INIT_WORK(&priv->reset_wq, rtl8192_restart); - INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); - INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); - INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); - INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); - INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); - INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8192_hw_wakeup_wq); - - tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, - (unsigned long) priv); - tasklet_init(&priv->irq_tx_tasklet, rtl8192_irq_tx_tasklet, - (unsigned long) priv); - tasklet_init(&priv->irq_prepare_beacon_tasklet, rtl8192_prepare_beacon, - (unsigned long) priv); -} - -static void rtl8192_get_eeprom_size(struct r8192_priv *priv) -{ - u16 curCR = 0; - RT_TRACE(COMP_INIT, "===========>%s()\n", __FUNCTION__); - curCR = read_nic_dword(priv, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); - //whether need I consider BIT5? - priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EPROM_93c56 : EPROM_93c46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype); -} - -/* - * Adapter->EEPROMAddressSize should be set before this function call. - * EEPROM address size can be got through GetEEPROMSize8185() - */ -static void rtl8192_read_eeprom_info(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - u8 tempval; - u8 ICVer8192, ICVer8256; - u16 i,usValue, IC_Version; - u16 EEPROMId; - u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; - RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); - - - // TODO: I don't know if we need to apply EF function to EEPROM read function - - //2 Read EEPROM ID to make sure autoload is success - EEPROMId = eprom_read(priv, 0); - if( EEPROMId != RTL8190_EEPROM_ID ) - { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); - priv->AutoloadFailFlag=true; - } - else - { - priv->AutoloadFailFlag=false; - } - - // - // Assign Chip Version ID - // - // Read IC Version && Channel Plan - if(!priv->AutoloadFailFlag) - { - // VID, PID - priv->eeprom_vid = eprom_read(priv, (EEPROM_VID >> 1)); - priv->eeprom_did = eprom_read(priv, (EEPROM_DID >> 1)); - - usValue = eprom_read(priv, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; - priv->eeprom_CustomerID = (u8)( usValue & 0xff); - usValue = eprom_read(priv, (EEPROM_ICVersion_ChannelPlan>>1)); - priv->eeprom_ChannelPlan = usValue&0xff; - IC_Version = ((usValue&0xff00)>>8); - - ICVer8192 = (IC_Version&0xf); //bit0~3; 1:A cut, 2:B cut, 3:C cut... - ICVer8256 = ((IC_Version&0xf0)>>4);//bit4~6, bit7 reserved for other RF chip; 1:A cut, 2:B cut, 3:C cut... - RT_TRACE(COMP_INIT, "ICVer8192 = 0x%x\n", ICVer8192); - RT_TRACE(COMP_INIT, "ICVer8256 = 0x%x\n", ICVer8256); - if(ICVer8192 == 0x2) //B-cut - { - if(ICVer8256 == 0x5) //E-cut - priv->card_8192_version= VERSION_8190_BE; - } - - switch(priv->card_8192_version) - { - case VERSION_8190_BD: - case VERSION_8190_BE: - break; - default: - priv->card_8192_version = VERSION_8190_BD; - break; - } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); - } - else - { - priv->card_8192_version = VERSION_8190_BD; - priv->eeprom_vid = 0; - priv->eeprom_did = 0; - priv->eeprom_CustomerID = 0; - priv->eeprom_ChannelPlan = 0; - RT_TRACE(COMP_INIT, "IC Version = 0x%x\n", 0xff); - } - - RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); - RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); - - //2 Read Permanent MAC address - if(!priv->AutoloadFailFlag) - { - for(i = 0; i < 6; i += 2) - { - usValue = eprom_read(priv, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); - *(u16*)(&dev->dev_addr[i]) = usValue; - } - } else { - // when auto load failed, the last address byte set to be a random one. - // added by david woo.2007/11/7 - memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); - } - - RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", dev->dev_addr); - - //2 TX Power Check EEPROM Fail or not - if(priv->card_8192_version > VERSION_8190_BD) { - priv->bTXPowerDataReadFromEEPORM = true; - } else { - priv->bTXPowerDataReadFromEEPORM = false; - } - - // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R - priv->rf_type = RTL819X_DEFAULT_RF_TYPE; - - if(priv->card_8192_version > VERSION_8190_BD) - { - // Read RF-indication and Tx Power gain index diff of legacy to HT OFDM rate. - if(!priv->AutoloadFailFlag) - { - tempval = (eprom_read(priv, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; - priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; // bit[3:0] - - if (tempval&0x80) //RF-indication, bit[7] - priv->rf_type = RF_1T2R; - else - priv->rf_type = RF_2T4R; - } - else - { - priv->EEPROMLegacyHTTxPowerDiff = EEPROM_Default_LegacyHTTxPowerDiff; - } - RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", - priv->EEPROMLegacyHTTxPowerDiff); - - // Read ThermalMeter from EEPROM - if(!priv->AutoloadFailFlag) - { - priv->EEPROMThermalMeter = (u8)(((eprom_read(priv, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); - } - else - { - priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - } - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); - //vivi, for tx power track - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; - - if(priv->epromtype == EPROM_93c46) - { - // Read antenna tx power offset of B/C/D to A and CrystalCap from EEPROM - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (EEPROM_TxPwDiff_CrystalCap>>1)); - priv->EEPROMAntPwDiff = (usValue&0x0fff); - priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); - - // - // Get per-channel Tx Power Level - // - for(i=0; i<14; i+=2) - { - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); - } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); - } - for(i=0; i<14; i+=2) - { - if(!priv->AutoloadFailFlag) - { - usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); - } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); - } - } - - // - // Update HAL variables. - // - if(priv->epromtype == EPROM_93c46) - { - for(i=0; i<14; i++) - { - priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; - } - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - // Antenna B gain offset to antenna A, bit0~3 - priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); - // Antenna C gain offset to antenna A, bit4~7 - priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); - // Antenna D gain offset to antenna A, bit8~11 - priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); - // CrystalCap, bit12~15 - priv->CrystalCap = priv->EEPROMCrystalCap; - // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - else if(priv->epromtype == EPROM_93c56) - { - for(i=0; i<3; i++) // channel 1~3 use the same Tx Power Level. - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; - } - for(i=3; i<9; i++) // channel 4~9 use the same Tx Power Level - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; - } - for(i=9; i<14; i++) // channel 10~14 use the same Tx Power Level - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; - } - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); - for(i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = 0; - priv->AntennaTxPwDiff[1] = 0; - priv->AntennaTxPwDiff[2] = 0; - priv->CrystalCap = priv->EEPROMCrystalCap; - // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - } - - if(priv->rf_type == RF_1T2R) - { - RT_TRACE(COMP_INIT, "1T2R config\n"); - } - else if (priv->rf_type == RF_2T4R) - { - RT_TRACE(COMP_INIT, "2T4R config\n"); - } - - // 2008/01/16 MH We can only know RF type in the function. So we have to init - // DIG RATR table again. - init_rate_adaptive(priv); - - //1 Make a copy for following variables and we can change them if we want - - if(priv->RegChannelPlan == 0xf) - { - priv->ChannelPlan = priv->eeprom_ChannelPlan; - } - else - { - priv->ChannelPlan = priv->RegChannelPlan; - } - - // - // Used PID and DID to Set CustomerID - // - if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) - { - priv->CustomerID = RT_CID_DLINK; - } - - switch(priv->eeprom_CustomerID) - { - case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; - break; - case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; - break; - case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; - break; - case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; - break; - case EEPROM_CID_TOSHIBA: // Merge by Jacken, 2008/01/31 - priv->CustomerID = RT_CID_TOSHIBA; - if(priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; - else - priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); - break; - case EEPROM_CID_Nettronix: - priv->CustomerID = RT_CID_Nettronix; - break; - case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; - break; - case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; - break; - - case EEPROM_CID_WHQL: - break; - default: - // value from RegCustomerID - break; - } - - //Avoid the channel plan array overflow, by Bruce, 2007-08-27. - if(priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) - priv->ChannelPlan = 0; //FCC - - if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) - priv->ieee80211->bSupportRemoteWakeUp = true; - else - priv->ieee80211->bSupportRemoteWakeUp = false; - - - RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); - RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); -} - - -static short rtl8192_get_channel_map(struct r8192_priv *priv) -{ -#ifdef ENABLE_DOT11D - if(priv->ChannelPlan> COUNTRY_CODE_GLOBAL_DOMAIN){ - printk("rtl8180_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan= 0; - } - RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); - - rtl819x_set_channel_map(priv->ChannelPlan, priv); -#else - int ch,i; - //Set Default Channel Plan - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - priv->ChannelPlan= 0;//hikaru - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } -#endif - return 0; -} - -static short rtl8192_init(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - - memset(&(priv->stats),0,sizeof(struct Stats)); - rtl8192_init_priv_variable(priv); - rtl8192_init_priv_lock(priv); - rtl8192_init_priv_task(priv); - rtl8192_get_eeprom_size(priv); - rtl8192_read_eeprom_info(priv); - rtl8192_get_channel_map(priv); - init_hal_dm(priv); - init_timer(&priv->watch_dog_timer); - priv->watch_dog_timer.data = (unsigned long)priv; - priv->watch_dog_timer.function = watch_dog_timer_callback; - if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) { - printk("Error allocating IRQ %d",dev->irq); - return -1; - }else{ - priv->irq=dev->irq; - printk("IRQ %d",dev->irq); - } - if (rtl8192_pci_initdescring(priv) != 0){ - printk("Endopoints initialization failed"); - return -1; - } - - return 0; -} - -/* - * Actually only set RRSR, RATR and BW_OPMODE registers - * not to do all the hw config as its name says - * This part need to modified according to the rate set we filtered - */ -static void rtl8192_hwconfig(struct r8192_priv *priv) -{ - u32 regRATR = 0, regRRSR = 0; - u8 regBwOpMode = 0, regTmp = 0; - -// Set RRSR, RATR, and BW_OPMODE registers - // - switch (priv->ieee80211->mode) - { - case WIRELESS_MODE_B: - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK; - regRRSR = RATE_ALL_CCK; - break; - case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; - regRATR = RATE_ALL_OFDM_AG; - regRRSR = RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_G: - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_AUTO: - case WIRELESS_MODE_N_24G: - // It support CCK rate by default. - // CCK rate will be filtered out only when associated AP does not support it. - regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - break; - case WIRELESS_MODE_N_5G: - regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_OFDM_AG; - break; - } - - write_nic_byte(priv, BW_OPMODE, regBwOpMode); - { - u32 ratr_value = 0; - ratr_value = regRATR; - if (priv->rf_type == RF_1T2R) - { - ratr_value &= ~(RATE_ALL_OFDM_2SS); - } - write_nic_dword(priv, RATR0, ratr_value); - write_nic_byte(priv, UFWP, 1); - } - regTmp = read_nic_byte(priv, 0x313); - regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); - write_nic_dword(priv, RRSR, regRRSR); - - // - // Set Retry Limit here - // - write_nic_word(priv, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | - priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - // Set Contention Window here - - // Set Tx AGC - - // Set Tx Antenna including Feedback control - - // Set Auto Rate fallback control - - -} - - -static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv) -{ - struct net_device *dev = priv->ieee80211->dev; - u32 ulRegRead; - RT_STATUS rtStatus = RT_STATUS_SUCCESS; - u8 tmpvalue; - u8 ICVersion,SwitchingRegulatorOutput; - bool bfirmwareok = true; - u32 tmpRegA, tmpRegC, TempCCk; - int i =0; - - RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__); - priv->being_init_adapter = true; - rtl8192_pci_resetdescring(priv); - // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W. - priv->Rf_Mode = RF_OP_By_SW_3wire; - - //dPLL on - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - write_nic_byte(priv, ANAPAR, 0x37); - // Accordign to designer's explain, LBUS active will never > 10ms. We delay 10ms - // Joseph increae the time to prevent firmware download fail - mdelay(500); - } - - //PlatformSleepUs(10000); - // For any kind of InitializeAdapter process, we shall use system now!! - priv->pFirmware->firmware_status = FW_STATUS_0_INIT; - - // - //3 //Config CPUReset Register - //3// - //3 Firmware Reset Or Not - ulRegRead = read_nic_dword(priv, CPU_GEN); - if(priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - { //called from MPInitialized. do nothing - ulRegRead |= CPU_GEN_SYSTEM_RESET; - }else if(priv->pFirmware->firmware_status == FW_STATUS_5_READY) - ulRegRead |= CPU_GEN_FIRMWARE_RESET; // Called from MPReset - else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status); - - write_nic_dword(priv, CPU_GEN, ulRegRead); - - //3// - //3 //Fix the issue of E-cut high temperature issue - //3// - // TODO: E cut only - ICVersion = read_nic_byte(priv, IC_VERRSION); - if(ICVersion >= 0x4) //E-cut only - { - // HW SD suggest that we should not wirte this register too often, so driver - // should readback this register. This register will be modified only when - // power on reset - SwitchingRegulatorOutput = read_nic_byte(priv, SWREGULATOR); - if(SwitchingRegulatorOutput != 0xb8) - { - write_nic_byte(priv, SWREGULATOR, 0xa8); - mdelay(1); - write_nic_byte(priv, SWREGULATOR, 0xb8); - } - } - - //3// - //3// Initialize BB before MAC - //3// - RT_TRACE(COMP_INIT, "BB Config Start!\n"); - rtStatus = rtl8192_BBConfig(priv); - if(rtStatus != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR, "BB Config failed\n"); - return rtStatus; - } - RT_TRACE(COMP_INIT,"BB Config Finished!\n"); - - //3//Set Loopback mode or Normal mode - //3// - //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings - // because setting of System_Reset bit reset MAC to default transmission mode. - //Loopback mode or not - priv->LoopbackMode = RTL819X_NO_LOOPBACK; - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - ulRegRead = read_nic_dword(priv, CPU_GEN); - if(priv->LoopbackMode == RTL819X_NO_LOOPBACK) - { - ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); - } - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) - { - ulRegRead |= CPU_CCK_LOOPBACK; - } - else - { - RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); - } - - //2008.06.03, for WOL - //ulRegRead &= (~(CPU_GEN_GPIO_UART)); - write_nic_dword(priv, CPU_GEN, ulRegRead); - - // 2006.11.29. After reset cpu, we sholud wait for a second, otherwise, it may fail to write registers. Emily - udelay(500); - } - //3Set Hardware(Do nothing now) - rtl8192_hwconfig(priv); - //2======================================================= - // Common Setting for all of the FPGA platform. (part 1) - //2======================================================= - // If there is changes, please make sure it applies to all of the FPGA version - //3 Turn on Tx/Rx - write_nic_byte(priv, CMDR, CR_RE|CR_TE); - - //2Set Tx dma burst - write_nic_byte(priv, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); - write_nic_word(priv, MAC4, ((u16*)(dev->dev_addr + 4))[0]); - //set RCR - write_nic_dword(priv, RCR, priv->ReceiveConfig); - - //3 Initialize Number of Reserved Pages in Firmware Queue - write_nic_dword(priv, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) - rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode); - //----------------------------------------------------------------------------- - // Set up security related. 070106, by rcnjko: - // 1. Clear all H/W keys. - // 2. Enable H/W encryption/decryption. - //----------------------------------------------------------------------------- - CamResetAllEntry(priv); - { - u8 SECR_value = 0x0; - SECR_value |= SCR_TxEncEnable; - SECR_value |= SCR_RxDecEnable; - SECR_value |= SCR_NoSKMC; - write_nic_byte(priv, SECR, SECR_value); - } - //3Beacon related - write_nic_word(priv, ATIMWND, 2); - write_nic_word(priv, BCN_INTERVAL, 100); - for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { - rtl8192_phy_getTxPower(priv); - rtl8192_phy_setTxPower(priv, priv->chan); - } - - //if D or C cut - tmpvalue = read_nic_byte(priv, IC_VERRSION); - priv->IC_Cut = tmpvalue; - RT_TRACE(COMP_INIT, "priv->IC_Cut = 0x%x\n", priv->IC_Cut); - if(priv->IC_Cut >= IC_VersionCut_D) - { - //pHalData->bDcut = TRUE; - if(priv->IC_Cut == IC_VersionCut_D) - RT_TRACE(COMP_INIT, "D-cut\n"); - if(priv->IC_Cut == IC_VersionCut_E) - { - RT_TRACE(COMP_INIT, "E-cut\n"); - // HW SD suggest that we should not wirte this register too often, so driver - // should readback this register. This register will be modified only when - // power on reset - } - } - else - { - //pHalData->bDcut = FALSE; - RT_TRACE(COMP_INIT, "Before C-cut\n"); - } - - //Firmware download - RT_TRACE(COMP_INIT, "Load Firmware!\n"); - bfirmwareok = init_firmware(priv); - if(bfirmwareok != true) { - rtStatus = RT_STATUS_FAILURE; - return rtStatus; - } - RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); - - //RF config - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - RT_TRACE(COMP_INIT, "RF Config Started!\n"); - rtStatus = rtl8192_phy_RFConfig(priv); - if(rtStatus != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR, "RF Config failed\n"); - return rtStatus; - } - RT_TRACE(COMP_INIT, "RF Config Finished!\n"); - } - rtl8192_phy_updateInitGain(priv); - - /*---- Set CCK and OFDM Block "ON"----*/ - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn, 0x1); - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bOFDMEn, 0x1); - - //Enable Led - write_nic_byte(priv, 0x87, 0x0); - - //2======================================================= - // RF Power Save - //2======================================================= -#ifdef ENABLE_IPS - -{ - if(priv->RfOffReason > RF_CHANGE_BY_PS) - { // H/W or S/W RF OFF before sleep. - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__,priv->RfOffReason); - MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); - } - else if(priv->RfOffReason >= RF_CHANGE_BY_IPS) - { // H/W or S/W RF OFF before sleep. - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__, priv->RfOffReason); - MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); - } - else - { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__FUNCTION__); - priv->eRFPowerState = eRfOn; - priv->RfOffReason = 0; - } -} -#endif - // We can force firmware to do RF-R/W - if(priv->ieee80211->FwRWRF) - priv->Rf_Mode = RF_OP_By_FW; - else - priv->Rf_Mode = RF_OP_By_SW_3wire; - - if(priv->ResetProgress == RESET_TYPE_NORESET) - { - dm_initialize_txpower_tracking(priv); - - if(priv->IC_Cut >= IC_VersionCut_D) - { - tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); - tmpRegC = rtl8192_QueryBBReg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord); - for(i = 0; itxbbgain_table[i].txbbgain_value) - { - priv->rfa_txpowertrackingindex= (u8)i; - priv->rfa_txpowertrackingindex_real= (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; - break; - } - } - - TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); - - for(i=0 ; icck_txbbgain_table[i].ccktxbb_valuearray[0]) - { - priv->CCKPresentAttentuation_20Mdefault =(u8) i; - break; - } - } - priv->CCKPresentAttentuation_40Mdefault = 0; - priv->CCKPresentAttentuation_difference = 0; - priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); - priv->btxpower_tracking = FALSE;//TEMPLY DISABLE - } - } - - rtl8192_irq_enable(priv); - priv->being_init_adapter = false; - return rtStatus; - -} - -static void rtl8192_prepare_beacon(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - struct sk_buff *skb; - cb_desc *tcb_desc; - - skb = ieee80211_get_beacon(priv->ieee80211); - tcb_desc = (cb_desc *)(skb->cb + 8); - /* prepare misc info for the beacon xmit */ - tcb_desc->queue_index = BEACON_QUEUE; - /* IBSS does not support HT yet, use 1M defaultly */ - tcb_desc->data_rate = 2; - tcb_desc->RATRIndex = 7; - tcb_desc->bTxDisableRateFallBack = 1; - tcb_desc->bTxUseDriverAssingedRate = 1; - - skb_push(skb, priv->ieee80211->tx_headroom); - if(skb){ - rtl8192_tx(priv, skb); - } -} - - -/* - * configure registers for beacon tx and enables it via - * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might - * be used to stop beacon transmission - */ -static void rtl8192_start_beacon(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - struct ieee80211_network *net = &priv->ieee80211->current_network; - u16 BcnTimeCfg = 0; - u16 BcnCW = 6; - u16 BcnIFS = 0xf; - - DMESG("Enabling beacon TX"); - rtl8192_irq_disable(priv); - //rtl8192_beacon_tx_enable(dev); - - /* ATIM window */ - write_nic_word(priv, ATIMWND, 2); - - /* Beacon interval (in unit of TU) */ - write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); - - /* - * DrvErlyInt (in unit of TU). - * (Time to send interrupt to notify driver to c - * hange beacon content) - * */ - write_nic_word(priv, BCN_DRV_EARLY_INT, 10); - - /* - * BcnDMATIM(in unit of us). - * Indicates the time before TBTT to perform beacon queue DMA - * */ - write_nic_word(priv, BCN_DMATIME, 256); - - /* - * Force beacon frame transmission even after receiving - * beacon frame from other ad hoc STA - * */ - write_nic_byte(priv, BCN_ERR_THRESH, 100); - - /* Set CW and IFS */ - BcnTimeCfg |= BcnCW<RxCounter); - // If rssi is small, we should check rx for long time because of bad rx. - // or maybe it will continuous silent reset every 2 seconds. - priv->rx_chk_cnt++; - if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) - { - priv->rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ - } - else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && - ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) || - (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) ) - - { - if(priv->rx_chk_cnt < 2) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbCurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbundecorated_smoothed_pwdb >= VeryLowRSSI) - { - if(priv->rx_chk_cnt < 4) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - else - { - if(priv->rx_chk_cnt < 8) - { - return bStuck; - } - else - { - priv->rx_chk_cnt = 0; - } - } - if(priv->RxCounter==RegRxCounter) - bStuck = TRUE; - - priv->RxCounter = RegRxCounter; - - return bStuck; -} - -static RESET_TYPE RxCheckStuck(struct r8192_priv *priv) -{ - - if(HalRxCheckStuck8190Pci(priv)) - { - RT_TRACE(COMP_RESET, "RxStuck Condition\n"); - return RESET_TYPE_SILENT; - } - - return RESET_TYPE_NORESET; -} - -static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv) -{ - RESET_TYPE RxResetType = RESET_TYPE_NORESET; - RT_RF_POWER_STATE rfState; - - rfState = priv->eRFPowerState; - - if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { - /* - * If driver is in the status of firmware download failure, - * driver skips RF initialization and RF is in turned off state. - * Driver should check whether Rx stuck and do silent reset. And - * if driver is in firmware download failure status, driver - * should initialize RF in the following silent reset procedure - * - * Driver should not check RX stuck in IBSS mode because it is - * required to set Check BSSID in order to send beacon, however, - * if check BSSID is set, STA cannot hear any packet a all. - */ - RxResetType = RxCheckStuck(priv); - } - - RT_TRACE(COMP_RESET, "%s(): RxResetType is %d\n", __FUNCTION__, RxResetType); - - return RxResetType; -} - -#ifdef ENABLE_IPS -static void InactivePsWorkItemCallback(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() --------->\n"); - // - // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem - // is really scheduled. - // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the - // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing - // blocks the IPS procedure of switching RF. - // By Bruce, 2007-12-25. - // - pPSC->bSwRfProcessing = TRUE; - - RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", - pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); - - - MgntActSet_RF_State(priv, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); - - // - // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20. - // - pPSC->bSwRfProcessing = FALSE; - RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <---------\n"); -} - -#ifdef ENABLE_LPS -/* Change current and default preamble mode. */ -bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode) -{ - - // Currently, we do not change power save mode on IBSS mode. - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { - return false; - } - - // - // If we make HW to fill up the PwrMgt bit for us, - // some AP will not response to our mgnt frames with PwrMgt bit set, - // e.g. cannot associate the AP. - // So I commented out it. 2005.02.16, by rcnjko. - // -// // Change device's power save mode. -// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); - - // Update power save mode configured. - //RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__FUNCTION__,rtPsMode); - if(!priv->ps_force) { - priv->ieee80211->ps = rtPsMode; - } - - // Awake immediately - if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED) - { - // Notify the AP we awke. - rtl8192_hw_wakeup(priv->ieee80211); - priv->ieee80211->sta_sleep = 0; - - spin_lock(&priv->ieee80211->mgmt_tx_lock); - printk("LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); - ieee80211_sta_ps_send_null_frame(priv->ieee80211, 0); - spin_unlock(&priv->ieee80211->mgmt_tx_lock); - } - - return true; -} - -/* Enter the leisure power save mode. */ -void LeisurePSEnter(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) && - (priv->ieee80211->state == IEEE80211_LINKED)) || - (priv->ieee80211->iw_mode == IW_MODE_ADHOC) || - (priv->ieee80211->iw_mode == IW_MODE_MASTER)) - return; - - if (pPSC->bLeisurePs) - { - // Idle for a while if we connect to AP a while ago. - if(pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) // 4 Sec - { - - if(priv->ieee80211->ps == IEEE80211_PS_DISABLED) - { - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); - - } - } - else - pPSC->LpsIdleCount++; - } -} - - -/* Leave leisure power save mode. */ -void LeisurePSLeave(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - if (pPSC->bLeisurePs) - { - if(priv->ieee80211->ps != IEEE80211_PS_DISABLED) - { - // move to lps_wakecomplete() - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); - - } - } -} -#endif - - -/* Enter the inactive power save mode. RF will be off */ -void IPSEnter(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - RT_RF_POWER_STATE rtState; - - if (pPSC->bInactivePs) - { - rtState = priv->eRFPowerState; - // - // Added by Bruce, 2007-12-25. - // Do not enter IPS in the following conditions: - // (1) RF is already OFF or Sleep - // (2) bSwRfProcessing (indicates the IPS is still under going) - // (3) Connectted (only disconnected can trigger IPS) - // (4) IBSS (send Beacon) - // (5) AP mode (send Beacon) - // - if (rtState == eRfOn && !pPSC->bSwRfProcessing - && (priv->ieee80211->state != IEEE80211_LINKED) ) - { - RT_TRACE(COMP_RF,"IPSEnter(): Turn off RF.\n"); - pPSC->eInactivePowerState = eRfOff; -// queue_work(priv->priv_wq,&(pPSC->InactivePsWorkItem)); - InactivePsWorkItemCallback(priv); - } - } -} - -// -// Description: -// Leave the inactive power save mode, RF will be on. -// 2007.08.17, by shien chang. -// -void IPSLeave(struct r8192_priv *priv) -{ - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - RT_RF_POWER_STATE rtState; - - if (pPSC->bInactivePs) - { - rtState = priv->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_POWER, "IPSLeave(): Turn on RF.\n"); - pPSC->eInactivePowerState = eRfOn; - InactivePsWorkItemCallback(priv); - } - } -} - -void IPSLeave_wq(struct work_struct *work) -{ - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq); - struct net_device *dev = ieee->dev; - - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -} - -void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - RT_RF_POWER_STATE rtState; - rtState = priv->eRFPowerState; - - if (priv->PowerSaveControl.bInactivePs){ - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - return; - } - else{ - printk("=========>%s(): IPSLeave\n",__FUNCTION__); - queue_work(priv->ieee80211->wq,&priv->ieee80211->ips_leave_wq); - } - } - } -} -//added by amy 090331 end -void ieee80211_ips_leave(struct ieee80211_device *ieee80211) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - down(&ieee80211->ips_sem); - IPSLeave(priv); - up(&ieee80211->ips_sem); -} -#endif - -static void rtl819x_update_rxcounts( - struct r8192_priv *priv, - u32* TotalRxBcnNum, - u32* TotalRxDataNum -) -{ - u16 SlotIndex; - u8 i; - - *TotalRxBcnNum = 0; - *TotalRxDataNum = 0; - - SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); - priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; - priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; - for( i=0; iieee80211->LinkDetectInfo.SlotNum; i++ ){ - *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; - *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; - } -} - - -static void rtl819x_watchdog_wqcallback(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); - struct ieee80211_device* ieee = priv->ieee80211; - RESET_TYPE ResetType = RESET_TYPE_NORESET; - bool bBusyTraffic = false; - bool bEnterPS = false; - - if ((!priv->up) || priv->bHwRadioOff) - return; - - if(!priv->up) - return; - hal_dm_watchdog(priv); -#ifdef ENABLE_IPS - if(ieee->actscanning == false){ - if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) && - (priv->eRFPowerState == eRfOn) && !ieee->is_set_key && - (!ieee->proto_stoppping) && !ieee->wx_set_enc){ - if (priv->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){ - IPSEnter(priv); - } - } - } -#endif - {//to get busy traffic condition - if(ieee->state == IEEE80211_LINKED) - { - if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { - bBusyTraffic = true; - } - -#ifdef ENABLE_LPS - //added by amy for Leisure PS - if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { - bEnterPS= false; - } - else - { - bEnterPS= true; - } - - // LeisurePS only work in infra mode. - if(bEnterPS) - { - LeisurePSEnter(priv->ieee80211); - } - else - { - LeisurePSLeave(priv->ieee80211); - } -#endif - - } - else - { -#ifdef ENABLE_LPS - LeisurePSLeave(priv->ieee80211); -#endif - } - - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - } - - - //added by amy for AP roaming - if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - if((TotalRxBcnNum+TotalRxDataNum) == 0) - { - if (priv->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); - printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); - // Dot11d_Reset(dev); - ieee->state = IEEE80211_ASSOCIATING; - notify_wx_assoc_event(priv->ieee80211); - RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); - ieee->is_roaming = true; - ieee->is_set_key = false; - ieee->link_change(ieee); - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } - } - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - //check if reset the driver - if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && - priv->watchdog_last_time != 1) - { - ResetType = rtl819x_check_reset(priv); - priv->watchdog_check_reset_cnt = 3; - } - if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) - { - priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__FUNCTION__); - return; - } - /* disable silent reset temply 2008.9.11*/ - - if( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) // This is control by OID set in Pomelo - { - priv->watchdog_last_time = 1; - } - else - priv->watchdog_last_time = 0; - - priv->force_reset = false; - priv->bForcedSilentReset = false; - priv->bResetInProgress = false; - RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); - -} - -void watch_dog_timer_callback(unsigned long data) -{ - struct r8192_priv *priv = (struct r8192_priv *) data; - queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); - -} - -static int _rtl8192_up(struct r8192_priv *priv) -{ - RT_STATUS init_status = RT_STATUS_SUCCESS; - struct net_device *dev = priv->ieee80211->dev; - - priv->up=1; - priv->ieee80211->ieee_up=1; - priv->bdisable_nic = false; //YJ,add,091111 - RT_TRACE(COMP_INIT, "Bringing up iface\n"); - - init_status = rtl8192_adapter_start(priv); - if(init_status != RT_STATUS_SUCCESS) - { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); - return -1; - } - RT_TRACE(COMP_INIT, "start adapter finished\n"); - - if (priv->eRFPowerState != eRfOn) - MgntActSet_RF_State(priv, eRfOn, priv->RfOffReason); - - if(priv->ieee80211->state != IEEE80211_LINKED) - ieee80211_softmac_start_protocol(priv->ieee80211); - ieee80211_reset_queue(priv->ieee80211); - watch_dog_timer_callback((unsigned long) priv); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -static int rtl8192_open(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8192_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8192_up(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8192_up(priv); -} - - -static int rtl8192_close(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8192_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8192_down(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - -#ifdef ENABLE_LPS - //LZM for PS-Poll AID issue. 090429 - if(priv->ieee80211->state == IEEE80211_LINKED) - LeisurePSLeave(priv->ieee80211); -#endif - - priv->up=0; - priv->ieee80211->ieee_up = 0; - RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__); -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8192_irq_disable(priv); - rtl8192_cancel_deferred_work(priv); - deinit_hal_dm(priv); - del_timer_sync(&priv->watch_dog_timer); - - ieee80211_softmac_stop_protocol(priv->ieee80211,true); - - rtl8192_halt_adapter(priv, false); - memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list)); - - RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__); - - return 0; -} - - -void rtl8192_commit(struct r8192_priv *priv) -{ - if (priv->up == 0) return ; - - - ieee80211_softmac_stop_protocol(priv->ieee80211,true); - - rtl8192_irq_disable(priv); - rtl8192_halt_adapter(priv, true); - _rtl8192_up(priv); -} - -static void rtl8192_restart(struct work_struct *work) -{ - struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); - - down(&priv->wx_sem); - - rtl8192_commit(priv); - - up(&priv->wx_sem); -} - -static void r8192_set_multicast(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; -} - - -static int r8192_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - up(&priv->wx_sem); - - return 0; -} - -static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw) -{ - struct ieee80211_device *ieee = priv->ieee80211; - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; - u32 key[4]; - - if (ipw->u.crypt.set_tx) { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) { - memcpy(key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(priv); - /* - * We fill both index entry and 4th entry for pairwise - * key as in IPW interface, adhoc will only get here, - * so we need index entry for its default key serching! - */ - setKey(priv, 4, ipw->u.crypt.idx, - ieee->pairwise_key_type, - (u8*)ieee->ap_mac_addr, 0, key); - - /* LEAP WEP will never set this. */ - if (ieee->auth_mode != 2) - setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, - ieee->pairwise_key_type, - (u8*)ieee->ap_mac_addr, 0, key); - } - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && - ieee->pHTInfo->bCurrentHTSupport) { - write_nic_byte(priv, 0x173, 1); /* fix aes bug */ - } - } else { - memcpy(key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } else - ieee->group_key_type = KEY_TYPE_NA; - - if (ieee->group_key_type) { - setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, - ieee->group_key_type, broadcast_addr, 0, key); - } - } -} - -/* based on ipw2200 driver */ -static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - struct iwreq *wrq = (struct iwreq *)rq; - int ret=-1; - struct iw_point *p = &wrq->u.data; - struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer; - - down(&priv->wx_sem); - - - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } - - ipw = kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; - goto out; - } - - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - /* parse here for HW security */ - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) - r8192e_set_hw_key(priv, ipw); - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - kfree(ipw); -out: - up(&priv->wx_sem); - - return ret; -} - -static u8 HwRateToMRate90(bool bIsHT, u8 rate) -{ - u8 ret_rate = 0x02; - - if(!bIsHT) { - switch(rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; - - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; - } - - } else { - switch(rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; - - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; - } - } - - return ret_rate; -} - -/* Record the TSF time stamp when receiving a packet */ -static void UpdateRxPktTimeStamp8190(struct r8192_priv *priv, struct ieee80211_rx_stats *stats) -{ - - if(stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } -} - -static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. -{ - long signal_power; // in dBm. - - // Translate to dBm (x=0.5y-95). - signal_power = (long)((signal_strength_index + 1) >> 1); - signal_power -= 95; - - return signal_power; -} - -/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to - be a local static. Otherwise, it may increase when we return from S3/S4. The - value will be kept in memory or disk. We must delcare the value in adapter - and it will be reinitialized when return from S3/S4. */ -static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats) -{ - bool bcheck = false; - u8 rfpath; - u32 nspatial_stream, tmp_val; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; - //cosa add for beacon rssi smoothing - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; - - struct ieee80211_hdr_3addr *hdr; - u16 sc ; - unsigned int frag,seq; - hdr = (struct ieee80211_hdr_3addr *)buffer; - sc = le16_to_cpu(hdr->seq_ctl); - frag = WLAN_GET_SEQ_FRAG(sc); - seq = WLAN_GET_SEQ_SEQ(sc); - - // - // Check whether we should take the previous packet into accounting - // - if(!pprevious_stats->bIsAMPDU) - { - // if previous packet is not aggregated packet - bcheck = true; - } - - if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) - { - slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; - last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; - priv->stats.slide_rssi_total -= last_rssi; - } - priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; - - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; - if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) - slide_rssi_index = 0; - - // <1> Showed on UI for user, in dbm - tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; - priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); - pcurrent_stats->rssi = priv->stats.signal_strength; - // - // If the previous packet does not match the criteria, neglect it - // - if(!pprevious_stats->bPacketMatchBSSID) - { - if(!pprevious_stats->bToSelfBA) - return; - } - - if(!bcheck) - return; - - // <2> Showed on UI for engineering - // hardware does not provide rssi information for each rf path in CCK - if(!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) - { - for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv, rfpath)) - continue; - RT_TRACE(COMP_DBG, "pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", pprevious_stats->RxMIMOSignalStrength[rfpath]); - //Fixed by Jacken 2008-03-20 - if(priv->stats.rx_rssi_percentage[rfpath] == 0) - { - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; - } - if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) - { - priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); - priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; - } - else - { - priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); - } - RT_TRACE(COMP_DBG, "priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" , priv->stats.rx_rssi_percentage[rfpath]); - } - } - - - // - // Check PWDB. - // - //cosa add for beacon rssi smoothing by average. - if(pprevious_stats->bPacketBeacon) - { - /* record the beacon pwdb to the sliding window. */ - if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) - { - slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; - priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; - // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total); - } - priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; - slide_beacon_adc_pwdb_index++; - if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) - slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; - if(pprevious_stats->RxPWDBAll >= 3) - pprevious_stats->RxPWDBAll -= 3; - } - - RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - pprevious_stats->bIsCCK? "CCK": "OFDM", - pprevious_stats->RxPWDBAll); - - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - if(priv->undecorated_smoothed_pwdb < 0) // initialize - { - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; - } - - if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) - { - priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); - priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; - } - else - { - priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); - } - } - - // - // Check EVM - // - /* record the general EVM to the sliding window. */ - if(pprevious_stats->SignalQuality == 0) - { - } - else - { - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ - if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ - slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; - last_evm = priv->stats.slide_evm[slide_evm_index]; - priv->stats.slide_evm_total -= last_evm; - } - - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; - - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; - if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) - slide_evm_index = 0; - - // <1> Showed on UI for user, in percentage. - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; - //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. - } - - // <2> Showed on UI for engineering - if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream - { - if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) - { - if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize - { - priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; - } - priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); - } - } - } - } - -} - -static u8 rtl819x_query_rxpwrpercentage( - char antpower - ) -{ - if ((antpower <= -100) || (antpower >= 20)) - { - return 0; - } - else if (antpower >= 0) - { - return 100; - } - else - { - return (100+antpower); - } - -} - -static u8 -rtl819x_evm_dbtopercentage( - char value - ) -{ - char ret_val; - - ret_val = value; - - if(ret_val >= 0) - ret_val = 0; - if(ret_val <= -33) - ret_val = -33; - ret_val = 0 - ret_val; - ret_val*=3; - if(ret_val == 99) - ret_val = 100; - return ret_val; -} - -/* We want good-looking for signal strength/quality */ -static long rtl819x_signal_scale_mapping(long currsig) -{ - long retsig; - - // Step 1. Scale mapping. - if(currsig >= 61 && currsig <= 100) - { - retsig = 90 + ((currsig - 60) / 4); - } - else if(currsig >= 41 && currsig <= 60) - { - retsig = 78 + ((currsig - 40) / 2); - } - else if(currsig >= 31 && currsig <= 40) - { - retsig = 66 + (currsig - 30); - } - else if(currsig >= 21 && currsig <= 30) - { - retsig = 54 + (currsig - 20); - } - else if(currsig >= 5 && currsig <= 20) - { - retsig = 42 + (((currsig - 5) * 2) / 3); - } - else if(currsig == 4) - { - retsig = 36; - } - else if(currsig == 3) - { - retsig = 27; - } - else if(currsig == 2) - { - retsig = 18; - } - else if(currsig == 1) - { - retsig = 9; - } - else - { - retsig = currsig; - } - - return retsig; -} - -static void rtl8192_query_rxphystatus( - struct r8192_priv * priv, - struct ieee80211_rx_stats * pstats, - prx_desc_819x_pci pdesc, - prx_fwinfo_819x_pci pdrvinfo, - struct ieee80211_rx_stats * precord_stats, - bool bpacket_match_bssid, - bool bpacket_toself, - bool bPacketBeacon, - bool bToSelfBA - ) -{ - //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status); - phy_sts_ofdm_819xpci_t* pofdm_buf; - phy_sts_cck_819xpci_t * pcck_buf; - phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; - u8 *prxpkt; - u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all=0; - //long rx_avg_pwr = 0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi=0;//, total_evm=0; -// long signal_strength_index = 0; - u8 is_cck_rate=0; - u8 rf_rx_num = 0; - - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); - - // Record it for next packet processing - memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; - pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; - pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo); - pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; - pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; - /*2007.08.30 requested by SD3 Jerry */ - if (priv->phy_check_reg824 == 0) - { - priv->phy_reg824_bit9 = rtl8192_QueryBBReg(priv, rFPGA0_XA_HSSIParameter2, 0x200); - priv->phy_check_reg824 = 1; - } - - - prxpkt = (u8*)pdrvinfo; - - /* Move pointer to the 16th bytes. Phy status start address. */ - prxpkt += sizeof(rx_fwinfo_819x_pci); - - /* Initial the cck and ofdm buffer pointer */ - pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; - pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; - - pstats->RxMIMOSignalQuality[0] = -1; - pstats->RxMIMOSignalQuality[1] = -1; - precord_stats->RxMIMOSignalQuality[0] = -1; - precord_stats->RxMIMOSignalQuality[1] = -1; - - if(is_cck_rate) - { - // - // (1)Hardware does not provide RSSI for CCK - // - - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // - u8 report;//, cck_agc_rpt; - - if (!priv->phy_reg824_bit9) - { - report = pcck_buf->cck_agc_rpt & 0xc0; - report = report>>6; - switch(report) - { - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is -38 , -26 , -14 , -2 - //Fixed value is -35 , -23 , -11 , 6 - case 0x3: - rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - } - } - else - { - report = pcck_buf->cck_agc_rpt & 0x60; - report = report>>5; - switch(report) - { - case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x0: - rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - } - } - - pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); - pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; - pstats->RecvSignalPower = rx_pwr_all; - - // - // (3) Get Signal Quality (EVM) - // - if(bpacket_match_bssid) - { - u8 sq; - - if(pstats->RxPWDBAll > 40) - { - sq = 100; - }else - { - sq = pcck_buf->sq_rpt; - - if(pcck_buf->sq_rpt > 64) - sq = 0; - else if (pcck_buf->sq_rpt < 20) - sq = 100; - else - sq = ((64-sq) * 100) / 44; - } - pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; - } - } - else - { - // - // (1)Get RSSI for HT rate - // - for(i=RF90_PATH_A; ibrfpath_rxenable[i]) - rf_rx_num++; - //else - //continue; - - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; - - //Get Rx snr value in DB - tmp_rxsnr = pofdm_buf->rxsnr_X[i]; - rx_snrX = (char)(tmp_rxsnr); - rx_snrX /= 2; - - /* Translate DBM to percentage. */ - RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); - if (priv->brfpath_rxenable[i]) - total_rssi += RSSI; - - /* Record Signal Strength for next packet */ - if(bpacket_match_bssid) - { - pstats->RxMIMOSignalStrength[i] =(u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; - } - } - - - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; - pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); - - pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; - pstats->RxPower = precord_stats->RxPower = rx_pwr_all; - pstats->RecvSignalPower = rx_pwr_all; - // - // (3)EVM of HT rate - // - if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && - pdrvinfo->RxRate<=DESC90_RATEMCS15) - max_spatial_stream = 2; //both spatial stream make sense - else - max_spatial_stream = 1; //only spatial stream 1 makes sense - - for(i=0; irxevm_X[i]; - rx_evmX = (char)(tmp_rxevm); - - // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment - // fill most significant bit to "zero" when doing shifting operation which may change a negative - // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. - rx_evmX /= 2; //dbm - - evm = rtl819x_evm_dbtopercentage(rx_evmX); - if(bpacket_match_bssid) - { - if(i==0) // Fill value in RFD, Get the first spatial stream only - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); - } - } - - - /* record rx statistics for debug */ - rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; - } - - //UI BSS List signal strength(in percentage), make it good looking, from 0~100. - //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). - if(is_cck_rate) - { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL; - - } - else - { - //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u1Byte)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u1Byte)(total_rssi/=RF90_PATH_MAX); - // We can judge RX path number now. - if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num))); - } -} - -static void -rtl8192_record_rxdesc_forlateruse( - struct ieee80211_rx_stats * psrc_stats, - struct ieee80211_rx_stats * ptarget_stats -) -{ - ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; - ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; -} - - - -static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv, - struct sk_buff *skb, - struct ieee80211_rx_stats * pstats, - prx_desc_819x_pci pdesc, - prx_fwinfo_819x_pci pdrvinfo) -{ - // TODO: We must only check packet for current MAC address. Not finish - bool bpacket_match_bssid, bpacket_toself; - bool bPacketBeacon=false, bToSelfBA=false; - struct ieee80211_hdr_3addr *hdr; - u16 fc,type; - - // Get Signal Quality for only RX data queue (but not command queue) - - u8* tmp_buf; - u8 *praddr; - - /* Get MAC frame start address. */ - tmp_buf = skb->data; - - hdr = (struct ieee80211_hdr_3addr *)tmp_buf; - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - - /* Check if the received packet is acceptabe. */ - bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) && - (!compare_ether_addr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) - && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)); - - if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON) - { - bPacketBeacon = true; - } - if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK) - { - if (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)) - bToSelfBA = true; - } - - // - // Process PHY information for previous packet (RSSI/PWDB/EVM) - // - // Because phy information is contained in the last packet of AMPDU only, so driver - // should process phy information of previous packet - rtl8192_process_phyinfo(priv, tmp_buf, &priv->previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &priv->previous_stats, bpacket_match_bssid, - bpacket_toself ,bPacketBeacon, bToSelfBA); - rtl8192_record_rxdesc_forlateruse(pstats, &priv->previous_stats); - -} - - -static void rtl8192_tx_resume(struct r8192_priv *priv) -{ - struct ieee80211_device *ieee = priv->ieee80211; - struct sk_buff *skb; - int i; - - for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) { - while ((!skb_queue_empty(&ieee->skb_waitQ[i])) && - (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) { - /* 1. dequeue the packet from the wait queue */ - skb = skb_dequeue(&ieee->skb_waitQ[i]); - /* 2. tx the packet directly */ - ieee->softmac_data_hard_start_xmit(skb, ieee, 0); - } - } -} - -static void rtl8192_irq_tx_tasklet(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE]; - unsigned long flags; - - /* check if we need to report that the management queue is drained */ - spin_lock_irqsave(&priv->irq_th_lock, flags); - - if (!skb_queue_len(&mgnt_ring->queue) && - priv->ieee80211->ack_tx_to_ieee && - rtl8192_is_tx_queue_empty(priv->ieee80211)) { - priv->ieee80211->ack_tx_to_ieee = 0; - ieee80211_ps_tx_ack(priv->ieee80211, 1); - } - - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - - rtl8192_tx_resume(priv); -} - -/* Record the received data rate */ -static void UpdateReceivedRateHistogramStatistics8190( - struct r8192_priv *priv, - struct ieee80211_rx_stats* pstats - ) -{ - u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV - u32 rateIndex; - u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI - - if(pstats->bCRC) - rcvType = 2; - else if(pstats->bICV) - rcvType = 3; - - if(pstats->bShortPreamble) - preamble_guardinterval = 1;// short - else - preamble_guardinterval = 0;// long - - switch(pstats->rate) - { - // - // CCK rate - // - case MGN_1M: rateIndex = 0; break; - case MGN_2M: rateIndex = 1; break; - case MGN_5_5M: rateIndex = 2; break; - case MGN_11M: rateIndex = 3; break; - // - // Legacy OFDM rate - // - case MGN_6M: rateIndex = 4; break; - case MGN_9M: rateIndex = 5; break; - case MGN_12M: rateIndex = 6; break; - case MGN_18M: rateIndex = 7; break; - case MGN_24M: rateIndex = 8; break; - case MGN_36M: rateIndex = 9; break; - case MGN_48M: rateIndex = 10; break; - case MGN_54M: rateIndex = 11; break; - // - // 11n High throughput rate - // - case MGN_MCS0: rateIndex = 12; break; - case MGN_MCS1: rateIndex = 13; break; - case MGN_MCS2: rateIndex = 14; break; - case MGN_MCS3: rateIndex = 15; break; - case MGN_MCS4: rateIndex = 16; break; - case MGN_MCS5: rateIndex = 17; break; - case MGN_MCS6: rateIndex = 18; break; - case MGN_MCS7: rateIndex = 19; break; - case MGN_MCS8: rateIndex = 20; break; - case MGN_MCS9: rateIndex = 21; break; - case MGN_MCS10: rateIndex = 22; break; - case MGN_MCS11: rateIndex = 23; break; - case MGN_MCS12: rateIndex = 24; break; - case MGN_MCS13: rateIndex = 25; break; - case MGN_MCS14: rateIndex = 26; break; - case MGN_MCS15: rateIndex = 27; break; - default: rateIndex = 28; break; - } - priv->stats.received_rate_histogram[0][rateIndex]++; //total - priv->stats.received_rate_histogram[rcvType][rateIndex]++; -} - -static void rtl8192_rx(struct r8192_priv *priv) -{ - struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; - bool unicast_packet = false; - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - .freq = IEEE80211_24GHZ_BAND, - }; - unsigned int count = priv->rxringcount; - prx_fwinfo_819x_pci pDrvInfo = NULL; - struct sk_buff *new_skb; - - while (count--) { - rx_desc_819x_pci *pdesc = &priv->rx_ring[priv->rx_idx];//rx descriptor - struct sk_buff *skb = priv->rx_buf[priv->rx_idx];//rx pkt - - if (pdesc->OWN) - /* wait data to be filled by hardware */ - return; - - stats.bICV = pdesc->ICV; - stats.bCRC = pdesc->CRC32; - stats.bHwError = pdesc->CRC32 | pdesc->ICV; - - stats.Length = pdesc->Length; - if(stats.Length < 24) - stats.bHwError |= 1; - - if(stats.bHwError) { - stats.bShift = false; - goto done; - } - pDrvInfo = NULL; - new_skb = dev_alloc_skb(priv->rxbuffersize); - - if (unlikely(!new_skb)) - goto done; - - stats.RxDrvInfoSize = pdesc->RxDrvInfoSize; - stats.RxBufShift = ((pdesc->Shift)&0x03); - stats.Decrypted = !pdesc->SWDec; - - pci_dma_sync_single_for_cpu(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); - skb_put(skb, pdesc->Length); - pDrvInfo = (rx_fwinfo_819x_pci *)(skb->data + stats.RxBufShift); - skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); - - stats.rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); - stats.bShortPreamble = pDrvInfo->SPLCP; - - /* it is debug only. It should be disabled in released driver. - * 2007.1.11 by Emily - * */ - UpdateReceivedRateHistogramStatistics8190(priv, &stats); - - stats.bIsAMPDU = (pDrvInfo->PartAggr==1); - stats.bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); - - stats.TimeStampLow = pDrvInfo->TSFL; - stats.TimeStampHigh = read_nic_dword(priv, TSFR+4); - - UpdateRxPktTimeStamp8190(priv, &stats); - - // - // Get Total offset of MPDU Frame Body - // - if((stats.RxBufShift + stats.RxDrvInfoSize) > 0) - stats.bShift = 1; - - /* ???? */ - TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo); - - /* Rx A-MPDU */ - if(pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); - skb_trim(skb, skb->len - 4/*sCrcLng*/); - /* rx packets statistics */ - ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; - unicast_packet = false; - - if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) { - //TODO - }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){ - //TODO - }else { - /* unicast packet */ - unicast_packet = true; - } - - if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){ - dev_kfree_skb_any(skb); - } else { - priv->stats.rxok++; - if(unicast_packet) { - priv->stats.rxbytesunicast += skb->len; - } - } - - pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - - skb = new_skb; - priv->rx_buf[priv->rx_idx] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); - -done: - pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); - pdesc->OWN = 1; - pdesc->Length = priv->rxbuffersize; - if (priv->rx_idx == priv->rxringcount-1) - pdesc->EOR = 1; - priv->rx_idx = (priv->rx_idx + 1) % priv->rxringcount; - } - -} - -static void rtl8192_irq_rx_tasklet(unsigned long arg) -{ - struct r8192_priv *priv = (struct r8192_priv*) arg; - rtl8192_rx(priv); - /* unmask RDU */ - write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) | IMR_RDU); -} - -static const struct net_device_ops rtl8192_netdev_ops = { - .ndo_open = rtl8192_open, - .ndo_stop = rtl8192_close, - .ndo_tx_timeout = tx_timeout, - .ndo_do_ioctl = rtl8192_ioctl, - .ndo_set_multicast_list = r8192_set_multicast, - .ndo_set_mac_address = r8192_set_mac_adr, - .ndo_start_xmit = ieee80211_rtl_xmit, -}; - -static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) -{ - struct net_device *dev = NULL; - struct r8192_priv *priv= NULL; - u8 unit = 0; - int ret = -ENODEV; - unsigned long pmem_start, pmem_len, pmem_flags; - u8 revisionid; - - RT_TRACE(COMP_INIT,"Configuring chip resources\n"); - - if( pci_enable_device (pdev) ){ - RT_TRACE(COMP_ERR,"Failed to enable PCI device"); - return -EIO; - } - - pci_set_master(pdev); - //pci_set_wmi(pdev); - pci_set_dma_mask(pdev, 0xffffff00ULL); - pci_set_consistent_dma_mask(pdev,0xffffff00ULL); - dev = alloc_ieee80211(sizeof(struct r8192_priv)); - if (!dev) { - ret = -ENOMEM; - goto fail_free; - } - - pci_set_drvdata(pdev, dev); - SET_NETDEV_DEV(dev, &pdev->dev); - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - priv->pdev=pdev; - if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ - priv->ieee80211->bSupportRemoteWakeUp = 1; - } else - { - priv->ieee80211->bSupportRemoteWakeUp = 0; - } - - pmem_start = pci_resource_start(pdev, 1); - pmem_len = pci_resource_len(pdev, 1); - pmem_flags = pci_resource_flags (pdev, 1); - - if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting\n"); - goto fail; - } - - //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); - if( ! request_mem_region(pmem_start, pmem_len, RTL819xE_MODULE_NAME)) { - RT_TRACE(COMP_ERR,"request_mem_region failed!\n"); - goto fail; - } - - priv->mem_start = ioremap_nocache(pmem_start, pmem_len); - if (!priv->mem_start) { - RT_TRACE(COMP_ERR,"ioremap failed!\n"); - goto fail1; - } - - dev->mem_start = (unsigned long) priv->mem_start; - dev->mem_end = (unsigned long) (priv->mem_start + - pci_resource_len(pdev, 0)); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, 0x41, 0x00); - - - pci_read_config_byte(pdev, 0x08, &revisionid); - /* If the revisionid is 0x10, the device uses rtl8192se. */ - if (pdev->device == 0x8192 && revisionid == 0x10) - goto fail1; - - pci_read_config_byte(pdev, 0x05, &unit); - pci_write_config_byte(pdev, 0x05, unit & (~0x04)); - - dev->irq = pdev->irq; - priv->irq = 0; - - dev->netdev_ops = &rtl8192_netdev_ops; - - dev->wireless_handlers = &r8192_wx_handlers_def; - dev->type=ARPHRD_ETHER; - - dev->watchdog_timeo = HZ*3; - - if (dev_alloc_name(dev, ifname) < 0){ - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - strcpy(ifname, "wlan%d"); - dev_alloc_name(dev, ifname); - } - - RT_TRACE(COMP_INIT, "Driver probe completed1\n"); - if (rtl8192_init(priv)!=0) { - RT_TRACE(COMP_ERR, "Initialization failed\n"); - goto fail; - } - - register_netdev(dev); - RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name); - rtl8192_proc_init_one(priv); - - - RT_TRACE(COMP_INIT, "Driver probe completed\n"); - return 0; - -fail1: - - if (priv->mem_start) { - iounmap(priv->mem_start); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); - } - -fail: - if(dev){ - - if (priv->irq) { - free_irq(priv->irq, priv); - priv->irq = 0; - } - free_ieee80211(dev); - } - -fail_free: - pci_disable_device(pdev); - - DMESG("wlan driver load failed\n"); - pci_set_drvdata(pdev, NULL); - return ret; - -} - -/* detach all the work and timer structure declared or inititialized - * in r8192_init function. - * */ -static void rtl8192_cancel_deferred_work(struct r8192_priv* priv) -{ - /* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code - * is or is newer than 2.6.20 and work structure is defined to be struct work_struct. - * Otherwise call cancel_delayed_work is enough. - * FIXME (2.6.20 should 2.6.22, work_struct should not cancel) - * */ - cancel_delayed_work(&priv->watch_dog_wq); - cancel_delayed_work(&priv->update_beacon_wq); - cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); - cancel_delayed_work(&priv->gpio_change_rf_wq); - cancel_work_sync(&priv->reset_wq); - cancel_work_sync(&priv->qos_activate); -} - - -static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv ; - u32 i; - - if (dev) { - - unregister_netdev(dev); - - priv = ieee80211_priv(dev); - - rtl8192_proc_remove_one(priv); - - rtl8192_down(dev); - if (priv->pFirmware) - { - vfree(priv->pFirmware); - priv->pFirmware = NULL; - } - destroy_workqueue(priv->priv_wq); - - /* free tx/rx rings */ - rtl8192_free_rx_ring(priv); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - rtl8192_free_tx_ring(priv, i); - - if (priv->irq) { - printk("Freeing irq %d\n", priv->irq); - free_irq(priv->irq, priv); - priv->irq = 0; - } - - if (priv->mem_start) { - iounmap(priv->mem_start); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); - } - - free_ieee80211(dev); - } - - pci_disable_device(pdev); - RT_TRACE(COMP_DOWN, "wlan driver removed\n"); -} - -extern int ieee80211_rtl_init(void); -extern void ieee80211_rtl_exit(void); - -static int __init rtl8192_pci_module_init(void) -{ - int retval; - - retval = ieee80211_rtl_init(); - if (retval) - return retval; - - printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); - RT_TRACE(COMP_INIT, "Initializing module\n"); - rtl8192_proc_module_init(); - if(0!=pci_register_driver(&rtl8192_pci_driver)) - { - DMESG("No device found"); - /*pci_unregister_driver (&rtl8192_pci_driver);*/ - return -ENODEV; - } - return 0; -} - - -static void __exit rtl8192_pci_module_exit(void) -{ - pci_unregister_driver(&rtl8192_pci_driver); - - RT_TRACE(COMP_DOWN, "Exiting\n"); - rtl8192_proc_module_remove(); - ieee80211_rtl_exit(); -} - -static irqreturn_t rtl8192_interrupt(int irq, void *param) -{ - struct r8192_priv *priv = param; - struct net_device *dev = priv->ieee80211->dev; - unsigned long flags; - u32 inta; - irqreturn_t ret = IRQ_HANDLED; - - spin_lock_irqsave(&priv->irq_th_lock, flags); - - /* ISR: 4bytes */ - - inta = read_nic_dword(priv, ISR); /* & priv->IntrMask; */ - write_nic_dword(priv, ISR, inta); /* reset int situation */ - - if (!inta) { - /* - * most probably we can safely return IRQ_NONE, - * but for now is better to avoid problems - */ - goto out_unlock; - } - - if (inta == 0xffff) { - /* HW disappared */ - goto out_unlock; - } - - if (!netif_running(dev)) - goto out_unlock; - - if (inta & IMR_TBDOK) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); - rtl8192_tx_isr(priv, BEACON_QUEUE); - priv->stats.txbeaconokint++; - } - - if (inta & IMR_TBDER) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); - rtl8192_tx_isr(priv, BEACON_QUEUE); - priv->stats.txbeaconerr++; - } - - if (inta & IMR_MGNTDOK ) { - RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); - priv->stats.txmanageokint++; - rtl8192_tx_isr(priv, MGNT_QUEUE); - } - - if (inta & IMR_COMDOK) - { - priv->stats.txcmdpktokint++; - rtl8192_tx_isr(priv, TXCMD_QUEUE); - } - - if (inta & IMR_ROK) { - priv->stats.rxint++; - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_BcnInt) { - RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); - tasklet_schedule(&priv->irq_prepare_beacon_tasklet); - } - - if (inta & IMR_RDU) { - RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); - priv->stats.rxrdu++; - /* reset int situation */ - write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) & ~IMR_RDU); - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_RXFOVW) { - RT_TRACE(COMP_INTR, "rx overflow !\n"); - priv->stats.rxoverflow++; - tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_TXFOVW) - priv->stats.txoverflow++; - - if (inta & IMR_BKDOK) { - RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); - priv->stats.txbkokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, BK_QUEUE); - } - - if (inta & IMR_BEDOK) { - RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); - priv->stats.txbeokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, BE_QUEUE); - } - - if (inta & IMR_VIDOK) { - RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); - priv->stats.txviokint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, VI_QUEUE); - } - - if (inta & IMR_VODOK) { - priv->stats.txvookint++; - priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(priv, VO_QUEUE); - } - -out_unlock: - spin_unlock_irqrestore(&priv->irq_th_lock, flags); - - return ret; -} - -void EnableHWSecurityConfig8192(struct r8192_priv *priv) -{ - u8 SECR_value = 0x0; - struct ieee80211_device* ieee = priv->ieee80211; - - SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; - - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; - } - - //add HWSec active enable here. -//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 - ieee->hwsec_active = 1; - - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off - { - ieee->hwsec_active = 0; - SECR_value &= ~SCR_RxDecEnable; - } - - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(priv, SECR, SECR_value);//SECR_value | SCR_UseDK ); - } - -} -#define TOTAL_CAM_ENTRY 32 -//#define CAM_CONTENT_COUNT 8 -void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, - const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) -{ - u32 TargetCommand = 0; - u32 TargetContent = 0; - u16 usConfig = 0; - u8 i; -#ifdef ENABLE_IPS - RT_RF_POWER_STATE rtState; - - rtState = priv->eRFPowerState; - if (priv->PowerSaveControl.bInactivePs){ - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - //up(&priv->wx_sem); - return ; - } - else{ - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); - } - } - } - priv->ieee80211->is_set_key = true; -#endif - if (EntryNo >= TOTAL_CAM_ENTRY) - RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); - - RT_TRACE(COMP_SEC, "====>to setKey(), priv:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", priv, EntryNo, KeyIndex, KeyType, MacAddr); - - if (DefaultKey) - usConfig |= BIT15 | (KeyType<<2); - else - usConfig |= BIT15 | (KeyType<<2) | KeyIndex; -// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; - - - for(i=0 ; iafter set key, usconfig:%x\n", usConfig); -} - -bool NicIFEnableNIC(struct r8192_priv *priv) -{ - RT_STATUS init_status = RT_STATUS_SUCCESS; - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - - //YJ,add,091109 - if (priv->up == 0){ - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__FUNCTION__); - priv->bdisable_nic = false; //YJ,add,091111 - return false; - } - // <1> Reset memory: descriptor, buffer,.. - //NicIFResetMemory(Adapter); - - // <2> Enable Adapter - //priv->bfirst_init = true; - init_status = rtl8192_adapter_start(priv); - if (init_status != RT_STATUS_SUCCESS) { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); - priv->bdisable_nic = false; //YJ,add,091111 - return -1; - } - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - //priv->bfirst_init = false; - - // <3> Enable Interrupt - rtl8192_irq_enable(priv); - priv->bdisable_nic = false; - - return (init_status == RT_STATUS_SUCCESS); -} - -bool NicIFDisableNIC(struct r8192_priv *priv) -{ - bool status = true; - u8 tmp_state = 0; - // <1> Disable Interrupt - - priv->bdisable_nic = true; //YJ,move,091109 - tmp_state = priv->ieee80211->state; - - ieee80211_softmac_stop_protocol(priv->ieee80211, false); - - priv->ieee80211->state = tmp_state; - rtl8192_cancel_deferred_work(priv); - rtl8192_irq_disable(priv); - // <2> Stop all timer - - // <3> Disable Adapter - rtl8192_halt_adapter(priv, false); -// priv->bdisable_nic = true; - - return status; -} - -module_init(rtl8192_pci_module_init); -module_exit(rtl8192_pci_module_exit); diff --git a/drivers/staging/rtl8192e/r8192E_core.c.rej b/drivers/staging/rtl8192e/r8192E_core.c.rej deleted file mode 100644 index 351b44cce9a..00000000000 --- a/drivers/staging/rtl8192e/r8192E_core.c.rej +++ /dev/null @@ -1,5036 +0,0 @@ ---- drivers/staging/rtl8192e/r8192E_core.c -+++ drivers/staging/rtl8192e/r8192E_core.c -@@ -1,5033 +0,0 @@ --/****************************************************************************** -- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. -- * Linux device driver for RTL8192E -- * -- * Based on the r8180 driver, which is: -- * Copyright 2004-2005 Andrea Merello , et al. -- * This program is free software; you can redistribute it and/or modify it -- * under the terms of version 2 of the GNU General Public License as -- * published by the Free Software Foundation. -- * -- * This program is distributed in the hope that it will be useful, but WITHOUT -- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -- * more details. -- * -- * You should have received a copy of the GNU General Public License along with -- * this program; if not, write to the Free Software Foundation, Inc., -- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -- * -- * The full GNU General Public License is included in this distribution in the -- * file called LICENSE. -- * -- * Contact Information: -- * Jerry chuang -- */ -- -- --#include --#include --#include --#include "r8192E_hw.h" --#include "r8192E.h" --#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ --#include "r8180_93cx6.h" /* Card EEPROM */ --#include "r8192E_wx.h" --#include "r819xE_phy.h" //added by WB 4.30.2008 --#include "r819xE_phyreg.h" --#include "r819xE_cmdpkt.h" --#include "r8192E_dm.h" -- --#ifdef CONFIG_PM --#include "r8192_pm.h" --#endif -- --#ifdef ENABLE_DOT11D --#include "ieee80211/dot11d.h" --#endif -- --//set here to open your trace code. //WB --u32 rt_global_debug_component = COMP_ERR ; //always open err flags on -- --static DEFINE_PCI_DEVICE_TABLE(rtl8192_pci_id_tbl) = { -- /* Realtek */ -- { PCI_DEVICE(0x10ec, 0x8192) }, -- -- /* Corega */ -- { PCI_DEVICE(0x07aa, 0x0044) }, -- { PCI_DEVICE(0x07aa, 0x0047) }, -- {} --}; -- --static char ifname[IFNAMSIZ] = "wlan%d"; --static int hwwep = 1; //default use hw. set 0 to use software security --static int channels = 0x3fff; -- --MODULE_LICENSE("GPL"); --MODULE_VERSION("V 1.1"); --MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); --//MODULE_AUTHOR("Andrea Merello "); --MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); -- -- --module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); --module_param(hwwep,int, S_IRUGO|S_IWUSR); --module_param(channels,int, S_IRUGO|S_IWUSR); -- --MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); --MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); --MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); -- --static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, -- const struct pci_device_id *id); --static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); -- --static struct pci_driver rtl8192_pci_driver = { -- .name = RTL819xE_MODULE_NAME, /* Driver name */ -- .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ -- .probe = rtl8192_pci_probe, /* probe fn */ -- .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ --#ifdef CONFIG_PM -- .suspend = rtl8192E_suspend, /* PM suspend fn */ -- .resume = rtl8192E_resume, /* PM resume fn */ --#else -- .suspend = NULL, /* PM suspend fn */ -- .resume = NULL, /* PM resume fn */ --#endif --}; -- --static void rtl8192_start_beacon(struct ieee80211_device *ieee80211); --static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211); --static void rtl819x_watchdog_wqcallback(struct work_struct *work); --static void rtl8192_irq_rx_tasklet(unsigned long arg); --static void rtl8192_irq_tx_tasklet(unsigned long arg); --static void rtl8192_prepare_beacon(unsigned long arg); --static irqreturn_t rtl8192_interrupt(int irq, void *param); --static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb); --static void rtl8192_update_ratr_table(struct r8192_priv *priv); --static void rtl8192_restart(struct work_struct *work); --static void watch_dog_timer_callback(unsigned long data); --static int _rtl8192_up(struct r8192_priv *priv); --static void rtl8192_cancel_deferred_work(struct r8192_priv* priv); --static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb); -- --#ifdef ENABLE_DOT11D -- --typedef struct _CHANNEL_LIST --{ -- u8 Channel[32]; -- u8 Len; --}CHANNEL_LIST, *PCHANNEL_LIST; -- --static const CHANNEL_LIST ChannelPlan[] = { -- {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC -- {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI -- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. -- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 -- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC -- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 --}; -- --static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) --{ -- int i, max_chan=-1, min_chan=-1; -- struct ieee80211_device* ieee = priv->ieee80211; -- switch (channel_plan) -- { -- case COUNTRY_CODE_FCC: -- case COUNTRY_CODE_IC: -- case COUNTRY_CODE_ETSI: -- case COUNTRY_CODE_SPAIN: -- case COUNTRY_CODE_FRANCE: -- case COUNTRY_CODE_MKK: -- case COUNTRY_CODE_MKK1: -- case COUNTRY_CODE_ISRAEL: -- case COUNTRY_CODE_TELEC: -- case COUNTRY_CODE_MIC: -- { -- Dot11d_Init(ieee); -- ieee->bGlobalDomain = false; -- //acturally 8225 & 8256 rf chip only support B,G,24N mode -- min_chan = 1; -- max_chan = 14; -- -- if (ChannelPlan[channel_plan].Len != 0){ -- // Clear old channel map -- memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); -- // Set new channel map -- for (i=0;i max_chan) -- break; -- GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; -- } -- } -- break; -- } -- case COUNTRY_CODE_GLOBAL_DOMAIN: -- { -- GET_DOT11D_INFO(ieee)->bEnabled = 0; //this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain setting -- Dot11d_Reset(ieee); -- ieee->bGlobalDomain = true; -- break; -- } -- default: -- break; -- } --} --#endif -- --static inline bool rx_hal_is_cck_rate(prx_fwinfo_819x_pci pdrvinfo) --{ -- return (pdrvinfo->RxRate == DESC90_RATE1M || -- pdrvinfo->RxRate == DESC90_RATE2M || -- pdrvinfo->RxRate == DESC90_RATE5_5M || -- pdrvinfo->RxRate == DESC90_RATE11M) && -- !pdrvinfo->RxHT; --} -- --void CamResetAllEntry(struct r8192_priv* priv) --{ -- write_nic_dword(priv, RWCAM, BIT31|BIT30); --} -- --void write_cam(struct r8192_priv *priv, u8 addr, u32 data) --{ -- write_nic_dword(priv, WCAMI, data); -- write_nic_dword(priv, RWCAM, BIT31|BIT16|(addr&0xff) ); --} -- --u32 read_cam(struct r8192_priv *priv, u8 addr) --{ -- write_nic_dword(priv, RWCAM, 0x80000000|(addr&0xff) ); -- return read_nic_dword(priv, 0xa8); --} -- --u8 read_nic_byte(struct r8192_priv *priv, int x) --{ -- return 0xff & readb(priv->mem_start + x); --} -- --u32 read_nic_dword(struct r8192_priv *priv, int x) --{ -- return readl(priv->mem_start + x); --} -- --u16 read_nic_word(struct r8192_priv *priv, int x) --{ -- return readw(priv->mem_start + x); --} -- --void write_nic_byte(struct r8192_priv *priv, int x,u8 y) --{ -- writeb(y, priv->mem_start + x); -- udelay(20); --} -- --void write_nic_dword(struct r8192_priv *priv, int x,u32 y) --{ -- writel(y, priv->mem_start + x); -- udelay(20); --} -- --void write_nic_word(struct r8192_priv *priv, int x,u16 y) --{ -- writew(y, priv->mem_start + x); -- udelay(20); --} -- --u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee) --{ -- static const u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; -- static const u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; -- int wpa_ie_len= ieee->wpa_ie_len; -- struct ieee80211_crypt_data* crypt; -- int encrypt; -- -- crypt = ieee->crypt[ieee->tx_keyidx]; -- -- encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) || -- (ieee->host_encrypt && crypt && crypt->ops && -- (0 == strcmp(crypt->ops->name,"WEP"))); -- -- /* simply judge */ -- if(encrypt && (wpa_ie_len == 0)) { -- // wep encryption, no N mode setting */ -- return SEC_ALG_WEP; -- } else if((wpa_ie_len != 0)) { -- // parse pairwise key type */ -- if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || -- ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) -- return SEC_ALG_CCMP; -- else -- return SEC_ALG_TKIP; -- } else { -- return SEC_ALG_NONE; -- } --} -- --void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- -- switch(variable) -- { -- -- case HW_VAR_BSSID: -- write_nic_dword(priv, BSSIDR, ((u32*)(val))[0]); -- write_nic_word(priv, BSSIDR+2, ((u16*)(val+2))[0]); -- break; -- -- case HW_VAR_MEDIA_STATUS: -- { -- RT_OP_MODE OpMode = *((RT_OP_MODE *)(val)); -- u8 btMsr = read_nic_byte(priv, MSR); -- -- btMsr &= 0xfc; -- -- switch(OpMode) -- { -- case RT_OP_MODE_INFRASTRUCTURE: -- btMsr |= MSR_INFRA; -- break; -- -- case RT_OP_MODE_IBSS: -- btMsr |= MSR_ADHOC; -- break; -- -- case RT_OP_MODE_AP: -- btMsr |= MSR_AP; -- break; -- -- default: -- btMsr |= MSR_NOLINK; -- break; -- } -- -- write_nic_byte(priv, MSR, btMsr); -- } -- break; -- -- case HW_VAR_CHECK_BSSID: -- { -- u32 RegRCR, Type; -- -- Type = ((u8*)(val))[0]; -- RegRCR = read_nic_dword(priv, RCR); -- priv->ReceiveConfig = RegRCR; -- -- if (Type == true) -- RegRCR |= (RCR_CBSSID); -- else if (Type == false) -- RegRCR &= (~RCR_CBSSID); -- -- write_nic_dword(priv, RCR,RegRCR); -- priv->ReceiveConfig = RegRCR; -- -- } -- break; -- -- case HW_VAR_SLOT_TIME: -- { -- priv->slot_time = val[0]; -- write_nic_byte(priv, SLOT_TIME, val[0]); -- -- } -- break; -- -- case HW_VAR_ACK_PREAMBLE: -- { -- u32 regTmp = 0; -- priv->short_preamble = (bool)(*(u8*)val ); -- regTmp = priv->basic_rate; -- if (priv->short_preamble) -- regTmp |= BRSR_AckShortPmb; -- write_nic_dword(priv, RRSR, regTmp); -- } -- break; -- -- case HW_VAR_CPU_RST: -- write_nic_dword(priv, CPU_GEN, ((u32*)(val))[0]); -- break; -- -- default: -- break; -- } -- --} -- --static struct proc_dir_entry *rtl8192_proc = NULL; -- --static int proc_get_stats_ap(char *page, char **start, -- off_t offset, int count, -- int *eof, void *data) --{ -- struct r8192_priv *priv = data; -- struct ieee80211_device *ieee = priv->ieee80211; -- struct ieee80211_network *target; -- int len = 0; -- -- list_for_each_entry(target, &ieee->network_list, list) { -- -- len += snprintf(page + len, count - len, -- "%s ", target->ssid); -- -- if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ -- len += snprintf(page + len, count - len, -- "WPA\n"); -- } -- else{ -- len += snprintf(page + len, count - len, -- "non_WPA\n"); -- } -- -- } -- -- *eof = 1; -- return len; --} -- --static int proc_get_registers(char *page, char **start, -- off_t offset, int count, -- int *eof, void *data) --{ -- struct r8192_priv *priv = data; -- int len = 0; -- int i,n; -- int max=0xff; -- -- /* This dump the current register page */ -- len += snprintf(page + len, count - len, -- "\n####################page 0##################\n "); -- -- for(n=0;n<=max;) -- { -- len += snprintf(page + len, count - len, -- "\nD: %2x > ",n); -- -- for(i=0;i<16 && n<=max;i++,n++) -- len += snprintf(page + len, count - len, -- "%2x ",read_nic_byte(priv,n)); -- } -- len += snprintf(page + len, count - len,"\n"); -- len += snprintf(page + len, count - len, -- "\n####################page 1##################\n "); -- for(n=0;n<=max;) -- { -- len += snprintf(page + len, count - len, -- "\nD: %2x > ",n); -- -- for(i=0;i<16 && n<=max;i++,n++) -- len += snprintf(page + len, count - len, -- "%2x ",read_nic_byte(priv,0x100|n)); -- } -- -- len += snprintf(page + len, count - len, -- "\n####################page 3##################\n "); -- for(n=0;n<=max;) -- { -- len += snprintf(page + len, count - len, -- "\nD: %2x > ",n); -- -- for(i=0;i<16 && n<=max;i++,n++) -- len += snprintf(page + len, count - len, -- "%2x ",read_nic_byte(priv,0x300|n)); -- } -- -- *eof = 1; -- return len; -- --} -- --static int proc_get_stats_tx(char *page, char **start, -- off_t offset, int count, -- int *eof, void *data) --{ -- struct r8192_priv *priv = data; -- -- int len = 0; -- -- len += snprintf(page + len, count - len, -- "TX VI priority ok int: %lu\n" -- "TX VO priority ok int: %lu\n" -- "TX BE priority ok int: %lu\n" -- "TX BK priority ok int: %lu\n" -- "TX MANAGE priority ok int: %lu\n" -- "TX BEACON priority ok int: %lu\n" -- "TX BEACON priority error int: %lu\n" -- "TX CMDPKT priority ok int: %lu\n" -- "TX queue stopped?: %d\n" -- "TX fifo overflow: %lu\n" -- "TX total data packets %lu\n" -- "TX total data bytes :%lu\n", -- priv->stats.txviokint, -- priv->stats.txvookint, -- priv->stats.txbeokint, -- priv->stats.txbkokint, -- priv->stats.txmanageokint, -- priv->stats.txbeaconokint, -- priv->stats.txbeaconerr, -- priv->stats.txcmdpktokint, -- netif_queue_stopped(priv->ieee80211->dev), -- priv->stats.txoverflow, -- priv->ieee80211->stats.tx_packets, -- priv->ieee80211->stats.tx_bytes); -- -- *eof = 1; -- return len; --} -- -- -- --static int proc_get_stats_rx(char *page, char **start, -- off_t offset, int count, -- int *eof, void *data) --{ -- struct r8192_priv *priv = data; -- int len = 0; -- -- len += snprintf(page + len, count - len, -- "RX packets: %lu\n" -- "RX desc err: %lu\n" -- "RX rx overflow error: %lu\n", -- priv->stats.rxint, -- priv->stats.rxrdu, -- priv->stats.rxoverflow); -- -- *eof = 1; -- return len; --} -- --static void rtl8192_proc_module_init(void) --{ -- RT_TRACE(COMP_INIT, "Initializing proc filesystem\n"); -- rtl8192_proc=create_proc_entry(RTL819xE_MODULE_NAME, S_IFDIR, init_net.proc_net); --} -- -- --static void rtl8192_proc_module_remove(void) --{ -- remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net); --} -- -- --static void rtl8192_proc_remove_one(struct r8192_priv *priv) --{ -- struct net_device *dev = priv->ieee80211->dev; -- -- printk("dev name=======> %s\n",dev->name); -- -- if (priv->dir_dev) { -- remove_proc_entry("stats-tx", priv->dir_dev); -- remove_proc_entry("stats-rx", priv->dir_dev); -- remove_proc_entry("stats-ap", priv->dir_dev); -- remove_proc_entry("registers", priv->dir_dev); -- remove_proc_entry("wlan0", rtl8192_proc); -- priv->dir_dev = NULL; -- } --} -- -- --static void rtl8192_proc_init_one(struct r8192_priv *priv) --{ -- struct net_device *dev = priv->ieee80211->dev; -- struct proc_dir_entry *e; -- -- priv->dir_dev = create_proc_entry(dev->name, -- S_IFDIR | S_IRUGO | S_IXUGO, -- rtl8192_proc); -- if (!priv->dir_dev) { -- RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", -- dev->name); -- return; -- } -- e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, -- priv->dir_dev, proc_get_stats_rx, priv); -- -- if (!e) { -- RT_TRACE(COMP_ERR,"Unable to initialize " -- "/proc/net/rtl8192/%s/stats-rx\n", -- dev->name); -- } -- -- -- e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, -- priv->dir_dev, proc_get_stats_tx, priv); -- -- if (!e) { -- RT_TRACE(COMP_ERR, "Unable to initialize " -- "/proc/net/rtl8192/%s/stats-tx\n", -- dev->name); -- } -- -- e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, -- priv->dir_dev, proc_get_stats_ap, priv); -- -- if (!e) { -- RT_TRACE(COMP_ERR, "Unable to initialize " -- "/proc/net/rtl8192/%s/stats-ap\n", -- dev->name); -- } -- -- e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, -- priv->dir_dev, proc_get_registers, priv); -- if (!e) { -- RT_TRACE(COMP_ERR, "Unable to initialize " -- "/proc/net/rtl8192/%s/registers\n", -- dev->name); -- } --} -- --static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; -- -- /* for now we reserve two free descriptor as a safety boundary -- * between the tail and the head -- */ -- return (ring->entries - skb_queue_len(&ring->queue) >= 2); --} -- --static void tx_timeout(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- -- schedule_work(&priv->reset_wq); -- printk("TXTIMEOUT"); --} -- --static void rtl8192_irq_enable(struct r8192_priv *priv) --{ -- u32 mask; -- -- mask = IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | -- IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | -- IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW | -- IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER; -- -- write_nic_dword(priv, INTA_MASK, mask); --} -- --static void rtl8192_irq_disable(struct r8192_priv *priv) --{ -- write_nic_dword(priv, INTA_MASK, 0); -- synchronize_irq(priv->irq); --} -- --static void rtl8192_update_msr(struct r8192_priv *priv) --{ -- u8 msr; -- -- msr = read_nic_byte(priv, MSR); -- msr &= ~ MSR_LINK_MASK; -- -- /* do not change in link_state != WLAN_LINK_ASSOCIATED. -- * msr must be updated if the state is ASSOCIATING. -- * this is intentional and make sense for ad-hoc and -- * master (see the create BSS/IBSS func) -- */ -- if (priv->ieee80211->state == IEEE80211_LINKED){ -- -- if (priv->ieee80211->iw_mode == IW_MODE_INFRA) -- msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) -- msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) -- msr |= (MSR_LINK_MASTER<dev); -- -- priv->chan = ch; -- -- /* need to implement rf set channel here WB */ -- -- if (priv->rf_set_chan) -- priv->rf_set_chan(ieee80211, priv->chan); --} -- --static void rtl8192_rx_enable(struct r8192_priv *priv) --{ -- write_nic_dword(priv, RDQDA, priv->rx_ring_dma); --} -- --/* the TX_DESC_BASE setting is according to the following queue index -- * BK_QUEUE ===> 0 -- * BE_QUEUE ===> 1 -- * VI_QUEUE ===> 2 -- * VO_QUEUE ===> 3 -- * HCCA_QUEUE ===> 4 -- * TXCMD_QUEUE ===> 5 -- * MGNT_QUEUE ===> 6 -- * HIGH_QUEUE ===> 7 -- * BEACON_QUEUE ===> 8 -- * */ --static const u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; --static void rtl8192_tx_enable(struct r8192_priv *priv) --{ -- u32 i; -- -- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) -- write_nic_dword(priv, TX_DESC_BASE[i], priv->tx_ring[i].dma); -- -- ieee80211_reset_queue(priv->ieee80211); --} -- -- --static void rtl8192_free_rx_ring(struct r8192_priv *priv) --{ -- int i; -- -- for (i = 0; i < priv->rxringcount; i++) { -- struct sk_buff *skb = priv->rx_buf[i]; -- if (!skb) -- continue; -- -- pci_unmap_single(priv->pdev, -- *((dma_addr_t *)skb->cb), -- priv->rxbuffersize, PCI_DMA_FROMDEVICE); -- kfree_skb(skb); -- } -- -- pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring) * priv->rxringcount, -- priv->rx_ring, priv->rx_ring_dma); -- priv->rx_ring = NULL; --} -- --static void rtl8192_free_tx_ring(struct r8192_priv *priv, unsigned int prio) --{ -- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; -- -- while (skb_queue_len(&ring->queue)) { -- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; -- struct sk_buff *skb = __skb_dequeue(&ring->queue); -- -- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), -- skb->len, PCI_DMA_TODEVICE); -- kfree_skb(skb); -- ring->idx = (ring->idx + 1) % ring->entries; -- } -- -- pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, -- ring->desc, ring->dma); -- ring->desc = NULL; --} -- --void PHY_SetRtl8192eRfOff(struct r8192_priv *priv) --{ -- //disable RF-Chip A/B -- rtl8192_setBBreg(priv, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); -- //analog to digital off, for power save -- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x0); -- //digital to analog off, for power save -- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x18, 0x0); -- //rx antenna off -- rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0xf, 0x0); -- //rx antenna off -- rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0xf, 0x0); -- //analog to digital part2 off, for power save -- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x60, 0x0); -- rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x4, 0x0); -- // Analog parameter!!Change bias and Lbus control. -- write_nic_byte(priv, ANAPAR_FOR_8192PciE, 0x07); --} -- --static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset) --{ -- int i; -- u8 OpMode; -- u32 ulRegRead; -- -- OpMode = RT_OP_MODE_NO_LINK; -- priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode); -- -- if (!priv->ieee80211->bSupportRemoteWakeUp) { -- /* -- * disable tx/rx. In 8185 we write 0x10 (Reset bit), -- * but here we make reference to WMAC and wirte 0x0 -- */ -- write_nic_byte(priv, CMDR, 0); -- } -- -- mdelay(20); -- -- if (!reset) { -- mdelay(150); -- -- priv->bHwRfOffAction = 2; -- -- /* -- * Call MgntActSet_RF_State instead to -- * prevent RF config race condition. -- */ -- if (!priv->ieee80211->bSupportRemoteWakeUp) { -- PHY_SetRtl8192eRfOff(priv); -- ulRegRead = read_nic_dword(priv, CPU_GEN); -- ulRegRead |= CPU_GEN_SYSTEM_RESET; -- write_nic_dword(priv,CPU_GEN, ulRegRead); -- } else { -- /* for WOL */ -- write_nic_dword(priv, WFCRC0, 0xffffffff); -- write_nic_dword(priv, WFCRC1, 0xffffffff); -- write_nic_dword(priv, WFCRC2, 0xffffffff); -- -- /* Write PMR register */ -- write_nic_byte(priv, PMR, 0x5); -- /* Disable tx, enanble rx */ -- write_nic_byte(priv, MacBlkCtrl, 0xa); -- } -- } -- -- for(i = 0; i < MAX_QUEUE_SIZE; i++) { -- skb_queue_purge(&priv->ieee80211->skb_waitQ [i]); -- } -- for(i = 0; i < MAX_QUEUE_SIZE; i++) { -- skb_queue_purge(&priv->ieee80211->skb_aggQ [i]); -- } -- -- skb_queue_purge(&priv->skb_queue); --} -- --static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211) --{ --} -- --static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211) --{ --} -- --/* -- * this function TX data frames when the ieee80211 stack requires this. -- * It checks also if we need to stop the ieee tx queue, eventually do it -- */ --static void rtl8192_hard_data_xmit(struct sk_buff *skb, -- struct ieee80211_device *ieee80211, int rate) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- int ret; -- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); -- u8 queue_index = tcb_desc->queue_index; -- -- /* shall not be referred by command packet */ -- BUG_ON(queue_index == TXCMD_QUEUE); -- -- if (priv->bHwRadioOff || (!priv->up)) -- { -- kfree_skb(skb); -- return; -- } -- -- skb_push(skb, priv->ieee80211->tx_headroom); -- ret = rtl8192_tx(priv, skb); -- if (ret != 0) { -- kfree_skb(skb); -- } -- -- if (queue_index != MGNT_QUEUE) { -- priv->ieee80211->stats.tx_bytes += (skb->len - priv->ieee80211->tx_headroom); -- priv->ieee80211->stats.tx_packets++; -- } --} -- --/* -- * This is a rough attempt to TX a frame -- * This is called by the ieee 80211 stack to TX management frames. -- * If the ring is full packet are dropped (for data frame the queue -- * is stopped before this can happen). -- */ --static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- int ret; -- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); -- u8 queue_index = tcb_desc->queue_index; -- -- if (queue_index != TXCMD_QUEUE) { -- if (priv->bHwRadioOff || (!priv->up)) -- { -- kfree_skb(skb); -- return 0; -- } -- } -- -- if (queue_index == TXCMD_QUEUE) { -- rtl819xE_tx_cmd(priv, skb); -- ret = 0; -- return ret; -- } else { -- tcb_desc->RATRIndex = 7; -- tcb_desc->bTxDisableRateFallBack = 1; -- tcb_desc->bTxUseDriverAssingedRate = 1; -- tcb_desc->bTxEnableFwCalcDur = 1; -- skb_push(skb, ieee80211->tx_headroom); -- ret = rtl8192_tx(priv, skb); -- if (ret != 0) { -- kfree_skb(skb); -- } -- } -- -- return ret; --} -- -- --static void rtl8192_tx_isr(struct r8192_priv *priv, int prio) --{ -- struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; -- -- while (skb_queue_len(&ring->queue)) { -- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; -- struct sk_buff *skb; -- -- /* -- * beacon packet will only use the first descriptor defaultly, -- * and the OWN may not be cleared by the hardware -- */ -- if (prio != BEACON_QUEUE) { -- if (entry->OWN) -- return; -- ring->idx = (ring->idx + 1) % ring->entries; -- } -- -- skb = __skb_dequeue(&ring->queue); -- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), -- skb->len, PCI_DMA_TODEVICE); -- -- kfree_skb(skb); -- } -- -- if (prio != BEACON_QUEUE) { -- /* try to deal with the pending packets */ -- tasklet_schedule(&priv->irq_tx_tasklet); -- } --} -- --static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211) --{ --} -- --static void rtl8192_config_rate(struct r8192_priv *priv, u16* rate_config) --{ -- struct ieee80211_network *net; -- u8 i=0, basic_rate = 0; -- net = & priv->ieee80211->current_network; -- -- for (i=0; irates_len; i++) -- { -- basic_rate = net->rates[i]&0x7f; -- switch(basic_rate) -- { -- case MGN_1M: *rate_config |= RRSR_1M; break; -- case MGN_2M: *rate_config |= RRSR_2M; break; -- case MGN_5_5M: *rate_config |= RRSR_5_5M; break; -- case MGN_11M: *rate_config |= RRSR_11M; break; -- case MGN_6M: *rate_config |= RRSR_6M; break; -- case MGN_9M: *rate_config |= RRSR_9M; break; -- case MGN_12M: *rate_config |= RRSR_12M; break; -- case MGN_18M: *rate_config |= RRSR_18M; break; -- case MGN_24M: *rate_config |= RRSR_24M; break; -- case MGN_36M: *rate_config |= RRSR_36M; break; -- case MGN_48M: *rate_config |= RRSR_48M; break; -- case MGN_54M: *rate_config |= RRSR_54M; break; -- } -- } -- for (i=0; irates_ex_len; i++) -- { -- basic_rate = net->rates_ex[i]&0x7f; -- switch(basic_rate) -- { -- case MGN_1M: *rate_config |= RRSR_1M; break; -- case MGN_2M: *rate_config |= RRSR_2M; break; -- case MGN_5_5M: *rate_config |= RRSR_5_5M; break; -- case MGN_11M: *rate_config |= RRSR_11M; break; -- case MGN_6M: *rate_config |= RRSR_6M; break; -- case MGN_9M: *rate_config |= RRSR_9M; break; -- case MGN_12M: *rate_config |= RRSR_12M; break; -- case MGN_18M: *rate_config |= RRSR_18M; break; -- case MGN_24M: *rate_config |= RRSR_24M; break; -- case MGN_36M: *rate_config |= RRSR_36M; break; -- case MGN_48M: *rate_config |= RRSR_48M; break; -- case MGN_54M: *rate_config |= RRSR_54M; break; -- } -- } --} -- -- --#define SHORT_SLOT_TIME 9 --#define NON_SHORT_SLOT_TIME 20 -- --static void rtl8192_update_cap(struct r8192_priv *priv, u16 cap) --{ -- u32 tmp = 0; -- struct ieee80211_network *net = &priv->ieee80211->current_network; -- -- priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; -- tmp = priv->basic_rate; -- if (priv->short_preamble) -- tmp |= BRSR_AckShortPmb; -- write_nic_dword(priv, RRSR, tmp); -- -- if (net->mode & (IEEE_G|IEEE_N_24G)) -- { -- u8 slot_time = 0; -- if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) -- {//short slot time -- slot_time = SHORT_SLOT_TIME; -- } -- else //long slot time -- slot_time = NON_SHORT_SLOT_TIME; -- priv->slot_time = slot_time; -- write_nic_byte(priv, SLOT_TIME, slot_time); -- } -- --} -- --static void rtl8192_net_update(struct r8192_priv *priv) --{ -- struct ieee80211_network *net; -- u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; -- u16 rate_config = 0; -- net = &priv->ieee80211->current_network; -- -- /* update Basic rate: RR, BRSR */ -- rtl8192_config_rate(priv, &rate_config); -- -- /* -- * Select RRSR (in Legacy-OFDM and CCK) -- * For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, -- * 2M, and 1M from the Basic rate. -- * We do not use other rates. -- */ -- priv->basic_rate = rate_config &= 0x15f; -- -- /* BSSID */ -- write_nic_dword(priv, BSSIDR, ((u32 *)net->bssid)[0]); -- write_nic_word(priv, BSSIDR+4, ((u16 *)net->bssid)[2]); -- -- if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) -- { -- write_nic_word(priv, ATIMWND, 2); -- write_nic_word(priv, BCN_DMATIME, 256); -- write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); -- /* -- * BIT15 of BCN_DRV_EARLY_INT will indicate -- * whether software beacon or hw beacon is applied. -- */ -- write_nic_word(priv, BCN_DRV_EARLY_INT, 10); -- write_nic_byte(priv, BCN_ERR_THRESH, 100); -- -- BcnTimeCfg |= (BcnCW<tx_ring[TXCMD_QUEUE]; -- mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); -- -- spin_lock_irqsave(&priv->irq_th_lock,flags); -- idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; -- entry = &ring->desc[idx]; -- -- tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); -- memset(entry,0,12); -- entry->LINIP = tcb_desc->bLastIniPkt; -- entry->FirstSeg = 1;//first segment -- entry->LastSeg = 1; //last segment -- if(tcb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { -- entry->CmdInit = DESC_PACKET_TYPE_INIT; -- } else { -- entry->CmdInit = DESC_PACKET_TYPE_NORMAL; -- entry->Offset = sizeof(TX_FWINFO_8190PCI) + 8; -- entry->PktSize = (u16)(tcb_desc->pkt_size + entry->Offset); -- entry->QueueSelect = QSLT_CMD; -- entry->TxFWInfoSize = 0x08; -- entry->RATid = (u8)DESC_PACKET_TYPE_INIT; -- } -- entry->TxBufferSize = skb->len; -- entry->TxBuffAddr = cpu_to_le32(mapping); -- entry->OWN = 1; -- -- __skb_queue_tail(&ring->queue, skb); -- spin_unlock_irqrestore(&priv->irq_th_lock,flags); -- -- write_nic_byte(priv, TPPoll, TPPoll_CQ); -- -- return; --} -- --/* -- * Mapping Software/Hardware descriptor queue id to "Queue Select Field" -- * in TxFwInfo data structure -- */ --static u8 MapHwQueueToFirmwareQueue(u8 QueueID) --{ -- u8 QueueSelect = 0; -- -- switch (QueueID) { -- case BE_QUEUE: -- QueueSelect = QSLT_BE; -- break; -- -- case BK_QUEUE: -- QueueSelect = QSLT_BK; -- break; -- -- case VO_QUEUE: -- QueueSelect = QSLT_VO; -- break; -- -- case VI_QUEUE: -- QueueSelect = QSLT_VI; -- break; -- -- case MGNT_QUEUE: -- QueueSelect = QSLT_MGNT; -- break; -- -- case BEACON_QUEUE: -- QueueSelect = QSLT_BEACON; -- break; -- -- case TXCMD_QUEUE: -- QueueSelect = QSLT_CMD; -- break; -- -- case HIGH_QUEUE: -- default: -- RT_TRACE(COMP_ERR, "Impossible Queue Selection: %d\n", QueueID); -- break; -- } -- return QueueSelect; --} -- --static u8 MRateToHwRate8190Pci(u8 rate) --{ -- u8 ret = DESC90_RATE1M; -- -- switch(rate) { -- case MGN_1M: ret = DESC90_RATE1M; break; -- case MGN_2M: ret = DESC90_RATE2M; break; -- case MGN_5_5M: ret = DESC90_RATE5_5M; break; -- case MGN_11M: ret = DESC90_RATE11M; break; -- case MGN_6M: ret = DESC90_RATE6M; break; -- case MGN_9M: ret = DESC90_RATE9M; break; -- case MGN_12M: ret = DESC90_RATE12M; break; -- case MGN_18M: ret = DESC90_RATE18M; break; -- case MGN_24M: ret = DESC90_RATE24M; break; -- case MGN_36M: ret = DESC90_RATE36M; break; -- case MGN_48M: ret = DESC90_RATE48M; break; -- case MGN_54M: ret = DESC90_RATE54M; break; -- -- // HT rate since here -- case MGN_MCS0: ret = DESC90_RATEMCS0; break; -- case MGN_MCS1: ret = DESC90_RATEMCS1; break; -- case MGN_MCS2: ret = DESC90_RATEMCS2; break; -- case MGN_MCS3: ret = DESC90_RATEMCS3; break; -- case MGN_MCS4: ret = DESC90_RATEMCS4; break; -- case MGN_MCS5: ret = DESC90_RATEMCS5; break; -- case MGN_MCS6: ret = DESC90_RATEMCS6; break; -- case MGN_MCS7: ret = DESC90_RATEMCS7; break; -- case MGN_MCS8: ret = DESC90_RATEMCS8; break; -- case MGN_MCS9: ret = DESC90_RATEMCS9; break; -- case MGN_MCS10: ret = DESC90_RATEMCS10; break; -- case MGN_MCS11: ret = DESC90_RATEMCS11; break; -- case MGN_MCS12: ret = DESC90_RATEMCS12; break; -- case MGN_MCS13: ret = DESC90_RATEMCS13; break; -- case MGN_MCS14: ret = DESC90_RATEMCS14; break; -- case MGN_MCS15: ret = DESC90_RATEMCS15; break; -- case (0x80|0x20): ret = DESC90_RATEMCS32; break; -- -- default: break; -- } -- return ret; --} -- -- --static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) --{ -- u8 tmp_Short; -- -- tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); -- -- if(TxHT==1 && TxRate != DESC90_RATEMCS15) -- tmp_Short = 0; -- -- return tmp_Short; --} -- --/* -- * The tx procedure is just as following, -- * skb->cb will contain all the following information, -- * priority, morefrag, rate, &dev. -- */ --static short rtl8192_tx(struct r8192_priv *priv, struct sk_buff* skb) --{ -- struct rtl8192_tx_ring *ring; -- unsigned long flags; -- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); -- tx_desc_819x_pci *pdesc = NULL; -- TX_FWINFO_8190PCI *pTxFwInfo = NULL; -- dma_addr_t mapping; -- bool multi_addr = false, broad_addr = false, uni_addr = false; -- u8 *pda_addr = NULL; -- int idx; -- -- if (priv->bdisable_nic) { -- RT_TRACE(COMP_ERR, "Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", -- skb->len, tcb_desc->queue_index); -- return skb->len; -- } -- --#ifdef ENABLE_LPS -- priv->ieee80211->bAwakePktSent = true; --#endif -- -- mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); -- -- /* collect the tx packets statitcs */ -- pda_addr = ((u8 *)skb->data) + sizeof(TX_FWINFO_8190PCI); -- if (is_multicast_ether_addr(pda_addr)) -- multi_addr = true; -- else if (is_broadcast_ether_addr(pda_addr)) -- broad_addr = true; -- else -- uni_addr = true; -- -- if (uni_addr) -- priv->stats.txbytesunicast += (u8)(skb->len) - sizeof(TX_FWINFO_8190PCI); -- -- /* fill tx firmware */ -- pTxFwInfo = (PTX_FWINFO_8190PCI)skb->data; -- memset(pTxFwInfo, 0, sizeof(TX_FWINFO_8190PCI)); -- pTxFwInfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; -- pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)tcb_desc->data_rate); -- pTxFwInfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; -- pTxFwInfo->Short = QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, tcb_desc); -- -- /* Aggregation related */ -- if (tcb_desc->bAMPDUEnable) { -- pTxFwInfo->AllowAggregation = 1; -- pTxFwInfo->RxMF = tcb_desc->ampdu_factor; -- pTxFwInfo->RxAMD = tcb_desc->ampdu_density; -- } else { -- pTxFwInfo->AllowAggregation = 0; -- pTxFwInfo->RxMF = 0; -- pTxFwInfo->RxAMD = 0; -- } -- -- /* Protection mode related */ -- pTxFwInfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; -- pTxFwInfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; -- pTxFwInfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; -- pTxFwInfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; -- pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); -- pTxFwInfo->RtsBandwidth = 0; -- pTxFwInfo->RtsSubcarrier = tcb_desc->RTSSC; -- pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : (tcb_desc->bRTSUseShortGI? 1 : 0); -- -- /* Set Bandwidth and sub-channel settings. */ -- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { -- if (tcb_desc->bPacketBW) { -- pTxFwInfo->TxBandwidth = 1; -- /* use duplicated mode */ -- pTxFwInfo->TxSubCarrier = 0; -- } else { -- pTxFwInfo->TxBandwidth = 0; -- pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; -- } -- } else { -- pTxFwInfo->TxBandwidth = 0; -- pTxFwInfo->TxSubCarrier = 0; -- } -- -- spin_lock_irqsave(&priv->irq_th_lock, flags); -- ring = &priv->tx_ring[tcb_desc->queue_index]; -- if (tcb_desc->queue_index != BEACON_QUEUE) -- idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; -- else -- idx = 0; -- -- pdesc = &ring->desc[idx]; -- if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { -- RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d,idx = %d,%x\n", -- tcb_desc->queue_index, ring->idx, idx, skb->len); -- spin_unlock_irqrestore(&priv->irq_th_lock, flags); -- return skb->len; -- } -- -- /* fill tx descriptor */ -- memset(pdesc, 0, 12); -- -- /*DWORD 0*/ -- pdesc->LINIP = 0; -- pdesc->CmdInit = 1; -- pdesc->Offset = sizeof(TX_FWINFO_8190PCI) + 8; /* We must add 8!! */ -- pdesc->PktSize = (u16)skb->len-sizeof(TX_FWINFO_8190PCI); -- -- /*DWORD 1*/ -- pdesc->SecCAMID = 0; -- pdesc->RATid = tcb_desc->RATRIndex; -- -- pdesc->NoEnc = 1; -- pdesc->SecType = 0x0; -- if (tcb_desc->bHwSec) { -- switch (priv->ieee80211->pairwise_key_type) { -- case KEY_TYPE_WEP40: -- case KEY_TYPE_WEP104: -- pdesc->SecType = 0x1; -- pdesc->NoEnc = 0; -- break; -- case KEY_TYPE_TKIP: -- pdesc->SecType = 0x2; -- pdesc->NoEnc = 0; -- break; -- case KEY_TYPE_CCMP: -- pdesc->SecType = 0x3; -- pdesc->NoEnc = 0; -- break; -- case KEY_TYPE_NA: -- pdesc->SecType = 0x0; -- pdesc->NoEnc = 1; -- break; -- } -- } -- -- /* Set Packet ID */ -- pdesc->PktId = 0x0; -- -- pdesc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); -- pdesc->TxFWInfoSize = sizeof(TX_FWINFO_8190PCI); -- -- pdesc->DISFB = tcb_desc->bTxDisableRateFallBack; -- pdesc->USERATE = tcb_desc->bTxUseDriverAssingedRate; -- -- pdesc->FirstSeg = 1; -- pdesc->LastSeg = 1; -- pdesc->TxBufferSize = skb->len; -- -- pdesc->TxBuffAddr = cpu_to_le32(mapping); -- __skb_queue_tail(&ring->queue, skb); -- pdesc->OWN = 1; -- spin_unlock_irqrestore(&priv->irq_th_lock, flags); -- priv->ieee80211->dev->trans_start = jiffies; -- write_nic_word(priv, TPPoll, 0x01<queue_index); -- return 0; --} -- --static short rtl8192_alloc_rx_desc_ring(struct r8192_priv *priv) --{ -- rx_desc_819x_pci *entry = NULL; -- int i; -- -- priv->rx_ring = pci_alloc_consistent(priv->pdev, -- sizeof(*priv->rx_ring) * priv->rxringcount, &priv->rx_ring_dma); -- -- if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { -- RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); -- return -ENOMEM; -- } -- -- memset(priv->rx_ring, 0, sizeof(*priv->rx_ring) * priv->rxringcount); -- priv->rx_idx = 0; -- -- for (i = 0; i < priv->rxringcount; i++) { -- struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize); -- dma_addr_t *mapping; -- entry = &priv->rx_ring[i]; -- if (!skb) -- return 0; -- priv->rx_buf[i] = skb; -- mapping = (dma_addr_t *)skb->cb; -- *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), -- priv->rxbuffersize, PCI_DMA_FROMDEVICE); -- -- entry->BufferAddress = cpu_to_le32(*mapping); -- -- entry->Length = priv->rxbuffersize; -- entry->OWN = 1; -- } -- -- entry->EOR = 1; -- return 0; --} -- --static int rtl8192_alloc_tx_desc_ring(struct r8192_priv *priv, -- unsigned int prio, unsigned int entries) --{ -- tx_desc_819x_pci *ring; -- dma_addr_t dma; -- int i; -- -- ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); -- if (!ring || (unsigned long)ring & 0xFF) { -- RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); -- return -ENOMEM; -- } -- -- memset(ring, 0, sizeof(*ring)*entries); -- priv->tx_ring[prio].desc = ring; -- priv->tx_ring[prio].dma = dma; -- priv->tx_ring[prio].idx = 0; -- priv->tx_ring[prio].entries = entries; -- skb_queue_head_init(&priv->tx_ring[prio].queue); -- -- for (i = 0; i < entries; i++) -- ring[i].NextDescAddress = -- cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); -- -- return 0; --} -- --static short rtl8192_pci_initdescring(struct r8192_priv *priv) --{ -- u32 ret; -- int i; -- -- ret = rtl8192_alloc_rx_desc_ring(priv); -- if (ret) -- return ret; -- -- /* general process for other queue */ -- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { -- ret = rtl8192_alloc_tx_desc_ring(priv, i, priv->txringcount); -- if (ret) -- goto err_free_rings; -- } -- -- return 0; -- --err_free_rings: -- rtl8192_free_rx_ring(priv); -- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) -- if (priv->tx_ring[i].desc) -- rtl8192_free_tx_ring(priv, i); -- return 1; --} -- --static void rtl8192_pci_resetdescring(struct r8192_priv *priv) --{ -- int i; -- -- /* force the rx_idx to the first one */ -- if(priv->rx_ring) { -- rx_desc_819x_pci *entry = NULL; -- for (i = 0; i < priv->rxringcount; i++) { -- entry = &priv->rx_ring[i]; -- entry->OWN = 1; -- } -- priv->rx_idx = 0; -- } -- -- /* after reset, release previous pending packet, and force the -- * tx idx to the first one */ -- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { -- if (priv->tx_ring[i].desc) { -- struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; -- -- while (skb_queue_len(&ring->queue)) { -- tx_desc_819x_pci *entry = &ring->desc[ring->idx]; -- struct sk_buff *skb = __skb_dequeue(&ring->queue); -- -- pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), -- skb->len, PCI_DMA_TODEVICE); -- kfree_skb(skb); -- ring->idx = (ring->idx + 1) % ring->entries; -- } -- ring->idx = 0; -- } -- } --} -- --static void rtl8192_link_change(struct ieee80211_device *ieee) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- -- if (ieee->state == IEEE80211_LINKED) -- { -- rtl8192_net_update(priv); -- rtl8192_update_ratr_table(priv); -- -- //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 -- if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) -- EnableHWSecurityConfig8192(priv); -- } -- else -- { -- write_nic_byte(priv, 0x173, 0); -- } -- -- rtl8192_update_msr(priv); -- -- // 2007/10/16 MH MAC Will update TSF according to all received beacon, so we have -- // // To set CBSSID bit when link with any AP or STA. -- if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) -- { -- u32 reg = 0; -- reg = read_nic_dword(priv, RCR); -- if (priv->ieee80211->state == IEEE80211_LINKED) -- priv->ReceiveConfig = reg |= RCR_CBSSID; -- else -- priv->ReceiveConfig = reg &= ~RCR_CBSSID; -- write_nic_dword(priv, RCR, reg); -- } --} -- -- --static const struct ieee80211_qos_parameters def_qos_parameters = { -- {3,3,3,3},/* cw_min */ -- {7,7,7,7},/* cw_max */ -- {2,2,2,2},/* aifs */ -- {0,0,0,0},/* flags */ -- {0,0,0,0} /* tx_op_limit */ --}; -- --static void rtl8192_update_beacon(struct work_struct * work) --{ -- struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); -- struct ieee80211_device* ieee = priv->ieee80211; -- struct ieee80211_network* net = &ieee->current_network; -- -- if (ieee->pHTInfo->bCurrentHTSupport) -- HTUpdateSelfAndPeerSetting(ieee, net); -- ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; -- rtl8192_update_cap(priv, net->capability); --} -- --/* --* background support to run QoS activate functionality --*/ --static const int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; --static void rtl8192_qos_activate(struct work_struct * work) --{ -- struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); -- struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; -- u8 mode = priv->ieee80211->current_network.mode; -- u8 u1bAIFS; -- u32 u4bAcParam; -- int i; -- -- mutex_lock(&priv->mutex); -- if(priv->ieee80211->state != IEEE80211_LINKED) -- goto success; -- RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); -- /* It better set slot time at first */ -- /* For we just support b/g mode at present, let the slot time at 9/20 selection */ -- /* update the ac parameter to related registers */ -- for(i = 0; i < QOS_QUEUE_NUM; i++) { -- //Mode G/A: slotTimeTimer = 9; Mode B: 20 -- u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; -- u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| -- (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| -- (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| -- ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); -- write_nic_dword(priv, WDCAPARA_ADD[i], u4bAcParam); -- } -- --success: -- mutex_unlock(&priv->mutex); --} -- --static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, -- int active_network, -- struct ieee80211_network *network) --{ -- int ret = 0; -- u32 size = sizeof(struct ieee80211_qos_parameters); -- -- if(priv->ieee80211->state !=IEEE80211_LINKED) -- return ret; -- -- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) -- return ret; -- -- if (network->flags & NETWORK_HAS_QOS_MASK) { -- if (active_network && -- (network->flags & NETWORK_HAS_QOS_PARAMETERS)) -- network->qos_data.active = network->qos_data.supported; -- -- if ((network->qos_data.active == 1) && (active_network == 1) && -- (network->flags & NETWORK_HAS_QOS_PARAMETERS) && -- (network->qos_data.old_param_count != -- network->qos_data.param_count)) { -- network->qos_data.old_param_count = -- network->qos_data.param_count; -- queue_work(priv->priv_wq, &priv->qos_activate); -- RT_TRACE (COMP_QOS, "QoS parameters change call " -- "qos_activate\n"); -- } -- } else { -- memcpy(&priv->ieee80211->current_network.qos_data.parameters, -- &def_qos_parameters, size); -- -- if ((network->qos_data.active == 1) && (active_network == 1)) { -- queue_work(priv->priv_wq, &priv->qos_activate); -- RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); -- } -- network->qos_data.active = 0; -- network->qos_data.supported = 0; -- } -- -- return 0; --} -- --/* handle manage frame frame beacon and probe response */ --static int rtl8192_handle_beacon(struct ieee80211_device *ieee, -- struct ieee80211_beacon * beacon, -- struct ieee80211_network * network) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- -- rtl8192_qos_handle_probe_response(priv,1,network); -- -- queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); -- return 0; -- --} -- --/* -- * handling the beaconing responses. if we get different QoS setting -- * off the network from the associated setting, adjust the QoS setting -- */ --static int rtl8192_qos_association_resp(struct r8192_priv *priv, -- struct ieee80211_network *network) --{ -- int ret = 0; -- unsigned long flags; -- u32 size = sizeof(struct ieee80211_qos_parameters); -- int set_qos_param = 0; -- -- if ((priv == NULL) || (network == NULL)) -- return ret; -- -- if (priv->ieee80211->state != IEEE80211_LINKED) -- return ret; -- -- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) -- return ret; -- -- spin_lock_irqsave(&priv->ieee80211->lock, flags); -- if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { -- memcpy(&priv->ieee80211->current_network.qos_data.parameters, -- &network->qos_data.parameters, -- sizeof(struct ieee80211_qos_parameters)); -- priv->ieee80211->current_network.qos_data.active = 1; -- set_qos_param = 1; -- /* update qos parameter for current network */ -- priv->ieee80211->current_network.qos_data.old_param_count = -- priv->ieee80211->current_network.qos_data.param_count; -- priv->ieee80211->current_network.qos_data.param_count = -- network->qos_data.param_count; -- -- } else { -- memcpy(&priv->ieee80211->current_network.qos_data.parameters, -- &def_qos_parameters, size); -- priv->ieee80211->current_network.qos_data.active = 0; -- priv->ieee80211->current_network.qos_data.supported = 0; -- set_qos_param = 1; -- } -- -- spin_unlock_irqrestore(&priv->ieee80211->lock, flags); -- -- RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __FUNCTION__, -- network->flags, priv->ieee80211->current_network.qos_data.active); -- if (set_qos_param == 1) -- queue_work(priv->priv_wq, &priv->qos_activate); -- -- return ret; --} -- -- --static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee, -- struct ieee80211_assoc_response_frame *resp, -- struct ieee80211_network *network) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- rtl8192_qos_association_resp(priv, network); -- return 0; --} -- -- --/* updateRATRTabel for MCS only. Basic rate is not implemented. */ --static void rtl8192_update_ratr_table(struct r8192_priv* priv) --{ -- struct ieee80211_device* ieee = priv->ieee80211; -- u8* pMcsRate = ieee->dot11HTOperationalRateSet; -- u32 ratr_value = 0; -- u8 rate_index = 0; -- -- rtl8192_config_rate(priv, (u16*)(&ratr_value)); -- ratr_value |= (*(u16*)(pMcsRate)) << 12; -- -- switch (ieee->mode) -- { -- case IEEE_A: -- ratr_value &= 0x00000FF0; -- break; -- case IEEE_B: -- ratr_value &= 0x0000000F; -- break; -- case IEEE_G: -- ratr_value &= 0x00000FF7; -- break; -- case IEEE_N_24G: -- case IEEE_N_5G: -- if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC -- ratr_value &= 0x0007F007; -- else{ -- if (priv->rf_type == RF_1T2R) -- ratr_value &= 0x000FF007; -- else -- ratr_value &= 0x0F81F007; -- } -- break; -- default: -- break; -- } -- ratr_value &= 0x0FFFFFFF; -- if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ -- ratr_value |= 0x80000000; -- }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ -- ratr_value |= 0x80000000; -- } -- write_nic_dword(priv, RATR0+rate_index*4, ratr_value); -- write_nic_byte(priv, UFWP, 1); --} -- --static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee) --{ -- return !(ieee->rtllib_ap_sec_type && -- (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))); --} -- --static void rtl8192_refresh_supportrate(struct r8192_priv* priv) --{ -- struct ieee80211_device* ieee = priv->ieee80211; -- //we donot consider set support rate for ABG mode, only HT MCS rate is set here. -- if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) -- { -- memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); -- } -- else -- memset(ieee->Regdot11HTOperationalRateSet, 0, 16); --} -- --static u8 rtl8192_getSupportedWireleeMode(void) --{ -- return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B); --} -- --static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- u8 bSupportMode = rtl8192_getSupportedWireleeMode(); -- -- if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0)) -- { -- if(bSupportMode & WIRELESS_MODE_N_24G) -- { -- wireless_mode = WIRELESS_MODE_N_24G; -- } -- else if(bSupportMode & WIRELESS_MODE_N_5G) -- { -- wireless_mode = WIRELESS_MODE_N_5G; -- } -- else if((bSupportMode & WIRELESS_MODE_A)) -- { -- wireless_mode = WIRELESS_MODE_A; -- } -- else if((bSupportMode & WIRELESS_MODE_G)) -- { -- wireless_mode = WIRELESS_MODE_G; -- } -- else if((bSupportMode & WIRELESS_MODE_B)) -- { -- wireless_mode = WIRELESS_MODE_B; -- } -- else{ -- RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode); -- wireless_mode = WIRELESS_MODE_B; -- } -- } -- priv->ieee80211->mode = wireless_mode; -- -- if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) -- priv->ieee80211->pHTInfo->bEnableHT = 1; -- else -- priv->ieee80211->pHTInfo->bEnableHT = 0; -- RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); -- rtl8192_refresh_supportrate(priv); --} -- --static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee) --{ -- return ieee->bHalfWirelessN24GMode; --} -- --static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee) --{ -- int i=0; -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- -- for (i=0; i<=MGNT_QUEUE; i++) -- { -- if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) -- continue; -- if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ -- printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); -- return 0; -- } -- } -- return 1; --} -- --static void rtl8192_hw_sleep_down(struct r8192_priv *priv) --{ -- MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS); --} -- --static void rtl8192_hw_wakeup(struct ieee80211_device *ieee) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS); --} -- --static void rtl8192_hw_wakeup_wq (struct work_struct *work) --{ -- struct delayed_work *dwork = container_of(work,struct delayed_work,work); -- struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); -- -- rtl8192_hw_wakeup(ieee); --} -- --#define MIN_SLEEP_TIME 50 --#define MAX_SLEEP_TIME 10000 --static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee->dev); -- u32 tmp; -- u32 rb = jiffies; -- -- // Writing HW register with 0 equals to disable -- // the timer, that is not really what we want -- // -- tl -= MSECS(8+16+7); -- -- // If the interval in witch we are requested to sleep is too -- // short then give up and remain awake -- // when we sleep after send null frame, the timer will be too short to sleep. -- // -- if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) -- ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { -- printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); -- return; -- } -- -- if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| -- ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| -- ((tlMSECS(MAX_SLEEP_TIME)))) { -- printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); -- return; -- } -- -- tmp = (tl>rb)?(tl-rb):(rb-tl); -- queue_delayed_work(priv->ieee80211->wq, -- &priv->ieee80211->hw_wakeup_wq,tmp); -- -- rtl8192_hw_sleep_down(priv); --} -- --static void rtl8192_init_priv_variable(struct r8192_priv *priv) --{ -- u8 i; -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- -- // Default Halt the NIC if RF is OFF. -- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_HALT_NIC; -- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_CLK_REQ; -- pPSC->RegRfPsLevel |= RT_RF_OFF_LEVL_ASPM; -- pPSC->RegRfPsLevel |= RT_RF_LPS_LEVEL_ASPM; -- pPSC->bLeisurePs = true; -- priv->ieee80211->RegMaxLPSAwakeIntvl = 5; -- priv->bHwRadioOff = false; -- -- priv->being_init_adapter = false; -- priv->txringcount = 64;//32; -- priv->rxbuffersize = 9100;//2048;//1024; -- priv->rxringcount = MAX_RX_COUNT;//64; -- priv->chan = 1; //set to channel 1 -- priv->RegWirelessMode = WIRELESS_MODE_AUTO; -- priv->RegChannelPlan = 0xf; -- priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO -- priv->ieee80211->iw_mode = IW_MODE_INFRA; -- priv->ieee80211->ieee_up=0; -- priv->retry_rts = DEFAULT_RETRY_RTS; -- priv->retry_data = DEFAULT_RETRY_DATA; -- priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; -- priv->ieee80211->rate = 110; //11 mbps -- priv->ieee80211->short_slot = 1; -- priv->promisc = (priv->ieee80211->dev->flags & IFF_PROMISC) ? 1:0; -- priv->bcck_in_ch14 = false; -- priv->CCKPresentAttentuation = 0; -- priv->rfa_txpowertrackingindex = 0; -- priv->rfc_txpowertrackingindex = 0; -- priv->CckPwEnl = 6; -- //added by amy for silent reset -- priv->ResetProgress = RESET_TYPE_NORESET; -- priv->bForcedSilentReset = 0; -- priv->bDisableNormalResetCheck = false; -- priv->force_reset = false; -- //added by amy for power save -- priv->RfOffReason = 0; -- priv->bHwRfOffAction = 0; -- priv->PowerSaveControl.bInactivePs = true; -- priv->PowerSaveControl.bIPSModeBackup = false; -- -- priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; -- priv->ieee80211->iw_mode = IW_MODE_INFRA; -- priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | -- IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | -- IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;/* | -- IEEE_SOFTMAC_BEACONS;*///added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE; -- -- priv->ieee80211->active_scan = 1; -- priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; -- priv->ieee80211->host_encrypt = 1; -- priv->ieee80211->host_decrypt = 1; -- priv->ieee80211->start_send_beacons = rtl8192_start_beacon; -- priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon; -- priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; -- priv->ieee80211->set_chan = rtl8192_set_chan; -- priv->ieee80211->link_change = rtl8192_link_change; -- priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; -- priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop; -- priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume; -- priv->ieee80211->init_wmmparam_flag = 0; -- priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; -- priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc; -- priv->ieee80211->tx_headroom = sizeof(TX_FWINFO_8190PCI); -- priv->ieee80211->qos_support = 1; -- priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; -- priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; -- priv->ieee80211->handle_beacon = rtl8192_handle_beacon; -- -- priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup; -- priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep; -- priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty; -- priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8190Pci; -- priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; -- priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xPci; -- -- priv->ieee80211->InitialGainHandler = InitialGain819xPci; -- --#ifdef ENABLE_IPS -- priv->ieee80211->ieee80211_ips_leave_wq = ieee80211_ips_leave_wq; -- priv->ieee80211->ieee80211_ips_leave = ieee80211_ips_leave; --#endif --#ifdef ENABLE_LPS -- priv->ieee80211->LeisurePSLeave = LeisurePSLeave; --#endif -- -- priv->ieee80211->SetHwRegHandler = rtl8192e_SetHwReg; -- priv->ieee80211->rtllib_ap_sec_type = rtl8192e_ap_sec_type; -- -- priv->ShortRetryLimit = 0x30; -- priv->LongRetryLimit = 0x30; -- -- priv->ReceiveConfig = RCR_ADD3 | -- RCR_AMF | RCR_ADF | //accept management/data -- RCR_AICV | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. -- RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC -- RCR_AAP | ((u32)7<pFirmware = vzalloc(sizeof(rt_firmware)); -- -- /* rx related queue */ -- skb_queue_head_init(&priv->skb_queue); -- -- /* Tx related queue */ -- for(i = 0; i < MAX_QUEUE_SIZE; i++) { -- skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]); -- } -- for(i = 0; i < MAX_QUEUE_SIZE; i++) { -- skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]); -- } -- priv->rf_set_chan = rtl8192_phy_SwChnl; --} -- --static void rtl8192_init_priv_lock(struct r8192_priv* priv) --{ -- spin_lock_init(&priv->irq_th_lock); -- spin_lock_init(&priv->rf_ps_lock); -- sema_init(&priv->wx_sem,1); -- sema_init(&priv->rf_sem,1); -- mutex_init(&priv->mutex); --} -- --/* init tasklet and wait_queue here */ --#define DRV_NAME "wlan0" --static void rtl8192_init_priv_task(struct r8192_priv *priv) --{ -- priv->priv_wq = create_workqueue(DRV_NAME); -- --#ifdef ENABLE_IPS -- INIT_WORK(&priv->ieee80211->ips_leave_wq, IPSLeave_wq); --#endif -- -- INIT_WORK(&priv->reset_wq, rtl8192_restart); -- INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); -- INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); -- INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); -- INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); -- INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); -- INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8192_hw_wakeup_wq); -- -- tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, -- (unsigned long) priv); -- tasklet_init(&priv->irq_tx_tasklet, rtl8192_irq_tx_tasklet, -- (unsigned long) priv); -- tasklet_init(&priv->irq_prepare_beacon_tasklet, rtl8192_prepare_beacon, -- (unsigned long) priv); --} -- --static void rtl8192_get_eeprom_size(struct r8192_priv *priv) --{ -- u16 curCR = 0; -- RT_TRACE(COMP_INIT, "===========>%s()\n", __FUNCTION__); -- curCR = read_nic_dword(priv, EPROM_CMD); -- RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); -- //whether need I consider BIT5? -- priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EPROM_93c56 : EPROM_93c46; -- RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype); --} -- --/* -- * Adapter->EEPROMAddressSize should be set before this function call. -- * EEPROM address size can be got through GetEEPROMSize8185() -- */ --static void rtl8192_read_eeprom_info(struct r8192_priv *priv) --{ -- struct net_device *dev = priv->ieee80211->dev; -- u8 tempval; -- u8 ICVer8192, ICVer8256; -- u16 i,usValue, IC_Version; -- u16 EEPROMId; -- u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; -- RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); -- -- -- // TODO: I don't know if we need to apply EF function to EEPROM read function -- -- //2 Read EEPROM ID to make sure autoload is success -- EEPROMId = eprom_read(priv, 0); -- if( EEPROMId != RTL8190_EEPROM_ID ) -- { -- RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); -- priv->AutoloadFailFlag=true; -- } -- else -- { -- priv->AutoloadFailFlag=false; -- } -- -- // -- // Assign Chip Version ID -- // -- // Read IC Version && Channel Plan -- if(!priv->AutoloadFailFlag) -- { -- // VID, PID -- priv->eeprom_vid = eprom_read(priv, (EEPROM_VID >> 1)); -- priv->eeprom_did = eprom_read(priv, (EEPROM_DID >> 1)); -- -- usValue = eprom_read(priv, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; -- priv->eeprom_CustomerID = (u8)( usValue & 0xff); -- usValue = eprom_read(priv, (EEPROM_ICVersion_ChannelPlan>>1)); -- priv->eeprom_ChannelPlan = usValue&0xff; -- IC_Version = ((usValue&0xff00)>>8); -- -- ICVer8192 = (IC_Version&0xf); //bit0~3; 1:A cut, 2:B cut, 3:C cut... -- ICVer8256 = ((IC_Version&0xf0)>>4);//bit4~6, bit7 reserved for other RF chip; 1:A cut, 2:B cut, 3:C cut... -- RT_TRACE(COMP_INIT, "ICVer8192 = 0x%x\n", ICVer8192); -- RT_TRACE(COMP_INIT, "ICVer8256 = 0x%x\n", ICVer8256); -- if(ICVer8192 == 0x2) //B-cut -- { -- if(ICVer8256 == 0x5) //E-cut -- priv->card_8192_version= VERSION_8190_BE; -- } -- -- switch(priv->card_8192_version) -- { -- case VERSION_8190_BD: -- case VERSION_8190_BE: -- break; -- default: -- priv->card_8192_version = VERSION_8190_BD; -- break; -- } -- RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); -- } -- else -- { -- priv->card_8192_version = VERSION_8190_BD; -- priv->eeprom_vid = 0; -- priv->eeprom_did = 0; -- priv->eeprom_CustomerID = 0; -- priv->eeprom_ChannelPlan = 0; -- RT_TRACE(COMP_INIT, "IC Version = 0x%x\n", 0xff); -- } -- -- RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); -- RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); -- RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); -- -- //2 Read Permanent MAC address -- if(!priv->AutoloadFailFlag) -- { -- for(i = 0; i < 6; i += 2) -- { -- usValue = eprom_read(priv, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); -- *(u16*)(&dev->dev_addr[i]) = usValue; -- } -- } else { -- // when auto load failed, the last address byte set to be a random one. -- // added by david woo.2007/11/7 -- memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); -- } -- -- RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", dev->dev_addr); -- -- //2 TX Power Check EEPROM Fail or not -- if(priv->card_8192_version > VERSION_8190_BD) { -- priv->bTXPowerDataReadFromEEPORM = true; -- } else { -- priv->bTXPowerDataReadFromEEPORM = false; -- } -- -- // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R -- priv->rf_type = RTL819X_DEFAULT_RF_TYPE; -- -- if(priv->card_8192_version > VERSION_8190_BD) -- { -- // Read RF-indication and Tx Power gain index diff of legacy to HT OFDM rate. -- if(!priv->AutoloadFailFlag) -- { -- tempval = (eprom_read(priv, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; -- priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; // bit[3:0] -- -- if (tempval&0x80) //RF-indication, bit[7] -- priv->rf_type = RF_1T2R; -- else -- priv->rf_type = RF_2T4R; -- } -- else -- { -- priv->EEPROMLegacyHTTxPowerDiff = EEPROM_Default_LegacyHTTxPowerDiff; -- } -- RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", -- priv->EEPROMLegacyHTTxPowerDiff); -- -- // Read ThermalMeter from EEPROM -- if(!priv->AutoloadFailFlag) -- { -- priv->EEPROMThermalMeter = (u8)(((eprom_read(priv, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); -- } -- else -- { -- priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; -- } -- RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); -- //vivi, for tx power track -- priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; -- -- if(priv->epromtype == EPROM_93c46) -- { -- // Read antenna tx power offset of B/C/D to A and CrystalCap from EEPROM -- if(!priv->AutoloadFailFlag) -- { -- usValue = eprom_read(priv, (EEPROM_TxPwDiff_CrystalCap>>1)); -- priv->EEPROMAntPwDiff = (usValue&0x0fff); -- priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); -- } -- else -- { -- priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; -- priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; -- } -- RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); -- RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); -- -- // -- // Get per-channel Tx Power Level -- // -- for(i=0; i<14; i+=2) -- { -- if(!priv->AutoloadFailFlag) -- { -- usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); -- } -- else -- { -- usValue = EEPROM_Default_TxPower; -- } -- *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; -- RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); -- RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); -- } -- for(i=0; i<14; i+=2) -- { -- if(!priv->AutoloadFailFlag) -- { -- usValue = eprom_read(priv, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); -- } -- else -- { -- usValue = EEPROM_Default_TxPower; -- } -- *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; -- RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); -- RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); -- } -- } -- -- // -- // Update HAL variables. -- // -- if(priv->epromtype == EPROM_93c46) -- { -- for(i=0; i<14; i++) -- { -- priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; -- priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; -- } -- priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; -- // Antenna B gain offset to antenna A, bit0~3 -- priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); -- // Antenna C gain offset to antenna A, bit4~7 -- priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); -- // Antenna D gain offset to antenna A, bit8~11 -- priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); -- // CrystalCap, bit12~15 -- priv->CrystalCap = priv->EEPROMCrystalCap; -- // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 -- priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); -- priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); -- } -- else if(priv->epromtype == EPROM_93c56) -- { -- for(i=0; i<3; i++) // channel 1~3 use the same Tx Power Level. -- { -- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; -- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; -- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; -- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; -- } -- for(i=3; i<9; i++) // channel 4~9 use the same Tx Power Level -- { -- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; -- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; -- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; -- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; -- } -- for(i=9; i<14; i++) // channel 10~14 use the same Tx Power Level -- { -- priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; -- priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; -- priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; -- priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; -- } -- for(i=0; i<14; i++) -- RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); -- for(i=0; i<14; i++) -- RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); -- for(i=0; i<14; i++) -- RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); -- for(i=0; i<14; i++) -- RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); -- priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; -- priv->AntennaTxPwDiff[0] = 0; -- priv->AntennaTxPwDiff[1] = 0; -- priv->AntennaTxPwDiff[2] = 0; -- priv->CrystalCap = priv->EEPROMCrystalCap; -- // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 -- priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); -- priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); -- } -- } -- -- if(priv->rf_type == RF_1T2R) -- { -- RT_TRACE(COMP_INIT, "1T2R config\n"); -- } -- else if (priv->rf_type == RF_2T4R) -- { -- RT_TRACE(COMP_INIT, "2T4R config\n"); -- } -- -- // 2008/01/16 MH We can only know RF type in the function. So we have to init -- // DIG RATR table again. -- init_rate_adaptive(priv); -- -- //1 Make a copy for following variables and we can change them if we want -- -- if(priv->RegChannelPlan == 0xf) -- { -- priv->ChannelPlan = priv->eeprom_ChannelPlan; -- } -- else -- { -- priv->ChannelPlan = priv->RegChannelPlan; -- } -- -- // -- // Used PID and DID to Set CustomerID -- // -- if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) -- { -- priv->CustomerID = RT_CID_DLINK; -- } -- -- switch(priv->eeprom_CustomerID) -- { -- case EEPROM_CID_DEFAULT: -- priv->CustomerID = RT_CID_DEFAULT; -- break; -- case EEPROM_CID_CAMEO: -- priv->CustomerID = RT_CID_819x_CAMEO; -- break; -- case EEPROM_CID_RUNTOP: -- priv->CustomerID = RT_CID_819x_RUNTOP; -- break; -- case EEPROM_CID_NetCore: -- priv->CustomerID = RT_CID_819x_Netcore; -- break; -- case EEPROM_CID_TOSHIBA: // Merge by Jacken, 2008/01/31 -- priv->CustomerID = RT_CID_TOSHIBA; -- if(priv->eeprom_ChannelPlan&0x80) -- priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; -- else -- priv->ChannelPlan = 0x0; -- RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", -- priv->ChannelPlan); -- break; -- case EEPROM_CID_Nettronix: -- priv->CustomerID = RT_CID_Nettronix; -- break; -- case EEPROM_CID_Pronet: -- priv->CustomerID = RT_CID_PRONET; -- break; -- case EEPROM_CID_DLINK: -- priv->CustomerID = RT_CID_DLINK; -- break; -- -- case EEPROM_CID_WHQL: -- break; -- default: -- // value from RegCustomerID -- break; -- } -- -- //Avoid the channel plan array overflow, by Bruce, 2007-08-27. -- if(priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) -- priv->ChannelPlan = 0; //FCC -- -- if( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) -- priv->ieee80211->bSupportRemoteWakeUp = true; -- else -- priv->ieee80211->bSupportRemoteWakeUp = false; -- -- -- RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); -- RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); -- RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); --} -- -- --static short rtl8192_get_channel_map(struct r8192_priv *priv) --{ --#ifdef ENABLE_DOT11D -- if(priv->ChannelPlan> COUNTRY_CODE_GLOBAL_DOMAIN){ -- printk("rtl8180_init:Error channel plan! Set to default.\n"); -- priv->ChannelPlan= 0; -- } -- RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); -- -- rtl819x_set_channel_map(priv->ChannelPlan, priv); --#else -- int ch,i; -- //Set Default Channel Plan -- if(!channels){ -- DMESG("No channels, aborting"); -- return -1; -- } -- ch=channels; -- priv->ChannelPlan= 0;//hikaru -- // set channels 1..14 allowed in given locale -- for (i=1; i<=14; i++) { -- (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); -- ch >>= 1; -- } --#endif -- return 0; --} -- --static short rtl8192_init(struct r8192_priv *priv) --{ -- struct net_device *dev = priv->ieee80211->dev; -- -- memset(&(priv->stats),0,sizeof(struct Stats)); -- rtl8192_init_priv_variable(priv); -- rtl8192_init_priv_lock(priv); -- rtl8192_init_priv_task(priv); -- rtl8192_get_eeprom_size(priv); -- rtl8192_read_eeprom_info(priv); -- rtl8192_get_channel_map(priv); -- init_hal_dm(priv); -- init_timer(&priv->watch_dog_timer); -- priv->watch_dog_timer.data = (unsigned long)priv; -- priv->watch_dog_timer.function = watch_dog_timer_callback; -- if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) { -- printk("Error allocating IRQ %d",dev->irq); -- return -1; -- }else{ -- priv->irq=dev->irq; -- printk("IRQ %d",dev->irq); -- } -- if (rtl8192_pci_initdescring(priv) != 0){ -- printk("Endopoints initialization failed"); -- return -1; -- } -- -- return 0; --} -- --/* -- * Actually only set RRSR, RATR and BW_OPMODE registers -- * not to do all the hw config as its name says -- * This part need to modified according to the rate set we filtered -- */ --static void rtl8192_hwconfig(struct r8192_priv *priv) --{ -- u32 regRATR = 0, regRRSR = 0; -- u8 regBwOpMode = 0, regTmp = 0; -- --// Set RRSR, RATR, and BW_OPMODE registers -- // -- switch (priv->ieee80211->mode) -- { -- case WIRELESS_MODE_B: -- regBwOpMode = BW_OPMODE_20MHZ; -- regRATR = RATE_ALL_CCK; -- regRRSR = RATE_ALL_CCK; -- break; -- case WIRELESS_MODE_A: -- regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; -- regRATR = RATE_ALL_OFDM_AG; -- regRRSR = RATE_ALL_OFDM_AG; -- break; -- case WIRELESS_MODE_G: -- regBwOpMode = BW_OPMODE_20MHZ; -- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -- break; -- case WIRELESS_MODE_AUTO: -- case WIRELESS_MODE_N_24G: -- // It support CCK rate by default. -- // CCK rate will be filtered out only when associated AP does not support it. -- regBwOpMode = BW_OPMODE_20MHZ; -- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; -- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -- break; -- case WIRELESS_MODE_N_5G: -- regBwOpMode = BW_OPMODE_5G; -- regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; -- regRRSR = RATE_ALL_OFDM_AG; -- break; -- } -- -- write_nic_byte(priv, BW_OPMODE, regBwOpMode); -- { -- u32 ratr_value = 0; -- ratr_value = regRATR; -- if (priv->rf_type == RF_1T2R) -- { -- ratr_value &= ~(RATE_ALL_OFDM_2SS); -- } -- write_nic_dword(priv, RATR0, ratr_value); -- write_nic_byte(priv, UFWP, 1); -- } -- regTmp = read_nic_byte(priv, 0x313); -- regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); -- write_nic_dword(priv, RRSR, regRRSR); -- -- // -- // Set Retry Limit here -- // -- write_nic_word(priv, RETRY_LIMIT, -- priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | -- priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); -- // Set Contention Window here -- -- // Set Tx AGC -- -- // Set Tx Antenna including Feedback control -- -- // Set Auto Rate fallback control -- -- --} -- -- --static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv) --{ -- struct net_device *dev = priv->ieee80211->dev; -- u32 ulRegRead; -- RT_STATUS rtStatus = RT_STATUS_SUCCESS; -- u8 tmpvalue; -- u8 ICVersion,SwitchingRegulatorOutput; -- bool bfirmwareok = true; -- u32 tmpRegA, tmpRegC, TempCCk; -- int i =0; -- -- RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__); -- priv->being_init_adapter = true; -- rtl8192_pci_resetdescring(priv); -- // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W. -- priv->Rf_Mode = RF_OP_By_SW_3wire; -- -- //dPLL on -- if(priv->ResetProgress == RESET_TYPE_NORESET) -- { -- write_nic_byte(priv, ANAPAR, 0x37); -- // Accordign to designer's explain, LBUS active will never > 10ms. We delay 10ms -- // Joseph increae the time to prevent firmware download fail -- mdelay(500); -- } -- -- //PlatformSleepUs(10000); -- // For any kind of InitializeAdapter process, we shall use system now!! -- priv->pFirmware->firmware_status = FW_STATUS_0_INIT; -- -- // -- //3 //Config CPUReset Register -- //3// -- //3 Firmware Reset Or Not -- ulRegRead = read_nic_dword(priv, CPU_GEN); -- if(priv->pFirmware->firmware_status == FW_STATUS_0_INIT) -- { //called from MPInitialized. do nothing -- ulRegRead |= CPU_GEN_SYSTEM_RESET; -- }else if(priv->pFirmware->firmware_status == FW_STATUS_5_READY) -- ulRegRead |= CPU_GEN_FIRMWARE_RESET; // Called from MPReset -- else -- RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status); -- -- write_nic_dword(priv, CPU_GEN, ulRegRead); -- -- //3// -- //3 //Fix the issue of E-cut high temperature issue -- //3// -- // TODO: E cut only -- ICVersion = read_nic_byte(priv, IC_VERRSION); -- if(ICVersion >= 0x4) //E-cut only -- { -- // HW SD suggest that we should not wirte this register too often, so driver -- // should readback this register. This register will be modified only when -- // power on reset -- SwitchingRegulatorOutput = read_nic_byte(priv, SWREGULATOR); -- if(SwitchingRegulatorOutput != 0xb8) -- { -- write_nic_byte(priv, SWREGULATOR, 0xa8); -- mdelay(1); -- write_nic_byte(priv, SWREGULATOR, 0xb8); -- } -- } -- -- //3// -- //3// Initialize BB before MAC -- //3// -- RT_TRACE(COMP_INIT, "BB Config Start!\n"); -- rtStatus = rtl8192_BBConfig(priv); -- if(rtStatus != RT_STATUS_SUCCESS) -- { -- RT_TRACE(COMP_ERR, "BB Config failed\n"); -- return rtStatus; -- } -- RT_TRACE(COMP_INIT,"BB Config Finished!\n"); -- -- //3//Set Loopback mode or Normal mode -- //3// -- //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings -- // because setting of System_Reset bit reset MAC to default transmission mode. -- //Loopback mode or not -- priv->LoopbackMode = RTL819X_NO_LOOPBACK; -- if(priv->ResetProgress == RESET_TYPE_NORESET) -- { -- ulRegRead = read_nic_dword(priv, CPU_GEN); -- if(priv->LoopbackMode == RTL819X_NO_LOOPBACK) -- { -- ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); -- } -- else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) -- { -- ulRegRead |= CPU_CCK_LOOPBACK; -- } -- else -- { -- RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); -- } -- -- //2008.06.03, for WOL -- //ulRegRead &= (~(CPU_GEN_GPIO_UART)); -- write_nic_dword(priv, CPU_GEN, ulRegRead); -- -- // 2006.11.29. After reset cpu, we sholud wait for a second, otherwise, it may fail to write registers. Emily -- udelay(500); -- } -- //3Set Hardware(Do nothing now) -- rtl8192_hwconfig(priv); -- //2======================================================= -- // Common Setting for all of the FPGA platform. (part 1) -- //2======================================================= -- // If there is changes, please make sure it applies to all of the FPGA version -- //3 Turn on Tx/Rx -- write_nic_byte(priv, CMDR, CR_RE|CR_TE); -- -- //2Set Tx dma burst -- write_nic_byte(priv, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); -- write_nic_word(priv, MAC4, ((u16*)(dev->dev_addr + 4))[0]); -- //set RCR -- write_nic_dword(priv, RCR, priv->ReceiveConfig); -- -- //3 Initialize Number of Reserved Pages in Firmware Queue -- write_nic_dword(priv, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | -- NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | -- NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | -- NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) -- rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode); -- //----------------------------------------------------------------------------- -- // Set up security related. 070106, by rcnjko: -- // 1. Clear all H/W keys. -- // 2. Enable H/W encryption/decryption. -- //----------------------------------------------------------------------------- -- CamResetAllEntry(priv); -- { -- u8 SECR_value = 0x0; -- SECR_value |= SCR_TxEncEnable; -- SECR_value |= SCR_RxDecEnable; -- SECR_value |= SCR_NoSKMC; -- write_nic_byte(priv, SECR, SECR_value); -- } -- //3Beacon related -- write_nic_word(priv, ATIMWND, 2); -- write_nic_word(priv, BCN_INTERVAL, 100); -- for (i=0; icard_8192_version > (u8) VERSION_8190_BD) { -- rtl8192_phy_getTxPower(priv); -- rtl8192_phy_setTxPower(priv, priv->chan); -- } -- -- //if D or C cut -- tmpvalue = read_nic_byte(priv, IC_VERRSION); -- priv->IC_Cut = tmpvalue; -- RT_TRACE(COMP_INIT, "priv->IC_Cut = 0x%x\n", priv->IC_Cut); -- if(priv->IC_Cut >= IC_VersionCut_D) -- { -- //pHalData->bDcut = TRUE; -- if(priv->IC_Cut == IC_VersionCut_D) -- RT_TRACE(COMP_INIT, "D-cut\n"); -- if(priv->IC_Cut == IC_VersionCut_E) -- { -- RT_TRACE(COMP_INIT, "E-cut\n"); -- // HW SD suggest that we should not wirte this register too often, so driver -- // should readback this register. This register will be modified only when -- // power on reset -- } -- } -- else -- { -- //pHalData->bDcut = FALSE; -- RT_TRACE(COMP_INIT, "Before C-cut\n"); -- } -- -- //Firmware download -- RT_TRACE(COMP_INIT, "Load Firmware!\n"); -- bfirmwareok = init_firmware(priv); -- if(bfirmwareok != true) { -- rtStatus = RT_STATUS_FAILURE; -- return rtStatus; -- } -- RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); -- -- //RF config -- if(priv->ResetProgress == RESET_TYPE_NORESET) -- { -- RT_TRACE(COMP_INIT, "RF Config Started!\n"); -- rtStatus = rtl8192_phy_RFConfig(priv); -- if(rtStatus != RT_STATUS_SUCCESS) -- { -- RT_TRACE(COMP_ERR, "RF Config failed\n"); -- return rtStatus; -- } -- RT_TRACE(COMP_INIT, "RF Config Finished!\n"); -- } -- rtl8192_phy_updateInitGain(priv); -- -- /*---- Set CCK and OFDM Block "ON"----*/ -- rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn, 0x1); -- rtl8192_setBBreg(priv, rFPGA0_RFMOD, bOFDMEn, 0x1); -- -- //Enable Led -- write_nic_byte(priv, 0x87, 0x0); -- -- //2======================================================= -- // RF Power Save -- //2======================================================= --#ifdef ENABLE_IPS -- --{ -- if(priv->RfOffReason > RF_CHANGE_BY_PS) -- { // H/W or S/W RF OFF before sleep. -- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__,priv->RfOffReason); -- MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); -- } -- else if(priv->RfOffReason >= RF_CHANGE_BY_IPS) -- { // H/W or S/W RF OFF before sleep. -- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d)\n", __FUNCTION__, priv->RfOffReason); -- MgntActSet_RF_State(priv, eRfOff, priv->RfOffReason); -- } -- else -- { -- RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__FUNCTION__); -- priv->eRFPowerState = eRfOn; -- priv->RfOffReason = 0; -- } --} --#endif -- // We can force firmware to do RF-R/W -- if(priv->ieee80211->FwRWRF) -- priv->Rf_Mode = RF_OP_By_FW; -- else -- priv->Rf_Mode = RF_OP_By_SW_3wire; -- -- if(priv->ResetProgress == RESET_TYPE_NORESET) -- { -- dm_initialize_txpower_tracking(priv); -- -- if(priv->IC_Cut >= IC_VersionCut_D) -- { -- tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); -- tmpRegC = rtl8192_QueryBBReg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord); -- for(i = 0; itxbbgain_table[i].txbbgain_value) -- { -- priv->rfa_txpowertrackingindex= (u8)i; -- priv->rfa_txpowertrackingindex_real= (u8)i; -- priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; -- break; -- } -- } -- -- TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); -- -- for(i=0 ; icck_txbbgain_table[i].ccktxbb_valuearray[0]) -- { -- priv->CCKPresentAttentuation_20Mdefault =(u8) i; -- break; -- } -- } -- priv->CCKPresentAttentuation_40Mdefault = 0; -- priv->CCKPresentAttentuation_difference = 0; -- priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; -- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); -- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); -- RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); -- RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); -- priv->btxpower_tracking = FALSE;//TEMPLY DISABLE -- } -- } -- -- rtl8192_irq_enable(priv); -- priv->being_init_adapter = false; -- return rtStatus; -- --} -- --static void rtl8192_prepare_beacon(unsigned long arg) --{ -- struct r8192_priv *priv = (struct r8192_priv*) arg; -- struct sk_buff *skb; -- cb_desc *tcb_desc; -- -- skb = ieee80211_get_beacon(priv->ieee80211); -- tcb_desc = (cb_desc *)(skb->cb + 8); -- /* prepare misc info for the beacon xmit */ -- tcb_desc->queue_index = BEACON_QUEUE; -- /* IBSS does not support HT yet, use 1M defaultly */ -- tcb_desc->data_rate = 2; -- tcb_desc->RATRIndex = 7; -- tcb_desc->bTxDisableRateFallBack = 1; -- tcb_desc->bTxUseDriverAssingedRate = 1; -- -- skb_push(skb, priv->ieee80211->tx_headroom); -- if(skb){ -- rtl8192_tx(priv, skb); -- } --} -- -- --/* -- * configure registers for beacon tx and enables it via -- * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might -- * be used to stop beacon transmission -- */ --static void rtl8192_start_beacon(struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- struct ieee80211_network *net = &priv->ieee80211->current_network; -- u16 BcnTimeCfg = 0; -- u16 BcnCW = 6; -- u16 BcnIFS = 0xf; -- -- DMESG("Enabling beacon TX"); -- rtl8192_irq_disable(priv); -- //rtl8192_beacon_tx_enable(dev); -- -- /* ATIM window */ -- write_nic_word(priv, ATIMWND, 2); -- -- /* Beacon interval (in unit of TU) */ -- write_nic_word(priv, BCN_INTERVAL, net->beacon_interval); -- -- /* -- * DrvErlyInt (in unit of TU). -- * (Time to send interrupt to notify driver to c -- * hange beacon content) -- * */ -- write_nic_word(priv, BCN_DRV_EARLY_INT, 10); -- -- /* -- * BcnDMATIM(in unit of us). -- * Indicates the time before TBTT to perform beacon queue DMA -- * */ -- write_nic_word(priv, BCN_DMATIME, 256); -- -- /* -- * Force beacon frame transmission even after receiving -- * beacon frame from other ad hoc STA -- * */ -- write_nic_byte(priv, BCN_ERR_THRESH, 100); -- -- /* Set CW and IFS */ -- BcnTimeCfg |= BcnCW<RxCounter); -- // If rssi is small, we should check rx for long time because of bad rx. -- // or maybe it will continuous silent reset every 2 seconds. -- priv->rx_chk_cnt++; -- if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) -- { -- priv->rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ -- } -- else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && -- ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) || -- (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) ) -- -- { -- if(priv->rx_chk_cnt < 2) -- { -- return bStuck; -- } -- else -- { -- priv->rx_chk_cnt = 0; -- } -- } -- else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbCurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdbundecorated_smoothed_pwdb >= VeryLowRSSI) -- { -- if(priv->rx_chk_cnt < 4) -- { -- return bStuck; -- } -- else -- { -- priv->rx_chk_cnt = 0; -- } -- } -- else -- { -- if(priv->rx_chk_cnt < 8) -- { -- return bStuck; -- } -- else -- { -- priv->rx_chk_cnt = 0; -- } -- } -- if(priv->RxCounter==RegRxCounter) -- bStuck = TRUE; -- -- priv->RxCounter = RegRxCounter; -- -- return bStuck; --} -- --static RESET_TYPE RxCheckStuck(struct r8192_priv *priv) --{ -- -- if(HalRxCheckStuck8190Pci(priv)) -- { -- RT_TRACE(COMP_RESET, "RxStuck Condition\n"); -- return RESET_TYPE_SILENT; -- } -- -- return RESET_TYPE_NORESET; --} -- --static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv) --{ -- RESET_TYPE RxResetType = RESET_TYPE_NORESET; -- RT_RF_POWER_STATE rfState; -- -- rfState = priv->eRFPowerState; -- -- if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { -- /* -- * If driver is in the status of firmware download failure, -- * driver skips RF initialization and RF is in turned off state. -- * Driver should check whether Rx stuck and do silent reset. And -- * if driver is in firmware download failure status, driver -- * should initialize RF in the following silent reset procedure -- * -- * Driver should not check RX stuck in IBSS mode because it is -- * required to set Check BSSID in order to send beacon, however, -- * if check BSSID is set, STA cannot hear any packet a all. -- */ -- RxResetType = RxCheckStuck(priv); -- } -- -- RT_TRACE(COMP_RESET, "%s(): RxResetType is %d\n", __FUNCTION__, RxResetType); -- -- return RxResetType; --} -- --#ifdef ENABLE_IPS --static void InactivePsWorkItemCallback(struct r8192_priv *priv) --{ -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- -- RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() --------->\n"); -- // -- // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem -- // is really scheduled. -- // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the -- // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing -- // blocks the IPS procedure of switching RF. -- // By Bruce, 2007-12-25. -- // -- pPSC->bSwRfProcessing = TRUE; -- -- RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", -- pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); -- -- -- MgntActSet_RF_State(priv, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); -- -- // -- // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20. -- // -- pPSC->bSwRfProcessing = FALSE; -- RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <---------\n"); --} -- --#ifdef ENABLE_LPS --/* Change current and default preamble mode. */ --bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode) --{ -- -- // Currently, we do not change power save mode on IBSS mode. -- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) -- { -- return false; -- } -- -- // -- // If we make HW to fill up the PwrMgt bit for us, -- // some AP will not response to our mgnt frames with PwrMgt bit set, -- // e.g. cannot associate the AP. -- // So I commented out it. 2005.02.16, by rcnjko. -- // --// // Change device's power save mode. --// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); -- -- // Update power save mode configured. -- //RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__FUNCTION__,rtPsMode); -- if(!priv->ps_force) { -- priv->ieee80211->ps = rtPsMode; -- } -- -- // Awake immediately -- if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED) -- { -- // Notify the AP we awke. -- rtl8192_hw_wakeup(priv->ieee80211); -- priv->ieee80211->sta_sleep = 0; -- -- spin_lock(&priv->ieee80211->mgmt_tx_lock); -- printk("LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); -- ieee80211_sta_ps_send_null_frame(priv->ieee80211, 0); -- spin_unlock(&priv->ieee80211->mgmt_tx_lock); -- } -- -- return true; --} -- --/* Enter the leisure power save mode. */ --void LeisurePSEnter(struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- -- if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) && -- (priv->ieee80211->state == IEEE80211_LINKED)) || -- (priv->ieee80211->iw_mode == IW_MODE_ADHOC) || -- (priv->ieee80211->iw_mode == IW_MODE_MASTER)) -- return; -- -- if (pPSC->bLeisurePs) -- { -- // Idle for a while if we connect to AP a while ago. -- if(pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) // 4 Sec -- { -- -- if(priv->ieee80211->ps == IEEE80211_PS_DISABLED) -- { -- MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); -- -- } -- } -- else -- pPSC->LpsIdleCount++; -- } --} -- -- --/* Leave leisure power save mode. */ --void LeisurePSLeave(struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- -- if (pPSC->bLeisurePs) -- { -- if(priv->ieee80211->ps != IEEE80211_PS_DISABLED) -- { -- // move to lps_wakecomplete() -- MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); -- -- } -- } --} --#endif -- -- --/* Enter the inactive power save mode. RF will be off */ --void IPSEnter(struct r8192_priv *priv) --{ -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- RT_RF_POWER_STATE rtState; -- -- if (pPSC->bInactivePs) -- { -- rtState = priv->eRFPowerState; -- // -- // Added by Bruce, 2007-12-25. -- // Do not enter IPS in the following conditions: -- // (1) RF is already OFF or Sleep -- // (2) bSwRfProcessing (indicates the IPS is still under going) -- // (3) Connectted (only disconnected can trigger IPS) -- // (4) IBSS (send Beacon) -- // (5) AP mode (send Beacon) -- // -- if (rtState == eRfOn && !pPSC->bSwRfProcessing -- && (priv->ieee80211->state != IEEE80211_LINKED) ) -- { -- RT_TRACE(COMP_RF,"IPSEnter(): Turn off RF.\n"); -- pPSC->eInactivePowerState = eRfOff; --// queue_work(priv->priv_wq,&(pPSC->InactivePsWorkItem)); -- InactivePsWorkItemCallback(priv); -- } -- } --} -- --// --// Description: --// Leave the inactive power save mode, RF will be on. --// 2007.08.17, by shien chang. --// --void IPSLeave(struct r8192_priv *priv) --{ -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- RT_RF_POWER_STATE rtState; -- -- if (pPSC->bInactivePs) -- { -- rtState = priv->eRFPowerState; -- if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) -- { -- RT_TRACE(COMP_POWER, "IPSLeave(): Turn on RF.\n"); -- pPSC->eInactivePowerState = eRfOn; -- InactivePsWorkItemCallback(priv); -- } -- } --} -- --void IPSLeave_wq(struct work_struct *work) --{ -- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq); -- struct net_device *dev = ieee->dev; -- -- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); -- down(&priv->ieee80211->ips_sem); -- IPSLeave(priv); -- up(&priv->ieee80211->ips_sem); --} -- --void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- RT_RF_POWER_STATE rtState; -- rtState = priv->eRFPowerState; -- -- if (priv->PowerSaveControl.bInactivePs){ -- if(rtState == eRfOff){ -- if(priv->RfOffReason > RF_CHANGE_BY_IPS) -- { -- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); -- return; -- } -- else{ -- printk("=========>%s(): IPSLeave\n",__FUNCTION__); -- queue_work(priv->ieee80211->wq,&priv->ieee80211->ips_leave_wq); -- } -- } -- } --} --//added by amy 090331 end --void ieee80211_ips_leave(struct ieee80211_device *ieee80211) --{ -- struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); -- down(&ieee80211->ips_sem); -- IPSLeave(priv); -- up(&ieee80211->ips_sem); --} --#endif -- --static void rtl819x_update_rxcounts( -- struct r8192_priv *priv, -- u32* TotalRxBcnNum, -- u32* TotalRxDataNum --) --{ -- u16 SlotIndex; -- u8 i; -- -- *TotalRxBcnNum = 0; -- *TotalRxDataNum = 0; -- -- SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); -- priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; -- priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; -- for( i=0; iieee80211->LinkDetectInfo.SlotNum; i++ ){ -- *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; -- *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; -- } --} -- -- --static void rtl819x_watchdog_wqcallback(struct work_struct *work) --{ -- struct delayed_work *dwork = container_of(work,struct delayed_work,work); -- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); -- struct ieee80211_device* ieee = priv->ieee80211; -- RESET_TYPE ResetType = RESET_TYPE_NORESET; -- bool bBusyTraffic = false; -- bool bEnterPS = false; -- -- if ((!priv->up) || priv->bHwRadioOff) -- return; -- -- if(!priv->up) -- return; -- hal_dm_watchdog(priv); --#ifdef ENABLE_IPS -- if(ieee->actscanning == false){ -- if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) && -- (priv->eRFPowerState == eRfOn) && !ieee->is_set_key && -- (!ieee->proto_stoppping) && !ieee->wx_set_enc){ -- if (priv->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){ -- IPSEnter(priv); -- } -- } -- } --#endif -- {//to get busy traffic condition -- if(ieee->state == IEEE80211_LINKED) -- { -- if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || -- ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { -- bBusyTraffic = true; -- } -- --#ifdef ENABLE_LPS -- //added by amy for Leisure PS -- if( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || -- (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) -- { -- bEnterPS= false; -- } -- else -- { -- bEnterPS= true; -- } -- -- // LeisurePS only work in infra mode. -- if(bEnterPS) -- { -- LeisurePSEnter(priv->ieee80211); -- } -- else -- { -- LeisurePSLeave(priv->ieee80211); -- } --#endif -- -- } -- else -- { --#ifdef ENABLE_LPS -- LeisurePSLeave(priv->ieee80211); --#endif -- } -- -- ieee->LinkDetectInfo.NumRxOkInPeriod = 0; -- ieee->LinkDetectInfo.NumTxOkInPeriod = 0; -- ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; -- ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; -- } -- -- -- //added by amy for AP roaming -- if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) -- { -- u32 TotalRxBcnNum = 0; -- u32 TotalRxDataNum = 0; -- -- rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); -- if((TotalRxBcnNum+TotalRxDataNum) == 0) -- { -- if (priv->eRFPowerState == eRfOff) -- RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); -- printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); -- // Dot11d_Reset(dev); -- ieee->state = IEEE80211_ASSOCIATING; -- notify_wx_assoc_event(priv->ieee80211); -- RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); -- ieee->is_roaming = true; -- ieee->is_set_key = false; -- ieee->link_change(ieee); -- queue_work(ieee->wq, &ieee->associate_procedure_wq); -- } -- } -- ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; -- ieee->LinkDetectInfo.NumRecvDataInPeriod=0; -- -- //check if reset the driver -- if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && -- priv->watchdog_last_time != 1) -- { -- ResetType = rtl819x_check_reset(priv); -- priv->watchdog_check_reset_cnt = 3; -- } -- if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) -- { -- priv->ResetProgress = RESET_TYPE_NORMAL; -- RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__FUNCTION__); -- return; -- } -- /* disable silent reset temply 2008.9.11*/ -- -- if( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) // This is control by OID set in Pomelo -- { -- priv->watchdog_last_time = 1; -- } -- else -- priv->watchdog_last_time = 0; -- -- priv->force_reset = false; -- priv->bForcedSilentReset = false; -- priv->bResetInProgress = false; -- RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); -- --} -- --void watch_dog_timer_callback(unsigned long data) --{ -- struct r8192_priv *priv = (struct r8192_priv *) data; -- queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0); -- mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); -- --} -- --static int _rtl8192_up(struct r8192_priv *priv) --{ -- RT_STATUS init_status = RT_STATUS_SUCCESS; -- struct net_device *dev = priv->ieee80211->dev; -- -- priv->up=1; -- priv->ieee80211->ieee_up=1; -- priv->bdisable_nic = false; //YJ,add,091111 -- RT_TRACE(COMP_INIT, "Bringing up iface\n"); -- -- init_status = rtl8192_adapter_start(priv); -- if(init_status != RT_STATUS_SUCCESS) -- { -- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); -- return -1; -- } -- RT_TRACE(COMP_INIT, "start adapter finished\n"); -- -- if (priv->eRFPowerState != eRfOn) -- MgntActSet_RF_State(priv, eRfOn, priv->RfOffReason); -- -- if(priv->ieee80211->state != IEEE80211_LINKED) -- ieee80211_softmac_start_protocol(priv->ieee80211); -- ieee80211_reset_queue(priv->ieee80211); -- watch_dog_timer_callback((unsigned long) priv); -- if(!netif_queue_stopped(dev)) -- netif_start_queue(dev); -- else -- netif_wake_queue(dev); -- -- return 0; --} -- -- --static int rtl8192_open(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- int ret; -- -- down(&priv->wx_sem); -- ret = rtl8192_up(dev); -- up(&priv->wx_sem); -- return ret; -- --} -- -- --int rtl8192_up(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- -- if (priv->up == 1) return -1; -- -- return _rtl8192_up(priv); --} -- -- --static int rtl8192_close(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- int ret; -- -- down(&priv->wx_sem); -- -- ret = rtl8192_down(dev); -- -- up(&priv->wx_sem); -- -- return ret; -- --} -- --int rtl8192_down(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- -- if (priv->up == 0) return -1; -- --#ifdef ENABLE_LPS -- //LZM for PS-Poll AID issue. 090429 -- if(priv->ieee80211->state == IEEE80211_LINKED) -- LeisurePSLeave(priv->ieee80211); --#endif -- -- priv->up=0; -- priv->ieee80211->ieee_up = 0; -- RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__); --/* FIXME */ -- if (!netif_queue_stopped(dev)) -- netif_stop_queue(dev); -- -- rtl8192_irq_disable(priv); -- rtl8192_cancel_deferred_work(priv); -- deinit_hal_dm(priv); -- del_timer_sync(&priv->watch_dog_timer); -- -- ieee80211_softmac_stop_protocol(priv->ieee80211,true); -- -- rtl8192_halt_adapter(priv, false); -- memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list)); -- -- RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__); -- -- return 0; --} -- -- --void rtl8192_commit(struct r8192_priv *priv) --{ -- if (priv->up == 0) return ; -- -- -- ieee80211_softmac_stop_protocol(priv->ieee80211,true); -- -- rtl8192_irq_disable(priv); -- rtl8192_halt_adapter(priv, true); -- _rtl8192_up(priv); --} -- --static void rtl8192_restart(struct work_struct *work) --{ -- struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); -- -- down(&priv->wx_sem); -- -- rtl8192_commit(priv); -- -- up(&priv->wx_sem); --} -- --static void r8192_set_multicast(struct net_device *dev) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- -- priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; --} -- -- --static int r8192_set_mac_adr(struct net_device *dev, void *mac) --{ -- struct r8192_priv *priv = ieee80211_priv(dev); -- struct sockaddr *addr = mac; -- -- down(&priv->wx_sem); -- -- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); -- -- schedule_work(&priv->reset_wq); -- up(&priv->wx_sem); -- -- return 0; --} -- --static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw) --{ -- struct ieee80211_device *ieee = priv->ieee80211; -- u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; -- u32 key[4]; -- -- if (ipw->u.crypt.set_tx) { -- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) -- ieee->pairwise_key_type = KEY_TYPE_CCMP; -- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) -- ieee->pairwise_key_type = KEY_TYPE_TKIP; -- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { -- if (ipw->u.crypt.key_len == 13) -- ieee->pairwise_key_type = KEY_TYPE_WEP104; -- else if (ipw->u.crypt.key_len == 5) -- ieee->pairwise_key_type = KEY_TYPE_WEP40; -- } else -- ieee->pairwise_key_type = KEY_TYPE_NA; -- -- if (ieee->pairwise_key_type) { -- memcpy(key, ipw->u.crypt.key, 16); -- EnableHWSecurityConfig8192(priv); -- /* -- * We fill both index entry and 4th entry for pairwise -- * key as in IPW interface, adhoc will only get here, -- * so we need index entry for its default key serching! -- */ -- setKey(priv, 4, ipw->u.crypt.idx, -- ieee->pairwise_key_type, -- (u8*)ieee->ap_mac_addr, 0, key); -- -- /* LEAP WEP will never set this. */ -- if (ieee->auth_mode != 2) -- setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, -- ieee->pairwise_key_type, -- (u8*)ieee->ap_mac_addr, 0, key); -- } -- if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && -- ieee->pHTInfo->bCurrentHTSupport) { -- write_nic_byte(priv, 0x173, 1); /* fix aes bug */ -- } -- } else { -- memcpy(key, ipw->u.crypt.key, 16); -- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) -- ieee->group_key_type= KEY_TYPE_CCMP; -- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) -- ieee->group_key_type = KEY_TYPE_TKIP; -- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { -- if (ipw->u.crypt.key_len == 13) -- ieee->group_key_type = KEY_TYPE_WEP104; -- else if (ipw->u.crypt.key_len == 5) -- ieee->group_key_type = KEY_TYPE_WEP40; -- } else -- ieee->group_key_type = KEY_TYPE_NA; -- -- if (ieee->group_key_type) { -- setKey(priv, ipw->u.crypt.idx, ipw->u.crypt.idx, -- ieee->group_key_type, broadcast_addr, 0, key); -- } -- } --} -- --/* based on ipw2200 driver */ --static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) --{ -- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); -- struct iwreq *wrq = (struct iwreq *)rq; -- int ret=-1; -- struct iw_point *p = &wrq->u.data; -- struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer; -- -- down(&priv->wx_sem); -- -- -- if (p->length < sizeof(struct ieee_param) || !p->pointer){ -- ret = -EINVAL; -- goto out; -- } -- -- ipw = kmalloc(p->length, GFP_KERNEL); -- if (ipw == NULL){ -- ret = -ENOMEM; -- goto out; -- } -- if (copy_from_user(ipw, p->pointer, p->length)) { -- kfree(ipw); -- ret = -EFAULT; -- goto out; -- } -- -- switch (cmd) { -- case RTL_IOCTL_WPA_SUPPLICANT: -- /* parse here for HW security */ -- if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) -- r8192e_set_hw_key(priv, ipw); -- ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); -- break; -- -- default: -- ret = -EOPNOTSUPP; -- break; -- } -- -- kfree(ipw); --out: -- up(&priv->wx_sem); -- -- return ret; --} -- --static u8 HwRateToMRate90(bool bIsHT, u8 rate) --{ -- u8 ret_rate = 0x02; -- -- if(!bIsHT) { -- switch(rate) { -- case DESC90_RATE1M: ret_rate = MGN_1M; break; -- case DESC90_RATE2M: ret_rate = MGN_2M; break; -- case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; -- case DESC90_RATE11M: ret_rate = MGN_11M; break; -- case DESC90_RATE6M: ret_rate = MGN_6M; break; -- case DESC90_RATE9M: ret_rate = MGN_9M; break; -- case DESC90_RATE12M: ret_rate = MGN_12M; break; -- case DESC90_RATE18M: ret_rate = MGN_18M; break; -- case DESC90_RATE24M: ret_rate = MGN_24M; break; -- case DESC90_RATE36M: ret_rate = MGN_36M; break; -- case DESC90_RATE48M: ret_rate = MGN_48M; break; -- case DESC90_RATE54M: ret_rate = MGN_54M; break; -- -- default: -- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); -- break; -- } -- -- } else { -- switch(rate) { -- case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; -- case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; -- case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; -- case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; -- case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; -- case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; -- case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; -- case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; -- case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; -- case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; -- case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; -- case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; -- case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; -- case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; -- case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; -- case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; -- case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; -- -- default: -- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); -- break; -- } -- } -- -- return ret_rate; --} -- --/* Record the TSF time stamp when receiving a packet */ --static void UpdateRxPktTimeStamp8190(struct r8192_priv *priv, struct ieee80211_rx_stats *stats) --{ -- -- if(stats->bIsAMPDU && !stats->bFirstMPDU) { -- stats->mac_time[0] = priv->LastRxDescTSFLow; -- stats->mac_time[1] = priv->LastRxDescTSFHigh; -- } else { -- priv->LastRxDescTSFLow = stats->mac_time[0]; -- priv->LastRxDescTSFHigh = stats->mac_time[1]; -- } --} -- --static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. --{ -- long signal_power; // in dBm. -- -- // Translate to dBm (x=0.5y-95). -- signal_power = (long)((signal_strength_index + 1) >> 1); -- signal_power -= 95; -- -- return signal_power; --} -- --/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to -- be a local static. Otherwise, it may increase when we return from S3/S4. The -- value will be kept in memory or disk. We must delcare the value in adapter -- and it will be reinitialized when return from S3/S4. */ --static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats) --{ -- bool bcheck = false; -- u8 rfpath; -- u32 nspatial_stream, tmp_val; -- static u32 slide_rssi_index=0, slide_rssi_statistics=0; -- static u32 slide_evm_index=0, slide_evm_statistics=0; -- static u32 last_rssi=0, last_evm=0; -- //cosa add for beacon rssi smoothing -- static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; -- static u32 last_beacon_adc_pwdb=0; -- -- struct ieee80211_hdr_3addr *hdr; -- u16 sc ; -- unsigned int frag,seq; -- hdr = (struct ieee80211_hdr_3addr *)buffer; -- sc = le16_to_cpu(hdr->seq_ctl); -- frag = WLAN_GET_SEQ_FRAG(sc); -- seq = WLAN_GET_SEQ_SEQ(sc); -- -- // -- // Check whether we should take the previous packet into accounting -- // -- if(!pprevious_stats->bIsAMPDU) -- { -- // if previous packet is not aggregated packet -- bcheck = true; -- } -- -- if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) -- { -- slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; -- last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; -- priv->stats.slide_rssi_total -= last_rssi; -- } -- priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; -- -- priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; -- if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) -- slide_rssi_index = 0; -- -- // <1> Showed on UI for user, in dbm -- tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; -- priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); -- pcurrent_stats->rssi = priv->stats.signal_strength; -- // -- // If the previous packet does not match the criteria, neglect it -- // -- if(!pprevious_stats->bPacketMatchBSSID) -- { -- if(!pprevious_stats->bToSelfBA) -- return; -- } -- -- if(!bcheck) -- return; -- -- // <2> Showed on UI for engineering -- // hardware does not provide rssi information for each rf path in CCK -- if(!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) -- { -- for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) -- { -- if (!rtl8192_phy_CheckIsLegalRFPath(priv, rfpath)) -- continue; -- RT_TRACE(COMP_DBG, "pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", pprevious_stats->RxMIMOSignalStrength[rfpath]); -- //Fixed by Jacken 2008-03-20 -- if(priv->stats.rx_rssi_percentage[rfpath] == 0) -- { -- priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; -- } -- if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) -- { -- priv->stats.rx_rssi_percentage[rfpath] = -- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + -- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); -- priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; -- } -- else -- { -- priv->stats.rx_rssi_percentage[rfpath] = -- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + -- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); -- } -- RT_TRACE(COMP_DBG, "priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" , priv->stats.rx_rssi_percentage[rfpath]); -- } -- } -- -- -- // -- // Check PWDB. -- // -- //cosa add for beacon rssi smoothing by average. -- if(pprevious_stats->bPacketBeacon) -- { -- /* record the beacon pwdb to the sliding window. */ -- if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) -- { -- slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; -- last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; -- priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; -- // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total); -- } -- priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; -- priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; -- slide_beacon_adc_pwdb_index++; -- if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) -- slide_beacon_adc_pwdb_index = 0; -- pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; -- if(pprevious_stats->RxPWDBAll >= 3) -- pprevious_stats->RxPWDBAll -= 3; -- } -- -- RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", -- pprevious_stats->bIsCCK? "CCK": "OFDM", -- pprevious_stats->RxPWDBAll); -- -- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) -- { -- if(priv->undecorated_smoothed_pwdb < 0) // initialize -- { -- priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; -- } -- -- if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) -- { -- priv->undecorated_smoothed_pwdb = -- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + -- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); -- priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; -- } -- else -- { -- priv->undecorated_smoothed_pwdb = -- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + -- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); -- } -- } -- -- // -- // Check EVM -- // -- /* record the general EVM to the sliding window. */ -- if(pprevious_stats->SignalQuality == 0) -- { -- } -- else -- { -- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ -- if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ -- slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; -- last_evm = priv->stats.slide_evm[slide_evm_index]; -- priv->stats.slide_evm_total -= last_evm; -- } -- -- priv->stats.slide_evm_total += pprevious_stats->SignalQuality; -- -- priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; -- if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) -- slide_evm_index = 0; -- -- // <1> Showed on UI for user, in percentage. -- tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; -- //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. -- } -- -- // <2> Showed on UI for engineering -- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) -- { -- for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream -- { -- if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) -- { -- if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize -- { -- priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; -- } -- priv->stats.rx_evm_percentage[nspatial_stream] = -- ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + -- (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); -- } -- } -- } -- } -- --} -- --static u8 rtl819x_query_rxpwrpercentage( -- char antpower -- ) --{ -- if ((antpower <= -100) || (antpower >= 20)) -- { -- return 0; -- } -- else if (antpower >= 0) -- { -- return 100; -- } -- else -- { -- return (100+antpower); -- } -- --} -- --static u8 --rtl819x_evm_dbtopercentage( -- char value -- ) --{ -- char ret_val; -- -- ret_val = value; -- -- if(ret_val >= 0) -- ret_val = 0; -- if(ret_val <= -33) -- ret_val = -33; -- ret_val = 0 - ret_val; -- ret_val*=3; -- if(ret_val == 99) -- ret_val = 100; -- return ret_val; --} -- --/* We want good-looking for signal strength/quality */ --static long rtl819x_signal_scale_mapping(long currsig) --{ -- long retsig; -- -- // Step 1. Scale mapping. -- if(currsig >= 61 && currsig <= 100) -- { -- retsig = 90 + ((currsig - 60) / 4); -- } -- else if(currsig >= 41 && currsig <= 60) -- { -- retsig = 78 + ((currsig - 40) / 2); -- } -- else if(currsig >= 31 && currsig <= 40) -- { -- retsig = 66 + (currsig - 30); -- } -- else if(currsig >= 21 && currsig <= 30) -- { -- retsig = 54 + (currsig - 20); -- } -- else if(currsig >= 5 && currsig <= 20) -- { -- retsig = 42 + (((currsig - 5) * 2) / 3); -- } -- else if(currsig == 4) -- { -- retsig = 36; -- } -- else if(currsig == 3) -- { -- retsig = 27; -- } -- else if(currsig == 2) -- { -- retsig = 18; -- } -- else if(currsig == 1) -- { -- retsig = 9; -- } -- else -- { -- retsig = currsig; -- } -- -- return retsig; --} -- --static void rtl8192_query_rxphystatus( -- struct r8192_priv * priv, -- struct ieee80211_rx_stats * pstats, -- prx_desc_819x_pci pdesc, -- prx_fwinfo_819x_pci pdrvinfo, -- struct ieee80211_rx_stats * precord_stats, -- bool bpacket_match_bssid, -- bool bpacket_toself, -- bool bPacketBeacon, -- bool bToSelfBA -- ) --{ -- //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status); -- phy_sts_ofdm_819xpci_t* pofdm_buf; -- phy_sts_cck_819xpci_t * pcck_buf; -- phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc; -- u8 *prxpkt; -- u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; -- char rx_pwr[4], rx_pwr_all=0; -- //long rx_avg_pwr = 0; -- char rx_snrX, rx_evmX; -- u8 evm, pwdb_all; -- u32 RSSI, total_rssi=0;//, total_evm=0; --// long signal_strength_index = 0; -- u8 is_cck_rate=0; -- u8 rf_rx_num = 0; -- -- is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); -- -- // Record it for next packet processing -- memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); -- pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; -- pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; -- pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo); -- pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; -- pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; -- /*2007.08.30 requested by SD3 Jerry */ -- if (priv->phy_check_reg824 == 0) -- { -- priv->phy_reg824_bit9 = rtl8192_QueryBBReg(priv, rFPGA0_XA_HSSIParameter2, 0x200); -- priv->phy_check_reg824 = 1; -- } -- -- -- prxpkt = (u8*)pdrvinfo; -- -- /* Move pointer to the 16th bytes. Phy status start address. */ -- prxpkt += sizeof(rx_fwinfo_819x_pci); -- -- /* Initial the cck and ofdm buffer pointer */ -- pcck_buf = (phy_sts_cck_819xpci_t *)prxpkt; -- pofdm_buf = (phy_sts_ofdm_819xpci_t *)prxpkt; -- -- pstats->RxMIMOSignalQuality[0] = -1; -- pstats->RxMIMOSignalQuality[1] = -1; -- precord_stats->RxMIMOSignalQuality[0] = -1; -- precord_stats->RxMIMOSignalQuality[1] = -1; -- -- if(is_cck_rate) -- { -- // -- // (1)Hardware does not provide RSSI for CCK -- // -- -- // -- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) -- // -- u8 report;//, cck_agc_rpt; -- -- if (!priv->phy_reg824_bit9) -- { -- report = pcck_buf->cck_agc_rpt & 0xc0; -- report = report>>6; -- switch(report) -- { -- //Fixed by Jacken from Bryant 2008-03-20 -- //Original value is -38 , -26 , -14 , -2 -- //Fixed value is -35 , -23 , -11 , 6 -- case 0x3: -- rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); -- break; -- case 0x2: -- rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); -- break; -- case 0x1: -- rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); -- break; -- case 0x0: -- rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); -- break; -- } -- } -- else -- { -- report = pcck_buf->cck_agc_rpt & 0x60; -- report = report>>5; -- switch(report) -- { -- case 0x3: -- rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; -- break; -- case 0x2: -- rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); -- break; -- case 0x1: -- rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; -- break; -- case 0x0: -- rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; -- break; -- } -- } -- -- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); -- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; -- pstats->RecvSignalPower = rx_pwr_all; -- -- // -- // (3) Get Signal Quality (EVM) -- // -- if(bpacket_match_bssid) -- { -- u8 sq; -- -- if(pstats->RxPWDBAll > 40) -- { -- sq = 100; -- }else -- { -- sq = pcck_buf->sq_rpt; -- -- if(pcck_buf->sq_rpt > 64) -- sq = 0; -- else if (pcck_buf->sq_rpt < 20) -- sq = 100; -- else -- sq = ((64-sq) * 100) / 44; -- } -- pstats->SignalQuality = precord_stats->SignalQuality = sq; -- pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; -- pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; -- } -- } -- else -- { -- // -- // (1)Get RSSI for HT rate -- // -- for(i=RF90_PATH_A; ibrfpath_rxenable[i]) -- rf_rx_num++; -- //else -- //continue; -- -- //Fixed by Jacken from Bryant 2008-03-20 -- //Original value is 106 -- rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; -- -- //Get Rx snr value in DB -- tmp_rxsnr = pofdm_buf->rxsnr_X[i]; -- rx_snrX = (char)(tmp_rxsnr); -- rx_snrX /= 2; -- -- /* Translate DBM to percentage. */ -- RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); -- if (priv->brfpath_rxenable[i]) -- total_rssi += RSSI; -- -- /* Record Signal Strength for next packet */ -- if(bpacket_match_bssid) -- { -- pstats->RxMIMOSignalStrength[i] =(u8) RSSI; -- precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; -- } -- } -- -- -- // -- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) -- // -- //Fixed by Jacken from Bryant 2008-03-20 -- //Original value is 106 -- rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; -- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); -- -- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; -- pstats->RxPower = precord_stats->RxPower = rx_pwr_all; -- pstats->RecvSignalPower = rx_pwr_all; -- // -- // (3)EVM of HT rate -- // -- if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && -- pdrvinfo->RxRate<=DESC90_RATEMCS15) -- max_spatial_stream = 2; //both spatial stream make sense -- else -- max_spatial_stream = 1; //only spatial stream 1 makes sense -- -- for(i=0; irxevm_X[i]; -- rx_evmX = (char)(tmp_rxevm); -- -- // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment -- // fill most significant bit to "zero" when doing shifting operation which may change a negative -- // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. -- rx_evmX /= 2; //dbm -- -- evm = rtl819x_evm_dbtopercentage(rx_evmX); -- if(bpacket_match_bssid) -- { -- if(i==0) // Fill value in RFD, Get the first spatial stream only -- pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); -- pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); -- } -- } -- -- -- /* record rx statistics for debug */ -- rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; -- prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; -- } -- -- //UI BSS List signal strength(in percentage), make it good looking, from 0~100. -- //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). -- if(is_cck_rate) -- { -- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL; -- -- } -- else -- { -- //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u1Byte)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u1Byte)(total_rssi/=RF90_PATH_MAX); -- // We can judge RX path number now. -- if (rf_rx_num != 0) -- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num))); -- } --} -- --static void --rtl8192_record_rxdesc_forlateruse( -- struct ieee80211_rx_stats * psrc_stats, -- struct ieee80211_rx_stats * ptarget_stats --) --{ -- ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; -- ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; --} -- -- -- --static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv, -- struct sk_buff *skb, -- struct ieee80211_rx_stats * pstats, -- prx_desc_819x_pci pdesc, -- prx_fwinfo_819x_pci pdrvinfo) --{ -- // TODO: We must only check packet for current MAC address. Not finish -- bool bpacket_match_bssid, bpacket_toself; -- bool bPacketBeacon=false, bToSelfBA=false; -- struct ieee80211_hdr_3addr *hdr; -- u16 fc,type; -- -- // Get Signal Quality for only RX data queue (but not command queue) -- -- u8* tmp_buf; -- u8 *praddr; -- -- /* Get MAC frame start address. */ -- tmp_buf = skb->data; -- -- hdr = (struct ieee80211_hdr_3addr *)tmp_buf; -- fc = le16_to_cpu(hdr->frame_ctl); -- type = WLAN_FC_GET_TYPE(fc); -- praddr = hdr->addr1; -- -- /* Check if the received packet is acceptabe. */ -- bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) && -- (!compare_ether_addr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) -- && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); -- bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)); -- -- if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON) -- { -- bPacketBeacon = true; -- } -- if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK) -- { -- if (!compare_ether_addr(praddr, priv->ieee80211->dev->dev_addr)) -- bToSelfBA = true; -- } -- -- // -- // Process PHY information for previous packet (RSSI/PWDB/EVM) -- // -- // Because phy information is contained in the last packet of AMPDU only, so driver -- // should process phy information of previous packet -- rtl8192_process_phyinfo(priv, tmp_buf, &priv->previous_stats, pstats); -- rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &priv->previous_stats, bpacket_match_bssid, -- bpacket_toself ,bPacketBeacon, bToSelfBA); -- rtl8192_record_rxdesc_forlateruse(pstats, &priv->previous_stats); -- --} -- -- --static void rtl8192_tx_resume(struct r8192_priv *priv) --{ -- struct ieee80211_device *ieee = priv->ieee80211; -- struct sk_buff *skb; -- int i; -- -- for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) { -- while ((!skb_queue_empty(&ieee->skb_waitQ[i])) && -- (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) { -- /* 1. dequeue the packet from the wait queue */ -- skb = skb_dequeue(&ieee->skb_waitQ[i]); -- /* 2. tx the packet directly */ -- ieee->softmac_data_hard_start_xmit(skb, ieee, 0); -- } -- } --} -- --static void rtl8192_irq_tx_tasklet(unsigned long arg) --{ -- struct r8192_priv *priv = (struct r8192_priv*) arg; -- struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE]; -- unsigned long flags; -- -- /* check if we need to report that the management queue is drained */ -- spin_lock_irqsave(&priv->irq_th_lock, flags); -- -- if (!skb_queue_len(&mgnt_ring->queue) && -- priv->ieee80211->ack_tx_to_ieee && -- rtl8192_is_tx_queue_empty(priv->ieee80211)) { -- priv->ieee80211->ack_tx_to_ieee = 0; -- ieee80211_ps_tx_ack(priv->ieee80211, 1); -- } -- -- spin_unlock_irqrestore(&priv->irq_th_lock, flags); -- -- rtl8192_tx_resume(priv); --} -- --/* Record the received data rate */ --static void UpdateReceivedRateHistogramStatistics8190( -- struct r8192_priv *priv, -- struct ieee80211_rx_stats* pstats -- ) --{ -- u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV -- u32 rateIndex; -- u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI -- -- if(pstats->bCRC) -- rcvType = 2; -- else if(pstats->bICV) -- rcvType = 3; -- -- if(pstats->bShortPreamble) -- preamble_guardinterval = 1;// short -- else -- preamble_guardinterval = 0;// long -- -- switch(pstats->rate) -- { -- // -- // CCK rate -- // -- case MGN_1M: rateIndex = 0; break; -- case MGN_2M: rateIndex = 1; break; -- case MGN_5_5M: rateIndex = 2; break; -- case MGN_11M: rateIndex = 3; break; -- // -- // Legacy OFDM rate -- // -- case MGN_6M: rateIndex = 4; break; -- case MGN_9M: rateIndex = 5; break; -- case MGN_12M: rateIndex = 6; break; -- case MGN_18M: rateIndex = 7; break; -- case MGN_24M: rateIndex = 8; break; -- case MGN_36M: rateIndex = 9; break; -- case MGN_48M: rateIndex = 10; break; -- case MGN_54M: rateIndex = 11; break; -- // -- // 11n High throughput rate -- // -- case MGN_MCS0: rateIndex = 12; break; -- case MGN_MCS1: rateIndex = 13; break; -- case MGN_MCS2: rateIndex = 14; break; -- case MGN_MCS3: rateIndex = 15; break; -- case MGN_MCS4: rateIndex = 16; break; -- case MGN_MCS5: rateIndex = 17; break; -- case MGN_MCS6: rateIndex = 18; break; -- case MGN_MCS7: rateIndex = 19; break; -- case MGN_MCS8: rateIndex = 20; break; -- case MGN_MCS9: rateIndex = 21; break; -- case MGN_MCS10: rateIndex = 22; break; -- case MGN_MCS11: rateIndex = 23; break; -- case MGN_MCS12: rateIndex = 24; break; -- case MGN_MCS13: rateIndex = 25; break; -- case MGN_MCS14: rateIndex = 26; break; -- case MGN_MCS15: rateIndex = 27; break; -- default: rateIndex = 28; break; -- } -- priv->stats.received_rate_histogram[0][rateIndex]++; //total -- priv->stats.received_rate_histogram[rcvType][rateIndex]++; --} -- --static void rtl8192_rx(struct r8192_priv *priv) --{ -- struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; -- bool unicast_packet = false; -- struct ieee80211_rx_stats stats = { -- .signal = 0, -- .noise = -98, -- .rate = 0, -- .freq = IEEE80211_24GHZ_BAND, -- }; -- unsigned int count = priv->rxringcount; -- prx_fwinfo_819x_pci pDrvInfo = NULL; -- struct sk_buff *new_skb; -- -- while (count--) { -- rx_desc_819x_pci *pdesc = &priv->rx_ring[priv->rx_idx];//rx descriptor -- struct sk_buff *skb = priv->rx_buf[priv->rx_idx];//rx pkt -- -- if (pdesc->OWN) -- /* wait data to be filled by hardware */ -- return; -- -- stats.bICV = pdesc->ICV; -- stats.bCRC = pdesc->CRC32; -- stats.bHwError = pdesc->CRC32 | pdesc->ICV; -- -- stats.Length = pdesc->Length; -- if(stats.Length < 24) -- stats.bHwError |= 1; -- -- if(stats.bHwError) { -- stats.bShift = false; -- goto done; -- } -- pDrvInfo = NULL; -- new_skb = dev_alloc_skb(priv->rxbuffersize); -- -- if (unlikely(!new_skb)) -- goto done; -- -- stats.RxDrvInfoSize = pdesc->RxDrvInfoSize; -- stats.RxBufShift = ((pdesc->Shift)&0x03); -- stats.Decrypted = !pdesc->SWDec; -- -- pci_dma_sync_single_for_cpu(priv->pdev, -- *((dma_addr_t *)skb->cb), -- priv->rxbuffersize, -- PCI_DMA_FROMDEVICE); -- skb_put(skb, pdesc->Length); -- pDrvInfo = (rx_fwinfo_819x_pci *)(skb->data + stats.RxBufShift); -- skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); -- -- stats.rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); -- stats.bShortPreamble = pDrvInfo->SPLCP; -- -- /* it is debug only. It should be disabled in released driver. -- * 2007.1.11 by Emily -- * */ -- UpdateReceivedRateHistogramStatistics8190(priv, &stats); -- -- stats.bIsAMPDU = (pDrvInfo->PartAggr==1); -- stats.bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); -- -- stats.TimeStampLow = pDrvInfo->TSFL; -- stats.TimeStampHigh = read_nic_dword(priv, TSFR+4); -- -- UpdateRxPktTimeStamp8190(priv, &stats); -- -- // -- // Get Total offset of MPDU Frame Body -- // -- if((stats.RxBufShift + stats.RxDrvInfoSize) > 0) -- stats.bShift = 1; -- -- /* ???? */ -- TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo); -- -- /* Rx A-MPDU */ -- if(pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) -- RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", -- pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); -- skb_trim(skb, skb->len - 4/*sCrcLng*/); -- /* rx packets statistics */ -- ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; -- unicast_packet = false; -- -- if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) { -- //TODO -- }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){ -- //TODO -- }else { -- /* unicast packet */ -- unicast_packet = true; -- } -- -- if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){ -- dev_kfree_skb_any(skb); -- } else { -- priv->stats.rxok++; -- if(unicast_packet) { -- priv->stats.rxbytesunicast += skb->len; -- } -- } -- -- pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb), -- priv->rxbuffersize, PCI_DMA_FROMDEVICE); -- -- skb = new_skb; -- priv->rx_buf[priv->rx_idx] = skb; -- *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); -- --done: -- pdesc->BufferAddress = cpu_to_le32(*((dma_addr_t *)skb->cb)); -- pdesc->OWN = 1; -- pdesc->Length = priv->rxbuffersize; -- if (priv->rx_idx == priv->rxringcount-1) -- pdesc->EOR = 1; -- priv->rx_idx = (priv->rx_idx + 1) % priv->rxringcount; -- } -- --} -- --static void rtl8192_irq_rx_tasklet(unsigned long arg) --{ -- struct r8192_priv *priv = (struct r8192_priv*) arg; -- rtl8192_rx(priv); -- /* unmask RDU */ -- write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) | IMR_RDU); --} -- --static const struct net_device_ops rtl8192_netdev_ops = { -- .ndo_open = rtl8192_open, -- .ndo_stop = rtl8192_close, -- .ndo_tx_timeout = tx_timeout, -- .ndo_do_ioctl = rtl8192_ioctl, -- .ndo_set_multicast_list = r8192_set_multicast, -- .ndo_set_mac_address = r8192_set_mac_adr, -- .ndo_start_xmit = ieee80211_rtl_xmit, --}; -- --static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, -- const struct pci_device_id *id) --{ -- struct net_device *dev = NULL; -- struct r8192_priv *priv= NULL; -- u8 unit = 0; -- int ret = -ENODEV; -- unsigned long pmem_start, pmem_len, pmem_flags; -- -- RT_TRACE(COMP_INIT,"Configuring chip resources\n"); -- -- if( pci_enable_device (pdev) ){ -- RT_TRACE(COMP_ERR,"Failed to enable PCI device"); -- return -EIO; -- } -- -- pci_set_master(pdev); -- //pci_set_wmi(pdev); -- pci_set_dma_mask(pdev, 0xffffff00ULL); -- pci_set_consistent_dma_mask(pdev,0xffffff00ULL); -- dev = alloc_ieee80211(sizeof(struct r8192_priv)); -- if (!dev) { -- ret = -ENOMEM; -- goto fail_free; -- } -- -- pci_set_drvdata(pdev, dev); -- SET_NETDEV_DEV(dev, &pdev->dev); -- priv = ieee80211_priv(dev); -- priv->ieee80211 = netdev_priv(dev); -- priv->pdev=pdev; -- if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){ -- priv->ieee80211->bSupportRemoteWakeUp = 1; -- } else -- { -- priv->ieee80211->bSupportRemoteWakeUp = 0; -- } -- -- pmem_start = pci_resource_start(pdev, 1); -- pmem_len = pci_resource_len(pdev, 1); -- pmem_flags = pci_resource_flags (pdev, 1); -- -- if (!(pmem_flags & IORESOURCE_MEM)) { -- RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting\n"); -- goto fail; -- } -- -- //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); -- if( ! request_mem_region(pmem_start, pmem_len, RTL819xE_MODULE_NAME)) { -- RT_TRACE(COMP_ERR,"request_mem_region failed!\n"); -- goto fail; -- } -- -- priv->mem_start = ioremap_nocache(pmem_start, pmem_len); -- if (!priv->mem_start) { -- RT_TRACE(COMP_ERR,"ioremap failed!\n"); -- goto fail1; -- } -- -- dev->mem_start = (unsigned long) priv->mem_start; -- dev->mem_end = (unsigned long) (priv->mem_start + -- pci_resource_len(pdev, 0)); -- -- /* We disable the RETRY_TIMEOUT register (0x41) to keep -- * PCI Tx retries from interfering with C3 CPU state */ -- pci_write_config_byte(pdev, 0x41, 0x00); -- -- -- pci_read_config_byte(pdev, 0x05, &unit); -- pci_write_config_byte(pdev, 0x05, unit & (~0x04)); -- -- dev->irq = pdev->irq; -- priv->irq = 0; -- -- dev->netdev_ops = &rtl8192_netdev_ops; -- -- dev->wireless_handlers = &r8192_wx_handlers_def; -- dev->type=ARPHRD_ETHER; -- -- dev->watchdog_timeo = HZ*3; -- -- if (dev_alloc_name(dev, ifname) < 0){ -- RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); -- strcpy(ifname, "wlan%d"); -- dev_alloc_name(dev, ifname); -- } -- -- RT_TRACE(COMP_INIT, "Driver probe completed1\n"); -- if (rtl8192_init(priv)!=0) { -- RT_TRACE(COMP_ERR, "Initialization failed\n"); -- goto fail; -- } -- -- register_netdev(dev); -- RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name); -- rtl8192_proc_init_one(priv); -- -- -- RT_TRACE(COMP_INIT, "Driver probe completed\n"); -- return 0; -- --fail1: -- -- if (priv->mem_start) { -- iounmap(priv->mem_start); -- release_mem_region( pci_resource_start(pdev, 1), -- pci_resource_len(pdev, 1) ); -- } -- --fail: -- if(dev){ -- -- if (priv->irq) { -- free_irq(priv->irq, priv); -- priv->irq = 0; -- } -- free_ieee80211(dev); -- } -- --fail_free: -- pci_disable_device(pdev); -- -- DMESG("wlan driver load failed\n"); -- pci_set_drvdata(pdev, NULL); -- return ret; -- --} -- --/* detach all the work and timer structure declared or inititialized -- * in r8192_init function. -- * */ --static void rtl8192_cancel_deferred_work(struct r8192_priv* priv) --{ -- /* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code -- * is or is newer than 2.6.20 and work structure is defined to be struct work_struct. -- * Otherwise call cancel_delayed_work is enough. -- * FIXME (2.6.20 should 2.6.22, work_struct should not cancel) -- * */ -- cancel_delayed_work(&priv->watch_dog_wq); -- cancel_delayed_work(&priv->update_beacon_wq); -- cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); -- cancel_delayed_work(&priv->gpio_change_rf_wq); -- cancel_work_sync(&priv->reset_wq); -- cancel_work_sync(&priv->qos_activate); --} -- -- --static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) --{ -- struct net_device *dev = pci_get_drvdata(pdev); -- struct r8192_priv *priv ; -- u32 i; -- -- if (dev) { -- -- unregister_netdev(dev); -- -- priv = ieee80211_priv(dev); -- -- rtl8192_proc_remove_one(priv); -- -- rtl8192_down(dev); -- if (priv->pFirmware) -- { -- vfree(priv->pFirmware); -- priv->pFirmware = NULL; -- } -- destroy_workqueue(priv->priv_wq); -- -- /* free tx/rx rings */ -- rtl8192_free_rx_ring(priv); -- for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) -- rtl8192_free_tx_ring(priv, i); -- -- if (priv->irq) { -- printk("Freeing irq %d\n", priv->irq); -- free_irq(priv->irq, priv); -- priv->irq = 0; -- } -- -- if (priv->mem_start) { -- iounmap(priv->mem_start); -- release_mem_region( pci_resource_start(pdev, 1), -- pci_resource_len(pdev, 1) ); -- } -- -- free_ieee80211(dev); -- } -- -- pci_disable_device(pdev); -- RT_TRACE(COMP_DOWN, "wlan driver removed\n"); --} -- --extern int ieee80211_rtl_init(void); --extern void ieee80211_rtl_exit(void); -- --static int __init rtl8192_pci_module_init(void) --{ -- int retval; -- -- retval = ieee80211_rtl_init(); -- if (retval) -- return retval; -- -- printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); -- printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); -- RT_TRACE(COMP_INIT, "Initializing module\n"); -- rtl8192_proc_module_init(); -- if(0!=pci_register_driver(&rtl8192_pci_driver)) -- { -- DMESG("No device found"); -- /*pci_unregister_driver (&rtl8192_pci_driver);*/ -- return -ENODEV; -- } -- return 0; --} -- -- --static void __exit rtl8192_pci_module_exit(void) --{ -- pci_unregister_driver(&rtl8192_pci_driver); -- -- RT_TRACE(COMP_DOWN, "Exiting\n"); -- rtl8192_proc_module_remove(); -- ieee80211_rtl_exit(); --} -- --static irqreturn_t rtl8192_interrupt(int irq, void *param) --{ -- struct r8192_priv *priv = param; -- struct net_device *dev = priv->ieee80211->dev; -- unsigned long flags; -- u32 inta; -- irqreturn_t ret = IRQ_HANDLED; -- -- spin_lock_irqsave(&priv->irq_th_lock, flags); -- -- /* ISR: 4bytes */ -- -- inta = read_nic_dword(priv, ISR); /* & priv->IntrMask; */ -- write_nic_dword(priv, ISR, inta); /* reset int situation */ -- -- if (!inta) { -- /* -- * most probably we can safely return IRQ_NONE, -- * but for now is better to avoid problems -- */ -- goto out_unlock; -- } -- -- if (inta == 0xffff) { -- /* HW disappared */ -- goto out_unlock; -- } -- -- if (!netif_running(dev)) -- goto out_unlock; -- -- if (inta & IMR_TBDOK) { -- RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); -- rtl8192_tx_isr(priv, BEACON_QUEUE); -- priv->stats.txbeaconokint++; -- } -- -- if (inta & IMR_TBDER) { -- RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); -- rtl8192_tx_isr(priv, BEACON_QUEUE); -- priv->stats.txbeaconerr++; -- } -- -- if (inta & IMR_MGNTDOK ) { -- RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); -- priv->stats.txmanageokint++; -- rtl8192_tx_isr(priv, MGNT_QUEUE); -- } -- -- if (inta & IMR_COMDOK) -- { -- priv->stats.txcmdpktokint++; -- rtl8192_tx_isr(priv, TXCMD_QUEUE); -- } -- -- if (inta & IMR_ROK) { -- priv->stats.rxint++; -- tasklet_schedule(&priv->irq_rx_tasklet); -- } -- -- if (inta & IMR_BcnInt) { -- RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); -- tasklet_schedule(&priv->irq_prepare_beacon_tasklet); -- } -- -- if (inta & IMR_RDU) { -- RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); -- priv->stats.rxrdu++; -- /* reset int situation */ -- write_nic_dword(priv, INTA_MASK, read_nic_dword(priv, INTA_MASK) & ~IMR_RDU); -- tasklet_schedule(&priv->irq_rx_tasklet); -- } -- -- if (inta & IMR_RXFOVW) { -- RT_TRACE(COMP_INTR, "rx overflow !\n"); -- priv->stats.rxoverflow++; -- tasklet_schedule(&priv->irq_rx_tasklet); -- } -- -- if (inta & IMR_TXFOVW) -- priv->stats.txoverflow++; -- -- if (inta & IMR_BKDOK) { -- RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); -- priv->stats.txbkokint++; -- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; -- rtl8192_tx_isr(priv, BK_QUEUE); -- } -- -- if (inta & IMR_BEDOK) { -- RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); -- priv->stats.txbeokint++; -- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; -- rtl8192_tx_isr(priv, BE_QUEUE); -- } -- -- if (inta & IMR_VIDOK) { -- RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); -- priv->stats.txviokint++; -- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; -- rtl8192_tx_isr(priv, VI_QUEUE); -- } -- -- if (inta & IMR_VODOK) { -- priv->stats.txvookint++; -- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; -- rtl8192_tx_isr(priv, VO_QUEUE); -- } -- --out_unlock: -- spin_unlock_irqrestore(&priv->irq_th_lock, flags); -- -- return ret; --} -- --void EnableHWSecurityConfig8192(struct r8192_priv *priv) --{ -- u8 SECR_value = 0x0; -- struct ieee80211_device* ieee = priv->ieee80211; -- -- SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; -- -- if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) -- { -- SECR_value |= SCR_RxUseDK; -- SECR_value |= SCR_TxUseDK; -- } -- else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) -- { -- SECR_value |= SCR_RxUseDK; -- SECR_value |= SCR_TxUseDK; -- } -- -- //add HWSec active enable here. --//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 -- ieee->hwsec_active = 1; -- -- if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off -- { -- ieee->hwsec_active = 0; -- SECR_value &= ~SCR_RxDecEnable; -- } -- -- RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, -- ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); -- { -- write_nic_byte(priv, SECR, SECR_value);//SECR_value | SCR_UseDK ); -- } -- --} --#define TOTAL_CAM_ENTRY 32 --//#define CAM_CONTENT_COUNT 8 --void setKey(struct r8192_priv *priv, u8 EntryNo, u8 KeyIndex, u16 KeyType, -- const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) --{ -- u32 TargetCommand = 0; -- u32 TargetContent = 0; -- u16 usConfig = 0; -- u8 i; --#ifdef ENABLE_IPS -- RT_RF_POWER_STATE rtState; -- -- rtState = priv->eRFPowerState; -- if (priv->PowerSaveControl.bInactivePs){ -- if(rtState == eRfOff){ -- if(priv->RfOffReason > RF_CHANGE_BY_IPS) -- { -- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); -- //up(&priv->wx_sem); -- return ; -- } -- else{ -- down(&priv->ieee80211->ips_sem); -- IPSLeave(priv); -- up(&priv->ieee80211->ips_sem); -- } -- } -- } -- priv->ieee80211->is_set_key = true; --#endif -- if (EntryNo >= TOTAL_CAM_ENTRY) -- RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); -- -- RT_TRACE(COMP_SEC, "====>to setKey(), priv:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", priv, EntryNo, KeyIndex, KeyType, MacAddr); -- -- if (DefaultKey) -- usConfig |= BIT15 | (KeyType<<2); -- else -- usConfig |= BIT15 | (KeyType<<2) | KeyIndex; --// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; -- -- -- for(i=0 ; iafter set key, usconfig:%x\n", usConfig); --} -- --bool NicIFEnableNIC(struct r8192_priv *priv) --{ -- RT_STATUS init_status = RT_STATUS_SUCCESS; -- PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; -- -- //YJ,add,091109 -- if (priv->up == 0){ -- RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__FUNCTION__); -- priv->bdisable_nic = false; //YJ,add,091111 -- return false; -- } -- // <1> Reset memory: descriptor, buffer,.. -- //NicIFResetMemory(Adapter); -- -- // <2> Enable Adapter -- //priv->bfirst_init = true; -- init_status = rtl8192_adapter_start(priv); -- if (init_status != RT_STATUS_SUCCESS) { -- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__FUNCTION__); -- priv->bdisable_nic = false; //YJ,add,091111 -- return -1; -- } -- RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); -- //priv->bfirst_init = false; -- -- // <3> Enable Interrupt -- rtl8192_irq_enable(priv); -- priv->bdisable_nic = false; -- -- return (init_status == RT_STATUS_SUCCESS); --} -- --bool NicIFDisableNIC(struct r8192_priv *priv) --{ -- bool status = true; -- u8 tmp_state = 0; -- // <1> Disable Interrupt -- -- priv->bdisable_nic = true; //YJ,move,091109 -- tmp_state = priv->ieee80211->state; -- -- ieee80211_softmac_stop_protocol(priv->ieee80211, false); -- -- priv->ieee80211->state = tmp_state; -- rtl8192_cancel_deferred_work(priv); -- rtl8192_irq_disable(priv); -- // <2> Stop all timer -- -- // <3> Disable Adapter -- rtl8192_halt_adapter(priv, false); --// priv->bdisable_nic = true; -- -- return status; --} -- --module_init(rtl8192_pci_module_init); --module_exit(rtl8192_pci_module_exit); diff --git a/drivers/staging/rtl8192e/r8192E_dm.c b/drivers/staging/rtl8192e/r8192E_dm.c deleted file mode 100644 index 688d29b5588..00000000000 --- a/drivers/staging/rtl8192e/r8192E_dm.c +++ /dev/null @@ -1,2554 +0,0 @@ -/*++ -Copyright-c Realtek Semiconductor Corp. All rights reserved. - -Module Name: - r8192U_dm.c - -Abstract: - HW dynamic mechanism. - -Major Change History: - When Who What - ---------- --------------- ------------------------------- - 2008-05-14 amy create version 0 porting from windows code. - ---*/ -#include "r8192E.h" -#include "r8192E_dm.h" -#include "r8192E_hw.h" -#include "r819xE_phy.h" -#include "r819xE_phyreg.h" -#include "r8190_rtl8256.h" - -#define DRV_NAME "rtl819xE" - -// -// Indicate different AP vendor for IOT issue. -// -static const u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5e4322, 0x5e4322}; -static const u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5e4322, 0x5e4322, 0x5e4322}; - -#define RTK_UL_EDCA 0xa44f -#define RTK_DL_EDCA 0x5e4322 - - -dig_t dm_digtable; -// For Dynamic Rx Path Selection by Signal Strength -DRxPathSel DM_RxPathSelTable; - -void dm_gpio_change_rf_callback(struct work_struct *work); - -// DM --> Rate Adaptive -static void dm_check_rate_adaptive(struct r8192_priv *priv); - -// DM --> Bandwidth switch -static void dm_init_bandwidth_autoswitch(struct r8192_priv *priv); -static void dm_bandwidth_autoswitch(struct r8192_priv *priv); - -// DM --> TX power control -static void dm_check_txpower_tracking(struct r8192_priv *priv); - -// DM --> Dynamic Init Gain by RSSI -static void dm_dig_init(struct r8192_priv *priv); -static void dm_ctrl_initgain_byrssi(struct r8192_priv *priv); -static void dm_ctrl_initgain_byrssi_highpwr(struct r8192_priv *priv); -static void dm_ctrl_initgain_byrssi_by_driverrssi(struct r8192_priv *priv); -static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct r8192_priv *priv); -static void dm_initial_gain(struct r8192_priv *priv); -static void dm_pd_th(struct r8192_priv *priv); -static void dm_cs_ratio(struct r8192_priv *priv); - -static void dm_init_ctstoself(struct r8192_priv *priv); -// DM --> EDCA turboe mode control -static void dm_check_edca_turbo(struct r8192_priv *priv); -static void dm_init_edca_turbo(struct r8192_priv *priv); - -// DM --> HW RF control -static void dm_check_rfctrl_gpio(struct r8192_priv *priv); - -// DM --> Check current RX RF path state -static void dm_check_rx_path_selection(struct r8192_priv *priv); -static void dm_init_rxpath_selection(struct r8192_priv *priv); -static void dm_rxpath_sel_byrssi(struct r8192_priv *priv); - -// DM --> Fsync for broadcom ap -static void dm_init_fsync(struct r8192_priv *priv); -static void dm_deInit_fsync(struct r8192_priv *priv); - -static void dm_check_txrateandretrycount(struct r8192_priv *priv); -static void dm_check_fsync(struct r8192_priv *priv); - - -/*---------------------Define of Tx Power Control For Near/Far Range --------*/ //Add by Jacken 2008/02/18 -static void dm_init_dynamic_txpower(struct r8192_priv *priv); -static void dm_dynamic_txpower(struct r8192_priv *priv); - -// DM --> For rate adaptive and DIG, we must send RSSI to firmware -static void dm_send_rssi_tofw(struct r8192_priv *priv); -static void dm_ctstoself(struct r8192_priv *priv); - -static void dm_fsync_timer_callback(unsigned long data); - -/* - * Prepare SW resource for HW dynamic mechanism. - * This function is only invoked at driver intialization once. - */ -void init_hal_dm(struct r8192_priv *priv) -{ - // Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism. - priv->undecorated_smoothed_pwdb = -1; - - //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code. - dm_init_dynamic_txpower(priv); - init_rate_adaptive(priv); - //dm_initialize_txpower_tracking(dev); - dm_dig_init(priv); - dm_init_edca_turbo(priv); - dm_init_bandwidth_autoswitch(priv); - dm_init_fsync(priv); - dm_init_rxpath_selection(priv); - dm_init_ctstoself(priv); - INIT_DELAYED_WORK(&priv->gpio_change_rf_wq, dm_gpio_change_rf_callback); - -} - -void deinit_hal_dm(struct r8192_priv *priv) -{ - dm_deInit_fsync(priv); -} - -void hal_dm_watchdog(struct r8192_priv *priv) -{ - - /*Add by amy 2008/05/15 ,porting from windows code.*/ - dm_check_rate_adaptive(priv); - dm_dynamic_txpower(priv); - dm_check_txrateandretrycount(priv); - - dm_check_txpower_tracking(priv); - - dm_ctrl_initgain_byrssi(priv); - dm_check_edca_turbo(priv); - dm_bandwidth_autoswitch(priv); - - dm_check_rfctrl_gpio(priv); - dm_check_rx_path_selection(priv); - dm_check_fsync(priv); - - // Add by amy 2008-05-15 porting from windows code. - dm_send_rssi_tofw(priv); - dm_ctstoself(priv); -} - - -/* - * Decide Rate Adaptive Set according to distance (signal strength) - * 01/11/2008 MHC Modify input arguments and RATR table level. - * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call - * the function after making sure RF_Type. - */ -void init_rate_adaptive(struct r8192_priv *priv) -{ - prate_adaptive pra = &priv->rate_adaptive; - - pra->ratr_state = DM_RATR_STA_MAX; - pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; - pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; - pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; - - pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; - pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; - pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; - - if(priv->CustomerID == RT_CID_819x_Netcore) - pra->ping_rssi_enable = 1; - else - pra->ping_rssi_enable = 0; - pra->ping_rssi_thresh_for_ra = 15; - - - if (priv->rf_type == RF_2T4R) - { - // 07/10/08 MH Modify for RA smooth scheme. - /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/ - pra->upper_rssi_threshold_ratr = 0x8f0f0000; - pra->middle_rssi_threshold_ratr = 0x8f0ff000; - pra->low_rssi_threshold_ratr = 0x8f0ff001; - pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; - pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; - pra->ping_rssi_ratr = 0x0000000d;//cosa add for test - } - else if (priv->rf_type == RF_1T2R) - { - pra->upper_rssi_threshold_ratr = 0x000f0000; - pra->middle_rssi_threshold_ratr = 0x000ff000; - pra->low_rssi_threshold_ratr = 0x000ff001; - pra->low_rssi_threshold_ratr_40M = 0x000ff005; - pra->low_rssi_threshold_ratr_20M = 0x000ff001; - pra->ping_rssi_ratr = 0x0000000d;//cosa add for test - } - -} - - -static void dm_check_rate_adaptive(struct r8192_priv *priv) -{ - PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; - u32 currentRATR, targetRATR = 0; - u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; - bool bshort_gi_enabled = false; - static u8 ping_rssi_state=0; - - - if(!priv->up) - { - RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); - return; - } - - if(pra->rate_adaptive_disabled)//this variable is set by ioctl. - return; - - // TODO: Only 11n mode is implemented currently, - if( !(priv->ieee80211->mode == WIRELESS_MODE_N_24G || - priv->ieee80211->mode == WIRELESS_MODE_N_5G)) - return; - - if( priv->ieee80211->state == IEEE80211_LINKED ) - { - // RT_TRACE(COMP_RATE, "dm_CheckRateAdaptive(): \t"); - - // - // Check whether Short GI is enabled - // - bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || - (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); - - - pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - - pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - } - else - { - pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - } - //cosa add for test - pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - - /* 2007/10/08 MH We support RA smooth scheme now. When it is the first - time to link with AP. We will not change upper/lower threshold. If - STA stay in high or low level, we must change two different threshold - to prevent jumping frequently. */ - if (pra->ratr_state == DM_RATR_STA_HIGH) - { - HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); - } - else if (pra->ratr_state == DM_RATR_STA_LOW) - { - HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); - } - else - { - HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); - } - - if(priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) - { - pra->ratr_state = DM_RATR_STA_HIGH; - targetRATR = pra->upper_rssi_threshold_ratr; - }else if(priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) - { - pra->ratr_state = DM_RATR_STA_MIDDLE; - targetRATR = pra->middle_rssi_threshold_ratr; - }else - { - pra->ratr_state = DM_RATR_STA_LOW; - targetRATR = pra->low_rssi_threshold_ratr; - } - - //cosa add for test - if(pra->ping_rssi_enable) - { - //pHalData->UndecoratedSmoothedPWDB = 19; - if(priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) - { - if( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || - ping_rssi_state ) - { - pra->ratr_state = DM_RATR_STA_LOW; - targetRATR = pra->ping_rssi_ratr; - ping_rssi_state = 1; - } - } - else - { - ping_rssi_state = 0; - } - } - - // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7. - if(priv->ieee80211->GetHalfNmodeSupportByAPsHandler(priv->ieee80211)) - targetRATR &= 0xf00fffff; - - // - // Check whether updating of RATR0 is required - // - currentRATR = read_nic_dword(priv, RATR0); - if( targetRATR != currentRATR ) - { - u32 ratr_value; - ratr_value = targetRATR; - RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR); - if(priv->rf_type == RF_1T2R) - { - ratr_value &= ~(RATE_ALL_OFDM_2SS); - } - write_nic_dword(priv, RATR0, ratr_value); - write_nic_byte(priv, UFWP, 1); - - pra->last_ratr = targetRATR; - } - - } - else - { - pra->ratr_state = DM_RATR_STA_MAX; - } - -} - - -static void dm_init_bandwidth_autoswitch(struct r8192_priv *priv) -{ - priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH; - priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW; - priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false; - priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable = false; - -} - - -static void dm_bandwidth_autoswitch(struct r8192_priv *priv) -{ - if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable){ - return; - }else{ - if(priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz == false){//If send packets in 40 Mhz in 20/40 - if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz) - priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = true; - }else{//in force send packets in 20 Mhz in 20/40 - if(priv->undecorated_smoothed_pwdb >= priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz) - priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false; - - } - } -} - -//OFDM default at 0db, index=6. -static const u32 OFDMSwingTable[OFDM_Table_Length] = { - 0x7f8001fe, // 0, +6db - 0x71c001c7, // 1, +5db - 0x65400195, // 2, +4db - 0x5a400169, // 3, +3db - 0x50800142, // 4, +2db - 0x47c0011f, // 5, +1db - 0x40000100, // 6, +0db ===> default, upper for higher temperature, lower for low temperature - 0x390000e4, // 7, -1db - 0x32c000cb, // 8, -2db - 0x2d4000b5, // 9, -3db - 0x288000a2, // 10, -4db - 0x24000090, // 11, -5db - 0x20000080, // 12, -6db - 0x1c800072, // 13, -7db - 0x19800066, // 14, -8db - 0x26c0005b, // 15, -9db - 0x24400051, // 16, -10db - 0x12000048, // 17, -11db - 0x10000040 // 18, -12db -}; -static const u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { - {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0db ===> CCK40M default - {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 1, -1db - {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 2, -2db - {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 3, -3db - {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 4, -4db - {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 5, -5db - {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 6, -6db ===> CCK20M default - {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 7, -7db - {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 8, -8db - {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 9, -9db - {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 10, -10db - {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} // 11, -11db -}; - -static const u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { - {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0db ===> CCK40M default - {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 1, -1db - {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 2, -2db - {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 3, -3db - {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 4, -4db - {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 5, -5db - {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 6, -6db ===> CCK20M default - {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 7, -7db - {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 8, -8db - {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 9, -9db - {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 10, -10db - {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} // 11, -11db -}; - -#define Pw_Track_Flag 0x11d -#define Tssi_Mea_Value 0x13c -#define Tssi_Report_Value1 0x134 -#define Tssi_Report_Value2 0x13e -#define FW_Busy_Flag 0x13f -static void dm_TXPowerTrackingCallback_TSSI(struct r8192_priv *priv) -{ - bool bHighpowerstate, viviflag = FALSE; - DCMD_TXCMD_T tx_cmd; - u8 powerlevelOFDM24G; - int i =0, j = 0, k = 0; - u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; - u32 Value; - u8 Pwr_Flag; - u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; -// bool rtStatus = true; - u32 delta=0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__FUNCTION__); -// write_nic_byte(priv, 0x1ba, 0); - write_nic_byte(priv, Pw_Track_Flag, 0); - write_nic_byte(priv, FW_Busy_Flag, 0); - priv->ieee80211->bdynamic_txpower_enable = false; - bHighpowerstate = priv->bDynamicTxHighPower; - - powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24); - RF_Type = priv->rf_type; - Value = (RF_Type<<8) | powerlevelOFDM24G; - - RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); - - for(j = 0; j<=30; j++) -{ //fill tx_cmd - - tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; - tx_cmd.Length = 4; - tx_cmd.Value = Value; - cmpk_message_handle_tx(priv, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T)); - mdelay(1); - - for(i = 0;i <= 30; i++) - { - Pwr_Flag = read_nic_byte(priv, Pw_Track_Flag); - - if (Pwr_Flag == 0) - { - mdelay(1); - continue; - } - - Avg_TSSI_Meas = read_nic_word(priv, Tssi_Mea_Value); - - if(Avg_TSSI_Meas == 0) - { - write_nic_byte(priv, Pw_Track_Flag, 0); - write_nic_byte(priv, FW_Busy_Flag, 0); - return; - } - - for(k = 0;k < 5; k++) - { - if(k !=4) - tmp_report[k] = read_nic_byte(priv, Tssi_Report_Value1+k); - else - tmp_report[k] = read_nic_byte(priv, Tssi_Report_Value2); - - RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]); - } - - //check if the report value is right - for(k = 0;k < 5; k++) - { - if(tmp_report[k] <= 20) - { - viviflag =TRUE; - break; - } - } - if(viviflag ==TRUE) - { - write_nic_byte(priv, Pw_Track_Flag, 0); - viviflag = FALSE; - RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); - for(k = 0;k < 5; k++) - tmp_report[k] = 0; - break; - } - - for(k = 0;k < 5; k++) - { - Avg_TSSI_Meas_from_driver += tmp_report[k]; - } - - Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; - RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); - TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); - - //if(abs(Avg_TSSI_Meas_from_driver - TSSI_13dBm) <= E_FOR_TX_POWER_TRACK) - // For MacOS-compatible - if(Avg_TSSI_Meas_from_driver > TSSI_13dBm) - delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; - else - delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - - if(delta <= E_FOR_TX_POWER_TRACK) - { - priv->ieee80211->bdynamic_txpower_enable = TRUE; - write_nic_byte(priv, Pw_Track_Flag, 0); - write_nic_byte(priv, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - return; - } - else - { - if(Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) - { - if (RF_Type == RF_2T4R) - { - - if((priv->rfa_txpowertrackingindex > 0) &&(priv->rfc_txpowertrackingindex > 0)) - { - priv->rfa_txpowertrackingindex--; - if(priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - - priv->rfc_txpowertrackingindex--; - if(priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - { - rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - else - { - if(priv->rfc_txpowertrackingindex > 0) - { - priv->rfc_txpowertrackingindex--; - if(priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - else - { - if (RF_Type == RF_2T4R) - { - if((priv->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&(priv->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - { - rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - else - { - if(priv->rfc_txpowertrackingindex < (TxBBGainTableLength - 1)) - { - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - if (RF_Type == RF_2T4R) - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; - else - priv->CCKPresentAttentuation_difference - = priv->rfc_txpowertrackingindex - priv->rfc_txpowertracking_default; - - if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; - else - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - - if(priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if(priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if(1) - { - if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = TRUE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = FALSE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24) - { - priv->ieee80211->bdynamic_txpower_enable = TRUE; - write_nic_byte(priv, Pw_Track_Flag, 0); - write_nic_byte(priv, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); - return; - } - - - } - write_nic_byte(priv, Pw_Track_Flag, 0); - Avg_TSSI_Meas_from_driver = 0; - for(k = 0;k < 5; k++) - tmp_report[k] = 0; - break; - } - write_nic_byte(priv, FW_Busy_Flag, 0); -} - priv->ieee80211->bdynamic_txpower_enable = TRUE; - write_nic_byte(priv, Pw_Track_Flag, 0); -} - -static void dm_TXPowerTrackingCallback_ThermalMeter(struct r8192_priv *priv) -{ -#define ThermalMeterVal 9 - u32 tmpRegA, TempCCk; - u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; - int i =0, CCKSwingNeedUpdate=0; - - if(!priv->btxpower_trackingInit) - { - //Query OFDM default setting - tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord); - for(i=0; iOFDM_index= (u8)i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n", - rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index); - } - } - - //Query CCK default setting From 0xa22 - TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2); - for(i=0 ; iCCK_index =(u8) i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n", - rCCK0_TxFilter1, TempCCk, priv->CCK_index); - break; - } - } - priv->btxpower_trackingInit = TRUE; - //pHalData->TXPowercount = 0; - return; - } - - // read and filter out unreasonable value - tmpRegA = rtl8192_phy_QueryRFReg(priv, RF90_PATH_A, 0x12, 0x078); // 0x12: RF Reg[10:7] - RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA); - if(tmpRegA < 3 || tmpRegA > 13) - return; - if(tmpRegA >= 12) // if over 12, TP will be bad when high temperature - tmpRegA = 12; - RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA); - priv->ThermalMeter[0] = ThermalMeterVal; //We use fixed value by Bryant's suggestion - priv->ThermalMeter[1] = ThermalMeterVal; //We use fixed value by Bryant's suggestion - - //Get current RF-A temperature index - if(priv->ThermalMeter[0] >= (u8)tmpRegA) //lower temperature - { - tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA); - tmpCCK40Mindex = tmpCCK20Mindex - 6; - if(tmpOFDMindex >= OFDM_Table_Length) - tmpOFDMindex = OFDM_Table_Length-1; - if(tmpCCK20Mindex >= CCK_Table_length) - tmpCCK20Mindex = CCK_Table_length-1; - if(tmpCCK40Mindex >= CCK_Table_length) - tmpCCK40Mindex = CCK_Table_length-1; - } - else - { - tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]); - if(tmpval >= 6) // higher temperature - tmpOFDMindex = tmpCCK20Mindex = 0; // max to +6dB - else - tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval; - tmpCCK40Mindex = 0; - } - - if(priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) //40M - tmpCCKindex = tmpCCK40Mindex; - else - tmpCCKindex = tmpCCK20Mindex; - - //record for bandwidth swith - priv->Record_CCK_20Mindex = tmpCCK20Mindex; - priv->Record_CCK_40Mindex = tmpCCK40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", - priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); - - if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = TRUE; - CCKSwingNeedUpdate = 1; - } - else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = FALSE; - CCKSwingNeedUpdate = 1; - } - - if(priv->CCK_index != tmpCCKindex) -{ - priv->CCK_index = tmpCCKindex; - CCKSwingNeedUpdate = 1; - } - - if(CCKSwingNeedUpdate) - { - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - if(priv->OFDM_index != tmpOFDMindex) - { - priv->OFDM_index = tmpOFDMindex; - rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index]); - RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", - priv->OFDM_index, OFDMSwingTable[priv->OFDM_index]); - } - priv->txpower_count = 0; -} - -void dm_txpower_trackingcallback(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,txpower_tracking_wq); - - if(priv->IC_Cut >= IC_VersionCut_D) - dm_TXPowerTrackingCallback_TSSI(priv); - else - dm_TXPowerTrackingCallback_ThermalMeter(priv); -} - - -static const txbbgain_struct rtl8192_txbbgain_table[] = { - { 12, 0x7f8001fe }, - { 11, 0x788001e2 }, - { 10, 0x71c001c7 }, - { 9, 0x6b8001ae }, - { 8, 0x65400195 }, - { 7, 0x5fc0017f }, - { 6, 0x5a400169 }, - { 5, 0x55400155 }, - { 4, 0x50800142 }, - { 3, 0x4c000130 }, - { 2, 0x47c0011f }, - { 1, 0x43c0010f }, - { 0, 0x40000100 }, - { -1, 0x3c8000f2 }, - { -2, 0x390000e4 }, - { -3, 0x35c000d7 }, - { -4, 0x32c000cb }, - { -5, 0x300000c0 }, - { -6, 0x2d4000b5 }, - { -7, 0x2ac000ab }, - { -8, 0x288000a2 }, - { -9, 0x26000098 }, - { -10, 0x24000090 }, - { -11, 0x22000088 }, - { -12, 0x20000080 }, - { -13, 0x1a00006c }, - { -14, 0x1c800072 }, - { -15, 0x18000060 }, - { -16, 0x19800066 }, - { -17, 0x15800056 }, - { -18, 0x26c0005b }, - { -19, 0x14400051 }, - { -20, 0x24400051 }, - { -21, 0x1300004c }, - { -22, 0x12000048 }, - { -23, 0x11000044 }, - { -24, 0x10000040 }, -}; - -/* - * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 - * This Table is for CH1~CH13 - */ -static const ccktxbbgain_struct rtl8192_cck_txbbgain_table[] = { - {{ 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 }}, - {{ 0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04 }}, - {{ 0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03 }}, - {{ 0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03 }}, - {{ 0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03 }}, - {{ 0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03 }}, - {{ 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03 }}, - {{ 0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03 }}, - {{ 0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02 }}, - {{ 0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02 }}, - {{ 0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02 }}, - {{ 0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02 }}, - {{ 0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02 }}, - {{ 0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02 }}, - {{ 0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02 }}, - {{ 0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02 }}, - {{ 0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01 }}, - {{ 0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02 }}, - {{ 0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01 }}, - {{ 0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01 }}, - {{ 0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01 }}, - {{ 0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01 }}, - {{ 0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01 }}, -}; - -/* - * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 - * This Table is for CH14 - */ -static const ccktxbbgain_struct rtl8192_cck_txbbgain_ch14_table[] = { - {{ 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x2d, 0x2d, 0x27, 0x17, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x28, 0x28, 0x22, 0x14, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00 }}, - {{ 0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00 }}, -}; - -static void dm_InitializeTXPowerTracking_TSSI(struct r8192_priv *priv) -{ - priv->txbbgain_table = rtl8192_txbbgain_table; - priv->cck_txbbgain_table = rtl8192_cck_txbbgain_table; - priv->cck_txbbgain_ch14_table = rtl8192_cck_txbbgain_ch14_table; - - priv->btxpower_tracking = TRUE; - priv->txpower_count = 0; - priv->btxpower_trackingInit = FALSE; - -} - -static void dm_InitializeTXPowerTracking_ThermalMeter(struct r8192_priv *priv) -{ - // Tx Power tracking by Theremal Meter require Firmware R/W 3-wire. This mechanism - // can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w - // 3-wire by driver cause RF goes into wrong state. - if(priv->ieee80211->FwRWRF) - priv->btxpower_tracking = TRUE; - else - priv->btxpower_tracking = FALSE; - priv->txpower_count = 0; - priv->btxpower_trackingInit = FALSE; -} - -void dm_initialize_txpower_tracking(struct r8192_priv *priv) -{ - if(priv->IC_Cut >= IC_VersionCut_D) - dm_InitializeTXPowerTracking_TSSI(priv); - else - dm_InitializeTXPowerTracking_ThermalMeter(priv); -} - - -static void dm_CheckTXPowerTracking_TSSI(struct r8192_priv *priv) -{ - static u32 tx_power_track_counter = 0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__FUNCTION__); - if(read_nic_byte(priv, 0x11e) ==1) - return; - if(!priv->btxpower_tracking) - return; - tx_power_track_counter++; - - if (tx_power_track_counter > 90) { - queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0); - tx_power_track_counter =0; - } -} - -static void dm_CheckTXPowerTracking_ThermalMeter(struct r8192_priv *priv) -{ - static u8 TM_Trigger=0; - - if(!priv->btxpower_tracking) - return; - else - { - if(priv->txpower_count <= 2) - { - priv->txpower_count++; - return; - } - } - - if(!TM_Trigger) - { - //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash - //actually write reg0x02 bit1=0, then bit1=1. - rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); - rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); - rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); - rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); - TM_Trigger = 1; - return; - } - else { - queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0); - TM_Trigger = 0; - } -} - -static void dm_check_txpower_tracking(struct r8192_priv *priv) -{ - if(priv->IC_Cut >= IC_VersionCut_D) - dm_CheckTXPowerTracking_TSSI(priv); - else - dm_CheckTXPowerTracking_ThermalMeter(priv); -} - - -static void dm_CCKTxPowerAdjust_TSSI(struct r8192_priv *priv, bool bInCH14) -{ - u32 TempVal; - //Write 0xa22 0xa23 - TempVal = 0; - if(!bInCH14){ - //Write 0xa22 0xa23 - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - - rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal); - //Write 0xa24 ~ 0xa27 - TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal); - //Write 0xa28 0xa29 - TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - - rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal); - } - else - { - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - - rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal); - //Write 0xa24 ~ 0xa27 - TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal); - //Write 0xa28 0xa29 - TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - - rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal); - } - - -} - -static void dm_CCKTxPowerAdjust_ThermalMeter(struct r8192_priv *priv, - bool bInCH14) -{ - u32 TempVal; - - TempVal = 0; - if(!bInCH14) - { - //Write 0xa22 0xa23 - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; - rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter1, TempVal); - //Write 0xa24 ~ 0xa27 - TempVal = 0; - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); - rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter2, TempVal); - //Write 0xa28 0xa29 - TempVal = 0; - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ; - - rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_DebugPort, TempVal); - } - else - { -// priv->CCKTxPowerAdjustCntNotCh14++; //cosa add for debug. - //Write 0xa22 0xa23 - TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + - (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; - - rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter1, TempVal); - //Write 0xa24 ~ 0xa27 - TempVal = 0; - TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + - (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ - (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); - rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter2, TempVal); - //Write 0xa28 0xa29 - TempVal = 0; - TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + - (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; - - rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_DebugPort, TempVal); - } -} - -void dm_cck_txpower_adjust(struct r8192_priv *priv, bool binch14) -{ - if(priv->IC_Cut >= IC_VersionCut_D) - dm_CCKTxPowerAdjust_TSSI(priv, binch14); - else - dm_CCKTxPowerAdjust_ThermalMeter(priv, binch14); -} - -/* Set DIG scheme init value. */ -static void dm_dig_init(struct r8192_priv *priv) -{ - /* 2007/10/05 MH Disable DIG scheme now. Not tested. */ - dm_digtable.dig_enable_flag = true; - dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; - dm_digtable.dbg_mode = DM_DBG_OFF; //off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig - dm_digtable.dig_algorithm_switch = 0; - - /* 2007/10/04 MH Define init gain threshold. */ - dm_digtable.dig_state = DM_STA_DIG_MAX; - dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; - dm_digtable.initialgain_lowerbound_state = false; - - dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; - dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; - - dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW; - dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH; - - dm_digtable.rssi_val = 50; //for new dig debug rssi value - dm_digtable.backoff_val = DM_DIG_BACKOFF; - dm_digtable.rx_gain_range_max = DM_DIG_MAX; - if(priv->CustomerID == RT_CID_819x_Netcore) - dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; - else - dm_digtable.rx_gain_range_min = DM_DIG_MIN; - -} - - -/* - * Driver must monitor RSSI and notify firmware to change initial - * gain according to different threshold. BB team provide the - * suggested solution. - */ -static void dm_ctrl_initgain_byrssi(struct r8192_priv *priv) -{ - if (dm_digtable.dig_enable_flag == false) - return; - - if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - dm_ctrl_initgain_byrssi_by_fwfalse_alarm(priv); - else if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI) - dm_ctrl_initgain_byrssi_by_driverrssi(priv); -} - - -static void dm_ctrl_initgain_byrssi_by_driverrssi(struct r8192_priv *priv) -{ - u8 i; - static u8 fw_dig=0; - - if (dm_digtable.dig_enable_flag == false) - return; - - if(dm_digtable.dig_algorithm_switch) // if swithed algorithm, we have to disable FW Dig. - fw_dig = 0; - if(fw_dig <= 3) // execute several times to make sure the FW Dig is disabled - {// FW DIG Off - for(i=0; i<3; i++) - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite. - fw_dig++; - dm_digtable.dig_state = DM_STA_DIG_OFF; //fw dig off. - } - - if(priv->ieee80211->state == IEEE80211_LINKED) - dm_digtable.cur_connect_state = DIG_CONNECT; - else - dm_digtable.cur_connect_state = DIG_DISCONNECT; - - if(dm_digtable.dbg_mode == DM_DBG_OFF) - dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; - - dm_initial_gain(priv); - dm_pd_th(priv); - dm_cs_ratio(priv); - if(dm_digtable.dig_algorithm_switch) - dm_digtable.dig_algorithm_switch = 0; - dm_digtable.pre_connect_state = dm_digtable.cur_connect_state; - -} - -static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct r8192_priv *priv) -{ - static u32 reset_cnt = 0; - u8 i; - - if (dm_digtable.dig_enable_flag == false) - return; - - if(dm_digtable.dig_algorithm_switch) - { - dm_digtable.dig_state = DM_STA_DIG_MAX; - // Fw DIG On. - for(i=0; i<3; i++) - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite. - dm_digtable.dig_algorithm_switch = 0; - } - - if (priv->ieee80211->state != IEEE80211_LINKED) - return; - - // For smooth, we can not change DIG state. - if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) && - (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh)) - { - return; - } - - /* 1. When RSSI decrease, We have to judge if it is smaller than a threshold - and then execute below step. */ - if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) - { - /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters - will be reset to init value. We must prevent the condition. */ - if (dm_digtable.dig_state == DM_STA_DIG_OFF && - (priv->reset_count == reset_cnt)) - { - return; - } - else - { - reset_cnt = priv->reset_count; - } - - // If DIG is off, DIG high power state must reset. - dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; - dm_digtable.dig_state = DM_STA_DIG_OFF; - - // 1.1 DIG Off. - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite. - - // 1.2 Set initial gain. - write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x17); - write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x17); - write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x17); - write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x17); - - // 1.3 Lower PD_TH for OFDM. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */ - // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x00); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x42); - - // 1.4 Lower CS ratio for CCK. - write_nic_byte(priv, 0xa0a, 0x08); - - // 1.5 Higher EDCCA. - //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325); - return; - - } - - /* 2. When RSSI increase, We have to judge if it is larger than a threshold - and then execute below step. */ - if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) ) - { - u8 reset_flag = 0; - - if (dm_digtable.dig_state == DM_STA_DIG_ON && - (priv->reset_count == reset_cnt)) - { - dm_ctrl_initgain_byrssi_highpwr(priv); - return; - } - else - { - if (priv->reset_count != reset_cnt) - reset_flag = 1; - - reset_cnt = priv->reset_count; - } - - dm_digtable.dig_state = DM_STA_DIG_ON; - - // 2.1 Set initial gain. - // 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment. - if (reset_flag == 1) - { - write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x2c); - write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x2c); - write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x2c); - write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x2c); - } - else - { - write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x20); - write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x20); - write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x20); - write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x20); - } - - // 2.2 Higher PD_TH for OFDM. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */ - // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x44); - - // 2.3 Higher CS ratio for CCK. - write_nic_byte(priv, 0xa0a, 0xcd); - - // 2.4 Lower EDCCA. - /* 2008/01/11 MH 90/92 series are the same. */ - //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346); - - // 2.5 DIG On. - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite. - - } - - dm_ctrl_initgain_byrssi_highpwr(priv); - -} - -static void dm_ctrl_initgain_byrssi_highpwr(struct r8192_priv *priv) -{ - static u32 reset_cnt_highpwr = 0; - - // For smooth, we can not change high power DIG state in the range. - if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && - (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) - { - return; - } - - /* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if - it is larger than a threshold and then execute below step. */ - // 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue. - if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) - { - if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && - (priv->reset_count == reset_cnt_highpwr)) - return; - else - dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; - - // 3.1 Higher PD_TH for OFDM for high power state. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x10); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x43); - } - else - { - if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&& - (priv->reset_count == reset_cnt_highpwr)) - return; - else - dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; - - if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && - priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) - { - // 3.2 Recover PD_TH for OFDM for normal power region. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x44); - } - } - - reset_cnt_highpwr = priv->reset_count; - -} - - -static void dm_initial_gain(struct r8192_priv *priv) -{ - u8 initial_gain=0; - static u8 initialized=0, force_write=0; - static u32 reset_cnt=0; - - if(dm_digtable.dig_algorithm_switch) - { - initialized = 0; - reset_cnt = 0; - } - - if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state) - { - if(dm_digtable.cur_connect_state == DIG_CONNECT) - { - if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - else if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; - else - dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; - } - else //current state is disconnected - { - if(dm_digtable.cur_ig_value == 0) - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; - else - dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; - } - } - else // disconnected -> connected or connected -> disconnected - { - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; - dm_digtable.pre_ig_value = 0; - } - - // if silent reset happened, we should rewrite the values back - if(priv->reset_count != reset_cnt) - { - force_write = 1; - reset_cnt = priv->reset_count; - } - - if(dm_digtable.pre_ig_value != read_nic_byte(priv, rOFDM0_XAAGCCore1)) - force_write = 1; - - { - if((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) - || !initialized || force_write) - { - initial_gain = (u8)dm_digtable.cur_ig_value; - // Set initial gain. - write_nic_byte(priv, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XDAGCCore1, initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } - } -} - -static void dm_pd_th(struct r8192_priv *priv) -{ - static u8 initialized=0, force_write=0; - static u32 reset_cnt = 0; - - if(dm_digtable.dig_algorithm_switch) - { - initialized = 0; - reset_cnt = 0; - } - - if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state) - { - if(dm_digtable.cur_connect_state == DIG_CONNECT) - { - if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) - dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; - else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) - dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) && - (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh)) - dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; - else - dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; - } - else - { - dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; - } - } - else // disconnected -> connected or connected -> disconnected - { - dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; - } - - // if silent reset happened, we should rewrite the values back - if(priv->reset_count != reset_cnt) - { - force_write = 1; - reset_cnt = priv->reset_count; - } - - { - if((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || - (initialized<=3) || force_write) - { - if(dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) - { - // Lower PD_TH for OFDM. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */ - // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x00); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x42); - } - else if(dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) - { - // Higher PD_TH for OFDM. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */ - // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x44); - } - else if(dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) - { - // Higher PD_TH for OFDM for high power state. - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x10); - } - else - write_nic_byte(priv, rOFDM0_RxDetector1, 0x43); - } - dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; - if(initialized <= 3) - initialized++; - force_write = 0; - } - } -} - -static void dm_cs_ratio(struct r8192_priv *priv) -{ - static u8 initialized=0,force_write=0; - static u32 reset_cnt = 0; - - if(dm_digtable.dig_algorithm_switch) - { - initialized = 0; - reset_cnt = 0; - } - - if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state) - { - if(dm_digtable.cur_connect_state == DIG_CONNECT) - { - if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) - dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) ) - dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER; - else - dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state; - } - else - { - dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - } - } - else // disconnected -> connected or connected -> disconnected - { - dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - } - - // if silent reset happened, we should rewrite the values back - if(priv->reset_count != reset_cnt) - { - force_write = 1; - reset_cnt = priv->reset_count; - } - - - if((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || - !initialized || force_write) - { - if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) - { - // Lower CS ratio for CCK. - write_nic_byte(priv, 0xa0a, 0x08); - } - else if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) - { - // Higher CS ratio for CCK. - write_nic_byte(priv, 0xa0a, 0xcd); - } - dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; - initialized = 1; - force_write = 0; - } -} - -void dm_init_edca_turbo(struct r8192_priv *priv) -{ - - priv->bcurrent_turbo_EDCA = false; - priv->ieee80211->bis_any_nonbepkts = false; - priv->bis_cur_rdlstate = false; -} - -static void dm_check_edca_turbo(struct r8192_priv *priv) -{ - PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - //PSTA_QOS pStaQos = pMgntInfo->pStaQos; - - // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo. - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; - - // - // Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters - // should follow the settings from QAP. By Bruce, 2007-12-07. - // - if(priv->ieee80211->state != IEEE80211_LINKED) - goto dm_CheckEdcaTurbo_EXIT; - // We do not turn on EDCA turbo mode for some AP that has IOT issue - if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) - goto dm_CheckEdcaTurbo_EXIT; - - // Check the status for current condition. - if(!priv->ieee80211->bis_any_nonbepkts) - { - curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; - curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - // For RT-AP, we needs to turn it on when Rx>Tx - if(curRxOkCnt > 4*curTxOkCnt) - { - if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(priv, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = true; - } - } - else - { - if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(priv, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = false; - } - - } - - priv->bcurrent_turbo_EDCA = true; - } - else - { - // - // Turn Off EDCA turbo here. - // Restore original EDCA according to the declaration of AP. - // - if(priv->bcurrent_turbo_EDCA) - { - - { - u8 u1bAIFS; - u32 u4bAcParam; - struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; - u8 mode = priv->ieee80211->mode; - - // For Each time updating EDCA parameter, reset EDCA turbo mode status. - dm_init_edca_turbo(priv); - u1bAIFS = qos_parameters->aifs[0] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[0]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[0]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[0]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); - printk("===>u4bAcParam:%x, ", u4bAcParam); - //write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); - write_nic_dword(priv, EDCAPARA_BE, u4bAcParam); - - // Check ACM bit. - // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13. - { - // TODO: Modified this part and try to set acm control in only 1 IO processing!! - - PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); - u8 AcmCtrl = read_nic_byte(priv, AcmHwCtrl ); - if( pAciAifsn->f.ACM ) - { // ACM bit is 1. - AcmCtrl |= AcmHw_BeqEn; - } - else - { // ACM bit is 0. - AcmCtrl &= (~AcmHw_BeqEn); - } - - RT_TRACE( COMP_QOS,"SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ) ; - write_nic_byte(priv, AcmHwCtrl, AcmCtrl ); - } - } - priv->bcurrent_turbo_EDCA = false; - } - } - - -dm_CheckEdcaTurbo_EXIT: - // Set variables for next time. - priv->ieee80211->bis_any_nonbepkts = false; - lastTxOkCnt = priv->stats.txbytesunicast; - lastRxOkCnt = priv->stats.rxbytesunicast; -} - -static void dm_init_ctstoself(struct r8192_priv *priv) -{ - priv->ieee80211->bCTSToSelfEnable = TRUE; - priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal; -} - -static void dm_ctstoself(struct r8192_priv *priv) -{ - PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; - - if(priv->ieee80211->bCTSToSelfEnable != TRUE) - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - return; - } - /* - 1. Uplink - 2. Linksys350/Linksys300N - 3. <50 disable, >55 enable - */ - - if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; - curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if(curRxOkCnt > 4*curTxOkCnt) //downlink, disable CTS to self - { - pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - } - else //uplink - { - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - } - - lastTxOkCnt = priv->stats.txbytesunicast; - lastRxOkCnt = priv->stats.rxbytesunicast; - } -} - - - -/* Copy 8187B template for 9xseries */ -static void dm_check_rfctrl_gpio(struct r8192_priv *priv) -{ - - // Walk around for DTM test, we will not enable HW - radio on/off because r/w - // page 1 register before Lextra bus is enabled cause system fails when resuming - // from S4. 20080218, Emily - - // Stop to execute workitem to prevent S3/S4 bug. - queue_delayed_work(priv->priv_wq,&priv->gpio_change_rf_wq,0); -} - -/* PCI will not support workitem call back HW radio on-off control. */ -void dm_gpio_change_rf_callback(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,gpio_change_rf_wq); - u8 tmp1byte; - RT_RF_POWER_STATE eRfPowerStateToSet; - bool bActuallySet = false; - - if (!priv->up) { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF),"dm_gpio_change_rf_callback(): Callback function breaks out!!\n"); - } else { - // 0x108 GPIO input register is read only - //set 0x108 B1= 1: RF-ON; 0: RF-OFF. - tmp1byte = read_nic_byte(priv, GPI); - - eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - - if (priv->bHwRadioOff && (eRfPowerStateToSet == eRfOn)) { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); - - priv->bHwRadioOff = false; - bActuallySet = true; - } else if ((!priv->bHwRadioOff) && (eRfPowerStateToSet == eRfOff)) { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); - priv->bHwRadioOff = true; - bActuallySet = true; - } - - if (bActuallySet) { - priv->bHwRfOffAction = 1; - MgntActSet_RF_State(priv, eRfPowerStateToSet, RF_CHANGE_BY_HW); - //DrvIFIndicateCurrentPhyStatus(pAdapter); - } else { - msleep(2000); - } - } -} - -/* Check if Current RF RX path is enabled */ -void dm_rf_pathcheck_workitemcallback(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,rfpath_check_wq); - u8 rfpath = 0, i; - - - /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will - always be the same. We only read 0xc04 now. */ - rfpath = read_nic_byte(priv, 0xc04); - - // Check Bit 0-3, it means if RF A-D is enabled. - for (i = 0; i < RF90_PATH_MAX; i++) - { - if (rfpath & (0x01<brfpath_rxenable[i] = 1; - else - priv->brfpath_rxenable[i] = 0; - } - if(!DM_RxPathSelTable.Enable) - return; - - dm_rxpath_sel_byrssi(priv); -} - -static void dm_init_rxpath_selection(struct r8192_priv *priv) -{ - u8 i; - - DM_RxPathSelTable.Enable = 1; //default enabled - DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; - DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; - if(priv->CustomerID == RT_CID_819x_Netcore) - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; - else - DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; - DM_RxPathSelTable.DbgMode = DM_DBG_OFF; - DM_RxPathSelTable.disabledRF = 0; - for(i=0; i<4; i++) - { - DM_RxPathSelTable.rf_rssi[i] = 50; - DM_RxPathSelTable.cck_pwdb_sta[i] = -64; - DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; - } -} - -static void dm_rxpath_sel_byrssi(struct r8192_priv *priv) -{ - u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0; - u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0; - u8 cck_default_Rx=0x2; //RF-C - u8 cck_optional_Rx=0x3;//RF-D - long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0; - u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; - u8 cur_rf_rssi; - long cur_cck_pwdb; - static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; - u8 update_cck_rx_path; - - if(priv->rf_type != RF_2T4R) - return; - - if(!cck_Rx_Path_initialized) - { - DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(priv, 0xa07)&0xf); - cck_Rx_Path_initialized = 1; - } - - DM_RxPathSelTable.disabledRF = 0xf; - DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(priv, 0xc04)); - - if(priv->ieee80211->mode == WIRELESS_MODE_B) - { - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; //pure B mode, fixed cck version2 - } - - //decide max/sec/min rssi index - for (i=0; istats.rx_rssi_percentage[i]; - - if(priv->brfpath_rxenable[i]) - { - rf_num++; - cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; - - if(rf_num == 1) // find first enabled rf path and the rssi values - { //initialize, set all rssi index to the same one - max_rssi_index = min_rssi_index = sec_rssi_index = i; - tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; - } - else if(rf_num == 2) - { // we pick up the max index first, and let sec and min to be the same one - if(cur_rf_rssi >= tmp_max_rssi) - { - tmp_max_rssi = cur_rf_rssi; - max_rssi_index = i; - } - else - { - tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; - sec_rssi_index = min_rssi_index = i; - } - } - else - { - if(cur_rf_rssi > tmp_max_rssi) - { - tmp_sec_rssi = tmp_max_rssi; - sec_rssi_index = max_rssi_index; - tmp_max_rssi = cur_rf_rssi; - max_rssi_index = i; - } - else if(cur_rf_rssi == tmp_max_rssi) - { // let sec and min point to the different index - tmp_sec_rssi = cur_rf_rssi; - sec_rssi_index = i; - } - else if((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi)) - { - tmp_sec_rssi = cur_rf_rssi; - sec_rssi_index = i; - } - else if(cur_rf_rssi == tmp_sec_rssi) - { - if(tmp_sec_rssi == tmp_min_rssi) - { // let sec and min point to the different index - tmp_sec_rssi = cur_rf_rssi; - sec_rssi_index = i; - } - else - { - // This case we don't need to set any index - } - } - else if((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi)) - { - // This case we don't need to set any index - } - else if(cur_rf_rssi == tmp_min_rssi) - { - if(tmp_sec_rssi == tmp_min_rssi) - { // let sec and min point to the different index - tmp_min_rssi = cur_rf_rssi; - min_rssi_index = i; - } - else - { - // This case we don't need to set any index - } - } - else if(cur_rf_rssi < tmp_min_rssi) - { - tmp_min_rssi = cur_rf_rssi; - min_rssi_index = i; - } - } - } - } - - rf_num = 0; - // decide max/sec/min cck pwdb index - if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { - for (i=0; ibrfpath_rxenable[i]) - { - rf_num++; - cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; - - if(rf_num == 1) // find first enabled rf path and the rssi values - { //initialize, set all rssi index to the same one - cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i; - tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb; - } - else if(rf_num == 2) - { // we pick up the max index first, and let sec and min to be the same one - if(cur_cck_pwdb >= tmp_cck_max_pwdb) - { - tmp_cck_max_pwdb = cur_cck_pwdb; - cck_rx_ver2_max_index = i; - } - else - { - tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i; - } - } - else - { - if(cur_cck_pwdb > tmp_cck_max_pwdb) - { - tmp_cck_sec_pwdb = tmp_cck_max_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_max_index; - tmp_cck_max_pwdb = cur_cck_pwdb; - cck_rx_ver2_max_index = i; - } - else if(cur_cck_pwdb == tmp_cck_max_pwdb) - { // let sec and min point to the different index - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - } - else if((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb)) - { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - } - else if(cur_cck_pwdb == tmp_cck_sec_pwdb) - { - if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { // let sec and min point to the different index - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - } - else - { - // This case we don't need to set any index - } - } - else if((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb)) - { - // This case we don't need to set any index - } - else if(cur_cck_pwdb == tmp_cck_min_pwdb) - { - if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { // let sec and min point to the different index - tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_min_index = i; - } - else - { - // This case we don't need to set any index - } - } - else if(cur_cck_pwdb < tmp_cck_min_pwdb) - { - tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_min_index = i; - } - } - - } - } - } - - - // Set CCK Rx path - // reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path. - update_cck_rx_path = 0; - if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { - cck_default_Rx = cck_rx_ver2_max_index; - cck_optional_Rx = cck_rx_ver2_sec_index; - if(tmp_cck_max_pwdb != -64) - update_cck_rx_path = 1; - } - - if(tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) - { - if((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) - { - //record the enabled rssi threshold - DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; - //disable the BB Rx path, OFDM - rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0x1<>i) & 0x1) //disabled rf - { - if(tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) - { - //enable the BB Rx path - rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0x1<priv_wq,&priv->rfpath_check_wq,0); -} - -static void dm_init_fsync(struct r8192_priv *priv) -{ - priv->ieee80211->fsync_time_interval = 500; - priv->ieee80211->fsync_rate_bitmap = 0x0f000800; - priv->ieee80211->fsync_rssi_threshold = 30; - priv->ieee80211->bfsync_enable = false; - priv->ieee80211->fsync_multiple_timeinterval = 3; - priv->ieee80211->fsync_firstdiff_ratethreshold= 100; - priv->ieee80211->fsync_seconddiff_ratethreshold= 200; - priv->ieee80211->fsync_state = Default_Fsync; - priv->framesyncMonitor = 1; // current default 0xc38 monitor on - - init_timer(&priv->fsync_timer); - priv->fsync_timer.data = (unsigned long)priv; - priv->fsync_timer.function = dm_fsync_timer_callback; -} - - -static void dm_deInit_fsync(struct r8192_priv *priv) -{ - del_timer_sync(&priv->fsync_timer); -} - -static void dm_fsync_timer_callback(unsigned long data) -{ - struct r8192_priv *priv = (struct r8192_priv *)data; - u32 rate_index, rate_count = 0, rate_count_diff=0; - bool bSwitchFromCountDiff = false; - bool bDoubleTimeInterval = false; - - if( priv->ieee80211->state == IEEE80211_LINKED && - priv->ieee80211->bfsync_enable && - (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) - { - // Count rate 54, MCS [7], [12, 13, 14, 15] - u32 rate_bitmap; - for(rate_index = 0; rate_index <= 27; rate_index++) - { - rate_bitmap = 1 << rate_index; - if(priv->ieee80211->fsync_rate_bitmap & rate_bitmap) - rate_count+= priv->stats.received_rate_histogram[1][rate_index]; - } - - if(rate_count < priv->rate_record) - rate_count_diff = 0xffffffff - rate_count + priv->rate_record; - else - rate_count_diff = rate_count - priv->rate_record; - if(rate_count_diff < priv->rateCountDiffRecord) - { - - u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff; - // Contiune count - if(DiffNum >= priv->ieee80211->fsync_seconddiff_ratethreshold) - priv->ContiuneDiffCount++; - else - priv->ContiuneDiffCount = 0; - - // Contiune count over - if(priv->ContiuneDiffCount >=2) - { - bSwitchFromCountDiff = true; - priv->ContiuneDiffCount = 0; - } - } - else - { - // Stop contiune count - priv->ContiuneDiffCount = 0; - } - - //If Count diff <= FsyncRateCountThreshold - if(rate_count_diff <= priv->ieee80211->fsync_firstdiff_ratethreshold) - { - bSwitchFromCountDiff = true; - priv->ContiuneDiffCount = 0; - } - priv->rate_record = rate_count; - priv->rateCountDiffRecord = rate_count_diff; - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); - // if we never receive those mcs rate and rssi > 30 % then switch fsyn - if(priv->undecorated_smoothed_pwdb > priv->ieee80211->fsync_rssi_threshold && bSwitchFromCountDiff) - { - bDoubleTimeInterval = true; - priv->bswitch_fsync = !priv->bswitch_fsync; - if(priv->bswitch_fsync) - { - write_nic_byte(priv,0xC36, 0x1c); - write_nic_byte(priv, 0xC3e, 0x90); - } - else - { - write_nic_byte(priv, 0xC36, 0x5c); - write_nic_byte(priv, 0xC3e, 0x96); - } - } - else if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->fsync_rssi_threshold) - { - if(priv->bswitch_fsync) - { - priv->bswitch_fsync = false; - write_nic_byte(priv, 0xC36, 0x5c); - write_nic_byte(priv, 0xC3e, 0x96); - } - } - if(bDoubleTimeInterval){ - if(timer_pending(&priv->fsync_timer)) - del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval); - add_timer(&priv->fsync_timer); - } - else{ - if(timer_pending(&priv->fsync_timer)) - del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval); - add_timer(&priv->fsync_timer); - } - } - else - { - // Let Register return to default value; - if(priv->bswitch_fsync) - { - priv->bswitch_fsync = false; - write_nic_byte(priv, 0xC36, 0x5c); - write_nic_byte(priv, 0xC3e, 0x96); - } - priv->ContiuneDiffCount = 0; - write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd); - } - RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); -} - -static void dm_StartHWFsync(struct r8192_priv *priv) -{ - RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__); - write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c12cf); - write_nic_byte(priv, 0xc3b, 0x41); -} - -static void dm_EndSWFsync(struct r8192_priv *priv) -{ - RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__); - del_timer_sync(&(priv->fsync_timer)); - - // Let Register return to default value; - if(priv->bswitch_fsync) - { - priv->bswitch_fsync = false; - - write_nic_byte(priv, 0xC36, 0x40); - - write_nic_byte(priv, 0xC3e, 0x96); - } - - priv->ContiuneDiffCount = 0; - - write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd); -} - -static void dm_StartSWFsync(struct r8192_priv *priv) -{ - u32 rateIndex; - u32 rateBitmap; - - RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__); - // Initial rate record to zero, start to record. - priv->rate_record = 0; - // Initial contiune diff count to zero, start to record. - priv->ContiuneDiffCount = 0; - priv->rateCountDiffRecord = 0; - priv->bswitch_fsync = false; - - if(priv->ieee80211->mode == WIRELESS_MODE_N_24G) - { - priv->ieee80211->fsync_firstdiff_ratethreshold= 600; - priv->ieee80211->fsync_seconddiff_ratethreshold = 0xffff; - } - else - { - priv->ieee80211->fsync_firstdiff_ratethreshold= 200; - priv->ieee80211->fsync_seconddiff_ratethreshold = 200; - } - for(rateIndex = 0; rateIndex <= 27; rateIndex++) - { - rateBitmap = 1 << rateIndex; - if(priv->ieee80211->fsync_rate_bitmap & rateBitmap) - priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex]; - } - if(timer_pending(&priv->fsync_timer)) - del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval); - add_timer(&priv->fsync_timer); - - write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c12cd); -} - -static void dm_EndHWFsync(struct r8192_priv *priv) -{ - RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__); - write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd); - write_nic_byte(priv, 0xc3b, 0x49); -} - -static void dm_check_fsync(struct r8192_priv *priv) -{ -#define RegC38_Default 0 -#define RegC38_NonFsync_Other_AP 1 -#define RegC38_Fsync_AP_BCM 2 - //u32 framesyncC34; - static u8 reg_c38_State=RegC38_Default; - static u32 reset_cnt=0; - - RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->ieee80211->fsync_rssi_threshold, priv->ieee80211->fsync_time_interval, priv->ieee80211->fsync_multiple_timeinterval); - RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->ieee80211->fsync_rate_bitmap, priv->ieee80211->fsync_firstdiff_ratethreshold, priv->ieee80211->fsync_seconddiff_ratethreshold); - - if( priv->ieee80211->state == IEEE80211_LINKED && - (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) - { - if(priv->ieee80211->bfsync_enable == 0) - { - switch(priv->ieee80211->fsync_state) - { - case Default_Fsync: - dm_StartHWFsync(priv); - priv->ieee80211->fsync_state = HW_Fsync; - break; - case SW_Fsync: - dm_EndSWFsync(priv); - dm_StartHWFsync(priv); - priv->ieee80211->fsync_state = HW_Fsync; - break; - case HW_Fsync: - default: - break; - } - } - else - { - switch(priv->ieee80211->fsync_state) - { - case Default_Fsync: - dm_StartSWFsync(priv); - priv->ieee80211->fsync_state = SW_Fsync; - break; - case HW_Fsync: - dm_EndHWFsync(priv); - dm_StartSWFsync(priv); - priv->ieee80211->fsync_state = SW_Fsync; - break; - case SW_Fsync: - default: - break; - - } - } - if(priv->framesyncMonitor) - { - if(reg_c38_State != RegC38_Fsync_AP_BCM) - { //For broadcom AP we write different default value - write_nic_byte(priv, rOFDM0_RxDetector3, 0x95); - - reg_c38_State = RegC38_Fsync_AP_BCM; - } - } - } - else - { - switch(priv->ieee80211->fsync_state) - { - case HW_Fsync: - dm_EndHWFsync(priv); - priv->ieee80211->fsync_state = Default_Fsync; - break; - case SW_Fsync: - dm_EndSWFsync(priv); - priv->ieee80211->fsync_state = Default_Fsync; - break; - case Default_Fsync: - default: - break; - } - - if(priv->framesyncMonitor) - { - if(priv->ieee80211->state == IEEE80211_LINKED) - { - if(priv->undecorated_smoothed_pwdb <= RegC38_TH) - { - if(reg_c38_State != RegC38_NonFsync_Other_AP) - { - write_nic_byte(priv, rOFDM0_RxDetector3, 0x90); - - reg_c38_State = RegC38_NonFsync_Other_AP; - } - } - else if(priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) - { - if(reg_c38_State) - { - write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync); - reg_c38_State = RegC38_Default; - } - } - } - else - { - if(reg_c38_State) - { - write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync); - reg_c38_State = RegC38_Default; - } - } - } - } - if(priv->framesyncMonitor) - { - if(priv->reset_count != reset_cnt) - { //After silent reset, the reg_c38_State will be returned to default value - write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync); - reg_c38_State = RegC38_Default; - reset_cnt = priv->reset_count; - } - } - else - { - if(reg_c38_State) - { - write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync); - reg_c38_State = RegC38_Default; - } - } -} - -/* - * Detect Signal strength to control TX Registry - * Tx Power Control For Near/Far Range - */ -static void dm_init_dynamic_txpower(struct r8192_priv *priv) -{ - //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code. - priv->ieee80211->bdynamic_txpower_enable = true; //Default to enable Tx Power Control - priv->bLastDTPFlag_High = false; - priv->bLastDTPFlag_Low = false; - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; -} - -static void dm_dynamic_txpower(struct r8192_priv *priv) -{ - unsigned int txhipower_threshhold=0; - unsigned int txlowpower_threshold=0; - if(priv->ieee80211->bdynamic_txpower_enable != true) - { - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; - return; - } - if((priv->ieee80211->current_network.atheros_cap_exist ) && (priv->ieee80211->mode == IEEE_G)){ - txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; - txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; - } - else - { - txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; - txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; - } - - RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n" , priv->undecorated_smoothed_pwdb); - - if(priv->ieee80211->state == IEEE80211_LINKED) - { - if(priv->undecorated_smoothed_pwdb >= txhipower_threshhold) - { - priv->bDynamicTxHighPower = true; - priv->bDynamicTxLowPower = false; - } - else - { - // high power state check - if(priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) - { - priv->bDynamicTxHighPower = false; - } - // low power state check - if(priv->undecorated_smoothed_pwdb < 35) - { - priv->bDynamicTxLowPower = true; - } - else if(priv->undecorated_smoothed_pwdb >= 40) - { - priv->bDynamicTxLowPower = false; - } - } - } - else - { - //pHalData->bTXPowerCtrlforNearFarRange = !pHalData->bTXPowerCtrlforNearFarRange; - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; - } - - if( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) || - (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) ) - { - RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", priv->ieee80211->current_network.channel); - - - rtl8192_phy_setTxPower(priv, priv->ieee80211->current_network.channel); - - } - priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; - priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; - -} - -//added by vivi, for read tx rate and retrycount -static void dm_check_txrateandretrycount(struct r8192_priv *priv) -{ - struct ieee80211_device* ieee = priv->ieee80211; - - //for initial tx rate - ieee->softmac_stats.last_packet_rate = read_nic_byte(priv ,Initial_Tx_Rate_Reg); - //for tx tx retry count - ieee->softmac_stats.txretrycount = read_nic_dword(priv, Tx_Retry_Count_Reg); -} - -static void dm_send_rssi_tofw(struct r8192_priv *priv) -{ - // If we test chariot, we should stop the TX command ? - // Because 92E will always silent reset when we send tx command. We use register - // 0x1e0(byte) to botify driver. - write_nic_byte(priv, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); - return; -} - diff --git a/drivers/staging/rtl8192e/r8192E_dm.h b/drivers/staging/rtl8192e/r8192E_dm.h deleted file mode 100644 index b5b34eaaee9..00000000000 --- a/drivers/staging/rtl8192e/r8192E_dm.h +++ /dev/null @@ -1,228 +0,0 @@ -/***************************************************************************** - * Copyright(c) 2007, RealTEK Technology Inc. All Right Reserved. - * - * Module: Hal819xUsbDM.h (RTL8192 Header H File) - * - * - * Note: For dynamic control definition constant structure. - * - * - * Export: - * - * Abbrev: - * - * History: - * Data Who Remark - * 10/04/2007 MHC Create initial version. - * - *****************************************************************************/ - -#ifndef __R8192UDM_H__ -#define __R8192UDM_H__ - -#define OFDM_Table_Length 19 -#define CCK_Table_length 12 - -#define DM_DIG_THRESH_HIGH 40 -#define DM_DIG_THRESH_LOW 35 - -#define DM_DIG_HIGH_PWR_THRESH_HIGH 75 -#define DM_DIG_HIGH_PWR_THRESH_LOW 70 - -#define BW_AUTO_SWITCH_HIGH_LOW 25 -#define BW_AUTO_SWITCH_LOW_HIGH 30 - -#define DM_check_fsync_time_interval 500 - - -#define DM_DIG_BACKOFF 12 -#define DM_DIG_MAX 0x36 -#define DM_DIG_MIN 0x1c -#define DM_DIG_MIN_Netcore 0x12 - -#define RxPathSelection_SS_TH_low 30 -#define RxPathSelection_diff_TH 18 - -#define RateAdaptiveTH_High 50 -#define RateAdaptiveTH_Low_20M 30 -#define RateAdaptiveTH_Low_40M 10 -#define VeryLowRSSI 15 -#define CTSToSelfTHVal 35 - -//defined by vivi, for tx power track -#define E_FOR_TX_POWER_TRACK 300 -//Dynamic Tx Power Control Threshold -#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 -#define TX_POWER_NEAR_FIELD_THRESH_LOW 62 -//added by amy for atheros AP -#define TX_POWER_ATHEROAP_THRESH_HIGH 78 -#define TX_POWER_ATHEROAP_THRESH_LOW 72 - -//defined by vivi, for showing on UI. Newer firmware has changed to 0x1e0 -#define Current_Tx_Rate_Reg 0x1e0//0x1b8 -#define Initial_Tx_Rate_Reg 0x1e1 //0x1b9 -#define Tx_Retry_Count_Reg 0x1ac -#define RegC38_TH 20 - -/* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ -typedef struct _dynamic_initial_gain_threshold_ -{ - u8 dig_enable_flag; - u8 dig_algorithm; - u8 dbg_mode; - u8 dig_algorithm_switch; - - long rssi_low_thresh; - long rssi_high_thresh; - - long rssi_high_power_lowthresh; - long rssi_high_power_highthresh; - - u8 dig_state; - u8 dig_highpwr_state; - u8 cur_connect_state; - u8 pre_connect_state; - - u8 curpd_thstate; - u8 prepd_thstate; - u8 curcs_ratio_state; - u8 precs_ratio_state; - - u32 pre_ig_value; - u32 cur_ig_value; - - u8 backoff_val; - u8 rx_gain_range_max; - u8 rx_gain_range_min; - bool initialgain_lowerbound_state; - - long rssi_val; -}dig_t; - -typedef enum tag_dynamic_init_gain_state_definition -{ - DM_STA_DIG_OFF = 0, - DM_STA_DIG_ON, - DM_STA_DIG_MAX -}dm_dig_sta_e; - - -/* 2007/10/08 MH Define RATR state. */ -typedef enum tag_dynamic_ratr_state_definition -{ - DM_RATR_STA_HIGH = 0, - DM_RATR_STA_MIDDLE = 1, - DM_RATR_STA_LOW = 2, - DM_RATR_STA_MAX -}dm_ratr_sta_e; - -/* 2007/10/11 MH Define DIG operation type. */ -typedef enum tag_dynamic_init_gain_operation_type_definition -{ - DIG_TYPE_THRESH_HIGH = 0, - DIG_TYPE_THRESH_LOW = 1, - DIG_TYPE_THRESH_HIGHPWR_HIGH = 2, - DIG_TYPE_THRESH_HIGHPWR_LOW = 3, - DIG_TYPE_DBG_MODE = 4, - DIG_TYPE_RSSI = 5, - DIG_TYPE_ALGORITHM = 6, - DIG_TYPE_BACKOFF = 7, - DIG_TYPE_PWDB_FACTOR = 8, - DIG_TYPE_RX_GAIN_MIN = 9, - DIG_TYPE_RX_GAIN_MAX = 10, - DIG_TYPE_ENABLE = 20, - DIG_TYPE_DISABLE = 30, - DIG_OP_TYPE_MAX -}dm_dig_op_e; - -typedef enum tag_dig_algorithm_definition -{ - DIG_ALGO_BY_FALSE_ALARM = 0, - DIG_ALGO_BY_RSSI = 1, - DIG_ALGO_MAX -}dm_dig_alg_e; - -typedef enum tag_dig_dbgmode_definition -{ - DIG_DBG_OFF = 0, - DIG_DBG_ON = 1, - DIG_DBG_MAX -}dm_dig_dbg_e; - -typedef enum tag_dig_connect_definition -{ - DIG_DISCONNECT = 0, - DIG_CONNECT = 1, - DIG_CONNECT_MAX -}dm_dig_connect_e; - -typedef enum tag_dig_packetdetection_threshold_definition -{ - DIG_PD_AT_LOW_POWER = 0, - DIG_PD_AT_NORMAL_POWER = 1, - DIG_PD_AT_HIGH_POWER = 2, - DIG_PD_MAX -}dm_dig_pd_th_e; - -typedef enum tag_dig_cck_cs_ratio_state_definition -{ - DIG_CS_RATIO_LOWER = 0, - DIG_CS_RATIO_HIGHER = 1, - DIG_CS_MAX -}dm_dig_cs_ratio_e; -typedef struct _Dynamic_Rx_Path_Selection_ -{ - u8 Enable; - u8 DbgMode; - u8 cck_method; - u8 cck_Rx_path; - - u8 SS_TH_low; - u8 diff_TH; - u8 disabledRF; - u8 reserved; - - u8 rf_rssi[4]; - u8 rf_enable_rssi_th[4]; - long cck_pwdb_sta[4]; -}DRxPathSel; - -typedef enum tag_CCK_Rx_Path_Method_Definition -{ - CCK_Rx_Version_1 = 0, - CCK_Rx_Version_2= 1, - CCK_Rx_Version_MAX -}DM_CCK_Rx_Path_Method; - -typedef enum tag_DM_DbgMode_Definition -{ - DM_DBG_OFF = 0, - DM_DBG_ON = 1, - DM_DBG_MAX -}DM_DBG_E; - -typedef struct tag_Tx_Config_Cmd_Format -{ - u32 Op; /* Command packet type. */ - u32 Length; /* Command packet length. */ - u32 Value; -}DCMD_TXCMD_T, *PDCMD_TXCMD_T; - - -extern dig_t dm_digtable; -extern DRxPathSel DM_RxPathSelTable; - -void init_hal_dm(struct r8192_priv *priv); -void deinit_hal_dm(struct r8192_priv *priv); - -void hal_dm_watchdog(struct r8192_priv *priv); - -void init_rate_adaptive(struct r8192_priv *priv); -void dm_txpower_trackingcallback(struct work_struct *work); -void dm_rf_pathcheck_workitemcallback(struct work_struct *work); -void dm_initialize_txpower_tracking(struct r8192_priv *priv); -void dm_cck_txpower_adjust(struct r8192_priv *priv, bool binch14); - - -#endif /*__R8192UDM_H__ */ - diff --git a/drivers/staging/rtl8192e/r8192E_wx.c b/drivers/staging/rtl8192e/r8192E_wx.c deleted file mode 100644 index adad91b0b6b..00000000000 --- a/drivers/staging/rtl8192e/r8192E_wx.c +++ /dev/null @@ -1,1163 +0,0 @@ -/* - This file contains wireless extension handlers. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part - of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#include -#include "r8192E.h" -#include "r8192E_hw.h" -#include "r8192E_wx.h" -#ifdef ENABLE_DOT11D -#include "ieee80211/dot11d.h" -#endif - -#define RATE_COUNT 12 -static const u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - - -#ifndef ENETDOWN -#define ENETDOWN 1 -#endif -static int r8192_wx_get_freq(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); -} - - -static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct r8192_priv *priv=ieee80211_priv(dev); - - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); -} - - - -static int r8192_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); -} - - - -static int r8192_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - - up(&priv->wx_sem); - - return ret; -} - - -static int r8192_wx_set_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - ret = ieee80211_wx_set_rts(priv->ieee80211,info,wrqu,extra); - - up(&priv->wx_sem); - - return ret; -} - -static int r8192_wx_get_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rts(priv->ieee80211,info,wrqu,extra); -} - -static int r8192_wx_set_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - ret = ieee80211_wx_set_power(priv->ieee80211,info,wrqu,extra); - - up(&priv->wx_sem); - - return ret; -} - -static int r8192_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_power(priv->ieee80211,info,wrqu,extra); -} - -static int r8192_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - - up(&priv->wx_sem); - - return ret; - -} - -static int r8192_wx_force_reset(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - printk("%s(): force reset ! extra is %d\n",__FUNCTION__, *extra); - priv->force_reset = *extra; - up(&priv->wx_sem); - return 0; - -} - - -static int r8192_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int *parms = (int *)extra; - int enable = (parms[0] > 0); - short prev = priv->crcmon; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - if(enable) - priv->crcmon=1; - else - priv->crcmon=0; - - DMESG("bad CRC in monitor mode are %s", - priv->crcmon ? "accepted" : "rejected"); - - if(prev != priv->crcmon && priv->up){ - //rtl8180_down(dev); - //rtl8180_up(dev); - } - - up(&priv->wx_sem); - - return 0; -} - -static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - RT_RF_POWER_STATE rtState; - int ret; - - if (priv->bHwRadioOff) - return 0; - - rtState = priv->eRFPowerState; - down(&priv->wx_sem); -#ifdef ENABLE_IPS - if(wrqu->mode == IW_MODE_ADHOC){ - - if (priv->PowerSaveControl.bInactivePs) { - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - up(&priv->wx_sem); - return -1; - } - else{ - RT_TRACE(COMP_ERR, "%s(): IPSLeave\n",__FUNCTION__); - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); - } - } - } - } -#endif - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - - //rtl8187_set_rxconf(dev); - - up(&priv->wx_sem); - return ret; -} - -struct iw_range_with_scan_capa -{ - /* Informative stuff (to choose between different interface) */ - __u32 throughput; /* To give an idea... */ - /* In theory this value should be the maximum benchmarked - * TCP/IP throughput, because with most of these devices the - * bit rate is meaningless (overhead an co) to estimate how - * fast the connection will go and pick the fastest one. - * I suggest people to play with Netperf or any benchmark... - */ - - /* NWID (or domain id) */ - __u32 min_nwid; /* Minimal NWID we are able to set */ - __u32 max_nwid; /* Maximal NWID we are able to set */ - - /* Old Frequency (backward compat - moved lower ) */ - __u16 old_num_channels; - __u8 old_num_frequency; - - /* Scan capabilities */ - __u8 scan_capa; -}; -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - struct iw_range_with_scan_capa* tmp = (struct iw_range_with_scan_capa*)range; - struct r8192_priv *priv = ieee80211_priv(dev); - u16 val; - int i; - - wrqu->data.length = sizeof(*range); - memset(range, 0, sizeof(*range)); - - /* Let's try to keep this struct in the same order as in - * linux/include/wireless.h - */ - - /* TODO: See what values we can set, and remove the ones we can't - * set, or fill them with some default data. - */ - - /* ~5 Mb/s real (802.11b) */ - range->throughput = 130 * 1000 * 1000; - - // TODO: Not used in 802.11b? -// range->min_nwid; /* Minimal NWID we are able to set */ - // TODO: Not used in 802.11b? -// range->max_nwid; /* Maximal NWID we are able to set */ - - /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; -// range->old_num_frequency; -// range->old_freq[6]; /* Filler to keep "version" at the same offset */ - - range->max_qual.qual = 100; - /* TODO: Find real max RSSI and stick here */ - range->max_qual.level = 0; - range->max_qual.noise = -98; - range->max_qual.updated = 7; /* Updated all three */ - - range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ - /* TODO: Find real 'good' to 'bad' threshold value for RSSI */ - range->avg_qual.level = 20 + -98; - range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ - - range->num_bitrates = RATE_COUNT; - - for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { - range->bitrate[i] = rtl8180_rates[i]; - } - - range->min_frag = MIN_FRAG_THRESHOLD; - range->max_frag = MAX_FRAG_THRESHOLD; - - range->min_pmp=0; - range->max_pmp = 5000000; - range->min_pmt = 0; - range->max_pmt = 65535*1000; - range->pmp_flags = IW_POWER_PERIOD; - range->pmt_flags = IW_POWER_TIMEOUT; - range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; - range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 18; - -// range->retry_capa; /* What retry options are supported */ -// range->retry_flags; /* How to decode max/min retry limit */ -// range->r_time_flags; /* How to decode max/min retry life */ -// range->min_retry; /* Minimal number of retries */ -// range->max_retry; /* Maximal number of retries */ -// range->min_r_time; /* Minimal retry lifetime */ -// range->max_r_time; /* Maximal retry lifetime */ - - - for (i = 0, val = 0; i < 14; i++) { - - // Include only legal frequencies for some countries -#ifdef ENABLE_DOT11D - if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) { -#else - if ((priv->ieee80211->channel_map)[i+1]) { -#endif - range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; - range->freq[val].e = 1; - val++; - } else { - // FIXME: do we need to set anything for channels - // we don't use ? - } - - if (val == IW_MAX_FREQUENCIES) - break; - } - range->num_frequency = val; - range->num_channels = val; - - range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2| - IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; - - tmp->scan_capa = 0x01; - return 0; -} - - -static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; - RT_RF_POWER_STATE rtState; - int ret; - - if (priv->bHwRadioOff) - return 0; - - rtState = priv->eRFPowerState; - - if(!priv->up) return -ENETDOWN; - if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true) - return -EAGAIN; - - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { - struct iw_scan_req* req = (struct iw_scan_req*)b; - if (req->essid_len) - { - //printk("==**&*&*&**===>scan set ssid:%s\n", req->essid); - ieee->current_network.ssid_len = req->essid_len; - memcpy(ieee->current_network.ssid, req->essid, req->essid_len); - //printk("=====>network ssid:%s\n", ieee->current_network.ssid); - } - } - - down(&priv->wx_sem); -#ifdef ENABLE_IPS - priv->ieee80211->actscanning = true; - if(priv->ieee80211->state != IEEE80211_LINKED){ - if (priv->PowerSaveControl.bInactivePs) { - if(rtState == eRfOff){ - if(priv->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__FUNCTION__); - up(&priv->wx_sem); - return -1; - } - else{ - //RT_TRACE(COMP_PS, "%s(): IPSLeave\n",__FUNCTION__); - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); - } - } - } - priv->ieee80211->scanning = 0; - ieee80211_softmac_scan_syncro(priv->ieee80211); - ret = 0; - } - else -#else - - if(priv->ieee80211->state != IEEE80211_LINKED){ - priv->ieee80211->scanning = 0; - ieee80211_softmac_scan_syncro(priv->ieee80211); - ret = 0; - } - else -#endif - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - - up(&priv->wx_sem); - return ret; -} - - -static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - if(!priv->up) return -ENETDOWN; - - down(&priv->wx_sem); - - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - - up(&priv->wx_sem); - - return ret; -} - -static int r8192_wx_set_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - RT_RF_POWER_STATE rtState; - int ret; - - if (priv->bHwRadioOff) - return 0; - - rtState = priv->eRFPowerState; - down(&priv->wx_sem); - -#ifdef ENABLE_IPS - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -#endif - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - - up(&priv->wx_sem); - - return ret; -} - - - - -static int r8192_wx_get_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); - - up(&priv->wx_sem); - - return ret; -} - - -static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - - up(&priv->wx_sem); - return ret; -} - -static int r8192_wx_get_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); -} - - -static int r8192_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - if (wrqu->frag.disabled) - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - else { - if (wrqu->frag.value < MIN_FRAG_THRESHOLD || - wrqu->frag.value > MAX_FRAG_THRESHOLD) - return -EINVAL; - - priv->ieee80211->fts = wrqu->frag.value & ~0x1; - } - - return 0; -} - - -static int r8192_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - wrqu->frag.value = priv->ieee80211->fts; - wrqu->frag.fixed = 0; /* no auto select */ - wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD); - - return 0; -} - - -static int r8192_wx_set_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra) -{ - - int ret; - struct r8192_priv *priv = ieee80211_priv(dev); -// struct sockaddr *temp = (struct sockaddr *)awrq; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - -#ifdef ENABLE_IPS - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -#endif - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - - up(&priv->wx_sem); - - return ret; - -} - - -static int r8192_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); -} - - -static int r8192_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); -} - -static int r8192_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int ret; - - struct ieee80211_device *ieee = priv->ieee80211; - //u32 TargetContent; - u32 hwkey[4]={0,0,0,0}; - u8 mask=0xff; - u32 key_idx=0; - u8 zero_addr[4][6] ={{0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x02}, - {0x00,0x00,0x00,0x00,0x00,0x03} }; - int i; - - if (priv->bHwRadioOff) - return 0; - - if(!priv->up) return -ENETDOWN; - - priv->ieee80211->wx_set_enc = 1; -#ifdef ENABLE_IPS - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -#endif - - down(&priv->wx_sem); - - RT_TRACE(COMP_SEC, "Setting SW wep key\n"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - - up(&priv->wx_sem); - - //sometimes, the length is zero while we do not type key value - if(wrqu->encoding.length!=0){ - - for(i=0 ; i<4 ; i++){ - hwkey[i] |= key[4*i+0]&mask; - if(i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; - if(i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; - hwkey[i] |= (key[4*i+1]&mask)<<8; - hwkey[i] |= (key[4*i+2]&mask)<<16; - hwkey[i] |= (key[4*i+3]&mask)<<24; - } - - #define CONF_WEP40 0x4 - #define CONF_WEP104 0x14 - - switch(wrqu->encoding.flags & IW_ENCODE_INDEX){ - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; - } - - //printk("-------====>length:%d, key_idx:%d, flag:%x\n", wrqu->encoding.length, key_idx, wrqu->encoding.flags); - if(wrqu->encoding.length==0x5){ - ieee->pairwise_key_type = KEY_TYPE_WEP40; - EnableHWSecurityConfig8192(priv); - setKey(priv, key_idx, key_idx, KEY_TYPE_WEP40, - zero_addr[key_idx], 0, hwkey); - } - - else if(wrqu->encoding.length==0xd){ - ieee->pairwise_key_type = KEY_TYPE_WEP104; - EnableHWSecurityConfig8192(priv); - setKey(priv, key_idx, key_idx, KEY_TYPE_WEP104, - zero_addr[key_idx], 0, hwkey); - } - else printk("wrong type in WEP, not WEP40 and WEP104\n"); - } - - priv->ieee80211->wx_set_enc = 0; - - return ret; -} - - -static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ - - struct r8192_priv *priv = ieee80211_priv(dev); - int *parms=(int*)p; - int mode=parms[0]; - - priv->ieee80211->active_scan = mode; - - return 1; -} - - - -static int r8192_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - int err = 0; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || - wrqu->retry.disabled){ - err = -EINVAL; - goto exit; - } - if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ - err = -EINVAL; - goto exit; - } - - if(wrqu->retry.value > R8180_MAX_RETRY){ - err= -EINVAL; - goto exit; - } - if (wrqu->retry.flags & IW_RETRY_MAX) { - priv->retry_rts = wrqu->retry.value; - DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - - }else { - priv->retry_data = wrqu->retry.value; - DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); - } - - /* FIXME ! - * We might try to write directly the TX config register - * or to restart just the (R)TX process. - * I'm unsure if whole reset is really needed - */ - - rtl8192_commit(priv); - /* - if(priv->up){ - rtl8180_rtx_disable(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - } - */ -exit: - up(&priv->wx_sem); - - return err; -} - -static int r8192_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - - wrqu->retry.disabled = 0; /* can't be disabled */ - - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) - return -EINVAL; - - if (wrqu->retry.flags & IW_RETRY_MAX) { - wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; - wrqu->retry.value = priv->retry_rts; - } else { - wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN; - wrqu->retry.value = priv->retry_data; - } - //DMESG("returning %d",wrqu->retry.value); - - - return 0; -} - -static int r8192_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) - return -1; /* we have not this support for this radio */ - wrqu->sens.value = priv->sens; - return 0; -} - - -static int r8192_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - struct r8192_priv *priv = ieee80211_priv(dev); - - short err = 0; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); - if(priv->rf_set_sens == NULL) { - err= -1; /* we have not this support for this radio */ - goto exit; - } - if(priv->rf_set_sens(dev, wrqu->sens.value) == 0) - priv->sens = wrqu->sens.value; - else - err= -EINVAL; - -exit: - up(&priv->wx_sem); - - return err; -} - -static int r8192_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret=0; - struct r8192_priv *priv = ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - - priv->ieee80211->wx_set_enc = 1; - -#ifdef ENABLE_IPS - down(&priv->ieee80211->ips_sem); - IPSLeave(priv); - up(&priv->ieee80211->ips_sem); -#endif - - ret = ieee80211_wx_set_encode_ext(ieee, info, wrqu, extra); - - { - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; - u8 zero[6] = {0}; - u32 key[4] = {0}; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - struct iw_point *encoding = &wrqu->encoding; - u8 idx = 0, alg = 0, group = 0; - - if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) //none is not allowed to use hwsec WB 2008.07.01 - { - ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; - CamResetAllEntry(priv); - goto end_hw_sec; - } - alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4; - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) - idx --; - group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; - - if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) - { - if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) - alg = KEY_TYPE_WEP104; - ieee->pairwise_key_type = alg; - EnableHWSecurityConfig8192(priv); - } - memcpy((u8*)key, ext->key, 16); //we only get 16 bytes key.why? WB 2008.7.1 - - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) - { - if (ext->key_len == 13) - ieee->pairwise_key_type = alg = KEY_TYPE_WEP104; - setKey(priv, idx, idx, alg, zero, 0, key); - } - else if (group) - { - ieee->group_key_type = alg; - setKey(priv, idx, idx, alg, broadcast_addr, 0, key); - } - else //pairwise key - { - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(priv, 0x173, 1); //fix aes bug - } - setKey(priv, 4, idx, alg, - (u8*)ieee->ap_mac_addr, 0, key); - } - - - } - -end_hw_sec: - priv->ieee80211->wx_set_enc = 0; - up(&priv->wx_sem); - return ret; - -} -static int r8192_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) -{ - int ret=0; - //printk("====>%s()\n", __FUNCTION__); - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra); - up(&priv->wx_sem); - return ret; -} - -static int r8192_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - //printk("====>%s()\n", __FUNCTION__); - - int ret=0; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); - return ret; -} - -static int r8192_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) -{ - //printk("====>%s(), len:%d\n", __FUNCTION__, data->length); - int ret=0; - struct r8192_priv *priv = ieee80211_priv(dev); - - if (priv->bHwRadioOff) - return 0; - - down(&priv->wx_sem); - ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length); - up(&priv->wx_sem); - //printk("<======%s(), ret:%d\n", __FUNCTION__, ret); - return ret; -} - -static int dummy(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu,char *b) -{ - return -1; -} - -// check ac/dc status with the help of user space application */ -static int r8192_wx_adapter_power_status(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = ieee80211_priv(dev); -#ifdef ENABLE_LPS - PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl; - struct ieee80211_device* ieee = priv->ieee80211; -#endif - down(&priv->wx_sem); - -#ifdef ENABLE_LPS - RT_TRACE(COMP_POWER, "%s(): %s\n",__FUNCTION__, (*extra == 6)?"DC power":"AC power"); - // ieee->ps shall not be set under DC mode, otherwise it conflict - // with Leisure power save mode setting. - // - if(*extra || priv->force_lps) { - priv->ps_force = false; - pPSC->bLeisurePs = true; - } else { - //LZM for PS-Poll AID issue. 090429 - if(priv->ieee80211->state == IEEE80211_LINKED) - LeisurePSLeave(priv->ieee80211); - - priv->ps_force = true; - pPSC->bLeisurePs = false; - ieee->ps = *extra; - } - -#endif - up(&priv->wx_sem); - return 0; - -} - - -static iw_handler r8192_wx_handlers[] = -{ - NULL, /* SIOCSIWCOMMIT */ - r8192_wx_get_name, /* SIOCGIWNAME */ - dummy, /* SIOCSIWNWID */ - dummy, /* SIOCGIWNWID */ - r8192_wx_set_freq, /* SIOCSIWFREQ */ - r8192_wx_get_freq, /* SIOCGIWFREQ */ - r8192_wx_set_mode, /* SIOCSIWMODE */ - r8192_wx_get_mode, /* SIOCGIWMODE */ - r8192_wx_set_sens, /* SIOCSIWSENS */ - r8192_wx_get_sens, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - rtl8180_wx_get_range, /* SIOCGIWRANGE */ - NULL, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - dummy, /* SIOCSIWSPY */ - dummy, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - r8192_wx_set_wap, /* SIOCSIWAP */ - r8192_wx_get_wap, /* SIOCGIWAP */ - r8192_wx_set_mlme, /* MLME-- */ - dummy, /* SIOCGIWAPLIST -- depricated */ - r8192_wx_set_scan, /* SIOCSIWSCAN */ - r8192_wx_get_scan, /* SIOCGIWSCAN */ - r8192_wx_set_essid, /* SIOCSIWESSID */ - r8192_wx_get_essid, /* SIOCGIWESSID */ - dummy, /* SIOCSIWNICKN */ - dummy, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - r8192_wx_set_rate, /* SIOCSIWRATE */ - r8192_wx_get_rate, /* SIOCGIWRATE */ - r8192_wx_set_rts, /* SIOCSIWRTS */ - r8192_wx_get_rts, /* SIOCGIWRTS */ - r8192_wx_set_frag, /* SIOCSIWFRAG */ - r8192_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ - r8192_wx_set_retry, /* SIOCSIWRETRY */ - r8192_wx_get_retry, /* SIOCGIWRETRY */ - r8192_wx_set_enc, /* SIOCSIWENCODE */ - r8192_wx_get_enc, /* SIOCGIWENCODE */ - r8192_wx_set_power, /* SIOCSIWPOWER */ - r8192_wx_get_power, /* SIOCGIWPOWER */ - NULL, /*---hole---*/ - NULL, /*---hole---*/ - r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */ - NULL, /* SIOCSIWGENIE */ - r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */ - NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */ - r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ - -}; - - -static const struct iw_priv_args r8192_private_args[] = { - - { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - - { - SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - - }, - { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" - } - , - { - SIOCIWFIRSTPRIV + 0x3, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" - - } - , - { - SIOCIWFIRSTPRIV + 0x4, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, - "set_power" - } - -}; - - -static iw_handler r8192_private_handler[] = { - r8192_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ - r8192_wx_set_scan_type, - r8192_wx_set_rawtx, - r8192_wx_force_reset, - r8192_wx_adapter_power_status, -}; - -static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; - struct iw_statistics* wstats = &priv->wstats; - int tmp_level = 0; - int tmp_qual = 0; - int tmp_noise = 0; - if(ieee->state < IEEE80211_LINKED) - { - wstats->qual.qual = 0; - wstats->qual.level = 0; - wstats->qual.noise = 0; - wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - return wstats; - } - - tmp_level = (&ieee->current_network)->stats.rssi; - tmp_qual = (&ieee->current_network)->stats.signal; - tmp_noise = (&ieee->current_network)->stats.noise; - //printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); - - wstats->qual.level = tmp_level; - wstats->qual.qual = tmp_qual; - wstats->qual.noise = tmp_noise; - wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - return wstats; -} - - -struct iw_handler_def r8192_wx_handlers_def={ - .standard = r8192_wx_handlers, - .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), - .private = r8192_private_handler, - .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), - .get_wireless_stats = r8192_get_wireless_stats, - .private_args = (struct iw_priv_args *)r8192_private_args, -}; diff --git a/drivers/staging/rtl8192e/r8192E_wx.h b/drivers/staging/rtl8192e/r8192E_wx.h deleted file mode 100644 index 25f06c165d4..00000000000 --- a/drivers/staging/rtl8192e/r8192E_wx.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - This is part of rtl8180 OpenSource driver - v 0.3 - Copyright (C) Andrea Merello 2004 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the official realtek driver - Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of such projects and the Ndiswrapper project Authors. -*/ - -/* this file (will) contains wireless extension handlers*/ - -#ifndef R8180_WX_H -#define R8180_WX_H -extern struct iw_handler_def r8192_wx_handlers_def; -#endif diff --git a/drivers/staging/rtl8192e/r8192_pm.c b/drivers/staging/rtl8192e/r8192_pm.c deleted file mode 100644 index 7bcc4a35099..00000000000 --- a/drivers/staging/rtl8192e/r8192_pm.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - Power management interface routines. - Written by Mariusz Matuszek. - This code is currently just a placeholder for later work and - does not do anything useful. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 - Released under the terms of GPL (General Public Licence) -*/ - -#include "r8192E.h" -#include "r8192E_hw.h" -#include "r8192_pm.h" -#include "r8190_rtl8256.h" - -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state) -{ - printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); - return -EAGAIN; -} - - -int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) -{ - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv = ieee80211_priv(dev); - u32 ulRegRead; - - RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); - if (!netif_running(dev)) - goto out_pci_suspend; - - if (dev->netdev_ops->ndo_stop) - dev->netdev_ops->ndo_stop(dev); - - // Call MgntActSet_RF_State instead to prevent RF config race condition. - if(!priv->ieee80211->bSupportRemoteWakeUp) { - MgntActSet_RF_State(priv, eRfOff, RF_CHANGE_BY_INIT); - // 2006.11.30. System reset bit - ulRegRead = read_nic_dword(priv, CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; - write_nic_dword(priv, CPU_GEN, ulRegRead); - } else { - //2008.06.03 for WOL - write_nic_dword(priv, WFCRC0, 0xffffffff); - write_nic_dword(priv, WFCRC1, 0xffffffff); - write_nic_dword(priv, WFCRC2, 0xffffffff); - //Write PMR register - write_nic_byte(priv, PMR, 0x5); - //Disable tx, enanble rx - write_nic_byte(priv, MacBlkCtrl, 0xa); - } - -out_pci_suspend: - RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); - if(priv->ieee80211->bSupportRemoteWakeUp) { - RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); - } - netif_device_detach(dev); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev,state), - priv->ieee80211->bSupportRemoteWakeUp?1:0); - pci_set_power_state(pdev,pci_choose_state(pdev,state)); - - return 0; -} - -int rtl8192E_resume (struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - int err; - u32 val; - - RT_TRACE(COMP_POWER, "================>r8192E resume call.\n"); - - pci_set_power_state(pdev, PCI_D0); - - err = pci_enable_device(pdev); - if(err) { - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", - dev->name); - return err; - } - - pci_restore_state(pdev); - - /* - * Suspend/Resume resets the PCI configuration space, so we have to - * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries - * from interfering with C3 CPU state. pci_restore_state won't help - * here since it only restores the first 64 bytes pci config header. - */ - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) { - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - } - - - - pci_enable_wake(pdev, PCI_D0, 0); - - if(!netif_running(dev)) - goto out; - - netif_device_attach(dev); - - if (dev->netdev_ops->ndo_open) - dev->netdev_ops->ndo_open(dev); - -out: - RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); - return 0; -} - - -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) -{ - printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", - state.event, enable); - return -EAGAIN; -} diff --git a/drivers/staging/rtl8192e/r8192_pm.h b/drivers/staging/rtl8192e/r8192_pm.h deleted file mode 100644 index 4da9b464b41..00000000000 --- a/drivers/staging/rtl8192e/r8192_pm.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - Power management interface routines. - Written by Mariusz Matuszek. - This code is currently just a placeholder for later work and - does not do anything useful. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 - Released under the terms of GPL (General Public Licence) - -*/ - -#ifndef R8192E_PM_H -#define R8192E_PM_H - -#include -#include - -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); -int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); -int rtl8192E_resume (struct pci_dev *dev); -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); - -#endif //R8192E_PM_H diff --git a/drivers/staging/rtl8192e/r819xE_cmdpkt.c b/drivers/staging/rtl8192e/r819xE_cmdpkt.c deleted file mode 100644 index 756e0660bbe..00000000000 --- a/drivers/staging/rtl8192e/r819xE_cmdpkt.c +++ /dev/null @@ -1,444 +0,0 @@ -/****************************************************************************** - - (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. - - Module: r819xusb_cmdpkt.c (RTL8190 TX/RX command packet handler Source C File) - - Note: The module is responsible for handling TX and RX command packet. - 1. TX : Send set and query configuration command packet. - 2. RX : Receive tx feedback, beacon state, query configuration - command packet. - - Function: - - Export: - - Abbrev: - - History: - Data Who Remark - - 05/06/2008 amy Create initial version porting from windows driver. - -******************************************************************************/ -#include "r8192E.h" -#include "r8192E_hw.h" -#include "r819xE_cmdpkt.h" - -/* - * Driver internal module can call the API to send message to - * firmware side. For example, you can send a debug command packet. - * Or you can send a request for FW to modify RLX4181 LBUS HW bank. - * Otherwise, you can change MAC/PHT/RF register by firmware at - * run time. We do not support message more than one segment now. - */ -RT_STATUS cmpk_message_handle_tx( - struct r8192_priv *priv, - u8* code_virtual_address, - u32 packettype, - u32 buffer_len) -{ - RT_STATUS rt_status = RT_STATUS_SUCCESS; - u16 frag_threshold; - u16 frag_length = 0, frag_offset = 0; - rt_firmware *pfirmware = priv->pFirmware; - struct sk_buff *skb; - unsigned char *seg_ptr; - cb_desc *tcb_desc; - u8 bLastIniPkt; - - PTX_FWINFO_8190PCI pTxFwInfo = NULL; - int i; - - RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__FUNCTION__,buffer_len); - firmware_init_param(priv); - //Fragmentation might be required - frag_threshold = pfirmware->cmdpacket_frag_thresold; - do { - if((buffer_len - frag_offset) > frag_threshold) { - frag_length = frag_threshold ; - bLastIniPkt = 0; - - } else { - frag_length =(u16)(buffer_len - frag_offset); - bLastIniPkt = 1; - - } - - /* Allocate skb buffer to contain firmware info and tx descriptor info - * add 4 to avoid packet appending overflow. - * */ - skb = dev_alloc_skb(frag_length + priv->ieee80211->tx_headroom + 4); - if(skb == NULL) { - rt_status = RT_STATUS_FAILURE; - goto Failed; - } - - tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->queue_index = TXCMD_QUEUE; - tcb_desc->bCmdOrInit = packettype; - tcb_desc->bLastIniPkt = bLastIniPkt; - tcb_desc->pkt_size = frag_length; - - //seg_ptr = skb_put(skb, frag_length + priv->ieee80211->tx_headroom); - seg_ptr = skb_put(skb, priv->ieee80211->tx_headroom); - - pTxFwInfo = (PTX_FWINFO_8190PCI)seg_ptr; - memset(pTxFwInfo,0,sizeof(TX_FWINFO_8190PCI)); - memset(pTxFwInfo,0x12,8); - - seg_ptr +=sizeof(TX_FWINFO_8190PCI); - - /* - * Transform from little endian to big endian - * and pending zero - */ - seg_ptr = skb_tail_pointer(skb); - for(i=0 ; i < frag_length; i+=4) { - *seg_ptr++ = ((i+0)ieee80211->softmac_hard_start_xmit(skb, priv->ieee80211); - - code_virtual_address += frag_length; - frag_offset += frag_length; - - }while(frag_offset < buffer_len); - -Failed: - return rt_status; -} - -static void cmpk_count_txstatistic(struct r8192_priv *priv, cmpk_txfb_t *pstx_fb) -{ -#ifdef ENABLE_PS - RT_RF_POWER_STATE rtState; - - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. - if (rtState == eRfOff) - { - return; - } -#endif - -#ifdef TODO - if(pAdapter->bInHctTest) - return; -#endif - /* We can not know the packet length and transmit type: broadcast or uni - or multicast. So the relative statistics must be collected in tx - feedback info. */ - if (pstx_fb->tok) - { - priv->stats.txoktotal++; - - /* We can not make sure broadcast/multicast or unicast mode. */ - if (pstx_fb->pkt_type != PACKET_MULTICAST && - pstx_fb->pkt_type != PACKET_BROADCAST) { - priv->stats.txbytesunicast += pstx_fb->pkt_length; - } - } -} - - - -/* - * The function is responsible for extract the message inside TX - * feedbck message from firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "TX Feedback Element". We have to read 20 bytes - * in the command packet. - */ -static void cmpk_handle_tx_feedback(struct r8192_priv *priv, u8 *pmsg) -{ - cmpk_txfb_t rx_tx_fb; /* */ - - priv->stats.txfeedback++; - - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); - /* Use tx feedback info to count TX statistics. */ - cmpk_count_txstatistic(priv, &rx_tx_fb); -} - - -/* - * The function is responsible for extract the message from - * firmware. It will contain dedicated info in - * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. - * Please refer to chapter "Interrupt Status Element". - */ -static void cmpk_handle_interrupt_status(struct r8192_priv *priv, u8 *pmsg) -{ - cmpk_intr_sta_t rx_intr_status; /* */ - - DMESG("---> cmpk_Handle_Interrupt_Status()\n"); - - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ - /* It seems that FW use big endian(MIPS) and DRV use little endian in - windows OS. So we have to read the content byte by byte or transfer - endian type before copy the message copy. */ - //rx_bcn_state.Element_ID = pMsg[0]; - //rx_bcn_state.Length = pMsg[1]; - rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) - { - DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); - return; - } - - - // Statistics of beacon for ad-hoc mode. - if( priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { - //2 maybe need endian transform? - rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - //rx_intr_status.InterruptStatus = N2H4BYTE(*((UINT32 *)(pMsg + 4))); - - DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); - - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { - priv->ieee80211->bibsscoordinator = true; - priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { - priv->ieee80211->bibsscoordinator = false; - priv->stats.txbeaconerr++; - } - } - - // Other informations in interrupt status we need? - - - DMESG("<---- cmpk_handle_interrupt_status()\n"); - -} - - -/* - * The function is responsible for extract the message from - * firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "Beacon State Element". - */ -static void cmpk_handle_query_config_rx(struct r8192_priv *priv, u8 *pmsg) -{ - cmpk_query_cfg_t rx_query_cfg; /* */ - - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg); - - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ - /* It seems that FW use big endian(MIPS) and DRV use little endian in - windows OS. So we have to read the content byte by byte or transfer - endian type before copy the message copy. */ - //rx_query_cfg.Element_ID = pMsg[0]; - //rx_query_cfg.Length = pMsg[1]; - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); - -} - - -/* - * Count aggregated tx status from firmwar of one type rx command - * packet element id = RX_TX_STATUS. - */ -static void cmpk_count_tx_status(struct r8192_priv *priv, cmpk_tx_status_t *pstx_status) -{ - -#ifdef ENABLE_PS - - RT_RF_POWER_STATE rtstate; - - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. - if (rtState == eRfOff) - { - return; - } -#endif - - priv->stats.txfeedbackok += pstx_status->txok; - priv->stats.txoktotal += pstx_status->txok; - - priv->stats.txbytesunicast += pstx_status->txuclength; -} - - - -/* - * Firmware add a new tx feedback status to reduce rx command - * packet buffer operation load. - */ -static void cmpk_handle_tx_status(struct r8192_priv *priv, u8 *pmsg) -{ - cmpk_tx_status_t rx_tx_sts; /* */ - - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(cmpk_tx_status_t)); - /* 2. Use tx feedback info to count TX statistics. */ - cmpk_count_tx_status(priv, &rx_tx_sts); - -} - - -/* Firmware add a new tx rate history */ -static void cmpk_handle_tx_rate_history(struct r8192_priv *priv, u8 *pmsg) -{ - u8 i; - u16 length = sizeof(cmpk_tx_rahis_t); - u32 *ptemp; - -#ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. - if (rtState == eRfOff) - { - return; - } -#endif - - ptemp = (u32 *)pmsg; - - // - // Do endian transfer to word alignment(16 bits) for windows system. - // You must do different endian transfer for linux and MAC OS - // - for (i = 0; i < (length/4); i++) - { - u16 temp1, temp2; - - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; - } -} - - -/* - * In the function, we will capture different RX command packet - * info. Every RX command packet element has different message - * length and meaning in content. We only support three type of RX - * command packet now. Please refer to document - * ws-06-0063-rtl8190-command-packet-specification. - */ -u32 cmpk_message_handle_rx(struct r8192_priv *priv, struct ieee80211_rx_stats *pstats) -{ -// u32 debug_level = DBG_LOUD; - int total_length; - u8 cmd_length, exe_cnt = 0; - u8 element_id; - u8 *pcmd_buff; - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx()\n"); - - /* 0. Check inpt arguments. If is is a command queue message or pointer is - null. */ - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) - { - /* Print error message. */ - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->Err queue id or pointer"));*/ - return 0; /* This is not a command packet. */ - } - - /* 1. Read received command packet message length from RFD. */ - total_length = pstats->Length; - - /* 2. Read virtual address from RFD. */ - pcmd_buff = pstats->virtual_address; - - /* 3. Read command pakcet element id and length. */ - element_id = pcmd_buff[0]; - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->element ID=%d Len=%d", element_id, total_length));*/ - - /* 4. Check every received command packet conent according to different - element type. Because FW may aggregate RX command packet to minimize - transmit time between DRV and FW.*/ - // Add a counter to prevent to locked in the loop too long - while (total_length > 0 || exe_cnt++ >100) - { - /* 2007/01/17 MH We support aggregation of different cmd in the same packet. */ - element_id = pcmd_buff[0]; - - switch(element_id) - { - case RX_TX_FEEDBACK: - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); - cmpk_handle_tx_feedback(priv, pcmd_buff); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_INTERRUPT_STATUS: - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); - cmpk_handle_interrupt_status(priv, pcmd_buff); - cmd_length = sizeof(cmpk_intr_sta_t); - break; - - case BOTH_QUERY_CONFIG: - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); - cmpk_handle_query_config_rx(priv, pcmd_buff); - cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; - break; - - case RX_TX_STATUS: - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); - cmpk_handle_tx_status(priv, pcmd_buff); - cmd_length = CMPK_RX_TX_STS_SIZE; - break; - - case RX_TX_PER_PKT_FEEDBACK: - // You must at lease add a switch case element here, - // Otherwise, we will jump to default case. - //DbgPrint("CCX Test\r\n"); - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_TX_RATE_HISTORY: - //DbgPrint(" rx tx rate history\r\n"); - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); - cmpk_handle_tx_rate_history(priv, pcmd_buff); - cmd_length = CMPK_TX_RAHIS_SIZE; - break; - - default: - - RT_TRACE(COMP_EVENTS, "---->cmpk_message_handle_rx():unknown CMD Element\n"); - return 1; /* This is a command packet. */ - } - - total_length -= cmd_length; - pcmd_buff += cmd_length; - } /* while (total_length > 0) */ - return 1; /* This is a command packet. */ - - RT_TRACE(COMP_EVENTS, "<----cmpk_message_handle_rx()\n"); -} diff --git a/drivers/staging/rtl8192e/r819xE_cmdpkt.h b/drivers/staging/rtl8192e/r819xE_cmdpkt.h deleted file mode 100644 index 312e4f84ded..00000000000 --- a/drivers/staging/rtl8192e/r819xE_cmdpkt.h +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef R819XUSB_CMDPKT_H -#define R819XUSB_CMDPKT_H -/* Different command packet have dedicated message length and definition. */ -#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) //20 -#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16 -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16 -#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t)// -#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t)// -#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) - -/* 2008/05/08 amy For USB constant. */ -#define ISR_TxBcnOk BIT27 // Transmit Beacon OK -#define ISR_TxBcnErr BIT26 // Transmit Beacon Error -#define ISR_BcnTimerIntr BIT13 // Beacon Timer Interrupt - -#if 0 -/* Define packet type. */ -typedef enum tag_packet_type -{ - PACKET_BROADCAST, - PACKET_MULTICAST, - PACKET_UNICAST, - PACKET_TYPE_MAX -}cmpk_pkt_type_e; -#endif - -/* Define element ID of command packet. */ - -/*------------------------------Define structure----------------------------*/ -/* Define different command packet structure. */ -/* 1. RX side: TX feedback packet. */ -typedef struct tag_cmd_pkt_tx_feedback -{ - // DWORD 0 - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - /* 2007/07/05 MH Change tx feedback info field. */ - /*------TX Feedback Info Field */ - u8 TID:4; /* */ - u8 fail_reason:3; /* */ - u8 tok:1; /* Transmit ok. */ - u8 reserve1:4; /* */ - u8 pkt_type:2; /* */ - u8 bandwidth:1; /* */ - u8 qos_pkt:1; /* */ - - // DWORD 1 - u8 reserve2; /* */ - /*------TX Feedback Info Field */ - u8 retry_cnt; /* */ - u16 pkt_id; /* */ - - // DWORD 3 - u16 seq_num; /* */ - u8 s_rate; /* Start rate. */ - u8 f_rate; /* Final rate. */ - - // DWORD 4 - u8 s_rts_rate; /* */ - u8 f_rts_rate; /* */ - u16 pkt_length; /* */ - - // DWORD 5 - u16 reserve3; /* */ - u16 duration; /* */ -}cmpk_txfb_t; - -/* 2. RX side: Interrupt status packet. It includes Beacon State, - Beacon Timer Interrupt and other useful informations in MAC ISR Reg. */ -typedef struct tag_cmd_pkt_interrupt_status -{ - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - u16 reserve; - u32 interrupt_status; /* Interrupt Status. */ -}cmpk_intr_sta_t; - - -/* 3. TX side: Set configuration packet. */ -typedef struct tag_cmd_pkt_set_configuration -{ - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - u16 reserve1; /* */ - u8 cfg_reserve1:3; - u8 cfg_size:2; /* Configuration info. */ - u8 cfg_type:2; /* Configuration info. */ - u8 cfg_action:1; /* Configuration info. */ - u8 cfg_reserve2; /* Configuration info. */ - u8 cfg_page:4; /* Configuration info. */ - u8 cfg_reserve3:4; /* Configuration info. */ - u8 cfg_offset; /* Configuration info. */ - u32 value; /* */ - u32 mask; /* */ -}cmpk_set_cfg_t; - -/* 4. Both side : TX/RX query configuraton packet. The query structure is the - same as set configuration. */ -#define cmpk_query_cfg_t cmpk_set_cfg_t - -/* 5. Multi packet feedback status. */ -typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007 -{ - // For endian transfer --> Driver will not the same as firmware structure. - // DW 0 - u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type - - // DW 1 - u16 txfail; // Tx Fail count - u16 txok; // Tx ok count - - // DW 2 - u16 txmcok; // tx multicast - u16 txretry; // Tx Retry count - - // DW 3 - u16 txucok; // tx unicast - u16 txbcok; // tx broadcast - - // DW 4 - u16 txbcfail; // - u16 txmcfail; // - - // DW 5 - u16 reserve2; // - u16 txucfail; // - - // DW 6-8 - u32 txmclength; - u32 txbclength; - u32 txuclength; - - // DW 9 - u16 reserve3_23; - u8 reserve3_1; - u8 rate; -}__attribute__((packed)) cmpk_tx_status_t; - -/* 6. Debug feedback message. */ -/* 2007/10/23 MH Define RX debug message */ -typedef struct tag_rx_debug_message_feedback -{ - // For endian transfer --> for driver - // DW 0 - u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type - - // DW 1-?? - // Variable debug message. - -}cmpk_rx_dbginfo_t; - -/* 2008/03/20 MH Define transmit rate history. For big endian format. */ -typedef struct tag_tx_rate_history -{ - // For endian transfer --> for driver - // DW 0 - u8 element_id; // Command packet type - u8 length; // Command packet length - u16 reserved1; - - // DW 1-2 CCK rate counter - u16 cck[4]; - - // DW 3-6 - u16 ofdm[8]; - - // DW 7-14 - //UINT16 MCS_BW0_SG0[16]; - - // DW 15-22 - //UINT16 MCS_BW1_SG0[16]; - - // DW 23-30 - //UINT16 MCS_BW0_SG1[16]; - - // DW 31-38 - //UINT16 MCS_BW1_SG1[16]; - - // DW 7-14 BW=0 SG=0 - // DW 15-22 BW=1 SG=0 - // DW 23-30 BW=0 SG=1 - // DW 31-38 BW=1 SG=1 - u16 ht_mcs[4][16]; - -}__attribute__((packed)) cmpk_tx_rahis_t; - -typedef enum tag_command_packet_directories -{ - RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, - RX_CMD_ELE_MAX -}cmpk_element_e; - -u32 cmpk_message_handle_rx(struct r8192_priv *priv, struct ieee80211_rx_stats *pstats); - - -#endif diff --git a/drivers/staging/rtl8192e/r819xE_firmware.c b/drivers/staging/rtl8192e/r819xE_firmware.c deleted file mode 100644 index d9e8b5a0890..00000000000 --- a/drivers/staging/rtl8192e/r819xE_firmware.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Procedure: Init boot code/firmware code/data session - * - * Description: This routine will initialize firmware. If any error occurs - * during the initialization process, the routine shall terminate - * immediately and return fail. - */ - -#include "r8192E.h" -#include "r8192E_hw.h" - -#include - -/* It should be double word alignment */ -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4 * (v / 4) - 8) - -enum firmware_init_step { - FW_INIT_STEP0_BOOT = 0, - FW_INIT_STEP1_MAIN = 1, - FW_INIT_STEP2_DATA = 2, -}; - -enum opt_rst_type { - OPT_SYSTEM_RESET = 0, - OPT_FIRMWARE_RESET = 1, -}; - -void firmware_init_param(struct r8192_priv *priv) -{ - rt_firmware *pfirmware = priv->pFirmware; - - pfirmware->cmdpacket_frag_thresold = - GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); -} - -/* - * segment the img and use the ptr and length to remember info on each segment - */ -static bool fw_download_code(struct r8192_priv *priv, u8 *code_virtual_address, - u32 buffer_len) -{ - bool rt_status = true; - u16 frag_threshold; - u16 frag_length, frag_offset = 0; - int i; - - rt_firmware *pfirmware = priv->pFirmware; - struct sk_buff *skb; - unsigned char *seg_ptr; - cb_desc *tcb_desc; - u8 bLastIniPkt; - - firmware_init_param(priv); - - /* Fragmentation might be required */ - frag_threshold = pfirmware->cmdpacket_frag_thresold; - do { - if ((buffer_len - frag_offset) > frag_threshold) { - frag_length = frag_threshold ; - bLastIniPkt = 0; - } else { - frag_length = buffer_len - frag_offset; - bLastIniPkt = 1; - } - - /* - * Allocate skb buffer to contain firmware info and tx - * descriptor info add 4 to avoid packet appending overflow. - */ - skb = dev_alloc_skb(frag_length + 4); - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->queue_index = TXCMD_QUEUE; - tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; - tcb_desc->bLastIniPkt = bLastIniPkt; - - seg_ptr = skb->data; - - /* - * Transform from little endian to big endian and pending zero - */ - for (i = 0; i < frag_length; i += 4) { - *seg_ptr++ = ((i+0) < frag_length) ? - code_virtual_address[i+3] : 0; - - *seg_ptr++ = ((i+1) < frag_length) ? - code_virtual_address[i+2] : 0; - - *seg_ptr++ = ((i+2) < frag_length) ? - code_virtual_address[i+1] : 0; - - *seg_ptr++ = ((i+3) < frag_length) ? - code_virtual_address[i+0] : 0; - } - tcb_desc->txbuf_size = (u16)i; - skb_put(skb, i); - priv->ieee80211->softmac_hard_start_xmit(skb, priv->ieee80211); - - code_virtual_address += frag_length; - frag_offset += frag_length; - - } while (frag_offset < buffer_len); - - return rt_status; -} - -/* - * Check whether main code is download OK. If OK, turn on CPU - * - * CPU register locates in different page against general - * register. Switch to CPU register in the begin and switch - * back before return - */ -static bool CPUcheck_maincodeok_turnonCPU(struct r8192_priv *priv) -{ - unsigned long timeout; - bool rt_status = true; - u32 CPU_status = 0; - - /* Check whether put code OK */ - timeout = jiffies + msecs_to_jiffies(20); - while (time_before(jiffies, timeout)) { - CPU_status = read_nic_dword(priv, CPU_GEN); - - if (CPU_status & CPU_GEN_PUT_CODE_OK) - break; - msleep(2); - } - - if (!(CPU_status & CPU_GEN_PUT_CODE_OK)) { - RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n"); - goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - } else { - RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n"); - } - - /* Turn On CPU */ - CPU_status = read_nic_dword(priv, CPU_GEN); - write_nic_byte(priv, CPU_GEN, - (u8)((CPU_status | CPU_GEN_PWR_STB_CPU) & 0xff)); - mdelay(1); - - /* Check whether CPU boot OK */ - timeout = jiffies + msecs_to_jiffies(20); - while (time_before(jiffies, timeout)) { - CPU_status = read_nic_dword(priv, CPU_GEN); - - if (CPU_status & CPU_GEN_BOOT_RDY) - break; - msleep(2); - } - - if (!(CPU_status & CPU_GEN_BOOT_RDY)) - goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - else - RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); - - return rt_status; - -CPUCheckMainCodeOKAndTurnOnCPU_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); - rt_status = FALSE; - return rt_status; -} - -static bool CPUcheck_firmware_ready(struct r8192_priv *priv) -{ - unsigned long timeout; - bool rt_status = true; - u32 CPU_status = 0; - - /* Check Firmware Ready */ - timeout = jiffies + msecs_to_jiffies(20); - while (time_before(jiffies, timeout)) { - CPU_status = read_nic_dword(priv, CPU_GEN); - - if (CPU_status & CPU_GEN_FIRM_RDY) - break; - msleep(2); - } - - if (!(CPU_status & CPU_GEN_FIRM_RDY)) - goto CPUCheckFirmwareReady_Fail; - else - RT_TRACE(COMP_FIRMWARE, "Download Firmware: Firmware ready!\n"); - - return rt_status; - -CPUCheckFirmwareReady_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); - rt_status = false; - return rt_status; - -} - -bool init_firmware(struct r8192_priv *priv) -{ - bool rt_status = true; - u32 file_length = 0; - u8 *mapped_file = NULL; - u32 init_step = 0; - enum opt_rst_type rst_opt = OPT_SYSTEM_RESET; - enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT; - - rt_firmware *pfirmware = priv->pFirmware; - const struct firmware *fw_entry; - const char *fw_name[3] = { "RTL8192E/boot.img", - "RTL8192E/main.img", - "RTL8192E/data.img"}; - int rc; - - RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); - - if (pfirmware->firmware_status == FW_STATUS_0_INIT) { - /* it is called by reset */ - rst_opt = OPT_SYSTEM_RESET; - starting_state = FW_INIT_STEP0_BOOT; - /* TODO: system reset */ - - } else if (pfirmware->firmware_status == FW_STATUS_5_READY) { - /* it is called by Initialize */ - rst_opt = OPT_FIRMWARE_RESET; - starting_state = FW_INIT_STEP2_DATA; - } else { - RT_TRACE(COMP_FIRMWARE, - "PlatformInitFirmware: undefined firmware state\n"); - } - - /* - * Download boot, main, and data image for System reset. - * Download data image for firmware reseta - */ - for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; - init_step++) { - /* - * Open Image file, and map file to contineous memory if open file success. - * or read image file from array. Default load from IMG file - */ - if (rst_opt == OPT_SYSTEM_RESET) { - if (pfirmware->firmware_buf_size[init_step] == 0) { - rc = request_firmware(&fw_entry, - fw_name[init_step], &priv->pdev->dev); - - if (rc < 0) { - RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); - goto download_firmware_fail; - } - - if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, - "img file size exceed the container buffer fail!\n"); - goto download_firmware_fail; - } - - if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step], - fw_entry->data, fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size; - - } else { - memset(pfirmware->firmware_buf[init_step], 0, 128); - memcpy(&pfirmware->firmware_buf[init_step][128], fw_entry->data, - fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size+128; - } - - if (rst_opt == OPT_SYSTEM_RESET) - release_firmware(fw_entry); - } - mapped_file = pfirmware->firmware_buf[init_step]; - file_length = pfirmware->firmware_buf_size[init_step]; - - } else if (rst_opt == OPT_FIRMWARE_RESET) { - /* we only need to download data.img here */ - mapped_file = pfirmware->firmware_buf[init_step]; - file_length = pfirmware->firmware_buf_size[init_step]; - } - - /* Download image file */ - /* The firmware download process is just as following, - * 1. that is each packet will be segmented and inserted to the - * wait queue. - * 2. each packet segment will be put in the skb_buff packet. - * 3. each skb_buff packet data content will already include - * the firmware info and Tx descriptor info - */ - rt_status = fw_download_code(priv, mapped_file, file_length); - if (rt_status != TRUE) - goto download_firmware_fail; - - switch (init_step) { - case FW_INIT_STEP0_BOOT: - /* Download boot - * initialize command descriptor. - * will set polling bit when firmware code is also - * configured - */ - pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE; - /* mdelay(1000); */ - /* - * To initialize IMEM, CPU move code from 0x80000080, - * hence, we send 0x80 byte packet - */ - break; - - case FW_INIT_STEP1_MAIN: - /* Download firmware code. - * Wait until Boot Ready and Turn on CPU */ - pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; - - /* Check Put Code OK and Turn On CPU */ - rt_status = CPUcheck_maincodeok_turnonCPU(priv); - if (rt_status != TRUE) { - RT_TRACE(COMP_FIRMWARE, - "CPUcheck_maincodeok_turnonCPU fail!\n"); - goto download_firmware_fail; - } - - pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; - break; - - case FW_INIT_STEP2_DATA: - /* download initial data code */ - pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE; - mdelay(1); - - rt_status = CPUcheck_firmware_ready(priv); - if (rt_status != TRUE) { - RT_TRACE(COMP_FIRMWARE, - "CPUcheck_firmware_ready fail(%d)!\n", - rt_status); - goto download_firmware_fail; - } - - /* wait until data code is initialized ready.*/ - pfirmware->firmware_status = FW_STATUS_5_READY; - break; - } - } - - RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n"); - return rt_status; - -download_firmware_fail: - RT_TRACE(COMP_ERR, "ERR in %s() step %d\n", __func__, init_step); - rt_status = false; - return rt_status; -} - -MODULE_FIRMWARE("RTL8192E/boot.img"); -MODULE_FIRMWARE("RTL8192E/main.img"); -MODULE_FIRMWARE("RTL8192E/data.img"); diff --git a/drivers/staging/rtl8192e/r819xE_phy.c b/drivers/staging/rtl8192e/r819xE_phy.c deleted file mode 100644 index 9e7828ef1cb..00000000000 --- a/drivers/staging/rtl8192e/r819xE_phy.c +++ /dev/null @@ -1,2225 +0,0 @@ -#include "r8192E.h" -#include "r8192E_hw.h" -#include "r819xE_phyreg.h" -#include "r8190_rtl8256.h" -#include "r819xE_phy.h" -#include "r8192E_dm.h" -#ifdef ENABLE_DOT11D -#include "ieee80211/dot11d.h" -#endif -static const u32 RF_CHANNEL_TABLE_ZEBRA[] = { - 0, - 0x085c, //2412 1 - 0x08dc, //2417 2 - 0x095c, //2422 3 - 0x09dc, //2427 4 - 0x0a5c, //2432 5 - 0x0adc, //2437 6 - 0x0b5c, //2442 7 - 0x0bdc, //2447 8 - 0x0c5c, //2452 9 - 0x0cdc, //2457 10 - 0x0d5c, //2462 11 - 0x0ddc, //2467 12 - 0x0e5c, //2472 13 - 0x0f72, //2484 -}; - -static u32 Rtl8192PciEMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000100, -}; -static u32 Rtl8192PciEMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0xe00,0xffffffff,0x06090909, -0xe04,0xffffffff,0x00030306, -0xe08,0x0000ff00,0x00000000, -0xe10,0xffffffff,0x0a0c0d0f, -0xe14,0xffffffff,0x06070809, -0xe18,0xffffffff,0x0a0c0d0f, -0xe1c,0xffffffff,0x06070809, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, -}; -static u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLength] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7d040001, -0xc78,0x7d050001, -0xc78,0x7c060001, -0xc78,0x7b070001, -0xc78,0x7a080001, -0xc78,0x79090001, -0xc78,0x780a0001, -0xc78,0x770b0001, -0xc78,0x760c0001, -0xc78,0x750d0001, -0xc78,0x740e0001, -0xc78,0x730f0001, -0xc78,0x72100001, -0xc78,0x71110001, -0xc78,0x70120001, -0xc78,0x6f130001, -0xc78,0x6e140001, -0xc78,0x6d150001, -0xc78,0x6c160001, -0xc78,0x6b170001, -0xc78,0x6a180001, -0xc78,0x69190001, -0xc78,0x681a0001, -0xc78,0x671b0001, -0xc78,0x661c0001, -0xc78,0x651d0001, -0xc78,0x641e0001, -0xc78,0x491f0001, -0xc78,0x48200001, -0xc78,0x47210001, -0xc78,0x46220001, -0xc78,0x45230001, -0xc78,0x44240001, -0xc78,0x43250001, -0xc78,0x28260001, -0xc78,0x27270001, -0xc78,0x26280001, -0xc78,0x25290001, -0xc78,0x242a0001, -0xc78,0x232b0001, -0xc78,0x222c0001, -0xc78,0x212d0001, -0xc78,0x202e0001, -0xc78,0x0a2f0001, -0xc78,0x08300001, -0xc78,0x06310001, -0xc78,0x05320001, -0xc78,0x04330001, -0xc78,0x03340001, -0xc78,0x02350001, -0xc78,0x01360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7d440001, -0xc78,0x7d450001, -0xc78,0x7c460001, -0xc78,0x7b470001, -0xc78,0x7a480001, -0xc78,0x79490001, -0xc78,0x784a0001, -0xc78,0x774b0001, -0xc78,0x764c0001, -0xc78,0x754d0001, -0xc78,0x744e0001, -0xc78,0x734f0001, -0xc78,0x72500001, -0xc78,0x71510001, -0xc78,0x70520001, -0xc78,0x6f530001, -0xc78,0x6e540001, -0xc78,0x6d550001, -0xc78,0x6c560001, -0xc78,0x6b570001, -0xc78,0x6a580001, -0xc78,0x69590001, -0xc78,0x685a0001, -0xc78,0x675b0001, -0xc78,0x665c0001, -0xc78,0x655d0001, -0xc78,0x645e0001, -0xc78,0x495f0001, -0xc78,0x48600001, -0xc78,0x47610001, -0xc78,0x46620001, -0xc78,0x45630001, -0xc78,0x44640001, -0xc78,0x43650001, -0xc78,0x28660001, -0xc78,0x27670001, -0xc78,0x26680001, -0xc78,0x25690001, -0xc78,0x246a0001, -0xc78,0x236b0001, -0xc78,0x226c0001, -0xc78,0x216d0001, -0xc78,0x206e0001, -0xc78,0x0a6f0001, -0xc78,0x08700001, -0xc78,0x06710001, -0xc78,0x05720001, -0xc78,0x04730001, -0xc78,0x03740001, -0xc78,0x02750001, -0xc78,0x01760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x2e00001e, -0xc78,0x2e01001e, -0xc78,0x2e02001e, -0xc78,0x2e03001e, -0xc78,0x2e04001e, -0xc78,0x2e05001e, -0xc78,0x3006001e, -0xc78,0x3407001e, -0xc78,0x3908001e, -0xc78,0x3c09001e, -0xc78,0x3f0a001e, -0xc78,0x420b001e, -0xc78,0x440c001e, -0xc78,0x450d001e, -0xc78,0x460e001e, -0xc78,0x460f001e, -0xc78,0x4710001e, -0xc78,0x4811001e, -0xc78,0x4912001e, -0xc78,0x4a13001e, -0xc78,0x4b14001e, -0xc78,0x4b15001e, -0xc78,0x4c16001e, -0xc78,0x4d17001e, -0xc78,0x4e18001e, -0xc78,0x4f19001e, -0xc78,0x4f1a001e, -0xc78,0x501b001e, -0xc78,0x511c001e, -0xc78,0x521d001e, -0xc78,0x521e001e, -0xc78,0x531f001e, -0xc78,0x5320001e, -0xc78,0x5421001e, -0xc78,0x5522001e, -0xc78,0x5523001e, -0xc78,0x5624001e, -0xc78,0x5725001e, -0xc78,0x5726001e, -0xc78,0x5827001e, -0xc78,0x5828001e, -0xc78,0x5929001e, -0xc78,0x592a001e, -0xc78,0x5a2b001e, -0xc78,0x5b2c001e, -0xc78,0x5c2d001e, -0xc78,0x5c2e001e, -0xc78,0x5d2f001e, -0xc78,0x5e30001e, -0xc78,0x5f31001e, -0xc78,0x6032001e, -0xc78,0x6033001e, -0xc78,0x6134001e, -0xc78,0x6235001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6438001e, -0xc78,0x6539001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x673c001e, -0xc78,0x683d001e, -0xc78,0x693e001e, -0xc78,0x6a3f001e, -}; -static u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLength] = { -0x0, }; -static u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLength] = { -0x800,0x00000000, -0x804,0x00000001, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x008514d0, -0x818,0x00000040, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x6870e36c, -0x884,0xe3573600, -0x888,0x4260c340, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x31121311, -0xa00,0x00d0c7d8, -0xa04,0x811f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x00005433, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08800000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x465c52cd, -0xc38,0x497f5994, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x20000000, -0xc88,0x40000100, -0xc8c,0x20200000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000750, -0xd04,0x00000403, -0xd08,0x0000907f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x04032064, -0xe00,0x161a1a1a, -0xe04,0x12121416, -0xe08,0x00001800, -0xe0c,0x00000000, -0xe10,0x161a1a1a, -0xe14,0x12121416, -0xe18,0x161a1a1a, -0xe1c,0x12121416, -}; -static u32 Rtl8192PciERadioA_Array[RadioA_ArrayLength] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000100, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; -static u32 Rtl8192PciERadioB_Array[RadioB_ArrayLength] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000100, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, -}; -static u32 Rtl8192PciERadioC_Array[RadioC_ArrayLength] = { -0x0, }; -static u32 Rtl8192PciERadioD_Array[RadioD_ArrayLength] = { -0x0, }; - -/*************************Define local function prototype**********************/ - -static u32 phy_FwRFSerialRead(struct r8192_priv *priv, RF90_RADIO_PATH_E eRFPath, u32 Offset); -static void phy_FwRFSerialWrite(struct r8192_priv *priv, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data); - -/*************************Define local function prototype**********************/ -/****************************************************************************** - *function: This function read BB parameters from Header file we gen, - * and do register read/write - * input: u32 dwBitMask //taget bit pos in the addr to be modified - * output: none - * return: u32 return the shift bit bit position of the mask - * ****************************************************************************/ -static u32 rtl8192_CalculateBitShift(u32 dwBitMask) -{ - u32 i; - for (i=0; i<=31; i++) - { - if (((dwBitMask>>i)&0x1) == 1) - break; - } - return i; -} -/****************************************************************************** - *function: This function check different RF type to execute legal judgement. If RF Path is illegal, we will return false. - * input: none - * output: none - * return: 0(illegal, false), 1(legal,true) - * ***************************************************************************/ -u8 rtl8192_phy_CheckIsLegalRFPath(struct r8192_priv *priv, u32 eRFPath) -{ - u8 ret = 1; - - if (priv->rf_type == RF_2T4R) - ret = 0; - else if (priv->rf_type == RF_1T2R) - { - if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) - ret = 1; - else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) - ret = 0; - } - - return ret; -} -/****************************************************************************** - *function: This function set specific bits to BB register - * input: net_device dev - * u32 dwRegAddr //target addr to be modified - * u32 dwBitMask //taget bit pos in the addr to be modified - * u32 dwData //value to be write - * output: none - * return: none - * notice: - * ****************************************************************************/ -void rtl8192_setBBreg(struct r8192_priv *priv, u32 dwRegAddr, u32 dwBitMask, u32 dwData) -{ - u32 OriginalValue, BitShift, NewValue; - - if(dwBitMask!= bMaskDWord) - {//if not "double word" write - OriginalValue = read_nic_dword(priv, dwRegAddr); - BitShift = rtl8192_CalculateBitShift(dwBitMask); - NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift)); - write_nic_dword(priv, dwRegAddr, NewValue); - }else - write_nic_dword(priv, dwRegAddr, dwData); -} -/****************************************************************************** - *function: This function reads specific bits from BB register - * input: net_device dev - * u32 dwRegAddr //target addr to be readback - * u32 dwBitMask //taget bit pos in the addr to be readback - * output: none - * return: u32 Data //the readback register value - * notice: - * ****************************************************************************/ -u32 rtl8192_QueryBBReg(struct r8192_priv *priv, u32 dwRegAddr, u32 dwBitMask) -{ - u32 OriginalValue, BitShift; - - OriginalValue = read_nic_dword(priv, dwRegAddr); - BitShift = rtl8192_CalculateBitShift(dwBitMask); - return (OriginalValue & dwBitMask) >> BitShift; -} -/****************************************************************************** - *function: This function read register from RF chip - * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D - * u32 Offset //target address to be read - * output: none - * return: u32 readback value - * notice: There are three types of serial operations:(1) Software serial write.(2)Hardware LSSI-Low Speed Serial Interface.(3)Hardware HSSI-High speed serial write. Driver here need to implement (1) and (2)---need more spec for this information. - * ****************************************************************************/ -static u32 rtl8192_phy_RFSerialRead(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 Offset) -{ - u32 ret = 0; - u32 NewOffset = 0; - BB_REGISTER_DEFINITION_T* pPhyReg = &priv->PHYRegDef[eRFPath]; - //rtl8192_setBBreg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData, 0); - //make sure RF register offset is correct - Offset &= 0x3f; - - //switch page for 8256 RF IC - //analog to digital off, for protection - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0xf00, 0x0);// 0x88c[11:8] - if (Offset >= 31) - { - priv->RfReg0Value[eRFPath] |= 0x140; - //Switch to Reg_Mode2 for Reg 31-45 - rtl8192_setBBreg(priv, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); - //modify offset - NewOffset = Offset -30; - } - else if (Offset >= 16) - { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); - //Switch to Reg_Mode 1 for Reg16-30 - rtl8192_setBBreg(priv, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); - - NewOffset = Offset - 15; - } - else - NewOffset = Offset; - - //put desired read addr to LSSI control Register - rtl8192_setBBreg(priv, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset); - //Issue a posedge trigger - // - rtl8192_setBBreg(priv, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0); - rtl8192_setBBreg(priv, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1); - - - // TODO: we should not delay such a long time. Ask help from SD3 - msleep(1); - - ret = rtl8192_QueryBBReg(priv, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); - - - // Switch back to Reg_Mode0; - priv->RfReg0Value[eRFPath] &= 0xebf; - - rtl8192_setBBreg( - priv, - pPhyReg->rf3wireOffset, - bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); - - //analog to digital on - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x3);// 0x88c[9:8] - - return ret; -} - -/****************************************************************************** - *function: This function write data to RF register - * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D - * u32 Offset //target address to be written - * u32 Data //The new register data to be written - * output: none - * return: none - * notice: For RF8256 only. - =========================================================== - *Reg Mode RegCTL[1] RegCTL[0] Note - * (Reg00[12]) (Reg00[10]) - *=========================================================== - *Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf) - *------------------------------------------------------------------ - *Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf) - *------------------------------------------------------------------ - * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf) - *------------------------------------------------------------------ - * ****************************************************************************/ -static void rtl8192_phy_RFSerialWrite(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 Offset, - u32 Data) -{ - u32 DataAndAddr = 0, NewOffset = 0; - BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; - - Offset &= 0x3f; - - //analog to digital off, for protection - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0xf00, 0x0);// 0x88c[11:8] - - if (Offset >= 31) - { - priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(priv, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); - NewOffset = Offset - 30; - } - else if (Offset >= 16) - { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(priv, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16)); - NewOffset = Offset - 15; - } - else - NewOffset = Offset; - - // Put write addr in [5:0] and write data in [31:16] - DataAndAddr = (Data<<16) | (NewOffset&0x3f); - - // Write Operation - rtl8192_setBBreg(priv, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); - - - if(Offset==0x0) - priv->RfReg0Value[eRFPath] = Data; - - // Switch back to Reg_Mode0; - if(Offset != 0) - { - priv->RfReg0Value[eRFPath] &= 0xebf; - rtl8192_setBBreg( - priv, - pPhyReg->rf3wireOffset, - bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); - } - //analog to digital on - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter4, 0x300, 0x3);// 0x88c[9:8] -} - -/****************************************************************************** - *function: This function set specific bits to RF register - * input: RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D - * u32 RegAddr //target addr to be modified - * u32 BitMask //taget bit pos in the addr to be modified - * u32 Data //value to be write - * output: none - * return: none - * notice: - * ****************************************************************************/ -void rtl8192_phy_SetRFReg(struct r8192_priv *priv, RF90_RADIO_PATH_E eRFPath, - u32 RegAddr, u32 BitMask, u32 Data) -{ - u32 Original_Value, BitShift, New_Value; -// u8 time = 0; - - if (!rtl8192_phy_CheckIsLegalRFPath(priv, eRFPath)) - return; - if (priv->eRFPowerState != eRfOn && !priv->being_init_adapter) - return; - //down(&priv->rf_sem); - - RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); - if (priv->Rf_Mode == RF_OP_By_FW) - { - if (BitMask != bMask12Bits) // RF data is 12 bits only - { - Original_Value = phy_FwRFSerialRead(priv, eRFPath, RegAddr); - BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); - - phy_FwRFSerialWrite(priv, eRFPath, RegAddr, New_Value); - }else - phy_FwRFSerialWrite(priv, eRFPath, RegAddr, Data); - udelay(200); - - } - else - { - if (BitMask != bMask12Bits) // RF data is 12 bits only - { - Original_Value = rtl8192_phy_RFSerialRead(priv, eRFPath, RegAddr); - BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); - - rtl8192_phy_RFSerialWrite(priv, eRFPath, RegAddr, New_Value); - }else - rtl8192_phy_RFSerialWrite(priv, eRFPath, RegAddr, Data); - } - //up(&priv->rf_sem); -} - -/****************************************************************************** - *function: This function reads specific bits from RF register - * input: net_device dev - * u32 RegAddr //target addr to be readback - * u32 BitMask //taget bit pos in the addr to be readback - * output: none - * return: u32 Data //the readback register value - * notice: - * ****************************************************************************/ -u32 rtl8192_phy_QueryRFReg(struct r8192_priv *priv, RF90_RADIO_PATH_E eRFPath, - u32 RegAddr, u32 BitMask) -{ - u32 Original_Value, Readback_Value, BitShift; - - if (!rtl8192_phy_CheckIsLegalRFPath(priv, eRFPath)) - return 0; - if (priv->eRFPowerState != eRfOn && !priv->being_init_adapter) - return 0; - down(&priv->rf_sem); - if (priv->Rf_Mode == RF_OP_By_FW) - { - Original_Value = phy_FwRFSerialRead(priv, eRFPath, RegAddr); - udelay(200); - } - else - { - Original_Value = rtl8192_phy_RFSerialRead(priv, eRFPath, RegAddr); - - } - BitShift = rtl8192_CalculateBitShift(BitMask); - Readback_Value = (Original_Value & BitMask) >> BitShift; - up(&priv->rf_sem); -// udelay(200); - return Readback_Value; -} - -/****************************************************************************** - *function: We support firmware to execute RF-R/W. - * input: dev - * output: none - * return: none - * notice: - * ***************************************************************************/ -static u32 phy_FwRFSerialRead(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 Offset) -{ - u32 Data = 0; - u8 time = 0; - //DbgPrint("FW RF CTRL\n\r"); - /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can - not execute the scheme in the initial step. Otherwise, RF-R/W will waste - much time. This is only for site survey. */ - // 1. Read operation need not insert data. bit 0-11 - //Data &= bMask12Bits; - // 2. Write RF register address. Bit 12-19 - Data |= ((Offset&0xFF)<<12); - // 3. Write RF path. bit 20-21 - Data |= ((eRFPath&0x3)<<20); - // 4. Set RF read indicator. bit 22=0 - //Data |= 0x00000; - // 5. Trigger Fw to operate the command. bit 31 - Data |= 0x80000000; - // 6. We can not execute read operation if bit 31 is 1. - while (read_nic_dword(priv, QPNR)&0x80000000) - { - // If FW can not finish RF-R/W for more than ?? times. We must reset FW. - if (time++ < 100) - { - //DbgPrint("FW not finish RF-R Time=%d\n\r", time); - udelay(10); - } - else - break; - } - // 7. Execute read operation. - write_nic_dword(priv, QPNR, Data); - // 8. Check if firmawre send back RF content. - while (read_nic_dword(priv, QPNR)&0x80000000) - { - // If FW can not finish RF-R/W for more than ?? times. We must reset FW. - if (time++ < 100) - { - //DbgPrint("FW not finish RF-W Time=%d\n\r", time); - udelay(10); - } - else - return 0; - } - return read_nic_dword(priv, RF_DATA); -} - -/****************************************************************************** - *function: We support firmware to execute RF-R/W. - * input: dev - * output: none - * return: none - * notice: - * ***************************************************************************/ -static void phy_FwRFSerialWrite(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data) -{ - u8 time = 0; - - //DbgPrint("N FW RF CTRL RF-%d OF%02x DATA=%03x\n\r", eRFPath, Offset, Data); - /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can - not execute the scheme in the initial step. Otherwise, RF-R/W will waste - much time. This is only for site survey. */ - - // 1. Set driver write bit and 12 bit data. bit 0-11 - //Data &= bMask12Bits; // Done by uper layer. - // 2. Write RF register address. bit 12-19 - Data |= ((Offset&0xFF)<<12); - // 3. Write RF path. bit 20-21 - Data |= ((eRFPath&0x3)<<20); - // 4. Set RF write indicator. bit 22=1 - Data |= 0x400000; - // 5. Trigger Fw to operate the command. bit 31=1 - Data |= 0x80000000; - - // 6. Write operation. We can not write if bit 31 is 1. - while (read_nic_dword(priv, QPNR)&0x80000000) - { - // If FW can not finish RF-R/W for more than ?? times. We must reset FW. - if (time++ < 100) - { - //DbgPrint("FW not finish RF-W Time=%d\n\r", time); - udelay(10); - } - else - break; - } - // 7. No matter check bit. We always force the write. Because FW will - // not accept the command. - write_nic_dword(priv, QPNR, Data); - /* 2007/11/02 MH Acoording to test, we must delay 20us to wait firmware - to finish RF write operation. */ - /* 2008/01/17 MH We support delay in firmware side now. */ - //delay_us(20); - -} - - -/****************************************************************************** - *function: This function read BB parameters from Header file we gen, - * and do register read/write - * input: dev - * output: none - * return: none - * notice: BB parameters may change all the time, so please make - * sure it has been synced with the newest. - * ***************************************************************************/ -void rtl8192_phy_configmac(struct r8192_priv *priv) -{ - u32 dwArrayLen = 0, i = 0; - u32* pdwArray = NULL; -#ifdef TO_DO_LIST -if(Adapter->bInHctTest) - { - RT_TRACE(COMP_PHY, "Rtl819XMACPHY_ArrayDTM\n"); - dwArrayLen = MACPHY_ArrayLengthDTM; - pdwArray = Rtl819XMACPHY_ArrayDTM; - } - else if(priv->bTXPowerDataReadFromEEPORM) -#endif - if(priv->bTXPowerDataReadFromEEPORM) - { - RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); - dwArrayLen = MACPHY_Array_PGLength; - pdwArray = Rtl819XMACPHY_Array_PG; - - } - else - { - RT_TRACE(COMP_PHY,"Read rtl819XMACPHY_Array\n"); - dwArrayLen = MACPHY_ArrayLength; - pdwArray = Rtl819XMACPHY_Array; - } - for(i = 0; ibInHctTest) - { - AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM; - Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM; - - if(priv->RF_Type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLengthDTM; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArrayDTM; - } - else if (priv->RF_Type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLengthDTM; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArrayDTM; - } - } - else -#endif - { - AGCTAB_ArrayLen = AGCTAB_ArrayLength; - Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; - if(priv->rf_type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; - } - else if (priv->rf_type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; - } - } - - if (ConfigType == BaseBand_Config_PHY_REG) - { - for (i=0; iPHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870 - priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) - priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 LSBs if read 32-bit from 0x874 - priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876) - - // RF Interface Readback Value - priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; // 16 LSBs if read 32-bit from 0x8E0 - priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2) - priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 LSBs if read 32-bit from 0x8E4 - priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6) - - // RF Interface Output (and Enable) - priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x860 - priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x864 - priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x868 - priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x86C - - // RF Interface (Output and) Enable - priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) - priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) - priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86A (16-bit for 0x86A) - priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86C (16-bit for 0x86E) - - //Addr of LSSI. Wirte RF register by driver - priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter - priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; - priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter; - priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter; - - // RF parameter - priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; //BB Band Select - priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; - priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; - priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; - - // Tx AGC Gain Stage (same for all path. Should we remove this?) - priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage - priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage - priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage - priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage - - // Tranceiver A~D HSSI Parameter-1 - priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; //wire control parameter1 - priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; //wire control parameter1 - priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; //wire control parameter1 - priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; //wire control parameter1 - - // Tranceiver A~D HSSI Parameter-2 - priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; //wire control parameter2 - priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; //wire control parameter2 - priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; //wire control parameter2 - priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; //wire control parameter1 - - // RF switch Control - priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; //TR/Ant switch control - priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; - priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; - priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; - - // AGC control 1 - priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; - priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; - priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; - priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; - - // AGC control 2 - priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; - priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; - priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; - priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; - - // RX AFE control 1 - priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; - priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; - priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; - priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; - - // RX AFE control 1 - priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE; - priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; - priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; - priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; - - // Tx AFE control 1 - priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; - priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; - priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; - priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; - - // Tx AFE control 2 - priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE; - priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; - priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; - priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; - - // Tranceiver LSSI Readback - priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; - -} -/****************************************************************************** - *function: This function is to write register and then readback to make sure whether BB and RF is OK - * input: net_device dev - * HW90_BLOCK_E CheckBlock - * RF90_RADIO_PATH_E eRFPath //only used when checkblock is HW90_BLOCK_RF - * output: none - * return: return whether BB and RF is ok(0:OK; 1:Fail) - * notice: This function may be removed in the ASIC - * ***************************************************************************/ -RT_STATUS rtl8192_phy_checkBBAndRF(struct r8192_priv *priv, - HW90_BLOCK_E CheckBlock, - RF90_RADIO_PATH_E eRFPath) -{ -// BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; - RT_STATUS ret = RT_STATUS_SUCCESS; - u32 i, CheckTimes = 4, dwRegRead = 0; - u32 WriteAddr[4]; - u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f}; - // Initialize register address offset to be checked - WriteAddr[HW90_BLOCK_MAC] = 0x100; - WriteAddr[HW90_BLOCK_PHY0] = 0x900; - WriteAddr[HW90_BLOCK_PHY1] = 0x800; - WriteAddr[HW90_BLOCK_RF] = 0x3; - RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __FUNCTION__, CheckBlock); - for(i=0 ; i < CheckTimes ; i++) - { - - // - // Write Data to register and readback - // - switch(CheckBlock) - { - case HW90_BLOCK_MAC: - RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!\n"); - break; - - case HW90_BLOCK_PHY0: - case HW90_BLOCK_PHY1: - write_nic_dword(priv, WriteAddr[CheckBlock], WriteData[i]); - dwRegRead = read_nic_dword(priv, WriteAddr[CheckBlock]); - break; - - case HW90_BLOCK_RF: - WriteData[i] &= 0xfff; - rtl8192_phy_SetRFReg(priv, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); - // TODO: we should not delay for such a long time. Ask SD3 - mdelay(10); - dwRegRead = rtl8192_phy_QueryRFReg(priv, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord); - mdelay(10); - break; - - default: - ret = RT_STATUS_FAILURE; - break; - } - - - // - // Check whether readback data is correct - // - if(dwRegRead != WriteData[i]) - { - RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, WriteData: %x\n", dwRegRead, WriteData[i]); - ret = RT_STATUS_FAILURE; - break; - } - } - - return ret; -} - - -/****************************************************************************** - *function: This function initialize BB&RF - * input: net_device dev - * output: none - * return: none - * notice: Initialization value may change all the time, so please make - * sure it has been synced with the newest. - * ***************************************************************************/ -static RT_STATUS rtl8192_BB_Config_ParaFile(struct r8192_priv *priv) -{ - RT_STATUS rtStatus = RT_STATUS_SUCCESS; - - u8 bRegValue = 0, eCheckItem = 0; - u32 dwRegValue = 0; - /************************************** - //<1>Initialize BaseBand - **************************************/ - - /*--set BB Global Reset--*/ - bRegValue = read_nic_byte(priv, BB_GLOBAL_RESET); - write_nic_byte(priv, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT)); - - /*---set BB reset Active---*/ - dwRegValue = read_nic_dword(priv, CPU_GEN); - write_nic_dword(priv, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); - - /*----Ckeck FPGAPHY0 and PHY1 board is OK----*/ - // TODO: this function should be removed on ASIC , Emily 2007.2.2 - for(eCheckItem=(HW90_BLOCK_E)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) - { - rtStatus = rtl8192_phy_checkBBAndRF(priv, (HW90_BLOCK_E)eCheckItem, (RF90_RADIO_PATH_E)0); //don't care RF path - if(rtStatus != RT_STATUS_SUCCESS) - { - RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); - return rtStatus; - } - } - /*---- Set CCK and OFDM Block "OFF"----*/ - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bCCKEn|bOFDMEn, 0x0); - /*----BB Register Initilazation----*/ - //==m==>Set PHY REG From Header<==m== - rtl8192_phyConfigBB(priv, BaseBand_Config_PHY_REG); - - /*----Set BB reset de-Active----*/ - dwRegValue = read_nic_dword(priv, CPU_GEN); - write_nic_dword(priv, CPU_GEN, (dwRegValue|CPU_GEN_BB_RST)); - - /*----BB AGC table Initialization----*/ - //==m==>Set PHY REG From Header<==m== - rtl8192_phyConfigBB(priv, BaseBand_Config_AGC_TAB); - - if (priv->card_8192_version > VERSION_8190_BD) - { - if(priv->rf_type == RF_2T4R) - { - // Antenna gain offset from B/C/D to A - dwRegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); - } - else - dwRegValue = 0x0; //Antenna gain offset doesn't make sense in RF 1T2R. - rtl8192_setBBreg(priv, rFPGA0_TxGainStage, - (bXBTxAGC|bXCTxAGC|bXDTxAGC), dwRegValue); - - - //XSTALLCap - dwRegValue = priv->CrystalCap; - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); - } - - // Check if the CCK HighPower is turned ON. - // This is used to calculate PWDB. -// priv->bCckHighPower = (u8)(rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter2, 0x200)); - return rtStatus; -} -/****************************************************************************** - *function: This function initialize BB&RF - * input: net_device dev - * output: none - * return: none - * notice: Initialization value may change all the time, so please make - * sure it has been synced with the newest. - * ***************************************************************************/ -RT_STATUS rtl8192_BBConfig(struct r8192_priv *priv) -{ - rtl8192_InitBBRFRegDef(priv); - //config BB&RF. As hardCode based initialization has not been well - //implemented, so use file first.FIXME:should implement it for hardcode? - return rtl8192_BB_Config_ParaFile(priv); -} - -/****************************************************************************** - *function: This function obtains the initialization value of Tx power Level offset - * input: net_device dev - * output: none - * return: none - * ***************************************************************************/ -void rtl8192_phy_getTxPower(struct r8192_priv *priv) -{ - priv->MCSTxPowerLevelOriginalOffset[0] = - read_nic_dword(priv, rTxAGC_Rate18_06); - priv->MCSTxPowerLevelOriginalOffset[1] = - read_nic_dword(priv, rTxAGC_Rate54_24); - priv->MCSTxPowerLevelOriginalOffset[2] = - read_nic_dword(priv, rTxAGC_Mcs03_Mcs00); - priv->MCSTxPowerLevelOriginalOffset[3] = - read_nic_dword(priv, rTxAGC_Mcs07_Mcs04); - priv->MCSTxPowerLevelOriginalOffset[4] = - read_nic_dword(priv, rTxAGC_Mcs11_Mcs08); - priv->MCSTxPowerLevelOriginalOffset[5] = - read_nic_dword(priv, rTxAGC_Mcs15_Mcs12); - - // read rx initial gain - priv->DefaultInitialGain[0] = read_nic_byte(priv, rOFDM0_XAAGCCore1); - priv->DefaultInitialGain[1] = read_nic_byte(priv, rOFDM0_XBAGCCore1); - priv->DefaultInitialGain[2] = read_nic_byte(priv, rOFDM0_XCAGCCore1); - priv->DefaultInitialGain[3] = read_nic_byte(priv, rOFDM0_XDAGCCore1); - RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", - priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], - priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); - - // read framesync - priv->framesync = read_nic_byte(priv, rOFDM0_RxDetector3); - priv->framesyncC34 = read_nic_dword(priv, rOFDM0_RxDetector2); - RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n", - rOFDM0_RxDetector3, priv->framesync); - // read SIFS (save the value read fome MACPHY_REG.txt) - priv->SifsTime = read_nic_word(priv, SIFS); -} - -/****************************************************************************** - *function: This function obtains the initialization value of Tx power Level offset - * input: net_device dev - * output: none - * return: none - * ***************************************************************************/ -void rtl8192_phy_setTxPower(struct r8192_priv *priv, u8 channel) -{ - u8 powerlevel = 0,powerlevelOFDM24G = 0; - char ant_pwr_diff; - u32 u4RegValue; - - if(priv->epromtype == EPROM_93c46) - { - powerlevel = priv->TxPowerLevelCCK[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - } - else if(priv->epromtype == EPROM_93c56) - { - if(priv->rf_type == RF_1T2R) - { - powerlevel = priv->TxPowerLevelCCK_C[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; - } - else if(priv->rf_type == RF_2T4R) - { - // Mainly we use RF-A Tx Power to write the Tx Power registers, but the RF-C Tx - // Power must be calculated by the antenna diff. - // So we have to rewrite Antenna gain offset register here. - powerlevel = priv->TxPowerLevelCCK_A[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; - - ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] - -priv->TxPowerLevelOFDM24G_A[channel-1]; - ant_pwr_diff &= 0xf; - - priv->AntennaTxPwDiff[2] = 0;// RF-D, don't care - priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);// RF-C - priv->AntennaTxPwDiff[0] = 0;// RF-B, don't care - - // Antenna gain offset from B/C/D to A - u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); - - rtl8192_setBBreg(priv, rFPGA0_TxGainStage, - (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); - } - } -#ifdef TODO - // - // CCX 2 S31, AP control of client transmit power: - // 1. We shall not exceed Cell Power Limit as possible as we can. - // 2. Tolerance is +/- 5dB. - // 3. 802.11h Power Contraint takes higher precedence over CCX Cell Power Limit. - // - // TODO: - // 1. 802.11h power contraint - // - // 071011, by rcnjko. - // - if( pMgntInfo->OpMode == RT_OP_MODE_INFRASTRUCTURE && - pMgntInfo->bWithCcxCellPwr && - channel == pMgntInfo->dot11CurrentChannelNumber) - { - u8 CckCellPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, pMgntInfo->CcxCellPwr); - u8 LegacyOfdmCellPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_G, pMgntInfo->CcxCellPwr); - u8 OfdmCellPwrIdx = DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, pMgntInfo->CcxCellPwr); - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("CCX Cell Limit: %d dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - pMgntInfo->CcxCellPwr, CckCellPwrIdx, LegacyOfdmCellPwrIdx, OfdmCellPwrIdx)); - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n", - channel, powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - - // CCK - if(powerlevel > CckCellPwrIdx) - powerlevel = CckCellPwrIdx; - // Legacy OFDM, HT OFDM - if(powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff > OfdmCellPwrIdx) - { - if((OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff) > 0) - { - powerlevelOFDM24G = OfdmCellPwrIdx - pHalData->LegacyHTTxPowerDiff; - } - else - { - LegacyOfdmCellPwrIdx = 0; - } - } - - RT_TRACE(COMP_TXAGC, DBG_LOUD, - ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n", - powerlevel, powerlevelOFDM24G + pHalData->LegacyHTTxPowerDiff, powerlevelOFDM24G)); - } - - pHalData->CurrentCckTxPwrIdx = powerlevel; - pHalData->CurrentOfdm24GTxPwrIdx = powerlevelOFDM24G; -#endif - PHY_SetRF8256CCKTxPower(priv, powerlevel); //need further implement - PHY_SetRF8256OFDMTxPower(priv, powerlevelOFDM24G); -} - -/****************************************************************************** - *function: This function check Rf chip to do RF config - * input: net_device dev - * output: none - * return: only 8256 is supported - * ***************************************************************************/ -RT_STATUS rtl8192_phy_RFConfig(struct r8192_priv *priv) -{ - return PHY_RF8256_Config(priv); -} - -/****************************************************************************** - *function: This function update Initial gain - * input: net_device dev - * output: none - * return: As Windows has not implemented this, wait for complement - * ***************************************************************************/ -void rtl8192_phy_updateInitGain(struct r8192_priv *priv) -{ -} - -/****************************************************************************** - *function: This function read RF parameters from general head file, and do RF 3-wire - * input: net_device dev - * output: none - * return: return code show if RF configuration is successful(0:pass, 1:fail) - * Note: Delay may be required for RF configuration - * ***************************************************************************/ -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath) -{ - - int i; - //u32* pRFArray; - u8 ret = 0; - - switch(eRFPath){ - case RF90_PATH_A: - for(i = 0;iTxPowerLevelCCK[channel-1]; - u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - - PHY_SetRF8256CCKTxPower(priv, powerlevel); - PHY_SetRF8256OFDMTxPower(priv, powerlevelOFDM24G); -} - -/**************************************************************************************** - *function: This function set command table variable(struct SwChnlCmd). - * input: SwChnlCmd* CmdTable //table to be set. - * u32 CmdTableIdx //variable index in table to be set - * u32 CmdTableSz //table size. - * SwChnlCmdID CmdID //command ID to set. - * u32 Para1 - * u32 Para2 - * u32 msDelay - * output: - * return: true if finished, false otherwise - * Note: - * ************************************************************************************/ -static u8 rtl8192_phy_SetSwChnlCmdArray( - SwChnlCmd* CmdTable, - u32 CmdTableIdx, - u32 CmdTableSz, - SwChnlCmdID CmdID, - u32 Para1, - u32 Para2, - u32 msDelay - ) -{ - SwChnlCmd* pCmd; - - if(CmdTable == NULL) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); - return false; - } - if(CmdTableIdx >= CmdTableSz) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", - CmdTableIdx, CmdTableSz); - return false; - } - - pCmd = CmdTable + CmdTableIdx; - pCmd->CmdID = CmdID; - pCmd->Para1 = Para1; - pCmd->Para2 = Para2; - pCmd->msDelay = msDelay; - - return true; -} -/****************************************************************************** - *function: This function set channel step by step - * input: struct net_device *dev - * u8 channel - * u8* stage //3 stages - * u8* step // - * u32* delay //whether need to delay - * output: store new stage, step and delay for next step(combine with function above) - * return: true if finished, false otherwise - * Note: Wait for simpler function to replace it //wb - * ***************************************************************************/ -static u8 rtl8192_phy_SwChnlStepByStep(struct r8192_priv *priv, u8 channel, - u8* stage, u8* step, u32* delay) -{ -// PCHANNEL_ACCESS_SETTING pChnlAccessSetting; - SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; - u32 PreCommonCmdCnt; - SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; - u32 PostCommonCmdCnt; - SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; - u32 RfDependCmdCnt; - SwChnlCmd *CurrentCmd = NULL; - //RF90_RADIO_PATH_E eRFPath; - u8 eRFPath; -// u32 RfRetVal; -// u8 RetryCnt; - - RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __FUNCTION__, *stage, *step, channel); -// RT_ASSERT(IsLegalChannel(Adapter, channel), ("illegal channel: %d\n", channel)); - -#ifdef ENABLE_DOT11D - if (!IsLegalChannel(priv->ieee80211, channel)) - { - RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); - return true; //return true to tell upper caller function this channel setting is finished! Or it will in while loop. - } -#endif - - //for(eRFPath = RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) - //for(eRFPath = 0; eRFPath Fill up pre common command. - PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_End, 0, 0, 0); - - // <2> Fill up post common command. - PostCommonCmdCnt = 0; - - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, - CmdID_End, 0, 0, 0); - - // <3> Fill up RF dependent command. - RfDependCmdCnt = 0; - - // TEST!! This is not the table for 8256!! - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel); - return false; - } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_End, 0, 0, 0); - - do{ - switch(*stage) - { - case 0: - CurrentCmd=&PreCommonCmd[*step]; - break; - case 1: - CurrentCmd=&RfDependCmd[*step]; - break; - case 2: - CurrentCmd=&PostCommonCmd[*step]; - break; - } - - if(CurrentCmd->CmdID==CmdID_End) - { - if((*stage)==2) - { - return true; - } - else - { - (*stage)++; - (*step)=0; - continue; - } - } - - switch(CurrentCmd->CmdID) - { - case CmdID_SetTxPowerLevel: - if(priv->card_8192_version > (u8)VERSION_8190_BD) //xiong: consider it later! - rtl8192_SetTxPowerLevel(priv, channel); - break; - case CmdID_WritePortUlong: - write_nic_dword(priv, CurrentCmd->Para1, CurrentCmd->Para2); - break; - case CmdID_WritePortUshort: - write_nic_word(priv, CurrentCmd->Para1, (u16)CurrentCmd->Para2); - break; - case CmdID_WritePortUchar: - write_nic_byte(priv, CurrentCmd->Para1, (u8)CurrentCmd->Para2); - break; - case CmdID_RF_WriteReg: - for(eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - rtl8192_phy_SetRFReg(priv, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); - break; - default: - break; - } - - break; - }while(true); - }/*for(Number of RF paths)*/ - - (*delay)=CurrentCmd->msDelay; - (*step)++; - return false; -} - -/****************************************************************************** - *function: This function does acturally set channel work - * input: struct net_device *dev - * u8 channel - * output: none - * return: noin - * Note: We should not call this function directly - * ***************************************************************************/ -static void rtl8192_phy_FinishSwChnlNow(struct r8192_priv *priv, u8 channel) -{ - u32 delay = 0; - - while (!rtl8192_phy_SwChnlStepByStep(priv, channel, &priv->SwChnlStage, &priv->SwChnlStep, &delay)) - { - if(delay>0) - msleep(delay);//or mdelay? need further consideration - if(!priv->up) - break; - } -} -/****************************************************************************** - *function: Callback routine of the work item for switch channel. - * input: - * - * output: none - * return: noin - * ***************************************************************************/ -void rtl8192_SwChnl_WorkItem(struct r8192_priv *priv) -{ - RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); - - RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __FUNCTION__, priv->chan, priv); - - rtl8192_phy_FinishSwChnlNow(priv, priv->chan); - - RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); -} - -/****************************************************************************** - *function: This function scheduled actural workitem to set channel - * input: net_device dev - * u8 channel //channel to set - * output: none - * return: return code show if workitem is scheduled(1:pass, 0:fail) - * Note: Delay may be required for RF configuration - * ***************************************************************************/ -u8 rtl8192_phy_SwChnl(struct ieee80211_device *ieee80211, u8 channel) -{ - struct r8192_priv *priv = ieee80211_priv(ieee80211->dev); - - RT_TRACE(COMP_PHY, "=====>%s()\n", __FUNCTION__); - if(!priv->up) - return false; - if(priv->SwChnlInProgress) - return false; - -// if(pHalData->SetBWModeInProgress) -// return; - - //-------------------------------------------- - switch(priv->ieee80211->mode) - { - case WIRELESS_MODE_A: - case WIRELESS_MODE_N_5G: - if (channel<=14){ - RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14\n"); - return false; - } - break; - case WIRELESS_MODE_B: - if (channel>14){ - RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14\n"); - return false; - } - break; - case WIRELESS_MODE_G: - case WIRELESS_MODE_N_24G: - if (channel>14){ - RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14\n"); - return false; - } - break; - } - //-------------------------------------------- - - priv->SwChnlInProgress = true; - if(channel == 0) - channel = 1; - - priv->chan=channel; - - priv->SwChnlStage=0; - priv->SwChnlStep=0; - if (priv->up) - rtl8192_SwChnl_WorkItem(priv); - - priv->SwChnlInProgress = false; - return true; -} - -static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct r8192_priv *priv) -{ - switch(priv->CurrentChannelBW) - { - /* 20 MHz channel*/ - case HT_CHANNEL_WIDTH_20: - //added by vivi, cck,tx power track, 20080703 - priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; - - if(priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if(priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if(priv->ieee80211->current_network.channel== 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = TRUE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = FALSE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - break; - - /* 40 MHz channel*/ - case HT_CHANNEL_WIDTH_20_40: - //added by vivi, cck,tx power track, 20080703 - priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - - RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - if(priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if(priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = TRUE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = FALSE; - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); - break; - } -} - -static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct r8192_priv *priv) -{ - if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) - priv->bcck_in_ch14 = TRUE; - else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) - priv->bcck_in_ch14 = FALSE; - - //write to default index and tx power track will be done in dm. - switch(priv->CurrentChannelBW) - { - /* 20 MHz channel*/ - case HT_CHANNEL_WIDTH_20: - if(priv->Record_CCK_20Mindex == 0) - priv->Record_CCK_20Mindex = 6; //set default value. - priv->CCK_index = priv->Record_CCK_20Mindex;//6; - RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n", priv->CCK_index); - break; - - /* 40 MHz channel*/ - case HT_CHANNEL_WIDTH_20_40: - priv->CCK_index = priv->Record_CCK_40Mindex;//0; - RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n", priv->CCK_index); - break; - } - dm_cck_txpower_adjust(priv, priv->bcck_in_ch14); -} - -static void CCK_Tx_Power_Track_BW_Switch(struct r8192_priv *priv) -{ - - //if(pHalData->bDcut == TRUE) - if(priv->IC_Cut >= IC_VersionCut_D) - CCK_Tx_Power_Track_BW_Switch_TSSI(priv); - else - CCK_Tx_Power_Track_BW_Switch_ThermalMeter(priv); -} - - -// -/****************************************************************************** - *function: Callback routine of the work item for set bandwidth mode. - * input: struct net_device *dev - * HT_CHANNEL_WIDTH Bandwidth //20M or 40M - * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care - * output: none - * return: none - * Note: I doubt whether SetBWModeInProgress flag is necessary as we can - * test whether current work in the queue or not.//do I? - * ***************************************************************************/ -void rtl8192_SetBWModeWorkItem(struct r8192_priv *priv) -{ - u8 regBwOpMode; - - RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz") - - - if(!priv->up) - { - priv->SetBWModeInProgress= false; - return; - } - //<1>Set MAC register - regBwOpMode = read_nic_byte(priv, BW_OPMODE); - - switch(priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - // 2007/02/07 Mark by Emily because we have not verify whether this register works - write_nic_byte(priv, BW_OPMODE, regBwOpMode); - break; - - case HT_CHANNEL_WIDTH_20_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - // 2007/02/07 Mark by Emily because we have not verify whether this register works - write_nic_byte(priv, BW_OPMODE, regBwOpMode); - break; - - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW); - break; - } - - //<2>Set PHY related register - switch(priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - // Add by Vivi 20071119 - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bRFMOD, 0x0); - rtl8192_setBBreg(priv, rFPGA1_RFMOD, bRFMOD, 0x0); -// rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); - - // Correct the tx power for CCK rate in 20M. Suggest by YN, 20071207 -// write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); -// write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); -// write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); - if(!priv->btxpower_tracking) - { - write_nic_dword(priv, rCCK0_TxFilter1, 0x1a1b0000); - write_nic_dword(priv, rCCK0_TxFilter2, 0x090e1317); - write_nic_dword(priv, rCCK0_DebugPort, 0x00000204); - } - else - CCK_Tx_Power_Track_BW_Switch(priv); - - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x00100000, 1); - break; - case HT_CHANNEL_WIDTH_20_40: - // Add by Vivi 20071119 - rtl8192_setBBreg(priv, rFPGA0_RFMOD, bRFMOD, 0x1); - rtl8192_setBBreg(priv, rFPGA1_RFMOD, bRFMOD, 0x1); - //rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - //rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); - //rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); - - // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207 - //write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); - //write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); - //write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); - if(!priv->btxpower_tracking) - { - write_nic_dword(priv, rCCK0_TxFilter1, 0x35360000); - write_nic_dword(priv, rCCK0_TxFilter2, 0x121c252e); - write_nic_dword(priv, rCCK0_DebugPort, 0x00000409); - } - else - CCK_Tx_Power_Track_BW_Switch(priv); - - // Set Control channel to upper or lower. These settings are required only for 40MHz - rtl8192_setBBreg(priv, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - rtl8192_setBBreg(priv, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); - - - rtl8192_setBBreg(priv, rFPGA0_AnalogParameter1, 0x00100000, 0); - break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); - break; - - } - //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 - - //<3>Set RF related register - PHY_SetRF8256Bandwidth(priv, priv->CurrentChannelBW); - - atomic_dec(&(priv->ieee80211->atm_swbw)); - priv->SetBWModeInProgress= false; - - RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()\n"); -} - -/****************************************************************************** - *function: This function schedules bandwidth switch work. - * input: struct net_device *dev - * HT_CHANNEL_WIDTH Bandwidth //20M or 40M - * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care - * output: none - * return: none - * Note: I doubt whether SetBWModeInProgress flag is necessary as we can - * test whether current work in the queue or not.//do I? - * ***************************************************************************/ -void rtl8192_SetBWMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) -{ - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - - - if(priv->SetBWModeInProgress) - return; - - atomic_inc(&(priv->ieee80211->atm_swbw)); - priv->SetBWModeInProgress= true; - - priv->CurrentChannelBW = Bandwidth; - - if(Offset==HT_EXTCHNL_OFFSET_LOWER) - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if(Offset==HT_EXTCHNL_OFFSET_UPPER) - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; - else - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - //queue_work(priv->priv_wq, &(priv->SetBWModeWorkItem)); - // schedule_work(&(priv->SetBWModeWorkItem)); - rtl8192_SetBWModeWorkItem(priv); - -} - - -void InitialGain819xPci(struct ieee80211_device *ieee, u8 Operation) -{ -#define SCAN_RX_INITIAL_GAIN 0x17 -#define POWER_DETECTION_TH 0x08 - struct r8192_priv *priv = ieee80211_priv(ieee->dev); - u32 BitMask; - u8 initial_gain; - - if(priv->up) - { - switch(Operation) - { - case IG_Backup: - RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n"); - initial_gain = SCAN_RX_INITIAL_GAIN;//pHalData->DefaultInitialGain[0];// - BitMask = bMaskByte0; - if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8); // FW DIG OFF - priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(priv, rOFDM0_XAAGCCore1, BitMask); - priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(priv, rOFDM0_XBAGCCore1, BitMask); - priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(priv, rOFDM0_XCAGCCore1, BitMask); - priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(priv, rOFDM0_XDAGCCore1, BitMask); - BitMask = bMaskByte2; - priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(priv, rCCK0_CCA, BitMask); - - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); - - RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain); - write_nic_byte(priv, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(priv, rOFDM0_XDAGCCore1, initial_gain); - RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH); - write_nic_byte(priv, 0xa0a, POWER_DETECTION_TH); - break; - case IG_Restore: - RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n"); - BitMask = 0x7f; //Bit0~ Bit6 - if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8); // FW DIG OFF - - rtl8192_setBBreg(priv, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1); - rtl8192_setBBreg(priv, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1); - rtl8192_setBBreg(priv, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1); - rtl8192_setBBreg(priv, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1); - BitMask = bMaskByte2; - rtl8192_setBBreg(priv, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); - - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); - - rtl8192_phy_setTxPower(priv, priv->ieee80211->current_network.channel); - - - if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x1); // FW DIG ON - break; - default: - RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n"); - break; - } - } -} - diff --git a/drivers/staging/rtl8192e/r819xE_phy.h b/drivers/staging/rtl8192e/r819xE_phy.h deleted file mode 100644 index 496e76fbadb..00000000000 --- a/drivers/staging/rtl8192e/r819xE_phy.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef _R819XU_PHY_H -#define _R819XU_PHY_H - -/* Channel switch: the size of command tables for switch channel */ -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - -#define MACPHY_Array_PGLength 30 -#define Rtl819XMACPHY_Array_PG Rtl8192PciEMACPHY_Array_PG -#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array -#define RadioC_ArrayLength 1 -#define RadioD_ArrayLength 1 -#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array -#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array -#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array -#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array -#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array -#define PHY_REGArrayLength 1 -#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray -#define PHY_REG_1T2RArrayLength 296 -#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray - -#define AGCTAB_ArrayLength 384 -#define MACPHY_ArrayLength 18 - -#define RadioA_ArrayLength 246 -#define RadioB_ArrayLength 78 - - -typedef enum _SwChnlCmdID { - CmdID_End, - CmdID_SetTxPowerLevel, - CmdID_BBRegWrite10, - CmdID_WritePortUlong, - CmdID_WritePortUshort, - CmdID_WritePortUchar, - CmdID_RF_WriteReg, -} SwChnlCmdID; - -/* switch channel data structure */ -typedef struct _SwChnlCmd { - SwChnlCmdID CmdID; - u32 Para1; - u32 Para2; - u32 msDelay; -} __attribute__ ((packed)) SwChnlCmd; - -extern u32 rtl819XMACPHY_Array_PG[]; -extern u32 rtl819XPHY_REG_1T2RArray[]; -extern u32 rtl819XAGCTAB_Array[]; -extern u32 rtl819XRadioA_Array[]; -extern u32 rtl819XRadioB_Array[]; -extern u32 rtl819XRadioC_Array[]; -extern u32 rtl819XRadioD_Array[]; - -typedef enum _HW90_BLOCK { - HW90_BLOCK_MAC = 0, - HW90_BLOCK_PHY0 = 1, - HW90_BLOCK_PHY1 = 2, - HW90_BLOCK_RF = 3, - /* Don't ever use this. */ - HW90_BLOCK_MAXIMUM = 4, -} HW90_BLOCK_E, *PHW90_BLOCK_E; - -typedef enum _RF90_RADIO_PATH { - /* Radio paths */ - RF90_PATH_A = 0, - RF90_PATH_B = 1, - RF90_PATH_C = 2, - RF90_PATH_D = 3, - - /* Max RF number 92 support */ - RF90_PATH_MAX -} RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; - -#define bMaskByte0 0xff -#define bMaskByte1 0xff00 -#define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 -#define bMaskHWord 0xffff0000 -#define bMaskLWord 0x0000ffff -#define bMaskDWord 0xffffffff - -u8 rtl8192_phy_CheckIsLegalRFPath(struct r8192_priv *priv, u32 eRFPath); - -void rtl8192_setBBreg(struct r8192_priv *priv, u32 dwRegAddr, - u32 dwBitMask, u32 dwData); - -u32 rtl8192_QueryBBReg(struct r8192_priv *priv, u32 dwRegAddr, - u32 dwBitMask); - -void rtl8192_phy_SetRFReg(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 RegAddr, - u32 BitMask, u32 Data); - -u32 rtl8192_phy_QueryRFReg(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask); - -void rtl8192_phy_configmac(struct r8192_priv *priv); - -void rtl8192_phyConfigBB(struct r8192_priv *priv, u8 ConfigType); - -RT_STATUS rtl8192_phy_checkBBAndRF(struct r8192_priv *priv, - HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); - -RT_STATUS rtl8192_BBConfig(struct r8192_priv *priv); - -void rtl8192_phy_getTxPower(struct r8192_priv *priv); - -void rtl8192_phy_setTxPower(struct r8192_priv *priv, u8 channel); - -RT_STATUS rtl8192_phy_RFConfig(struct r8192_priv *priv); - -void rtl8192_phy_updateInitGain(struct r8192_priv *priv); - -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct r8192_priv *priv, - RF90_RADIO_PATH_E eRFPath); - -u8 rtl8192_phy_SwChnl(struct ieee80211_device *ieee80211, u8 channel); - -void rtl8192_SetBWMode(struct ieee80211_device *ieee80211, - HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); - -void rtl8192_SwChnl_WorkItem(struct r8192_priv *priv); - -void rtl8192_SetBWModeWorkItem(struct r8192_priv *priv); - -void InitialGain819xPci(struct ieee80211_device *ieee, u8 Operation); - -#endif /* _R819XU_PHY_H */ diff --git a/drivers/staging/rtl8192e/readme b/drivers/staging/rtl8192e/readme deleted file mode 100644 index 10a66f56560..00000000000 --- a/drivers/staging/rtl8192e/readme +++ /dev/null @@ -1,160 +0,0 @@ -What this layer should do - -- It mantain the old mechanism as alternative, so the - ipw2100 driver works with really few changes. -- Encapsulate / Decapsulate rtllib packet -- Handle fragmentation -- Optionally provide an alterantive mechanism for netif queue stop/wake, - so that the rtllib layer will pass one fragment per time instead of - one txb struct per time. so the driver can stop the queue in the middle - of a packet. -- Provide two different TX interfaces for cards that can handle management - frames on one HW queue, and data on another, and for cards that have only - one HW queue (the latter untested and very, very rough). -- Optionally provide the logic for handling IBSS/MASTER/MONITOR/BSS modes - and for the channel, essid and wap get/set wireless extension requests. - so that the driver has only to change channel when the ieee stack tell it. -- Optionally provide a scanning mechanism so that the driver has not to - worry about this, just implement the set channel calback and pass - frames to the upper layer -- Optionally provide the bss client protocol handshaking (just with open - authentication) -- Optionally provide the probe request send mechanism -- Optionally provide the bss master mode logic to handle association - protocol (only open authentication) and probe responses. -- SW wep encryption (with open authentication) -- It collects some stats -- It provides beacons to the card when it ask for them - -What this layer doesn't do (yet) -- Perform shared authentication -- Have full support for master mode (the AP should loop back in the air - frames from an associated client to another. This could be done easily - with few lines of code, and it is done in my previous version of the - stach, but a table of association must be keept and a disassociation - policy must be decided and implemented. -- Handle cleanly the full ieee 802.11 protocol. In AP mode it never - disassociate clients, and it is really prone to always allow access. - In bss client mode it is a bit rough with AP deauth and disassoc requests. -- It has not any entry point to view the collected stats. -- Altought it takes care of the card supported rates in the management frame - it sends, support for rate changing on TXed packet is not complete. -- Give up once associated in bss client mode (it never detect a - signal loss condition to disassociate and restart scanning) -- Provide a mechanism for enabling the TX in monitor mode, so - userspace programs can TX raw packets. -- Provide a mechanism for cards that need that the SW take care of beacon - TX completely, in sense that the SW has to enqueue by itself beacons - to the card so it TX them (if any...) -APIs - -Callback functions in the original stack has been mantained. -following has been added (from rtllib.h) - - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that - * one might want to use for data and management frames - * the option to have two callbacks might be useful. - * This fucntion can't sleep. - */ - int (*softmac_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev); - - /* used instead of hard_start_xmit (not softmac_hard_start_xmit) - * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data - * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set - * then also management frames are sent via this callback. - * This function can't sleep. - */ - void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev); - - /* stops the HW queue for DATA frames. Useful to avoid - * waste time to TX data frame when we are reassociating - * This function can sleep. - */ - void (*data_hard_stop)(struct net_device *dev); - - /* OK this is complementar to data_poll_hard_stop */ - void (*data_hard_resume)(struct net_device *dev); - - /* ask to the driver to retune the radio . - * This function can sleep. the driver should ensure - * the radio has been swithced before return. - */ - void (*set_chan)(struct net_device *dev,short ch); - - /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). - * In this case only the set_chan is used. - * - * The syncro version is similar to the start_scan but - * does not return until all channels has been scanned. - * this is called in user context and should sleep, - * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. - * the fucntion stop_scan should stop both the syncro and - * background scanning and can sleep. - * The fucntion start_scan should initiate the background - * scanning and can't sleep. - */ - void (*scan_syncro)(struct net_device *dev); - void (*start_scan)(struct net_device *dev); - void (*stop_scan)(struct net_device *dev); - - /* indicate the driver that the link state is changed - * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led - */ - void (*link_change)(struct net_device *dev); - -Functions hard_data_[resume/stop] are optional and should not be used -if the driver decides to uses data+management frames enqueue in a -single HQ queue (thus using just the softmac_hard_data_start_xmit -callback). - -Function that the driver can use are: - -rtllib_get_beacon - this is called by the driver when - the HW needs a beacon. -rtllib_softmac_start_protocol - this should normally be called in the - driver open function -rtllib_softmac_stop_protocol - the opposite of the above -rtllib_wake_queue - this is similar to netif_wake_queue -rtllib_reset_queue - this throw away fragments pending(if any) -rtllib_stop_queue - this is similar to netif_stop_queue - - -known BUGS: -- When performing syncro scan (possiblily when swithcing to ad-hoc mode - and when running iwlist scan when associated) there is still an odd - behaviour.. I have not looked in this more accurately (yet). - -locking: -locking is done by means of three structures. -1- ieee->lock (by means of spin_[un]lock_irq[save/restore] -2- ieee->wx_sem -3- ieee->scan_sem - -the lock 1 is what protect most of the critical sections in the ieee stack. -the lock 2 is used to avoid that more than one of the SET wireless extension -handlers (as well as start/stop protocol function) are running at the same time. -the lock 1 is used when we need to modify or read the shared data in the wx handlers. -In other words the lock 2 will prevent one SET action will run across another SET -action (by make sleep the 2nd one) but allow GET actions, while the lock 1 -make atomic those little shared data access in both GET and SET operation. -So get operation will be never be delayed really: they will never sleep.. -Furthermore in the top of some SET operations a flag is set before acquiring -the lock. This is an help to make the previous running SET operation to -finish faster if needed (just in case the second one will totally undo the -first, so there is not need to complete the 1st really.. ). -The background scanning mechaninsm is protected by the lock 1 except for the -workqueue. this wq is here just to let the set_chan callback sleep (I thinked it -might be appreciated by USB network card driver developer). In this case the lock 3 -take its turn. -Thus the stop function needs both the locks. -Funny in the syncro scan the lock 2 play its role (as both the syncro_scan -function and the stop scan function are called with this semaphore held). From 1800925f87040ce26ad0eb178b198bcbf3964f6e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 22 Jul 2011 14:30:37 -0500 Subject: [PATCH 0517/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part I Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 68 ++++---- drivers/staging/rtl8192e/r8190P_rtl8256.c | 186 ++++++++++++-------- drivers/staging/rtl8192e/r8190P_rtl8256.h | 11 +- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 196 +++++++++------------- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 45 ++--- drivers/staging/rtl8192e/r8192E_dev.c | 20 +-- 6 files changed, 276 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 2355766bb32..b7bb71fa9ec 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -39,7 +39,7 @@ enum rtl819x_loopback { #define RESET_DELAY_8185 20 -#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) +#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) #define DESC90_RATE1M 0x00 #define DESC90_RATE2M 0x01 @@ -85,7 +85,7 @@ enum rtl819x_loopback { #define BT_QA_BOARD 1 #define BT_FPGA 2 -#define Rx_Smooth_Factor 20 +#define RX_SMOOTH 20 #define QSLT_BK 0x1 #define QSLT_BE 0x0 @@ -130,7 +130,7 @@ enum rtl819x_loopback { enum version_8190_loopback { - VERSION_8190_BD=0x3, + VERSION_8190_BD = 0x3, VERSION_8190_BE }; @@ -139,9 +139,9 @@ enum version_8190_loopback { #define IC_VersionCut_E 0x4 enum rf_optype { - RF_OP_By_SW_3wire = 0, - RF_OP_By_FW, - RF_OP_MAX + RF_OP_By_SW_3wire = 0, + RF_OP_By_FW, + RF_OP_MAX }; @@ -303,41 +303,41 @@ struct phy_sts_cck_819xpci { #define PHY_Beacon_RSSI_SLID_WIN_MAX 10 struct tx_desc { - u16 PktSize; - u8 Offset; - u8 Reserved1:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; + u16 PktSize; + u8 Offset; + u8 Reserved1:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; - u8 TxFWInfoSize; - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Resv:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; + u8 TxFWInfoSize; + u8 RATid:3; + u8 DISFB:1; + u8 USERATE:1; + u8 MOREFRAG:1; + u8 NoEnc:1; + u8 PIFS:1; + u8 QueueSelect:5; + u8 NoACM:1; + u8 Resv:2; + u8 SecCAMID:5; + u8 SecDescAssign:1; + u8 SecType:2; - u16 TxBufferSize; - u8 PktId:7; - u8 Resv1:1; - u8 Reserved2; + u16 TxBufferSize; + u8 PktId:7; + u8 Resv1:1; + u8 Reserved2; u32 TxBuffAddr; u32 NextDescAddress; - u32 Reserved5; - u32 Reserved6; - u32 Reserved7; + u32 Reserved5; + u32 Reserved6; + u32 Reserved7; }; diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index e8bef59a798..0da56c80f08 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -22,41 +22,59 @@ #include "r8192E_phy.h" #include "r8190P_rtl8256.h" -void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth) +void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth) { u8 eRFPath; struct r8192_priv *priv = rtllib_priv(dev); - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = 0; eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: - if (priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x100); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3d7); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x021); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x100); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3d7); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x021); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; case HT_CHANNEL_WIDTH_20_40: - if (priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x300); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3ff); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x0e1); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x300); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3ff); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x0e1); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; default: - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown " + "Bandwidth: %#X\n", Bandwidth); break; } @@ -64,7 +82,7 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandw return; } -bool PHY_RF8256_Config(struct net_device* dev) +bool PHY_RF8256_Config(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -74,7 +92,7 @@ bool PHY_RF8256_Config(struct net_device* dev) return rtStatus; } -bool phy_RF8256_Config_ParaFile(struct net_device* dev) +bool phy_RF8256_Config_ParaFile(struct net_device *dev) { u32 u4RegValue = 0; u8 eRFPath; @@ -87,7 +105,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; - for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; + eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; @@ -97,11 +116,13 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV<<16); break; } @@ -109,14 +130,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireAddressLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireDataLength, 0x0); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, + bMask12Bits, 0xbf); - rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path)eRFPath); - if (rtStatus!= true) { - RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); + rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, + (enum rf90_radio_path)eRFPath); + if (rtStatus != true) { + RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check " + "Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -124,34 +150,61 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) RF3_Final_Value = 0; switch (eRFPath) { case RF90_PATH_A: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; @@ -160,16 +213,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, + u4RegValue); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, + u4RegValue); break; } if (ret) { - RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); + RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():" + "Radio[%d] Fail!!", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -183,18 +239,17 @@ phy_RF8256_Config_ParaFile_Fail: return false; } -void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel) { - u32 TxAGC=0; + u32 TxAGC = 0; struct r8192_priv *priv = rtllib_priv(dev); TxAGC = powerlevel; - if (priv->bDynamicTxLowPower == true) - { + if (priv->bDynamicTxLowPower == true) { if (priv->CustomerID == RT_CID_819x_Netcore) - TxAGC = 0x22; - else - TxAGC += priv->CckPwEnl; + TxAGC = 0x22; + else + TxAGC += priv->CckPwEnl; } if (TxAGC > 0x24) TxAGC = 0x24; @@ -202,7 +257,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) } -void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel) { struct r8192_priv *priv = rtllib_priv(dev); u32 writeVal, powerBase0, powerBase1, writeVal_tmp; @@ -211,13 +266,15 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) u8 byte0, byte1, byte2, byte3; powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; - powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0; + powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | + (powerBase0 << 8) | powerBase0; powerBase1 = powerlevel; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1; + powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | + (powerBase1 << 8) | powerBase1; - for (index=0; index<6; index++) - { - writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1)); + for (index = 0; index < 6; index++) { + writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + + ((index < 2) ? powerBase0 : powerBase1)); byte0 = (u8)(writeVal & 0x7f); byte1 = (u8)((writeVal & 0x7f00)>>8); byte2 = (u8)((writeVal & 0x7f0000)>>16); @@ -231,20 +288,17 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) if (byte3 > 0x24) byte3 = 0x24; - if (index == 3) - { - writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; + if (index == 3) { + writeVal_tmp = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; priv->Pwr_Track = writeVal_tmp; } if (priv->bDynamicTxHighPower == true) - { writeVal = 0x03030303; - } else - { - writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; - } + writeVal = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); } diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h index 00fe5a1bb7e..64e831d2f4e 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -21,10 +21,11 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 -extern void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth); -extern bool PHY_RF8256_Config(struct net_device* dev); -extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); -extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel); -extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel); +extern void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth); +extern bool PHY_RF8256_Config(struct net_device *dev); +extern bool phy_RF8256_Config_ParaFile(struct net_device *dev); +extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); +extern void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel); #endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index edca4d55f58..881eb1f96d2 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -29,14 +29,14 @@ u32 temp[10];\ \ memcpy(temp, Address, 40);\ - for (i = 0; i <40; i+=4)\ - printk("\r\n %08x", temp[i]);\ -}\ + for (i = 0; i < 40; i += 4)\ + printk(KERN_INFO "\r\n %08x", temp[i]);\ +} /*---------------------------Define functions---------------------------------*/ - extern bool cmpk_message_handle_tx( +extern bool cmpk_message_handle_tx( struct net_device *dev, - u8* code_virtual_address, + u8 *code_virtual_address, u32 packettype, u32 buffer_len) { @@ -53,7 +53,7 @@ struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__func__,buffer_len); + RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, buffer_len); firmware_init_param(dev); frag_threshold = pfirmware->cmdpacket_frag_thresold; @@ -63,18 +63,19 @@ bLastIniPkt = 0; } else { - frag_length =(u16)(buffer_len - frag_offset); + frag_length = (u16)(buffer_len - frag_offset); bLastIniPkt = 1; } - skb = dev_alloc_skb(frag_length + priv->rtllib->tx_headroom + 4); + skb = dev_alloc_skb(frag_length + + priv->rtllib->tx_headroom + 4); if (skb == NULL) { rt_status = false; goto Failed; } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; @@ -83,18 +84,18 @@ seg_ptr = skb_put(skb, priv->rtllib->tx_headroom); pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - memset(pTxFwInfo,0x12,8); + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + memset(pTxFwInfo, 0x12, 8); seg_ptr = skb_put(skb, frag_length); memcpy(seg_ptr, code_virtual_address, (u32)frag_length); - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); Failed: @@ -110,7 +111,8 @@ cmpk_count_txstatistic( #ifdef ENABLE_PS enum rt_rf_power_state rtState; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) return; @@ -152,10 +154,7 @@ cmpk_count_txstatistic( -static void -cmpk_handle_tx_feedback( - struct net_device *dev, - u8 * pmsg) +static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = rtllib_priv(dev); struct cmpk_txfb rx_tx_fb; /* */ @@ -163,41 +162,30 @@ cmpk_handle_tx_feedback( priv->stats.txfeedback++; - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); + memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); cmpk_count_txstatistic(dev, &rx_tx_fb); } /* cmpk_Handle_Tx_Feedback */ -void -cmdpkt_beacontimerinterrupt_819xusb( - struct net_device *dev -) +void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; - { - if ((priv->rtllib->current_network.mode == IEEE_A) || - (priv->rtllib->current_network.mode == IEEE_N_5G) || - ((priv->rtllib->current_network.mode == IEEE_N_24G) && (!priv->rtllib->pHTInfo->bCurSuppCCK))) - { - tx_rate = 60; - DMESG("send beacon frame tx rate is 6Mbpm\n"); - } - else - { - tx_rate =10; - DMESG("send beacon frame tx rate is 1Mbpm\n"); - } - + if ((priv->rtllib->current_network.mode == IEEE_A) || + (priv->rtllib->current_network.mode == IEEE_N_5G) || + ((priv->rtllib->current_network.mode == IEEE_N_24G) && + (!priv->rtllib->pHTInfo->bCurSuppCCK))) { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } else { + tx_rate = 10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); } } -static void -cmpk_handle_interrupt_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { struct cmpk_intr_sta rx_intr_status; /* */ struct r8192_priv *priv = rtllib_priv(dev); @@ -206,67 +194,55 @@ cmpk_handle_interrupt_status( rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) - { + if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } - if ( priv->rtllib->iw_mode == IW_MODE_ADHOC) - { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); + DMESG("interrupt status = 0x%x\n", + rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->rtllib->bibsscoordinator = true; priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { + } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { priv->rtllib->bibsscoordinator = false; priv->stats.txbeaconerr++; } if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - { cmdpkt_beacontimerinterrupt_819xusb(dev); - } - } - - DMESG("<---- cmpk_handle_interrupt_status()\n"); } /* cmpk_handle_interrupt_status */ -static void -cmpk_handle_query_config_rx( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { cmpk_query_cfg_t rx_query_cfg; /* */ - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); } /* cmpk_Handle_Query_Config_Rx */ -static void cmpk_count_tx_status( struct net_device *dev, - struct cmpk_tx_status *pstx_status) +static void cmpk_count_tx_status(struct net_device *dev, + struct cmpk_tx_status *pstx_status) { struct r8192_priv *priv = rtllib_priv(dev); @@ -274,12 +250,11 @@ static void cmpk_count_tx_status( struct net_device *dev, enum rt_rf_power_state rtstate; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif priv->stats.txfeedbackok += pstx_status->txok; @@ -309,68 +284,56 @@ static void cmpk_count_tx_status( struct net_device *dev, -static void -cmpk_handle_tx_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_status rx_tx_sts; /* */ - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(struct cmpk_tx_status)); + memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(struct cmpk_tx_status)); cmpk_count_tx_status(dev, &rx_tx_sts); - } - -static void -cmpk_handle_tx_rate_history( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_rahis *ptxrate; - u8 i, j; + u8 i, j; u16 length = sizeof(struct cmpk_tx_rahis); - u32 *ptemp; + u32 *ptemp; struct r8192_priv *priv = rtllib_priv(dev); #ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif ptemp = (u32 *)pmsg; - for (i = 0; i < (length/4); i++) - { + for (i = 0; i < (length / 4); i++) { u16 temp1, temp2; - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; + temp1 = ptemp[i] & 0x0000FFFF; + temp2 = ptemp[i] >> 16; + ptemp[i] = (temp1 << 16) | temp2; } ptxrate = (struct cmpk_tx_rahis *)pmsg; - if (ptxrate == NULL ) - { + if (ptxrate == NULL) return; - } - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; - if (i< 8) + if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; for (j = 0; j < 4; j++) - priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; + priv->stats.txrate.ht_mcs[j][i] += + ptxrate->ht_mcs[j][i]; } } @@ -389,8 +352,7 @@ cmpk_message_handle_rx( RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx()\n"); - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) - { + if (pstats == NULL) { /* Print error message. */ /*RT_TRACE(COMP_SEND, DebugLevel, ("\n\r[CMPK]-->Err queue id or pointer"));*/ @@ -403,43 +365,49 @@ cmpk_message_handle_rx( element_id = pcmd_buff[0]; - while (total_length > 0 || exe_cnt++ >100) - { + while (total_length > 0 || exe_cnt++ > 100) { element_id = pcmd_buff[0]; switch (element_id) { case RX_TX_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); - cmpk_handle_tx_feedback (dev, pcmd_buff); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_FEEDBACK\n"); + cmpk_handle_tx_feedback(dev, pcmd_buff); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_INTERRUPT_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_INTERRUPT_STATUS\n"); cmpk_handle_interrupt_status(dev, pcmd_buff); cmd_length = sizeof(struct cmpk_intr_sta); break; case BOTH_QUERY_CONFIG: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "BOTH_QUERY_CONFIG\n"); cmpk_handle_query_config_rx(dev, pcmd_buff); cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; break; case RX_TX_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_STATUS\n"); cmpk_handle_tx_status(dev, pcmd_buff); cmd_length = CMPK_RX_TX_STS_SIZE; break; case RX_TX_PER_PKT_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_PER_PKT_FEEDBACK\n"); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_TX_RATE_HISTORY: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_HISTORY\n"); cmpk_handle_tx_rate_history(dev, pcmd_buff); cmd_length = CMPK_TX_RAHIS_SIZE; break; default: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():unknow CMD Element\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "unknow CMD Element\n"); return 1; } diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index b55d075d6cd..23219e17e5a 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -18,16 +18,16 @@ ******************************************************************************/ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) -#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) -#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) -#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) +#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) +#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) +#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) +#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) -#define ISR_TxBcnOk BIT27 -#define ISR_TxBcnErr BIT26 -#define ISR_BcnTimerIntr BIT13 +#define ISR_TxBcnOk BIT27 +#define ISR_TxBcnErr BIT26 +#define ISR_BcnTimerIntr BIT13 struct cmpk_txfb { @@ -110,7 +110,7 @@ struct cmpk_tx_status { u16 reserve3_23; u8 reserve3_1; u8 rate; -}__packed; +} __packed; struct cmpk_rx_dbginfo { u16 reserve1; @@ -138,19 +138,22 @@ struct cmpk_tx_rahis { } __packed; enum cmpk_element { - RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, - RX_CMD_ELE_MAX + RX_TX_FEEDBACK = 0, + RX_INTERRUPT_STATUS = 1, + TX_SET_CONFIG = 2, + BOTH_QUERY_CONFIG = 3, + RX_TX_STATUS = 4, + RX_DBGINFO_FEEDBACK = 5, + RX_TX_PER_PKT_FEEDBACK = 6, + RX_TX_RATE_HISTORY = 7, + RX_CMD_ELE_MAX }; -extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); -extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); +extern u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats); +extern bool cmpk_message_handle_tx(struct net_device *dev, + u8 *codevirtualaddress, u32 packettype, + u32 buffer_len); #endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 453481959ff..aaba5586dbe 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1662,15 +1662,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; } else { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); } RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); } @@ -1708,15 +1708,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; } else { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); } rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); } @@ -1755,8 +1755,8 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; } priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); } } } From e829d65e7855fb4c98a81dd8c210c5b6d738bde1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 15:31:00 -0500 Subject: [PATCH 0518/1519] staging: rtl8192e: Modify time handling In several places, the driver keeps times (in jiffies) in two 32-bit quantities. In the rtl8192_hw_to_sleep(), there is an error in the calculation of the difference between two 64-bit quantities. Rather than fix that error, I have converted to a single 64-bit number. That makes the code be much cleaner and clearer. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 11 ++++----- drivers/staging/rtl8192e/rtl_core.h | 3 +-- drivers/staging/rtl8192e/rtl_ps.c | 27 ++++++++++------------- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 9 ++++---- drivers/staging/rtl8192e/rtllib_rx.c | 6 ++--- drivers/staging/rtl8192e/rtllib_softmac.c | 23 +++++++------------ 7 files changed, 32 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index e633f0b074e..f585f71e14b 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2243,13 +2243,10 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - if (stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } + if (stats->bIsAMPDU && !stats->bFirstMPDU) + stats->mac_time = priv->LastRxDescTSF; + else + priv->LastRxDescTSF = stats->mac_time; } long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 22b0a438b9d..4f94d0a18f0 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -642,8 +642,7 @@ struct r8192_priv { int rxringcount; u16 rxbuffersize; - u32 LastRxDescTSFHigh; - u32 LastRxDescTSFLow; + u64 LastRxDescTSF; u16 EarlyRxThreshold; u32 ReceiveConfig; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 58966e07be7..ea9eac71253 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data) #define MIN_SLEEP_TIME 50 #define MAX_SLEEP_TIME 10000 -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) { struct r8192_priv *priv = rtllib_priv(dev); - u32 rb = jiffies; + u32 tmp; unsigned long flags; spin_lock_irqsave(&priv->ps_lock,flags); - tl -= MSECS(8+16+7); + time -= MSECS(8+16+7); - if (((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { spin_unlock_irqrestore(&priv->ps_lock,flags); - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + printk(KERN_INFO "too short to sleep::%lld < %ld\n", + time - jiffies, MSECS(MIN_SLEEP_TIME)); return; } - if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { + printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", + time - jiffies, MSECS(MAX_SLEEP_TIME)); spin_unlock_irqrestore(&priv->ps_lock,flags); return; } - { - u32 tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); - } + tmp = time - jiffies; + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq,tmp); queue_delayed_work_rsl(priv->rtllib->wq, (void *)&priv->rtllib->hw_sleep_wq,0); spin_unlock_irqrestore(&priv->ps_lock,flags); diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index d97a6edd1e8..453df2cbb3d 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -33,7 +33,7 @@ struct net_device; #define INIT_DEFAULT_CHAN 1 void rtl8192_hw_wakeup(struct net_device *dev); -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); void IPSLeave_wq (void *data); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2ab1e6cb639..2a394ee9f75 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -993,7 +993,7 @@ struct ieee_ibss_seq { * any adverse affects. */ struct rtllib_rx_stats { #if 1 - u32 mac_time[2]; + u64 mac_time; s8 rssi; u8 signal; u8 noise; @@ -1679,7 +1679,7 @@ struct rtllib_network { struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; - u32 last_dtim_sta_time[2]; + u64 last_dtim_sta_time; u8 wmm_info; struct rtllib_wmm_ac_param wmm_param[4]; @@ -2305,8 +2305,7 @@ struct rtllib_device { int ps_timeout; int ps_period; struct tasklet_struct ps_task; - u32 ps_th; - u32 ps_tl; + u64 ps_time; bool polling; short raw_tx; @@ -2498,7 +2497,7 @@ struct rtllib_device { /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); + void (*enter_sleep_state) (struct net_device *dev, u64 time); short (*ps_is_queue_empty) (struct net_device *dev); int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 24ad9713d0b..9606bedf16d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->dtim_period = info_element->data[1]; if (ieee->state != RTLLIB_LINKED) break; - network->last_dtim_sta_time[0] = jiffies; - network->last_dtim_sta_time[1] = stats->mac_time[1]; + network->last_dtim_sta_time = jiffies; network->dtim_data = RTLLIB_DTIM_VALID; @@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst, dst->atim_window = src->atim_window; dst->dtim_period = src->dtim_period; dst->dtim_data = src->dtim_data; - dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; - dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; + dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); dst->bssht.bdSupportHT = src->bssht.bdSupportHT; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 11433c61bda..29277d18f02 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2037,7 +2037,7 @@ void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) } -short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) +static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; @@ -2074,7 +2074,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time_l){ + if (time){ if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } - *time_l = ieee->current_network.last_dtim_sta_time[0] + *time = ieee->current_network.last_dtim_sta_time + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); } } - if (time_h) { - *time_h = ieee->current_network.last_dtim_sta_time[1]; - if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) - *time_h += 1; - } - return 1; @@ -2126,7 +2120,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u32 th,tl; + u64 time; short sleep; unsigned long flags,flags2; @@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee,&th, &tl); + sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) { @@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) } if (sleep == 1){ if (ieee->sta_sleep == LPS_IS_SLEEP){ - ieee->enter_sleep_state(ieee->dev,th,tl); + ieee->enter_sleep_state(ieee->dev, time); } else if (ieee->sta_sleep == LPS_IS_WAKE){ @@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee,1); - ieee->ps_th = th; - ieee->ps_tl = tl; + ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) /* Null frame with PS bit set */ if (success){ ieee->sta_sleep = LPS_IS_SLEEP; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake From 81e3863636b2f963d32245ce6b23b37404d0cd39 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 15:53:53 -0500 Subject: [PATCH 0519/1519] staging: rtl8192e: Remove extraneous log message The driver logs all DHCP transactions and thus spams the logs. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_tx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index d03b5aa02cc..7ccad860182 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -632,15 +632,13 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) goto success; } - if (skb->len > 282){ + if (skb->len > 282) { if (ETH_P_IP == ether_type) { const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { - printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]); - bdhcp = true; ieee->LPSDelayCnt = 200; } From b9ffad087cb6b5251e342b7005862d71724baccc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 17:59:24 -0500 Subject: [PATCH 0520/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part II Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2275 +++++++++++++------------ 1 file changed, 1198 insertions(+), 1077 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index aaba5586dbe..229d6df789f 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -37,8 +37,8 @@ void rtl8192e_start_beacon(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; u16 BcnTimeCfg = 0; - u16 BcnCW = 6; - u16 BcnIFS = 0xf; + u16 BcnCW = 6; + u16 BcnIFS = 0xf; DMESG("Enabling beacon TX"); rtl8192_irq_disable(dev); @@ -63,7 +63,7 @@ void rtl8192e_update_msr(struct net_device *dev) u8 msr; enum led_ctl_mode LedAction = LED_CTL_NO_LINK; msr = read_nic_byte(dev, MSR); - msr &= ~ MSR_LINK_MASK; + msr &= ~MSR_LINK_MASK; switch (priv->rtllib->iw_mode) { case IW_MODE_INFRA: @@ -94,250 +94,246 @@ void rtl8192e_update_msr(struct net_device *dev) priv->rtllib->LedControlHandler(dev, LedAction); } -void -rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - switch (variable) + switch (variable) { + case HW_VAR_BSSID: + write_nic_dword(dev, BSSIDR, ((u32 *)(val))[0]); + write_nic_word(dev, BSSIDR+2, ((u16 *)(val+2))[0]); + break; + + case HW_VAR_MEDIA_STATUS: { + enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); + enum led_ctl_mode LedAction = LED_CTL_NO_LINK; + u8 btMsr = read_nic_byte(dev, MSR); - case HW_VAR_BSSID: - write_nic_dword(dev, BSSIDR, ((u32*)(val))[0]); - write_nic_word(dev, BSSIDR+2, ((u16*)(val+2))[0]); - break; + btMsr &= 0xfc; - case HW_VAR_MEDIA_STATUS: - { - enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); - enum led_ctl_mode LedAction = LED_CTL_NO_LINK; - u8 btMsr = read_nic_byte(dev, MSR); + switch (OpMode) { + case RT_OP_MODE_INFRASTRUCTURE: + btMsr |= MSR_INFRA; + LedAction = LED_CTL_LINK; + break; - btMsr &= 0xfc; + case RT_OP_MODE_IBSS: + btMsr |= MSR_ADHOC; + break; - switch (OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_INFRA; - LedAction = LED_CTL_LINK; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_ADHOC; - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_AP; - LedAction = LED_CTL_LINK; - break; - - default: - btMsr |= MSR_NOLINK; - break; - } - - write_nic_byte(dev, MSR, btMsr); + case RT_OP_MODE_AP: + btMsr |= MSR_AP; + LedAction = LED_CTL_LINK; + break; + default: + btMsr |= MSR_NOLINK; + break; } + + write_nic_byte(dev, MSR, btMsr); + + } + break; + + case HW_VAR_CECHK_BSSID: + { + u32 RegRCR, Type; + + Type = ((u8 *)(val))[0]; + RegRCR = read_nic_dword(dev, RCR); + priv->ReceiveConfig = RegRCR; + + if (Type == true) + RegRCR |= (RCR_CBSSID); + else if (Type == false) + RegRCR &= (~RCR_CBSSID); + + write_nic_dword(dev, RCR, RegRCR); + priv->ReceiveConfig = RegRCR; + + } + break; + + case HW_VAR_SLOT_TIME: + + priv->slot_time = val[0]; + write_nic_byte(dev, SLOT_TIME, val[0]); + break; - case HW_VAR_CECHK_BSSID: - { - u32 RegRCR, Type; + case HW_VAR_ACK_PREAMBLE: + { + u32 regTmp; + priv->short_preamble = (bool)(*(u8 *)val); + regTmp = priv->basic_rate; + if (priv->short_preamble) + regTmp |= BRSR_AckShortPmb; + write_nic_dword(dev, RRSR, regTmp); + break; + } - Type = ((u8*)(val))[0]; - RegRCR = read_nic_dword(dev,RCR); - priv->ReceiveConfig = RegRCR; + case HW_VAR_CPU_RST: + write_nic_dword(dev, CPU_GEN, ((u32 *)(val))[0]); + break; - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); + case HW_VAR_AC_PARAM: + { + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + u8 u1bAIFS; + u32 u4bAcParam; + u8 mode = priv->rtllib->mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; - write_nic_dword(dev, RCR,RegRCR); - priv->ReceiveConfig = RegRCR; + u1bAIFS = qos_parameters->aifs[pAcParam] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + dm_init_edca_turbo(dev); + + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[pAcParam])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[pAcParam])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[pAcParam])) << + AC_PARAM_ECW_MIN_OFFSET) | + (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); + + RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", + __func__, eACI, u4bAcParam); + switch (eACI) { + case AC1_BK: + write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); + break; + + case AC0_BE: + write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + break; + + case AC2_VI: + write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + break; + + case AC3_VO: + write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + break; + + default: + printk(KERN_INFO "SetHwReg8185(): invalid ACI: %d !\n", + eACI); + break; } + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, + (u8 *)(&pAcParam)); break; + } - case HW_VAR_SLOT_TIME: - { + case HW_VAR_ACM_CTRL: + { + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + union aci_aifsn *pAciAifsn = (union aci_aifsn *) & + (qos_parameters->aifs[0]); + u8 acm = pAciAifsn->f.acm; + u8 AcmCtrl = read_nic_byte(dev, AcmHwCtrl); - priv->slot_time = val[0]; - write_nic_byte(dev, SLOT_TIME, val[0]); - - } - break; - - case HW_VAR_ACK_PREAMBLE: - { - u32 regTmp = 0; - priv->short_preamble = (bool)(*(u8*)val ); - regTmp = priv->basic_rate; - if (priv->short_preamble) - regTmp |= BRSR_AckShortPmb; - write_nic_dword(dev, RRSR, regTmp); - } - break; - - case HW_VAR_CPU_RST: - write_nic_dword(dev, CPU_GEN, ((u32*)(val))[0]); - break; - - case HW_VAR_AC_PARAM: - { - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - u8 u1bAIFS; - u32 u4bAcParam; - u8 mode = priv->rtllib->mode; - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - - - u1bAIFS = qos_parameters->aifs[pAcParam] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - - dm_init_edca_turbo(dev); - - u4bAcParam = ( (((u32)(qos_parameters->tx_op_limit[pAcParam])) << AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(qos_parameters->cw_max[pAcParam])) << AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(qos_parameters->cw_min[pAcParam])) << AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET) ); - - RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", __func__,eACI, u4bAcParam); - switch (eACI) - { - case AC1_BK: - write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); - break; + RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", + __func__, eACI); + AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2) ? 0x0 : 0x1); + if (acm) { + switch (eACI) { case AC0_BE: - write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + AcmCtrl |= AcmHw_BeqEn; break; case AC2_VI: - write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + AcmCtrl |= AcmHw_ViqEn; break; case AC3_VO: - write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + AcmCtrl |= AcmHw_VoqEn; break; default: - printk("SetHwReg8185(): invalid ACI: %d !\n", eACI); + RT_TRACE(COMP_QOS, "SetHwReg8185(): [HW_VAR_" + "ACM_CTRL] acm set failed: eACI is " + "%d\n", eACI); break; } - priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, (u8*)(&pAcParam)); - } - break; + } else { + switch (eACI) { + case AC0_BE: + AcmCtrl &= (~AcmHw_BeqEn); + break; - case HW_VAR_ACM_CTRL: - { - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); - u8 acm = pAciAifsn->f.acm; - u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); + case AC2_VI: + AcmCtrl &= (~AcmHw_ViqEn); + break; - RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", __func__,eACI); - AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2)?0x0:0x1); + case AC3_VO: + AcmCtrl &= (~AcmHw_BeqEn); + break; - if (acm) - { - switch (eACI) - { - case AC0_BE: - AcmCtrl |= AcmHw_BeqEn; - break; - - case AC2_VI: - AcmCtrl |= AcmHw_ViqEn; - break; - - case AC3_VO: - AcmCtrl |= AcmHw_VoqEn; - break; - - default: - RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n", eACI ); - break; - } + default: + break; } - else - { - switch (eACI) - { - case AC0_BE: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - case AC2_VI: - AcmCtrl &= (~AcmHw_ViqEn); - break; - - case AC3_VO: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - default: - break; - } - } - - RT_TRACE( COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ); - write_nic_byte(dev, AcmHwCtrl, AcmCtrl ); } + + RT_TRACE(COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write" + " 0x%X\n", AcmCtrl); + write_nic_byte(dev, AcmHwCtrl, AcmCtrl); + break; + } + + case HW_VAR_SIFS: + write_nic_byte(dev, SIFS, val[0]); + write_nic_byte(dev, SIFS+1, val[0]); break; - case HW_VAR_SIFS: - write_nic_byte(dev, SIFS, val[0]); - write_nic_byte(dev, SIFS+1, val[0]); + case HW_VAR_RF_TIMING: + { + u8 Rf_Timing = *((u8 *)val); + write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); break; + } - case HW_VAR_RF_TIMING: - { - u8 Rf_Timing = *((u8*)val); - write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); - } - break; - - default: + default: break; } } -static void rtl8192_read_eeprom_info(struct net_device* dev) +static void rtl8192_read_eeprom_info(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 tempval; - u8 ICVer8192, ICVer8256; - u16 i,usValue, IC_Version; - u16 EEPROMId; + u8 tempval; + u8 ICVer8192, ICVer8256; + u16 i, usValue, IC_Version; + u16 EEPROMId; u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); - - EEPROMId = eprom_read(dev, 0); - if ( EEPROMId != RTL8190_EEPROM_ID ) - { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); - priv->AutoloadFailFlag=true; - } - else - { - priv->AutoloadFailFlag=false; + if (EEPROMId != RTL8190_EEPROM_ID) { + RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", + EEPROMId, RTL8190_EEPROM_ID); + priv->AutoloadFailFlag = true; + } else { + priv->AutoloadFailFlag = false; } - if (!priv->AutoloadFailFlag) - { + if (!priv->AutoloadFailFlag) { priv->eeprom_vid = eprom_read(dev, (EEPROM_VID >> 1)); priv->eeprom_did = eprom_read(dev, (EEPROM_DID >> 1)); - usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; - priv->eeprom_CustomerID = (u8)( usValue & 0xff); + usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8; + priv->eeprom_CustomerID = (u8)(usValue & 0xff); usValue = eprom_read(dev, (EEPROM_ICVersion_ChannelPlan>>1)); priv->eeprom_ChannelPlan = usValue&0xff; IC_Version = ((usValue&0xff00)>>8); @@ -346,24 +342,21 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) ICVer8256 = ((IC_Version&0xf0)>>4); RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256); - if (ICVer8192 == 0x2) - { + if (ICVer8192 == 0x2) { if (ICVer8256 == 0x5) - priv->card_8192_version= VERSION_8190_BE; + priv->card_8192_version = VERSION_8190_BE; } - switch (priv->card_8192_version) - { - case VERSION_8190_BD: - case VERSION_8190_BE: - break; - default: - priv->card_8192_version = VERSION_8190_BD; - break; + switch (priv->card_8192_version) { + case VERSION_8190_BD: + case VERSION_8190_BE: + break; + default: + priv->card_8192_version = VERSION_8190_BD; + break; } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); - } - else - { + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", + priv->card_8192_version); + } else { priv->card_8192_version = VERSION_8190_BD; priv->eeprom_vid = 0; priv->eeprom_did = 0; @@ -374,282 +367,289 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); + RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", + priv->eeprom_CustomerID); - if (!priv->AutoloadFailFlag) - { - for (i = 0; i < 6; i += 2) - { - usValue = eprom_read(dev, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); - *(u16*)(&dev->dev_addr[i]) = usValue; + if (!priv->AutoloadFailFlag) { + for (i = 0; i < 6; i += 2) { + usValue = eprom_read(dev, + (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); + *(u16 *)(&dev->dev_addr[i]) = usValue; } } else { memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); } - RT_TRACE(COMP_INIT, "Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - dev->dev_addr[0], dev->dev_addr[1], - dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); + RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", + dev->dev_addr); - if (priv->card_8192_version > VERSION_8190_BD) { + if (priv->card_8192_version > VERSION_8190_BD) priv->bTXPowerDataReadFromEEPORM = true; - } else { + else priv->bTXPowerDataReadFromEEPORM = false; - } priv->rf_type = RTL819X_DEFAULT_RF_TYPE; - if (priv->card_8192_version > VERSION_8190_BD) - { - if (!priv->AutoloadFailFlag) - { - tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; + if (priv->card_8192_version > VERSION_8190_BD) { + if (!priv->AutoloadFailFlag) { + tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff >> + 1))) & 0xff; priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; if (tempval&0x80) priv->rf_type = RF_1T2R; else priv->rf_type = RF_2T4R; - } - else - { + } else { priv->EEPROMLegacyHTTxPowerDiff = 0x04; } RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", priv->EEPROMLegacyHTTxPowerDiff); if (!priv->AutoloadFailFlag) - { - priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); - } + priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, + (EEPROM_ThermalMeter>>1))) & + 0xff00)>>8); else - { priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - } - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; + RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", + priv->EEPROMThermalMeter); + priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; - if (priv->epromtype == EEPROM_93C46) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (EEPROM_TxPwDiff_CrystalCap>>1)); + if (priv->epromtype == EEPROM_93C46) { + if (!priv->AutoloadFailFlag) { + usValue = eprom_read(dev, + (EEPROM_TxPwDiff_CrystalCap >> 1)); priv->EEPROMAntPwDiff = (usValue&0x0fff); - priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + priv->EEPROMCrystalCap = (u8)((usValue & 0xf000) + >> 12); + } else { + priv->EEPROMAntPwDiff = + EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = + EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", + priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", + priv->EEPROMCrystalCap); - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_CCK + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) = + usValue; + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelCCK[i]); + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i+1, + priv->EEPROMTxPowerLevelCCK[i+1]); } - else - { - usValue = EEPROM_Default_TxPower; + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_OFDM_24G + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i])) + = usValue; + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelOFDM24G[i]); + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i + 1, + priv->EEPROMTxPowerLevelOFDM24G[i+1]); } - *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); } - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); + if (priv->epromtype == EEPROM_93C46) { + for (i = 0; i < 14; i++) { + priv->TxPowerLevelCCK[i] = + priv->EEPROMTxPowerLevelCCK[i]; + priv->TxPowerLevelOFDM24G[i] = + priv->EEPROMTxPowerLevelOFDM24G[i]; } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); - } - } - else if (priv->epromtype== EEPROM_93C56) - { - - } - if (priv->epromtype == EEPROM_93C46) - { - for (i=0; i<14; i++) - { - priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; - } - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); - priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); - priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & + 0xf); + priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & + 0xf0)>>4); + priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & + 0xf00)>>8); priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - else if (priv->epromtype == EEPROM_93C56) - { + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); + } else if (priv->epromtype == EEPROM_93C56) { - for (i=0; i<3; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; + for (i = 0; i < 3; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[0]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[0]; } - for (i=3; i<9; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; + for (i = 3; i < 9; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[1]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[1]; } - for (i=9; i<14; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; + for (i = 9; i < 14; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[2]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[2]; } - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_A[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_C[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_C[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_C[i]); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; priv->AntennaTxPwDiff[0] = 0; priv->AntennaTxPwDiff[1] = 0; priv->AntennaTxPwDiff[2] = 0; priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); } } - if (priv->rf_type == RF_1T2R) - { + if (priv->rf_type == RF_1T2R) { + /* no matter what checkpatch says, the braces are needed */ RT_TRACE(COMP_INIT, "\n1T2R config\n"); - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { RT_TRACE(COMP_INIT, "\n2T4R config\n"); } init_rate_adaptive(dev); - - priv->rf_chip= RF_8256; + priv->rf_chip = RF_8256; if (priv->RegChannelPlan == 0xf) - { priv->ChannelPlan = priv->eeprom_ChannelPlan; - } else - { priv->ChannelPlan = priv->RegChannelPlan; - } - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) - { + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->CustomerID = RT_CID_DLINK; - } - switch (priv->eeprom_CustomerID) - { - case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; - break; - case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; - break; - case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; - break; - case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; - break; - case EEPROM_CID_TOSHIBA: - priv->CustomerID = RT_CID_TOSHIBA; - if (priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; - else - priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); - break; - case EEPROM_CID_Nettronix: - priv->ScanDelay = 100; - priv->CustomerID = RT_CID_Nettronix; - break; - case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; - break; - case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; - break; + switch (priv->eeprom_CustomerID) { + case EEPROM_CID_DEFAULT: + priv->CustomerID = RT_CID_DEFAULT; + break; + case EEPROM_CID_CAMEO: + priv->CustomerID = RT_CID_819x_CAMEO; + break; + case EEPROM_CID_RUNTOP: + priv->CustomerID = RT_CID_819x_RUNTOP; + break; + case EEPROM_CID_NetCore: + priv->CustomerID = RT_CID_819x_Netcore; + break; + case EEPROM_CID_TOSHIBA: + priv->CustomerID = RT_CID_TOSHIBA; + if (priv->eeprom_ChannelPlan&0x80) + priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + else + priv->ChannelPlan = 0x0; + RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", + priv->ChannelPlan); + break; + case EEPROM_CID_Nettronix: + priv->ScanDelay = 100; + priv->CustomerID = RT_CID_Nettronix; + break; + case EEPROM_CID_Pronet: + priv->CustomerID = RT_CID_PRONET; + break; + case EEPROM_CID_DLINK: + priv->CustomerID = RT_CID_DLINK; + break; - case EEPROM_CID_WHQL: - - - - break; - default: - break; + case EEPROM_CID_WHQL: + break; + default: + break; } if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) priv->ChannelPlan = 0; priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; else priv->rtllib->bSupportRemoteWakeUp = false; RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d \n", priv->ChannelPlan); + RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); - - return ; } -void rtl8192_get_eeprom_size(struct net_device* dev) +void rtl8192_get_eeprom_size(struct net_device *dev) { - u16 curCR = 0; + u16 curCR; struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); curCR = read_nic_dword(dev, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); - priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : EEPROM_93C46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); + RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, + curCR); + priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : + EEPROM_93C46; + RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, + priv->epromtype); rtl8192_read_eeprom_info(dev); } -static void rtl8192_hwconfig(struct net_device* dev) +static void rtl8192_hwconfig(struct net_device *dev) { u32 regRATR = 0, regRRSR = 0; u8 regBwOpMode = 0, regTmp = 0; struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_B: regBwOpMode = BW_OPMODE_20MHZ; regRATR = RATE_ALL_CCK; regRRSR = RATE_ALL_CCK; break; case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regBwOpMode = BW_OPMODE_5G | BW_OPMODE_20MHZ; regRATR = RATE_ALL_OFDM_AG; regRRSR = RATE_ALL_OFDM_AG; break; @@ -661,12 +661,14 @@ static void rtl8192_hwconfig(struct net_device* dev) case WIRELESS_MODE_AUTO: case WIRELESS_MODE_N_24G: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | + RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_5G: regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | + RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_OFDM_AG; break; default: @@ -681,9 +683,7 @@ static void rtl8192_hwconfig(struct net_device* dev) u32 ratr_value = 0; ratr_value = regRATR; if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -692,11 +692,8 @@ static void rtl8192_hwconfig(struct net_device* dev) write_nic_dword(dev, RRSR, regRRSR); write_nic_word(dev, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \ + priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - - - } bool rtl8192_adapter_start(struct net_device *dev) @@ -705,7 +702,7 @@ bool rtl8192_adapter_start(struct net_device *dev) u32 ulRegRead; bool rtStatus = true; u8 tmpvalue; - u8 ICVersion,SwitchingRegulatorOutput; + u8 ICVersion, SwitchingRegulatorOutput; bool bfirmwareok = true; u32 tmpRegA, tmpRegC, TempCCk; int i = 0; @@ -715,13 +712,12 @@ bool rtl8192_adapter_start(struct net_device *dev) priv->being_init_adapter = true; start: - rtl8192_pci_resetdescring(dev); + rtl8192_pci_resetdescring(dev); priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - write_nic_byte(dev, ANAPAR, 0x37); - mdelay(500); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + write_nic_byte(dev, ANAPAR, 0x37); + mdelay(500); + } priv->pFirmware->firmware_status = FW_STATUS_0_INIT; if (priv->RegRfOff == true) @@ -729,23 +725,19 @@ start: ulRegRead = read_nic_dword(dev, CPU_GEN); if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - { ulRegRead |= CPU_GEN_SYSTEM_RESET; - }else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) + else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) ulRegRead |= CPU_GEN_FIRMWARE_RESET; else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); - + RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)" + "\n", __func__, priv->pFirmware->firmware_status); write_nic_dword(dev, CPU_GEN, ulRegRead); - ICVersion = read_nic_byte(dev, IC_VERRSION); - if (ICVersion >= 0x4) - { + if (ICVersion >= 0x4) { SwitchingRegulatorOutput = read_nic_byte(dev, SWREGULATOR); - if (SwitchingRegulatorOutput != 0xb8) - { + if (SwitchingRegulatorOutput != 0xb8) { write_nic_byte(dev, SWREGULATOR, 0xa8); mdelay(1); write_nic_byte(dev, SWREGULATOR, 0xb8); @@ -753,64 +745,64 @@ start: } RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl8192_BBConfig(dev); - if (rtStatus != true) - { + if (rtStatus != true) { RT_TRACE(COMP_ERR, "BB Config failed\n"); return rtStatus; } - RT_TRACE(COMP_INIT,"BB Config Finished!\n"); + RT_TRACE(COMP_INIT, "BB Config Finished!\n"); priv->LoopbackMode = RTL819X_NO_LOOPBACK; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - ulRegRead = read_nic_dword(dev, CPU_GEN); - if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) - { - ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); - } - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) - { - ulRegRead |= CPU_CCK_LOOPBACK; - } - else - { - RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + ulRegRead = read_nic_dword(dev, CPU_GEN); + if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) + ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | + CPU_GEN_NO_LOOPBACK_SET); + else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK) + ulRegRead |= CPU_CCK_LOOPBACK; + else + RT_TRACE(COMP_ERR, "Serious error: wrong loopback" + " mode setting\n"); - write_nic_dword(dev, CPU_GEN, ulRegRead); + write_nic_dword(dev, CPU_GEN, ulRegRead); - udelay(500); + udelay(500); } rtl8192_hwconfig(dev); - write_nic_byte(dev, CMDR, CR_RE|CR_TE); + write_nic_byte(dev, CMDR, CR_RE | CR_TE); - write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); + write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); + write_nic_word(dev, MAC4, ((u16 *)(dev->dev_addr + 4))[0]); write_nic_dword(dev, RCR, priv->ReceiveConfig); - { - write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\ - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) - rtl8192_SetWirelessMode(dev, priv->rtllib->mode); + rtl8192_SetWirelessMode(dev, priv->rtllib->mode); CamResetAllEntry(dev); { u8 SECR_value = 0x0; @@ -823,8 +815,8 @@ start: write_nic_word(dev, BCN_INTERVAL, 100); { int i; - for (i=0; iIC_Cut= tmpvalue; + priv->IC_Cut = tmpvalue; RT_TRACE(COMP_INIT, "priv->IC_Cut= 0x%x\n", priv->IC_Cut); - if (priv->IC_Cut>= IC_VersionCut_D) - { - if (priv->IC_Cut== IC_VersionCut_D) { + if (priv->IC_Cut >= IC_VersionCut_D) { + if (priv->IC_Cut == IC_VersionCut_D) { + /* no matter what checkpatch says, braces are needed */ RT_TRACE(COMP_INIT, "D-cut\n"); - } else if (priv->IC_Cut== IC_VersionCut_E) { + } else if (priv->IC_Cut == IC_VersionCut_E) { RT_TRACE(COMP_INIT, "E-cut\n"); } } else { @@ -878,20 +870,27 @@ start: write_nic_byte(dev, 0x87, 0x0); if (priv->RegRfOff == true) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW,true); + RT_TRACE((COMP_INIT | COMP_RF | COMP_POWER), + "%s(): Turn off RF for RegRfOff ----------\n", + __func__); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW, true); } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__func__); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON\n", + __func__); priv->rtllib->eRFPowerState = eRfOn; priv->rtllib->RfOffReason = 0; - - } if (priv->rtllib->FwRWRF) @@ -899,37 +898,51 @@ start: else priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { + if (priv->ResetProgress == RESET_TYPE_NORESET) { dm_initialize_txpower_tracking(dev); - if (priv->IC_Cut>= IC_VersionCut_D) { - tmpRegA= rtl8192_QueryBBReg(dev,rOFDM0_XATxIQImbalance,bMaskDWord); - tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord); - for (i = 0; itxbbgain_table[i].txbbgain_value) { - priv->rfa_txpowertrackingindex= (u8)i; - priv->rfa_txpowertrackingindex_real= (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + if (priv->IC_Cut >= IC_VersionCut_D) { + tmpRegA = rtl8192_QueryBBReg(dev, + rOFDM0_XATxIQImbalance, bMaskDWord); + tmpRegC = rtl8192_QueryBBReg(dev, + rOFDM0_XCTxIQImbalance, bMaskDWord); + for (i = 0; i < TxBBGainTableLength; i++) { + if (tmpRegA == + priv->txbbgain_table[i].txbbgain_value) { + priv->rfa_txpowertrackingindex = (u8)i; + priv->rfa_txpowertrackingindex_real = + (u8)i; + priv->rfa_txpowertracking_default = + priv->rfa_txpowertrackingindex; break; } } - TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + TempCCk = rtl8192_QueryBBReg(dev, + rCCK0_TxFilter1, bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { - priv->CCKPresentAttentuation_20Mdefault =(u8) i; + priv->CCKPresentAttentuation_20Mdefault = (u8)i; break; } } priv->CCKPresentAttentuation_40Mdefault = 0; priv->CCKPresentAttentuation_difference = 0; - priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault; + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_initial = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_real__initial = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_difference_initial = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_initial = %d\n", + priv->CCKPresentAttentuation); priv->btxpower_tracking = false; } } @@ -951,8 +964,8 @@ void rtl8192_net_update(struct net_device *dev) rtl8192_config_rate(dev, &rate_config); priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; priv->basic_rate = rate_config &= 0x15f; - write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]); + write_nic_dword(dev, BSSIDR, ((u32 *)net->bssid)[0]); + write_nic_word(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { write_nic_word(dev, ATIMWND, 2); @@ -971,15 +984,16 @@ void rtl8192_net_update(struct net_device *dev) void rtl8192_link_change(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (!priv->up) - return; + return; if (ieee->state == RTLLIB_LINKED) { rtl8192_net_update(dev); priv->ops->update_ratr_table(dev); - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) EnableHWSecurityConfig8192(dev); } else { write_nic_byte(dev, 0x173, 0); @@ -991,8 +1005,8 @@ void rtl8192_link_change(struct net_device *dev) reg = read_nic_dword(dev, RCR); if (priv->rtllib->state == RTLLIB_LINKED) { if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn) - ; - else + ; + else priv->ReceiveConfig = reg |= RCR_CBSSID; } else priv->ReceiveConfig = reg &= ~RCR_CBSSID; @@ -1001,21 +1015,20 @@ void rtl8192_link_change(struct net_device *dev) } } -void rtl8192_AllowAllDestAddr(struct net_device* dev, - bool bAllowAllDA, bool WriteIntoReg) +void rtl8192_AllowAllDestAddr(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - if (bAllowAllDA) - priv->ReceiveConfig |= RCR_AAP; - else - priv->ReceiveConfig &= ~RCR_AAP; + if (bAllowAllDA) + priv->ReceiveConfig |= RCR_AAP; + else + priv->ReceiveConfig &= ~RCR_AAP; - if (WriteIntoReg) - write_nic_dword( dev, RCR, priv->ReceiveConfig ); + if (WriteIntoReg) + write_nic_dword(dev, RCR, priv->ReceiveConfig); } - static u8 MRateToHwRate8190Pci(u8 rate) { u8 ret = DESC90_RATE1M; @@ -1148,138 +1161,144 @@ u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) break; default: RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection:" - " %d \n", QueueID); + " %d\n", QueueID); break; } return QueueSelect; } - -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - pTxFwInfo->TxHT = (cb_desc->data_rate&0x80)?1:0; - pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); - pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; - pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, cb_desc); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); + struct tx_fwinfo_8190pci *pTxFwInfo = NULL; + pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + pTxFwInfo->TxHT = (cb_desc->data_rate & 0x80) ? 1 : 0; + pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); + pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; + pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, + pTxFwInfo->TxRate, + cb_desc); - if (cb_desc->bAMPDUEnable) { - pTxFwInfo->AllowAggregation = 1; - pTxFwInfo->RxMF = cb_desc->ampdu_factor; - pTxFwInfo->RxAMD = cb_desc->ampdu_density; - } else { - pTxFwInfo->AllowAggregation = 0; - pTxFwInfo->RxMF = 0; - pTxFwInfo->RxAMD = 0; - } + if (cb_desc->bAMPDUEnable) { + pTxFwInfo->AllowAggregation = 1; + pTxFwInfo->RxMF = cb_desc->ampdu_factor; + pTxFwInfo->RxAMD = cb_desc->ampdu_density; + } else { + pTxFwInfo->AllowAggregation = 0; + pTxFwInfo->RxMF = 0; + pTxFwInfo->RxAMD = 0; + } - pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable)?1:0; - pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable)?1:0; - pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC)?1:0; - pTxFwInfo->RtsHT= (cb_desc->rts_rate&0x80)?1:0; - pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); - pTxFwInfo->RtsBandwidth = 0; - pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; - pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT==0)?(cb_desc->bRTSUseShortPreamble?1:0):(cb_desc->bRTSUseShortGI?1:0); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) - { - if (cb_desc->bPacketBW) - { - pTxFwInfo->TxBandwidth = 1; - pTxFwInfo->TxSubCarrier = 0; - } - else - { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = 0; - } + pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable) ? 1 : 0; + pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable) ? 1 : 0; + pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC) ? 1 : 0; + pTxFwInfo->RtsHT = (cb_desc->rts_rate&0x80) ? 1 : 0; + pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); + pTxFwInfo->RtsBandwidth = 0; + pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; + pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? + (cb_desc->bRTSUseShortPreamble ? 1 : 0) : + (cb_desc->bRTSUseShortGI ? 1 : 0); + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { + if (cb_desc->bPacketBW) { + pTxFwInfo->TxBandwidth = 1; + pTxFwInfo->TxSubCarrier = 0; + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + } + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = 0; + } - memset((u8*)pdesc,0,12); - pdesc->LINIP = 0; - pdesc->CmdInit = 1; - pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); + memset((u8 *)pdesc, 0, 12); + pdesc->LINIP = 0; + pdesc->CmdInit = 1; + pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); - pdesc->SecCAMID= 0; - pdesc->RATid = cb_desc->RATRIndex; + pdesc->SecCAMID = 0; + pdesc->RATid = cb_desc->RATRIndex; - pdesc->NoEnc = 1; - pdesc->SecType = 0x0; - if (cb_desc->bHwSec) { - static u8 tmp =0; - if (!tmp) { - RT_TRACE(COMP_DBG, "==>================hw sec\n"); - tmp = 1; - } - switch (priv->rtllib->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - pdesc->SecType = 0x1; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - pdesc->SecType = 0x2; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - pdesc->SecType = 0x3; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_NA: - pdesc->SecType = 0x0; - pdesc->NoEnc = 1; - break; - } - } + pdesc->NoEnc = 1; + pdesc->SecType = 0x0; + if (cb_desc->bHwSec) { + static u8 tmp; + if (!tmp) { + RT_TRACE(COMP_DBG, "==>================hw sec\n"); + tmp = 1; + } + switch (priv->rtllib->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + pdesc->SecType = 0x1; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_TKIP: + pdesc->SecType = 0x2; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_CCMP: + pdesc->SecType = 0x3; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_NA: + pdesc->SecType = 0x0; + pdesc->NoEnc = 1; + break; + } + } - pdesc->PktId = 0x0; + pdesc->PktId = 0x0; - pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(cb_desc->queue_index, cb_desc->priority); - pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); + pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue( + cb_desc->queue_index, + cb_desc->priority); + pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); - pdesc->DISFB = cb_desc->bTxDisableRateFallBack; - pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; + pdesc->DISFB = cb_desc->bTxDisableRateFallBack; + pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; - pdesc->FirstSeg =1; - pdesc->LastSeg = 1; - pdesc->TxBufferSize = skb->len; + pdesc->FirstSeg = 1; + pdesc->LastSeg = 1; + pdesc->TxBufferSize = skb->len; - pdesc->TxBuffAddr = cpu_to_le32(mapping); + pdesc->TxBuffAddr = cpu_to_le32(mapping); } -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff* skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); - memset(entry,0,12); - entry->LINIP = cb_desc->bLastIniPkt; - entry->FirstSeg = 1; - entry->LastSeg = 1; - if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { - entry->CmdInit = DESC_PACKET_TYPE_INIT; - } else { - struct tx_desc * entry_tmp = (struct tx_desc *)entry; - entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); - entry_tmp->QueueSelect = QSLT_CMD; - entry_tmp->TxFWInfoSize = 0x08; - entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; - } - entry->TxBufferSize = skb->len; - entry->TxBuffAddr = cpu_to_le32(mapping); - entry->OWN = 1; + memset(entry, 0, 12); + entry->LINIP = cb_desc->bLastIniPkt; + entry->FirstSeg = 1; + entry->LastSeg = 1; + if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { + entry->CmdInit = DESC_PACKET_TYPE_INIT; + } else { + struct tx_desc * entry_tmp = (struct tx_desc *)entry; + entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; + entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + entry_tmp->PktSize = (u16)(cb_desc->pkt_size + + entry_tmp->Offset); + entry_tmp->QueueSelect = QSLT_CMD; + entry_tmp->TxFWInfoSize = 0x08; + entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; + } + entry->TxBufferSize = skb->len; + entry->TxBuffAddr = cpu_to_le32(mapping); + entry->OWN = 1; } u8 HwRateToMRate90(bool bIsHT, u8 rate) @@ -1288,156 +1307,193 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) if (!bIsHT) { switch (rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; + case DESC90_RATE1M: + ret_rate = MGN_1M; + break; + case DESC90_RATE2M: + ret_rate = MGN_2M; + break; + case DESC90_RATE5_5M: + ret_rate = MGN_5_5M; + break; + case DESC90_RATE11M: + ret_rate = MGN_11M; + break; + case DESC90_RATE6M: + ret_rate = MGN_6M; + break; + case DESC90_RATE9M: + ret_rate = MGN_9M; + break; + case DESC90_RATE12M: + ret_rate = MGN_12M; + break; + case DESC90_RATE18M: + ret_rate = MGN_18M; + break; + case DESC90_RATE24M: + ret_rate = MGN_24M; + break; + case DESC90_RATE36M: + ret_rate = MGN_36M; + break; + case DESC90_RATE48M: + ret_rate = MGN_48M; + break; + case DESC90_RATE54M: + ret_rate = MGN_54M; + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported" + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } else { switch (rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + case DESC90_RATEMCS0: + ret_rate = MGN_MCS0; + break; + case DESC90_RATEMCS1: + ret_rate = MGN_MCS1; + break; + case DESC90_RATEMCS2: + ret_rate = MGN_MCS2; + break; + case DESC90_RATEMCS3: + ret_rate = MGN_MCS3; + break; + case DESC90_RATEMCS4: + ret_rate = MGN_MCS4; + break; + case DESC90_RATEMCS5: + ret_rate = MGN_MCS5; + break; + case DESC90_RATEMCS6: + ret_rate = MGN_MCS6; + break; + case DESC90_RATEMCS7: + ret_rate = MGN_MCS7; + break; + case DESC90_RATEMCS8: + ret_rate = MGN_MCS8; + break; + case DESC90_RATEMCS9: + ret_rate = MGN_MCS9; + break; + case DESC90_RATEMCS10: + ret_rate = MGN_MCS10; + break; + case DESC90_RATEMCS11: + ret_rate = MGN_MCS11; + break; + case DESC90_RATEMCS12: + ret_rate = MGN_MCS12; + break; + case DESC90_RATEMCS13: + ret_rate = MGN_MCS13; + break; + case DESC90_RATEMCS14: + ret_rate = MGN_MCS14; + break; + case DESC90_RATEMCS15: + ret_rate = MGN_MCS15; + break; + case DESC90_RATEMCS32: + ret_rate = (0x80|0x20); + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported " + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } return ret_rate; } -long -rtl8192_signal_scale_mapping(struct r8192_priv * priv, - long currsig - ) +long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; if (currsig >= 61 && currsig <= 100) - { retsig = 90 + ((currsig - 60) / 4); - } else if (currsig >= 41 && currsig <= 60) - { retsig = 78 + ((currsig - 40) / 2); - } else if (currsig >= 31 && currsig <= 40) - { retsig = 66 + (currsig - 30); - } else if (currsig >= 21 && currsig <= 30) - { retsig = 54 + (currsig - 20); - } else if (currsig >= 5 && currsig <= 20) - { retsig = 42 + (((currsig - 5) * 2) / 3); - } else if (currsig == 4) - { retsig = 36; - } else if (currsig == 3) - { retsig = 27; - } else if (currsig == 2) - { retsig = 18; - } else if (currsig == 1) - { retsig = 9; - } else - { retsig = currsig; - } return retsig; } -#define rx_hal_is_cck_rate(_pdrvinfo)\ - (_pdrvinfo->RxRate == DESC90_RATE1M ||\ +#define rx_hal_is_cck_rate(_pdrvinfo)\ + ((_pdrvinfo->RxRate == DESC90_RATE1M ||\ _pdrvinfo->RxRate == DESC90_RATE2M ||\ _pdrvinfo->RxRate == DESC90_RATE5_5M ||\ _pdrvinfo->RxRate == DESC90_RATE11M) &&\ - !_pdrvinfo->RxHT + !_pdrvinfo->RxHT) + void rtl8192_query_rxphystatus( - struct r8192_priv * priv, - struct rtllib_rx_stats * pstats, + struct r8192_priv *priv, + struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, struct rx_fwinfo *pdrvinfo, - struct rtllib_rx_stats * precord_stats, + struct rtllib_rx_stats *precord_stats, bool bpacket_match_bssid, bool bpacket_toself, bool bPacketBeacon, bool bToSelfBA ) { - struct phy_sts_ofdm_819xpci* pofdm_buf; - struct phy_sts_cck_819xpci * pcck_buf; - struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; - u8 *prxpkt; - u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all=0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi=0; - u8 is_cck_rate=0; - u8 rf_rx_num = 0; - - static u8 check_reg824 = 0; - static u32 reg824_bit9 = 0; + struct phy_sts_ofdm_819xpci *pofdm_buf; + struct phy_sts_cck_819xpci *pcck_buf; + struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc; + u8 *prxpkt; + u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all = 0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi = 0; + u8 is_cck_rate = 0; + u8 rf_rx_num = 0; + static u8 check_reg824; + static u32 reg824_bit9; priv->stats.numqry_phystatus++; - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); memset(precord_stats, 0, sizeof(struct rtllib_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = + bpacket_match_bssid; pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate; pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; - if (check_reg824 == 0) - { - reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, rFPGA0_XA_HSSIParameter2, 0x200); + if (check_reg824 == 0) { + reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, + rFPGA0_XA_HSSIParameter2, 0x200); check_reg824 = 1; } - prxpkt = (u8*)pdrvinfo; + prxpkt = (u8 *)pdrvinfo; prxpkt += sizeof(struct rx_fwinfo); @@ -1449,50 +1505,54 @@ void rtl8192_query_rxphystatus( precord_stats->RxMIMOSignalQuality[0] = -1; precord_stats->RxMIMOSignalQuality[1] = -1; - if (is_cck_rate) - { - + if (is_cck_rate) { u8 report; priv->stats.numqry_phystatusCCK++; - if (!reg824_bit9) - { + if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; report = report>>6; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x2: + rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x1: + rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x0: + rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); + break; } - } - else - { + } else { report = pcck_buf->cck_agc_rpt & 0x60; report = report>>5; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x0: - rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x2: + rx_pwr_all = -23 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x1: + rx_pwr_all = -11 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x0: + rx_pwr_all = -8 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; } } @@ -1500,15 +1560,12 @@ void rtl8192_query_rxphystatus( pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RecvSignalPower = rx_pwr_all; - if (bpacket_match_bssid) - { + if (bpacket_match_bssid) { u8 sq; - if (pstats->RxPWDBAll > 40) - { + if (pstats->RxPWDBAll > 40) { sq = 100; - }else - { + } else { sq = pcck_buf->sq_rpt; if (pcck_buf->sq_rpt > 64) @@ -1518,20 +1575,21 @@ void rtl8192_query_rxphystatus( else sq = ((64-sq) * 100) / 44; } - pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + pstats->SignalQuality = sq; + precord_stats->SignalQuality = sq; + pstats->RxMIMOSignalQuality[0] = sq; + precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = -1; + precord_stats->RxMIMOSignalQuality[1] = -1; } - } - else - { + } else { priv->stats.numqry_phystatusHT++; - for (i=RF90_PATH_A; ibrfpath_rxenable[i]) rf_rx_num++; - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * + 2) - 110; tmp_rxsnr = pofdm_buf->rxsnr_X[i]; rx_snrX = (char)(tmp_rxsnr); @@ -1542,284 +1600,294 @@ void rtl8192_query_rxphystatus( if (priv->brfpath_rxenable[i]) total_rssi += RSSI; - if (bpacket_match_bssid) - { - pstats->RxMIMOSignalStrength[i] =(u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; + if (bpacket_match_bssid) { + pstats->RxMIMOSignalStrength[i] = (u8) RSSI; + precord_stats->RxMIMOSignalStrength[i] = + (u8) RSSI; } } - rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; + rx_pwr_all = (((pofdm_buf->pwdb_all) >> 1) & 0x7f) - 106; pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RxPower = precord_stats->RxPower = rx_pwr_all; pstats->RecvSignalPower = rx_pwr_all; - if (pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && - pdrvinfo->RxRate<=DESC90_RATEMCS15) + if (pdrvinfo->RxHT && pdrvinfo->RxRate >= DESC90_RATEMCS8 && + pdrvinfo->RxRate <= DESC90_RATEMCS15) max_spatial_stream = 2; else max_spatial_stream = 1; - for (i=0; irxevm_X[i]; rx_evmX = (char)(tmp_rxevm); rx_evmX /= 2; evm = rtl819x_evm_dbtopercentage(rx_evmX); - if (bpacket_match_bssid) - { - if (i==0) - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + if (bpacket_match_bssid) { + if (i == 0) { + pstats->SignalQuality = (u8)(evm & + 0xff); + precord_stats->SignalQuality = (u8)(evm + & 0xff); + } + pstats->RxMIMOSignalQuality[i] = (u8)(evm & + 0xff); + precord_stats->RxMIMOSignalQuality[i] = (u8)(evm + & 0xff); } } rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *) + &rxsc_sgien_exflg; if (pdrvinfo->BW) priv->stats.received_bwtype[1+prxsc->rxsc]++; else priv->stats.received_bwtype[0]++; } - if (is_cck_rate) - { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)pwdb_all)); + if (is_cck_rate) { + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)pwdb_all)); - } - else - { + } else { if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)(total_rssi/=rf_rx_num))); + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)(total_rssi /= rf_rx_num))); } } -void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) +void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; - u32 nspatial_stream, tmp_val; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; - + u32 ij, tmp_val; + static u32 slide_rssi_index, slide_rssi_statistics; + static u32 slide_evm_index, slide_evm_statistics; + static u32 last_rssi, last_evm; + static u32 slide_beacon_adc_pwdb_index; + static u32 slide_beacon_adc_pwdb_statistics; + static u32 last_beacon_adc_pwdb; struct rtllib_hdr_3addr *hdr; - u16 sc ; - unsigned int frag,seq; + u16 sc; + unsigned int frag, seq; + hdr = (struct rtllib_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); - pcurrent_stats->Seq_Num = seq; - if (!pprevious_stats->bIsAMPDU) + curr_st->Seq_Num = seq; + if (!prev_st->bIsAMPDU) bcheck = true; - if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) - { + if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; priv->stats.slide_rssi_total -= last_rssi; } - priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; + priv->stats.slide_rssi_total += prev_st->SignalStrength; - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + priv->stats.slide_signal_strength[slide_rssi_index++] = + prev_st->SignalStrength; if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) slide_rssi_index = 0; tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; - priv->stats.signal_strength = rtl819x_translate_todbm(priv, (u8)tmp_val); - pcurrent_stats->rssi = priv->stats.signal_strength; - if (!pprevious_stats->bPacketMatchBSSID) - { - if (!pprevious_stats->bToSelfBA) + priv->stats.signal_strength = rtl819x_translate_todbm(priv, + (u8)tmp_val); + curr_st->rssi = priv->stats.signal_strength; + if (!prev_st->bPacketMatchBSSID) { + if (!prev_st->bToSelfBA) return; } if (!bcheck) return; - rtl819x_process_cck_rxpathsel(priv,pprevious_stats); + rtl819x_process_cck_rxpathsel(priv, prev_st); priv->stats.num_process_phyinfo++; - if (!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) - { - for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, rfpath)) + if (!prev_st->bIsCCK && prev_st->bPacketToSelf) { + for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) { + if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, + rfpath)) continue; - RT_TRACE(COMP_DBG,"Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath] = %d \n" ,pprevious_stats->RxMIMOSignalStrength[rfpath] ); - if (priv->stats.rx_rssi_percentage[rfpath] == 0) - { - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; - } - if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) - { + RT_TRACE(COMP_DBG, "Jacken -> pPreviousstats->RxMIMO" + "SignalStrength[rfpath] = %d\n", + prev_st->RxMIMOSignalStrength[rfpath]); + if (priv->stats.rx_rssi_percentage[rfpath] == 0) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); - priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; + prev_st->RxMIMOSignalStrength[rfpath]; } - else - { + if (prev_st->RxMIMOSignalStrength[rfpath] > + priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); + ((priv->stats.rx_rssi_percentage[rfpath] + * (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalStrength + [rfpath])) / (RX_SMOOTH); + priv->stats.rx_rssi_percentage[rfpath] = + priv->stats.rx_rssi_percentage[rfpath] + + 1; + } else { + priv->stats.rx_rssi_percentage[rfpath] = + ((priv->stats.rx_rssi_percentage[rfpath] * + (RX_SMOOTH-1)) + + (prev_st->RxMIMOSignalStrength[rfpath])) / + (RX_SMOOTH); } - RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); + RT_TRACE(COMP_DBG, "Jacken -> priv->RxStats.RxRSSI" + "Percentage[rfPath] = %d\n", + priv->stats.rx_rssi_percentage[rfpath]); } } - if (pprevious_stats->bPacketBeacon) - { - if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) - { - slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; + if (prev_st->bPacketBeacon) { + if (slide_beacon_adc_pwdb_statistics++ >= + PHY_Beacon_RSSI_SLID_WIN_MAX) { + slide_beacon_adc_pwdb_statistics = + PHY_Beacon_RSSI_SLID_WIN_MAX; + last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb + [slide_beacon_adc_pwdb_index]; priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; } - priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; + priv->stats.Slide_Beacon_Total += prev_st->RxPWDBAll; + priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = + prev_st->RxPWDBAll; slide_beacon_adc_pwdb_index++; if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; - if (pprevious_stats->RxPWDBAll >= 3) - pprevious_stats->RxPWDBAll -= 3; + prev_st->RxPWDBAll = priv->stats.Slide_Beacon_Total / + slide_beacon_adc_pwdb_statistics; + if (prev_st->RxPWDBAll >= 3) + prev_st->RxPWDBAll -= 3; } RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - pprevious_stats->bIsCCK? "CCK": "OFDM", - pprevious_stats->RxPWDBAll); + prev_st->bIsCCK ? "CCK" : "OFDM", + prev_st->RxPWDBAll); - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { if (priv->undecorated_smoothed_pwdb < 0) - { - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; - } - if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) - { + priv->undecorated_smoothed_pwdb = prev_st->RxPWDBAll; + if (prev_st->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); - priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; - } - else - { + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); + priv->undecorated_smoothed_pwdb + 1; + } else { + priv->undecorated_smoothed_pwdb = + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); } - rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); + rtl819x_update_rxsignalstatistics8190pci(priv, prev_st); } - if (pprevious_stats->SignalQuality == 0) - { - } - else - { - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ - if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ + if (prev_st->SignalQuality != 0) { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; - last_evm = priv->stats.slide_evm[slide_evm_index]; + last_evm = + priv->stats.slide_evm[slide_evm_index]; priv->stats.slide_evm_total -= last_evm; } - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + priv->stats.slide_evm_total += prev_st->SignalQuality; - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + priv->stats.slide_evm[slide_evm_index++] = + prev_st->SignalQuality; if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) slide_evm_index = 0; - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + tmp_val = priv->stats.slide_evm_total / + slide_evm_statistics; priv->stats.signal_quality = tmp_val; priv->stats.last_signal_strength_inpercent = tmp_val; } - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - for (nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) - { - if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) - { - if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) - { - priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; - } - priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); + if (prev_st->bPacketToSelf || + prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + for (ij = 0; ij < 2; ij++) { + if (prev_st->RxMIMOSignalQuality[ij] != -1) { + if (priv->stats.rx_evm_percentage[ij] == 0) + priv->stats.rx_evm_percentage[ij] = + prev_st->RxMIMOSignalQuality[ij]; + priv->stats.rx_evm_percentage[ij] = + ((priv->stats.rx_evm_percentage[ij] * + (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalQuality[ij])) / + (RX_SMOOTH); } } } } - } - -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, - struct sk_buff *skb, - struct rtllib_rx_stats * pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - bool bpacket_match_bssid, bpacket_toself; - bool bPacketBeacon=false; - struct rtllib_hdr_3addr *hdr; - bool bToSelfBA=false; - static struct rtllib_rx_stats previous_stats; - u16 fc,type; - - - u8* tmp_buf; - u8 *praddr; - - tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; - - hdr = (struct rtllib_hdr_3addr *)tmp_buf; - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - - bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && - (!compare_ether_addr(priv->rtllib->current_network.bssid, - (fc & RTLLIB_FCTL_TODS)? hdr->addr1 : - (fc & RTLLIB_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) - && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); - if (WLAN_FC_GET_FRAMETYPE(fc)== RTLLIB_STYPE_BEACON) - { - bPacketBeacon = true; - } - if (bpacket_match_bssid) - { - priv->stats.numpacket_matchbssid++; - } - if (bpacket_toself){ - priv->stats.numpacket_toself++; - } - rtl8192_process_phyinfo(priv, tmp_buf,&previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &previous_stats, bpacket_match_bssid, - bpacket_toself ,bPacketBeacon, bToSelfBA); - rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); -} - -void rtl8192_UpdateReceivedRateHistogramStatistics( - struct net_device *dev, - struct rtllib_rx_stats* pstats - ) +void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 rcvType=1; + bool bpacket_match_bssid, bpacket_toself; + bool bPacketBeacon = false; + struct rtllib_hdr_3addr *hdr; + bool bToSelfBA = false; + static struct rtllib_rx_stats previous_stats; + u16 fc, type; + u8 *tmp_buf; + u8 *praddr; + + tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; + + hdr = (struct rtllib_hdr_3addr *)tmp_buf; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + + bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && + (!compare_ether_addr(priv->rtllib-> + current_network.bssid, + (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : + (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) + && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); + bpacket_toself = bpacket_match_bssid & + (!compare_ether_addr(praddr, + priv->rtllib->dev->dev_addr)); + if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) + bPacketBeacon = true; + if (bpacket_match_bssid) + priv->stats.numpacket_matchbssid++; + if (bpacket_toself) + priv->stats.numpacket_toself++; + rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats); + rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, + &previous_stats, bpacket_match_bssid, + bpacket_toself, bPacketBeacon, bToSelfBA); + rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); +} + +void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, + struct rtllib_rx_stats *pstats) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 rcvType = 1; u32 rateIndex; u32 preamble_guardinterval; @@ -1833,45 +1901,104 @@ void rtl8192_UpdateReceivedRateHistogramStatistics( else preamble_guardinterval = 0; - switch (pstats->rate) - { - case MGN_1M: rateIndex = 0; break; - case MGN_2M: rateIndex = 1; break; - case MGN_5_5M: rateIndex = 2; break; - case MGN_11M: rateIndex = 3; break; - case MGN_6M: rateIndex = 4; break; - case MGN_9M: rateIndex = 5; break; - case MGN_12M: rateIndex = 6; break; - case MGN_18M: rateIndex = 7; break; - case MGN_24M: rateIndex = 8; break; - case MGN_36M: rateIndex = 9; break; - case MGN_48M: rateIndex = 10; break; - case MGN_54M: rateIndex = 11; break; - case MGN_MCS0: rateIndex = 12; break; - case MGN_MCS1: rateIndex = 13; break; - case MGN_MCS2: rateIndex = 14; break; - case MGN_MCS3: rateIndex = 15; break; - case MGN_MCS4: rateIndex = 16; break; - case MGN_MCS5: rateIndex = 17; break; - case MGN_MCS6: rateIndex = 18; break; - case MGN_MCS7: rateIndex = 19; break; - case MGN_MCS8: rateIndex = 20; break; - case MGN_MCS9: rateIndex = 21; break; - case MGN_MCS10: rateIndex = 22; break; - case MGN_MCS11: rateIndex = 23; break; - case MGN_MCS12: rateIndex = 24; break; - case MGN_MCS13: rateIndex = 25; break; - case MGN_MCS14: rateIndex = 26; break; - case MGN_MCS15: rateIndex = 27; break; - default: rateIndex = 28; break; + switch (pstats->rate) { + case MGN_1M: + rateIndex = 0; + break; + case MGN_2M: + rateIndex = 1; + break; + case MGN_5_5M: + rateIndex = 2; + break; + case MGN_11M: + rateIndex = 3; + break; + case MGN_6M: + rateIndex = 4; + break; + case MGN_9M: + rateIndex = 5; + break; + case MGN_12M: + rateIndex = 6; + break; + case MGN_18M: + rateIndex = 7; + break; + case MGN_24M: + rateIndex = 8; + break; + case MGN_36M: + rateIndex = 9; + break; + case MGN_48M: + rateIndex = 10; + break; + case MGN_54M: + rateIndex = 11; + break; + case MGN_MCS0: + rateIndex = 12; + break; + case MGN_MCS1: + rateIndex = 13; + break; + case MGN_MCS2: + rateIndex = 14; + break; + case MGN_MCS3: + rateIndex = 15; + break; + case MGN_MCS4: + rateIndex = 16; + break; + case MGN_MCS5: + rateIndex = 17; + break; + case MGN_MCS6: + rateIndex = 18; + break; + case MGN_MCS7: + rateIndex = 19; + break; + case MGN_MCS8: + rateIndex = 20; + break; + case MGN_MCS9: + rateIndex = 21; + break; + case MGN_MCS10: + rateIndex = 22; + break; + case MGN_MCS11: + rateIndex = 23; + break; + case MGN_MCS12: + rateIndex = 24; + break; + case MGN_MCS13: + rateIndex = 25; + break; + case MGN_MCS14: + rateIndex = 26; + break; + case MGN_MCS15: + rateIndex = 27; + break; + default: + rateIndex = 28; + break; } priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; priv->stats.received_rate_histogram[0][rateIndex]++; priv->stats.received_rate_histogram[rcvType][rateIndex]++; } -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats* stats, - struct rx_desc *pdesc, struct sk_buff* skb) +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1887,9 +2014,9 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->bShift = false; if (pdesc->CRC32) { - if (pdesc->Length <500) + if (pdesc->Length < 500) priv->stats.rxcrcerrmin++; - else if (pdesc->Length >1000) + else if (pdesc->Length > 1000) priv->stats.rxcrcerrmax++; else priv->stats.rxcrcerrmid++; @@ -1903,13 +2030,15 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift); - stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); + stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, + (u8)pDrvInfo->RxRate); stats->bShortPreamble = pDrvInfo->SPLCP; rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats); - stats->bIsAMPDU = (pDrvInfo->PartAggr==1); - stats->bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); + stats->bIsAMPDU = (pDrvInfo->PartAggr == 1); + stats->bFirstMPDU = (pDrvInfo->PartAggr == 1) && + (pDrvInfo->FirstAGGR == 1); stats->TimeStampLow = pDrvInfo->TSFL; stats->TimeStampHigh = read_nic_dword(dev, TSFR+4); @@ -1921,11 +2050,13 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->RxIs40MHzPacket = pDrvInfo->BW; - rtl8192_TranslateRxSignalStuff(dev,skb, stats, pdesc, pDrvInfo); + rtl8192_TranslateRxSignalStuff(dev, skb, stats, pdesc, + pDrvInfo); - if (pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); + if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1) + RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d," + " pDrvInfo->PartAggr = %d\n", + pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); skb_trim(skb, skb->len - 4/*sCrcLng*/); @@ -1948,36 +2079,24 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) OpMode = RT_OP_MODE_NO_LINK; priv->rtllib->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode); -#if 1 - if (!priv->rtllib->bSupportRemoteWakeUp) - { + if (!priv->rtllib->bSupportRemoteWakeUp) { u1bTmp = 0x0; write_nic_byte(dev, CMDR, u1bTmp); } -#else - cmd=read_nic_byte(dev,CMDR); - write_nic_byte(dev, CMDR, cmd &~ (CR_TE|CR_RE)); -#endif mdelay(20); - if (!reset) - { + if (!reset) { mdelay(150); priv->bHwRfOffAction = 2; - if (!priv->rtllib->bSupportRemoteWakeUp) - { - { - PHY_SetRtl8192eRfOff(dev); - } - ulRegRead = read_nic_dword(dev,CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; - write_nic_dword(dev,CPU_GEN, ulRegRead); - } - else - { + if (!priv->rtllib->bSupportRemoteWakeUp) { + PHY_SetRtl8192eRfOff(dev); + ulRegRead = read_nic_dword(dev, CPU_GEN); + ulRegRead |= CPU_GEN_SYSTEM_RESET; + write_nic_dword(dev, CPU_GEN, ulRegRead); + } else { write_nic_dword(dev, WFCRC0, 0xffffffff); write_nic_dword(dev, WFCRC1, 0xffffffff); write_nic_dword(dev, WFCRC2, 0xffffffff); @@ -1988,59 +2107,57 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) } } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_aggQ [i]); - } + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_aggQ[i]); skb_queue_purge(&priv->skb_queue); return; } -void rtl8192_update_ratr_table(struct net_device* dev) +void rtl8192_update_ratr_table(struct net_device *dev) { - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - u8* pMcsRate = ieee->dot11HTOperationalRateSet; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + u8 *pMcsRate = ieee->dot11HTOperationalRateSet; u32 ratr_value = 0; u8 rate_index = 0; - rtl8192_config_rate(dev, (u16*)(&ratr_value)); - ratr_value |= (*(u16*)(pMcsRate)) << 12; - switch (ieee->mode) - { - case IEEE_A: - ratr_value &= 0x00000FF0; - break; - case IEEE_B: - ratr_value &= 0x0000000F; - break; - case IEEE_G: - case IEEE_G|IEEE_B: - ratr_value &= 0x00000FF7; - break; - case IEEE_N_24G: - case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) - ratr_value &= 0x0007F007; - else{ - if (priv->rf_type == RF_1T2R) - ratr_value &= 0x000FF007; - else - ratr_value &= 0x0F81F007; - } - break; - default: - break; + rtl8192_config_rate(dev, (u16 *)(&ratr_value)); + ratr_value |= (*(u16 *)(pMcsRate)) << 12; + switch (ieee->mode) { + case IEEE_A: + ratr_value &= 0x00000FF0; + break; + case IEEE_B: + ratr_value &= 0x0000000F; + break; + case IEEE_G: + case IEEE_G|IEEE_B: + ratr_value &= 0x00000FF7; + break; + case IEEE_N_24G: + case IEEE_N_5G: + if (ieee->pHTInfo->PeerMimoPs == 0) { + ratr_value &= 0x0007F007; + } else { + if (priv->rf_type == RF_1T2R) + ratr_value &= 0x000FF007; + else + ratr_value &= 0x0F81F007; + } + break; + default: + break; } ratr_value &= 0x0FFFFFFF; - if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ + if (ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI40MHz) ratr_value |= 0x80000000; - }else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ + else if (!ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI20MHz) ratr_value |= 0x80000000; - } write_nic_dword(dev, RATR0+rate_index*4, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -2077,17 +2194,19 @@ rtl8192_InitializeVariables(struct net_device *dev) RCR_AAP | ((u32)7<irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |\ - IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |\ - IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |\ - IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + priv->irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | + IMR_BEDOK | IMR_BKDOK | IMR_HCCADOK | + IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | + IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | + IMR_RDU | IMR_RXFOVW | IMR_TXFOVW | + IMR_BcnInt | IMR_TBDOK | IMR_TBDER); priv->MidHighPwrTHR_L1 = 0x3B; priv->MidHighPwrTHR_L2 = 0x40; priv->PwrDomainProtect = false; - priv->bfirst_after_down = 0; + priv->bfirst_after_down = 0; } void rtl8192_EnableInterrupt(struct net_device *dev) @@ -2095,7 +2214,7 @@ void rtl8192_EnableInterrupt(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->irq_enabled = 1; - write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); + write_nic_dword(dev, INTA_MASK, priv->irq_mask[0]); } @@ -2103,7 +2222,7 @@ void rtl8192_DisableInterrupt(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev,INTA_MASK,0); + write_nic_dword(dev, INTA_MASK, 0); priv->irq_enabled = 0; } @@ -2118,18 +2237,21 @@ void rtl8192_ClearInterrupt(struct net_device *dev) void rtl8192_enable_rx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev, RDQDA,priv->rx_ring_dma[RX_MPDU_QUEUE]); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + write_nic_dword(dev, RDQDA, priv->rx_ring_dma[RX_MPDU_QUEUE]); } -u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +static const u32 TX_DESC_BASE[] = { + BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA +}; + void rtl8192_enable_tx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 i; - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); } @@ -2138,16 +2260,17 @@ void rtl8192_beacon_disable(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u32 reg; - reg = read_nic_dword(priv->rtllib->dev,INTA_MASK); + reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); } -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb) { - *p_inta = read_nic_dword(dev, ISR) ; - write_nic_dword(dev,ISR,*p_inta); + *p_inta = read_nic_dword(dev, ISR); + write_nic_dword(dev, ISR, *p_inta); } bool rtl8192_HalRxCheckStuck(struct net_device *dev) @@ -2155,61 +2278,56 @@ bool rtl8192_HalRxCheckStuck(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u16 RegRxCounter = read_nic_word(dev, 0x130); bool bStuck = false; - static u8 rx_chk_cnt = 0; + static u8 rx_chk_cnt; u32 SlotIndex = 0, TotalRxStuckCount = 0; u8 i; u8 SilentResetRxSoltNum = 4; - RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n", - __func__, RegRxCounter,priv->RxCounter); + RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d, RxCounter is %d\n", + __func__, RegRxCounter, priv->RxCounter); rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) - { + if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { rx_chk_cnt = 0; - } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5)) && - (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) || - ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)))) { - if (rx_chk_cnt < 2) { + } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5)) + && (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) + || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M)))) { + if (rx_chk_cnt < 2) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M))) && priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { - if (rx_chk_cnt < 4) { + if (rx_chk_cnt < 4) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else { - if (rx_chk_cnt < 8) { + if (rx_chk_cnt < 8) return bStuck; - } else { + else rx_chk_cnt = 0; - } } SlotIndex = (priv->SilentResetRxSlotIndex++)%SilentResetRxSoltNum; - if (priv->RxCounter==RegRxCounter) - { + if (priv->RxCounter == RegRxCounter) { priv->SilentResetRxStuckEvent[SlotIndex] = 1; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) + for (i = 0; i < SilentResetRxSoltNum; i++) TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; - if (TotalRxStuckCount == SilentResetRxSoltNum) - { - bStuck = true; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) - TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + if (TotalRxStuckCount == SilentResetRxSoltNum) { + bStuck = true; + for (i = 0; i < SilentResetRxSoltNum; i++) + TotalRxStuckCount += + priv->SilentResetRxStuckEvent[i]; } @@ -2226,10 +2344,10 @@ bool rtl8192_HalTxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool bStuck = false; - u16 RegTxCounter = read_nic_word(dev, 0x128); + u16 RegTxCounter = read_nic_word(dev, 0x128); RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", - __func__,RegTxCounter,priv->TxCounter); + __func__, RegTxCounter, priv->TxCounter); if (priv->TxCounter == RegTxCounter) bStuck = true; @@ -2244,18 +2362,19 @@ bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP | + SEC_ALG_TKIP))) { return false; } else { return true; } } -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev) { - bool Reval; - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + bool Reval; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->bHalfWirelessN24GMode == true) Reval = true; @@ -2269,8 +2388,9 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) { u8 tmp_Short; - tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); - if (TxHT==1 && TxRate != DESC90_RATEMCS15) + tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : + ((tcb_desc->bUseShortPreamble) ? 1 : 0); + if (TxHT == 1 && TxRate != DESC90_RATEMCS15) tmp_Short = 0; return tmp_Short; @@ -2278,12 +2398,12 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) void ActUpdateChannelAccessSetting( - struct net_device* dev, + struct net_device *dev, enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting ) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); return; @@ -2295,7 +2415,8 @@ ActUpdateChannelAccessSetting( else SIFS_Timer = priv->SifsTime; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SIFS, (u8*)&SIFS_Timer); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_SIFS, + (u8 *)&SIFS_Timer); } } From 99a1f99f0f86d84f44bad3f6acefb9077d4740a2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 26 Jul 2011 15:03:23 -0500 Subject: [PATCH 0521/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part III Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.h | 30 +- drivers/staging/rtl8192e/r8192E_firmware.c | 154 +-- drivers/staging/rtl8192e/r8192E_firmware.h | 4 +- drivers/staging/rtl8192e/r8192E_hw.h | 76 +- drivers/staging/rtl8192e/r8192E_hwimg.c | 1043 ++++++++++---------- 5 files changed, 667 insertions(+), 640 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 4f31307c1fa..b9b3b52f912 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -28,11 +28,12 @@ #include "r8190P_def.h" u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc); -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev); +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev); bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev); bool rtl8192_HalTxCheckStuck(struct net_device *dev); bool rtl8192_HalRxCheckStuck(struct net_device *dev); -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb); +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb); void rtl8192_enable_rx(struct net_device *dev); void rtl8192_enable_tx(struct net_device *dev); void rtl8192_EnableInterrupt(struct net_device *dev); @@ -40,17 +41,22 @@ void rtl8192_DisableInterrupt(struct net_device *dev); void rtl8192_ClearInterrupt(struct net_device *dev); void rtl8192_InitializeVariables(struct net_device *dev); void rtl8192e_start_beacon(struct net_device *dev); -void rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val); -void rtl8192_get_eeprom_size(struct net_device* dev); +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val); +void rtl8192_get_eeprom_size(struct net_device *dev); bool rtl8192_adapter_start(struct net_device *dev); void rtl8192_link_change(struct net_device *dev); -void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, - struct sk_buff* skb); -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb); -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, - struct rx_desc *pdesc, struct sk_buff* skb); +void rtl8192_AllowAllDestAddr(struct net_device *dev, bool bAllowAllDA, + bool WriteIntoReg); +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, + struct sk_buff *skb); +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff *skb); +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); void rtl8192_halt_adapter(struct net_device *dev, bool reset); -void rtl8192_update_ratr_table(struct net_device* dev); +void rtl8192_update_ratr_table(struct net_device *dev); #endif diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index d284d422b64..c2689993530 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -28,10 +28,12 @@ extern void firmware_init_param(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; - pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); + pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD( + MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) +bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -59,46 +61,48 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff } skb = dev_alloc_skb(frag_length + 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastIniPkt; seg_ptr = skb->data; - for (i=0 ; i < frag_length; i+=4) { - *seg_ptr++ = ((i+0)txbuf_size= (u16)i; + tcb_desc->txbuf_size = (u16)i; skb_put(skb, i); - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE, "===================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) || + (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================> tx " + "full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ + [tcb_desc->queue_index], skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); return rt_status; } -bool -fwSendNullPacket( - struct net_device *dev, - u32 Length -) +bool fwSendNullPacket(struct net_device *dev, u32 Length) { bool rtStatus = true; struct r8192_priv *priv = rtllib_priv(dev); @@ -108,23 +112,25 @@ fwSendNullPacket( bool bLastInitPacket = false; - skb = dev_alloc_skb(Length+ 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + skb = dev_alloc_skb(Length + 4); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastInitPacket; ptr_buf = skb_put(skb, Length); - memset(ptr_buf,0,Length); - tcb_desc->txbuf_size= (u16)Length; + memset(ptr_buf, 0, Length); + tcb_desc->txbuf_size = (u16)Length; - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"===================NULL packet================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> + queue_index])) || (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" + "========> tx full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], + skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } write_nic_byte(dev, TPPoll, TPPoll_CQ); @@ -142,7 +148,7 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status & CPU_GEN_PUT_CODE_OK) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) { @@ -153,7 +159,8 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) } CPU_status = read_nic_dword(dev, CPU_GEN); - write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); + write_nic_byte(dev, CPU_GEN, + (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); mdelay(1); timeout = jiffies + MSECS(200); @@ -161,14 +168,13 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_BOOT_RDY) break; - msleep(2); + mdelay(2); } - if (!(CPU_status&CPU_GEN_BOOT_RDY)) { + if (!(CPU_status&CPU_GEN_BOOT_RDY)) goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - } else { + else RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); - } return rt_status; @@ -190,7 +196,7 @@ bool CPUcheck_firmware_ready(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_FIRM_RDY) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_FIRM_RDY)) @@ -207,7 +213,8 @@ CPUCheckFirmwareReady_Fail: } -inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) +static bool firmware_check_ready(struct net_device *dev, + u8 load_fw_status) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -222,11 +229,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; rt_status = CPUcheck_maincodeok_turnonCPU(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnonCPU fail!\n"); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnon" + "CPU fail!\n"); break; @@ -235,11 +242,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu mdelay(1); rt_status = CPUcheck_firmware_ready(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_5_READY; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail" + "(%d)!\n", rt_status); break; default: @@ -273,53 +280,64 @@ bool init_firmware(struct net_device *dev) RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); - if (pfirmware->firmware_status == FW_STATUS_0_INIT ) { + if (pfirmware->firmware_status == FW_STATUS_0_INIT) { rst_opt = OPT_SYSTEM_RESET; starting_state = FW_INIT_STEP0_BOOT; - }else if (pfirmware->firmware_status == FW_STATUS_5_READY) { + } else if (pfirmware->firmware_status == FW_STATUS_5_READY) { rst_opt = OPT_FIRMWARE_RESET; starting_state = FW_INIT_STEP2_DATA; - }else { - RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n"); + } else { + RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined" + " firmware state\n"); } priv->firmware_source = FW_SOURCE_IMG_FILE; - for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { + for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; + init_step++) { if (rst_opt == OPT_SYSTEM_RESET) { switch (priv->firmware_source) { case FW_SOURCE_IMG_FILE: { if (pfirmware->firmware_buf_size[init_step] == 0) { const char *fw_name[3] = { "RTL8192E/boot.img", - "RTL8192E/main.img", - "RTL8192E/data.img" - }; + "RTL8192E/main.img", + "RTL8192E/data.img" + }; const struct firmware *fw_entry; int rc; - rc = request_firmware(&fw_entry, fw_name[init_step],&priv->pdev->dev); - if (rc < 0 ) { - RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); + rc = request_firmware(&fw_entry, + fw_name[init_step], &priv->pdev->dev); + if (rc < 0) { + RT_TRACE(COMP_FIRMWARE, "request firm" + "ware fail!\n"); goto download_firmware_fail; } - if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, "img file size exceed the container struct buffer fail!\n"); + if (fw_entry->size > + sizeof(pfirmware->firmware_buf[init_step])) { + RT_TRACE(COMP_FIRMWARE, "img file size " + "exceed the container struct " + "buffer fail!\n"); goto download_firmware_fail; } if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size; + memcpy(pfirmware->firmware_buf[init_step], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size; } else { - memset(pfirmware->firmware_buf[init_step],0,128); - memcpy(&pfirmware->firmware_buf[init_step][128],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size+128; + memset(pfirmware->firmware_buf[init_step], + 0, 128); + memcpy(&pfirmware->firmware_buf[init_step][128], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size + 128; } - if (rst_opt == OPT_SYSTEM_RESET) { + if (rst_opt == OPT_SYSTEM_RESET) release_firmware(fw_entry); - } } mapped_file = pfirmware->firmware_buf[init_step]; file_length = pfirmware->firmware_buf_size[init_step]; @@ -344,7 +362,7 @@ bool init_firmware(struct net_device *dev) file_length = pfirmware->firmware_buf_size[init_step]; } - rt_status = fw_download_code(dev,mapped_file,file_length); + rt_status = fw_download_code(dev, mapped_file, file_length); if (rt_status != true) { goto download_firmware_fail; } diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index c7d4c994a29..caa87883310 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -21,7 +21,7 @@ #define RTL8190_CPU_START_OFFSET 0x80 -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8) enum firmware_init_step { FW_INIT_STEP0_BOOT = 0, @@ -63,7 +63,7 @@ struct rt_firmware { u16 cmdpacket_frag_thresold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 #define MAX_FW_INIT_STEP 3 - u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; + u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; u16 firmware_buf_size[MAX_FW_INIT_STEP]; }; diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 9a3c4084faf..43c3fb859d1 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -109,7 +109,7 @@ enum _RTL8192Pci_HW { #define MULRW_SHIFT 3 #define MXDMA2_RX_SHIFT 4 #define MXDMA2_TX_SHIFT 0 - PMR = 0x00c, + PMR = 0x00c, EPROM_CMD = 0x00e, #define EPROM_CMD_RESERVED_MASK BIT5 #define EPROM_CMD_9356SEL BIT4 @@ -141,7 +141,8 @@ enum _RTL8192Pci_HW { SIFS = 0x03E, TCR = 0x040, RCR = 0x044, -#define RCR_FILTER_MASK (BIT0|BIT1|BIT2|BIT3|BIT5|BIT12|BIT18|BIT19|BIT20|BIT21|BIT22|BIT23) +#define RCR_FILTER_MASK (BIT0 | BIT1 | BIT2 | BIT3 | BIT5 | BIT12 | \ + BIT18 | BIT19 | BIT20 | BIT21 | BIT22 | BIT23) #define RCR_ONLYERLPKT BIT31 #define RCR_ENCS2 BIT30 #define RCR_ENCS1 BIT29 @@ -337,9 +338,9 @@ enum _RTL8192Pci_HW { NHM_RPI_COUNTER5 = 0x269, NHM_RPI_COUNTER6 = 0x26A, NHM_RPI_COUNTER7 = 0x26B, - WFCRC0 = 0x2f0, - WFCRC1 = 0x2f4, - WFCRC2 = 0x2f8, + WFCRC0 = 0x2f0, + WFCRC1 = 0x2f4, + WFCRC2 = 0x2f8, BW_OPMODE = 0x300, #define BW_OPMODE_11J BIT0 @@ -365,32 +366,32 @@ enum _RTL8192Pci_HW { #define RETRY_LIMIT_LONG_SHIFT 0 TSFR = 0x308, RRSR = 0x310, -#define RRSR_RSC_OFFSET 21 +#define RRSR_RSC_OFFSET 21 #define RRSR_SHORT_OFFSET 23 #define RRSR_RSC_DUPLICATE 0x600000 #define RRSR_RSC_UPSUBCHNL 0x400000 -#define RRSR_RSC_LOWSUBCHNL 0x200000 -#define RRSR_SHORT 0x800000 -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 +#define RRSR_RSC_LOWSUBCHNL 0x200000 +#define RRSR_SHORT 0x800000 +#define RRSR_1M BIT0 +#define RRSR_2M BIT1 +#define RRSR_5_5M BIT2 +#define RRSR_11M BIT3 +#define RRSR_6M BIT4 +#define RRSR_9M BIT5 +#define RRSR_12M BIT6 +#define RRSR_18M BIT7 +#define RRSR_24M BIT8 +#define RRSR_36M BIT9 +#define RRSR_48M BIT10 +#define RRSR_54M BIT11 +#define RRSR_MCS0 BIT12 +#define RRSR_MCS1 BIT13 +#define RRSR_MCS2 BIT14 +#define RRSR_MCS3 BIT15 +#define RRSR_MCS4 BIT16 +#define RRSR_MCS5 BIT17 +#define RRSR_MCS6 BIT18 +#define RRSR_MCS7 BIT19 #define BRSR_AckShortPmb BIT23 UFWP = 0x318, RATR0 = 0x320, @@ -422,12 +423,15 @@ enum _RTL8192Pci_HW { #define RATR_MCS13 0x02000000 #define RATR_MCS14 0x04000000 #define RATR_MCS15 0x08000000 -#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M -#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|RATR_36M|RATR_48M|RATR_54M -#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 | \ - RATR_MCS4|RATR_MCS5|RATR_MCS6 |RATR_MCS7 -#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11| \ - RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15 +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | \ + RATR_MCS6 | RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ + RATR_MCS14|RATR_MCS15) DRIVER_RSSI = 0x32c, @@ -442,8 +446,8 @@ enum _RTL8192Pci_HW { #define GPO 0x109 #define GPE 0x10a -#define HWSET_MAX_SIZE_92S 128 +#define HWSET_MAX_SIZE_92S 128 -#define ANAPAR_FOR_8192PciE 0x17 +#define ANAPAR_FOR_8192PciE 0x17 #endif diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.c b/drivers/staging/rtl8192e/r8192E_hwimg.c index 1b42f7335d9..08e7dbb6694 100644 --- a/drivers/staging/rtl8192e/r8192E_hwimg.c +++ b/drivers/staging/rtl8192e/r8192E_hwimg.c @@ -2791,547 +2791,546 @@ u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = { 0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88, }; -u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = { -0x0, }; +u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = {0x0,}; u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = { -0x800,0x00000000, -0x804,0x00000001, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x008514d0, -0x818,0x00000040, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x6870e36c, -0x884,0xe3573600, -0x888,0x4260c340, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x31121311, -0xa00,0x00d0c7d8, -0xa04,0x811f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x00005433, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08800000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x465c52cd, -0xc38,0x497f5994, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x20000000, -0xc88,0x40000100, -0xc8c,0x20200000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000750, -0xd04,0x00000403, -0xd08,0x0000907f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x04032064, -0xe00,0x161a1a1a, -0xe04,0x12121416, -0xe08,0x00001800, -0xe0c,0x00000000, -0xe10,0x161a1a1a, -0xe14,0x12121416, -0xe18,0x161a1a1a, -0xe1c,0x12121416, + 0x800, 0x00000000, + 0x804, 0x00000001, + 0x808, 0x0000fc00, + 0x80c, 0x0000001c, + 0x810, 0x801010aa, + 0x814, 0x008514d0, + 0x818, 0x00000040, + 0x81c, 0x00000000, + 0x820, 0x00000004, + 0x824, 0x00690000, + 0x828, 0x00000004, + 0x82c, 0x00e90000, + 0x830, 0x00000004, + 0x834, 0x00690000, + 0x838, 0x00000004, + 0x83c, 0x00e90000, + 0x840, 0x00000000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84c, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x65a965a9, + 0x85c, 0x65a965a9, + 0x860, 0x001f0010, + 0x864, 0x007f0010, + 0x868, 0x001f0010, + 0x86c, 0x007f0010, + 0x870, 0x0f100f70, + 0x874, 0x0f100f70, + 0x878, 0x00000000, + 0x87c, 0x00000000, + 0x880, 0x6870e36c, + 0x884, 0xe3573600, + 0x888, 0x4260c340, + 0x88c, 0x0000ff00, + 0x890, 0x00000000, + 0x894, 0xfffffffe, + 0x898, 0x4c42382f, + 0x89c, 0x00656056, + 0x8b0, 0x00000000, + 0x8e0, 0x00000000, + 0x8e4, 0x00000000, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90c, 0x31121311, + 0xa00, 0x00d0c7d8, + 0xa04, 0x811f0008, + 0xa08, 0x80cd8300, + 0xa0c, 0x2e62740f, + 0xa10, 0x95009b78, + 0xa14, 0x11145008, + 0xa18, 0x00881117, + 0xa1c, 0x89140fa0, + 0xa20, 0x1a1b0000, + 0xa24, 0x090e1317, + 0xa28, 0x00000204, + 0xa2c, 0x00000000, + 0xc00, 0x00000040, + 0xc04, 0x00005433, + 0xc08, 0x000000e4, + 0xc0c, 0x6c6c6c6c, + 0xc10, 0x08800000, + 0xc14, 0x40000100, + 0xc18, 0x08000000, + 0xc1c, 0x40000100, + 0xc20, 0x08000000, + 0xc24, 0x40000100, + 0xc28, 0x08000000, + 0xc2c, 0x40000100, + 0xc30, 0x6de9ac44, + 0xc34, 0x465c52cd, + 0xc38, 0x497f5994, + 0xc3c, 0x0a969764, + 0xc40, 0x1f7c403f, + 0xc44, 0x000100b7, + 0xc48, 0xec020000, + 0xc4c, 0x00000300, + 0xc50, 0x69543420, + 0xc54, 0x433c0094, + 0xc58, 0x69543420, + 0xc5c, 0x433c0094, + 0xc60, 0x69543420, + 0xc64, 0x433c0094, + 0xc68, 0x69543420, + 0xc6c, 0x433c0094, + 0xc70, 0x2c7f000d, + 0xc74, 0x0186175b, + 0xc78, 0x0000001f, + 0xc7c, 0x00b91612, + 0xc80, 0x40000100, + 0xc84, 0x20000000, + 0xc88, 0x40000100, + 0xc8c, 0x20200000, + 0xc90, 0x40000100, + 0xc94, 0x00000000, + 0xc98, 0x40000100, + 0xc9c, 0x00000000, + 0xca0, 0x00492492, + 0xca4, 0x00000000, + 0xca8, 0x00000000, + 0xcac, 0x00000000, + 0xcb0, 0x00000000, + 0xcb4, 0x00000000, + 0xcb8, 0x00000000, + 0xcbc, 0x00492492, + 0xcc0, 0x00000000, + 0xcc4, 0x00000000, + 0xcc8, 0x00000000, + 0xccc, 0x00000000, + 0xcd0, 0x00000000, + 0xcd4, 0x00000000, + 0xcd8, 0x64b22427, + 0xcdc, 0x00766932, + 0xce0, 0x00222222, + 0xd00, 0x00000750, + 0xd04, 0x00000403, + 0xd08, 0x0000907f, + 0xd0c, 0x00000001, + 0xd10, 0xa0633333, + 0xd14, 0x33333c63, + 0xd18, 0x6a8f5b6b, + 0xd1c, 0x00000000, + 0xd20, 0x00000000, + 0xd24, 0x00000000, + 0xd28, 0x00000000, + 0xd2c, 0xcc979975, + 0xd30, 0x00000000, + 0xd34, 0x00000000, + 0xd38, 0x00000000, + 0xd3c, 0x00027293, + 0xd40, 0x00000000, + 0xd44, 0x00000000, + 0xd48, 0x00000000, + 0xd4c, 0x00000000, + 0xd50, 0x6437140a, + 0xd54, 0x024dbd02, + 0xd58, 0x00000000, + 0xd5c, 0x04032064, + 0xe00, 0x161a1a1a, + 0xe04, 0x12121416, + 0xe08, 0x00001800, + 0xe0c, 0x00000000, + 0xe10, 0x161a1a1a, + 0xe14, 0x12121416, + 0xe18, 0x161a1a1a, + 0xe1c, 0x12121416, }; u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000100, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x00000ee0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x009, 0x000007f0, + 0x00a, 0x000009d0, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x00f, 0x00000990, + 0x012, 0x00000806, + 0x014, 0x000005ab, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000f80, + 0x01b, 0x00000f5e, + 0x01c, 0x00000008, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x01f, 0x00000000, + 0x020, 0x000001a5, + 0x01f, 0x00000001, + 0x020, 0x00000165, + 0x01f, 0x00000002, + 0x020, 0x000000c6, + 0x01f, 0x00000003, + 0x020, 0x00000086, + 0x01f, 0x00000004, + 0x020, 0x00000046, + 0x01f, 0x00000005, + 0x020, 0x000001e6, + 0x01f, 0x00000006, + 0x020, 0x000001a6, + 0x01f, 0x00000007, + 0x020, 0x00000166, + 0x01f, 0x00000008, + 0x020, 0x000000c7, + 0x01f, 0x00000009, + 0x020, 0x00000087, + 0x01f, 0x0000000a, + 0x020, 0x000000f7, + 0x01f, 0x0000000b, + 0x020, 0x000000d7, + 0x01f, 0x0000000c, + 0x020, 0x000000b7, + 0x01f, 0x0000000d, + 0x020, 0x00000097, + 0x01f, 0x0000000e, + 0x020, 0x00000077, + 0x01f, 0x0000000f, + 0x020, 0x00000057, + 0x01f, 0x00000010, + 0x020, 0x00000037, + 0x01f, 0x00000011, + 0x020, 0x000000fb, + 0x01f, 0x00000012, + 0x020, 0x000000db, + 0x01f, 0x00000013, + 0x020, 0x000000bb, + 0x01f, 0x00000014, + 0x020, 0x000000ff, + 0x01f, 0x00000015, + 0x020, 0x000000e3, + 0x01f, 0x00000016, + 0x020, 0x000000c3, + 0x01f, 0x00000017, + 0x020, 0x000000a3, + 0x01f, 0x00000018, + 0x020, 0x00000083, + 0x01f, 0x00000019, + 0x020, 0x00000063, + 0x01f, 0x0000001a, + 0x020, 0x00000043, + 0x01f, 0x0000001b, + 0x020, 0x00000023, + 0x01f, 0x0000001c, + 0x020, 0x00000003, + 0x01f, 0x0000001d, + 0x020, 0x000001e3, + 0x01f, 0x0000001e, + 0x020, 0x000001c3, + 0x01f, 0x0000001f, + 0x020, 0x000001a3, + 0x01f, 0x00000020, + 0x020, 0x00000183, + 0x01f, 0x00000021, + 0x020, 0x00000163, + 0x01f, 0x00000022, + 0x020, 0x00000143, + 0x01f, 0x00000023, + 0x020, 0x00000123, + 0x01f, 0x00000024, + 0x020, 0x00000103, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x00b, 0x000001ba, + 0x02c, 0x000003d7, + 0x02d, 0x00000ff0, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x007, 0x00000080, + 0x002, 0x0000088d, + 0x0fe, 0x00000000, + 0x0fe, 0x00000000, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x000, 0x000000bf, + 0x00d, 0x0000001f, + 0x00d, 0x00000c9f, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000100, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x000006e0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x000, 0x000000b7, + 0x00a, 0x00000850, + 0x000, 0x000000bf, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000e00, + 0x01b, 0x00000f5e, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x00b, 0x000001ba, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x00d, 0x00000ccc, + 0x000, 0x000000bf, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciEMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000100, + 0x03c, 0xffff0000, 0x00000f0f, + 0x340, 0xffffffff, 0x161a1a1a, + 0x344, 0xffffffff, 0x12121416, + 0x348, 0x0000ffff, 0x00001818, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000100, }; u32 Rtl8192PciEMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0xe00,0xffffffff,0x06090909, -0xe04,0xffffffff,0x00030306, -0xe08,0x0000ff00,0x00000000, -0xe10,0xffffffff,0x0a0c0d0f, -0xe14,0xffffffff,0x06070809, -0xe18,0xffffffff,0x0a0c0d0f, -0xe1c,0xffffffff,0x06070809, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, + 0x03c, 0xffff0000, 0x00000f0f, + 0xe00, 0xffffffff, 0x06090909, + 0xe04, 0xffffffff, 0x00030306, + 0xe08, 0x0000ff00, 0x00000000, + 0xe10, 0xffffffff, 0x0a0c0d0f, + 0xe14, 0xffffffff, 0x06070809, + 0xe18, 0xffffffff, 0x0a0c0d0f, + 0xe1c, 0xffffffff, 0x06070809, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000800, }; u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7d040001, -0xc78,0x7d050001, -0xc78,0x7c060001, -0xc78,0x7b070001, -0xc78,0x7a080001, -0xc78,0x79090001, -0xc78,0x780a0001, -0xc78,0x770b0001, -0xc78,0x760c0001, -0xc78,0x750d0001, -0xc78,0x740e0001, -0xc78,0x730f0001, -0xc78,0x72100001, -0xc78,0x71110001, -0xc78,0x70120001, -0xc78,0x6f130001, -0xc78,0x6e140001, -0xc78,0x6d150001, -0xc78,0x6c160001, -0xc78,0x6b170001, -0xc78,0x6a180001, -0xc78,0x69190001, -0xc78,0x681a0001, -0xc78,0x671b0001, -0xc78,0x661c0001, -0xc78,0x651d0001, -0xc78,0x641e0001, -0xc78,0x491f0001, -0xc78,0x48200001, -0xc78,0x47210001, -0xc78,0x46220001, -0xc78,0x45230001, -0xc78,0x44240001, -0xc78,0x43250001, -0xc78,0x28260001, -0xc78,0x27270001, -0xc78,0x26280001, -0xc78,0x25290001, -0xc78,0x242a0001, -0xc78,0x232b0001, -0xc78,0x222c0001, -0xc78,0x212d0001, -0xc78,0x202e0001, -0xc78,0x0a2f0001, -0xc78,0x08300001, -0xc78,0x06310001, -0xc78,0x05320001, -0xc78,0x04330001, -0xc78,0x03340001, -0xc78,0x02350001, -0xc78,0x01360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7d440001, -0xc78,0x7d450001, -0xc78,0x7c460001, -0xc78,0x7b470001, -0xc78,0x7a480001, -0xc78,0x79490001, -0xc78,0x784a0001, -0xc78,0x774b0001, -0xc78,0x764c0001, -0xc78,0x754d0001, -0xc78,0x744e0001, -0xc78,0x734f0001, -0xc78,0x72500001, -0xc78,0x71510001, -0xc78,0x70520001, -0xc78,0x6f530001, -0xc78,0x6e540001, -0xc78,0x6d550001, -0xc78,0x6c560001, -0xc78,0x6b570001, -0xc78,0x6a580001, -0xc78,0x69590001, -0xc78,0x685a0001, -0xc78,0x675b0001, -0xc78,0x665c0001, -0xc78,0x655d0001, -0xc78,0x645e0001, -0xc78,0x495f0001, -0xc78,0x48600001, -0xc78,0x47610001, -0xc78,0x46620001, -0xc78,0x45630001, -0xc78,0x44640001, -0xc78,0x43650001, -0xc78,0x28660001, -0xc78,0x27670001, -0xc78,0x26680001, -0xc78,0x25690001, -0xc78,0x246a0001, -0xc78,0x236b0001, -0xc78,0x226c0001, -0xc78,0x216d0001, -0xc78,0x206e0001, -0xc78,0x0a6f0001, -0xc78,0x08700001, -0xc78,0x06710001, -0xc78,0x05720001, -0xc78,0x04730001, -0xc78,0x03740001, -0xc78,0x02750001, -0xc78,0x01760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x2e00001e, -0xc78,0x2e01001e, -0xc78,0x2e02001e, -0xc78,0x2e03001e, -0xc78,0x2e04001e, -0xc78,0x2e05001e, -0xc78,0x3006001e, -0xc78,0x3407001e, -0xc78,0x3908001e, -0xc78,0x3c09001e, -0xc78,0x3f0a001e, -0xc78,0x420b001e, -0xc78,0x440c001e, -0xc78,0x450d001e, -0xc78,0x460e001e, -0xc78,0x460f001e, -0xc78,0x4710001e, -0xc78,0x4811001e, -0xc78,0x4912001e, -0xc78,0x4a13001e, -0xc78,0x4b14001e, -0xc78,0x4b15001e, -0xc78,0x4c16001e, -0xc78,0x4d17001e, -0xc78,0x4e18001e, -0xc78,0x4f19001e, -0xc78,0x4f1a001e, -0xc78,0x501b001e, -0xc78,0x511c001e, -0xc78,0x521d001e, -0xc78,0x521e001e, -0xc78,0x531f001e, -0xc78,0x5320001e, -0xc78,0x5421001e, -0xc78,0x5522001e, -0xc78,0x5523001e, -0xc78,0x5624001e, -0xc78,0x5725001e, -0xc78,0x5726001e, -0xc78,0x5827001e, -0xc78,0x5828001e, -0xc78,0x5929001e, -0xc78,0x592a001e, -0xc78,0x5a2b001e, -0xc78,0x5b2c001e, -0xc78,0x5c2d001e, -0xc78,0x5c2e001e, -0xc78,0x5d2f001e, -0xc78,0x5e30001e, -0xc78,0x5f31001e, -0xc78,0x6032001e, -0xc78,0x6033001e, -0xc78,0x6134001e, -0xc78,0x6235001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6438001e, -0xc78,0x6539001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x673c001e, -0xc78,0x683d001e, -0xc78,0x693e001e, -0xc78,0x6a3f001e, + 0xc78, 0x7d000001, + 0xc78, 0x7d010001, + 0xc78, 0x7d020001, + 0xc78, 0x7d030001, + 0xc78, 0x7d040001, + 0xc78, 0x7d050001, + 0xc78, 0x7c060001, + 0xc78, 0x7b070001, + 0xc78, 0x7a080001, + 0xc78, 0x79090001, + 0xc78, 0x780a0001, + 0xc78, 0x770b0001, + 0xc78, 0x760c0001, + 0xc78, 0x750d0001, + 0xc78, 0x740e0001, + 0xc78, 0x730f0001, + 0xc78, 0x72100001, + 0xc78, 0x71110001, + 0xc78, 0x70120001, + 0xc78, 0x6f130001, + 0xc78, 0x6e140001, + 0xc78, 0x6d150001, + 0xc78, 0x6c160001, + 0xc78, 0x6b170001, + 0xc78, 0x6a180001, + 0xc78, 0x69190001, + 0xc78, 0x681a0001, + 0xc78, 0x671b0001, + 0xc78, 0x661c0001, + 0xc78, 0x651d0001, + 0xc78, 0x641e0001, + 0xc78, 0x491f0001, + 0xc78, 0x48200001, + 0xc78, 0x47210001, + 0xc78, 0x46220001, + 0xc78, 0x45230001, + 0xc78, 0x44240001, + 0xc78, 0x43250001, + 0xc78, 0x28260001, + 0xc78, 0x27270001, + 0xc78, 0x26280001, + 0xc78, 0x25290001, + 0xc78, 0x242a0001, + 0xc78, 0x232b0001, + 0xc78, 0x222c0001, + 0xc78, 0x212d0001, + 0xc78, 0x202e0001, + 0xc78, 0x0a2f0001, + 0xc78, 0x08300001, + 0xc78, 0x06310001, + 0xc78, 0x05320001, + 0xc78, 0x04330001, + 0xc78, 0x03340001, + 0xc78, 0x02350001, + 0xc78, 0x01360001, + 0xc78, 0x00370001, + 0xc78, 0x00380001, + 0xc78, 0x00390001, + 0xc78, 0x003a0001, + 0xc78, 0x003b0001, + 0xc78, 0x003c0001, + 0xc78, 0x003d0001, + 0xc78, 0x003e0001, + 0xc78, 0x003f0001, + 0xc78, 0x7d400001, + 0xc78, 0x7d410001, + 0xc78, 0x7d420001, + 0xc78, 0x7d430001, + 0xc78, 0x7d440001, + 0xc78, 0x7d450001, + 0xc78, 0x7c460001, + 0xc78, 0x7b470001, + 0xc78, 0x7a480001, + 0xc78, 0x79490001, + 0xc78, 0x784a0001, + 0xc78, 0x774b0001, + 0xc78, 0x764c0001, + 0xc78, 0x754d0001, + 0xc78, 0x744e0001, + 0xc78, 0x734f0001, + 0xc78, 0x72500001, + 0xc78, 0x71510001, + 0xc78, 0x70520001, + 0xc78, 0x6f530001, + 0xc78, 0x6e540001, + 0xc78, 0x6d550001, + 0xc78, 0x6c560001, + 0xc78, 0x6b570001, + 0xc78, 0x6a580001, + 0xc78, 0x69590001, + 0xc78, 0x685a0001, + 0xc78, 0x675b0001, + 0xc78, 0x665c0001, + 0xc78, 0x655d0001, + 0xc78, 0x645e0001, + 0xc78, 0x495f0001, + 0xc78, 0x48600001, + 0xc78, 0x47610001, + 0xc78, 0x46620001, + 0xc78, 0x45630001, + 0xc78, 0x44640001, + 0xc78, 0x43650001, + 0xc78, 0x28660001, + 0xc78, 0x27670001, + 0xc78, 0x26680001, + 0xc78, 0x25690001, + 0xc78, 0x246a0001, + 0xc78, 0x236b0001, + 0xc78, 0x226c0001, + 0xc78, 0x216d0001, + 0xc78, 0x206e0001, + 0xc78, 0x0a6f0001, + 0xc78, 0x08700001, + 0xc78, 0x06710001, + 0xc78, 0x05720001, + 0xc78, 0x04730001, + 0xc78, 0x03740001, + 0xc78, 0x02750001, + 0xc78, 0x01760001, + 0xc78, 0x00770001, + 0xc78, 0x00780001, + 0xc78, 0x00790001, + 0xc78, 0x007a0001, + 0xc78, 0x007b0001, + 0xc78, 0x007c0001, + 0xc78, 0x007d0001, + 0xc78, 0x007e0001, + 0xc78, 0x007f0001, + 0xc78, 0x2e00001e, + 0xc78, 0x2e01001e, + 0xc78, 0x2e02001e, + 0xc78, 0x2e03001e, + 0xc78, 0x2e04001e, + 0xc78, 0x2e05001e, + 0xc78, 0x3006001e, + 0xc78, 0x3407001e, + 0xc78, 0x3908001e, + 0xc78, 0x3c09001e, + 0xc78, 0x3f0a001e, + 0xc78, 0x420b001e, + 0xc78, 0x440c001e, + 0xc78, 0x450d001e, + 0xc78, 0x460e001e, + 0xc78, 0x460f001e, + 0xc78, 0x4710001e, + 0xc78, 0x4811001e, + 0xc78, 0x4912001e, + 0xc78, 0x4a13001e, + 0xc78, 0x4b14001e, + 0xc78, 0x4b15001e, + 0xc78, 0x4c16001e, + 0xc78, 0x4d17001e, + 0xc78, 0x4e18001e, + 0xc78, 0x4f19001e, + 0xc78, 0x4f1a001e, + 0xc78, 0x501b001e, + 0xc78, 0x511c001e, + 0xc78, 0x521d001e, + 0xc78, 0x521e001e, + 0xc78, 0x531f001e, + 0xc78, 0x5320001e, + 0xc78, 0x5421001e, + 0xc78, 0x5522001e, + 0xc78, 0x5523001e, + 0xc78, 0x5624001e, + 0xc78, 0x5725001e, + 0xc78, 0x5726001e, + 0xc78, 0x5827001e, + 0xc78, 0x5828001e, + 0xc78, 0x5929001e, + 0xc78, 0x592a001e, + 0xc78, 0x5a2b001e, + 0xc78, 0x5b2c001e, + 0xc78, 0x5c2d001e, + 0xc78, 0x5c2e001e, + 0xc78, 0x5d2f001e, + 0xc78, 0x5e30001e, + 0xc78, 0x5f31001e, + 0xc78, 0x6032001e, + 0xc78, 0x6033001e, + 0xc78, 0x6134001e, + 0xc78, 0x6235001e, + 0xc78, 0x6336001e, + 0xc78, 0x6437001e, + 0xc78, 0x6438001e, + 0xc78, 0x6539001e, + 0xc78, 0x663a001e, + 0xc78, 0x673b001e, + 0xc78, 0x673c001e, + 0xc78, 0x683d001e, + 0xc78, 0x693e001e, + 0xc78, 0x6a3f001e, }; From b09693415b968d7bfbdf98f9efecd15b7c226dd9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 26 Jul 2011 21:46:37 -0500 Subject: [PATCH 0522/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IV Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 1439 +++++++++++++------------ drivers/staging/rtl8192e/r8192E_phy.h | 82 +- 2 files changed, 785 insertions(+), 736 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 9c1d16b5fb6..96ccbd5b25d 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -47,26 +47,29 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { /*************************Define local function prototype**********************/ -static u32 phy_FwRFSerialRead(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset); -static void phy_FwRFSerialWrite(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset,u32 Data); +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset); +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data); u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; - for (i=0; i<=31; i++) - { - if (((dwBitMask>>i)&0x1) == 1) + for (i = 0; i <= 31; i++) { + if (((dwBitMask >> i) & 0x1) == 1) break; } return i; } -u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) + +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath) { u8 ret = 1; struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_type == RF_2T4R) ret = 0; - else if (priv->rf_type == RF_1T2R) - { + else if (priv->rf_type == RF_1T2R) { if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) ret = 1; else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) @@ -74,22 +77,25 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) } return ret; } -void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) + +void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask, + u32 dwData) { u32 OriginalValue, BitShift, NewValue; - if (dwBitMask!= bMaskDWord) - { + if (dwBitMask != bMaskDWord) { OriginalValue = read_nic_dword(dev, dwRegAddr); BitShift = rtl8192_CalculateBitShift(dwBitMask); - NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift)); + NewValue = (((OriginalValue) & (~dwBitMask)) | + (dwData << BitShift)); write_nic_dword(dev, dwRegAddr, NewValue); - }else + } else write_nic_dword(dev, dwRegAddr, dwData); return; } -u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) + +u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) { u32 Ret = 0, OriginalValue, BitShift; @@ -97,60 +103,55 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) BitShift = rtl8192_CalculateBitShift(dwBitMask); Ret = (OriginalValue & dwBitMask) >> BitShift; - return (Ret); + return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset) +u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; u32 NewOffset = 0; - struct bb_reg_definition* pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); - NewOffset = Offset -30; - } - else if (Offset >= 16) - { + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); + NewOffset = Offset - 30; + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need" + " to be 8256\n"); NewOffset = Offset; } - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, + NewOffset); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1); + mdelay(1); - msleep(1); + ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, + bLSSIReadBackData); - ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); - - - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { priv->RfReg0Value[eRFPath] &= 0xebf; - rtl8192_setBBreg( - dev, - pPhyReg->rf3wireOffset, - bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } @@ -160,36 +161,36 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPat } -void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data) +void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 30; - } - else if (Offset >= 16) - { + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be" + " 8256\n"); NewOffset = Offset; } @@ -197,14 +198,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); - - if (Offset==0x0) + if (Offset == 0x0) priv->RfReg0Value[eRFPath] = Data; - if (priv->rf_chip == RF_8256) - { - if (Offset != 0) - { + if (priv->rf_chip == RF_8256) { + if (Offset != 0) { priv->RfReg0Value[eRFPath] &= 0xebf; rtl8192_setBBreg( dev, @@ -214,11 +212,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP } rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } - return; } -void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +void rtl8192_phy_SetRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 Original_Value, BitShift, New_Value; @@ -229,36 +227,37 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, return; RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); - if (priv->Rf_Mode == RF_OP_By_FW) - { - if (BitMask != bMask12Bits) - { - Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); + if (priv->Rf_Mode == RF_OP_By_FW) { + if (BitMask != bMask12Bits) { + Original_Value = phy_FwRFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + } else phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data); udelay(200); - } - else - { - if (BitMask != bMask12Bits) - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); + } else { + if (BitMask != bMask12Bits) { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); - rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, + New_Value); + } else rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data); } return; } -u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask) +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask) { u32 Original_Value, Readback_Value, BitShift; struct r8192_priv *priv = rtllib_priv(dev); @@ -267,79 +266,61 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) return 0; down(&priv->rf_sem); - if (priv->Rf_Mode == RF_OP_By_FW) - { + if (priv->Rf_Mode == RF_OP_By_FW) { Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); udelay(200); - } - else - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); - + } else { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); } BitShift = rtl8192_CalculateBitShift(BitMask); Readback_Value = (Original_Value & BitMask) >> BitShift; up(&priv->rf_sem); - return (Readback_Value); + return Readback_Value; } -static u32 phy_FwRFSerialRead( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset ) +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { u32 retValue = 0; u32 Data = 0; u8 time = 0; - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR)&0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } write_nic_dword(dev, QPNR, Data); - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else - return (0); + return 0; } retValue = read_nic_dword(dev, RF_DATA); - return (retValue); + return retValue; } /* phy_FwRFSerialRead */ -static void -phy_FwRFSerialWrite( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset, - u32 Data ) +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data) { u8 time = 0; - - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x400000; Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } @@ -348,82 +329,81 @@ phy_FwRFSerialWrite( } /* phy_FwRFSerialWrite */ -void rtl8192_phy_configmac(struct net_device* dev) +void rtl8192_phy_configmac(struct net_device *dev) { u32 dwArrayLen = 0, i = 0; - u32* pdwArray = NULL; + u32 *pdwArray = NULL; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bTXPowerDataReadFromEEPORM) - { + + if (priv->bTXPowerDataReadFromEEPORM) { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); dwArrayLen = MACPHY_Array_PGLength; pdwArray = Rtl819XMACPHY_Array_PG; - } - else - { - RT_TRACE(COMP_PHY,"Read rtl819XMACPHY_Array\n"); + } else { + RT_TRACE(COMP_PHY, "Read rtl819XMACPHY_Array\n"); dwArrayLen = MACPHY_ArrayLength; pdwArray = Rtl819XMACPHY_Array; } - for (i = 0; irf_type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; - } - else if (priv->rf_type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; - } + + AGCTAB_ArrayLen = AGCTAB_ArrayLength; + Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; + if (priv->rf_type == RF_2T4R) { + PHY_REGArrayLen = PHY_REGArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; + } else if (priv->rf_type == RF_1T2R) { + PHY_REGArrayLen = PHY_REG_1T2RArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; } - if (ConfigType == BaseBand_Config_PHY_REG) - { - for (i=0; iPHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; @@ -510,37 +490,45 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } -bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath) + +bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath) { bool ret = true; u32 i, CheckTimes = 4, dwRegRead = 0; u32 WriteAddr[4]; u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f}; + WriteAddr[HW90_BLOCK_MAC] = 0x100; WriteAddr[HW90_BLOCK_PHY0] = 0x900; WriteAddr[HW90_BLOCK_PHY1] = 0x800; WriteAddr[HW90_BLOCK_RF] = 0x3; - RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, CheckBlock); - for (i=0 ; i < CheckTimes ; i++) - { - - switch (CheckBlock) - { + RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, + CheckBlock); + for (i = 0; i < CheckTimes; i++) { + switch (CheckBlock) { case HW90_BLOCK_MAC: - RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!"); + RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write " + "0x100 here!"); break; case HW90_BLOCK_PHY0: case HW90_BLOCK_PHY1: - write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]); + write_nic_dword(dev, WriteAddr[CheckBlock], + WriteData[i]); dwRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]); break; case HW90_BLOCK_RF: WriteData[i] &= 0xfff; - rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); + rtl8192_phy_SetRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMask12Bits, WriteData[i]); mdelay(10); - dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord); + dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMaskDWord); mdelay(10); break; @@ -550,9 +538,9 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock } - if (dwRegRead != WriteData[i]) - { - RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, WriteData: %x \n", dwRegRead, WriteData[i]); + if (dwRegRead != WriteData[i]) { + RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, " + "WriteData: %x\n", dwRegRead, WriteData[i]); ret = false; break; } @@ -561,27 +549,27 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device* dev) +bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; u8 bRegValue = 0, eCheckItem = 0; u32 dwRegValue = 0; - /************************************** - **************************************/ bRegValue = read_nic_byte(dev, BB_GLOBAL_RESET); - write_nic_byte(dev, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT)); + write_nic_byte(dev, BB_GLOBAL_RESET, (bRegValue|BB_GLOBAL_RESET_BIT)); dwRegValue = read_nic_dword(dev, CPU_GEN); write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); - for (eCheckItem=(enum hw90_block)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) - { - rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (enum rf90_radio_path)0); - if (rtStatus != true) - { - RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); + for (eCheckItem = (enum hw90_block)HW90_BLOCK_PHY0; + eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { + rtStatus = rtl8192_phy_checkBBAndRF(dev, + (enum hw90_block)eCheckItem, + (enum rf90_radio_path)0); + if (rtStatus != true) { + RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():" + "Check PHY%d Fail!!\n", eCheckItem-1); return rtStatus; } } @@ -593,14 +581,11 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) rtl8192_phyConfigBB(dev, BaseBand_Config_AGC_TAB); - if (priv->IC_Cut > VERSION_8190_BD) - { + if (priv->IC_Cut > VERSION_8190_BD) { if (priv->rf_type == RF_2T4R) - { - dwRegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); - } + dwRegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); else dwRegValue = 0x0; rtl8192_setBBreg(dev, rFPGA0_TxGainStage, @@ -608,22 +593,25 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) dwRegValue = priv->CrystalCap; - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, + dwRegValue); } return rtStatus; } -bool rtl8192_BBConfig(struct net_device* dev) +bool rtl8192_BBConfig(struct net_device *dev) { bool rtStatus = true; + rtl8192_InitBBRFRegDef(dev); rtStatus = rtl8192_BB_Config_ParaFile(dev); return rtStatus; } -void rtl8192_phy_getTxPower(struct net_device* dev) +void rtl8192_phy_getTxPower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); + priv->MCSTxPowerLevelOriginalOffset[0] = read_nic_dword(dev, rTxAGC_Rate18_06); priv->MCSTxPowerLevelOriginalOffset[1] = @@ -641,44 +629,39 @@ void rtl8192_phy_getTxPower(struct net_device* dev) priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1); priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1); - RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n", + RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, " + "c60=0x%x, c68=0x%x)\n", priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3); priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2); - RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n", + RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n", rOFDM0_RxDetector3, priv->framesync); priv->SifsTime = read_nic_word(dev, SIFS); return; } -void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) +void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u8 powerlevel = 0,powerlevelOFDM24G = 0; + u8 powerlevel = 0, powerlevelOFDM24G = 0; char ant_pwr_diff; u32 u4RegValue; - if (priv->epromtype == EEPROM_93C46) - { + if (priv->epromtype == EEPROM_93C46) { powerlevel = priv->TxPowerLevelCCK[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - } - else if (priv->epromtype == EEPROM_93C56) - { - if (priv->rf_type == RF_1T2R) - { + } else if (priv->epromtype == EEPROM_93C56) { + if (priv->rf_type == RF_1T2R) { powerlevel = priv->TxPowerLevelCCK_C[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { powerlevel = priv->TxPowerLevelCCK_A[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] - -priv->TxPowerLevelOFDM24G_A[channel-1]; + - priv->TxPowerLevelOFDM24G_A[channel-1]; priv->RF_C_TxPwDiff = ant_pwr_diff; @@ -688,9 +671,9 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); priv->AntennaTxPwDiff[0] = 0; - u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); + u4RegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); @@ -706,97 +689,105 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", __func__); + RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", + __func__); break; } return; } -bool rtl8192_phy_RFConfig(struct net_device* dev) +bool rtl8192_phy_RFConfig(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; - switch (priv->rf_chip) - { - case RF_8225: - break; - case RF_8256: - rtStatus = PHY_RF8256_Config(dev); - break; - - case RF_8258: - break; - case RF_PSEUDO_11N: + switch (priv->rf_chip) { + case RF_8225: + break; + case RF_8256: + rtStatus = PHY_RF8256_Config(dev); break; - default: - RT_TRACE(COMP_ERR, "error chip id\n"); - break; + case RF_8258: + break; + case RF_PSEUDO_11N: + break; + + default: + RT_TRACE(COMP_ERR, "error chip id\n"); + break; } return rtStatus; } -void rtl8192_phy_updateInitGain(struct net_device* dev) +void rtl8192_phy_updateInitGain(struct net_device *dev) { return; } -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath) +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath) { int i; u8 ret = 0; - switch (eRFPath){ - case RF90_PATH_A: - for (i = 0;iTxPowerLevelCCK[channel-1]; u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - switch (priv->rf_chip) - { + switch (priv->rf_chip) { case RF_8225: break; @@ -818,31 +808,28 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n"); + RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPower" + "Level()\n"); break; } return; } -u8 rtl8192_phy_SetSwChnlCmdArray( - struct sw_chnl_cmd* CmdTable, - u32 CmdTableIdx, - u32 CmdTableSz, - enum sw_chnl_cmd_id CmdID, - u32 Para1, - u32 Para2, - u32 msDelay - ) -{ - struct sw_chnl_cmd* pCmd; - if (CmdTable == NULL) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); +u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, + u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) +{ + struct sw_chnl_cmd *pCmd; + + if (CmdTable == NULL) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot " + "be NULL.\n"); return false; } - if (CmdTableIdx >= CmdTableSz) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", + if (CmdTableIdx >= CmdTableSz) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid" + " index, please check size of the table, CmdTableIdx:" + "%d, CmdTableSz:%d\n", CmdTableIdx, CmdTableSz); return false; } @@ -855,7 +842,9 @@ u8 rtl8192_phy_SetSwChnlCmdArray( return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay) + +u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, + u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -867,50 +856,58 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; - RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); + RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", + __func__, *stage, *step, channel); - if (!IsLegalChannel(priv->rtllib, channel)) - { - RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); + if (!IsLegalChannel(priv->rtllib, channel)) { + RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", + channel); return true; } { PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, + 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); PostCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, + MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); RfDependCmdCnt = 0; - switch ( priv->rf_chip ) - { + switch (priv->rf_chip) { case RF_8225: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8225: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra " + "8225: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, + RF_CHANNEL_TABLE_ZEBRA[channel], 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; case RF_8256: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra" + " 8256: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, channel, + 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, + MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; @@ -918,68 +915,70 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u break; default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", + priv->rf_chip); return false; break; } - do{ - switch (*stage) - { + do { + switch (*stage) { case 0: - CurrentCmd=&PreCommonCmd[*step]; + CurrentCmd = &PreCommonCmd[*step]; break; case 1: - CurrentCmd=&RfDependCmd[*step]; + CurrentCmd = &RfDependCmd[*step]; break; case 2: - CurrentCmd=&PostCommonCmd[*step]; + CurrentCmd = &PostCommonCmd[*step]; break; } - if (CurrentCmd->CmdID==CmdID_End) - { - if ((*stage)==2) - { + if (CurrentCmd->CmdID == CmdID_End) { + if ((*stage) == 2) { return true; - } - else - { + } else { (*stage)++; - (*step)=0; + (*step) = 0; continue; } } - switch (CurrentCmd->CmdID) - { + switch (CurrentCmd->CmdID) { case CmdID_SetTxPowerLevel: if (priv->IC_Cut > (u8)VERSION_8190_BD) - rtl8192_SetTxPowerLevel(dev,channel); + rtl8192_SetTxPowerLevel(dev, channel); break; case CmdID_WritePortUlong: - write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); + write_nic_dword(dev, CurrentCmd->Para1, + CurrentCmd->Para2); break; case CmdID_WritePortUshort: - write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); + write_nic_word(dev, CurrentCmd->Para1, + (u16)CurrentCmd->Para2); break; case CmdID_WritePortUchar: - write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); + write_nic_byte(dev, CurrentCmd->Para1, + (u8)CurrentCmd->Para2); break; case CmdID_RF_WriteReg: - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); + for (eRFPath = 0; eRFPath < + priv->NumTotalRFPath; eRFPath++) + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + CurrentCmd->Para1, bMask12Bits, + CurrentCmd->Para2<<7); break; default: break; } break; - }while(true); - }/*for (Number of RF paths)*/ + } while (true); + } /*for (Number of RF paths)*/ - (*delay)=CurrentCmd->msDelay; + (*delay) = CurrentCmd->msDelay; (*step)++; return false; } @@ -987,14 +986,14 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u32 delay = 0; + u32 delay = 0; - while(!rtl8192_phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay)) - { - if (delay>0) + while (!rtl8192_phy_SwChnlStepByStep(dev, channel, &priv->SwChnlStage, + &priv->SwChnlStep, &delay)) { + if (delay > 0) msleep(delay); if (IS_NIC_DOWN(priv)) - break; + break; } } void rtl8192_SwChnl_WorkItem(struct net_device *dev) @@ -1004,44 +1003,43 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); - RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, priv->chan, priv); + RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, + priv->chan, priv); rtl8192_phy_FinishSwChnlNow(dev , priv->chan); RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); } -u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) +u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); - if (IS_NIC_DOWN(priv)) - { - RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__); return false; } if (priv->SwChnlInProgress) return false; - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_A: case WIRELESS_MODE_N_5G: - if (channel<=14){ + if (channel <= 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14"); return false; } break; case WIRELESS_MODE_B: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14"); return false; } break; case WIRELESS_MODE_G: case WIRELESS_MODE_N_24G: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14"); return false; } @@ -1052,71 +1050,77 @@ u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) if (channel == 0) channel = 1; - priv->chan=channel; + priv->chan = channel; - priv->SwChnlStage=0; - priv->SwChnlStep=0; + priv->SwChnlStage = 0; + priv->SwChnlStep = 0; - if (!IS_NIC_DOWN(priv)){ + if (!IS_NIC_DOWN(priv)) rtl8192_SwChnl_WorkItem(dev); - } priv->SwChnlInProgress = false; return true; } -static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev ) +static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength-1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; + RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); - RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->rtllib->current_network.channel== 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != + 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; - case HT_CHANNEL_WIDTH_20_40: + case HT_CHANNEL_WIDTH_20_40: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength - 1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 + && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; } } @@ -1125,24 +1129,29 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) priv->bcck_in_ch14 = true; - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) priv->bcck_in_ch14 = false; - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - if (priv->Record_CCK_20Mindex == 0) - priv->Record_CCK_20Mindex = 6; - priv->CCK_index = priv->Record_CCK_20Mindex; - RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n", priv->CCK_index); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + if (priv->Record_CCK_20Mindex == 0) + priv->Record_CCK_20Mindex = 6; + priv->CCK_index = priv->Record_CCK_20Mindex; + RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(),CCK_index = %d\n", + priv->CCK_index); + break; - case HT_CHANNEL_WIDTH_20_40: - priv->CCK_index = priv->Record_CCK_40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n", priv->CCK_index); - break; + case HT_CHANNEL_WIDTH_20_40: + priv->CCK_index = priv->Record_CCK_40Mindex; + RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(), CCK_index = %d\n", + priv->CCK_index); + break; } dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } @@ -1163,108 +1172,107 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u8 regBwOpMode; - RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \ - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz") + RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s " + "bandwidth\n", priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz") - if (priv->rf_chip== RF_PSEUDO_11N) - { - priv->SetBWModeInProgress= false; + if (priv->rf_chip == RF_PSEUDO_11N) { + priv->SetBWModeInProgress = false; return; } - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR,"%s(): ERR!! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__); return; } regBwOpMode = read_nic_byte(dev, BW_OPMODE); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - case HT_CHANNEL_WIDTH_20_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + case HT_CHANNEL_WIDTH_20_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW); - break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); - break; - case HT_CHANNEL_WIDTH_20_40: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); + break; + case HT_CHANNEL_WIDTH_20_40: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); + rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, + (priv->nCur40MhzPrimeSC>>1)); + rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, + priv->nCur40MhzPrimeSC); - - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); - break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); - break; + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); + break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch ( priv->rf_chip ) - { - case RF_8225: - break; + switch (priv->rf_chip) { + case RF_8225: + break; - case RF_8256: - PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); - break; + case RF_8256: + PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); + break; - case RF_8258: - break; + case RF_8258: + break; - case RF_PSEUDO_11N: - break; + case RF_PSEUDO_11N: + break; - default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); - break; + default: + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + break; } atomic_dec(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= false; + priv->SetBWModeInProgress = false; RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1272,14 +1280,14 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, if (priv->SetBWModeInProgress) return; - atomic_inc(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= true; + atomic_inc(&(priv->rtllib->atm_swbw)); + priv->SetBWModeInProgress = true; priv->CurrentChannelBW = Bandwidth; - if (Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Offset == HT_EXTCHNL_OFFSET_LOWER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if (Offset==HT_EXTCHNL_OFFSET_UPPER) + else if (Offset == HT_EXTCHNL_OFFSET_UPPER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; else priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -1288,79 +1296,107 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, } - void InitialGain819xPci(struct net_device *dev, u8 Operation) { #define SCAN_RX_INITIAL_GAIN 0x17 #define POWER_DETECTION_TH 0x08 struct r8192_priv *priv = rtllib_priv(dev); - u32 BitMask; - u8 initial_gain; + u32 BitMask; + u8 initial_gain; - if (!IS_NIC_DOWN(priv)){ - switch (Operation) - { - case IG_Backup: - RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n"); - initial_gain = SCAN_RX_INITIAL_GAIN; - BitMask = bMaskByte0; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask); - priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask); - priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask); - priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask); - BitMask = bMaskByte2; - priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask); + if (!IS_NIC_DOWN(priv)) { + switch (Operation) { + case IG_Backup: + RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial" + " gain.\n"); + initial_gain = SCAN_RX_INITIAL_GAIN; + BitMask = bMaskByte0; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + priv->initgain_backup.xaagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, + BitMask); + priv->initgain_backup.xbagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, + BitMask); + priv->initgain_backup.xcagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, + BitMask); + priv->initgain_backup.xdagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, + BitMask); + BitMask = bMaskByte2; + priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, + rCCK0_CCA, BitMask); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is" + " %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is" + " %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is" + " %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is" + " %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is" + " %x\n", priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain); - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH); - write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); - break; - case IG_Restore: - RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n"); - BitMask = 0x7f; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n", + initial_gain); + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x\n", + POWER_DETECTION_TH); + write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); + break; + case IG_Restore: + RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial " + "gain.\n"); + BitMask = 0x7f; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1); - rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1); - rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1); - BitMask = bMaskByte2; - rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, + (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, + (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, + (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, + (u32)priv->initgain_backup.xdagccore1); + BitMask = bMaskByte2; + rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, + (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50" + " is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58" + " is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60" + " is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68" + " is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a" + " is %x\n", priv->initgain_backup.cca); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); - - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - break; - default: - RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n"); - break; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + break; + default: + RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n"); + break; } } } -extern void -PHY_SetRtl8192eRfOff(struct net_device* dev ) +void PHY_SetRtl8192eRfOff(struct net_device *dev) { rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); @@ -1374,14 +1410,12 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) } -bool -SetRFPowerState8190( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bResult = true; u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; @@ -1391,137 +1425,142 @@ SetRFPowerState8190( RT_TRACE(COMP_PS, "===========> SetRFPowerState8190()!\n"); priv->SetRFPowerStateInProgress = true; - switch (priv->rf_chip) - { - case RF_8256: - switch ( eRFPowerState ) - { - case eRfOn: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn !\n"); - if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - bool rtstatus = true; - u32 InitilizeCount = 3; - do - { - InitilizeCount--; - priv->RegRfOff = false; - rtstatus = NicIFEnableNIC(dev); - }while( (rtstatus != true) &&(InitilizeCount >0) ); + switch (priv->rf_chip) { + case RF_8256: + switch (eRFPowerState) { + case eRfOn: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn!\n"); + if ((priv->rtllib->eRFPowerState == eRfOff) && + RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + bool rtstatus = true; + u32 InitilizeCount = 3; + do { + InitilizeCount--; + priv->RegRfOff = false; + rtstatus = NicIFEnableNIC(dev); + } while ((rtstatus != true) && + (InitilizeCount > 0)); - if (rtstatus != true) - { - RT_TRACE(COMP_ERR,"%s():Initialize Adapter fail,return\n",__func__); - priv->SetRFPowerStateInProgress = false; - return false; - } + if (rtstatus != true) { + RT_TRACE(COMP_ERR, "%s():Initialize Ada" + "pter fail,return\n", + __func__); + priv->SetRFPowerStateInProgress = false; + return false; + } - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } else { + RT_CLEAR_PS_LEVEL(pPSC, + RT_RF_OFF_LEVL_HALT_NIC); + } else { write_nic_byte(dev, ANAPAR, 0x37); mdelay(1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x4, 0x1); priv->bHwRfOffAction = 0; - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x3); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, + BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, + 0x300, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x18, 0x3); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x60, 0x3); + } + + break; + + case eRfSleep: + if (priv->rtllib->eRFPowerState == eRfOff) + break; + + + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE((COMP_POWER|COMP_RF), "eRf Off" + "/Sleep: %d times TcbBusyQueue" + "[%d] !=0 before doze!\n", + (i+1), QueueID); + udelay(10); + i++; } - break; - - case eRfSleep: - { - if (priv->rtllib->eRFPowerState == eRfOff) + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! " + "SetRFPowerState8190(): eRfOff" + ": %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; - - - { - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! SetRFPowerState8190(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); - break; - } - } - } - - { - PHY_SetRtl8192eRfOff(dev); } } - break; + PHY_SetRtl8192eRfOff(dev); + break; - case eRfOff: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/Sleep !\n"); + case eRfOff: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/" + "Sleep !\n"); + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE(COMP_POWER, - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); - break; - } - } - - { - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - - NicIFDisableNIC(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } - else if (!(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC)) - { - PHY_SetRtl8192eRfOff(dev); - } + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE(COMP_POWER, "eRf Off/Sleep: %d" + " times TcbBusyQueue[%d] !=0 b" + "efore doze!\n", (i+1), + QueueID); + udelay(10); + i++; } + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n SetZebra: " + "RFPowerState8185B(): eRfOff:" + " %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; + } + } - default: - bResult = false; - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state to set: 0x%X!!!\n", eRFPowerState); - break; + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && + !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + NicIFDisableNIC(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } else if (!(pPSC->RegRfPsLevel & + RT_RF_OFF_LEVL_HALT_NIC)) { + PHY_SetRtl8192eRfOff(dev); + } + + break; + + default: + bResult = false; + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state" + " to set: 0x%X!!!\n", eRFPowerState); + break; } break; - default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); - break; + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; } if (bResult) { @@ -1532,62 +1571,60 @@ SetRFPowerState8190( break; default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown " + "RF type\n"); break; } } priv->SetRFPowerStateInProgress = false; - RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", bResult); + RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", + bResult); return bResult; } - - -bool -SetRFPowerState( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); bool bResult = false; - RT_TRACE(COMP_PS,"---------> SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState); - if (eRFPowerState == priv->rtllib->eRFPowerState && priv->bHwRfOffAction == 0) { - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState); + RT_TRACE(COMP_PS, "---------> SetRFPowerState(): eRFPowerState(%d)\n", + eRFPowerState); + if (eRFPowerState == priv->rtllib->eRFPowerState && + priv->bHwRfOffAction == 0) { + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the " + "request for eRFPowerState(%d) is the same.\n", + eRFPowerState); return bResult; } bResult = SetRFPowerState8190(dev, eRFPowerState); - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", bResult); + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", + bResult); return bResult; } -extern void -PHY_ScanOperationBackup8192( - struct net_device* dev, - u8 Operation - ) +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->up) { switch (Operation) { - case SCAN_OPT_BACKUP: - priv->rtllib->InitialGainHandler(dev,IG_Backup); - break; + case SCAN_OPT_BACKUP: + priv->rtllib->InitialGainHandler(dev, IG_Backup); + break; - case SCAN_OPT_RESTORE: - priv->rtllib->InitialGainHandler(dev,IG_Restore); - break; + case SCAN_OPT_RESTORE: + priv->rtllib->InitialGainHandler(dev, IG_Restore); + break; - default: - RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation. \n"); - break; + default: + RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation.\n"); + break; } } diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 79adc8096bd..86c6acd0c54 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -25,25 +25,25 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE -#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE -#define RadioA_ArrayLength RadioA_ArrayLengthPciE -#define RadioB_ArrayLength RadioB_ArrayLengthPciE +#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE +#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE +#define RadioA_ArrayLength RadioA_ArrayLengthPciE +#define RadioB_ArrayLength RadioB_ArrayLengthPciE #define MACPHY_Array_PGLength MACPHY_Array_PGLengthPciE -#define RadioC_ArrayLength RadioC_ArrayLengthPciE -#define RadioD_ArrayLength RadioD_ArrayLengthPciE -#define PHY_REGArrayLength PHY_REGArrayLengthPciE -#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE +#define RadioC_ArrayLength RadioC_ArrayLengthPciE +#define RadioD_ArrayLength RadioD_ArrayLengthPciE +#define PHY_REGArrayLength PHY_REGArrayLengthPciE +#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE #define Rtl819XMACPHY_Array_PG Rtl8192PciEMACPHY_Array_PG -#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array -#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array -#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array -#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array -#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array -#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array -#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray -#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray +#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array +#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array +#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array +#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array +#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array +#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array +#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray +#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray @@ -57,7 +57,7 @@ enum sw_chnl_cmd_id { CmdID_RF_WriteReg, }; -/*--------------------------------Define structure--------------------------------*/ +/*--------------------------------Define structure----------------------------*/ struct sw_chnl_cmd { enum sw_chnl_cmd_id CmdID; u32 Para1; @@ -97,23 +97,35 @@ enum rf90_radio_path { #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff -extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath); -extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData); -extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask); -extern void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask); -extern void rtl8192_phy_configmac(struct net_device* dev); -extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); -extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath); -extern bool rtl8192_BBConfig(struct net_device* dev); -extern void rtl8192_phy_getTxPower(struct net_device* dev); -extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); -extern bool rtl8192_phy_RFConfig(struct net_device* dev); -extern void rtl8192_phy_updateInitGain(struct net_device* dev); -extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); +extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, + u32 eRFPath); +extern void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask, u32 dwData); +extern u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask); +extern void rtl8192_phy_SetRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); +extern u32 rtl8192_phy_QueryRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask); +extern void rtl8192_phy_configmac(struct net_device *dev); +extern void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); +extern bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath); +extern bool rtl8192_BBConfig(struct net_device *dev); +extern void rtl8192_phy_getTxPower(struct net_device *dev); +extern void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); +extern bool rtl8192_phy_RFConfig(struct net_device *dev); +extern void rtl8192_phy_updateInitGain(struct net_device *dev); +extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath); -extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); +extern u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); +extern void rtl8192_SetBWMode(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); @@ -122,11 +134,11 @@ extern void PHY_SetRtl8192eRfOff(struct net_device *dev); bool SetRFPowerState( - struct net_device* dev, + struct net_device *dev, enum rt_rf_power_state eRFPowerState ); #define PHY_SetRFPowerState SetRFPowerState -extern void PHY_ScanOperationBackup8192(struct net_device* dev,u8 Operation); +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation); #endif From 81108afb95148de7db0c11aa6e5219ba1faa55b0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 12:32:07 -0500 Subject: [PATCH 0523/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part V Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 5 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 403 +++++----- drivers/staging/rtl8192e/rtl819x_HT.h | 25 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 876 +++++++++++----------- 4 files changed, 650 insertions(+), 659 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index d2020b39018..613e14c12df 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -38,11 +38,10 @@ #define DELBA_REASON_TIMEOUT 39 union sequence_control { u16 ShortData; - struct - { + struct { u16 FragNum:4; u16 SeqNum:12; - }field; + } field; }; union ba_param_set { diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index aeb8a4b5d05..2e4085b8877 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,46 +20,44 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device* ieee, struct ba_record *pBA, u16 Time) +void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry( struct rtllib_device* ieee, struct ba_record *pBA) +void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) + +u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; - u8 bSendDELBA = false; + u8 bSendDELBA = false; - if (pPendingBa->bValid) - { + if (pPendingBa->bValid) { DeActivateBAEntry(ieee, pPendingBa); bSendDELBA = true; } - if (pAdmittedBa->bValid) - { + if (pAdmittedBa->bValid) { DeActivateBAEntry(ieee, pAdmittedBa); bSendDELBA = true; } - return bSendDELBA; } -u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) +u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; - if (pBa->bValid) - { + if (pBa->bValid) { DeActivateBAEntry(ieee, pBa); bSendDELBA = true; } @@ -67,7 +65,7 @@ u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) return bSendDELBA; } -void ResetBaEntry( struct ba_record *pBA) +void ResetBaEntry(struct ba_record *pBA) { pBA->bValid = false; pBA->BaParamSet.shortData = 0; @@ -75,31 +73,35 @@ void ResetBaEntry( struct ba_record *pBA) pBA->DialogToken = 0; pBA->BaStartSeqCtrl.ShortData = 0; } -static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct ba_record *pBA, u16 StatusCode, u8 type) +static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, + struct ba_record *pBA, + u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* BAReq = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *BAReq = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = ieee->tx_headroom + 9; - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, type, MAC_ARG(Dst), ieee->dev); - if (pBA == NULL||ieee == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" + " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, + type, MAC_ARG(Dst), ieee->dev); + if (pBA == NULL || ieee == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " + "NULL\n", pBA, ieee); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct rtllib_hdr_3addr)); + memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr)); skb_reserve(skb, ieee->tx_headroom); - BAReq = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + BAReq = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(BAReq->addr1, Dst, ETH_ALEN); memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -107,28 +109,26 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 9); + tag = (u8 *)skb_put(skb, 9); *tag ++= ACT_CAT_BA; *tag ++= type; *tag ++= pBA->DialogToken; - if (ACT_ADDBARSP == type) - { + if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); tmp = cpu_to_le16(StatusCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; } tmp = cpu_to_le16(pBA->BaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(pBA->BaTimeoutValue); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; - if (ACT_ADDBAREQ == type) - { - memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2); + if (ACT_ADDBAREQ == type) { + memcpy(tag, (u8 *)&(pBA->BaStartSeqCtrl), 2); tag += 2; } @@ -136,64 +136,65 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct return skb; } -static struct sk_buff* rtllib_DELBA( - struct rtllib_device* ieee, - u8* dst, - struct ba_record *pBA, - enum tr_select TxRxSelect, - u16 ReasonCode - ) +static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, + enum tr_select TxRxSelect, u16 ReasonCode) { union delba_param_set DelbaParamSet; struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* Delba = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *Delba = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __func__, ReasonCode, MAC_ARG(dst)); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, + "========>%s(), Reason" + "Code(%d) sentd to:"MAC_FMT"\n", __func__, + ReasonCode, MAC_ARG(dst)); memset(&DelbaParamSet, 0, 2); - DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; + DelbaParamSet.field.Initiator = (TxRxSelect == TX_DIR) ? 1 : 0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } skb_reserve(skb, ieee->tx_headroom); - Delba = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + Delba = (struct rtllib_hdr_3addr *) skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(Delba->addr1, dst, ETH_ALEN); memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 6); + tag = (u8 *)skb_put(skb, 6); *tag ++= ACT_CAT_BA; *tag ++= ACT_DELBA; tmp = cpu_to_le16(DelbaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(ReasonCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", + __func__); return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA) +void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -202,65 +203,66 @@ void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); softmac_mgmt_xmit(skb, ieee); } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); } return; } -void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, u16 StatusCode) +void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); if (skb) softmac_mgmt_xmit(skb, ieee); else - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); return; - } -void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, enum tr_select TxRxSelect, u16 ReasonCode) +void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); if (skb) - { softmac_mgmt_xmit(skb, ieee); - } else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - } + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in func" + "tion %s()\n", __func__); return ; } -int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* req = NULL; + struct rtllib_hdr_3addr *req = NULL; u16 rc = 0; - u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; struct ba_record *pBA = NULL; union ba_param_set *pBaParamSet = NULL; - u16* pBaTimeoutVal = NULL; + u16 *pBaTimeoutVal = NULL; union sequence_control *pBaStartSeqCtrl = NULL; struct rx_ts_record *pTS = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n",(int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - req = ( struct rtllib_hdr_3addr*) skb->data; - tag = (u8*)req; - dst = (u8*)(&req->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + req = (struct rtllib_hdr_3addr *) skb->data; + tag = (u8 *)req; + dst = (u8 *)(&req->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; pBaParamSet = (union ba_param_set *)(tag + 3); - pBaTimeoutVal = (u16*)(tag + 5); + pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); @@ -268,31 +270,27 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as " + "some capability is not ready(%d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); goto OnADDBAReq_Fail; } - if (!GetTs( - ieee, - (struct ts_common_info **)(&pTS), - dst, - (u8)(pBaParamSet->field.TID), - RX_DIR, - true) ) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + (u8)(pBaParamSet->field.TID), RX_DIR, true)) { rc = ADDBA_STATUS_REFUSED; RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; } pBA = &pTS->RxAdmittedBARecord; - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { rc = ADDBA_STATUS_INVALID_PARAM; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in " + "%s()\n", __func__); goto OnADDBAReq_Fail; } - rtllib_FlushRxTsPendingPkts(ieee, pTS); DeActivateBAEntry(ieee, pBA); @@ -301,11 +299,11 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) pBA->BaTimeoutValue = *pBaTimeoutVal; pBA->BaStartSeqCtrl = *pBaStartSeqCtrl; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)|| - (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) - pBA->BaParamSet.field.BufferSize = 1; + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) || + (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) + pBA->BaParamSet.field.BufferSize = 1; else - pBA->BaParamSet.field.BufferSize = 32; + pBA->BaParamSet.field.BufferSize = 32; ActivateBAEntry(ieee, pBA, 0); rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS); @@ -322,40 +320,42 @@ OnADDBAReq_Fail: rtllib_send_ADDBARsp(ieee, dst, &BA, rc); return 0; } - } -int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* rsp = NULL; + struct rtllib_hdr_3addr *rsp = NULL; struct ba_record *pPendingBA, *pAdmittedBA; struct tx_ts_record *pTS = NULL; - u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; - u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; + u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL; union ba_param_set *pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } - rsp = ( struct rtllib_hdr_3addr*)skb->data; - tag = (u8*)rsp; - dst = (u8*)(&rsp->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + rsp = (struct rtllib_hdr_3addr *)skb->data; + tag = (u8 *)rsp; + dst = (u8 *)(&rsp->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; - pStatusCode = (u16*)(tag + 3); + pStatusCode = (u16 *)(tag + 3); pBaParamSet = (union ba_param_set *)(tag + 5); - pBaTimeoutVal = (u16*)(tag + 7); + pBaTimeoutVal = (u16 *)(tag + 7); RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false || + ieee->pHTInfo->bCurrentAMPDUEnable == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capab" + "ility is not ready(%d, %d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -373,28 +373,25 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) pAdmittedBA = &pTS->TxAdmittedBARecord; - if ((pAdmittedBA->bValid==true)) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); + if ((pAdmittedBA->bValid == true)) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp." + " Drop because already admit it!\n"); return -1; - } - else if ((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); + } else if ((pPendingBA->bValid == false) || + (*pDialogToken != pPendingBA->DialogToken)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. " + "BA invalid, DELBA!\n"); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA " + "is admitted! Status code:%X\n", *pStatusCode); DeActivateBAEntry(ieee, pPendingBA); } - if (*pStatusCode == ADDBA_STATUS_SUCCESS) - { - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (*pStatusCode == ADDBA_STATUS_SUCCESS) { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { pTS->bAddBaReqDelayed = true; DeActivateBAEntry(ieee, pAdmittedBA); ReasonCode = DELBA_REASON_END_BA; @@ -424,68 +421,58 @@ OnADDBARsp_Reject: rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); return 0; } - } -int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) +int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* delba = NULL; + struct rtllib_hdr_3addr *delba = NULL; union delba_param_set *pDelBaParamSet = NULL; - u16* pReasonCode = NULL; - u8* dst = NULL; + u16 *pReasonCode = NULL; + u8 *dst = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 6) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 6)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d /" + " %d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 6)); return -1; } - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT " + "is not supported(%d, %d)\n", + ieee->current_network. qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - delba = ( struct rtllib_hdr_3addr*)skb->data; - dst = (u8*)(&delba->addr2[0]); - delba += sizeof( struct rtllib_hdr_3addr); + delba = (struct rtllib_hdr_3addr *)skb->data; + dst = (u8 *)(&delba->addr2[0]); + delba += sizeof(struct rtllib_hdr_3addr); pDelBaParamSet = (union delba_param_set *)(delba+2); - pReasonCode = (u16*)(delba+4); + pReasonCode = (u16 *)(delba+4); - if (pDelBaParamSet->field.Initiator == 1) - { + if (pDelBaParamSet->field.Initiator == 1) { struct rx_ts_record *pRxTs; - if ( !GetTs( - ieee, - (struct ts_common_info **)&pRxTs, - dst, - (u8)pDelBaParamSet->field.TID, - RX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in %s().dst:"MAC_FMT" TID:%d\n", __func__, MAC_ARG(dst), (u8)pDelBaParamSet->field.TID); + if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, + (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " + "%s().dst:"MAC_FMT" TID:%d\n", __func__, + MAC_ARG(dst), + (u8)pDelBaParamSet->field.TID); return -1; } RxTsDeleteBA(ieee, pRxTs); - } - else - { + } else { struct tx_ts_record *pTxTs; - if (!GetTs( - ieee, - (struct ts_common_info **)&pTxTs, - dst, - (u8)pDelBaParamSet->field.TID, - TX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); + if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst, + (u8)pDelBaParamSet->field.TID, TX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in " + "%s()\n", __func__); return -1; } @@ -498,17 +485,12 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) return 0; } -void -TsInitAddBA( - struct rtllib_device* ieee, - struct tx_ts_record *pTS, - u8 Policy, - u8 bOverwritePending - ) +void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending) { struct ba_record *pBA = &pTS->TxPendingBARecord; - if (pBA->bValid==true && bOverwritePending==false) + if (pBA->bValid == true && bOverwritePending == false) return; DeActivateBAEntry(ieee, pBA); @@ -516,7 +498,8 @@ TsInitAddBA( pBA->DialogToken++; pBA->BaParamSet.field.AMSDU_Support = 0; pBA->BaParamSet.field.BAPolicy = Policy; - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; + pBA->BaParamSet.field.TID = + pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; pBA->BaParamSet.field.BufferSize = 32; pBA->BaTimeoutValue = 0; pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; @@ -526,34 +509,30 @@ TsInitAddBA( rtllib_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); } -void -TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) +void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect) { - - if (TxRxSelect == TX_DIR) - { - struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo; + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *pTxTs = + (struct tx_ts_record *)pTsCommonInfo; if (TxTsDeleteBA(ieee, pTxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), - TxRxSelect, - DELBA_REASON_END_BA); - } - else if (TxRxSelect == RX_DIR) - { - struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo; + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + (pTxTs->TxAdmittedBARecord.bValid) ? + (&pTxTs->TxAdmittedBARecord) : + (&pTxTs->TxPendingBARecord), + TxRxSelect, DELBA_REASON_END_BA); + } else if (TxRxSelect == RX_DIR) { + struct rx_ts_record *pRxTs = + (struct rx_ts_record *)pTsCommonInfo; if (RxTsDeleteBA(ieee, pRxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - &pRxTs->RxAdmittedBARecord, - TxRxSelect, - DELBA_REASON_END_BA ); + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + &pRxTs->RxAdmittedBARecord, + TxRxSelect, DELBA_REASON_END_BA); } } + void BaSetupTimeOut(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; @@ -566,27 +545,23 @@ void BaSetupTimeOut(unsigned long data) void TxBaInactTimeout(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[pTxTs->num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); - rtllib_send_DELBA( - ieee, - pTxTs->TsCommonInfo.Addr, - &pTxTs->TxAdmittedBARecord, - TX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pTxTs->TsCommonInfo.Addr, + &pTxTs->TxAdmittedBARecord, TX_DIR, + DELBA_REASON_TIMEOUT); } void RxBaInactTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); - rtllib_send_DELBA( - ieee, - pRxTs->TsCommonInfo.Addr, - &pRxTs->RxAdmittedBARecord, - RX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pRxTs->TsCommonInfo.Addr, + &pRxTs->RxAdmittedBARecord, RX_DIR, + DELBA_REASON_TIMEOUT); return ; } diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 891714fb182..13f41057461 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -34,10 +34,10 @@ #define sHTCLng 4 -#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff -#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 -#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP - +#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff +#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 +#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP \ + (HT_MCS_1SS_BITMAP | HT_MCS_1SS_2SS_BITMAP) enum ht_mcs_rate { HT_MCS0 = 0x00000001, @@ -381,13 +381,12 @@ extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; #define PICK_RATE(_nLegacyRate, _nMcsRate) \ - (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate) + ((_nMcsRate == 0) ? (_nLegacyRate&0x7f) : (_nMcsRate)) #define LEGACY_WIRELESS_MODE IEEE_MODE_MASK #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \ - ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\ - (LegacyRate):\ - (PICK_RATE(LegacyRate, HTRate)) + ((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \ + (LegacyRate) : (PICK_RATE(LegacyRate, HTRate)) @@ -411,8 +410,8 @@ enum ht_iot_peer { HT_IOT_PEER_BROADCOM = 3, HT_IOT_PEER_RALINK = 4, HT_IOT_PEER_ATHEROS = 5, - HT_IOT_PEER_CISCO= 6, - HT_IOT_PEER_MARVELL=7, + HT_IOT_PEER_CISCO = 6, + HT_IOT_PEER_MARVELL = 7, HT_IOT_PEER_92U_SOFTAP = 8, HT_IOT_PEER_SELF_SOFTAP = 9, HT_IOT_PEER_AIRGO = 10, @@ -447,10 +446,10 @@ enum ht_iot_action { HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000, HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000, - HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, - HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, + HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, + HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, - HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, + HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000, HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000, diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 825b90805b4..f8da913c47b 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -18,53 +18,75 @@ ******************************************************************************/ #include "rtllib.h" #include "rtl819x_HT.h" -u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_ALL[16] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; -u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_1SS[16] = { + 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +; -u16 MCS_DATA_RATE[2][2][77] = - { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260, - 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520, - 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195, - 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260, - 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, - {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, - 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578, - 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217, - 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289, - 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, - { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, - 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, - 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, - 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, - 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, - {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, - 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, - 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, - 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600, - 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } - }; +u16 MCS_DATA_RATE[2][2][77] = { + {{13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, + 260, 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, + 468, 520, 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, + 182, 208, 156, 195, 195, 234, 273, 273, 312, 130, 156, 181, 156, + 181, 208, 234, 208, 234, 260, 260, 286, 195, 234, 273, 234, 273, + 312, 351, 312, 351, 390, 390, 429} , + {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, + 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, + 578, 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, + 173, 217, 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, + 231, 260, 289, 289, 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, + 433, 433, 477} } , + {{27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, + 540, 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, + 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, + 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324, + 378, 432, 486, 432, 486, 540, 540, 594, 405, 486, 567, 486, 567, 648, + 729, 648, 729, 810, 810, 891}, + {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, + 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, + 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, + 420, 420, 480, 360, 450, 450, 540, 630, 630, 720, 300, 360, 420, 360, + 420, 480, 540, 480, 540, 600, 600, 660, 450, 540, 630, 540, 630, 720, + 810, 720, 810, 900, 900, 990} } +}; static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf}; + static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70}; + static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e}; + static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; + static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf}; + static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc}; + static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; + static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; + static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0}; + static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91}; + static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; + static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; -void HTUpdateDefaultSetting(struct rtllib_device* ieee) + +void HTUpdateDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->bAcceptAddbaReq = 1; - pHTInfo->bRegShortGI20MHz= 1; - pHTInfo->bRegShortGI40MHz= 1; + pHTInfo->bRegShortGI20MHz = 1; + pHTInfo->bRegShortGI40MHz = 1; pHTInfo->bRegBW40MHz = 1; @@ -94,97 +116,110 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->RxReorderWinSize = 64; pHTInfo->RxReorderPendingTime = 30; } -void HTDebugHTCapability(u8* CapIE, u8* TitleString ) + +void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; struct ht_capab_ele *pCapELE; - if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) - { + if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pCapELE = (struct ht_capab_ele *)(&CapIE[4]); - }else + } else pCapELE = (struct ht_capab_ele *)(&CapIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString ); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", + TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ - pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", + (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", + (pCapELE->ShortGI20Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", + (pCapELE->ShortGI40Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", + (pCapELE->TxSTBC) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", + (pCapELE->MaxAMSDUSize) ? "3839" : "7935"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", + (pCapELE->DssCCk) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", + pCapELE->MaxRxAMPDUFactor); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", + pCapELE->MPDUDensity); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", + pCapELE->MCS[0], pCapELE->MCS[1], pCapELE->MCS[2], + pCapELE->MCS[3], pCapELE->MCS[4]); return; } -void HTDebugHTInfo(u8* InfoIE, u8* TitleString) + +void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) { static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; struct ht_info_ele *pHTInfoEle; - if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - { + if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]); - }else + } else pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". " + "Called by %s\n", TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", + pHTInfoEle->ControlChl); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel ="); - switch (pHTInfoEle->ExtChlOffset) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); - break; + switch (pHTInfoEle->ExtChlOffset) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", + (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz"); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = "); - switch (pHTInfoEle->OptMode) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); - break; + switch (pHTInfoEle->OptMode) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ - pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x]" + "[%x]\n", pHTInfoEle->BasicMSC[0], pHTInfoEle->BasicMSC[1], + pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], + pHTInfoEle->BasicMSC[4]); return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) +bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (pHTInfo->bRegBW40MHz == false) retValue = false; @@ -198,25 +233,24 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) +bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) retValue = false; - else if (is40MHz) - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) + else if (is40MHz) { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) retValue = true; else retValue = false; - } - else - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) + } else { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) retValue = true; else retValue = false; @@ -225,89 +259,75 @@ bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) return retValue; } -u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate) +u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { u8 is40MHz; u8 isShortGI; - is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0; - isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0; + is40MHz = (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0; + isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0; - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate) +u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; - u8 isShortGI = (pHTInfo->bCurBW40MHz)? - ((pHTInfo->bCurShortGI40MHz)?1:0): - ((pHTInfo->bCurShortGI20MHz)?1:0); - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + u8 is40MHz = (pHTInfo->bCurBW40MHz) ? 1 : 0; + u8 isShortGI = (pHTInfo->bCurBW40MHz) ? + ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) : + ((pHTInfo->bCurShortGI20MHz) ? 1 : 0); + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate) +u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate) { - u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c}; + u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, + 0x24, 0x30, 0x48, 0x60, 0x6c}; u8 is40MHz = 0; u8 isShortGI = 0; - if (nDataRate < 12) - { + if (nDataRate < 12) { return CCKOFDMRate[nDataRate]; - } - else - { - if (nDataRate >= 0x10 && nDataRate <= 0x1f) - { + } else { + if (nDataRate >= 0x10 && nDataRate <= 0x1f) { is40MHz = 0; isShortGI = 0; - - } - else if (nDataRate >=0x20 && nDataRate <= 0x2f ) - { + } else if (nDataRate >= 0x20 && nDataRate <= 0x2f) { is40MHz = 1; isShortGI = 0; - } - else if (nDataRate >= 0x30 && nDataRate <= 0x3f ) - { + } else if (nDataRate >= 0x30 && nDataRate <= 0x3f) { is40MHz = 0; isShortGI = 1; - - } - else if (nDataRate >= 0x40 && nDataRate <= 0x4f ) - { + } else if (nDataRate >= 0x40 && nDataRate <= 0x4f) { is40MHz = 1; isShortGI = 1; - } return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; } } - - -bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) +bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) { bool retValue = false; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_network *net = &ieee->current_network; - if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - (net->ralink_cap_exist)) + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + (net->ralink_cap_exist)) + retValue = true; + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) || + (net->broadcom_cap_exist)) retValue = true; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| - (net->broadcom_cap_exist)) - retValue = true; else if (net->bssht.bdRT2RTAggregation) retValue = true; else @@ -316,38 +336,35 @@ bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device* ieee) +void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct rtllib_network* net = &ieee->current_network; - if (net->bssht.bdRT2RTAggregation){ + struct rtllib_network *net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation) { pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE; - } - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP) pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP; - } - } - else if (net->broadcom_cap_exist) + } else if (net->broadcom_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)/*|| - (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) */) + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - net->ralink_cap_exist) + else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + net->ralink_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; - else if ((net->atheros_cap_exist )|| - (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)|| + else if ((net->atheros_cap_exist) || + (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) || (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; - else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist) + else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) || + net->cisco_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || net->marvell_cap_exist) @@ -357,35 +374,35 @@ void HTIOTPeerDetermine(struct rtllib_device* ieee) else pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); + RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", + pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; - } +} -bool HTIOTActIsDisableMCS15(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { - bool retValue = false; - return retValue; + return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) +bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) { bool retValue = false; @@ -393,70 +410,65 @@ bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) } -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) +u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 retValue = false; - u8 boundary=59; + u8 boundary = 59; pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) - { - if (!(pHTInfo->bRegBW40MHz)) - { - if (ieee->current_network.mode != WIRELESS_MODE_B) - { + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (ieee->current_network.bssht.bdBandWidth == + HT_CHANNEL_WIDTH_20_40) { + if (!(pHTInfo->bRegBW40MHz)) { + if (ieee->current_network.mode != + WIRELESS_MODE_B) { pHTInfo->bWAIotBroadcom = true; - if (ieee->b_customer_lenovo_id == true) + if (ieee->b_customer_lenovo_id) boundary = 30; - if ( ieee->current_network.RSSI >= boundary) + if (ieee->current_network.RSSI >= + boundary) retValue = true; } - }else{ - ; } } } return retValue; } -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - { retValue = 1; - } return retValue; } -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -466,54 +478,48 @@ HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *netwo u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; - -} - -u8 - HTIOTActIsEDCABiasRx(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActDisableShortGI(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, + struct rtllib_network *network) +{ + u8 retValue = 0; + + return retValue; +} + +u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) retValue = 1; - } return retValue; } -u8 -HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -void -HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) +void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -527,81 +533,77 @@ HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) } -u8 -HTIOTActIsDisableTx40MHz(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsTxNoAggregation(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -u8 -HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool -HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -void HTResetIOTSetting( - struct rt_hi_throughput *pHTInfo -) +void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; pHTInfo->IOTRaFunc = 0; } - -void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) +void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, + u8 *len, u8 IsEncrypt, bool bAssoc) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_capab_ele *pCapELE = NULL; - if ((posHTCap == NULL) || (pHT == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + if ((posHTCap == NULL) || (pHT == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be " + "null in HTConstructCapabilityElement()\n"); return; } memset(posHTCap, 0, *len); - if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) - { + if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) { u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); pCapELE = (struct ht_capab_ele *)&(posHTCap[4]); *len = 30 + 2; - }else - { + } else { pCapELE = (struct ht_capab_ele *)posHTCap; *len = 26 + 2; } @@ -610,7 +612,7 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pCapELE->ChlWidth = 0; else - pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); + pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0); pCapELE->MimoPwrSave = pHT->SelfMimoPs; pCapELE->GreenField = 0; @@ -620,21 +622,20 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* pCapELE->TxSTBC = 1; pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; - pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; - pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); - pCapELE->PSMP = 0; - pCapELE->LSigTxopProtect = 0; + pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0; + pCapELE->DssCCk = ((pHT->bRegBW40MHz) ? (pHT->bRegSuppCCK ? 1 : 0) : 0); + pCapELE->PSMP = 0; + pCapELE->LSigTxopProtect = 0; - RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); + RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d " + "DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, + pCapELE->DssCCk); - if ( IsEncrypt) - { + if (IsEncrypt) { pCapELE->MPDUDensity = 7; pCapELE->MaxRxAMPDUFactor = 2; - } - else - { + } else { pCapELE->MaxRxAMPDUFactor = 3; pCapELE->MPDUDensity = 0; } @@ -658,67 +659,63 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) pCapELE->ShortGI40Mhz = 0; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - { + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { pCapELE->ChlWidth = 0; - pCapELE->MCS[1] = 0; } } - - - - - return; - } -void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) + +void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo, + u8 *len, u8 IsEncrypt) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo; - if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be " + "null in HTConstructInfoElement()\n"); return; } memset(posHTInfo, 0, *len); - if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) - { + if ((ieee->iw_mode == IW_MODE_ADHOC) || + (ieee->iw_mode == IW_MODE_MASTER)) { pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: - (ieee->current_network.channel<=6)? - HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); + pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false) ? + HT_EXTCHNL_OFFSET_NO_EXT : + (ieee->current_network.channel <= 6) + ? HT_EXTCHNL_OFFSET_UPPER : + HT_EXTCHNL_OFFSET_LOWER); pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; - pHTInfoEle->RIFS = 0; + pHTInfoEle->RIFS = 0; pHTInfoEle->PSMPAccessOnly = 0; pHTInfoEle->SrvIntGranularity = 0; - pHTInfoEle->OptMode = pHT->CurrentOpMode; + pHTInfoEle->OptMode = pHT->CurrentOpMode; pHTInfoEle->NonGFDevPresent = 0; pHTInfoEle->DualBeacon = 0; pHTInfoEle->SecondaryBeacon = 0; pHTInfoEle->LSigTxopProtectFull = 0; - pHTInfoEle->PcoActive = 0; - pHTInfoEle->PcoPhase = 0; + pHTInfoEle->PcoActive = 0; + pHTInfoEle->PcoPhase = 0; memset(pHTInfoEle->BasicMSC, 0, 16); *len = 22 + 2; - } - else - { + } else { *len = 0; } return; } -void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len) +void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, + u8 *len) { if (posRT2RTAgg == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in " + "HTConstructRT2RTAggElement()\n"); return; } memset(posRT2RTAgg, 0, *len); @@ -730,21 +727,20 @@ void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* *posRT2RTAgg = 0x30; - if (ieee->bSupportRemoteWakeUp) { + if (ieee->bSupportRemoteWakeUp) *posRT2RTAgg |= RT_HT_CAP_USE_WOW; - } *len = 6 + 2; return; } -u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) +u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { - u8 i; - if (pOperateMCS == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); + u8 i; + if (pOperateMCS == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null" + " in HT_PickMCSRate()\n"); return false; } @@ -752,14 +748,14 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) case IEEE_A: case IEEE_B: case IEEE_G: - for (i=0;i<=15;i++) - pOperateMCS[i] = 0; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = 0; break; case IEEE_N_24G: case IEEE_N_5G: - pOperateMCS[0] &=RATE_ADPT_1SS_MASK; - pOperateMCS[1] &=RATE_ADPT_2SS_MASK; - pOperateMCS[3] &=RATE_ADPT_MCS32_MASK; + pOperateMCS[0] &= RATE_ADPT_1SS_MASK; + pOperateMCS[1] &= RATE_ADPT_2SS_MASK; + pOperateMCS[3] &= RATE_ADPT_MCS32_MASK; break; default: break; @@ -769,145 +765,151 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) return true; } -u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter) +u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter) { u8 i, j; u8 bitMap; u8 mcsRate = 0; u8 availableMcsRate[16]; - if (pMCSRateSet == NULL || pMCSFilter == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + if (pMCSRateSet == NULL || pMCSFilter == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't " + "be null in HTGetHighestMCSRate()\n"); return false; } - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i]; - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (availableMcsRate[i] != 0) break; } if (i == 16) return false; - for (i = 0; i < 16; i++) - { - if (availableMcsRate[i] != 0) - { + for (i = 0; i < 16; i++) { + if (availableMcsRate[i] != 0) { bitMap = availableMcsRate[i]; - for (j = 0; j < 8; j++) - { - if ((bitMap%2) != 0) - { - if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) + for (j = 0; j < 8; j++) { + if ((bitMap%2) != 0) { + if (HTMcsToDataRate(ieee, (8*i+j)) > + HTMcsToDataRate(ieee, mcsRate)) mcsRate = (8*i+j); } bitMap = bitMap>>1; } } } - return (mcsRate|0x80); + return mcsRate | 0x80; } -u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS) +u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS) { - u8 i=0; - - for (i=0;i<=15;i++){ - pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i]&pSupportMCS[i]; - } - + u8 i; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i] & + pSupportMCS[i]; HT_PickMCSRate(ieee, pOperateMCS); if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pOperateMCS[1] = 0; - for (i=2; i<=15; i++) + for (i = 2; i <= 15; i++) pOperateMCS[i] = 0; return true; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct ht_capab_ele *pPeerHTCap = NULL; struct ht_info_ele *pPeerHTInfo = NULL; - u16 nMaxAMSDUSize = 0; - u8* pMcsFilter = NULL; + u16 nMaxAMSDUSize = 0; + u8 *pMcsFilter = NULL; - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; + static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; - if ( pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); + if (pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): " + "HT_DISABLE\n"); return; } RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); - if (!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) + if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap))) pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]); else pPeerHTCap = (struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf); if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - pPeerHTInfo = (struct ht_info_ele *)(&pHTInfo->PeerHTInfoBuf[4]); + pPeerHTInfo = (struct ht_info_ele *) + (&pHTInfo->PeerHTInfoBuf[4]); else pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); - HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); - pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap, + sizeof(struct ht_capab_ele)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), + (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); + pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? + true : false); - pHTInfo->bCurShortGI20MHz= - ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false); - pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false); + pHTInfo->bCurShortGI20MHz = ((pHTInfo->bRegShortGI20MHz) ? + ((pPeerHTCap->ShortGI20Mhz == 1) ? + true : false) : false); + pHTInfo->bCurShortGI40MHz = ((pHTInfo->bRegShortGI40MHz) ? + ((pPeerHTCap->ShortGI40Mhz == 1) ? + true : false) : false); - pHTInfo->bCurSuppCCK = - ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false); + pHTInfo->bCurSuppCCK = ((pHTInfo->bRegSuppCCK) ? + ((pPeerHTCap->DssCCk == 1) ? true : + false) : false); pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; - nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935; + nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935; - if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize ) + if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize) pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; else pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){ - if ( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) || - (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) ) + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) || + (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN)) pHTInfo->bCurrentAMPDUEnable = false; } - if (!pHTInfo->bRegRT2RTAggregation) - { + if (!pHTInfo->bRegRT2RTAggregation) { if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; } else { - if (ieee->current_network.bssht.bdRT2RTAggregation) - { - if ( ieee->pairwise_key_type != KEY_TYPE_NA) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + if (ieee->current_network.bssht.bdRT2RTAggregation) { + if (ieee->pairwise_key_type != KEY_TYPE_NA) + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; - }else - { + } else { if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; } @@ -916,8 +918,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; else pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; - if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) - { + if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; pHTInfo->ForcedAMSDUMaxSize = 7935; @@ -927,7 +928,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) if (pPeerHTCap->MCS[0] == 0) pPeerHTCap->MCS[0] = 0xff; - HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0)); + HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1]) != 0)); HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); @@ -936,15 +937,14 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pMcsFilter = MCS_FILTER_1SS; else pMcsFilter = MCS_FILTER_ALL; - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, pMcsFilter); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } -void HTSetConnectBwModeCallback(struct rtllib_device* ieee); -void HTInitializeHTInfo(struct rtllib_device* ieee) +void HTInitializeHTInfo(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -965,10 +965,14 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); - memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); - memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); - memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); + memset((void *)(&(pHTInfo->SelfHTCap)), 0, + sizeof(pHTInfo->SelfHTCap)); + memset((void *)(&(pHTInfo->SelfHTInfo)), 0, + sizeof(pHTInfo->SelfHTInfo)); + memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0, + sizeof(pHTInfo->PeerHTCapBuf)); + memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, + sizeof(pHTInfo->PeerHTInfoBuf)); pHTInfo->bSwBwInProgress = false; pHTInfo->ChnlOp = CHNLOP_NONE; @@ -984,12 +988,13 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->IOTRaFunc = 0; { - u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); RegHTSuppRateSets[0] = 0xFF; RegHTSuppRateSets[1] = 0xFF; RegHTSuppRateSets[4] = 0x01; } } + void HTInitializeBssDesc(struct bss_ht *pBssHT) { @@ -999,39 +1004,46 @@ void HTInitializeBssDesc(struct bss_ht *pBssHT) memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf)); pBssHT->bdHTInfoLen = 0; - pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE; + pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE; pBssHT->bdRT2RTAggregation = false; pBssHT->bdRT2RTLongSlotTime = false; pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0; } -void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 bIOTAction = 0; RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); - /*unmark bEnableHT flag here is the same reason why unmarked in function rtllib_softmac_new_net. WB 2008.09.10*/ - if (pNetwork->bssht.bdSupportHT) - { + /* unmark bEnableHT flag here is the same reason why unmarked in + * function rtllib_softmac_new_net. WB 2008.09.10*/ + if (pNetwork->bssht.bdSupportHT) { pHTInfo->bCurrentHTSupport = true; pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; - if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) - memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); + if (pNetwork->bssht.bdHTCapLen > 0 && + pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) + memcpy(pHTInfo->PeerHTCapBuf, + pNetwork->bssht.bdHTCapBuf, + pNetwork->bssht.bdHTCapLen); - if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) - memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen); + if (pNetwork->bssht.bdHTInfoLen > 0 && + pNetwork->bssht.bdHTInfoLen <= + sizeof(pHTInfo->PeerHTInfoBuf)) + memcpy(pHTInfo->PeerHTInfoBuf, + pNetwork->bssht.bdHTInfoBuf, + pNetwork->bssht.bdHTInfoLen); - if (pHTInfo->bRegRT2RTAggregation) - { - pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation; - pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime; + if (pHTInfo->bRegRT2RTAggregation) { + pHTInfo->bCurrentRT2RTAggregation = + pNetwork->bssht.bdRT2RTAggregation; + pHTInfo->bCurrentRT2RTLongSlotTime = + pNetwork->bssht.bdRT2RTLongSlotTime; pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode; - } - else - { + } else { pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; @@ -1057,7 +1069,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; - bIOTAction = HTIOTActIsMgntUseCCK6M(ieee,pNetwork); + bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; bIOTAction = HTIOTActIsCCDFsync(ieee); @@ -1072,23 +1084,22 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net pHTInfo->IOTAction = 0; pHTInfo->IOTRaFunc = 0; } - } -void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct ht_info_ele *pPeerHTInfo = (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; + struct ht_info_ele *pPeerHTInfo = + (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; - if (pHTInfo->bCurrentHTSupport) - { + if (pHTInfo->bCurrentHTSupport) { if (pNetwork->bssht.bdHTInfoLen != 0) pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } } -void HTUseDefaultSetting(struct rtllib_device* ieee) +void HTUseDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1097,14 +1108,13 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz; - pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz; + pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz; - pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz; + pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz; if (ieee->iw_mode == IW_MODE_ADHOC) - { - ieee->current_network.qos_data.active = ieee->current_network.qos_data.supported; - } + ieee->current_network.qos_data.active = + ieee->current_network.qos_data.supported; pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; @@ -1113,9 +1123,11 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; - - HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); + HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, + ieee->dot11HTOperationalRateSet); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, + MCS_FILTER_ALL); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; } else { @@ -1124,20 +1136,49 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) return; } -u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) +u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) { - if (ieee->pHTInfo->bCurrentHTSupport) - { - if ( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) - { - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED EXIST!!\n"); + if (ieee->pHTInfo->bCurrentHTSupport) { + if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) { + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED " + "EXIST!!\n"); return true; } } return false; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +{ + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); + if (pHTInfo->bCurBW40MHz) { + if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel + 2); + else if (pHTInfo->CurSTAExtChnlOffset == + HT_EXTCHNL_OFFSET_LOWER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel - 2); + else + ieee->set_chan(ieee->dev, + ieee->current_network.channel); + + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, + pHTInfo->CurSTAExtChnlOffset); + } else { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } + + pHTInfo->bSwBwInProgress = false; +} + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1145,18 +1186,18 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi return; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - Bandwidth=HT_CHANNEL_WIDTH_20; - + Bandwidth = HT_CHANNEL_WIDTH_20; if (pHTInfo->bSwBwInProgress) { - printk("%s: bSwBwInProgress!!\n", __func__); + printk(KERN_INFO "%s: bSwBwInProgress!!\n", __func__); return; } - if (Bandwidth==HT_CHANNEL_WIDTH_20_40) - { - if (ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Bandwidth == HT_CHANNEL_WIDTH_20_40) { + if (ieee->current_network.channel < 2 && + Offset == HT_EXTCHNL_OFFSET_LOWER) Offset = HT_EXTCHNL_OFFSET_NO_EXT; - if (Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) { + if (Offset == HT_EXTCHNL_OFFSET_UPPER || + Offset == HT_EXTCHNL_OFFSET_LOWER) { pHTInfo->bCurBW40MHz = true; pHTInfo->CurSTAExtChnlOffset = Offset; } else { @@ -1168,33 +1209,10 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; } - printk("%s():pHTInfo->bCurBW40MHz:%x\n", __func__, pHTInfo->bCurBW40MHz); + printk(KERN_INFO "%s():pHTInfo->bCurBW40MHz:%x\n", __func__, + pHTInfo->bCurBW40MHz); pHTInfo->bSwBwInProgress = true; HTSetConnectBwModeCallback(ieee); - -} - -void HTSetConnectBwModeCallback(struct rtllib_device* ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); - if (pHTInfo->bCurBW40MHz) - { - if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee->dev, ieee->current_network.channel+2); - else if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee->dev, ieee->current_network.channel-2); - else - ieee->set_chan(ieee->dev, ieee->current_network.channel); - - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset); - } else { - ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } - - pHTInfo->bSwBwInProgress = false; } From d76eaf7eb8fb0e710c5e1ce74fafbb63b2096a8e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 15:15:28 -0500 Subject: [PATCH 0524/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VI Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 245 +++++++------- drivers/staging/rtl8192e/rtl819x_TS.h | 2 + drivers/staging/rtl8192e/rtl819x_TSProc.c | 369 ++++++++++------------ 3 files changed, 310 insertions(+), 306 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 0d2f8bff474..5ecd556f079 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -21,38 +21,38 @@ #include "rtllib_endianfree.h" -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 union qos_tsinfo { u8 charData[3]; @@ -67,14 +67,13 @@ union qos_tsinfo { u8 ucTSInfoAckPolicy:2; u8 ucSchedule:1; u8 ucReserved:7; - }field; + } field; }; union tspec_body { u8 charData[55]; - struct - { + struct { union qos_tsinfo TSInfo; u16 NominalMSDUsize; u16 MaxMSDUsize; @@ -105,9 +104,10 @@ struct wmm_tspec { }; struct octet_string { - u8 *Octet; - u16 Length; + u8 *Octet; + u16 Length; }; + #define MAX_WMMELE_LENGTH 64 #define QOS_MODE u32 @@ -143,28 +143,43 @@ enum ack_policy { }; -#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) +#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) \ + WriteEF1Byte(_pStart, _val) -#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4) -#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) +#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 4) +#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) -#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1) -#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 7, 1) +#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 1, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 2, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 3, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) -#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 5, 2) +#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) enum qos_ie_source { QOSIE_SRC_ADDTSREQ, @@ -186,26 +201,40 @@ enum qos_ie_source { #define AC_PARAM_SIZE 4 -#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) ) -#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) +#define GET_WMM_AC_PARAM_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 4)) +#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) -#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) ) -#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) +#define GET_WMM_AC_PARAM_ACM(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 4, 1)) +#define SET_WMM_AC_PARAM_ACM(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) -#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) ) -#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) +#define GET_WMM_AC_PARAM_ACI(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 5, 2)) +#define SET_WMM_AC_PARAM_ACI(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) -#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) ) -#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) +#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 8)) +#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) -#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) ) -#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) +#define GET_WMM_AC_PARAM_ECWMIN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 8, 4)) +#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) -#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) ) -#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) +#define GET_WMM_AC_PARAM_ECWMAX(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 12, 4)) +#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) -#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) ) -#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) +#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 16, 16)) +#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) @@ -255,13 +284,13 @@ struct acm { union qos_tclas { - struct _TYPE_GENERAL{ + struct _TYPE_GENERAL { u8 Priority; u8 ClassifierType; u8 Mask; } TYPE_GENERAL; - struct _TYPE0_ETH{ + struct _TYPE0_ETH { u8 Priority; u8 ClassifierType; u8 Mask; @@ -270,7 +299,7 @@ union qos_tclas { u16 Type; } TYPE0_ETH; - struct _TYPE1_IPV4{ + struct _TYPE1_IPV4 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -284,7 +313,7 @@ union qos_tclas { u8 Reserved; } TYPE1_IPV4; - struct _TYPE1_IPV6{ + struct _TYPE1_IPV6 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -296,7 +325,7 @@ union qos_tclas { u8 FlowLabel[3]; } TYPE1_IPV6; - struct _TYPE2_8021Q{ + struct _TYPE2_8021Q { u8 Priority; u8 ClassifierType; u8 Mask; @@ -317,20 +346,20 @@ struct qos_tstream { }; struct sta_qos { - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8* WMMIE; + u8 WMMIEBuf[MAX_WMMELE_LENGTH]; + u8 *WMMIE; - QOS_MODE QosCapability; - QOS_MODE CurrentQosMode; + QOS_MODE QosCapability; + QOS_MODE CurrentQosMode; - AC_UAPSD b4ac_Uapsd; - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; + AC_UAPSD b4ac_Uapsd; + AC_UAPSD Curr4acUapsd; + u8 bInServicePeriod; + u8 MaxSPLength; + int NumBcnBeforeTrigger; - u8 * pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; + u8 *pWMMInfoEle; + u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; struct acm acm[4]; enum acm_method AcmMethod; @@ -347,67 +376,69 @@ struct sta_qos { }; -#define QBSS_LOAD_SIZE 5 -#define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) -#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value) -#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2) -#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value) -#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3) -#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value) +#define QBSS_LOAD_SIZE 5 +#define GET_QBSS_LOAD_STA_COUNT(__pStart) \ + ReadEF2Byte(__pStart) +#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) \ + WriteEF2Byte(__pStart, __Value) +#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) \ + ReadEF1Byte((u8 *)(__pStart) + 2) +#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) \ + WriteEF1Byte((u8 *)(__pStart) + 2, __Value) +#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) \ + ReadEF2Byte((u8 *)(__pStart) + 3) +#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) \ + WriteEF2Byte((u8 *)(__pStart) + 3, __Value) struct bss_qos { - - QOS_MODE bdQoSMode; - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; + QOS_MODE bdQoSMode; + u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; struct octet_string bdWMMIE; enum qos_ele_subtype EleSubType; - u8* pWMMInfoEle; - u8* pWMMParamEle; + u8 *pWMMInfoEle; + u8 *pWMMParamEle; - u8 QBssLoad[QBSS_LOAD_SIZE]; - bool bQBssLoadValid; + u8 QBssLoad[QBSS_LOAD_SIZE]; + bool bQBssLoadValid; }; #define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) +#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0) -#define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false ) +#define IsACValid(ac) ((ac >= 0 && ac <= 7) ? true : false) union aci_aifsn { u8 charData; - struct - { + struct { u8 AIFSN:4; u8 acm:1; u8 ACI:2; u8 Reserved:1; - }f; + } f; }; union ecw { u8 charData; - struct - { + struct { u8 ECWmin:4; u8 ECWmax:4; - }f; + } f; }; union ac_param { u32 longData; u8 charData[4]; - struct - { + struct { union aci_aifsn AciAifsn; union ecw Ecw; u16 TXOPLimit; - }f; + } f; }; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index b4bebab3632..8601b1ad217 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -67,5 +67,7 @@ struct rx_ts_record { u8 num; }; +void _setup_timer(struct timer_list *, void *, unsigned long); + #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index a6dbd26c691..519349f0ce4 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -19,7 +19,6 @@ #include "rtllib.h" #include #include "rtl819x_TS.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long); void TsSetupTimeOut(unsigned long data) { @@ -32,7 +31,8 @@ void TsInactTimeout(unsigned long data) void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); struct rx_reorder_entry *pReorderEntry = NULL; @@ -42,51 +42,57 @@ void RxPktPendingTimeout(unsigned long data) bool bPktInBuf = false; spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - if (pRxTs->RxTimeoutIndicateSeq != 0xffff) - { - while(!list_empty(&pRxTs->RxPendingPktList)) - { - pReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTs->RxPendingPktList.prev,struct rx_reorder_entry,List); + if (pRxTs->RxTimeoutIndicateSeq != 0xffff) { + while (!list_empty(&pRxTs->RxPendingPktList)) { + pReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTs->RxPendingPktList.prev, + struct rx_reorder_entry, List); if (index == 0) pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; - if ( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) - { + if (SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) { list_del_init(&pReorderEntry->List); - if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) - pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; + if (SN_EQUAL(pReorderEntry->SeqNum, + pRxTs->RxIndicateSeq)) + pRxTs->RxIndicateSeq = + (pRxTs->RxIndicateSeq + 1) % 4096; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, pReorderEntry->SeqNum); - stats_IndicateArray[index] = pReorderEntry->prxb; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate" + " SeqNum: %d\n", __func__, + pReorderEntry->SeqNum); + stats_IndicateArray[index] = + pReorderEntry->prxb; index++; - list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); - } - else - { + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); + } else { bPktInBuf = true; break; } } } - if (index>0){ + if (index > 0) { pRxTs->RxTimeoutIndicateSeq = 0xffff; - if (index > REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, stats_IndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){ + if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) { pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; - mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); + mod_timer(&pRxTs->RxPktPendingTimer, jiffies + + MSECS(ieee->pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } @@ -95,13 +101,14 @@ void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[num]); TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is " + "started!!\n"); } - void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); @@ -142,8 +149,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pTxTS->num = count; _setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, @@ -173,8 +179,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); @@ -195,13 +200,14 @@ void TSInitialize(struct rtllib_device *ieee) (unsigned long) pRxTS); ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); + list_add_tail(&pRxTS->TsCommonInfo.List, + &ieee->Rx_TS_Unused_List); pRxTS++; } INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); - for (count = 0; count < REORDER_ENTRY_NUM; count++) - { - list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + for (count = 0; count < REORDER_ENTRY_NUM; count++) { + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); if (count == (REORDER_ENTRY_NUM-1)) break; pRxReorderEntry = &ieee->RxReorderEntry[count+1]; @@ -209,55 +215,46 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) +void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, + u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); - if (InactTime!=0) - mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); + if (InactTime != 0) + mod_timer(&pTsCommonInfo->InactTimer, jiffies + + MSECS(InactTime)); } - -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, enum tr_select TxRxSelect) +struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, + u8 TID, enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; - struct list_head* psearch_list; + bool search_dir[4] = {0, 0, 0, 0}; + struct list_head *psearch_list; struct ts_common_info *pRet = NULL; - if (ieee->iw_mode == IW_MODE_MASTER) - { - if (TxRxSelect == TX_DIR) - { + if (ieee->iw_mode == IW_MODE_MASTER) { + if (TxRxSelect == TX_DIR) { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; + search_dir[DIR_BI_DIR] = true; + } else { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; } - else - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - } - } - else if (ieee->iw_mode == IW_MODE_ADHOC) - { + } else if (ieee->iw_mode == IW_MODE_ADHOC) { if (TxRxSelect == TX_DIR) - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; else search_dir[DIR_DOWN] = true; - } - else - { - if (TxRxSelect == TX_DIR) - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; - } - else - { + } else { + if (TxRxSelect == TX_DIR) { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; + } else { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; } } @@ -266,38 +263,29 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, else psearch_list = &ieee->Rx_TS_Admit_List; - for (dir = 0; dir <= DIR_BI_DIR; dir++) - { - if (search_dir[dir] ==false ) + for (dir = 0; dir <= DIR_BI_DIR; dir++) { + if (search_dir[dir] == false) continue; - list_for_each_entry(pRet, psearch_list, List){ + list_for_each_entry(pRet, psearch_list, List) { if (memcmp(pRet->Addr, Addr, 6) == 0) if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) if (pRet->TSpec.f.TSInfo.field.ucDirection == dir) - { break; - } } if (&pRet->List != psearch_list) break; } - if (&pRet->List != psearch_list){ + if (&pRet->List != psearch_list) return pRet ; - } else return NULL; } -void MakeTSEntry( - struct ts_common_info *pTsCommonInfo, - u8* Addr, - union tspec_body *pTSPEC, - union qos_tclas *pTCLAS, - u8 TCLAS_Num, - u8 TCLAS_Proc - ) +void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -307,34 +295,32 @@ void MakeTSEntry( memcpy(pTsCommonInfo->Addr, Addr, 6); if (pTSPEC != NULL) - memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(union tspec_body)); + memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC, + sizeof(union tspec_body)); for (count = 0; count < TCLAS_Num; count++) - memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(union qos_tclas)); + memcpy((u8 *)(&(pTsCommonInfo->TClass[count])), + (u8 *)pTCLAS, sizeof(union qos_tclas)); pTsCommonInfo->TClasProc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; } -bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs) +bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, + u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) { u8 UP = 0; - if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n"); + if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or " + "Multicast\n"); return false; } if (ieee->current_network.qos_data.supported == 0) { UP = 0; } else { if (!IsACValid(TID)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __func__, TID); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is " + "not valid\n", __func__, TID); return false; } @@ -358,55 +344,54 @@ bool GetTs( } } - *ppTS = SearchAdmitTRStream( - ieee, - Addr, - UP, - TxRxSelect); - if (*ppTS != NULL) - { + *ppTS = SearchAdmitTRStream(ieee, Addr, UP, TxRxSelect); + if (*ppTS != NULL) { return true; - } - else - { - if (bAddNewTs == false) - { - RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP); + } else { + if (bAddNewTs == false) { + RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed" + "(tid:%d)\n", UP); return false; - } - else - { + } else { union tspec_body TSpec; union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; - struct list_head* pUnusedList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Unused_List): - (&ieee->Rx_TS_Unused_List); + struct list_head *pUnusedList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Unused_List) : + (&ieee->Rx_TS_Unused_List); - struct list_head* pAddmitList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Admit_List): - (&ieee->Rx_TS_Admit_List); + struct list_head *pAddmitList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Admit_List) : + (&ieee->Rx_TS_Admit_List); - enum direction_value Dir = (ieee->iw_mode == IW_MODE_MASTER)? - ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): - ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); + enum direction_value Dir = + (ieee->iw_mode == IW_MODE_MASTER) ? + ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) : + ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN); RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); - if (!list_empty(pUnusedList)) - { - (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); + if (!list_empty(pUnusedList)) { + (*ppTS) = list_entry(pUnusedList->next, + struct ts_common_info, List); list_del_init(&(*ppTS)->List); - if (TxRxSelect==TX_DIR) - { - struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *tmp = + container_of(*ppTS, + struct tx_ts_record, + TsCommonInfo); ResetTxTsEntry(tmp); - } - else{ - struct rx_ts_record *tmp = container_of(*ppTS, struct rx_ts_record, TsCommonInfo); + } else { + struct rx_ts_record *tmp = + container_of(*ppTS, + struct rx_ts_record, + TsCommonInfo); ResetRxTsEntry(tmp); } - RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS); + RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" + ", UP:%d, Dir:%d, addr:"MAC_FMT + " ppTs=%p\n", UP, Dir, + MAC_ARG(Addr), *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -422,99 +407,90 @@ bool GetTs( list_add_tail(&((*ppTS)->List), pAddmitList); return true; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __func__,Dir); + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function " + "%s() There is not enough dir=%d" + "(0=up down=1) TS record to be " + "used!!", __func__, Dir); return false; } } } } -void RemoveTsEntry( - struct rtllib_device* ieee, - struct ts_common_info *pTs, - enum tr_select TxRxSelect - ) +void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); TsInitDelBA(ieee, pTs, TxRxSelect); - if (TxRxSelect == RX_DIR) - { + if (TxRxSelect == RX_DIR) { struct rx_reorder_entry *pRxReorderEntry; struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if (timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); - while(!list_empty(&pRxTS->RxPendingPktList)){ - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + while (!list_empty(&pRxTS->RxPendingPktList)) { + pRxReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Delete SeqNum " + "%d!\n", __func__, + pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); { int i = 0; - struct rtllib_rxb * prxb = pRxReorderEntry->prxb; - if (unlikely(!prxb)){ + struct rtllib_rxb *prxb = pRxReorderEntry->prxb; + if (unlikely(!prxb)) return; - } - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } - list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); } - } - else{ + } else { struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; del_timer_sync(&pTxTS->TsAddBaTimer); } } -void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) +void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - printk("====>remove Tx_TS_admin_list\n"); + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { + printk(KERN_INFO "====>remove Tx_TS_admin_list\n"); RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); @@ -522,56 +498,51 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) } } -void RemoveAllTS(struct rtllib_device* ieee) +void RemoveAllTS(struct rtllib_device *ieee) { struct ts_common_info *pTS, *pTmpTS; - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } -void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS) +void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS) { - if (pTxTS->bAddBaReqInProgress == false) - { + if (pTxTS->bAddBaReqInProgress == false) { pTxTS->bAddBaReqInProgress = true; - if (pTxTS->bAddBaReqDelayed) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + if (pTxTS->bAddBaReqDelayed) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Delayed Start ADDBA after 60 sec!!\n"); + mod_timer(&pTxTS->TsAddBaTimer, jiffies + + MSECS(TS_ADDBA_DELAY)); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Immediately Start ADDBA now!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); } - } - else - RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__); + } else + RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", + __func__); } From 922d71a409714bf0bc73423d04e2849d35b4d934 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 17:51:41 -0500 Subject: [PATCH 0525/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_cam.c | 325 +++++++++++------------------ drivers/staging/rtl8192e/rtl_cam.h | 10 +- 2 files changed, 132 insertions(+), 203 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index 4a11b30d184..a9991a0fa1c 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -40,12 +40,12 @@ void CamResetAllEntry(struct net_device *dev) void write_cam(struct net_device *dev, u8 addr, u32 data) { write_nic_dword(dev, WCAMI, data); - write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) ); + write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff)); } u32 read_cam(struct net_device *dev, u8 addr) { - write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) ); + write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff)); return read_nic_dword(dev, 0xa8); } @@ -53,66 +53,53 @@ void EnableHWSecurityConfig8192(struct net_device *dev) { u8 SECR_value = 0x0; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->rtllib->auth_mode != 2)) - { + if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && + (priv->rtllib->auth_mode != 2)) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { + } else if ((ieee->iw_mode == IW_MODE_ADHOC) && + (ieee->pairwise_key_type & (KEY_TYPE_CCMP | + KEY_TYPE_TKIP))) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; } ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) - { + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__, \ - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(dev, SECR, SECR_value); - } + RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", + __func__, ieee->hwsec_active, ieee->pairwise_key_type, + SECR_value); + write_nic_byte(dev, SECR, SECR_value); } -void set_swcam(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent, - u8 is_mesh) +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is " "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo, KeyIndex, KeyType, is_mesh); - if (is_mesh){ - } else { - ieee->swcamtable[EntryNo].bused=true; - ieee->swcamtable[EntryNo].key_index=KeyIndex; - ieee->swcamtable[EntryNo].key_type=KeyType; - memcpy(ieee->swcamtable[EntryNo].macaddr,MacAddr,6); - ieee->swcamtable[EntryNo].useDK=DefaultKey; - memcpy(ieee->swcamtable[EntryNo].key_buf,(u8*)KeyContent,16); + if (!is_mesh) { + ieee->swcamtable[EntryNo].bused = true; + ieee->swcamtable[EntryNo].key_index = KeyIndex; + ieee->swcamtable[EntryNo].key_type = KeyType; + memcpy(ieee->swcamtable[EntryNo].macaddr, MacAddr, 6); + ieee->swcamtable[EntryNo].useDK = DefaultKey; + memcpy(ieee->swcamtable[EntryNo].key_buf, (u8 *)KeyContent, 16); } } -void setKey(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent ) +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) { u32 TargetCommand = 0; u32 TargetContent = 0; @@ -121,17 +108,17 @@ void setKey(struct net_device *dev, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return ; - } - else{ + } else { down(&priv->rtllib->ips_sem); IPSLeave(dev); - up(&priv->rtllib->ips_sem); } + up(&priv->rtllib->ips_sem); + } } } priv->rtllib->is_set_key = true; @@ -139,7 +126,7 @@ void setKey(struct net_device *dev, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev,EntryNo, KeyIndex, + "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, KeyType, MAC_ARG(MacAddr)); if (DefaultKey) @@ -149,227 +136,167 @@ void setKey(struct net_device *dev, for (i = 0; i < CAM_CONTENT_COUNT; i++) { - TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; + TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; TargetCommand |= BIT31|BIT16; if (i == 0) { - TargetContent = (u32)(*(MacAddr+0)) << 16| - (u32)(*(MacAddr+1)) << 24| + TargetContent = (u32)(*(MacAddr+0)) << 16 | + (u32)(*(MacAddr+1)) << 24 | (u32)usConfig; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else if (i == 1) { - TargetContent = (u32)(*(MacAddr+2)) | - (u32)(*(MacAddr+3)) << 8| - (u32)(*(MacAddr+4)) << 16| + TargetContent = (u32)(*(MacAddr+2)) | + (u32)(*(MacAddr+3)) << 8 | + (u32)(*(MacAddr+4)) << 16 | (u32)(*(MacAddr+5)) << 24; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else { if (KeyContent != NULL) { - write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); + write_nic_dword(dev, WCAMI, + (u32)(*(KeyContent+i-2))); write_nic_dword(dev, RWCAM, TargetCommand); udelay(100); } } } - RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig); + RT_TRACE(COMP_SEC, "=========>after set key, usconfig:%x\n", usConfig); } void CAM_read_entry(struct net_device *dev, u32 iIndex) { - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; - s32 i=100; - for (entry_i=0;entry_i=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); - RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A0: %x\n", + target_command); target_content = read_nic_dword(dev, RCAMO); - RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x\n", + target_content); } - printk("\n"); + printk(KERN_INFO "\n"); } -void CamRestoreAllEntry( struct net_device *dev) +void CamRestoreAllEntry(struct net_device *dev) { u8 EntryId = 0; struct r8192_priv *priv = rtllib_priv(dev); - u8* MacAddr = priv->rtllib->current_network.bssid; + u8 *MacAddr = priv->rtllib->current_network.bssid; static u8 CAM_CONST_ADDR[4][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}; - static u8 CAM_CONST_BROAD[] = - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} + }; + static u8 CAM_CONST_BROAD[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; - RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n"); + RT_TRACE(COMP_SEC, "CamRestoreAllEntry:\n"); - if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40)|| - (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) - { + if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40) || + (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) { - for (EntryId=0; EntryId<4; EntryId++) - { - { - MacAddr = CAM_CONST_ADDR[EntryId]; - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); - } + for (EntryId = 0; EntryId < 4; EntryId++) { + MacAddr = CAM_CONST_ADDR[EntryId]; + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable + [EntryId].key_buf[0])); } } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) - { - - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); + } else { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) - { - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); + } else { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - } } - - - if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) - { + if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1 ; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId, - EntryId, - priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId, EntryId, + priv->rtllib->group_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) + ); } } - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - if (priv->rtllib->swcamtable[0].bused ){ - setKey(dev, - 0, - 0, - priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0]) - ); - } - else - { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",__func__); + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + if (priv->rtllib->swcamtable[0].bused) { + setKey(dev, 0, 0, + priv->rtllib->group_key_type, + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]) + ); + } else { + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC TKIP " + ",but 0 entry is have no data\n", + __func__); return; } } } else if (priv->rtllib->group_key_type == KEY_TYPE_CCMP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); } } if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { if (priv->rtllib->swcamtable[0].bused) { - setKey(dev, - 0 , - 0, + setKey(dev, 0 , 0, priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0])); + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])); } else { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n", - __func__); + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC CCMP ," + "but 0 entry is have no data\n", + __func__); return; } } diff --git a/drivers/staging/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl_cam.h index 9e4d0edb21b..fa607f98b17 100644 --- a/drivers/staging/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl_cam.h @@ -28,11 +28,13 @@ #include struct net_device; -void CamResetAllEntry(struct net_device* dev); +void CamResetAllEntry(struct net_device *dev); void EnableHWSecurityConfig8192(struct net_device *dev); -void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent ); -void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); -void CamPrintDbgReg(struct net_device* dev); +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); +void CamPrintDbgReg(struct net_device *dev); u32 read_cam(struct net_device *dev, u8 addr); void write_cam(struct net_device *dev, u8 addr, u32 data); From 42b565df8567751dfdca85b57de6219ddfee49f8 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Thu, 25 Aug 2011 12:53:30 +0200 Subject: [PATCH 0526/1519] staging/olpc_dcon: Remove obsolete cleanup for clientdata A few new i2c-drivers came into the kernel which clear the clientdata-pointer on exit or error. This is obsolete meanwhile, the core will do it. Signed-off-by: Wolfram Sang Acked-by: Andres Salomon Cc: Andrew Morton Cc: Marek Belisko Acked-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 87268059eb4..d3cd68e9045 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -697,7 +697,6 @@ static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) eirq: free_irq(DCON_IRQ, dcon); einit: - i2c_set_clientdata(client, NULL); kfree(dcon); return rc; } @@ -706,8 +705,6 @@ static int dcon_remove(struct i2c_client *client) { struct dcon_priv *dcon = i2c_get_clientdata(client); - i2c_set_clientdata(client, NULL); - fb_unregister_client(&dcon->fbevent_nb); unregister_reboot_notifier(&dcon->reboot_nb); atomic_notifier_chain_unregister(&panic_notifier_list, &dcon_panic_nb); From 09ebd6f23b07f1eb0c8850af32d05519ddeaa524 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 25 Aug 2011 16:17:06 +1000 Subject: [PATCH 0527/1519] staging: rtl8192e: using vmalloc/vfree requires including vmalloc.h Signed-off-by: Stephen Rothwell Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index e633f0b074e..cb1830b9f84 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -43,6 +43,7 @@ #include #include +#include #include "rtl_core.h" #include "r8192E_phy.h" #include "r8192E_phyreg.h" From 75bf74b90fd0c21b92d5e6153eb40388812e7096 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 24 Aug 2011 23:16:48 -0700 Subject: [PATCH 0528/1519] staging: brcmfmac: Consolidate debugging macros Convert multiple BRCMF_ macros to a single brcmf_dbg(level, fmt, ...) macro. Remove the now unnecessary double parentheses in the uses of the old macros when converting to brcmf_dbg. Delete all uses of "%s: [fmt]", __func__, args... and move the "%s: ", __func__ to the macro for consistency. Coalesce long formats. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 46 +- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 163 ++-- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 66 +- .../staging/brcm80211/brcmfmac/dhd_common.c | 228 +++-- drivers/staging/brcm80211/brcmfmac/dhd_dbg.h | 46 +- .../staging/brcm80211/brcmfmac/dhd_linux.c | 201 ++--- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 806 ++++++++---------- 7 files changed, 694 insertions(+), 862 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 0c845c945f2..8448b8bb549 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -86,8 +86,7 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, if (!set && !(arg && len)) return -EINVAL; - BRCMF_TRACE(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), - name)); + brcmf_dbg(TRACE, "Enter (%s %s)\n", set ? "set" : "get", name); vi = brcmu_iovar_lookup(sdioh_iovars, name); if (vi == NULL) { @@ -168,7 +167,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) { struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); - BRCMF_TRACE(("brcmf: ***IRQHandler\n")); + brcmf_dbg(TRACE, "***IRQHandler\n"); sdio_release_host(func); @@ -179,7 +178,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) { - BRCMF_TRACE(("%s: Entering\n", __func__)); + brcmf_dbg(TRACE, "Entering\n"); sdio_claim_host(sdiodev->func[1]); sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler); @@ -190,7 +189,7 @@ int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) { - BRCMF_TRACE(("%s: Entering\n", __func__)); + brcmf_dbg(TRACE, "Entering\n"); sdio_claim_host(sdiodev->func[1]); sdio_release_irq(sdiodev->func[1]); @@ -216,8 +215,8 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, if (err) *err = status; - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", - __func__, fnc_num, addr, data)); + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n", + fnc_num, addr, data); return data; } @@ -239,8 +238,8 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, if (err) *err = status; - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n", - __func__, fnc_num, addr, data)); + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n", + fnc_num, addr, data); } int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, @@ -260,7 +259,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, into the provided buffer. */ tmp_buf = kmalloc(length, GFP_ATOMIC); if (tmp_buf == NULL) { - BRCMF_ERROR(("%s: out of memory\n", __func__)); + brcmf_dbg(ERROR, "out of memory\n"); return -ENOMEM; } memcpy(tmp_buf, cis, length); @@ -302,7 +301,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) u32 word = 0; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - BRCMF_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr)); + brcmf_dbg(INFO, "fun = 1, addr = 0x%x\n", addr); if (bar0 != sdiodev->sbwad) { if (brcmf_sdcard_set_sbaddr_window(sdiodev, bar0)) @@ -320,7 +319,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) sdiodev->regfail = (status != 0); - BRCMF_INFO(("u32data = 0x%x\n", word)); + brcmf_dbg(INFO, "u32data = 0x%x\n", word); /* if ok, return appropriately masked word */ if (status == 0) { @@ -338,8 +337,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) } /* otherwise, bad sdio access or invalid size */ - BRCMF_ERROR(("%s: error reading addr 0x%04x size %d\n", __func__, - addr, size)); + brcmf_dbg(ERROR, "error reading addr 0x%04x size %d\n", addr, size); return 0xFFFFFFFF; } @@ -350,8 +348,8 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", - __func__, addr, size * 8, data)); + brcmf_dbg(INFO, "fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", + addr, size * 8, data); if (bar0 != sdiodev->sbwad) { err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); @@ -372,8 +370,8 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, if (status == 0) return 0; - BRCMF_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n", - __func__, data, addr, size)); + brcmf_dbg(ERROR, "error writing 0x%08x to addr 0x%04x size %d\n", + data, addr, size); return 0xFFFFFFFF; } @@ -393,8 +391,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", - __func__, fn, addr, nbytes)); + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); /* Async not implemented yet */ if (flags & SDIO_REQ_ASYNC) @@ -430,8 +427,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n", - __func__, fn, addr, nbytes)); + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); /* Async not implemented yet */ if (flags & SDIO_REQ_ASYNC) @@ -470,13 +466,13 @@ int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) { char t_func = (char)fn; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* issue abort cmd52 command through F0 */ brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, SDIO_FUNC_0, SDIO_CCCR_ABORT, &t_func); - BRCMF_TRACE(("%s: Exit\n", __func__)); + brcmf_dbg(TRACE, "Exit\n"); return 0; } @@ -502,7 +498,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) /* try to attach to the target device */ sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev); if (!sdiodev->bus) { - BRCMF_ERROR(("%s: device attach failed\n", __func__)); + brcmf_dbg(ERROR, "device attach failed\n"); ret = -ENODEV; goto out; } diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index fca966cd30f..0b92cef5bb6 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -111,21 +111,21 @@ static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) u32 fbraddr; u8 func; - BRCMF_TRACE(("%s\n", __func__)); + brcmf_dbg(TRACE, "\n"); /* Get the Card's common CIS address */ sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev, SDIO_CCCR_CIS); - BRCMF_INFO(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, - sdiodev->func_cis_ptr[0])); + brcmf_dbg(INFO, "Card's Common CIS Ptr = 0x%x\n", + sdiodev->func_cis_ptr[0]); /* Get the Card's function CIS (for each function) */ for (fbraddr = SDIO_FBR_BASE(1), func = 1; func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { sdiodev->func_cis_ptr[func] = brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr); - BRCMF_INFO(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func, - sdiodev->func_cis_ptr[func])); + brcmf_dbg(INFO, "Function %d CIS Ptr = 0x%x\n", + func, sdiodev->func_cis_ptr[func]); } /* Enable Function 1 */ @@ -133,8 +133,7 @@ static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) err_ret = sdio_enable_func(sdiodev->func[1]); sdio_release_host(sdiodev->func[1]); if (err_ret) - BRCMF_ERROR(("brcmf_sdioh_enablefuncs: Failed to enable F1 " - "Err: 0x%08x\n", err_ret)); + brcmf_dbg(ERROR, "Failed to enable F1 Err: 0x%08x\n", err_ret); return false; } @@ -146,7 +145,7 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) { int err_ret = 0; - BRCMF_TRACE(("%s\n", __func__)); + brcmf_dbg(TRACE, "\n"); sdiodev->num_funcs = 2; @@ -154,7 +153,7 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) err_ret = sdio_set_block_size(sdiodev->func[1], 64); sdio_release_host(sdiodev->func[1]); if (err_ret) { - BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); + brcmf_dbg(ERROR, "Failed to set F1 blocksize\n"); goto out; } @@ -162,21 +161,21 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize); sdio_release_host(sdiodev->func[2]); if (err_ret) { - BRCMF_ERROR(("%s: Failed to set F2 blocksize" - " to %d\n", __func__, sd_f2_blocksize)); + brcmf_dbg(ERROR, "Failed to set F2 blocksize to %d\n", + sd_f2_blocksize); goto out; } brcmf_sdioh_enablefuncs(sdiodev); out: - BRCMF_TRACE(("%s: Done\n", __func__)); + brcmf_dbg(TRACE, "Done\n"); return err_ret; } void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) { - BRCMF_TRACE(("%s\n", __func__)); + brcmf_dbg(TRACE, "\n"); /* Disable Function 2 */ sdio_claim_host(sdiodev->func[2]); @@ -199,7 +198,7 @@ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) for (i = 0; i < 3; i++) { if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, ®data)) != SUCCESS) - BRCMF_ERROR(("%s: Can't read!\n", __func__)); + brcmf_dbg(ERROR, "Can't read!\n"); *ptr++ = (u8) regdata; regaddr++; @@ -220,22 +219,21 @@ brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u32 foo; u8 *cis = cisd; - BRCMF_TRACE(("%s: Func = %d\n", __func__, func)); + brcmf_dbg(TRACE, "Func = %d\n", func); if (!sdiodev->func_cis_ptr[func]) { memset(cis, 0, length); - BRCMF_ERROR(("%s: no func_cis_ptr[%d]\n", __func__, func)); + brcmf_dbg(ERROR, "no func_cis_ptr[%d]\n", func); return -ENOTSUPP; } - BRCMF_ERROR(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func, - sdiodev->func_cis_ptr[func])); + brcmf_dbg(ERROR, "func_cis_ptr[%d]=0x%04x\n", + func, sdiodev->func_cis_ptr[func]); for (count = 0; count < length; count++) { offset = sdiodev->func_cis_ptr[func] + count; if (brcmf_sdioh_card_regread(sdiodev, 0, offset, 1, &foo) < 0) { - BRCMF_ERROR(("%s: regread failed: Can't read CIS\n", - __func__)); + brcmf_dbg(ERROR, "regread failed: Can't read CIS\n"); return -EIO; } @@ -252,8 +250,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, { int err_ret; - BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, - regaddr)); + brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); @@ -272,22 +269,18 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, sdio_enable_func (sdiodev->func[2]); if (err_ret) - BRCMF_ERROR(( - "request_byte: " - "enable F2 " - "failed:%d\n", - err_ret)); + brcmf_dbg(ERROR, + "enable F2 failed:%d\n", + err_ret); } else { /* Disable Function 2 */ err_ret = sdio_disable_func (sdiodev->func[2]); if (err_ret) - BRCMF_ERROR(( - "request_byte: " - "Disab F2 " - "failed:%d\n", - err_ret)); + brcmf_dbg(ERROR, + "Disable F2 failed:%d\n", + err_ret); } sdio_release_host(sdiodev->func[2]); } @@ -305,8 +298,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, regaddr, &err_ret); sdio_release_host(sdiodev->func[func]); } else if (regaddr < 0xF0) { - BRCMF_ERROR(("brcmf: F0 Wr:0x%02x: write " - "disallowed\n", regaddr)); + brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", + regaddr); } else { /* Claim host controller, perform F0 write, and release */ @@ -341,9 +334,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, } if (err_ret) - BRCMF_ERROR(("brcmf: Failed to %s byte F%d:@0x%05x=%02x, " - "Err: %d\n", rw ? "Write" : "Read", func, regaddr, - *byte, err_ret)); + brcmf_dbg(ERROR, "Failed to %s byte F%d:@0x%05x=%02x, Err: %d\n", + rw ? "write" : "read", func, regaddr, *byte, err_ret); return err_ret; } @@ -355,12 +347,12 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, int err_ret = -EIO; if (func == 0) { - BRCMF_ERROR(("%s: Only CMD52 allowed to F0.\n", __func__)); + brcmf_dbg(ERROR, "Only CMD52 allowed to F0\n"); return -EINVAL; } - BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", - __func__, cmd_type, rw, func, addr, nbytes)); + brcmf_dbg(INFO, "cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", + cmd_type, rw, func, addr, nbytes); BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); @@ -375,8 +367,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, sdio_writew(sdiodev->func[func], (*word & 0xFFFF), addr, &err_ret); else - BRCMF_ERROR(("%s: Invalid nbytes: %d\n", - __func__, nbytes)); + brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } else { /* CMD52 Read */ if (nbytes == 4) *word = @@ -386,16 +377,15 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, sdio_readw(sdiodev->func[func], addr, &err_ret) & 0xFFFF; else - BRCMF_ERROR(("%s: Invalid nbytes: %d\n", - __func__, nbytes)); + brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } /* Release host controller */ sdio_release_host(sdiodev->func[func]); if (err_ret) - BRCMF_ERROR(("brcmf: Failed to %s word, Err: 0x%08x\n", - rw ? "Write" : "Read", err_ret)); + brcmf_dbg(ERROR, "Failed to %s word, Err: 0x%08x\n", + rw ? "write" : "read", err_ret); return err_ret; } @@ -411,7 +401,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, struct sk_buff *pnext; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); @@ -442,15 +432,13 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, } if (err_ret) { - BRCMF_ERROR(("%s: %s FAILED %p[%d], addr=0x%05x, " - "pkt_len=%d, ERR=0x%08x\n", __func__, - (write) ? "TX" : "RX", - pnext, SGCount, addr, pkt_len, err_ret)); + brcmf_dbg(ERROR, "%s FAILED %p[%d], addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", + write ? "TX" : "RX", pnext, SGCount, addr, + pkt_len, err_ret); } else { - BRCMF_TRACE(("%s: %s xfr'd %p[%d], addr=0x%05x, " - "len=%d\n", __func__, - (write) ? "TX" : "RX", - pnext, SGCount, addr, pkt_len)); + brcmf_dbg(TRACE, "%s xfr'd %p[%d], addr=0x%05x, len=%d\n", + write ? "TX" : "RX", pnext, SGCount, addr, + pkt_len); } if (!fifo) @@ -462,7 +450,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, /* Release host controller */ sdio_release_host(sdiodev->func[func]); - BRCMF_TRACE(("%s: Exit\n", __func__)); + brcmf_dbg(TRACE, "Exit\n"); return err_ret; } @@ -490,18 +478,18 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, int Status; struct sk_buff *mypkt = NULL; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); /* Case 1: we don't have a packet. */ if (pkt == NULL) { - BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n", - __func__, write ? "TX" : "RX", buflen_u)); + brcmf_dbg(DATA, "Creating new %s Packet, len=%d\n", + write ? "TX" : "RX", buflen_u); mypkt = brcmu_pkt_buf_get_skb(buflen_u); if (!mypkt) { - BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed: " - "len %d\n", __func__, buflen_u)); + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", + buflen_u); return -EIO; } @@ -522,12 +510,12 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, * Case 2: We have a packet, but it is unaligned. * In this case, we cannot have a chain (pkt->next == NULL) */ - BRCMF_DATA(("%s: Creating aligned %s Packet, len=%d\n", - __func__, write ? "TX" : "RX", pkt->len)); + brcmf_dbg(DATA, "Creating aligned %s Packet, len=%d\n", + write ? "TX" : "RX", pkt->len); mypkt = brcmu_pkt_buf_get_skb(pkt->len); if (!mypkt) { - BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed: " - "len %d\n", __func__, pkt->len)); + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", + pkt->len); return -EIO; } @@ -545,8 +533,8 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, brcmu_pkt_buf_free_skb(mypkt); } else { /* case 3: We have a packet and it is aligned. */ - BRCMF_DATA(("%s: Aligned %s Packet, direct DMA\n", - __func__, write ? "Tx" : "Rx")); + brcmf_dbg(DATA, "Aligned %s Packet, direct DMA\n", + write ? "Tx" : "Rx"); Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, func, addr, pkt); } @@ -567,14 +555,14 @@ brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, &temp); *data = temp; *data &= 0xff; - BRCMF_DATA(("%s: byte read data=0x%02x\n", __func__, *data)); + brcmf_dbg(DATA, "byte read data=0x%02x\n", *data); } else { brcmf_sdioh_request_word(sdiodev, 0, SDIOH_READ, func, regaddr, data, regsize); if (regsize == 2) *data &= 0xffff; - BRCMF_DATA(("%s: word read data=0x%08x\n", __func__, *data)); + brcmf_dbg(DATA, "word read data=0x%08x\n", *data); } return SUCCESS; @@ -585,16 +573,15 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, { int ret = 0; struct brcmf_sdio_dev *sdiodev; - BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__)); - BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class)); - BRCMF_TRACE(("sdio_vendor: 0x%04x\n", func->vendor)); - BRCMF_TRACE(("sdio_device: 0x%04x\n", func->device)); - BRCMF_TRACE(("Function#: 0x%04x\n", func->num)); + brcmf_dbg(TRACE, "Enter\n"); + brcmf_dbg(TRACE, "func->class=%x\n", func->class); + brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor); + brcmf_dbg(TRACE, "sdio_device: 0x%04x\n", func->device); + brcmf_dbg(TRACE, "Function#: 0x%04x\n", func->num); if (func->num == 1) { if (dev_get_drvdata(&func->card->dev)) { - BRCMF_ERROR(("%s: card private drvdata occupied.\n", - __func__)); + brcmf_dbg(ERROR, "card private drvdata occupied\n"); return -ENXIO; } sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); @@ -614,7 +601,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdiodev->func[2] = func; brcmf_cfg80211_sdio_func(func); - BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n")); + brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_probe...\n"); ret = brcmf_sdio_probe(sdiodev); } @@ -624,15 +611,15 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, static void brcmf_ops_sdio_remove(struct sdio_func *func) { struct brcmf_sdio_dev *sdiodev; - BRCMF_TRACE(("%s Enter\n", __func__)); - BRCMF_INFO(("func->class=%x\n", func->class)); - BRCMF_INFO(("sdio_vendor: 0x%04x\n", func->vendor)); - BRCMF_INFO(("sdio_device: 0x%04x\n", func->device)); - BRCMF_INFO(("Function#: 0x%04x\n", func->num)); + brcmf_dbg(TRACE, "Enter\n"); + brcmf_dbg(INFO, "func->class=%x\n", func->class); + brcmf_dbg(INFO, "sdio_vendor: 0x%04x\n", func->vendor); + brcmf_dbg(INFO, "sdio_device: 0x%04x\n", func->device); + brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num); if (func->num == 2) { sdiodev = dev_get_drvdata(&func->card->dev); - BRCMF_TRACE(("F2 found, calling brcmf_sdio_remove...\n")); + brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); brcmf_sdio_remove(sdiodev); dev_set_drvdata(&func->card->dev, NULL); kfree(sdiodev); @@ -648,7 +635,7 @@ static int brcmf_sdio_suspend(struct device *dev) struct sdio_func *func = dev_to_sdio_func(dev); int ret = 0; - BRCMF_TRACE(("%s\n", __func__)); + brcmf_dbg(TRACE, "\n"); sdiodev = dev_get_drvdata(&func->card->dev); @@ -656,13 +643,13 @@ static int brcmf_sdio_suspend(struct device *dev) sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { - BRCMF_ERROR(("Host can't keep power while suspended\n")); + brcmf_dbg(ERROR, "Host can't keep power while suspended\n"); return -EINVAL; } ret = sdio_set_host_pm_flags(sdiodev->func[1], MMC_PM_KEEP_POWER); if (ret) { - BRCMF_ERROR(("Failed to set pm_flags\n")); + brcmf_dbg(ERROR, "Failed to set pm_flags\n"); return ret; } @@ -689,7 +676,7 @@ static int brcmf_sdio_resume(struct device *dev) int brcmf_sdio_function_init(void) { int error = 0; - BRCMF_TRACE(("brcmf_sdio_function_init: %s Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); error = sdio_register_driver(&brcmf_sdmmc_driver); @@ -701,7 +688,7 @@ int brcmf_sdio_function_init(void) */ void brcmf_sdio_function_cleanup(void) { - BRCMF_TRACE(("%s Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); sdio_unregister_driver(&brcmf_sdmmc_driver); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 345acabe935..1ac8057c39e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -104,7 +104,7 @@ static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr) int len = le32_to_cpu(prot->msg.len) + sizeof(struct brcmf_proto_cdc_ioctl); - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* NOTE : cdc->msg.len holds the desired length of the buffer to be * returned. Only up to CDC_MAX_MSG_SIZE of this buffer area @@ -123,7 +123,7 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len) int ret; struct brcmf_proto *prot = drvr->prot; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); do { ret = brcmf_sdbrcm_bus_rxctl(drvr->bus, @@ -146,8 +146,8 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, int ret = 0, retries = 0; u32 id, flags = 0; - BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_CTL(("%s: cmd %d len %d\n", __func__, cmd, len)); + brcmf_dbg(TRACE, "Enter\n"); + brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); /* Respond "bcmerror" and "bcmerrorstr" with local cache */ if (cmd == BRCMF_C_GET_VAR && buf) { @@ -174,8 +174,8 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, ret = brcmf_proto_cdc_msg(drvr); if (ret < 0) { - BRCMF_ERROR(("brcmf_proto_cdc_query_ioctl: brcmf_proto_cdc_msg " - "failed w/status %d\n", ret)); + brcmf_dbg(ERROR, "brcmf_proto_cdc_msg failed w/status %d\n", + ret); goto done; } @@ -191,9 +191,8 @@ retry: if ((id < prot->reqid) && (++retries < RETRIES)) goto retry; if (id != prot->reqid) { - BRCMF_ERROR(("%s: %s: unexpected request id %d (expected %d)\n", - brcmf_ifname(drvr, ifidx), __func__, id, - prot->reqid)); + brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n", + brcmf_ifname(drvr, ifidx), id, prot->reqid); ret = -EINVAL; goto done; } @@ -227,8 +226,8 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, int ret = 0; u32 flags, id; - BRCMF_TRACE(("%s: Enter\n", __func__)); - BRCMF_CTL(("%s: cmd %d len %d\n", __func__, cmd, len)); + brcmf_dbg(TRACE, "Enter\n"); + brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); memset(msg, 0, sizeof(struct brcmf_proto_cdc_ioctl)); @@ -253,9 +252,8 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; if (id != prot->reqid) { - BRCMF_ERROR(("%s: %s: unexpected request id %d (expected %d)\n", - brcmf_ifname(drvr, ifidx), __func__, id, - prot->reqid)); + brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n", + brcmf_ifname(drvr, ifidx), id, prot->reqid); ret = -EINVAL; goto done; } @@ -279,25 +277,23 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, int ret = -1; if (drvr->busstate == BRCMF_BUS_DOWN) { - BRCMF_ERROR(("%s : bus is down. we have nothing to do\n", - __func__)); + brcmf_dbg(ERROR, "bus is down. we have nothing to do.\n"); return ret; } brcmf_os_proto_block(drvr); - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (len > BRCMF_C_IOCTL_MAXLEN) goto done; if (prot->pending == true) { - BRCMF_TRACE(("CDC packet is pending!!!! cmd=0x%x (%lu) " - "lastcmd=0x%x (%lu)\n", - ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd, - (unsigned long)prot->lastcmd)); + brcmf_dbg(TRACE, "CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n", + ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd, + (unsigned long)prot->lastcmd); if ((ioc->cmd == BRCMF_C_SET_VAR) || (ioc->cmd == BRCMF_C_GET_VAR)) - BRCMF_TRACE(("iovar cmd=%s\n", (char *)buf)); + brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)buf); goto done; } @@ -358,7 +354,7 @@ void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx, { struct brcmf_proto_bdc_header *h; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Push BDC header used to convey priority for buses that don't */ @@ -381,13 +377,13 @@ int brcmf_proto_hdrpull(struct brcmf_pub *drvr, int *ifidx, { struct brcmf_proto_bdc_header *h; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Pop BDC header used to convey priority for buses that don't */ if (pktbuf->len < BDC_HEADER_LEN) { - BRCMF_ERROR(("%s: rx data too short (%d < %d)\n", __func__, - pktbuf->len, BDC_HEADER_LEN)); + brcmf_dbg(ERROR, "rx data too short (%d < %d)\n", + pktbuf->len, BDC_HEADER_LEN); return -EBADE; } @@ -395,22 +391,20 @@ int brcmf_proto_hdrpull(struct brcmf_pub *drvr, int *ifidx, *ifidx = BDC_GET_IF_IDX(h); if (*ifidx >= BRCMF_MAX_IFS) { - BRCMF_ERROR(("%s: rx data ifnum out of range (%d)\n", - __func__, *ifidx)); + brcmf_dbg(ERROR, "rx data ifnum out of range (%d)\n", *ifidx); return -EBADE; } if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) != BDC_PROTO_VER) { - BRCMF_ERROR(("%s: non-BDC packet received, flags 0x%x\n", - brcmf_ifname(drvr, *ifidx), h->flags)); + brcmf_dbg(ERROR, "%s: non-BDC packet received, flags 0x%x\n", + brcmf_ifname(drvr, *ifidx), h->flags); return -EBADE; } if (h->flags & BDC_FLAG_SUM_GOOD) { - BRCMF_INFO(("%s: BDC packet received with good rx-csum, " - "flags 0x%x\n", - brcmf_ifname(drvr, *ifidx), h->flags)); + brcmf_dbg(INFO, "%s: BDC packet received with good rx-csum, flags 0x%x\n", + brcmf_ifname(drvr, *ifidx), h->flags); PKTSETSUMGOOD(pktbuf, true); } @@ -427,13 +421,13 @@ int brcmf_proto_attach(struct brcmf_pub *drvr) cdc = kzalloc(sizeof(struct brcmf_proto), GFP_ATOMIC); if (!cdc) { - BRCMF_ERROR(("%s: kmalloc failed\n", __func__)); + brcmf_dbg(ERROR, "kmalloc failed\n"); goto fail; } /* ensure that the msg buf directly follows the cdc msg struct */ if ((unsigned long)(&cdc->msg + 1) != (unsigned long)cdc->buf) { - BRCMF_ERROR(("struct brcmf_proto is not correctly defined\n")); + brcmf_dbg(ERROR, "struct brcmf_proto is not correctly defined\n"); goto fail; } @@ -472,7 +466,7 @@ int brcmf_proto_init(struct brcmf_pub *drvr) int ret = 0; char buf[128]; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); brcmf_os_proto_block(drvr); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index bd655a31087..059289a5d82 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -172,7 +172,7 @@ brcmf_c_doiovar(struct brcmf_pub *drvr, const struct brcmu_iovar *vi, int bcmerror = 0; s32 int_val = 0; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); bcmerror = brcmu_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid)); if (bcmerror != 0) @@ -267,8 +267,8 @@ bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) : brcmu_pktq_pdeq_tail(q, eprec); if (p == NULL) - BRCMF_ERROR(("%s: brcmu_pktq_penq() failed, oldest %d.", - __func__, discard_oldest)); + brcmf_dbg(ERROR, "brcmu_pktq_penq() failed, oldest %d\n", + discard_oldest); brcmu_pkt_buf_free_skb(p); } @@ -276,7 +276,7 @@ bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, /* Enqueue */ p = brcmu_pktq_penq(q, prec, pkt); if (p == NULL) - BRCMF_ERROR(("%s: brcmu_pktq_penq() failed.", __func__)); + brcmf_dbg(ERROR, "brcmu_pktq_penq() failed\n"); return p != NULL; } @@ -290,7 +290,7 @@ brcmf_c_iovar_op(struct brcmf_pub *drvr, const char *name, const struct brcmu_iovar *vi = NULL; u32 actionid; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (name == NULL || len < 0) return -EINVAL; @@ -309,8 +309,8 @@ brcmf_c_iovar_op(struct brcmf_pub *drvr, const char *name, goto exit; } - BRCMF_CTL(("%s: %s %s, len %d plen %d\n", __func__, - name, (set ? "set" : "get"), len, plen)); + brcmf_dbg(CTL, "%s %s, len %d plen %d\n", + name, set ? "set" : "get", len, plen); /* set up 'params' pointer in case this is a set command so that * the convenience int and bool code can be common to set and get @@ -342,7 +342,7 @@ int brcmf_c_ioctl(struct brcmf_pub *drvr, struct brcmf_c_ioctl *ioc, void *buf, { int bcmerror = 0; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (!buf) return -EINVAL; @@ -498,9 +498,9 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) event_name = event_names[i].event_name; } - BRCMF_EVENT(("EVENT: %s, event ID = %d\n", event_name, event_type)); - BRCMF_EVENT(("flags 0x%04x, status %d, reason %d, auth_type %d" - " MAC %s\n", flags, status, reason, auth_type, eabuf)); + brcmf_dbg(EVENT, "EVENT: %s, event ID = %d\n", event_name, event_type); + brcmf_dbg(EVENT, "flags 0x%04x, status %d, reason %d, auth_type %d MAC %s\n", + flags, status, reason, auth_type, eabuf); if (flags & BRCMF_EVENT_MSG_LINK) link = true; @@ -513,35 +513,34 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) case BRCMF_E_START: case BRCMF_E_DEAUTH: case BRCMF_E_DISASSOC: - BRCMF_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); break; case BRCMF_E_ASSOC_IND: case BRCMF_E_REASSOC_IND: - BRCMF_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); break; case BRCMF_E_ASSOC: case BRCMF_E_REASSOC: if (status == BRCMF_E_STATUS_SUCCESS) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, SUCCESS\n", - event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, SUCCESS\n", + event_name, eabuf); else if (status == BRCMF_E_STATUS_TIMEOUT) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, TIMEOUT\n", - event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, TIMEOUT\n", + event_name, eabuf); else if (status == BRCMF_E_STATUS_FAIL) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, FAILURE," - " reason %d\n", event_name, eabuf, - (int)reason)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, FAILURE, reason %d\n", + event_name, eabuf, (int)reason); else - BRCMF_EVENT(("MACEVENT: %s, MAC %s, unexpected status " - "%d\n", event_name, eabuf, (int)status)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, unexpected status %d\n", + event_name, eabuf, (int)status); break; case BRCMF_E_DEAUTH_IND: case BRCMF_E_DISASSOC_IND: - BRCMF_EVENT(("MACEVENT: %s, MAC %s, reason %d\n", event_name, - eabuf, (int)reason)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, reason %d\n", + event_name, eabuf, (int)reason); break; case BRCMF_E_AUTH: @@ -555,18 +554,17 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) auth_str = err_msg; } if (event_type == BRCMF_E_AUTH_IND) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s\n", event_name, - eabuf, auth_str)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s\n", + event_name, eabuf, auth_str); else if (status == BRCMF_E_STATUS_SUCCESS) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, SUCCESS\n", - event_name, eabuf, auth_str)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, SUCCESS\n", + event_name, eabuf, auth_str); else if (status == BRCMF_E_STATUS_TIMEOUT) - BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, TIMEOUT\n", - event_name, eabuf, auth_str)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, TIMEOUT\n", + event_name, eabuf, auth_str); else if (status == BRCMF_E_STATUS_FAIL) { - BRCMF_EVENT(("MACEVENT: %s, MAC %s, %s, FAILURE, " - "reason %d\n", - event_name, eabuf, auth_str, (int)reason)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, FAILURE, reason %d\n", + event_name, eabuf, auth_str, (int)reason); } break; @@ -575,63 +573,63 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) case BRCMF_E_ROAM: case BRCMF_E_SET_SSID: if (status == BRCMF_E_STATUS_SUCCESS) - BRCMF_EVENT(("MACEVENT: %s, MAC %s\n", event_name, - eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", + event_name, eabuf); else if (status == BRCMF_E_STATUS_FAIL) - BRCMF_EVENT(("MACEVENT: %s, failed\n", event_name)); + brcmf_dbg(EVENT, "MACEVENT: %s, failed\n", event_name); else if (status == BRCMF_E_STATUS_NO_NETWORKS) - BRCMF_EVENT(("MACEVENT: %s, no networks found\n", - event_name)); + brcmf_dbg(EVENT, "MACEVENT: %s, no networks found\n", + event_name); else - BRCMF_EVENT(("MACEVENT: %s, unexpected status %d\n", - event_name, (int)status)); + brcmf_dbg(EVENT, "MACEVENT: %s, unexpected status %d\n", + event_name, (int)status); break; case BRCMF_E_BEACON_RX: if (status == BRCMF_E_STATUS_SUCCESS) - BRCMF_EVENT(("MACEVENT: %s, SUCCESS\n", event_name)); + brcmf_dbg(EVENT, "MACEVENT: %s, SUCCESS\n", event_name); else if (status == BRCMF_E_STATUS_FAIL) - BRCMF_EVENT(("MACEVENT: %s, FAIL\n", event_name)); + brcmf_dbg(EVENT, "MACEVENT: %s, FAIL\n", event_name); else - BRCMF_EVENT(("MACEVENT: %s, status %d\n", event_name, - status)); + brcmf_dbg(EVENT, "MACEVENT: %s, status %d\n", + event_name, status); break; case BRCMF_E_LINK: - BRCMF_EVENT(("MACEVENT: %s %s\n", event_name, - link ? "UP" : "DOWN")); + brcmf_dbg(EVENT, "MACEVENT: %s %s\n", + event_name, link ? "UP" : "DOWN"); break; case BRCMF_E_MIC_ERROR: - BRCMF_EVENT(("MACEVENT: %s, MAC %s, Group %d, Flush %d\n", - event_name, eabuf, group, flush_txq)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, Group %d, Flush %d\n", + event_name, eabuf, group, flush_txq); break; case BRCMF_E_ICV_ERROR: case BRCMF_E_UNICAST_DECODE_ERROR: case BRCMF_E_MULTICAST_DECODE_ERROR: - BRCMF_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); break; case BRCMF_E_TXFAIL: - BRCMF_EVENT(("MACEVENT: %s, RA %s\n", event_name, eabuf)); + brcmf_dbg(EVENT, "MACEVENT: %s, RA %s\n", event_name, eabuf); break; case BRCMF_E_SCAN_COMPLETE: case BRCMF_E_PMKID_CACHE: - BRCMF_EVENT(("MACEVENT: %s\n", event_name)); + brcmf_dbg(EVENT, "MACEVENT: %s\n", event_name); break; case BRCMF_E_PFN_NET_FOUND: case BRCMF_E_PFN_NET_LOST: case BRCMF_E_PFN_SCAN_COMPLETE: - BRCMF_EVENT(("PNOEVENT: %s\n", event_name)); + brcmf_dbg(EVENT, "PNOEVENT: %s\n", event_name); break; case BRCMF_E_PSK_SUP: case BRCMF_E_PRUNE: - BRCMF_EVENT(("MACEVENT: %s, status %d, reason %d\n", - event_name, (int)status, (int)reason)); + brcmf_dbg(EVENT, "MACEVENT: %s, status %d, reason %d\n", + event_name, (int)status, (int)reason); break; case BRCMF_E_TRACE: @@ -645,11 +643,9 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) memcpy(&hdr, buf, sizeof(struct msgtrace_hdr)); if (hdr.version != MSGTRACE_VERSION) { - BRCMF_ERROR( - ("\nMACEVENT: %s [unsupported version --> " - "brcmf version:%d dongle version:%d]\n", - event_name, MSGTRACE_VERSION, hdr.version) - ); + brcmf_dbg(ERROR, "MACEVENT: %s [unsupported version --> brcmf version:%d dongle version:%d]\n", + event_name, + MSGTRACE_VERSION, hdr.version); /* Reset datalen to avoid display below */ datalen = 0; break; @@ -661,18 +657,14 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) if (be32_to_cpu(hdr.discarded_bytes) || be32_to_cpu(hdr.discarded_printf)) - BRCMF_ERROR(("\nWLC_E_TRACE: [Discarded traces " - "in dongle -->discarded_bytes %d " - "discarded_printf %d]\n", - be32_to_cpu(hdr.discarded_bytes), - be32_to_cpu(hdr.discarded_printf))) - ; + brcmf_dbg(ERROR, "WLC_E_TRACE: [Discarded traces in dongle --> discarded_bytes %d discarded_printf %d]\n", + be32_to_cpu(hdr.discarded_bytes), + be32_to_cpu(hdr.discarded_printf)); nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; if (nblost > 0) - BRCMF_ERROR(("\nWLC_E_TRACE: [Event lost --> " - "seqnum %d nblost %d\n", - be32_to_cpu(hdr.seqnum), nblost)); + brcmf_dbg(ERROR, "WLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n", + be32_to_cpu(hdr.seqnum), nblost); seqnum_prev = be32_to_cpu(hdr.seqnum); /* Display the trace buffer. Advance from \n to \n to @@ -693,24 +685,24 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) break; case BRCMF_E_RSSI: - BRCMF_EVENT(("MACEVENT: %s %d\n", event_name, - be32_to_cpu(*((int *)event_data)))); + brcmf_dbg(EVENT, "MACEVENT: %s %d\n", + event_name, be32_to_cpu(*((int *)event_data))); break; default: - BRCMF_EVENT(("MACEVENT: %s %d, MAC %s, status %d, reason %d, " - "auth %d\n", event_name, event_type, eabuf, - (int)status, (int)reason, (int)auth_type)); + brcmf_dbg(EVENT, "MACEVENT: %s %d, MAC %s, status %d, reason %d, auth %d\n", + event_name, event_type, eabuf, + (int)status, (int)reason, (int)auth_type); break; } /* show any appended data */ if (datalen) { buf = (unsigned char *) event_data; - BRCMF_EVENT((" data (%d) : ", datalen)); + brcmf_dbg(EVENT, " data (%d) : ", datalen); for (i = 0; i < datalen; i++) - BRCMF_EVENT((" 0x%02x ", *buf++)); - BRCMF_EVENT(("\n")); + brcmf_dbg(EVENT, " 0x%02x ", *buf++); + brcmf_dbg(EVENT, "\n"); } } #endif /* SHOW_EVENTS */ @@ -727,14 +719,14 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, int evlen; if (memcmp(BRCM_OUI, &pvt_data->hdr.oui[0], DOT11_OUI_LEN)) { - BRCMF_ERROR(("%s: mismatched OUI, bailing\n", __func__)); + brcmf_dbg(ERROR, "mismatched OUI, bailing\n"); return -EBADE; } /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */ if (get_unaligned_be16(&pvt_data->hdr.usr_subtype) != BCMILCP_BCM_SUBTYPE_EVENT) { - BRCMF_ERROR(("%s: mismatched subtype, bailing\n", __func__)); + brcmf_dbg(ERROR, "mismatched subtype, bailing\n"); return -EBADE; } @@ -755,7 +747,7 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, { struct brcmf_if_event *ifevent = (struct brcmf_if_event *) event_data; - BRCMF_TRACE(("%s: if event\n", __func__)); + brcmf_dbg(TRACE, "if event\n"); if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { @@ -768,9 +760,8 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, else brcmf_del_if(drvr_priv, ifevent->ifidx); } else { - BRCMF_ERROR(("%s: Invalid ifidx %d for %s\n", - __func__, ifevent->ifidx, - event->ifname)); + brcmf_dbg(ERROR, "Invalid ifidx %d for %s\n", + ifevent->ifidx, event->ifname); } } /* send up the if event: btamp user needs it */ @@ -787,16 +778,16 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, /* Fall through: this should get _everything_ */ *ifidx = brcmf_ifname2idx(drvr_priv, event->ifname); - BRCMF_TRACE(("%s: MAC event %d, flags %x, status %x\n", - __func__, type, flags, status)); + brcmf_dbg(TRACE, "MAC event %d, flags %x, status %x\n", + type, flags, status); /* put it back to BRCMF_E_NDIS_LINK */ if (type == BRCMF_E_NDIS_LINK) { u32 temp; temp = get_unaligned_be32(&event->event_type); - BRCMF_TRACE(("Converted to WLC_E_LINK type %d\n", - temp)); + brcmf_dbg(TRACE, "Converted to WLC_E_LINK type %d\n", + temp); temp = be32_to_cpu(BRCMF_E_NDIS_LINK); memcpy((void *)(&pvt_data->msg.event_type), &temp, @@ -817,12 +808,12 @@ static int brcmf_c_pattern_atoh(char *src, char *dst) { int i; if (strncmp(src, "0x", 2) != 0 && strncmp(src, "0X", 2) != 0) { - BRCMF_ERROR(("Mask invalid format. Needs to start with 0x\n")); + brcmf_dbg(ERROR, "Mask invalid format. Needs to start with 0x\n"); return -EINVAL; } src = src + 2; /* Skip past 0x */ if (strlen(src) % 2 != 0) { - BRCMF_ERROR(("Mask invalid format. Length must be even.\n")); + brcmf_dbg(ERROR, "Mask invalid format. Length must be even.\n"); return -EINVAL; } for (i = 0; *src != '\0'; i++) { @@ -856,7 +847,7 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC); if (!arg_save) { - BRCMF_ERROR(("%s: kmalloc failed\n", __func__)); + brcmf_dbg(ERROR, "kmalloc failed\n"); goto fail; } arg_org = arg_save; @@ -866,7 +857,7 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, i = 0; if (NULL == argv[i]) { - BRCMF_ERROR(("No args provided\n")); + brcmf_dbg(ERROR, "No args provided\n"); goto fail; } @@ -893,11 +884,10 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, rc = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) - BRCMF_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", - __func__, arg, rc)); + brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", + arg, rc); else - BRCMF_TRACE(("%s: successfully added pktfilter %s\n", - __func__, arg)); + brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg); /* Contorl the master mode */ brcmu_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf, @@ -906,8 +896,8 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, sizeof(buf)); rc = rc >= 0 ? 0 : rc; if (rc) - BRCMF_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", - __func__, arg, rc)); + brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", + arg, rc); fail: kfree(arg_org); @@ -930,7 +920,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) arg_save = kstrdup(arg, GFP_ATOMIC); if (!arg_save) { - BRCMF_ERROR(("%s: kmalloc failed\n", __func__)); + brcmf_dbg(ERROR, "kmalloc failed\n"); goto fail; } @@ -938,7 +928,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) buf = kmalloc(PKTFILTER_BUF_SIZE, GFP_ATOMIC); if (!buf) { - BRCMF_ERROR(("%s: kmalloc failed\n", __func__)); + brcmf_dbg(ERROR, "kmalloc failed\n"); goto fail; } @@ -948,7 +938,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) i = 0; if (NULL == argv[i]) { - BRCMF_ERROR(("No args provided\n")); + brcmf_dbg(ERROR, "No args provided\n"); goto fail; } @@ -965,7 +955,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) pkt_filter.id = (u32)res; if (NULL == argv[++i]) { - BRCMF_ERROR(("Polarity not provided\n")); + brcmf_dbg(ERROR, "Polarity not provided\n"); goto fail; } @@ -975,7 +965,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) pkt_filter.negate_match = (u32)res; if (NULL == argv[++i]) { - BRCMF_ERROR(("Filter type not provided\n")); + brcmf_dbg(ERROR, "Filter type not provided\n"); goto fail; } @@ -985,7 +975,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) pkt_filter.type = (u32)res; if (NULL == argv[++i]) { - BRCMF_ERROR(("Offset not provided\n")); + brcmf_dbg(ERROR, "Offset not provided\n"); goto fail; } @@ -995,7 +985,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) pkt_filter.u.pattern.offset = (u32)res; if (NULL == argv[++i]) { - BRCMF_ERROR(("Bitmask not provided\n")); + brcmf_dbg(ERROR, "Bitmask not provided\n"); goto fail; } @@ -1005,7 +995,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern); if (NULL == argv[++i]) { - BRCMF_ERROR(("Pattern not provided\n")); + brcmf_dbg(ERROR, "Pattern not provided\n"); goto fail; } @@ -1016,7 +1006,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) mask_and_pattern[mask_size]); if (mask_size != pattern_size) { - BRCMF_ERROR(("Mask and pattern not the same size\n")); + brcmf_dbg(ERROR, "Mask and pattern not the same size\n"); goto fail; } @@ -1037,11 +1027,10 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) rc = rc >= 0 ? 0 : rc; if (rc) - BRCMF_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", - __func__, arg, rc)); + brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", + arg, rc); else - BRCMF_TRACE(("%s: successfully added pktfilter %s\n", - __func__, arg)); + brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg); fail: kfree(arg_org); @@ -1059,11 +1048,11 @@ void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) - BRCMF_TRACE(("%s: failed to set ARP offload mode to 0x%x, " - "retcode = %d\n", __func__, arp_mode, retcode)); + brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, retcode = %d\n", + arp_mode, retcode); else - BRCMF_TRACE(("%s: successfully set ARP offload mode to 0x%x\n", - __func__, arp_mode)); + brcmf_dbg(TRACE, "successfully set ARP offload mode to 0x%x\n", + arp_mode); } void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) @@ -1076,11 +1065,11 @@ void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) - BRCMF_TRACE(("%s: failed to enabe ARP offload to %d, " - "retcode = %d\n", __func__, arp_enable, retcode)); + brcmf_dbg(TRACE, "failed to enable ARP offload to %d, retcode = %d\n", + arp_enable, retcode); else - BRCMF_TRACE(("%s: successfully enabed ARP offload to %d\n", - __func__, arp_enable)); + brcmf_dbg(TRACE, "successfully enabled ARP offload to %d\n", + arp_enable); } int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) @@ -1103,8 +1092,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) if (brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_COUNTRY, drvr->country_code, sizeof(drvr->country_code)) < 0) - BRCMF_ERROR(("%s: country code setting failed\n", - __func__)); + brcmf_dbg(ERROR, "country code setting failed\n"); } /* query for 'ver' to get version info from firmware */ @@ -1114,7 +1102,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); strsep(&ptr, "\n"); /* Print fw version info */ - BRCMF_ERROR(("Firmware version = %s\n", buf)); + brcmf_dbg(ERROR, "Firmware version = %s\n", buf); /* Match Host and Dongle rx alignment */ brcmu_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h index 5be4d7a609c..7467922f053 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h @@ -19,25 +19,21 @@ #if defined(BCMDBG) -#define BRCMF_ERROR(args) \ - do {if ((brcmf_msg_level & BRCMF_ERROR_VAL) && (net_ratelimit())) \ - printk args; } while (0) -#define BRCMF_TRACE(args) do {if (brcmf_msg_level & BRCMF_TRACE_VAL) \ - printk args; } while (0) -#define BRCMF_INFO(args) do {if (brcmf_msg_level & BRCMF_INFO_VAL) \ - printk args; } while (0) -#define BRCMF_DATA(args) do {if (brcmf_msg_level & BRCMF_DATA_VAL) \ - printk args; } while (0) -#define BRCMF_CTL(args) do {if (brcmf_msg_level & BRCMF_CTL_VAL) \ - printk args; } while (0) -#define BRCMF_TIMER(args) do {if (brcmf_msg_level & BRCMF_TIMER_VAL) \ - printk args; } while (0) -#define BRCMF_INTR(args) do {if (brcmf_msg_level & BRCMF_INTR_VAL) \ - printk args; } while (0) -#define BRCMF_GLOM(args) do {if (brcmf_msg_level & BRCMF_GLOM_VAL) \ - printk args; } while (0) -#define BRCMF_EVENT(args) do {if (brcmf_msg_level & BRCMF_EVENT_VAL) \ - printk args; } while (0) +#define brcmf_dbg(level, fmt, ...) \ +do { \ + if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \ + if (brcmf_msg_level & BRCMF_##level##_VAL) { \ + if (net_ratelimit()) \ + printk(KERN_DEBUG "%s: " fmt, \ + __func__, ##__VA_ARGS__); \ + } \ + } else { \ + if (brcmf_msg_level & BRCMF_##level##_VAL) { \ + printk(KERN_DEBUG "%s: " fmt, \ + __func__, ##__VA_ARGS__); \ + } \ + } \ +} while (0) #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL) #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL) @@ -47,20 +43,12 @@ #else /* (defined BCMDBG) || (defined BCMDBG) */ -#define BRCMF_ERROR(args) do {if (net_ratelimit()) printk args; } while (0) -#define BRCMF_TRACE(args) -#define BRCMF_INFO(args) -#define BRCMF_DATA(args) -#define BRCMF_CTL(args) -#define BRCMF_TIMER(args) -#define BRCMF_INTR(args) -#define BRCMF_GLOM(args) -#define BRCMF_EVENT(args) +#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) #define BRCMF_DATA_ON() 0 #define BRCMF_CTL_ON() 0 #define BRCMF_HDRS_ON() 0 -#define BRCMF_BYTES_ON() 0 +#define BRCMF_BYTES_ON() 0 #define BRCMF_GLOM_ON() 0 #endif /* defined(BCMDBG) */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index b8f9922c56e..2c633fa54c4 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -163,7 +163,7 @@ int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) && !strncmp(drvr_priv->iflist[i]->name, name, IFNAMSIZ)) break; - BRCMF_TRACE(("%s: return idx %d for \"%s\"\n", __func__, i, name)); + brcmf_dbg(TRACE, "return idx %d for \"%s\"\n", i, name); return i; /* default - the primary interface */ } @@ -173,12 +173,12 @@ char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx) struct brcmf_info *drvr_priv = drvr->info; if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) { - BRCMF_ERROR(("%s: ifidx %d out of range\n", __func__, ifidx)); + brcmf_dbg(ERROR, "ifidx %d out of range\n", ifidx); return ""; } if (drvr_priv->iflist[ifidx] == NULL) { - BRCMF_ERROR(("%s: null i/f %d\n", __func__, ifidx)); + brcmf_dbg(ERROR, "null i/f %d\n", ifidx); return ""; } @@ -210,8 +210,8 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN); bufp = buf = kmalloc(buflen, GFP_ATOMIC); if (!bufp) { - BRCMF_ERROR(("%s: out of memory for mcast_list, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), cnt)); + brcmf_dbg(ERROR, "%s: out of memory for mcast_list, cnt %d\n", + brcmf_ifname(&drvr_priv->pub, ifidx), cnt); return; } @@ -238,8 +238,8 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { - BRCMF_ERROR(("%s: set mcast_list failed, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), cnt)); + brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n", + brcmf_ifname(&drvr_priv->pub, ifidx), cnt); allmulti = cnt ? true : allmulti; } @@ -253,18 +253,17 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) buflen = sizeof("allmulti") + sizeof(allmulti); buf = kmalloc(buflen, GFP_ATOMIC); if (!buf) { - BRCMF_ERROR(("%s: out of memory for allmulti\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(ERROR, "%s: out of memory for allmulti\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); return; } allmulti = cpu_to_le32(allmulti); if (!brcmu_mkiovar ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) { - BRCMF_ERROR(("%s: mkiovar failed for allmulti, datalen %d " - "buflen %u\n", - brcmf_ifname(&drvr_priv->pub, ifidx), - (int)sizeof(allmulti), buflen)); + brcmf_dbg(ERROR, "%s: mkiovar failed for allmulti, datalen %d buflen %u\n", + brcmf_ifname(&drvr_priv->pub, ifidx), + (int)sizeof(allmulti), buflen); kfree(buf); return; } @@ -277,9 +276,9 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { - BRCMF_ERROR(("%s: set allmulti %d failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx), - le32_to_cpu(allmulti))); + brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", + brcmf_ifname(&drvr_priv->pub, ifidx), + le32_to_cpu(allmulti)); } kfree(buf); @@ -298,9 +297,9 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { - BRCMF_ERROR(("%s: set promisc %d failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx), - le32_to_cpu(allmulti))); + brcmf_dbg(ERROR, "%s: set promisc %d failed\n", + brcmf_ifname(&drvr_priv->pub, ifidx), + le32_to_cpu(allmulti)); } } @@ -311,11 +310,10 @@ _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) struct brcmf_ioctl ioc; int ret; - BRCMF_TRACE(("%s enter\n", __func__)); - if (!brcmu_mkiovar - ("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) { - BRCMF_ERROR(("%s: mkiovar failed for cur_etheraddr\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(TRACE, "enter\n"); + if (!brcmu_mkiovar("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) { + brcmf_dbg(ERROR, "%s: mkiovar failed for cur_etheraddr\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); return -1; } memset(&ioc, 0, sizeof(ioc)); @@ -326,8 +324,8 @@ _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) - BRCMF_ERROR(("%s: set cur_etheraddr failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); else memcpy(drvr_priv->iflist[ifidx]->net->dev_addr, addr, ETH_ALEN); @@ -346,7 +344,7 @@ static void brcmf_op_if(struct brcmf_if *ifp) drvr_priv = ifp->info; - BRCMF_TRACE(("%s: idx %d, state %d\n", __func__, ifp->idx, ifp->state)); + brcmf_dbg(TRACE, "idx %d, state %d\n", ifp->idx, ifp->state); switch (ifp->state) { case BRCMF_E_IF_ADD: @@ -355,9 +353,8 @@ static void brcmf_op_if(struct brcmf_if *ifp) * in case we missed the BRCMF_E_IF_DEL event. */ if (ifp->net != NULL) { - BRCMF_ERROR(("%s: ERROR: netdev:%s already exists, " - "try free & unregister\n", - __func__, ifp->net->name)); + brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", + ifp->net->name); netif_stop_queue(ifp->net); unregister_netdev(ifp->net); free_netdev(ifp->net); @@ -365,7 +362,7 @@ static void brcmf_op_if(struct brcmf_if *ifp) /* Allocate etherdev, including space for private structure */ ifp->net = alloc_etherdev(sizeof(drvr_priv)); if (!ifp->net) { - BRCMF_ERROR(("%s: OOM - alloc_etherdev\n", __func__)); + brcmf_dbg(ERROR, "OOM - alloc_etherdev\n"); ret = -ENOMEM; } if (ret == 0) { @@ -374,9 +371,8 @@ static void brcmf_op_if(struct brcmf_if *ifp) sizeof(drvr_priv)); err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); if (err != 0) { - BRCMF_ERROR(("%s: brcmf_net_attach failed, " - "err %d\n", - __func__, err)); + brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", + err); ret = -EOPNOTSUPP; } else { #ifdef SOFTAP @@ -391,17 +387,15 @@ static void brcmf_op_if(struct brcmf_if *ifp) wl0.1 is ready */ up(&ap_eth_sema); #endif - BRCMF_TRACE(("\n ==== pid:%x, net_device for " - "if:%s created ===\n\n", - current->pid, ifp->net->name)); + brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", + current->pid, ifp->net->name); ifp->state = 0; } } break; case BRCMF_E_IF_DEL: if (ifp->net != NULL) { - BRCMF_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n", - __func__)); + brcmf_dbg(TRACE, "got 'WLC_E_IF_DEL' state\n"); netif_stop_queue(ifp->net); unregister_netdev(ifp->net); ret = BRCMF_DEL_IF; /* Make sure the free_netdev() @@ -409,7 +403,7 @@ static void brcmf_op_if(struct brcmf_if *ifp) } break; default: - BRCMF_ERROR(("%s: bad op %d\n", __func__, ifp->state)); + brcmf_dbg(ERROR, "bad op %d\n", ifp->state); break; } @@ -458,26 +452,21 @@ static int _brcmf_sysioc_thread(void *data) brcmf_op_if(ifentry); #ifdef SOFTAP if (drvr_priv->iflist[i] == NULL) { - BRCMF_TRACE(("\n\n %s: interface %d " - "removed!\n", __func__, - i)); + brcmf_dbg(TRACE, "interface %d removed!\n", + i); continue; } if (in_ap && drvr_priv->set_macaddress) { - BRCMF_TRACE(("attempt to set MAC for" - " %s in AP Mode," - " blocked.\n", - ifentry->net->name)); + brcmf_dbg(TRACE, "attempt to set MAC for %s in AP Mode, blocked.\n", + ifentry->net->name); drvr_priv->set_macaddress = false; continue; } if (in_ap && drvr_priv->set_multicast) { - BRCMF_TRACE(("attempt to set MULTICAST " - "list for %s in AP Mode, " - "blocked.\n", - ifentry->net->name)); + brcmf_dbg(TRACE, "attempt to set MULTICAST list for %s in AP Mode, blocked.\n", + ifentry->net->name); drvr_priv->set_multicast = false; continue; } @@ -561,20 +550,19 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net) struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); int ifidx; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Reject if down */ if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == BRCMF_BUS_DOWN)) { - BRCMF_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n", - __func__, drvr_priv->pub.up, - drvr_priv->pub.busstate)); + brcmf_dbg(ERROR, "xmit rejected pub.up=%d busstate=%d\n", + drvr_priv->pub.up, drvr_priv->pub.busstate); netif_stop_queue(net); return -ENODEV; } ifidx = brcmf_net2idx(drvr_priv, net); if (ifidx == BRCMF_BAD_IF) { - BRCMF_ERROR(("%s: bad ifidx %d\n", __func__, ifidx)); + brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); netif_stop_queue(net); return -ENODEV; } @@ -583,15 +571,15 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net) if (skb_headroom(skb) < drvr_priv->pub.hdrlen) { struct sk_buff *skb2; - BRCMF_INFO(("%s: insufficient headroom\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(INFO, "%s: insufficient headroom\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); drvr_priv->pub.tx_realloc++; skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); dev_kfree_skb(skb); skb = skb2; if (skb == NULL) { - BRCMF_ERROR(("%s: skb_realloc_headroom failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); ret = -ENOMEM; goto done; } @@ -614,7 +602,7 @@ void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool state) struct net_device *net; struct brcmf_info *drvr_priv = drvr->info; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); drvr->txoff = state; net = drvr_priv->iflist[ifidx]->net; @@ -636,7 +624,7 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, struct brcmf_if *ifp; struct brcmf_event_msg event; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); save_pktbuf = skb; @@ -728,7 +716,7 @@ static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *net) struct brcmf_if *ifp; int ifidx; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); ifidx = brcmf_net2idx(drvr_priv, net); if (ifidx == BRCMF_BAD_IF) @@ -774,13 +762,13 @@ static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol) if (ret < 0) { /* Check for older dongle image that doesn't support toe_ol */ if (ret == -EIO) { - BRCMF_ERROR(("%s: toe not supported by device\n", - brcmf_ifname(&drvr_priv->pub, ifidx))); + brcmf_dbg(ERROR, "%s: toe not supported by device\n", + brcmf_ifname(&drvr_priv->pub, ifidx)); return -EOPNOTSUPP; } - BRCMF_INFO(("%s: could not get toe_ol: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret)); + brcmf_dbg(INFO, "%s: could not get toe_ol: ret=%d\n", + brcmf_ifname(&drvr_priv->pub, ifidx), ret); return ret; } @@ -810,8 +798,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { - BRCMF_ERROR(("%s: could not set toe_ol: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret)); + brcmf_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n", + brcmf_ifname(&drvr_priv->pub, ifidx), ret); return ret; } @@ -824,8 +812,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { - BRCMF_ERROR(("%s: could not set toe: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret)); + brcmf_dbg(ERROR, "%s: could not set toe: ret=%d\n", + brcmf_ifname(&drvr_priv->pub, ifidx), ret); return ret; } @@ -857,7 +845,7 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr) u32 toe_cmpnt, csum_dir; int ret; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* all ethtool calls start with a cmd word */ if (copy_from_user(&cmd, uaddr, sizeof(u32))) @@ -883,7 +871,7 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr) /* otherwise, require dongle to be up */ else if (!drvr_priv->pub.up) { - BRCMF_ERROR(("%s: dongle is not up\n", __func__)); + brcmf_dbg(ERROR, "dongle is not up\n"); return -ENODEV; } @@ -896,8 +884,8 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr) sprintf(info.version, "%lu", drvr_priv->pub.drv_version); if (copy_to_user(uaddr, &info, sizeof(info))) return -EFAULT; - BRCMF_CTL(("%s: given %*s, returning %s\n", __func__, - (int)sizeof(drvname), drvname, info.driver)); + brcmf_dbg(CTL, "given %*s, returning %s\n", + (int)sizeof(drvname), drvname, info.driver); break; /* Get toe offload components from dongle */ @@ -972,7 +960,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, bool is_set_key_cmd; ifidx = brcmf_net2idx(drvr_priv, net); - BRCMF_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __func__, ifidx, cmd)); + brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); if (ifidx == BRCMF_BAD_IF) return -1; @@ -1036,7 +1024,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, /* send to dongle (must be up, and wl) */ if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { - BRCMF_ERROR(("%s DONGLE_DOWN,__func__\n", __func__)); + brcmf_dbg(ERROR, "DONGLE_DOWN\n"); bcmerror = -EIO; goto done; } @@ -1080,7 +1068,7 @@ static int brcmf_netdev_stop(struct net_device *net) #if !defined(IGNORE_ETH0_DOWN) struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); brcmf_cfg80211_down(); if (drvr_priv->pub.up == 0) return 0; @@ -1089,8 +1077,7 @@ static int brcmf_netdev_stop(struct net_device *net) drvr_priv->pub.up = 0; netif_stop_queue(net); #else - BRCMF_ERROR(("BYPASS %s:due to BRCM compilation: under investigation\n", - __func__)); + brcmf_dbg(ERROR, "BYPASSed due to BRCM compilation: under investigation\n"); #endif /* !defined(IGNORE_ETH0_DOWN) */ return 0; @@ -1103,15 +1090,14 @@ static int brcmf_netdev_open(struct net_device *net) int ifidx = brcmf_net2idx(drvr_priv, net); s32 ret = 0; - BRCMF_TRACE(("%s: ifidx %d\n", __func__, ifidx)); + brcmf_dbg(TRACE, "ifidx %d\n", ifidx); if (ifidx == 0) { /* do it only for primary eth0 */ /* try to bring up bus */ ret = brcmf_bus_start(&drvr_priv->pub); if (ret != 0) { - BRCMF_ERROR(("%s: failed with code %d\n", - __func__, ret)); + brcmf_dbg(ERROR, "failed with code %d\n", ret); return -1; } atomic_set(&drvr_priv->pend_8021x_cnt, 0); @@ -1131,8 +1117,7 @@ static int brcmf_netdev_open(struct net_device *net) netif_start_queue(net); drvr_priv->pub.up = 1; if (unlikely(brcmf_cfg80211_up())) { - BRCMF_ERROR(("%s: failed to bring up cfg80211\n", - __func__)); + brcmf_dbg(ERROR, "failed to bring up cfg80211\n"); return -1; } @@ -1145,13 +1130,13 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, { struct brcmf_if *ifp; - BRCMF_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, net)); + brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, net); ifp = drvr_priv->iflist[ifidx]; if (!ifp) { ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); if (!ifp) { - BRCMF_ERROR(("%s: OOM - struct brcmf_if\n", __func__)); + brcmf_dbg(ERROR, "OOM - struct brcmf_if\n"); return -ENOMEM; } } @@ -1177,11 +1162,11 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) { struct brcmf_if *ifp; - BRCMF_TRACE(("%s: idx %d\n", __func__, ifidx)); + brcmf_dbg(TRACE, "idx %d\n", ifidx); ifp = drvr_priv->iflist[ifidx]; if (!ifp) { - BRCMF_ERROR(("%s: Null interface\n", __func__)); + brcmf_dbg(ERROR, "Null interface\n"); return; } @@ -1195,19 +1180,19 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) struct brcmf_info *drvr_priv = NULL; struct net_device *net; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Allocate etherdev, including space for private structure */ net = alloc_etherdev(sizeof(drvr_priv)); if (!net) { - BRCMF_ERROR(("%s: OOM - alloc_etherdev\n", __func__)); + brcmf_dbg(ERROR, "OOM - alloc_etherdev\n"); goto fail; } /* Allocate primary brcmf_info */ drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); if (!drvr_priv) { - BRCMF_ERROR(("%s: OOM - alloc brcmf_info\n", __func__)); + brcmf_dbg(ERROR, "OOM - alloc brcmf_info\n"); goto fail; } @@ -1244,13 +1229,13 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) /* Attach and link in the protocol */ if (brcmf_proto_attach(&drvr_priv->pub) != 0) { - BRCMF_ERROR(("brcmf_prot_attach failed\n")); + brcmf_dbg(ERROR, "brcmf_prot_attach failed\n"); goto fail; } /* Attach and link in the cfg80211 */ if (unlikely(brcmf_cfg80211_attach(net, &drvr_priv->pub))) { - BRCMF_ERROR(("wl_cfg80211_attach failed\n")); + brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); goto fail; } @@ -1289,19 +1274,18 @@ int brcmf_bus_start(struct brcmf_pub *drvr) /* Room for "event_msgs" + '\0' + bitvec */ char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; - BRCMF_TRACE(("%s:\n", __func__)); + brcmf_dbg(TRACE, "\n"); /* Bring up the bus */ ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub, true); if (ret != 0) { - BRCMF_ERROR(("%s, brcmf_sdbrcm_bus_init failed %d\n", __func__, - ret)); + brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret); return ret; } /* If bus is not ready, can't come up */ if (drvr_priv->pub.busstate != BRCMF_BUS_DATA) { - BRCMF_ERROR(("%s failed bus is not ready\n", __func__)); + brcmf_dbg(ERROR, "failed bus is not ready\n"); return -ENODEV; } @@ -1361,7 +1345,7 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) u8 temp_addr[ETH_ALEN] = { 0x00, 0x90, 0x4c, 0x11, 0x22, 0x33}; - BRCMF_TRACE(("%s: ifidx %d\n", __func__, ifidx)); + brcmf_dbg(TRACE, "ifidx %d\n", ifidx); net = drvr_priv->iflist[ifidx]->net; net->netdev_ops = &brcmf_netdev_ops_pri; @@ -1376,7 +1360,7 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) } if (ifidx == 1) { - BRCMF_TRACE(("%s ACCESS POINT MAC:\n", __func__)); + brcmf_dbg(TRACE, "ACCESS POINT MAC:\n"); /* ACCESSPOINT INTERFACE CASE */ temp_addr[0] |= 0X02; /* set bit 2 , - Locally Administered address */ @@ -1391,12 +1375,11 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) memcpy(net->dev_addr, temp_addr, ETH_ALEN); if (register_netdev(net) != 0) { - BRCMF_ERROR(("%s: couldn't register the net device\n", - __func__)); + brcmf_dbg(ERROR, "couldn't register the net device\n"); goto fail; } - BRCMF_INFO(("%s: Broadcom Dongle Host Driver\n", net->name)); + brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", net->name); return 0; @@ -1409,7 +1392,7 @@ static void brcmf_bus_detach(struct brcmf_pub *drvr) { struct brcmf_info *drvr_priv; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (drvr) { drvr_priv = drvr->info; @@ -1427,7 +1410,7 @@ void brcmf_detach(struct brcmf_pub *drvr) { struct brcmf_info *drvr_priv; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (drvr) { drvr_priv = drvr->info; @@ -1467,7 +1450,7 @@ void brcmf_detach(struct brcmf_pub *drvr) static void __exit brcmf_module_cleanup(void) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); brcmf_bus_unregister(); } @@ -1476,12 +1459,12 @@ static int __init brcmf_module_init(void) { int error; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); error = brcmf_bus_register(); if (error) { - BRCMF_ERROR(("%s: brcmf_bus_register failed\n", __func__)); + brcmf_dbg(ERROR, "brcmf_bus_register failed\n"); goto failed; } return 0; @@ -1583,7 +1566,7 @@ int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size) /* open file to write */ fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640); if (!fp) { - BRCMF_ERROR(("%s: open file error\n", __func__)); + brcmf_dbg(ERROR, "open file error\n"); ret = -1; goto exit; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 7632a0ebd97..8e59086d639 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -859,7 +859,7 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) if (*retryvar) { bus->regfails += (*retryvar-1); if (*retryvar > retry_limit) { - BRCMF_ERROR(("FAILED READ %Xh\n", reg_offset)); + brcmf_dbg(ERROR, "FAILED READ %Xh\n", reg_offset); *regvar = 0; } } @@ -878,8 +878,8 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) if (*retryvar) { bus->regfails += (*retryvar-1); if (*retryvar > retry_limit) - BRCMF_ERROR(("FAILED REGISTER WRITE" - " %Xh\n", reg_offset)); + brcmf_dbg(ERROR, "FAILED REGISTER WRITE %Xh\n", + reg_offset); } } @@ -954,8 +954,8 @@ static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size) { s32 min_size = DONGLE_MIN_MEMSIZE; /* Restrict the memsize to user specified limit */ - BRCMF_ERROR(("user: Restrict the dongle ram size to %d, min %d\n", - brcmf_dongle_memsize, min_size)); + brcmf_dbg(ERROR, "user: Restrict the dongle ram size to %d, min %d\n", + brcmf_dongle_memsize, min_size); if ((brcmf_dongle_memsize > min_size) && (brcmf_dongle_memsize < (s32) bus->orig_ramsize)) bus->ramsize = brcmf_dongle_memsize; @@ -986,7 +986,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) u8 clkctl, clkreq, devctl; unsigned long timeout; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); clkctl = 0; @@ -1002,8 +1002,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); if (err) { - BRCMF_ERROR(("%s: HT Avail request error: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "HT Avail request error: %d\n", err); return -EBADE; } @@ -1019,8 +1018,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err) { - BRCMF_ERROR(("%s: HT Avail read error: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "HT Avail read error: %d\n", err); return -EBADE; } @@ -1031,15 +1029,15 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { - BRCMF_ERROR(("%s: Devctl error setting CA:" - " %d\n", __func__, err)); + brcmf_dbg(ERROR, "Devctl error setting CA: %d\n", + err); return -EBADE; } devctl |= SBSDIO_DEVCTL_CA_INT_ONLY; brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); - BRCMF_INFO(("CLKCTL: set PENDING\n")); + brcmf_dbg(INFO, "CLKCTL: set PENDING\n"); bus->clkstate = CLK_PENDING; return 0; @@ -1067,26 +1065,23 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) usleep_range(5000, 10000); } if (err) { - BRCMF_ERROR(("%s: HT Avail request error: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "HT Avail request error: %d\n", err); return -EBADE; } if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { - BRCMF_ERROR(("%s: HT Avail timeout (%d): " - "clkctl 0x%02x\n", __func__, - PMU_MAX_TRANSITION_DLY, clkctl)); + brcmf_dbg(ERROR, "HT Avail timeout (%d): clkctl 0x%02x\n", + PMU_MAX_TRANSITION_DLY, clkctl); return -EBADE; } /* Mark clock available */ bus->clkstate = CLK_AVAIL; - BRCMF_INFO(("CLKCTL: turned ON\n")); + brcmf_dbg(INFO, "CLKCTL: turned ON\n"); #if defined(BCMDBG) if (bus->alp_only != true) { if (SBSDIO_ALPONLY(clkctl)) - BRCMF_ERROR(("%s: HT Clock should be on.\n", - __func__)); + brcmf_dbg(ERROR, "HT Clock should be on\n"); } #endif /* defined (BCMDBG) */ @@ -1107,10 +1102,10 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) bus->clkstate = CLK_SDONLY; brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); - BRCMF_INFO(("CLKCTL: turned OFF\n")); + brcmf_dbg(INFO, "CLKCTL: turned OFF\n"); if (err) { - BRCMF_ERROR(("%s: Failed access turning clock off:" - " %d\n", __func__, err)); + brcmf_dbg(ERROR, "Failed access turning clock off: %d\n", + err); return -EBADE; } } @@ -1120,7 +1115,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) /* Change idle/active SD state */ static int brcmf_sdbrcm_sdclk(struct brcmf_bus *bus, bool on) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (on) bus->clkstate = CLK_SDONLY; @@ -1137,7 +1132,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) uint oldstate = bus->clkstate; #endif /* BCMDBG */ - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Early exit if we're already there */ if (bus->clkstate == target) { @@ -1166,8 +1161,8 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) else if (bus->clkstate == CLK_AVAIL) brcmf_sdbrcm_htclk(bus, false, false); else - BRCMF_ERROR(("brcmf_sdbrcm_clkctl: request for %d -> %d" - "\n", bus->clkstate, target)); + brcmf_dbg(ERROR, "request for %d -> %d\n", + bus->clkstate, target); brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); break; @@ -1181,8 +1176,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) break; } #ifdef BCMDBG - BRCMF_INFO(("brcmf_sdbrcm_clkctl: %d -> %d\n", - oldstate, bus->clkstate)); + brcmf_dbg(INFO, "%d -> %d\n", oldstate, bus->clkstate); #endif /* BCMDBG */ return 0; @@ -1192,9 +1186,9 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) { uint retries = 0; - BRCMF_INFO(("brcmf_sdbrcm_bussleep: request %s (currently %s)\n", - (sleep ? "SLEEP" : "WAKE"), - (bus->sleeping ? "SLEEP" : "WAKE"))); + brcmf_dbg(INFO, "request %s (currently %s)\n", + sleep ? "SLEEP" : "WAKE", + bus->sleeping ? "SLEEP" : "WAKE"); /* Done if we're already in the requested state */ if (sleep == bus->sleeping) @@ -1213,8 +1207,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) w_sdreg32(bus, SMB_USE_OOB, offsetof(struct sdpcmd_regs, tosbmailbox), &retries); if (retries > retry_limit) - BRCMF_ERROR(("CANNOT SIGNAL CHIP, " - "WILL NOT WAKE UP!!\n")); + brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n"); /* Turn off our contribution to the HT clock request */ brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); @@ -1258,7 +1251,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) &retries); if (retries > retry_limit) - BRCMF_ERROR(("CANNOT SIGNAL CHIP TO CLEAR OOB!!\n")); + brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP TO CLEAR OOB!!\n"); /* Make sure we have SD bus access */ brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); @@ -1289,7 +1282,7 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, struct sk_buff *new; int i; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr->dongle_reset) { ret = -EPERM; @@ -1302,14 +1295,13 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, pad = ((unsigned long)frame % BRCMF_SDALIGN); if (pad) { if (skb_headroom(pkt) < pad) { - BRCMF_INFO(("%s: insufficient headroom %d for %d pad\n", - __func__, skb_headroom(pkt), pad)); + brcmf_dbg(INFO, "insufficient headroom %d for %d pad\n", + skb_headroom(pkt), pad); bus->drvr->tx_realloc++; new = brcmu_pkt_buf_get_skb(pkt->len + BRCMF_SDALIGN); if (!new) { - BRCMF_ERROR(("%s: couldn't allocate new " - "%d-byte packet\n", __func__, - pkt->len + BRCMF_SDALIGN)); + brcmf_dbg(ERROR, "couldn't allocate new %d-byte packet\n", + pkt->len + BRCMF_SDALIGN); ret = -ENOMEM; goto done; } @@ -1383,8 +1375,8 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, if (ret < 0) { /* On failure, abort the command and terminate the frame */ - BRCMF_INFO(("%s: sdio error %d, abort command and " - "terminate frame.\n", __func__, ret)); + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); bus->tx_sderrs++; brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); @@ -1432,7 +1424,7 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) int ret = -EBADE; uint datalen, prec; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); datalen = pkt->len; @@ -1448,8 +1440,8 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) || bus->dpc_sched || (!DATAOK(bus)) || (bus->flowcontrol & NBITVAL(prec)) || (bus->clkstate != CLK_AVAIL)) { - BRCMF_TRACE(("%s: deferring pktq len %d\n", __func__, - pktq_len(&bus->txq))); + brcmf_dbg(TRACE, "deferring pktq len %d\n", + pktq_len(&bus->txq)); bus->fcqueued++; /* Priority based enq */ @@ -1459,7 +1451,7 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) skb_pull(pkt, SDPCM_HDRLEN); brcmf_txcomplete(bus->drvr, pkt, false); brcmu_pkt_buf_free_skb(pkt); - BRCMF_ERROR(("%s: out of bus->txq !!!\n", __func__)); + brcmf_dbg(ERROR, "out of bus->txq !!!\n"); ret = -ENOSR; } else { ret = 0; @@ -1487,7 +1479,7 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) /* Make sure back plane ht clk is on, no pending allowed */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); - BRCMF_TRACE(("%s: calling txpkt\n", __func__)); + brcmf_dbg(TRACE, "calling txpkt\n"); ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); if (ret) bus->drvr->tx_errors++; @@ -1518,7 +1510,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) struct brcmf_pub *drvr = bus->drvr; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); tx_prec_map = ~bus->flowcontrol; @@ -1572,7 +1564,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) int ret = -1; int i; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr->dongle_reset) return -EIO; @@ -1631,9 +1623,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); if (!DATAOK(bus)) { - BRCMF_INFO(("%s: No bus credit bus->tx_max %d," - " bus->tx_seq %d\n", __func__, - bus->tx_max, bus->tx_seq)); + brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", + bus->tx_max, bus->tx_seq); bus->ctrl_frame_stat = true; /* Send from dpc */ bus->ctrl_frame_buf = frame; @@ -1642,11 +1633,10 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_sdbrcm_wait_for_event(bus, &bus->ctrl_frame_stat); if (bus->ctrl_frame_stat == false) { - BRCMF_INFO(("%s: ctrl_frame_stat == false\n", - __func__)); + brcmf_dbg(INFO, "ctrl_frame_stat == false\n"); ret = 0; } else { - BRCMF_INFO(("%s: ctrl_frame_stat == true\n", __func__)); + brcmf_dbg(INFO, "ctrl_frame_stat == true\n"); ret = -1; } } @@ -1674,9 +1664,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) if (ret < 0) { /* On failure, abort the command and terminate the frame */ - BRCMF_INFO(("%s: sdio error %d, abort command " - "and terminate frame.\n", - __func__, ret)); + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); bus->tx_sderrs++; brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); @@ -1732,7 +1721,7 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) uint rxlen = 0; bool pending; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr->dongle_reset) return -EIO; @@ -1747,20 +1736,20 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_sdbrcm_sdunlock(bus); if (rxlen) { - BRCMF_CTL(("%s: resumed on rxctl frame, got %d expected %d\n", - __func__, rxlen, msglen)); + brcmf_dbg(CTL, "resumed on rxctl frame, got %d expected %d\n", + rxlen, msglen); } else if (timeleft == 0) { - BRCMF_ERROR(("%s: resumed on timeout\n", __func__)); + brcmf_dbg(ERROR, "resumed on timeout\n"); #ifdef BCMDBG brcmf_sdbrcm_sdlock(bus); brcmf_sdbrcm_checkdied(bus, NULL, 0); brcmf_sdbrcm_sdunlock(bus); #endif /* BCMDBG */ } else if (pending == true) { - BRCMF_CTL(("%s: cancelled\n", __func__)); + brcmf_dbg(CTL, "cancelled\n"); return -ERESTARTSYS; } else { - BRCMF_CTL(("%s: resumed for unknown reason?\n", __func__)); + brcmf_dbg(CTL, "resumed for unknown reason?\n"); #ifdef BCMDBG brcmf_sdbrcm_sdlock(bus); brcmf_sdbrcm_checkdied(bus, NULL, 0); @@ -1984,20 +1973,19 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, /* Set the backplane window to include the start address */ bcmerror = brcmf_sdbrcm_set_siaddr_window(bus, address); if (bcmerror) { - BRCMF_ERROR(("%s: window change failed\n", __func__)); + brcmf_dbg(ERROR, "window change failed\n"); goto xfer_done; } /* Do the transfer(s) */ while (size) { - BRCMF_INFO(("%s: %s %d bytes at offset 0x%08x in window" - " 0x%08x\n", __func__, (write ? "write" : "read"), - dsize, sdaddr, (address & SBSDIO_SBWINDOW_MASK))); + brcmf_dbg(INFO, "%s %d bytes at offset 0x%08x in window 0x%08x\n", + write ? "write" : "read", dsize, + sdaddr, address & SBSDIO_SBWINDOW_MASK); bcmerror = brcmf_sdcard_rwdata(bus->sdiodev, write, sdaddr, data, dsize); if (bcmerror) { - BRCMF_ERROR(("%s: membytes transfer failed\n", - __func__)); + brcmf_dbg(ERROR, "membytes transfer failed\n"); break; } @@ -2008,8 +1996,7 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, address += dsize; bcmerror = brcmf_sdbrcm_set_siaddr_window(bus, address); if (bcmerror) { - BRCMF_ERROR(("%s: window change failed\n", - __func__)); + brcmf_dbg(ERROR, "window change failed\n"); break; } sdaddr = 0; @@ -2022,8 +2009,8 @@ xfer_done: if (brcmf_sdbrcm_set_siaddr_window(bus, brcmf_sdcard_cur_sbwad( bus->sdiodev))) - BRCMF_ERROR(("%s: FAILED to set window back to 0x%x\n", - __func__, brcmf_sdcard_cur_sbwad(bus->sdiodev))); + brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", + brcmf_sdcard_cur_sbwad(bus->sdiodev)); return bcmerror; } @@ -2044,15 +2031,15 @@ brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) addr = le32_to_cpu(addr); - BRCMF_INFO(("sdpcm_shared address 0x%08X\n", addr)); + brcmf_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr); /* * Check if addr is valid. * NVRAM length at the end of memory should have been overwritten. */ if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) { - BRCMF_ERROR(("%s: address (0x%08x) of sdpcm_shared invalid\n", - __func__, addr)); + brcmf_dbg(ERROR, "address (0x%08x) of sdpcm_shared invalid\n", + addr); return -EBADE; } @@ -2072,10 +2059,9 @@ brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr); if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { - BRCMF_ERROR(("%s: sdpcm_shared version %d in brcmf " - "is different than sdpcm_shared version %d in dongle\n", - __func__, SDPCM_SHARED_VERSION, - sh->flags & SDPCM_SHARED_VERSION_MASK)); + brcmf_dbg(ERROR, "sdpcm_shared version %d in brcmf is different than sdpcm_shared version %d in dongle\n", + SDPCM_SHARED_VERSION, + sh->flags & SDPCM_SHARED_VERSION_MASK); return -EBADE; } @@ -2093,7 +2079,7 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) struct sdpcm_shared sdpcm_shared; struct brcmu_strbuf strbuf; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (data == NULL) { /* @@ -2103,8 +2089,7 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) size = msize; mbuffer = data = kmalloc(msize, GFP_ATOMIC); if (mbuffer == NULL) { - BRCMF_ERROR(("%s: kmalloc(%d) failed\n", __func__, - msize)); + brcmf_dbg(ERROR, "kmalloc(%d) failed\n", msize); bcmerror = -ENOMEM; goto done; } @@ -2112,7 +2097,7 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) str = kmalloc(maxstrlen, GFP_ATOMIC); if (str == NULL) { - BRCMF_ERROR(("%s: kmalloc(%d) failed\n", __func__, maxstrlen)); + brcmf_dbg(ERROR, "kmalloc(%d) failed\n", maxstrlen); bcmerror = -ENOMEM; goto done; } @@ -2194,7 +2179,7 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) } if (sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) - BRCMF_ERROR(("%s: %s\n", __func__, strbuf.origbuf)); + brcmf_dbg(ERROR, "%s\n", strbuf.origbuf); #ifdef BCMDBG if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) @@ -2222,7 +2207,7 @@ static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) size = bus->ramsize; buf = kmalloc(size, GFP_ATOMIC); if (!buf) { - BRCMF_ERROR(("%s: Out of memory (%d bytes)\n", __func__, size)); + brcmf_dbg(ERROR, "Out of memory (%d bytes)\n", size); return -1; } @@ -2234,7 +2219,7 @@ static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) ret = brcmf_sdbrcm_membytes(bus, false, start, databuf, read_size); if (ret) { - BRCMF_ERROR(("%s: Error membytes %d\n", __func__, ret)); + brcmf_dbg(ERROR, "Error membytes %d\n", ret); kfree(buf); return -1; } @@ -2249,7 +2234,7 @@ static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) /* free buf before return !!! */ if (brcmf_write_to_file(bus->drvr, buf, bus->ramsize)) { - BRCMF_ERROR(("%s: Error writing to files\n", __func__)); + brcmf_dbg(ERROR, "Error writing to files\n"); return -1; } @@ -2340,7 +2325,7 @@ int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) { int bcmerror = 0; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Basic sanity checks */ if (bus->drvr->up) { @@ -2378,9 +2363,8 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, s32 int_val = 0; bool bool_val = 0; - BRCMF_TRACE(("%s: Enter, action %d name %s params %p plen %d arg %p " - "len %d val_size %d\n", __func__, actionid, name, params, - plen, arg, len, val_size)); + brcmf_dbg(TRACE, "Enter, action %d name %s params %p plen %d arg %p len %d val_size %d\n", + actionid, name, params, plen, arg, len, val_size); bcmerror = brcmu_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid)); if (bcmerror != 0) @@ -2476,25 +2460,22 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, /* Do some validation */ dsize = set ? plen - (2 * sizeof(int)) : len; if (dsize < size) { - BRCMF_ERROR(("%s: error on %s membytes, addr " - "0x%08x size %d dsize %d\n", - __func__, (set ? "set" : "get"), - address, size, dsize)); + brcmf_dbg(ERROR, "error on %s membytes, addr 0x%08x size %d dsize %d\n", + set ? "set" : "get", + address, size, dsize); bcmerror = -EINVAL; break; } - BRCMF_INFO(("%s: Request to %s %d bytes at address " - "0x%08x\n", __func__, - (set ? "write" : "read"), size, address)); + brcmf_dbg(INFO, "Request to %s %d bytes at address 0x%08x\n", + set ? "write" : "read", size, address); /* If we know about SOCRAM, check for a fit */ if ((bus->orig_ramsize) && ((address > bus->orig_ramsize) || (address + size > bus->orig_ramsize))) { - BRCMF_ERROR(("%s: ramsize 0x%08x doesn't have" - " %d bytes at 0x%08x\n", __func__, - bus->orig_ramsize, size, address)); + brcmf_dbg(ERROR, "ramsize 0x%08x doesn't have %d bytes at 0x%08x\n", + bus->orig_ramsize, size, address); bcmerror = -EINVAL; break; } @@ -2721,17 +2702,16 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, #endif /* BCMDBG */ case IOV_SVAL(IOV_DEVRESET): - BRCMF_TRACE(("%s: Called set IOV_DEVRESET=%d dongle_reset=%d " - "busstate=%d\n", - __func__, bool_val, bus->drvr->dongle_reset, - bus->drvr->busstate)); + brcmf_dbg(TRACE, "Called set IOV_DEVRESET=%d dongle_reset=%d busstate=%d\n", + bool_val, bus->drvr->dongle_reset, + bus->drvr->busstate); brcmf_bus_devreset(bus->drvr, (u8) bool_val); break; case IOV_GVAL(IOV_DEVRESET): - BRCMF_TRACE(("%s: Called get IOV_DEVRESET\n", __func__)); + brcmf_dbg(TRACE, "Called get IOV_DEVRESET\n"); /* Get its status */ int_val = (bool) bus->drvr->dongle_reset; @@ -2813,7 +2793,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); #ifdef BCMDBG /* Verify NVRAM bytes */ - BRCMF_INFO(("Compare NVRAM dl & ul; varsize=%d\n", varsize)); + brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); nvram_ularray = kmalloc(varsize, GFP_ATOMIC); if (!nvram_ularray) return -ENOMEM; @@ -2826,17 +2806,14 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) brcmf_sdbrcm_membytes(bus, false, varaddr, nvram_ularray, varsize); if (bcmerror) { - BRCMF_ERROR(("%s: error %d on reading %d nvram bytes" - " at 0x%08x\n", __func__, bcmerror, - varsize, varaddr)); + brcmf_dbg(ERROR, "error %d on reading %d nvram bytes at 0x%08x\n", + bcmerror, varsize, varaddr); } /* Compare the org NVRAM with the one read from RAM */ if (memcmp(vbuffer, nvram_ularray, varsize)) - BRCMF_ERROR(("%s: Downloaded NVRAM image is " - "corrupted.\n", __func__)); + brcmf_dbg(ERROR, "Downloaded NVRAM image is corrupted\n"); else - BRCMF_ERROR(("%s: Download/Upload/Compare of" - " NVRAM ok.\n", __func__)); + brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); kfree(nvram_ularray); #endif /* BCMDBG */ @@ -2845,9 +2822,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) } /* adjust to the user specified RAM */ - BRCMF_INFO(("Physical memory size: %d, usable memory size: %d\n", - bus->orig_ramsize, bus->ramsize)); - BRCMF_INFO(("Vars are at %d, orig varsize is %d\n", varaddr, varsize)); + brcmf_dbg(INFO, "Physical memory size: %d, usable memory size: %d\n", + bus->orig_ramsize, bus->ramsize); + brcmf_dbg(INFO, "Vars are at %d, orig varsize is %d\n", + varaddr, varsize); varsize = ((bus->orig_ramsize - 4) - varaddr); /* @@ -2863,8 +2841,8 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) varsizew = cpu_to_le32(varsizew); } - BRCMF_INFO(("New varsize is %d, length token=0x%08x\n", varsize, - varsizew)); + brcmf_dbg(INFO, "New varsize is %d, length token=0x%08x\n", + varsize, varsizew); /* Write the length token to the last word */ bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->orig_ramsize - 4), @@ -2902,15 +2880,14 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) regdata &= (SBTML_RESET | SBTML_REJ_MASK | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { - BRCMF_ERROR(("%s: SOCRAM core is down after reset?\n", - __func__)); + brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); bcmerror = -EBADE; goto fail; } bcmerror = brcmf_sdbrcm_write_vars(bus); if (bcmerror) { - BRCMF_ERROR(("%s: no vars written to RAM\n", __func__)); + brcmf_dbg(ERROR, "no vars written to RAM\n"); bcmerror = 0; } @@ -2938,7 +2915,7 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, int val_size; u32 actionid; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (name == NULL || len < 0) return -EINVAL; @@ -2974,8 +2951,8 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, goto exit; } - BRCMF_CTL(("%s: %s %s, len %d plen %d\n", __func__, - name, (set ? "set" : "get"), len, plen)); + brcmf_dbg(CTL, "%s %s, len %d plen %d\n", + name, set ? "set" : "get", len, plen); /* set up 'params' pointer in case this is a set command so that * the convenience int and bool code can be common to set and get @@ -3008,7 +2985,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) uint retries; int err; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (enforce_mutex) brcmf_sdbrcm_sdlock(bus); @@ -3048,11 +3025,10 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) (saveclk | SBSDIO_FORCE_HT), &err); } if (err) - BRCMF_ERROR(("%s: Failed to force clock for F2: err %d\n", - __func__, err)); + brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); /* Turn off the bus (F2), free any pending packets */ - BRCMF_INTR(("%s: disable SDIO interrupts\n", __func__)); + brcmf_dbg(INTR, "disable SDIO interrupts\n"); brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); @@ -3096,7 +3072,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) int err, ret = 0; u8 saveclk; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* try to download image and nvram to the dongle */ if (drvr->busstate == BRCMF_BUS_DOWN) { @@ -3129,8 +3105,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) (saveclk | SBSDIO_FORCE_HT), &err); } if (err) { - BRCMF_ERROR(("%s: Failed to force clock for F2: err %d\n", - __func__, err)); + brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); goto exit; } @@ -3154,8 +3129,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) msleep_interruptible(20); } - BRCMF_INFO(("%s: enable 0x%02x, ready 0x%02x\n", - __func__, enable, ready)); + brcmf_dbg(INFO, "enable 0x%02x, ready 0x%02x\n", enable, ready); /* If F2 successfully enabled, set core and enable interrupts */ if (ready == enable) { @@ -3186,8 +3160,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* Host registration for OOB interrupt */ if (brcmf_sdio_register_oob_intr(bus->dhd)) { brcmf_sdbrcm_wd_timer(bus, 0); - BRCMF_ERROR(("%s Host failed to resgister for OOB\n", - __func__)); + brcmf_dbg(ERROR, "Host failed to resgister for OOB\n"); ret = -ENODEV; goto exit; } @@ -3214,9 +3187,9 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) u8 hi, lo; int err; - BRCMF_ERROR(("%s: %sterminate frame%s\n", __func__, - (abort ? "abort command, " : ""), - (rtx ? ", send NAK" : ""))); + brcmf_dbg(ERROR, "%sterminate frame%s\n", + abort ? "abort command, " : "", + rtx ? ", send NAK" : ""); if (abort) brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); @@ -3238,19 +3211,16 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) break; if ((hi > (lastrbc >> 8)) && (lo > (lastrbc & 0x00ff))) { - BRCMF_ERROR(("%s: count growing: last 0x%04x now " - "0x%04x\n", - __func__, lastrbc, ((hi << 8) + lo))); + brcmf_dbg(ERROR, "count growing: last 0x%04x now 0x%04x\n", + lastrbc, (hi << 8) + lo); } lastrbc = (hi << 8) + lo; } if (!retries) - BRCMF_ERROR(("%s: count never zeroed: last 0x%04x\n", - __func__, lastrbc)); + brcmf_dbg(ERROR, "count never zeroed: last 0x%04x\n", lastrbc); else - BRCMF_INFO(("%s: flush took %d iterations\n", __func__, - (0xffff - retries))); + brcmf_dbg(INFO, "flush took %d iterations\n", 0xffff - retries); if (rtx) { bus->rxrtx++; @@ -3277,7 +3247,7 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) int sdret; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Set rxctl for frame (w/optional alignment) */ bus->rxctl = bus->rxbuf; @@ -3311,17 +3281,16 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) /* Drop if the read is too big or it exceeds our maximum */ if ((rdlen + firstread) > bus->drvr->maxctl) { - BRCMF_ERROR(("%s: %d-byte control read exceeds %d-byte" - " buffer\n", __func__, rdlen, bus->drvr->maxctl)); + brcmf_dbg(ERROR, "%d-byte control read exceeds %d-byte buffer\n", + rdlen, bus->drvr->maxctl); bus->drvr->rx_errors++; brcmf_sdbrcm_rxfail(bus, false, false); goto done; } if ((len - doff) > bus->drvr->maxctl) { - BRCMF_ERROR(("%s: %d-byte ctl frame (%d-byte ctl data) exceeds " - "%d-byte limit\n", - __func__, len, (len - doff), bus->drvr->maxctl)); + brcmf_dbg(ERROR, "%d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n", + len, len - doff, bus->drvr->maxctl); bus->drvr->rx_errors++; bus->rx_toolong++; brcmf_sdbrcm_rxfail(bus, false, false); @@ -3338,8 +3307,8 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) /* Control frame failures need retransmission */ if (sdret < 0) { - BRCMF_ERROR(("%s: read %d control bytes failed: %d\n", - __func__, rdlen, sdret)); + brcmf_dbg(ERROR, "read %d control bytes failed: %d\n", + rdlen, sdret); bus->rxc_errors++; brcmf_sdbrcm_rxfail(bus, true, true); goto done; @@ -3381,8 +3350,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* If packets, issue read(s) and send up packet chain */ /* Return sequence numbers consumed? */ - BRCMF_TRACE(("brcmf_sdbrcm_rxglom: start: glomd %p glom %p\n", - bus->glomd, bus->glom)); + brcmf_dbg(TRACE, "start: glomd %p glom %p\n", bus->glomd, bus->glom); /* If there's a descriptor, generate the packet chain */ if (bus->glomd) { @@ -3390,9 +3358,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) dlen = (u16) (bus->glomd->len); dptr = bus->glomd->data; if (!dlen || (dlen & 1)) { - BRCMF_ERROR(("%s: bad glomd len(%d)," - " ignore descriptor\n", - __func__, dlen)); + brcmf_dbg(ERROR, "bad glomd len(%d), ignore descriptor\n", + dlen); dlen = 0; } @@ -3403,15 +3370,14 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) dptr += sizeof(u16); if ((sublen < SDPCM_HDRLEN) || ((num == 0) && (sublen < (2 * SDPCM_HDRLEN)))) { - BRCMF_ERROR(("%s: descriptor len %d bad: %d\n", - __func__, num, sublen)); + brcmf_dbg(ERROR, "descriptor len %d bad: %d\n", + num, sublen); pnext = NULL; break; } if (sublen % BRCMF_SDALIGN) { - BRCMF_ERROR(("%s: sublen %d not multiple of" - " %d\n", __func__, sublen, - BRCMF_SDALIGN)); + brcmf_dbg(ERROR, "sublen %d not multiple of %d\n", + sublen, BRCMF_SDALIGN); usechain = false; } totlen += sublen; @@ -3427,9 +3393,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* Allocate/chain packet for next subframe */ pnext = brcmu_pkt_buf_get_skb(sublen + BRCMF_SDALIGN); if (pnext == NULL) { - BRCMF_ERROR(("%s: bcm_pkt_buf_get_skb failed, " - "num %d len %d\n", __func__, - num, sublen)); + brcmf_dbg(ERROR, "bcm_pkt_buf_get_skb failed, num %d len %d\n", + num, sublen); break; } if (!pfirst) { @@ -3446,15 +3411,12 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* If all allocations succeeded, save packet chain in bus structure */ if (pnext) { - BRCMF_GLOM(("%s: allocated %d-byte packet chain for %d " - "subframes\n", __func__, totlen, num)); + brcmf_dbg(GLOM, "allocated %d-byte packet chain for %d subframes\n", + totlen, num); if (BRCMF_GLOM_ON() && bus->nextlen) { if (totlen != bus->nextlen) { - BRCMF_GLOM(("%s: glomdesc mismatch: " - "nextlen %d glomdesc %d " - "rxseq %d\n", __func__, - bus->nextlen, - totlen, rxseq)); + brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", + bus->nextlen, totlen, rxseq); } } bus->glom = pfirst; @@ -3476,12 +3438,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) or had one from before */ if (bus->glom) { if (BRCMF_GLOM_ON()) { - BRCMF_GLOM(("%s: try superframe read, packet chain:\n", - __func__)); + brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); for (pnext = bus->glom; pnext; pnext = pnext->next) { - BRCMF_GLOM((" %p: %p len 0x%04x (%d)\n", - pnext, (u8 *) (pnext->data), - pnext->len, pnext->len)); + brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", + pnext, (u8 *) (pnext->data), + pnext->len, pnext->len); } } @@ -3507,23 +3468,22 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, bus->dataptr); if (sublen != dlen) { - BRCMF_ERROR(("%s: FAILED TO COPY, dlen %d " - "sublen %d\n", - __func__, dlen, sublen)); + brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", + dlen, sublen); errcode = -1; } pnext = NULL; } else { - BRCMF_ERROR(("COULDN'T ALLOC %d-BYTE GLOM, " - "FORCE FAILURE\n", dlen)); + brcmf_dbg(ERROR, "COULDN'T ALLOC %d-BYTE GLOM, FORCE FAILURE\n", + dlen); errcode = -1; } bus->f2rxdata++; /* On failure, kill the superframe, allow a couple retries */ if (errcode < 0) { - BRCMF_ERROR(("%s: glom read of %d bytes failed: %d\n", - __func__, dlen, errcode)); + brcmf_dbg(ERROR, "glom read of %d bytes failed: %d\n", + dlen, errcode); bus->drvr->rx_errors++; if (bus->glomerr++ < 3) { @@ -3554,8 +3514,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); bus->nextlen = dptr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - BRCMF_INFO(("%s: nextlen too large (%d) seq %d\n", - __func__, bus->nextlen, seq)); + brcmf_dbg(INFO, "nextlen too large (%d) seq %d\n", + bus->nextlen, seq); bus->nextlen = 0; } doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); @@ -3563,48 +3523,42 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) errcode = 0; if ((u16)~(sublen ^ check)) { - BRCMF_ERROR(("%s (superframe): HW hdr error: len/check " - "0x%04x/0x%04x\n", __func__, sublen, - check)); + brcmf_dbg(ERROR, "(superframe): HW hdr error: len/check 0x%04x/0x%04x\n", + sublen, check); errcode = -1; } else if (roundup(sublen, bus->blocksize) != dlen) { - BRCMF_ERROR(("%s (superframe): len 0x%04x, rounded " - "0x%04x, expect 0x%04x\n", - __func__, sublen, - roundup(sublen, bus->blocksize), dlen)); + brcmf_dbg(ERROR, "(superframe): len 0x%04x, rounded 0x%04x, expect 0x%04x\n", + sublen, roundup(sublen, bus->blocksize), + dlen); errcode = -1; } else if (SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]) != SDPCM_GLOM_CHANNEL) { - BRCMF_ERROR(("%s (superframe): bad channel %d\n", - __func__, - SDPCM_PACKET_CHANNEL(&dptr - [SDPCM_FRAMETAG_LEN]))); + brcmf_dbg(ERROR, "(superframe): bad channel %d\n", + SDPCM_PACKET_CHANNEL( + &dptr[SDPCM_FRAMETAG_LEN])); errcode = -1; } else if (SDPCM_GLOMDESC(&dptr[SDPCM_FRAMETAG_LEN])) { - BRCMF_ERROR(("%s (superframe): got 2nd descriptor?\n", - __func__)); + brcmf_dbg(ERROR, "(superframe): got 2nd descriptor?\n"); errcode = -1; } else if ((doff < SDPCM_HDRLEN) || (doff > (pfirst->len - SDPCM_HDRLEN))) { - BRCMF_ERROR(("%s (superframe): Bad data offset %d: " - "HW %d pkt %d min %d\n", - __func__, doff, sublen, - pfirst->len, SDPCM_HDRLEN)); + brcmf_dbg(ERROR, "(superframe): Bad data offset %d: HW %d pkt %d min %d\n", + doff, sublen, pfirst->len, SDPCM_HDRLEN); errcode = -1; } /* Check sequence number of superframe SW header */ if (rxseq != seq) { - BRCMF_INFO(("%s: (superframe) rx_seq %d, expected %d\n", - __func__, seq, rxseq)); + brcmf_dbg(INFO, "(superframe) rx_seq %d, expected %d\n", + seq, rxseq); bus->rx_badseq++; rxseq = seq; } /* Check window for sanity */ if ((u8) (txmax - bus->tx_seq) > 0x40) { - BRCMF_ERROR(("%s: unlikely tx max %d with tx_seq %d\n", - __func__, txmax, bus->tx_seq)); + brcmf_dbg(ERROR, "unlikely tx max %d with tx_seq %d\n", + txmax, bus->tx_seq); txmax = bus->tx_seq + 2; } bus->tx_max = txmax; @@ -3631,25 +3585,21 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) #endif if ((u16)~(sublen ^ check)) { - BRCMF_ERROR(("%s (subframe %d): HW hdr error: " - "len/check 0x%04x/0x%04x\n", - __func__, num, sublen, check)); + brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n", + num, sublen, check); errcode = -1; } else if ((sublen > dlen) || (sublen < SDPCM_HDRLEN)) { - BRCMF_ERROR(("%s (subframe %d): length mismatch" - ": len 0x%04x, expect 0x%04x\n", - __func__, num, sublen, dlen)); + brcmf_dbg(ERROR, "(subframe %d): length mismatch: len 0x%04x, expect 0x%04x\n", + num, sublen, dlen); errcode = -1; } else if ((chan != SDPCM_DATA_CHANNEL) && (chan != SDPCM_EVENT_CHANNEL)) { - BRCMF_ERROR(("%s (subframe %d): bad channel" - " %d\n", __func__, num, chan)); + brcmf_dbg(ERROR, "(subframe %d): bad channel %d\n", + num, chan); errcode = -1; } else if ((doff < SDPCM_HDRLEN) || (doff > sublen)) { - BRCMF_ERROR(("%s (subframe %d): Bad data offset" - " %d: HW %d min %d\n", - __func__, num, doff, sublen, - SDPCM_HDRLEN)); + brcmf_dbg(ERROR, "(subframe %d): Bad data offset %d: HW %d min %d\n", + num, doff, sublen, SDPCM_HDRLEN); errcode = -1; } } @@ -3687,17 +3637,16 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); - BRCMF_GLOM(("%s: Get subframe %d, %p(%p/%d), sublen %d " - "chan %d seq %d\n", - __func__, num, pfirst, pfirst->data, - pfirst->len, sublen, chan, seq)); + brcmf_dbg(GLOM, "Get subframe %d, %p(%p/%d), sublen %d chan %d seq %d\n", + num, pfirst, pfirst->data, + pfirst->len, sublen, chan, seq); /* precondition: chan == SDPCM_DATA_CHANNEL || chan == SDPCM_EVENT_CHANNEL */ if (rxseq != seq) { - BRCMF_GLOM(("%s: rx_seq %d, expected %d\n", - __func__, seq, rxseq)); + brcmf_dbg(GLOM, "rx_seq %d, expected %d\n", + seq, rxseq); bus->rx_badseq++; rxseq = seq; } @@ -3722,8 +3671,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) continue; } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pfirst) != 0) { - BRCMF_ERROR(("%s: rx protocol error\n", - __func__)); + brcmf_dbg(ERROR, "rx protocol error\n"); bus->drvr->rx_errors++; brcmu_pkt_buf_free_skb(pfirst); if (plast) @@ -3742,11 +3690,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) #ifdef BCMDBG if (BRCMF_GLOM_ON()) { - BRCMF_GLOM(("%s subframe %d to stack, %p" - "(%p/%d) nxt/lnk %p/%p\n", - __func__, num, pfirst, pfirst->data, - pfirst->len, pfirst->next, - pfirst->prev)); + brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", + num, pfirst, pfirst->data, + pfirst->len, pfirst->next, + pfirst->prev); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, pfirst->data, min_t(int, pfirst->len, 32)); @@ -3786,7 +3733,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) int ifidx = 0; uint rxcount = 0; /* Total frames read */ - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Not finished unless we encounter no more frames indication */ *finished = false; @@ -3798,10 +3745,10 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Handle glomming separately */ if (bus->glom || bus->glomd) { u8 cnt; - BRCMF_GLOM(("%s: calling rxglom: glomd %p, glom %p\n", - __func__, bus->glomd, bus->glom)); + brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", + bus->glomd, bus->glom); cnt = brcmf_sdbrcm_rxglom(bus, rxseq); - BRCMF_GLOM(("%s: rxglom returned %d\n", __func__, cnt)); + brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); rxseq += cnt - 1; rxleft = (rxleft > cnt) ? (rxleft - cnt) : 1; continue; @@ -3844,12 +3791,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN); if (!pkt) { /* Give up on data, request rtx of events */ - BRCMF_ERROR(("%s (nextlen): " - "brcmu_pkt_buf_get_skb " - "failed:" - " len %d rdlen %d expected" - " rxseq %d\n", __func__, - len, rdlen, rxseq)); + brcmf_dbg(ERROR, "(nextlen): brcmu_pkt_buf_get_skb failed: len %d rdlen %d expected rxseq %d\n", + len, rdlen, rxseq); continue; } else { PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); @@ -3864,9 +3807,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->f2rxdata++; if (sdret < 0) { - BRCMF_ERROR(("%s (nextlen): read %d" - " bytes failed: %d\n", - __func__, rdlen, sdret)); + brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n", + rdlen, sdret); brcmu_pkt_buf_free_skb(pkt); bus->drvr->rx_errors++; /* Force retry w/normal header read. @@ -3887,18 +3829,15 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* All zeros means readahead info was bad */ if (!(len | check)) { - BRCMF_INFO(("%s (nextlen): read zeros in HW " - "header???\n", __func__)); + brcmf_dbg(INFO, "(nextlen): read zeros in HW header???\n"); brcmf_sdbrcm_pktfree2(bus, pkt); continue; } /* Validate check bytes */ if ((u16)~(len ^ check)) { - BRCMF_ERROR(("%s (nextlen): HW hdr error:" - " nextlen/len/check" - " 0x%04x/0x%04x/0x%04x\n", - __func__, nextlen, len, check)); + brcmf_dbg(ERROR, "(nextlen): HW hdr error: nextlen/len/check 0x%04x/0x%04x/0x%04x\n", + nextlen, len, check); bus->rx_badhdr++; brcmf_sdbrcm_rxfail(bus, false, false); brcmf_sdbrcm_pktfree2(bus, pkt); @@ -3907,8 +3846,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Validate frame length */ if (len < SDPCM_HDRLEN) { - BRCMF_ERROR(("%s (nextlen): HW hdr length " - "invalid: %d\n", __func__, len)); + brcmf_dbg(ERROR, "(nextlen): HW hdr length invalid: %d\n", + len); brcmf_sdbrcm_pktfree2(bus, pkt); continue; } @@ -3918,11 +3857,9 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) if (len_consistent) { /* Mismatch, force retry w/normal header (may be >4K) */ - BRCMF_ERROR(("%s (nextlen): mismatch, " - "nextlen %d len %d rnd %d; " - "expected rxseq %d\n", - __func__, nextlen, - len, roundup(len, 16), rxseq)); + brcmf_dbg(ERROR, "(nextlen): mismatch, nextlen %d len %d rnd %d; expected rxseq %d\n", + nextlen, len, roundup(len, 16), + rxseq); brcmf_sdbrcm_rxfail(bus, true, true); brcmf_sdbrcm_pktfree2(bus, pkt); continue; @@ -3942,9 +3879,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - BRCMF_INFO(("%s (nextlen): got frame w/nextlen" - " too large (%d), seq %d\n", - __func__, bus->nextlen, seq)); + brcmf_dbg(INFO, "(nextlen): got frame w/nextlen too large (%d), seq %d\n", + bus->nextlen, seq); bus->nextlen = 0; } @@ -3967,17 +3903,16 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Check and update sequence number */ if (rxseq != seq) { - BRCMF_INFO(("%s (nextlen): rx_seq %d, expected " - "%d\n", __func__, seq, rxseq)); + brcmf_dbg(INFO, "(nextlen): rx_seq %d, expected %d\n", + seq, rxseq); bus->rx_badseq++; rxseq = seq; } /* Check window for sanity */ if ((u8) (txmax - bus->tx_seq) > 0x40) { - BRCMF_ERROR(("%s: got unlikely tx max %d with " - "tx_seq %d\n", - __func__, txmax, bus->tx_seq)); + brcmf_dbg(ERROR, "got unlikely tx max %d with tx_seq %d\n", + txmax, bus->tx_seq); txmax = bus->tx_seq + 2; } bus->tx_max = txmax; @@ -3995,9 +3930,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) #endif if (chan == SDPCM_CONTROL_CHANNEL) { - BRCMF_ERROR(("%s (nextlen): readahead" - " on control packet %d?\n", - __func__, seq)); + brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n", + seq); /* Force retry w/normal header read */ bus->nextlen = 0; brcmf_sdbrcm_rxfail(bus, false, true); @@ -4007,9 +3941,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Validate data offset */ if ((doff < SDPCM_HDRLEN) || (doff > len)) { - BRCMF_ERROR(("%s (nextlen): bad data offset %d:" - " HW len %d min %d\n", __func__, - doff, len, SDPCM_HDRLEN)); + brcmf_dbg(ERROR, "(nextlen): bad data offset %d: HW len %d min %d\n", + doff, len, SDPCM_HDRLEN); brcmf_sdbrcm_rxfail(bus, false, false); brcmf_sdbrcm_pktfree2(bus, pkt); continue; @@ -4027,8 +3960,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->f2rxhdrs++; if (sdret < 0) { - BRCMF_ERROR(("%s: RXHEADER FAILED: %d\n", __func__, - sdret)); + brcmf_dbg(ERROR, "RXHEADER FAILED: %d\n", sdret); bus->rx_hdrfail++; brcmf_sdbrcm_rxfail(bus, true, true); continue; @@ -4053,8 +3985,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Validate check bytes */ if ((u16) ~(len ^ check)) { - BRCMF_ERROR(("%s: HW hdr err: len/check " - "0x%04x/0x%04x\n", __func__, len, check)); + brcmf_dbg(ERROR, "HW hdr err: len/check 0x%04x/0x%04x\n", + len, check); bus->rx_badhdr++; brcmf_sdbrcm_rxfail(bus, false, false); continue; @@ -4062,8 +3994,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Validate frame length */ if (len < SDPCM_HDRLEN) { - BRCMF_ERROR(("%s: HW hdr length invalid: %d\n", - __func__, len)); + brcmf_dbg(ERROR, "HW hdr length invalid: %d\n", len); continue; } @@ -4075,9 +4006,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Validate data offset */ if ((doff < SDPCM_HDRLEN) || (doff > len)) { - BRCMF_ERROR(("%s: Bad data offset %d: HW len %d," - " min %d seq %d\n", __func__, doff, - len, SDPCM_HDRLEN, seq)); + brcmf_dbg(ERROR, "Bad data offset %d: HW len %d, min %d seq %d\n", + doff, len, SDPCM_HDRLEN, seq); bus->rx_badhdr++; brcmf_sdbrcm_rxfail(bus, false, false); continue; @@ -4087,9 +4017,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->nextlen = bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - BRCMF_INFO(("%s (nextlen): got frame w/nextlen too" - " large (%d), seq %d\n", - __func__, bus->nextlen, seq)); + brcmf_dbg(INFO, "(nextlen): got frame w/nextlen too large (%d), seq %d\n", + bus->nextlen, seq); bus->nextlen = 0; } @@ -4109,16 +4038,15 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Check and update sequence number */ if (rxseq != seq) { - BRCMF_INFO(("%s: rx_seq %d, expected %d\n", __func__, - seq, rxseq)); + brcmf_dbg(INFO, "rx_seq %d, expected %d\n", seq, rxseq); bus->rx_badseq++; rxseq = seq; } /* Check window for sanity */ if ((u8) (txmax - bus->tx_seq) > 0x40) { - BRCMF_ERROR(("%s: unlikely tx max %d with tx_seq %d\n", - __func__, txmax, bus->tx_seq)); + brcmf_dbg(ERROR, "unlikely tx max %d with tx_seq %d\n", + txmax, bus->tx_seq); txmax = bus->tx_seq + 2; } bus->tx_max = txmax; @@ -4153,8 +4081,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) if ((rdlen + firstread) > MAX_RX_DATASZ) { /* Too long -- skip this frame */ - BRCMF_ERROR(("%s: too long: len %d rdlen %d\n", - __func__, len, rdlen)); + brcmf_dbg(ERROR, "too long: len %d rdlen %d\n", + len, rdlen); bus->drvr->rx_errors++; bus->rx_toolong++; brcmf_sdbrcm_rxfail(bus, false, false); @@ -4164,9 +4092,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) pkt = brcmu_pkt_buf_get_skb(rdlen + firstread + BRCMF_SDALIGN); if (!pkt) { /* Give up on data, request rtx of events */ - BRCMF_ERROR(("%s: brcmu_pkt_buf_get_skb failed:" - " rdlen %d chan %d\n", __func__, rdlen, - chan)); + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: rdlen %d chan %d\n", + rdlen, chan); bus->drvr->rx_dropped++; brcmf_sdbrcm_rxfail(bus, false, RETRYCHAN(chan)); continue; @@ -4184,11 +4111,10 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->f2rxdata++; if (sdret < 0) { - BRCMF_ERROR(("%s: read %d %s bytes failed: %d\n", - __func__, rdlen, - ((chan == SDPCM_EVENT_CHANNEL) ? "event" - : ((chan == SDPCM_DATA_CHANNEL) ? "data" - : "test")), sdret)); + brcmf_dbg(ERROR, "read %d %s bytes failed: %d\n", rdlen, + ((chan == SDPCM_EVENT_CHANNEL) ? "event" + : ((chan == SDPCM_DATA_CHANNEL) ? "data" + : "test")), sdret); brcmu_pkt_buf_free_skb(pkt); bus->drvr->rx_errors++; brcmf_sdbrcm_rxfail(bus, true, RETRYCHAN(chan)); @@ -4211,8 +4137,8 @@ deliver: /* Save superframe descriptor and allocate packet frame */ if (chan == SDPCM_GLOM_CHANNEL) { if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { - BRCMF_GLOM(("%s: glom descriptor, %d bytes:\n", - __func__, len)); + brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", + len); #ifdef BCMDBG if (BRCMF_GLOM_ON()) { printk(KERN_DEBUG "Glom Data:\n"); @@ -4225,8 +4151,8 @@ deliver: skb_pull(pkt, SDPCM_HDRLEN); bus->glomd = pkt; } else { - BRCMF_ERROR(("%s: glom superframe w/o " - "descriptor!\n", __func__)); + brcmf_dbg(ERROR, "%s: glom superframe w/o " + "descriptor!\n", __func__); brcmf_sdbrcm_rxfail(bus, false, false); } continue; @@ -4240,7 +4166,7 @@ deliver: brcmu_pkt_buf_free_skb(pkt); continue; } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pkt) != 0) { - BRCMF_ERROR(("%s: rx protocol error\n", __func__)); + brcmf_dbg(ERROR, "rx protocol error\n"); brcmu_pkt_buf_free_skb(pkt); bus->drvr->rx_errors++; continue; @@ -4255,11 +4181,11 @@ deliver: #ifdef BCMDBG /* Message if we hit the limit */ if (!rxleft) - BRCMF_DATA(("%s: hit rx limit of %d frames\n", __func__, - maxframes)); + brcmf_dbg(DATA, "hit rx limit of %d frames\n", + maxframes); else #endif /* BCMDBG */ - BRCMF_DATA(("%s: processed %d frames\n", __func__, rxcount)); + brcmf_dbg(DATA, "processed %d frames\n", rxcount); /* Back off rxseq if awaiting rtx, update rx_seq */ if (bus->rxskip) rxseq--; @@ -4275,7 +4201,7 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) u8 fcbits; uint retries = 0; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Read mailbox data and ack that we did so */ r_sdreg32(bus, &hmb_data, @@ -4288,10 +4214,10 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) /* Dongle recomposed rx frames, accept them again */ if (hmb_data & HMB_DATA_NAKHANDLED) { - BRCMF_INFO(("Dongle reports NAK handled, expect rtx of %d\n", - bus->rx_seq)); + brcmf_dbg(INFO, "Dongle reports NAK handled, expect rtx of %d\n", + bus->rx_seq); if (!bus->rxskip) - BRCMF_ERROR(("%s: unexpected NAKHANDLED!\n", __func__)); + brcmf_dbg(ERROR, "unexpected NAKHANDLED!\n"); bus->rxskip = false; intstatus |= I_HMB_FRAME_IND; @@ -4305,12 +4231,12 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) (hmb_data & HMB_DATA_VERSION_MASK) >> HMB_DATA_VERSION_SHIFT; if (bus->sdpcm_ver != SDPCM_PROT_VERSION) - BRCMF_ERROR(("Version mismatch, dongle reports %d, " - "expecting %d\n", - bus->sdpcm_ver, SDPCM_PROT_VERSION)); + brcmf_dbg(ERROR, "Version mismatch, dongle reports %d, " + "expecting %d\n", + bus->sdpcm_ver, SDPCM_PROT_VERSION); else - BRCMF_INFO(("Dongle ready, protocol version %d\n", - bus->sdpcm_ver)); + brcmf_dbg(INFO, "Dongle ready, protocol version %d\n", + bus->sdpcm_ver); } /* @@ -4338,8 +4264,8 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) HMB_DATA_FC | HMB_DATA_FWREADY | HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) - BRCMF_ERROR(("Unknown mailbox data content: 0x%02x\n", - hmb_data)); + brcmf_dbg(ERROR, "Unknown mailbox data content: 0x%02x\n", + hmb_data); return intstatus; } @@ -4354,7 +4280,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) bool rxdone = true; /* Flag for no more read data */ bool resched = false; /* Flag indicating resched wanted */ - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Start with leftover status bits */ intstatus = bus->intstatus; @@ -4371,8 +4297,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { - BRCMF_ERROR(("%s: error reading DEVCTL: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); bus->drvr->busstate = BRCMF_BUS_DOWN; } #endif /* BCMDBG */ @@ -4381,29 +4306,29 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err) { - BRCMF_ERROR(("%s: error reading CSR: %d\n", __func__, - err)); + brcmf_dbg(ERROR, "error reading CSR: %d\n", + err); bus->drvr->busstate = BRCMF_BUS_DOWN; } - BRCMF_INFO(("DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", - devctl, clkctl)); + brcmf_dbg(INFO, "DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", + devctl, clkctl); if (SBSDIO_HTAV(clkctl)) { devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); if (err) { - BRCMF_ERROR(("%s: error reading DEVCTL: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", + err); bus->drvr->busstate = BRCMF_BUS_DOWN; } devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); if (err) { - BRCMF_ERROR(("%s: error writing DEVCTL: %d\n", - __func__, err)); + brcmf_dbg(ERROR, "error writing DEVCTL: %d\n", + err); bus->drvr->busstate = BRCMF_BUS_DOWN; } bus->clkstate = CLK_AVAIL; @@ -4466,23 +4391,23 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) /* Generally don't ask for these, can get CRC errors... */ if (intstatus & I_WR_OOSYNC) { - BRCMF_ERROR(("Dongle reports WR_OOSYNC\n")); + brcmf_dbg(ERROR, "Dongle reports WR_OOSYNC\n"); intstatus &= ~I_WR_OOSYNC; } if (intstatus & I_RD_OOSYNC) { - BRCMF_ERROR(("Dongle reports RD_OOSYNC\n")); + brcmf_dbg(ERROR, "Dongle reports RD_OOSYNC\n"); intstatus &= ~I_RD_OOSYNC; } if (intstatus & I_SBINT) { - BRCMF_ERROR(("Dongle reports SBINT\n")); + brcmf_dbg(ERROR, "Dongle reports SBINT\n"); intstatus &= ~I_SBINT; } /* Would be active due to wake-wlan in gSPI */ if (intstatus & I_CHIPACTIVE) { - BRCMF_INFO(("Dongle reports CHIPACTIVE\n")); + brcmf_dbg(INFO, "Dongle reports CHIPACTIVE\n"); intstatus &= ~I_CHIPACTIVE; } @@ -4514,8 +4439,8 @@ clkwait: if (ret < 0) { /* On failure, abort the command and terminate the frame */ - BRCMF_INFO(("%s: sdio error %d, abort command and " - "terminate frame.\n", __func__, ret)); + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); bus->tx_sderrs++; brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); @@ -4544,7 +4469,7 @@ clkwait: if (ret == 0) bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - BRCMF_INFO(("Return_dpc value is : %d\n", ret)); + brcmf_dbg(INFO, "Return_dpc value is : %d\n", ret); bus->ctrl_frame_stat = false; brcmf_sdbrcm_wait_event_wakeup(bus); } @@ -4563,14 +4488,12 @@ clkwait: no resched or interrupts */ if ((bus->drvr->busstate == BRCMF_BUS_DOWN) || brcmf_sdcard_regfail(bus->sdiodev)) { - BRCMF_ERROR(("%s: failed backplane access over SDIO, halting " - "operation %d\n", __func__, - brcmf_sdcard_regfail(bus->sdiodev))); + brcmf_dbg(ERROR, "failed backplane access over SDIO, halting operation %d\n", + brcmf_sdcard_regfail(bus->sdiodev)); bus->drvr->busstate = BRCMF_BUS_DOWN; bus->intstatus = 0; } else if (bus->clkstate == CLK_PENDING) { - BRCMF_INFO(("%s: rescheduled due to CLK_PENDING awaiting " - "I_CHIPACTIVE interrupt\n", __func__)); + brcmf_dbg(INFO, "rescheduled due to CLK_PENDING awaiting I_CHIPACTIVE interrupt\n"); resched = true; } else if (bus->intstatus || bus->ipend || (!bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) @@ -4596,16 +4519,15 @@ void brcmf_sdbrcm_isr(void *arg) { struct brcmf_bus *bus = (struct brcmf_bus *) arg; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (!bus) { - BRCMF_ERROR(("%s : bus is null pointer , exit\n", __func__)); + brcmf_dbg(ERROR, "bus is null pointer, exiting\n"); return; } if (bus->drvr->busstate == BRCMF_BUS_DOWN) { - BRCMF_ERROR(("%s : bus is down. we have nothing to do\n", - __func__)); + brcmf_dbg(ERROR, "bus is down. we have nothing to do\n"); return; } /* Count the interrupt call */ @@ -4614,16 +4536,16 @@ void brcmf_sdbrcm_isr(void *arg) /* Shouldn't get this interrupt if we're sleeping? */ if (bus->sleeping) { - BRCMF_ERROR(("INTERRUPT WHILE SLEEPING??\n")); + brcmf_dbg(ERROR, "INTERRUPT WHILE SLEEPING??\n"); return; } /* Disable additional interrupts (is this needed now)? */ if (!bus->intr) - BRCMF_ERROR(("brcmf_sdbrcm_isr() w/o interrupt configured!\n")); + brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); #if defined(SDIO_ISR_THREAD) - BRCMF_TRACE(("Calling brcmf_sdbrcm_dpc() from %s\n", __func__)); + brcmf_dbg(TRACE, "Calling brcmf_sdbrcm_dpc()\n"); while (brcmf_sdbrcm_dpc(bus)) ; #else @@ -4637,7 +4559,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) { struct brcmf_bus *bus; - BRCMF_TIMER(("%s: Enter\n", __func__)); + brcmf_dbg(TIMER, "Enter\n"); bus = drvr->bus; @@ -4817,7 +4739,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, brcmf_c_init(); - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* We make an assumption about address window mappings: * regsva == SI_ENUM_BASE*/ @@ -4825,8 +4747,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Allocate private bus interface state */ bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); if (!bus) { - BRCMF_ERROR(("%s: kmalloc of struct dhd_bus failed\n", - __func__)); + brcmf_dbg(ERROR, "kmalloc of struct dhd_bus failed\n"); goto fail; } bus->sdiodev = sdiodev; @@ -4837,8 +4758,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* attempt to attach to the dongle */ if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { - BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_attach failed\n", - __func__)); + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_attach failed\n"); goto fail; } @@ -4893,47 +4813,43 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Attach to the brcmf/OS/network interface */ bus->drvr = brcmf_attach(bus, SDPCM_RESERVE); if (!bus->drvr) { - BRCMF_ERROR(("%s: brcmf_attach failed\n", __func__)); + brcmf_dbg(ERROR, "brcmf_attach failed\n"); goto fail; } /* Allocate buffers */ if (!(brcmf_sdbrcm_probe_malloc(bus))) { - BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_malloc failed\n", - __func__)); + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_malloc failed\n"); goto fail; } if (!(brcmf_sdbrcm_probe_init(bus))) { - BRCMF_ERROR(("%s: brcmf_sdbrcm_probe_init failed\n", __func__)); + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_init failed\n"); goto fail; } /* Register interrupt callback, but mask it (not operational yet). */ - BRCMF_INTR(("%s: disable SDIO interrupts (not interested yet)\n", - __func__)); + brcmf_dbg(INTR, "disable SDIO interrupts (not interested yet)\n"); ret = brcmf_sdcard_intr_reg(bus->sdiodev); if (ret != 0) { - BRCMF_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n", - __func__, ret)); + brcmf_dbg(ERROR, "FAILED: sdcard_intr_reg returned %d\n", ret); goto fail; } - BRCMF_INTR(("%s: registered SDIO interrupt function ok\n", __func__)); + brcmf_dbg(INTR, "registered SDIO interrupt function ok\n"); - BRCMF_INFO(("%s: completed!!\n", __func__)); + brcmf_dbg(INFO, "completed!!\n"); /* if firmware path present try to download and bring up bus */ ret = brcmf_bus_start(bus->drvr); if (ret != 0) { if (ret == -ENOLINK) { - BRCMF_ERROR(("%s: dongle is not responding\n", - __func__)); + brcmf_dbg(ERROR, "dongle is not responding\n"); goto fail; } } /* Ok, have the per-port tell the stack we're open for business */ if (brcmf_net_attach(bus->drvr, 0) != 0) { - BRCMF_ERROR(("%s: Net attach failed!!\n", __func__)); + brcmf_dbg(ERROR, "Net attach failed!!\n"); goto fail; } @@ -4956,8 +4872,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) /* Return the window to backplane enumeration space for core access */ if (brcmf_sdbrcm_set_siaddr_window(bus, SI_ENUM_BASE)) - BRCMF_ERROR(("%s: FAILED to return to SI_ENUM_BASE\n", - __func__)); + brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); #ifdef BCMDBG printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", @@ -4979,21 +4894,18 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) SBSDIO_FUNC1_CHIPCLKCSR, &err); if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { - BRCMF_ERROR(("brcmf_sdbrcm_probe: ChipClkCSR access: err %d" - " wrote 0x%02x read 0x%02x\n", - err, BRCMF_INIT_CLKCTL1, clkctl)); + brcmf_dbg(ERROR, "ChipClkCSR access: err %d wrote 0x%02x read 0x%02x\n", + err, BRCMF_INIT_CLKCTL1, clkctl); goto fail; } if (brcmf_sdbrcm_chip_attach(bus, regsva)) { - BRCMF_ERROR(("%s: brcmf_sdbrcm_chip_attach failed!\n", - __func__)); + brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); goto fail; } if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) { - BRCMF_ERROR(("%s: unsupported chip: 0x%04x\n", - __func__, bus->ci->chip)); + brcmf_dbg(ERROR, "unsupported chip: 0x%04x\n", bus->ci->chip); goto fail; } @@ -5004,16 +4916,15 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) CORE_SB(bus->ci->armcorebase, sbidhigh), 4); bus->orig_ramsize = bus->ci->ramsize; if (!(bus->orig_ramsize)) { - BRCMF_ERROR(("%s: failed to find SOCRAM memory!\n", - __func__)); + brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); goto fail; } bus->ramsize = bus->orig_ramsize; if (brcmf_dongle_memsize) brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); - BRCMF_ERROR(("DHD: dongle ram size is set to %d(orig %d)\n", - bus->ramsize, bus->orig_ramsize)); + brcmf_dbg(ERROR, "DHD: dongle ram size is set to %d(orig %d)\n", + bus->ramsize, bus->orig_ramsize); /* Set core control so an SDIO reset does a backplane reset */ reg_addr = bus->ci->buscorebase + @@ -5042,7 +4953,7 @@ fail: static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr->maxctl) { bus->rxblen = @@ -5050,8 +4961,8 @@ static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) ALIGNMENT) + BRCMF_SDALIGN; bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC); if (!(bus->rxbuf)) { - BRCMF_ERROR(("%s: kmalloc of %d-byte rxbuf failed\n", - __func__, bus->rxblen)); + brcmf_dbg(ERROR, "kmalloc of %d-byte rxbuf failed\n", + bus->rxblen); goto fail; } } @@ -5059,8 +4970,8 @@ static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) /* Allocate buffer to receive glomed packet */ bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC); if (!(bus->databuf)) { - BRCMF_ERROR(("%s: kmalloc of %d-byte databuf failed\n", - __func__, MAX_DATA_BUF)); + brcmf_dbg(ERROR, "kmalloc of %d-byte databuf failed\n", + MAX_DATA_BUF); /* release rxbuf which was already located as above */ if (!bus->rxblen) kfree(bus->rxbuf); @@ -5082,7 +4993,7 @@ fail: static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Disable F2 to clear any intermediate frame state on the dongle */ brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, @@ -5112,9 +5023,8 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) false) != 0) bus->sd_rxchain = false; else - BRCMF_INFO(("%s: bus module (through sdiocard API) %s" - " chaining\n", __func__, bus->sd_rxchain - ? "supports" : "does not support")); + brcmf_dbg(INFO, "bus module (through sdiocard API) %s chaining\n", + bus->sd_rxchain ? "supports" : "does not support"); bus->use_rxchain = (bool) bus->sd_rxchain; @@ -5139,7 +5049,7 @@ brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) /* Detach and free everything */ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus) { /* De-register interrupt handler */ @@ -5156,12 +5066,12 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) kfree(bus); } - BRCMF_TRACE(("%s: Disconnected\n", __func__)); + brcmf_dbg(TRACE, "Disconnected\n"); } static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr && bus->drvr->dongle_reset) return; @@ -5176,7 +5086,7 @@ static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus->drvr && bus->drvr->dongle_reset) return; @@ -5190,24 +5100,24 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) bus->vars = NULL; } - BRCMF_TRACE(("%s: Disconnected\n", __func__)); + brcmf_dbg(TRACE, "Disconnected\n"); } void brcmf_sdbrcm_disconnect(void *ptr) { struct brcmf_bus *bus = (struct brcmf_bus *)ptr; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); if (bus) brcmf_sdbrcm_release(bus); - BRCMF_TRACE(("%s: Disconnected\n", __func__)); + brcmf_dbg(TRACE, "Disconnected\n"); } int brcmf_bus_register(void) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* Sanity check on the module parameters */ do { @@ -5220,7 +5130,7 @@ int brcmf_bus_register(void) && brcmf_deferred_tx) break; - BRCMF_ERROR(("Invalid module parameters.\n")); + brcmf_dbg(ERROR, "Invalid module parameters.\n"); return -EINVAL; } while (0); @@ -5229,7 +5139,7 @@ int brcmf_bus_register(void) void brcmf_bus_unregister(void) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); brcmf_sdio_unregister(); } @@ -5241,22 +5151,21 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) u8 *memblock = NULL, *memptr; int ret; - BRCMF_INFO(("%s: Enter\n", __func__)); + brcmf_dbg(INFO, "Enter\n"); bus->fw_name = BCM4329_FW_NAME; ret = request_firmware(&bus->firmware, bus->fw_name, &bus->sdiodev->func[2]->dev); if (ret) { - BRCMF_ERROR(("%s: Fail to request firmware %d\n", - __func__, ret)); + brcmf_dbg(ERROR, "Fail to request firmware %d\n", ret); return ret; } bus->fw_ptr = 0; memptr = memblock = kmalloc(MEMBLOCK + BRCMF_SDALIGN, GFP_ATOMIC); if (memblock == NULL) { - BRCMF_ERROR(("%s: Failed to allocate memory %d bytes\n", - __func__, MEMBLOCK)); + brcmf_dbg(ERROR, "Failed to allocate memory %d bytes\n", + MEMBLOCK); ret = -ENOMEM; goto err; } @@ -5269,9 +5178,8 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) brcmf_sdbrcm_get_image((char *)memptr, MEMBLOCK, bus))) { ret = brcmf_sdbrcm_membytes(bus, true, offset, memptr, len); if (ret) { - BRCMF_ERROR(("%s: error %d on writing %d membytes at " - "0x%08x\n", __func__, ret, MEMBLOCK, - offset)); + brcmf_dbg(ERROR, "error %d on writing %d membytes at 0x%08x\n", + ret, MEMBLOCK, offset); goto err; } @@ -5349,15 +5257,15 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) ret = request_firmware(&bus->firmware, bus->nv_name, &bus->sdiodev->func[2]->dev); if (ret) { - BRCMF_ERROR(("%s: Fail to request nvram %d\n", __func__, ret)); + brcmf_dbg(ERROR, "Fail to request nvram %d\n", ret); return ret; } bus->fw_ptr = 0; memblock = kmalloc(MEMBLOCK, GFP_ATOMIC); if (memblock == NULL) { - BRCMF_ERROR(("%s: Failed to allocate memory %d bytes\n", - __func__, MEMBLOCK)); + brcmf_dbg(ERROR, "Failed to allocate memory %d bytes\n", + MEMBLOCK); ret = -ENOMEM; goto err; } @@ -5373,11 +5281,9 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) if (len) ret = brcmf_sdbrcm_downloadvars(bus, memblock, len + 1); if (ret) - BRCMF_ERROR(("%s: error downloading vars: %d\n", - __func__, ret)); + brcmf_dbg(ERROR, "error downloading vars: %d\n", ret); } else { - BRCMF_ERROR(("%s: error reading nvram file: %d\n", - __func__, len)); + brcmf_dbg(ERROR, "error reading nvram file: %d\n", len); ret = -EIO; } @@ -5396,27 +5302,23 @@ static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) /* Keep arm in reset */ if (brcmf_sdbrcm_download_state(bus, true)) { - BRCMF_ERROR(("%s: error placing ARM core in reset\n", - __func__)); + brcmf_dbg(ERROR, "error placing ARM core in reset\n"); goto err; } /* External image takes precedence if specified */ if (brcmf_sdbrcm_download_code_file(bus)) { - BRCMF_ERROR(("%s: dongle image file download failed\n", - __func__)); + brcmf_dbg(ERROR, "dongle image file download failed\n"); goto err; } /* External nvram takes precedence if specified */ if (brcmf_sdbrcm_download_nvram(bus)) - BRCMF_ERROR(("%s: dongle nvram file download failed\n", - __func__)); + brcmf_dbg(ERROR, "dongle nvram file download failed\n"); /* Take arm out of reset */ if (brcmf_sdbrcm_download_state(bus, false)) { - BRCMF_ERROR(("%s: error getting out of ARM core reset\n", - __func__)); + brcmf_dbg(ERROR, "error getting out of ARM core reset\n"); goto err; } @@ -5457,14 +5359,14 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) bus->drvr->dongle_reset = true; bus->drvr->up = false; - BRCMF_TRACE(("%s: WLAN OFF DONE\n", __func__)); + brcmf_dbg(TRACE, "WLAN OFF DONE\n"); /* App can now remove power from device */ } else bcmerror = -EIO; } else { /* App must have restored power to device before calling */ - BRCMF_TRACE(("\n\n%s: == WLAN ON ==\n", __func__)); + brcmf_dbg(TRACE, " == WLAN ON ==\n"); if (bus->drvr->dongle_reset) { /* Turn on WLAN */ @@ -5479,16 +5381,14 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) bus->drvr->dongle_reset = false; bus->drvr->up = true; - BRCMF_TRACE(("%s: WLAN ON DONE\n", - __func__)); + brcmf_dbg(TRACE, "WLAN ON DONE\n"); } else bcmerror = -EIO; } else bcmerror = -EIO; } else { bcmerror = -EISCONN; - BRCMF_ERROR(("%s: Set DEVRESET=false invoked when" - " device is on\n", __func__)); + brcmf_dbg(ERROR, "Set DEVRESET=false invoked when device is on\n"); bcmerror = -EIO; } brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); @@ -5514,8 +5414,7 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, ci->chip = regdata & CID_ID_MASK; ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; - BRCMF_INFO(("%s: chipid=0x%x chiprev=%d\n", - __func__, ci->chip, ci->chiprev)); + brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); /* Address of cores for new chips should be added here */ switch (ci->chip) { @@ -5526,8 +5425,7 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, ci->ramsize = BCM4329_RAMSIZE; break; default: - BRCMF_ERROR(("%s: chipid 0x%x is not supported\n", - __func__, ci->chip)); + brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); return -ENODEV; } @@ -5544,9 +5442,8 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, ci->buscorerev = SBCOREREV(regdata); ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; - BRCMF_INFO(("%s: ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - __func__, ci->ccrev, ci->pmurev, - ci->buscorerev, ci->buscoretype)); + brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", + ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); /* get chipcommon capabilites */ ci->cccaps = brcmf_sdcard_reg_read(sdiodev, @@ -5587,7 +5484,7 @@ brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4); if (regdata & SBTMH_BUSY) - BRCMF_ERROR(("%s: ARM core still busy\n", __func__)); + brcmf_dbg(ERROR, "ARM core still busy\n"); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbidlow), 4); @@ -5641,12 +5538,12 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) int err; u8 clkval, clkset; - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); /* alloc chip_info_t */ ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); if (NULL == ci) { - BRCMF_ERROR(("%s: malloc failed!\n", __func__)); + brcmf_dbg(ERROR, "malloc failed!\n"); return -ENOMEM; } @@ -5656,7 +5553,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); if (err) { - BRCMF_ERROR(("%s: error writing for HT off\n", __func__)); + brcmf_dbg(ERROR, "error writing for HT off\n"); goto fail; } @@ -5672,8 +5569,8 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) !SBSDIO_ALPAV(clkval)), PMU_MAX_TRANSITION_DLY); if (!SBSDIO_ALPAV(clkval)) { - BRCMF_ERROR(("%s: timeout on ALPAV wait," - " clkval 0x%02x\n", __func__, clkval)); + brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", + clkval); err = -EBUSY; goto fail; } @@ -5684,8 +5581,8 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) clkset, &err); udelay(65); } else { - BRCMF_ERROR(("%s: ChipClkCSR access: wrote 0x%02x" - " read 0x%02x\n", __func__, clkset, clkval)); + brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", + clkset, clkval); err = -EACCES; goto fail; } @@ -5844,10 +5741,9 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, str_shift = 11; break; default: - BRCMF_ERROR(("No SDIO Drive strength init" - "done for chip %s rev %d pmurev %d\n", - brcmu_chipname(bus->ci->chip, chn, 8), - bus->ci->chiprev, bus->ci->pmurev)); + brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", + brcmu_chipname(bus->ci->chip, chn, 8), + bus->ci->chiprev, bus->ci->pmurev); break; } @@ -5875,15 +5771,15 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4, cc_data_temp); - BRCMF_INFO(("SDIO: %dmA drive strength selected, " - "set to 0x%08x\n", drivestrength, cc_data_temp)); + brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", + drivestrength, cc_data_temp); } } static void brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) { - BRCMF_TRACE(("%s: Enter\n", __func__)); + brcmf_dbg(TRACE, "Enter\n"); kfree(bus->ci); bus->ci = NULL; From 54586533ef1cc8fc0accea0f4e02f8099461613f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 6 Aug 2011 19:13:25 -0500 Subject: [PATCH 0529/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VIII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2357 ++++++++++++++------------- drivers/staging/rtl8192e/rtl_core.h | 683 ++++---- 2 files changed, 1537 insertions(+), 1503 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index f585f71e14b..68a4e858ecb 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -41,7 +41,7 @@ #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC -#include +#include #include #include "rtl_core.h" #include "r8192E_phy.h" @@ -58,26 +58,26 @@ int hwwep = 1; static int channels = 0x3fff; -char* ifname = "wlan%d"; +char *ifname = "wlan%d"; struct rtl819x_ops rtl819xp_ops = { - .nic_type = NIC_8192E, - .get_eeprom_size = rtl8192_get_eeprom_size, + .nic_type = NIC_8192E, + .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, - .initialize_adapter = rtl8192_adapter_start, - .link_change = rtl8192_link_change, - .tx_fill_descriptor = rtl8192_tx_fill_desc, - .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, + .initialize_adapter = rtl8192_adapter_start, + .link_change = rtl8192_link_change, + .tx_fill_descriptor = rtl8192_tx_fill_desc, + .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, .rx_query_status_descriptor = rtl8192_rx_query_status_desc, .rx_command_packet_handler = NULL, - .stop_adapter = rtl8192_halt_adapter, - .update_ratr_table = rtl8192_update_ratr_table, - .irq_enable = rtl8192_EnableInterrupt, - .irq_disable = rtl8192_DisableInterrupt, - .irq_clear = rtl8192_ClearInterrupt, - .rx_enable = rtl8192_enable_rx, - .tx_enable = rtl8192_enable_tx, + .stop_adapter = rtl8192_halt_adapter, + .update_ratr_table = rtl8192_update_ratr_table, + .irq_enable = rtl8192_EnableInterrupt, + .irq_disable = rtl8192_DisableInterrupt, + .irq_clear = rtl8192_ClearInterrupt, + .rx_enable = rtl8192_enable_rx, + .tx_enable = rtl8192_enable_tx, .interrupt_recognized = rtl8192_interrupt_recognized, .TxCheckStuckHandler = rtl8192_HalTxCheckStuck, .RxCheckStuckHandler = rtl8192_HalRxCheckStuck, @@ -93,130 +93,110 @@ static struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); + const struct pci_device_id *id); static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); static struct pci_driver rtl8192_pci_driver = { - .name = DRV_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = rtl8192_pci_probe, /* probe fn */ - .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ - .suspend = rtl8192E_suspend, /* PM suspend fn */ - .resume = rtl8192E_resume, /* PM resume fn */ + .name = DRV_NAME, /* Driver name */ + .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ + .probe = rtl8192_pci_probe, /* probe fn */ + .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ + .suspend = rtl8192E_suspend, /* PM suspend fn */ + .resume = rtl8192E_resume, /* PM resume fn */ }; /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool -PlatformIOCheckPageLegalAndGetRegMask( - u32 u4bPage, - u8* pu1bPageMask -) +bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; + *pu1bPageMask = 0xfe; - switch (u4bPage) - { - case 1: case 2: case 3: case 4: - case 8: case 9: case 10: case 12: case 13: - bReturn = true; - *pu1bPageMask = 0xf0; - break; + switch (u4bPage) { + case 1: case 2: case 3: case 4: + case 8: case 9: case 10: case 12: case 13: + bReturn = true; + *pu1bPageMask = 0xf0; + break; - default: - bReturn = false; - break; + default: + bReturn = false; + break; } return bReturn; } -void write_nic_io_byte(struct net_device *dev, int x,u8 y) +void write_nic_io_byte(struct net_device *dev, int x, u8 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outb(y&0xff,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outb(y&0xff, dev->base_addr + x); + + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_byte(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - - } -void write_nic_io_word(struct net_device *dev, int x,u16 y) +void write_nic_io_word(struct net_device *dev, int x, u16 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outw(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outw(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_word(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } - } -void write_nic_io_dword(struct net_device *dev, int x,u32 y) +void write_nic_io_dword(struct net_device *dev, int x, u32 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outl(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outl(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_dword(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - } + u8 read_nic_io_byte(struct net_device *dev, int x) { u32 u4bPage = (x >> 8); @@ -224,23 +204,18 @@ u8 read_nic_io_byte(struct net_device *dev, int x) bool bIsLegalPage = false; u8 Data = 0; - if (u4bPage == 0) - { - return 0xff&inb(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return 0xff&inb(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_byte(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } @@ -254,23 +229,19 @@ u16 read_nic_io_word(struct net_device *dev, int x) bool bIsLegalPage = false; u16 Data = 0; - if (u4bPage == 0) - { - return inw(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inw(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_word(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -284,23 +255,19 @@ u32 read_nic_io_dword(struct net_device *dev, int x) bool bIsLegalPage = false; u32 Data = 0; - if (u4bPage == 0) - { - return inl(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inl(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_dword(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -309,36 +276,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff&readb((u8*)dev->mem_start +x); + return 0xff & readb((u8 *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8*)dev->mem_start +x); + return readl((u8 *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8*)dev->mem_start +x); + return readw((u8 *)dev->mem_start + x); } -void write_nic_byte(struct net_device *dev, int x,u8 y) +void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y,(u8*)dev->mem_start +x); + writeb(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_dword(struct net_device *dev, int x,u32 y) +void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y,(u8*)dev->mem_start +x); + writel(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_word(struct net_device *dev, int x,u16 y) +void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y,(u8*)dev->mem_start +x); + writew(y, (u8 *)dev->mem_start + x); udelay(20); } @@ -346,106 +313,101 @@ void write_nic_word(struct net_device *dev, int x,u16 y) /**************************************************************************** -----------------------------GENERAL FUNCTION------------------------- *****************************************************************************/ -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ) +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device * ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; bool bActionAllowed = false; bool bConnectBySSID = false; enum rt_rf_power_state rtState; u16 RFWaitCounter = 0; unsigned long flag; - RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); + RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): " + "StateToSet(%d)\n", StateToSet); ProtectOrNot = false; - if (!ProtectOrNot) - { - while(true) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet); + if (!ProtectOrNot) { + while (true) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): RF Change in " + "progress! Wait to set..StateToSet" + "(%d).\n", StateToSet); - while(priv->RFChangeInProgress) - { - RFWaitCounter ++; - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Wait 1 ms (%d times)...\n", RFWaitCounter); - mdelay(1); + while (priv->RFChangeInProgress) { + RFWaitCounter++; + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): Wait 1" + " ms (%d times)...\n", + RFWaitCounter); + mdelay(1); - if (RFWaitCounter > 100) - { - RT_TRACE(COMP_ERR, "MgntActSet_RF_State(): Wait too logn to set RF\n"); - return false; + if (RFWaitCounter > 100) { + RT_TRACE(COMP_ERR, "MgntActSet_" + "RF_State(): Wait too " + "logn to set RF\n"); + return false; + } } + } else { + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + break; } } - else - { - priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - break; - } - } } rtState = priv->rtllib->eRFPowerState; - switch (StateToSet) - { + switch (StateToSet) { case eRfOn: - priv->rtllib->RfOffReason &= (~ChangeSource); - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == true)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == true)) priv->bHwRadioOff = false; - } - if (! priv->rtllib->RfOffReason) - { + if (!priv->rtllib->RfOffReason) { priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >=RF_CHANGE_BY_HW ) - { + if (rtState == eRfOff && + ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; - } - } - else{ - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", priv->rtllib->RfOffReason, ChangeSource); - } + } else { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - " + "eRfon reject pMgntInfo->RfOffReason= 0x%x," + " ChangeSource=0x%X\n", + priv->rtllib->RfOffReason, ChangeSource); + } break; case eRfOff: - if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || (priv->rtllib->iw_mode == IW_MODE_ADHOC)) - { - if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || (ChangeSource > RF_CHANGE_BY_IPS)) - { + if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || + (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { + if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || + (ChangeSource > RF_CHANGE_BY_IPS)) { if (ieee->state == RTLLIB_LINKED) priv->blinked_ingpio = true; else priv->blinked_ingpio = false; - rtllib_MgntDisconnect(priv->rtllib,disas_lv_ss); - - - + rtllib_MgntDisconnect(priv->rtllib, + disas_lv_ss); } } - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == false)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == false)) priv->bHwRadioOff = true; - } priv->rtllib->RfOffReason |= ChangeSource; bActionAllowed = true; break; @@ -459,29 +421,30 @@ MgntActSet_RF_State( break; } - if (bActionAllowed) - { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->rtllib->RfOffReason); + if (bActionAllowed) { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is" + " allowed.... StateToSet(%d), RfOffReason(%#X)\n", + StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); - if (StateToSet == eRfOn) - { + if (StateToSet == eRfOn) { - if (bConnectBySSID && (priv->blinked_ingpio == true)) - { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + if (bConnectBySSID && (priv->blinked_ingpio == true)) { + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); priv->blinked_ingpio = false; - } } } else { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->rtllib->RfOffReason); + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): " + "Action is rejected.... StateToSet(%d), ChangeSource" + "(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, + priv->rtllib->RfOffReason); } - if (!ProtectOrNot) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + if (!ProtectOrNot) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); } RT_TRACE((COMP_PS && COMP_RF), "<===MgntActSet_RF_State()\n"); @@ -491,36 +454,35 @@ MgntActSet_RF_State( short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - /* For now, we reserved two free descriptor as a safety boundary - * between the tail and the head - */ - if ((prio == MGNT_QUEUE) &&(skb_queue_len(&ring->queue)>10)) - RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d queue_len=%d---------\n", - prio,ring->idx, skb_queue_len(&ring->queue)); - return skb_queue_len(&ring->queue); + /* For now, we reserved two free descriptor as a safety boundary + * between the tail and the head + */ + if ((prio == MGNT_QUEUE) && (skb_queue_len(&ring->queue) > 10)) + RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d " + "queue_len=%d---------\n", prio, ring->idx, + skb_queue_len(&ring->queue)); + return skb_queue_len(&ring->queue); } short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - if (ring->entries - skb_queue_len(&ring->queue) >= 2) { - return 1; - } else { - return 0; - } + if (ring->entries - skb_queue_len(&ring->queue) >= 2) + return 1; + return 0; } void rtl8192_tx_timeout(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - schedule_work(&priv->reset_wq); - printk("TXTIMEOUT"); + schedule_work(&priv->reset_wq); + printk(KERN_INFO "TXTIMEOUT"); } void rtl8192_irq_enable(struct net_device *dev) @@ -548,136 +510,137 @@ void rtl8192_irq_clear(struct net_device *dev) } -void rtl8192_set_chan(struct net_device *dev,short ch) +void rtl8192_set_chan(struct net_device *dev, short ch) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); - if (priv->chan_forced) - return; + RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); + if (priv->chan_forced) + return; - priv->chan = ch; + priv->chan = ch; - if (priv->rf_set_chan) - priv->rf_set_chan(dev,priv->chan); + if (priv->rf_set_chan) + priv->rf_set_chan(dev, priv->chan); } -void rtl8192_update_cap(struct net_device* dev, u16 cap) +void rtl8192_update_cap(struct net_device *dev, u16 cap) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; + bool ShortPreamble; - - { - bool ShortPreamble; - - if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) - { - ShortPreamble = true; - priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) { + if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) { + ShortPreamble = true; + priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } - else - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) - { - ShortPreamble = false; - priv->dot11CurrentPreambleMode = PREAMBLE_LONG; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + } else { + if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) { + ShortPreamble = false; + priv->dot11CurrentPreambleMode = PREAMBLE_LONG; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } } - if (net->mode & (IEEE_G|IEEE_N_24G)) - { + if (net->mode & (IEEE_G|IEEE_N_24G)) { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) - { - if (CurSlotTime != SHORT_SLOT_TIME) - { + if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && + (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { + if (CurSlotTime != SHORT_SLOT_TIME) { slot_time_val = SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } - } - else - { - if (CurSlotTime != NON_SHORT_SLOT_TIME) - { + } else { + if (CurSlotTime != NON_SHORT_SLOT_TIME) { slot_time_val = NON_SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } } } } static struct rtllib_qos_parameters def_qos_parameters = { - {3,3,3,3}, - {7,7,7,7}, - {2,2,2,2}, - {0,0,0,0}, - {0,0,0,0} + {3, 3, 3, 3}, + {7, 7, 7, 7}, + {2, 2, 2, 2}, + {0, 0, 0, 0}, + {0, 0, 0, 0} }; void rtl8192_update_beacon(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + update_beacon_wq.work); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_device *ieee = priv->rtllib; + struct rtllib_network *net = &ieee->current_network; if (ieee->pHTInfo->bCurrentHTSupport) HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = + net->bssht.bdRT2RTLongSlotTime; ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode; rtl8192_update_cap(dev, net->capability); } #define MOVE_INTO_HANDLER -int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; void rtl8192_qos_activate(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + qos_activate); struct net_device *dev = priv->rtllib->dev; #ifndef MOVE_INTO_HANDLER - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 mode = priv->rtllib->current_network.mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 mode = priv->rtllib->current_network.mode; u8 u1bAIFS; u32 u4bAcParam; #endif - int i; + int i; - if (priv == NULL) - return; + if (priv == NULL) + return; - mutex_lock(&priv->mutex); - if (priv->rtllib->state != RTLLIB_LINKED) + mutex_lock(&priv->mutex); + if (priv->rtllib->state != RTLLIB_LINKED) goto success; - RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); + RT_TRACE(COMP_QOS, "qos active process with associate response " + "received\n"); for (i = 0; i < QOS_QUEUE_NUM; i++) { #ifndef MOVE_INTO_HANDLER - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + u1bAIFS = qos_parameters->aifs[i] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[i])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[i])) << + AC_PARAM_ECW_MIN_OFFSET) | + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); RT_TRACE(COMP_DBG, "===>ACI:%d:u4bAcParam:%x\n", i, u4bAcParam); write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); #else - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&i)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); #endif } success: - mutex_unlock(&priv->mutex); + mutex_unlock(&priv->mutex); } static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, @@ -687,8 +650,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, int ret = 0; u32 size = sizeof(struct rtllib_qos_parameters); - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) return ret; @@ -701,21 +664,22 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, if ((network->qos_data.active == 1) && (active_network == 1) && (network->flags & NETWORK_HAS_QOS_PARAMETERS) && (network->qos_data.old_param_count != - network->qos_data.param_count)) { + network->qos_data.param_count)) { network->qos_data.old_param_count = network->qos_data.param_count; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE (COMP_QOS, "QoS parameters change call " + RT_TRACE(COMP_QOS, "QoS parameters change call " "qos_activate\n"); } } else { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ + memcpy(&priv->rtllib->current_network.qos_data.parameters, &def_qos_parameters, size); if ((network->qos_data.active == 1) && (active_network == 1)) { queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n"); + RT_TRACE(COMP_QOS, "QoS was disabled call qos_" + "activate\n"); } network->qos_data.active = 0; network->qos_data.supported = 0; @@ -724,13 +688,13 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, return 0; } -static int rtl8192_handle_beacon(struct net_device * dev, - struct rtllib_beacon * beacon, - struct rtllib_network * network) +static int rtl8192_handle_beacon(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network) { struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_handle_probe_response(priv,1,network); + rtl8192_qos_handle_probe_response(priv, 1, network); queue_delayed_work_rsl(priv->priv_wq, &priv->update_beacon_wq, 0); return 0; @@ -738,60 +702,60 @@ static int rtl8192_handle_beacon(struct net_device * dev, } static int rtl8192_qos_association_resp(struct r8192_priv *priv, - struct rtllib_network *network) + struct rtllib_network *network) { - int ret = 0; - unsigned long flags; - u32 size = sizeof(struct rtllib_qos_parameters); - int set_qos_param = 0; + int ret = 0; + unsigned long flags; + u32 size = sizeof(struct rtllib_qos_parameters); + int set_qos_param = 0; - if ((priv == NULL) || (network == NULL)) - return ret; + if ((priv == NULL) || (network == NULL)) + return ret; - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) - return ret; + return ret; - spin_lock_irqsave(&priv->rtllib->lock, flags); + spin_lock_irqsave(&priv->rtllib->lock, flags); if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ - &network->qos_data.parameters,\ - sizeof(struct rtllib_qos_parameters)); + memcpy(&priv->rtllib->current_network.qos_data.parameters, + &network->qos_data.parameters, + sizeof(struct rtllib_qos_parameters)); priv->rtllib->current_network.qos_data.active = 1; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; set_qos_param = 1; priv->rtllib->current_network.qos_data.old_param_count = - priv->rtllib->current_network.qos_data.param_count; + priv->rtllib->current_network.qos_data.param_count; priv->rtllib->current_network.qos_data.param_count = - network->qos_data.param_count; - } else { + network->qos_data.param_count; + } else { memcpy(&priv->rtllib->current_network.qos_data.parameters, - &def_qos_parameters, size); + &def_qos_parameters, size); priv->rtllib->current_network.qos_data.active = 0; priv->rtllib->current_network.qos_data.supported = 0; - set_qos_param = 1; - } + set_qos_param = 1; + } - spin_unlock_irqrestore(&priv->rtllib->lock, flags); + spin_unlock_irqrestore(&priv->rtllib->lock, flags); RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, - network->flags ,priv->rtllib->current_network.qos_data.active); + network->flags, priv->rtllib->current_network.qos_data.active); if (set_qos_param == 1) { dm_init_edca_turbo(priv->rtllib->dev); queue_work_rsl(priv->priv_wq, &priv->qos_activate); } - return ret; + return ret; } static int rtl8192_handle_assoc_response(struct net_device *dev, - struct rtllib_assoc_response_frame *resp, - struct rtllib_network *network) + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network) { - struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_association_resp(priv, network); - return 0; + struct r8192_priv *priv = rtllib_priv(dev); + rtl8192_qos_association_resp(priv, network); + return 0; } void rtl8192_prepare_beacon(struct r8192_priv *priv) @@ -831,104 +795,107 @@ void rtl8192_stop_beacon(struct net_device *dev) { } -void rtl8192_config_rate(struct net_device* dev, u16* rate_config) +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_network *net; - u8 i=0, basic_rate = 0; - net = & priv->rtllib->current_network; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net; + u8 i = 0, basic_rate = 0; + net = &priv->rtllib->current_network; - for (i = 0; i < net->rates_len; i++) { - basic_rate = net->rates[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_len; i++) { + basic_rate = net->rates[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } - for (i = 0; i < net->rates_ex_len; i++) { - basic_rate = net->rates_ex[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_ex_len; i++) { + basic_rate = net->rates_ex[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } } -void rtl8192_refresh_supportrate(struct r8192_priv * priv) +void rtl8192_refresh_supportrate(struct r8192_priv *priv) { - struct rtllib_device* ieee = priv->rtllib; - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) { - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); - memcpy(ieee->Regdot11TxHTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + struct rtllib_device *ieee = priv->rtllib; + if (ieee->mode == WIRELESS_MODE_N_24G || + ieee->mode == WIRELESS_MODE_N_5G) { + memcpy(ieee->Regdot11HTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); + memcpy(ieee->Regdot11TxHTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); } else { memset(ieee->Regdot11HTOperationalRateSet, 0, 16); @@ -936,7 +903,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv * priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) +u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -958,12 +925,13 @@ u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) return ret; } -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) { struct r8192_priv *priv = rtllib_priv(dev); u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev); - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) { + if ((wireless_mode == WIRELESS_MODE_AUTO) || + ((wireless_mode & bSupportMode) == 0)) { if (bSupportMode & WIRELESS_MODE_N_24G) { wireless_mode = WIRELESS_MODE_N_24G; } else if (bSupportMode & WIRELESS_MODE_N_5G) { @@ -975,49 +943,55 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) } else if ((bSupportMode & WIRELESS_MODE_B)) { wireless_mode = WIRELESS_MODE_B; } else { - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported (%x)!!!\n", - __func__, bSupportMode); + RT_TRACE(COMP_ERR, "%s(), No valid wireless mode " + "supported (%x)!!!\n", __func__, bSupportMode); wireless_mode = WIRELESS_MODE_B; } } - if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == (WIRELESS_MODE_G | WIRELESS_MODE_B)) + if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == + (WIRELESS_MODE_G | WIRELESS_MODE_B)) wireless_mode = WIRELESS_MODE_G; priv->rtllib->mode = wireless_mode; - ActUpdateChannelAccessSetting( dev, wireless_mode, &priv->ChannelAccessSetting); + ActUpdateChannelAccessSetting(dev, wireless_mode, + &priv->ChannelAccessSetting); - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)){ + if ((wireless_mode == WIRELESS_MODE_N_24G) || + (wireless_mode == WIRELESS_MODE_N_5G)) { priv->rtllib->pHTInfo->bEnableHT = 1; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", __func__,wireless_mode); - }else{ + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", + __func__, wireless_mode); + } else { priv->rtllib->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", __func__,wireless_mode); - } + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", + __func__, wireless_mode); + } RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool init_status = true; priv->bDriverIsGoingToUnload = false; priv->bdisable_nic = false; - priv->up=1; - priv->rtllib->ieee_up=1; + priv->up = 1; + priv->rtllib->ieee_up = 1; priv->up_first_time = 0; RT_TRACE(COMP_INIT, "Bringing up iface"); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); - if (init_status != true) - { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + if (init_status != true) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bfirst_init = false; return -1; } @@ -1026,16 +1000,14 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } if (priv->rtllib->state != RTLLIB_LINKED) - rtllib_softmac_start_protocol(priv->rtllib, 0); + rtllib_softmac_start_protocol(priv->rtllib, 0); rtllib_reset_queue(priv->rtllib); watch_dog_timer_callback((unsigned long) dev); - if (!netif_queue_stopped(dev)) netif_start_queue(dev); else @@ -1050,7 +1022,8 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) unsigned long flags = 0; u8 RFInProgressTimeOut = 0; - if (priv->up == 0) return -1; + if (priv->up == 0) + return -1; if (priv->rtllib->rtllib_ips_leave != NULL) priv->rtllib->rtllib_ips_leave(dev); @@ -1059,7 +1032,7 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) LeisurePSLeave(dev); priv->bDriverIsGoingToUnload = true; - priv->up=0; + priv->up = 0; priv->rtllib->ieee_up = 0; priv->bfirst_after_down = 1; RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__); @@ -1067,11 +1040,10 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) netif_stop_queue(dev); priv->rtllib->wpa_ie_len = 0; - if (priv->rtllib->wpa_ie) - kfree(priv->rtllib->wpa_ie); + kfree(priv->rtllib->wpa_ie); priv->rtllib->wpa_ie = NULL; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtl8192_irq_disable(dev); del_timer_sync(&priv->watch_dog_timer); @@ -1079,40 +1051,40 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) cancel_delayed_work(&priv->rtllib->hw_wakeup_wq); rtllib_softmac_stop_protocol(priv->rtllib, 0, true); - spin_lock_irqsave(&priv->rf_ps_lock,flags); - while(priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - if (RFInProgressTimeOut > 100) - { - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); + while (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + if (RFInProgressTimeOut > 100) { + spin_lock_irqsave(&priv->rf_ps_lock, flags); break; } - RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait until rf chang is done.\n",__func__); + RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait " + "until rf chang is done.\n", __func__); mdelay(1); - RFInProgressTimeOut ++; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + RFInProgressTimeOut++; + spin_lock_irqsave(&priv->rf_ps_lock, flags); } priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); priv->ops->stop_adapter(dev, false); - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); udelay(100); - memset(&priv->rtllib->current_network, 0 , offsetof(struct rtllib_network, list)); + memset(&priv->rtllib->current_network, 0, + offsetof(struct rtllib_network, list)); RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; } -static void rtl8192_init_priv_handler(struct net_device* dev) +static void rtl8192_init_priv_handler(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->rtllib->softmac_hard_start_xmit = rtl8192_hard_start_xmit; - priv->rtllib->set_chan = rtl8192_set_chan; - priv->rtllib->link_change = priv->ops->link_change; + priv->rtllib->set_chan = rtl8192_set_chan; + priv->rtllib->link_change = priv->ops->link_change; priv->rtllib->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; priv->rtllib->data_hard_stop = rtl8192_data_hard_stop; priv->rtllib->data_hard_resume = rtl8192_data_hard_resume; @@ -1133,7 +1105,8 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->ps_is_queue_empty = rtl8192_is_tx_queue_empty; priv->rtllib->GetNmodeSupportBySecCfg = rtl8192_GetNmodeSupportBySecCfg; - priv->rtllib->GetHalfNmodeSupportByAPsHandler = rtl8192_GetHalfNmodeSupportByAPs; + priv->rtllib->GetHalfNmodeSupportByAPsHandler = + rtl8192_GetHalfNmodeSupportByAPs; priv->rtllib->SetHwRegHandler = rtl8192e_SetHwReg; priv->rtllib->AllowAllDestAddrHandler = rtl8192_AllowAllDestAddr; @@ -1150,10 +1123,11 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->rtllib_rfkill_poll = NULL; } -static void rtl8192_init_priv_constant(struct net_device* dev) +static void rtl8192_init_priv_constant(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); pPSC->RegMaxLPSAwakeIntvl = 5; @@ -1169,7 +1143,7 @@ static void rtl8192_init_priv_constant(struct net_device* dev) } -static void rtl8192_init_priv_variable(struct net_device* dev) +static void rtl8192_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 i; @@ -1193,7 +1167,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->txringcount = 64; priv->rxbuffersize = 9100; priv->rxringcount = MAX_RX_COUNT; - priv->irq_enabled=0; + priv->irq_enabled = 0; priv->chan = 1; priv->RegWirelessMode = WIRELESS_MODE_AUTO; priv->RegChannelPlan = 0xf; @@ -1205,14 +1179,15 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->bNetPromiscuousMode = false; priv->rtllib->IntelPromiscuousModeInfo.bPromiscuousOn = false; - priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = false; - priv->rtllib->ieee_up=0; + priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = + false; + priv->rtllib->ieee_up = 0; priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->rtllib->rts = DEFAULT_RTS_THRESHOLD; priv->rtllib->rate = 110; priv->rtllib->short_slot = 1; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; + priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->bcck_in_ch14 = false; priv->bfsync_processing = false; priv->CCKPresentAttentuation = 0; @@ -1224,11 +1199,11 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->bForcedSilentReset = 0; priv->bDisableNormalResetCheck = false; priv->force_reset = false; - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); - memset(&priv->InterruptLog,0,sizeof(struct log_int_8190)); + memset(&priv->InterruptLog, 0, sizeof(struct log_int_8190)); priv->RxCounter = 0; - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; priv->bHwRadioOff = false; priv->RegRfOff = 0; priv->isRFOff = false; @@ -1246,7 +1221,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->eRFPowerState = eRfOn; priv->txpower_checkcnt = 0; - priv->thermal_readback_index =0; + priv->thermal_readback_index = 0; priv->txpower_tracking_callback_cnt = 0; priv->ccktxpower_adjustcnt_ch14 = 0; priv->ccktxpower_adjustcnt_not_ch14 = 0; @@ -1255,7 +1230,8 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->active_scan = 1; priv->rtllib->be_scan_inprogress = false; - priv->rtllib->modulation = RTLLIB_CCK_MODULATION | RTLLIB_OFDM_MODULATION; + priv->rtllib->modulation = RTLLIB_CCK_MODULATION | + RTLLIB_OFDM_MODULATION; priv->rtllib->host_encrypt = 1; priv->rtllib->host_decrypt = 1; @@ -1267,23 +1243,20 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = (struct rt_firmware *)vmalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); - skb_queue_head_init(&priv->rx_queue); + skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_aggQ [i]); - } - + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_aggQ[i]); } -static void rtl8192_init_priv_lock(struct r8192_priv * priv) +static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->fw_scan_lock); spin_lock_init(&priv->tx_lock); @@ -1293,57 +1266,64 @@ static void rtl8192_init_priv_lock(struct r8192_priv * priv) spin_lock_init(&priv->ps_lock); spin_lock_init(&priv->rf_lock); spin_lock_init(&priv->rt_h2c_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_sem,1); + sema_init(&priv->wx_sem, 1); + sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } -static void rtl8192_init_priv_task(struct net_device* dev) +static void rtl8192_init_priv_task(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->priv_wq = create_workqueue(DRV_NAME); - INIT_WORK_RSL(&priv->reset_wq, (void*)rtl8192_restart, dev); - INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void*)IPSLeave_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev); - INIT_WORK_RSL(&priv->qos_activate, (void*)rtl8192_qos_activate, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev); + INIT_WORK_RSL(&priv->reset_wq, (void *)rtl8192_restart, dev); + INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void *)IPSLeave_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, + (void *)rtl819x_watchdog_wqcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, + (void *)dm_txpower_trackingcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, + (void *)dm_rf_pathcheck_workitemcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, + (void *)rtl8192_update_beacon, dev); + INIT_WORK_RSL(&priv->qos_activate, (void *)rtl8192_qos_activate, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq, + (void *) rtl8192_hw_wakeup_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq, + (void *) rtl8192_hw_sleep_wq, dev); tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8192_irq_rx_tasklet, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_rx_tasklet, + (unsigned long)priv); tasklet_init(&priv->irq_tx_tasklet, - (void(*)(unsigned long))rtl8192_irq_tx_tasklet, - (unsigned long)priv); - tasklet_init(&priv->irq_prepare_beacon_tasklet, - (void(*)(unsigned long))rtl8192_prepare_beacon, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_tx_tasklet, + (unsigned long)priv); + tasklet_init(&priv->irq_prepare_beacon_tasklet, + (void(*)(unsigned long))rtl8192_prepare_beacon, + (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device * dev) +short rtl8192_get_channel_map(struct net_device *dev) { int i; struct r8192_priv *priv = rtllib_priv(dev); if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && (priv->rf_chip != RF_6052)) { - RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel map\n", __func__); + RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel " + "map\n", __func__); return -1; } if (priv->ChannelPlan > COUNTRY_CODE_MAX) { - printk("rtl819x_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan= COUNTRY_CODE_FCC; + printk(KERN_INFO "rtl819x_init:Error channel plan! Set to " + "default.\n"); + priv->ChannelPlan = COUNTRY_CODE_FCC; } - RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); + RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan); Dot11d_Init(priv->rtllib); Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); - for (i = 1; i <= 11; i++) { + for (i = 1; i <= 11; i++) (priv->rtllib->active_channel_map)[i] = 1; - } (priv->rtllib->active_channel_map)[12] = 2; (priv->rtllib->active_channel_map)[13] = 2; @@ -1354,10 +1334,9 @@ short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - memset(&(priv->stats),0,sizeof(struct rt_stats)); + memset(&(priv->stats), 0, sizeof(struct rt_stats)); rtl8192_dbgp_flag_init(dev); - rtl8192_init_priv_handler(dev); rtl8192_init_priv_constant(dev); rtl8192_init_priv_variable(dev); @@ -1380,17 +1359,17 @@ short rtl8192_init(struct net_device *dev) (unsigned long)dev); rtl8192_irq_disable(dev); - if (request_irq(dev->irq, (void*)rtl8192_interrupt_rsl, IRQF_SHARED, dev->name, dev)) - { - printk("Error allocating IRQ %d",dev->irq); + if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, IRQF_SHARED, + dev->name, dev)) { + printk(KERN_ERR "Error allocating IRQ %d", dev->irq); return -1; } else { - priv->irq=dev->irq; - RT_TRACE(COMP_INIT, "IRQ %d\n",dev->irq); + priv->irq = dev->irq; + RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq); } if (rtl8192_pci_initdescring(dev) != 0) { - printk("Endopoints initialization failed"); + printk(KERN_ERR "Endopoints initialization failed"); return -1; } @@ -1398,51 +1377,48 @@ short rtl8192_init(struct net_device *dev) } /*************************************************************************** - -------------------------------WATCHDOG STUFF--------------------------- + -------------------------------WATCHDOG STUFF--------------------------- ***************************************************************************/ short rtl8192_is_tx_queue_empty(struct net_device *dev) { - int i=0; + int i = 0; struct r8192_priv *priv = rtllib_priv(dev); - for (i=0; i<=MGNT_QUEUE; i++) - { - if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) + for (i = 0; i <= MGNT_QUEUE; i++) { + if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE)) continue; - if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ - printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); + if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0) { + printk(KERN_INFO "===>tx queue is not empty:%d, %d\n", + i, skb_queue_len(&(&priv->tx_ring[i])->queue)); return 0; } } return 1; } -enum reset_type -rtl819x_TxCheckStuck(struct net_device *dev) +enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 QueueID; - u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - bool bCheckFwTxCnt = false; + u8 QueueID; + u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + bool bCheckFwTxCnt = false; struct rtl8192_tx_ring *ring = NULL; - struct sk_buff* skb = NULL; - struct cb_desc * tcb_desc = NULL; + struct sk_buff *skb = NULL; + struct cb_desc *tcb_desc = NULL; unsigned long flags = 0; - switch (priv->rtllib->ps) - { - case RTLLIB_PS_DISABLED: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; - break; - case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; - default: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; + switch (priv->rtllib->ps) { + case RTLLIB_PS_DISABLED: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; + break; + case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; + default: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) - { + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) { if (QueueID == TXCMD_QUEUE) continue; @@ -1451,24 +1427,26 @@ rtl819x_TxCheckStuck(struct net_device *dev) ring = &priv->tx_ring[QueueID]; - if (skb_queue_len(&ring->queue) == 0) + if (skb_queue_len(&ring->queue) == 0) { continue; - else - { + } else { skb = (&ring->queue)->next; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); tcb_desc->nStuckCount++; bCheckFwTxCnt = true; if (tcb_desc->nStuckCount > 1) - printk("%s: QueueID=%d tcb_desc->nStuckCount=%d\n",__func__,QueueID,tcb_desc->nStuckCount); + printk(KERN_INFO "%s: QueueID=%d tcb_desc->n" + "StuckCount=%d\n", __func__, QueueID, + tcb_desc->nStuckCount); } } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); if (bCheckFwTxCnt) { - if (priv->ops->TxCheckStuckHandler(dev)) - { - RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n"); + if (priv->ops->TxCheckStuckHandler(dev)) { + RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no" + " Tx condition!\n"); return RESET_TYPE_SILENT; } } @@ -1480,8 +1458,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->ops->RxCheckStuckHandler(dev)) - { + if (priv->ops->RxCheckStuckHandler(dev)) { RT_TRACE(COMP_RESET, "RxStuck Condition\n"); return RESET_TYPE_SILENT; } @@ -1502,18 +1479,20 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) if (rfState == eRfOn) TxResetType = rtl819x_TxCheckStuck(dev); - if ( rfState == eRfOn && + if (rfState == eRfOn && (priv->rtllib->iw_mode == IW_MODE_INFRA) && - (priv->rtllib->state == RTLLIB_LINKED)) { - + (priv->rtllib->state == RTLLIB_LINKED)) RxResetType = rtl819x_RxCheckStuck(dev); - } - if (TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + if (TxResetType == RESET_TYPE_NORMAL || + RxResetType == RESET_TYPE_NORMAL) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_NORMAL; - } else if (TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + } else if (TxResetType == RESET_TYPE_SILENT || + RxResetType == RESET_TYPE_SILENT) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_SILENT; } else { return RESET_TYPE_NORESET; @@ -1536,21 +1515,20 @@ void rtl819x_ifsilentreset(struct net_device *dev) u8 IsPortal = 0; - if (priv->ResetProgress==RESET_TYPE_NORESET) { + if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_RESET,"=========>Reset progress!! \n"); + RT_TRACE(COMP_RESET, "=========>Reset progress!!\n"); priv->ResetProgress = RESET_TYPE_SILENT; - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); goto END; } priv->RFChangeInProgress = true; priv->bResetInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); RESET_START: @@ -1560,15 +1538,18 @@ RESET_START: LeisurePSLeave(dev); if (IS_NIC_DOWN(priv)) { - RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__func__); + RT_TRACE(COMP_ERR, "%s():the driver is not up! " + "return\n", __func__); up(&priv->wx_sem); return ; } priv->up = 0; - RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", + __func__); mdelay(1000); - RT_TRACE(COMP_RESET,"%s():111111111111111111111111======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():111111111111111111111111======>start" + " to down the driver\n", __func__); if (!netif_queue_stopped(dev)) netif_stop_queue(dev); @@ -1581,7 +1562,7 @@ RESET_START: if (ieee->state == RTLLIB_LINKED) { SEM_DOWN_IEEE_WX(&ieee->wx_sem); - printk("ieee->state is RTLLIB_LINKED\n"); + printk(KERN_INFO "ieee->state is RTLLIB_LINKED\n"); rtllib_stop_send_beacons(priv->rtllib); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); @@ -1589,43 +1570,51 @@ RESET_START: netif_carrier_off(dev); SEM_UP_IEEE_WX(&ieee->wx_sem); } else { - printk("ieee->state is NOT LINKED\n"); - rtllib_softmac_stop_protocol(priv->rtllib, 0 ,true); + printk(KERN_INFO "ieee->state is NOT LINKED\n"); + rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); } dm_backup_dynamic_mechanism_state(dev); up(&priv->wx_sem); - RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<==========down process is " + "finished\n", __func__); - RT_TRACE(COMP_RESET,"%s():<===========up process start\n",__func__); - reset_status = _rtl8192_up(dev,true); + RT_TRACE(COMP_RESET, "%s():<===========up process start\n", + __func__); + reset_status = _rtl8192_up(dev, true); - RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<===========up process is " + "finished\n", __func__); if (reset_status == -1) { if (reset_times < 3) { reset_times++; goto RESET_START; } else { - RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n",__func__); + RT_TRACE(COMP_ERR, " ERR!!! %s(): Reset " + "Failed!!\n", __func__); } } ieee->is_silent_reset = 1; - spin_lock_irqsave(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); EnableHWSecurityConfig8192(dev); - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_INFRA) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); - } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_ADHOC) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); ieee->link_change(ieee->dev); notify_wx_assoc_event(ieee); @@ -1645,27 +1634,30 @@ END: priv->ResetProgress = RESET_TYPE_NORESET; priv->reset_count++; - priv->bForcedSilentReset =false; + priv->bForcedSilentReset = false; priv->bResetInProgress = false; write_nic_byte(dev, UFWP, 1); - RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); + RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", + priv->reset_count); } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, - u32 *TotalRxBcnNum, +void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, u32 *TotalRxDataNum) { - u16 SlotIndex; - u8 i; + u16 SlotIndex; + u8 i; *TotalRxBcnNum = 0; *TotalRxDataNum = 0; - SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++)%(priv->rtllib->LinkDetectInfo.SlotNum); - priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; - priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; + SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++) % + (priv->rtllib->LinkDetectInfo.SlotNum); + priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; + priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; for (i = 0; i < priv->rtllib->LinkDetectInfo.SlotNum; i++) { *TotalRxBcnNum += priv->rtllib->LinkDetectInfo.RxBcnNum[i]; *TotalRxDataNum += priv->rtllib->LinkDetectInfo.RxDataNum[i]; @@ -1675,13 +1667,15 @@ void rtl819x_update_rxcounts(struct r8192_priv *priv, void rtl819x_watchdog_wqcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, watch_dog_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum reset_type ResetType = RESET_TYPE_NORESET; - static u8 check_reset_cnt = 0; + static u8 check_reset_cnt; unsigned long flags; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bBusyTraffic = false; bool bHigherBusyTraffic = false; bool bHigherBusyRxTraffic = false; @@ -1691,7 +1685,7 @@ void rtl819x_watchdog_wqcallback(void *data) return; if (priv->rtllib->state >= RTLLIB_LINKED) { - if (priv->rtllib->CntAfterLink<2) + if (priv->rtllib->CntAfterLink < 2) priv->rtllib->CntAfterLink++; } else { priv->rtllib->CntAfterLink = 0; @@ -1699,130 +1693,125 @@ void rtl819x_watchdog_wqcallback(void *data) hal_dm_watchdog(dev); - if (rtllib_act_scanning(priv->rtllib,false) == false){ - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) &&\ - (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\ - (!ieee->proto_stoppping) && !ieee->wx_set_enc - ){ - if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE)&& - (!ieee->bNetPromiscuousMode)) - { - RT_TRACE(COMP_PS, "====================>haha:IPSEnter()\n"); + if (rtllib_act_scanning(priv->rtllib, false) == false) { + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == + RTLLIB_NOLINK) && + (ieee->eRFPowerState == eRfOn) && !ieee->is_set_key && + (!ieee->proto_stoppping) && !ieee->wx_set_enc) { + if ((ieee->PowerSaveControl.ReturnPoint == + IPS_CALLBACK_NONE) && + (!ieee->bNetPromiscuousMode)) { + RT_TRACE(COMP_PS, "====================>haha: " + "IPSEnter()\n"); IPSEnter(dev); } } } - { - if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) - { - if ( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { - bBusyTraffic = true; - } + if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == + IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) { + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 100 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 100) + bBusyTraffic = true; - if ( ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || - ieee->LinkDetectInfo.NumTxOkInPeriod > 4000 ) - { - bHigherBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) - bHigherBusyRxTraffic = true; - else - bHigherBusyRxTraffic = false; - } - - if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) - bEnterPS= false; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) + bHigherBusyRxTraffic = true; else - bEnterPS= true; + bHigherBusyRxTraffic = false; + } - if (ieee->current_network.beacon_interval < 95) - bEnterPS= false; + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS = false; + else + bEnterPS = true; - if (bEnterPS) - LeisurePSEnter(dev); - else - LeisurePSLeave(dev); + if (ieee->current_network.beacon_interval < 95) + bEnterPS = false; - } else { - RT_TRACE(COMP_LPS,"====>no link LPS leave\n"); + if (bEnterPS) + LeisurePSEnter(dev); + else LeisurePSLeave(dev); + + } else { + RT_TRACE(COMP_LPS, "====>no link LPS leave\n"); + LeisurePSLeave(dev); + } + + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + + ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; + + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + + if ((TotalRxBcnNum+TotalRxDataNum) == 0) + priv->check_roaming_cnt++; + else + priv->check_roaming_cnt = 0; + + + if (priv->check_roaming_cnt > 0) { + if (ieee->eRFPowerState == eRfOff) + RT_TRACE(COMP_ERR, "========>%s()\n", __func__); + + printk(KERN_INFO "===>%s(): AP is power off, chan:%d," + " connect another one\n", __func__, priv->chan); + + ieee->state = RTLLIB_ASSOCIATING; + + RemovePeerTS(priv->rtllib, + priv->rtllib->current_network.bssid); + ieee->is_roaming = true; + ieee->is_set_key = false; + ieee->link_change(dev); + if (ieee->LedControlHandler) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + + notify_wx_assoc_event(ieee); + + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + + priv->check_roaming_cnt = 0; } - - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - - ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; - ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; } - { - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - - if ((TotalRxBcnNum+TotalRxDataNum) == 0) - priv->check_roaming_cnt ++; - else - priv->check_roaming_cnt = 0; - - - if (priv->check_roaming_cnt > 0) - { - if ( ieee->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__func__); - - printk("===>%s(): AP is power off,chan:%d, connect another one\n",__func__, priv->chan); - - ieee->state = RTLLIB_ASSOCIATING; - - RemovePeerTS(priv->rtllib,priv->rtllib->current_network.bssid); - ieee->is_roaming = true; - ieee->is_set_key = false; - ieee->link_change(dev); - if (ieee->LedControlHandler) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - - notify_wx_assoc_event(ieee); - - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - - priv->check_roaming_cnt = 0; - } - } - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - } - - spin_lock_irqsave(&priv->tx_lock,flags); + spin_lock_irqsave(&priv->tx_lock, flags); if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) && - (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) - { + (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) { ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; } - spin_unlock_irqrestore(&priv->tx_lock,flags); + spin_unlock_irqrestore(&priv->tx_lock, flags); - if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) - { + if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) { priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__func__); + RT_TRACE(COMP_RESET, "%s(): NOMAL RESET\n", __func__); return; } - if ( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) - { + if (((priv->force_reset) || (!priv->bDisableNormalResetCheck && + ResetType == RESET_TYPE_SILENT))) rtl819x_ifsilentreset(dev); - } priv->force_reset = false; priv->bForcedSilentReset = false; priv->bResetInProgress = false; @@ -1831,9 +1820,10 @@ void rtl819x_watchdog_wqcallback(void *data) void watch_dog_timer_callback(unsigned long data) { - struct r8192_priv *priv = rtllib_priv((struct net_device *) data); - queue_delayed_work_rsl(priv->priv_wq,&priv->watch_dog_wq,0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); + queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0); + mod_timer(&priv->watch_dog_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /**************************************************************************** @@ -1841,61 +1831,65 @@ void watch_dog_timer_callback(unsigned long data) *****************************************************************************/ void rtl8192_rx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->rx_enable(dev); } void rtl8192_tx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->tx_enable(dev); - rtllib_reset_queue(priv->rtllib); + rtllib_reset_queue(priv->rtllib); } static void rtl8192_free_rx_ring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ - for (i = 0; i < priv->rxringcount; i++) { + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; + rx_queue_idx++) { + for (i = 0; i < priv->rxringcount; i++) { struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i]; - if (!skb) - continue; + if (!skb) + continue; - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - kfree_skb(skb); - } + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } - pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, - priv->rx_ring[rx_queue_idx], priv->rx_ring_dma[rx_queue_idx]); + pci_free_consistent(priv->pdev, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + priv->rx_ring[rx_queue_idx], + priv->rx_ring_dma[rx_queue_idx]); priv->rx_ring[rx_queue_idx] = NULL; } } static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } - pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; + pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; } void rtl8192_data_hard_stop(struct net_device *dev) @@ -1907,14 +1901,17 @@ void rtl8192_data_hard_resume(struct net_device *dev) { } -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || + priv->bResetInProgress) { kfree_skb(skb); return; } @@ -1922,15 +1919,16 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat assert(queue_index != TXCMD_QUEUE); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); ret = rtl8192_tx(dev, skb); if (ret != 0) { kfree_skb(skb); }; - if (queue_index!=MGNT_QUEUE) { - priv->rtllib->stats.tx_bytes+=(skb->len - priv->rtllib->tx_headroom); + if (queue_index != MGNT_QUEUE) { + priv->rtllib->stats.tx_bytes += (skb->len - + priv->rtllib->tx_headroom); priv->rtllib->stats.tx_packets++; } @@ -1938,21 +1936,23 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat return; } -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if (queue_index != TXCMD_QUEUE){ - if ((priv->rtllib->eRFPowerState == eRfOff) ||IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if (queue_index != TXCMD_QUEUE) { + if ((priv->rtllib->eRFPowerState == eRfOff) || + IS_NIC_DOWN(priv) || priv->bResetInProgress) { kfree_skb(skb); return 0; } } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); if (queue_index == TXCMD_QUEUE) { rtl8192_tx_cmd(dev, skb); ret = 0; @@ -1977,81 +1977,82 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) void rtl8192_tx_isr(struct net_device *dev, int prio) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb; + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb; - if (prio != BEACON_QUEUE) { - if (entry->OWN) - return; - ring->idx = (ring->idx + 1) % ring->entries; - } + if (prio != BEACON_QUEUE) { + if (entry->OWN) + return; + ring->idx = (ring->idx + 1) % ring->entries; + } - skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - - kfree_skb(skb); - } - if (prio != BEACON_QUEUE) { - tasklet_schedule(&priv->irq_tx_tasklet); - } + skb = __skb_dequeue(&ring->queue); + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + } + if (prio != BEACON_QUEUE) + tasklet_schedule(&priv->irq_tx_tasklet); } void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring; - struct tx_desc_cmd * entry; - unsigned int idx; - struct cb_desc *tcb_desc; - unsigned long flags; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring; + struct tx_desc_cmd *entry; + unsigned int idx; + struct cb_desc *tcb_desc; + unsigned long flags; - spin_lock_irqsave(&priv->irq_th_lock,flags); - ring = &priv->tx_ring[TXCMD_QUEUE]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + ring = &priv->tx_ring[TXCMD_QUEUE]; - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = (struct tx_desc_cmd *) &ring->desc[idx]; + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + entry = (struct tx_desc_cmd *) &ring->desc[idx]; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); + priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + __skb_queue_tail(&ring->queue, skb); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); - return; + return; } -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring; unsigned long flags; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct tx_desc *pdesc = NULL; - struct rtllib_hdr_1addr * header = NULL; - u16 fc=0, type=0,stype=0; - bool multi_addr=false,broad_addr=false,uni_addr=false; - u8* pda_addr = NULL; + struct rtllib_hdr_1addr *header = NULL; + u16 fc = 0, type = 0, stype = 0; + bool multi_addr = false, broad_addr = false, uni_addr = false; + u8 *pda_addr = NULL; int idx; u32 fwinfo_size = 0; - if (priv->bdisable_nic){ - RT_TRACE(COMP_ERR,"%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", __func__, skb->len, tcb_desc->queue_index); - return skb->len; + if (priv->bdisable_nic) { + RT_TRACE(COMP_ERR, "%s: ERR!! Nic is disabled! Can't tx packet" + " len=%d qidx=%d!!!\n", __func__, skb->len, + tcb_desc->queue_index); + return skb->len; } priv->rtllib->bAwakePktSent = true; fwinfo_size = sizeof(struct tx_fwinfo_8190pci); - header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); + header = (struct rtllib_hdr_1addr *)(((u8 *)skb->data) + fwinfo_size); fc = header->frame_ctl; type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); @@ -2061,9 +2062,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) multi_addr = true; else if (is_broadcast_ether_addr(pda_addr)) broad_addr = true; - else { + else uni_addr = true; - } if (uni_addr) priv->stats.txbytesunicast += skb->len - fwinfo_size; @@ -2072,36 +2072,34 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) else priv->stats.txbytesbroadcast += skb->len - fwinfo_size; - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); ring = &priv->tx_ring[tcb_desc->queue_index]; - if (tcb_desc->queue_index != BEACON_QUEUE) { + if (tcb_desc->queue_index != BEACON_QUEUE) idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - } else { + else idx = 0; - } pdesc = &ring->desc[idx]; if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d, skblen = 0x%x queuelen=%d", \ - tcb_desc->queue_index,ring->idx, idx,skb->len, skb_queue_len(&ring->queue)); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d, idx = " + "%d, skblen = 0x%x queuelen=%d", + tcb_desc->queue_index, ring->idx, idx, skb->len, + skb_queue_len(&ring->queue)); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); return skb->len; } - if (tcb_desc->queue_index == MGNT_QUEUE){ - } - - if (type == RTLLIB_FTYPE_DATA){ + if (type == RTLLIB_FTYPE_DATA) { if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, LED_CTL_TX); } priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, skb); __skb_queue_tail(&ring->queue, skb); pdesc->OWN = 1; - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); dev->trans_start = jiffies; - write_nic_word(dev,TPPoll,0x01<queue_index); + write_nic_word(dev, TPPoll, 0x01 << tcb_desc->queue_index); return 0; } @@ -2111,16 +2109,21 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) struct rx_desc *entry = NULL; int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { priv->rx_ring[rx_queue_idx] = pci_alloc_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + &priv->rx_ring_dma[rx_queue_idx]); - if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { - RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); + if (!priv->rx_ring[rx_queue_idx] || + (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate RX ring\n"); return -ENOMEM; } - memset(priv->rx_ring[rx_queue_idx], 0, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount); + memset(priv->rx_ring[rx_queue_idx], 0, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount); priv->rx_idx[rx_queue_idx] = 0; for (i = 0; i < priv->rxringcount; i++) { @@ -2132,8 +2135,10 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) skb->dev = dev; priv->rx_buf[rx_queue_idx][i] = skb; mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); + *mapping = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); entry->BufferAddress = cpu_to_le32(*mapping); @@ -2147,68 +2152,69 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) } static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, - unsigned int prio, unsigned int entries) + unsigned int prio, unsigned int entries) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct tx_desc *ring; - dma_addr_t dma; - int i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct tx_desc *ring; + dma_addr_t dma; + int i; - ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); - if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); - return -ENOMEM; - } + ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + if (!ring || (unsigned long)ring & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", + prio); + return -ENOMEM; + } - memset(ring, 0, sizeof(*ring)*entries); - priv->tx_ring[prio].desc = ring; - priv->tx_ring[prio].dma = dma; - priv->tx_ring[prio].idx = 0; - priv->tx_ring[prio].entries = entries; - skb_queue_head_init(&priv->tx_ring[prio].queue); + memset(ring, 0, sizeof(*ring)*entries); + priv->tx_ring[prio].desc = ring; + priv->tx_ring[prio].dma = dma; + priv->tx_ring[prio].idx = 0; + priv->tx_ring[prio].entries = entries; + skb_queue_head_init(&priv->tx_ring[prio].queue); - for (i = 0; i < entries; i++) - ring[i].NextDescAddress = - cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); + for (i = 0; i < entries; i++) + ring[i].NextDescAddress = + cpu_to_le32((u32)dma + ((i + 1) % entries) * + sizeof(*ring)); - return 0; + return 0; } short rtl8192_pci_initdescring(struct net_device *dev) { - u32 ret; - int i; - struct r8192_priv *priv = rtllib_priv(dev); + u32 ret; + int i; + struct r8192_priv *priv = rtllib_priv(dev); - ret = rtl8192_alloc_rx_desc_ring(dev); - if (ret) { - return ret; - } + ret = rtl8192_alloc_rx_desc_ring(dev); + if (ret) + return ret; + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount); + if (ret) + goto err_free_rings; + } - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if ((ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount))) - goto err_free_rings; - } - - return 0; + return 0; err_free_rings: - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - if (priv->tx_ring[i].desc) - rtl8192_free_tx_ring(dev, i); - return 1; + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + if (priv->tx_ring[i].desc) + rtl8192_free_tx_ring(dev, i); + return 1; } void rtl8192_pci_resetdescring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; - unsigned long flags = 0; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; + unsigned long flags = 0; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { if (priv->rx_ring[rx_queue_idx]) { struct rx_desc *entry = NULL; for (i = 0; i < priv->rxringcount; i++) { @@ -2219,27 +2225,30 @@ void rtl8192_pci_resetdescring(struct net_device *dev) } } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if (priv->tx_ring[i].desc) { - struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if (priv->tx_ring[i].desc) { + struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = + __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - ring->idx = 0; - } - } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + pci_unmap_single(priv->pdev, + le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } + spin_unlock_irqrestore(&priv->irq_th_lock, flags); } -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats) +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2249,7 +2258,7 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat priv->LastRxDescTSF = stats->mac_time; } -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index) { long signal_power; @@ -2262,48 +2271,41 @@ long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index void rtl819x_update_rxsignalstatistics8190pci( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats + struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats ) { int weighting = 0; if (priv->stats.recv_signal_power == 0) - priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; + priv->stats.recv_signal_power = + pprevious_stats->RecvSignalPower; if (pprevious_stats->RecvSignalPower > priv->stats.recv_signal_power) weighting = 5; - else if (pprevious_stats->RecvSignalPower < priv->stats.recv_signal_power) + else if (pprevious_stats->RecvSignalPower < + priv->stats.recv_signal_power) weighting = (-5); - priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + pprevious_stats->RecvSignalPower + weighting) / 6; + priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + + pprevious_stats->RecvSignalPower + + weighting) / 6; } -void -rtl819x_process_cck_rxpathsel( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats - ) +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats) { } -u8 rtl819x_query_rxpwrpercentage( - char antpower - ) +u8 rtl819x_query_rxpwrpercentage(char antpower) { if ((antpower <= -100) || (antpower >= 20)) - { return 0; - } else if (antpower >= 0) - { return 100; - } else - { - return (100+antpower); - } + return 100 + antpower; } /* QueryRxPwrPercentage */ @@ -2321,16 +2323,16 @@ rtl819x_evm_dbtopercentage( if (ret_val <= -33) ret_val = -33; ret_val = 0 - ret_val; - ret_val*=3; + ret_val *= 3; if (ret_val == 99) ret_val = 100; - return(ret_val); + return ret_val; } void rtl8192_record_rxdesc_forlateruse( - struct rtllib_rx_stats * psrc_stats, - struct rtllib_rx_stats * ptarget_stats + struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats ) { ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; @@ -2344,8 +2346,8 @@ void rtl8192_rx_normal(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; bool unicast_packet = false; - bool bLedBlinking=true; - u16 fc=0, type=0; + bool bLedBlinking = true; + u16 fc = 0, type = 0; u32 skb_len = 0; int rx_queue_idx = RX_MPDU_QUEUE; @@ -2360,8 +2362,10 @@ void rtl8192_rx_normal(struct net_device *dev) stats.nic_type = NIC_8192E; while (count--) { - struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; + struct sk_buff *skb = priv->rx_buf[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; if (pdesc->OWN) { return; @@ -2369,11 +2373,11 @@ void rtl8192_rx_normal(struct net_device *dev) struct sk_buff *new_skb; if (!priv->ops->rx_query_status_descriptor(dev, &stats, - pdesc, skb)) + pdesc, skb)) goto done; new_skb = dev_alloc_skb(priv->rxbuffersize); /* if allocation of new skb failed - drop current packet - * and reuse skb */ + * and reuse skb */ if (unlikely(!new_skb)) goto done; @@ -2384,11 +2388,11 @@ void rtl8192_rx_normal(struct net_device *dev) skb_put(skb, pdesc->Length); skb_reserve(skb, stats.RxDrvInfoSize + - stats.RxBufShift); + stats.RxBufShift); skb_trim(skb, skb->len - 4/*sCrcLng*/); rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; if (!is_broadcast_ether_addr(rtllib_hdr->addr1) && - !is_multicast_ether_addr(rtllib_hdr->addr1)) { + !is_multicast_ether_addr(rtllib_hdr->addr1)) { /* unicast packet */ unicast_packet = true; } @@ -2400,18 +2404,18 @@ void rtl8192_rx_normal(struct net_device *dev) if (bLedBlinking) if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, - LED_CTL_RX); + LED_CTL_RX); if (stats.bCRC) { if (type != RTLLIB_FTYPE_MGMT) - priv->stats.rxdatacrcerr ++; + priv->stats.rxdatacrcerr++; else - priv->stats.rxmgmtcrcerr ++; + priv->stats.rxmgmtcrcerr++; } skb_len = skb->len; - if (!rtllib_rx(priv->rtllib, skb, &stats)){ + if (!rtllib_rx(priv->rtllib, skb, &stats)) { dev_kfree_skb_any(skb); } else { priv->stats.rxok++; @@ -2422,8 +2426,12 @@ void rtl8192_rx_normal(struct net_device *dev) skb = new_skb; skb->dev = dev; - priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = + skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); } done: @@ -2432,7 +2440,8 @@ done: pdesc->Length = priv->rxbuffersize; if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) pdesc->EOR = 1; - priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; + priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % + priv->rxringcount; } } @@ -2449,18 +2458,19 @@ void rtl8192_tx_resume(struct net_device *dev) struct sk_buff *skb; int queue_index; - for (queue_index = BK_QUEUE; queue_index < MAX_QUEUE_SIZE;queue_index++) { - while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&& - (priv->rtllib->check_nic_enough_desc(dev,queue_index) > 0)) { + for (queue_index = BK_QUEUE; + queue_index < MAX_QUEUE_SIZE; queue_index++) { + while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index])) && + (priv->rtllib->check_nic_enough_desc(dev, queue_index) > 0)) { skb = skb_dequeue(&ieee->skb_waitQ[queue_index]); - ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/); + ieee->softmac_data_hard_start_xmit(skb, dev, 0); } } } void rtl8192_irq_tx_tasklet(struct r8192_priv *priv) { - rtl8192_tx_resume(priv->rtllib->dev); + rtl8192_tx_resume(priv->rtllib->dev); } void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) @@ -2470,13 +2480,14 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) if (MAX_RX_QUEUE > 1) rtl8192_rx_cmd(priv->rtllib->dev); - write_nic_dword(priv->rtllib->dev, INTA_MASK,read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); + write_nic_dword(priv->rtllib->dev, INTA_MASK, + read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); } /**************************************************************************** ---------------------------- NIC START/CLOSE STUFF--------------------------- *****************************************************************************/ -void rtl8192_cancel_deferred_work(struct r8192_priv * priv) +void rtl8192_cancel_deferred_work(struct r8192_priv *priv) { cancel_delayed_work(&priv->watch_dog_wq); cancel_delayed_work(&priv->update_beacon_wq); @@ -2485,7 +2496,7 @@ void rtl8192_cancel_deferred_work(struct r8192_priv * priv) cancel_work_sync(&priv->qos_activate); } -int _rtl8192_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_up(struct net_device *dev, bool is_silent_reset) { if (_rtl8192_sta_up(dev, is_silent_reset) == -1) return -1; @@ -2510,8 +2521,9 @@ int rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 1) return -1; - return _rtl8192_up(dev,false); + if (priv->up == 1) + return -1; + return _rtl8192_up(dev, false); } @@ -2521,13 +2533,13 @@ int rtl8192_close(struct net_device *dev) int ret; if ((rtllib_act_scanning(priv->rtllib, false)) && - !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_stop_scan(priv->rtllib); } down(&priv->wx_sem); - ret = rtl8192_down(dev,true); + ret = rtl8192_down(dev, true); up(&priv->wx_sem); @@ -2547,16 +2559,18 @@ void rtl8192_commit(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 0) return ; + if (priv->up == 0) + return; rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, true); - _rtl8192_up(dev,false); + _rtl8192_up(dev, false); } void rtl8192_restart(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, reset_wq); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + reset_wq); struct net_device *dev = priv->rtllib->dev; down(&priv->wx_sem); @@ -2571,14 +2585,7 @@ static void r8192_set_multicast(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); short promisc; - - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) { - ; - } - + promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->promisc = promisc; } @@ -2604,117 +2611,118 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; - int ret=-1; + int ret = -1; struct rtllib_device *ieee = priv->rtllib; u32 key[4]; - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero_addr[6] = {0}; struct iw_point *p = &wrq->u.data; + struct ieee_param *ipw = NULL; down(&priv->wx_sem); switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - { - struct ieee_param *ipw = NULL; - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } + case RTL_IOCTL_WPA_SUPPLICANT: + if (p->length < sizeof(struct ieee_param) || !p->pointer) { + ret = -EINVAL; + goto out; + } - ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; - goto out; - } - - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) - { - if (ipw->u.crypt.set_tx) - { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } - else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) - { - if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0) - ieee->iw_mode = IW_MODE_ADHOC; - - memcpy((u8*)key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(dev); - set_swcam(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - if (ieee->iw_mode == IW_MODE_ADHOC){ - set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - } - } - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } + ipw = kmalloc(p->length, GFP_KERNEL); + if (ipw == NULL) { + ret = -ENOMEM; + goto out; + } + if (copy_from_user(ipw, p->pointer, p->length)) { + kfree(ipw); + ret = -EFAULT; + goto out; + } + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { + if (ipw->u.crypt.set_tx) { + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = + KEY_TYPE_WEP40; + } else { + ieee->pairwise_key_type = KEY_TYPE_NA; } - else - { - memcpy((u8*)key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } - else - ieee->group_key_type = KEY_TYPE_NA; - if (ieee->group_key_type) - { - set_swcam( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key, - 0); - setKey( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key); + if (ieee->pairwise_key_type) { + if (memcmp(ieee->ap_mac_addr, zero_addr, + 6) == 0) + ieee->iw_mode = IW_MODE_ADHOC; + memcpy((u8 *)key, ipw->u.crypt.key, 16); + EnableHWSecurityConfig8192(dev); + set_swcam(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, 0, key); + if (ieee->iw_mode == IW_MODE_ADHOC) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key); } } + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) + && ieee->pHTInfo->bCurrentHTSupport) { + write_nic_byte(dev, 0x173, 1); + } + + } else { + memcpy((u8 *)key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = + KEY_TYPE_WEP40; + } else + ieee->group_key_type = KEY_TYPE_NA; + + if (ieee->group_key_type) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key); + } } - - ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, 0); - kfree(ipw); - break; } - default: - ret = -EOPNOTSUPP; - break; + + ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, + 0); + kfree(ipw); + break; + default: + ret = -EOPNOTSUPP; + break; } out: @@ -2727,40 +2735,48 @@ void FairBeacon(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i=100; - static u8 forceturn =0; - u16 beaconint = net->beacon_interval; + static u8 i = 100; + static u8 forceturn; + u16 beaconint = net->beacon_interval; if (priv->rtllib->iw_mode != IW_MODE_ADHOC) return; - if (priv->bIbssCoordinator){ + if (priv->bIbssCoordinator) { i--; - if (forceturn ==2){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 2) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i<=94){ - beaconint=beaconint+2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =1; + if (i <= 94) { + beaconint = beaconint+2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 1; } } else { i++; - if (forceturn ==1){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 1) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i>=106){ - beaconint=beaconint-2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =2; + if (i >= 106) { + beaconint = beaconint-2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 2; } } } @@ -2775,71 +2791,67 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) u32 intb; intb = 0; - if (priv->irq_enabled == 0){ + if (priv->irq_enabled == 0) goto done; - } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); priv->ops->interrupt_recognized(dev, &inta, &intb); priv->stats.shints++; if (!inta) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } if (inta == 0xffff) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } priv->stats.ints++; if (!netif_running(dev)) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } - if (inta & IMR_TBDOK){ + if (inta & IMR_TBDOK) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconokint++; } - if (inta & IMR_TBDER){ + if (inta & IMR_TBDER) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconerr++; } - if (inta & IMR_BDOK) { + if (inta & IMR_BDOK) RT_TRACE(COMP_INTR, "beacon interrupt!\n"); - } - if (inta & IMR_MGNTDOK ) { + if (inta & IMR_MGNTDOK) { RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); priv->stats.txmanageokint++; - rtl8192_tx_isr(dev,MGNT_QUEUE); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - if (priv->rtllib->ack_tx_to_ieee){ - if (rtl8192_is_tx_queue_empty(dev)){ + rtl8192_tx_isr(dev, MGNT_QUEUE); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + if (priv->rtllib->ack_tx_to_ieee) { + if (rtl8192_is_tx_queue_empty(dev)) { priv->rtllib->ack_tx_to_ieee = 0; rtllib_ps_tx_ack(priv->rtllib, 1); } } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); } if (inta & IMR_COMDOK) { priv->stats.txcmdpktokint++; - rtl8192_tx_isr(dev,TXCMD_QUEUE); + rtl8192_tx_isr(dev, TXCMD_QUEUE); } - if (inta & IMR_HIGHDOK) { - rtl8192_tx_isr(dev,HIGH_QUEUE); - } + if (inta & IMR_HIGHDOK) + rtl8192_tx_isr(dev, HIGH_QUEUE); - if (inta & IMR_ROK) - { + if (inta & IMR_ROK) { priv->stats.rxint++; priv->InterruptLog.nIMR_ROK++; tasklet_schedule(&priv->irq_rx_tasklet); @@ -2853,7 +2865,8 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_RDU) { RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); priv->stats.rxrdu++; - write_nic_dword(dev,INTA_MASK,read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); + write_nic_dword(dev, INTA_MASK, + read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); tasklet_schedule(&priv->irq_rx_tasklet); } @@ -2863,37 +2876,38 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) tasklet_schedule(&priv->irq_rx_tasklet); } - if (inta & IMR_TXFOVW) priv->stats.txoverflow++; + if (inta & IMR_TXFOVW) + priv->stats.txoverflow++; if (inta & IMR_BKDOK) { RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); priv->stats.txbkokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BK_QUEUE); + rtl8192_tx_isr(dev, BK_QUEUE); } if (inta & IMR_BEDOK) { RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); priv->stats.txbeokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BE_QUEUE); + rtl8192_tx_isr(dev, BE_QUEUE); } if (inta & IMR_VIDOK) { RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); priv->stats.txviokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VI_QUEUE); + rtl8192_tx_isr(dev, VI_QUEUE); } if (inta & IMR_VODOK) { priv->stats.txvookint++; RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n"); priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VO_QUEUE); + rtl8192_tx_isr(dev, VO_QUEUE); } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); done: @@ -2903,7 +2917,7 @@ done: /**************************************************************************** - ---------------------------- PCI_STUFF--------------------------- + ---------------------------- PCI_STUFF--------------------------- *****************************************************************************/ #ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops rtl8192_netdev_ops = { @@ -2920,73 +2934,71 @@ static const struct net_device_ops rtl8192_netdev_ops = { #endif static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) + const struct pci_device_id *id) { unsigned long ioaddr = 0; struct net_device *dev = NULL; - struct r8192_priv *priv= NULL; + struct r8192_priv *priv = NULL; struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); unsigned long pmem_start, pmem_len, pmem_flags; int err = 0; bool bdma64 = false; u8 revision_id; - RT_TRACE(COMP_INIT,"Configuring chip resources"); + RT_TRACE(COMP_INIT, "Configuring chip resources"); - if ( pci_enable_device (pdev) ){ - RT_TRACE(COMP_ERR,"Failed to enable PCI device"); + if (pci_enable_device(pdev)) { + RT_TRACE(COMP_ERR, "Failed to enable PCI device"); return -EIO; } pci_set_master(pdev); - { - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { - printk( "Unable to obtain 32bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; - } + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + printk(KERN_INFO "Unable to obtain 32bit DMA for consistent allocations\n"); + pci_disable_device(pdev); + return -ENOMEM; } } dev = alloc_rtllib(sizeof(struct r8192_priv)); if (!dev) return -ENOMEM; - if (bdma64){ + if (bdma64) dev->features |= NETIF_F_HIGHDMA; - } pci_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev); priv = rtllib_priv(dev); priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev); - priv->pdev=pdev; - priv->rtllib->pdev=pdev; - if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)) + priv->pdev = pdev; + priv->rtllib->pdev = pdev; + if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK) && + (pdev->subsystem_device == 0x3304)) priv->rtllib->bSupportRemoteWakeUp = 1; else priv->rtllib->bSupportRemoteWakeUp = 0; pmem_start = pci_resource_start(pdev, 1); pmem_len = pci_resource_len(pdev, 1); - pmem_flags = pci_resource_flags (pdev, 1); + pmem_flags = pci_resource_flags(pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR,"region #1 not a MMIO resource, aborting"); + RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting"); goto fail; } - printk("Memory mapped space start: 0x%08lx \n", pmem_start); + printk(KERN_INFO "Memory mapped space start: 0x%08lx\n", pmem_start); if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { - RT_TRACE(COMP_ERR,"request_mem_region failed!"); + RT_TRACE(COMP_ERR, "request_mem_region failed!"); goto fail; } - ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); - if ( ioaddr == (unsigned long)NULL ){ - RT_TRACE(COMP_ERR,"ioremap failed!"); + ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); + if (ioaddr == (unsigned long)NULL) { + RT_TRACE(COMP_ERR, "ioremap failed!"); goto fail1; } @@ -3018,19 +3030,21 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->hard_start_xmit = rtllib_xmit; #endif - dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; + dev->wireless_handlers = (struct iw_handler_def *) + &r8192_wx_handlers_def; dev->ethtool_ops = &rtl819x_ethtool_ops; dev->type = ARPHRD_ETHER; - dev->watchdog_timeo = HZ*3; + dev->watchdog_timeo = HZ * 3; - if (dev_alloc_name(dev, ifname) < 0){ - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - dev_alloc_name(dev, ifname); - } + if (dev_alloc_name(dev, ifname) < 0) { + RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying " + "wlan%%d...\n"); + dev_alloc_name(dev, ifname); + } RT_TRACE(COMP_INIT, "Driver probe completed1\n"); - if (rtl8192_init(dev)!=0){ + if (rtl8192_init(dev) != 0) { RT_TRACE(COMP_ERR, "Initialization failed"); goto fail1; } @@ -3039,33 +3053,31 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, netif_stop_queue(dev); register_netdev(dev); - RT_TRACE(COMP_INIT, "dev name: %s\n",dev->name); + RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); err = rtl_debug_module_init(priv, dev->name); - if (err) { - RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring error: %d\n", err); - } + if (err) + RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring " + "error: %d\n", err); rtl8192_proc_init_one(dev); - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; fail1: - if ( dev->mem_start != (unsigned long)NULL ){ - iounmap( (void *)dev->mem_start ); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); + if (dev->mem_start != (unsigned long)NULL) { + iounmap((void *)dev->mem_start); + release_mem_region(pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1)); } fail: - if (dev){ - + if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq=0; + dev->irq = 0; } free_rtllib(dev); } @@ -3082,7 +3094,9 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv ; - if (dev){ + u32 i; + + if (dev) { unregister_netdev(dev); priv = rtllib_priv(dev); @@ -3092,63 +3106,59 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) priv->polling_timer_on = 0; rtl_debug_module_remove(priv); rtl8192_proc_remove_one(dev); - rtl8192_down(dev,true); + rtl8192_down(dev, true); deinit_hal_dm(dev); if (priv->pFirmware) { vfree(priv->pFirmware); priv->pFirmware = NULL; } destroy_workqueue(priv->priv_wq); - { - u32 i; - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - rtl8192_free_tx_ring(dev, i); - } - } + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + rtl8192_free_tx_ring(dev, i); - if (priv->irq){ - - printk("Freeing irq %d\n",dev->irq); + if (priv->irq) { + printk(KERN_INFO "Freeing irq %d\n", dev->irq); free_irq(dev->irq, dev); - priv->irq=0; - + priv->irq = 0; } free_rtllib(dev); - if (priv->scan_cmd) - kfree(priv->scan_cmd); + kfree(priv->scan_cmd); if (dev->mem_start != 0) { iounmap((void *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); + pci_resource_len(pdev, 1)); } - } else{ - priv=rtllib_priv(dev); - } + } else { + priv = rtllib_priv(dev); + } pci_disable_device(pdev); RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } -bool NicIFEnableNIC(struct net_device* dev) +bool NicIFEnableNIC(struct net_device *dev) { bool init_status = true; - struct r8192_priv * priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n", + __func__); priv->bdisable_nic = false; return RT_STATUS_FAILURE; } - RT_TRACE(COMP_PS, "===========>%s()\n",__func__); + RT_TRACE(COMP_PS, "===========>%s()\n", __func__); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (init_status != true) { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bdisable_nic = false; return -1; } @@ -3158,15 +3168,15 @@ bool NicIFEnableNIC(struct net_device* dev) rtl8192_irq_enable(dev); priv->bdisable_nic = false; - RT_TRACE(COMP_PS,"<===========%s()\n",__func__); + RT_TRACE(COMP_PS, "<===========%s()\n", __func__); return init_status; } -bool NicIFDisableNIC(struct net_device* dev) +bool NicIFDisableNIC(struct net_device *dev) { bool status = true; - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); u8 tmp_state = 0; - RT_TRACE(COMP_PS, "=========>%s()\n",__func__); + RT_TRACE(COMP_PS, "=========>%s()\n", __func__); priv->bdisable_nic = true; tmp_state = priv->rtllib->state; rtllib_softmac_stop_protocol(priv->rtllib, 0, false); @@ -3175,7 +3185,7 @@ bool NicIFDisableNIC(struct net_device* dev) rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, false); - RT_TRACE(COMP_PS, "<=========%s()\n",__func__); + RT_TRACE(COMP_PS, "<=========%s()\n", __func__); return status; } @@ -3220,14 +3230,14 @@ static int __init rtl8192_pci_module_init(void) } rtl8192_proc_module_init(); - if (0!=pci_register_driver(&rtl8192_pci_driver)) { + if (0 != pci_register_driver(&rtl8192_pci_driver)) { DMESG("No device found"); /*pci_unregister_driver (&rtl8192_pci_driver);*/ return -ENODEV; } return 0; err_out: - return error; + return error; } @@ -3247,17 +3257,18 @@ static void __exit rtl8192_pci_module_exit(void) void check_rfctrl_gpio_timer(unsigned long data) { - struct r8192_priv * priv = rtllib_priv((struct net_device *)data); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); priv->polling_timer_on = 1; - queue_delayed_work_rsl(priv->priv_wq,&priv->gpio_change_rf_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->gpio_change_rf_wq, 0); - mod_timer(&priv->gpio_polling_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + mod_timer(&priv->gpio_polling_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /*************************************************************************** - ------------------- module init / exit stubs ---------------- + ------------------- module init / exit stubs ---------------- ****************************************************************************/ module_init(rtl8192_pci_module_init); module_exit(rtl8192_pci_module_exit); @@ -3267,10 +3278,10 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR); +module_param(hwwep, int, S_IRUGO|S_IWUSR); +module_param(channels, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support(default use hw. set 0 to use software security)"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); +MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); +MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support(default use hw. set 0 to use software security)"); +MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI"); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 4f94d0a18f0..03a86fe283c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include "dot11d.h" @@ -62,28 +62,35 @@ #include "rtl_pci.h" #include "rtl_cam.h" -#define DRV_COPYRIGHT "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" +#define DRV_COPYRIGHT \ + "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" #define DRV_AUTHOR "" #define DRV_VERSION "0014.0401.2010" #define DRV_NAME "rtl819xE" -#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8190P)||\ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192E)) -#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192SE) -#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CE) -#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CU) -#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DE) -#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DU) +#define IS_HARDWARE_TYPE_819xP(_priv) \ + ((((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8190P) || \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192E)) +#define IS_HARDWARE_TYPE_8192SE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE) +#define IS_HARDWARE_TYPE_8192CE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CE) +#define IS_HARDWARE_TYPE_8192CU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CU) +#define IS_HARDWARE_TYPE_8192DE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DE) +#define IS_HARDWARE_TYPE_8192DU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DU) #define RTL_PCI_DEVICE(vend, dev, cfg) \ .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice =PCI_ANY_ID , \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \ .driver_data = (kernel_ulong_t)&(cfg) #define irqreturn_type irqreturn_t -#define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) +#define rtl8192_interrupt(x, y, z) rtl8192_interrupt_rsl(x, y) #define RTL_MAX_SCAN_SIZE 128 @@ -100,8 +107,9 @@ #define IS_ADAPTER_SENDS_BEACON(dev) 0 -#define IS_UNDER_11N_AES_MODE(_rtllib) ((_rtllib->pHTInfo->bCurrentHTSupport == true) &&\ - (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) +#define IS_UNDER_11N_AES_MODE(_rtllib) \ + ((_rtllib->pHTInfo->bCurrentHTSupport == true) && \ + (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) #define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI 0x1000 #define HAL_HW_PCI_REVISION_ID_8190PCI 0x00 @@ -120,36 +128,38 @@ #define HAL_HW_PCI_8198_DEVICE_ID 0x8198 #define HAL_HW_PCI_8190_DEVICE_ID 0x8190 #define HAL_HW_PCI_8192_DEVICE_ID 0x8192 -#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 +#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 #define HAL_HW_PCI_8174_DEVICE_ID 0x8174 #define HAL_HW_PCI_8173_DEVICE_ID 0x8173 #define HAL_HW_PCI_8172_DEVICE_ID 0x8172 #define HAL_HW_PCI_8171_DEVICE_ID 0x8171 -#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 -#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 -#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 -#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 -#define HAL_HW_PCI_700F_DEVICE_ID 0x700F -#define HAL_HW_PCI_701F_DEVICE_ID 0x701F -#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 +#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 +#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 +#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 +#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 +#define HAL_HW_PCI_700F_DEVICE_ID 0x700F +#define HAL_HW_PCI_701F_DEVICE_ID 0x701F +#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 #define HAL_HW_PCI_8192CET_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 -#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 -#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 -#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D -#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 +#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 +#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 +#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 +#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D #define RTL819X_DEFAULT_RF_TYPE RF_1T2R #define RTLLIB_WATCH_DOG_TIME 2000 -#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */ +#define MAX_DEV_ADDR_SIZE 8 /*support till 64 bit bus width OS*/ #define MAX_FIRMWARE_INFORMATION_SIZE 32 #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 #define MAX_FRAGMENT_COUNT 8 -#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) +#define MAX_TRANSMIT_BUFFER_SIZE \ + (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) * \ + MAX_FRAGMENT_COUNT) #define scrclng 4 @@ -164,13 +174,13 @@ #define PHY_RSSI_SLID_WIN_MAX 100 -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) -#define TxBBGainTableLength 37 -#define CCKTxBBGainTableLength 23 +#define TxBBGainTableLength 37 +#define CCKTxBBGainTableLength 23 #define CHANNEL_PLAN_LEN 10 -#define sCrcLng 4 +#define sCrcLng 4 #define NIC_SEND_HANG_THRESHOLD_NORMAL 4 #define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 @@ -179,30 +189,30 @@ #define MAX_RX_QUEUE 1 -#define MAX_RX_COUNT 64 -#define MAX_TX_QUEUE_COUNT 9 +#define MAX_RX_COUNT 64 +#define MAX_TX_QUEUE_COUNT 9 enum RTL819x_PHY_PARAM { - RTL819X_PHY_MACPHY_REG = 0, - RTL819X_PHY_MACPHY_REG_PG = 1, - RTL8188C_PHY_MACREG =2, - RTL8192C_PHY_MACREG =3, + RTL819X_PHY_MACPHY_REG = 0, + RTL819X_PHY_MACPHY_REG_PG = 1, + RTL8188C_PHY_MACREG = 2, + RTL8192C_PHY_MACREG = 3, RTL819X_PHY_REG = 4, RTL819X_PHY_REG_1T2R = 5, - RTL819X_PHY_REG_to1T1R = 6, - RTL819X_PHY_REG_to1T2R = 7, - RTL819X_PHY_REG_to2T2R = 8, + RTL819X_PHY_REG_to1T1R = 6, + RTL819X_PHY_REG_to1T2R = 7, + RTL819X_PHY_REG_to2T2R = 8, RTL819X_PHY_REG_PG = 9, RTL819X_AGC_TAB = 10, - RTL819X_PHY_RADIO_A =11, - RTL819X_PHY_RADIO_A_1T =12, - RTL819X_PHY_RADIO_A_2T =13, - RTL819X_PHY_RADIO_B =14, - RTL819X_PHY_RADIO_B_GM =15, - RTL819X_PHY_RADIO_C =16, - RTL819X_PHY_RADIO_D =17, - RTL819X_EEPROM_MAP =18, - RTL819X_EFUSE_MAP =19, + RTL819X_PHY_RADIO_A = 11, + RTL819X_PHY_RADIO_A_1T = 12, + RTL819X_PHY_RADIO_A_2T = 13, + RTL819X_PHY_RADIO_B = 14, + RTL819X_PHY_RADIO_B_GM = 15, + RTL819X_PHY_RADIO_C = 16, + RTL819X_PHY_RADIO_D = 17, + RTL819X_EEPROM_MAP = 18, + RTL819X_EFUSE_MAP = 19, }; enum RTL_DEBUG { @@ -212,27 +222,27 @@ enum RTL_DEBUG { COMP_RECV = BIT3, COMP_SEND = BIT4, COMP_CMD = BIT5, - COMP_POWER = BIT6, - COMP_EPROM = BIT7, + COMP_POWER = BIT6, + COMP_EPROM = BIT7, COMP_SWBW = BIT8, COMP_SEC = BIT9, COMP_LPS = BIT10, COMP_QOS = BIT11, COMP_RATE = BIT12, - COMP_RXDESC = BIT13, + COMP_RXDESC = BIT13, COMP_PHY = BIT14, COMP_DIG = BIT15, COMP_TXAGC = BIT16, - COMP_HALDM = BIT17, + COMP_HALDM = BIT17, COMP_POWER_TRACKING = BIT18, - COMP_CH = BIT19, - COMP_RF = BIT20, - COMP_FIRMWARE = BIT21, - COMP_HT = BIT22, + COMP_CH = BIT19, + COMP_RF = BIT20, + COMP_FIRMWARE = BIT21, + COMP_HT = BIT22, COMP_RESET = BIT23, - COMP_CMDPKT = BIT24, + COMP_CMDPKT = BIT24, COMP_SCAN = BIT25, - COMP_PS = BIT26, + COMP_PS = BIT26, COMP_DOWN = BIT27, COMP_INTR = BIT28, COMP_LED = BIT29, @@ -245,11 +255,11 @@ enum nic_t { NIC_8192E = 1, NIC_8190P = 2, NIC_8192SE = 4, - NIC_8192CE = 5, - NIC_8192CU = 6, - NIC_8192DE = 7, - NIC_8192DU = 8, - }; + NIC_8192CE = 5, + NIC_8192CU = 6, + NIC_8192DE = 7, + NIC_8192DU = 8, +}; enum rt_eeprom_type { EEPROM_93C46, @@ -258,7 +268,7 @@ enum rt_eeprom_type { }; enum dcmg_txcmd_op { - TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, + TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, TXCMD_SET_TX_DURATION = 0xFF900003, @@ -268,18 +278,18 @@ enum dcmg_txcmd_op { }; enum rt_rf_type_819xu { - RF_TYPE_MIN = 0, - RF_8225, - RF_8256, - RF_8258, - RF_6052=4, - RF_PSEUDO_11N = 5, + RF_TYPE_MIN = 0, + RF_8225, + RF_8256, + RF_8258, + RF_6052 = 4, + RF_PSEUDO_11N = 5, }; enum rf_step { - RF_STEP_INIT = 0, - RF_STEP_NORMAL, - RF_STEP_MAX + RF_STEP_INIT = 0, + RF_STEP_NORMAL, + RF_STEP_MAX }; enum rt_status { @@ -290,32 +300,32 @@ enum rt_status { }; enum rt_customer_id { - RT_CID_DEFAULT = 0, + RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, RT_CID_8187_SERCOMM_PS = 2, RT_CID_8187_HW_LED = 3, RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, + RT_CID_WHQL = 5, RT_CID_819x_CAMEO = 6, RT_CID_819x_RUNTOP = 7, RT_CID_819x_Senao = 8, - RT_CID_TOSHIBA = 9, + RT_CID_TOSHIBA = 9, RT_CID_819x_Netcore = 10, - RT_CID_Nettronix = 11, - RT_CID_DLINK = 12, - RT_CID_PRONET = 13, - RT_CID_COREGA = 14, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, RT_CID_819x_ALPHA = 15, RT_CID_819x_Sitecom = 16, - RT_CID_CCX = 17, + RT_CID_CCX = 17, RT_CID_819x_Lenovo = 18, - RT_CID_819x_QMI = 19, + RT_CID_819x_QMI = 19, RT_CID_819x_Edimax_Belkin = 20, RT_CID_819x_Sercomm_Belkin = 21, RT_CID_819x_CAMEO1 = 22, RT_CID_819x_MSI = 23, RT_CID_819x_Acer = 24, - RT_CID_819x_HP =27, + RT_CID_819x_HP = 27, RT_CID_819x_CLEVO = 28, RT_CID_819x_Arcadyan_Belkin = 29, RT_CID_819x_SAMSUNG = 30, @@ -329,8 +339,8 @@ enum reset_type { }; enum ic_inferiority_8192s { - IC_INFERIORITY_A = 0, - IC_INFERIORITY_B = 1, + IC_INFERIORITY_A = 0, + IC_INFERIORITY_B = 1, }; enum pci_bridge_vendor { @@ -350,20 +360,20 @@ struct buffer { }; struct rtl_reg_debug { - unsigned int cmd; - struct { - unsigned char type; - unsigned char addr; - unsigned char page; - unsigned char length; - } head; - unsigned char buf[0xff]; + unsigned int cmd; + struct { + unsigned char type; + unsigned char addr; + unsigned char page; + unsigned char length; + } head; + unsigned char buf[0xff]; }; struct rt_tx_rahis { - u32 cck[4]; - u32 ofdm[8]; - u32 ht_mcs[4][16]; + u32 cck[4]; + u32 ofdm[8]; + u32 ht_mcs[4][16]; }; struct rt_smooth_data_4rf { @@ -449,7 +459,7 @@ struct rt_stats { unsigned long txerrunicast; unsigned long txretrycount; unsigned long txfeedbackretry; - u8 last_packet_rate; + u8 last_packet_rate; unsigned long slide_signal_strength[100]; unsigned long slide_evm[100]; unsigned long slide_rssi_total; @@ -496,51 +506,63 @@ struct ccktxbbgain { }; struct init_gain { - u8 xaagccore1; - u8 xbagccore1; - u8 xcagccore1; - u8 xdagccore1; - u8 cca; + u8 xaagccore1; + u8 xbagccore1; + u8 xcagccore1; + u8 xdagccore1; + u8 cca; }; struct tx_ring { - u32 * desc; + u32 *desc; u8 nStuckCount; - struct tx_ring * next; + struct tx_ring *next; } __packed; struct rtl8192_tx_ring { - struct tx_desc *desc; - dma_addr_t dma; - unsigned int idx; - unsigned int entries; - struct sk_buff_head queue; + struct tx_desc *desc; + dma_addr_t dma; + unsigned int idx; + unsigned int entries; + struct sk_buff_head queue; }; -struct rtl819x_ops{ +struct rtl819x_ops { enum nic_t nic_type; - void (* get_eeprom_size)(struct net_device* dev); - void (* init_adapter_variable)(struct net_device* dev); - void (* init_before_adapter_start)(struct net_device* dev); - bool (* initialize_adapter)(struct net_device* dev); - void (*link_change)(struct net_device* dev); - void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, struct cb_desc *cb_desc, struct sk_buff *skb); - void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, struct cb_desc *cb_desc, struct sk_buff *skb); - bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, struct rx_desc *pdesc, struct sk_buff* skb); - bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, struct rx_desc *pdesc); - void (* stop_adapter)(struct net_device *dev, bool reset); - void (* update_ratr_table)(struct net_device* dev); - void (* irq_enable)(struct net_device* dev); - void (* irq_disable)(struct net_device* dev); - void (* irq_clear)(struct net_device* dev); - void (* rx_enable)(struct net_device* dev); - void (* tx_enable)(struct net_device* dev); - void (* interrupt_recognized)(struct net_device *dev, u32 *p_inta, u32 *p_intb); - bool (* TxCheckStuckHandler)(struct net_device* dev); - bool (* RxCheckStuckHandler)(struct net_device* dev); + void (*get_eeprom_size)(struct net_device *dev); + void (*init_adapter_variable)(struct net_device *dev); + void (*init_before_adapter_start)(struct net_device *dev); + bool (*initialize_adapter)(struct net_device *dev); + void (*link_change)(struct net_device *dev); + void (*tx_fill_descriptor)(struct net_device *dev, + struct tx_desc *tx_desc, + struct cb_desc *cb_desc, + struct sk_buff *skb); + void (*tx_fill_cmd_descriptor)(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, + struct sk_buff *skb); + bool (*rx_query_status_descriptor)(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); + bool (*rx_command_packet_handler)(struct net_device *dev, + struct sk_buff *skb, + struct rx_desc *pdesc); + void (*stop_adapter)(struct net_device *dev, bool reset); + void (*update_ratr_table)(struct net_device *dev); + void (*irq_enable)(struct net_device *dev); + void (*irq_disable)(struct net_device *dev); + void (*irq_clear)(struct net_device *dev); + void (*rx_enable)(struct net_device *dev); + void (*tx_enable)(struct net_device *dev); + void (*interrupt_recognized)(struct net_device *dev, + u32 *p_inta, u32 *p_intb); + bool (*TxCheckStuckHandler)(struct net_device *dev); + bool (*RxCheckStuckHandler)(struct net_device *dev); }; struct r8192_priv { @@ -630,8 +652,8 @@ struct r8192_priv { struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - short (*rf_set_sens)(struct net_device *dev,short sens); - u8 (*rf_set_chan)(struct net_device *dev,u8 ch); + short (*rf_set_sens)(struct net_device *dev, short sens); + u8 (*rf_set_chan)(struct net_device *dev, u8 ch); void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); @@ -672,227 +694,229 @@ struct r8192_priv { /**********************************************************/ - enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type; + enum card_type { + PCI, MINIPCI, + CARDBUS, USB + } card_type; struct work_struct qos_activate; - u8 bIbssCoordinator; + u8 bIbssCoordinator; short promisc; short crcmon; - int txbeaconcount; + int txbeaconcount; short chan; short sens; short max_sens; - u32 rx_prevlen; + u32 rx_prevlen; - u8 ScanDelay; - bool ps_force; + u8 ScanDelay; + bool ps_force; - u32 irq_mask[2]; + u32 irq_mask[2]; - u8 Rf_Mode; + u8 Rf_Mode; enum nic_t card_8192; - u8 card_8192_version; + u8 card_8192_version; short enable_gpio0; - u8 rf_type; - u8 IC_Cut; - char nick[IW_ESSID_MAX_SIZE + 1]; + u8 rf_type; + u8 IC_Cut; + char nick[IW_ESSID_MAX_SIZE + 1]; - u8 RegBcnCtrlVal; - bool bHwAntDiv; + u8 RegBcnCtrlVal; + bool bHwAntDiv; - bool bTKIPinNmodeFromReg; - bool bWEPinNmodeFromReg; + bool bTKIPinNmodeFromReg; + bool bWEPinNmodeFromReg; - bool bLedOpenDrain; + bool bLedOpenDrain; - u8 check_roaming_cnt; + u8 check_roaming_cnt; - bool bIgnoreSilentReset; - u32 SilentResetRxSoltNum; - u32 SilentResetRxSlotIndex; - u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; + bool bIgnoreSilentReset; + u32 SilentResetRxSoltNum; + u32 SilentResetRxSlotIndex; + u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; - void *scan_cmd; - u8 hwscan_bw_40; + void *scan_cmd; + u8 hwscan_bw_40; - u16 nrxAMPDU_size; - u8 nrxAMPDU_aggr_num; + u16 nrxAMPDU_size; + u8 nrxAMPDU_aggr_num; - u32 last_rxdesc_tsf_high; - u32 last_rxdesc_tsf_low; + u32 last_rxdesc_tsf_high; + u32 last_rxdesc_tsf_low; + u16 basic_rate; + u8 short_preamble; + u8 dot11CurrentPreambleMode; + u8 slot_time; + u16 SifsTime; - u16 basic_rate; - u8 short_preamble; - u8 dot11CurrentPreambleMode; - u8 slot_time; - u16 SifsTime; + u8 RegWirelessMode; - u8 RegWirelessMode; + u8 firmware_version; + u16 FirmwareSubVersion; + u16 rf_pathmap; + bool AutoloadFailFlag; - u8 firmware_version; - u16 FirmwareSubVersion; - u16 rf_pathmap; - bool AutoloadFailFlag; + u8 RegPciASPM; + u8 RegAMDPciASPM; + u8 RegHwSwRfOffD3; + u8 RegSupportPciASPM; + bool bSupportASPM; - u8 RegPciASPM; - u8 RegAMDPciASPM; - u8 RegHwSwRfOffD3; - u8 RegSupportPciASPM; - bool bSupportASPM; + u32 RfRegChnlVal[2]; - u32 RfRegChnlVal[2]; + u8 ShowRateMode; + u8 RATRTableBitmap; - u8 ShowRateMode; - u8 RATRTableBitmap; - - u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; - u16 EfuseUsedBytes; - u8 EfuseUsedPercentage; + u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; + u16 EfuseUsedBytes; + u8 EfuseUsedPercentage; short epromtype; - u16 eeprom_vid; - u16 eeprom_did; - u16 eeprom_svid; - u16 eeprom_smid; - u8 eeprom_CustomerID; - u16 eeprom_ChannelPlan; - u8 eeprom_version; + u16 eeprom_vid; + u16 eeprom_did; + u16 eeprom_svid; + u16 eeprom_smid; + u8 eeprom_CustomerID; + u16 eeprom_ChannelPlan; + u8 eeprom_version; - u8 EEPROMRegulatory; - u8 EEPROMPwrGroup[2][3]; - u8 EEPROMOptional; + u8 EEPROMRegulatory; + u8 EEPROMPwrGroup[2][3]; + u8 EEPROMOptional; - u8 EEPROMTxPowerLevelCCK[14]; - u8 EEPROMTxPowerLevelOFDM24G[14]; - u8 EEPROMTxPowerLevelOFDM5G[24]; - u8 EEPROMRfACCKChnl1TxPwLevel[3]; - u8 EEPROMRfAOfdmChnlTxPwLevel[3]; - u8 EEPROMRfCCCKChnl1TxPwLevel[3]; - u8 EEPROMRfCOfdmChnlTxPwLevel[3]; - u16 EEPROMTxPowerDiff; - u16 EEPROMAntPwDiff; - u8 EEPROMThermalMeter; - u8 EEPROMPwDiff; - u8 EEPROMCrystalCap; + u8 EEPROMTxPowerLevelCCK[14]; + u8 EEPROMTxPowerLevelOFDM24G[14]; + u8 EEPROMTxPowerLevelOFDM5G[24]; + u8 EEPROMRfACCKChnl1TxPwLevel[3]; + u8 EEPROMRfAOfdmChnlTxPwLevel[3]; + u8 EEPROMRfCCCKChnl1TxPwLevel[3]; + u8 EEPROMRfCOfdmChnlTxPwLevel[3]; + u16 EEPROMTxPowerDiff; + u16 EEPROMAntPwDiff; + u8 EEPROMThermalMeter; + u8 EEPROMPwDiff; + u8 EEPROMCrystalCap; - u8 EEPROMBluetoothCoexist; - u8 EEPROMBluetoothType; - u8 EEPROMBluetoothAntNum; - u8 EEPROMBluetoothAntIsolation; - u8 EEPROMBluetoothRadioShared; + u8 EEPROMBluetoothCoexist; + u8 EEPROMBluetoothType; + u8 EEPROMBluetoothAntNum; + u8 EEPROMBluetoothAntIsolation; + u8 EEPROMBluetoothRadioShared; - u8 EEPROMSupportWoWLAN; - u8 EEPROMBoardType; - u8 EEPROM_Def_Ver; - u8 EEPROMHT2T_TxPwr[6]; - u8 EEPROMTSSI_A; - u8 EEPROMTSSI_B; - u8 EEPROMTxPowerLevelCCK_V1[3]; - u8 EEPROMLegacyHTTxPowerDiff; + u8 EEPROMSupportWoWLAN; + u8 EEPROMBoardType; + u8 EEPROM_Def_Ver; + u8 EEPROMHT2T_TxPwr[6]; + u8 EEPROMTSSI_A; + u8 EEPROMTSSI_B; + u8 EEPROMTxPowerLevelCCK_V1[3]; + u8 EEPROMLegacyHTTxPowerDiff; - u8 BluetoothCoexist; + u8 BluetoothCoexist; - u8 CrystalCap; - u8 ThermalMeter[2]; + u8 CrystalCap; + u8 ThermalMeter[2]; - u16 FwCmdIOMap; - u32 FwCmdIOParam; + u16 FwCmdIOMap; + u32 FwCmdIOParam; - u8 SwChnlInProgress; - u8 SwChnlStage; - u8 SwChnlStep; - u8 SetBWModeInProgress; + u8 SwChnlInProgress; + u8 SwChnlStage; + u8 SwChnlStep; + u8 SetBWModeInProgress; - u8 nCur40MhzPrimeSC; + u8 nCur40MhzPrimeSC; - u32 RfReg0Value[4]; - u8 NumTotalRFPath; - bool brfpath_rxenable[4]; + u32 RfReg0Value[4]; + u8 NumTotalRFPath; + bool brfpath_rxenable[4]; - bool bTXPowerDataReadFromEEPORM; + bool bTXPowerDataReadFromEEPORM; - u16 RegChannelPlan; - u16 ChannelPlan; - bool bChnlPlanFromHW; + u16 RegChannelPlan; + u16 ChannelPlan; + bool bChnlPlanFromHW; - bool RegRfOff; - bool isRFOff; - bool bInPowerSaveMode; - u8 bHwRfOffAction; + bool RegRfOff; + bool isRFOff; + bool bInPowerSaveMode; + u8 bHwRfOffAction; - bool aspm_clkreq_enable; - u32 pci_bridge_vendor; - u8 RegHostPciASPMSetting; - u8 RegDevicePciASPMSetting; + bool aspm_clkreq_enable; + u32 pci_bridge_vendor; + u8 RegHostPciASPMSetting; + u8 RegDevicePciASPMSetting; - bool RFChangeInProgress; - bool SetRFPowerStateInProgress; - bool bdisable_nic; + bool RFChangeInProgress; + bool SetRFPowerStateInProgress; + bool bdisable_nic; - u8 pwrGroupCnt; + u8 pwrGroupCnt; - u8 ThermalValue_LCK; - u8 ThermalValue_IQK; - bool bRfPiEnable; + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + bool bRfPiEnable; - u32 APKoutput[2][2]; - bool bAPKdone; + u32 APKoutput[2][2]; + bool bAPKdone; - long RegE94; - long RegE9C; - long RegEB4; - long RegEBC; + long RegE94; + long RegE9C; + long RegEB4; + long RegEBC; - u32 RegC04; - u32 Reg874; - u32 RegC08; - u32 ADDA_backup[16]; - u32 IQK_MAC_backup[3]; + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 ADDA_backup[16]; + u32 IQK_MAC_backup[3]; - bool SetFwCmdInProgress; - u8 CurrentFwCmdIO; + bool SetFwCmdInProgress; + u8 CurrentFwCmdIO; - u8 rssi_level; + u8 rssi_level; - bool bInformFWDriverControlDM; - u8 PwrGroupHT20[2][14]; - u8 PwrGroupHT40[2][14]; + bool bInformFWDriverControlDM; + u8 PwrGroupHT20[2][14]; + u8 PwrGroupHT40[2][14]; - u8 ThermalValue; - long EntryMinUndecoratedSmoothedPWDB; - long EntryMaxUndecoratedSmoothedPWDB; - u8 DynamicTxHighPowerLvl; - u8 LastDTPLvl; - u32 CurrentRATR0; + u8 ThermalValue; + long EntryMinUndecoratedSmoothedPWDB; + long EntryMaxUndecoratedSmoothedPWDB; + u8 DynamicTxHighPowerLvl; + u8 LastDTPLvl; + u32 CurrentRATR0; struct false_alarm_stats FalseAlmCnt; - u8 DMFlag; - u8 DM_Type; + u8 DMFlag; + u8 DM_Type; - u8 CckPwEnl; - u16 TSSI_13dBm; - u32 Pwr_Track; - u8 CCKPresentAttentuation_20Mdefault; - u8 CCKPresentAttentuation_40Mdefault; - char CCKPresentAttentuation_difference; - char CCKPresentAttentuation; - u8 bCckHighPower; - long undecorated_smoothed_pwdb; - long undecorated_smoothed_cck_adc_pwdb[4]; + u8 CckPwEnl; + u16 TSSI_13dBm; + u32 Pwr_Track; + u8 CCKPresentAttentuation_20Mdefault; + u8 CCKPresentAttentuation_40Mdefault; + char CCKPresentAttentuation_difference; + char CCKPresentAttentuation; + u8 bCckHighPower; + long undecorated_smoothed_pwdb; + long undecorated_smoothed_cck_adc_pwdb[4]; - u32 MCSTxPowerLevelOriginalOffset[6]; - u32 CCKTxPowerLevelOriginalOffset; - u8 TxPowerLevelCCK[14]; - u8 TxPowerLevelCCK_A[14]; - u8 TxPowerLevelCCK_C[14]; + u32 MCSTxPowerLevelOriginalOffset[6]; + u32 CCKTxPowerLevelOriginalOffset; + u8 TxPowerLevelCCK[14]; + u8 TxPowerLevelCCK_A[14]; + u8 TxPowerLevelCCK_C[14]; u8 TxPowerLevelOFDM24G[14]; u8 TxPowerLevelOFDM5G[14]; u8 TxPowerLevelOFDM24G_A[14]; @@ -962,7 +986,7 @@ struct r8192_priv { u8 framesyncMonitor; bool bDMInitialGainEnable; - bool MutualAuthenticationFail; + bool MutualAuthenticationFail; bool bDisableFrameBursting; @@ -1016,41 +1040,42 @@ struct r8192_priv { extern const struct ethtool_ops rtl819x_ethtool_ops; void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb); -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb); +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb); u8 read_nic_io_byte(struct net_device *dev, int x); u32 read_nic_io_dword(struct net_device *dev, int x); u16 read_nic_io_word(struct net_device *dev, int x) ; -void write_nic_io_byte(struct net_device *dev, int x,u8 y); -void write_nic_io_word(struct net_device *dev, int x,u16 y); -void write_nic_io_dword(struct net_device *dev, int x,u32 y); +void write_nic_io_byte(struct net_device *dev, int x, u8 y); +void write_nic_io_word(struct net_device *dev, int x, u16 y); +void write_nic_io_dword(struct net_device *dev, int x, u32 y); u8 read_nic_byte(struct net_device *dev, int x); u32 read_nic_dword(struct net_device *dev, int x); u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); +void write_nic_byte(struct net_device *dev, int x, u8 y); +void write_nic_word(struct net_device *dev, int x, u16 y); +void write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); void rtl8192_rx_enable(struct net_device *); void rtl8192_tx_enable(struct net_device *); -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev); -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate); +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev); +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate); void rtl8192_data_hard_stop(struct net_device *dev); void rtl8192_data_hard_resume(struct net_device *dev); void rtl8192_restart(void *data); void rtl819x_watchdog_wqcallback(void *data); -void rtl8192_hw_sleep_wq (void *data); +void rtl8192_hw_sleep_wq(void *data); void watch_dog_timer_callback(unsigned long data); void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); void rtl8192_irq_tx_tasklet(struct r8192_priv *priv); -int rtl8192_down(struct net_device *dev,bool shutdownrf); +int rtl8192_down(struct net_device *dev, bool shutdownrf); int rtl8192_up(struct net_device *dev); void rtl8192_commit(struct net_device *dev); -void rtl8192_set_chan(struct net_device *dev,short ch); +void rtl8192_set_chan(struct net_device *dev, short ch); void check_rfctrl_gpio_timer(unsigned long data); @@ -1059,44 +1084,42 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); short rtl8192_pci_initdescring(struct net_device *dev); -void rtl8192_cancel_deferred_work(struct r8192_priv * priv); +void rtl8192_cancel_deferred_work(struct r8192_priv *priv); -int _rtl8192_up(struct net_device *dev,bool is_silent_reset); +int _rtl8192_up(struct net_device *dev, bool is_silent_reset); short rtl8192_is_tx_queue_empty(struct net_device *dev); void rtl8192_irq_disable(struct net_device *dev); void rtl8192_tx_timeout(struct net_device *dev); void rtl8192_pci_resetdescring(struct net_device *dev); -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode); +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode); void rtl8192_irq_enable(struct net_device *dev); -void rtl8192_config_rate(struct net_device* dev, u16* rate_config); -void rtl8192_update_cap(struct net_device* dev, u16 cap); +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config); +void rtl8192_update_cap(struct net_device *dev, u16 cap); void rtl8192_irq_disable(struct net_device *dev); -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats); -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ); -void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats); +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index); +void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); u8 rtl819x_evm_dbtopercentage(char value); -void rtl819x_process_cck_rxpathsel(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); -u8 rtl819x_query_rxpwrpercentage( char antpower ); -void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats * psrc_stats,struct rtllib_rx_stats * ptarget_stats); +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); +u8 rtl819x_query_rxpwrpercentage(char antpower); +void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats); -bool NicIFEnableNIC(struct net_device* dev); -bool NicIFDisableNIC(struct net_device* dev); +bool NicIFEnableNIC(struct net_device *dev); +bool NicIFDisableNIC(struct net_device *dev); -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ); -void -ActUpdateChannelAccessSetting( - struct net_device* dev, - enum wireless_mode WirelessMode, - struct channel_access_setting *ChnlAccessSetting - ); +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot); +void ActUpdateChannelAccessSetting(struct net_device *dev, + enum wireless_mode WirelessMode, + struct channel_access_setting *ChnlAccessSetting); #endif From 88a9fd04faea535aab4828bd8d1c5ed9f7e90202 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 6 Aug 2011 21:21:07 -0500 Subject: [PATCH 0530/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IX Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_crypto.h | 80 +-- drivers/staging/rtl8192e/rtl_debug.c | 712 +++++++++++++------------- drivers/staging/rtl8192e/rtl_debug.h | 236 ++++----- 3 files changed, 511 insertions(+), 517 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h index 7b4551db961..ee57c0f4fa6 100644 --- a/drivers/staging/rtl8192e/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #define crypto_register_alg crypto_register_alg_rsl #define crypto_unregister_alg crypto_unregister_alg_rsl @@ -73,7 +73,7 @@ struct cipher_alg { unsigned int cia_min_keysize; unsigned int cia_max_keysize; int (*cia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); }; @@ -84,16 +84,16 @@ struct digest_alg { void (*dia_update)(void *ctx, const u8 *data, unsigned int len); void (*dia_final)(void *ctx, u8 *out); int (*dia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); }; struct compress_alg { int (*coa_init)(void *ctx); void (*coa_exit)(void *ctx); int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); }; #define cra_cipher cra_u.cipher @@ -139,15 +139,15 @@ struct cipher_tfm { unsigned int cit_ivsize; u32 cit_mode; int (*cit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); int (*cit_encrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes); int (*cit_encrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv); int (*cit_decrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, @@ -162,21 +162,21 @@ struct cipher_tfm { struct digest_tfm { void (*dit_init)(struct crypto_tfm *tfm); void (*dit_update)(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); + struct scatterlist *sg, unsigned int nsg); void (*dit_final)(struct crypto_tfm *tfm, u8 *out); void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, - unsigned int nsg, u8 *out); + unsigned int nsg, u8 *out); int (*dit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); }; struct compress_tfm { int (*cot_compress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); int (*cot_decompress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); }; #define crt_cipher crt_u.cipher @@ -274,8 +274,8 @@ static inline void crypto_digest_init(struct crypto_tfm *tfm) } static inline void crypto_digest_update(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg) + struct scatterlist *sg, + unsigned int nsg) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_update(tfm, sg, nsg); @@ -288,15 +288,15 @@ static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out) } static inline void crypto_digest_digest(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg, u8 *out) + struct scatterlist *sg, + unsigned int nsg, u8 *out) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_digest(tfm, sg, nsg, out); } static inline int crypto_digest_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); if (tfm->crt_digest.dit_setkey == NULL) @@ -305,25 +305,25 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm, } static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_setkey(tfm, key, keylen); } static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -331,18 +331,18 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, } static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -350,30 +350,30 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, } static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, - const u8 *src, unsigned int len) + const u8 *src, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(tfm->crt_cipher.cit_iv, src, len); } static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, - u8 *dst, unsigned int len) + u8 *dst, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(dst, tfm->crt_cipher.cit_iv, len); } static inline int crypto_comp_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen); } static inline int crypto_comp_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 5c2d01c8b45..22bc2dd6e43 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -53,12 +53,10 @@ u32 DBGP_Type[DBGP_TYPE_MAX]; *---------------------------------------------------------------------------*/ void rtl8192_dbgp_flag_init(struct net_device *dev) { - u8 i; + u8 i; for (i = 0; i < DBGP_TYPE_MAX; i++) - { DBGP_Type[i] = 0; - } } /* DBGP_Flag_Init */ @@ -67,19 +65,19 @@ void rtl8192_dbgp_flag_init(struct net_device *dev) void print_buffer(u32 *buffer, int len) { int i; - u8 *buf =(u8*)buffer; + u8 *buf = (u8 *)buffer; - printk("ASCII BUFFER DUMP (len: %x):\n",len); + printk(KERN_INFO "ASCII BUFFER DUMP (len: %x):\n", len); - for (i=0;i ", n); + printk(KERN_INFO "\nD: %2x> ", n); for (i = 0; i < 16 && n <= max; i++, n++) - printk("%2x ", read_nic_byte(dev, n)); + printk(KERN_INFO "%2x ", read_nic_byte(dev, n)); } - printk("\n"); + printk(KERN_INFO "\n"); } /**************************************************************************** -----------------------------PROCFS STUFF------------------------- *****************************************************************************/ /*This part is related to PROC, which will record some statistics. */ -static struct proc_dir_entry *rtl8192_proc = NULL; +static struct proc_dir_entry *rtl8192_proc; static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, @@ -123,24 +121,21 @@ static int proc_get_stats_ap(char *page, char **start, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; struct rtllib_network *target; - int len = 0; - list_for_each_entry(target, &ieee->network_list, list) { + list_for_each_entry(target, &ieee->network_list, list) { len += snprintf(page + len, count - len, - "%s ", target->ssid); + "%s ", target->ssid); - if (target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) + len += snprintf(page + len, count - len, + "WPA\n"); + else + len += snprintf(page + len, count - len, + "non_WPA\n"); - } + } *eof = 1; return len; @@ -153,25 +148,25 @@ static int proc_get_registers_0(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x000; - { - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;n++,i++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; n++, i++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -183,25 +178,27 @@ static int proc_get_registers_1(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x100; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -213,25 +210,27 @@ static int proc_get_registers_2(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x200; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0 >> 8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -243,25 +242,27 @@ static int proc_get_registers_3(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x300; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -273,117 +274,125 @@ static int proc_get_registers_4(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x400; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } static int proc_get_registers_5(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x500; + int max = 0xff; + page0 = 0x500; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_6(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x600; + int max = 0xff; + page0 = 0x600; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_7(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x700; + int max = 0xff; + page0 = 0x700; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_8(char *page, char **start, @@ -393,22 +402,23 @@ static int proc_get_registers_8(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x800; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -420,22 +430,23 @@ static int proc_get_registers_9(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x900; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -446,22 +457,23 @@ static int proc_get_registers_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xa00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -472,22 +484,23 @@ static int proc_get_registers_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xb00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -498,22 +511,23 @@ static int proc_get_registers_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xc00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -524,22 +538,23 @@ static int proc_get_registers_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xd00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -550,22 +565,23 @@ static int proc_get_registers_e(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xe00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -577,21 +593,22 @@ static int proc_get_reg_rf_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-A ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_A,n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_A, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -603,21 +620,22 @@ static int proc_get_reg_rf_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-B ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_B, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_B, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -629,21 +647,22 @@ static int proc_get_reg_rf_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### RF-C ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n#################### RF-C ##################\n"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_C, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_C, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -655,21 +674,22 @@ static int proc_get_reg_rf_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-D ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_D, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_D, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -679,41 +699,38 @@ static int proc_get_cam_register_1(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (0-10) ##################\n "); - for (j=0; j<11; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i+CAM_CONTENT_COUNT*j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -723,41 +740,38 @@ static int proc_get_cam_register_2(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (11-21) ##################\n "); - for (j=11; j<22; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -767,41 +781,38 @@ static int proc_get_cam_register_3(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (22-31) ##################\n "); - for (j=22; j ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -877,7 +888,7 @@ static int proc_get_stats_rx(char *page, char **start, void rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); + rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); } @@ -891,7 +902,7 @@ void rtl8192_proc_remove_one(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - printk("dev name %s\n",dev->name); + printk(KERN_INFO "dev name %s\n", dev->name); if (priv->dir_dev) { remove_proc_entry("stats-tx", priv->dir_dev); @@ -929,194 +940,169 @@ void rtl8192_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtl8192_proc); if (!priv->dir_dev) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); + RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192" + "/%s\n", dev->name); return; } e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - if (!e) { - RT_TRACE(COMP_ERR,"Unable to initialize " + if (!e) + RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-rx\n", dev->name); - } - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-tx\n", dev->name); - } e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-ap\n", dev->name); - } e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_0, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-0\n", dev->name); - } e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-1\n", dev->name); - } e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-2\n", dev->name); - } e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-3\n", dev->name); - } e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_4, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-4\n", dev->name); - } e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_5, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-5\n", dev->name); - } e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_6, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-6\n", dev->name); - } e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_7, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-7\n", dev->name); - } e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_8, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-8\n", dev->name); - } e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_9, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-9\n", dev->name); - } e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-a\n", dev->name); - } e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-b\n", dev->name); - } e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-c\n", dev->name); - } e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-d\n", dev->name); - } e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_e, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-e\n", dev->name); - } e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-A\n", dev->name); - } e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-B\n", dev->name); - } e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-C\n", dev->name); - } e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-D\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-1\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-2\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-3\n", dev->name); - } } diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 415dfca6b37..50fb9a9b828 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -36,31 +36,30 @@ struct net_device; #define DBG_LOUD 4 -#define RT_ASSERT(_Exp,Fmt) \ - if (!(_Exp)) \ - { \ - printk("Rtl819x: "); \ - printk Fmt; \ +#define RT_ASSERT(_Exp, Fmt) \ + if (!(_Exp)) { \ + printk("Rtl819x: "); \ + printk Fmt; \ } enum dbgp_flag { FQoS = 0, - FTX = 1, - FRX = 2, + FTX = 1, + FRX = 2, FSEC = 3, FMGNT = 4, FMLME = 5, FRESOURCE = 6, - FBEACON = 7, + FBEACON = 7, FISR = 8, FPHY = 9, - FMP = 10, - FEEPROM = 11, + FMP = 10, + FEEPROM = 11, FPWR = 12, - FDM = 13, - FDBGCtrl = 14, + FDM = 13, + FDBGCtrl = 14, FC2H = 15, - FBT = 16, + FBT = 16, FINIT = 17, FIOCTL = 18, DBGP_TYPE_MAX @@ -76,10 +75,10 @@ enum dbgp_flag { #define RX_PHY_STS BIT1 #define RX_PHY_SS BIT2 #define RX_PHY_SQ BIT3 -#define RX_PHY_ASTS BIT4 +#define RX_PHY_ASTS BIT4 #define RX_ERR_LEN BIT5 #define RX_DEFRAG BIT6 -#define RX_ERR_RATE BIT7 +#define RX_ERR_RATE BIT7 @@ -93,68 +92,68 @@ enum dbgp_flag { #define ISR_CHK BIT0 -#define PHY_BBR BIT0 -#define PHY_BBW BIT1 -#define PHY_RFR BIT2 -#define PHY_RFW BIT3 +#define PHY_BBR BIT0 +#define PHY_BBW BIT1 +#define PHY_RFR BIT2 +#define PHY_RFW BIT3 #define PHY_MACR BIT4 #define PHY_MACW BIT5 #define PHY_ALLR BIT6 #define PHY_ALLW BIT7 #define PHY_TXPWR BIT8 -#define PHY_PWRDIFF BIT9 +#define PHY_PWRDIFF BIT9 #define MP_RX BIT0 -#define MP_SWICH_CH BIT1 +#define MP_SWICH_CH BIT1 #define EEPROM_W BIT0 #define EFUSE_PG BIT1 -#define EFUSE_READ_ALL BIT2 +#define EFUSE_READ_ALL BIT2 -#define LPS BIT0 -#define IPS BIT1 +#define LPS BIT0 +#define IPS BIT1 #define PWRSW BIT2 #define PWRHW BIT3 #define PWRHAL BIT4 #define WA_IOT BIT0 -#define DM_PWDB BIT1 +#define DM_PWDB BIT1 #define DM_Monitor BIT2 #define DM_DIG BIT3 -#define DM_EDCA_Turbo BIT4 +#define DM_EDCA_Turbo BIT4 -#define DbgCtrl_Trace BIT0 -#define DbgCtrl_InbandNoise BIT1 +#define DbgCtrl_Trace BIT0 +#define DbgCtrl_InbandNoise BIT1 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 -#define C2H_Summary BIT0 -#define C2H_PacketData BIT1 -#define C2H_ContentData BIT2 +#define C2H_Summary BIT0 +#define C2H_PacketData BIT1 +#define C2H_ContentData BIT2 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 #define INIT_EEPROM BIT0 -#define INIT_TxPower BIT1 +#define INIT_TxPower BIT1 #define INIT_IQK BIT2 #define INIT_RF BIT3 -#define IOCTL_TRACE BIT0 -#define IOCTL_BT_EVENT BIT1 +#define IOCTL_TRACE BIT0 +#define IOCTL_BT_EVENT BIT1 #define IOCTL_BT_EVENT_DETAIL BIT2 #define IOCTL_BT_TX_ACLDATA BIT3 #define IOCTL_BT_TX_ACLDATA_DETAIL BIT4 #define IOCTL_BT_RX_ACLDATA BIT5 -#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 +#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 #define IOCTL_BT_HCICMD BIT7 #define IOCTL_BT_HCICMD_DETAIL BIT8 -#define IOCTL_IRP BIT9 -#define IOCTL_IRP_DETAIL BIT10 -#define IOCTL_CALLBACK_FUN BIT11 -#define IOCTL_STATE BIT12 -#define IOCTL_BT_TP BIT13 -#define IOCTL_BT_LOGO BIT14 +#define IOCTL_IRP BIT9 +#define IOCTL_IRP_DETAIL BIT10 +#define IOCTL_CALLBACK_FUN BIT11 +#define IOCTL_STATE BIT12 +#define IOCTL_BT_TP BIT13 +#define IOCTL_BT_LOGO BIT14 /* 2007/07/13 MH ------For DeBuG Print modeue------*/ /*------------------------------Define structure----------------------------*/ @@ -164,97 +163,98 @@ enum dbgp_flag { #define DEBUG_PRINT 1 #if (DEBUG_PRINT == 1) -#define RTPRINT(dbgtype, dbgflag, printstr) \ -{ \ - if (DBGP_Type[dbgtype] & dbgflag)\ - { \ +#define RTPRINT(dbgtype, dbgflag, printstr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ printk printstr; \ - } \ + } \ } -#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_Ptr; \ - printk printstr; \ - printk(" "); \ - for ( __i=0; __i<6; __i++ ) \ - printk("%02X%s", ptr[__i], (__i==5)?"":"-"); \ - printk("\n"); \ - }\ +#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_Ptr; \ + printk printstr; \ + printk(" "); \ + for (__i = 0; __i < 6; __i++) \ + printk("%02X%s", ptr[__i], \ + (__i == 5) ? "" : "-"); \ + printk("\n"); \ + } \ } #define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\ - if (((__i + 1) % 16) == 0) printk("\n");\ - } \ - printk("\n"); \ - }\ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_HexData; \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) \ + % 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ + } \ } #else #define RTPRINT(dbgtype, dbgflag, printstr) #define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) -#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) +#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) #endif extern u32 DBGP_Type[DBGP_TYPE_MAX]; -#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ +#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ do {\ - if (((_Comp) & rt_global_debug_component ) && (_Level <= rt_global_debug_component )) \ - { \ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk("Rtl819x: "); \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \ - if (((__i + 1) % 16) == 0) printk("\n"); \ - } \ - printk("\n"); \ + if (((_Comp) & rt_global_debug_component) && \ + (_Level <= rt_global_debug_component)) { \ + int __i; \ + u8* ptr = (u8 *)_HexData; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) % \ + 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ } \ -}while(0); +} while (0); -#define DMESG(x,a...) -#define DMESGW(x,a...) -#define DMESGE(x,a...) +#define DMESG(x, a...) +#define DMESGW(x, a...) +#define DMESGE(x, a...) extern u32 rt_global_debug_component; #define RT_TRACE(component, x, args...) \ -do { if (rt_global_debug_component & component) \ - printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ - ##args);\ -}while(0); +do { \ + if (rt_global_debug_component & component) \ + printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ + ##args);\ +} while (0); #define assert(expr) \ - if (!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n", \ - #expr,__FILE__,__func__,__LINE__); \ - } + if (!(expr)) { \ + printk(KERN_INFO "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr, __FILE__, __func__, __LINE__); \ + } #define RT_DEBUG_DATA(level, data, datalen) \ - do{ if ((rt_global_debug_component & (level)) == (level)) \ - { \ - int _i; \ - u8* _pdata = (u8*) data; \ - printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ - for (_i=0; _i<(int)(datalen); _i++) \ - { \ - printk("%2x ", _pdata[_i]); \ - if ((_i+1)%16 == 0) printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) + do { \ + if ((rt_global_debug_component & (level)) == (level)) {\ + int _i; \ + u8 *_pdata = (u8 *)data; \ + printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ + for (_i = 0; _i < (int)(datalen); _i++) { \ + printk(KERN_INFO "%2x ", _pdata[_i]); \ + if ((_i+1) % 16 == 0) \ + printk("\n"); \ + } \ + printk(KERN_INFO "\n"); \ + } \ + } while (0) struct rtl_fs_debug { const char *name; @@ -270,16 +270,23 @@ void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); /* debugfs stuff */ -static inline int rtl_debug_module_init(struct r8192_priv *priv, const char *name) { +static inline int rtl_debug_module_init(struct r8192_priv *priv, + const char *name) +{ return 0; } -static inline void rtl_debug_module_remove(struct r8192_priv *priv) { +static inline void rtl_debug_module_remove(struct r8192_priv *priv) +{ } -static inline int rtl_create_debugfs_root(void) { + +static inline int rtl_create_debugfs_root(void) +{ return 0; } -static inline void rtl_remove_debugfs_root(void) { + +static inline void rtl_remove_debugfs_root(void) +{ } /* proc stuff */ @@ -288,4 +295,5 @@ void rtl8192_proc_remove_one(struct net_device *dev); void rtl8192_proc_module_init(void); void rtl8192_proc_module_remove(void); void rtl8192_dbgp_flag_init(struct net_device *dev); + #endif From b2a3fff4bfd113e0309bc6bd7734b9ce9cdd1943 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 15:05:00 -0500 Subject: [PATCH 0531/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part X With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.c | 2442 +++++++++++++---------------- drivers/staging/rtl8192e/rtl_dm.h | 61 +- 2 files changed, 1128 insertions(+), 1375 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 3ab71c78634..291ec3e9d22 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -25,37 +25,37 @@ #include "r8192E_cmdpkt.h" /*---------------------------Define Local Constant---------------------------*/ -static u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4332 - }; - -static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4322 +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4332 }; -static u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0xa44f, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0x5e4322, - 0x5e4322, - 0x5e4332 +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0x5e4322, + 0x5e4322, + 0x5e4332 }; #define RTK_UL_EDCA 0xa44f @@ -65,7 +65,10 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = /*------------------------Define global variable-----------------------------*/ struct dig_t dm_digtable; -u8 dm_shadow[16][256] = {{0}}; +u8 dm_shadow[16][256] = { + {0} +}; + struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ @@ -74,46 +77,12 @@ struct drx_path_sel DM_RxPathSelTable; /*------------------------Define local variable------------------------------*/ -/*--------------------Define export function prototype-----------------------*/ -extern void init_hal_dm(struct net_device *dev); -extern void deinit_hal_dm(struct net_device *dev); - -extern void hal_dm_watchdog(struct net_device *dev); - - -extern void init_rate_adaptive(struct net_device *dev); -extern void dm_txpower_trackingcallback(void *data); - -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); -extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); -extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); -extern void dm_rf_pathcheck_workitemcallback(void *data); -extern void dm_fsync_timer_callback(unsigned long data); -extern void dm_check_fsync(struct net_device *dev); -extern void dm_shadow_init(struct net_device *dev); -extern void dm_initialize_txpower_tracking(struct net_device *dev); - -extern void dm_CheckRfCtrlGPIO(void *data); - - -/*--------------------Define export function prototype-----------------------*/ - /*---------------------Define local function prototype-----------------------*/ static void dm_check_rate_adaptive(struct net_device *dev); -static void dm_init_bandwidth_autoswitch (struct net_device *dev); -static void dm_bandwidth_autoswitch ( struct net_device *dev); +static void dm_init_bandwidth_autoswitch(struct net_device *dev); +static void dm_bandwidth_autoswitch(struct net_device *dev); static void dm_check_txpower_tracking(struct net_device *dev); @@ -130,7 +99,7 @@ static void dm_bb_initialgain_backup(struct net_device *dev); static void dm_dig_init(struct net_device *dev); static void dm_ctrl_initgain_byrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev); -static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev); +static void dm_ctrl_initgain_byrssi_by_driverrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev); static void dm_initial_gain(struct net_device *dev); static void dm_pd_th(struct net_device *dev); @@ -179,14 +148,14 @@ init_hal_dm(struct net_device *dev) dm_dig_init(dev); dm_init_edca_turbo(dev); - dm_init_bandwidth_autoswitch (dev); + dm_init_bandwidth_autoswitch(dev); dm_init_fsync(dev); dm_init_rxpath_selection(dev); dm_init_ctstoself(dev); - if (IS_HARDWARE_TYPE_8192SE(dev)) - dm_Init_WA_Broadcom_IOT(dev); + if (IS_HARDWARE_TYPE_8192SE(dev)) + dm_Init_WA_Broadcom_IOT(dev); - INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO,dev); + INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } extern void deinit_hal_dm(struct net_device *dev) @@ -213,7 +182,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_check_txpower_tracking(dev); dm_ctrl_initgain_byrssi(dev); - dm_bandwidth_autoswitch (dev); + dm_bandwidth_autoswitch(dev); dm_check_rx_path_selection(dev); dm_check_fsync(dev); @@ -226,28 +195,27 @@ void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; - char *argv[] = {ac_dc_check_script_path,DRV_NAME,NULL}; + char *argv[] = {ac_dc_check_script_path, DRV_NAME, NULL}; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - if (priv->ResetProgress == RESET_TYPE_SILENT) - { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); + if (priv->ResetProgress == RESET_TYPE_SILENT) { + RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), + "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); return; } - if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->state != RTLLIB_LINKED) return; - } - call_usermodehelper(ac_dc_check_script_path,argv,envp,1); + call_usermodehelper(ac_dc_check_script_path, argv, envp, 1); return; }; -extern void init_rate_adaptive(struct net_device * dev) +extern void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -269,17 +237,14 @@ extern void init_rate_adaptive(struct net_device * dev) pra->ping_rssi_thresh_for_ra = 15; - if (priv->rf_type == RF_2T4R) - { + if (priv->rf_type == RF_2T4R) { pra->upper_rssi_threshold_ratr = 0x8f0f0000; pra->middle_rssi_threshold_ratr = 0x8f0ff000; pra->low_rssi_threshold_ratr = 0x8f0ff001; pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; pra->ping_rssi_ratr = 0x0000000d; - } - else if (priv->rf_type == RF_1T2R) - { + } else if (priv->rf_type == RF_1T2R) { pra->upper_rssi_threshold_ratr = 0x000fc000; pra->middle_rssi_threshold_ratr = 0x000ff000; pra->low_rssi_threshold_ratr = 0x000ff001; @@ -291,17 +256,17 @@ extern void init_rate_adaptive(struct net_device * dev) } -static void dm_check_rate_adaptive(struct net_device * dev) +static void dm_check_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; - u32 currentRATR, targetRATR = 0; - u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; - bool bshort_gi_enabled = false; - static u8 ping_rssi_state=0; + u32 currentRATR, targetRATR = 0; + u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; + bool bshort_gi_enabled = false; + static u8 ping_rssi_state; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); return; } @@ -309,83 +274,66 @@ static void dm_check_rate_adaptive(struct net_device * dev) if (pra->rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode == WIRELESS_MODE_N_24G || - priv->rtllib->mode == WIRELESS_MODE_N_5G)) - return; + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; - if ( priv->rtllib->state == RTLLIB_LINKED ) - { + if (priv->rtllib->state == RTLLIB_LINKED) { bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - } - else - { + (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + } else { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); } pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (pra->ratr_state == DM_RATR_STA_HIGH) - { + if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); - } - else if (pra->ratr_state == DM_RATR_STA_LOW) - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); + } else if (pra->ratr_state == DM_RATR_STA_LOW) { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); - } - else - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M); + } else { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } - if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) - { + if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_HIGH; targetRATR = pra->upper_rssi_threshold_ratr; - }else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) - { + } else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_MIDDLE; targetRATR = pra->middle_rssi_threshold_ratr; - }else - { + } else { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->low_rssi_threshold_ratr; } - if (pra->ping_rssi_enable) - { - if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) - { - if ( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || - ping_rssi_state ) - { + if (pra->ping_rssi_enable) { + if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) { + if ((priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || + ping_rssi_state) { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->ping_rssi_ratr; ping_rssi_state = 1; } - } - else - { + } else { ping_rssi_state = 0; } } @@ -394,30 +342,26 @@ static void dm_check_rate_adaptive(struct net_device * dev) targetRATR &= 0xf00fffff; currentRATR = read_nic_dword(dev, RATR0); - if ( targetRATR != currentRATR ) - { + if (targetRATR != currentRATR) { u32 ratr_value; ratr_value = targetRATR; - RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR); + RT_TRACE(COMP_RATE, + "currentRATR = %x, targetRATR = %x\n", + currentRATR, targetRATR); if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); pra->last_ratr = targetRATR; } - } - else - { + } else { pra->ratr_state = DM_RATR_STA_MAX; } - } -static void dm_init_bandwidth_autoswitch (struct net_device * dev) +static void dm_init_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -425,22 +369,23 @@ static void dm_init_bandwidth_autoswitch (struct net_device * dev) priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW; priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; priv->rtllib->bandwidth_auto_switch.bautoswitch_enable = false; - } - -static void dm_bandwidth_autoswitch (struct net_device * dev) +static void dm_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->rtllib->bandwidth_auto_switch.bautoswitch_enable){ + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || + !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) { return; - }else{ - if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false){ - if (priv->undecorated_smoothed_pwdb <= priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) + } else { + if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) { + if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true; - }else{ - if (priv->undecorated_smoothed_pwdb >= priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) + } else { + if (priv->undecorated_smoothed_pwdb >= + priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; } @@ -468,6 +413,7 @@ static u32 OFDMSwingTable[OFDM_Table_Length] = { 0x12000048, 0x10000040 }; + static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, @@ -497,25 +443,27 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} }; + #define Pw_Track_Flag 0x11d #define Tssi_Mea_Value 0x13c #define Tssi_Report_Value1 0x134 #define Tssi_Report_Value2 0x13e #define FW_Busy_Flag 0x13f -static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) - { +static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) +{ struct r8192_priv *priv = rtllib_priv(dev); - bool bHighpowerstate, viviflag = false; + bool bHighpowerstate, viviflag = false; struct dcmd_txcmd tx_cmd; - u8 powerlevelOFDM24G; - int i =0, j = 0, k = 0; - u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; - u32 Value; - u8 Pwr_Flag; - u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; - u32 delta=0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); + u8 powerlevelOFDM24G; + int i = 0, j = 0, k = 0; + u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0}; + u32 Value; + u8 Pwr_Flag; + u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0; + u32 delta = 0; + + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); priv->rtllib->bdynamic_txpower_enable = false; @@ -525,305 +473,312 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) RF_Type = priv->rf_type; Value = (RF_Type<<8) | powerlevelOFDM24G; - RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); + RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", + powerlevelOFDM24G); - for (j = 0; j<=30; j++) -{ + for (j = 0; j <= 30; j++) { - tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; - tx_cmd.Length = 4; - tx_cmd.Value = Value; - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); - mdelay(1); - for (i = 0;i <= 30; i++) - { - Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); + tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; + tx_cmd.Length = 4; + tx_cmd.Value = Value; + cmpk_message_handle_tx(dev, (u8 *)&tx_cmd, + DESC_PACKET_TYPE_INIT, + sizeof(struct dcmd_txcmd)); + mdelay(1); + for (i = 0; i <= 30; i++) { + Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); - if (Pwr_Flag == 0) - { - mdelay(1); + if (Pwr_Flag == 0) { + mdelay(1); - if (priv->bResetInProgress) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in slient reset progress, so return\n"); - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; + if (priv->bResetInProgress) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in slient reset progress, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + if ((priv->rtllib->eRFPowerState != eRfOn)) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in power save, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + + continue; } - if ((priv->rtllib->eRFPowerState != eRfOn)) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in power save, so return\n"); + + Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + + if (Avg_TSSI_Meas == 0) { write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); return; } - continue; - } + for (k = 0; k < 5; k++) { + if (k != 4) + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value1+k); + else + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value2); - Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + RT_TRACE(COMP_POWER_TRACKING, + "TSSI_report_value = %d\n", + tmp_report[k]); - if (Avg_TSSI_Meas == 0) - { - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; - } + if (tmp_report[k] <= 20) { + viviflag = true; + break; + } + } - for (k = 0;k < 5; k++) - { - if (k !=4) - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value1+k); + if (viviflag == true) { + write_nic_byte(dev, Pw_Track_Flag, 0); + viviflag = false; + RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); + for (k = 0; k < 5; k++) + tmp_report[k] = 0; + break; + } + + for (k = 0; k < 5; k++) + Avg_TSSI_Meas_from_driver += tmp_report[k]; + + Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; + RT_TRACE(COMP_POWER_TRACKING, + "Avg_TSSI_Meas_from_driver = %d\n", + Avg_TSSI_Meas_from_driver); + TSSI_13dBm = priv->TSSI_13dBm; + RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); + + if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) + delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; else - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value2); + delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]); + if (delta <= E_FOR_TX_POWER_TRACK) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, + "tx power track is done\n"); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + return; + } else { + if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) { + if (RF_Type == RF_2T4R) { - { - if (tmp_report[k] <= 20) - { - viviflag =true; - break; - } - } - } + if ((priv->rfa_txpowertrackingindex > 0) && + (priv->rfc_txpowertrackingindex > 0)) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } - if (viviflag ==true) - { + priv->rfc_txpowertrackingindex--; + if (priv->rfc_txpowertrackingindex_real > 4) { + priv->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[4].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex > 0) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + + } + } else { + if (RF_Type == RF_2T4R) { + if ((priv->rfa_txpowertrackingindex < + TxBBGainTableLength - 1) && + (priv->rfc_txpowertrackingindex < + TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table + [priv->rfa_txpowertrackingindex_real].txbbgain_value); + priv->rfc_txpowertrackingindex++; + priv->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } else { + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } + if (RF_Type == RF_2T4R) { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; + } else { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; + } + + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + else + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + if (priv->CCKPresentAttentuation > -1 && + priv->CCKPresentAttentuation < CCKTxBBGainTableLength) { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + + if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); + return; + } + } write_nic_byte(dev, Pw_Track_Flag, 0); - viviflag = false; - RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); - for (k = 0;k < 5; k++) + Avg_TSSI_Meas_from_driver = 0; + for (k = 0; k < 5; k++) tmp_report[k] = 0; break; } - - for (k = 0;k < 5; k++) - { - Avg_TSSI_Meas_from_driver += tmp_report[k]; - } - - Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; - RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); - TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); - - if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) - delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; - else - delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - - if (delta <= E_FOR_TX_POWER_TRACK) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - return; - } - else - { - if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) - { - if (RF_Type == RF_2T4R) - { - - if ((priv->rfa_txpowertrackingindex > 0) &&(priv->rfc_txpowertrackingindex > 0)) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - - priv->rfc_txpowertrackingindex--; - if (priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex > 0) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - - } - } - else - { - if (RF_Type == RF_2T4R) - { - if ((priv->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&(priv->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - } - } - if (RF_Type == RF_2T4R){ - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; - }else{ - { - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; - } - } - - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; - else - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->CCKPresentAttentuation > -1&&priv->CCKPresentAttentuation < CCKTxBBGainTableLength) - { - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); - return; - } - - + write_nic_byte(dev, FW_Busy_Flag, 0); } - write_nic_byte(dev, Pw_Track_Flag, 0); - Avg_TSSI_Meas_from_driver = 0; - for (k = 0;k < 5; k++) - tmp_report[k] = 0; - break; - } - write_nic_byte(dev, FW_Busy_Flag, 0); -} - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); } -static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) +static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev) { #define ThermalMeterVal 9 struct r8192_priv *priv = rtllib_priv(dev); u32 tmpRegA, TempCCk; u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; - int i =0, CCKSwingNeedUpdate=0; + int i = 0, CCKSwingNeedUpdate = 0; - if (!priv->btxpower_trackingInit) - { - tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); - for (i=0; iOFDM_index[0]= (u8)i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n", + if (!priv->btxpower_trackingInit) { + tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + for (i = 0; i < OFDM_Table_Length; i++) { + if (tmpRegA == OFDMSwingTable[i]) { + priv->OFDM_index[0] = (u8)i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]); } } TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); - for (i=0 ; iCCK_index =(u8) i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n", - rCCK0_TxFilter1, TempCCk, priv->CCK_index); - break; - } -} + for (i = 0; i < CCK_Table_length; i++) { + if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) { + priv->CCK_index = (u8) i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x" + " = 0x%x, CCK_index = 0x%x\n", + rCCK0_TxFilter1, TempCCk, + priv->CCK_index); + break; + } + } priv->btxpower_trackingInit = true; return; } tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); - RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA); if (tmpRegA < 3 || tmpRegA > 13) return; if (tmpRegA >= 12) tmpRegA = 12; - RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA); priv->ThermalMeter[0] = ThermalMeterVal; priv->ThermalMeter[1] = ThermalMeterVal; - if (priv->ThermalMeter[0] >= (u8)tmpRegA) - { - tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA); + if (priv->ThermalMeter[0] >= (u8)tmpRegA) { + tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0] - + (u8)tmpRegA); tmpCCK40Mindex = tmpCCK20Mindex - 6; if (tmpOFDMindex >= OFDM_Table_Length) tmpOFDMindex = OFDM_Table_Length-1; @@ -831,9 +786,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) tmpCCK20Mindex = CCK_Table_length-1; if (tmpCCK40Mindex >= CCK_Table_length) tmpCCK40Mindex = CCK_Table_length-1; - } - else - { + } else { tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]); if (tmpval >= 6) tmpOFDMindex = tmpCCK20Mindex = 0; @@ -848,43 +801,42 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) priv->Record_CCK_20Mindex = tmpCCK20Mindex; priv->Record_CCK_40Mindex = tmpCCK40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", - priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); + RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40" + "Mindex = %d / %d.\n", + priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { priv->bcck_in_ch14 = true; CCKSwingNeedUpdate = 1; - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { + } else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) { priv->bcck_in_ch14 = false; CCKSwingNeedUpdate = 1; } - if (priv->CCK_index != tmpCCKindex) -{ + if (priv->CCK_index != tmpCCKindex) { priv->CCK_index = tmpCCKindex; CCKSwingNeedUpdate = 1; } if (CCKSwingNeedUpdate) - { dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - } - if (priv->OFDM_index[0] != tmpOFDMindex) - { + if (priv->OFDM_index[0] != tmpOFDMindex) { priv->OFDM_index[0] = tmpOFDMindex; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index[0]]); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + OFDMSwingTable[priv->OFDM_index[0]]); RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", - priv->OFDM_index[0], OFDMSwingTable[priv->OFDM_index[0]]); + priv->OFDM_index[0], + OFDMSwingTable[priv->OFDM_index[0]]); } priv->txpower_count = 0; } void dm_txpower_trackingcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,txpower_tracking_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; if (priv->IC_Cut >= IC_VersionCut_D) @@ -898,80 +850,80 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); - priv->txbbgain_table[0].txbb_iq_amplifygain = 12; - priv->txbbgain_table[0].txbbgain_value=0x7f8001fe; - priv->txbbgain_table[1].txbb_iq_amplifygain = 11; - priv->txbbgain_table[1].txbbgain_value=0x788001e2; - priv->txbbgain_table[2].txbb_iq_amplifygain = 10; - priv->txbbgain_table[2].txbbgain_value=0x71c001c7; - priv->txbbgain_table[3].txbb_iq_amplifygain = 9; - priv->txbbgain_table[3].txbbgain_value=0x6b8001ae; - priv->txbbgain_table[4].txbb_iq_amplifygain = 8; - priv->txbbgain_table[4].txbbgain_value=0x65400195; - priv->txbbgain_table[5].txbb_iq_amplifygain = 7; - priv->txbbgain_table[5].txbbgain_value=0x5fc0017f; - priv->txbbgain_table[6].txbb_iq_amplifygain = 6; - priv->txbbgain_table[6].txbbgain_value=0x5a400169; - priv->txbbgain_table[7].txbb_iq_amplifygain = 5; - priv->txbbgain_table[7].txbbgain_value=0x55400155; - priv->txbbgain_table[8].txbb_iq_amplifygain = 4; - priv->txbbgain_table[8].txbbgain_value=0x50800142; - priv->txbbgain_table[9].txbb_iq_amplifygain = 3; - priv->txbbgain_table[9].txbbgain_value=0x4c000130; - priv->txbbgain_table[10].txbb_iq_amplifygain = 2; - priv->txbbgain_table[10].txbbgain_value=0x47c0011f; - priv->txbbgain_table[11].txbb_iq_amplifygain = 1; - priv->txbbgain_table[11].txbbgain_value=0x43c0010f; - priv->txbbgain_table[12].txbb_iq_amplifygain = 0; - priv->txbbgain_table[12].txbbgain_value=0x40000100; - priv->txbbgain_table[13].txbb_iq_amplifygain = -1; - priv->txbbgain_table[13].txbbgain_value=0x3c8000f2; - priv->txbbgain_table[14].txbb_iq_amplifygain = -2; - priv->txbbgain_table[14].txbbgain_value=0x390000e4; - priv->txbbgain_table[15].txbb_iq_amplifygain = -3; - priv->txbbgain_table[15].txbbgain_value=0x35c000d7; - priv->txbbgain_table[16].txbb_iq_amplifygain = -4; - priv->txbbgain_table[16].txbbgain_value=0x32c000cb; - priv->txbbgain_table[17].txbb_iq_amplifygain = -5; - priv->txbbgain_table[17].txbbgain_value=0x300000c0; - priv->txbbgain_table[18].txbb_iq_amplifygain = -6; - priv->txbbgain_table[18].txbbgain_value=0x2d4000b5; - priv->txbbgain_table[19].txbb_iq_amplifygain = -7; - priv->txbbgain_table[19].txbbgain_value=0x2ac000ab; - priv->txbbgain_table[20].txbb_iq_amplifygain = -8; - priv->txbbgain_table[20].txbbgain_value=0x288000a2; - priv->txbbgain_table[21].txbb_iq_amplifygain = -9; - priv->txbbgain_table[21].txbbgain_value=0x26000098; - priv->txbbgain_table[22].txbb_iq_amplifygain = -10; - priv->txbbgain_table[22].txbbgain_value=0x24000090; - priv->txbbgain_table[23].txbb_iq_amplifygain = -11; - priv->txbbgain_table[23].txbbgain_value=0x22000088; - priv->txbbgain_table[24].txbb_iq_amplifygain = -12; - priv->txbbgain_table[24].txbbgain_value=0x20000080; - priv->txbbgain_table[25].txbb_iq_amplifygain = -13; - priv->txbbgain_table[25].txbbgain_value=0x1a00006c; - priv->txbbgain_table[26].txbb_iq_amplifygain = -14; - priv->txbbgain_table[26].txbbgain_value=0x1c800072; - priv->txbbgain_table[27].txbb_iq_amplifygain = -15; - priv->txbbgain_table[27].txbbgain_value=0x18000060; - priv->txbbgain_table[28].txbb_iq_amplifygain = -16; - priv->txbbgain_table[28].txbbgain_value=0x19800066; - priv->txbbgain_table[29].txbb_iq_amplifygain = -17; - priv->txbbgain_table[29].txbbgain_value=0x15800056; - priv->txbbgain_table[30].txbb_iq_amplifygain = -18; - priv->txbbgain_table[30].txbbgain_value=0x26c0005b; - priv->txbbgain_table[31].txbb_iq_amplifygain = -19; - priv->txbbgain_table[31].txbbgain_value=0x14400051; - priv->txbbgain_table[32].txbb_iq_amplifygain = -20; - priv->txbbgain_table[32].txbbgain_value=0x24400051; - priv->txbbgain_table[33].txbb_iq_amplifygain = -21; - priv->txbbgain_table[33].txbbgain_value=0x1300004c; - priv->txbbgain_table[34].txbb_iq_amplifygain = -22; - priv->txbbgain_table[34].txbbgain_value=0x12000048; - priv->txbbgain_table[35].txbb_iq_amplifygain = -23; - priv->txbbgain_table[35].txbbgain_value=0x11000044; - priv->txbbgain_table[36].txbb_iq_amplifygain = -24; - priv->txbbgain_table[36].txbbgain_value=0x10000040; + priv->txbbgain_table[0].txbb_iq_amplifygain = 12; + priv->txbbgain_table[0].txbbgain_value = 0x7f8001fe; + priv->txbbgain_table[1].txbb_iq_amplifygain = 11; + priv->txbbgain_table[1].txbbgain_value = 0x788001e2; + priv->txbbgain_table[2].txbb_iq_amplifygain = 10; + priv->txbbgain_table[2].txbbgain_value = 0x71c001c7; + priv->txbbgain_table[3].txbb_iq_amplifygain = 9; + priv->txbbgain_table[3].txbbgain_value = 0x6b8001ae; + priv->txbbgain_table[4].txbb_iq_amplifygain = 8; + priv->txbbgain_table[4].txbbgain_value = 0x65400195; + priv->txbbgain_table[5].txbb_iq_amplifygain = 7; + priv->txbbgain_table[5].txbbgain_value = 0x5fc0017f; + priv->txbbgain_table[6].txbb_iq_amplifygain = 6; + priv->txbbgain_table[6].txbbgain_value = 0x5a400169; + priv->txbbgain_table[7].txbb_iq_amplifygain = 5; + priv->txbbgain_table[7].txbbgain_value = 0x55400155; + priv->txbbgain_table[8].txbb_iq_amplifygain = 4; + priv->txbbgain_table[8].txbbgain_value = 0x50800142; + priv->txbbgain_table[9].txbb_iq_amplifygain = 3; + priv->txbbgain_table[9].txbbgain_value = 0x4c000130; + priv->txbbgain_table[10].txbb_iq_amplifygain = 2; + priv->txbbgain_table[10].txbbgain_value = 0x47c0011f; + priv->txbbgain_table[11].txbb_iq_amplifygain = 1; + priv->txbbgain_table[11].txbbgain_value = 0x43c0010f; + priv->txbbgain_table[12].txbb_iq_amplifygain = 0; + priv->txbbgain_table[12].txbbgain_value = 0x40000100; + priv->txbbgain_table[13].txbb_iq_amplifygain = -1; + priv->txbbgain_table[13].txbbgain_value = 0x3c8000f2; + priv->txbbgain_table[14].txbb_iq_amplifygain = -2; + priv->txbbgain_table[14].txbbgain_value = 0x390000e4; + priv->txbbgain_table[15].txbb_iq_amplifygain = -3; + priv->txbbgain_table[15].txbbgain_value = 0x35c000d7; + priv->txbbgain_table[16].txbb_iq_amplifygain = -4; + priv->txbbgain_table[16].txbbgain_value = 0x32c000cb; + priv->txbbgain_table[17].txbb_iq_amplifygain = -5; + priv->txbbgain_table[17].txbbgain_value = 0x300000c0; + priv->txbbgain_table[18].txbb_iq_amplifygain = -6; + priv->txbbgain_table[18].txbbgain_value = 0x2d4000b5; + priv->txbbgain_table[19].txbb_iq_amplifygain = -7; + priv->txbbgain_table[19].txbbgain_value = 0x2ac000ab; + priv->txbbgain_table[20].txbb_iq_amplifygain = -8; + priv->txbbgain_table[20].txbbgain_value = 0x288000a2; + priv->txbbgain_table[21].txbb_iq_amplifygain = -9; + priv->txbbgain_table[21].txbbgain_value = 0x26000098; + priv->txbbgain_table[22].txbb_iq_amplifygain = -10; + priv->txbbgain_table[22].txbbgain_value = 0x24000090; + priv->txbbgain_table[23].txbb_iq_amplifygain = -11; + priv->txbbgain_table[23].txbbgain_value = 0x22000088; + priv->txbbgain_table[24].txbb_iq_amplifygain = -12; + priv->txbbgain_table[24].txbbgain_value = 0x20000080; + priv->txbbgain_table[25].txbb_iq_amplifygain = -13; + priv->txbbgain_table[25].txbbgain_value = 0x1a00006c; + priv->txbbgain_table[26].txbb_iq_amplifygain = -14; + priv->txbbgain_table[26].txbbgain_value = 0x1c800072; + priv->txbbgain_table[27].txbb_iq_amplifygain = -15; + priv->txbbgain_table[27].txbbgain_value = 0x18000060; + priv->txbbgain_table[28].txbb_iq_amplifygain = -16; + priv->txbbgain_table[28].txbbgain_value = 0x19800066; + priv->txbbgain_table[29].txbb_iq_amplifygain = -17; + priv->txbbgain_table[29].txbbgain_value = 0x15800056; + priv->txbbgain_table[30].txbb_iq_amplifygain = -18; + priv->txbbgain_table[30].txbbgain_value = 0x26c0005b; + priv->txbbgain_table[31].txbb_iq_amplifygain = -19; + priv->txbbgain_table[31].txbbgain_value = 0x14400051; + priv->txbbgain_table[32].txbb_iq_amplifygain = -20; + priv->txbbgain_table[32].txbbgain_value = 0x24400051; + priv->txbbgain_table[33].txbb_iq_amplifygain = -21; + priv->txbbgain_table[33].txbbgain_value = 0x1300004c; + priv->txbbgain_table[34].txbb_iq_amplifygain = -22; + priv->txbbgain_table[34].txbbgain_value = 0x12000048; + priv->txbbgain_table[35].txbb_iq_amplifygain = -23; + priv->txbbgain_table[35].txbbgain_value = 0x11000044; + priv->txbbgain_table[36].txbb_iq_amplifygain = -24; + priv->txbbgain_table[36].txbbgain_value = 0x10000040; priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35; @@ -1404,7 +1356,8 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) priv->btxpower_tracking = false; priv->txpower_count = 0; priv->btxpower_trackingInit = false; - RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", priv->btxpower_tracking); + RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", + priv->btxpower_tracking); } void dm_initialize_txpower_tracking(struct net_device *dev) @@ -1419,55 +1372,53 @@ void dm_initialize_txpower_tracking(struct net_device *dev) static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 tx_power_track_counter = 0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); - if (read_nic_byte(dev, 0x11e) ==1) + static u32 tx_power_track_counter; + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); + if (read_nic_byte(dev, 0x11e) == 1) return; if (!priv->btxpower_tracking) return; tx_power_track_counter++; - if (tx_power_track_counter >= 180) - { - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); - tx_power_track_counter =0; - } + if (tx_power_track_counter >= 180) { + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); + tx_power_track_counter = 0; + } } static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 TM_Trigger=0; + static u8 TM_Trigger; u8 TxPowerCheckCnt = 0; if (IS_HARDWARE_TYPE_8192SE(dev)) TxPowerCheckCnt = 5; else TxPowerCheckCnt = 2; - if (!priv->btxpower_tracking){ - return; - } else { - if (priv->txpower_count <= TxPowerCheckCnt) { + if (!priv->btxpower_tracking) { + return; + } else { + if (priv->txpower_count <= TxPowerCheckCnt) { priv->txpower_count++; return; } } - if (!TM_Trigger) - { - { + if (!TM_Trigger) { + { rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); - } + } TM_Trigger = 1; return; } else { - printk("===============>Schedule TxPowerTrackingWorkItem\n"); + printk(KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n"); - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); TM_Trigger = 0; } @@ -1488,40 +1439,38 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) u32 TempVal; struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14){ - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + if (!bInCH14) { + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); - } - else - { - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); + } else { + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } @@ -1533,8 +1482,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14) - { + if (!bInCH14) { TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); @@ -1543,7 +1491,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", @@ -1555,9 +1503,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); - } - else - { + } else { TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; @@ -1567,7 +1513,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", @@ -1577,7 +1523,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n", + RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); } } @@ -1601,17 +1547,26 @@ static void dm_txpower_reset_recovery( struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->CCKPresentAttentuation); - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n", + priv->CCKPresentAttentuation); + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", + priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); } @@ -1619,30 +1574,25 @@ extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; + u32 ratr_value; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); return; } if (priv->rate_adaptive.rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode==WIRELESS_MODE_N_24G || - priv->rtllib->mode==WIRELESS_MODE_N_5G)) - return; - { - u32 ratr_value; - ratr_value = reg_ratr; - if (priv->rf_type == RF_1T2R) - { - ratr_value &=~ (RATE_ALL_OFDM_2SS); - } - write_nic_dword(dev, RATR0, ratr_value); - write_nic_byte(dev, UFWP, 1); - } - if (priv->btxpower_trackingInit && priv->btxpower_tracking){ + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; + ratr_value = reg_ratr; + if (priv->rf_type == RF_1T2R) + ratr_value &= ~(RATE_ALL_OFDM_2SS); + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + if (priv->btxpower_trackingInit && priv->btxpower_tracking) dm_txpower_reset_recovery(dev); - } dm_bb_initialgain_restore(dev); @@ -1664,11 +1614,11 @@ static void dm_bb_initialgain_restore(struct net_device *dev) bit_mask = bMaskByte2; rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca); rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); } @@ -1701,93 +1651,66 @@ static void dm_bb_initialgain_backup(struct net_device *dev) bit_mask = bMaskByte2; priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca); } extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value) + u32 dm_type, u32 dm_value) { - if (dm_type == DIG_TYPE_THRESH_HIGH) - { + if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_LOW) - { + } else if (dm_type == DIG_TYPE_THRESH_LOW) { dm_digtable.rssi_low_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_ENABLE) - { + } else if (dm_type == DIG_TYPE_ENABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = true; - } - else if (dm_type == DIG_TYPE_DISABLE) - { + } else if (dm_type == DIG_TYPE_DISABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = false; - } - else if (dm_type == DIG_TYPE_DBG_MODE) - { + } else if (dm_type == DIG_TYPE_DBG_MODE) { if (dm_value >= DM_DBG_MAX) dm_value = DM_DBG_OFF; dm_digtable.dbg_mode = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RSSI) - { + } else if (dm_type == DIG_TYPE_RSSI) { if (dm_value > 100) dm_value = 30; dm_digtable.rssi_val = (long)dm_value; - } - else if (dm_type == DIG_TYPE_ALGORITHM) - { + } else if (dm_type == DIG_TYPE_ALGORITHM) { if (dm_value >= DIG_ALGO_MAX) dm_value = DIG_ALGO_BY_FALSE_ALARM; if (dm_digtable.dig_algorithm != (u8)dm_value) dm_digtable.dig_algorithm_switch = 1; dm_digtable.dig_algorithm = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_BACKOFF) - { + } else if (dm_type == DIG_TYPE_BACKOFF) { if (dm_value > 30) dm_value = 30; dm_digtable.backoff_val = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MIN) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MIN) { if (dm_value == 0) dm_value = 0x1; dm_digtable.rx_gain_range_min = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MAX) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MAX) { if (dm_value > 0x50) dm_value = 0x50; dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void -dm_change_fsync_setting( - struct net_device *dev, +extern void dm_change_fsync_setting(struct net_device *dev, s32 DM_Type, s32 DM_Value) { struct r8192_priv *priv = rtllib_priv(dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->framesyncMonitor = (u8)DM_Value; @@ -1804,68 +1727,47 @@ dm_change_rxpath_selection_setting( struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.Enable = (u8)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } - else if (DM_Type == 2) - { + } else if (DM_Type == 2) { if (DM_Value > 40) DM_Value = 40; DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } - else if (DM_Type == 3) - { + } else if (DM_Type == 3) { if (DM_Value > 25) DM_Value = 25; DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } - else if (DM_Type == 4) - { + } else if (DM_Type == 4) { if (DM_Value >= CCK_Rx_Version_MAX) DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method= (u8)DM_Value; - } - else if (DM_Type == 10) - { + DM_RxPathSelTable.cck_method = (u8)DM_Value; + } else if (DM_Type == 10) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } - else if (DM_Type == 11) - { + } else if (DM_Type == 11) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } - else if (DM_Type == 12) - { + } else if (DM_Type == 12) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } - else if (DM_Type == 13) - { + } else if (DM_Type == 13) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } - else if (DM_Type == 20) - { + } else if (DM_Type == 20) { if (DM_Value > 1) DM_Value = 1; pRA->ping_rssi_enable = (u8)DM_Value; - } - else if (DM_Type == 21) - { + } else if (DM_Type == 21) { if (DM_Value > 30) DM_Value = 30; pRA->ping_rssi_thresh_for_ra = DM_Value; @@ -1919,16 +1821,16 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); @@ -1939,7 +1841,8 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) FalseAlmCnt->Cnt_Cck_fail); RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail , FalseAlmCnt->Cnt_all); + FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, + FalseAlmCnt->Cnt_all); } static void dm_ctrl_initgain_byrssi(struct net_device *dev) @@ -1979,16 +1882,15 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( { struct r8192_priv *priv = rtllib_priv(dev); u8 i; - static u8 fw_dig=0; + static u8 fw_dig; if (dm_digtable.dig_enable_flag == false) return; if (dm_digtable.dig_algorithm_switch) fw_dig = 0; - if (fw_dig <= 3) - { - for (i=0; i<3; i++) + if (fw_dig <= 3) { + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); fw_dig++; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2015,16 +1917,15 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt = 0; + static u32 reset_cnt; u8 i; if (dm_digtable.dig_enable_flag == false) return; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { dm_digtable.dig_state = DM_STA_DIG_MAX; - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); dm_digtable.dig_algorithm_switch = 0; } @@ -2034,20 +1935,13 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh)) - { return; - } - if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) - { + if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) { if (dm_digtable.dig_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt)) - { return; - } else - { reset_cnt = priv->reset_count; - } dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2060,30 +1954,23 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17); if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); write_nic_byte(dev, 0xa0a, 0x08); return; - } - if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) ) - { + if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)) { u8 reset_flag = 0; if (dm_digtable.dig_state == DM_STA_DIG_ON && - (priv->reset_count == reset_cnt)) - { + (priv->reset_count == reset_cnt)) { dm_ctrl_initgain_byrssi_highpwr(dev); return; - } - else - { + } else { if (priv->reset_count != reset_cnt) reset_flag = 1; @@ -2092,54 +1979,41 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( dm_digtable.dig_state = DM_STA_DIG_ON; - if (reset_flag == 1) - { + if (reset_flag == 1) { write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c); - } - else - { - write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); + } else { + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); } if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); write_nic_byte(dev, 0xa0a, 0xcd); - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - } - dm_ctrl_initgain_byrssi_highpwr(dev); - } -static void dm_ctrl_initgain_byrssi_highpwr( - struct net_device * dev) +static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt_highpwr = 0; + static u32 reset_cnt_highpwr; if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) - { return; - } - if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) - { + if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) { if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && (priv->reset_count == reset_cnt_highpwr)) return; @@ -2147,84 +2021,64 @@ static void dm_ctrl_initgain_byrssi_highpwr( dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - else - { - if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&& + } else { + if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt_highpwr)) return; else dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && - priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) - { + priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); } } - reset_cnt_highpwr = priv->reset_count; - } - -static void dm_initial_gain( - struct net_device * dev) +static void dm_initial_gain(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; - static u32 reset_cnt=0; + u8 initial_gain = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (rtllib_act_scanning(priv->rtllib,true) == true) - { + if (rtllib_act_scanning(priv->rtllib, true) == true) { force_write = 1; return; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; - } - else - { + } else { if (dm_digtable.cur_ig_value == 0) dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; else dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; } - } - else - { + } else { dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; dm_digtable.pre_ig_value = 0; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } @@ -2232,82 +2086,70 @@ static void dm_initial_gain( if (dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1)) force_write = 1; - { - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) - || !initialized || force_write) - { - initial_gain = (u8)dm_digtable.cur_ig_value; - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) + || !initialized || force_write) { + initial_gain = (u8)dm_digtable.cur_ig_value; + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; + initialized = 1; + force_write = 0; } } void dm_initial_gain_STABeforeConnect( - struct net_device * dev) + struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; + u8 initial_gain = 0; + static u8 initialized, force_write; RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) - { + (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { + if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { if (priv->rtllib->eRFPowerState != eRfOn) return; - if (dm_digtable.Backoff_Enable_Flag == true) - { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) - { - if ((dm_digtable.backoff_val -6) < dm_digtable.BackoffVal_range_min) + if (dm_digtable.Backoff_Enable_Flag == true) { + if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { + if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; else dm_digtable.backoff_val -= 6; - } - else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) - { - if ((dm_digtable.backoff_val+6) > dm_digtable.BackoffVal_range_max) + } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { + if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; else - dm_digtable.backoff_val +=6; + dm_digtable.backoff_val += 6; } - } - else - dm_digtable.backoff_val =DM_DIG_BACKOFF; + } else + dm_digtable.backoff_val = DM_DIG_BACKOFF; if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else - dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - + dm_digtable.backoff_val; if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value>0x33)?dm_digtable.cur_ig_value:0x33; + dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? + dm_digtable.cur_ig_value : 0x33; if (priv->FalseAlmCnt.Cnt_all > 16000) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - } - else - { + } else { return; } - } - else - { + } else { dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); @@ -2317,44 +2159,44 @@ void dm_initial_gain_STABeforeConnect( return; } - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0)) + if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, + rOFDM0_XAAGCCore1, bMaskByte0)) force_write = 1; - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || !initialized || force_write) - { + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || + !initialized || force_write) { priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); initial_gain = (u8)dm_digtable.cur_ig_value; - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, + initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, + initial_gain); dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; initialized = 1; force_write = 0; } - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, backoff_val = %d\n", - dm_digtable.cur_ig_value, dm_digtable.pre_ig_value, dm_digtable.backoff_val); + RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " + "backoff_val = %d\n", dm_digtable.cur_ig_value, + dm_digtable.pre_ig_value, dm_digtable.backoff_val); } -static void dm_pd_th( - struct net_device * dev) +static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0, force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) @@ -2364,123 +2206,88 @@ static void dm_pd_th( dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; else dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || - (initialized<=3) || force_write) - { - if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; - if (initialized <= 3) - initialized++; - force_write = 0; + if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || + (initialized <= 3) || force_write) { + if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); } + dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; + if (initialized <= 3) + initialized++; + force_write = 0; } } -static void dm_cs_ratio( - struct net_device * dev) +static void dm_cs_ratio(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0,force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) ) + else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER; else dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state; - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || - !initialized || force_write) - { - if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) - { - write_nic_byte(dev, 0xa0a, 0x08); - } - else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) - { - write_nic_byte(dev, 0xa0a, 0xcd); - } - dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || + !initialized || force_write) { + if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) + write_nic_byte(dev, 0xa0a, 0x08); + else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) + write_nic_byte(dev, 0xa0a, 0xcd); + dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; + initialized = 1; + force_write = 0; } } -extern void dm_init_edca_turbo(struct net_device * dev) +extern void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2489,98 +2296,89 @@ extern void dm_init_edca_turbo(struct net_device * dev) priv->bis_cur_rdlstate = false; } -static void dm_check_edca_turbo( - struct net_device * dev) +static void dm_check_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->state != RTLLIB_LINKED) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) - { goto dm_CheckEdcaTurbo_EXIT; - } { - u8* peername[11] = {"unknown", "realtek_90", "realtek_92se","broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"}; - static int wb_tmp = 0; - if (wb_tmp == 0){ - printk("%s():iot peer is %s, bssid:"MAC_FMT"\n",__func__,peername[pHTInfo->IOTPeer], MAC_ARG(priv->rtllib->current_network.bssid)); + u8 *peername[11] = { + "unknown", "realtek_90", "realtek_92se", "broadcom", + "ralink", "atheros", "cisco", "marvell", "92u_softap", + "self_softap" + }; + static int wb_tmp; + if (wb_tmp == 0) { + printk(KERN_INFO "%s():iot peer is %s, bssid:" + MAC_FMT"\n", __func__, + peername[pHTInfo->IOTPeer], + MAC_ARG(priv->rtllib->current_network.bssid)); wb_tmp = 1; } } - if (!priv->rtllib->bis_any_nonbepkts) - { + if (!priv->rtllib->bis_any_nonbepkts) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) - { - if (curTxOkCnt > 4*curRxOkCnt) - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); + if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) { + if (curTxOkCnt > 4*curRxOkCnt) { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = false; } - } - else - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { + } else { + if (!priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = true; } } priv->bcurrent_turbo_EDCA = true; - } - else - { - if (curRxOkCnt > 4*curTxOkCnt) - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); - else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = true; - } - } - else - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = false; + } else { + if (curRxOkCnt > 4*curTxOkCnt) { + if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { + if (priv->rtllib->mode == WIRELESS_MODE_G) + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); + else + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = true; + } + } else { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = false; + } + } + priv->bcurrent_turbo_EDCA = true; } - - priv->bcurrent_turbo_EDCA = true; - } - } - else - { - if (priv->bcurrent_turbo_EDCA) - { - - u8 tmp = AC0_BE; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&tmp) ); + } else { + if (priv->bcurrent_turbo_EDCA) { + u8 tmp = AC0_BE; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp)); priv->bcurrent_turbo_EDCA = false; } } @@ -2592,25 +2390,23 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value) +extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, + u32 DM_Value) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value >= 50) DM_Value = 50; priv->rtllib->CTSToSelfTH = (u8)DM_Value; } } -static void dm_init_ctstoself(struct net_device * dev) +static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2622,28 +2418,22 @@ static void dm_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; - if (priv->rtllib->bCTSToSelfEnable != true) - { + if (priv->rtllib->bCTSToSelfEnable != true) { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } - if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; if (curRxOkCnt > 4*curTxOkCnt) - { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - } else - { pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - } lastTxOkCnt = priv->stats.txbytesunicast; lastRxOkCnt = priv->stats.rxbytesunicast; @@ -2651,8 +2441,7 @@ static void dm_ctstoself(struct net_device *dev) } -static void -dm_Init_WA_Broadcom_IOT(struct net_device * dev) +static void dm_Init_WA_Broadcom_IOT(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; @@ -2665,78 +2454,65 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } - extern void dm_CheckRfCtrlGPIO(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,gpio_change_rf_wq); - struct net_device *dev = priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, gpio_change_rf_wq); + struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; enum rt_rf_power_state eRfPowerStateToSet; bool bActuallySet = false; - char *argv[3]; static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - bActuallySet=false; + bActuallySet = false; if ((priv->up_first_time == 1) || (priv->being_init_adapter)) - { return; - } - if (priv->bfirst_after_down){ + if (priv->bfirst_after_down) { priv->bfirst_after_down = 1; return; } + tmp1byte = read_nic_byte(dev, GPI); + eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - { - tmp1byte = read_nic_byte(dev,GPI); - - eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - - if ( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); - printk("gpiochangeRF - HW Radio ON\n"); - priv->bHwRadioOff = false; - bActuallySet = true; - } - else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); - printk("gpiochangeRF - HW Radio OFF\n"); - priv->bHwRadioOff = true; - bActuallySet = true; - } - - if (bActuallySet) - { - mdelay(1000); - priv->bHwRfOffAction = 1; - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); - { - if (priv->bHwRadioOff == true) - argv[1] = "RFOFF"; - else - argv[1] = "RFON"; - - argv[0] = RadioPowerPath; - argv[2] = NULL; - call_usermodehelper(RadioPowerPath,argv,envp,1); - } - - } + if ((priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio ON\n"); + priv->bHwRadioOff = false; + bActuallySet = true; + } else if ((priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio OFF\n"); + priv->bHwRadioOff = true; + bActuallySet = true; } + if (bActuallySet) { + mdelay(1000); + priv->bHwRfOffAction = 1; + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, true); + if (priv->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + + argv[0] = RadioPowerPath; + argv[2] = NULL; + call_usermodehelper(RadioPowerPath, argv, envp, 1); + } } void dm_rf_pathcheck_workitemcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,rfpath_check_wq); - struct net_device *dev =priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, + rfpath_check_wq); + struct net_device *dev = priv->rtllib->dev; u8 rfpath = 0, i; rfpath = read_nic_byte(dev, 0xc04); @@ -2753,10 +2529,11 @@ void dm_rf_pathcheck_workitemcallback(void *data) dm_rxpath_sel_byrssi(dev); } -static void dm_init_rxpath_selection(struct net_device * dev) +static void dm_init_rxpath_selection(struct net_device *dev) { u8 i; struct r8192_priv *priv = rtllib_priv(dev); + DM_RxPathSelTable.Enable = 1; DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; @@ -2766,119 +2543,92 @@ static void dm_init_rxpath_selection(struct net_device * dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; DM_RxPathSelTable.DbgMode = DM_DBG_OFF; DM_RxPathSelTable.disabledRF = 0; - for (i=0; i<4; i++) - { + for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; DM_RxPathSelTable.cck_pwdb_sta[i] = -64; DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; } } -static void dm_rxpath_sel_byrssi(struct net_device * dev) +#define PWDB_IN_RANGE ((cur_cck_pwdb < tmp_cck_max_pwdb) && \ + (cur_cck_pwdb > tmp_cck_sec_pwdb)) + +static void dm_rxpath_sel_byrssi(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0; - u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0; - u8 cck_default_Rx=0x2; - u8 cck_optional_Rx=0x3; - long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0; - u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; - u8 cur_rf_rssi; - long cur_cck_pwdb; - static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; - u8 update_cck_rx_path; + u8 i, max_rssi_index = 0, min_rssi_index = 0; + u8 sec_rssi_index = 0, rf_num = 0; + u8 tmp_max_rssi = 0, tmp_min_rssi = 0, tmp_sec_rssi = 0; + u8 cck_default_Rx = 0x2; + u8 cck_optional_Rx = 0x3; + long tmp_cck_max_pwdb = 0, tmp_cck_min_pwdb = 0, tmp_cck_sec_pwdb = 0; + u8 cck_rx_ver2_max_index = 0, cck_rx_ver2_min_index = 0; + u8 cck_rx_ver2_sec_index = 0; + u8 cur_rf_rssi; + long cur_cck_pwdb; + static u8 disabled_rf_cnt, cck_Rx_Path_initialized; + u8 update_cck_rx_path; if (priv->rf_type != RF_2T4R) return; - if (!cck_Rx_Path_initialized) - { + if (!cck_Rx_Path_initialized) { DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf); cck_Rx_Path_initialized = 1; } DM_RxPathSelTable.disabledRF = 0xf; - DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04)); + DM_RxPathSelTable.disabledRF &= ~(read_nic_byte(dev, 0xc04)); if (priv->rtllib->mode == WIRELESS_MODE_B) - { DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; - } - for (i=0; istats.rx_rssi_percentage[i]; - if (priv->brfpath_rxenable[i]) - { + if (priv->brfpath_rxenable[i]) { rf_num++; cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; - if (rf_num == 1) - { + if (rf_num == 1) { max_rssi_index = min_rssi_index = sec_rssi_index = i; tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; - } - else if (rf_num == 2) - { - if (cur_rf_rssi >= tmp_max_rssi) - { + } else if (rf_num == 2) { + if (cur_rf_rssi >= tmp_max_rssi) { tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else - { + } else { tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; sec_rssi_index = min_rssi_index = i; } - } - else - { - if (cur_rf_rssi > tmp_max_rssi) - { + } else { + if (cur_rf_rssi > tmp_max_rssi) { tmp_sec_rssi = tmp_max_rssi; sec_rssi_index = max_rssi_index; tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else if (cur_rf_rssi == tmp_max_rssi) - { + } else if (cur_rf_rssi == tmp_max_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if ((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi)) - { + } else if ((cur_rf_rssi < tmp_max_rssi) && + (cur_rf_rssi > tmp_sec_rssi)) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if (cur_rf_rssi == tmp_sec_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if (cur_rf_rssi == tmp_sec_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; } - else - { - } - } - else if ((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi)) - { - } - else if (cur_rf_rssi == tmp_min_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if ((cur_rf_rssi < tmp_sec_rssi) && + (cur_rf_rssi > tmp_min_rssi)) { + ; + } else if (cur_rf_rssi == tmp_min_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } - else - { - } - } - else if (cur_rf_rssi < tmp_min_rssi) - { + } else if (cur_rf_rssi < tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } @@ -2887,79 +2637,63 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } rf_num = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { - for (i=0; ibrfpath_rxenable[i]) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + for (i = 0; i < RF90_PATH_MAX; i++) { + if (priv->brfpath_rxenable[i]) { rf_num++; - cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; + cur_cck_pwdb = + DM_RxPathSelTable.cck_pwdb_sta[i]; - if (rf_num == 1) - { - cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i; - tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb; - } - else if (rf_num == 2) - { - if (cur_cck_pwdb >= tmp_cck_max_pwdb) - { + if (rf_num == 1) { + cck_rx_ver2_max_index = i; + cck_rx_ver2_min_index = i; + cck_rx_ver2_sec_index = i; + tmp_cck_max_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + tmp_cck_sec_pwdb = cur_cck_pwdb; + } else if (rf_num == 2) { + if (cur_cck_pwdb >= tmp_cck_max_pwdb) { tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; + } else { + tmp_cck_sec_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + cck_rx_ver2_min_index = i; } - else - { - tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i; - } - } - else - { - if (cur_cck_pwdb > tmp_cck_max_pwdb) - { - tmp_cck_sec_pwdb = tmp_cck_max_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_max_index; + } else { + if (cur_cck_pwdb > tmp_cck_max_pwdb) { + tmp_cck_sec_pwdb = + tmp_cck_max_pwdb; + cck_rx_ver2_sec_index = + cck_rx_ver2_max_index; tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; - } - else if (cur_cck_pwdb == tmp_cck_max_pwdb) - { + } else if (cur_cck_pwdb == + tmp_cck_max_pwdb) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if ((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb)) - { + } else if (PWDB_IN_RANGE) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if (cur_cck_pwdb == tmp_cck_sec_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; + } else if (cur_cck_pwdb == + tmp_cck_sec_pwdb) { + if (tmp_cck_sec_pwdb == + tmp_cck_min_pwdb) { + tmp_cck_sec_pwdb = + cur_cck_pwdb; + cck_rx_ver2_sec_index = + i; } - else - { - } - } - else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb)) - { - } - else if (cur_cck_pwdb == tmp_cck_min_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { + } else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && + (cur_cck_pwdb > tmp_cck_min_pwdb)) { + ; + } else if (cur_cck_pwdb == tmp_cck_min_pwdb) { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } - else - { - } - } - else if (cur_cck_pwdb < tmp_cck_min_pwdb) - { + } else if (cur_cck_pwdb < tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } @@ -2969,27 +2703,26 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } } - update_cck_rx_path = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { cck_default_Rx = cck_rx_ver2_max_index; cck_optional_Rx = cck_rx_ver2_sec_index; if (tmp_cck_max_pwdb != -64) update_cck_rx_path = 1; } - if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) - { - if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) - { - DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<= + DM_RxPathSelTable.diff_TH) { + DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = + tmp_max_rssi+5; + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, + 0x1<>i) & 0x1) - { - if (tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) - { - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<>i) & 0x1) { + if (tmp_max_rssi >= + DM_RxPathSelTable.rf_enable_rssi_th[i]) { + rtl8192_setBBreg(dev, + rOFDM0_TRxPathEnable, 0x1 << i, + 0x1); + rtl8192_setBBreg(dev, + rOFDM1_TRxPathEnable, + 0x1 << i, 0x1); + DM_RxPathSelTable.rf_enable_rssi_th[i] + = 100; disabled_rf_cnt--; } } @@ -3024,11 +2760,12 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) static void dm_check_rx_path_selection(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - queue_delayed_work_rsl(priv->priv_wq,&priv->rfpath_check_wq,0); + + queue_delayed_work_rsl(priv->priv_wq, &priv->rfpath_check_wq, 0); } -static void dm_init_fsync (struct net_device *dev) +static void dm_init_fsync(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -3037,13 +2774,14 @@ static void dm_init_fsync (struct net_device *dev) priv->rtllib->fsync_rssi_threshold = 30; priv->rtllib->bfsync_enable = false; priv->rtllib->fsync_multiple_timeinterval = 3; - priv->rtllib->fsync_firstdiff_ratethreshold= 100; - priv->rtllib->fsync_seconddiff_ratethreshold= 200; + priv->rtllib->fsync_firstdiff_ratethreshold = 100; + priv->rtllib->fsync_seconddiff_ratethreshold = 200; priv->rtllib->fsync_state = Default_Fsync; priv->framesyncMonitor = 1; init_timer(&priv->fsync_timer); - setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,(unsigned long) dev); + setup_timer(&priv->fsync_timer, dm_fsync_timer_callback, + (unsigned long) dev); } @@ -3057,95 +2795,91 @@ extern void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); - u32 rate_index, rate_count = 0, rate_count_diff=0; + u32 rate_index, rate_count = 0, rate_count_diff = 0; bool bSwitchFromCountDiff = false; bool bDoubleTimeInterval = false; - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->bfsync_enable && - (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) - { + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->bfsync_enable && + (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) { u32 rate_bitmap; - for (rate_index = 0; rate_index <= 27; rate_index++) - { + for (rate_index = 0; rate_index <= 27; rate_index++) { rate_bitmap = 1 << rate_index; if (priv->rtllib->fsync_rate_bitmap & rate_bitmap) - rate_count+= priv->stats.received_rate_histogram[1][rate_index]; + rate_count += + priv->stats.received_rate_histogram[1] + [rate_index]; } if (rate_count < priv->rate_record) - rate_count_diff = 0xffffffff - rate_count + priv->rate_record; + rate_count_diff = 0xffffffff - rate_count + + priv->rate_record; else rate_count_diff = rate_count - priv->rate_record; - if (rate_count_diff < priv->rateCountDiffRecord) - { + if (rate_count_diff < priv->rateCountDiffRecord) { - u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff; - if (DiffNum >= priv->rtllib->fsync_seconddiff_ratethreshold) + u32 DiffNum = priv->rateCountDiffRecord - + rate_count_diff; + if (DiffNum >= + priv->rtllib->fsync_seconddiff_ratethreshold) priv->ContiuneDiffCount++; else priv->ContiuneDiffCount = 0; - if (priv->ContiuneDiffCount >=2) - { + if (priv->ContiuneDiffCount >= 2) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } - } - else - { + } else { priv->ContiuneDiffCount = 0; } - if (rate_count_diff <= priv->rtllib->fsync_firstdiff_ratethreshold) - { + if (rate_count_diff <= + priv->rtllib->fsync_firstdiff_ratethreshold) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } priv->rate_record = rate_count; priv->rateCountDiffRecord = rate_count_diff; - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); - if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) - { + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rate" + "Countdiff %d bSwitchFsync %d\n", priv->rate_record, + rate_count, rate_count_diff, priv->bswitch_fsync); + if (priv->undecorated_smoothed_pwdb > + priv->rtllib->fsync_rssi_threshold && + bSwitchFromCountDiff) { bDoubleTimeInterval = true; priv->bswitch_fsync = !priv->bswitch_fsync; - if (priv->bswitch_fsync) - { - write_nic_byte(dev,0xC36, 0x1c); + if (priv->bswitch_fsync) { + write_nic_byte(dev, 0xC36, 0x1c); write_nic_byte(dev, 0xC3e, 0x90); - } - else - { + } else { write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } - } - else if (priv->undecorated_smoothed_pwdb <= priv->rtllib->fsync_rssi_threshold) - { - if (priv->bswitch_fsync) - { + } else if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->fsync_rssi_threshold) { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } } - if (bDoubleTimeInterval){ + if (bDoubleTimeInterval) { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval*priv->rtllib->fsync_multiple_timeinterval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval * + priv->rtllib->fsync_multiple_timeinterval); add_timer(&priv->fsync_timer); - } - else{ + } else { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); } - } - else - { - if (priv->bswitch_fsync) - { + } else { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); @@ -3154,7 +2888,9 @@ extern void dm_fsync_timer_callback(unsigned long data) write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); } RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d " + "bSwitchFsync %d\n", priv->rate_record, rate_count, + rate_count_diff, priv->bswitch_fsync); } static void dm_StartHWFsync(struct net_device *dev) @@ -3163,7 +2899,8 @@ static void dm_StartHWFsync(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, + (u8 *)(&rf_timing)); write_nic_byte(dev, 0xc3b, 0x41); } @@ -3171,9 +2908,10 @@ static void dm_EndHWFsync(struct net_device *dev) { u8 rf_timing = 0xaa; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *) + (&rf_timing)); write_nic_byte(dev, 0xc3b, 0x49); } @@ -3184,8 +2922,7 @@ static void dm_EndSWFsync(struct net_device *dev) RT_TRACE(COMP_HALDM, "%s\n", __func__); del_timer_sync(&(priv->fsync_timer)); - if (priv->bswitch_fsync) - { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); @@ -3203,31 +2940,30 @@ static void dm_StartSWFsync(struct net_device *dev) u32 rateIndex; u32 rateBitmap; - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); priv->rate_record = 0; priv->ContiuneDiffCount = 0; priv->rateCountDiffRecord = 0; priv->bswitch_fsync = false; - if (priv->rtllib->mode == WIRELESS_MODE_N_24G) - { - priv->rtllib->fsync_firstdiff_ratethreshold= 600; + if (priv->rtllib->mode == WIRELESS_MODE_N_24G) { + priv->rtllib->fsync_firstdiff_ratethreshold = 600; priv->rtllib->fsync_seconddiff_ratethreshold = 0xffff; - } - else - { - priv->rtllib->fsync_firstdiff_ratethreshold= 200; + } else { + priv->rtllib->fsync_firstdiff_ratethreshold = 200; priv->rtllib->fsync_seconddiff_ratethreshold = 200; } - for (rateIndex = 0; rateIndex <= 27; rateIndex++) - { + for (rateIndex = 0; rateIndex <= 27; rateIndex++) { rateBitmap = 1 << rateIndex; - if (priv->rtllib->fsync_rate_bitmap & rateBitmap) - priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex]; + if (priv->rtllib->fsync_rate_bitmap & rateBitmap) + priv->rate_record += + priv->stats.received_rate_histogram[1] + [rateIndex]; } if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd); @@ -3236,61 +2972,59 @@ static void dm_StartSWFsync(struct net_device *dev) void dm_check_fsync(struct net_device *dev) { -#define RegC38_Default 0 +#define RegC38_Default 0 #define RegC38_NonFsync_Other_AP 1 #define RegC38_Fsync_AP_BCM 2 struct r8192_priv *priv = rtllib_priv(dev); - static u8 reg_c38_State=RegC38_Default; - static u32 reset_cnt=0; + static u8 reg_c38_State = RegC38_Default; + static u32 reset_cnt; - RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->rtllib->fsync_rssi_threshold, priv->rtllib->fsync_time_interval, priv->rtllib->fsync_multiple_timeinterval); - RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, priv->rtllib->fsync_firstdiff_ratethreshold, priv->rtllib->fsync_seconddiff_ratethreshold); + RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval " + "%d\n", priv->rtllib->fsync_rssi_threshold, + priv->rtllib->fsync_time_interval, + priv->rtllib->fsync_multiple_timeinterval); + RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d Second" + "DiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, + priv->rtllib->fsync_firstdiff_ratethreshold, + priv->rtllib->fsync_seconddiff_ratethreshold); - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (priv->rtllib->bfsync_enable == 0) - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case SW_Fsync: - dm_EndSWFsync(dev); - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case HW_Fsync: - default: - break; + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (priv->rtllib->bfsync_enable == 0) { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case SW_Fsync: + dm_EndSWFsync(dev); + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case HW_Fsync: + default: + break; } - } - else - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case HW_Fsync: - dm_EndHWFsync(dev); - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case SW_Fsync: - default: - break; + } else { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case HW_Fsync: + dm_EndHWFsync(dev); + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case SW_Fsync: + default: + break; } } - if (priv->framesyncMonitor) - { - if (reg_c38_State != RegC38_Fsync_AP_BCM) - { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); + if (priv->framesyncMonitor) { + if (reg_c38_State != RegC38_Fsync_AP_BCM) { + write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); reg_c38_State = RegC38_Fsync_AP_BCM; } @@ -3312,21 +3046,30 @@ void dm_check_fsync(struct net_device *dev) if (priv->framesyncMonitor) { if (priv->rtllib->state == RTLLIB_LINKED) { - if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { - if (reg_c38_State != RegC38_NonFsync_Other_AP) { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); + if (priv->undecorated_smoothed_pwdb <= + RegC38_TH) { + if (reg_c38_State != + RegC38_NonFsync_Other_AP) { + write_nic_byte(dev, + rOFDM0_RxDetector3, + 0x90); - reg_c38_State = RegC38_NonFsync_Other_AP; + reg_c38_State = + RegC38_NonFsync_Other_AP; } - } else if (priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) { + } else if (priv->undecorated_smoothed_pwdb >= + (RegC38_TH+5)) { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, + rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3334,13 +3077,15 @@ void dm_check_fsync(struct net_device *dev) } if (priv->framesyncMonitor) { if (priv->reset_count != reset_cnt) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; reset_cnt = priv->reset_count; } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3353,15 +3098,18 @@ extern void dm_shadow_init(struct net_device *dev) for (page = 0; page < 5; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 8; page < 11; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 12; page < 15; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page*256); } @@ -3380,93 +3128,75 @@ static void dm_init_dynamic_txpower(struct net_device *dev) static void dm_dynamic_txpower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - unsigned int txhipower_threshhold=0; - unsigned int txlowpower_threshold=0; - if (priv->rtllib->bdynamic_txpower_enable != true) - { + unsigned int txhipower_threshhold = 0; + unsigned int txlowpower_threshold = 0; + if (priv->rtllib->bdynamic_txpower_enable != true) { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; return; } - if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && (priv->rtllib->mode == IEEE_G)){ + if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && + (priv->rtllib->mode == IEEE_G)) { txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; - } - else - { + } else { txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } + RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n", + priv->undecorated_smoothed_pwdb); - RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb); - - if (priv->rtllib->state == RTLLIB_LINKED) - { - if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) - { + if (priv->rtllib->state == RTLLIB_LINKED) { + if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) { priv->bDynamicTxHighPower = true; priv->bDynamicTxLowPower = false; - } - else - { - if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) - { + } else { + if (priv->undecorated_smoothed_pwdb < + txlowpower_threshold && + priv->bDynamicTxHighPower == true) priv->bDynamicTxHighPower = false; - } if (priv->undecorated_smoothed_pwdb < 35) - { priv->bDynamicTxLowPower = true; - } else if (priv->undecorated_smoothed_pwdb >= 40) - { priv->bDynamicTxLowPower = false; - } } - } - else - { + } else { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; } - if ( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) || - (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) ) - { - RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->rtllib->current_network.channel); + if ((priv->bDynamicTxHighPower != priv->bLastDTPFlag_High) || + (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low)) { + RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", + priv->rtllib->current_network.channel); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); } priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; } -static void dm_check_txrateandretrycount(struct net_device * dev) +static void dm_check_txrateandretrycount(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg); + ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, + Current_Tx_Rate_Reg); - ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg); + ieee->softmac_stats.last_packet_rate = read_nic_byte(dev, + Initial_Tx_Rate_Reg); - ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg); + ieee->softmac_stats.txretrycount = read_nic_dword(dev, + Tx_Retry_Count_Reg); } static void dm_send_rssi_tofw(struct net_device *dev) { - struct dcmd_txcmd tx_cmd; struct r8192_priv *priv = rtllib_priv(dev); write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); - return; - tx_cmd.Op = TXCMD_SET_RX_RSSI; - tx_cmd.Length = 4; - tx_cmd.Value = priv->undecorated_smoothed_pwdb; - - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, - DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); } - -/*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 64fa749cfb4..ab44a9a6927 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -59,15 +59,15 @@ #define WAIotTHVal 25 -#define E_FOR_TX_POWER_TRACK 300 +#define E_FOR_TX_POWER_TRACK 300 #define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 #define TX_POWER_NEAR_FIELD_THRESH_LOW 62 -#define TX_POWER_ATHEROAP_THRESH_HIGH 78 +#define TX_POWER_ATHEROAP_THRESH_HIGH 78 #define TX_POWER_ATHEROAP_THRESH_LOW 72 -#define Current_Tx_Rate_Reg 0x1e0 -#define Initial_Tx_Rate_Reg 0x1e1 -#define Tx_Retry_Count_Reg 0x1ac +#define Current_Tx_Rate_Reg 0x1e0 +#define Initial_Tx_Rate_Reg 0x1e1 +#define Tx_Retry_Count_Reg 0x1ac #define RegC38_TH 20 #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 @@ -227,7 +227,7 @@ struct drx_path_sel { enum dm_cck_rx_path_method { CCK_Rx_Version_1 = 0, - CCK_Rx_Version_2= 1, + CCK_Rx_Version_2 = 1, CCK_Rx_Version_MAX }; @@ -256,7 +256,10 @@ extern u8 test_flag; /*------------------------Export Marco Definition---------------------------*/ -#define DM_APInitGainChangeNotify(Event) {dm_digtable.CurAPConnectState = Event;} +#define DM_APInitGainChangeNotify(Event) \ + { \ + dm_digtable.CurAPConnectState = Event; \ + } /*------------------------Export Marco Definition---------------------------*/ @@ -271,19 +274,19 @@ extern void hal_dm_watchdog(struct net_device *dev); extern void init_rate_adaptive(struct net_device *dev); extern void dm_txpower_trackingcallback(void *data); -extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14); +extern void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); + u32 dm_type, + u32 dm_value); extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); + s32 DM_Type, + s32 DM_Value); extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); + u32 force_type, + u32 force_value); extern void dm_init_edca_turbo(struct net_device *dev); extern void dm_rf_operation_test_callback(unsigned long data); extern void dm_rf_pathcheck_workitemcallback(void *data); @@ -291,11 +294,31 @@ extern void dm_fsync_timer_callback(unsigned long data); extern void dm_check_fsync(struct net_device *dev); extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); - +extern void dm_CheckRfCtrlGPIO(void *data); +extern void dm_InitRateAdaptiveMask(struct net_device *dev); +extern void init_hal_dm(struct net_device *dev); +extern void deinit_hal_dm(struct net_device *dev); +extern void hal_dm_watchdog(struct net_device *dev); +extern void init_rate_adaptive(struct net_device *dev); +extern void dm_txpower_trackingcallback(void *data); +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value); +extern void DM_ChangeFsyncSetting(struct net_device *dev, + s32 DM_Type, + s32 DM_Value); +extern void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, + u32 force_value); +extern void dm_init_edca_turbo(struct net_device *dev); +extern void dm_rf_operation_test_callback(unsigned long data); +extern void dm_rf_pathcheck_workitemcallback(void *data); +extern void dm_fsync_timer_callback(unsigned long data); +extern void dm_check_fsync(struct net_device *dev); +extern void dm_shadow_init(struct net_device *dev); +extern void dm_initialize_txpower_tracking(struct net_device *dev); extern void dm_CheckRfCtrlGPIO(void *data); -extern void dm_InitRateAdaptiveMask(struct net_device * dev); - #endif /*__R8192UDM_H__ */ - -/* End of r8192U_dm.h */ From fbf76538736ddc5c4f23a67e2f9278c3921c393c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 16:42:31 -0500 Subject: [PATCH 0532/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XI Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_eeprom.c | 69 ++++++----- drivers/staging/rtl8192e/rtl_eeprom.h | 2 +- drivers/staging/rtl8192e/rtllib_crypt.c | 6 +- drivers/staging/rtl8192e/rtllib_crypt.h | 8 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 30 +++-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 118 ++++++++++--------- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 74 ++++++------ drivers/staging/rtl8192e/rtllib_endianfree.h | 66 ++++++----- 8 files changed, 194 insertions(+), 179 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index 14a8c1d13e2..df72a6007d0 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -29,11 +29,11 @@ void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, - (1<epromtype==EEPROM_93C56){ - addr_str[7]=addr & 1; - addr_str[6]=addr & (1<<1); - addr_str[5]=addr & (1<<2); - addr_str[4]=addr & (1<<3); - addr_str[3]=addr & (1<<4); - addr_str[2]=addr & (1<<5); - addr_str[1]=addr & (1<<6); - addr_str[0]=addr & (1<<7); - addr_len=8; - }else{ - addr_str[5]=addr & 1; - addr_str[4]=addr & (1<<1); - addr_str[3]=addr & (1<<2); - addr_str[2]=addr & (1<<3); - addr_str[1]=addr & (1<<4); - addr_str[0]=addr & (1<<5); - addr_len=6; + if (priv->epromtype == EEPROM_93C56) { + addr_str[7] = addr & 1; + addr_str[6] = addr & (1<<1); + addr_str[5] = addr & (1<<2); + addr_str[4] = addr & (1<<3); + addr_str[3] = addr & (1<<4); + addr_str[2] = addr & (1<<5); + addr_str[1] = addr & (1<<6); + addr_str[0] = addr & (1<<7); + addr_len = 8; + } else { + addr_str[5] = addr & 1; + addr_str[4] = addr & (1<<1); + addr_str[3] = addr & (1<<2); + addr_str[2] = addr & (1<<3); + addr_str[1] = addr & (1<<4); + addr_str[0] = addr & (1<<5); + addr_len = 6; } eprom_cs(dev, 1); eprom_ck_cycle(dev); @@ -127,7 +126,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) eprom_w(dev, 0); - for (i = 0; i < 16; i++){ + for (i = 0; i < 16; i++) { eprom_ck_cycle(dev); ret |= (eprom_r(dev)<<(15-i)); } diff --git a/drivers/staging/rtl8192e/rtl_eeprom.h b/drivers/staging/rtl8192e/rtl_eeprom.h index f765efbf809..9452e1683a7 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.h +++ b/drivers/staging/rtl8192e/rtl_eeprom.h @@ -26,4 +26,4 @@ #define EPROM_DELAY 10 -u32 eprom_read(struct net_device *dev,u32 addr); +u32 eprom_read(struct net_device *dev, u32 addr); diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c index 225d28a7754..acda37b8184 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.c +++ b/drivers/staging/rtl8192e/rtllib_crypt.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include "rtllib.h" @@ -152,7 +152,7 @@ int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops) } -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name) +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name) { unsigned long flags; struct list_head *ptr; diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h index b01410550c4..49b90b73ed9 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -61,8 +61,8 @@ struct rtllib_crypto_ops { /* maximum number of bytes added by encryption; encrypt buf is * allocated with extra_prefix_len bytes, copy of in_buf, and * extra_postfix_len; encrypt need not use all this space, but - * the result must start at the beginning of the struct buffer and correct - * length must be returned */ + * the result must start at the beginning of the struct buffer and + * correct length must be returned */ int extra_prefix_len, extra_postfix_len; struct module *owner; @@ -77,9 +77,9 @@ struct rtllib_crypt_data { int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops); int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops); -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name); +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name); void rtllib_crypt_deinit_entries(struct rtllib_device *, int); void rtllib_crypt_deinit_handler(unsigned long); void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, - struct rtllib_crypt_data **crypt); + struct rtllib_crypt_data **crypt); #endif diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 9e640c24b89..306d6ff707a 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -56,10 +56,10 @@ struct rtllib_ccmp_data { void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { - crypto_cipher_encrypt_one((void*)tfm, ct, pt); + crypto_cipher_encrypt_one((void *)tfm, ct, pt); } -static void * rtllib_ccmp_init(int key_idx) +static void *rtllib_ccmp_init(int key_idx) { struct rtllib_ccmp_data *priv; @@ -69,7 +69,7 @@ static void * rtllib_ccmp_init(int key_idx) memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; - priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " "crypto API aes\n"); @@ -81,7 +81,7 @@ static void * rtllib_ccmp_init(int key_idx) fail: if (priv) { if (priv->tfm) - crypto_free_cipher((void*)priv->tfm); + crypto_free_cipher((void *)priv->tfm); kfree(priv); } @@ -93,7 +93,7 @@ static void rtllib_ccmp_deinit(void *priv) { struct rtllib_ccmp_data *_priv = priv; if (_priv && _priv->tfm) - crypto_free_cipher((void*)_priv->tfm); + crypto_free_cipher((void *)_priv->tfm); kfree(priv); } @@ -124,7 +124,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, /* qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x08)); - */ + */ qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x80)); aad_len = 22; @@ -192,7 +192,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int data_len, i; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) @@ -232,7 +233,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) mic = skb_put(skb, CCMP_MIC_LEN); - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, + b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -262,7 +264,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) struct rtllib_ccmp_data *key = priv; u8 keyidx, *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 pn[6]; if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { @@ -308,7 +311,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -4; } if (!tcb_desc->bHwSec) { - size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; + size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - + CCMP_MIC_LEN; u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; u8 *b0 = key->rx_b0; u8 *b = key->rx_b; @@ -376,7 +380,7 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) data->rx_pn[4] = seq[1]; data->rx_pn[5] = seq[0]; } - crypto_cipher_setkey((void*)data->tfm, data->key, CCMP_TK_LEN); + crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); } else if (len == 0) data->key_set = 0; else @@ -410,7 +414,7 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_ccmp_print_stats(char *p, void *priv) +static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 89da28de571..c4e490e57ad 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -18,15 +18,13 @@ #include #include #include -#include -#include "rtllib.h" - - +#include #include #include - #include +#include "rtllib.h" + struct rtllib_tkip_data { #define TKIP_KEY_LEN 32 u8 key[TKIP_KEY_LEN]; @@ -39,7 +37,7 @@ struct rtllib_tkip_data { u32 rx_iv32; u16 rx_iv16; - bool initialized; + bool initialized; u16 rx_ttak[5]; int rx_phase1_done; u32 rx_iv32_new; @@ -58,7 +56,7 @@ struct rtllib_tkip_data { u8 rx_hdr[16], tx_hdr[16]; }; -static void * rtllib_tkip_init(int key_idx) +static void *rtllib_tkip_init(int key_idx) { struct rtllib_tkip_data *priv; @@ -181,8 +179,7 @@ static inline u16 Mk16_le(u16 *v) } -static const u16 Sbox[256] = -{ +static const u16 Sbox[256] = { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, @@ -303,7 +300,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int len; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; u8 rc4key[16], *icv; @@ -322,7 +320,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, + tkey->tx_iv16); } else tkey->tx_phase1_done = 1; @@ -360,7 +359,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); - ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); + ret = crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); } tkey->tx_iv16++; @@ -384,7 +383,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 iv32; u16 iv16; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; u8 icv[4]; @@ -422,23 +422,25 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); pos += 8; - if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) - { + if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) { if ((iv32 < tkey->rx_iv32 || - (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16))&&tkey->initialized) { + (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) && + tkey->initialized) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), - tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); + printk(KERN_DEBUG "TKIP: replay detected: STA=" + MAC_FMT + " previous TSC %08x%04x received TSC " + "%08x%04x\n", MAC_ARG(hdr->addr2), + tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; return -4; } - tkey->initialized = true; + tkey->initialized = true; if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1(tkey->rx_ttak, tkey->key, + hdr->addr2, iv32); tkey->rx_phase1_done = 1; } tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); @@ -451,7 +453,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", + "received packet from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); } return -7; @@ -465,8 +467,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(icv, pos + plen, 4) != 0) { if (iv32 != tkey->rx_iv32) { - /* Previously cached Phase1 result was already lost, so - * it needs to be recalculated for the next packet. */ + /* Previously cached Phase1 result was already + * lost, so it needs to be recalculated for the + * next packet. */ tkey->rx_phase1_done = 0; } if (net_ratelimit()) { @@ -493,26 +496,26 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, - u8 * data, size_t data_len, u8 * mic) +static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) { - struct hash_desc desc; - struct scatterlist sg[2]; + struct hash_desc desc; + struct scatterlist sg[2]; - if (tfm_michael == NULL) { - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); + if (tfm_michael == NULL) { + printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); + return -1; + } + sg_init_table(sg, 2); + sg_set_buf(&sg[0], hdr, 16); + sg_set_buf(&sg[1], data, data_len); - if (crypto_hash_setkey(tfm_michael, key, 8)) - return -1; + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; - desc.tfm = tfm_michael; - desc.flags = 0; - return crypto_hash_digest(&desc, sg, data_len + 16, mic); + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); } static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) @@ -563,12 +566,11 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) michael_mic_hdr(skb, tkey->tx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } pos = skb_put(skb, 8); if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; return 0; @@ -597,7 +599,8 @@ static void rtllib_michael_mic_failure(struct net_device *dev, } static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv, struct rtllib_device* ieee) + int hdr_len, void *priv, + struct rtllib_device *ieee) { struct rtllib_tkip_data *tkey = priv; u8 mic[8]; @@ -609,29 +612,30 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; michael_mic_hdr(skb, tkey->rx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; - if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { + if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0) || + (ieee->force_mic_error)) { struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from " MAC_FMT " keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); - printk("%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ - ieee->force_mic_error); + printk(KERN_DEBUG "%d, force_mic_error = %d\n", + (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ + ieee->force_mic_error); if (skb->dev) { - printk("skb->dev != NULL\n"); + printk(KERN_INFO "skb->dev != NULL\n"); rtllib_michael_mic_failure(skb->dev, hdr, keyidx); - } + } tkey->dot11RSNAStatsTKIPLocalMICFailures++; - ieee->force_mic_error = false; + ieee->force_mic_error = false; return -1; } @@ -711,7 +715,7 @@ static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_tkip_print_stats(char *p, void *priv) +static char *rtllib_tkip_print_stats(char *p, void *priv) { struct rtllib_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -751,7 +755,7 @@ static struct rtllib_crypto_ops rtllib_crypt_tkip = { .print_stats = rtllib_tkip_print_stats, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ - .owner = THIS_MODULE, + .owner = THIS_MODULE, }; @@ -768,5 +772,5 @@ void __exit rtllib_crypto_tkip_exit(void) void rtllib_tkip_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 78a749f5efa..c59bf10fe78 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include @@ -29,12 +29,12 @@ struct prism2_wep_data { u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; - struct crypto_blkcipher *tx_tfm; - struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; + struct crypto_blkcipher *rx_tfm; }; -static void * prism2_wep_init(int keyidx) +static void *prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; @@ -45,19 +45,19 @@ static void * prism2_wep_init(int keyidx) priv->key_idx = keyidx; priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->tx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->tx_tfm = NULL; - goto fail; - } - priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->rx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->rx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -66,12 +66,12 @@ static void * prism2_wep_init(int keyidx) fail: if (priv) { - if (priv->tx_tfm) - crypto_free_blkcipher(priv->tx_tfm); - if (priv->rx_tfm) - crypto_free_blkcipher(priv->rx_tfm); - kfree(priv); - } + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); + kfree(priv); + } return NULL; } @@ -81,11 +81,11 @@ static void prism2_wep_deinit(void *priv) struct prism2_wep_data *_priv = priv; if (_priv) { - if (_priv->tx_tfm) - crypto_free_blkcipher(_priv->tx_tfm); - if (_priv->rx_tfm) - crypto_free_blkcipher(_priv->rx_tfm); - } + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } kfree(priv); } @@ -101,14 +101,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; u32 crc; u8 *icv; struct scatterlist sg; if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len){ - printk("Error!!!headroom=%d tailroom=%d skblen=%d hdr_len=%d\n",skb_headroom(skb),skb_tailroom(skb),skb->len,hdr_len); + printk(KERN_ERR "Error!!! headroom=%d tailroom=%d skblen=%d" + " hdr_len=%d\n", skb_headroom(skb), skb_tailroom(skb), + skb->len, hdr_len); return -1; } len = skb->len - hdr_len; @@ -157,8 +160,8 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } -/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP part of - * the frame: IV (4 bytes), encrypted payload (including SNAP header), +/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP + * part of the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. * * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on @@ -170,7 +173,8 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; u32 crc; u8 icv[4]; @@ -245,7 +249,7 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) } -static char * prism2_wep_print_stats(char *p, void *priv) +static char *prism2_wep_print_stats(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -284,5 +288,5 @@ void __exit rtllib_crypto_wep_exit(void) void rtllib_wep_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_endianfree.h b/drivers/staging/rtl8192e/rtllib_endianfree.h index 46d8f196248..b268605a52a 100644 --- a/drivers/staging/rtl8192e/rtllib_endianfree.h +++ b/drivers/staging/rtl8192e/rtllib_endianfree.h @@ -14,26 +14,28 @@ #define BYTE_ORDER __MACHINE_LITTLE_ENDIAN #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) ((u16)(_val)) -#define EF4Byte(_val) ((u32)(_val)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) ((u16)(_val)) +#define EF4Byte(_val) ((u32)(_val)) #else -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) -#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8)|\ - ((((u32)(_val))&0x00ff0000)>>8)|\ - ((((u32)(_val))&0xff000000)>>24)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) \ + (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) +#define EF4Byte(_val) \ + (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8)|\ + ((((u32)(_val))&0x00ff0000)>>8)|\ + ((((u32)(_val))&0xff000000)>>24)) #endif #define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr))) #define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr))) #define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr))) -#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val) -#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val) -#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val) +#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr))) = EF1Byte(_val) +#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr))) = EF2Byte(_val) +#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr))) = EF4Byte(_val) #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN #define H2N1BYTE(_val) ((u8)(_val)) #define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ @@ -63,13 +65,14 @@ #endif #define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen))) -#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) +#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \ + (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) #define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart)))) #define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_32(__BitLen) \ ) @@ -78,7 +81,7 @@ ( \ LE_P4BYTE_TO_HOST_4BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \ @@ -86,8 +89,8 @@ EF4Byte( \ LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ | \ - ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \ - ); + ((((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset)) \ + ); #define BIT_LEN_MASK_16(__BitLen) \ @@ -101,7 +104,7 @@ #define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_16(__BitLen) \ ) @@ -110,16 +113,16 @@ ( \ LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \ *((u16 *)(__pStart)) = \ EF2Byte( \ LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << \ + (__BitOffset)) \ + ); #define BIT_LEN_MASK_8(__BitLen) \ (0xFF >> (8 - (__BitLen))) @@ -132,7 +135,7 @@ #define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_8(__BitLen) \ ) @@ -141,16 +144,17 @@ ( \ LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen)) \ ) -#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u8 *)(__pStart)) = \ - EF1Byte( \ +#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u8 *)(__pStart)) = EF1Byte( \ LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << \ + (__BitOffset)) \ + ); -#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment)) +#define N_BYTE_ALIGMENT(__Value, __Aligment) \ + ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / \ + __Aligment) * __Aligment)) #endif From d57429f05eac870a1c099045bf2735edf3aa70ab Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 21:12:29 -0500 Subject: [PATCH 0533/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XII This patch removes all the errors and most of the warnings generated by checkpatch -f. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 1211 ++++++++++++---------- drivers/staging/rtl8192e/rtllib_module.c | 30 +- drivers/staging/rtl8192e/rtllib_tx.c | 1 - 3 files changed, 655 insertions(+), 587 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2a394ee9f75..c7b3641f30b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -64,14 +64,14 @@ /** * container_of - cast a member of a structure out to the containing structure * - * @ptr: the pointer to the member. + * @ptr: the pointer to the member. * @type: the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member)*__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); }) #endif #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) @@ -79,21 +79,24 @@ #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) - #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) - #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) +#define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z) +#define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y) - #define queue_work_rsl(x,y) queue_work(x,y) - #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) +#define queue_work_rsl(x, y) queue_work(x, y) +#define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y) - #define container_of_work_rsl(x,y,z) container_of(x,y,z) - #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z) +#define container_of_work_rsl(x, y, z) container_of(x, y, z) +#define container_of_dwork_rsl(x, y, z) \ + container_of(container_of(x, struct delayed_work, work), y, z) - #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len) +#define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \ + iwe_stream_add_event(info, start, stop, iwe, len) - #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p) +#define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \ + iwe_stream_add_point(info, start, stop, iwe, p) - #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y) - #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y) +#define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y) +#define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y) static inline void *netdev_priv_rsl(struct net_device *dev) { @@ -108,18 +111,18 @@ static inline void *netdev_priv_rsl(struct net_device *dev) /* added for rtl819x tx procedure */ #define MAX_QUEUE_SIZE 0x10 -#define BK_QUEUE 0 -#define BE_QUEUE 1 -#define VI_QUEUE 2 -#define VO_QUEUE 3 -#define HCCA_QUEUE 4 -#define TXCMD_QUEUE 5 -#define MGNT_QUEUE 6 -#define HIGH_QUEUE 7 -#define BEACON_QUEUE 8 +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define HCCA_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define BEACON_QUEUE 8 -#define LOW_QUEUE BE_QUEUE -#define NORMAL_QUEUE MGNT_QUEUE +#define LOW_QUEUE BE_QUEUE +#define NORMAL_QUEUE MGNT_QUEUE #ifndef IW_MODE_MESH #define IW_MODE_MESH 7 @@ -139,8 +142,10 @@ static inline void *netdev_priv_rsl(struct net_device *dev) #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 #define RT_RF_LPS_DISALBE_2R BIT30 #define RT_RF_LPS_LEVEL_ASPM BIT31 -#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) -#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG))) +#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \ + ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \ + (pPSC->CurPsLevel &= (~(_PS_FLAG))) #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) /* defined for skb cb field */ @@ -203,36 +208,36 @@ struct cb_desc { }; /*--------------------------Define -------------------------------------------*/ -#define MGN_1M 0x02 -#define MGN_2M 0x04 -#define MGN_5_5M 0x0b -#define MGN_11M 0x16 +#define MGN_1M 0x02 +#define MGN_2M 0x04 +#define MGN_5_5M 0x0b +#define MGN_11M 0x16 -#define MGN_6M 0x0c -#define MGN_9M 0x12 -#define MGN_12M 0x18 -#define MGN_18M 0x24 -#define MGN_24M 0x30 -#define MGN_36M 0x48 -#define MGN_48M 0x60 -#define MGN_54M 0x6c +#define MGN_6M 0x0c +#define MGN_9M 0x12 +#define MGN_12M 0x18 +#define MGN_18M 0x24 +#define MGN_24M 0x30 +#define MGN_36M 0x48 +#define MGN_48M 0x60 +#define MGN_54M 0x6c -#define MGN_MCS0 0x80 -#define MGN_MCS1 0x81 -#define MGN_MCS2 0x82 -#define MGN_MCS3 0x83 -#define MGN_MCS4 0x84 -#define MGN_MCS5 0x85 -#define MGN_MCS6 0x86 -#define MGN_MCS7 0x87 -#define MGN_MCS8 0x88 -#define MGN_MCS9 0x89 -#define MGN_MCS10 0x8a -#define MGN_MCS11 0x8b -#define MGN_MCS12 0x8c -#define MGN_MCS13 0x8d -#define MGN_MCS14 0x8e -#define MGN_MCS15 0x8f +#define MGN_MCS0 0x80 +#define MGN_MCS1 0x81 +#define MGN_MCS2 0x82 +#define MGN_MCS3 0x83 +#define MGN_MCS4 0x84 +#define MGN_MCS5 0x85 +#define MGN_MCS6 0x86 +#define MGN_MCS7 0x87 +#define MGN_MCS8 0x88 +#define MGN_MCS9 0x89 +#define MGN_MCS10 0x8a +#define MGN_MCS11 0x8b +#define MGN_MCS12 0x8c +#define MGN_MCS13 0x8d +#define MGN_MCS14 0x8e +#define MGN_MCS15 0x8f #define MGN_MCS0_SG 0x90 #define MGN_MCS1_SG 0x91 #define MGN_MCS2_SG 0x92 @@ -251,7 +256,7 @@ struct cb_desc { #define MGN_MCS15_SG 0x9f -enum _ReasonCode{ +enum _ReasonCode { unspec_reason = 0x1, auth_not_valid = 0x2, deauth_lv_ss = 0x3, @@ -273,7 +278,7 @@ enum _ReasonCode{ invalid_AKMP = 0x14, unsup_RSNIEver = 0x15, invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, + auth_802_1x_fail = 0x17, ciper_reject = 0x18, QoS_unspec = 0x20, @@ -282,7 +287,7 @@ enum _ReasonCode{ no_facility = 0x23, req_declined = 0x25, invalid_param = 0x26, - req_not_honored= 0x27, + req_not_honored = 0x27, TS_not_created = 0x2F, DL_not_allowed = 0x30, dest_not_exist = 0x31, @@ -308,10 +313,9 @@ enum hal_def_variable { HW_DEF_GPIO, HAL_DEF_PCI_SUPPORT_ASPM, HAL_DEF_THERMAL_VALUE, - HAL_DEF_USB_IN_TOKEN_REV, + HAL_DEF_USB_IN_TOKEN_REV, }; - enum hw_variables { HW_VAR_ETHER_ADDR, HW_VAR_MULTICAST_REG, @@ -355,14 +359,14 @@ enum hw_variables { HW_VAR_RF_STATE, HW_VAR_RF_OFF_BY_HW, HW_VAR_BUS_SPEED, - HW_VAR_SET_DEV_POWER, + HW_VAR_SET_DEV_POWER, HW_VAR_RCR, HW_VAR_RATR_0, HW_VAR_RRSR, HW_VAR_CPU_RST, HW_VAR_CECHK_BSSID, - HW_VAR_LBK_MODE, + HW_VAR_LBK_MODE, HW_VAR_AES_11N_FIX, HW_VAR_USB_RX_AGGR, HW_VAR_USER_CONTROL_TURBO_MODE, @@ -400,7 +404,7 @@ enum hw_variables { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_INT_MIGRATION, HW_VAR_INT_AC, - HW_VAR_RF_TIMING, + HW_VAR_RF_TIMING, }; enum rt_op_mode { @@ -411,7 +415,10 @@ enum rt_op_mode { }; -#define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) +#define aSifsTime \ + (((priv->rtllib->current_network.mode == IEEE_A) \ + || (priv->rtllib->current_network.mode == IEEE_N_24G) \ + || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10) #define MGMT_QUEUE_NUM 5 @@ -452,13 +459,14 @@ enum rt_op_mode { #define IEEE_CRYPT_ALG_NAME_LEN 16 #define MAX_IE_LEN 0xff -#define RT_ASSERT_RET(_Exp) do {} while(0) -#define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) +#define RT_ASSERT_RET(_Exp) do {} while (0) +#define RT_ASSERT_RET_VALUE(_Exp, Ret) \ + do {} while (0) struct ieee_param { u32 cmd; u8 sta_addr[ETH_ALEN]; - union { + union { struct { u8 name; u32 value; @@ -468,7 +476,7 @@ struct ieee_param { u8 reserved[32]; u8 data[0]; } wpa_ie; - struct{ + struct { int command; int reason_code; } mlme; @@ -510,8 +518,8 @@ struct ieee_param { #define RTLLIB_3ADDR_LEN 24 #define RTLLIB_4ADDR_LEN 30 #define RTLLIB_FCS_LEN 4 -#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) -#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) +#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) +#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) #define RTLLIB_MGMT_HDR_LEN 24 #define RTLLIB_DATA_HDR3_LEN 24 #define RTLLIB_DATA_HDR4_LEN 30 @@ -583,57 +591,59 @@ struct ieee_param { #define RTLLIB_SCTL_SEQ 0xFFF0 /* QOS control */ -#define RTLLIB_QCTL_TID 0x000F +#define RTLLIB_QCTL_TID 0x000F #define FC_QOS_BIT BIT7 -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) -#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT))) +#define IsQoSDataFrame(pframe) \ + ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \ + (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER) +#define SN_LESS(a, b) (((a-b)&0x800) != 0) #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 enum act_category { - ACT_CAT_QOS = 1, - ACT_CAT_DLS = 2, - ACT_CAT_BA = 3, - ACT_CAT_HT = 7, - ACT_CAT_WMM = 17, + ACT_CAT_QOS = 1, + ACT_CAT_DLS = 2, + ACT_CAT_BA = 3, + ACT_CAT_HT = 7, + ACT_CAT_WMM = 17, }; enum ts_action { - ACT_ADDTSREQ = 0, - ACT_ADDTSRSP = 1, - ACT_DELTS = 2, - ACT_SCHEDULE = 3, + ACT_ADDTSREQ = 0, + ACT_ADDTSRSP = 1, + ACT_DELTS = 2, + ACT_SCHEDULE = 3, }; enum ba_action { - ACT_ADDBAREQ = 0, - ACT_ADDBARSP = 1, - ACT_DELBA = 2, + ACT_ADDBAREQ = 0, + ACT_ADDBARSP = 1, + ACT_DELBA = 2, }; enum init_gain_op_type { - IG_Backup=0, + IG_Backup = 0, IG_Restore, IG_Max }; enum led_ctl_mode { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, - LED_CTL_STOP_WPS_FAIL = 12, + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, + LED_CTL_STOP_WPS_FAIL = 12, LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, }; @@ -670,25 +680,29 @@ enum wireless_network_type { /* debug macros */ extern u32 rtllib_debug_level; #define RTLLIB_DEBUG(level, fmt, args...) \ -do { if (rtllib_debug_level & (level)) \ - printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0) +do { \ + if (rtllib_debug_level & (level)) \ + printk(KERN_DEBUG "rtllib: " fmt, ## args); \ +} while (0) + #define RTLLIB_DEBUG_DATA(level, data, datalen) \ - do{ if ((rtllib_debug_level & (level)) == (level)) \ - { \ + do { \ + if ((rtllib_debug_level & (level)) == (level)) { \ int i; \ - u8* pdata = (u8*) data; \ + u8 *pdata = (u8 *)data; \ printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ - for (i=0; i<(int)(datalen); i++) \ - { \ + for (i = 0; i < (int)(datalen); i++) { \ printk("%2.2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ + if ((i+1)%16 == 0) \ + printk("\n"); \ } \ printk("\n"); \ } \ } while (0) #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] +#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ + ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] /* * To use the debug system; @@ -714,22 +728,22 @@ do { if (rtllib_debug_level & (level)) \ * */ -#define RTLLIB_DL_INFO (1<<0) -#define RTLLIB_DL_WX (1<<1) -#define RTLLIB_DL_SCAN (1<<2) -#define RTLLIB_DL_STATE (1<<3) -#define RTLLIB_DL_MGMT (1<<4) -#define RTLLIB_DL_FRAG (1<<5) -#define RTLLIB_DL_EAP (1<<6) -#define RTLLIB_DL_DROP (1<<7) +#define RTLLIB_DL_INFO (1<<0) +#define RTLLIB_DL_WX (1<<1) +#define RTLLIB_DL_SCAN (1<<2) +#define RTLLIB_DL_STATE (1<<3) +#define RTLLIB_DL_MGMT (1<<4) +#define RTLLIB_DL_FRAG (1<<5) +#define RTLLIB_DL_EAP (1<<6) +#define RTLLIB_DL_DROP (1<<7) -#define RTLLIB_DL_TX (1<<8) -#define RTLLIB_DL_RX (1<<9) +#define RTLLIB_DL_TX (1<<8) +#define RTLLIB_DL_RX (1<<9) #define RTLLIB_DL_HT (1<<10) #define RTLLIB_DL_BA (1<<11) #define RTLLIB_DL_TS (1<<12) -#define RTLLIB_DL_QOS (1<<13) +#define RTLLIB_DL_QOS (1<<13) #define RTLLIB_DL_REORDER (1<<14) #define RTLLIB_DL_IOT (1<<15) #define RTLLIB_DL_IPS (1<<16) @@ -753,25 +767,24 @@ do { if (rtllib_debug_level & (level)) \ /* Added by Annie, 2005-11-22. */ #define MAX_STR_LEN 64 -/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ -#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') -#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if ((_Comp) & level) \ - { \ - int __i; \ - u8 struct buffer[MAX_STR_LEN]; \ - int length = (_Len\n", _Len, struct buffer); \ - } +/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */ +#define PRINTABLE(_ch) (_ch > '!' && _ch < '~') +#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ + if ((_Comp) & level) { \ + int __i; \ + u8 struct buffer[MAX_STR_LEN]; \ + int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\ + memset(struct buffer, 0, MAX_STR_LEN); \ + memcpy(struct buffer, (u8 *)_Ptr, length); \ + for (__i = 0; __i < MAX_STR_LEN; __i++) { \ + if (!PRINTABLE(struct buffer[__i])) \ + struct buffer[__i] = '?'; \ + } \ + struct buffer[length] = '\0'; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + printk(": %d, <%s>\n", _Len, struct buffer); \ + } #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ @@ -790,17 +803,17 @@ do { if (rtllib_debug_level & (level)) \ struct rtllib_snap_hdr { - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ -} __attribute__ ((packed)); +} __packed; -enum _REG_PREAMBLE_MODE{ +enum _REG_PREAMBLE_MODE { PREAMBLE_LONG = 1, PREAMBLE_AUTO = 2, - PREAMBLE_SHORT= 3, + PREAMBLE_SHORT = 3, }; #define SNAP_SIZE sizeof(struct rtllib_snap_hdr) @@ -841,65 +854,65 @@ enum _REG_PREAMBLE_MODE{ /* Status codes */ enum rtllib_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, + WLAN_STATUS_SUCCESS = 0, + WLAN_STATUS_UNSPECIFIED_FAILURE = 1, + WLAN_STATUS_CAPS_UNSUPPORTED = 10, + WLAN_STATUS_REASSOC_NO_ASSOC = 11, + WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, + WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, + WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, + WLAN_STATUS_CHALLENGE_FAIL = 15, + WLAN_STATUS_AUTH_TIMEOUT = 16, + WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, + WLAN_STATUS_ASSOC_DENIED_RATES = 18, + /* 802.11b */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, + WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, + WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, + /* 802.11h */ + WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, + WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, + WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, + /* 802.11g */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, + WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, + /* 802.11i */ + WLAN_STATUS_INVALID_IE = 40, + WLAN_STATUS_INVALID_GROUP_CIPHER = 41, + WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, + WLAN_STATUS_INVALID_AKMP = 43, + WLAN_STATUS_UNSUPP_RSN_VERSION = 44, + WLAN_STATUS_INVALID_RSN_IE_CAP = 45, + WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, }; /* Reason codes */ enum rtllib_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, + WLAN_REASON_UNSPECIFIED = 1, + WLAN_REASON_PREV_AUTH_NOT_VALID = 2, + WLAN_REASON_DEAUTH_LEAVING = 3, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, + WLAN_REASON_DISASSOC_AP_BUSY = 5, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, + WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, + /* 802.11h */ + WLAN_REASON_DISASSOC_BAD_POWER = 10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, + /* 802.11i */ + WLAN_REASON_INVALID_IE = 13, + WLAN_REASON_MIC_FAILURE = 14, + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, + WLAN_REASON_IE_DIFFERENT = 17, + WLAN_REASON_INVALID_GROUP_CIPHER = 18, + WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, + WLAN_REASON_INVALID_AKMP = 20, + WLAN_REASON_UNSUPP_RSN_VERSION = 21, + WLAN_REASON_INVALID_RSN_IE_CAP = 22, + WLAN_REASON_IEEE8021X_FAILED = 23, + WLAN_REASON_CIPHER_SUITE_REJECTED = 24, }; #define RTLLIB_STATMASK_SIGNAL (1<<0) @@ -915,13 +928,13 @@ enum rtllib_reasoncode { #define RTLLIB_52GHZ_BAND (1<<1) #define RTLLIB_CCK_RATE_LEN 4 -#define RTLLIB_CCK_RATE_1MB 0x02 -#define RTLLIB_CCK_RATE_2MB 0x04 -#define RTLLIB_CCK_RATE_5MB 0x0B -#define RTLLIB_CCK_RATE_11MB 0x16 +#define RTLLIB_CCK_RATE_1MB 0x02 +#define RTLLIB_CCK_RATE_2MB 0x04 +#define RTLLIB_CCK_RATE_5MB 0x0B +#define RTLLIB_CCK_RATE_11MB 0x16 #define RTLLIB_OFDM_RATE_LEN 8 -#define RTLLIB_OFDM_RATE_6MB 0x0C -#define RTLLIB_OFDM_RATE_9MB 0x12 +#define RTLLIB_OFDM_RATE_6MB 0x0C +#define RTLLIB_OFDM_RATE_9MB 0x12 #define RTLLIB_OFDM_RATE_12MB 0x18 #define RTLLIB_OFDM_RATE_18MB 0x24 #define RTLLIB_OFDM_RATE_24MB 0x30 @@ -943,12 +956,12 @@ enum rtllib_reasoncode { #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) -#define RTLLIB_CCK_RATES_MASK 0x0000000F +#define RTLLIB_CCK_RATES_MASK 0x0000000F #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ RTLLIB_CCK_RATE_2MB_MASK) #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ - RTLLIB_CCK_RATE_5MB_MASK | \ - RTLLIB_CCK_RATE_11MB_MASK) + RTLLIB_CCK_RATE_5MB_MASK | \ + RTLLIB_CCK_RATE_11MB_MASK) #define RTLLIB_OFDM_RATES_MASK 0x00000FF0 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ @@ -961,11 +974,11 @@ enum rtllib_reasoncode { RTLLIB_OFDM_RATE_48MB_MASK | \ RTLLIB_OFDM_RATE_54MB_MASK) #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ - RTLLIB_CCK_DEFAULT_RATES_MASK) + RTLLIB_CCK_DEFAULT_RATES_MASK) #define RTLLIB_NUM_OFDM_RATES 8 -#define RTLLIB_NUM_CCK_RATES 4 -#define RTLLIB_OFDM_SHIFT_MASK_A 4 +#define RTLLIB_NUM_CCK_RATES 4 +#define RTLLIB_OFDM_SHIFT_MASK_A 4 /* this is stolen and modified from the madwifi driver*/ @@ -992,7 +1005,6 @@ struct ieee_ibss_seq { * information for frames received. Not setting these will not cause * any adverse affects. */ struct rtllib_rx_stats { -#if 1 u64 mac_time; s8 rssi; u8 signal; @@ -1038,7 +1050,7 @@ struct rtllib_rx_stats { bool bPacketMatchBSSID; bool bIsCCK; bool bPacketToSelf; - u8* virtual_address; + u8 *virtual_address; u16 packetlength; u16 fraglength; u16 fragoffset; @@ -1049,8 +1061,6 @@ struct rtllib_rx_stats { char cck_adc_pwdb[4]; u16 Seq_Num; u8 nTotalAggPkt; -#endif - }; /* IEEE 802.11 requires that STA supports concurrent reception of at least @@ -1096,14 +1106,14 @@ struct rtllib_device; #include "rtllib_crypt.h" -#define SEC_KEY_1 (1<<0) -#define SEC_KEY_2 (1<<1) -#define SEC_KEY_3 (1<<2) -#define SEC_KEY_4 (1<<3) +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) #define SEC_ACTIVE_KEY (1<<4) #define SEC_AUTH_MODE (1<<5) #define SEC_UNICAST_GROUP (1<<6) -#define SEC_LEVEL (1<<7) +#define SEC_LEVEL (1<<7) #define SEC_ENABLED (1<<8) #define SEC_ENCRYPT (1<<9) @@ -1113,28 +1123,28 @@ struct rtllib_device; #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ -#define SEC_ALG_NONE 0 -#define SEC_ALG_WEP 1 -#define SEC_ALG_TKIP 2 -#define SEC_ALG_CCMP 4 +#define SEC_ALG_NONE 0 +#define SEC_ALG_WEP 1 +#define SEC_ALG_TKIP 2 +#define SEC_ALG_CCMP 4 #define WEP_KEYS 4 #define WEP_KEY_LEN 13 -#define SCM_KEY_LEN 32 +#define SCM_KEY_LEN 32 #define SCM_TEMPORAL_KEY_LENGTH 16 struct rtllib_security { u16 active_key:2, - enabled:1, + enabled:1, auth_mode:2, - auth_algo:4, - unicast_uses_group:1, + auth_algo:4, + unicast_uses_group:1, encrypt:1; u8 key_sizes[WEP_KEYS]; u8 keys[WEP_KEYS][SCM_KEY_LEN]; u8 level; u16 flags; -} __attribute__ ((packed)); +} __packed; /* @@ -1143,75 +1153,75 @@ struct rtllib_security { Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | + | | tion | (BSSID) | | | ence | data | | `-------------------------------------------------------------------' Total: 28-2340 bytes */ /* Management Frame Information Element Types */ enum rtllib_mfie { - MFIE_TYPE_SSID = 0, - MFIE_TYPE_RATES = 1, - MFIE_TYPE_FH_SET = 2, - MFIE_TYPE_DS_SET = 3, - MFIE_TYPE_CF_SET = 4, - MFIE_TYPE_TIM = 5, - MFIE_TYPE_IBSS_SET = 6, - MFIE_TYPE_COUNTRY = 7, - MFIE_TYPE_HOP_PARAMS = 8, - MFIE_TYPE_HOP_TABLE = 9, - MFIE_TYPE_REQUEST = 10, - MFIE_TYPE_CHALLENGE = 16, - MFIE_TYPE_POWER_CONSTRAINT = 32, - MFIE_TYPE_POWER_CAPABILITY = 33, - MFIE_TYPE_TPC_REQUEST = 34, - MFIE_TYPE_TPC_REPORT = 35, - MFIE_TYPE_SUPP_CHANNELS = 36, - MFIE_TYPE_CSA = 37, - MFIE_TYPE_MEASURE_REQUEST = 38, - MFIE_TYPE_MEASURE_REPORT = 39, - MFIE_TYPE_QUIET = 40, - MFIE_TYPE_IBSS_DFS = 41, - MFIE_TYPE_ERP = 42, - MFIE_TYPE_HT_CAP= 45, + MFIE_TYPE_SSID = 0, + MFIE_TYPE_RATES = 1, + MFIE_TYPE_FH_SET = 2, + MFIE_TYPE_DS_SET = 3, + MFIE_TYPE_CF_SET = 4, + MFIE_TYPE_TIM = 5, + MFIE_TYPE_IBSS_SET = 6, + MFIE_TYPE_COUNTRY = 7, + MFIE_TYPE_HOP_PARAMS = 8, + MFIE_TYPE_HOP_TABLE = 9, + MFIE_TYPE_REQUEST = 10, + MFIE_TYPE_CHALLENGE = 16, + MFIE_TYPE_POWER_CONSTRAINT = 32, + MFIE_TYPE_POWER_CAPABILITY = 33, + MFIE_TYPE_TPC_REQUEST = 34, + MFIE_TYPE_TPC_REPORT = 35, + MFIE_TYPE_SUPP_CHANNELS = 36, + MFIE_TYPE_CSA = 37, + MFIE_TYPE_MEASURE_REQUEST = 38, + MFIE_TYPE_MEASURE_REPORT = 39, + MFIE_TYPE_QUIET = 40, + MFIE_TYPE_IBSS_DFS = 41, + MFIE_TYPE_ERP = 42, + MFIE_TYPE_HT_CAP = 45, MFIE_TYPE_RSN = 48, MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, + MFIE_TYPE_HT_INFO = 61, + MFIE_TYPE_AIRONET = 133, MFIE_TYPE_GENERIC = 221, - MFIE_TYPE_QOS_PARAMETER = 222, + MFIE_TYPE_QOS_PARAMETER = 222, }; /* Minimal header; can be used for passing 802.11 frames with sufficient * information to determine what type of underlying data type is actually * stored in the data. */ struct rtllib_pspoll_hdr { - __le16 frame_ctl; - __le16 aid; + __le16 frame_ctl; + __le16 aid; u8 bssid[ETH_ALEN]; - u8 ta[ETH_ALEN]; -} __attribute__ ((packed)); + u8 ta[ETH_ALEN]; +} __packed; struct rtllib_hdr { - __le16 frame_ctl; - __le16 duration_id; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 payload[0]; +} __packed; struct rtllib_hdr_1addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_2addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_3addr { __le16 frame_ctl; @@ -1220,8 +1230,8 @@ struct rtllib_hdr_3addr { u8 addr2[ETH_ALEN]; u8 addr3[ETH_ALEN]; __le16 seq_ctl; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_4addr { __le16 frame_ctl; @@ -1231,8 +1241,8 @@ struct rtllib_hdr_4addr { u8 addr3[ETH_ALEN]; __le16 seq_ctl; u8 addr4[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_3addrqos { __le16 frame_ctl; @@ -1243,7 +1253,7 @@ struct rtllib_hdr_3addrqos { __le16 seq_ctl; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_hdr_4addrqos { __le16 frame_ctl; @@ -1255,13 +1265,13 @@ struct rtllib_hdr_4addrqos { u8 addr4[ETH_ALEN]; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_info_element { u8 id; u8 len; u8 data[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_authentication { struct rtllib_hdr_3addr header; @@ -1270,33 +1280,33 @@ struct rtllib_authentication { __le16 status; /*challenge*/ struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_disauth { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_disassoc { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_probe_request { struct rtllib_hdr_3addr header; /* SSID, supported rates */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_probe_response { struct rtllib_hdr_3addr header; u32 time_stamp[2]; __le16 beacon_interval; __le16 capability; - /* SSID, supported rates, FH params, DS params, - * CF params, IBSS params, TIM (if beacon), RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + /* SSID, supported rates, FH params, DS params, + * CF params, IBSS params, TIM (if beacon), RSN */ + struct rtllib_info_element info_element[0]; +} __packed; /* Alias beacon for probe_response */ #define rtllib_beacon rtllib_probe_response @@ -1306,8 +1316,8 @@ struct rtllib_assoc_request_frame { __le16 capability; __le16 listen_interval; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_reassoc_request_frame { struct rtllib_hdr_3addr header; @@ -1315,8 +1325,8 @@ struct rtllib_reassoc_request_frame { __le16 listen_interval; u8 current_ap[ETH_ALEN]; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_assoc_response_frame { struct rtllib_hdr_3addr header; @@ -1324,7 +1334,7 @@ struct rtllib_assoc_response_frame { __le16 status; __le16 aid; struct rtllib_info_element info_element[0]; /* supported rates */ -} __attribute__ ((packed)); +} __packed; struct rtllib_txb { u8 nr_frags; @@ -1341,7 +1351,7 @@ struct rtllib_txb { struct rtllib_drv_agg_txb { u8 nr_drv_agg_frames; struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -}__attribute__((packed)); +} __packed; #define MAX_SUBFRAME_COUNT 64 struct rtllib_rxb { @@ -1349,7 +1359,7 @@ struct rtllib_rxb { struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; u8 dst[ETH_ALEN]; u8 src[ETH_ALEN]; -}__attribute__((packed)); +} __packed; union frameqos { u16 shortdata; @@ -1360,7 +1370,7 @@ union frameqos { u16 ack_policy:2; u16 reserved:1; u16 txop:8; - }field; + } field; }; /* SWEEP TABLE ENTRIES NUMBER*/ @@ -1370,15 +1380,15 @@ union frameqos { * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the * main rates information element... */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 96 +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#define MAX_NETWORK_COUNT 96 -#define MAX_CHANNEL_NUMBER 161 +#define MAX_CHANNEL_NUMBER 161 #define RTLLIB_SOFTMAC_SCAN_TIME 100 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) -#define CRC_LENGTH 4U +#define CRC_LENGTH 4U #define MAX_WPA_IE_LEN 64 #define MAX_WZC_IE_LEN 256 @@ -1390,69 +1400,69 @@ union frameqos { /* QoS structure */ #define NETWORK_HAS_QOS_PARAMETERS (1<<3) #define NETWORK_HAS_QOS_INFORMATION (1<<4) -#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ - NETWORK_HAS_QOS_INFORMATION) +#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ + NETWORK_HAS_QOS_INFORMATION) /* 802.11h */ #define NETWORK_HAS_POWER_CONSTRAINT (1<<5) -#define NETWORK_HAS_CSA (1<<6) -#define NETWORK_HAS_QUIET (1<<7) -#define NETWORK_HAS_IBSS_DFS (1<<8) -#define NETWORK_HAS_TPC_REPORT (1<<9) +#define NETWORK_HAS_CSA (1<<6) +#define NETWORK_HAS_QUIET (1<<7) +#define NETWORK_HAS_IBSS_DFS (1<<8) +#define NETWORK_HAS_TPC_REPORT (1<<9) -#define NETWORK_HAS_ERP_VALUE (1<<10) +#define NETWORK_HAS_ERP_VALUE (1<<10) + +#define QOS_QUEUE_NUM 4 +#define QOS_OUI_LEN 3 +#define QOS_OUI_TYPE 2 +#define QOS_ELEMENT_ID 221 +#define QOS_OUI_INFO_SUB_TYPE 0 +#define QOS_OUI_PARAM_SUB_TYPE 1 +#define QOS_VERSION_1 1 +#define QOS_AIFSN_MIN_VALUE 2 -#define QOS_QUEUE_NUM 4 -#define QOS_OUI_LEN 3 -#define QOS_OUI_TYPE 2 -#define QOS_ELEMENT_ID 221 -#define QOS_OUI_INFO_SUB_TYPE 0 -#define QOS_OUI_PARAM_SUB_TYPE 1 -#define QOS_VERSION_1 1 -#define QOS_AIFSN_MIN_VALUE 2 -#if 1 struct rtllib_qos_information_element { - u8 elementID; - u8 length; - u8 qui[QOS_OUI_LEN]; - u8 qui_type; - u8 qui_subtype; - u8 version; - u8 ac_info; -} __attribute__ ((packed)); + u8 elementID; + u8 length; + u8 qui[QOS_OUI_LEN]; + u8 qui_type; + u8 qui_subtype; + u8 version; + u8 ac_info; +} __packed; struct rtllib_qos_ac_parameter { - u8 aci_aifsn; - u8 ecw_min_max; - __le16 tx_op_limit; -} __attribute__ ((packed)); + u8 aci_aifsn; + u8 ecw_min_max; + __le16 tx_op_limit; +} __packed; struct rtllib_qos_parameter_info { - struct rtllib_qos_information_element info_element; - u8 reserved; - struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + struct rtllib_qos_information_element info_element; + u8 reserved; + struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_parameters { - __le16 cw_min[QOS_QUEUE_NUM]; - __le16 cw_max[QOS_QUEUE_NUM]; - u8 aifs[QOS_QUEUE_NUM]; - u8 flag[QOS_QUEUE_NUM]; - __le16 tx_op_limit[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + __le16 cw_min[QOS_QUEUE_NUM]; + __le16 cw_max[QOS_QUEUE_NUM]; + u8 aifs[QOS_QUEUE_NUM]; + u8 flag[QOS_QUEUE_NUM]; + __le16 tx_op_limit[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_data { - struct rtllib_qos_parameters parameters; + struct rtllib_qos_parameters parameters; unsigned int wmm_acm; - int active; - int supported; - u8 param_count; - u8 old_param_count; + int active; + int supported; + u8 param_count; + u8 old_param_count; }; struct rtllib_tim_parameters { - u8 tim_count; - u8 tim_period; -} __attribute__ ((packed)); + u8 tim_count; + u8 tim_period; +} __packed; struct rtllib_wmm_ac_param { u8 ac_aci_acm_aifsn; @@ -1464,7 +1474,7 @@ struct rtllib_wmm_ts_info { u8 ac_dir_tid; u8 ac_up_psb; u8 reserved; -} __attribute__ ((packed)); +} __packed; struct rtllib_wmm_tspec_elem { struct rtllib_wmm_ts_info ts_info; @@ -1483,8 +1493,8 @@ struct rtllib_wmm_tspec_elem { u32 min_phy_rate; u16 surp_band_allow; u16 medium_time; -}__attribute__((packed)); -#endif +} __packed; + enum eap_type { EAP_PACKET = 0, EAPOL_START, @@ -1503,15 +1513,17 @@ static const char *eap_types[] = { static inline const char *eap_get_type(int type) { - return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; + return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : + eap_types[type]; } -static inline u8 Frame_QoSTID(u8* buf) +static inline u8 Frame_QoSTID(u8 *buf) { struct rtllib_hdr_3addr *hdr; u16 fc; hdr = (struct rtllib_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) && + (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid; } @@ -1521,9 +1533,9 @@ struct eapol { u8 version; u8 type; u16 length; -} __attribute__ ((packed)); +} __packed; -struct rtllib_softmac_stats{ +struct rtllib_softmac_stats { unsigned int rx_ass_ok; unsigned int rx_ass_err; unsigned int rx_probe_rq; @@ -1551,7 +1563,7 @@ struct rtllib_softmac_stats{ struct rtllib_info_element_hdr { u8 id; u8 len; -} __attribute__ ((packed)); +} __packed; /* * These are the data types that can make up management packets @@ -1564,7 +1576,7 @@ struct rtllib_info_element_hdr { u16 listen_interval; struct { u16 association_id:14, reserved:2; - } __attribute__ ((packed)); + } __packed; u32 time_stamp[2]; u16 reason; u16 status; @@ -1611,13 +1623,14 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; 0) #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ -#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/ +#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address + * plus ether type*/ struct ether_header { u8 ether_dhost[ETHER_ADDR_LEN]; u8 ether_shost[ETHER_ADDR_LEN]; u16 ether_type; -} __attribute__((packed)); +} __packed; #ifndef ETHERTYPE_PAE #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ @@ -1676,13 +1689,13 @@ struct rtllib_network { u8 wzc_ie[MAX_WZC_IE_LEN]; size_t wzc_ie_len; - struct rtllib_tim_parameters tim; + struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; u64 last_dtim_sta_time; - u8 wmm_info; - struct rtllib_wmm_ac_param wmm_param[4]; + u8 wmm_info; + struct rtllib_wmm_ac_param wmm_param[4]; u8 Turbo_Enable; u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; @@ -1743,13 +1756,13 @@ enum rtllib_state { }; #else enum rtllib_state { - RTLLIB_UNINITIALIZED = 0, - RTLLIB_INITIALIZED, - RTLLIB_ASSOCIATING, - RTLLIB_ASSOCIATED, - RTLLIB_AUTHENTICATING, - RTLLIB_AUTHENTICATED, - RTLLIB_SHUTDOWN + RTLLIB_UNINITIALIZED = 0, + RTLLIB_INITIALIZED, + RTLLIB_ASSOCIATING, + RTLLIB_ASSOCIATED, + RTLLIB_AUTHENTICATING, + RTLLIB_AUTHENTICATED, + RTLLIB_SHUTDOWN }; #endif @@ -1763,14 +1776,16 @@ enum rtllib_state { #define RTLLIB_24GHZ_MIN_CHANNEL 1 #define RTLLIB_24GHZ_MAX_CHANNEL 14 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ - RTLLIB_24GHZ_MIN_CHANNEL + 1) + RTLLIB_24GHZ_MIN_CHANNEL + 1) #define RTLLIB_52GHZ_MIN_CHANNEL 34 #define RTLLIB_52GHZ_MAX_CHANNEL 165 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ - RTLLIB_52GHZ_MIN_CHANNEL + 1) + RTLLIB_52GHZ_MIN_CHANNEL + 1) #ifndef eqMacAddr -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) +#define eqMacAddr(a, b) \ + (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \ + (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) #endif struct tx_pending { int frag; @@ -1791,7 +1806,7 @@ struct bandwidth_autoswitch { struct rx_reorder_entry { struct list_head List; u16 SeqNum; - struct rtllib_rxb* prxb; + struct rtllib_rxb *prxb; }; enum fsync_state { Default_Fsync, @@ -1936,7 +1951,7 @@ enum country_code_type { }; enum scan_op_backup_opt { - SCAN_OPT_BACKUP=0, + SCAN_OPT_BACKUP = 0, SCAN_OPT_RESTORE, SCAN_OPT_MAX }; @@ -1949,10 +1964,10 @@ enum fw_cmd_io_type { FW_CMD_HIGH_PWR_ENABLE = 4, FW_CMD_HIGH_PWR_DISABLE = 5, FW_CMD_RA_RESET = 6, - FW_CMD_RA_ACTIVE= 7, - FW_CMD_RA_REFRESH_N= 8, - FW_CMD_RA_REFRESH_BG= 9, - FW_CMD_RA_INIT= 10, + FW_CMD_RA_ACTIVE = 7, + FW_CMD_RA_REFRESH_N = 8, + FW_CMD_RA_REFRESH_BG = 9, + FW_CMD_RA_INIT = 10, FW_CMD_IQK_ENABLE = 11, FW_CMD_TXPWR_TRACK_ENABLE = 12, FW_CMD_TXPWR_TRACK_DISABLE = 13, @@ -2046,17 +2061,17 @@ enum ratr_table_mode_8192s { #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { - u8 bUsed; - u8 Bssid[6]; - u8 PMKID[16]; - u8 SsidBuf[33]; - u8* ssid_octet; - u16 ssid_length; + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8 *ssid_octet; + u16 ssid_length; }; struct rt_intel_promisc_mode { - bool bPromiscuousOn; - bool bFilterSourceStationFrame; + bool bPromiscuousOn; + bool bFilterSourceStationFrame; }; @@ -2070,14 +2085,14 @@ struct rt_intel_promisc_mode { enum { NO_USE = 0, USED = 1, - HW_SEC = 2, + HW_SEC = 2, SW_SEC = 3, }; enum { LPS_IS_WAKE = 0, LPS_IS_SLEEP = 1, - LPS_WAIT_NULL_DATA_SEND =2, + LPS_WAIT_NULL_DATA_SEND = 2, }; struct rtllib_device { @@ -2113,7 +2128,7 @@ struct rtllib_device { u8 hwsec_active; bool is_silent_reset; - bool force_mic_error; + bool force_mic_error; bool is_roaming; bool ieee_up; bool cannot_notify; @@ -2135,10 +2150,10 @@ struct rtllib_device { u8 Regdot11TxHTOperationalRateSet[16]; u8 dot11HTOperationalRateSet[16]; u8 RegHTSuppRateSet[16]; - u8 HTCurrentOperaRate; - u8 HTHighestOperaRate; - u8 MinSpaceCfg; - u8 MaxMssDensity; + u8 HTCurrentOperaRate; + u8 HTHighestOperaRate; + u8 MinSpaceCfg; + u8 MaxMssDensity; u8 bTxDisableRateFallBack; u8 bTxUseDriverAssingedRate; u8 bTxEnableFwCalcDur; @@ -2193,15 +2208,15 @@ struct rtllib_device { int host_encrypt; int host_encrypt_msdu; int host_decrypt; - /* host performs multicast decryption */ - int host_mc_decrypt; + /* host performs multicast decryption */ + int host_mc_decrypt; - /* host should strip IV and ICV from protected frames */ - /* meaningful only when hardware decryption is being used */ - int host_strip_iv_icv; + /* host should strip IV and ICV from protected frames */ + /* meaningful only when hardware decryption is being used */ + int host_strip_iv_icv; - int host_open_frag; - int host_build_iv; + int host_open_frag; + int host_build_iv; int ieee802_1x; /* is IEEE 802.1X used */ /* WPA data */ @@ -2224,7 +2239,7 @@ struct rtllib_device { int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; struct timer_list crypt_deinit_timer; - int crypt_quiesced; + int crypt_quiesced; int bcrx_sta_key; /* use individual keys to override default keys even * with RX of broad/multicast frames */ @@ -2238,10 +2253,10 @@ struct rtllib_device { #define DEFAULT_RTS_THRESHOLD 2346U #define MIN_RTS_THRESHOLD 1 #define MAX_RTS_THRESHOLD 2346U - u16 rts; /* RTS threshold */ + u16 rts; /* RTS threshold */ - /* Association info */ - u8 bssid[ETH_ALEN]; + /* Association info */ + u8 bssid[ETH_ALEN]; /* This stores infos for the current network. * Either the network we are associated in INFRASTRUCTURE @@ -2260,20 +2275,20 @@ struct rtllib_device { int mode; /* A, B, G */ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ - int abg_true; /* ABG flag */ + int abg_true; /* ABG flag */ /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ short sync_scan_hurryup; u16 scan_watch_dog; - int perfect_rssi; - int worst_rssi; + int perfect_rssi; + int worst_rssi; - u16 prev_seq_ctl; /* used to drop duplicate frames */ + u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ - void* pDot11dInfo; + void *pDot11dInfo; bool bGlobalDomain; u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; @@ -2417,11 +2432,11 @@ struct rtllib_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device * dev, int pri); + int (*is_queue_full)(struct net_device *dev, int pri); - int (*handle_management) (struct net_device * dev, - struct rtllib_network * network, u16 type); - int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + int (*handle_management)(struct net_device *dev, + struct rtllib_network *network, u16 type); + int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (mamagement) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -2440,7 +2455,7 @@ struct rtllib_device { * This function can't sleep. */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev,int rate); + struct net_device *dev, int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating @@ -2455,7 +2470,7 @@ struct rtllib_device { * This function can sleep. the driver should ensure * the radio has been swithced before return. */ - void (*set_chan)(struct net_device *dev,short ch); + void (*set_chan)(struct net_device *dev, short ch); /* These are not used if the ieee stack takes care of * scanning (IEEE_SOFTMAC_SCAN feature set). @@ -2492,41 +2507,55 @@ struct rtllib_device { * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ - void (*start_send_beacons) (struct net_device *dev); - void (*stop_send_beacons) (struct net_device *dev); + void (*start_send_beacons)(struct net_device *dev); + void (*stop_send_beacons)(struct net_device *dev); /* power save mode related */ - void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u64 time); - short (*ps_is_queue_empty) (struct net_device *dev); - int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); - int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); + void (*sta_wake_up)(struct net_device *dev); + void (*enter_sleep_state)(struct net_device *dev, u64 time); + short (*ps_is_queue_empty)(struct net_device *dev); + int (*handle_beacon)(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network); + int (*handle_assoc_response)(struct net_device *dev, + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network); /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); short (*get_nic_desc_num)(struct net_device *dev, int queue_index); - void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); - bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); - void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); - bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); + void (*SetBWModeHandler)(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); + void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); + bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); - bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO); - void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level); - void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start); - void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); + bool (*SetFwCmdHandler)(struct net_device *dev, + enum fw_cmd_io_type FwCmdIO); + void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast, + u8 macId, u8 MimoPs, u8 WirelessMode, + u8 bCurTxBW40MHz, u8 rssi_level); + void (*UpdateBeaconInterruptHandler)(struct net_device *dev, + bool start); + void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR, + u32 RemoveMSR); u16 (*rtl_11n_user_show_rates)(struct net_device *dev); - void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); - void (*LedControlHandler)(struct net_device * dev, enum led_ctl_mode LedAction); - void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); - void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); + void (*ScanOperationBackupHandler)(struct net_device *dev, + u8 Operation); + void (*LedControlHandler)(struct net_device *dev, + enum led_ctl_mode LedAction); + void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); + void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); - void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg); + void (*AllowAllDestAddrHandler)(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg); - void (*rtllib_ips_leave_wq) (struct net_device *dev); - void (*rtllib_ips_leave)(struct net_device *dev); + void (*rtllib_ips_leave_wq) (struct net_device *dev); + void (*rtllib_ips_leave)(struct net_device *dev); void (*LeisurePSLeave)(struct net_device *dev); void (*rtllib_rfkill_poll)(struct net_device *dev); @@ -2535,9 +2564,9 @@ struct rtllib_device { u8 priv[0]; }; -#define IEEE_A (1<<0) -#define IEEE_B (1<<1) -#define IEEE_G (1<<2) +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) #define IEEE_N_24G (1<<4) #define IEEE_N_5G (1<<5) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) @@ -2650,45 +2679,45 @@ extern inline int rtllib_get_hdrlen(u16 fc) static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr) { - switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { - case RTLLIB_1ADDR_LEN: - return ((struct rtllib_hdr_1addr *)hdr)->payload; - case RTLLIB_2ADDR_LEN: - return ((struct rtllib_hdr_2addr *)hdr)->payload; - case RTLLIB_3ADDR_LEN: - return ((struct rtllib_hdr_3addr *)hdr)->payload; - case RTLLIB_4ADDR_LEN: - return ((struct rtllib_hdr_4addr *)hdr)->payload; - } - return NULL; + switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { + case RTLLIB_1ADDR_LEN: + return ((struct rtllib_hdr_1addr *)hdr)->payload; + case RTLLIB_2ADDR_LEN: + return ((struct rtllib_hdr_2addr *)hdr)->payload; + case RTLLIB_3ADDR_LEN: + return ((struct rtllib_hdr_3addr *)hdr)->payload; + case RTLLIB_4ADDR_LEN: + return ((struct rtllib_hdr_4addr *)hdr)->payload; + } + return NULL; } static inline int rtllib_is_ofdm_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_OFDM_RATE_6MB: - case RTLLIB_OFDM_RATE_9MB: - case RTLLIB_OFDM_RATE_12MB: - case RTLLIB_OFDM_RATE_18MB: - case RTLLIB_OFDM_RATE_24MB: - case RTLLIB_OFDM_RATE_36MB: - case RTLLIB_OFDM_RATE_48MB: - case RTLLIB_OFDM_RATE_54MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_OFDM_RATE_6MB: + case RTLLIB_OFDM_RATE_9MB: + case RTLLIB_OFDM_RATE_12MB: + case RTLLIB_OFDM_RATE_18MB: + case RTLLIB_OFDM_RATE_24MB: + case RTLLIB_OFDM_RATE_36MB: + case RTLLIB_OFDM_RATE_48MB: + case RTLLIB_OFDM_RATE_54MB: + return 1; + } + return 0; } static inline int rtllib_is_cck_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_CCK_RATE_1MB: - case RTLLIB_CCK_RATE_2MB: - case RTLLIB_CCK_RATE_5MB: - case RTLLIB_CCK_RATE_11MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_CCK_RATE_1MB: + case RTLLIB_CCK_RATE_2MB: + case RTLLIB_CCK_RATE_5MB: + case RTLLIB_CCK_RATE_11MB: + return 1; + } + return 0; } @@ -2716,8 +2745,8 @@ extern void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *stats); extern void rtllib_rx_probe_rq(struct rtllib_device *ieee, - struct sk_buff *skb); -extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel); + struct sk_buff *skb); +extern int IsLegalChannel(struct rtllib_device *rtllib, u8 channel); /* rtllib_wx.c */ extern int rtllib_wx_get_scan(struct rtllib_device *ieee, @@ -2731,30 +2760,33 @@ extern int rtllib_wx_get_encode(struct rtllib_device *ieee, union iwreq_data *wrqu, char *key); #if WIRELESS_EXT >= 18 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); #endif extern int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra); + struct iw_request_info *info, + struct iw_param *data, char *extra); extern int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); /* rtllib_softmac.c */ extern short rtllib_is_54g(struct rtllib_network *net); extern short rtllib_is_shortslot(struct rtllib_network net); -extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype); -extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net); +extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype); +extern void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net); void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); -extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee); +extern void rtllib_softmac_xmit(struct rtllib_txb *txb, + struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); extern void notify_wx_assoc_event(struct rtllib_device *ieee); @@ -2772,21 +2804,28 @@ extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); -extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); +extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, + short pwr); extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); extern void rtllib_check_all_nets(struct rtllib_device *ieee); extern void rtllib_start_protocol(struct rtllib_device *ieee); extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); -extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState); +extern void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh); -extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown); -extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag); +extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, + u8 mesh_flag, u8 shutdown); +extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, + u8 mesh_flag); extern void rtllib_reset_queue(struct rtllib_device *ieee); extern void rtllib_wake_queue(struct rtllib_device *ieee); @@ -2796,13 +2835,16 @@ extern void rtllib_stop_all_queues(struct rtllib_device *ieee); extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); extern void rtllib_start_send_beacons(struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); -extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh); +extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, + struct iw_point *p, u8 is_mesh); extern void notify_wx_assoc_event(struct rtllib_device *ieee); extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success); -extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee); -extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst); +extern void softmac_mgmt_xmit(struct sk_buff *skb, + struct rtllib_device *ieee); +extern u16 rtllib_query_seqnum(struct rtllib_device *ieee, + struct sk_buff *skb, u8 *dst); extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); /* rtllib_crypt_ccmp&tkip&wep.c */ @@ -2813,42 +2855,49 @@ extern void rtllib_ccmp_null(void); /* rtllib_softmac_wx.c */ extern int rtllib_wx_get_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *ext); + struct iw_request_info *info, + union iwreq_data *wrqu, char *ext); extern int rtllib_wx_set_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra); + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra); -extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int rtllib_wx_get_essid(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_get_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_scan(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern void rtllib_wx_sync_scan_wq(void *data); extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee, @@ -2875,49 +2924,62 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); #define MAX_RECEIVE_BUFFER_SIZE 9100 -extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); -extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); +extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); +extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); -extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); -extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); -extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); -extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len); +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); +extern void HTUpdateDefaultSetting(struct rtllib_device *ieee); +extern void HTConstructCapabilityElement(struct rtllib_device *ieee, + u8 *posHTCap, u8 *len, + u8 isEncrypt, bool bAssoc); +extern void HTConstructInfoElement(struct rtllib_device *ieee, + u8 *posHTInfo, u8 *len, u8 isEncrypt); +extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee, + u8 *posRT2RTAgg, u8* len); extern void HTOnAssocRsp(struct rtllib_device *ieee); -extern void HTInitializeHTInfo(struct rtllib_device* ieee); +extern void HTInitializeHTInfo(struct rtllib_device *ieee); extern void HTInitializeBssDesc(struct bss_ht *pBssHT); -extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); +extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; -extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame); +extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame); extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo); -extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee); -extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate); -extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate); -extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate); -extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); -extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); +extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee); +extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate); +extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb); +extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending); +extern void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry( struct ba_record *pBA); +extern void ResetBaEntry(struct ba_record *pBA); extern bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs - ); + struct rtllib_device *ieee, + struct ts_common_info **ppTS, + u8 *Addr, + u8 TID, + enum tr_select TxRxSelect, + bool bAddNewTs +); extern void TSInitialize(struct rtllib_device *ieee); -extern void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS); -extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr); -extern void RemoveAllTS(struct rtllib_device* ieee); +extern void TsStartAddBaProcess(struct rtllib_device *ieee, + struct tx_ts_record *pTxTS); +extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr); +extern void RemoveAllTS(struct rtllib_device *ieee); void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern const long rtllib_wlan_frequencies[]; @@ -2932,7 +2994,8 @@ extern inline int rtllib_get_scans(struct rtllib_device *ieee) return ieee->scans; } -static inline const char *escape_essid(const char *essid, u8 essid_len) { +static inline const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; const char *s = essid; char *d = escaped; @@ -2956,7 +3019,9 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) { return escaped; } -#define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE #include #include -#include +#include #include #include "rtllib.h" @@ -56,11 +56,11 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer( struct timer_list* ptimer, void* fun, unsigned long data ) +void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) { - ptimer->function = fun; - ptimer->data = data; - init_timer( ptimer ); + ptimer->function = fun; + ptimer->data = data; + init_timer(ptimer); } static inline int rtllib_networks_allocate(struct rtllib_device *ieee) @@ -98,14 +98,15 @@ static inline void rtllib_networks_initialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->network_free_list); INIT_LIST_HEAD(&ieee->network_list); for (i = 0; i < MAX_NETWORK_COUNT; i++) - list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); + list_add_tail(&ieee->networks[i].list, + &ieee->network_free_list); } struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; struct net_device *dev; - int i,err; + int i, err; RTLLIB_DEBUG_INFO("Initializing...\n"); @@ -159,12 +160,11 @@ struct net_device *alloc_rtllib(int sizeof_priv) ieee->raw_tx = 0; ieee->hwsec_active = 0; - memset(ieee->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtllib_softmac_init(ieee); - ieee->pHTInfo = (struct rt_hi_throughput*)kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); - if (ieee->pHTInfo == NULL) - { + ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); + if (ieee->pHTInfo == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); return NULL; } @@ -192,10 +192,10 @@ struct net_device *alloc_rtllib(int sizeof_priv) return NULL; } - void free_rtllib(struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); int i; if (ieee->pHTInfo != NULL) { kfree(ieee->pHTInfo); @@ -219,11 +219,11 @@ void free_rtllib(struct net_device *dev) free_netdev(dev); } -u32 rtllib_debug_level = 0; +u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc = NULL; +struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 7ccad860182..134e69f4ee5 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -286,7 +286,6 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -#define SN_LESS(a, b) (((a-b)&0x800)!=0) void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; From 87d30617c676a18e3c706150f191f2da16047bd4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 8 Aug 2011 12:06:19 -0500 Subject: [PATCH 0534/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIII With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_module.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 1490 +++++++++++----------- 2 files changed, 714 insertions(+), 778 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index a2c22cf990d..dd0d8db01bd 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -56,7 +56,7 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) +void _setup_timer(struct timer_list *ptimer, void *fun, unsigned long data) { ptimer->function = fun; ptimer->data = data; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 9606bedf16d..205c5750849 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -39,18 +39,18 @@ #include #include #include -#include +#include #include #include "rtllib.h" #include "dot11d.h" static inline void rtllib_monitor_rx(struct rtllib_device *ieee, - struct sk_buff *skb,struct rtllib_rx_stats *rx_status, + struct sk_buff *skb, struct rtllib_rx_stats *rx_status, size_t hdr_length) { skb->dev = ieee->dev; - skb_reset_mac_header(skb); + skb_reset_mac_header(skb); skb_pull(skb, hdr_length); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); @@ -61,7 +61,7 @@ static inline void rtllib_monitor_rx(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ) */ static struct rtllib_frag_entry * rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, - unsigned int frag, u8 tid,u8 *src, u8 *dst) + unsigned int frag, u8 tid, u8 *src, u8 *dst) { struct rtllib_frag_entry *entry; int i; @@ -103,18 +103,18 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } if (frag == 0) { @@ -125,7 +125,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, 2 /* alignment */ + 8 /* WEP */ + ETH_ALEN /* WDS */ + - (RTLLIB_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */); + (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */); if (skb == NULL) return NULL; @@ -146,7 +146,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = rtllib_frag_cache_find(ieee, seq, frag, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -170,21 +170,21 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } - entry = rtllib_frag_cache_find(ieee, seq, -1, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, -1, tid, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -198,8 +198,6 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, return 0; } - - /* rtllib_rx_frame_mgtmt * * Responsible for handling management control frames @@ -217,7 +215,7 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_hdr_3addr * hdr = (struct rtllib_hdr_3addr *)skb->data; rx_stats->len = skb->len; - rtllib_rx_mgt(ieee,skb,rx_stats); + rtllib_rx_mgt(ieee, skb, rx_stats); if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) { dev_kfree_skb_any(skb); return 0; @@ -231,11 +229,13 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +static unsigned char rfc1042_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 +}; /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; +static unsigned char bridge_tunnel_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 +}; /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by rtllib_rx_frame_decrypt */ @@ -280,8 +280,8 @@ static int rtllib_is_eapol_frame(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, - struct rtllib_crypt_data *crypt) +rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; int res, hdrlen; @@ -289,9 +289,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -322,7 +321,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, +rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, int keyidx, struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; @@ -330,9 +329,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -343,7 +341,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); - res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv,ieee); + res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv, ieee); atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" @@ -371,18 +369,18 @@ static int is_duplicate_packet(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos*)header; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)header; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } switch (ieee->iw_mode) { @@ -427,10 +425,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee, if ((*last_seq == seq) && time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { - if (*last_frag == frag){ + if (*last_frag == frag) goto drop; - - } if (*last_frag + 1 != frag) /* out-of-order fragment */ goto drop; @@ -445,28 +441,18 @@ drop: return 1; } -bool -AddReorderEntry( - struct rx_ts_record *pTS, - struct rx_reorder_entry *pReorderEntry - ) + +bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; - while(pList->next != &pTS->RxPendingPktList) - { - if ( SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + while (pList->next != &pTS->RxPendingPktList) { + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) pList = pList->next; - } - else if ( SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) return false; - } else - { break; - } } pReorderEntry->List.next = pList->next; pReorderEntry->List.next->prev = &pReorderEntry->List; @@ -476,24 +462,24 @@ AddReorderEntry( return true; } -void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index) +void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index) { struct net_device_stats *stats = &ieee->stats; - u8 i = 0 , j=0; + u8 i = 0 , j = 0; u16 ethertype; for (j = 0; j < index; j++) { - struct rtllib_rxb* prxb = prxbIndicateArray[j]; - for (i = 0; inr_subframes; i++) { + struct rtllib_rxb *prxb = prxbIndicateArray[j]; + for (i = 0; i < prxb->nr_subframes; i++) { struct sk_buff *sub_skb = prxb->subframes[i]; /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation + * and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); @@ -506,7 +492,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); } - /* Indicat the packets to upper layer */ + /* Indicat the packets to upper layer */ if (sub_skb) { stats->rx_packets++; stats->rx_bytes += sub_skb->len; @@ -526,24 +512,21 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx } } -void -rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) +void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { struct rx_reorder_entry *pRxReorderEntry; - struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; - u8 RfdCnt = 0; - + struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; + u8 RfdCnt = 0; del_timer_sync(&pTS->RxPktPendingTimer); - while(!list_empty(&pTS->RxPendingPktList)) - { - if (RfdCnt >= REORDER_WIN_SIZE){ - printk("-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); + while (!list_empty(&pTS->RxPendingPktList)) { + if (RfdCnt >= REORDER_WIN_SIZE) { + printk(KERN_INFO "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); break; } - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); RfdArray[RfdCnt] = pRxReorderEntry->prxb; @@ -556,41 +539,38 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS pTS->RxIndicateSeq = 0xffff; } - -void RxReorderIndicatePacket( struct rtllib_device *ieee, - struct rtllib_rxb* prxb, - struct rx_ts_record *pTS, - u16 SeqNum) +void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; - struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; - u8 WinSize = pHTInfo->RxReorderWinSize; - u16 WinEnd = 0; - u8 index = 0; - bool bMatchWinStart = false, bPktInBuf = false; + struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; + u8 WinSize = pHTInfo->RxReorderWinSize; + u16 WinEnd = 0; + u8 index = 0; + bool bMatchWinStart = false, bPktInBuf = false; unsigned long flags; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq" + " is %d, WinSize is %d\n", __func__, SeqNum, + pTS->RxIndicateSeq, WinSize); spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; + WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096; /* Rx Reorder initialize condition.*/ - if (pTS->RxIndicateSeq == 0xffff) { + if (pTS->RxIndicateSeq == 0xffff) pTS->RxIndicateSeq = SeqNum; - } /* Drop out the packet which SeqNum is smaller than WinStart */ if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); pHTInfo->RxReorderDropCounter++; { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -607,33 +587,38 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; bMatchWinStart = true; } else if (SN_LESS(WinEnd, SeqNum)) { - if (SeqNum >= (WinSize - 1)) { - pTS->RxIndicateSeq = SeqNum + 1 -WinSize; - } else { - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; - } - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + if (SeqNum >= (WinSize - 1)) + pTS->RxIndicateSeq = SeqNum + 1 - WinSize; + else + pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d," + " NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); } /* * Indication process. - * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets - * with the SeqNum smaller than latest WinStart and struct buffer other packets. + * After Packet dropping and Sliding Window shifting as above, we can + * now just indicate the packets with the SeqNum smaller than latest + * WinStart and struct buffer other packets. */ /* For Rx Reorder condition: * 1. All packets with SeqNum smaller than WinStart => Indicate - * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. + * 2. All packets with SeqNum larger than or equal to + * WinStart => Buffer it. */ if (bMatchWinStart) { /* Current packet is going to be indicated.*/ - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! " + "IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); prxbIndicateArray[0] = prxb; index = 1; } else { /* Current packet is going to be inserted into pending list.*/ if (!list_empty(&ieee->RxReorder_Unused_List)) { - pReorderEntry = (struct rx_reorder_entry *)list_entry(ieee->RxReorder_Unused_List.next,struct rx_reorder_entry,List); + pReorderEntry = (struct rx_reorder_entry *) + list_entry(ieee->RxReorder_Unused_List.next, + struct rx_reorder_entry, List); list_del_init(&pReorderEntry->List); /* Make a reorder entry and insert into a the packet list.*/ @@ -641,34 +626,40 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pReorderEntry->prxb = prxb; if (!AddReorderEntry(pTS, pReorderEntry)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __func__, pTS->RxIndicateSeq, SeqNum); - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); - { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, + "%s(): Duplicate packet is " + "dropped!! IndicateSeq: %d, " + "NewSeq: %d\n", + __func__, pTS->RxIndicateSeq, + SeqNum); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } } else { RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + "Pkt insert into struct buffer!! " + "IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } - } - else { + } else { /* - * Packets are dropped if there is not enough reorder entries. - * This part shall be modified!! We can just indicate all the - * packets in struct buffer and get reorder entries. + * Packets are dropped if there are not enough reorder + * entries. This part should be modified!! We can just + * indicate all the packets in struct buffer and get + * reorder entries. */ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " There is no reorder entry!! Packet is " + "dropped!!\n"); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -676,16 +667,17 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, } /* Check if there is any packet need indicate.*/ - while(!list_empty(&pTS->RxPendingPktList)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); + while (!list_empty(&pTS->RxPendingPktList)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__); - pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - { + pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicate" + "Packet(): Buffer overflow!!\n"); bPktInBuf = true; break; } @@ -696,74 +688,76 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; prxbIndicateArray[index] = pReorderEntry->prxb; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pReorderEntry->SeqNum); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum" + " %d!\n", __func__, pReorderEntry->SeqNum); index++; - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); } else { bPktInBuf = true; break; } } - /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ - if (index>0) { - if (timer_pending(&pTS->RxPktPendingTimer)){ + /* Handling pending timer. Set this timer to prevent from long time + * Rx buffering.*/ + if (index > 0) { + if (timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); - } pTS->RxTimeoutIndicateSeq = 0xffff; - if (index>REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, prxbIndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); + if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n", + __func__); pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; - mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime)); + mod_timer(&pTS->RxPktPendingTimer, jiffies + + MSECS(pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb,u8* src,u8* dst) +u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { - struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr* )skb->data; + struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 LLCOffset= sizeof(struct rtllib_hdr_3addr); + u16 LLCOffset = sizeof(struct rtllib_hdr_3addr); u16 ChkLength; bool bIsAggregateFrame = false; u16 nSubframe_Length; u8 nPadding_Length = 0; - u16 SeqNum=0; + u16 SeqNum = 0; struct sk_buff *sub_skb; - u8 *data_ptr; + u8 *data_ptr; /* just for debug purpose */ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); - if ((RTLLIB_QOS_HAS_SEQ(fc))&&\ - (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { + if ((RTLLIB_QOS_HAS_SEQ(fc)) && + (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) bIsAggregateFrame = true; - } - if (RTLLIB_QOS_HAS_SEQ(fc)) { + if (RTLLIB_QOS_HAS_SEQ(fc)) LLCOffset += 2; - } - if (rx_stats->bContainHTC) { + if (rx_stats->bContainHTC) LLCOffset += sHTCLng; - } - ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ + ChkLength = LLCOffset; - if ( skb->len <= ChkLength ) { + if (skb->len <= ChkLength) return 0; - } skb_pull(skb, LLCOffset); ieee->bIsAggregateFrame = bIsAggregateFrame; @@ -787,25 +781,31 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, rxb->subframes[0] = sub_skb; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); rxb->subframes[0]->dev = ieee->dev; return 1; } else { rxb->nr_subframes = 0; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); - while(skb->len > ETHERNET_HEADER_SIZE) { + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); + while (skb->len > ETHERNET_HEADER_SIZE) { /* Offset 12 denote 2 mac address */ - nSubframe_Length = *((u16*)(skb->data + 12)); - nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8); + nSubframe_Length = *((u16 *)(skb->data + 12)); + nSubframe_Length = (nSubframe_Length >> 8) + + (nSubframe_Length << 8); - if (skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { - printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ - __func__,rxb->nr_subframes); - printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length); - printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); - printk("The Packet SeqNum is %d\n",SeqNum); + if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + printk(KERN_INFO "%s: A-MSDU parse error!! " + "pRfd->nTotalSubframe : %d\n",\ + __func__, rxb->nr_subframes); + printk(KERN_INFO "%s: A-MSDU parse error!! " + "Subframe Length: %d\n", __func__, + nSubframe_Length); + printk(KERN_INFO "nRemain_Length is %d and " + "nSubframe_Length is : %d\n", skb->len, + nSubframe_Length); + printk(KERN_INFO "The Packet SeqNum is %d\n", SeqNum); return 0; } @@ -824,27 +824,27 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, sub_skb = dev_alloc_skb(nSubframe_Length + 12); skb_reserve(sub_skb, 12); data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); - memcpy(data_ptr,skb->data,nSubframe_Length); + memcpy(data_ptr, skb->data, nSubframe_Length); sub_skb->dev = ieee->dev; rxb->subframes[rxb->nr_subframes++] = sub_skb; if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { - RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + RTLLIB_DEBUG_RX("ParseSubframe(): Too many " + "Subframes! Packets dropped!\n"); break; } - skb_pull(skb,nSubframe_Length); + skb_pull(skb, nSubframe_Length); if (skb->len != 0) { - nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4); - if (nPadding_Length == 4) { + nPadding_Length = 4 - ((nSubframe_Length + + ETHERNET_HEADER_SIZE) % 4); + if (nPadding_Length == 4) nPadding_Length = 0; - } - if (skb->len < nPadding_Length) { + if (skb->len < nPadding_Length) return 0; - } - skb_pull(skb,nPadding_Length); + skb_pull(skb, nPadding_Length); } } @@ -863,7 +863,7 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(fc); if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: find HTCControl!\n", __func__); + printk(KERN_INFO "%s: find HTCControl!\n", __func__); hdrlen += 4; rx_stats->bContainHTC = 1; } @@ -874,7 +874,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u8 multicast) +int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, + u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -886,19 +887,18 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || + if ((ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { - if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ - if (is_duplicate_packet(ieee, hdr)){ + if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) { + if (is_duplicate_packet(ieee, hdr)) return -1; - } } } else { struct rx_ts_record *pRxTS = NULL; if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2, - (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { + (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) { if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { return -1; @@ -907,41 +907,47 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); } } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip" + " the check!!\n", __func__); return -1; } } return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, u8 *bssid) + +void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, + u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { - case RTLLIB_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); - break; - case RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); - break; - case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); - break; - case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); - break; + case RTLLIB_FCTL_FROMDS: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr3, ETH_ALEN); + memcpy(bssid, hdr->addr2, ETH_ALEN); + break; + case RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr1, ETH_ALEN); + break; + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr4, ETH_ALEN); + memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + break; + case 0: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr3, ETH_ALEN); + break; } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, u8 *bssid, u8 *addr2) + +int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, + u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -951,14 +957,14 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Filter frames from different BSS */ if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) - && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) - && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { + && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) + && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { return -1; } /* Filter packets sent by an STA that will be forwarded by AP */ - if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { + if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn && + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame) { if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { @@ -968,13 +974,12 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Nullfunc frames may have PS-bit set, so they must be passed to * hostap_handle_sta_rx() before being dropped here. */ - if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn){ + if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) { if (stype != RTLLIB_STYPE_DATA && stype != RTLLIB_STYPE_DATA_CFACK && stype != RTLLIB_STYPE_DATA_CFPOLL && - stype != RTLLIB_STYPE_DATA_CFACKPOLL&& - stype != RTLLIB_STYPE_QOS_DATA - ) { + stype != RTLLIB_STYPE_DATA_CFACKPOLL && + stype != RTLLIB_STYPE_QOS_DATA) { if (stype != RTLLIB_STYPE_NULLFUNC) RTLLIB_DEBUG_DROP( "RX: dropped data frame " @@ -992,18 +997,15 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* {broad,multi}cast packets to our BSS go through */ if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) { - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) { + if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) return -1; - } } } return 0; } -int rtllib_rx_get_crypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_crypt_data **crypt, - size_t hdrlen) + +int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -1035,12 +1037,10 @@ int rtllib_rx_get_crypt( return 0; } -int rtllib_rx_decrypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_crypt_data *crypt, - size_t hdrlen) + +int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_crypt_data *crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr; int keyidx = 0; @@ -1052,15 +1052,14 @@ int rtllib_rx_decrypt( sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ((!rx_stats->Decrypted)){ + if ((!rx_stats->Decrypted)) ieee->need_sw_enc = 1; - }else{ + else ieee->need_sw_enc = 0; - } - if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { - printk("%s: decrypt frame error\n", __func__); + keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt); + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) { + printk(KERN_INFO "%s: decrypt frame error\n", __func__); return -1; } @@ -1120,9 +1119,8 @@ int rtllib_rx_decrypt( /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) - { - printk("%s: ==>decrypt msdu error\n", __func__); + rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) { + printk(KERN_INFO "%s: ==>decrypt msdu error\n", __func__); return -1; } @@ -1164,21 +1162,20 @@ int rtllib_rx_decrypt( return -1; } - if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) printk(KERN_WARNING "RX: IEEE802.1X EAPOL frame!\n"); - } return 0; } + void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { - if (unicast){ + if (unicast) { - if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) - { - if ( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { + if ((ieee->state == RTLLIB_LINKED)) { + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { if (ieee->LeisurePSLeave) ieee->LeisurePSLeave(ieee->dev); } @@ -1186,10 +1183,10 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub } ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy( - struct rtllib_device *ieee, + +void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb* rxb, + struct rtllib_rxb *rxb, u8 *dst, u8 *src) { @@ -1197,21 +1194,21 @@ void rtllib_rx_indicate_pkt_legacy( u16 ethertype; int i = 0; - if (rxb == NULL){ - printk("%s: rxb is NULL!!\n", __func__); + if (rxb == NULL) { + printk(KERN_INFO "%s: rxb is NULL!!\n", __func__); return ; } - for (i = 0; inr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) { struct sk_buff *sub_skb = rxb->subframes[i]; if (sub_skb) { /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and * replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); @@ -1229,9 +1226,8 @@ void rtllib_rx_indicate_pkt_legacy( ieee->stats.rx_packets++; ieee->stats.rx_bytes += sub_skb->len; - if (is_multicast_ether_addr(dst)) { + if (is_multicast_ether_addr(dst)) ieee->stats.multicast++; - } /* Indicat the packets to upper layer */ memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); @@ -1246,13 +1242,14 @@ void rtllib_rx_indicate_pkt_legacy( kfree(rxb); rxb = NULL; } + int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; struct rtllib_crypt_data *crypt = NULL; - struct rtllib_rxb* rxb = NULL; + struct rtllib_rxb *rxb = NULL; struct rx_ts_record *pTS = NULL; u16 fc, sc, SeqNum = 0; u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; @@ -1279,8 +1276,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /*Filter pkt has too small length */ hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); goto rx_dropped; } @@ -1290,9 +1287,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, goto rx_dropped; /* Filter CTRL Frame */ - if (type == RTLLIB_FTYPE_CTL) { + if (type == RTLLIB_FTYPE_CTL) goto rx_dropped; - } /* Filter MGNT Frame */ if (type == RTLLIB_FTYPE_MGMT) { @@ -1307,7 +1303,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Filter WAPI DATA Frame */ /* Update statstics for AP roaming */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { ieee->LinkDetectInfo.NumRecvDataInPeriod++; ieee->LinkDetectInfo.NumRxOkInPeriod++; } @@ -1321,9 +1317,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, if (ret < 0) goto rx_dropped; - if (skb->len == hdrlen){ + if (skb->len == hdrlen) goto rx_dropped; - } /* Send pspoll based on moredata */ if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) @@ -1352,32 +1347,29 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, hdr = (struct rtllib_hdr_4addr *) skb->data; if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1) - && (!bToOtherSTA)) - { + && (!bToOtherSTA)) { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(struct ts_common_info **) &pTS,hdr->addr2,TID,RX_DIR,true); - if (TID !=0 && TID !=3){ + GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true); + if (TID != 0 && TID != 3) ieee->bis_any_nonbepkts = true; - } } /* Parse rx data frame (For AMSDU) */ /* skb: hdr + (possible reassembled) full plaintext payload */ payload = skb->data + hdrlen; - rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); - if (rxb == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); + rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC); + if (rxb == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, + "%s(): kmalloc rxb error\n", __func__); goto rx_dropped; } /* to parse amsdu packets */ /* qos data packets & reserved bit is 1 */ - if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { + if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) { /* only to free rxb, and not submit the packets to upper layer */ - for (i =0; i < rxb->nr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) dev_kfree_skb(rxb->subframes[i]); - } kfree(rxb); rxb = NULL; goto rx_dropped; @@ -1386,7 +1378,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Update WAPI PN */ /* Check if leave LPS */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { if (ieee->bIsAggregateFrame) nr_subframes = rxb->nr_subframes; else @@ -1397,11 +1389,10 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } /* Indicate packets to upper layer or Rx Reorder */ - if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA){ + if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA) rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); - }else{ + else RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); - } dev_kfree_skb(skb); @@ -1409,8 +1400,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 1; rx_dropped: - if (rxb != NULL) - { + if (rxb != NULL) { kfree(rxb); rxb = NULL; } @@ -1427,6 +1417,7 @@ int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, { return 0; } + int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { @@ -1434,14 +1425,14 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, u16 fc = le16_to_cpu(hdr->frame_ctl); size_t hdrlen = rtllib_get_hdrlen(fc); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); return 0; } if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: Find HTCControl!\n", __func__); + printk(KERN_INFO "%s: Find HTCControl!\n", __func__); hdrlen += 4; } @@ -1466,12 +1457,12 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, { int ret = 0; - if ((NULL==ieee) || (NULL==skb) || (NULL==rx_stats)){ + if ((NULL == ieee) || (NULL == skb) || (NULL == rx_stats)) { printk(KERN_INFO "%s: Input parameters NULL!\n", __func__); goto rx_dropped; } if (skb->len < 10) { - printk(KERN_INFO "%s: SKB length < 10 \n", __func__); + printk(KERN_INFO "%s: SKB length < 10\n", __func__); goto rx_dropped; } @@ -1509,19 +1500,19 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; * the right values */ static int rtllib_verify_qos_info(struct rtllib_qos_information_element - *info_element, int sub_type) + *info_element, int sub_type) { - if (info_element->qui_subtype != sub_type) - return -1; - if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) - return -1; - if (info_element->qui_type != QOS_OUI_TYPE) - return -1; - if (info_element->version != QOS_VERSION_1) - return -1; + if (info_element->qui_subtype != sub_type) + return -1; + if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) + return -1; + if (info_element->qui_type != QOS_OUI_TYPE) + return -1; + if (info_element->version != QOS_VERSION_1) + return -1; - return 0; + return 0; } @@ -1529,56 +1520,56 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element * Parse a QoS parameter element */ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info - *element_param, struct rtllib_info_element - *info_element) + *element_param, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; - if ((info_element == NULL) || (element_param == NULL)) - return -1; + if ((info_element == NULL) || (element_param == NULL)) + return -1; - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { + memcpy(element_param->info_element.qui, info_element->data, + info_element->len); + element_param->info_element.elementID = info_element->id; + element_param->info_element.length = info_element->len; + } else + ret = -1; + if (ret == 0) + ret = rtllib_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); + return ret; } /* * Parse a QoS information element */ static int rtllib_read_qos_info_element(struct - rtllib_qos_information_element - *element_info, struct rtllib_info_element - *info_element) + rtllib_qos_information_element + *element_info, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_information_element) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_information_element) - 2; - if (element_info == NULL) - return -1; - if (info_element == NULL) - return -1; + if (element_info == NULL) + return -1; + if (info_element == NULL) + return -1; - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; + if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + memcpy(element_info->qui, info_element->data, + info_element->len); + element_info->elementID = info_element->id; + element_info->length = info_element->len; + } else + ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + if (ret == 0) + ret = rtllib_verify_qos_info(element_info, + QOS_OUI_INFO_SUB_TYPE); + return ret; } @@ -1588,16 +1579,16 @@ static int rtllib_read_qos_info_element(struct static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm, struct rtllib_qos_data *qos_data) { - struct rtllib_qos_ac_parameter *ac_params; + struct rtllib_qos_ac_parameter *ac_params; struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); - int rc = 0; - int i; + int rc = 0; + int i; u8 aci; u8 acm; qos_data->wmm_acm = 0; - for (i = 0; i < QOS_QUEUE_NUM; i++) { - ac_params = &(param_elm->ac_params_record[i]); + for (i = 0; i < QOS_QUEUE_NUM; i++) { + ac_params = &(param_elm->ac_params_record[i]); aci = (ac_params->aci_aifsn & 0x60) >> 5; acm = (ac_params->aci_aifsn & 0x10) >> 4; @@ -1605,43 +1596,43 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info if (aci >= QOS_QUEUE_NUM) continue; switch (aci) { - case 1: - /* BIT(0) | BIT(3) */ - if (acm) - qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); - break; - case 2: - /* BIT(4) | BIT(5) */ - if (acm) - qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); - break; - case 3: - /* BIT(6) | BIT(7) */ - if (acm) - qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); - break; - case 0: - default: - /* BIT(1) | BIT(2) */ - if (acm) - qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); - break; + case 1: + /* BIT(0) | BIT(3) */ + if (acm) + qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); + break; + case 2: + /* BIT(4) | BIT(5) */ + if (acm) + qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); + break; + case 3: + /* BIT(6) | BIT(7) */ + if (acm) + qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); + break; + case 0: + default: + /* BIT(1) | BIT(2) */ + if (acm) + qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); + break; } - qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; + qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; + qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci]; - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; + qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; + qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; - qos_param->flag[aci] = - (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); - } - return rc; + qos_param->flag[aci] = + (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; + qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); + } + return rc; } /* @@ -1650,96 +1641,94 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info * which type to read */ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element - *info_element, - struct rtllib_network *network) + *info_element, + struct rtllib_network *network) { - int rc = 0; - struct rtllib_qos_information_element qos_info_element; + int rc = 0; + struct rtllib_qos_information_element qos_info_element; - rc = rtllib_read_qos_info_element(&qos_info_element, info_element); + rc = rtllib_read_qos_info_element(&qos_info_element, info_element); - if (rc == 0) { - network->qos_data.param_count = qos_info_element.ac_info & 0x0F; - network->flags |= NETWORK_HAS_QOS_INFORMATION; - } else { - struct rtllib_qos_parameter_info param_element; + if (rc == 0) { + network->qos_data.param_count = qos_info_element.ac_info & 0x0F; + network->flags |= NETWORK_HAS_QOS_INFORMATION; + } else { + struct rtllib_qos_parameter_info param_element; - rc = rtllib_read_qos_param_element(¶m_element, - info_element); - if (rc == 0) { - rtllib_qos_convert_ac_to_parameters(¶m_element, - &(network->qos_data)); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } - } + rc = rtllib_read_qos_param_element(¶m_element, + info_element); + if (rc == 0) { + rtllib_qos_convert_ac_to_parameters(¶m_element, + &(network->qos_data)); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; + } + } - if (rc == 0) { - RTLLIB_DEBUG_QOS("QoS is supported\n"); - network->qos_data.supported = 1; - } - return rc; + if (rc == 0) { + RTLLIB_DEBUG_QOS("QoS is supported\n"); + network->qos_data.supported = 1; + } + return rc; } #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x static const char *get_info_element_string(u16 id) { - switch (id) { - MFIE_STRING(SSID); - MFIE_STRING(RATES); - MFIE_STRING(FH_SET); - MFIE_STRING(DS_SET); - MFIE_STRING(CF_SET); - MFIE_STRING(TIM); - MFIE_STRING(IBSS_SET); - MFIE_STRING(COUNTRY); - MFIE_STRING(HOP_PARAMS); - MFIE_STRING(HOP_TABLE); - MFIE_STRING(REQUEST); - MFIE_STRING(CHALLENGE); - MFIE_STRING(POWER_CONSTRAINT); - MFIE_STRING(POWER_CAPABILITY); - MFIE_STRING(TPC_REQUEST); - MFIE_STRING(TPC_REPORT); - MFIE_STRING(SUPP_CHANNELS); - MFIE_STRING(CSA); - MFIE_STRING(MEASURE_REQUEST); - MFIE_STRING(MEASURE_REPORT); - MFIE_STRING(QUIET); - MFIE_STRING(IBSS_DFS); - MFIE_STRING(RSN); - MFIE_STRING(RATES_EX); - MFIE_STRING(GENERIC); - MFIE_STRING(QOS_PARAMETER); - default: - return "UNKNOWN"; - } + switch (id) { + MFIE_STRING(SSID); + MFIE_STRING(RATES); + MFIE_STRING(FH_SET); + MFIE_STRING(DS_SET); + MFIE_STRING(CF_SET); + MFIE_STRING(TIM); + MFIE_STRING(IBSS_SET); + MFIE_STRING(COUNTRY); + MFIE_STRING(HOP_PARAMS); + MFIE_STRING(HOP_TABLE); + MFIE_STRING(REQUEST); + MFIE_STRING(CHALLENGE); + MFIE_STRING(POWER_CONSTRAINT); + MFIE_STRING(POWER_CAPABILITY); + MFIE_STRING(TPC_REQUEST); + MFIE_STRING(TPC_REPORT); + MFIE_STRING(SUPP_CHANNELS); + MFIE_STRING(CSA); + MFIE_STRING(MEASURE_REQUEST); + MFIE_STRING(MEASURE_REPORT); + MFIE_STRING(QUIET); + MFIE_STRING(IBSS_DFS); + MFIE_STRING(RSN); + MFIE_STRING(RATES_EX); + MFIE_STRING(GENERIC); + MFIE_STRING(QOS_PARAMETER); + default: + return "UNKNOWN"; + } } static inline void rtllib_extract_country_ie( struct rtllib_device *ieee, struct rtllib_info_element *info_element, struct rtllib_network *network, - u8 * addr2) + u8 *addr2) { if (IS_DOT11D_ENABLE(ieee)) { - if (info_element->len!= 0) { + if (info_element->len != 0) { memcpy(network->CountryIeBuf, info_element->data, info_element->len); network->CountryIeLen = info_element->len; - if (!IS_COUNTRY_IE_VALID(ieee)) - { - if ((rtllib_act_scanning(ieee,false) == true) && (ieee->FirstIe_InScan == 1)) - printk("Received beacon ContryIE, SSID: <%s>\n",network->ssid); + if (!IS_COUNTRY_IE_VALID(ieee)) { + if ((rtllib_act_scanning(ieee, false) == true) && (ieee->FirstIe_InScan == 1)) + printk(KERN_INFO "Received beacon ContryIE, SSID: <%s>\n", network->ssid); Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); } } - if (IS_EQUAL_CIE_SRC(ieee, addr2)) { + if (IS_EQUAL_CIE_SRC(ieee, addr2)) UPDATE_CIE_WATCHDOG(ieee); - } } } @@ -1752,9 +1741,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, { u8 i; short offset; - u16 tmp_htcap_len=0; - u16 tmp_htinfo_len=0; - u16 ht_realtek_agg_len=0; + u16 tmp_htcap_len = 0; + u16 tmp_htinfo_len = 0; + u16 ht_realtek_agg_len = 0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; char rates_str[64]; char *p; @@ -1864,28 +1853,28 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->tim.tim_count = info_element->data[0]; network->tim.tim_period = info_element->data[1]; - network->dtim_period = info_element->data[1]; - if (ieee->state != RTLLIB_LINKED) - break; + network->dtim_period = info_element->data[1]; + if (ieee->state != RTLLIB_LINKED) + break; network->last_dtim_sta_time = jiffies; - network->dtim_data = RTLLIB_DTIM_VALID; + network->dtim_data = RTLLIB_DTIM_VALID; - if (info_element->data[2] & 1) - network->dtim_data |= RTLLIB_DTIM_MBCAST; + if (info_element->data[2] & 1) + network->dtim_data |= RTLLIB_DTIM_MBCAST; - offset = (info_element->data[2] >> 1)*2; + offset = (info_element->data[2] >> 1)*2; - if (ieee->assoc_id < 8*offset || - ieee->assoc_id > 8*(offset + info_element->len -3)) + if (ieee->assoc_id < 8*offset || + ieee->assoc_id > 8*(offset + info_element->len - 3)) + break; - break; - - offset = (ieee->assoc_id / 8) - offset; - if (info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) - network->dtim_data |= RTLLIB_DTIM_UCAST; + offset = (ieee->assoc_id / 8) - offset; + if (info_element->data[3 + offset] & + (1 << (ieee->assoc_id % 8))) + network->dtim_data |= RTLLIB_DTIM_UCAST; network->listen_interval = network->dtim_period; break; @@ -1923,13 +1912,13 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->wpa_ie_len); break; } - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) - network->Turbo_Enable = 1; + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) + network->Turbo_Enable = 1; if (tmp_htcap_len == 0) { if (info_element->len >= 4 && @@ -1938,193 +1927,160 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, info_element->data[2] == 0x4c && info_element->data[3] == 0x033) { - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); } } - if (tmp_htcap_len != 0){ + if (tmp_htcap_len != 0) { network->bssht.bdSupportHT = true; network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - }else{ + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; } } - if (tmp_htinfo_len == 0){ + if (tmp_htinfo_len == 0) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034){ - - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - if (tmp_htinfo_len){ - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); - } - + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034) { + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + if (tmp_htinfo_len) { + network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); } + } + } } - if (ieee->aggregation){ - if (network->bssht.bdSupportHT){ + if (ieee->aggregation) { + if (network->bssht.bdSupportHT) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02){ - - ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN); - memcpy(ht_realtek_agg_buf,info_element->data,info_element->len); - + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02) { + ht_realtek_agg_len = min(info_element->len, (u8)MAX_IE_LEN); + memcpy(ht_realtek_agg_buf, info_element->data, info_element->len); } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { network->realtek_cap_exit = true; network->bssht.bdRT2RTAggregation = true; if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; + network->bssht.bdRT2RTLongSlotTime = true; - if ((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) - { + if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; - } } } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; } } - { - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x05 && - info_element->data[2] == 0xb5) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf7) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x10 && - info_element->data[2] == 0x18)){ - - network->broadcom_cap_exist = true; - - } + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x05 && + info_element->data[2] == 0xb5) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf7) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x10 && + info_element->data[2] == 0x18)) { + network->broadcom_cap_exist = true; } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0c && - info_element->data[2] == 0x43) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0c && + info_element->data[2] == 0x43) network->ralink_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x03 && - info_element->data[2] == 0x7f) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x13 && - info_element->data[2] == 0x74)) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x03 && + info_element->data[2] == 0x7f) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x13 && + info_element->data[2] == 0x74)) network->atheros_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0x43) ) - { - network->marvell_cap_exist = true; - } + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0x43)) + network->marvell_cap_exist = true; if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96) network->cisco_cap_exist = true; - } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf5) network->airgo_cap_exist = true; - } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x01) - { - if (info_element->len == 6) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) { + if (info_element->len == 6) { memcpy(network->CcxRmState, &info_element[4], 2); if (network->CcxRmState[0] != 0) - { network->bCcxRmEnable = true; - } else network->bCcxRmEnable = false; network->MBssidMask = network->CcxRmState[1] & 0x07; - if (network->MBssidMask != 0) - { + if (network->MBssidMask != 0) { network->bMBssidValid = true; network->MBssidMask = 0xff << (network->MBssidMask); memcpy(network->MBssid, network->bssid, ETH_ALEN); network->MBssid[5] &= network->MBssidMask; - } - else - { + } else { network->bMBssidValid = false; } - } - else - { + } else { network->bCcxRmEnable = false; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x03) - { - if (info_element->len == 5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x03) { + if (info_element->len == 5) { network->bWithCcxVerNum = true; network->BssCcxVerNumber = info_element->data[4]; - } - else - { + } else { network->bWithCcxVerNum = false; network->BssCcxVerNumber = 0; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x04) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x04) { RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", info_element->len); network->wzc_ie_len = min(info_element->len+2, @@ -2146,22 +2102,26 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_CAP: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", info_element->len); - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, + info_element->data, + network->bssht.bdHTCapLen); network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + network->bssht.bdHT1R = ((((struct ht_capab_ele *) + network->bssht.bdHTCapBuf))->MCS[1]) == 0; - network->bssht.bdBandWidth = (enum ht_channel_width)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); - } - else{ + network->bssht.bdBandWidth = (enum ht_channel_width) + (((struct ht_capab_ele *) + (network->bssht.bdHTCapBuf))->ChlWidth); + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; - network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20 ; + network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20; } break; @@ -2169,34 +2129,33 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_INFO: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", info_element->len); - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len){ + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len) { network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); + network->bssht.bdHTInfoLen = tmp_htinfo_len > + sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : + tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, + info_element->data, + network->bssht.bdHTInfoLen); } break; case MFIE_TYPE_AIRONET: RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", info_element->len); - if (info_element->len >IE_CISCO_FLAG_POSITION) - { + if (info_element->len > IE_CISCO_FLAG_POSITION) { network->bWithAironetIE = true; - if ( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || - (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) - { + if ((info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_MIC) || + (info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_PK)) network->bCkipSupported = true; - } else - { network->bCkipSupported = false; - } - } - else - { + } else { network->bWithAironetIE = false; network->bCkipSupported = false; } @@ -2209,7 +2168,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_COUNTRY: RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", info_element->len); - rtllib_extract_country_ie(ieee, info_element, network, network->bssid); + rtllib_extract_country_ie(ieee, info_element, network, + network->bssid); break; /* TODO */ default: @@ -2227,70 +2187,43 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } if (!network->atheros_cap_exist && !network->broadcom_cap_exist && - !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation) - { + !network->cisco_cap_exist && !network->ralink_cap_exist && + !network->bssht.bdRT2RTAggregation) network->unknown_cap_exist = true; - } else - { network->unknown_cap_exist = false; - } return 0; } -static inline u8 rtllib_SignalStrengthTranslate( - u8 CurrSS - ) +static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) { u8 RetSS; if (CurrSS >= 71 && CurrSS <= 100) - { RetSS = 90 + ((CurrSS - 70) / 3); - } else if (CurrSS >= 41 && CurrSS <= 70) - { RetSS = 78 + ((CurrSS - 40) / 3); - } else if (CurrSS >= 31 && CurrSS <= 40) - { RetSS = 66 + (CurrSS - 30); - } else if (CurrSS >= 21 && CurrSS <= 30) - { RetSS = 54 + (CurrSS - 20); - } else if (CurrSS >= 5 && CurrSS <= 20) - { RetSS = 42 + (((CurrSS - 5) * 2) / 3); - } else if (CurrSS == 4) - { RetSS = 36; - } else if (CurrSS == 3) - { RetSS = 27; - } else if (CurrSS == 2) - { RetSS = 18; - } else if (CurrSS == 1) - { RetSS = 9; - } else - { RetSS = CurrSS; - } - - return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index ) +long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; @@ -2308,10 +2241,10 @@ static inline int rtllib_network_init( { /* - network->qos_data.active = 0; - network->qos_data.supported = 0; - network->qos_data.param_count = 0; - network->qos_data.old_param_count = 0; + network->qos_data.active = 0; + network->qos_data.supported = 0; + network->qos_data.param_count = 0; + network->qos_data.old_param_count = 0; */ memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data)); @@ -2332,9 +2265,9 @@ static inline int rtllib_network_init( network->flags = 0; network->atim_window = 0; network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? - 0x3 : 0x0; + 0x3 : 0x0; network->berp_info_valid = false; - network->broadcom_cap_exist = false; + network->broadcom_cap_exist = false; network->ralink_cap_exist = false; network->atheros_cap_exist = false; network->cisco_cap_exist = false; @@ -2358,12 +2291,12 @@ static inline int rtllib_network_init( network->rsn_ie_len = 0; network->wzc_ie_len = 0; - if (rtllib_parse_info_param(ieee, + if (rtllib_parse_info_param(ieee, beacon->info_element, (stats->len - sizeof(*beacon)), network, stats)) - return 1; + return 1; network->mode = 0; if (stats->freq == RTLLIB_52GHZ_BAND) @@ -2384,7 +2317,7 @@ static inline int rtllib_network_init( return 1; } - if (network->bssht.bdSupportHT){ + if (network->bssht.bdSupportHT) { if (network->mode == IEEE_A) network->mode = IEEE_N_5G; else if (network->mode & (IEEE_G | IEEE_B)) @@ -2393,7 +2326,7 @@ static inline int rtllib_network_init( if (rtllib_is_empty_essid(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; stats->signal = 30 + (stats->SignalStrength * 70) / 100; - stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) -25; + stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) - 25; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -2407,11 +2340,11 @@ static inline int is_same_network(struct rtllib_network *src, * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ - return - (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && + return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && - (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (!ssidbroad)) && + (!memcmp(src->ssid, dst->ssid, src->ssid_len) || + (!ssidbroad)) && ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && ((src->capability & WLAN_CAPABILITY_ESS) == @@ -2438,14 +2371,12 @@ static inline void update_network(struct rtllib_network *dst, dst->rates_len = src->rates_len; memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); dst->rates_ex_len = src->rates_ex_len; - if (src->ssid_len > 0) - { - if (dst->ssid_len == 0) - { + if (src->ssid_len > 0) { + if (dst->ssid_len == 0) { memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid)); dst->hidden_ssid_len = src->ssid_len; memcpy(dst->hidden_ssid, src->ssid, src->ssid_len); - }else{ + } else { memset(dst->ssid, 0, dst->ssid_len); dst->ssid_len = src->ssid_len; memcpy(dst->ssid, src->ssid, src->ssid_len); @@ -2455,8 +2386,7 @@ static inline void update_network(struct rtllib_network *dst, dst->flags = src->flags; dst->time_stamp[0] = src->time_stamp[0]; dst->time_stamp[1] = src->time_stamp[1]; - if (src->flags & NETWORK_HAS_ERP_VALUE) - { + if (src->flags & NETWORK_HAS_ERP_VALUE) { dst->erp_value = src->erp_value; dst->berp_info_valid = src->berp_info_valid = true; } @@ -2468,12 +2398,14 @@ static inline void update_network(struct rtllib_network *dst, dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); - dst->bssht.bdSupportHT = src->bssht.bdSupportHT; + dst->bssht.bdSupportHT = src->bssht.bdSupportHT; dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; - dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; - memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); - dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen; - memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen); + dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen; + memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf, + src->bssht.bdHTCapLen); + dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen; + memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf, + src->bssht.bdHTInfoLen); dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer; dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime; dst->broadcom_cap_exist = src->broadcom_cap_exist; @@ -2497,7 +2429,8 @@ static inline void update_network(struct rtllib_network *dst, old_param = dst->qos_data.param_count; dst->qos_data.supported = src->qos_data.supported; if (dst->flags & NETWORK_HAS_QOS_PARAMETERS) - memcpy(&dst->qos_data, &src->qos_data, sizeof(struct rtllib_qos_data)); + memcpy(&dst->qos_data, &src->qos_data, + sizeof(struct rtllib_qos_data)); if (dst->qos_data.supported == 1) { if (dst->ssid_len) RTLLIB_DEBUG_QOS @@ -2512,12 +2445,11 @@ static inline void update_network(struct rtllib_network *dst, /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; - if (src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn) { - memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); - } + if (src->wmm_param[0].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn || + src->wmm_param[2].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn) + memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); dst->SignalStrength = src->SignalStrength; dst->RSSI = src->RSSI; @@ -2528,24 +2460,24 @@ static inline void update_network(struct rtllib_network *dst, dst->bWithAironetIE = src->bWithAironetIE; dst->bCkipSupported = src->bCkipSupported; - memcpy(dst->CcxRmState,src->CcxRmState,2); + memcpy(dst->CcxRmState, src->CcxRmState, 2); dst->bCcxRmEnable = src->bCcxRmEnable; dst->MBssidMask = src->MBssidMask; dst->bMBssidValid = src->bMBssidValid; - memcpy(dst->MBssid,src->MBssid,6); + memcpy(dst->MBssid, src->MBssid, 6); dst->bWithCcxVerNum = src->bWithCcxVerNum; dst->BssCcxVerNumber = src->BssCcxVerNumber; - } + static inline int is_beacon(__le16 fc) { return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); } -static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) +static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } @@ -2555,10 +2487,10 @@ static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) return 0; } -int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) +int IsLegalChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } if (rtllib->active_channel_map[channel] > 0) @@ -2567,7 +2499,6 @@ int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) return 0; } - static inline void rtllib_process_probe_response( struct rtllib_device *ieee, struct rtllib_probe_response *beacon, @@ -2578,7 +2509,8 @@ static inline void rtllib_process_probe_response( struct rtllib_info_element *info_element = &beacon->info_element[0]; unsigned long flags; short renew; - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return; @@ -2606,12 +2538,12 @@ static inline void rtllib_process_probe_response( if (rtllib_network_init(ieee, beacon, network, stats)) { RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", - escape_essid(info_element->data, - info_element->len), - MAC_ARG(beacon->header.addr3), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(info_element->data, + info_element->len), + MAC_ARG(beacon->header.addr3), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); goto free_network; } @@ -2619,10 +2551,12 @@ static inline void rtllib_process_probe_response( if (!IsLegalChannel(ieee, network->channel)) goto free_network; - if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP) { + if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP) { if (IsPassiveChannel(ieee, network->channel)) { - printk("GetScanInfo(): For Global Domain, " - "filter probe response at channel(%d).\n", network->channel); + printk(KERN_INFO "GetScanInfo(): For Global Domain, " + "filter probe response at channel(%d).\n", + network->channel); goto free_network; } } @@ -2631,32 +2565,32 @@ static inline void rtllib_process_probe_response( * to see if we can find it in our list. * * NOTE: This search is definitely not optimized. Once its doing - * the "right thing" we'll optimize it for efficiency if - * necessary */ + * the "right thing" we'll optimize it for efficiency if + * necessary */ /* Search for this entry in the list and update it if it is * already there. */ spin_lock_irqsave(&ieee->lock, flags); - { - if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { - update_network(&ieee->current_network, network); - if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) - && ieee->current_network.berp_info_valid){ - if (ieee->current_network.erp_value& ERP_UseProtection) + if (is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0))) { + update_network(&ieee->current_network, network); + if ((ieee->current_network.mode == IEEE_N_24G || + ieee->current_network.mode == IEEE_G) + && ieee->current_network.berp_info_valid) { + if (ieee->current_network.erp_value & ERP_UseProtection) ieee->current_network.buseprotection = true; - else - ieee->current_network.buseprotection = false; + else + ieee->current_network.buseprotection = false; } - if (is_beacon(beacon->header.frame_ctl)) - { - if (ieee->state >= RTLLIB_LINKED) - ieee->LinkDetectInfo.NumRecvBcnInPeriod++; - } + if (is_beacon(beacon->header.frame_ctl)) { + if (ieee->state >= RTLLIB_LINKED) + ieee->LinkDetectInfo.NumRecvBcnInPeriod++; } } list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, network,(target->ssid_len?1:0))) + if (is_same_network(target, network, + (target->ssid_len ? 1 : 0))) break; if ((oldest == NULL) || (target->last_scanned < oldest->last_scanned)) @@ -2684,49 +2618,51 @@ static inline void rtllib_process_probe_response( RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", - escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", - escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(target->ssid, + target->ssid_len), + MAC_ARG(target->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); - /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new - * net and call the new_net handler + /* we have an entry and we are going to update it. But this + * entry may be already expired. In this case we do the same + * as we found a new net and call the new_net handler */ - renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); + renew = !time_after(target->last_scanned + ieee->scan_age, + jiffies); if ((!target->ssid_len) && - (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) - || ((ieee->current_network.ssid_len == network->ssid_len) && - (strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0) && - (ieee->state == RTLLIB_NOLINK))) - ) { + (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) + || ((ieee->current_network.ssid_len == network->ssid_len) && + (strncmp(ieee->current_network.ssid, network->ssid, + network->ssid_len) == 0) && + (ieee->state == RTLLIB_NOLINK)))) renew = 1; - } update_network(target, network); if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) rtllib_softmac_new_net(ieee, network); } spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))&&\ - (ieee->state == RTLLIB_LINKED)) { - if (ieee->handle_beacon != NULL) { - ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); - } + if (is_beacon(beacon->header.frame_ctl) && + is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0)) && + (ieee->state == RTLLIB_LINKED)) { + if (ieee->handle_beacon != NULL) + ieee->handle_beacon(ieee->dev, beacon, + &ieee->current_network); } free_network: kfree(network); @@ -2734,48 +2670,48 @@ free_network: } void rtllib_rx_mgt(struct rtllib_device *ieee, - struct sk_buff *skb, + struct sk_buff *skb, struct rtllib_rx_stats *stats) { - struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && - WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) - ieee->last_rx_ps_time = jiffies; + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && + WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) + ieee->last_rx_ps_time = jiffies; - case RTLLIB_STYPE_BEACON: - RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Beacon\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && - ieee->state == RTLLIB_LINKED)) - tasklet_schedule(&ieee->ps_task); + case RTLLIB_STYPE_BEACON: + RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Beacon\n"); + rtllib_process_probe_response( + ieee, (struct rtllib_probe_response *)header, + stats); - break; + if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && + ieee->iw_mode == IW_MODE_INFRA && + ieee->state == RTLLIB_LINKED)) + tasklet_schedule(&ieee->ps_task); - case RTLLIB_STYPE_PROBE_RESP: - RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe response\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); - break; - case RTLLIB_STYPE_PROBE_REQ: - RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe request\n"); - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == RTLLIB_LINKED)){ - rtllib_rx_probe_rq(ieee, skb); - } - break; - } + break; + case RTLLIB_STYPE_PROBE_RESP: + RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe response\n"); + rtllib_process_probe_response(ieee, + (struct rtllib_probe_response *)header, stats); + break; + case RTLLIB_STYPE_PROBE_REQ: + RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe request\n"); + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == RTLLIB_LINKED)) + rtllib_rx_probe_rq(ieee, skb); + break; + } } From 3927ee360059eb692507c413868a83471620e466 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 13:19:58 -0500 Subject: [PATCH 0535/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIV With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtllib_softmac.c will need refactoring. In addition, some of the variables may need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 1978 ++++++++++----------- 1 file changed, 961 insertions(+), 1017 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 29277d18f02..fa0e2afd1ed 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -20,27 +20,26 @@ #include #include #include -#include +#include #include "dot11d.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long ); u8 rsn_authen_cipher_suite[16][4] = { - {0x00,0x0F,0xAC,0x00}, - {0x00,0x0F,0xAC,0x01}, - {0x00,0x0F,0xAC,0x02}, - {0x00,0x0F,0xAC,0x03}, - {0x00,0x0F,0xAC,0x04}, - {0x00,0x0F,0xAC,0x05}, + {0x00, 0x0F, 0xAC, 0x00}, + {0x00, 0x0F, 0xAC, 0x01}, + {0x00, 0x0F, 0xAC, 0x02}, + {0x00, 0x0F, 0xAC, 0x03}, + {0x00, 0x0F, 0xAC, 0x04}, + {0x00, 0x0F, 0xAC, 0x05}, }; short rtllib_is_54g(struct rtllib_network *net) { - return ((net->rates_ex_len > 0) || (net->rates_len > 4)); + return (net->rates_ex_len > 0) || (net->rates_len > 4); } short rtllib_is_shortslot(struct rtllib_network net) { - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME); + return net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME; } /* returns the total length needed for pleacing the RATE MFIE @@ -69,7 +68,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { *tag++ = MFIE_TYPE_RATES; *tag++ = 4; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; @@ -78,7 +77,8 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; } - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW + * might support */ *tag_p = tag; } @@ -86,8 +86,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ - + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; @@ -98,14 +97,14 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB; - } - - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW might + * support */ *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; *tag++ = MFIE_TYPE_GENERIC; @@ -120,17 +119,18 @@ void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { *tag_p = tag; } -void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = 7; - *tag++ = 0x00; - *tag++ = 0xe0; - *tag++ = 0x4c; - *tag++ = 0x01; - *tag++ = 0x02; - *tag++ = 0x11; + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = 7; + *tag++ = 0x00; + *tag++ = 0xe0; + *tag++ = 0x4c; + *tag++ = 0x01; + *tag++ = 0x02; + *tag++ = 0x11; *tag++ = 0x00; *tag_p = tag; @@ -140,7 +140,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; /* * if the queue is full but we have newer frames then @@ -183,29 +183,21 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) u8 BasicRate; - for ( i = 0; i < ieee->current_network.rates_len; i++) - { + for (i = 0; i < ieee->current_network.rates_len; i++) { BasicRate = ieee->current_network.rates[i]&0x7F; - if (!rtllib_is_cck_rate(BasicRate)) - { - if (QueryRate == 0) - { + if (!rtllib_is_cck_rate(BasicRate)) { + if (QueryRate == 0) { QueryRate = BasicRate; - } - else - { + } else { if (BasicRate < QueryRate) - { QueryRate = BasicRate; - } } } } - if (QueryRate == 0) - { + if (QueryRate == 0) { QueryRate = 12; - printk("No BasicRate found!!\n"); + printk(KERN_INFO "No BasicRate found!!\n"); } return QueryRate; } @@ -220,10 +212,10 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) else rate = ieee->basic_rate & 0x7f; - if (rate == 0){ - if (ieee->mode == IEEE_A|| - ieee->mode== IEEE_N_5G|| - (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + if (rate == 0) { + if (ieee->mode == IEEE_A || + ieee->mode == IEEE_N_5G || + (ieee->mode == IEEE_N_24G && !pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -232,21 +224,18 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) return rate; } - -void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); - inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct rtllib_hdr_3addr *header= + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); if (header->frame_ctl == RTLLIB_STYPE_BEACON) tcb_desc->queue_index = BEACON_QUEUE; @@ -261,9 +250,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) tcb_desc->bTxDisableRateFallBack = 1; tcb_desc->bTxUseDriverAssingedRate = 1; if (single) { - if (ieee->queue_stop){ - enqueue_mgmt(ieee,skb); - }else{ + if (ieee->queue_stop) { + enqueue_mgmt(ieee, skb); + } else { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -272,11 +261,12 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } spin_unlock_irqrestore(&ieee->lock, flags); - }else{ + } else { spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); @@ -288,17 +278,19 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* check wether the managed packet queued greater than 5 */ - if (!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ - (ieee->queue_stop) ) { + if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) || + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || + (ieee->queue_stop)) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. * */ - printk("%s():insert to waitqueue, queue_index:%d!\n",__func__,tcb_desc->queue_index); - skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); + printk(KERN_INFO "%s():insert to waitqueue, queue_index" + ":%d!\n", __func__, tcb_desc->queue_index); + skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], + skb); } else { - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } @@ -310,7 +302,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u16 fc,type,stype; + u16 fc, type, stype; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); fc = header->frame_ctl; @@ -342,7 +334,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, } /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } else { if (type != RTLLIB_FTYPE_CTL) { @@ -353,14 +346,14 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, else ieee->seq_ctrl[0]++; } - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } } inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) { - unsigned int len,rate_len; + unsigned int len, rate_len; u8 *tag; struct sk_buff *skb; struct rtllib_probe_request *req; @@ -377,7 +370,8 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); + req = (struct rtllib_probe_request *) skb_put(skb, + sizeof(struct rtllib_probe_request)); req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ); req->header.duration_id = 0; @@ -385,15 +379,15 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - tag = (u8 *) skb_put(skb,len+2+rate_len); + tag = (u8 *) skb_put(skb, len + 2 + rate_len); *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - rtllib_MFIE_Brate(ieee,&tag); - rtllib_MFIE_Grate(ieee,&tag); + rtllib_MFIE_Brate(ieee, &tag); + rtllib_MFIE_Grate(ieee, &tag); return skb; } @@ -407,14 +401,14 @@ void rtllib_send_beacon(struct rtllib_device *ieee) return; skb = rtllib_get_beacon_(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_beacons++; } - if (ieee->beacon_txing && ieee->ieee_up){ - mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); - } + if (ieee->beacon_txing && ieee->ieee_up) + mod_timer(&ieee->beacon_timer, jiffies + + (MSECS(ieee->current_network.beacon_interval - 5))); } @@ -431,83 +425,86 @@ void rtllib_send_beacon_cb(unsigned long _ieee) /* * Description: - * Enable network monitor mode, all rx packets will be received. + * Enable network monitor mode, all rx packets will be received. */ -void rtllib_EnableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Monitor Mode\n"); + printk(KERN_INFO "========>Enter Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); } /* * Description: - * Disable network network monitor mode, only packets destinated to - * us will be received. + * Disable network network monitor mode, only packets destinated to + * us will be received. */ -void rtllib_DisableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Monitor Mode\n"); + printk(KERN_INFO "========>Exit Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); } /* * Description: - * This enables the specialized promiscuous mode required by Intel. - * In this mode, Intel intends to hear traffics from/to other STAs in the same BSS. - * Therefore we don't have to disable checking BSSID and we only need to allow all dest. - * BUT: if we enable checking BSSID then we can't recv packets from other STA. + * This enables the specialized promiscuous mode required by Intel. + * In this mode, Intel intends to hear traffics from/to other STAs in the + * same BSS. Therefore we don't have to disable checking BSSID and we only need + * to allow all dest. BUT: if we enable checking BSSID then we can't recv + * packets from other STA. */ -void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = false; + bool bFilterOutNonAssociatedBSSID = false; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Enter Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = true; + ieee->bNetPromiscuousMode = true; } /* * Description: - * This disables the specialized promiscuous mode required by Intel. - * See MgntEnableIntelPromiscuousMode for detail. + * This disables the specialized promiscuous mode required by Intel. + * See MgntEnableIntelPromiscuousMode for detail. */ -void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = true; + bool bFilterOutNonAssociatedBSSID = true; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Exit Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = false; + ieee->bNetPromiscuousMode = false; } void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } @@ -529,7 +526,8 @@ void rtllib_softmac_hint11d_wq(void *data) void rtllib_update_active_chan_map(struct rtllib_device *ieee) { - memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); + memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, + MAX_CHANNEL_NUMBER+1); } /* this performs syncro scan blocking the caller until all channels @@ -537,6 +535,7 @@ void rtllib_update_active_chan_map(struct rtllib_device *ieee) */ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { + union iwreq_data wrqu; short ch = 0; rtllib_update_active_chan_map(ieee); @@ -545,14 +544,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) down(&ieee->scan_sem); - while(1) - { - + while (1) { do { ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are @@ -575,14 +572,14 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) if (ieee->state == RTLLIB_LINKED) goto out; - if (ieee->sync_scan_hurryup){ - printk("============>sync_scan_hurryup out\n"); + if (ieee->sync_scan_hurryup) { + printk(KERN_INFO "============>sync_scan_hurryup out\n"); goto out; } ieee->set_chan(ieee->dev, ch); if (ieee->active_channel_map[ch] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -593,7 +590,7 @@ out: ieee->actscanning = false; ieee->sync_scan_hurryup = 0; - if (ieee->state >= RTLLIB_LINKED){ + if (ieee->state >= RTLLIB_LINKED) { if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); } @@ -601,53 +598,52 @@ out: ieee->be_scan_inprogress = false; - { - union iwreq_data wrqu; memset(&wrqu, 0, sizeof(wrqu)); - wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); - } + wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } void rtllib_softmac_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, softmac_scan_wq); u8 last_channel = ieee->current_network.channel; rtllib_update_active_chan_map(ieee); if (!ieee->ieee_up) return; - if (rtllib_act_scanning(ieee,true) == true) + if (rtllib_act_scanning(ieee, true) == true) return; down(&ieee->scan_sem); - if (ieee->eRFPowerState == eRfOff) - { - printk("======>%s():rf state is eRfOff, return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + printk(KERN_INFO "======>%s():rf state is eRfOff, return\n", + __func__); goto out1; } - do{ + do { ieee->current_network.channel = - (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) - { + (ieee->current_network.channel + 1) % + MAX_CHANNEL_NUMBER; + if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) { if (!ieee->active_channel_map[ieee->current_network.channel]) ieee->current_network.channel = 6; goto out; /* no good chans */ } - } while(!ieee->active_channel_map[ieee->current_network.channel]); + } while (!ieee->active_channel_map[ieee->current_network.channel]); - if (ieee->scanning_continue == 0 ) + if (ieee->scanning_continue == 0) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); if (ieee->active_channel_map[ieee->current_network.channel] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); + queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, + MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); up(&ieee->scan_sem); return; @@ -669,24 +665,24 @@ out1: void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 1; rtllib_send_beacon(ieee); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 0; del_timer_sync(&ieee->beacon_timer); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } @@ -725,9 +721,9 @@ void rtllib_softmac_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_stop_scan(ieee); - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -735,9 +731,9 @@ void rtllib_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan_syncro(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { ieee->sync_scan_hurryup = 1; - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -745,13 +741,12 @@ void rtllib_stop_scan_syncro(struct rtllib_device *ieee) bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ - if (sync_scan){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { + if (sync_scan) return ieee->be_scan_inprogress; - }else{ - return (ieee->actscanning ||ieee->be_scan_inprogress); - } - }else{ + else + return ieee->actscanning || ieee->be_scan_inprogress; + } else { return test_bit(STATUS_SCANNING, &ieee->status); } } @@ -759,61 +754,55 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) /* called with ieee->lock held */ void rtllib_start_scan(struct rtllib_device *ieee) { - RT_TRACE(COMP_DBG, "===>%s()\n",__func__); + RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) - ieee->rtllib_ips_leave_wq(ieee->dev); + ieee->rtllib_ips_leave_wq(ieee->dev); - - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { if (ieee->scanning_continue == 0) { ieee->actscanning = true; ieee->scanning_continue = 1; - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, 0); + queue_delayed_work_rsl(ieee->wq, + &ieee->softmac_scan_wq, 0); } } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } /* called with wx_sem held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } ieee->sync_scan_hurryup = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_scan_syncro(ieee, is_mesh); - }else{ + } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, - struct rtllib_device *ieee, int challengelen,u8 * daddr) + struct rtllib_device *ieee, int challengelen, u8 *daddr) { struct sk_buff *skb; struct rtllib_authentication *auth; int len = 0; - len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; + len = sizeof(struct rtllib_authentication) + challengelen + + ieee->tx_headroom + 4; skb = dev_alloc_skb(len); - if (!skb) return NULL; + if (!skb) + return NULL; skb_reserve(skb, ieee->tx_headroom); @@ -821,10 +810,11 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, skb_put(skb, sizeof(struct rtllib_authentication)); auth->header.frame_ctl = RTLLIB_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= RTLLIB_FCTL_WEP; + if (challengelen) + auth->header.frame_ctl |= RTLLIB_FCTL_WEP; auth->header.duration_id = 0x013a; - memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); if (ieee->auth_mode == 0) @@ -839,22 +829,18 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); return skb; - } -void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) +void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) { - u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; + u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) - { + if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { szQoSOUI[0] = 46; szQoSOUI[1] = *wmm_len; - memcpy(wmmie,szQoSOUI,3); + memcpy(wmmie, szQoSOUI, 3); *wmm_len = 3; - } - else - { + } else { szQoSOUI[1] = *wmm_len + 6; szQoSOUI[6] = oui_subtype; memcpy(wmmie, szQoSOUI, 8); @@ -863,15 +849,15 @@ void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) } } -static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; int beacon_size; struct rtllib_probe_response *beacon_buf; struct sk_buff *skb = NULL; int encrypt; - int atim_len,erp_len; - struct rtllib_crypt_data* crypt; + int atim_len, erp_len; + struct rtllib_crypt_data *crypt; char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; @@ -880,82 +866,83 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) int wpa_ie_len = ieee->wpa_ie_len; u8 erpinfo_content = 0; - u8* tmp_ht_cap_buf = NULL; + u8 *tmp_ht_cap_buf = NULL; u8 tmp_ht_cap_len = 0; - u8* tmp_ht_info_buf = NULL; + u8 *tmp_ht_info_buf = NULL; u8 tmp_ht_info_len = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8* tmp_generic_ie_buf = NULL; + u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; if (rate_ex_len > 0) - rate_ex_len+=2; + rate_ex_len += 2; if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - if ((ieee->current_network.mode == IEEE_G) - ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) { + if ((ieee->current_network.mode == IEEE_G) || + (ieee->current_network.mode == IEEE_N_24G && + ieee->pHTInfo->bCurSuppCCK)) { erp_len = 3; erpinfo_content = 0; if (ieee->current_network.buseprotection) erpinfo_content |= ERP_UseProtection; - } - else + } else erp_len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); - if (ieee->pHTInfo->bCurrentHTSupport){ - tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport) { + tmp_ht_cap_buf = (u8 *) &(ieee->pHTInfo->SelfHTCap); tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf = (u8 *) &(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); - HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt, false); - HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); + HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, + &tmp_ht_cap_len, encrypt, false); + HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, + encrypt); - - if (pHTInfo->bRegRT2RTAggregation) - { + if (pHTInfo->bRegRT2RTAggregation) { tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); + tmp_generic_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, + &tmp_generic_ie_len); } } beacon_size = sizeof(struct rtllib_probe_response)+2+ - ssid_len - +3 - +rate_len - +rate_ex_len - +atim_len - +erp_len - +wpa_ie_len - +ieee->tx_headroom; + ssid_len + 3 + rate_len + rate_ex_len + atim_len + erp_len + + wpa_ie_len + ieee->tx_headroom; skb = dev_alloc_skb(beacon_size); if (!skb) return NULL; skb_reserve(skb, ieee->tx_headroom); - beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + beacon_buf = (struct rtllib_probe_response *) skb_put(skb, + (beacon_size - ieee->tx_headroom)); + memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); + memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); beacon_buf->capability = - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_IBSS); beacon_buf->capability |= - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME)); + if (ieee->short_slot && (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_SLOT_TIME)) + cpu_to_le16((beacon_buf->capability |= + WLAN_CAPABILITY_SHORT_SLOT_TIME)); crypt = ieee->crypt[ieee->tx_keyidx]; if (encrypt) @@ -966,7 +953,7 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) beacon_buf->info_element[0].id = MFIE_TYPE_SSID; beacon_buf->info_element[0].len = ssid_len; - tag = (u8*) beacon_buf->info_element[0].data; + tag = (u8 *) beacon_buf->info_element[0].data; memcpy(tag, ssid, ssid_len); @@ -974,58 +961,55 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) *(tag++) = MFIE_TYPE_RATES; *(tag++) = rate_len-2; - memcpy(tag,ieee->current_network.rates,rate_len-2); - tag+=rate_len-2; + memcpy(tag, ieee->current_network.rates, rate_len-2); + tag += rate_len-2; *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - if (atim_len){ - u16 val16; + if (atim_len) { + u16 val16; *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; val16 = cpu_to_le16(ieee->current_network.atim_window); memcpy((u8 *)tag, (u8 *)&val16, 2); - tag+=2; + tag += 2; } - if (erp_len){ + if (erp_len) { *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; *(tag++) = erpinfo_content; } - if (rate_ex_len){ + if (rate_ex_len) { *(tag++) = MFIE_TYPE_RATES_EX; *(tag++) = rate_ex_len-2; - memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); - tag+=rate_ex_len-2; + memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2); + tag += rate_ex_len-2; } - if (wpa_ie_len) - { + if (wpa_ie_len) { if (ieee->iw_mode == IW_MODE_ADHOC) - { memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); - } memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); tag += ieee->wpa_ie_len; } - return skb; } -struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; - u8* tag; + u8 *tag; - struct rtllib_crypt_data* crypt; + struct rtllib_crypt_data *crypt; struct rtllib_assoc_response_frame *assoc; short encrypt; unsigned int rate_len = rtllib_MFIE_rate_len(ieee); - int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; + int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + + ieee->tx_headroom; skb = dev_alloc_skb(len); @@ -1035,10 +1019,10 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) skb_reserve(skb, ieee->tx_headroom); assoc = (struct rtllib_assoc_response_frame *) - skb_put(skb,sizeof(struct rtllib_assoc_response_frame)); + skb_put(skb, sizeof(struct rtllib_assoc_response_frame)); assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr1, dest, ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? @@ -1046,14 +1030,15 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) if (ieee->short_slot) - assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); + assoc->capability |= + cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - encrypt = ( crypt && crypt->ops); + encrypt = (crypt && crypt->ops); if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); @@ -1061,22 +1046,23 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) - ieee->assoc_id=0; + ieee->assoc_id = 0; else ieee->assoc_id++; - tag = (u8*) skb_put(skb, rate_len); + tag = (u8 *) skb_put(skb, rate_len); rtllib_MFIE_Brate(ieee, &tag); rtllib_MFIE_Grate(ieee, &tag); return skb; } -struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest) +struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, + u8 *dest) { struct sk_buff *skb = NULL; struct rtllib_authentication *auth; - int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; + int len = ieee->tx_headroom + sizeof(struct rtllib_authentication) + 1; skb = dev_alloc_skb(len); if (!skb) return NULL; @@ -1101,10 +1087,10 @@ struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest } -struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) +struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; - struct rtllib_hdr_3addr* hdr; + struct rtllib_hdr_3addr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); if (!skb) @@ -1112,7 +1098,8 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); + hdr = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -1120,17 +1107,17 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | - (pwr ? RTLLIB_FCTL_PM:0)); + (pwr ? RTLLIB_FCTL_PM : 0)); return skb; } -struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) +struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_pspoll_hdr* hdr; + struct rtllib_pspoll_hdr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); if (!skb) @@ -1138,19 +1125,21 @@ struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); + hdr = (struct rtllib_pspoll_hdr *)skb_put(skb, + sizeof(struct rtllib_pspoll_hdr)); memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); - hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL |RTLLIB_STYPE_PSPOLL | RTLLIB_FCTL_PM); + hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL | + RTLLIB_FCTL_PM); return skb; } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) +void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1159,7 +1148,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8* dest) +void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1181,110 +1170,98 @@ inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid) { int i = 0; - do - { - if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) - { + do { + if ((ieee->PMKIDList[i].bUsed) && + (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) break; - } else - { i++; - } } while (i < NUM_PMKID_CACHE); if (i == NUM_PMKID_CACHE) - { i = -1; - } - else - { - } - - return (i); - + return i; } - -inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,struct rtllib_device *ieee) +inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, + struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_assoc_request_frame *hdr; u8 *tag, *ies; int i; - u8* ht_cap_buf = NULL; - u8 ht_cap_len=0; - u8* realtek_ie_buf=NULL; - u8 realtek_ie_len=0; - int wpa_ie_len= ieee->wpa_ie_len; + u8 *ht_cap_buf = NULL; + u8 ht_cap_len = 0; + u8 *realtek_ie_buf = NULL; + u8 realtek_ie_len = 0; + int wpa_ie_len = ieee->wpa_ie_len; int wps_ie_len = ieee->wps_ie_len; - unsigned int ckip_ie_len=0; - unsigned int ccxrm_ie_len=0; - unsigned int cxvernum_ie_len=0; - struct rtllib_crypt_data* crypt; + unsigned int ckip_ie_len = 0; + unsigned int ccxrm_ie_len = 0; + unsigned int cxvernum_ie_len = 0; + struct rtllib_crypt_data *crypt; int encrypt; int PMKCacheIdx; - unsigned int rate_len = (beacon->rates_len?(beacon->rates_len+2):0) + (beacon->rates_ex_len?(beacon->rates_ex_len)+2:0); + unsigned int rate_len = (beacon->rates_len ? + (beacon->rates_len + 2) : 0) + + (beacon->rates_ex_len ? (beacon->rates_ex_len) + + 2 : 0); - unsigned int wmm_info_len = beacon->qos_data.supported?9:0; - unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; + unsigned int wmm_info_len = beacon->qos_data.supported ? 9 : 0; + unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0; int len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; - if (crypt != NULL) { - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); - } else { + if (crypt != NULL) + encrypt = ieee->host_encrypt && crypt && crypt->ops && + ((0 == strcmp(crypt->ops->name, "WEP") || + wpa_ie_len)); + else encrypt = 0; - } - if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) - { + if ((ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee) & SEC_ALG_TKIP)) || + (ieee->bForcedBgMode == true)) { ieee->pHTInfo->bEnableHT = 0; ieee->mode = WIRELESS_MODE_G; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); + HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, + encrypt, true); if (ieee->pHTInfo->bCurrentRT2RTAggregation) { realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); - + realtek_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, realtek_ie_buf, + &realtek_ie_len); } } if (beacon->bCkipSupported) - { ckip_ie_len = 30+2; - } if (beacon->bCcxRmEnable) - { ccxrm_ie_len = 6+2; - } - if ( beacon->BssCcxVerNumber >= 2 ) - { + if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5+2; - } PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { wpa_ie_len += 18; - printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); + printk(KERN_INFO "[PMK cache]: WPA2 IE length: %x\n", + wpa_ie_len); } - len = sizeof(struct rtllib_assoc_request_frame)+ 2 + len = sizeof(struct rtllib_assoc_request_frame) + 2 + beacon->ssid_len + rate_len + wpa_ie_len + wps_ie_len + wmm_info_len + turbo_info_len - + ht_cap_len + + ht_cap_len + realtek_ie_len + ckip_ie_len + ccxrm_ie_len @@ -1299,11 +1276,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_assoc_request_frame *) - skb_put(skb, sizeof(struct rtllib_assoc_request_frame)+2); + skb_put(skb, sizeof(struct rtllib_assoc_request_frame) + 2); hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; + hdr->header.duration_id = 37; memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); @@ -1311,13 +1288,14 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) + if (ieee->short_slot && + (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); @@ -1331,94 +1309,89 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru tag = skb_put(skb, rate_len); - if (beacon->rates_len){ + if (beacon->rates_len) { *tag++ = MFIE_TYPE_RATES; *tag++ = beacon->rates_len; - for (i=0;irates_len;i++){ + for (i = 0; i < beacon->rates_len; i++) *tag++ = beacon->rates[i]; - } } - if (beacon->rates_ex_len){ + if (beacon->rates_ex_len) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = beacon->rates_ex_len; - for (i=0;irates_ex_len;i++){ + for (i = 0; i < beacon->rates_ex_len; i++) *tag++ = beacon->rates_ex[i]; - } } - if ( beacon->bCkipSupported ) - { + if (beacon->bCkipSupported) { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; u8 CcxAironetBuf[30]; struct octet_string osCcxAironetIE; - memset(CcxAironetBuf, 0,30); + memset(CcxAironetBuf, 0, 30); osCcxAironetIE.Octet = CcxAironetBuf; osCcxAironetIE.Length = sizeof(CcxAironetBuf); - memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); + memcpy(osCcxAironetIE.Octet, AironetIeOui, + sizeof(AironetIeOui)); - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= + (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC); tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; *tag++ = osCcxAironetIE.Length; - memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); + memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length); tag += osCcxAironetIE.Length; } - if (beacon->bCcxRmEnable) - { + if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; struct octet_string osCcxRmCap; osCcxRmCap.Octet = CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); - tag = skb_put(skb,ccxrm_ie_len); + tag = skb_put(skb, ccxrm_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxRmCap.Length; - memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); + memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length); tag += osCcxRmCap.Length; } - if ( beacon->BssCcxVerNumber >= 2 ) - { - u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; + if (beacon->BssCcxVerNumber >= 2) { + u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; osCcxVerNum.Octet = CcxVerNumBuf; osCcxVerNum.Length = sizeof(CcxVerNumBuf); - tag = skb_put(skb,cxvernum_ie_len); + tag = skb_put(skb, cxvernum_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxVerNum.Length; - memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); + memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length); tag += osCcxVerNum.Length; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len -2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } } - - if (wpa_ie_len){ + if (wpa_ie_len) { tag = skb_put(skb, ieee->wpa_ie_len); memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { tag = skb_put(skb, 18); *tag = 1; *(tag + 1) = 0; - memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16); + memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, + 16); } } if (wmm_info_len) { - tag = skb_put(skb,wmm_info_len); + tag = skb_put(skb, wmm_info_len); rtllib_WMM_Info(ieee, &tag); } @@ -1427,42 +1400,39 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(tag, ieee->wps_ie, wps_ie_len); } - tag = skb_put(skb,turbo_info_len); - if (turbo_info_len) - rtllib_TURBO_Info(ieee, &tag); + tag = skb_put(skb, turbo_info_len); + if (turbo_info_len) + rtllib_TURBO_Info(ieee, &tag); - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len - 2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } - if (ieee->pHTInfo->bCurrentRT2RTAggregation){ + if (ieee->pHTInfo->bCurrentRT2RTAggregation) { tag = skb_put(skb, realtek_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = realtek_ie_len - 2; - memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); + memcpy(tag, realtek_ie_buf, realtek_ie_len - 2); } } - if (ieee->assocreq_ies){ - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; ies = &(hdr->info_element[0].id); ieee->assocreq_ies_len = (skb->data + skb->len) - ies; ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); if (ieee->assocreq_ies) memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocreq_ies\n", __func__); + else { + printk(KERN_INFO "%s()Warning: can't alloc memory for assocreq" + "_ies\n", __func__); ieee->assocreq_ies_len = 0; } - return skb; } @@ -1480,18 +1450,18 @@ void rtllib_associate_abort(struct rtllib_device *ieee) * Here we will check if there are good nets to associate * with, so we retry or just get back to NO_LINK and scanning */ - if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING){ + if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) { RTLLIB_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; - }else{ + } else { RTLLIB_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } ieee->state = RTLLIB_ASSOCIATING_RETRY; - queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, \ - RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); + queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, + RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1501,7 +1471,7 @@ void rtllib_associate_abort_cb(unsigned long dev) rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) +void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1510,15 +1480,15 @@ void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) ieee->softmac_stats.tx_auth_rq++; - skb=rtllib_authentication_req(beacon, ieee, 0,daddr); + skb = rtllib_authentication_req(beacon, ieee, 0, daddr); if (!skb) rtllib_associate_abort(ieee); - else{ + else { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ; RTLLIB_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); - if (!timer_pending(&ieee->associate_timer)){ + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } @@ -1534,19 +1504,21 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = rtllib_authentication_req(beacon, ieee, chlen+2,beacon->bssid); + skb = rtllib_authentication_req(beacon, ieee, chlen + 2, beacon->bssid); if (!skb) rtllib_associate_abort(ieee); - else{ + else { c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); + RTLLIB_DEBUG_MGMT("Sending authentication challenge " + "response\n"); - rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr )); + rtllib_encrypt_fragment(ieee, skb, + sizeof(struct rtllib_hdr_3addr)); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); @@ -1556,7 +1528,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) void rtllib_associate_step2(struct rtllib_device *ieee) { - struct sk_buff* skb; + struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; del_timer_sync(&ieee->associate_timer); @@ -1564,10 +1536,10 @@ void rtllib_associate_step2(struct rtllib_device *ieee) RTLLIB_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=rtllib_association_req(beacon, ieee); + skb = rtllib_association_req(beacon, ieee); if (!skb) rtllib_associate_abort(ieee); - else{ + else { softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); } @@ -1576,48 +1548,54 @@ void rtllib_associate_step2(struct rtllib_device *ieee) #define CANCELLED 2 void rtllib_associate_complete_wq(void *data) { - struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); + struct rtllib_device *ieee = (struct rtllib_device *) + container_of_work_rsl(data, + struct rtllib_device, + associate_complete_wq); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); printk(KERN_INFO "Associated successfully\n"); - if (ieee->is_silent_reset == 0){ - printk("normal associate\n"); - notify_wx_assoc_event(ieee); - } + if (ieee->is_silent_reset == 0) { + printk(KERN_INFO "normal associate\n"); + notify_wx_assoc_event(ieee); + } netif_carrier_on(ieee->dev); ieee->is_roaming = false; if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { ieee->rate = 108; printk(KERN_INFO"Using G rates:%d\n", ieee->rate); - }else{ + } else { ieee->rate = 22; ieee->SetWirelessMode(ieee->dev, IEEE_B); printk(KERN_INFO"Using B rates:%d\n", ieee->rate); } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - printk("Successfully associated, ht enabled\n"); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + printk(KERN_INFO "Successfully associated, ht enabled\n"); HTOnAssocRsp(ieee); } else { - printk("Successfully associated, ht not enabled(%d, %d)\n", - ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); + printk(KERN_INFO "Successfully associated, ht not " + "enabled(%d, %d)\n", + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bEnableHT); memset(ieee->dot11HTOperationalRateSet, 0, 16); } - ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { + ieee->LinkDetectInfo.SlotNum = 2 * (1 + + ieee->current_network.beacon_interval / + 500); + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } pPSC->LpsIdleCount = 0; ieee->link_change(ieee->dev); - if (ieee->is_silent_reset == 1) { - printk("silent reset associate\n"); + if (ieee->is_silent_reset == 1) { + printk(KERN_INFO "silent reset associate\n"); ieee->is_silent_reset = 0; - } + } if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1626,49 +1604,6 @@ void rtllib_associate_complete_wq(void *data) static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { - char *buf; - size_t len; - int i; - union iwreq_data wrqu; - - return; - - - buf = kmalloc(50 + 2 * (ieee->assocreq_ies_len + ieee->assocresp_ies_len), GFP_ATOMIC); - if (!buf) - return; - - len = sprintf(buf, "ASSOCINFO("); - if (ieee->assocreq_ies) { - len += sprintf(buf + len, "ReqIEs="); - for (i = 0; i < ieee->assocreq_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocreq_ies[i]); - } - } - if (ieee->assocresp_ies) { - if (ieee->assocreq_ies) - len += sprintf(buf + len, " "); - len += sprintf(buf + len, "RespIEs="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - len += sprintf(buf + len, ")"); - - if (len > IW_CUSTOM_MAX) { - len = sprintf(buf, "ASSOCRESPIE="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - - if (len <= IW_CUSTOM_MAX) { - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = len; - wireless_send_event(ieee->dev, IWEVCUSTOM, &wrqu, buf); - } - - kfree(buf); } void rtllib_associate_complete(struct rtllib_device *ieee) @@ -1683,7 +1618,9 @@ void rtllib_associate_complete(struct rtllib_device *ieee) void rtllib_associate_procedure_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_procedure_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, + associate_procedure_wq); rtllib_stop_scan_syncro(ieee); if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -1693,11 +1630,12 @@ void rtllib_associate_procedure_wq(void *data) ieee->data_hard_stop(ieee->dev); rtllib_stop_scan(ieee); - RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, ieee->current_network.channel); + RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, + ieee->current_network.channel); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - if (ieee->eRFPowerState == eRfOff) - { - RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff," + " schedule ipsleave wq again,return\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) ieee->rtllib_ips_leave_wq(ieee->dev); up(&ieee->wx_sem); @@ -1710,12 +1648,13 @@ void rtllib_associate_procedure_wq(void *data) up(&ieee->wx_sem); } -inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net) +inline void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net) { - u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; + u8 tmp_ssid[IW_ESSID_MAX_SIZE + 1]; int tmp_ssid_len = 0; - short apset,ssidset,ssidbroad,apmatch,ssidmatch; + short apset, ssidset, ssidbroad, apmatch, ssidmatch; /* we are interested in new new only if we are not associated * and we are not associating / authenticating @@ -1723,103 +1662,124 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_net if (ieee->state != RTLLIB_NOLINK) return; - if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_ESS)) + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & + WLAN_CAPABILITY_ESS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & + WLAN_CAPABILITY_IBSS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal)) { + if ((ieee->iw_mode == IW_MODE_ADHOC) && + (net->channel > ieee->ibss_maxjoin_chal)) return; - } - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not * broadcast it, it can be put manually. */ apset = ieee->wap_set; ssidset = ieee->ssid_set; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); - if (!ssidbroad){ - ssidmatch = (ieee->current_network.ssid_len == net->hidden_ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->hidden_ssid, net->hidden_ssid_len)); - if (net->hidden_ssid_len > 0) - { - strncpy(net->ssid, net->hidden_ssid, net->hidden_ssid_len); - net->ssid_len = net->hidden_ssid_len; - ssidbroad = 1; - } - } - else - ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, + ETH_ALEN) == 0); + if (!ssidbroad) { + ssidmatch = (ieee->current_network.ssid_len == + net->hidden_ssid_len) && + (!strncmp(ieee->current_network.ssid, + net->hidden_ssid, net->hidden_ssid_len)); + if (net->hidden_ssid_len > 0) { + strncpy(net->ssid, net->hidden_ssid, + net->hidden_ssid_len); + net->ssid_len = net->hidden_ssid_len; + ssidbroad = 1; + } + } else + ssidmatch = + (ieee->current_network.ssid_len == net->ssid_len) && + (!strncmp(ieee->current_network.ssid, net->ssid, + net->ssid_len)); - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplyed ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) - /* if the ap is not set, check that the user set the bssid - * and the network does bradcast and that those two bssid matches - */ - || (!apset && ssidset && ssidbroad && ssidmatch) || (ieee->is_roaming && ssidset && ssidbroad && ssidmatch) - ){ - /* if the essid is hidden replace it with the - * essid provided by the user. - */ - if (!ssidbroad){ - strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); - tmp_ssid_len = ieee->current_network.ssid_len; - } - memcpy(&ieee->current_network, net, sizeof(struct rtllib_network)); - if (!ssidbroad){ - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - } - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode, ieee->current_network.flags); + /* if the user set the AP check if match. + * if the network does not broadcast essid we check the + * user supplyed ANY essid + * if the network does broadcast and the user does not set + * essid it is OK + * if the network does broadcast and the user did set essid + * check if essid match + * if the ap is not set, check that the user set the bssid + * and the network does bradcast and that those two bssid match + */ + if ((apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || + (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + (!apset && ssidset && ssidbroad && ssidmatch) || + (ieee->is_roaming && ssidset && ssidbroad && ssidmatch)) { + /* if the essid is hidden replace it with the + * essid provided by the user. + */ + if (!ssidbroad) { + strncpy(tmp_ssid, ieee->current_network.ssid, + IW_ESSID_MAX_SIZE); + tmp_ssid_len = ieee->current_network.ssid_len; + } + memcpy(&ieee->current_network, net, + sizeof(struct rtllib_network)); + if (!ssidbroad) { + strncpy(ieee->current_network.ssid, tmp_ssid, + IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; + } + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, " + "myHT:%d, networkHT:%d, mode:%x cur_net.flags" + ":0x%x\n", ieee->current_network.ssid, + ieee->current_network.channel, + ieee->current_network.qos_data.supported, + ieee->pHTInfo->bEnableHT, + ieee->current_network.bssht.bdSupportHT, + ieee->current_network.mode, + ieee->current_network.flags); - if ((rtllib_act_scanning(ieee, false)) && !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - rtllib_stop_scan_syncro(ieee); - } + if ((rtllib_act_scanning(ieee, false)) && + !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) + rtllib_stop_scan_syncro(ieee); - ieee->hwscan_ch_bk = ieee->current_network.channel; - HTResetIOTSetting(ieee->pHTInfo); - ieee->wmm_acm = 0; - if (ieee->iw_mode == IW_MODE_INFRA) { - /* Join the network for the first time */ - ieee->AsocRetryCount = 0; - if ((ieee->current_network.qos_data.supported == 1) && - ieee->current_network.bssht.bdSupportHT) - HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); - else - ieee->pHTInfo->bCurrentHTSupport = false; + ieee->hwscan_ch_bk = ieee->current_network.channel; + HTResetIOTSetting(ieee->pHTInfo); + ieee->wmm_acm = 0; + if (ieee->iw_mode == IW_MODE_INFRA) { + /* Join the network for the first time */ + ieee->AsocRetryCount = 0; + if ((ieee->current_network.qos_data.supported == 1) && + ieee->current_network.bssht.bdSupportHT) + HTResetSelfAndSavePeerSetting(ieee, + &(ieee->current_network)); + else + ieee->pHTInfo->bCurrentHTSupport = + false; - ieee->state = RTLLIB_ASSOCIATING; - if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + ieee->state = RTLLIB_ASSOCIATING; + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + } else { + if (rtllib_is_54g(&ieee->current_network) && + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { + ieee->rate = 108; + ieee->SetWirelessMode(ieee->dev, IEEE_G); + printk(KERN_INFO"Using G rates\n"); } else { - if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - ieee->rate = 108; - ieee->SetWirelessMode(ieee->dev, IEEE_G); - printk(KERN_INFO"Using G rates\n"); - }else{ - ieee->rate = 22; - ieee->SetWirelessMode(ieee->dev, IEEE_B); - printk(KERN_INFO"Using B rates\n"); - } - memset(ieee->dot11HTOperationalRateSet, 0, 16); - ieee->state = RTLLIB_LINKED; + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates\n"); } - + memset(ieee->dot11HTOperationalRateSet, 0, 16); + ieee->state = RTLLIB_LINKED; + } } } - } void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) @@ -1838,51 +1798,49 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) if (ieee->state != RTLLIB_NOLINK) break; - if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - rtllib_softmac_new_net(ieee, target); + if (ieee->scan_age == 0 || time_after(target->last_scanned + + ieee->scan_age, jiffies)) + rtllib_softmac_new_net(ieee, target); } - spin_unlock_irqrestore(&ieee->lock, flags); - } - static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) { struct rtllib_authentication *a; u8 *t; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; - a = (struct rtllib_authentication*) skb->data; - if (skb->len > (sizeof(struct rtllib_authentication) +3)){ + a = (struct rtllib_authentication *) skb->data; + if (skb->len > (sizeof(struct rtllib_authentication) + 3)) { t = skb->data + sizeof(struct rtllib_authentication); - if (*(t++) == MFIE_TYPE_CHALLENGE){ + if (*(t++) == MFIE_TYPE_CHALLENGE) { *chlen = *(t++); - *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); - memcpy(*challenge, t, *chlen); + *challenge = kmalloc(*chlen, GFP_ATOMIC); + memcpy(*challenge, t, *chlen); /*TODO - check here*/ } } - return cpu_to_le16(a->status); - } - -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n", + skb->len); return -1; } - a = (struct rtllib_authentication*) skb->data; + a = (struct rtllib_authentication *) skb->data; - memcpy(dest,a->header.addr2, ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1890,38 +1848,36 @@ int auth_rq_parse(struct sk_buff *skb,u8* dest) return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *src) { u8 *tag; u8 *skbend; - u8 *ssid=NULL; + u8 *ssid = NULL; u8 ssidlen = 0; - struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + bool bssid_match; - if (skb->len < sizeof (struct rtllib_hdr_3addr )) + if (skb->len < sizeof(struct rtllib_hdr_3addr)) return -1; /* corrupted */ - if ((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&& - (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) { - return -1; - } - if (memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) { - } + bssid_match = + (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) && + (memcmp(header->addr3, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0); + if (bssid_match) + return -1; - if (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) { - } - memcpy(src,header->addr2, ETH_ALEN); + memcpy(src, header->addr2, ETH_ALEN); - skbend = (u8*)skb->data + skb->len; + skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct rtllib_hdr_3addr ); + tag = skb->data + sizeof(struct rtllib_hdr_3addr); - while (tag+1 < skbend){ - if (*tag == 0){ - ssid = tag+2; - ssidlen = *(tag+1); + while (tag + 1 < skbend) { + if (*tag == 0) { + ssid = tag + 2; + ssidlen = *(tag + 1); break; } tag++; /* point to the len field */ @@ -1929,53 +1885,56 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 tag++; /* point to the next tag */ } - if (ssidlen == 0) return 1; + if (ssidlen == 0) + return 1; - if (!ssid) return 1; /* ssid not found in tagged param */ - return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); + if (!ssid) + return 1; /* ssid not found in tagged param */ + return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - sizeof(struct rtllib_info_element))) { - RTLLIB_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); + RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len); return -1; } - a = (struct rtllib_assoc_request_frame*) skb->data; + a = (struct rtllib_assoc_request_frame *) skb->data; - memcpy(dest,a->header.addr2,ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); return 0; } -static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, int *aid) +static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, + int *aid) { struct rtllib_assoc_response_frame *response_head; u16 status_code; - if (skb->len < sizeof(struct rtllib_assoc_response_frame)){ + if (skb->len < sizeof(struct rtllib_assoc_response_frame)) { RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - response_head = (struct rtllib_assoc_response_frame*) skb->data; + response_head = (struct rtllib_assoc_response_frame *) skb->data; *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if ((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& + if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || + status_code == WLAN_STATUS_CAPS_UNSUPPORTED) && ((ieee->mode == IEEE_G) && - (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; - }else { - ieee->AsocRetryCount = 0; + (ieee->current_network.mode == IEEE_N_24G) && + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + } else { + ieee->AsocRetryCount = 0; } return le16_to_cpu(response_head->status); @@ -1985,38 +1944,37 @@ void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_probe_rq++; - if (probe_rq_parse(ieee, skb, dest) > 0){ + if (probe_rq_parse(ieee, skb, dest) > 0) { ieee->softmac_stats.tx_probe_rs++; rtllib_resp_to_probe(ieee, dest); } } -static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) rtllib_resp_to_auth(ieee, status, dest); - } - } -static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ + if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); } - void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) { @@ -2024,34 +1982,25 @@ void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) { - struct sk_buff *buf = rtllib_pspoll_func(ieee); if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); - /*if (ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED) + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); - return 0; - */ - - if (ieee->LPSDelayCnt) - { - ieee->LPSDelayCnt --; + if (ieee->LPSDelayCnt) { + ieee->LPSDelayCnt--; return 0; } @@ -2060,21 +2009,20 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) return 0; timeout = ieee->current_network.beacon_interval; ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID; - /* there's no need to nofity AP that I find you buffered with broadcast packet */ + /* there's no need to nofity AP that I find you buffered + * with broadcast packet */ if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps)) return 2; - if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ + if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - } - if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){ + if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - } - if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && - (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) && + (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time){ + if (time) { if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2088,27 +2036,37 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) MaxPeriod = ieee->current_network.dtim_period; else MaxPeriod = pPSC->RegMaxLPSAwakeIntvl; - pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1); + pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= + MaxPeriod) ? MaxPeriod : + (pPSC->LPSAwakeIntvl + 1); } { u8 LPSAwakeIntvl_tmp = 0; u8 period = ieee->current_network.dtim_period; u8 count = ieee->current_network.tim.tim_count; - if (count == 0 ) { + if (count == 0) { if (pPSC->LPSAwakeIntvl > period) - LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period); + LPSAwakeIntvl_tmp = period + + (pPSC->LPSAwakeIntvl - + period) - + ((pPSC->LPSAwakeIntvl-period) % + period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } else { - if (pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count) - LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period); + if (pPSC->LPSAwakeIntvl > + ieee->current_network.tim.tim_count) + LPSAwakeIntvl_tmp = count + + (pPSC->LPSAwakeIntvl - count) - + ((pPSC->LPSAwakeIntvl-count)%period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } *time = ieee->current_network.last_dtim_sta_time - + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); + + MSECS(ieee->current_network.beacon_interval * + LPSAwakeIntvl_tmp); } } @@ -2119,45 +2077,38 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u64 time; short sleep; - - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); if ((ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED)){ - - RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", - __func__,ieee->ps,ieee->iw_mode,ieee->state); + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != RTLLIB_LINKED)) { + RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! " + "ieee->ps is %d, ieee->iw_mode is %d, ieee->state" + " is %d\n", __func__, ieee->ps, ieee->iw_mode, + ieee->state); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) - { goto out; - } - if (sleep == 1){ - if (ieee->sta_sleep == LPS_IS_SLEEP){ + if (sleep == 1) { + if (ieee->sta_sleep == LPS_IS_SLEEP) { ieee->enter_sleep_state(ieee->dev, time); - } - - else if (ieee->sta_sleep == LPS_IS_WAKE){ + } else if (ieee->sta_sleep == LPS_IS_WAKE) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->ps_is_queue_empty(ieee->dev)){ + if (ieee->ps_is_queue_empty(ieee->dev)) { ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; - rtllib_sta_ps_send_null_frame(ieee,1); + rtllib_sta_ps_send_null_frame(ieee, 1); ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2166,10 +2117,10 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->bAwakePktSent = false; - }else if (sleep == 2){ + } else if (sleep == 2) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee,1); + rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -2181,15 +2132,13 @@ out: void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) { - if (ieee->sta_sleep == LPS_IS_WAKE){ - if (nl){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->sta_sleep == LPS_IS_WAKE) { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_pspoll_frame(ieee); } @@ -2200,19 +2149,12 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) if (ieee->sta_sleep == LPS_IS_SLEEP) ieee->sta_wake_up(ieee->dev); - if (nl){ - /* - ieee->ack_tx_to_ieee = 1; - printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__); - rtllib_sta_ps_send_null_frame(ieee, 0); - */ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; ieee->polling = true; rtllib_sta_ps_send_pspoll_frame(ieee); @@ -2226,13 +2168,13 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) { - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); - if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND){ + if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND) { /* Null frame with PS bit set */ - if (success){ + if (success) { ieee->sta_sleep = LPS_IS_SLEEP; ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } @@ -2241,199 +2183,208 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) */ } else {/* 21112005 - tx again null without PS bit if lost */ - if ((ieee->sta_sleep == LPS_IS_WAKE) && !success){ + if ((ieee->sta_sleep == LPS_IS_WAKE) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) rtllib_sta_ps_send_null_frame(ieee, 0); - } else - { rtllib_sta_ps_send_pspoll_frame(ieee); - } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device* ieee, struct sk_buff* skb) +void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u8* act = rtllib_get_payload((struct rtllib_hdr *)header); + u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); u8 category = 0; if (act == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of action frame\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of " + "action frame\n"); return; } category = *act; - act ++; + act++; switch (category) { - case ACT_CAT_BA: - switch (*act) { - case ACT_ADDBAREQ: - rtllib_rx_ADDBAReq(ieee, skb); - break; - case ACT_ADDBARSP: - rtllib_rx_ADDBARsp(ieee, skb); - break; - case ACT_DELBA: - rtllib_rx_DELBA(ieee, skb); - break; - } + case ACT_CAT_BA: + switch (*act) { + case ACT_ADDBAREQ: + rtllib_rx_ADDBAReq(ieee, skb); break; - default: + case ACT_ADDBARSP: + rtllib_rx_ADDBARsp(ieee, skb); break; + case ACT_DELBA: + rtllib_rx_DELBA(ieee, skb); + break; + } + break; + default: + break; } return; } -inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; int aid; - u8* ies; + u8 *ies; struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); + WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && - (ieee->iw_mode == IW_MODE_INFRA)) - { - if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && + (ieee->iw_mode == IW_MODE_INFRA)) { + errcode = assoc_parse(ieee, skb, &aid); + if (0 == errcode) { + struct rtllib_network *network = + kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return 1; - memset(network,0,sizeof(*network)); - ieee->state=RTLLIB_LINKED; + memset(network, 0, sizeof(*network)); + ieee->state = RTLLIB_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; /* station support qos */ - /* Let the register setting defaultly with Legacy station */ - assoc_resp = (struct rtllib_assoc_response_frame*)skb->data; + /* Let the register setting default with Legacy station */ + assoc_resp = (struct rtllib_assoc_response_frame *)skb->data; if (ieee->current_network.qos_data.supported == 1) { - if (rtllib_parse_info_param(ieee,assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ + if (rtllib_parse_info_param(ieee, assoc_resp->info_element, + rx_stats->len - sizeof(*assoc_resp), + network, rx_stats)) { kfree(network); return 1; - } - else - { - memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); + } else { + memcpy(ieee->pHTInfo->PeerHTCapBuf, + network->bssht.bdHTCapBuf, + network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, + network->bssht.bdHTInfoBuf, + network->bssht.bdHTInfoLen); } if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee->dev, (struct rtllib_assoc_response_frame*)header, network); + ieee->handle_assoc_response(ieee->dev, + (struct rtllib_assoc_response_frame *)header, + network); kfree(network); } - if (ieee->assocresp_ies){ - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - } + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; ies = &(assoc_resp->info_element[0].id); ieee->assocresp_ies_len = (skb->data + skb->len) - ies; - ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, GFP_ATOMIC); + ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, + GFP_ATOMIC); if (ieee->assocresp_ies) - memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocresp_ies\n", __func__); + memcpy(ieee->assocresp_ies, ies, + ieee->assocresp_ies_len); + else { + printk(KERN_INFO "%s()Warning: can't alloc " + "memory for assocresp_ies\n", __func__); ieee->assocresp_ies_len = 0; } rtllib_associate_complete(ieee); } else { /* aid could not been allocated */ ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", + printk(KERN_INFO "Association response status code 0x%x\n", errcode); RTLLIB_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - } else { + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + else rtllib_associate_abort(ieee); - } } } - return 0; } -inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; - u8* challenge; - int chlen=0; + u8 *challenge; + int chlen = 0; bool bSupportNmode = true, bHalfSupportNmode = false; - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && (ieee->iw_mode == IW_MODE_INFRA)) { RTLLIB_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))) { - if (ieee->open_wep || !challenge){ + errcode = auth_parse(skb, &challenge, &chlen); + if (0 == errcode) { + if (ieee->open_wep || !challenge) { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - if (!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) - { - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) - { - if (IsHTHalfNmodeAPs(ieee)) - { + if (!(ieee->pHTInfo->IOTAction & + HT_IOT_ACT_PURE_N_MODE)) { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { + if (IsHTHalfNmodeAPs(ieee)) { bSupportNmode = true; bHalfSupportNmode = true; - } - else - { + } else { bSupportNmode = false; bHalfSupportNmode = false; } } } - /* Dummy wirless mode setting to avoid encryption issue */ + /* Dummy wirless mode setting to avoid + * encryption issue */ if (bSupportNmode) { - ieee->SetWirelessMode(ieee->dev, \ - ieee->current_network.mode); - }else{ + ieee->SetWirelessMode(ieee->dev, + ieee->current_network.mode); + } else { /*TODO*/ - ieee->SetWirelessMode(ieee->dev, IEEE_G); + ieee->SetWirelessMode(ieee->dev, + IEEE_G); } - if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) - { - printk("===============>entern half N mode\n"); - ieee->bHalfWirelessN24GMode = true; - } - else - ieee->bHalfWirelessN24GMode = false; + if (ieee->current_network.mode == + IEEE_N_24G && + bHalfSupportNmode == true) { + printk(KERN_INFO "======>enter " + "half N mode\n"); + ieee->bHalfWirelessN24GMode = + true; + } else + ieee->bHalfWirelessN24GMode = + false; rtllib_associate_step2(ieee); - }else{ - rtllib_auth_challenge(ieee, challenge, chlen); + } else { + rtllib_auth_challenge(ieee, challenge, + chlen); } - }else{ + } else { ieee->softmac_stats.rx_auth_rs_err++; - RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); + RTLLIB_DEBUG_MGMT("Authentication respose" + " status code 0x%x", errcode); - printk("Authentication respose status code 0x%x",errcode); + printk(KERN_INFO "Authentication respose " + "status code 0x%x", errcode); rtllib_associate_abort(ieee); } - }else if (ieee->iw_mode == IW_MODE_MASTER){ + } else if (ieee->iw_mode == IW_MODE_MASTER) { rtllib_rx_auth_rq(ieee, skb); } } - return 0; } @@ -2453,7 +2404,7 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) printk(KERN_INFO "==========>received disassoc/deauth(%x) " "frame, reason code:%x\n", WLAN_FC_GET_STYPE(header->frame_ctl), - ((struct rtllib_disassoc*)skb->data)->reason); + ((struct rtllib_disassoc *)skb->data)->reason); ieee->state = RTLLIB_ASSOCIATING; ieee->softmac_stats.reassoc++; ieee->is_roaming = true; @@ -2461,18 +2412,21 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) rtllib_disassociate(ieee); RemovePeerTS(ieee, header->addr2); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 5); + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 5); } - return 0; } -inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype) +inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; @@ -2480,44 +2434,31 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *s return 0; switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - - case RTLLIB_STYPE_ASSOC_RESP: - case RTLLIB_STYPE_REASSOC_RESP: - - if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) - return 1; - - break; - - case RTLLIB_STYPE_ASSOC_REQ: - case RTLLIB_STYPE_REASSOC_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) - - rtllib_rx_assoc_rq(ieee, skb); - break; - - case RTLLIB_STYPE_AUTH: - - rtllib_rx_auth(ieee, skb, rx_stats); - - break; - case RTLLIB_STYPE_DISASSOC: - case RTLLIB_STYPE_DEAUTH: - - rtllib_rx_deauth(ieee, skb); - - break; - - case RTLLIB_STYPE_MANAGE_ACT: - rtllib_process_action(ieee,skb); - break; - default: - return -1; - break; + case RTLLIB_STYPE_ASSOC_RESP: + case RTLLIB_STYPE_REASSOC_RESP: + if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) + return 1; + break; + case RTLLIB_STYPE_ASSOC_REQ: + case RTLLIB_STYPE_REASSOC_REQ: + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->iw_mode == IW_MODE_MASTER) + rtllib_rx_assoc_rq(ieee, skb); + break; + case RTLLIB_STYPE_AUTH: + rtllib_rx_auth(ieee, skb, rx_stats); + break; + case RTLLIB_STYPE_DISASSOC: + case RTLLIB_STYPE_DEAUTH: + rtllib_rx_deauth(ieee, skb); + break; + case RTLLIB_STYPE_MANAGE_ACT: + rtllib_process_action(ieee, skb); + break; + default: + return -1; + break; } - return 0; } @@ -2548,43 +2489,43 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) struct cb_desc *tcb_desc = NULL; unsigned long queue_len = 0; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd parm 0, no tx mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); /* update the tx status */ - tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if (tcb_desc->bMulticast) { + tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + + MAX_DEV_ADDR_SIZE); + if (tcb_desc->bMulticast) ieee->stats.multicast++; - } - /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ + /* if xmit available, just xmit it immediately, else just insert it to + * the wait queue */ for (i = 0; i < txb->nr_frags; i++) { queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); if ((queue_len != 0) ||\ - (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ - (ieee->queue_stop)) { + (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || + (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need * to check it any more. * */ if (queue_len < 200) - { - skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); - }else{ + skb_queue_tail(&ieee->skb_waitQ[queue_index], + txb->fragments[i]); + else kfree_skb(txb->fragments[i]); - } - }else{ + } else { ieee->softmac_data_hard_start_xmit( txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); } } rtllib_txb_free(txb); - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2592,16 +2533,17 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) void rtllib_resume_tx(struct rtllib_device *ieee) { int i; - for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; + i++) { - if (ieee->queue_stop){ + if (ieee->queue_stop) { ieee->tx_pending.frag = i; return; - }else{ + } else { ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); ieee->stats.tx_packets++; } } @@ -2615,14 +2557,14 @@ void rtllib_reset_queue(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); init_mgmt_queue(ieee); - if (ieee->tx_pending.txb){ + if (ieee->tx_pending.txb) { rtllib_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2633,13 +2575,14 @@ void rtllib_wake_queue(struct rtllib_device *ieee) struct sk_buff *skb; struct rtllib_hdr_3addr *header; - spin_lock_irqsave(&ieee->lock,flags); - if (! ieee->queue_stop) goto exit; + spin_lock_irqsave(&ieee->lock, flags); + if (!ieee->queue_stop) + goto exit; ieee->queue_stop = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { + while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) { header = (struct rtllib_hdr_3addr *) skb->data; @@ -2650,26 +2593,27 @@ void rtllib_wake_queue(struct rtllib_device *ieee) else ieee->seq_ctrl[0]++; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } } if (!ieee->queue_stop && ieee->tx_pending.txb) rtllib_resume_tx(ieee); - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) { ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } -exit : - spin_unlock_irqrestore(&ieee->lock,flags); +exit: + spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_stop_queue(struct rtllib_device *ieee) { - if (! netif_queue_stopped(ieee->dev)){ + if (!netif_queue_stopped(ieee->dev)) { netif_stop_queue(ieee->dev); ieee->softmac_stats.swtxstop++; } @@ -2680,8 +2624,8 @@ void rtllib_stop_queue(struct rtllib_device *ieee) void rtllib_stop_all_queues(struct rtllib_device *ieee) { unsigned int i; - for (i=0; i < ieee->dev->num_tx_queues; i++) - netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; + for (i = 0; i < ieee->dev->num_tx_queues; i++) + netdev_get_tx_queue(ieee->dev, i)->trans_start = jiffies; netif_tx_stop_all_queues(ieee->dev); } @@ -2708,12 +2652,13 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) { ieee->assoc_id = 1; - if (ieee->current_network.ssid_len == 0){ + if (ieee->current_network.ssid_len == 0) { strncpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); + ieee->current_network.ssid_len = + strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2733,7 +2678,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ - if (ieee->raw_tx){ + if (ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -2743,7 +2688,8 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) void rtllib_start_ibss_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. @@ -2751,14 +2697,14 @@ void rtllib_start_ibss_wq(void *data) * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - if (!ieee->proto_started){ - printk("==========oh driver down return\n"); + if (!ieee->proto_started) { + printk(KERN_INFO "==========oh driver down return\n"); return; } down(&ieee->wx_sem); - if (ieee->current_network.ssid_len == 0){ - strcpy(ieee->current_network.ssid,RTLLIB_DEFAULT_TX_ESSID); + if (ieee->current_network.ssid_len == 0) { + strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2787,47 +2733,50 @@ void rtllib_start_ibss_wq(void *data) rtllib_start_scan_syncro(ieee, 0); /* the network definitively is not here.. create a new cell */ - if (ieee->state == RTLLIB_NOLINK){ - printk("creating new IBSS cell\n"); + if (ieee->state == RTLLIB_NOLINK) { + printk(KERN_INFO "creating new IBSS cell\n"); ieee->current_network.channel = ieee->IbssStartChnl; if (!ieee->wap_set) rtllib_randomize_cell(ieee); - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { ieee->current_network.rates_len = 4; - ieee->current_network.rates[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; - ieee->current_network.rates[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; - ieee->current_network.rates[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; - ieee->current_network.rates[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; + ieee->current_network.rates[0] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; + ieee->current_network.rates[1] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; + ieee->current_network.rates[2] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; + ieee->current_network.rates[3] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; - }else + } else ieee->current_network.rates_len = 0; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { ieee->current_network.rates_ex_len = 8; - /*ieee->current_network.rates_ex[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;*/ - - ieee->current_network.rates_ex[0] = RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_OFDM_RATE_54MB; + ieee->current_network.rates_ex[0] = + RTLLIB_OFDM_RATE_6MB; + ieee->current_network.rates_ex[1] = + RTLLIB_OFDM_RATE_9MB; + ieee->current_network.rates_ex[2] = + RTLLIB_OFDM_RATE_12MB; + ieee->current_network.rates_ex[3] = + RTLLIB_OFDM_RATE_18MB; + ieee->current_network.rates_ex[4] = + RTLLIB_OFDM_RATE_24MB; + ieee->current_network.rates_ex[5] = + RTLLIB_OFDM_RATE_36MB; + ieee->current_network.rates_ex[6] = + RTLLIB_OFDM_RATE_48MB; + ieee->current_network.rates_ex[7] = + RTLLIB_OFDM_RATE_54MB; ieee->rate = 108; - }else{ + } else { ieee->current_network.rates_ex_len = 0; ieee->rate = 22; } @@ -2839,20 +2788,21 @@ void rtllib_start_ibss_wq(void *data) ieee->current_network.capability = WLAN_CAPABILITY_IBSS; } - printk("%s(): ieee->mode = %d\n", __func__, ieee->mode); + printk(KERN_INFO "%s(): ieee->mode = %d\n", __func__, ieee->mode); if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G)) HTUseDefaultSetting(ieee); else ieee->pHTInfo->bCurrentHTSupport = false; - ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&ieee->state)); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&ieee->state)); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev,LED_CTL_LINK); + ieee->LedControlHandler(ieee->dev, LED_CTL_LINK); rtllib_start_send_beacons(ieee); @@ -2875,12 +2825,9 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee) void rtllib_start_bss(struct rtllib_device *ieee) { unsigned long flags; - if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { - if (! ieee->bGlobalDomain) - { + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { + if (!ieee->bGlobalDomain) return; - } } /* check if we have already found the net we * are interested in (if any). @@ -2898,15 +2845,15 @@ void rtllib_start_bss(struct rtllib_device *ieee) */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == RTLLIB_NOLINK) { + if (ieee->state == RTLLIB_NOLINK) rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_link_change_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, link_change_wq); ieee->link_change(ieee->dev); } /* called only in userspace context */ @@ -2931,7 +2878,8 @@ void rtllib_disassociate(struct rtllib_device *ieee) void rtllib_associate_retry_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, associate_retry_wq); unsigned long flags; down(&ieee->wx_sem); @@ -2962,9 +2910,7 @@ void rtllib_associate_retry_wq(void *data) spin_lock_irqsave(&ieee->lock, flags); if (ieee->state == RTLLIB_NOLINK) - { rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); ieee->beinretry = false; @@ -2974,7 +2920,7 @@ exit: struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) { - u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sk_buff *skb; struct rtllib_probe_response *b; @@ -3010,11 +2956,12 @@ struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee) return skb; } -void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) +void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, + u8 shutdown) { rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); - rtllib_stop_protocol(ieee,shutdown); + rtllib_stop_protocol(ieee, shutdown); up(&ieee->wx_sem); } @@ -3024,8 +2971,8 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (!ieee->proto_started) return; - if (shutdown){ - ieee->proto_started = 0; + if (shutdown) { + ieee->proto_started = 0; ieee->proto_stoppping = 1; if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -3041,26 +2988,22 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) ieee->state = RTLLIB_NOLINK; - if (ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { if (ieee->iw_mode == IW_MODE_INFRA) - SendDisassociation(ieee,1,deauth_lv_ss); + SendDisassociation(ieee, 1, deauth_lv_ss); rtllib_disassociate(ieee); } - if (shutdown){ + if (shutdown) { RemoveAllTS(ieee); ieee->proto_stoppping = 0; } - if (ieee->assocreq_ies) { - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - ieee->assocreq_ies_len = 0; - } - if (ieee->assocresp_ies) { - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - ieee->assocresp_ies_len = 0; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; + ieee->assocreq_ies_len = 0; + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + ieee->assocresp_ies_len = 0; } void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) @@ -3087,7 +3030,7 @@ void rtllib_start_protocol(struct rtllib_device *ieee) ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); ieee->current_network.channel = ch; } @@ -3130,20 +3073,19 @@ void rtllib_softmac_init(struct rtllib_device *ieee) memset(&ieee->current_network, 0, sizeof(struct rtllib_network)); ieee->state = RTLLIB_NOLINK; - for (i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } + for (i = 0; i < 5; i++) + ieee->seq_ctrl[i] = 0; ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); if (!ieee->pDot11dInfo) RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); ieee->LinkDetectInfo.SlotIndex = 0; ieee->LinkDetectInfo.SlotNum = 2; - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - ieee->LinkDetectInfo.NumTxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod=0; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; ieee->bIsAggregateFrame = false; ieee->assoc_id = 0; ieee->queue_stop = 0; @@ -3158,13 +3100,13 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->ps = RTLLIB_PS_DISABLED; ieee->sta_sleep = LPS_IS_WAKE; - ieee->Regdot11HTOperationalRateSet[0]= 0xff; - ieee->Regdot11HTOperationalRateSet[1]= 0xff; - ieee->Regdot11HTOperationalRateSet[4]= 0x01; + ieee->Regdot11HTOperationalRateSet[0] = 0xff; + ieee->Regdot11HTOperationalRateSet[1] = 0xff; + ieee->Regdot11HTOperationalRateSet[4] = 0x01; - ieee->Regdot11TxHTOperationalRateSet[0]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[1]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[4]= 0x01; + ieee->Regdot11TxHTOperationalRateSet[0] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[1] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[4] = 0x01; ieee->FirstIe_InScan = false; ieee->actscanning = false; @@ -3191,18 +3133,26 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->wq = create_workqueue(DRV_NAME); - INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); - INIT_WORK_RSL(&ieee->associate_complete_wq, (void*)rtllib_associate_complete_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, (void*)rtllib_associate_procedure_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,(void*)rtllib_softmac_scan_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,(void*)rtllib_softmac_hint11d_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void*)rtllib_associate_retry_wq,ieee); - INIT_WORK_RSL(&ieee->wx_sync_scan_wq,(void*)rtllib_wx_sync_scan_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->link_change_wq, + (void *)rtllib_link_change_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq, + (void *)rtllib_start_ibss_wq, ieee); + INIT_WORK_RSL(&ieee->associate_complete_wq, + (void *)rtllib_associate_complete_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, + (void *)rtllib_associate_procedure_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq, + (void *)rtllib_softmac_scan_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq, + (void *)rtllib_softmac_hint11d_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, + (void *)rtllib_associate_retry_wq, ieee); + INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq, + ieee); sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - sema_init(&ieee->ips_sem,1); + sema_init(&ieee->ips_sem, 1); spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); @@ -3216,8 +3166,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { down(&ieee->wx_sem); - if (NULL != ieee->pDot11dInfo) - { + if (NULL != ieee->pDot11dInfo) { kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; } @@ -3229,8 +3178,8 @@ void rtllib_softmac_free(struct rtllib_device *ieee) } /******************************************************** - * Start of WPA code. * - * this is stolen from the ipw2200 driver * + * Start of WPA code. * + * this is stolen from the ipw2200 driver * ********************************************************/ @@ -3238,14 +3187,15 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ - printk("%s WPA\n",value ? "enabling" : "disabling"); + printk(KERN_INFO "%s WPA\n", value ? "enabling" : "disabling"); ieee->wpa_enabled = value; memset(ieee->ap_mac_addr, 0, 6); return 0; } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, int wpa_ie_len) +void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3268,7 +3218,7 @@ static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason) break; default: - printk("Unknown MLME request: %d\n", command); + printk(KERN_INFO "Unknown MLME request: %d\n", command); ret = -EOPNOTSUPP; } @@ -3319,12 +3269,11 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) sec.auth_mode = WLAN_AUTH_SHARED_KEY; ieee->open_wep = 0; ieee->auth_mode = 1; - } else if (value & AUTH_ALG_OPEN_SYSTEM){ + } else if (value & AUTH_ALG_OPEN_SYSTEM) { sec.auth_mode = WLAN_AUTH_OPEN; ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (value & AUTH_ALG_LEAP){ + } else if (value & AUTH_ALG_LEAP) { sec.auth_mode = WLAN_AUTH_LEAP >> 6; ieee->open_wep = 1; ieee->auth_mode = 2; @@ -3339,7 +3288,7 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) { - int ret=0; + int ret = 0; unsigned long flags; switch (name) { @@ -3348,11 +3297,11 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures=value; + ieee->tkip_countermeasures = value; break; - case IEEE_PARAM_DROP_UNENCRYPTED: - { + case IEEE_PARAM_DROP_UNENCRYPTED: + { /* HACK: * * wpa_supplicant calls set_wpa_enabled when the driver @@ -3375,8 +3324,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) if (!value) { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_0; - } - else { + } else { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } @@ -3386,7 +3334,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) } case IEEE_PARAM_PRIVACY_INVOKED: - ieee->privacy_invoked=value; + ieee->privacy_invoked = value; break; case IEEE_PARAM_AUTH_ALGS: @@ -3394,15 +3342,15 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_IEEE_802_1X: - ieee->ieee802_1x=value; + ieee->ieee802_1x = value; break; case IEEE_PARAM_WPAX_SELECT: - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); + spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags); + spin_unlock_irqrestore(&ieee->wpax_suitlist_lock, flags); break; default: - printk("Unknown WPA param: %d\n",name); + printk(KERN_INFO "Unknown WPA param: %d\n", name); ret = -EOPNOTSUPP; } @@ -3411,7 +3359,8 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) /* implementation borrowed from hostap driver */ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, - struct ieee_param *param, int param_len, u8 is_mesh) + struct ieee_param *param, int param_len, + u8 is_mesh) { int ret = 0; struct rtllib_crypto_ops *ops; @@ -3427,7 +3376,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, if (param_len != (int) ((char *) param->u.crypt.key - (char *) param) + param->u.crypt.key_len) { - printk("Len mismatch %d, %d\n", param_len, + printk(KERN_INFO "Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); return -EINVAL; } @@ -3470,7 +3419,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ops = rtllib_get_crypto_ops(param->u.crypt.alg); } if (ops == NULL) { - printk("unknown crypto alg '%s'\n", param->u.crypt.alg); + printk(KERN_INFO "unknown crypto alg '%s'\n", + param->u.crypt.alg); param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; ret = -EINVAL; goto done; @@ -3506,7 +3456,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, (*crypt)->ops->set_key(param->u.crypt.key, param->u.crypt.key_len, param->u.crypt.seq, (*crypt)->priv) < 0) { - printk("key setting failed\n"); + printk(KERN_INFO "key setting failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; ret = -EINVAL; goto done; @@ -3551,7 +3501,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(ieee->dev)) { - printk("reset_port failed\n"); + printk(KERN_INFO "reset_port failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; return -EINVAL; } @@ -3559,7 +3509,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, return ret; } -inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3567,13 +3517,13 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); + disauth = (struct rtllib_disauth *) skb_put(skb, + sizeof(struct rtllib_disauth)); disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); disauth->header.duration_id = 0; @@ -3585,7 +3535,7 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, return skb; } -inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3593,13 +3543,13 @@ inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); + disass = (struct rtllib_disassoc *) skb_put(skb, + sizeof(struct rtllib_disassoc)); disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); disass->header.duration_id = 0; @@ -3616,36 +3566,36 @@ void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; - if (deauth) { - skb = rtllib_disauth_skb(beacon,ieee,asRsn); - } else { - skb = rtllib_disassociate_skb(beacon,ieee,asRsn); - } + if (deauth) + skb = rtllib_disauth_skb(beacon, ieee, asRsn); + else + skb = rtllib_disassociate_skb(beacon, ieee, asRsn); - if (skb){ + if (skb) softmac_mgmt_xmit(skb, ieee); - } } u8 rtllib_ap_sec_type(struct rtllib_device *ieee) { - static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; + static u8 ccmp_ie[4] = {0x00, 0x50, 0xf2, 0x04}; static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; - int wpa_ie_len= ieee->wpa_ie_len; - struct rtllib_crypt_data* crypt; + int wpa_ie_len = ieee->wpa_ie_len; + struct rtllib_crypt_data *crypt; int encrypt; crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\ - (ieee->host_encrypt && crypt && crypt->ops && \ - (0 == strcmp(crypt->ops->name,"WEP"))); + encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) + || (ieee->host_encrypt && crypt && crypt->ops && + (0 == strcmp(crypt->ops->name, "WEP"))); /* simply judge */ if (encrypt && (wpa_ie_len == 0)) { return SEC_ALG_WEP; } else if ((wpa_ie_len != 0)) { - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || - ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) + if (((ieee->wpa_ie[0] == 0xdd) && + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || + ((ieee->wpa_ie[0] == 0x30) && + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4)))) return SEC_ALG_CCMP; else return SEC_ALG_TKIP; @@ -3654,20 +3604,21 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee) } } -int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh) +int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, + u8 is_mesh) { struct ieee_param *param; - int ret=0; + int ret = 0; down(&ieee->wx_sem); - if (p->length < sizeof(struct ieee_param) || !p->pointer){ + if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; } - param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (param == NULL){ + param = kmalloc(p->length, GFP_KERNEL); + if (param == NULL) { ret = -ENOMEM; goto out; } @@ -3678,7 +3629,6 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name, param->u.wpa_param.value); @@ -3698,7 +3648,8 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, break; default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); + printk(KERN_INFO "Unknown WPA supplicant request: %d\n", + param->cmd); ret = -EOPNOTSUPP; break; } @@ -3713,8 +3664,7 @@ out: return ret; } -void -rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) +void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib) { u8 OpMode; u8 i; @@ -3722,26 +3672,25 @@ rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i]= 0x55; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x55; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); OpMode = RT_OP_MODE_NO_LINK; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode); rtllib_stop_send_beacons(rtllib); bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); notify_wx_assoc_event(rtllib); } -void -rtllib_MlmeDisassociateRequest( - struct rtllib_device* rtllib, - u8* asSta, - u8 asRsn - ) +void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, + u8 asRsn) { u8 i; u8 OpMode; @@ -3749,17 +3698,19 @@ rtllib_MlmeDisassociateRequest( RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid,asSta,6) == 0) - { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i] = 0x22; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x22; OpMode = RT_OP_MODE_NO_LINK; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&OpMode) ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&OpMode)); rtllib_disassociate(rtllib); - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); } @@ -3767,40 +3718,31 @@ rtllib_MlmeDisassociateRequest( void rtllib_MgntDisconnectAP( - struct rtllib_device* rtllib, + struct rtllib_device *rtllib, u8 asRsn ) { bool bFilterOutNonAssociatedBSSID = false; bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); - rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid, + asRsn); rtllib->state = RTLLIB_NOLINK; } -bool -rtllib_MgntDisconnect( - struct rtllib_device* rtllib, - u8 asRsn -) +bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) { if (rtllib->ps != RTLLIB_PS_DISABLED) - { - rtllib->sta_wake_up(rtllib->dev); - } + rtllib->sta_wake_up(rtllib->dev); - if ( rtllib->state == RTLLIB_LINKED ) - { - if ( rtllib->iw_mode == IW_MODE_ADHOC ) - { + if (rtllib->state == RTLLIB_LINKED) { + if (rtllib->iw_mode == IW_MODE_ADHOC) rtllib_MgntDisconnectIBSS(rtllib); - } - if ( rtllib->iw_mode == IW_MODE_INFRA ) - { + if (rtllib->iw_mode == IW_MODE_INFRA) rtllib_MgntDisconnectAP(rtllib, asRsn); - } } @@ -3816,10 +3758,12 @@ void notify_wx_assoc_event(struct rtllib_device *ieee) wrqu.ap_addr.sa_family = ARPHRD_ETHER; if (ieee->state == RTLLIB_LINKED) - memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - else{ + memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, + ETH_ALEN); + else { - printk("%s(): Tell user space disconnected\n",__func__); + printk(KERN_INFO "%s(): Tell user space disconnected\n", + __func__); memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); } wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); From 755f3a84cfa5e366094c33fbede39f18a4f4f08a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 14:42:16 -0500 Subject: [PATCH 0536/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XV This patch removes all the errors and warnings generated by checkpatch -f for rtllib_softmac_wx.c.. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 177 ++++++++++--------- 1 file changed, 90 insertions(+), 87 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index e6702a14165..22988fbd444 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -31,11 +31,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->iw_mode == IW_MODE_INFRA) { ret = 0; goto out; } @@ -56,11 +56,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, } } - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1) { ret = -EOPNOTSUPP; goto out; - }else { /* Set the channel */ + } else { /* Set the channel */ if (ieee->active_channel_map[fwrq->m] != 1) { ret = -EINVAL; @@ -69,11 +69,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - if (ieee->state == RTLLIB_LINKED){ - - rtllib_stop_send_beacons(ieee); - rtllib_start_send_beacons(ieee); + if (ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) + if (ieee->state == RTLLIB_LINKED) { + rtllib_stop_send_beacons(ieee); + rtllib_start_send_beacons(ieee); } } @@ -88,11 +88,12 @@ int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; if (ieee->current_network.channel == 0) return -1; - fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * 100000; + fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * + 100000; fwrq->e = 1; return 0; } @@ -133,7 +134,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, { int ret = 0; - u8 zero[] = {0,0,0,0,0,0}; + u8 zero[] = {0, 0, 0, 0, 0, 0}; unsigned long flags; short ifup = ieee->proto_started; @@ -143,28 +144,28 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, down(&ieee->wx_sem); /* use ifconfig hw ether */ - if (ieee->iw_mode == IW_MODE_MASTER){ + if (ieee->iw_mode == IW_MODE_MASTER) { ret = -1; goto out; } - if (temp->sa_family != ARPHRD_ETHER){ + if (temp->sa_family != ARPHRD_ETHER) { ret = -EINVAL; goto out; } - if (memcmp(temp->sa_data, zero,ETH_ALEN) == 0){ - spin_lock_irqsave(&ieee->lock, flags); - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = 0; - spin_unlock_irqrestore(&ieee->lock, flags); - ret = -1; - goto out; - } + if (memcmp(temp->sa_data, zero, ETH_ALEN) == 0) { + spin_lock_irqsave(&ieee->lock, flags); + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ieee->wap_set = 0; + spin_unlock_irqrestore(&ieee->lock, flags); + ret = -1; + goto out; + } if (ifup) - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise @@ -173,7 +174,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, ieee->cannot_notify = false; memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = (memcmp(temp->sa_data, zero,ETH_ALEN)!=0); + ieee->wap_set = (memcmp(temp->sa_data, zero, ETH_ALEN) != 0); spin_unlock_irqrestore(&ieee->lock, flags); @@ -184,9 +185,10 @@ out: return ret; } - int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) +int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { - int len,ret = 0; + int len, ret = 0; unsigned long flags; if (ieee->iw_mode == IW_MODE_MONITOR) @@ -196,20 +198,20 @@ out: spin_lock_irqsave(&ieee->lock, flags); if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0) { ret = -1; goto out; } if (ieee->state != RTLLIB_LINKED && ieee->state != RTLLIB_LINKED_SCANNING && - ieee->ssid_set == 0){ + ieee->ssid_set == 0) { ret = -1; goto out; } len = ieee->current_network.ssid_len; wrqu->essid.length = len; - strncpy(b,ieee->current_network.ssid,len); + strncpy(b, ieee->current_network.ssid, len); wrqu->essid.flags = 1; out: @@ -235,7 +237,8 @@ int rtllib_wx_get_rate(struct rtllib_device *ieee, union iwreq_data *wrqu, char *extra) { u32 tmp_rate = 0; - tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); + tmp_rate = TxCountToDataRate(ieee, + ieee->softmac_stats.CurrentShowTxate); wrqu->bitrate.value = tmp_rate * 500000; return 0; @@ -248,8 +251,7 @@ int rtllib_wx_set_rts(struct rtllib_device *ieee, { if (wrqu->rts.disabled || !wrqu->rts.fixed) ieee->rts = DEFAULT_RTS_THRESHOLD; - else - { + else { if (wrqu->rts.value < MIN_RTS_THRESHOLD || wrqu->rts.value > MAX_RTS_THRESHOLD) return -EINVAL; @@ -293,17 +295,17 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, if (wrqu->mode == IW_MODE_MONITOR) { ieee->dev->type = ARPHRD_IEEE80211; - rtllib_EnableNetMonitorMode(ieee->dev,false); + rtllib_EnableNetMonitorMode(ieee->dev, false); } else { ieee->dev->type = ARPHRD_ETHER; if (ieee->iw_mode == IW_MODE_MONITOR) - rtllib_DisableNetMonitorMode(ieee->dev,false); + rtllib_DisableNetMonitorMode(ieee->dev, false); } if (!ieee->proto_started) { ieee->iw_mode = wrqu->mode; } else { - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); ieee->iw_mode = wrqu->mode; rtllib_start_protocol(ieee); } @@ -315,14 +317,15 @@ out: void rtllib_wx_sync_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, wx_sync_scan_wq); short chan; - enum ht_extchnl_offset chan_offset=0; - enum ht_channel_width bandwidth=0; + enum ht_extchnl_offset chan_offset = 0; + enum ht_channel_width bandwidth = 0; int b40M = 0; - static int count = 0; + static int count; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_start_scan_syncro(ieee, 0); goto out; } @@ -346,15 +349,18 @@ void rtllib_wx_sync_scan_wq(void *data) msleep(50); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_BACKUP); - if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && + ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; - RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } + RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", + chan_offset, bandwidth); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } rtllib_start_scan_syncro(ieee, 0); @@ -372,7 +378,7 @@ void rtllib_wx_sync_scan_wq(void *data) } if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_RESTORE); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); @@ -381,9 +387,9 @@ void rtllib_wx_sync_scan_wq(void *data) rtllib_sta_ps_send_null_frame(ieee, 0); if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || - ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } if (ieee->data_hard_resume) @@ -407,12 +413,12 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) { ret = -1; goto out; } - if ( ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { queue_work_rsl(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; @@ -424,11 +430,11 @@ out: } int rtllib_wx_set_essid(struct rtllib_device *ieee, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) { - int ret=0,len,i; + int ret = 0, len, i; short proto_started; unsigned long flags; @@ -437,27 +443,28 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, proto_started = ieee->proto_started; - len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : + IW_ESSID_MAX_SIZE; - if (len > IW_ESSID_MAX_SIZE){ - ret= -E2BIG; + if (len > IW_ESSID_MAX_SIZE) { + ret = -E2BIG; goto out; } - if (ieee->iw_mode == IW_MODE_MONITOR){ - ret= -1; + if (ieee->iw_mode == IW_MODE_MONITOR) { + ret = -1; goto out; } - for (i=0; icurrent_network.ssid_len = len; ieee->cannot_notify = false; ieee->ssid_set = 1; - } - else{ + } else { ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; @@ -485,16 +491,16 @@ out: return ret; } - int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) +int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { wrqu->mode = ieee->iw_mode; return 0; } - int rtllib_wx_set_rawtx(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +int rtllib_wx_set_rawtx(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int *parms = (int *)extra; @@ -511,9 +517,8 @@ out: printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); - if (ieee->iw_mode == IW_MODE_MONITOR) - { - if (prev == 0 && ieee->raw_tx){ + if (ieee->iw_mode == IW_MODE_MONITOR) { + if (prev == 0 && ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -552,33 +557,30 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, { int ret = 0; - if ( - (!ieee->sta_wake_up) || - (!ieee->enter_sleep_state) || - (!ieee->ps_is_queue_empty)){ - - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): PS mode is tryied to be use but driver missed a callback\n\n",__func__); - + if ((!ieee->sta_wake_up) || + (!ieee->enter_sleep_state) || + (!ieee->ps_is_queue_empty)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tryied to be use " + "but driver missed a callback\n\n", __func__); return -1; } down(&ieee->wx_sem); - if (wrqu->power.disabled){ - RT_TRACE(COMP_DBG, "===>%s(): power disable\n",__func__); + if (wrqu->power.disabled) { + RT_TRACE(COMP_DBG, "===>%s(): power disable\n", __func__); ieee->ps = RTLLIB_PS_DISABLED; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { ieee->ps_timeout = wrqu->power.value / 1000; - RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n",__func__,ieee->ps_timeout); + RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n", __func__, + ieee->ps_timeout); } - if (wrqu->power.flags & IW_POWER_PERIOD) { - + if (wrqu->power.flags & IW_POWER_PERIOD) ieee->ps_period = wrqu->power.value / 1000; - } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = RTLLIB_PS_UNICAST; @@ -609,7 +611,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret =0; + int ret = 0; down(&ieee->wx_sem); @@ -628,7 +630,8 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, wrqu->power.value = ieee->ps_period * 1000; } - if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) + if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == + (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) wrqu->power.flags |= IW_POWER_ALL_R; else if (ieee->ps & RTLLIB_PS_MBCAST) wrqu->power.flags |= IW_POWER_MULTICAST_R; From 94fa3e89b4527606b0fef70f2659f9f4ecb38cfc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 20:15:22 -0500 Subject: [PATCH 0537/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVI This patch removes all the errors and most of the warnings generated by checkpatch -f for rtllib_softmac_tx.c.. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_tx.c | 512 ++++++++++++++------------- 1 file changed, 262 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 134e69f4ee5..f038aa93083 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -67,21 +67,21 @@ bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------| desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep | - | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | + | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | '-----------------------------------------------------------------------------------------' - /\ - | -802.11 Data Frame | - ,--------- 'ctrl' expands to >-----------' - | + /\ + | +802.11 Data Frame | + ,--------- 'ctrl' expands to >-----------' + | ,--'---,-------------------------------------------------------------. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `--------------------------------------------------| |------' -Total: 28 non-data bytes `----.----' - | + | | tion | (BSSID) | | | ence | data | | + `--------------------------------------------------| |------' +Total: 28 non-data bytes `----.----' + | .- 'Frame data' expands to <---------------------------' | V @@ -89,11 +89,11 @@ Total: 28 non-data bytes `----.----' Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | |------|------|---------|----------|------|---------| Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | - | DSAP | SSAP | | | | Packet | - | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | - `-----------------------------------------| | -Total: 8 non-data bytes `----.----' - | + | DSAP | SSAP | | | | Packet | + | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | + `-----------------------------------------| | +Total: 8 non-data bytes `----.----' + | .- 'IP Packet' expands, if WEP enabled, to <--' | V @@ -112,7 +112,7 @@ Total: 8 non-data bytes Bytes | 6 | 6 | 2 | Variable | 4 | |-------|-------|------|-----------|------| Desc. | Dest. | Source| Type | IP Packet | fcs | - | MAC | MAC | | | | + | MAC | MAC | | | | `-----------------------------------------' Total: 18 non-data bytes @@ -130,19 +130,19 @@ payload of each frame is reduced to 492 bytes. * * ,- skb->data * | -* | ETHERNET HEADER ,-<-- PAYLOAD -* | | 14 bytes from skb->data +* | ETHERNET HEADER ,-<-- PAYLOAD +* | | 14 bytes from skb->data * | 2 bytes for Type --> ,T. | (sizeof ethhdr) -* | | | | +* | | | | * |,-Dest.--. ,--Src.---. | | | * | 6 bytes| | 6 bytes | | | | -* v | | | | | | -* 0 | v 1 | v | v 2 +* v | | | | | | +* 0 | v 1 | v | v 2 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 -* ^ | ^ | ^ | -* | | | | | | -* | | | | `T' <---- 2 bytes for Type -* | | | | +* ^ | ^ | ^ | +* | | | | | | +* | | | | `T' <---- 2 bytes for Type +* | | | | * | | '---SNAP--' <-------- 6 bytes for SNAP * | | * `-IV--' <-------------------- 4 bytes for IV (WEP) @@ -177,19 +177,16 @@ inline int rtllib_put_snap(u8 *data, u16 h_proto) return SNAP_SIZE + sizeof(u16); } -int rtllib_encrypt_fragment( - struct rtllib_device *ieee, - struct sk_buff *frag, - int hdr_len) +int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag, + int hdr_len) { - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; int res; crypt = ieee->crypt[ieee->tx_keyidx]; - if (!(crypt && crypt->ops)) - { - printk("=========>%s(), crypt is null\n", __func__); + if (!(crypt && crypt->ops)) { + printk(KERN_INFO "=========>%s(), crypt is null\n", __func__); return -1; } /* To encrypt, frame format is: @@ -216,20 +213,20 @@ int rtllib_encrypt_fragment( } -void rtllib_txb_free(struct rtllib_txb *txb) { +void rtllib_txb_free(struct rtllib_txb *txb) +{ if (unlikely(!txb)) return; kfree(txb); } struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) + int gfp_mask) { struct rtllib_txb *txb; int i; - txb = kmalloc( - sizeof(struct rtllib_txb) + (sizeof(u8*) * nr_frags), - gfp_mask); + txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), + gfp_mask); if (!txb) return NULL; @@ -286,23 +283,25 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) +void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; - struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; + struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr *)skb->data; - if (rtllib_act_scanning(ieee,false)) + if (rtllib_act_scanning(ieee, false)) return; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (!IsQoSDataFrame(skb->data)) return; - if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1)) + if (is_multicast_ether_addr(hdr->addr1) || + is_broadcast_ether_addr(hdr->addr1)) return; - if (tcb_desc->bdhcp || ieee->CntAfterLink<2) + if (tcb_desc->bdhcp || ieee->CntAfterLink < 2) return; if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) @@ -310,22 +309,25 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) return; - if (pHTInfo->bCurrentAMPDUEnable){ - if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ - printk("%s: can't get TS\n", __func__); + if (pHTInfo->bCurrentAMPDUEnable) { + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, + skb->priority, TX_DIR, true)) { + printk(KERN_INFO "%s: can't get TS\n", __func__); return; } - if (pTxTs->TxAdmittedBARecord.bValid == false){ - if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA)) { + if (pTxTs->TxAdmittedBARecord.bValid == false) { + if (ieee->wpa_ie_len && (ieee->pairwise_key_type == + KEY_TYPE_NA)) { ; - } else if (tcb_desc->bdhcp == 1){ + } else if (tcb_desc->bdhcp == 1) { ; - } else if (!pTxTs->bDisable_AddBa){ + } else if (!pTxTs->bDisable_AddBa) { TsStartAddBaProcess(ieee, pTxTs); } goto FORCED_AGG_SETTING; } else if (pTxTs->bUsingBa == false) { - if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) + if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, + (pTxTs->TxCurSeq+1)%4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; @@ -338,81 +340,80 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st } FORCED_AGG_SETTING: switch (pHTInfo->ForcedAMPDUMode) { - case HT_AGG_AUTO: - break; + case HT_AGG_AUTO: + break; - case HT_AGG_FORCE_ENABLE: - tcb_desc->bAMPDUEnable = true; - tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; - tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; - break; + case HT_AGG_FORCE_ENABLE: + tcb_desc->bAMPDUEnable = true; + tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; + tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; + break; - case HT_AGG_FORCE_DISABLE: - tcb_desc->bAMPDUEnable = false; - tcb_desc->ampdu_density = 0; - tcb_desc->ampdu_factor = 0; - break; - - } - return; -} - -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) -{ - tcb_desc->bUseShortPreamble = false; - if (tcb_desc->data_rate == 2) - { - return; - } - else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - tcb_desc->bUseShortPreamble = true; + case HT_AGG_FORCE_DISABLE: + tcb_desc->bAMPDUEnable = false; + tcb_desc->ampdu_density = 0; + tcb_desc->ampdu_factor = 0; + break; } return; } -extern void -rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) +extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) +{ + tcb_desc->bUseShortPreamble = false; + if (tcb_desc->data_rate == 2) + return; + else if (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE) + tcb_desc->bUseShortPreamble = true; + return; +} + +extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bUseShortGI = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; - if (pHTInfo->bForcedShortGI) - { + if (pHTInfo->bForcedShortGI) { tcb_desc->bUseShortGI = true; return; } - if ((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz) + if ((pHTInfo->bCurBW40MHz == true) && pHTInfo->bCurShortGI40MHz) tcb_desc->bUseShortGI = true; - else if ((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz) + else if ((pHTInfo->bCurBW40MHz == false) && pHTInfo->bCurShortGI20MHz) tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device* ieee, struct cb_desc *tcb_desc) +void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bPacketBW = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (tcb_desc->bMulticast || tcb_desc->bBroadcast) return; - if ((tcb_desc->data_rate & 0x80)==0) + if ((tcb_desc->data_rate & 0x80) == 0) return; - if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) + if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && + !ieee->bandwidth_auto_switch.bforced_tx20Mhz) tcb_desc->bPacketBW = true; return; } -void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc, struct sk_buff* skb) +void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -426,77 +427,58 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc if (is_broadcast_ether_addr(skb->data+16)) return; - if (ieee->mode < IEEE_N_24G) - { - if (skb->len > ieee->rts) - { + if (ieee->mode < IEEE_N_24G) { + if (skb->len > ieee->rts) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; - } - else if (ieee->current_network.buseprotection) - { + } else if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; } return; - } - else - { + } else { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - while (true) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) - { + while (true) { + if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; - } - else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE)) - { + } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS | + HT_IOT_ACT_PURE_N_MODE)) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (ieee->current_network.buseprotection) - { + if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) - { + if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { u8 HTOpMode = pHTInfo->CurrentOpMode; - if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || - (!pHTInfo->bCurBW40MHz && HTOpMode == 3) ) - { + if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || + HTOpMode == 3)) || + (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } } - if (skb->len > ieee->rts) - { + if (skb->len > ieee->rts) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } - if (tcb_desc->bAMPDUEnable) - { + if (tcb_desc->bAMPDUEnable) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = false; break; } goto NO_PROTECTION; } - } - if ( 0 ) - { - tcb_desc->bCTSEnable = true; - tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; } if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) tcb_desc->bUseShortPreamble = true; @@ -506,39 +488,40 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc NO_PROTECTION: tcb_desc->bRTSEnable = false; tcb_desc->bCTSEnable = false; - tcb_desc->rts_rate = 0; + tcb_desc->rts_rate = 0; tcb_desc->RTSSC = 0; - tcb_desc->bRTSBW = false; + tcb_desc->bRTSBW = false; } -void rtllib_txrate_selectmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) +void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; if (ieee->bTxUseDriverAssingedRate) tcb_desc->bTxUseDriverAssingedRate = true; - if (!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) - { - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) + if (!tcb_desc->bTxDisableRateFallBack || + !tcb_desc->bTxUseDriverAssingedRate) { + if (ieee->iw_mode == IW_MODE_INFRA || + ieee->iw_mode == IW_MODE_ADHOC) tcb_desc->RATRIndex = 0; } } -u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) +u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *dst) { u16 seqnum = 0; if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) return 0; - if (IsQoSDataFrame(skb->data)) - { + if (IsQoSDataFrame(skb->data)) { struct tx_ts_record *pTS = NULL; - if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + skb->priority, TX_DIR, true)) return 0; - } seqnum = pTS->TxCurSeq; pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; return seqnum; @@ -549,26 +532,27 @@ u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) static int wme_downgrade_ac(struct sk_buff *skb) { switch (skb->priority) { - case 6: - case 7: - skb->priority = 5; /* VO -> VI */ - return 0; - case 4: - case 5: - skb->priority = 3; /* VI -> BE */ - return 0; - case 0: - case 3: - skb->priority = 1; /* BE -> BK */ - return 0; - default: - return -1; + case 6: + case 7: + skb->priority = 5; /* VO -> VI */ + return 0; + case 4: + case 5: + skb->priority = 3; /* VI -> BE */ + return 0; + case 0: + case 3: + skb->priority = 1; /* BE -> BK */ + return 0; + default: + return -1; } } int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); struct rtllib_txb *txb = NULL; struct rtllib_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; @@ -584,25 +568,27 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) }; u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; struct cb_desc *tcb_desc; u8 bIsMulticast = false; u8 IsAmsdu = false; + bool bdhcp = false; - bool bdhcp =false; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother * creating it... */ - if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))|| - ((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { + if ((!ieee->hard_start_xmit && !(ieee->softmac_features & + IEEE_SOFTMAC_TX_QUEUE)) || + ((!ieee->softmac_data_hard_start_xmit && + (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name); goto success; } - if (likely(ieee->raw_tx == 0)){ + if (likely(ieee->raw_tx == 0)) { if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -615,39 +601,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) memset(skb->cb, 0, sizeof(skb->cb)); ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - if (ieee->iw_mode == IW_MODE_MONITOR) - { + if (ieee->iw_mode == IW_MODE_MONITOR) { txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); if (unlikely(!txb)) { - printk(KERN_WARNING "%s: Could not allocate TXB\n", + printk(KERN_WARNING "%s: Could not allocate " + "TXB\n", ieee->dev->name); goto failed; } txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); goto success; } if (skb->len > 282) { if (ETH_P_IP == ether_type) { - const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); + const struct iphdr *ip = (struct iphdr *) + ((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { - struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); - if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || - ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { + struct udphdr *udp; + + udp = (struct udphdr *)((u8 *)ip + + (ip->ihl << 2)); + if (((((u8 *)udp)[1] == 68) && + (((u8 *)udp)[3] == 67)) || + ((((u8 *)udp)[1] == 67) && + (((u8 *)udp)[3] == 68))) { bdhcp = true; ieee->LPSDelayCnt = 200; } } - }else if (ETH_P_ARP == ether_type){ - printk("=================>DHCP Protocol start tx ARP pkt!!\n"); + } else if (ETH_P_ARP == ether_type) { + printk(KERN_INFO "=================>DHCP " + "Protocol start tx ARP pkt!!\n"); bdhcp = true; - ieee->LPSDelayCnt = ieee->current_network.tim.tim_count; - - + ieee->LPSDelayCnt = + ieee->current_network.tim.tim_count; } } @@ -656,13 +649,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; if (!encrypt && ieee->ieee802_1x && - ieee->drop_unencrypted && ether_type != ETH_P_PAE) { + ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + - sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); + sizeof(struct ethhdr) - SNAP_SIZE - + sizeof(u16)); RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", eap_get_type(eap->type)); } @@ -670,7 +664,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - /* Determine total amount of storage required for TXB packets */ + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); if (encrypt) @@ -687,10 +681,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) fc |= RTLLIB_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */ - memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr1, ieee->current_network.bssid, + ETH_ALEN); memcpy(&header.addr2, &src, ETH_ALEN); if (IsAmsdu) - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, + ieee->current_network.bssid, ETH_ALEN); else memcpy(&header.addr3, &dest, ETH_ALEN); } else if (ieee->iw_mode == IW_MODE_ADHOC) { @@ -698,12 +694,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) Addr3 = BSSID */ memcpy(&header.addr1, dest, ETH_ALEN); memcpy(&header.addr2, src, ETH_ALEN); - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, ieee->current_network.bssid, + ETH_ALEN); } - bIsMulticast = is_broadcast_ether_addr(header.addr1) ||is_multicast_ether_addr(header.addr1); + bIsMulticast = is_broadcast_ether_addr(header.addr1) || + is_multicast_ether_addr(header.addr1); - header.frame_ctl = cpu_to_le16(fc); + header.frame_ctl = cpu_to_le16(fc); /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ @@ -718,29 +716,30 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (qos_actived) { hdr_len = RTLLIB_3ADDR_LEN + 2; - /* in case we are a client verify acm is not set for this ac */ - while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { - printk("skb->priority = %x\n", skb->priority); - if (wme_downgrade_ac(skb)) { - break; - } - printk("converted skb->priority = %x\n", skb->priority); - } - qos_ctl |= skb->priority; - header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); + /* in case we are a client verify acm is not set for this ac */ + while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { + printk(KERN_INFO "skb->priority = %x\n", skb->priority); + if (wme_downgrade_ac(skb)) + break; + printk(KERN_INFO "converted skb->priority = %x\n", + skb->priority); + } + qos_ctl |= skb->priority; + header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); } else { hdr_len = RTLLIB_3ADDR_LEN; } /* Determine amount of payload per fragment. Regardless of if - * this stack is providing the full 802.11 header, one will - * eventually be affixed to this fragment -- so we must account for - * it when determining the amount of payload space. */ + * this stack is providing the full 802.11 header, one will + * eventually be affixed to this fragment -- so we must account + * for it when determining the amount of payload space. */ bytes_per_frag = frag_size - hdr_len; if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) bytes_per_frag -= RTLLIB_FCS_LEN; - /* Each fragment may need to have room for encryptiong pre/postfix */ + /* Each fragment may need to have room for encryptiong + * pre/postfix */ if (encrypt) { bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; @@ -754,10 +753,11 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) else bytes_last_frag = bytes_per_frag; - /* When we allocate the TXB we allocate enough space for the reserve - * and full fragment bytes (bytes_per_frag doesn't include prefix, - * postfix, header, FCS, etc.) */ - txb = rtllib_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC); + /* When we allocate the TXB we allocate enough space for the + * reserve and full fragment bytes (bytes_per_frag doesn't + * include prefix, postfix, header, FCS, etc.) */ + txb = rtllib_alloc_txb(nr_frags, frag_size + + ieee->tx_headroom, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -767,16 +767,15 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->payload_size = bytes; if (qos_actived) - { txb->queue_index = UP2AC(skb->priority); - } else { - txb->queue_index = WME_AC_BE;; - } + else + txb->queue_index = WME_AC_BE; for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - tcb_desc = (struct cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); - if (qos_actived){ + tcb_desc = (struct cb_desc *)(skb_frag->cb + + MAX_DEV_ADDR_SIZE); + if (qos_actived) { skb_frag->priority = skb->priority; tcb_desc->queue_index = UP2AC(skb->priority); } else { @@ -785,41 +784,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } skb_reserve(skb_frag, ieee->tx_headroom); - if (encrypt){ + if (encrypt) { if (ieee->hwsec_active) tcb_desc->bHwSec = 1; else tcb_desc->bHwSec = 0; - skb_reserve(skb_frag, crypt->ops->extra_prefix_len); + skb_reserve(skb_frag, + crypt->ops->extra_prefix_len); } else { tcb_desc->bHwSec = 0; } - frag_hdr = (struct rtllib_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtllib_hdr_3addrqos *) + skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - /* If this is not the last fragment, then add the MOREFRAGS - * bit to the frame control */ + /* If this is not the last fragment, then add the + * MOREFRAGS bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | RTLLIB_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { - /* The last fragment takes the remaining length */ + /* The last fragment has the remaining length */ bytes = bytes_last_frag; } - if ((qos_actived) && (!bIsMulticast)) - { - frag_hdr->seq_ctl = rtllib_query_seqnum(ieee, skb_frag, header.addr1); - frag_hdr->seq_ctl = cpu_to_le16(frag_hdr->seq_ctl<<4 | i); + if ((qos_actived) && (!bIsMulticast)) { + frag_hdr->seq_ctl = + rtllib_query_seqnum(ieee, skb_frag, + header.addr1); + frag_hdr->seq_ctl = + cpu_to_le16(frag_hdr->seq_ctl<<4 | i); } else { - frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); + frag_hdr->seq_ctl = + cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); } /* Put a SNAP header on the first fragment */ if (i == 0) { rtllib_put_snap( - skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), - ether_type); + skb_put(skb_frag, SNAP_SIZE + + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } @@ -828,27 +832,29 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB... */ skb_pull(skb, bytes); - /* Encryption routine will move the header forward in order - * to insert the IV between the header and the payload */ + /* Encryption routine will move the header forward in + * order to insert the IV between the header and the + * payload */ if (encrypt) - rtllib_encrypt_fragment(ieee, skb_frag, hdr_len); + rtllib_encrypt_fragment(ieee, skb_frag, + hdr_len); if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) skb_put(skb_frag, 4); } if ((qos_actived) && (!bIsMulticast)) { - if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) - ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; - else - ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; + if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) + ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; + else + ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; } else { - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; } - }else{ + } else { if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -856,7 +862,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); - if (!txb){ + if (!txb) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; @@ -864,22 +870,24 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); } success: - if (txb) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + if (txb) { + struct cb_desc *tcb_desc = (struct cb_desc *) + (txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; tcb_desc->priority = skb->priority; if (ether_type == ETH_P_PAE) { - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = ieee->basic_rate; tcb_desc->bTxDisableRateFallBack = 1; } @@ -893,17 +901,19 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (is_broadcast_ether_addr(header.addr1)) tcb_desc->bBroadcast = 1; rtllib_txrate_selectmode(ieee, tcb_desc); - if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->bMulticast || tcb_desc->bBroadcast) tcb_desc->data_rate = ieee->basic_rate; else - tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + tcb_desc->data_rate = CURRENT_RATE(ieee->mode, + ieee->rate, ieee->HTCurrentOperaRate); - if (bdhcp == true){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (bdhcp == true) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = MGN_1M; tcb_desc->bTxDisableRateFallBack = 1; } @@ -915,20 +925,22 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); - rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], + tcb_desc); rtllib_query_HTCapShortGI(ieee, tcb_desc); rtllib_query_BandwidthMode(ieee, tcb_desc); - rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); + rtllib_query_protectionmode(ieee, tcb_desc, + txb->fragments[0]); } } spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { - if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) { dev->stats.tx_packets++; dev->stats.tx_bytes += txb->payload_size; rtllib_softmac_xmit(txb, ieee); - }else{ + } else { if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; From c73901c9fded7be7fbc328be6f55c9a1a59f6d2c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 18:16:43 -0500 Subject: [PATCH 0538/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_pci.c | 21 +- drivers/staging/rtl8192e/rtl_pci.h | 6 +- drivers/staging/rtl8192e/rtllib_wx.c | 452 ++++++++++++++------------- 3 files changed, 247 insertions(+), 232 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl_pci.c index 2416db13217..ddadcc3e4e7 100644 --- a/drivers/staging/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl_pci.c @@ -25,7 +25,8 @@ #include "rtl_pci.h" #include "rtl_core.h" -static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_device *dev) +static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, + struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -37,10 +38,11 @@ static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_dev pci_read_config_byte(priv->pdev, pos + PCI_EXP_LNKCTL, &LinkCtrlReg); priv->NdisAdapter.LinkCtrlReg = LinkCtrlReg; - RT_TRACE(COMP_INIT, "Link Control Register =%x\n", priv->NdisAdapter.LinkCtrlReg); + RT_TRACE(COMP_INIT, "Link Control Register =%x\n", + priv->NdisAdapter.LinkCtrlReg); pci_read_config_byte(pdev, 0x98, &tmp); - tmp |=BIT4; + tmp |= BIT4; pci_write_config_byte(pdev, 0x98, tmp); tmp = 0x17; @@ -65,24 +67,27 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) if (DeviceID == 0x8172) { switch (RevisionID) { case HAL_HW_PCI_REVISION_ID_8192PCIE: - printk("Adapter(8192 PCI-E) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192 PCI-E) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192E; break; case HAL_HW_PCI_REVISION_ID_8192SE: - printk("Adapter(8192SE) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192SE) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192SE; break; default: - printk("UNKNOWN nic type(%4x:%4x)\n", pdev->vendor, pdev->device); + printk(KERN_INFO "UNKNOWN nic type(%4x:%4x)\n", + pdev->vendor, pdev->device); priv->card_8192 = NIC_UNKNOWN; return false; } } if (priv->ops->nic_type != priv->card_8192) { - printk("Detect info(%x) and hardware info(%x) not match!\n", + printk(KERN_INFO "Detect info(%x) and hardware info(%x) not match!\n", priv->ops->nic_type, priv->card_8192); - printk("Please select proper driver before install!!!!\n"); + printk(KERN_INFO "Please select proper driver before install!!!!\n"); return false; } diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h index b4efc7c4db0..7ea5a47dfd2 100644 --- a/drivers/staging/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -69,11 +69,11 @@ struct mp_adapter { u16 PciBridgeDeviceId; u8 PciBridgePCIeHdrOffset; u8 PciBridgeLinkCtrlReg; -};//,*pmp_adapter; +}; struct rt_pci_capab_header { - unsigned char CapabilityID; - unsigned char Next; + unsigned char CapabilityID; + unsigned char Next; }; #define PCI_MAX_BRIDGE_NUMBER 255 diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 39c6644f11b..c350f4e277d 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -40,19 +40,19 @@ struct modes_unit { int mode_size; }; static struct modes_unit rtllib_modes[] = { - {"a",1}, - {"b",1}, - {"g",1}, - {"?",1}, - {"N-24G",5}, - {"N-5G",4}, + {"a", 1}, + {"b", 1}, + {"g", 1}, + {"?", 1}, + {"N-24G", 5}, + {"N-5G", 4}, }; #define MAX_CUSTOM_LEN 64 static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, char *start, char *stop, struct rtllib_network *network, - struct iw_request_info *info) + struct iw_request_info *info) { char custom[MAX_CUSTOM_LEN]; char proto_name[IFNAMSIZ]; @@ -67,52 +67,60 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_ADDR_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_ADDR_LEN); /* Remaining entries will be displayed in the order we provide them */ /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - if (network->ssid_len > 0){ + if (network->ssid_len > 0) { iwe.u.data.length = min(network->ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); - }else if (network->hidden_ssid_len == 0){ + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->ssid); + } else if (network->hidden_ssid_len == 0) { iwe.u.data.length = sizeof(""); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, ""); - }else { + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, ""); + } else { iwe.u.data.length = min(network->hidden_ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->hidden_ssid); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->hidden_ssid); } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - for (i=0; i<(sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { + for (i = 0; i < (sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { if (network->mode&(1<capability & + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_CHAR_LEN); + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + if (network->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { if (network->capability & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN); - } + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_UINT_LEN); + } - /* Add frequency/channel */ + /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; /* iwe.u.freq.m = rtllib_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_FREQ_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; @@ -121,12 +129,13 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, network->ssid); /* Add basic and extended rates */ max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - for (i = 0, j = 0; i < network->rates_len; ) { + for (i = 0, j = 0; i < network->rates_len;) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) < (network->rates[i] & 0x7F))) @@ -146,22 +155,24 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, max_rate = rate; } - if (network->mode >= IEEE_N_24G) - { + if (network->mode >= IEEE_N_24G) { struct ht_capab_ele *ht_cap = NULL; bool is40M = false, isShortGI = false; u8 max_mcs = 0; if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4)) - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[4]; + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[4]; else - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[0]; - is40M = (ht_cap->ChlWidth)?1:0; - isShortGI = (ht_cap->ChlWidth)? - ((ht_cap->ShortGI40Mhz)?1:0): - ((ht_cap->ShortGI20Mhz)?1:0); + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[0]; + is40M = (ht_cap->ChlWidth) ? 1 : 0; + isShortGI = (ht_cap->ChlWidth) ? + ((ht_cap->ShortGI40Mhz) ? 1 : 0) : + ((ht_cap->ShortGI20Mhz) ? 1 : 0); - max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, MCS_FILTER_ALL); - rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs&0x7f]; + max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, + MCS_FILTER_ALL); + rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs & 0x7f]; if (rate > max_rate) max_rate = rate; } @@ -173,7 +184,8 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); /* Add quality statistics */ /* TODO: Fix these values... */ iwe.cmd = IWEVQUAL; @@ -188,53 +200,54 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, if (!(network->stats.mask & RTLLIB_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; iwe.u.qual.updated = 7; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_QUAL_LEN); iwe.cmd = IWEVCUSTOM; p = custom; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); memset(&iwe, 0, sizeof(iwe)); - if (network->wpa_ie_len) - { + if (network->wpa_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->wpa_ie, network->wpa_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wpa_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } memset(&iwe, 0, sizeof(iwe)); - if (network->rsn_ie_len) - { + if (network->rsn_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->rsn_ie, network->rsn_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->rsn_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* add info for WZC */ memset(&iwe, 0, sizeof(iwe)); - if (network->wzc_ie_len) - { + if (network->wzc_ie_len) { char buf[MAX_WZC_IE_LEN]; memcpy(buf, network->wzc_ie, network->wzc_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wzc_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* Add EXTRA: Age to display seconds since last beacon/probe response * for given network. */ iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), - " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); + " Last beacon: %lums ago", + (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); return start; } @@ -256,17 +269,16 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, list_for_each_entry(network, &ieee->network_list, list) { i++; - if ((stop-ev)<200) - { + if ((stop - ev) < 200) { err = -E2BIG; break; - } + } if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = rtl819x_translate_scan(ieee, ev, stop, network, info); + ev = rtl819x_translate_scan(ieee, ev, stop, network, + info); else - RTLLIB_DEBUG_SCAN( - "Not showing network '%s (" + RTLLIB_DEBUG_SCAN("Not showing network '%s (" MAC_FMT ")' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), @@ -326,7 +338,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, if (ieee->crypt[i] != NULL) { if (key_provided) break; - rtllib_crypt_delayed_deinit(ieee, &ieee->crypt[i]); + rtllib_crypt_delayed_deinit(ieee, + &ieee->crypt[i]); } } @@ -406,7 +419,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, NULL, (*crypt)->priv); if (len == 0) { /* Set a default key of all 0 */ - printk("Setting key %d to all zero.\n", + printk(KERN_INFO "Setting key %d to all zero.\n", key); RTLLIB_DEBUG_WX("Setting key %d to all zero.\n", @@ -429,7 +442,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, } done: ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); - ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; + ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : + WLAN_AUTH_SHARED_KEY; sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? @@ -501,27 +515,27 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, } int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct net_device *dev = ieee->dev; - struct iw_point *encoding = &wrqu->encoding; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - int i, idx; - int group_key = 0; - const char *alg, *module; - struct rtllib_crypto_ops *ops; - struct rtllib_crypt_data **crypt; + struct iw_point *encoding = &wrqu->encoding; + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; + int i, idx; + int group_key = 0; + const char *alg, *module; + struct rtllib_crypto_ops *ops; + struct rtllib_crypt_data **crypt; - struct rtllib_security sec = { - .flags = 0, - }; - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) { - if (idx < 1 || idx > WEP_KEYS) - return -EINVAL; - idx--; + struct rtllib_security sec = { + .flags = 0, + }; + idx = encoding->flags & IW_ENCODE_INDEX; + if (idx) { + if (idx < 1 || idx > WEP_KEYS) + return -EINVAL; + idx--; } else{ idx = ieee->tx_keyidx; } @@ -531,7 +545,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } else { /* some Cisco APs use idx>0 for unicast in dynamic WEP */ if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) - return -EINVAL; + return -EINVAL; if (ieee->iw_mode == IW_MODE_INFRA) crypt = &ieee->crypt[idx]; else @@ -540,7 +554,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, sec.flags |= SEC_ENABLED; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) { + ext->alg == IW_ENCODE_ALG_NONE) { if (*crypt) rtllib_crypt_delayed_deinit(ieee, crypt); @@ -557,108 +571,108 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } sec.enabled = 1; - switch (ext->alg) { - case IW_ENCODE_ALG_WEP: - alg = "WEP"; - module = "rtllib_crypt_wep"; - break; - case IW_ENCODE_ALG_TKIP: - alg = "TKIP"; - module = "rtllib_crypt_tkip"; - break; - case IW_ENCODE_ALG_CCMP: - alg = "CCMP"; - module = "rtllib_crypt_ccmp"; - break; - default: - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - ret = -EINVAL; - goto done; - } - printk("alg name:%s\n",alg); + switch (ext->alg) { + case IW_ENCODE_ALG_WEP: + alg = "WEP"; + module = "rtllib_crypt_wep"; + break; + case IW_ENCODE_ALG_TKIP: + alg = "TKIP"; + module = "rtllib_crypt_tkip"; + break; + case IW_ENCODE_ALG_CCMP: + alg = "CCMP"; + module = "rtllib_crypt_ccmp"; + break; + default: + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + ret = -EINVAL; + goto done; + } + printk(KERN_INFO "alg name:%s\n", alg); ops = rtllib_get_crypto_ops(alg); - if (ops == NULL) { - char tempbuf[100]; + if (ops == NULL) { + char tempbuf[100]; - memset( tempbuf, 0x00, 100 ); - sprintf( tempbuf, "%s", module); - request_module("%s",tempbuf); - ops = rtllib_get_crypto_ops(alg); - } - if (ops == NULL) { - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - printk("========>unknown crypto alg %d\n", ext->alg); - ret = -EINVAL; - goto done; - } + memset(tempbuf, 0x00, 100); + sprintf(tempbuf, "%s", module); + request_module("%s", tempbuf); + ops = rtllib_get_crypto_ops(alg); + } + if (ops == NULL) { + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + printk(KERN_INFO "========>unknown crypto alg %d\n", ext->alg); + ret = -EINVAL; + goto done; + } - if (*crypt == NULL || (*crypt)->ops != ops) { - struct rtllib_crypt_data *new_crypt; + if (*crypt == NULL || (*crypt)->ops != ops) { + struct rtllib_crypt_data *new_crypt; - rtllib_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); - new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - new_crypt->ops = ops; + new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); + if (new_crypt == NULL) { + ret = -ENOMEM; + goto done; + } + new_crypt->ops = ops; if (new_crypt->ops) - new_crypt->priv = new_crypt->ops->init(idx); + new_crypt->priv = new_crypt->ops->init(idx); - if (new_crypt->priv == NULL) { - kfree(new_crypt); - ret = -EINVAL; - goto done; - } - *crypt = new_crypt; + if (new_crypt->priv == NULL) { + kfree(new_crypt); + ret = -EINVAL; + goto done; + } + *crypt = new_crypt; } - if (ext->key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, - (*crypt)->priv) < 0) { - RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); - printk("key setting failed\n"); - ret = -EINVAL; - goto done; - } - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - ieee->tx_keyidx = idx; - sec.active_key = idx; - sec.flags |= SEC_ACTIVE_KEY; - } - if (ext->alg != IW_ENCODE_ALG_NONE) { - sec.key_sizes[idx] = ext->key_len; - sec.flags |= (1 << idx); - if (ext->alg == IW_ENCODE_ALG_WEP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - /* Don't set sec level for group keys. */ - if (group_key) - sec.flags &= ~SEC_LEVEL; - } + if (ext->key_len > 0 && (*crypt)->ops->set_key && + (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, + (*crypt)->priv) < 0) { + RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); + printk(KERN_INFO "key setting failed\n"); + ret = -EINVAL; + goto done; + } + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { + ieee->tx_keyidx = idx; + sec.active_key = idx; + sec.flags |= SEC_ACTIVE_KEY; + } + if (ext->alg != IW_ENCODE_ALG_NONE) { + sec.key_sizes[idx] = ext->key_len; + sec.flags |= (1 << idx); + if (ext->alg == IW_ENCODE_ALG_WEP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } else if (ext->alg == IW_ENCODE_ALG_TKIP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_2; + } else if (ext->alg == IW_ENCODE_ALG_CCMP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_3; + } + /* Don't set sec level for group keys. */ + if (group_key) + sec.flags &= ~SEC_LEVEL; + } done: - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(dev)) { - RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); - return -EINVAL; - } - return ret; + ieee->iw_mode != IW_MODE_INFRA && + ieee->reset_port && ieee->reset_port(dev)) { + RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); + return -EINVAL; + } + return ret; } int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, @@ -692,12 +706,12 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); - if (crypt == NULL || crypt->ops == NULL ) { + if (crypt == NULL || crypt->ops == NULL) { ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; encoding->flags |= IW_ENCODE_DISABLED; } else { - if (strcmp(crypt->ops->name, "WEP") == 0 ) + if (strcmp(crypt->ops->name, "WEP") == 0) ext->alg = IW_ENCODE_ALG_WEP; else if (strcmp(crypt->ops->name, "TKIP")) ext->alg = IW_ENCODE_ALG_TKIP; @@ -705,7 +719,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, ext->alg = IW_ENCODE_ALG_CCMP; else return -EINVAL; - ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, NULL, crypt->priv); + ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, + NULL, crypt->priv); encoding->flags |= IW_ENCODE_ENABLED; if (ext->key_len && (ext->alg == IW_ENCODE_ALG_TKIP || @@ -718,8 +733,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, } int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { u8 i = 0; bool deauth = false; @@ -731,28 +746,28 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, down(&ieee->wx_sem); switch (mlme->cmd) { - case IW_MLME_DEAUTH: - deauth = true; - /* leave break out intentionly */ + case IW_MLME_DEAUTH: + deauth = true; + /* leave break out intentionly */ - case IW_MLME_DISASSOC: - if (deauth == true) - printk("disauth packet !\n"); - else - printk("dis associate packet!\n"); + case IW_MLME_DISASSOC: + if (deauth == true) + printk(KERN_INFO "disauth packet !\n"); + else + printk(KERN_INFO "dis associate packet!\n"); - ieee->cannot_notify = true; + ieee->cannot_notify = true; - SendDisassociation(ieee,deauth,mlme->reason_code); - rtllib_disassociate(ieee); + SendDisassociation(ieee, deauth, mlme->reason_code); + rtllib_disassociate(ieee); - ieee->wap_set = 0; - for (i = 0; i < 6; i++) - ieee->current_network.bssid[i]= 0x55; + ieee->wap_set = 0; + for (i = 0; i < 6; i++) + ieee->current_network.bssid[i] = 0x55; - ieee->ssid_set = 0; - ieee->current_network.ssid[0] = '\0'; - ieee->current_network.ssid_len = 0; + ieee->ssid_set = 0; + ieee->current_network.ssid[0] = '\0'; + ieee->current_network.ssid_len = 0; break; default: up(&ieee->wx_sem); @@ -765,56 +780,53 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, } int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra) + struct iw_request_info *info, + struct iw_param *data, char *extra) { switch (data->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: + case IW_AUTH_WPA_VERSION: break; - case IW_AUTH_CIPHER_PAIRWISE: - case IW_AUTH_CIPHER_GROUP: - case IW_AUTH_KEY_MGMT: + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: /* * Host AP driver does not use these parameters and allows * wpa_supplicant to control them internally. */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures = data->value; - break; - case IW_AUTH_DROP_UNENCRYPTED: - ieee->drop_unencrypted = data->value; + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + ieee->tkip_countermeasures = data->value; + break; + case IW_AUTH_DROP_UNENCRYPTED: + ieee->drop_unencrypted = data->value; break; case IW_AUTH_80211_AUTH_ALG: - if (data->value & IW_AUTH_ALG_SHARED_KEY){ + if (data->value & IW_AUTH_ALG_SHARED_KEY) { ieee->open_wep = 0; ieee->auth_mode = 1; - } - else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM){ + } else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM) { ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (data->value & IW_AUTH_ALG_LEAP){ + } else if (data->value & IW_AUTH_ALG_LEAP) { ieee->open_wep = 1; ieee->auth_mode = 2; - } - else + } else return -EINVAL; break; case IW_AUTH_WPA_ENABLED: - ieee->wpa_enabled = (data->value)?1:0; + ieee->wpa_enabled = (data->value) ? 1 : 0; break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: - ieee->ieee802_1x = data->value; + ieee->ieee802_1x = data->value; break; case IW_AUTH_PRIVACY_INVOKED: ieee->privacy_invoked = data->value; break; default: - return -EOPNOTSUPP; + return -EOPNOTSUPP; } return 0; } @@ -822,17 +834,18 @@ int rtllib_wx_set_auth(struct rtllib_device *ieee, int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) { u8 *buf; - u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { + if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) return -EINVAL; - } if (len) { eid = ie[0]; - if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) { + if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], + wps_oui, 4))) { - ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len):(MAX_WZC_IE_LEN); + ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) : + (MAX_WZC_IE_LEN); buf = kmalloc(ieee->wps_ie_len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -842,13 +855,11 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) } } ieee->wps_ie_len = 0; - if (ieee->wps_ie) - kfree(ieee->wps_ie); + kfree(ieee->wps_ie); ieee->wps_ie = NULL; if (len) { - if (len != ie[1]+2) { + if (len != ie[1]+2) return -EINVAL; - } buf = kmalloc(len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -857,7 +868,6 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) ieee->wpa_ie = buf; ieee->wpa_ie_len = len; } else { - if (ieee->wpa_ie) kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; From 8bd890a41f66b4b3f8494a9c91bface5a0b8cbe3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 22:00:11 -0500 Subject: [PATCH 0539/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVIII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_pm.c | 120 +++-- drivers/staging/rtl8192e/rtl_pm.h | 8 +- drivers/staging/rtl8192e/rtl_ps.c | 182 ++++---- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtl_wx.c | 748 ++++++++++++++---------------- drivers/staging/rtl8192e/rtl_wx.h | 2 +- 6 files changed, 506 insertions(+), 556 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c index af1c8201e01..92e2fde7f5f 100644 --- a/drivers/staging/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -23,42 +23,38 @@ #include "r8190P_rtl8256.h" #include "rtl_pm.h" -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state) +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state) { - printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); - return(-EAGAIN); + printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); + return -EAGAIN; } -int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) +int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); u32 ulRegRead; - RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); - printk("============> r8192E suspend call.\n"); + printk(KERN_INFO "============> r8192E suspend call.\n"); del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of suspend function\n"); - goto out_pci_suspend; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of suspend " + "function\n"); + goto out_pci_suspend; + } -#ifdef HAVE_NET_DEVICE_OPS if (dev->netdev_ops->ndo_stop) dev->netdev_ops->ndo_stop(dev); -#else - dev->stop(dev); -#endif netif_device_detach(dev); if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT,true); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true); ulRegRead = read_nic_dword(dev, CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; + ulRegRead |= CPU_GEN_SYSTEM_RESET; write_nic_dword(dev, CPU_GEN, ulRegRead); } else { write_nic_dword(dev, WFCRC0, 0xffffffff); @@ -68,81 +64,73 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) write_nic_byte(dev, MacBlkCtrl, 0xa); } out_pci_suspend: - RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); printk("r8192E support WOL call??????????????????????\n"); - if (priv->rtllib->bSupportRemoteWakeUp) { - RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); - } + if (priv->rtllib->bSupportRemoteWakeUp) + RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!" + "!!!!!!!!!!!.\n"); pci_save_state(pdev); pci_disable_device(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev,state),\ - priv->rtllib->bSupportRemoteWakeUp?1:0); - pci_set_power_state(pdev,pci_choose_state(pdev,state)); + pci_enable_wake(pdev, pci_choose_state(pdev, state), + priv->rtllib->bSupportRemoteWakeUp ? 1 : 0); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); - mdelay(20); + mdelay(20); return 0; } -int rtl8192E_resume (struct pci_dev *pdev) +int rtl8192E_resume(struct pci_dev *pdev) { - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv = rtllib_priv(dev); - int err; - u32 val; + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv = rtllib_priv(dev); + int err; + u32 val; - RT_TRACE(COMP_POWER, "================>r8192E resume call."); - printk("================>r8192E resume call.\n"); + printk(KERN_INFO "================>r8192E resume call.\n"); - pci_set_power_state(pdev, PCI_D0); + pci_set_power_state(pdev, PCI_D0); - err = pci_enable_device(pdev); - if (err) { - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", - dev->name); - return err; - } - pci_restore_state(pdev); + err = pci_enable_device(pdev); + if (err) { + printk(KERN_ERR "%s: pci_enable_device failed on resume\n", + dev->name); + return err; + } + pci_restore_state(pdev); - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) { - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - } + pci_read_config_dword(pdev, 0x40, &val); + if ((val & 0x0000ff00) != 0) + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - pci_enable_wake(pdev, PCI_D0, 0); + pci_enable_wake(pdev, PCI_D0, 0); - if (priv->polling_timer_on == 0){ - check_rfctrl_gpio_timer((unsigned long)dev); - } + if (priv->polling_timer_on == 0) + check_rfctrl_gpio_timer((unsigned long)dev); - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of resume function\n"); - goto out; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of resume " + "function\n"); + goto out; + } - netif_device_attach(dev); -#ifdef HAVE_NET_DEVICE_OPS - if (dev->netdev_ops->ndo_open) - dev->netdev_ops->ndo_open(dev); -#else - dev->open(dev); -#endif + netif_device_attach(dev); + if (dev->netdev_ops->ndo_open) + dev->netdev_ops->ndo_open(dev); - if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT,true); - } + if (!priv->rtllib->bSupportRemoteWakeUp) + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true); out: - RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); - return 0; + RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); + return 0; } -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable) { - printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", + printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", state.event, enable); - return(-EAGAIN); + return -EAGAIN; } #endif diff --git a/drivers/staging/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl_pm.h index 22df2908181..4d7f4067cc7 100644 --- a/drivers/staging/rtl8192e/rtl_pm.h +++ b/drivers/staging/rtl8192e/rtl_pm.h @@ -25,10 +25,10 @@ #include #include -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); -int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); -int rtl8192E_resume (struct pci_dev *dev); -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state); +int rtl8192E_suspend(struct pci_dev *dev, pm_message_t state); +int rtl8192E_resume(struct pci_dev *dev); +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable); #endif diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index ea9eac71253..f39f0d340e2 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -33,44 +33,49 @@ void rtl8192_hw_sleep_down(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in progress! \n"); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in " + "progress!\n"); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); - MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS, false); } void rtl8192_hw_sleep_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_sleep_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_sleep_wq); struct net_device *dev = ieee->dev; - rtl8192_hw_sleep_down(dev); + rtl8192_hw_sleep_down(dev); } -void rtl8192_hw_wakeup(struct net_device* dev) +void rtl8192_hw_wakeup(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in progress! \n"); - queue_delayed_work_rsl(priv->rtllib->wq,&priv->rtllib->hw_wakeup_wq,MSECS(10)); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in " + "progress!\n"); + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq, MSECS(10)); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS, false); } void rtl8192_hw_wakeup_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_wakeup_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_wakeup_wq); struct net_device *dev = ieee->dev; rtl8192_hw_wakeup(dev); @@ -85,12 +90,12 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) u32 tmp; unsigned long flags; - spin_lock_irqsave(&priv->ps_lock,flags); + spin_lock_irqsave(&priv->ps_lock, flags); time -= MSECS(8+16+7); if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); printk(KERN_INFO "too short to sleep::%lld < %ld\n", time - jiffies, MSECS(MIN_SLEEP_TIME)); return; @@ -99,48 +104,48 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", time - jiffies, MSECS(MAX_SLEEP_TIME)); - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); return; } tmp = time - jiffies; queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); + &priv->rtllib->hw_wakeup_wq, tmp); queue_delayed_work_rsl(priv->rtllib->wq, - (void *)&priv->rtllib->hw_sleep_wq,0); - spin_unlock_irqrestore(&priv->ps_lock,flags); + (void *)&priv->rtllib->hw_sleep_wq, 0); + spin_unlock_irqrestore(&priv->ps_lock, flags); } void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() ---------> \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() --------->\n"); pPSC->bSwRfProcessing = true; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", \ - pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); - MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", + pPSC->eInactivePowerState == eRfOff ? "OFF" : "ON"); + MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS, + false); pPSC->bSwRfProcessing = false; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <--------- \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <---------\n"); } -void -IPSEnter(struct net_device *dev) +void IPSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState == eRfOn && !pPSC->bSwRfProcessing &&\ - (priv->rtllib->state != RTLLIB_LINKED)&&\ - (priv->rtllib->iw_mode != IW_MODE_MASTER)) - { - RT_TRACE(COMP_PS,"IPSEnter(): Turn off RF.\n"); + if (rtState == eRfOn && !pPSC->bSwRfProcessing && + (priv->rtllib->state != RTLLIB_LINKED) && + (priv->rtllib->iw_mode != IW_MODE_MASTER)) { + RT_TRACE(COMP_PS, "IPSEnter(): Turn off RF.\n"); pPSC->eInactivePowerState = eRfOff; priv->isRFOff = true; priv->bInPowerSaveMode = true; @@ -149,18 +154,17 @@ IPSEnter(struct net_device *dev) } } -void -IPSLeave(struct net_device *dev) +void IPSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) - { + if (rtState != eRfOn && !pPSC->bSwRfProcessing && + priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) { RT_TRACE(COMP_PS, "IPSLeave(): Turn on RF.\n"); pPSC->eInactivePowerState = eRfOn; priv->bInPowerSaveMode = false; @@ -168,9 +172,11 @@ IPSLeave(struct net_device *dev) } } } + void IPSLeave_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data,struct rtllib_device,ips_leave_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, ips_leave_wq); struct net_device *dev = ieee->dev; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); down(&priv->rtllib->ips_sem); @@ -184,20 +190,22 @@ void rtllib_ips_leave_wq(struct net_device *dev) enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return; - } - else{ - printk("=========>%s(): IPSLeave\n",__func__); - queue_work_rsl(priv->rtllib->wq,&priv->rtllib->ips_leave_wq); + } else { + printk(KERN_INFO "=========>%s(): IPSLeave\n", + __func__); + queue_work_rsl(priv->rtllib->wq, + &priv->rtllib->ips_leave_wq); } } } } + void rtllib_ips_leave(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -213,38 +221,42 @@ bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) if (priv->rtllib->iw_mode == IW_MODE_ADHOC) return false; - RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__func__,rtPsMode); - if (!priv->ps_force) { + RT_TRACE(COMP_LPS, "%s(): set ieee->ps = %x\n", __func__, rtPsMode); + if (!priv->ps_force) priv->rtllib->ps = rtPsMode; - } - if (priv->rtllib->sta_sleep != LPS_IS_WAKE && rtPsMode == RTLLIB_PS_DISABLED) { - unsigned long flags; + if (priv->rtllib->sta_sleep != LPS_IS_WAKE && + rtPsMode == RTLLIB_PS_DISABLED) { + unsigned long flags; rtl8192_hw_wakeup(dev); priv->rtllib->sta_sleep = LPS_IS_WAKE; - spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); + spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); RT_TRACE(COMP_DBG, "LPS leave: notify AP we are awaked" " ++++++++++ SendNullFunctionData\n"); rtllib_sta_ps_send_null_frame(priv->rtllib, 0); - spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); + spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); } return true; } - void LeisurePSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSEnter()...\n"); - RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", - pPSC->bLeisurePs, priv->rtllib->ps,pPSC->LpsIdleCount,RT_CHECK_FOR_HANG_PERIOD); + RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdle" + "Count is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", + pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount, + RT_CHECK_FOR_HANG_PERIOD); - if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) - || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || (priv->rtllib->iw_mode == IW_MODE_MASTER)) + if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && + (priv->rtllib->state == RTLLIB_LINKED)) + || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || + (priv->rtllib->iw_mode == IW_MODE_MASTER)) return; if (pPSC->bLeisurePs) { @@ -252,44 +264,46 @@ void LeisurePSEnter(struct net_device *dev) if (priv->rtllib->ps == RTLLIB_PS_DISABLED) { - RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter 802.11 power save mode...\n"); + RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter " + "802.11 power save mode...\n"); if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_ENTER); + priv->rtllib->SetFwCmdHandler( + dev, FW_CMD_LPS_ENTER); } - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_MBCAST | + RTLLIB_PS_UNICAST); } } else pPSC->LpsIdleCount++; } } - void LeisurePSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSLeave()...\n"); RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d\n", pPSC->bLeisurePs, priv->rtllib->ps); - if (pPSC->bLeisurePs) - { - if (priv->rtllib->ps != RTLLIB_PS_DISABLED) - { - RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n"); - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_DISABLED); + if (pPSC->bLeisurePs) { + if (priv->rtllib->ps != RTLLIB_PS_DISABLED) { + RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , " + "Leave 802.11 power save..\n"); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_DISABLED); - if (!pPSC->bFwCtrlLPS) - { + if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_LEAVE); - } - } + priv->rtllib->SetFwCmdHandler(dev, + FW_CMD_LPS_LEAVE); + } } } } diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index 453df2cbb3d..a9c2d799c08 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -36,7 +36,7 @@ void rtl8192_hw_wakeup(struct net_device *dev); void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); -void IPSLeave_wq (void *data); +void IPSLeave_wq(void *data); void IPSEnter(struct net_device *dev); void IPSLeave(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index bc096c096cf..f869ce3dbec 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,14 +22,14 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - +u32 rtl8192_rates[] = { + 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, + 18000000, 24000000, 36000000, 48000000, 54000000 +}; #ifndef ENETDOWN #define ENETDOWN 1 #endif -extern int hwwep; static int r8192_wx_get_freq(struct net_device *dev, struct iw_request_info *a, @@ -37,16 +37,16 @@ static int r8192_wx_get_freq(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_freq(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8192_priv *priv=rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_mode(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_rate(struct net_device *dev, @@ -54,7 +54,7 @@ static int r8192_wx_get_rate(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rate(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra); } @@ -71,7 +71,7 @@ static int r8192_wx_set_rate(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rate(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -91,7 +91,7 @@ static int r8192_wx_set_rts(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rts(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -103,7 +103,7 @@ static int r8192_wx_get_rts(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rts(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_power(struct net_device *dev, @@ -113,13 +113,14 @@ static int r8192_wx_set_power(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff == true){ - RT_TRACE(COMP_ERR,"%s():Hw is Radio Off, we can't set Power,return\n",__func__); + if (priv->bHwRadioOff == true) { + RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set " + "Power,return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_power(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -131,12 +132,12 @@ static int r8192_wx_get_power(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_power(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -162,7 +163,8 @@ static int r8192_wx_force_reset(struct net_device *dev, down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", __func__, *extra); + RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", + __func__, *extra); priv->force_reset = *extra; up(&priv->wx_sem); return 0; @@ -174,11 +176,11 @@ static int r8192_wx_force_mic_error(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force mic error ! \n", __func__); + RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__); ieee->force_mic_error = true; up(&priv->wx_sem); return 0; @@ -197,8 +199,8 @@ struct adhoc_peers_info { }; int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -216,12 +218,14 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); - struct rtllib_device* ieee = priv->rtllib; + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_POWER, "%s(): %s\n",__func__, (*extra == 6)?"DC power":"AC power"); + RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ? + "DC power" : "AC power"); if (*extra || priv->force_lps) { priv->ps_force = false; pPSC->bLeisurePs = true; @@ -240,40 +244,41 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, } static int r8192se_wx_set_radio(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set radio ! extra is %d\n",__func__, *extra); - if ((*extra != 0) && (*extra != 1)) - { - RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",__func__); - return -1; - } - priv->sw_radio_on = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra); + if ((*extra != 0) && (*extra != 1)) { + RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio " + "off) or 1(radio on)\n", __func__); + return -1; + } + priv->sw_radio_on = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set lps awake interval ! extra is %d\n",__func__, *extra); - - pPSC->RegMaxLPSAwakeIntvl = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n", + __func__, *extra); + pPSC->RegMaxLPSAwakeIntvl = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_force_lps(struct net_device *dev, @@ -284,7 +289,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, down(&priv->wx_sem); - printk("%s(): force LPS ! extra is %d (1 is open 0 is close)\n",__func__, *extra); + printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is " + "close)\n", __func__, *extra); priv->force_lps = *extra; up(&priv->wx_sem); return 0; @@ -292,8 +298,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, } static int r8192_wx_set_debugflag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); u8 c = *extra; @@ -301,12 +307,12 @@ static int r8192_wx_set_debugflag(struct net_device *dev, if (priv->bHwRadioOff == true) return 0; - printk("=====>%s(), *extra:%x, debugflag:%x\n", __func__, *extra, rt_global_debug_component); - if (c > 0) { + printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__, + *extra, rt_global_debug_component); + if (c > 0) rt_global_debug_component |= (1<rtllib->eRFPowerState; down(&priv->wx_sem); - if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR - || ieee->bNetPromiscuousMode ) - { - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR || + ieee->bNetPromiscuousMode) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); up(&priv->wx_sem); return -1; } else { - printk("=========>%s(): IPSLeave\n",__func__); + printk(KERN_INFO "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -342,33 +349,32 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } } } - ret = rtllib_wx_set_mode(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); return ret; } -struct iw_range_with_scan_capa -{ - /* Informative stuff (to choose between different interface) */ - __u32 throughput; /* To give an idea... */ - /* In theory this value should be the maximum benchmarked - * TCP/IP throughput, because with most of these devices the - * bit rate is meaningless (overhead an co) to estimate how - * fast the connection will go and pick the fastest one. - * I suggest people to play with Netperf or any benchmark... - */ +struct iw_range_with_scan_capa { + /* Informative stuff (to choose between different interface) */ + __u32 throughput; /* To give an idea... */ + /* In theory this value should be the maximum benchmarked + * TCP/IP throughput, because with most of these devices the + * bit rate is meaningless (overhead an co) to estimate how + * fast the connection will go and pick the fastest one. + * I suggest people to play with Netperf or any benchmark... + */ - /* NWID (or domain id) */ - __u32 min_nwid; /* Minimal NWID we are able to set */ - __u32 max_nwid; /* Maximal NWID we are able to set */ + /* NWID (or domain id) */ + __u32 min_nwid; /* Minimal NWID we are able to set */ + __u32 max_nwid; /* Maximal NWID we are able to set */ - /* Old Frequency (backward compat - moved lower ) */ - __u16 old_num_channels; - __u8 old_num_frequency; + /* Old Frequency (backward compat - moved lower ) */ + __u16 old_num_channels; + __u8 old_num_frequency; - /* Scan capabilities */ - __u8 scan_capa; + /* Scan capabilities */ + __u8 scan_capa; }; static int rtl8192_wx_get_range(struct net_device *dev, @@ -386,8 +392,10 @@ static int rtl8192_wx_get_range(struct net_device *dev, /* ~130 Mb/s real (802.11n) */ range->throughput = 130 * 1000 * 1000; - if (priv->rf_set_sens != NULL) - range->sensitivity = priv->max_sens; /* signal level threshold range */ + if (priv->rf_set_sens != NULL) { + /* signal level threshold range */ + range->sensitivity = priv->max_sens; + } range->max_qual.qual = 100; range->max_qual.level = 0; @@ -401,9 +409,8 @@ static int rtl8192_wx_get_range(struct net_device *dev, range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES); - for (i = 0; i < range->num_bitrates; i++) { + for (i = 0; i < range->num_bitrates; i++) range->bitrate[i] = rtl8192_rates[i]; - } range->max_rts = DEFAULT_RTS_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD; @@ -421,15 +428,15 @@ static int rtl8192_wx_get_range(struct net_device *dev, for (i = 0, val = 0; i < 14; i++) { if ((priv->rtllib->active_channel_map)[i+1]) { - range->freq[val].i = i + 1; - range->freq[val].m = rtllib_wlan_frequencies[i] * 100000; + range->freq[val].i = i + 1; + range->freq[val].m = rtllib_wlan_frequencies[i] * + 100000; range->freq[val].e = 1; val++; - } else { } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; range->num_channels = val; @@ -437,7 +444,7 @@ static int rtl8192_wx_get_range(struct net_device *dev, IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; - /* Event capability (kernel + driver) */ + /* Event capability (kernel + driver) */ return 0; } @@ -446,35 +453,36 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum rt_rf_power_state rtState; int ret; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - if ((ieee->state >= RTLLIB_ASSOCIATING) && (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { + if ((ieee->state >= RTLLIB_ASSOCIATING) && + (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)) return 0; - } - if ((priv->rtllib->state == RTLLIB_LINKED) && (priv->rtllib->CntAfterLink<2)){ + if ((priv->rtllib->state == RTLLIB_LINKED) && + (priv->rtllib->CntAfterLink < 2)) return 0; - } } - if (priv->bHwRadioOff == true){ - printk("================>%s(): hwradio off\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "================>%s(): hwradio off\n", + __func__); return 0; } rtState = priv->rtllib->eRFPowerState; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { - struct iw_scan_req* req = (struct iw_scan_req*)b; - if (req->essid_len) - { + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { + struct iw_scan_req *req = (struct iw_scan_req *)b; + if (req->essid_len) { ieee->current_network.ssid_len = req->essid_len; - memcpy(ieee->current_network.ssid, req->essid, req->essid_len); + memcpy(ieee->current_network.ssid, req->essid, + req->essid_len); } } @@ -482,15 +490,18 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, priv->rtllib->FirstIe_InScan = true; - if (priv->rtllib->state != RTLLIB_LINKED){ - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS){ - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is " + "OFF.\n", __func__); up(&priv->wx_sem); return -1; - }else{ - RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",__func__); + } else { + RT_TRACE(COMP_PS, "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -499,23 +510,26 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } rtllib_stop_scan(priv->rtllib); if (priv->rtllib->LedControlHandler) - priv->rtllib->LedControlHandler(dev, LED_CTL_SITE_SURVEY); + priv->rtllib->LedControlHandler(dev, + LED_CTL_SITE_SURVEY); - if (priv->rtllib->eRFPowerState != eRfOff){ + if (priv->rtllib->eRFPowerState != eRfOff) { priv->rtllib->actscanning = true; if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_BACKUP); rtllib_start_scan_syncro(priv->rtllib, 0); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); - } + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_RESTORE); + } ret = 0; } else { priv->rtllib->actscanning = true; - ret = rtllib_wx_set_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b); } up(&priv->wx_sem); @@ -530,7 +544,8 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->bHwRadioOff == true) return 0; @@ -538,7 +553,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, down(&priv->wx_sem); - ret = rtllib_wx_get_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -552,15 +567,17 @@ static int r8192_wx_set_essid(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int ret; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } - if (priv->bHwRadioOff == true){ - printk("=========>%s():hw radio off,or Rf state is eRfOff, return\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "=========>%s():hw radio off,or Rf state is " + "eRfOff, return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_essid(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -682,12 +699,12 @@ static int r8192_wx_set_wap(struct net_device *dev, union iwreq_data *awrq, char *extra) { - int ret; struct r8192_priv *priv = rtllib_priv(dev); - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } if (priv->bHwRadioOff == true) @@ -695,7 +712,7 @@ static int r8192_wx_set_wap(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_wap(priv->rtllib,info,awrq,extra); + ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra); up(&priv->wx_sem); @@ -710,7 +727,7 @@ static int r8192_wx_get_wap(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_wap(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra); } @@ -731,87 +748,91 @@ static int r8192_wx_set_enc(struct net_device *dev, int ret; struct rtllib_device *ieee = priv->rtllib; - u32 hwkey[4]={0,0,0,0}; - u8 mask=0xff; - u32 key_idx=0; - u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x02}, - {0x00,0x00,0x00,0x00,0x00,0x03} }; + u32 hwkey[4] = {0, 0, 0, 0}; + u8 mask = 0xff; + u32 key_idx = 0; + u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; - } + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) + ; /* TODO - get rid of if */ if (priv->bHwRadioOff == true) return 0; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); down(&priv->wx_sem); RT_TRACE(COMP_SEC, "Setting SW wep key"); - ret = rtllib_wx_set_encode(priv->rtllib,info,wrqu,key); + ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key); up(&priv->wx_sem); if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - if (wrqu->encoding.length!=0){ + if (wrqu->encoding.length != 0) { - for (i=0 ; i<4 ; i++){ + for (i = 0; i < 4; i++) { hwkey[i] |= key[4*i+0]&mask; - if (i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; - if (i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; - hwkey[i] |= (key[4*i+1]&mask)<<8; - hwkey[i] |= (key[4*i+2]&mask)<<16; - hwkey[i] |= (key[4*i+3]&mask)<<24; + if (i == 1 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + if (i == 3 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + hwkey[i] |= (key[4 * i + 1] & mask) << 8; + hwkey[i] |= (key[4 * i + 2] & mask) << 16; + hwkey[i] |= (key[4 * i + 3] & mask) << 24; } #define CONF_WEP40 0x4 #define CONF_WEP104 0x14 - switch (wrqu->encoding.flags & IW_ENCODE_INDEX){ - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; + switch (wrqu->encoding.flags & IW_ENCODE_INDEX) { + case 0: + key_idx = ieee->tx_keyidx; + break; + case 1: + key_idx = 0; + break; + case 2: + key_idx = 1; + break; + case 3: + key_idx = 2; + break; + case 4: + key_idx = 3; + break; + default: + break; } - if (wrqu->encoding.length==0x5){ + if (wrqu->encoding.length == 0x5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; EnableHWSecurityConfig8192(dev); } - else if (wrqu->encoding.length==0xd){ + else if (wrqu->encoding.length == 0xd) { ieee->pairwise_key_type = KEY_TYPE_WEP104; EnableHWSecurityConfig8192(dev); - setKey( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey); - set_swcam( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey, - 0); + setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey); + set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey, 0); } else { - printk("wrong type in WEP, not WEP40 and WEP104\n"); + printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n"); } } @@ -820,13 +841,13 @@ end_hw_sec: return ret; } - -static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ - +static int r8192_wx_set_scan_type(struct net_device *dev, + struct iw_request_info *aa, + union iwreq_data *wrqu, char *p) +{ struct r8192_priv *priv = rtllib_priv(dev); - int *parms=(int*)p; - int mode=parms[0]; + int *parms = (int *)p; + int mode = parms[0]; if (priv->bHwRadioOff == true) return 0; @@ -852,38 +873,32 @@ static int r8192_wx_set_retry(struct net_device *dev, down(&priv->wx_sem); if (wrqu->retry.flags & IW_RETRY_LIFETIME || - wrqu->retry.disabled){ + wrqu->retry.disabled) { err = -EINVAL; goto exit; } - if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ + if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) { err = -EINVAL; goto exit; } - if (wrqu->retry.value > R8192_MAX_RETRY){ - err= -EINVAL; + if (wrqu->retry.value > R8192_MAX_RETRY) { + err = -EINVAL; goto exit; } if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; - DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for RTS/CTS data to %d", + wrqu->retry.value); - }else { + } else { priv->retry_data = wrqu->retry.value; - DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for non RTS/CTS data to %d", + wrqu->retry.value); } rtl8192_commit(dev); - /* - if (priv->up){ - rtl8180_halt_adapter(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - } - */ exit: up(&priv->wx_sem); @@ -910,14 +925,12 @@ static int r8192_wx_get_retry(struct net_device *dev, wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN; wrqu->retry.value = priv->retry_data; } - - return 0; } static int r8192_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_set_sens == NULL) @@ -941,13 +954,13 @@ static int r8192_wx_set_sens(struct net_device *dev, down(&priv->wx_sem); if (priv->rf_set_sens == NULL) { - err= -1; /* we have not this support for this radio */ + err = -1; /* we have not this support for this radio */ goto exit; } if (priv->rf_set_sens(dev, wrqu->sens.value) == 0) priv->sens = wrqu->sens.value; else - err= -EINVAL; + err = -EINVAL; exit: up(&priv->wx_sem); @@ -956,130 +969,90 @@ exit: } static int r8192_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (priv->bHwRadioOff == true) return 0; down(&priv->wx_sem); - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra); - { - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero[6] = {0}; u32 key[4] = {0}; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_point *encoding = &wrqu->encoding; u8 idx = 0, alg = 0, group = 0; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) - { - ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; + ext->alg == IW_ENCODE_ALG_NONE) { + ieee->pairwise_key_type = ieee->group_key_type + = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; + alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP : + ext->alg; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) - idx --; + idx--; group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; - if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) - { - if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) + if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || + (alg == KEY_TYPE_WEP40)) { + if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40)) alg = KEY_TYPE_WEP104; ieee->pairwise_key_type = alg; EnableHWSecurityConfig8192(dev); } - memcpy((u8*)key, ext->key, 16); + memcpy((u8 *)key, ext->key, 16); - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) - { + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) { if (ext->key_len == 13) ieee->pairwise_key_type = alg = KEY_TYPE_WEP104; - setKey( dev, - idx, - idx, - alg, - zero, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - zero, - 0, - key, - 0); - } - else if (group) - { + setKey(dev, idx, idx, alg, zero, 0, key); + set_swcam(dev, idx, idx, alg, zero, 0, key, 0); + } else if (group) { ieee->group_key_type = alg; - setKey( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key, - 0); - } - else - { - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } - setKey( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key); - set_swcam( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key, - 0); + setKey(dev, idx, idx, alg, broadcast_addr, 0, key); + set_swcam(dev, idx, idx, alg, broadcast_addr, 0, + key, 0); + } else { + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && + ieee->pHTInfo->bCurrentHTSupport) + write_nic_byte(dev, 0x173, 1); + setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key); + set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key, 0); } } end_hw_sec: - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; up(&priv->wx_sem); return ret; } static int r8192_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1093,11 +1066,11 @@ static int r8192_wx_set_auth(struct net_device *dev, } static int r8192_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1111,71 +1084,69 @@ static int r8192_wx_set_mlme(struct net_device *dev, } static int r8192_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); if (priv->bHwRadioOff == true) return 0; - down(&priv->wx_sem); - ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); - up(&priv->wx_sem); - return ret; + down(&priv->wx_sem); + ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); + up(&priv->wx_sem); + return ret; } static int r8192_wx_get_gen_ie(struct net_device *dev, - struct iw_request_info *info, + struct iw_request_info *info, union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { data->data.length = 0; return 0; } - if (data->data.length < ieee->wpa_ie_len) { + if (data->data.length < ieee->wpa_ie_len) return -E2BIG; - } data->data.length = ieee->wpa_ie_len; memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); - return ret; + return ret; } #define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6 static int r8192_wx_set_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - u32 *info_buf = (u32*)(wrqu->data.pointer); + u32 *info_buf = (u32 *)(wrqu->data.pointer); u32 oid = info_buf[0]; u32 bPromiscuousOn = info_buf[1]; u32 bFilterSourceStationFrame = info_buf[2]; - if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) - { + if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) { ieee->IntelPromiscuousModeInfo.bPromiscuousOn = - (bPromiscuousOn)? (true) : (false); + (bPromiscuousOn) ? (true) : (false); ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame = - (bFilterSourceStationFrame)? (true) : (false); + (bFilterSourceStationFrame) ? (true) : (false); + (bPromiscuousOn) ? + (rtllib_EnableIntelPromiscuousMode(dev, false)) : + (rtllib_DisableIntelPromiscuousMode(dev, false)); - (bPromiscuousOn) ? (rtllib_EnableIntelPromiscuousMode(dev, false)) : - (rtllib_DisableIntelPromiscuousMode(dev, false)); - - printk("=======>%s(), on = %d, filter src sta = %d\n", __func__, - bPromiscuousOn, bFilterSourceStationFrame); + printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n", + __func__, bPromiscuousOn, bFilterSourceStationFrame); } else { return -1; } @@ -1185,56 +1156,55 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev, static int r8192_wx_get_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - down(&priv->wx_sem); + down(&priv->wx_sem); - snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",\ - ieee->IntelPromiscuousModeInfo.bPromiscuousOn,\ - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); - wrqu->data.length = strlen(extra) + 1; + snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d", + ieee->IntelPromiscuousModeInfo.bPromiscuousOn, + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); + wrqu->data.length = strlen(extra) + 1; - up(&priv->wx_sem); + up(&priv->wx_sem); return 0; } #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] -static iw_handler r8192_wx_handlers[] = -{ - IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, - IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, - IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, - IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, - IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, - IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, - IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, - IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, - IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, - IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, - IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, - IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, - IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, - IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, - IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, +static iw_handler r8192_wx_handlers[] = { + IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, + IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, + IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, + IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, + IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick, - IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, - IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, - IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, - IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, - IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, - IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, - IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, - IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, - IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, - IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, - IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, - IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, + IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, + IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, + IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, + IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, @@ -1251,69 +1221,47 @@ static const struct iw_priv_args r8192_private_args[] = { { SIOCIWFIRSTPRIV + 0x0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag" - }, - { + }, { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - }, - { + }, { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x3, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x5, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1, "firm_ver" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "set_power" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x9, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "radio" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xa, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_interv" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xb, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_force" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xc, 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x16, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" - } - , - { + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" + }, { SIOCIWFIRSTPRIV + 0x17, - 0,IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" } }; @@ -1347,14 +1295,13 @@ static iw_handler r8192_private_handler[] = { struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - struct iw_statistics* wstats = &priv->wstats; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + struct iw_statistics *wstats = &priv->wstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if (ieee->state < RTLLIB_LINKED) - { + if (ieee->state < RTLLIB_LINKED) { wstats->qual.qual = 10; wstats->qual.level = 0; wstats->qual.noise = -100; @@ -1362,7 +1309,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } - tmp_level = (&ieee->current_network)->stats.rssi; + tmp_level = (&ieee->current_network)->stats.rssi; tmp_qual = (&ieee->current_network)->stats.signal; tmp_noise = (&ieee->current_network)->stats.noise; @@ -1373,12 +1320,13 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } -struct iw_handler_def r8192_wx_handlers_def={ +struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), .private = r8192_private_handler, .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), + .num_private_args = sizeof(r8192_private_args) / + sizeof(struct iw_priv_args), .get_wireless_stats = r8192_get_wireless_stats, .private_args = (struct iw_priv_args *)r8192_private_args, }; diff --git a/drivers/staging/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl_wx.h index 94d42a82211..6a51a25ec87 100644 --- a/drivers/staging/rtl8192e/rtl_wx.h +++ b/drivers/staging/rtl8192e/rtl_wx.h @@ -26,6 +26,6 @@ struct iw_statistics; extern struct iw_handler_def r8192_wx_handlers_def; struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); -u16 rtl8192_11n_user_show_rates(struct net_device* dev); +u16 rtl8192_11n_user_show_rates(struct net_device *dev); #endif From ac513a88a072b23452ca96a86f18ba8b9c0d85cd Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:11 -0500 Subject: [PATCH 0540/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part I Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8190P_def.h | 68 ++++---- drivers/staging/rtl8192e/r8190P_rtl8256.c | 186 ++++++++++++-------- drivers/staging/rtl8192e/r8190P_rtl8256.h | 11 +- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 196 +++++++++------------- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 45 ++--- drivers/staging/rtl8192e/r8192E_dev.c | 20 +-- 6 files changed, 276 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 2355766bb32..b7bb71fa9ec 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -39,7 +39,7 @@ enum rtl819x_loopback { #define RESET_DELAY_8185 20 -#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) +#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) #define DESC90_RATE1M 0x00 #define DESC90_RATE2M 0x01 @@ -85,7 +85,7 @@ enum rtl819x_loopback { #define BT_QA_BOARD 1 #define BT_FPGA 2 -#define Rx_Smooth_Factor 20 +#define RX_SMOOTH 20 #define QSLT_BK 0x1 #define QSLT_BE 0x0 @@ -130,7 +130,7 @@ enum rtl819x_loopback { enum version_8190_loopback { - VERSION_8190_BD=0x3, + VERSION_8190_BD = 0x3, VERSION_8190_BE }; @@ -139,9 +139,9 @@ enum version_8190_loopback { #define IC_VersionCut_E 0x4 enum rf_optype { - RF_OP_By_SW_3wire = 0, - RF_OP_By_FW, - RF_OP_MAX + RF_OP_By_SW_3wire = 0, + RF_OP_By_FW, + RF_OP_MAX }; @@ -303,41 +303,41 @@ struct phy_sts_cck_819xpci { #define PHY_Beacon_RSSI_SLID_WIN_MAX 10 struct tx_desc { - u16 PktSize; - u8 Offset; - u8 Reserved1:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; + u16 PktSize; + u8 Offset; + u8 Reserved1:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; - u8 TxFWInfoSize; - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Resv:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; + u8 TxFWInfoSize; + u8 RATid:3; + u8 DISFB:1; + u8 USERATE:1; + u8 MOREFRAG:1; + u8 NoEnc:1; + u8 PIFS:1; + u8 QueueSelect:5; + u8 NoACM:1; + u8 Resv:2; + u8 SecCAMID:5; + u8 SecDescAssign:1; + u8 SecType:2; - u16 TxBufferSize; - u8 PktId:7; - u8 Resv1:1; - u8 Reserved2; + u16 TxBufferSize; + u8 PktId:7; + u8 Resv1:1; + u8 Reserved2; u32 TxBuffAddr; u32 NextDescAddress; - u32 Reserved5; - u32 Reserved6; - u32 Reserved7; + u32 Reserved5; + u32 Reserved6; + u32 Reserved7; }; diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index e8bef59a798..0da56c80f08 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -22,41 +22,59 @@ #include "r8192E_phy.h" #include "r8190P_rtl8256.h" -void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth) +void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth) { u8 eRFPath; struct r8192_priv *priv = rtllib_priv(dev); - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = 0; eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: - if (priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x100); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3d7); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x021); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x100); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3d7); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x021); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; case HT_CHANNEL_WIDTH_20_40: - if (priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x300); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3ff); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x0e1); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x300); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3ff); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x0e1); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; default: - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown " + "Bandwidth: %#X\n", Bandwidth); break; } @@ -64,7 +82,7 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandw return; } -bool PHY_RF8256_Config(struct net_device* dev) +bool PHY_RF8256_Config(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -74,7 +92,7 @@ bool PHY_RF8256_Config(struct net_device* dev) return rtStatus; } -bool phy_RF8256_Config_ParaFile(struct net_device* dev) +bool phy_RF8256_Config_ParaFile(struct net_device *dev) { u32 u4RegValue = 0; u8 eRFPath; @@ -87,7 +105,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; - for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; + eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; @@ -97,11 +116,13 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV<<16); break; } @@ -109,14 +130,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireAddressLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireDataLength, 0x0); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, + bMask12Bits, 0xbf); - rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path)eRFPath); - if (rtStatus!= true) { - RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); + rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, + (enum rf90_radio_path)eRFPath); + if (rtStatus != true) { + RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check " + "Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -124,34 +150,61 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) RF3_Final_Value = 0; switch (eRFPath) { case RF90_PATH_A: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; @@ -160,16 +213,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, + u4RegValue); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, + u4RegValue); break; } if (ret) { - RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); + RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():" + "Radio[%d] Fail!!", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -183,18 +239,17 @@ phy_RF8256_Config_ParaFile_Fail: return false; } -void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel) { - u32 TxAGC=0; + u32 TxAGC = 0; struct r8192_priv *priv = rtllib_priv(dev); TxAGC = powerlevel; - if (priv->bDynamicTxLowPower == true) - { + if (priv->bDynamicTxLowPower == true) { if (priv->CustomerID == RT_CID_819x_Netcore) - TxAGC = 0x22; - else - TxAGC += priv->CckPwEnl; + TxAGC = 0x22; + else + TxAGC += priv->CckPwEnl; } if (TxAGC > 0x24) TxAGC = 0x24; @@ -202,7 +257,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) } -void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel) { struct r8192_priv *priv = rtllib_priv(dev); u32 writeVal, powerBase0, powerBase1, writeVal_tmp; @@ -211,13 +266,15 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) u8 byte0, byte1, byte2, byte3; powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; - powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0; + powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | + (powerBase0 << 8) | powerBase0; powerBase1 = powerlevel; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1; + powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | + (powerBase1 << 8) | powerBase1; - for (index=0; index<6; index++) - { - writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1)); + for (index = 0; index < 6; index++) { + writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + + ((index < 2) ? powerBase0 : powerBase1)); byte0 = (u8)(writeVal & 0x7f); byte1 = (u8)((writeVal & 0x7f00)>>8); byte2 = (u8)((writeVal & 0x7f0000)>>16); @@ -231,20 +288,17 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) if (byte3 > 0x24) byte3 = 0x24; - if (index == 3) - { - writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; + if (index == 3) { + writeVal_tmp = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; priv->Pwr_Track = writeVal_tmp; } if (priv->bDynamicTxHighPower == true) - { writeVal = 0x03030303; - } else - { - writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; - } + writeVal = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); } diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h index 00fe5a1bb7e..64e831d2f4e 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -21,10 +21,11 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 -extern void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth); -extern bool PHY_RF8256_Config(struct net_device* dev); -extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); -extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel); -extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel); +extern void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth); +extern bool PHY_RF8256_Config(struct net_device *dev); +extern bool phy_RF8256_Config_ParaFile(struct net_device *dev); +extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); +extern void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel); #endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index edca4d55f58..881eb1f96d2 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -29,14 +29,14 @@ u32 temp[10];\ \ memcpy(temp, Address, 40);\ - for (i = 0; i <40; i+=4)\ - printk("\r\n %08x", temp[i]);\ -}\ + for (i = 0; i < 40; i += 4)\ + printk(KERN_INFO "\r\n %08x", temp[i]);\ +} /*---------------------------Define functions---------------------------------*/ - extern bool cmpk_message_handle_tx( +extern bool cmpk_message_handle_tx( struct net_device *dev, - u8* code_virtual_address, + u8 *code_virtual_address, u32 packettype, u32 buffer_len) { @@ -53,7 +53,7 @@ struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__func__,buffer_len); + RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, buffer_len); firmware_init_param(dev); frag_threshold = pfirmware->cmdpacket_frag_thresold; @@ -63,18 +63,19 @@ bLastIniPkt = 0; } else { - frag_length =(u16)(buffer_len - frag_offset); + frag_length = (u16)(buffer_len - frag_offset); bLastIniPkt = 1; } - skb = dev_alloc_skb(frag_length + priv->rtllib->tx_headroom + 4); + skb = dev_alloc_skb(frag_length + + priv->rtllib->tx_headroom + 4); if (skb == NULL) { rt_status = false; goto Failed; } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; @@ -83,18 +84,18 @@ seg_ptr = skb_put(skb, priv->rtllib->tx_headroom); pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - memset(pTxFwInfo,0x12,8); + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + memset(pTxFwInfo, 0x12, 8); seg_ptr = skb_put(skb, frag_length); memcpy(seg_ptr, code_virtual_address, (u32)frag_length); - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); Failed: @@ -110,7 +111,8 @@ cmpk_count_txstatistic( #ifdef ENABLE_PS enum rt_rf_power_state rtState; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) return; @@ -152,10 +154,7 @@ cmpk_count_txstatistic( -static void -cmpk_handle_tx_feedback( - struct net_device *dev, - u8 * pmsg) +static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = rtllib_priv(dev); struct cmpk_txfb rx_tx_fb; /* */ @@ -163,41 +162,30 @@ cmpk_handle_tx_feedback( priv->stats.txfeedback++; - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); + memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); cmpk_count_txstatistic(dev, &rx_tx_fb); } /* cmpk_Handle_Tx_Feedback */ -void -cmdpkt_beacontimerinterrupt_819xusb( - struct net_device *dev -) +void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; - { - if ((priv->rtllib->current_network.mode == IEEE_A) || - (priv->rtllib->current_network.mode == IEEE_N_5G) || - ((priv->rtllib->current_network.mode == IEEE_N_24G) && (!priv->rtllib->pHTInfo->bCurSuppCCK))) - { - tx_rate = 60; - DMESG("send beacon frame tx rate is 6Mbpm\n"); - } - else - { - tx_rate =10; - DMESG("send beacon frame tx rate is 1Mbpm\n"); - } - + if ((priv->rtllib->current_network.mode == IEEE_A) || + (priv->rtllib->current_network.mode == IEEE_N_5G) || + ((priv->rtllib->current_network.mode == IEEE_N_24G) && + (!priv->rtllib->pHTInfo->bCurSuppCCK))) { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } else { + tx_rate = 10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); } } -static void -cmpk_handle_interrupt_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { struct cmpk_intr_sta rx_intr_status; /* */ struct r8192_priv *priv = rtllib_priv(dev); @@ -206,67 +194,55 @@ cmpk_handle_interrupt_status( rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) - { + if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } - if ( priv->rtllib->iw_mode == IW_MODE_ADHOC) - { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); + DMESG("interrupt status = 0x%x\n", + rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->rtllib->bibsscoordinator = true; priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { + } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { priv->rtllib->bibsscoordinator = false; priv->stats.txbeaconerr++; } if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - { cmdpkt_beacontimerinterrupt_819xusb(dev); - } - } - - DMESG("<---- cmpk_handle_interrupt_status()\n"); } /* cmpk_handle_interrupt_status */ -static void -cmpk_handle_query_config_rx( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { cmpk_query_cfg_t rx_query_cfg; /* */ - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); } /* cmpk_Handle_Query_Config_Rx */ -static void cmpk_count_tx_status( struct net_device *dev, - struct cmpk_tx_status *pstx_status) +static void cmpk_count_tx_status(struct net_device *dev, + struct cmpk_tx_status *pstx_status) { struct r8192_priv *priv = rtllib_priv(dev); @@ -274,12 +250,11 @@ static void cmpk_count_tx_status( struct net_device *dev, enum rt_rf_power_state rtstate; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif priv->stats.txfeedbackok += pstx_status->txok; @@ -309,68 +284,56 @@ static void cmpk_count_tx_status( struct net_device *dev, -static void -cmpk_handle_tx_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_status rx_tx_sts; /* */ - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(struct cmpk_tx_status)); + memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(struct cmpk_tx_status)); cmpk_count_tx_status(dev, &rx_tx_sts); - } - -static void -cmpk_handle_tx_rate_history( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_rahis *ptxrate; - u8 i, j; + u8 i, j; u16 length = sizeof(struct cmpk_tx_rahis); - u32 *ptemp; + u32 *ptemp; struct r8192_priv *priv = rtllib_priv(dev); #ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif ptemp = (u32 *)pmsg; - for (i = 0; i < (length/4); i++) - { + for (i = 0; i < (length / 4); i++) { u16 temp1, temp2; - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; + temp1 = ptemp[i] & 0x0000FFFF; + temp2 = ptemp[i] >> 16; + ptemp[i] = (temp1 << 16) | temp2; } ptxrate = (struct cmpk_tx_rahis *)pmsg; - if (ptxrate == NULL ) - { + if (ptxrate == NULL) return; - } - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; - if (i< 8) + if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; for (j = 0; j < 4; j++) - priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; + priv->stats.txrate.ht_mcs[j][i] += + ptxrate->ht_mcs[j][i]; } } @@ -389,8 +352,7 @@ cmpk_message_handle_rx( RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx()\n"); - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) - { + if (pstats == NULL) { /* Print error message. */ /*RT_TRACE(COMP_SEND, DebugLevel, ("\n\r[CMPK]-->Err queue id or pointer"));*/ @@ -403,43 +365,49 @@ cmpk_message_handle_rx( element_id = pcmd_buff[0]; - while (total_length > 0 || exe_cnt++ >100) - { + while (total_length > 0 || exe_cnt++ > 100) { element_id = pcmd_buff[0]; switch (element_id) { case RX_TX_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); - cmpk_handle_tx_feedback (dev, pcmd_buff); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_FEEDBACK\n"); + cmpk_handle_tx_feedback(dev, pcmd_buff); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_INTERRUPT_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_INTERRUPT_STATUS\n"); cmpk_handle_interrupt_status(dev, pcmd_buff); cmd_length = sizeof(struct cmpk_intr_sta); break; case BOTH_QUERY_CONFIG: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "BOTH_QUERY_CONFIG\n"); cmpk_handle_query_config_rx(dev, pcmd_buff); cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; break; case RX_TX_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_STATUS\n"); cmpk_handle_tx_status(dev, pcmd_buff); cmd_length = CMPK_RX_TX_STS_SIZE; break; case RX_TX_PER_PKT_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_PER_PKT_FEEDBACK\n"); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_TX_RATE_HISTORY: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_HISTORY\n"); cmpk_handle_tx_rate_history(dev, pcmd_buff); cmd_length = CMPK_TX_RAHIS_SIZE; break; default: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():unknow CMD Element\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "unknow CMD Element\n"); return 1; } diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index b55d075d6cd..23219e17e5a 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -18,16 +18,16 @@ ******************************************************************************/ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) -#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) -#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) -#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) +#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) +#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) +#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) +#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) -#define ISR_TxBcnOk BIT27 -#define ISR_TxBcnErr BIT26 -#define ISR_BcnTimerIntr BIT13 +#define ISR_TxBcnOk BIT27 +#define ISR_TxBcnErr BIT26 +#define ISR_BcnTimerIntr BIT13 struct cmpk_txfb { @@ -110,7 +110,7 @@ struct cmpk_tx_status { u16 reserve3_23; u8 reserve3_1; u8 rate; -}__packed; +} __packed; struct cmpk_rx_dbginfo { u16 reserve1; @@ -138,19 +138,22 @@ struct cmpk_tx_rahis { } __packed; enum cmpk_element { - RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, - RX_CMD_ELE_MAX + RX_TX_FEEDBACK = 0, + RX_INTERRUPT_STATUS = 1, + TX_SET_CONFIG = 2, + BOTH_QUERY_CONFIG = 3, + RX_TX_STATUS = 4, + RX_DBGINFO_FEEDBACK = 5, + RX_TX_PER_PKT_FEEDBACK = 6, + RX_TX_RATE_HISTORY = 7, + RX_CMD_ELE_MAX }; -extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); -extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); +extern u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats); +extern bool cmpk_message_handle_tx(struct net_device *dev, + u8 *codevirtualaddress, u32 packettype, + u32 buffer_len); #endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 453481959ff..aaba5586dbe 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1662,15 +1662,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; } else { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); } RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); } @@ -1708,15 +1708,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; } else { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); } rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); } @@ -1755,8 +1755,8 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; } priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); } } } From 0dd565069b21ae20f4916cf305b64268bb3f9d3f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:12 -0500 Subject: [PATCH 0541/1519] staging: rtl8192e: Modify time handling In several places, the driver keeps times (in jiffies) in two 32-bit quantities. In the rtl8192_hw_to_sleep(), there is an error in the calculation of the difference between two 64-bit quantities. Rather than fix that error, I have converted to a single 64-bit number. That makes the code be much cleaner and clearer. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 11 ++++----- drivers/staging/rtl8192e/rtl_core.h | 3 +-- drivers/staging/rtl8192e/rtl_ps.c | 27 ++++++++++------------- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 9 ++++---- drivers/staging/rtl8192e/rtllib_rx.c | 6 ++--- drivers/staging/rtl8192e/rtllib_softmac.c | 23 +++++++------------ 7 files changed, 32 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index cb1830b9f84..7d8a15c685d 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2244,13 +2244,10 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - if (stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } + if (stats->bIsAMPDU && !stats->bFirstMPDU) + stats->mac_time = priv->LastRxDescTSF; + else + priv->LastRxDescTSF = stats->mac_time; } long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 22b0a438b9d..4f94d0a18f0 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -642,8 +642,7 @@ struct r8192_priv { int rxringcount; u16 rxbuffersize; - u32 LastRxDescTSFHigh; - u32 LastRxDescTSFLow; + u64 LastRxDescTSF; u16 EarlyRxThreshold; u32 ReceiveConfig; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 58966e07be7..ea9eac71253 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data) #define MIN_SLEEP_TIME 50 #define MAX_SLEEP_TIME 10000 -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) { struct r8192_priv *priv = rtllib_priv(dev); - u32 rb = jiffies; + u32 tmp; unsigned long flags; spin_lock_irqsave(&priv->ps_lock,flags); - tl -= MSECS(8+16+7); + time -= MSECS(8+16+7); - if (((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { spin_unlock_irqrestore(&priv->ps_lock,flags); - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + printk(KERN_INFO "too short to sleep::%lld < %ld\n", + time - jiffies, MSECS(MIN_SLEEP_TIME)); return; } - if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { + printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", + time - jiffies, MSECS(MAX_SLEEP_TIME)); spin_unlock_irqrestore(&priv->ps_lock,flags); return; } - { - u32 tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); - } + tmp = time - jiffies; + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq,tmp); queue_delayed_work_rsl(priv->rtllib->wq, (void *)&priv->rtllib->hw_sleep_wq,0); spin_unlock_irqrestore(&priv->ps_lock,flags); diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index d97a6edd1e8..453df2cbb3d 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -33,7 +33,7 @@ struct net_device; #define INIT_DEFAULT_CHAN 1 void rtl8192_hw_wakeup(struct net_device *dev); -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); void IPSLeave_wq (void *data); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2ab1e6cb639..2a394ee9f75 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -993,7 +993,7 @@ struct ieee_ibss_seq { * any adverse affects. */ struct rtllib_rx_stats { #if 1 - u32 mac_time[2]; + u64 mac_time; s8 rssi; u8 signal; u8 noise; @@ -1679,7 +1679,7 @@ struct rtllib_network { struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; - u32 last_dtim_sta_time[2]; + u64 last_dtim_sta_time; u8 wmm_info; struct rtllib_wmm_ac_param wmm_param[4]; @@ -2305,8 +2305,7 @@ struct rtllib_device { int ps_timeout; int ps_period; struct tasklet_struct ps_task; - u32 ps_th; - u32 ps_tl; + u64 ps_time; bool polling; short raw_tx; @@ -2498,7 +2497,7 @@ struct rtllib_device { /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); + void (*enter_sleep_state) (struct net_device *dev, u64 time); short (*ps_is_queue_empty) (struct net_device *dev); int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 24ad9713d0b..9606bedf16d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->dtim_period = info_element->data[1]; if (ieee->state != RTLLIB_LINKED) break; - network->last_dtim_sta_time[0] = jiffies; - network->last_dtim_sta_time[1] = stats->mac_time[1]; + network->last_dtim_sta_time = jiffies; network->dtim_data = RTLLIB_DTIM_VALID; @@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst, dst->atim_window = src->atim_window; dst->dtim_period = src->dtim_period; dst->dtim_data = src->dtim_data; - dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; - dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; + dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); dst->bssht.bdSupportHT = src->bssht.bdSupportHT; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 11433c61bda..29277d18f02 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2037,7 +2037,7 @@ void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) } -short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) +static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; @@ -2074,7 +2074,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time_l){ + if (time){ if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } - *time_l = ieee->current_network.last_dtim_sta_time[0] + *time = ieee->current_network.last_dtim_sta_time + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); } } - if (time_h) { - *time_h = ieee->current_network.last_dtim_sta_time[1]; - if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) - *time_h += 1; - } - return 1; @@ -2126,7 +2120,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u32 th,tl; + u64 time; short sleep; unsigned long flags,flags2; @@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee,&th, &tl); + sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) { @@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) } if (sleep == 1){ if (ieee->sta_sleep == LPS_IS_SLEEP){ - ieee->enter_sleep_state(ieee->dev,th,tl); + ieee->enter_sleep_state(ieee->dev, time); } else if (ieee->sta_sleep == LPS_IS_WAKE){ @@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee,1); - ieee->ps_th = th; - ieee->ps_tl = tl; + ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) /* Null frame with PS bit set */ if (success){ ieee->sta_sleep = LPS_IS_SLEEP; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake From 55dc4eb35f7c191db2767c887c158a8de0e6e4f7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:13 -0500 Subject: [PATCH 0542/1519] staging: rtl8192e: Remove extraneous log message The driver logs all DHCP transactions and thus spams the logs. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_tx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index d03b5aa02cc..7ccad860182 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -632,15 +632,13 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) goto success; } - if (skb->len > 282){ + if (skb->len > 282) { if (ETH_P_IP == ether_type) { const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { - printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]); - bdhcp = true; ieee->LPSDelayCnt = 200; } From 526294770c72e92c1e14ec6c6f677cd0bab6727a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:14 -0500 Subject: [PATCH 0543/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part II Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_dev.c | 2275 +++++++++++++------------ 1 file changed, 1198 insertions(+), 1077 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index aaba5586dbe..229d6df789f 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -37,8 +37,8 @@ void rtl8192e_start_beacon(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; u16 BcnTimeCfg = 0; - u16 BcnCW = 6; - u16 BcnIFS = 0xf; + u16 BcnCW = 6; + u16 BcnIFS = 0xf; DMESG("Enabling beacon TX"); rtl8192_irq_disable(dev); @@ -63,7 +63,7 @@ void rtl8192e_update_msr(struct net_device *dev) u8 msr; enum led_ctl_mode LedAction = LED_CTL_NO_LINK; msr = read_nic_byte(dev, MSR); - msr &= ~ MSR_LINK_MASK; + msr &= ~MSR_LINK_MASK; switch (priv->rtllib->iw_mode) { case IW_MODE_INFRA: @@ -94,250 +94,246 @@ void rtl8192e_update_msr(struct net_device *dev) priv->rtllib->LedControlHandler(dev, LedAction); } -void -rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - switch (variable) + switch (variable) { + case HW_VAR_BSSID: + write_nic_dword(dev, BSSIDR, ((u32 *)(val))[0]); + write_nic_word(dev, BSSIDR+2, ((u16 *)(val+2))[0]); + break; + + case HW_VAR_MEDIA_STATUS: { + enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); + enum led_ctl_mode LedAction = LED_CTL_NO_LINK; + u8 btMsr = read_nic_byte(dev, MSR); - case HW_VAR_BSSID: - write_nic_dword(dev, BSSIDR, ((u32*)(val))[0]); - write_nic_word(dev, BSSIDR+2, ((u16*)(val+2))[0]); - break; + btMsr &= 0xfc; - case HW_VAR_MEDIA_STATUS: - { - enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); - enum led_ctl_mode LedAction = LED_CTL_NO_LINK; - u8 btMsr = read_nic_byte(dev, MSR); + switch (OpMode) { + case RT_OP_MODE_INFRASTRUCTURE: + btMsr |= MSR_INFRA; + LedAction = LED_CTL_LINK; + break; - btMsr &= 0xfc; + case RT_OP_MODE_IBSS: + btMsr |= MSR_ADHOC; + break; - switch (OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_INFRA; - LedAction = LED_CTL_LINK; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_ADHOC; - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_AP; - LedAction = LED_CTL_LINK; - break; - - default: - btMsr |= MSR_NOLINK; - break; - } - - write_nic_byte(dev, MSR, btMsr); + case RT_OP_MODE_AP: + btMsr |= MSR_AP; + LedAction = LED_CTL_LINK; + break; + default: + btMsr |= MSR_NOLINK; + break; } + + write_nic_byte(dev, MSR, btMsr); + + } + break; + + case HW_VAR_CECHK_BSSID: + { + u32 RegRCR, Type; + + Type = ((u8 *)(val))[0]; + RegRCR = read_nic_dword(dev, RCR); + priv->ReceiveConfig = RegRCR; + + if (Type == true) + RegRCR |= (RCR_CBSSID); + else if (Type == false) + RegRCR &= (~RCR_CBSSID); + + write_nic_dword(dev, RCR, RegRCR); + priv->ReceiveConfig = RegRCR; + + } + break; + + case HW_VAR_SLOT_TIME: + + priv->slot_time = val[0]; + write_nic_byte(dev, SLOT_TIME, val[0]); + break; - case HW_VAR_CECHK_BSSID: - { - u32 RegRCR, Type; + case HW_VAR_ACK_PREAMBLE: + { + u32 regTmp; + priv->short_preamble = (bool)(*(u8 *)val); + regTmp = priv->basic_rate; + if (priv->short_preamble) + regTmp |= BRSR_AckShortPmb; + write_nic_dword(dev, RRSR, regTmp); + break; + } - Type = ((u8*)(val))[0]; - RegRCR = read_nic_dword(dev,RCR); - priv->ReceiveConfig = RegRCR; + case HW_VAR_CPU_RST: + write_nic_dword(dev, CPU_GEN, ((u32 *)(val))[0]); + break; - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); + case HW_VAR_AC_PARAM: + { + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + u8 u1bAIFS; + u32 u4bAcParam; + u8 mode = priv->rtllib->mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; - write_nic_dword(dev, RCR,RegRCR); - priv->ReceiveConfig = RegRCR; + u1bAIFS = qos_parameters->aifs[pAcParam] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + dm_init_edca_turbo(dev); + + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[pAcParam])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[pAcParam])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[pAcParam])) << + AC_PARAM_ECW_MIN_OFFSET) | + (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); + + RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", + __func__, eACI, u4bAcParam); + switch (eACI) { + case AC1_BK: + write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); + break; + + case AC0_BE: + write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + break; + + case AC2_VI: + write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + break; + + case AC3_VO: + write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + break; + + default: + printk(KERN_INFO "SetHwReg8185(): invalid ACI: %d !\n", + eACI); + break; } + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, + (u8 *)(&pAcParam)); break; + } - case HW_VAR_SLOT_TIME: - { + case HW_VAR_ACM_CTRL: + { + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + union aci_aifsn *pAciAifsn = (union aci_aifsn *) & + (qos_parameters->aifs[0]); + u8 acm = pAciAifsn->f.acm; + u8 AcmCtrl = read_nic_byte(dev, AcmHwCtrl); - priv->slot_time = val[0]; - write_nic_byte(dev, SLOT_TIME, val[0]); - - } - break; - - case HW_VAR_ACK_PREAMBLE: - { - u32 regTmp = 0; - priv->short_preamble = (bool)(*(u8*)val ); - regTmp = priv->basic_rate; - if (priv->short_preamble) - regTmp |= BRSR_AckShortPmb; - write_nic_dword(dev, RRSR, regTmp); - } - break; - - case HW_VAR_CPU_RST: - write_nic_dword(dev, CPU_GEN, ((u32*)(val))[0]); - break; - - case HW_VAR_AC_PARAM: - { - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - u8 u1bAIFS; - u32 u4bAcParam; - u8 mode = priv->rtllib->mode; - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - - - u1bAIFS = qos_parameters->aifs[pAcParam] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - - dm_init_edca_turbo(dev); - - u4bAcParam = ( (((u32)(qos_parameters->tx_op_limit[pAcParam])) << AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(qos_parameters->cw_max[pAcParam])) << AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(qos_parameters->cw_min[pAcParam])) << AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET) ); - - RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", __func__,eACI, u4bAcParam); - switch (eACI) - { - case AC1_BK: - write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); - break; + RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", + __func__, eACI); + AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2) ? 0x0 : 0x1); + if (acm) { + switch (eACI) { case AC0_BE: - write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + AcmCtrl |= AcmHw_BeqEn; break; case AC2_VI: - write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + AcmCtrl |= AcmHw_ViqEn; break; case AC3_VO: - write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + AcmCtrl |= AcmHw_VoqEn; break; default: - printk("SetHwReg8185(): invalid ACI: %d !\n", eACI); + RT_TRACE(COMP_QOS, "SetHwReg8185(): [HW_VAR_" + "ACM_CTRL] acm set failed: eACI is " + "%d\n", eACI); break; } - priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, (u8*)(&pAcParam)); - } - break; + } else { + switch (eACI) { + case AC0_BE: + AcmCtrl &= (~AcmHw_BeqEn); + break; - case HW_VAR_ACM_CTRL: - { - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); - u8 acm = pAciAifsn->f.acm; - u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); + case AC2_VI: + AcmCtrl &= (~AcmHw_ViqEn); + break; - RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", __func__,eACI); - AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2)?0x0:0x1); + case AC3_VO: + AcmCtrl &= (~AcmHw_BeqEn); + break; - if (acm) - { - switch (eACI) - { - case AC0_BE: - AcmCtrl |= AcmHw_BeqEn; - break; - - case AC2_VI: - AcmCtrl |= AcmHw_ViqEn; - break; - - case AC3_VO: - AcmCtrl |= AcmHw_VoqEn; - break; - - default: - RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n", eACI ); - break; - } + default: + break; } - else - { - switch (eACI) - { - case AC0_BE: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - case AC2_VI: - AcmCtrl &= (~AcmHw_ViqEn); - break; - - case AC3_VO: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - default: - break; - } - } - - RT_TRACE( COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ); - write_nic_byte(dev, AcmHwCtrl, AcmCtrl ); } + + RT_TRACE(COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write" + " 0x%X\n", AcmCtrl); + write_nic_byte(dev, AcmHwCtrl, AcmCtrl); + break; + } + + case HW_VAR_SIFS: + write_nic_byte(dev, SIFS, val[0]); + write_nic_byte(dev, SIFS+1, val[0]); break; - case HW_VAR_SIFS: - write_nic_byte(dev, SIFS, val[0]); - write_nic_byte(dev, SIFS+1, val[0]); + case HW_VAR_RF_TIMING: + { + u8 Rf_Timing = *((u8 *)val); + write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); break; + } - case HW_VAR_RF_TIMING: - { - u8 Rf_Timing = *((u8*)val); - write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); - } - break; - - default: + default: break; } } -static void rtl8192_read_eeprom_info(struct net_device* dev) +static void rtl8192_read_eeprom_info(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 tempval; - u8 ICVer8192, ICVer8256; - u16 i,usValue, IC_Version; - u16 EEPROMId; + u8 tempval; + u8 ICVer8192, ICVer8256; + u16 i, usValue, IC_Version; + u16 EEPROMId; u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); - - EEPROMId = eprom_read(dev, 0); - if ( EEPROMId != RTL8190_EEPROM_ID ) - { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); - priv->AutoloadFailFlag=true; - } - else - { - priv->AutoloadFailFlag=false; + if (EEPROMId != RTL8190_EEPROM_ID) { + RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", + EEPROMId, RTL8190_EEPROM_ID); + priv->AutoloadFailFlag = true; + } else { + priv->AutoloadFailFlag = false; } - if (!priv->AutoloadFailFlag) - { + if (!priv->AutoloadFailFlag) { priv->eeprom_vid = eprom_read(dev, (EEPROM_VID >> 1)); priv->eeprom_did = eprom_read(dev, (EEPROM_DID >> 1)); - usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; - priv->eeprom_CustomerID = (u8)( usValue & 0xff); + usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8; + priv->eeprom_CustomerID = (u8)(usValue & 0xff); usValue = eprom_read(dev, (EEPROM_ICVersion_ChannelPlan>>1)); priv->eeprom_ChannelPlan = usValue&0xff; IC_Version = ((usValue&0xff00)>>8); @@ -346,24 +342,21 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) ICVer8256 = ((IC_Version&0xf0)>>4); RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256); - if (ICVer8192 == 0x2) - { + if (ICVer8192 == 0x2) { if (ICVer8256 == 0x5) - priv->card_8192_version= VERSION_8190_BE; + priv->card_8192_version = VERSION_8190_BE; } - switch (priv->card_8192_version) - { - case VERSION_8190_BD: - case VERSION_8190_BE: - break; - default: - priv->card_8192_version = VERSION_8190_BD; - break; + switch (priv->card_8192_version) { + case VERSION_8190_BD: + case VERSION_8190_BE: + break; + default: + priv->card_8192_version = VERSION_8190_BD; + break; } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); - } - else - { + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", + priv->card_8192_version); + } else { priv->card_8192_version = VERSION_8190_BD; priv->eeprom_vid = 0; priv->eeprom_did = 0; @@ -374,282 +367,289 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); + RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", + priv->eeprom_CustomerID); - if (!priv->AutoloadFailFlag) - { - for (i = 0; i < 6; i += 2) - { - usValue = eprom_read(dev, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); - *(u16*)(&dev->dev_addr[i]) = usValue; + if (!priv->AutoloadFailFlag) { + for (i = 0; i < 6; i += 2) { + usValue = eprom_read(dev, + (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); + *(u16 *)(&dev->dev_addr[i]) = usValue; } } else { memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); } - RT_TRACE(COMP_INIT, "Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - dev->dev_addr[0], dev->dev_addr[1], - dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); + RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", + dev->dev_addr); - if (priv->card_8192_version > VERSION_8190_BD) { + if (priv->card_8192_version > VERSION_8190_BD) priv->bTXPowerDataReadFromEEPORM = true; - } else { + else priv->bTXPowerDataReadFromEEPORM = false; - } priv->rf_type = RTL819X_DEFAULT_RF_TYPE; - if (priv->card_8192_version > VERSION_8190_BD) - { - if (!priv->AutoloadFailFlag) - { - tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; + if (priv->card_8192_version > VERSION_8190_BD) { + if (!priv->AutoloadFailFlag) { + tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff >> + 1))) & 0xff; priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; if (tempval&0x80) priv->rf_type = RF_1T2R; else priv->rf_type = RF_2T4R; - } - else - { + } else { priv->EEPROMLegacyHTTxPowerDiff = 0x04; } RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", priv->EEPROMLegacyHTTxPowerDiff); if (!priv->AutoloadFailFlag) - { - priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); - } + priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, + (EEPROM_ThermalMeter>>1))) & + 0xff00)>>8); else - { priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - } - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; + RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", + priv->EEPROMThermalMeter); + priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; - if (priv->epromtype == EEPROM_93C46) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (EEPROM_TxPwDiff_CrystalCap>>1)); + if (priv->epromtype == EEPROM_93C46) { + if (!priv->AutoloadFailFlag) { + usValue = eprom_read(dev, + (EEPROM_TxPwDiff_CrystalCap >> 1)); priv->EEPROMAntPwDiff = (usValue&0x0fff); - priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + priv->EEPROMCrystalCap = (u8)((usValue & 0xf000) + >> 12); + } else { + priv->EEPROMAntPwDiff = + EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = + EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", + priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", + priv->EEPROMCrystalCap); - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_CCK + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) = + usValue; + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelCCK[i]); + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i+1, + priv->EEPROMTxPowerLevelCCK[i+1]); } - else - { - usValue = EEPROM_Default_TxPower; + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_OFDM_24G + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i])) + = usValue; + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelOFDM24G[i]); + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i + 1, + priv->EEPROMTxPowerLevelOFDM24G[i+1]); } - *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); } - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); + if (priv->epromtype == EEPROM_93C46) { + for (i = 0; i < 14; i++) { + priv->TxPowerLevelCCK[i] = + priv->EEPROMTxPowerLevelCCK[i]; + priv->TxPowerLevelOFDM24G[i] = + priv->EEPROMTxPowerLevelOFDM24G[i]; } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); - } - } - else if (priv->epromtype== EEPROM_93C56) - { - - } - if (priv->epromtype == EEPROM_93C46) - { - for (i=0; i<14; i++) - { - priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; - } - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); - priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); - priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & + 0xf); + priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & + 0xf0)>>4); + priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & + 0xf00)>>8); priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - else if (priv->epromtype == EEPROM_93C56) - { + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); + } else if (priv->epromtype == EEPROM_93C56) { - for (i=0; i<3; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; + for (i = 0; i < 3; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[0]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[0]; } - for (i=3; i<9; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; + for (i = 3; i < 9; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[1]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[1]; } - for (i=9; i<14; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; + for (i = 9; i < 14; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[2]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[2]; } - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_A[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_C[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_C[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_C[i]); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; priv->AntennaTxPwDiff[0] = 0; priv->AntennaTxPwDiff[1] = 0; priv->AntennaTxPwDiff[2] = 0; priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); } } - if (priv->rf_type == RF_1T2R) - { + if (priv->rf_type == RF_1T2R) { + /* no matter what checkpatch says, the braces are needed */ RT_TRACE(COMP_INIT, "\n1T2R config\n"); - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { RT_TRACE(COMP_INIT, "\n2T4R config\n"); } init_rate_adaptive(dev); - - priv->rf_chip= RF_8256; + priv->rf_chip = RF_8256; if (priv->RegChannelPlan == 0xf) - { priv->ChannelPlan = priv->eeprom_ChannelPlan; - } else - { priv->ChannelPlan = priv->RegChannelPlan; - } - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) - { + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->CustomerID = RT_CID_DLINK; - } - switch (priv->eeprom_CustomerID) - { - case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; - break; - case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; - break; - case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; - break; - case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; - break; - case EEPROM_CID_TOSHIBA: - priv->CustomerID = RT_CID_TOSHIBA; - if (priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; - else - priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); - break; - case EEPROM_CID_Nettronix: - priv->ScanDelay = 100; - priv->CustomerID = RT_CID_Nettronix; - break; - case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; - break; - case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; - break; + switch (priv->eeprom_CustomerID) { + case EEPROM_CID_DEFAULT: + priv->CustomerID = RT_CID_DEFAULT; + break; + case EEPROM_CID_CAMEO: + priv->CustomerID = RT_CID_819x_CAMEO; + break; + case EEPROM_CID_RUNTOP: + priv->CustomerID = RT_CID_819x_RUNTOP; + break; + case EEPROM_CID_NetCore: + priv->CustomerID = RT_CID_819x_Netcore; + break; + case EEPROM_CID_TOSHIBA: + priv->CustomerID = RT_CID_TOSHIBA; + if (priv->eeprom_ChannelPlan&0x80) + priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + else + priv->ChannelPlan = 0x0; + RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", + priv->ChannelPlan); + break; + case EEPROM_CID_Nettronix: + priv->ScanDelay = 100; + priv->CustomerID = RT_CID_Nettronix; + break; + case EEPROM_CID_Pronet: + priv->CustomerID = RT_CID_PRONET; + break; + case EEPROM_CID_DLINK: + priv->CustomerID = RT_CID_DLINK; + break; - case EEPROM_CID_WHQL: - - - - break; - default: - break; + case EEPROM_CID_WHQL: + break; + default: + break; } if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) priv->ChannelPlan = 0; priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; else priv->rtllib->bSupportRemoteWakeUp = false; RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d \n", priv->ChannelPlan); + RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); - - return ; } -void rtl8192_get_eeprom_size(struct net_device* dev) +void rtl8192_get_eeprom_size(struct net_device *dev) { - u16 curCR = 0; + u16 curCR; struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); curCR = read_nic_dword(dev, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); - priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : EEPROM_93C46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); + RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, + curCR); + priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : + EEPROM_93C46; + RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, + priv->epromtype); rtl8192_read_eeprom_info(dev); } -static void rtl8192_hwconfig(struct net_device* dev) +static void rtl8192_hwconfig(struct net_device *dev) { u32 regRATR = 0, regRRSR = 0; u8 regBwOpMode = 0, regTmp = 0; struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_B: regBwOpMode = BW_OPMODE_20MHZ; regRATR = RATE_ALL_CCK; regRRSR = RATE_ALL_CCK; break; case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regBwOpMode = BW_OPMODE_5G | BW_OPMODE_20MHZ; regRATR = RATE_ALL_OFDM_AG; regRRSR = RATE_ALL_OFDM_AG; break; @@ -661,12 +661,14 @@ static void rtl8192_hwconfig(struct net_device* dev) case WIRELESS_MODE_AUTO: case WIRELESS_MODE_N_24G: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | + RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_5G: regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | + RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_OFDM_AG; break; default: @@ -681,9 +683,7 @@ static void rtl8192_hwconfig(struct net_device* dev) u32 ratr_value = 0; ratr_value = regRATR; if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -692,11 +692,8 @@ static void rtl8192_hwconfig(struct net_device* dev) write_nic_dword(dev, RRSR, regRRSR); write_nic_word(dev, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \ + priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - - - } bool rtl8192_adapter_start(struct net_device *dev) @@ -705,7 +702,7 @@ bool rtl8192_adapter_start(struct net_device *dev) u32 ulRegRead; bool rtStatus = true; u8 tmpvalue; - u8 ICVersion,SwitchingRegulatorOutput; + u8 ICVersion, SwitchingRegulatorOutput; bool bfirmwareok = true; u32 tmpRegA, tmpRegC, TempCCk; int i = 0; @@ -715,13 +712,12 @@ bool rtl8192_adapter_start(struct net_device *dev) priv->being_init_adapter = true; start: - rtl8192_pci_resetdescring(dev); + rtl8192_pci_resetdescring(dev); priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - write_nic_byte(dev, ANAPAR, 0x37); - mdelay(500); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + write_nic_byte(dev, ANAPAR, 0x37); + mdelay(500); + } priv->pFirmware->firmware_status = FW_STATUS_0_INIT; if (priv->RegRfOff == true) @@ -729,23 +725,19 @@ start: ulRegRead = read_nic_dword(dev, CPU_GEN); if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - { ulRegRead |= CPU_GEN_SYSTEM_RESET; - }else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) + else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) ulRegRead |= CPU_GEN_FIRMWARE_RESET; else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); - + RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)" + "\n", __func__, priv->pFirmware->firmware_status); write_nic_dword(dev, CPU_GEN, ulRegRead); - ICVersion = read_nic_byte(dev, IC_VERRSION); - if (ICVersion >= 0x4) - { + if (ICVersion >= 0x4) { SwitchingRegulatorOutput = read_nic_byte(dev, SWREGULATOR); - if (SwitchingRegulatorOutput != 0xb8) - { + if (SwitchingRegulatorOutput != 0xb8) { write_nic_byte(dev, SWREGULATOR, 0xa8); mdelay(1); write_nic_byte(dev, SWREGULATOR, 0xb8); @@ -753,64 +745,64 @@ start: } RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl8192_BBConfig(dev); - if (rtStatus != true) - { + if (rtStatus != true) { RT_TRACE(COMP_ERR, "BB Config failed\n"); return rtStatus; } - RT_TRACE(COMP_INIT,"BB Config Finished!\n"); + RT_TRACE(COMP_INIT, "BB Config Finished!\n"); priv->LoopbackMode = RTL819X_NO_LOOPBACK; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - ulRegRead = read_nic_dword(dev, CPU_GEN); - if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) - { - ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); - } - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) - { - ulRegRead |= CPU_CCK_LOOPBACK; - } - else - { - RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + ulRegRead = read_nic_dword(dev, CPU_GEN); + if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) + ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | + CPU_GEN_NO_LOOPBACK_SET); + else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK) + ulRegRead |= CPU_CCK_LOOPBACK; + else + RT_TRACE(COMP_ERR, "Serious error: wrong loopback" + " mode setting\n"); - write_nic_dword(dev, CPU_GEN, ulRegRead); + write_nic_dword(dev, CPU_GEN, ulRegRead); - udelay(500); + udelay(500); } rtl8192_hwconfig(dev); - write_nic_byte(dev, CMDR, CR_RE|CR_TE); + write_nic_byte(dev, CMDR, CR_RE | CR_TE); - write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); + write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); + write_nic_word(dev, MAC4, ((u16 *)(dev->dev_addr + 4))[0]); write_nic_dword(dev, RCR, priv->ReceiveConfig); - { - write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\ - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) - rtl8192_SetWirelessMode(dev, priv->rtllib->mode); + rtl8192_SetWirelessMode(dev, priv->rtllib->mode); CamResetAllEntry(dev); { u8 SECR_value = 0x0; @@ -823,8 +815,8 @@ start: write_nic_word(dev, BCN_INTERVAL, 100); { int i; - for (i=0; iIC_Cut= tmpvalue; + priv->IC_Cut = tmpvalue; RT_TRACE(COMP_INIT, "priv->IC_Cut= 0x%x\n", priv->IC_Cut); - if (priv->IC_Cut>= IC_VersionCut_D) - { - if (priv->IC_Cut== IC_VersionCut_D) { + if (priv->IC_Cut >= IC_VersionCut_D) { + if (priv->IC_Cut == IC_VersionCut_D) { + /* no matter what checkpatch says, braces are needed */ RT_TRACE(COMP_INIT, "D-cut\n"); - } else if (priv->IC_Cut== IC_VersionCut_E) { + } else if (priv->IC_Cut == IC_VersionCut_E) { RT_TRACE(COMP_INIT, "E-cut\n"); } } else { @@ -878,20 +870,27 @@ start: write_nic_byte(dev, 0x87, 0x0); if (priv->RegRfOff == true) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW,true); + RT_TRACE((COMP_INIT | COMP_RF | COMP_POWER), + "%s(): Turn off RF for RegRfOff ----------\n", + __func__); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW, true); } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__func__); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON\n", + __func__); priv->rtllib->eRFPowerState = eRfOn; priv->rtllib->RfOffReason = 0; - - } if (priv->rtllib->FwRWRF) @@ -899,37 +898,51 @@ start: else priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { + if (priv->ResetProgress == RESET_TYPE_NORESET) { dm_initialize_txpower_tracking(dev); - if (priv->IC_Cut>= IC_VersionCut_D) { - tmpRegA= rtl8192_QueryBBReg(dev,rOFDM0_XATxIQImbalance,bMaskDWord); - tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord); - for (i = 0; itxbbgain_table[i].txbbgain_value) { - priv->rfa_txpowertrackingindex= (u8)i; - priv->rfa_txpowertrackingindex_real= (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + if (priv->IC_Cut >= IC_VersionCut_D) { + tmpRegA = rtl8192_QueryBBReg(dev, + rOFDM0_XATxIQImbalance, bMaskDWord); + tmpRegC = rtl8192_QueryBBReg(dev, + rOFDM0_XCTxIQImbalance, bMaskDWord); + for (i = 0; i < TxBBGainTableLength; i++) { + if (tmpRegA == + priv->txbbgain_table[i].txbbgain_value) { + priv->rfa_txpowertrackingindex = (u8)i; + priv->rfa_txpowertrackingindex_real = + (u8)i; + priv->rfa_txpowertracking_default = + priv->rfa_txpowertrackingindex; break; } } - TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + TempCCk = rtl8192_QueryBBReg(dev, + rCCK0_TxFilter1, bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { - priv->CCKPresentAttentuation_20Mdefault =(u8) i; + priv->CCKPresentAttentuation_20Mdefault = (u8)i; break; } } priv->CCKPresentAttentuation_40Mdefault = 0; priv->CCKPresentAttentuation_difference = 0; - priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault; + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_initial = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_real__initial = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_difference_initial = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_initial = %d\n", + priv->CCKPresentAttentuation); priv->btxpower_tracking = false; } } @@ -951,8 +964,8 @@ void rtl8192_net_update(struct net_device *dev) rtl8192_config_rate(dev, &rate_config); priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; priv->basic_rate = rate_config &= 0x15f; - write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]); + write_nic_dword(dev, BSSIDR, ((u32 *)net->bssid)[0]); + write_nic_word(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { write_nic_word(dev, ATIMWND, 2); @@ -971,15 +984,16 @@ void rtl8192_net_update(struct net_device *dev) void rtl8192_link_change(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (!priv->up) - return; + return; if (ieee->state == RTLLIB_LINKED) { rtl8192_net_update(dev); priv->ops->update_ratr_table(dev); - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) EnableHWSecurityConfig8192(dev); } else { write_nic_byte(dev, 0x173, 0); @@ -991,8 +1005,8 @@ void rtl8192_link_change(struct net_device *dev) reg = read_nic_dword(dev, RCR); if (priv->rtllib->state == RTLLIB_LINKED) { if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn) - ; - else + ; + else priv->ReceiveConfig = reg |= RCR_CBSSID; } else priv->ReceiveConfig = reg &= ~RCR_CBSSID; @@ -1001,21 +1015,20 @@ void rtl8192_link_change(struct net_device *dev) } } -void rtl8192_AllowAllDestAddr(struct net_device* dev, - bool bAllowAllDA, bool WriteIntoReg) +void rtl8192_AllowAllDestAddr(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - if (bAllowAllDA) - priv->ReceiveConfig |= RCR_AAP; - else - priv->ReceiveConfig &= ~RCR_AAP; + if (bAllowAllDA) + priv->ReceiveConfig |= RCR_AAP; + else + priv->ReceiveConfig &= ~RCR_AAP; - if (WriteIntoReg) - write_nic_dword( dev, RCR, priv->ReceiveConfig ); + if (WriteIntoReg) + write_nic_dword(dev, RCR, priv->ReceiveConfig); } - static u8 MRateToHwRate8190Pci(u8 rate) { u8 ret = DESC90_RATE1M; @@ -1148,138 +1161,144 @@ u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) break; default: RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection:" - " %d \n", QueueID); + " %d\n", QueueID); break; } return QueueSelect; } - -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - pTxFwInfo->TxHT = (cb_desc->data_rate&0x80)?1:0; - pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); - pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; - pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, cb_desc); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); + struct tx_fwinfo_8190pci *pTxFwInfo = NULL; + pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + pTxFwInfo->TxHT = (cb_desc->data_rate & 0x80) ? 1 : 0; + pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); + pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; + pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, + pTxFwInfo->TxRate, + cb_desc); - if (cb_desc->bAMPDUEnable) { - pTxFwInfo->AllowAggregation = 1; - pTxFwInfo->RxMF = cb_desc->ampdu_factor; - pTxFwInfo->RxAMD = cb_desc->ampdu_density; - } else { - pTxFwInfo->AllowAggregation = 0; - pTxFwInfo->RxMF = 0; - pTxFwInfo->RxAMD = 0; - } + if (cb_desc->bAMPDUEnable) { + pTxFwInfo->AllowAggregation = 1; + pTxFwInfo->RxMF = cb_desc->ampdu_factor; + pTxFwInfo->RxAMD = cb_desc->ampdu_density; + } else { + pTxFwInfo->AllowAggregation = 0; + pTxFwInfo->RxMF = 0; + pTxFwInfo->RxAMD = 0; + } - pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable)?1:0; - pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable)?1:0; - pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC)?1:0; - pTxFwInfo->RtsHT= (cb_desc->rts_rate&0x80)?1:0; - pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); - pTxFwInfo->RtsBandwidth = 0; - pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; - pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT==0)?(cb_desc->bRTSUseShortPreamble?1:0):(cb_desc->bRTSUseShortGI?1:0); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) - { - if (cb_desc->bPacketBW) - { - pTxFwInfo->TxBandwidth = 1; - pTxFwInfo->TxSubCarrier = 0; - } - else - { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = 0; - } + pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable) ? 1 : 0; + pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable) ? 1 : 0; + pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC) ? 1 : 0; + pTxFwInfo->RtsHT = (cb_desc->rts_rate&0x80) ? 1 : 0; + pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); + pTxFwInfo->RtsBandwidth = 0; + pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; + pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? + (cb_desc->bRTSUseShortPreamble ? 1 : 0) : + (cb_desc->bRTSUseShortGI ? 1 : 0); + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { + if (cb_desc->bPacketBW) { + pTxFwInfo->TxBandwidth = 1; + pTxFwInfo->TxSubCarrier = 0; + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + } + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = 0; + } - memset((u8*)pdesc,0,12); - pdesc->LINIP = 0; - pdesc->CmdInit = 1; - pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); + memset((u8 *)pdesc, 0, 12); + pdesc->LINIP = 0; + pdesc->CmdInit = 1; + pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); - pdesc->SecCAMID= 0; - pdesc->RATid = cb_desc->RATRIndex; + pdesc->SecCAMID = 0; + pdesc->RATid = cb_desc->RATRIndex; - pdesc->NoEnc = 1; - pdesc->SecType = 0x0; - if (cb_desc->bHwSec) { - static u8 tmp =0; - if (!tmp) { - RT_TRACE(COMP_DBG, "==>================hw sec\n"); - tmp = 1; - } - switch (priv->rtllib->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - pdesc->SecType = 0x1; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - pdesc->SecType = 0x2; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - pdesc->SecType = 0x3; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_NA: - pdesc->SecType = 0x0; - pdesc->NoEnc = 1; - break; - } - } + pdesc->NoEnc = 1; + pdesc->SecType = 0x0; + if (cb_desc->bHwSec) { + static u8 tmp; + if (!tmp) { + RT_TRACE(COMP_DBG, "==>================hw sec\n"); + tmp = 1; + } + switch (priv->rtllib->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + pdesc->SecType = 0x1; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_TKIP: + pdesc->SecType = 0x2; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_CCMP: + pdesc->SecType = 0x3; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_NA: + pdesc->SecType = 0x0; + pdesc->NoEnc = 1; + break; + } + } - pdesc->PktId = 0x0; + pdesc->PktId = 0x0; - pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(cb_desc->queue_index, cb_desc->priority); - pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); + pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue( + cb_desc->queue_index, + cb_desc->priority); + pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); - pdesc->DISFB = cb_desc->bTxDisableRateFallBack; - pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; + pdesc->DISFB = cb_desc->bTxDisableRateFallBack; + pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; - pdesc->FirstSeg =1; - pdesc->LastSeg = 1; - pdesc->TxBufferSize = skb->len; + pdesc->FirstSeg = 1; + pdesc->LastSeg = 1; + pdesc->TxBufferSize = skb->len; - pdesc->TxBuffAddr = cpu_to_le32(mapping); + pdesc->TxBuffAddr = cpu_to_le32(mapping); } -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff* skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); - memset(entry,0,12); - entry->LINIP = cb_desc->bLastIniPkt; - entry->FirstSeg = 1; - entry->LastSeg = 1; - if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { - entry->CmdInit = DESC_PACKET_TYPE_INIT; - } else { - struct tx_desc * entry_tmp = (struct tx_desc *)entry; - entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); - entry_tmp->QueueSelect = QSLT_CMD; - entry_tmp->TxFWInfoSize = 0x08; - entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; - } - entry->TxBufferSize = skb->len; - entry->TxBuffAddr = cpu_to_le32(mapping); - entry->OWN = 1; + memset(entry, 0, 12); + entry->LINIP = cb_desc->bLastIniPkt; + entry->FirstSeg = 1; + entry->LastSeg = 1; + if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { + entry->CmdInit = DESC_PACKET_TYPE_INIT; + } else { + struct tx_desc * entry_tmp = (struct tx_desc *)entry; + entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; + entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + entry_tmp->PktSize = (u16)(cb_desc->pkt_size + + entry_tmp->Offset); + entry_tmp->QueueSelect = QSLT_CMD; + entry_tmp->TxFWInfoSize = 0x08; + entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; + } + entry->TxBufferSize = skb->len; + entry->TxBuffAddr = cpu_to_le32(mapping); + entry->OWN = 1; } u8 HwRateToMRate90(bool bIsHT, u8 rate) @@ -1288,156 +1307,193 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) if (!bIsHT) { switch (rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; + case DESC90_RATE1M: + ret_rate = MGN_1M; + break; + case DESC90_RATE2M: + ret_rate = MGN_2M; + break; + case DESC90_RATE5_5M: + ret_rate = MGN_5_5M; + break; + case DESC90_RATE11M: + ret_rate = MGN_11M; + break; + case DESC90_RATE6M: + ret_rate = MGN_6M; + break; + case DESC90_RATE9M: + ret_rate = MGN_9M; + break; + case DESC90_RATE12M: + ret_rate = MGN_12M; + break; + case DESC90_RATE18M: + ret_rate = MGN_18M; + break; + case DESC90_RATE24M: + ret_rate = MGN_24M; + break; + case DESC90_RATE36M: + ret_rate = MGN_36M; + break; + case DESC90_RATE48M: + ret_rate = MGN_48M; + break; + case DESC90_RATE54M: + ret_rate = MGN_54M; + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported" + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } else { switch (rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + case DESC90_RATEMCS0: + ret_rate = MGN_MCS0; + break; + case DESC90_RATEMCS1: + ret_rate = MGN_MCS1; + break; + case DESC90_RATEMCS2: + ret_rate = MGN_MCS2; + break; + case DESC90_RATEMCS3: + ret_rate = MGN_MCS3; + break; + case DESC90_RATEMCS4: + ret_rate = MGN_MCS4; + break; + case DESC90_RATEMCS5: + ret_rate = MGN_MCS5; + break; + case DESC90_RATEMCS6: + ret_rate = MGN_MCS6; + break; + case DESC90_RATEMCS7: + ret_rate = MGN_MCS7; + break; + case DESC90_RATEMCS8: + ret_rate = MGN_MCS8; + break; + case DESC90_RATEMCS9: + ret_rate = MGN_MCS9; + break; + case DESC90_RATEMCS10: + ret_rate = MGN_MCS10; + break; + case DESC90_RATEMCS11: + ret_rate = MGN_MCS11; + break; + case DESC90_RATEMCS12: + ret_rate = MGN_MCS12; + break; + case DESC90_RATEMCS13: + ret_rate = MGN_MCS13; + break; + case DESC90_RATEMCS14: + ret_rate = MGN_MCS14; + break; + case DESC90_RATEMCS15: + ret_rate = MGN_MCS15; + break; + case DESC90_RATEMCS32: + ret_rate = (0x80|0x20); + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported " + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } return ret_rate; } -long -rtl8192_signal_scale_mapping(struct r8192_priv * priv, - long currsig - ) +long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; if (currsig >= 61 && currsig <= 100) - { retsig = 90 + ((currsig - 60) / 4); - } else if (currsig >= 41 && currsig <= 60) - { retsig = 78 + ((currsig - 40) / 2); - } else if (currsig >= 31 && currsig <= 40) - { retsig = 66 + (currsig - 30); - } else if (currsig >= 21 && currsig <= 30) - { retsig = 54 + (currsig - 20); - } else if (currsig >= 5 && currsig <= 20) - { retsig = 42 + (((currsig - 5) * 2) / 3); - } else if (currsig == 4) - { retsig = 36; - } else if (currsig == 3) - { retsig = 27; - } else if (currsig == 2) - { retsig = 18; - } else if (currsig == 1) - { retsig = 9; - } else - { retsig = currsig; - } return retsig; } -#define rx_hal_is_cck_rate(_pdrvinfo)\ - (_pdrvinfo->RxRate == DESC90_RATE1M ||\ +#define rx_hal_is_cck_rate(_pdrvinfo)\ + ((_pdrvinfo->RxRate == DESC90_RATE1M ||\ _pdrvinfo->RxRate == DESC90_RATE2M ||\ _pdrvinfo->RxRate == DESC90_RATE5_5M ||\ _pdrvinfo->RxRate == DESC90_RATE11M) &&\ - !_pdrvinfo->RxHT + !_pdrvinfo->RxHT) + void rtl8192_query_rxphystatus( - struct r8192_priv * priv, - struct rtllib_rx_stats * pstats, + struct r8192_priv *priv, + struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, struct rx_fwinfo *pdrvinfo, - struct rtllib_rx_stats * precord_stats, + struct rtllib_rx_stats *precord_stats, bool bpacket_match_bssid, bool bpacket_toself, bool bPacketBeacon, bool bToSelfBA ) { - struct phy_sts_ofdm_819xpci* pofdm_buf; - struct phy_sts_cck_819xpci * pcck_buf; - struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; - u8 *prxpkt; - u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all=0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi=0; - u8 is_cck_rate=0; - u8 rf_rx_num = 0; - - static u8 check_reg824 = 0; - static u32 reg824_bit9 = 0; + struct phy_sts_ofdm_819xpci *pofdm_buf; + struct phy_sts_cck_819xpci *pcck_buf; + struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc; + u8 *prxpkt; + u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all = 0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi = 0; + u8 is_cck_rate = 0; + u8 rf_rx_num = 0; + static u8 check_reg824; + static u32 reg824_bit9; priv->stats.numqry_phystatus++; - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); memset(precord_stats, 0, sizeof(struct rtllib_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = + bpacket_match_bssid; pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate; pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; - if (check_reg824 == 0) - { - reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, rFPGA0_XA_HSSIParameter2, 0x200); + if (check_reg824 == 0) { + reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, + rFPGA0_XA_HSSIParameter2, 0x200); check_reg824 = 1; } - prxpkt = (u8*)pdrvinfo; + prxpkt = (u8 *)pdrvinfo; prxpkt += sizeof(struct rx_fwinfo); @@ -1449,50 +1505,54 @@ void rtl8192_query_rxphystatus( precord_stats->RxMIMOSignalQuality[0] = -1; precord_stats->RxMIMOSignalQuality[1] = -1; - if (is_cck_rate) - { - + if (is_cck_rate) { u8 report; priv->stats.numqry_phystatusCCK++; - if (!reg824_bit9) - { + if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; report = report>>6; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x2: + rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x1: + rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x0: + rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); + break; } - } - else - { + } else { report = pcck_buf->cck_agc_rpt & 0x60; report = report>>5; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x0: - rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x2: + rx_pwr_all = -23 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x1: + rx_pwr_all = -11 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x0: + rx_pwr_all = -8 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; } } @@ -1500,15 +1560,12 @@ void rtl8192_query_rxphystatus( pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RecvSignalPower = rx_pwr_all; - if (bpacket_match_bssid) - { + if (bpacket_match_bssid) { u8 sq; - if (pstats->RxPWDBAll > 40) - { + if (pstats->RxPWDBAll > 40) { sq = 100; - }else - { + } else { sq = pcck_buf->sq_rpt; if (pcck_buf->sq_rpt > 64) @@ -1518,20 +1575,21 @@ void rtl8192_query_rxphystatus( else sq = ((64-sq) * 100) / 44; } - pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + pstats->SignalQuality = sq; + precord_stats->SignalQuality = sq; + pstats->RxMIMOSignalQuality[0] = sq; + precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = -1; + precord_stats->RxMIMOSignalQuality[1] = -1; } - } - else - { + } else { priv->stats.numqry_phystatusHT++; - for (i=RF90_PATH_A; ibrfpath_rxenable[i]) rf_rx_num++; - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * + 2) - 110; tmp_rxsnr = pofdm_buf->rxsnr_X[i]; rx_snrX = (char)(tmp_rxsnr); @@ -1542,284 +1600,294 @@ void rtl8192_query_rxphystatus( if (priv->brfpath_rxenable[i]) total_rssi += RSSI; - if (bpacket_match_bssid) - { - pstats->RxMIMOSignalStrength[i] =(u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; + if (bpacket_match_bssid) { + pstats->RxMIMOSignalStrength[i] = (u8) RSSI; + precord_stats->RxMIMOSignalStrength[i] = + (u8) RSSI; } } - rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; + rx_pwr_all = (((pofdm_buf->pwdb_all) >> 1) & 0x7f) - 106; pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RxPower = precord_stats->RxPower = rx_pwr_all; pstats->RecvSignalPower = rx_pwr_all; - if (pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && - pdrvinfo->RxRate<=DESC90_RATEMCS15) + if (pdrvinfo->RxHT && pdrvinfo->RxRate >= DESC90_RATEMCS8 && + pdrvinfo->RxRate <= DESC90_RATEMCS15) max_spatial_stream = 2; else max_spatial_stream = 1; - for (i=0; irxevm_X[i]; rx_evmX = (char)(tmp_rxevm); rx_evmX /= 2; evm = rtl819x_evm_dbtopercentage(rx_evmX); - if (bpacket_match_bssid) - { - if (i==0) - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + if (bpacket_match_bssid) { + if (i == 0) { + pstats->SignalQuality = (u8)(evm & + 0xff); + precord_stats->SignalQuality = (u8)(evm + & 0xff); + } + pstats->RxMIMOSignalQuality[i] = (u8)(evm & + 0xff); + precord_stats->RxMIMOSignalQuality[i] = (u8)(evm + & 0xff); } } rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *) + &rxsc_sgien_exflg; if (pdrvinfo->BW) priv->stats.received_bwtype[1+prxsc->rxsc]++; else priv->stats.received_bwtype[0]++; } - if (is_cck_rate) - { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)pwdb_all)); + if (is_cck_rate) { + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)pwdb_all)); - } - else - { + } else { if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)(total_rssi/=rf_rx_num))); + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)(total_rssi /= rf_rx_num))); } } -void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) +void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; - u32 nspatial_stream, tmp_val; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; - + u32 ij, tmp_val; + static u32 slide_rssi_index, slide_rssi_statistics; + static u32 slide_evm_index, slide_evm_statistics; + static u32 last_rssi, last_evm; + static u32 slide_beacon_adc_pwdb_index; + static u32 slide_beacon_adc_pwdb_statistics; + static u32 last_beacon_adc_pwdb; struct rtllib_hdr_3addr *hdr; - u16 sc ; - unsigned int frag,seq; + u16 sc; + unsigned int frag, seq; + hdr = (struct rtllib_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); - pcurrent_stats->Seq_Num = seq; - if (!pprevious_stats->bIsAMPDU) + curr_st->Seq_Num = seq; + if (!prev_st->bIsAMPDU) bcheck = true; - if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) - { + if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; priv->stats.slide_rssi_total -= last_rssi; } - priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; + priv->stats.slide_rssi_total += prev_st->SignalStrength; - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + priv->stats.slide_signal_strength[slide_rssi_index++] = + prev_st->SignalStrength; if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) slide_rssi_index = 0; tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; - priv->stats.signal_strength = rtl819x_translate_todbm(priv, (u8)tmp_val); - pcurrent_stats->rssi = priv->stats.signal_strength; - if (!pprevious_stats->bPacketMatchBSSID) - { - if (!pprevious_stats->bToSelfBA) + priv->stats.signal_strength = rtl819x_translate_todbm(priv, + (u8)tmp_val); + curr_st->rssi = priv->stats.signal_strength; + if (!prev_st->bPacketMatchBSSID) { + if (!prev_st->bToSelfBA) return; } if (!bcheck) return; - rtl819x_process_cck_rxpathsel(priv,pprevious_stats); + rtl819x_process_cck_rxpathsel(priv, prev_st); priv->stats.num_process_phyinfo++; - if (!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) - { - for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, rfpath)) + if (!prev_st->bIsCCK && prev_st->bPacketToSelf) { + for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) { + if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, + rfpath)) continue; - RT_TRACE(COMP_DBG,"Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath] = %d \n" ,pprevious_stats->RxMIMOSignalStrength[rfpath] ); - if (priv->stats.rx_rssi_percentage[rfpath] == 0) - { - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; - } - if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) - { + RT_TRACE(COMP_DBG, "Jacken -> pPreviousstats->RxMIMO" + "SignalStrength[rfpath] = %d\n", + prev_st->RxMIMOSignalStrength[rfpath]); + if (priv->stats.rx_rssi_percentage[rfpath] == 0) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); - priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; + prev_st->RxMIMOSignalStrength[rfpath]; } - else - { + if (prev_st->RxMIMOSignalStrength[rfpath] > + priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); + ((priv->stats.rx_rssi_percentage[rfpath] + * (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalStrength + [rfpath])) / (RX_SMOOTH); + priv->stats.rx_rssi_percentage[rfpath] = + priv->stats.rx_rssi_percentage[rfpath] + + 1; + } else { + priv->stats.rx_rssi_percentage[rfpath] = + ((priv->stats.rx_rssi_percentage[rfpath] * + (RX_SMOOTH-1)) + + (prev_st->RxMIMOSignalStrength[rfpath])) / + (RX_SMOOTH); } - RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); + RT_TRACE(COMP_DBG, "Jacken -> priv->RxStats.RxRSSI" + "Percentage[rfPath] = %d\n", + priv->stats.rx_rssi_percentage[rfpath]); } } - if (pprevious_stats->bPacketBeacon) - { - if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) - { - slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; + if (prev_st->bPacketBeacon) { + if (slide_beacon_adc_pwdb_statistics++ >= + PHY_Beacon_RSSI_SLID_WIN_MAX) { + slide_beacon_adc_pwdb_statistics = + PHY_Beacon_RSSI_SLID_WIN_MAX; + last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb + [slide_beacon_adc_pwdb_index]; priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; } - priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; + priv->stats.Slide_Beacon_Total += prev_st->RxPWDBAll; + priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = + prev_st->RxPWDBAll; slide_beacon_adc_pwdb_index++; if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; - if (pprevious_stats->RxPWDBAll >= 3) - pprevious_stats->RxPWDBAll -= 3; + prev_st->RxPWDBAll = priv->stats.Slide_Beacon_Total / + slide_beacon_adc_pwdb_statistics; + if (prev_st->RxPWDBAll >= 3) + prev_st->RxPWDBAll -= 3; } RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - pprevious_stats->bIsCCK? "CCK": "OFDM", - pprevious_stats->RxPWDBAll); + prev_st->bIsCCK ? "CCK" : "OFDM", + prev_st->RxPWDBAll); - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { if (priv->undecorated_smoothed_pwdb < 0) - { - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; - } - if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) - { + priv->undecorated_smoothed_pwdb = prev_st->RxPWDBAll; + if (prev_st->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); - priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; - } - else - { + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); + priv->undecorated_smoothed_pwdb + 1; + } else { + priv->undecorated_smoothed_pwdb = + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); } - rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); + rtl819x_update_rxsignalstatistics8190pci(priv, prev_st); } - if (pprevious_stats->SignalQuality == 0) - { - } - else - { - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ - if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ + if (prev_st->SignalQuality != 0) { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; - last_evm = priv->stats.slide_evm[slide_evm_index]; + last_evm = + priv->stats.slide_evm[slide_evm_index]; priv->stats.slide_evm_total -= last_evm; } - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + priv->stats.slide_evm_total += prev_st->SignalQuality; - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + priv->stats.slide_evm[slide_evm_index++] = + prev_st->SignalQuality; if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) slide_evm_index = 0; - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + tmp_val = priv->stats.slide_evm_total / + slide_evm_statistics; priv->stats.signal_quality = tmp_val; priv->stats.last_signal_strength_inpercent = tmp_val; } - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - for (nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) - { - if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) - { - if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) - { - priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; - } - priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); + if (prev_st->bPacketToSelf || + prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + for (ij = 0; ij < 2; ij++) { + if (prev_st->RxMIMOSignalQuality[ij] != -1) { + if (priv->stats.rx_evm_percentage[ij] == 0) + priv->stats.rx_evm_percentage[ij] = + prev_st->RxMIMOSignalQuality[ij]; + priv->stats.rx_evm_percentage[ij] = + ((priv->stats.rx_evm_percentage[ij] * + (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalQuality[ij])) / + (RX_SMOOTH); } } } } - } - -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, - struct sk_buff *skb, - struct rtllib_rx_stats * pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - bool bpacket_match_bssid, bpacket_toself; - bool bPacketBeacon=false; - struct rtllib_hdr_3addr *hdr; - bool bToSelfBA=false; - static struct rtllib_rx_stats previous_stats; - u16 fc,type; - - - u8* tmp_buf; - u8 *praddr; - - tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; - - hdr = (struct rtllib_hdr_3addr *)tmp_buf; - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - - bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && - (!compare_ether_addr(priv->rtllib->current_network.bssid, - (fc & RTLLIB_FCTL_TODS)? hdr->addr1 : - (fc & RTLLIB_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) - && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); - if (WLAN_FC_GET_FRAMETYPE(fc)== RTLLIB_STYPE_BEACON) - { - bPacketBeacon = true; - } - if (bpacket_match_bssid) - { - priv->stats.numpacket_matchbssid++; - } - if (bpacket_toself){ - priv->stats.numpacket_toself++; - } - rtl8192_process_phyinfo(priv, tmp_buf,&previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &previous_stats, bpacket_match_bssid, - bpacket_toself ,bPacketBeacon, bToSelfBA); - rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); -} - -void rtl8192_UpdateReceivedRateHistogramStatistics( - struct net_device *dev, - struct rtllib_rx_stats* pstats - ) +void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 rcvType=1; + bool bpacket_match_bssid, bpacket_toself; + bool bPacketBeacon = false; + struct rtllib_hdr_3addr *hdr; + bool bToSelfBA = false; + static struct rtllib_rx_stats previous_stats; + u16 fc, type; + u8 *tmp_buf; + u8 *praddr; + + tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; + + hdr = (struct rtllib_hdr_3addr *)tmp_buf; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + + bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && + (!compare_ether_addr(priv->rtllib-> + current_network.bssid, + (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : + (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) + && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); + bpacket_toself = bpacket_match_bssid & + (!compare_ether_addr(praddr, + priv->rtllib->dev->dev_addr)); + if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) + bPacketBeacon = true; + if (bpacket_match_bssid) + priv->stats.numpacket_matchbssid++; + if (bpacket_toself) + priv->stats.numpacket_toself++; + rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats); + rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, + &previous_stats, bpacket_match_bssid, + bpacket_toself, bPacketBeacon, bToSelfBA); + rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); +} + +void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, + struct rtllib_rx_stats *pstats) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 rcvType = 1; u32 rateIndex; u32 preamble_guardinterval; @@ -1833,45 +1901,104 @@ void rtl8192_UpdateReceivedRateHistogramStatistics( else preamble_guardinterval = 0; - switch (pstats->rate) - { - case MGN_1M: rateIndex = 0; break; - case MGN_2M: rateIndex = 1; break; - case MGN_5_5M: rateIndex = 2; break; - case MGN_11M: rateIndex = 3; break; - case MGN_6M: rateIndex = 4; break; - case MGN_9M: rateIndex = 5; break; - case MGN_12M: rateIndex = 6; break; - case MGN_18M: rateIndex = 7; break; - case MGN_24M: rateIndex = 8; break; - case MGN_36M: rateIndex = 9; break; - case MGN_48M: rateIndex = 10; break; - case MGN_54M: rateIndex = 11; break; - case MGN_MCS0: rateIndex = 12; break; - case MGN_MCS1: rateIndex = 13; break; - case MGN_MCS2: rateIndex = 14; break; - case MGN_MCS3: rateIndex = 15; break; - case MGN_MCS4: rateIndex = 16; break; - case MGN_MCS5: rateIndex = 17; break; - case MGN_MCS6: rateIndex = 18; break; - case MGN_MCS7: rateIndex = 19; break; - case MGN_MCS8: rateIndex = 20; break; - case MGN_MCS9: rateIndex = 21; break; - case MGN_MCS10: rateIndex = 22; break; - case MGN_MCS11: rateIndex = 23; break; - case MGN_MCS12: rateIndex = 24; break; - case MGN_MCS13: rateIndex = 25; break; - case MGN_MCS14: rateIndex = 26; break; - case MGN_MCS15: rateIndex = 27; break; - default: rateIndex = 28; break; + switch (pstats->rate) { + case MGN_1M: + rateIndex = 0; + break; + case MGN_2M: + rateIndex = 1; + break; + case MGN_5_5M: + rateIndex = 2; + break; + case MGN_11M: + rateIndex = 3; + break; + case MGN_6M: + rateIndex = 4; + break; + case MGN_9M: + rateIndex = 5; + break; + case MGN_12M: + rateIndex = 6; + break; + case MGN_18M: + rateIndex = 7; + break; + case MGN_24M: + rateIndex = 8; + break; + case MGN_36M: + rateIndex = 9; + break; + case MGN_48M: + rateIndex = 10; + break; + case MGN_54M: + rateIndex = 11; + break; + case MGN_MCS0: + rateIndex = 12; + break; + case MGN_MCS1: + rateIndex = 13; + break; + case MGN_MCS2: + rateIndex = 14; + break; + case MGN_MCS3: + rateIndex = 15; + break; + case MGN_MCS4: + rateIndex = 16; + break; + case MGN_MCS5: + rateIndex = 17; + break; + case MGN_MCS6: + rateIndex = 18; + break; + case MGN_MCS7: + rateIndex = 19; + break; + case MGN_MCS8: + rateIndex = 20; + break; + case MGN_MCS9: + rateIndex = 21; + break; + case MGN_MCS10: + rateIndex = 22; + break; + case MGN_MCS11: + rateIndex = 23; + break; + case MGN_MCS12: + rateIndex = 24; + break; + case MGN_MCS13: + rateIndex = 25; + break; + case MGN_MCS14: + rateIndex = 26; + break; + case MGN_MCS15: + rateIndex = 27; + break; + default: + rateIndex = 28; + break; } priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; priv->stats.received_rate_histogram[0][rateIndex]++; priv->stats.received_rate_histogram[rcvType][rateIndex]++; } -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats* stats, - struct rx_desc *pdesc, struct sk_buff* skb) +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1887,9 +2014,9 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->bShift = false; if (pdesc->CRC32) { - if (pdesc->Length <500) + if (pdesc->Length < 500) priv->stats.rxcrcerrmin++; - else if (pdesc->Length >1000) + else if (pdesc->Length > 1000) priv->stats.rxcrcerrmax++; else priv->stats.rxcrcerrmid++; @@ -1903,13 +2030,15 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift); - stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); + stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, + (u8)pDrvInfo->RxRate); stats->bShortPreamble = pDrvInfo->SPLCP; rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats); - stats->bIsAMPDU = (pDrvInfo->PartAggr==1); - stats->bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); + stats->bIsAMPDU = (pDrvInfo->PartAggr == 1); + stats->bFirstMPDU = (pDrvInfo->PartAggr == 1) && + (pDrvInfo->FirstAGGR == 1); stats->TimeStampLow = pDrvInfo->TSFL; stats->TimeStampHigh = read_nic_dword(dev, TSFR+4); @@ -1921,11 +2050,13 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->RxIs40MHzPacket = pDrvInfo->BW; - rtl8192_TranslateRxSignalStuff(dev,skb, stats, pdesc, pDrvInfo); + rtl8192_TranslateRxSignalStuff(dev, skb, stats, pdesc, + pDrvInfo); - if (pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); + if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1) + RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d," + " pDrvInfo->PartAggr = %d\n", + pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); skb_trim(skb, skb->len - 4/*sCrcLng*/); @@ -1948,36 +2079,24 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) OpMode = RT_OP_MODE_NO_LINK; priv->rtllib->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode); -#if 1 - if (!priv->rtllib->bSupportRemoteWakeUp) - { + if (!priv->rtllib->bSupportRemoteWakeUp) { u1bTmp = 0x0; write_nic_byte(dev, CMDR, u1bTmp); } -#else - cmd=read_nic_byte(dev,CMDR); - write_nic_byte(dev, CMDR, cmd &~ (CR_TE|CR_RE)); -#endif mdelay(20); - if (!reset) - { + if (!reset) { mdelay(150); priv->bHwRfOffAction = 2; - if (!priv->rtllib->bSupportRemoteWakeUp) - { - { - PHY_SetRtl8192eRfOff(dev); - } - ulRegRead = read_nic_dword(dev,CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; - write_nic_dword(dev,CPU_GEN, ulRegRead); - } - else - { + if (!priv->rtllib->bSupportRemoteWakeUp) { + PHY_SetRtl8192eRfOff(dev); + ulRegRead = read_nic_dword(dev, CPU_GEN); + ulRegRead |= CPU_GEN_SYSTEM_RESET; + write_nic_dword(dev, CPU_GEN, ulRegRead); + } else { write_nic_dword(dev, WFCRC0, 0xffffffff); write_nic_dword(dev, WFCRC1, 0xffffffff); write_nic_dword(dev, WFCRC2, 0xffffffff); @@ -1988,59 +2107,57 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) } } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_aggQ [i]); - } + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_aggQ[i]); skb_queue_purge(&priv->skb_queue); return; } -void rtl8192_update_ratr_table(struct net_device* dev) +void rtl8192_update_ratr_table(struct net_device *dev) { - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - u8* pMcsRate = ieee->dot11HTOperationalRateSet; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + u8 *pMcsRate = ieee->dot11HTOperationalRateSet; u32 ratr_value = 0; u8 rate_index = 0; - rtl8192_config_rate(dev, (u16*)(&ratr_value)); - ratr_value |= (*(u16*)(pMcsRate)) << 12; - switch (ieee->mode) - { - case IEEE_A: - ratr_value &= 0x00000FF0; - break; - case IEEE_B: - ratr_value &= 0x0000000F; - break; - case IEEE_G: - case IEEE_G|IEEE_B: - ratr_value &= 0x00000FF7; - break; - case IEEE_N_24G: - case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) - ratr_value &= 0x0007F007; - else{ - if (priv->rf_type == RF_1T2R) - ratr_value &= 0x000FF007; - else - ratr_value &= 0x0F81F007; - } - break; - default: - break; + rtl8192_config_rate(dev, (u16 *)(&ratr_value)); + ratr_value |= (*(u16 *)(pMcsRate)) << 12; + switch (ieee->mode) { + case IEEE_A: + ratr_value &= 0x00000FF0; + break; + case IEEE_B: + ratr_value &= 0x0000000F; + break; + case IEEE_G: + case IEEE_G|IEEE_B: + ratr_value &= 0x00000FF7; + break; + case IEEE_N_24G: + case IEEE_N_5G: + if (ieee->pHTInfo->PeerMimoPs == 0) { + ratr_value &= 0x0007F007; + } else { + if (priv->rf_type == RF_1T2R) + ratr_value &= 0x000FF007; + else + ratr_value &= 0x0F81F007; + } + break; + default: + break; } ratr_value &= 0x0FFFFFFF; - if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ + if (ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI40MHz) ratr_value |= 0x80000000; - }else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ + else if (!ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI20MHz) ratr_value |= 0x80000000; - } write_nic_dword(dev, RATR0+rate_index*4, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -2077,17 +2194,19 @@ rtl8192_InitializeVariables(struct net_device *dev) RCR_AAP | ((u32)7<irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |\ - IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |\ - IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |\ - IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + priv->irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | + IMR_BEDOK | IMR_BKDOK | IMR_HCCADOK | + IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | + IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | + IMR_RDU | IMR_RXFOVW | IMR_TXFOVW | + IMR_BcnInt | IMR_TBDOK | IMR_TBDER); priv->MidHighPwrTHR_L1 = 0x3B; priv->MidHighPwrTHR_L2 = 0x40; priv->PwrDomainProtect = false; - priv->bfirst_after_down = 0; + priv->bfirst_after_down = 0; } void rtl8192_EnableInterrupt(struct net_device *dev) @@ -2095,7 +2214,7 @@ void rtl8192_EnableInterrupt(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->irq_enabled = 1; - write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); + write_nic_dword(dev, INTA_MASK, priv->irq_mask[0]); } @@ -2103,7 +2222,7 @@ void rtl8192_DisableInterrupt(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev,INTA_MASK,0); + write_nic_dword(dev, INTA_MASK, 0); priv->irq_enabled = 0; } @@ -2118,18 +2237,21 @@ void rtl8192_ClearInterrupt(struct net_device *dev) void rtl8192_enable_rx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev, RDQDA,priv->rx_ring_dma[RX_MPDU_QUEUE]); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + write_nic_dword(dev, RDQDA, priv->rx_ring_dma[RX_MPDU_QUEUE]); } -u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +static const u32 TX_DESC_BASE[] = { + BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA +}; + void rtl8192_enable_tx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 i; - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); } @@ -2138,16 +2260,17 @@ void rtl8192_beacon_disable(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u32 reg; - reg = read_nic_dword(priv->rtllib->dev,INTA_MASK); + reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); } -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb) { - *p_inta = read_nic_dword(dev, ISR) ; - write_nic_dword(dev,ISR,*p_inta); + *p_inta = read_nic_dword(dev, ISR); + write_nic_dword(dev, ISR, *p_inta); } bool rtl8192_HalRxCheckStuck(struct net_device *dev) @@ -2155,61 +2278,56 @@ bool rtl8192_HalRxCheckStuck(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u16 RegRxCounter = read_nic_word(dev, 0x130); bool bStuck = false; - static u8 rx_chk_cnt = 0; + static u8 rx_chk_cnt; u32 SlotIndex = 0, TotalRxStuckCount = 0; u8 i; u8 SilentResetRxSoltNum = 4; - RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n", - __func__, RegRxCounter,priv->RxCounter); + RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d, RxCounter is %d\n", + __func__, RegRxCounter, priv->RxCounter); rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) - { + if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { rx_chk_cnt = 0; - } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5)) && - (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) || - ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)))) { - if (rx_chk_cnt < 2) { + } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5)) + && (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) + || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M)))) { + if (rx_chk_cnt < 2) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M))) && priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { - if (rx_chk_cnt < 4) { + if (rx_chk_cnt < 4) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else { - if (rx_chk_cnt < 8) { + if (rx_chk_cnt < 8) return bStuck; - } else { + else rx_chk_cnt = 0; - } } SlotIndex = (priv->SilentResetRxSlotIndex++)%SilentResetRxSoltNum; - if (priv->RxCounter==RegRxCounter) - { + if (priv->RxCounter == RegRxCounter) { priv->SilentResetRxStuckEvent[SlotIndex] = 1; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) + for (i = 0; i < SilentResetRxSoltNum; i++) TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; - if (TotalRxStuckCount == SilentResetRxSoltNum) - { - bStuck = true; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) - TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + if (TotalRxStuckCount == SilentResetRxSoltNum) { + bStuck = true; + for (i = 0; i < SilentResetRxSoltNum; i++) + TotalRxStuckCount += + priv->SilentResetRxStuckEvent[i]; } @@ -2226,10 +2344,10 @@ bool rtl8192_HalTxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool bStuck = false; - u16 RegTxCounter = read_nic_word(dev, 0x128); + u16 RegTxCounter = read_nic_word(dev, 0x128); RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", - __func__,RegTxCounter,priv->TxCounter); + __func__, RegTxCounter, priv->TxCounter); if (priv->TxCounter == RegTxCounter) bStuck = true; @@ -2244,18 +2362,19 @@ bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP | + SEC_ALG_TKIP))) { return false; } else { return true; } } -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev) { - bool Reval; - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + bool Reval; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->bHalfWirelessN24GMode == true) Reval = true; @@ -2269,8 +2388,9 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) { u8 tmp_Short; - tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); - if (TxHT==1 && TxRate != DESC90_RATEMCS15) + tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : + ((tcb_desc->bUseShortPreamble) ? 1 : 0); + if (TxHT == 1 && TxRate != DESC90_RATEMCS15) tmp_Short = 0; return tmp_Short; @@ -2278,12 +2398,12 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) void ActUpdateChannelAccessSetting( - struct net_device* dev, + struct net_device *dev, enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting ) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); return; @@ -2295,7 +2415,8 @@ ActUpdateChannelAccessSetting( else SIFS_Timer = priv->SifsTime; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SIFS, (u8*)&SIFS_Timer); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_SIFS, + (u8 *)&SIFS_Timer); } } From 11632a0eed310190187e12786750ae8ce2e4bca4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:15 -0500 Subject: [PATCH 0544/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part III Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_dev.h | 30 +- drivers/staging/rtl8192e/r8192E_firmware.c | 154 +-- drivers/staging/rtl8192e/r8192E_firmware.h | 4 +- drivers/staging/rtl8192e/r8192E_hw.h | 76 +- drivers/staging/rtl8192e/r8192E_hwimg.c | 1043 ++++++++++---------- 5 files changed, 667 insertions(+), 640 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 4f31307c1fa..b9b3b52f912 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -28,11 +28,12 @@ #include "r8190P_def.h" u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc); -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev); +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev); bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev); bool rtl8192_HalTxCheckStuck(struct net_device *dev); bool rtl8192_HalRxCheckStuck(struct net_device *dev); -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb); +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb); void rtl8192_enable_rx(struct net_device *dev); void rtl8192_enable_tx(struct net_device *dev); void rtl8192_EnableInterrupt(struct net_device *dev); @@ -40,17 +41,22 @@ void rtl8192_DisableInterrupt(struct net_device *dev); void rtl8192_ClearInterrupt(struct net_device *dev); void rtl8192_InitializeVariables(struct net_device *dev); void rtl8192e_start_beacon(struct net_device *dev); -void rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val); -void rtl8192_get_eeprom_size(struct net_device* dev); +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val); +void rtl8192_get_eeprom_size(struct net_device *dev); bool rtl8192_adapter_start(struct net_device *dev); void rtl8192_link_change(struct net_device *dev); -void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, - struct sk_buff* skb); -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb); -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, - struct rx_desc *pdesc, struct sk_buff* skb); +void rtl8192_AllowAllDestAddr(struct net_device *dev, bool bAllowAllDA, + bool WriteIntoReg); +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, + struct sk_buff *skb); +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff *skb); +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); void rtl8192_halt_adapter(struct net_device *dev, bool reset); -void rtl8192_update_ratr_table(struct net_device* dev); +void rtl8192_update_ratr_table(struct net_device *dev); #endif diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index d284d422b64..c2689993530 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -28,10 +28,12 @@ extern void firmware_init_param(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; - pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); + pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD( + MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) +bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -59,46 +61,48 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff } skb = dev_alloc_skb(frag_length + 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastIniPkt; seg_ptr = skb->data; - for (i=0 ; i < frag_length; i+=4) { - *seg_ptr++ = ((i+0)txbuf_size= (u16)i; + tcb_desc->txbuf_size = (u16)i; skb_put(skb, i); - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE, "===================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) || + (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================> tx " + "full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ + [tcb_desc->queue_index], skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); return rt_status; } -bool -fwSendNullPacket( - struct net_device *dev, - u32 Length -) +bool fwSendNullPacket(struct net_device *dev, u32 Length) { bool rtStatus = true; struct r8192_priv *priv = rtllib_priv(dev); @@ -108,23 +112,25 @@ fwSendNullPacket( bool bLastInitPacket = false; - skb = dev_alloc_skb(Length+ 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + skb = dev_alloc_skb(Length + 4); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastInitPacket; ptr_buf = skb_put(skb, Length); - memset(ptr_buf,0,Length); - tcb_desc->txbuf_size= (u16)Length; + memset(ptr_buf, 0, Length); + tcb_desc->txbuf_size = (u16)Length; - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"===================NULL packet================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> + queue_index])) || (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" + "========> tx full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], + skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } write_nic_byte(dev, TPPoll, TPPoll_CQ); @@ -142,7 +148,7 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status & CPU_GEN_PUT_CODE_OK) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) { @@ -153,7 +159,8 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) } CPU_status = read_nic_dword(dev, CPU_GEN); - write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); + write_nic_byte(dev, CPU_GEN, + (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); mdelay(1); timeout = jiffies + MSECS(200); @@ -161,14 +168,13 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_BOOT_RDY) break; - msleep(2); + mdelay(2); } - if (!(CPU_status&CPU_GEN_BOOT_RDY)) { + if (!(CPU_status&CPU_GEN_BOOT_RDY)) goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - } else { + else RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); - } return rt_status; @@ -190,7 +196,7 @@ bool CPUcheck_firmware_ready(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_FIRM_RDY) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_FIRM_RDY)) @@ -207,7 +213,8 @@ CPUCheckFirmwareReady_Fail: } -inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) +static bool firmware_check_ready(struct net_device *dev, + u8 load_fw_status) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -222,11 +229,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; rt_status = CPUcheck_maincodeok_turnonCPU(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnonCPU fail!\n"); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnon" + "CPU fail!\n"); break; @@ -235,11 +242,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu mdelay(1); rt_status = CPUcheck_firmware_ready(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_5_READY; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail" + "(%d)!\n", rt_status); break; default: @@ -273,53 +280,64 @@ bool init_firmware(struct net_device *dev) RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); - if (pfirmware->firmware_status == FW_STATUS_0_INIT ) { + if (pfirmware->firmware_status == FW_STATUS_0_INIT) { rst_opt = OPT_SYSTEM_RESET; starting_state = FW_INIT_STEP0_BOOT; - }else if (pfirmware->firmware_status == FW_STATUS_5_READY) { + } else if (pfirmware->firmware_status == FW_STATUS_5_READY) { rst_opt = OPT_FIRMWARE_RESET; starting_state = FW_INIT_STEP2_DATA; - }else { - RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n"); + } else { + RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined" + " firmware state\n"); } priv->firmware_source = FW_SOURCE_IMG_FILE; - for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { + for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; + init_step++) { if (rst_opt == OPT_SYSTEM_RESET) { switch (priv->firmware_source) { case FW_SOURCE_IMG_FILE: { if (pfirmware->firmware_buf_size[init_step] == 0) { const char *fw_name[3] = { "RTL8192E/boot.img", - "RTL8192E/main.img", - "RTL8192E/data.img" - }; + "RTL8192E/main.img", + "RTL8192E/data.img" + }; const struct firmware *fw_entry; int rc; - rc = request_firmware(&fw_entry, fw_name[init_step],&priv->pdev->dev); - if (rc < 0 ) { - RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); + rc = request_firmware(&fw_entry, + fw_name[init_step], &priv->pdev->dev); + if (rc < 0) { + RT_TRACE(COMP_FIRMWARE, "request firm" + "ware fail!\n"); goto download_firmware_fail; } - if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, "img file size exceed the container struct buffer fail!\n"); + if (fw_entry->size > + sizeof(pfirmware->firmware_buf[init_step])) { + RT_TRACE(COMP_FIRMWARE, "img file size " + "exceed the container struct " + "buffer fail!\n"); goto download_firmware_fail; } if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size; + memcpy(pfirmware->firmware_buf[init_step], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size; } else { - memset(pfirmware->firmware_buf[init_step],0,128); - memcpy(&pfirmware->firmware_buf[init_step][128],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size+128; + memset(pfirmware->firmware_buf[init_step], + 0, 128); + memcpy(&pfirmware->firmware_buf[init_step][128], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size + 128; } - if (rst_opt == OPT_SYSTEM_RESET) { + if (rst_opt == OPT_SYSTEM_RESET) release_firmware(fw_entry); - } } mapped_file = pfirmware->firmware_buf[init_step]; file_length = pfirmware->firmware_buf_size[init_step]; @@ -344,7 +362,7 @@ bool init_firmware(struct net_device *dev) file_length = pfirmware->firmware_buf_size[init_step]; } - rt_status = fw_download_code(dev,mapped_file,file_length); + rt_status = fw_download_code(dev, mapped_file, file_length); if (rt_status != true) { goto download_firmware_fail; } diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index c7d4c994a29..caa87883310 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -21,7 +21,7 @@ #define RTL8190_CPU_START_OFFSET 0x80 -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8) enum firmware_init_step { FW_INIT_STEP0_BOOT = 0, @@ -63,7 +63,7 @@ struct rt_firmware { u16 cmdpacket_frag_thresold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 #define MAX_FW_INIT_STEP 3 - u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; + u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; u16 firmware_buf_size[MAX_FW_INIT_STEP]; }; diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 9a3c4084faf..43c3fb859d1 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -109,7 +109,7 @@ enum _RTL8192Pci_HW { #define MULRW_SHIFT 3 #define MXDMA2_RX_SHIFT 4 #define MXDMA2_TX_SHIFT 0 - PMR = 0x00c, + PMR = 0x00c, EPROM_CMD = 0x00e, #define EPROM_CMD_RESERVED_MASK BIT5 #define EPROM_CMD_9356SEL BIT4 @@ -141,7 +141,8 @@ enum _RTL8192Pci_HW { SIFS = 0x03E, TCR = 0x040, RCR = 0x044, -#define RCR_FILTER_MASK (BIT0|BIT1|BIT2|BIT3|BIT5|BIT12|BIT18|BIT19|BIT20|BIT21|BIT22|BIT23) +#define RCR_FILTER_MASK (BIT0 | BIT1 | BIT2 | BIT3 | BIT5 | BIT12 | \ + BIT18 | BIT19 | BIT20 | BIT21 | BIT22 | BIT23) #define RCR_ONLYERLPKT BIT31 #define RCR_ENCS2 BIT30 #define RCR_ENCS1 BIT29 @@ -337,9 +338,9 @@ enum _RTL8192Pci_HW { NHM_RPI_COUNTER5 = 0x269, NHM_RPI_COUNTER6 = 0x26A, NHM_RPI_COUNTER7 = 0x26B, - WFCRC0 = 0x2f0, - WFCRC1 = 0x2f4, - WFCRC2 = 0x2f8, + WFCRC0 = 0x2f0, + WFCRC1 = 0x2f4, + WFCRC2 = 0x2f8, BW_OPMODE = 0x300, #define BW_OPMODE_11J BIT0 @@ -365,32 +366,32 @@ enum _RTL8192Pci_HW { #define RETRY_LIMIT_LONG_SHIFT 0 TSFR = 0x308, RRSR = 0x310, -#define RRSR_RSC_OFFSET 21 +#define RRSR_RSC_OFFSET 21 #define RRSR_SHORT_OFFSET 23 #define RRSR_RSC_DUPLICATE 0x600000 #define RRSR_RSC_UPSUBCHNL 0x400000 -#define RRSR_RSC_LOWSUBCHNL 0x200000 -#define RRSR_SHORT 0x800000 -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 +#define RRSR_RSC_LOWSUBCHNL 0x200000 +#define RRSR_SHORT 0x800000 +#define RRSR_1M BIT0 +#define RRSR_2M BIT1 +#define RRSR_5_5M BIT2 +#define RRSR_11M BIT3 +#define RRSR_6M BIT4 +#define RRSR_9M BIT5 +#define RRSR_12M BIT6 +#define RRSR_18M BIT7 +#define RRSR_24M BIT8 +#define RRSR_36M BIT9 +#define RRSR_48M BIT10 +#define RRSR_54M BIT11 +#define RRSR_MCS0 BIT12 +#define RRSR_MCS1 BIT13 +#define RRSR_MCS2 BIT14 +#define RRSR_MCS3 BIT15 +#define RRSR_MCS4 BIT16 +#define RRSR_MCS5 BIT17 +#define RRSR_MCS6 BIT18 +#define RRSR_MCS7 BIT19 #define BRSR_AckShortPmb BIT23 UFWP = 0x318, RATR0 = 0x320, @@ -422,12 +423,15 @@ enum _RTL8192Pci_HW { #define RATR_MCS13 0x02000000 #define RATR_MCS14 0x04000000 #define RATR_MCS15 0x08000000 -#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M -#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|RATR_36M|RATR_48M|RATR_54M -#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 | \ - RATR_MCS4|RATR_MCS5|RATR_MCS6 |RATR_MCS7 -#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11| \ - RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15 +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | \ + RATR_MCS6 | RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ + RATR_MCS14|RATR_MCS15) DRIVER_RSSI = 0x32c, @@ -442,8 +446,8 @@ enum _RTL8192Pci_HW { #define GPO 0x109 #define GPE 0x10a -#define HWSET_MAX_SIZE_92S 128 +#define HWSET_MAX_SIZE_92S 128 -#define ANAPAR_FOR_8192PciE 0x17 +#define ANAPAR_FOR_8192PciE 0x17 #endif diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.c b/drivers/staging/rtl8192e/r8192E_hwimg.c index 1b42f7335d9..08e7dbb6694 100644 --- a/drivers/staging/rtl8192e/r8192E_hwimg.c +++ b/drivers/staging/rtl8192e/r8192E_hwimg.c @@ -2791,547 +2791,546 @@ u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = { 0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88, }; -u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = { -0x0, }; +u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = {0x0,}; u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = { -0x800,0x00000000, -0x804,0x00000001, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x008514d0, -0x818,0x00000040, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x6870e36c, -0x884,0xe3573600, -0x888,0x4260c340, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x31121311, -0xa00,0x00d0c7d8, -0xa04,0x811f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x00005433, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08800000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x465c52cd, -0xc38,0x497f5994, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x20000000, -0xc88,0x40000100, -0xc8c,0x20200000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000750, -0xd04,0x00000403, -0xd08,0x0000907f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x04032064, -0xe00,0x161a1a1a, -0xe04,0x12121416, -0xe08,0x00001800, -0xe0c,0x00000000, -0xe10,0x161a1a1a, -0xe14,0x12121416, -0xe18,0x161a1a1a, -0xe1c,0x12121416, + 0x800, 0x00000000, + 0x804, 0x00000001, + 0x808, 0x0000fc00, + 0x80c, 0x0000001c, + 0x810, 0x801010aa, + 0x814, 0x008514d0, + 0x818, 0x00000040, + 0x81c, 0x00000000, + 0x820, 0x00000004, + 0x824, 0x00690000, + 0x828, 0x00000004, + 0x82c, 0x00e90000, + 0x830, 0x00000004, + 0x834, 0x00690000, + 0x838, 0x00000004, + 0x83c, 0x00e90000, + 0x840, 0x00000000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84c, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x65a965a9, + 0x85c, 0x65a965a9, + 0x860, 0x001f0010, + 0x864, 0x007f0010, + 0x868, 0x001f0010, + 0x86c, 0x007f0010, + 0x870, 0x0f100f70, + 0x874, 0x0f100f70, + 0x878, 0x00000000, + 0x87c, 0x00000000, + 0x880, 0x6870e36c, + 0x884, 0xe3573600, + 0x888, 0x4260c340, + 0x88c, 0x0000ff00, + 0x890, 0x00000000, + 0x894, 0xfffffffe, + 0x898, 0x4c42382f, + 0x89c, 0x00656056, + 0x8b0, 0x00000000, + 0x8e0, 0x00000000, + 0x8e4, 0x00000000, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90c, 0x31121311, + 0xa00, 0x00d0c7d8, + 0xa04, 0x811f0008, + 0xa08, 0x80cd8300, + 0xa0c, 0x2e62740f, + 0xa10, 0x95009b78, + 0xa14, 0x11145008, + 0xa18, 0x00881117, + 0xa1c, 0x89140fa0, + 0xa20, 0x1a1b0000, + 0xa24, 0x090e1317, + 0xa28, 0x00000204, + 0xa2c, 0x00000000, + 0xc00, 0x00000040, + 0xc04, 0x00005433, + 0xc08, 0x000000e4, + 0xc0c, 0x6c6c6c6c, + 0xc10, 0x08800000, + 0xc14, 0x40000100, + 0xc18, 0x08000000, + 0xc1c, 0x40000100, + 0xc20, 0x08000000, + 0xc24, 0x40000100, + 0xc28, 0x08000000, + 0xc2c, 0x40000100, + 0xc30, 0x6de9ac44, + 0xc34, 0x465c52cd, + 0xc38, 0x497f5994, + 0xc3c, 0x0a969764, + 0xc40, 0x1f7c403f, + 0xc44, 0x000100b7, + 0xc48, 0xec020000, + 0xc4c, 0x00000300, + 0xc50, 0x69543420, + 0xc54, 0x433c0094, + 0xc58, 0x69543420, + 0xc5c, 0x433c0094, + 0xc60, 0x69543420, + 0xc64, 0x433c0094, + 0xc68, 0x69543420, + 0xc6c, 0x433c0094, + 0xc70, 0x2c7f000d, + 0xc74, 0x0186175b, + 0xc78, 0x0000001f, + 0xc7c, 0x00b91612, + 0xc80, 0x40000100, + 0xc84, 0x20000000, + 0xc88, 0x40000100, + 0xc8c, 0x20200000, + 0xc90, 0x40000100, + 0xc94, 0x00000000, + 0xc98, 0x40000100, + 0xc9c, 0x00000000, + 0xca0, 0x00492492, + 0xca4, 0x00000000, + 0xca8, 0x00000000, + 0xcac, 0x00000000, + 0xcb0, 0x00000000, + 0xcb4, 0x00000000, + 0xcb8, 0x00000000, + 0xcbc, 0x00492492, + 0xcc0, 0x00000000, + 0xcc4, 0x00000000, + 0xcc8, 0x00000000, + 0xccc, 0x00000000, + 0xcd0, 0x00000000, + 0xcd4, 0x00000000, + 0xcd8, 0x64b22427, + 0xcdc, 0x00766932, + 0xce0, 0x00222222, + 0xd00, 0x00000750, + 0xd04, 0x00000403, + 0xd08, 0x0000907f, + 0xd0c, 0x00000001, + 0xd10, 0xa0633333, + 0xd14, 0x33333c63, + 0xd18, 0x6a8f5b6b, + 0xd1c, 0x00000000, + 0xd20, 0x00000000, + 0xd24, 0x00000000, + 0xd28, 0x00000000, + 0xd2c, 0xcc979975, + 0xd30, 0x00000000, + 0xd34, 0x00000000, + 0xd38, 0x00000000, + 0xd3c, 0x00027293, + 0xd40, 0x00000000, + 0xd44, 0x00000000, + 0xd48, 0x00000000, + 0xd4c, 0x00000000, + 0xd50, 0x6437140a, + 0xd54, 0x024dbd02, + 0xd58, 0x00000000, + 0xd5c, 0x04032064, + 0xe00, 0x161a1a1a, + 0xe04, 0x12121416, + 0xe08, 0x00001800, + 0xe0c, 0x00000000, + 0xe10, 0x161a1a1a, + 0xe14, 0x12121416, + 0xe18, 0x161a1a1a, + 0xe1c, 0x12121416, }; u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000100, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x00000ee0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x009, 0x000007f0, + 0x00a, 0x000009d0, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x00f, 0x00000990, + 0x012, 0x00000806, + 0x014, 0x000005ab, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000f80, + 0x01b, 0x00000f5e, + 0x01c, 0x00000008, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x01f, 0x00000000, + 0x020, 0x000001a5, + 0x01f, 0x00000001, + 0x020, 0x00000165, + 0x01f, 0x00000002, + 0x020, 0x000000c6, + 0x01f, 0x00000003, + 0x020, 0x00000086, + 0x01f, 0x00000004, + 0x020, 0x00000046, + 0x01f, 0x00000005, + 0x020, 0x000001e6, + 0x01f, 0x00000006, + 0x020, 0x000001a6, + 0x01f, 0x00000007, + 0x020, 0x00000166, + 0x01f, 0x00000008, + 0x020, 0x000000c7, + 0x01f, 0x00000009, + 0x020, 0x00000087, + 0x01f, 0x0000000a, + 0x020, 0x000000f7, + 0x01f, 0x0000000b, + 0x020, 0x000000d7, + 0x01f, 0x0000000c, + 0x020, 0x000000b7, + 0x01f, 0x0000000d, + 0x020, 0x00000097, + 0x01f, 0x0000000e, + 0x020, 0x00000077, + 0x01f, 0x0000000f, + 0x020, 0x00000057, + 0x01f, 0x00000010, + 0x020, 0x00000037, + 0x01f, 0x00000011, + 0x020, 0x000000fb, + 0x01f, 0x00000012, + 0x020, 0x000000db, + 0x01f, 0x00000013, + 0x020, 0x000000bb, + 0x01f, 0x00000014, + 0x020, 0x000000ff, + 0x01f, 0x00000015, + 0x020, 0x000000e3, + 0x01f, 0x00000016, + 0x020, 0x000000c3, + 0x01f, 0x00000017, + 0x020, 0x000000a3, + 0x01f, 0x00000018, + 0x020, 0x00000083, + 0x01f, 0x00000019, + 0x020, 0x00000063, + 0x01f, 0x0000001a, + 0x020, 0x00000043, + 0x01f, 0x0000001b, + 0x020, 0x00000023, + 0x01f, 0x0000001c, + 0x020, 0x00000003, + 0x01f, 0x0000001d, + 0x020, 0x000001e3, + 0x01f, 0x0000001e, + 0x020, 0x000001c3, + 0x01f, 0x0000001f, + 0x020, 0x000001a3, + 0x01f, 0x00000020, + 0x020, 0x00000183, + 0x01f, 0x00000021, + 0x020, 0x00000163, + 0x01f, 0x00000022, + 0x020, 0x00000143, + 0x01f, 0x00000023, + 0x020, 0x00000123, + 0x01f, 0x00000024, + 0x020, 0x00000103, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x00b, 0x000001ba, + 0x02c, 0x000003d7, + 0x02d, 0x00000ff0, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x007, 0x00000080, + 0x002, 0x0000088d, + 0x0fe, 0x00000000, + 0x0fe, 0x00000000, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x000, 0x000000bf, + 0x00d, 0x0000001f, + 0x00d, 0x00000c9f, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000100, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x000006e0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x000, 0x000000b7, + 0x00a, 0x00000850, + 0x000, 0x000000bf, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000e00, + 0x01b, 0x00000f5e, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x00b, 0x000001ba, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x00d, 0x00000ccc, + 0x000, 0x000000bf, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciEMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000100, + 0x03c, 0xffff0000, 0x00000f0f, + 0x340, 0xffffffff, 0x161a1a1a, + 0x344, 0xffffffff, 0x12121416, + 0x348, 0x0000ffff, 0x00001818, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000100, }; u32 Rtl8192PciEMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0xe00,0xffffffff,0x06090909, -0xe04,0xffffffff,0x00030306, -0xe08,0x0000ff00,0x00000000, -0xe10,0xffffffff,0x0a0c0d0f, -0xe14,0xffffffff,0x06070809, -0xe18,0xffffffff,0x0a0c0d0f, -0xe1c,0xffffffff,0x06070809, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, + 0x03c, 0xffff0000, 0x00000f0f, + 0xe00, 0xffffffff, 0x06090909, + 0xe04, 0xffffffff, 0x00030306, + 0xe08, 0x0000ff00, 0x00000000, + 0xe10, 0xffffffff, 0x0a0c0d0f, + 0xe14, 0xffffffff, 0x06070809, + 0xe18, 0xffffffff, 0x0a0c0d0f, + 0xe1c, 0xffffffff, 0x06070809, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000800, }; u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7d040001, -0xc78,0x7d050001, -0xc78,0x7c060001, -0xc78,0x7b070001, -0xc78,0x7a080001, -0xc78,0x79090001, -0xc78,0x780a0001, -0xc78,0x770b0001, -0xc78,0x760c0001, -0xc78,0x750d0001, -0xc78,0x740e0001, -0xc78,0x730f0001, -0xc78,0x72100001, -0xc78,0x71110001, -0xc78,0x70120001, -0xc78,0x6f130001, -0xc78,0x6e140001, -0xc78,0x6d150001, -0xc78,0x6c160001, -0xc78,0x6b170001, -0xc78,0x6a180001, -0xc78,0x69190001, -0xc78,0x681a0001, -0xc78,0x671b0001, -0xc78,0x661c0001, -0xc78,0x651d0001, -0xc78,0x641e0001, -0xc78,0x491f0001, -0xc78,0x48200001, -0xc78,0x47210001, -0xc78,0x46220001, -0xc78,0x45230001, -0xc78,0x44240001, -0xc78,0x43250001, -0xc78,0x28260001, -0xc78,0x27270001, -0xc78,0x26280001, -0xc78,0x25290001, -0xc78,0x242a0001, -0xc78,0x232b0001, -0xc78,0x222c0001, -0xc78,0x212d0001, -0xc78,0x202e0001, -0xc78,0x0a2f0001, -0xc78,0x08300001, -0xc78,0x06310001, -0xc78,0x05320001, -0xc78,0x04330001, -0xc78,0x03340001, -0xc78,0x02350001, -0xc78,0x01360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7d440001, -0xc78,0x7d450001, -0xc78,0x7c460001, -0xc78,0x7b470001, -0xc78,0x7a480001, -0xc78,0x79490001, -0xc78,0x784a0001, -0xc78,0x774b0001, -0xc78,0x764c0001, -0xc78,0x754d0001, -0xc78,0x744e0001, -0xc78,0x734f0001, -0xc78,0x72500001, -0xc78,0x71510001, -0xc78,0x70520001, -0xc78,0x6f530001, -0xc78,0x6e540001, -0xc78,0x6d550001, -0xc78,0x6c560001, -0xc78,0x6b570001, -0xc78,0x6a580001, -0xc78,0x69590001, -0xc78,0x685a0001, -0xc78,0x675b0001, -0xc78,0x665c0001, -0xc78,0x655d0001, -0xc78,0x645e0001, -0xc78,0x495f0001, -0xc78,0x48600001, -0xc78,0x47610001, -0xc78,0x46620001, -0xc78,0x45630001, -0xc78,0x44640001, -0xc78,0x43650001, -0xc78,0x28660001, -0xc78,0x27670001, -0xc78,0x26680001, -0xc78,0x25690001, -0xc78,0x246a0001, -0xc78,0x236b0001, -0xc78,0x226c0001, -0xc78,0x216d0001, -0xc78,0x206e0001, -0xc78,0x0a6f0001, -0xc78,0x08700001, -0xc78,0x06710001, -0xc78,0x05720001, -0xc78,0x04730001, -0xc78,0x03740001, -0xc78,0x02750001, -0xc78,0x01760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x2e00001e, -0xc78,0x2e01001e, -0xc78,0x2e02001e, -0xc78,0x2e03001e, -0xc78,0x2e04001e, -0xc78,0x2e05001e, -0xc78,0x3006001e, -0xc78,0x3407001e, -0xc78,0x3908001e, -0xc78,0x3c09001e, -0xc78,0x3f0a001e, -0xc78,0x420b001e, -0xc78,0x440c001e, -0xc78,0x450d001e, -0xc78,0x460e001e, -0xc78,0x460f001e, -0xc78,0x4710001e, -0xc78,0x4811001e, -0xc78,0x4912001e, -0xc78,0x4a13001e, -0xc78,0x4b14001e, -0xc78,0x4b15001e, -0xc78,0x4c16001e, -0xc78,0x4d17001e, -0xc78,0x4e18001e, -0xc78,0x4f19001e, -0xc78,0x4f1a001e, -0xc78,0x501b001e, -0xc78,0x511c001e, -0xc78,0x521d001e, -0xc78,0x521e001e, -0xc78,0x531f001e, -0xc78,0x5320001e, -0xc78,0x5421001e, -0xc78,0x5522001e, -0xc78,0x5523001e, -0xc78,0x5624001e, -0xc78,0x5725001e, -0xc78,0x5726001e, -0xc78,0x5827001e, -0xc78,0x5828001e, -0xc78,0x5929001e, -0xc78,0x592a001e, -0xc78,0x5a2b001e, -0xc78,0x5b2c001e, -0xc78,0x5c2d001e, -0xc78,0x5c2e001e, -0xc78,0x5d2f001e, -0xc78,0x5e30001e, -0xc78,0x5f31001e, -0xc78,0x6032001e, -0xc78,0x6033001e, -0xc78,0x6134001e, -0xc78,0x6235001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6438001e, -0xc78,0x6539001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x673c001e, -0xc78,0x683d001e, -0xc78,0x693e001e, -0xc78,0x6a3f001e, + 0xc78, 0x7d000001, + 0xc78, 0x7d010001, + 0xc78, 0x7d020001, + 0xc78, 0x7d030001, + 0xc78, 0x7d040001, + 0xc78, 0x7d050001, + 0xc78, 0x7c060001, + 0xc78, 0x7b070001, + 0xc78, 0x7a080001, + 0xc78, 0x79090001, + 0xc78, 0x780a0001, + 0xc78, 0x770b0001, + 0xc78, 0x760c0001, + 0xc78, 0x750d0001, + 0xc78, 0x740e0001, + 0xc78, 0x730f0001, + 0xc78, 0x72100001, + 0xc78, 0x71110001, + 0xc78, 0x70120001, + 0xc78, 0x6f130001, + 0xc78, 0x6e140001, + 0xc78, 0x6d150001, + 0xc78, 0x6c160001, + 0xc78, 0x6b170001, + 0xc78, 0x6a180001, + 0xc78, 0x69190001, + 0xc78, 0x681a0001, + 0xc78, 0x671b0001, + 0xc78, 0x661c0001, + 0xc78, 0x651d0001, + 0xc78, 0x641e0001, + 0xc78, 0x491f0001, + 0xc78, 0x48200001, + 0xc78, 0x47210001, + 0xc78, 0x46220001, + 0xc78, 0x45230001, + 0xc78, 0x44240001, + 0xc78, 0x43250001, + 0xc78, 0x28260001, + 0xc78, 0x27270001, + 0xc78, 0x26280001, + 0xc78, 0x25290001, + 0xc78, 0x242a0001, + 0xc78, 0x232b0001, + 0xc78, 0x222c0001, + 0xc78, 0x212d0001, + 0xc78, 0x202e0001, + 0xc78, 0x0a2f0001, + 0xc78, 0x08300001, + 0xc78, 0x06310001, + 0xc78, 0x05320001, + 0xc78, 0x04330001, + 0xc78, 0x03340001, + 0xc78, 0x02350001, + 0xc78, 0x01360001, + 0xc78, 0x00370001, + 0xc78, 0x00380001, + 0xc78, 0x00390001, + 0xc78, 0x003a0001, + 0xc78, 0x003b0001, + 0xc78, 0x003c0001, + 0xc78, 0x003d0001, + 0xc78, 0x003e0001, + 0xc78, 0x003f0001, + 0xc78, 0x7d400001, + 0xc78, 0x7d410001, + 0xc78, 0x7d420001, + 0xc78, 0x7d430001, + 0xc78, 0x7d440001, + 0xc78, 0x7d450001, + 0xc78, 0x7c460001, + 0xc78, 0x7b470001, + 0xc78, 0x7a480001, + 0xc78, 0x79490001, + 0xc78, 0x784a0001, + 0xc78, 0x774b0001, + 0xc78, 0x764c0001, + 0xc78, 0x754d0001, + 0xc78, 0x744e0001, + 0xc78, 0x734f0001, + 0xc78, 0x72500001, + 0xc78, 0x71510001, + 0xc78, 0x70520001, + 0xc78, 0x6f530001, + 0xc78, 0x6e540001, + 0xc78, 0x6d550001, + 0xc78, 0x6c560001, + 0xc78, 0x6b570001, + 0xc78, 0x6a580001, + 0xc78, 0x69590001, + 0xc78, 0x685a0001, + 0xc78, 0x675b0001, + 0xc78, 0x665c0001, + 0xc78, 0x655d0001, + 0xc78, 0x645e0001, + 0xc78, 0x495f0001, + 0xc78, 0x48600001, + 0xc78, 0x47610001, + 0xc78, 0x46620001, + 0xc78, 0x45630001, + 0xc78, 0x44640001, + 0xc78, 0x43650001, + 0xc78, 0x28660001, + 0xc78, 0x27670001, + 0xc78, 0x26680001, + 0xc78, 0x25690001, + 0xc78, 0x246a0001, + 0xc78, 0x236b0001, + 0xc78, 0x226c0001, + 0xc78, 0x216d0001, + 0xc78, 0x206e0001, + 0xc78, 0x0a6f0001, + 0xc78, 0x08700001, + 0xc78, 0x06710001, + 0xc78, 0x05720001, + 0xc78, 0x04730001, + 0xc78, 0x03740001, + 0xc78, 0x02750001, + 0xc78, 0x01760001, + 0xc78, 0x00770001, + 0xc78, 0x00780001, + 0xc78, 0x00790001, + 0xc78, 0x007a0001, + 0xc78, 0x007b0001, + 0xc78, 0x007c0001, + 0xc78, 0x007d0001, + 0xc78, 0x007e0001, + 0xc78, 0x007f0001, + 0xc78, 0x2e00001e, + 0xc78, 0x2e01001e, + 0xc78, 0x2e02001e, + 0xc78, 0x2e03001e, + 0xc78, 0x2e04001e, + 0xc78, 0x2e05001e, + 0xc78, 0x3006001e, + 0xc78, 0x3407001e, + 0xc78, 0x3908001e, + 0xc78, 0x3c09001e, + 0xc78, 0x3f0a001e, + 0xc78, 0x420b001e, + 0xc78, 0x440c001e, + 0xc78, 0x450d001e, + 0xc78, 0x460e001e, + 0xc78, 0x460f001e, + 0xc78, 0x4710001e, + 0xc78, 0x4811001e, + 0xc78, 0x4912001e, + 0xc78, 0x4a13001e, + 0xc78, 0x4b14001e, + 0xc78, 0x4b15001e, + 0xc78, 0x4c16001e, + 0xc78, 0x4d17001e, + 0xc78, 0x4e18001e, + 0xc78, 0x4f19001e, + 0xc78, 0x4f1a001e, + 0xc78, 0x501b001e, + 0xc78, 0x511c001e, + 0xc78, 0x521d001e, + 0xc78, 0x521e001e, + 0xc78, 0x531f001e, + 0xc78, 0x5320001e, + 0xc78, 0x5421001e, + 0xc78, 0x5522001e, + 0xc78, 0x5523001e, + 0xc78, 0x5624001e, + 0xc78, 0x5725001e, + 0xc78, 0x5726001e, + 0xc78, 0x5827001e, + 0xc78, 0x5828001e, + 0xc78, 0x5929001e, + 0xc78, 0x592a001e, + 0xc78, 0x5a2b001e, + 0xc78, 0x5b2c001e, + 0xc78, 0x5c2d001e, + 0xc78, 0x5c2e001e, + 0xc78, 0x5d2f001e, + 0xc78, 0x5e30001e, + 0xc78, 0x5f31001e, + 0xc78, 0x6032001e, + 0xc78, 0x6033001e, + 0xc78, 0x6134001e, + 0xc78, 0x6235001e, + 0xc78, 0x6336001e, + 0xc78, 0x6437001e, + 0xc78, 0x6438001e, + 0xc78, 0x6539001e, + 0xc78, 0x663a001e, + 0xc78, 0x673b001e, + 0xc78, 0x673c001e, + 0xc78, 0x683d001e, + 0xc78, 0x693e001e, + 0xc78, 0x6a3f001e, }; From 547d0c34b71b1ced82d9652c78143bbcbe08ccdf Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:16 -0500 Subject: [PATCH 0545/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IV Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_phy.c | 1439 +++++++++++++------------ drivers/staging/rtl8192e/r8192E_phy.h | 82 +- 2 files changed, 785 insertions(+), 736 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 9c1d16b5fb6..96ccbd5b25d 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -47,26 +47,29 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { /*************************Define local function prototype**********************/ -static u32 phy_FwRFSerialRead(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset); -static void phy_FwRFSerialWrite(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset,u32 Data); +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset); +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data); u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; - for (i=0; i<=31; i++) - { - if (((dwBitMask>>i)&0x1) == 1) + for (i = 0; i <= 31; i++) { + if (((dwBitMask >> i) & 0x1) == 1) break; } return i; } -u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) + +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath) { u8 ret = 1; struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_type == RF_2T4R) ret = 0; - else if (priv->rf_type == RF_1T2R) - { + else if (priv->rf_type == RF_1T2R) { if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) ret = 1; else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) @@ -74,22 +77,25 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) } return ret; } -void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) + +void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask, + u32 dwData) { u32 OriginalValue, BitShift, NewValue; - if (dwBitMask!= bMaskDWord) - { + if (dwBitMask != bMaskDWord) { OriginalValue = read_nic_dword(dev, dwRegAddr); BitShift = rtl8192_CalculateBitShift(dwBitMask); - NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift)); + NewValue = (((OriginalValue) & (~dwBitMask)) | + (dwData << BitShift)); write_nic_dword(dev, dwRegAddr, NewValue); - }else + } else write_nic_dword(dev, dwRegAddr, dwData); return; } -u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) + +u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) { u32 Ret = 0, OriginalValue, BitShift; @@ -97,60 +103,55 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) BitShift = rtl8192_CalculateBitShift(dwBitMask); Ret = (OriginalValue & dwBitMask) >> BitShift; - return (Ret); + return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset) +u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; u32 NewOffset = 0; - struct bb_reg_definition* pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); - NewOffset = Offset -30; - } - else if (Offset >= 16) - { + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); + NewOffset = Offset - 30; + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need" + " to be 8256\n"); NewOffset = Offset; } - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, + NewOffset); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1); + mdelay(1); - msleep(1); + ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, + bLSSIReadBackData); - ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); - - - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { priv->RfReg0Value[eRFPath] &= 0xebf; - rtl8192_setBBreg( - dev, - pPhyReg->rf3wireOffset, - bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } @@ -160,36 +161,36 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPat } -void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data) +void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 30; - } - else if (Offset >= 16) - { + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be" + " 8256\n"); NewOffset = Offset; } @@ -197,14 +198,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); - - if (Offset==0x0) + if (Offset == 0x0) priv->RfReg0Value[eRFPath] = Data; - if (priv->rf_chip == RF_8256) - { - if (Offset != 0) - { + if (priv->rf_chip == RF_8256) { + if (Offset != 0) { priv->RfReg0Value[eRFPath] &= 0xebf; rtl8192_setBBreg( dev, @@ -214,11 +212,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP } rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } - return; } -void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +void rtl8192_phy_SetRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 Original_Value, BitShift, New_Value; @@ -229,36 +227,37 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, return; RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); - if (priv->Rf_Mode == RF_OP_By_FW) - { - if (BitMask != bMask12Bits) - { - Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); + if (priv->Rf_Mode == RF_OP_By_FW) { + if (BitMask != bMask12Bits) { + Original_Value = phy_FwRFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + } else phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data); udelay(200); - } - else - { - if (BitMask != bMask12Bits) - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); + } else { + if (BitMask != bMask12Bits) { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); - rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, + New_Value); + } else rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data); } return; } -u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask) +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask) { u32 Original_Value, Readback_Value, BitShift; struct r8192_priv *priv = rtllib_priv(dev); @@ -267,79 +266,61 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) return 0; down(&priv->rf_sem); - if (priv->Rf_Mode == RF_OP_By_FW) - { + if (priv->Rf_Mode == RF_OP_By_FW) { Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); udelay(200); - } - else - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); - + } else { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); } BitShift = rtl8192_CalculateBitShift(BitMask); Readback_Value = (Original_Value & BitMask) >> BitShift; up(&priv->rf_sem); - return (Readback_Value); + return Readback_Value; } -static u32 phy_FwRFSerialRead( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset ) +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { u32 retValue = 0; u32 Data = 0; u8 time = 0; - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR)&0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } write_nic_dword(dev, QPNR, Data); - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else - return (0); + return 0; } retValue = read_nic_dword(dev, RF_DATA); - return (retValue); + return retValue; } /* phy_FwRFSerialRead */ -static void -phy_FwRFSerialWrite( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset, - u32 Data ) +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data) { u8 time = 0; - - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x400000; Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } @@ -348,82 +329,81 @@ phy_FwRFSerialWrite( } /* phy_FwRFSerialWrite */ -void rtl8192_phy_configmac(struct net_device* dev) +void rtl8192_phy_configmac(struct net_device *dev) { u32 dwArrayLen = 0, i = 0; - u32* pdwArray = NULL; + u32 *pdwArray = NULL; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bTXPowerDataReadFromEEPORM) - { + + if (priv->bTXPowerDataReadFromEEPORM) { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); dwArrayLen = MACPHY_Array_PGLength; pdwArray = Rtl819XMACPHY_Array_PG; - } - else - { - RT_TRACE(COMP_PHY,"Read rtl819XMACPHY_Array\n"); + } else { + RT_TRACE(COMP_PHY, "Read rtl819XMACPHY_Array\n"); dwArrayLen = MACPHY_ArrayLength; pdwArray = Rtl819XMACPHY_Array; } - for (i = 0; irf_type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; - } - else if (priv->rf_type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; - } + + AGCTAB_ArrayLen = AGCTAB_ArrayLength; + Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; + if (priv->rf_type == RF_2T4R) { + PHY_REGArrayLen = PHY_REGArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; + } else if (priv->rf_type == RF_1T2R) { + PHY_REGArrayLen = PHY_REG_1T2RArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; } - if (ConfigType == BaseBand_Config_PHY_REG) - { - for (i=0; iPHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; @@ -510,37 +490,45 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } -bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath) + +bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath) { bool ret = true; u32 i, CheckTimes = 4, dwRegRead = 0; u32 WriteAddr[4]; u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f}; + WriteAddr[HW90_BLOCK_MAC] = 0x100; WriteAddr[HW90_BLOCK_PHY0] = 0x900; WriteAddr[HW90_BLOCK_PHY1] = 0x800; WriteAddr[HW90_BLOCK_RF] = 0x3; - RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, CheckBlock); - for (i=0 ; i < CheckTimes ; i++) - { - - switch (CheckBlock) - { + RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, + CheckBlock); + for (i = 0; i < CheckTimes; i++) { + switch (CheckBlock) { case HW90_BLOCK_MAC: - RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!"); + RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write " + "0x100 here!"); break; case HW90_BLOCK_PHY0: case HW90_BLOCK_PHY1: - write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]); + write_nic_dword(dev, WriteAddr[CheckBlock], + WriteData[i]); dwRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]); break; case HW90_BLOCK_RF: WriteData[i] &= 0xfff; - rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); + rtl8192_phy_SetRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMask12Bits, WriteData[i]); mdelay(10); - dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord); + dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMaskDWord); mdelay(10); break; @@ -550,9 +538,9 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock } - if (dwRegRead != WriteData[i]) - { - RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, WriteData: %x \n", dwRegRead, WriteData[i]); + if (dwRegRead != WriteData[i]) { + RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, " + "WriteData: %x\n", dwRegRead, WriteData[i]); ret = false; break; } @@ -561,27 +549,27 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device* dev) +bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; u8 bRegValue = 0, eCheckItem = 0; u32 dwRegValue = 0; - /************************************** - **************************************/ bRegValue = read_nic_byte(dev, BB_GLOBAL_RESET); - write_nic_byte(dev, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT)); + write_nic_byte(dev, BB_GLOBAL_RESET, (bRegValue|BB_GLOBAL_RESET_BIT)); dwRegValue = read_nic_dword(dev, CPU_GEN); write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); - for (eCheckItem=(enum hw90_block)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) - { - rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (enum rf90_radio_path)0); - if (rtStatus != true) - { - RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); + for (eCheckItem = (enum hw90_block)HW90_BLOCK_PHY0; + eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { + rtStatus = rtl8192_phy_checkBBAndRF(dev, + (enum hw90_block)eCheckItem, + (enum rf90_radio_path)0); + if (rtStatus != true) { + RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():" + "Check PHY%d Fail!!\n", eCheckItem-1); return rtStatus; } } @@ -593,14 +581,11 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) rtl8192_phyConfigBB(dev, BaseBand_Config_AGC_TAB); - if (priv->IC_Cut > VERSION_8190_BD) - { + if (priv->IC_Cut > VERSION_8190_BD) { if (priv->rf_type == RF_2T4R) - { - dwRegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); - } + dwRegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); else dwRegValue = 0x0; rtl8192_setBBreg(dev, rFPGA0_TxGainStage, @@ -608,22 +593,25 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) dwRegValue = priv->CrystalCap; - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, + dwRegValue); } return rtStatus; } -bool rtl8192_BBConfig(struct net_device* dev) +bool rtl8192_BBConfig(struct net_device *dev) { bool rtStatus = true; + rtl8192_InitBBRFRegDef(dev); rtStatus = rtl8192_BB_Config_ParaFile(dev); return rtStatus; } -void rtl8192_phy_getTxPower(struct net_device* dev) +void rtl8192_phy_getTxPower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); + priv->MCSTxPowerLevelOriginalOffset[0] = read_nic_dword(dev, rTxAGC_Rate18_06); priv->MCSTxPowerLevelOriginalOffset[1] = @@ -641,44 +629,39 @@ void rtl8192_phy_getTxPower(struct net_device* dev) priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1); priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1); - RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n", + RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, " + "c60=0x%x, c68=0x%x)\n", priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3); priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2); - RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n", + RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n", rOFDM0_RxDetector3, priv->framesync); priv->SifsTime = read_nic_word(dev, SIFS); return; } -void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) +void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u8 powerlevel = 0,powerlevelOFDM24G = 0; + u8 powerlevel = 0, powerlevelOFDM24G = 0; char ant_pwr_diff; u32 u4RegValue; - if (priv->epromtype == EEPROM_93C46) - { + if (priv->epromtype == EEPROM_93C46) { powerlevel = priv->TxPowerLevelCCK[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - } - else if (priv->epromtype == EEPROM_93C56) - { - if (priv->rf_type == RF_1T2R) - { + } else if (priv->epromtype == EEPROM_93C56) { + if (priv->rf_type == RF_1T2R) { powerlevel = priv->TxPowerLevelCCK_C[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { powerlevel = priv->TxPowerLevelCCK_A[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] - -priv->TxPowerLevelOFDM24G_A[channel-1]; + - priv->TxPowerLevelOFDM24G_A[channel-1]; priv->RF_C_TxPwDiff = ant_pwr_diff; @@ -688,9 +671,9 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); priv->AntennaTxPwDiff[0] = 0; - u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); + u4RegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); @@ -706,97 +689,105 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", __func__); + RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", + __func__); break; } return; } -bool rtl8192_phy_RFConfig(struct net_device* dev) +bool rtl8192_phy_RFConfig(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; - switch (priv->rf_chip) - { - case RF_8225: - break; - case RF_8256: - rtStatus = PHY_RF8256_Config(dev); - break; - - case RF_8258: - break; - case RF_PSEUDO_11N: + switch (priv->rf_chip) { + case RF_8225: + break; + case RF_8256: + rtStatus = PHY_RF8256_Config(dev); break; - default: - RT_TRACE(COMP_ERR, "error chip id\n"); - break; + case RF_8258: + break; + case RF_PSEUDO_11N: + break; + + default: + RT_TRACE(COMP_ERR, "error chip id\n"); + break; } return rtStatus; } -void rtl8192_phy_updateInitGain(struct net_device* dev) +void rtl8192_phy_updateInitGain(struct net_device *dev) { return; } -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath) +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath) { int i; u8 ret = 0; - switch (eRFPath){ - case RF90_PATH_A: - for (i = 0;iTxPowerLevelCCK[channel-1]; u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - switch (priv->rf_chip) - { + switch (priv->rf_chip) { case RF_8225: break; @@ -818,31 +808,28 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n"); + RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPower" + "Level()\n"); break; } return; } -u8 rtl8192_phy_SetSwChnlCmdArray( - struct sw_chnl_cmd* CmdTable, - u32 CmdTableIdx, - u32 CmdTableSz, - enum sw_chnl_cmd_id CmdID, - u32 Para1, - u32 Para2, - u32 msDelay - ) -{ - struct sw_chnl_cmd* pCmd; - if (CmdTable == NULL) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); +u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, + u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) +{ + struct sw_chnl_cmd *pCmd; + + if (CmdTable == NULL) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot " + "be NULL.\n"); return false; } - if (CmdTableIdx >= CmdTableSz) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", + if (CmdTableIdx >= CmdTableSz) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid" + " index, please check size of the table, CmdTableIdx:" + "%d, CmdTableSz:%d\n", CmdTableIdx, CmdTableSz); return false; } @@ -855,7 +842,9 @@ u8 rtl8192_phy_SetSwChnlCmdArray( return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay) + +u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, + u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -867,50 +856,58 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; - RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); + RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", + __func__, *stage, *step, channel); - if (!IsLegalChannel(priv->rtllib, channel)) - { - RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); + if (!IsLegalChannel(priv->rtllib, channel)) { + RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", + channel); return true; } { PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, + 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); PostCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, + MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); RfDependCmdCnt = 0; - switch ( priv->rf_chip ) - { + switch (priv->rf_chip) { case RF_8225: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8225: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra " + "8225: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, + RF_CHANNEL_TABLE_ZEBRA[channel], 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; case RF_8256: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra" + " 8256: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, channel, + 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, + MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; @@ -918,68 +915,70 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u break; default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", + priv->rf_chip); return false; break; } - do{ - switch (*stage) - { + do { + switch (*stage) { case 0: - CurrentCmd=&PreCommonCmd[*step]; + CurrentCmd = &PreCommonCmd[*step]; break; case 1: - CurrentCmd=&RfDependCmd[*step]; + CurrentCmd = &RfDependCmd[*step]; break; case 2: - CurrentCmd=&PostCommonCmd[*step]; + CurrentCmd = &PostCommonCmd[*step]; break; } - if (CurrentCmd->CmdID==CmdID_End) - { - if ((*stage)==2) - { + if (CurrentCmd->CmdID == CmdID_End) { + if ((*stage) == 2) { return true; - } - else - { + } else { (*stage)++; - (*step)=0; + (*step) = 0; continue; } } - switch (CurrentCmd->CmdID) - { + switch (CurrentCmd->CmdID) { case CmdID_SetTxPowerLevel: if (priv->IC_Cut > (u8)VERSION_8190_BD) - rtl8192_SetTxPowerLevel(dev,channel); + rtl8192_SetTxPowerLevel(dev, channel); break; case CmdID_WritePortUlong: - write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); + write_nic_dword(dev, CurrentCmd->Para1, + CurrentCmd->Para2); break; case CmdID_WritePortUshort: - write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); + write_nic_word(dev, CurrentCmd->Para1, + (u16)CurrentCmd->Para2); break; case CmdID_WritePortUchar: - write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); + write_nic_byte(dev, CurrentCmd->Para1, + (u8)CurrentCmd->Para2); break; case CmdID_RF_WriteReg: - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); + for (eRFPath = 0; eRFPath < + priv->NumTotalRFPath; eRFPath++) + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + CurrentCmd->Para1, bMask12Bits, + CurrentCmd->Para2<<7); break; default: break; } break; - }while(true); - }/*for (Number of RF paths)*/ + } while (true); + } /*for (Number of RF paths)*/ - (*delay)=CurrentCmd->msDelay; + (*delay) = CurrentCmd->msDelay; (*step)++; return false; } @@ -987,14 +986,14 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u32 delay = 0; + u32 delay = 0; - while(!rtl8192_phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay)) - { - if (delay>0) + while (!rtl8192_phy_SwChnlStepByStep(dev, channel, &priv->SwChnlStage, + &priv->SwChnlStep, &delay)) { + if (delay > 0) msleep(delay); if (IS_NIC_DOWN(priv)) - break; + break; } } void rtl8192_SwChnl_WorkItem(struct net_device *dev) @@ -1004,44 +1003,43 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); - RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, priv->chan, priv); + RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, + priv->chan, priv); rtl8192_phy_FinishSwChnlNow(dev , priv->chan); RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); } -u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) +u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); - if (IS_NIC_DOWN(priv)) - { - RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__); return false; } if (priv->SwChnlInProgress) return false; - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_A: case WIRELESS_MODE_N_5G: - if (channel<=14){ + if (channel <= 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14"); return false; } break; case WIRELESS_MODE_B: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14"); return false; } break; case WIRELESS_MODE_G: case WIRELESS_MODE_N_24G: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14"); return false; } @@ -1052,71 +1050,77 @@ u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) if (channel == 0) channel = 1; - priv->chan=channel; + priv->chan = channel; - priv->SwChnlStage=0; - priv->SwChnlStep=0; + priv->SwChnlStage = 0; + priv->SwChnlStep = 0; - if (!IS_NIC_DOWN(priv)){ + if (!IS_NIC_DOWN(priv)) rtl8192_SwChnl_WorkItem(dev); - } priv->SwChnlInProgress = false; return true; } -static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev ) +static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength-1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; + RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); - RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->rtllib->current_network.channel== 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != + 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; - case HT_CHANNEL_WIDTH_20_40: + case HT_CHANNEL_WIDTH_20_40: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength - 1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 + && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; } } @@ -1125,24 +1129,29 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) priv->bcck_in_ch14 = true; - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) priv->bcck_in_ch14 = false; - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - if (priv->Record_CCK_20Mindex == 0) - priv->Record_CCK_20Mindex = 6; - priv->CCK_index = priv->Record_CCK_20Mindex; - RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n", priv->CCK_index); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + if (priv->Record_CCK_20Mindex == 0) + priv->Record_CCK_20Mindex = 6; + priv->CCK_index = priv->Record_CCK_20Mindex; + RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(),CCK_index = %d\n", + priv->CCK_index); + break; - case HT_CHANNEL_WIDTH_20_40: - priv->CCK_index = priv->Record_CCK_40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n", priv->CCK_index); - break; + case HT_CHANNEL_WIDTH_20_40: + priv->CCK_index = priv->Record_CCK_40Mindex; + RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(), CCK_index = %d\n", + priv->CCK_index); + break; } dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } @@ -1163,108 +1172,107 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u8 regBwOpMode; - RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \ - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz") + RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s " + "bandwidth\n", priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz") - if (priv->rf_chip== RF_PSEUDO_11N) - { - priv->SetBWModeInProgress= false; + if (priv->rf_chip == RF_PSEUDO_11N) { + priv->SetBWModeInProgress = false; return; } - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR,"%s(): ERR!! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__); return; } regBwOpMode = read_nic_byte(dev, BW_OPMODE); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - case HT_CHANNEL_WIDTH_20_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + case HT_CHANNEL_WIDTH_20_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW); - break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); - break; - case HT_CHANNEL_WIDTH_20_40: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); + break; + case HT_CHANNEL_WIDTH_20_40: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); + rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, + (priv->nCur40MhzPrimeSC>>1)); + rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, + priv->nCur40MhzPrimeSC); - - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); - break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); - break; + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); + break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch ( priv->rf_chip ) - { - case RF_8225: - break; + switch (priv->rf_chip) { + case RF_8225: + break; - case RF_8256: - PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); - break; + case RF_8256: + PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); + break; - case RF_8258: - break; + case RF_8258: + break; - case RF_PSEUDO_11N: - break; + case RF_PSEUDO_11N: + break; - default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); - break; + default: + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + break; } atomic_dec(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= false; + priv->SetBWModeInProgress = false; RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1272,14 +1280,14 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, if (priv->SetBWModeInProgress) return; - atomic_inc(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= true; + atomic_inc(&(priv->rtllib->atm_swbw)); + priv->SetBWModeInProgress = true; priv->CurrentChannelBW = Bandwidth; - if (Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Offset == HT_EXTCHNL_OFFSET_LOWER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if (Offset==HT_EXTCHNL_OFFSET_UPPER) + else if (Offset == HT_EXTCHNL_OFFSET_UPPER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; else priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -1288,79 +1296,107 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, } - void InitialGain819xPci(struct net_device *dev, u8 Operation) { #define SCAN_RX_INITIAL_GAIN 0x17 #define POWER_DETECTION_TH 0x08 struct r8192_priv *priv = rtllib_priv(dev); - u32 BitMask; - u8 initial_gain; + u32 BitMask; + u8 initial_gain; - if (!IS_NIC_DOWN(priv)){ - switch (Operation) - { - case IG_Backup: - RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n"); - initial_gain = SCAN_RX_INITIAL_GAIN; - BitMask = bMaskByte0; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask); - priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask); - priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask); - priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask); - BitMask = bMaskByte2; - priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask); + if (!IS_NIC_DOWN(priv)) { + switch (Operation) { + case IG_Backup: + RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial" + " gain.\n"); + initial_gain = SCAN_RX_INITIAL_GAIN; + BitMask = bMaskByte0; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + priv->initgain_backup.xaagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, + BitMask); + priv->initgain_backup.xbagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, + BitMask); + priv->initgain_backup.xcagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, + BitMask); + priv->initgain_backup.xdagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, + BitMask); + BitMask = bMaskByte2; + priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, + rCCK0_CCA, BitMask); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is" + " %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is" + " %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is" + " %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is" + " %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is" + " %x\n", priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain); - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH); - write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); - break; - case IG_Restore: - RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n"); - BitMask = 0x7f; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n", + initial_gain); + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x\n", + POWER_DETECTION_TH); + write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); + break; + case IG_Restore: + RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial " + "gain.\n"); + BitMask = 0x7f; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1); - rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1); - rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1); - BitMask = bMaskByte2; - rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, + (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, + (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, + (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, + (u32)priv->initgain_backup.xdagccore1); + BitMask = bMaskByte2; + rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, + (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50" + " is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58" + " is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60" + " is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68" + " is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a" + " is %x\n", priv->initgain_backup.cca); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); - - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - break; - default: - RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n"); - break; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + break; + default: + RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n"); + break; } } } -extern void -PHY_SetRtl8192eRfOff(struct net_device* dev ) +void PHY_SetRtl8192eRfOff(struct net_device *dev) { rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); @@ -1374,14 +1410,12 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) } -bool -SetRFPowerState8190( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bResult = true; u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; @@ -1391,137 +1425,142 @@ SetRFPowerState8190( RT_TRACE(COMP_PS, "===========> SetRFPowerState8190()!\n"); priv->SetRFPowerStateInProgress = true; - switch (priv->rf_chip) - { - case RF_8256: - switch ( eRFPowerState ) - { - case eRfOn: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn !\n"); - if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - bool rtstatus = true; - u32 InitilizeCount = 3; - do - { - InitilizeCount--; - priv->RegRfOff = false; - rtstatus = NicIFEnableNIC(dev); - }while( (rtstatus != true) &&(InitilizeCount >0) ); + switch (priv->rf_chip) { + case RF_8256: + switch (eRFPowerState) { + case eRfOn: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn!\n"); + if ((priv->rtllib->eRFPowerState == eRfOff) && + RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + bool rtstatus = true; + u32 InitilizeCount = 3; + do { + InitilizeCount--; + priv->RegRfOff = false; + rtstatus = NicIFEnableNIC(dev); + } while ((rtstatus != true) && + (InitilizeCount > 0)); - if (rtstatus != true) - { - RT_TRACE(COMP_ERR,"%s():Initialize Adapter fail,return\n",__func__); - priv->SetRFPowerStateInProgress = false; - return false; - } + if (rtstatus != true) { + RT_TRACE(COMP_ERR, "%s():Initialize Ada" + "pter fail,return\n", + __func__); + priv->SetRFPowerStateInProgress = false; + return false; + } - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } else { + RT_CLEAR_PS_LEVEL(pPSC, + RT_RF_OFF_LEVL_HALT_NIC); + } else { write_nic_byte(dev, ANAPAR, 0x37); mdelay(1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x4, 0x1); priv->bHwRfOffAction = 0; - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x3); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, + BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, + 0x300, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x18, 0x3); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x60, 0x3); + } + + break; + + case eRfSleep: + if (priv->rtllib->eRFPowerState == eRfOff) + break; + + + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE((COMP_POWER|COMP_RF), "eRf Off" + "/Sleep: %d times TcbBusyQueue" + "[%d] !=0 before doze!\n", + (i+1), QueueID); + udelay(10); + i++; } - break; - - case eRfSleep: - { - if (priv->rtllib->eRFPowerState == eRfOff) + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! " + "SetRFPowerState8190(): eRfOff" + ": %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; - - - { - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! SetRFPowerState8190(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); - break; - } - } - } - - { - PHY_SetRtl8192eRfOff(dev); } } - break; + PHY_SetRtl8192eRfOff(dev); + break; - case eRfOff: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/Sleep !\n"); + case eRfOff: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/" + "Sleep !\n"); + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE(COMP_POWER, - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); - break; - } - } - - { - if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - - NicIFDisableNIC(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } - else if (!(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC)) - { - PHY_SetRtl8192eRfOff(dev); - } + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE(COMP_POWER, "eRf Off/Sleep: %d" + " times TcbBusyQueue[%d] !=0 b" + "efore doze!\n", (i+1), + QueueID); + udelay(10); + i++; } + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n SetZebra: " + "RFPowerState8185B(): eRfOff:" + " %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; + } + } - default: - bResult = false; - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state to set: 0x%X!!!\n", eRFPowerState); - break; + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && + !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + NicIFDisableNIC(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } else if (!(pPSC->RegRfPsLevel & + RT_RF_OFF_LEVL_HALT_NIC)) { + PHY_SetRtl8192eRfOff(dev); + } + + break; + + default: + bResult = false; + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state" + " to set: 0x%X!!!\n", eRFPowerState); + break; } break; - default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); - break; + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; } if (bResult) { @@ -1532,62 +1571,60 @@ SetRFPowerState8190( break; default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown " + "RF type\n"); break; } } priv->SetRFPowerStateInProgress = false; - RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", bResult); + RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", + bResult); return bResult; } - - -bool -SetRFPowerState( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); bool bResult = false; - RT_TRACE(COMP_PS,"---------> SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState); - if (eRFPowerState == priv->rtllib->eRFPowerState && priv->bHwRfOffAction == 0) { - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState); + RT_TRACE(COMP_PS, "---------> SetRFPowerState(): eRFPowerState(%d)\n", + eRFPowerState); + if (eRFPowerState == priv->rtllib->eRFPowerState && + priv->bHwRfOffAction == 0) { + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the " + "request for eRFPowerState(%d) is the same.\n", + eRFPowerState); return bResult; } bResult = SetRFPowerState8190(dev, eRFPowerState); - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", bResult); + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", + bResult); return bResult; } -extern void -PHY_ScanOperationBackup8192( - struct net_device* dev, - u8 Operation - ) +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->up) { switch (Operation) { - case SCAN_OPT_BACKUP: - priv->rtllib->InitialGainHandler(dev,IG_Backup); - break; + case SCAN_OPT_BACKUP: + priv->rtllib->InitialGainHandler(dev, IG_Backup); + break; - case SCAN_OPT_RESTORE: - priv->rtllib->InitialGainHandler(dev,IG_Restore); - break; + case SCAN_OPT_RESTORE: + priv->rtllib->InitialGainHandler(dev, IG_Restore); + break; - default: - RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation. \n"); - break; + default: + RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation.\n"); + break; } } diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 79adc8096bd..86c6acd0c54 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -25,25 +25,25 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE -#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE -#define RadioA_ArrayLength RadioA_ArrayLengthPciE -#define RadioB_ArrayLength RadioB_ArrayLengthPciE +#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE +#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE +#define RadioA_ArrayLength RadioA_ArrayLengthPciE +#define RadioB_ArrayLength RadioB_ArrayLengthPciE #define MACPHY_Array_PGLength MACPHY_Array_PGLengthPciE -#define RadioC_ArrayLength RadioC_ArrayLengthPciE -#define RadioD_ArrayLength RadioD_ArrayLengthPciE -#define PHY_REGArrayLength PHY_REGArrayLengthPciE -#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE +#define RadioC_ArrayLength RadioC_ArrayLengthPciE +#define RadioD_ArrayLength RadioD_ArrayLengthPciE +#define PHY_REGArrayLength PHY_REGArrayLengthPciE +#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE #define Rtl819XMACPHY_Array_PG Rtl8192PciEMACPHY_Array_PG -#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array -#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array -#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array -#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array -#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array -#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array -#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray -#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray +#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array +#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array +#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array +#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array +#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array +#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array +#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray +#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray @@ -57,7 +57,7 @@ enum sw_chnl_cmd_id { CmdID_RF_WriteReg, }; -/*--------------------------------Define structure--------------------------------*/ +/*--------------------------------Define structure----------------------------*/ struct sw_chnl_cmd { enum sw_chnl_cmd_id CmdID; u32 Para1; @@ -97,23 +97,35 @@ enum rf90_radio_path { #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff -extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath); -extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData); -extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask); -extern void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask); -extern void rtl8192_phy_configmac(struct net_device* dev); -extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); -extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath); -extern bool rtl8192_BBConfig(struct net_device* dev); -extern void rtl8192_phy_getTxPower(struct net_device* dev); -extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); -extern bool rtl8192_phy_RFConfig(struct net_device* dev); -extern void rtl8192_phy_updateInitGain(struct net_device* dev); -extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); +extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, + u32 eRFPath); +extern void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask, u32 dwData); +extern u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask); +extern void rtl8192_phy_SetRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); +extern u32 rtl8192_phy_QueryRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask); +extern void rtl8192_phy_configmac(struct net_device *dev); +extern void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); +extern bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath); +extern bool rtl8192_BBConfig(struct net_device *dev); +extern void rtl8192_phy_getTxPower(struct net_device *dev); +extern void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); +extern bool rtl8192_phy_RFConfig(struct net_device *dev); +extern void rtl8192_phy_updateInitGain(struct net_device *dev); +extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath); -extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); +extern u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); +extern void rtl8192_SetBWMode(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); @@ -122,11 +134,11 @@ extern void PHY_SetRtl8192eRfOff(struct net_device *dev); bool SetRFPowerState( - struct net_device* dev, + struct net_device *dev, enum rt_rf_power_state eRFPowerState ); #define PHY_SetRFPowerState SetRFPowerState -extern void PHY_ScanOperationBackup8192(struct net_device* dev,u8 Operation); +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation); #endif From 831cb9db38ccf3f21804ef1fa0510d4ed27e27f1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:17 -0500 Subject: [PATCH 0546/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part V Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BA.h | 5 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 403 +++++----- drivers/staging/rtl8192e/rtl819x_HT.h | 25 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 876 +++++++++++----------- 4 files changed, 650 insertions(+), 659 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index d2020b39018..613e14c12df 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -38,11 +38,10 @@ #define DELBA_REASON_TIMEOUT 39 union sequence_control { u16 ShortData; - struct - { + struct { u16 FragNum:4; u16 SeqNum:12; - }field; + } field; }; union ba_param_set { diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index aeb8a4b5d05..2e4085b8877 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,46 +20,44 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device* ieee, struct ba_record *pBA, u16 Time) +void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry( struct rtllib_device* ieee, struct ba_record *pBA) +void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) + +u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; - u8 bSendDELBA = false; + u8 bSendDELBA = false; - if (pPendingBa->bValid) - { + if (pPendingBa->bValid) { DeActivateBAEntry(ieee, pPendingBa); bSendDELBA = true; } - if (pAdmittedBa->bValid) - { + if (pAdmittedBa->bValid) { DeActivateBAEntry(ieee, pAdmittedBa); bSendDELBA = true; } - return bSendDELBA; } -u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) +u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; - if (pBa->bValid) - { + if (pBa->bValid) { DeActivateBAEntry(ieee, pBa); bSendDELBA = true; } @@ -67,7 +65,7 @@ u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) return bSendDELBA; } -void ResetBaEntry( struct ba_record *pBA) +void ResetBaEntry(struct ba_record *pBA) { pBA->bValid = false; pBA->BaParamSet.shortData = 0; @@ -75,31 +73,35 @@ void ResetBaEntry( struct ba_record *pBA) pBA->DialogToken = 0; pBA->BaStartSeqCtrl.ShortData = 0; } -static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct ba_record *pBA, u16 StatusCode, u8 type) +static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, + struct ba_record *pBA, + u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* BAReq = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *BAReq = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = ieee->tx_headroom + 9; - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, type, MAC_ARG(Dst), ieee->dev); - if (pBA == NULL||ieee == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" + " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, + type, MAC_ARG(Dst), ieee->dev); + if (pBA == NULL || ieee == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " + "NULL\n", pBA, ieee); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct rtllib_hdr_3addr)); + memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr)); skb_reserve(skb, ieee->tx_headroom); - BAReq = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + BAReq = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(BAReq->addr1, Dst, ETH_ALEN); memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -107,28 +109,26 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 9); + tag = (u8 *)skb_put(skb, 9); *tag ++= ACT_CAT_BA; *tag ++= type; *tag ++= pBA->DialogToken; - if (ACT_ADDBARSP == type) - { + if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); tmp = cpu_to_le16(StatusCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; } tmp = cpu_to_le16(pBA->BaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(pBA->BaTimeoutValue); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; - if (ACT_ADDBAREQ == type) - { - memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2); + if (ACT_ADDBAREQ == type) { + memcpy(tag, (u8 *)&(pBA->BaStartSeqCtrl), 2); tag += 2; } @@ -136,64 +136,65 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct return skb; } -static struct sk_buff* rtllib_DELBA( - struct rtllib_device* ieee, - u8* dst, - struct ba_record *pBA, - enum tr_select TxRxSelect, - u16 ReasonCode - ) +static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, + enum tr_select TxRxSelect, u16 ReasonCode) { union delba_param_set DelbaParamSet; struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* Delba = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *Delba = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __func__, ReasonCode, MAC_ARG(dst)); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, + "========>%s(), Reason" + "Code(%d) sentd to:"MAC_FMT"\n", __func__, + ReasonCode, MAC_ARG(dst)); memset(&DelbaParamSet, 0, 2); - DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; + DelbaParamSet.field.Initiator = (TxRxSelect == TX_DIR) ? 1 : 0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } skb_reserve(skb, ieee->tx_headroom); - Delba = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + Delba = (struct rtllib_hdr_3addr *) skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(Delba->addr1, dst, ETH_ALEN); memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 6); + tag = (u8 *)skb_put(skb, 6); *tag ++= ACT_CAT_BA; *tag ++= ACT_DELBA; tmp = cpu_to_le16(DelbaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(ReasonCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", + __func__); return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA) +void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -202,65 +203,66 @@ void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); softmac_mgmt_xmit(skb, ieee); } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); } return; } -void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, u16 StatusCode) +void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); if (skb) softmac_mgmt_xmit(skb, ieee); else - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); return; - } -void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, enum tr_select TxRxSelect, u16 ReasonCode) +void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); if (skb) - { softmac_mgmt_xmit(skb, ieee); - } else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - } + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in func" + "tion %s()\n", __func__); return ; } -int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* req = NULL; + struct rtllib_hdr_3addr *req = NULL; u16 rc = 0; - u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; struct ba_record *pBA = NULL; union ba_param_set *pBaParamSet = NULL; - u16* pBaTimeoutVal = NULL; + u16 *pBaTimeoutVal = NULL; union sequence_control *pBaStartSeqCtrl = NULL; struct rx_ts_record *pTS = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n",(int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - req = ( struct rtllib_hdr_3addr*) skb->data; - tag = (u8*)req; - dst = (u8*)(&req->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + req = (struct rtllib_hdr_3addr *) skb->data; + tag = (u8 *)req; + dst = (u8 *)(&req->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; pBaParamSet = (union ba_param_set *)(tag + 3); - pBaTimeoutVal = (u16*)(tag + 5); + pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); @@ -268,31 +270,27 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as " + "some capability is not ready(%d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); goto OnADDBAReq_Fail; } - if (!GetTs( - ieee, - (struct ts_common_info **)(&pTS), - dst, - (u8)(pBaParamSet->field.TID), - RX_DIR, - true) ) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + (u8)(pBaParamSet->field.TID), RX_DIR, true)) { rc = ADDBA_STATUS_REFUSED; RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; } pBA = &pTS->RxAdmittedBARecord; - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { rc = ADDBA_STATUS_INVALID_PARAM; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in " + "%s()\n", __func__); goto OnADDBAReq_Fail; } - rtllib_FlushRxTsPendingPkts(ieee, pTS); DeActivateBAEntry(ieee, pBA); @@ -301,11 +299,11 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) pBA->BaTimeoutValue = *pBaTimeoutVal; pBA->BaStartSeqCtrl = *pBaStartSeqCtrl; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)|| - (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) - pBA->BaParamSet.field.BufferSize = 1; + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) || + (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) + pBA->BaParamSet.field.BufferSize = 1; else - pBA->BaParamSet.field.BufferSize = 32; + pBA->BaParamSet.field.BufferSize = 32; ActivateBAEntry(ieee, pBA, 0); rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS); @@ -322,40 +320,42 @@ OnADDBAReq_Fail: rtllib_send_ADDBARsp(ieee, dst, &BA, rc); return 0; } - } -int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* rsp = NULL; + struct rtllib_hdr_3addr *rsp = NULL; struct ba_record *pPendingBA, *pAdmittedBA; struct tx_ts_record *pTS = NULL; - u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; - u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; + u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL; union ba_param_set *pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } - rsp = ( struct rtllib_hdr_3addr*)skb->data; - tag = (u8*)rsp; - dst = (u8*)(&rsp->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + rsp = (struct rtllib_hdr_3addr *)skb->data; + tag = (u8 *)rsp; + dst = (u8 *)(&rsp->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; - pStatusCode = (u16*)(tag + 3); + pStatusCode = (u16 *)(tag + 3); pBaParamSet = (union ba_param_set *)(tag + 5); - pBaTimeoutVal = (u16*)(tag + 7); + pBaTimeoutVal = (u16 *)(tag + 7); RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false || + ieee->pHTInfo->bCurrentAMPDUEnable == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capab" + "ility is not ready(%d, %d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -373,28 +373,25 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) pAdmittedBA = &pTS->TxAdmittedBARecord; - if ((pAdmittedBA->bValid==true)) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); + if ((pAdmittedBA->bValid == true)) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp." + " Drop because already admit it!\n"); return -1; - } - else if ((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); + } else if ((pPendingBA->bValid == false) || + (*pDialogToken != pPendingBA->DialogToken)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. " + "BA invalid, DELBA!\n"); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA " + "is admitted! Status code:%X\n", *pStatusCode); DeActivateBAEntry(ieee, pPendingBA); } - if (*pStatusCode == ADDBA_STATUS_SUCCESS) - { - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (*pStatusCode == ADDBA_STATUS_SUCCESS) { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { pTS->bAddBaReqDelayed = true; DeActivateBAEntry(ieee, pAdmittedBA); ReasonCode = DELBA_REASON_END_BA; @@ -424,68 +421,58 @@ OnADDBARsp_Reject: rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); return 0; } - } -int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) +int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* delba = NULL; + struct rtllib_hdr_3addr *delba = NULL; union delba_param_set *pDelBaParamSet = NULL; - u16* pReasonCode = NULL; - u8* dst = NULL; + u16 *pReasonCode = NULL; + u8 *dst = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 6) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 6)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d /" + " %d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 6)); return -1; } - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT " + "is not supported(%d, %d)\n", + ieee->current_network. qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - delba = ( struct rtllib_hdr_3addr*)skb->data; - dst = (u8*)(&delba->addr2[0]); - delba += sizeof( struct rtllib_hdr_3addr); + delba = (struct rtllib_hdr_3addr *)skb->data; + dst = (u8 *)(&delba->addr2[0]); + delba += sizeof(struct rtllib_hdr_3addr); pDelBaParamSet = (union delba_param_set *)(delba+2); - pReasonCode = (u16*)(delba+4); + pReasonCode = (u16 *)(delba+4); - if (pDelBaParamSet->field.Initiator == 1) - { + if (pDelBaParamSet->field.Initiator == 1) { struct rx_ts_record *pRxTs; - if ( !GetTs( - ieee, - (struct ts_common_info **)&pRxTs, - dst, - (u8)pDelBaParamSet->field.TID, - RX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in %s().dst:"MAC_FMT" TID:%d\n", __func__, MAC_ARG(dst), (u8)pDelBaParamSet->field.TID); + if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, + (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " + "%s().dst:"MAC_FMT" TID:%d\n", __func__, + MAC_ARG(dst), + (u8)pDelBaParamSet->field.TID); return -1; } RxTsDeleteBA(ieee, pRxTs); - } - else - { + } else { struct tx_ts_record *pTxTs; - if (!GetTs( - ieee, - (struct ts_common_info **)&pTxTs, - dst, - (u8)pDelBaParamSet->field.TID, - TX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); + if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst, + (u8)pDelBaParamSet->field.TID, TX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in " + "%s()\n", __func__); return -1; } @@ -498,17 +485,12 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) return 0; } -void -TsInitAddBA( - struct rtllib_device* ieee, - struct tx_ts_record *pTS, - u8 Policy, - u8 bOverwritePending - ) +void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending) { struct ba_record *pBA = &pTS->TxPendingBARecord; - if (pBA->bValid==true && bOverwritePending==false) + if (pBA->bValid == true && bOverwritePending == false) return; DeActivateBAEntry(ieee, pBA); @@ -516,7 +498,8 @@ TsInitAddBA( pBA->DialogToken++; pBA->BaParamSet.field.AMSDU_Support = 0; pBA->BaParamSet.field.BAPolicy = Policy; - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; + pBA->BaParamSet.field.TID = + pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; pBA->BaParamSet.field.BufferSize = 32; pBA->BaTimeoutValue = 0; pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; @@ -526,34 +509,30 @@ TsInitAddBA( rtllib_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); } -void -TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) +void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect) { - - if (TxRxSelect == TX_DIR) - { - struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo; + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *pTxTs = + (struct tx_ts_record *)pTsCommonInfo; if (TxTsDeleteBA(ieee, pTxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), - TxRxSelect, - DELBA_REASON_END_BA); - } - else if (TxRxSelect == RX_DIR) - { - struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo; + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + (pTxTs->TxAdmittedBARecord.bValid) ? + (&pTxTs->TxAdmittedBARecord) : + (&pTxTs->TxPendingBARecord), + TxRxSelect, DELBA_REASON_END_BA); + } else if (TxRxSelect == RX_DIR) { + struct rx_ts_record *pRxTs = + (struct rx_ts_record *)pTsCommonInfo; if (RxTsDeleteBA(ieee, pRxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - &pRxTs->RxAdmittedBARecord, - TxRxSelect, - DELBA_REASON_END_BA ); + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + &pRxTs->RxAdmittedBARecord, + TxRxSelect, DELBA_REASON_END_BA); } } + void BaSetupTimeOut(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; @@ -566,27 +545,23 @@ void BaSetupTimeOut(unsigned long data) void TxBaInactTimeout(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[pTxTs->num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); - rtllib_send_DELBA( - ieee, - pTxTs->TsCommonInfo.Addr, - &pTxTs->TxAdmittedBARecord, - TX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pTxTs->TsCommonInfo.Addr, + &pTxTs->TxAdmittedBARecord, TX_DIR, + DELBA_REASON_TIMEOUT); } void RxBaInactTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); - rtllib_send_DELBA( - ieee, - pRxTs->TsCommonInfo.Addr, - &pRxTs->RxAdmittedBARecord, - RX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pRxTs->TsCommonInfo.Addr, + &pRxTs->RxAdmittedBARecord, RX_DIR, + DELBA_REASON_TIMEOUT); return ; } diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 891714fb182..13f41057461 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -34,10 +34,10 @@ #define sHTCLng 4 -#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff -#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 -#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP - +#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff +#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 +#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP \ + (HT_MCS_1SS_BITMAP | HT_MCS_1SS_2SS_BITMAP) enum ht_mcs_rate { HT_MCS0 = 0x00000001, @@ -381,13 +381,12 @@ extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; #define PICK_RATE(_nLegacyRate, _nMcsRate) \ - (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate) + ((_nMcsRate == 0) ? (_nLegacyRate&0x7f) : (_nMcsRate)) #define LEGACY_WIRELESS_MODE IEEE_MODE_MASK #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \ - ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\ - (LegacyRate):\ - (PICK_RATE(LegacyRate, HTRate)) + ((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \ + (LegacyRate) : (PICK_RATE(LegacyRate, HTRate)) @@ -411,8 +410,8 @@ enum ht_iot_peer { HT_IOT_PEER_BROADCOM = 3, HT_IOT_PEER_RALINK = 4, HT_IOT_PEER_ATHEROS = 5, - HT_IOT_PEER_CISCO= 6, - HT_IOT_PEER_MARVELL=7, + HT_IOT_PEER_CISCO = 6, + HT_IOT_PEER_MARVELL = 7, HT_IOT_PEER_92U_SOFTAP = 8, HT_IOT_PEER_SELF_SOFTAP = 9, HT_IOT_PEER_AIRGO = 10, @@ -447,10 +446,10 @@ enum ht_iot_action { HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000, HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000, - HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, - HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, + HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, + HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, - HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, + HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000, HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000, diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 825b90805b4..f8da913c47b 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -18,53 +18,75 @@ ******************************************************************************/ #include "rtllib.h" #include "rtl819x_HT.h" -u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_ALL[16] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; -u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_1SS[16] = { + 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +; -u16 MCS_DATA_RATE[2][2][77] = - { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260, - 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520, - 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195, - 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260, - 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, - {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, - 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578, - 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217, - 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289, - 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, - { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, - 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, - 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, - 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, - 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, - {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, - 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, - 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, - 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600, - 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } - }; +u16 MCS_DATA_RATE[2][2][77] = { + {{13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, + 260, 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, + 468, 520, 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, + 182, 208, 156, 195, 195, 234, 273, 273, 312, 130, 156, 181, 156, + 181, 208, 234, 208, 234, 260, 260, 286, 195, 234, 273, 234, 273, + 312, 351, 312, 351, 390, 390, 429} , + {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, + 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, + 578, 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, + 173, 217, 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, + 231, 260, 289, 289, 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, + 433, 433, 477} } , + {{27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, + 540, 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, + 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, + 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324, + 378, 432, 486, 432, 486, 540, 540, 594, 405, 486, 567, 486, 567, 648, + 729, 648, 729, 810, 810, 891}, + {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, + 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, + 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, + 420, 420, 480, 360, 450, 450, 540, 630, 630, 720, 300, 360, 420, 360, + 420, 480, 540, 480, 540, 600, 600, 660, 450, 540, 630, 540, 630, 720, + 810, 720, 810, 900, 900, 990} } +}; static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf}; + static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70}; + static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e}; + static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; + static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf}; + static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc}; + static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; + static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; + static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0}; + static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91}; + static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; + static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; -void HTUpdateDefaultSetting(struct rtllib_device* ieee) + +void HTUpdateDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->bAcceptAddbaReq = 1; - pHTInfo->bRegShortGI20MHz= 1; - pHTInfo->bRegShortGI40MHz= 1; + pHTInfo->bRegShortGI20MHz = 1; + pHTInfo->bRegShortGI40MHz = 1; pHTInfo->bRegBW40MHz = 1; @@ -94,97 +116,110 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->RxReorderWinSize = 64; pHTInfo->RxReorderPendingTime = 30; } -void HTDebugHTCapability(u8* CapIE, u8* TitleString ) + +void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; struct ht_capab_ele *pCapELE; - if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) - { + if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pCapELE = (struct ht_capab_ele *)(&CapIE[4]); - }else + } else pCapELE = (struct ht_capab_ele *)(&CapIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString ); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", + TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ - pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", + (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", + (pCapELE->ShortGI20Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", + (pCapELE->ShortGI40Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", + (pCapELE->TxSTBC) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", + (pCapELE->MaxAMSDUSize) ? "3839" : "7935"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", + (pCapELE->DssCCk) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", + pCapELE->MaxRxAMPDUFactor); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", + pCapELE->MPDUDensity); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", + pCapELE->MCS[0], pCapELE->MCS[1], pCapELE->MCS[2], + pCapELE->MCS[3], pCapELE->MCS[4]); return; } -void HTDebugHTInfo(u8* InfoIE, u8* TitleString) + +void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) { static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; struct ht_info_ele *pHTInfoEle; - if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - { + if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]); - }else + } else pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". " + "Called by %s\n", TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", + pHTInfoEle->ControlChl); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel ="); - switch (pHTInfoEle->ExtChlOffset) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); - break; + switch (pHTInfoEle->ExtChlOffset) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", + (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz"); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = "); - switch (pHTInfoEle->OptMode) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); - break; + switch (pHTInfoEle->OptMode) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ - pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x]" + "[%x]\n", pHTInfoEle->BasicMSC[0], pHTInfoEle->BasicMSC[1], + pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], + pHTInfoEle->BasicMSC[4]); return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) +bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (pHTInfo->bRegBW40MHz == false) retValue = false; @@ -198,25 +233,24 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) +bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) retValue = false; - else if (is40MHz) - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) + else if (is40MHz) { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) retValue = true; else retValue = false; - } - else - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) + } else { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) retValue = true; else retValue = false; @@ -225,89 +259,75 @@ bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) return retValue; } -u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate) +u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { u8 is40MHz; u8 isShortGI; - is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0; - isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0; + is40MHz = (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0; + isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0; - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate) +u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; - u8 isShortGI = (pHTInfo->bCurBW40MHz)? - ((pHTInfo->bCurShortGI40MHz)?1:0): - ((pHTInfo->bCurShortGI20MHz)?1:0); - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + u8 is40MHz = (pHTInfo->bCurBW40MHz) ? 1 : 0; + u8 isShortGI = (pHTInfo->bCurBW40MHz) ? + ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) : + ((pHTInfo->bCurShortGI20MHz) ? 1 : 0); + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate) +u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate) { - u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c}; + u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, + 0x24, 0x30, 0x48, 0x60, 0x6c}; u8 is40MHz = 0; u8 isShortGI = 0; - if (nDataRate < 12) - { + if (nDataRate < 12) { return CCKOFDMRate[nDataRate]; - } - else - { - if (nDataRate >= 0x10 && nDataRate <= 0x1f) - { + } else { + if (nDataRate >= 0x10 && nDataRate <= 0x1f) { is40MHz = 0; isShortGI = 0; - - } - else if (nDataRate >=0x20 && nDataRate <= 0x2f ) - { + } else if (nDataRate >= 0x20 && nDataRate <= 0x2f) { is40MHz = 1; isShortGI = 0; - } - else if (nDataRate >= 0x30 && nDataRate <= 0x3f ) - { + } else if (nDataRate >= 0x30 && nDataRate <= 0x3f) { is40MHz = 0; isShortGI = 1; - - } - else if (nDataRate >= 0x40 && nDataRate <= 0x4f ) - { + } else if (nDataRate >= 0x40 && nDataRate <= 0x4f) { is40MHz = 1; isShortGI = 1; - } return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; } } - - -bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) +bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) { bool retValue = false; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_network *net = &ieee->current_network; - if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - (net->ralink_cap_exist)) + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + (net->ralink_cap_exist)) + retValue = true; + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) || + (net->broadcom_cap_exist)) retValue = true; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| - (net->broadcom_cap_exist)) - retValue = true; else if (net->bssht.bdRT2RTAggregation) retValue = true; else @@ -316,38 +336,35 @@ bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device* ieee) +void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct rtllib_network* net = &ieee->current_network; - if (net->bssht.bdRT2RTAggregation){ + struct rtllib_network *net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation) { pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE; - } - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP) pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP; - } - } - else if (net->broadcom_cap_exist) + } else if (net->broadcom_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)/*|| - (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) */) + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - net->ralink_cap_exist) + else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + net->ralink_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; - else if ((net->atheros_cap_exist )|| - (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)|| + else if ((net->atheros_cap_exist) || + (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) || (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; - else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist) + else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) || + net->cisco_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || net->marvell_cap_exist) @@ -357,35 +374,35 @@ void HTIOTPeerDetermine(struct rtllib_device* ieee) else pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); + RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", + pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; - } +} -bool HTIOTActIsDisableMCS15(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { - bool retValue = false; - return retValue; + return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) +bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) { bool retValue = false; @@ -393,70 +410,65 @@ bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) } -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) +u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 retValue = false; - u8 boundary=59; + u8 boundary = 59; pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) - { - if (!(pHTInfo->bRegBW40MHz)) - { - if (ieee->current_network.mode != WIRELESS_MODE_B) - { + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (ieee->current_network.bssht.bdBandWidth == + HT_CHANNEL_WIDTH_20_40) { + if (!(pHTInfo->bRegBW40MHz)) { + if (ieee->current_network.mode != + WIRELESS_MODE_B) { pHTInfo->bWAIotBroadcom = true; - if (ieee->b_customer_lenovo_id == true) + if (ieee->b_customer_lenovo_id) boundary = 30; - if ( ieee->current_network.RSSI >= boundary) + if (ieee->current_network.RSSI >= + boundary) retValue = true; } - }else{ - ; } } } return retValue; } -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - { retValue = 1; - } return retValue; } -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -466,54 +478,48 @@ HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *netwo u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; - -} - -u8 - HTIOTActIsEDCABiasRx(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActDisableShortGI(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, + struct rtllib_network *network) +{ + u8 retValue = 0; + + return retValue; +} + +u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) retValue = 1; - } return retValue; } -u8 -HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -void -HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) +void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -527,81 +533,77 @@ HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) } -u8 -HTIOTActIsDisableTx40MHz(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsTxNoAggregation(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -u8 -HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool -HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -void HTResetIOTSetting( - struct rt_hi_throughput *pHTInfo -) +void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; pHTInfo->IOTRaFunc = 0; } - -void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) +void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, + u8 *len, u8 IsEncrypt, bool bAssoc) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_capab_ele *pCapELE = NULL; - if ((posHTCap == NULL) || (pHT == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + if ((posHTCap == NULL) || (pHT == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be " + "null in HTConstructCapabilityElement()\n"); return; } memset(posHTCap, 0, *len); - if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) - { + if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) { u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); pCapELE = (struct ht_capab_ele *)&(posHTCap[4]); *len = 30 + 2; - }else - { + } else { pCapELE = (struct ht_capab_ele *)posHTCap; *len = 26 + 2; } @@ -610,7 +612,7 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pCapELE->ChlWidth = 0; else - pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); + pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0); pCapELE->MimoPwrSave = pHT->SelfMimoPs; pCapELE->GreenField = 0; @@ -620,21 +622,20 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* pCapELE->TxSTBC = 1; pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; - pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; - pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); - pCapELE->PSMP = 0; - pCapELE->LSigTxopProtect = 0; + pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0; + pCapELE->DssCCk = ((pHT->bRegBW40MHz) ? (pHT->bRegSuppCCK ? 1 : 0) : 0); + pCapELE->PSMP = 0; + pCapELE->LSigTxopProtect = 0; - RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); + RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d " + "DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, + pCapELE->DssCCk); - if ( IsEncrypt) - { + if (IsEncrypt) { pCapELE->MPDUDensity = 7; pCapELE->MaxRxAMPDUFactor = 2; - } - else - { + } else { pCapELE->MaxRxAMPDUFactor = 3; pCapELE->MPDUDensity = 0; } @@ -658,67 +659,63 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) pCapELE->ShortGI40Mhz = 0; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - { + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { pCapELE->ChlWidth = 0; - pCapELE->MCS[1] = 0; } } - - - - - return; - } -void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) + +void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo, + u8 *len, u8 IsEncrypt) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo; - if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be " + "null in HTConstructInfoElement()\n"); return; } memset(posHTInfo, 0, *len); - if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) - { + if ((ieee->iw_mode == IW_MODE_ADHOC) || + (ieee->iw_mode == IW_MODE_MASTER)) { pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: - (ieee->current_network.channel<=6)? - HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); + pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false) ? + HT_EXTCHNL_OFFSET_NO_EXT : + (ieee->current_network.channel <= 6) + ? HT_EXTCHNL_OFFSET_UPPER : + HT_EXTCHNL_OFFSET_LOWER); pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; - pHTInfoEle->RIFS = 0; + pHTInfoEle->RIFS = 0; pHTInfoEle->PSMPAccessOnly = 0; pHTInfoEle->SrvIntGranularity = 0; - pHTInfoEle->OptMode = pHT->CurrentOpMode; + pHTInfoEle->OptMode = pHT->CurrentOpMode; pHTInfoEle->NonGFDevPresent = 0; pHTInfoEle->DualBeacon = 0; pHTInfoEle->SecondaryBeacon = 0; pHTInfoEle->LSigTxopProtectFull = 0; - pHTInfoEle->PcoActive = 0; - pHTInfoEle->PcoPhase = 0; + pHTInfoEle->PcoActive = 0; + pHTInfoEle->PcoPhase = 0; memset(pHTInfoEle->BasicMSC, 0, 16); *len = 22 + 2; - } - else - { + } else { *len = 0; } return; } -void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len) +void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, + u8 *len) { if (posRT2RTAgg == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in " + "HTConstructRT2RTAggElement()\n"); return; } memset(posRT2RTAgg, 0, *len); @@ -730,21 +727,20 @@ void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* *posRT2RTAgg = 0x30; - if (ieee->bSupportRemoteWakeUp) { + if (ieee->bSupportRemoteWakeUp) *posRT2RTAgg |= RT_HT_CAP_USE_WOW; - } *len = 6 + 2; return; } -u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) +u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { - u8 i; - if (pOperateMCS == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); + u8 i; + if (pOperateMCS == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null" + " in HT_PickMCSRate()\n"); return false; } @@ -752,14 +748,14 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) case IEEE_A: case IEEE_B: case IEEE_G: - for (i=0;i<=15;i++) - pOperateMCS[i] = 0; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = 0; break; case IEEE_N_24G: case IEEE_N_5G: - pOperateMCS[0] &=RATE_ADPT_1SS_MASK; - pOperateMCS[1] &=RATE_ADPT_2SS_MASK; - pOperateMCS[3] &=RATE_ADPT_MCS32_MASK; + pOperateMCS[0] &= RATE_ADPT_1SS_MASK; + pOperateMCS[1] &= RATE_ADPT_2SS_MASK; + pOperateMCS[3] &= RATE_ADPT_MCS32_MASK; break; default: break; @@ -769,145 +765,151 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) return true; } -u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter) +u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter) { u8 i, j; u8 bitMap; u8 mcsRate = 0; u8 availableMcsRate[16]; - if (pMCSRateSet == NULL || pMCSFilter == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + if (pMCSRateSet == NULL || pMCSFilter == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't " + "be null in HTGetHighestMCSRate()\n"); return false; } - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i]; - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (availableMcsRate[i] != 0) break; } if (i == 16) return false; - for (i = 0; i < 16; i++) - { - if (availableMcsRate[i] != 0) - { + for (i = 0; i < 16; i++) { + if (availableMcsRate[i] != 0) { bitMap = availableMcsRate[i]; - for (j = 0; j < 8; j++) - { - if ((bitMap%2) != 0) - { - if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) + for (j = 0; j < 8; j++) { + if ((bitMap%2) != 0) { + if (HTMcsToDataRate(ieee, (8*i+j)) > + HTMcsToDataRate(ieee, mcsRate)) mcsRate = (8*i+j); } bitMap = bitMap>>1; } } } - return (mcsRate|0x80); + return mcsRate | 0x80; } -u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS) +u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS) { - u8 i=0; - - for (i=0;i<=15;i++){ - pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i]&pSupportMCS[i]; - } - + u8 i; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i] & + pSupportMCS[i]; HT_PickMCSRate(ieee, pOperateMCS); if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pOperateMCS[1] = 0; - for (i=2; i<=15; i++) + for (i = 2; i <= 15; i++) pOperateMCS[i] = 0; return true; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct ht_capab_ele *pPeerHTCap = NULL; struct ht_info_ele *pPeerHTInfo = NULL; - u16 nMaxAMSDUSize = 0; - u8* pMcsFilter = NULL; + u16 nMaxAMSDUSize = 0; + u8 *pMcsFilter = NULL; - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; + static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; - if ( pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); + if (pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): " + "HT_DISABLE\n"); return; } RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); - if (!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) + if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap))) pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]); else pPeerHTCap = (struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf); if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - pPeerHTInfo = (struct ht_info_ele *)(&pHTInfo->PeerHTInfoBuf[4]); + pPeerHTInfo = (struct ht_info_ele *) + (&pHTInfo->PeerHTInfoBuf[4]); else pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); - HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); - pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap, + sizeof(struct ht_capab_ele)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), + (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); + pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? + true : false); - pHTInfo->bCurShortGI20MHz= - ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false); - pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false); + pHTInfo->bCurShortGI20MHz = ((pHTInfo->bRegShortGI20MHz) ? + ((pPeerHTCap->ShortGI20Mhz == 1) ? + true : false) : false); + pHTInfo->bCurShortGI40MHz = ((pHTInfo->bRegShortGI40MHz) ? + ((pPeerHTCap->ShortGI40Mhz == 1) ? + true : false) : false); - pHTInfo->bCurSuppCCK = - ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false); + pHTInfo->bCurSuppCCK = ((pHTInfo->bRegSuppCCK) ? + ((pPeerHTCap->DssCCk == 1) ? true : + false) : false); pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; - nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935; + nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935; - if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize ) + if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize) pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; else pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){ - if ( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) || - (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) ) + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) || + (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN)) pHTInfo->bCurrentAMPDUEnable = false; } - if (!pHTInfo->bRegRT2RTAggregation) - { + if (!pHTInfo->bRegRT2RTAggregation) { if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; } else { - if (ieee->current_network.bssht.bdRT2RTAggregation) - { - if ( ieee->pairwise_key_type != KEY_TYPE_NA) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + if (ieee->current_network.bssht.bdRT2RTAggregation) { + if (ieee->pairwise_key_type != KEY_TYPE_NA) + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; - }else - { + } else { if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; } @@ -916,8 +918,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; else pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; - if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) - { + if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; pHTInfo->ForcedAMSDUMaxSize = 7935; @@ -927,7 +928,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) if (pPeerHTCap->MCS[0] == 0) pPeerHTCap->MCS[0] = 0xff; - HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0)); + HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1]) != 0)); HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); @@ -936,15 +937,14 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pMcsFilter = MCS_FILTER_1SS; else pMcsFilter = MCS_FILTER_ALL; - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, pMcsFilter); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } -void HTSetConnectBwModeCallback(struct rtllib_device* ieee); -void HTInitializeHTInfo(struct rtllib_device* ieee) +void HTInitializeHTInfo(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -965,10 +965,14 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); - memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); - memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); - memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); + memset((void *)(&(pHTInfo->SelfHTCap)), 0, + sizeof(pHTInfo->SelfHTCap)); + memset((void *)(&(pHTInfo->SelfHTInfo)), 0, + sizeof(pHTInfo->SelfHTInfo)); + memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0, + sizeof(pHTInfo->PeerHTCapBuf)); + memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, + sizeof(pHTInfo->PeerHTInfoBuf)); pHTInfo->bSwBwInProgress = false; pHTInfo->ChnlOp = CHNLOP_NONE; @@ -984,12 +988,13 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->IOTRaFunc = 0; { - u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); RegHTSuppRateSets[0] = 0xFF; RegHTSuppRateSets[1] = 0xFF; RegHTSuppRateSets[4] = 0x01; } } + void HTInitializeBssDesc(struct bss_ht *pBssHT) { @@ -999,39 +1004,46 @@ void HTInitializeBssDesc(struct bss_ht *pBssHT) memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf)); pBssHT->bdHTInfoLen = 0; - pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE; + pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE; pBssHT->bdRT2RTAggregation = false; pBssHT->bdRT2RTLongSlotTime = false; pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0; } -void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 bIOTAction = 0; RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); - /*unmark bEnableHT flag here is the same reason why unmarked in function rtllib_softmac_new_net. WB 2008.09.10*/ - if (pNetwork->bssht.bdSupportHT) - { + /* unmark bEnableHT flag here is the same reason why unmarked in + * function rtllib_softmac_new_net. WB 2008.09.10*/ + if (pNetwork->bssht.bdSupportHT) { pHTInfo->bCurrentHTSupport = true; pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; - if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) - memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); + if (pNetwork->bssht.bdHTCapLen > 0 && + pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) + memcpy(pHTInfo->PeerHTCapBuf, + pNetwork->bssht.bdHTCapBuf, + pNetwork->bssht.bdHTCapLen); - if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) - memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen); + if (pNetwork->bssht.bdHTInfoLen > 0 && + pNetwork->bssht.bdHTInfoLen <= + sizeof(pHTInfo->PeerHTInfoBuf)) + memcpy(pHTInfo->PeerHTInfoBuf, + pNetwork->bssht.bdHTInfoBuf, + pNetwork->bssht.bdHTInfoLen); - if (pHTInfo->bRegRT2RTAggregation) - { - pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation; - pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime; + if (pHTInfo->bRegRT2RTAggregation) { + pHTInfo->bCurrentRT2RTAggregation = + pNetwork->bssht.bdRT2RTAggregation; + pHTInfo->bCurrentRT2RTLongSlotTime = + pNetwork->bssht.bdRT2RTLongSlotTime; pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode; - } - else - { + } else { pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; @@ -1057,7 +1069,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; - bIOTAction = HTIOTActIsMgntUseCCK6M(ieee,pNetwork); + bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; bIOTAction = HTIOTActIsCCDFsync(ieee); @@ -1072,23 +1084,22 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net pHTInfo->IOTAction = 0; pHTInfo->IOTRaFunc = 0; } - } -void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct ht_info_ele *pPeerHTInfo = (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; + struct ht_info_ele *pPeerHTInfo = + (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; - if (pHTInfo->bCurrentHTSupport) - { + if (pHTInfo->bCurrentHTSupport) { if (pNetwork->bssht.bdHTInfoLen != 0) pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } } -void HTUseDefaultSetting(struct rtllib_device* ieee) +void HTUseDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1097,14 +1108,13 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz; - pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz; + pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz; - pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz; + pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz; if (ieee->iw_mode == IW_MODE_ADHOC) - { - ieee->current_network.qos_data.active = ieee->current_network.qos_data.supported; - } + ieee->current_network.qos_data.active = + ieee->current_network.qos_data.supported; pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; @@ -1113,9 +1123,11 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; - - HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); + HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, + ieee->dot11HTOperationalRateSet); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, + MCS_FILTER_ALL); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; } else { @@ -1124,20 +1136,49 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) return; } -u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) +u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) { - if (ieee->pHTInfo->bCurrentHTSupport) - { - if ( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) - { - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED EXIST!!\n"); + if (ieee->pHTInfo->bCurrentHTSupport) { + if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) { + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED " + "EXIST!!\n"); return true; } } return false; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +{ + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); + if (pHTInfo->bCurBW40MHz) { + if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel + 2); + else if (pHTInfo->CurSTAExtChnlOffset == + HT_EXTCHNL_OFFSET_LOWER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel - 2); + else + ieee->set_chan(ieee->dev, + ieee->current_network.channel); + + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, + pHTInfo->CurSTAExtChnlOffset); + } else { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } + + pHTInfo->bSwBwInProgress = false; +} + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1145,18 +1186,18 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi return; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - Bandwidth=HT_CHANNEL_WIDTH_20; - + Bandwidth = HT_CHANNEL_WIDTH_20; if (pHTInfo->bSwBwInProgress) { - printk("%s: bSwBwInProgress!!\n", __func__); + printk(KERN_INFO "%s: bSwBwInProgress!!\n", __func__); return; } - if (Bandwidth==HT_CHANNEL_WIDTH_20_40) - { - if (ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Bandwidth == HT_CHANNEL_WIDTH_20_40) { + if (ieee->current_network.channel < 2 && + Offset == HT_EXTCHNL_OFFSET_LOWER) Offset = HT_EXTCHNL_OFFSET_NO_EXT; - if (Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) { + if (Offset == HT_EXTCHNL_OFFSET_UPPER || + Offset == HT_EXTCHNL_OFFSET_LOWER) { pHTInfo->bCurBW40MHz = true; pHTInfo->CurSTAExtChnlOffset = Offset; } else { @@ -1168,33 +1209,10 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; } - printk("%s():pHTInfo->bCurBW40MHz:%x\n", __func__, pHTInfo->bCurBW40MHz); + printk(KERN_INFO "%s():pHTInfo->bCurBW40MHz:%x\n", __func__, + pHTInfo->bCurBW40MHz); pHTInfo->bSwBwInProgress = true; HTSetConnectBwModeCallback(ieee); - -} - -void HTSetConnectBwModeCallback(struct rtllib_device* ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); - if (pHTInfo->bCurBW40MHz) - { - if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee->dev, ieee->current_network.channel+2); - else if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee->dev, ieee->current_network.channel-2); - else - ieee->set_chan(ieee->dev, ieee->current_network.channel); - - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset); - } else { - ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } - - pHTInfo->bSwBwInProgress = false; } From f88ec6cbc1db3fbe5890250a37f5065506b5989c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:18 -0500 Subject: [PATCH 0547/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VI Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_Qos.h | 245 +++++++------- drivers/staging/rtl8192e/rtl819x_TS.h | 2 + drivers/staging/rtl8192e/rtl819x_TSProc.c | 369 ++++++++++------------ 3 files changed, 310 insertions(+), 306 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 0d2f8bff474..5ecd556f079 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -21,38 +21,38 @@ #include "rtllib_endianfree.h" -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 union qos_tsinfo { u8 charData[3]; @@ -67,14 +67,13 @@ union qos_tsinfo { u8 ucTSInfoAckPolicy:2; u8 ucSchedule:1; u8 ucReserved:7; - }field; + } field; }; union tspec_body { u8 charData[55]; - struct - { + struct { union qos_tsinfo TSInfo; u16 NominalMSDUsize; u16 MaxMSDUsize; @@ -105,9 +104,10 @@ struct wmm_tspec { }; struct octet_string { - u8 *Octet; - u16 Length; + u8 *Octet; + u16 Length; }; + #define MAX_WMMELE_LENGTH 64 #define QOS_MODE u32 @@ -143,28 +143,43 @@ enum ack_policy { }; -#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) +#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) \ + WriteEF1Byte(_pStart, _val) -#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4) -#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) +#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 4) +#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) -#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1) -#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 7, 1) +#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 1, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 2, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 3, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) -#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 5, 2) +#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) enum qos_ie_source { QOSIE_SRC_ADDTSREQ, @@ -186,26 +201,40 @@ enum qos_ie_source { #define AC_PARAM_SIZE 4 -#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) ) -#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) +#define GET_WMM_AC_PARAM_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 4)) +#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) -#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) ) -#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) +#define GET_WMM_AC_PARAM_ACM(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 4, 1)) +#define SET_WMM_AC_PARAM_ACM(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) -#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) ) -#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) +#define GET_WMM_AC_PARAM_ACI(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 5, 2)) +#define SET_WMM_AC_PARAM_ACI(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) -#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) ) -#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) +#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 8)) +#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) -#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) ) -#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) +#define GET_WMM_AC_PARAM_ECWMIN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 8, 4)) +#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) -#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) ) -#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) +#define GET_WMM_AC_PARAM_ECWMAX(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 12, 4)) +#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) -#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) ) -#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) +#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 16, 16)) +#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) @@ -255,13 +284,13 @@ struct acm { union qos_tclas { - struct _TYPE_GENERAL{ + struct _TYPE_GENERAL { u8 Priority; u8 ClassifierType; u8 Mask; } TYPE_GENERAL; - struct _TYPE0_ETH{ + struct _TYPE0_ETH { u8 Priority; u8 ClassifierType; u8 Mask; @@ -270,7 +299,7 @@ union qos_tclas { u16 Type; } TYPE0_ETH; - struct _TYPE1_IPV4{ + struct _TYPE1_IPV4 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -284,7 +313,7 @@ union qos_tclas { u8 Reserved; } TYPE1_IPV4; - struct _TYPE1_IPV6{ + struct _TYPE1_IPV6 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -296,7 +325,7 @@ union qos_tclas { u8 FlowLabel[3]; } TYPE1_IPV6; - struct _TYPE2_8021Q{ + struct _TYPE2_8021Q { u8 Priority; u8 ClassifierType; u8 Mask; @@ -317,20 +346,20 @@ struct qos_tstream { }; struct sta_qos { - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8* WMMIE; + u8 WMMIEBuf[MAX_WMMELE_LENGTH]; + u8 *WMMIE; - QOS_MODE QosCapability; - QOS_MODE CurrentQosMode; + QOS_MODE QosCapability; + QOS_MODE CurrentQosMode; - AC_UAPSD b4ac_Uapsd; - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; + AC_UAPSD b4ac_Uapsd; + AC_UAPSD Curr4acUapsd; + u8 bInServicePeriod; + u8 MaxSPLength; + int NumBcnBeforeTrigger; - u8 * pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; + u8 *pWMMInfoEle; + u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; struct acm acm[4]; enum acm_method AcmMethod; @@ -347,67 +376,69 @@ struct sta_qos { }; -#define QBSS_LOAD_SIZE 5 -#define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) -#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value) -#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2) -#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value) -#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3) -#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value) +#define QBSS_LOAD_SIZE 5 +#define GET_QBSS_LOAD_STA_COUNT(__pStart) \ + ReadEF2Byte(__pStart) +#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) \ + WriteEF2Byte(__pStart, __Value) +#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) \ + ReadEF1Byte((u8 *)(__pStart) + 2) +#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) \ + WriteEF1Byte((u8 *)(__pStart) + 2, __Value) +#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) \ + ReadEF2Byte((u8 *)(__pStart) + 3) +#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) \ + WriteEF2Byte((u8 *)(__pStart) + 3, __Value) struct bss_qos { - - QOS_MODE bdQoSMode; - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; + QOS_MODE bdQoSMode; + u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; struct octet_string bdWMMIE; enum qos_ele_subtype EleSubType; - u8* pWMMInfoEle; - u8* pWMMParamEle; + u8 *pWMMInfoEle; + u8 *pWMMParamEle; - u8 QBssLoad[QBSS_LOAD_SIZE]; - bool bQBssLoadValid; + u8 QBssLoad[QBSS_LOAD_SIZE]; + bool bQBssLoadValid; }; #define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) +#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0) -#define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false ) +#define IsACValid(ac) ((ac >= 0 && ac <= 7) ? true : false) union aci_aifsn { u8 charData; - struct - { + struct { u8 AIFSN:4; u8 acm:1; u8 ACI:2; u8 Reserved:1; - }f; + } f; }; union ecw { u8 charData; - struct - { + struct { u8 ECWmin:4; u8 ECWmax:4; - }f; + } f; }; union ac_param { u32 longData; u8 charData[4]; - struct - { + struct { union aci_aifsn AciAifsn; union ecw Ecw; u16 TXOPLimit; - }f; + } f; }; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index b4bebab3632..8601b1ad217 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -67,5 +67,7 @@ struct rx_ts_record { u8 num; }; +void _setup_timer(struct timer_list *, void *, unsigned long); + #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index a6dbd26c691..519349f0ce4 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -19,7 +19,6 @@ #include "rtllib.h" #include #include "rtl819x_TS.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long); void TsSetupTimeOut(unsigned long data) { @@ -32,7 +31,8 @@ void TsInactTimeout(unsigned long data) void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); struct rx_reorder_entry *pReorderEntry = NULL; @@ -42,51 +42,57 @@ void RxPktPendingTimeout(unsigned long data) bool bPktInBuf = false; spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - if (pRxTs->RxTimeoutIndicateSeq != 0xffff) - { - while(!list_empty(&pRxTs->RxPendingPktList)) - { - pReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTs->RxPendingPktList.prev,struct rx_reorder_entry,List); + if (pRxTs->RxTimeoutIndicateSeq != 0xffff) { + while (!list_empty(&pRxTs->RxPendingPktList)) { + pReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTs->RxPendingPktList.prev, + struct rx_reorder_entry, List); if (index == 0) pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; - if ( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) - { + if (SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) { list_del_init(&pReorderEntry->List); - if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) - pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; + if (SN_EQUAL(pReorderEntry->SeqNum, + pRxTs->RxIndicateSeq)) + pRxTs->RxIndicateSeq = + (pRxTs->RxIndicateSeq + 1) % 4096; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, pReorderEntry->SeqNum); - stats_IndicateArray[index] = pReorderEntry->prxb; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate" + " SeqNum: %d\n", __func__, + pReorderEntry->SeqNum); + stats_IndicateArray[index] = + pReorderEntry->prxb; index++; - list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); - } - else - { + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); + } else { bPktInBuf = true; break; } } } - if (index>0){ + if (index > 0) { pRxTs->RxTimeoutIndicateSeq = 0xffff; - if (index > REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, stats_IndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){ + if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) { pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; - mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); + mod_timer(&pRxTs->RxPktPendingTimer, jiffies + + MSECS(ieee->pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } @@ -95,13 +101,14 @@ void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[num]); TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is " + "started!!\n"); } - void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); @@ -142,8 +149,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pTxTS->num = count; _setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, @@ -173,8 +179,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); @@ -195,13 +200,14 @@ void TSInitialize(struct rtllib_device *ieee) (unsigned long) pRxTS); ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); + list_add_tail(&pRxTS->TsCommonInfo.List, + &ieee->Rx_TS_Unused_List); pRxTS++; } INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); - for (count = 0; count < REORDER_ENTRY_NUM; count++) - { - list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + for (count = 0; count < REORDER_ENTRY_NUM; count++) { + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); if (count == (REORDER_ENTRY_NUM-1)) break; pRxReorderEntry = &ieee->RxReorderEntry[count+1]; @@ -209,55 +215,46 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) +void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, + u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); - if (InactTime!=0) - mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); + if (InactTime != 0) + mod_timer(&pTsCommonInfo->InactTimer, jiffies + + MSECS(InactTime)); } - -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, enum tr_select TxRxSelect) +struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, + u8 TID, enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; - struct list_head* psearch_list; + bool search_dir[4] = {0, 0, 0, 0}; + struct list_head *psearch_list; struct ts_common_info *pRet = NULL; - if (ieee->iw_mode == IW_MODE_MASTER) - { - if (TxRxSelect == TX_DIR) - { + if (ieee->iw_mode == IW_MODE_MASTER) { + if (TxRxSelect == TX_DIR) { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; + search_dir[DIR_BI_DIR] = true; + } else { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; } - else - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - } - } - else if (ieee->iw_mode == IW_MODE_ADHOC) - { + } else if (ieee->iw_mode == IW_MODE_ADHOC) { if (TxRxSelect == TX_DIR) - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; else search_dir[DIR_DOWN] = true; - } - else - { - if (TxRxSelect == TX_DIR) - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; - } - else - { + } else { + if (TxRxSelect == TX_DIR) { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; + } else { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; } } @@ -266,38 +263,29 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, else psearch_list = &ieee->Rx_TS_Admit_List; - for (dir = 0; dir <= DIR_BI_DIR; dir++) - { - if (search_dir[dir] ==false ) + for (dir = 0; dir <= DIR_BI_DIR; dir++) { + if (search_dir[dir] == false) continue; - list_for_each_entry(pRet, psearch_list, List){ + list_for_each_entry(pRet, psearch_list, List) { if (memcmp(pRet->Addr, Addr, 6) == 0) if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) if (pRet->TSpec.f.TSInfo.field.ucDirection == dir) - { break; - } } if (&pRet->List != psearch_list) break; } - if (&pRet->List != psearch_list){ + if (&pRet->List != psearch_list) return pRet ; - } else return NULL; } -void MakeTSEntry( - struct ts_common_info *pTsCommonInfo, - u8* Addr, - union tspec_body *pTSPEC, - union qos_tclas *pTCLAS, - u8 TCLAS_Num, - u8 TCLAS_Proc - ) +void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -307,34 +295,32 @@ void MakeTSEntry( memcpy(pTsCommonInfo->Addr, Addr, 6); if (pTSPEC != NULL) - memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(union tspec_body)); + memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC, + sizeof(union tspec_body)); for (count = 0; count < TCLAS_Num; count++) - memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(union qos_tclas)); + memcpy((u8 *)(&(pTsCommonInfo->TClass[count])), + (u8 *)pTCLAS, sizeof(union qos_tclas)); pTsCommonInfo->TClasProc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; } -bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs) +bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, + u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) { u8 UP = 0; - if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n"); + if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or " + "Multicast\n"); return false; } if (ieee->current_network.qos_data.supported == 0) { UP = 0; } else { if (!IsACValid(TID)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __func__, TID); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is " + "not valid\n", __func__, TID); return false; } @@ -358,55 +344,54 @@ bool GetTs( } } - *ppTS = SearchAdmitTRStream( - ieee, - Addr, - UP, - TxRxSelect); - if (*ppTS != NULL) - { + *ppTS = SearchAdmitTRStream(ieee, Addr, UP, TxRxSelect); + if (*ppTS != NULL) { return true; - } - else - { - if (bAddNewTs == false) - { - RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP); + } else { + if (bAddNewTs == false) { + RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed" + "(tid:%d)\n", UP); return false; - } - else - { + } else { union tspec_body TSpec; union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; - struct list_head* pUnusedList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Unused_List): - (&ieee->Rx_TS_Unused_List); + struct list_head *pUnusedList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Unused_List) : + (&ieee->Rx_TS_Unused_List); - struct list_head* pAddmitList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Admit_List): - (&ieee->Rx_TS_Admit_List); + struct list_head *pAddmitList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Admit_List) : + (&ieee->Rx_TS_Admit_List); - enum direction_value Dir = (ieee->iw_mode == IW_MODE_MASTER)? - ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): - ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); + enum direction_value Dir = + (ieee->iw_mode == IW_MODE_MASTER) ? + ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) : + ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN); RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); - if (!list_empty(pUnusedList)) - { - (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); + if (!list_empty(pUnusedList)) { + (*ppTS) = list_entry(pUnusedList->next, + struct ts_common_info, List); list_del_init(&(*ppTS)->List); - if (TxRxSelect==TX_DIR) - { - struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *tmp = + container_of(*ppTS, + struct tx_ts_record, + TsCommonInfo); ResetTxTsEntry(tmp); - } - else{ - struct rx_ts_record *tmp = container_of(*ppTS, struct rx_ts_record, TsCommonInfo); + } else { + struct rx_ts_record *tmp = + container_of(*ppTS, + struct rx_ts_record, + TsCommonInfo); ResetRxTsEntry(tmp); } - RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS); + RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" + ", UP:%d, Dir:%d, addr:"MAC_FMT + " ppTs=%p\n", UP, Dir, + MAC_ARG(Addr), *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -422,99 +407,90 @@ bool GetTs( list_add_tail(&((*ppTS)->List), pAddmitList); return true; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __func__,Dir); + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function " + "%s() There is not enough dir=%d" + "(0=up down=1) TS record to be " + "used!!", __func__, Dir); return false; } } } } -void RemoveTsEntry( - struct rtllib_device* ieee, - struct ts_common_info *pTs, - enum tr_select TxRxSelect - ) +void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); TsInitDelBA(ieee, pTs, TxRxSelect); - if (TxRxSelect == RX_DIR) - { + if (TxRxSelect == RX_DIR) { struct rx_reorder_entry *pRxReorderEntry; struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if (timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); - while(!list_empty(&pRxTS->RxPendingPktList)){ - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + while (!list_empty(&pRxTS->RxPendingPktList)) { + pRxReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Delete SeqNum " + "%d!\n", __func__, + pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); { int i = 0; - struct rtllib_rxb * prxb = pRxReorderEntry->prxb; - if (unlikely(!prxb)){ + struct rtllib_rxb *prxb = pRxReorderEntry->prxb; + if (unlikely(!prxb)) return; - } - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } - list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); } - } - else{ + } else { struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; del_timer_sync(&pTxTS->TsAddBaTimer); } } -void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) +void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - printk("====>remove Tx_TS_admin_list\n"); + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { + printk(KERN_INFO "====>remove Tx_TS_admin_list\n"); RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); @@ -522,56 +498,51 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) } } -void RemoveAllTS(struct rtllib_device* ieee) +void RemoveAllTS(struct rtllib_device *ieee) { struct ts_common_info *pTS, *pTmpTS; - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } -void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS) +void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS) { - if (pTxTS->bAddBaReqInProgress == false) - { + if (pTxTS->bAddBaReqInProgress == false) { pTxTS->bAddBaReqInProgress = true; - if (pTxTS->bAddBaReqDelayed) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + if (pTxTS->bAddBaReqDelayed) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Delayed Start ADDBA after 60 sec!!\n"); + mod_timer(&pTxTS->TsAddBaTimer, jiffies + + MSECS(TS_ADDBA_DELAY)); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Immediately Start ADDBA now!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); } - } - else - RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__); + } else + RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", + __func__); } From b6da7313e0a7c436d1a1f89ec24950031820867a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:19 -0500 Subject: [PATCH 0548/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VII Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_cam.c | 325 +++++++++++------------------ drivers/staging/rtl8192e/rtl_cam.h | 10 +- 2 files changed, 132 insertions(+), 203 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index 4a11b30d184..a9991a0fa1c 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -40,12 +40,12 @@ void CamResetAllEntry(struct net_device *dev) void write_cam(struct net_device *dev, u8 addr, u32 data) { write_nic_dword(dev, WCAMI, data); - write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) ); + write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff)); } u32 read_cam(struct net_device *dev, u8 addr) { - write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) ); + write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff)); return read_nic_dword(dev, 0xa8); } @@ -53,66 +53,53 @@ void EnableHWSecurityConfig8192(struct net_device *dev) { u8 SECR_value = 0x0; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->rtllib->auth_mode != 2)) - { + if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && + (priv->rtllib->auth_mode != 2)) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { + } else if ((ieee->iw_mode == IW_MODE_ADHOC) && + (ieee->pairwise_key_type & (KEY_TYPE_CCMP | + KEY_TYPE_TKIP))) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; } ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) - { + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__, \ - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(dev, SECR, SECR_value); - } + RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", + __func__, ieee->hwsec_active, ieee->pairwise_key_type, + SECR_value); + write_nic_byte(dev, SECR, SECR_value); } -void set_swcam(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent, - u8 is_mesh) +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is " "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo, KeyIndex, KeyType, is_mesh); - if (is_mesh){ - } else { - ieee->swcamtable[EntryNo].bused=true; - ieee->swcamtable[EntryNo].key_index=KeyIndex; - ieee->swcamtable[EntryNo].key_type=KeyType; - memcpy(ieee->swcamtable[EntryNo].macaddr,MacAddr,6); - ieee->swcamtable[EntryNo].useDK=DefaultKey; - memcpy(ieee->swcamtable[EntryNo].key_buf,(u8*)KeyContent,16); + if (!is_mesh) { + ieee->swcamtable[EntryNo].bused = true; + ieee->swcamtable[EntryNo].key_index = KeyIndex; + ieee->swcamtable[EntryNo].key_type = KeyType; + memcpy(ieee->swcamtable[EntryNo].macaddr, MacAddr, 6); + ieee->swcamtable[EntryNo].useDK = DefaultKey; + memcpy(ieee->swcamtable[EntryNo].key_buf, (u8 *)KeyContent, 16); } } -void setKey(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent ) +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) { u32 TargetCommand = 0; u32 TargetContent = 0; @@ -121,17 +108,17 @@ void setKey(struct net_device *dev, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return ; - } - else{ + } else { down(&priv->rtllib->ips_sem); IPSLeave(dev); - up(&priv->rtllib->ips_sem); } + up(&priv->rtllib->ips_sem); + } } } priv->rtllib->is_set_key = true; @@ -139,7 +126,7 @@ void setKey(struct net_device *dev, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev,EntryNo, KeyIndex, + "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, KeyType, MAC_ARG(MacAddr)); if (DefaultKey) @@ -149,227 +136,167 @@ void setKey(struct net_device *dev, for (i = 0; i < CAM_CONTENT_COUNT; i++) { - TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; + TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; TargetCommand |= BIT31|BIT16; if (i == 0) { - TargetContent = (u32)(*(MacAddr+0)) << 16| - (u32)(*(MacAddr+1)) << 24| + TargetContent = (u32)(*(MacAddr+0)) << 16 | + (u32)(*(MacAddr+1)) << 24 | (u32)usConfig; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else if (i == 1) { - TargetContent = (u32)(*(MacAddr+2)) | - (u32)(*(MacAddr+3)) << 8| - (u32)(*(MacAddr+4)) << 16| + TargetContent = (u32)(*(MacAddr+2)) | + (u32)(*(MacAddr+3)) << 8 | + (u32)(*(MacAddr+4)) << 16 | (u32)(*(MacAddr+5)) << 24; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else { if (KeyContent != NULL) { - write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); + write_nic_dword(dev, WCAMI, + (u32)(*(KeyContent+i-2))); write_nic_dword(dev, RWCAM, TargetCommand); udelay(100); } } } - RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig); + RT_TRACE(COMP_SEC, "=========>after set key, usconfig:%x\n", usConfig); } void CAM_read_entry(struct net_device *dev, u32 iIndex) { - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; - s32 i=100; - for (entry_i=0;entry_i=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); - RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A0: %x\n", + target_command); target_content = read_nic_dword(dev, RCAMO); - RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x\n", + target_content); } - printk("\n"); + printk(KERN_INFO "\n"); } -void CamRestoreAllEntry( struct net_device *dev) +void CamRestoreAllEntry(struct net_device *dev) { u8 EntryId = 0; struct r8192_priv *priv = rtllib_priv(dev); - u8* MacAddr = priv->rtllib->current_network.bssid; + u8 *MacAddr = priv->rtllib->current_network.bssid; static u8 CAM_CONST_ADDR[4][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}; - static u8 CAM_CONST_BROAD[] = - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} + }; + static u8 CAM_CONST_BROAD[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; - RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n"); + RT_TRACE(COMP_SEC, "CamRestoreAllEntry:\n"); - if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40)|| - (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) - { + if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40) || + (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) { - for (EntryId=0; EntryId<4; EntryId++) - { - { - MacAddr = CAM_CONST_ADDR[EntryId]; - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); - } + for (EntryId = 0; EntryId < 4; EntryId++) { + MacAddr = CAM_CONST_ADDR[EntryId]; + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable + [EntryId].key_buf[0])); } } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) - { - - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); + } else { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) - { - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); + } else { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - } } - - - if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) - { + if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1 ; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId, - EntryId, - priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId, EntryId, + priv->rtllib->group_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) + ); } } - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - if (priv->rtllib->swcamtable[0].bused ){ - setKey(dev, - 0, - 0, - priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0]) - ); - } - else - { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",__func__); + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + if (priv->rtllib->swcamtable[0].bused) { + setKey(dev, 0, 0, + priv->rtllib->group_key_type, + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]) + ); + } else { + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC TKIP " + ",but 0 entry is have no data\n", + __func__); return; } } } else if (priv->rtllib->group_key_type == KEY_TYPE_CCMP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); } } if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { if (priv->rtllib->swcamtable[0].bused) { - setKey(dev, - 0 , - 0, + setKey(dev, 0 , 0, priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0])); + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])); } else { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n", - __func__); + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC CCMP ," + "but 0 entry is have no data\n", + __func__); return; } } diff --git a/drivers/staging/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl_cam.h index 9e4d0edb21b..fa607f98b17 100644 --- a/drivers/staging/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl_cam.h @@ -28,11 +28,13 @@ #include struct net_device; -void CamResetAllEntry(struct net_device* dev); +void CamResetAllEntry(struct net_device *dev); void EnableHWSecurityConfig8192(struct net_device *dev); -void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent ); -void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); -void CamPrintDbgReg(struct net_device* dev); +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); +void CamPrintDbgReg(struct net_device *dev); u32 read_cam(struct net_device *dev, u8 addr); void write_cam(struct net_device *dev, u8 addr, u32 data); From 1344ee25917bdde1a28719db3c07b3ccde3f42e9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:20 -0500 Subject: [PATCH 0549/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VIII Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 2357 ++++++++++++++------------- drivers/staging/rtl8192e/rtl_core.h | 683 ++++---- 2 files changed, 1537 insertions(+), 1503 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 7d8a15c685d..9554eef1fcb 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -41,7 +41,7 @@ #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC -#include +#include #include #include #include "rtl_core.h" @@ -59,26 +59,26 @@ int hwwep = 1; static int channels = 0x3fff; -char* ifname = "wlan%d"; +char *ifname = "wlan%d"; struct rtl819x_ops rtl819xp_ops = { - .nic_type = NIC_8192E, - .get_eeprom_size = rtl8192_get_eeprom_size, + .nic_type = NIC_8192E, + .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, - .initialize_adapter = rtl8192_adapter_start, - .link_change = rtl8192_link_change, - .tx_fill_descriptor = rtl8192_tx_fill_desc, - .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, + .initialize_adapter = rtl8192_adapter_start, + .link_change = rtl8192_link_change, + .tx_fill_descriptor = rtl8192_tx_fill_desc, + .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, .rx_query_status_descriptor = rtl8192_rx_query_status_desc, .rx_command_packet_handler = NULL, - .stop_adapter = rtl8192_halt_adapter, - .update_ratr_table = rtl8192_update_ratr_table, - .irq_enable = rtl8192_EnableInterrupt, - .irq_disable = rtl8192_DisableInterrupt, - .irq_clear = rtl8192_ClearInterrupt, - .rx_enable = rtl8192_enable_rx, - .tx_enable = rtl8192_enable_tx, + .stop_adapter = rtl8192_halt_adapter, + .update_ratr_table = rtl8192_update_ratr_table, + .irq_enable = rtl8192_EnableInterrupt, + .irq_disable = rtl8192_DisableInterrupt, + .irq_clear = rtl8192_ClearInterrupt, + .rx_enable = rtl8192_enable_rx, + .tx_enable = rtl8192_enable_tx, .interrupt_recognized = rtl8192_interrupt_recognized, .TxCheckStuckHandler = rtl8192_HalTxCheckStuck, .RxCheckStuckHandler = rtl8192_HalRxCheckStuck, @@ -94,130 +94,110 @@ static struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); + const struct pci_device_id *id); static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); static struct pci_driver rtl8192_pci_driver = { - .name = DRV_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = rtl8192_pci_probe, /* probe fn */ - .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ - .suspend = rtl8192E_suspend, /* PM suspend fn */ - .resume = rtl8192E_resume, /* PM resume fn */ + .name = DRV_NAME, /* Driver name */ + .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ + .probe = rtl8192_pci_probe, /* probe fn */ + .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ + .suspend = rtl8192E_suspend, /* PM suspend fn */ + .resume = rtl8192E_resume, /* PM resume fn */ }; /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool -PlatformIOCheckPageLegalAndGetRegMask( - u32 u4bPage, - u8* pu1bPageMask -) +bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; + *pu1bPageMask = 0xfe; - switch (u4bPage) - { - case 1: case 2: case 3: case 4: - case 8: case 9: case 10: case 12: case 13: - bReturn = true; - *pu1bPageMask = 0xf0; - break; + switch (u4bPage) { + case 1: case 2: case 3: case 4: + case 8: case 9: case 10: case 12: case 13: + bReturn = true; + *pu1bPageMask = 0xf0; + break; - default: - bReturn = false; - break; + default: + bReturn = false; + break; } return bReturn; } -void write_nic_io_byte(struct net_device *dev, int x,u8 y) +void write_nic_io_byte(struct net_device *dev, int x, u8 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outb(y&0xff,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outb(y&0xff, dev->base_addr + x); + + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_byte(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - - } -void write_nic_io_word(struct net_device *dev, int x,u16 y) +void write_nic_io_word(struct net_device *dev, int x, u16 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outw(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outw(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_word(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } - } -void write_nic_io_dword(struct net_device *dev, int x,u32 y) +void write_nic_io_dword(struct net_device *dev, int x, u32 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outl(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outl(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_dword(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - } + u8 read_nic_io_byte(struct net_device *dev, int x) { u32 u4bPage = (x >> 8); @@ -225,23 +205,18 @@ u8 read_nic_io_byte(struct net_device *dev, int x) bool bIsLegalPage = false; u8 Data = 0; - if (u4bPage == 0) - { - return 0xff&inb(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return 0xff&inb(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_byte(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } @@ -255,23 +230,19 @@ u16 read_nic_io_word(struct net_device *dev, int x) bool bIsLegalPage = false; u16 Data = 0; - if (u4bPage == 0) - { - return inw(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inw(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_word(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -285,23 +256,19 @@ u32 read_nic_io_dword(struct net_device *dev, int x) bool bIsLegalPage = false; u32 Data = 0; - if (u4bPage == 0) - { - return inl(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inl(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_dword(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -310,36 +277,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff&readb((u8*)dev->mem_start +x); + return 0xff & readb((u8 *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8*)dev->mem_start +x); + return readl((u8 *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8*)dev->mem_start +x); + return readw((u8 *)dev->mem_start + x); } -void write_nic_byte(struct net_device *dev, int x,u8 y) +void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y,(u8*)dev->mem_start +x); + writeb(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_dword(struct net_device *dev, int x,u32 y) +void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y,(u8*)dev->mem_start +x); + writel(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_word(struct net_device *dev, int x,u16 y) +void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y,(u8*)dev->mem_start +x); + writew(y, (u8 *)dev->mem_start + x); udelay(20); } @@ -347,106 +314,101 @@ void write_nic_word(struct net_device *dev, int x,u16 y) /**************************************************************************** -----------------------------GENERAL FUNCTION------------------------- *****************************************************************************/ -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ) +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device * ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; bool bActionAllowed = false; bool bConnectBySSID = false; enum rt_rf_power_state rtState; u16 RFWaitCounter = 0; unsigned long flag; - RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); + RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): " + "StateToSet(%d)\n", StateToSet); ProtectOrNot = false; - if (!ProtectOrNot) - { - while(true) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet); + if (!ProtectOrNot) { + while (true) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): RF Change in " + "progress! Wait to set..StateToSet" + "(%d).\n", StateToSet); - while(priv->RFChangeInProgress) - { - RFWaitCounter ++; - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Wait 1 ms (%d times)...\n", RFWaitCounter); - mdelay(1); + while (priv->RFChangeInProgress) { + RFWaitCounter++; + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): Wait 1" + " ms (%d times)...\n", + RFWaitCounter); + mdelay(1); - if (RFWaitCounter > 100) - { - RT_TRACE(COMP_ERR, "MgntActSet_RF_State(): Wait too logn to set RF\n"); - return false; + if (RFWaitCounter > 100) { + RT_TRACE(COMP_ERR, "MgntActSet_" + "RF_State(): Wait too " + "logn to set RF\n"); + return false; + } } + } else { + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + break; } } - else - { - priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - break; - } - } } rtState = priv->rtllib->eRFPowerState; - switch (StateToSet) - { + switch (StateToSet) { case eRfOn: - priv->rtllib->RfOffReason &= (~ChangeSource); - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == true)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == true)) priv->bHwRadioOff = false; - } - if (! priv->rtllib->RfOffReason) - { + if (!priv->rtllib->RfOffReason) { priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >=RF_CHANGE_BY_HW ) - { + if (rtState == eRfOff && + ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; - } - } - else{ - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", priv->rtllib->RfOffReason, ChangeSource); - } + } else { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - " + "eRfon reject pMgntInfo->RfOffReason= 0x%x," + " ChangeSource=0x%X\n", + priv->rtllib->RfOffReason, ChangeSource); + } break; case eRfOff: - if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || (priv->rtllib->iw_mode == IW_MODE_ADHOC)) - { - if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || (ChangeSource > RF_CHANGE_BY_IPS)) - { + if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || + (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { + if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || + (ChangeSource > RF_CHANGE_BY_IPS)) { if (ieee->state == RTLLIB_LINKED) priv->blinked_ingpio = true; else priv->blinked_ingpio = false; - rtllib_MgntDisconnect(priv->rtllib,disas_lv_ss); - - - + rtllib_MgntDisconnect(priv->rtllib, + disas_lv_ss); } } - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == false)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == false)) priv->bHwRadioOff = true; - } priv->rtllib->RfOffReason |= ChangeSource; bActionAllowed = true; break; @@ -460,29 +422,30 @@ MgntActSet_RF_State( break; } - if (bActionAllowed) - { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->rtllib->RfOffReason); + if (bActionAllowed) { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is" + " allowed.... StateToSet(%d), RfOffReason(%#X)\n", + StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); - if (StateToSet == eRfOn) - { + if (StateToSet == eRfOn) { - if (bConnectBySSID && (priv->blinked_ingpio == true)) - { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + if (bConnectBySSID && (priv->blinked_ingpio == true)) { + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); priv->blinked_ingpio = false; - } } } else { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->rtllib->RfOffReason); + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): " + "Action is rejected.... StateToSet(%d), ChangeSource" + "(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, + priv->rtllib->RfOffReason); } - if (!ProtectOrNot) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + if (!ProtectOrNot) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); } RT_TRACE((COMP_PS && COMP_RF), "<===MgntActSet_RF_State()\n"); @@ -492,36 +455,35 @@ MgntActSet_RF_State( short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - /* For now, we reserved two free descriptor as a safety boundary - * between the tail and the head - */ - if ((prio == MGNT_QUEUE) &&(skb_queue_len(&ring->queue)>10)) - RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d queue_len=%d---------\n", - prio,ring->idx, skb_queue_len(&ring->queue)); - return skb_queue_len(&ring->queue); + /* For now, we reserved two free descriptor as a safety boundary + * between the tail and the head + */ + if ((prio == MGNT_QUEUE) && (skb_queue_len(&ring->queue) > 10)) + RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d " + "queue_len=%d---------\n", prio, ring->idx, + skb_queue_len(&ring->queue)); + return skb_queue_len(&ring->queue); } short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - if (ring->entries - skb_queue_len(&ring->queue) >= 2) { - return 1; - } else { - return 0; - } + if (ring->entries - skb_queue_len(&ring->queue) >= 2) + return 1; + return 0; } void rtl8192_tx_timeout(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - schedule_work(&priv->reset_wq); - printk("TXTIMEOUT"); + schedule_work(&priv->reset_wq); + printk(KERN_INFO "TXTIMEOUT"); } void rtl8192_irq_enable(struct net_device *dev) @@ -549,136 +511,137 @@ void rtl8192_irq_clear(struct net_device *dev) } -void rtl8192_set_chan(struct net_device *dev,short ch) +void rtl8192_set_chan(struct net_device *dev, short ch) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); - if (priv->chan_forced) - return; + RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); + if (priv->chan_forced) + return; - priv->chan = ch; + priv->chan = ch; - if (priv->rf_set_chan) - priv->rf_set_chan(dev,priv->chan); + if (priv->rf_set_chan) + priv->rf_set_chan(dev, priv->chan); } -void rtl8192_update_cap(struct net_device* dev, u16 cap) +void rtl8192_update_cap(struct net_device *dev, u16 cap) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; + bool ShortPreamble; - - { - bool ShortPreamble; - - if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) - { - ShortPreamble = true; - priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) { + if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) { + ShortPreamble = true; + priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } - else - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) - { - ShortPreamble = false; - priv->dot11CurrentPreambleMode = PREAMBLE_LONG; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + } else { + if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) { + ShortPreamble = false; + priv->dot11CurrentPreambleMode = PREAMBLE_LONG; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } } - if (net->mode & (IEEE_G|IEEE_N_24G)) - { + if (net->mode & (IEEE_G|IEEE_N_24G)) { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) - { - if (CurSlotTime != SHORT_SLOT_TIME) - { + if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && + (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { + if (CurSlotTime != SHORT_SLOT_TIME) { slot_time_val = SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } - } - else - { - if (CurSlotTime != NON_SHORT_SLOT_TIME) - { + } else { + if (CurSlotTime != NON_SHORT_SLOT_TIME) { slot_time_val = NON_SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } } } } static struct rtllib_qos_parameters def_qos_parameters = { - {3,3,3,3}, - {7,7,7,7}, - {2,2,2,2}, - {0,0,0,0}, - {0,0,0,0} + {3, 3, 3, 3}, + {7, 7, 7, 7}, + {2, 2, 2, 2}, + {0, 0, 0, 0}, + {0, 0, 0, 0} }; void rtl8192_update_beacon(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + update_beacon_wq.work); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_device *ieee = priv->rtllib; + struct rtllib_network *net = &ieee->current_network; if (ieee->pHTInfo->bCurrentHTSupport) HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = + net->bssht.bdRT2RTLongSlotTime; ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode; rtl8192_update_cap(dev, net->capability); } #define MOVE_INTO_HANDLER -int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; void rtl8192_qos_activate(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + qos_activate); struct net_device *dev = priv->rtllib->dev; #ifndef MOVE_INTO_HANDLER - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 mode = priv->rtllib->current_network.mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 mode = priv->rtllib->current_network.mode; u8 u1bAIFS; u32 u4bAcParam; #endif - int i; + int i; - if (priv == NULL) - return; + if (priv == NULL) + return; - mutex_lock(&priv->mutex); - if (priv->rtllib->state != RTLLIB_LINKED) + mutex_lock(&priv->mutex); + if (priv->rtllib->state != RTLLIB_LINKED) goto success; - RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); + RT_TRACE(COMP_QOS, "qos active process with associate response " + "received\n"); for (i = 0; i < QOS_QUEUE_NUM; i++) { #ifndef MOVE_INTO_HANDLER - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + u1bAIFS = qos_parameters->aifs[i] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[i])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[i])) << + AC_PARAM_ECW_MIN_OFFSET) | + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); RT_TRACE(COMP_DBG, "===>ACI:%d:u4bAcParam:%x\n", i, u4bAcParam); write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); #else - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&i)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); #endif } success: - mutex_unlock(&priv->mutex); + mutex_unlock(&priv->mutex); } static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, @@ -688,8 +651,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, int ret = 0; u32 size = sizeof(struct rtllib_qos_parameters); - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) return ret; @@ -702,21 +665,22 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, if ((network->qos_data.active == 1) && (active_network == 1) && (network->flags & NETWORK_HAS_QOS_PARAMETERS) && (network->qos_data.old_param_count != - network->qos_data.param_count)) { + network->qos_data.param_count)) { network->qos_data.old_param_count = network->qos_data.param_count; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE (COMP_QOS, "QoS parameters change call " + RT_TRACE(COMP_QOS, "QoS parameters change call " "qos_activate\n"); } } else { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ + memcpy(&priv->rtllib->current_network.qos_data.parameters, &def_qos_parameters, size); if ((network->qos_data.active == 1) && (active_network == 1)) { queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n"); + RT_TRACE(COMP_QOS, "QoS was disabled call qos_" + "activate\n"); } network->qos_data.active = 0; network->qos_data.supported = 0; @@ -725,13 +689,13 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, return 0; } -static int rtl8192_handle_beacon(struct net_device * dev, - struct rtllib_beacon * beacon, - struct rtllib_network * network) +static int rtl8192_handle_beacon(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network) { struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_handle_probe_response(priv,1,network); + rtl8192_qos_handle_probe_response(priv, 1, network); queue_delayed_work_rsl(priv->priv_wq, &priv->update_beacon_wq, 0); return 0; @@ -739,60 +703,60 @@ static int rtl8192_handle_beacon(struct net_device * dev, } static int rtl8192_qos_association_resp(struct r8192_priv *priv, - struct rtllib_network *network) + struct rtllib_network *network) { - int ret = 0; - unsigned long flags; - u32 size = sizeof(struct rtllib_qos_parameters); - int set_qos_param = 0; + int ret = 0; + unsigned long flags; + u32 size = sizeof(struct rtllib_qos_parameters); + int set_qos_param = 0; - if ((priv == NULL) || (network == NULL)) - return ret; + if ((priv == NULL) || (network == NULL)) + return ret; - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) - return ret; + return ret; - spin_lock_irqsave(&priv->rtllib->lock, flags); + spin_lock_irqsave(&priv->rtllib->lock, flags); if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ - &network->qos_data.parameters,\ - sizeof(struct rtllib_qos_parameters)); + memcpy(&priv->rtllib->current_network.qos_data.parameters, + &network->qos_data.parameters, + sizeof(struct rtllib_qos_parameters)); priv->rtllib->current_network.qos_data.active = 1; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; set_qos_param = 1; priv->rtllib->current_network.qos_data.old_param_count = - priv->rtllib->current_network.qos_data.param_count; + priv->rtllib->current_network.qos_data.param_count; priv->rtllib->current_network.qos_data.param_count = - network->qos_data.param_count; - } else { + network->qos_data.param_count; + } else { memcpy(&priv->rtllib->current_network.qos_data.parameters, - &def_qos_parameters, size); + &def_qos_parameters, size); priv->rtllib->current_network.qos_data.active = 0; priv->rtllib->current_network.qos_data.supported = 0; - set_qos_param = 1; - } + set_qos_param = 1; + } - spin_unlock_irqrestore(&priv->rtllib->lock, flags); + spin_unlock_irqrestore(&priv->rtllib->lock, flags); RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, - network->flags ,priv->rtllib->current_network.qos_data.active); + network->flags, priv->rtllib->current_network.qos_data.active); if (set_qos_param == 1) { dm_init_edca_turbo(priv->rtllib->dev); queue_work_rsl(priv->priv_wq, &priv->qos_activate); } - return ret; + return ret; } static int rtl8192_handle_assoc_response(struct net_device *dev, - struct rtllib_assoc_response_frame *resp, - struct rtllib_network *network) + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network) { - struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_association_resp(priv, network); - return 0; + struct r8192_priv *priv = rtllib_priv(dev); + rtl8192_qos_association_resp(priv, network); + return 0; } void rtl8192_prepare_beacon(struct r8192_priv *priv) @@ -832,104 +796,107 @@ void rtl8192_stop_beacon(struct net_device *dev) { } -void rtl8192_config_rate(struct net_device* dev, u16* rate_config) +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_network *net; - u8 i=0, basic_rate = 0; - net = & priv->rtllib->current_network; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net; + u8 i = 0, basic_rate = 0; + net = &priv->rtllib->current_network; - for (i = 0; i < net->rates_len; i++) { - basic_rate = net->rates[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_len; i++) { + basic_rate = net->rates[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } - for (i = 0; i < net->rates_ex_len; i++) { - basic_rate = net->rates_ex[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_ex_len; i++) { + basic_rate = net->rates_ex[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } } -void rtl8192_refresh_supportrate(struct r8192_priv * priv) +void rtl8192_refresh_supportrate(struct r8192_priv *priv) { - struct rtllib_device* ieee = priv->rtllib; - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) { - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); - memcpy(ieee->Regdot11TxHTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + struct rtllib_device *ieee = priv->rtllib; + if (ieee->mode == WIRELESS_MODE_N_24G || + ieee->mode == WIRELESS_MODE_N_5G) { + memcpy(ieee->Regdot11HTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); + memcpy(ieee->Regdot11TxHTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); } else { memset(ieee->Regdot11HTOperationalRateSet, 0, 16); @@ -937,7 +904,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv * priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) +u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -959,12 +926,13 @@ u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) return ret; } -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) { struct r8192_priv *priv = rtllib_priv(dev); u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev); - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) { + if ((wireless_mode == WIRELESS_MODE_AUTO) || + ((wireless_mode & bSupportMode) == 0)) { if (bSupportMode & WIRELESS_MODE_N_24G) { wireless_mode = WIRELESS_MODE_N_24G; } else if (bSupportMode & WIRELESS_MODE_N_5G) { @@ -976,49 +944,55 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) } else if ((bSupportMode & WIRELESS_MODE_B)) { wireless_mode = WIRELESS_MODE_B; } else { - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported (%x)!!!\n", - __func__, bSupportMode); + RT_TRACE(COMP_ERR, "%s(), No valid wireless mode " + "supported (%x)!!!\n", __func__, bSupportMode); wireless_mode = WIRELESS_MODE_B; } } - if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == (WIRELESS_MODE_G | WIRELESS_MODE_B)) + if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == + (WIRELESS_MODE_G | WIRELESS_MODE_B)) wireless_mode = WIRELESS_MODE_G; priv->rtllib->mode = wireless_mode; - ActUpdateChannelAccessSetting( dev, wireless_mode, &priv->ChannelAccessSetting); + ActUpdateChannelAccessSetting(dev, wireless_mode, + &priv->ChannelAccessSetting); - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)){ + if ((wireless_mode == WIRELESS_MODE_N_24G) || + (wireless_mode == WIRELESS_MODE_N_5G)) { priv->rtllib->pHTInfo->bEnableHT = 1; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", __func__,wireless_mode); - }else{ + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", + __func__, wireless_mode); + } else { priv->rtllib->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", __func__,wireless_mode); - } + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", + __func__, wireless_mode); + } RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool init_status = true; priv->bDriverIsGoingToUnload = false; priv->bdisable_nic = false; - priv->up=1; - priv->rtllib->ieee_up=1; + priv->up = 1; + priv->rtllib->ieee_up = 1; priv->up_first_time = 0; RT_TRACE(COMP_INIT, "Bringing up iface"); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); - if (init_status != true) - { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + if (init_status != true) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bfirst_init = false; return -1; } @@ -1027,16 +1001,14 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } if (priv->rtllib->state != RTLLIB_LINKED) - rtllib_softmac_start_protocol(priv->rtllib, 0); + rtllib_softmac_start_protocol(priv->rtllib, 0); rtllib_reset_queue(priv->rtllib); watch_dog_timer_callback((unsigned long) dev); - if (!netif_queue_stopped(dev)) netif_start_queue(dev); else @@ -1051,7 +1023,8 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) unsigned long flags = 0; u8 RFInProgressTimeOut = 0; - if (priv->up == 0) return -1; + if (priv->up == 0) + return -1; if (priv->rtllib->rtllib_ips_leave != NULL) priv->rtllib->rtllib_ips_leave(dev); @@ -1060,7 +1033,7 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) LeisurePSLeave(dev); priv->bDriverIsGoingToUnload = true; - priv->up=0; + priv->up = 0; priv->rtllib->ieee_up = 0; priv->bfirst_after_down = 1; RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__); @@ -1068,11 +1041,10 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) netif_stop_queue(dev); priv->rtllib->wpa_ie_len = 0; - if (priv->rtllib->wpa_ie) - kfree(priv->rtllib->wpa_ie); + kfree(priv->rtllib->wpa_ie); priv->rtllib->wpa_ie = NULL; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtl8192_irq_disable(dev); del_timer_sync(&priv->watch_dog_timer); @@ -1080,40 +1052,40 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) cancel_delayed_work(&priv->rtllib->hw_wakeup_wq); rtllib_softmac_stop_protocol(priv->rtllib, 0, true); - spin_lock_irqsave(&priv->rf_ps_lock,flags); - while(priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - if (RFInProgressTimeOut > 100) - { - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); + while (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + if (RFInProgressTimeOut > 100) { + spin_lock_irqsave(&priv->rf_ps_lock, flags); break; } - RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait until rf chang is done.\n",__func__); + RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait " + "until rf chang is done.\n", __func__); mdelay(1); - RFInProgressTimeOut ++; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + RFInProgressTimeOut++; + spin_lock_irqsave(&priv->rf_ps_lock, flags); } priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); priv->ops->stop_adapter(dev, false); - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); udelay(100); - memset(&priv->rtllib->current_network, 0 , offsetof(struct rtllib_network, list)); + memset(&priv->rtllib->current_network, 0, + offsetof(struct rtllib_network, list)); RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; } -static void rtl8192_init_priv_handler(struct net_device* dev) +static void rtl8192_init_priv_handler(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->rtllib->softmac_hard_start_xmit = rtl8192_hard_start_xmit; - priv->rtllib->set_chan = rtl8192_set_chan; - priv->rtllib->link_change = priv->ops->link_change; + priv->rtllib->set_chan = rtl8192_set_chan; + priv->rtllib->link_change = priv->ops->link_change; priv->rtllib->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; priv->rtllib->data_hard_stop = rtl8192_data_hard_stop; priv->rtllib->data_hard_resume = rtl8192_data_hard_resume; @@ -1134,7 +1106,8 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->ps_is_queue_empty = rtl8192_is_tx_queue_empty; priv->rtllib->GetNmodeSupportBySecCfg = rtl8192_GetNmodeSupportBySecCfg; - priv->rtllib->GetHalfNmodeSupportByAPsHandler = rtl8192_GetHalfNmodeSupportByAPs; + priv->rtllib->GetHalfNmodeSupportByAPsHandler = + rtl8192_GetHalfNmodeSupportByAPs; priv->rtllib->SetHwRegHandler = rtl8192e_SetHwReg; priv->rtllib->AllowAllDestAddrHandler = rtl8192_AllowAllDestAddr; @@ -1151,10 +1124,11 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->rtllib_rfkill_poll = NULL; } -static void rtl8192_init_priv_constant(struct net_device* dev) +static void rtl8192_init_priv_constant(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); pPSC->RegMaxLPSAwakeIntvl = 5; @@ -1170,7 +1144,7 @@ static void rtl8192_init_priv_constant(struct net_device* dev) } -static void rtl8192_init_priv_variable(struct net_device* dev) +static void rtl8192_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 i; @@ -1194,7 +1168,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->txringcount = 64; priv->rxbuffersize = 9100; priv->rxringcount = MAX_RX_COUNT; - priv->irq_enabled=0; + priv->irq_enabled = 0; priv->chan = 1; priv->RegWirelessMode = WIRELESS_MODE_AUTO; priv->RegChannelPlan = 0xf; @@ -1206,14 +1180,15 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->bNetPromiscuousMode = false; priv->rtllib->IntelPromiscuousModeInfo.bPromiscuousOn = false; - priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = false; - priv->rtllib->ieee_up=0; + priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = + false; + priv->rtllib->ieee_up = 0; priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->rtllib->rts = DEFAULT_RTS_THRESHOLD; priv->rtllib->rate = 110; priv->rtllib->short_slot = 1; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; + priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->bcck_in_ch14 = false; priv->bfsync_processing = false; priv->CCKPresentAttentuation = 0; @@ -1225,11 +1200,11 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->bForcedSilentReset = 0; priv->bDisableNormalResetCheck = false; priv->force_reset = false; - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); - memset(&priv->InterruptLog,0,sizeof(struct log_int_8190)); + memset(&priv->InterruptLog, 0, sizeof(struct log_int_8190)); priv->RxCounter = 0; - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; priv->bHwRadioOff = false; priv->RegRfOff = 0; priv->isRFOff = false; @@ -1247,7 +1222,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->eRFPowerState = eRfOn; priv->txpower_checkcnt = 0; - priv->thermal_readback_index =0; + priv->thermal_readback_index = 0; priv->txpower_tracking_callback_cnt = 0; priv->ccktxpower_adjustcnt_ch14 = 0; priv->ccktxpower_adjustcnt_not_ch14 = 0; @@ -1256,7 +1231,8 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->active_scan = 1; priv->rtllib->be_scan_inprogress = false; - priv->rtllib->modulation = RTLLIB_CCK_MODULATION | RTLLIB_OFDM_MODULATION; + priv->rtllib->modulation = RTLLIB_CCK_MODULATION | + RTLLIB_OFDM_MODULATION; priv->rtllib->host_encrypt = 1; priv->rtllib->host_decrypt = 1; @@ -1268,23 +1244,20 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = (struct rt_firmware *)vmalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); - skb_queue_head_init(&priv->rx_queue); + skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_aggQ [i]); - } - + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_aggQ[i]); } -static void rtl8192_init_priv_lock(struct r8192_priv * priv) +static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->fw_scan_lock); spin_lock_init(&priv->tx_lock); @@ -1294,57 +1267,64 @@ static void rtl8192_init_priv_lock(struct r8192_priv * priv) spin_lock_init(&priv->ps_lock); spin_lock_init(&priv->rf_lock); spin_lock_init(&priv->rt_h2c_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_sem,1); + sema_init(&priv->wx_sem, 1); + sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } -static void rtl8192_init_priv_task(struct net_device* dev) +static void rtl8192_init_priv_task(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->priv_wq = create_workqueue(DRV_NAME); - INIT_WORK_RSL(&priv->reset_wq, (void*)rtl8192_restart, dev); - INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void*)IPSLeave_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev); - INIT_WORK_RSL(&priv->qos_activate, (void*)rtl8192_qos_activate, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev); + INIT_WORK_RSL(&priv->reset_wq, (void *)rtl8192_restart, dev); + INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void *)IPSLeave_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, + (void *)rtl819x_watchdog_wqcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, + (void *)dm_txpower_trackingcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, + (void *)dm_rf_pathcheck_workitemcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, + (void *)rtl8192_update_beacon, dev); + INIT_WORK_RSL(&priv->qos_activate, (void *)rtl8192_qos_activate, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq, + (void *) rtl8192_hw_wakeup_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq, + (void *) rtl8192_hw_sleep_wq, dev); tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8192_irq_rx_tasklet, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_rx_tasklet, + (unsigned long)priv); tasklet_init(&priv->irq_tx_tasklet, - (void(*)(unsigned long))rtl8192_irq_tx_tasklet, - (unsigned long)priv); - tasklet_init(&priv->irq_prepare_beacon_tasklet, - (void(*)(unsigned long))rtl8192_prepare_beacon, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_tx_tasklet, + (unsigned long)priv); + tasklet_init(&priv->irq_prepare_beacon_tasklet, + (void(*)(unsigned long))rtl8192_prepare_beacon, + (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device * dev) +short rtl8192_get_channel_map(struct net_device *dev) { int i; struct r8192_priv *priv = rtllib_priv(dev); if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && (priv->rf_chip != RF_6052)) { - RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel map\n", __func__); + RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel " + "map\n", __func__); return -1; } if (priv->ChannelPlan > COUNTRY_CODE_MAX) { - printk("rtl819x_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan= COUNTRY_CODE_FCC; + printk(KERN_INFO "rtl819x_init:Error channel plan! Set to " + "default.\n"); + priv->ChannelPlan = COUNTRY_CODE_FCC; } - RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); + RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan); Dot11d_Init(priv->rtllib); Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); - for (i = 1; i <= 11; i++) { + for (i = 1; i <= 11; i++) (priv->rtllib->active_channel_map)[i] = 1; - } (priv->rtllib->active_channel_map)[12] = 2; (priv->rtllib->active_channel_map)[13] = 2; @@ -1355,10 +1335,9 @@ short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - memset(&(priv->stats),0,sizeof(struct rt_stats)); + memset(&(priv->stats), 0, sizeof(struct rt_stats)); rtl8192_dbgp_flag_init(dev); - rtl8192_init_priv_handler(dev); rtl8192_init_priv_constant(dev); rtl8192_init_priv_variable(dev); @@ -1381,17 +1360,17 @@ short rtl8192_init(struct net_device *dev) (unsigned long)dev); rtl8192_irq_disable(dev); - if (request_irq(dev->irq, (void*)rtl8192_interrupt_rsl, IRQF_SHARED, dev->name, dev)) - { - printk("Error allocating IRQ %d",dev->irq); + if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, IRQF_SHARED, + dev->name, dev)) { + printk(KERN_ERR "Error allocating IRQ %d", dev->irq); return -1; } else { - priv->irq=dev->irq; - RT_TRACE(COMP_INIT, "IRQ %d\n",dev->irq); + priv->irq = dev->irq; + RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq); } if (rtl8192_pci_initdescring(dev) != 0) { - printk("Endopoints initialization failed"); + printk(KERN_ERR "Endopoints initialization failed"); return -1; } @@ -1399,51 +1378,48 @@ short rtl8192_init(struct net_device *dev) } /*************************************************************************** - -------------------------------WATCHDOG STUFF--------------------------- + -------------------------------WATCHDOG STUFF--------------------------- ***************************************************************************/ short rtl8192_is_tx_queue_empty(struct net_device *dev) { - int i=0; + int i = 0; struct r8192_priv *priv = rtllib_priv(dev); - for (i=0; i<=MGNT_QUEUE; i++) - { - if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) + for (i = 0; i <= MGNT_QUEUE; i++) { + if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE)) continue; - if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ - printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); + if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0) { + printk(KERN_INFO "===>tx queue is not empty:%d, %d\n", + i, skb_queue_len(&(&priv->tx_ring[i])->queue)); return 0; } } return 1; } -enum reset_type -rtl819x_TxCheckStuck(struct net_device *dev) +enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 QueueID; - u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - bool bCheckFwTxCnt = false; + u8 QueueID; + u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + bool bCheckFwTxCnt = false; struct rtl8192_tx_ring *ring = NULL; - struct sk_buff* skb = NULL; - struct cb_desc * tcb_desc = NULL; + struct sk_buff *skb = NULL; + struct cb_desc *tcb_desc = NULL; unsigned long flags = 0; - switch (priv->rtllib->ps) - { - case RTLLIB_PS_DISABLED: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; - break; - case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; - default: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; + switch (priv->rtllib->ps) { + case RTLLIB_PS_DISABLED: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; + break; + case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; + default: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) - { + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) { if (QueueID == TXCMD_QUEUE) continue; @@ -1452,24 +1428,26 @@ rtl819x_TxCheckStuck(struct net_device *dev) ring = &priv->tx_ring[QueueID]; - if (skb_queue_len(&ring->queue) == 0) + if (skb_queue_len(&ring->queue) == 0) { continue; - else - { + } else { skb = (&ring->queue)->next; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); tcb_desc->nStuckCount++; bCheckFwTxCnt = true; if (tcb_desc->nStuckCount > 1) - printk("%s: QueueID=%d tcb_desc->nStuckCount=%d\n",__func__,QueueID,tcb_desc->nStuckCount); + printk(KERN_INFO "%s: QueueID=%d tcb_desc->n" + "StuckCount=%d\n", __func__, QueueID, + tcb_desc->nStuckCount); } } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); if (bCheckFwTxCnt) { - if (priv->ops->TxCheckStuckHandler(dev)) - { - RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n"); + if (priv->ops->TxCheckStuckHandler(dev)) { + RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no" + " Tx condition!\n"); return RESET_TYPE_SILENT; } } @@ -1481,8 +1459,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->ops->RxCheckStuckHandler(dev)) - { + if (priv->ops->RxCheckStuckHandler(dev)) { RT_TRACE(COMP_RESET, "RxStuck Condition\n"); return RESET_TYPE_SILENT; } @@ -1503,18 +1480,20 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) if (rfState == eRfOn) TxResetType = rtl819x_TxCheckStuck(dev); - if ( rfState == eRfOn && + if (rfState == eRfOn && (priv->rtllib->iw_mode == IW_MODE_INFRA) && - (priv->rtllib->state == RTLLIB_LINKED)) { - + (priv->rtllib->state == RTLLIB_LINKED)) RxResetType = rtl819x_RxCheckStuck(dev); - } - if (TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + if (TxResetType == RESET_TYPE_NORMAL || + RxResetType == RESET_TYPE_NORMAL) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_NORMAL; - } else if (TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + } else if (TxResetType == RESET_TYPE_SILENT || + RxResetType == RESET_TYPE_SILENT) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_SILENT; } else { return RESET_TYPE_NORESET; @@ -1537,21 +1516,20 @@ void rtl819x_ifsilentreset(struct net_device *dev) u8 IsPortal = 0; - if (priv->ResetProgress==RESET_TYPE_NORESET) { + if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_RESET,"=========>Reset progress!! \n"); + RT_TRACE(COMP_RESET, "=========>Reset progress!!\n"); priv->ResetProgress = RESET_TYPE_SILENT; - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); goto END; } priv->RFChangeInProgress = true; priv->bResetInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); RESET_START: @@ -1561,15 +1539,18 @@ RESET_START: LeisurePSLeave(dev); if (IS_NIC_DOWN(priv)) { - RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__func__); + RT_TRACE(COMP_ERR, "%s():the driver is not up! " + "return\n", __func__); up(&priv->wx_sem); return ; } priv->up = 0; - RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", + __func__); mdelay(1000); - RT_TRACE(COMP_RESET,"%s():111111111111111111111111======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():111111111111111111111111======>start" + " to down the driver\n", __func__); if (!netif_queue_stopped(dev)) netif_stop_queue(dev); @@ -1582,7 +1563,7 @@ RESET_START: if (ieee->state == RTLLIB_LINKED) { SEM_DOWN_IEEE_WX(&ieee->wx_sem); - printk("ieee->state is RTLLIB_LINKED\n"); + printk(KERN_INFO "ieee->state is RTLLIB_LINKED\n"); rtllib_stop_send_beacons(priv->rtllib); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); @@ -1590,43 +1571,51 @@ RESET_START: netif_carrier_off(dev); SEM_UP_IEEE_WX(&ieee->wx_sem); } else { - printk("ieee->state is NOT LINKED\n"); - rtllib_softmac_stop_protocol(priv->rtllib, 0 ,true); + printk(KERN_INFO "ieee->state is NOT LINKED\n"); + rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); } dm_backup_dynamic_mechanism_state(dev); up(&priv->wx_sem); - RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<==========down process is " + "finished\n", __func__); - RT_TRACE(COMP_RESET,"%s():<===========up process start\n",__func__); - reset_status = _rtl8192_up(dev,true); + RT_TRACE(COMP_RESET, "%s():<===========up process start\n", + __func__); + reset_status = _rtl8192_up(dev, true); - RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<===========up process is " + "finished\n", __func__); if (reset_status == -1) { if (reset_times < 3) { reset_times++; goto RESET_START; } else { - RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n",__func__); + RT_TRACE(COMP_ERR, " ERR!!! %s(): Reset " + "Failed!!\n", __func__); } } ieee->is_silent_reset = 1; - spin_lock_irqsave(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); EnableHWSecurityConfig8192(dev); - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_INFRA) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); - } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_ADHOC) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); ieee->link_change(ieee->dev); notify_wx_assoc_event(ieee); @@ -1646,27 +1635,30 @@ END: priv->ResetProgress = RESET_TYPE_NORESET; priv->reset_count++; - priv->bForcedSilentReset =false; + priv->bForcedSilentReset = false; priv->bResetInProgress = false; write_nic_byte(dev, UFWP, 1); - RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); + RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", + priv->reset_count); } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, - u32 *TotalRxBcnNum, +void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, u32 *TotalRxDataNum) { - u16 SlotIndex; - u8 i; + u16 SlotIndex; + u8 i; *TotalRxBcnNum = 0; *TotalRxDataNum = 0; - SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++)%(priv->rtllib->LinkDetectInfo.SlotNum); - priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; - priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; + SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++) % + (priv->rtllib->LinkDetectInfo.SlotNum); + priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; + priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; for (i = 0; i < priv->rtllib->LinkDetectInfo.SlotNum; i++) { *TotalRxBcnNum += priv->rtllib->LinkDetectInfo.RxBcnNum[i]; *TotalRxDataNum += priv->rtllib->LinkDetectInfo.RxDataNum[i]; @@ -1676,13 +1668,15 @@ void rtl819x_update_rxcounts(struct r8192_priv *priv, void rtl819x_watchdog_wqcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, watch_dog_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum reset_type ResetType = RESET_TYPE_NORESET; - static u8 check_reset_cnt = 0; + static u8 check_reset_cnt; unsigned long flags; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bBusyTraffic = false; bool bHigherBusyTraffic = false; bool bHigherBusyRxTraffic = false; @@ -1692,7 +1686,7 @@ void rtl819x_watchdog_wqcallback(void *data) return; if (priv->rtllib->state >= RTLLIB_LINKED) { - if (priv->rtllib->CntAfterLink<2) + if (priv->rtllib->CntAfterLink < 2) priv->rtllib->CntAfterLink++; } else { priv->rtllib->CntAfterLink = 0; @@ -1700,130 +1694,125 @@ void rtl819x_watchdog_wqcallback(void *data) hal_dm_watchdog(dev); - if (rtllib_act_scanning(priv->rtllib,false) == false){ - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) &&\ - (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\ - (!ieee->proto_stoppping) && !ieee->wx_set_enc - ){ - if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE)&& - (!ieee->bNetPromiscuousMode)) - { - RT_TRACE(COMP_PS, "====================>haha:IPSEnter()\n"); + if (rtllib_act_scanning(priv->rtllib, false) == false) { + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == + RTLLIB_NOLINK) && + (ieee->eRFPowerState == eRfOn) && !ieee->is_set_key && + (!ieee->proto_stoppping) && !ieee->wx_set_enc) { + if ((ieee->PowerSaveControl.ReturnPoint == + IPS_CALLBACK_NONE) && + (!ieee->bNetPromiscuousMode)) { + RT_TRACE(COMP_PS, "====================>haha: " + "IPSEnter()\n"); IPSEnter(dev); } } } - { - if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) - { - if ( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { - bBusyTraffic = true; - } + if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == + IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) { + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 100 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 100) + bBusyTraffic = true; - if ( ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || - ieee->LinkDetectInfo.NumTxOkInPeriod > 4000 ) - { - bHigherBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) - bHigherBusyRxTraffic = true; - else - bHigherBusyRxTraffic = false; - } - - if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) - bEnterPS= false; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) + bHigherBusyRxTraffic = true; else - bEnterPS= true; + bHigherBusyRxTraffic = false; + } - if (ieee->current_network.beacon_interval < 95) - bEnterPS= false; + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS = false; + else + bEnterPS = true; - if (bEnterPS) - LeisurePSEnter(dev); - else - LeisurePSLeave(dev); + if (ieee->current_network.beacon_interval < 95) + bEnterPS = false; - } else { - RT_TRACE(COMP_LPS,"====>no link LPS leave\n"); + if (bEnterPS) + LeisurePSEnter(dev); + else LeisurePSLeave(dev); + + } else { + RT_TRACE(COMP_LPS, "====>no link LPS leave\n"); + LeisurePSLeave(dev); + } + + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + + ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; + + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + + if ((TotalRxBcnNum+TotalRxDataNum) == 0) + priv->check_roaming_cnt++; + else + priv->check_roaming_cnt = 0; + + + if (priv->check_roaming_cnt > 0) { + if (ieee->eRFPowerState == eRfOff) + RT_TRACE(COMP_ERR, "========>%s()\n", __func__); + + printk(KERN_INFO "===>%s(): AP is power off, chan:%d," + " connect another one\n", __func__, priv->chan); + + ieee->state = RTLLIB_ASSOCIATING; + + RemovePeerTS(priv->rtllib, + priv->rtllib->current_network.bssid); + ieee->is_roaming = true; + ieee->is_set_key = false; + ieee->link_change(dev); + if (ieee->LedControlHandler) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + + notify_wx_assoc_event(ieee); + + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + + priv->check_roaming_cnt = 0; } - - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - - ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; - ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; } - { - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - - if ((TotalRxBcnNum+TotalRxDataNum) == 0) - priv->check_roaming_cnt ++; - else - priv->check_roaming_cnt = 0; - - - if (priv->check_roaming_cnt > 0) - { - if ( ieee->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__func__); - - printk("===>%s(): AP is power off,chan:%d, connect another one\n",__func__, priv->chan); - - ieee->state = RTLLIB_ASSOCIATING; - - RemovePeerTS(priv->rtllib,priv->rtllib->current_network.bssid); - ieee->is_roaming = true; - ieee->is_set_key = false; - ieee->link_change(dev); - if (ieee->LedControlHandler) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - - notify_wx_assoc_event(ieee); - - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - - priv->check_roaming_cnt = 0; - } - } - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - } - - spin_lock_irqsave(&priv->tx_lock,flags); + spin_lock_irqsave(&priv->tx_lock, flags); if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) && - (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) - { + (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) { ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; } - spin_unlock_irqrestore(&priv->tx_lock,flags); + spin_unlock_irqrestore(&priv->tx_lock, flags); - if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) - { + if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) { priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__func__); + RT_TRACE(COMP_RESET, "%s(): NOMAL RESET\n", __func__); return; } - if ( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) - { + if (((priv->force_reset) || (!priv->bDisableNormalResetCheck && + ResetType == RESET_TYPE_SILENT))) rtl819x_ifsilentreset(dev); - } priv->force_reset = false; priv->bForcedSilentReset = false; priv->bResetInProgress = false; @@ -1832,9 +1821,10 @@ void rtl819x_watchdog_wqcallback(void *data) void watch_dog_timer_callback(unsigned long data) { - struct r8192_priv *priv = rtllib_priv((struct net_device *) data); - queue_delayed_work_rsl(priv->priv_wq,&priv->watch_dog_wq,0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); + queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0); + mod_timer(&priv->watch_dog_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /**************************************************************************** @@ -1842,61 +1832,65 @@ void watch_dog_timer_callback(unsigned long data) *****************************************************************************/ void rtl8192_rx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->rx_enable(dev); } void rtl8192_tx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->tx_enable(dev); - rtllib_reset_queue(priv->rtllib); + rtllib_reset_queue(priv->rtllib); } static void rtl8192_free_rx_ring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ - for (i = 0; i < priv->rxringcount; i++) { + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; + rx_queue_idx++) { + for (i = 0; i < priv->rxringcount; i++) { struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i]; - if (!skb) - continue; + if (!skb) + continue; - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - kfree_skb(skb); - } + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } - pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, - priv->rx_ring[rx_queue_idx], priv->rx_ring_dma[rx_queue_idx]); + pci_free_consistent(priv->pdev, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + priv->rx_ring[rx_queue_idx], + priv->rx_ring_dma[rx_queue_idx]); priv->rx_ring[rx_queue_idx] = NULL; } } static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } - pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; + pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; } void rtl8192_data_hard_stop(struct net_device *dev) @@ -1908,14 +1902,17 @@ void rtl8192_data_hard_resume(struct net_device *dev) { } -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || + priv->bResetInProgress) { kfree_skb(skb); return; } @@ -1923,15 +1920,16 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat assert(queue_index != TXCMD_QUEUE); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); ret = rtl8192_tx(dev, skb); if (ret != 0) { kfree_skb(skb); }; - if (queue_index!=MGNT_QUEUE) { - priv->rtllib->stats.tx_bytes+=(skb->len - priv->rtllib->tx_headroom); + if (queue_index != MGNT_QUEUE) { + priv->rtllib->stats.tx_bytes += (skb->len - + priv->rtllib->tx_headroom); priv->rtllib->stats.tx_packets++; } @@ -1939,21 +1937,23 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat return; } -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if (queue_index != TXCMD_QUEUE){ - if ((priv->rtllib->eRFPowerState == eRfOff) ||IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if (queue_index != TXCMD_QUEUE) { + if ((priv->rtllib->eRFPowerState == eRfOff) || + IS_NIC_DOWN(priv) || priv->bResetInProgress) { kfree_skb(skb); return 0; } } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); if (queue_index == TXCMD_QUEUE) { rtl8192_tx_cmd(dev, skb); ret = 0; @@ -1978,81 +1978,82 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) void rtl8192_tx_isr(struct net_device *dev, int prio) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb; + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb; - if (prio != BEACON_QUEUE) { - if (entry->OWN) - return; - ring->idx = (ring->idx + 1) % ring->entries; - } + if (prio != BEACON_QUEUE) { + if (entry->OWN) + return; + ring->idx = (ring->idx + 1) % ring->entries; + } - skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - - kfree_skb(skb); - } - if (prio != BEACON_QUEUE) { - tasklet_schedule(&priv->irq_tx_tasklet); - } + skb = __skb_dequeue(&ring->queue); + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + } + if (prio != BEACON_QUEUE) + tasklet_schedule(&priv->irq_tx_tasklet); } void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring; - struct tx_desc_cmd * entry; - unsigned int idx; - struct cb_desc *tcb_desc; - unsigned long flags; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring; + struct tx_desc_cmd *entry; + unsigned int idx; + struct cb_desc *tcb_desc; + unsigned long flags; - spin_lock_irqsave(&priv->irq_th_lock,flags); - ring = &priv->tx_ring[TXCMD_QUEUE]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + ring = &priv->tx_ring[TXCMD_QUEUE]; - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = (struct tx_desc_cmd *) &ring->desc[idx]; + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + entry = (struct tx_desc_cmd *) &ring->desc[idx]; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); + priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + __skb_queue_tail(&ring->queue, skb); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); - return; + return; } -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring; unsigned long flags; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct tx_desc *pdesc = NULL; - struct rtllib_hdr_1addr * header = NULL; - u16 fc=0, type=0,stype=0; - bool multi_addr=false,broad_addr=false,uni_addr=false; - u8* pda_addr = NULL; + struct rtllib_hdr_1addr *header = NULL; + u16 fc = 0, type = 0, stype = 0; + bool multi_addr = false, broad_addr = false, uni_addr = false; + u8 *pda_addr = NULL; int idx; u32 fwinfo_size = 0; - if (priv->bdisable_nic){ - RT_TRACE(COMP_ERR,"%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", __func__, skb->len, tcb_desc->queue_index); - return skb->len; + if (priv->bdisable_nic) { + RT_TRACE(COMP_ERR, "%s: ERR!! Nic is disabled! Can't tx packet" + " len=%d qidx=%d!!!\n", __func__, skb->len, + tcb_desc->queue_index); + return skb->len; } priv->rtllib->bAwakePktSent = true; fwinfo_size = sizeof(struct tx_fwinfo_8190pci); - header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); + header = (struct rtllib_hdr_1addr *)(((u8 *)skb->data) + fwinfo_size); fc = header->frame_ctl; type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); @@ -2062,9 +2063,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) multi_addr = true; else if (is_broadcast_ether_addr(pda_addr)) broad_addr = true; - else { + else uni_addr = true; - } if (uni_addr) priv->stats.txbytesunicast += skb->len - fwinfo_size; @@ -2073,36 +2073,34 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) else priv->stats.txbytesbroadcast += skb->len - fwinfo_size; - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); ring = &priv->tx_ring[tcb_desc->queue_index]; - if (tcb_desc->queue_index != BEACON_QUEUE) { + if (tcb_desc->queue_index != BEACON_QUEUE) idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - } else { + else idx = 0; - } pdesc = &ring->desc[idx]; if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d, skblen = 0x%x queuelen=%d", \ - tcb_desc->queue_index,ring->idx, idx,skb->len, skb_queue_len(&ring->queue)); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d, idx = " + "%d, skblen = 0x%x queuelen=%d", + tcb_desc->queue_index, ring->idx, idx, skb->len, + skb_queue_len(&ring->queue)); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); return skb->len; } - if (tcb_desc->queue_index == MGNT_QUEUE){ - } - - if (type == RTLLIB_FTYPE_DATA){ + if (type == RTLLIB_FTYPE_DATA) { if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, LED_CTL_TX); } priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, skb); __skb_queue_tail(&ring->queue, skb); pdesc->OWN = 1; - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); dev->trans_start = jiffies; - write_nic_word(dev,TPPoll,0x01<queue_index); + write_nic_word(dev, TPPoll, 0x01 << tcb_desc->queue_index); return 0; } @@ -2112,16 +2110,21 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) struct rx_desc *entry = NULL; int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { priv->rx_ring[rx_queue_idx] = pci_alloc_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + &priv->rx_ring_dma[rx_queue_idx]); - if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { - RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); + if (!priv->rx_ring[rx_queue_idx] || + (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate RX ring\n"); return -ENOMEM; } - memset(priv->rx_ring[rx_queue_idx], 0, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount); + memset(priv->rx_ring[rx_queue_idx], 0, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount); priv->rx_idx[rx_queue_idx] = 0; for (i = 0; i < priv->rxringcount; i++) { @@ -2133,8 +2136,10 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) skb->dev = dev; priv->rx_buf[rx_queue_idx][i] = skb; mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); + *mapping = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); entry->BufferAddress = cpu_to_le32(*mapping); @@ -2148,68 +2153,69 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) } static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, - unsigned int prio, unsigned int entries) + unsigned int prio, unsigned int entries) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct tx_desc *ring; - dma_addr_t dma; - int i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct tx_desc *ring; + dma_addr_t dma; + int i; - ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); - if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); - return -ENOMEM; - } + ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + if (!ring || (unsigned long)ring & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", + prio); + return -ENOMEM; + } - memset(ring, 0, sizeof(*ring)*entries); - priv->tx_ring[prio].desc = ring; - priv->tx_ring[prio].dma = dma; - priv->tx_ring[prio].idx = 0; - priv->tx_ring[prio].entries = entries; - skb_queue_head_init(&priv->tx_ring[prio].queue); + memset(ring, 0, sizeof(*ring)*entries); + priv->tx_ring[prio].desc = ring; + priv->tx_ring[prio].dma = dma; + priv->tx_ring[prio].idx = 0; + priv->tx_ring[prio].entries = entries; + skb_queue_head_init(&priv->tx_ring[prio].queue); - for (i = 0; i < entries; i++) - ring[i].NextDescAddress = - cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); + for (i = 0; i < entries; i++) + ring[i].NextDescAddress = + cpu_to_le32((u32)dma + ((i + 1) % entries) * + sizeof(*ring)); - return 0; + return 0; } short rtl8192_pci_initdescring(struct net_device *dev) { - u32 ret; - int i; - struct r8192_priv *priv = rtllib_priv(dev); + u32 ret; + int i; + struct r8192_priv *priv = rtllib_priv(dev); - ret = rtl8192_alloc_rx_desc_ring(dev); - if (ret) { - return ret; - } + ret = rtl8192_alloc_rx_desc_ring(dev); + if (ret) + return ret; + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount); + if (ret) + goto err_free_rings; + } - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if ((ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount))) - goto err_free_rings; - } - - return 0; + return 0; err_free_rings: - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - if (priv->tx_ring[i].desc) - rtl8192_free_tx_ring(dev, i); - return 1; + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + if (priv->tx_ring[i].desc) + rtl8192_free_tx_ring(dev, i); + return 1; } void rtl8192_pci_resetdescring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; - unsigned long flags = 0; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; + unsigned long flags = 0; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { if (priv->rx_ring[rx_queue_idx]) { struct rx_desc *entry = NULL; for (i = 0; i < priv->rxringcount; i++) { @@ -2220,27 +2226,30 @@ void rtl8192_pci_resetdescring(struct net_device *dev) } } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if (priv->tx_ring[i].desc) { - struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if (priv->tx_ring[i].desc) { + struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = + __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - ring->idx = 0; - } - } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + pci_unmap_single(priv->pdev, + le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } + spin_unlock_irqrestore(&priv->irq_th_lock, flags); } -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats) +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2250,7 +2259,7 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat priv->LastRxDescTSF = stats->mac_time; } -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index) { long signal_power; @@ -2263,48 +2272,41 @@ long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index void rtl819x_update_rxsignalstatistics8190pci( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats + struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats ) { int weighting = 0; if (priv->stats.recv_signal_power == 0) - priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; + priv->stats.recv_signal_power = + pprevious_stats->RecvSignalPower; if (pprevious_stats->RecvSignalPower > priv->stats.recv_signal_power) weighting = 5; - else if (pprevious_stats->RecvSignalPower < priv->stats.recv_signal_power) + else if (pprevious_stats->RecvSignalPower < + priv->stats.recv_signal_power) weighting = (-5); - priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + pprevious_stats->RecvSignalPower + weighting) / 6; + priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + + pprevious_stats->RecvSignalPower + + weighting) / 6; } -void -rtl819x_process_cck_rxpathsel( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats - ) +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats) { } -u8 rtl819x_query_rxpwrpercentage( - char antpower - ) +u8 rtl819x_query_rxpwrpercentage(char antpower) { if ((antpower <= -100) || (antpower >= 20)) - { return 0; - } else if (antpower >= 0) - { return 100; - } else - { - return (100+antpower); - } + return 100 + antpower; } /* QueryRxPwrPercentage */ @@ -2322,16 +2324,16 @@ rtl819x_evm_dbtopercentage( if (ret_val <= -33) ret_val = -33; ret_val = 0 - ret_val; - ret_val*=3; + ret_val *= 3; if (ret_val == 99) ret_val = 100; - return(ret_val); + return ret_val; } void rtl8192_record_rxdesc_forlateruse( - struct rtllib_rx_stats * psrc_stats, - struct rtllib_rx_stats * ptarget_stats + struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats ) { ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; @@ -2345,8 +2347,8 @@ void rtl8192_rx_normal(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; bool unicast_packet = false; - bool bLedBlinking=true; - u16 fc=0, type=0; + bool bLedBlinking = true; + u16 fc = 0, type = 0; u32 skb_len = 0; int rx_queue_idx = RX_MPDU_QUEUE; @@ -2361,8 +2363,10 @@ void rtl8192_rx_normal(struct net_device *dev) stats.nic_type = NIC_8192E; while (count--) { - struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; + struct sk_buff *skb = priv->rx_buf[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; if (pdesc->OWN) { return; @@ -2370,11 +2374,11 @@ void rtl8192_rx_normal(struct net_device *dev) struct sk_buff *new_skb; if (!priv->ops->rx_query_status_descriptor(dev, &stats, - pdesc, skb)) + pdesc, skb)) goto done; new_skb = dev_alloc_skb(priv->rxbuffersize); /* if allocation of new skb failed - drop current packet - * and reuse skb */ + * and reuse skb */ if (unlikely(!new_skb)) goto done; @@ -2385,11 +2389,11 @@ void rtl8192_rx_normal(struct net_device *dev) skb_put(skb, pdesc->Length); skb_reserve(skb, stats.RxDrvInfoSize + - stats.RxBufShift); + stats.RxBufShift); skb_trim(skb, skb->len - 4/*sCrcLng*/); rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; if (!is_broadcast_ether_addr(rtllib_hdr->addr1) && - !is_multicast_ether_addr(rtllib_hdr->addr1)) { + !is_multicast_ether_addr(rtllib_hdr->addr1)) { /* unicast packet */ unicast_packet = true; } @@ -2401,18 +2405,18 @@ void rtl8192_rx_normal(struct net_device *dev) if (bLedBlinking) if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, - LED_CTL_RX); + LED_CTL_RX); if (stats.bCRC) { if (type != RTLLIB_FTYPE_MGMT) - priv->stats.rxdatacrcerr ++; + priv->stats.rxdatacrcerr++; else - priv->stats.rxmgmtcrcerr ++; + priv->stats.rxmgmtcrcerr++; } skb_len = skb->len; - if (!rtllib_rx(priv->rtllib, skb, &stats)){ + if (!rtllib_rx(priv->rtllib, skb, &stats)) { dev_kfree_skb_any(skb); } else { priv->stats.rxok++; @@ -2423,8 +2427,12 @@ void rtl8192_rx_normal(struct net_device *dev) skb = new_skb; skb->dev = dev; - priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = + skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); } done: @@ -2433,7 +2441,8 @@ done: pdesc->Length = priv->rxbuffersize; if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) pdesc->EOR = 1; - priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; + priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % + priv->rxringcount; } } @@ -2450,18 +2459,19 @@ void rtl8192_tx_resume(struct net_device *dev) struct sk_buff *skb; int queue_index; - for (queue_index = BK_QUEUE; queue_index < MAX_QUEUE_SIZE;queue_index++) { - while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&& - (priv->rtllib->check_nic_enough_desc(dev,queue_index) > 0)) { + for (queue_index = BK_QUEUE; + queue_index < MAX_QUEUE_SIZE; queue_index++) { + while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index])) && + (priv->rtllib->check_nic_enough_desc(dev, queue_index) > 0)) { skb = skb_dequeue(&ieee->skb_waitQ[queue_index]); - ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/); + ieee->softmac_data_hard_start_xmit(skb, dev, 0); } } } void rtl8192_irq_tx_tasklet(struct r8192_priv *priv) { - rtl8192_tx_resume(priv->rtllib->dev); + rtl8192_tx_resume(priv->rtllib->dev); } void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) @@ -2471,13 +2481,14 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) if (MAX_RX_QUEUE > 1) rtl8192_rx_cmd(priv->rtllib->dev); - write_nic_dword(priv->rtllib->dev, INTA_MASK,read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); + write_nic_dword(priv->rtllib->dev, INTA_MASK, + read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); } /**************************************************************************** ---------------------------- NIC START/CLOSE STUFF--------------------------- *****************************************************************************/ -void rtl8192_cancel_deferred_work(struct r8192_priv * priv) +void rtl8192_cancel_deferred_work(struct r8192_priv *priv) { cancel_delayed_work(&priv->watch_dog_wq); cancel_delayed_work(&priv->update_beacon_wq); @@ -2486,7 +2497,7 @@ void rtl8192_cancel_deferred_work(struct r8192_priv * priv) cancel_work_sync(&priv->qos_activate); } -int _rtl8192_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_up(struct net_device *dev, bool is_silent_reset) { if (_rtl8192_sta_up(dev, is_silent_reset) == -1) return -1; @@ -2511,8 +2522,9 @@ int rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 1) return -1; - return _rtl8192_up(dev,false); + if (priv->up == 1) + return -1; + return _rtl8192_up(dev, false); } @@ -2522,13 +2534,13 @@ int rtl8192_close(struct net_device *dev) int ret; if ((rtllib_act_scanning(priv->rtllib, false)) && - !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_stop_scan(priv->rtllib); } down(&priv->wx_sem); - ret = rtl8192_down(dev,true); + ret = rtl8192_down(dev, true); up(&priv->wx_sem); @@ -2548,16 +2560,18 @@ void rtl8192_commit(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 0) return ; + if (priv->up == 0) + return; rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, true); - _rtl8192_up(dev,false); + _rtl8192_up(dev, false); } void rtl8192_restart(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, reset_wq); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + reset_wq); struct net_device *dev = priv->rtllib->dev; down(&priv->wx_sem); @@ -2572,14 +2586,7 @@ static void r8192_set_multicast(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); short promisc; - - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) { - ; - } - + promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->promisc = promisc; } @@ -2605,117 +2612,118 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; - int ret=-1; + int ret = -1; struct rtllib_device *ieee = priv->rtllib; u32 key[4]; - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero_addr[6] = {0}; struct iw_point *p = &wrq->u.data; + struct ieee_param *ipw = NULL; down(&priv->wx_sem); switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - { - struct ieee_param *ipw = NULL; - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } + case RTL_IOCTL_WPA_SUPPLICANT: + if (p->length < sizeof(struct ieee_param) || !p->pointer) { + ret = -EINVAL; + goto out; + } - ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; - goto out; - } - - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) - { - if (ipw->u.crypt.set_tx) - { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } - else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) - { - if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0) - ieee->iw_mode = IW_MODE_ADHOC; - - memcpy((u8*)key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(dev); - set_swcam(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - if (ieee->iw_mode == IW_MODE_ADHOC){ - set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - } - } - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } + ipw = kmalloc(p->length, GFP_KERNEL); + if (ipw == NULL) { + ret = -ENOMEM; + goto out; + } + if (copy_from_user(ipw, p->pointer, p->length)) { + kfree(ipw); + ret = -EFAULT; + goto out; + } + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { + if (ipw->u.crypt.set_tx) { + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = + KEY_TYPE_WEP40; + } else { + ieee->pairwise_key_type = KEY_TYPE_NA; } - else - { - memcpy((u8*)key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } - else - ieee->group_key_type = KEY_TYPE_NA; - if (ieee->group_key_type) - { - set_swcam( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key, - 0); - setKey( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key); + if (ieee->pairwise_key_type) { + if (memcmp(ieee->ap_mac_addr, zero_addr, + 6) == 0) + ieee->iw_mode = IW_MODE_ADHOC; + memcpy((u8 *)key, ipw->u.crypt.key, 16); + EnableHWSecurityConfig8192(dev); + set_swcam(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, 0, key); + if (ieee->iw_mode == IW_MODE_ADHOC) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key); } } + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) + && ieee->pHTInfo->bCurrentHTSupport) { + write_nic_byte(dev, 0x173, 1); + } + + } else { + memcpy((u8 *)key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = + KEY_TYPE_WEP40; + } else + ieee->group_key_type = KEY_TYPE_NA; + + if (ieee->group_key_type) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key); + } } - - ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, 0); - kfree(ipw); - break; } - default: - ret = -EOPNOTSUPP; - break; + + ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, + 0); + kfree(ipw); + break; + default: + ret = -EOPNOTSUPP; + break; } out: @@ -2728,40 +2736,48 @@ void FairBeacon(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i=100; - static u8 forceturn =0; - u16 beaconint = net->beacon_interval; + static u8 i = 100; + static u8 forceturn; + u16 beaconint = net->beacon_interval; if (priv->rtllib->iw_mode != IW_MODE_ADHOC) return; - if (priv->bIbssCoordinator){ + if (priv->bIbssCoordinator) { i--; - if (forceturn ==2){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 2) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i<=94){ - beaconint=beaconint+2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =1; + if (i <= 94) { + beaconint = beaconint+2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 1; } } else { i++; - if (forceturn ==1){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 1) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i>=106){ - beaconint=beaconint-2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =2; + if (i >= 106) { + beaconint = beaconint-2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 2; } } } @@ -2776,71 +2792,67 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) u32 intb; intb = 0; - if (priv->irq_enabled == 0){ + if (priv->irq_enabled == 0) goto done; - } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); priv->ops->interrupt_recognized(dev, &inta, &intb); priv->stats.shints++; if (!inta) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } if (inta == 0xffff) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } priv->stats.ints++; if (!netif_running(dev)) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } - if (inta & IMR_TBDOK){ + if (inta & IMR_TBDOK) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconokint++; } - if (inta & IMR_TBDER){ + if (inta & IMR_TBDER) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconerr++; } - if (inta & IMR_BDOK) { + if (inta & IMR_BDOK) RT_TRACE(COMP_INTR, "beacon interrupt!\n"); - } - if (inta & IMR_MGNTDOK ) { + if (inta & IMR_MGNTDOK) { RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); priv->stats.txmanageokint++; - rtl8192_tx_isr(dev,MGNT_QUEUE); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - if (priv->rtllib->ack_tx_to_ieee){ - if (rtl8192_is_tx_queue_empty(dev)){ + rtl8192_tx_isr(dev, MGNT_QUEUE); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + if (priv->rtllib->ack_tx_to_ieee) { + if (rtl8192_is_tx_queue_empty(dev)) { priv->rtllib->ack_tx_to_ieee = 0; rtllib_ps_tx_ack(priv->rtllib, 1); } } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); } if (inta & IMR_COMDOK) { priv->stats.txcmdpktokint++; - rtl8192_tx_isr(dev,TXCMD_QUEUE); + rtl8192_tx_isr(dev, TXCMD_QUEUE); } - if (inta & IMR_HIGHDOK) { - rtl8192_tx_isr(dev,HIGH_QUEUE); - } + if (inta & IMR_HIGHDOK) + rtl8192_tx_isr(dev, HIGH_QUEUE); - if (inta & IMR_ROK) - { + if (inta & IMR_ROK) { priv->stats.rxint++; priv->InterruptLog.nIMR_ROK++; tasklet_schedule(&priv->irq_rx_tasklet); @@ -2854,7 +2866,8 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_RDU) { RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); priv->stats.rxrdu++; - write_nic_dword(dev,INTA_MASK,read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); + write_nic_dword(dev, INTA_MASK, + read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); tasklet_schedule(&priv->irq_rx_tasklet); } @@ -2864,37 +2877,38 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) tasklet_schedule(&priv->irq_rx_tasklet); } - if (inta & IMR_TXFOVW) priv->stats.txoverflow++; + if (inta & IMR_TXFOVW) + priv->stats.txoverflow++; if (inta & IMR_BKDOK) { RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); priv->stats.txbkokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BK_QUEUE); + rtl8192_tx_isr(dev, BK_QUEUE); } if (inta & IMR_BEDOK) { RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); priv->stats.txbeokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BE_QUEUE); + rtl8192_tx_isr(dev, BE_QUEUE); } if (inta & IMR_VIDOK) { RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); priv->stats.txviokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VI_QUEUE); + rtl8192_tx_isr(dev, VI_QUEUE); } if (inta & IMR_VODOK) { priv->stats.txvookint++; RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n"); priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VO_QUEUE); + rtl8192_tx_isr(dev, VO_QUEUE); } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); done: @@ -2904,7 +2918,7 @@ done: /**************************************************************************** - ---------------------------- PCI_STUFF--------------------------- + ---------------------------- PCI_STUFF--------------------------- *****************************************************************************/ #ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops rtl8192_netdev_ops = { @@ -2921,73 +2935,71 @@ static const struct net_device_ops rtl8192_netdev_ops = { #endif static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) + const struct pci_device_id *id) { unsigned long ioaddr = 0; struct net_device *dev = NULL; - struct r8192_priv *priv= NULL; + struct r8192_priv *priv = NULL; struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); unsigned long pmem_start, pmem_len, pmem_flags; int err = 0; bool bdma64 = false; u8 revision_id; - RT_TRACE(COMP_INIT,"Configuring chip resources"); + RT_TRACE(COMP_INIT, "Configuring chip resources"); - if ( pci_enable_device (pdev) ){ - RT_TRACE(COMP_ERR,"Failed to enable PCI device"); + if (pci_enable_device(pdev)) { + RT_TRACE(COMP_ERR, "Failed to enable PCI device"); return -EIO; } pci_set_master(pdev); - { - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { - printk( "Unable to obtain 32bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; - } + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + printk(KERN_INFO "Unable to obtain 32bit DMA for consistent allocations\n"); + pci_disable_device(pdev); + return -ENOMEM; } } dev = alloc_rtllib(sizeof(struct r8192_priv)); if (!dev) return -ENOMEM; - if (bdma64){ + if (bdma64) dev->features |= NETIF_F_HIGHDMA; - } pci_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev); priv = rtllib_priv(dev); priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev); - priv->pdev=pdev; - priv->rtllib->pdev=pdev; - if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)) + priv->pdev = pdev; + priv->rtllib->pdev = pdev; + if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK) && + (pdev->subsystem_device == 0x3304)) priv->rtllib->bSupportRemoteWakeUp = 1; else priv->rtllib->bSupportRemoteWakeUp = 0; pmem_start = pci_resource_start(pdev, 1); pmem_len = pci_resource_len(pdev, 1); - pmem_flags = pci_resource_flags (pdev, 1); + pmem_flags = pci_resource_flags(pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR,"region #1 not a MMIO resource, aborting"); + RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting"); goto fail; } - printk("Memory mapped space start: 0x%08lx \n", pmem_start); + printk(KERN_INFO "Memory mapped space start: 0x%08lx\n", pmem_start); if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { - RT_TRACE(COMP_ERR,"request_mem_region failed!"); + RT_TRACE(COMP_ERR, "request_mem_region failed!"); goto fail; } - ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); - if ( ioaddr == (unsigned long)NULL ){ - RT_TRACE(COMP_ERR,"ioremap failed!"); + ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); + if (ioaddr == (unsigned long)NULL) { + RT_TRACE(COMP_ERR, "ioremap failed!"); goto fail1; } @@ -3019,19 +3031,21 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->hard_start_xmit = rtllib_xmit; #endif - dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; + dev->wireless_handlers = (struct iw_handler_def *) + &r8192_wx_handlers_def; dev->ethtool_ops = &rtl819x_ethtool_ops; dev->type = ARPHRD_ETHER; - dev->watchdog_timeo = HZ*3; + dev->watchdog_timeo = HZ * 3; - if (dev_alloc_name(dev, ifname) < 0){ - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - dev_alloc_name(dev, ifname); - } + if (dev_alloc_name(dev, ifname) < 0) { + RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying " + "wlan%%d...\n"); + dev_alloc_name(dev, ifname); + } RT_TRACE(COMP_INIT, "Driver probe completed1\n"); - if (rtl8192_init(dev)!=0){ + if (rtl8192_init(dev) != 0) { RT_TRACE(COMP_ERR, "Initialization failed"); goto fail1; } @@ -3040,33 +3054,31 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, netif_stop_queue(dev); register_netdev(dev); - RT_TRACE(COMP_INIT, "dev name: %s\n",dev->name); + RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); err = rtl_debug_module_init(priv, dev->name); - if (err) { - RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring error: %d\n", err); - } + if (err) + RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring " + "error: %d\n", err); rtl8192_proc_init_one(dev); - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; fail1: - if ( dev->mem_start != (unsigned long)NULL ){ - iounmap( (void *)dev->mem_start ); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); + if (dev->mem_start != (unsigned long)NULL) { + iounmap((void *)dev->mem_start); + release_mem_region(pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1)); } fail: - if (dev){ - + if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq=0; + dev->irq = 0; } free_rtllib(dev); } @@ -3083,7 +3095,9 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv ; - if (dev){ + u32 i; + + if (dev) { unregister_netdev(dev); priv = rtllib_priv(dev); @@ -3093,63 +3107,59 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) priv->polling_timer_on = 0; rtl_debug_module_remove(priv); rtl8192_proc_remove_one(dev); - rtl8192_down(dev,true); + rtl8192_down(dev, true); deinit_hal_dm(dev); if (priv->pFirmware) { vfree(priv->pFirmware); priv->pFirmware = NULL; } destroy_workqueue(priv->priv_wq); - { - u32 i; - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - rtl8192_free_tx_ring(dev, i); - } - } + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + rtl8192_free_tx_ring(dev, i); - if (priv->irq){ - - printk("Freeing irq %d\n",dev->irq); + if (priv->irq) { + printk(KERN_INFO "Freeing irq %d\n", dev->irq); free_irq(dev->irq, dev); - priv->irq=0; - + priv->irq = 0; } free_rtllib(dev); - if (priv->scan_cmd) - kfree(priv->scan_cmd); + kfree(priv->scan_cmd); if (dev->mem_start != 0) { iounmap((void *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); + pci_resource_len(pdev, 1)); } - } else{ - priv=rtllib_priv(dev); - } + } else { + priv = rtllib_priv(dev); + } pci_disable_device(pdev); RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } -bool NicIFEnableNIC(struct net_device* dev) +bool NicIFEnableNIC(struct net_device *dev) { bool init_status = true; - struct r8192_priv * priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n", + __func__); priv->bdisable_nic = false; return RT_STATUS_FAILURE; } - RT_TRACE(COMP_PS, "===========>%s()\n",__func__); + RT_TRACE(COMP_PS, "===========>%s()\n", __func__); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (init_status != true) { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bdisable_nic = false; return -1; } @@ -3159,15 +3169,15 @@ bool NicIFEnableNIC(struct net_device* dev) rtl8192_irq_enable(dev); priv->bdisable_nic = false; - RT_TRACE(COMP_PS,"<===========%s()\n",__func__); + RT_TRACE(COMP_PS, "<===========%s()\n", __func__); return init_status; } -bool NicIFDisableNIC(struct net_device* dev) +bool NicIFDisableNIC(struct net_device *dev) { bool status = true; - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); u8 tmp_state = 0; - RT_TRACE(COMP_PS, "=========>%s()\n",__func__); + RT_TRACE(COMP_PS, "=========>%s()\n", __func__); priv->bdisable_nic = true; tmp_state = priv->rtllib->state; rtllib_softmac_stop_protocol(priv->rtllib, 0, false); @@ -3176,7 +3186,7 @@ bool NicIFDisableNIC(struct net_device* dev) rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, false); - RT_TRACE(COMP_PS, "<=========%s()\n",__func__); + RT_TRACE(COMP_PS, "<=========%s()\n", __func__); return status; } @@ -3221,14 +3231,14 @@ static int __init rtl8192_pci_module_init(void) } rtl8192_proc_module_init(); - if (0!=pci_register_driver(&rtl8192_pci_driver)) { + if (0 != pci_register_driver(&rtl8192_pci_driver)) { DMESG("No device found"); /*pci_unregister_driver (&rtl8192_pci_driver);*/ return -ENODEV; } return 0; err_out: - return error; + return error; } @@ -3248,17 +3258,18 @@ static void __exit rtl8192_pci_module_exit(void) void check_rfctrl_gpio_timer(unsigned long data) { - struct r8192_priv * priv = rtllib_priv((struct net_device *)data); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); priv->polling_timer_on = 1; - queue_delayed_work_rsl(priv->priv_wq,&priv->gpio_change_rf_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->gpio_change_rf_wq, 0); - mod_timer(&priv->gpio_polling_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + mod_timer(&priv->gpio_polling_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /*************************************************************************** - ------------------- module init / exit stubs ---------------- + ------------------- module init / exit stubs ---------------- ****************************************************************************/ module_init(rtl8192_pci_module_init); module_exit(rtl8192_pci_module_exit); @@ -3268,10 +3279,10 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR); +module_param(hwwep, int, S_IRUGO|S_IWUSR); +module_param(channels, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support(default use hw. set 0 to use software security)"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); +MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); +MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support(default use hw. set 0 to use software security)"); +MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI"); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 4f94d0a18f0..03a86fe283c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include "dot11d.h" @@ -62,28 +62,35 @@ #include "rtl_pci.h" #include "rtl_cam.h" -#define DRV_COPYRIGHT "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" +#define DRV_COPYRIGHT \ + "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" #define DRV_AUTHOR "" #define DRV_VERSION "0014.0401.2010" #define DRV_NAME "rtl819xE" -#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8190P)||\ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192E)) -#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192SE) -#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CE) -#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CU) -#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DE) -#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DU) +#define IS_HARDWARE_TYPE_819xP(_priv) \ + ((((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8190P) || \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192E)) +#define IS_HARDWARE_TYPE_8192SE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE) +#define IS_HARDWARE_TYPE_8192CE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CE) +#define IS_HARDWARE_TYPE_8192CU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CU) +#define IS_HARDWARE_TYPE_8192DE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DE) +#define IS_HARDWARE_TYPE_8192DU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DU) #define RTL_PCI_DEVICE(vend, dev, cfg) \ .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice =PCI_ANY_ID , \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \ .driver_data = (kernel_ulong_t)&(cfg) #define irqreturn_type irqreturn_t -#define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) +#define rtl8192_interrupt(x, y, z) rtl8192_interrupt_rsl(x, y) #define RTL_MAX_SCAN_SIZE 128 @@ -100,8 +107,9 @@ #define IS_ADAPTER_SENDS_BEACON(dev) 0 -#define IS_UNDER_11N_AES_MODE(_rtllib) ((_rtllib->pHTInfo->bCurrentHTSupport == true) &&\ - (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) +#define IS_UNDER_11N_AES_MODE(_rtllib) \ + ((_rtllib->pHTInfo->bCurrentHTSupport == true) && \ + (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) #define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI 0x1000 #define HAL_HW_PCI_REVISION_ID_8190PCI 0x00 @@ -120,36 +128,38 @@ #define HAL_HW_PCI_8198_DEVICE_ID 0x8198 #define HAL_HW_PCI_8190_DEVICE_ID 0x8190 #define HAL_HW_PCI_8192_DEVICE_ID 0x8192 -#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 +#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 #define HAL_HW_PCI_8174_DEVICE_ID 0x8174 #define HAL_HW_PCI_8173_DEVICE_ID 0x8173 #define HAL_HW_PCI_8172_DEVICE_ID 0x8172 #define HAL_HW_PCI_8171_DEVICE_ID 0x8171 -#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 -#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 -#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 -#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 -#define HAL_HW_PCI_700F_DEVICE_ID 0x700F -#define HAL_HW_PCI_701F_DEVICE_ID 0x701F -#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 +#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 +#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 +#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 +#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 +#define HAL_HW_PCI_700F_DEVICE_ID 0x700F +#define HAL_HW_PCI_701F_DEVICE_ID 0x701F +#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 #define HAL_HW_PCI_8192CET_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 -#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 -#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 -#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D -#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 +#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 +#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 +#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 +#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D #define RTL819X_DEFAULT_RF_TYPE RF_1T2R #define RTLLIB_WATCH_DOG_TIME 2000 -#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */ +#define MAX_DEV_ADDR_SIZE 8 /*support till 64 bit bus width OS*/ #define MAX_FIRMWARE_INFORMATION_SIZE 32 #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 #define MAX_FRAGMENT_COUNT 8 -#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) +#define MAX_TRANSMIT_BUFFER_SIZE \ + (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) * \ + MAX_FRAGMENT_COUNT) #define scrclng 4 @@ -164,13 +174,13 @@ #define PHY_RSSI_SLID_WIN_MAX 100 -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) -#define TxBBGainTableLength 37 -#define CCKTxBBGainTableLength 23 +#define TxBBGainTableLength 37 +#define CCKTxBBGainTableLength 23 #define CHANNEL_PLAN_LEN 10 -#define sCrcLng 4 +#define sCrcLng 4 #define NIC_SEND_HANG_THRESHOLD_NORMAL 4 #define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 @@ -179,30 +189,30 @@ #define MAX_RX_QUEUE 1 -#define MAX_RX_COUNT 64 -#define MAX_TX_QUEUE_COUNT 9 +#define MAX_RX_COUNT 64 +#define MAX_TX_QUEUE_COUNT 9 enum RTL819x_PHY_PARAM { - RTL819X_PHY_MACPHY_REG = 0, - RTL819X_PHY_MACPHY_REG_PG = 1, - RTL8188C_PHY_MACREG =2, - RTL8192C_PHY_MACREG =3, + RTL819X_PHY_MACPHY_REG = 0, + RTL819X_PHY_MACPHY_REG_PG = 1, + RTL8188C_PHY_MACREG = 2, + RTL8192C_PHY_MACREG = 3, RTL819X_PHY_REG = 4, RTL819X_PHY_REG_1T2R = 5, - RTL819X_PHY_REG_to1T1R = 6, - RTL819X_PHY_REG_to1T2R = 7, - RTL819X_PHY_REG_to2T2R = 8, + RTL819X_PHY_REG_to1T1R = 6, + RTL819X_PHY_REG_to1T2R = 7, + RTL819X_PHY_REG_to2T2R = 8, RTL819X_PHY_REG_PG = 9, RTL819X_AGC_TAB = 10, - RTL819X_PHY_RADIO_A =11, - RTL819X_PHY_RADIO_A_1T =12, - RTL819X_PHY_RADIO_A_2T =13, - RTL819X_PHY_RADIO_B =14, - RTL819X_PHY_RADIO_B_GM =15, - RTL819X_PHY_RADIO_C =16, - RTL819X_PHY_RADIO_D =17, - RTL819X_EEPROM_MAP =18, - RTL819X_EFUSE_MAP =19, + RTL819X_PHY_RADIO_A = 11, + RTL819X_PHY_RADIO_A_1T = 12, + RTL819X_PHY_RADIO_A_2T = 13, + RTL819X_PHY_RADIO_B = 14, + RTL819X_PHY_RADIO_B_GM = 15, + RTL819X_PHY_RADIO_C = 16, + RTL819X_PHY_RADIO_D = 17, + RTL819X_EEPROM_MAP = 18, + RTL819X_EFUSE_MAP = 19, }; enum RTL_DEBUG { @@ -212,27 +222,27 @@ enum RTL_DEBUG { COMP_RECV = BIT3, COMP_SEND = BIT4, COMP_CMD = BIT5, - COMP_POWER = BIT6, - COMP_EPROM = BIT7, + COMP_POWER = BIT6, + COMP_EPROM = BIT7, COMP_SWBW = BIT8, COMP_SEC = BIT9, COMP_LPS = BIT10, COMP_QOS = BIT11, COMP_RATE = BIT12, - COMP_RXDESC = BIT13, + COMP_RXDESC = BIT13, COMP_PHY = BIT14, COMP_DIG = BIT15, COMP_TXAGC = BIT16, - COMP_HALDM = BIT17, + COMP_HALDM = BIT17, COMP_POWER_TRACKING = BIT18, - COMP_CH = BIT19, - COMP_RF = BIT20, - COMP_FIRMWARE = BIT21, - COMP_HT = BIT22, + COMP_CH = BIT19, + COMP_RF = BIT20, + COMP_FIRMWARE = BIT21, + COMP_HT = BIT22, COMP_RESET = BIT23, - COMP_CMDPKT = BIT24, + COMP_CMDPKT = BIT24, COMP_SCAN = BIT25, - COMP_PS = BIT26, + COMP_PS = BIT26, COMP_DOWN = BIT27, COMP_INTR = BIT28, COMP_LED = BIT29, @@ -245,11 +255,11 @@ enum nic_t { NIC_8192E = 1, NIC_8190P = 2, NIC_8192SE = 4, - NIC_8192CE = 5, - NIC_8192CU = 6, - NIC_8192DE = 7, - NIC_8192DU = 8, - }; + NIC_8192CE = 5, + NIC_8192CU = 6, + NIC_8192DE = 7, + NIC_8192DU = 8, +}; enum rt_eeprom_type { EEPROM_93C46, @@ -258,7 +268,7 @@ enum rt_eeprom_type { }; enum dcmg_txcmd_op { - TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, + TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, TXCMD_SET_TX_DURATION = 0xFF900003, @@ -268,18 +278,18 @@ enum dcmg_txcmd_op { }; enum rt_rf_type_819xu { - RF_TYPE_MIN = 0, - RF_8225, - RF_8256, - RF_8258, - RF_6052=4, - RF_PSEUDO_11N = 5, + RF_TYPE_MIN = 0, + RF_8225, + RF_8256, + RF_8258, + RF_6052 = 4, + RF_PSEUDO_11N = 5, }; enum rf_step { - RF_STEP_INIT = 0, - RF_STEP_NORMAL, - RF_STEP_MAX + RF_STEP_INIT = 0, + RF_STEP_NORMAL, + RF_STEP_MAX }; enum rt_status { @@ -290,32 +300,32 @@ enum rt_status { }; enum rt_customer_id { - RT_CID_DEFAULT = 0, + RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, RT_CID_8187_SERCOMM_PS = 2, RT_CID_8187_HW_LED = 3, RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, + RT_CID_WHQL = 5, RT_CID_819x_CAMEO = 6, RT_CID_819x_RUNTOP = 7, RT_CID_819x_Senao = 8, - RT_CID_TOSHIBA = 9, + RT_CID_TOSHIBA = 9, RT_CID_819x_Netcore = 10, - RT_CID_Nettronix = 11, - RT_CID_DLINK = 12, - RT_CID_PRONET = 13, - RT_CID_COREGA = 14, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, RT_CID_819x_ALPHA = 15, RT_CID_819x_Sitecom = 16, - RT_CID_CCX = 17, + RT_CID_CCX = 17, RT_CID_819x_Lenovo = 18, - RT_CID_819x_QMI = 19, + RT_CID_819x_QMI = 19, RT_CID_819x_Edimax_Belkin = 20, RT_CID_819x_Sercomm_Belkin = 21, RT_CID_819x_CAMEO1 = 22, RT_CID_819x_MSI = 23, RT_CID_819x_Acer = 24, - RT_CID_819x_HP =27, + RT_CID_819x_HP = 27, RT_CID_819x_CLEVO = 28, RT_CID_819x_Arcadyan_Belkin = 29, RT_CID_819x_SAMSUNG = 30, @@ -329,8 +339,8 @@ enum reset_type { }; enum ic_inferiority_8192s { - IC_INFERIORITY_A = 0, - IC_INFERIORITY_B = 1, + IC_INFERIORITY_A = 0, + IC_INFERIORITY_B = 1, }; enum pci_bridge_vendor { @@ -350,20 +360,20 @@ struct buffer { }; struct rtl_reg_debug { - unsigned int cmd; - struct { - unsigned char type; - unsigned char addr; - unsigned char page; - unsigned char length; - } head; - unsigned char buf[0xff]; + unsigned int cmd; + struct { + unsigned char type; + unsigned char addr; + unsigned char page; + unsigned char length; + } head; + unsigned char buf[0xff]; }; struct rt_tx_rahis { - u32 cck[4]; - u32 ofdm[8]; - u32 ht_mcs[4][16]; + u32 cck[4]; + u32 ofdm[8]; + u32 ht_mcs[4][16]; }; struct rt_smooth_data_4rf { @@ -449,7 +459,7 @@ struct rt_stats { unsigned long txerrunicast; unsigned long txretrycount; unsigned long txfeedbackretry; - u8 last_packet_rate; + u8 last_packet_rate; unsigned long slide_signal_strength[100]; unsigned long slide_evm[100]; unsigned long slide_rssi_total; @@ -496,51 +506,63 @@ struct ccktxbbgain { }; struct init_gain { - u8 xaagccore1; - u8 xbagccore1; - u8 xcagccore1; - u8 xdagccore1; - u8 cca; + u8 xaagccore1; + u8 xbagccore1; + u8 xcagccore1; + u8 xdagccore1; + u8 cca; }; struct tx_ring { - u32 * desc; + u32 *desc; u8 nStuckCount; - struct tx_ring * next; + struct tx_ring *next; } __packed; struct rtl8192_tx_ring { - struct tx_desc *desc; - dma_addr_t dma; - unsigned int idx; - unsigned int entries; - struct sk_buff_head queue; + struct tx_desc *desc; + dma_addr_t dma; + unsigned int idx; + unsigned int entries; + struct sk_buff_head queue; }; -struct rtl819x_ops{ +struct rtl819x_ops { enum nic_t nic_type; - void (* get_eeprom_size)(struct net_device* dev); - void (* init_adapter_variable)(struct net_device* dev); - void (* init_before_adapter_start)(struct net_device* dev); - bool (* initialize_adapter)(struct net_device* dev); - void (*link_change)(struct net_device* dev); - void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, struct cb_desc *cb_desc, struct sk_buff *skb); - void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, struct cb_desc *cb_desc, struct sk_buff *skb); - bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, struct rx_desc *pdesc, struct sk_buff* skb); - bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, struct rx_desc *pdesc); - void (* stop_adapter)(struct net_device *dev, bool reset); - void (* update_ratr_table)(struct net_device* dev); - void (* irq_enable)(struct net_device* dev); - void (* irq_disable)(struct net_device* dev); - void (* irq_clear)(struct net_device* dev); - void (* rx_enable)(struct net_device* dev); - void (* tx_enable)(struct net_device* dev); - void (* interrupt_recognized)(struct net_device *dev, u32 *p_inta, u32 *p_intb); - bool (* TxCheckStuckHandler)(struct net_device* dev); - bool (* RxCheckStuckHandler)(struct net_device* dev); + void (*get_eeprom_size)(struct net_device *dev); + void (*init_adapter_variable)(struct net_device *dev); + void (*init_before_adapter_start)(struct net_device *dev); + bool (*initialize_adapter)(struct net_device *dev); + void (*link_change)(struct net_device *dev); + void (*tx_fill_descriptor)(struct net_device *dev, + struct tx_desc *tx_desc, + struct cb_desc *cb_desc, + struct sk_buff *skb); + void (*tx_fill_cmd_descriptor)(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, + struct sk_buff *skb); + bool (*rx_query_status_descriptor)(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); + bool (*rx_command_packet_handler)(struct net_device *dev, + struct sk_buff *skb, + struct rx_desc *pdesc); + void (*stop_adapter)(struct net_device *dev, bool reset); + void (*update_ratr_table)(struct net_device *dev); + void (*irq_enable)(struct net_device *dev); + void (*irq_disable)(struct net_device *dev); + void (*irq_clear)(struct net_device *dev); + void (*rx_enable)(struct net_device *dev); + void (*tx_enable)(struct net_device *dev); + void (*interrupt_recognized)(struct net_device *dev, + u32 *p_inta, u32 *p_intb); + bool (*TxCheckStuckHandler)(struct net_device *dev); + bool (*RxCheckStuckHandler)(struct net_device *dev); }; struct r8192_priv { @@ -630,8 +652,8 @@ struct r8192_priv { struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - short (*rf_set_sens)(struct net_device *dev,short sens); - u8 (*rf_set_chan)(struct net_device *dev,u8 ch); + short (*rf_set_sens)(struct net_device *dev, short sens); + u8 (*rf_set_chan)(struct net_device *dev, u8 ch); void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); @@ -672,227 +694,229 @@ struct r8192_priv { /**********************************************************/ - enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type; + enum card_type { + PCI, MINIPCI, + CARDBUS, USB + } card_type; struct work_struct qos_activate; - u8 bIbssCoordinator; + u8 bIbssCoordinator; short promisc; short crcmon; - int txbeaconcount; + int txbeaconcount; short chan; short sens; short max_sens; - u32 rx_prevlen; + u32 rx_prevlen; - u8 ScanDelay; - bool ps_force; + u8 ScanDelay; + bool ps_force; - u32 irq_mask[2]; + u32 irq_mask[2]; - u8 Rf_Mode; + u8 Rf_Mode; enum nic_t card_8192; - u8 card_8192_version; + u8 card_8192_version; short enable_gpio0; - u8 rf_type; - u8 IC_Cut; - char nick[IW_ESSID_MAX_SIZE + 1]; + u8 rf_type; + u8 IC_Cut; + char nick[IW_ESSID_MAX_SIZE + 1]; - u8 RegBcnCtrlVal; - bool bHwAntDiv; + u8 RegBcnCtrlVal; + bool bHwAntDiv; - bool bTKIPinNmodeFromReg; - bool bWEPinNmodeFromReg; + bool bTKIPinNmodeFromReg; + bool bWEPinNmodeFromReg; - bool bLedOpenDrain; + bool bLedOpenDrain; - u8 check_roaming_cnt; + u8 check_roaming_cnt; - bool bIgnoreSilentReset; - u32 SilentResetRxSoltNum; - u32 SilentResetRxSlotIndex; - u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; + bool bIgnoreSilentReset; + u32 SilentResetRxSoltNum; + u32 SilentResetRxSlotIndex; + u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; - void *scan_cmd; - u8 hwscan_bw_40; + void *scan_cmd; + u8 hwscan_bw_40; - u16 nrxAMPDU_size; - u8 nrxAMPDU_aggr_num; + u16 nrxAMPDU_size; + u8 nrxAMPDU_aggr_num; - u32 last_rxdesc_tsf_high; - u32 last_rxdesc_tsf_low; + u32 last_rxdesc_tsf_high; + u32 last_rxdesc_tsf_low; + u16 basic_rate; + u8 short_preamble; + u8 dot11CurrentPreambleMode; + u8 slot_time; + u16 SifsTime; - u16 basic_rate; - u8 short_preamble; - u8 dot11CurrentPreambleMode; - u8 slot_time; - u16 SifsTime; + u8 RegWirelessMode; - u8 RegWirelessMode; + u8 firmware_version; + u16 FirmwareSubVersion; + u16 rf_pathmap; + bool AutoloadFailFlag; - u8 firmware_version; - u16 FirmwareSubVersion; - u16 rf_pathmap; - bool AutoloadFailFlag; + u8 RegPciASPM; + u8 RegAMDPciASPM; + u8 RegHwSwRfOffD3; + u8 RegSupportPciASPM; + bool bSupportASPM; - u8 RegPciASPM; - u8 RegAMDPciASPM; - u8 RegHwSwRfOffD3; - u8 RegSupportPciASPM; - bool bSupportASPM; + u32 RfRegChnlVal[2]; - u32 RfRegChnlVal[2]; + u8 ShowRateMode; + u8 RATRTableBitmap; - u8 ShowRateMode; - u8 RATRTableBitmap; - - u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; - u16 EfuseUsedBytes; - u8 EfuseUsedPercentage; + u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; + u16 EfuseUsedBytes; + u8 EfuseUsedPercentage; short epromtype; - u16 eeprom_vid; - u16 eeprom_did; - u16 eeprom_svid; - u16 eeprom_smid; - u8 eeprom_CustomerID; - u16 eeprom_ChannelPlan; - u8 eeprom_version; + u16 eeprom_vid; + u16 eeprom_did; + u16 eeprom_svid; + u16 eeprom_smid; + u8 eeprom_CustomerID; + u16 eeprom_ChannelPlan; + u8 eeprom_version; - u8 EEPROMRegulatory; - u8 EEPROMPwrGroup[2][3]; - u8 EEPROMOptional; + u8 EEPROMRegulatory; + u8 EEPROMPwrGroup[2][3]; + u8 EEPROMOptional; - u8 EEPROMTxPowerLevelCCK[14]; - u8 EEPROMTxPowerLevelOFDM24G[14]; - u8 EEPROMTxPowerLevelOFDM5G[24]; - u8 EEPROMRfACCKChnl1TxPwLevel[3]; - u8 EEPROMRfAOfdmChnlTxPwLevel[3]; - u8 EEPROMRfCCCKChnl1TxPwLevel[3]; - u8 EEPROMRfCOfdmChnlTxPwLevel[3]; - u16 EEPROMTxPowerDiff; - u16 EEPROMAntPwDiff; - u8 EEPROMThermalMeter; - u8 EEPROMPwDiff; - u8 EEPROMCrystalCap; + u8 EEPROMTxPowerLevelCCK[14]; + u8 EEPROMTxPowerLevelOFDM24G[14]; + u8 EEPROMTxPowerLevelOFDM5G[24]; + u8 EEPROMRfACCKChnl1TxPwLevel[3]; + u8 EEPROMRfAOfdmChnlTxPwLevel[3]; + u8 EEPROMRfCCCKChnl1TxPwLevel[3]; + u8 EEPROMRfCOfdmChnlTxPwLevel[3]; + u16 EEPROMTxPowerDiff; + u16 EEPROMAntPwDiff; + u8 EEPROMThermalMeter; + u8 EEPROMPwDiff; + u8 EEPROMCrystalCap; - u8 EEPROMBluetoothCoexist; - u8 EEPROMBluetoothType; - u8 EEPROMBluetoothAntNum; - u8 EEPROMBluetoothAntIsolation; - u8 EEPROMBluetoothRadioShared; + u8 EEPROMBluetoothCoexist; + u8 EEPROMBluetoothType; + u8 EEPROMBluetoothAntNum; + u8 EEPROMBluetoothAntIsolation; + u8 EEPROMBluetoothRadioShared; - u8 EEPROMSupportWoWLAN; - u8 EEPROMBoardType; - u8 EEPROM_Def_Ver; - u8 EEPROMHT2T_TxPwr[6]; - u8 EEPROMTSSI_A; - u8 EEPROMTSSI_B; - u8 EEPROMTxPowerLevelCCK_V1[3]; - u8 EEPROMLegacyHTTxPowerDiff; + u8 EEPROMSupportWoWLAN; + u8 EEPROMBoardType; + u8 EEPROM_Def_Ver; + u8 EEPROMHT2T_TxPwr[6]; + u8 EEPROMTSSI_A; + u8 EEPROMTSSI_B; + u8 EEPROMTxPowerLevelCCK_V1[3]; + u8 EEPROMLegacyHTTxPowerDiff; - u8 BluetoothCoexist; + u8 BluetoothCoexist; - u8 CrystalCap; - u8 ThermalMeter[2]; + u8 CrystalCap; + u8 ThermalMeter[2]; - u16 FwCmdIOMap; - u32 FwCmdIOParam; + u16 FwCmdIOMap; + u32 FwCmdIOParam; - u8 SwChnlInProgress; - u8 SwChnlStage; - u8 SwChnlStep; - u8 SetBWModeInProgress; + u8 SwChnlInProgress; + u8 SwChnlStage; + u8 SwChnlStep; + u8 SetBWModeInProgress; - u8 nCur40MhzPrimeSC; + u8 nCur40MhzPrimeSC; - u32 RfReg0Value[4]; - u8 NumTotalRFPath; - bool brfpath_rxenable[4]; + u32 RfReg0Value[4]; + u8 NumTotalRFPath; + bool brfpath_rxenable[4]; - bool bTXPowerDataReadFromEEPORM; + bool bTXPowerDataReadFromEEPORM; - u16 RegChannelPlan; - u16 ChannelPlan; - bool bChnlPlanFromHW; + u16 RegChannelPlan; + u16 ChannelPlan; + bool bChnlPlanFromHW; - bool RegRfOff; - bool isRFOff; - bool bInPowerSaveMode; - u8 bHwRfOffAction; + bool RegRfOff; + bool isRFOff; + bool bInPowerSaveMode; + u8 bHwRfOffAction; - bool aspm_clkreq_enable; - u32 pci_bridge_vendor; - u8 RegHostPciASPMSetting; - u8 RegDevicePciASPMSetting; + bool aspm_clkreq_enable; + u32 pci_bridge_vendor; + u8 RegHostPciASPMSetting; + u8 RegDevicePciASPMSetting; - bool RFChangeInProgress; - bool SetRFPowerStateInProgress; - bool bdisable_nic; + bool RFChangeInProgress; + bool SetRFPowerStateInProgress; + bool bdisable_nic; - u8 pwrGroupCnt; + u8 pwrGroupCnt; - u8 ThermalValue_LCK; - u8 ThermalValue_IQK; - bool bRfPiEnable; + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + bool bRfPiEnable; - u32 APKoutput[2][2]; - bool bAPKdone; + u32 APKoutput[2][2]; + bool bAPKdone; - long RegE94; - long RegE9C; - long RegEB4; - long RegEBC; + long RegE94; + long RegE9C; + long RegEB4; + long RegEBC; - u32 RegC04; - u32 Reg874; - u32 RegC08; - u32 ADDA_backup[16]; - u32 IQK_MAC_backup[3]; + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 ADDA_backup[16]; + u32 IQK_MAC_backup[3]; - bool SetFwCmdInProgress; - u8 CurrentFwCmdIO; + bool SetFwCmdInProgress; + u8 CurrentFwCmdIO; - u8 rssi_level; + u8 rssi_level; - bool bInformFWDriverControlDM; - u8 PwrGroupHT20[2][14]; - u8 PwrGroupHT40[2][14]; + bool bInformFWDriverControlDM; + u8 PwrGroupHT20[2][14]; + u8 PwrGroupHT40[2][14]; - u8 ThermalValue; - long EntryMinUndecoratedSmoothedPWDB; - long EntryMaxUndecoratedSmoothedPWDB; - u8 DynamicTxHighPowerLvl; - u8 LastDTPLvl; - u32 CurrentRATR0; + u8 ThermalValue; + long EntryMinUndecoratedSmoothedPWDB; + long EntryMaxUndecoratedSmoothedPWDB; + u8 DynamicTxHighPowerLvl; + u8 LastDTPLvl; + u32 CurrentRATR0; struct false_alarm_stats FalseAlmCnt; - u8 DMFlag; - u8 DM_Type; + u8 DMFlag; + u8 DM_Type; - u8 CckPwEnl; - u16 TSSI_13dBm; - u32 Pwr_Track; - u8 CCKPresentAttentuation_20Mdefault; - u8 CCKPresentAttentuation_40Mdefault; - char CCKPresentAttentuation_difference; - char CCKPresentAttentuation; - u8 bCckHighPower; - long undecorated_smoothed_pwdb; - long undecorated_smoothed_cck_adc_pwdb[4]; + u8 CckPwEnl; + u16 TSSI_13dBm; + u32 Pwr_Track; + u8 CCKPresentAttentuation_20Mdefault; + u8 CCKPresentAttentuation_40Mdefault; + char CCKPresentAttentuation_difference; + char CCKPresentAttentuation; + u8 bCckHighPower; + long undecorated_smoothed_pwdb; + long undecorated_smoothed_cck_adc_pwdb[4]; - u32 MCSTxPowerLevelOriginalOffset[6]; - u32 CCKTxPowerLevelOriginalOffset; - u8 TxPowerLevelCCK[14]; - u8 TxPowerLevelCCK_A[14]; - u8 TxPowerLevelCCK_C[14]; + u32 MCSTxPowerLevelOriginalOffset[6]; + u32 CCKTxPowerLevelOriginalOffset; + u8 TxPowerLevelCCK[14]; + u8 TxPowerLevelCCK_A[14]; + u8 TxPowerLevelCCK_C[14]; u8 TxPowerLevelOFDM24G[14]; u8 TxPowerLevelOFDM5G[14]; u8 TxPowerLevelOFDM24G_A[14]; @@ -962,7 +986,7 @@ struct r8192_priv { u8 framesyncMonitor; bool bDMInitialGainEnable; - bool MutualAuthenticationFail; + bool MutualAuthenticationFail; bool bDisableFrameBursting; @@ -1016,41 +1040,42 @@ struct r8192_priv { extern const struct ethtool_ops rtl819x_ethtool_ops; void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb); -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb); +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb); u8 read_nic_io_byte(struct net_device *dev, int x); u32 read_nic_io_dword(struct net_device *dev, int x); u16 read_nic_io_word(struct net_device *dev, int x) ; -void write_nic_io_byte(struct net_device *dev, int x,u8 y); -void write_nic_io_word(struct net_device *dev, int x,u16 y); -void write_nic_io_dword(struct net_device *dev, int x,u32 y); +void write_nic_io_byte(struct net_device *dev, int x, u8 y); +void write_nic_io_word(struct net_device *dev, int x, u16 y); +void write_nic_io_dword(struct net_device *dev, int x, u32 y); u8 read_nic_byte(struct net_device *dev, int x); u32 read_nic_dword(struct net_device *dev, int x); u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); +void write_nic_byte(struct net_device *dev, int x, u8 y); +void write_nic_word(struct net_device *dev, int x, u16 y); +void write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); void rtl8192_rx_enable(struct net_device *); void rtl8192_tx_enable(struct net_device *); -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev); -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate); +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev); +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate); void rtl8192_data_hard_stop(struct net_device *dev); void rtl8192_data_hard_resume(struct net_device *dev); void rtl8192_restart(void *data); void rtl819x_watchdog_wqcallback(void *data); -void rtl8192_hw_sleep_wq (void *data); +void rtl8192_hw_sleep_wq(void *data); void watch_dog_timer_callback(unsigned long data); void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); void rtl8192_irq_tx_tasklet(struct r8192_priv *priv); -int rtl8192_down(struct net_device *dev,bool shutdownrf); +int rtl8192_down(struct net_device *dev, bool shutdownrf); int rtl8192_up(struct net_device *dev); void rtl8192_commit(struct net_device *dev); -void rtl8192_set_chan(struct net_device *dev,short ch); +void rtl8192_set_chan(struct net_device *dev, short ch); void check_rfctrl_gpio_timer(unsigned long data); @@ -1059,44 +1084,42 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); short rtl8192_pci_initdescring(struct net_device *dev); -void rtl8192_cancel_deferred_work(struct r8192_priv * priv); +void rtl8192_cancel_deferred_work(struct r8192_priv *priv); -int _rtl8192_up(struct net_device *dev,bool is_silent_reset); +int _rtl8192_up(struct net_device *dev, bool is_silent_reset); short rtl8192_is_tx_queue_empty(struct net_device *dev); void rtl8192_irq_disable(struct net_device *dev); void rtl8192_tx_timeout(struct net_device *dev); void rtl8192_pci_resetdescring(struct net_device *dev); -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode); +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode); void rtl8192_irq_enable(struct net_device *dev); -void rtl8192_config_rate(struct net_device* dev, u16* rate_config); -void rtl8192_update_cap(struct net_device* dev, u16 cap); +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config); +void rtl8192_update_cap(struct net_device *dev, u16 cap); void rtl8192_irq_disable(struct net_device *dev); -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats); -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ); -void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats); +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index); +void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); u8 rtl819x_evm_dbtopercentage(char value); -void rtl819x_process_cck_rxpathsel(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); -u8 rtl819x_query_rxpwrpercentage( char antpower ); -void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats * psrc_stats,struct rtllib_rx_stats * ptarget_stats); +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); +u8 rtl819x_query_rxpwrpercentage(char antpower); +void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats); -bool NicIFEnableNIC(struct net_device* dev); -bool NicIFDisableNIC(struct net_device* dev); +bool NicIFEnableNIC(struct net_device *dev); +bool NicIFDisableNIC(struct net_device *dev); -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ); -void -ActUpdateChannelAccessSetting( - struct net_device* dev, - enum wireless_mode WirelessMode, - struct channel_access_setting *ChnlAccessSetting - ); +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot); +void ActUpdateChannelAccessSetting(struct net_device *dev, + enum wireless_mode WirelessMode, + struct channel_access_setting *ChnlAccessSetting); #endif From cffa5bd956cb65f68de8fa3fe8d0188fca196bf4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:21 -0500 Subject: [PATCH 0550/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IX Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_crypto.h | 80 +-- drivers/staging/rtl8192e/rtl_debug.c | 712 +++++++++++++------------- drivers/staging/rtl8192e/rtl_debug.h | 236 ++++----- 3 files changed, 511 insertions(+), 517 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h index 7b4551db961..ee57c0f4fa6 100644 --- a/drivers/staging/rtl8192e/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #define crypto_register_alg crypto_register_alg_rsl #define crypto_unregister_alg crypto_unregister_alg_rsl @@ -73,7 +73,7 @@ struct cipher_alg { unsigned int cia_min_keysize; unsigned int cia_max_keysize; int (*cia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); }; @@ -84,16 +84,16 @@ struct digest_alg { void (*dia_update)(void *ctx, const u8 *data, unsigned int len); void (*dia_final)(void *ctx, u8 *out); int (*dia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); }; struct compress_alg { int (*coa_init)(void *ctx); void (*coa_exit)(void *ctx); int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); }; #define cra_cipher cra_u.cipher @@ -139,15 +139,15 @@ struct cipher_tfm { unsigned int cit_ivsize; u32 cit_mode; int (*cit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); int (*cit_encrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes); int (*cit_encrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv); int (*cit_decrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, @@ -162,21 +162,21 @@ struct cipher_tfm { struct digest_tfm { void (*dit_init)(struct crypto_tfm *tfm); void (*dit_update)(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); + struct scatterlist *sg, unsigned int nsg); void (*dit_final)(struct crypto_tfm *tfm, u8 *out); void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, - unsigned int nsg, u8 *out); + unsigned int nsg, u8 *out); int (*dit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); }; struct compress_tfm { int (*cot_compress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); int (*cot_decompress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); }; #define crt_cipher crt_u.cipher @@ -274,8 +274,8 @@ static inline void crypto_digest_init(struct crypto_tfm *tfm) } static inline void crypto_digest_update(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg) + struct scatterlist *sg, + unsigned int nsg) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_update(tfm, sg, nsg); @@ -288,15 +288,15 @@ static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out) } static inline void crypto_digest_digest(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg, u8 *out) + struct scatterlist *sg, + unsigned int nsg, u8 *out) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_digest(tfm, sg, nsg, out); } static inline int crypto_digest_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); if (tfm->crt_digest.dit_setkey == NULL) @@ -305,25 +305,25 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm, } static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_setkey(tfm, key, keylen); } static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -331,18 +331,18 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, } static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -350,30 +350,30 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, } static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, - const u8 *src, unsigned int len) + const u8 *src, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(tfm->crt_cipher.cit_iv, src, len); } static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, - u8 *dst, unsigned int len) + u8 *dst, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(dst, tfm->crt_cipher.cit_iv, len); } static inline int crypto_comp_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen); } static inline int crypto_comp_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 5c2d01c8b45..22bc2dd6e43 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -53,12 +53,10 @@ u32 DBGP_Type[DBGP_TYPE_MAX]; *---------------------------------------------------------------------------*/ void rtl8192_dbgp_flag_init(struct net_device *dev) { - u8 i; + u8 i; for (i = 0; i < DBGP_TYPE_MAX; i++) - { DBGP_Type[i] = 0; - } } /* DBGP_Flag_Init */ @@ -67,19 +65,19 @@ void rtl8192_dbgp_flag_init(struct net_device *dev) void print_buffer(u32 *buffer, int len) { int i; - u8 *buf =(u8*)buffer; + u8 *buf = (u8 *)buffer; - printk("ASCII BUFFER DUMP (len: %x):\n",len); + printk(KERN_INFO "ASCII BUFFER DUMP (len: %x):\n", len); - for (i=0;i ", n); + printk(KERN_INFO "\nD: %2x> ", n); for (i = 0; i < 16 && n <= max; i++, n++) - printk("%2x ", read_nic_byte(dev, n)); + printk(KERN_INFO "%2x ", read_nic_byte(dev, n)); } - printk("\n"); + printk(KERN_INFO "\n"); } /**************************************************************************** -----------------------------PROCFS STUFF------------------------- *****************************************************************************/ /*This part is related to PROC, which will record some statistics. */ -static struct proc_dir_entry *rtl8192_proc = NULL; +static struct proc_dir_entry *rtl8192_proc; static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, @@ -123,24 +121,21 @@ static int proc_get_stats_ap(char *page, char **start, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; struct rtllib_network *target; - int len = 0; - list_for_each_entry(target, &ieee->network_list, list) { + list_for_each_entry(target, &ieee->network_list, list) { len += snprintf(page + len, count - len, - "%s ", target->ssid); + "%s ", target->ssid); - if (target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) + len += snprintf(page + len, count - len, + "WPA\n"); + else + len += snprintf(page + len, count - len, + "non_WPA\n"); - } + } *eof = 1; return len; @@ -153,25 +148,25 @@ static int proc_get_registers_0(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x000; - { - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;n++,i++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; n++, i++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -183,25 +178,27 @@ static int proc_get_registers_1(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x100; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -213,25 +210,27 @@ static int proc_get_registers_2(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x200; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0 >> 8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -243,25 +242,27 @@ static int proc_get_registers_3(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x300; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -273,117 +274,125 @@ static int proc_get_registers_4(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x400; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } static int proc_get_registers_5(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x500; + int max = 0xff; + page0 = 0x500; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_6(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x600; + int max = 0xff; + page0 = 0x600; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_7(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x700; + int max = 0xff; + page0 = 0x700; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_8(char *page, char **start, @@ -393,22 +402,23 @@ static int proc_get_registers_8(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x800; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -420,22 +430,23 @@ static int proc_get_registers_9(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x900; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -446,22 +457,23 @@ static int proc_get_registers_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xa00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -472,22 +484,23 @@ static int proc_get_registers_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xb00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -498,22 +511,23 @@ static int proc_get_registers_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xc00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -524,22 +538,23 @@ static int proc_get_registers_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xd00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -550,22 +565,23 @@ static int proc_get_registers_e(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xe00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -577,21 +593,22 @@ static int proc_get_reg_rf_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-A ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_A,n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_A, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -603,21 +620,22 @@ static int proc_get_reg_rf_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-B ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_B, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_B, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -629,21 +647,22 @@ static int proc_get_reg_rf_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### RF-C ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n#################### RF-C ##################\n"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_C, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_C, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -655,21 +674,22 @@ static int proc_get_reg_rf_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-D ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_D, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_D, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -679,41 +699,38 @@ static int proc_get_cam_register_1(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (0-10) ##################\n "); - for (j=0; j<11; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i+CAM_CONTENT_COUNT*j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -723,41 +740,38 @@ static int proc_get_cam_register_2(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (11-21) ##################\n "); - for (j=11; j<22; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -767,41 +781,38 @@ static int proc_get_cam_register_3(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (22-31) ##################\n "); - for (j=22; j ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -877,7 +888,7 @@ static int proc_get_stats_rx(char *page, char **start, void rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); + rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); } @@ -891,7 +902,7 @@ void rtl8192_proc_remove_one(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - printk("dev name %s\n",dev->name); + printk(KERN_INFO "dev name %s\n", dev->name); if (priv->dir_dev) { remove_proc_entry("stats-tx", priv->dir_dev); @@ -929,194 +940,169 @@ void rtl8192_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtl8192_proc); if (!priv->dir_dev) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); + RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192" + "/%s\n", dev->name); return; } e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - if (!e) { - RT_TRACE(COMP_ERR,"Unable to initialize " + if (!e) + RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-rx\n", dev->name); - } - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-tx\n", dev->name); - } e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-ap\n", dev->name); - } e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_0, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-0\n", dev->name); - } e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-1\n", dev->name); - } e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-2\n", dev->name); - } e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-3\n", dev->name); - } e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_4, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-4\n", dev->name); - } e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_5, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-5\n", dev->name); - } e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_6, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-6\n", dev->name); - } e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_7, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-7\n", dev->name); - } e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_8, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-8\n", dev->name); - } e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_9, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-9\n", dev->name); - } e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-a\n", dev->name); - } e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-b\n", dev->name); - } e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-c\n", dev->name); - } e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-d\n", dev->name); - } e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_e, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-e\n", dev->name); - } e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-A\n", dev->name); - } e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-B\n", dev->name); - } e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-C\n", dev->name); - } e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-D\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-1\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-2\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-3\n", dev->name); - } } diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 415dfca6b37..50fb9a9b828 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -36,31 +36,30 @@ struct net_device; #define DBG_LOUD 4 -#define RT_ASSERT(_Exp,Fmt) \ - if (!(_Exp)) \ - { \ - printk("Rtl819x: "); \ - printk Fmt; \ +#define RT_ASSERT(_Exp, Fmt) \ + if (!(_Exp)) { \ + printk("Rtl819x: "); \ + printk Fmt; \ } enum dbgp_flag { FQoS = 0, - FTX = 1, - FRX = 2, + FTX = 1, + FRX = 2, FSEC = 3, FMGNT = 4, FMLME = 5, FRESOURCE = 6, - FBEACON = 7, + FBEACON = 7, FISR = 8, FPHY = 9, - FMP = 10, - FEEPROM = 11, + FMP = 10, + FEEPROM = 11, FPWR = 12, - FDM = 13, - FDBGCtrl = 14, + FDM = 13, + FDBGCtrl = 14, FC2H = 15, - FBT = 16, + FBT = 16, FINIT = 17, FIOCTL = 18, DBGP_TYPE_MAX @@ -76,10 +75,10 @@ enum dbgp_flag { #define RX_PHY_STS BIT1 #define RX_PHY_SS BIT2 #define RX_PHY_SQ BIT3 -#define RX_PHY_ASTS BIT4 +#define RX_PHY_ASTS BIT4 #define RX_ERR_LEN BIT5 #define RX_DEFRAG BIT6 -#define RX_ERR_RATE BIT7 +#define RX_ERR_RATE BIT7 @@ -93,68 +92,68 @@ enum dbgp_flag { #define ISR_CHK BIT0 -#define PHY_BBR BIT0 -#define PHY_BBW BIT1 -#define PHY_RFR BIT2 -#define PHY_RFW BIT3 +#define PHY_BBR BIT0 +#define PHY_BBW BIT1 +#define PHY_RFR BIT2 +#define PHY_RFW BIT3 #define PHY_MACR BIT4 #define PHY_MACW BIT5 #define PHY_ALLR BIT6 #define PHY_ALLW BIT7 #define PHY_TXPWR BIT8 -#define PHY_PWRDIFF BIT9 +#define PHY_PWRDIFF BIT9 #define MP_RX BIT0 -#define MP_SWICH_CH BIT1 +#define MP_SWICH_CH BIT1 #define EEPROM_W BIT0 #define EFUSE_PG BIT1 -#define EFUSE_READ_ALL BIT2 +#define EFUSE_READ_ALL BIT2 -#define LPS BIT0 -#define IPS BIT1 +#define LPS BIT0 +#define IPS BIT1 #define PWRSW BIT2 #define PWRHW BIT3 #define PWRHAL BIT4 #define WA_IOT BIT0 -#define DM_PWDB BIT1 +#define DM_PWDB BIT1 #define DM_Monitor BIT2 #define DM_DIG BIT3 -#define DM_EDCA_Turbo BIT4 +#define DM_EDCA_Turbo BIT4 -#define DbgCtrl_Trace BIT0 -#define DbgCtrl_InbandNoise BIT1 +#define DbgCtrl_Trace BIT0 +#define DbgCtrl_InbandNoise BIT1 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 -#define C2H_Summary BIT0 -#define C2H_PacketData BIT1 -#define C2H_ContentData BIT2 +#define C2H_Summary BIT0 +#define C2H_PacketData BIT1 +#define C2H_ContentData BIT2 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 #define INIT_EEPROM BIT0 -#define INIT_TxPower BIT1 +#define INIT_TxPower BIT1 #define INIT_IQK BIT2 #define INIT_RF BIT3 -#define IOCTL_TRACE BIT0 -#define IOCTL_BT_EVENT BIT1 +#define IOCTL_TRACE BIT0 +#define IOCTL_BT_EVENT BIT1 #define IOCTL_BT_EVENT_DETAIL BIT2 #define IOCTL_BT_TX_ACLDATA BIT3 #define IOCTL_BT_TX_ACLDATA_DETAIL BIT4 #define IOCTL_BT_RX_ACLDATA BIT5 -#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 +#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 #define IOCTL_BT_HCICMD BIT7 #define IOCTL_BT_HCICMD_DETAIL BIT8 -#define IOCTL_IRP BIT9 -#define IOCTL_IRP_DETAIL BIT10 -#define IOCTL_CALLBACK_FUN BIT11 -#define IOCTL_STATE BIT12 -#define IOCTL_BT_TP BIT13 -#define IOCTL_BT_LOGO BIT14 +#define IOCTL_IRP BIT9 +#define IOCTL_IRP_DETAIL BIT10 +#define IOCTL_CALLBACK_FUN BIT11 +#define IOCTL_STATE BIT12 +#define IOCTL_BT_TP BIT13 +#define IOCTL_BT_LOGO BIT14 /* 2007/07/13 MH ------For DeBuG Print modeue------*/ /*------------------------------Define structure----------------------------*/ @@ -164,97 +163,98 @@ enum dbgp_flag { #define DEBUG_PRINT 1 #if (DEBUG_PRINT == 1) -#define RTPRINT(dbgtype, dbgflag, printstr) \ -{ \ - if (DBGP_Type[dbgtype] & dbgflag)\ - { \ +#define RTPRINT(dbgtype, dbgflag, printstr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ printk printstr; \ - } \ + } \ } -#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_Ptr; \ - printk printstr; \ - printk(" "); \ - for ( __i=0; __i<6; __i++ ) \ - printk("%02X%s", ptr[__i], (__i==5)?"":"-"); \ - printk("\n"); \ - }\ +#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_Ptr; \ + printk printstr; \ + printk(" "); \ + for (__i = 0; __i < 6; __i++) \ + printk("%02X%s", ptr[__i], \ + (__i == 5) ? "" : "-"); \ + printk("\n"); \ + } \ } #define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\ - if (((__i + 1) % 16) == 0) printk("\n");\ - } \ - printk("\n"); \ - }\ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_HexData; \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) \ + % 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ + } \ } #else #define RTPRINT(dbgtype, dbgflag, printstr) #define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) -#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) +#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) #endif extern u32 DBGP_Type[DBGP_TYPE_MAX]; -#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ +#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ do {\ - if (((_Comp) & rt_global_debug_component ) && (_Level <= rt_global_debug_component )) \ - { \ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk("Rtl819x: "); \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \ - if (((__i + 1) % 16) == 0) printk("\n"); \ - } \ - printk("\n"); \ + if (((_Comp) & rt_global_debug_component) && \ + (_Level <= rt_global_debug_component)) { \ + int __i; \ + u8* ptr = (u8 *)_HexData; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) % \ + 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ } \ -}while(0); +} while (0); -#define DMESG(x,a...) -#define DMESGW(x,a...) -#define DMESGE(x,a...) +#define DMESG(x, a...) +#define DMESGW(x, a...) +#define DMESGE(x, a...) extern u32 rt_global_debug_component; #define RT_TRACE(component, x, args...) \ -do { if (rt_global_debug_component & component) \ - printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ - ##args);\ -}while(0); +do { \ + if (rt_global_debug_component & component) \ + printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ + ##args);\ +} while (0); #define assert(expr) \ - if (!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n", \ - #expr,__FILE__,__func__,__LINE__); \ - } + if (!(expr)) { \ + printk(KERN_INFO "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr, __FILE__, __func__, __LINE__); \ + } #define RT_DEBUG_DATA(level, data, datalen) \ - do{ if ((rt_global_debug_component & (level)) == (level)) \ - { \ - int _i; \ - u8* _pdata = (u8*) data; \ - printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ - for (_i=0; _i<(int)(datalen); _i++) \ - { \ - printk("%2x ", _pdata[_i]); \ - if ((_i+1)%16 == 0) printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) + do { \ + if ((rt_global_debug_component & (level)) == (level)) {\ + int _i; \ + u8 *_pdata = (u8 *)data; \ + printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ + for (_i = 0; _i < (int)(datalen); _i++) { \ + printk(KERN_INFO "%2x ", _pdata[_i]); \ + if ((_i+1) % 16 == 0) \ + printk("\n"); \ + } \ + printk(KERN_INFO "\n"); \ + } \ + } while (0) struct rtl_fs_debug { const char *name; @@ -270,16 +270,23 @@ void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); /* debugfs stuff */ -static inline int rtl_debug_module_init(struct r8192_priv *priv, const char *name) { +static inline int rtl_debug_module_init(struct r8192_priv *priv, + const char *name) +{ return 0; } -static inline void rtl_debug_module_remove(struct r8192_priv *priv) { +static inline void rtl_debug_module_remove(struct r8192_priv *priv) +{ } -static inline int rtl_create_debugfs_root(void) { + +static inline int rtl_create_debugfs_root(void) +{ return 0; } -static inline void rtl_remove_debugfs_root(void) { + +static inline void rtl_remove_debugfs_root(void) +{ } /* proc stuff */ @@ -288,4 +295,5 @@ void rtl8192_proc_remove_one(struct net_device *dev); void rtl8192_proc_module_init(void); void rtl8192_proc_module_remove(void); void rtl8192_dbgp_flag_init(struct net_device *dev); + #endif From b448b0cc13112c7bdfdef2b242f15f2c86bd31f1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:22 -0500 Subject: [PATCH 0551/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part X With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_dm.c | 2442 +++++++++++++---------------- drivers/staging/rtl8192e/rtl_dm.h | 61 +- 2 files changed, 1128 insertions(+), 1375 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 3ab71c78634..291ec3e9d22 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -25,37 +25,37 @@ #include "r8192E_cmdpkt.h" /*---------------------------Define Local Constant---------------------------*/ -static u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4332 - }; - -static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4322 +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4332 }; -static u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0xa44f, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0x5e4322, - 0x5e4322, - 0x5e4332 +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0x5e4322, + 0x5e4322, + 0x5e4332 }; #define RTK_UL_EDCA 0xa44f @@ -65,7 +65,10 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = /*------------------------Define global variable-----------------------------*/ struct dig_t dm_digtable; -u8 dm_shadow[16][256] = {{0}}; +u8 dm_shadow[16][256] = { + {0} +}; + struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ @@ -74,46 +77,12 @@ struct drx_path_sel DM_RxPathSelTable; /*------------------------Define local variable------------------------------*/ -/*--------------------Define export function prototype-----------------------*/ -extern void init_hal_dm(struct net_device *dev); -extern void deinit_hal_dm(struct net_device *dev); - -extern void hal_dm_watchdog(struct net_device *dev); - - -extern void init_rate_adaptive(struct net_device *dev); -extern void dm_txpower_trackingcallback(void *data); - -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); -extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); -extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); -extern void dm_rf_pathcheck_workitemcallback(void *data); -extern void dm_fsync_timer_callback(unsigned long data); -extern void dm_check_fsync(struct net_device *dev); -extern void dm_shadow_init(struct net_device *dev); -extern void dm_initialize_txpower_tracking(struct net_device *dev); - -extern void dm_CheckRfCtrlGPIO(void *data); - - -/*--------------------Define export function prototype-----------------------*/ - /*---------------------Define local function prototype-----------------------*/ static void dm_check_rate_adaptive(struct net_device *dev); -static void dm_init_bandwidth_autoswitch (struct net_device *dev); -static void dm_bandwidth_autoswitch ( struct net_device *dev); +static void dm_init_bandwidth_autoswitch(struct net_device *dev); +static void dm_bandwidth_autoswitch(struct net_device *dev); static void dm_check_txpower_tracking(struct net_device *dev); @@ -130,7 +99,7 @@ static void dm_bb_initialgain_backup(struct net_device *dev); static void dm_dig_init(struct net_device *dev); static void dm_ctrl_initgain_byrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev); -static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev); +static void dm_ctrl_initgain_byrssi_by_driverrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev); static void dm_initial_gain(struct net_device *dev); static void dm_pd_th(struct net_device *dev); @@ -179,14 +148,14 @@ init_hal_dm(struct net_device *dev) dm_dig_init(dev); dm_init_edca_turbo(dev); - dm_init_bandwidth_autoswitch (dev); + dm_init_bandwidth_autoswitch(dev); dm_init_fsync(dev); dm_init_rxpath_selection(dev); dm_init_ctstoself(dev); - if (IS_HARDWARE_TYPE_8192SE(dev)) - dm_Init_WA_Broadcom_IOT(dev); + if (IS_HARDWARE_TYPE_8192SE(dev)) + dm_Init_WA_Broadcom_IOT(dev); - INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO,dev); + INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } extern void deinit_hal_dm(struct net_device *dev) @@ -213,7 +182,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_check_txpower_tracking(dev); dm_ctrl_initgain_byrssi(dev); - dm_bandwidth_autoswitch (dev); + dm_bandwidth_autoswitch(dev); dm_check_rx_path_selection(dev); dm_check_fsync(dev); @@ -226,28 +195,27 @@ void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; - char *argv[] = {ac_dc_check_script_path,DRV_NAME,NULL}; + char *argv[] = {ac_dc_check_script_path, DRV_NAME, NULL}; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - if (priv->ResetProgress == RESET_TYPE_SILENT) - { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); + if (priv->ResetProgress == RESET_TYPE_SILENT) { + RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), + "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); return; } - if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->state != RTLLIB_LINKED) return; - } - call_usermodehelper(ac_dc_check_script_path,argv,envp,1); + call_usermodehelper(ac_dc_check_script_path, argv, envp, 1); return; }; -extern void init_rate_adaptive(struct net_device * dev) +extern void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -269,17 +237,14 @@ extern void init_rate_adaptive(struct net_device * dev) pra->ping_rssi_thresh_for_ra = 15; - if (priv->rf_type == RF_2T4R) - { + if (priv->rf_type == RF_2T4R) { pra->upper_rssi_threshold_ratr = 0x8f0f0000; pra->middle_rssi_threshold_ratr = 0x8f0ff000; pra->low_rssi_threshold_ratr = 0x8f0ff001; pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; pra->ping_rssi_ratr = 0x0000000d; - } - else if (priv->rf_type == RF_1T2R) - { + } else if (priv->rf_type == RF_1T2R) { pra->upper_rssi_threshold_ratr = 0x000fc000; pra->middle_rssi_threshold_ratr = 0x000ff000; pra->low_rssi_threshold_ratr = 0x000ff001; @@ -291,17 +256,17 @@ extern void init_rate_adaptive(struct net_device * dev) } -static void dm_check_rate_adaptive(struct net_device * dev) +static void dm_check_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; - u32 currentRATR, targetRATR = 0; - u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; - bool bshort_gi_enabled = false; - static u8 ping_rssi_state=0; + u32 currentRATR, targetRATR = 0; + u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; + bool bshort_gi_enabled = false; + static u8 ping_rssi_state; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); return; } @@ -309,83 +274,66 @@ static void dm_check_rate_adaptive(struct net_device * dev) if (pra->rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode == WIRELESS_MODE_N_24G || - priv->rtllib->mode == WIRELESS_MODE_N_5G)) - return; + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; - if ( priv->rtllib->state == RTLLIB_LINKED ) - { + if (priv->rtllib->state == RTLLIB_LINKED) { bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - } - else - { + (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + } else { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); } pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (pra->ratr_state == DM_RATR_STA_HIGH) - { + if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); - } - else if (pra->ratr_state == DM_RATR_STA_LOW) - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); + } else if (pra->ratr_state == DM_RATR_STA_LOW) { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); - } - else - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M); + } else { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } - if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) - { + if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_HIGH; targetRATR = pra->upper_rssi_threshold_ratr; - }else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) - { + } else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_MIDDLE; targetRATR = pra->middle_rssi_threshold_ratr; - }else - { + } else { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->low_rssi_threshold_ratr; } - if (pra->ping_rssi_enable) - { - if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) - { - if ( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || - ping_rssi_state ) - { + if (pra->ping_rssi_enable) { + if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) { + if ((priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || + ping_rssi_state) { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->ping_rssi_ratr; ping_rssi_state = 1; } - } - else - { + } else { ping_rssi_state = 0; } } @@ -394,30 +342,26 @@ static void dm_check_rate_adaptive(struct net_device * dev) targetRATR &= 0xf00fffff; currentRATR = read_nic_dword(dev, RATR0); - if ( targetRATR != currentRATR ) - { + if (targetRATR != currentRATR) { u32 ratr_value; ratr_value = targetRATR; - RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR); + RT_TRACE(COMP_RATE, + "currentRATR = %x, targetRATR = %x\n", + currentRATR, targetRATR); if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); pra->last_ratr = targetRATR; } - } - else - { + } else { pra->ratr_state = DM_RATR_STA_MAX; } - } -static void dm_init_bandwidth_autoswitch (struct net_device * dev) +static void dm_init_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -425,22 +369,23 @@ static void dm_init_bandwidth_autoswitch (struct net_device * dev) priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW; priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; priv->rtllib->bandwidth_auto_switch.bautoswitch_enable = false; - } - -static void dm_bandwidth_autoswitch (struct net_device * dev) +static void dm_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->rtllib->bandwidth_auto_switch.bautoswitch_enable){ + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || + !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) { return; - }else{ - if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false){ - if (priv->undecorated_smoothed_pwdb <= priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) + } else { + if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) { + if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true; - }else{ - if (priv->undecorated_smoothed_pwdb >= priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) + } else { + if (priv->undecorated_smoothed_pwdb >= + priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; } @@ -468,6 +413,7 @@ static u32 OFDMSwingTable[OFDM_Table_Length] = { 0x12000048, 0x10000040 }; + static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, @@ -497,25 +443,27 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} }; + #define Pw_Track_Flag 0x11d #define Tssi_Mea_Value 0x13c #define Tssi_Report_Value1 0x134 #define Tssi_Report_Value2 0x13e #define FW_Busy_Flag 0x13f -static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) - { +static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) +{ struct r8192_priv *priv = rtllib_priv(dev); - bool bHighpowerstate, viviflag = false; + bool bHighpowerstate, viviflag = false; struct dcmd_txcmd tx_cmd; - u8 powerlevelOFDM24G; - int i =0, j = 0, k = 0; - u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; - u32 Value; - u8 Pwr_Flag; - u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; - u32 delta=0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); + u8 powerlevelOFDM24G; + int i = 0, j = 0, k = 0; + u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0}; + u32 Value; + u8 Pwr_Flag; + u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0; + u32 delta = 0; + + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); priv->rtllib->bdynamic_txpower_enable = false; @@ -525,305 +473,312 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) RF_Type = priv->rf_type; Value = (RF_Type<<8) | powerlevelOFDM24G; - RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); + RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", + powerlevelOFDM24G); - for (j = 0; j<=30; j++) -{ + for (j = 0; j <= 30; j++) { - tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; - tx_cmd.Length = 4; - tx_cmd.Value = Value; - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); - mdelay(1); - for (i = 0;i <= 30; i++) - { - Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); + tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; + tx_cmd.Length = 4; + tx_cmd.Value = Value; + cmpk_message_handle_tx(dev, (u8 *)&tx_cmd, + DESC_PACKET_TYPE_INIT, + sizeof(struct dcmd_txcmd)); + mdelay(1); + for (i = 0; i <= 30; i++) { + Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); - if (Pwr_Flag == 0) - { - mdelay(1); + if (Pwr_Flag == 0) { + mdelay(1); - if (priv->bResetInProgress) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in slient reset progress, so return\n"); - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; + if (priv->bResetInProgress) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in slient reset progress, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + if ((priv->rtllib->eRFPowerState != eRfOn)) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in power save, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + + continue; } - if ((priv->rtllib->eRFPowerState != eRfOn)) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in power save, so return\n"); + + Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + + if (Avg_TSSI_Meas == 0) { write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); return; } - continue; - } + for (k = 0; k < 5; k++) { + if (k != 4) + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value1+k); + else + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value2); - Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + RT_TRACE(COMP_POWER_TRACKING, + "TSSI_report_value = %d\n", + tmp_report[k]); - if (Avg_TSSI_Meas == 0) - { - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; - } + if (tmp_report[k] <= 20) { + viviflag = true; + break; + } + } - for (k = 0;k < 5; k++) - { - if (k !=4) - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value1+k); + if (viviflag == true) { + write_nic_byte(dev, Pw_Track_Flag, 0); + viviflag = false; + RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); + for (k = 0; k < 5; k++) + tmp_report[k] = 0; + break; + } + + for (k = 0; k < 5; k++) + Avg_TSSI_Meas_from_driver += tmp_report[k]; + + Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; + RT_TRACE(COMP_POWER_TRACKING, + "Avg_TSSI_Meas_from_driver = %d\n", + Avg_TSSI_Meas_from_driver); + TSSI_13dBm = priv->TSSI_13dBm; + RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); + + if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) + delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; else - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value2); + delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]); + if (delta <= E_FOR_TX_POWER_TRACK) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, + "tx power track is done\n"); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + return; + } else { + if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) { + if (RF_Type == RF_2T4R) { - { - if (tmp_report[k] <= 20) - { - viviflag =true; - break; - } - } - } + if ((priv->rfa_txpowertrackingindex > 0) && + (priv->rfc_txpowertrackingindex > 0)) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } - if (viviflag ==true) - { + priv->rfc_txpowertrackingindex--; + if (priv->rfc_txpowertrackingindex_real > 4) { + priv->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[4].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex > 0) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + + } + } else { + if (RF_Type == RF_2T4R) { + if ((priv->rfa_txpowertrackingindex < + TxBBGainTableLength - 1) && + (priv->rfc_txpowertrackingindex < + TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table + [priv->rfa_txpowertrackingindex_real].txbbgain_value); + priv->rfc_txpowertrackingindex++; + priv->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } else { + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } + if (RF_Type == RF_2T4R) { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; + } else { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; + } + + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + else + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + if (priv->CCKPresentAttentuation > -1 && + priv->CCKPresentAttentuation < CCKTxBBGainTableLength) { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + + if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); + return; + } + } write_nic_byte(dev, Pw_Track_Flag, 0); - viviflag = false; - RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); - for (k = 0;k < 5; k++) + Avg_TSSI_Meas_from_driver = 0; + for (k = 0; k < 5; k++) tmp_report[k] = 0; break; } - - for (k = 0;k < 5; k++) - { - Avg_TSSI_Meas_from_driver += tmp_report[k]; - } - - Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; - RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); - TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); - - if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) - delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; - else - delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - - if (delta <= E_FOR_TX_POWER_TRACK) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - return; - } - else - { - if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) - { - if (RF_Type == RF_2T4R) - { - - if ((priv->rfa_txpowertrackingindex > 0) &&(priv->rfc_txpowertrackingindex > 0)) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - - priv->rfc_txpowertrackingindex--; - if (priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex > 0) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - - } - } - else - { - if (RF_Type == RF_2T4R) - { - if ((priv->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&(priv->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - } - } - if (RF_Type == RF_2T4R){ - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; - }else{ - { - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; - } - } - - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; - else - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->CCKPresentAttentuation > -1&&priv->CCKPresentAttentuation < CCKTxBBGainTableLength) - { - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); - return; - } - - + write_nic_byte(dev, FW_Busy_Flag, 0); } - write_nic_byte(dev, Pw_Track_Flag, 0); - Avg_TSSI_Meas_from_driver = 0; - for (k = 0;k < 5; k++) - tmp_report[k] = 0; - break; - } - write_nic_byte(dev, FW_Busy_Flag, 0); -} - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); } -static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) +static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev) { #define ThermalMeterVal 9 struct r8192_priv *priv = rtllib_priv(dev); u32 tmpRegA, TempCCk; u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; - int i =0, CCKSwingNeedUpdate=0; + int i = 0, CCKSwingNeedUpdate = 0; - if (!priv->btxpower_trackingInit) - { - tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); - for (i=0; iOFDM_index[0]= (u8)i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n", + if (!priv->btxpower_trackingInit) { + tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + for (i = 0; i < OFDM_Table_Length; i++) { + if (tmpRegA == OFDMSwingTable[i]) { + priv->OFDM_index[0] = (u8)i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]); } } TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); - for (i=0 ; iCCK_index =(u8) i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n", - rCCK0_TxFilter1, TempCCk, priv->CCK_index); - break; - } -} + for (i = 0; i < CCK_Table_length; i++) { + if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) { + priv->CCK_index = (u8) i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x" + " = 0x%x, CCK_index = 0x%x\n", + rCCK0_TxFilter1, TempCCk, + priv->CCK_index); + break; + } + } priv->btxpower_trackingInit = true; return; } tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); - RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA); if (tmpRegA < 3 || tmpRegA > 13) return; if (tmpRegA >= 12) tmpRegA = 12; - RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA); priv->ThermalMeter[0] = ThermalMeterVal; priv->ThermalMeter[1] = ThermalMeterVal; - if (priv->ThermalMeter[0] >= (u8)tmpRegA) - { - tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA); + if (priv->ThermalMeter[0] >= (u8)tmpRegA) { + tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0] - + (u8)tmpRegA); tmpCCK40Mindex = tmpCCK20Mindex - 6; if (tmpOFDMindex >= OFDM_Table_Length) tmpOFDMindex = OFDM_Table_Length-1; @@ -831,9 +786,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) tmpCCK20Mindex = CCK_Table_length-1; if (tmpCCK40Mindex >= CCK_Table_length) tmpCCK40Mindex = CCK_Table_length-1; - } - else - { + } else { tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]); if (tmpval >= 6) tmpOFDMindex = tmpCCK20Mindex = 0; @@ -848,43 +801,42 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) priv->Record_CCK_20Mindex = tmpCCK20Mindex; priv->Record_CCK_40Mindex = tmpCCK40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", - priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); + RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40" + "Mindex = %d / %d.\n", + priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { priv->bcck_in_ch14 = true; CCKSwingNeedUpdate = 1; - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { + } else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) { priv->bcck_in_ch14 = false; CCKSwingNeedUpdate = 1; } - if (priv->CCK_index != tmpCCKindex) -{ + if (priv->CCK_index != tmpCCKindex) { priv->CCK_index = tmpCCKindex; CCKSwingNeedUpdate = 1; } if (CCKSwingNeedUpdate) - { dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - } - if (priv->OFDM_index[0] != tmpOFDMindex) - { + if (priv->OFDM_index[0] != tmpOFDMindex) { priv->OFDM_index[0] = tmpOFDMindex; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index[0]]); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + OFDMSwingTable[priv->OFDM_index[0]]); RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", - priv->OFDM_index[0], OFDMSwingTable[priv->OFDM_index[0]]); + priv->OFDM_index[0], + OFDMSwingTable[priv->OFDM_index[0]]); } priv->txpower_count = 0; } void dm_txpower_trackingcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,txpower_tracking_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; if (priv->IC_Cut >= IC_VersionCut_D) @@ -898,80 +850,80 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); - priv->txbbgain_table[0].txbb_iq_amplifygain = 12; - priv->txbbgain_table[0].txbbgain_value=0x7f8001fe; - priv->txbbgain_table[1].txbb_iq_amplifygain = 11; - priv->txbbgain_table[1].txbbgain_value=0x788001e2; - priv->txbbgain_table[2].txbb_iq_amplifygain = 10; - priv->txbbgain_table[2].txbbgain_value=0x71c001c7; - priv->txbbgain_table[3].txbb_iq_amplifygain = 9; - priv->txbbgain_table[3].txbbgain_value=0x6b8001ae; - priv->txbbgain_table[4].txbb_iq_amplifygain = 8; - priv->txbbgain_table[4].txbbgain_value=0x65400195; - priv->txbbgain_table[5].txbb_iq_amplifygain = 7; - priv->txbbgain_table[5].txbbgain_value=0x5fc0017f; - priv->txbbgain_table[6].txbb_iq_amplifygain = 6; - priv->txbbgain_table[6].txbbgain_value=0x5a400169; - priv->txbbgain_table[7].txbb_iq_amplifygain = 5; - priv->txbbgain_table[7].txbbgain_value=0x55400155; - priv->txbbgain_table[8].txbb_iq_amplifygain = 4; - priv->txbbgain_table[8].txbbgain_value=0x50800142; - priv->txbbgain_table[9].txbb_iq_amplifygain = 3; - priv->txbbgain_table[9].txbbgain_value=0x4c000130; - priv->txbbgain_table[10].txbb_iq_amplifygain = 2; - priv->txbbgain_table[10].txbbgain_value=0x47c0011f; - priv->txbbgain_table[11].txbb_iq_amplifygain = 1; - priv->txbbgain_table[11].txbbgain_value=0x43c0010f; - priv->txbbgain_table[12].txbb_iq_amplifygain = 0; - priv->txbbgain_table[12].txbbgain_value=0x40000100; - priv->txbbgain_table[13].txbb_iq_amplifygain = -1; - priv->txbbgain_table[13].txbbgain_value=0x3c8000f2; - priv->txbbgain_table[14].txbb_iq_amplifygain = -2; - priv->txbbgain_table[14].txbbgain_value=0x390000e4; - priv->txbbgain_table[15].txbb_iq_amplifygain = -3; - priv->txbbgain_table[15].txbbgain_value=0x35c000d7; - priv->txbbgain_table[16].txbb_iq_amplifygain = -4; - priv->txbbgain_table[16].txbbgain_value=0x32c000cb; - priv->txbbgain_table[17].txbb_iq_amplifygain = -5; - priv->txbbgain_table[17].txbbgain_value=0x300000c0; - priv->txbbgain_table[18].txbb_iq_amplifygain = -6; - priv->txbbgain_table[18].txbbgain_value=0x2d4000b5; - priv->txbbgain_table[19].txbb_iq_amplifygain = -7; - priv->txbbgain_table[19].txbbgain_value=0x2ac000ab; - priv->txbbgain_table[20].txbb_iq_amplifygain = -8; - priv->txbbgain_table[20].txbbgain_value=0x288000a2; - priv->txbbgain_table[21].txbb_iq_amplifygain = -9; - priv->txbbgain_table[21].txbbgain_value=0x26000098; - priv->txbbgain_table[22].txbb_iq_amplifygain = -10; - priv->txbbgain_table[22].txbbgain_value=0x24000090; - priv->txbbgain_table[23].txbb_iq_amplifygain = -11; - priv->txbbgain_table[23].txbbgain_value=0x22000088; - priv->txbbgain_table[24].txbb_iq_amplifygain = -12; - priv->txbbgain_table[24].txbbgain_value=0x20000080; - priv->txbbgain_table[25].txbb_iq_amplifygain = -13; - priv->txbbgain_table[25].txbbgain_value=0x1a00006c; - priv->txbbgain_table[26].txbb_iq_amplifygain = -14; - priv->txbbgain_table[26].txbbgain_value=0x1c800072; - priv->txbbgain_table[27].txbb_iq_amplifygain = -15; - priv->txbbgain_table[27].txbbgain_value=0x18000060; - priv->txbbgain_table[28].txbb_iq_amplifygain = -16; - priv->txbbgain_table[28].txbbgain_value=0x19800066; - priv->txbbgain_table[29].txbb_iq_amplifygain = -17; - priv->txbbgain_table[29].txbbgain_value=0x15800056; - priv->txbbgain_table[30].txbb_iq_amplifygain = -18; - priv->txbbgain_table[30].txbbgain_value=0x26c0005b; - priv->txbbgain_table[31].txbb_iq_amplifygain = -19; - priv->txbbgain_table[31].txbbgain_value=0x14400051; - priv->txbbgain_table[32].txbb_iq_amplifygain = -20; - priv->txbbgain_table[32].txbbgain_value=0x24400051; - priv->txbbgain_table[33].txbb_iq_amplifygain = -21; - priv->txbbgain_table[33].txbbgain_value=0x1300004c; - priv->txbbgain_table[34].txbb_iq_amplifygain = -22; - priv->txbbgain_table[34].txbbgain_value=0x12000048; - priv->txbbgain_table[35].txbb_iq_amplifygain = -23; - priv->txbbgain_table[35].txbbgain_value=0x11000044; - priv->txbbgain_table[36].txbb_iq_amplifygain = -24; - priv->txbbgain_table[36].txbbgain_value=0x10000040; + priv->txbbgain_table[0].txbb_iq_amplifygain = 12; + priv->txbbgain_table[0].txbbgain_value = 0x7f8001fe; + priv->txbbgain_table[1].txbb_iq_amplifygain = 11; + priv->txbbgain_table[1].txbbgain_value = 0x788001e2; + priv->txbbgain_table[2].txbb_iq_amplifygain = 10; + priv->txbbgain_table[2].txbbgain_value = 0x71c001c7; + priv->txbbgain_table[3].txbb_iq_amplifygain = 9; + priv->txbbgain_table[3].txbbgain_value = 0x6b8001ae; + priv->txbbgain_table[4].txbb_iq_amplifygain = 8; + priv->txbbgain_table[4].txbbgain_value = 0x65400195; + priv->txbbgain_table[5].txbb_iq_amplifygain = 7; + priv->txbbgain_table[5].txbbgain_value = 0x5fc0017f; + priv->txbbgain_table[6].txbb_iq_amplifygain = 6; + priv->txbbgain_table[6].txbbgain_value = 0x5a400169; + priv->txbbgain_table[7].txbb_iq_amplifygain = 5; + priv->txbbgain_table[7].txbbgain_value = 0x55400155; + priv->txbbgain_table[8].txbb_iq_amplifygain = 4; + priv->txbbgain_table[8].txbbgain_value = 0x50800142; + priv->txbbgain_table[9].txbb_iq_amplifygain = 3; + priv->txbbgain_table[9].txbbgain_value = 0x4c000130; + priv->txbbgain_table[10].txbb_iq_amplifygain = 2; + priv->txbbgain_table[10].txbbgain_value = 0x47c0011f; + priv->txbbgain_table[11].txbb_iq_amplifygain = 1; + priv->txbbgain_table[11].txbbgain_value = 0x43c0010f; + priv->txbbgain_table[12].txbb_iq_amplifygain = 0; + priv->txbbgain_table[12].txbbgain_value = 0x40000100; + priv->txbbgain_table[13].txbb_iq_amplifygain = -1; + priv->txbbgain_table[13].txbbgain_value = 0x3c8000f2; + priv->txbbgain_table[14].txbb_iq_amplifygain = -2; + priv->txbbgain_table[14].txbbgain_value = 0x390000e4; + priv->txbbgain_table[15].txbb_iq_amplifygain = -3; + priv->txbbgain_table[15].txbbgain_value = 0x35c000d7; + priv->txbbgain_table[16].txbb_iq_amplifygain = -4; + priv->txbbgain_table[16].txbbgain_value = 0x32c000cb; + priv->txbbgain_table[17].txbb_iq_amplifygain = -5; + priv->txbbgain_table[17].txbbgain_value = 0x300000c0; + priv->txbbgain_table[18].txbb_iq_amplifygain = -6; + priv->txbbgain_table[18].txbbgain_value = 0x2d4000b5; + priv->txbbgain_table[19].txbb_iq_amplifygain = -7; + priv->txbbgain_table[19].txbbgain_value = 0x2ac000ab; + priv->txbbgain_table[20].txbb_iq_amplifygain = -8; + priv->txbbgain_table[20].txbbgain_value = 0x288000a2; + priv->txbbgain_table[21].txbb_iq_amplifygain = -9; + priv->txbbgain_table[21].txbbgain_value = 0x26000098; + priv->txbbgain_table[22].txbb_iq_amplifygain = -10; + priv->txbbgain_table[22].txbbgain_value = 0x24000090; + priv->txbbgain_table[23].txbb_iq_amplifygain = -11; + priv->txbbgain_table[23].txbbgain_value = 0x22000088; + priv->txbbgain_table[24].txbb_iq_amplifygain = -12; + priv->txbbgain_table[24].txbbgain_value = 0x20000080; + priv->txbbgain_table[25].txbb_iq_amplifygain = -13; + priv->txbbgain_table[25].txbbgain_value = 0x1a00006c; + priv->txbbgain_table[26].txbb_iq_amplifygain = -14; + priv->txbbgain_table[26].txbbgain_value = 0x1c800072; + priv->txbbgain_table[27].txbb_iq_amplifygain = -15; + priv->txbbgain_table[27].txbbgain_value = 0x18000060; + priv->txbbgain_table[28].txbb_iq_amplifygain = -16; + priv->txbbgain_table[28].txbbgain_value = 0x19800066; + priv->txbbgain_table[29].txbb_iq_amplifygain = -17; + priv->txbbgain_table[29].txbbgain_value = 0x15800056; + priv->txbbgain_table[30].txbb_iq_amplifygain = -18; + priv->txbbgain_table[30].txbbgain_value = 0x26c0005b; + priv->txbbgain_table[31].txbb_iq_amplifygain = -19; + priv->txbbgain_table[31].txbbgain_value = 0x14400051; + priv->txbbgain_table[32].txbb_iq_amplifygain = -20; + priv->txbbgain_table[32].txbbgain_value = 0x24400051; + priv->txbbgain_table[33].txbb_iq_amplifygain = -21; + priv->txbbgain_table[33].txbbgain_value = 0x1300004c; + priv->txbbgain_table[34].txbb_iq_amplifygain = -22; + priv->txbbgain_table[34].txbbgain_value = 0x12000048; + priv->txbbgain_table[35].txbb_iq_amplifygain = -23; + priv->txbbgain_table[35].txbbgain_value = 0x11000044; + priv->txbbgain_table[36].txbb_iq_amplifygain = -24; + priv->txbbgain_table[36].txbbgain_value = 0x10000040; priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35; @@ -1404,7 +1356,8 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) priv->btxpower_tracking = false; priv->txpower_count = 0; priv->btxpower_trackingInit = false; - RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", priv->btxpower_tracking); + RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", + priv->btxpower_tracking); } void dm_initialize_txpower_tracking(struct net_device *dev) @@ -1419,55 +1372,53 @@ void dm_initialize_txpower_tracking(struct net_device *dev) static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 tx_power_track_counter = 0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); - if (read_nic_byte(dev, 0x11e) ==1) + static u32 tx_power_track_counter; + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); + if (read_nic_byte(dev, 0x11e) == 1) return; if (!priv->btxpower_tracking) return; tx_power_track_counter++; - if (tx_power_track_counter >= 180) - { - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); - tx_power_track_counter =0; - } + if (tx_power_track_counter >= 180) { + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); + tx_power_track_counter = 0; + } } static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 TM_Trigger=0; + static u8 TM_Trigger; u8 TxPowerCheckCnt = 0; if (IS_HARDWARE_TYPE_8192SE(dev)) TxPowerCheckCnt = 5; else TxPowerCheckCnt = 2; - if (!priv->btxpower_tracking){ - return; - } else { - if (priv->txpower_count <= TxPowerCheckCnt) { + if (!priv->btxpower_tracking) { + return; + } else { + if (priv->txpower_count <= TxPowerCheckCnt) { priv->txpower_count++; return; } } - if (!TM_Trigger) - { - { + if (!TM_Trigger) { + { rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); - } + } TM_Trigger = 1; return; } else { - printk("===============>Schedule TxPowerTrackingWorkItem\n"); + printk(KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n"); - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); TM_Trigger = 0; } @@ -1488,40 +1439,38 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) u32 TempVal; struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14){ - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + if (!bInCH14) { + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); - } - else - { - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); + } else { + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } @@ -1533,8 +1482,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14) - { + if (!bInCH14) { TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); @@ -1543,7 +1491,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", @@ -1555,9 +1503,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); - } - else - { + } else { TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; @@ -1567,7 +1513,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", @@ -1577,7 +1523,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n", + RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); } } @@ -1601,17 +1547,26 @@ static void dm_txpower_reset_recovery( struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->CCKPresentAttentuation); - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n", + priv->CCKPresentAttentuation); + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", + priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); } @@ -1619,30 +1574,25 @@ extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; + u32 ratr_value; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); return; } if (priv->rate_adaptive.rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode==WIRELESS_MODE_N_24G || - priv->rtllib->mode==WIRELESS_MODE_N_5G)) - return; - { - u32 ratr_value; - ratr_value = reg_ratr; - if (priv->rf_type == RF_1T2R) - { - ratr_value &=~ (RATE_ALL_OFDM_2SS); - } - write_nic_dword(dev, RATR0, ratr_value); - write_nic_byte(dev, UFWP, 1); - } - if (priv->btxpower_trackingInit && priv->btxpower_tracking){ + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; + ratr_value = reg_ratr; + if (priv->rf_type == RF_1T2R) + ratr_value &= ~(RATE_ALL_OFDM_2SS); + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + if (priv->btxpower_trackingInit && priv->btxpower_tracking) dm_txpower_reset_recovery(dev); - } dm_bb_initialgain_restore(dev); @@ -1664,11 +1614,11 @@ static void dm_bb_initialgain_restore(struct net_device *dev) bit_mask = bMaskByte2; rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca); rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); } @@ -1701,93 +1651,66 @@ static void dm_bb_initialgain_backup(struct net_device *dev) bit_mask = bMaskByte2; priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca); } extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value) + u32 dm_type, u32 dm_value) { - if (dm_type == DIG_TYPE_THRESH_HIGH) - { + if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_LOW) - { + } else if (dm_type == DIG_TYPE_THRESH_LOW) { dm_digtable.rssi_low_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_ENABLE) - { + } else if (dm_type == DIG_TYPE_ENABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = true; - } - else if (dm_type == DIG_TYPE_DISABLE) - { + } else if (dm_type == DIG_TYPE_DISABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = false; - } - else if (dm_type == DIG_TYPE_DBG_MODE) - { + } else if (dm_type == DIG_TYPE_DBG_MODE) { if (dm_value >= DM_DBG_MAX) dm_value = DM_DBG_OFF; dm_digtable.dbg_mode = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RSSI) - { + } else if (dm_type == DIG_TYPE_RSSI) { if (dm_value > 100) dm_value = 30; dm_digtable.rssi_val = (long)dm_value; - } - else if (dm_type == DIG_TYPE_ALGORITHM) - { + } else if (dm_type == DIG_TYPE_ALGORITHM) { if (dm_value >= DIG_ALGO_MAX) dm_value = DIG_ALGO_BY_FALSE_ALARM; if (dm_digtable.dig_algorithm != (u8)dm_value) dm_digtable.dig_algorithm_switch = 1; dm_digtable.dig_algorithm = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_BACKOFF) - { + } else if (dm_type == DIG_TYPE_BACKOFF) { if (dm_value > 30) dm_value = 30; dm_digtable.backoff_val = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MIN) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MIN) { if (dm_value == 0) dm_value = 0x1; dm_digtable.rx_gain_range_min = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MAX) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MAX) { if (dm_value > 0x50) dm_value = 0x50; dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void -dm_change_fsync_setting( - struct net_device *dev, +extern void dm_change_fsync_setting(struct net_device *dev, s32 DM_Type, s32 DM_Value) { struct r8192_priv *priv = rtllib_priv(dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->framesyncMonitor = (u8)DM_Value; @@ -1804,68 +1727,47 @@ dm_change_rxpath_selection_setting( struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.Enable = (u8)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } - else if (DM_Type == 2) - { + } else if (DM_Type == 2) { if (DM_Value > 40) DM_Value = 40; DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } - else if (DM_Type == 3) - { + } else if (DM_Type == 3) { if (DM_Value > 25) DM_Value = 25; DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } - else if (DM_Type == 4) - { + } else if (DM_Type == 4) { if (DM_Value >= CCK_Rx_Version_MAX) DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method= (u8)DM_Value; - } - else if (DM_Type == 10) - { + DM_RxPathSelTable.cck_method = (u8)DM_Value; + } else if (DM_Type == 10) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } - else if (DM_Type == 11) - { + } else if (DM_Type == 11) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } - else if (DM_Type == 12) - { + } else if (DM_Type == 12) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } - else if (DM_Type == 13) - { + } else if (DM_Type == 13) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } - else if (DM_Type == 20) - { + } else if (DM_Type == 20) { if (DM_Value > 1) DM_Value = 1; pRA->ping_rssi_enable = (u8)DM_Value; - } - else if (DM_Type == 21) - { + } else if (DM_Type == 21) { if (DM_Value > 30) DM_Value = 30; pRA->ping_rssi_thresh_for_ra = DM_Value; @@ -1919,16 +1821,16 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); @@ -1939,7 +1841,8 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) FalseAlmCnt->Cnt_Cck_fail); RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail , FalseAlmCnt->Cnt_all); + FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, + FalseAlmCnt->Cnt_all); } static void dm_ctrl_initgain_byrssi(struct net_device *dev) @@ -1979,16 +1882,15 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( { struct r8192_priv *priv = rtllib_priv(dev); u8 i; - static u8 fw_dig=0; + static u8 fw_dig; if (dm_digtable.dig_enable_flag == false) return; if (dm_digtable.dig_algorithm_switch) fw_dig = 0; - if (fw_dig <= 3) - { - for (i=0; i<3; i++) + if (fw_dig <= 3) { + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); fw_dig++; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2015,16 +1917,15 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt = 0; + static u32 reset_cnt; u8 i; if (dm_digtable.dig_enable_flag == false) return; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { dm_digtable.dig_state = DM_STA_DIG_MAX; - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); dm_digtable.dig_algorithm_switch = 0; } @@ -2034,20 +1935,13 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh)) - { return; - } - if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) - { + if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) { if (dm_digtable.dig_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt)) - { return; - } else - { reset_cnt = priv->reset_count; - } dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2060,30 +1954,23 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17); if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); write_nic_byte(dev, 0xa0a, 0x08); return; - } - if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) ) - { + if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)) { u8 reset_flag = 0; if (dm_digtable.dig_state == DM_STA_DIG_ON && - (priv->reset_count == reset_cnt)) - { + (priv->reset_count == reset_cnt)) { dm_ctrl_initgain_byrssi_highpwr(dev); return; - } - else - { + } else { if (priv->reset_count != reset_cnt) reset_flag = 1; @@ -2092,54 +1979,41 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( dm_digtable.dig_state = DM_STA_DIG_ON; - if (reset_flag == 1) - { + if (reset_flag == 1) { write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c); - } - else - { - write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); + } else { + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); } if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); write_nic_byte(dev, 0xa0a, 0xcd); - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - } - dm_ctrl_initgain_byrssi_highpwr(dev); - } -static void dm_ctrl_initgain_byrssi_highpwr( - struct net_device * dev) +static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt_highpwr = 0; + static u32 reset_cnt_highpwr; if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) - { return; - } - if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) - { + if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) { if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && (priv->reset_count == reset_cnt_highpwr)) return; @@ -2147,84 +2021,64 @@ static void dm_ctrl_initgain_byrssi_highpwr( dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - else - { - if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&& + } else { + if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt_highpwr)) return; else dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && - priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) - { + priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); } } - reset_cnt_highpwr = priv->reset_count; - } - -static void dm_initial_gain( - struct net_device * dev) +static void dm_initial_gain(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; - static u32 reset_cnt=0; + u8 initial_gain = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (rtllib_act_scanning(priv->rtllib,true) == true) - { + if (rtllib_act_scanning(priv->rtllib, true) == true) { force_write = 1; return; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; - } - else - { + } else { if (dm_digtable.cur_ig_value == 0) dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; else dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; } - } - else - { + } else { dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; dm_digtable.pre_ig_value = 0; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } @@ -2232,82 +2086,70 @@ static void dm_initial_gain( if (dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1)) force_write = 1; - { - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) - || !initialized || force_write) - { - initial_gain = (u8)dm_digtable.cur_ig_value; - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) + || !initialized || force_write) { + initial_gain = (u8)dm_digtable.cur_ig_value; + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; + initialized = 1; + force_write = 0; } } void dm_initial_gain_STABeforeConnect( - struct net_device * dev) + struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; + u8 initial_gain = 0; + static u8 initialized, force_write; RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) - { + (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { + if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { if (priv->rtllib->eRFPowerState != eRfOn) return; - if (dm_digtable.Backoff_Enable_Flag == true) - { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) - { - if ((dm_digtable.backoff_val -6) < dm_digtable.BackoffVal_range_min) + if (dm_digtable.Backoff_Enable_Flag == true) { + if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { + if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; else dm_digtable.backoff_val -= 6; - } - else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) - { - if ((dm_digtable.backoff_val+6) > dm_digtable.BackoffVal_range_max) + } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { + if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; else - dm_digtable.backoff_val +=6; + dm_digtable.backoff_val += 6; } - } - else - dm_digtable.backoff_val =DM_DIG_BACKOFF; + } else + dm_digtable.backoff_val = DM_DIG_BACKOFF; if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else - dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - + dm_digtable.backoff_val; if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value>0x33)?dm_digtable.cur_ig_value:0x33; + dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? + dm_digtable.cur_ig_value : 0x33; if (priv->FalseAlmCnt.Cnt_all > 16000) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - } - else - { + } else { return; } - } - else - { + } else { dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); @@ -2317,44 +2159,44 @@ void dm_initial_gain_STABeforeConnect( return; } - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0)) + if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, + rOFDM0_XAAGCCore1, bMaskByte0)) force_write = 1; - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || !initialized || force_write) - { + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || + !initialized || force_write) { priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); initial_gain = (u8)dm_digtable.cur_ig_value; - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, + initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, + initial_gain); dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; initialized = 1; force_write = 0; } - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, backoff_val = %d\n", - dm_digtable.cur_ig_value, dm_digtable.pre_ig_value, dm_digtable.backoff_val); + RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " + "backoff_val = %d\n", dm_digtable.cur_ig_value, + dm_digtable.pre_ig_value, dm_digtable.backoff_val); } -static void dm_pd_th( - struct net_device * dev) +static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0, force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) @@ -2364,123 +2206,88 @@ static void dm_pd_th( dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; else dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || - (initialized<=3) || force_write) - { - if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; - if (initialized <= 3) - initialized++; - force_write = 0; + if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || + (initialized <= 3) || force_write) { + if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); } + dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; + if (initialized <= 3) + initialized++; + force_write = 0; } } -static void dm_cs_ratio( - struct net_device * dev) +static void dm_cs_ratio(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0,force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) ) + else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER; else dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state; - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || - !initialized || force_write) - { - if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) - { - write_nic_byte(dev, 0xa0a, 0x08); - } - else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) - { - write_nic_byte(dev, 0xa0a, 0xcd); - } - dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || + !initialized || force_write) { + if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) + write_nic_byte(dev, 0xa0a, 0x08); + else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) + write_nic_byte(dev, 0xa0a, 0xcd); + dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; + initialized = 1; + force_write = 0; } } -extern void dm_init_edca_turbo(struct net_device * dev) +extern void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2489,98 +2296,89 @@ extern void dm_init_edca_turbo(struct net_device * dev) priv->bis_cur_rdlstate = false; } -static void dm_check_edca_turbo( - struct net_device * dev) +static void dm_check_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->state != RTLLIB_LINKED) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) - { goto dm_CheckEdcaTurbo_EXIT; - } { - u8* peername[11] = {"unknown", "realtek_90", "realtek_92se","broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"}; - static int wb_tmp = 0; - if (wb_tmp == 0){ - printk("%s():iot peer is %s, bssid:"MAC_FMT"\n",__func__,peername[pHTInfo->IOTPeer], MAC_ARG(priv->rtllib->current_network.bssid)); + u8 *peername[11] = { + "unknown", "realtek_90", "realtek_92se", "broadcom", + "ralink", "atheros", "cisco", "marvell", "92u_softap", + "self_softap" + }; + static int wb_tmp; + if (wb_tmp == 0) { + printk(KERN_INFO "%s():iot peer is %s, bssid:" + MAC_FMT"\n", __func__, + peername[pHTInfo->IOTPeer], + MAC_ARG(priv->rtllib->current_network.bssid)); wb_tmp = 1; } } - if (!priv->rtllib->bis_any_nonbepkts) - { + if (!priv->rtllib->bis_any_nonbepkts) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) - { - if (curTxOkCnt > 4*curRxOkCnt) - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); + if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) { + if (curTxOkCnt > 4*curRxOkCnt) { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = false; } - } - else - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { + } else { + if (!priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = true; } } priv->bcurrent_turbo_EDCA = true; - } - else - { - if (curRxOkCnt > 4*curTxOkCnt) - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); - else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = true; - } - } - else - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = false; + } else { + if (curRxOkCnt > 4*curTxOkCnt) { + if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { + if (priv->rtllib->mode == WIRELESS_MODE_G) + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); + else + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = true; + } + } else { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = false; + } + } + priv->bcurrent_turbo_EDCA = true; } - - priv->bcurrent_turbo_EDCA = true; - } - } - else - { - if (priv->bcurrent_turbo_EDCA) - { - - u8 tmp = AC0_BE; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&tmp) ); + } else { + if (priv->bcurrent_turbo_EDCA) { + u8 tmp = AC0_BE; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp)); priv->bcurrent_turbo_EDCA = false; } } @@ -2592,25 +2390,23 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value) +extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, + u32 DM_Value) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value >= 50) DM_Value = 50; priv->rtllib->CTSToSelfTH = (u8)DM_Value; } } -static void dm_init_ctstoself(struct net_device * dev) +static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2622,28 +2418,22 @@ static void dm_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; - if (priv->rtllib->bCTSToSelfEnable != true) - { + if (priv->rtllib->bCTSToSelfEnable != true) { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } - if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; if (curRxOkCnt > 4*curTxOkCnt) - { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - } else - { pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - } lastTxOkCnt = priv->stats.txbytesunicast; lastRxOkCnt = priv->stats.rxbytesunicast; @@ -2651,8 +2441,7 @@ static void dm_ctstoself(struct net_device *dev) } -static void -dm_Init_WA_Broadcom_IOT(struct net_device * dev) +static void dm_Init_WA_Broadcom_IOT(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; @@ -2665,78 +2454,65 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } - extern void dm_CheckRfCtrlGPIO(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,gpio_change_rf_wq); - struct net_device *dev = priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, gpio_change_rf_wq); + struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; enum rt_rf_power_state eRfPowerStateToSet; bool bActuallySet = false; - char *argv[3]; static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - bActuallySet=false; + bActuallySet = false; if ((priv->up_first_time == 1) || (priv->being_init_adapter)) - { return; - } - if (priv->bfirst_after_down){ + if (priv->bfirst_after_down) { priv->bfirst_after_down = 1; return; } + tmp1byte = read_nic_byte(dev, GPI); + eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - { - tmp1byte = read_nic_byte(dev,GPI); - - eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - - if ( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); - printk("gpiochangeRF - HW Radio ON\n"); - priv->bHwRadioOff = false; - bActuallySet = true; - } - else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); - printk("gpiochangeRF - HW Radio OFF\n"); - priv->bHwRadioOff = true; - bActuallySet = true; - } - - if (bActuallySet) - { - mdelay(1000); - priv->bHwRfOffAction = 1; - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); - { - if (priv->bHwRadioOff == true) - argv[1] = "RFOFF"; - else - argv[1] = "RFON"; - - argv[0] = RadioPowerPath; - argv[2] = NULL; - call_usermodehelper(RadioPowerPath,argv,envp,1); - } - - } + if ((priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio ON\n"); + priv->bHwRadioOff = false; + bActuallySet = true; + } else if ((priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio OFF\n"); + priv->bHwRadioOff = true; + bActuallySet = true; } + if (bActuallySet) { + mdelay(1000); + priv->bHwRfOffAction = 1; + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, true); + if (priv->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + + argv[0] = RadioPowerPath; + argv[2] = NULL; + call_usermodehelper(RadioPowerPath, argv, envp, 1); + } } void dm_rf_pathcheck_workitemcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,rfpath_check_wq); - struct net_device *dev =priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, + rfpath_check_wq); + struct net_device *dev = priv->rtllib->dev; u8 rfpath = 0, i; rfpath = read_nic_byte(dev, 0xc04); @@ -2753,10 +2529,11 @@ void dm_rf_pathcheck_workitemcallback(void *data) dm_rxpath_sel_byrssi(dev); } -static void dm_init_rxpath_selection(struct net_device * dev) +static void dm_init_rxpath_selection(struct net_device *dev) { u8 i; struct r8192_priv *priv = rtllib_priv(dev); + DM_RxPathSelTable.Enable = 1; DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; @@ -2766,119 +2543,92 @@ static void dm_init_rxpath_selection(struct net_device * dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; DM_RxPathSelTable.DbgMode = DM_DBG_OFF; DM_RxPathSelTable.disabledRF = 0; - for (i=0; i<4; i++) - { + for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; DM_RxPathSelTable.cck_pwdb_sta[i] = -64; DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; } } -static void dm_rxpath_sel_byrssi(struct net_device * dev) +#define PWDB_IN_RANGE ((cur_cck_pwdb < tmp_cck_max_pwdb) && \ + (cur_cck_pwdb > tmp_cck_sec_pwdb)) + +static void dm_rxpath_sel_byrssi(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0; - u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0; - u8 cck_default_Rx=0x2; - u8 cck_optional_Rx=0x3; - long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0; - u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; - u8 cur_rf_rssi; - long cur_cck_pwdb; - static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; - u8 update_cck_rx_path; + u8 i, max_rssi_index = 0, min_rssi_index = 0; + u8 sec_rssi_index = 0, rf_num = 0; + u8 tmp_max_rssi = 0, tmp_min_rssi = 0, tmp_sec_rssi = 0; + u8 cck_default_Rx = 0x2; + u8 cck_optional_Rx = 0x3; + long tmp_cck_max_pwdb = 0, tmp_cck_min_pwdb = 0, tmp_cck_sec_pwdb = 0; + u8 cck_rx_ver2_max_index = 0, cck_rx_ver2_min_index = 0; + u8 cck_rx_ver2_sec_index = 0; + u8 cur_rf_rssi; + long cur_cck_pwdb; + static u8 disabled_rf_cnt, cck_Rx_Path_initialized; + u8 update_cck_rx_path; if (priv->rf_type != RF_2T4R) return; - if (!cck_Rx_Path_initialized) - { + if (!cck_Rx_Path_initialized) { DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf); cck_Rx_Path_initialized = 1; } DM_RxPathSelTable.disabledRF = 0xf; - DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04)); + DM_RxPathSelTable.disabledRF &= ~(read_nic_byte(dev, 0xc04)); if (priv->rtllib->mode == WIRELESS_MODE_B) - { DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; - } - for (i=0; istats.rx_rssi_percentage[i]; - if (priv->brfpath_rxenable[i]) - { + if (priv->brfpath_rxenable[i]) { rf_num++; cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; - if (rf_num == 1) - { + if (rf_num == 1) { max_rssi_index = min_rssi_index = sec_rssi_index = i; tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; - } - else if (rf_num == 2) - { - if (cur_rf_rssi >= tmp_max_rssi) - { + } else if (rf_num == 2) { + if (cur_rf_rssi >= tmp_max_rssi) { tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else - { + } else { tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; sec_rssi_index = min_rssi_index = i; } - } - else - { - if (cur_rf_rssi > tmp_max_rssi) - { + } else { + if (cur_rf_rssi > tmp_max_rssi) { tmp_sec_rssi = tmp_max_rssi; sec_rssi_index = max_rssi_index; tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else if (cur_rf_rssi == tmp_max_rssi) - { + } else if (cur_rf_rssi == tmp_max_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if ((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi)) - { + } else if ((cur_rf_rssi < tmp_max_rssi) && + (cur_rf_rssi > tmp_sec_rssi)) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if (cur_rf_rssi == tmp_sec_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if (cur_rf_rssi == tmp_sec_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; } - else - { - } - } - else if ((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi)) - { - } - else if (cur_rf_rssi == tmp_min_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if ((cur_rf_rssi < tmp_sec_rssi) && + (cur_rf_rssi > tmp_min_rssi)) { + ; + } else if (cur_rf_rssi == tmp_min_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } - else - { - } - } - else if (cur_rf_rssi < tmp_min_rssi) - { + } else if (cur_rf_rssi < tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } @@ -2887,79 +2637,63 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } rf_num = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { - for (i=0; ibrfpath_rxenable[i]) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + for (i = 0; i < RF90_PATH_MAX; i++) { + if (priv->brfpath_rxenable[i]) { rf_num++; - cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; + cur_cck_pwdb = + DM_RxPathSelTable.cck_pwdb_sta[i]; - if (rf_num == 1) - { - cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i; - tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb; - } - else if (rf_num == 2) - { - if (cur_cck_pwdb >= tmp_cck_max_pwdb) - { + if (rf_num == 1) { + cck_rx_ver2_max_index = i; + cck_rx_ver2_min_index = i; + cck_rx_ver2_sec_index = i; + tmp_cck_max_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + tmp_cck_sec_pwdb = cur_cck_pwdb; + } else if (rf_num == 2) { + if (cur_cck_pwdb >= tmp_cck_max_pwdb) { tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; + } else { + tmp_cck_sec_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + cck_rx_ver2_min_index = i; } - else - { - tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i; - } - } - else - { - if (cur_cck_pwdb > tmp_cck_max_pwdb) - { - tmp_cck_sec_pwdb = tmp_cck_max_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_max_index; + } else { + if (cur_cck_pwdb > tmp_cck_max_pwdb) { + tmp_cck_sec_pwdb = + tmp_cck_max_pwdb; + cck_rx_ver2_sec_index = + cck_rx_ver2_max_index; tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; - } - else if (cur_cck_pwdb == tmp_cck_max_pwdb) - { + } else if (cur_cck_pwdb == + tmp_cck_max_pwdb) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if ((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb)) - { + } else if (PWDB_IN_RANGE) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if (cur_cck_pwdb == tmp_cck_sec_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; + } else if (cur_cck_pwdb == + tmp_cck_sec_pwdb) { + if (tmp_cck_sec_pwdb == + tmp_cck_min_pwdb) { + tmp_cck_sec_pwdb = + cur_cck_pwdb; + cck_rx_ver2_sec_index = + i; } - else - { - } - } - else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb)) - { - } - else if (cur_cck_pwdb == tmp_cck_min_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { + } else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && + (cur_cck_pwdb > tmp_cck_min_pwdb)) { + ; + } else if (cur_cck_pwdb == tmp_cck_min_pwdb) { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } - else - { - } - } - else if (cur_cck_pwdb < tmp_cck_min_pwdb) - { + } else if (cur_cck_pwdb < tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } @@ -2969,27 +2703,26 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } } - update_cck_rx_path = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { cck_default_Rx = cck_rx_ver2_max_index; cck_optional_Rx = cck_rx_ver2_sec_index; if (tmp_cck_max_pwdb != -64) update_cck_rx_path = 1; } - if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) - { - if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) - { - DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<= + DM_RxPathSelTable.diff_TH) { + DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = + tmp_max_rssi+5; + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, + 0x1<>i) & 0x1) - { - if (tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) - { - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<>i) & 0x1) { + if (tmp_max_rssi >= + DM_RxPathSelTable.rf_enable_rssi_th[i]) { + rtl8192_setBBreg(dev, + rOFDM0_TRxPathEnable, 0x1 << i, + 0x1); + rtl8192_setBBreg(dev, + rOFDM1_TRxPathEnable, + 0x1 << i, 0x1); + DM_RxPathSelTable.rf_enable_rssi_th[i] + = 100; disabled_rf_cnt--; } } @@ -3024,11 +2760,12 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) static void dm_check_rx_path_selection(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - queue_delayed_work_rsl(priv->priv_wq,&priv->rfpath_check_wq,0); + + queue_delayed_work_rsl(priv->priv_wq, &priv->rfpath_check_wq, 0); } -static void dm_init_fsync (struct net_device *dev) +static void dm_init_fsync(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -3037,13 +2774,14 @@ static void dm_init_fsync (struct net_device *dev) priv->rtllib->fsync_rssi_threshold = 30; priv->rtllib->bfsync_enable = false; priv->rtllib->fsync_multiple_timeinterval = 3; - priv->rtllib->fsync_firstdiff_ratethreshold= 100; - priv->rtllib->fsync_seconddiff_ratethreshold= 200; + priv->rtllib->fsync_firstdiff_ratethreshold = 100; + priv->rtllib->fsync_seconddiff_ratethreshold = 200; priv->rtllib->fsync_state = Default_Fsync; priv->framesyncMonitor = 1; init_timer(&priv->fsync_timer); - setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,(unsigned long) dev); + setup_timer(&priv->fsync_timer, dm_fsync_timer_callback, + (unsigned long) dev); } @@ -3057,95 +2795,91 @@ extern void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); - u32 rate_index, rate_count = 0, rate_count_diff=0; + u32 rate_index, rate_count = 0, rate_count_diff = 0; bool bSwitchFromCountDiff = false; bool bDoubleTimeInterval = false; - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->bfsync_enable && - (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) - { + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->bfsync_enable && + (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) { u32 rate_bitmap; - for (rate_index = 0; rate_index <= 27; rate_index++) - { + for (rate_index = 0; rate_index <= 27; rate_index++) { rate_bitmap = 1 << rate_index; if (priv->rtllib->fsync_rate_bitmap & rate_bitmap) - rate_count+= priv->stats.received_rate_histogram[1][rate_index]; + rate_count += + priv->stats.received_rate_histogram[1] + [rate_index]; } if (rate_count < priv->rate_record) - rate_count_diff = 0xffffffff - rate_count + priv->rate_record; + rate_count_diff = 0xffffffff - rate_count + + priv->rate_record; else rate_count_diff = rate_count - priv->rate_record; - if (rate_count_diff < priv->rateCountDiffRecord) - { + if (rate_count_diff < priv->rateCountDiffRecord) { - u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff; - if (DiffNum >= priv->rtllib->fsync_seconddiff_ratethreshold) + u32 DiffNum = priv->rateCountDiffRecord - + rate_count_diff; + if (DiffNum >= + priv->rtllib->fsync_seconddiff_ratethreshold) priv->ContiuneDiffCount++; else priv->ContiuneDiffCount = 0; - if (priv->ContiuneDiffCount >=2) - { + if (priv->ContiuneDiffCount >= 2) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } - } - else - { + } else { priv->ContiuneDiffCount = 0; } - if (rate_count_diff <= priv->rtllib->fsync_firstdiff_ratethreshold) - { + if (rate_count_diff <= + priv->rtllib->fsync_firstdiff_ratethreshold) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } priv->rate_record = rate_count; priv->rateCountDiffRecord = rate_count_diff; - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); - if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) - { + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rate" + "Countdiff %d bSwitchFsync %d\n", priv->rate_record, + rate_count, rate_count_diff, priv->bswitch_fsync); + if (priv->undecorated_smoothed_pwdb > + priv->rtllib->fsync_rssi_threshold && + bSwitchFromCountDiff) { bDoubleTimeInterval = true; priv->bswitch_fsync = !priv->bswitch_fsync; - if (priv->bswitch_fsync) - { - write_nic_byte(dev,0xC36, 0x1c); + if (priv->bswitch_fsync) { + write_nic_byte(dev, 0xC36, 0x1c); write_nic_byte(dev, 0xC3e, 0x90); - } - else - { + } else { write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } - } - else if (priv->undecorated_smoothed_pwdb <= priv->rtllib->fsync_rssi_threshold) - { - if (priv->bswitch_fsync) - { + } else if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->fsync_rssi_threshold) { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } } - if (bDoubleTimeInterval){ + if (bDoubleTimeInterval) { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval*priv->rtllib->fsync_multiple_timeinterval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval * + priv->rtllib->fsync_multiple_timeinterval); add_timer(&priv->fsync_timer); - } - else{ + } else { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); } - } - else - { - if (priv->bswitch_fsync) - { + } else { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); @@ -3154,7 +2888,9 @@ extern void dm_fsync_timer_callback(unsigned long data) write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); } RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d " + "bSwitchFsync %d\n", priv->rate_record, rate_count, + rate_count_diff, priv->bswitch_fsync); } static void dm_StartHWFsync(struct net_device *dev) @@ -3163,7 +2899,8 @@ static void dm_StartHWFsync(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, + (u8 *)(&rf_timing)); write_nic_byte(dev, 0xc3b, 0x41); } @@ -3171,9 +2908,10 @@ static void dm_EndHWFsync(struct net_device *dev) { u8 rf_timing = 0xaa; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *) + (&rf_timing)); write_nic_byte(dev, 0xc3b, 0x49); } @@ -3184,8 +2922,7 @@ static void dm_EndSWFsync(struct net_device *dev) RT_TRACE(COMP_HALDM, "%s\n", __func__); del_timer_sync(&(priv->fsync_timer)); - if (priv->bswitch_fsync) - { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); @@ -3203,31 +2940,30 @@ static void dm_StartSWFsync(struct net_device *dev) u32 rateIndex; u32 rateBitmap; - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); priv->rate_record = 0; priv->ContiuneDiffCount = 0; priv->rateCountDiffRecord = 0; priv->bswitch_fsync = false; - if (priv->rtllib->mode == WIRELESS_MODE_N_24G) - { - priv->rtllib->fsync_firstdiff_ratethreshold= 600; + if (priv->rtllib->mode == WIRELESS_MODE_N_24G) { + priv->rtllib->fsync_firstdiff_ratethreshold = 600; priv->rtllib->fsync_seconddiff_ratethreshold = 0xffff; - } - else - { - priv->rtllib->fsync_firstdiff_ratethreshold= 200; + } else { + priv->rtllib->fsync_firstdiff_ratethreshold = 200; priv->rtllib->fsync_seconddiff_ratethreshold = 200; } - for (rateIndex = 0; rateIndex <= 27; rateIndex++) - { + for (rateIndex = 0; rateIndex <= 27; rateIndex++) { rateBitmap = 1 << rateIndex; - if (priv->rtllib->fsync_rate_bitmap & rateBitmap) - priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex]; + if (priv->rtllib->fsync_rate_bitmap & rateBitmap) + priv->rate_record += + priv->stats.received_rate_histogram[1] + [rateIndex]; } if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd); @@ -3236,61 +2972,59 @@ static void dm_StartSWFsync(struct net_device *dev) void dm_check_fsync(struct net_device *dev) { -#define RegC38_Default 0 +#define RegC38_Default 0 #define RegC38_NonFsync_Other_AP 1 #define RegC38_Fsync_AP_BCM 2 struct r8192_priv *priv = rtllib_priv(dev); - static u8 reg_c38_State=RegC38_Default; - static u32 reset_cnt=0; + static u8 reg_c38_State = RegC38_Default; + static u32 reset_cnt; - RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->rtllib->fsync_rssi_threshold, priv->rtllib->fsync_time_interval, priv->rtllib->fsync_multiple_timeinterval); - RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, priv->rtllib->fsync_firstdiff_ratethreshold, priv->rtllib->fsync_seconddiff_ratethreshold); + RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval " + "%d\n", priv->rtllib->fsync_rssi_threshold, + priv->rtllib->fsync_time_interval, + priv->rtllib->fsync_multiple_timeinterval); + RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d Second" + "DiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, + priv->rtllib->fsync_firstdiff_ratethreshold, + priv->rtllib->fsync_seconddiff_ratethreshold); - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (priv->rtllib->bfsync_enable == 0) - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case SW_Fsync: - dm_EndSWFsync(dev); - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case HW_Fsync: - default: - break; + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (priv->rtllib->bfsync_enable == 0) { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case SW_Fsync: + dm_EndSWFsync(dev); + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case HW_Fsync: + default: + break; } - } - else - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case HW_Fsync: - dm_EndHWFsync(dev); - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case SW_Fsync: - default: - break; + } else { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case HW_Fsync: + dm_EndHWFsync(dev); + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case SW_Fsync: + default: + break; } } - if (priv->framesyncMonitor) - { - if (reg_c38_State != RegC38_Fsync_AP_BCM) - { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); + if (priv->framesyncMonitor) { + if (reg_c38_State != RegC38_Fsync_AP_BCM) { + write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); reg_c38_State = RegC38_Fsync_AP_BCM; } @@ -3312,21 +3046,30 @@ void dm_check_fsync(struct net_device *dev) if (priv->framesyncMonitor) { if (priv->rtllib->state == RTLLIB_LINKED) { - if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { - if (reg_c38_State != RegC38_NonFsync_Other_AP) { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); + if (priv->undecorated_smoothed_pwdb <= + RegC38_TH) { + if (reg_c38_State != + RegC38_NonFsync_Other_AP) { + write_nic_byte(dev, + rOFDM0_RxDetector3, + 0x90); - reg_c38_State = RegC38_NonFsync_Other_AP; + reg_c38_State = + RegC38_NonFsync_Other_AP; } - } else if (priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) { + } else if (priv->undecorated_smoothed_pwdb >= + (RegC38_TH+5)) { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, + rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3334,13 +3077,15 @@ void dm_check_fsync(struct net_device *dev) } if (priv->framesyncMonitor) { if (priv->reset_count != reset_cnt) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; reset_cnt = priv->reset_count; } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3353,15 +3098,18 @@ extern void dm_shadow_init(struct net_device *dev) for (page = 0; page < 5; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 8; page < 11; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 12; page < 15; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page*256); } @@ -3380,93 +3128,75 @@ static void dm_init_dynamic_txpower(struct net_device *dev) static void dm_dynamic_txpower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - unsigned int txhipower_threshhold=0; - unsigned int txlowpower_threshold=0; - if (priv->rtllib->bdynamic_txpower_enable != true) - { + unsigned int txhipower_threshhold = 0; + unsigned int txlowpower_threshold = 0; + if (priv->rtllib->bdynamic_txpower_enable != true) { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; return; } - if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && (priv->rtllib->mode == IEEE_G)){ + if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && + (priv->rtllib->mode == IEEE_G)) { txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; - } - else - { + } else { txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } + RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n", + priv->undecorated_smoothed_pwdb); - RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb); - - if (priv->rtllib->state == RTLLIB_LINKED) - { - if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) - { + if (priv->rtllib->state == RTLLIB_LINKED) { + if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) { priv->bDynamicTxHighPower = true; priv->bDynamicTxLowPower = false; - } - else - { - if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) - { + } else { + if (priv->undecorated_smoothed_pwdb < + txlowpower_threshold && + priv->bDynamicTxHighPower == true) priv->bDynamicTxHighPower = false; - } if (priv->undecorated_smoothed_pwdb < 35) - { priv->bDynamicTxLowPower = true; - } else if (priv->undecorated_smoothed_pwdb >= 40) - { priv->bDynamicTxLowPower = false; - } } - } - else - { + } else { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; } - if ( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) || - (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) ) - { - RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->rtllib->current_network.channel); + if ((priv->bDynamicTxHighPower != priv->bLastDTPFlag_High) || + (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low)) { + RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", + priv->rtllib->current_network.channel); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); } priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; } -static void dm_check_txrateandretrycount(struct net_device * dev) +static void dm_check_txrateandretrycount(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg); + ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, + Current_Tx_Rate_Reg); - ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg); + ieee->softmac_stats.last_packet_rate = read_nic_byte(dev, + Initial_Tx_Rate_Reg); - ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg); + ieee->softmac_stats.txretrycount = read_nic_dword(dev, + Tx_Retry_Count_Reg); } static void dm_send_rssi_tofw(struct net_device *dev) { - struct dcmd_txcmd tx_cmd; struct r8192_priv *priv = rtllib_priv(dev); write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); - return; - tx_cmd.Op = TXCMD_SET_RX_RSSI; - tx_cmd.Length = 4; - tx_cmd.Value = priv->undecorated_smoothed_pwdb; - - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, - DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); } - -/*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 64fa749cfb4..ab44a9a6927 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -59,15 +59,15 @@ #define WAIotTHVal 25 -#define E_FOR_TX_POWER_TRACK 300 +#define E_FOR_TX_POWER_TRACK 300 #define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 #define TX_POWER_NEAR_FIELD_THRESH_LOW 62 -#define TX_POWER_ATHEROAP_THRESH_HIGH 78 +#define TX_POWER_ATHEROAP_THRESH_HIGH 78 #define TX_POWER_ATHEROAP_THRESH_LOW 72 -#define Current_Tx_Rate_Reg 0x1e0 -#define Initial_Tx_Rate_Reg 0x1e1 -#define Tx_Retry_Count_Reg 0x1ac +#define Current_Tx_Rate_Reg 0x1e0 +#define Initial_Tx_Rate_Reg 0x1e1 +#define Tx_Retry_Count_Reg 0x1ac #define RegC38_TH 20 #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 @@ -227,7 +227,7 @@ struct drx_path_sel { enum dm_cck_rx_path_method { CCK_Rx_Version_1 = 0, - CCK_Rx_Version_2= 1, + CCK_Rx_Version_2 = 1, CCK_Rx_Version_MAX }; @@ -256,7 +256,10 @@ extern u8 test_flag; /*------------------------Export Marco Definition---------------------------*/ -#define DM_APInitGainChangeNotify(Event) {dm_digtable.CurAPConnectState = Event;} +#define DM_APInitGainChangeNotify(Event) \ + { \ + dm_digtable.CurAPConnectState = Event; \ + } /*------------------------Export Marco Definition---------------------------*/ @@ -271,19 +274,19 @@ extern void hal_dm_watchdog(struct net_device *dev); extern void init_rate_adaptive(struct net_device *dev); extern void dm_txpower_trackingcallback(void *data); -extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14); +extern void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); + u32 dm_type, + u32 dm_value); extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); + s32 DM_Type, + s32 DM_Value); extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); + u32 force_type, + u32 force_value); extern void dm_init_edca_turbo(struct net_device *dev); extern void dm_rf_operation_test_callback(unsigned long data); extern void dm_rf_pathcheck_workitemcallback(void *data); @@ -291,11 +294,31 @@ extern void dm_fsync_timer_callback(unsigned long data); extern void dm_check_fsync(struct net_device *dev); extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); - +extern void dm_CheckRfCtrlGPIO(void *data); +extern void dm_InitRateAdaptiveMask(struct net_device *dev); +extern void init_hal_dm(struct net_device *dev); +extern void deinit_hal_dm(struct net_device *dev); +extern void hal_dm_watchdog(struct net_device *dev); +extern void init_rate_adaptive(struct net_device *dev); +extern void dm_txpower_trackingcallback(void *data); +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value); +extern void DM_ChangeFsyncSetting(struct net_device *dev, + s32 DM_Type, + s32 DM_Value); +extern void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, + u32 force_value); +extern void dm_init_edca_turbo(struct net_device *dev); +extern void dm_rf_operation_test_callback(unsigned long data); +extern void dm_rf_pathcheck_workitemcallback(void *data); +extern void dm_fsync_timer_callback(unsigned long data); +extern void dm_check_fsync(struct net_device *dev); +extern void dm_shadow_init(struct net_device *dev); +extern void dm_initialize_txpower_tracking(struct net_device *dev); extern void dm_CheckRfCtrlGPIO(void *data); -extern void dm_InitRateAdaptiveMask(struct net_device * dev); - #endif /*__R8192UDM_H__ */ - -/* End of r8192U_dm.h */ From a44325f98563c39bc63311db7471b848153e49fe Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:23 -0500 Subject: [PATCH 0552/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XI Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_eeprom.c | 69 ++++++----- drivers/staging/rtl8192e/rtl_eeprom.h | 2 +- drivers/staging/rtl8192e/rtllib_crypt.c | 6 +- drivers/staging/rtl8192e/rtllib_crypt.h | 8 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 30 +++-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 118 ++++++++++--------- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 74 ++++++------ drivers/staging/rtl8192e/rtllib_endianfree.h | 66 ++++++----- 8 files changed, 194 insertions(+), 179 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index 14a8c1d13e2..df72a6007d0 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -29,11 +29,11 @@ void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, - (1<epromtype==EEPROM_93C56){ - addr_str[7]=addr & 1; - addr_str[6]=addr & (1<<1); - addr_str[5]=addr & (1<<2); - addr_str[4]=addr & (1<<3); - addr_str[3]=addr & (1<<4); - addr_str[2]=addr & (1<<5); - addr_str[1]=addr & (1<<6); - addr_str[0]=addr & (1<<7); - addr_len=8; - }else{ - addr_str[5]=addr & 1; - addr_str[4]=addr & (1<<1); - addr_str[3]=addr & (1<<2); - addr_str[2]=addr & (1<<3); - addr_str[1]=addr & (1<<4); - addr_str[0]=addr & (1<<5); - addr_len=6; + if (priv->epromtype == EEPROM_93C56) { + addr_str[7] = addr & 1; + addr_str[6] = addr & (1<<1); + addr_str[5] = addr & (1<<2); + addr_str[4] = addr & (1<<3); + addr_str[3] = addr & (1<<4); + addr_str[2] = addr & (1<<5); + addr_str[1] = addr & (1<<6); + addr_str[0] = addr & (1<<7); + addr_len = 8; + } else { + addr_str[5] = addr & 1; + addr_str[4] = addr & (1<<1); + addr_str[3] = addr & (1<<2); + addr_str[2] = addr & (1<<3); + addr_str[1] = addr & (1<<4); + addr_str[0] = addr & (1<<5); + addr_len = 6; } eprom_cs(dev, 1); eprom_ck_cycle(dev); @@ -127,7 +126,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) eprom_w(dev, 0); - for (i = 0; i < 16; i++){ + for (i = 0; i < 16; i++) { eprom_ck_cycle(dev); ret |= (eprom_r(dev)<<(15-i)); } diff --git a/drivers/staging/rtl8192e/rtl_eeprom.h b/drivers/staging/rtl8192e/rtl_eeprom.h index f765efbf809..9452e1683a7 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.h +++ b/drivers/staging/rtl8192e/rtl_eeprom.h @@ -26,4 +26,4 @@ #define EPROM_DELAY 10 -u32 eprom_read(struct net_device *dev,u32 addr); +u32 eprom_read(struct net_device *dev, u32 addr); diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c index 225d28a7754..acda37b8184 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.c +++ b/drivers/staging/rtl8192e/rtllib_crypt.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include "rtllib.h" @@ -152,7 +152,7 @@ int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops) } -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name) +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name) { unsigned long flags; struct list_head *ptr; diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h index b01410550c4..49b90b73ed9 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -61,8 +61,8 @@ struct rtllib_crypto_ops { /* maximum number of bytes added by encryption; encrypt buf is * allocated with extra_prefix_len bytes, copy of in_buf, and * extra_postfix_len; encrypt need not use all this space, but - * the result must start at the beginning of the struct buffer and correct - * length must be returned */ + * the result must start at the beginning of the struct buffer and + * correct length must be returned */ int extra_prefix_len, extra_postfix_len; struct module *owner; @@ -77,9 +77,9 @@ struct rtllib_crypt_data { int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops); int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops); -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name); +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name); void rtllib_crypt_deinit_entries(struct rtllib_device *, int); void rtllib_crypt_deinit_handler(unsigned long); void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, - struct rtllib_crypt_data **crypt); + struct rtllib_crypt_data **crypt); #endif diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 9e640c24b89..306d6ff707a 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -56,10 +56,10 @@ struct rtllib_ccmp_data { void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { - crypto_cipher_encrypt_one((void*)tfm, ct, pt); + crypto_cipher_encrypt_one((void *)tfm, ct, pt); } -static void * rtllib_ccmp_init(int key_idx) +static void *rtllib_ccmp_init(int key_idx) { struct rtllib_ccmp_data *priv; @@ -69,7 +69,7 @@ static void * rtllib_ccmp_init(int key_idx) memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; - priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " "crypto API aes\n"); @@ -81,7 +81,7 @@ static void * rtllib_ccmp_init(int key_idx) fail: if (priv) { if (priv->tfm) - crypto_free_cipher((void*)priv->tfm); + crypto_free_cipher((void *)priv->tfm); kfree(priv); } @@ -93,7 +93,7 @@ static void rtllib_ccmp_deinit(void *priv) { struct rtllib_ccmp_data *_priv = priv; if (_priv && _priv->tfm) - crypto_free_cipher((void*)_priv->tfm); + crypto_free_cipher((void *)_priv->tfm); kfree(priv); } @@ -124,7 +124,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, /* qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x08)); - */ + */ qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x80)); aad_len = 22; @@ -192,7 +192,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int data_len, i; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) @@ -232,7 +233,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) mic = skb_put(skb, CCMP_MIC_LEN); - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, + b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -262,7 +264,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) struct rtllib_ccmp_data *key = priv; u8 keyidx, *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 pn[6]; if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { @@ -308,7 +311,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -4; } if (!tcb_desc->bHwSec) { - size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; + size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - + CCMP_MIC_LEN; u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; u8 *b0 = key->rx_b0; u8 *b = key->rx_b; @@ -376,7 +380,7 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) data->rx_pn[4] = seq[1]; data->rx_pn[5] = seq[0]; } - crypto_cipher_setkey((void*)data->tfm, data->key, CCMP_TK_LEN); + crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); } else if (len == 0) data->key_set = 0; else @@ -410,7 +414,7 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_ccmp_print_stats(char *p, void *priv) +static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 89da28de571..c4e490e57ad 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -18,15 +18,13 @@ #include #include #include -#include -#include "rtllib.h" - - +#include #include #include - #include +#include "rtllib.h" + struct rtllib_tkip_data { #define TKIP_KEY_LEN 32 u8 key[TKIP_KEY_LEN]; @@ -39,7 +37,7 @@ struct rtllib_tkip_data { u32 rx_iv32; u16 rx_iv16; - bool initialized; + bool initialized; u16 rx_ttak[5]; int rx_phase1_done; u32 rx_iv32_new; @@ -58,7 +56,7 @@ struct rtllib_tkip_data { u8 rx_hdr[16], tx_hdr[16]; }; -static void * rtllib_tkip_init(int key_idx) +static void *rtllib_tkip_init(int key_idx) { struct rtllib_tkip_data *priv; @@ -181,8 +179,7 @@ static inline u16 Mk16_le(u16 *v) } -static const u16 Sbox[256] = -{ +static const u16 Sbox[256] = { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, @@ -303,7 +300,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int len; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; u8 rc4key[16], *icv; @@ -322,7 +320,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, + tkey->tx_iv16); } else tkey->tx_phase1_done = 1; @@ -360,7 +359,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); - ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); + ret = crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); } tkey->tx_iv16++; @@ -384,7 +383,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 iv32; u16 iv16; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; u8 icv[4]; @@ -422,23 +422,25 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); pos += 8; - if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) - { + if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) { if ((iv32 < tkey->rx_iv32 || - (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16))&&tkey->initialized) { + (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) && + tkey->initialized) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), - tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); + printk(KERN_DEBUG "TKIP: replay detected: STA=" + MAC_FMT + " previous TSC %08x%04x received TSC " + "%08x%04x\n", MAC_ARG(hdr->addr2), + tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; return -4; } - tkey->initialized = true; + tkey->initialized = true; if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1(tkey->rx_ttak, tkey->key, + hdr->addr2, iv32); tkey->rx_phase1_done = 1; } tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); @@ -451,7 +453,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", + "received packet from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); } return -7; @@ -465,8 +467,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(icv, pos + plen, 4) != 0) { if (iv32 != tkey->rx_iv32) { - /* Previously cached Phase1 result was already lost, so - * it needs to be recalculated for the next packet. */ + /* Previously cached Phase1 result was already + * lost, so it needs to be recalculated for the + * next packet. */ tkey->rx_phase1_done = 0; } if (net_ratelimit()) { @@ -493,26 +496,26 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, - u8 * data, size_t data_len, u8 * mic) +static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) { - struct hash_desc desc; - struct scatterlist sg[2]; + struct hash_desc desc; + struct scatterlist sg[2]; - if (tfm_michael == NULL) { - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); + if (tfm_michael == NULL) { + printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); + return -1; + } + sg_init_table(sg, 2); + sg_set_buf(&sg[0], hdr, 16); + sg_set_buf(&sg[1], data, data_len); - if (crypto_hash_setkey(tfm_michael, key, 8)) - return -1; + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; - desc.tfm = tfm_michael; - desc.flags = 0; - return crypto_hash_digest(&desc, sg, data_len + 16, mic); + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); } static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) @@ -563,12 +566,11 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) michael_mic_hdr(skb, tkey->tx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } pos = skb_put(skb, 8); if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; return 0; @@ -597,7 +599,8 @@ static void rtllib_michael_mic_failure(struct net_device *dev, } static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv, struct rtllib_device* ieee) + int hdr_len, void *priv, + struct rtllib_device *ieee) { struct rtllib_tkip_data *tkey = priv; u8 mic[8]; @@ -609,29 +612,30 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; michael_mic_hdr(skb, tkey->rx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; - if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { + if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0) || + (ieee->force_mic_error)) { struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from " MAC_FMT " keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); - printk("%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ - ieee->force_mic_error); + printk(KERN_DEBUG "%d, force_mic_error = %d\n", + (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ + ieee->force_mic_error); if (skb->dev) { - printk("skb->dev != NULL\n"); + printk(KERN_INFO "skb->dev != NULL\n"); rtllib_michael_mic_failure(skb->dev, hdr, keyidx); - } + } tkey->dot11RSNAStatsTKIPLocalMICFailures++; - ieee->force_mic_error = false; + ieee->force_mic_error = false; return -1; } @@ -711,7 +715,7 @@ static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_tkip_print_stats(char *p, void *priv) +static char *rtllib_tkip_print_stats(char *p, void *priv) { struct rtllib_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -751,7 +755,7 @@ static struct rtllib_crypto_ops rtllib_crypt_tkip = { .print_stats = rtllib_tkip_print_stats, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ - .owner = THIS_MODULE, + .owner = THIS_MODULE, }; @@ -768,5 +772,5 @@ void __exit rtllib_crypto_tkip_exit(void) void rtllib_tkip_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 78a749f5efa..c59bf10fe78 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include @@ -29,12 +29,12 @@ struct prism2_wep_data { u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; - struct crypto_blkcipher *tx_tfm; - struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; + struct crypto_blkcipher *rx_tfm; }; -static void * prism2_wep_init(int keyidx) +static void *prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; @@ -45,19 +45,19 @@ static void * prism2_wep_init(int keyidx) priv->key_idx = keyidx; priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->tx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->tx_tfm = NULL; - goto fail; - } - priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->rx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->rx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -66,12 +66,12 @@ static void * prism2_wep_init(int keyidx) fail: if (priv) { - if (priv->tx_tfm) - crypto_free_blkcipher(priv->tx_tfm); - if (priv->rx_tfm) - crypto_free_blkcipher(priv->rx_tfm); - kfree(priv); - } + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); + kfree(priv); + } return NULL; } @@ -81,11 +81,11 @@ static void prism2_wep_deinit(void *priv) struct prism2_wep_data *_priv = priv; if (_priv) { - if (_priv->tx_tfm) - crypto_free_blkcipher(_priv->tx_tfm); - if (_priv->rx_tfm) - crypto_free_blkcipher(_priv->rx_tfm); - } + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } kfree(priv); } @@ -101,14 +101,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; u32 crc; u8 *icv; struct scatterlist sg; if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len){ - printk("Error!!!headroom=%d tailroom=%d skblen=%d hdr_len=%d\n",skb_headroom(skb),skb_tailroom(skb),skb->len,hdr_len); + printk(KERN_ERR "Error!!! headroom=%d tailroom=%d skblen=%d" + " hdr_len=%d\n", skb_headroom(skb), skb_tailroom(skb), + skb->len, hdr_len); return -1; } len = skb->len - hdr_len; @@ -157,8 +160,8 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } -/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP part of - * the frame: IV (4 bytes), encrypted payload (including SNAP header), +/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP + * part of the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. * * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on @@ -170,7 +173,8 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; u32 crc; u8 icv[4]; @@ -245,7 +249,7 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) } -static char * prism2_wep_print_stats(char *p, void *priv) +static char *prism2_wep_print_stats(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -284,5 +288,5 @@ void __exit rtllib_crypto_wep_exit(void) void rtllib_wep_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_endianfree.h b/drivers/staging/rtl8192e/rtllib_endianfree.h index 46d8f196248..b268605a52a 100644 --- a/drivers/staging/rtl8192e/rtllib_endianfree.h +++ b/drivers/staging/rtl8192e/rtllib_endianfree.h @@ -14,26 +14,28 @@ #define BYTE_ORDER __MACHINE_LITTLE_ENDIAN #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) ((u16)(_val)) -#define EF4Byte(_val) ((u32)(_val)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) ((u16)(_val)) +#define EF4Byte(_val) ((u32)(_val)) #else -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) -#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8)|\ - ((((u32)(_val))&0x00ff0000)>>8)|\ - ((((u32)(_val))&0xff000000)>>24)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) \ + (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) +#define EF4Byte(_val) \ + (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8)|\ + ((((u32)(_val))&0x00ff0000)>>8)|\ + ((((u32)(_val))&0xff000000)>>24)) #endif #define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr))) #define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr))) #define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr))) -#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val) -#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val) -#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val) +#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr))) = EF1Byte(_val) +#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr))) = EF2Byte(_val) +#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr))) = EF4Byte(_val) #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN #define H2N1BYTE(_val) ((u8)(_val)) #define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ @@ -63,13 +65,14 @@ #endif #define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen))) -#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) +#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \ + (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) #define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart)))) #define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_32(__BitLen) \ ) @@ -78,7 +81,7 @@ ( \ LE_P4BYTE_TO_HOST_4BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \ @@ -86,8 +89,8 @@ EF4Byte( \ LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ | \ - ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \ - ); + ((((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset)) \ + ); #define BIT_LEN_MASK_16(__BitLen) \ @@ -101,7 +104,7 @@ #define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_16(__BitLen) \ ) @@ -110,16 +113,16 @@ ( \ LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \ *((u16 *)(__pStart)) = \ EF2Byte( \ LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << \ + (__BitOffset)) \ + ); #define BIT_LEN_MASK_8(__BitLen) \ (0xFF >> (8 - (__BitLen))) @@ -132,7 +135,7 @@ #define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_8(__BitLen) \ ) @@ -141,16 +144,17 @@ ( \ LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen)) \ ) -#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u8 *)(__pStart)) = \ - EF1Byte( \ +#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u8 *)(__pStart)) = EF1Byte( \ LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << \ + (__BitOffset)) \ + ); -#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment)) +#define N_BYTE_ALIGMENT(__Value, __Aligment) \ + ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / \ + __Aligment) * __Aligment)) #endif From 8567829a6cfe13e2a8b366794fffa54e5fd06e9f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:24 -0500 Subject: [PATCH 0553/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XII This patch removes all the errors and most of the warnings generated by checkpatch -f. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1211 ++++++++++++---------- drivers/staging/rtl8192e/rtllib_module.c | 30 +- drivers/staging/rtl8192e/rtllib_tx.c | 1 - 3 files changed, 655 insertions(+), 587 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2a394ee9f75..c7b3641f30b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -64,14 +64,14 @@ /** * container_of - cast a member of a structure out to the containing structure * - * @ptr: the pointer to the member. + * @ptr: the pointer to the member. * @type: the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member)*__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); }) #endif #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) @@ -79,21 +79,24 @@ #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) - #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) - #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) +#define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z) +#define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y) - #define queue_work_rsl(x,y) queue_work(x,y) - #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) +#define queue_work_rsl(x, y) queue_work(x, y) +#define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y) - #define container_of_work_rsl(x,y,z) container_of(x,y,z) - #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z) +#define container_of_work_rsl(x, y, z) container_of(x, y, z) +#define container_of_dwork_rsl(x, y, z) \ + container_of(container_of(x, struct delayed_work, work), y, z) - #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len) +#define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \ + iwe_stream_add_event(info, start, stop, iwe, len) - #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p) +#define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \ + iwe_stream_add_point(info, start, stop, iwe, p) - #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y) - #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y) +#define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y) +#define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y) static inline void *netdev_priv_rsl(struct net_device *dev) { @@ -108,18 +111,18 @@ static inline void *netdev_priv_rsl(struct net_device *dev) /* added for rtl819x tx procedure */ #define MAX_QUEUE_SIZE 0x10 -#define BK_QUEUE 0 -#define BE_QUEUE 1 -#define VI_QUEUE 2 -#define VO_QUEUE 3 -#define HCCA_QUEUE 4 -#define TXCMD_QUEUE 5 -#define MGNT_QUEUE 6 -#define HIGH_QUEUE 7 -#define BEACON_QUEUE 8 +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define HCCA_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define BEACON_QUEUE 8 -#define LOW_QUEUE BE_QUEUE -#define NORMAL_QUEUE MGNT_QUEUE +#define LOW_QUEUE BE_QUEUE +#define NORMAL_QUEUE MGNT_QUEUE #ifndef IW_MODE_MESH #define IW_MODE_MESH 7 @@ -139,8 +142,10 @@ static inline void *netdev_priv_rsl(struct net_device *dev) #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 #define RT_RF_LPS_DISALBE_2R BIT30 #define RT_RF_LPS_LEVEL_ASPM BIT31 -#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) -#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG))) +#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \ + ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \ + (pPSC->CurPsLevel &= (~(_PS_FLAG))) #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) /* defined for skb cb field */ @@ -203,36 +208,36 @@ struct cb_desc { }; /*--------------------------Define -------------------------------------------*/ -#define MGN_1M 0x02 -#define MGN_2M 0x04 -#define MGN_5_5M 0x0b -#define MGN_11M 0x16 +#define MGN_1M 0x02 +#define MGN_2M 0x04 +#define MGN_5_5M 0x0b +#define MGN_11M 0x16 -#define MGN_6M 0x0c -#define MGN_9M 0x12 -#define MGN_12M 0x18 -#define MGN_18M 0x24 -#define MGN_24M 0x30 -#define MGN_36M 0x48 -#define MGN_48M 0x60 -#define MGN_54M 0x6c +#define MGN_6M 0x0c +#define MGN_9M 0x12 +#define MGN_12M 0x18 +#define MGN_18M 0x24 +#define MGN_24M 0x30 +#define MGN_36M 0x48 +#define MGN_48M 0x60 +#define MGN_54M 0x6c -#define MGN_MCS0 0x80 -#define MGN_MCS1 0x81 -#define MGN_MCS2 0x82 -#define MGN_MCS3 0x83 -#define MGN_MCS4 0x84 -#define MGN_MCS5 0x85 -#define MGN_MCS6 0x86 -#define MGN_MCS7 0x87 -#define MGN_MCS8 0x88 -#define MGN_MCS9 0x89 -#define MGN_MCS10 0x8a -#define MGN_MCS11 0x8b -#define MGN_MCS12 0x8c -#define MGN_MCS13 0x8d -#define MGN_MCS14 0x8e -#define MGN_MCS15 0x8f +#define MGN_MCS0 0x80 +#define MGN_MCS1 0x81 +#define MGN_MCS2 0x82 +#define MGN_MCS3 0x83 +#define MGN_MCS4 0x84 +#define MGN_MCS5 0x85 +#define MGN_MCS6 0x86 +#define MGN_MCS7 0x87 +#define MGN_MCS8 0x88 +#define MGN_MCS9 0x89 +#define MGN_MCS10 0x8a +#define MGN_MCS11 0x8b +#define MGN_MCS12 0x8c +#define MGN_MCS13 0x8d +#define MGN_MCS14 0x8e +#define MGN_MCS15 0x8f #define MGN_MCS0_SG 0x90 #define MGN_MCS1_SG 0x91 #define MGN_MCS2_SG 0x92 @@ -251,7 +256,7 @@ struct cb_desc { #define MGN_MCS15_SG 0x9f -enum _ReasonCode{ +enum _ReasonCode { unspec_reason = 0x1, auth_not_valid = 0x2, deauth_lv_ss = 0x3, @@ -273,7 +278,7 @@ enum _ReasonCode{ invalid_AKMP = 0x14, unsup_RSNIEver = 0x15, invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, + auth_802_1x_fail = 0x17, ciper_reject = 0x18, QoS_unspec = 0x20, @@ -282,7 +287,7 @@ enum _ReasonCode{ no_facility = 0x23, req_declined = 0x25, invalid_param = 0x26, - req_not_honored= 0x27, + req_not_honored = 0x27, TS_not_created = 0x2F, DL_not_allowed = 0x30, dest_not_exist = 0x31, @@ -308,10 +313,9 @@ enum hal_def_variable { HW_DEF_GPIO, HAL_DEF_PCI_SUPPORT_ASPM, HAL_DEF_THERMAL_VALUE, - HAL_DEF_USB_IN_TOKEN_REV, + HAL_DEF_USB_IN_TOKEN_REV, }; - enum hw_variables { HW_VAR_ETHER_ADDR, HW_VAR_MULTICAST_REG, @@ -355,14 +359,14 @@ enum hw_variables { HW_VAR_RF_STATE, HW_VAR_RF_OFF_BY_HW, HW_VAR_BUS_SPEED, - HW_VAR_SET_DEV_POWER, + HW_VAR_SET_DEV_POWER, HW_VAR_RCR, HW_VAR_RATR_0, HW_VAR_RRSR, HW_VAR_CPU_RST, HW_VAR_CECHK_BSSID, - HW_VAR_LBK_MODE, + HW_VAR_LBK_MODE, HW_VAR_AES_11N_FIX, HW_VAR_USB_RX_AGGR, HW_VAR_USER_CONTROL_TURBO_MODE, @@ -400,7 +404,7 @@ enum hw_variables { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_INT_MIGRATION, HW_VAR_INT_AC, - HW_VAR_RF_TIMING, + HW_VAR_RF_TIMING, }; enum rt_op_mode { @@ -411,7 +415,10 @@ enum rt_op_mode { }; -#define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) +#define aSifsTime \ + (((priv->rtllib->current_network.mode == IEEE_A) \ + || (priv->rtllib->current_network.mode == IEEE_N_24G) \ + || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10) #define MGMT_QUEUE_NUM 5 @@ -452,13 +459,14 @@ enum rt_op_mode { #define IEEE_CRYPT_ALG_NAME_LEN 16 #define MAX_IE_LEN 0xff -#define RT_ASSERT_RET(_Exp) do {} while(0) -#define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) +#define RT_ASSERT_RET(_Exp) do {} while (0) +#define RT_ASSERT_RET_VALUE(_Exp, Ret) \ + do {} while (0) struct ieee_param { u32 cmd; u8 sta_addr[ETH_ALEN]; - union { + union { struct { u8 name; u32 value; @@ -468,7 +476,7 @@ struct ieee_param { u8 reserved[32]; u8 data[0]; } wpa_ie; - struct{ + struct { int command; int reason_code; } mlme; @@ -510,8 +518,8 @@ struct ieee_param { #define RTLLIB_3ADDR_LEN 24 #define RTLLIB_4ADDR_LEN 30 #define RTLLIB_FCS_LEN 4 -#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) -#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) +#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) +#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) #define RTLLIB_MGMT_HDR_LEN 24 #define RTLLIB_DATA_HDR3_LEN 24 #define RTLLIB_DATA_HDR4_LEN 30 @@ -583,57 +591,59 @@ struct ieee_param { #define RTLLIB_SCTL_SEQ 0xFFF0 /* QOS control */ -#define RTLLIB_QCTL_TID 0x000F +#define RTLLIB_QCTL_TID 0x000F #define FC_QOS_BIT BIT7 -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) -#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT))) +#define IsQoSDataFrame(pframe) \ + ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \ + (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER) +#define SN_LESS(a, b) (((a-b)&0x800) != 0) #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 enum act_category { - ACT_CAT_QOS = 1, - ACT_CAT_DLS = 2, - ACT_CAT_BA = 3, - ACT_CAT_HT = 7, - ACT_CAT_WMM = 17, + ACT_CAT_QOS = 1, + ACT_CAT_DLS = 2, + ACT_CAT_BA = 3, + ACT_CAT_HT = 7, + ACT_CAT_WMM = 17, }; enum ts_action { - ACT_ADDTSREQ = 0, - ACT_ADDTSRSP = 1, - ACT_DELTS = 2, - ACT_SCHEDULE = 3, + ACT_ADDTSREQ = 0, + ACT_ADDTSRSP = 1, + ACT_DELTS = 2, + ACT_SCHEDULE = 3, }; enum ba_action { - ACT_ADDBAREQ = 0, - ACT_ADDBARSP = 1, - ACT_DELBA = 2, + ACT_ADDBAREQ = 0, + ACT_ADDBARSP = 1, + ACT_DELBA = 2, }; enum init_gain_op_type { - IG_Backup=0, + IG_Backup = 0, IG_Restore, IG_Max }; enum led_ctl_mode { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, - LED_CTL_STOP_WPS_FAIL = 12, + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, + LED_CTL_STOP_WPS_FAIL = 12, LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, }; @@ -670,25 +680,29 @@ enum wireless_network_type { /* debug macros */ extern u32 rtllib_debug_level; #define RTLLIB_DEBUG(level, fmt, args...) \ -do { if (rtllib_debug_level & (level)) \ - printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0) +do { \ + if (rtllib_debug_level & (level)) \ + printk(KERN_DEBUG "rtllib: " fmt, ## args); \ +} while (0) + #define RTLLIB_DEBUG_DATA(level, data, datalen) \ - do{ if ((rtllib_debug_level & (level)) == (level)) \ - { \ + do { \ + if ((rtllib_debug_level & (level)) == (level)) { \ int i; \ - u8* pdata = (u8*) data; \ + u8 *pdata = (u8 *)data; \ printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ - for (i=0; i<(int)(datalen); i++) \ - { \ + for (i = 0; i < (int)(datalen); i++) { \ printk("%2.2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ + if ((i+1)%16 == 0) \ + printk("\n"); \ } \ printk("\n"); \ } \ } while (0) #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] +#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ + ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] /* * To use the debug system; @@ -714,22 +728,22 @@ do { if (rtllib_debug_level & (level)) \ * */ -#define RTLLIB_DL_INFO (1<<0) -#define RTLLIB_DL_WX (1<<1) -#define RTLLIB_DL_SCAN (1<<2) -#define RTLLIB_DL_STATE (1<<3) -#define RTLLIB_DL_MGMT (1<<4) -#define RTLLIB_DL_FRAG (1<<5) -#define RTLLIB_DL_EAP (1<<6) -#define RTLLIB_DL_DROP (1<<7) +#define RTLLIB_DL_INFO (1<<0) +#define RTLLIB_DL_WX (1<<1) +#define RTLLIB_DL_SCAN (1<<2) +#define RTLLIB_DL_STATE (1<<3) +#define RTLLIB_DL_MGMT (1<<4) +#define RTLLIB_DL_FRAG (1<<5) +#define RTLLIB_DL_EAP (1<<6) +#define RTLLIB_DL_DROP (1<<7) -#define RTLLIB_DL_TX (1<<8) -#define RTLLIB_DL_RX (1<<9) +#define RTLLIB_DL_TX (1<<8) +#define RTLLIB_DL_RX (1<<9) #define RTLLIB_DL_HT (1<<10) #define RTLLIB_DL_BA (1<<11) #define RTLLIB_DL_TS (1<<12) -#define RTLLIB_DL_QOS (1<<13) +#define RTLLIB_DL_QOS (1<<13) #define RTLLIB_DL_REORDER (1<<14) #define RTLLIB_DL_IOT (1<<15) #define RTLLIB_DL_IPS (1<<16) @@ -753,25 +767,24 @@ do { if (rtllib_debug_level & (level)) \ /* Added by Annie, 2005-11-22. */ #define MAX_STR_LEN 64 -/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ -#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') -#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if ((_Comp) & level) \ - { \ - int __i; \ - u8 struct buffer[MAX_STR_LEN]; \ - int length = (_Len\n", _Len, struct buffer); \ - } +/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */ +#define PRINTABLE(_ch) (_ch > '!' && _ch < '~') +#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ + if ((_Comp) & level) { \ + int __i; \ + u8 struct buffer[MAX_STR_LEN]; \ + int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\ + memset(struct buffer, 0, MAX_STR_LEN); \ + memcpy(struct buffer, (u8 *)_Ptr, length); \ + for (__i = 0; __i < MAX_STR_LEN; __i++) { \ + if (!PRINTABLE(struct buffer[__i])) \ + struct buffer[__i] = '?'; \ + } \ + struct buffer[length] = '\0'; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + printk(": %d, <%s>\n", _Len, struct buffer); \ + } #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ @@ -790,17 +803,17 @@ do { if (rtllib_debug_level & (level)) \ struct rtllib_snap_hdr { - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ -} __attribute__ ((packed)); +} __packed; -enum _REG_PREAMBLE_MODE{ +enum _REG_PREAMBLE_MODE { PREAMBLE_LONG = 1, PREAMBLE_AUTO = 2, - PREAMBLE_SHORT= 3, + PREAMBLE_SHORT = 3, }; #define SNAP_SIZE sizeof(struct rtllib_snap_hdr) @@ -841,65 +854,65 @@ enum _REG_PREAMBLE_MODE{ /* Status codes */ enum rtllib_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, + WLAN_STATUS_SUCCESS = 0, + WLAN_STATUS_UNSPECIFIED_FAILURE = 1, + WLAN_STATUS_CAPS_UNSUPPORTED = 10, + WLAN_STATUS_REASSOC_NO_ASSOC = 11, + WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, + WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, + WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, + WLAN_STATUS_CHALLENGE_FAIL = 15, + WLAN_STATUS_AUTH_TIMEOUT = 16, + WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, + WLAN_STATUS_ASSOC_DENIED_RATES = 18, + /* 802.11b */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, + WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, + WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, + /* 802.11h */ + WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, + WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, + WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, + /* 802.11g */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, + WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, + /* 802.11i */ + WLAN_STATUS_INVALID_IE = 40, + WLAN_STATUS_INVALID_GROUP_CIPHER = 41, + WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, + WLAN_STATUS_INVALID_AKMP = 43, + WLAN_STATUS_UNSUPP_RSN_VERSION = 44, + WLAN_STATUS_INVALID_RSN_IE_CAP = 45, + WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, }; /* Reason codes */ enum rtllib_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, + WLAN_REASON_UNSPECIFIED = 1, + WLAN_REASON_PREV_AUTH_NOT_VALID = 2, + WLAN_REASON_DEAUTH_LEAVING = 3, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, + WLAN_REASON_DISASSOC_AP_BUSY = 5, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, + WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, + /* 802.11h */ + WLAN_REASON_DISASSOC_BAD_POWER = 10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, + /* 802.11i */ + WLAN_REASON_INVALID_IE = 13, + WLAN_REASON_MIC_FAILURE = 14, + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, + WLAN_REASON_IE_DIFFERENT = 17, + WLAN_REASON_INVALID_GROUP_CIPHER = 18, + WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, + WLAN_REASON_INVALID_AKMP = 20, + WLAN_REASON_UNSUPP_RSN_VERSION = 21, + WLAN_REASON_INVALID_RSN_IE_CAP = 22, + WLAN_REASON_IEEE8021X_FAILED = 23, + WLAN_REASON_CIPHER_SUITE_REJECTED = 24, }; #define RTLLIB_STATMASK_SIGNAL (1<<0) @@ -915,13 +928,13 @@ enum rtllib_reasoncode { #define RTLLIB_52GHZ_BAND (1<<1) #define RTLLIB_CCK_RATE_LEN 4 -#define RTLLIB_CCK_RATE_1MB 0x02 -#define RTLLIB_CCK_RATE_2MB 0x04 -#define RTLLIB_CCK_RATE_5MB 0x0B -#define RTLLIB_CCK_RATE_11MB 0x16 +#define RTLLIB_CCK_RATE_1MB 0x02 +#define RTLLIB_CCK_RATE_2MB 0x04 +#define RTLLIB_CCK_RATE_5MB 0x0B +#define RTLLIB_CCK_RATE_11MB 0x16 #define RTLLIB_OFDM_RATE_LEN 8 -#define RTLLIB_OFDM_RATE_6MB 0x0C -#define RTLLIB_OFDM_RATE_9MB 0x12 +#define RTLLIB_OFDM_RATE_6MB 0x0C +#define RTLLIB_OFDM_RATE_9MB 0x12 #define RTLLIB_OFDM_RATE_12MB 0x18 #define RTLLIB_OFDM_RATE_18MB 0x24 #define RTLLIB_OFDM_RATE_24MB 0x30 @@ -943,12 +956,12 @@ enum rtllib_reasoncode { #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) -#define RTLLIB_CCK_RATES_MASK 0x0000000F +#define RTLLIB_CCK_RATES_MASK 0x0000000F #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ RTLLIB_CCK_RATE_2MB_MASK) #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ - RTLLIB_CCK_RATE_5MB_MASK | \ - RTLLIB_CCK_RATE_11MB_MASK) + RTLLIB_CCK_RATE_5MB_MASK | \ + RTLLIB_CCK_RATE_11MB_MASK) #define RTLLIB_OFDM_RATES_MASK 0x00000FF0 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ @@ -961,11 +974,11 @@ enum rtllib_reasoncode { RTLLIB_OFDM_RATE_48MB_MASK | \ RTLLIB_OFDM_RATE_54MB_MASK) #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ - RTLLIB_CCK_DEFAULT_RATES_MASK) + RTLLIB_CCK_DEFAULT_RATES_MASK) #define RTLLIB_NUM_OFDM_RATES 8 -#define RTLLIB_NUM_CCK_RATES 4 -#define RTLLIB_OFDM_SHIFT_MASK_A 4 +#define RTLLIB_NUM_CCK_RATES 4 +#define RTLLIB_OFDM_SHIFT_MASK_A 4 /* this is stolen and modified from the madwifi driver*/ @@ -992,7 +1005,6 @@ struct ieee_ibss_seq { * information for frames received. Not setting these will not cause * any adverse affects. */ struct rtllib_rx_stats { -#if 1 u64 mac_time; s8 rssi; u8 signal; @@ -1038,7 +1050,7 @@ struct rtllib_rx_stats { bool bPacketMatchBSSID; bool bIsCCK; bool bPacketToSelf; - u8* virtual_address; + u8 *virtual_address; u16 packetlength; u16 fraglength; u16 fragoffset; @@ -1049,8 +1061,6 @@ struct rtllib_rx_stats { char cck_adc_pwdb[4]; u16 Seq_Num; u8 nTotalAggPkt; -#endif - }; /* IEEE 802.11 requires that STA supports concurrent reception of at least @@ -1096,14 +1106,14 @@ struct rtllib_device; #include "rtllib_crypt.h" -#define SEC_KEY_1 (1<<0) -#define SEC_KEY_2 (1<<1) -#define SEC_KEY_3 (1<<2) -#define SEC_KEY_4 (1<<3) +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) #define SEC_ACTIVE_KEY (1<<4) #define SEC_AUTH_MODE (1<<5) #define SEC_UNICAST_GROUP (1<<6) -#define SEC_LEVEL (1<<7) +#define SEC_LEVEL (1<<7) #define SEC_ENABLED (1<<8) #define SEC_ENCRYPT (1<<9) @@ -1113,28 +1123,28 @@ struct rtllib_device; #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ -#define SEC_ALG_NONE 0 -#define SEC_ALG_WEP 1 -#define SEC_ALG_TKIP 2 -#define SEC_ALG_CCMP 4 +#define SEC_ALG_NONE 0 +#define SEC_ALG_WEP 1 +#define SEC_ALG_TKIP 2 +#define SEC_ALG_CCMP 4 #define WEP_KEYS 4 #define WEP_KEY_LEN 13 -#define SCM_KEY_LEN 32 +#define SCM_KEY_LEN 32 #define SCM_TEMPORAL_KEY_LENGTH 16 struct rtllib_security { u16 active_key:2, - enabled:1, + enabled:1, auth_mode:2, - auth_algo:4, - unicast_uses_group:1, + auth_algo:4, + unicast_uses_group:1, encrypt:1; u8 key_sizes[WEP_KEYS]; u8 keys[WEP_KEYS][SCM_KEY_LEN]; u8 level; u16 flags; -} __attribute__ ((packed)); +} __packed; /* @@ -1143,75 +1153,75 @@ struct rtllib_security { Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | + | | tion | (BSSID) | | | ence | data | | `-------------------------------------------------------------------' Total: 28-2340 bytes */ /* Management Frame Information Element Types */ enum rtllib_mfie { - MFIE_TYPE_SSID = 0, - MFIE_TYPE_RATES = 1, - MFIE_TYPE_FH_SET = 2, - MFIE_TYPE_DS_SET = 3, - MFIE_TYPE_CF_SET = 4, - MFIE_TYPE_TIM = 5, - MFIE_TYPE_IBSS_SET = 6, - MFIE_TYPE_COUNTRY = 7, - MFIE_TYPE_HOP_PARAMS = 8, - MFIE_TYPE_HOP_TABLE = 9, - MFIE_TYPE_REQUEST = 10, - MFIE_TYPE_CHALLENGE = 16, - MFIE_TYPE_POWER_CONSTRAINT = 32, - MFIE_TYPE_POWER_CAPABILITY = 33, - MFIE_TYPE_TPC_REQUEST = 34, - MFIE_TYPE_TPC_REPORT = 35, - MFIE_TYPE_SUPP_CHANNELS = 36, - MFIE_TYPE_CSA = 37, - MFIE_TYPE_MEASURE_REQUEST = 38, - MFIE_TYPE_MEASURE_REPORT = 39, - MFIE_TYPE_QUIET = 40, - MFIE_TYPE_IBSS_DFS = 41, - MFIE_TYPE_ERP = 42, - MFIE_TYPE_HT_CAP= 45, + MFIE_TYPE_SSID = 0, + MFIE_TYPE_RATES = 1, + MFIE_TYPE_FH_SET = 2, + MFIE_TYPE_DS_SET = 3, + MFIE_TYPE_CF_SET = 4, + MFIE_TYPE_TIM = 5, + MFIE_TYPE_IBSS_SET = 6, + MFIE_TYPE_COUNTRY = 7, + MFIE_TYPE_HOP_PARAMS = 8, + MFIE_TYPE_HOP_TABLE = 9, + MFIE_TYPE_REQUEST = 10, + MFIE_TYPE_CHALLENGE = 16, + MFIE_TYPE_POWER_CONSTRAINT = 32, + MFIE_TYPE_POWER_CAPABILITY = 33, + MFIE_TYPE_TPC_REQUEST = 34, + MFIE_TYPE_TPC_REPORT = 35, + MFIE_TYPE_SUPP_CHANNELS = 36, + MFIE_TYPE_CSA = 37, + MFIE_TYPE_MEASURE_REQUEST = 38, + MFIE_TYPE_MEASURE_REPORT = 39, + MFIE_TYPE_QUIET = 40, + MFIE_TYPE_IBSS_DFS = 41, + MFIE_TYPE_ERP = 42, + MFIE_TYPE_HT_CAP = 45, MFIE_TYPE_RSN = 48, MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, + MFIE_TYPE_HT_INFO = 61, + MFIE_TYPE_AIRONET = 133, MFIE_TYPE_GENERIC = 221, - MFIE_TYPE_QOS_PARAMETER = 222, + MFIE_TYPE_QOS_PARAMETER = 222, }; /* Minimal header; can be used for passing 802.11 frames with sufficient * information to determine what type of underlying data type is actually * stored in the data. */ struct rtllib_pspoll_hdr { - __le16 frame_ctl; - __le16 aid; + __le16 frame_ctl; + __le16 aid; u8 bssid[ETH_ALEN]; - u8 ta[ETH_ALEN]; -} __attribute__ ((packed)); + u8 ta[ETH_ALEN]; +} __packed; struct rtllib_hdr { - __le16 frame_ctl; - __le16 duration_id; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 payload[0]; +} __packed; struct rtllib_hdr_1addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_2addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_3addr { __le16 frame_ctl; @@ -1220,8 +1230,8 @@ struct rtllib_hdr_3addr { u8 addr2[ETH_ALEN]; u8 addr3[ETH_ALEN]; __le16 seq_ctl; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_4addr { __le16 frame_ctl; @@ -1231,8 +1241,8 @@ struct rtllib_hdr_4addr { u8 addr3[ETH_ALEN]; __le16 seq_ctl; u8 addr4[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_3addrqos { __le16 frame_ctl; @@ -1243,7 +1253,7 @@ struct rtllib_hdr_3addrqos { __le16 seq_ctl; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_hdr_4addrqos { __le16 frame_ctl; @@ -1255,13 +1265,13 @@ struct rtllib_hdr_4addrqos { u8 addr4[ETH_ALEN]; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_info_element { u8 id; u8 len; u8 data[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_authentication { struct rtllib_hdr_3addr header; @@ -1270,33 +1280,33 @@ struct rtllib_authentication { __le16 status; /*challenge*/ struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_disauth { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_disassoc { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_probe_request { struct rtllib_hdr_3addr header; /* SSID, supported rates */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_probe_response { struct rtllib_hdr_3addr header; u32 time_stamp[2]; __le16 beacon_interval; __le16 capability; - /* SSID, supported rates, FH params, DS params, - * CF params, IBSS params, TIM (if beacon), RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + /* SSID, supported rates, FH params, DS params, + * CF params, IBSS params, TIM (if beacon), RSN */ + struct rtllib_info_element info_element[0]; +} __packed; /* Alias beacon for probe_response */ #define rtllib_beacon rtllib_probe_response @@ -1306,8 +1316,8 @@ struct rtllib_assoc_request_frame { __le16 capability; __le16 listen_interval; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_reassoc_request_frame { struct rtllib_hdr_3addr header; @@ -1315,8 +1325,8 @@ struct rtllib_reassoc_request_frame { __le16 listen_interval; u8 current_ap[ETH_ALEN]; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_assoc_response_frame { struct rtllib_hdr_3addr header; @@ -1324,7 +1334,7 @@ struct rtllib_assoc_response_frame { __le16 status; __le16 aid; struct rtllib_info_element info_element[0]; /* supported rates */ -} __attribute__ ((packed)); +} __packed; struct rtllib_txb { u8 nr_frags; @@ -1341,7 +1351,7 @@ struct rtllib_txb { struct rtllib_drv_agg_txb { u8 nr_drv_agg_frames; struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -}__attribute__((packed)); +} __packed; #define MAX_SUBFRAME_COUNT 64 struct rtllib_rxb { @@ -1349,7 +1359,7 @@ struct rtllib_rxb { struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; u8 dst[ETH_ALEN]; u8 src[ETH_ALEN]; -}__attribute__((packed)); +} __packed; union frameqos { u16 shortdata; @@ -1360,7 +1370,7 @@ union frameqos { u16 ack_policy:2; u16 reserved:1; u16 txop:8; - }field; + } field; }; /* SWEEP TABLE ENTRIES NUMBER*/ @@ -1370,15 +1380,15 @@ union frameqos { * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the * main rates information element... */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 96 +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#define MAX_NETWORK_COUNT 96 -#define MAX_CHANNEL_NUMBER 161 +#define MAX_CHANNEL_NUMBER 161 #define RTLLIB_SOFTMAC_SCAN_TIME 100 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) -#define CRC_LENGTH 4U +#define CRC_LENGTH 4U #define MAX_WPA_IE_LEN 64 #define MAX_WZC_IE_LEN 256 @@ -1390,69 +1400,69 @@ union frameqos { /* QoS structure */ #define NETWORK_HAS_QOS_PARAMETERS (1<<3) #define NETWORK_HAS_QOS_INFORMATION (1<<4) -#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ - NETWORK_HAS_QOS_INFORMATION) +#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ + NETWORK_HAS_QOS_INFORMATION) /* 802.11h */ #define NETWORK_HAS_POWER_CONSTRAINT (1<<5) -#define NETWORK_HAS_CSA (1<<6) -#define NETWORK_HAS_QUIET (1<<7) -#define NETWORK_HAS_IBSS_DFS (1<<8) -#define NETWORK_HAS_TPC_REPORT (1<<9) +#define NETWORK_HAS_CSA (1<<6) +#define NETWORK_HAS_QUIET (1<<7) +#define NETWORK_HAS_IBSS_DFS (1<<8) +#define NETWORK_HAS_TPC_REPORT (1<<9) -#define NETWORK_HAS_ERP_VALUE (1<<10) +#define NETWORK_HAS_ERP_VALUE (1<<10) + +#define QOS_QUEUE_NUM 4 +#define QOS_OUI_LEN 3 +#define QOS_OUI_TYPE 2 +#define QOS_ELEMENT_ID 221 +#define QOS_OUI_INFO_SUB_TYPE 0 +#define QOS_OUI_PARAM_SUB_TYPE 1 +#define QOS_VERSION_1 1 +#define QOS_AIFSN_MIN_VALUE 2 -#define QOS_QUEUE_NUM 4 -#define QOS_OUI_LEN 3 -#define QOS_OUI_TYPE 2 -#define QOS_ELEMENT_ID 221 -#define QOS_OUI_INFO_SUB_TYPE 0 -#define QOS_OUI_PARAM_SUB_TYPE 1 -#define QOS_VERSION_1 1 -#define QOS_AIFSN_MIN_VALUE 2 -#if 1 struct rtllib_qos_information_element { - u8 elementID; - u8 length; - u8 qui[QOS_OUI_LEN]; - u8 qui_type; - u8 qui_subtype; - u8 version; - u8 ac_info; -} __attribute__ ((packed)); + u8 elementID; + u8 length; + u8 qui[QOS_OUI_LEN]; + u8 qui_type; + u8 qui_subtype; + u8 version; + u8 ac_info; +} __packed; struct rtllib_qos_ac_parameter { - u8 aci_aifsn; - u8 ecw_min_max; - __le16 tx_op_limit; -} __attribute__ ((packed)); + u8 aci_aifsn; + u8 ecw_min_max; + __le16 tx_op_limit; +} __packed; struct rtllib_qos_parameter_info { - struct rtllib_qos_information_element info_element; - u8 reserved; - struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + struct rtllib_qos_information_element info_element; + u8 reserved; + struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_parameters { - __le16 cw_min[QOS_QUEUE_NUM]; - __le16 cw_max[QOS_QUEUE_NUM]; - u8 aifs[QOS_QUEUE_NUM]; - u8 flag[QOS_QUEUE_NUM]; - __le16 tx_op_limit[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + __le16 cw_min[QOS_QUEUE_NUM]; + __le16 cw_max[QOS_QUEUE_NUM]; + u8 aifs[QOS_QUEUE_NUM]; + u8 flag[QOS_QUEUE_NUM]; + __le16 tx_op_limit[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_data { - struct rtllib_qos_parameters parameters; + struct rtllib_qos_parameters parameters; unsigned int wmm_acm; - int active; - int supported; - u8 param_count; - u8 old_param_count; + int active; + int supported; + u8 param_count; + u8 old_param_count; }; struct rtllib_tim_parameters { - u8 tim_count; - u8 tim_period; -} __attribute__ ((packed)); + u8 tim_count; + u8 tim_period; +} __packed; struct rtllib_wmm_ac_param { u8 ac_aci_acm_aifsn; @@ -1464,7 +1474,7 @@ struct rtllib_wmm_ts_info { u8 ac_dir_tid; u8 ac_up_psb; u8 reserved; -} __attribute__ ((packed)); +} __packed; struct rtllib_wmm_tspec_elem { struct rtllib_wmm_ts_info ts_info; @@ -1483,8 +1493,8 @@ struct rtllib_wmm_tspec_elem { u32 min_phy_rate; u16 surp_band_allow; u16 medium_time; -}__attribute__((packed)); -#endif +} __packed; + enum eap_type { EAP_PACKET = 0, EAPOL_START, @@ -1503,15 +1513,17 @@ static const char *eap_types[] = { static inline const char *eap_get_type(int type) { - return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; + return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : + eap_types[type]; } -static inline u8 Frame_QoSTID(u8* buf) +static inline u8 Frame_QoSTID(u8 *buf) { struct rtllib_hdr_3addr *hdr; u16 fc; hdr = (struct rtllib_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) && + (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid; } @@ -1521,9 +1533,9 @@ struct eapol { u8 version; u8 type; u16 length; -} __attribute__ ((packed)); +} __packed; -struct rtllib_softmac_stats{ +struct rtllib_softmac_stats { unsigned int rx_ass_ok; unsigned int rx_ass_err; unsigned int rx_probe_rq; @@ -1551,7 +1563,7 @@ struct rtllib_softmac_stats{ struct rtllib_info_element_hdr { u8 id; u8 len; -} __attribute__ ((packed)); +} __packed; /* * These are the data types that can make up management packets @@ -1564,7 +1576,7 @@ struct rtllib_info_element_hdr { u16 listen_interval; struct { u16 association_id:14, reserved:2; - } __attribute__ ((packed)); + } __packed; u32 time_stamp[2]; u16 reason; u16 status; @@ -1611,13 +1623,14 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; 0) #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ -#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/ +#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address + * plus ether type*/ struct ether_header { u8 ether_dhost[ETHER_ADDR_LEN]; u8 ether_shost[ETHER_ADDR_LEN]; u16 ether_type; -} __attribute__((packed)); +} __packed; #ifndef ETHERTYPE_PAE #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ @@ -1676,13 +1689,13 @@ struct rtllib_network { u8 wzc_ie[MAX_WZC_IE_LEN]; size_t wzc_ie_len; - struct rtllib_tim_parameters tim; + struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; u64 last_dtim_sta_time; - u8 wmm_info; - struct rtllib_wmm_ac_param wmm_param[4]; + u8 wmm_info; + struct rtllib_wmm_ac_param wmm_param[4]; u8 Turbo_Enable; u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; @@ -1743,13 +1756,13 @@ enum rtllib_state { }; #else enum rtllib_state { - RTLLIB_UNINITIALIZED = 0, - RTLLIB_INITIALIZED, - RTLLIB_ASSOCIATING, - RTLLIB_ASSOCIATED, - RTLLIB_AUTHENTICATING, - RTLLIB_AUTHENTICATED, - RTLLIB_SHUTDOWN + RTLLIB_UNINITIALIZED = 0, + RTLLIB_INITIALIZED, + RTLLIB_ASSOCIATING, + RTLLIB_ASSOCIATED, + RTLLIB_AUTHENTICATING, + RTLLIB_AUTHENTICATED, + RTLLIB_SHUTDOWN }; #endif @@ -1763,14 +1776,16 @@ enum rtllib_state { #define RTLLIB_24GHZ_MIN_CHANNEL 1 #define RTLLIB_24GHZ_MAX_CHANNEL 14 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ - RTLLIB_24GHZ_MIN_CHANNEL + 1) + RTLLIB_24GHZ_MIN_CHANNEL + 1) #define RTLLIB_52GHZ_MIN_CHANNEL 34 #define RTLLIB_52GHZ_MAX_CHANNEL 165 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ - RTLLIB_52GHZ_MIN_CHANNEL + 1) + RTLLIB_52GHZ_MIN_CHANNEL + 1) #ifndef eqMacAddr -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) +#define eqMacAddr(a, b) \ + (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \ + (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) #endif struct tx_pending { int frag; @@ -1791,7 +1806,7 @@ struct bandwidth_autoswitch { struct rx_reorder_entry { struct list_head List; u16 SeqNum; - struct rtllib_rxb* prxb; + struct rtllib_rxb *prxb; }; enum fsync_state { Default_Fsync, @@ -1936,7 +1951,7 @@ enum country_code_type { }; enum scan_op_backup_opt { - SCAN_OPT_BACKUP=0, + SCAN_OPT_BACKUP = 0, SCAN_OPT_RESTORE, SCAN_OPT_MAX }; @@ -1949,10 +1964,10 @@ enum fw_cmd_io_type { FW_CMD_HIGH_PWR_ENABLE = 4, FW_CMD_HIGH_PWR_DISABLE = 5, FW_CMD_RA_RESET = 6, - FW_CMD_RA_ACTIVE= 7, - FW_CMD_RA_REFRESH_N= 8, - FW_CMD_RA_REFRESH_BG= 9, - FW_CMD_RA_INIT= 10, + FW_CMD_RA_ACTIVE = 7, + FW_CMD_RA_REFRESH_N = 8, + FW_CMD_RA_REFRESH_BG = 9, + FW_CMD_RA_INIT = 10, FW_CMD_IQK_ENABLE = 11, FW_CMD_TXPWR_TRACK_ENABLE = 12, FW_CMD_TXPWR_TRACK_DISABLE = 13, @@ -2046,17 +2061,17 @@ enum ratr_table_mode_8192s { #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { - u8 bUsed; - u8 Bssid[6]; - u8 PMKID[16]; - u8 SsidBuf[33]; - u8* ssid_octet; - u16 ssid_length; + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8 *ssid_octet; + u16 ssid_length; }; struct rt_intel_promisc_mode { - bool bPromiscuousOn; - bool bFilterSourceStationFrame; + bool bPromiscuousOn; + bool bFilterSourceStationFrame; }; @@ -2070,14 +2085,14 @@ struct rt_intel_promisc_mode { enum { NO_USE = 0, USED = 1, - HW_SEC = 2, + HW_SEC = 2, SW_SEC = 3, }; enum { LPS_IS_WAKE = 0, LPS_IS_SLEEP = 1, - LPS_WAIT_NULL_DATA_SEND =2, + LPS_WAIT_NULL_DATA_SEND = 2, }; struct rtllib_device { @@ -2113,7 +2128,7 @@ struct rtllib_device { u8 hwsec_active; bool is_silent_reset; - bool force_mic_error; + bool force_mic_error; bool is_roaming; bool ieee_up; bool cannot_notify; @@ -2135,10 +2150,10 @@ struct rtllib_device { u8 Regdot11TxHTOperationalRateSet[16]; u8 dot11HTOperationalRateSet[16]; u8 RegHTSuppRateSet[16]; - u8 HTCurrentOperaRate; - u8 HTHighestOperaRate; - u8 MinSpaceCfg; - u8 MaxMssDensity; + u8 HTCurrentOperaRate; + u8 HTHighestOperaRate; + u8 MinSpaceCfg; + u8 MaxMssDensity; u8 bTxDisableRateFallBack; u8 bTxUseDriverAssingedRate; u8 bTxEnableFwCalcDur; @@ -2193,15 +2208,15 @@ struct rtllib_device { int host_encrypt; int host_encrypt_msdu; int host_decrypt; - /* host performs multicast decryption */ - int host_mc_decrypt; + /* host performs multicast decryption */ + int host_mc_decrypt; - /* host should strip IV and ICV from protected frames */ - /* meaningful only when hardware decryption is being used */ - int host_strip_iv_icv; + /* host should strip IV and ICV from protected frames */ + /* meaningful only when hardware decryption is being used */ + int host_strip_iv_icv; - int host_open_frag; - int host_build_iv; + int host_open_frag; + int host_build_iv; int ieee802_1x; /* is IEEE 802.1X used */ /* WPA data */ @@ -2224,7 +2239,7 @@ struct rtllib_device { int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; struct timer_list crypt_deinit_timer; - int crypt_quiesced; + int crypt_quiesced; int bcrx_sta_key; /* use individual keys to override default keys even * with RX of broad/multicast frames */ @@ -2238,10 +2253,10 @@ struct rtllib_device { #define DEFAULT_RTS_THRESHOLD 2346U #define MIN_RTS_THRESHOLD 1 #define MAX_RTS_THRESHOLD 2346U - u16 rts; /* RTS threshold */ + u16 rts; /* RTS threshold */ - /* Association info */ - u8 bssid[ETH_ALEN]; + /* Association info */ + u8 bssid[ETH_ALEN]; /* This stores infos for the current network. * Either the network we are associated in INFRASTRUCTURE @@ -2260,20 +2275,20 @@ struct rtllib_device { int mode; /* A, B, G */ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ - int abg_true; /* ABG flag */ + int abg_true; /* ABG flag */ /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ short sync_scan_hurryup; u16 scan_watch_dog; - int perfect_rssi; - int worst_rssi; + int perfect_rssi; + int worst_rssi; - u16 prev_seq_ctl; /* used to drop duplicate frames */ + u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ - void* pDot11dInfo; + void *pDot11dInfo; bool bGlobalDomain; u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; @@ -2417,11 +2432,11 @@ struct rtllib_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device * dev, int pri); + int (*is_queue_full)(struct net_device *dev, int pri); - int (*handle_management) (struct net_device * dev, - struct rtllib_network * network, u16 type); - int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + int (*handle_management)(struct net_device *dev, + struct rtllib_network *network, u16 type); + int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (mamagement) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -2440,7 +2455,7 @@ struct rtllib_device { * This function can't sleep. */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev,int rate); + struct net_device *dev, int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating @@ -2455,7 +2470,7 @@ struct rtllib_device { * This function can sleep. the driver should ensure * the radio has been swithced before return. */ - void (*set_chan)(struct net_device *dev,short ch); + void (*set_chan)(struct net_device *dev, short ch); /* These are not used if the ieee stack takes care of * scanning (IEEE_SOFTMAC_SCAN feature set). @@ -2492,41 +2507,55 @@ struct rtllib_device { * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ - void (*start_send_beacons) (struct net_device *dev); - void (*stop_send_beacons) (struct net_device *dev); + void (*start_send_beacons)(struct net_device *dev); + void (*stop_send_beacons)(struct net_device *dev); /* power save mode related */ - void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u64 time); - short (*ps_is_queue_empty) (struct net_device *dev); - int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); - int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); + void (*sta_wake_up)(struct net_device *dev); + void (*enter_sleep_state)(struct net_device *dev, u64 time); + short (*ps_is_queue_empty)(struct net_device *dev); + int (*handle_beacon)(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network); + int (*handle_assoc_response)(struct net_device *dev, + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network); /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); short (*get_nic_desc_num)(struct net_device *dev, int queue_index); - void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); - bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); - void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); - bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); + void (*SetBWModeHandler)(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); + void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); + bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); - bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO); - void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level); - void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start); - void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); + bool (*SetFwCmdHandler)(struct net_device *dev, + enum fw_cmd_io_type FwCmdIO); + void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast, + u8 macId, u8 MimoPs, u8 WirelessMode, + u8 bCurTxBW40MHz, u8 rssi_level); + void (*UpdateBeaconInterruptHandler)(struct net_device *dev, + bool start); + void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR, + u32 RemoveMSR); u16 (*rtl_11n_user_show_rates)(struct net_device *dev); - void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); - void (*LedControlHandler)(struct net_device * dev, enum led_ctl_mode LedAction); - void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); - void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); + void (*ScanOperationBackupHandler)(struct net_device *dev, + u8 Operation); + void (*LedControlHandler)(struct net_device *dev, + enum led_ctl_mode LedAction); + void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); + void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); - void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg); + void (*AllowAllDestAddrHandler)(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg); - void (*rtllib_ips_leave_wq) (struct net_device *dev); - void (*rtllib_ips_leave)(struct net_device *dev); + void (*rtllib_ips_leave_wq) (struct net_device *dev); + void (*rtllib_ips_leave)(struct net_device *dev); void (*LeisurePSLeave)(struct net_device *dev); void (*rtllib_rfkill_poll)(struct net_device *dev); @@ -2535,9 +2564,9 @@ struct rtllib_device { u8 priv[0]; }; -#define IEEE_A (1<<0) -#define IEEE_B (1<<1) -#define IEEE_G (1<<2) +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) #define IEEE_N_24G (1<<4) #define IEEE_N_5G (1<<5) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) @@ -2650,45 +2679,45 @@ extern inline int rtllib_get_hdrlen(u16 fc) static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr) { - switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { - case RTLLIB_1ADDR_LEN: - return ((struct rtllib_hdr_1addr *)hdr)->payload; - case RTLLIB_2ADDR_LEN: - return ((struct rtllib_hdr_2addr *)hdr)->payload; - case RTLLIB_3ADDR_LEN: - return ((struct rtllib_hdr_3addr *)hdr)->payload; - case RTLLIB_4ADDR_LEN: - return ((struct rtllib_hdr_4addr *)hdr)->payload; - } - return NULL; + switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { + case RTLLIB_1ADDR_LEN: + return ((struct rtllib_hdr_1addr *)hdr)->payload; + case RTLLIB_2ADDR_LEN: + return ((struct rtllib_hdr_2addr *)hdr)->payload; + case RTLLIB_3ADDR_LEN: + return ((struct rtllib_hdr_3addr *)hdr)->payload; + case RTLLIB_4ADDR_LEN: + return ((struct rtllib_hdr_4addr *)hdr)->payload; + } + return NULL; } static inline int rtllib_is_ofdm_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_OFDM_RATE_6MB: - case RTLLIB_OFDM_RATE_9MB: - case RTLLIB_OFDM_RATE_12MB: - case RTLLIB_OFDM_RATE_18MB: - case RTLLIB_OFDM_RATE_24MB: - case RTLLIB_OFDM_RATE_36MB: - case RTLLIB_OFDM_RATE_48MB: - case RTLLIB_OFDM_RATE_54MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_OFDM_RATE_6MB: + case RTLLIB_OFDM_RATE_9MB: + case RTLLIB_OFDM_RATE_12MB: + case RTLLIB_OFDM_RATE_18MB: + case RTLLIB_OFDM_RATE_24MB: + case RTLLIB_OFDM_RATE_36MB: + case RTLLIB_OFDM_RATE_48MB: + case RTLLIB_OFDM_RATE_54MB: + return 1; + } + return 0; } static inline int rtllib_is_cck_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_CCK_RATE_1MB: - case RTLLIB_CCK_RATE_2MB: - case RTLLIB_CCK_RATE_5MB: - case RTLLIB_CCK_RATE_11MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_CCK_RATE_1MB: + case RTLLIB_CCK_RATE_2MB: + case RTLLIB_CCK_RATE_5MB: + case RTLLIB_CCK_RATE_11MB: + return 1; + } + return 0; } @@ -2716,8 +2745,8 @@ extern void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *stats); extern void rtllib_rx_probe_rq(struct rtllib_device *ieee, - struct sk_buff *skb); -extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel); + struct sk_buff *skb); +extern int IsLegalChannel(struct rtllib_device *rtllib, u8 channel); /* rtllib_wx.c */ extern int rtllib_wx_get_scan(struct rtllib_device *ieee, @@ -2731,30 +2760,33 @@ extern int rtllib_wx_get_encode(struct rtllib_device *ieee, union iwreq_data *wrqu, char *key); #if WIRELESS_EXT >= 18 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); #endif extern int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra); + struct iw_request_info *info, + struct iw_param *data, char *extra); extern int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); /* rtllib_softmac.c */ extern short rtllib_is_54g(struct rtllib_network *net); extern short rtllib_is_shortslot(struct rtllib_network net); -extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype); -extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net); +extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype); +extern void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net); void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); -extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee); +extern void rtllib_softmac_xmit(struct rtllib_txb *txb, + struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); extern void notify_wx_assoc_event(struct rtllib_device *ieee); @@ -2772,21 +2804,28 @@ extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); -extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); +extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, + short pwr); extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); extern void rtllib_check_all_nets(struct rtllib_device *ieee); extern void rtllib_start_protocol(struct rtllib_device *ieee); extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); -extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState); +extern void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh); -extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown); -extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag); +extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, + u8 mesh_flag, u8 shutdown); +extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, + u8 mesh_flag); extern void rtllib_reset_queue(struct rtllib_device *ieee); extern void rtllib_wake_queue(struct rtllib_device *ieee); @@ -2796,13 +2835,16 @@ extern void rtllib_stop_all_queues(struct rtllib_device *ieee); extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); extern void rtllib_start_send_beacons(struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); -extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh); +extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, + struct iw_point *p, u8 is_mesh); extern void notify_wx_assoc_event(struct rtllib_device *ieee); extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success); -extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee); -extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst); +extern void softmac_mgmt_xmit(struct sk_buff *skb, + struct rtllib_device *ieee); +extern u16 rtllib_query_seqnum(struct rtllib_device *ieee, + struct sk_buff *skb, u8 *dst); extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); /* rtllib_crypt_ccmp&tkip&wep.c */ @@ -2813,42 +2855,49 @@ extern void rtllib_ccmp_null(void); /* rtllib_softmac_wx.c */ extern int rtllib_wx_get_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *ext); + struct iw_request_info *info, + union iwreq_data *wrqu, char *ext); extern int rtllib_wx_set_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra); + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra); -extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int rtllib_wx_get_essid(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_get_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_scan(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern void rtllib_wx_sync_scan_wq(void *data); extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee, @@ -2875,49 +2924,62 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); #define MAX_RECEIVE_BUFFER_SIZE 9100 -extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); -extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); +extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); +extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); -extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); -extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); -extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); -extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len); +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); +extern void HTUpdateDefaultSetting(struct rtllib_device *ieee); +extern void HTConstructCapabilityElement(struct rtllib_device *ieee, + u8 *posHTCap, u8 *len, + u8 isEncrypt, bool bAssoc); +extern void HTConstructInfoElement(struct rtllib_device *ieee, + u8 *posHTInfo, u8 *len, u8 isEncrypt); +extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee, + u8 *posRT2RTAgg, u8* len); extern void HTOnAssocRsp(struct rtllib_device *ieee); -extern void HTInitializeHTInfo(struct rtllib_device* ieee); +extern void HTInitializeHTInfo(struct rtllib_device *ieee); extern void HTInitializeBssDesc(struct bss_ht *pBssHT); -extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); +extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; -extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame); +extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame); extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo); -extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee); -extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate); -extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate); -extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate); -extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); -extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); +extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee); +extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate); +extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb); +extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending); +extern void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry( struct ba_record *pBA); +extern void ResetBaEntry(struct ba_record *pBA); extern bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs - ); + struct rtllib_device *ieee, + struct ts_common_info **ppTS, + u8 *Addr, + u8 TID, + enum tr_select TxRxSelect, + bool bAddNewTs +); extern void TSInitialize(struct rtllib_device *ieee); -extern void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS); -extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr); -extern void RemoveAllTS(struct rtllib_device* ieee); +extern void TsStartAddBaProcess(struct rtllib_device *ieee, + struct tx_ts_record *pTxTS); +extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr); +extern void RemoveAllTS(struct rtllib_device *ieee); void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern const long rtllib_wlan_frequencies[]; @@ -2932,7 +2994,8 @@ extern inline int rtllib_get_scans(struct rtllib_device *ieee) return ieee->scans; } -static inline const char *escape_essid(const char *essid, u8 essid_len) { +static inline const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; const char *s = essid; char *d = escaped; @@ -2956,7 +3019,9 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) { return escaped; } -#define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE #include #include -#include +#include #include #include "rtllib.h" @@ -56,11 +56,11 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer( struct timer_list* ptimer, void* fun, unsigned long data ) +void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) { - ptimer->function = fun; - ptimer->data = data; - init_timer( ptimer ); + ptimer->function = fun; + ptimer->data = data; + init_timer(ptimer); } static inline int rtllib_networks_allocate(struct rtllib_device *ieee) @@ -98,14 +98,15 @@ static inline void rtllib_networks_initialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->network_free_list); INIT_LIST_HEAD(&ieee->network_list); for (i = 0; i < MAX_NETWORK_COUNT; i++) - list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); + list_add_tail(&ieee->networks[i].list, + &ieee->network_free_list); } struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; struct net_device *dev; - int i,err; + int i, err; RTLLIB_DEBUG_INFO("Initializing...\n"); @@ -159,12 +160,11 @@ struct net_device *alloc_rtllib(int sizeof_priv) ieee->raw_tx = 0; ieee->hwsec_active = 0; - memset(ieee->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtllib_softmac_init(ieee); - ieee->pHTInfo = (struct rt_hi_throughput*)kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); - if (ieee->pHTInfo == NULL) - { + ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); + if (ieee->pHTInfo == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); return NULL; } @@ -192,10 +192,10 @@ struct net_device *alloc_rtllib(int sizeof_priv) return NULL; } - void free_rtllib(struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); int i; if (ieee->pHTInfo != NULL) { kfree(ieee->pHTInfo); @@ -219,11 +219,11 @@ void free_rtllib(struct net_device *dev) free_netdev(dev); } -u32 rtllib_debug_level = 0; +u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc = NULL; +struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 7ccad860182..134e69f4ee5 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -286,7 +286,6 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -#define SN_LESS(a, b) (((a-b)&0x800)!=0) void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; From db8971b618ed967c93fb89622dfe6006a58d55a5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:25 -0500 Subject: [PATCH 0554/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIII With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_module.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 1490 +++++++++++----------- 2 files changed, 714 insertions(+), 778 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index a2c22cf990d..dd0d8db01bd 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -56,7 +56,7 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) +void _setup_timer(struct timer_list *ptimer, void *fun, unsigned long data) { ptimer->function = fun; ptimer->data = data; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 9606bedf16d..205c5750849 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -39,18 +39,18 @@ #include #include #include -#include +#include #include #include "rtllib.h" #include "dot11d.h" static inline void rtllib_monitor_rx(struct rtllib_device *ieee, - struct sk_buff *skb,struct rtllib_rx_stats *rx_status, + struct sk_buff *skb, struct rtllib_rx_stats *rx_status, size_t hdr_length) { skb->dev = ieee->dev; - skb_reset_mac_header(skb); + skb_reset_mac_header(skb); skb_pull(skb, hdr_length); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); @@ -61,7 +61,7 @@ static inline void rtllib_monitor_rx(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ) */ static struct rtllib_frag_entry * rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, - unsigned int frag, u8 tid,u8 *src, u8 *dst) + unsigned int frag, u8 tid, u8 *src, u8 *dst) { struct rtllib_frag_entry *entry; int i; @@ -103,18 +103,18 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } if (frag == 0) { @@ -125,7 +125,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, 2 /* alignment */ + 8 /* WEP */ + ETH_ALEN /* WDS */ + - (RTLLIB_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */); + (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */); if (skb == NULL) return NULL; @@ -146,7 +146,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = rtllib_frag_cache_find(ieee, seq, frag, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -170,21 +170,21 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } - entry = rtllib_frag_cache_find(ieee, seq, -1, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, -1, tid, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -198,8 +198,6 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, return 0; } - - /* rtllib_rx_frame_mgtmt * * Responsible for handling management control frames @@ -217,7 +215,7 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_hdr_3addr * hdr = (struct rtllib_hdr_3addr *)skb->data; rx_stats->len = skb->len; - rtllib_rx_mgt(ieee,skb,rx_stats); + rtllib_rx_mgt(ieee, skb, rx_stats); if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) { dev_kfree_skb_any(skb); return 0; @@ -231,11 +229,13 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +static unsigned char rfc1042_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 +}; /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; +static unsigned char bridge_tunnel_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 +}; /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by rtllib_rx_frame_decrypt */ @@ -280,8 +280,8 @@ static int rtllib_is_eapol_frame(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, - struct rtllib_crypt_data *crypt) +rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; int res, hdrlen; @@ -289,9 +289,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -322,7 +321,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, +rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, int keyidx, struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; @@ -330,9 +329,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -343,7 +341,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); - res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv,ieee); + res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv, ieee); atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" @@ -371,18 +369,18 @@ static int is_duplicate_packet(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos*)header; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)header; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } switch (ieee->iw_mode) { @@ -427,10 +425,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee, if ((*last_seq == seq) && time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { - if (*last_frag == frag){ + if (*last_frag == frag) goto drop; - - } if (*last_frag + 1 != frag) /* out-of-order fragment */ goto drop; @@ -445,28 +441,18 @@ drop: return 1; } -bool -AddReorderEntry( - struct rx_ts_record *pTS, - struct rx_reorder_entry *pReorderEntry - ) + +bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; - while(pList->next != &pTS->RxPendingPktList) - { - if ( SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + while (pList->next != &pTS->RxPendingPktList) { + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) pList = pList->next; - } - else if ( SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) return false; - } else - { break; - } } pReorderEntry->List.next = pList->next; pReorderEntry->List.next->prev = &pReorderEntry->List; @@ -476,24 +462,24 @@ AddReorderEntry( return true; } -void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index) +void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index) { struct net_device_stats *stats = &ieee->stats; - u8 i = 0 , j=0; + u8 i = 0 , j = 0; u16 ethertype; for (j = 0; j < index; j++) { - struct rtllib_rxb* prxb = prxbIndicateArray[j]; - for (i = 0; inr_subframes; i++) { + struct rtllib_rxb *prxb = prxbIndicateArray[j]; + for (i = 0; i < prxb->nr_subframes; i++) { struct sk_buff *sub_skb = prxb->subframes[i]; /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation + * and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); @@ -506,7 +492,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); } - /* Indicat the packets to upper layer */ + /* Indicat the packets to upper layer */ if (sub_skb) { stats->rx_packets++; stats->rx_bytes += sub_skb->len; @@ -526,24 +512,21 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx } } -void -rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) +void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { struct rx_reorder_entry *pRxReorderEntry; - struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; - u8 RfdCnt = 0; - + struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; + u8 RfdCnt = 0; del_timer_sync(&pTS->RxPktPendingTimer); - while(!list_empty(&pTS->RxPendingPktList)) - { - if (RfdCnt >= REORDER_WIN_SIZE){ - printk("-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); + while (!list_empty(&pTS->RxPendingPktList)) { + if (RfdCnt >= REORDER_WIN_SIZE) { + printk(KERN_INFO "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); break; } - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); RfdArray[RfdCnt] = pRxReorderEntry->prxb; @@ -556,41 +539,38 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS pTS->RxIndicateSeq = 0xffff; } - -void RxReorderIndicatePacket( struct rtllib_device *ieee, - struct rtllib_rxb* prxb, - struct rx_ts_record *pTS, - u16 SeqNum) +void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; - struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; - u8 WinSize = pHTInfo->RxReorderWinSize; - u16 WinEnd = 0; - u8 index = 0; - bool bMatchWinStart = false, bPktInBuf = false; + struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; + u8 WinSize = pHTInfo->RxReorderWinSize; + u16 WinEnd = 0; + u8 index = 0; + bool bMatchWinStart = false, bPktInBuf = false; unsigned long flags; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq" + " is %d, WinSize is %d\n", __func__, SeqNum, + pTS->RxIndicateSeq, WinSize); spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; + WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096; /* Rx Reorder initialize condition.*/ - if (pTS->RxIndicateSeq == 0xffff) { + if (pTS->RxIndicateSeq == 0xffff) pTS->RxIndicateSeq = SeqNum; - } /* Drop out the packet which SeqNum is smaller than WinStart */ if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); pHTInfo->RxReorderDropCounter++; { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -607,33 +587,38 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; bMatchWinStart = true; } else if (SN_LESS(WinEnd, SeqNum)) { - if (SeqNum >= (WinSize - 1)) { - pTS->RxIndicateSeq = SeqNum + 1 -WinSize; - } else { - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; - } - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + if (SeqNum >= (WinSize - 1)) + pTS->RxIndicateSeq = SeqNum + 1 - WinSize; + else + pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d," + " NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); } /* * Indication process. - * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets - * with the SeqNum smaller than latest WinStart and struct buffer other packets. + * After Packet dropping and Sliding Window shifting as above, we can + * now just indicate the packets with the SeqNum smaller than latest + * WinStart and struct buffer other packets. */ /* For Rx Reorder condition: * 1. All packets with SeqNum smaller than WinStart => Indicate - * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. + * 2. All packets with SeqNum larger than or equal to + * WinStart => Buffer it. */ if (bMatchWinStart) { /* Current packet is going to be indicated.*/ - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! " + "IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); prxbIndicateArray[0] = prxb; index = 1; } else { /* Current packet is going to be inserted into pending list.*/ if (!list_empty(&ieee->RxReorder_Unused_List)) { - pReorderEntry = (struct rx_reorder_entry *)list_entry(ieee->RxReorder_Unused_List.next,struct rx_reorder_entry,List); + pReorderEntry = (struct rx_reorder_entry *) + list_entry(ieee->RxReorder_Unused_List.next, + struct rx_reorder_entry, List); list_del_init(&pReorderEntry->List); /* Make a reorder entry and insert into a the packet list.*/ @@ -641,34 +626,40 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pReorderEntry->prxb = prxb; if (!AddReorderEntry(pTS, pReorderEntry)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __func__, pTS->RxIndicateSeq, SeqNum); - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); - { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, + "%s(): Duplicate packet is " + "dropped!! IndicateSeq: %d, " + "NewSeq: %d\n", + __func__, pTS->RxIndicateSeq, + SeqNum); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } } else { RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + "Pkt insert into struct buffer!! " + "IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } - } - else { + } else { /* - * Packets are dropped if there is not enough reorder entries. - * This part shall be modified!! We can just indicate all the - * packets in struct buffer and get reorder entries. + * Packets are dropped if there are not enough reorder + * entries. This part should be modified!! We can just + * indicate all the packets in struct buffer and get + * reorder entries. */ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " There is no reorder entry!! Packet is " + "dropped!!\n"); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -676,16 +667,17 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, } /* Check if there is any packet need indicate.*/ - while(!list_empty(&pTS->RxPendingPktList)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); + while (!list_empty(&pTS->RxPendingPktList)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__); - pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - { + pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicate" + "Packet(): Buffer overflow!!\n"); bPktInBuf = true; break; } @@ -696,74 +688,76 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; prxbIndicateArray[index] = pReorderEntry->prxb; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pReorderEntry->SeqNum); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum" + " %d!\n", __func__, pReorderEntry->SeqNum); index++; - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); } else { bPktInBuf = true; break; } } - /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ - if (index>0) { - if (timer_pending(&pTS->RxPktPendingTimer)){ + /* Handling pending timer. Set this timer to prevent from long time + * Rx buffering.*/ + if (index > 0) { + if (timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); - } pTS->RxTimeoutIndicateSeq = 0xffff; - if (index>REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, prxbIndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); + if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n", + __func__); pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; - mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime)); + mod_timer(&pTS->RxPktPendingTimer, jiffies + + MSECS(pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb,u8* src,u8* dst) +u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { - struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr* )skb->data; + struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 LLCOffset= sizeof(struct rtllib_hdr_3addr); + u16 LLCOffset = sizeof(struct rtllib_hdr_3addr); u16 ChkLength; bool bIsAggregateFrame = false; u16 nSubframe_Length; u8 nPadding_Length = 0; - u16 SeqNum=0; + u16 SeqNum = 0; struct sk_buff *sub_skb; - u8 *data_ptr; + u8 *data_ptr; /* just for debug purpose */ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); - if ((RTLLIB_QOS_HAS_SEQ(fc))&&\ - (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { + if ((RTLLIB_QOS_HAS_SEQ(fc)) && + (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) bIsAggregateFrame = true; - } - if (RTLLIB_QOS_HAS_SEQ(fc)) { + if (RTLLIB_QOS_HAS_SEQ(fc)) LLCOffset += 2; - } - if (rx_stats->bContainHTC) { + if (rx_stats->bContainHTC) LLCOffset += sHTCLng; - } - ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ + ChkLength = LLCOffset; - if ( skb->len <= ChkLength ) { + if (skb->len <= ChkLength) return 0; - } skb_pull(skb, LLCOffset); ieee->bIsAggregateFrame = bIsAggregateFrame; @@ -787,25 +781,31 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, rxb->subframes[0] = sub_skb; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); rxb->subframes[0]->dev = ieee->dev; return 1; } else { rxb->nr_subframes = 0; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); - while(skb->len > ETHERNET_HEADER_SIZE) { + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); + while (skb->len > ETHERNET_HEADER_SIZE) { /* Offset 12 denote 2 mac address */ - nSubframe_Length = *((u16*)(skb->data + 12)); - nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8); + nSubframe_Length = *((u16 *)(skb->data + 12)); + nSubframe_Length = (nSubframe_Length >> 8) + + (nSubframe_Length << 8); - if (skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { - printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ - __func__,rxb->nr_subframes); - printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length); - printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); - printk("The Packet SeqNum is %d\n",SeqNum); + if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + printk(KERN_INFO "%s: A-MSDU parse error!! " + "pRfd->nTotalSubframe : %d\n",\ + __func__, rxb->nr_subframes); + printk(KERN_INFO "%s: A-MSDU parse error!! " + "Subframe Length: %d\n", __func__, + nSubframe_Length); + printk(KERN_INFO "nRemain_Length is %d and " + "nSubframe_Length is : %d\n", skb->len, + nSubframe_Length); + printk(KERN_INFO "The Packet SeqNum is %d\n", SeqNum); return 0; } @@ -824,27 +824,27 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, sub_skb = dev_alloc_skb(nSubframe_Length + 12); skb_reserve(sub_skb, 12); data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); - memcpy(data_ptr,skb->data,nSubframe_Length); + memcpy(data_ptr, skb->data, nSubframe_Length); sub_skb->dev = ieee->dev; rxb->subframes[rxb->nr_subframes++] = sub_skb; if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { - RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + RTLLIB_DEBUG_RX("ParseSubframe(): Too many " + "Subframes! Packets dropped!\n"); break; } - skb_pull(skb,nSubframe_Length); + skb_pull(skb, nSubframe_Length); if (skb->len != 0) { - nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4); - if (nPadding_Length == 4) { + nPadding_Length = 4 - ((nSubframe_Length + + ETHERNET_HEADER_SIZE) % 4); + if (nPadding_Length == 4) nPadding_Length = 0; - } - if (skb->len < nPadding_Length) { + if (skb->len < nPadding_Length) return 0; - } - skb_pull(skb,nPadding_Length); + skb_pull(skb, nPadding_Length); } } @@ -863,7 +863,7 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(fc); if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: find HTCControl!\n", __func__); + printk(KERN_INFO "%s: find HTCControl!\n", __func__); hdrlen += 4; rx_stats->bContainHTC = 1; } @@ -874,7 +874,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u8 multicast) +int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, + u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -886,19 +887,18 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || + if ((ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { - if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ - if (is_duplicate_packet(ieee, hdr)){ + if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) { + if (is_duplicate_packet(ieee, hdr)) return -1; - } } } else { struct rx_ts_record *pRxTS = NULL; if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2, - (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { + (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) { if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { return -1; @@ -907,41 +907,47 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); } } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip" + " the check!!\n", __func__); return -1; } } return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, u8 *bssid) + +void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, + u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { - case RTLLIB_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); - break; - case RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); - break; - case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); - break; - case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); - break; + case RTLLIB_FCTL_FROMDS: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr3, ETH_ALEN); + memcpy(bssid, hdr->addr2, ETH_ALEN); + break; + case RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr1, ETH_ALEN); + break; + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr4, ETH_ALEN); + memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + break; + case 0: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr3, ETH_ALEN); + break; } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, u8 *bssid, u8 *addr2) + +int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, + u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -951,14 +957,14 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Filter frames from different BSS */ if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) - && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) - && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { + && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) + && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { return -1; } /* Filter packets sent by an STA that will be forwarded by AP */ - if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { + if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn && + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame) { if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { @@ -968,13 +974,12 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Nullfunc frames may have PS-bit set, so they must be passed to * hostap_handle_sta_rx() before being dropped here. */ - if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn){ + if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) { if (stype != RTLLIB_STYPE_DATA && stype != RTLLIB_STYPE_DATA_CFACK && stype != RTLLIB_STYPE_DATA_CFPOLL && - stype != RTLLIB_STYPE_DATA_CFACKPOLL&& - stype != RTLLIB_STYPE_QOS_DATA - ) { + stype != RTLLIB_STYPE_DATA_CFACKPOLL && + stype != RTLLIB_STYPE_QOS_DATA) { if (stype != RTLLIB_STYPE_NULLFUNC) RTLLIB_DEBUG_DROP( "RX: dropped data frame " @@ -992,18 +997,15 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* {broad,multi}cast packets to our BSS go through */ if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) { - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) { + if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) return -1; - } } } return 0; } -int rtllib_rx_get_crypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_crypt_data **crypt, - size_t hdrlen) + +int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -1035,12 +1037,10 @@ int rtllib_rx_get_crypt( return 0; } -int rtllib_rx_decrypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_crypt_data *crypt, - size_t hdrlen) + +int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_crypt_data *crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr; int keyidx = 0; @@ -1052,15 +1052,14 @@ int rtllib_rx_decrypt( sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ((!rx_stats->Decrypted)){ + if ((!rx_stats->Decrypted)) ieee->need_sw_enc = 1; - }else{ + else ieee->need_sw_enc = 0; - } - if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { - printk("%s: decrypt frame error\n", __func__); + keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt); + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) { + printk(KERN_INFO "%s: decrypt frame error\n", __func__); return -1; } @@ -1120,9 +1119,8 @@ int rtllib_rx_decrypt( /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) - { - printk("%s: ==>decrypt msdu error\n", __func__); + rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) { + printk(KERN_INFO "%s: ==>decrypt msdu error\n", __func__); return -1; } @@ -1164,21 +1162,20 @@ int rtllib_rx_decrypt( return -1; } - if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) printk(KERN_WARNING "RX: IEEE802.1X EAPOL frame!\n"); - } return 0; } + void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { - if (unicast){ + if (unicast) { - if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) - { - if ( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { + if ((ieee->state == RTLLIB_LINKED)) { + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { if (ieee->LeisurePSLeave) ieee->LeisurePSLeave(ieee->dev); } @@ -1186,10 +1183,10 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub } ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy( - struct rtllib_device *ieee, + +void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb* rxb, + struct rtllib_rxb *rxb, u8 *dst, u8 *src) { @@ -1197,21 +1194,21 @@ void rtllib_rx_indicate_pkt_legacy( u16 ethertype; int i = 0; - if (rxb == NULL){ - printk("%s: rxb is NULL!!\n", __func__); + if (rxb == NULL) { + printk(KERN_INFO "%s: rxb is NULL!!\n", __func__); return ; } - for (i = 0; inr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) { struct sk_buff *sub_skb = rxb->subframes[i]; if (sub_skb) { /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and * replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); @@ -1229,9 +1226,8 @@ void rtllib_rx_indicate_pkt_legacy( ieee->stats.rx_packets++; ieee->stats.rx_bytes += sub_skb->len; - if (is_multicast_ether_addr(dst)) { + if (is_multicast_ether_addr(dst)) ieee->stats.multicast++; - } /* Indicat the packets to upper layer */ memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); @@ -1246,13 +1242,14 @@ void rtllib_rx_indicate_pkt_legacy( kfree(rxb); rxb = NULL; } + int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; struct rtllib_crypt_data *crypt = NULL; - struct rtllib_rxb* rxb = NULL; + struct rtllib_rxb *rxb = NULL; struct rx_ts_record *pTS = NULL; u16 fc, sc, SeqNum = 0; u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; @@ -1279,8 +1276,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /*Filter pkt has too small length */ hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); goto rx_dropped; } @@ -1290,9 +1287,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, goto rx_dropped; /* Filter CTRL Frame */ - if (type == RTLLIB_FTYPE_CTL) { + if (type == RTLLIB_FTYPE_CTL) goto rx_dropped; - } /* Filter MGNT Frame */ if (type == RTLLIB_FTYPE_MGMT) { @@ -1307,7 +1303,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Filter WAPI DATA Frame */ /* Update statstics for AP roaming */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { ieee->LinkDetectInfo.NumRecvDataInPeriod++; ieee->LinkDetectInfo.NumRxOkInPeriod++; } @@ -1321,9 +1317,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, if (ret < 0) goto rx_dropped; - if (skb->len == hdrlen){ + if (skb->len == hdrlen) goto rx_dropped; - } /* Send pspoll based on moredata */ if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) @@ -1352,32 +1347,29 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, hdr = (struct rtllib_hdr_4addr *) skb->data; if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1) - && (!bToOtherSTA)) - { + && (!bToOtherSTA)) { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(struct ts_common_info **) &pTS,hdr->addr2,TID,RX_DIR,true); - if (TID !=0 && TID !=3){ + GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true); + if (TID != 0 && TID != 3) ieee->bis_any_nonbepkts = true; - } } /* Parse rx data frame (For AMSDU) */ /* skb: hdr + (possible reassembled) full plaintext payload */ payload = skb->data + hdrlen; - rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); - if (rxb == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); + rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC); + if (rxb == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, + "%s(): kmalloc rxb error\n", __func__); goto rx_dropped; } /* to parse amsdu packets */ /* qos data packets & reserved bit is 1 */ - if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { + if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) { /* only to free rxb, and not submit the packets to upper layer */ - for (i =0; i < rxb->nr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) dev_kfree_skb(rxb->subframes[i]); - } kfree(rxb); rxb = NULL; goto rx_dropped; @@ -1386,7 +1378,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Update WAPI PN */ /* Check if leave LPS */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { if (ieee->bIsAggregateFrame) nr_subframes = rxb->nr_subframes; else @@ -1397,11 +1389,10 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } /* Indicate packets to upper layer or Rx Reorder */ - if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA){ + if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA) rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); - }else{ + else RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); - } dev_kfree_skb(skb); @@ -1409,8 +1400,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 1; rx_dropped: - if (rxb != NULL) - { + if (rxb != NULL) { kfree(rxb); rxb = NULL; } @@ -1427,6 +1417,7 @@ int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, { return 0; } + int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { @@ -1434,14 +1425,14 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, u16 fc = le16_to_cpu(hdr->frame_ctl); size_t hdrlen = rtllib_get_hdrlen(fc); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); return 0; } if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: Find HTCControl!\n", __func__); + printk(KERN_INFO "%s: Find HTCControl!\n", __func__); hdrlen += 4; } @@ -1466,12 +1457,12 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, { int ret = 0; - if ((NULL==ieee) || (NULL==skb) || (NULL==rx_stats)){ + if ((NULL == ieee) || (NULL == skb) || (NULL == rx_stats)) { printk(KERN_INFO "%s: Input parameters NULL!\n", __func__); goto rx_dropped; } if (skb->len < 10) { - printk(KERN_INFO "%s: SKB length < 10 \n", __func__); + printk(KERN_INFO "%s: SKB length < 10\n", __func__); goto rx_dropped; } @@ -1509,19 +1500,19 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; * the right values */ static int rtllib_verify_qos_info(struct rtllib_qos_information_element - *info_element, int sub_type) + *info_element, int sub_type) { - if (info_element->qui_subtype != sub_type) - return -1; - if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) - return -1; - if (info_element->qui_type != QOS_OUI_TYPE) - return -1; - if (info_element->version != QOS_VERSION_1) - return -1; + if (info_element->qui_subtype != sub_type) + return -1; + if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) + return -1; + if (info_element->qui_type != QOS_OUI_TYPE) + return -1; + if (info_element->version != QOS_VERSION_1) + return -1; - return 0; + return 0; } @@ -1529,56 +1520,56 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element * Parse a QoS parameter element */ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info - *element_param, struct rtllib_info_element - *info_element) + *element_param, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; - if ((info_element == NULL) || (element_param == NULL)) - return -1; + if ((info_element == NULL) || (element_param == NULL)) + return -1; - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { + memcpy(element_param->info_element.qui, info_element->data, + info_element->len); + element_param->info_element.elementID = info_element->id; + element_param->info_element.length = info_element->len; + } else + ret = -1; + if (ret == 0) + ret = rtllib_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); + return ret; } /* * Parse a QoS information element */ static int rtllib_read_qos_info_element(struct - rtllib_qos_information_element - *element_info, struct rtllib_info_element - *info_element) + rtllib_qos_information_element + *element_info, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_information_element) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_information_element) - 2; - if (element_info == NULL) - return -1; - if (info_element == NULL) - return -1; + if (element_info == NULL) + return -1; + if (info_element == NULL) + return -1; - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; + if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + memcpy(element_info->qui, info_element->data, + info_element->len); + element_info->elementID = info_element->id; + element_info->length = info_element->len; + } else + ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + if (ret == 0) + ret = rtllib_verify_qos_info(element_info, + QOS_OUI_INFO_SUB_TYPE); + return ret; } @@ -1588,16 +1579,16 @@ static int rtllib_read_qos_info_element(struct static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm, struct rtllib_qos_data *qos_data) { - struct rtllib_qos_ac_parameter *ac_params; + struct rtllib_qos_ac_parameter *ac_params; struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); - int rc = 0; - int i; + int rc = 0; + int i; u8 aci; u8 acm; qos_data->wmm_acm = 0; - for (i = 0; i < QOS_QUEUE_NUM; i++) { - ac_params = &(param_elm->ac_params_record[i]); + for (i = 0; i < QOS_QUEUE_NUM; i++) { + ac_params = &(param_elm->ac_params_record[i]); aci = (ac_params->aci_aifsn & 0x60) >> 5; acm = (ac_params->aci_aifsn & 0x10) >> 4; @@ -1605,43 +1596,43 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info if (aci >= QOS_QUEUE_NUM) continue; switch (aci) { - case 1: - /* BIT(0) | BIT(3) */ - if (acm) - qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); - break; - case 2: - /* BIT(4) | BIT(5) */ - if (acm) - qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); - break; - case 3: - /* BIT(6) | BIT(7) */ - if (acm) - qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); - break; - case 0: - default: - /* BIT(1) | BIT(2) */ - if (acm) - qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); - break; + case 1: + /* BIT(0) | BIT(3) */ + if (acm) + qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); + break; + case 2: + /* BIT(4) | BIT(5) */ + if (acm) + qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); + break; + case 3: + /* BIT(6) | BIT(7) */ + if (acm) + qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); + break; + case 0: + default: + /* BIT(1) | BIT(2) */ + if (acm) + qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); + break; } - qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; + qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; + qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci]; - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; + qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; + qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; - qos_param->flag[aci] = - (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); - } - return rc; + qos_param->flag[aci] = + (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; + qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); + } + return rc; } /* @@ -1650,96 +1641,94 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info * which type to read */ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element - *info_element, - struct rtllib_network *network) + *info_element, + struct rtllib_network *network) { - int rc = 0; - struct rtllib_qos_information_element qos_info_element; + int rc = 0; + struct rtllib_qos_information_element qos_info_element; - rc = rtllib_read_qos_info_element(&qos_info_element, info_element); + rc = rtllib_read_qos_info_element(&qos_info_element, info_element); - if (rc == 0) { - network->qos_data.param_count = qos_info_element.ac_info & 0x0F; - network->flags |= NETWORK_HAS_QOS_INFORMATION; - } else { - struct rtllib_qos_parameter_info param_element; + if (rc == 0) { + network->qos_data.param_count = qos_info_element.ac_info & 0x0F; + network->flags |= NETWORK_HAS_QOS_INFORMATION; + } else { + struct rtllib_qos_parameter_info param_element; - rc = rtllib_read_qos_param_element(¶m_element, - info_element); - if (rc == 0) { - rtllib_qos_convert_ac_to_parameters(¶m_element, - &(network->qos_data)); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } - } + rc = rtllib_read_qos_param_element(¶m_element, + info_element); + if (rc == 0) { + rtllib_qos_convert_ac_to_parameters(¶m_element, + &(network->qos_data)); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; + } + } - if (rc == 0) { - RTLLIB_DEBUG_QOS("QoS is supported\n"); - network->qos_data.supported = 1; - } - return rc; + if (rc == 0) { + RTLLIB_DEBUG_QOS("QoS is supported\n"); + network->qos_data.supported = 1; + } + return rc; } #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x static const char *get_info_element_string(u16 id) { - switch (id) { - MFIE_STRING(SSID); - MFIE_STRING(RATES); - MFIE_STRING(FH_SET); - MFIE_STRING(DS_SET); - MFIE_STRING(CF_SET); - MFIE_STRING(TIM); - MFIE_STRING(IBSS_SET); - MFIE_STRING(COUNTRY); - MFIE_STRING(HOP_PARAMS); - MFIE_STRING(HOP_TABLE); - MFIE_STRING(REQUEST); - MFIE_STRING(CHALLENGE); - MFIE_STRING(POWER_CONSTRAINT); - MFIE_STRING(POWER_CAPABILITY); - MFIE_STRING(TPC_REQUEST); - MFIE_STRING(TPC_REPORT); - MFIE_STRING(SUPP_CHANNELS); - MFIE_STRING(CSA); - MFIE_STRING(MEASURE_REQUEST); - MFIE_STRING(MEASURE_REPORT); - MFIE_STRING(QUIET); - MFIE_STRING(IBSS_DFS); - MFIE_STRING(RSN); - MFIE_STRING(RATES_EX); - MFIE_STRING(GENERIC); - MFIE_STRING(QOS_PARAMETER); - default: - return "UNKNOWN"; - } + switch (id) { + MFIE_STRING(SSID); + MFIE_STRING(RATES); + MFIE_STRING(FH_SET); + MFIE_STRING(DS_SET); + MFIE_STRING(CF_SET); + MFIE_STRING(TIM); + MFIE_STRING(IBSS_SET); + MFIE_STRING(COUNTRY); + MFIE_STRING(HOP_PARAMS); + MFIE_STRING(HOP_TABLE); + MFIE_STRING(REQUEST); + MFIE_STRING(CHALLENGE); + MFIE_STRING(POWER_CONSTRAINT); + MFIE_STRING(POWER_CAPABILITY); + MFIE_STRING(TPC_REQUEST); + MFIE_STRING(TPC_REPORT); + MFIE_STRING(SUPP_CHANNELS); + MFIE_STRING(CSA); + MFIE_STRING(MEASURE_REQUEST); + MFIE_STRING(MEASURE_REPORT); + MFIE_STRING(QUIET); + MFIE_STRING(IBSS_DFS); + MFIE_STRING(RSN); + MFIE_STRING(RATES_EX); + MFIE_STRING(GENERIC); + MFIE_STRING(QOS_PARAMETER); + default: + return "UNKNOWN"; + } } static inline void rtllib_extract_country_ie( struct rtllib_device *ieee, struct rtllib_info_element *info_element, struct rtllib_network *network, - u8 * addr2) + u8 *addr2) { if (IS_DOT11D_ENABLE(ieee)) { - if (info_element->len!= 0) { + if (info_element->len != 0) { memcpy(network->CountryIeBuf, info_element->data, info_element->len); network->CountryIeLen = info_element->len; - if (!IS_COUNTRY_IE_VALID(ieee)) - { - if ((rtllib_act_scanning(ieee,false) == true) && (ieee->FirstIe_InScan == 1)) - printk("Received beacon ContryIE, SSID: <%s>\n",network->ssid); + if (!IS_COUNTRY_IE_VALID(ieee)) { + if ((rtllib_act_scanning(ieee, false) == true) && (ieee->FirstIe_InScan == 1)) + printk(KERN_INFO "Received beacon ContryIE, SSID: <%s>\n", network->ssid); Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); } } - if (IS_EQUAL_CIE_SRC(ieee, addr2)) { + if (IS_EQUAL_CIE_SRC(ieee, addr2)) UPDATE_CIE_WATCHDOG(ieee); - } } } @@ -1752,9 +1741,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, { u8 i; short offset; - u16 tmp_htcap_len=0; - u16 tmp_htinfo_len=0; - u16 ht_realtek_agg_len=0; + u16 tmp_htcap_len = 0; + u16 tmp_htinfo_len = 0; + u16 ht_realtek_agg_len = 0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; char rates_str[64]; char *p; @@ -1864,28 +1853,28 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->tim.tim_count = info_element->data[0]; network->tim.tim_period = info_element->data[1]; - network->dtim_period = info_element->data[1]; - if (ieee->state != RTLLIB_LINKED) - break; + network->dtim_period = info_element->data[1]; + if (ieee->state != RTLLIB_LINKED) + break; network->last_dtim_sta_time = jiffies; - network->dtim_data = RTLLIB_DTIM_VALID; + network->dtim_data = RTLLIB_DTIM_VALID; - if (info_element->data[2] & 1) - network->dtim_data |= RTLLIB_DTIM_MBCAST; + if (info_element->data[2] & 1) + network->dtim_data |= RTLLIB_DTIM_MBCAST; - offset = (info_element->data[2] >> 1)*2; + offset = (info_element->data[2] >> 1)*2; - if (ieee->assoc_id < 8*offset || - ieee->assoc_id > 8*(offset + info_element->len -3)) + if (ieee->assoc_id < 8*offset || + ieee->assoc_id > 8*(offset + info_element->len - 3)) + break; - break; - - offset = (ieee->assoc_id / 8) - offset; - if (info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) - network->dtim_data |= RTLLIB_DTIM_UCAST; + offset = (ieee->assoc_id / 8) - offset; + if (info_element->data[3 + offset] & + (1 << (ieee->assoc_id % 8))) + network->dtim_data |= RTLLIB_DTIM_UCAST; network->listen_interval = network->dtim_period; break; @@ -1923,13 +1912,13 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->wpa_ie_len); break; } - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) - network->Turbo_Enable = 1; + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) + network->Turbo_Enable = 1; if (tmp_htcap_len == 0) { if (info_element->len >= 4 && @@ -1938,193 +1927,160 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, info_element->data[2] == 0x4c && info_element->data[3] == 0x033) { - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); } } - if (tmp_htcap_len != 0){ + if (tmp_htcap_len != 0) { network->bssht.bdSupportHT = true; network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - }else{ + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; } } - if (tmp_htinfo_len == 0){ + if (tmp_htinfo_len == 0) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034){ - - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - if (tmp_htinfo_len){ - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); - } - + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034) { + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + if (tmp_htinfo_len) { + network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); } + } + } } - if (ieee->aggregation){ - if (network->bssht.bdSupportHT){ + if (ieee->aggregation) { + if (network->bssht.bdSupportHT) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02){ - - ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN); - memcpy(ht_realtek_agg_buf,info_element->data,info_element->len); - + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02) { + ht_realtek_agg_len = min(info_element->len, (u8)MAX_IE_LEN); + memcpy(ht_realtek_agg_buf, info_element->data, info_element->len); } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { network->realtek_cap_exit = true; network->bssht.bdRT2RTAggregation = true; if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; + network->bssht.bdRT2RTLongSlotTime = true; - if ((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) - { + if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; - } } } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; } } - { - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x05 && - info_element->data[2] == 0xb5) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf7) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x10 && - info_element->data[2] == 0x18)){ - - network->broadcom_cap_exist = true; - - } + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x05 && + info_element->data[2] == 0xb5) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf7) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x10 && + info_element->data[2] == 0x18)) { + network->broadcom_cap_exist = true; } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0c && - info_element->data[2] == 0x43) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0c && + info_element->data[2] == 0x43) network->ralink_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x03 && - info_element->data[2] == 0x7f) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x13 && - info_element->data[2] == 0x74)) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x03 && + info_element->data[2] == 0x7f) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x13 && + info_element->data[2] == 0x74)) network->atheros_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0x43) ) - { - network->marvell_cap_exist = true; - } + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0x43)) + network->marvell_cap_exist = true; if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96) network->cisco_cap_exist = true; - } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf5) network->airgo_cap_exist = true; - } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x01) - { - if (info_element->len == 6) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) { + if (info_element->len == 6) { memcpy(network->CcxRmState, &info_element[4], 2); if (network->CcxRmState[0] != 0) - { network->bCcxRmEnable = true; - } else network->bCcxRmEnable = false; network->MBssidMask = network->CcxRmState[1] & 0x07; - if (network->MBssidMask != 0) - { + if (network->MBssidMask != 0) { network->bMBssidValid = true; network->MBssidMask = 0xff << (network->MBssidMask); memcpy(network->MBssid, network->bssid, ETH_ALEN); network->MBssid[5] &= network->MBssidMask; - } - else - { + } else { network->bMBssidValid = false; } - } - else - { + } else { network->bCcxRmEnable = false; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x03) - { - if (info_element->len == 5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x03) { + if (info_element->len == 5) { network->bWithCcxVerNum = true; network->BssCcxVerNumber = info_element->data[4]; - } - else - { + } else { network->bWithCcxVerNum = false; network->BssCcxVerNumber = 0; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x04) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x04) { RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", info_element->len); network->wzc_ie_len = min(info_element->len+2, @@ -2146,22 +2102,26 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_CAP: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", info_element->len); - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, + info_element->data, + network->bssht.bdHTCapLen); network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + network->bssht.bdHT1R = ((((struct ht_capab_ele *) + network->bssht.bdHTCapBuf))->MCS[1]) == 0; - network->bssht.bdBandWidth = (enum ht_channel_width)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); - } - else{ + network->bssht.bdBandWidth = (enum ht_channel_width) + (((struct ht_capab_ele *) + (network->bssht.bdHTCapBuf))->ChlWidth); + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; - network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20 ; + network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20; } break; @@ -2169,34 +2129,33 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_INFO: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", info_element->len); - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len){ + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len) { network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); + network->bssht.bdHTInfoLen = tmp_htinfo_len > + sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : + tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, + info_element->data, + network->bssht.bdHTInfoLen); } break; case MFIE_TYPE_AIRONET: RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", info_element->len); - if (info_element->len >IE_CISCO_FLAG_POSITION) - { + if (info_element->len > IE_CISCO_FLAG_POSITION) { network->bWithAironetIE = true; - if ( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || - (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) - { + if ((info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_MIC) || + (info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_PK)) network->bCkipSupported = true; - } else - { network->bCkipSupported = false; - } - } - else - { + } else { network->bWithAironetIE = false; network->bCkipSupported = false; } @@ -2209,7 +2168,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_COUNTRY: RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", info_element->len); - rtllib_extract_country_ie(ieee, info_element, network, network->bssid); + rtllib_extract_country_ie(ieee, info_element, network, + network->bssid); break; /* TODO */ default: @@ -2227,70 +2187,43 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } if (!network->atheros_cap_exist && !network->broadcom_cap_exist && - !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation) - { + !network->cisco_cap_exist && !network->ralink_cap_exist && + !network->bssht.bdRT2RTAggregation) network->unknown_cap_exist = true; - } else - { network->unknown_cap_exist = false; - } return 0; } -static inline u8 rtllib_SignalStrengthTranslate( - u8 CurrSS - ) +static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) { u8 RetSS; if (CurrSS >= 71 && CurrSS <= 100) - { RetSS = 90 + ((CurrSS - 70) / 3); - } else if (CurrSS >= 41 && CurrSS <= 70) - { RetSS = 78 + ((CurrSS - 40) / 3); - } else if (CurrSS >= 31 && CurrSS <= 40) - { RetSS = 66 + (CurrSS - 30); - } else if (CurrSS >= 21 && CurrSS <= 30) - { RetSS = 54 + (CurrSS - 20); - } else if (CurrSS >= 5 && CurrSS <= 20) - { RetSS = 42 + (((CurrSS - 5) * 2) / 3); - } else if (CurrSS == 4) - { RetSS = 36; - } else if (CurrSS == 3) - { RetSS = 27; - } else if (CurrSS == 2) - { RetSS = 18; - } else if (CurrSS == 1) - { RetSS = 9; - } else - { RetSS = CurrSS; - } - - return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index ) +long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; @@ -2308,10 +2241,10 @@ static inline int rtllib_network_init( { /* - network->qos_data.active = 0; - network->qos_data.supported = 0; - network->qos_data.param_count = 0; - network->qos_data.old_param_count = 0; + network->qos_data.active = 0; + network->qos_data.supported = 0; + network->qos_data.param_count = 0; + network->qos_data.old_param_count = 0; */ memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data)); @@ -2332,9 +2265,9 @@ static inline int rtllib_network_init( network->flags = 0; network->atim_window = 0; network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? - 0x3 : 0x0; + 0x3 : 0x0; network->berp_info_valid = false; - network->broadcom_cap_exist = false; + network->broadcom_cap_exist = false; network->ralink_cap_exist = false; network->atheros_cap_exist = false; network->cisco_cap_exist = false; @@ -2358,12 +2291,12 @@ static inline int rtllib_network_init( network->rsn_ie_len = 0; network->wzc_ie_len = 0; - if (rtllib_parse_info_param(ieee, + if (rtllib_parse_info_param(ieee, beacon->info_element, (stats->len - sizeof(*beacon)), network, stats)) - return 1; + return 1; network->mode = 0; if (stats->freq == RTLLIB_52GHZ_BAND) @@ -2384,7 +2317,7 @@ static inline int rtllib_network_init( return 1; } - if (network->bssht.bdSupportHT){ + if (network->bssht.bdSupportHT) { if (network->mode == IEEE_A) network->mode = IEEE_N_5G; else if (network->mode & (IEEE_G | IEEE_B)) @@ -2393,7 +2326,7 @@ static inline int rtllib_network_init( if (rtllib_is_empty_essid(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; stats->signal = 30 + (stats->SignalStrength * 70) / 100; - stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) -25; + stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) - 25; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -2407,11 +2340,11 @@ static inline int is_same_network(struct rtllib_network *src, * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ - return - (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && + return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && - (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (!ssidbroad)) && + (!memcmp(src->ssid, dst->ssid, src->ssid_len) || + (!ssidbroad)) && ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && ((src->capability & WLAN_CAPABILITY_ESS) == @@ -2438,14 +2371,12 @@ static inline void update_network(struct rtllib_network *dst, dst->rates_len = src->rates_len; memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); dst->rates_ex_len = src->rates_ex_len; - if (src->ssid_len > 0) - { - if (dst->ssid_len == 0) - { + if (src->ssid_len > 0) { + if (dst->ssid_len == 0) { memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid)); dst->hidden_ssid_len = src->ssid_len; memcpy(dst->hidden_ssid, src->ssid, src->ssid_len); - }else{ + } else { memset(dst->ssid, 0, dst->ssid_len); dst->ssid_len = src->ssid_len; memcpy(dst->ssid, src->ssid, src->ssid_len); @@ -2455,8 +2386,7 @@ static inline void update_network(struct rtllib_network *dst, dst->flags = src->flags; dst->time_stamp[0] = src->time_stamp[0]; dst->time_stamp[1] = src->time_stamp[1]; - if (src->flags & NETWORK_HAS_ERP_VALUE) - { + if (src->flags & NETWORK_HAS_ERP_VALUE) { dst->erp_value = src->erp_value; dst->berp_info_valid = src->berp_info_valid = true; } @@ -2468,12 +2398,14 @@ static inline void update_network(struct rtllib_network *dst, dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); - dst->bssht.bdSupportHT = src->bssht.bdSupportHT; + dst->bssht.bdSupportHT = src->bssht.bdSupportHT; dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; - dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; - memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); - dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen; - memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen); + dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen; + memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf, + src->bssht.bdHTCapLen); + dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen; + memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf, + src->bssht.bdHTInfoLen); dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer; dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime; dst->broadcom_cap_exist = src->broadcom_cap_exist; @@ -2497,7 +2429,8 @@ static inline void update_network(struct rtllib_network *dst, old_param = dst->qos_data.param_count; dst->qos_data.supported = src->qos_data.supported; if (dst->flags & NETWORK_HAS_QOS_PARAMETERS) - memcpy(&dst->qos_data, &src->qos_data, sizeof(struct rtllib_qos_data)); + memcpy(&dst->qos_data, &src->qos_data, + sizeof(struct rtllib_qos_data)); if (dst->qos_data.supported == 1) { if (dst->ssid_len) RTLLIB_DEBUG_QOS @@ -2512,12 +2445,11 @@ static inline void update_network(struct rtllib_network *dst, /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; - if (src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn) { - memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); - } + if (src->wmm_param[0].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn || + src->wmm_param[2].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn) + memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); dst->SignalStrength = src->SignalStrength; dst->RSSI = src->RSSI; @@ -2528,24 +2460,24 @@ static inline void update_network(struct rtllib_network *dst, dst->bWithAironetIE = src->bWithAironetIE; dst->bCkipSupported = src->bCkipSupported; - memcpy(dst->CcxRmState,src->CcxRmState,2); + memcpy(dst->CcxRmState, src->CcxRmState, 2); dst->bCcxRmEnable = src->bCcxRmEnable; dst->MBssidMask = src->MBssidMask; dst->bMBssidValid = src->bMBssidValid; - memcpy(dst->MBssid,src->MBssid,6); + memcpy(dst->MBssid, src->MBssid, 6); dst->bWithCcxVerNum = src->bWithCcxVerNum; dst->BssCcxVerNumber = src->BssCcxVerNumber; - } + static inline int is_beacon(__le16 fc) { return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); } -static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) +static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } @@ -2555,10 +2487,10 @@ static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) return 0; } -int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) +int IsLegalChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } if (rtllib->active_channel_map[channel] > 0) @@ -2567,7 +2499,6 @@ int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) return 0; } - static inline void rtllib_process_probe_response( struct rtllib_device *ieee, struct rtllib_probe_response *beacon, @@ -2578,7 +2509,8 @@ static inline void rtllib_process_probe_response( struct rtllib_info_element *info_element = &beacon->info_element[0]; unsigned long flags; short renew; - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return; @@ -2606,12 +2538,12 @@ static inline void rtllib_process_probe_response( if (rtllib_network_init(ieee, beacon, network, stats)) { RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", - escape_essid(info_element->data, - info_element->len), - MAC_ARG(beacon->header.addr3), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(info_element->data, + info_element->len), + MAC_ARG(beacon->header.addr3), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); goto free_network; } @@ -2619,10 +2551,12 @@ static inline void rtllib_process_probe_response( if (!IsLegalChannel(ieee, network->channel)) goto free_network; - if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP) { + if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP) { if (IsPassiveChannel(ieee, network->channel)) { - printk("GetScanInfo(): For Global Domain, " - "filter probe response at channel(%d).\n", network->channel); + printk(KERN_INFO "GetScanInfo(): For Global Domain, " + "filter probe response at channel(%d).\n", + network->channel); goto free_network; } } @@ -2631,32 +2565,32 @@ static inline void rtllib_process_probe_response( * to see if we can find it in our list. * * NOTE: This search is definitely not optimized. Once its doing - * the "right thing" we'll optimize it for efficiency if - * necessary */ + * the "right thing" we'll optimize it for efficiency if + * necessary */ /* Search for this entry in the list and update it if it is * already there. */ spin_lock_irqsave(&ieee->lock, flags); - { - if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { - update_network(&ieee->current_network, network); - if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) - && ieee->current_network.berp_info_valid){ - if (ieee->current_network.erp_value& ERP_UseProtection) + if (is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0))) { + update_network(&ieee->current_network, network); + if ((ieee->current_network.mode == IEEE_N_24G || + ieee->current_network.mode == IEEE_G) + && ieee->current_network.berp_info_valid) { + if (ieee->current_network.erp_value & ERP_UseProtection) ieee->current_network.buseprotection = true; - else - ieee->current_network.buseprotection = false; + else + ieee->current_network.buseprotection = false; } - if (is_beacon(beacon->header.frame_ctl)) - { - if (ieee->state >= RTLLIB_LINKED) - ieee->LinkDetectInfo.NumRecvBcnInPeriod++; - } + if (is_beacon(beacon->header.frame_ctl)) { + if (ieee->state >= RTLLIB_LINKED) + ieee->LinkDetectInfo.NumRecvBcnInPeriod++; } } list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, network,(target->ssid_len?1:0))) + if (is_same_network(target, network, + (target->ssid_len ? 1 : 0))) break; if ((oldest == NULL) || (target->last_scanned < oldest->last_scanned)) @@ -2684,49 +2618,51 @@ static inline void rtllib_process_probe_response( RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", - escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", - escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(target->ssid, + target->ssid_len), + MAC_ARG(target->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); - /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new - * net and call the new_net handler + /* we have an entry and we are going to update it. But this + * entry may be already expired. In this case we do the same + * as we found a new net and call the new_net handler */ - renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); + renew = !time_after(target->last_scanned + ieee->scan_age, + jiffies); if ((!target->ssid_len) && - (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) - || ((ieee->current_network.ssid_len == network->ssid_len) && - (strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0) && - (ieee->state == RTLLIB_NOLINK))) - ) { + (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) + || ((ieee->current_network.ssid_len == network->ssid_len) && + (strncmp(ieee->current_network.ssid, network->ssid, + network->ssid_len) == 0) && + (ieee->state == RTLLIB_NOLINK)))) renew = 1; - } update_network(target, network); if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) rtllib_softmac_new_net(ieee, network); } spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))&&\ - (ieee->state == RTLLIB_LINKED)) { - if (ieee->handle_beacon != NULL) { - ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); - } + if (is_beacon(beacon->header.frame_ctl) && + is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0)) && + (ieee->state == RTLLIB_LINKED)) { + if (ieee->handle_beacon != NULL) + ieee->handle_beacon(ieee->dev, beacon, + &ieee->current_network); } free_network: kfree(network); @@ -2734,48 +2670,48 @@ free_network: } void rtllib_rx_mgt(struct rtllib_device *ieee, - struct sk_buff *skb, + struct sk_buff *skb, struct rtllib_rx_stats *stats) { - struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && - WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) - ieee->last_rx_ps_time = jiffies; + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && + WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) + ieee->last_rx_ps_time = jiffies; - case RTLLIB_STYPE_BEACON: - RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Beacon\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && - ieee->state == RTLLIB_LINKED)) - tasklet_schedule(&ieee->ps_task); + case RTLLIB_STYPE_BEACON: + RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Beacon\n"); + rtllib_process_probe_response( + ieee, (struct rtllib_probe_response *)header, + stats); - break; + if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && + ieee->iw_mode == IW_MODE_INFRA && + ieee->state == RTLLIB_LINKED)) + tasklet_schedule(&ieee->ps_task); - case RTLLIB_STYPE_PROBE_RESP: - RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe response\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); - break; - case RTLLIB_STYPE_PROBE_REQ: - RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe request\n"); - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == RTLLIB_LINKED)){ - rtllib_rx_probe_rq(ieee, skb); - } - break; - } + break; + case RTLLIB_STYPE_PROBE_RESP: + RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe response\n"); + rtllib_process_probe_response(ieee, + (struct rtllib_probe_response *)header, stats); + break; + case RTLLIB_STYPE_PROBE_REQ: + RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe request\n"); + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == RTLLIB_LINKED)) + rtllib_rx_probe_rq(ieee, skb); + break; + } } From 9d92ece80d38a6fbf098bd924cf6db146c08f817 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:26 -0500 Subject: [PATCH 0555/1519] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIV With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtllib_softmac.c will need refactoring. In addition, some of the variables may need renaming. Those changes can be deferred. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 1978 ++++++++++----------- 1 file changed, 961 insertions(+), 1017 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 29277d18f02..fa0e2afd1ed 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -20,27 +20,26 @@ #include #include #include -#include +#include #include "dot11d.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long ); u8 rsn_authen_cipher_suite[16][4] = { - {0x00,0x0F,0xAC,0x00}, - {0x00,0x0F,0xAC,0x01}, - {0x00,0x0F,0xAC,0x02}, - {0x00,0x0F,0xAC,0x03}, - {0x00,0x0F,0xAC,0x04}, - {0x00,0x0F,0xAC,0x05}, + {0x00, 0x0F, 0xAC, 0x00}, + {0x00, 0x0F, 0xAC, 0x01}, + {0x00, 0x0F, 0xAC, 0x02}, + {0x00, 0x0F, 0xAC, 0x03}, + {0x00, 0x0F, 0xAC, 0x04}, + {0x00, 0x0F, 0xAC, 0x05}, }; short rtllib_is_54g(struct rtllib_network *net) { - return ((net->rates_ex_len > 0) || (net->rates_len > 4)); + return (net->rates_ex_len > 0) || (net->rates_len > 4); } short rtllib_is_shortslot(struct rtllib_network net) { - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME); + return net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME; } /* returns the total length needed for pleacing the RATE MFIE @@ -69,7 +68,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { *tag++ = MFIE_TYPE_RATES; *tag++ = 4; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; @@ -78,7 +77,8 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; } - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW + * might support */ *tag_p = tag; } @@ -86,8 +86,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ - + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; @@ -98,14 +97,14 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB; - } - - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW might + * support */ *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; *tag++ = MFIE_TYPE_GENERIC; @@ -120,17 +119,18 @@ void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { *tag_p = tag; } -void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = 7; - *tag++ = 0x00; - *tag++ = 0xe0; - *tag++ = 0x4c; - *tag++ = 0x01; - *tag++ = 0x02; - *tag++ = 0x11; + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = 7; + *tag++ = 0x00; + *tag++ = 0xe0; + *tag++ = 0x4c; + *tag++ = 0x01; + *tag++ = 0x02; + *tag++ = 0x11; *tag++ = 0x00; *tag_p = tag; @@ -140,7 +140,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; /* * if the queue is full but we have newer frames then @@ -183,29 +183,21 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) u8 BasicRate; - for ( i = 0; i < ieee->current_network.rates_len; i++) - { + for (i = 0; i < ieee->current_network.rates_len; i++) { BasicRate = ieee->current_network.rates[i]&0x7F; - if (!rtllib_is_cck_rate(BasicRate)) - { - if (QueryRate == 0) - { + if (!rtllib_is_cck_rate(BasicRate)) { + if (QueryRate == 0) { QueryRate = BasicRate; - } - else - { + } else { if (BasicRate < QueryRate) - { QueryRate = BasicRate; - } } } } - if (QueryRate == 0) - { + if (QueryRate == 0) { QueryRate = 12; - printk("No BasicRate found!!\n"); + printk(KERN_INFO "No BasicRate found!!\n"); } return QueryRate; } @@ -220,10 +212,10 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) else rate = ieee->basic_rate & 0x7f; - if (rate == 0){ - if (ieee->mode == IEEE_A|| - ieee->mode== IEEE_N_5G|| - (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + if (rate == 0) { + if (ieee->mode == IEEE_A || + ieee->mode == IEEE_N_5G || + (ieee->mode == IEEE_N_24G && !pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -232,21 +224,18 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) return rate; } - -void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); - inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct rtllib_hdr_3addr *header= + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); if (header->frame_ctl == RTLLIB_STYPE_BEACON) tcb_desc->queue_index = BEACON_QUEUE; @@ -261,9 +250,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) tcb_desc->bTxDisableRateFallBack = 1; tcb_desc->bTxUseDriverAssingedRate = 1; if (single) { - if (ieee->queue_stop){ - enqueue_mgmt(ieee,skb); - }else{ + if (ieee->queue_stop) { + enqueue_mgmt(ieee, skb); + } else { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -272,11 +261,12 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } spin_unlock_irqrestore(&ieee->lock, flags); - }else{ + } else { spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); @@ -288,17 +278,19 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* check wether the managed packet queued greater than 5 */ - if (!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ - (ieee->queue_stop) ) { + if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) || + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || + (ieee->queue_stop)) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. * */ - printk("%s():insert to waitqueue, queue_index:%d!\n",__func__,tcb_desc->queue_index); - skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); + printk(KERN_INFO "%s():insert to waitqueue, queue_index" + ":%d!\n", __func__, tcb_desc->queue_index); + skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], + skb); } else { - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } @@ -310,7 +302,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u16 fc,type,stype; + u16 fc, type, stype; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); fc = header->frame_ctl; @@ -342,7 +334,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, } /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } else { if (type != RTLLIB_FTYPE_CTL) { @@ -353,14 +346,14 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, else ieee->seq_ctrl[0]++; } - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } } inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) { - unsigned int len,rate_len; + unsigned int len, rate_len; u8 *tag; struct sk_buff *skb; struct rtllib_probe_request *req; @@ -377,7 +370,8 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); + req = (struct rtllib_probe_request *) skb_put(skb, + sizeof(struct rtllib_probe_request)); req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ); req->header.duration_id = 0; @@ -385,15 +379,15 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - tag = (u8 *) skb_put(skb,len+2+rate_len); + tag = (u8 *) skb_put(skb, len + 2 + rate_len); *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - rtllib_MFIE_Brate(ieee,&tag); - rtllib_MFIE_Grate(ieee,&tag); + rtllib_MFIE_Brate(ieee, &tag); + rtllib_MFIE_Grate(ieee, &tag); return skb; } @@ -407,14 +401,14 @@ void rtllib_send_beacon(struct rtllib_device *ieee) return; skb = rtllib_get_beacon_(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_beacons++; } - if (ieee->beacon_txing && ieee->ieee_up){ - mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); - } + if (ieee->beacon_txing && ieee->ieee_up) + mod_timer(&ieee->beacon_timer, jiffies + + (MSECS(ieee->current_network.beacon_interval - 5))); } @@ -431,83 +425,86 @@ void rtllib_send_beacon_cb(unsigned long _ieee) /* * Description: - * Enable network monitor mode, all rx packets will be received. + * Enable network monitor mode, all rx packets will be received. */ -void rtllib_EnableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Monitor Mode\n"); + printk(KERN_INFO "========>Enter Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); } /* * Description: - * Disable network network monitor mode, only packets destinated to - * us will be received. + * Disable network network monitor mode, only packets destinated to + * us will be received. */ -void rtllib_DisableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Monitor Mode\n"); + printk(KERN_INFO "========>Exit Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); } /* * Description: - * This enables the specialized promiscuous mode required by Intel. - * In this mode, Intel intends to hear traffics from/to other STAs in the same BSS. - * Therefore we don't have to disable checking BSSID and we only need to allow all dest. - * BUT: if we enable checking BSSID then we can't recv packets from other STA. + * This enables the specialized promiscuous mode required by Intel. + * In this mode, Intel intends to hear traffics from/to other STAs in the + * same BSS. Therefore we don't have to disable checking BSSID and we only need + * to allow all dest. BUT: if we enable checking BSSID then we can't recv + * packets from other STA. */ -void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = false; + bool bFilterOutNonAssociatedBSSID = false; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Enter Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = true; + ieee->bNetPromiscuousMode = true; } /* * Description: - * This disables the specialized promiscuous mode required by Intel. - * See MgntEnableIntelPromiscuousMode for detail. + * This disables the specialized promiscuous mode required by Intel. + * See MgntEnableIntelPromiscuousMode for detail. */ -void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = true; + bool bFilterOutNonAssociatedBSSID = true; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Exit Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = false; + ieee->bNetPromiscuousMode = false; } void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } @@ -529,7 +526,8 @@ void rtllib_softmac_hint11d_wq(void *data) void rtllib_update_active_chan_map(struct rtllib_device *ieee) { - memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); + memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, + MAX_CHANNEL_NUMBER+1); } /* this performs syncro scan blocking the caller until all channels @@ -537,6 +535,7 @@ void rtllib_update_active_chan_map(struct rtllib_device *ieee) */ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { + union iwreq_data wrqu; short ch = 0; rtllib_update_active_chan_map(ieee); @@ -545,14 +544,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) down(&ieee->scan_sem); - while(1) - { - + while (1) { do { ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are @@ -575,14 +572,14 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) if (ieee->state == RTLLIB_LINKED) goto out; - if (ieee->sync_scan_hurryup){ - printk("============>sync_scan_hurryup out\n"); + if (ieee->sync_scan_hurryup) { + printk(KERN_INFO "============>sync_scan_hurryup out\n"); goto out; } ieee->set_chan(ieee->dev, ch); if (ieee->active_channel_map[ch] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -593,7 +590,7 @@ out: ieee->actscanning = false; ieee->sync_scan_hurryup = 0; - if (ieee->state >= RTLLIB_LINKED){ + if (ieee->state >= RTLLIB_LINKED) { if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); } @@ -601,53 +598,52 @@ out: ieee->be_scan_inprogress = false; - { - union iwreq_data wrqu; memset(&wrqu, 0, sizeof(wrqu)); - wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); - } + wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } void rtllib_softmac_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, softmac_scan_wq); u8 last_channel = ieee->current_network.channel; rtllib_update_active_chan_map(ieee); if (!ieee->ieee_up) return; - if (rtllib_act_scanning(ieee,true) == true) + if (rtllib_act_scanning(ieee, true) == true) return; down(&ieee->scan_sem); - if (ieee->eRFPowerState == eRfOff) - { - printk("======>%s():rf state is eRfOff, return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + printk(KERN_INFO "======>%s():rf state is eRfOff, return\n", + __func__); goto out1; } - do{ + do { ieee->current_network.channel = - (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) - { + (ieee->current_network.channel + 1) % + MAX_CHANNEL_NUMBER; + if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) { if (!ieee->active_channel_map[ieee->current_network.channel]) ieee->current_network.channel = 6; goto out; /* no good chans */ } - } while(!ieee->active_channel_map[ieee->current_network.channel]); + } while (!ieee->active_channel_map[ieee->current_network.channel]); - if (ieee->scanning_continue == 0 ) + if (ieee->scanning_continue == 0) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); if (ieee->active_channel_map[ieee->current_network.channel] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); + queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, + MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); up(&ieee->scan_sem); return; @@ -669,24 +665,24 @@ out1: void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 1; rtllib_send_beacon(ieee); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 0; del_timer_sync(&ieee->beacon_timer); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } @@ -725,9 +721,9 @@ void rtllib_softmac_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_stop_scan(ieee); - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -735,9 +731,9 @@ void rtllib_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan_syncro(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { ieee->sync_scan_hurryup = 1; - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -745,13 +741,12 @@ void rtllib_stop_scan_syncro(struct rtllib_device *ieee) bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ - if (sync_scan){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { + if (sync_scan) return ieee->be_scan_inprogress; - }else{ - return (ieee->actscanning ||ieee->be_scan_inprogress); - } - }else{ + else + return ieee->actscanning || ieee->be_scan_inprogress; + } else { return test_bit(STATUS_SCANNING, &ieee->status); } } @@ -759,61 +754,55 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) /* called with ieee->lock held */ void rtllib_start_scan(struct rtllib_device *ieee) { - RT_TRACE(COMP_DBG, "===>%s()\n",__func__); + RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) - ieee->rtllib_ips_leave_wq(ieee->dev); + ieee->rtllib_ips_leave_wq(ieee->dev); - - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { if (ieee->scanning_continue == 0) { ieee->actscanning = true; ieee->scanning_continue = 1; - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, 0); + queue_delayed_work_rsl(ieee->wq, + &ieee->softmac_scan_wq, 0); } } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } /* called with wx_sem held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } ieee->sync_scan_hurryup = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_scan_syncro(ieee, is_mesh); - }else{ + } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, - struct rtllib_device *ieee, int challengelen,u8 * daddr) + struct rtllib_device *ieee, int challengelen, u8 *daddr) { struct sk_buff *skb; struct rtllib_authentication *auth; int len = 0; - len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; + len = sizeof(struct rtllib_authentication) + challengelen + + ieee->tx_headroom + 4; skb = dev_alloc_skb(len); - if (!skb) return NULL; + if (!skb) + return NULL; skb_reserve(skb, ieee->tx_headroom); @@ -821,10 +810,11 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, skb_put(skb, sizeof(struct rtllib_authentication)); auth->header.frame_ctl = RTLLIB_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= RTLLIB_FCTL_WEP; + if (challengelen) + auth->header.frame_ctl |= RTLLIB_FCTL_WEP; auth->header.duration_id = 0x013a; - memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); if (ieee->auth_mode == 0) @@ -839,22 +829,18 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); return skb; - } -void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) +void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) { - u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; + u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) - { + if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { szQoSOUI[0] = 46; szQoSOUI[1] = *wmm_len; - memcpy(wmmie,szQoSOUI,3); + memcpy(wmmie, szQoSOUI, 3); *wmm_len = 3; - } - else - { + } else { szQoSOUI[1] = *wmm_len + 6; szQoSOUI[6] = oui_subtype; memcpy(wmmie, szQoSOUI, 8); @@ -863,15 +849,15 @@ void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) } } -static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; int beacon_size; struct rtllib_probe_response *beacon_buf; struct sk_buff *skb = NULL; int encrypt; - int atim_len,erp_len; - struct rtllib_crypt_data* crypt; + int atim_len, erp_len; + struct rtllib_crypt_data *crypt; char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; @@ -880,82 +866,83 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) int wpa_ie_len = ieee->wpa_ie_len; u8 erpinfo_content = 0; - u8* tmp_ht_cap_buf = NULL; + u8 *tmp_ht_cap_buf = NULL; u8 tmp_ht_cap_len = 0; - u8* tmp_ht_info_buf = NULL; + u8 *tmp_ht_info_buf = NULL; u8 tmp_ht_info_len = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8* tmp_generic_ie_buf = NULL; + u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; if (rate_ex_len > 0) - rate_ex_len+=2; + rate_ex_len += 2; if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - if ((ieee->current_network.mode == IEEE_G) - ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) { + if ((ieee->current_network.mode == IEEE_G) || + (ieee->current_network.mode == IEEE_N_24G && + ieee->pHTInfo->bCurSuppCCK)) { erp_len = 3; erpinfo_content = 0; if (ieee->current_network.buseprotection) erpinfo_content |= ERP_UseProtection; - } - else + } else erp_len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); - if (ieee->pHTInfo->bCurrentHTSupport){ - tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport) { + tmp_ht_cap_buf = (u8 *) &(ieee->pHTInfo->SelfHTCap); tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf = (u8 *) &(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); - HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt, false); - HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); + HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, + &tmp_ht_cap_len, encrypt, false); + HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, + encrypt); - - if (pHTInfo->bRegRT2RTAggregation) - { + if (pHTInfo->bRegRT2RTAggregation) { tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); + tmp_generic_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, + &tmp_generic_ie_len); } } beacon_size = sizeof(struct rtllib_probe_response)+2+ - ssid_len - +3 - +rate_len - +rate_ex_len - +atim_len - +erp_len - +wpa_ie_len - +ieee->tx_headroom; + ssid_len + 3 + rate_len + rate_ex_len + atim_len + erp_len + + wpa_ie_len + ieee->tx_headroom; skb = dev_alloc_skb(beacon_size); if (!skb) return NULL; skb_reserve(skb, ieee->tx_headroom); - beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + beacon_buf = (struct rtllib_probe_response *) skb_put(skb, + (beacon_size - ieee->tx_headroom)); + memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); + memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); beacon_buf->capability = - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_IBSS); beacon_buf->capability |= - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME)); + if (ieee->short_slot && (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_SLOT_TIME)) + cpu_to_le16((beacon_buf->capability |= + WLAN_CAPABILITY_SHORT_SLOT_TIME)); crypt = ieee->crypt[ieee->tx_keyidx]; if (encrypt) @@ -966,7 +953,7 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) beacon_buf->info_element[0].id = MFIE_TYPE_SSID; beacon_buf->info_element[0].len = ssid_len; - tag = (u8*) beacon_buf->info_element[0].data; + tag = (u8 *) beacon_buf->info_element[0].data; memcpy(tag, ssid, ssid_len); @@ -974,58 +961,55 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) *(tag++) = MFIE_TYPE_RATES; *(tag++) = rate_len-2; - memcpy(tag,ieee->current_network.rates,rate_len-2); - tag+=rate_len-2; + memcpy(tag, ieee->current_network.rates, rate_len-2); + tag += rate_len-2; *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - if (atim_len){ - u16 val16; + if (atim_len) { + u16 val16; *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; val16 = cpu_to_le16(ieee->current_network.atim_window); memcpy((u8 *)tag, (u8 *)&val16, 2); - tag+=2; + tag += 2; } - if (erp_len){ + if (erp_len) { *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; *(tag++) = erpinfo_content; } - if (rate_ex_len){ + if (rate_ex_len) { *(tag++) = MFIE_TYPE_RATES_EX; *(tag++) = rate_ex_len-2; - memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); - tag+=rate_ex_len-2; + memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2); + tag += rate_ex_len-2; } - if (wpa_ie_len) - { + if (wpa_ie_len) { if (ieee->iw_mode == IW_MODE_ADHOC) - { memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); - } memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); tag += ieee->wpa_ie_len; } - return skb; } -struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; - u8* tag; + u8 *tag; - struct rtllib_crypt_data* crypt; + struct rtllib_crypt_data *crypt; struct rtllib_assoc_response_frame *assoc; short encrypt; unsigned int rate_len = rtllib_MFIE_rate_len(ieee); - int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; + int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + + ieee->tx_headroom; skb = dev_alloc_skb(len); @@ -1035,10 +1019,10 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) skb_reserve(skb, ieee->tx_headroom); assoc = (struct rtllib_assoc_response_frame *) - skb_put(skb,sizeof(struct rtllib_assoc_response_frame)); + skb_put(skb, sizeof(struct rtllib_assoc_response_frame)); assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr1, dest, ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? @@ -1046,14 +1030,15 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) if (ieee->short_slot) - assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); + assoc->capability |= + cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - encrypt = ( crypt && crypt->ops); + encrypt = (crypt && crypt->ops); if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); @@ -1061,22 +1046,23 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) - ieee->assoc_id=0; + ieee->assoc_id = 0; else ieee->assoc_id++; - tag = (u8*) skb_put(skb, rate_len); + tag = (u8 *) skb_put(skb, rate_len); rtllib_MFIE_Brate(ieee, &tag); rtllib_MFIE_Grate(ieee, &tag); return skb; } -struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest) +struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, + u8 *dest) { struct sk_buff *skb = NULL; struct rtllib_authentication *auth; - int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; + int len = ieee->tx_headroom + sizeof(struct rtllib_authentication) + 1; skb = dev_alloc_skb(len); if (!skb) return NULL; @@ -1101,10 +1087,10 @@ struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest } -struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) +struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; - struct rtllib_hdr_3addr* hdr; + struct rtllib_hdr_3addr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); if (!skb) @@ -1112,7 +1098,8 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); + hdr = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -1120,17 +1107,17 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | - (pwr ? RTLLIB_FCTL_PM:0)); + (pwr ? RTLLIB_FCTL_PM : 0)); return skb; } -struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) +struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_pspoll_hdr* hdr; + struct rtllib_pspoll_hdr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); if (!skb) @@ -1138,19 +1125,21 @@ struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); + hdr = (struct rtllib_pspoll_hdr *)skb_put(skb, + sizeof(struct rtllib_pspoll_hdr)); memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); - hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL |RTLLIB_STYPE_PSPOLL | RTLLIB_FCTL_PM); + hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL | + RTLLIB_FCTL_PM); return skb; } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) +void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1159,7 +1148,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8* dest) +void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1181,110 +1170,98 @@ inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid) { int i = 0; - do - { - if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) - { + do { + if ((ieee->PMKIDList[i].bUsed) && + (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) break; - } else - { i++; - } } while (i < NUM_PMKID_CACHE); if (i == NUM_PMKID_CACHE) - { i = -1; - } - else - { - } - - return (i); - + return i; } - -inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,struct rtllib_device *ieee) +inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, + struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_assoc_request_frame *hdr; u8 *tag, *ies; int i; - u8* ht_cap_buf = NULL; - u8 ht_cap_len=0; - u8* realtek_ie_buf=NULL; - u8 realtek_ie_len=0; - int wpa_ie_len= ieee->wpa_ie_len; + u8 *ht_cap_buf = NULL; + u8 ht_cap_len = 0; + u8 *realtek_ie_buf = NULL; + u8 realtek_ie_len = 0; + int wpa_ie_len = ieee->wpa_ie_len; int wps_ie_len = ieee->wps_ie_len; - unsigned int ckip_ie_len=0; - unsigned int ccxrm_ie_len=0; - unsigned int cxvernum_ie_len=0; - struct rtllib_crypt_data* crypt; + unsigned int ckip_ie_len = 0; + unsigned int ccxrm_ie_len = 0; + unsigned int cxvernum_ie_len = 0; + struct rtllib_crypt_data *crypt; int encrypt; int PMKCacheIdx; - unsigned int rate_len = (beacon->rates_len?(beacon->rates_len+2):0) + (beacon->rates_ex_len?(beacon->rates_ex_len)+2:0); + unsigned int rate_len = (beacon->rates_len ? + (beacon->rates_len + 2) : 0) + + (beacon->rates_ex_len ? (beacon->rates_ex_len) + + 2 : 0); - unsigned int wmm_info_len = beacon->qos_data.supported?9:0; - unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; + unsigned int wmm_info_len = beacon->qos_data.supported ? 9 : 0; + unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0; int len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; - if (crypt != NULL) { - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); - } else { + if (crypt != NULL) + encrypt = ieee->host_encrypt && crypt && crypt->ops && + ((0 == strcmp(crypt->ops->name, "WEP") || + wpa_ie_len)); + else encrypt = 0; - } - if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) - { + if ((ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee) & SEC_ALG_TKIP)) || + (ieee->bForcedBgMode == true)) { ieee->pHTInfo->bEnableHT = 0; ieee->mode = WIRELESS_MODE_G; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); + HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, + encrypt, true); if (ieee->pHTInfo->bCurrentRT2RTAggregation) { realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); - + realtek_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, realtek_ie_buf, + &realtek_ie_len); } } if (beacon->bCkipSupported) - { ckip_ie_len = 30+2; - } if (beacon->bCcxRmEnable) - { ccxrm_ie_len = 6+2; - } - if ( beacon->BssCcxVerNumber >= 2 ) - { + if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5+2; - } PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { wpa_ie_len += 18; - printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); + printk(KERN_INFO "[PMK cache]: WPA2 IE length: %x\n", + wpa_ie_len); } - len = sizeof(struct rtllib_assoc_request_frame)+ 2 + len = sizeof(struct rtllib_assoc_request_frame) + 2 + beacon->ssid_len + rate_len + wpa_ie_len + wps_ie_len + wmm_info_len + turbo_info_len - + ht_cap_len + + ht_cap_len + realtek_ie_len + ckip_ie_len + ccxrm_ie_len @@ -1299,11 +1276,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_assoc_request_frame *) - skb_put(skb, sizeof(struct rtllib_assoc_request_frame)+2); + skb_put(skb, sizeof(struct rtllib_assoc_request_frame) + 2); hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; + hdr->header.duration_id = 37; memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); @@ -1311,13 +1288,14 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) + if (ieee->short_slot && + (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); @@ -1331,94 +1309,89 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru tag = skb_put(skb, rate_len); - if (beacon->rates_len){ + if (beacon->rates_len) { *tag++ = MFIE_TYPE_RATES; *tag++ = beacon->rates_len; - for (i=0;irates_len;i++){ + for (i = 0; i < beacon->rates_len; i++) *tag++ = beacon->rates[i]; - } } - if (beacon->rates_ex_len){ + if (beacon->rates_ex_len) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = beacon->rates_ex_len; - for (i=0;irates_ex_len;i++){ + for (i = 0; i < beacon->rates_ex_len; i++) *tag++ = beacon->rates_ex[i]; - } } - if ( beacon->bCkipSupported ) - { + if (beacon->bCkipSupported) { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; u8 CcxAironetBuf[30]; struct octet_string osCcxAironetIE; - memset(CcxAironetBuf, 0,30); + memset(CcxAironetBuf, 0, 30); osCcxAironetIE.Octet = CcxAironetBuf; osCcxAironetIE.Length = sizeof(CcxAironetBuf); - memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); + memcpy(osCcxAironetIE.Octet, AironetIeOui, + sizeof(AironetIeOui)); - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= + (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC); tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; *tag++ = osCcxAironetIE.Length; - memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); + memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length); tag += osCcxAironetIE.Length; } - if (beacon->bCcxRmEnable) - { + if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; struct octet_string osCcxRmCap; osCcxRmCap.Octet = CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); - tag = skb_put(skb,ccxrm_ie_len); + tag = skb_put(skb, ccxrm_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxRmCap.Length; - memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); + memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length); tag += osCcxRmCap.Length; } - if ( beacon->BssCcxVerNumber >= 2 ) - { - u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; + if (beacon->BssCcxVerNumber >= 2) { + u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; osCcxVerNum.Octet = CcxVerNumBuf; osCcxVerNum.Length = sizeof(CcxVerNumBuf); - tag = skb_put(skb,cxvernum_ie_len); + tag = skb_put(skb, cxvernum_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxVerNum.Length; - memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); + memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length); tag += osCcxVerNum.Length; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len -2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } } - - if (wpa_ie_len){ + if (wpa_ie_len) { tag = skb_put(skb, ieee->wpa_ie_len); memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { tag = skb_put(skb, 18); *tag = 1; *(tag + 1) = 0; - memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16); + memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, + 16); } } if (wmm_info_len) { - tag = skb_put(skb,wmm_info_len); + tag = skb_put(skb, wmm_info_len); rtllib_WMM_Info(ieee, &tag); } @@ -1427,42 +1400,39 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(tag, ieee->wps_ie, wps_ie_len); } - tag = skb_put(skb,turbo_info_len); - if (turbo_info_len) - rtllib_TURBO_Info(ieee, &tag); + tag = skb_put(skb, turbo_info_len); + if (turbo_info_len) + rtllib_TURBO_Info(ieee, &tag); - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len - 2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } - if (ieee->pHTInfo->bCurrentRT2RTAggregation){ + if (ieee->pHTInfo->bCurrentRT2RTAggregation) { tag = skb_put(skb, realtek_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = realtek_ie_len - 2; - memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); + memcpy(tag, realtek_ie_buf, realtek_ie_len - 2); } } - if (ieee->assocreq_ies){ - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; ies = &(hdr->info_element[0].id); ieee->assocreq_ies_len = (skb->data + skb->len) - ies; ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); if (ieee->assocreq_ies) memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocreq_ies\n", __func__); + else { + printk(KERN_INFO "%s()Warning: can't alloc memory for assocreq" + "_ies\n", __func__); ieee->assocreq_ies_len = 0; } - return skb; } @@ -1480,18 +1450,18 @@ void rtllib_associate_abort(struct rtllib_device *ieee) * Here we will check if there are good nets to associate * with, so we retry or just get back to NO_LINK and scanning */ - if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING){ + if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) { RTLLIB_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; - }else{ + } else { RTLLIB_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } ieee->state = RTLLIB_ASSOCIATING_RETRY; - queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, \ - RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); + queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, + RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1501,7 +1471,7 @@ void rtllib_associate_abort_cb(unsigned long dev) rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) +void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1510,15 +1480,15 @@ void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) ieee->softmac_stats.tx_auth_rq++; - skb=rtllib_authentication_req(beacon, ieee, 0,daddr); + skb = rtllib_authentication_req(beacon, ieee, 0, daddr); if (!skb) rtllib_associate_abort(ieee); - else{ + else { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ; RTLLIB_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); - if (!timer_pending(&ieee->associate_timer)){ + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } @@ -1534,19 +1504,21 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = rtllib_authentication_req(beacon, ieee, chlen+2,beacon->bssid); + skb = rtllib_authentication_req(beacon, ieee, chlen + 2, beacon->bssid); if (!skb) rtllib_associate_abort(ieee); - else{ + else { c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); + RTLLIB_DEBUG_MGMT("Sending authentication challenge " + "response\n"); - rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr )); + rtllib_encrypt_fragment(ieee, skb, + sizeof(struct rtllib_hdr_3addr)); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); @@ -1556,7 +1528,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) void rtllib_associate_step2(struct rtllib_device *ieee) { - struct sk_buff* skb; + struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; del_timer_sync(&ieee->associate_timer); @@ -1564,10 +1536,10 @@ void rtllib_associate_step2(struct rtllib_device *ieee) RTLLIB_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=rtllib_association_req(beacon, ieee); + skb = rtllib_association_req(beacon, ieee); if (!skb) rtllib_associate_abort(ieee); - else{ + else { softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); } @@ -1576,48 +1548,54 @@ void rtllib_associate_step2(struct rtllib_device *ieee) #define CANCELLED 2 void rtllib_associate_complete_wq(void *data) { - struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); + struct rtllib_device *ieee = (struct rtllib_device *) + container_of_work_rsl(data, + struct rtllib_device, + associate_complete_wq); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); printk(KERN_INFO "Associated successfully\n"); - if (ieee->is_silent_reset == 0){ - printk("normal associate\n"); - notify_wx_assoc_event(ieee); - } + if (ieee->is_silent_reset == 0) { + printk(KERN_INFO "normal associate\n"); + notify_wx_assoc_event(ieee); + } netif_carrier_on(ieee->dev); ieee->is_roaming = false; if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { ieee->rate = 108; printk(KERN_INFO"Using G rates:%d\n", ieee->rate); - }else{ + } else { ieee->rate = 22; ieee->SetWirelessMode(ieee->dev, IEEE_B); printk(KERN_INFO"Using B rates:%d\n", ieee->rate); } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - printk("Successfully associated, ht enabled\n"); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + printk(KERN_INFO "Successfully associated, ht enabled\n"); HTOnAssocRsp(ieee); } else { - printk("Successfully associated, ht not enabled(%d, %d)\n", - ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); + printk(KERN_INFO "Successfully associated, ht not " + "enabled(%d, %d)\n", + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bEnableHT); memset(ieee->dot11HTOperationalRateSet, 0, 16); } - ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { + ieee->LinkDetectInfo.SlotNum = 2 * (1 + + ieee->current_network.beacon_interval / + 500); + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } pPSC->LpsIdleCount = 0; ieee->link_change(ieee->dev); - if (ieee->is_silent_reset == 1) { - printk("silent reset associate\n"); + if (ieee->is_silent_reset == 1) { + printk(KERN_INFO "silent reset associate\n"); ieee->is_silent_reset = 0; - } + } if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1626,49 +1604,6 @@ void rtllib_associate_complete_wq(void *data) static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { - char *buf; - size_t len; - int i; - union iwreq_data wrqu; - - return; - - - buf = kmalloc(50 + 2 * (ieee->assocreq_ies_len + ieee->assocresp_ies_len), GFP_ATOMIC); - if (!buf) - return; - - len = sprintf(buf, "ASSOCINFO("); - if (ieee->assocreq_ies) { - len += sprintf(buf + len, "ReqIEs="); - for (i = 0; i < ieee->assocreq_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocreq_ies[i]); - } - } - if (ieee->assocresp_ies) { - if (ieee->assocreq_ies) - len += sprintf(buf + len, " "); - len += sprintf(buf + len, "RespIEs="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - len += sprintf(buf + len, ")"); - - if (len > IW_CUSTOM_MAX) { - len = sprintf(buf, "ASSOCRESPIE="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - - if (len <= IW_CUSTOM_MAX) { - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = len; - wireless_send_event(ieee->dev, IWEVCUSTOM, &wrqu, buf); - } - - kfree(buf); } void rtllib_associate_complete(struct rtllib_device *ieee) @@ -1683,7 +1618,9 @@ void rtllib_associate_complete(struct rtllib_device *ieee) void rtllib_associate_procedure_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_procedure_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, + associate_procedure_wq); rtllib_stop_scan_syncro(ieee); if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -1693,11 +1630,12 @@ void rtllib_associate_procedure_wq(void *data) ieee->data_hard_stop(ieee->dev); rtllib_stop_scan(ieee); - RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, ieee->current_network.channel); + RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, + ieee->current_network.channel); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - if (ieee->eRFPowerState == eRfOff) - { - RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff," + " schedule ipsleave wq again,return\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) ieee->rtllib_ips_leave_wq(ieee->dev); up(&ieee->wx_sem); @@ -1710,12 +1648,13 @@ void rtllib_associate_procedure_wq(void *data) up(&ieee->wx_sem); } -inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net) +inline void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net) { - u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; + u8 tmp_ssid[IW_ESSID_MAX_SIZE + 1]; int tmp_ssid_len = 0; - short apset,ssidset,ssidbroad,apmatch,ssidmatch; + short apset, ssidset, ssidbroad, apmatch, ssidmatch; /* we are interested in new new only if we are not associated * and we are not associating / authenticating @@ -1723,103 +1662,124 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_net if (ieee->state != RTLLIB_NOLINK) return; - if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_ESS)) + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & + WLAN_CAPABILITY_ESS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & + WLAN_CAPABILITY_IBSS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal)) { + if ((ieee->iw_mode == IW_MODE_ADHOC) && + (net->channel > ieee->ibss_maxjoin_chal)) return; - } - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not * broadcast it, it can be put manually. */ apset = ieee->wap_set; ssidset = ieee->ssid_set; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); - if (!ssidbroad){ - ssidmatch = (ieee->current_network.ssid_len == net->hidden_ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->hidden_ssid, net->hidden_ssid_len)); - if (net->hidden_ssid_len > 0) - { - strncpy(net->ssid, net->hidden_ssid, net->hidden_ssid_len); - net->ssid_len = net->hidden_ssid_len; - ssidbroad = 1; - } - } - else - ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, + ETH_ALEN) == 0); + if (!ssidbroad) { + ssidmatch = (ieee->current_network.ssid_len == + net->hidden_ssid_len) && + (!strncmp(ieee->current_network.ssid, + net->hidden_ssid, net->hidden_ssid_len)); + if (net->hidden_ssid_len > 0) { + strncpy(net->ssid, net->hidden_ssid, + net->hidden_ssid_len); + net->ssid_len = net->hidden_ssid_len; + ssidbroad = 1; + } + } else + ssidmatch = + (ieee->current_network.ssid_len == net->ssid_len) && + (!strncmp(ieee->current_network.ssid, net->ssid, + net->ssid_len)); - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplyed ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) - /* if the ap is not set, check that the user set the bssid - * and the network does bradcast and that those two bssid matches - */ - || (!apset && ssidset && ssidbroad && ssidmatch) || (ieee->is_roaming && ssidset && ssidbroad && ssidmatch) - ){ - /* if the essid is hidden replace it with the - * essid provided by the user. - */ - if (!ssidbroad){ - strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); - tmp_ssid_len = ieee->current_network.ssid_len; - } - memcpy(&ieee->current_network, net, sizeof(struct rtllib_network)); - if (!ssidbroad){ - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - } - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode, ieee->current_network.flags); + /* if the user set the AP check if match. + * if the network does not broadcast essid we check the + * user supplyed ANY essid + * if the network does broadcast and the user does not set + * essid it is OK + * if the network does broadcast and the user did set essid + * check if essid match + * if the ap is not set, check that the user set the bssid + * and the network does bradcast and that those two bssid match + */ + if ((apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || + (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + (!apset && ssidset && ssidbroad && ssidmatch) || + (ieee->is_roaming && ssidset && ssidbroad && ssidmatch)) { + /* if the essid is hidden replace it with the + * essid provided by the user. + */ + if (!ssidbroad) { + strncpy(tmp_ssid, ieee->current_network.ssid, + IW_ESSID_MAX_SIZE); + tmp_ssid_len = ieee->current_network.ssid_len; + } + memcpy(&ieee->current_network, net, + sizeof(struct rtllib_network)); + if (!ssidbroad) { + strncpy(ieee->current_network.ssid, tmp_ssid, + IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; + } + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, " + "myHT:%d, networkHT:%d, mode:%x cur_net.flags" + ":0x%x\n", ieee->current_network.ssid, + ieee->current_network.channel, + ieee->current_network.qos_data.supported, + ieee->pHTInfo->bEnableHT, + ieee->current_network.bssht.bdSupportHT, + ieee->current_network.mode, + ieee->current_network.flags); - if ((rtllib_act_scanning(ieee, false)) && !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - rtllib_stop_scan_syncro(ieee); - } + if ((rtllib_act_scanning(ieee, false)) && + !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) + rtllib_stop_scan_syncro(ieee); - ieee->hwscan_ch_bk = ieee->current_network.channel; - HTResetIOTSetting(ieee->pHTInfo); - ieee->wmm_acm = 0; - if (ieee->iw_mode == IW_MODE_INFRA) { - /* Join the network for the first time */ - ieee->AsocRetryCount = 0; - if ((ieee->current_network.qos_data.supported == 1) && - ieee->current_network.bssht.bdSupportHT) - HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); - else - ieee->pHTInfo->bCurrentHTSupport = false; + ieee->hwscan_ch_bk = ieee->current_network.channel; + HTResetIOTSetting(ieee->pHTInfo); + ieee->wmm_acm = 0; + if (ieee->iw_mode == IW_MODE_INFRA) { + /* Join the network for the first time */ + ieee->AsocRetryCount = 0; + if ((ieee->current_network.qos_data.supported == 1) && + ieee->current_network.bssht.bdSupportHT) + HTResetSelfAndSavePeerSetting(ieee, + &(ieee->current_network)); + else + ieee->pHTInfo->bCurrentHTSupport = + false; - ieee->state = RTLLIB_ASSOCIATING; - if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + ieee->state = RTLLIB_ASSOCIATING; + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + } else { + if (rtllib_is_54g(&ieee->current_network) && + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { + ieee->rate = 108; + ieee->SetWirelessMode(ieee->dev, IEEE_G); + printk(KERN_INFO"Using G rates\n"); } else { - if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - ieee->rate = 108; - ieee->SetWirelessMode(ieee->dev, IEEE_G); - printk(KERN_INFO"Using G rates\n"); - }else{ - ieee->rate = 22; - ieee->SetWirelessMode(ieee->dev, IEEE_B); - printk(KERN_INFO"Using B rates\n"); - } - memset(ieee->dot11HTOperationalRateSet, 0, 16); - ieee->state = RTLLIB_LINKED; + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates\n"); } - + memset(ieee->dot11HTOperationalRateSet, 0, 16); + ieee->state = RTLLIB_LINKED; + } } } - } void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) @@ -1838,51 +1798,49 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) if (ieee->state != RTLLIB_NOLINK) break; - if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - rtllib_softmac_new_net(ieee, target); + if (ieee->scan_age == 0 || time_after(target->last_scanned + + ieee->scan_age, jiffies)) + rtllib_softmac_new_net(ieee, target); } - spin_unlock_irqrestore(&ieee->lock, flags); - } - static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) { struct rtllib_authentication *a; u8 *t; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; - a = (struct rtllib_authentication*) skb->data; - if (skb->len > (sizeof(struct rtllib_authentication) +3)){ + a = (struct rtllib_authentication *) skb->data; + if (skb->len > (sizeof(struct rtllib_authentication) + 3)) { t = skb->data + sizeof(struct rtllib_authentication); - if (*(t++) == MFIE_TYPE_CHALLENGE){ + if (*(t++) == MFIE_TYPE_CHALLENGE) { *chlen = *(t++); - *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); - memcpy(*challenge, t, *chlen); + *challenge = kmalloc(*chlen, GFP_ATOMIC); + memcpy(*challenge, t, *chlen); /*TODO - check here*/ } } - return cpu_to_le16(a->status); - } - -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n", + skb->len); return -1; } - a = (struct rtllib_authentication*) skb->data; + a = (struct rtllib_authentication *) skb->data; - memcpy(dest,a->header.addr2, ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1890,38 +1848,36 @@ int auth_rq_parse(struct sk_buff *skb,u8* dest) return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *src) { u8 *tag; u8 *skbend; - u8 *ssid=NULL; + u8 *ssid = NULL; u8 ssidlen = 0; - struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + bool bssid_match; - if (skb->len < sizeof (struct rtllib_hdr_3addr )) + if (skb->len < sizeof(struct rtllib_hdr_3addr)) return -1; /* corrupted */ - if ((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&& - (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) { - return -1; - } - if (memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) { - } + bssid_match = + (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) && + (memcmp(header->addr3, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0); + if (bssid_match) + return -1; - if (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) { - } - memcpy(src,header->addr2, ETH_ALEN); + memcpy(src, header->addr2, ETH_ALEN); - skbend = (u8*)skb->data + skb->len; + skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct rtllib_hdr_3addr ); + tag = skb->data + sizeof(struct rtllib_hdr_3addr); - while (tag+1 < skbend){ - if (*tag == 0){ - ssid = tag+2; - ssidlen = *(tag+1); + while (tag + 1 < skbend) { + if (*tag == 0) { + ssid = tag + 2; + ssidlen = *(tag + 1); break; } tag++; /* point to the len field */ @@ -1929,53 +1885,56 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 tag++; /* point to the next tag */ } - if (ssidlen == 0) return 1; + if (ssidlen == 0) + return 1; - if (!ssid) return 1; /* ssid not found in tagged param */ - return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); + if (!ssid) + return 1; /* ssid not found in tagged param */ + return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - sizeof(struct rtllib_info_element))) { - RTLLIB_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); + RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len); return -1; } - a = (struct rtllib_assoc_request_frame*) skb->data; + a = (struct rtllib_assoc_request_frame *) skb->data; - memcpy(dest,a->header.addr2,ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); return 0; } -static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, int *aid) +static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, + int *aid) { struct rtllib_assoc_response_frame *response_head; u16 status_code; - if (skb->len < sizeof(struct rtllib_assoc_response_frame)){ + if (skb->len < sizeof(struct rtllib_assoc_response_frame)) { RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - response_head = (struct rtllib_assoc_response_frame*) skb->data; + response_head = (struct rtllib_assoc_response_frame *) skb->data; *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if ((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& + if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || + status_code == WLAN_STATUS_CAPS_UNSUPPORTED) && ((ieee->mode == IEEE_G) && - (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; - }else { - ieee->AsocRetryCount = 0; + (ieee->current_network.mode == IEEE_N_24G) && + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + } else { + ieee->AsocRetryCount = 0; } return le16_to_cpu(response_head->status); @@ -1985,38 +1944,37 @@ void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_probe_rq++; - if (probe_rq_parse(ieee, skb, dest) > 0){ + if (probe_rq_parse(ieee, skb, dest) > 0) { ieee->softmac_stats.tx_probe_rs++; rtllib_resp_to_probe(ieee, dest); } } -static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) rtllib_resp_to_auth(ieee, status, dest); - } - } -static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ + if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); } - void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) { @@ -2024,34 +1982,25 @@ void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) { - struct sk_buff *buf = rtllib_pspoll_func(ieee); if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); - /*if (ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED) + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); - return 0; - */ - - if (ieee->LPSDelayCnt) - { - ieee->LPSDelayCnt --; + if (ieee->LPSDelayCnt) { + ieee->LPSDelayCnt--; return 0; } @@ -2060,21 +2009,20 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) return 0; timeout = ieee->current_network.beacon_interval; ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID; - /* there's no need to nofity AP that I find you buffered with broadcast packet */ + /* there's no need to nofity AP that I find you buffered + * with broadcast packet */ if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps)) return 2; - if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ + if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - } - if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){ + if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - } - if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && - (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) && + (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time){ + if (time) { if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2088,27 +2036,37 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) MaxPeriod = ieee->current_network.dtim_period; else MaxPeriod = pPSC->RegMaxLPSAwakeIntvl; - pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1); + pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= + MaxPeriod) ? MaxPeriod : + (pPSC->LPSAwakeIntvl + 1); } { u8 LPSAwakeIntvl_tmp = 0; u8 period = ieee->current_network.dtim_period; u8 count = ieee->current_network.tim.tim_count; - if (count == 0 ) { + if (count == 0) { if (pPSC->LPSAwakeIntvl > period) - LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period); + LPSAwakeIntvl_tmp = period + + (pPSC->LPSAwakeIntvl - + period) - + ((pPSC->LPSAwakeIntvl-period) % + period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } else { - if (pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count) - LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period); + if (pPSC->LPSAwakeIntvl > + ieee->current_network.tim.tim_count) + LPSAwakeIntvl_tmp = count + + (pPSC->LPSAwakeIntvl - count) - + ((pPSC->LPSAwakeIntvl-count)%period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } *time = ieee->current_network.last_dtim_sta_time - + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); + + MSECS(ieee->current_network.beacon_interval * + LPSAwakeIntvl_tmp); } } @@ -2119,45 +2077,38 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u64 time; short sleep; - - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); if ((ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED)){ - - RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", - __func__,ieee->ps,ieee->iw_mode,ieee->state); + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != RTLLIB_LINKED)) { + RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! " + "ieee->ps is %d, ieee->iw_mode is %d, ieee->state" + " is %d\n", __func__, ieee->ps, ieee->iw_mode, + ieee->state); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) - { goto out; - } - if (sleep == 1){ - if (ieee->sta_sleep == LPS_IS_SLEEP){ + if (sleep == 1) { + if (ieee->sta_sleep == LPS_IS_SLEEP) { ieee->enter_sleep_state(ieee->dev, time); - } - - else if (ieee->sta_sleep == LPS_IS_WAKE){ + } else if (ieee->sta_sleep == LPS_IS_WAKE) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->ps_is_queue_empty(ieee->dev)){ + if (ieee->ps_is_queue_empty(ieee->dev)) { ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; - rtllib_sta_ps_send_null_frame(ieee,1); + rtllib_sta_ps_send_null_frame(ieee, 1); ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2166,10 +2117,10 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->bAwakePktSent = false; - }else if (sleep == 2){ + } else if (sleep == 2) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee,1); + rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -2181,15 +2132,13 @@ out: void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) { - if (ieee->sta_sleep == LPS_IS_WAKE){ - if (nl){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->sta_sleep == LPS_IS_WAKE) { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_pspoll_frame(ieee); } @@ -2200,19 +2149,12 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) if (ieee->sta_sleep == LPS_IS_SLEEP) ieee->sta_wake_up(ieee->dev); - if (nl){ - /* - ieee->ack_tx_to_ieee = 1; - printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__); - rtllib_sta_ps_send_null_frame(ieee, 0); - */ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; ieee->polling = true; rtllib_sta_ps_send_pspoll_frame(ieee); @@ -2226,13 +2168,13 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) { - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); - if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND){ + if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND) { /* Null frame with PS bit set */ - if (success){ + if (success) { ieee->sta_sleep = LPS_IS_SLEEP; ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } @@ -2241,199 +2183,208 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) */ } else {/* 21112005 - tx again null without PS bit if lost */ - if ((ieee->sta_sleep == LPS_IS_WAKE) && !success){ + if ((ieee->sta_sleep == LPS_IS_WAKE) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) rtllib_sta_ps_send_null_frame(ieee, 0); - } else - { rtllib_sta_ps_send_pspoll_frame(ieee); - } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device* ieee, struct sk_buff* skb) +void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u8* act = rtllib_get_payload((struct rtllib_hdr *)header); + u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); u8 category = 0; if (act == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of action frame\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of " + "action frame\n"); return; } category = *act; - act ++; + act++; switch (category) { - case ACT_CAT_BA: - switch (*act) { - case ACT_ADDBAREQ: - rtllib_rx_ADDBAReq(ieee, skb); - break; - case ACT_ADDBARSP: - rtllib_rx_ADDBARsp(ieee, skb); - break; - case ACT_DELBA: - rtllib_rx_DELBA(ieee, skb); - break; - } + case ACT_CAT_BA: + switch (*act) { + case ACT_ADDBAREQ: + rtllib_rx_ADDBAReq(ieee, skb); break; - default: + case ACT_ADDBARSP: + rtllib_rx_ADDBARsp(ieee, skb); break; + case ACT_DELBA: + rtllib_rx_DELBA(ieee, skb); + break; + } + break; + default: + break; } return; } -inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; int aid; - u8* ies; + u8 *ies; struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); + WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && - (ieee->iw_mode == IW_MODE_INFRA)) - { - if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && + (ieee->iw_mode == IW_MODE_INFRA)) { + errcode = assoc_parse(ieee, skb, &aid); + if (0 == errcode) { + struct rtllib_network *network = + kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return 1; - memset(network,0,sizeof(*network)); - ieee->state=RTLLIB_LINKED; + memset(network, 0, sizeof(*network)); + ieee->state = RTLLIB_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; /* station support qos */ - /* Let the register setting defaultly with Legacy station */ - assoc_resp = (struct rtllib_assoc_response_frame*)skb->data; + /* Let the register setting default with Legacy station */ + assoc_resp = (struct rtllib_assoc_response_frame *)skb->data; if (ieee->current_network.qos_data.supported == 1) { - if (rtllib_parse_info_param(ieee,assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ + if (rtllib_parse_info_param(ieee, assoc_resp->info_element, + rx_stats->len - sizeof(*assoc_resp), + network, rx_stats)) { kfree(network); return 1; - } - else - { - memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); + } else { + memcpy(ieee->pHTInfo->PeerHTCapBuf, + network->bssht.bdHTCapBuf, + network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, + network->bssht.bdHTInfoBuf, + network->bssht.bdHTInfoLen); } if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee->dev, (struct rtllib_assoc_response_frame*)header, network); + ieee->handle_assoc_response(ieee->dev, + (struct rtllib_assoc_response_frame *)header, + network); kfree(network); } - if (ieee->assocresp_ies){ - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - } + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; ies = &(assoc_resp->info_element[0].id); ieee->assocresp_ies_len = (skb->data + skb->len) - ies; - ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, GFP_ATOMIC); + ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, + GFP_ATOMIC); if (ieee->assocresp_ies) - memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocresp_ies\n", __func__); + memcpy(ieee->assocresp_ies, ies, + ieee->assocresp_ies_len); + else { + printk(KERN_INFO "%s()Warning: can't alloc " + "memory for assocresp_ies\n", __func__); ieee->assocresp_ies_len = 0; } rtllib_associate_complete(ieee); } else { /* aid could not been allocated */ ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", + printk(KERN_INFO "Association response status code 0x%x\n", errcode); RTLLIB_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - } else { + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + else rtllib_associate_abort(ieee); - } } } - return 0; } -inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; - u8* challenge; - int chlen=0; + u8 *challenge; + int chlen = 0; bool bSupportNmode = true, bHalfSupportNmode = false; - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && (ieee->iw_mode == IW_MODE_INFRA)) { RTLLIB_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))) { - if (ieee->open_wep || !challenge){ + errcode = auth_parse(skb, &challenge, &chlen); + if (0 == errcode) { + if (ieee->open_wep || !challenge) { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - if (!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) - { - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) - { - if (IsHTHalfNmodeAPs(ieee)) - { + if (!(ieee->pHTInfo->IOTAction & + HT_IOT_ACT_PURE_N_MODE)) { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { + if (IsHTHalfNmodeAPs(ieee)) { bSupportNmode = true; bHalfSupportNmode = true; - } - else - { + } else { bSupportNmode = false; bHalfSupportNmode = false; } } } - /* Dummy wirless mode setting to avoid encryption issue */ + /* Dummy wirless mode setting to avoid + * encryption issue */ if (bSupportNmode) { - ieee->SetWirelessMode(ieee->dev, \ - ieee->current_network.mode); - }else{ + ieee->SetWirelessMode(ieee->dev, + ieee->current_network.mode); + } else { /*TODO*/ - ieee->SetWirelessMode(ieee->dev, IEEE_G); + ieee->SetWirelessMode(ieee->dev, + IEEE_G); } - if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) - { - printk("===============>entern half N mode\n"); - ieee->bHalfWirelessN24GMode = true; - } - else - ieee->bHalfWirelessN24GMode = false; + if (ieee->current_network.mode == + IEEE_N_24G && + bHalfSupportNmode == true) { + printk(KERN_INFO "======>enter " + "half N mode\n"); + ieee->bHalfWirelessN24GMode = + true; + } else + ieee->bHalfWirelessN24GMode = + false; rtllib_associate_step2(ieee); - }else{ - rtllib_auth_challenge(ieee, challenge, chlen); + } else { + rtllib_auth_challenge(ieee, challenge, + chlen); } - }else{ + } else { ieee->softmac_stats.rx_auth_rs_err++; - RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); + RTLLIB_DEBUG_MGMT("Authentication respose" + " status code 0x%x", errcode); - printk("Authentication respose status code 0x%x",errcode); + printk(KERN_INFO "Authentication respose " + "status code 0x%x", errcode); rtllib_associate_abort(ieee); } - }else if (ieee->iw_mode == IW_MODE_MASTER){ + } else if (ieee->iw_mode == IW_MODE_MASTER) { rtllib_rx_auth_rq(ieee, skb); } } - return 0; } @@ -2453,7 +2404,7 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) printk(KERN_INFO "==========>received disassoc/deauth(%x) " "frame, reason code:%x\n", WLAN_FC_GET_STYPE(header->frame_ctl), - ((struct rtllib_disassoc*)skb->data)->reason); + ((struct rtllib_disassoc *)skb->data)->reason); ieee->state = RTLLIB_ASSOCIATING; ieee->softmac_stats.reassoc++; ieee->is_roaming = true; @@ -2461,18 +2412,21 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) rtllib_disassociate(ieee); RemovePeerTS(ieee, header->addr2); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 5); + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 5); } - return 0; } -inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype) +inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; @@ -2480,44 +2434,31 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *s return 0; switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - - case RTLLIB_STYPE_ASSOC_RESP: - case RTLLIB_STYPE_REASSOC_RESP: - - if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) - return 1; - - break; - - case RTLLIB_STYPE_ASSOC_REQ: - case RTLLIB_STYPE_REASSOC_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) - - rtllib_rx_assoc_rq(ieee, skb); - break; - - case RTLLIB_STYPE_AUTH: - - rtllib_rx_auth(ieee, skb, rx_stats); - - break; - case RTLLIB_STYPE_DISASSOC: - case RTLLIB_STYPE_DEAUTH: - - rtllib_rx_deauth(ieee, skb); - - break; - - case RTLLIB_STYPE_MANAGE_ACT: - rtllib_process_action(ieee,skb); - break; - default: - return -1; - break; + case RTLLIB_STYPE_ASSOC_RESP: + case RTLLIB_STYPE_REASSOC_RESP: + if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) + return 1; + break; + case RTLLIB_STYPE_ASSOC_REQ: + case RTLLIB_STYPE_REASSOC_REQ: + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->iw_mode == IW_MODE_MASTER) + rtllib_rx_assoc_rq(ieee, skb); + break; + case RTLLIB_STYPE_AUTH: + rtllib_rx_auth(ieee, skb, rx_stats); + break; + case RTLLIB_STYPE_DISASSOC: + case RTLLIB_STYPE_DEAUTH: + rtllib_rx_deauth(ieee, skb); + break; + case RTLLIB_STYPE_MANAGE_ACT: + rtllib_process_action(ieee, skb); + break; + default: + return -1; + break; } - return 0; } @@ -2548,43 +2489,43 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) struct cb_desc *tcb_desc = NULL; unsigned long queue_len = 0; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd parm 0, no tx mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); /* update the tx status */ - tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if (tcb_desc->bMulticast) { + tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + + MAX_DEV_ADDR_SIZE); + if (tcb_desc->bMulticast) ieee->stats.multicast++; - } - /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ + /* if xmit available, just xmit it immediately, else just insert it to + * the wait queue */ for (i = 0; i < txb->nr_frags; i++) { queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); if ((queue_len != 0) ||\ - (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ - (ieee->queue_stop)) { + (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || + (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need * to check it any more. * */ if (queue_len < 200) - { - skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); - }else{ + skb_queue_tail(&ieee->skb_waitQ[queue_index], + txb->fragments[i]); + else kfree_skb(txb->fragments[i]); - } - }else{ + } else { ieee->softmac_data_hard_start_xmit( txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); } } rtllib_txb_free(txb); - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2592,16 +2533,17 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) void rtllib_resume_tx(struct rtllib_device *ieee) { int i; - for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; + i++) { - if (ieee->queue_stop){ + if (ieee->queue_stop) { ieee->tx_pending.frag = i; return; - }else{ + } else { ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); ieee->stats.tx_packets++; } } @@ -2615,14 +2557,14 @@ void rtllib_reset_queue(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); init_mgmt_queue(ieee); - if (ieee->tx_pending.txb){ + if (ieee->tx_pending.txb) { rtllib_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2633,13 +2575,14 @@ void rtllib_wake_queue(struct rtllib_device *ieee) struct sk_buff *skb; struct rtllib_hdr_3addr *header; - spin_lock_irqsave(&ieee->lock,flags); - if (! ieee->queue_stop) goto exit; + spin_lock_irqsave(&ieee->lock, flags); + if (!ieee->queue_stop) + goto exit; ieee->queue_stop = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { + while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) { header = (struct rtllib_hdr_3addr *) skb->data; @@ -2650,26 +2593,27 @@ void rtllib_wake_queue(struct rtllib_device *ieee) else ieee->seq_ctrl[0]++; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } } if (!ieee->queue_stop && ieee->tx_pending.txb) rtllib_resume_tx(ieee); - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) { ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } -exit : - spin_unlock_irqrestore(&ieee->lock,flags); +exit: + spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_stop_queue(struct rtllib_device *ieee) { - if (! netif_queue_stopped(ieee->dev)){ + if (!netif_queue_stopped(ieee->dev)) { netif_stop_queue(ieee->dev); ieee->softmac_stats.swtxstop++; } @@ -2680,8 +2624,8 @@ void rtllib_stop_queue(struct rtllib_device *ieee) void rtllib_stop_all_queues(struct rtllib_device *ieee) { unsigned int i; - for (i=0; i < ieee->dev->num_tx_queues; i++) - netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; + for (i = 0; i < ieee->dev->num_tx_queues; i++) + netdev_get_tx_queue(ieee->dev, i)->trans_start = jiffies; netif_tx_stop_all_queues(ieee->dev); } @@ -2708,12 +2652,13 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) { ieee->assoc_id = 1; - if (ieee->current_network.ssid_len == 0){ + if (ieee->current_network.ssid_len == 0) { strncpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); + ieee->current_network.ssid_len = + strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2733,7 +2678,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ - if (ieee->raw_tx){ + if (ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -2743,7 +2688,8 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) void rtllib_start_ibss_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. @@ -2751,14 +2697,14 @@ void rtllib_start_ibss_wq(void *data) * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - if (!ieee->proto_started){ - printk("==========oh driver down return\n"); + if (!ieee->proto_started) { + printk(KERN_INFO "==========oh driver down return\n"); return; } down(&ieee->wx_sem); - if (ieee->current_network.ssid_len == 0){ - strcpy(ieee->current_network.ssid,RTLLIB_DEFAULT_TX_ESSID); + if (ieee->current_network.ssid_len == 0) { + strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2787,47 +2733,50 @@ void rtllib_start_ibss_wq(void *data) rtllib_start_scan_syncro(ieee, 0); /* the network definitively is not here.. create a new cell */ - if (ieee->state == RTLLIB_NOLINK){ - printk("creating new IBSS cell\n"); + if (ieee->state == RTLLIB_NOLINK) { + printk(KERN_INFO "creating new IBSS cell\n"); ieee->current_network.channel = ieee->IbssStartChnl; if (!ieee->wap_set) rtllib_randomize_cell(ieee); - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { ieee->current_network.rates_len = 4; - ieee->current_network.rates[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; - ieee->current_network.rates[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; - ieee->current_network.rates[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; - ieee->current_network.rates[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; + ieee->current_network.rates[0] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; + ieee->current_network.rates[1] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; + ieee->current_network.rates[2] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; + ieee->current_network.rates[3] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; - }else + } else ieee->current_network.rates_len = 0; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { ieee->current_network.rates_ex_len = 8; - /*ieee->current_network.rates_ex[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;*/ - - ieee->current_network.rates_ex[0] = RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_OFDM_RATE_54MB; + ieee->current_network.rates_ex[0] = + RTLLIB_OFDM_RATE_6MB; + ieee->current_network.rates_ex[1] = + RTLLIB_OFDM_RATE_9MB; + ieee->current_network.rates_ex[2] = + RTLLIB_OFDM_RATE_12MB; + ieee->current_network.rates_ex[3] = + RTLLIB_OFDM_RATE_18MB; + ieee->current_network.rates_ex[4] = + RTLLIB_OFDM_RATE_24MB; + ieee->current_network.rates_ex[5] = + RTLLIB_OFDM_RATE_36MB; + ieee->current_network.rates_ex[6] = + RTLLIB_OFDM_RATE_48MB; + ieee->current_network.rates_ex[7] = + RTLLIB_OFDM_RATE_54MB; ieee->rate = 108; - }else{ + } else { ieee->current_network.rates_ex_len = 0; ieee->rate = 22; } @@ -2839,20 +2788,21 @@ void rtllib_start_ibss_wq(void *data) ieee->current_network.capability = WLAN_CAPABILITY_IBSS; } - printk("%s(): ieee->mode = %d\n", __func__, ieee->mode); + printk(KERN_INFO "%s(): ieee->mode = %d\n", __func__, ieee->mode); if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G)) HTUseDefaultSetting(ieee); else ieee->pHTInfo->bCurrentHTSupport = false; - ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&ieee->state)); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&ieee->state)); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev,LED_CTL_LINK); + ieee->LedControlHandler(ieee->dev, LED_CTL_LINK); rtllib_start_send_beacons(ieee); @@ -2875,12 +2825,9 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee) void rtllib_start_bss(struct rtllib_device *ieee) { unsigned long flags; - if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { - if (! ieee->bGlobalDomain) - { + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { + if (!ieee->bGlobalDomain) return; - } } /* check if we have already found the net we * are interested in (if any). @@ -2898,15 +2845,15 @@ void rtllib_start_bss(struct rtllib_device *ieee) */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == RTLLIB_NOLINK) { + if (ieee->state == RTLLIB_NOLINK) rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_link_change_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, link_change_wq); ieee->link_change(ieee->dev); } /* called only in userspace context */ @@ -2931,7 +2878,8 @@ void rtllib_disassociate(struct rtllib_device *ieee) void rtllib_associate_retry_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, associate_retry_wq); unsigned long flags; down(&ieee->wx_sem); @@ -2962,9 +2910,7 @@ void rtllib_associate_retry_wq(void *data) spin_lock_irqsave(&ieee->lock, flags); if (ieee->state == RTLLIB_NOLINK) - { rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); ieee->beinretry = false; @@ -2974,7 +2920,7 @@ exit: struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) { - u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sk_buff *skb; struct rtllib_probe_response *b; @@ -3010,11 +2956,12 @@ struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee) return skb; } -void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) +void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, + u8 shutdown) { rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); - rtllib_stop_protocol(ieee,shutdown); + rtllib_stop_protocol(ieee, shutdown); up(&ieee->wx_sem); } @@ -3024,8 +2971,8 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (!ieee->proto_started) return; - if (shutdown){ - ieee->proto_started = 0; + if (shutdown) { + ieee->proto_started = 0; ieee->proto_stoppping = 1; if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -3041,26 +2988,22 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) ieee->state = RTLLIB_NOLINK; - if (ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { if (ieee->iw_mode == IW_MODE_INFRA) - SendDisassociation(ieee,1,deauth_lv_ss); + SendDisassociation(ieee, 1, deauth_lv_ss); rtllib_disassociate(ieee); } - if (shutdown){ + if (shutdown) { RemoveAllTS(ieee); ieee->proto_stoppping = 0; } - if (ieee->assocreq_ies) { - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - ieee->assocreq_ies_len = 0; - } - if (ieee->assocresp_ies) { - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - ieee->assocresp_ies_len = 0; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; + ieee->assocreq_ies_len = 0; + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + ieee->assocresp_ies_len = 0; } void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) @@ -3087,7 +3030,7 @@ void rtllib_start_protocol(struct rtllib_device *ieee) ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); ieee->current_network.channel = ch; } @@ -3130,20 +3073,19 @@ void rtllib_softmac_init(struct rtllib_device *ieee) memset(&ieee->current_network, 0, sizeof(struct rtllib_network)); ieee->state = RTLLIB_NOLINK; - for (i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } + for (i = 0; i < 5; i++) + ieee->seq_ctrl[i] = 0; ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); if (!ieee->pDot11dInfo) RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); ieee->LinkDetectInfo.SlotIndex = 0; ieee->LinkDetectInfo.SlotNum = 2; - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - ieee->LinkDetectInfo.NumTxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod=0; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; ieee->bIsAggregateFrame = false; ieee->assoc_id = 0; ieee->queue_stop = 0; @@ -3158,13 +3100,13 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->ps = RTLLIB_PS_DISABLED; ieee->sta_sleep = LPS_IS_WAKE; - ieee->Regdot11HTOperationalRateSet[0]= 0xff; - ieee->Regdot11HTOperationalRateSet[1]= 0xff; - ieee->Regdot11HTOperationalRateSet[4]= 0x01; + ieee->Regdot11HTOperationalRateSet[0] = 0xff; + ieee->Regdot11HTOperationalRateSet[1] = 0xff; + ieee->Regdot11HTOperationalRateSet[4] = 0x01; - ieee->Regdot11TxHTOperationalRateSet[0]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[1]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[4]= 0x01; + ieee->Regdot11TxHTOperationalRateSet[0] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[1] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[4] = 0x01; ieee->FirstIe_InScan = false; ieee->actscanning = false; @@ -3191,18 +3133,26 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->wq = create_workqueue(DRV_NAME); - INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); - INIT_WORK_RSL(&ieee->associate_complete_wq, (void*)rtllib_associate_complete_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, (void*)rtllib_associate_procedure_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,(void*)rtllib_softmac_scan_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,(void*)rtllib_softmac_hint11d_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void*)rtllib_associate_retry_wq,ieee); - INIT_WORK_RSL(&ieee->wx_sync_scan_wq,(void*)rtllib_wx_sync_scan_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->link_change_wq, + (void *)rtllib_link_change_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq, + (void *)rtllib_start_ibss_wq, ieee); + INIT_WORK_RSL(&ieee->associate_complete_wq, + (void *)rtllib_associate_complete_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, + (void *)rtllib_associate_procedure_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq, + (void *)rtllib_softmac_scan_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq, + (void *)rtllib_softmac_hint11d_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, + (void *)rtllib_associate_retry_wq, ieee); + INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq, + ieee); sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - sema_init(&ieee->ips_sem,1); + sema_init(&ieee->ips_sem, 1); spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); @@ -3216,8 +3166,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { down(&ieee->wx_sem); - if (NULL != ieee->pDot11dInfo) - { + if (NULL != ieee->pDot11dInfo) { kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; } @@ -3229,8 +3178,8 @@ void rtllib_softmac_free(struct rtllib_device *ieee) } /******************************************************** - * Start of WPA code. * - * this is stolen from the ipw2200 driver * + * Start of WPA code. * + * this is stolen from the ipw2200 driver * ********************************************************/ @@ -3238,14 +3187,15 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ - printk("%s WPA\n",value ? "enabling" : "disabling"); + printk(KERN_INFO "%s WPA\n", value ? "enabling" : "disabling"); ieee->wpa_enabled = value; memset(ieee->ap_mac_addr, 0, 6); return 0; } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, int wpa_ie_len) +void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3268,7 +3218,7 @@ static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason) break; default: - printk("Unknown MLME request: %d\n", command); + printk(KERN_INFO "Unknown MLME request: %d\n", command); ret = -EOPNOTSUPP; } @@ -3319,12 +3269,11 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) sec.auth_mode = WLAN_AUTH_SHARED_KEY; ieee->open_wep = 0; ieee->auth_mode = 1; - } else if (value & AUTH_ALG_OPEN_SYSTEM){ + } else if (value & AUTH_ALG_OPEN_SYSTEM) { sec.auth_mode = WLAN_AUTH_OPEN; ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (value & AUTH_ALG_LEAP){ + } else if (value & AUTH_ALG_LEAP) { sec.auth_mode = WLAN_AUTH_LEAP >> 6; ieee->open_wep = 1; ieee->auth_mode = 2; @@ -3339,7 +3288,7 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) { - int ret=0; + int ret = 0; unsigned long flags; switch (name) { @@ -3348,11 +3297,11 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures=value; + ieee->tkip_countermeasures = value; break; - case IEEE_PARAM_DROP_UNENCRYPTED: - { + case IEEE_PARAM_DROP_UNENCRYPTED: + { /* HACK: * * wpa_supplicant calls set_wpa_enabled when the driver @@ -3375,8 +3324,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) if (!value) { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_0; - } - else { + } else { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } @@ -3386,7 +3334,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) } case IEEE_PARAM_PRIVACY_INVOKED: - ieee->privacy_invoked=value; + ieee->privacy_invoked = value; break; case IEEE_PARAM_AUTH_ALGS: @@ -3394,15 +3342,15 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_IEEE_802_1X: - ieee->ieee802_1x=value; + ieee->ieee802_1x = value; break; case IEEE_PARAM_WPAX_SELECT: - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); + spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags); + spin_unlock_irqrestore(&ieee->wpax_suitlist_lock, flags); break; default: - printk("Unknown WPA param: %d\n",name); + printk(KERN_INFO "Unknown WPA param: %d\n", name); ret = -EOPNOTSUPP; } @@ -3411,7 +3359,8 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) /* implementation borrowed from hostap driver */ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, - struct ieee_param *param, int param_len, u8 is_mesh) + struct ieee_param *param, int param_len, + u8 is_mesh) { int ret = 0; struct rtllib_crypto_ops *ops; @@ -3427,7 +3376,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, if (param_len != (int) ((char *) param->u.crypt.key - (char *) param) + param->u.crypt.key_len) { - printk("Len mismatch %d, %d\n", param_len, + printk(KERN_INFO "Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); return -EINVAL; } @@ -3470,7 +3419,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ops = rtllib_get_crypto_ops(param->u.crypt.alg); } if (ops == NULL) { - printk("unknown crypto alg '%s'\n", param->u.crypt.alg); + printk(KERN_INFO "unknown crypto alg '%s'\n", + param->u.crypt.alg); param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; ret = -EINVAL; goto done; @@ -3506,7 +3456,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, (*crypt)->ops->set_key(param->u.crypt.key, param->u.crypt.key_len, param->u.crypt.seq, (*crypt)->priv) < 0) { - printk("key setting failed\n"); + printk(KERN_INFO "key setting failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; ret = -EINVAL; goto done; @@ -3551,7 +3501,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(ieee->dev)) { - printk("reset_port failed\n"); + printk(KERN_INFO "reset_port failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; return -EINVAL; } @@ -3559,7 +3509,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, return ret; } -inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3567,13 +3517,13 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); + disauth = (struct rtllib_disauth *) skb_put(skb, + sizeof(struct rtllib_disauth)); disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); disauth->header.duration_id = 0; @@ -3585,7 +3535,7 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, return skb; } -inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3593,13 +3543,13 @@ inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); + disass = (struct rtllib_disassoc *) skb_put(skb, + sizeof(struct rtllib_disassoc)); disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); disass->header.duration_id = 0; @@ -3616,36 +3566,36 @@ void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; - if (deauth) { - skb = rtllib_disauth_skb(beacon,ieee,asRsn); - } else { - skb = rtllib_disassociate_skb(beacon,ieee,asRsn); - } + if (deauth) + skb = rtllib_disauth_skb(beacon, ieee, asRsn); + else + skb = rtllib_disassociate_skb(beacon, ieee, asRsn); - if (skb){ + if (skb) softmac_mgmt_xmit(skb, ieee); - } } u8 rtllib_ap_sec_type(struct rtllib_device *ieee) { - static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; + static u8 ccmp_ie[4] = {0x00, 0x50, 0xf2, 0x04}; static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; - int wpa_ie_len= ieee->wpa_ie_len; - struct rtllib_crypt_data* crypt; + int wpa_ie_len = ieee->wpa_ie_len; + struct rtllib_crypt_data *crypt; int encrypt; crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\ - (ieee->host_encrypt && crypt && crypt->ops && \ - (0 == strcmp(crypt->ops->name,"WEP"))); + encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) + || (ieee->host_encrypt && crypt && crypt->ops && + (0 == strcmp(crypt->ops->name, "WEP"))); /* simply judge */ if (encrypt && (wpa_ie_len == 0)) { return SEC_ALG_WEP; } else if ((wpa_ie_len != 0)) { - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || - ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) + if (((ieee->wpa_ie[0] == 0xdd) && + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || + ((ieee->wpa_ie[0] == 0x30) && + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4)))) return SEC_ALG_CCMP; else return SEC_ALG_TKIP; @@ -3654,20 +3604,21 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee) } } -int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh) +int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, + u8 is_mesh) { struct ieee_param *param; - int ret=0; + int ret = 0; down(&ieee->wx_sem); - if (p->length < sizeof(struct ieee_param) || !p->pointer){ + if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; } - param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (param == NULL){ + param = kmalloc(p->length, GFP_KERNEL); + if (param == NULL) { ret = -ENOMEM; goto out; } @@ -3678,7 +3629,6 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name, param->u.wpa_param.value); @@ -3698,7 +3648,8 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, break; default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); + printk(KERN_INFO "Unknown WPA supplicant request: %d\n", + param->cmd); ret = -EOPNOTSUPP; break; } @@ -3713,8 +3664,7 @@ out: return ret; } -void -rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) +void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib) { u8 OpMode; u8 i; @@ -3722,26 +3672,25 @@ rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i]= 0x55; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x55; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); OpMode = RT_OP_MODE_NO_LINK; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode); rtllib_stop_send_beacons(rtllib); bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); notify_wx_assoc_event(rtllib); } -void -rtllib_MlmeDisassociateRequest( - struct rtllib_device* rtllib, - u8* asSta, - u8 asRsn - ) +void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, + u8 asRsn) { u8 i; u8 OpMode; @@ -3749,17 +3698,19 @@ rtllib_MlmeDisassociateRequest( RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid,asSta,6) == 0) - { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i] = 0x22; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x22; OpMode = RT_OP_MODE_NO_LINK; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&OpMode) ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&OpMode)); rtllib_disassociate(rtllib); - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); } @@ -3767,40 +3718,31 @@ rtllib_MlmeDisassociateRequest( void rtllib_MgntDisconnectAP( - struct rtllib_device* rtllib, + struct rtllib_device *rtllib, u8 asRsn ) { bool bFilterOutNonAssociatedBSSID = false; bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); - rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid, + asRsn); rtllib->state = RTLLIB_NOLINK; } -bool -rtllib_MgntDisconnect( - struct rtllib_device* rtllib, - u8 asRsn -) +bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) { if (rtllib->ps != RTLLIB_PS_DISABLED) - { - rtllib->sta_wake_up(rtllib->dev); - } + rtllib->sta_wake_up(rtllib->dev); - if ( rtllib->state == RTLLIB_LINKED ) - { - if ( rtllib->iw_mode == IW_MODE_ADHOC ) - { + if (rtllib->state == RTLLIB_LINKED) { + if (rtllib->iw_mode == IW_MODE_ADHOC) rtllib_MgntDisconnectIBSS(rtllib); - } - if ( rtllib->iw_mode == IW_MODE_INFRA ) - { + if (rtllib->iw_mode == IW_MODE_INFRA) rtllib_MgntDisconnectAP(rtllib, asRsn); - } } @@ -3816,10 +3758,12 @@ void notify_wx_assoc_event(struct rtllib_device *ieee) wrqu.ap_addr.sa_family = ARPHRD_ETHER; if (ieee->state == RTLLIB_LINKED) - memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - else{ + memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, + ETH_ALEN); + else { - printk("%s(): Tell user space disconnected\n",__func__); + printk(KERN_INFO "%s(): Tell user space disconnected\n", + __func__); memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); } wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); From a44be772cb2beb1dd93102ba4f6b5e652895f783 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:27 -0500 Subject: [PATCH 0556/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XV This patch removes all the errors and warnings generated by checkpatch -f for rtllib_softmac_wx.c.. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 177 ++++++++++--------- 1 file changed, 90 insertions(+), 87 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index e6702a14165..22988fbd444 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -31,11 +31,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->iw_mode == IW_MODE_INFRA) { ret = 0; goto out; } @@ -56,11 +56,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, } } - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1) { ret = -EOPNOTSUPP; goto out; - }else { /* Set the channel */ + } else { /* Set the channel */ if (ieee->active_channel_map[fwrq->m] != 1) { ret = -EINVAL; @@ -69,11 +69,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - if (ieee->state == RTLLIB_LINKED){ - - rtllib_stop_send_beacons(ieee); - rtllib_start_send_beacons(ieee); + if (ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) + if (ieee->state == RTLLIB_LINKED) { + rtllib_stop_send_beacons(ieee); + rtllib_start_send_beacons(ieee); } } @@ -88,11 +88,12 @@ int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; if (ieee->current_network.channel == 0) return -1; - fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * 100000; + fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * + 100000; fwrq->e = 1; return 0; } @@ -133,7 +134,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, { int ret = 0; - u8 zero[] = {0,0,0,0,0,0}; + u8 zero[] = {0, 0, 0, 0, 0, 0}; unsigned long flags; short ifup = ieee->proto_started; @@ -143,28 +144,28 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, down(&ieee->wx_sem); /* use ifconfig hw ether */ - if (ieee->iw_mode == IW_MODE_MASTER){ + if (ieee->iw_mode == IW_MODE_MASTER) { ret = -1; goto out; } - if (temp->sa_family != ARPHRD_ETHER){ + if (temp->sa_family != ARPHRD_ETHER) { ret = -EINVAL; goto out; } - if (memcmp(temp->sa_data, zero,ETH_ALEN) == 0){ - spin_lock_irqsave(&ieee->lock, flags); - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = 0; - spin_unlock_irqrestore(&ieee->lock, flags); - ret = -1; - goto out; - } + if (memcmp(temp->sa_data, zero, ETH_ALEN) == 0) { + spin_lock_irqsave(&ieee->lock, flags); + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ieee->wap_set = 0; + spin_unlock_irqrestore(&ieee->lock, flags); + ret = -1; + goto out; + } if (ifup) - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise @@ -173,7 +174,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, ieee->cannot_notify = false; memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = (memcmp(temp->sa_data, zero,ETH_ALEN)!=0); + ieee->wap_set = (memcmp(temp->sa_data, zero, ETH_ALEN) != 0); spin_unlock_irqrestore(&ieee->lock, flags); @@ -184,9 +185,10 @@ out: return ret; } - int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) +int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { - int len,ret = 0; + int len, ret = 0; unsigned long flags; if (ieee->iw_mode == IW_MODE_MONITOR) @@ -196,20 +198,20 @@ out: spin_lock_irqsave(&ieee->lock, flags); if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0) { ret = -1; goto out; } if (ieee->state != RTLLIB_LINKED && ieee->state != RTLLIB_LINKED_SCANNING && - ieee->ssid_set == 0){ + ieee->ssid_set == 0) { ret = -1; goto out; } len = ieee->current_network.ssid_len; wrqu->essid.length = len; - strncpy(b,ieee->current_network.ssid,len); + strncpy(b, ieee->current_network.ssid, len); wrqu->essid.flags = 1; out: @@ -235,7 +237,8 @@ int rtllib_wx_get_rate(struct rtllib_device *ieee, union iwreq_data *wrqu, char *extra) { u32 tmp_rate = 0; - tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); + tmp_rate = TxCountToDataRate(ieee, + ieee->softmac_stats.CurrentShowTxate); wrqu->bitrate.value = tmp_rate * 500000; return 0; @@ -248,8 +251,7 @@ int rtllib_wx_set_rts(struct rtllib_device *ieee, { if (wrqu->rts.disabled || !wrqu->rts.fixed) ieee->rts = DEFAULT_RTS_THRESHOLD; - else - { + else { if (wrqu->rts.value < MIN_RTS_THRESHOLD || wrqu->rts.value > MAX_RTS_THRESHOLD) return -EINVAL; @@ -293,17 +295,17 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, if (wrqu->mode == IW_MODE_MONITOR) { ieee->dev->type = ARPHRD_IEEE80211; - rtllib_EnableNetMonitorMode(ieee->dev,false); + rtllib_EnableNetMonitorMode(ieee->dev, false); } else { ieee->dev->type = ARPHRD_ETHER; if (ieee->iw_mode == IW_MODE_MONITOR) - rtllib_DisableNetMonitorMode(ieee->dev,false); + rtllib_DisableNetMonitorMode(ieee->dev, false); } if (!ieee->proto_started) { ieee->iw_mode = wrqu->mode; } else { - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); ieee->iw_mode = wrqu->mode; rtllib_start_protocol(ieee); } @@ -315,14 +317,15 @@ out: void rtllib_wx_sync_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, wx_sync_scan_wq); short chan; - enum ht_extchnl_offset chan_offset=0; - enum ht_channel_width bandwidth=0; + enum ht_extchnl_offset chan_offset = 0; + enum ht_channel_width bandwidth = 0; int b40M = 0; - static int count = 0; + static int count; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_start_scan_syncro(ieee, 0); goto out; } @@ -346,15 +349,18 @@ void rtllib_wx_sync_scan_wq(void *data) msleep(50); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_BACKUP); - if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && + ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; - RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } + RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", + chan_offset, bandwidth); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } rtllib_start_scan_syncro(ieee, 0); @@ -372,7 +378,7 @@ void rtllib_wx_sync_scan_wq(void *data) } if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_RESTORE); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); @@ -381,9 +387,9 @@ void rtllib_wx_sync_scan_wq(void *data) rtllib_sta_ps_send_null_frame(ieee, 0); if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || - ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } if (ieee->data_hard_resume) @@ -407,12 +413,12 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) { ret = -1; goto out; } - if ( ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { queue_work_rsl(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; @@ -424,11 +430,11 @@ out: } int rtllib_wx_set_essid(struct rtllib_device *ieee, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) { - int ret=0,len,i; + int ret = 0, len, i; short proto_started; unsigned long flags; @@ -437,27 +443,28 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, proto_started = ieee->proto_started; - len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : + IW_ESSID_MAX_SIZE; - if (len > IW_ESSID_MAX_SIZE){ - ret= -E2BIG; + if (len > IW_ESSID_MAX_SIZE) { + ret = -E2BIG; goto out; } - if (ieee->iw_mode == IW_MODE_MONITOR){ - ret= -1; + if (ieee->iw_mode == IW_MODE_MONITOR) { + ret = -1; goto out; } - for (i=0; icurrent_network.ssid_len = len; ieee->cannot_notify = false; ieee->ssid_set = 1; - } - else{ + } else { ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; @@ -485,16 +491,16 @@ out: return ret; } - int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) +int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { wrqu->mode = ieee->iw_mode; return 0; } - int rtllib_wx_set_rawtx(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +int rtllib_wx_set_rawtx(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int *parms = (int *)extra; @@ -511,9 +517,8 @@ out: printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); - if (ieee->iw_mode == IW_MODE_MONITOR) - { - if (prev == 0 && ieee->raw_tx){ + if (ieee->iw_mode == IW_MODE_MONITOR) { + if (prev == 0 && ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -552,33 +557,30 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, { int ret = 0; - if ( - (!ieee->sta_wake_up) || - (!ieee->enter_sleep_state) || - (!ieee->ps_is_queue_empty)){ - - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): PS mode is tryied to be use but driver missed a callback\n\n",__func__); - + if ((!ieee->sta_wake_up) || + (!ieee->enter_sleep_state) || + (!ieee->ps_is_queue_empty)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tryied to be use " + "but driver missed a callback\n\n", __func__); return -1; } down(&ieee->wx_sem); - if (wrqu->power.disabled){ - RT_TRACE(COMP_DBG, "===>%s(): power disable\n",__func__); + if (wrqu->power.disabled) { + RT_TRACE(COMP_DBG, "===>%s(): power disable\n", __func__); ieee->ps = RTLLIB_PS_DISABLED; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { ieee->ps_timeout = wrqu->power.value / 1000; - RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n",__func__,ieee->ps_timeout); + RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n", __func__, + ieee->ps_timeout); } - if (wrqu->power.flags & IW_POWER_PERIOD) { - + if (wrqu->power.flags & IW_POWER_PERIOD) ieee->ps_period = wrqu->power.value / 1000; - } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = RTLLIB_PS_UNICAST; @@ -609,7 +611,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret =0; + int ret = 0; down(&ieee->wx_sem); @@ -628,7 +630,8 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, wrqu->power.value = ieee->ps_period * 1000; } - if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) + if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == + (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) wrqu->power.flags |= IW_POWER_ALL_R; else if (ieee->ps & RTLLIB_PS_MBCAST) wrqu->power.flags |= IW_POWER_MULTICAST_R; From f38d223b692742e77c70033d145245615c8f3aa5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:28 -0500 Subject: [PATCH 0557/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVI This patch removes all the errors and most of the warnings generated by checkpatch -f for rtllib_softmac_tx.c.. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_tx.c | 512 ++++++++++++++------------- 1 file changed, 262 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 134e69f4ee5..f038aa93083 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -67,21 +67,21 @@ bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------| desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep | - | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | + | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | '-----------------------------------------------------------------------------------------' - /\ - | -802.11 Data Frame | - ,--------- 'ctrl' expands to >-----------' - | + /\ + | +802.11 Data Frame | + ,--------- 'ctrl' expands to >-----------' + | ,--'---,-------------------------------------------------------------. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `--------------------------------------------------| |------' -Total: 28 non-data bytes `----.----' - | + | | tion | (BSSID) | | | ence | data | | + `--------------------------------------------------| |------' +Total: 28 non-data bytes `----.----' + | .- 'Frame data' expands to <---------------------------' | V @@ -89,11 +89,11 @@ Total: 28 non-data bytes `----.----' Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | |------|------|---------|----------|------|---------| Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | - | DSAP | SSAP | | | | Packet | - | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | - `-----------------------------------------| | -Total: 8 non-data bytes `----.----' - | + | DSAP | SSAP | | | | Packet | + | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | + `-----------------------------------------| | +Total: 8 non-data bytes `----.----' + | .- 'IP Packet' expands, if WEP enabled, to <--' | V @@ -112,7 +112,7 @@ Total: 8 non-data bytes Bytes | 6 | 6 | 2 | Variable | 4 | |-------|-------|------|-----------|------| Desc. | Dest. | Source| Type | IP Packet | fcs | - | MAC | MAC | | | | + | MAC | MAC | | | | `-----------------------------------------' Total: 18 non-data bytes @@ -130,19 +130,19 @@ payload of each frame is reduced to 492 bytes. * * ,- skb->data * | -* | ETHERNET HEADER ,-<-- PAYLOAD -* | | 14 bytes from skb->data +* | ETHERNET HEADER ,-<-- PAYLOAD +* | | 14 bytes from skb->data * | 2 bytes for Type --> ,T. | (sizeof ethhdr) -* | | | | +* | | | | * |,-Dest.--. ,--Src.---. | | | * | 6 bytes| | 6 bytes | | | | -* v | | | | | | -* 0 | v 1 | v | v 2 +* v | | | | | | +* 0 | v 1 | v | v 2 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 -* ^ | ^ | ^ | -* | | | | | | -* | | | | `T' <---- 2 bytes for Type -* | | | | +* ^ | ^ | ^ | +* | | | | | | +* | | | | `T' <---- 2 bytes for Type +* | | | | * | | '---SNAP--' <-------- 6 bytes for SNAP * | | * `-IV--' <-------------------- 4 bytes for IV (WEP) @@ -177,19 +177,16 @@ inline int rtllib_put_snap(u8 *data, u16 h_proto) return SNAP_SIZE + sizeof(u16); } -int rtllib_encrypt_fragment( - struct rtllib_device *ieee, - struct sk_buff *frag, - int hdr_len) +int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag, + int hdr_len) { - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; int res; crypt = ieee->crypt[ieee->tx_keyidx]; - if (!(crypt && crypt->ops)) - { - printk("=========>%s(), crypt is null\n", __func__); + if (!(crypt && crypt->ops)) { + printk(KERN_INFO "=========>%s(), crypt is null\n", __func__); return -1; } /* To encrypt, frame format is: @@ -216,20 +213,20 @@ int rtllib_encrypt_fragment( } -void rtllib_txb_free(struct rtllib_txb *txb) { +void rtllib_txb_free(struct rtllib_txb *txb) +{ if (unlikely(!txb)) return; kfree(txb); } struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) + int gfp_mask) { struct rtllib_txb *txb; int i; - txb = kmalloc( - sizeof(struct rtllib_txb) + (sizeof(u8*) * nr_frags), - gfp_mask); + txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), + gfp_mask); if (!txb) return NULL; @@ -286,23 +283,25 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) +void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; - struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; + struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr *)skb->data; - if (rtllib_act_scanning(ieee,false)) + if (rtllib_act_scanning(ieee, false)) return; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (!IsQoSDataFrame(skb->data)) return; - if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1)) + if (is_multicast_ether_addr(hdr->addr1) || + is_broadcast_ether_addr(hdr->addr1)) return; - if (tcb_desc->bdhcp || ieee->CntAfterLink<2) + if (tcb_desc->bdhcp || ieee->CntAfterLink < 2) return; if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) @@ -310,22 +309,25 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) return; - if (pHTInfo->bCurrentAMPDUEnable){ - if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ - printk("%s: can't get TS\n", __func__); + if (pHTInfo->bCurrentAMPDUEnable) { + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, + skb->priority, TX_DIR, true)) { + printk(KERN_INFO "%s: can't get TS\n", __func__); return; } - if (pTxTs->TxAdmittedBARecord.bValid == false){ - if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA)) { + if (pTxTs->TxAdmittedBARecord.bValid == false) { + if (ieee->wpa_ie_len && (ieee->pairwise_key_type == + KEY_TYPE_NA)) { ; - } else if (tcb_desc->bdhcp == 1){ + } else if (tcb_desc->bdhcp == 1) { ; - } else if (!pTxTs->bDisable_AddBa){ + } else if (!pTxTs->bDisable_AddBa) { TsStartAddBaProcess(ieee, pTxTs); } goto FORCED_AGG_SETTING; } else if (pTxTs->bUsingBa == false) { - if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) + if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, + (pTxTs->TxCurSeq+1)%4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; @@ -338,81 +340,80 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st } FORCED_AGG_SETTING: switch (pHTInfo->ForcedAMPDUMode) { - case HT_AGG_AUTO: - break; + case HT_AGG_AUTO: + break; - case HT_AGG_FORCE_ENABLE: - tcb_desc->bAMPDUEnable = true; - tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; - tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; - break; + case HT_AGG_FORCE_ENABLE: + tcb_desc->bAMPDUEnable = true; + tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; + tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; + break; - case HT_AGG_FORCE_DISABLE: - tcb_desc->bAMPDUEnable = false; - tcb_desc->ampdu_density = 0; - tcb_desc->ampdu_factor = 0; - break; - - } - return; -} - -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) -{ - tcb_desc->bUseShortPreamble = false; - if (tcb_desc->data_rate == 2) - { - return; - } - else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - tcb_desc->bUseShortPreamble = true; + case HT_AGG_FORCE_DISABLE: + tcb_desc->bAMPDUEnable = false; + tcb_desc->ampdu_density = 0; + tcb_desc->ampdu_factor = 0; + break; } return; } -extern void -rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) +extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) +{ + tcb_desc->bUseShortPreamble = false; + if (tcb_desc->data_rate == 2) + return; + else if (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE) + tcb_desc->bUseShortPreamble = true; + return; +} + +extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bUseShortGI = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; - if (pHTInfo->bForcedShortGI) - { + if (pHTInfo->bForcedShortGI) { tcb_desc->bUseShortGI = true; return; } - if ((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz) + if ((pHTInfo->bCurBW40MHz == true) && pHTInfo->bCurShortGI40MHz) tcb_desc->bUseShortGI = true; - else if ((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz) + else if ((pHTInfo->bCurBW40MHz == false) && pHTInfo->bCurShortGI20MHz) tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device* ieee, struct cb_desc *tcb_desc) +void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bPacketBW = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (tcb_desc->bMulticast || tcb_desc->bBroadcast) return; - if ((tcb_desc->data_rate & 0x80)==0) + if ((tcb_desc->data_rate & 0x80) == 0) return; - if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) + if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && + !ieee->bandwidth_auto_switch.bforced_tx20Mhz) tcb_desc->bPacketBW = true; return; } -void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc, struct sk_buff* skb) +void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -426,77 +427,58 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc if (is_broadcast_ether_addr(skb->data+16)) return; - if (ieee->mode < IEEE_N_24G) - { - if (skb->len > ieee->rts) - { + if (ieee->mode < IEEE_N_24G) { + if (skb->len > ieee->rts) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; - } - else if (ieee->current_network.buseprotection) - { + } else if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; } return; - } - else - { + } else { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - while (true) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) - { + while (true) { + if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; - } - else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE)) - { + } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS | + HT_IOT_ACT_PURE_N_MODE)) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (ieee->current_network.buseprotection) - { + if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) - { + if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { u8 HTOpMode = pHTInfo->CurrentOpMode; - if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || - (!pHTInfo->bCurBW40MHz && HTOpMode == 3) ) - { + if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || + HTOpMode == 3)) || + (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } } - if (skb->len > ieee->rts) - { + if (skb->len > ieee->rts) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } - if (tcb_desc->bAMPDUEnable) - { + if (tcb_desc->bAMPDUEnable) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = false; break; } goto NO_PROTECTION; } - } - if ( 0 ) - { - tcb_desc->bCTSEnable = true; - tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; } if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) tcb_desc->bUseShortPreamble = true; @@ -506,39 +488,40 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc NO_PROTECTION: tcb_desc->bRTSEnable = false; tcb_desc->bCTSEnable = false; - tcb_desc->rts_rate = 0; + tcb_desc->rts_rate = 0; tcb_desc->RTSSC = 0; - tcb_desc->bRTSBW = false; + tcb_desc->bRTSBW = false; } -void rtllib_txrate_selectmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) +void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; if (ieee->bTxUseDriverAssingedRate) tcb_desc->bTxUseDriverAssingedRate = true; - if (!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) - { - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) + if (!tcb_desc->bTxDisableRateFallBack || + !tcb_desc->bTxUseDriverAssingedRate) { + if (ieee->iw_mode == IW_MODE_INFRA || + ieee->iw_mode == IW_MODE_ADHOC) tcb_desc->RATRIndex = 0; } } -u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) +u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *dst) { u16 seqnum = 0; if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) return 0; - if (IsQoSDataFrame(skb->data)) - { + if (IsQoSDataFrame(skb->data)) { struct tx_ts_record *pTS = NULL; - if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + skb->priority, TX_DIR, true)) return 0; - } seqnum = pTS->TxCurSeq; pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; return seqnum; @@ -549,26 +532,27 @@ u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) static int wme_downgrade_ac(struct sk_buff *skb) { switch (skb->priority) { - case 6: - case 7: - skb->priority = 5; /* VO -> VI */ - return 0; - case 4: - case 5: - skb->priority = 3; /* VI -> BE */ - return 0; - case 0: - case 3: - skb->priority = 1; /* BE -> BK */ - return 0; - default: - return -1; + case 6: + case 7: + skb->priority = 5; /* VO -> VI */ + return 0; + case 4: + case 5: + skb->priority = 3; /* VI -> BE */ + return 0; + case 0: + case 3: + skb->priority = 1; /* BE -> BK */ + return 0; + default: + return -1; } } int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); struct rtllib_txb *txb = NULL; struct rtllib_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; @@ -584,25 +568,27 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) }; u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; struct cb_desc *tcb_desc; u8 bIsMulticast = false; u8 IsAmsdu = false; + bool bdhcp = false; - bool bdhcp =false; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother * creating it... */ - if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))|| - ((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { + if ((!ieee->hard_start_xmit && !(ieee->softmac_features & + IEEE_SOFTMAC_TX_QUEUE)) || + ((!ieee->softmac_data_hard_start_xmit && + (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name); goto success; } - if (likely(ieee->raw_tx == 0)){ + if (likely(ieee->raw_tx == 0)) { if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -615,39 +601,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) memset(skb->cb, 0, sizeof(skb->cb)); ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - if (ieee->iw_mode == IW_MODE_MONITOR) - { + if (ieee->iw_mode == IW_MODE_MONITOR) { txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); if (unlikely(!txb)) { - printk(KERN_WARNING "%s: Could not allocate TXB\n", + printk(KERN_WARNING "%s: Could not allocate " + "TXB\n", ieee->dev->name); goto failed; } txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); goto success; } if (skb->len > 282) { if (ETH_P_IP == ether_type) { - const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); + const struct iphdr *ip = (struct iphdr *) + ((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { - struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); - if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || - ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { + struct udphdr *udp; + + udp = (struct udphdr *)((u8 *)ip + + (ip->ihl << 2)); + if (((((u8 *)udp)[1] == 68) && + (((u8 *)udp)[3] == 67)) || + ((((u8 *)udp)[1] == 67) && + (((u8 *)udp)[3] == 68))) { bdhcp = true; ieee->LPSDelayCnt = 200; } } - }else if (ETH_P_ARP == ether_type){ - printk("=================>DHCP Protocol start tx ARP pkt!!\n"); + } else if (ETH_P_ARP == ether_type) { + printk(KERN_INFO "=================>DHCP " + "Protocol start tx ARP pkt!!\n"); bdhcp = true; - ieee->LPSDelayCnt = ieee->current_network.tim.tim_count; - - + ieee->LPSDelayCnt = + ieee->current_network.tim.tim_count; } } @@ -656,13 +649,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; if (!encrypt && ieee->ieee802_1x && - ieee->drop_unencrypted && ether_type != ETH_P_PAE) { + ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + - sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); + sizeof(struct ethhdr) - SNAP_SIZE - + sizeof(u16)); RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", eap_get_type(eap->type)); } @@ -670,7 +664,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - /* Determine total amount of storage required for TXB packets */ + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); if (encrypt) @@ -687,10 +681,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) fc |= RTLLIB_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */ - memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr1, ieee->current_network.bssid, + ETH_ALEN); memcpy(&header.addr2, &src, ETH_ALEN); if (IsAmsdu) - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, + ieee->current_network.bssid, ETH_ALEN); else memcpy(&header.addr3, &dest, ETH_ALEN); } else if (ieee->iw_mode == IW_MODE_ADHOC) { @@ -698,12 +694,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) Addr3 = BSSID */ memcpy(&header.addr1, dest, ETH_ALEN); memcpy(&header.addr2, src, ETH_ALEN); - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, ieee->current_network.bssid, + ETH_ALEN); } - bIsMulticast = is_broadcast_ether_addr(header.addr1) ||is_multicast_ether_addr(header.addr1); + bIsMulticast = is_broadcast_ether_addr(header.addr1) || + is_multicast_ether_addr(header.addr1); - header.frame_ctl = cpu_to_le16(fc); + header.frame_ctl = cpu_to_le16(fc); /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ @@ -718,29 +716,30 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (qos_actived) { hdr_len = RTLLIB_3ADDR_LEN + 2; - /* in case we are a client verify acm is not set for this ac */ - while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { - printk("skb->priority = %x\n", skb->priority); - if (wme_downgrade_ac(skb)) { - break; - } - printk("converted skb->priority = %x\n", skb->priority); - } - qos_ctl |= skb->priority; - header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); + /* in case we are a client verify acm is not set for this ac */ + while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { + printk(KERN_INFO "skb->priority = %x\n", skb->priority); + if (wme_downgrade_ac(skb)) + break; + printk(KERN_INFO "converted skb->priority = %x\n", + skb->priority); + } + qos_ctl |= skb->priority; + header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); } else { hdr_len = RTLLIB_3ADDR_LEN; } /* Determine amount of payload per fragment. Regardless of if - * this stack is providing the full 802.11 header, one will - * eventually be affixed to this fragment -- so we must account for - * it when determining the amount of payload space. */ + * this stack is providing the full 802.11 header, one will + * eventually be affixed to this fragment -- so we must account + * for it when determining the amount of payload space. */ bytes_per_frag = frag_size - hdr_len; if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) bytes_per_frag -= RTLLIB_FCS_LEN; - /* Each fragment may need to have room for encryptiong pre/postfix */ + /* Each fragment may need to have room for encryptiong + * pre/postfix */ if (encrypt) { bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; @@ -754,10 +753,11 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) else bytes_last_frag = bytes_per_frag; - /* When we allocate the TXB we allocate enough space for the reserve - * and full fragment bytes (bytes_per_frag doesn't include prefix, - * postfix, header, FCS, etc.) */ - txb = rtllib_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC); + /* When we allocate the TXB we allocate enough space for the + * reserve and full fragment bytes (bytes_per_frag doesn't + * include prefix, postfix, header, FCS, etc.) */ + txb = rtllib_alloc_txb(nr_frags, frag_size + + ieee->tx_headroom, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -767,16 +767,15 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->payload_size = bytes; if (qos_actived) - { txb->queue_index = UP2AC(skb->priority); - } else { - txb->queue_index = WME_AC_BE;; - } + else + txb->queue_index = WME_AC_BE; for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - tcb_desc = (struct cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); - if (qos_actived){ + tcb_desc = (struct cb_desc *)(skb_frag->cb + + MAX_DEV_ADDR_SIZE); + if (qos_actived) { skb_frag->priority = skb->priority; tcb_desc->queue_index = UP2AC(skb->priority); } else { @@ -785,41 +784,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } skb_reserve(skb_frag, ieee->tx_headroom); - if (encrypt){ + if (encrypt) { if (ieee->hwsec_active) tcb_desc->bHwSec = 1; else tcb_desc->bHwSec = 0; - skb_reserve(skb_frag, crypt->ops->extra_prefix_len); + skb_reserve(skb_frag, + crypt->ops->extra_prefix_len); } else { tcb_desc->bHwSec = 0; } - frag_hdr = (struct rtllib_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtllib_hdr_3addrqos *) + skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - /* If this is not the last fragment, then add the MOREFRAGS - * bit to the frame control */ + /* If this is not the last fragment, then add the + * MOREFRAGS bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | RTLLIB_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { - /* The last fragment takes the remaining length */ + /* The last fragment has the remaining length */ bytes = bytes_last_frag; } - if ((qos_actived) && (!bIsMulticast)) - { - frag_hdr->seq_ctl = rtllib_query_seqnum(ieee, skb_frag, header.addr1); - frag_hdr->seq_ctl = cpu_to_le16(frag_hdr->seq_ctl<<4 | i); + if ((qos_actived) && (!bIsMulticast)) { + frag_hdr->seq_ctl = + rtllib_query_seqnum(ieee, skb_frag, + header.addr1); + frag_hdr->seq_ctl = + cpu_to_le16(frag_hdr->seq_ctl<<4 | i); } else { - frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); + frag_hdr->seq_ctl = + cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); } /* Put a SNAP header on the first fragment */ if (i == 0) { rtllib_put_snap( - skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), - ether_type); + skb_put(skb_frag, SNAP_SIZE + + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } @@ -828,27 +832,29 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB... */ skb_pull(skb, bytes); - /* Encryption routine will move the header forward in order - * to insert the IV between the header and the payload */ + /* Encryption routine will move the header forward in + * order to insert the IV between the header and the + * payload */ if (encrypt) - rtllib_encrypt_fragment(ieee, skb_frag, hdr_len); + rtllib_encrypt_fragment(ieee, skb_frag, + hdr_len); if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) skb_put(skb_frag, 4); } if ((qos_actived) && (!bIsMulticast)) { - if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) - ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; - else - ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; + if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) + ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; + else + ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; } else { - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; } - }else{ + } else { if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -856,7 +862,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); - if (!txb){ + if (!txb) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; @@ -864,22 +870,24 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); } success: - if (txb) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + if (txb) { + struct cb_desc *tcb_desc = (struct cb_desc *) + (txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; tcb_desc->priority = skb->priority; if (ether_type == ETH_P_PAE) { - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = ieee->basic_rate; tcb_desc->bTxDisableRateFallBack = 1; } @@ -893,17 +901,19 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (is_broadcast_ether_addr(header.addr1)) tcb_desc->bBroadcast = 1; rtllib_txrate_selectmode(ieee, tcb_desc); - if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->bMulticast || tcb_desc->bBroadcast) tcb_desc->data_rate = ieee->basic_rate; else - tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + tcb_desc->data_rate = CURRENT_RATE(ieee->mode, + ieee->rate, ieee->HTCurrentOperaRate); - if (bdhcp == true){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (bdhcp == true) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = MGN_1M; tcb_desc->bTxDisableRateFallBack = 1; } @@ -915,20 +925,22 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); - rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], + tcb_desc); rtllib_query_HTCapShortGI(ieee, tcb_desc); rtllib_query_BandwidthMode(ieee, tcb_desc); - rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); + rtllib_query_protectionmode(ieee, tcb_desc, + txb->fragments[0]); } } spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { - if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) { dev->stats.tx_packets++; dev->stats.tx_bytes += txb->payload_size; rtllib_softmac_xmit(txb, ieee); - }else{ + } else { if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; From 62f27cc4ae4183e9ee4e562eae60101966014f58 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:29 -0500 Subject: [PATCH 0558/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVII Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_pci.c | 21 +- drivers/staging/rtl8192e/rtl_pci.h | 6 +- drivers/staging/rtl8192e/rtllib_wx.c | 452 ++++++++++++++------------- 3 files changed, 247 insertions(+), 232 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl_pci.c index 2416db13217..ddadcc3e4e7 100644 --- a/drivers/staging/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl_pci.c @@ -25,7 +25,8 @@ #include "rtl_pci.h" #include "rtl_core.h" -static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_device *dev) +static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, + struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -37,10 +38,11 @@ static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_dev pci_read_config_byte(priv->pdev, pos + PCI_EXP_LNKCTL, &LinkCtrlReg); priv->NdisAdapter.LinkCtrlReg = LinkCtrlReg; - RT_TRACE(COMP_INIT, "Link Control Register =%x\n", priv->NdisAdapter.LinkCtrlReg); + RT_TRACE(COMP_INIT, "Link Control Register =%x\n", + priv->NdisAdapter.LinkCtrlReg); pci_read_config_byte(pdev, 0x98, &tmp); - tmp |=BIT4; + tmp |= BIT4; pci_write_config_byte(pdev, 0x98, tmp); tmp = 0x17; @@ -65,24 +67,27 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) if (DeviceID == 0x8172) { switch (RevisionID) { case HAL_HW_PCI_REVISION_ID_8192PCIE: - printk("Adapter(8192 PCI-E) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192 PCI-E) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192E; break; case HAL_HW_PCI_REVISION_ID_8192SE: - printk("Adapter(8192SE) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192SE) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192SE; break; default: - printk("UNKNOWN nic type(%4x:%4x)\n", pdev->vendor, pdev->device); + printk(KERN_INFO "UNKNOWN nic type(%4x:%4x)\n", + pdev->vendor, pdev->device); priv->card_8192 = NIC_UNKNOWN; return false; } } if (priv->ops->nic_type != priv->card_8192) { - printk("Detect info(%x) and hardware info(%x) not match!\n", + printk(KERN_INFO "Detect info(%x) and hardware info(%x) not match!\n", priv->ops->nic_type, priv->card_8192); - printk("Please select proper driver before install!!!!\n"); + printk(KERN_INFO "Please select proper driver before install!!!!\n"); return false; } diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h index b4efc7c4db0..7ea5a47dfd2 100644 --- a/drivers/staging/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -69,11 +69,11 @@ struct mp_adapter { u16 PciBridgeDeviceId; u8 PciBridgePCIeHdrOffset; u8 PciBridgeLinkCtrlReg; -};//,*pmp_adapter; +}; struct rt_pci_capab_header { - unsigned char CapabilityID; - unsigned char Next; + unsigned char CapabilityID; + unsigned char Next; }; #define PCI_MAX_BRIDGE_NUMBER 255 diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 39c6644f11b..c350f4e277d 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -40,19 +40,19 @@ struct modes_unit { int mode_size; }; static struct modes_unit rtllib_modes[] = { - {"a",1}, - {"b",1}, - {"g",1}, - {"?",1}, - {"N-24G",5}, - {"N-5G",4}, + {"a", 1}, + {"b", 1}, + {"g", 1}, + {"?", 1}, + {"N-24G", 5}, + {"N-5G", 4}, }; #define MAX_CUSTOM_LEN 64 static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, char *start, char *stop, struct rtllib_network *network, - struct iw_request_info *info) + struct iw_request_info *info) { char custom[MAX_CUSTOM_LEN]; char proto_name[IFNAMSIZ]; @@ -67,52 +67,60 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_ADDR_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_ADDR_LEN); /* Remaining entries will be displayed in the order we provide them */ /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - if (network->ssid_len > 0){ + if (network->ssid_len > 0) { iwe.u.data.length = min(network->ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); - }else if (network->hidden_ssid_len == 0){ + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->ssid); + } else if (network->hidden_ssid_len == 0) { iwe.u.data.length = sizeof(""); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, ""); - }else { + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, ""); + } else { iwe.u.data.length = min(network->hidden_ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->hidden_ssid); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->hidden_ssid); } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - for (i=0; i<(sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { + for (i = 0; i < (sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { if (network->mode&(1<capability & + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_CHAR_LEN); + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + if (network->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { if (network->capability & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN); - } + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_UINT_LEN); + } - /* Add frequency/channel */ + /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; /* iwe.u.freq.m = rtllib_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_FREQ_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; @@ -121,12 +129,13 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, network->ssid); /* Add basic and extended rates */ max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - for (i = 0, j = 0; i < network->rates_len; ) { + for (i = 0, j = 0; i < network->rates_len;) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) < (network->rates[i] & 0x7F))) @@ -146,22 +155,24 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, max_rate = rate; } - if (network->mode >= IEEE_N_24G) - { + if (network->mode >= IEEE_N_24G) { struct ht_capab_ele *ht_cap = NULL; bool is40M = false, isShortGI = false; u8 max_mcs = 0; if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4)) - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[4]; + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[4]; else - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[0]; - is40M = (ht_cap->ChlWidth)?1:0; - isShortGI = (ht_cap->ChlWidth)? - ((ht_cap->ShortGI40Mhz)?1:0): - ((ht_cap->ShortGI20Mhz)?1:0); + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[0]; + is40M = (ht_cap->ChlWidth) ? 1 : 0; + isShortGI = (ht_cap->ChlWidth) ? + ((ht_cap->ShortGI40Mhz) ? 1 : 0) : + ((ht_cap->ShortGI20Mhz) ? 1 : 0); - max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, MCS_FILTER_ALL); - rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs&0x7f]; + max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, + MCS_FILTER_ALL); + rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs & 0x7f]; if (rate > max_rate) max_rate = rate; } @@ -173,7 +184,8 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); /* Add quality statistics */ /* TODO: Fix these values... */ iwe.cmd = IWEVQUAL; @@ -188,53 +200,54 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, if (!(network->stats.mask & RTLLIB_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; iwe.u.qual.updated = 7; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_QUAL_LEN); iwe.cmd = IWEVCUSTOM; p = custom; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); memset(&iwe, 0, sizeof(iwe)); - if (network->wpa_ie_len) - { + if (network->wpa_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->wpa_ie, network->wpa_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wpa_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } memset(&iwe, 0, sizeof(iwe)); - if (network->rsn_ie_len) - { + if (network->rsn_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->rsn_ie, network->rsn_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->rsn_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* add info for WZC */ memset(&iwe, 0, sizeof(iwe)); - if (network->wzc_ie_len) - { + if (network->wzc_ie_len) { char buf[MAX_WZC_IE_LEN]; memcpy(buf, network->wzc_ie, network->wzc_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wzc_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* Add EXTRA: Age to display seconds since last beacon/probe response * for given network. */ iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), - " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); + " Last beacon: %lums ago", + (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); return start; } @@ -256,17 +269,16 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, list_for_each_entry(network, &ieee->network_list, list) { i++; - if ((stop-ev)<200) - { + if ((stop - ev) < 200) { err = -E2BIG; break; - } + } if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = rtl819x_translate_scan(ieee, ev, stop, network, info); + ev = rtl819x_translate_scan(ieee, ev, stop, network, + info); else - RTLLIB_DEBUG_SCAN( - "Not showing network '%s (" + RTLLIB_DEBUG_SCAN("Not showing network '%s (" MAC_FMT ")' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), @@ -326,7 +338,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, if (ieee->crypt[i] != NULL) { if (key_provided) break; - rtllib_crypt_delayed_deinit(ieee, &ieee->crypt[i]); + rtllib_crypt_delayed_deinit(ieee, + &ieee->crypt[i]); } } @@ -406,7 +419,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, NULL, (*crypt)->priv); if (len == 0) { /* Set a default key of all 0 */ - printk("Setting key %d to all zero.\n", + printk(KERN_INFO "Setting key %d to all zero.\n", key); RTLLIB_DEBUG_WX("Setting key %d to all zero.\n", @@ -429,7 +442,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, } done: ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); - ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; + ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : + WLAN_AUTH_SHARED_KEY; sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? @@ -501,27 +515,27 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, } int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct net_device *dev = ieee->dev; - struct iw_point *encoding = &wrqu->encoding; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - int i, idx; - int group_key = 0; - const char *alg, *module; - struct rtllib_crypto_ops *ops; - struct rtllib_crypt_data **crypt; + struct iw_point *encoding = &wrqu->encoding; + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; + int i, idx; + int group_key = 0; + const char *alg, *module; + struct rtllib_crypto_ops *ops; + struct rtllib_crypt_data **crypt; - struct rtllib_security sec = { - .flags = 0, - }; - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) { - if (idx < 1 || idx > WEP_KEYS) - return -EINVAL; - idx--; + struct rtllib_security sec = { + .flags = 0, + }; + idx = encoding->flags & IW_ENCODE_INDEX; + if (idx) { + if (idx < 1 || idx > WEP_KEYS) + return -EINVAL; + idx--; } else{ idx = ieee->tx_keyidx; } @@ -531,7 +545,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } else { /* some Cisco APs use idx>0 for unicast in dynamic WEP */ if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) - return -EINVAL; + return -EINVAL; if (ieee->iw_mode == IW_MODE_INFRA) crypt = &ieee->crypt[idx]; else @@ -540,7 +554,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, sec.flags |= SEC_ENABLED; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) { + ext->alg == IW_ENCODE_ALG_NONE) { if (*crypt) rtllib_crypt_delayed_deinit(ieee, crypt); @@ -557,108 +571,108 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } sec.enabled = 1; - switch (ext->alg) { - case IW_ENCODE_ALG_WEP: - alg = "WEP"; - module = "rtllib_crypt_wep"; - break; - case IW_ENCODE_ALG_TKIP: - alg = "TKIP"; - module = "rtllib_crypt_tkip"; - break; - case IW_ENCODE_ALG_CCMP: - alg = "CCMP"; - module = "rtllib_crypt_ccmp"; - break; - default: - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - ret = -EINVAL; - goto done; - } - printk("alg name:%s\n",alg); + switch (ext->alg) { + case IW_ENCODE_ALG_WEP: + alg = "WEP"; + module = "rtllib_crypt_wep"; + break; + case IW_ENCODE_ALG_TKIP: + alg = "TKIP"; + module = "rtllib_crypt_tkip"; + break; + case IW_ENCODE_ALG_CCMP: + alg = "CCMP"; + module = "rtllib_crypt_ccmp"; + break; + default: + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + ret = -EINVAL; + goto done; + } + printk(KERN_INFO "alg name:%s\n", alg); ops = rtllib_get_crypto_ops(alg); - if (ops == NULL) { - char tempbuf[100]; + if (ops == NULL) { + char tempbuf[100]; - memset( tempbuf, 0x00, 100 ); - sprintf( tempbuf, "%s", module); - request_module("%s",tempbuf); - ops = rtllib_get_crypto_ops(alg); - } - if (ops == NULL) { - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - printk("========>unknown crypto alg %d\n", ext->alg); - ret = -EINVAL; - goto done; - } + memset(tempbuf, 0x00, 100); + sprintf(tempbuf, "%s", module); + request_module("%s", tempbuf); + ops = rtllib_get_crypto_ops(alg); + } + if (ops == NULL) { + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + printk(KERN_INFO "========>unknown crypto alg %d\n", ext->alg); + ret = -EINVAL; + goto done; + } - if (*crypt == NULL || (*crypt)->ops != ops) { - struct rtllib_crypt_data *new_crypt; + if (*crypt == NULL || (*crypt)->ops != ops) { + struct rtllib_crypt_data *new_crypt; - rtllib_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); - new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - new_crypt->ops = ops; + new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); + if (new_crypt == NULL) { + ret = -ENOMEM; + goto done; + } + new_crypt->ops = ops; if (new_crypt->ops) - new_crypt->priv = new_crypt->ops->init(idx); + new_crypt->priv = new_crypt->ops->init(idx); - if (new_crypt->priv == NULL) { - kfree(new_crypt); - ret = -EINVAL; - goto done; - } - *crypt = new_crypt; + if (new_crypt->priv == NULL) { + kfree(new_crypt); + ret = -EINVAL; + goto done; + } + *crypt = new_crypt; } - if (ext->key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, - (*crypt)->priv) < 0) { - RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); - printk("key setting failed\n"); - ret = -EINVAL; - goto done; - } - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - ieee->tx_keyidx = idx; - sec.active_key = idx; - sec.flags |= SEC_ACTIVE_KEY; - } - if (ext->alg != IW_ENCODE_ALG_NONE) { - sec.key_sizes[idx] = ext->key_len; - sec.flags |= (1 << idx); - if (ext->alg == IW_ENCODE_ALG_WEP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - /* Don't set sec level for group keys. */ - if (group_key) - sec.flags &= ~SEC_LEVEL; - } + if (ext->key_len > 0 && (*crypt)->ops->set_key && + (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, + (*crypt)->priv) < 0) { + RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); + printk(KERN_INFO "key setting failed\n"); + ret = -EINVAL; + goto done; + } + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { + ieee->tx_keyidx = idx; + sec.active_key = idx; + sec.flags |= SEC_ACTIVE_KEY; + } + if (ext->alg != IW_ENCODE_ALG_NONE) { + sec.key_sizes[idx] = ext->key_len; + sec.flags |= (1 << idx); + if (ext->alg == IW_ENCODE_ALG_WEP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } else if (ext->alg == IW_ENCODE_ALG_TKIP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_2; + } else if (ext->alg == IW_ENCODE_ALG_CCMP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_3; + } + /* Don't set sec level for group keys. */ + if (group_key) + sec.flags &= ~SEC_LEVEL; + } done: - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(dev)) { - RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); - return -EINVAL; - } - return ret; + ieee->iw_mode != IW_MODE_INFRA && + ieee->reset_port && ieee->reset_port(dev)) { + RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); + return -EINVAL; + } + return ret; } int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, @@ -692,12 +706,12 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); - if (crypt == NULL || crypt->ops == NULL ) { + if (crypt == NULL || crypt->ops == NULL) { ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; encoding->flags |= IW_ENCODE_DISABLED; } else { - if (strcmp(crypt->ops->name, "WEP") == 0 ) + if (strcmp(crypt->ops->name, "WEP") == 0) ext->alg = IW_ENCODE_ALG_WEP; else if (strcmp(crypt->ops->name, "TKIP")) ext->alg = IW_ENCODE_ALG_TKIP; @@ -705,7 +719,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, ext->alg = IW_ENCODE_ALG_CCMP; else return -EINVAL; - ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, NULL, crypt->priv); + ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, + NULL, crypt->priv); encoding->flags |= IW_ENCODE_ENABLED; if (ext->key_len && (ext->alg == IW_ENCODE_ALG_TKIP || @@ -718,8 +733,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, } int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { u8 i = 0; bool deauth = false; @@ -731,28 +746,28 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, down(&ieee->wx_sem); switch (mlme->cmd) { - case IW_MLME_DEAUTH: - deauth = true; - /* leave break out intentionly */ + case IW_MLME_DEAUTH: + deauth = true; + /* leave break out intentionly */ - case IW_MLME_DISASSOC: - if (deauth == true) - printk("disauth packet !\n"); - else - printk("dis associate packet!\n"); + case IW_MLME_DISASSOC: + if (deauth == true) + printk(KERN_INFO "disauth packet !\n"); + else + printk(KERN_INFO "dis associate packet!\n"); - ieee->cannot_notify = true; + ieee->cannot_notify = true; - SendDisassociation(ieee,deauth,mlme->reason_code); - rtllib_disassociate(ieee); + SendDisassociation(ieee, deauth, mlme->reason_code); + rtllib_disassociate(ieee); - ieee->wap_set = 0; - for (i = 0; i < 6; i++) - ieee->current_network.bssid[i]= 0x55; + ieee->wap_set = 0; + for (i = 0; i < 6; i++) + ieee->current_network.bssid[i] = 0x55; - ieee->ssid_set = 0; - ieee->current_network.ssid[0] = '\0'; - ieee->current_network.ssid_len = 0; + ieee->ssid_set = 0; + ieee->current_network.ssid[0] = '\0'; + ieee->current_network.ssid_len = 0; break; default: up(&ieee->wx_sem); @@ -765,56 +780,53 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, } int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra) + struct iw_request_info *info, + struct iw_param *data, char *extra) { switch (data->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: + case IW_AUTH_WPA_VERSION: break; - case IW_AUTH_CIPHER_PAIRWISE: - case IW_AUTH_CIPHER_GROUP: - case IW_AUTH_KEY_MGMT: + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: /* * Host AP driver does not use these parameters and allows * wpa_supplicant to control them internally. */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures = data->value; - break; - case IW_AUTH_DROP_UNENCRYPTED: - ieee->drop_unencrypted = data->value; + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + ieee->tkip_countermeasures = data->value; + break; + case IW_AUTH_DROP_UNENCRYPTED: + ieee->drop_unencrypted = data->value; break; case IW_AUTH_80211_AUTH_ALG: - if (data->value & IW_AUTH_ALG_SHARED_KEY){ + if (data->value & IW_AUTH_ALG_SHARED_KEY) { ieee->open_wep = 0; ieee->auth_mode = 1; - } - else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM){ + } else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM) { ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (data->value & IW_AUTH_ALG_LEAP){ + } else if (data->value & IW_AUTH_ALG_LEAP) { ieee->open_wep = 1; ieee->auth_mode = 2; - } - else + } else return -EINVAL; break; case IW_AUTH_WPA_ENABLED: - ieee->wpa_enabled = (data->value)?1:0; + ieee->wpa_enabled = (data->value) ? 1 : 0; break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: - ieee->ieee802_1x = data->value; + ieee->ieee802_1x = data->value; break; case IW_AUTH_PRIVACY_INVOKED: ieee->privacy_invoked = data->value; break; default: - return -EOPNOTSUPP; + return -EOPNOTSUPP; } return 0; } @@ -822,17 +834,18 @@ int rtllib_wx_set_auth(struct rtllib_device *ieee, int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) { u8 *buf; - u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { + if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) return -EINVAL; - } if (len) { eid = ie[0]; - if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) { + if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], + wps_oui, 4))) { - ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len):(MAX_WZC_IE_LEN); + ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) : + (MAX_WZC_IE_LEN); buf = kmalloc(ieee->wps_ie_len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -842,13 +855,11 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) } } ieee->wps_ie_len = 0; - if (ieee->wps_ie) - kfree(ieee->wps_ie); + kfree(ieee->wps_ie); ieee->wps_ie = NULL; if (len) { - if (len != ie[1]+2) { + if (len != ie[1]+2) return -EINVAL; - } buf = kmalloc(len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -857,7 +868,6 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) ieee->wpa_ie = buf; ieee->wpa_ie_len = len; } else { - if (ieee->wpa_ie) kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; From 08d348a021213a16eb76b6e9937e91d1ec67a90b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 11:48:30 -0500 Subject: [PATCH 0559/1519] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVIII Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_pm.c | 120 +++-- drivers/staging/rtl8192e/rtl_pm.h | 8 +- drivers/staging/rtl8192e/rtl_ps.c | 182 ++++---- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtl_wx.c | 748 ++++++++++++++---------------- drivers/staging/rtl8192e/rtl_wx.h | 2 +- 6 files changed, 506 insertions(+), 556 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c index af1c8201e01..92e2fde7f5f 100644 --- a/drivers/staging/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -23,42 +23,38 @@ #include "r8190P_rtl8256.h" #include "rtl_pm.h" -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state) +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state) { - printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); - return(-EAGAIN); + printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); + return -EAGAIN; } -int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) +int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); u32 ulRegRead; - RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); - printk("============> r8192E suspend call.\n"); + printk(KERN_INFO "============> r8192E suspend call.\n"); del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of suspend function\n"); - goto out_pci_suspend; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of suspend " + "function\n"); + goto out_pci_suspend; + } -#ifdef HAVE_NET_DEVICE_OPS if (dev->netdev_ops->ndo_stop) dev->netdev_ops->ndo_stop(dev); -#else - dev->stop(dev); -#endif netif_device_detach(dev); if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT,true); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true); ulRegRead = read_nic_dword(dev, CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; + ulRegRead |= CPU_GEN_SYSTEM_RESET; write_nic_dword(dev, CPU_GEN, ulRegRead); } else { write_nic_dword(dev, WFCRC0, 0xffffffff); @@ -68,81 +64,73 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) write_nic_byte(dev, MacBlkCtrl, 0xa); } out_pci_suspend: - RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); printk("r8192E support WOL call??????????????????????\n"); - if (priv->rtllib->bSupportRemoteWakeUp) { - RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); - } + if (priv->rtllib->bSupportRemoteWakeUp) + RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!" + "!!!!!!!!!!!.\n"); pci_save_state(pdev); pci_disable_device(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev,state),\ - priv->rtllib->bSupportRemoteWakeUp?1:0); - pci_set_power_state(pdev,pci_choose_state(pdev,state)); + pci_enable_wake(pdev, pci_choose_state(pdev, state), + priv->rtllib->bSupportRemoteWakeUp ? 1 : 0); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); - mdelay(20); + mdelay(20); return 0; } -int rtl8192E_resume (struct pci_dev *pdev) +int rtl8192E_resume(struct pci_dev *pdev) { - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv = rtllib_priv(dev); - int err; - u32 val; + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv = rtllib_priv(dev); + int err; + u32 val; - RT_TRACE(COMP_POWER, "================>r8192E resume call."); - printk("================>r8192E resume call.\n"); + printk(KERN_INFO "================>r8192E resume call.\n"); - pci_set_power_state(pdev, PCI_D0); + pci_set_power_state(pdev, PCI_D0); - err = pci_enable_device(pdev); - if (err) { - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", - dev->name); - return err; - } - pci_restore_state(pdev); + err = pci_enable_device(pdev); + if (err) { + printk(KERN_ERR "%s: pci_enable_device failed on resume\n", + dev->name); + return err; + } + pci_restore_state(pdev); - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) { - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - } + pci_read_config_dword(pdev, 0x40, &val); + if ((val & 0x0000ff00) != 0) + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - pci_enable_wake(pdev, PCI_D0, 0); + pci_enable_wake(pdev, PCI_D0, 0); - if (priv->polling_timer_on == 0){ - check_rfctrl_gpio_timer((unsigned long)dev); - } + if (priv->polling_timer_on == 0) + check_rfctrl_gpio_timer((unsigned long)dev); - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of resume function\n"); - goto out; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of resume " + "function\n"); + goto out; + } - netif_device_attach(dev); -#ifdef HAVE_NET_DEVICE_OPS - if (dev->netdev_ops->ndo_open) - dev->netdev_ops->ndo_open(dev); -#else - dev->open(dev); -#endif + netif_device_attach(dev); + if (dev->netdev_ops->ndo_open) + dev->netdev_ops->ndo_open(dev); - if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT,true); - } + if (!priv->rtllib->bSupportRemoteWakeUp) + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true); out: - RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); - return 0; + RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); + return 0; } -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable) { - printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", + printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", state.event, enable); - return(-EAGAIN); + return -EAGAIN; } #endif diff --git a/drivers/staging/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl_pm.h index 22df2908181..4d7f4067cc7 100644 --- a/drivers/staging/rtl8192e/rtl_pm.h +++ b/drivers/staging/rtl8192e/rtl_pm.h @@ -25,10 +25,10 @@ #include #include -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); -int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); -int rtl8192E_resume (struct pci_dev *dev); -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state); +int rtl8192E_suspend(struct pci_dev *dev, pm_message_t state); +int rtl8192E_resume(struct pci_dev *dev); +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable); #endif diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index ea9eac71253..f39f0d340e2 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -33,44 +33,49 @@ void rtl8192_hw_sleep_down(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in progress! \n"); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in " + "progress!\n"); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); - MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS, false); } void rtl8192_hw_sleep_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_sleep_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_sleep_wq); struct net_device *dev = ieee->dev; - rtl8192_hw_sleep_down(dev); + rtl8192_hw_sleep_down(dev); } -void rtl8192_hw_wakeup(struct net_device* dev) +void rtl8192_hw_wakeup(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in progress! \n"); - queue_delayed_work_rsl(priv->rtllib->wq,&priv->rtllib->hw_wakeup_wq,MSECS(10)); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in " + "progress!\n"); + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq, MSECS(10)); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS, false); } void rtl8192_hw_wakeup_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_wakeup_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_wakeup_wq); struct net_device *dev = ieee->dev; rtl8192_hw_wakeup(dev); @@ -85,12 +90,12 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) u32 tmp; unsigned long flags; - spin_lock_irqsave(&priv->ps_lock,flags); + spin_lock_irqsave(&priv->ps_lock, flags); time -= MSECS(8+16+7); if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); printk(KERN_INFO "too short to sleep::%lld < %ld\n", time - jiffies, MSECS(MIN_SLEEP_TIME)); return; @@ -99,48 +104,48 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", time - jiffies, MSECS(MAX_SLEEP_TIME)); - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); return; } tmp = time - jiffies; queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); + &priv->rtllib->hw_wakeup_wq, tmp); queue_delayed_work_rsl(priv->rtllib->wq, - (void *)&priv->rtllib->hw_sleep_wq,0); - spin_unlock_irqrestore(&priv->ps_lock,flags); + (void *)&priv->rtllib->hw_sleep_wq, 0); + spin_unlock_irqrestore(&priv->ps_lock, flags); } void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() ---------> \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() --------->\n"); pPSC->bSwRfProcessing = true; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", \ - pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); - MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", + pPSC->eInactivePowerState == eRfOff ? "OFF" : "ON"); + MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS, + false); pPSC->bSwRfProcessing = false; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <--------- \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <---------\n"); } -void -IPSEnter(struct net_device *dev) +void IPSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState == eRfOn && !pPSC->bSwRfProcessing &&\ - (priv->rtllib->state != RTLLIB_LINKED)&&\ - (priv->rtllib->iw_mode != IW_MODE_MASTER)) - { - RT_TRACE(COMP_PS,"IPSEnter(): Turn off RF.\n"); + if (rtState == eRfOn && !pPSC->bSwRfProcessing && + (priv->rtllib->state != RTLLIB_LINKED) && + (priv->rtllib->iw_mode != IW_MODE_MASTER)) { + RT_TRACE(COMP_PS, "IPSEnter(): Turn off RF.\n"); pPSC->eInactivePowerState = eRfOff; priv->isRFOff = true; priv->bInPowerSaveMode = true; @@ -149,18 +154,17 @@ IPSEnter(struct net_device *dev) } } -void -IPSLeave(struct net_device *dev) +void IPSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) - { + if (rtState != eRfOn && !pPSC->bSwRfProcessing && + priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) { RT_TRACE(COMP_PS, "IPSLeave(): Turn on RF.\n"); pPSC->eInactivePowerState = eRfOn; priv->bInPowerSaveMode = false; @@ -168,9 +172,11 @@ IPSLeave(struct net_device *dev) } } } + void IPSLeave_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data,struct rtllib_device,ips_leave_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, ips_leave_wq); struct net_device *dev = ieee->dev; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); down(&priv->rtllib->ips_sem); @@ -184,20 +190,22 @@ void rtllib_ips_leave_wq(struct net_device *dev) enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return; - } - else{ - printk("=========>%s(): IPSLeave\n",__func__); - queue_work_rsl(priv->rtllib->wq,&priv->rtllib->ips_leave_wq); + } else { + printk(KERN_INFO "=========>%s(): IPSLeave\n", + __func__); + queue_work_rsl(priv->rtllib->wq, + &priv->rtllib->ips_leave_wq); } } } } + void rtllib_ips_leave(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -213,38 +221,42 @@ bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) if (priv->rtllib->iw_mode == IW_MODE_ADHOC) return false; - RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__func__,rtPsMode); - if (!priv->ps_force) { + RT_TRACE(COMP_LPS, "%s(): set ieee->ps = %x\n", __func__, rtPsMode); + if (!priv->ps_force) priv->rtllib->ps = rtPsMode; - } - if (priv->rtllib->sta_sleep != LPS_IS_WAKE && rtPsMode == RTLLIB_PS_DISABLED) { - unsigned long flags; + if (priv->rtllib->sta_sleep != LPS_IS_WAKE && + rtPsMode == RTLLIB_PS_DISABLED) { + unsigned long flags; rtl8192_hw_wakeup(dev); priv->rtllib->sta_sleep = LPS_IS_WAKE; - spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); + spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); RT_TRACE(COMP_DBG, "LPS leave: notify AP we are awaked" " ++++++++++ SendNullFunctionData\n"); rtllib_sta_ps_send_null_frame(priv->rtllib, 0); - spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); + spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); } return true; } - void LeisurePSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSEnter()...\n"); - RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", - pPSC->bLeisurePs, priv->rtllib->ps,pPSC->LpsIdleCount,RT_CHECK_FOR_HANG_PERIOD); + RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdle" + "Count is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", + pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount, + RT_CHECK_FOR_HANG_PERIOD); - if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) - || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || (priv->rtllib->iw_mode == IW_MODE_MASTER)) + if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && + (priv->rtllib->state == RTLLIB_LINKED)) + || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || + (priv->rtllib->iw_mode == IW_MODE_MASTER)) return; if (pPSC->bLeisurePs) { @@ -252,44 +264,46 @@ void LeisurePSEnter(struct net_device *dev) if (priv->rtllib->ps == RTLLIB_PS_DISABLED) { - RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter 802.11 power save mode...\n"); + RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter " + "802.11 power save mode...\n"); if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_ENTER); + priv->rtllib->SetFwCmdHandler( + dev, FW_CMD_LPS_ENTER); } - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_MBCAST | + RTLLIB_PS_UNICAST); } } else pPSC->LpsIdleCount++; } } - void LeisurePSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSLeave()...\n"); RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d\n", pPSC->bLeisurePs, priv->rtllib->ps); - if (pPSC->bLeisurePs) - { - if (priv->rtllib->ps != RTLLIB_PS_DISABLED) - { - RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n"); - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_DISABLED); + if (pPSC->bLeisurePs) { + if (priv->rtllib->ps != RTLLIB_PS_DISABLED) { + RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , " + "Leave 802.11 power save..\n"); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_DISABLED); - if (!pPSC->bFwCtrlLPS) - { + if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_LEAVE); - } - } + priv->rtllib->SetFwCmdHandler(dev, + FW_CMD_LPS_LEAVE); + } } } } diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index 453df2cbb3d..a9c2d799c08 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -36,7 +36,7 @@ void rtl8192_hw_wakeup(struct net_device *dev); void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); -void IPSLeave_wq (void *data); +void IPSLeave_wq(void *data); void IPSEnter(struct net_device *dev); void IPSLeave(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index bc096c096cf..f869ce3dbec 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,14 +22,14 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - +u32 rtl8192_rates[] = { + 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, + 18000000, 24000000, 36000000, 48000000, 54000000 +}; #ifndef ENETDOWN #define ENETDOWN 1 #endif -extern int hwwep; static int r8192_wx_get_freq(struct net_device *dev, struct iw_request_info *a, @@ -37,16 +37,16 @@ static int r8192_wx_get_freq(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_freq(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8192_priv *priv=rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_mode(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_rate(struct net_device *dev, @@ -54,7 +54,7 @@ static int r8192_wx_get_rate(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rate(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra); } @@ -71,7 +71,7 @@ static int r8192_wx_set_rate(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rate(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -91,7 +91,7 @@ static int r8192_wx_set_rts(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rts(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -103,7 +103,7 @@ static int r8192_wx_get_rts(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rts(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_power(struct net_device *dev, @@ -113,13 +113,14 @@ static int r8192_wx_set_power(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff == true){ - RT_TRACE(COMP_ERR,"%s():Hw is Radio Off, we can't set Power,return\n",__func__); + if (priv->bHwRadioOff == true) { + RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set " + "Power,return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_power(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -131,12 +132,12 @@ static int r8192_wx_get_power(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_power(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -162,7 +163,8 @@ static int r8192_wx_force_reset(struct net_device *dev, down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", __func__, *extra); + RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", + __func__, *extra); priv->force_reset = *extra; up(&priv->wx_sem); return 0; @@ -174,11 +176,11 @@ static int r8192_wx_force_mic_error(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force mic error ! \n", __func__); + RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__); ieee->force_mic_error = true; up(&priv->wx_sem); return 0; @@ -197,8 +199,8 @@ struct adhoc_peers_info { }; int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -216,12 +218,14 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); - struct rtllib_device* ieee = priv->rtllib; + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_POWER, "%s(): %s\n",__func__, (*extra == 6)?"DC power":"AC power"); + RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ? + "DC power" : "AC power"); if (*extra || priv->force_lps) { priv->ps_force = false; pPSC->bLeisurePs = true; @@ -240,40 +244,41 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, } static int r8192se_wx_set_radio(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set radio ! extra is %d\n",__func__, *extra); - if ((*extra != 0) && (*extra != 1)) - { - RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",__func__); - return -1; - } - priv->sw_radio_on = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra); + if ((*extra != 0) && (*extra != 1)) { + RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio " + "off) or 1(radio on)\n", __func__); + return -1; + } + priv->sw_radio_on = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set lps awake interval ! extra is %d\n",__func__, *extra); - - pPSC->RegMaxLPSAwakeIntvl = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n", + __func__, *extra); + pPSC->RegMaxLPSAwakeIntvl = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_force_lps(struct net_device *dev, @@ -284,7 +289,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, down(&priv->wx_sem); - printk("%s(): force LPS ! extra is %d (1 is open 0 is close)\n",__func__, *extra); + printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is " + "close)\n", __func__, *extra); priv->force_lps = *extra; up(&priv->wx_sem); return 0; @@ -292,8 +298,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, } static int r8192_wx_set_debugflag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); u8 c = *extra; @@ -301,12 +307,12 @@ static int r8192_wx_set_debugflag(struct net_device *dev, if (priv->bHwRadioOff == true) return 0; - printk("=====>%s(), *extra:%x, debugflag:%x\n", __func__, *extra, rt_global_debug_component); - if (c > 0) { + printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__, + *extra, rt_global_debug_component); + if (c > 0) rt_global_debug_component |= (1<rtllib->eRFPowerState; down(&priv->wx_sem); - if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR - || ieee->bNetPromiscuousMode ) - { - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR || + ieee->bNetPromiscuousMode) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); up(&priv->wx_sem); return -1; } else { - printk("=========>%s(): IPSLeave\n",__func__); + printk(KERN_INFO "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -342,33 +349,32 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } } } - ret = rtllib_wx_set_mode(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); return ret; } -struct iw_range_with_scan_capa -{ - /* Informative stuff (to choose between different interface) */ - __u32 throughput; /* To give an idea... */ - /* In theory this value should be the maximum benchmarked - * TCP/IP throughput, because with most of these devices the - * bit rate is meaningless (overhead an co) to estimate how - * fast the connection will go and pick the fastest one. - * I suggest people to play with Netperf or any benchmark... - */ +struct iw_range_with_scan_capa { + /* Informative stuff (to choose between different interface) */ + __u32 throughput; /* To give an idea... */ + /* In theory this value should be the maximum benchmarked + * TCP/IP throughput, because with most of these devices the + * bit rate is meaningless (overhead an co) to estimate how + * fast the connection will go and pick the fastest one. + * I suggest people to play with Netperf or any benchmark... + */ - /* NWID (or domain id) */ - __u32 min_nwid; /* Minimal NWID we are able to set */ - __u32 max_nwid; /* Maximal NWID we are able to set */ + /* NWID (or domain id) */ + __u32 min_nwid; /* Minimal NWID we are able to set */ + __u32 max_nwid; /* Maximal NWID we are able to set */ - /* Old Frequency (backward compat - moved lower ) */ - __u16 old_num_channels; - __u8 old_num_frequency; + /* Old Frequency (backward compat - moved lower ) */ + __u16 old_num_channels; + __u8 old_num_frequency; - /* Scan capabilities */ - __u8 scan_capa; + /* Scan capabilities */ + __u8 scan_capa; }; static int rtl8192_wx_get_range(struct net_device *dev, @@ -386,8 +392,10 @@ static int rtl8192_wx_get_range(struct net_device *dev, /* ~130 Mb/s real (802.11n) */ range->throughput = 130 * 1000 * 1000; - if (priv->rf_set_sens != NULL) - range->sensitivity = priv->max_sens; /* signal level threshold range */ + if (priv->rf_set_sens != NULL) { + /* signal level threshold range */ + range->sensitivity = priv->max_sens; + } range->max_qual.qual = 100; range->max_qual.level = 0; @@ -401,9 +409,8 @@ static int rtl8192_wx_get_range(struct net_device *dev, range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES); - for (i = 0; i < range->num_bitrates; i++) { + for (i = 0; i < range->num_bitrates; i++) range->bitrate[i] = rtl8192_rates[i]; - } range->max_rts = DEFAULT_RTS_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD; @@ -421,15 +428,15 @@ static int rtl8192_wx_get_range(struct net_device *dev, for (i = 0, val = 0; i < 14; i++) { if ((priv->rtllib->active_channel_map)[i+1]) { - range->freq[val].i = i + 1; - range->freq[val].m = rtllib_wlan_frequencies[i] * 100000; + range->freq[val].i = i + 1; + range->freq[val].m = rtllib_wlan_frequencies[i] * + 100000; range->freq[val].e = 1; val++; - } else { } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; range->num_channels = val; @@ -437,7 +444,7 @@ static int rtl8192_wx_get_range(struct net_device *dev, IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; - /* Event capability (kernel + driver) */ + /* Event capability (kernel + driver) */ return 0; } @@ -446,35 +453,36 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum rt_rf_power_state rtState; int ret; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - if ((ieee->state >= RTLLIB_ASSOCIATING) && (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { + if ((ieee->state >= RTLLIB_ASSOCIATING) && + (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)) return 0; - } - if ((priv->rtllib->state == RTLLIB_LINKED) && (priv->rtllib->CntAfterLink<2)){ + if ((priv->rtllib->state == RTLLIB_LINKED) && + (priv->rtllib->CntAfterLink < 2)) return 0; - } } - if (priv->bHwRadioOff == true){ - printk("================>%s(): hwradio off\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "================>%s(): hwradio off\n", + __func__); return 0; } rtState = priv->rtllib->eRFPowerState; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { - struct iw_scan_req* req = (struct iw_scan_req*)b; - if (req->essid_len) - { + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { + struct iw_scan_req *req = (struct iw_scan_req *)b; + if (req->essid_len) { ieee->current_network.ssid_len = req->essid_len; - memcpy(ieee->current_network.ssid, req->essid, req->essid_len); + memcpy(ieee->current_network.ssid, req->essid, + req->essid_len); } } @@ -482,15 +490,18 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, priv->rtllib->FirstIe_InScan = true; - if (priv->rtllib->state != RTLLIB_LINKED){ - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS){ - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is " + "OFF.\n", __func__); up(&priv->wx_sem); return -1; - }else{ - RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",__func__); + } else { + RT_TRACE(COMP_PS, "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -499,23 +510,26 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } rtllib_stop_scan(priv->rtllib); if (priv->rtllib->LedControlHandler) - priv->rtllib->LedControlHandler(dev, LED_CTL_SITE_SURVEY); + priv->rtllib->LedControlHandler(dev, + LED_CTL_SITE_SURVEY); - if (priv->rtllib->eRFPowerState != eRfOff){ + if (priv->rtllib->eRFPowerState != eRfOff) { priv->rtllib->actscanning = true; if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_BACKUP); rtllib_start_scan_syncro(priv->rtllib, 0); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); - } + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_RESTORE); + } ret = 0; } else { priv->rtllib->actscanning = true; - ret = rtllib_wx_set_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b); } up(&priv->wx_sem); @@ -530,7 +544,8 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->bHwRadioOff == true) return 0; @@ -538,7 +553,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, down(&priv->wx_sem); - ret = rtllib_wx_get_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -552,15 +567,17 @@ static int r8192_wx_set_essid(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int ret; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } - if (priv->bHwRadioOff == true){ - printk("=========>%s():hw radio off,or Rf state is eRfOff, return\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "=========>%s():hw radio off,or Rf state is " + "eRfOff, return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_essid(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -682,12 +699,12 @@ static int r8192_wx_set_wap(struct net_device *dev, union iwreq_data *awrq, char *extra) { - int ret; struct r8192_priv *priv = rtllib_priv(dev); - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } if (priv->bHwRadioOff == true) @@ -695,7 +712,7 @@ static int r8192_wx_set_wap(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_wap(priv->rtllib,info,awrq,extra); + ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra); up(&priv->wx_sem); @@ -710,7 +727,7 @@ static int r8192_wx_get_wap(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_wap(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra); } @@ -731,87 +748,91 @@ static int r8192_wx_set_enc(struct net_device *dev, int ret; struct rtllib_device *ieee = priv->rtllib; - u32 hwkey[4]={0,0,0,0}; - u8 mask=0xff; - u32 key_idx=0; - u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x02}, - {0x00,0x00,0x00,0x00,0x00,0x03} }; + u32 hwkey[4] = {0, 0, 0, 0}; + u8 mask = 0xff; + u32 key_idx = 0; + u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; - } + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) + ; /* TODO - get rid of if */ if (priv->bHwRadioOff == true) return 0; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); down(&priv->wx_sem); RT_TRACE(COMP_SEC, "Setting SW wep key"); - ret = rtllib_wx_set_encode(priv->rtllib,info,wrqu,key); + ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key); up(&priv->wx_sem); if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - if (wrqu->encoding.length!=0){ + if (wrqu->encoding.length != 0) { - for (i=0 ; i<4 ; i++){ + for (i = 0; i < 4; i++) { hwkey[i] |= key[4*i+0]&mask; - if (i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; - if (i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; - hwkey[i] |= (key[4*i+1]&mask)<<8; - hwkey[i] |= (key[4*i+2]&mask)<<16; - hwkey[i] |= (key[4*i+3]&mask)<<24; + if (i == 1 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + if (i == 3 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + hwkey[i] |= (key[4 * i + 1] & mask) << 8; + hwkey[i] |= (key[4 * i + 2] & mask) << 16; + hwkey[i] |= (key[4 * i + 3] & mask) << 24; } #define CONF_WEP40 0x4 #define CONF_WEP104 0x14 - switch (wrqu->encoding.flags & IW_ENCODE_INDEX){ - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; + switch (wrqu->encoding.flags & IW_ENCODE_INDEX) { + case 0: + key_idx = ieee->tx_keyidx; + break; + case 1: + key_idx = 0; + break; + case 2: + key_idx = 1; + break; + case 3: + key_idx = 2; + break; + case 4: + key_idx = 3; + break; + default: + break; } - if (wrqu->encoding.length==0x5){ + if (wrqu->encoding.length == 0x5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; EnableHWSecurityConfig8192(dev); } - else if (wrqu->encoding.length==0xd){ + else if (wrqu->encoding.length == 0xd) { ieee->pairwise_key_type = KEY_TYPE_WEP104; EnableHWSecurityConfig8192(dev); - setKey( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey); - set_swcam( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey, - 0); + setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey); + set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey, 0); } else { - printk("wrong type in WEP, not WEP40 and WEP104\n"); + printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n"); } } @@ -820,13 +841,13 @@ end_hw_sec: return ret; } - -static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ - +static int r8192_wx_set_scan_type(struct net_device *dev, + struct iw_request_info *aa, + union iwreq_data *wrqu, char *p) +{ struct r8192_priv *priv = rtllib_priv(dev); - int *parms=(int*)p; - int mode=parms[0]; + int *parms = (int *)p; + int mode = parms[0]; if (priv->bHwRadioOff == true) return 0; @@ -852,38 +873,32 @@ static int r8192_wx_set_retry(struct net_device *dev, down(&priv->wx_sem); if (wrqu->retry.flags & IW_RETRY_LIFETIME || - wrqu->retry.disabled){ + wrqu->retry.disabled) { err = -EINVAL; goto exit; } - if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ + if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) { err = -EINVAL; goto exit; } - if (wrqu->retry.value > R8192_MAX_RETRY){ - err= -EINVAL; + if (wrqu->retry.value > R8192_MAX_RETRY) { + err = -EINVAL; goto exit; } if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; - DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for RTS/CTS data to %d", + wrqu->retry.value); - }else { + } else { priv->retry_data = wrqu->retry.value; - DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for non RTS/CTS data to %d", + wrqu->retry.value); } rtl8192_commit(dev); - /* - if (priv->up){ - rtl8180_halt_adapter(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - } - */ exit: up(&priv->wx_sem); @@ -910,14 +925,12 @@ static int r8192_wx_get_retry(struct net_device *dev, wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN; wrqu->retry.value = priv->retry_data; } - - return 0; } static int r8192_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_set_sens == NULL) @@ -941,13 +954,13 @@ static int r8192_wx_set_sens(struct net_device *dev, down(&priv->wx_sem); if (priv->rf_set_sens == NULL) { - err= -1; /* we have not this support for this radio */ + err = -1; /* we have not this support for this radio */ goto exit; } if (priv->rf_set_sens(dev, wrqu->sens.value) == 0) priv->sens = wrqu->sens.value; else - err= -EINVAL; + err = -EINVAL; exit: up(&priv->wx_sem); @@ -956,130 +969,90 @@ exit: } static int r8192_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (priv->bHwRadioOff == true) return 0; down(&priv->wx_sem); - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra); - { - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero[6] = {0}; u32 key[4] = {0}; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_point *encoding = &wrqu->encoding; u8 idx = 0, alg = 0, group = 0; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) - { - ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; + ext->alg == IW_ENCODE_ALG_NONE) { + ieee->pairwise_key_type = ieee->group_key_type + = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; + alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP : + ext->alg; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) - idx --; + idx--; group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; - if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) - { - if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) + if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || + (alg == KEY_TYPE_WEP40)) { + if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40)) alg = KEY_TYPE_WEP104; ieee->pairwise_key_type = alg; EnableHWSecurityConfig8192(dev); } - memcpy((u8*)key, ext->key, 16); + memcpy((u8 *)key, ext->key, 16); - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) - { + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) { if (ext->key_len == 13) ieee->pairwise_key_type = alg = KEY_TYPE_WEP104; - setKey( dev, - idx, - idx, - alg, - zero, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - zero, - 0, - key, - 0); - } - else if (group) - { + setKey(dev, idx, idx, alg, zero, 0, key); + set_swcam(dev, idx, idx, alg, zero, 0, key, 0); + } else if (group) { ieee->group_key_type = alg; - setKey( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key, - 0); - } - else - { - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } - setKey( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key); - set_swcam( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key, - 0); + setKey(dev, idx, idx, alg, broadcast_addr, 0, key); + set_swcam(dev, idx, idx, alg, broadcast_addr, 0, + key, 0); + } else { + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && + ieee->pHTInfo->bCurrentHTSupport) + write_nic_byte(dev, 0x173, 1); + setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key); + set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key, 0); } } end_hw_sec: - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; up(&priv->wx_sem); return ret; } static int r8192_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1093,11 +1066,11 @@ static int r8192_wx_set_auth(struct net_device *dev, } static int r8192_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1111,71 +1084,69 @@ static int r8192_wx_set_mlme(struct net_device *dev, } static int r8192_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); if (priv->bHwRadioOff == true) return 0; - down(&priv->wx_sem); - ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); - up(&priv->wx_sem); - return ret; + down(&priv->wx_sem); + ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); + up(&priv->wx_sem); + return ret; } static int r8192_wx_get_gen_ie(struct net_device *dev, - struct iw_request_info *info, + struct iw_request_info *info, union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { data->data.length = 0; return 0; } - if (data->data.length < ieee->wpa_ie_len) { + if (data->data.length < ieee->wpa_ie_len) return -E2BIG; - } data->data.length = ieee->wpa_ie_len; memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); - return ret; + return ret; } #define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6 static int r8192_wx_set_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - u32 *info_buf = (u32*)(wrqu->data.pointer); + u32 *info_buf = (u32 *)(wrqu->data.pointer); u32 oid = info_buf[0]; u32 bPromiscuousOn = info_buf[1]; u32 bFilterSourceStationFrame = info_buf[2]; - if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) - { + if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) { ieee->IntelPromiscuousModeInfo.bPromiscuousOn = - (bPromiscuousOn)? (true) : (false); + (bPromiscuousOn) ? (true) : (false); ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame = - (bFilterSourceStationFrame)? (true) : (false); + (bFilterSourceStationFrame) ? (true) : (false); + (bPromiscuousOn) ? + (rtllib_EnableIntelPromiscuousMode(dev, false)) : + (rtllib_DisableIntelPromiscuousMode(dev, false)); - (bPromiscuousOn) ? (rtllib_EnableIntelPromiscuousMode(dev, false)) : - (rtllib_DisableIntelPromiscuousMode(dev, false)); - - printk("=======>%s(), on = %d, filter src sta = %d\n", __func__, - bPromiscuousOn, bFilterSourceStationFrame); + printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n", + __func__, bPromiscuousOn, bFilterSourceStationFrame); } else { return -1; } @@ -1185,56 +1156,55 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev, static int r8192_wx_get_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - down(&priv->wx_sem); + down(&priv->wx_sem); - snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",\ - ieee->IntelPromiscuousModeInfo.bPromiscuousOn,\ - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); - wrqu->data.length = strlen(extra) + 1; + snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d", + ieee->IntelPromiscuousModeInfo.bPromiscuousOn, + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); + wrqu->data.length = strlen(extra) + 1; - up(&priv->wx_sem); + up(&priv->wx_sem); return 0; } #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] -static iw_handler r8192_wx_handlers[] = -{ - IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, - IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, - IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, - IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, - IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, - IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, - IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, - IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, - IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, - IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, - IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, - IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, - IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, - IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, - IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, +static iw_handler r8192_wx_handlers[] = { + IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, + IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, + IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, + IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, + IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick, - IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, - IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, - IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, - IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, - IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, - IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, - IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, - IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, - IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, - IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, - IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, - IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, + IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, + IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, + IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, + IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, @@ -1251,69 +1221,47 @@ static const struct iw_priv_args r8192_private_args[] = { { SIOCIWFIRSTPRIV + 0x0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag" - }, - { + }, { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - }, - { + }, { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x3, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x5, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1, "firm_ver" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "set_power" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x9, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "radio" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xa, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_interv" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xb, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_force" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xc, 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x16, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" - } - , - { + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" + }, { SIOCIWFIRSTPRIV + 0x17, - 0,IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" } }; @@ -1347,14 +1295,13 @@ static iw_handler r8192_private_handler[] = { struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - struct iw_statistics* wstats = &priv->wstats; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + struct iw_statistics *wstats = &priv->wstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if (ieee->state < RTLLIB_LINKED) - { + if (ieee->state < RTLLIB_LINKED) { wstats->qual.qual = 10; wstats->qual.level = 0; wstats->qual.noise = -100; @@ -1362,7 +1309,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } - tmp_level = (&ieee->current_network)->stats.rssi; + tmp_level = (&ieee->current_network)->stats.rssi; tmp_qual = (&ieee->current_network)->stats.signal; tmp_noise = (&ieee->current_network)->stats.noise; @@ -1373,12 +1320,13 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } -struct iw_handler_def r8192_wx_handlers_def={ +struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), .private = r8192_private_handler, .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), + .num_private_args = sizeof(r8192_private_args) / + sizeof(struct iw_priv_args), .get_wireless_stats = r8192_get_wireless_stats, .private_args = (struct iw_priv_args *)r8192_private_args, }; diff --git a/drivers/staging/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl_wx.h index 94d42a82211..6a51a25ec87 100644 --- a/drivers/staging/rtl8192e/rtl_wx.h +++ b/drivers/staging/rtl8192e/rtl_wx.h @@ -26,6 +26,6 @@ struct iw_statistics; extern struct iw_handler_def r8192_wx_handlers_def; struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); -u16 rtl8192_11n_user_show_rates(struct net_device* dev); +u16 rtl8192_11n_user_show_rates(struct net_device *dev); #endif From 32a753ffb2c5aea6c32d34393a8e0da3ecfd78bb Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:27 -0700 Subject: [PATCH 0560/1519] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature VMBUS is an ACPI enumerated device, get rid of the PCI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 67a4f336df9..8f1d6eb7096 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -754,18 +753,6 @@ static struct acpi_driver vmbus_acpi_driver = { }, }; -/* - * We use a PCI table to determine if we should autoload this driver This is - * needed by distro tools to determine if the hyperv drivers should be - * installed and/or configured. We don't do anything else with the table, but - * it needs to be present. - */ -static const struct pci_device_id microsoft_hv_pci_table[] = { - { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ - { 0 } -}; -MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table); - static int __init hv_acpi_init(void) { int ret, t; From 358d2ee2e8f5c25f1661e94c206102c88fdee370 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:28 -0700 Subject: [PATCH 0561/1519] Staging: hv: Replace struct hv_guid with the uuid type already defined in Linux Replace struct hv_guid with the uuid type already defined in Linux. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 18 ++-- drivers/staging/hv/channel.c | 4 +- drivers/staging/hv/channel_mgmt.c | 50 +++++------ drivers/staging/hv/hv_mouse.c | 6 +- drivers/staging/hv/hyperv.h | 24 +++-- drivers/staging/hv/hyperv_vmbus.h | 8 +- drivers/staging/hv/netvsc.c | 6 +- drivers/staging/hv/storvsc_drv.c | 6 +- drivers/staging/hv/vmbus_drv.c | 142 +++++++++++++++--------------- 9 files changed, 129 insertions(+), 135 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index d286b222318..018b29394b0 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -112,8 +112,8 @@ struct block_device_context { static const char *drv_name = "blkvsc"; /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ -static const struct hv_guid dev_type = { - .data = { +static const uuid_le dev_type = { + .b = { 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 } @@ -155,13 +155,13 @@ static int blkvsc_device_add(struct hv_device *device, * id. For IDE devices, the device instance id is formatted as * * - - 8899 - 000000000000. */ - device_info->path_id = device->dev_instance.data[3] << 24 | - device->dev_instance.data[2] << 16 | - device->dev_instance.data[1] << 8 | - device->dev_instance.data[0]; + device_info->path_id = device->dev_instance.b[3] << 24 | + device->dev_instance.b[2] << 16 | + device->dev_instance.b[1] << 8 | + device->dev_instance.b[0]; - device_info->target_id = device->dev_instance.data[5] << 8 | - device->dev_instance.data[4]; + device_info->target_id = device->dev_instance.b[5] << 8 | + device->dev_instance.b[4]; return ret; } @@ -829,7 +829,7 @@ static int blkvsc_drv_init(void) BUILD_BUG_ON(sizeof(sector_t) != 8); - memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid)); + memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le)); drv->driver.name = drv_name; /* The driver belongs to vmbus */ diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 455f47a891f..222adcc24c7 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -81,10 +81,10 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, debuginfo->relid = channel->offermsg.child_relid; debuginfo->state = channel->state; memcpy(&debuginfo->interfacetype, - &channel->offermsg.offer.if_type, sizeof(struct hv_guid)); + &channel->offermsg.offer.if_type, sizeof(uuid_le)); memcpy(&debuginfo->interface_instance, &channel->offermsg.offer.if_instance, - sizeof(struct hv_guid)); + sizeof(uuid_le)); monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index bf011f3fb85..11beb41c373 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -40,12 +40,12 @@ struct vmbus_channel_message_table_entry { #define MAX_MSG_TYPES 4 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8 -static const struct hv_guid +static const uuid_le supported_device_classes[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = { /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ /* Storage - SCSI */ { - .data = { + .b = { 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f } @@ -54,7 +54,7 @@ static const struct hv_guid /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ /* Network */ { - .data = { + .b = { 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E } @@ -63,7 +63,7 @@ static const struct hv_guid /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */ /* Input */ { - .data = { + .b = { 0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A } @@ -72,7 +72,7 @@ static const struct hv_guid /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ /* IDE */ { - .data = { + .b = { 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 } @@ -80,7 +80,7 @@ static const struct hv_guid /* 0E0B6031-5213-4934-818B-38D90CED39DB */ /* Shutdown */ { - .data = { + .b = { 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB } @@ -88,7 +88,7 @@ static const struct hv_guid /* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */ /* TimeSync */ { - .data = { + .b = { 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } @@ -96,7 +96,7 @@ static const struct hv_guid /* {57164f39-9115-4e78-ab55-382f3bd5422d} */ /* Heartbeat */ { - .data = { + .b = { 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d } @@ -104,7 +104,7 @@ static const struct hv_guid /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */ /* KVP */ { - .data = { + .b = { 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 } @@ -231,7 +231,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { /* Shutdown */ { .msg_type = HV_SHUTDOWN_MSG, - .data = { + .data.b = { 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB }, @@ -242,7 +242,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { /* TimeSync */ { .msg_type = HV_TIMESYNC_MSG, - .data = { + .data.b = { 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf }, @@ -252,7 +252,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { /* Heartbeat */ { .msg_type = HV_HEARTBEAT_MSG, - .data = { + .data.b = { 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d }, @@ -261,7 +261,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */ /* KVP */ { - .data = { + .data.b = { 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 }, @@ -358,12 +358,10 @@ static void vmbus_process_offer(struct work_struct *work) spin_lock_irqsave(&vmbus_connection.channel_lock, flags); list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { - if (!memcmp(&channel->offermsg.offer.if_type, - &newchannel->offermsg.offer.if_type, - sizeof(struct hv_guid)) && - !memcmp(&channel->offermsg.offer.if_instance, - &newchannel->offermsg.offer.if_instance, - sizeof(struct hv_guid))) { + if (!uuid_le_cmp(channel->offermsg.offer.if_type, + newchannel->offermsg.offer.if_type) && + !uuid_le_cmp(channel->offermsg.offer.if_instance, + newchannel->offermsg.offer.if_instance)) { fnew = false; break; } @@ -416,9 +414,8 @@ static void vmbus_process_offer(struct work_struct *work) /* Open IC channels */ for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) { - if (memcmp(&newchannel->offermsg.offer.if_type, - &hv_cb_utils[cnt].data, - sizeof(struct hv_guid)) == 0 && + if (!uuid_le_cmp(newchannel->offermsg.offer.if_type, + hv_cb_utils[cnt].data) && vmbus_open(newchannel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0, chn_cb_negotiate, @@ -444,16 +441,15 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) { struct vmbus_channel_offer_channel *offer; struct vmbus_channel *newchannel; - struct hv_guid *guidtype; - struct hv_guid *guidinstance; + uuid_le *guidtype; + uuid_le *guidinstance; int i; int fsupported = 0; offer = (struct vmbus_channel_offer_channel *)hdr; for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) { - if (memcmp(&offer->offer.if_type, - &supported_device_classes[i], - sizeof(struct hv_guid)) == 0) { + if (!uuid_le_cmp(offer->offer.if_type, + supported_device_classes[i])) { fsupported = 1; break; } diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 9f3fbeeed8d..950f4b4cf67 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -179,8 +179,8 @@ struct mousevsc_dev { static const char *driver_name = "mousevsc"; /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */ -static const struct hv_guid mouse_guid = { - .data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, +static const uuid_le mouse_guid = { + .b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A} }; @@ -932,7 +932,7 @@ static int __init mousevsc_init(void) DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing."); memcpy(&drv->dev_type, &mouse_guid, - sizeof(struct hv_guid)); + sizeof(uuid_le)); drv->driver.name = driver_name; diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 1747a2404f6..399d9fe7a81 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -35,9 +36,6 @@ #include -struct hv_guid { - unsigned char data[16]; -}; #define MAX_PAGE_BUFFER_COUNT 16 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ @@ -156,8 +154,8 @@ struct hv_ring_buffer_debug_info { * struct contains the fundamental information about an offer. */ struct vmbus_channel_offer { - struct hv_guid if_type; - struct hv_guid if_instance; + uuid_le if_type; + uuid_le if_instance; u64 int_latency; /* in 100ns units */ u32 if_revision; u32 server_ctx_size; /* in bytes */ @@ -526,8 +524,8 @@ enum vmbus_channel_state { struct vmbus_channel_debug_info { u32 relid; enum vmbus_channel_state state; - struct hv_guid interfacetype; - struct hv_guid interface_instance; + uuid_le interfacetype; + uuid_le interface_instance; u32 monitorid; u32 servermonitor_pending; u32 servermonitor_latency; @@ -786,8 +784,8 @@ struct hv_dev_port_info { struct hv_device_info { u32 chn_id; u32 chn_state; - struct hv_guid chn_type; - struct hv_guid chn_instance; + uuid_le chn_type; + uuid_le chn_instance; u32 monitor_id; u32 server_monitor_pending; @@ -806,7 +804,7 @@ struct hv_driver { const char *name; /* the device type supported by this driver */ - struct hv_guid dev_type; + uuid_le dev_type; struct device_driver driver; @@ -819,10 +817,10 @@ struct hv_driver { /* Base device object */ struct hv_device { /* the device type id of this device */ - struct hv_guid dev_type; + uuid_le dev_type; /* the device instance id of this device */ - struct hv_guid dev_instance; + uuid_le dev_instance; struct device device; @@ -935,7 +933,7 @@ struct ictimesync_data { struct hyperv_service_callback { u8 msg_type; char *log_msg; - unsigned char data[16]; + uuid_le data; struct vmbus_channel *channel; void (*callback) (void *context); }; diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h index 349ad80ce32..16ca90d9ac2 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/staging/hv/hyperv_vmbus.h @@ -451,8 +451,8 @@ enum { /* #define VMBUS_PORT_ID 11 */ /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */ -static const struct hv_guid VMBUS_SERVICE_ID = { - .data = { +static const uuid_le VMBUS_SERVICE_ID = { + .b = { 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c, 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4 }, @@ -601,8 +601,8 @@ extern struct vmbus_connection vmbus_connection; /* General vmbus interface */ -struct hv_device *vmbus_child_device_create(struct hv_guid *type, - struct hv_guid *instance, +struct hv_device *vmbus_child_device_create(uuid_le *type, + uuid_le *instance, struct vmbus_channel *channel); int vmbus_child_device_register(struct hv_device *child_device_obj); diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index dc5e5c488e3..1506b534667 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -36,8 +36,8 @@ static const char *driver_name = "netvsc"; /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const struct hv_guid netvsc_device_type = { - .data = { +static const uuid_le netvsc_device_type = { + .b = { 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E } @@ -1009,7 +1009,7 @@ int netvsc_initialize(struct hv_driver *drv) { drv->name = driver_name; - memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid)); + memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le)); return 0; } diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 7effaf32e25..e4cdbc52d42 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -45,8 +45,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); static const char *driver_name = "storvsc"; /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const struct hv_guid stor_vsci_device_type = { - .data = { +static const uuid_le stor_vsci_device_type = { + .b = { 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f } @@ -765,7 +765,7 @@ static int __init storvsc_drv_init(void) sizeof(u64))); memcpy(&drv->dev_type, &stor_vsci_device_type, - sizeof(struct hv_guid)); + sizeof(uuid_le)); if (max_outstanding_req_per_channel < STORVSC_MAX_IO_REQUESTS) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 8f1d6eb7096..c88a183fa36 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -64,9 +64,9 @@ static void get_channel_info(struct hv_device *device, info->chn_id = debug_info.relid; info->chn_state = debug_info.state; memcpy(&info->chn_type, &debug_info.interfacetype, - sizeof(struct hv_guid)); + sizeof(uuid_le)); memcpy(&info->chn_instance, &debug_info.interface_instance, - sizeof(struct hv_guid)); + sizeof(uuid_le)); info->monitor_id = debug_info.monitorid; @@ -116,41 +116,41 @@ static ssize_t vmbus_show_device_attr(struct device *dev, if (!strcmp(dev_attr->attr.name, "class_id")) { return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_type.data[3], - device_info.chn_type.data[2], - device_info.chn_type.data[1], - device_info.chn_type.data[0], - device_info.chn_type.data[5], - device_info.chn_type.data[4], - device_info.chn_type.data[7], - device_info.chn_type.data[6], - device_info.chn_type.data[8], - device_info.chn_type.data[9], - device_info.chn_type.data[10], - device_info.chn_type.data[11], - device_info.chn_type.data[12], - device_info.chn_type.data[13], - device_info.chn_type.data[14], - device_info.chn_type.data[15]); + device_info.chn_type.b[3], + device_info.chn_type.b[2], + device_info.chn_type.b[1], + device_info.chn_type.b[0], + device_info.chn_type.b[5], + device_info.chn_type.b[4], + device_info.chn_type.b[7], + device_info.chn_type.b[6], + device_info.chn_type.b[8], + device_info.chn_type.b[9], + device_info.chn_type.b[10], + device_info.chn_type.b[11], + device_info.chn_type.b[12], + device_info.chn_type.b[13], + device_info.chn_type.b[14], + device_info.chn_type.b[15]); } else if (!strcmp(dev_attr->attr.name, "device_id")) { return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_instance.data[3], - device_info.chn_instance.data[2], - device_info.chn_instance.data[1], - device_info.chn_instance.data[0], - device_info.chn_instance.data[5], - device_info.chn_instance.data[4], - device_info.chn_instance.data[7], - device_info.chn_instance.data[6], - device_info.chn_instance.data[8], - device_info.chn_instance.data[9], - device_info.chn_instance.data[10], - device_info.chn_instance.data[11], - device_info.chn_instance.data[12], - device_info.chn_instance.data[13], - device_info.chn_instance.data[14], - device_info.chn_instance.data[15]); + device_info.chn_instance.b[3], + device_info.chn_instance.b[2], + device_info.chn_instance.b[1], + device_info.chn_instance.b[0], + device_info.chn_instance.b[5], + device_info.chn_instance.b[4], + device_info.chn_instance.b[7], + device_info.chn_instance.b[6], + device_info.chn_instance.b[8], + device_info.chn_instance.b[9], + device_info.chn_instance.b[10], + device_info.chn_instance.b[11], + device_info.chn_instance.b[12], + device_info.chn_instance.b[13], + device_info.chn_instance.b[14], + device_info.chn_instance.b[15]); } else if (!strcmp(dev_attr->attr.name, "state")) { return sprintf(buf, "%d\n", device_info.chn_state); } else if (!strcmp(dev_attr->attr.name, "id")) { @@ -246,22 +246,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" "%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.data[3], - dev->dev_type.data[2], - dev->dev_type.data[1], - dev->dev_type.data[0], - dev->dev_type.data[5], - dev->dev_type.data[4], - dev->dev_type.data[7], - dev->dev_type.data[6], - dev->dev_type.data[8], - dev->dev_type.data[9], - dev->dev_type.data[10], - dev->dev_type.data[11], - dev->dev_type.data[12], - dev->dev_type.data[13], - dev->dev_type.data[14], - dev->dev_type.data[15]); + dev->dev_type.b[3], + dev->dev_type.b[2], + dev->dev_type.b[1], + dev->dev_type.b[0], + dev->dev_type.b[5], + dev->dev_type.b[4], + dev->dev_type.b[7], + dev->dev_type.b[6], + dev->dev_type.b[8], + dev->dev_type.b[9], + dev->dev_type.b[10], + dev->dev_type.b[11], + dev->dev_type.b[12], + dev->dev_type.b[13], + dev->dev_type.b[14], + dev->dev_type.b[15]); if (ret) return ret; @@ -269,22 +269,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" "%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_instance.data[3], - dev->dev_instance.data[2], - dev->dev_instance.data[1], - dev->dev_instance.data[0], - dev->dev_instance.data[5], - dev->dev_instance.data[4], - dev->dev_instance.data[7], - dev->dev_instance.data[6], - dev->dev_instance.data[8], - dev->dev_instance.data[9], - dev->dev_instance.data[10], - dev->dev_instance.data[11], - dev->dev_instance.data[12], - dev->dev_instance.data[13], - dev->dev_instance.data[14], - dev->dev_instance.data[15]); + dev->dev_instance.b[3], + dev->dev_instance.b[2], + dev->dev_instance.b[1], + dev->dev_instance.b[0], + dev->dev_instance.b[5], + dev->dev_instance.b[4], + dev->dev_instance.b[7], + dev->dev_instance.b[6], + dev->dev_instance.b[8], + dev->dev_instance.b[9], + dev->dev_instance.b[10], + dev->dev_instance.b[11], + dev->dev_instance.b[12], + dev->dev_instance.b[13], + dev->dev_instance.b[14], + dev->dev_instance.b[15]); if (ret) return ret; @@ -303,7 +303,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) /* We found our driver ? */ if (memcmp(&hv_dev->dev_type, &drv->dev_type, - sizeof(struct hv_guid)) == 0) + sizeof(uuid_le)) == 0) match = 1; return match; @@ -630,8 +630,8 @@ EXPORT_SYMBOL(vmbus_child_driver_unregister); * vmbus_child_device_create - Creates and registers a new child device * on the vmbus. */ -struct hv_device *vmbus_child_device_create(struct hv_guid *type, - struct hv_guid *instance, +struct hv_device *vmbus_child_device_create(uuid_le *type, + uuid_le *instance, struct vmbus_channel *channel) { struct hv_device *child_device_obj; @@ -644,9 +644,9 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type, } child_device_obj->channel = channel; - memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid)); + memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le)); memcpy(&child_device_obj->dev_instance, instance, - sizeof(struct hv_guid)); + sizeof(uuid_le)); return child_device_obj; From 17be18c2b5f5c8acd75e4edf1211abf2cfd60fa5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:29 -0700 Subject: [PATCH 0562/1519] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h In preparation for implementing vmbus aliases for auto-loading Hyper-V drivers, define vmbus specific device ID. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- include/linux/mod_devicetable.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index ae28e93fd07..5a123774c2e 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -405,6 +405,13 @@ struct virtio_device_id { }; #define VIRTIO_DEV_ANY_ID 0xffffffff +/* + * For Hyper-V devices we use the device guid as the id. + */ +struct hv_vmbus_device_id { + __u8 guid[16]; +}; + /* i2c */ #define I2C_NAME_SIZE 20 From a91befc116f424883602fb7b57b63b5fcfe18719 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 10:25:37 -0700 Subject: [PATCH 0563/1519] Staging: hv: add driver_data to hv_vmbus_device_id This is going to be needed by some drivers that handle more than one device, like all other bus types do, so prepare for that in advance before the user/kernel api is used. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- include/linux/mod_devicetable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 5a123774c2e..468819cdde8 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -410,6 +410,8 @@ struct virtio_device_id { */ struct hv_vmbus_device_id { __u8 guid[16]; + kernel_ulong_t driver_data /* Data private to the driver */ + __attribute__((aligned(sizeof(kernel_ulong_t)))); }; /* i2c */ From 438812c3ecfd6976d05bf9320783b689ec884dff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 22:31:50 -0500 Subject: [PATCH 0564/1519] staging: rtl8192e: Remove MAC_FMT and MAC_ARG for %pM Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 15 +++---- drivers/staging/rtl8192e/rtl819x_TSProc.c | 6 +-- drivers/staging/rtl8192e/rtl_cam.c | 4 +- drivers/staging/rtl8192e/rtl_dm.c | 4 +- drivers/staging/rtl8192e/rtllib.h | 4 -- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 13 +++--- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 21 +++++---- drivers/staging/rtl8192e/rtllib_rx.c | 46 ++++++++++---------- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_wx.c | 4 +- 10 files changed, 55 insertions(+), 64 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 2e4085b8877..5bdb78cdeab 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -83,8 +83,8 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, u16 tmp = 0; u16 len = ieee->tx_headroom + 9; RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" - " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, - type, MAC_ARG(Dst), ieee->dev); + " sentd to: %pM, ieee->dev:%p\n", __func__, + type, Dst, ieee->dev); if (pBA == NULL || ieee == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " "NULL\n", pBA, ieee); @@ -150,8 +150,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, if (net_ratelimit()) RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), Reason" - "Code(%d) sentd to:"MAC_FMT"\n", __func__, - ReasonCode, MAC_ARG(dst)); + "Code(%d) sentd to: %pM\n", __func__, + ReasonCode, dst); memset(&DelbaParamSet, 0, 2); @@ -265,7 +265,7 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { @@ -347,7 +347,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pBaParamSet = (union ba_param_set *)(tag + 5); pBaTimeoutVal = (u16 *)(tag + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || ieee->pHTInfo->bCurrentHTSupport == false || ieee->pHTInfo->bCurrentAMPDUEnable == false) { @@ -459,8 +459,7 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " - "%s().dst:"MAC_FMT" TID:%d\n", __func__, - MAC_ARG(dst), + "%s().dst: %pM TID:%d\n", __func__, dst, (u8)pDelBaParamSet->field.TID); return -1; } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 519349f0ce4..6ebd20e8530 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -389,9 +389,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" - ", UP:%d, Dir:%d, addr:"MAC_FMT + ", UP:%d, Dir:%d, addr: %pM" " ppTs=%p\n", UP, Dir, - MAC_ARG(Addr), *ppTS); + Addr, *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -462,7 +462,7 @@ void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS, %pM\n", Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { if (memcmp(pTS->Addr, Addr, 6) == 0) { diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index a9991a0fa1c..baf3b6342e4 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -126,8 +126,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, - KeyType, MAC_ARG(MacAddr)); + "KeyType:%d, MacAddr %pM\n", dev, EntryNo, KeyIndex, + KeyType, MacAddr); if (DefaultKey) usConfig |= BIT15 | (KeyType<<2); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 291ec3e9d22..6d201ec3827 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -2322,9 +2322,9 @@ static void dm_check_edca_turbo(struct net_device *dev) static int wb_tmp; if (wb_tmp == 0) { printk(KERN_INFO "%s():iot peer is %s, bssid:" - MAC_FMT"\n", __func__, + " %pM\n", __func__, peername[pHTInfo->IOTPeer], - MAC_ARG(priv->rtllib->current_network.bssid)); + priv->rtllib->current_network.bssid); wb_tmp = 1; } } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c7b3641f30b..b33caccb43a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -700,10 +700,6 @@ do { \ } \ } while (0) -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ - ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] - /* * To use the debug system; * diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 306d6ff707a..78059b9671f 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -279,7 +279,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; @@ -292,9 +292,9 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT + printk(KERN_DEBUG "CCMP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -342,7 +342,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -418,11 +418,10 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%02x%02x%02x%02x%02x%02x " - "rx_pn=%02x%02x%02x%02x%02x%02x " + "tx_pn=%pM rx_pn=%pM " "format_errors=%d replays=%d decrypt_errors=%d\n", ccmp->key_idx, ccmp->key_set, - MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn), + ccmp->tx_pn, ccmp->rx_pn, ccmp->dot11RSNAStatsCCMPFormatErrors, ccmp->dot11RSNAStatsCCMPReplays, ccmp->dot11RSNAStatsCCMPDecryptErrors); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index c4e490e57ad..6a0c8788642 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -400,7 +400,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } return -2; } @@ -412,9 +412,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT + printk(KERN_DEBUG "TKIP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -428,9 +428,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->initialized) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: replay detected: STA=" - MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), + " %pM previous TSC %08x%04x received " + "TSC %08x%04x\n",hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; @@ -453,8 +452,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", - MAC_ARG(hdr->addr2)); + "received packet from %pM\n", + hdr->addr2); } return -7; } @@ -474,7 +473,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: ICV error detected: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -624,8 +623,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " - "MSDU from " MAC_FMT " keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), + "MSDU from %pM keyidx=%d\n", + skb->dev ? skb->dev->name : "N/A", hdr->addr2, keyidx); printk(KERN_DEBUG "%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 205c5750849..35f70d6fe2e 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -305,8 +305,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { RTLLIB_DEBUG_DROP( - "decryption failed (SA=" MAC_FMT - ") res=%d\n", MAC_ARG(hdr->addr2), res); + "decryption failed (SA= %pM" + ") res=%d\n", hdr->addr2, res); if (res == -2) RTLLIB_DEBUG_DROP("Decryption failed ICV " "mismatch (key %d)\n", @@ -345,8 +345,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" - " (SA=" MAC_FMT " keyidx=%d)\n", - ieee->dev->name, MAC_ARG(hdr->addr2), keyidx); + " (SA= %pM keyidx=%d)\n", + ieee->dev->name, hdr->addr2, keyidx); return -1; } @@ -1028,8 +1028,8 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, * frames silently instead of filling system log with * these reports. */ RTLLIB_DEBUG_DROP("Decryption failed (not set)" - " (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + " (SA= %pM)\n", + hdr->addr2); ieee->ieee_stats.rx_discards_undecryptable++; return -1; } @@ -1138,8 +1138,8 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, } else { RTLLIB_DEBUG_DROP( "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + "frame not encrypted (SA= %pM)\n", + hdr->addr2); return -1; } } @@ -1156,9 +1156,9 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { RTLLIB_DEBUG_DROP( "dropped unencrypted RX data " - "frame from " MAC_FMT + "frame from %pM" " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); + hdr->addr2); return -1; } @@ -2309,11 +2309,11 @@ static inline int rtllib_network_init( } if (network->mode == 0) { - RTLLIB_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' " + RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' " "network.\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid)); + network->bssid); return 1; } @@ -2516,9 +2516,9 @@ static inline void rtllib_process_probe_response( return; RTLLIB_DEBUG_SCAN( - "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, (beacon->capability & (1<<0xf)) ? '1' : '0', (beacon->capability & (1<<0xe)) ? '1' : '0', (beacon->capability & (1<<0xd)) ? '1' : '0', @@ -2537,10 +2537,10 @@ static inline void rtllib_process_probe_response( (beacon->capability & (1<<0x0)) ? '1' : '0'); if (rtllib_network_init(ieee, beacon, network, stats)) { - RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2604,11 +2604,11 @@ static inline void rtllib_process_probe_response( /* If there are no more slots, expire the oldest */ list_del(&oldest->list); target = oldest; - RTLLIB_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from " + RTLLIB_DEBUG_SCAN("Expired '%s' ( %pM) from " "network list.\n", escape_essid(target->ssid, target->ssid_len), - MAC_ARG(target->bssid)); + target->bssid); } else { /* Otherwise just pull from the free list */ target = list_entry(ieee->network_free_list.next, @@ -2617,10 +2617,9 @@ static inline void rtllib_process_probe_response( } - RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n", escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), + network->ssid_len), network->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2629,10 +2628,9 @@ static inline void rtllib_process_probe_response( if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { - RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n", escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), + target->ssid_len), target->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index fa0e2afd1ed..dd4dec8c53a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1972,7 +1972,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); + printk(KERN_INFO"New client associated: %pM\n", dest); } void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index c350f4e277d..8cea4a60e1b 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -279,10 +279,10 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, info); else RTLLIB_DEBUG_SCAN("Not showing network '%s (" - MAC_FMT ")' due to age (%lums).\n", + " %pM)' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), + network->bssid, (jiffies - network->last_scanned) / (HZ / 100)); } From 966aeb321cd797332243b270e74d9b08936a6dab Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 07:31:47 -0500 Subject: [PATCH 0565/1519] staging: rtl8192e: Fix sparse (non-endian) messages - Part I Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 24 +-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 169 ++----------------- drivers/staging/rtl8192e/rtl819x_TSProc.c | 35 ++-- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_module.c | 9 +- drivers/staging/rtl8192e/rtllib_softmac.c | 111 +++++------- drivers/staging/rtl8192e/rtllib_tx.c | 29 ++-- 7 files changed, 104 insertions(+), 275 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 5bdb78cdeab..48f9f71051e 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,21 +20,21 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, - u16 Time) +static void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) +static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) +static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; @@ -52,7 +52,7 @@ u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) return bSendDELBA; } -u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) +static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; @@ -193,8 +193,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA) +static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -209,8 +209,8 @@ void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, u16 StatusCode) +static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); @@ -222,9 +222,9 @@ void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, enum tr_select TxRxSelect, - u16 ReasonCode) +static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index f8da913c47b..b1c0c566882 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -214,7 +214,7 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) +static bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -233,7 +233,7 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) +static bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -336,7 +336,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device *ieee) +static void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rtllib_network *net = &ieee->current_network; @@ -378,40 +378,31 @@ void HTIOTPeerDetermine(struct rtllib_device *ieee) pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; } -bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } - -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) -{ - bool retValue = false; - - return retValue; -} - - -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, - struct rtllib_network *network) +static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -422,60 +413,7 @@ u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, return retValue; } -u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 retValue = false; - u8 boundary = 59; - - pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { - if (ieee->current_network.bssht.bdBandWidth == - HT_CHANNEL_WIDTH_20_40) { - if (!(pHTInfo->bRegBW40MHz)) { - if (ieee->current_network.mode != - WIRELESS_MODE_B) { - pHTInfo->bWAIotBroadcom = true; - - if (ieee->b_customer_lenovo_id) - boundary = 30; - - if (ieee->current_network.RSSI >= - boundary) - retValue = true; - } - } - } - } - return retValue; -} - -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - retValue = 1; - - return retValue; -} - -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - return retValue; -} - -u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) +static u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; @@ -484,42 +422,7 @@ u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) return retValue; } -u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) - retValue = 1; - - return retValue; -} - -u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) +static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -532,52 +435,6 @@ void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) } - -u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; @@ -735,7 +592,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, return; } -u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) +static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { u8 i; if (pOperateMCS == NULL) { @@ -1148,7 +1005,7 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) return false; } -void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +static void HTSetConnectBwModeCallback(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 6ebd20e8530..ccec382cea2 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -20,15 +20,15 @@ #include #include "rtl819x_TS.h" -void TsSetupTimeOut(unsigned long data) +static void TsSetupTimeOut(unsigned long data) { } -void TsInactTimeout(unsigned long data) +static void TsInactTimeout(unsigned long data) { } -void RxPktPendingTimeout(unsigned long data) +static void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, @@ -97,7 +97,7 @@ void RxPktPendingTimeout(unsigned long data) spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -void TsAddBaProcess(unsigned long data) +static void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; @@ -109,7 +109,7 @@ void TsAddBaProcess(unsigned long data) "started!!\n"); } -void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) +static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body)); @@ -118,7 +118,7 @@ void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) pTsCommonInfo->TClasNum = 0; } -void ResetTxTsEntry(struct tx_ts_record *pTS) +static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->TxCurSeq = 0; @@ -130,7 +130,7 @@ void ResetTxTsEntry(struct tx_ts_record *pTS) ResetBaEntry(&pTS->TxPendingBARecord); } -void ResetRxTsEntry(struct rx_ts_record *pTS) +static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->RxIndicateSeq = 0xffff; @@ -215,8 +215,8 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, - u32 InactTime) +static void AdmitTS(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); @@ -226,11 +226,12 @@ void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, MSECS(InactTime)); } -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, - u8 TID, enum tr_select TxRxSelect) +static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, + u8 *Addr, u8 TID, + enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; + bool search_dir[4] = {0}; struct list_head *psearch_list; struct ts_common_info *pRet = NULL; if (ieee->iw_mode == IW_MODE_MASTER) { @@ -283,9 +284,9 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, return NULL; } -void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, - union tspec_body *pTSPEC, union qos_tclas *pTCLAS, - u8 TCLAS_Num, u8 TCLAS_Proc) +static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -418,8 +419,8 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } } -void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, - enum tr_select TxRxSelect) +static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 78059b9671f..6196b9aa3a0 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -53,7 +53,7 @@ struct rtllib_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, +static void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { crypto_cipher_encrypt_one((void *)tfm, ct, pt); diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index dd0d8db01bd..0fe67a54edd 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -68,7 +68,7 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) if (ieee->networks) return 0; - ieee->networks = kmalloc( + ieee->networks = kzalloc( MAX_NETWORK_COUNT * sizeof(struct rtllib_network), GFP_KERNEL); if (!ieee->networks) { @@ -77,9 +77,6 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) return -ENOMEM; } - memset(ieee->networks, 0, - MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); - return 0; } @@ -223,7 +220,7 @@ u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc; +static struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -231,7 +228,7 @@ static int show_debug_level(char *page, char **start, off_t offset, return snprintf(page, count, "0x%08X\n", rtllib_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level(struct file *file, const char __user *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index dd4dec8c53a..a420ed1a947 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -23,15 +23,6 @@ #include #include "dot11d.h" -u8 rsn_authen_cipher_suite[16][4] = { - {0x00, 0x0F, 0xAC, 0x00}, - {0x00, 0x0F, 0xAC, 0x01}, - {0x00, 0x0F, 0xAC, 0x02}, - {0x00, 0x0F, 0xAC, 0x03}, - {0x00, 0x0F, 0xAC, 0x04}, - {0x00, 0x0F, 0xAC, 0x05}, -}; - short rtllib_is_54g(struct rtllib_network *net) { return (net->rates_ex_len > 0) || (net->rates_len > 4); @@ -46,7 +37,7 @@ short rtllib_is_shortslot(struct rtllib_network net) * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) +static unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) { unsigned int rate_len = 0; @@ -64,7 +55,7 @@ unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -82,7 +73,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -103,7 +94,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -137,7 +128,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) printk(KERN_ALERT "This is enable turbo mode IE process\n"); } -void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) +static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; @@ -154,7 +145,7 @@ void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) } -struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) +static struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) { struct sk_buff *ret; @@ -169,7 +160,7 @@ struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) return ret; } -void init_mgmt_queue(struct rtllib_device *ieee) +static void init_mgmt_queue(struct rtllib_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } @@ -394,7 +385,7 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee); -void rtllib_send_beacon(struct rtllib_device *ieee) +static void rtllib_send_beacon(struct rtllib_device *ieee) { struct sk_buff *skb; if (!ieee->ieee_up) @@ -412,7 +403,7 @@ void rtllib_send_beacon(struct rtllib_device *ieee) } -void rtllib_send_beacon_cb(unsigned long _ieee) +static void rtllib_send_beacon_cb(unsigned long _ieee) { struct rtllib_device *ieee = (struct rtllib_device *) _ieee; @@ -500,7 +491,7 @@ void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, ieee->bNetPromiscuousMode = false; } -void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) +static void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); @@ -520,7 +511,7 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) } } -void rtllib_softmac_hint11d_wq(void *data) +static void rtllib_softmac_hint11d_wq(void *data) { } @@ -602,7 +593,7 @@ out: wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } -void rtllib_softmac_scan_wq(void *data) +static void rtllib_softmac_scan_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); @@ -662,7 +653,7 @@ out1: -void rtllib_beacons_start(struct rtllib_device *ieee) +static void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock, flags); @@ -673,7 +664,7 @@ void rtllib_beacons_start(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->beacon_lock, flags); } -void rtllib_beacons_stop(struct rtllib_device *ieee) +static void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; @@ -705,7 +696,7 @@ void rtllib_start_send_beacons(struct rtllib_device *ieee) } -void rtllib_softmac_stop_scan(struct rtllib_device *ieee) +static void rtllib_softmac_stop_scan(struct rtllib_device *ieee) { down(&ieee->scan_sem); ieee->scan_watch_dog = 0; @@ -752,7 +743,7 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) } /* called with ieee->lock held */ -void rtllib_start_scan(struct rtllib_device *ieee) +static void rtllib_start_scan(struct rtllib_device *ieee) { RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) @@ -831,24 +822,6 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, return skb; } -void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) -{ - u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { - szQoSOUI[0] = 46; - szQoSOUI[1] = *wmm_len; - memcpy(wmmie, szQoSOUI, 3); - *wmm_len = 3; - } else { - szQoSOUI[1] = *wmm_len + 6; - szQoSOUI[6] = oui_subtype; - memcpy(wmmie, szQoSOUI, 8); - *(wmmie+8) = 0; - *wmm_len = 9; - } -} - static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; @@ -998,7 +971,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; u8 *tag; @@ -1057,7 +1030,7 @@ struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, +static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, u8 *dest) { struct sk_buff *skb = NULL; @@ -1087,7 +1060,7 @@ struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, } -struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) +static struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; struct rtllib_hdr_3addr *hdr; @@ -1114,7 +1087,7 @@ struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) } -struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) +static struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_pspoll_hdr *hdr; @@ -1139,7 +1112,7 @@ struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1148,7 +1121,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) +static void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1157,7 +1130,7 @@ void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) } -void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_probe_resp(ieee, dest); @@ -1466,12 +1439,12 @@ void rtllib_associate_abort(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_associate_abort_cb(unsigned long dev) +static void rtllib_associate_abort_cb(unsigned long dev) { rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) +static void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1495,7 +1468,7 @@ void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) } } -void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) +static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -1526,7 +1499,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) kfree(challenge); } -void rtllib_associate_step2(struct rtllib_device *ieee) +static void rtllib_associate_step2(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; @@ -1546,7 +1519,7 @@ void rtllib_associate_step2(struct rtllib_device *ieee) } #define CANCELLED 2 -void rtllib_associate_complete_wq(void *data) +static void rtllib_associate_complete_wq(void *data) { struct rtllib_device *ieee = (struct rtllib_device *) container_of_work_rsl(data, @@ -1606,7 +1579,7 @@ static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { } -void rtllib_associate_complete(struct rtllib_device *ieee) +static void rtllib_associate_complete(struct rtllib_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -1616,7 +1589,7 @@ void rtllib_associate_complete(struct rtllib_device *ieee) queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); } -void rtllib_associate_procedure_wq(void *data) +static void rtllib_associate_procedure_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, @@ -1828,7 +1801,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) return cpu_to_le16(a->status); } -int auth_rq_parse(struct sk_buff *skb, u8 *dest) +static int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; @@ -1894,7 +1867,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb, u8 *dest) +static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; @@ -2075,7 +2048,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) } -inline void rtllib_sta_ps(struct rtllib_device *ieee) +static inline void rtllib_sta_ps(struct rtllib_device *ieee) { u64 time; short sleep; @@ -2196,7 +2169,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) +static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); @@ -2530,7 +2503,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) } /* called with ieee->lock acquired */ -void rtllib_resume_tx(struct rtllib_device *ieee) +static void rtllib_resume_tx(struct rtllib_device *ieee) { int i; for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; @@ -2675,7 +2648,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) netif_carrier_on(ieee->dev); } -void rtllib_start_monitor_mode(struct rtllib_device *ieee) +static void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ if (ieee->raw_tx) { @@ -2686,7 +2659,7 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) } } -void rtllib_start_ibss_wq(void *data) +static void rtllib_start_ibss_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); @@ -2850,7 +2823,7 @@ void rtllib_start_bss(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_link_change_wq(void *data) +static void rtllib_link_change_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); @@ -2876,7 +2849,7 @@ void rtllib_disassociate(struct rtllib_device *ieee) notify_wx_assoc_event(ieee); } -void rtllib_associate_retry_wq(void *data) +static void rtllib_associate_retry_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); @@ -3194,8 +3167,8 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, - int wpa_ie_len) +static void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3698,7 +3671,7 @@ void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == NULL) { rtllib->state = RTLLIB_NOLINK; for (i = 0; i < 6; i++) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f038aa93083..44e8006bc1a 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -220,8 +220,8 @@ void rtllib_txb_free(struct rtllib_txb *txb) kfree(txb); } -struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) +static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, + gfp_t gfp_mask) { struct rtllib_txb *txb; int i; @@ -251,8 +251,7 @@ struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, return txb; } -int -rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) +static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) { struct ethhdr *eth; struct iphdr *ip; @@ -283,8 +282,9 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, - struct cb_desc *tcb_desc) +static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, + struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; @@ -358,7 +358,7 @@ FORCED_AGG_SETTING: return; } -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, +static void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { tcb_desc->bUseShortPreamble = false; @@ -370,7 +370,7 @@ extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, return; } -extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, +static void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -391,8 +391,8 @@ extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -412,8 +412,9 @@ void rtllib_query_BandwidthMode(struct rtllib_device *ieee, return; } -void rtllib_query_protectionmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc, struct sk_buff *skb) +static void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, + struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -494,8 +495,8 @@ NO_PROTECTION: } -void rtllib_txrate_selectmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; From fec90b64dbbe6edbd11d12af2b8bc045790356e8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 12:55:23 -0500 Subject: [PATCH 0566/1519] staging: rtl8192e: Fix sparse (non-endian) warnings - Part II Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 10 +- drivers/staging/rtl8192e/r8192E_dev.c | 43 ++-- drivers/staging/rtl8192e/r8192E_firmware.c | 45 +--- drivers/staging/rtl8192e/r8192E_phy.c | 38 ++-- drivers/staging/rtl8192e/rtl_core.c | 144 ++++--------- drivers/staging/rtl8192e/rtl_core.h | 1 - drivers/staging/rtl8192e/rtl_dm.c | 237 ++------------------- drivers/staging/rtl8192e/rtl_eeprom.c | 11 +- drivers/staging/rtl8192e/rtl_ps.c | 7 +- drivers/staging/rtl8192e/rtl_wx.c | 10 +- drivers/staging/rtl8192e/rtllib_rx.c | 61 +++--- 11 files changed, 152 insertions(+), 455 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 881eb1f96d2..09978b6428f 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -34,7 +34,7 @@ } /*---------------------------Define functions---------------------------------*/ -extern bool cmpk_message_handle_tx( +bool cmpk_message_handle_tx( struct net_device *dev, u8 *code_virtual_address, u32 packettype, @@ -167,7 +167,7 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) } /* cmpk_Handle_Tx_Feedback */ -void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) +static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; @@ -339,10 +339,8 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) } -extern u32 -cmpk_message_handle_rx( - struct net_device *dev, - struct rtllib_rx_stats *pstats) +u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = rtllib_priv(dev); int total_length; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 229d6df789f..899e4e5e98f 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -57,7 +57,7 @@ void rtl8192e_start_beacon(struct net_device *dev) rtl8192_irq_enable(dev); } -void rtl8192e_update_msr(struct net_device *dev) +static void rtl8192e_update_msr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 msr; @@ -952,7 +952,7 @@ end: return rtStatus; } -void rtl8192_net_update(struct net_device *dev) +static void rtl8192_net_update(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1127,7 +1127,7 @@ static u8 MRateToHwRate8190Pci(u8 rate) return ret; } -u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) +static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) { u8 QueueSelect = 0x0; @@ -1301,7 +1301,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev, entry->OWN = 1; } -u8 HwRateToMRate90(bool bIsHT, u8 rate) +static u8 HwRateToMRate90(bool bIsHT, u8 rate) { u8 ret_rate = 0x02; @@ -1414,7 +1414,7 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) return ret_rate; } -long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) +static long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; @@ -1450,7 +1450,7 @@ long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) _pdrvinfo->RxRate == DESC90_RATE11M) &&\ !_pdrvinfo->RxHT) -void rtl8192_query_rxphystatus( +static void rtl8192_query_rxphystatus( struct r8192_priv *priv, struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, @@ -1664,9 +1664,9 @@ void rtl8192_query_rxphystatus( } } -void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, - struct rtllib_rx_stats *prev_st, - struct rtllib_rx_stats *curr_st) +static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; @@ -1839,10 +1839,11 @@ void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, } } -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, - struct rtllib_rx_stats *pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) +static void rtl8192_TranslateRxSignalStuff(struct net_device *dev, + struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); bool bpacket_match_bssid, bpacket_toself; @@ -1867,7 +1868,7 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & + bpacket_toself = bpacket_match_bssid && /* check this */ (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) @@ -1883,7 +1884,8 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); } -void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, +static void rtl8192_UpdateReceivedRateHistogramStatistics( + struct net_device *dev, struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2255,17 +2257,6 @@ void rtl8192_enable_tx(struct net_device *dev) } -void rtl8192_beacon_disable(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 reg; - - reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); - - reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); -} - void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) { diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index c2689993530..37719859bda 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -23,7 +23,7 @@ #include "r8192E_firmware.h" #include -extern void firmware_init_param(struct net_device *dev) +void firmware_init_param(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -32,8 +32,8 @@ extern void firmware_init_param(struct net_device *dev) MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, - u32 buffer_len) +static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -102,42 +102,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, return rt_status; } -bool fwSendNullPacket(struct net_device *dev, u32 Length) -{ - bool rtStatus = true; - struct r8192_priv *priv = rtllib_priv(dev); - struct sk_buff *skb; - struct cb_desc *tcb_desc; - unsigned char *ptr_buf; - bool bLastInitPacket = false; - - - skb = dev_alloc_skb(Length + 4); - memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->queue_index = TXCMD_QUEUE; - tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; - tcb_desc->bLastIniPkt = bLastInitPacket; - ptr_buf = skb_put(skb, Length); - memset(ptr_buf, 0, Length); - tcb_desc->txbuf_size = (u16)Length; - - if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> - queue_index])) || (priv->rtllib->queue_stop)) { - RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" - "========> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], - skb); - } else { - priv->rtllib->softmac_hard_start_xmit(skb, dev); - } - - write_nic_byte(dev, TPPoll, TPPoll_CQ); - return rtStatus; -} - -bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) +static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) { bool rt_status = true; u32 CPU_status = 0; @@ -184,7 +149,7 @@ CPUCheckMainCodeOKAndTurnOnCPU_Fail: return rt_status; } -bool CPUcheck_firmware_ready(struct net_device *dev) +static bool CPUcheck_firmware_ready(struct net_device *dev) { bool rt_status = true; diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 96ccbd5b25d..83e00d72199 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -53,7 +53,8 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, static void phy_FwRFSerialWrite(struct net_device *dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data); -u32 rtl8192_CalculateBitShift(u32 dwBitMask) + +static u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; for (i = 0; i <= 31; i++) { @@ -105,8 +106,8 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset) +static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; @@ -161,9 +162,9 @@ u32 rtl8192_phy_RFSerialRead(struct net_device *dev, } -void rtl8192_phy_RFSerialWrite(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset, - u32 Data) +static void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; @@ -400,7 +401,7 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType) return; } -void rtl8192_InitBBRFRegDef(struct net_device *dev) +static void rtl8192_InitBBRFRegDef(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -549,7 +550,7 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev, return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device *dev) +static bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -790,7 +791,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, return ret; } -void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) +static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u8 powerlevel = priv->TxPowerLevelCCK[channel-1]; @@ -815,9 +816,10 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) return; } -u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, - u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, - u32 Para1, u32 Para2, u32 msDelay) +static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, + u32 CmdTableIdx, u32 CmdTableSz, + enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) { struct sw_chnl_cmd *pCmd; @@ -843,8 +845,8 @@ u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, - u8 *step, u32 *delay) +static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, + u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -983,7 +985,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, return false; } -void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) +static void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u32 delay = 0; @@ -1410,8 +1412,8 @@ void PHY_SetRtl8192eRfOff(struct net_device *dev) } -bool SetRFPowerState8190(struct net_device *dev, - enum rt_rf_power_state eRFPowerState) +static bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1608,7 +1610,7 @@ bool SetRFPowerState(struct net_device *dev, return bResult; } -extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) +void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 68a4e858ecb..9bc20f0ba39 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -58,10 +58,10 @@ int hwwep = 1; static int channels = 0x3fff; -char *ifname = "wlan%d"; +static char *ifname = "wlan%d"; -struct rtl819x_ops rtl819xp_ops = { +static struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, @@ -108,7 +108,7 @@ static struct pci_driver rtl8192_pci_driver = { /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) +static bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; @@ -276,36 +276,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff & readb((u8 *)dev->mem_start + x); + return 0xff & readb((u8 __iomem *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8 *)dev->mem_start + x); + return readl((u8 __iomem *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8 *)dev->mem_start + x); + return readw((u8 __iomem *)dev->mem_start + x); } void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y, (u8 *)dev->mem_start + x); + writeb(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y, (u8 *)dev->mem_start + x); + writel(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y, (u8 *)dev->mem_start + x); + writew(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } @@ -452,7 +452,7 @@ bool MgntActSet_RF_State(struct net_device *dev, } -short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) +static short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -467,7 +467,7 @@ short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) return skb_queue_len(&ring->queue); } -short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) +static short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -502,14 +502,6 @@ void rtl8192_irq_disable(struct net_device *dev) priv->irq_enabled = 0; } -void rtl8192_irq_clear(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - priv->ops->irq_clear(dev); -} - - void rtl8192_set_chan(struct net_device *dev, short ch) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -579,7 +571,7 @@ static struct rtllib_qos_parameters def_qos_parameters = { {0, 0, 0, 0} }; -void rtl8192_update_beacon(void *data) +static void rtl8192_update_beacon(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); @@ -598,7 +590,7 @@ void rtl8192_update_beacon(void *data) #define MOVE_INTO_HANDLER int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; -void rtl8192_qos_activate(void *data) +static void rtl8192_qos_activate(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); @@ -758,7 +750,7 @@ static int rtl8192_handle_assoc_response(struct net_device *dev, return 0; } -void rtl8192_prepare_beacon(struct r8192_priv *priv) +static void rtl8192_prepare_beacon(struct r8192_priv *priv) { struct net_device *dev = priv->rtllib->dev; struct sk_buff *pskb = NULL, *pnewskb = NULL; @@ -791,7 +783,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) return; } -void rtl8192_stop_beacon(struct net_device *dev) +static void rtl8192_stop_beacon(struct net_device *dev) { } @@ -887,7 +879,7 @@ void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) } } -void rtl8192_refresh_supportrate(struct r8192_priv *priv) +static void rtl8192_refresh_supportrate(struct r8192_priv *priv) { struct rtllib_device *ieee = priv->rtllib; if (ieee->mode == WIRELESS_MODE_N_24G || @@ -903,7 +895,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv *priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) +static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -973,7 +965,7 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) +static int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1016,7 +1008,7 @@ int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) return 0; } -int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) +static int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; @@ -1243,9 +1235,10 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); - if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + if (!priv->pFirmware) + printk(KERN_ERR "rtl8193e: Unable to allocate space " + "for firmware\n"); skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); @@ -1302,7 +1295,7 @@ static void rtl8192_init_priv_task(struct net_device *dev) (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device *dev) +static short rtl8192_get_channel_map(struct net_device *dev) { int i; @@ -1330,7 +1323,7 @@ short rtl8192_get_channel_map(struct net_device *dev) return 0; } -short rtl8192_init(struct net_device *dev) +static short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1395,7 +1388,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev) return 1; } -enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 QueueID; @@ -1454,7 +1447,7 @@ enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1466,8 +1459,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type -rtl819x_ifcheck_resetornot(struct net_device *dev) +static enum reset_type rtl819x_ifcheck_resetornot(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); enum reset_type TxResetType = RESET_TYPE_NORESET; @@ -1500,11 +1492,11 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) } -void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) +static void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) { } -void rtl819x_ifsilentreset(struct net_device *dev) +static void rtl819x_ifsilentreset(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 reset_times = 0; @@ -1643,8 +1635,8 @@ END: } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, - u32 *TotalRxDataNum) +static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, + u32 *TotalRxDataNum) { u16 SlotIndex; u8 i; @@ -1975,7 +1967,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } -void rtl8192_tx_isr(struct net_device *dev, int prio) +static void rtl8192_tx_isr(struct net_device *dev, int prio) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2103,7 +2095,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) return 0; } -short rtl8192_alloc_rx_desc_ring(struct net_device *dev) +static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rx_desc *entry = NULL; @@ -2341,7 +2333,7 @@ rtl8192_record_rxdesc_forlateruse( -void rtl8192_rx_normal(struct net_device *dev) +static void rtl8192_rx_normal(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; @@ -2446,12 +2438,12 @@ done: } -void rtl8192_rx_cmd(struct net_device *dev) +static void rtl8192_rx_cmd(struct net_device *dev) { } -void rtl8192_tx_resume(struct net_device *dev) +static void rtl8192_tx_resume(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; @@ -2504,7 +2496,7 @@ int _rtl8192_up(struct net_device *dev, bool is_silent_reset) } -int rtl8192_open(struct net_device *dev) +static int rtl8192_open(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2527,7 +2519,7 @@ int rtl8192_up(struct net_device *dev) } -int rtl8192_close(struct net_device *dev) +static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2591,7 +2583,7 @@ static void r8192_set_multicast(struct net_device *dev) } -int r8192_set_mac_adr(struct net_device *dev, void *mac) +static int r8192_set_mac_adr(struct net_device *dev, void *mac) { struct r8192_priv *priv = rtllib_priv(dev); struct sockaddr *addr = mac; @@ -2607,7 +2599,7 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac) } /* based on ipw2200 driver */ -int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; @@ -2731,56 +2723,6 @@ out: return ret; } -void FairBeacon(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i = 100; - static u8 forceturn; - u16 beaconint = net->beacon_interval; - - if (priv->rtllib->iw_mode != IW_MODE_ADHOC) - return; - - if (priv->bIbssCoordinator) { - i--; - - if (forceturn == 2) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i <= 94) { - beaconint = beaconint+2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 1; - } - } else { - i++; - - if (forceturn == 1) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i >= 106) { - beaconint = beaconint-2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 2; - } - } -} - irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) { @@ -3077,7 +3019,7 @@ fail: if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq = 0; + priv->irq = 0; } free_rtllib(dev); } @@ -3127,7 +3069,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) kfree(priv->scan_cmd); if (dev->mem_start != 0) { - iounmap((void *)dev->mem_start); + iounmap((void __iomem *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); } diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 03a86fe283c..5b78530bf22 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -1110,7 +1110,6 @@ void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, u8 rtl819x_query_rxpwrpercentage(char antpower); void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, struct rtllib_rx_stats *ptarget_stats); - bool NicIFEnableNIC(struct net_device *dev); bool NicIFDisableNIC(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 6d201ec3827..a7fa9aad6f2 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -134,8 +134,7 @@ static void dm_send_rssi_tofw(struct net_device *dev); static void dm_ctstoself(struct net_device *dev); /*---------------------------Define function prototype------------------------*/ -extern void -init_hal_dm(struct net_device *dev) +void init_hal_dm(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->DM_Type = DM_Type_ByDriver; @@ -158,14 +157,14 @@ init_hal_dm(struct net_device *dev) INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } -extern void deinit_hal_dm(struct net_device *dev) +void deinit_hal_dm(struct net_device *dev) { dm_deInit_fsync(dev); } -extern void hal_dm_watchdog(struct net_device *dev) +void hal_dm_watchdog(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->being_init_adapter) @@ -191,7 +190,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_ctstoself(dev); } -void dm_check_ac_dc_power(struct net_device *dev) +static void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; @@ -215,7 +214,7 @@ void dm_check_ac_dc_power(struct net_device *dev) }; -extern void init_rate_adaptive(struct net_device *dev) +void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1528,10 +1527,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH } } -extern void dm_cck_txpower_adjust( - struct net_device *dev, - bool binch14 -) +void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->IC_Cut >= IC_VersionCut_D) @@ -1540,9 +1536,7 @@ extern void dm_cck_txpower_adjust( dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); } -static void dm_txpower_reset_recovery( - struct net_device *dev -) +static void dm_txpower_reset_recovery(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1570,7 +1564,7 @@ static void dm_txpower_reset_recovery( } -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) +void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; @@ -1624,7 +1618,7 @@ static void dm_bb_initialgain_restore(struct net_device *dev) } -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev) +void dm_backup_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1659,8 +1653,8 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value) +void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, u32 dm_value) { if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; @@ -1704,75 +1698,6 @@ extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void dm_change_fsync_setting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->framesyncMonitor = (u8)DM_Value; - } -} - -extern void -dm_change_rxpath_selection_setting( - struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.Enable = (u8)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } else if (DM_Type == 2) { - if (DM_Value > 40) - DM_Value = 40; - DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } else if (DM_Type == 3) { - if (DM_Value > 25) - DM_Value = 25; - DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } else if (DM_Type == 4) { - if (DM_Value >= CCK_Rx_Version_MAX) - DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method = (u8)DM_Value; - } else if (DM_Type == 10) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } else if (DM_Type == 11) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } else if (DM_Type == 12) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } else if (DM_Type == 13) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } else if (DM_Type == 20) { - if (DM_Value > 1) - DM_Value = 1; - pRA->ping_rssi_enable = (u8)DM_Value; - } else if (DM_Type == 21) { - if (DM_Value > 30) - DM_Value = 30; - pRA->ping_rssi_thresh_for_ra = DM_Value; - } -} static void dm_dig_init(struct net_device *dev) { @@ -1814,37 +1739,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.BackoffVal_range_min = DM_DIG_BACKOFF_MIN; } -void dm_FalseAlarmCounterStatistics(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u32 ret_value; - struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); - FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); - - FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; - - ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); - FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); - FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Parity_Fail + - FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + - FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Cck_fail); - - RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, - FalseAlmCnt->Cnt_all); -} - static void dm_ctrl_initgain_byrssi(struct net_device *dev) { @@ -2099,91 +1993,6 @@ static void dm_initial_gain(struct net_device *dev) } } -void dm_initial_gain_STABeforeConnect( - struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain = 0; - static u8 initialized, force_write; - - RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", - dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); - - - if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { - if (priv->rtllib->eRFPowerState != eRfOn) - return; - - if (dm_digtable.Backoff_Enable_Flag == true) { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { - if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; - else - dm_digtable.backoff_val -= 6; - } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { - if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; - else - dm_digtable.backoff_val += 6; - } - } else - dm_digtable.backoff_val = DM_DIG_BACKOFF; - - if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; - else - dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - - dm_digtable.backoff_val; - - if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? - dm_digtable.cur_ig_value : 0x33; - - if (priv->FalseAlmCnt.Cnt_all > 16000) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - - } else { - return; - } - } else { - dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); - - dm_digtable.backoff_val = DM_DIG_BACKOFF; - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; - dm_digtable.pre_ig_value = 0; - return; - } - - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, - rOFDM0_XAAGCCore1, bMaskByte0)) - force_write = 1; - - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || - !initialized || force_write) { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); - - initial_gain = (u8)dm_digtable.cur_ig_value; - - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, - initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, - initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } - - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " - "backoff_val = %d\n", dm_digtable.cur_ig_value, - dm_digtable.pre_ig_value, dm_digtable.backoff_val); - -} - static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2287,7 +2096,7 @@ static void dm_cs_ratio(struct net_device *dev) } } -extern void dm_init_edca_turbo(struct net_device *dev) +void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2390,22 +2199,6 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, - u32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value >= 50) - DM_Value = 50; - priv->rtllib->CTSToSelfTH = (u8)DM_Value; - } -} - static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2454,7 +2247,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } -extern void dm_CheckRfCtrlGPIO(void *data) +void dm_CheckRfCtrlGPIO(void *data) { struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, gpio_change_rf_wq); @@ -2791,7 +2584,7 @@ static void dm_deInit_fsync(struct net_device *dev) del_timer_sync(&priv->fsync_timer); } -extern void dm_fsync_timer_callback(unsigned long data) +void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); @@ -3091,7 +2884,7 @@ void dm_check_fsync(struct net_device *dev) } } -extern void dm_shadow_init(struct net_device *dev) +void dm_shadow_init(struct net_device *dev) { u8 page; u16 offset; diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index df72a6007d0..c1ccff4a832 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -25,7 +25,7 @@ #include "rtl_core.h" #include "rtl_eeprom.h" -void eprom_cs(struct net_device *dev, short bit) +static void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, @@ -39,7 +39,7 @@ void eprom_cs(struct net_device *dev, short bit) } -void eprom_ck_cycle(struct net_device *dev) +static void eprom_ck_cycle(struct net_device *dev) { write_nic_byte(dev, EPROM_CMD, (1<ps_lock, flags); } -void InactivePsWorkItemCallback(struct net_device *dev) +static void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -214,7 +214,8 @@ void rtllib_ips_leave(struct net_device *dev) up(&priv->rtllib->ips_sem); } -bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) +static bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, + u8 rtPsMode) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index f869ce3dbec..77ea4bb8c7a 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,7 +22,7 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = { +static u32 rtl8192_rates[] = { 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000 }; @@ -198,9 +198,9 @@ struct adhoc_peers_info { unsigned char num; }; -int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8192_wx_get_adhoc_peers(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -1293,7 +1293,7 @@ static iw_handler r8192_private_handler[] = { (iw_handler)r8192_wx_get_PromiscuousMode, }; -struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) +static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 35f70d6fe2e..745ae0861df 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -442,15 +442,20 @@ drop: return 1; } -bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) +static bool AddReorderEntry(struct rx_ts_record *pTS, + struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; while (pList->next != &pTS->RxPendingPktList) { - if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *) + list_entry(pList->next, struct rx_reorder_entry, + List))->SeqNum)) pList = pList->next; - else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) - return false; + else if (SN_EQUAL(pReorderEntry->SeqNum, + ((struct rx_reorder_entry *)list_entry(pList->next, + struct rx_reorder_entry, List))->SeqNum)) + return false; else break; } @@ -539,8 +544,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record pTS->RxIndicateSeq = 0xffff; } -void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, - struct rx_ts_record *pTS, u16 SeqNum) +static void RxReorderIndicatePacket(struct rtllib_device *ieee, + struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; @@ -728,9 +734,9 @@ void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb, u8 *src, u8 *dst) +static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -853,8 +859,9 @@ u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, } -size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats) +static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -874,8 +881,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, - u8 multicast) +static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, + struct sk_buff *skb, u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -916,9 +923,9 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, - struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, - u8 *bssid) +static void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, + u8 *src, u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -946,8 +953,8 @@ void rtllib_rx_extract_addr(struct rtllib_device *ieee, } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, - u8 *bssid, u8 *addr2) +static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, + u8 *dst, u8 *src, u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -1004,7 +1011,7 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, return 0; } -int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1038,7 +1045,7 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats, struct rtllib_crypt_data *crypt, size_t hdrlen) { @@ -1168,7 +1175,7 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) +static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { if (unicast) { @@ -1184,7 +1191,7 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, +static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, struct rtllib_rxb *rxb, u8 *dst, @@ -1243,7 +1250,7 @@ void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, rxb = NULL; } -int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -1412,13 +1419,13 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; } -int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1443,7 +1450,7 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, return 1; } -int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; @@ -2223,7 +2230,7 @@ static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index) +static long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; From c73298e6c45a336d813d613dc535b56964e3f55f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 15:42:43 -0500 Subject: [PATCH 0567/1519] staging: rtl8192e: Add endian checking switch to Makefile Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index fb007491c5f..a66a9ad3368 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -38,3 +38,4 @@ r8192e_pci-objs := \ obj-$(CONFIG_RTL8192E) += r8192e_pci.o +ccflags-y += -D__CHECK_ENDIAN__ From d2ee52aaf30072e4a761e785c752e305ce10152f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:30 -0700 Subject: [PATCH 0568/1519] Staging: hv: Add code to parse struct hv_vmbus_device_id table Add code to parse struct hv_vmbus_device_id table. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e26e2fb462d..b74d21ab91f 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -735,6 +735,27 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, return 1; } +/* + * Looks like: vmbus:guid + * Each byte of the guid will be represented by two hex characters + * in the name. + */ + +static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, + char *alias) +{ + int i; + char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2]; + + for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2) + sprintf(&guid_name[i], "%02x", id->guid[i/2]); + + strcpy(alias, "vmbus:"); + strcat(alias, guid_name); + + return 1; +} + /* Looks like: i2c:S */ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, char *alias) @@ -994,6 +1015,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct virtio_device_id), "virtio", do_virtio_entry, mod); + else if (sym_is(symname, "__mod_vmbus_device_table")) + do_table(symval, sym->st_size, + sizeof(struct hv_vmbus_device_id), "vmbus", + do_vmbus_entry, mod); else if (sym_is(symname, "__mod_i2c_device_table")) do_table(symval, sym->st_size, sizeof(struct i2c_device_id), "i2c", From 2e2c1d17abc3953239bc05ac586eab9f2f14bfda Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:31 -0700 Subject: [PATCH 0569/1519] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver In preparation for supporting auto-loading Hyper-V drivers using vmbus specific aliases, introduce vmbus ID space in struct hv_driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 399d9fe7a81..b8199f4b4ae 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -805,6 +806,7 @@ struct hv_driver { /* the device type supported by this driver */ uuid_le dev_type; + const struct hv_vmbus_device_id *id_table; struct device_driver driver; From ebf16e38515188b61962ba84b59e898ad64ffff6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 11:28:11 -0700 Subject: [PATCH 0570/1519] Staging: hv: file2alias: fix up alias creation logic for hv_vmbus_device_id When I added the driver_data field to hv_vmbus_device_id, I forgot to take into the account how the alias was created, so it would append the kernel pointer to the end of the alias, which is not correct. This changes how the hv_vmbus_device_id alias is created to proper account for the driver_data field. As no module yet uses this alias, it is safe to fix this up at this point in the commit stream. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b74d21ab91f..f936d1fa969 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -745,9 +745,9 @@ static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, char *alias) { int i; - char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2]; + char guid_name[((sizeof(id->guid) + 1)) * 2]; - for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2) + for (i = 0; i < (sizeof(id->guid) * 2); i += 2) sprintf(&guid_name[i], "%02x", id->guid[i/2]); strcpy(alias, "vmbus:"); From eefd7f4555163da346781a2216264ba871aed76b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:32 -0700 Subject: [PATCH 0571/1519] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver Use the newly introduced vmbus ID in the blockvsc driver. Also, do the associated cleanup. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 018b29394b0..9b99387d98c 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -111,14 +111,6 @@ struct block_device_context { static const char *drv_name = "blkvsc"; -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */ -static const uuid_le dev_type = { - .b = { - 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 - } -}; - /* * There is a circular dependency involving blkvsc_request_completion() * and blkvsc_do_request(). @@ -802,10 +794,24 @@ static void blkvsc_request(struct request_queue *queue) } } +static const struct hv_vmbus_device_id id_table[] = { + { + /* IDE guid */ + .guid = { + 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, + 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 + } + }, + { + .guid = { } + }, +}; +MODULE_DEVICE_TABLE(vmbus, id_table); /* The one and only one */ static struct hv_driver blkvsc_drv = { + .id_table = id_table, .probe = blkvsc_probe, .remove = blkvsc_remove, .shutdown = blkvsc_shutdown, @@ -829,7 +835,6 @@ static int blkvsc_drv_init(void) BUILD_BUG_ON(sizeof(sector_t) != 8); - memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le)); drv->driver.name = drv_name; /* The driver belongs to vmbus */ From d847b5fe333d3cc588b26fabb138bb86077f080d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:33 -0700 Subject: [PATCH 0572/1519] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver Use the newly introduced vmbus ID in storvsc driver. Also, do the assciated cleanup. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e4cdbc52d42..ed2140c0154 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -44,14 +44,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); static const char *driver_name = "storvsc"; -/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const uuid_le stor_vsci_device_type = { - .b = { - 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, - 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f - } -}; - struct hv_host_device { struct hv_device *dev; struct kmem_cache *request_pool; @@ -646,7 +638,20 @@ static struct scsi_host_template scsi_driver = { .dma_boundary = PAGE_SIZE-1, }; +static const struct hv_vmbus_device_id id_table[] = { + { + /* SCSI guid */ + .guid = { + 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, + 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f + } + }, + { + .guid = { } + }, +}; +MODULE_DEVICE_TABLE(vmbus, id_table); /* * storvsc_probe - Add a new device for this driver */ @@ -720,6 +725,7 @@ static int storvsc_probe(struct hv_device *device) /* The one and only one */ static struct hv_driver storvsc_drv = { + .id_table = id_table, .probe = storvsc_probe, .remove = storvsc_remove, }; @@ -764,9 +770,6 @@ static int __init storvsc_drv_init(void) sizeof(struct vstor_packet) + sizeof(u64), sizeof(u64))); - memcpy(&drv->dev_type, &stor_vsci_device_type, - sizeof(uuid_le)); - if (max_outstanding_req_per_channel < STORVSC_MAX_IO_REQUESTS) return -1; From 345c4cc3b953a43464776701918e22c7e30cedd0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:34 -0700 Subject: [PATCH 0573/1519] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver Use the newly introduced vmbus ID in netvsc driver. Also, do the associated cleanup. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 10 ---------- drivers/staging/hv/netvsc_drv.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 1506b534667..6f4541bcef8 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -35,15 +35,6 @@ /* Globals */ static const char *driver_name = "netvsc"; -/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const uuid_le netvsc_device_type = { - .b = { - 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E - } -}; - - static struct netvsc_device *alloc_net_device(struct hv_device *device) { struct netvsc_device *net_device; @@ -1009,7 +1000,6 @@ int netvsc_initialize(struct hv_driver *drv) { drv->name = driver_name; - memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le)); return 0; } diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 61989f0d9f0..2e25c957cfd 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -413,8 +413,24 @@ static int netvsc_remove(struct hv_device *dev) return 0; } +static const struct hv_vmbus_device_id id_table[] = { + { + /* Network guid */ + .guid = { + 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, + 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E + } + }, + { + .guid = { } + }, +}; + +MODULE_DEVICE_TABLE(vmbus, id_table); + /* The one and only one */ static struct hv_driver netvsc_drv = { + .id_table = id_table, .probe = netvsc_probe, .remove = netvsc_remove, }; From 1ec91ebe4da8fe016a16eec1177e8edb2ea57517 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:35 -0700 Subject: [PATCH 0574/1519] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver Use the newly introduced vmbus ID in mouse driver. Also, do the associated cleanup. Since the mouse driver is not functional, we disable the autoloading of this driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 950f4b4cf67..dd8a1143b35 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -178,12 +178,6 @@ struct mousevsc_dev { static const char *driver_name = "mousevsc"; -/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */ -static const uuid_le mouse_guid = { - .b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, - 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A} -}; - static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info); static void inputreport_callback(struct hv_device *dev, void *packet, u32 len); static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len); @@ -914,8 +908,26 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) kfree(hid_dev); } +static const struct hv_vmbus_device_id id_table[] = { + { + /* Mouse guid */ + .guid = { + 0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, + 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A + } + }, + { + .guid = { } + }, +}; + +/* + * The mouse driver is not functional; do not auto-load it. + */ +/* MODULE_DEVICE_TABLE(vmbus, id_table); */ static struct hv_driver mousevsc_drv = { + .id_table = id_table, .probe = mousevsc_probe, .remove = mousevsc_remove, }; @@ -931,9 +943,6 @@ static int __init mousevsc_init(void) DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing."); - memcpy(&drv->dev_type, &mouse_guid, - sizeof(uuid_le)); - drv->driver.name = driver_name; /* The driver belongs to vmbus */ From 283f21294ea02f7608e0c833b9c982712427fc50 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:36 -0700 Subject: [PATCH 0575/1519] Staging: hv: util: Make hv_utils a vmbus device driver In preperation for supporting auto-loading the util driver, make the util driver a vmbus driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 64 +++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index c164b54b4cd..a620f4d810c 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -36,6 +36,8 @@ static u8 *shut_txf_buf; static u8 *time_txf_buf; static u8 *hbeat_txf_buf; +static const char *driver_name = "hv_util"; + static void shutdown_onchannelcallback(void *context) { struct vmbus_channel *channel = context; @@ -210,6 +212,63 @@ static void heartbeat_onchannelcallback(void *context) } } +/* + * The devices managed by the util driver don't need any additional + * setup. + */ +static int util_probe(struct hv_device *dev) +{ + return 0; +} + +static int util_remove(struct hv_device *dev) +{ + return 0; +} + +static const struct hv_vmbus_device_id id_table[] = { + { + /* Shutdown guid */ + .guid = { + 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, + 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB + } + }, + { + /* Time synch guid */ + .guid = { + 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf + } + }, + { + /* Heartbeat guid */ + .guid = { + 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d + } + }, + { + /* KVP guid */ + .guid = { + 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 + } + }, + { + .guid = { } + }, +}; + +MODULE_DEVICE_TABLE(vmbus, id_table); + +/* The one and only one */ +static struct hv_driver util_drv = { + .id_table = id_table, + .probe = util_probe, + .remove = util_remove, +}; + static const struct pci_device_id __initconst hv_utils_pci_table[] __maybe_unused = { { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */ @@ -264,7 +323,9 @@ static int __init init_hyperv_utils(void) hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; - return 0; + util_drv.driver.name = driver_name; + + return vmbus_child_driver_register(&util_drv.driver); } static void exit_hyperv_utils(void) @@ -296,6 +357,7 @@ static void exit_hyperv_utils(void) kfree(shut_txf_buf); kfree(time_txf_buf); kfree(hbeat_txf_buf); + vmbus_child_driver_unregister(&util_drv.driver); } module_init(init_hyperv_utils); From c45cf2d4976e2fcde68d88898a37af70f2caaf5d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 11:41:33 -0700 Subject: [PATCH 0576/1519] Staging: hv: create VMBUS_DEVICE macro and use it. This is to be used to be able to write hv_vmbus_device_id tables easier. This patch also converts all hv drivers to use the macro, saving some lines of code and making things easier to read overall. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 14 +++------- drivers/staging/hv/hv_mouse.c | 14 +++------- drivers/staging/hv/hv_util.c | 44 ++++++++++---------------------- drivers/staging/hv/hyperv.h | 11 ++++++++ drivers/staging/hv/netvsc_drv.c | 14 +++------- drivers/staging/hv/storvsc_drv.c | 14 +++------- 6 files changed, 40 insertions(+), 71 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 9b99387d98c..d170f24a07f 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -795,16 +795,10 @@ static void blkvsc_request(struct request_queue *queue) } static const struct hv_vmbus_device_id id_table[] = { - { - /* IDE guid */ - .guid = { - 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 - } - }, - { - .guid = { } - }, + /* IDE guid */ + { VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, + 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) }, + { }, }; MODULE_DEVICE_TABLE(vmbus, id_table); diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index dd8a1143b35..ebd17150d6c 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -909,16 +909,10 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) } static const struct hv_vmbus_device_id id_table[] = { - { - /* Mouse guid */ - .guid = { - 0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, - 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A - } - }, - { - .guid = { } - }, + /* Mouse guid */ + { VMBUS_DEVICE(0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, + 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A) }, + { }, }; /* diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index a620f4d810c..5bd6f00b824 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -227,37 +227,19 @@ static int util_remove(struct hv_device *dev) } static const struct hv_vmbus_device_id id_table[] = { - { - /* Shutdown guid */ - .guid = { - 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB - } - }, - { - /* Time synch guid */ - .guid = { - 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, - 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf - } - }, - { - /* Heartbeat guid */ - .guid = { - 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, - 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d - } - }, - { - /* KVP guid */ - .guid = { - 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, - 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 - } - }, - { - .guid = { } - }, + /* Shutdown guid */ + { VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, + 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) }, + /* Time synch guid */ + { VMBUS_DEVICE(0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) }, + /* Heartbeat guid */ + { VMBUS_DEVICE(0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) }, + /* KVP guid */ + { VMBUS_DEVICE(0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6) }, + { }, }; MODULE_DEVICE_TABLE(vmbus, id_table); diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index b8199f4b4ae..d96de668eb1 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -848,6 +848,17 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d) int vmbus_child_driver_register(struct device_driver *drv); void vmbus_child_driver_unregister(struct device_driver *drv); +/** + * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device + * + * This macro is used to create a struct hv_vmbus_device_id that matches a + * specific device. + */ +#define VMBUS_DEVICE(g0, g1, g2, g3, g4, g5, g6, g7, \ + g8, g9, ga, gb, gc, gd, ge, gf) \ + .guid = { g0, g1, g2, g3, g4, g5, g6, g7, \ + g8, g9, ga, gb, gc, gd, ge, gf }, + /* * Common header for Hyper-V ICs */ diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 2e25c957cfd..c3b7de14700 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -414,16 +414,10 @@ static int netvsc_remove(struct hv_device *dev) } static const struct hv_vmbus_device_id id_table[] = { - { - /* Network guid */ - .guid = { - 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E - } - }, - { - .guid = { } - }, + /* Network guid */ + { VMBUS_DEVICE(0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, + 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E) }, + { }, }; MODULE_DEVICE_TABLE(vmbus, id_table); diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index ed2140c0154..f85f2ea2374 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -639,16 +639,10 @@ static struct scsi_host_template scsi_driver = { }; static const struct hv_vmbus_device_id id_table[] = { - { - /* SCSI guid */ - .guid = { - 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, - 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f - } - }, - { - .guid = { } - }, + /* SCSI guid */ + { VMBUS_DEVICE(0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, + 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) }, + { }, }; MODULE_DEVICE_TABLE(vmbus, id_table); From 5cee7cb79d210f48c19692a79e0508ec001e439f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:37 -0700 Subject: [PATCH 0577/1519] Staging: hv: vmbus: Cleanup vmbus_match() Use the preferred mechanism to compare guids in vmbus_match(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index c88a183fa36..b651968177a 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -302,8 +302,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) struct hv_device *hv_dev = device_to_hv_device(device); /* We found our driver ? */ - if (memcmp(&hv_dev->dev_type, &drv->dev_type, - sizeof(uuid_le)) == 0) + if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type)) match = 1; return match; From 0ddda6603a6eea0b3aff294648ecb30a22e974f1 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:38 -0700 Subject: [PATCH 0578/1519] Staging: hv: vmbus: Cleanup vmbus_uevent() code Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code. [gregkh - fixed code to handle driver_data portion of struct hv_vmbus_device_id] Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 56 ++++++---------------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index b651968177a..afb16704221 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = { * This routine is invoked when a device is added or removed on the vmbus to * generate a uevent to udev in the userspace. The udev will then look at its * rule and the uevent generated here to load the appropriate driver + * + * The alias string will be of the form vmbus:guid where guid is the string + * representation of the device guid (each byte of the guid will be + * represented with two hex characters. */ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) { struct hv_device *dev = device_to_hv_device(device); - int ret; + int i, ret; + char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) * 2]; - ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.b[3], - dev->dev_type.b[2], - dev->dev_type.b[1], - dev->dev_type.b[0], - dev->dev_type.b[5], - dev->dev_type.b[4], - dev->dev_type.b[7], - dev->dev_type.b[6], - dev->dev_type.b[8], - dev->dev_type.b[9], - dev->dev_type.b[10], - dev->dev_type.b[11], - dev->dev_type.b[12], - dev->dev_type.b[13], - dev->dev_type.b[14], - dev->dev_type.b[15]); + for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2) + sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]); - if (ret) - return ret; - - ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_instance.b[3], - dev->dev_instance.b[2], - dev->dev_instance.b[1], - dev->dev_instance.b[0], - dev->dev_instance.b[5], - dev->dev_instance.b[4], - dev->dev_instance.b[7], - dev->dev_instance.b[6], - dev->dev_instance.b[8], - dev->dev_instance.b[9], - dev->dev_instance.b[10], - dev->dev_instance.b[11], - dev->dev_instance.b[12], - dev->dev_instance.b[13], - dev->dev_instance.b[14], - dev->dev_instance.b[15]); - if (ret) - return ret; - - return 0; + ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name); + return ret; } From 5841a829594983077f670192b78fee4f7712e2b4 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:39 -0700 Subject: [PATCH 0579/1519] Staging: hv: vmbus: Support the notion of id tables in vmbus_match() Introduce code to handle driver specific id tables to the vmbus core (vmbus_match). This would allow us to handle more than one device type with a given driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index afb16704221..82769a41197 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -255,21 +255,31 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) return ret; } +static uuid_le null_guid; + +static inline bool is_null_guid(const __u8 *guid) +{ + if (memcmp(guid, &null_guid, sizeof(uuid_le))) + return false; + return true; +} + /* * vmbus_match - Attempt to match the specified device to the specified driver */ static int vmbus_match(struct device *device, struct device_driver *driver) { - int match = 0; struct hv_driver *drv = drv_to_hv_drv(driver); struct hv_device *hv_dev = device_to_hv_device(device); + const struct hv_vmbus_device_id *id_array = drv->id_table; - /* We found our driver ? */ - if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type)) - match = 1; + for (; !is_null_guid(id_array->guid); id_array++) + if (!memcmp(&id_array->guid, &hv_dev->dev_type.b, + sizeof(struct hv_vmbus_device_id))) + return 1; - return match; + return 0; } /* From 49ce6757cfb4de5be695a47f2cbcbc5589838af6 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:40 -0700 Subject: [PATCH 0580/1519] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c Get rid of an unnecessary include line in vmbus_drv.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 82769a41197..0114b04d224 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include From 4e80fbfc7ff4e063d96b258aaa3da97e8e4dc6a5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:41 -0700 Subject: [PATCH 0581/1519] Staging: hv: storvsc: Get rid of the DMI signature Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index f85f2ea2374..6f67e9bfebd 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -724,27 +723,6 @@ static struct hv_driver storvsc_drv = { .remove = storvsc_remove, }; -/* - * We use a DMI table to determine if we should autoload this driver This is - * needed by distro tools to determine if the hyperv drivers should be - * installed and/or configured. We don't do anything else with the table, but - * it needs to be present. - */ - -static const struct dmi_system_id __initconst -hv_stor_dmi_table[] __maybe_unused = { - { - .ident = "Hyper-V", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), - DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), - }, - }, - { }, -}; -MODULE_DEVICE_TABLE(dmi, hv_stor_dmi_table); - static int __init storvsc_drv_init(void) { int ret; From d7dc6b9c2e8fec9f9d6ebe518918d028a505ef7b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:42 -0700 Subject: [PATCH 0582/1519] Staging: hv: netvsc: Get rid of the PCI signature Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the PCI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index c3b7de14700..1c3c5fef950 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -471,13 +470,6 @@ static int __init netvsc_drv_init(void) return ret; } -static const struct pci_device_id __initconst -hv_netvsc_pci_table[] __maybe_unused = { - { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ - { 0 } -}; -MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table); - MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); MODULE_DESCRIPTION("Microsoft Hyper-V network driver"); From 2e7a35adbb4fdca2e5f2a02791c83704f4b1797f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:43 -0700 Subject: [PATCH 0583/1519] Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 1c3c5fef950..2d2955c1925 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -434,20 +433,6 @@ static void __exit netvsc_drv_exit(void) } -static const struct dmi_system_id __initconst -hv_netvsc_dmi_table[] __maybe_unused = { - { - .ident = "Hyper-V", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), - DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), - }, - }, - { }, -}; -MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table); - static int __init netvsc_drv_init(void) { struct hv_driver *drv = &netvsc_drv; @@ -455,10 +440,6 @@ static int __init netvsc_drv_init(void) pr_info("initializing...."); - if (!dmi_check_system(hv_netvsc_dmi_table)) - return -ENODEV; - - /* Callback to client driver to complete the initialization */ netvsc_initialize(drv); From 84385b057fae74eb91a2a163be59543a31291bc6 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:44 -0700 Subject: [PATCH 0584/1519] Staging: hv: util: Get rid of the DMI signature in hv_util.c Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index 5bd6f00b824..c16a7f1e228 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "hyperv.h" @@ -258,22 +257,6 @@ hv_utils_pci_table[] __maybe_unused = { }; MODULE_DEVICE_TABLE(pci, hv_utils_pci_table); - -static const struct dmi_system_id __initconst -hv_utils_dmi_table[] __maybe_unused = { - { - .ident = "Hyper-V", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), - DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), - }, - }, - { }, -}; -MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table); - - static int __init init_hyperv_utils(void) { pr_info("Registering HyperV Utility Driver\n"); @@ -282,9 +265,6 @@ static int __init init_hyperv_utils(void) return -ENODEV; - if (!dmi_check_system(hv_utils_dmi_table)) - return -ENODEV; - shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); From c411a5981d6f53ed2502ad06a2ee70d67ed13f12 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:45 -0700 Subject: [PATCH 0585/1519] Staging: hv: util: Get rid of the PCI signature in hv_util.c Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the PCI signature. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index c16a7f1e228..b0d89deec76 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "hyperv.h" #include "hv_kvp.h" @@ -250,13 +249,6 @@ static struct hv_driver util_drv = { .remove = util_remove, }; -static const struct pci_device_id __initconst -hv_utils_pci_table[] __maybe_unused = { - { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */ - { 0 } -}; -MODULE_DEVICE_TABLE(pci, hv_utils_pci_table); - static int __init init_hyperv_utils(void) { pr_info("Registering HyperV Utility Driver\n"); From 768fa21919b7f30b77f0b3ba94939f5556d111d5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 15:07:32 -0700 Subject: [PATCH 0586/1519] Staging: hv: fix up driver registering mess Individual drivers should never be touching the 'struct device' field, so if that is a requirement to pass to the vmbus core, you know something is wrong. This patch fixes that all up, and resolves the problem where the module reference counting was not happening properly for the individual drivers as well. Overall, it reduces the lines of code the individual drivers have to have, which tells you that this is the correct thing to do. Also, somehow the _GPL marking for the functions got removed on an older patch. As the name of the function was changing, properly change the _GPL marking as well at the same time. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 17 +++---------- drivers/staging/hv/hv_mouse.c | 21 +++------------- drivers/staging/hv/hv_util.c | 9 +++---- drivers/staging/hv/hyperv.h | 8 ++++-- drivers/staging/hv/hyperv_net.h | 1 - drivers/staging/hv/netvsc.c | 14 ----------- drivers/staging/hv/netvsc_drv.c | 19 +++----------- drivers/staging/hv/storvsc_drv.c | 24 ++++++------------ drivers/staging/hv/vmbus_drv.c | 43 ++++++++++++++++---------------- 9 files changed, 46 insertions(+), 110 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index d170f24a07f..07dc9ed6ec5 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -109,7 +109,6 @@ struct block_device_context { int users; }; -static const char *drv_name = "blkvsc"; /* * There is a circular dependency involving blkvsc_request_completion() @@ -805,6 +804,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table); /* The one and only one */ static struct hv_driver blkvsc_drv = { + .name = "blkvsc", .id_table = id_table, .probe = blkvsc_probe, .remove = blkvsc_remove, @@ -824,24 +824,13 @@ static const struct block_device_operations block_ops = { */ static int blkvsc_drv_init(void) { - struct hv_driver *drv = &blkvsc_drv; - int ret; - BUILD_BUG_ON(sizeof(sector_t) != 8); - - drv->driver.name = drv_name; - - /* The driver belongs to vmbus */ - ret = vmbus_child_driver_register(&drv->driver); - - return ret; + return vmbus_driver_register(&blkvsc_drv); } - static void blkvsc_drv_exit(void) { - - vmbus_child_driver_unregister(&blkvsc_drv.driver); + vmbus_driver_unregister(&blkvsc_drv); } /* diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index ebd17150d6c..572717317e7 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -176,8 +176,6 @@ struct mousevsc_dev { }; -static const char *driver_name = "mousevsc"; - static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info); static void inputreport_callback(struct hv_device *dev, void *packet, u32 len); static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len); @@ -921,33 +919,20 @@ static const struct hv_vmbus_device_id id_table[] = { /* MODULE_DEVICE_TABLE(vmbus, id_table); */ static struct hv_driver mousevsc_drv = { + .name = "mousevsc", .id_table = id_table, .probe = mousevsc_probe, .remove = mousevsc_remove, }; -static void mousevsc_drv_exit(void) -{ - vmbus_child_driver_unregister(&mousevsc_drv.driver); -} - static int __init mousevsc_init(void) { - struct hv_driver *drv = &mousevsc_drv; - - DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing."); - - drv->driver.name = driver_name; - - /* The driver belongs to vmbus */ - vmbus_child_driver_register(&drv->driver); - - return 0; + return vmbus_driver_register(&mousevsc_drv); } static void __exit mousevsc_exit(void) { - mousevsc_drv_exit(); + vmbus_driver_unregister(&mousevsc_drv); } /* diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index b0d89deec76..f2f456f5e44 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -34,8 +34,6 @@ static u8 *shut_txf_buf; static u8 *time_txf_buf; static u8 *hbeat_txf_buf; -static const char *driver_name = "hv_util"; - static void shutdown_onchannelcallback(void *context) { struct vmbus_channel *channel = context; @@ -244,6 +242,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table); /* The one and only one */ static struct hv_driver util_drv = { + .name = "hv_util", .id_table = id_table, .probe = util_probe, .remove = util_remove, @@ -277,9 +276,7 @@ static int __init init_hyperv_utils(void) hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; - util_drv.driver.name = driver_name; - - return vmbus_child_driver_register(&util_drv.driver); + return vmbus_driver_register(&util_drv); } static void exit_hyperv_utils(void) @@ -311,7 +308,7 @@ static void exit_hyperv_utils(void) kfree(shut_txf_buf); kfree(time_txf_buf); kfree(hbeat_txf_buf); - vmbus_child_driver_unregister(&util_drv.driver); + vmbus_driver_unregister(&util_drv); } module_init(init_hyperv_utils); diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index d96de668eb1..c24981198b1 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -845,8 +845,12 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d) /* Vmbus interface */ -int vmbus_child_driver_register(struct device_driver *drv); -void vmbus_child_driver_unregister(struct device_driver *drv); +#define vmbus_driver_register(driver) \ + __vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) +int __must_check __vmbus_driver_register(struct hv_driver *hv_driver, + struct module *owner, + const char *mod_name); +void vmbus_driver_unregister(struct hv_driver *hv_driver); /** * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h index 27f987b48df..5782fea9a17 100644 --- a/drivers/staging/hv/hyperv_net.h +++ b/drivers/staging/hv/hyperv_net.h @@ -96,7 +96,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, unsigned int status); int netvsc_recv_callback(struct hv_device *device_obj, struct hv_netvsc_packet *packet); -int netvsc_initialize(struct hv_driver *drv); int rndis_filter_open(struct hv_device *dev); int rndis_filter_close(struct hv_device *dev); int rndis_filter_device_add(struct hv_device *dev, diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 6f4541bcef8..cb02eed741f 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -32,9 +32,6 @@ #include "hyperv_net.h" -/* Globals */ -static const char *driver_name = "netvsc"; - static struct netvsc_device *alloc_net_device(struct hv_device *device) { struct netvsc_device *net_device; @@ -992,14 +989,3 @@ cleanup: return ret; } - -/* - * netvsc_initialize - Main entry point - */ -int netvsc_initialize(struct hv_driver *drv) -{ - - drv->name = driver_name; - - return 0; -} diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 2d2955c1925..ad1ef038ff7 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -422,6 +422,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table); /* The one and only one */ static struct hv_driver netvsc_drv = { + .name = "netvsc", .id_table = id_table, .probe = netvsc_probe, .remove = netvsc_remove, @@ -429,26 +430,12 @@ static struct hv_driver netvsc_drv = { static void __exit netvsc_drv_exit(void) { - vmbus_child_driver_unregister(&netvsc_drv.driver); + vmbus_driver_unregister(&netvsc_drv); } - static int __init netvsc_drv_init(void) { - struct hv_driver *drv = &netvsc_drv; - int ret; - - pr_info("initializing...."); - - /* Callback to client driver to complete the initialization */ - netvsc_initialize(drv); - - drv->driver.name = drv->name; - - /* The driver belongs to vmbus */ - ret = vmbus_child_driver_register(&drv->driver); - - return ret; + return vmbus_driver_register(&netvsc_drv); } MODULE_LICENSE("GPL"); diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 6f67e9bfebd..0297418e8a6 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -41,8 +41,6 @@ static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; module_param(storvsc_ringbuffer_size, int, S_IRUGO); MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); -static const char *driver_name = "storvsc"; - struct hv_host_device { struct hv_device *dev; struct kmem_cache *request_pool; @@ -718,6 +716,7 @@ static int storvsc_probe(struct hv_device *device) /* The one and only one */ static struct hv_driver storvsc_drv = { + .name = "storvsc", .id_table = id_table, .probe = storvsc_probe, .remove = storvsc_remove, @@ -725,8 +724,6 @@ static struct hv_driver storvsc_drv = { static int __init storvsc_drv_init(void) { - int ret; - struct hv_driver *drv = &storvsc_drv; u32 max_outstanding_req_per_channel; /* @@ -735,29 +732,22 @@ static int __init storvsc_drv_init(void) * the ring buffer indices) by the max request size (which is * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64) */ - max_outstanding_req_per_channel = - ((storvsc_ringbuffer_size - PAGE_SIZE) / - ALIGN(MAX_MULTIPAGE_BUFFER_PACKET + - sizeof(struct vstor_packet) + sizeof(u64), - sizeof(u64))); + ((storvsc_ringbuffer_size - PAGE_SIZE) / + ALIGN(MAX_MULTIPAGE_BUFFER_PACKET + + sizeof(struct vstor_packet) + sizeof(u64), + sizeof(u64))); if (max_outstanding_req_per_channel < STORVSC_MAX_IO_REQUESTS) return -1; - drv->driver.name = driver_name; - - - /* The driver belongs to vmbus */ - ret = vmbus_child_driver_register(&drv->driver); - - return ret; + return vmbus_driver_register(&storvsc_drv); } static void __exit storvsc_drv_exit(void) { - vmbus_child_driver_unregister(&storvsc_drv.driver); + vmbus_driver_unregister(&storvsc_drv); } MODULE_LICENSE("GPL"); diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 0114b04d224..26f49010e1f 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -552,51 +552,50 @@ static int vmbus_bus_init(int irq) } /** - * vmbus_child_driver_register() - Register a vmbus's child driver - * @drv: Pointer to driver structure you want to register - * + * __vmbus_child_driver_register - Register a vmbus's driver + * @drv: Pointer to driver structure you want to register + * @owner: owner module of the drv + * @mod_name: module name string * * Registers the given driver with Linux through the 'driver_register()' call - * And sets up the hyper-v vmbus handling for this driver. + * and sets up the hyper-v vmbus handling for this driver. * It will return the state of the 'driver_register()' call. * - * Mainly used by Hyper-V drivers. */ -int vmbus_child_driver_register(struct device_driver *drv) +int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, const char *mod_name) { int ret; - pr_info("child driver registering - name %s\n", drv->name); + pr_info("registering driver %s\n", hv_driver->name); - /* The child driver on this vmbus */ - drv->bus = &hv_bus; + hv_driver->driver.name = hv_driver->name; + hv_driver->driver.owner = owner; + hv_driver->driver.mod_name = mod_name; + hv_driver->driver.bus = &hv_bus; - ret = driver_register(drv); + ret = driver_register(&hv_driver->driver); vmbus_request_offers(); return ret; } -EXPORT_SYMBOL(vmbus_child_driver_register); +EXPORT_SYMBOL_GPL(__vmbus_driver_register); /** - * vmbus_child_driver_unregister() - Unregister a vmbus's child driver - * @drv: Pointer to driver structure you want to un-register + * vmbus_driver_unregister() - Unregister a vmbus's driver + * @drv: Pointer to driver structure you want to un-register * - * - * Un-register the given driver with Linux through the 'driver_unregister()' - * call. And ungegisters the driver from the Hyper-V vmbus handler. - * - * Mainly used by Hyper-V drivers. + * Un-register the given driver that was previous registered with a call to + * vmbus_driver_register() */ -void vmbus_child_driver_unregister(struct device_driver *drv) +void vmbus_driver_unregister(struct hv_driver *hv_driver) { - pr_info("child driver unregistering - name %s\n", drv->name); + pr_info("unregistering driver %s\n", hv_driver->name); - driver_unregister(drv); + driver_unregister(&hv_driver->driver); } -EXPORT_SYMBOL(vmbus_child_driver_unregister); +EXPORT_SYMBOL_GPL(vmbus_driver_unregister); /* * vmbus_child_device_create - Creates and registers a new child device From 94a66c9c803a31805d98c92e65593b756ffa05c4 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:49 -0700 Subject: [PATCH 0587/1519] Staging: hv: vmbus: Get rid of some unnecessary comments Get rid of some unnecessary comments. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 26f49010e1f..be62b6244e3 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -44,8 +44,6 @@ static struct tasklet_struct event_dpc; unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL); EXPORT_SYMBOL(vmbus_loglevel); - /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */ - /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */ static struct completion probe_event; static int irq; From ffca7c40b62b182d9de17c7229346f4230df46d6 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:50 -0700 Subject: [PATCH 0588/1519] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c Cleanup unnecessary comments in hv.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index 2192d7885d4..d2b921bd765 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -164,11 +164,7 @@ int hv_init(void) goto cleanup; max_leaf = query_hypervisor_info(); - /* HvQueryHypervisorFeatures(maxLeaf); */ - /* - * We only support running on top of Hyper-V - */ rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid); if (hv_context.guestid != 0) @@ -181,10 +177,6 @@ int hv_init(void) /* See if the hypercall page is already set */ rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); - /* - * Allocate the hypercall page memory - * virtaddr = osd_page_alloc(1); - */ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC); if (!virtaddr) From 5433e00334d3e20f8bff70845c7f44e00cdf2d14 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:51 -0700 Subject: [PATCH 0589/1519] Staging: hv: vmbus: Cleanup error handling in hv_init() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index d2b921bd765..736794ef787 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -151,7 +151,6 @@ static u64 do_hypercall(u64 control, void *input, void *output) */ int hv_init(void) { - int ret = 0; int max_leaf; union hv_x64_msr_hypercall_contents hypercall_msr; void *virtaddr = NULL; @@ -214,7 +213,7 @@ int hv_init(void) hv_context.signal_event_param->flag_number = 0; hv_context.signal_event_param->rsvdz = 0; - return ret; + return 0; cleanup: if (virtaddr) { @@ -225,8 +224,8 @@ cleanup: vfree(virtaddr); } - ret = -1; - return ret; + + return -ENOTSUPP; } /* From 7a9462d842197cba9ca16b915284289535c88675 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:52 -0700 Subject: [PATCH 0590/1519] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c Get rid of unnecessay comments in connection.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/connection.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index e6b40392e08..0e7efce3128 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -215,8 +215,6 @@ static void process_chn_event(u32 relid) { struct vmbus_channel *channel; - /* ASSERT(relId > 0); */ - /* * Find the channel based on this relid and invokes the * channel callback to process the event From 1f22b9aae313ae5707358abbe9617ea13c7f80c5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:53 -0700 Subject: [PATCH 0591/1519] Staging: hv: vmbus: Get rid of the function dump_gpadl_body() Get rid of the function dump_gpadl_body() since it adds no value and actually is in the data path. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 222adcc24c7..2d5bfacf9e1 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -239,24 +239,6 @@ errorout: } EXPORT_SYMBOL_GPL(vmbus_open); -/* - * dump_gpadl_body - Dump the gpadl body message to the console for - * debugging purposes. - */ -static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len) -{ - int i; - int pfncount; - - pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) / - sizeof(u64); - - DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount); - - for (i = 0; i < pfncount; i++) - DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu", - i, gpadl->pfn[i]); -} /* * dump_gpadl_header - Dump the gpadl header message to the console for @@ -485,8 +467,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, CHANNELMSG_GPADL_BODY; gpadl_body->gpadl = next_gpadl_handle; - dump_gpadl_body(gpadl_body, submsginfo->msgsize - - sizeof(*submsginfo)); ret = vmbus_post_msg(gpadl_body, submsginfo->msgsize - sizeof(*submsginfo)); From da06da287d9f2697f247024efbb6e18a764411f8 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:54 -0700 Subject: [PATCH 0592/1519] Staging: hv: vmbus: Get rid of the function dump_gpadl_header() Get rid of the function dump_gpadl_header() as this adds no value. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 2d5bfacf9e1..aa0a15013c0 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -239,33 +239,6 @@ errorout: } EXPORT_SYMBOL_GPL(vmbus_open); - -/* - * dump_gpadl_header - Dump the gpadl header message to the console for - * debugging purposes. - */ -static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl) -{ - int i, j; - int pagecount; - - DPRINT_DBG(VMBUS, - "gpadl header - relid %d, range count %d, range buflen %d", - gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen); - for (i = 0; i < gpadl->rangecount; i++) { - pagecount = gpadl->range[i].byte_count >> PAGE_SHIFT; - pagecount = (pagecount > 26) ? 26 : pagecount; - - DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d " - "page count %d", i, gpadl->range[i].byte_count, - gpadl->range[i].byte_offset, pagecount); - - for (j = 0; j < pagecount; j++) - DPRINT_DBG(VMBUS, "%d) pfn %llu", j, - gpadl->range[i].pfn_array[j]); - } -} - /* * create_gpadl_header - Creates a gpadl for the specified buffer */ @@ -443,7 +416,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, gpadlmsg->child_relid = channel->offermsg.child_relid; gpadlmsg->gpadl = next_gpadl_handle; - dump_gpadl_header(gpadlmsg); spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_add_tail(&msginfo->msglistentry, From 0987ff696d55ad4454211d0b72615fb52b05aa77 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:55 -0700 Subject: [PATCH 0593/1519] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c Rename openMsg to open_msg in channel.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index aa0a15013c0..ebd75529549 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, u32 recv_ringbuffer_size, void *userdata, u32 userdatalen, void (*onchannelcallback)(void *context), void *context) { - struct vmbus_channel_open_channel *openMsg; + struct vmbus_channel_open_channel *open_msg; struct vmbus_channel_msginfo *openInfo = NULL; void *in, *out; unsigned long flags; @@ -183,14 +183,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, init_completion(&openInfo->waitevent); - openMsg = (struct vmbus_channel_open_channel *)openInfo->msg; - openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL; - openMsg->openid = newchannel->offermsg.child_relid; - openMsg->child_relid = newchannel->offermsg.child_relid; - openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle; - openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >> + open_msg = (struct vmbus_channel_open_channel *)openInfo->msg; + open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL; + open_msg->openid = newchannel->offermsg.child_relid; + open_msg->child_relid = newchannel->offermsg.child_relid; + open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle; + open_msg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >> PAGE_SHIFT; - openMsg->server_contextarea_gpadlhandle = 0; + open_msg->server_contextarea_gpadlhandle = 0; if (userdatalen > MAX_USER_DEFINED_BYTES) { err = -EINVAL; @@ -198,14 +198,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, } if (userdatalen) - memcpy(openMsg->userdata, userdata, userdatalen); + memcpy(open_msg->userdata, userdata, userdatalen); spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_add_tail(&openInfo->msglistentry, &vmbus_connection.chn_msg_list); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); - ret = vmbus_post_msg(openMsg, + ret = vmbus_post_msg(open_msg, sizeof(struct vmbus_channel_open_channel)); if (ret != 0) From c8a56985faae8e4150779b781de8d53afa4a7da2 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:56 -0700 Subject: [PATCH 0594/1519] Staging: hv: vmbus: Get rid of unnecessary comments in channel.c Get rid of unnecessary comments in channel.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index ebd75529549..e02060e719d 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -76,7 +76,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, struct hv_monitor_page *monitorpage; u8 monitor_group = (u8)channel->offermsg.monitorid / 32; u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; - /* u32 monitorBit = 1 << monitorOffset; */ debuginfo->relid = channel->offermsg.child_relid; debuginfo->state = channel->state; @@ -392,7 +391,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, { struct vmbus_channel_gpadl_header *gpadlmsg; struct vmbus_channel_gpadl_body *gpadl_body; - /* struct vmbus_channel_gpadl_created *gpadlCreated; */ struct vmbus_channel_msginfo *msginfo = NULL; struct vmbus_channel_msginfo *submsginfo; u32 msgcount; @@ -474,8 +472,6 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) unsigned long flags; int ret, t; - /* ASSERT(gpadl_handle != 0); */ - info = kmalloc(sizeof(*info) + sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL); if (!info) From 176fb9e3f1c145c502dfcd88b2800039aa5e2a24 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:57 -0700 Subject: [PATCH 0595/1519] Staging: hv: vmbus: Change the variable name openInfo to open_info in channel.c Change the variable name openInfo to open_info in channel.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index e02060e719d..9eb8def2266 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, void (*onchannelcallback)(void *context), void *context) { struct vmbus_channel_open_channel *open_msg; - struct vmbus_channel_msginfo *openInfo = NULL; + struct vmbus_channel_msginfo *open_info = NULL; void *in, *out; unsigned long flags; int ret, t, err = 0; @@ -172,17 +172,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, } /* Create and init the channel open message */ - openInfo = kmalloc(sizeof(*openInfo) + + open_info = kmalloc(sizeof(*open_info) + sizeof(struct vmbus_channel_open_channel), GFP_KERNEL); - if (!openInfo) { + if (!open_info) { err = -ENOMEM; goto errorout; } - init_completion(&openInfo->waitevent); + init_completion(&open_info->waitevent); - open_msg = (struct vmbus_channel_open_channel *)openInfo->msg; + open_msg = (struct vmbus_channel_open_channel *)open_info->msg; open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL; open_msg->openid = newchannel->offermsg.child_relid; open_msg->child_relid = newchannel->offermsg.child_relid; @@ -200,7 +200,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, memcpy(open_msg->userdata, userdata, userdatalen); spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); - list_add_tail(&openInfo->msglistentry, + list_add_tail(&open_info->msglistentry, &vmbus_connection.chn_msg_list); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); @@ -210,22 +210,22 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, if (ret != 0) goto cleanup; - t = wait_for_completion_timeout(&openInfo->waitevent, 5*HZ); + t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ); if (t == 0) { err = -ETIMEDOUT; goto errorout; } - if (openInfo->response.open_result.status) - err = openInfo->response.open_result.status; + if (open_info->response.open_result.status) + err = open_info->response.open_result.status; cleanup: spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); - list_del(&openInfo->msglistentry); + list_del(&open_info->msglistentry); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); - kfree(openInfo); + kfree(open_info); return err; errorout: @@ -233,7 +233,7 @@ errorout: hv_ringbuffer_cleanup(&newchannel->inbound); free_pages((unsigned long)out, get_order(send_ringbuffer_size + recv_ringbuffer_size)); - kfree(openInfo); + kfree(open_info); return err; } EXPORT_SYMBOL_GPL(vmbus_open); From d2598f017f02bbc3623503c6e08f22f7ea473cdd Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:58 -0700 Subject: [PATCH 0596/1519] Staging: hv: vmbus: Cleanup error values in ringbuffer.c Use standard Linux errno values in ringbuffer.c and do the associated cleanup in the clients. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/netvsc.c | 2 +- drivers/staging/hv/ring_buffer.c | 6 +++--- drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 07dc9ed6ec5..2b41eb677b2 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -725,7 +725,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev, } else { ret = blkvsc_submit_request(blkvsc_req, blkvsc_request_completion); - if (ret == -1) { + if (ret == -EAGAIN) { pending = 1; list_add_tail(&blkvsc_req->pend_entry, &blkdev->pending_list); diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index cb02eed741f..d547ff676a0 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -565,7 +565,7 @@ retry_send_cmplt: if (ret == 0) { /* success */ /* no-op */ - } else if (ret == -1) { + } else if (ret == -EAGAIN) { /* no more room...wait a bit and attempt to retry 3 times */ retries++; dev_err(&device->device, "unable to send receive completion pkt" diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index 42f76728429..9212699a663 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -390,7 +390,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, /* is empty since the read index == write index */ if (bytes_avail_towrite <= totalbytes_towrite) { spin_unlock_irqrestore(&outring_info->ring_lock, flags); - return -1; + return -EAGAIN; } /* Write to the ring buffer */ @@ -450,7 +450,7 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info, spin_unlock_irqrestore(&Inring_info->ring_lock, flags); - return -1; + return -EAGAIN; } /* Convert to byte offset */ @@ -496,7 +496,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer, if (bytes_avail_toread < buflen) { spin_unlock_irqrestore(&inring_info->ring_lock, flags); - return -1; + return -EAGAIN; } next_read_location = diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 0297418e8a6..29ac6440688 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -578,7 +578,7 @@ retry_request: /* Invokes the vsc to start an IO */ ret = storvsc_do_io(dev, &cmd_request->request); - if (ret == -1) { + if (ret == -EAGAIN) { /* no more space */ if (cmd_request->bounce_sgl_count) { From 3d5cad97c4be2bfc5cb4e52a0972c6e3bf8c278d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:59 -0700 Subject: [PATCH 0597/1519] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw() Use standard Linux errno values. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 2 +- drivers/staging/hv/hv_mouse.c | 2 +- drivers/staging/hv/netvsc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 9eb8def2266..ac92c1f9926 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -811,7 +811,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, pr_err("Buffer too small - needed %d bytes but " "got space for only %d bytes\n", packetlen, bufferlen); - return -2; + return -ENOBUFS; } *requestid = desc.trans_id; diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 572717317e7..d7e24bce4c0 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -539,7 +539,7 @@ static void mousevsc_on_channel_callback(void *context) } break; } - } else if (ret == -2) { + } else if (ret == -ENOBUFS) { /* Handle large packet */ bufferlen = bytes_recvd; buffer = kzalloc(bytes_recvd, GFP_KERNEL); diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index d547ff676a0..b89ac7e40ca 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -884,7 +884,7 @@ static void netvsc_channel_cb(void *context) break; } - } else if (ret == -2) { + } else if (ret == -ENOBUFS) { /* Handle large packet */ buffer = kmalloc(bytes_recvd, GFP_ATOMIC); if (buffer == NULL) { From 0293e5cabcd9067f35a64575922470b92d642d0e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:00 -0700 Subject: [PATCH 0598/1519] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe() Get rid of an unnecessary print statement in netvsc_probe(). Furthermore, this fixes a bug since netdev_err is being invoked after the device has been freed. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index ad1ef038ff7..0b8ac1abe1a 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -355,8 +355,6 @@ static int netvsc_probe(struct hv_device *dev) if (ret != 0) { free_netdev(net); dev_set_drvdata(&dev->device, NULL); - - netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); return ret; } From 5289d3d160e8d5c63974502696ab5def71891f18 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:01 -0700 Subject: [PATCH 0599/1519] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up The function hv_post_msg() can fail because of transient resource conditions. It may be useful to retry the operation. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/hyperv.h | 1 + drivers/staging/hv/connection.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/hyperv.h b/arch/x86/include/asm/hyperv.h index 5df477ac3af..b80420bcd09 100644 --- a/arch/x86/include/asm/hyperv.h +++ b/arch/x86/include/asm/hyperv.h @@ -189,5 +189,6 @@ #define HV_STATUS_INVALID_HYPERCALL_CODE 2 #define HV_STATUS_INVALID_HYPERCALL_INPUT 3 #define HV_STATUS_INVALID_ALIGNMENT 4 +#define HV_STATUS_INSUFFICIENT_BUFFERS 19 #endif diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 0e7efce3128..a88ad707256 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -268,10 +269,25 @@ void vmbus_on_event(unsigned long data) int vmbus_post_msg(void *buffer, size_t buflen) { union hv_connection_id conn_id; + int ret = 0; + int retries = 0; conn_id.asu32 = 0; conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID; - return hv_post_message(conn_id, 1, buffer, buflen); + + /* + * hv_post_message() can have transient failures because of + * insufficient resources. Retry the operation a couple of + * times before giving up. + */ + while (retries < 3) { + ret = hv_post_message(conn_id, 1, buffer, buflen); + if (ret != HV_STATUS_INSUFFICIENT_BUFFERS) + return ret; + retries++; + msleep(100); + } + return ret; } /* From d225d36b13927defee0f5d51ade9987bb617d465 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:02 -0700 Subject: [PATCH 0600/1519] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add() Use standard Linux error values and cleanup error handling. I would like to acknowledge Andre Bartke (andre.bartke@gmail.com) for highlighting this problem. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 30297861194..915aeeed11a 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device, device_info = (struct storvsc_device_info *)additional_info; stor_device = alloc_stor_device(device); - if (!stor_device) { - ret = -1; - goto cleanup; - } + if (!stor_device) + return -ENOMEM; /* Save the channel properties to our storvsc channel */ @@ -409,11 +407,13 @@ int storvsc_dev_add(struct hv_device *device, stor_device->port_number = device_info->port_number; /* Send it back up */ ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size); - + if (ret) { + free_stor_device(stor_device); + return ret; + } device_info->path_id = stor_device->path_id; device_info->target_id = stor_device->target_id; -cleanup: return ret; } From 5260e291ff116ff1db14166a778fcab3f5932bc8 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:03 -0700 Subject: [PATCH 0601/1519] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 915aeeed11a..22ac6f21e26 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -111,7 +111,7 @@ static int storvsc_channel_init(struct hv_device *device) stor_device = get_stor_device(device); if (!stor_device) - return -1; + return -ENODEV; request = &stor_device->init_request; vstor_packet = &request->vstor_packet; From cae50a27a0405b7a70a97a2c9c22912955c84d44 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:04 -0700 Subject: [PATCH 0602/1519] Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp() Cleanup error handling in storvsc_connect_to_vsp(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 22ac6f21e26..2b73f726bbb 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -376,7 +376,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) storvsc_on_channel_callback, device); if (ret != 0) - return -1; + return ret; ret = storvsc_channel_init(device); From 3b54eed7de90d59b2c6fa416513826279acc3bbd Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:05 -0700 Subject: [PATCH 0603/1519] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 2b73f726bbb..2b914e41f52 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -454,7 +454,7 @@ int storvsc_do_io(struct hv_device *device, stor_device = get_stor_device(device); if (!stor_device) - return -2; + return -ENODEV; request->device = device; From e9bda4348b8dc907ffb26dcda53fff568d35a045 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:06 -0700 Subject: [PATCH 0604/1519] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c Get rid of some unnecessary DPRINTs from storvsc.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 2b914e41f52..3730f3fce38 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -125,8 +125,6 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION..."); - ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request, @@ -145,7 +143,6 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->status != 0) goto cleanup; - DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION..."); /* reuse the packet for version range supported */ memset(vstor_packet, 0, sizeof(struct vstor_packet)); @@ -174,8 +171,6 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->status != 0) goto cleanup; - /* Query channel properties */ - DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION..."); memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES; @@ -207,8 +202,6 @@ static int storvsc_channel_init(struct hv_device *device) stor_device->target_id = vstor_packet->storage_channel_properties.target_id; - DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION..."); - memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; @@ -232,7 +225,6 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->status != 0) goto cleanup; - DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****"); cleanup: put_stor_device(device); @@ -305,13 +297,8 @@ static void storvsc_on_receive(struct hv_device *device, storvsc_on_io_completion(device, vstor_packet, request); break; case VSTOR_OPERATION_REMOVE_DEVICE: - DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION"); - /* TODO: */ - break; default: - DPRINT_INFO(STORVSC, "Unknown operation received - %d", - vstor_packet->operation); break; } } @@ -421,9 +408,6 @@ int storvsc_dev_remove(struct hv_device *device) { struct storvsc_device *stor_device; - DPRINT_INFO(STORVSC, "disabling storage device (%p)...", - device->ext); - stor_device = release_stor_device(device); /* From 1920da8801284c954e6edb8156a84fa9ce041128 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:07 -0700 Subject: [PATCH 0605/1519] Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c Fix/cleanup some dated comments in storvsc.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 3730f3fce38..827b6a307ef 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -166,7 +166,6 @@ static int storvsc_channel_init(struct hv_device *device) goto cleanup; } - /* TODO: Check returned version */ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || vstor_packet->status != 0) goto cleanup; @@ -193,7 +192,6 @@ static int storvsc_channel_init(struct hv_device *device) goto cleanup; } - /* TODO: Check returned version */ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || vstor_packet->status != 0) goto cleanup; @@ -384,11 +382,12 @@ int storvsc_dev_add(struct hv_device *device, /* Save the channel properties to our storvsc channel */ - /* FIXME: */ /* * If we support more than 1 scsi channel, we need to set the * port number here to the scsi channel but how do we get the - * scsi channel prior to the bus scan + * scsi channel prior to the bus scan. + * + * The host does not support this. */ stor_device->port_number = device_info->port_number; @@ -545,4 +544,3 @@ int storvsc_get_major_info(struct storvsc_device_info *device_info, return -ENODEV; } - From f3b741658c983a2a7abc5d22a5dc60b503f6cbc3 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:08 -0700 Subject: [PATCH 0606/1519] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 29ac6440688..0eb8c71b787 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -346,7 +346,7 @@ static int storvsc_host_reset(struct hv_device *device) stor_device = get_stor_device(device); if (!stor_device) - return -1; + return -ENODEV; request = &stor_device->reset_request; vstor_packet = &request->vstor_packet; From 8e854680b57440a8bbfdaae05534b010060f7966 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:09 -0700 Subject: [PATCH 0607/1519] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 0eb8c71b787..69a312f0b36 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -685,7 +685,7 @@ static int storvsc_probe(struct hv_device *device) if (ret != 0) { kmem_cache_destroy(host_dev->request_pool); scsi_host_put(host); - return -1; + return -ENODEV; } host_dev->path = device_info.path_id; @@ -706,7 +706,7 @@ static int storvsc_probe(struct hv_device *device) kmem_cache_destroy(host_dev->request_pool); scsi_host_put(host); - return -1; + return -ENODEV; } scsi_scan_host(host); From b06efc199f9b8cc49e47d441f837a2dbe4971e4e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:10 -0700 Subject: [PATCH 0608/1519] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 69a312f0b36..faa8d576087 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -740,7 +740,7 @@ static int __init storvsc_drv_init(void) if (max_outstanding_req_per_channel < STORVSC_MAX_IO_REQUESTS) - return -1; + return -EINVAL; return vmbus_driver_register(&storvsc_drv); } From 51a805d0ce0f78810fd90d4e9eafd8a0ab4bdb58 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:11 -0700 Subject: [PATCH 0609/1519] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 0b8ac1abe1a..90a3198c997 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -338,7 +338,7 @@ static int netvsc_probe(struct hv_device *dev) net = alloc_etherdev(sizeof(struct net_device_context)); if (!net) - return -1; + return -ENOMEM; /* Set initial state */ netif_carrier_off(net); From a3e00530469baa39ccc08b1731a4e120bd63012f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:12 -0700 Subject: [PATCH 0610/1519] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf() Cleanup error return codes in netvsc_destroy_recv_buf(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index b89ac7e40ca..baa0c8d9153 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -160,7 +160,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) if (ret != 0) { dev_err(&net_device->dev->device, "unable to send " "revoke receive buffer to netvsp"); - return -1; + return ret; } } @@ -175,7 +175,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) if (ret != 0) { dev_err(&net_device->dev->device, "unable to teardown receive buffer's gpadl"); - return -1; + return -ret; } net_device->recv_buf_gpadl_handle = 0; } From 927bc33c0a239b706635b23c5cc1f3df2a3c8b86 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:13 -0700 Subject: [PATCH 0611/1519] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index baa0c8d9153..5703fd7c524 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -207,7 +207,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) if (!net_device) { dev_err(&device->device, "unable to get net device..." "device being destroyed?"); - return -1; + return -ENODEV; } net_device->recv_buf = @@ -216,7 +216,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) if (!net_device->recv_buf) { dev_err(&device->device, "unable to allocate receive " "buffer of size %d", net_device->recv_buf_size); - ret = -1; + ret = -ENOMEM; goto cleanup; } @@ -269,7 +269,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) "initialzation with NetVsp - status %d", init_packet->msg.v1_msg. send_recv_buf_complete.status); - ret = -1; + ret = -EINVAL; goto cleanup; } @@ -281,7 +281,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device->recv_section = kmalloc(net_device->recv_section_cnt * sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL); if (net_device->recv_section == NULL) { - ret = -1; + ret = -EINVAL; goto cleanup; } @@ -297,7 +297,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) */ if (net_device->recv_section_cnt != 1 || net_device->recv_section->offset != 0) { - ret = -1; + ret = -EINVAL; goto cleanup; } From 0f48c72ca63a6e1da7f226163c36fecd7a923fed Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:14 -0700 Subject: [PATCH 0612/1519] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 5703fd7c524..9cc126ba8d7 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -323,7 +323,7 @@ static int netvsc_connect_vsp(struct hv_device *device) if (!net_device) { dev_err(&device->device, "unable to get net device..." "device being destroyed?"); - return -1; + return -ENODEV; } init_packet = &net_device->channel_init_pkt; @@ -354,13 +354,13 @@ static int netvsc_connect_vsp(struct hv_device *device) if (init_packet->msg.init_msg.init_complete.status != NVSP_STAT_SUCCESS) { - ret = -1; + ret = -EINVAL; goto cleanup; } if (init_packet->msg.init_msg.init_complete. negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) { - ret = -1; + ret = -EPROTO; goto cleanup; } /* Send the ndis version */ @@ -381,10 +381,8 @@ static int netvsc_connect_vsp(struct hv_device *device) sizeof(struct nvsp_message), (unsigned long)init_packet, VM_PKT_DATA_INBAND, 0); - if (ret != 0) { - ret = -1; + if (ret != 0) goto cleanup; - } /* Post the big receive buffer to NetVSP */ ret = netvsc_init_recv_buf(device); From ff2bd69ae3ec164b606114fcbd9b9e4d5f2bcdc7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:15 -0700 Subject: [PATCH 0613/1519] Staging: hv: netvsc: Cleanup error return values in netvsc_send() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 9cc126ba8d7..f7f4957ace1 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -409,7 +409,7 @@ int netvsc_device_remove(struct hv_device *device) net_device = release_outbound_net_device(device); if (!net_device) { dev_err(&device->device, "No net device present!!"); - return -1; + return -ENODEV; } /* Wait for all send completions */ @@ -499,7 +499,7 @@ int netvsc_send(struct hv_device *device, if (!net_device) { dev_err(&device->device, "net device (%p) shutting down..." "ignoring outbound packets", net_device); - return -2; + return -ENODEV; } sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT; From ace163a85a9a98e7f91db3a23db3f63689038f1e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:16 -0700 Subject: [PATCH 0614/1519] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index f7f4957ace1..b6e1fb988d2 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -918,7 +918,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) net_device = alloc_net_device(device); if (!net_device) { - ret = -1; + ret = -ENOMEM; goto cleanup; } @@ -947,7 +947,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) if (ret != 0) { dev_err(&device->device, "unable to open channel: %d", ret); - ret = -1; goto cleanup; } @@ -959,7 +958,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) if (ret != 0) { dev_err(&device->device, "unable to connect to NetVSP - %d", ret); - ret = -1; goto close; } From 62c0743ef00cb0ad0b32b05fb96acd4d8e7391dd Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:17 -0700 Subject: [PATCH 0615/1519] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index dbb52019975..8e1ef0056d6 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -358,14 +358,14 @@ int rndis_filter_receive(struct hv_device *dev, if (!net_dev->extension) { dev_err(&dev->device, "got rndis message but no rndis device - " "dropping this message!\n"); - return -1; + return -ENODEV; } rndis_dev = (struct rndis_device *)net_dev->extension; if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) { dev_err(&dev->device, "got rndis message but rndis device " "uninitialized...dropping this message!\n"); - return -1; + return -ENODEV; } rndis_hdr = (struct rndis_message *)kmap_atomic( From de6e0580d5884942f58a636902e5b0225f38b8cf Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:18 -0700 Subject: [PATCH 0616/1519] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 8e1ef0056d6..f26886d7738 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -437,7 +437,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG, RNDIS_MESSAGE_SIZE(struct rndis_query_request)); if (!request) { - ret = -1; + ret = -ENOMEM; goto Cleanup; } From 58ef3977ce8e0edba374dd7645e59cf5afdc6447 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:19 -0700 Subject: [PATCH 0617/1519] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter() Use standard Linux error codes and cleanup some error paths. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index f26886d7738..f5f3052e32b 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -511,7 +511,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32)); if (!request) { - ret = -1; + ret = -ENOMEM; goto Cleanup; } @@ -531,7 +531,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, t = wait_for_completion_timeout(&request->wait_event, 5*HZ); if (t == 0) { - ret = -1; dev_err(&dev->net_dev->dev->device, "timeout before we got a set response...\n"); /* @@ -540,8 +539,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, */ goto Exit; } else { - if (ret > 0) - ret = 0; set_complete = &request->response_msg.msg.set_complete; status = set_complete->status; } From bc49b92671632d09a0fa6651c4fdf2b9ab0632ee Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:20 -0700 Subject: [PATCH 0618/1519] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index f5f3052e32b..a71f29d5ca0 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -562,7 +562,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG, RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); if (!request) { - ret = -1; + ret = -ENOMEM; goto Cleanup; } @@ -596,7 +596,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) ret = 0; } else { dev->state = RNDIS_DEV_UNINITIALIZED; - ret = -1; + ret = -EINVAL; } Cleanup: From 327efbae1f96743c9b208e8a4c667eea9b8cf6c0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:21 -0700 Subject: [PATCH 0619/1519] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add() Use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index a71f29d5ca0..f0d1362913e 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -673,7 +673,7 @@ int rndis_filter_device_add(struct hv_device *dev, rndisDevice = get_rndis_device(); if (!rndisDevice) - return -1; + return -ENODEV; /* * Let the inner driver handle this first to create the netvsc channel From fdb3c32cb7b80d28f23f005543eb4f0d6e88c2a3 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:22 -0700 Subject: [PATCH 0620/1519] Staging: hv: mouse: Change the jump label Cleanup to cleanup Change the jump label "Cleanup" to "cleanup". Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index d7e24bce4c0..07a65842bb2 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -336,7 +336,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, if (!input_device->hid_desc) { pr_err("unable to allocate hid descriptor - size %d", desc->bLength); - goto Cleanup; + goto cleanup; } memcpy(input_device->hid_desc, desc, desc->bLength); @@ -349,7 +349,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, if (!input_device->report_desc) { pr_err("unable to allocate report descriptor - size %d", input_device->report_desc_size); - goto Cleanup; + goto cleanup; } memcpy(input_device->report_desc, @@ -376,7 +376,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, if (ret != 0) { pr_err("unable to send synthhid device info ack - ret %d", ret); - goto Cleanup; + goto cleanup; } input_device->device_wait_condition = 1; @@ -384,7 +384,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, return; -Cleanup: +cleanup: kfree(input_device->hid_desc); input_device->hid_desc = NULL; @@ -603,7 +603,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { pr_err("unable to send synthhid protocol request."); - goto Cleanup; + goto cleanup; } input_dev->protocol_wait_condition = 0; @@ -611,7 +611,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) input_dev->protocol_wait_condition, msecs_to_jiffies(1000)); if (input_dev->protocol_wait_condition == 0) { ret = -ETIMEDOUT; - goto Cleanup; + goto cleanup; } response = &input_dev->protocol_resp; @@ -620,7 +620,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) pr_err("synthhid protocol request failed (version %d)", SYNTHHID_INPUT_VERSION); ret = -1; - goto Cleanup; + goto cleanup; } input_dev->device_wait_condition = 0; @@ -628,7 +628,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) input_dev->device_wait_condition, msecs_to_jiffies(1000)); if (input_dev->device_wait_condition == 0) { ret = -ETIMEDOUT; - goto Cleanup; + goto cleanup; } /* @@ -640,7 +640,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) else ret = -1; -Cleanup: +cleanup: put_input_device(device); return ret; @@ -658,7 +658,7 @@ static int mousevsc_on_device_add(struct hv_device *device, if (!input_dev) { ret = -1; - goto Cleanup; + goto cleanup; } input_dev->init_complete = false; @@ -711,7 +711,7 @@ static int mousevsc_on_device_add(struct hv_device *device, input_dev->init_complete = true; -Cleanup: +cleanup: return ret; } From 1c627870f005149e815a7db00084160cfde1bef8 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:24 -0700 Subject: [PATCH 0621/1519] Staging: hv: netvsc: Change the jump label Cleanup to cleanup Change the jump label "Cleanup" to "cleanup". Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index f0d1362913e..79dfe78807b 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -438,7 +438,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, RNDIS_MESSAGE_SIZE(struct rndis_query_request)); if (!request) { ret = -ENOMEM; - goto Cleanup; + goto cleanup; } /* Setup the rndis query */ @@ -450,12 +450,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ret = rndis_filter_send_request(dev, request); if (ret != 0) - goto Cleanup; + goto cleanup; t = wait_for_completion_timeout(&request->wait_event, 5*HZ); if (t == 0) { ret = -ETIMEDOUT; - goto Cleanup; + goto cleanup; } /* Copy the response back */ @@ -463,7 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, if (query_complete->info_buflen > inresult_size) { ret = -1; - goto Cleanup; + goto cleanup; } memcpy(result, @@ -473,7 +473,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, *result_size = query_complete->info_buflen; -Cleanup: +cleanup: if (request) put_rndis_request(dev, request); @@ -512,7 +512,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, sizeof(u32)); if (!request) { ret = -ENOMEM; - goto Cleanup; + goto cleanup; } /* Setup the rndis set */ @@ -526,7 +526,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, ret = rndis_filter_send_request(dev, request); if (ret != 0) - goto Cleanup; + goto cleanup; t = wait_for_completion_timeout(&request->wait_event, 5*HZ); @@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, status = set_complete->status; } -Cleanup: +cleanup: if (request) put_rndis_request(dev, request); Exit: @@ -563,7 +563,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); if (!request) { ret = -ENOMEM; - goto Cleanup; + goto cleanup; } /* Setup the rndis set */ @@ -578,7 +578,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) ret = rndis_filter_send_request(dev, request); if (ret != 0) { dev->state = RNDIS_DEV_UNINITIALIZED; - goto Cleanup; + goto cleanup; } @@ -586,7 +586,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) if (t == 0) { ret = -ETIMEDOUT; - goto Cleanup; + goto cleanup; } init_complete = &request->response_msg.msg.init_complete; @@ -599,7 +599,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) ret = -EINVAL; } -Cleanup: +cleanup: if (request) put_rndis_request(dev, request); @@ -615,7 +615,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev) request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG, RNDIS_MESSAGE_SIZE(struct rndis_halt_request)); if (!request) - goto Cleanup; + goto cleanup; /* Setup the rndis set */ halt = &request->request_msg.msg.halt_req; @@ -626,7 +626,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev) dev->state = RNDIS_DEV_UNINITIALIZED; -Cleanup: +cleanup: if (request) put_rndis_request(dev, request); return; From 5585d81e0a52f7994b8cdc6a8927b425c068444a Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:25 -0700 Subject: [PATCH 0622/1519] Staging: hv: netvsc: Change the jump label Exit to exit Change the jump lable "Exit" to "exit". Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 79dfe78807b..6db48b92fe9 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -537,7 +537,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, * We can't deallocate the request since we may still receive a * send completion for it. */ - goto Exit; + goto exit; } else { set_complete = &request->response_msg.msg.set_complete; status = set_complete->status; @@ -546,7 +546,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, cleanup: if (request) put_rndis_request(dev, request); -Exit: +exit: return ret; } From 18d08aff878c827e8a7a0ea10da597a44ddfe7bc Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:49:23 -0700 Subject: [PATCH 0623/1519] Staging: hv: mouse: Get rid of the unused PCI signature Get rid of the unused PCI signature in the mouse driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 07a65842bb2..dfa8ae87ca6 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include "hyperv.h" @@ -935,26 +933,6 @@ static void __exit mousevsc_exit(void) vmbus_driver_unregister(&mousevsc_drv); } -/* - * We don't want to automatically load this driver just yet, it's quite - * broken. It's safe if you want to load it yourself manually, but - * don't inflict it on unsuspecting users, that's just mean. - */ -#if 0 - -/* - * We use a PCI table to determine if we should autoload this driver This is - * needed by distro tools to determine if the hyperv drivers should be - * installed and/or configured. We don't do anything else with the table, but - * it needs to be present. - */ -static const struct pci_device_id microsoft_hv_pci_table[] = { - { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ - { 0 } -}; -MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table); -#endif - MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); module_init(mousevsc_init); From ac50ddaaeeca4f649c53ce31175aa68d26420138 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 14:07:03 -0500 Subject: [PATCH 0624/1519] staging: rtl8192e: Remove MAC_FMT and MAC_ARG for %pM Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 15 +++---- drivers/staging/rtl8192e/rtl819x_TSProc.c | 6 +-- drivers/staging/rtl8192e/rtl_cam.c | 4 +- drivers/staging/rtl8192e/rtl_dm.c | 4 +- drivers/staging/rtl8192e/rtllib.h | 4 -- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 13 +++--- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 21 +++++---- drivers/staging/rtl8192e/rtllib_rx.c | 46 ++++++++++---------- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_wx.c | 4 +- 10 files changed, 55 insertions(+), 64 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 2e4085b8877..5bdb78cdeab 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -83,8 +83,8 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, u16 tmp = 0; u16 len = ieee->tx_headroom + 9; RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" - " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, - type, MAC_ARG(Dst), ieee->dev); + " sentd to: %pM, ieee->dev:%p\n", __func__, + type, Dst, ieee->dev); if (pBA == NULL || ieee == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " "NULL\n", pBA, ieee); @@ -150,8 +150,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, if (net_ratelimit()) RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), Reason" - "Code(%d) sentd to:"MAC_FMT"\n", __func__, - ReasonCode, MAC_ARG(dst)); + "Code(%d) sentd to: %pM\n", __func__, + ReasonCode, dst); memset(&DelbaParamSet, 0, 2); @@ -265,7 +265,7 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { @@ -347,7 +347,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pBaParamSet = (union ba_param_set *)(tag + 5); pBaTimeoutVal = (u16 *)(tag + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || ieee->pHTInfo->bCurrentHTSupport == false || ieee->pHTInfo->bCurrentAMPDUEnable == false) { @@ -459,8 +459,7 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " - "%s().dst:"MAC_FMT" TID:%d\n", __func__, - MAC_ARG(dst), + "%s().dst: %pM TID:%d\n", __func__, dst, (u8)pDelBaParamSet->field.TID); return -1; } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 519349f0ce4..6ebd20e8530 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -389,9 +389,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" - ", UP:%d, Dir:%d, addr:"MAC_FMT + ", UP:%d, Dir:%d, addr: %pM" " ppTs=%p\n", UP, Dir, - MAC_ARG(Addr), *ppTS); + Addr, *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -462,7 +462,7 @@ void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS, %pM\n", Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { if (memcmp(pTS->Addr, Addr, 6) == 0) { diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index a9991a0fa1c..baf3b6342e4 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -126,8 +126,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, - KeyType, MAC_ARG(MacAddr)); + "KeyType:%d, MacAddr %pM\n", dev, EntryNo, KeyIndex, + KeyType, MacAddr); if (DefaultKey) usConfig |= BIT15 | (KeyType<<2); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 291ec3e9d22..6d201ec3827 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -2322,9 +2322,9 @@ static void dm_check_edca_turbo(struct net_device *dev) static int wb_tmp; if (wb_tmp == 0) { printk(KERN_INFO "%s():iot peer is %s, bssid:" - MAC_FMT"\n", __func__, + " %pM\n", __func__, peername[pHTInfo->IOTPeer], - MAC_ARG(priv->rtllib->current_network.bssid)); + priv->rtllib->current_network.bssid); wb_tmp = 1; } } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c7b3641f30b..b33caccb43a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -700,10 +700,6 @@ do { \ } \ } while (0) -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ - ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] - /* * To use the debug system; * diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 306d6ff707a..78059b9671f 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -279,7 +279,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; @@ -292,9 +292,9 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT + printk(KERN_DEBUG "CCMP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -342,7 +342,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -418,11 +418,10 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%02x%02x%02x%02x%02x%02x " - "rx_pn=%02x%02x%02x%02x%02x%02x " + "tx_pn=%pM rx_pn=%pM " "format_errors=%d replays=%d decrypt_errors=%d\n", ccmp->key_idx, ccmp->key_set, - MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn), + ccmp->tx_pn, ccmp->rx_pn, ccmp->dot11RSNAStatsCCMPFormatErrors, ccmp->dot11RSNAStatsCCMPReplays, ccmp->dot11RSNAStatsCCMPDecryptErrors); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index c4e490e57ad..6a0c8788642 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -400,7 +400,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } return -2; } @@ -412,9 +412,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT + printk(KERN_DEBUG "TKIP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -428,9 +428,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->initialized) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: replay detected: STA=" - MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), + " %pM previous TSC %08x%04x received " + "TSC %08x%04x\n",hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; @@ -453,8 +452,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", - MAC_ARG(hdr->addr2)); + "received packet from %pM\n", + hdr->addr2); } return -7; } @@ -474,7 +473,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: ICV error detected: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -624,8 +623,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " - "MSDU from " MAC_FMT " keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), + "MSDU from %pM keyidx=%d\n", + skb->dev ? skb->dev->name : "N/A", hdr->addr2, keyidx); printk(KERN_DEBUG "%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 205c5750849..35f70d6fe2e 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -305,8 +305,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { RTLLIB_DEBUG_DROP( - "decryption failed (SA=" MAC_FMT - ") res=%d\n", MAC_ARG(hdr->addr2), res); + "decryption failed (SA= %pM" + ") res=%d\n", hdr->addr2, res); if (res == -2) RTLLIB_DEBUG_DROP("Decryption failed ICV " "mismatch (key %d)\n", @@ -345,8 +345,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" - " (SA=" MAC_FMT " keyidx=%d)\n", - ieee->dev->name, MAC_ARG(hdr->addr2), keyidx); + " (SA= %pM keyidx=%d)\n", + ieee->dev->name, hdr->addr2, keyidx); return -1; } @@ -1028,8 +1028,8 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, * frames silently instead of filling system log with * these reports. */ RTLLIB_DEBUG_DROP("Decryption failed (not set)" - " (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + " (SA= %pM)\n", + hdr->addr2); ieee->ieee_stats.rx_discards_undecryptable++; return -1; } @@ -1138,8 +1138,8 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, } else { RTLLIB_DEBUG_DROP( "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + "frame not encrypted (SA= %pM)\n", + hdr->addr2); return -1; } } @@ -1156,9 +1156,9 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { RTLLIB_DEBUG_DROP( "dropped unencrypted RX data " - "frame from " MAC_FMT + "frame from %pM" " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); + hdr->addr2); return -1; } @@ -2309,11 +2309,11 @@ static inline int rtllib_network_init( } if (network->mode == 0) { - RTLLIB_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' " + RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' " "network.\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid)); + network->bssid); return 1; } @@ -2516,9 +2516,9 @@ static inline void rtllib_process_probe_response( return; RTLLIB_DEBUG_SCAN( - "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, (beacon->capability & (1<<0xf)) ? '1' : '0', (beacon->capability & (1<<0xe)) ? '1' : '0', (beacon->capability & (1<<0xd)) ? '1' : '0', @@ -2537,10 +2537,10 @@ static inline void rtllib_process_probe_response( (beacon->capability & (1<<0x0)) ? '1' : '0'); if (rtllib_network_init(ieee, beacon, network, stats)) { - RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2604,11 +2604,11 @@ static inline void rtllib_process_probe_response( /* If there are no more slots, expire the oldest */ list_del(&oldest->list); target = oldest; - RTLLIB_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from " + RTLLIB_DEBUG_SCAN("Expired '%s' ( %pM) from " "network list.\n", escape_essid(target->ssid, target->ssid_len), - MAC_ARG(target->bssid)); + target->bssid); } else { /* Otherwise just pull from the free list */ target = list_entry(ieee->network_free_list.next, @@ -2617,10 +2617,9 @@ static inline void rtllib_process_probe_response( } - RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n", escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), + network->ssid_len), network->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2629,10 +2628,9 @@ static inline void rtllib_process_probe_response( if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { - RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n", escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), + target->ssid_len), target->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index fa0e2afd1ed..dd4dec8c53a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1972,7 +1972,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); + printk(KERN_INFO"New client associated: %pM\n", dest); } void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index c350f4e277d..8cea4a60e1b 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -279,10 +279,10 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, info); else RTLLIB_DEBUG_SCAN("Not showing network '%s (" - MAC_FMT ")' due to age (%lums).\n", + " %pM)' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), + network->bssid, (jiffies - network->last_scanned) / (HZ / 100)); } From ec0dc6beea5436c037707dc0f501cf07878a8e2a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 14:07:04 -0500 Subject: [PATCH 0625/1519] staging: rtl8192e: Fix sparse (non-endian) messages - Part I Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 24 +-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 169 ++----------------- drivers/staging/rtl8192e/rtl819x_TSProc.c | 35 ++-- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_module.c | 9 +- drivers/staging/rtl8192e/rtllib_softmac.c | 111 +++++------- drivers/staging/rtl8192e/rtllib_tx.c | 29 ++-- 7 files changed, 104 insertions(+), 275 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 5bdb78cdeab..48f9f71051e 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,21 +20,21 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, - u16 Time) +static void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) +static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) +static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; @@ -52,7 +52,7 @@ u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) return bSendDELBA; } -u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) +static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; @@ -193,8 +193,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA) +static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -209,8 +209,8 @@ void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, u16 StatusCode) +static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); @@ -222,9 +222,9 @@ void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, enum tr_select TxRxSelect, - u16 ReasonCode) +static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index f8da913c47b..b1c0c566882 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -214,7 +214,7 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) +static bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -233,7 +233,7 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) +static bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -336,7 +336,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device *ieee) +static void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rtllib_network *net = &ieee->current_network; @@ -378,40 +378,31 @@ void HTIOTPeerDetermine(struct rtllib_device *ieee) pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; } -bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } - -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) -{ - bool retValue = false; - - return retValue; -} - - -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, - struct rtllib_network *network) +static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -422,60 +413,7 @@ u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, return retValue; } -u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 retValue = false; - u8 boundary = 59; - - pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { - if (ieee->current_network.bssht.bdBandWidth == - HT_CHANNEL_WIDTH_20_40) { - if (!(pHTInfo->bRegBW40MHz)) { - if (ieee->current_network.mode != - WIRELESS_MODE_B) { - pHTInfo->bWAIotBroadcom = true; - - if (ieee->b_customer_lenovo_id) - boundary = 30; - - if (ieee->current_network.RSSI >= - boundary) - retValue = true; - } - } - } - } - return retValue; -} - -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - retValue = 1; - - return retValue; -} - -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - return retValue; -} - -u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) +static u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; @@ -484,42 +422,7 @@ u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) return retValue; } -u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) - retValue = 1; - - return retValue; -} - -u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) +static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -532,52 +435,6 @@ void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) } - -u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; @@ -735,7 +592,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, return; } -u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) +static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { u8 i; if (pOperateMCS == NULL) { @@ -1148,7 +1005,7 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) return false; } -void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +static void HTSetConnectBwModeCallback(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 6ebd20e8530..ccec382cea2 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -20,15 +20,15 @@ #include #include "rtl819x_TS.h" -void TsSetupTimeOut(unsigned long data) +static void TsSetupTimeOut(unsigned long data) { } -void TsInactTimeout(unsigned long data) +static void TsInactTimeout(unsigned long data) { } -void RxPktPendingTimeout(unsigned long data) +static void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, @@ -97,7 +97,7 @@ void RxPktPendingTimeout(unsigned long data) spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -void TsAddBaProcess(unsigned long data) +static void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; @@ -109,7 +109,7 @@ void TsAddBaProcess(unsigned long data) "started!!\n"); } -void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) +static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body)); @@ -118,7 +118,7 @@ void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) pTsCommonInfo->TClasNum = 0; } -void ResetTxTsEntry(struct tx_ts_record *pTS) +static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->TxCurSeq = 0; @@ -130,7 +130,7 @@ void ResetTxTsEntry(struct tx_ts_record *pTS) ResetBaEntry(&pTS->TxPendingBARecord); } -void ResetRxTsEntry(struct rx_ts_record *pTS) +static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->RxIndicateSeq = 0xffff; @@ -215,8 +215,8 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, - u32 InactTime) +static void AdmitTS(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); @@ -226,11 +226,12 @@ void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, MSECS(InactTime)); } -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, - u8 TID, enum tr_select TxRxSelect) +static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, + u8 *Addr, u8 TID, + enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; + bool search_dir[4] = {0}; struct list_head *psearch_list; struct ts_common_info *pRet = NULL; if (ieee->iw_mode == IW_MODE_MASTER) { @@ -283,9 +284,9 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, return NULL; } -void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, - union tspec_body *pTSPEC, union qos_tclas *pTCLAS, - u8 TCLAS_Num, u8 TCLAS_Proc) +static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -418,8 +419,8 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } } -void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, - enum tr_select TxRxSelect) +static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 78059b9671f..6196b9aa3a0 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -53,7 +53,7 @@ struct rtllib_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, +static void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { crypto_cipher_encrypt_one((void *)tfm, ct, pt); diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index dd0d8db01bd..0fe67a54edd 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -68,7 +68,7 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) if (ieee->networks) return 0; - ieee->networks = kmalloc( + ieee->networks = kzalloc( MAX_NETWORK_COUNT * sizeof(struct rtllib_network), GFP_KERNEL); if (!ieee->networks) { @@ -77,9 +77,6 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) return -ENOMEM; } - memset(ieee->networks, 0, - MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); - return 0; } @@ -223,7 +220,7 @@ u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc; +static struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -231,7 +228,7 @@ static int show_debug_level(char *page, char **start, off_t offset, return snprintf(page, count, "0x%08X\n", rtllib_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level(struct file *file, const char __user *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index dd4dec8c53a..a420ed1a947 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -23,15 +23,6 @@ #include #include "dot11d.h" -u8 rsn_authen_cipher_suite[16][4] = { - {0x00, 0x0F, 0xAC, 0x00}, - {0x00, 0x0F, 0xAC, 0x01}, - {0x00, 0x0F, 0xAC, 0x02}, - {0x00, 0x0F, 0xAC, 0x03}, - {0x00, 0x0F, 0xAC, 0x04}, - {0x00, 0x0F, 0xAC, 0x05}, -}; - short rtllib_is_54g(struct rtllib_network *net) { return (net->rates_ex_len > 0) || (net->rates_len > 4); @@ -46,7 +37,7 @@ short rtllib_is_shortslot(struct rtllib_network net) * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) +static unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) { unsigned int rate_len = 0; @@ -64,7 +55,7 @@ unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -82,7 +73,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -103,7 +94,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -137,7 +128,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) printk(KERN_ALERT "This is enable turbo mode IE process\n"); } -void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) +static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; @@ -154,7 +145,7 @@ void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) } -struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) +static struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) { struct sk_buff *ret; @@ -169,7 +160,7 @@ struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) return ret; } -void init_mgmt_queue(struct rtllib_device *ieee) +static void init_mgmt_queue(struct rtllib_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } @@ -394,7 +385,7 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee); -void rtllib_send_beacon(struct rtllib_device *ieee) +static void rtllib_send_beacon(struct rtllib_device *ieee) { struct sk_buff *skb; if (!ieee->ieee_up) @@ -412,7 +403,7 @@ void rtllib_send_beacon(struct rtllib_device *ieee) } -void rtllib_send_beacon_cb(unsigned long _ieee) +static void rtllib_send_beacon_cb(unsigned long _ieee) { struct rtllib_device *ieee = (struct rtllib_device *) _ieee; @@ -500,7 +491,7 @@ void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, ieee->bNetPromiscuousMode = false; } -void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) +static void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); @@ -520,7 +511,7 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) } } -void rtllib_softmac_hint11d_wq(void *data) +static void rtllib_softmac_hint11d_wq(void *data) { } @@ -602,7 +593,7 @@ out: wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } -void rtllib_softmac_scan_wq(void *data) +static void rtllib_softmac_scan_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); @@ -662,7 +653,7 @@ out1: -void rtllib_beacons_start(struct rtllib_device *ieee) +static void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock, flags); @@ -673,7 +664,7 @@ void rtllib_beacons_start(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->beacon_lock, flags); } -void rtllib_beacons_stop(struct rtllib_device *ieee) +static void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; @@ -705,7 +696,7 @@ void rtllib_start_send_beacons(struct rtllib_device *ieee) } -void rtllib_softmac_stop_scan(struct rtllib_device *ieee) +static void rtllib_softmac_stop_scan(struct rtllib_device *ieee) { down(&ieee->scan_sem); ieee->scan_watch_dog = 0; @@ -752,7 +743,7 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) } /* called with ieee->lock held */ -void rtllib_start_scan(struct rtllib_device *ieee) +static void rtllib_start_scan(struct rtllib_device *ieee) { RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) @@ -831,24 +822,6 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, return skb; } -void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) -{ - u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { - szQoSOUI[0] = 46; - szQoSOUI[1] = *wmm_len; - memcpy(wmmie, szQoSOUI, 3); - *wmm_len = 3; - } else { - szQoSOUI[1] = *wmm_len + 6; - szQoSOUI[6] = oui_subtype; - memcpy(wmmie, szQoSOUI, 8); - *(wmmie+8) = 0; - *wmm_len = 9; - } -} - static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; @@ -998,7 +971,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; u8 *tag; @@ -1057,7 +1030,7 @@ struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, +static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, u8 *dest) { struct sk_buff *skb = NULL; @@ -1087,7 +1060,7 @@ struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, } -struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) +static struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; struct rtllib_hdr_3addr *hdr; @@ -1114,7 +1087,7 @@ struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) } -struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) +static struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_pspoll_hdr *hdr; @@ -1139,7 +1112,7 @@ struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1148,7 +1121,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) +static void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1157,7 +1130,7 @@ void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) } -void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_probe_resp(ieee, dest); @@ -1466,12 +1439,12 @@ void rtllib_associate_abort(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_associate_abort_cb(unsigned long dev) +static void rtllib_associate_abort_cb(unsigned long dev) { rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) +static void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1495,7 +1468,7 @@ void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) } } -void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) +static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -1526,7 +1499,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) kfree(challenge); } -void rtllib_associate_step2(struct rtllib_device *ieee) +static void rtllib_associate_step2(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; @@ -1546,7 +1519,7 @@ void rtllib_associate_step2(struct rtllib_device *ieee) } #define CANCELLED 2 -void rtllib_associate_complete_wq(void *data) +static void rtllib_associate_complete_wq(void *data) { struct rtllib_device *ieee = (struct rtllib_device *) container_of_work_rsl(data, @@ -1606,7 +1579,7 @@ static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { } -void rtllib_associate_complete(struct rtllib_device *ieee) +static void rtllib_associate_complete(struct rtllib_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -1616,7 +1589,7 @@ void rtllib_associate_complete(struct rtllib_device *ieee) queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); } -void rtllib_associate_procedure_wq(void *data) +static void rtllib_associate_procedure_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, @@ -1828,7 +1801,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) return cpu_to_le16(a->status); } -int auth_rq_parse(struct sk_buff *skb, u8 *dest) +static int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; @@ -1894,7 +1867,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb, u8 *dest) +static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; @@ -2075,7 +2048,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) } -inline void rtllib_sta_ps(struct rtllib_device *ieee) +static inline void rtllib_sta_ps(struct rtllib_device *ieee) { u64 time; short sleep; @@ -2196,7 +2169,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) +static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); @@ -2530,7 +2503,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) } /* called with ieee->lock acquired */ -void rtllib_resume_tx(struct rtllib_device *ieee) +static void rtllib_resume_tx(struct rtllib_device *ieee) { int i; for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; @@ -2675,7 +2648,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) netif_carrier_on(ieee->dev); } -void rtllib_start_monitor_mode(struct rtllib_device *ieee) +static void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ if (ieee->raw_tx) { @@ -2686,7 +2659,7 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) } } -void rtllib_start_ibss_wq(void *data) +static void rtllib_start_ibss_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); @@ -2850,7 +2823,7 @@ void rtllib_start_bss(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_link_change_wq(void *data) +static void rtllib_link_change_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); @@ -2876,7 +2849,7 @@ void rtllib_disassociate(struct rtllib_device *ieee) notify_wx_assoc_event(ieee); } -void rtllib_associate_retry_wq(void *data) +static void rtllib_associate_retry_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); @@ -3194,8 +3167,8 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, - int wpa_ie_len) +static void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3698,7 +3671,7 @@ void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == NULL) { rtllib->state = RTLLIB_NOLINK; for (i = 0; i < 6; i++) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f038aa93083..44e8006bc1a 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -220,8 +220,8 @@ void rtllib_txb_free(struct rtllib_txb *txb) kfree(txb); } -struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) +static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, + gfp_t gfp_mask) { struct rtllib_txb *txb; int i; @@ -251,8 +251,7 @@ struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, return txb; } -int -rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) +static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) { struct ethhdr *eth; struct iphdr *ip; @@ -283,8 +282,9 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, - struct cb_desc *tcb_desc) +static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, + struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; @@ -358,7 +358,7 @@ FORCED_AGG_SETTING: return; } -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, +static void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { tcb_desc->bUseShortPreamble = false; @@ -370,7 +370,7 @@ extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, return; } -extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, +static void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -391,8 +391,8 @@ extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -412,8 +412,9 @@ void rtllib_query_BandwidthMode(struct rtllib_device *ieee, return; } -void rtllib_query_protectionmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc, struct sk_buff *skb) +static void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, + struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -494,8 +495,8 @@ NO_PROTECTION: } -void rtllib_txrate_selectmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; From 49aab5fd9df153a73992afa7cc386661d759c8e3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 14:07:05 -0500 Subject: [PATCH 0626/1519] staging: rtl8192e: Fix sparse (non-endian) warnings - Part II Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 10 +- drivers/staging/rtl8192e/r8192E_dev.c | 43 ++-- drivers/staging/rtl8192e/r8192E_firmware.c | 45 +--- drivers/staging/rtl8192e/r8192E_phy.c | 38 ++-- drivers/staging/rtl8192e/rtl_core.c | 144 ++++--------- drivers/staging/rtl8192e/rtl_core.h | 1 - drivers/staging/rtl8192e/rtl_dm.c | 237 ++------------------- drivers/staging/rtl8192e/rtl_eeprom.c | 11 +- drivers/staging/rtl8192e/rtl_ps.c | 7 +- drivers/staging/rtl8192e/rtl_wx.c | 10 +- drivers/staging/rtl8192e/rtllib_rx.c | 61 +++--- 11 files changed, 152 insertions(+), 455 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 881eb1f96d2..09978b6428f 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -34,7 +34,7 @@ } /*---------------------------Define functions---------------------------------*/ -extern bool cmpk_message_handle_tx( +bool cmpk_message_handle_tx( struct net_device *dev, u8 *code_virtual_address, u32 packettype, @@ -167,7 +167,7 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) } /* cmpk_Handle_Tx_Feedback */ -void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) +static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; @@ -339,10 +339,8 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) } -extern u32 -cmpk_message_handle_rx( - struct net_device *dev, - struct rtllib_rx_stats *pstats) +u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = rtllib_priv(dev); int total_length; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 229d6df789f..899e4e5e98f 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -57,7 +57,7 @@ void rtl8192e_start_beacon(struct net_device *dev) rtl8192_irq_enable(dev); } -void rtl8192e_update_msr(struct net_device *dev) +static void rtl8192e_update_msr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 msr; @@ -952,7 +952,7 @@ end: return rtStatus; } -void rtl8192_net_update(struct net_device *dev) +static void rtl8192_net_update(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1127,7 +1127,7 @@ static u8 MRateToHwRate8190Pci(u8 rate) return ret; } -u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) +static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) { u8 QueueSelect = 0x0; @@ -1301,7 +1301,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev, entry->OWN = 1; } -u8 HwRateToMRate90(bool bIsHT, u8 rate) +static u8 HwRateToMRate90(bool bIsHT, u8 rate) { u8 ret_rate = 0x02; @@ -1414,7 +1414,7 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) return ret_rate; } -long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) +static long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; @@ -1450,7 +1450,7 @@ long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) _pdrvinfo->RxRate == DESC90_RATE11M) &&\ !_pdrvinfo->RxHT) -void rtl8192_query_rxphystatus( +static void rtl8192_query_rxphystatus( struct r8192_priv *priv, struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, @@ -1664,9 +1664,9 @@ void rtl8192_query_rxphystatus( } } -void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, - struct rtllib_rx_stats *prev_st, - struct rtllib_rx_stats *curr_st) +static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; @@ -1839,10 +1839,11 @@ void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, } } -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, - struct rtllib_rx_stats *pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) +static void rtl8192_TranslateRxSignalStuff(struct net_device *dev, + struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); bool bpacket_match_bssid, bpacket_toself; @@ -1867,7 +1868,7 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & + bpacket_toself = bpacket_match_bssid && /* check this */ (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) @@ -1883,7 +1884,8 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); } -void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, +static void rtl8192_UpdateReceivedRateHistogramStatistics( + struct net_device *dev, struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2255,17 +2257,6 @@ void rtl8192_enable_tx(struct net_device *dev) } -void rtl8192_beacon_disable(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 reg; - - reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); - - reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); -} - void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) { diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index c2689993530..37719859bda 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -23,7 +23,7 @@ #include "r8192E_firmware.h" #include -extern void firmware_init_param(struct net_device *dev) +void firmware_init_param(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -32,8 +32,8 @@ extern void firmware_init_param(struct net_device *dev) MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, - u32 buffer_len) +static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -102,42 +102,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, return rt_status; } -bool fwSendNullPacket(struct net_device *dev, u32 Length) -{ - bool rtStatus = true; - struct r8192_priv *priv = rtllib_priv(dev); - struct sk_buff *skb; - struct cb_desc *tcb_desc; - unsigned char *ptr_buf; - bool bLastInitPacket = false; - - - skb = dev_alloc_skb(Length + 4); - memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->queue_index = TXCMD_QUEUE; - tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; - tcb_desc->bLastIniPkt = bLastInitPacket; - ptr_buf = skb_put(skb, Length); - memset(ptr_buf, 0, Length); - tcb_desc->txbuf_size = (u16)Length; - - if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> - queue_index])) || (priv->rtllib->queue_stop)) { - RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" - "========> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], - skb); - } else { - priv->rtllib->softmac_hard_start_xmit(skb, dev); - } - - write_nic_byte(dev, TPPoll, TPPoll_CQ); - return rtStatus; -} - -bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) +static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) { bool rt_status = true; u32 CPU_status = 0; @@ -184,7 +149,7 @@ CPUCheckMainCodeOKAndTurnOnCPU_Fail: return rt_status; } -bool CPUcheck_firmware_ready(struct net_device *dev) +static bool CPUcheck_firmware_ready(struct net_device *dev) { bool rt_status = true; diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 96ccbd5b25d..83e00d72199 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -53,7 +53,8 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, static void phy_FwRFSerialWrite(struct net_device *dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data); -u32 rtl8192_CalculateBitShift(u32 dwBitMask) + +static u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; for (i = 0; i <= 31; i++) { @@ -105,8 +106,8 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset) +static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; @@ -161,9 +162,9 @@ u32 rtl8192_phy_RFSerialRead(struct net_device *dev, } -void rtl8192_phy_RFSerialWrite(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset, - u32 Data) +static void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; @@ -400,7 +401,7 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType) return; } -void rtl8192_InitBBRFRegDef(struct net_device *dev) +static void rtl8192_InitBBRFRegDef(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -549,7 +550,7 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev, return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device *dev) +static bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -790,7 +791,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, return ret; } -void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) +static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u8 powerlevel = priv->TxPowerLevelCCK[channel-1]; @@ -815,9 +816,10 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) return; } -u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, - u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, - u32 Para1, u32 Para2, u32 msDelay) +static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, + u32 CmdTableIdx, u32 CmdTableSz, + enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) { struct sw_chnl_cmd *pCmd; @@ -843,8 +845,8 @@ u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, - u8 *step, u32 *delay) +static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, + u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -983,7 +985,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, return false; } -void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) +static void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u32 delay = 0; @@ -1410,8 +1412,8 @@ void PHY_SetRtl8192eRfOff(struct net_device *dev) } -bool SetRFPowerState8190(struct net_device *dev, - enum rt_rf_power_state eRFPowerState) +static bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1608,7 +1610,7 @@ bool SetRFPowerState(struct net_device *dev, return bResult; } -extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) +void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 9554eef1fcb..f803c96dc83 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -59,10 +59,10 @@ int hwwep = 1; static int channels = 0x3fff; -char *ifname = "wlan%d"; +static char *ifname = "wlan%d"; -struct rtl819x_ops rtl819xp_ops = { +static struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, @@ -109,7 +109,7 @@ static struct pci_driver rtl8192_pci_driver = { /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) +static bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; @@ -277,36 +277,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff & readb((u8 *)dev->mem_start + x); + return 0xff & readb((u8 __iomem *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8 *)dev->mem_start + x); + return readl((u8 __iomem *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8 *)dev->mem_start + x); + return readw((u8 __iomem *)dev->mem_start + x); } void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y, (u8 *)dev->mem_start + x); + writeb(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y, (u8 *)dev->mem_start + x); + writel(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y, (u8 *)dev->mem_start + x); + writew(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } @@ -453,7 +453,7 @@ bool MgntActSet_RF_State(struct net_device *dev, } -short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) +static short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -468,7 +468,7 @@ short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) return skb_queue_len(&ring->queue); } -short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) +static short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -503,14 +503,6 @@ void rtl8192_irq_disable(struct net_device *dev) priv->irq_enabled = 0; } -void rtl8192_irq_clear(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - priv->ops->irq_clear(dev); -} - - void rtl8192_set_chan(struct net_device *dev, short ch) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -580,7 +572,7 @@ static struct rtllib_qos_parameters def_qos_parameters = { {0, 0, 0, 0} }; -void rtl8192_update_beacon(void *data) +static void rtl8192_update_beacon(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); @@ -599,7 +591,7 @@ void rtl8192_update_beacon(void *data) #define MOVE_INTO_HANDLER int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; -void rtl8192_qos_activate(void *data) +static void rtl8192_qos_activate(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); @@ -759,7 +751,7 @@ static int rtl8192_handle_assoc_response(struct net_device *dev, return 0; } -void rtl8192_prepare_beacon(struct r8192_priv *priv) +static void rtl8192_prepare_beacon(struct r8192_priv *priv) { struct net_device *dev = priv->rtllib->dev; struct sk_buff *pskb = NULL, *pnewskb = NULL; @@ -792,7 +784,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) return; } -void rtl8192_stop_beacon(struct net_device *dev) +static void rtl8192_stop_beacon(struct net_device *dev) { } @@ -888,7 +880,7 @@ void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) } } -void rtl8192_refresh_supportrate(struct r8192_priv *priv) +static void rtl8192_refresh_supportrate(struct r8192_priv *priv) { struct rtllib_device *ieee = priv->rtllib; if (ieee->mode == WIRELESS_MODE_N_24G || @@ -904,7 +896,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv *priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) +static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -974,7 +966,7 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) +static int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1017,7 +1009,7 @@ int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) return 0; } -int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) +static int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; @@ -1244,9 +1236,10 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); - if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + if (!priv->pFirmware) + printk(KERN_ERR "rtl8193e: Unable to allocate space " + "for firmware\n"); skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); @@ -1303,7 +1296,7 @@ static void rtl8192_init_priv_task(struct net_device *dev) (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device *dev) +static short rtl8192_get_channel_map(struct net_device *dev) { int i; @@ -1331,7 +1324,7 @@ short rtl8192_get_channel_map(struct net_device *dev) return 0; } -short rtl8192_init(struct net_device *dev) +static short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1396,7 +1389,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev) return 1; } -enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 QueueID; @@ -1455,7 +1448,7 @@ enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1467,8 +1460,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type -rtl819x_ifcheck_resetornot(struct net_device *dev) +static enum reset_type rtl819x_ifcheck_resetornot(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); enum reset_type TxResetType = RESET_TYPE_NORESET; @@ -1501,11 +1493,11 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) } -void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) +static void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) { } -void rtl819x_ifsilentreset(struct net_device *dev) +static void rtl819x_ifsilentreset(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 reset_times = 0; @@ -1644,8 +1636,8 @@ END: } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, - u32 *TotalRxDataNum) +static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, + u32 *TotalRxDataNum) { u16 SlotIndex; u8 i; @@ -1976,7 +1968,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } -void rtl8192_tx_isr(struct net_device *dev, int prio) +static void rtl8192_tx_isr(struct net_device *dev, int prio) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2104,7 +2096,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) return 0; } -short rtl8192_alloc_rx_desc_ring(struct net_device *dev) +static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rx_desc *entry = NULL; @@ -2342,7 +2334,7 @@ rtl8192_record_rxdesc_forlateruse( -void rtl8192_rx_normal(struct net_device *dev) +static void rtl8192_rx_normal(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; @@ -2447,12 +2439,12 @@ done: } -void rtl8192_rx_cmd(struct net_device *dev) +static void rtl8192_rx_cmd(struct net_device *dev) { } -void rtl8192_tx_resume(struct net_device *dev) +static void rtl8192_tx_resume(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; @@ -2505,7 +2497,7 @@ int _rtl8192_up(struct net_device *dev, bool is_silent_reset) } -int rtl8192_open(struct net_device *dev) +static int rtl8192_open(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2528,7 +2520,7 @@ int rtl8192_up(struct net_device *dev) } -int rtl8192_close(struct net_device *dev) +static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2592,7 +2584,7 @@ static void r8192_set_multicast(struct net_device *dev) } -int r8192_set_mac_adr(struct net_device *dev, void *mac) +static int r8192_set_mac_adr(struct net_device *dev, void *mac) { struct r8192_priv *priv = rtllib_priv(dev); struct sockaddr *addr = mac; @@ -2608,7 +2600,7 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac) } /* based on ipw2200 driver */ -int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; @@ -2732,56 +2724,6 @@ out: return ret; } -void FairBeacon(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i = 100; - static u8 forceturn; - u16 beaconint = net->beacon_interval; - - if (priv->rtllib->iw_mode != IW_MODE_ADHOC) - return; - - if (priv->bIbssCoordinator) { - i--; - - if (forceturn == 2) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i <= 94) { - beaconint = beaconint+2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 1; - } - } else { - i++; - - if (forceturn == 1) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i >= 106) { - beaconint = beaconint-2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 2; - } - } -} - irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) { @@ -3078,7 +3020,7 @@ fail: if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq = 0; + priv->irq = 0; } free_rtllib(dev); } @@ -3128,7 +3070,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) kfree(priv->scan_cmd); if (dev->mem_start != 0) { - iounmap((void *)dev->mem_start); + iounmap((void __iomem *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); } diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 03a86fe283c..5b78530bf22 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -1110,7 +1110,6 @@ void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, u8 rtl819x_query_rxpwrpercentage(char antpower); void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, struct rtllib_rx_stats *ptarget_stats); - bool NicIFEnableNIC(struct net_device *dev); bool NicIFDisableNIC(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 6d201ec3827..a7fa9aad6f2 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -134,8 +134,7 @@ static void dm_send_rssi_tofw(struct net_device *dev); static void dm_ctstoself(struct net_device *dev); /*---------------------------Define function prototype------------------------*/ -extern void -init_hal_dm(struct net_device *dev) +void init_hal_dm(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->DM_Type = DM_Type_ByDriver; @@ -158,14 +157,14 @@ init_hal_dm(struct net_device *dev) INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } -extern void deinit_hal_dm(struct net_device *dev) +void deinit_hal_dm(struct net_device *dev) { dm_deInit_fsync(dev); } -extern void hal_dm_watchdog(struct net_device *dev) +void hal_dm_watchdog(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->being_init_adapter) @@ -191,7 +190,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_ctstoself(dev); } -void dm_check_ac_dc_power(struct net_device *dev) +static void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; @@ -215,7 +214,7 @@ void dm_check_ac_dc_power(struct net_device *dev) }; -extern void init_rate_adaptive(struct net_device *dev) +void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1528,10 +1527,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH } } -extern void dm_cck_txpower_adjust( - struct net_device *dev, - bool binch14 -) +void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->IC_Cut >= IC_VersionCut_D) @@ -1540,9 +1536,7 @@ extern void dm_cck_txpower_adjust( dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); } -static void dm_txpower_reset_recovery( - struct net_device *dev -) +static void dm_txpower_reset_recovery(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1570,7 +1564,7 @@ static void dm_txpower_reset_recovery( } -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) +void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; @@ -1624,7 +1618,7 @@ static void dm_bb_initialgain_restore(struct net_device *dev) } -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev) +void dm_backup_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1659,8 +1653,8 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value) +void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, u32 dm_value) { if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; @@ -1704,75 +1698,6 @@ extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void dm_change_fsync_setting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->framesyncMonitor = (u8)DM_Value; - } -} - -extern void -dm_change_rxpath_selection_setting( - struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.Enable = (u8)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } else if (DM_Type == 2) { - if (DM_Value > 40) - DM_Value = 40; - DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } else if (DM_Type == 3) { - if (DM_Value > 25) - DM_Value = 25; - DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } else if (DM_Type == 4) { - if (DM_Value >= CCK_Rx_Version_MAX) - DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method = (u8)DM_Value; - } else if (DM_Type == 10) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } else if (DM_Type == 11) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } else if (DM_Type == 12) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } else if (DM_Type == 13) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } else if (DM_Type == 20) { - if (DM_Value > 1) - DM_Value = 1; - pRA->ping_rssi_enable = (u8)DM_Value; - } else if (DM_Type == 21) { - if (DM_Value > 30) - DM_Value = 30; - pRA->ping_rssi_thresh_for_ra = DM_Value; - } -} static void dm_dig_init(struct net_device *dev) { @@ -1814,37 +1739,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.BackoffVal_range_min = DM_DIG_BACKOFF_MIN; } -void dm_FalseAlarmCounterStatistics(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u32 ret_value; - struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); - FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); - - FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; - - ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); - FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); - FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Parity_Fail + - FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + - FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Cck_fail); - - RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, - FalseAlmCnt->Cnt_all); -} - static void dm_ctrl_initgain_byrssi(struct net_device *dev) { @@ -2099,91 +1993,6 @@ static void dm_initial_gain(struct net_device *dev) } } -void dm_initial_gain_STABeforeConnect( - struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain = 0; - static u8 initialized, force_write; - - RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", - dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); - - - if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { - if (priv->rtllib->eRFPowerState != eRfOn) - return; - - if (dm_digtable.Backoff_Enable_Flag == true) { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { - if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; - else - dm_digtable.backoff_val -= 6; - } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { - if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; - else - dm_digtable.backoff_val += 6; - } - } else - dm_digtable.backoff_val = DM_DIG_BACKOFF; - - if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; - else - dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - - dm_digtable.backoff_val; - - if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? - dm_digtable.cur_ig_value : 0x33; - - if (priv->FalseAlmCnt.Cnt_all > 16000) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - - } else { - return; - } - } else { - dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); - - dm_digtable.backoff_val = DM_DIG_BACKOFF; - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; - dm_digtable.pre_ig_value = 0; - return; - } - - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, - rOFDM0_XAAGCCore1, bMaskByte0)) - force_write = 1; - - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || - !initialized || force_write) { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); - - initial_gain = (u8)dm_digtable.cur_ig_value; - - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, - initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, - initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } - - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " - "backoff_val = %d\n", dm_digtable.cur_ig_value, - dm_digtable.pre_ig_value, dm_digtable.backoff_val); - -} - static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2287,7 +2096,7 @@ static void dm_cs_ratio(struct net_device *dev) } } -extern void dm_init_edca_turbo(struct net_device *dev) +void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2390,22 +2199,6 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, - u32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value >= 50) - DM_Value = 50; - priv->rtllib->CTSToSelfTH = (u8)DM_Value; - } -} - static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2454,7 +2247,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } -extern void dm_CheckRfCtrlGPIO(void *data) +void dm_CheckRfCtrlGPIO(void *data) { struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, gpio_change_rf_wq); @@ -2791,7 +2584,7 @@ static void dm_deInit_fsync(struct net_device *dev) del_timer_sync(&priv->fsync_timer); } -extern void dm_fsync_timer_callback(unsigned long data) +void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); @@ -3091,7 +2884,7 @@ void dm_check_fsync(struct net_device *dev) } } -extern void dm_shadow_init(struct net_device *dev) +void dm_shadow_init(struct net_device *dev) { u8 page; u16 offset; diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index df72a6007d0..c1ccff4a832 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -25,7 +25,7 @@ #include "rtl_core.h" #include "rtl_eeprom.h" -void eprom_cs(struct net_device *dev, short bit) +static void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, @@ -39,7 +39,7 @@ void eprom_cs(struct net_device *dev, short bit) } -void eprom_ck_cycle(struct net_device *dev) +static void eprom_ck_cycle(struct net_device *dev) { write_nic_byte(dev, EPROM_CMD, (1<ps_lock, flags); } -void InactivePsWorkItemCallback(struct net_device *dev) +static void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -214,7 +214,8 @@ void rtllib_ips_leave(struct net_device *dev) up(&priv->rtllib->ips_sem); } -bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) +static bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, + u8 rtPsMode) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index f869ce3dbec..77ea4bb8c7a 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,7 +22,7 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = { +static u32 rtl8192_rates[] = { 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000 }; @@ -198,9 +198,9 @@ struct adhoc_peers_info { unsigned char num; }; -int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8192_wx_get_adhoc_peers(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -1293,7 +1293,7 @@ static iw_handler r8192_private_handler[] = { (iw_handler)r8192_wx_get_PromiscuousMode, }; -struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) +static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 35f70d6fe2e..745ae0861df 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -442,15 +442,20 @@ drop: return 1; } -bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) +static bool AddReorderEntry(struct rx_ts_record *pTS, + struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; while (pList->next != &pTS->RxPendingPktList) { - if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *) + list_entry(pList->next, struct rx_reorder_entry, + List))->SeqNum)) pList = pList->next; - else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) - return false; + else if (SN_EQUAL(pReorderEntry->SeqNum, + ((struct rx_reorder_entry *)list_entry(pList->next, + struct rx_reorder_entry, List))->SeqNum)) + return false; else break; } @@ -539,8 +544,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record pTS->RxIndicateSeq = 0xffff; } -void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, - struct rx_ts_record *pTS, u16 SeqNum) +static void RxReorderIndicatePacket(struct rtllib_device *ieee, + struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; @@ -728,9 +734,9 @@ void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb, u8 *src, u8 *dst) +static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -853,8 +859,9 @@ u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, } -size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats) +static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -874,8 +881,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, - u8 multicast) +static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, + struct sk_buff *skb, u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -916,9 +923,9 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, - struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, - u8 *bssid) +static void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, + u8 *src, u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -946,8 +953,8 @@ void rtllib_rx_extract_addr(struct rtllib_device *ieee, } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, - u8 *bssid, u8 *addr2) +static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, + u8 *dst, u8 *src, u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -1004,7 +1011,7 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, return 0; } -int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1038,7 +1045,7 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats, struct rtllib_crypt_data *crypt, size_t hdrlen) { @@ -1168,7 +1175,7 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) +static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { if (unicast) { @@ -1184,7 +1191,7 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, +static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, struct rtllib_rxb *rxb, u8 *dst, @@ -1243,7 +1250,7 @@ void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, rxb = NULL; } -int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -1412,13 +1419,13 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; } -int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1443,7 +1450,7 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, return 1; } -int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; @@ -2223,7 +2230,7 @@ static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index) +static long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; From f00c5460b46b6068d0005ba29fe39e77e4fdbd0b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 25 Aug 2011 14:07:06 -0500 Subject: [PATCH 0627/1519] staging: rtl8192e: Add endian checking switch to Makefile Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index fb007491c5f..a66a9ad3368 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -38,3 +38,4 @@ r8192e_pci-objs := \ obj-$(CONFIG_RTL8192E) += r8192e_pci.o +ccflags-y += -D__CHECK_ENDIAN__ From 4bc694057bc95049ed8d451c2e142c79bbf97328 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 16:36:52 -0700 Subject: [PATCH 0628/1519] Staging: hv: hv_mouse: remove deviceinfo_callback function It's not needed, so just inline the two lines. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index dfa8ae87ca6..8c4ae37ac65 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -173,8 +173,13 @@ struct mousevsc_dev { struct hv_input_dev_info hid_dev_info; }; +struct input_device_context { + struct hv_device *device_ctx; + struct hid_device *hid_device; + struct hv_input_dev_info device_info; + int connected; +}; -static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info); static void inputreport_callback(struct hv_device *dev, void *packet, u32 len); static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len); @@ -651,6 +656,7 @@ static int mousevsc_on_device_add(struct hv_device *device, struct mousevsc_dev *input_dev; struct hv_driver *input_drv; struct hv_input_dev_info dev_info; + struct input_device_context *input_device_ctx; input_dev = alloc_input_device(device); @@ -697,7 +703,9 @@ static int mousevsc_on_device_add(struct hv_device *device, strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse"); /* Send the device info back up */ - deviceinfo_callback(device, &dev_info); + input_device_ctx = dev_get_drvdata(&device->device); + memcpy(&input_device_ctx->device_info, &dev_info, + sizeof(struct hv_input_dev_info)); /* Send the report desc back up */ /* workaround SA-167 */ @@ -752,28 +760,6 @@ static int mousevsc_on_device_remove(struct hv_device *device) } -/* - * Data types - */ -struct input_device_context { - struct hv_device *device_ctx; - struct hid_device *hid_device; - struct hv_input_dev_info device_info; - int connected; -}; - - -static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info) -{ - struct input_device_context *input_device_ctx = - dev_get_drvdata(&dev->device); - - memcpy(&input_device_ctx->device_info, info, - sizeof(struct hv_input_dev_info)); - - DPRINT_INFO(INPUTVSC_DRV, "%s", __func__); -} - static void inputreport_callback(struct hv_device *dev, void *packet, u32 len) { int ret = 0; From 3f4636e625204e74986e9f1f845229ebd6235f9e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 16:41:06 -0700 Subject: [PATCH 0629/1519] Staging: hv: hv_mouse: remove inputreport_callback function It's not needed, so just inline the two lines. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 8c4ae37ac65..257684eff6e 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -180,7 +180,6 @@ struct input_device_context { int connected; }; -static void inputreport_callback(struct hv_device *dev, void *packet, u32 len); static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len); static struct mousevsc_dev *alloc_input_device(struct hv_device *device) @@ -403,6 +402,7 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, struct synthhid_input_report *input_report) { struct hv_driver *input_drv; + struct input_device_context *input_dev_ctx; if (!input_device->init_complete) { pr_info("Initialization incomplete...ignoring input_report msg"); @@ -411,9 +411,11 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, input_drv = drv_to_hv_drv(input_device->device->device.driver); - inputreport_callback(input_device->device, - input_report->buffer, - input_report->header.size); + input_dev_ctx = dev_get_drvdata(&input_device->device->device); + + hid_input_report(input_dev_ctx->hid_device, + HID_INPUT_REPORT, input_report->buffer, input_report->header.size, 1); + } static void mousevsc_on_receive(struct hv_device *device, @@ -760,19 +762,6 @@ static int mousevsc_on_device_remove(struct hv_device *device) } -static void inputreport_callback(struct hv_device *dev, void *packet, u32 len) -{ - int ret = 0; - - struct input_device_context *input_dev_ctx = - dev_get_drvdata(&dev->device); - - ret = hid_input_report(input_dev_ctx->hid_device, - HID_INPUT_REPORT, packet, len, 1); - - DPRINT_DBG(INPUTVSC_DRV, "hid_input_report (ret %d)", ret); -} - static int mousevsc_hid_open(struct hid_device *hid) { return 0; From 4ab0871ddd1bfdc514f93472cfd68290ecdb62c0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 16:47:43 -0700 Subject: [PATCH 0630/1519] Staging: hv: hv_mouse: remove a forward declaration This moves some functions around to remove a forward declaration. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 126 +++++++++++++++++----------------- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 257684eff6e..083f28f7abd 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -180,8 +180,6 @@ struct input_device_context { int connected; }; -static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len); - static struct mousevsc_dev *alloc_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; @@ -651,6 +649,68 @@ cleanup: return ret; } +static int mousevsc_hid_open(struct hid_device *hid) +{ + return 0; +} + +static void mousevsc_hid_close(struct hid_device *hid) +{ +} + +static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) +{ + struct input_device_context *input_device_ctx = + dev_get_drvdata(&dev->device); + struct hid_device *hid_dev; + + /* hid_debug = -1; */ + hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL); + + if (hid_parse_report(hid_dev, packet, len)) { + DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report"); + return; + } + + if (hid_dev) { + DPRINT_INFO(INPUTVSC_DRV, "hid_device created"); + + hid_dev->ll_driver->open = mousevsc_hid_open; + hid_dev->ll_driver->close = mousevsc_hid_close; + + hid_dev->bus = BUS_VIRTUAL; + hid_dev->vendor = input_device_ctx->device_info.vendor; + hid_dev->product = input_device_ctx->device_info.product; + hid_dev->version = input_device_ctx->device_info.version; + hid_dev->dev = dev->device; + + sprintf(hid_dev->name, "%s", + input_device_ctx->device_info.name); + + /* + * HJ Do we want to call it with a 0 + */ + if (!hidinput_connect(hid_dev, 0)) { + hid_dev->claimed |= HID_CLAIMED_INPUT; + + input_device_ctx->connected = 1; + + DPRINT_INFO(INPUTVSC_DRV, + "HID device claimed by input\n"); + } + + if (!hid_dev->claimed) { + DPRINT_ERR(INPUTVSC_DRV, + "HID device not claimed by " + "input or hiddev\n"); + } + + input_device_ctx->hid_device = hid_dev; + } + + kfree(hid_dev); +} + static int mousevsc_on_device_add(struct hv_device *device, void *additional_info) { @@ -762,15 +822,6 @@ static int mousevsc_on_device_remove(struct hv_device *device) } -static int mousevsc_hid_open(struct hid_device *hid) -{ - return 0; -} - -static void mousevsc_hid_close(struct hid_device *hid) -{ -} - static int mousevsc_probe(struct hv_device *dev) { int ret = 0; @@ -826,59 +877,6 @@ static int mousevsc_remove(struct hv_device *dev) return ret; } -static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) -{ - struct input_device_context *input_device_ctx = - dev_get_drvdata(&dev->device); - struct hid_device *hid_dev; - - /* hid_debug = -1; */ - hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL); - - if (hid_parse_report(hid_dev, packet, len)) { - DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report"); - return; - } - - if (hid_dev) { - DPRINT_INFO(INPUTVSC_DRV, "hid_device created"); - - hid_dev->ll_driver->open = mousevsc_hid_open; - hid_dev->ll_driver->close = mousevsc_hid_close; - - hid_dev->bus = BUS_VIRTUAL; - hid_dev->vendor = input_device_ctx->device_info.vendor; - hid_dev->product = input_device_ctx->device_info.product; - hid_dev->version = input_device_ctx->device_info.version; - hid_dev->dev = dev->device; - - sprintf(hid_dev->name, "%s", - input_device_ctx->device_info.name); - - /* - * HJ Do we want to call it with a 0 - */ - if (!hidinput_connect(hid_dev, 0)) { - hid_dev->claimed |= HID_CLAIMED_INPUT; - - input_device_ctx->connected = 1; - - DPRINT_INFO(INPUTVSC_DRV, - "HID device claimed by input\n"); - } - - if (!hid_dev->claimed) { - DPRINT_ERR(INPUTVSC_DRV, - "HID device not claimed by " - "input or hiddev\n"); - } - - input_device_ctx->hid_device = hid_dev; - } - - kfree(hid_dev); -} - static const struct hv_vmbus_device_id id_table[] = { /* Mouse guid */ { VMBUS_DEVICE(0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, From 6a180978aea7cb231c60b69b078ec339f40e2faa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 16:51:28 -0700 Subject: [PATCH 0631/1519] Staging: hv: hv_mouse: fix up remove() function This function obviously never worked, it was a cut-and-paste from the probe() function. Rewrite it to do what it is supposed to do at least in theory. As to if it works yet, well, it's not worse than it was before, so this can't hurt. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 083f28f7abd..090736af8df 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -847,15 +847,10 @@ static int mousevsc_probe(struct hv_device *dev) static int mousevsc_remove(struct hv_device *dev) { - int ret = 0; - struct input_device_context *input_dev_ctx; + int ret; - input_dev_ctx = kmalloc(sizeof(struct input_device_context), - GFP_KERNEL); - - dev_set_drvdata(&dev->device, input_dev_ctx); - + input_dev_ctx = dev_get_drvdata(&dev->device); if (input_dev_ctx->connected) { hidinput_disconnect(input_dev_ctx->hid_device); input_dev_ctx->connected = 0; @@ -866,7 +861,6 @@ static int mousevsc_remove(struct hv_device *dev) * is being removed */ ret = mousevsc_on_device_remove(dev); - if (ret != 0) { DPRINT_ERR(INPUTVSC_DRV, "unable to remove vsc device (ret %d)", ret); From 99c978529a40132a6f7a5f136b4362b56fc88d8c Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 3 Jul 2011 15:49:50 -0400 Subject: [PATCH 0632/1519] staging: Add module.h to drivers/staging users Lots of people expect module.h to just "be there" without any #include effort. But we are crushing that. So fix those files in staging relying on implicit module.h presence. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/altera-stapl/altera.c | 1 + drivers/staging/dt3155v4l/dt3155v4l.c | 1 + drivers/staging/iio/accel/adis16201_core.c | 1 + drivers/staging/iio/accel/adis16203_core.c | 1 + drivers/staging/iio/accel/adis16204_core.c | 1 + drivers/staging/iio/accel/adis16209_core.c | 1 + drivers/staging/iio/accel/adis16240_core.c | 1 + drivers/staging/iio/accel/kxsd9.c | 1 + drivers/staging/iio/accel/lis3l02dq_core.c | 1 + drivers/staging/iio/accel/sca3000_core.c | 1 + drivers/staging/iio/adc/ad7150.c | 1 + drivers/staging/iio/adc/ad7152.c | 1 + drivers/staging/iio/adc/ad7291.c | 1 + drivers/staging/iio/adc/ad7298_core.c | 1 + drivers/staging/iio/adc/ad7314.c | 1 + drivers/staging/iio/adc/ad7476_core.c | 1 + drivers/staging/iio/adc/ad7606_core.c | 1 + drivers/staging/iio/adc/ad7745.c | 1 + drivers/staging/iio/adc/ad7780.c | 1 + drivers/staging/iio/adc/ad7816.c | 1 + drivers/staging/iio/adc/ad7887_core.c | 1 + drivers/staging/iio/adc/ad799x_core.c | 1 + drivers/staging/iio/adc/adt7310.c | 1 + drivers/staging/iio/adc/adt7410.c | 1 + drivers/staging/iio/adc/adt75.c | 1 + drivers/staging/iio/adc/max1363_core.c | 1 + drivers/staging/iio/addac/adt7316-i2c.c | 1 + drivers/staging/iio/addac/adt7316.c | 1 + drivers/staging/iio/dac/ad5446.c | 1 + drivers/staging/iio/dac/ad5504.c | 1 + drivers/staging/iio/dac/ad5624r_spi.c | 1 + drivers/staging/iio/dac/ad5686.c | 1 + drivers/staging/iio/dac/ad5791.c | 1 + drivers/staging/iio/dds/ad5930.c | 1 + drivers/staging/iio/dds/ad9832.c | 1 + drivers/staging/iio/dds/ad9834.c | 1 + drivers/staging/iio/dds/ad9850.c | 1 + drivers/staging/iio/dds/ad9852.c | 1 + drivers/staging/iio/dds/ad9910.c | 1 + drivers/staging/iio/dds/ad9951.c | 1 + drivers/staging/iio/gyro/adis16060_core.c | 1 + drivers/staging/iio/gyro/adis16080_core.c | 1 + drivers/staging/iio/gyro/adis16130_core.c | 1 + drivers/staging/iio/gyro/adis16260_core.c | 1 + drivers/staging/iio/gyro/adxrs450_core.c | 1 + drivers/staging/iio/imu/adis16400_core.c | 1 + drivers/staging/iio/light/tsl2583.c | 1 + drivers/staging/iio/meter/ade7753.c | 1 + drivers/staging/iio/meter/ade7754.c | 1 + drivers/staging/iio/meter/ade7758_core.c | 1 + drivers/staging/iio/meter/ade7759.c | 1 + drivers/staging/iio/meter/ade7854-i2c.c | 1 + drivers/staging/iio/meter/ade7854-spi.c | 1 + drivers/staging/iio/meter/ade7854.c | 1 + drivers/staging/iio/resolver/ad2s120x.c | 1 + drivers/staging/iio/resolver/ad2s1210.c | 1 + drivers/staging/iio/resolver/ad2s90.c | 1 + drivers/staging/iio/trigger.h | 1 + drivers/staging/olpc_dcon/olpc_dcon.c | 1 + drivers/staging/sm7xx/smtcfb.c | 2 ++ drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 1 + drivers/staging/usbip/stub_dev.c | 1 + drivers/staging/usbip/stub_main.c | 1 + 63 files changed, 64 insertions(+) diff --git a/drivers/staging/altera-stapl/altera.c b/drivers/staging/altera-stapl/altera.c index be777a4945c..c2eff6a82db 100644 --- a/drivers/staging/altera-stapl/altera.c +++ b/drivers/staging/altera-stapl/altera.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "altera.h" #include "altera-exprt.h" #include "altera-jtag.h" diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c index 05aa41cf875..4059ea60951 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include #include #include #include diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 16b388bf899..2b8c5e9c33e 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index a7c06b957be..14836762736 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 6a64b2b723d..445a75b1d54 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index bd3d55714ed..ca671ddc152 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 237da463c67..d485f7342f8 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index 3f2d047f58e..2a0565181d4 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 7f946aa0140..33001f8992e 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index d5684fc29cd..dbf1622e19f 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" #include "../ring_generic.h" diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 5a1e15f6aec..c01acbc7b34 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 21f5f380fb5..fcec9b620c6 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 96cbb17bc2c..e884c78d804 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 21d1931edb3..3e5bead2636 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7314.c b/drivers/staging/iio/adc/ad7314.c index 9070d9cac72..e3d38dbd846 100644 --- a/drivers/staging/iio/adc/ad7314.c +++ b/drivers/staging/iio/adc/ad7314.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index f2fdd48303e..bb8be5daa6b 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index dcdb180d7e7..ef0558130ca 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 4c13f26aa9a..91d598c1a14 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index f90cdeacadf..46d1f8f3fe8 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 3fa4bb34a43..f5aa57bb8f2 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index a7da9e68eba..74e222f9243 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 2438ed597e9..33e4e219714 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index 1a41b803440..697ad1b9195 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index 76aa0639a55..b7631f18ee2 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index fc31cac7eae..dd782776ce3 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 6896b4cddf3..e10a4d82814 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 52d1ea34963..69fab53dec9 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "adt7316.h" diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index c828b6f0a28..474d946866d 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index e8a9d0bf1ed..c670fb9de31 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index ba3d9b3154a..5243ef962b5 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index a5b3776718e..7303bb13901 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index fd67cfa5edb..ae71d3f87d6 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 5b00b70b3fe..5c45d0fe816 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/dds/ad5930.c index 0b2aa4cafdd..4847ea2941d 100644 --- a/drivers/staging/iio/dds/ad5930.c +++ b/drivers/staging/iio/dds/ad5930.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index e3e61a469bb..e6cfa649e8c 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "../iio.h" diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index e6454d58fe4..a5b5aedd769 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "../iio.h" diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/dds/ad9850.c index d7c9d05f635..7f2dd47334f 100644 --- a/drivers/staging/iio/dds/ad9850.c +++ b/drivers/staging/iio/dds/ad9850.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index 86722657e7c..7f65b92598d 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index 33585533a0b..b72df8ca723 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index 6c18e24d0f6..3d478e7a48f 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 0cbe677359b..3f5087329e5 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index bd3eb101986..16ba0e11e44 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index 5ddaefcf94a..a9f270e5eb9 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index bc45228d070..fcd7819a124 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index f65ad497263..670b615839f 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 371eb0104b4..58a29b1e243 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f75fe856389..c7daa2fcecf 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "../iio.h" #define TSL258X_MAX_DEVICE_REGS 32 diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 4d1bd42ff9e..bccc5798fa5 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index f4f85fd5619..6f0f464aba3 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 299b95434e2..ac0e092e49d 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index a51a64cad03..31723e8e64f 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/meter/ade7854-i2c.c b/drivers/staging/iio/meter/ade7854-i2c.c index dd723435340..cbca3fd8fcd 100644 --- a/drivers/staging/iio/meter/ade7854-i2c.c +++ b/drivers/staging/iio/meter/ade7854-i2c.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "../iio.h" #include "ade7854.h" diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c index e0d10865590..cfa23ba30ef 100644 --- a/drivers/staging/iio/meter/ade7854-spi.c +++ b/drivers/staging/iio/meter/ade7854-spi.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "../iio.h" #include "ade7854.h" diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index 9b240ed858f..bc1f83eea7c 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s120x.c index bed4c725f2d..fdaf0a8fcf9 100644 --- a/drivers/staging/iio/resolver/ad2s120x.c +++ b/drivers/staging/iio/resolver/ad2s120x.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 53cb031b04d..f8459e8e855 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 43a66d46d00..3739bd24951 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 722fc338f36..598fcb3599f 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -7,6 +7,7 @@ * the Free Software Foundation. */ #include +#include #ifndef _IIO_TRIGGER_H_ #define _IIO_TRIGGER_H_ diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index d3cd68e9045..af24ddfb58c 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c index a164fc43bd8..39dbf339a4f 100644 --- a/drivers/staging/sm7xx/smtcfb.c +++ b/drivers/staging/sm7xx/smtcfb.c @@ -35,11 +35,13 @@ #include #include #include +#include #include #include #ifdef CONFIG_PM #include +#include #endif #include "smtcfb.h" diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c index 36f4cb77567..11728a03f8a 100644 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "synaptics_i2c_rmi4.h" /* TODO: for multiple device support will need a per-device mutex */ diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 77d64693b87..55c0b510889 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -19,6 +19,7 @@ #include #include +#include #include "usbip_common.h" #include "stub.h" diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index a34249a9cb6..2d631785006 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -18,6 +18,7 @@ */ #include +#include #include "usbip_common.h" #include "stub.h" From faae60d232df564ee5e88237fd816a6d3719a8c0 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 25 Aug 2011 15:02:09 +1000 Subject: [PATCH 0633/1519] rtl8192e: update for ndo_set_multicast_list removal. After merging the staging tree, today's linux-next build (x86_64 allmodconfig) failed like this: drivers/staging/rtl8192e/rtl_core.c:2917:2: error: unknown field 'ndo_set_multicast_list' specified in initializer Caused by commit 94a799425eee ("From: wlanfae " - really "[PATCH 1/8] rtl8192e: Import new version of driver from realtek" Signed-off-by: Stephen Rothwell Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 9bc20f0ba39..2d7bb511c3c 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2867,7 +2867,7 @@ static const struct net_device_ops rtl8192_netdev_ops = { .ndo_stop = rtl8192_close, .ndo_tx_timeout = rtl8192_tx_timeout, .ndo_do_ioctl = rtl8192_ioctl, - .ndo_set_multicast_list = r8192_set_multicast, + .ndo_set_rx_mode = r8192_set_multicast, .ndo_set_mac_address = r8192_set_mac_adr, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu, From ee8cc854e643cb1e77ccdc9f6a84201c4d3324de Mon Sep 17 00:00:00 2001 From: Patrik Jakobsson Date: Fri, 26 Aug 2011 11:17:42 +0100 Subject: [PATCH 0634/1519] gma500: Only register interrupt handler for poulsbo hardware First step in adding proper irq handling. We'll start with poulsbo support so make sure other chips don't touch drm_irq_install(). Signed-off-by: Patrik Jakobsson Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/psb_drv.c | 2 +- drivers/staging/gma500/psb_drv.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index b2cdce7b97e..d91083a6818 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -410,7 +410,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset) PSB_WVDC32(0x00000000, PSB_INT_ENABLE_R); PSB_WVDC32(0xFFFFFFFF, PSB_INT_MASK_R); spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags); - if (drm_core_check_feature(dev, DRIVER_MODESET)) + if (IS_PSB(dev) && drm_core_check_feature(dev, DRIVER_MODESET)) drm_irq_install(dev); dev->vblank_disable_allowed = 1; diff --git a/drivers/staging/gma500/psb_drv.h b/drivers/staging/gma500/psb_drv.h index fd4732dd783..8cd4f1a9ed3 100644 --- a/drivers/staging/gma500/psb_drv.h +++ b/drivers/staging/gma500/psb_drv.h @@ -43,6 +43,7 @@ enum { CHIP_MFLD_0130 = 3, /* Medfield */ }; +#define IS_PSB(dev) (((dev)->pci_device & 0xfffe) == 0x8108) #define IS_MRST(dev) (((dev)->pci_device & 0xfffc) == 0x4100) #define IS_MFLD(dev) (((dev)->pci_device & 0xfff8) == 0x0130) From 24dd55b4ee05923b66294c88272be5b337ec84e2 Mon Sep 17 00:00:00 2001 From: Patrik Jakobsson Date: Fri, 26 Aug 2011 11:17:57 +0100 Subject: [PATCH 0635/1519] gma500: Don't enable MSI on Poulsbo Chipset reports MSI capabilities for Poulsbo even though it isn't really there. Signed-off-by: Patrik Jakobsson Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/psb_drv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index d91083a6818..10c8ecdbbbf 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -329,6 +329,11 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->dev = dev; dev->dev_private = (void *) dev_priv; + if (!IS_PSB(dev)) { + if (pci_enable_msi(dev->pdev)) + dev_warn(dev->dev, "Enabling MSI failed!\n"); + } + dev_priv->num_pipe = dev_priv->ops->pipes; resource_start = pci_resource_start(dev->pdev, PSB_MMIO_RESOURCE); @@ -1207,9 +1212,6 @@ static struct pci_driver psb_pci_driver = { static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - /* MLD Added this from Inaky's patch */ - if (pci_enable_msi(pdev)) - dev_warn(&pdev->dev, "Enable MSI failed!\n"); return drm_get_pci_dev(pdev, ent, &driver); } From 0a0691a20d7a26e9f7a9cbcdcd8a45020394c4f9 Mon Sep 17 00:00:00 2001 From: Patrik Jakobsson Date: Fri, 26 Aug 2011 11:18:13 +0100 Subject: [PATCH 0636/1519] gma500: Add VBLANK support for Poulsbo hardware Signed-off-by: Patrik Jakobsson Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/psb_drv.h | 3 ++ drivers/staging/gma500/psb_irq.c | 71 ++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/drivers/staging/gma500/psb_drv.h b/drivers/staging/gma500/psb_drv.h index 8cd4f1a9ed3..9cbb494ed3d 100644 --- a/drivers/staging/gma500/psb_drv.h +++ b/drivers/staging/gma500/psb_drv.h @@ -135,6 +135,9 @@ enum { #define _PSB_IRQ_MSVDX_FLAG (1<<19) #define _LNC_IRQ_TOPAZ_FLAG (1<<20) +#define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \ + _PSB_VSYNC_PIPEB_FLAG) + /* This flag includes all the display IRQ bits excepts the vblank irqs. */ #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \ _MDFLD_PIPEB_EVENT_FLAG | \ diff --git a/drivers/staging/gma500/psb_irq.c b/drivers/staging/gma500/psb_irq.c index 4a0fa42893f..36dd63044b0 100644 --- a/drivers/staging/gma500/psb_irq.c +++ b/drivers/staging/gma500/psb_irq.c @@ -138,22 +138,11 @@ void mid_disable_pipe_event(struct drm_psb_private *dev_priv, int pipe) } } -/** - * Display controller interrupt handler for vsync/vblank. - * - */ -static void mid_vblank_handler(struct drm_device *dev, uint32_t pipe) -{ - drm_handle_vblank(dev, pipe); -} - - /** * Display controller interrupt handler for pipe event. * */ -#define WAIT_STATUS_CLEAR_LOOP_COUNT 0xffff -static void mid_pipe_event_handler(struct drm_device *dev, uint32_t pipe) +static void mid_pipe_event_handler(struct drm_device *dev, int pipe) { struct drm_psb_private *dev_priv = (struct drm_psb_private *) dev->dev_private; @@ -162,6 +151,7 @@ static void mid_pipe_event_handler(struct drm_device *dev, uint32_t pipe) uint32_t pipe_stat_reg = psb_pipestat(pipe); uint32_t pipe_enable = dev_priv->pipestat[pipe]; uint32_t pipe_status = dev_priv->pipestat[pipe] >> 16; + uint32_t pipe_clear; uint32_t i = 0; spin_lock(&dev_priv->irqmask_lock); @@ -172,27 +162,23 @@ static void mid_pipe_event_handler(struct drm_device *dev, uint32_t pipe) spin_unlock(&dev_priv->irqmask_lock); - /* clear the 2nd level interrupt status bits */ - /** - * FIXME: shouldn't use while loop here. However, the interrupt - * status 'sticky' bits cannot be cleared by setting '1' to that - * bit once... - */ - for (i = 0; i < WAIT_STATUS_CLEAR_LOOP_COUNT; i++) { + /* Clear the 2nd level interrupt status bits + * Sometimes the bits are very sticky so we repeat until they unstick */ + for (i = 0; i < 0xffff; i++) { PSB_WVDC32(PSB_RVDC32(pipe_stat_reg), pipe_stat_reg); - (void) PSB_RVDC32(pipe_stat_reg); + pipe_clear = PSB_RVDC32(pipe_stat_reg) & pipe_status; - if ((PSB_RVDC32(pipe_stat_reg) & pipe_status) == 0) + if (pipe_clear == 0) break; } - if (i == WAIT_STATUS_CLEAR_LOOP_COUNT) + if (pipe_clear) dev_err(dev->dev, - "%s, can't clear the status bits in pipe_stat_reg, its value = 0x%x.\n", - __func__, PSB_RVDC32(pipe_stat_reg)); + "%s, can't clear status bits for pipe %d, its value = 0x%x.\n", + __func__, pipe, PSB_RVDC32(pipe_stat_reg)); if (pipe_stat_val & PIPE_VBLANK_STATUS) - mid_vblank_handler(dev, pipe); + drm_handle_vblank(dev, pipe); if (pipe_stat_val & PIPE_TE_STATUS) drm_handle_vblank(dev, pipe); @@ -203,8 +189,11 @@ static void mid_pipe_event_handler(struct drm_device *dev, uint32_t pipe) */ static void psb_vdc_interrupt(struct drm_device *dev, uint32_t vdc_stat) { - if (vdc_stat & _PSB_PIPEA_EVENT_FLAG) + if (vdc_stat & _PSB_VSYNC_PIPEA_FLAG) mid_pipe_event_handler(dev, 0); + + if (vdc_stat & _PSB_VSYNC_PIPEB_FLAG) + mid_pipe_event_handler(dev, 1); } irqreturn_t psb_irq_handler(DRM_IRQ_ARGS) @@ -220,8 +209,13 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS) vdc_stat = PSB_RVDC32(PSB_INT_IDENTITY_R); + if (vdc_stat & _PSB_PIPE_EVENT_FLAG) + dsp_int = 1; + + /* FIXME: Handle Medfield if (vdc_stat & _MDFLD_DISP_ALL_IRQ_FLAG) dsp_int = 1; + */ if (vdc_stat & _PSB_IRQ_SGX_FLAG) sgx_int = 1; @@ -267,13 +261,18 @@ void psb_irq_preinstall(struct drm_device *dev) if (gma_power_is_on(dev)) PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM); if (dev->vblank_enabled[0]) - dev_priv->vdc_irq_mask |= _PSB_PIPEA_EVENT_FLAG; + dev_priv->vdc_irq_mask |= _PSB_VSYNC_PIPEA_FLAG; + if (dev->vblank_enabled[1]) + dev_priv->vdc_irq_mask |= _PSB_VSYNC_PIPEB_FLAG; + + /* FIXME: Handle Medfield irq mask if (dev->vblank_enabled[1]) dev_priv->vdc_irq_mask |= _MDFLD_PIPEB_EVENT_FLAG; if (dev->vblank_enabled[2]) dev_priv->vdc_irq_mask |= _MDFLD_PIPEC_EVENT_FLAG; + */ - /*This register is safe even if display island is off*/ + /* This register is safe even if display island is off */ PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R); spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags); } @@ -471,7 +470,13 @@ int psb_enable_vblank(struct drm_device *dev, int pipe) spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags); - mid_enable_pipe_event(dev_priv, pipe); + if (pipe == 0) + dev_priv->vdc_irq_mask |= _PSB_VSYNC_PIPEA_FLAG; + else if (pipe == 1) + dev_priv->vdc_irq_mask |= _PSB_VSYNC_PIPEB_FLAG; + + PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R); + PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R); psb_enable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_ENABLE); spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags); @@ -493,7 +498,13 @@ void psb_disable_vblank(struct drm_device *dev, int pipe) #endif spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags); - mid_disable_pipe_event(dev_priv, pipe); + if (pipe == 0) + dev_priv->vdc_irq_mask &= ~_PSB_VSYNC_PIPEA_FLAG; + else if (pipe == 1) + dev_priv->vdc_irq_mask &= ~_PSB_VSYNC_PIPEB_FLAG; + + PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R); + PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R); psb_disable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_ENABLE); spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags); From 6b8402b5fe6803f350cf4ce2933c382a1f6e099b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 26 Aug 2011 11:18:41 +0100 Subject: [PATCH 0637/1519] gma500: do a pass over the FIXME tags Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/cdv_device.c | 1 - drivers/staging/gma500/framebuffer.c | 7 +++-- drivers/staging/gma500/gem.c | 5 +--- drivers/staging/gma500/gtt.c | 30 +++++++++++++------- drivers/staging/gma500/intel_opregion.c | 1 + drivers/staging/gma500/mdfld_intel_display.c | 12 ++++---- drivers/staging/gma500/mrst_crtc.c | 16 ++++------- drivers/staging/gma500/psb_drv.c | 1 - drivers/staging/gma500/psb_intel_lvds.c | 1 - drivers/staging/gma500/psb_lid.c | 2 -- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/staging/gma500/cdv_device.c b/drivers/staging/gma500/cdv_device.c index 87614e0d396..8ec10caab13 100644 --- a/drivers/staging/gma500/cdv_device.c +++ b/drivers/staging/gma500/cdv_device.c @@ -30,7 +30,6 @@ #define VGA_SR_INDEX 0x3c4 #define VGA_SR_DATA 0x3c5 -/* FIXME: should check if we are the active VGA device ?? */ static void cdv_disable_vga(struct drm_device *dev) { u8 sr1; diff --git a/drivers/staging/gma500/framebuffer.c b/drivers/staging/gma500/framebuffer.c index ebfde13ec18..7748331d269 100644 --- a/drivers/staging/gma500/framebuffer.c +++ b/drivers/staging/gma500/framebuffer.c @@ -733,9 +733,12 @@ static void psb_setup_outputs(struct drm_device *dev) clone_mask = (1 << INTEL_OUTPUT_MIPI2); break; case INTEL_OUTPUT_HDMI: - if (IS_MFLD(dev)) + /* HDMI on crtc 1 for SoC devices and crtc 0 for + Cedarview. HDMI on Poulsbo is only via external + logic */ + if (IS_MFLD(dev) || IS_MRST(dev)) crtc_mask = (1 << 1); - else /* FIXME: review Oaktrail */ + else crtc_mask = (1 << 0); /* Cedarview */ clone_mask = (1 << INTEL_OUTPUT_HDMI); break; diff --git a/drivers/staging/gma500/gem.c b/drivers/staging/gma500/gem.c index 65fdd6b8ab1..f6433c037d2 100644 --- a/drivers/staging/gma500/gem.c +++ b/drivers/staging/gma500/gem.c @@ -120,8 +120,7 @@ static int psb_gem_create(struct drm_file *file, /* Initialize the extra goodies GEM needs to do all the hard work */ if (drm_gem_object_init(dev, &r->gem, size) != 0) { psb_gtt_free_range(dev, r); - /* GEM doesn't give an error code and we don't have an - EGEMSUCKS so make something up for now - FIXME */ + /* GEM doesn't give an error code so use -ENOMEM */ dev_err(dev->dev, "GEM init failed for %lld\n", size); return -ENOMEM; } @@ -191,8 +190,6 @@ int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, * The VMA was set up by GEM. In doing so it also ensured that the * vma->vm_private_data points to the GEM object that is backing this * mapping. - * - * FIXME */ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { diff --git a/drivers/staging/gma500/gtt.c b/drivers/staging/gma500/gtt.c index 461ead251bb..a24623997e5 100644 --- a/drivers/staging/gma500/gtt.c +++ b/drivers/staging/gma500/gtt.c @@ -72,9 +72,8 @@ u32 *psb_gtt_entry(struct drm_device *dev, struct gtt_range *r) * @r: our GTT range * * Take our preallocated GTT range and insert the GEM object into - * the GTT. - * - * FIXME: gtt lock ? + * the GTT. This is protected via the gtt mutex which the caller + * must hold. */ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r) { @@ -111,7 +110,8 @@ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r) * @r: our GTT range * * Remove a preallocated GTT range from the GTT. Overwrite all the - * page table entries with the dummy page + * page table entries with the dummy page. This is protected via the gtt + * mutex which the caller must hold. */ static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r) @@ -136,7 +136,8 @@ static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r) * @gt: the gtt range * * Pin and build an in kernel list of the pages that back our GEM object. - * While we hold this the pages cannot be swapped out + * While we hold this the pages cannot be swapped out. This is protected + * via the gtt mutex which the caller must hold. */ static int psb_gtt_attach_pages(struct gtt_range *gt) { @@ -158,7 +159,7 @@ static int psb_gtt_attach_pages(struct gtt_range *gt) gt->npage = pages; for (i = 0; i < pages; i++) { - /* FIXME: review flags later */ + /* FIXME: needs updating as per mail from Hugh Dickins */ p = read_cache_page_gfp(mapping, i, __GFP_COLD | GFP_KERNEL); if (IS_ERR(p)) @@ -181,7 +182,8 @@ err: * * Undo the effect of psb_gtt_attach_pages. At this point the pages * must have been removed from the GTT as they could now be paged out - * and move bus address. + * and move bus address. This is protected via the gtt mutex which the + * caller must hold. */ static void psb_gtt_detach_pages(struct gtt_range *gt) { @@ -390,15 +392,18 @@ int psb_gtt_init(struct drm_device *dev, int resume) pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK; /* - * FIXME: video mmu has hw bug to access 0x0D0000000, - * then make gatt start at 0x0e000,0000 + * The video mmu has a hw bug when accessing 0x0D0000000. + * Make gatt start at 0x0e000,0000. This doesn't actually + * matter for us but may do if the video acceleration ever + * gets opened up. */ pg->mmu_gatt_start = 0xE0000000; pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE); gtt_pages = pci_resource_len(dev->pdev, PSB_GTT_RESOURCE) >> PAGE_SHIFT; - /* CDV workaround */ + /* Some CDV firmware doesn't report this currently. In which case the + system has 64 gtt pages */ if (pg->gtt_start == 0 || gtt_pages == 0) { dev_err(dev->dev, "GTT PCI BAR not initialized.\n"); gtt_pages = 64; @@ -412,13 +417,16 @@ int psb_gtt_init(struct drm_device *dev, int resume) if (pg->gatt_pages == 0 || pg->gatt_start == 0) { static struct resource fudge; /* Preferably peppermint */ - /* This can occur on CDV SDV systems. Fudge it in this case. We really don't care what imaginary space is being allocated at this point */ dev_err(dev->dev, "GATT PCI BAR not initialized.\n"); pg->gatt_start = 0x40000000; pg->gatt_pages = (128 * 1024 * 1024) >> PAGE_SHIFT; + /* This is a little confusing but in fact the GTT is providing + a view from the GPU into memory and not vice versa. As such + this is really allocating space that is not the same as the + CPU address space on CDV */ fudge.start = 0x40000000; fudge.end = 0x40000000 + 128 * 1024 * 1024 - 1; fudge.name = "fudge"; diff --git a/drivers/staging/gma500/intel_opregion.c b/drivers/staging/gma500/intel_opregion.c index d2e60376982..d946bc1b17b 100644 --- a/drivers/staging/gma500/intel_opregion.c +++ b/drivers/staging/gma500/intel_opregion.c @@ -20,6 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * + * FIXME: resolve with the i915 version */ #include "psb_drv.h" diff --git a/drivers/staging/gma500/mdfld_intel_display.c b/drivers/staging/gma500/mdfld_intel_display.c index aa2ff559383..8eb827ecc3d 100644 --- a/drivers/staging/gma500/mdfld_intel_display.c +++ b/drivers/staging/gma500/mdfld_intel_display.c @@ -282,7 +282,7 @@ static int mdfld_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) return -EINVAL; } -#if 1 /* FIXME_JLIU7 can't enalbe cursorB/C HW issue. need to remove after HW fix */ +#if 1 /* FIXME_JLIU7 can't enable cursorB/C HW issue. need to remove after HW fix */ if (pipe != 0) return 0; #endif @@ -484,7 +484,7 @@ void mdfld_disable_crtc (struct drm_device *dev, int pipe) /* FIXME_JLIU7 MDFLD_PO revisit */ /* Wait for vblank for the disable to take effect */ -// MDFLD_PO_JLIU7 psb_intel_wait_for_vblank(dev); +/* MDFLD_PO_JLIU7 psb_intel_wait_for_vblank(dev); */ /* Next, disable display pipes */ temp = REG_READ(pipeconf_reg); @@ -561,7 +561,6 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) //gbdispstatus = true; } - /* FIXME_JLIU7 MDFLD_PO replaced w/ the following function */ /* mdfld_dbi_dpms (struct drm_device *dev, int pipe, bool enabled) */ @@ -1150,8 +1149,11 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, dev->mode_config.scaling_mode_property, &scalingType); if (scalingType == DRM_MODE_SCALE_NO_SCALE) { - /*Moorestown doesn't have register support for centering so we need to - mess with the h/vblank and h/vsync start and ends to get centering*/ + /* + * Medfield doesn't have register support for centering so + * we need to mess with the h/vblank and h/vsync start and + * ends to get central + */ int offsetX = 0, offsetY = 0; offsetX = (adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2; diff --git a/drivers/staging/gma500/mrst_crtc.c b/drivers/staging/gma500/mrst_crtc.c index 72464dd0f23..c9311a573c2 100644 --- a/drivers/staging/gma500/mrst_crtc.c +++ b/drivers/staging/gma500/mrst_crtc.c @@ -521,12 +521,11 @@ int mrst_pipe_set_base(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *old_fb) { struct drm_device *dev = crtc->dev; - /* struct drm_i915_master_private *master_priv; */ struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); int pipe = psb_intel_crtc->pipe; unsigned long start, offset; - /* FIXME: check if we need this surely MRST is pipe 0 only */ + int dspbase = (pipe == 0 ? DSPALINOFF : DSPBBASE); int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF); int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE; @@ -572,15 +571,10 @@ int mrst_pipe_set_base(struct drm_crtc *crtc, } REG_WRITE(dspcntr_reg, dspcntr); - if (0 /* FIXMEAC - check what PSB needs */) { - REG_WRITE(dspbase, offset); - REG_READ(dspbase); - REG_WRITE(dspsurf, start); - REG_READ(dspsurf); - } else { - REG_WRITE(dspbase, start + offset); - REG_READ(dspbase); - } + REG_WRITE(dspbase, offset); + REG_READ(dspbase); + REG_WRITE(dspsurf, start); + REG_READ(dspsurf); pipe_set_base_exit: gma_power_end(dev); diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index 10c8ecdbbbf..34cf24a1731 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -183,7 +183,6 @@ static void psb_lastclose(struct drm_device *dev) static void psb_do_takedown(struct drm_device *dev) { - /* FIXME: do we need to clean up the gtt here ? */ } static int psb_do_init(struct drm_device *dev) diff --git a/drivers/staging/gma500/psb_intel_lvds.c b/drivers/staging/gma500/psb_intel_lvds.c index c6436da6073..8b951e3afd4 100644 --- a/drivers/staging/gma500/psb_intel_lvds.c +++ b/drivers/staging/gma500/psb_intel_lvds.c @@ -382,7 +382,6 @@ bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder, if (psb_intel_output->type == INTEL_OUTPUT_MIPI2) panel_fixed_mode = mode_dev->panel_fixed_mode2; - /* FIXME: review for Medfield */ /* PSB requires the LVDS is on pipe B, MRST has only one pipe anyway */ if (!IS_MRST(dev) && psb_intel_crtc->pipe == 0) { printk(KERN_ERR "Can't support LVDS on pipe A\n"); diff --git a/drivers/staging/gma500/psb_lid.c b/drivers/staging/gma500/psb_lid.c index af328516561..b867aabe6bf 100644 --- a/drivers/staging/gma500/psb_lid.c +++ b/drivers/staging/gma500/psb_lid.c @@ -52,8 +52,6 @@ static void psb_lid_timer_func(unsigned long data) pp_status = REG_READ(PP_STATUS); } while ((pp_status & PP_ON) == 0); } - /* printk(KERN_INFO"%s: lid: closed\n", __FUNCTION__); */ - dev_priv->lid_last_state = readl(lid_state); lid_timer_schedule: From 6cee1f83448bc568de8b426f7cc15f0dc6f4b064 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 26 Aug 2011 11:18:57 +0100 Subject: [PATCH 0638/1519] gma500: Convert spaces to tabs in accel_2d.c. Convert the spaces within the accel_2d.c file to tabs in order to comply with the coding style of the kernel. Signed-off-by: Akshay Joshi Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/accel_2d.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/gma500/accel_2d.c b/drivers/staging/gma500/accel_2d.c index 14400fcfe8a..be9237184ab 100644 --- a/drivers/staging/gma500/accel_2d.c +++ b/drivers/staging/gma500/accel_2d.c @@ -118,7 +118,7 @@ static int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf, size -= submit_size; ret = psb_2d_wait_available(dev_priv, submit_size); if (ret) - break; + break; submit_size <<= 2; @@ -388,19 +388,19 @@ int psb_accel_ioctl(struct drm_device *dev, void *data, struct drm_file *file) for (i = 0; i < op->size; i++, op_ptr++) { u32 r = *op_ptr & 0xF0000000; /* Fill in the GTT offsets for the command buffer */ - if (r == PSB_2D_SRC_SURF_BH || - r == PSB_2D_DST_SURF_BH || + if (r == PSB_2D_SRC_SURF_BH || + r == PSB_2D_DST_SURF_BH || r == PSB_2D_MASK_SURF_BH || r == PSB_2D_PAT_SURF_BH) { i++; op_ptr++; if (i == op->size) goto bad; - if (*op_ptr) + if (*op_ptr) goto bad; - *op_ptr = gtt->offset; - continue; - } + *op_ptr = gtt->offset; + continue; + } } psbfb_2d_submit(dev_priv, op->cmd, op->size); err = 0; From d921b0b76510045e8c911ef9b3de8b71a1d526e4 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 26 Aug 2011 11:19:17 +0100 Subject: [PATCH 0639/1519] gma500: kill bogus code During the power split ups and work a chunk of code escaped into the Poulsbo code path which it isn't for. On some devices such as the Dell mini-10 this causes problems. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/psb_device.c | 32 ----------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/gma500/psb_device.c b/drivers/staging/gma500/psb_device.c index 46591323595..b97aa78519f 100644 --- a/drivers/staging/gma500/psb_device.c +++ b/drivers/staging/gma500/psb_device.c @@ -213,7 +213,6 @@ static int psb_restore_display_registers(struct drm_device *dev) struct drm_psb_private *dev_priv = dev->dev_private; struct drm_crtc *crtc; struct drm_connector *connector; - int pp_stat; /* Display arbitration + watermarks */ PSB_WVDC32(dev_priv->saveDSPARB, DSPARB); @@ -237,37 +236,6 @@ static int psb_restore_display_registers(struct drm_device *dev) connector->funcs->restore(connector); mutex_unlock(&dev->mode_config.mutex); - - if (dev_priv->iLVDS_enable) { - /*shutdown the panel*/ - PSB_WVDC32(0, PP_CONTROL); - do { - pp_stat = PSB_RVDC32(PP_STATUS); - } while (pp_stat & 0x80000000); - - /* Turn off the plane */ - PSB_WVDC32(0x58000000, DSPACNTR); - PSB_WVDC32(0, DSPASURF);/*trigger the plane disable*/ - /* Wait ~4 ticks */ - msleep(4); - /* Turn off pipe */ - PSB_WVDC32(0x0, PIPEACONF); - /* Wait ~8 ticks */ - msleep(8); - - /* Turn off PLLs */ - PSB_WVDC32(0, MRST_DPLL_A); - } else { - PSB_WVDC32(DPI_SHUT_DOWN, DPI_CONTROL_REG); - PSB_WVDC32(0x0, PIPEACONF); - PSB_WVDC32(0x2faf0000, BLC_PWM_CTL); - while (REG_READ(0x70008) & 0x40000000) - cpu_relax(); - while ((PSB_RVDC32(GEN_FIFO_STAT_REG) & DPI_FIFO_EMPTY) - != DPI_FIFO_EMPTY) - cpu_relax(); - PSB_WVDC32(0, DEVICE_READY_REG); - } return 0; } From 2a30cda7af24dc179d60f6343f065d6077f541f3 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 26 Aug 2011 11:19:34 +0100 Subject: [PATCH 0640/1519] gma500: Fix backlight crash Initial changes to get backlight behaviour we want and to fix backlight crashes on suspend/resume paths. [Note: on some boxes this will now produce a warning about the backlight, this isn't a regression it's an unfixed but non harmful case I still need to nail] Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/power.c | 2 +- drivers/staging/gma500/psb_intel_lvds.c | 58 ++++++++++++++----------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/staging/gma500/power.c b/drivers/staging/gma500/power.c index 972bea7c1af..94025693bae 100644 --- a/drivers/staging/gma500/power.c +++ b/drivers/staging/gma500/power.c @@ -302,7 +302,7 @@ int psb_runtime_suspend(struct device *dev) int psb_runtime_resume(struct device *dev) { - return 0; + return gma_power_resume(dev);; } int psb_runtime_idle(struct device *dev) diff --git a/drivers/staging/gma500/psb_intel_lvds.c b/drivers/staging/gma500/psb_intel_lvds.c index 8b951e3afd4..21022e1a977 100644 --- a/drivers/staging/gma500/psb_intel_lvds.c +++ b/drivers/staging/gma500/psb_intel_lvds.c @@ -68,20 +68,23 @@ struct psb_intel_lvds_priv { static u32 psb_intel_lvds_get_max_backlight(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; - u32 retVal; + u32 ret; if (gma_power_begin(dev, false)) { - retVal = ((REG_READ(BLC_PWM_CTL) & - BACKLIGHT_MODULATION_FREQ_MASK) >> - BACKLIGHT_MODULATION_FREQ_SHIFT) * 2; - + ret = REG_READ(BLC_PWM_CTL); gma_power_end(dev); - } else - retVal = ((dev_priv->saveBLC_PWM_CTL & - BACKLIGHT_MODULATION_FREQ_MASK) >> - BACKLIGHT_MODULATION_FREQ_SHIFT) * 2; + } else /* Powered off, use the saved value */ + ret = dev_priv->saveBLC_PWM_CTL; - return retVal; + /* Top 15bits hold the frequency mask */ + ret = (ret & BACKLIGHT_MODULATION_FREQ_MASK) >> + BACKLIGHT_MODULATION_FREQ_SHIFT; + + ret *= 2; /* Return a 16bit range as needed for setting */ + if (ret == 0) + dev_err(dev->dev, "BL bug: Reg %08x save %08X\n", + REG_READ(BLC_PWM_CTL), dev_priv->saveBLC_PWM_CTL); + return ret; } /* @@ -142,7 +145,7 @@ static int psb_lvds_pwm_set_brightness(struct drm_device *dev, int level) max_pwm_blc = psb_intel_lvds_get_max_backlight(dev); /*BLC_PWM_CTL Should be initiated while backlight device init*/ - BUG_ON((max_pwm_blc & PSB_BLC_MAX_PWM_REG_FREQ) == 0); + BUG_ON(max_pwm_blc == 0); blc_pwm_duty_cycle = level * max_pwm_blc / BRIGHTNESS_MAX_LEVEL; @@ -154,6 +157,10 @@ static int psb_lvds_pwm_set_brightness(struct drm_device *dev, int level) (max_pwm_blc << PSB_BACKLIGHT_PWM_CTL_SHIFT) | (blc_pwm_duty_cycle)); + dev_info(dev->dev, "Backlight lvds set brightness %08x\n", + (max_pwm_blc << PSB_BACKLIGHT_PWM_CTL_SHIFT) | + (blc_pwm_duty_cycle)); + return 0; } @@ -162,14 +169,12 @@ static int psb_lvds_pwm_set_brightness(struct drm_device *dev, int level) */ void psb_intel_lvds_set_brightness(struct drm_device *dev, int level) { - /*u32 blc_pwm_ctl;*/ - struct drm_psb_private *dev_priv = - (struct drm_psb_private *)dev->dev_private; + struct drm_psb_private *dev_priv = dev->dev_private; dev_dbg(dev->dev, "backlight level is %d\n", level); if (!dev_priv->lvds_bl) { - dev_err(dev->dev, "NO LVDS Backlight Info\n"); + dev_err(dev->dev, "NO LVDS backlight info\n"); return; } @@ -190,11 +195,13 @@ static void psb_intel_lvds_set_backlight(struct drm_device *dev, int level) u32 blc_pwm_ctl; if (gma_power_begin(dev, false)) { - blc_pwm_ctl = - REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK; + blc_pwm_ctl = REG_READ(BLC_PWM_CTL); + blc_pwm_ctl &= ~BACKLIGHT_DUTY_CYCLE_MASK; REG_WRITE(BLC_PWM_CTL, (blc_pwm_ctl | (level << BACKLIGHT_DUTY_CYCLE_SHIFT))); + dev_priv->saveBLC_PWM_CTL = (blc_pwm_ctl | + (level << BACKLIGHT_DUTY_CYCLE_SHIFT)); gma_power_end(dev); } else { blc_pwm_ctl = dev_priv->saveBLC_PWM_CTL & @@ -212,9 +219,11 @@ static void psb_intel_lvds_set_power(struct drm_device *dev, { u32 pp_status; - if (!gma_power_begin(dev, true)) + if (!gma_power_begin(dev, true)) { + dev_err(dev->dev, "set power, chip off!\n"); return; - + } + if (on) { REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON); @@ -296,9 +305,6 @@ static void psb_intel_lvds_restore(struct drm_connector *connector) { struct drm_device *dev = connector->dev; u32 pp_status; - - /*struct drm_psb_private *dev_priv = - (struct drm_psb_private *)dev->dev_private;*/ struct psb_intel_output *psb_intel_output = to_psb_intel_output(connector); struct psb_intel_lvds_priv *lvds_priv = @@ -621,7 +627,8 @@ int psb_intel_lvds_set_property(struct drm_connector *connector, goto set_prop_error; else { #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE - struct drm_psb_private *devp = encoder->dev->dev_private; + struct drm_psb_private *devp = + encoder->dev->dev_private; struct backlight_device *bd = devp->backlight_device; if (bd) { bd->props.brightness = value; @@ -694,8 +701,7 @@ void psb_intel_lvds_init(struct drm_device *dev, struct drm_encoder *encoder; struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_crtc *crtc; - struct drm_psb_private *dev_priv = - (struct drm_psb_private *)dev->dev_private; + struct drm_psb_private *dev_priv = dev->dev_private; u32 lvds; int pipe; @@ -711,8 +717,8 @@ void psb_intel_lvds_init(struct drm_device *dev, } psb_intel_output->dev_priv = lvds_priv; - psb_intel_output->mode_dev = mode_dev; + connector = &psb_intel_output->base; encoder = &psb_intel_output->enc; drm_connector_init(dev, &psb_intel_output->base, From cf9f1155592091687b02e64a40c41d6a482985cd Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 26 Aug 2011 11:20:17 +0100 Subject: [PATCH 0641/1519] gma500: Fix up suspend/resume This isn't ideal as we could do with deferring the power on a lot more on Oaktrail and Medfield. We can't however do that without fixing other things first. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/power.c | 6 ++-- drivers/staging/gma500/psb_drv.c | 36 ++++++++++------------ drivers/staging/gma500/psb_intel_display.c | 4 --- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/staging/gma500/power.c b/drivers/staging/gma500/power.c index 94025693bae..436fe9733b1 100644 --- a/drivers/staging/gma500/power.c +++ b/drivers/staging/gma500/power.c @@ -83,7 +83,7 @@ static void gma_suspend_display(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; - if (dev_priv->suspended) + if (!dev_priv->display_power) return; dev_priv->ops->save_regs(dev); dev_priv->ops->power_down(dev); @@ -101,7 +101,7 @@ static void gma_resume_display(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); struct drm_psb_private *dev_priv = dev->dev_private; - if (dev_priv->suspended == false) + if (dev_priv->display_power) return; /* turn on the display power island */ @@ -265,6 +265,8 @@ bool gma_power_begin(struct drm_device *dev, bool force_on) /* Ok power up needed */ ret = gma_resume_pci(dev->pdev); if (ret == 0) { + /* FIXME: we want to defer this for Medfield/Oaktrail */ + gma_resume_display(dev); psb_irq_preinstall(dev); psb_irq_postinstall(dev); pm_runtime_get(&dev->pdev->dev); diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index 34cf24a1731..297b05a391d 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -448,12 +448,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset) if (ret) return ret; -#if 0 - /*enable runtime pm at last*/ - pm_runtime_enable(&dev->pdev->dev); + + /* Enable runtime pm at last */ pm_runtime_set_active(&dev->pdev->dev); -#endif - /*Intel drm driver load is done, continue doing pvr load*/ return 0; out_err: psb_driver_unload(dev); @@ -470,14 +467,13 @@ static int psb_sizes_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_psb_private *dev_priv = psb_priv(dev); - struct drm_psb_sizes_arg *arg = - (struct drm_psb_sizes_arg *) data; + struct drm_psb_sizes_arg *arg = data; *arg = dev_priv->sizes; return 0; } -static int psb_dc_state_ioctl(struct drm_device *dev, void * data, +static int psb_dc_state_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { uint32_t flags; @@ -485,8 +481,7 @@ static int psb_dc_state_ioctl(struct drm_device *dev, void * data, struct drm_mode_object *obj; struct drm_connector *connector; struct drm_crtc *crtc; - struct drm_psb_dc_state_arg *arg = - (struct drm_psb_dc_state_arg *)data; + struct drm_psb_dc_state_arg *arg = data; /* Double check MRST case */ @@ -1114,15 +1109,12 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd, { struct drm_file *file_priv = filp->private_data; struct drm_device *dev = file_priv->minor->dev; - struct drm_psb_private *dev_priv = dev->dev_private; - static unsigned int runtime_allowed; - - if (runtime_allowed == 1 && dev_priv->is_lvds_on) { - runtime_allowed++; - pm_runtime_allow(&dev->pdev->dev); - dev_priv->rpm_enabled = 1; - } - return drm_ioctl(filp, cmd, arg); + int ret; + + pm_runtime_forbid(dev->dev); + ret = drm_ioctl(filp, cmd, arg); + pm_runtime_allow(dev->dev); + return ret; /* FIXME: do we need to wrap the other side of this */ } @@ -1141,8 +1133,12 @@ static void psb_remove(struct pci_dev *pdev) } static const struct dev_pm_ops psb_pm_ops = { - .resume = gma_power_resume, .suspend = gma_power_suspend, + .resume = gma_power_resume, + .freeze = gma_power_suspend, + .thaw = gma_power_resume, + .poweroff = gma_power_suspend, + .restore = gma_power_resume, .runtime_suspend = psb_runtime_suspend, .runtime_resume = psb_runtime_resume, .runtime_idle = psb_runtime_idle, diff --git a/drivers/staging/gma500/psb_intel_display.c b/drivers/staging/gma500/psb_intel_display.c index 4afa671f974..caa9d86f26d 100644 --- a/drivers/staging/gma500/psb_intel_display.c +++ b/drivers/staging/gma500/psb_intel_display.c @@ -1102,10 +1102,6 @@ static int psb_crtc_set_config(struct drm_mode_set *set) { int ret; struct drm_device *dev = set->crtc->dev; - struct drm_psb_private *dev_priv = dev->dev_private; - - if (!dev_priv->rpm_enabled) - return drm_crtc_helper_set_config(set); pm_runtime_forbid(&dev->pdev->dev); ret = drm_crtc_helper_set_config(set); From 04831578b801f56ef664f1593dc0f4197eb696a2 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:28 +0200 Subject: [PATCH 0642/1519] staging: brcm80211: remove unused definition flag from top Makefile The use of the definition BCMDMA32 was already removed from the source code, but it was still defined in the top-level Makefile. This patch removes it. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/brcm80211/Makefile b/drivers/staging/brcm80211/Makefile index 8b01f5e7ba2..f41c047eca8 100644 --- a/drivers/staging/brcm80211/Makefile +++ b/drivers/staging/brcm80211/Makefile @@ -16,7 +16,6 @@ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # common flags -subdir-ccflags-y := -DBCMDMA32 subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG obj-$(CONFIG_BRCMUTIL) += brcmutil/ From 0a980d455baef8194105702c85834a0368172fe0 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:29 +0200 Subject: [PATCH 0643/1519] staging: brcm80211: remove macro definitions from brcmsmac Makefile The Makefile for the brcmsmac driver contains macro definitions that are always set and even some are not used in the source code anymore. This patch removes those definitions from the Makefile and source code. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/Makefile | 7 ------- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 5 +---- drivers/staging/brcm80211/brcmsmac/srom.c | 12 ++---------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile index 3147c487188..eee2fe30ca7 100644 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -16,13 +16,6 @@ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ccflags-y := \ - -DWLC_HIGH \ - -DWLC_LOW \ - -DSTA \ - -DWME \ - -DWL11N \ - -DDBAND \ - -DBCMNVRAMR \ -Idrivers/staging/brcm80211/brcmsmac \ -Idrivers/staging/brcm80211/brcmsmac/phy \ -Idrivers/staging/brcm80211/include diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 5307bd8c258..cbb0bde439e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -1666,13 +1666,10 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) } } } -#if WL11N + max_num_rate = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : ((ISLCNPHY(pi)) ? (TXP_LAST_SISO_MCS_20 + 1) : (TXP_LAST_OFDM + 1))); -#else - max_num_rate = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : (TXP_LAST_OFDM + 1)); -#endif wlc_phy_upd_env_txpwr_rate_limits(pi, band); diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 90e2ac80c22..a8f7c008628 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -798,9 +798,7 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, uint *count); static int sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc); -#if defined(BCMNVRAMR) static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz); -#endif static int initvars_table(char *start, char *end, char **vars, uint *count); @@ -940,7 +938,6 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, return err; } -#if defined(BCMNVRAMR) static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) { u8 *otp; @@ -976,7 +973,7 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) return err; } -#endif /* defined(BCMNVRAMR) */ + /* * Create variable table from memory. * Return 0 on success, nonzero on error. @@ -1208,18 +1205,13 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, sromrev = 1; } } -#if defined(BCMNVRAMR) - /* Use OTP if SPROM not available */ else { + /* Use OTP if SPROM not available */ err = otp_read_pci(sih, srom, SROM_MAX); if (err == 0) /* OTP only contain SROM rev8/rev9 for now */ sromrev = srom[SROM4_CRCREV] & 0xff; } -#else - else - err = -ENODEV; -#endif if (!err) { /* Bitmask for the sromrev */ From 1bf8b11069e9fbd3efab45e65e4a6aa2da383b9e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:30 +0200 Subject: [PATCH 0644/1519] staging: brcm80211: remove usage of macro WL11N_20MHZONLY The macro WL11N_20MHZONLY is never defined so code #ifdef'ed by it has been removed. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/include/brcmu_wifi.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/brcm80211/include/brcmu_wifi.h b/drivers/staging/brcm80211/include/brcmu_wifi.h index 717d88542b7..0ab432d91d2 100644 --- a/drivers/staging/brcm80211/include/brcmu_wifi.h +++ b/drivers/staging/brcm80211/include/brcmu_wifi.h @@ -96,18 +96,6 @@ #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK)) #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) -#ifdef WL11N_20MHZONLY - -#define CHSPEC_CTL_SB(chspec) WL_CHANSPEC_CTL_SB_NONE -#define CHSPEC_BW(chspec) WL_CHANSPEC_BW_20 -#define CHSPEC_IS10(chspec) 0 -#define CHSPEC_IS20(chspec) 1 -#ifndef CHSPEC_IS40 -#define CHSPEC_IS40(chspec) 0 -#endif - -#else /* !WL11N_20MHZONLY */ - #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK) #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK) @@ -122,8 +110,6 @@ (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) #endif -#endif /* !WL11N_20MHZONLY */ - #define CHSPEC_IS5G(chspec) \ (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) From f66a27de208228f007c5812932e495fab48abff1 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:31 +0200 Subject: [PATCH 0645/1519] staging: brcm80211: remove macro definitions from brcmfmac Makefile The Makefile for the brcmfmac driver contains macro definitions that are always set. This patch removes those definitions from the Makefile and source code. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/Makefile | 5 ----- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 7 +------ drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 15 ++------------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/Makefile b/drivers/staging/brcm80211/brcmfmac/Makefile index da3c8057590..826a2ba6a73 100644 --- a/drivers/staging/brcm80211/brcmfmac/Makefile +++ b/drivers/staging/brcm80211/brcmfmac/Makefile @@ -15,11 +15,6 @@ # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -ccflags-y := \ - -DBRCMF_FIRSTREAD=64 \ - -DBRCMF_SDALIGN=64 \ - -DMAX_HDR_READ=64 - ccflags-$(CONFIG_BRCMDBG) += -DSHOW_EVENTS ccflags-y += \ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 653cf0daa0e..24f578ab406 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -18,12 +18,7 @@ #define _BRCMF_BUS_H_ /* Packet alignment for most efficient SDIO (can change based on platform) */ -#ifndef BRCMF_SDALIGN -#define BRCMF_SDALIGN 32 -#endif -#if !ISPOWEROF2(BRCMF_SDALIGN) -#error BRCMF_SDALIGN is not a power of 2! -#endif +#define BRCMF_SDALIGN (1 << 6) /* * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8e59086d639..9b41891b191 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -130,13 +130,8 @@ struct rte_console { #define MAX_DATA_BUF (32 * 1024) /* Must be large enough to hold biggest possible glom */ -#ifndef BRCMF_FIRSTREAD -#define BRCMF_FIRSTREAD 32 -#endif +#define BRCMF_FIRSTREAD (1 << 6) -#if !ISPOWEROF2(BRCMF_FIRSTREAD) -#error BRCMF_FIRSTREAD is not a power of 2! -#endif /* SBSDIO_DEVICE_CTL */ @@ -362,13 +357,7 @@ struct rte_console { /* Space for header read, limit for data packets */ -#ifndef MAX_HDR_READ -#define MAX_HDR_READ 32 -#endif -#if !ISPOWEROF2(MAX_HDR_READ) -#error MAX_HDR_READ is not a power of 2! -#endif - +#define MAX_HDR_READ (1 << 6) #define MAX_RX_DATASZ 2048 /* Maximum milliseconds to wait for F2 to come up */ From 206a443fc44f63d378c22cbec5d3c8e2d75c498c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:32 +0200 Subject: [PATCH 0646/1519] staging: brcm80211: rename key endian conversion functions The key endian conversion functions in wl_cfg80211.c have been renamed as the old names were misleasing. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 80bb30a8a76..8b052b0fbb1 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -215,8 +215,8 @@ static s32 brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, /* ** key indianess swap utilities */ -static void swap_key_from_BE(struct brcmf_wsec_key *key); -static void swap_key_to_BE(struct brcmf_wsec_key *key); +static void convert_key_from_CPU(struct brcmf_wsec_key *key); +static void convert_key_to_CPU(struct brcmf_wsec_key *key); /* ** brcmf_cfg80211_priv memory init/deinit utilities @@ -509,7 +509,7 @@ static const u32 __wl_cipher_suites[] = { WLAN_CIPHER_SUITE_AES_CMAC, }; -static void swap_key_from_BE(struct brcmf_wsec_key *key) +static void convert_key_from_CPU(struct brcmf_wsec_key *key) { key->index = cpu_to_le32(key->index); key->len = cpu_to_le32(key->len); @@ -520,7 +520,7 @@ static void swap_key_from_BE(struct brcmf_wsec_key *key) key->iv_initialized = cpu_to_le32(key->iv_initialized); } -static void swap_key_to_BE(struct brcmf_wsec_key *key) +static void convert_key_to_CPU(struct brcmf_wsec_key *key) { key->index = le32_to_cpu(key->index); key->len = le32_to_cpu(key->len); @@ -1344,7 +1344,7 @@ brcmf_set_set_sharedkey(struct net_device *dev, WL_CONN("key length (%d) key index (%d) algo (%d)\n", key.len, key.index, key.algo); WL_CONN("key \"%s\"\n", key.data); - swap_key_from_BE(&key); + convert_key_from_CPU(&key); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); if (unlikely(err)) { @@ -1612,7 +1612,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, /* check for key index change */ if (key.len == 0) { /* key delete */ - swap_key_from_BE(&key); + convert_key_from_CPU(&key); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); if (unlikely(err)) { WL_ERR("key delete error (%d)\n", err); @@ -1670,7 +1670,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, WL_ERR("Invalid cipher (0x%x)\n", params->cipher); return -EINVAL; } - swap_key_from_BE(&key); + convert_key_from_CPU(&key); brcmf_netdev_wait_pend8021x(dev); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); @@ -1745,7 +1745,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, } /* Set the new key/index */ - swap_key_from_BE(&key); + convert_key_from_CPU(&key); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); if (unlikely(err)) { WL_ERR("WLC_SET_KEY error (%d)\n", err); @@ -1795,7 +1795,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, WL_CONN("key index (%d)\n", key_idx); /* Set the new key/index */ - swap_key_from_BE(&key); + convert_key_from_CPU(&key); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); if (unlikely(err)) { if (err == -EINVAL) { @@ -1859,7 +1859,7 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, memset(&key, 0, sizeof(key)); key.index = key_idx; - swap_key_to_BE(&key); + convert_key_to_CPU(&key); memset(¶ms, 0, sizeof(params)); params.key_len = (u8) min_t(u8, WLAN_MAX_KEY_LEN, key.len); memcpy(params.key, key.data, params.key_len); From 0310b1bc75336a05a68589de68d7b04db35483ad Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 26 Aug 2011 15:19:33 +0200 Subject: [PATCH 0647/1519] staging: brcm80211: remove brcmf_find_msb() function This function is similar to ffs() wihch is provided by the linux kernel already. This patch replaces brcmf_find_msb() with ffs(). Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 8b052b0fbb1..4f7b0816af7 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -293,11 +294,6 @@ static s32 brcmf_iscan_pending(struct brcmf_cfg80211_priv *cfg_priv); static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv); static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv); -/* -* find most significant bit set -*/ -static __used u32 brcmf_find_msb(u16 bit16); - /* * update pmklist to dongle */ @@ -2008,33 +2004,6 @@ done: return err; } -static __used u32 brcmf_find_msb(u16 bit16) -{ - u32 ret = 0; - - if (bit16 & 0xff00) { - ret += 8; - bit16 >>= 8; - } - - if (bit16 & 0xf0) { - ret += 4; - bit16 >>= 4; - } - - if (bit16 & 0xc) { - ret += 2; - bit16 >>= 2; - } - - if (bit16 & 2) - ret += bit16 & 2; - else if (bit16) - ret += bit16; - - return ret; -} - static s32 brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, const u8 *addr, @@ -2062,10 +2031,10 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, rateset.count = le32_to_cpu(rateset.count); - legacy = brcmf_find_msb(mask->control[IEEE80211_BAND_2GHZ].legacy); + legacy = ffs(mask->control[IEEE80211_BAND_2GHZ].legacy & 0xFFFF); if (!legacy) - legacy = brcmf_find_msb( - mask->control[IEEE80211_BAND_5GHZ].legacy); + legacy = ffs(mask->control[IEEE80211_BAND_5GHZ].legacy & + 0xFFFF); val = wl_g_rates[legacy - 1].bitrate * 100000; From 87687ac926c2db6875b47f86fd466a82873751c5 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:34 +0200 Subject: [PATCH 0648/1519] staging: brcm80211: removed unused code in dma.c Code cleanup. Preprocessor symbol BCMDMASGLISTOSL was never defined. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 138 ++++------------------- 1 file changed, 22 insertions(+), 116 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 05dad9fcc93..e53088e7643 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -207,18 +207,6 @@ static uint dma_msg_level; #define DI_INFO(dmah) ((dma_info_t *)dmah) -/* One physical DMA segment */ -struct dma_seg { - unsigned long addr; - u32 length; -}; - -struct dma_seg_map { - uint origsize; /* Size of the virtual packet */ - uint nsegs; - struct dma_seg segs[MAX_DMA_SEGS]; -}; - /* * DMA Descriptor * Descriptors are only read by the hardware, never written back. @@ -261,7 +249,6 @@ struct dma_info { u16 txout; /* index of next descriptor to post */ /* pointer to parallel array of pointers to packets */ struct sk_buff **txp; - struct dma_seg_map *txp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long txdpa; /* Original physical address of descriptor ring */ @@ -278,7 +265,6 @@ struct dma_info { u16 rxout; /* index of next descriptor to post */ /* pointer to parallel array of pointers to packets */ struct sk_buff **rxp; - struct dma_seg_map *rxp_dmah; /* DMA MAP meta-data handle */ /* Aligned physical address of descriptor ring */ unsigned long rxdpa; /* Original physical address of descriptor ring */ @@ -312,16 +298,6 @@ struct dma_info { bool aligndesc_4k; }; -/* - * DMA Scatter-gather list is supported. Note this is limited to TX - * direction only - */ -#ifdef BCMDMASGLISTOSL -#define DMASGLIST_ENAB true -#else -#define DMASGLIST_ENAB false -#endif /* BCMDMASGLISTOSL */ - /* descriptor bumping macros */ /* faster than %, but n must be power of 2 */ #define XXD(x, n) ((x) & ((n) - 1)) @@ -524,23 +500,6 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->ddoffsethigh, di->dataoffsetlow, di->dataoffsethigh, di->addrext)); - /* allocate DMA mapping vectors */ - if (DMASGLIST_ENAB) { - if (ntxd) { - size = ntxd * sizeof(struct dma_seg_map); - di->txp_dmah = kzalloc(size, GFP_ATOMIC); - if (di->txp_dmah == NULL) - goto fail; - } - - if (nrxd) { - size = nrxd * sizeof(struct dma_seg_map); - di->rxp_dmah = kzalloc(size, GFP_ATOMIC); - if (di->rxp_dmah == NULL) - goto fail; - } - } - return (struct dma_pub *) di; fail: @@ -635,12 +594,6 @@ void dma_detach(struct dma_pub *pub) kfree(di->txp); kfree(di->rxp); - /* free tx packet DMA handles */ - kfree(di->txp_dmah); - - /* free rx packet DMA handles */ - kfree(di->rxp_dmah); - /* free our private info structure */ kfree(di); @@ -910,10 +863,6 @@ bool dma_rxfill(struct dma_pub *pub) */ *(u32 *) (p->data) = 0; - if (DMASGLIST_ENAB) - memset(&di->rxp_dmah[rxout], 0, - sizeof(struct dma_seg_map)); - pa = pci_map_single(di->pbus, p->data, di->rxbufsize, PCI_DMA_FROMDEVICE); @@ -1265,9 +1214,6 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) * allocating and initializing transmit descriptor entries. */ for (p = p0; p; p = next) { - uint nsegs, j; - struct dma_seg_map *map; - data = p->data; len = p->len; next = p->next; @@ -1280,53 +1226,25 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) continue; /* get physical address of buffer start */ - if (DMASGLIST_ENAB) - memset(&di->txp_dmah[txout], 0, - sizeof(struct dma_seg_map)); - pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); - if (DMASGLIST_ENAB) { - map = &di->txp_dmah[txout]; + flags = 0; + if (p == p0) + flags |= D64_CTRL1_SOF; - /* See if all the segments can be accounted for */ - if (map->nsegs > - (uint) (di->ntxd - NTXDACTIVE(di->txin, di->txout) - - 1)) - goto outoftxd; + /* With a DMA segment list, Descriptor table is filled + * using the segment list instead of looping over + * buffers in multi-chain DMA. Therefore, EOF for SGLIST + * is when end of segment list is reached. + */ + if (next == NULL) + flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF); + if (txout == (di->ntxd - 1)) + flags |= D64_CTRL1_EOT; - nsegs = map->nsegs; - } else - nsegs = 1; + dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - for (j = 1; j <= nsegs; j++) { - flags = 0; - if (p == p0 && j == 1) - flags |= D64_CTRL1_SOF; - - /* With a DMA segment list, Descriptor table is filled - * using the segment list instead of looping over - * buffers in multi-chain DMA. Therefore, EOF for SGLIST - * is when end of segment list is reached. - */ - if ((!DMASGLIST_ENAB && next == NULL) || - (DMASGLIST_ENAB && j == nsegs)) - flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF); - if (txout == (di->ntxd - 1)) - flags |= D64_CTRL1_EOT; - - if (DMASGLIST_ENAB) { - len = map->segs[j - 1].length; - pa = map->segs[j - 1].addr; - } - dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - - txout = NEXTTXD(txout); - } - - /* See above. No need to loop over individual buffers */ - if (DMASGLIST_ENAB) - break; + txout = NEXTTXD(txout); } /* if last txd eof not set, fix it */ @@ -1414,31 +1332,19 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) for (i = start; i != end && !txp; i = NEXTTXD(i)) { unsigned long pa; - struct dma_seg_map *map = NULL; - uint size, j, nsegs; + uint size; pa = cpu_to_le32(di->txd64[i].addrlow) - di->dataoffsetlow; - if (DMASGLIST_ENAB) { - map = &di->txp_dmah[i]; - size = map->origsize; - nsegs = map->nsegs; - } else { - size = - (cpu_to_le32(di->txd64[i].ctrl2) & - D64_CTRL2_BC_MASK); - nsegs = 1; - } + size = + (cpu_to_le32(di->txd64[i].ctrl2) & + D64_CTRL2_BC_MASK); - for (j = nsegs; j > 0; j--) { - di->txd64[i].addrlow = 0xdeadbeef; - di->txd64[i].addrhigh = 0xdeadbeef; + di->txd64[i].addrlow = 0xdeadbeef; + di->txd64[i].addrhigh = 0xdeadbeef; - txp = di->txp[i]; - di->txp[i] = NULL; - if (j > 1) - i = NEXTTXD(i); - } + txp = di->txp[i]; + di->txp[i] = NULL; pci_unmap_single(di->pbus, pa, size, PCI_DMA_TODEVICE); } From b5a44c8ad3378e88a5a14e1f74495c292a755527 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:35 +0200 Subject: [PATCH 0649/1519] staging: brcm80211: assigned physical addresses in dma.c correct type Code cleanup. Physical addresses in dma.c are all allocated by calls to pci_alloc_consistent(). Since that call returns physical addresses as type 'dma_addr_t', all physical addresses in dma.c were changed from 'unsigned long' to 'dma_addr_t'. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 35 ++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index e53088e7643..42446cda0a0 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -250,9 +250,9 @@ struct dma_info { /* pointer to parallel array of pointers to packets */ struct sk_buff **txp; /* Aligned physical address of descriptor ring */ - unsigned long txdpa; + dma_addr_t txdpa; /* Original physical address of descriptor ring */ - unsigned long txdpaorig; + dma_addr_t txdpaorig; u16 txdalign; /* #bytes added to alloc'd mem to align txd */ u32 txdalloc; /* #bytes allocated for the ring */ u32 xmtptrbase; /* When using unaligned descriptors, the ptr register @@ -266,9 +266,9 @@ struct dma_info { /* pointer to parallel array of pointers to packets */ struct sk_buff **rxp; /* Aligned physical address of descriptor ring */ - unsigned long rxdpa; + dma_addr_t rxdpa; /* Original physical address of descriptor ring */ - unsigned long rxdpaorig; + dma_addr_t rxdpaorig; u16 rxdalign; /* #bytes added to alloc'd mem to align rxd */ u32 rxdalloc; /* #bytes allocated for the ring */ u32 rcvptrbase; /* Base for ptr reg when using unaligned descriptors */ @@ -327,14 +327,14 @@ static bool _dma_isaddrext(struct dma_info *di); static bool _dma_descriptor_align(struct dma_info *di); static bool _dma_alloc(struct dma_info *di, uint direction); static void _dma_ddtable_init(struct dma_info *di, uint direction, - unsigned long pa); + dma_addr_t pa); static void _dma_rxenable(struct dma_info *di); static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall); static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - unsigned long *descpa); + dma_addr_t *descpa); /* Prototypes for 64-bit routines */ static bool dma64_alloc(struct dma_info *di, uint direction); @@ -521,7 +521,7 @@ static inline u32 parity32(u32 data) static inline void dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, - unsigned long pa, uint outidx, u32 *flags, u32 bufcount) + dma_addr_t pa, uint outidx, u32 *flags, u32 bufcount) { u32 ctrl2 = bufcount & D64_CTRL2_BC_MASK; @@ -557,20 +557,15 @@ static bool _dma_alloc(struct dma_info *di, uint direction) } void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, - uint *alloced, unsigned long *pap) + uint *alloced, dma_addr_t *pap) { - void *rc; - dma_addr_t dma_addr; - if (align_bits) { u16 align = (1 << align_bits); if (!IS_ALIGNED(PAGE_SIZE, align)) size += align; *alloced = size; } - rc = pci_alloc_consistent(pdev, size, &dma_addr); - *pap = dma_addr; - return rc; + return pci_alloc_consistent(pdev, size, pap); } /* !! may be called with core in reset */ @@ -644,7 +639,7 @@ static bool _dma_isaddrext(struct dma_info *di) /* initialize descriptor table base address */ static void -_dma_ddtable_init(struct dma_info *di, uint direction, unsigned long pa) +_dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) { if (!di->aligndesc_4k) { if (direction == DMA_TX) @@ -814,7 +809,7 @@ bool dma_rxfill(struct dma_pub *pub) u32 flags = 0; uint n; uint i; - unsigned long pa; + dma_addr_t pa; uint extra_offset = 0; bool ring_empty; @@ -977,7 +972,7 @@ u8 dma_align_sizetobits(uint size) */ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - unsigned long *descpa) + dma_addr_t *descpa) { void *va; u32 desc_strtaddr; @@ -1203,7 +1198,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) uint len; u16 txout; u32 flags = 0; - unsigned long pa; + dma_addr_t pa; DMA_TRACE(("%s: dma_txfast\n", di->name)); @@ -1331,7 +1326,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) goto bogus; for (i = start; i != end && !txp; i = NEXTTXD(i)) { - unsigned long pa; + dma_addr_t pa; uint size; pa = cpu_to_le32(di->txd64[i].addrlow) - di->dataoffsetlow; @@ -1366,7 +1361,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) { uint i, curr; struct sk_buff *rxp; - unsigned long pa; + dma_addr_t pa; i = di->rxin; From b6f29edecd95f2eb4715e9d1778688eb1a44c83c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:36 +0200 Subject: [PATCH 0650/1519] staging: brcm80211: bugfix for 32 bit power pc platform On some platforms resource_size_t == 64 but but unsigned long is only 32-bits. In this particular problem, reported and fixed by Tony Breeds, a physical address was truncated as a result. Reported-by: Tony Breeds Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 23701718613..9b787e6c088 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -752,12 +752,11 @@ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) * is called in brcms_pci_probe() context, therefore no locking required. */ static struct brcms_info *brcms_attach(u16 vendor, u16 device, - unsigned long regs, + resource_size_t regs, struct pci_dev *btparam, uint irq) { struct brcms_info *wl = NULL; int unit, err; - unsigned long base_addr; struct ieee80211_hw *hw; u8 perm[ETH_ALEN]; @@ -780,11 +779,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, /* setup the bottom half handler */ tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl); - - - base_addr = regs; - - wl->regsva = ioremap_nocache(base_addr, PCI_BAR0_WINSZ); + wl->regsva = ioremap_nocache(regs, PCI_BAR0_WINSZ); if (wl->regsva == NULL) { wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit); goto fail; From cc698552f3ba1f59f96672229a74e4647b82ed51 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:37 +0200 Subject: [PATCH 0651/1519] staging: brcm80211: removed NORADIO_ENAB() macro from softmac phy code Code cleanup. Preprocessor constant EXT_CBALL was never defined so removed related code. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 35 ----- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 6 - .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 57 +------ .../staging/brcm80211/brcmsmac/phy/phy_n.c | 142 +++++++----------- 4 files changed, 58 insertions(+), 182 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index cbb0bde439e..3d54a3942a6 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -220,9 +220,6 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) if ((addr == RADIO_IDCODE)) return 0xffff; - if (NORADIO_ENAB(pi->pubpi)) - return NORADIO_IDCODE & 0xffff; - switch (pi->pubpi.phy_type) { case PHY_TYPE_N: CASECHECK(PHYTYPE, PHY_TYPE_N); @@ -265,9 +262,6 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) { - if (NORADIO_ENAB(pi->pubpi)) - return; - if ((D11REV_GE(pi->sh->corerev, 24)) || (D11REV_IS(pi->sh->corerev, 22) && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { @@ -289,9 +283,6 @@ static u32 read_radio_id(struct brcms_phy *pi) { u32 id; - if (NORADIO_ENAB(pi->pubpi)) - return NORADIO_IDCODE; - if (D11REV_GE(pi->sh->corerev, 24)) { u32 b0, b1, b2; @@ -317,9 +308,6 @@ void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) { u16 rval; - if (NORADIO_ENAB(pi->pubpi)) - return; - rval = read_radio_reg(pi, addr); write_radio_reg(pi, addr, (rval & val)); } @@ -328,9 +316,6 @@ void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) { u16 rval; - if (NORADIO_ENAB(pi->pubpi)) - return; - rval = read_radio_reg(pi, addr); write_radio_reg(pi, addr, (rval | val)); } @@ -339,9 +324,6 @@ void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask) { u16 rval; - if (NORADIO_ENAB(pi->pubpi)) - return; - rval = read_radio_reg(pi, addr); write_radio_reg(pi, addr, (rval ^ mask)); } @@ -350,9 +332,6 @@ void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) { u16 rval; - if (NORADIO_ENAB(pi->pubpi)) - return; - rval = read_radio_reg(pi, addr); write_radio_reg(pi, addr, (rval & ~mask) | (val & mask)); } @@ -1225,9 +1204,6 @@ void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on) { struct brcms_phy *pi = (struct brcms_phy *) pih; - if (NORADIO_ENAB(pi->pubpi)) - return; - { uint mc; @@ -2308,9 +2284,6 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) bool sampling_in_progress = (pi->phynoise_state != 0); bool wait_for_intr = true; - if (NORADIO_ENAB(pi->pubpi)) - return; - switch (reason) { case PHY_NOISE_SAMPLE_MON: pi->phynoise_chan_watchdog = ch; @@ -2618,11 +2591,6 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, uint radioid = pih->radioid; struct brcms_phy *pi = (struct brcms_phy *) pih; - if (NORADIO_ENAB(pi->pubpi)) { - rssi = BRCMS_RSSI_INVALID; - goto end; - } - if ((pi->sh->corerev >= 11) && !(le16_to_cpu(rxh->RxStatus2) & RXS_PHYRXST_VALID)) { rssi = BRCMS_RSSI_INVALID; @@ -2704,9 +2672,6 @@ void wlc_phy_watchdog(struct brcms_phy_pub *pih) pi->phycal_txpower = pi->sh->now; } - if (NORADIO_ENAB(pi->pubpi)) - return; - if ((SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) || ASSOC_INPROG_PHY(pi))) return; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 0594a088e72..7ec2ad253e8 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -297,12 +297,6 @@ enum phy_cal_mode { #define PUB_NOT_ASSOC(pi) \ (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC)) -#if defined(EXT_CBALL) -#define NORADIO_ENAB(pub) ((pub).radioid == NORADIO_ID) -#else -#define NORADIO_ENAB(pub) 0 -#endif - #define PHY_LTRN_LIST_LEN 64 extern u16 ltrn_list[PHY_LTRN_LIST_LEN]; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 269346e18a1..47f96a9c89b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -1218,10 +1218,8 @@ void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) or_phy_reg(pi, 0x44a, 0x44); write_phy_reg(pi, 0x44a, 0x80); - if (!NORADIO_ENAB(pi->pubpi)) { - wlc_lcnphy_radio_2064_channel_tune_4313(pi, channel); - udelay(1000); - } + wlc_lcnphy_radio_2064_channel_tune_4313(pi, channel); + udelay(1000); wlc_lcnphy_toggle_afe_pwdn(pi); @@ -1704,9 +1702,6 @@ static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) index = FIXED_TXPWR; - if (NORADIO_ENAB(pi->pubpi)) - return index; - if (pi_lcn->lcnphy_tempsense_slope == 0) return index; @@ -1875,9 +1870,6 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, u16 *values_to_save; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (NORADIO_ENAB(pi->pubpi)) - return; - values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); if (NULL == values_to_save) return; @@ -2291,13 +2283,6 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi) if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); - if (NORADIO_ENAB(pi->pubpi)) { - wlc_lcnphy_set_bbmult(pi, 0x30); - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - return; - } - if (!pi->hwpwrctrl_capable) { if (CHSPEC_IS2G(pi->radio_chanspec)) { tx_gains.gm_gain = 4; @@ -2965,9 +2950,6 @@ s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode) s16 avg = 0; bool suspend = 0; - if (NORADIO_ENAB(pi->pubpi)) - return -1; - if (mode == 1) { suspend = (0 == @@ -3012,9 +2994,6 @@ u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode) u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (NORADIO_ENAB(pi->pubpi)) - return -1; - if (mode == 1) { suspend = (0 == @@ -3081,9 +3060,6 @@ s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode) s32 avg = 0; bool suspend = 0; - if (NORADIO_ENAB(pi->pubpi)) - return -1; - if (mode == 1) { suspend = (0 == @@ -3420,8 +3396,6 @@ cal_done: static void wlc_lcnphy_temp_adj(struct brcms_phy *pi) { - if (NORADIO_ENAB(pi->pubpi)) - return; } static void wlc_lcnphy_glacial_timer_based_cal(struct brcms_phy *pi) @@ -3461,9 +3435,6 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) s32 tssi, pwr, maxtargetpwr, mintargetpwr; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (NORADIO_ENAB(pi->pubpi)) - return; - pi->phy_lastcal = pi->sh->now; pi->phy_forcecal = false; full_cal = @@ -3594,9 +3565,6 @@ wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) u8 channel = CHSPEC_CHANNEL(chanspec); struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (NORADIO_ENAB(pi->pubpi)) - return; - if (channel == 14) mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); else @@ -4444,9 +4412,6 @@ static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi) u32 tableBuffer[2]; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (NORADIO_ENAB(pi->pubpi)) - return; - temp = (s16) read_phy_reg(pi, 0x4df); pi_lcn->lcnphy_ofdmgainidxtableoffset = (temp & (0xff << 0)) >> 0; @@ -4497,9 +4462,6 @@ static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi) static void wlc_lcnphy_bu_tweaks(struct brcms_phy *pi) { - if (NORADIO_ENAB(pi->pubpi)) - return; - or_phy_reg(pi, 0x805, 0x1); mod_phy_reg(pi, 0x42f, (0x7 << 0), (0x3) << 0); @@ -4623,9 +4585,6 @@ static void wlc_radio_2064_init(struct brcms_phy *pi) static void wlc_lcnphy_radio_init(struct brcms_phy *pi) { - if (NORADIO_ENAB(pi->pubpi)) - return; - wlc_radio_2064_init(pi); } @@ -4633,9 +4592,6 @@ static void wlc_lcnphy_rcal(struct brcms_phy *pi) { u8 rcal_value; - if (NORADIO_ENAB(pi->pubpi)) - return; - and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); or_radio_reg(pi, RADIO_2064_REG004, 0x40); @@ -4665,9 +4621,6 @@ static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) u8 dflt_rc_cal_val; u16 flt_val; - if (NORADIO_ENAB(pi->pubpi)) - return; - dflt_rc_cal_val = 7; if (LCNREV_IS(pi->pubpi.phy_rev, 1)) dflt_rc_cal_val = 11; @@ -4830,8 +4783,7 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) u8 d15, d16, f16, e44, e45; u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; u16 loop_bw, d30, setCount; - if (NORADIO_ENAB(pi->pubpi)) - return; + ci = &chan_info_2064_lcnphy[0]; rfpll_doubler = 1; @@ -5021,8 +4973,7 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) pi_lcn = pi->u.pi_lcnphy; - if ((0 == (pi->sh->boardflags & BFL_NOPA)) && - !NORADIO_ENAB(pi->pubpi)) { + if (0 == (pi->sh->boardflags & BFL_NOPA)) { pi->hwpwrctrl = true; pi->hwpwrctrl_capable = true; } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 2d90f098b07..c5b7ad40454 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14256,17 +14256,7 @@ static void wlc_phy_bphy_init_nphy(struct brcms_phy *pi) val -= 0x0202; } - if (NORADIO_ENAB(pi->pubpi)) { - - write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_PHYCRSTH, 0x3206); - - write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_RSSI_TRESH, 0x281e); - - or_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_LNA_GAIN_RANGE, 0x1a); - - } else { - write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_STEP, 0x668); - } + write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_STEP, 0x668); } void @@ -14595,6 +14585,7 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) uint origidx, intr_val; struct d11regs *regs; u32 d11_clk_ctl_st; + bool do_rssi_cal = false; core = 0; @@ -14858,73 +14849,69 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if (PHY_PERICAL_MPHASE_PENDING(pi)) wlc_phy_cal_perical_mphase_restart(pi); - if (!NORADIO_ENAB(pi->pubpi)) { - bool do_rssi_cal = false; + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? + (pi->nphy_rssical_chanspec_2G == 0) : + (pi->nphy_rssical_chanspec_5G == 0); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_rssical_chanspec_2G == 0) : - (pi->nphy_rssical_chanspec_5G == 0); - - if (do_rssi_cal) - wlc_phy_rssi_cal_nphy(pi); - else - wlc_phy_restore_rssical_nphy(pi); - } else { + if (do_rssi_cal) wlc_phy_rssi_cal_nphy(pi); - } + else + wlc_phy_restore_rssical_nphy(pi); + } else { + wlc_phy_rssi_cal_nphy(pi); + } - if (!SCAN_RM_IN_PROGRESS(pi)) - do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_iqcal_chanspec_2G == 0) : - (pi->nphy_iqcal_chanspec_5G == 0); + if (!SCAN_RM_IN_PROGRESS(pi)) + do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? + (pi->nphy_iqcal_chanspec_2G == 0) : + (pi->nphy_iqcal_chanspec_5G == 0); - if (!pi->do_initcal) - do_nphy_cal = false; + if (!pi->do_initcal) + do_nphy_cal = false; - if (do_nphy_cal) { + if (do_nphy_cal) { - target_gain = wlc_phy_get_tx_gain_nphy(pi); + target_gain = wlc_phy_get_tx_gain_nphy(pi); - if (pi->antsel_type == ANTSEL_2x3) - wlc_phy_antsel_init((struct brcms_phy_pub *) pi, - true); + if (pi->antsel_type == ANTSEL_2x3) + wlc_phy_antsel_init((struct brcms_phy_pub *) pi, + true); - if (pi->nphy_perical != PHY_PERICAL_MPHASE) { - wlc_phy_rssi_cal_nphy(pi); + if (pi->nphy_perical != PHY_PERICAL_MPHASE) { + wlc_phy_rssi_cal_nphy(pi); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->nphy_cal_orig_pwr_idx[0] = - pi->nphy_txpwrindex[PHY_CORE_0] - . - index_internal; - pi->nphy_cal_orig_pwr_idx[1] = - pi->nphy_txpwrindex[PHY_CORE_1] - . - index_internal; + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + pi->nphy_cal_orig_pwr_idx[0] = + pi->nphy_txpwrindex[PHY_CORE_0] + . + index_internal; + pi->nphy_cal_orig_pwr_idx[1] = + pi->nphy_txpwrindex[PHY_CORE_1] + . + index_internal; - wlc_phy_precal_txgain_nphy(pi); - target_gain = - wlc_phy_get_tx_gain_nphy(pi); - } - - if (wlc_phy_cal_txiqlo_nphy - (pi, target_gain, true, - false) == 0) { - if (wlc_phy_cal_rxiq_nphy - (pi, target_gain, 2, - false) == 0) - wlc_phy_savecal_nphy(pi); - - } - } else if (pi->mphase_cal_phase_id == - MPHASE_CAL_STATE_IDLE) { - wlc_phy_cal_perical((struct brcms_phy_pub *) pi, - PHY_PERICAL_PHYINIT); + wlc_phy_precal_txgain_nphy(pi); + target_gain = + wlc_phy_get_tx_gain_nphy(pi); } - } else { - wlc_phy_restorecal_nphy(pi); + + if (wlc_phy_cal_txiqlo_nphy + (pi, target_gain, true, + false) == 0) { + if (wlc_phy_cal_rxiq_nphy + (pi, target_gain, 2, + false) == 0) + wlc_phy_savecal_nphy(pi); + + } + } else if (pi->mphase_cal_phase_id == + MPHASE_CAL_STATE_IDLE) { + wlc_phy_cal_perical((struct brcms_phy_pub *) pi, + PHY_PERICAL_PHYINIT); } + } else { + wlc_phy_restorecal_nphy(pi); } wlc_phy_txpwrctrl_coeff_setup_nphy(pi); @@ -15595,8 +15582,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_REV7_RFCTRLOVERRIDE_ID2); } - if (!NORADIO_ENAB(pi->pubpi)) - write_phy_reg(pi, 0x32f, 0x3); + write_phy_reg(pi, 0x32f, 0x3); if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) wlc_phy_rfctrl_override_nphy_rev7( @@ -17662,9 +17648,6 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, break; default: - if (NORADIO_ENAB(pi->pubpi)) - goto fail; - break; } } else if (NREV_IS(pi->pubpi.phy_rev, 16)) { @@ -17732,9 +17715,6 @@ wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, chan_info_nphyrev6_2056v11); break; default: - if (NORADIO_ENAB(pi->pubpi)) - goto fail; - break; } } @@ -17778,9 +17758,6 @@ u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint channel) struct chan_info_nphy_radio2057_rev5 *t2 = NULL; struct chan_info_nphy_2055 *t3 = NULL; - if (NORADIO_ENAB(pi->pubpi)) - return WL_CHAN_FREQ_RANGE_2G; - if (channel == 0) channel = CHSPEC_CHANNEL(pi->radio_chanspec); @@ -19053,9 +19030,6 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) struct chan_info_nphy_radio2057_rev5 *t2 = NULL; struct chan_info_nphy_2055 *t3 = NULL; - if (NORADIO_ENAB(pi->pubpi)) - return; - if (!wlc_phy_chan2freq_nphy (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) return; @@ -23669,11 +23643,6 @@ void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) bool restore_tx_gain = false; bool mphase; - if (NORADIO_ENAB(pi->pubpi)) { - wlc_phy_cal_perical_mphase_reset(pi); - return; - } - if (PHY_MUTED(pi)) return; @@ -27023,9 +26992,6 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) pi->nphy_papd_last_cal = pi->sh->now; pi->nphy_papd_recal_counter++; - if (NORADIO_ENAB(pi->pubpi)) - return; - phy_b4 = pi->nphy_txpwrctrl; wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); From 38a02acde38eabee56c273ce0973af2d8139932a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:38 +0200 Subject: [PATCH 0652/1519] staging: brcm80211: removed unused phy logging Macro's were not used so they were removed. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 4 ---- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 -- drivers/staging/brcm80211/brcmsmac/phy/phy_int.h | 16 ---------------- 3 files changed, 22 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 9b787e6c088..01829db4fe8 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -105,8 +105,6 @@ MODULE_DEVICE_TABLE(pci, brcms_pci_id_table); #ifdef BCMDBG static int msglevel = 0xdeadbeef; module_param(msglevel, int, 0); -static int phymsglevel = 0xdeadbeef; -module_param(phymsglevel, int, 0); #endif /* BCMDBG */ #define HW_TO_WL(hw) (hw->priv) @@ -1282,8 +1280,6 @@ static int __init brcms_module_init(void) #ifdef BCMDBG if (msglevel != 0xdeadbeef) brcm_msg_level = msglevel; - if (phymsglevel != 0xdeadbeef) - phyhal_msg_level = phymsglevel; #endif /* BCMDBG */ error = pci_register_driver(&brcms_pci_driver); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 3d54a3942a6..bd602de84d1 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -27,8 +27,6 @@ #include "phy_lcn.h" #include "phyreg_n.h" -u32 phyhal_msg_level = PHYHAL_ERROR; - struct chan_info_basic { u16 chan; u16 freq; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 7ec2ad253e8..a06e7190bcd 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -23,22 +23,6 @@ #define PHY_VERSION { 1, 82, 8, 0 } -#define PHYHAL_ERROR 0x0001 -#define PHYHAL_TRACE 0x0002 -#define PHYHAL_INFORM 0x0004 - -extern u32 phyhal_msg_level; - -#define PHY_INFORM_ON() (phyhal_msg_level & PHYHAL_INFORM) -#define PHY_THERMAL_ON() (phyhal_msg_level & PHYHAL_THERMAL) -#define PHY_CAL_ON() (phyhal_msg_level & PHYHAL_CAL) - -#ifdef BOARD_TYPE -#define BOARDTYPE(_type) BOARD_TYPE -#else -#define BOARDTYPE(_type) _type -#endif - #define LCNXN_BASEREV 16 struct phy_shim_info; From b61c23c846978a4381fdc499055bd66b7bd24120 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:39 +0200 Subject: [PATCH 0653/1519] staging: brcm80211: removed unused #ifdef sections Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 4 --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 16 --------- .../staging/brcm80211/brcmfmac/dhd_proto.h | 5 --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 22 ------------ .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 6 ---- drivers/staging/brcm80211/brcmsmac/aiutils.c | 1 + drivers/staging/brcm80211/brcmsmac/aiutils.h | 17 --------- drivers/staging/brcm80211/brcmsmac/channel.c | 12 ------- drivers/staging/brcm80211/brcmsmac/d11.h | 4 --- .../staging/brcm80211/brcmsmac/mac80211_if.h | 3 -- drivers/staging/brcm80211/brcmsmac/main.c | 35 ++----------------- drivers/staging/brcm80211/brcmsmac/pub.h | 14 -------- drivers/staging/brcm80211/brcmsmac/types.h | 8 ----- .../staging/brcm80211/include/brcmu_utils.h | 6 ---- drivers/staging/brcm80211/include/defs.h | 6 ---- drivers/staging/brcm80211/include/soc.h | 4 --- 16 files changed, 4 insertions(+), 159 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 0b92cef5bb6..a15765b6d88 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -34,15 +34,11 @@ #include "dhd_dbg.h" #include "wl_cfg80211.h" -#if !defined(SDIO_VENDOR_ID_BROADCOM) #define SDIO_VENDOR_ID_BROADCOM 0x02d0 -#endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */ #define DMA_ALIGN_MASK 0x03 -#if !defined(SDIO_DEVICE_ID_BROADCOM_4329) #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 -#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr); static int brcmf_ops_sdio_probe(struct sdio_func *func, diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 2c633fa54c4..46f75b7f7be 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -120,18 +120,6 @@ uint brcmf_radio_up = 1; char iface_name[IFNAMSIZ] = "wlan"; module_param_string(iface_name, iface_name, IFNAMSIZ, 0); -/* The following are specific to the SDIO dongle */ - -#ifdef SDTEST -/* Echo packet generator (pkts/s) */ -uint brcmf_pktgen; -module_param(brcmf_pktgen, uint, 0); - -/* Echo packet len (0 => sawtooth, max 2040) */ -uint brcmf_pktgen_len; -module_param(brcmf_pktgen_len, uint, 0); -#endif - static int brcmf_toe_get(struct brcmf_info *drvr_priv, int idx, u32 *toe_ol); static int brcmf_toe_set(struct brcmf_info *drvr_priv, int idx, u32 toe_ol); static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, @@ -1065,7 +1053,6 @@ done: static int brcmf_netdev_stop(struct net_device *net) { -#if !defined(IGNORE_ETH0_DOWN) struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); brcmf_dbg(TRACE, "Enter\n"); @@ -1076,9 +1063,6 @@ static int brcmf_netdev_stop(struct net_device *net) /* Set state and stop OS transmissions */ drvr_priv->pub.up = 0; netif_stop_queue(net); -#else - brcmf_dbg(ERROR, "BYPASSed due to BRCM compilation: under investigation\n"); -#endif /* !defined(IGNORE_ETH0_DOWN) */ return 0; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h index ff788b37afd..2ce5feabbef 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h @@ -17,13 +17,8 @@ #ifndef _BRCMF_PROTO_H_ #define _BRCMF_PROTO_H_ -#ifndef IOCTL_RESP_TIMEOUT #define IOCTL_RESP_TIMEOUT 2000 /* In milli second */ -#endif - -#ifndef IOCTL_CHIP_ACTIVE_TIMEOUT #define IOCTL_CHIP_ACTIVE_TIMEOUT 10 /* In milli second */ -#endif /* * Exported from the brcmf protocol module (brcmf_cdc) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 9b41891b191..c1647ebafb5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -368,10 +368,8 @@ struct rte_console { * for HT availability, it could take a couple hundred ms more, so * max out at a 1 second (1000000us). */ -#if (PMU_MAX_TRANSITION_DLY <= 1000000) #undef PMU_MAX_TRANSITION_DLY #define PMU_MAX_TRANSITION_DLY 1000000 -#endif /* Value for ChipClockCSR during initial setup */ #define BRCMF_INIT_CLKCTL1 (SBSDIO_FORCE_HW_CLKREQ_OFF | \ @@ -3145,19 +3143,6 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); -#if defined(OOB_INTR_ONLY) - /* Host registration for OOB interrupt */ - if (brcmf_sdio_register_oob_intr(bus->dhd)) { - brcmf_sdbrcm_wd_timer(bus, 0); - brcmf_dbg(ERROR, "Host failed to resgister for OOB\n"); - ret = -ENODEV; - goto exit; - } - - /* Enable oob at firmware */ - brcmf_sdbrcm_enable_oob_intr(bus, true); -#endif /* defined(OOB_INTR_ONLY) */ - /* If we didn't come up, turn off backplane clock */ if (drvr->busstate != BRCMF_BUS_DATA) brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); @@ -4533,15 +4518,8 @@ void brcmf_sdbrcm_isr(void *arg) if (!bus->intr) brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); -#if defined(SDIO_ISR_THREAD) - brcmf_dbg(TRACE, "Calling brcmf_sdbrcm_dpc()\n"); - while (brcmf_sdbrcm_dpc(bus)) - ; -#else bus->dpc_sched = true; brcmf_sdbrcm_sched_dpc(bus); -#endif - } extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 4f7b0816af7..9010ce73b31 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2337,14 +2337,10 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; wdev->wiphy->cipher_suites = __wl_cipher_suites; wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites); -#ifndef WL_POWERSAVE_DISABLED wdev->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; /* enable power * save mode * by default */ -#else - wdev->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; -#endif /* !WL_POWERSAVE_DISABLED */ err = wiphy_register(wdev->wiphy); if (unlikely(err < 0)) { WL_ERR("Couldn not register wiphy device (%d)\n", err); @@ -3409,9 +3405,7 @@ static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) s32 err = 0; cfg_priv->scan_request = NULL; -#ifndef WL_POWERSAVE_DISABLED cfg_priv->pwr_save = true; -#endif /* WL_POWERSAVE_DISABLED */ cfg_priv->iscan_on = true; /* iscan on & off switch. we enable iscan per default */ cfg_priv->roam_on = true; /* roam on & off switch. diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index c9c41a5327b..62186b7db69 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "types.h" #include "pub.h" #include "pmu.h" diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 375c06f7c02..5dee80ffd83 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -33,12 +33,6 @@ /* Region 2 for sdram (512 MB) */ #define SI_SDRAM_R2 0x80000000 -#ifdef SI_ENUM_BASE_VARIABLE -#define SI_ENUM_BASE (sii->pub.si_enum_base) -#else -#define SI_ENUM_BASE 0x18000000 /* Enumeration space base */ -#endif /* SI_ENUM_BASE_VARIABLE */ - /* Wrapper space base */ #define SI_WRAP_BASE 0x18100000 /* each core gets 4Kbytes for registers */ @@ -337,10 +331,8 @@ #define DEFAULT_GPIO_ONTIME 10 /* Default: 10% on */ #define DEFAULT_GPIO_OFFTIME 90 /* Default: 10% on */ -#ifndef DEFAULT_GPIOTIMERVAL #define DEFAULT_GPIOTIMERVAL \ ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME) -#endif /* * Data structure to export all chip specific common variables @@ -412,20 +404,11 @@ struct si_pub { #define SI_PCIUP 3 /* PMU clock/power control */ -#if defined(BCMPMUCTL) -#define PMUCTL_ENAB(sih) (BCMPMUCTL) -#else #define PMUCTL_ENAB(sih) ((sih)->cccaps & CC_CAP_PMU) -#endif /* chipcommon clock/power control (exclusive with PMU's) */ -#if defined(BCMPMUCTL) && BCMPMUCTL -#define CCCTL_ENAB(sih) (0) -#define CCPLL_ENAB(sih) (0) -#else #define CCCTL_ENAB(sih) ((sih)->cccaps & CC_CAP_PWR_CTL) #define CCPLL_ENAB(sih) ((sih)->cccaps & CC_CAP_PLL_MASK) -#endif /* External PA enable mask */ #define GPIO_CTRL_EPA_EN_MASK 0x40 diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 1aad680c7f6..89d8fa7330b 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -107,9 +107,6 @@ static const struct locale_mimo_info *brcms_c_get_mimo_2g(u8 locale_idx); static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx); /* QDB() macro takes a dB value and converts to a quarter dB value */ -#ifdef QDB -#undef QDB -#endif #define QDB(n) ((n) * BRCMS_TXPWR_DB_FACTOR) /* Regulatory Matrix Spreadsheet (CLM) MIMO v3.7.9 */ @@ -489,19 +486,10 @@ static const struct locale_mimo_info *g_mimo_5g_table[] = { &locale_11n }; -#ifdef LC -#undef LC -#endif #define LC(id) LOCALE_MIMO_IDX_ ## id -#ifdef LC_2G -#undef LC_2G -#endif #define LC_2G(id) LOCALE_2G_IDX_ ## id -#ifdef LC_5G -#undef LC_5G -#endif #define LC_5G(id) LOCALE_5G_IDX_ ## id #define LOCALES(band2, band5, mimo2, mimo5) \ diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index 96f487aed9b..f0c3f5a75a2 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -47,11 +47,7 @@ #define TX_DATA_FIFO TX_AC_BE_FIFO #define TX_CTL_FIFO TX_AC_VO_FIFO -#ifndef WL_RSSI_ANT_MAX #define WL_RSSI_ANT_MAX 4 /* max possible rx antennas */ -#elif WL_RSSI_ANT_MAX != 4 -#error "WL_RSSI_ANT_MAX does not match" -#endif struct intctrlregs { u32 intstatus; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 7f290d7c0c4..1d528036019 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -75,9 +75,6 @@ struct brcms_info { struct tasklet_struct tasklet; /* dpc tasklet */ bool resched; /* dpc needs to be and is rescheduled */ -#ifdef LINUXSTA_PS - u32 pci_psstate[16]; /* pci ps-state save/restore */ -#endif struct brcms_firmware fw; struct wiphy *wiphy; }; diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 339ab28477a..3aa03090b01 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3540,11 +3540,6 @@ void brcms_c_set_bssid(struct brcms_bss_cfg *cfg) /* if primary config, we need to update BSSID in RXE match registers */ if (cfg == wlc->cfg) brcms_c_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID); -#ifdef SUPPORT_HWKEYS - else if (BSSCFG_STA(cfg) && cfg->BSS) - brcms_c_rcmta_add_bssid(wlc, cfg); - -#endif } void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) @@ -3774,7 +3769,7 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, break; } } -#if NCONF + /* * pick siso/cdd as default for OFDM (note no basic * rate MCSs are supported yet) @@ -3782,8 +3777,6 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, if (IS_OFDM(lowest_basic_rspec)) lowest_basic_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); -#endif - return lowest_basic_rspec; } @@ -4236,12 +4229,6 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) /* WME QoS mode is Auto by default */ wlc->pub->_wme = AUTO; - -#ifdef BCMSDIODEV_ENABLED - /* enable priority flow control for sdio dongle */ - wlc->pub->_priofc = true; -#endif - wlc->pub->_ampdu = AMPDU_AGG_HOST; wlc->pub->bcmerror = 0; wlc->pub->_coex = ON; @@ -7457,16 +7444,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, else rspec[k] |= (mimo_ctlchbw << RSPEC_BW_SHIFT); - /* Set Short GI */ -#ifdef NOSGIYET - if (IS_MCS(rspec[k]) - && (txrate[k]->flags & IEEE80211_TX_RC_SHORT_GI)) - rspec[k] |= RSPEC_SHORT_GI; - else if (!(txrate[k]->flags & IEEE80211_TX_RC_SHORT_GI)) - rspec[k] &= ~RSPEC_SHORT_GI; -#else + /* Disable short GI, not supported yet */ rspec[k] &= ~RSPEC_SHORT_GI; -#endif mimo_preamble_type = BRCMS_MM_PREAMBLE; if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) @@ -9582,15 +9561,7 @@ static void brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, struct brcms_txq_info *qi, bool on, int prio) { -#ifdef NON_FUNCTIONAL - /* wlcif_list is never filled so this function is not functional */ - struct brcms_c_if *wlcif; - - for (wlcif = wlc->wlcif_list; wlcif != NULL; wlcif = wlcif->next) { - if (wlcif->qi == qi && wlcif->flags & BRCMS_IF_LINKED) - brcms_txflowcontrol(wlc->wl, wlcif->wlif, on, prio); - } -#endif + /* wlcif_list is never filled so this function is not functional yet */ } static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index c2ab1a3e288..f4e47e8487c 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -113,10 +113,8 @@ #define ANTSWITCH_TYPE_3 3 #define RXBUFSZ PKTBUFSZ -#ifndef AIDMAPSZ /* aid bitmap size in bytes */ #define AIDMAPSZ (roundup(MAXSCB, NBBY)/NBBY) -#endif /* AIDMAPSZ */ #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ @@ -353,22 +351,10 @@ enum wlc_par_id { #define SUPPORT_11N (ENAB_1x1|ENAB_2x2) #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) /* WL11N Support */ -#if ((defined(NCONF) && (NCONF != 0)) || \ - (defined(LCNCONF) && (LCNCONF != 0)) || \ - (defined(HTCONF) && (HTCONF != 0)) || \ - (defined(SSLPNCONF) && (SSLPNCONF != 0))) #define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N) #define N_REQD(pub) ((pub)->_n_reqd) -#else -#define N_ENAB(pub) 0 -#define N_REQD(pub) 0 -#endif -#if (defined(HTCONF) && (HTCONF != 0)) -#define HT_ENAB(pub) (((pub)->_n_enab & SUPPORT_HT) == SUPPORT_HT) -#else #define HT_ENAB(pub) 0 -#endif #define AMPDU_AGG_HOST 1 #define AMPDU_ENAB(pub) ((pub)->_ampdu) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index d44db5674b3..6d17d7fa9b7 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -20,14 +20,6 @@ #include #include -#if 0 -/* Bus types */ -#define SDIO_BUS 3 /* SDIO target */ -#define USB_BUS 5 /* USB (does not support R/W REG) */ -#define SPI_BUS 6 /* gSPI target */ -#define RPC_BUS 7 /* RPC target */ -#endif - #define WL_CHAN_FREQ_RANGE_2G 0 #define WL_CHAN_FREQ_RANGE_5GL 1 #define WL_CHAN_FREQ_RANGE_5GM 2 diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index ff8f3634d28..de627c211f6 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -45,12 +45,8 @@ struct brcmu_strbuf { } /* osl multi-precedence packet queue */ -#ifndef PKTQ_LEN_DEFAULT #define PKTQ_LEN_DEFAULT 128 /* Max 128 packets */ -#endif -#ifndef PKTQ_MAX_PREC #define PKTQ_MAX_PREC 16 /* Maximum precedence levels */ -#endif struct pktq_prec { struct sk_buff *head; /* first packet to dequeue */ @@ -192,9 +188,7 @@ extern int brcmu_iovar_lencheck(const struct brcmu_iovar *table, void *arg, #define BCME_STRLEN 64 /* Max string length for BCM errors */ -#ifndef ABS #define ABS(a) (((a) < 0) ? -(a) : (a)) -#endif /* ABS */ #define CEIL(x, y) (((x) + ((y)-1)) / (y)) #define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h index 8e0c559398c..c745b7e5922 100644 --- a/drivers/staging/brcm80211/include/defs.h +++ b/drivers/staging/brcm80211/include/defs.h @@ -27,14 +27,8 @@ #define USB_BUS 5 #define SPI_BUS 6 -#ifndef OFF #define OFF 0 -#endif - -#ifndef ON #define ON 1 /* ON = 1 */ -#endif - #define AUTO (-1) /* Auto = -1 */ /* diff --git a/drivers/staging/brcm80211/include/soc.h b/drivers/staging/brcm80211/include/soc.h index f23edc5d307..4fcb956ad9e 100644 --- a/drivers/staging/brcm80211/include/soc.h +++ b/drivers/staging/brcm80211/include/soc.h @@ -17,11 +17,7 @@ #ifndef _BRCM_SOC_H #define _BRCM_SOC_H -#ifdef SI_ENUM_BASE_VARIABLE -#define SI_ENUM_BASE (sii->pub.si_enum_base) -#else #define SI_ENUM_BASE 0x18000000 /* Enumeration space base */ -#endif /* SI_ENUM_BASE_VARIABLE */ /* core codes */ #define NODEV_CORE_ID 0x700 /* Invalid coreid */ From 5fa2674ae76947618aa1008706d46073ad3fc810 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 26 Aug 2011 15:19:40 +0200 Subject: [PATCH 0654/1519] staging: brcm80211: got rid of static function declarations in softmac phy Code cleanup. Reshuffled functions so that the declarations were not necessary anymore. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 402 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 2870 ++-- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 12210 ++++++++-------- 3 files changed, 7639 insertions(+), 7843 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index bd602de84d1..3955d6eb83c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -119,32 +119,6 @@ const u8 ofdm_rate_lookup[] = { #define PHY_WREG_LIMIT 24 -static void wlc_set_phy_uninitted(struct brcms_phy *pi); -static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi); -static void wlc_phy_timercb_phycal(struct brcms_phy *pi); - -static bool wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, - s8 *pwr_ant); - -static void wlc_phy_cal_perical_mphase_schedule(struct brcms_phy *pi, - uint delay); - -static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm); -static void wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, - u8 ch); - -static void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, - struct txpwr_limits *tp, - u16 chanspec); - -static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi); - -static s8 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, - u32 band, u8 rate); -static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band); -static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi); -static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi); - char *phy_getvar(struct brcms_phy *pi, const char *name) { char *vars = pi->vars; @@ -480,6 +454,37 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) return sh; } +static void wlc_phy_timercb_phycal(struct brcms_phy *pi) +{ + uint delay = 5; + + if (PHY_PERICAL_MPHASE_PENDING(pi)) { + if (!pi->sh->up) { + wlc_phy_cal_perical_mphase_reset(pi); + return; + } + + if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)) { + + delay = 1000; + wlc_phy_cal_perical_mphase_restart(pi); + } else + wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); + wlapi_add_timer(pi->sh->physhim, pi->phycal_timer, delay, 0); + return; + } + +} + +static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) +{ + u32 ver; + + ver = read_radio_id(pi); + + return ver; +} + struct brcms_phy_pub * wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, char *vars, struct wiphy *wiphy) @@ -692,28 +697,6 @@ u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih) return pi->pubpi.coreflags; } -static void wlc_phy_timercb_phycal(struct brcms_phy *pi) -{ - uint delay = 5; - - if (PHY_PERICAL_MPHASE_PENDING(pi)) { - if (!pi->sh->up) { - wlc_phy_cal_perical_mphase_reset(pi); - return; - } - - if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)) { - - delay = 1000; - wlc_phy_cal_perical_mphase_restart(pi); - } else - wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); - wlapi_add_timer(pi->sh->physhim, pi->phycal_timer, delay, 0); - return; - } - -} - void wlc_phy_anacore(struct brcms_phy_pub *pih, bool on) { struct brcms_phy *pi = (struct brcms_phy *) pih; @@ -909,15 +892,6 @@ int wlc_phy_down(struct brcms_phy_pub *pih) return callbacks; } -static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) -{ - u32 ver; - - ver = read_radio_id(pi); - - return ver; -} - void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset, u16 tblAddr, u16 tblDataHi, u16 tblDataLo) @@ -1594,6 +1568,46 @@ u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi) return pi->tx_power_max; } +static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi) +{ + if (ISLCNPHY(pi)) + return wlc_lcnphy_vbatsense(pi, 0); + else + return 0; +} + +static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi) +{ + if (ISLCNPHY(pi)) + return wlc_lcnphy_tempsense_degree(pi, 0); + else + return 0; +} + +static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band) +{ + u8 i; + s8 temp, vbat; + + for (i = 0; i < TXP_NUM_RATES; i++) + pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; + + vbat = wlc_phy_env_measure_vbat(pi); + temp = wlc_phy_env_measure_temperature(pi); + +} + +static s8 +wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, u32 band, + u8 rate) +{ + s8 offset = 0; + + if (!pi->user_txpwr_at_rfport) + return offset; + return offset; +} + void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) { u8 maxtxpwr, mintxpwr, rate, pactrl; @@ -2274,6 +2288,123 @@ wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant) return true; } +static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) +{ + if (!pi->phynoise_state) + return; + + if (pi->phynoise_state & PHY_NOISE_STATE_MON) { + if (pi->phynoise_chan_watchdog == channel) { + pi->sh->phy_noise_window[pi->sh->phy_noise_index] = + noise_dbm; + pi->sh->phy_noise_index = + MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); + } + pi->phynoise_state &= ~PHY_NOISE_STATE_MON; + } + + if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) + pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; + +} + +static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) +{ + u32 cmplx_pwr[PHY_CORE_MAX]; + s8 noise_dbm_ant[PHY_CORE_MAX]; + u16 lo, hi; + u32 cmplx_pwr_tot = 0; + s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; + u8 idx, core; + + memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); + memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); + + for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, + core++) { + lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); + hi = wlapi_bmac_read_shm(pi->sh->physhim, + M_PWRIND_MAP(idx + 1)); + cmplx_pwr[core] = (hi << 16) + lo; + cmplx_pwr_tot += cmplx_pwr[core]; + if (cmplx_pwr[core] == 0) + noise_dbm_ant[core] = PHY_NOISE_FIXED_VAL_NPHY; + else + cmplx_pwr[core] >>= PHY_NOISE_SAMPLE_LOG_NUM_UCODE; + } + + if (cmplx_pwr_tot != 0) + wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); + + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + pi->nphy_noise_win[core][pi->nphy_noise_index] = + noise_dbm_ant[core]; + + if (noise_dbm_ant[core] > noise_dbm) + noise_dbm = noise_dbm_ant[core]; + } + pi->nphy_noise_index = + MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); + + return noise_dbm; + +} + +void wlc_phy_noise_sample_intr(struct brcms_phy_pub *pih) +{ + struct brcms_phy *pi = (struct brcms_phy *) pih; + u16 jssi_aux; + u8 channel = 0; + s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; + + if (ISLCNPHY(pi)) { + u32 cmplx_pwr, cmplx_pwr0, cmplx_pwr1; + u16 lo, hi; + s32 pwr_offset_dB, gain_dB; + u16 status_0, status_1; + + jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); + channel = jssi_aux & D11_CURCHANNEL_MAX; + + lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP0); + hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP1); + cmplx_pwr0 = (hi << 16) + lo; + + lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP2); + hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP3); + cmplx_pwr1 = (hi << 16) + lo; + cmplx_pwr = (cmplx_pwr0 + cmplx_pwr1) >> 6; + + status_0 = 0x44; + status_1 = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_0); + if ((cmplx_pwr > 0 && cmplx_pwr < 500) + && ((status_1 & 0xc000) == 0x4000)) { + + wlc_phy_compute_dB(&cmplx_pwr, &noise_dbm, + pi->pubpi.phy_corenum); + pwr_offset_dB = (read_phy_reg(pi, 0x434) & 0xFF); + if (pwr_offset_dB > 127) + pwr_offset_dB -= 256; + + noise_dbm += (s8) (pwr_offset_dB - 30); + + gain_dB = (status_0 & 0x1ff); + noise_dbm -= (s8) (gain_dB); + } else { + noise_dbm = PHY_NOISE_FIXED_VAL_LCNPHY; + } + } else if (ISNPHY(pi)) { + + jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); + channel = jssi_aux & D11_CURCHANNEL_MAX; + + noise_dbm = wlc_phy_noise_read_shmem(pi); + } + + wlc_phy_noise_cb(pi, channel, noise_dbm); + +} + static void wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) { @@ -2408,123 +2539,6 @@ void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *pih) wlc_phy_noise_sample_request(pih, PHY_NOISE_SAMPLE_EXTERNAL, channel); } -static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) -{ - if (!pi->phynoise_state) - return; - - if (pi->phynoise_state & PHY_NOISE_STATE_MON) { - if (pi->phynoise_chan_watchdog == channel) { - pi->sh->phy_noise_window[pi->sh->phy_noise_index] = - noise_dbm; - pi->sh->phy_noise_index = - MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); - } - pi->phynoise_state &= ~PHY_NOISE_STATE_MON; - } - - if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) - pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; - -} - -static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) -{ - u32 cmplx_pwr[PHY_CORE_MAX]; - s8 noise_dbm_ant[PHY_CORE_MAX]; - u16 lo, hi; - u32 cmplx_pwr_tot = 0; - s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - u8 idx, core; - - memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); - memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); - - for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, - core++) { - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); - hi = wlapi_bmac_read_shm(pi->sh->physhim, - M_PWRIND_MAP(idx + 1)); - cmplx_pwr[core] = (hi << 16) + lo; - cmplx_pwr_tot += cmplx_pwr[core]; - if (cmplx_pwr[core] == 0) - noise_dbm_ant[core] = PHY_NOISE_FIXED_VAL_NPHY; - else - cmplx_pwr[core] >>= PHY_NOISE_SAMPLE_LOG_NUM_UCODE; - } - - if (cmplx_pwr_tot != 0) - wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - pi->nphy_noise_win[core][pi->nphy_noise_index] = - noise_dbm_ant[core]; - - if (noise_dbm_ant[core] > noise_dbm) - noise_dbm = noise_dbm_ant[core]; - } - pi->nphy_noise_index = - MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); - - return noise_dbm; - -} - -void wlc_phy_noise_sample_intr(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 jssi_aux; - u8 channel = 0; - s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - - if (ISLCNPHY(pi)) { - u32 cmplx_pwr, cmplx_pwr0, cmplx_pwr1; - u16 lo, hi; - s32 pwr_offset_dB, gain_dB; - u16 status_0, status_1; - - jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); - channel = jssi_aux & D11_CURCHANNEL_MAX; - - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP0); - hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP1); - cmplx_pwr0 = (hi << 16) + lo; - - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP2); - hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP3); - cmplx_pwr1 = (hi << 16) + lo; - cmplx_pwr = (cmplx_pwr0 + cmplx_pwr1) >> 6; - - status_0 = 0x44; - status_1 = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_0); - if ((cmplx_pwr > 0 && cmplx_pwr < 500) - && ((status_1 & 0xc000) == 0x4000)) { - - wlc_phy_compute_dB(&cmplx_pwr, &noise_dbm, - pi->pubpi.phy_corenum); - pwr_offset_dB = (read_phy_reg(pi, 0x434) & 0xFF); - if (pwr_offset_dB > 127) - pwr_offset_dB -= 256; - - noise_dbm += (s8) (pwr_offset_dB - 30); - - gain_dB = (status_0 & 0x1ff); - noise_dbm -= (s8) (gain_dB); - } else { - noise_dbm = PHY_NOISE_FIXED_VAL_LCNPHY; - } - } else if (ISNPHY(pi)) { - - jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); - channel = jssi_aux & D11_CURCHANNEL_MAX; - - noise_dbm = wlc_phy_noise_read_shmem(pi); - } - - wlc_phy_noise_cb(pi, channel, noise_dbm); - -} - s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { 8, 8, @@ -2985,46 +2999,6 @@ void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) } } -static s8 -wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, u32 band, - u8 rate) -{ - s8 offset = 0; - - if (!pi->user_txpwr_at_rfport) - return offset; - return offset; -} - -static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi) -{ - if (ISLCNPHY(pi)) - return wlc_lcnphy_vbatsense(pi, 0); - else - return 0; -} - -static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi) -{ - if (ISLCNPHY(pi)) - return wlc_lcnphy_tempsense_degree(pi, 0); - else - return 0; -} - -static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band) -{ - u8 i; - s8 temp, vbat; - - for (i = 0; i < TXP_NUM_RATES; i++) - pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; - - vbat = wlc_phy_env_measure_vbat(pi); - temp = wlc_phy_env_measure_temperature(pi); - -} - void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool ldpc) { return; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 47f96a9c89b..941b7fa3f1a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -965,71 +965,6 @@ u16 LCNPHY_txdigfiltcoeffs_ofdm[LCNPHY_NUM_TX_DIG_FILTERS_OFDM] #define FIXED_TXPWR 78 #define LCNPHY_TEMPSENSE(val) ((s16)((val > 255) ? (val - 512) : val)) -static u32 wlc_lcnphy_qdiv_roundup(u32 divident, u32 divisor, - u8 precision); -static void wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, - u16 ext_lna, u16 trsw, - u16 biq2, u16 biq1, - u16 tia, u16 lna2, - u16 lna1); -static void wlc_lcnphy_clear_tx_power_offsets(struct brcms_phy *pi); -static void wlc_lcnphy_set_pa_gain(struct brcms_phy *pi, u16 gain); -static void wlc_lcnphy_set_trsw_override(struct brcms_phy *pi, bool tx, - bool rx); -static void wlc_lcnphy_set_bbmult(struct brcms_phy *pi, u8 m0); -static u8 wlc_lcnphy_get_bbmult(struct brcms_phy *pi); -static void wlc_lcnphy_get_tx_gain(struct brcms_phy *pi, - struct lcnphy_txgains *gains); -static void wlc_lcnphy_set_tx_gain_override(struct brcms_phy *pi, bool bEnable); -static void wlc_lcnphy_toggle_afe_pwdn(struct brcms_phy *pi); -static void wlc_lcnphy_rx_gain_override_enable(struct brcms_phy *pi, - bool enable); -static void wlc_lcnphy_set_tx_gain(struct brcms_phy *pi, - struct lcnphy_txgains *target_gains); -static bool wlc_lcnphy_rx_iq_est(struct brcms_phy *pi, u16 num_samps, - u8 wait_time, struct lcnphy_iq_est *iq_est); -static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps); -static u16 wlc_lcnphy_get_pa_gain(struct brcms_phy *pi); -static void wlc_lcnphy_afe_clk_init(struct brcms_phy *pi, u8 mode); -static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi); -static void wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, - u8 channel); - -static void wlc_lcnphy_load_tx_gain_table( - struct brcms_phy *pi, - const struct lcnphy_tx_gain_tbl_entry - *g); - -static void wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, - u16 thresh, s16 *ptr, int mode); -static int wlc_lcnphy_calc_floor(s16 coeff, int type); -static void wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, - u16 *values_to_save); -static void wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, - u16 *values_to_save); -static void wlc_lcnphy_set_cc(struct brcms_phy *pi, int cal_type, s16 coeff_x, - s16 coeff_y); -static struct lcnphy_unsign16_struct wlc_lcnphy_get_cc(struct brcms_phy *pi, - int cal_type); -static void wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, - int num_levels, int step_size_lg2); -static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi); - -static void wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, - u16 chanspec); -static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi); -static void wlc_lcnphy_temp_adj(struct brcms_phy *pi); -static void wlc_lcnphy_clear_papd_comptable(struct brcms_phy *pi); -static void wlc_lcnphy_baseband_init(struct brcms_phy *pi); -static void wlc_lcnphy_radio_init(struct brcms_phy *pi); -static void wlc_lcnphy_rc_cal(struct brcms_phy *pi); -static void wlc_lcnphy_rcal(struct brcms_phy *pi); -static void wlc_lcnphy_txrx_spur_avoidance_mode(struct brcms_phy *pi, - bool enable); -static int wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, - s16 filt_type); -static void wlc_lcnphy_set_rx_iq_comp(struct brcms_phy *pi, u16 a, u16 b); - void wlc_lcnphy_write_table(struct brcms_phy *pi, const struct phytbl_info *pti) { wlc_phy_write_table(pi, pti, 0x455, 0x457, 0x456); @@ -1115,6 +1050,446 @@ static int wlc_lcnphy_calc_floor(s16 coeff_x, int type) return k; } +static void +wlc_lcnphy_get_tx_gain(struct brcms_phy *pi, struct lcnphy_txgains *gains) +{ + u16 dac_gain; + + dac_gain = read_phy_reg(pi, 0x439) >> 0; + gains->dac_gain = (dac_gain & 0x380) >> 7; + + { + u16 rfgain0, rfgain1; + + rfgain0 = (read_phy_reg(pi, 0x4b5) & (0xffff << 0)) >> 0; + rfgain1 = (read_phy_reg(pi, 0x4fb) & (0x7fff << 0)) >> 0; + + gains->gm_gain = rfgain0 & 0xff; + gains->pga_gain = (rfgain0 >> 8) & 0xff; + gains->pad_gain = rfgain1 & 0xff; + } +} + + +static void wlc_lcnphy_set_dac_gain(struct brcms_phy *pi, u16 dac_gain) +{ + u16 dac_ctrl; + + dac_ctrl = (read_phy_reg(pi, 0x439) >> 0); + dac_ctrl = dac_ctrl & 0xc7f; + dac_ctrl = dac_ctrl | (dac_gain << 7); + mod_phy_reg(pi, 0x439, (0xfff << 0), (dac_ctrl) << 0); + +} + +static void wlc_lcnphy_set_tx_gain_override(struct brcms_phy *pi, bool bEnable) +{ + u16 bit = bEnable ? 1 : 0; + + mod_phy_reg(pi, 0x4b0, (0x1 << 7), bit << 7); + + mod_phy_reg(pi, 0x4b0, (0x1 << 14), bit << 14); + + mod_phy_reg(pi, 0x43b, (0x1 << 6), bit << 6); +} + +static void +wlc_lcnphy_rx_gain_override_enable(struct brcms_phy *pi, bool enable) +{ + u16 ebit = enable ? 1 : 0; + + mod_phy_reg(pi, 0x4b0, (0x1 << 8), ebit << 8); + + mod_phy_reg(pi, 0x44c, (0x1 << 0), ebit << 0); + + if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { + mod_phy_reg(pi, 0x44c, (0x1 << 4), ebit << 4); + mod_phy_reg(pi, 0x44c, (0x1 << 6), ebit << 6); + mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); + mod_phy_reg(pi, 0x4b0, (0x1 << 6), ebit << 6); + } else { + mod_phy_reg(pi, 0x4b0, (0x1 << 12), ebit << 12); + mod_phy_reg(pi, 0x4b0, (0x1 << 13), ebit << 13); + mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); + } + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + mod_phy_reg(pi, 0x4b0, (0x1 << 10), ebit << 10); + mod_phy_reg(pi, 0x4e5, (0x1 << 3), ebit << 3); + } +} + +static void +wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, + u16 trsw, + u16 ext_lna, + u16 biq2, + u16 biq1, + u16 tia, u16 lna2, u16 lna1) +{ + u16 gain0_15, gain16_19; + + gain16_19 = biq2 & 0xf; + gain0_15 = ((biq1 & 0xf) << 12) | + ((tia & 0xf) << 8) | + ((lna2 & 0x3) << 6) | + ((lna2 & + 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); + + mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); + mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); + mod_phy_reg(pi, 0x4b1, (0x3 << 11), lna1 << 11); + + if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { + mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); + mod_phy_reg(pi, 0x4b1, (0x1 << 10), ext_lna << 10); + } else { + mod_phy_reg(pi, 0x4b1, (0x1 << 10), 0 << 10); + + mod_phy_reg(pi, 0x4b1, (0x1 << 15), 0 << 15); + + mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); + } + + mod_phy_reg(pi, 0x44d, (0x1 << 0), (!trsw) << 0); + +} + +static void wlc_lcnphy_set_trsw_override(struct brcms_phy *pi, bool tx, bool rx) +{ + + mod_phy_reg(pi, 0x44d, + (0x1 << 1) | + (0x1 << 0), (tx ? (0x1 << 1) : 0) | (rx ? (0x1 << 0) : 0)); + + or_phy_reg(pi, 0x44c, (0x1 << 1) | (0x1 << 0)); +} + +static void wlc_lcnphy_clear_trsw_override(struct brcms_phy *pi) +{ + + and_phy_reg(pi, 0x44c, (u16) ~((0x1 << 1) | (0x1 << 0))); +} + +static void wlc_lcnphy_set_rx_iq_comp(struct brcms_phy *pi, u16 a, u16 b) +{ + mod_phy_reg(pi, 0x645, (0x3ff << 0), (a) << 0); + + mod_phy_reg(pi, 0x646, (0x3ff << 0), (b) << 0); + + mod_phy_reg(pi, 0x647, (0x3ff << 0), (a) << 0); + + mod_phy_reg(pi, 0x648, (0x3ff << 0), (b) << 0); + + mod_phy_reg(pi, 0x649, (0x3ff << 0), (a) << 0); + + mod_phy_reg(pi, 0x64a, (0x3ff << 0), (b) << 0); + +} + +static bool +wlc_lcnphy_rx_iq_est(struct brcms_phy *pi, + u16 num_samps, + u8 wait_time, struct lcnphy_iq_est *iq_est) +{ + int wait_count = 0; + bool result = true; + u8 phybw40; + phybw40 = CHSPEC_IS40(pi->radio_chanspec); + + mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5); + + mod_phy_reg(pi, 0x410, (0x1 << 3), (0) << 3); + + mod_phy_reg(pi, 0x482, (0xffff << 0), (num_samps) << 0); + + mod_phy_reg(pi, 0x481, (0xff << 0), ((u16) wait_time) << 0); + + mod_phy_reg(pi, 0x481, (0x1 << 8), (0) << 8); + + mod_phy_reg(pi, 0x481, (0x1 << 9), (1) << 9); + + while (read_phy_reg(pi, 0x481) & (0x1 << 9)) { + + if (wait_count > (10 * 500)) { + result = false; + goto cleanup; + } + udelay(100); + wait_count++; + } + + iq_est->iq_prod = ((u32) read_phy_reg(pi, 0x483) << 16) | + (u32) read_phy_reg(pi, 0x484); + iq_est->i_pwr = ((u32) read_phy_reg(pi, 0x485) << 16) | + (u32) read_phy_reg(pi, 0x486); + iq_est->q_pwr = ((u32) read_phy_reg(pi, 0x487) << 16) | + (u32) read_phy_reg(pi, 0x488); + +cleanup: + mod_phy_reg(pi, 0x410, (0x1 << 3), (1) << 3); + + mod_phy_reg(pi, 0x6da, (0x1 << 5), (0) << 5); + + return result; +} + +static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps) +{ +#define LCNPHY_MIN_RXIQ_PWR 2 + bool result; + u16 a0_new, b0_new; + struct lcnphy_iq_est iq_est = { 0, 0, 0 }; + s32 a, b, temp; + s16 iq_nbits, qq_nbits, arsh, brsh; + s32 iq; + u32 ii, qq; + struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + + a0_new = ((read_phy_reg(pi, 0x645) & (0x3ff << 0)) >> 0); + b0_new = ((read_phy_reg(pi, 0x646) & (0x3ff << 0)) >> 0); + mod_phy_reg(pi, 0x6d1, (0x1 << 2), (0) << 2); + + mod_phy_reg(pi, 0x64b, (0x1 << 6), (1) << 6); + + wlc_lcnphy_set_rx_iq_comp(pi, 0, 0); + + result = wlc_lcnphy_rx_iq_est(pi, num_samps, 32, &iq_est); + if (!result) + goto cleanup; + + iq = (s32) iq_est.iq_prod; + ii = iq_est.i_pwr; + qq = iq_est.q_pwr; + + if ((ii + qq) < LCNPHY_MIN_RXIQ_PWR) { + result = false; + goto cleanup; + } + + iq_nbits = wlc_phy_nbits(iq); + qq_nbits = wlc_phy_nbits(qq); + + arsh = 10 - (30 - iq_nbits); + if (arsh >= 0) { + a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); + temp = (s32) (ii >> arsh); + if (temp == 0) + return false; + } else { + a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); + temp = (s32) (ii << -arsh); + if (temp == 0) + return false; + } + a /= temp; + brsh = qq_nbits - 31 + 20; + if (brsh >= 0) { + b = (qq << (31 - qq_nbits)); + temp = (s32) (ii >> brsh); + if (temp == 0) + return false; + } else { + b = (qq << (31 - qq_nbits)); + temp = (s32) (ii << -brsh); + if (temp == 0) + return false; + } + b /= temp; + b -= a * a; + b = (s32) int_sqrt((unsigned long) b); + b -= (1 << 10); + a0_new = (u16) (a & 0x3ff); + b0_new = (u16) (b & 0x3ff); +cleanup: + + wlc_lcnphy_set_rx_iq_comp(pi, a0_new, b0_new); + + mod_phy_reg(pi, 0x64b, (0x1 << 0), (1) << 0); + + mod_phy_reg(pi, 0x64b, (0x1 << 3), (1) << 3); + + pi_lcn->lcnphy_cal_results.rxiqcal_coeff_a0 = a0_new; + pi_lcn->lcnphy_cal_results.rxiqcal_coeff_b0 = b0_new; + + return result; +} + +static u32 wlc_lcnphy_measure_digital_power(struct brcms_phy *pi, u16 nsamples) +{ + struct lcnphy_iq_est iq_est = { 0, 0, 0 }; + + if (!wlc_lcnphy_rx_iq_est(pi, nsamples, 32, &iq_est)) + return 0; + return (iq_est.i_pwr + iq_est.q_pwr) / nsamples; +} + +static bool +wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, + const struct lcnphy_rx_iqcomp *iqcomp, + int iqcomp_sz, bool tx_switch, bool rx_switch, int module, + int tx_gain_idx) +{ + struct lcnphy_txgains old_gains; + u16 tx_pwr_ctrl; + u8 tx_gain_index_old = 0; + bool result = false, tx_gain_override_old = false; + u16 i, Core1TxControl_old, RFOverride0_old, + RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, + rfoverride3_old, rfoverride3val_old, rfoverride4_old, + rfoverride4val_old, afectrlovr_old, afectrlovrval_old; + int tia_gain; + u32 received_power, rx_pwr_threshold; + u16 old_sslpnCalibClkEnCtrl, old_sslpnRxFeClkEnCtrl; + u16 values_to_save[11]; + s16 *ptr; + struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + + ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); + if (NULL == ptr) + return false; + if (module == 2) { + while (iqcomp_sz--) { + if (iqcomp[iqcomp_sz].chan == + CHSPEC_CHANNEL(pi->radio_chanspec)) { + wlc_lcnphy_set_rx_iq_comp(pi, + (u16) + iqcomp[iqcomp_sz].a, + (u16) + iqcomp[iqcomp_sz].b); + result = true; + break; + } + } + goto cal_done; + } + + if (module == 1) { + + tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); + wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); + + for (i = 0; i < 11; i++) + values_to_save[i] = + read_radio_reg(pi, rxiq_cal_rf_reg[i]); + Core1TxControl_old = read_phy_reg(pi, 0x631); + + or_phy_reg(pi, 0x631, 0x0015); + + RFOverride0_old = read_phy_reg(pi, 0x44c); + RFOverrideVal0_old = read_phy_reg(pi, 0x44d); + rfoverride2_old = read_phy_reg(pi, 0x4b0); + rfoverride2val_old = read_phy_reg(pi, 0x4b1); + rfoverride3_old = read_phy_reg(pi, 0x4f9); + rfoverride3val_old = read_phy_reg(pi, 0x4fa); + rfoverride4_old = read_phy_reg(pi, 0x938); + rfoverride4val_old = read_phy_reg(pi, 0x939); + afectrlovr_old = read_phy_reg(pi, 0x43b); + afectrlovrval_old = read_phy_reg(pi, 0x43c); + old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); + old_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); + + tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); + if (tx_gain_override_old) { + wlc_lcnphy_get_tx_gain(pi, &old_gains); + tx_gain_index_old = pi_lcn->lcnphy_current_index; + } + + wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_idx); + + mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); + mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); + + mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); + mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); + + write_radio_reg(pi, RADIO_2064_REG116, 0x06); + write_radio_reg(pi, RADIO_2064_REG12C, 0x07); + write_radio_reg(pi, RADIO_2064_REG06A, 0xd3); + write_radio_reg(pi, RADIO_2064_REG098, 0x03); + write_radio_reg(pi, RADIO_2064_REG00B, 0x7); + mod_radio_reg(pi, RADIO_2064_REG113, 1 << 4, 1 << 4); + write_radio_reg(pi, RADIO_2064_REG01D, 0x01); + write_radio_reg(pi, RADIO_2064_REG114, 0x01); + write_radio_reg(pi, RADIO_2064_REG02E, 0x10); + write_radio_reg(pi, RADIO_2064_REG12A, 0x08); + + mod_phy_reg(pi, 0x938, (0x1 << 0), 1 << 0); + mod_phy_reg(pi, 0x939, (0x1 << 0), 0 << 0); + mod_phy_reg(pi, 0x938, (0x1 << 1), 1 << 1); + mod_phy_reg(pi, 0x939, (0x1 << 1), 1 << 1); + mod_phy_reg(pi, 0x938, (0x1 << 2), 1 << 2); + mod_phy_reg(pi, 0x939, (0x1 << 2), 1 << 2); + mod_phy_reg(pi, 0x938, (0x1 << 3), 1 << 3); + mod_phy_reg(pi, 0x939, (0x1 << 3), 1 << 3); + mod_phy_reg(pi, 0x938, (0x1 << 5), 1 << 5); + mod_phy_reg(pi, 0x939, (0x1 << 5), 0 << 5); + + mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); + mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); + + wlc_lcnphy_start_tx_tone(pi, 2000, 120, 0); + write_phy_reg(pi, 0x6da, 0xffff); + or_phy_reg(pi, 0x6db, 0x3); + wlc_lcnphy_set_trsw_override(pi, tx_switch, rx_switch); + wlc_lcnphy_rx_gain_override_enable(pi, true); + + tia_gain = 8; + rx_pwr_threshold = 950; + while (tia_gain > 0) { + tia_gain -= 1; + wlc_lcnphy_set_rx_gain_by_distribution(pi, + 0, 0, 2, 2, + (u16) + tia_gain, 1, 0); + udelay(500); + + received_power = + wlc_lcnphy_measure_digital_power(pi, 2000); + if (received_power < rx_pwr_threshold) + break; + } + result = wlc_lcnphy_calc_rx_iq_comp(pi, 0xffff); + + wlc_lcnphy_stop_tx_tone(pi); + + write_phy_reg(pi, 0x631, Core1TxControl_old); + + write_phy_reg(pi, 0x44c, RFOverrideVal0_old); + write_phy_reg(pi, 0x44d, RFOverrideVal0_old); + write_phy_reg(pi, 0x4b0, rfoverride2_old); + write_phy_reg(pi, 0x4b1, rfoverride2val_old); + write_phy_reg(pi, 0x4f9, rfoverride3_old); + write_phy_reg(pi, 0x4fa, rfoverride3val_old); + write_phy_reg(pi, 0x938, rfoverride4_old); + write_phy_reg(pi, 0x939, rfoverride4val_old); + write_phy_reg(pi, 0x43b, afectrlovr_old); + write_phy_reg(pi, 0x43c, afectrlovrval_old); + write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); + write_phy_reg(pi, 0x6db, old_sslpnRxFeClkEnCtrl); + + wlc_lcnphy_clear_trsw_override(pi); + + mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); + + for (i = 0; i < 11; i++) + write_radio_reg(pi, rxiq_cal_rf_reg[i], + values_to_save[i]); + + if (tx_gain_override_old) + wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); + else + wlc_lcnphy_disable_tx_gain_override(pi); + + wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); + wlc_lcnphy_rx_gain_override_enable(pi, false); + } + +cal_done: + kfree(ptr); + return result; +} + s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi) { s8 index; @@ -1130,15 +1505,6 @@ s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi) return index; } -static u32 wlc_lcnphy_measure_digital_power(struct brcms_phy *pi, u16 nsamples) -{ - struct lcnphy_iq_est iq_est = { 0, 0, 0 }; - - if (!wlc_lcnphy_rx_iq_est(pi, nsamples, 32, &iq_est)) - return 0; - return (iq_est.i_pwr + iq_est.q_pwr) / nsamples; -} - void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel) { u16 afectrlovr, afectrlovrval; @@ -1207,6 +1573,295 @@ wlc_lcnphy_txrx_spur_avoidance_mode(struct brcms_phy *pi, bool enable) wlapi_switch_macfreq(pi->sh->physhim, enable); } +static void +wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) +{ + u8 channel = CHSPEC_CHANNEL(chanspec); + struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + + if (channel == 14) + mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); + else + mod_phy_reg(pi, 0x448, (0x3 << 8), (1) << 8); + + pi_lcn->lcnphy_bandedge_corr = 2; + if (channel == 1) + pi_lcn->lcnphy_bandedge_corr = 4; + + if (channel == 1 || channel == 2 || channel == 3 || + channel == 4 || channel == 9 || + channel == 10 || channel == 11 || channel == 12) { + si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03000c04); + si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x0); + si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x200005c0); + + si_pmu_pllupd(pi->sh->sih); + write_phy_reg(pi, 0x942, 0); + wlc_lcnphy_txrx_spur_avoidance_mode(pi, false); + pi_lcn->lcnphy_spurmod = 0; + mod_phy_reg(pi, 0x424, (0xff << 8), (0x1b) << 8); + + write_phy_reg(pi, 0x425, 0x5907); + } else { + si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03140c04); + si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x333333); + si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x202c2820); + + si_pmu_pllupd(pi->sh->sih); + write_phy_reg(pi, 0x942, 0); + wlc_lcnphy_txrx_spur_avoidance_mode(pi, true); + + pi_lcn->lcnphy_spurmod = 0; + mod_phy_reg(pi, 0x424, (0xff << 8), (0x1f) << 8); + + write_phy_reg(pi, 0x425, 0x590a); + } + + or_phy_reg(pi, 0x44a, 0x44); + write_phy_reg(pi, 0x44a, 0x80); +} + +static void +wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) +{ + uint i; + const struct chan_info_2064_lcnphy *ci; + u8 rfpll_doubler = 0; + u8 pll_pwrup, pll_pwrup_ovr; + s32 qFxtal, qFref, qFvco, qFcal; + u8 d15, d16, f16, e44, e45; + u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; + u16 loop_bw, d30, setCount; + + ci = &chan_info_2064_lcnphy[0]; + rfpll_doubler = 1; + + mod_radio_reg(pi, RADIO_2064_REG09D, 0x4, 0x1 << 2); + + write_radio_reg(pi, RADIO_2064_REG09E, 0xf); + if (!rfpll_doubler) { + loop_bw = PLL_2064_LOOP_BW; + d30 = PLL_2064_D30; + } else { + loop_bw = PLL_2064_LOOP_BW_DOUBLER; + d30 = PLL_2064_D30_DOUBLER; + } + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + for (i = 0; i < ARRAY_SIZE(chan_info_2064_lcnphy); i++) + if (chan_info_2064_lcnphy[i].chan == channel) + break; + + if (i >= ARRAY_SIZE(chan_info_2064_lcnphy)) + return; + + ci = &chan_info_2064_lcnphy[i]; + } + + write_radio_reg(pi, RADIO_2064_REG02A, ci->logen_buftune); + + mod_radio_reg(pi, RADIO_2064_REG030, 0x3, ci->logen_rccr_tx); + + mod_radio_reg(pi, RADIO_2064_REG091, 0x3, ci->txrf_mix_tune_ctrl); + + mod_radio_reg(pi, RADIO_2064_REG038, 0xf, ci->pa_input_tune_g); + + mod_radio_reg(pi, RADIO_2064_REG030, 0x3 << 2, + (ci->logen_rccr_rx) << 2); + + mod_radio_reg(pi, RADIO_2064_REG05E, 0xf, ci->pa_rxrf_lna1_freq_tune); + + mod_radio_reg(pi, RADIO_2064_REG05E, (0xf) << 4, + (ci->pa_rxrf_lna2_freq_tune) << 4); + + write_radio_reg(pi, RADIO_2064_REG06C, ci->rxrf_rxrf_spare1); + + pll_pwrup = (u8) read_radio_reg(pi, RADIO_2064_REG044); + pll_pwrup_ovr = (u8) read_radio_reg(pi, RADIO_2064_REG12B); + + or_radio_reg(pi, RADIO_2064_REG044, 0x07); + + or_radio_reg(pi, RADIO_2064_REG12B, (0x07) << 1); + e44 = 0; + e45 = 0; + + fpfd = rfpll_doubler ? (pi->xtalfreq << 1) : (pi->xtalfreq); + if (pi->xtalfreq > 26000000) + e44 = 1; + if (pi->xtalfreq > 52000000) + e45 = 1; + if (e44 == 0) + fcal_div = 1; + else if (e45 == 0) + fcal_div = 2; + else + fcal_div = 4; + fvco3 = (ci->freq * 3); + fref3 = 2 * fpfd; + + qFxtal = wlc_lcnphy_qdiv_roundup(pi->xtalfreq, PLL_2064_MHZ, 16); + qFref = wlc_lcnphy_qdiv_roundup(fpfd, PLL_2064_MHZ, 16); + qFcal = pi->xtalfreq * fcal_div / PLL_2064_MHZ; + qFvco = wlc_lcnphy_qdiv_roundup(fvco3, 2, 16); + + write_radio_reg(pi, RADIO_2064_REG04F, 0x02); + + d15 = (pi->xtalfreq * fcal_div * 4 / 5) / PLL_2064_MHZ - 1; + write_radio_reg(pi, RADIO_2064_REG052, (0x07 & (d15 >> 2))); + write_radio_reg(pi, RADIO_2064_REG053, (d15 & 0x3) << 5); + + d16 = (qFcal * 8 / (d15 + 1)) - 1; + write_radio_reg(pi, RADIO_2064_REG051, d16); + + f16 = ((d16 + 1) * (d15 + 1)) / qFcal; + setCount = f16 * 3 * (ci->freq) / 32 - 1; + mod_radio_reg(pi, RADIO_2064_REG053, (0x0f << 0), + (u8) (setCount >> 8)); + + or_radio_reg(pi, RADIO_2064_REG053, 0x10); + write_radio_reg(pi, RADIO_2064_REG054, (u8) (setCount & 0xff)); + + div_int = ((fvco3 * (PLL_2064_MHZ >> 4)) / fref3) << 4; + + div_frac = ((fvco3 * (PLL_2064_MHZ >> 4)) % fref3) << 4; + while (div_frac >= fref3) { + div_int++; + div_frac -= fref3; + } + div_frac = wlc_lcnphy_qdiv_roundup(div_frac, fref3, 20); + + mod_radio_reg(pi, RADIO_2064_REG045, (0x1f << 0), + (u8) (div_int >> 4)); + mod_radio_reg(pi, RADIO_2064_REG046, (0x1f << 4), + (u8) (div_int << 4)); + mod_radio_reg(pi, RADIO_2064_REG046, (0x0f << 0), + (u8) (div_frac >> 16)); + write_radio_reg(pi, RADIO_2064_REG047, (u8) (div_frac >> 8) & 0xff); + write_radio_reg(pi, RADIO_2064_REG048, (u8) div_frac & 0xff); + + write_radio_reg(pi, RADIO_2064_REG040, 0xfb); + + write_radio_reg(pi, RADIO_2064_REG041, 0x9A); + write_radio_reg(pi, RADIO_2064_REG042, 0xA3); + write_radio_reg(pi, RADIO_2064_REG043, 0x0C); + + { + u8 h29, h23, c28, d29, h28_ten, e30, h30_ten, cp_current; + u16 c29, c38, c30, g30, d28; + c29 = loop_bw; + d29 = 200; + c38 = 1250; + h29 = d29 / c29; + h23 = 1; + c28 = 30; + d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * + (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / + (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) + + PLL_2064_LOW_END_KVCO; + h28_ten = (d28 * 10) / c28; + c30 = 2640; + e30 = (d30 - 680) / 490; + g30 = 680 + (e30 * 490); + h30_ten = (g30 * 10) / c30; + cp_current = ((c38 * h29 * h23 * 100) / h28_ten) / h30_ten; + mod_radio_reg(pi, RADIO_2064_REG03C, 0x3f, cp_current); + } + if (channel >= 1 && channel <= 5) + write_radio_reg(pi, RADIO_2064_REG03C, 0x8); + else + write_radio_reg(pi, RADIO_2064_REG03C, 0x7); + write_radio_reg(pi, RADIO_2064_REG03D, 0x3); + + mod_radio_reg(pi, RADIO_2064_REG044, 0x0c, 0x0c); + udelay(1); + + wlc_2064_vco_cal(pi); + + write_radio_reg(pi, RADIO_2064_REG044, pll_pwrup); + write_radio_reg(pi, RADIO_2064_REG12B, pll_pwrup_ovr); + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { + write_radio_reg(pi, RADIO_2064_REG038, 3); + write_radio_reg(pi, RADIO_2064_REG091, 7); + } +} + +static int +wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, s16 filt_type) +{ + s16 filt_index = -1; + int j; + + u16 addr[] = { + 0x910, + 0x91e, + 0x91f, + 0x924, + 0x925, + 0x926, + 0x920, + 0x921, + 0x927, + 0x928, + 0x929, + 0x922, + 0x923, + 0x930, + 0x931, + 0x932 + }; + + u16 addr_ofdm[] = { + 0x90f, + 0x900, + 0x901, + 0x906, + 0x907, + 0x908, + 0x902, + 0x903, + 0x909, + 0x90a, + 0x90b, + 0x904, + 0x905, + 0x90c, + 0x90d, + 0x90e + }; + + if (!is_ofdm) { + for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_CCK; j++) { + if (filt_type == LCNPHY_txdigfiltcoeffs_cck[j][0]) { + filt_index = (s16) j; + break; + } + } + + if (filt_index != -1) { + for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, addr[j], + LCNPHY_txdigfiltcoeffs_cck + [filt_index][j + 1]); + } + } else { + for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_OFDM; j++) { + if (filt_type == LCNPHY_txdigfiltcoeffs_ofdm[j][0]) { + filt_index = (s16) j; + break; + } + } + + if (filt_index != -1) { + for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, addr_ofdm[j], + LCNPHY_txdigfiltcoeffs_ofdm + [filt_index][j + 1]); + } + } + + return (filt_index != -1) ? 0 : -1; +} + void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) { u8 channel = CHSPEC_CHANNEL(chanspec); @@ -1242,28 +1897,6 @@ void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) } -static void wlc_lcnphy_set_dac_gain(struct brcms_phy *pi, u16 dac_gain) -{ - u16 dac_ctrl; - - dac_ctrl = (read_phy_reg(pi, 0x439) >> 0); - dac_ctrl = dac_ctrl & 0xc7f; - dac_ctrl = dac_ctrl | (dac_gain << 7); - mod_phy_reg(pi, 0x439, (0xfff << 0), (dac_ctrl) << 0); - -} - -static void wlc_lcnphy_set_tx_gain_override(struct brcms_phy *pi, bool bEnable) -{ - u16 bit = bEnable ? 1 : 0; - - mod_phy_reg(pi, 0x4b0, (0x1 << 7), bit << 7); - - mod_phy_reg(pi, 0x4b0, (0x1 << 14), bit << 14); - - mod_phy_reg(pi, 0x43b, (0x1 << 6), bit << 6); -} - static u16 wlc_lcnphy_get_pa_gain(struct brcms_phy *pi) { u16 pa_gain; @@ -1815,6 +2448,98 @@ void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode) } } +static void +wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, u16 *values_to_save) +{ + u16 vmid; + int i; + for (i = 0; i < 20; i++) + values_to_save[i] = + read_radio_reg(pi, iqlo_loopback_rf_regs[i]); + + mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); + mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); + + mod_phy_reg(pi, 0x44c, (0x1 << 11), 1 << 11); + mod_phy_reg(pi, 0x44d, (0x1 << 13), 0 << 13); + + mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); + mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); + + mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); + mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); + + if (LCNREV_IS(pi->pubpi.phy_rev, 2)) + and_radio_reg(pi, RADIO_2064_REG03A, 0xFD); + else + and_radio_reg(pi, RADIO_2064_REG03A, 0xF9); + or_radio_reg(pi, RADIO_2064_REG11A, 0x1); + + or_radio_reg(pi, RADIO_2064_REG036, 0x01); + or_radio_reg(pi, RADIO_2064_REG11A, 0x18); + udelay(20); + + if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) + mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0); + else + or_radio_reg(pi, RADIO_2064_REG03A, 1); + } else { + if (CHSPEC_IS5G(pi->radio_chanspec)) + mod_radio_reg(pi, RADIO_2064_REG03A, 3, 1); + else + or_radio_reg(pi, RADIO_2064_REG03A, 0x3); + } + + udelay(20); + + write_radio_reg(pi, RADIO_2064_REG025, 0xF); + if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) + mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x4); + else + mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x6); + } else { + if (CHSPEC_IS5G(pi->radio_chanspec)) + mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x4 << 1); + else + mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x6 << 1); + } + + udelay(20); + + write_radio_reg(pi, RADIO_2064_REG005, 0x8); + or_radio_reg(pi, RADIO_2064_REG112, 0x80); + udelay(20); + + or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); + or_radio_reg(pi, RADIO_2064_REG11F, 0x44); + udelay(20); + + or_radio_reg(pi, RADIO_2064_REG00B, 0x7); + or_radio_reg(pi, RADIO_2064_REG113, 0x10); + udelay(20); + + write_radio_reg(pi, RADIO_2064_REG007, 0x1); + udelay(20); + + vmid = 0x2A6; + mod_radio_reg(pi, RADIO_2064_REG0FC, 0x3 << 0, (vmid >> 8) & 0x3); + write_radio_reg(pi, RADIO_2064_REG0FD, (vmid & 0xff)); + or_radio_reg(pi, RADIO_2064_REG11F, 0x44); + udelay(20); + + or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); + udelay(20); + write_radio_reg(pi, RADIO_2064_REG012, 0x02); + or_radio_reg(pi, RADIO_2064_REG112, 0x06); + write_radio_reg(pi, RADIO_2064_REG036, 0x11); + write_radio_reg(pi, RADIO_2064_REG059, 0xcc); + write_radio_reg(pi, RADIO_2064_REG05C, 0x2e); + write_radio_reg(pi, RADIO_2064_REG078, 0xd7); + write_radio_reg(pi, RADIO_2064_REG092, 0x15); +} + static bool wlc_lcnphy_iqcal_wait(struct brcms_phy *pi) { uint delay_count = 0; @@ -1830,6 +2555,20 @@ static bool wlc_lcnphy_iqcal_wait(struct brcms_phy *pi) return (0 == wlc_lcnphy_iqcal_active(pi)); } +static void +wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, u16 *values_to_save) +{ + int i; + + and_phy_reg(pi, 0x44c, 0x0 >> 11); + + and_phy_reg(pi, 0x43b, 0xC); + + for (i = 0; i < 20; i++) + write_radio_reg(pi, iqlo_loopback_rf_regs[i], + values_to_save[i]); +} + static void wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, struct lcnphy_txgains *target_gains, @@ -2374,26 +3113,6 @@ wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, *fq0 = LCNPHY_IQLOCC_READ(read_radio_reg(pi, RADIO_2064_REG08C)); } -static void -wlc_lcnphy_get_tx_gain(struct brcms_phy *pi, struct lcnphy_txgains *gains) -{ - u16 dac_gain; - - dac_gain = read_phy_reg(pi, 0x439) >> 0; - gains->dac_gain = (dac_gain & 0x380) >> 7; - - { - u16 rfgain0, rfgain1; - - rfgain0 = (read_phy_reg(pi, 0x4b5) & (0xffff << 0)) >> 0; - rfgain1 = (read_phy_reg(pi, 0x4fb) & (0x7fff << 0)) >> 0; - - gains->gm_gain = rfgain0 & 0xff; - gains->pga_gain = (rfgain0 >> 8) & 0xff; - gains->pad_gain = rfgain1 & 0xff; - } -} - void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b) { struct phytbl_info tab; @@ -2481,16 +3200,6 @@ void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index) } } -static void wlc_lcnphy_set_trsw_override(struct brcms_phy *pi, bool tx, bool rx) -{ - - mod_phy_reg(pi, 0x44d, - (0x1 << 1) | - (0x1 << 0), (tx ? (0x1 << 1) : 0) | (rx ? (0x1 << 0) : 0)); - - or_phy_reg(pi, 0x44c, (0x1 << 1) | (0x1 << 0)); -} - static void wlc_lcnphy_clear_papd_comptable(struct brcms_phy *pi) { u32 j; @@ -2510,68 +3219,6 @@ static void wlc_lcnphy_clear_papd_comptable(struct brcms_phy *pi) return; } -static void -wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, - u16 trsw, - u16 ext_lna, - u16 biq2, - u16 biq1, - u16 tia, u16 lna2, u16 lna1) -{ - u16 gain0_15, gain16_19; - - gain16_19 = biq2 & 0xf; - gain0_15 = ((biq1 & 0xf) << 12) | - ((tia & 0xf) << 8) | - ((lna2 & 0x3) << 6) | - ((lna2 & - 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); - - mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); - mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); - mod_phy_reg(pi, 0x4b1, (0x3 << 11), lna1 << 11); - - if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { - mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); - mod_phy_reg(pi, 0x4b1, (0x1 << 10), ext_lna << 10); - } else { - mod_phy_reg(pi, 0x4b1, (0x1 << 10), 0 << 10); - - mod_phy_reg(pi, 0x4b1, (0x1 << 15), 0 << 15); - - mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); - } - - mod_phy_reg(pi, 0x44d, (0x1 << 0), (!trsw) << 0); - -} - -static void -wlc_lcnphy_rx_gain_override_enable(struct brcms_phy *pi, bool enable) -{ - u16 ebit = enable ? 1 : 0; - - mod_phy_reg(pi, 0x4b0, (0x1 << 8), ebit << 8); - - mod_phy_reg(pi, 0x44c, (0x1 << 0), ebit << 0); - - if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { - mod_phy_reg(pi, 0x44c, (0x1 << 4), ebit << 4); - mod_phy_reg(pi, 0x44c, (0x1 << 6), ebit << 6); - mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); - mod_phy_reg(pi, 0x4b0, (0x1 << 6), ebit << 6); - } else { - mod_phy_reg(pi, 0x4b0, (0x1 << 12), ebit << 12); - mod_phy_reg(pi, 0x4b0, (0x1 << 13), ebit << 13); - mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x4b0, (0x1 << 10), ebit << 10); - mod_phy_reg(pi, 0x4e5, (0x1 << 3), ebit << 3); - } -} - void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable) { if (!bEnable) { @@ -2796,10 +3443,359 @@ void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi) wlc_lcnphy_deaf_mode(pi, false); } -static void wlc_lcnphy_clear_trsw_override(struct brcms_phy *pi) +static void +wlc_lcnphy_set_cc(struct brcms_phy *pi, int cal_type, s16 coeff_x, s16 coeff_y) { + u16 di0dq0; + u16 x, y, data_rf; + int k; + switch (cal_type) { + case 0: + wlc_lcnphy_set_tx_iqcc(pi, coeff_x, coeff_y); + break; + case 2: + di0dq0 = (coeff_x & 0xff) << 8 | (coeff_y & 0xff); + wlc_lcnphy_set_tx_locc(pi, di0dq0); + break; + case 3: + k = wlc_lcnphy_calc_floor(coeff_x, 0); + y = 8 + k; + k = wlc_lcnphy_calc_floor(coeff_x, 1); + x = 8 - k; + data_rf = (x * 16 + y); + write_radio_reg(pi, RADIO_2064_REG089, data_rf); + k = wlc_lcnphy_calc_floor(coeff_y, 0); + y = 8 + k; + k = wlc_lcnphy_calc_floor(coeff_y, 1); + x = 8 - k; + data_rf = (x * 16 + y); + write_radio_reg(pi, RADIO_2064_REG08A, data_rf); + break; + case 4: + k = wlc_lcnphy_calc_floor(coeff_x, 0); + y = 8 + k; + k = wlc_lcnphy_calc_floor(coeff_x, 1); + x = 8 - k; + data_rf = (x * 16 + y); + write_radio_reg(pi, RADIO_2064_REG08B, data_rf); + k = wlc_lcnphy_calc_floor(coeff_y, 0); + y = 8 + k; + k = wlc_lcnphy_calc_floor(coeff_y, 1); + x = 8 - k; + data_rf = (x * 16 + y); + write_radio_reg(pi, RADIO_2064_REG08C, data_rf); + break; + } +} - and_phy_reg(pi, 0x44c, (u16) ~((0x1 << 1) | (0x1 << 0))); +static struct lcnphy_unsign16_struct +wlc_lcnphy_get_cc(struct brcms_phy *pi, int cal_type) +{ + u16 a, b, didq; + u8 di0, dq0, ei, eq, fi, fq; + struct lcnphy_unsign16_struct cc; + cc.re = 0; + cc.im = 0; + switch (cal_type) { + case 0: + wlc_lcnphy_get_tx_iqcc(pi, &a, &b); + cc.re = a; + cc.im = b; + break; + case 2: + didq = wlc_lcnphy_get_tx_locc(pi); + di0 = (((didq & 0xff00) << 16) >> 24); + dq0 = (((didq & 0x00ff) << 24) >> 24); + cc.re = (u16) di0; + cc.im = (u16) dq0; + break; + case 3: + wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); + cc.re = (u16) ei; + cc.im = (u16) eq; + break; + case 4: + wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); + cc.re = (u16) fi; + cc.im = (u16) fq; + break; + } + return cc; +} + +static void +wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, + s16 *ptr, int mode) +{ + u32 curval1, curval2, stpptr, curptr, strptr, val; + u16 sslpnCalibClkEnCtrl, timer; + u16 old_sslpnCalibClkEnCtrl; + s16 imag, real; + struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + + timer = 0; + old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); + + curval1 = R_REG(&pi->regs->psm_corectlsts); + ptr[130] = 0; + W_REG(&pi->regs->psm_corectlsts, ((1 << 6) | curval1)); + + W_REG(&pi->regs->smpl_clct_strptr, 0x7E00); + W_REG(&pi->regs->smpl_clct_stpptr, 0x8000); + udelay(20); + curval2 = R_REG(&pi->regs->psm_phy_hdr_param); + W_REG(&pi->regs->psm_phy_hdr_param, curval2 | 0x30); + + write_phy_reg(pi, 0x555, 0x0); + write_phy_reg(pi, 0x5a6, 0x5); + + write_phy_reg(pi, 0x5a2, (u16) (mode | mode << 6)); + write_phy_reg(pi, 0x5cf, 3); + write_phy_reg(pi, 0x5a5, 0x3); + write_phy_reg(pi, 0x583, 0x0); + write_phy_reg(pi, 0x584, 0x0); + write_phy_reg(pi, 0x585, 0x0fff); + write_phy_reg(pi, 0x586, 0x0000); + + write_phy_reg(pi, 0x580, 0x4501); + + sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); + write_phy_reg(pi, 0x6da, (u32) (sslpnCalibClkEnCtrl | 0x2008)); + stpptr = R_REG(&pi->regs->smpl_clct_stpptr); + curptr = R_REG(&pi->regs->smpl_clct_curptr); + do { + udelay(10); + curptr = R_REG(&pi->regs->smpl_clct_curptr); + timer++; + } while ((curptr != stpptr) && (timer < 500)); + + W_REG(&pi->regs->psm_phy_hdr_param, 0x2); + strptr = 0x7E00; + W_REG(&pi->regs->tplatewrptr, strptr); + while (strptr < 0x8000) { + val = R_REG(&pi->regs->tplatewrdata); + imag = ((val >> 16) & 0x3ff); + real = ((val) & 0x3ff); + if (imag > 511) + imag -= 1024; + + if (real > 511) + real -= 1024; + + if (pi_lcn->lcnphy_iqcal_swp_dis) + ptr[(strptr - 0x7E00) / 4] = real; + else + ptr[(strptr - 0x7E00) / 4] = imag; + + if (clip_detect_algo) { + if (imag > thresh || imag < -thresh) { + strptr = 0x8000; + ptr[130] = 1; + } + } + + strptr += 4; + } + + write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); + W_REG(&pi->regs->psm_phy_hdr_param, curval2); + W_REG(&pi->regs->psm_corectlsts, curval1); +} + +static void +wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, + int step_size_lg2) +{ + const struct lcnphy_spb_tone *phy_c1; + struct lcnphy_spb_tone phy_c2; + struct lcnphy_unsign16_struct phy_c3; + int phy_c4, phy_c5, k, l, j, phy_c6; + u16 phy_c7, phy_c8, phy_c9; + s16 phy_c10, phy_c11, phy_c12, phy_c13, phy_c14, phy_c15, phy_c16; + s16 *ptr, phy_c17; + s32 phy_c18, phy_c19; + u32 phy_c20, phy_c21; + bool phy_c22, phy_c23, phy_c24, phy_c25; + u16 phy_c26, phy_c27; + u16 phy_c28, phy_c29, phy_c30; + u16 phy_c31; + u16 *phy_c32; + phy_c21 = 0; + phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; + ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); + if (NULL == ptr) + return; + + phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); + if (NULL == phy_c32) { + kfree(ptr); + return; + } + phy_c26 = read_phy_reg(pi, 0x6da); + phy_c27 = read_phy_reg(pi, 0x6db); + phy_c31 = read_radio_reg(pi, RADIO_2064_REG026); + write_phy_reg(pi, 0x93d, 0xC0); + + wlc_lcnphy_start_tx_tone(pi, 3750, 88, 0); + write_phy_reg(pi, 0x6da, 0xffff); + or_phy_reg(pi, 0x6db, 0x3); + + wlc_lcnphy_tx_iqlo_loopback(pi, phy_c32); + udelay(500); + phy_c28 = read_phy_reg(pi, 0x938); + phy_c29 = read_phy_reg(pi, 0x4d7); + phy_c30 = read_phy_reg(pi, 0x4d8); + or_phy_reg(pi, 0x938, 0x1 << 2); + or_phy_reg(pi, 0x4d7, 0x1 << 2); + or_phy_reg(pi, 0x4d7, 0x1 << 3); + mod_phy_reg(pi, 0x4d7, (0x7 << 12), 0x2 << 12); + or_phy_reg(pi, 0x4d8, 1 << 0); + or_phy_reg(pi, 0x4d8, 1 << 1); + mod_phy_reg(pi, 0x4d8, (0x3ff << 2), 0x23A << 2); + mod_phy_reg(pi, 0x4d8, (0x7 << 12), 0x7 << 12); + phy_c1 = &lcnphy_spb_tone_3750[0]; + phy_c4 = 32; + + if (num_levels == 0) { + if (cal_type != 0) + num_levels = 4; + else + num_levels = 9; + } + if (step_size_lg2 == 0) { + if (cal_type != 0) + step_size_lg2 = 3; + else + step_size_lg2 = 8; + } + + phy_c7 = (1 << step_size_lg2); + phy_c3 = wlc_lcnphy_get_cc(pi, cal_type); + phy_c15 = (s16) phy_c3.re; + phy_c16 = (s16) phy_c3.im; + if (cal_type == 2) { + if (phy_c3.re > 127) + phy_c15 = phy_c3.re - 256; + if (phy_c3.im > 127) + phy_c16 = phy_c3.im - 256; + } + wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); + udelay(20); + for (phy_c8 = 0; phy_c7 != 0 && phy_c8 < num_levels; phy_c8++) { + phy_c23 = 1; + phy_c22 = 0; + switch (cal_type) { + case 0: + phy_c10 = 511; + break; + case 2: + phy_c10 = 127; + break; + case 3: + phy_c10 = 15; + break; + case 4: + phy_c10 = 15; + break; + } + + phy_c9 = read_phy_reg(pi, 0x93d); + phy_c9 = 2 * phy_c9; + phy_c24 = 0; + phy_c5 = 7; + phy_c25 = 1; + while (1) { + write_radio_reg(pi, RADIO_2064_REG026, + (phy_c5 & 0x7) | ((phy_c5 & 0x7) << 4)); + udelay(50); + phy_c22 = 0; + ptr[130] = 0; + wlc_lcnphy_samp_cap(pi, 1, phy_c9, &ptr[0], 2); + if (ptr[130] == 1) + phy_c22 = 1; + if (phy_c22) + phy_c5 -= 1; + if ((phy_c22 != phy_c24) && (!phy_c25)) + break; + if (!phy_c22) + phy_c5 += 1; + if (phy_c5 <= 0 || phy_c5 >= 7) + break; + phy_c24 = phy_c22; + phy_c25 = 0; + } + + if (phy_c5 < 0) + phy_c5 = 0; + else if (phy_c5 > 7) + phy_c5 = 7; + + for (k = -phy_c7; k <= phy_c7; k += phy_c7) { + for (l = -phy_c7; l <= phy_c7; l += phy_c7) { + phy_c11 = phy_c15 + k; + phy_c12 = phy_c16 + l; + + if (phy_c11 < -phy_c10) + phy_c11 = -phy_c10; + else if (phy_c11 > phy_c10) + phy_c11 = phy_c10; + if (phy_c12 < -phy_c10) + phy_c12 = -phy_c10; + else if (phy_c12 > phy_c10) + phy_c12 = phy_c10; + wlc_lcnphy_set_cc(pi, cal_type, phy_c11, + phy_c12); + udelay(20); + wlc_lcnphy_samp_cap(pi, 0, 0, ptr, 2); + + phy_c18 = 0; + phy_c19 = 0; + for (j = 0; j < 128; j++) { + if (cal_type != 0) + phy_c6 = j % phy_c4; + else + phy_c6 = (2 * j) % phy_c4; + + phy_c2.re = phy_c1[phy_c6].re; + phy_c2.im = phy_c1[phy_c6].im; + phy_c17 = ptr[j]; + phy_c18 = phy_c18 + phy_c17 * phy_c2.re; + phy_c19 = phy_c19 + phy_c17 * phy_c2.im; + } + + phy_c18 = phy_c18 >> 10; + phy_c19 = phy_c19 >> 10; + phy_c20 = ((phy_c18 * phy_c18) + + (phy_c19 * phy_c19)); + + if (phy_c23 || phy_c20 < phy_c21) { + phy_c21 = phy_c20; + phy_c13 = phy_c11; + phy_c14 = phy_c12; + } + phy_c23 = 0; + } + } + phy_c23 = 1; + phy_c15 = phy_c13; + phy_c16 = phy_c14; + phy_c7 = phy_c7 >> 1; + wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); + udelay(20); + } + goto cleanup; +cleanup: + wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, phy_c32); + wlc_lcnphy_stop_tx_tone(pi); + write_phy_reg(pi, 0x6da, phy_c26); + write_phy_reg(pi, 0x6db, phy_c27); + write_phy_reg(pi, 0x938, phy_c28); + write_phy_reg(pi, 0x4d7, phy_c29); + write_phy_reg(pi, 0x4d8, phy_c30); + write_radio_reg(pi, RADIO_2064_REG026, phy_c31); + + kfree(phy_c32); + kfree(ptr); } void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b) @@ -2818,6 +3814,28 @@ void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b) *b = iqcc[1]; } +static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi) +{ + struct lcnphy_unsign16_struct iqcc0, locc2, locc3, locc4; + + wlc_lcnphy_set_cc(pi, 0, 0, 0); + wlc_lcnphy_set_cc(pi, 2, 0, 0); + wlc_lcnphy_set_cc(pi, 3, 0, 0); + wlc_lcnphy_set_cc(pi, 4, 0, 0); + + wlc_lcnphy_a1(pi, 4, 0, 0); + wlc_lcnphy_a1(pi, 3, 0, 0); + wlc_lcnphy_a1(pi, 2, 3, 2); + wlc_lcnphy_a1(pi, 0, 5, 8); + wlc_lcnphy_a1(pi, 2, 2, 1); + wlc_lcnphy_a1(pi, 0, 4, 3); + + iqcc0 = wlc_lcnphy_get_cc(pi, 0); + locc2 = wlc_lcnphy_get_cc(pi, 2); + locc3 = wlc_lcnphy_get_cc(pi, 3); + locc4 = wlc_lcnphy_get_cc(pi, 4); +} + u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi) { struct phytbl_info tab; @@ -3100,300 +4118,6 @@ static void wlc_lcnphy_afe_clk_init(struct brcms_phy *pi, u8 mode) wlc_lcnphy_toggle_afe_pwdn(pi); } -static bool -wlc_lcnphy_rx_iq_est(struct brcms_phy *pi, - u16 num_samps, - u8 wait_time, struct lcnphy_iq_est *iq_est) -{ - int wait_count = 0; - bool result = true; - u8 phybw40; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5); - - mod_phy_reg(pi, 0x410, (0x1 << 3), (0) << 3); - - mod_phy_reg(pi, 0x482, (0xffff << 0), (num_samps) << 0); - - mod_phy_reg(pi, 0x481, (0xff << 0), ((u16) wait_time) << 0); - - mod_phy_reg(pi, 0x481, (0x1 << 8), (0) << 8); - - mod_phy_reg(pi, 0x481, (0x1 << 9), (1) << 9); - - while (read_phy_reg(pi, 0x481) & (0x1 << 9)) { - - if (wait_count > (10 * 500)) { - result = false; - goto cleanup; - } - udelay(100); - wait_count++; - } - - iq_est->iq_prod = ((u32) read_phy_reg(pi, 0x483) << 16) | - (u32) read_phy_reg(pi, 0x484); - iq_est->i_pwr = ((u32) read_phy_reg(pi, 0x485) << 16) | - (u32) read_phy_reg(pi, 0x486); - iq_est->q_pwr = ((u32) read_phy_reg(pi, 0x487) << 16) | - (u32) read_phy_reg(pi, 0x488); - -cleanup: - mod_phy_reg(pi, 0x410, (0x1 << 3), (1) << 3); - - mod_phy_reg(pi, 0x6da, (0x1 << 5), (0) << 5); - - return result; -} - -static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps) -{ -#define LCNPHY_MIN_RXIQ_PWR 2 - bool result; - u16 a0_new, b0_new; - struct lcnphy_iq_est iq_est = { 0, 0, 0 }; - s32 a, b, temp; - s16 iq_nbits, qq_nbits, arsh, brsh; - s32 iq; - u32 ii, qq; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - a0_new = ((read_phy_reg(pi, 0x645) & (0x3ff << 0)) >> 0); - b0_new = ((read_phy_reg(pi, 0x646) & (0x3ff << 0)) >> 0); - mod_phy_reg(pi, 0x6d1, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x64b, (0x1 << 6), (1) << 6); - - wlc_lcnphy_set_rx_iq_comp(pi, 0, 0); - - result = wlc_lcnphy_rx_iq_est(pi, num_samps, 32, &iq_est); - if (!result) - goto cleanup; - - iq = (s32) iq_est.iq_prod; - ii = iq_est.i_pwr; - qq = iq_est.q_pwr; - - if ((ii + qq) < LCNPHY_MIN_RXIQ_PWR) { - result = false; - goto cleanup; - } - - iq_nbits = wlc_phy_nbits(iq); - qq_nbits = wlc_phy_nbits(qq); - - arsh = 10 - (30 - iq_nbits); - if (arsh >= 0) { - a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); - temp = (s32) (ii >> arsh); - if (temp == 0) - return false; - } else { - a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); - temp = (s32) (ii << -arsh); - if (temp == 0) - return false; - } - a /= temp; - brsh = qq_nbits - 31 + 20; - if (brsh >= 0) { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii >> brsh); - if (temp == 0) - return false; - } else { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii << -brsh); - if (temp == 0) - return false; - } - b /= temp; - b -= a * a; - b = (s32) int_sqrt((unsigned long) b); - b -= (1 << 10); - a0_new = (u16) (a & 0x3ff); - b0_new = (u16) (b & 0x3ff); -cleanup: - - wlc_lcnphy_set_rx_iq_comp(pi, a0_new, b0_new); - - mod_phy_reg(pi, 0x64b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, 0x64b, (0x1 << 3), (1) << 3); - - pi_lcn->lcnphy_cal_results.rxiqcal_coeff_a0 = a0_new; - pi_lcn->lcnphy_cal_results.rxiqcal_coeff_b0 = b0_new; - - return result; -} - -static bool -wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, - const struct lcnphy_rx_iqcomp *iqcomp, - int iqcomp_sz, bool tx_switch, bool rx_switch, int module, - int tx_gain_idx) -{ - struct lcnphy_txgains old_gains; - u16 tx_pwr_ctrl; - u8 tx_gain_index_old = 0; - bool result = false, tx_gain_override_old = false; - u16 i, Core1TxControl_old, RFOverride0_old, - RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, - rfoverride3_old, rfoverride3val_old, rfoverride4_old, - rfoverride4val_old, afectrlovr_old, afectrlovrval_old; - int tia_gain; - u32 received_power, rx_pwr_threshold; - u16 old_sslpnCalibClkEnCtrl, old_sslpnRxFeClkEnCtrl; - u16 values_to_save[11]; - s16 *ptr; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) - return false; - if (module == 2) { - while (iqcomp_sz--) { - if (iqcomp[iqcomp_sz].chan == - CHSPEC_CHANNEL(pi->radio_chanspec)) { - wlc_lcnphy_set_rx_iq_comp(pi, - (u16) - iqcomp[iqcomp_sz].a, - (u16) - iqcomp[iqcomp_sz].b); - result = true; - break; - } - } - goto cal_done; - } - - if (module == 1) { - - tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - for (i = 0; i < 11; i++) - values_to_save[i] = - read_radio_reg(pi, rxiq_cal_rf_reg[i]); - Core1TxControl_old = read_phy_reg(pi, 0x631); - - or_phy_reg(pi, 0x631, 0x0015); - - RFOverride0_old = read_phy_reg(pi, 0x44c); - RFOverrideVal0_old = read_phy_reg(pi, 0x44d); - rfoverride2_old = read_phy_reg(pi, 0x4b0); - rfoverride2val_old = read_phy_reg(pi, 0x4b1); - rfoverride3_old = read_phy_reg(pi, 0x4f9); - rfoverride3val_old = read_phy_reg(pi, 0x4fa); - rfoverride4_old = read_phy_reg(pi, 0x938); - rfoverride4val_old = read_phy_reg(pi, 0x939); - afectrlovr_old = read_phy_reg(pi, 0x43b); - afectrlovrval_old = read_phy_reg(pi, 0x43c); - old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - old_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); - - tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); - if (tx_gain_override_old) { - wlc_lcnphy_get_tx_gain(pi, &old_gains); - tx_gain_index_old = pi_lcn->lcnphy_current_index; - } - - wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_idx); - - mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); - - mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); - - write_radio_reg(pi, RADIO_2064_REG116, 0x06); - write_radio_reg(pi, RADIO_2064_REG12C, 0x07); - write_radio_reg(pi, RADIO_2064_REG06A, 0xd3); - write_radio_reg(pi, RADIO_2064_REG098, 0x03); - write_radio_reg(pi, RADIO_2064_REG00B, 0x7); - mod_radio_reg(pi, RADIO_2064_REG113, 1 << 4, 1 << 4); - write_radio_reg(pi, RADIO_2064_REG01D, 0x01); - write_radio_reg(pi, RADIO_2064_REG114, 0x01); - write_radio_reg(pi, RADIO_2064_REG02E, 0x10); - write_radio_reg(pi, RADIO_2064_REG12A, 0x08); - - mod_phy_reg(pi, 0x938, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x939, (0x1 << 0), 0 << 0); - mod_phy_reg(pi, 0x938, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x939, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x938, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x939, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x938, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x939, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x938, (0x1 << 5), 1 << 5); - mod_phy_reg(pi, 0x939, (0x1 << 5), 0 << 5); - - mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); - - wlc_lcnphy_start_tx_tone(pi, 2000, 120, 0); - write_phy_reg(pi, 0x6da, 0xffff); - or_phy_reg(pi, 0x6db, 0x3); - wlc_lcnphy_set_trsw_override(pi, tx_switch, rx_switch); - wlc_lcnphy_rx_gain_override_enable(pi, true); - - tia_gain = 8; - rx_pwr_threshold = 950; - while (tia_gain > 0) { - tia_gain -= 1; - wlc_lcnphy_set_rx_gain_by_distribution(pi, - 0, 0, 2, 2, - (u16) - tia_gain, 1, 0); - udelay(500); - - received_power = - wlc_lcnphy_measure_digital_power(pi, 2000); - if (received_power < rx_pwr_threshold) - break; - } - result = wlc_lcnphy_calc_rx_iq_comp(pi, 0xffff); - - wlc_lcnphy_stop_tx_tone(pi); - - write_phy_reg(pi, 0x631, Core1TxControl_old); - - write_phy_reg(pi, 0x44c, RFOverrideVal0_old); - write_phy_reg(pi, 0x44d, RFOverrideVal0_old); - write_phy_reg(pi, 0x4b0, rfoverride2_old); - write_phy_reg(pi, 0x4b1, rfoverride2val_old); - write_phy_reg(pi, 0x4f9, rfoverride3_old); - write_phy_reg(pi, 0x4fa, rfoverride3val_old); - write_phy_reg(pi, 0x938, rfoverride4_old); - write_phy_reg(pi, 0x939, rfoverride4val_old); - write_phy_reg(pi, 0x43b, afectrlovr_old); - write_phy_reg(pi, 0x43c, afectrlovrval_old); - write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - write_phy_reg(pi, 0x6db, old_sslpnRxFeClkEnCtrl); - - wlc_lcnphy_clear_trsw_override(pi); - - mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); - - for (i = 0; i < 11; i++) - write_radio_reg(pi, rxiq_cal_rf_reg[i], - values_to_save[i]); - - if (tx_gain_override_old) - wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); - else - wlc_lcnphy_disable_tx_gain_override(pi); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); - wlc_lcnphy_rx_gain_override_enable(pi, false); - } - -cal_done: - kfree(ptr); - return result; -} - static void wlc_lcnphy_temp_adj(struct brcms_phy *pi) { } @@ -3559,54 +4283,6 @@ void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi) } -static void -wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) -{ - u8 channel = CHSPEC_CHANNEL(chanspec); - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (channel == 14) - mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); - else - mod_phy_reg(pi, 0x448, (0x3 << 8), (1) << 8); - - pi_lcn->lcnphy_bandedge_corr = 2; - if (channel == 1) - pi_lcn->lcnphy_bandedge_corr = 4; - - if (channel == 1 || channel == 2 || channel == 3 || - channel == 4 || channel == 9 || - channel == 10 || channel == 11 || channel == 12) { - si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03000c04); - si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x0); - si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x200005c0); - - si_pmu_pllupd(pi->sh->sih); - write_phy_reg(pi, 0x942, 0); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, false); - pi_lcn->lcnphy_spurmod = 0; - mod_phy_reg(pi, 0x424, (0xff << 8), (0x1b) << 8); - - write_phy_reg(pi, 0x425, 0x5907); - } else { - si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03140c04); - si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x333333); - si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x202c2820); - - si_pmu_pllupd(pi->sh->sih); - write_phy_reg(pi, 0x942, 0); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, true); - - pi_lcn->lcnphy_spurmod = 0; - mod_phy_reg(pi, 0x424, (0xff << 8), (0x1f) << 8); - - write_phy_reg(pi, 0x425, 0x590a); - } - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); -} - void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi) { s8 index; @@ -3625,554 +4301,6 @@ void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi) } } -static void wlc_lcnphy_set_rx_iq_comp(struct brcms_phy *pi, u16 a, u16 b) -{ - mod_phy_reg(pi, 0x645, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x646, (0x3ff << 0), (b) << 0); - - mod_phy_reg(pi, 0x647, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x648, (0x3ff << 0), (b) << 0); - - mod_phy_reg(pi, 0x649, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x64a, (0x3ff << 0), (b) << 0); - -} - -void wlc_phy_init_lcnphy(struct brcms_phy *pi) -{ - u8 phybw40; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - pi_lcn->lcnphy_cal_counter = 0; - pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense; - - or_phy_reg(pi, 0x44a, 0x80); - and_phy_reg(pi, 0x44a, 0x7f); - - wlc_lcnphy_afe_clk_init(pi, AFE_CLK_INIT_MODE_TXRX2X); - - write_phy_reg(pi, 0x60a, 160); - - write_phy_reg(pi, 0x46a, 25); - - wlc_lcnphy_baseband_init(pi); - - wlc_lcnphy_radio_init(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_lcnphy_tx_pwr_ctrl_init((struct brcms_phy_pub *) pi); - - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); - - si_pmu_regcontrol(pi->sh->sih, 0, 0xf, 0x9); - - si_pmu_chipcontrol(pi->sh->sih, 0, 0xffffffff, 0x03CDDDDD); - - if ((pi->sh->boardflags & BFL_FEM) - && wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - wlc_lcnphy_set_tx_pwr_by_index(pi, FIXED_TXPWR); - - wlc_lcnphy_agc_temp_init(pi); - - wlc_lcnphy_temp_adj(pi); - - mod_phy_reg(pi, 0x448, (0x1 << 14), (1) << 14); - - udelay(100); - mod_phy_reg(pi, 0x448, (0x1 << 14), (0) << 14); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_HW); - pi_lcn->lcnphy_noise_samples = LCNPHY_NOISE_SAMPLES_DEFAULT; - wlc_lcnphy_calib_modes(pi, PHY_PERICAL_PHYINIT); -} - -static void -wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, u16 *values_to_save) -{ - u16 vmid; - int i; - for (i = 0; i < 20; i++) - values_to_save[i] = - read_radio_reg(pi, iqlo_loopback_rf_regs[i]); - - mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); - mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); - - mod_phy_reg(pi, 0x44c, (0x1 << 11), 1 << 11); - mod_phy_reg(pi, 0x44d, (0x1 << 13), 0 << 13); - - mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); - - mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) - and_radio_reg(pi, RADIO_2064_REG03A, 0xFD); - else - and_radio_reg(pi, RADIO_2064_REG03A, 0xF9); - or_radio_reg(pi, RADIO_2064_REG11A, 0x1); - - or_radio_reg(pi, RADIO_2064_REG036, 0x01); - or_radio_reg(pi, RADIO_2064_REG11A, 0x18); - udelay(20); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0); - else - or_radio_reg(pi, RADIO_2064_REG03A, 1); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG03A, 3, 1); - else - or_radio_reg(pi, RADIO_2064_REG03A, 0x3); - } - - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG025, 0xF); - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x4); - else - mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x6); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x4 << 1); - else - mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x6 << 1); - } - - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG005, 0x8); - or_radio_reg(pi, RADIO_2064_REG112, 0x80); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); - or_radio_reg(pi, RADIO_2064_REG11F, 0x44); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG00B, 0x7); - or_radio_reg(pi, RADIO_2064_REG113, 0x10); - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG007, 0x1); - udelay(20); - - vmid = 0x2A6; - mod_radio_reg(pi, RADIO_2064_REG0FC, 0x3 << 0, (vmid >> 8) & 0x3); - write_radio_reg(pi, RADIO_2064_REG0FD, (vmid & 0xff)); - or_radio_reg(pi, RADIO_2064_REG11F, 0x44); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); - udelay(20); - write_radio_reg(pi, RADIO_2064_REG012, 0x02); - or_radio_reg(pi, RADIO_2064_REG112, 0x06); - write_radio_reg(pi, RADIO_2064_REG036, 0x11); - write_radio_reg(pi, RADIO_2064_REG059, 0xcc); - write_radio_reg(pi, RADIO_2064_REG05C, 0x2e); - write_radio_reg(pi, RADIO_2064_REG078, 0xd7); - write_radio_reg(pi, RADIO_2064_REG092, 0x15); -} - -static void -wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, - s16 *ptr, int mode) -{ - u32 curval1, curval2, stpptr, curptr, strptr, val; - u16 sslpnCalibClkEnCtrl, timer; - u16 old_sslpnCalibClkEnCtrl; - s16 imag, real; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - timer = 0; - old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - - curval1 = R_REG(&pi->regs->psm_corectlsts); - ptr[130] = 0; - W_REG(&pi->regs->psm_corectlsts, ((1 << 6) | curval1)); - - W_REG(&pi->regs->smpl_clct_strptr, 0x7E00); - W_REG(&pi->regs->smpl_clct_stpptr, 0x8000); - udelay(20); - curval2 = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, curval2 | 0x30); - - write_phy_reg(pi, 0x555, 0x0); - write_phy_reg(pi, 0x5a6, 0x5); - - write_phy_reg(pi, 0x5a2, (u16) (mode | mode << 6)); - write_phy_reg(pi, 0x5cf, 3); - write_phy_reg(pi, 0x5a5, 0x3); - write_phy_reg(pi, 0x583, 0x0); - write_phy_reg(pi, 0x584, 0x0); - write_phy_reg(pi, 0x585, 0x0fff); - write_phy_reg(pi, 0x586, 0x0000); - - write_phy_reg(pi, 0x580, 0x4501); - - sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - write_phy_reg(pi, 0x6da, (u32) (sslpnCalibClkEnCtrl | 0x2008)); - stpptr = R_REG(&pi->regs->smpl_clct_stpptr); - curptr = R_REG(&pi->regs->smpl_clct_curptr); - do { - udelay(10); - curptr = R_REG(&pi->regs->smpl_clct_curptr); - timer++; - } while ((curptr != stpptr) && (timer < 500)); - - W_REG(&pi->regs->psm_phy_hdr_param, 0x2); - strptr = 0x7E00; - W_REG(&pi->regs->tplatewrptr, strptr); - while (strptr < 0x8000) { - val = R_REG(&pi->regs->tplatewrdata); - imag = ((val >> 16) & 0x3ff); - real = ((val) & 0x3ff); - if (imag > 511) - imag -= 1024; - - if (real > 511) - real -= 1024; - - if (pi_lcn->lcnphy_iqcal_swp_dis) - ptr[(strptr - 0x7E00) / 4] = real; - else - ptr[(strptr - 0x7E00) / 4] = imag; - - if (clip_detect_algo) { - if (imag > thresh || imag < -thresh) { - strptr = 0x8000; - ptr[130] = 1; - } - } - - strptr += 4; - } - - write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - W_REG(&pi->regs->psm_phy_hdr_param, curval2); - W_REG(&pi->regs->psm_corectlsts, curval1); -} - -static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi) -{ - struct lcnphy_unsign16_struct iqcc0, locc2, locc3, locc4; - - wlc_lcnphy_set_cc(pi, 0, 0, 0); - wlc_lcnphy_set_cc(pi, 2, 0, 0); - wlc_lcnphy_set_cc(pi, 3, 0, 0); - wlc_lcnphy_set_cc(pi, 4, 0, 0); - - wlc_lcnphy_a1(pi, 4, 0, 0); - wlc_lcnphy_a1(pi, 3, 0, 0); - wlc_lcnphy_a1(pi, 2, 3, 2); - wlc_lcnphy_a1(pi, 0, 5, 8); - wlc_lcnphy_a1(pi, 2, 2, 1); - wlc_lcnphy_a1(pi, 0, 4, 3); - - iqcc0 = wlc_lcnphy_get_cc(pi, 0); - locc2 = wlc_lcnphy_get_cc(pi, 2); - locc3 = wlc_lcnphy_get_cc(pi, 3); - locc4 = wlc_lcnphy_get_cc(pi, 4); -} - -static void -wlc_lcnphy_set_cc(struct brcms_phy *pi, int cal_type, s16 coeff_x, s16 coeff_y) -{ - u16 di0dq0; - u16 x, y, data_rf; - int k; - switch (cal_type) { - case 0: - wlc_lcnphy_set_tx_iqcc(pi, coeff_x, coeff_y); - break; - case 2: - di0dq0 = (coeff_x & 0xff) << 8 | (coeff_y & 0xff); - wlc_lcnphy_set_tx_locc(pi, di0dq0); - break; - case 3: - k = wlc_lcnphy_calc_floor(coeff_x, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_x, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG089, data_rf); - k = wlc_lcnphy_calc_floor(coeff_y, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_y, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08A, data_rf); - break; - case 4: - k = wlc_lcnphy_calc_floor(coeff_x, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_x, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08B, data_rf); - k = wlc_lcnphy_calc_floor(coeff_y, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_y, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08C, data_rf); - break; - } -} - -static struct lcnphy_unsign16_struct -wlc_lcnphy_get_cc(struct brcms_phy *pi, int cal_type) -{ - u16 a, b, didq; - u8 di0, dq0, ei, eq, fi, fq; - struct lcnphy_unsign16_struct cc; - cc.re = 0; - cc.im = 0; - switch (cal_type) { - case 0: - wlc_lcnphy_get_tx_iqcc(pi, &a, &b); - cc.re = a; - cc.im = b; - break; - case 2: - didq = wlc_lcnphy_get_tx_locc(pi); - di0 = (((didq & 0xff00) << 16) >> 24); - dq0 = (((didq & 0x00ff) << 24) >> 24); - cc.re = (u16) di0; - cc.im = (u16) dq0; - break; - case 3: - wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); - cc.re = (u16) ei; - cc.im = (u16) eq; - break; - case 4: - wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); - cc.re = (u16) fi; - cc.im = (u16) fq; - break; - } - return cc; -} - -static void -wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, - int step_size_lg2) -{ - const struct lcnphy_spb_tone *phy_c1; - struct lcnphy_spb_tone phy_c2; - struct lcnphy_unsign16_struct phy_c3; - int phy_c4, phy_c5, k, l, j, phy_c6; - u16 phy_c7, phy_c8, phy_c9; - s16 phy_c10, phy_c11, phy_c12, phy_c13, phy_c14, phy_c15, phy_c16; - s16 *ptr, phy_c17; - s32 phy_c18, phy_c19; - u32 phy_c20, phy_c21; - bool phy_c22, phy_c23, phy_c24, phy_c25; - u16 phy_c26, phy_c27; - u16 phy_c28, phy_c29, phy_c30; - u16 phy_c31; - u16 *phy_c32; - phy_c21 = 0; - phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; - ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) - return; - - phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); - if (NULL == phy_c32) { - kfree(ptr); - return; - } - phy_c26 = read_phy_reg(pi, 0x6da); - phy_c27 = read_phy_reg(pi, 0x6db); - phy_c31 = read_radio_reg(pi, RADIO_2064_REG026); - write_phy_reg(pi, 0x93d, 0xC0); - - wlc_lcnphy_start_tx_tone(pi, 3750, 88, 0); - write_phy_reg(pi, 0x6da, 0xffff); - or_phy_reg(pi, 0x6db, 0x3); - - wlc_lcnphy_tx_iqlo_loopback(pi, phy_c32); - udelay(500); - phy_c28 = read_phy_reg(pi, 0x938); - phy_c29 = read_phy_reg(pi, 0x4d7); - phy_c30 = read_phy_reg(pi, 0x4d8); - or_phy_reg(pi, 0x938, 0x1 << 2); - or_phy_reg(pi, 0x4d7, 0x1 << 2); - or_phy_reg(pi, 0x4d7, 0x1 << 3); - mod_phy_reg(pi, 0x4d7, (0x7 << 12), 0x2 << 12); - or_phy_reg(pi, 0x4d8, 1 << 0); - or_phy_reg(pi, 0x4d8, 1 << 1); - mod_phy_reg(pi, 0x4d8, (0x3ff << 2), 0x23A << 2); - mod_phy_reg(pi, 0x4d8, (0x7 << 12), 0x7 << 12); - phy_c1 = &lcnphy_spb_tone_3750[0]; - phy_c4 = 32; - - if (num_levels == 0) { - if (cal_type != 0) - num_levels = 4; - else - num_levels = 9; - } - if (step_size_lg2 == 0) { - if (cal_type != 0) - step_size_lg2 = 3; - else - step_size_lg2 = 8; - } - - phy_c7 = (1 << step_size_lg2); - phy_c3 = wlc_lcnphy_get_cc(pi, cal_type); - phy_c15 = (s16) phy_c3.re; - phy_c16 = (s16) phy_c3.im; - if (cal_type == 2) { - if (phy_c3.re > 127) - phy_c15 = phy_c3.re - 256; - if (phy_c3.im > 127) - phy_c16 = phy_c3.im - 256; - } - wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); - udelay(20); - for (phy_c8 = 0; phy_c7 != 0 && phy_c8 < num_levels; phy_c8++) { - phy_c23 = 1; - phy_c22 = 0; - switch (cal_type) { - case 0: - phy_c10 = 511; - break; - case 2: - phy_c10 = 127; - break; - case 3: - phy_c10 = 15; - break; - case 4: - phy_c10 = 15; - break; - } - - phy_c9 = read_phy_reg(pi, 0x93d); - phy_c9 = 2 * phy_c9; - phy_c24 = 0; - phy_c5 = 7; - phy_c25 = 1; - while (1) { - write_radio_reg(pi, RADIO_2064_REG026, - (phy_c5 & 0x7) | ((phy_c5 & 0x7) << 4)); - udelay(50); - phy_c22 = 0; - ptr[130] = 0; - wlc_lcnphy_samp_cap(pi, 1, phy_c9, &ptr[0], 2); - if (ptr[130] == 1) - phy_c22 = 1; - if (phy_c22) - phy_c5 -= 1; - if ((phy_c22 != phy_c24) && (!phy_c25)) - break; - if (!phy_c22) - phy_c5 += 1; - if (phy_c5 <= 0 || phy_c5 >= 7) - break; - phy_c24 = phy_c22; - phy_c25 = 0; - } - - if (phy_c5 < 0) - phy_c5 = 0; - else if (phy_c5 > 7) - phy_c5 = 7; - - for (k = -phy_c7; k <= phy_c7; k += phy_c7) { - for (l = -phy_c7; l <= phy_c7; l += phy_c7) { - phy_c11 = phy_c15 + k; - phy_c12 = phy_c16 + l; - - if (phy_c11 < -phy_c10) - phy_c11 = -phy_c10; - else if (phy_c11 > phy_c10) - phy_c11 = phy_c10; - if (phy_c12 < -phy_c10) - phy_c12 = -phy_c10; - else if (phy_c12 > phy_c10) - phy_c12 = phy_c10; - wlc_lcnphy_set_cc(pi, cal_type, phy_c11, - phy_c12); - udelay(20); - wlc_lcnphy_samp_cap(pi, 0, 0, ptr, 2); - - phy_c18 = 0; - phy_c19 = 0; - for (j = 0; j < 128; j++) { - if (cal_type != 0) - phy_c6 = j % phy_c4; - else - phy_c6 = (2 * j) % phy_c4; - - phy_c2.re = phy_c1[phy_c6].re; - phy_c2.im = phy_c1[phy_c6].im; - phy_c17 = ptr[j]; - phy_c18 = phy_c18 + phy_c17 * phy_c2.re; - phy_c19 = phy_c19 + phy_c17 * phy_c2.im; - } - - phy_c18 = phy_c18 >> 10; - phy_c19 = phy_c19 >> 10; - phy_c20 = ((phy_c18 * phy_c18) + - (phy_c19 * phy_c19)); - - if (phy_c23 || phy_c20 < phy_c21) { - phy_c21 = phy_c20; - phy_c13 = phy_c11; - phy_c14 = phy_c12; - } - phy_c23 = 0; - } - } - phy_c23 = 1; - phy_c15 = phy_c13; - phy_c16 = phy_c14; - phy_c7 = phy_c7 >> 1; - wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); - udelay(20); - } - goto cleanup; -cleanup: - wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, phy_c32); - wlc_lcnphy_stop_tx_tone(pi); - write_phy_reg(pi, 0x6da, phy_c26); - write_phy_reg(pi, 0x6db, phy_c27); - write_phy_reg(pi, 0x938, phy_c28); - write_phy_reg(pi, 0x4d7, phy_c29); - write_phy_reg(pi, 0x4d8, phy_c30); - write_radio_reg(pi, RADIO_2064_REG026, phy_c31); - - kfree(phy_c32); - kfree(ptr); -} - -static void -wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, u16 *values_to_save) -{ - int i; - - and_phy_reg(pi, 0x44c, 0x0 >> 11); - - and_phy_reg(pi, 0x43b, 0xC); - - for (i = 0; i < 20; i++) - write_radio_reg(pi, iqlo_loopback_rf_regs[i], - values_to_save[i]); -} - static void wlc_lcnphy_load_tx_gain_table(struct brcms_phy *pi, const struct lcnphy_tx_gain_tbl_entry *gain_table) @@ -4259,6 +4387,172 @@ static void wlc_lcnphy_load_rfpower(struct brcms_phy *pi) } } +static void wlc_lcnphy_bu_tweaks(struct brcms_phy *pi) +{ + or_phy_reg(pi, 0x805, 0x1); + + mod_phy_reg(pi, 0x42f, (0x7 << 0), (0x3) << 0); + + mod_phy_reg(pi, 0x030, (0x7 << 0), (0x3) << 0); + + write_phy_reg(pi, 0x414, 0x1e10); + write_phy_reg(pi, 0x415, 0x0640); + + mod_phy_reg(pi, 0x4df, (0xff << 8), -9 << 8); + + or_phy_reg(pi, 0x44a, 0x44); + write_phy_reg(pi, 0x44a, 0x80); + mod_phy_reg(pi, 0x434, (0xff << 0), (0xFD) << 0); + + mod_phy_reg(pi, 0x420, (0xff << 0), (16) << 0); + + if (!(pi->sh->boardrev < 0x1204)) + mod_radio_reg(pi, RADIO_2064_REG09B, 0xF0, 0xF0); + + write_phy_reg(pi, 0x7d6, 0x0902); + mod_phy_reg(pi, 0x429, (0xf << 0), (0x9) << 0); + + mod_phy_reg(pi, 0x429, (0x3f << 4), (0xe) << 4); + + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { + mod_phy_reg(pi, 0x423, (0xff << 0), (0x46) << 0); + + mod_phy_reg(pi, 0x411, (0xff << 0), (1) << 0); + + mod_phy_reg(pi, 0x434, (0xff << 0), (0xFF) << 0); + + mod_phy_reg(pi, 0x656, (0xf << 0), (2) << 0); + + mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); + + mod_radio_reg(pi, RADIO_2064_REG0F7, 0x4, 0x4); + mod_radio_reg(pi, RADIO_2064_REG0F1, 0x3, 0); + mod_radio_reg(pi, RADIO_2064_REG0F2, 0xF8, 0x90); + mod_radio_reg(pi, RADIO_2064_REG0F3, 0x3, 0x2); + mod_radio_reg(pi, RADIO_2064_REG0F3, 0xf0, 0xa0); + + mod_radio_reg(pi, RADIO_2064_REG11F, 0x2, 0x2); + + wlc_lcnphy_clear_tx_power_offsets(pi); + mod_phy_reg(pi, 0x4d0, (0x1ff << 6), (10) << 6); + + } +} + +static void wlc_lcnphy_rcal(struct brcms_phy *pi) +{ + u8 rcal_value; + + and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); + + or_radio_reg(pi, RADIO_2064_REG004, 0x40); + or_radio_reg(pi, RADIO_2064_REG120, 0x10); + + or_radio_reg(pi, RADIO_2064_REG078, 0x80); + or_radio_reg(pi, RADIO_2064_REG129, 0x02); + + or_radio_reg(pi, RADIO_2064_REG057, 0x01); + + or_radio_reg(pi, RADIO_2064_REG05B, 0x02); + mdelay(5); + SPINWAIT(!wlc_radio_2064_rcal_done(pi), 10 * 1000 * 1000); + + if (wlc_radio_2064_rcal_done(pi)) { + rcal_value = (u8) read_radio_reg(pi, RADIO_2064_REG05C); + rcal_value = rcal_value & 0x1f; + } + + and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); + + and_radio_reg(pi, RADIO_2064_REG057, 0xFE); +} + +static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) +{ + u8 dflt_rc_cal_val; + u16 flt_val; + + dflt_rc_cal_val = 7; + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) + dflt_rc_cal_val = 11; + flt_val = + (dflt_rc_cal_val << 10) | (dflt_rc_cal_val << 5) | + (dflt_rc_cal_val); + write_phy_reg(pi, 0x933, flt_val); + write_phy_reg(pi, 0x934, flt_val); + write_phy_reg(pi, 0x935, flt_val); + write_phy_reg(pi, 0x936, flt_val); + write_phy_reg(pi, 0x937, (flt_val & 0x1FF)); + + return; +} + +static void wlc_radio_2064_init(struct brcms_phy *pi) +{ + u32 i; + struct lcnphy_radio_regs *lcnphyregs = NULL; + + lcnphyregs = lcnphy_radio_regs_2064; + + for (i = 0; lcnphyregs[i].address != 0xffff; i++) + if (CHSPEC_IS5G(pi->radio_chanspec) && lcnphyregs[i].do_init_a) + write_radio_reg(pi, + ((lcnphyregs[i].address & 0x3fff) | + RADIO_DEFAULT_CORE), + (u16) lcnphyregs[i].init_a); + else if (lcnphyregs[i].do_init_g) + write_radio_reg(pi, + ((lcnphyregs[i].address & 0x3fff) | + RADIO_DEFAULT_CORE), + (u16) lcnphyregs[i].init_g); + + write_radio_reg(pi, RADIO_2064_REG032, 0x62); + write_radio_reg(pi, RADIO_2064_REG033, 0x19); + + write_radio_reg(pi, RADIO_2064_REG090, 0x10); + + write_radio_reg(pi, RADIO_2064_REG010, 0x00); + + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { + + write_radio_reg(pi, RADIO_2064_REG060, 0x7f); + write_radio_reg(pi, RADIO_2064_REG061, 0x72); + write_radio_reg(pi, RADIO_2064_REG062, 0x7f); + } + + write_radio_reg(pi, RADIO_2064_REG01D, 0x02); + write_radio_reg(pi, RADIO_2064_REG01E, 0x06); + + mod_phy_reg(pi, 0x4ea, (0x7 << 0), 0 << 0); + + mod_phy_reg(pi, 0x4ea, (0x7 << 3), 1 << 3); + + mod_phy_reg(pi, 0x4ea, (0x7 << 6), 2 << 6); + + mod_phy_reg(pi, 0x4ea, (0x7 << 9), 3 << 9); + + mod_phy_reg(pi, 0x4ea, (0x7 << 12), 4 << 12); + + write_phy_reg(pi, 0x4ea, 0x4688); + + mod_phy_reg(pi, 0x4eb, (0x7 << 0), 2 << 0); + + mod_phy_reg(pi, 0x4eb, (0x7 << 6), 0 << 6); + + mod_phy_reg(pi, 0x46a, (0xffff << 0), 25 << 0); + + wlc_lcnphy_set_tx_locc(pi, 0); + + wlc_lcnphy_rcal(pi); + + wlc_lcnphy_rc_cal(pi); +} + +static void wlc_lcnphy_radio_init(struct brcms_phy *pi) +{ + wlc_radio_2064_init(pi); +} + static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) { uint idx; @@ -4460,58 +4754,6 @@ static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi) } -static void wlc_lcnphy_bu_tweaks(struct brcms_phy *pi) -{ - or_phy_reg(pi, 0x805, 0x1); - - mod_phy_reg(pi, 0x42f, (0x7 << 0), (0x3) << 0); - - mod_phy_reg(pi, 0x030, (0x7 << 0), (0x3) << 0); - - write_phy_reg(pi, 0x414, 0x1e10); - write_phy_reg(pi, 0x415, 0x0640); - - mod_phy_reg(pi, 0x4df, (0xff << 8), -9 << 8); - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); - mod_phy_reg(pi, 0x434, (0xff << 0), (0xFD) << 0); - - mod_phy_reg(pi, 0x420, (0xff << 0), (16) << 0); - - if (!(pi->sh->boardrev < 0x1204)) - mod_radio_reg(pi, RADIO_2064_REG09B, 0xF0, 0xF0); - - write_phy_reg(pi, 0x7d6, 0x0902); - mod_phy_reg(pi, 0x429, (0xf << 0), (0x9) << 0); - - mod_phy_reg(pi, 0x429, (0x3f << 4), (0xe) << 4); - - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { - mod_phy_reg(pi, 0x423, (0xff << 0), (0x46) << 0); - - mod_phy_reg(pi, 0x411, (0xff << 0), (1) << 0); - - mod_phy_reg(pi, 0x434, (0xff << 0), (0xFF) << 0); - - mod_phy_reg(pi, 0x656, (0xf << 0), (2) << 0); - - mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); - - mod_radio_reg(pi, RADIO_2064_REG0F7, 0x4, 0x4); - mod_radio_reg(pi, RADIO_2064_REG0F1, 0x3, 0); - mod_radio_reg(pi, RADIO_2064_REG0F2, 0xF8, 0x90); - mod_radio_reg(pi, RADIO_2064_REG0F3, 0x3, 0x2); - mod_radio_reg(pi, RADIO_2064_REG0F3, 0xf0, 0xa0); - - mod_radio_reg(pi, RADIO_2064_REG11F, 0x2, 0x2); - - wlc_lcnphy_clear_tx_power_offsets(pi); - mod_phy_reg(pi, 0x4d0, (0x1ff << 6), (10) << 6); - - } -} - static void wlc_lcnphy_baseband_init(struct brcms_phy *pi) { @@ -4522,118 +4764,53 @@ static void wlc_lcnphy_baseband_init(struct brcms_phy *pi) wlc_lcnphy_bu_tweaks(pi); } -static void wlc_radio_2064_init(struct brcms_phy *pi) +void wlc_phy_init_lcnphy(struct brcms_phy *pi) { - u32 i; - struct lcnphy_radio_regs *lcnphyregs = NULL; + u8 phybw40; + struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + phybw40 = CHSPEC_IS40(pi->radio_chanspec); - lcnphyregs = lcnphy_radio_regs_2064; + pi_lcn->lcnphy_cal_counter = 0; + pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense; - for (i = 0; lcnphyregs[i].address != 0xffff; i++) - if (CHSPEC_IS5G(pi->radio_chanspec) && lcnphyregs[i].do_init_a) - write_radio_reg(pi, - ((lcnphyregs[i].address & 0x3fff) | - RADIO_DEFAULT_CORE), - (u16) lcnphyregs[i].init_a); - else if (lcnphyregs[i].do_init_g) - write_radio_reg(pi, - ((lcnphyregs[i].address & 0x3fff) | - RADIO_DEFAULT_CORE), - (u16) lcnphyregs[i].init_g); + or_phy_reg(pi, 0x44a, 0x80); + and_phy_reg(pi, 0x44a, 0x7f); - write_radio_reg(pi, RADIO_2064_REG032, 0x62); - write_radio_reg(pi, RADIO_2064_REG033, 0x19); + wlc_lcnphy_afe_clk_init(pi, AFE_CLK_INIT_MODE_TXRX2X); - write_radio_reg(pi, RADIO_2064_REG090, 0x10); + write_phy_reg(pi, 0x60a, 160); - write_radio_reg(pi, RADIO_2064_REG010, 0x00); + write_phy_reg(pi, 0x46a, 25); - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { + wlc_lcnphy_baseband_init(pi); - write_radio_reg(pi, RADIO_2064_REG060, 0x7f); - write_radio_reg(pi, RADIO_2064_REG061, 0x72); - write_radio_reg(pi, RADIO_2064_REG062, 0x7f); - } + wlc_lcnphy_radio_init(pi); - write_radio_reg(pi, RADIO_2064_REG01D, 0x02); - write_radio_reg(pi, RADIO_2064_REG01E, 0x06); + if (CHSPEC_IS2G(pi->radio_chanspec)) + wlc_lcnphy_tx_pwr_ctrl_init((struct brcms_phy_pub *) pi); - mod_phy_reg(pi, 0x4ea, (0x7 << 0), 0 << 0); + wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); - mod_phy_reg(pi, 0x4ea, (0x7 << 3), 1 << 3); + si_pmu_regcontrol(pi->sh->sih, 0, 0xf, 0x9); - mod_phy_reg(pi, 0x4ea, (0x7 << 6), 2 << 6); + si_pmu_chipcontrol(pi->sh->sih, 0, 0xffffffff, 0x03CDDDDD); - mod_phy_reg(pi, 0x4ea, (0x7 << 9), 3 << 9); + if ((pi->sh->boardflags & BFL_FEM) + && wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) + wlc_lcnphy_set_tx_pwr_by_index(pi, FIXED_TXPWR); - mod_phy_reg(pi, 0x4ea, (0x7 << 12), 4 << 12); + wlc_lcnphy_agc_temp_init(pi); - write_phy_reg(pi, 0x4ea, 0x4688); + wlc_lcnphy_temp_adj(pi); - mod_phy_reg(pi, 0x4eb, (0x7 << 0), 2 << 0); + mod_phy_reg(pi, 0x448, (0x1 << 14), (1) << 14); - mod_phy_reg(pi, 0x4eb, (0x7 << 6), 0 << 6); + udelay(100); + mod_phy_reg(pi, 0x448, (0x1 << 14), (0) << 14); - mod_phy_reg(pi, 0x46a, (0xffff << 0), 25 << 0); - - wlc_lcnphy_set_tx_locc(pi, 0); - - wlc_lcnphy_rcal(pi); - - wlc_lcnphy_rc_cal(pi); -} - -static void wlc_lcnphy_radio_init(struct brcms_phy *pi) -{ - wlc_radio_2064_init(pi); -} - -static void wlc_lcnphy_rcal(struct brcms_phy *pi) -{ - u8 rcal_value; - - and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); - - or_radio_reg(pi, RADIO_2064_REG004, 0x40); - or_radio_reg(pi, RADIO_2064_REG120, 0x10); - - or_radio_reg(pi, RADIO_2064_REG078, 0x80); - or_radio_reg(pi, RADIO_2064_REG129, 0x02); - - or_radio_reg(pi, RADIO_2064_REG057, 0x01); - - or_radio_reg(pi, RADIO_2064_REG05B, 0x02); - mdelay(5); - SPINWAIT(!wlc_radio_2064_rcal_done(pi), 10 * 1000 * 1000); - - if (wlc_radio_2064_rcal_done(pi)) { - rcal_value = (u8) read_radio_reg(pi, RADIO_2064_REG05C); - rcal_value = rcal_value & 0x1f; - } - - and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); - - and_radio_reg(pi, RADIO_2064_REG057, 0xFE); -} - -static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) -{ - u8 dflt_rc_cal_val; - u16 flt_val; - - dflt_rc_cal_val = 7; - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) - dflt_rc_cal_val = 11; - flt_val = - (dflt_rc_cal_val << 10) | (dflt_rc_cal_val << 5) | - (dflt_rc_cal_val); - write_phy_reg(pi, 0x933, flt_val); - write_phy_reg(pi, 0x934, flt_val); - write_phy_reg(pi, 0x935, flt_val); - write_phy_reg(pi, 0x936, flt_val); - write_phy_reg(pi, 0x937, (flt_val & 0x1FF)); - - return; + wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_HW); + pi_lcn->lcnphy_noise_samples = LCNPHY_NOISE_SAMPLES_DEFAULT; + wlc_lcnphy_calib_modes(pi, PHY_PERICAL_PHYINIT); } static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) @@ -4772,170 +4949,6 @@ void wlc_2064_vco_cal(struct brcms_phy *pi) mod_radio_reg(pi, RADIO_2064_REG057, 1 << 3, 0); } -static void -wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) -{ - uint i; - const struct chan_info_2064_lcnphy *ci; - u8 rfpll_doubler = 0; - u8 pll_pwrup, pll_pwrup_ovr; - s32 qFxtal, qFref, qFvco, qFcal; - u8 d15, d16, f16, e44, e45; - u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; - u16 loop_bw, d30, setCount; - - ci = &chan_info_2064_lcnphy[0]; - rfpll_doubler = 1; - - mod_radio_reg(pi, RADIO_2064_REG09D, 0x4, 0x1 << 2); - - write_radio_reg(pi, RADIO_2064_REG09E, 0xf); - if (!rfpll_doubler) { - loop_bw = PLL_2064_LOOP_BW; - d30 = PLL_2064_D30; - } else { - loop_bw = PLL_2064_LOOP_BW_DOUBLER; - d30 = PLL_2064_D30_DOUBLER; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - for (i = 0; i < ARRAY_SIZE(chan_info_2064_lcnphy); i++) - if (chan_info_2064_lcnphy[i].chan == channel) - break; - - if (i >= ARRAY_SIZE(chan_info_2064_lcnphy)) - return; - - ci = &chan_info_2064_lcnphy[i]; - } - - write_radio_reg(pi, RADIO_2064_REG02A, ci->logen_buftune); - - mod_radio_reg(pi, RADIO_2064_REG030, 0x3, ci->logen_rccr_tx); - - mod_radio_reg(pi, RADIO_2064_REG091, 0x3, ci->txrf_mix_tune_ctrl); - - mod_radio_reg(pi, RADIO_2064_REG038, 0xf, ci->pa_input_tune_g); - - mod_radio_reg(pi, RADIO_2064_REG030, 0x3 << 2, - (ci->logen_rccr_rx) << 2); - - mod_radio_reg(pi, RADIO_2064_REG05E, 0xf, ci->pa_rxrf_lna1_freq_tune); - - mod_radio_reg(pi, RADIO_2064_REG05E, (0xf) << 4, - (ci->pa_rxrf_lna2_freq_tune) << 4); - - write_radio_reg(pi, RADIO_2064_REG06C, ci->rxrf_rxrf_spare1); - - pll_pwrup = (u8) read_radio_reg(pi, RADIO_2064_REG044); - pll_pwrup_ovr = (u8) read_radio_reg(pi, RADIO_2064_REG12B); - - or_radio_reg(pi, RADIO_2064_REG044, 0x07); - - or_radio_reg(pi, RADIO_2064_REG12B, (0x07) << 1); - e44 = 0; - e45 = 0; - - fpfd = rfpll_doubler ? (pi->xtalfreq << 1) : (pi->xtalfreq); - if (pi->xtalfreq > 26000000) - e44 = 1; - if (pi->xtalfreq > 52000000) - e45 = 1; - if (e44 == 0) - fcal_div = 1; - else if (e45 == 0) - fcal_div = 2; - else - fcal_div = 4; - fvco3 = (ci->freq * 3); - fref3 = 2 * fpfd; - - qFxtal = wlc_lcnphy_qdiv_roundup(pi->xtalfreq, PLL_2064_MHZ, 16); - qFref = wlc_lcnphy_qdiv_roundup(fpfd, PLL_2064_MHZ, 16); - qFcal = pi->xtalfreq * fcal_div / PLL_2064_MHZ; - qFvco = wlc_lcnphy_qdiv_roundup(fvco3, 2, 16); - - write_radio_reg(pi, RADIO_2064_REG04F, 0x02); - - d15 = (pi->xtalfreq * fcal_div * 4 / 5) / PLL_2064_MHZ - 1; - write_radio_reg(pi, RADIO_2064_REG052, (0x07 & (d15 >> 2))); - write_radio_reg(pi, RADIO_2064_REG053, (d15 & 0x3) << 5); - - d16 = (qFcal * 8 / (d15 + 1)) - 1; - write_radio_reg(pi, RADIO_2064_REG051, d16); - - f16 = ((d16 + 1) * (d15 + 1)) / qFcal; - setCount = f16 * 3 * (ci->freq) / 32 - 1; - mod_radio_reg(pi, RADIO_2064_REG053, (0x0f << 0), - (u8) (setCount >> 8)); - - or_radio_reg(pi, RADIO_2064_REG053, 0x10); - write_radio_reg(pi, RADIO_2064_REG054, (u8) (setCount & 0xff)); - - div_int = ((fvco3 * (PLL_2064_MHZ >> 4)) / fref3) << 4; - - div_frac = ((fvco3 * (PLL_2064_MHZ >> 4)) % fref3) << 4; - while (div_frac >= fref3) { - div_int++; - div_frac -= fref3; - } - div_frac = wlc_lcnphy_qdiv_roundup(div_frac, fref3, 20); - - mod_radio_reg(pi, RADIO_2064_REG045, (0x1f << 0), - (u8) (div_int >> 4)); - mod_radio_reg(pi, RADIO_2064_REG046, (0x1f << 4), - (u8) (div_int << 4)); - mod_radio_reg(pi, RADIO_2064_REG046, (0x0f << 0), - (u8) (div_frac >> 16)); - write_radio_reg(pi, RADIO_2064_REG047, (u8) (div_frac >> 8) & 0xff); - write_radio_reg(pi, RADIO_2064_REG048, (u8) div_frac & 0xff); - - write_radio_reg(pi, RADIO_2064_REG040, 0xfb); - - write_radio_reg(pi, RADIO_2064_REG041, 0x9A); - write_radio_reg(pi, RADIO_2064_REG042, 0xA3); - write_radio_reg(pi, RADIO_2064_REG043, 0x0C); - - { - u8 h29, h23, c28, d29, h28_ten, e30, h30_ten, cp_current; - u16 c29, c38, c30, g30, d28; - c29 = loop_bw; - d29 = 200; - c38 = 1250; - h29 = d29 / c29; - h23 = 1; - c28 = 30; - d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * - (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / - (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) - + PLL_2064_LOW_END_KVCO; - h28_ten = (d28 * 10) / c28; - c30 = 2640; - e30 = (d30 - 680) / 490; - g30 = 680 + (e30 * 490); - h30_ten = (g30 * 10) / c30; - cp_current = ((c38 * h29 * h23 * 100) / h28_ten) / h30_ten; - mod_radio_reg(pi, RADIO_2064_REG03C, 0x3f, cp_current); - } - if (channel >= 1 && channel <= 5) - write_radio_reg(pi, RADIO_2064_REG03C, 0x8); - else - write_radio_reg(pi, RADIO_2064_REG03C, 0x7); - write_radio_reg(pi, RADIO_2064_REG03D, 0x3); - - mod_radio_reg(pi, RADIO_2064_REG044, 0x0c, 0x0c); - udelay(1); - - wlc_2064_vco_cal(pi); - - write_radio_reg(pi, RADIO_2064_REG044, pll_pwrup); - write_radio_reg(pi, RADIO_2064_REG12B, pll_pwrup_ovr); - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { - write_radio_reg(pi, RADIO_2064_REG038, 3); - write_radio_reg(pi, RADIO_2064_REG091, 7); - } -} - bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi) { if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) @@ -5148,80 +5161,3 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) return input_power_db; } - -static int -wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, s16 filt_type) -{ - s16 filt_index = -1; - int j; - - u16 addr[] = { - 0x910, - 0x91e, - 0x91f, - 0x924, - 0x925, - 0x926, - 0x920, - 0x921, - 0x927, - 0x928, - 0x929, - 0x922, - 0x923, - 0x930, - 0x931, - 0x932 - }; - - u16 addr_ofdm[] = { - 0x90f, - 0x900, - 0x901, - 0x906, - 0x907, - 0x908, - 0x902, - 0x903, - 0x909, - 0x90a, - 0x90b, - 0x904, - 0x905, - 0x90c, - 0x90d, - 0x90e - }; - - if (!is_ofdm) { - for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_CCK; j++) { - if (filt_type == LCNPHY_txdigfiltcoeffs_cck[j][0]) { - filt_index = (s16) j; - break; - } - } - - if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr[j], - LCNPHY_txdigfiltcoeffs_cck - [filt_index][j + 1]); - } - } else { - for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_OFDM; j++) { - if (filt_type == LCNPHY_txdigfiltcoeffs_ofdm[j][0]) { - filt_index = (s16) j; - break; - } - } - - if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_ofdm[j], - LCNPHY_txdigfiltcoeffs_ofdm - [filt_index][j + 1]); - } - } - - return (filt_index != -1) ? 0 : -1; -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index c5b7ad40454..cdf61858051 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -159,6 +159,22 @@ #define CCTRL5357_EXTPA (1<<14) /* extPA in ChipControl 1, bit 14 */ #define CCTRL5357_ANT_MUX_2o3 (1<<15) /* 2o3 in ChipControl 1, bit 15 */ +#define NPHY_CAL_TSSISAMPS 64 +#define NPHY_TEST_TONE_FREQ_40MHz 4000 +#define NPHY_TEST_TONE_FREQ_20MHz 2500 + +#define MAX_205x_RCAL_WAITLOOPS 10000 + +#define NPHY_RXCAL_TONEAMP 181 +#define NPHY_RXCAL_TONEFREQ_40MHz 4000 +#define NPHY_RXCAL_TONEFREQ_20MHz 2000 + +#define TXFILT_SHAPING_OFDM20 0 +#define TXFILT_SHAPING_OFDM40 1 +#define TXFILT_SHAPING_CCK 2 +#define TXFILT_DEFAULT_OFDM20 3 +#define TXFILT_DEFAULT_OFDM40 4 + struct nphy_iqcal_params { u16 txlpf; u16 txgm; @@ -238,10 +254,6 @@ struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz_rev7[] = { {0, 0, 6, 3, 0, 10} }; -#define NPHY_RXCAL_TONEAMP 181 -#define NPHY_RXCAL_TONEFREQ_40MHz 4000 -#define NPHY_RXCAL_TONEFREQ_20MHz 2000 - enum { NPHY_RXCAL_GAIN_INIT = 0, NPHY_RXCAL_GAIN_UP, @@ -254,12 +266,6 @@ enum { (0x1 << 14) | \ (0x1 << 13))) -#define TXFILT_SHAPING_OFDM20 0 -#define TXFILT_SHAPING_OFDM40 1 -#define TXFILT_SHAPING_CCK 2 -#define TXFILT_DEFAULT_OFDM20 3 -#define TXFILT_DEFAULT_OFDM40 4 - u16 NPHY_IPA_REV4_txdigi_filtcoeffs[][NPHY_NUM_DIG_FILT_COEFFS] = { {-377, 137, -407, 208, -1527, 956, 93, 186, 93, 230, -44, 230, 201, -191, 201}, @@ -14107,120 +14113,6 @@ static u8 ant_sw_ctrl_tbl_rev8_2057v7_core1[] = { 0x09, 0x0a, 0x09, 0x0a, 0x15, 0x16 }; -static bool wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, - struct chan_info_nphy_radio2057 **t0, - struct chan_info_nphy_radio205x **t1, - struct chan_info_nphy_radio2057_rev5 **t2, - struct chan_info_nphy_2055 **t3); -static void wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chans, - const struct nphy_sfo_cfg *c); - -static void wlc_phy_adjust_rx_analpfbw_nphy(struct brcms_phy *pi, - u16 reduction_factr); -static void wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, - int ntones, int *, u32 *buf); -static void wlc_phy_adjust_crsminpwr_nphy(struct brcms_phy *pi, u8 minpwr); -static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi); -static void wlc_phy_spurwar_nphy(struct brcms_phy *pi); - -static void wlc_phy_radio_preinit_2055(struct brcms_phy *pi); -static void wlc_phy_radio_init_2055(struct brcms_phy *pi); -static void wlc_phy_radio_postinit_2055(struct brcms_phy *pi); -static void wlc_phy_radio_preinit_205x(struct brcms_phy *pi); -static void wlc_phy_radio_init_2056(struct brcms_phy *pi); -static void wlc_phy_radio_postinit_2056(struct brcms_phy *pi); -static void wlc_phy_radio_init_2057(struct brcms_phy *pi); -static void wlc_phy_radio_postinit_2057(struct brcms_phy *pi); -static void wlc_phy_workarounds_nphy(struct brcms_phy *pi); -static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi); -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi); -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi); -static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi); - -static void wlc_phy_restore_rssical_nphy(struct brcms_phy *pi); -static void wlc_phy_reapply_txcal_coeffs_nphy(struct brcms_phy *pi); -static void wlc_phy_tx_iq_war_nphy(struct brcms_phy *pi); -static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, - struct nphy_txgains tg, u8 type, bool d); -static void wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rxcore, - u16 *rg, u8 type); -static void wlc_phy_update_mimoconfig_nphy(struct brcms_phy *pi, s32 preamble); -static void wlc_phy_savecal_nphy(struct brcms_phy *pi); -static void wlc_phy_restorecal_nphy(struct brcms_phy *pi); -static void wlc_phy_resetcca_nphy(struct brcms_phy *pi); - -static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi); -static void wlc_phy_internal_cal_txgain_nphy(struct brcms_phy *pi); -static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi); -static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core); - -static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi); -static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi); -static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi); -static u16 wlc_phy_ipa_get_bbmult_nphy(struct brcms_phy *pi); -static void wlc_phy_ipa_set_bbmult_nphy(struct brcms_phy *pi, u8 m0, u8 m1); -static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi); - -static void wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32, - u32 e); -static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core); -static void wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *, - enum phy_cal_mode, u8); - -static void -wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state); - -static void wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state, - u8); - -static void wlc_phy_clip_det_nphy(struct brcms_phy *pi, u8 write, u16 *vals); - -static void wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *evts, - u8 *dlys, u8 len); - -static u16 wlc_phy_read_lpf_bw_ctl_nphy(struct brcms_phy *pi, u16 offset); - -static void -wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, - u8 core_mask, u8 off, - u8 override_id); - -static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type); -static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi); - -static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi); -static void wlc_phy_txpwr_nphy_srom_convert(u8 *srom_max, - u16 *pwr_offset, - u8 tmp_max_pwr, u8 rate_start, - u8 rate_end); - -static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi); -static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi); -static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi); -static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi); - -static bool wlc_phy_txpwr_ison_nphy(struct brcms_phy *pi); -static u8 wlc_phy_txpwr_idx_cur_get_nphy(struct brcms_phy *pi, u8 core); -static void wlc_phy_txpwr_idx_cur_set_nphy(struct brcms_phy *pi, u8 idx0, - u8 idx1); -static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal); - -static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi); - -static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi); - -static u16 wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, - u16 max_val, - u8 dac_test_mode); -static void wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, - struct cordic_iq *tone_buf, - u16 num_samps); -static void wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 n, u16 lps, - u16 wait, u8 iq, u8 dac_test_mode, - bool modify_bbmult); - bool wlc_phy_bist_check_phy(struct brcms_phy_pub *pih) { struct brcms_phy *pi = (struct brcms_phy *) pih; @@ -14464,6 +14356,287 @@ void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs) pi->sh->_rifs_phy = rifs; } +static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi) +{ + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + pi->nphy_txpwrctrl = PHY_TPC_HW_ON; + pi->phy_5g_pwrgain = true; + return; + } + + pi->nphy_txpwrctrl = PHY_TPC_HW_OFF; + pi->phy_5g_pwrgain = false; + + if ((pi->sh->boardflags2 & BFL2_TXPWRCTRL_EN) && + NREV_GE(pi->pubpi.phy_rev, 2) && (pi->sh->sromrev >= 4)) + pi->nphy_txpwrctrl = PHY_TPC_HW_ON; + else if ((pi->sh->sromrev >= 4) + && (pi->sh->boardflags2 & BFL2_5G_PWRGAIN)) + pi->phy_5g_pwrgain = true; +} + +static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) +{ + u16 bw40po, cddpo, stbcpo, bwduppo; + uint band_num; + + if (pi->sh->sromrev >= 9) + return; + + bw40po = (u16) PHY_GETINTVAR(pi, "bw40po"); + pi->bw402gpo = bw40po & 0xf; + pi->bw405gpo = (bw40po & 0xf0) >> 4; + pi->bw405glpo = (bw40po & 0xf00) >> 8; + pi->bw405ghpo = (bw40po & 0xf000) >> 12; + + cddpo = (u16) PHY_GETINTVAR(pi, "cddpo"); + pi->cdd2gpo = cddpo & 0xf; + pi->cdd5gpo = (cddpo & 0xf0) >> 4; + pi->cdd5glpo = (cddpo & 0xf00) >> 8; + pi->cdd5ghpo = (cddpo & 0xf000) >> 12; + + stbcpo = (u16) PHY_GETINTVAR(pi, "stbcpo"); + pi->stbc2gpo = stbcpo & 0xf; + pi->stbc5gpo = (stbcpo & 0xf0) >> 4; + pi->stbc5glpo = (stbcpo & 0xf00) >> 8; + pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; + + bwduppo = (u16) PHY_GETINTVAR(pi, "bwduppo"); + pi->bwdup2gpo = bwduppo & 0xf; + pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; + pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; + pi->bwdup5ghpo = (bwduppo & 0xf000) >> 12; + + for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); + band_num++) { + switch (band_num) { + case 0: + + pi->nphy_txpid2g[PHY_CORE_0] = + (u8) PHY_GETINTVAR(pi, "txpid2ga0"); + pi->nphy_txpid2g[PHY_CORE_1] = + (u8) PHY_GETINTVAR(pi, "txpid2ga1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = + (s8) PHY_GETINTVAR(pi, "maxp2ga0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = + (s8) PHY_GETINTVAR(pi, "maxp2ga1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = + (s16) PHY_GETINTVAR(pi, "pa2gw0a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = + (s16) PHY_GETINTVAR(pi, "pa2gw0a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = + (s16) PHY_GETINTVAR(pi, "pa2gw1a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = + (s16) PHY_GETINTVAR(pi, "pa2gw1a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = + (s16) PHY_GETINTVAR(pi, "pa2gw2a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = + (s16) PHY_GETINTVAR(pi, "pa2gw2a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = + (s8) PHY_GETINTVAR(pi, "itt2ga0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = + (s8) PHY_GETINTVAR(pi, "itt2ga1"); + + pi->cck2gpo = (u16) PHY_GETINTVAR(pi, "cck2gpo"); + + pi->ofdm2gpo = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); + + pi->mcs2gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); + pi->mcs2gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs2gpo1"); + pi->mcs2gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs2gpo2"); + pi->mcs2gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs2gpo3"); + pi->mcs2gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs2gpo4"); + pi->mcs2gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs2gpo5"); + pi->mcs2gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs2gpo6"); + pi->mcs2gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs2gpo7"); + break; + case 1: + + pi->nphy_txpid5g[PHY_CORE_0] = + (u8) PHY_GETINTVAR(pi, "txpid5ga0"); + pi->nphy_txpid5g[PHY_CORE_1] = + (u8) PHY_GETINTVAR(pi, "txpid5ga1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = + (s8) PHY_GETINTVAR(pi, "maxp5ga0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = + (s8) PHY_GETINTVAR(pi, "maxp5ga1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = + (s16) PHY_GETINTVAR(pi, "pa5gw0a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = + (s16) PHY_GETINTVAR(pi, "pa5gw0a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = + (s16) PHY_GETINTVAR(pi, "pa5gw1a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = + (s16) PHY_GETINTVAR(pi, "pa5gw1a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = + (s16) PHY_GETINTVAR(pi, "pa5gw2a0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = + (s16) PHY_GETINTVAR(pi, "pa5gw2a1"); + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = + (s8) PHY_GETINTVAR(pi, "itt5ga0"); + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = + (s8) PHY_GETINTVAR(pi, "itt5ga1"); + + pi->ofdm5gpo = (u32) PHY_GETINTVAR(pi, "ofdm5gpo"); + + pi->mcs5gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs5gpo0"); + pi->mcs5gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs5gpo1"); + pi->mcs5gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs5gpo2"); + pi->mcs5gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs5gpo3"); + pi->mcs5gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs5gpo4"); + pi->mcs5gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs5gpo5"); + pi->mcs5gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs5gpo6"); + pi->mcs5gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs5gpo7"); + break; + case 2: + + pi->nphy_txpid5gl[0] = + (u8) PHY_GETINTVAR(pi, "txpid5gla0"); + pi->nphy_txpid5gl[1] = + (u8) PHY_GETINTVAR(pi, "txpid5gla1"); + pi->nphy_pwrctrl_info[0].max_pwr_5gl = + (s8) PHY_GETINTVAR(pi, "maxp5gla0"); + pi->nphy_pwrctrl_info[1].max_pwr_5gl = + (s8) PHY_GETINTVAR(pi, "maxp5gla1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = + (s16) PHY_GETINTVAR(pi, "pa5glw0a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = + (s16) PHY_GETINTVAR(pi, "pa5glw0a1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = + (s16) PHY_GETINTVAR(pi, "pa5glw1a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = + (s16) PHY_GETINTVAR(pi, "pa5glw1a1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = + (s16) PHY_GETINTVAR(pi, "pa5glw2a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = + (s16) PHY_GETINTVAR(pi, "pa5glw2a1"); + pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; + pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; + + pi->ofdm5glpo = (u32) PHY_GETINTVAR(pi, "ofdm5glpo"); + + pi->mcs5glpo[0] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo0"); + pi->mcs5glpo[1] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo1"); + pi->mcs5glpo[2] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo2"); + pi->mcs5glpo[3] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo3"); + pi->mcs5glpo[4] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo4"); + pi->mcs5glpo[5] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo5"); + pi->mcs5glpo[6] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo6"); + pi->mcs5glpo[7] = + (u16) PHY_GETINTVAR(pi, "mcs5glpo7"); + break; + case 3: + + pi->nphy_txpid5gh[0] = + (u8) PHY_GETINTVAR(pi, "txpid5gha0"); + pi->nphy_txpid5gh[1] = + (u8) PHY_GETINTVAR(pi, "txpid5gha1"); + pi->nphy_pwrctrl_info[0].max_pwr_5gh = + (s8) PHY_GETINTVAR(pi, "maxp5gha0"); + pi->nphy_pwrctrl_info[1].max_pwr_5gh = + (s8) PHY_GETINTVAR(pi, "maxp5gha1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = + (s16) PHY_GETINTVAR(pi, "pa5ghw0a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = + (s16) PHY_GETINTVAR(pi, "pa5ghw0a1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = + (s16) PHY_GETINTVAR(pi, "pa5ghw1a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = + (s16) PHY_GETINTVAR(pi, "pa5ghw1a1"); + pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = + (s16) PHY_GETINTVAR(pi, "pa5ghw2a0"); + pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = + (s16) PHY_GETINTVAR(pi, "pa5ghw2a1"); + pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; + pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; + + pi->ofdm5ghpo = (u32) PHY_GETINTVAR(pi, "ofdm5ghpo"); + + pi->mcs5ghpo[0] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo0"); + pi->mcs5ghpo[1] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo1"); + pi->mcs5ghpo[2] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo2"); + pi->mcs5ghpo[3] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo3"); + pi->mcs5ghpo[4] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo4"); + pi->mcs5ghpo[5] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo5"); + pi->mcs5ghpo[6] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo6"); + pi->mcs5ghpo[7] = + (u16) PHY_GETINTVAR(pi, "mcs5ghpo7"); + break; + } + } + + wlc_phy_txpwr_apply_nphy(pi); +} + +static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) +{ + + pi->antswitch = (u8) PHY_GETINTVAR(pi, "antswitch"); + pi->aa2g = (u8) PHY_GETINTVAR(pi, "aa2g"); + pi->aa5g = (u8) PHY_GETINTVAR(pi, "aa5g"); + + pi->srom_fem2g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos2g"); + pi->srom_fem2g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain2g"); + pi->srom_fem2g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange2g"); + pi->srom_fem2g.triso = (u8) PHY_GETINTVAR(pi, "triso2g"); + pi->srom_fem2g.antswctrllut = (u8) PHY_GETINTVAR(pi, "antswctl2g"); + + pi->srom_fem5g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos5g"); + pi->srom_fem5g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain5g"); + pi->srom_fem5g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange5g"); + pi->srom_fem5g.triso = (u8) PHY_GETINTVAR(pi, "triso5g"); + if (PHY_GETVAR(pi, "antswctl5g")) + pi->srom_fem5g.antswctrllut = + (u8) PHY_GETINTVAR(pi, "antswctl5g"); + else + pi->srom_fem5g.antswctrllut = + (u8) PHY_GETINTVAR(pi, "antswctl2g"); + + wlc_phy_txpower_ipa_upd(pi); + + pi->phy_txcore_disable_temp = (s16) PHY_GETINTVAR(pi, "tempthresh"); + if (pi->phy_txcore_disable_temp == 0) + pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; + + pi->phy_tempsense_offset = (s8) PHY_GETINTVAR(pi, "tempoffset"); + if (pi->phy_tempsense_offset != 0) { + if (pi->phy_tempsense_offset > + (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) + pi->phy_tempsense_offset = NPHY_SROM_MAXTEMPOFFSET; + else if (pi->phy_tempsense_offset < (NPHY_SROM_TEMPSHIFT + + NPHY_SROM_MINTEMPOFFSET)) + pi->phy_tempsense_offset = NPHY_SROM_MINTEMPOFFSET; + else + pi->phy_tempsense_offset -= NPHY_SROM_TEMPSHIFT; + } + + pi->phy_txcore_enable_temp = + pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; + + pi->phycal_tempdelta = (u8) PHY_GETINTVAR(pi, "phycal_tempdelta"); + if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) + pi->phycal_tempdelta = 0; + + wlc_phy_txpwr_srom_read_ppr_nphy(pi); + + return true; +} + bool wlc_phy_attach_nphy(struct brcms_phy *pi) { uint i; @@ -14516,26 +14689,6 @@ bool wlc_phy_attach_nphy(struct brcms_phy *pi) return true; } -static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi) -{ - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->nphy_txpwrctrl = PHY_TPC_HW_ON; - pi->phy_5g_pwrgain = true; - return; - } - - pi->nphy_txpwrctrl = PHY_TPC_HW_OFF; - pi->phy_5g_pwrgain = false; - - if ((pi->sh->boardflags2 & BFL2_TXPWRCTRL_EN) && - NREV_GE(pi->pubpi.phy_rev, 2) && (pi->sh->sromrev >= 4)) - pi->nphy_txpwrctrl = PHY_TPC_HW_ON; - else if ((pi->sh->sromrev >= 4) - && (pi->sh->boardflags2 & BFL2_5G_PWRGAIN)) - pi->phy_5g_pwrgain = true; -} - static s32 get_rf_pwr_offset(struct brcms_phy *pi, s16 pga_gn, s16 pad_gn) { s32 rfpwr_offset = 0; @@ -14574,362 +14727,6 @@ static s32 get_rf_pwr_offset(struct brcms_phy *pi, s16 pga_gn, s16 pad_gn) return rfpwr_offset; } -void wlc_phy_init_nphy(struct brcms_phy *pi) -{ - u16 val; - u16 clip1_ths[2]; - struct nphy_txgains target_gain; - u8 tx_pwr_ctrl_state; - bool do_nphy_cal = false; - uint core; - uint origidx, intr_val; - struct d11regs *regs; - u32 d11_clk_ctl_st; - bool do_rssi_cal = false; - - core = 0; - - if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) - pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - - if ((ISNPHY(pi)) && (NREV_GE(pi->pubpi.phy_rev, 5)) && - ((pi->sh->chippkg == BCM4717_PKG_ID) || - (pi->sh->chippkg == BCM4718_PKG_ID))) { - if ((pi->sh->boardflags & BFL_EXTLNA) && - (CHSPEC_IS2G(pi->radio_chanspec))) - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol), - 0x40, 0x40); - } - - if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && - CHSPEC_IS40(pi->radio_chanspec)) { - - regs = (struct d11regs *) ai_switch_core(pi->sh->sih, - D11_CORE_ID, &origidx, - &intr_val); - d11_clk_ctl_st = R_REG(®s->clk_ctl_st); - AND_REG(®s->clk_ctl_st, - ~(CCS_FORCEHT | CCS_HTAREQ)); - - W_REG(®s->clk_ctl_st, d11_clk_ctl_st); - - ai_restore_core(pi->sh->sih, origidx, intr_val); - } - - pi->use_int_tx_iqlo_cal_nphy = - (PHY_IPA(pi) || - (NREV_GE(pi->pubpi.phy_rev, 7) || - (NREV_GE(pi->pubpi.phy_rev, 5) - && pi->sh->boardflags2 & BFL2_INTERNDET_TXIQCAL))); - - pi->internal_tx_iqlo_cal_tapoff_intpa_nphy = false; - - pi->nphy_deaf_count = 0; - - wlc_phy_tbl_init_nphy(pi); - - pi->nphy_crsminpwr_adjusted = false; - pi->nphy_noisevars_adjusted = false; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0xe7, 0); - write_phy_reg(pi, 0xec, 0); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_phy_reg(pi, 0x342, 0); - write_phy_reg(pi, 0x343, 0); - write_phy_reg(pi, 0x346, 0); - write_phy_reg(pi, 0x347, 0); - } - write_phy_reg(pi, 0xe5, 0); - write_phy_reg(pi, 0xe6, 0); - } else { - write_phy_reg(pi, 0xec, 0); - } - - write_phy_reg(pi, 0x91, 0); - write_phy_reg(pi, 0x92, 0); - if (NREV_LT(pi->pubpi.phy_rev, 6)) { - write_phy_reg(pi, 0x93, 0); - write_phy_reg(pi, 0x94, 0); - } - - and_phy_reg(pi, 0xa1, ~3); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0x8f, 0); - write_phy_reg(pi, 0xa5, 0); - } else { - write_phy_reg(pi, 0xa5, 0); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x3b); - else if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x40); - - write_phy_reg(pi, 0x203, 32); - write_phy_reg(pi, 0x201, 32); - - if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD) - write_phy_reg(pi, 0x20d, 160); - else - write_phy_reg(pi, 0x20d, 184); - - write_phy_reg(pi, 0x13a, 200); - - write_phy_reg(pi, 0x70, 80); - - write_phy_reg(pi, 0x1ff, 48); - - if (NREV_LT(pi->pubpi.phy_rev, 8)) - wlc_phy_update_mimoconfig_nphy(pi, pi->n_preamble_override); - - wlc_phy_stf_chain_upd_nphy(pi); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - write_phy_reg(pi, 0x180, 0xaa8); - write_phy_reg(pi, 0x181, 0x9a4); - } - - if (PHY_IPA(pi)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), - (pi->nphy_papd_epsilon_offset[core]) << 7); - - } - - wlc_phy_ipa_set_tx_digi_filts_nphy(pi); - } else if (NREV_GE(pi->pubpi.phy_rev, 5)) { - wlc_phy_extpa_set_tx_digi_filts_nphy(pi); - } - - wlc_phy_workarounds_nphy(pi); - - wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); - - val = read_phy_reg(pi, 0x01); - write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); - write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); - wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); - - wlapi_bmac_macphyclk_set(pi->sh->physhim, ON); - - wlc_phy_pa_override_nphy(pi, OFF); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - wlc_phy_pa_override_nphy(pi, ON); - - wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_clip_det_nphy(pi, 0, clip1_ths); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_phy_bphy_init_nphy(pi); - - tx_pwr_ctrl_state = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - wlc_phy_txpwr_fixpower_nphy(pi); - - wlc_phy_txpwrctrl_idle_tssi_nphy(pi); - - wlc_phy_txpwrctrl_pwr_setup_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - u32 *tx_pwrctrl_tbl = NULL; - u16 idx; - s16 pga_gn = 0; - s16 pad_gn = 0; - s32 rfpwr_offset; - - if (PHY_IPA(pi)) { - tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(pi->pubpi.phy_rev, 3)) - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev3; - else if (NREV_IS(pi->pubpi.phy_rev, 4)) - tx_pwrctrl_tbl = - (pi->srom_fem5g.extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA : - nphy_tpc_5GHz_txgain_rev4; - else - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev5; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (pi->pubpi.radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev5; - else if (pi->pubpi.radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev3; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 5) && - (pi->srom_fem2g.extpagain == 3)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_HiPwrEPA; - else - tx_pwrctrl_tbl = - nphy_tpc_txgain_rev3; - } - } - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, - 192, 32, tx_pwrctrl_tbl); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, - 192, 32, tx_pwrctrl_tbl); - - pi->nphy_gmval = (u16) ((*tx_pwrctrl_tbl >> 16) & 0x7000); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - for (idx = 0; idx < 128; idx++) { - pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; - pad_gn = (tx_pwrctrl_tbl[idx] >> 19) & 0x1f; - rfpwr_offset = get_rf_pwr_offset(pi, pga_gn, - pad_gn); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - } - } else { - - for (idx = 0; idx < 128; idx++) { - pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; - if (CHSPEC_IS2G(pi->radio_chanspec)) - rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_2g - [pga_gn]; - else - rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_5g - [pga_gn]; - - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - } - - } - } else { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, - 192, 32, nphy_tpc_txgain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, - 192, 32, nphy_tpc_txgain); - } - - if (pi->sh->phyrxchain != 0x3) - wlc_phy_rxcore_setstate_nphy((struct brcms_phy_pub *) pi, - pi->sh->phyrxchain); - - if (PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_restart(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_rssical_chanspec_2G == 0) : - (pi->nphy_rssical_chanspec_5G == 0); - - if (do_rssi_cal) - wlc_phy_rssi_cal_nphy(pi); - else - wlc_phy_restore_rssical_nphy(pi); - } else { - wlc_phy_rssi_cal_nphy(pi); - } - - if (!SCAN_RM_IN_PROGRESS(pi)) - do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_iqcal_chanspec_2G == 0) : - (pi->nphy_iqcal_chanspec_5G == 0); - - if (!pi->do_initcal) - do_nphy_cal = false; - - if (do_nphy_cal) { - - target_gain = wlc_phy_get_tx_gain_nphy(pi); - - if (pi->antsel_type == ANTSEL_2x3) - wlc_phy_antsel_init((struct brcms_phy_pub *) pi, - true); - - if (pi->nphy_perical != PHY_PERICAL_MPHASE) { - wlc_phy_rssi_cal_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->nphy_cal_orig_pwr_idx[0] = - pi->nphy_txpwrindex[PHY_CORE_0] - . - index_internal; - pi->nphy_cal_orig_pwr_idx[1] = - pi->nphy_txpwrindex[PHY_CORE_1] - . - index_internal; - - wlc_phy_precal_txgain_nphy(pi); - target_gain = - wlc_phy_get_tx_gain_nphy(pi); - } - - if (wlc_phy_cal_txiqlo_nphy - (pi, target_gain, true, - false) == 0) { - if (wlc_phy_cal_rxiq_nphy - (pi, target_gain, 2, - false) == 0) - wlc_phy_savecal_nphy(pi); - - } - } else if (pi->mphase_cal_phase_id == - MPHASE_CAL_STATE_IDLE) { - wlc_phy_cal_perical((struct brcms_phy_pub *) pi, - PHY_PERICAL_PHYINIT); - } - } else { - wlc_phy_restorecal_nphy(pi); - } - - wlc_phy_txpwrctrl_coeff_setup_nphy(pi); - - wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); - - wlc_phy_nphy_tkip_rifs_war(pi, pi->sh->_rifs_phy); - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LE(pi->pubpi.phy_rev, 6)) - - write_phy_reg(pi, 0x70, 50); - - wlc_phy_txlpfbw_nphy(pi); - - wlc_phy_spurwar_nphy(pi); - -} - static void wlc_phy_update_mimoconfig_nphy(struct brcms_phy *pi, s32 preamble) { bool gf_preamble = false; @@ -14948,271 +14745,437 @@ static void wlc_phy_update_mimoconfig_nphy(struct brcms_phy *pi, s32 preamble) write_phy_reg(pi, 0xed, val); } -static void wlc_phy_resetcca_nphy(struct brcms_phy *pi) +static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) { - u16 val; + int j, type; + u16 addr_offset[] = { 0x186, 0x195, 0x2c5}; - wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); + for (type = 0; type < 3; type++) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, addr_offset[type] + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); + } - val = read_phy_reg(pi, 0x01); - write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); - udelay(1); - write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); - - wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); -} - -void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en) -{ - u16 rfctrlintc_override_val; - - if (!en) { - - pi->rfctrlIntc1_save = read_phy_reg(pi, 0x91); - pi->rfctrlIntc2_save = read_phy_reg(pi, 0x92); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - rfctrlintc_override_val = 0x1480; - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; - else - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; - - write_phy_reg(pi, 0x91, rfctrlintc_override_val); - write_phy_reg(pi, 0x92, rfctrlintc_override_val); + if (IS40MHZ(pi)) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, 0x186 + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); } else { - write_phy_reg(pi, 0x91, pi->rfctrlIntc1_save); - write_phy_reg(pi, 0x92, pi->rfctrlIntc2_save); - } + if (CHSPEC_IS5G(pi->radio_chanspec)) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, 0x186 + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[5][j]); + } + if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, 0x2c5 + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[6][j]); + } + } } -void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi) +static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) { + int j; - u16 txrx_chain = - (NPHY_RfseqCoreActv_TxRxChain0 | NPHY_RfseqCoreActv_TxRxChain1); - bool CoreActv_override = false; - - if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN0) { - txrx_chain = NPHY_RfseqCoreActv_TxRxChain0; - CoreActv_override = true; - - if (NREV_LE(pi->pubpi.phy_rev, 2)) - and_phy_reg(pi, 0xa0, ~0x20); - } else if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN1) { - txrx_chain = NPHY_RfseqCoreActv_TxRxChain1; - CoreActv_override = true; - - if (NREV_LE(pi->pubpi.phy_rev, 2)) - or_phy_reg(pi, 0xa0, 0x20); - } - - mod_phy_reg(pi, 0xa2, ((0xf << 0) | (0xf << 4)), txrx_chain); - - if (CoreActv_override) { - pi->nphy_perical = PHY_PERICAL_DISABLE; - or_phy_reg(pi, 0xa1, NPHY_RfseqMode_CoreActv_override); + if (IS40MHZ(pi)) { + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, 0x195 + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[4][j]); } else { - pi->nphy_perical = PHY_PERICAL_MPHASE; - and_phy_reg(pi, 0xa1, ~NPHY_RfseqMode_CoreActv_override); + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, 0x186 + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); } } -void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) +static void +wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, + u8 len) { - u16 regval; - u16 tbl_buf[16]; - uint i; - struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 tbl_opcode; - bool suspend; - - pi->sh->phyrxchain = rxcore_bitmask; - - if (!pi->sh->clk) - return; - - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); + u32 t1_offset, t2_offset; + u8 ctr; + u8 end_event = + NREV_GE(pi->pubpi.phy_rev, + 3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END; + u8 end_dly = 1; if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, true); - regval = read_phy_reg(pi, 0xa2); - regval &= ~(0xf << 4); - regval |= ((u16) (rxcore_bitmask & 0x3)) << 4; - write_phy_reg(pi, 0xa2, regval); + t1_offset = cmd << 4; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t1_offset, 8, + events); + t2_offset = t1_offset + 0x080; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t2_offset, 8, + dlys); - if ((rxcore_bitmask & 0x3) != 0x3) { - - write_phy_reg(pi, 0x20e, 1); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->rx2tx_biasentry == -1) { - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, - ARRAY_SIZE(tbl_buf), 80, - 16, tbl_buf); - - for (i = 0; i < ARRAY_SIZE(tbl_buf); i++) { - if (tbl_buf[i] == - NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS) { - pi->rx2tx_biasentry = (u8) i; - tbl_opcode = - NPHY_REV3_RFSEQ_CMD_NOP; - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_RFSEQ, - 1, i, - 16, - &tbl_opcode); - break; - } else if (tbl_buf[i] == - NPHY_REV3_RFSEQ_CMD_END) - break; - } - } - } - } else { - - write_phy_reg(pi, 0x20e, 30); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->rx2tx_biasentry != -1) { - tbl_opcode = NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, pi->rx2tx_biasentry, - 16, &tbl_opcode); - pi->rx2tx_biasentry = -1; - } - } + for (ctr = len; ctr < 16; ctr++) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + t1_offset + ctr, 8, &end_event); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + t2_offset + ctr, 8, &end_dly); } - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, false); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); } -u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih) +static u16 wlc_phy_read_lpf_bw_ctl_nphy(struct brcms_phy *pi, u16 offset) { - u16 regval, rxen_bits; - struct brcms_phy *pi = (struct brcms_phy *) pih; + u16 lpf_bw_ctl_val = 0; + u16 rx2tx_lpf_rc_lut_offset = 0; - regval = read_phy_reg(pi, 0xa2); - rxen_bits = (regval >> 4) & 0xf; + if (offset == 0) { + if (CHSPEC_IS40(pi->radio_chanspec)) + rx2tx_lpf_rc_lut_offset = 0x159; + else + rx2tx_lpf_rc_lut_offset = 0x154; + } else { + rx2tx_lpf_rc_lut_offset = offset; + } + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + (u32) rx2tx_lpf_rc_lut_offset, 16, + &lpf_bw_ctl_val); - return (u8) rxen_bits; + lpf_bw_ctl_val = lpf_bw_ctl_val & 0x7; + + return lpf_bw_ctl_val; } -bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pi) +static void +wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, + u8 core_mask, u8 off, u8 override_id) { - return PHY_IPA(pi); -} + u8 core_num; + u16 addr = 0, en_addr = 0, val_addr = 0, en_mask = 0, val_mask = 0; + u8 val_shift = 0; -static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) -{ - u8 idx, idx2, i, delta_ind; + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + en_mask = field; + for (core_num = 0; core_num < 2; core_num++) { + if (override_id == NPHY_REV7_RFCTRLOVERRIDE_ID0) { - for (idx = TXP_FIRST_CCK; idx <= TXP_LAST_CCK; idx++) - pi->adj_pwr_tbl_nphy[idx] = pi->tx_power_offset[idx]; + switch (field) { + case (0x1 << 2): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 1); + val_shift = 1; + break; + case (0x1 << 3): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 2); + val_shift = 2; + break; + case (0x1 << 4): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 4); + val_shift = 4; + break; + case (0x1 << 5): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 5); + val_shift = 5; + break; + case (0x1 << 6): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 6); + val_shift = 6; + break; + case (0x1 << 7): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : + 0x7d; + val_mask = (0x1 << 7); + val_shift = 7; + break; + case (0x1 << 10): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0xf8 : + 0xfa; + val_mask = (0x7 << 4); + val_shift = 4; + break; + case (0x1 << 11): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7b : + 0x7e; + val_mask = (0xffff << 0); + val_shift = 0; + break; + case (0x1 << 12): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7c : + 0x7f; + val_mask = (0xffff << 0); + val_shift = 0; + break; + case (0x3 << 13): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x348 : + 0x349; + val_mask = (0xff << 0); + val_shift = 0; + break; + case (0x1 << 13): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x348 : + 0x349; + val_mask = (0xf << 0); + val_shift = 0; + break; + default: + addr = 0xffff; + break; + } + } else if (override_id == + NPHY_REV7_RFCTRLOVERRIDE_ID1) { - for (i = 0; i < 4; i++) { - idx2 = 0; + switch (field) { + case (0x1 << 1): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 1); + val_shift = 1; + break; + case (0x1 << 3): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 3); + val_shift = 3; + break; + case (0x1 << 5): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 5); + val_shift = 5; + break; + case (0x1 << 4): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 4); + val_shift = 4; + break; + case (0x1 << 2): - delta_ind = 0; + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 2); + val_shift = 2; + break; + case (0x1 << 7): - switch (i) { - case 0: + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x7 << 8); + val_shift = 8; + break; + case (0x1 << 11): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 14); + val_shift = 14; + break; + case (0x1 << 10): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 13); + val_shift = 13; + break; + case (0x1 << 9): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 12); + val_shift = 12; + break; + case (0x1 << 8): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 11); + val_shift = 11; + break; + case (0x1 << 6): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 6); + val_shift = 6; + break; + case (0x1 << 0): + en_addr = (core_num == 0) ? 0x342 : + 0x343; + val_addr = (core_num == 0) ? 0x340 : + 0x341; + val_mask = (0x1 << 0); + val_shift = 0; + break; + default: + addr = 0xffff; + break; + } + } else if (override_id == + NPHY_REV7_RFCTRLOVERRIDE_ID2) { - if (CHSPEC_IS40(pi->radio_chanspec) - && NPHY_IS_SROM_REINTERPRET) { - idx = TXP_FIRST_MCS_40_SISO; - } else { - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_OFDM_40_SISO : TXP_FIRST_OFDM; - delta_ind = 1; + switch (field) { + case (0x1 << 3): + en_addr = (core_num == 0) ? 0x346 : + 0x347; + val_addr = (core_num == 0) ? 0x344 : + 0x345; + val_mask = (0x1 << 3); + val_shift = 3; + break; + case (0x1 << 1): + en_addr = (core_num == 0) ? 0x346 : + 0x347; + val_addr = (core_num == 0) ? 0x344 : + 0x345; + val_mask = (0x1 << 1); + val_shift = 1; + break; + case (0x1 << 0): + en_addr = (core_num == 0) ? 0x346 : + 0x347; + val_addr = (core_num == 0) ? 0x344 : + 0x345; + val_mask = (0x1 << 0); + val_shift = 0; + break; + case (0x1 << 2): + en_addr = (core_num == 0) ? 0x346 : + 0x347; + val_addr = (core_num == 0) ? 0x344 : + 0x345; + val_mask = (0x1 << 2); + val_shift = 2; + break; + case (0x1 << 4): + en_addr = (core_num == 0) ? 0x346 : + 0x347; + val_addr = (core_num == 0) ? 0x344 : + 0x345; + val_mask = (0x1 << 4); + val_shift = 4; + break; + default: + addr = 0xffff; + break; + } } - break; - case 1: + if (off) { + and_phy_reg(pi, en_addr, ~en_mask); + and_phy_reg(pi, val_addr, ~val_mask); + } else { - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_CDD : TXP_FIRST_MCS_20_CDD; - break; + if ((core_mask == 0) + || (core_mask & (1 << core_num))) { + or_phy_reg(pi, en_addr, en_mask); - case 2: - - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_STBC : TXP_FIRST_MCS_20_STBC; - break; - - case 3: - - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_SDM : TXP_FIRST_MCS_20_SDM; - break; + if (addr != 0xffff) + mod_phy_reg(pi, val_addr, + val_mask, + (value << + val_shift)); + } + } } - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - idx = idx + delta_ind; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - idx = idx + 1 - delta_ind; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; } } -void wlc_phy_cal_init_nphy(struct brcms_phy *pi) +static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) { + uint core; + int ctr; + s16 gain_delta[2]; + u8 curr_channel; + u16 minmax_gain[2]; + u16 regval[4]; + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + if (pi->nphy_gain_boost) { + if ((CHSPEC_IS2G(pi->radio_chanspec))) { + + gain_delta[0] = 6; + gain_delta[1] = 6; + } else { + + curr_channel = CHSPEC_CHANNEL(pi->radio_chanspec); + gain_delta[0] = + (s16) + PHY_HW_ROUND(((nphy_lnagain_est0[0] * + curr_channel) + + nphy_lnagain_est0[1]), 13); + gain_delta[1] = + (s16) + PHY_HW_ROUND(((nphy_lnagain_est1[0] * + curr_channel) + + nphy_lnagain_est1[1]), 13); + } + } else { + + gain_delta[0] = 0; + gain_delta[1] = 0; + } + + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + if (pi->nphy_elna_gain_config) { + + regval[0] = nphy_def_lnagains[2] + gain_delta[core]; + regval[1] = nphy_def_lnagains[3] + gain_delta[core]; + regval[2] = nphy_def_lnagains[3] + gain_delta[core]; + regval[3] = nphy_def_lnagains[3] + gain_delta[core]; + } else { + for (ctr = 0; ctr < 4; ctr++) + regval[ctr] = + nphy_def_lnagains[ctr] + + gain_delta[core]; + } + wlc_phy_table_write_nphy(pi, core, 4, 8, 16, regval); + + minmax_gain[core] = + (u16) (nphy_def_lnagains[2] + gain_delta[core] + 4); + } + + mod_phy_reg(pi, 0x1e, (0xff << 0), (minmax_gain[0] << 0)); + mod_phy_reg(pi, 0x34, (0xff << 0), (minmax_gain[1] << 0)); + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); } static void @@ -15246,6 +15209,888 @@ static void wlc_phy_war_txchain_upd_nphy(struct brcms_phy *pi, u8 txchain) wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); } +static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) +{ + s8 lna1_gain_db[] = { 8, 13, 17, 22 }; + s8 lna2_gain_db[] = { -2, 7, 11, 15 }; + s8 tia_gain_db[] = { -4, -1, 2, 5, 5, 5, 5, 5, 5, 5 }; + s8 tia_gainbits[] = { + 0x0, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; + + mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); + mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + + mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); + + mod_phy_reg(pi, 0x283, (0xff << 0), (0x3c << 0)); + mod_phy_reg(pi, 0x280, (0xff << 0), (0x3c << 0)); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x8, 8, + lna1_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x8, 8, + lna1_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, 8, + lna2_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, 8, + lna2_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, + tia_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, + tia_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, + tia_gainbits); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, + tia_gainbits); + + write_phy_reg(pi, 0x37, 0x74); + write_phy_reg(pi, 0x2ad, 0x74); + write_phy_reg(pi, 0x38, 0x18); + write_phy_reg(pi, 0x2ae, 0x18); + + write_phy_reg(pi, 0x2b, 0xe8); + write_phy_reg(pi, 0x41, 0xe8); + + if (CHSPEC_IS20(pi->radio_chanspec)) { + + mod_phy_reg(pi, 0x300, (0x3f << 0), (0x12 << 0)); + mod_phy_reg(pi, 0x301, (0x3f << 0), (0x12 << 0)); + } else { + + mod_phy_reg(pi, 0x300, (0x3f << 0), (0x10 << 0)); + mod_phy_reg(pi, 0x301, (0x3f << 0), (0x10 << 0)); + } +} + +static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) +{ + u16 currband; + s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; + s8 *lna1_gain_db = NULL; + s8 *lna1_gain_db_2 = NULL; + s8 *lna2_gain_db = NULL; + s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; + s8 *tia_gain_db; + s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; + s8 *tia_gainbits; + u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; + u16 *rfseq_init_gain; + u16 init_gaincode; + u16 clip1hi_gaincode; + u16 clip1md_gaincode = 0; + u16 clip1md_gaincode_B; + u16 clip1lo_gaincode; + u16 clip1lo_gaincode_B; + u8 crsminl_th = 0; + u8 crsminu_th; + u16 nbclip_th = 0; + u8 w1clip_th; + u16 freq; + s8 nvar_baseline_offset0 = 0, nvar_baseline_offset1 = 0; + u8 chg_nbclip_th = 0; + + mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); + mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + + currband = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; + if (currband == 0) { + + lna1_gain_db = lna1G_gain_db_rev7; + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, + lna1_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, + lna1_gain_db); + + mod_phy_reg(pi, 0x283, (0xff << 0), (0x40 << 0)); + + if (CHSPEC_IS40(pi->radio_chanspec)) { + mod_phy_reg(pi, 0x280, (0xff << 0), (0x3e << 0)); + mod_phy_reg(pi, 0x283, (0xff << 0), (0x3e << 0)); + } + + mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); + + if (CHSPEC_IS20(pi->radio_chanspec)) { + mod_phy_reg(pi, 0x300, (0x3f << 0), (13 << 0)); + mod_phy_reg(pi, 0x301, (0x3f << 0), (13 << 0)); + } + } else { + + init_gaincode = 0x9e; + clip1hi_gaincode = 0x9e; + clip1md_gaincode_B = 0x24; + clip1lo_gaincode = 0x8a; + clip1lo_gaincode_B = 8; + rfseq_init_gain = rfseqA_init_gain_rev7; + + tia_gain_db = tiaA_gain_db_rev7; + tia_gainbits = tiaA_gainbits_rev7; + + freq = CHAN5G_FREQ(CHSPEC_CHANNEL(pi->radio_chanspec)); + if (CHSPEC_IS20(pi->radio_chanspec)) { + + w1clip_th = 25; + clip1md_gaincode = 0x82; + + if ((freq <= 5080) || (freq == 5825)) { + + s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; + s8 lna1A_gain_db_2_rev7[] = { + 11, 17, 22, 25}; + s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; + + crsminu_th = 0x3e; + lna1_gain_db = lna1A_gain_db_rev7; + lna1_gain_db_2 = lna1A_gain_db_2_rev7; + lna2_gain_db = lna2A_gain_db_rev7; + } else if ((freq >= 5500) && (freq <= 5700)) { + + s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; + s8 lna1A_gain_db_2_rev7[] = { + 12, 18, 22, 26}; + s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; + + crsminu_th = 0x45; + clip1md_gaincode_B = 0x14; + nbclip_th = 0xff; + chg_nbclip_th = 1; + lna1_gain_db = lna1A_gain_db_rev7; + lna1_gain_db_2 = lna1A_gain_db_2_rev7; + lna2_gain_db = lna2A_gain_db_rev7; + } else { + + s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; + s8 lna1A_gain_db_2_rev7[] = { + 12, 18, 22, 26}; + s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; + + crsminu_th = 0x41; + lna1_gain_db = lna1A_gain_db_rev7; + lna1_gain_db_2 = lna1A_gain_db_2_rev7; + lna2_gain_db = lna2A_gain_db_rev7; + } + + if (freq <= 4920) { + nvar_baseline_offset0 = 5; + nvar_baseline_offset1 = 5; + } else if ((freq > 4920) && (freq <= 5320)) { + nvar_baseline_offset0 = 3; + nvar_baseline_offset1 = 5; + } else if ((freq > 5320) && (freq <= 5700)) { + nvar_baseline_offset0 = 3; + nvar_baseline_offset1 = 2; + } else { + nvar_baseline_offset0 = 4; + nvar_baseline_offset1 = 0; + } + } else { + + crsminu_th = 0x3a; + crsminl_th = 0x3a; + w1clip_th = 20; + + if ((freq >= 4920) && (freq <= 5320)) { + nvar_baseline_offset0 = 4; + nvar_baseline_offset1 = 5; + } else if ((freq > 5320) && (freq <= 5550)) { + nvar_baseline_offset0 = 4; + nvar_baseline_offset1 = 2; + } else { + nvar_baseline_offset0 = 5; + nvar_baseline_offset1 = 3; + } + } + + write_phy_reg(pi, 0x20, init_gaincode); + write_phy_reg(pi, 0x2a7, init_gaincode); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, + pi->pubpi.phy_corenum, 0x106, 16, + rfseq_init_gain); + + write_phy_reg(pi, 0x22, clip1hi_gaincode); + write_phy_reg(pi, 0x2a9, clip1hi_gaincode); + + write_phy_reg(pi, 0x36, clip1md_gaincode_B); + write_phy_reg(pi, 0x2ac, clip1md_gaincode_B); + + write_phy_reg(pi, 0x37, clip1lo_gaincode); + write_phy_reg(pi, 0x2ad, clip1lo_gaincode); + write_phy_reg(pi, 0x38, clip1lo_gaincode_B); + write_phy_reg(pi, 0x2ae, clip1lo_gaincode_B); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, + tia_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, + tia_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, + tia_gainbits); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, + tia_gainbits); + + mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); + + if (chg_nbclip_th == 1) { + write_phy_reg(pi, 0x2b, nbclip_th); + write_phy_reg(pi, 0x41, nbclip_th); + } + + mod_phy_reg(pi, 0x300, (0x3f << 0), (w1clip_th << 0)); + mod_phy_reg(pi, 0x301, (0x3f << 0), (w1clip_th << 0)); + + mod_phy_reg(pi, 0x2e4, + (0x3f << 0), (nvar_baseline_offset0 << 0)); + + mod_phy_reg(pi, 0x2e4, + (0x3f << 6), (nvar_baseline_offset1 << 6)); + + if (CHSPEC_IS20(pi->radio_chanspec)) { + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, + lna1_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, + lna1_gain_db_2); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, + 8, lna2_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, + 8, lna2_gain_db); + + write_phy_reg(pi, 0x24, clip1md_gaincode); + write_phy_reg(pi, 0x2ab, clip1md_gaincode); + } else { + mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); + } + } +} + +static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) +{ + u16 w1th, hpf_code, currband; + int ctr; + u8 rfseq_updategainu_events[] = { + NPHY_RFSEQ_CMD_RX_GAIN, + NPHY_RFSEQ_CMD_CLR_HIQ_DIS, + NPHY_RFSEQ_CMD_SET_HPF_BW + }; + u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; + s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; + s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; + s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; + s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; + s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; + s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; + s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; + s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; + s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; + s8 *lna1_gain_db = NULL; + s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; + s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; + s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; + s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; + s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; + s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; + s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; + s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; + s8 *lna2_gain_db = NULL; + s8 tiaG_gain_db[] = { + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; + s8 tiaA_gain_db[] = { + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; + s8 tiaA_gain_db_rev4[] = { + 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; + s8 tiaA_gain_db_rev5[] = { + 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; + s8 tiaA_gain_db_rev6[] = { + 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; + s8 *tia_gain_db; + s8 tiaG_gainbits[] = { + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; + s8 tiaA_gainbits[] = { + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; + s8 tiaA_gainbits_rev4[] = { + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; + s8 tiaA_gainbits_rev5[] = { + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; + s8 tiaA_gainbits_rev6[] = { + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; + s8 *tia_gainbits; + s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; + s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; + u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; + u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; + u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; + u16 rfseqG_init_gain_rev5_elna[] = { + 0x013f, 0x013f, 0x013f, 0x013f }; + u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; + u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; + u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; + u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; + u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; + u16 rfseqA_init_gain_rev4_elna[] = { + 0x314f, 0x314f, 0x314f, 0x314f }; + u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; + u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; + u16 *rfseq_init_gain; + u16 initG_gaincode = 0x627e; + u16 initG_gaincode_rev4 = 0x527e; + u16 initG_gaincode_rev5 = 0x427e; + u16 initG_gaincode_rev5_elna = 0x027e; + u16 initG_gaincode_rev6 = 0x527e; + u16 initG_gaincode_rev6_224B0 = 0x427e; + u16 initG_gaincode_rev6_elna = 0x127e; + u16 initA_gaincode = 0x52de; + u16 initA_gaincode_rev4 = 0x629e; + u16 initA_gaincode_rev4_elna = 0x329e; + u16 initA_gaincode_rev5 = 0x729e; + u16 initA_gaincode_rev6 = 0x729e; + u16 init_gaincode; + u16 clip1hiG_gaincode = 0x107e; + u16 clip1hiG_gaincode_rev4 = 0x007e; + u16 clip1hiG_gaincode_rev5 = 0x1076; + u16 clip1hiG_gaincode_rev6 = 0x007e; + u16 clip1hiA_gaincode = 0x00de; + u16 clip1hiA_gaincode_rev4 = 0x029e; + u16 clip1hiA_gaincode_rev5 = 0x029e; + u16 clip1hiA_gaincode_rev6 = 0x029e; + u16 clip1hi_gaincode; + u16 clip1mdG_gaincode = 0x0066; + u16 clip1mdA_gaincode = 0x00ca; + u16 clip1mdA_gaincode_rev4 = 0x1084; + u16 clip1mdA_gaincode_rev5 = 0x2084; + u16 clip1mdA_gaincode_rev6 = 0x2084; + u16 clip1md_gaincode = 0; + u16 clip1loG_gaincode = 0x0074; + u16 clip1loG_gaincode_rev5[] = { + 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c + }; + u16 clip1loG_gaincode_rev6[] = { + 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e + }; + u16 clip1loG_gaincode_rev6_224B0 = 0x1074; + u16 clip1loA_gaincode = 0x00cc; + u16 clip1loA_gaincode_rev4 = 0x0086; + u16 clip1loA_gaincode_rev5 = 0x2086; + u16 clip1loA_gaincode_rev6 = 0x2086; + u16 clip1lo_gaincode; + u8 crsminG_th = 0x18; + u8 crsminG_th_rev5 = 0x18; + u8 crsminG_th_rev6 = 0x18; + u8 crsminA_th = 0x1e; + u8 crsminA_th_rev4 = 0x24; + u8 crsminA_th_rev5 = 0x24; + u8 crsminA_th_rev6 = 0x24; + u8 crsmin_th; + u8 crsminlG_th = 0x18; + u8 crsminlG_th_rev5 = 0x18; + u8 crsminlG_th_rev6 = 0x18; + u8 crsminlA_th = 0x1e; + u8 crsminlA_th_rev4 = 0x24; + u8 crsminlA_th_rev5 = 0x24; + u8 crsminlA_th_rev6 = 0x24; + u8 crsminl_th = 0; + u8 crsminuG_th = 0x18; + u8 crsminuG_th_rev5 = 0x18; + u8 crsminuG_th_rev6 = 0x18; + u8 crsminuA_th = 0x1e; + u8 crsminuA_th_rev4 = 0x24; + u8 crsminuA_th_rev5 = 0x24; + u8 crsminuA_th_rev6 = 0x24; + u8 crsminuA_th_rev6_224B0 = 0x2d; + u8 crsminu_th; + u16 nbclipG_th = 0x20d; + u16 nbclipG_th_rev4 = 0x1a1; + u16 nbclipG_th_rev5 = 0x1d0; + u16 nbclipG_th_rev6 = 0x1d0; + u16 nbclipA_th = 0x1a1; + u16 nbclipA_th_rev4 = 0x107; + u16 nbclipA_th_rev5 = 0x0a9; + u16 nbclipA_th_rev6 = 0x0f0; + u16 nbclip_th = 0; + u8 w1clipG_th = 5; + u8 w1clipG_th_rev5 = 9; + u8 w1clipG_th_rev6 = 5; + u8 w1clipA_th = 25, w1clip_th; + u8 rssi_gain_default = 0x50; + u8 rssiG_gain_rev6_224B0 = 0x50; + u8 rssiA_gain_rev5 = 0x90; + u8 rssiA_gain_rev6 = 0x90; + u8 rssi_gain; + u16 regval[21]; + u8 triso; + + triso = (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g.triso : + pi->srom_fem2g.triso; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (pi->pubpi.radiorev == 5) { + wlc_phy_workarounds_nphy_gainctrl_2057_rev5(pi); + } else if (pi->pubpi.radiorev == 7) { + wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); + + mod_phy_reg(pi, 0x283, (0xff << 0), (0x44 << 0)); + mod_phy_reg(pi, 0x280, (0xff << 0), (0x44 << 0)); + + } else if ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 8)) { + wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); + + if (pi->pubpi.radiorev == 8) { + mod_phy_reg(pi, 0x283, + (0xff << 0), (0x44 << 0)); + mod_phy_reg(pi, 0x280, + (0xff << 0), (0x44 << 0)); + } + } else { + wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); + } + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + mod_phy_reg(pi, 0xa0, (0x1 << 6), (1 << 6)); + + mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); + mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + + currband = + read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; + if (currband == 0) { + if (NREV_GE(pi->pubpi.phy_rev, 6)) { + if (pi->pubpi.radiorev == 11) { + lna1_gain_db = lna1G_gain_db_rev6_224B0; + lna2_gain_db = lna2G_gain_db_rev6_224B0; + rfseq_init_gain = + rfseqG_init_gain_rev6_224B0; + init_gaincode = + initG_gaincode_rev6_224B0; + clip1hi_gaincode = + clip1hiG_gaincode_rev6; + clip1lo_gaincode = + clip1loG_gaincode_rev6_224B0; + nbclip_th = nbclipG_th_rev6; + w1clip_th = w1clipG_th_rev6; + crsmin_th = crsminG_th_rev6; + crsminl_th = crsminlG_th_rev6; + crsminu_th = crsminuG_th_rev6; + rssi_gain = rssiG_gain_rev6_224B0; + } else { + lna1_gain_db = lna1G_gain_db_rev6; + lna2_gain_db = lna2G_gain_db_rev6; + if (pi->sh->boardflags & BFL_EXTLNA) { + + rfseq_init_gain = + rfseqG_init_gain_rev6_elna; + init_gaincode = + initG_gaincode_rev6_elna; + } else { + rfseq_init_gain = + rfseqG_init_gain_rev6; + init_gaincode = + initG_gaincode_rev6; + } + clip1hi_gaincode = + clip1hiG_gaincode_rev6; + switch (triso) { + case 0: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [0]; + break; + case 1: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [1]; + break; + case 2: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [2]; + break; + case 3: + default: + + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [3]; + break; + case 4: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [4]; + break; + case 5: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [5]; + break; + case 6: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [6]; + break; + case 7: + clip1lo_gaincode = + clip1loG_gaincode_rev6 + [7]; + break; + } + nbclip_th = nbclipG_th_rev6; + w1clip_th = w1clipG_th_rev6; + crsmin_th = crsminG_th_rev6; + crsminl_th = crsminlG_th_rev6; + crsminu_th = crsminuG_th_rev6; + rssi_gain = rssi_gain_default; + } + } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { + lna1_gain_db = lna1G_gain_db_rev5; + lna2_gain_db = lna2G_gain_db_rev5; + if (pi->sh->boardflags & BFL_EXTLNA) { + + rfseq_init_gain = + rfseqG_init_gain_rev5_elna; + init_gaincode = + initG_gaincode_rev5_elna; + } else { + rfseq_init_gain = rfseqG_init_gain_rev5; + init_gaincode = initG_gaincode_rev5; + } + clip1hi_gaincode = clip1hiG_gaincode_rev5; + switch (triso) { + case 0: + clip1lo_gaincode = + clip1loG_gaincode_rev5[0]; + break; + case 1: + clip1lo_gaincode = + clip1loG_gaincode_rev5[1]; + break; + case 2: + clip1lo_gaincode = + clip1loG_gaincode_rev5[2]; + break; + case 3: + + clip1lo_gaincode = + clip1loG_gaincode_rev5[3]; + break; + case 4: + clip1lo_gaincode = + clip1loG_gaincode_rev5[4]; + break; + case 5: + clip1lo_gaincode = + clip1loG_gaincode_rev5[5]; + break; + case 6: + clip1lo_gaincode = + clip1loG_gaincode_rev5[6]; + break; + case 7: + clip1lo_gaincode = + clip1loG_gaincode_rev5[7]; + break; + default: + clip1lo_gaincode = + clip1loG_gaincode_rev5[3]; + break; + } + nbclip_th = nbclipG_th_rev5; + w1clip_th = w1clipG_th_rev5; + crsmin_th = crsminG_th_rev5; + crsminl_th = crsminlG_th_rev5; + crsminu_th = crsminuG_th_rev5; + rssi_gain = rssi_gain_default; + } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { + lna1_gain_db = lna1G_gain_db_rev4; + lna2_gain_db = lna2G_gain_db; + rfseq_init_gain = rfseqG_init_gain_rev4; + init_gaincode = initG_gaincode_rev4; + clip1hi_gaincode = clip1hiG_gaincode_rev4; + clip1lo_gaincode = clip1loG_gaincode; + nbclip_th = nbclipG_th_rev4; + w1clip_th = w1clipG_th; + crsmin_th = crsminG_th; + crsminl_th = crsminlG_th; + crsminu_th = crsminuG_th; + rssi_gain = rssi_gain_default; + } else { + lna1_gain_db = lna1G_gain_db; + lna2_gain_db = lna2G_gain_db; + rfseq_init_gain = rfseqG_init_gain; + init_gaincode = initG_gaincode; + clip1hi_gaincode = clip1hiG_gaincode; + clip1lo_gaincode = clip1loG_gaincode; + nbclip_th = nbclipG_th; + w1clip_th = w1clipG_th; + crsmin_th = crsminG_th; + crsminl_th = crsminlG_th; + crsminu_th = crsminuG_th; + rssi_gain = rssi_gain_default; + } + tia_gain_db = tiaG_gain_db; + tia_gainbits = tiaG_gainbits; + clip1md_gaincode = clip1mdG_gaincode; + } else { + if (NREV_GE(pi->pubpi.phy_rev, 6)) { + lna1_gain_db = lna1A_gain_db_rev6; + lna2_gain_db = lna2A_gain_db_rev6; + tia_gain_db = tiaA_gain_db_rev6; + tia_gainbits = tiaA_gainbits_rev6; + rfseq_init_gain = rfseqA_init_gain_rev6; + init_gaincode = initA_gaincode_rev6; + clip1hi_gaincode = clip1hiA_gaincode_rev6; + clip1md_gaincode = clip1mdA_gaincode_rev6; + clip1lo_gaincode = clip1loA_gaincode_rev6; + crsmin_th = crsminA_th_rev6; + crsminl_th = crsminlA_th_rev6; + if ((pi->pubpi.radiorev == 11) && + (CHSPEC_IS40(pi->radio_chanspec) == 0)) + crsminu_th = crsminuA_th_rev6_224B0; + else + crsminu_th = crsminuA_th_rev6; + + nbclip_th = nbclipA_th_rev6; + rssi_gain = rssiA_gain_rev6; + } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { + lna1_gain_db = lna1A_gain_db_rev5; + lna2_gain_db = lna2A_gain_db_rev5; + tia_gain_db = tiaA_gain_db_rev5; + tia_gainbits = tiaA_gainbits_rev5; + rfseq_init_gain = rfseqA_init_gain_rev5; + init_gaincode = initA_gaincode_rev5; + clip1hi_gaincode = clip1hiA_gaincode_rev5; + clip1md_gaincode = clip1mdA_gaincode_rev5; + clip1lo_gaincode = clip1loA_gaincode_rev5; + crsmin_th = crsminA_th_rev5; + crsminl_th = crsminlA_th_rev5; + crsminu_th = crsminuA_th_rev5; + nbclip_th = nbclipA_th_rev5; + rssi_gain = rssiA_gain_rev5; + } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { + lna1_gain_db = lna1A_gain_db_rev4; + lna2_gain_db = lna2A_gain_db_rev4; + tia_gain_db = tiaA_gain_db_rev4; + tia_gainbits = tiaA_gainbits_rev4; + if (pi->sh->boardflags & BFL_EXTLNA_5GHz) { + + rfseq_init_gain = + rfseqA_init_gain_rev4_elna; + init_gaincode = + initA_gaincode_rev4_elna; + } else { + rfseq_init_gain = rfseqA_init_gain_rev4; + init_gaincode = initA_gaincode_rev4; + } + clip1hi_gaincode = clip1hiA_gaincode_rev4; + clip1md_gaincode = clip1mdA_gaincode_rev4; + clip1lo_gaincode = clip1loA_gaincode_rev4; + crsmin_th = crsminA_th_rev4; + crsminl_th = crsminlA_th_rev4; + crsminu_th = crsminuA_th_rev4; + nbclip_th = nbclipA_th_rev4; + rssi_gain = rssi_gain_default; + } else { + lna1_gain_db = lna1A_gain_db; + lna2_gain_db = lna2A_gain_db; + tia_gain_db = tiaA_gain_db; + tia_gainbits = tiaA_gainbits; + rfseq_init_gain = rfseqA_init_gain; + init_gaincode = initA_gaincode; + clip1hi_gaincode = clip1hiA_gaincode; + clip1md_gaincode = clip1mdA_gaincode; + clip1lo_gaincode = clip1loA_gaincode; + crsmin_th = crsminA_th; + crsminl_th = crsminlA_th; + crsminu_th = crsminuA_th; + nbclip_th = nbclipA_th; + rssi_gain = rssi_gain_default; + } + w1clip_th = w1clipA_th; + } + + write_radio_reg(pi, + (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | + RADIO_2056_RX0), 0x17); + write_radio_reg(pi, + (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | + RADIO_2056_RX1), 0x17); + + write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX0), + 0xf0); + write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX1), + 0xf0); + + write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX0), + 0x0); + write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX1), + 0x0); + + write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX0), + rssi_gain); + write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX1), + rssi_gain); + + write_radio_reg(pi, + (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | + RADIO_2056_RX0), 0x17); + write_radio_reg(pi, + (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | + RADIO_2056_RX1), 0x17); + + write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX0), + 0xFF); + write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX1), + 0xFF); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, + 8, lna1_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, + 8, lna1_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, + 8, lna2_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, + 8, lna2_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, + 8, tia_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, + 8, tia_gain_db); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, + 8, tia_gainbits); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, + 8, tia_gainbits); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 6, 0x40, + 8, &lpf_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 6, 0x40, + 8, &lpf_gain_db); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 6, 0x40, + 8, &lpf_gainbits); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 6, 0x40, + 8, &lpf_gainbits); + + write_phy_reg(pi, 0x20, init_gaincode); + write_phy_reg(pi, 0x2a7, init_gaincode); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, + pi->pubpi.phy_corenum, 0x106, 16, + rfseq_init_gain); + + write_phy_reg(pi, 0x22, clip1hi_gaincode); + write_phy_reg(pi, 0x2a9, clip1hi_gaincode); + + write_phy_reg(pi, 0x24, clip1md_gaincode); + write_phy_reg(pi, 0x2ab, clip1md_gaincode); + + write_phy_reg(pi, 0x37, clip1lo_gaincode); + write_phy_reg(pi, 0x2ad, clip1lo_gaincode); + + mod_phy_reg(pi, 0x27d, (0xff << 0), (crsmin_th << 0)); + mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); + mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); + + write_phy_reg(pi, 0x2b, nbclip_th); + write_phy_reg(pi, 0x41, nbclip_th); + + mod_phy_reg(pi, 0x27, (0x3f << 0), (w1clip_th << 0)); + mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1clip_th << 0)); + + write_phy_reg(pi, 0x150, 0x809c); + + } else { + + mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); + mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + + write_phy_reg(pi, 0x2b, 0x84); + write_phy_reg(pi, 0x41, 0x84); + + if (CHSPEC_IS20(pi->radio_chanspec)) { + write_phy_reg(pi, 0x6b, 0x2b); + write_phy_reg(pi, 0x6c, 0x2b); + write_phy_reg(pi, 0x6d, 0x9); + write_phy_reg(pi, 0x6e, 0x9); + } + + w1th = NPHY_RSSICAL_W1_TARGET - 4; + mod_phy_reg(pi, 0x27, (0x3f << 0), (w1th << 0)); + mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1th << 0)); + + if (CHSPEC_IS20(pi->radio_chanspec)) { + mod_phy_reg(pi, 0x1c, (0x1f << 0), (0x1 << 0)); + mod_phy_reg(pi, 0x32, (0x1f << 0), (0x1 << 0)); + + mod_phy_reg(pi, 0x1d, (0x1f << 0), (0x1 << 0)); + mod_phy_reg(pi, 0x33, (0x1f << 0), (0x1 << 0)); + } + + write_phy_reg(pi, 0x150, 0x809c); + + if (pi->nphy_gain_boost) + if ((CHSPEC_IS2G(pi->radio_chanspec)) && + (CHSPEC_IS40(pi->radio_chanspec))) + hpf_code = 4; + else + hpf_code = 5; + else if (CHSPEC_IS40(pi->radio_chanspec)) + hpf_code = 6; + else + hpf_code = 7; + + mod_phy_reg(pi, 0x20, (0x1f << 7), (hpf_code << 7)); + mod_phy_reg(pi, 0x36, (0x1f << 7), (hpf_code << 7)); + + for (ctr = 0; ctr < 4; ctr++) + regval[ctr] = (hpf_code << 8) | 0x7c; + wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); + + wlc_phy_adjust_lnagaintbl_nphy(pi); + + if (pi->nphy_elna_gain_config) { + regval[0] = 0; + regval[1] = 1; + regval[2] = 1; + regval[3] = 1; + wlc_phy_table_write_nphy(pi, 2, 4, 8, 16, regval); + wlc_phy_table_write_nphy(pi, 3, 4, 8, 16, regval); + + for (ctr = 0; ctr < 4; ctr++) + regval[ctr] = (hpf_code << 8) | 0x74; + wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); + } + + if (NREV_IS(pi->pubpi.phy_rev, 2)) { + for (ctr = 0; ctr < 21; ctr++) + regval[ctr] = 3 * ctr; + wlc_phy_table_write_nphy(pi, 0, 21, 32, 16, regval); + wlc_phy_table_write_nphy(pi, 1, 21, 32, 16, regval); + + for (ctr = 0; ctr < 21; ctr++) + regval[ctr] = (u16) ctr; + wlc_phy_table_write_nphy(pi, 2, 21, 32, 16, regval); + wlc_phy_table_write_nphy(pi, 3, 21, 32, 16, regval); + } + + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_UPDATEGAINU, + rfseq_updategainu_events, + rfseq_updategainu_dlys, + sizeof(rfseq_updategainu_events) / + sizeof(rfseq_updategainu_events[0])); + + mod_phy_reg(pi, 0x153, (0xff << 8), (90 << 8)); + + if (CHSPEC_IS2G(pi->radio_chanspec)) + mod_phy_reg(pi, + (NPHY_TO_BPHY_OFF + BPHY_OPTIONAL_MODES), + 0x7f, 0x4); + } +} + static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) { u8 rfseq_rx2tx_events[] = { @@ -16331,1111 +17176,2709 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) wlc_phy_stay_in_carriersearch_nphy(pi, false); } -static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) +static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi) { - u16 w1th, hpf_code, currband; - int ctr; - u8 rfseq_updategainu_events[] = { - NPHY_RFSEQ_CMD_RX_GAIN, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_RFSEQ_CMD_SET_HPF_BW - }; - u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; - s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; - s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; - s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; - s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; - s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; - s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; - s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; - s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; - s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; - s8 *lna1_gain_db = NULL; - s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; - s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; - s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; - s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; - s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; - s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; - s8 *lna2_gain_db = NULL; - s8 tiaG_gain_db[] = { - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; - s8 tiaA_gain_db[] = { - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; - s8 tiaA_gain_db_rev4[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev5[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev6[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 *tia_gain_db; - s8 tiaG_gainbits[] = { - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; - s8 tiaA_gainbits[] = { - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; - s8 tiaA_gainbits_rev4[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev5[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev6[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 *tia_gainbits; - s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; - s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; - u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; - u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev5_elna[] = { - 0x013f, 0x013f, 0x013f, 0x013f }; - u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; - u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; - u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; - u16 rfseqA_init_gain_rev4_elna[] = { - 0x314f, 0x314f, 0x314f, 0x314f }; - u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; - u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; - u16 *rfseq_init_gain; - u16 initG_gaincode = 0x627e; - u16 initG_gaincode_rev4 = 0x527e; - u16 initG_gaincode_rev5 = 0x427e; - u16 initG_gaincode_rev5_elna = 0x027e; - u16 initG_gaincode_rev6 = 0x527e; - u16 initG_gaincode_rev6_224B0 = 0x427e; - u16 initG_gaincode_rev6_elna = 0x127e; - u16 initA_gaincode = 0x52de; - u16 initA_gaincode_rev4 = 0x629e; - u16 initA_gaincode_rev4_elna = 0x329e; - u16 initA_gaincode_rev5 = 0x729e; - u16 initA_gaincode_rev6 = 0x729e; - u16 init_gaincode; - u16 clip1hiG_gaincode = 0x107e; - u16 clip1hiG_gaincode_rev4 = 0x007e; - u16 clip1hiG_gaincode_rev5 = 0x1076; - u16 clip1hiG_gaincode_rev6 = 0x007e; - u16 clip1hiA_gaincode = 0x00de; - u16 clip1hiA_gaincode_rev4 = 0x029e; - u16 clip1hiA_gaincode_rev5 = 0x029e; - u16 clip1hiA_gaincode_rev6 = 0x029e; - u16 clip1hi_gaincode; - u16 clip1mdG_gaincode = 0x0066; - u16 clip1mdA_gaincode = 0x00ca; - u16 clip1mdA_gaincode_rev4 = 0x1084; - u16 clip1mdA_gaincode_rev5 = 0x2084; - u16 clip1mdA_gaincode_rev6 = 0x2084; - u16 clip1md_gaincode = 0; - u16 clip1loG_gaincode = 0x0074; - u16 clip1loG_gaincode_rev5[] = { - 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c - }; - u16 clip1loG_gaincode_rev6[] = { - 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e - }; - u16 clip1loG_gaincode_rev6_224B0 = 0x1074; - u16 clip1loA_gaincode = 0x00cc; - u16 clip1loA_gaincode_rev4 = 0x0086; - u16 clip1loA_gaincode_rev5 = 0x2086; - u16 clip1loA_gaincode_rev6 = 0x2086; - u16 clip1lo_gaincode; - u8 crsminG_th = 0x18; - u8 crsminG_th_rev5 = 0x18; - u8 crsminG_th_rev6 = 0x18; - u8 crsminA_th = 0x1e; - u8 crsminA_th_rev4 = 0x24; - u8 crsminA_th_rev5 = 0x24; - u8 crsminA_th_rev6 = 0x24; - u8 crsmin_th; - u8 crsminlG_th = 0x18; - u8 crsminlG_th_rev5 = 0x18; - u8 crsminlG_th_rev6 = 0x18; - u8 crsminlA_th = 0x1e; - u8 crsminlA_th_rev4 = 0x24; - u8 crsminlA_th_rev5 = 0x24; - u8 crsminlA_th_rev6 = 0x24; - u8 crsminl_th = 0; - u8 crsminuG_th = 0x18; - u8 crsminuG_th_rev5 = 0x18; - u8 crsminuG_th_rev6 = 0x18; - u8 crsminuA_th = 0x1e; - u8 crsminuA_th_rev4 = 0x24; - u8 crsminuA_th_rev5 = 0x24; - u8 crsminuA_th_rev6 = 0x24; - u8 crsminuA_th_rev6_224B0 = 0x2d; - u8 crsminu_th; - u16 nbclipG_th = 0x20d; - u16 nbclipG_th_rev4 = 0x1a1; - u16 nbclipG_th_rev5 = 0x1d0; - u16 nbclipG_th_rev6 = 0x1d0; - u16 nbclipA_th = 0x1a1; - u16 nbclipA_th_rev4 = 0x107; - u16 nbclipA_th_rev5 = 0x0a9; - u16 nbclipA_th_rev6 = 0x0f0; - u16 nbclip_th = 0; - u8 w1clipG_th = 5; - u8 w1clipG_th_rev5 = 9; - u8 w1clipG_th_rev6 = 5; - u8 w1clipA_th = 25, w1clip_th; - u8 rssi_gain_default = 0x50; - u8 rssiG_gain_rev6_224B0 = 0x50; - u8 rssiA_gain_rev5 = 0x90; - u8 rssiA_gain_rev6 = 0x90; - u8 rssi_gain; - u16 regval[21]; - u8 triso; + int j, type = 2; + u16 addr_offset = 0x2c5; - triso = (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g.triso : - pi->srom_fem2g.triso; + for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) + write_phy_reg(pi, addr_offset + j, + NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); +} + +static void wlc_phy_clip_det_nphy(struct brcms_phy *pi, u8 write, u16 *vals) +{ + + if (write == 0) { + vals[0] = read_phy_reg(pi, 0x2c); + vals[1] = read_phy_reg(pi, 0x42); + } else { + write_phy_reg(pi, 0x2c, vals[0]); + write_phy_reg(pi, 0x42, vals[1]); + } +} + +static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) +{ + u8 core; if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (pi->pubpi.radiorev == 5) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev5(pi); - } else if (pi->pubpi.radiorev == 7) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + if (CHSPEC_IS2G(pi->radio_chanspec)) { + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MASTER, 0x5); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MUX, 0xe); - mod_phy_reg(pi, 0x283, (0xff << 0), (0x44 << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (0x44 << 0)); + if (pi->pubpi.radiorev != 5) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, + core, TSSIA, 0); - } else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 8)) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); - - if (pi->pubpi.radiorev == 8) { - mod_phy_reg(pi, 0x283, - (0xff << 0), (0x44 << 0)); - mod_phy_reg(pi, 0x280, - (0xff << 0), (0x44 << 0)); - } - } else { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); - } - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - mod_phy_reg(pi, 0xa0, (0x1 << 6), (1 << 6)); - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - currband = - read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; - if (currband == 0) { - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - if (pi->pubpi.radiorev == 11) { - lna1_gain_db = lna1G_gain_db_rev6_224B0; - lna2_gain_db = lna2G_gain_db_rev6_224B0; - rfseq_init_gain = - rfseqG_init_gain_rev6_224B0; - init_gaincode = - initG_gaincode_rev6_224B0; - clip1hi_gaincode = - clip1hiG_gaincode_rev6; - clip1lo_gaincode = - clip1loG_gaincode_rev6_224B0; - nbclip_th = nbclipG_th_rev6; - w1clip_th = w1clipG_th_rev6; - crsmin_th = crsminG_th_rev6; - crsminl_th = crsminlG_th_rev6; - crsminu_th = crsminuG_th_rev6; - rssi_gain = rssiG_gain_rev6_224B0; - } else { - lna1_gain_db = lna1G_gain_db_rev6; - lna2_gain_db = lna2G_gain_db_rev6; - if (pi->sh->boardflags & BFL_EXTLNA) { - - rfseq_init_gain = - rfseqG_init_gain_rev6_elna; - init_gaincode = - initG_gaincode_rev6_elna; - } else { - rfseq_init_gain = - rfseqG_init_gain_rev6; - init_gaincode = - initG_gaincode_rev6; - } - clip1hi_gaincode = - clip1hiG_gaincode_rev6; - switch (triso) { - case 0: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [0]; - break; - case 1: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [1]; - break; - case 2: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [2]; - break; - case 3: - default: - - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [3]; - break; - case 4: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [4]; - break; - case 5: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [5]; - break; - case 6: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [6]; - break; - case 7: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [7]; - break; - } - nbclip_th = nbclipG_th_rev6; - w1clip_th = w1clipG_th_rev6; - crsmin_th = crsminG_th_rev6; - crsminl_th = crsminlG_th_rev6; - crsminu_th = crsminuG_th_rev6; - rssi_gain = rssi_gain_default; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - lna1_gain_db = lna1G_gain_db_rev5; - lna2_gain_db = lna2G_gain_db_rev5; - if (pi->sh->boardflags & BFL_EXTLNA) { - - rfseq_init_gain = - rfseqG_init_gain_rev5_elna; - init_gaincode = - initG_gaincode_rev5_elna; - } else { - rfseq_init_gain = rfseqG_init_gain_rev5; - init_gaincode = initG_gaincode_rev5; - } - clip1hi_gaincode = clip1hiG_gaincode_rev5; - switch (triso) { - case 0: - clip1lo_gaincode = - clip1loG_gaincode_rev5[0]; - break; - case 1: - clip1lo_gaincode = - clip1loG_gaincode_rev5[1]; - break; - case 2: - clip1lo_gaincode = - clip1loG_gaincode_rev5[2]; - break; - case 3: - - clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; - break; - case 4: - clip1lo_gaincode = - clip1loG_gaincode_rev5[4]; - break; - case 5: - clip1lo_gaincode = - clip1loG_gaincode_rev5[5]; - break; - case 6: - clip1lo_gaincode = - clip1loG_gaincode_rev5[6]; - break; - case 7: - clip1lo_gaincode = - clip1loG_gaincode_rev5[7]; - break; - default: - clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; - break; - } - nbclip_th = nbclipG_th_rev5; - w1clip_th = w1clipG_th_rev5; - crsmin_th = crsminG_th_rev5; - crsminl_th = crsminlG_th_rev5; - crsminu_th = crsminuG_th_rev5; - rssi_gain = rssi_gain_default; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - lna1_gain_db = lna1G_gain_db_rev4; - lna2_gain_db = lna2G_gain_db; - rfseq_init_gain = rfseqG_init_gain_rev4; - init_gaincode = initG_gaincode_rev4; - clip1hi_gaincode = clip1hiG_gaincode_rev4; - clip1lo_gaincode = clip1loG_gaincode; - nbclip_th = nbclipG_th_rev4; - w1clip_th = w1clipG_th; - crsmin_th = crsminG_th; - crsminl_th = crsminlG_th; - crsminu_th = crsminuG_th; - rssi_gain = rssi_gain_default; - } else { - lna1_gain_db = lna1G_gain_db; - lna2_gain_db = lna2G_gain_db; - rfseq_init_gain = rfseqG_init_gain; - init_gaincode = initG_gaincode; - clip1hi_gaincode = clip1hiG_gaincode; - clip1lo_gaincode = clip1loG_gaincode; - nbclip_th = nbclipG_th; - w1clip_th = w1clipG_th; - crsmin_th = crsminG_th; - crsminl_th = crsminlG_th; - crsminu_th = crsminuG_th; - rssi_gain = rssi_gain_default; - } - tia_gain_db = tiaG_gain_db; - tia_gainbits = tiaG_gainbits; - clip1md_gaincode = clip1mdG_gaincode; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - lna1_gain_db = lna1A_gain_db_rev6; - lna2_gain_db = lna2A_gain_db_rev6; - tia_gain_db = tiaA_gain_db_rev6; - tia_gainbits = tiaA_gainbits_rev6; - rfseq_init_gain = rfseqA_init_gain_rev6; - init_gaincode = initA_gaincode_rev6; - clip1hi_gaincode = clip1hiA_gaincode_rev6; - clip1md_gaincode = clip1mdA_gaincode_rev6; - clip1lo_gaincode = clip1loA_gaincode_rev6; - crsmin_th = crsminA_th_rev6; - crsminl_th = crsminlA_th_rev6; - if ((pi->pubpi.radiorev == 11) && - (CHSPEC_IS40(pi->radio_chanspec) == 0)) - crsminu_th = crsminuA_th_rev6_224B0; + if (!NREV_IS(pi->pubpi.phy_rev, 7)) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, + core, TSSIG, 0x1); else - crsminu_th = crsminuA_th_rev6; + WRITE_RADIO_REG3(pi, RADIO_2057, TX, + core, TSSIG, 0x31); + } else { + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MASTER, 0x9); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TX_SSI_MUX, 0xc); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TSSIG, 0); - nbclip_th = nbclipA_th_rev6; - rssi_gain = rssiA_gain_rev6; - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - lna1_gain_db = lna1A_gain_db_rev5; - lna2_gain_db = lna2A_gain_db_rev5; - tia_gain_db = tiaA_gain_db_rev5; - tia_gainbits = tiaA_gainbits_rev5; - rfseq_init_gain = rfseqA_init_gain_rev5; - init_gaincode = initA_gaincode_rev5; - clip1hi_gaincode = clip1hiA_gaincode_rev5; - clip1md_gaincode = clip1mdA_gaincode_rev5; - clip1lo_gaincode = clip1loA_gaincode_rev5; - crsmin_th = crsminA_th_rev5; - crsminl_th = crsminlA_th_rev5; - crsminu_th = crsminuA_th_rev5; - nbclip_th = nbclipA_th_rev5; - rssi_gain = rssiA_gain_rev5; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - lna1_gain_db = lna1A_gain_db_rev4; - lna2_gain_db = lna2A_gain_db_rev4; - tia_gain_db = tiaA_gain_db_rev4; - tia_gainbits = tiaA_gainbits_rev4; - if (pi->sh->boardflags & BFL_EXTLNA_5GHz) { - - rfseq_init_gain = - rfseqA_init_gain_rev4_elna; - init_gaincode = - initA_gaincode_rev4_elna; - } else { - rfseq_init_gain = rfseqA_init_gain_rev4; - init_gaincode = initA_gaincode_rev4; + if (pi->pubpi.radiorev != 5) { + if (!NREV_IS(pi->pubpi.phy_rev, 7)) + WRITE_RADIO_REG3(pi, RADIO_2057, + TX, core, + TSSIA, 0x1); + else + WRITE_RADIO_REG3(pi, RADIO_2057, + TX, core, + TSSIA, 0x31); } - clip1hi_gaincode = clip1hiA_gaincode_rev4; - clip1md_gaincode = clip1mdA_gaincode_rev4; - clip1lo_gaincode = clip1loA_gaincode_rev4; - crsmin_th = crsminA_th_rev4; - crsminl_th = crsminlA_th_rev4; - crsminu_th = crsminuA_th_rev4; - nbclip_th = nbclipA_th_rev4; - rssi_gain = rssi_gain_default; - } else { - lna1_gain_db = lna1A_gain_db; - lna2_gain_db = lna2A_gain_db; - tia_gain_db = tiaA_gain_db; - tia_gainbits = tiaA_gainbits; - rfseq_init_gain = rfseqA_init_gain; - init_gaincode = initA_gaincode; - clip1hi_gaincode = clip1hiA_gaincode; - clip1md_gaincode = clip1mdA_gaincode; - clip1lo_gaincode = clip1loA_gaincode; - crsmin_th = crsminA_th; - crsminl_th = crsminlA_th; - crsminu_th = crsminuA_th; - nbclip_th = nbclipA_th; - rssi_gain = rssi_gain_default; } - w1clip_th = w1clipA_th; + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_VCM_HG, + 0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_IDAC, + 0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_VCM, + 0x3); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, + 0x0); } - - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | - RADIO_2056_RX0), 0x17); - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | - RADIO_2056_RX1), 0x17); - - write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX0), - 0xf0); - write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX1), - 0xf0); - - write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX1), - 0x0); - - write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX0), - rssi_gain); - write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX1), - rssi_gain); - - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | - RADIO_2056_RX0), 0x17); - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | - RADIO_2056_RX1), 0x17); - - write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX0), - 0xFF); - write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX1), - 0xFF); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, - 8, lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, - 8, lna1_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, - 8, lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, - 8, lna2_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, - 8, tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, - 8, tia_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, - 8, tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, - 8, tia_gainbits); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 6, 0x40, - 8, &lpf_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 6, 0x40, - 8, &lpf_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 6, 0x40, - 8, &lpf_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 6, 0x40, - 8, &lpf_gainbits); - - write_phy_reg(pi, 0x20, init_gaincode); - write_phy_reg(pi, 0x2a7, init_gaincode); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - pi->pubpi.phy_corenum, 0x106, 16, - rfseq_init_gain); - - write_phy_reg(pi, 0x22, clip1hi_gaincode); - write_phy_reg(pi, 0x2a9, clip1hi_gaincode); - - write_phy_reg(pi, 0x24, clip1md_gaincode); - write_phy_reg(pi, 0x2ab, clip1md_gaincode); - - write_phy_reg(pi, 0x37, clip1lo_gaincode); - write_phy_reg(pi, 0x2ad, clip1lo_gaincode); - - mod_phy_reg(pi, 0x27d, (0xff << 0), (crsmin_th << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); - mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); - - write_phy_reg(pi, 0x2b, nbclip_th); - write_phy_reg(pi, 0x41, nbclip_th); - - mod_phy_reg(pi, 0x27, (0x3f << 0), (w1clip_th << 0)); - mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1clip_th << 0)); - - write_phy_reg(pi, 0x150, 0x809c); - } else { + WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR31, + (CHSPEC_IS2G(pi->radio_chanspec)) ? 0x128 : + 0x80); + WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR30, 0x0); + WRITE_RADIO_SYN(pi, RADIO_2056, GPIO_MASTER1, 0x29); - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_VCM_HG, + 0x0); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_IDAC, + 0x0); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_VCM, + 0x3); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TX_AMP_DET, + 0x0); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC1, + 0x8); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC2, + 0x0); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC3, + 0x0); - write_phy_reg(pi, 0x2b, 0x84); - write_phy_reg(pi, 0x41, 0x84); + if (CHSPEC_IS2G(pi->radio_chanspec)) { + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TX_SSI_MASTER, 0x5); - if (CHSPEC_IS20(pi->radio_chanspec)) { - write_phy_reg(pi, 0x6b, 0x2b); - write_phy_reg(pi, 0x6c, 0x2b); - write_phy_reg(pi, 0x6d, 0x9); - write_phy_reg(pi, 0x6e, 0x9); + if (pi->pubpi.radiorev != 5) + WRITE_RADIO_REG2(pi, RADIO_2056, TX, + core, TSSIA, 0x0); + if (NREV_GE(pi->pubpi.phy_rev, 5)) + WRITE_RADIO_REG2(pi, RADIO_2056, TX, + core, TSSIG, 0x31); + else + WRITE_RADIO_REG2(pi, RADIO_2056, TX, + core, TSSIG, 0x11); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TX_SSI_MUX, 0xe); + } else { + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TX_SSI_MASTER, 0x9); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TSSIA, 0x31); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TSSIG, 0x0); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + TX_SSI_MUX, 0xc); + } } - - w1th = NPHY_RSSICAL_W1_TARGET - 4; - mod_phy_reg(pi, 0x27, (0x3f << 0), (w1th << 0)); - mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1th << 0)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x1c, (0x1f << 0), (0x1 << 0)); - mod_phy_reg(pi, 0x32, (0x1f << 0), (0x1 << 0)); - - mod_phy_reg(pi, 0x1d, (0x1f << 0), (0x1 << 0)); - mod_phy_reg(pi, 0x33, (0x1f << 0), (0x1 << 0)); - } - - write_phy_reg(pi, 0x150, 0x809c); - - if (pi->nphy_gain_boost) - if ((CHSPEC_IS2G(pi->radio_chanspec)) && - (CHSPEC_IS40(pi->radio_chanspec))) - hpf_code = 4; - else - hpf_code = 5; - else if (CHSPEC_IS40(pi->radio_chanspec)) - hpf_code = 6; - else - hpf_code = 7; - - mod_phy_reg(pi, 0x20, (0x1f << 7), (hpf_code << 7)); - mod_phy_reg(pi, 0x36, (0x1f << 7), (hpf_code << 7)); - - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = (hpf_code << 8) | 0x7c; - wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); - - wlc_phy_adjust_lnagaintbl_nphy(pi); - - if (pi->nphy_elna_gain_config) { - regval[0] = 0; - regval[1] = 1; - regval[2] = 1; - regval[3] = 1; - wlc_phy_table_write_nphy(pi, 2, 4, 8, 16, regval); - wlc_phy_table_write_nphy(pi, 3, 4, 8, 16, regval); - - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = (hpf_code << 8) | 0x74; - wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) { - for (ctr = 0; ctr < 21; ctr++) - regval[ctr] = 3 * ctr; - wlc_phy_table_write_nphy(pi, 0, 21, 32, 16, regval); - wlc_phy_table_write_nphy(pi, 1, 21, 32, 16, regval); - - for (ctr = 0; ctr < 21; ctr++) - regval[ctr] = (u16) ctr; - wlc_phy_table_write_nphy(pi, 2, 21, 32, 16, regval); - wlc_phy_table_write_nphy(pi, 3, 21, 32, 16, regval); - } - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_UPDATEGAINU, - rfseq_updategainu_events, - rfseq_updategainu_dlys, - sizeof(rfseq_updategainu_events) / - sizeof(rfseq_updategainu_events[0])); - - mod_phy_reg(pi, 0x153, (0xff << 8), (90 << 8)); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - mod_phy_reg(pi, - (NPHY_TO_BPHY_OFF + BPHY_OPTIONAL_MODES), - 0x7f, 0x4); } } -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) +static void +wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, + u8 core_mask, u8 off) { - s8 lna1_gain_db[] = { 8, 13, 17, 22 }; - s8 lna2_gain_db[] = { -2, 7, 11, 15 }; - s8 tia_gain_db[] = { -4, -1, 2, 5, 5, 5, 5, 5, 5, 5 }; - s8 tia_gainbits[] = { - 0x0, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; + u8 core_num; + u16 addr = 0, mask = 0, en_addr = 0, val_addr = 0, en_mask = + 0, val_mask = 0; + u8 shift = 0, val_shift = 0; - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); + if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); + en_mask = field; + for (core_num = 0; core_num < 2; core_num++) { - mod_phy_reg(pi, 0x283, (0xff << 0), (0x3c << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (0x3c << 0)); + switch (field) { + case (0x1 << 1): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 0); + val_shift = 0; + break; + case (0x1 << 2): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 1); + val_shift = 1; + break; + case (0x1 << 3): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 2); + val_shift = 2; + break; + case (0x1 << 4): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 4); + val_shift = 4; + break; + case (0x1 << 5): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 5); + val_shift = 5; + break; + case (0x1 << 6): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 6); + val_shift = 6; + break; + case (0x1 << 7): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x1 << 7); + val_shift = 7; + break; + case (0x1 << 8): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x7 << 8); + val_shift = 8; + break; + case (0x1 << 11): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7a : 0x7d; + val_mask = (0x7 << 13); + val_shift = 13; + break; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x8, 8, - lna1_gain_db); + case (0x1 << 9): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0xf8 : 0xfa; + val_mask = (0x7 << 0); + val_shift = 0; + break; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, 8, - lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, 8, - lna2_gain_db); + case (0x1 << 10): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0xf8 : 0xfa; + val_mask = (0x7 << 4); + val_shift = 4; + break; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, - tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, - tia_gain_db); + case (0x1 << 12): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7b : 0x7e; + val_mask = (0xffff << 0); + val_shift = 0; + break; + case (0x1 << 13): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0x7c : 0x7f; + val_mask = (0xffff << 0); + val_shift = 0; + break; + case (0x1 << 14): + en_addr = (core_num == 0) ? 0xe7 : 0xec; + val_addr = (core_num == 0) ? 0xf9 : 0xfb; + val_mask = (0x3 << 6); + val_shift = 6; + break; + case (0x1 << 0): + en_addr = (core_num == 0) ? 0xe5 : 0xe6; + val_addr = (core_num == 0) ? 0xf9 : 0xfb; + val_mask = (0x1 << 15); + val_shift = 15; + break; + default: + addr = 0xffff; + break; + } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, - tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, - tia_gainbits); + if (off) { + and_phy_reg(pi, en_addr, ~en_mask); + and_phy_reg(pi, val_addr, ~val_mask); + } else { - write_phy_reg(pi, 0x37, 0x74); - write_phy_reg(pi, 0x2ad, 0x74); - write_phy_reg(pi, 0x38, 0x18); - write_phy_reg(pi, 0x2ae, 0x18); + if ((core_mask == 0) + || (core_mask & (1 << core_num))) { + or_phy_reg(pi, en_addr, en_mask); - write_phy_reg(pi, 0x2b, 0xe8); - write_phy_reg(pi, 0x41, 0xe8); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - - mod_phy_reg(pi, 0x300, (0x3f << 0), (0x12 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (0x12 << 0)); - } else { - - mod_phy_reg(pi, 0x300, (0x3f << 0), (0x10 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (0x10 << 0)); - } -} - -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) -{ - u16 currband; - s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; - s8 *lna1_gain_db = NULL; - s8 *lna1_gain_db_2 = NULL; - s8 *lna2_gain_db = NULL; - s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; - s8 *tia_gain_db; - s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; - s8 *tia_gainbits; - u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; - u16 *rfseq_init_gain; - u16 init_gaincode; - u16 clip1hi_gaincode; - u16 clip1md_gaincode = 0; - u16 clip1md_gaincode_B; - u16 clip1lo_gaincode; - u16 clip1lo_gaincode_B; - u8 crsminl_th = 0; - u8 crsminu_th; - u16 nbclip_th = 0; - u8 w1clip_th; - u16 freq; - s8 nvar_baseline_offset0 = 0, nvar_baseline_offset1 = 0; - u8 chg_nbclip_th = 0; - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - currband = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; - if (currband == 0) { - - lna1_gain_db = lna1G_gain_db_rev7; - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, - lna1_gain_db); - - mod_phy_reg(pi, 0x283, (0xff << 0), (0x40 << 0)); - - if (CHSPEC_IS40(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x280, (0xff << 0), (0x3e << 0)); - mod_phy_reg(pi, 0x283, (0xff << 0), (0x3e << 0)); - } - - mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x300, (0x3f << 0), (13 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (13 << 0)); + if (addr != 0xffff) + mod_phy_reg(pi, val_addr, + val_mask, + (value << + val_shift)); + } + } } } else { - init_gaincode = 0x9e; - clip1hi_gaincode = 0x9e; - clip1md_gaincode_B = 0x24; - clip1lo_gaincode = 0x8a; - clip1lo_gaincode_B = 8; - rfseq_init_gain = rfseqA_init_gain_rev7; - - tia_gain_db = tiaA_gain_db_rev7; - tia_gainbits = tiaA_gainbits_rev7; - - freq = CHAN5G_FREQ(CHSPEC_CHANNEL(pi->radio_chanspec)); - if (CHSPEC_IS20(pi->radio_chanspec)) { - - w1clip_th = 25; - clip1md_gaincode = 0x82; - - if ((freq <= 5080) || (freq == 5825)) { - - s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; - s8 lna1A_gain_db_2_rev7[] = { - 11, 17, 22, 25}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; - - crsminu_th = 0x3e; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } else if ((freq >= 5500) && (freq <= 5700)) { - - s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; - - crsminu_th = 0x45; - clip1md_gaincode_B = 0x14; - nbclip_th = 0xff; - chg_nbclip_th = 1; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } else { - - s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; - - crsminu_th = 0x41; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } - - if (freq <= 4920) { - nvar_baseline_offset0 = 5; - nvar_baseline_offset1 = 5; - } else if ((freq > 4920) && (freq <= 5320)) { - nvar_baseline_offset0 = 3; - nvar_baseline_offset1 = 5; - } else if ((freq > 5320) && (freq <= 5700)) { - nvar_baseline_offset0 = 3; - nvar_baseline_offset1 = 2; - } else { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 0; - } + if (off) { + and_phy_reg(pi, 0xec, ~field); + value = 0x0; } else { + or_phy_reg(pi, 0xec, field); + } - crsminu_th = 0x3a; - crsminl_th = 0x3a; - w1clip_th = 20; + for (core_num = 0; core_num < 2; core_num++) { - if ((freq >= 4920) && (freq <= 5320)) { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 5; - } else if ((freq > 5320) && (freq <= 5550)) { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 2; - } else { - nvar_baseline_offset0 = 5; - nvar_baseline_offset1 = 3; + switch (field) { + case (0x1 << 1): + case (0x1 << 9): + case (0x1 << 12): + case (0x1 << 13): + case (0x1 << 14): + addr = 0x78; + + core_mask = 0x1; + break; + case (0x1 << 2): + case (0x1 << 3): + case (0x1 << 4): + case (0x1 << 5): + case (0x1 << 6): + case (0x1 << 7): + case (0x1 << 8): + addr = (core_num == 0) ? 0x7a : 0x7d; + break; + case (0x1 << 10): + addr = (core_num == 0) ? 0x7b : 0x7e; + break; + case (0x1 << 11): + addr = (core_num == 0) ? 0x7c : 0x7f; + break; + default: + addr = 0xffff; } + + switch (field) { + case (0x1 << 1): + mask = (0x7 << 3); + shift = 3; + break; + case (0x1 << 9): + mask = (0x1 << 2); + shift = 2; + break; + case (0x1 << 12): + mask = (0x1 << 8); + shift = 8; + break; + case (0x1 << 13): + mask = (0x1 << 9); + shift = 9; + break; + case (0x1 << 14): + mask = (0xf << 12); + shift = 12; + break; + case (0x1 << 2): + mask = (0x1 << 0); + shift = 0; + break; + case (0x1 << 3): + mask = (0x1 << 1); + shift = 1; + break; + case (0x1 << 4): + mask = (0x1 << 2); + shift = 2; + break; + case (0x1 << 5): + mask = (0x3 << 4); + shift = 4; + break; + case (0x1 << 6): + mask = (0x3 << 6); + shift = 6; + break; + case (0x1 << 7): + mask = (0x1 << 8); + shift = 8; + break; + case (0x1 << 8): + mask = (0x1 << 9); + shift = 9; + break; + case (0x1 << 10): + mask = 0x1fff; + shift = 0x0; + break; + case (0x1 << 11): + mask = 0x1fff; + shift = 0x0; + break; + default: + mask = 0x0; + shift = 0x0; + break; + } + + if ((addr != 0xffff) && (core_mask & (1 << core_num))) + mod_phy_reg(pi, addr, mask, (value << shift)); } - write_phy_reg(pi, 0x20, init_gaincode); - write_phy_reg(pi, 0x2a7, init_gaincode); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - pi->pubpi.phy_corenum, 0x106, 16, - rfseq_init_gain); - - write_phy_reg(pi, 0x22, clip1hi_gaincode); - write_phy_reg(pi, 0x2a9, clip1hi_gaincode); - - write_phy_reg(pi, 0x36, clip1md_gaincode_B); - write_phy_reg(pi, 0x2ac, clip1md_gaincode_B); - - write_phy_reg(pi, 0x37, clip1lo_gaincode); - write_phy_reg(pi, 0x2ad, clip1lo_gaincode); - write_phy_reg(pi, 0x38, clip1lo_gaincode_B); - write_phy_reg(pi, 0x2ae, clip1lo_gaincode_B); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, - tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, - tia_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, - tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, - tia_gainbits); - - mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); - - if (chg_nbclip_th == 1) { - write_phy_reg(pi, 0x2b, nbclip_th); - write_phy_reg(pi, 0x41, nbclip_th); - } - - mod_phy_reg(pi, 0x300, (0x3f << 0), (w1clip_th << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (w1clip_th << 0)); - - mod_phy_reg(pi, 0x2e4, - (0x3f << 0), (nvar_baseline_offset0 << 0)); - - mod_phy_reg(pi, 0x2e4, - (0x3f << 6), (nvar_baseline_offset1 << 6)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, - lna1_gain_db_2); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, - 8, lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, - 8, lna2_gain_db); - - write_phy_reg(pi, 0x24, clip1md_gaincode); - write_phy_reg(pi, 0x2ab, clip1md_gaincode); - } else { - mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); - } + or_phy_reg(pi, 0xec, (0x1 << 0)); + or_phy_reg(pi, 0x78, (0x1 << 0)); + udelay(1); + and_phy_reg(pi, 0xec, ~(0x1 << 0)); } } -static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) +static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) { - uint core; - int ctr; - s16 gain_delta[2]; - u8 curr_channel; - u16 minmax_gain[2]; - u16 regval[4]; + s32 rssi_buf[4]; + s32 int_val; + + if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) || PHY_MUTED(pi)) + + return; + + if (PHY_IPA(pi)) + wlc_phy_ipa_internal_tssi_setup_nphy(pi); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), + 0, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + else if (NREV_GE(pi->pubpi.phy_rev, 3)) + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 0); + + wlc_phy_stopplayback_nphy(pi); + + wlc_phy_tx_tone_nphy(pi, 4000, 0, 0, 0, false); + + udelay(20); + int_val = + wlc_phy_poll_rssi_nphy(pi, (u8) NPHY_RSSI_SEL_TSSI_2G, rssi_buf, + 1); + wlc_phy_stopplayback_nphy(pi); + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, 0); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), + 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + else if (NREV_GE(pi->pubpi.phy_rev, 3)) + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 1); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = + (u8) ((int_val >> 24) & 0xff); + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = + (u8) ((int_val >> 24) & 0xff); + + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = + (u8) ((int_val >> 8) & 0xff); + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = + (u8) ((int_val >> 8) & 0xff); + } else { + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = + (u8) ((int_val >> 24) & 0xff); + + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = + (u8) ((int_val >> 8) & 0xff); + + pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = + (u8) ((int_val >> 16) & 0xff); + pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = + (u8) ((int_val) & 0xff); + } + +} + +static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) +{ + u8 idx, idx2, i, delta_ind; + + for (idx = TXP_FIRST_CCK; idx <= TXP_LAST_CCK; idx++) + pi->adj_pwr_tbl_nphy[idx] = pi->tx_power_offset[idx]; + + for (i = 0; i < 4; i++) { + idx2 = 0; + + delta_ind = 0; + + switch (i) { + case 0: + + if (CHSPEC_IS40(pi->radio_chanspec) + && NPHY_IS_SROM_REINTERPRET) { + idx = TXP_FIRST_MCS_40_SISO; + } else { + idx = (CHSPEC_IS40(pi->radio_chanspec)) ? + TXP_FIRST_OFDM_40_SISO : TXP_FIRST_OFDM; + delta_ind = 1; + } + break; + + case 1: + + idx = (CHSPEC_IS40(pi->radio_chanspec)) ? + TXP_FIRST_MCS_40_CDD : TXP_FIRST_MCS_20_CDD; + break; + + case 2: + + idx = (CHSPEC_IS40(pi->radio_chanspec)) ? + TXP_FIRST_MCS_40_STBC : TXP_FIRST_MCS_20_STBC; + break; + + case 3: + + idx = (CHSPEC_IS40(pi->radio_chanspec)) ? + TXP_FIRST_MCS_40_SDM : TXP_FIRST_MCS_20_SDM; + break; + } + + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + idx = idx + delta_ind; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx++]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + idx = idx + 1 - delta_ind; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = + pi->tx_power_offset[idx]; + } +} + +static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) +{ + u32 idx; + s16 a1[2], b0[2], b1[2]; + s8 target_pwr_qtrdbm[2]; + s32 num, den, pwr_est; + u8 chan_freq_range; + u8 idle_tssi[2]; + u32 tbl_id, tbl_len, tbl_offset; + u32 regval[64]; + u8 core; + + if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { + wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); + (void)R_REG(&pi->regs->maccontrol); + udelay(1); + } if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, true); - if (pi->nphy_gain_boost) { - if ((CHSPEC_IS2G(pi->radio_chanspec))) { + or_phy_reg(pi, 0x122, (0x1 << 0)); - gain_delta[0] = 6; - gain_delta[1] = 6; - } else { + if (NREV_GE(pi->pubpi.phy_rev, 3)) + and_phy_reg(pi, 0x1e7, (u16) (~(0x1 << 15))); + else + or_phy_reg(pi, 0x1e7, (0x1 << 15)); - curr_channel = CHSPEC_CHANNEL(pi->radio_chanspec); - gain_delta[0] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est0[0] * - curr_channel) + - nphy_lnagain_est0[1]), 13); - gain_delta[1] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est1[0] * - curr_channel) + - nphy_lnagain_est1[1]), 13); - } + if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) + wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); + + if (pi->sh->sromrev < 4) { + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; + target_pwr_qtrdbm[0] = 13 * 4; + target_pwr_qtrdbm[1] = 13 * 4; + a1[0] = -424; + a1[1] = -424; + b0[0] = 5612; + b0[1] = 5612; + b1[1] = -1393; + b1[0] = -1393; } else { - gain_delta[0] = 0; - gain_delta[1] = 0; - } - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (pi->nphy_elna_gain_config) { - - regval[0] = nphy_def_lnagains[2] + gain_delta[core]; - regval[1] = nphy_def_lnagains[3] + gain_delta[core]; - regval[2] = nphy_def_lnagains[3] + gain_delta[core]; - regval[3] = nphy_def_lnagains[3] + gain_delta[core]; - } else { - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = - nphy_def_lnagains[ctr] + - gain_delta[core]; + chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); + switch (chan_freq_range) { + case WL_CHAN_FREQ_RANGE_2G: + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; + target_pwr_qtrdbm[0] = + pi->nphy_pwrctrl_info[0].max_pwr_2g; + target_pwr_qtrdbm[1] = + pi->nphy_pwrctrl_info[1].max_pwr_2g; + a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_a1; + a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_a1; + b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b0; + b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b0; + b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b1; + b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b1; + break; + case WL_CHAN_FREQ_RANGE_5GL: + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; + target_pwr_qtrdbm[0] = + pi->nphy_pwrctrl_info[0].max_pwr_5gl; + target_pwr_qtrdbm[1] = + pi->nphy_pwrctrl_info[1].max_pwr_5gl; + a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1; + a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1; + b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0; + b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0; + b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1; + b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1; + break; + case WL_CHAN_FREQ_RANGE_5GM: + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; + target_pwr_qtrdbm[0] = + pi->nphy_pwrctrl_info[0].max_pwr_5gm; + target_pwr_qtrdbm[1] = + pi->nphy_pwrctrl_info[1].max_pwr_5gm; + a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_a1; + a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_a1; + b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b0; + b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b0; + b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b1; + b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b1; + break; + case WL_CHAN_FREQ_RANGE_5GH: + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; + target_pwr_qtrdbm[0] = + pi->nphy_pwrctrl_info[0].max_pwr_5gh; + target_pwr_qtrdbm[1] = + pi->nphy_pwrctrl_info[1].max_pwr_5gh; + a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1; + a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1; + b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0; + b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0; + b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1; + b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1; + break; + default: + idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; + idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; + target_pwr_qtrdbm[0] = 13 * 4; + target_pwr_qtrdbm[1] = 13 * 4; + a1[0] = -424; + a1[1] = -424; + b0[0] = 5612; + b0[1] = 5612; + b1[1] = -1393; + b1[0] = -1393; + break; } - wlc_phy_table_write_nphy(pi, core, 4, 8, 16, regval); - - minmax_gain[core] = - (u16) (nphy_def_lnagains[2] + gain_delta[core] + 4); } - mod_phy_reg(pi, 0x1e, (0xff << 0), (minmax_gain[0] << 0)); - mod_phy_reg(pi, 0x34, (0xff << 0), (minmax_gain[1] << 0)); + target_pwr_qtrdbm[0] = (s8) pi->tx_power_max; + target_pwr_qtrdbm[1] = (s8) pi->tx_power_max; + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (pi->srom_fem2g.tssipos) + or_phy_reg(pi, 0x1e9, (0x1 << 14)); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + for (core = 0; core <= 1; core++) { + if (PHY_IPA(pi)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) + WRITE_RADIO_REG3(pi, RADIO_2057, + TX, core, + TX_SSI_MUX, + 0xe); + else + WRITE_RADIO_REG3(pi, RADIO_2057, + TX, core, + TX_SSI_MUX, + 0xc); + } + } + } else { + if (PHY_IPA(pi)) { + + write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | + RADIO_2056_TX0, + (CHSPEC_IS5G + (pi->radio_chanspec)) ? + 0xc : 0xe); + write_radio_reg(pi, + RADIO_2056_TX_TX_SSI_MUX | + RADIO_2056_TX1, + (CHSPEC_IS5G + (pi->radio_chanspec)) ? + 0xc : 0xe); + } else { + + write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | + RADIO_2056_TX0, 0x11); + write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | + RADIO_2056_TX1, 0x11); + } + } + } + + if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { + wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); + (void)R_REG(&pi->regs->maccontrol); + udelay(1); + } + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + mod_phy_reg(pi, 0x1e7, (0x7f << 0), + (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); + else + mod_phy_reg(pi, 0x1e7, (0x7f << 0), + (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + mod_phy_reg(pi, 0x222, (0xff << 0), + (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); + else if (NREV_GT(pi->pubpi.phy_rev, 1)) + mod_phy_reg(pi, 0x222, (0xff << 0), + (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); + + if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) + wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); + + write_phy_reg(pi, 0x1e8, (0x3 << 8) | (240 << 0)); + + write_phy_reg(pi, 0x1e9, + (1 << 15) | (idle_tssi[0] << 0) | (idle_tssi[1] << 8)); + + write_phy_reg(pi, 0x1ea, + (target_pwr_qtrdbm[0] << 0) | + (target_pwr_qtrdbm[1] << 8)); + + tbl_len = 64; + tbl_offset = 0; + for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; + tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { + + for (idx = 0; idx < tbl_len; idx++) { + num = 8 * + (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx); + den = 32768 + a1[tbl_id - 26] * idx; + pwr_est = max(((4 * num + den / 2) / den), -8); + if (NREV_LT(pi->pubpi.phy_rev, 3)) { + if (idx <= + (uint) (31 - idle_tssi[tbl_id - 26] + 1)) + pwr_est = + max(pwr_est, + target_pwr_qtrdbm + [tbl_id - 26] + 1); + } + regval[idx] = (u32) pwr_est; + } + wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, + regval); + } + + wlc_phy_txpwr_limit_to_tbl_nphy(pi); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 84, 64, 8, + pi->adj_pwr_tbl_nphy); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 84, 64, 8, + pi->adj_pwr_tbl_nphy); if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, false); } -void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on) +static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) { - if (on) { + u32 *tx_pwrctrl_tbl = NULL; + + if (CHSPEC_IS2G(pi->radio_chanspec)) { if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (!pi->radio_is_on) { - wlc_phy_radio_preinit_205x(pi); - wlc_phy_radio_init_2057(pi); - wlc_phy_radio_postinit_2057(pi); + if ((pi->pubpi.radiorev == 4) + || (pi->pubpi.radiorev == 6)) + tx_pwrctrl_tbl = + nphy_tpc_txgain_ipa_2g_2057rev4n6; + else if (pi->pubpi.radiorev == 3) + tx_pwrctrl_tbl = + nphy_tpc_txgain_ipa_2g_2057rev3; + else if (pi->pubpi.radiorev == 5) + tx_pwrctrl_tbl = + nphy_tpc_txgain_ipa_2g_2057rev5; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + tx_pwrctrl_tbl = + nphy_tpc_txgain_ipa_2g_2057rev7; + } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { + tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev6; + } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { + tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev5; + } else { + tx_pwrctrl_tbl = nphy_tpc_txgain_ipa; + } + } else { + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + tx_pwrctrl_tbl = + nphy_tpc_txgain_ipa_5g_2057rev7; + } else { + tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g; + } + } + + return tx_pwrctrl_tbl; +} + +static void wlc_phy_restore_rssical_nphy(struct brcms_phy *pi) +{ + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (pi->nphy_rssical_chanspec_2G == 0) + return; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, + RADIO_2057_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_2G[0]); + mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, + RADIO_2057_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_2G[1]); + } else { + mod_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, + RADIO_2056_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_2G[0]); + mod_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, + RADIO_2056_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_2G[1]); + } + + write_phy_reg(pi, 0x1a6, + pi->rssical_cache.rssical_phyregs_2G[0]); + write_phy_reg(pi, 0x1ac, + pi->rssical_cache.rssical_phyregs_2G[1]); + write_phy_reg(pi, 0x1b2, + pi->rssical_cache.rssical_phyregs_2G[2]); + write_phy_reg(pi, 0x1b8, + pi->rssical_cache.rssical_phyregs_2G[3]); + write_phy_reg(pi, 0x1a4, + pi->rssical_cache.rssical_phyregs_2G[4]); + write_phy_reg(pi, 0x1aa, + pi->rssical_cache.rssical_phyregs_2G[5]); + write_phy_reg(pi, 0x1b0, + pi->rssical_cache.rssical_phyregs_2G[6]); + write_phy_reg(pi, 0x1b6, + pi->rssical_cache.rssical_phyregs_2G[7]); + write_phy_reg(pi, 0x1a5, + pi->rssical_cache.rssical_phyregs_2G[8]); + write_phy_reg(pi, 0x1ab, + pi->rssical_cache.rssical_phyregs_2G[9]); + write_phy_reg(pi, 0x1b1, + pi->rssical_cache.rssical_phyregs_2G[10]); + write_phy_reg(pi, 0x1b7, + pi->rssical_cache.rssical_phyregs_2G[11]); + + } else { + if (pi->nphy_rssical_chanspec_5G == 0) + return; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, + RADIO_2057_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_5G[0]); + mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, + RADIO_2057_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_5G[1]); + } else { + mod_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, + RADIO_2056_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_5G[0]); + mod_radio_reg(pi, + RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, + RADIO_2056_VCM_MASK, + pi->rssical_cache. + rssical_radio_regs_5G[1]); + } + + write_phy_reg(pi, 0x1a6, + pi->rssical_cache.rssical_phyregs_5G[0]); + write_phy_reg(pi, 0x1ac, + pi->rssical_cache.rssical_phyregs_5G[1]); + write_phy_reg(pi, 0x1b2, + pi->rssical_cache.rssical_phyregs_5G[2]); + write_phy_reg(pi, 0x1b8, + pi->rssical_cache.rssical_phyregs_5G[3]); + write_phy_reg(pi, 0x1a4, + pi->rssical_cache.rssical_phyregs_5G[4]); + write_phy_reg(pi, 0x1aa, + pi->rssical_cache.rssical_phyregs_5G[5]); + write_phy_reg(pi, 0x1b0, + pi->rssical_cache.rssical_phyregs_5G[6]); + write_phy_reg(pi, 0x1b6, + pi->rssical_cache.rssical_phyregs_5G[7]); + write_phy_reg(pi, 0x1a5, + pi->rssical_cache.rssical_phyregs_5G[8]); + write_phy_reg(pi, 0x1ab, + pi->rssical_cache.rssical_phyregs_5G[9]); + write_phy_reg(pi, 0x1b1, + pi->rssical_cache.rssical_phyregs_5G[10]); + write_phy_reg(pi, 0x1b7, + pi->rssical_cache.rssical_phyregs_5G[11]); + } +} + +static void wlc_phy_internal_cal_txgain_nphy(struct brcms_phy *pi) +{ + u16 txcal_gain[2]; + + pi->nphy_txcal_pwr_idx[0] = pi->nphy_cal_orig_pwr_idx[0]; + pi->nphy_txcal_pwr_idx[1] = pi->nphy_cal_orig_pwr_idx[0]; + wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); + wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); + + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, + txcal_gain); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F40; + txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F40; + } else { + txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F60; + txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F60; + } + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, + txcal_gain); +} + +static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) +{ + bool save_bbmult = false; + u8 txcal_index_2057_rev5n7 = 0; + u8 txcal_index_2057_rev3n4n6 = 10; + + if (pi->use_int_tx_iqlo_cal_nphy) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) { + + pi->nphy_txcal_pwr_idx[0] = + txcal_index_2057_rev3n4n6; + pi->nphy_txcal_pwr_idx[1] = + txcal_index_2057_rev3n4n6; + wlc_phy_txpwr_index_nphy( + pi, 3, + txcal_index_2057_rev3n4n6, + false); + } else { + + pi->nphy_txcal_pwr_idx[0] = + txcal_index_2057_rev5n7; + pi->nphy_txcal_pwr_idx[1] = + txcal_index_2057_rev5n7; + wlc_phy_txpwr_index_nphy( + pi, 3, + txcal_index_2057_rev5n7, + false); + } + save_bbmult = true; + + } else if (NREV_LT(pi->pubpi.phy_rev, 5)) { + wlc_phy_cal_txgainctrl_nphy(pi, 11, false); + if (pi->sh->hw_phytxchain != 3) { + pi->nphy_txcal_pwr_idx[1] = + pi->nphy_txcal_pwr_idx[0]; + wlc_phy_txpwr_index_nphy(pi, 3, + pi-> + nphy_txcal_pwr_idx[0], + true); + save_bbmult = true; } - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, - pi->radio_chanspec); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_radio_preinit_205x(pi); - wlc_phy_radio_init_2056(pi); - wlc_phy_radio_postinit_2056(pi); + } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { + if (PHY_IPA(pi)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) { + wlc_phy_cal_txgainctrl_nphy(pi, 12, + false); + } else { + pi->nphy_txcal_pwr_idx[0] = 80; + pi->nphy_txcal_pwr_idx[1] = 80; + wlc_phy_txpwr_index_nphy(pi, 3, 80, + false); + save_bbmult = true; + } + } else { + wlc_phy_internal_cal_txgain_nphy(pi); + save_bbmult = true; + } - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, - pi->radio_chanspec); - } else { - wlc_phy_radio_preinit_2055(pi); - wlc_phy_radio_init_2055(pi); - wlc_phy_radio_postinit_2055(pi); + } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { + if (PHY_IPA(pi)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) + wlc_phy_cal_txgainctrl_nphy(pi, 12, + false); + else + wlc_phy_cal_txgainctrl_nphy(pi, 14, + false); + } else { + wlc_phy_internal_cal_txgain_nphy(pi); + save_bbmult = true; + } } - pi->radio_is_on = true; - } else { + wlc_phy_cal_txgainctrl_nphy(pi, 10, false); + } - if (NREV_GE(pi->pubpi.phy_rev, 3) - && NREV_LT(pi->pubpi.phy_rev, 7)) { - and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); - mod_radio_reg(pi, RADIO_2056_SYN_COM_PU, 0x2, 0x0); + if (save_bbmult) + wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, + &pi->nphy_txcal_bbmult); +} - write_radio_reg(pi, - RADIO_2056_TX_PADA_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PADG_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAA_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAG_BOOST_TUNE | - RADIO_2056_TX0, 0); - mod_radio_reg(pi, - RADIO_2056_TX_MIXA_BOOST_TUNE | - RADIO_2056_TX0, 0xf0, 0); - write_radio_reg(pi, - RADIO_2056_TX_MIXG_BOOST_TUNE | - RADIO_2056_TX0, 0); +static void +wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, + u8 core_code) +{ + u16 mask; + u16 val; + u8 core; - write_radio_reg(pi, - RADIO_2056_TX_PADA_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PADG_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAA_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAG_BOOST_TUNE | - RADIO_2056_TX1, 0); - mod_radio_reg(pi, - RADIO_2056_TX_MIXA_BOOST_TUNE | - RADIO_2056_TX1, 0xf0, 0); - write_radio_reg(pi, - RADIO_2056_TX_MIXG_BOOST_TUNE | - RADIO_2056_TX1, 0); + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + if (core_code == RADIO_MIMO_CORESEL_CORE1 + && core == PHY_CORE_1) + continue; + else if (core_code == RADIO_MIMO_CORESEL_CORE2 + && core == PHY_CORE_0) + continue; - pi->radio_is_on = false; + if (NREV_LT(pi->pubpi.phy_rev, 7)) { + + mask = (0x1 << 10); + val = 1 << 10; + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : + 0x92, mask, val); + } + + if (field == NPHY_RfctrlIntc_override_OFF) { + + write_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : + 0x92, 0); + + wlc_phy_force_rfseq_nphy(pi, + NPHY_RFSEQ_RESET2RX); + } else if (field == NPHY_RfctrlIntc_override_TRSW) { + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + mask = (0x1 << 6) | (0x1 << 7); + + val = value << 6; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + + or_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + (0x1 << 10)); + + and_phy_reg(pi, 0x2ff, (u16) + ~(0x3 << 14)); + or_phy_reg(pi, 0x2ff, (0x1 << 13)); + or_phy_reg(pi, 0x2ff, (0x1 << 0)); + } else { + + mask = (0x1 << 6) | + (0x1 << 7) | + (0x1 << 8) | (0x1 << 9); + val = value << 6; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + + mask = (0x1 << 0); + val = 1 << 0; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0xe7 : 0xec, + mask, val); + + mask = (core == PHY_CORE_0) ? + (0x1 << 0) : (0x1 << 1); + val = 1 << ((core == PHY_CORE_0) ? + 0 : 1); + mod_phy_reg(pi, 0x78, mask, val); + + SPINWAIT(((read_phy_reg(pi, 0x78) & val) + != 0), 10000); + if (WARN(read_phy_reg(pi, 0x78) & val, + "HW error: override failed")) + return; + + mask = (0x1 << 0); + val = 0 << 0; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0xe7 : 0xec, + mask, val); + } + } else if (field == NPHY_RfctrlIntc_override_PA) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + mask = (0x1 << 4) | (0x1 << 5); + + if (CHSPEC_IS5G(pi->radio_chanspec)) + val = value << 5; + else + val = value << 4; + + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + + or_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + (0x1 << 12)); + } else { + + if (CHSPEC_IS5G(pi->radio_chanspec)) { + mask = (0x1 << 5); + val = value << 5; + } else { + mask = (0x1 << 4); + val = value << 4; + } + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + } + } else if (field == + NPHY_RfctrlIntc_override_EXT_LNA_PU) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) { + + mask = (0x1 << 0); + val = value << 0; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, val); + + mask = (0x1 << 2); + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, 0); + } else { + + mask = (0x1 << 2); + val = value << 2; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, val); + + mask = (0x1 << 0); + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, 0); + } + + mask = (0x1 << 11); + val = 1 << 11; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + } else { + + if (CHSPEC_IS5G(pi->radio_chanspec)) { + mask = (0x1 << 0); + val = value << 0; + } else { + mask = (0x1 << 2); + val = value << 2; + } + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + } + } else if (field == + NPHY_RfctrlIntc_override_EXT_LNA_GAIN) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) { + + mask = (0x1 << 1); + val = value << 1; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, val); + + mask = (0x1 << 3); + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, 0); + } else { + + mask = (0x1 << 3); + val = value << 3; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, val); + + mask = (0x1 << 1); + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 + : 0x92, mask, 0); + } + + mask = (0x1 << 11); + val = 1 << 11; + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + } else { + + if (CHSPEC_IS5G(pi->radio_chanspec)) { + mask = (0x1 << 1); + val = value << 1; + } else { + mask = (0x1 << 3); + val = value << 3; + } + mod_phy_reg(pi, + (core == + PHY_CORE_0) ? 0x91 : 0x92, + mask, val); + } + } } - - if (NREV_GE(pi->pubpi.phy_rev, 8)) { - and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); - pi->radio_is_on = false; - } - } } -static void wlc_phy_radio_preinit_2055(struct brcms_phy *pi) +void +wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, + bool debug) { + int gainctrl_loopidx; + uint core; + u16 m0m1, curr_m0m1; + s32 delta_power; + s32 txpwrindex; + s32 qdBm_power[2]; + u16 orig_BBConfig; + u16 phy_saveregs[4]; + u32 freq_test; + u16 ampl_test = 250; + uint stepsize; + bool phyhang_avoid_state = false; - and_phy_reg(pi, 0x78, ~RFCC_POR_FORCE); - or_phy_reg(pi, 0x78, RFCC_CHIP0_PU | RFCC_OE_POR_FORCE); + if (NREV_GE(pi->pubpi.phy_rev, 7)) + stepsize = 2; + else + stepsize = 1; - or_phy_reg(pi, 0x78, RFCC_POR_FORCE); -} + if (CHSPEC_IS40(pi->radio_chanspec)) + freq_test = 5000; + else + freq_test = 2500; -static void wlc_phy_radio_init_2055(struct brcms_phy *pi) -{ - wlc_phy_init_radio_regs(pi, regs_2055, RADIO_DEFAULT_CORE); -} + wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); + wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); -static void wlc_phy_radio_postinit_2055(struct brcms_phy *pi) -{ + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); - and_radio_reg(pi, RADIO_2055_MASTER_CNTRL1, - ~(RADIO_2055_JTAGCTRL_MASK | RADIO_2055_JTAGSYNC_MASK)); + phyhang_avoid_state = pi->phyhang_avoid; + pi->phyhang_avoid = false; - if (((pi->sh->sromrev >= 4) - && !(pi->sh->boardflags2 & BFL2_RXBB_INT_REG_DIS)) - || ((pi->sh->sromrev < 4))) { - and_radio_reg(pi, RADIO_2055_CORE1_RXBB_REGULATOR, 0x7F); - and_radio_reg(pi, RADIO_2055_CORE2_RXBB_REGULATOR, 0x7F); + phy_saveregs[0] = read_phy_reg(pi, 0x91); + phy_saveregs[1] = read_phy_reg(pi, 0x92); + phy_saveregs[2] = read_phy_reg(pi, 0xe7); + phy_saveregs[3] = read_phy_reg(pi, 0xec); + wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 1, + RADIO_MIMO_CORESEL_CORE1 | + RADIO_MIMO_CORESEL_CORE2); + + if (!debug) { + wlc_phy_rfctrlintc_override_nphy(pi, + NPHY_RfctrlIntc_override_TRSW, + 0x2, RADIO_MIMO_CORESEL_CORE1); + wlc_phy_rfctrlintc_override_nphy(pi, + NPHY_RfctrlIntc_override_TRSW, + 0x8, RADIO_MIMO_CORESEL_CORE2); + } else { + wlc_phy_rfctrlintc_override_nphy(pi, + NPHY_RfctrlIntc_override_TRSW, + 0x1, RADIO_MIMO_CORESEL_CORE1); + wlc_phy_rfctrlintc_override_nphy(pi, + NPHY_RfctrlIntc_override_TRSW, + 0x7, RADIO_MIMO_CORESEL_CORE2); } - mod_radio_reg(pi, RADIO_2055_RRCCAL_N_OPT_SEL, 0x3F, 0x2C); - write_radio_reg(pi, RADIO_2055_CAL_MISC, 0x3C); + orig_BBConfig = read_phy_reg(pi, 0x01); + mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - and_radio_reg(pi, RADIO_2055_CAL_MISC, - ~(RADIO_2055_RRCAL_START | RADIO_2055_RRCAL_RST_N)); + wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); - or_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, RADIO_2055_CAL_LPO_ENABLE); + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + txpwrindex = (s32) pi->nphy_cal_orig_pwr_idx[core]; - or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_RST_N); + for (gainctrl_loopidx = 0; gainctrl_loopidx < 2; + gainctrl_loopidx++) { + wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, + false); - udelay(1000); + if (core == PHY_CORE_0) + curr_m0m1 = m0m1 & 0xff00; + else + curr_m0m1 = m0m1 & 0x00ff; - or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_START); + wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &curr_m0m1); + wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &curr_m0m1); - SPINWAIT(((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & - RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000); + udelay(50); - if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & - RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE, - "HW error: radio calibration1\n")) + wlc_phy_est_tonepwr_nphy(pi, qdBm_power, + NPHY_CAL_TSSISAMPS); + + pi->nphy_bb_mult_save = 0; + wlc_phy_stopplayback_nphy(pi); + + delta_power = (dBm_targetpower * 4) - qdBm_power[core]; + + txpwrindex -= stepsize * delta_power; + if (txpwrindex < 0) + txpwrindex = 0; + else if (txpwrindex > 127) + txpwrindex = 127; + + if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (NREV_IS(pi->pubpi.phy_rev, 4) && + (pi->srom_fem5g.extpagain == 3)) { + if (txpwrindex < 30) + txpwrindex = 30; + } + } else { + if (NREV_GE(pi->pubpi.phy_rev, 5) && + (pi->srom_fem2g.extpagain == 3)) { + if (txpwrindex < 50) + txpwrindex = 50; + } + } + + wlc_phy_txpwr_index_nphy(pi, (1 << core), + (u8) txpwrindex, true); + } + + pi->nphy_txcal_pwr_idx[core] = (u8) txpwrindex; + + if (debug) { + u16 radio_gain; + u16 dbg_m0m1; + + wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); + + wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, + false); + + wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); + wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &dbg_m0m1); + + udelay(100); + + wlc_phy_est_tonepwr_nphy(pi, qdBm_power, + NPHY_CAL_TSSISAMPS); + + wlc_phy_table_read_nphy(pi, 7, 1, (0x110 + core), 16, + &radio_gain); + + mdelay(4000); + pi->nphy_bb_mult_save = 0; + wlc_phy_stopplayback_nphy(pi); + } + } + + wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_txcal_pwr_idx[0], true); + wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_txcal_pwr_idx[1], true); + + wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &pi->nphy_txcal_bbmult); + + write_phy_reg(pi, 0x01, orig_BBConfig); + + write_phy_reg(pi, 0x91, phy_saveregs[0]); + write_phy_reg(pi, 0x92, phy_saveregs[1]); + write_phy_reg(pi, 0xe7, phy_saveregs[2]); + write_phy_reg(pi, 0xec, phy_saveregs[3]); + + pi->phyhang_avoid = phyhang_avoid_state; + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); +} + +static void wlc_phy_savecal_nphy(struct brcms_phy *pi) +{ + void *tbl_ptr; + int coreNum; + u16 *txcal_radio_regs = NULL; + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + + wlc_phy_rx_iq_coeffs_nphy(pi, 0, + &pi->calibration_cache. + rxcal_coeffs_2G); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + txcal_radio_regs = + pi->calibration_cache.txcal_radio_regs_2G; + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + pi->calibration_cache.txcal_radio_regs_2G[0] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_2G[1] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_2G[2] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1); + pi->calibration_cache.txcal_radio_regs_2G[3] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1); + + pi->calibration_cache.txcal_radio_regs_2G[4] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_2G[5] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_2G[6] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1); + pi->calibration_cache.txcal_radio_regs_2G[7] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1); + } else { + pi->calibration_cache.txcal_radio_regs_2G[0] = + read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); + pi->calibration_cache.txcal_radio_regs_2G[1] = + read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); + pi->calibration_cache.txcal_radio_regs_2G[2] = + read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); + pi->calibration_cache.txcal_radio_regs_2G[3] = + read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); + } + + pi->nphy_iqcal_chanspec_2G = pi->radio_chanspec; + tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; + } else { + + wlc_phy_rx_iq_coeffs_nphy(pi, 0, + &pi->calibration_cache. + rxcal_coeffs_5G); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + txcal_radio_regs = + pi->calibration_cache.txcal_radio_regs_5G; + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + pi->calibration_cache.txcal_radio_regs_5G[0] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_5G[1] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_5G[2] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1); + pi->calibration_cache.txcal_radio_regs_5G[3] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1); + + pi->calibration_cache.txcal_radio_regs_5G[4] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_5G[5] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0); + pi->calibration_cache.txcal_radio_regs_5G[6] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1); + pi->calibration_cache.txcal_radio_regs_5G[7] = + read_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1); + } else { + pi->calibration_cache.txcal_radio_regs_5G[0] = + read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); + pi->calibration_cache.txcal_radio_regs_5G[1] = + read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); + pi->calibration_cache.txcal_radio_regs_5G[2] = + read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); + pi->calibration_cache.txcal_radio_regs_5G[3] = + read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); + } + + pi->nphy_iqcal_chanspec_5G = pi->radio_chanspec; + tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; + } + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + for (coreNum = 0; coreNum <= 1; coreNum++) { + + txcal_radio_regs[2 * coreNum] = + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_I); + txcal_radio_regs[2 * coreNum + 1] = + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_Q); + + txcal_radio_regs[2 * coreNum + 4] = + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_I); + txcal_radio_regs[2 * coreNum + 5] = + READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_Q); + } + } + + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 8, 80, 16, tbl_ptr); + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); +} + +static void wlc_phy_tx_iq_war_nphy(struct brcms_phy *pi) +{ + struct nphy_iq_comp tx_comp; + + wlc_phy_table_read_nphy(pi, 15, 4, 0x50, 16, &tx_comp); + + wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ, tx_comp.a0); + wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 2, tx_comp.b0); + wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 4, tx_comp.a1); + wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 6, tx_comp.b1); +} + +static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) +{ + u16 *loft_comp; + u16 txcal_coeffs_bphy[4]; + u16 *tbl_ptr; + int coreNum; + u16 *txcal_radio_regs = NULL; + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (pi->nphy_iqcal_chanspec_2G == 0) + return; + + tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; + loft_comp = &pi->calibration_cache.txcal_coeffs_2G[5]; + } else { + if (pi->nphy_iqcal_chanspec_5G == 0) + return; + + tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; + loft_comp = &pi->calibration_cache.txcal_coeffs_5G[5]; + } + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, 16, tbl_ptr); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + txcal_coeffs_bphy[0] = tbl_ptr[0]; + txcal_coeffs_bphy[1] = tbl_ptr[1]; + txcal_coeffs_bphy[2] = tbl_ptr[2]; + txcal_coeffs_bphy[3] = tbl_ptr[3]; + } else { + txcal_coeffs_bphy[0] = 0; + txcal_coeffs_bphy[1] = 0; + txcal_coeffs_bphy[2] = 0; + txcal_coeffs_bphy[3] = 0; + } + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 88, 16, + txcal_coeffs_bphy); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 85, 16, loft_comp); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 93, 16, loft_comp); + + if (NREV_LT(pi->pubpi.phy_rev, 2)) + wlc_phy_tx_iq_war_nphy(pi); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + txcal_radio_regs = + pi->calibration_cache.txcal_radio_regs_2G; + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_2G[0]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_2G[1]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_2G[2]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_2G[3]); + + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_2G[4]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_2G[5]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_2G[6]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_2G[7]); + } else { + write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, + pi->calibration_cache. + txcal_radio_regs_2G[0]); + write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, + pi->calibration_cache. + txcal_radio_regs_2G[1]); + write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, + pi->calibration_cache. + txcal_radio_regs_2G[2]); + write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, + pi->calibration_cache. + txcal_radio_regs_2G[3]); + } + + wlc_phy_rx_iq_coeffs_nphy(pi, 1, + &pi->calibration_cache. + rxcal_coeffs_2G); + } else { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + txcal_radio_regs = + pi->calibration_cache.txcal_radio_regs_5G; + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_5G[0]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_5G[1]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_I | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_5G[2]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_FINE_Q | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_5G[3]); + + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_5G[4]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX0, + pi->calibration_cache. + txcal_radio_regs_5G[5]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_I | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_5G[6]); + write_radio_reg(pi, + RADIO_2056_TX_LOFT_COARSE_Q | + RADIO_2056_TX1, + pi->calibration_cache. + txcal_radio_regs_5G[7]); + } else { + write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, + pi->calibration_cache. + txcal_radio_regs_5G[0]); + write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, + pi->calibration_cache. + txcal_radio_regs_5G[1]); + write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, + pi->calibration_cache. + txcal_radio_regs_5G[2]); + write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, + pi->calibration_cache. + txcal_radio_regs_5G[3]); + } + + wlc_phy_rx_iq_coeffs_nphy(pi, 1, + &pi->calibration_cache. + rxcal_coeffs_5G); + } + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + for (coreNum = 0; coreNum <= 1; coreNum++) { + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_I, + txcal_radio_regs[2 * coreNum]); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_FINE_Q, + txcal_radio_regs[2 * coreNum + 1]); + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_I, + txcal_radio_regs[2 * coreNum + 4]); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, + LOFT_COARSE_Q, + txcal_radio_regs[2 * coreNum + 5]); + } + } +} + +static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) +{ + u32 idx; + u16 iqloCalbuf[7]; + u32 iqcomp, locomp, curr_locomp; + s8 locomp_i, locomp_q; + s8 curr_locomp_i, curr_locomp_q; + u32 tbl_id, tbl_len, tbl_offset; + u32 regval[128]; + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + wlc_phy_table_read_nphy(pi, 15, 7, 80, 16, iqloCalbuf); + + tbl_len = 128; + tbl_offset = 320; + for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; + tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { + iqcomp = + (tbl_id == + 26) ? (((u32) (iqloCalbuf[0] & 0x3ff)) << 10) | + (iqloCalbuf[1] & 0x3ff) + : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | + (iqloCalbuf[3] & 0x3ff); + + for (idx = 0; idx < tbl_len; idx++) + regval[idx] = iqcomp; + wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, + regval); + } + + tbl_offset = 448; + for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; + tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { + + locomp = + (u32) ((tbl_id == 26) ? iqloCalbuf[5] : iqloCalbuf[6]); + locomp_i = (s8) ((locomp >> 8) & 0xff); + locomp_q = (s8) ((locomp) & 0xff); + for (idx = 0; idx < tbl_len; idx++) { + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + curr_locomp_i = locomp_i; + curr_locomp_q = locomp_q; + } else { + curr_locomp_i = (s8) ((locomp_i * + nphy_tpc_loscale[idx] + + 128) >> 8); + curr_locomp_q = + (s8) ((locomp_q * + nphy_tpc_loscale[idx] + + 128) >> 8); + } + curr_locomp = (u32) ((curr_locomp_i & 0xff) << 8); + curr_locomp |= (u32) (curr_locomp_q & 0xff); + regval[idx] = curr_locomp; + } + wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, + regval); + } + + if (NREV_LT(pi->pubpi.phy_rev, 2)) { + + wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX1, 0xFFFF); + wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX2, 0xFFFF); + } + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); +} + +static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi) +{ + u8 tx_lpf_bw = 0; + + if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { + if (CHSPEC_IS40(pi->radio_chanspec)) + tx_lpf_bw = 3; + else + tx_lpf_bw = 1; + + if (PHY_IPA(pi)) { + if (CHSPEC_IS40(pi->radio_chanspec)) + tx_lpf_bw = 5; + else + tx_lpf_bw = 4; + } + + write_phy_reg(pi, 0xe8, + (tx_lpf_bw << 0) | + (tx_lpf_bw << 3) | + (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); + + if (PHY_IPA(pi)) { + + if (CHSPEC_IS40(pi->radio_chanspec)) + tx_lpf_bw = 4; + else + tx_lpf_bw = 1; + + write_phy_reg(pi, 0xe9, + (tx_lpf_bw << 0) | + (tx_lpf_bw << 3) | + (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); + } + } +} + +static void +wlc_phy_adjust_rx_analpfbw_nphy(struct brcms_phy *pi, u16 reduction_factr) +{ + if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { + if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && + CHSPEC_IS40(pi->radio_chanspec)) { + if (!pi->nphy_anarxlpf_adjusted) { + write_radio_reg(pi, + (RADIO_2056_RX_RXLPF_RCCAL_LPC | + RADIO_2056_RX0), + ((pi->nphy_rccal_value + + reduction_factr) | 0x80)); + + pi->nphy_anarxlpf_adjusted = true; + } + } else { + if (pi->nphy_anarxlpf_adjusted) { + write_radio_reg(pi, + (RADIO_2056_RX_RXLPF_RCCAL_LPC | + RADIO_2056_RX0), + (pi->nphy_rccal_value | 0x80)); + + pi->nphy_anarxlpf_adjusted = false; + } + } + } +} + +static void +wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, + int *tone_id_buf, u32 *noise_var_buf) +{ + int i; + u32 offset; + int tone_id; + int tbllen = + CHSPEC_IS40(pi->radio_chanspec) ? + NPHY_NOISEVAR_TBLLEN40 : NPHY_NOISEVAR_TBLLEN20; + + if (pi->nphy_noisevars_adjusted) { + for (i = 0; i < pi->nphy_saved_noisevars.bufcount; i++) { + tone_id = pi->nphy_saved_noisevars.tone_id[i]; + offset = (tone_id >= 0) ? + ((tone_id * + 2) + 1) : (tbllen + (tone_id * 2) + 1); + wlc_phy_table_write_nphy( + pi, NPHY_TBL_ID_NOISEVAR, 1, + offset, 32, + &pi->nphy_saved_noisevars.min_noise_vars[i]); + } + + pi->nphy_saved_noisevars.bufcount = 0; + pi->nphy_noisevars_adjusted = false; + } + + if ((noise_var_buf != NULL) && (tone_id_buf != NULL)) { + pi->nphy_saved_noisevars.bufcount = 0; + + for (i = 0; i < ntones; i++) { + tone_id = tone_id_buf[i]; + offset = (tone_id >= 0) ? + ((tone_id * 2) + 1) : + (tbllen + (tone_id * 2) + 1); + pi->nphy_saved_noisevars.tone_id[i] = tone_id; + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + offset, 32, + &pi->nphy_saved_noisevars. + min_noise_vars[i]); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + offset, 32, &noise_var_buf[i]); + pi->nphy_saved_noisevars.bufcount++; + } + + pi->nphy_noisevars_adjusted = true; + } +} + +static void wlc_phy_adjust_crsminpwr_nphy(struct brcms_phy *pi, u8 minpwr) +{ + u16 regval; + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && + CHSPEC_IS40(pi->radio_chanspec)) { + if (!pi->nphy_crsminpwr_adjusted) { + regval = read_phy_reg(pi, 0x27d); + pi->nphy_crsminpwr[0] = regval & 0xff; + regval &= 0xff00; + regval |= (u16) minpwr; + write_phy_reg(pi, 0x27d, regval); + + regval = read_phy_reg(pi, 0x280); + pi->nphy_crsminpwr[1] = regval & 0xff; + regval &= 0xff00; + regval |= (u16) minpwr; + write_phy_reg(pi, 0x280, regval); + + regval = read_phy_reg(pi, 0x283); + pi->nphy_crsminpwr[2] = regval & 0xff; + regval &= 0xff00; + regval |= (u16) minpwr; + write_phy_reg(pi, 0x283, regval); + + pi->nphy_crsminpwr_adjusted = true; + } + } else { + if (pi->nphy_crsminpwr_adjusted) { + regval = read_phy_reg(pi, 0x27d); + regval &= 0xff00; + regval |= pi->nphy_crsminpwr[0]; + write_phy_reg(pi, 0x27d, regval); + + regval = read_phy_reg(pi, 0x280); + regval &= 0xff00; + regval |= pi->nphy_crsminpwr[1]; + write_phy_reg(pi, 0x280, regval); + + regval = read_phy_reg(pi, 0x283); + regval &= 0xff00; + regval |= pi->nphy_crsminpwr[2]; + write_phy_reg(pi, 0x283, regval); + + pi->nphy_crsminpwr_adjusted = false; + } + } + } +} + +static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) +{ + u16 cur_channel = 0; + int nphy_adj_tone_id_buf[] = { 57, 58 }; + u32 nphy_adj_noise_var_buf[] = { 0x3ff, 0x3ff }; + bool isAdjustNoiseVar = false; + uint numTonesAdjust = 0; + u32 tempval = 0; + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + cur_channel = CHSPEC_CHANNEL(pi->radio_chanspec); + + if (pi->nphy_gband_spurwar_en) { + + wlc_phy_adjust_rx_analpfbw_nphy( + pi, + NPHY_ANARXLPFBW_REDUCTIONFACT); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((cur_channel == 11) + && CHSPEC_IS40(pi->radio_chanspec)) + wlc_phy_adjust_min_noisevar_nphy( + pi, 2, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); + else + wlc_phy_adjust_min_noisevar_nphy(pi, 0, + NULL, + NULL); + } + + wlc_phy_adjust_crsminpwr_nphy(pi, + NPHY_ADJUSTED_MINCRSPOWER); + } + + if ((pi->nphy_gband_spurwar2_en) + && CHSPEC_IS2G(pi->radio_chanspec)) { + + if (CHSPEC_IS40(pi->radio_chanspec)) { + switch (cur_channel) { + case 3: + nphy_adj_tone_id_buf[0] = 57; + nphy_adj_tone_id_buf[1] = 58; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x25f; + isAdjustNoiseVar = true; + break; + case 4: + nphy_adj_tone_id_buf[0] = 41; + nphy_adj_tone_id_buf[1] = 42; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x25f; + isAdjustNoiseVar = true; + break; + case 5: + nphy_adj_tone_id_buf[0] = 25; + nphy_adj_tone_id_buf[1] = 26; + nphy_adj_noise_var_buf[0] = 0x24f; + nphy_adj_noise_var_buf[1] = 0x25f; + isAdjustNoiseVar = true; + break; + case 6: + nphy_adj_tone_id_buf[0] = 9; + nphy_adj_tone_id_buf[1] = 10; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x24f; + isAdjustNoiseVar = true; + break; + case 7: + nphy_adj_tone_id_buf[0] = 121; + nphy_adj_tone_id_buf[1] = 122; + nphy_adj_noise_var_buf[0] = 0x18f; + nphy_adj_noise_var_buf[1] = 0x24f; + isAdjustNoiseVar = true; + break; + case 8: + nphy_adj_tone_id_buf[0] = 105; + nphy_adj_tone_id_buf[1] = 106; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x25f; + isAdjustNoiseVar = true; + break; + case 9: + nphy_adj_tone_id_buf[0] = 89; + nphy_adj_tone_id_buf[1] = 90; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x24f; + isAdjustNoiseVar = true; + break; + case 10: + nphy_adj_tone_id_buf[0] = 73; + nphy_adj_tone_id_buf[1] = 74; + nphy_adj_noise_var_buf[0] = 0x22f; + nphy_adj_noise_var_buf[1] = 0x24f; + isAdjustNoiseVar = true; + break; + default: + isAdjustNoiseVar = false; + break; + } + } + + if (isAdjustNoiseVar) { + numTonesAdjust = sizeof(nphy_adj_tone_id_buf) / + sizeof(nphy_adj_tone_id_buf[0]); + + wlc_phy_adjust_min_noisevar_nphy( + pi, + numTonesAdjust, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); + + tempval = 0; + + } else { + wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, + NULL); + } + } + + if ((pi->nphy_aband_spurwar_en) && + (CHSPEC_IS5G(pi->radio_chanspec))) { + switch (cur_channel) { + case 54: + nphy_adj_tone_id_buf[0] = 32; + nphy_adj_noise_var_buf[0] = 0x25f; + break; + case 38: + case 102: + case 118: + nphy_adj_tone_id_buf[0] = 0; + nphy_adj_noise_var_buf[0] = 0x0; + break; + case 134: + nphy_adj_tone_id_buf[0] = 32; + nphy_adj_noise_var_buf[0] = 0x21f; + break; + case 151: + nphy_adj_tone_id_buf[0] = 16; + nphy_adj_noise_var_buf[0] = 0x23f; + break; + case 153: + case 161: + nphy_adj_tone_id_buf[0] = 48; + nphy_adj_noise_var_buf[0] = 0x23f; + break; + default: + nphy_adj_tone_id_buf[0] = 0; + nphy_adj_noise_var_buf[0] = 0x0; + break; + } + + if (nphy_adj_tone_id_buf[0] + && nphy_adj_noise_var_buf[0]) + wlc_phy_adjust_min_noisevar_nphy( + pi, 1, + nphy_adj_tone_id_buf, + nphy_adj_noise_var_buf); + else + wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, + NULL); + } + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); + } +} + +void wlc_phy_init_nphy(struct brcms_phy *pi) +{ + u16 val; + u16 clip1_ths[2]; + struct nphy_txgains target_gain; + u8 tx_pwr_ctrl_state; + bool do_nphy_cal = false; + uint core; + uint origidx, intr_val; + struct d11regs *regs; + u32 d11_clk_ctl_st; + bool do_rssi_cal = false; + + core = 0; + + if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) + pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; + + if ((ISNPHY(pi)) && (NREV_GE(pi->pubpi.phy_rev, 5)) && + ((pi->sh->chippkg == BCM4717_PKG_ID) || + (pi->sh->chippkg == BCM4718_PKG_ID))) { + if ((pi->sh->boardflags & BFL_EXTLNA) && + (CHSPEC_IS2G(pi->radio_chanspec))) + ai_corereg(pi->sh->sih, SI_CC_IDX, + offsetof(struct chipcregs, chipcontrol), + 0x40, 0x40); + } + + if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && + CHSPEC_IS40(pi->radio_chanspec)) { + + regs = (struct d11regs *) ai_switch_core(pi->sh->sih, + D11_CORE_ID, &origidx, + &intr_val); + d11_clk_ctl_st = R_REG(®s->clk_ctl_st); + AND_REG(®s->clk_ctl_st, + ~(CCS_FORCEHT | CCS_HTAREQ)); + + W_REG(®s->clk_ctl_st, d11_clk_ctl_st); + + ai_restore_core(pi->sh->sih, origidx, intr_val); + } + + pi->use_int_tx_iqlo_cal_nphy = + (PHY_IPA(pi) || + (NREV_GE(pi->pubpi.phy_rev, 7) || + (NREV_GE(pi->pubpi.phy_rev, 5) + && pi->sh->boardflags2 & BFL2_INTERNDET_TXIQCAL))); + + pi->internal_tx_iqlo_cal_tapoff_intpa_nphy = false; + + pi->nphy_deaf_count = 0; + + wlc_phy_tbl_init_nphy(pi); + + pi->nphy_crsminpwr_adjusted = false; + pi->nphy_noisevars_adjusted = false; + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + write_phy_reg(pi, 0xe7, 0); + write_phy_reg(pi, 0xec, 0); + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + write_phy_reg(pi, 0x342, 0); + write_phy_reg(pi, 0x343, 0); + write_phy_reg(pi, 0x346, 0); + write_phy_reg(pi, 0x347, 0); + } + write_phy_reg(pi, 0xe5, 0); + write_phy_reg(pi, 0xe6, 0); + } else { + write_phy_reg(pi, 0xec, 0); + } + + write_phy_reg(pi, 0x91, 0); + write_phy_reg(pi, 0x92, 0); + if (NREV_LT(pi->pubpi.phy_rev, 6)) { + write_phy_reg(pi, 0x93, 0); + write_phy_reg(pi, 0x94, 0); + } + + and_phy_reg(pi, 0xa1, ~3); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + write_phy_reg(pi, 0x8f, 0); + write_phy_reg(pi, 0xa5, 0); + } else { + write_phy_reg(pi, 0xa5, 0); + } + + if (NREV_IS(pi->pubpi.phy_rev, 2)) + mod_phy_reg(pi, 0xdc, 0x00ff, 0x3b); + else if (NREV_LT(pi->pubpi.phy_rev, 2)) + mod_phy_reg(pi, 0xdc, 0x00ff, 0x40); + + write_phy_reg(pi, 0x203, 32); + write_phy_reg(pi, 0x201, 32); + + if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD) + write_phy_reg(pi, 0x20d, 160); + else + write_phy_reg(pi, 0x20d, 184); + + write_phy_reg(pi, 0x13a, 200); + + write_phy_reg(pi, 0x70, 80); + + write_phy_reg(pi, 0x1ff, 48); + + if (NREV_LT(pi->pubpi.phy_rev, 8)) + wlc_phy_update_mimoconfig_nphy(pi, pi->n_preamble_override); + + wlc_phy_stf_chain_upd_nphy(pi); + + if (NREV_LT(pi->pubpi.phy_rev, 2)) { + write_phy_reg(pi, 0x180, 0xaa8); + write_phy_reg(pi, 0x181, 0x9a4); + } + + if (PHY_IPA(pi)) { + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (1) << 0); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x298 : + 0x29c, (0x1ff << 7), + (pi->nphy_papd_epsilon_offset[core]) << 7); + + } + + wlc_phy_ipa_set_tx_digi_filts_nphy(pi); + } else if (NREV_GE(pi->pubpi.phy_rev, 5)) { + wlc_phy_extpa_set_tx_digi_filts_nphy(pi); + } + + wlc_phy_workarounds_nphy(pi); + + wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); + + val = read_phy_reg(pi, 0x01); + write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); + write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); + wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); + + wlapi_bmac_macphyclk_set(pi->sh->physhim, ON); + + wlc_phy_pa_override_nphy(pi, OFF); + wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX); + wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); + wlc_phy_pa_override_nphy(pi, ON); + + wlc_phy_classifier_nphy(pi, 0, 0); + wlc_phy_clip_det_nphy(pi, 0, clip1_ths); + + if (CHSPEC_IS2G(pi->radio_chanspec)) + wlc_phy_bphy_init_nphy(pi); + + tx_pwr_ctrl_state = pi->nphy_txpwrctrl; + wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); + + wlc_phy_txpwr_fixpower_nphy(pi); + + wlc_phy_txpwrctrl_idle_tssi_nphy(pi); + + wlc_phy_txpwrctrl_pwr_setup_nphy(pi); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + u32 *tx_pwrctrl_tbl = NULL; + u16 idx; + s16 pga_gn = 0; + s16 pad_gn = 0; + s32 rfpwr_offset; + + if (PHY_IPA(pi)) { + tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi); + } else { + if (CHSPEC_IS5G(pi->radio_chanspec)) { + if (NREV_IS(pi->pubpi.phy_rev, 3)) + tx_pwrctrl_tbl = + nphy_tpc_5GHz_txgain_rev3; + else if (NREV_IS(pi->pubpi.phy_rev, 4)) + tx_pwrctrl_tbl = + (pi->srom_fem5g.extpagain == + 3) ? + nphy_tpc_5GHz_txgain_HiPwrEPA : + nphy_tpc_5GHz_txgain_rev4; + else + tx_pwrctrl_tbl = + nphy_tpc_5GHz_txgain_rev5; + } else { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (pi->pubpi.radiorev == 5) + tx_pwrctrl_tbl = + nphy_tpc_txgain_epa_2057rev5; + else if (pi->pubpi.radiorev == 3) + tx_pwrctrl_tbl = + nphy_tpc_txgain_epa_2057rev3; + } else { + if (NREV_GE(pi->pubpi.phy_rev, 5) && + (pi->srom_fem2g.extpagain == 3)) + tx_pwrctrl_tbl = + nphy_tpc_txgain_HiPwrEPA; + else + tx_pwrctrl_tbl = + nphy_tpc_txgain_rev3; + } + } + } + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, + 192, 32, tx_pwrctrl_tbl); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, + 192, 32, tx_pwrctrl_tbl); + + pi->nphy_gmval = (u16) ((*tx_pwrctrl_tbl >> 16) & 0x7000); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + for (idx = 0; idx < 128; idx++) { + pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; + pad_gn = (tx_pwrctrl_tbl[idx] >> 19) & 0x1f; + rfpwr_offset = get_rf_pwr_offset(pi, pga_gn, + pad_gn); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE1TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE2TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + } + } else { + + for (idx = 0; idx < 128; idx++) { + pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; + if (CHSPEC_IS2G(pi->radio_chanspec)) + rfpwr_offset = (s16) + nphy_papd_pga_gain_delta_ipa_2g + [pga_gn]; + else + rfpwr_offset = (s16) + nphy_papd_pga_gain_delta_ipa_5g + [pga_gn]; + + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE1TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_CORE2TXPWRCTL, + 1, 576 + idx, 32, + &rfpwr_offset); + } + + } + } else { + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, + 192, 32, nphy_tpc_txgain); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, + 192, 32, nphy_tpc_txgain); + } + + if (pi->sh->phyrxchain != 0x3) + wlc_phy_rxcore_setstate_nphy((struct brcms_phy_pub *) pi, + pi->sh->phyrxchain); + + if (PHY_PERICAL_MPHASE_PENDING(pi)) + wlc_phy_cal_perical_mphase_restart(pi); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? + (pi->nphy_rssical_chanspec_2G == 0) : + (pi->nphy_rssical_chanspec_5G == 0); + + if (do_rssi_cal) + wlc_phy_rssi_cal_nphy(pi); + else + wlc_phy_restore_rssical_nphy(pi); + } else { + wlc_phy_rssi_cal_nphy(pi); + } + + if (!SCAN_RM_IN_PROGRESS(pi)) + do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? + (pi->nphy_iqcal_chanspec_2G == 0) : + (pi->nphy_iqcal_chanspec_5G == 0); + + if (!pi->do_initcal) + do_nphy_cal = false; + + if (do_nphy_cal) { + + target_gain = wlc_phy_get_tx_gain_nphy(pi); + + if (pi->antsel_type == ANTSEL_2x3) + wlc_phy_antsel_init((struct brcms_phy_pub *) pi, + true); + + if (pi->nphy_perical != PHY_PERICAL_MPHASE) { + wlc_phy_rssi_cal_nphy(pi); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + pi->nphy_cal_orig_pwr_idx[0] = + pi->nphy_txpwrindex[PHY_CORE_0] + . + index_internal; + pi->nphy_cal_orig_pwr_idx[1] = + pi->nphy_txpwrindex[PHY_CORE_1] + . + index_internal; + + wlc_phy_precal_txgain_nphy(pi); + target_gain = + wlc_phy_get_tx_gain_nphy(pi); + } + + if (wlc_phy_cal_txiqlo_nphy + (pi, target_gain, true, + false) == 0) { + if (wlc_phy_cal_rxiq_nphy + (pi, target_gain, 2, + false) == 0) + wlc_phy_savecal_nphy(pi); + + } + } else if (pi->mphase_cal_phase_id == + MPHASE_CAL_STATE_IDLE) { + wlc_phy_cal_perical((struct brcms_phy_pub *) pi, + PHY_PERICAL_PHYINIT); + } + } else { + wlc_phy_restorecal_nphy(pi); + } + + wlc_phy_txpwrctrl_coeff_setup_nphy(pi); + + wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); + + wlc_phy_nphy_tkip_rifs_war(pi, pi->sh->_rifs_phy); + + if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LE(pi->pubpi.phy_rev, 6)) + + write_phy_reg(pi, 0x70, 50); + + wlc_phy_txlpfbw_nphy(pi); + + wlc_phy_spurwar_nphy(pi); + +} + +static void wlc_phy_resetcca_nphy(struct brcms_phy *pi) +{ + u16 val; + + wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); + + val = read_phy_reg(pi, 0x01); + write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); + udelay(1); + write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); + + wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); + + wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); +} + +void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en) +{ + u16 rfctrlintc_override_val; + + if (!en) { + + pi->rfctrlIntc1_save = read_phy_reg(pi, 0x91); + pi->rfctrlIntc2_save = read_phy_reg(pi, 0x92); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + rfctrlintc_override_val = 0x1480; + else if (NREV_GE(pi->pubpi.phy_rev, 3)) + rfctrlintc_override_val = + CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; + else + rfctrlintc_override_val = + CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; + + write_phy_reg(pi, 0x91, rfctrlintc_override_val); + write_phy_reg(pi, 0x92, rfctrlintc_override_val); + } else { + write_phy_reg(pi, 0x91, pi->rfctrlIntc1_save); + write_phy_reg(pi, 0x92, pi->rfctrlIntc2_save); + } + +} + +void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi) +{ + + u16 txrx_chain = + (NPHY_RfseqCoreActv_TxRxChain0 | NPHY_RfseqCoreActv_TxRxChain1); + bool CoreActv_override = false; + + if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN0) { + txrx_chain = NPHY_RfseqCoreActv_TxRxChain0; + CoreActv_override = true; + + if (NREV_LE(pi->pubpi.phy_rev, 2)) + and_phy_reg(pi, 0xa0, ~0x20); + } else if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN1) { + txrx_chain = NPHY_RfseqCoreActv_TxRxChain1; + CoreActv_override = true; + + if (NREV_LE(pi->pubpi.phy_rev, 2)) + or_phy_reg(pi, 0xa0, 0x20); + } + + mod_phy_reg(pi, 0xa2, ((0xf << 0) | (0xf << 4)), txrx_chain); + + if (CoreActv_override) { + pi->nphy_perical = PHY_PERICAL_DISABLE; + or_phy_reg(pi, 0xa1, NPHY_RfseqMode_CoreActv_override); + } else { + pi->nphy_perical = PHY_PERICAL_MPHASE; + and_phy_reg(pi, 0xa1, ~NPHY_RfseqMode_CoreActv_override); + } +} + +void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) +{ + u16 regval; + u16 tbl_buf[16]; + uint i; + struct brcms_phy *pi = (struct brcms_phy *) pih; + u16 tbl_opcode; + bool suspend; + + pi->sh->phyrxchain = rxcore_bitmask; + + if (!pi->sh->clk) return; - and_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, - ~(RADIO_2055_CAL_LPO_ENABLE)); + suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + if (!suspend) + wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); - write_radio_reg(pi, RADIO_2055_CORE1_RXBB_LPF, 9); - write_radio_reg(pi, RADIO_2055_CORE2_RXBB_LPF, 9); + regval = read_phy_reg(pi, 0xa2); + regval &= ~(0xf << 4); + regval |= ((u16) (rxcore_bitmask & 0x3)) << 4; + write_phy_reg(pi, 0xa2, regval); - write_radio_reg(pi, RADIO_2055_CORE1_RXBB_MIDAC_HIPAS, 0x83); - write_radio_reg(pi, RADIO_2055_CORE2_RXBB_MIDAC_HIPAS, 0x83); + if ((rxcore_bitmask & 0x3) != 0x3) { - mod_radio_reg(pi, RADIO_2055_CORE1_LNA_GAINBST, - RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); - mod_radio_reg(pi, RADIO_2055_CORE2_LNA_GAINBST, - RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); - if (pi->nphy_gain_boost) { - and_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, - ~(RADIO_2055_GAINBST_DISABLE)); - and_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, - ~(RADIO_2055_GAINBST_DISABLE)); + write_phy_reg(pi, 0x20e, 1); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (pi->rx2tx_biasentry == -1) { + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, + ARRAY_SIZE(tbl_buf), 80, + 16, tbl_buf); + + for (i = 0; i < ARRAY_SIZE(tbl_buf); i++) { + if (tbl_buf[i] == + NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS) { + pi->rx2tx_biasentry = (u8) i; + tbl_opcode = + NPHY_REV3_RFSEQ_CMD_NOP; + wlc_phy_table_write_nphy( + pi, + NPHY_TBL_ID_RFSEQ, + 1, i, + 16, + &tbl_opcode); + break; + } else if (tbl_buf[i] == + NPHY_REV3_RFSEQ_CMD_END) + break; + } + } + } } else { - or_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, - RADIO_2055_GAINBST_DISABLE); - or_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, - RADIO_2055_GAINBST_DISABLE); + + write_phy_reg(pi, 0x20e, 30); + + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + if (pi->rx2tx_biasentry != -1) { + tbl_opcode = NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, + 1, pi->rx2tx_biasentry, + 16, &tbl_opcode); + pi->rx2tx_biasentry = -1; + } + } } - udelay(2); + wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); + + if (!suspend) + wlapi_enable_mac(pi->sh->physhim); +} + +u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih) +{ + u16 regval, rxen_bits; + struct brcms_phy *pi = (struct brcms_phy *) pih; + + regval = read_phy_reg(pi, 0xa2); + rxen_bits = (regval >> 4) & 0xf; + + return (u8) rxen_bits; +} + +bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pi) +{ + return PHY_IPA(pi); +} + +void wlc_phy_cal_init_nphy(struct brcms_phy *pi) +{ } static void wlc_phy_radio_preinit_205x(struct brcms_phy *pi) @@ -17449,6 +19892,252 @@ static void wlc_phy_radio_preinit_205x(struct brcms_phy *pi) } +static void wlc_phy_radio_init_2057(struct brcms_phy *pi) +{ + struct radio_20xx_regs *regs_2057_ptr = NULL; + + if (NREV_IS(pi->pubpi.phy_rev, 7)) { + regs_2057_ptr = regs_2057_rev4; + } else if (NREV_IS(pi->pubpi.phy_rev, 8) + || NREV_IS(pi->pubpi.phy_rev, 9)) { + switch (pi->pubpi.radiorev) { + case 5: + + if (pi->pubpi.radiover == 0x0) + regs_2057_ptr = regs_2057_rev5; + else if (pi->pubpi.radiover == 0x1) + regs_2057_ptr = regs_2057_rev5v1; + else + break; + + case 7: + + regs_2057_ptr = regs_2057_rev7; + break; + + case 8: + + regs_2057_ptr = regs_2057_rev8; + break; + + default: + break; + } + } + + wlc_phy_init_radio_regs_allbands(pi, regs_2057_ptr); +} + +static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) +{ + u16 rcal_reg = 0; + int i; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + if (pi->pubpi.radiorev == 5) { + + and_phy_reg(pi, 0x342, ~(0x1 << 1)); + + udelay(10); + + mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x1); + mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, + 0x1); + } + mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x1); + + udelay(10); + + mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x3, 0x3); + + for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { + rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS); + if (rcal_reg & 0x1) + break; + + udelay(100); + } + + if (WARN(i == MAX_205x_RCAL_WAITLOOPS, + "HW error: radio calib2")) + return 0; + + mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x2, 0x0); + + rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS) & 0x3e; + + mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x0); + if (pi->pubpi.radiorev == 5) { + + mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x0); + mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, + 0x0); + } + + if ((pi->pubpi.radiorev <= 4) || (pi->pubpi.radiorev == 6)) { + + mod_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, 0x3c, + rcal_reg); + mod_radio_reg(pi, RADIO_2057_BANDGAP_RCAL_TRIM, 0xf0, + rcal_reg << 2); + } + + } else if (NREV_IS(pi->pubpi.phy_rev, 3)) { + u16 savereg; + + savereg = + read_radio_reg( + pi, + RADIO_2056_SYN_PLL_MAST2 | + RADIO_2056_SYN); + write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, + savereg | 0x7); + udelay(10); + + write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, + 0x1); + udelay(10); + + write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, + 0x9); + + for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { + rcal_reg = read_radio_reg( + pi, + RADIO_2056_SYN_RCAL_CODE_OUT | + RADIO_2056_SYN); + if (rcal_reg & 0x80) + break; + + udelay(100); + } + + if (WARN(i == MAX_205x_RCAL_WAITLOOPS, + "HW error: radio calib3")) + return 0; + + write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, + 0x1); + + rcal_reg = + read_radio_reg(pi, + RADIO_2056_SYN_RCAL_CODE_OUT | + RADIO_2056_SYN); + + write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, + 0x0); + + write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, + savereg); + + return rcal_reg & 0x1f; + } + return rcal_reg & 0x3e; +} + +static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) +{ + u16 rccal_valid; + int i; + bool chip43226_6362A0; + + chip43226_6362A0 = ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 4) + || (pi->pubpi.radiorev == 6)); + + rccal_valid = 0; + if (chip43226_6362A0) { + write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x61); + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xc0); + } else { + write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x61); + + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xe9); + } + write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); + + for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { + rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); + if (rccal_valid & 0x2) + break; + + udelay(500); + } + + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); + + rccal_valid = 0; + if (chip43226_6362A0) { + write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x69); + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); + } else { + write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x69); + + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xd5); + } + write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); + + for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { + rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); + if (rccal_valid & 0x2) + break; + + udelay(500); + } + + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); + + rccal_valid = 0; + if (chip43226_6362A0) { + write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x73); + + write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x28); + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); + } else { + write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x73); + write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); + write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0x99); + } + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); + + for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { + rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); + if (rccal_valid & 0x2) + break; + + udelay(500); + } + + if (WARN(!(rccal_valid & 0x2), "HW error: radio calib4")) + return 0; + + write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); + + return rccal_valid; +} + +static void wlc_phy_radio_postinit_2057(struct brcms_phy *pi) +{ + + mod_radio_reg(pi, RADIO_2057_XTALPUOVR_PINCTRL, 0x1, 0x1); + + mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x78); + mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x80); + mdelay(2); + mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x0); + mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x0); + + if (pi->phy_init_por) { + wlc_phy_radio205x_rcal(pi); + wlc_phy_radio2057_rccal(pi); + } + + mod_radio_reg(pi, RADIO_2057_RFPLL_MASTER, 0x8, 0x0); +} + static void wlc_phy_radio_init_2056(struct brcms_phy *pi) { struct radio_regs *regs_SYN_2056_ptr = NULL; @@ -17533,59 +20222,166 @@ static void wlc_phy_radio_postinit_2056(struct brcms_phy *pi) wlc_phy_radio205x_rcal(pi); } -static void wlc_phy_radio_init_2057(struct brcms_phy *pi) +static void wlc_phy_radio_preinit_2055(struct brcms_phy *pi) { - struct radio_20xx_regs *regs_2057_ptr = NULL; - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - regs_2057_ptr = regs_2057_rev4; - } else if (NREV_IS(pi->pubpi.phy_rev, 8) - || NREV_IS(pi->pubpi.phy_rev, 9)) { - switch (pi->pubpi.radiorev) { - case 5: + and_phy_reg(pi, 0x78, ~RFCC_POR_FORCE); + or_phy_reg(pi, 0x78, RFCC_CHIP0_PU | RFCC_OE_POR_FORCE); - if (pi->pubpi.radiover == 0x0) - regs_2057_ptr = regs_2057_rev5; - else if (pi->pubpi.radiover == 0x1) - regs_2057_ptr = regs_2057_rev5v1; - else - break; - - case 7: - - regs_2057_ptr = regs_2057_rev7; - break; - - case 8: - - regs_2057_ptr = regs_2057_rev8; - break; - - default: - break; - } - } - - wlc_phy_init_radio_regs_allbands(pi, regs_2057_ptr); + or_phy_reg(pi, 0x78, RFCC_POR_FORCE); } -static void wlc_phy_radio_postinit_2057(struct brcms_phy *pi) +static void wlc_phy_radio_init_2055(struct brcms_phy *pi) +{ + wlc_phy_init_radio_regs(pi, regs_2055, RADIO_DEFAULT_CORE); +} + +static void wlc_phy_radio_postinit_2055(struct brcms_phy *pi) { - mod_radio_reg(pi, RADIO_2057_XTALPUOVR_PINCTRL, 0x1, 0x1); + and_radio_reg(pi, RADIO_2055_MASTER_CNTRL1, + ~(RADIO_2055_JTAGCTRL_MASK | RADIO_2055_JTAGSYNC_MASK)); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x78); - mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x80); - mdelay(2); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x0); - mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x0); - - if (pi->phy_init_por) { - wlc_phy_radio205x_rcal(pi); - wlc_phy_radio2057_rccal(pi); + if (((pi->sh->sromrev >= 4) + && !(pi->sh->boardflags2 & BFL2_RXBB_INT_REG_DIS)) + || ((pi->sh->sromrev < 4))) { + and_radio_reg(pi, RADIO_2055_CORE1_RXBB_REGULATOR, 0x7F); + and_radio_reg(pi, RADIO_2055_CORE2_RXBB_REGULATOR, 0x7F); } - mod_radio_reg(pi, RADIO_2057_RFPLL_MASTER, 0x8, 0x0); + mod_radio_reg(pi, RADIO_2055_RRCCAL_N_OPT_SEL, 0x3F, 0x2C); + write_radio_reg(pi, RADIO_2055_CAL_MISC, 0x3C); + + and_radio_reg(pi, RADIO_2055_CAL_MISC, + ~(RADIO_2055_RRCAL_START | RADIO_2055_RRCAL_RST_N)); + + or_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, RADIO_2055_CAL_LPO_ENABLE); + + or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_RST_N); + + udelay(1000); + + or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_START); + + SPINWAIT(((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & + RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000); + + if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & + RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE, + "HW error: radio calibration1\n")) + return; + + and_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, + ~(RADIO_2055_CAL_LPO_ENABLE)); + + wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); + + write_radio_reg(pi, RADIO_2055_CORE1_RXBB_LPF, 9); + write_radio_reg(pi, RADIO_2055_CORE2_RXBB_LPF, 9); + + write_radio_reg(pi, RADIO_2055_CORE1_RXBB_MIDAC_HIPAS, 0x83); + write_radio_reg(pi, RADIO_2055_CORE2_RXBB_MIDAC_HIPAS, 0x83); + + mod_radio_reg(pi, RADIO_2055_CORE1_LNA_GAINBST, + RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); + mod_radio_reg(pi, RADIO_2055_CORE2_LNA_GAINBST, + RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); + if (pi->nphy_gain_boost) { + and_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, + ~(RADIO_2055_GAINBST_DISABLE)); + and_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, + ~(RADIO_2055_GAINBST_DISABLE)); + } else { + or_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, + RADIO_2055_GAINBST_DISABLE); + or_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, + RADIO_2055_GAINBST_DISABLE); + } + + udelay(2); +} + +void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on) +{ + if (on) { + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (!pi->radio_is_on) { + wlc_phy_radio_preinit_205x(pi); + wlc_phy_radio_init_2057(pi); + wlc_phy_radio_postinit_2057(pi); + } + + wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, + pi->radio_chanspec); + } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { + wlc_phy_radio_preinit_205x(pi); + wlc_phy_radio_init_2056(pi); + wlc_phy_radio_postinit_2056(pi); + + wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, + pi->radio_chanspec); + } else { + wlc_phy_radio_preinit_2055(pi); + wlc_phy_radio_init_2055(pi); + wlc_phy_radio_postinit_2055(pi); + } + + pi->radio_is_on = true; + + } else { + + if (NREV_GE(pi->pubpi.phy_rev, 3) + && NREV_LT(pi->pubpi.phy_rev, 7)) { + and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); + mod_radio_reg(pi, RADIO_2056_SYN_COM_PU, 0x2, 0x0); + + write_radio_reg(pi, + RADIO_2056_TX_PADA_BOOST_TUNE | + RADIO_2056_TX0, 0); + write_radio_reg(pi, + RADIO_2056_TX_PADG_BOOST_TUNE | + RADIO_2056_TX0, 0); + write_radio_reg(pi, + RADIO_2056_TX_PGAA_BOOST_TUNE | + RADIO_2056_TX0, 0); + write_radio_reg(pi, + RADIO_2056_TX_PGAG_BOOST_TUNE | + RADIO_2056_TX0, 0); + mod_radio_reg(pi, + RADIO_2056_TX_MIXA_BOOST_TUNE | + RADIO_2056_TX0, 0xf0, 0); + write_radio_reg(pi, + RADIO_2056_TX_MIXG_BOOST_TUNE | + RADIO_2056_TX0, 0); + + write_radio_reg(pi, + RADIO_2056_TX_PADA_BOOST_TUNE | + RADIO_2056_TX1, 0); + write_radio_reg(pi, + RADIO_2056_TX_PADG_BOOST_TUNE | + RADIO_2056_TX1, 0); + write_radio_reg(pi, + RADIO_2056_TX_PGAA_BOOST_TUNE | + RADIO_2056_TX1, 0); + write_radio_reg(pi, + RADIO_2056_TX_PGAG_BOOST_TUNE | + RADIO_2056_TX1, 0); + mod_radio_reg(pi, + RADIO_2056_TX_MIXA_BOOST_TUNE | + RADIO_2056_TX1, 0xf0, 0); + write_radio_reg(pi, + RADIO_2056_TX_MIXG_BOOST_TUNE | + RADIO_2056_TX1, 0); + + pi->radio_is_on = false; + } + + if (NREV_GE(pi->pubpi.phy_rev, 8)) { + and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); + pi->radio_is_on = false; + } + + } } static bool @@ -18171,116 +20967,6 @@ void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi) udelay(300); } -#define MAX_205x_RCAL_WAITLOOPS 10000 - -static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) -{ - u16 rcal_reg = 0; - int i; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (pi->pubpi.radiorev == 5) { - - and_phy_reg(pi, 0x342, ~(0x1 << 1)); - - udelay(10); - - mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x1); - mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, - 0x1); - } - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x1); - - udelay(10); - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x3, 0x3); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS); - if (rcal_reg & 0x1) - break; - - udelay(100); - } - - if (WARN(i == MAX_205x_RCAL_WAITLOOPS, - "HW error: radio calib2")) - return 0; - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x2, 0x0); - - rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS) & 0x3e; - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x0); - if (pi->pubpi.radiorev == 5) { - - mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x0); - mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, - 0x0); - } - - if ((pi->pubpi.radiorev <= 4) || (pi->pubpi.radiorev == 6)) { - - mod_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, 0x3c, - rcal_reg); - mod_radio_reg(pi, RADIO_2057_BANDGAP_RCAL_TRIM, 0xf0, - rcal_reg << 2); - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 3)) { - u16 savereg; - - savereg = - read_radio_reg( - pi, - RADIO_2056_SYN_PLL_MAST2 | - RADIO_2056_SYN); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, - savereg | 0x7); - udelay(10); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x1); - udelay(10); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x9); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rcal_reg = read_radio_reg( - pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); - if (rcal_reg & 0x80) - break; - - udelay(100); - } - - if (WARN(i == MAX_205x_RCAL_WAITLOOPS, - "HW error: radio calib3")) - return 0; - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x1); - - rcal_reg = - read_radio_reg(pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x0); - - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, - savereg); - - return rcal_reg & 0x1f; - } - return rcal_reg & 0x3e; -} - static void wlc_phy_chanspec_radio2057_setup( struct brcms_phy *pi, @@ -18478,425 +21164,6 @@ wlc_phy_chanspec_radio2057_setup( wlc_phy_radio205x_vcocal_nphy(pi); } -static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) -{ - u16 rccal_valid; - int i; - bool chip43226_6362A0; - - chip43226_6362A0 = ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x61); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xc0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x61); - - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xe9); - } - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x69); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x69); - - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xd5); - } - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x73); - - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x28); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x73); - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0x99); - } - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - if (WARN(!(rccal_valid & 0x2), "HW error: radio calib4")) - return 0; - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - return rccal_valid; -} - -static void -wlc_phy_adjust_rx_analpfbw_nphy(struct brcms_phy *pi, u16 reduction_factr) -{ - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && - CHSPEC_IS40(pi->radio_chanspec)) { - if (!pi->nphy_anarxlpf_adjusted) { - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - RADIO_2056_RX0), - ((pi->nphy_rccal_value + - reduction_factr) | 0x80)); - - pi->nphy_anarxlpf_adjusted = true; - } - } else { - if (pi->nphy_anarxlpf_adjusted) { - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - RADIO_2056_RX0), - (pi->nphy_rccal_value | 0x80)); - - pi->nphy_anarxlpf_adjusted = false; - } - } - } -} - -static void -wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, - int *tone_id_buf, u32 *noise_var_buf) -{ - int i; - u32 offset; - int tone_id; - int tbllen = - CHSPEC_IS40(pi->radio_chanspec) ? - NPHY_NOISEVAR_TBLLEN40 : NPHY_NOISEVAR_TBLLEN20; - - if (pi->nphy_noisevars_adjusted) { - for (i = 0; i < pi->nphy_saved_noisevars.bufcount; i++) { - tone_id = pi->nphy_saved_noisevars.tone_id[i]; - offset = (tone_id >= 0) ? - ((tone_id * - 2) + 1) : (tbllen + (tone_id * 2) + 1); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - &pi->nphy_saved_noisevars.min_noise_vars[i]); - } - - pi->nphy_saved_noisevars.bufcount = 0; - pi->nphy_noisevars_adjusted = false; - } - - if ((noise_var_buf != NULL) && (tone_id_buf != NULL)) { - pi->nphy_saved_noisevars.bufcount = 0; - - for (i = 0; i < ntones; i++) { - tone_id = tone_id_buf[i]; - offset = (tone_id >= 0) ? - ((tone_id * 2) + 1) : - (tbllen + (tone_id * 2) + 1); - pi->nphy_saved_noisevars.tone_id[i] = tone_id; - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - &pi->nphy_saved_noisevars. - min_noise_vars[i]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, &noise_var_buf[i]); - pi->nphy_saved_noisevars.bufcount++; - } - - pi->nphy_noisevars_adjusted = true; - } -} - -static void wlc_phy_adjust_crsminpwr_nphy(struct brcms_phy *pi, u8 minpwr) -{ - u16 regval; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && - CHSPEC_IS40(pi->radio_chanspec)) { - if (!pi->nphy_crsminpwr_adjusted) { - regval = read_phy_reg(pi, 0x27d); - pi->nphy_crsminpwr[0] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x27d, regval); - - regval = read_phy_reg(pi, 0x280); - pi->nphy_crsminpwr[1] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x280, regval); - - regval = read_phy_reg(pi, 0x283); - pi->nphy_crsminpwr[2] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x283, regval); - - pi->nphy_crsminpwr_adjusted = true; - } - } else { - if (pi->nphy_crsminpwr_adjusted) { - regval = read_phy_reg(pi, 0x27d); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[0]; - write_phy_reg(pi, 0x27d, regval); - - regval = read_phy_reg(pi, 0x280); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[1]; - write_phy_reg(pi, 0x280, regval); - - regval = read_phy_reg(pi, 0x283); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[2]; - write_phy_reg(pi, 0x283, regval); - - pi->nphy_crsminpwr_adjusted = false; - } - } - } -} - -static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi) -{ - u8 tx_lpf_bw = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 3; - else - tx_lpf_bw = 1; - - if (PHY_IPA(pi)) { - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 5; - else - tx_lpf_bw = 4; - } - - write_phy_reg(pi, 0xe8, - (tx_lpf_bw << 0) | - (tx_lpf_bw << 3) | - (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); - - if (PHY_IPA(pi)) { - - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 4; - else - tx_lpf_bw = 1; - - write_phy_reg(pi, 0xe9, - (tx_lpf_bw << 0) | - (tx_lpf_bw << 3) | - (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); - } - } -} - -static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) -{ - u16 cur_channel = 0; - int nphy_adj_tone_id_buf[] = { 57, 58 }; - u32 nphy_adj_noise_var_buf[] = { 0x3ff, 0x3ff }; - bool isAdjustNoiseVar = false; - uint numTonesAdjust = 0; - u32 tempval = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - cur_channel = CHSPEC_CHANNEL(pi->radio_chanspec); - - if (pi->nphy_gband_spurwar_en) { - - wlc_phy_adjust_rx_analpfbw_nphy( - pi, - NPHY_ANARXLPFBW_REDUCTIONFACT); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((cur_channel == 11) - && CHSPEC_IS40(pi->radio_chanspec)) - wlc_phy_adjust_min_noisevar_nphy( - pi, 2, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - else - wlc_phy_adjust_min_noisevar_nphy(pi, 0, - NULL, - NULL); - } - - wlc_phy_adjust_crsminpwr_nphy(pi, - NPHY_ADJUSTED_MINCRSPOWER); - } - - if ((pi->nphy_gband_spurwar2_en) - && CHSPEC_IS2G(pi->radio_chanspec)) { - - if (CHSPEC_IS40(pi->radio_chanspec)) { - switch (cur_channel) { - case 3: - nphy_adj_tone_id_buf[0] = 57; - nphy_adj_tone_id_buf[1] = 58; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 4: - nphy_adj_tone_id_buf[0] = 41; - nphy_adj_tone_id_buf[1] = 42; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 5: - nphy_adj_tone_id_buf[0] = 25; - nphy_adj_tone_id_buf[1] = 26; - nphy_adj_noise_var_buf[0] = 0x24f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 6: - nphy_adj_tone_id_buf[0] = 9; - nphy_adj_tone_id_buf[1] = 10; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 7: - nphy_adj_tone_id_buf[0] = 121; - nphy_adj_tone_id_buf[1] = 122; - nphy_adj_noise_var_buf[0] = 0x18f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 8: - nphy_adj_tone_id_buf[0] = 105; - nphy_adj_tone_id_buf[1] = 106; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 9: - nphy_adj_tone_id_buf[0] = 89; - nphy_adj_tone_id_buf[1] = 90; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 10: - nphy_adj_tone_id_buf[0] = 73; - nphy_adj_tone_id_buf[1] = 74; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - default: - isAdjustNoiseVar = false; - break; - } - } - - if (isAdjustNoiseVar) { - numTonesAdjust = sizeof(nphy_adj_tone_id_buf) / - sizeof(nphy_adj_tone_id_buf[0]); - - wlc_phy_adjust_min_noisevar_nphy( - pi, - numTonesAdjust, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - - tempval = 0; - - } else { - wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, - NULL); - } - } - - if ((pi->nphy_aband_spurwar_en) && - (CHSPEC_IS5G(pi->radio_chanspec))) { - switch (cur_channel) { - case 54: - nphy_adj_tone_id_buf[0] = 32; - nphy_adj_noise_var_buf[0] = 0x25f; - break; - case 38: - case 102: - case 118: - nphy_adj_tone_id_buf[0] = 0; - nphy_adj_noise_var_buf[0] = 0x0; - break; - case 134: - nphy_adj_tone_id_buf[0] = 32; - nphy_adj_noise_var_buf[0] = 0x21f; - break; - case 151: - nphy_adj_tone_id_buf[0] = 16; - nphy_adj_noise_var_buf[0] = 0x23f; - break; - case 153: - case 161: - nphy_adj_tone_id_buf[0] = 48; - nphy_adj_noise_var_buf[0] = 0x23f; - break; - default: - nphy_adj_tone_id_buf[0] = 0; - nphy_adj_noise_var_buf[0] = 0x0; - break; - } - - if (nphy_adj_tone_id_buf[0] - && nphy_adj_noise_var_buf[0]) - wlc_phy_adjust_min_noisevar_nphy( - pi, 1, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - else - wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, - NULL); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); - } -} - static void wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, const struct nphy_sfo_cfg *ci) @@ -19099,353 +21366,6 @@ void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) } -static void wlc_phy_savecal_nphy(struct brcms_phy *pi) -{ - void *tbl_ptr; - int coreNum; - u16 *txcal_radio_regs = NULL; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, - &pi->calibration_cache. - rxcal_coeffs_2G); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); - - pi->calibration_cache.txcal_radio_regs_2G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_2G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); - } else { - pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); - pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); - } - - pi->nphy_iqcal_chanspec_2G = pi->radio_chanspec; - tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; - } else { - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, - &pi->calibration_cache. - rxcal_coeffs_5G); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); - - pi->calibration_cache.txcal_radio_regs_5G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_5G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); - } else { - pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); - pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); - } - - pi->nphy_iqcal_chanspec_5G = pi->radio_chanspec; - tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - - txcal_radio_regs[2 * coreNum] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_I); - txcal_radio_regs[2 * coreNum + 1] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_Q); - - txcal_radio_regs[2 * coreNum + 4] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_I); - txcal_radio_regs[2 * coreNum + 5] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_Q); - } - } - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 8, 80, 16, tbl_ptr); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) -{ - u16 *loft_comp; - u16 txcal_coeffs_bphy[4]; - u16 *tbl_ptr; - int coreNum; - u16 *txcal_radio_regs = NULL; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->nphy_iqcal_chanspec_2G == 0) - return; - - tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; - loft_comp = &pi->calibration_cache.txcal_coeffs_2G[5]; - } else { - if (pi->nphy_iqcal_chanspec_5G == 0) - return; - - tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; - loft_comp = &pi->calibration_cache.txcal_coeffs_5G[5]; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, 16, tbl_ptr); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - txcal_coeffs_bphy[0] = tbl_ptr[0]; - txcal_coeffs_bphy[1] = tbl_ptr[1]; - txcal_coeffs_bphy[2] = tbl_ptr[2]; - txcal_coeffs_bphy[3] = tbl_ptr[3]; - } else { - txcal_coeffs_bphy[0] = 0; - txcal_coeffs_bphy[1] = 0; - txcal_coeffs_bphy[2] = 0; - txcal_coeffs_bphy[3] = 0; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 88, 16, - txcal_coeffs_bphy); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 85, 16, loft_comp); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 93, 16, loft_comp); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) - wlc_phy_tx_iq_war_nphy(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[0]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[1]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[2]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[3]); - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[4]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[5]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[6]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[7]); - } else { - write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_2G[0]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_2G[1]); - write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_2G[2]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_2G[3]); - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, - &pi->calibration_cache. - rxcal_coeffs_2G); - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[0]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[1]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[2]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[3]); - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[4]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[5]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[6]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[7]); - } else { - write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_5G[0]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_5G[1]); - write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_5G[2]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_5G[3]); - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, - &pi->calibration_cache. - rxcal_coeffs_5G); - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_I, - txcal_radio_regs[2 * coreNum]); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_Q, - txcal_radio_regs[2 * coreNum + 1]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_I, - txcal_radio_regs[2 * coreNum + 4]); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_Q, - txcal_radio_regs[2 * coreNum + 5]); - } - } -} - void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init) { struct brcms_phy *pi = (struct brcms_phy *) ppi; @@ -19531,18 +21451,6 @@ u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val) return new_ctl; } -static void wlc_phy_clip_det_nphy(struct brcms_phy *pi, u8 write, u16 *vals) -{ - - if (write == 0) { - vals[0] = read_phy_reg(pi, 0x2c); - vals[1] = read_phy_reg(pi, 0x42); - } else { - write_phy_reg(pi, 0x2c, vals[0]); - write_phy_reg(pi, 0x42, vals[1]); - } -} - void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd) { u16 trigger_mask, status_mask; @@ -19587,575 +21495,6 @@ void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd) WARN(read_phy_reg(pi, 0xa4) & status_mask, "HW error in rf"); } -static void -wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, - u8 len) -{ - u32 t1_offset, t2_offset; - u8 ctr; - u8 end_event = - NREV_GE(pi->pubpi.phy_rev, - 3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END; - u8 end_dly = 1; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - t1_offset = cmd << 4; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t1_offset, 8, - events); - t2_offset = t1_offset + 0x080; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t2_offset, 8, - dlys); - - for (ctr = len; ctr < 16; ctr++) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - t1_offset + ctr, 8, &end_event); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - t2_offset + ctr, 8, &end_dly); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static u16 wlc_phy_read_lpf_bw_ctl_nphy(struct brcms_phy *pi, u16 offset) -{ - u16 lpf_bw_ctl_val = 0; - u16 rx2tx_lpf_rc_lut_offset = 0; - - if (offset == 0) { - if (CHSPEC_IS40(pi->radio_chanspec)) - rx2tx_lpf_rc_lut_offset = 0x159; - else - rx2tx_lpf_rc_lut_offset = 0x154; - } else { - rx2tx_lpf_rc_lut_offset = offset; - } - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - (u32) rx2tx_lpf_rc_lut_offset, 16, - &lpf_bw_ctl_val); - - lpf_bw_ctl_val = lpf_bw_ctl_val & 0x7; - - return lpf_bw_ctl_val; -} - -static void -wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, - u8 core_mask, u8 off, u8 override_id) -{ - u8 core_num; - u16 addr = 0, en_addr = 0, val_addr = 0, en_mask = 0, val_mask = 0; - u8 val_shift = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - en_mask = field; - for (core_num = 0; core_num < 2; core_num++) { - if (override_id == NPHY_REV7_RFCTRLOVERRIDE_ID0) { - - switch (field) { - case (0x1 << 2): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 7): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 7); - val_shift = 7; - break; - case (0x1 << 10): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : - 0xfa; - val_mask = (0x7 << 4); - val_shift = 4; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7b : - 0x7e; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 12): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7c : - 0x7f; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x3 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x348 : - 0x349; - val_mask = (0xff << 0); - val_shift = 0; - break; - case (0x1 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x348 : - 0x349; - val_mask = (0xf << 0); - val_shift = 0; - break; - default: - addr = 0xffff; - break; - } - } else if (override_id == - NPHY_REV7_RFCTRLOVERRIDE_ID1) { - - switch (field) { - case (0x1 << 1): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 3); - val_shift = 3; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 2): - - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 7): - - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x7 << 8); - val_shift = 8; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 14); - val_shift = 14; - break; - case (0x1 << 10): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 13); - val_shift = 13; - break; - case (0x1 << 9): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 12); - val_shift = 12; - break; - case (0x1 << 8): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 11); - val_shift = 11; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 0); - val_shift = 0; - break; - default: - addr = 0xffff; - break; - } - } else if (override_id == - NPHY_REV7_RFCTRLOVERRIDE_ID2) { - - switch (field) { - case (0x1 << 3): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 3); - val_shift = 3; - break; - case (0x1 << 1): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 0); - val_shift = 0; - break; - case (0x1 << 2): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 4); - val_shift = 4; - break; - default: - addr = 0xffff; - break; - } - } - - if (off) { - and_phy_reg(pi, en_addr, ~en_mask); - and_phy_reg(pi, val_addr, ~val_mask); - } else { - - if ((core_mask == 0) - || (core_mask & (1 << core_num))) { - or_phy_reg(pi, en_addr, en_mask); - - if (addr != 0xffff) - mod_phy_reg(pi, val_addr, - val_mask, - (value << - val_shift)); - } - } - } - } -} - -static void -wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, - u8 core_mask, u8 off) -{ - u8 core_num; - u16 addr = 0, mask = 0, en_addr = 0, val_addr = 0, en_mask = - 0, val_mask = 0; - u8 shift = 0, val_shift = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - - en_mask = field; - for (core_num = 0; core_num < 2; core_num++) { - - switch (field) { - case (0x1 << 1): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 0); - val_shift = 0; - break; - case (0x1 << 2): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 7): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 7); - val_shift = 7; - break; - case (0x1 << 8): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x7 << 8); - val_shift = 8; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x7 << 13); - val_shift = 13; - break; - - case (0x1 << 9): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : 0xfa; - val_mask = (0x7 << 0); - val_shift = 0; - break; - - case (0x1 << 10): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : 0xfa; - val_mask = (0x7 << 4); - val_shift = 4; - break; - - case (0x1 << 12): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7b : 0x7e; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7c : 0x7f; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 14): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf9 : 0xfb; - val_mask = (0x3 << 6); - val_shift = 6; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0xe5 : 0xe6; - val_addr = (core_num == 0) ? 0xf9 : 0xfb; - val_mask = (0x1 << 15); - val_shift = 15; - break; - default: - addr = 0xffff; - break; - } - - if (off) { - and_phy_reg(pi, en_addr, ~en_mask); - and_phy_reg(pi, val_addr, ~val_mask); - } else { - - if ((core_mask == 0) - || (core_mask & (1 << core_num))) { - or_phy_reg(pi, en_addr, en_mask); - - if (addr != 0xffff) - mod_phy_reg(pi, val_addr, - val_mask, - (value << - val_shift)); - } - } - } - } else { - - if (off) { - and_phy_reg(pi, 0xec, ~field); - value = 0x0; - } else { - or_phy_reg(pi, 0xec, field); - } - - for (core_num = 0; core_num < 2; core_num++) { - - switch (field) { - case (0x1 << 1): - case (0x1 << 9): - case (0x1 << 12): - case (0x1 << 13): - case (0x1 << 14): - addr = 0x78; - - core_mask = 0x1; - break; - case (0x1 << 2): - case (0x1 << 3): - case (0x1 << 4): - case (0x1 << 5): - case (0x1 << 6): - case (0x1 << 7): - case (0x1 << 8): - addr = (core_num == 0) ? 0x7a : 0x7d; - break; - case (0x1 << 10): - addr = (core_num == 0) ? 0x7b : 0x7e; - break; - case (0x1 << 11): - addr = (core_num == 0) ? 0x7c : 0x7f; - break; - default: - addr = 0xffff; - } - - switch (field) { - case (0x1 << 1): - mask = (0x7 << 3); - shift = 3; - break; - case (0x1 << 9): - mask = (0x1 << 2); - shift = 2; - break; - case (0x1 << 12): - mask = (0x1 << 8); - shift = 8; - break; - case (0x1 << 13): - mask = (0x1 << 9); - shift = 9; - break; - case (0x1 << 14): - mask = (0xf << 12); - shift = 12; - break; - case (0x1 << 2): - mask = (0x1 << 0); - shift = 0; - break; - case (0x1 << 3): - mask = (0x1 << 1); - shift = 1; - break; - case (0x1 << 4): - mask = (0x1 << 2); - shift = 2; - break; - case (0x1 << 5): - mask = (0x3 << 4); - shift = 4; - break; - case (0x1 << 6): - mask = (0x3 << 6); - shift = 6; - break; - case (0x1 << 7): - mask = (0x1 << 8); - shift = 8; - break; - case (0x1 << 8): - mask = (0x1 << 9); - shift = 9; - break; - case (0x1 << 10): - mask = 0x1fff; - shift = 0x0; - break; - case (0x1 << 11): - mask = 0x1fff; - shift = 0x0; - break; - default: - mask = 0x0; - shift = 0x0; - break; - } - - if ((addr != 0xffff) && (core_mask & (1 << core_num))) - mod_phy_reg(pi, addr, mask, (value << shift)); - } - - or_phy_reg(pi, 0xec, (0x1 << 0)); - or_phy_reg(pi, 0x78, (0x1 << 0)); - udelay(1); - and_phy_reg(pi, 0xec, ~(0x1 << 0)); - } -} - static void wlc_phy_rfctrl_override_1tomany_nphy(struct brcms_phy *pi, u16 cmd, u16 value, u8 core_mask, u8 off) @@ -21067,491 +22406,6 @@ wlc_phy_set_rssi_2055_vcm(struct brcms_phy *pi, u8 rssi_type, u8 *vcm_buf) } } -void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi) -{ - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_rssi_cal_nphy_rev3(pi); - } else { - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_NB); - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W1); - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W2); - } -} - -static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) -{ - s32 target_code; - u16 classif_state; - u16 clip_state[2]; - u16 rssi_ctrl_state[2], pd_state[2]; - u16 rfctrlintc_state[2], rfpdcorerxtx_state[2]; - u16 rfctrlintc_override_val; - u16 clip_off[] = { 0xffff, 0xffff }; - u16 rf_pd_val, pd_mask, rssi_ctrl_mask; - u8 vcm, min_vcm, vcm_tmp[4]; - u8 vcm_final[4] = { 0, 0, 0, 0 }; - u8 result_idx, ctr; - s32 poll_results[4][4] = { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - }; - s32 poll_miniq[4][2] = { - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0} - }; - s32 min_d, curr_d; - s32 fine_digital_offset[4]; - s32 poll_results_min[4] = { 0, 0, 0, 0 }; - s32 min_poll; - - switch (rssi_type) { - case NPHY_RSSI_SEL_NB: - target_code = NPHY_RSSICAL_NB_TARGET; - break; - case NPHY_RSSI_SEL_W1: - target_code = NPHY_RSSICAL_W1_TARGET; - break; - case NPHY_RSSI_SEL_W2: - target_code = NPHY_RSSICAL_W2_TARGET; - break; - default: - return; - break; - } - - classif_state = wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); - wlc_phy_clip_det_nphy(pi, 0, clip_state); - wlc_phy_clip_det_nphy(pi, 1, clip_off); - - rf_pd_val = (rssi_type == NPHY_RSSI_SEL_NB) ? 0x6 : 0x4; - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110; - - rfctrlintc_state[0] = read_phy_reg(pi, 0x91); - rfpdcorerxtx_state[0] = read_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX); - write_phy_reg(pi, 0x91, rfctrlintc_override_val); - write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rf_pd_val); - - rfctrlintc_state[1] = read_phy_reg(pi, 0x92); - rfpdcorerxtx_state[1] = read_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX); - write_phy_reg(pi, 0x92, rfctrlintc_override_val); - write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rf_pd_val); - - pd_mask = RADIO_2055_NBRSSI_PD | RADIO_2055_WBRSSI_G1_PD | - RADIO_2055_WBRSSI_G2_PD; - pd_state[0] = - read_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC) & pd_mask; - pd_state[1] = - read_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC) & pd_mask; - mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, 0); - mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, 0); - rssi_ctrl_mask = RADIO_2055_NBRSSI_SEL | RADIO_2055_WBRSSI_G1_SEL | - RADIO_2055_WBRSSI_G2_SEL; - rssi_ctrl_state[0] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE1) & rssi_ctrl_mask; - rssi_ctrl_state[1] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE2) & rssi_ctrl_mask; - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, - NPHY_RAIL_I, rssi_type); - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, - NPHY_RAIL_Q, rssi_type); - - for (vcm = 0; vcm < 4; vcm++) { - - vcm_tmp[0] = vcm_tmp[1] = vcm_tmp[2] = vcm_tmp[3] = vcm; - if (rssi_type != NPHY_RSSI_SEL_W2) - wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_tmp); - - wlc_phy_poll_rssi_nphy(pi, rssi_type, &poll_results[vcm][0], - NPHY_RSSICAL_NPOLL); - - if ((rssi_type == NPHY_RSSI_SEL_W1) - || (rssi_type == NPHY_RSSI_SEL_W2)) { - for (ctr = 0; ctr < 2; ctr++) - poll_miniq[vcm][ctr] = - min(poll_results[vcm][ctr * 2 + 0], - poll_results[vcm][ctr * 2 + 1]); - } - } - - for (result_idx = 0; result_idx < 4; result_idx++) { - min_d = NPHY_RSSICAL_MAXD; - min_vcm = 0; - min_poll = NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL + 1; - for (vcm = 0; vcm < 4; vcm++) { - curr_d = ABS(((rssi_type == NPHY_RSSI_SEL_NB) ? - poll_results[vcm][result_idx] : - poll_miniq[vcm][result_idx / 2]) - - (target_code * NPHY_RSSICAL_NPOLL)); - if (curr_d < min_d) { - min_d = curr_d; - min_vcm = vcm; - } - if (poll_results[vcm][result_idx] < min_poll) - min_poll = poll_results[vcm][result_idx]; - } - vcm_final[result_idx] = min_vcm; - poll_results_min[result_idx] = min_poll; - } - - if (rssi_type != NPHY_RSSI_SEL_W2) - wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_final); - - for (result_idx = 0; result_idx < 4; result_idx++) { - fine_digital_offset[result_idx] = - (target_code * NPHY_RSSICAL_NPOLL) - - poll_results[vcm_final[result_idx]][result_idx]; - if (fine_digital_offset[result_idx] < 0) { - fine_digital_offset[result_idx] = - ABS(fine_digital_offset[result_idx]); - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; - fine_digital_offset[result_idx] = - -fine_digital_offset[result_idx]; - } else { - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; - } - - if (poll_results_min[result_idx] == - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) - fine_digital_offset[result_idx] = - (target_code - NPHY_RSSICAL_MAXREAD - 1); - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, - (s8) - fine_digital_offset[result_idx], - (result_idx / 2 == - 0) ? RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - (result_idx % 2 == - 0) ? NPHY_RAIL_I : NPHY_RAIL_Q, - rssi_type); - } - - mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, pd_state[0]); - mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, pd_state[1]); - if (rssi_ctrl_state[0] == RADIO_2055_NBRSSI_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_NB); - else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G1_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W1); - else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G2_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W2); - else - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W2); - if (rssi_ctrl_state[1] == RADIO_2055_NBRSSI_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_NB); - else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G1_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W1); - else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G2_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W2); - else - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W2); - - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, rssi_type); - - write_phy_reg(pi, 0x91, rfctrlintc_state[0]); - write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rfpdcorerxtx_state[0]); - write_phy_reg(pi, 0x92, rfctrlintc_state[1]); - write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rfpdcorerxtx_state[1]); - - wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); - wlc_phy_clip_det_nphy(pi, 1, clip_state); - - wlc_phy_resetcca_nphy(pi); -} - -int -wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct brcms_d11rxhdr *wlc_rxh) -{ - struct d11rxhdr *rxh = &wlc_rxh->rxhdr; - s16 rxpwr, rxpwr0, rxpwr1; - s16 phyRx0_l, phyRx2_l; - - rxpwr = 0; - rxpwr0 = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR0_MASK; - rxpwr1 = (le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR1_MASK) >> 8; - - if (rxpwr0 > 127) - rxpwr0 -= 256; - if (rxpwr1 > 127) - rxpwr1 -= 256; - - phyRx0_l = le16_to_cpu(rxh->PhyRxStatus_0) & 0x00ff; - phyRx2_l = le16_to_cpu(rxh->PhyRxStatus_2) & 0x00ff; - if (phyRx2_l > 127) - phyRx2_l -= 256; - - if (((rxpwr0 == 16) || (rxpwr0 == 32))) { - rxpwr0 = rxpwr1; - rxpwr1 = phyRx2_l; - } - - wlc_rxh->rxpwr[0] = (s8) rxpwr0; - wlc_rxh->rxpwr[1] = (s8) rxpwr1; - wlc_rxh->do_rssi_ma = 0; - - if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MAX) - rxpwr = (rxpwr0 > rxpwr1) ? rxpwr0 : rxpwr1; - else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MIN) - rxpwr = (rxpwr0 < rxpwr1) ? rxpwr0 : rxpwr1; - else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_AVG) - rxpwr = (rxpwr0 + rxpwr1) >> 1; - - return rxpwr; -} - -static void -wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, - u8 core_code) -{ - u16 mask; - u16 val; - u8 core; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (core_code == RADIO_MIMO_CORESEL_CORE1 - && core == PHY_CORE_1) - continue; - else if (core_code == RADIO_MIMO_CORESEL_CORE2 - && core == PHY_CORE_0) - continue; - - if (NREV_LT(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 10); - val = 1 << 10; - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : - 0x92, mask, val); - } - - if (field == NPHY_RfctrlIntc_override_OFF) { - - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : - 0x92, 0); - - wlc_phy_force_rfseq_nphy(pi, - NPHY_RFSEQ_RESET2RX); - } else if (field == NPHY_RfctrlIntc_override_TRSW) { - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 6) | (0x1 << 7); - - val = value << 6; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - or_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - (0x1 << 10)); - - and_phy_reg(pi, 0x2ff, (u16) - ~(0x3 << 14)); - or_phy_reg(pi, 0x2ff, (0x1 << 13)); - or_phy_reg(pi, 0x2ff, (0x1 << 0)); - } else { - - mask = (0x1 << 6) | - (0x1 << 7) | - (0x1 << 8) | (0x1 << 9); - val = value << 6; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - mask = (0x1 << 0); - val = 1 << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xe7 : 0xec, - mask, val); - - mask = (core == PHY_CORE_0) ? - (0x1 << 0) : (0x1 << 1); - val = 1 << ((core == PHY_CORE_0) ? - 0 : 1); - mod_phy_reg(pi, 0x78, mask, val); - - SPINWAIT(((read_phy_reg(pi, 0x78) & val) - != 0), 10000); - if (WARN(read_phy_reg(pi, 0x78) & val, - "HW error: override failed")) - return; - - mask = (0x1 << 0); - val = 0 << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xe7 : 0xec, - mask, val); - } - } else if (field == NPHY_RfctrlIntc_override_PA) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 4) | (0x1 << 5); - - if (CHSPEC_IS5G(pi->radio_chanspec)) - val = value << 5; - else - val = value << 4; - - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - or_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - (0x1 << 12)); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 5); - val = value << 5; - } else { - mask = (0x1 << 4); - val = value << 4; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } else if (field == - NPHY_RfctrlIntc_override_EXT_LNA_PU) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - mask = (0x1 << 0); - val = value << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 2); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } else { - - mask = (0x1 << 2); - val = value << 2; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 0); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } - - mask = (0x1 << 11); - val = 1 << 11; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 0); - val = value << 0; - } else { - mask = (0x1 << 2); - val = value << 2; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } else if (field == - NPHY_RfctrlIntc_override_EXT_LNA_GAIN) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - mask = (0x1 << 1); - val = value << 1; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 3); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } else { - - mask = (0x1 << 3); - val = value << 3; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 1); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } - - mask = (0x1 << 11); - val = 1 << 11; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 1); - val = value << 1; - } else { - mask = (0x1 << 3); - val = value << 3; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } - } - } -} - static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) { u16 classif_state; @@ -22041,110 +22895,281 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) wlc_phy_clip_det_nphy(pi, 1, clip_state); } -static void wlc_phy_restore_rssical_nphy(struct brcms_phy *pi) +static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->nphy_rssical_chanspec_2G == 0) - return; + s32 target_code; + u16 classif_state; + u16 clip_state[2]; + u16 rssi_ctrl_state[2], pd_state[2]; + u16 rfctrlintc_state[2], rfpdcorerxtx_state[2]; + u16 rfctrlintc_override_val; + u16 clip_off[] = { 0xffff, 0xffff }; + u16 rf_pd_val, pd_mask, rssi_ctrl_mask; + u8 vcm, min_vcm, vcm_tmp[4]; + u8 vcm_final[4] = { 0, 0, 0, 0 }; + u8 result_idx, ctr; + s32 poll_results[4][4] = { + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0} + }; + s32 poll_miniq[4][2] = { + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0} + }; + s32 min_d, curr_d; + s32 fine_digital_offset[4]; + s32 poll_results_min[4] = { 0, 0, 0, 0 }; + s32 min_poll; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[0]); - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[1]); - } else { - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[0]); - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[1]); - } - - write_phy_reg(pi, 0x1a6, - pi->rssical_cache.rssical_phyregs_2G[0]); - write_phy_reg(pi, 0x1ac, - pi->rssical_cache.rssical_phyregs_2G[1]); - write_phy_reg(pi, 0x1b2, - pi->rssical_cache.rssical_phyregs_2G[2]); - write_phy_reg(pi, 0x1b8, - pi->rssical_cache.rssical_phyregs_2G[3]); - write_phy_reg(pi, 0x1a4, - pi->rssical_cache.rssical_phyregs_2G[4]); - write_phy_reg(pi, 0x1aa, - pi->rssical_cache.rssical_phyregs_2G[5]); - write_phy_reg(pi, 0x1b0, - pi->rssical_cache.rssical_phyregs_2G[6]); - write_phy_reg(pi, 0x1b6, - pi->rssical_cache.rssical_phyregs_2G[7]); - write_phy_reg(pi, 0x1a5, - pi->rssical_cache.rssical_phyregs_2G[8]); - write_phy_reg(pi, 0x1ab, - pi->rssical_cache.rssical_phyregs_2G[9]); - write_phy_reg(pi, 0x1b1, - pi->rssical_cache.rssical_phyregs_2G[10]); - write_phy_reg(pi, 0x1b7, - pi->rssical_cache.rssical_phyregs_2G[11]); - - } else { - if (pi->nphy_rssical_chanspec_5G == 0) - return; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[0]); - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[1]); - } else { - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[0]); - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[1]); - } - - write_phy_reg(pi, 0x1a6, - pi->rssical_cache.rssical_phyregs_5G[0]); - write_phy_reg(pi, 0x1ac, - pi->rssical_cache.rssical_phyregs_5G[1]); - write_phy_reg(pi, 0x1b2, - pi->rssical_cache.rssical_phyregs_5G[2]); - write_phy_reg(pi, 0x1b8, - pi->rssical_cache.rssical_phyregs_5G[3]); - write_phy_reg(pi, 0x1a4, - pi->rssical_cache.rssical_phyregs_5G[4]); - write_phy_reg(pi, 0x1aa, - pi->rssical_cache.rssical_phyregs_5G[5]); - write_phy_reg(pi, 0x1b0, - pi->rssical_cache.rssical_phyregs_5G[6]); - write_phy_reg(pi, 0x1b6, - pi->rssical_cache.rssical_phyregs_5G[7]); - write_phy_reg(pi, 0x1a5, - pi->rssical_cache.rssical_phyregs_5G[8]); - write_phy_reg(pi, 0x1ab, - pi->rssical_cache.rssical_phyregs_5G[9]); - write_phy_reg(pi, 0x1b1, - pi->rssical_cache.rssical_phyregs_5G[10]); - write_phy_reg(pi, 0x1b7, - pi->rssical_cache.rssical_phyregs_5G[11]); + switch (rssi_type) { + case NPHY_RSSI_SEL_NB: + target_code = NPHY_RSSICAL_NB_TARGET; + break; + case NPHY_RSSI_SEL_W1: + target_code = NPHY_RSSICAL_W1_TARGET; + break; + case NPHY_RSSI_SEL_W2: + target_code = NPHY_RSSICAL_W2_TARGET; + break; + default: + return; + break; } + + classif_state = wlc_phy_classifier_nphy(pi, 0, 0); + wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); + wlc_phy_clip_det_nphy(pi, 0, clip_state); + wlc_phy_clip_det_nphy(pi, 1, clip_off); + + rf_pd_val = (rssi_type == NPHY_RSSI_SEL_NB) ? 0x6 : 0x4; + rfctrlintc_override_val = + CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110; + + rfctrlintc_state[0] = read_phy_reg(pi, 0x91); + rfpdcorerxtx_state[0] = read_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX); + write_phy_reg(pi, 0x91, rfctrlintc_override_val); + write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rf_pd_val); + + rfctrlintc_state[1] = read_phy_reg(pi, 0x92); + rfpdcorerxtx_state[1] = read_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX); + write_phy_reg(pi, 0x92, rfctrlintc_override_val); + write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rf_pd_val); + + pd_mask = RADIO_2055_NBRSSI_PD | RADIO_2055_WBRSSI_G1_PD | + RADIO_2055_WBRSSI_G2_PD; + pd_state[0] = + read_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC) & pd_mask; + pd_state[1] = + read_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC) & pd_mask; + mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, 0); + mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, 0); + rssi_ctrl_mask = RADIO_2055_NBRSSI_SEL | RADIO_2055_WBRSSI_G1_SEL | + RADIO_2055_WBRSSI_G2_SEL; + rssi_ctrl_state[0] = + read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE1) & rssi_ctrl_mask; + rssi_ctrl_state[1] = + read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE2) & rssi_ctrl_mask; + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); + + wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, + NPHY_RAIL_I, rssi_type); + wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, + NPHY_RAIL_Q, rssi_type); + + for (vcm = 0; vcm < 4; vcm++) { + + vcm_tmp[0] = vcm_tmp[1] = vcm_tmp[2] = vcm_tmp[3] = vcm; + if (rssi_type != NPHY_RSSI_SEL_W2) + wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_tmp); + + wlc_phy_poll_rssi_nphy(pi, rssi_type, &poll_results[vcm][0], + NPHY_RSSICAL_NPOLL); + + if ((rssi_type == NPHY_RSSI_SEL_W1) + || (rssi_type == NPHY_RSSI_SEL_W2)) { + for (ctr = 0; ctr < 2; ctr++) + poll_miniq[vcm][ctr] = + min(poll_results[vcm][ctr * 2 + 0], + poll_results[vcm][ctr * 2 + 1]); + } + } + + for (result_idx = 0; result_idx < 4; result_idx++) { + min_d = NPHY_RSSICAL_MAXD; + min_vcm = 0; + min_poll = NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL + 1; + for (vcm = 0; vcm < 4; vcm++) { + curr_d = ABS(((rssi_type == NPHY_RSSI_SEL_NB) ? + poll_results[vcm][result_idx] : + poll_miniq[vcm][result_idx / 2]) - + (target_code * NPHY_RSSICAL_NPOLL)); + if (curr_d < min_d) { + min_d = curr_d; + min_vcm = vcm; + } + if (poll_results[vcm][result_idx] < min_poll) + min_poll = poll_results[vcm][result_idx]; + } + vcm_final[result_idx] = min_vcm; + poll_results_min[result_idx] = min_poll; + } + + if (rssi_type != NPHY_RSSI_SEL_W2) + wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_final); + + for (result_idx = 0; result_idx < 4; result_idx++) { + fine_digital_offset[result_idx] = + (target_code * NPHY_RSSICAL_NPOLL) - + poll_results[vcm_final[result_idx]][result_idx]; + if (fine_digital_offset[result_idx] < 0) { + fine_digital_offset[result_idx] = + ABS(fine_digital_offset[result_idx]); + fine_digital_offset[result_idx] += + (NPHY_RSSICAL_NPOLL / 2); + fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; + fine_digital_offset[result_idx] = + -fine_digital_offset[result_idx]; + } else { + fine_digital_offset[result_idx] += + (NPHY_RSSICAL_NPOLL / 2); + fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; + } + + if (poll_results_min[result_idx] == + NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) + fine_digital_offset[result_idx] = + (target_code - NPHY_RSSICAL_MAXREAD - 1); + + wlc_phy_scale_offset_rssi_nphy(pi, 0x0, + (s8) + fine_digital_offset[result_idx], + (result_idx / 2 == + 0) ? RADIO_MIMO_CORESEL_CORE1 : + RADIO_MIMO_CORESEL_CORE2, + (result_idx % 2 == + 0) ? NPHY_RAIL_I : NPHY_RAIL_Q, + rssi_type); + } + + mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, pd_state[0]); + mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, pd_state[1]); + if (rssi_ctrl_state[0] == RADIO_2055_NBRSSI_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, + NPHY_RSSI_SEL_NB); + else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G1_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, + NPHY_RSSI_SEL_W1); + else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G2_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, + NPHY_RSSI_SEL_W2); + else + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, + NPHY_RSSI_SEL_W2); + if (rssi_ctrl_state[1] == RADIO_2055_NBRSSI_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, + NPHY_RSSI_SEL_NB); + else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G1_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, + NPHY_RSSI_SEL_W1); + else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G2_SEL) + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, + NPHY_RSSI_SEL_W2); + else + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, + NPHY_RSSI_SEL_W2); + + wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, rssi_type); + + write_phy_reg(pi, 0x91, rfctrlintc_state[0]); + write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rfpdcorerxtx_state[0]); + write_phy_reg(pi, 0x92, rfctrlintc_state[1]); + write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rfpdcorerxtx_state[1]); + + wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); + wlc_phy_clip_det_nphy(pi, 1, clip_state); + + wlc_phy_resetcca_nphy(pi); +} + +void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi) +{ + if (NREV_GE(pi->pubpi.phy_rev, 3)) { + wlc_phy_rssi_cal_nphy_rev3(pi); + } else { + wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_NB); + wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W1); + wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W2); + } +} + +int +wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct brcms_d11rxhdr *wlc_rxh) +{ + struct d11rxhdr *rxh = &wlc_rxh->rxhdr; + s16 rxpwr, rxpwr0, rxpwr1; + s16 phyRx0_l, phyRx2_l; + + rxpwr = 0; + rxpwr0 = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR0_MASK; + rxpwr1 = (le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR1_MASK) >> 8; + + if (rxpwr0 > 127) + rxpwr0 -= 256; + if (rxpwr1 > 127) + rxpwr1 -= 256; + + phyRx0_l = le16_to_cpu(rxh->PhyRxStatus_0) & 0x00ff; + phyRx2_l = le16_to_cpu(rxh->PhyRxStatus_2) & 0x00ff; + if (phyRx2_l > 127) + phyRx2_l -= 256; + + if (((rxpwr0 == 16) || (rxpwr0 == 32))) { + rxpwr0 = rxpwr1; + rxpwr1 = phyRx2_l; + } + + wlc_rxh->rxpwr[0] = (s8) rxpwr0; + wlc_rxh->rxpwr[1] = (s8) rxpwr1; + wlc_rxh->do_rssi_ma = 0; + + if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MAX) + rxpwr = (rxpwr0 > rxpwr1) ? rxpwr0 : rxpwr1; + else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MIN) + rxpwr = (rxpwr0 < rxpwr1) ? rxpwr0 : rxpwr1; + else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_AVG) + rxpwr = (rxpwr0 + rxpwr1) >> 1; + + return rxpwr; +} + +static void +wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, + u16 num_samps) +{ + u16 t; + u32 *data_buf = NULL; + + data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); + if (data_buf == NULL) + return; + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + for (t = 0; t < num_samps; t++) + data_buf[t] = ((((unsigned int)tone_buf[t].i) & 0x3ff) << 10) | + (((unsigned int)tone_buf[t].q) & 0x3ff); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, + data_buf); + + kfree(data_buf); + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, false); } static u16 @@ -22195,51 +23220,6 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, return num_samps; } -int -wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, - u8 iqmode, u8 dac_test_mode, bool modify_bbmult) -{ - u16 num_samps; - u16 loops = 0xffff; - u16 wait = 0; - - num_samps = wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, - dac_test_mode); - if (num_samps == 0) - return -EBADE; - - wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode, - dac_test_mode, modify_bbmult); - - return 0; -} - -static void -wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, - u16 num_samps) -{ - u16 t; - u32 *data_buf = NULL; - - data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); - if (data_buf == NULL) - return; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - for (t = 0; t < num_samps; t++) - data_buf[t] = ((((unsigned int)tone_buf[t].i) & 0x3ff) << 10) | - (((unsigned int)tone_buf[t].q) & 0x3ff); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, - data_buf); - - kfree(data_buf); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - static void wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, u16 wait, u8 iqmode, u8 dac_test_mode, @@ -22330,6 +23310,25 @@ wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, write_phy_reg(pi, 0xa1, orig_RfseqCoreActv); } +int +wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, + u8 iqmode, u8 dac_test_mode, bool modify_bbmult) +{ + u16 num_samps; + u16 loops = 0xffff; + u16 wait = 0; + + num_samps = wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, + dac_test_mode); + if (num_samps == 0) + return -EBADE; + + wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode, + dac_test_mode, modify_bbmult); + + return 0; +} + void wlc_phy_stopplayback_nphy(struct brcms_phy *pi) { u16 playback_status; @@ -23273,10 +24272,6 @@ static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) } } -#define NPHY_CAL_TSSISAMPS 64 -#define NPHY_TEST_TONE_FREQ_40MHz 4000 -#define NPHY_TEST_TONE_FREQ_20MHz 2500 - void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, u8 num_samps) { @@ -23323,276 +24318,6 @@ wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, u8 num_samps) (u32) pwrindex[1], 32, &qdBm_pwrbuf[1]); } -static void wlc_phy_internal_cal_txgain_nphy(struct brcms_phy *pi) -{ - u16 txcal_gain[2]; - - pi->nphy_txcal_pwr_idx[0] = pi->nphy_cal_orig_pwr_idx[0]; - pi->nphy_txcal_pwr_idx[1] = pi->nphy_cal_orig_pwr_idx[0]; - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - txcal_gain); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F40; - txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F40; - } else { - txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F60; - txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F60; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - txcal_gain); -} - -static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) -{ - bool save_bbmult = false; - u8 txcal_index_2057_rev5n7 = 0; - u8 txcal_index_2057_rev3n4n6 = 10; - - if (pi->use_int_tx_iqlo_cal_nphy) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - - pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev3n4n6; - pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev3n4n6; - wlc_phy_txpwr_index_nphy( - pi, 3, - txcal_index_2057_rev3n4n6, - false); - } else { - - pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev5n7; - pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev5n7; - wlc_phy_txpwr_index_nphy( - pi, 3, - txcal_index_2057_rev5n7, - false); - } - save_bbmult = true; - - } else if (NREV_LT(pi->pubpi.phy_rev, 5)) { - wlc_phy_cal_txgainctrl_nphy(pi, 11, false); - if (pi->sh->hw_phytxchain != 3) { - pi->nphy_txcal_pwr_idx[1] = - pi->nphy_txcal_pwr_idx[0]; - wlc_phy_txpwr_index_nphy(pi, 3, - pi-> - nphy_txcal_pwr_idx[0], - true); - save_bbmult = true; - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - wlc_phy_cal_txgainctrl_nphy(pi, 12, - false); - } else { - pi->nphy_txcal_pwr_idx[0] = 80; - pi->nphy_txcal_pwr_idx[1] = 80; - wlc_phy_txpwr_index_nphy(pi, 3, 80, - false); - save_bbmult = true; - } - } else { - wlc_phy_internal_cal_txgain_nphy(pi); - save_bbmult = true; - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_phy_cal_txgainctrl_nphy(pi, 12, - false); - else - wlc_phy_cal_txgainctrl_nphy(pi, 14, - false); - } else { - wlc_phy_internal_cal_txgain_nphy(pi); - save_bbmult = true; - } - } - - } else { - wlc_phy_cal_txgainctrl_nphy(pi, 10, false); - } - - if (save_bbmult) - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, - &pi->nphy_txcal_bbmult); -} - -void -wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, - bool debug) -{ - int gainctrl_loopidx; - uint core; - u16 m0m1, curr_m0m1; - s32 delta_power; - s32 txpwrindex; - s32 qdBm_power[2]; - u16 orig_BBConfig; - u16 phy_saveregs[4]; - u32 freq_test; - u16 ampl_test = 250; - uint stepsize; - bool phyhang_avoid_state = false; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - stepsize = 2; - else - stepsize = 1; - - if (CHSPEC_IS40(pi->radio_chanspec)) - freq_test = 5000; - else - freq_test = 2500; - - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - phyhang_avoid_state = pi->phyhang_avoid; - pi->phyhang_avoid = false; - - phy_saveregs[0] = read_phy_reg(pi, 0x91); - phy_saveregs[1] = read_phy_reg(pi, 0x92); - phy_saveregs[2] = read_phy_reg(pi, 0xe7); - phy_saveregs[3] = read_phy_reg(pi, 0xec); - wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 1, - RADIO_MIMO_CORESEL_CORE1 | - RADIO_MIMO_CORESEL_CORE2); - - if (!debug) { - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x2, RADIO_MIMO_CORESEL_CORE1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x8, RADIO_MIMO_CORESEL_CORE2); - } else { - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x1, RADIO_MIMO_CORESEL_CORE1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x7, RADIO_MIMO_CORESEL_CORE2); - } - - orig_BBConfig = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - txpwrindex = (s32) pi->nphy_cal_orig_pwr_idx[core]; - - for (gainctrl_loopidx = 0; gainctrl_loopidx < 2; - gainctrl_loopidx++) { - wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, - false); - - if (core == PHY_CORE_0) - curr_m0m1 = m0m1 & 0xff00; - else - curr_m0m1 = m0m1 & 0x00ff; - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &curr_m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &curr_m0m1); - - udelay(50); - - wlc_phy_est_tonepwr_nphy(pi, qdBm_power, - NPHY_CAL_TSSISAMPS); - - pi->nphy_bb_mult_save = 0; - wlc_phy_stopplayback_nphy(pi); - - delta_power = (dBm_targetpower * 4) - qdBm_power[core]; - - txpwrindex -= stepsize * delta_power; - if (txpwrindex < 0) - txpwrindex = 0; - else if (txpwrindex > 127) - txpwrindex = 127; - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(pi->pubpi.phy_rev, 4) && - (pi->srom_fem5g.extpagain == 3)) { - if (txpwrindex < 30) - txpwrindex = 30; - } - } else { - if (NREV_GE(pi->pubpi.phy_rev, 5) && - (pi->srom_fem2g.extpagain == 3)) { - if (txpwrindex < 50) - txpwrindex = 50; - } - } - - wlc_phy_txpwr_index_nphy(pi, (1 << core), - (u8) txpwrindex, true); - } - - pi->nphy_txcal_pwr_idx[core] = (u8) txpwrindex; - - if (debug) { - u16 radio_gain; - u16 dbg_m0m1; - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); - - wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, - false); - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &dbg_m0m1); - - udelay(100); - - wlc_phy_est_tonepwr_nphy(pi, qdBm_power, - NPHY_CAL_TSSISAMPS); - - wlc_phy_table_read_nphy(pi, 7, 1, (0x110 + core), 16, - &radio_gain); - - mdelay(4000); - pi->nphy_bb_mult_save = 0; - wlc_phy_stopplayback_nphy(pi); - } - } - - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_txcal_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_txcal_pwr_idx[1], true); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &pi->nphy_txcal_bbmult); - - write_phy_reg(pi, 0x01, orig_BBConfig); - - write_phy_reg(pi, 0x91, phy_saveregs[0]); - write_phy_reg(pi, 0x92, phy_saveregs[1]); - write_phy_reg(pi, 0xe7, phy_saveregs[2]); - write_phy_reg(pi, 0xec, phy_saveregs[3]); - - pi->phyhang_avoid = phyhang_avoid_state; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) { int index; @@ -23635,6 +24360,1199 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) } } +static u8 wlc_phy_txpwr_idx_cur_get_nphy(struct brcms_phy *pi, u8 core) +{ + u16 tmp; + tmp = read_phy_reg(pi, ((core == PHY_CORE_0) ? 0x1ed : 0x1ee)); + + tmp = (tmp & (0x7f << 8)) >> 8; + return (u8) tmp; +} + +static void +wlc_phy_txpwr_idx_cur_set_nphy(struct brcms_phy *pi, u8 idx0, u8 idx1) +{ + mod_phy_reg(pi, 0x1e7, (0x7f << 0), idx0); + + if (NREV_GT(pi->pubpi.phy_rev, 1)) + mod_phy_reg(pi, 0x222, (0xff << 0), idx1); +} + +static u16 wlc_phy_ipa_get_bbmult_nphy(struct brcms_phy *pi) +{ + u16 m0m1; + + wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); + + return m0m1; +} + +static void wlc_phy_ipa_set_bbmult_nphy(struct brcms_phy *pi, u8 m0, u8 m1) +{ + u16 m0m1 = (u16) ((m0 << 8) | m1); + + wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m0m1); + wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &m0m1); +} + +static void +wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, + struct nphy_papd_restore_state *state, u8 core) +{ + s32 tone_freq; + u8 off_core; + u16 mixgain = 0; + + off_core = core ^ 0x1; + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + if (NREV_IS(pi->pubpi.phy_rev, 7) + || NREV_GE(pi->pubpi.phy_rev, 8)) + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), + wlc_phy_read_lpf_bw_ctl_nphy + (pi, + 0), 0, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (pi->pubpi.radiorev == 5) + mixgain = (core == 0) ? 0x20 : 0x00; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + mixgain = 0x00; + else if ((pi->pubpi.radiorev <= 4) + || (pi->pubpi.radiorev == 6)) + mixgain = 0x00; + } else { + if ((pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + mixgain = 0x50; + else if ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + mixgain = 0x0; + } + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), + mixgain, (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_tx_pu, + 1, (1 << core), 0); + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_tx_pu, + 0, (1 << off_core), 0); + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), + 0, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), + 0, (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, + (1 << core), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + + state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? + 0xa6 : 0xa7); + state->afeoverride[core] = + read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); + state->afectrl[off_core] = + read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa7 : 0xa6); + state->afeoverride[off_core] = + read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa5 : 0x8f); + + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), + (0x1 << 2), 0); + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : + 0xa5), (0x1 << 2), (0x1 << 2)); + + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa7 : 0xa6), + (0x1 << 2), (0x1 << 2)); + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa5 : + 0x8f), (0x1 << 2), (0x1 << 2)); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + state->pwrup[core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_PWRUP); + state->atten[core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN); + state->pwrup[off_core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_PWRUP); + state->atten[off_core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_ATTEN); + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_PWRUP, 0xc); + + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN, 0xf0); + else if (pi->pubpi.radiorev == 5) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN, + (core == 0) ? 0xf7 : 0xf2); + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN, 0xf0); + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_PWRUP, 0x0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_2G_ATTEN, 0xff); + } else { + state->pwrup[core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_PWRUP); + state->atten[core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_ATTEN); + state->pwrup[off_core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_PWRUP); + state->atten[off_core] = + READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_ATTEN); + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_PWRUP, 0xc); + + if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_ATTEN, 0xf4); + + else + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_ATTEN, 0xf0); + + WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_PWRUP, 0x0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, + TXRXCOUPLE_5G_ATTEN, 0xff); + } + + tone_freq = 4000; + + wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (1) << 13); + + mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_OFF) << 0); + + mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (0) << 13); + + } else { + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 0); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0, 0); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 0); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 1, 0x3, 0); + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0x3, 0); + + state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? + 0xa6 : 0xa7); + state->afeoverride[core] = + read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); + + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), + (0x1 << 0) | (0x1 << 1) | (0x1 << 2), 0); + mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : + 0xa5), + (0x1 << 0) | + (0x1 << 1) | + (0x1 << 2), (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); + + state->vga_master[core] = + READ_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER); + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, 0x2b); + if (CHSPEC_IS2G(pi->radio_chanspec)) { + state->fbmix[core] = + READ_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_G); + state->intpa_master[core] = + READ_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAG_MASTER); + + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_G, + 0x03); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAG_MASTER, 0x04); + } else { + state->fbmix[core] = + READ_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_A); + state->intpa_master[core] = + READ_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAA_MASTER); + + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_A, + 0x03); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAA_MASTER, 0x04); + + } + + tone_freq = 4000; + + wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (1) << 0); + + mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (0) << 0); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); + } +} + +static void +wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, + struct nphy_papd_restore_state *state) +{ + u8 core; + + wlc_phy_stopplayback_nphy(pi); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_PWRUP, 0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_2G_ATTEN, + state->atten[core]); + } else { + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_PWRUP, 0); + WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, + TXRXCOUPLE_5G_ATTEN, + state->atten[core]); + } + } + + if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + else + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 2), + 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), + 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 1, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, 0x3, 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + + write_phy_reg(pi, (core == PHY_CORE_0) ? + 0xa6 : 0xa7, state->afectrl[core]); + write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : + 0xa5, state->afeoverride[core]); + } + + wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, + (state->mm & 0xff)); + + if (NREV_IS(pi->pubpi.phy_rev, 7) + || NREV_GE(pi->pubpi.phy_rev, 8)) + wlc_phy_rfctrl_override_nphy_rev7( + pi, (0x1 << 7), 0, 0, + 1, + NPHY_REV7_RFCTRLOVERRIDE_ID1); + } else { + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 0x3, 1); + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 1); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 0, 0x3, 1); + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 0, 0x3, 1); + + for (core = 0; core < pi->pubpi.phy_corenum; core++) { + + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, + state->vga_master[core]); + if (CHSPEC_IS2G(pi->radio_chanspec)) { + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_G, state->fbmix[core]); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAG_MASTER, + state->intpa_master[core]); + } else { + WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, + TXFBMIX_A, state->fbmix[core]); + WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, + INTPAA_MASTER, + state->intpa_master[core]); + } + + write_phy_reg(pi, (core == PHY_CORE_0) ? + 0xa6 : 0xa7, state->afectrl[core]); + write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : + 0xa5, state->afeoverride[core]); + } + + wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, + (state->mm & 0xff)); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 1); + } +} + +static void +wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32 start, + u32 end) +{ + u32 *buf, *src, *dst, sz; + + sz = end - start + 1; + + buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC); + if (NULL == buf) + return; + + src = buf; + dst = buf + NPHY_PAPD_EPS_TBL_SIZE; + + wlc_phy_table_read_nphy(pi, + (core == + PHY_CORE_0 ? NPHY_TBL_ID_EPSILONTBL0 : + NPHY_TBL_ID_EPSILONTBL1), + NPHY_PAPD_EPS_TBL_SIZE, 0, 32, src); + + do { + u32 phy_a1, phy_a2; + s32 phy_a3, phy_a4, phy_a5, phy_a6, phy_a7; + + phy_a1 = end - min(end, (winsz >> 1)); + phy_a2 = min_t(u32, NPHY_PAPD_EPS_TBL_SIZE - 1, + end + (winsz >> 1)); + phy_a3 = phy_a2 - phy_a1 + 1; + phy_a6 = 0; + phy_a7 = 0; + + do { + wlc_phy_papd_decode_epsilon(src[phy_a2], &phy_a4, + &phy_a5); + phy_a6 += phy_a4; + phy_a7 += phy_a5; + } while (phy_a2-- != phy_a1); + + phy_a6 /= phy_a3; + phy_a7 /= phy_a3; + dst[end] = ((u32) phy_a7 << 13) | ((u32) phy_a6 & 0x1fff); + } while (end-- != start); + + wlc_phy_table_write_nphy(pi, + (core == + PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 : + NPHY_TBL_ID_EPSILONTBL1, sz, start, 32, dst); + + kfree(buf); +} + +static void +wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, + enum phy_cal_mode cal_mode, u8 core) +{ + u16 phy_a1, phy_a2, phy_a3; + u16 phy_a4, phy_a5; + bool phy_a6; + u8 phy_a7, m[2]; + u32 phy_a8 = 0; + struct nphy_txgains phy_a9; + + if (NREV_LT(pi->pubpi.phy_rev, 3)) + return; + + phy_a7 = (core == PHY_CORE_0) ? 1 : 0; + + phy_a6 = ((cal_mode == CAL_GCTRL) + || (cal_mode == CAL_SOFT)) ? true : false; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + phy_a9 = wlc_phy_get_tx_gain_nphy(pi); + + if (CHSPEC_IS2G(pi->radio_chanspec)) + phy_a5 = ((phy_a9.txlpf[core] << 15) | + (phy_a9.txgm[core] << 12) | + (phy_a9.pga[core] << 8) | + (txgains->gains.pad[core] << 3) | + (phy_a9.ipa[core])); + else + phy_a5 = ((phy_a9.txlpf[core] << 15) | + (phy_a9.txgm[core] << 12) | + (txgains->gains.pga[core] << 8) | + (phy_a9.pad[core] << 3) | (phy_a9.ipa[core])); + + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_txgain, + phy_a5, (1 << core), 0); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((pi->pubpi.radiorev <= 4) + || (pi->pubpi.radiorev == 6)) + m[core] = IS40MHZ(pi) ? 60 : 79; + else + m[core] = IS40MHZ(pi) ? 45 : 64; + } else { + m[core] = IS40MHZ(pi) ? 75 : 107; + } + + m[phy_a7] = 0; + wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); + + phy_a2 = 63; + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((pi->pubpi.radiorev == 4) + || (pi->pubpi.radiorev == 6)) { + phy_a1 = 30; + phy_a3 = 30; + } else { + phy_a1 = 25; + phy_a3 = 25; + } + } else { + if ((pi->pubpi.radiorev == 5) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { + phy_a1 = 25; + phy_a3 = 25; + } else { + phy_a1 = 35; + phy_a3 = 35; + } + } + + if (cal_mode == CAL_GCTRL) { + if ((pi->pubpi.radiorev == 5) + && (CHSPEC_IS2G(pi->radio_chanspec))) + phy_a1 = 55; + else if (((pi->pubpi.radiorev == 7) && + (CHSPEC_IS2G(pi->radio_chanspec))) || + ((pi->pubpi.radiorev == 8) && + (CHSPEC_IS2G(pi->radio_chanspec)))) + phy_a1 = 60; + else + phy_a1 = 63; + + } else if ((cal_mode != CAL_FULL) && (cal_mode != CAL_SOFT)) { + + phy_a1 = 35; + phy_a3 = 35; + } + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (1) << 0); + + mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (0) << 0); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (1) << 13); + + mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (0) << 13); + + write_phy_reg(pi, 0x2a1, 0x80); + write_phy_reg(pi, 0x2a2, 0x100); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 4), (11) << 4); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 8), (11) << 8); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 0), (0x3) << 0); + + write_phy_reg(pi, 0x2e5, 0x20); + + mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); + + mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); + + mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), + 1, ((core == 0) ? 1 : 2), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), + 0, ((core == 0) ? 2 : 1), 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + + write_phy_reg(pi, 0x2be, 1); + SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); + + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), + 0, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); + + wlc_phy_table_write_nphy(pi, + (core == + PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 + : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, + 32, &phy_a8); + + if (cal_mode != CAL_GCTRL) { + if (CHSPEC_IS5G(pi->radio_chanspec)) + wlc_phy_a1_nphy(pi, core, 5, 0, 35); + } + + wlc_phy_rfctrl_override_1tomany_nphy( + pi, + NPHY_REV7_RfctrlOverride_cmd_txgain, + phy_a5, (1 << core), 1); + + } else { + + if (txgains) { + if (txgains->useindex) { + phy_a4 = 15 - ((txgains->index) >> 3); + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (NREV_GE(pi->pubpi.phy_rev, 6)) + phy_a5 = 0x00f7 | (phy_a4 << 8); + + else + if (NREV_IS(pi->pubpi.phy_rev, 5)) + phy_a5 = 0x10f7 | (phy_a4 << 8); + else + phy_a5 = 0x50f7 | (phy_a4 << 8); + } else { + phy_a5 = 0x70f7 | (phy_a4 << 8); + } + wlc_phy_rfctrl_override_nphy(pi, + (0x1 << 13), + phy_a5, + (1 << core), 0); + } else { + wlc_phy_rfctrl_override_nphy(pi, + (0x1 << 13), + 0x5bf7, + (1 << core), 0); + } + } + + if (CHSPEC_IS2G(pi->radio_chanspec)) + m[core] = IS40MHZ(pi) ? 45 : 64; + else + m[core] = IS40MHZ(pi) ? 75 : 107; + + m[phy_a7] = 0; + wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); + + phy_a2 = 63; + + if (cal_mode == CAL_FULL) { + phy_a1 = 25; + phy_a3 = 25; + } else if (cal_mode == CAL_SOFT) { + phy_a1 = 25; + phy_a3 = 25; + } else if (cal_mode == CAL_GCTRL) { + phy_a1 = 63; + phy_a3 = 25; + } else { + + phy_a1 = 25; + phy_a3 = 25; + } + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (1) << 0); + + mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (0) << 0); + + if (NREV_GE(pi->pubpi.phy_rev, 6)) { + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (1) << 13); + + mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (0) << 13); + + write_phy_reg(pi, 0x2a1, 0x20); + write_phy_reg(pi, 0x2a2, 0x60); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0xf << 4), (9) << 4); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0xf << 8), (9) << 8); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0xf << 0), (0x2) << 0); + + write_phy_reg(pi, 0x2e5, 0x20); + } else { + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 11), (1) << 11); + + mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 11), (0) << 11); + + write_phy_reg(pi, 0x2a1, 0x80); + write_phy_reg(pi, 0x2a2, 0x600); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 4), (0) << 4); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 8), (0) << 8); + + mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x7 << 0), (0x3) << 0); + + mod_phy_reg(pi, 0x2a0, (0x3f << 8), (0x20) << 8); + + } + + mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); + + mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); + + mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0x3, 0); + + write_phy_reg(pi, 0x2be, 1); + SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); + + wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); + + wlc_phy_table_write_nphy(pi, + (core == + PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 + : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, + 32, &phy_a8); + + if (cal_mode != CAL_GCTRL) + wlc_phy_a1_nphy(pi, core, 5, 0, 40); + } +} + +static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) +{ + int phy_a1; + int phy_a2; + bool phy_a3; + struct nphy_ipa_txcalgains phy_a4; + bool phy_a5 = false; + bool phy_a6 = true; + s32 phy_a7, phy_a8; + u32 phy_a9; + int phy_a10; + bool phy_a11 = false; + int phy_a12; + u8 phy_a13 = 0; + u8 phy_a14; + u8 *phy_a15 = NULL; + + phy_a4.useindex = true; + phy_a12 = start_gain; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + + phy_a2 = 20; + phy_a1 = 1; + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (pi->pubpi.radiorev == 5) { + + phy_a15 = pad_gain_codes_used_2057rev5; + phy_a13 = + sizeof(pad_gain_codes_used_2057rev5) / + sizeof(pad_gain_codes_used_2057rev5 + [0]) - 1; + + } else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { + + phy_a15 = pad_gain_codes_used_2057rev7; + phy_a13 = + sizeof(pad_gain_codes_used_2057rev7) / + sizeof(pad_gain_codes_used_2057rev7 + [0]) - 1; + + } else { + + phy_a15 = pad_all_gain_codes_2057; + phy_a13 = sizeof(pad_all_gain_codes_2057) / + sizeof(pad_all_gain_codes_2057[0]) - + 1; + } + + } else { + + phy_a15 = pga_all_gain_codes_2057; + phy_a13 = sizeof(pga_all_gain_codes_2057) / + sizeof(pga_all_gain_codes_2057[0]) - 1; + } + + phy_a14 = 0; + + for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { + if (CHSPEC_IS2G(pi->radio_chanspec)) + phy_a4.gains.pad[core] = + (u16) phy_a15[phy_a12]; + else + phy_a4.gains.pga[core] = + (u16) phy_a15[phy_a12]; + + wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); + + wlc_phy_table_read_nphy(pi, + (core == + PHY_CORE_0 ? + NPHY_TBL_ID_EPSILONTBL0 : + NPHY_TBL_ID_EPSILONTBL1), 1, + 63, 32, &phy_a9); + + wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); + + phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || + (phy_a8 == 4095) || (phy_a8 == -4096)); + + if (!phy_a6 && (phy_a3 != phy_a5)) { + if (!phy_a3) + phy_a12 -= (u8) phy_a1; + + phy_a11 = true; + break; + } + + if (phy_a3) + phy_a12 += (u8) phy_a1; + else + phy_a12 -= (u8) phy_a1; + + if ((phy_a12 < phy_a14) || (phy_a12 > phy_a13)) { + if (phy_a12 < phy_a14) + phy_a12 = phy_a14; + else + phy_a12 = phy_a13; + + phy_a11 = true; + break; + } + + phy_a6 = false; + phy_a5 = phy_a3; + } + + } else { + phy_a2 = 10; + phy_a1 = 8; + for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { + phy_a4.index = (u8) phy_a12; + wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); + + wlc_phy_table_read_nphy(pi, + (core == + PHY_CORE_0 ? + NPHY_TBL_ID_EPSILONTBL0 : + NPHY_TBL_ID_EPSILONTBL1), 1, + 63, 32, &phy_a9); + + wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); + + phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || + (phy_a8 == 4095) || (phy_a8 == -4096)); + + if (!phy_a6 && (phy_a3 != phy_a5)) { + if (!phy_a3) + phy_a12 -= (u8) phy_a1; + + phy_a11 = true; + break; + } + + if (phy_a3) + phy_a12 += (u8) phy_a1; + else + phy_a12 -= (u8) phy_a1; + + if ((phy_a12 < 0) || (phy_a12 > 127)) { + if (phy_a12 < 0) + phy_a12 = 0; + else + phy_a12 = 127; + + phy_a11 = true; + break; + } + + phy_a6 = false; + phy_a5 = phy_a3; + } + + } + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + return (u8) phy_a15[phy_a12]; + else + return (u8) phy_a12; + +} + +static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) +{ + struct nphy_ipa_txcalgains phy_b1[2]; + struct nphy_papd_restore_state phy_b2; + bool phy_b3; + u8 phy_b4; + u8 phy_b5; + s16 phy_b6, phy_b7, phy_b8; + u16 phy_b9; + s16 phy_b10, phy_b11, phy_b12; + + phy_b11 = 0; + phy_b12 = 0; + phy_b7 = 0; + phy_b8 = 0; + phy_b6 = 0; + + if (pi->nphy_papd_skip == 1) + return; + + phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + if (!phy_b3) + wlapi_suspend_mac_and_wait(pi->sh->physhim); + + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + pi->nphy_force_papd_cal = false; + + for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) + pi->nphy_papd_tx_gain_at_last_cal[phy_b5] = + wlc_phy_txpwr_idx_cur_get_nphy(pi, phy_b5); + + pi->nphy_papd_last_cal = pi->sh->now; + pi->nphy_papd_recal_counter++; + + phy_b4 = pi->nphy_txpwrctrl; + wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL0, 64, 0, 32, + nphy_papd_scaltbl); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL1, 64, 0, 32, + nphy_papd_scaltbl); + + phy_b9 = read_phy_reg(pi, 0x01); + mod_phy_reg(pi, 0x01, (0x1 << 15), 0); + + for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { + s32 i, val = 0; + for (i = 0; i < 64; i++) + wlc_phy_table_write_nphy(pi, + ((phy_b5 == + PHY_CORE_0) ? + NPHY_TBL_ID_EPSILONTBL0 : + NPHY_TBL_ID_EPSILONTBL1), 1, + i, 32, &val); + } + + wlc_phy_ipa_restore_tx_digi_filts_nphy(pi); + + phy_b2.mm = wlc_phy_ipa_get_bbmult_nphy(pi); + for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { + wlc_phy_papd_cal_setup_nphy(pi, &phy_b2, phy_b5); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 4) + || (pi->pubpi.radiorev == 6)) { + pi->nphy_papd_cal_gain_index[phy_b5] = + 23; + } else if (pi->pubpi.radiorev == 5) { + pi->nphy_papd_cal_gain_index[phy_b5] = + 0; + pi->nphy_papd_cal_gain_index[phy_b5] = + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], + phy_b5); + + } else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { + + pi->nphy_papd_cal_gain_index[phy_b5] = + 0; + pi->nphy_papd_cal_gain_index[phy_b5] = + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], + phy_b5); + + } + + phy_b1[phy_b5].gains.pad[phy_b5] = + pi->nphy_papd_cal_gain_index[phy_b5]; + + } else { + pi->nphy_papd_cal_gain_index[phy_b5] = 0; + pi->nphy_papd_cal_gain_index[phy_b5] = + wlc_phy_a3_nphy( + pi, + pi-> + nphy_papd_cal_gain_index + [phy_b5], phy_b5); + phy_b1[phy_b5].gains.pga[phy_b5] = + pi->nphy_papd_cal_gain_index[phy_b5]; + } + } else { + phy_b1[phy_b5].useindex = true; + phy_b1[phy_b5].index = 16; + phy_b1[phy_b5].index = + wlc_phy_a3_nphy(pi, phy_b1[phy_b5].index, + phy_b5); + + pi->nphy_papd_cal_gain_index[phy_b5] = + 15 - ((phy_b1[phy_b5].index) >> 3); + } + + switch (pi->nphy_papd_cal_type) { + case 0: + wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_FULL, phy_b5); + break; + case 1: + wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_SOFT, phy_b5); + break; + } + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); + } + + if (NREV_LT(pi->pubpi.phy_rev, 7)) + wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); + + for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { + int eps_offset = 0; + + if (NREV_GE(pi->pubpi.phy_rev, 7)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if (pi->pubpi.radiorev == 3) + eps_offset = -2; + else if (pi->pubpi.radiorev == 5) + eps_offset = 3; + else + eps_offset = -1; + } else { + eps_offset = 2; + } + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + phy_b8 = phy_b1[phy_b5].gains.pad[phy_b5]; + phy_b10 = 0; + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) { + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev3n4 + [phy_b8] + 1) / 2; + phy_b10 = -1; + } else if (pi->pubpi.radiorev == 5) { + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev5 + [phy_b8] + 1) / 2; + } else if ((pi->pubpi.radiorev == 7) || + (pi->pubpi.radiorev == 8)) { + phy_b12 = -( + nphy_papd_padgain_dlt_2g_2057rev7 + [phy_b8] + 1) / 2; + } + } else { + phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5]; + if ((pi->pubpi.radiorev == 3) || + (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) + phy_b11 = + -(nphy_papd_pgagain_dlt_5g_2057 + [phy_b7] + + 1) / 2; + else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) + phy_b11 = -( + nphy_papd_pgagain_dlt_5g_2057rev7 + [phy_b7] + 1) / 2; + + phy_b10 = -9; + } + + if (CHSPEC_IS2G(pi->radio_chanspec)) + phy_b6 = + -60 + 27 + eps_offset + phy_b12 + + phy_b10; + else + phy_b6 = + -60 + 27 + eps_offset + phy_b11 + + phy_b10; + + mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : + 0x29c, (0x1ff << 7), (phy_b6) << 7); + + pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; + } else { + if (NREV_LT(pi->pubpi.phy_rev, 5)) + eps_offset = 4; + else + eps_offset = 2; + + phy_b7 = 15 - ((phy_b1[phy_b5].index) >> 3); + + if (CHSPEC_IS2G(pi->radio_chanspec)) { + phy_b11 = + -(nphy_papd_pga_gain_delta_ipa_2g[ + phy_b7] + + 1) / 2; + phy_b10 = 0; + } else { + phy_b11 = + -(nphy_papd_pga_gain_delta_ipa_5g[ + phy_b7] + + 1) / 2; + phy_b10 = -9; + } + + phy_b6 = -60 + 27 + eps_offset + phy_b11 + phy_b10; + + mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : + 0x29c, (0x1ff << 7), (phy_b6) << 7); + + pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; + } + } + + mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); + + mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : + 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); + + if (NREV_GE(pi->pubpi.phy_rev, 6)) { + mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (0) << 13); + + mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 13), (0) << 13); + + } else { + mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 11), (0) << 11); + + mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : + 0x2a4, (0x1 << 11), (0) << 11); + + } + pi->nphy_papdcomp = NPHY_PAPD_COMP_ON; + + write_phy_reg(pi, 0x01, phy_b9); + + wlc_phy_ipa_set_tx_digi_filts_nphy(pi); + + wlc_phy_txpwrctrl_enable_nphy(pi, phy_b4); + if (phy_b4 == PHY_TPC_HW_OFF) { + wlc_phy_txpwr_index_nphy(pi, (1 << 0), + (s8) (pi->nphy_txpwrindex[0]. + index_internal), false); + wlc_phy_txpwr_index_nphy(pi, (1 << 1), + (s8) (pi->nphy_txpwrindex[1]. + index_internal), false); + } + + wlc_phy_stay_in_carriersearch_nphy(pi, false); + + if (!phy_b3) + wlapi_enable_mac(pi->sh->physhim); +} + void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) { struct nphy_txgains target_gain; @@ -24271,18 +26189,6 @@ static void wlc_phy_reapply_txcal_coeffs_nphy(struct brcms_phy *pi) } } -static void wlc_phy_tx_iq_war_nphy(struct brcms_phy *pi) -{ - struct nphy_iq_comp tx_comp; - - wlc_phy_table_read_nphy(pi, 15, 4, 0x50, 16, &tx_comp); - - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ, tx_comp.a0); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 2, tx_comp.b0); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 4, tx_comp.a1); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 6, tx_comp.b1); -} - void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write, struct nphy_iq_comp *pcomp) @@ -25958,1282 +27864,6 @@ wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, return wlc_phy_cal_rxiq_nphy_rev2(pi, target_gain, debug); } -static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j, type = 2; - u16 addr_offset = 0x2c5; - - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_offset + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); -} - -static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j, type; - u16 addr_offset[] = { 0x186, 0x195, 0x2c5}; - - for (type = 0; type < 3; type++) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_offset[type] + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); - } - - if (IS40MHZ(pi)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[5][j]); - } - - if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x2c5 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[6][j]); - } - } -} - -static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j; - - if (IS40MHZ(pi)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x195 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[4][j]); - } else { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } -} - -static u16 wlc_phy_ipa_get_bbmult_nphy(struct brcms_phy *pi) -{ - u16 m0m1; - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); - - return m0m1; -} - -static void wlc_phy_ipa_set_bbmult_nphy(struct brcms_phy *pi, u8 m0, u8 m1) -{ - u16 m0m1 = (u16) ((m0 << 8) | m1); - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &m0m1); -} - -static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) -{ - u32 *tx_pwrctrl_tbl = NULL; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev4n6; - else if (pi->pubpi.radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev3; - else if (pi->pubpi.radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev5; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev7; - } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev6; - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev5; - } else { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa; - } - } else { - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_5g_2057rev7; - } else { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g; - } - } - - return tx_pwrctrl_tbl; -} - -static void -wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state, u8 core) -{ - s32 tone_freq; - u8 off_core; - u16 mixgain = 0; - - off_core = core ^ 0x1; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, - 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 5) - mixgain = (core == 0) ? 0x20 : 0x00; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - mixgain = 0x00; - else if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) - mixgain = 0x00; - } else { - if ((pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - mixgain = 0x50; - else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - mixgain = 0x0; - } - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), - mixgain, (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 1, (1 << core), 0); - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 0, (1 << off_core), 0); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), - 0, (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7); - state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); - state->afectrl[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa7 : 0xa6); - state->afeoverride[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa5 : 0x8f); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), - (0x1 << 2), 0); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), (0x1 << 2), (0x1 << 2)); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa7 : 0xa6), - (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa5 : - 0x8f), (0x1 << 2), (0x1 << 2)); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP); - state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN); - state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_PWRUP); - state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_ATTEN); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP, 0xc); - - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, 0xf0); - else if (pi->pubpi.radiorev == 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, - (core == 0) ? 0xf7 : 0xf2); - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, 0xf0); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_PWRUP, 0x0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_ATTEN, 0xff); - } else { - state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP); - state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN); - state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_PWRUP); - state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_ATTEN); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP, 0xc); - - if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, 0xf4); - - else - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, 0xf0); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_PWRUP, 0x0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_ATTEN, 0xff); - } - - tone_freq = 4000; - - wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_OFF) << 0); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - } else { - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 1, 0x3, 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0x3, 0); - - state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7); - state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), - (0x1 << 0) | (0x1 << 1) | (0x1 << 2), 0); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), - (0x1 << 0) | - (0x1 << 1) | - (0x1 << 2), (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); - - state->vga_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER); - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, 0x2b); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_G); - state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER); - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_G, - 0x03); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER, 0x04); - } else { - state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_A); - state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER); - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_A, - 0x03); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER, 0x04); - - } - - tone_freq = 4000; - - wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); - } -} - -static void -wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state) -{ - u8 core; - - wlc_phy_stopplayback_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP, 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, - state->atten[core]); - } else { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP, 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, - state->atten[core]); - } - } - - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7, state->afectrl[core]); - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : - 0xa5, state->afeoverride[core]); - } - - wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, - (state->mm & 0xff)); - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), 0, 0, - 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 1); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 0, 0x3, 1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, - state->vga_master[core]); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_G, state->fbmix[core]); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER, - state->intpa_master[core]); - } else { - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_A, state->fbmix[core]); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER, - state->intpa_master[core]); - } - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7, state->afectrl[core]); - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : - 0xa5, state->afeoverride[core]); - } - - wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, - (state->mm & 0xff)); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 1); - } -} - -static void -wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32 start, - u32 end) -{ - u32 *buf, *src, *dst, sz; - - sz = end - start + 1; - - buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC); - if (NULL == buf) - return; - - src = buf; - dst = buf + NPHY_PAPD_EPS_TBL_SIZE; - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), - NPHY_PAPD_EPS_TBL_SIZE, 0, 32, src); - - do { - u32 phy_a1, phy_a2; - s32 phy_a3, phy_a4, phy_a5, phy_a6, phy_a7; - - phy_a1 = end - min(end, (winsz >> 1)); - phy_a2 = min_t(u32, NPHY_PAPD_EPS_TBL_SIZE - 1, - end + (winsz >> 1)); - phy_a3 = phy_a2 - phy_a1 + 1; - phy_a6 = 0; - phy_a7 = 0; - - do { - wlc_phy_papd_decode_epsilon(src[phy_a2], &phy_a4, - &phy_a5); - phy_a6 += phy_a4; - phy_a7 += phy_a5; - } while (phy_a2-- != phy_a1); - - phy_a6 /= phy_a3; - phy_a7 /= phy_a3; - dst[end] = ((u32) phy_a7 << 13) | ((u32) phy_a6 & 0x1fff); - } while (end-- != start); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1, sz, start, 32, dst); - - kfree(buf); -} - -static void -wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, - enum phy_cal_mode cal_mode, u8 core) -{ - u16 phy_a1, phy_a2, phy_a3; - u16 phy_a4, phy_a5; - bool phy_a6; - u8 phy_a7, m[2]; - u32 phy_a8 = 0; - struct nphy_txgains phy_a9; - - if (NREV_LT(pi->pubpi.phy_rev, 3)) - return; - - phy_a7 = (core == PHY_CORE_0) ? 1 : 0; - - phy_a6 = ((cal_mode == CAL_GCTRL) - || (cal_mode == CAL_SOFT)) ? true : false; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - phy_a9 = wlc_phy_get_tx_gain_nphy(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_a5 = ((phy_a9.txlpf[core] << 15) | - (phy_a9.txgm[core] << 12) | - (phy_a9.pga[core] << 8) | - (txgains->gains.pad[core] << 3) | - (phy_a9.ipa[core])); - else - phy_a5 = ((phy_a9.txlpf[core] << 15) | - (phy_a9.txgm[core] << 12) | - (txgains->gains.pga[core] << 8) | - (phy_a9.pad[core] << 3) | (phy_a9.ipa[core])); - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 0); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) - m[core] = IS40MHZ(pi) ? 60 : 79; - else - m[core] = IS40MHZ(pi) ? 45 : 64; - } else { - m[core] = IS40MHZ(pi) ? 75 : 107; - } - - m[phy_a7] = 0; - wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); - - phy_a2 = 63; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - phy_a1 = 30; - phy_a3 = 30; - } else { - phy_a1 = 25; - phy_a3 = 25; - } - } else { - if ((pi->pubpi.radiorev == 5) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - phy_a1 = 25; - phy_a3 = 25; - } else { - phy_a1 = 35; - phy_a3 = 35; - } - } - - if (cal_mode == CAL_GCTRL) { - if ((pi->pubpi.radiorev == 5) - && (CHSPEC_IS2G(pi->radio_chanspec))) - phy_a1 = 55; - else if (((pi->pubpi.radiorev == 7) && - (CHSPEC_IS2G(pi->radio_chanspec))) || - ((pi->pubpi.radiorev == 8) && - (CHSPEC_IS2G(pi->radio_chanspec)))) - phy_a1 = 60; - else - phy_a1 = 63; - - } else if ((cal_mode != CAL_FULL) && (cal_mode != CAL_SOFT)) { - - phy_a1 = 35; - phy_a3 = 35; - } - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - write_phy_reg(pi, 0x2a1, 0x80); - write_phy_reg(pi, 0x2a2, 0x100); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 4), (11) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 8), (11) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 0), (0x3) << 0); - - write_phy_reg(pi, 0x2e5, 0x20); - - mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 1, ((core == 0) ? 1 : 2), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, ((core == 0) ? 2 : 1), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - write_phy_reg(pi, 0x2be, 1); - SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 - : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, - 32, &phy_a8); - - if (cal_mode != CAL_GCTRL) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - wlc_phy_a1_nphy(pi, core, 5, 0, 35); - } - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 1); - - } else { - - if (txgains) { - if (txgains->useindex) { - phy_a4 = 15 - ((txgains->index) >> 3); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 6)) - phy_a5 = 0x00f7 | (phy_a4 << 8); - - else - if (NREV_IS(pi->pubpi.phy_rev, 5)) - phy_a5 = 0x10f7 | (phy_a4 << 8); - else - phy_a5 = 0x50f7 | (phy_a4 << 8); - } else { - phy_a5 = 0x70f7 | (phy_a4 << 8); - } - wlc_phy_rfctrl_override_nphy(pi, - (0x1 << 13), - phy_a5, - (1 << core), 0); - } else { - wlc_phy_rfctrl_override_nphy(pi, - (0x1 << 13), - 0x5bf7, - (1 << core), 0); - } - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) - m[core] = IS40MHZ(pi) ? 45 : 64; - else - m[core] = IS40MHZ(pi) ? 75 : 107; - - m[phy_a7] = 0; - wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); - - phy_a2 = 63; - - if (cal_mode == CAL_FULL) { - phy_a1 = 25; - phy_a3 = 25; - } else if (cal_mode == CAL_SOFT) { - phy_a1 = 25; - phy_a3 = 25; - } else if (cal_mode == CAL_GCTRL) { - phy_a1 = 63; - phy_a3 = 25; - } else { - - phy_a1 = 25; - phy_a3 = 25; - } - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - write_phy_reg(pi, 0x2a1, 0x20); - write_phy_reg(pi, 0x2a2, 0x60); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 4), (9) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 8), (9) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 0), (0x2) << 0); - - write_phy_reg(pi, 0x2e5, 0x20); - } else { - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (1) << 11); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - write_phy_reg(pi, 0x2a1, 0x80); - write_phy_reg(pi, 0x2a2, 0x600); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 4), (0) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 8), (0) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 0), (0x3) << 0); - - mod_phy_reg(pi, 0x2a0, (0x3f << 8), (0x20) << 8); - - } - - mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0x3, 0); - - write_phy_reg(pi, 0x2be, 1); - SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 - : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, - 32, &phy_a8); - - if (cal_mode != CAL_GCTRL) - wlc_phy_a1_nphy(pi, core, 5, 0, 40); - } -} - -static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) -{ - int phy_a1; - int phy_a2; - bool phy_a3; - struct nphy_ipa_txcalgains phy_a4; - bool phy_a5 = false; - bool phy_a6 = true; - s32 phy_a7, phy_a8; - u32 phy_a9; - int phy_a10; - bool phy_a11 = false; - int phy_a12; - u8 phy_a13 = 0; - u8 phy_a14; - u8 *phy_a15 = NULL; - - phy_a4.useindex = true; - phy_a12 = start_gain; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - phy_a2 = 20; - phy_a1 = 1; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 5) { - - phy_a15 = pad_gain_codes_used_2057rev5; - phy_a13 = - sizeof(pad_gain_codes_used_2057rev5) / - sizeof(pad_gain_codes_used_2057rev5 - [0]) - 1; - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - phy_a15 = pad_gain_codes_used_2057rev7; - phy_a13 = - sizeof(pad_gain_codes_used_2057rev7) / - sizeof(pad_gain_codes_used_2057rev7 - [0]) - 1; - - } else { - - phy_a15 = pad_all_gain_codes_2057; - phy_a13 = sizeof(pad_all_gain_codes_2057) / - sizeof(pad_all_gain_codes_2057[0]) - - 1; - } - - } else { - - phy_a15 = pga_all_gain_codes_2057; - phy_a13 = sizeof(pga_all_gain_codes_2057) / - sizeof(pga_all_gain_codes_2057[0]) - 1; - } - - phy_a14 = 0; - - for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_a4.gains.pad[core] = - (u16) phy_a15[phy_a12]; - else - phy_a4.gains.pga[core] = - (u16) phy_a15[phy_a12]; - - wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - 63, 32, &phy_a9); - - wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); - - phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || - (phy_a8 == 4095) || (phy_a8 == -4096)); - - if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) - phy_a12 -= (u8) phy_a1; - - phy_a11 = true; - break; - } - - if (phy_a3) - phy_a12 += (u8) phy_a1; - else - phy_a12 -= (u8) phy_a1; - - if ((phy_a12 < phy_a14) || (phy_a12 > phy_a13)) { - if (phy_a12 < phy_a14) - phy_a12 = phy_a14; - else - phy_a12 = phy_a13; - - phy_a11 = true; - break; - } - - phy_a6 = false; - phy_a5 = phy_a3; - } - - } else { - phy_a2 = 10; - phy_a1 = 8; - for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { - phy_a4.index = (u8) phy_a12; - wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - 63, 32, &phy_a9); - - wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); - - phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || - (phy_a8 == 4095) || (phy_a8 == -4096)); - - if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) - phy_a12 -= (u8) phy_a1; - - phy_a11 = true; - break; - } - - if (phy_a3) - phy_a12 += (u8) phy_a1; - else - phy_a12 -= (u8) phy_a1; - - if ((phy_a12 < 0) || (phy_a12 > 127)) { - if (phy_a12 < 0) - phy_a12 = 0; - else - phy_a12 = 127; - - phy_a11 = true; - break; - } - - phy_a6 = false; - phy_a5 = phy_a3; - } - - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - return (u8) phy_a15[phy_a12]; - else - return (u8) phy_a12; - -} - -static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) -{ - struct nphy_ipa_txcalgains phy_b1[2]; - struct nphy_papd_restore_state phy_b2; - bool phy_b3; - u8 phy_b4; - u8 phy_b5; - s16 phy_b6, phy_b7, phy_b8; - u16 phy_b9; - s16 phy_b10, phy_b11, phy_b12; - - phy_b11 = 0; - phy_b12 = 0; - phy_b7 = 0; - phy_b8 = 0; - phy_b6 = 0; - - if (pi->nphy_papd_skip == 1) - return; - - phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!phy_b3) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - pi->nphy_force_papd_cal = false; - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) - pi->nphy_papd_tx_gain_at_last_cal[phy_b5] = - wlc_phy_txpwr_idx_cur_get_nphy(pi, phy_b5); - - pi->nphy_papd_last_cal = pi->sh->now; - pi->nphy_papd_recal_counter++; - - phy_b4 = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL0, 64, 0, 32, - nphy_papd_scaltbl); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL1, 64, 0, 32, - nphy_papd_scaltbl); - - phy_b9 = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - s32 i, val = 0; - for (i = 0; i < 64; i++) - wlc_phy_table_write_nphy(pi, - ((phy_b5 == - PHY_CORE_0) ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - i, 32, &val); - } - - wlc_phy_ipa_restore_tx_digi_filts_nphy(pi); - - phy_b2.mm = wlc_phy_ipa_get_bbmult_nphy(pi); - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - wlc_phy_papd_cal_setup_nphy(pi, &phy_b2, phy_b5); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - pi->nphy_papd_cal_gain_index[phy_b5] = - 23; - } else if (pi->pubpi.radiorev == 5) { - pi->nphy_papd_cal_gain_index[phy_b5] = - 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], - phy_b5); - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - pi->nphy_papd_cal_gain_index[phy_b5] = - 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], - phy_b5); - - } - - phy_b1[phy_b5].gains.pad[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; - - } else { - pi->nphy_papd_cal_gain_index[phy_b5] = 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], phy_b5); - phy_b1[phy_b5].gains.pga[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; - } - } else { - phy_b1[phy_b5].useindex = true; - phy_b1[phy_b5].index = 16; - phy_b1[phy_b5].index = - wlc_phy_a3_nphy(pi, phy_b1[phy_b5].index, - phy_b5); - - pi->nphy_papd_cal_gain_index[phy_b5] = - 15 - ((phy_b1[phy_b5].index) >> 3); - } - - switch (pi->nphy_papd_cal_type) { - case 0: - wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_FULL, phy_b5); - break; - case 1: - wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_SOFT, phy_b5); - break; - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - } - - if (NREV_LT(pi->pubpi.phy_rev, 7)) - wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - int eps_offset = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 3) - eps_offset = -2; - else if (pi->pubpi.radiorev == 5) - eps_offset = 3; - else - eps_offset = -1; - } else { - eps_offset = 2; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - phy_b8 = phy_b1[phy_b5].gains.pad[phy_b5]; - phy_b10 = 0; - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev3n4 - [phy_b8] + 1) / 2; - phy_b10 = -1; - } else if (pi->pubpi.radiorev == 5) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev5 - [phy_b8] + 1) / 2; - } else if ((pi->pubpi.radiorev == 7) || - (pi->pubpi.radiorev == 8)) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev7 - [phy_b8] + 1) / 2; - } - } else { - phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5]; - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - phy_b11 = - -(nphy_papd_pgagain_dlt_5g_2057 - [phy_b7] - + 1) / 2; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - phy_b11 = -( - nphy_papd_pgagain_dlt_5g_2057rev7 - [phy_b7] + 1) / 2; - - phy_b10 = -9; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_b6 = - -60 + 27 + eps_offset + phy_b12 + - phy_b10; - else - phy_b6 = - -60 + 27 + eps_offset + phy_b11 + - phy_b10; - - mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), (phy_b6) << 7); - - pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; - } else { - if (NREV_LT(pi->pubpi.phy_rev, 5)) - eps_offset = 4; - else - eps_offset = 2; - - phy_b7 = 15 - ((phy_b1[phy_b5].index) >> 3); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_2g[ - phy_b7] + - 1) / 2; - phy_b10 = 0; - } else { - phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_5g[ - phy_b7] + - 1) / 2; - phy_b10 = -9; - } - - phy_b6 = -60 + 27 + eps_offset + phy_b11 + phy_b10; - - mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), (phy_b6) << 7); - - pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; - } - } - - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - } else { - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - } - pi->nphy_papdcomp = NPHY_PAPD_COMP_ON; - - write_phy_reg(pi, 0x01, phy_b9); - - wlc_phy_ipa_set_tx_digi_filts_nphy(pi); - - wlc_phy_txpwrctrl_enable_nphy(pi, phy_b4); - if (phy_b4 == PHY_TPC_HW_OFF) { - wlc_phy_txpwr_index_nphy(pi, (1 << 0), - (s8) (pi->nphy_txpwrindex[0]. - index_internal), false); - wlc_phy_txpwr_index_nphy(pi, (1 << 1), - (s8) (pi->nphy_txpwrindex[1]. - index_internal), false); - } - - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - if (!phy_b3) - wlapi_enable_mac(pi->sh->physhim); -} - void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) { uint core; @@ -27637,267 +28267,6 @@ void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) return; } -static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) -{ - u16 bw40po, cddpo, stbcpo, bwduppo; - uint band_num; - - if (pi->sh->sromrev >= 9) - return; - - bw40po = (u16) PHY_GETINTVAR(pi, "bw40po"); - pi->bw402gpo = bw40po & 0xf; - pi->bw405gpo = (bw40po & 0xf0) >> 4; - pi->bw405glpo = (bw40po & 0xf00) >> 8; - pi->bw405ghpo = (bw40po & 0xf000) >> 12; - - cddpo = (u16) PHY_GETINTVAR(pi, "cddpo"); - pi->cdd2gpo = cddpo & 0xf; - pi->cdd5gpo = (cddpo & 0xf0) >> 4; - pi->cdd5glpo = (cddpo & 0xf00) >> 8; - pi->cdd5ghpo = (cddpo & 0xf000) >> 12; - - stbcpo = (u16) PHY_GETINTVAR(pi, "stbcpo"); - pi->stbc2gpo = stbcpo & 0xf; - pi->stbc5gpo = (stbcpo & 0xf0) >> 4; - pi->stbc5glpo = (stbcpo & 0xf00) >> 8; - pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; - - bwduppo = (u16) PHY_GETINTVAR(pi, "bwduppo"); - pi->bwdup2gpo = bwduppo & 0xf; - pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; - pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; - pi->bwdup5ghpo = (bwduppo & 0xf000) >> 12; - - for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); - band_num++) { - switch (band_num) { - case 0: - - pi->nphy_txpid2g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid2ga0"); - pi->nphy_txpid2g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid2ga1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga1"); - - pi->cck2gpo = (u16) PHY_GETINTVAR(pi, "cck2gpo"); - - pi->ofdm2gpo = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); - - pi->mcs2gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); - pi->mcs2gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs2gpo1"); - pi->mcs2gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs2gpo2"); - pi->mcs2gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs2gpo3"); - pi->mcs2gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs2gpo4"); - pi->mcs2gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs2gpo5"); - pi->mcs2gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs2gpo6"); - pi->mcs2gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs2gpo7"); - break; - case 1: - - pi->nphy_txpid5g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid5ga0"); - pi->nphy_txpid5g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid5ga1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a1"); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga0"); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga1"); - - pi->ofdm5gpo = (u32) PHY_GETINTVAR(pi, "ofdm5gpo"); - - pi->mcs5gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs5gpo0"); - pi->mcs5gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs5gpo1"); - pi->mcs5gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs5gpo2"); - pi->mcs5gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs5gpo3"); - pi->mcs5gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs5gpo4"); - pi->mcs5gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs5gpo5"); - pi->mcs5gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs5gpo6"); - pi->mcs5gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs5gpo7"); - break; - case 2: - - pi->nphy_txpid5gl[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gla0"); - pi->nphy_txpid5gl[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gla1"); - pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla0"); - pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a1"); - pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; - pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; - - pi->ofdm5glpo = (u32) PHY_GETINTVAR(pi, "ofdm5glpo"); - - pi->mcs5glpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo0"); - pi->mcs5glpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo1"); - pi->mcs5glpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo2"); - pi->mcs5glpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo3"); - pi->mcs5glpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo4"); - pi->mcs5glpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo5"); - pi->mcs5glpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo6"); - pi->mcs5glpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo7"); - break; - case 3: - - pi->nphy_txpid5gh[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gha0"); - pi->nphy_txpid5gh[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gha1"); - pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha0"); - pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a1"); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a0"); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a1"); - pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; - pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; - - pi->ofdm5ghpo = (u32) PHY_GETINTVAR(pi, "ofdm5ghpo"); - - pi->mcs5ghpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo0"); - pi->mcs5ghpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo1"); - pi->mcs5ghpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo2"); - pi->mcs5ghpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo3"); - pi->mcs5ghpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo4"); - pi->mcs5ghpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo5"); - pi->mcs5ghpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo6"); - pi->mcs5ghpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo7"); - break; - } - } - - wlc_phy_txpwr_apply_nphy(pi); -} - -static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) -{ - - pi->antswitch = (u8) PHY_GETINTVAR(pi, "antswitch"); - pi->aa2g = (u8) PHY_GETINTVAR(pi, "aa2g"); - pi->aa5g = (u8) PHY_GETINTVAR(pi, "aa5g"); - - pi->srom_fem2g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos2g"); - pi->srom_fem2g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain2g"); - pi->srom_fem2g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange2g"); - pi->srom_fem2g.triso = (u8) PHY_GETINTVAR(pi, "triso2g"); - pi->srom_fem2g.antswctrllut = (u8) PHY_GETINTVAR(pi, "antswctl2g"); - - pi->srom_fem5g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos5g"); - pi->srom_fem5g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain5g"); - pi->srom_fem5g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange5g"); - pi->srom_fem5g.triso = (u8) PHY_GETINTVAR(pi, "triso5g"); - if (PHY_GETVAR(pi, "antswctl5g")) - pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl5g"); - else - pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl2g"); - - wlc_phy_txpower_ipa_upd(pi); - - pi->phy_txcore_disable_temp = (s16) PHY_GETINTVAR(pi, "tempthresh"); - if (pi->phy_txcore_disable_temp == 0) - pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - - pi->phy_tempsense_offset = (s8) PHY_GETINTVAR(pi, "tempoffset"); - if (pi->phy_tempsense_offset != 0) { - if (pi->phy_tempsense_offset > - (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) - pi->phy_tempsense_offset = NPHY_SROM_MAXTEMPOFFSET; - else if (pi->phy_tempsense_offset < (NPHY_SROM_TEMPSHIFT + - NPHY_SROM_MINTEMPOFFSET)) - pi->phy_tempsense_offset = NPHY_SROM_MINTEMPOFFSET; - else - pi->phy_tempsense_offset -= NPHY_SROM_TEMPSHIFT; - } - - pi->phy_txcore_enable_temp = - pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; - - pi->phycal_tempdelta = (u8) PHY_GETINTVAR(pi, "phycal_tempdelta"); - if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) - pi->phycal_tempdelta = 0; - - wlc_phy_txpwr_srom_read_ppr_nphy(pi); - - return true; -} - void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi) { u8 tx_pwr_ctrl_state; @@ -27918,495 +28287,12 @@ void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi) wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); } -static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) -{ - u32 idx; - u16 iqloCalbuf[7]; - u32 iqcomp, locomp, curr_locomp; - s8 locomp_i, locomp_q; - s8 curr_locomp_i, curr_locomp_q; - u32 tbl_id, tbl_len, tbl_offset; - u32 regval[128]; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - wlc_phy_table_read_nphy(pi, 15, 7, 80, 16, iqloCalbuf); - - tbl_len = 128; - tbl_offset = 320; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - iqcomp = - (tbl_id == - 26) ? (((u32) (iqloCalbuf[0] & 0x3ff)) << 10) | - (iqloCalbuf[1] & 0x3ff) - : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | - (iqloCalbuf[3] & 0x3ff); - - for (idx = 0; idx < tbl_len; idx++) - regval[idx] = iqcomp; - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - tbl_offset = 448; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - - locomp = - (u32) ((tbl_id == 26) ? iqloCalbuf[5] : iqloCalbuf[6]); - locomp_i = (s8) ((locomp >> 8) & 0xff); - locomp_q = (s8) ((locomp) & 0xff); - for (idx = 0; idx < tbl_len; idx++) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - curr_locomp_i = locomp_i; - curr_locomp_q = locomp_q; - } else { - curr_locomp_i = (s8) ((locomp_i * - nphy_tpc_loscale[idx] + - 128) >> 8); - curr_locomp_q = - (s8) ((locomp_q * - nphy_tpc_loscale[idx] + - 128) >> 8); - } - curr_locomp = (u32) ((curr_locomp_i & 0xff) << 8); - curr_locomp |= (u32) (curr_locomp_q & 0xff); - regval[idx] = curr_locomp; - } - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - - wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX1, 0xFFFF); - wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX2, 0xFFFF); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) -{ - u8 core; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x5); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX, 0xe); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIA, 0); - - if (!NREV_IS(pi->pubpi.phy_rev, 7)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIG, 0x1); - else - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIG, 0x31); - } else { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x9); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX, 0xc); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSIG, 0); - - if (pi->pubpi.radiorev != 5) { - if (!NREV_IS(pi->pubpi.phy_rev, 7)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x1); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x31); - } - } - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_VCM_HG, - 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_IDAC, - 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_VCM, - 0x3); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, - 0x0); - } - } else { - WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR31, - (CHSPEC_IS2G(pi->radio_chanspec)) ? 0x128 : - 0x80); - WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR30, 0x0); - WRITE_RADIO_SYN(pi, RADIO_2056, GPIO_MASTER1, 0x29); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_VCM_HG, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_IDAC, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_VCM, - 0x3); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TX_AMP_DET, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC1, - 0x8); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC2, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC3, - 0x0); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MASTER, 0x5); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIA, 0x0); - if (NREV_GE(pi->pubpi.phy_rev, 5)) - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIG, 0x31); - else - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIG, 0x11); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MUX, 0xe); - } else { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MASTER, 0x9); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TSSIA, 0x31); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TSSIG, 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MUX, 0xc); - } - } - } -} - -static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) -{ - s32 rssi_buf[4]; - s32 int_val; - - if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) || PHY_MUTED(pi)) - - return; - - if (PHY_IPA(pi)) - wlc_phy_ipa_internal_tssi_setup_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 0); - - wlc_phy_stopplayback_nphy(pi); - - wlc_phy_tx_tone_nphy(pi, 4000, 0, 0, 0, false); - - udelay(20); - int_val = - wlc_phy_poll_rssi_nphy(pi, (u8) NPHY_RSSI_SEL_TSSI_2G, rssi_buf, - 1); - wlc_phy_stopplayback_nphy(pi); - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, 0); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 1); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 24) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val >> 8) & 0xff); - } else { - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 16) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val) & 0xff); - } - -} - -static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) -{ - u32 idx; - s16 a1[2], b0[2], b1[2]; - s8 target_pwr_qtrdbm[2]; - s32 num, den, pwr_est; - u8 chan_freq_range; - u8 idle_tssi[2]; - u32 tbl_id, tbl_len, tbl_offset; - u32 regval[64]; - u8 core; - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); - udelay(1); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - or_phy_reg(pi, 0x122, (0x1 << 0)); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - and_phy_reg(pi, 0x1e7, (u16) (~(0x1 << 15))); - else - or_phy_reg(pi, 0x1e7, (0x1 << 15)); - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); - - if (pi->sh->sromrev < 4) { - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; - a1[0] = -424; - a1[1] = -424; - b0[0] = 5612; - b0[1] = 5612; - b1[1] = -1393; - b1[0] = -1393; - } else { - - chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_2G: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_2g; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_2g; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b1; - break; - case WL_CHAN_FREQ_RANGE_5GL: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gl; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gl; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1; - break; - case WL_CHAN_FREQ_RANGE_5GM: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gm; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gm; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b1; - break; - case WL_CHAN_FREQ_RANGE_5GH: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gh; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gh; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1; - break; - default: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; - a1[0] = -424; - a1[1] = -424; - b0[0] = 5612; - b0[1] = 5612; - b1[1] = -1393; - b1[0] = -1393; - break; - } - } - - target_pwr_qtrdbm[0] = (s8) pi->tx_power_max; - target_pwr_qtrdbm[1] = (s8) pi->tx_power_max; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->srom_fem2g.tssipos) - or_phy_reg(pi, 0x1e9, (0x1 << 14)); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (core = 0; core <= 1; core++) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TX_SSI_MUX, - 0xe); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TX_SSI_MUX, - 0xc); - } - } - } else { - if (PHY_IPA(pi)) { - - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX0, - (CHSPEC_IS5G - (pi->radio_chanspec)) ? - 0xc : 0xe); - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX1, - (CHSPEC_IS5G - (pi->radio_chanspec)) ? - 0xc : 0xe); - } else { - - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX0, 0x11); - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX1, 0x11); - } - } - } - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); - udelay(1); - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_phy_reg(pi, 0x1e7, (0x7f << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - else - mod_phy_reg(pi, 0x1e7, (0x7f << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_phy_reg(pi, 0x222, (0xff << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - else if (NREV_GT(pi->pubpi.phy_rev, 1)) - mod_phy_reg(pi, 0x222, (0xff << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); - - write_phy_reg(pi, 0x1e8, (0x3 << 8) | (240 << 0)); - - write_phy_reg(pi, 0x1e9, - (1 << 15) | (idle_tssi[0] << 0) | (idle_tssi[1] << 8)); - - write_phy_reg(pi, 0x1ea, - (target_pwr_qtrdbm[0] << 0) | - (target_pwr_qtrdbm[1] << 8)); - - tbl_len = 64; - tbl_offset = 0; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - - for (idx = 0; idx < tbl_len; idx++) { - num = 8 * - (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx); - den = 32768 + a1[tbl_id - 26] * idx; - pwr_est = max(((4 * num + den / 2) / den), -8); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - if (idx <= - (uint) (31 - idle_tssi[tbl_id - 26] + 1)) - pwr_est = - max(pwr_est, - target_pwr_qtrdbm - [tbl_id - 26] + 1); - } - regval[idx] = (u32) pwr_est; - } - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - wlc_phy_txpwr_limit_to_tbl_nphy(pi); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 84, 64, 8, - pi->adj_pwr_tbl_nphy); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 84, 64, 8, - pi->adj_pwr_tbl_nphy); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - static bool wlc_phy_txpwr_ison_nphy(struct brcms_phy *pi) { return read_phy_reg((pi), 0x1e7) & ((0x1 << 15) | (0x1 << 14) | (0x1 << 13)); } -static u8 wlc_phy_txpwr_idx_cur_get_nphy(struct brcms_phy *pi, u8 core) -{ - u16 tmp; - tmp = read_phy_reg(pi, ((core == PHY_CORE_0) ? 0x1ed : 0x1ee)); - - tmp = (tmp & (0x7f << 8)) >> 8; - return (u8) tmp; -} - -static void -wlc_phy_txpwr_idx_cur_set_nphy(struct brcms_phy *pi, u8 idx0, u8 idx1) -{ - mod_phy_reg(pi, 0x1e7, (0x7f << 0), idx0); - - if (NREV_GT(pi->pubpi.phy_rev, 1)) - mod_phy_reg(pi, 0x222, (0xff << 0), idx1); -} - u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi) { u16 tmp; From b9c4decbd9530b0c4c6dc4ad0626af628b79cd53 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 26 Aug 2011 11:06:08 -0700 Subject: [PATCH 0655/1519] staging: fix rts5139 depends & build RTS5139 should depend on USB, not USB_SUPPORT, to fix build errors. USB_SUPPORT can be enabled for gadget-only support or when PCI is not enabled. ERROR: "usb_reset_endpoint" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_kill_urb" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_deregister_dev" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_unlink_urb" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_deregister" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_register_dev" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_free_coherent" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_submit_urb" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_sg_cancel" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_find_interface" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_sg_init" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_register_driver" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_alloc_coherent" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_free_urb" [drivers/staging/rts5139/rts5139.ko] undefined! ERROR: "usb_alloc_urb" [drivers/staging/rts5139/rts5139.ko] undefined! Signed-off-by: Randy Dunlap Cc: Edwin Rong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5139/Kconfig b/drivers/staging/rts5139/Kconfig index f940e516945..afd526bf422 100644 --- a/drivers/staging/rts5139/Kconfig +++ b/drivers/staging/rts5139/Kconfig @@ -1,6 +1,6 @@ config RTS5139 tristate "Realtek RTS5139 USB card reader support" - depends on USB_SUPPORT && SCSI + depends on USB && SCSI help Say Y here to include driver code to support the Realtek RTS5139 USB card readers. From a504de3a1e201994eff1400d4eb16241be68c311 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 26 Aug 2011 16:46:28 -0500 Subject: [PATCH 0656/1519] staging: rtl8192e: Fix array overrun Smatch outputs the following message: drivers/staging/rtl8192e/r8192E_cmdpkt.c +412 cmpk_message_handle_rx(70) error: buffer overflow 'priv->stats.rxcmdpkt' 4 <= 7 407 RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" 408 "unknow CMD Element\n"); 409 return 1; 410 } 411 412 priv->stats.rxcmdpkt[element_id]++; ^^^^^^^^^^ ->stats.rxcmdpkt[] only has 4 elements, but from the switch statement in the section before we can see that element_id can go up to 7 (RX_TX_RATE_HISTORY). Reported-by: Dan Carpenter Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 5b78530bf22..f9af5153d9c 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -388,7 +388,7 @@ struct rt_stats { unsigned long rxrdu; unsigned long rxok; unsigned long rxframgment; - unsigned long rxcmdpkt[4]; + unsigned long rxcmdpkt[8]; unsigned long rxurberr; unsigned long rxstaterr; unsigned long rxdatacrcerr; From 0fb07a87ec663652bea02a54faa05fb4b3d0c20f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:00 -0700 Subject: [PATCH 0657/1519] Staging: hv: storvsc: Inline free_stor_device() Inline the code for free_stor_device() and get rid of the function. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 827b6a307ef..8c62829f599 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -51,10 +51,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) return stor_device; } -static inline void free_stor_device(struct storvsc_device *device) -{ - kfree(device); -} /* Get the stordevice object iff exists and its refcount > 0 */ static inline struct storvsc_device *must_get_stor_device( @@ -394,7 +390,7 @@ int storvsc_dev_add(struct hv_device *device, /* Send it back up */ ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size); if (ret) { - free_stor_device(stor_device); + kfree(stor_device); return ret; } device_info->path_id = stor_device->path_id; @@ -422,7 +418,7 @@ int storvsc_dev_remove(struct hv_device *device) /* Close the channel */ vmbus_close(device->channel); - free_stor_device(stor_device); + kfree(stor_device); return 0; } From bdbc49706be445d0f5c16c0add979d52d01a7b2c Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:01 -0700 Subject: [PATCH 0658/1519] Staging: hv: storvsc: Do not aquire an unnecessary reference on stor_device On entry into storvsc_on_io_completion() we have already acquired a reference on the stor_device; there is no need to acquire an additional reference here. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 8c62829f599..cd38cd6803e 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -232,9 +232,7 @@ static void storvsc_on_io_completion(struct hv_device *device, struct storvsc_device *stor_device; struct vstor_packet *stor_pkt; - stor_device = must_get_stor_device(device); - if (!stor_device) - return; + stor_device = (struct storvsc_device *)device->ext; stor_pkt = &request->vstor_packet; @@ -279,7 +277,6 @@ static void storvsc_on_io_completion(struct hv_device *device, wake_up(&stor_device->waiting_to_drain); - put_stor_device(device); } static void storvsc_on_receive(struct hv_device *device, From bf49e809986f11c9046239e3d2439b5581f2421b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:02 -0700 Subject: [PATCH 0659/1519] Staging: hv: storvsc: Rename must_get_stor_device() In preparation for cleaning up how we manage reference counts on the stor device, clearly distinguish why we are attempting to acquire a reference. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index cd38cd6803e..89708b1d3f6 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) return NULL; /* Set to 2 to allow both inbound and outbound traffics */ - /* (ie get_stor_device() and must_get_stor_device()) to proceed. */ + /* (ie get_stor_device() and get_in_stor_device()) to proceed. */ atomic_cmpxchg(&stor_device->ref_count, 0, 2); init_waitqueue_head(&stor_device->waiting_to_drain); @@ -53,7 +53,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) /* Get the stordevice object iff exists and its refcount > 0 */ -static inline struct storvsc_device *must_get_stor_device( +static inline struct storvsc_device *get_in_stor_device( struct hv_device *device) { struct storvsc_device *stor_device; @@ -305,7 +305,7 @@ static void storvsc_on_channel_callback(void *context) int ret; - stor_device = must_get_stor_device(device); + stor_device = get_in_stor_device(device); if (!stor_device) return; From 1eaaddf93853b222a08ec37d4d8c4edc1085d312 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:03 -0700 Subject: [PATCH 0660/1519] Staging: hv: storvsc: Rename get_stor_device() In preparation for cleaning up how we manage reference counts on the stor device, clearly distinguish why we are attempting to acquire a reference. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_storage.h | 3 ++- drivers/staging/hv/storvsc.c | 8 ++++---- drivers/staging/hv/storvsc_drv.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h index a01f9a07c98..a2244138637 100644 --- a/drivers/staging/hv/hyperv_storage.h +++ b/drivers/staging/hv/hyperv_storage.h @@ -288,7 +288,8 @@ struct storvsc_device { /* Get the stordevice object iff exists and its refcount > 1 */ -static inline struct storvsc_device *get_stor_device(struct hv_device *device) +static inline struct storvsc_device *get_out_stor_device( + struct hv_device *device) { struct storvsc_device *stor_device; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 89708b1d3f6..313a3f8cfaf 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) return NULL; /* Set to 2 to allow both inbound and outbound traffics */ - /* (ie get_stor_device() and get_in_stor_device()) to proceed. */ + /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */ atomic_cmpxchg(&stor_device->ref_count, 0, 2); init_waitqueue_head(&stor_device->waiting_to_drain); @@ -67,7 +67,7 @@ static inline struct storvsc_device *get_in_stor_device( return stor_device; } -/* Drop ref count to 1 to effectively disable get_stor_device() */ +/* Drop ref count to 1 to effectively disable get_out_stor_device() */ static inline struct storvsc_device *release_stor_device( struct hv_device *device) { @@ -105,7 +105,7 @@ static int storvsc_channel_init(struct hv_device *device) struct vstor_packet *vstor_packet; int ret, t; - stor_device = get_stor_device(device); + stor_device = get_out_stor_device(device); if (!stor_device) return -ENODEV; @@ -427,7 +427,7 @@ int storvsc_do_io(struct hv_device *device, int ret = 0; vstor_packet = &request->vstor_packet; - stor_device = get_stor_device(device); + stor_device = get_out_stor_device(device); if (!stor_device) return -ENODEV; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index faa8d576087..5b2004fbb4b 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -344,7 +344,7 @@ static int storvsc_host_reset(struct hv_device *device) int ret, t; - stor_device = get_stor_device(device); + stor_device = get_out_stor_device(device); if (!stor_device) return -ENODEV; From df977d6c90632b3868055862262529007019d4ef Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:04 -0700 Subject: [PATCH 0661/1519] Staging: hv: storvsc: Cleanup alloc_stor_device() Cleanup alloc_stor_device(), we can set the ref_count directly. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 313a3f8cfaf..48bd8dae02e 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -42,7 +42,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) /* Set to 2 to allow both inbound and outbound traffics */ /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */ - atomic_cmpxchg(&stor_device->ref_count, 0, 2); + atomic_set(&stor_device->ref_count, 2); init_waitqueue_head(&stor_device->waiting_to_drain); stor_device->device = device; From f6c17484eb386014ee52d9edc8b3e8263d57c640 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:05 -0700 Subject: [PATCH 0662/1519] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device Introduce state to manage the lifecycle of stor device. This would be the basis for managing the references on the stor object. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_storage.h | 2 +- drivers/staging/hv/storvsc.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h index a2244138637..d93bf93eb24 100644 --- a/drivers/staging/hv/hyperv_storage.h +++ b/drivers/staging/hv/hyperv_storage.h @@ -266,7 +266,7 @@ struct storvsc_device { /* 0 indicates the device is being destroyed */ atomic_t ref_count; - + bool destroy; bool drain_notify; atomic_t num_outstanding_req; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 48bd8dae02e..0f8c60961ec 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) /* Set to 2 to allow both inbound and outbound traffics */ /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */ atomic_set(&stor_device->ref_count, 2); - + stor_device->destroy = false; init_waitqueue_head(&stor_device->waiting_to_drain); stor_device->device = device; device->ext = stor_device; @@ -399,9 +399,15 @@ int storvsc_dev_add(struct hv_device *device, int storvsc_dev_remove(struct hv_device *device) { struct storvsc_device *stor_device; + unsigned long flags; + stor_device = release_stor_device(device); + spin_lock_irqsave(&device->channel->inbound_lock, flags); + stor_device->destroy = true; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); + /* * At this point, all outbound traffic should be disable. We * only allow inbound traffic (responses) to proceed so that From 582f445fde4886959deacf93b6dea6817f41ba88 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:06 -0700 Subject: [PATCH 0663/1519] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is being destroyed Prevent outgoing traffic when stor dev is destroyed. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_storage.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h index d93bf93eb24..1a59ca090fc 100644 --- a/drivers/staging/hv/hyperv_storage.h +++ b/drivers/staging/hv/hyperv_storage.h @@ -294,7 +294,8 @@ static inline struct storvsc_device *get_out_stor_device( struct storvsc_device *stor_device; stor_device = (struct storvsc_device *)device->ext; - if (stor_device && atomic_read(&stor_device->ref_count) > 1) + if (stor_device && (atomic_read(&stor_device->ref_count) > 1) && + !stor_device->destroy) atomic_inc(&stor_device->ref_count); else stor_device = NULL; From c352ee8f610bb136d5666b142bff8f48fa7a9289 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:07 -0700 Subject: [PATCH 0664/1519] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code Get rid of release_stor_device() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 0f8c60961ec..1976a34102b 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -67,21 +67,6 @@ static inline struct storvsc_device *get_in_stor_device( return stor_device; } -/* Drop ref count to 1 to effectively disable get_out_stor_device() */ -static inline struct storvsc_device *release_stor_device( - struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; - - /* Busy wait until the ref drop to 2, then set it to 1 */ - while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2) - udelay(100); - - return stor_device; -} - /* Drop ref count to 0. No one can use stor_device object. */ static inline struct storvsc_device *final_release_stor_device( struct hv_device *device) @@ -401,8 +386,8 @@ int storvsc_dev_remove(struct hv_device *device) struct storvsc_device *stor_device; unsigned long flags; - - stor_device = release_stor_device(device); + stor_device = (struct storvsc_device *)device->ext; + atomic_dec(&stor_device->ref_count); spin_lock_irqsave(&device->channel->inbound_lock, flags); stor_device->destroy = true; From a5b2359b05925ade4b9a645b9e45a6c4b8fb1ff0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:08 -0700 Subject: [PATCH 0665/1519] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code Get rid of final_release_stor_device() by inlining code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 1976a34102b..3e9829f2c1d 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -67,22 +67,6 @@ static inline struct storvsc_device *get_in_stor_device( return stor_device; } -/* Drop ref count to 0. No one can use stor_device object. */ -static inline struct storvsc_device *final_release_stor_device( - struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; - - /* Busy wait until the ref drop to 1, then set it to 0 */ - while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1) - udelay(100); - - device->ext = NULL; - return stor_device; -} - static int storvsc_channel_init(struct hv_device *device) { struct storvsc_device *stor_device; @@ -401,7 +385,12 @@ int storvsc_dev_remove(struct hv_device *device) storvsc_wait_to_drain(stor_device); - stor_device = final_release_stor_device(device); + /* + * Since we have already drained, we don't need to busy wait + * as was done in final_release_stor_device() + */ + atomic_set(&stor_device->ref_count, 0); + device->ext = NULL; /* Close the channel */ vmbus_close(device->channel); From 5e6f4d069f102b6a49433943cf37e3bdc52e2314 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:09 -0700 Subject: [PATCH 0666/1519] Staging: hv: storvsc: Get rid of the reference counting in struct storvsc_device Get rid of the reference counting in struct storvsc_device. We manage the lifecycle with the following logic: If the device is marked for destruction, we dot allow any outgoing traffic on the device. Incoming traffic is allowed only to drain pending outgoing traffic. Note that while the upper level code in Linux deals with outstanding I/Os, we may have situations on Hyper-V where some book keeping messages are sent out that the upper level Linux code may not be aware of. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_storage.h | 18 ++-------------- drivers/staging/hv/storvsc.c | 33 ++++++++++++++++++----------- drivers/staging/hv/storvsc_drv.c | 1 - 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h index 1a59ca090fc..687cdc543c4 100644 --- a/drivers/staging/hv/hyperv_storage.h +++ b/drivers/staging/hv/hyperv_storage.h @@ -264,8 +264,6 @@ struct storvsc_major_info { struct storvsc_device { struct hv_device *device; - /* 0 indicates the device is being destroyed */ - atomic_t ref_count; bool destroy; bool drain_notify; atomic_t num_outstanding_req; @@ -287,32 +285,20 @@ struct storvsc_device { }; -/* Get the stordevice object iff exists and its refcount > 1 */ static inline struct storvsc_device *get_out_stor_device( struct hv_device *device) { struct storvsc_device *stor_device; stor_device = (struct storvsc_device *)device->ext; - if (stor_device && (atomic_read(&stor_device->ref_count) > 1) && - !stor_device->destroy) - atomic_inc(&stor_device->ref_count); - else + + if (stor_device && stor_device->destroy) stor_device = NULL; return stor_device; } -static inline void put_stor_device(struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; - - atomic_dec(&stor_device->ref_count); -} - static inline void storvsc_wait_to_drain(struct storvsc_device *dev) { dev->drain_notify = true; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 3e9829f2c1d..fb7b3cae0fe 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -40,9 +40,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) if (!stor_device) return NULL; - /* Set to 2 to allow both inbound and outbound traffics */ - /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */ - atomic_set(&stor_device->ref_count, 2); stor_device->destroy = false; init_waitqueue_head(&stor_device->waiting_to_drain); stor_device->device = device; @@ -52,19 +49,31 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) } -/* Get the stordevice object iff exists and its refcount > 0 */ static inline struct storvsc_device *get_in_stor_device( struct hv_device *device) { struct storvsc_device *stor_device; + unsigned long flags; + spin_lock_irqsave(&device->channel->inbound_lock, flags); stor_device = (struct storvsc_device *)device->ext; - if (stor_device && atomic_read(&stor_device->ref_count)) - atomic_inc(&stor_device->ref_count); - else + + if (!stor_device) + goto get_in_err; + + /* + * If the device is being destroyed; allow incoming + * traffic only to cleanup outstanding requests. + */ + + if (stor_device->destroy && + (atomic_read(&stor_device->num_outstanding_req) == 0)) stor_device = NULL; +get_in_err: + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); return stor_device; + } static int storvsc_channel_init(struct hv_device *device) @@ -190,7 +199,6 @@ static int storvsc_channel_init(struct hv_device *device) cleanup: - put_stor_device(device); return ret; } @@ -303,7 +311,6 @@ static void storvsc_on_channel_callback(void *context) } } while (1); - put_stor_device(device); return; } @@ -371,7 +378,6 @@ int storvsc_dev_remove(struct hv_device *device) unsigned long flags; stor_device = (struct storvsc_device *)device->ext; - atomic_dec(&stor_device->ref_count); spin_lock_irqsave(&device->channel->inbound_lock, flags); stor_device->destroy = true; @@ -388,9 +394,13 @@ int storvsc_dev_remove(struct hv_device *device) /* * Since we have already drained, we don't need to busy wait * as was done in final_release_stor_device() + * Note that we cannot set the ext pointer to NULL until + * we have drained - to drain the outgoing packets, we need to + * allow incoming packets. */ - atomic_set(&stor_device->ref_count, 0); + spin_lock_irqsave(&device->channel->inbound_lock, flags); device->ext = NULL; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); /* Close the channel */ vmbus_close(device->channel); @@ -448,7 +458,6 @@ int storvsc_do_io(struct hv_device *device, atomic_inc(&stor_device->num_outstanding_req); - put_stor_device(device); return ret; } diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 5b2004fbb4b..ae74f509e6c 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -378,7 +378,6 @@ static int storvsc_host_reset(struct hv_device *device) */ cleanup: - put_stor_device(device); return ret; } From 356c4657193c8a5b3aff84fe8cdf5ddc64742801 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:10 -0700 Subject: [PATCH 0667/1519] Staging: hv: netvsc: Inline the code for free_net_device() Inline the code for free_net_device(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index b6e1fb988d2..75c6ed7b790 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -49,14 +49,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) return net_device; } -static void free_net_device(struct netvsc_device *device) -{ - WARN_ON(atomic_read(&device->refcnt) != 0); - device->dev->ext = NULL; - kfree(device); -} - - /* Get the net device object iff exists and its refcount > 1 */ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) { @@ -438,7 +430,7 @@ int netvsc_device_remove(struct hv_device *device) kfree(netvsc_packet); } - free_net_device(net_device); + kfree(net_device); return 0; } @@ -980,7 +972,7 @@ cleanup: release_outbound_net_device(device); release_inbound_net_device(device); - free_net_device(net_device); + kfree(net_device); } return ret; From 509ee3878b8f0f8908892579d679c123084f5ac5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:11 -0700 Subject: [PATCH 0668/1519] Staging: hv: netvsc: Cleanup alloc_net_device() Cleanup alloc_net_device(); we can directly set the refcnt. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 75c6ed7b790..77221026878 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -41,7 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) return NULL; /* Set to 2 to allow both inbound and outbound traffic */ - atomic_cmpxchg(&net_device->refcnt, 0, 2); + atomic_set(&net_device->refcnt, 2); net_device->dev = device; device->ext = net_device; From c38b9c7118b95aa48bfa38d3bcd241dba3d23c10 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:12 -0700 Subject: [PATCH 0669/1519] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device Introduce state to manage the lifecycle of net device. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_net.h | 1 + drivers/staging/hv/netvsc.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h index 5782fea9a17..0b347c1edc3 100644 --- a/drivers/staging/hv/hyperv_net.h +++ b/drivers/staging/hv/hyperv_net.h @@ -371,6 +371,7 @@ struct netvsc_device { atomic_t refcnt; atomic_t num_outstanding_sends; + bool destroy; /* * List of free preallocated hv_netvsc_packet to represent receive * packet diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 77221026878..8eb4039b5ff 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) /* Set to 2 to allow both inbound and outbound traffic */ atomic_set(&net_device->refcnt, 2); + net_device->destroy = false; net_device->dev = device; device->ext = net_device; @@ -396,6 +397,7 @@ int netvsc_device_remove(struct hv_device *device) { struct netvsc_device *net_device; struct hv_netvsc_packet *netvsc_packet, *pos; + unsigned long flags; /* Stop outbound traffic ie sends and receives completions */ net_device = release_outbound_net_device(device); @@ -404,6 +406,10 @@ int netvsc_device_remove(struct hv_device *device) return -ENODEV; } + spin_lock_irqsave(&device->channel->inbound_lock, flags); + net_device->destroy = true; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); + /* Wait for all send completions */ while (atomic_read(&net_device->num_outstanding_sends)) { dev_err(&device->device, From 2ef7714397cd49dc378e20afa6dd19306e5f2b5e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:13 -0700 Subject: [PATCH 0670/1519] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed Prevent outgoing traffic when netvsc dev is destroyed. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 8eb4039b5ff..67065c182b7 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -56,7 +56,8 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) struct netvsc_device *net_device; net_device = device->ext; - if (net_device && atomic_read(&net_device->refcnt) > 1) + if (net_device && (atomic_read(&net_device->refcnt) > 1) && + !net_device->destroy) atomic_inc(&net_device->refcnt); else net_device = NULL; From 3852409b88e8ec2a8abb28db5be25a7503297208 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:14 -0700 Subject: [PATCH 0671/1519] Staging: hv: netvsc: Get rid of release_outbound_net_device() by inlining the code Get rid of release_outbound_net_device() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 38 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 67065c182b7..e46161d05e6 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -88,22 +88,6 @@ static void put_net_device(struct hv_device *device) atomic_dec(&net_device->refcnt); } -static struct netvsc_device *release_outbound_net_device( - struct hv_device *device) -{ - struct netvsc_device *net_device; - - net_device = device->ext; - if (net_device == NULL) - return NULL; - - /* Busy wait until the ref drop to 2, then set it to 1 */ - while (atomic_cmpxchg(&net_device->refcnt, 2, 1) != 2) - udelay(100); - - return net_device; -} - static struct netvsc_device *release_inbound_net_device( struct hv_device *device) { @@ -400,13 +384,8 @@ int netvsc_device_remove(struct hv_device *device) struct hv_netvsc_packet *netvsc_packet, *pos; unsigned long flags; - /* Stop outbound traffic ie sends and receives completions */ - net_device = release_outbound_net_device(device); - if (!net_device) { - dev_err(&device->device, "No net device present!!"); - return -ENODEV; - } - + net_device = (struct netvsc_device *)device->ext; + atomic_dec(&net_device->refcnt); spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device->destroy = true; spin_unlock_irqrestore(&device->channel->inbound_lock, flags); @@ -424,6 +403,18 @@ int netvsc_device_remove(struct hv_device *device) /* Stop inbound traffic ie receives and sends completions */ net_device = release_inbound_net_device(device); + /* + * Wait until the ref cnt falls to 0. + * We have already stopped any new references + * for outgoing traffic. Also, at this point we don't have any + * incoming traffic as well. So this must be outgoing refrences + * established prior to marking the device as being destroyed. + * Since the send path is non-blocking, it is reasonable to busy + * wait here. + */ + while (atomic_read(&net_device->refcnt)) + udelay(100); + /* At this point, no one should be accessing netDevice except in here */ dev_notice(&device->device, "net device safe to remove"); @@ -976,7 +967,6 @@ cleanup: kfree(packet); } - release_outbound_net_device(device); release_inbound_net_device(device); kfree(net_device); From 124f506dc1bbfc79c32dd17566f09ef51f7cf863 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:15 -0700 Subject: [PATCH 0672/1519] Staging: hv: netvsc: Get rid of release_inbound_net_device() by inlining the code Get rid of release_inbound_net_device() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index e46161d05e6..388f08380d4 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -88,23 +88,6 @@ static void put_net_device(struct hv_device *device) atomic_dec(&net_device->refcnt); } -static struct netvsc_device *release_inbound_net_device( - struct hv_device *device) -{ - struct netvsc_device *net_device; - - net_device = device->ext; - if (net_device == NULL) - return NULL; - - /* Busy wait until the ref drop to 1, then set it to 0 */ - while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1) - udelay(100); - - device->ext = NULL; - return net_device; -} - static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) { struct nvsp_message *revoke_packet; @@ -400,9 +383,8 @@ int netvsc_device_remove(struct hv_device *device) netvsc_disconnect_vsp(net_device); - /* Stop inbound traffic ie receives and sends completions */ - net_device = release_inbound_net_device(device); - + atomic_dec(&net_device->refcnt); + device->ext = NULL; /* * Wait until the ref cnt falls to 0. * We have already stopped any new references @@ -967,8 +949,6 @@ cleanup: kfree(packet); } - release_inbound_net_device(device); - kfree(net_device); } From 9d88f33a1530f4241227226e7479d36ac959e9ce Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:16 -0700 Subject: [PATCH 0673/1519] Staging: hv: netvsc: Get rid of the refcnt field in struct netvsc_device Get rid of the refcnt field in struct netvsc_device. We implement the following logic to manage the life cycle of the device: If the device is being destroyed, we do not allow any outgoing traffic. Furthermore, if the device is being destroyed, we allow incoming traffic only to drain outgoing traffic. Note that the driver may send some book keeping messages to the host not known to upper level Linux code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_net.h | 1 - drivers/staging/hv/netvsc.c | 62 +++++++++++---------------------- 2 files changed, 20 insertions(+), 43 deletions(-) diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h index 0b347c1edc3..af8a37fb502 100644 --- a/drivers/staging/hv/hyperv_net.h +++ b/drivers/staging/hv/hyperv_net.h @@ -369,7 +369,6 @@ struct nvsp_message { struct netvsc_device { struct hv_device *dev; - atomic_t refcnt; atomic_t num_outstanding_sends; bool destroy; /* diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 388f08380d4..9828f0b5960 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -40,8 +40,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) if (!net_device) return NULL; - /* Set to 2 to allow both inbound and outbound traffic */ - atomic_set(&net_device->refcnt, 2); net_device->destroy = false; net_device->dev = device; @@ -50,43 +48,37 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) return net_device; } -/* Get the net device object iff exists and its refcount > 1 */ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) { struct netvsc_device *net_device; net_device = device->ext; - if (net_device && (atomic_read(&net_device->refcnt) > 1) && - !net_device->destroy) - atomic_inc(&net_device->refcnt); - else + if (net_device && net_device->destroy) net_device = NULL; return net_device; } -/* Get the net device object iff exists and its refcount > 0 */ static struct netvsc_device *get_inbound_net_device(struct hv_device *device) { struct netvsc_device *net_device; + unsigned long flags; + spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device = device->ext; - if (net_device && atomic_read(&net_device->refcnt)) - atomic_inc(&net_device->refcnt); - else + + if (!net_device) + goto get_in_err; + + if (net_device->destroy && + atomic_read(&net_device->num_outstanding_sends) == 0) net_device = NULL; +get_in_err: + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); return net_device; } -static void put_net_device(struct hv_device *device) -{ - struct netvsc_device *net_device; - - net_device = device->ext; - - atomic_dec(&net_device->refcnt); -} static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) { @@ -268,7 +260,6 @@ cleanup: netvsc_destroy_recv_buf(net_device); exit: - put_net_device(device); return ret; } @@ -349,7 +340,6 @@ static int netvsc_connect_vsp(struct hv_device *device) ret = netvsc_init_recv_buf(device); cleanup: - put_net_device(device); return ret; } @@ -368,7 +358,6 @@ int netvsc_device_remove(struct hv_device *device) unsigned long flags; net_device = (struct netvsc_device *)device->ext; - atomic_dec(&net_device->refcnt); spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device->destroy = true; spin_unlock_irqrestore(&device->channel->inbound_lock, flags); @@ -383,19 +372,17 @@ int netvsc_device_remove(struct hv_device *device) netvsc_disconnect_vsp(net_device); - atomic_dec(&net_device->refcnt); - device->ext = NULL; /* - * Wait until the ref cnt falls to 0. - * We have already stopped any new references - * for outgoing traffic. Also, at this point we don't have any - * incoming traffic as well. So this must be outgoing refrences - * established prior to marking the device as being destroyed. - * Since the send path is non-blocking, it is reasonable to busy - * wait here. + * Since we have already drained, we don't need to busy wait + * as was done in final_release_stor_device() + * Note that we cannot set the ext pointer to NULL until + * we have drained - to drain the outgoing packets, we need to + * allow incoming packets. */ - while (atomic_read(&net_device->refcnt)) - udelay(100); + + spin_lock_irqsave(&device->channel->inbound_lock, flags); + device->ext = NULL; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); /* At this point, no one should be accessing netDevice except in here */ dev_notice(&device->device, "net device safe to remove"); @@ -456,7 +443,6 @@ static void netvsc_send_completion(struct hv_device *device, "%d received!!", nvsp_packet->hdr.msg_type); } - put_net_device(device); } int netvsc_send(struct hv_device *device, @@ -509,7 +495,6 @@ int netvsc_send(struct hv_device *device, packet, ret); atomic_inc(&net_device->num_outstanding_sends); - put_net_device(device); return ret; } @@ -602,7 +587,6 @@ static void netvsc_receive_completion(void *context) if (fsend_receive_comp) netvsc_send_recv_completion(device, transaction_id); - put_net_device(device); } static void netvsc_receive(struct hv_device *device, @@ -636,7 +620,6 @@ static void netvsc_receive(struct hv_device *device, if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) { dev_err(&device->device, "Unknown packet type received - %d", packet->type); - put_net_device(device); return; } @@ -648,7 +631,6 @@ static void netvsc_receive(struct hv_device *device, NVSP_MSG1_TYPE_SEND_RNDIS_PKT) { dev_err(&device->device, "Unknown nvsp packet type received-" " %d", nvsp_packet->hdr.msg_type); - put_net_device(device); return; } @@ -658,7 +640,6 @@ static void netvsc_receive(struct hv_device *device, dev_err(&device->device, "Invalid xfer page set id - " "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID, vmxferpage_packet->xfer_pageset_id); - put_net_device(device); return; } @@ -698,7 +679,6 @@ static void netvsc_receive(struct hv_device *device, netvsc_send_recv_completion(device, vmxferpage_packet->d.trans_id); - put_net_device(device); return; } @@ -786,7 +766,6 @@ static void netvsc_receive(struct hv_device *device, completion.recv.recv_completion_ctx); } - put_net_device(device); } static void netvsc_channel_cb(void *context) @@ -869,7 +848,6 @@ static void netvsc_channel_cb(void *context) } } while (1); - put_net_device(device); out: kfree(buffer); return; From bd1f5d6a0098debce610dc23729ebff691a5c3f5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:17 -0700 Subject: [PATCH 0674/1519] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver Add code to handle IDE devices using the storvsc driver. The storvsc_probe() is modified so that the storvsc driver can surface all disks presented to the guest as scsi devices using generic upper level Linux scsi drivers. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 60 +++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index ae74f509e6c..f43420056f8 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -59,6 +59,17 @@ struct storvsc_cmd_request { struct hv_storvsc_request request; }; +static void storvsc_get_ide_info(struct hv_device *dev, int *target, int *path) +{ + *target = + dev->dev_instance.b[5] << 8 | dev->dev_instance.b[4]; + + *path = + dev->dev_instance.b[3] << 24 | + dev->dev_instance.b[2] << 16 | + dev->dev_instance.b[1] << 8 | dev->dev_instance.b[0]; +} + static int storvsc_device_alloc(struct scsi_device *sdevice) { @@ -642,6 +653,20 @@ static const struct hv_vmbus_device_id id_table[] = { }; MODULE_DEVICE_TABLE(vmbus, id_table); + +/* + * This declaration is temporary; once we get the + * infrastructure in place, we will integrate with + * id_table. + */ + +static const uuid_le ide_blk_guid = { + .b = { + 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, + 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 + } +}; + /* * storvsc_probe - Add a new device for this driver */ @@ -652,6 +677,14 @@ static int storvsc_probe(struct hv_device *device) struct Scsi_Host *host; struct hv_host_device *host_dev; struct storvsc_device_info device_info; + bool dev_is_ide; + int path = 0; + int target = 0; + + if (!uuid_le_cmp(device->dev_type, ide_blk_guid)) + dev_is_ide = true; + else + dev_is_ide = false; host = scsi_host_alloc(&scsi_driver, sizeof(struct hv_host_device)); @@ -687,6 +720,9 @@ static int storvsc_probe(struct hv_device *device) return -ENODEV; } + if (dev_is_ide) + storvsc_get_ide_info(device, &target, &path); + host_dev->path = device_info.path_id; host_dev->target = device_info.target_id; @@ -699,17 +735,25 @@ static int storvsc_probe(struct hv_device *device) /* Register the HBA and start the scsi bus scan */ ret = scsi_add_host(host, &device->device); - if (ret != 0) { + if (ret != 0) + goto err_out; - storvsc_dev_remove(device); - - kmem_cache_destroy(host_dev->request_pool); - scsi_host_put(host); - return -ENODEV; + if (!dev_is_ide) { + scsi_scan_host(host); + return 0; } + ret = scsi_add_device(host, 0, target, 0); + if (ret) { + scsi_remove_host(host); + goto err_out; + } + return 0; - scsi_scan_host(host); - return ret; +err_out: + storvsc_dev_remove(device); + kmem_cache_destroy(host_dev->request_pool); + scsi_host_put(host); + return -ENODEV; } /* The one and only one */ From 21e37742361fe408d534c004b6e39717cb6b5999 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:18 -0700 Subject: [PATCH 0675/1519] Staging: hv: storvsc: Handle IDE devices using the storvsc driver Now, enable handling of all IDE devices by extending the storvsc device id table to handle IDE guid. As part of this cleanup Kconfig and Hyper-V Makefile to not build the IDE driver (blkvsc). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/Kconfig | 7 ------- drivers/staging/hv/Makefile | 2 -- drivers/staging/hv/storvsc_drv.c | 21 ++++++++------------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig index 5e0c9f6c745..26b5064bf63 100644 --- a/drivers/staging/hv/Kconfig +++ b/drivers/staging/hv/Kconfig @@ -15,13 +15,6 @@ config HYPERV_STORAGE help Select this option to enable the Hyper-V virtual storage driver. -config HYPERV_BLOCK - tristate "Microsoft Hyper-V virtual block driver" - depends on BLOCK && SCSI && (LBDAF || 64BIT) - default HYPERV - help - Select this option to enable the Hyper-V virtual block driver. - config HYPERV_NET tristate "Microsoft Hyper-V virtual network driver" depends on NET diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile index 30046743a0b..bb89437d0e7 100644 --- a/drivers/staging/hv/Makefile +++ b/drivers/staging/hv/Makefile @@ -1,6 +1,5 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o hv_timesource.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o -obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o obj-$(CONFIG_HYPERV_MOUSE) += hv_mouse.o @@ -9,6 +8,5 @@ hv_vmbus-y := vmbus_drv.o \ hv.o connection.o channel.o \ channel_mgmt.o ring_buffer.o hv_storvsc-y := storvsc_drv.o storvsc.o -hv_blkvsc-y := blkvsc_drv.o storvsc.o hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o hv_utils-y := hv_util.o hv_kvp.o diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index f43420056f8..9464f99bf7a 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -645,27 +645,22 @@ static struct scsi_host_template scsi_driver = { .dma_boundary = PAGE_SIZE-1, }; +/* + * The storvsc_probe function assumes that the IDE guid + * is the second entry. + */ static const struct hv_vmbus_device_id id_table[] = { /* SCSI guid */ { VMBUS_DEVICE(0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) }, + /* IDE guid */ + { VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, + 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) }, { }, }; MODULE_DEVICE_TABLE(vmbus, id_table); -/* - * This declaration is temporary; once we get the - * infrastructure in place, we will integrate with - * id_table. - */ - -static const uuid_le ide_blk_guid = { - .b = { - 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 - } -}; /* * storvsc_probe - Add a new device for this driver @@ -681,7 +676,7 @@ static int storvsc_probe(struct hv_device *device) int path = 0; int target = 0; - if (!uuid_le_cmp(device->dev_type, ide_blk_guid)) + if (!memcmp(&device->dev_type.b, id_table[1].guid, sizeof(uuid_le))) dev_is_ide = true; else dev_is_ide = false; From b38cc43432d7b7b0a4dc0a13d261a85944fc7c65 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:19 -0700 Subject: [PATCH 0676/1519] Staging: hv: blkvsc: Get rid of blkvsc_drv.c as this code is not used Now that blkvsc driver is no longer needed, remove blkvsc_drv.c Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 1014 ------------------------------- 1 file changed, 1014 deletions(-) delete mode 100644 drivers/staging/hv/blkvsc_drv.c diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c deleted file mode 100644 index 2b41eb677b2..00000000000 --- a/drivers/staging/hv/blkvsc_drv.c +++ /dev/null @@ -1,1014 +0,0 @@ -/* - * Copyright (c) 2009, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang - * Hank Janssen - * K. Y. Srinivasan - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hyperv.h" -#include "hyperv_storage.h" - - -#define BLKVSC_MINORS 64 - -enum blkvsc_device_type { - UNKNOWN_DEV_TYPE, - HARDDISK_TYPE, - DVD_TYPE, -}; - -enum blkvsc_op_type { - DO_INQUIRY, - DO_CAPACITY, - DO_FLUSH, -}; - -/* - * This request ties the struct request and struct - * blkvsc_request/hv_storvsc_request together A struct request may be - * represented by 1 or more struct blkvsc_request - */ -struct blkvsc_request_group { - int outstanding; - int status; - struct list_head blkvsc_req_list; /* list of blkvsc_requests */ -}; - -struct blkvsc_request { - /* blkvsc_request_group.blkvsc_req_list */ - struct list_head req_entry; - - /* block_device_context.pending_list */ - struct list_head pend_entry; - - /* This may be null if we generate a request internally */ - struct request *req; - - struct block_device_context *dev; - - /* The group this request is part of. Maybe null */ - struct blkvsc_request_group *group; - - int write; - sector_t sector_start; - unsigned long sector_count; - - unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE]; - unsigned char cmd_len; - unsigned char cmnd[MAX_COMMAND_SIZE]; - - struct hv_storvsc_request request; -}; - -/* Per device structure */ -struct block_device_context { - /* point back to our device context */ - struct hv_device *device_ctx; - struct kmem_cache *request_pool; - spinlock_t lock; - struct gendisk *gd; - enum blkvsc_device_type device_type; - struct list_head pending_list; - - unsigned char device_id[64]; - unsigned int device_id_len; - int num_outstanding_reqs; - int shutting_down; - unsigned int sector_size; - sector_t capacity; - unsigned int port; - unsigned char path; - unsigned char target; - int users; -}; - - -/* - * There is a circular dependency involving blkvsc_request_completion() - * and blkvsc_do_request(). - */ -static void blkvsc_request_completion(struct hv_storvsc_request *request); - -static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE; - -module_param(blkvsc_ringbuffer_size, int, S_IRUGO); -MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)"); - -/* - * There is a circular dependency involving blkvsc_probe() - * and block_ops. - */ -static int blkvsc_probe(struct hv_device *dev); - -static int blkvsc_device_add(struct hv_device *device, - void *additional_info) -{ - struct storvsc_device_info *device_info; - int ret = 0; - - device_info = (struct storvsc_device_info *)additional_info; - - device_info->ring_buffer_size = blkvsc_ringbuffer_size; - - ret = storvsc_dev_add(device, additional_info); - if (ret != 0) - return ret; - - /* - * We need to use the device instance guid to set the path and target - * id. For IDE devices, the device instance id is formatted as - * * - - 8899 - 000000000000. - */ - device_info->path_id = device->dev_instance.b[3] << 24 | - device->dev_instance.b[2] << 16 | - device->dev_instance.b[1] << 8 | - device->dev_instance.b[0]; - - device_info->target_id = device->dev_instance.b[5] << 8 | - device->dev_instance.b[4]; - - return ret; -} - -static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, - void (*request_completion)(struct hv_storvsc_request *)) -{ - struct block_device_context *blkdev = blkvsc_req->dev; - struct hv_storvsc_request *storvsc_req; - struct vmscsi_request *vm_srb; - int ret; - - - storvsc_req = &blkvsc_req->request; - vm_srb = &storvsc_req->vstor_packet.vm_srb; - - vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; - - storvsc_req->on_io_completion = request_completion; - storvsc_req->context = blkvsc_req; - - vm_srb->port_number = blkdev->port; - vm_srb->path_id = blkdev->path; - vm_srb->target_id = blkdev->target; - vm_srb->lun = 0; /* this is not really used at all */ - - vm_srb->cdb_length = blkvsc_req->cmd_len; - - memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length); - - storvsc_req->sense_buffer = blkvsc_req->sense_buffer; - - ret = storvsc_do_io(blkdev->device_ctx, - &blkvsc_req->request); - if (ret == 0) - blkdev->num_outstanding_reqs++; - - return ret; -} - - -static int blkvsc_open(struct block_device *bdev, fmode_t mode) -{ - struct block_device_context *blkdev = bdev->bd_disk->private_data; - unsigned long flags; - - spin_lock_irqsave(&blkdev->lock, flags); - - blkdev->users++; - - spin_unlock_irqrestore(&blkdev->lock, flags); - - return 0; -} - - -static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg) -{ - sector_t nsect = get_capacity(bd->bd_disk); - sector_t cylinders = nsect; - - /* - * We are making up these values; let us keep it simple. - */ - hg->heads = 0xff; - hg->sectors = 0x3f; - sector_div(cylinders, hg->heads * hg->sectors); - hg->cylinders = cylinders; - if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect) - hg->cylinders = 0xffff; - return 0; - -} - - -static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req) -{ - - blkvsc_req->cmd_len = 16; - - if (rq_data_dir(blkvsc_req->req)) { - blkvsc_req->write = 1; - blkvsc_req->cmnd[0] = WRITE_16; - } else { - blkvsc_req->write = 0; - blkvsc_req->cmnd[0] = READ_16; - } - - blkvsc_req->cmnd[1] |= - (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; - - *(unsigned long long *)&blkvsc_req->cmnd[2] = - cpu_to_be64(blkvsc_req->sector_start); - *(unsigned int *)&blkvsc_req->cmnd[10] = - cpu_to_be32(blkvsc_req->sector_count); -} - - -static int blkvsc_ioctl(struct block_device *bd, fmode_t mode, - unsigned cmd, unsigned long arg) -{ - struct block_device_context *blkdev = bd->bd_disk->private_data; - int ret = 0; - - switch (cmd) { - case HDIO_GET_IDENTITY: - if (copy_to_user((void __user *)arg, blkdev->device_id, - blkdev->device_id_len)) - ret = -EFAULT; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static void blkvsc_cmd_completion(struct hv_storvsc_request *request) -{ - struct blkvsc_request *blkvsc_req = - (struct blkvsc_request *)request->context; - struct block_device_context *blkdev = - (struct block_device_context *)blkvsc_req->dev; - struct scsi_sense_hdr sense_hdr; - struct vmscsi_request *vm_srb; - unsigned long flags; - - - vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; - - spin_lock_irqsave(&blkdev->lock, flags); - blkdev->num_outstanding_reqs--; - spin_unlock_irqrestore(&blkdev->lock, flags); - - if (vm_srb->scsi_status) - if (scsi_normalize_sense(blkvsc_req->sense_buffer, - SCSI_SENSE_BUFFERSIZE, &sense_hdr)) - scsi_print_sense_hdr("blkvsc", &sense_hdr); - - complete(&blkvsc_req->request.wait_event); -} - - -static int blkvsc_do_operation(struct block_device_context *blkdev, - enum blkvsc_op_type op) -{ - struct blkvsc_request *blkvsc_req; - struct page *page_buf; - unsigned char *buf; - unsigned char device_type; - struct scsi_sense_hdr sense_hdr; - struct vmscsi_request *vm_srb; - unsigned long flags; - - int ret = 0; - - blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL); - if (!blkvsc_req) - return -ENOMEM; - - page_buf = alloc_page(GFP_KERNEL); - if (!page_buf) { - kmem_cache_free(blkdev->request_pool, blkvsc_req); - return -ENOMEM; - } - - vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; - init_completion(&blkvsc_req->request.wait_event); - blkvsc_req->dev = blkdev; - blkvsc_req->req = NULL; - blkvsc_req->write = 0; - - blkvsc_req->request.data_buffer.pfn_array[0] = - page_to_pfn(page_buf); - blkvsc_req->request.data_buffer.offset = 0; - - switch (op) { - case DO_INQUIRY: - blkvsc_req->cmnd[0] = INQUIRY; - blkvsc_req->cmnd[1] = 0x1; /* Get product data */ - blkvsc_req->cmnd[2] = 0x83; /* mode page 83 */ - blkvsc_req->cmnd[4] = 64; - blkvsc_req->cmd_len = 6; - blkvsc_req->request.data_buffer.len = 64; - break; - - case DO_CAPACITY: - blkdev->sector_size = 0; - blkdev->capacity = 0; - - blkvsc_req->cmnd[0] = READ_CAPACITY; - blkvsc_req->cmd_len = 16; - blkvsc_req->request.data_buffer.len = 8; - break; - - case DO_FLUSH: - blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE; - blkvsc_req->cmd_len = 10; - blkvsc_req->request.data_buffer.pfn_array[0] = 0; - blkvsc_req->request.data_buffer.len = 0; - break; - default: - ret = -EINVAL; - goto cleanup; - } - - spin_lock_irqsave(&blkdev->lock, flags); - blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion); - spin_unlock_irqrestore(&blkdev->lock, flags); - - wait_for_completion_interruptible(&blkvsc_req->request.wait_event); - - /* check error */ - if (vm_srb->scsi_status) { - scsi_normalize_sense(blkvsc_req->sense_buffer, - SCSI_SENSE_BUFFERSIZE, &sense_hdr); - - return 0; - } - - buf = kmap(page_buf); - - switch (op) { - case DO_INQUIRY: - device_type = buf[0] & 0x1F; - - if (device_type == 0x0) - blkdev->device_type = HARDDISK_TYPE; - else - blkdev->device_type = UNKNOWN_DEV_TYPE; - - blkdev->device_id_len = buf[7]; - if (blkdev->device_id_len > 64) - blkdev->device_id_len = 64; - - memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len); - break; - - case DO_CAPACITY: - /* be to le */ - blkdev->capacity = - ((buf[0] << 24) | (buf[1] << 16) | - (buf[2] << 8) | buf[3]) + 1; - - blkdev->sector_size = - (buf[4] << 24) | (buf[5] << 16) | - (buf[6] << 8) | buf[7]; - break; - default: - break; - - } - -cleanup: - - kunmap(page_buf); - - __free_page(page_buf); - - kmem_cache_free(blkdev->request_pool, blkvsc_req); - - return ret; -} - - -static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) -{ - struct blkvsc_request *pend_req, *tmp; - struct blkvsc_request *comp_req, *tmp2; - struct vmscsi_request *vm_srb; - - int ret = 0; - - - /* Flush the pending list first */ - list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list, - pend_entry) { - /* - * The pend_req could be part of a partially completed - * request. If so, complete those req first until we - * hit the pend_req - */ - list_for_each_entry_safe(comp_req, tmp2, - &pend_req->group->blkvsc_req_list, - req_entry) { - - if (comp_req == pend_req) - break; - - list_del(&comp_req->req_entry); - - if (comp_req->req) { - vm_srb = - &comp_req->request.vstor_packet. - vm_srb; - ret = __blk_end_request(comp_req->req, - (!vm_srb->scsi_status ? 0 : -EIO), - comp_req->sector_count * - blkdev->sector_size); - - /* FIXME: shouldn't this do more than return? */ - if (ret) - goto out; - } - - kmem_cache_free(blkdev->request_pool, comp_req); - } - - list_del(&pend_req->pend_entry); - - list_del(&pend_req->req_entry); - - if (comp_req->req) { - if (!__blk_end_request(pend_req->req, -EIO, - pend_req->sector_count * - blkdev->sector_size)) { - /* - * All the sectors have been xferred ie the - * request is done - */ - kmem_cache_free(blkdev->request_pool, - pend_req->group); - } - } - - kmem_cache_free(blkdev->request_pool, pend_req); - } - -out: - return ret; -} - - -/* - * blkvsc_remove() - Callback when our device is removed - */ -static int blkvsc_remove(struct hv_device *dev) -{ - struct block_device_context *blkdev = dev_get_drvdata(&dev->device); - unsigned long flags; - - - /* Get to a known state */ - spin_lock_irqsave(&blkdev->lock, flags); - - blkdev->shutting_down = 1; - - blk_stop_queue(blkdev->gd->queue); - - blkvsc_cancel_pending_reqs(blkdev); - - spin_unlock_irqrestore(&blkdev->lock, flags); - - blkvsc_do_operation(blkdev, DO_FLUSH); - - if (blkdev->users == 0) { - del_gendisk(blkdev->gd); - put_disk(blkdev->gd); - blk_cleanup_queue(blkdev->gd->queue); - - storvsc_dev_remove(blkdev->device_ctx); - - kmem_cache_destroy(blkdev->request_pool); - kfree(blkdev); - } - - return 0; -} - -static void blkvsc_shutdown(struct hv_device *dev) -{ - struct block_device_context *blkdev = dev_get_drvdata(&dev->device); - unsigned long flags; - - if (!blkdev) - return; - - spin_lock_irqsave(&blkdev->lock, flags); - - blkdev->shutting_down = 1; - - blk_stop_queue(blkdev->gd->queue); - - blkvsc_cancel_pending_reqs(blkdev); - - spin_unlock_irqrestore(&blkdev->lock, flags); - - blkvsc_do_operation(blkdev, DO_FLUSH); - - /* - * Now wait for all outgoing I/O to be drained. - */ - storvsc_wait_to_drain((struct storvsc_device *)dev->ext); - -} - -static int blkvsc_release(struct gendisk *disk, fmode_t mode) -{ - struct block_device_context *blkdev = disk->private_data; - unsigned long flags; - - spin_lock_irqsave(&blkdev->lock, flags); - - if ((--blkdev->users == 0) && (blkdev->shutting_down)) { - blk_stop_queue(blkdev->gd->queue); - spin_unlock_irqrestore(&blkdev->lock, flags); - - blkvsc_do_operation(blkdev, DO_FLUSH); - del_gendisk(blkdev->gd); - put_disk(blkdev->gd); - blk_cleanup_queue(blkdev->gd->queue); - - storvsc_dev_remove(blkdev->device_ctx); - - kmem_cache_destroy(blkdev->request_pool); - kfree(blkdev); - } else - spin_unlock_irqrestore(&blkdev->lock, flags); - - return 0; -} - - -/* - * We break the request into 1 or more blkvsc_requests and submit - * them. If we cant submit them all, we put them on the - * pending_list. The blkvsc_request() will work on the pending_list. - */ -static int blkvsc_do_request(struct block_device_context *blkdev, - struct request *req) -{ - struct bio *bio = NULL; - struct bio_vec *bvec = NULL; - struct bio_vec *prev_bvec = NULL; - struct blkvsc_request *blkvsc_req = NULL; - struct blkvsc_request *tmp; - int databuf_idx = 0; - int seg_idx = 0; - sector_t start_sector; - unsigned long num_sectors = 0; - int ret = 0; - int pending = 0; - struct blkvsc_request_group *group = NULL; - - /* Create a group to tie req to list of blkvsc_reqs */ - group = kmem_cache_zalloc(blkdev->request_pool, GFP_ATOMIC); - if (!group) - return -ENOMEM; - - INIT_LIST_HEAD(&group->blkvsc_req_list); - group->outstanding = group->status = 0; - - start_sector = blk_rq_pos(req); - - /* foreach bio in the request */ - if (req->bio) { - for (bio = req->bio; bio; bio = bio->bi_next) { - /* - * Map this bio into an existing or new storvsc request - */ - bio_for_each_segment(bvec, bio, seg_idx) { - /* Get a new storvsc request */ - /* 1st-time */ - if ((!blkvsc_req) || - (databuf_idx >= MAX_MULTIPAGE_BUFFER_COUNT) - /* hole at the begin of page */ - || (bvec->bv_offset != 0) || - /* hold at the end of page */ - (prev_bvec && - (prev_bvec->bv_len != PAGE_SIZE))) { - /* submit the prev one */ - if (blkvsc_req) { - blkvsc_req->sector_start = - start_sector; - sector_div( - blkvsc_req->sector_start, - (blkdev->sector_size >> 9)); - - blkvsc_req->sector_count = - num_sectors / - (blkdev->sector_size >> 9); - blkvsc_init_rw(blkvsc_req); - } - - /* - * Create new blkvsc_req to represent - * the current bvec - */ - blkvsc_req = - kmem_cache_zalloc( - blkdev->request_pool, GFP_ATOMIC); - if (!blkvsc_req) { - /* free up everything */ - list_for_each_entry_safe( - blkvsc_req, tmp, - &group->blkvsc_req_list, - req_entry) { - list_del( - &blkvsc_req->req_entry); - kmem_cache_free( - blkdev->request_pool, - blkvsc_req); - } - - kmem_cache_free( - blkdev->request_pool, group); - return -ENOMEM; - } - - memset(blkvsc_req, 0, - sizeof(struct blkvsc_request)); - - blkvsc_req->dev = blkdev; - blkvsc_req->req = req; - blkvsc_req->request. - data_buffer.offset - = bvec->bv_offset; - blkvsc_req->request. - data_buffer.len = 0; - - /* Add to the group */ - blkvsc_req->group = group; - blkvsc_req->group->outstanding++; - list_add_tail(&blkvsc_req->req_entry, - &blkvsc_req->group->blkvsc_req_list); - - start_sector += num_sectors; - num_sectors = 0; - databuf_idx = 0; - } - - /* - * Add the curr bvec/segment to the curr - * blkvsc_req - */ - blkvsc_req->request.data_buffer. - pfn_array[databuf_idx] - = page_to_pfn(bvec->bv_page); - blkvsc_req->request.data_buffer.len - += bvec->bv_len; - - prev_bvec = bvec; - - databuf_idx++; - num_sectors += bvec->bv_len >> 9; - - } /* bio_for_each_segment */ - - } /* rq_for_each_bio */ - } - - /* Handle the last one */ - if (blkvsc_req) { - blkvsc_req->sector_start = start_sector; - sector_div(blkvsc_req->sector_start, - (blkdev->sector_size >> 9)); - - blkvsc_req->sector_count = num_sectors / - (blkdev->sector_size >> 9); - - blkvsc_init_rw(blkvsc_req); - } - - list_for_each_entry(blkvsc_req, &group->blkvsc_req_list, req_entry) { - if (pending) { - - list_add_tail(&blkvsc_req->pend_entry, - &blkdev->pending_list); - } else { - ret = blkvsc_submit_request(blkvsc_req, - blkvsc_request_completion); - if (ret == -EAGAIN) { - pending = 1; - list_add_tail(&blkvsc_req->pend_entry, - &blkdev->pending_list); - } - - } - } - - return pending; -} - -static int blkvsc_do_pending_reqs(struct block_device_context *blkdev) -{ - struct blkvsc_request *pend_req, *tmp; - int ret = 0; - - /* Flush the pending list first */ - list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list, - pend_entry) { - - ret = blkvsc_submit_request(pend_req, - blkvsc_request_completion); - if (ret != 0) - break; - else - list_del(&pend_req->pend_entry); - } - - return ret; -} - - -static void blkvsc_request(struct request_queue *queue) -{ - struct block_device_context *blkdev = NULL; - struct request *req; - int ret = 0; - - while ((req = blk_peek_request(queue)) != NULL) { - - blkdev = req->rq_disk->private_data; - if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS) { - __blk_end_request_cur(req, 0); - continue; - } - - ret = blkvsc_do_pending_reqs(blkdev); - - if (ret != 0) { - blk_stop_queue(queue); - break; - } - - blk_start_request(req); - - ret = blkvsc_do_request(blkdev, req); - if (ret > 0) { - blk_stop_queue(queue); - break; - } else if (ret < 0) { - blk_requeue_request(queue, req); - blk_stop_queue(queue); - break; - } - } -} - -static const struct hv_vmbus_device_id id_table[] = { - /* IDE guid */ - { VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) }, - { }, -}; - -MODULE_DEVICE_TABLE(vmbus, id_table); - -/* The one and only one */ -static struct hv_driver blkvsc_drv = { - .name = "blkvsc", - .id_table = id_table, - .probe = blkvsc_probe, - .remove = blkvsc_remove, - .shutdown = blkvsc_shutdown, -}; - -static const struct block_device_operations block_ops = { - .owner = THIS_MODULE, - .open = blkvsc_open, - .release = blkvsc_release, - .getgeo = blkvsc_getgeo, - .ioctl = blkvsc_ioctl, -}; - -/* - * blkvsc_drv_init - BlkVsc driver initialization. - */ -static int blkvsc_drv_init(void) -{ - BUILD_BUG_ON(sizeof(sector_t) != 8); - return vmbus_driver_register(&blkvsc_drv); -} - -static void blkvsc_drv_exit(void) -{ - vmbus_driver_unregister(&blkvsc_drv); -} - -/* - * blkvsc_probe - Add a new device for this driver - */ -static int blkvsc_probe(struct hv_device *dev) -{ - struct block_device_context *blkdev = NULL; - struct storvsc_device_info device_info; - struct storvsc_major_info major_info; - int ret = 0; - - blkdev = kzalloc(sizeof(struct block_device_context), GFP_KERNEL); - if (!blkdev) { - ret = -ENOMEM; - goto cleanup; - } - - INIT_LIST_HEAD(&blkdev->pending_list); - - /* Initialize what we can here */ - spin_lock_init(&blkdev->lock); - - - blkdev->request_pool = kmem_cache_create(dev_name(&dev->device), - sizeof(struct blkvsc_request), 0, - SLAB_HWCACHE_ALIGN, NULL); - if (!blkdev->request_pool) { - ret = -ENOMEM; - goto cleanup; - } - - - ret = blkvsc_device_add(dev, &device_info); - if (ret != 0) - goto cleanup; - - blkdev->device_ctx = dev; - /* this identified the device 0 or 1 */ - blkdev->target = device_info.target_id; - /* this identified the ide ctrl 0 or 1 */ - blkdev->path = device_info.path_id; - - dev_set_drvdata(&dev->device, blkdev); - - ret = storvsc_get_major_info(&device_info, &major_info); - - if (ret) - goto cleanup; - - if (major_info.do_register) { - ret = register_blkdev(major_info.major, major_info.devname); - - if (ret != 0) { - DPRINT_ERR(BLKVSC_DRV, - "register_blkdev() failed! ret %d", ret); - goto remove; - } - } - - DPRINT_INFO(BLKVSC_DRV, "blkvsc registered for major %d!!", - major_info.major); - - blkdev->gd = alloc_disk(BLKVSC_MINORS); - if (!blkdev->gd) { - ret = -1; - goto cleanup; - } - - blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock); - - blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE); - blk_queue_max_segments(blkdev->gd->queue, MAX_MULTIPAGE_BUFFER_COUNT); - blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1); - blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY); - blk_queue_dma_alignment(blkdev->gd->queue, 511); - - blkdev->gd->major = major_info.major; - if (major_info.index == 1 || major_info.index == 3) - blkdev->gd->first_minor = BLKVSC_MINORS; - else - blkdev->gd->first_minor = 0; - blkdev->gd->fops = &block_ops; - blkdev->gd->private_data = blkdev; - blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device); - sprintf(blkdev->gd->disk_name, "hd%c", 'a' + major_info.index); - - blkvsc_do_operation(blkdev, DO_INQUIRY); - blkvsc_do_operation(blkdev, DO_CAPACITY); - - set_capacity(blkdev->gd, blkdev->capacity * (blkdev->sector_size/512)); - blk_queue_logical_block_size(blkdev->gd->queue, blkdev->sector_size); - /* go! */ - add_disk(blkdev->gd); - - DPRINT_INFO(BLKVSC_DRV, "%s added!! capacity %lu sector_size %d", - blkdev->gd->disk_name, (unsigned long)blkdev->capacity, - blkdev->sector_size); - - return ret; - -remove: - storvsc_dev_remove(dev); - -cleanup: - if (blkdev) { - if (blkdev->request_pool) { - kmem_cache_destroy(blkdev->request_pool); - blkdev->request_pool = NULL; - } - kfree(blkdev); - blkdev = NULL; - } - - return ret; -} - -static void blkvsc_request_completion(struct hv_storvsc_request *request) -{ - struct blkvsc_request *blkvsc_req = - (struct blkvsc_request *)request->context; - struct block_device_context *blkdev = - (struct block_device_context *)blkvsc_req->dev; - unsigned long flags; - struct blkvsc_request *comp_req, *tmp; - struct vmscsi_request *vm_srb; - - - spin_lock_irqsave(&blkdev->lock, flags); - - blkdev->num_outstanding_reqs--; - blkvsc_req->group->outstanding--; - - /* - * Only start processing when all the blkvsc_reqs are - * completed. This guarantees no out-of-order blkvsc_req - * completion when calling end_that_request_first() - */ - if (blkvsc_req->group->outstanding == 0) { - list_for_each_entry_safe(comp_req, tmp, - &blkvsc_req->group->blkvsc_req_list, - req_entry) { - - list_del(&comp_req->req_entry); - - vm_srb = - &comp_req->request.vstor_packet.vm_srb; - if (!__blk_end_request(comp_req->req, - (!vm_srb->scsi_status ? 0 : -EIO), - comp_req->sector_count * blkdev->sector_size)) { - /* - * All the sectors have been xferred ie the - * request is done - */ - kmem_cache_free(blkdev->request_pool, - comp_req->group); - } - - kmem_cache_free(blkdev->request_pool, comp_req); - } - - if (!blkdev->shutting_down) { - blkvsc_do_pending_reqs(blkdev); - blk_start_queue(blkdev->gd->queue); - blkvsc_request(blkdev->gd->queue); - } - } - - spin_unlock_irqrestore(&blkdev->lock, flags); -} - -static void __exit blkvsc_exit(void) -{ - blkvsc_drv_exit(); -} - -MODULE_LICENSE("GPL"); -MODULE_VERSION(HV_DRV_VERSION); -MODULE_DESCRIPTION("Microsoft Hyper-V virtual block driver"); -module_init(blkvsc_drv_init); -module_exit(blkvsc_exit); From 3612ef99b05f107d5cd85f6bc45b94ed880d78f3 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:20 -0700 Subject: [PATCH 0677/1519] Staging: hv: storvsc: Optimize bounce buffer handling for the "write" case Optimize bounce buffer handling for the "write" case. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 9464f99bf7a..90b91ade825 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -425,17 +425,17 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) struct scsi_sense_hdr sense_hdr; struct vmscsi_request *vm_srb; + vm_srb = &request->vstor_packet.vm_srb; if (cmd_request->bounce_sgl_count) { - - /* FIXME: We can optimize on writes by just skipping this */ - copy_from_bounce_buffer(scsi_sglist(scmnd), + if (vm_srb->data_in == READ_TYPE) { + copy_from_bounce_buffer(scsi_sglist(scmnd), cmd_request->bounce_sgl, scsi_sg_count(scmnd)); - destroy_bounce_buffer(cmd_request->bounce_sgl, - cmd_request->bounce_sgl_count); + destroy_bounce_buffer(cmd_request->bounce_sgl, + cmd_request->bounce_sgl_count); + } } - vm_srb = &request->vstor_packet.vm_srb; scmnd->result = vm_srb->scsi_status; if (scmnd->result) { From fa23b8c78fefae4e8033a28e685673c35ff10789 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:21 -0700 Subject: [PATCH 0678/1519] Staging: hv: storvsc: Optimize the bounce buffer handling in the "read" case Optimize the bounce buffer handling in the "read" case. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 90b91ade825..3e00e70c945 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -560,12 +560,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) >> PAGE_SHIFT; - /* - * FIXME: We can optimize on reads by just skipping - * this - */ - copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl, - scsi_sg_count(scmnd)); + if (vm_srb->data_in == WRITE_TYPE) + copy_to_bounce_buffer(sgl, + cmd_request->bounce_sgl, + scsi_sg_count(scmnd)); sgl = cmd_request->bounce_sgl; sg_count = cmd_request->bounce_sgl_count; From 8dcf37d446f103d55b96beddb100db6a0ad8d0ba Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:22 -0700 Subject: [PATCH 0679/1519] Staging: hv: storvsc: Include storvsc.c in storvsc_drv.c As part of further cleanup of our storage drivers, include the content of storvsc.c into storvsc_drv.c and delete storvsc.c and do the necessary adjustments. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/Makefile | 2 +- drivers/staging/hv/storvsc.c | 528 ------------------------------ drivers/staging/hv/storvsc_drv.c | 529 +++++++++++++++++++++++++++++++ 3 files changed, 530 insertions(+), 529 deletions(-) delete mode 100644 drivers/staging/hv/storvsc.c diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile index bb89437d0e7..bd176b1f231 100644 --- a/drivers/staging/hv/Makefile +++ b/drivers/staging/hv/Makefile @@ -7,6 +7,6 @@ obj-$(CONFIG_HYPERV_MOUSE) += hv_mouse.o hv_vmbus-y := vmbus_drv.o \ hv.o connection.o channel.o \ channel_mgmt.o ring_buffer.o -hv_storvsc-y := storvsc_drv.o storvsc.o +hv_storvsc-y := storvsc_drv.o hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o hv_utils-y := hv_util.o hv_kvp.o diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c deleted file mode 100644 index fb7b3cae0fe..00000000000 --- a/drivers/staging/hv/storvsc.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (c) 2009, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang - * Hank Janssen - * K. Y. Srinivasan - * - */ -#include -#include -#include -#include -#include -#include -#include - -#include "hyperv.h" -#include "hyperv_storage.h" - - -static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL); - if (!stor_device) - return NULL; - - stor_device->destroy = false; - init_waitqueue_head(&stor_device->waiting_to_drain); - stor_device->device = device; - device->ext = stor_device; - - return stor_device; -} - - -static inline struct storvsc_device *get_in_stor_device( - struct hv_device *device) -{ - struct storvsc_device *stor_device; - unsigned long flags; - - spin_lock_irqsave(&device->channel->inbound_lock, flags); - stor_device = (struct storvsc_device *)device->ext; - - if (!stor_device) - goto get_in_err; - - /* - * If the device is being destroyed; allow incoming - * traffic only to cleanup outstanding requests. - */ - - if (stor_device->destroy && - (atomic_read(&stor_device->num_outstanding_req) == 0)) - stor_device = NULL; - -get_in_err: - spin_unlock_irqrestore(&device->channel->inbound_lock, flags); - return stor_device; - -} - -static int storvsc_channel_init(struct hv_device *device) -{ - struct storvsc_device *stor_device; - struct hv_storvsc_request *request; - struct vstor_packet *vstor_packet; - int ret, t; - - stor_device = get_out_stor_device(device); - if (!stor_device) - return -ENODEV; - - request = &stor_device->init_request; - vstor_packet = &request->vstor_packet; - - /* - * Now, initiate the vsc/vsp initialization protocol on the open - * channel - */ - memset(request, 0, sizeof(struct hv_storvsc_request)); - init_completion(&request->wait_event); - vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; - vstor_packet->flags = REQUEST_COMPLETION_FLAG; - - ret = vmbus_sendpacket(device->channel, vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - if (ret != 0) - goto cleanup; - - t = wait_for_completion_timeout(&request->wait_event, 5*HZ); - if (t == 0) { - ret = -ETIMEDOUT; - goto cleanup; - } - - if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || - vstor_packet->status != 0) - goto cleanup; - - - /* reuse the packet for version range supported */ - memset(vstor_packet, 0, sizeof(struct vstor_packet)); - vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION; - vstor_packet->flags = REQUEST_COMPLETION_FLAG; - - vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT; - FILL_VMSTOR_REVISION(vstor_packet->version.revision); - - ret = vmbus_sendpacket(device->channel, vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - if (ret != 0) - goto cleanup; - - t = wait_for_completion_timeout(&request->wait_event, 5*HZ); - if (t == 0) { - ret = -ETIMEDOUT; - goto cleanup; - } - - if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || - vstor_packet->status != 0) - goto cleanup; - - - memset(vstor_packet, 0, sizeof(struct vstor_packet)); - vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES; - vstor_packet->flags = REQUEST_COMPLETION_FLAG; - vstor_packet->storage_channel_properties.port_number = - stor_device->port_number; - - ret = vmbus_sendpacket(device->channel, vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - - if (ret != 0) - goto cleanup; - - t = wait_for_completion_timeout(&request->wait_event, 5*HZ); - if (t == 0) { - ret = -ETIMEDOUT; - goto cleanup; - } - - if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || - vstor_packet->status != 0) - goto cleanup; - - stor_device->path_id = vstor_packet->storage_channel_properties.path_id; - stor_device->target_id - = vstor_packet->storage_channel_properties.target_id; - - memset(vstor_packet, 0, sizeof(struct vstor_packet)); - vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; - vstor_packet->flags = REQUEST_COMPLETION_FLAG; - - ret = vmbus_sendpacket(device->channel, vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - - if (ret != 0) - goto cleanup; - - t = wait_for_completion_timeout(&request->wait_event, 5*HZ); - if (t == 0) { - ret = -ETIMEDOUT; - goto cleanup; - } - - if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || - vstor_packet->status != 0) - goto cleanup; - - -cleanup: - return ret; -} - -static void storvsc_on_io_completion(struct hv_device *device, - struct vstor_packet *vstor_packet, - struct hv_storvsc_request *request) -{ - struct storvsc_device *stor_device; - struct vstor_packet *stor_pkt; - - stor_device = (struct storvsc_device *)device->ext; - - stor_pkt = &request->vstor_packet; - - - /* Copy over the status...etc */ - stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; - stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status; - stor_pkt->vm_srb.sense_info_length = - vstor_packet->vm_srb.sense_info_length; - - if (vstor_packet->vm_srb.scsi_status != 0 || - vstor_packet->vm_srb.srb_status != 1){ - DPRINT_WARN(STORVSC, - "cmd 0x%x scsi status 0x%x srb status 0x%x\n", - stor_pkt->vm_srb.cdb[0], - vstor_packet->vm_srb.scsi_status, - vstor_packet->vm_srb.srb_status); - } - - if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { - /* CHECK_CONDITION */ - if (vstor_packet->vm_srb.srb_status & 0x80) { - /* autosense data available */ - DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data " - "valid - len %d\n", request, - vstor_packet->vm_srb.sense_info_length); - - memcpy(request->sense_buffer, - vstor_packet->vm_srb.sense_data, - vstor_packet->vm_srb.sense_info_length); - - } - } - - stor_pkt->vm_srb.data_transfer_length = - vstor_packet->vm_srb.data_transfer_length; - - request->on_io_completion(request); - - if (atomic_dec_and_test(&stor_device->num_outstanding_req) && - stor_device->drain_notify) - wake_up(&stor_device->waiting_to_drain); - - -} - -static void storvsc_on_receive(struct hv_device *device, - struct vstor_packet *vstor_packet, - struct hv_storvsc_request *request) -{ - switch (vstor_packet->operation) { - case VSTOR_OPERATION_COMPLETE_IO: - storvsc_on_io_completion(device, vstor_packet, request); - break; - case VSTOR_OPERATION_REMOVE_DEVICE: - - default: - break; - } -} - -static void storvsc_on_channel_callback(void *context) -{ - struct hv_device *device = (struct hv_device *)context; - struct storvsc_device *stor_device; - u32 bytes_recvd; - u64 request_id; - unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)]; - struct hv_storvsc_request *request; - int ret; - - - stor_device = get_in_stor_device(device); - if (!stor_device) - return; - - do { - ret = vmbus_recvpacket(device->channel, packet, - ALIGN(sizeof(struct vstor_packet), 8), - &bytes_recvd, &request_id); - if (ret == 0 && bytes_recvd > 0) { - - request = (struct hv_storvsc_request *) - (unsigned long)request_id; - - if ((request == &stor_device->init_request) || - (request == &stor_device->reset_request)) { - - memcpy(&request->vstor_packet, packet, - sizeof(struct vstor_packet)); - complete(&request->wait_event); - } else { - storvsc_on_receive(device, - (struct vstor_packet *)packet, - request); - } - } else { - break; - } - } while (1); - - return; -} - -static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) -{ - struct vmstorage_channel_properties props; - int ret; - - memset(&props, 0, sizeof(struct vmstorage_channel_properties)); - - /* Open the channel */ - ret = vmbus_open(device->channel, - ring_size, - ring_size, - (void *)&props, - sizeof(struct vmstorage_channel_properties), - storvsc_on_channel_callback, device); - - if (ret != 0) - return ret; - - ret = storvsc_channel_init(device); - - return ret; -} - -int storvsc_dev_add(struct hv_device *device, - void *additional_info) -{ - struct storvsc_device *stor_device; - struct storvsc_device_info *device_info; - int ret = 0; - - device_info = (struct storvsc_device_info *)additional_info; - stor_device = alloc_stor_device(device); - if (!stor_device) - return -ENOMEM; - - /* Save the channel properties to our storvsc channel */ - - /* - * If we support more than 1 scsi channel, we need to set the - * port number here to the scsi channel but how do we get the - * scsi channel prior to the bus scan. - * - * The host does not support this. - */ - - stor_device->port_number = device_info->port_number; - /* Send it back up */ - ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size); - if (ret) { - kfree(stor_device); - return ret; - } - device_info->path_id = stor_device->path_id; - device_info->target_id = stor_device->target_id; - - return ret; -} - -int storvsc_dev_remove(struct hv_device *device) -{ - struct storvsc_device *stor_device; - unsigned long flags; - - stor_device = (struct storvsc_device *)device->ext; - - spin_lock_irqsave(&device->channel->inbound_lock, flags); - stor_device->destroy = true; - spin_unlock_irqrestore(&device->channel->inbound_lock, flags); - - /* - * At this point, all outbound traffic should be disable. We - * only allow inbound traffic (responses) to proceed so that - * outstanding requests can be completed. - */ - - storvsc_wait_to_drain(stor_device); - - /* - * Since we have already drained, we don't need to busy wait - * as was done in final_release_stor_device() - * Note that we cannot set the ext pointer to NULL until - * we have drained - to drain the outgoing packets, we need to - * allow incoming packets. - */ - spin_lock_irqsave(&device->channel->inbound_lock, flags); - device->ext = NULL; - spin_unlock_irqrestore(&device->channel->inbound_lock, flags); - - /* Close the channel */ - vmbus_close(device->channel); - - kfree(stor_device); - return 0; -} - -int storvsc_do_io(struct hv_device *device, - struct hv_storvsc_request *request) -{ - struct storvsc_device *stor_device; - struct vstor_packet *vstor_packet; - int ret = 0; - - vstor_packet = &request->vstor_packet; - stor_device = get_out_stor_device(device); - - if (!stor_device) - return -ENODEV; - - - request->device = device; - - - vstor_packet->flags |= REQUEST_COMPLETION_FLAG; - - vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); - - - vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; - - - vstor_packet->vm_srb.data_transfer_length = - request->data_buffer.len; - - vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; - - if (request->data_buffer.len) { - ret = vmbus_sendpacket_multipagebuffer(device->channel, - &request->data_buffer, - vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request); - } else { - ret = vmbus_sendpacket(device->channel, vstor_packet, - sizeof(struct vstor_packet), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - } - - if (ret != 0) - return ret; - - atomic_inc(&stor_device->num_outstanding_req); - - return ret; -} - -/* - * The channel properties uniquely specify how the device is to be - * presented to the guest. Map this information for use by the block - * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest - * (storvsc_drv) and so scsi devices in the guest are handled by - * native upper level Linux drivers. Consequently, Hyper-V - * block driver, while being a generic block driver, presently does not - * deal with anything other than devices that would need to be presented - * to the guest as an IDE disk. - * - * This function maps the channel properties as embedded in the input - * parameter device_info onto information necessary to register the - * corresponding block device. - * - * Currently, there is no way to stop the emulation of the block device - * on the host side. And so, to prevent the native IDE drivers in Linux - * from taking over these devices (to be managedby Hyper-V block - * driver), we will take over if need be the major of the IDE controllers. - * - */ - -int storvsc_get_major_info(struct storvsc_device_info *device_info, - struct storvsc_major_info *major_info) -{ - static bool ide0_registered; - static bool ide1_registered; - - /* - * For now we only support IDE disks. - */ - major_info->devname = "ide"; - major_info->diskname = "hd"; - - if (device_info->path_id) { - major_info->major = 22; - if (!ide1_registered) { - major_info->do_register = true; - ide1_registered = true; - } else - major_info->do_register = false; - - if (device_info->target_id) - major_info->index = 3; - else - major_info->index = 2; - - return 0; - } else { - major_info->major = 3; - if (!ide0_registered) { - major_info->do_register = true; - ide0_registered = true; - } else - major_info->do_register = false; - - if (device_info->target_id) - major_info->index = 1; - else - major_info->index = 0; - - return 0; - } - - return -ENODEV; -} diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 3e00e70c945..ddb31cf4209 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -36,6 +36,535 @@ #include "hyperv.h" #include "hyperv_storage.h" + +/* + * Copyright (c) 2009, Microsoft Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + * + * Authors: + * Haiyang Zhang + * Hank Janssen + * K. Y. Srinivasan + * + */ +#include +#include +#include +#include +#include +#include +#include + +#include "hyperv.h" +#include "hyperv_storage.h" + + +static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) +{ + struct storvsc_device *stor_device; + + stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL); + if (!stor_device) + return NULL; + + stor_device->destroy = false; + init_waitqueue_head(&stor_device->waiting_to_drain); + stor_device->device = device; + device->ext = stor_device; + + return stor_device; +} + + +static inline struct storvsc_device *get_in_stor_device( + struct hv_device *device) +{ + struct storvsc_device *stor_device; + unsigned long flags; + + spin_lock_irqsave(&device->channel->inbound_lock, flags); + stor_device = (struct storvsc_device *)device->ext; + + if (!stor_device) + goto get_in_err; + + /* + * If the device is being destroyed; allow incoming + * traffic only to cleanup outstanding requests. + */ + + if (stor_device->destroy && + (atomic_read(&stor_device->num_outstanding_req) == 0)) + stor_device = NULL; + +get_in_err: + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); + return stor_device; + +} + +static int storvsc_channel_init(struct hv_device *device) +{ + struct storvsc_device *stor_device; + struct hv_storvsc_request *request; + struct vstor_packet *vstor_packet; + int ret, t; + + stor_device = get_out_stor_device(device); + if (!stor_device) + return -ENODEV; + + request = &stor_device->init_request; + vstor_packet = &request->vstor_packet; + + /* + * Now, initiate the vsc/vsp initialization protocol on the open + * channel + */ + memset(request, 0, sizeof(struct hv_storvsc_request)); + init_completion(&request->wait_event); + vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; + vstor_packet->flags = REQUEST_COMPLETION_FLAG; + + ret = vmbus_sendpacket(device->channel, vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + if (ret != 0) + goto cleanup; + + t = wait_for_completion_timeout(&request->wait_event, 5*HZ); + if (t == 0) { + ret = -ETIMEDOUT; + goto cleanup; + } + + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || + vstor_packet->status != 0) + goto cleanup; + + + /* reuse the packet for version range supported */ + memset(vstor_packet, 0, sizeof(struct vstor_packet)); + vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION; + vstor_packet->flags = REQUEST_COMPLETION_FLAG; + + vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT; + FILL_VMSTOR_REVISION(vstor_packet->version.revision); + + ret = vmbus_sendpacket(device->channel, vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + if (ret != 0) + goto cleanup; + + t = wait_for_completion_timeout(&request->wait_event, 5*HZ); + if (t == 0) { + ret = -ETIMEDOUT; + goto cleanup; + } + + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || + vstor_packet->status != 0) + goto cleanup; + + + memset(vstor_packet, 0, sizeof(struct vstor_packet)); + vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES; + vstor_packet->flags = REQUEST_COMPLETION_FLAG; + vstor_packet->storage_channel_properties.port_number = + stor_device->port_number; + + ret = vmbus_sendpacket(device->channel, vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + + if (ret != 0) + goto cleanup; + + t = wait_for_completion_timeout(&request->wait_event, 5*HZ); + if (t == 0) { + ret = -ETIMEDOUT; + goto cleanup; + } + + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || + vstor_packet->status != 0) + goto cleanup; + + stor_device->path_id = vstor_packet->storage_channel_properties.path_id; + stor_device->target_id + = vstor_packet->storage_channel_properties.target_id; + + memset(vstor_packet, 0, sizeof(struct vstor_packet)); + vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; + vstor_packet->flags = REQUEST_COMPLETION_FLAG; + + ret = vmbus_sendpacket(device->channel, vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + + if (ret != 0) + goto cleanup; + + t = wait_for_completion_timeout(&request->wait_event, 5*HZ); + if (t == 0) { + ret = -ETIMEDOUT; + goto cleanup; + } + + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || + vstor_packet->status != 0) + goto cleanup; + + +cleanup: + return ret; +} + +static void storvsc_on_io_completion(struct hv_device *device, + struct vstor_packet *vstor_packet, + struct hv_storvsc_request *request) +{ + struct storvsc_device *stor_device; + struct vstor_packet *stor_pkt; + + stor_device = (struct storvsc_device *)device->ext; + + stor_pkt = &request->vstor_packet; + + + /* Copy over the status...etc */ + stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; + stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status; + stor_pkt->vm_srb.sense_info_length = + vstor_packet->vm_srb.sense_info_length; + + if (vstor_packet->vm_srb.scsi_status != 0 || + vstor_packet->vm_srb.srb_status != 1){ + DPRINT_WARN(STORVSC, + "cmd 0x%x scsi status 0x%x srb status 0x%x\n", + stor_pkt->vm_srb.cdb[0], + vstor_packet->vm_srb.scsi_status, + vstor_packet->vm_srb.srb_status); + } + + if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { + /* CHECK_CONDITION */ + if (vstor_packet->vm_srb.srb_status & 0x80) { + /* autosense data available */ + DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data " + "valid - len %d\n", request, + vstor_packet->vm_srb.sense_info_length); + + memcpy(request->sense_buffer, + vstor_packet->vm_srb.sense_data, + vstor_packet->vm_srb.sense_info_length); + + } + } + + stor_pkt->vm_srb.data_transfer_length = + vstor_packet->vm_srb.data_transfer_length; + + request->on_io_completion(request); + + if (atomic_dec_and_test(&stor_device->num_outstanding_req) && + stor_device->drain_notify) + wake_up(&stor_device->waiting_to_drain); + + +} + +static void storvsc_on_receive(struct hv_device *device, + struct vstor_packet *vstor_packet, + struct hv_storvsc_request *request) +{ + switch (vstor_packet->operation) { + case VSTOR_OPERATION_COMPLETE_IO: + storvsc_on_io_completion(device, vstor_packet, request); + break; + case VSTOR_OPERATION_REMOVE_DEVICE: + + default: + break; + } +} + +static void storvsc_on_channel_callback(void *context) +{ + struct hv_device *device = (struct hv_device *)context; + struct storvsc_device *stor_device; + u32 bytes_recvd; + u64 request_id; + unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)]; + struct hv_storvsc_request *request; + int ret; + + + stor_device = get_in_stor_device(device); + if (!stor_device) + return; + + do { + ret = vmbus_recvpacket(device->channel, packet, + ALIGN(sizeof(struct vstor_packet), 8), + &bytes_recvd, &request_id); + if (ret == 0 && bytes_recvd > 0) { + + request = (struct hv_storvsc_request *) + (unsigned long)request_id; + + if ((request == &stor_device->init_request) || + (request == &stor_device->reset_request)) { + + memcpy(&request->vstor_packet, packet, + sizeof(struct vstor_packet)); + complete(&request->wait_event); + } else { + storvsc_on_receive(device, + (struct vstor_packet *)packet, + request); + } + } else { + break; + } + } while (1); + + return; +} + +static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) +{ + struct vmstorage_channel_properties props; + int ret; + + memset(&props, 0, sizeof(struct vmstorage_channel_properties)); + + /* Open the channel */ + ret = vmbus_open(device->channel, + ring_size, + ring_size, + (void *)&props, + sizeof(struct vmstorage_channel_properties), + storvsc_on_channel_callback, device); + + if (ret != 0) + return ret; + + ret = storvsc_channel_init(device); + + return ret; +} + +int storvsc_dev_add(struct hv_device *device, + void *additional_info) +{ + struct storvsc_device *stor_device; + struct storvsc_device_info *device_info; + int ret = 0; + + device_info = (struct storvsc_device_info *)additional_info; + stor_device = alloc_stor_device(device); + if (!stor_device) + return -ENOMEM; + + /* Save the channel properties to our storvsc channel */ + + /* + * If we support more than 1 scsi channel, we need to set the + * port number here to the scsi channel but how do we get the + * scsi channel prior to the bus scan. + * + * The host does not support this. + */ + + stor_device->port_number = device_info->port_number; + /* Send it back up */ + ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size); + if (ret) { + kfree(stor_device); + return ret; + } + device_info->path_id = stor_device->path_id; + device_info->target_id = stor_device->target_id; + + return ret; +} + +int storvsc_dev_remove(struct hv_device *device) +{ + struct storvsc_device *stor_device; + unsigned long flags; + + stor_device = (struct storvsc_device *)device->ext; + + spin_lock_irqsave(&device->channel->inbound_lock, flags); + stor_device->destroy = true; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); + + /* + * At this point, all outbound traffic should be disable. We + * only allow inbound traffic (responses) to proceed so that + * outstanding requests can be completed. + */ + + storvsc_wait_to_drain(stor_device); + + /* + * Since we have already drained, we don't need to busy wait + * as was done in final_release_stor_device() + * Note that we cannot set the ext pointer to NULL until + * we have drained - to drain the outgoing packets, we need to + * allow incoming packets. + */ + spin_lock_irqsave(&device->channel->inbound_lock, flags); + device->ext = NULL; + spin_unlock_irqrestore(&device->channel->inbound_lock, flags); + + /* Close the channel */ + vmbus_close(device->channel); + + kfree(stor_device); + return 0; +} + +int storvsc_do_io(struct hv_device *device, + struct hv_storvsc_request *request) +{ + struct storvsc_device *stor_device; + struct vstor_packet *vstor_packet; + int ret = 0; + + vstor_packet = &request->vstor_packet; + stor_device = get_out_stor_device(device); + + if (!stor_device) + return -ENODEV; + + + request->device = device; + + + vstor_packet->flags |= REQUEST_COMPLETION_FLAG; + + vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); + + + vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; + + + vstor_packet->vm_srb.data_transfer_length = + request->data_buffer.len; + + vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; + + if (request->data_buffer.len) { + ret = vmbus_sendpacket_multipagebuffer(device->channel, + &request->data_buffer, + vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request); + } else { + ret = vmbus_sendpacket(device->channel, vstor_packet, + sizeof(struct vstor_packet), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + } + + if (ret != 0) + return ret; + + atomic_inc(&stor_device->num_outstanding_req); + + return ret; +} + +/* + * The channel properties uniquely specify how the device is to be + * presented to the guest. Map this information for use by the block + * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest + * (storvsc_drv) and so scsi devices in the guest are handled by + * native upper level Linux drivers. Consequently, Hyper-V + * block driver, while being a generic block driver, presently does not + * deal with anything other than devices that would need to be presented + * to the guest as an IDE disk. + * + * This function maps the channel properties as embedded in the input + * parameter device_info onto information necessary to register the + * corresponding block device. + * + * Currently, there is no way to stop the emulation of the block device + * on the host side. And so, to prevent the native IDE drivers in Linux + * from taking over these devices (to be managedby Hyper-V block + * driver), we will take over if need be the major of the IDE controllers. + * + */ + +int storvsc_get_major_info(struct storvsc_device_info *device_info, + struct storvsc_major_info *major_info) +{ + static bool ide0_registered; + static bool ide1_registered; + + /* + * For now we only support IDE disks. + */ + major_info->devname = "ide"; + major_info->diskname = "hd"; + + if (device_info->path_id) { + major_info->major = 22; + if (!ide1_registered) { + major_info->do_register = true; + ide1_registered = true; + } else + major_info->do_register = false; + + if (device_info->target_id) + major_info->index = 3; + else + major_info->index = 2; + + return 0; + } else { + major_info->major = 3; + if (!ide0_registered) { + major_info->do_register = true; + ide0_registered = true; + } else + major_info->do_register = false; + + if (device_info->target_id) + major_info->index = 1; + else + major_info->index = 0; + + return 0; + } + + return -ENODEV; +} static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; module_param(storvsc_ringbuffer_size, int, S_IRUGO); From a1be1706ed0c6d8b93a1aa8fdb03810508fdae3e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:23 -0700 Subject: [PATCH 0680/1519] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c Cleanup storvsc_drv.c after adding the contents of storvsc.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 147 ++++++------------------------- 1 file changed, 27 insertions(+), 120 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index ddb31cf4209..096f615a92e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -19,11 +19,17 @@ * Hank Janssen * K. Y. Srinivasan */ + +#include +#include +#include +#include +#include +#include #include #include #include #include -#include #include #include #include @@ -37,39 +43,28 @@ #include "hyperv_storage.h" -/* - * Copyright (c) 2009, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang - * Hank Janssen - * K. Y. Srinivasan - * - */ -#include -#include -#include -#include -#include -#include -#include +static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; -#include "hyperv.h" -#include "hyperv_storage.h" +module_param(storvsc_ringbuffer_size, int, S_IRUGO); +MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); +struct hv_host_device { + struct hv_device *dev; + struct kmem_cache *request_pool; + unsigned int port; + unsigned char path; + unsigned char target; +}; + +struct storvsc_cmd_request { + struct list_head entry; + struct scsi_cmnd *cmd; + + unsigned int bounce_sgl_count; + struct scatterlist *bounce_sgl; + + struct hv_storvsc_request request; +}; static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) { @@ -500,94 +495,6 @@ int storvsc_do_io(struct hv_device *device, return ret; } -/* - * The channel properties uniquely specify how the device is to be - * presented to the guest. Map this information for use by the block - * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest - * (storvsc_drv) and so scsi devices in the guest are handled by - * native upper level Linux drivers. Consequently, Hyper-V - * block driver, while being a generic block driver, presently does not - * deal with anything other than devices that would need to be presented - * to the guest as an IDE disk. - * - * This function maps the channel properties as embedded in the input - * parameter device_info onto information necessary to register the - * corresponding block device. - * - * Currently, there is no way to stop the emulation of the block device - * on the host side. And so, to prevent the native IDE drivers in Linux - * from taking over these devices (to be managedby Hyper-V block - * driver), we will take over if need be the major of the IDE controllers. - * - */ - -int storvsc_get_major_info(struct storvsc_device_info *device_info, - struct storvsc_major_info *major_info) -{ - static bool ide0_registered; - static bool ide1_registered; - - /* - * For now we only support IDE disks. - */ - major_info->devname = "ide"; - major_info->diskname = "hd"; - - if (device_info->path_id) { - major_info->major = 22; - if (!ide1_registered) { - major_info->do_register = true; - ide1_registered = true; - } else - major_info->do_register = false; - - if (device_info->target_id) - major_info->index = 3; - else - major_info->index = 2; - - return 0; - } else { - major_info->major = 3; - if (!ide0_registered) { - major_info->do_register = true; - ide0_registered = true; - } else - major_info->do_register = false; - - if (device_info->target_id) - major_info->index = 1; - else - major_info->index = 0; - - return 0; - } - - return -ENODEV; -} -static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; - -module_param(storvsc_ringbuffer_size, int, S_IRUGO); -MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); - -struct hv_host_device { - struct hv_device *dev; - struct kmem_cache *request_pool; - unsigned int port; - unsigned char path; - unsigned char target; -}; - -struct storvsc_cmd_request { - struct list_head entry; - struct scsi_cmnd *cmd; - - unsigned int bounce_sgl_count; - struct scatterlist *bounce_sgl; - - struct hv_storvsc_request request; -}; - static void storvsc_get_ide_info(struct hv_device *dev, int *target, int *path) { *target = From f0d79fe9c564fbe1e09d8366d0863611bc57cafa Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:24 -0700 Subject: [PATCH 0681/1519] Staging: hv: storvsc: Add the contents of hyperv_storage.h to storvsc_drv.c As part of further cleanup of storvsc, add the contents of hyperv_storage.h to storvsc_drv.c and do the necessary adjustments. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_storage.h | 322 ---------------------------- drivers/staging/hv/storvsc_drv.c | 277 +++++++++++++++++++++++- 2 files changed, 276 insertions(+), 323 deletions(-) delete mode 100644 drivers/staging/hv/hyperv_storage.h diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h deleted file mode 100644 index 687cdc543c4..00000000000 --- a/drivers/staging/hv/hyperv_storage.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * - * Copyright (c) 2011, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang - * Hank Janssen - * K. Y. Srinivasan - * - */ - -#ifndef _HYPERV_STORAGE_H -#define _HYPERV_STORAGE_H - - -/* vstorage.w revision number. This is used in the case of a version match, */ -/* to alert the user that structure sizes may be mismatched even though the */ -/* protocol versions match. */ - - -#define REVISION_STRING(REVISION_) #REVISION_ -#define FILL_VMSTOR_REVISION(RESULT_LVALUE_) \ - do { \ - char *revision_string \ - = REVISION_STRING($Rev : 6 $) + 6; \ - RESULT_LVALUE_ = 0; \ - while (*revision_string >= '0' \ - && *revision_string <= '9') { \ - RESULT_LVALUE_ *= 10; \ - RESULT_LVALUE_ += *revision_string - '0'; \ - revision_string++; \ - } \ - } while (0) - -/* Major/minor macros. Minor version is in LSB, meaning that earlier flat */ -/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */ -#define VMSTOR_PROTOCOL_MAJOR(VERSION_) (((VERSION_) >> 8) & 0xff) -#define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_)) & 0xff) -#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \ - (((MINOR_) & 0xff))) -#define VMSTOR_INVALID_PROTOCOL_VERSION (-1) - -/* Version history: */ -/* V1 Beta 0.1 */ -/* V1 RC < 2008/1/31 1.0 */ -/* V1 RC > 2008/1/31 2.0 */ -#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0) - - - - -/* This will get replaced with the max transfer length that is possible on */ -/* the host adapter. */ -/* The max transfer length will be published when we offer a vmbus channel. */ -#define MAX_TRANSFER_LENGTH 0x40000 -#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) + \ - sizeof(struct vstor_packet) + \ - sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE))) - - -/* Packet structure describing virtual storage requests. */ -enum vstor_packet_operation { - VSTOR_OPERATION_COMPLETE_IO = 1, - VSTOR_OPERATION_REMOVE_DEVICE = 2, - VSTOR_OPERATION_EXECUTE_SRB = 3, - VSTOR_OPERATION_RESET_LUN = 4, - VSTOR_OPERATION_RESET_ADAPTER = 5, - VSTOR_OPERATION_RESET_BUS = 6, - VSTOR_OPERATION_BEGIN_INITIALIZATION = 7, - VSTOR_OPERATION_END_INITIALIZATION = 8, - VSTOR_OPERATION_QUERY_PROTOCOL_VERSION = 9, - VSTOR_OPERATION_QUERY_PROPERTIES = 10, - VSTOR_OPERATION_MAXIMUM = 10 -}; - -/* - * Platform neutral description of a scsi request - - * this remains the same across the write regardless of 32/64 bit - * note: it's patterned off the SCSI_PASS_THROUGH structure - */ -#define CDB16GENERIC_LENGTH 0x10 - -#ifndef SENSE_BUFFER_SIZE -#define SENSE_BUFFER_SIZE 0x12 -#endif - -#define MAX_DATA_BUF_LEN_WITH_PADDING 0x14 - -struct vmscsi_request { - unsigned short length; - unsigned char srb_status; - unsigned char scsi_status; - - unsigned char port_number; - unsigned char path_id; - unsigned char target_id; - unsigned char lun; - - unsigned char cdb_length; - unsigned char sense_info_length; - unsigned char data_in; - unsigned char reserved; - - unsigned int data_transfer_length; - - union { - unsigned char cdb[CDB16GENERIC_LENGTH]; - unsigned char sense_data[SENSE_BUFFER_SIZE]; - unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING]; - }; -} __attribute((packed)); - - -/* - * This structure is sent during the intialization phase to get the different - * properties of the channel. - */ -struct vmstorage_channel_properties { - unsigned short protocol_version; - unsigned char path_id; - unsigned char target_id; - - /* Note: port number is only really known on the client side */ - unsigned int port_number; - unsigned int flags; - unsigned int max_transfer_bytes; - - /* This id is unique for each channel and will correspond with */ - /* vendor specific data in the inquirydata */ - unsigned long long unique_id; -} __packed; - -/* This structure is sent during the storage protocol negotiations. */ -struct vmstorage_protocol_version { - /* Major (MSW) and minor (LSW) version numbers. */ - unsigned short major_minor; - - /* - * Revision number is auto-incremented whenever this file is changed - * (See FILL_VMSTOR_REVISION macro above). Mismatch does not - * definitely indicate incompatibility--but it does indicate mismatched - * builds. - */ - unsigned short revision; -} __packed; - -/* Channel Property Flags */ -#define STORAGE_CHANNEL_REMOVABLE_FLAG 0x1 -#define STORAGE_CHANNEL_EMULATED_IDE_FLAG 0x2 - -struct vstor_packet { - /* Requested operation type */ - enum vstor_packet_operation operation; - - /* Flags - see below for values */ - unsigned int flags; - - /* Status of the request returned from the server side. */ - unsigned int status; - - /* Data payload area */ - union { - /* - * Structure used to forward SCSI commands from the - * client to the server. - */ - struct vmscsi_request vm_srb; - - /* Structure used to query channel properties. */ - struct vmstorage_channel_properties storage_channel_properties; - - /* Used during version negotiations. */ - struct vmstorage_protocol_version version; - }; -} __packed; - -/* Packet flags */ -/* - * This flag indicates that the server should send back a completion for this - * packet. - */ -#define REQUEST_COMPLETION_FLAG 0x1 - -/* This is the set of flags that the vsc can set in any packets it sends */ -#define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG) - - -#include -#include -#include "hyperv_storage.h" -#include "hyperv.h" - -/* Defines */ -#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) -#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) - -#define STORVSC_MAX_IO_REQUESTS 128 - -/* - * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In - * reality, the path/target is not used (ie always set to 0) so our - * scsi host adapter essentially has 1 bus with 1 target that contains - * up to 256 luns. - */ -#define STORVSC_MAX_LUNS_PER_TARGET 64 -#define STORVSC_MAX_TARGETS 1 -#define STORVSC_MAX_CHANNELS 1 - -struct hv_storvsc_request; - -/* Matches Windows-end */ -enum storvsc_request_type { - WRITE_TYPE, - READ_TYPE, - UNKNOWN_TYPE, -}; - - -struct hv_storvsc_request { - struct hv_storvsc_request *request; - struct hv_device *device; - - /* Synchronize the request/response if needed */ - struct completion wait_event; - - unsigned char *sense_buffer; - void *context; - void (*on_io_completion)(struct hv_storvsc_request *request); - struct hv_multipage_buffer data_buffer; - - struct vstor_packet vstor_packet; -}; - - -struct storvsc_device_info { - u32 ring_buffer_size; - unsigned int port_number; - unsigned char path_id; - unsigned char target_id; -}; - -struct storvsc_major_info { - int major; - int index; - bool do_register; - char *devname; - char *diskname; -}; - -/* A storvsc device is a device object that contains a vmbus channel */ -struct storvsc_device { - struct hv_device *device; - - bool destroy; - bool drain_notify; - atomic_t num_outstanding_req; - - wait_queue_head_t waiting_to_drain; - - /* - * Each unique Port/Path/Target represents 1 channel ie scsi - * controller. In reality, the pathid, targetid is always 0 - * and the port is set by us - */ - unsigned int port_number; - unsigned char path_id; - unsigned char target_id; - - /* Used for vsc/vsp channel reset process */ - struct hv_storvsc_request init_request; - struct hv_storvsc_request reset_request; -}; - - -static inline struct storvsc_device *get_out_stor_device( - struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; - - if (stor_device && stor_device->destroy) - stor_device = NULL; - - return stor_device; -} - - -static inline void storvsc_wait_to_drain(struct storvsc_device *dev) -{ - dev->drain_notify = true; - wait_event(dev->waiting_to_drain, - atomic_read(&dev->num_outstanding_req) == 0); - dev->drain_notify = false; -} - -/* Interface */ - -int storvsc_dev_add(struct hv_device *device, - void *additional_info); -int storvsc_dev_remove(struct hv_device *device); - -int storvsc_do_io(struct hv_device *device, - struct hv_storvsc_request *request); - -int storvsc_get_major_info(struct storvsc_device_info *device_info, - struct storvsc_major_info *major_info); - -#endif /* _HYPERV_STORAGE_H */ diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 096f615a92e..4a95f8be807 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -40,7 +41,281 @@ #include #include "hyperv.h" -#include "hyperv_storage.h" + +/* to alert the user that structure sizes may be mismatched even though the */ +/* protocol versions match. */ + + +#define REVISION_STRING(REVISION_) #REVISION_ +#define FILL_VMSTOR_REVISION(RESULT_LVALUE_) \ + do { \ + char *revision_string \ + = REVISION_STRING($Rev : 6 $) + 6; \ + RESULT_LVALUE_ = 0; \ + while (*revision_string >= '0' \ + && *revision_string <= '9') { \ + RESULT_LVALUE_ *= 10; \ + RESULT_LVALUE_ += *revision_string - '0'; \ + revision_string++; \ + } \ + } while (0) + +/* Major/minor macros. Minor version is in LSB, meaning that earlier flat */ +/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */ +#define VMSTOR_PROTOCOL_MAJOR(VERSION_) (((VERSION_) >> 8) & 0xff) +#define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_)) & 0xff) +#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \ + (((MINOR_) & 0xff))) +#define VMSTOR_INVALID_PROTOCOL_VERSION (-1) + +/* Version history: */ +/* V1 Beta 0.1 */ +/* V1 RC < 2008/1/31 1.0 */ +/* V1 RC > 2008/1/31 2.0 */ +#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0) + + + + +/* This will get replaced with the max transfer length that is possible on */ +/* the host adapter. */ +/* The max transfer length will be published when we offer a vmbus channel. */ +#define MAX_TRANSFER_LENGTH 0x40000 +#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) + \ + sizeof(struct vstor_packet) + \ + sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE))) + + +/* Packet structure describing virtual storage requests. */ +enum vstor_packet_operation { + VSTOR_OPERATION_COMPLETE_IO = 1, + VSTOR_OPERATION_REMOVE_DEVICE = 2, + VSTOR_OPERATION_EXECUTE_SRB = 3, + VSTOR_OPERATION_RESET_LUN = 4, + VSTOR_OPERATION_RESET_ADAPTER = 5, + VSTOR_OPERATION_RESET_BUS = 6, + VSTOR_OPERATION_BEGIN_INITIALIZATION = 7, + VSTOR_OPERATION_END_INITIALIZATION = 8, + VSTOR_OPERATION_QUERY_PROTOCOL_VERSION = 9, + VSTOR_OPERATION_QUERY_PROPERTIES = 10, + VSTOR_OPERATION_MAXIMUM = 10 +}; + +/* + * Platform neutral description of a scsi request - + * this remains the same across the write regardless of 32/64 bit + * note: it's patterned off the SCSI_PASS_THROUGH structure + */ +#define CDB16GENERIC_LENGTH 0x10 + +#ifndef SENSE_BUFFER_SIZE +#define SENSE_BUFFER_SIZE 0x12 +#endif + +#define MAX_DATA_BUF_LEN_WITH_PADDING 0x14 + +struct vmscsi_request { + unsigned short length; + unsigned char srb_status; + unsigned char scsi_status; + + unsigned char port_number; + unsigned char path_id; + unsigned char target_id; + unsigned char lun; + + unsigned char cdb_length; + unsigned char sense_info_length; + unsigned char data_in; + unsigned char reserved; + + unsigned int data_transfer_length; + + union { + unsigned char cdb[CDB16GENERIC_LENGTH]; + unsigned char sense_data[SENSE_BUFFER_SIZE]; + unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING]; + }; +} __attribute((packed)); + + +/* + * This structure is sent during the intialization phase to get the different + * properties of the channel. + */ +struct vmstorage_channel_properties { + unsigned short protocol_version; + unsigned char path_id; + unsigned char target_id; + + /* Note: port number is only really known on the client side */ + unsigned int port_number; + unsigned int flags; + unsigned int max_transfer_bytes; + + /* This id is unique for each channel and will correspond with */ + /* vendor specific data in the inquirydata */ + unsigned long long unique_id; +} __packed; + +/* This structure is sent during the storage protocol negotiations. */ +struct vmstorage_protocol_version { + /* Major (MSW) and minor (LSW) version numbers. */ + unsigned short major_minor; + + /* + * Revision number is auto-incremented whenever this file is changed + * (See FILL_VMSTOR_REVISION macro above). Mismatch does not + * definitely indicate incompatibility--but it does indicate mismatched + * builds. + */ + unsigned short revision; +} __packed; + +/* Channel Property Flags */ +#define STORAGE_CHANNEL_REMOVABLE_FLAG 0x1 +#define STORAGE_CHANNEL_EMULATED_IDE_FLAG 0x2 + +struct vstor_packet { + /* Requested operation type */ + enum vstor_packet_operation operation; + + /* Flags - see below for values */ + unsigned int flags; + + /* Status of the request returned from the server side. */ + unsigned int status; + + /* Data payload area */ + union { + /* + * Structure used to forward SCSI commands from the + * client to the server. + */ + struct vmscsi_request vm_srb; + + /* Structure used to query channel properties. */ + struct vmstorage_channel_properties storage_channel_properties; + + /* Used during version negotiations. */ + struct vmstorage_protocol_version version; + }; +} __packed; + +/* Packet flags */ +/* + * This flag indicates that the server should send back a completion for this + * packet. + */ +#define REQUEST_COMPLETION_FLAG 0x1 + +/* This is the set of flags that the vsc can set in any packets it sends */ +#define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG) + + +/* Defines */ +#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) +#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) + +#define STORVSC_MAX_IO_REQUESTS 128 + +/* + * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In + * reality, the path/target is not used (ie always set to 0) so our + * scsi host adapter essentially has 1 bus with 1 target that contains + * up to 256 luns. + */ +#define STORVSC_MAX_LUNS_PER_TARGET 64 +#define STORVSC_MAX_TARGETS 1 +#define STORVSC_MAX_CHANNELS 1 + +struct hv_storvsc_request; + +/* Matches Windows-end */ +enum storvsc_request_type { + WRITE_TYPE, + READ_TYPE, + UNKNOWN_TYPE, +}; + + +struct hv_storvsc_request { + struct hv_storvsc_request *request; + struct hv_device *device; + + /* Synchronize the request/response if needed */ + struct completion wait_event; + + unsigned char *sense_buffer; + void *context; + void (*on_io_completion)(struct hv_storvsc_request *request); + struct hv_multipage_buffer data_buffer; + + struct vstor_packet vstor_packet; +}; + + +struct storvsc_device_info { + u32 ring_buffer_size; + unsigned int port_number; + unsigned char path_id; + unsigned char target_id; +}; + +struct storvsc_major_info { + int major; + int index; + bool do_register; + char *devname; + char *diskname; +}; + +/* A storvsc device is a device object that contains a vmbus channel */ +struct storvsc_device { + struct hv_device *device; + + bool destroy; + bool drain_notify; + atomic_t num_outstanding_req; + + wait_queue_head_t waiting_to_drain; + + /* + * Each unique Port/Path/Target represents 1 channel ie scsi + * controller. In reality, the pathid, targetid is always 0 + * and the port is set by us + */ + unsigned int port_number; + unsigned char path_id; + unsigned char target_id; + + /* Used for vsc/vsp channel reset process */ + struct hv_storvsc_request init_request; + struct hv_storvsc_request reset_request; +}; + + +static inline struct storvsc_device *get_out_stor_device( + struct hv_device *device) +{ + struct storvsc_device *stor_device; + + stor_device = (struct storvsc_device *)device->ext; + + if (stor_device && stor_device->destroy) + stor_device = NULL; + + return stor_device; +} + + +static inline void storvsc_wait_to_drain(struct storvsc_device *dev) +{ + dev->drain_notify = true; + wait_event(dev->waiting_to_drain, + atomic_read(&dev->num_outstanding_req) == 0); + dev->drain_notify = false; +} static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; From c1b3d067e419dee621ddd5e8f5d812973a6d0946 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:25 -0700 Subject: [PATCH 0682/1519] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 62 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 4a95f8be807..0bb4e0e4898 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -42,6 +42,12 @@ #include "hyperv.h" +#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) +static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; + +module_param(storvsc_ringbuffer_size, int, S_IRUGO); +MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); + /* to alert the user that structure sizes may be mismatched even though the */ /* protocol versions match. */ @@ -214,8 +220,6 @@ struct vstor_packet { /* Defines */ -#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) -#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) #define STORVSC_MAX_IO_REQUESTS 128 @@ -262,13 +266,6 @@ struct storvsc_device_info { unsigned char target_id; }; -struct storvsc_major_info { - int major; - int index; - bool do_register; - char *devname; - char *diskname; -}; /* A storvsc device is a device object that contains a vmbus channel */ struct storvsc_device { @@ -294,6 +291,23 @@ struct storvsc_device { struct hv_storvsc_request reset_request; }; +struct hv_host_device { + struct hv_device *dev; + struct kmem_cache *request_pool; + unsigned int port; + unsigned char path; + unsigned char target; +}; + +struct storvsc_cmd_request { + struct list_head entry; + struct scsi_cmnd *cmd; + + unsigned int bounce_sgl_count; + struct scatterlist *bounce_sgl; + + struct hv_storvsc_request request; +}; static inline struct storvsc_device *get_out_stor_device( struct hv_device *device) @@ -317,30 +331,6 @@ static inline void storvsc_wait_to_drain(struct storvsc_device *dev) dev->drain_notify = false; } - -static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; - -module_param(storvsc_ringbuffer_size, int, S_IRUGO); -MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); - -struct hv_host_device { - struct hv_device *dev; - struct kmem_cache *request_pool; - unsigned int port; - unsigned char path; - unsigned char target; -}; - -struct storvsc_cmd_request { - struct list_head entry; - struct scsi_cmnd *cmd; - - unsigned int bounce_sgl_count; - struct scatterlist *bounce_sgl; - - struct hv_storvsc_request request; -}; - static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) { struct storvsc_device *stor_device; @@ -646,7 +636,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) return ret; } -int storvsc_dev_add(struct hv_device *device, +static int storvsc_dev_add(struct hv_device *device, void *additional_info) { struct storvsc_device *stor_device; @@ -681,7 +671,7 @@ int storvsc_dev_add(struct hv_device *device, return ret; } -int storvsc_dev_remove(struct hv_device *device) +static int storvsc_dev_remove(struct hv_device *device) { struct storvsc_device *stor_device; unsigned long flags; @@ -718,7 +708,7 @@ int storvsc_dev_remove(struct hv_device *device) return 0; } -int storvsc_do_io(struct hv_device *device, +static int storvsc_do_io(struct hv_device *device, struct hv_storvsc_request *request) { struct storvsc_device *stor_device; From 4ed51a21c0f69e1379cf858fc21a9d9022bfe0e7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:26 -0700 Subject: [PATCH 0683/1519] Staging: hv: storvsc: Fixup srb and scsi status for INQUIRY and MODE_SENSE The current VHD handler on the Windows Host does not correctly handle INQUIRY and MODE_SENSE commands with some options. Fixup srb_status in these cases since the failure is not fatal. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 0bb4e0e4898..72ca25c4b8e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -512,6 +512,23 @@ static void storvsc_on_io_completion(struct hv_device *device, stor_pkt = &request->vstor_packet; + /* + * The current SCSI handling on the host side does + * not correctly handle: + * INQUIRY command with page code parameter set to 0x80 + * MODE_SENSE command with cmd[2] == 0x1c + * + * Setup srb and scsi status so this won't be fatal. + * We do this so we can distinguish truly fatal failues + * (srb status == 0x4) and off-line the device in that case. + */ + + if ((stor_pkt->vm_srb.cdb[0] == INQUIRY) || + (stor_pkt->vm_srb.cdb[0] == MODE_SENSE)) { + vstor_packet->vm_srb.scsi_status = 0; + vstor_packet->vm_srb.srb_status = 0x1; + } + /* Copy over the status...etc */ stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; From b8de73df1b5143c3d567e707e4dab0b20c82ab54 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:27 -0700 Subject: [PATCH 0684/1519] Staging: hv: storvsc: Fix a typo Fix a typo in a function name. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 72ca25c4b8e..ad0f9d4c5ba 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1130,9 +1130,9 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) /* - * storvsc_commmand_completion - Command completion processing + * storvsc_command_completion - Command completion processing */ -static void storvsc_commmand_completion(struct hv_storvsc_request *request) +static void storvsc_command_completion(struct hv_storvsc_request *request) { struct storvsc_cmd_request *cmd_request = (struct storvsc_cmd_request *)request->context; @@ -1240,7 +1240,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, break; } - request->on_io_completion = storvsc_commmand_completion; + request->on_io_completion = storvsc_command_completion; request->context = cmd_request;/* scmnd; */ vm_srb->port_number = host_dev->port; From 2544b794372b63e46384ac4af91c5630e92cf7f4 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:28 -0700 Subject: [PATCH 0685/1519] Staging: hv: storvsc: In case of scsi errors offline the device When we do get fatal errors from the host, offline the device since the host has already tried all possible recovery actions. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index ad0f9d4c5ba..22a1d758620 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1154,7 +1154,15 @@ static void storvsc_command_completion(struct hv_storvsc_request *request) } } - scmnd->result = vm_srb->scsi_status; + /* + * If there is an error; offline the device since all + * error recovery strategies would have already been + * deployed on the host side. + */ + if (vm_srb->srb_status == 0x4) + scmnd->result = DID_TARGET_FAILURE << 16; + else + scmnd->result = vm_srb->scsi_status; if (scmnd->result) { if (scsi_normalize_sense(scmnd->sense_buffer, From 70691ec666a6c04f6f1438d9a0bf495b24e22610 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:29 -0700 Subject: [PATCH 0686/1519] Staging: hv: storvsc: No need to copy from bounce buffer in case of a failure No need to copy from bounce buffer in case of a failure; cleanup the code accordingly. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 22a1d758620..d575bc92ffc 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1315,17 +1315,9 @@ retry_request: if (ret == -EAGAIN) { /* no more space */ - if (cmd_request->bounce_sgl_count) { - /* - * FIXME: We can optimize on writes by just skipping - * this - */ - copy_from_bounce_buffer(scsi_sglist(scmnd), - cmd_request->bounce_sgl, - scsi_sg_count(scmnd)); + if (cmd_request->bounce_sgl_count) destroy_bounce_buffer(cmd_request->bounce_sgl, - cmd_request->bounce_sgl_count); - } + cmd_request->bounce_sgl_count); kmem_cache_free(host_dev->request_pool, cmd_request); From ae2a0b42bfe6e7eb9251bfb05f7a03008df446a8 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:30 -0700 Subject: [PATCH 0687/1519] Staging: hv: util: Forcefully shutdown when shutdown is requested When the host requests a "shutdown", make sure we shutdown! Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index f2f456f5e44..876d44a8a86 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -89,7 +89,7 @@ static void shutdown_onchannelcallback(void *context) } if (execute_shutdown == true) - orderly_poweroff(false); + orderly_poweroff(true); } /* From 95ff7cde91f5513ebc95ccf0cd482f07dc3454e4 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:31 -0700 Subject: [PATCH 0688/1519] Staging: hv: util: Adjust guest time in a process context The current code was adjusting guest time in interrupt context; do this in process context since we may have to initiate cross-processor interrupts as part of setting time. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index 876d44a8a86..e29a2a23eda 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -106,6 +106,24 @@ static inline void do_adj_guesttime(u64 hosttime) do_settimeofday(&host_ts); } +/* + * Set the host time in a process context. + */ + +struct adj_time_work { + struct work_struct work; + u64 host_time; +}; + +static void hv_set_host_time(struct work_struct *work) +{ + struct adj_time_work *wrk; + + wrk = container_of(work, struct adj_time_work, work); + do_adj_guesttime(wrk->host_time); + kfree(wrk); +} + /* * Synchronize time with host after reboot, restore, etc. * @@ -119,17 +137,26 @@ static inline void do_adj_guesttime(u64 hosttime) */ static inline void adj_guesttime(u64 hosttime, u8 flags) { + struct adj_time_work *wrk; static s32 scnt = 50; + wrk = kmalloc(sizeof(struct adj_time_work), GFP_ATOMIC); + if (wrk == NULL) + return; + + wrk->host_time = hosttime; if ((flags & ICTIMESYNCFLAG_SYNC) != 0) { - do_adj_guesttime(hosttime); + INIT_WORK(&wrk->work, hv_set_host_time); + schedule_work(&wrk->work); return; } if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) { scnt--; - do_adj_guesttime(hosttime); - } + INIT_WORK(&wrk->work, hv_set_host_time); + schedule_work(&wrk->work); + } else + kfree(wrk); } /* From 76c39d429d606d8f9b354ee2b1973b76c8331b1f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:32 -0700 Subject: [PATCH 0689/1519] Staging: hv: vmbus: Check before invoking the channel callback When we close a channel, we set the corresponding callback function to NULL. Check before invoking the channel callback. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index a88ad707256..7a3ec75bab1 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -222,7 +222,7 @@ static void process_chn_event(u32 relid) */ channel = relid2channel(relid); - if (channel) { + if (channel && (channel->onchannel_callback != NULL)) { channel->onchannel_callback(channel->channel_callback_context); } else { pr_err("channel not found for relid - %u\n", relid); From dad76bf73fc20b42d020fe5a93dbe4b4868e7681 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:33 -0700 Subject: [PATCH 0690/1519] Staging: hv: vmbus: Properly deal with de-registering channel callback Ensure that we correctly handle racing invocations of the channel callback when the channel is being closed. We do this using the channel's inbound_lock. A side-effect of this strategy is that we avoid repeatedly picking up this lock as we drain the inbound ring-buffer. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel.c | 20 +++++--------------- drivers/staging/hv/connection.c | 3 +++ drivers/staging/hv/netvsc.c | 3 --- drivers/staging/hv/storvsc_drv.c | 3 --- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index ac92c1f9926..b6f3d38a6db 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -513,9 +513,12 @@ void vmbus_close(struct vmbus_channel *channel) { struct vmbus_channel_close_channel *msg; int ret; + unsigned long flags; /* Stop callback and cancel the timer asap */ + spin_lock_irqsave(&channel->inbound_lock, flags); channel->onchannel_callback = NULL; + spin_unlock_irqrestore(&channel->inbound_lock, flags); /* Send a closing message */ @@ -735,19 +738,15 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, u32 packetlen; u32 userlen; int ret; - unsigned long flags; *buffer_actual_len = 0; *requestid = 0; - spin_lock_irqsave(&channel->inbound_lock, flags); ret = hv_ringbuffer_peek(&channel->inbound, &desc, sizeof(struct vmpacket_descriptor)); - if (ret != 0) { - spin_unlock_irqrestore(&channel->inbound_lock, flags); + if (ret != 0) return 0; - } packetlen = desc.len8 << 3; userlen = packetlen - (desc.offset8 << 3); @@ -755,7 +754,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, *buffer_actual_len = userlen; if (userlen > bufferlen) { - spin_unlock_irqrestore(&channel->inbound_lock, flags); pr_err("Buffer too small - got %d needs %d\n", bufferlen, userlen); @@ -768,7 +766,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, ret = hv_ringbuffer_read(&channel->inbound, buffer, userlen, (desc.offset8 << 3)); - spin_unlock_irqrestore(&channel->inbound_lock, flags); return 0; } @@ -785,19 +782,15 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, u32 packetlen; u32 userlen; int ret; - unsigned long flags; *buffer_actual_len = 0; *requestid = 0; - spin_lock_irqsave(&channel->inbound_lock, flags); ret = hv_ringbuffer_peek(&channel->inbound, &desc, sizeof(struct vmpacket_descriptor)); - if (ret != 0) { - spin_unlock_irqrestore(&channel->inbound_lock, flags); + if (ret != 0) return 0; - } packetlen = desc.len8 << 3; @@ -806,8 +799,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, *buffer_actual_len = packetlen; if (packetlen > bufferlen) { - spin_unlock_irqrestore(&channel->inbound_lock, flags); - pr_err("Buffer too small - needed %d bytes but " "got space for only %d bytes\n", packetlen, bufferlen); @@ -819,7 +810,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, /* Copy over the entire packet to the user buffer */ ret = hv_ringbuffer_read(&channel->inbound, buffer, packetlen, 0); - spin_unlock_irqrestore(&channel->inbound_lock, flags); return 0; } EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 7a3ec75bab1..6aab802ba99 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -215,6 +215,7 @@ struct vmbus_channel *relid2channel(u32 relid) static void process_chn_event(u32 relid) { struct vmbus_channel *channel; + unsigned long flags; /* * Find the channel based on this relid and invokes the @@ -222,11 +223,13 @@ static void process_chn_event(u32 relid) */ channel = relid2channel(relid); + spin_lock_irqsave(&channel->inbound_lock, flags); if (channel && (channel->onchannel_callback != NULL)) { channel->onchannel_callback(channel->channel_callback_context); } else { pr_err("channel not found for relid - %u\n", relid); } + spin_unlock_irqrestore(&channel->inbound_lock, flags); } /* diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 9828f0b5960..e4cc40a3bd8 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -62,9 +62,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) static struct netvsc_device *get_inbound_net_device(struct hv_device *device) { struct netvsc_device *net_device; - unsigned long flags; - spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device = device->ext; if (!net_device) @@ -75,7 +73,6 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device) net_device = NULL; get_in_err: - spin_unlock_irqrestore(&device->channel->inbound_lock, flags); return net_device; } diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index d575bc92ffc..3686d1048e3 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -352,9 +352,7 @@ static inline struct storvsc_device *get_in_stor_device( struct hv_device *device) { struct storvsc_device *stor_device; - unsigned long flags; - spin_lock_irqsave(&device->channel->inbound_lock, flags); stor_device = (struct storvsc_device *)device->ext; if (!stor_device) @@ -370,7 +368,6 @@ static inline struct storvsc_device *get_in_stor_device( stor_device = NULL; get_in_err: - spin_unlock_irqrestore(&device->channel->inbound_lock, flags); return stor_device; } From e61ee14f0e9be1ff3d0d3e6168d47125729864c7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:34 -0700 Subject: [PATCH 0691/1519] Staging: hv: Fix a bug in vmbus_match() The recent checkin that add a private pointer to hv_vmbus_device_id introduced this bug in vmbus_match; fix it. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index be62b6244e3..51002c0523a 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -273,7 +273,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) for (; !is_null_guid(id_array->guid); id_array++) if (!memcmp(&id_array->guid, &hv_dev->dev_type.b, - sizeof(struct hv_vmbus_device_id))) + sizeof(uuid_le))) return 1; return 0; From ae4636e6c0d1d8d326f38586121478d7b32150b7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:35 -0700 Subject: [PATCH 0692/1519] Staging: hv: vmbus: Get rid of vmbus_on_isr() by inlining the code Get rid of vmbus_on_isr() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 45 +++++++++++----------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 51002c0523a..5dcc8c31eb7 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -437,53 +437,36 @@ static void vmbus_on_msg_dpc(unsigned long data) } } -/* - * vmbus_on_isr - ISR routine - */ -static int vmbus_on_isr(void) +static irqreturn_t vmbus_isr(int irq, void *dev_id) { - int ret = 0; int cpu = smp_processor_id(); void *page_addr; struct hv_message *msg; union hv_synic_event_flags *event; + bool handled = false; page_addr = hv_context.synic_message_page[cpu]; msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; /* Check if there are actual msgs to be process */ - if (msg->header.message_type != HVMSG_NONE) - ret |= 0x1; + if (msg->header.message_type != HVMSG_NONE) { + handled = true; + tasklet_schedule(&msg_dpc); + } page_addr = hv_context.synic_event_page[cpu]; event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; /* Since we are a child, we only need to check bit 0 */ - if (sync_test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) - ret |= 0x2; - - return ret; -} - - -static irqreturn_t vmbus_isr(int irq, void *dev_id) -{ - int ret; - - ret = vmbus_on_isr(); - - /* Schedules a dpc if necessary */ - if (ret > 0) { - if (test_bit(0, (unsigned long *)&ret)) - tasklet_schedule(&msg_dpc); - - if (test_bit(1, (unsigned long *)&ret)) - tasklet_schedule(&event_dpc); - - return IRQ_HANDLED; - } else { - return IRQ_NONE; + if (sync_test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) { + handled = true; + tasklet_schedule(&event_dpc); } + + if (handled) + return IRQ_HANDLED; + else + return IRQ_NONE; } /* From 93511baa06437785758be98ee7a7149c49c8e9c5 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:37 -0700 Subject: [PATCH 0693/1519] Staging: hv: vmbus: Do not enable auto eoi Linux interrupt handling code generates the eoi; don't enable auto eoi. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index 736794ef787..06f1e158c27 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -369,7 +369,7 @@ void hv_synic_init(void *irqarg) shared_sint.as_uint64 = 0; shared_sint.vector = irq_vector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */ shared_sint.masked = false; - shared_sint.auto_eoi = true; + shared_sint.auto_eoi = false; wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); From 0a4425b65dcdb3dc767c05308dd1078ef86e914c Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:38 -0700 Subject: [PATCH 0694/1519] Staging: hv: vmbus: Fixup indentation in vmbus_acpi_add() Fixup indentation in vmbus_acpi_add(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 5dcc8c31eb7..ed18488c591 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -678,9 +678,8 @@ static int vmbus_acpi_add(struct acpi_device *device) hv_acpi_dev = device; - result = - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - vmbus_walk_resources, &irq); + result = acpi_walk_resources(device->handle, METHOD_NAME__CRS, + vmbus_walk_resources, &irq); if (ACPI_FAILURE(result)) { complete(&probe_event); From 0bce28b62e1927565566f8a1a7f127d196b87039 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:39 -0700 Subject: [PATCH 0695/1519] Staging: hv: vmbus: Get rid of some dated/redundant comments Get rid of some dated/redundant comments in vmbus_drv.c Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index ed18488c591..757943b5d40 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -391,9 +391,6 @@ static void vmbus_onmessage_work(struct work_struct *work) kfree(ctx); } -/* - * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior - */ static void vmbus_on_msg_dpc(unsigned long data) { int cpu = smp_processor_id(); @@ -490,16 +487,13 @@ static int vmbus_bus_init(int irq) return ret; } - /* Initialize the bus context */ tasklet_init(&msg_dpc, vmbus_on_msg_dpc, 0); tasklet_init(&event_dpc, vmbus_on_event, 0); - /* Now, register the bus with LDM */ ret = bus_register(&hv_bus); if (ret) return ret; - /* Get the interrupt resource */ ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM, driver_name, hv_acpi_dev); @@ -588,7 +582,6 @@ struct hv_device *vmbus_child_device_create(uuid_le *type, { struct hv_device *child_device_obj; - /* Allocate the new child device */ child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL); if (!child_device_obj) { pr_err("Unable to allocate device object for child device\n"); @@ -613,12 +606,10 @@ int vmbus_child_device_register(struct hv_device *child_device_obj) static atomic_t device_num = ATOMIC_INIT(0); - /* Set the device name. Otherwise, device_register() will fail. */ dev_set_name(&child_device_obj->device, "vmbus_0_%d", atomic_inc_return(&device_num)); - /* The new device belongs to this bus */ - child_device_obj->device.bus = &hv_bus; /* device->dev.bus; */ + child_device_obj->device.bus = &hv_bus; child_device_obj->device.parent = &hv_acpi_dev->dev; child_device_obj->device.release = vmbus_device_release; From c2ec81cb3e9d6cb6d819155883684d94fab005ad Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:41 -0700 Subject: [PATCH 0696/1519] Staging: hv: vmbus: Get rid of an unnecessary check in vmbus_connect() Get rid of an unnecessary check in vmbus_connect(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/connection.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 6aab802ba99..ca92ca34261 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -50,10 +50,6 @@ int vmbus_connect(void) struct vmbus_channel_initiate_contact *msg; unsigned long flags; - /* Make sure we are not connecting or connected */ - if (vmbus_connection.conn_state != DISCONNECTED) - return -EISCONN; - /* Initialize the vmbus connection */ vmbus_connection.conn_state = CONNECTING; vmbus_connection.work_queue = create_workqueue("hv_vmbus_con"); From b737b2e00d99a4c07ba3e50d2f5b154addfe7c76 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:42 -0700 Subject: [PATCH 0697/1519] Staging: hv: vmbus: Fix a checkpatch warning in ring_buffer.c Fix a checkpatch warning in ring_buffer.c Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/ring_buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index 9212699a663..70e2e66fec7 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -34,7 +34,8 @@ /* Amount of space to write to */ -#define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) +#define BYTES_AVAIL_TO_WRITE(r, w, z) \ + ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) /* From d9add43b485538bd1e6c52d8177231ae31143265 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:43 -0700 Subject: [PATCH 0698/1519] Staging: hv: vmbus: Fix checkpatch warnings in connection.c Fix checkpatch warnings in connection.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/connection.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index ca92ca34261..9e99c044b23 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -220,11 +220,11 @@ static void process_chn_event(u32 relid) channel = relid2channel(relid); spin_lock_irqsave(&channel->inbound_lock, flags); - if (channel && (channel->onchannel_callback != NULL)) { + if (channel && (channel->onchannel_callback != NULL)) channel->onchannel_callback(channel->channel_callback_context); - } else { + else pr_err("channel not found for relid - %u\n", relid); - } + spin_unlock_irqrestore(&channel->inbound_lock, flags); } @@ -246,16 +246,17 @@ void vmbus_on_event(unsigned long data) if (!recv_int_page[dword]) continue; for (bit = 0; bit < 32; bit++) { - if (sync_test_and_clear_bit(bit, (unsigned long *)&recv_int_page[dword])) { + if (sync_test_and_clear_bit(bit, + (unsigned long *)&recv_int_page[dword])) { relid = (dword << 5) + bit; - if (relid == 0) { + if (relid == 0) /* * Special case - vmbus * channel protocol msg */ continue; - } + process_chn_event(relid); } } From bb5da491ffd48f7e401da364d4fb0577ce0e9939 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sat, 27 Aug 2011 11:31:44 -0700 Subject: [PATCH 0699/1519] Staging: hv: mousevsc: Fix checkpatch errors and warnings Fix checkpatch errors and warnings. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 090736af8df..dbb04ee4e96 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -335,7 +335,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL); if (!input_device->hid_desc) { - pr_err("unable to allocate hid descriptor - size %d", desc->bLength); + pr_err("unable to allocate hid descriptor - size %d", + desc->bLength); goto cleanup; } @@ -598,12 +599,12 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) pr_info("synthhid protocol request..."); ret = vmbus_sendpacket(device->channel, request, - sizeof(struct pipe_prt_msg) - - sizeof(unsigned char) + - sizeof(struct synthhid_protocol_request), - (unsigned long)request, - VM_PKT_DATA_INBAND, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + sizeof(struct pipe_prt_msg) - + sizeof(unsigned char) + + sizeof(struct synthhid_protocol_request), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { pr_err("unable to send synthhid protocol request."); goto cleanup; From 7f9615e6f6c703c68f84460fe22b858be6c258d1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 27 Aug 2011 14:06:07 +0300 Subject: [PATCH 0700/1519] Staging: hv: netvsc: return negative error codes There was a typo here and we changed the -ENOMEM into +ENOMEM. The error codes aren't used, so this is just a cleanup. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index e4cc40a3bd8..30d31395285 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -125,7 +125,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) if (ret != 0) { dev_err(&net_device->dev->device, "unable to teardown receive buffer's gpadl"); - return -ret; + return ret; } net_device->recv_buf_gpadl_handle = 0; } From 6d15059fd0fbff6f5f3dc56de7758e53b4e99fac Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:36 +0100 Subject: [PATCH 0701/1519] staging: et131x: Further tidy up of 131x_pci_setup() * Removed unused bool variable. * Eliminated mid-function returns, used gotos instead Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_initpci.c | 58 ++++++++++++------------- drivers/staging/et131x/et131x_netdev.c | 2 +- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 072cfb52a65..813a72ffa9d 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -512,10 +512,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, struct et131x_adapter *adapter; - /* Setup the fundamental net_device and private adapter structure - * elements */ - SET_NETDEV_DEV(netdev, &pdev->dev); - /* Allocate private adapter struct and copy in relevant information */ adapter = netdev_priv(netdev); adapter->pdev = pci_dev_get(pdev); @@ -579,33 +575,29 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, static int __devinit et131x_pci_setup(struct pci_dev *pdev, const struct pci_device_id *ent) { - int result = -EBUSY; + int result; int pm_cap; - bool pci_using_dac; struct net_device *netdev; struct et131x_adapter *adapter; /* Enable the device via the PCI subsystem */ - if (pci_enable_device(pdev) != 0) { - dev_err(&pdev->dev, - "pci_enable_device() failed\n"); - return -EIO; + result = pci_enable_device(pdev); + if (result) { + dev_err(&pdev->dev, "pci_enable_device() failed\n"); + goto err_out; } /* Perform some basic PCI checks */ if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { - dev_err(&pdev->dev, - "Can't find PCI device's base address\n"); + dev_err(&pdev->dev, "Can't find PCI device's base address\n"); goto err_disable; } if (pci_request_regions(pdev, DRIVER_NAME)) { - dev_err(&pdev->dev, - "Can't get PCI resources\n"); + dev_err(&pdev->dev, "Can't get PCI resources\n"); goto err_disable; } - /* Enable PCI bus mastering */ pci_set_master(pdev); /* Query PCI for Power Mgmt Capabilities @@ -614,7 +606,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, * needed? */ pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); - if (pm_cap == 0) { + if (!pm_cap) { dev_err(&pdev->dev, "Cannot find Power Management capabilities\n"); result = -EIO; @@ -623,37 +615,42 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Check the DMA addressing support of this device */ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { - pci_using_dac = true; - result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); - if (result != 0) { + if (result) { dev_err(&pdev->dev, - "Unable to obtain 64 bit DMA for consistent allocations\n"); + "Unable to obtain 64 bit DMA for consistent allocations\n"); goto err_release_res; } } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - pci_using_dac = false; + result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (result) { + dev_err(&pdev->dev, + "Unable to obtain 32 bit DMA for consistent allocations\n"); + goto err_release_res; + } } else { - dev_err(&pdev->dev, - "No usable DMA addressing method\n"); + dev_err(&pdev->dev, "No usable DMA addressing method\n"); result = -EIO; goto err_release_res; } /* Allocate netdev and private adapter structs */ netdev = et131x_device_alloc(); - if (netdev == NULL) { + if (!netdev) { dev_err(&pdev->dev, "Couldn't alloc netdev struct\n"); result = -ENOMEM; goto err_release_res; } + + SET_NETDEV_DEV(netdev, &pdev->dev); + adapter = et131x_adapter_init(netdev, pdev); /* Initialise the PCI setup for the device */ et131x_pci_init(adapter, pdev); /* Map the bus-relative registers to system virtual memory */ adapter->regs = pci_ioremap_bar(pdev, 0); - if (adapter->regs == NULL) { + if (!adapter->regs) { dev_err(&pdev->dev, "Cannot map device registers\n"); result = -ENOMEM; goto err_free_dev; @@ -670,7 +667,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Allocate DMA memory */ result = et131x_adapter_memory_alloc(adapter); - if (result != 0) { + if (result) { dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n"); goto err_iounmap; } @@ -678,9 +675,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Init send data structures */ et131x_init_send(adapter); - /* - * Set up the task structure for the ISR's deferred handler - */ + /* Set up the task structure for the ISR's deferred handler */ INIT_WORK(&adapter->task, et131x_isr_handler); /* Copy address into the net_device struct */ @@ -699,8 +694,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Initialize link state */ netif_carrier_off(adapter->netdev); - /* Initialize variable for counting how long we do not have - link status */ + /* Init variable for counting how long we do not have link status */ adapter->boot_coma = 0; /* We can enable interrupts now @@ -723,6 +717,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, */ pci_set_drvdata(pdev, netdev); pci_save_state(adapter->pdev); + return result; err_mem_free: @@ -736,6 +731,7 @@ err_release_res: pci_release_regions(pdev); err_disable: pci_disable_device(pdev); +err_out: return result; } diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 7555a241ed2..20df1454117 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -687,7 +687,7 @@ struct net_device *et131x_device_alloc(void) /* Alloc net_device and adapter structs */ netdev = alloc_etherdev(sizeof(struct et131x_adapter)); - if (netdev == NULL) { + if (!netdev) { printk(KERN_ERR "et131x: Alloc of net_device struct failed\n"); return NULL; } From 8dc2bbe72ec31469286027ebce6a00f05ef38a9f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:37 +0100 Subject: [PATCH 0702/1519] MAINAINERS: Add details for drivers/staging/et131x Adding myself as a maintainer for this driver, as I appear to have been the only interested party for some time. Not sure if Olaf Hartman is still interested? So will leave it up to him to add his name to the list. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1a8cc600067..4f00a54ba34 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6172,6 +6172,11 @@ M: David Rowe S: Odd Fixes F: drivers/staging/echo/ +STAGING - ET131X NETWORK DRIVER +M: Mark Einon +S: Odd Fixes +F: drivers/staging/et131x/ + STAGING - FLARION FT1000 DRIVERS M: Marek Belisko S: Odd Fixes From 4a334d898a5cdbbe6d7a923a5106526ea82a9ffc Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:38 +0100 Subject: [PATCH 0703/1519] staging: et131x: Remove unused xcvr_id in struct ce_stats xcvr_id holds the phy ID which is stored but never used in the driver. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 4 ---- drivers/staging/et131x/et131x_adapter.h | 1 - 2 files changed, 5 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index c845c27f23d..21e07042795 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -242,7 +242,6 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) u8 xcvr_addr; u16 idr1; u16 idr2; - u32 xcvr_id; /* We need to get xcvr id and address we just get the first one */ for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) { @@ -254,10 +253,7 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) (u8) offsetof(struct mi_regs, idr2), &idr2); - xcvr_id = (u32) ((idr1 << 16) | idr2); - if (idr1 != 0 && idr1 != 0xffff) { - adapter->stats.xcvr_id = xcvr_id; adapter->stats.xcvr_addr = xcvr_addr; return 0; } diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 762e07ca3ee..b03460bbb29 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -115,7 +115,6 @@ struct ce_stats { /* Transceiver state informations. */ u8 xcvr_addr; - u32 xcvr_id; /* Tx Statistics. */ u32 tx_underflows; From 694bd60383318ebb19b94303781456739ad579b2 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:39 +0100 Subject: [PATCH 0704/1519] staging: et131x: Remove redundant replica loopback code A mechanism used to set the phy in loopback mode is not present in the driver, making associated checks and variables redundant. Removing them. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_address_map.h | 6 +++--- drivers/staging/et131x/et1310_rx.c | 11 ----------- drivers/staging/et131x/et131x_adapter.h | 4 ---- drivers/staging/et131x/et131x_isr.c | 16 +++++++--------- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h index 410677ee22b..38ec56c1298 100644 --- a/drivers/staging/et131x/et1310_address_map.h +++ b/drivers/staging/et131x/et1310_address_map.h @@ -1,6 +1,6 @@ /* * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs + * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved. @@ -149,7 +149,7 @@ * GLOBAL Module of JAGCore Address Mapping * Located at address 0x0000 */ -struct global_regs { /* Location: */ +struct global_regs { /* Location: */ u32 txq_start_addr; /* 0x0000 */ u32 txq_end_addr; /* 0x0004 */ u32 rxq_start_addr; /* 0x0008 */ @@ -163,7 +163,7 @@ struct global_regs { /* Location: */ u32 sw_reset; /* 0x0028 */ u32 slv_timer; /* 0x002C */ u32 msi_config; /* 0x0030 */ - u32 loopback; /* 0x0034 */ + u32 loopback; /* 0x0034 */ u32 watchdog_timer; /* 0x0038 */ }; diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index e6458dbef93..f50420c582a 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -988,17 +988,6 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) } if (len) { - if (adapter->replica_phy_loopbk == 1) { - buf = rx_local->fbr[ring_index]->virt[buff_index]; - - if (memcmp(&buf[6], adapter->addr, ETH_ALEN) == 0) { - if (memcmp(&buf[42], "Replica packet", - ETH_HLEN)) { - adapter->replica_phy_loopbk_passfail = 1; - } - } - } - /* Determine if this is a multicast packet coming in */ if ((word0 & ALCATEL_MULTICAST_PKT) && !(word0 & ALCATEL_BROADCAST_PKT)) { diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index b03460bbb29..508cc632ad8 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -222,10 +222,6 @@ struct et131x_adapter { /* Rx Memory Variables */ struct rx_ring rx_ring; - /* Loopback specifics */ - u8 replica_phy_loopbk; /* Replica Enable */ - u8 replica_phy_loopbk_passfail; /* Replica Enable Pass/Fail */ - /* Stats */ struct ce_stats stats; diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 7cfd213fb13..4d75690e7af 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -389,17 +389,15 @@ void et131x_isr_handler(struct work_struct *work) (uint8_t) offsetof(struct mi_regs, isr), &myisr); - if (!adapter->replica_phy_loopbk) { - et131x_mii_read(adapter, - (uint8_t) offsetof(struct mi_regs, bmsr), - &bmsr_data); + et131x_mii_read(adapter, + (uint8_t) offsetof(struct mi_regs, bmsr), + &bmsr_data); - bmsr_ints = adapter->bmsr ^ bmsr_data; - adapter->bmsr = bmsr_data; + bmsr_ints = adapter->bmsr ^ bmsr_data; + adapter->bmsr = bmsr_data; - /* Do all the cable in / cable out stuff */ - et131x_mii_check(adapter, bmsr_data, bmsr_ints); - } + /* Do all the cable in / cable out stuff */ + et131x_mii_check(adapter, bmsr_data, bmsr_ints); } /* Let's move on to the TxMac */ From fca7737f5c4bdf11f5a62bf7d79c9c60f15ceaff Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:40 +0100 Subject: [PATCH 0705/1519] staging: et131x: Remove module_param et131x_speed_set Manual setting of speed/duplex will be achieved using ethtool. Remove the driver specific module_param that also does this. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_initpci.c | 50 +------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 813a72ffa9d..a184ac1669e 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -1,6 +1,6 @@ /* * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs + * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved. @@ -97,30 +97,6 @@ #define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */ #define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ -/* Defines for Parameter Default/Min/Max vaules */ -#define PARM_SPEED_DUPLEX_MIN 0 -#define PARM_SPEED_DUPLEX_MAX 5 - -/* Module parameter for manual speed setting - * Set Link speed and dublex manually (0-5) [0] - * 1 : 10Mb Half-Duplex - * 2 : 10Mb Full-Duplex - * 3 : 100Mb Half-Duplex - * 4 : 100Mb Full-Duplex - * 5 : 1000Mb Full-Duplex - * 0 : Auto Speed Auto Duplex // default - */ -static u32 et131x_speed_set; -module_param(et131x_speed_set, uint, 0); -MODULE_PARM_DESC(et131x_speed_set, - "Set Link speed and dublex manually (0-5) [0]\n" - "1 : 10Mb Half-Duplex\n" - "2 : 10Mb Full-Duplex\n" - "3 : 100Mb Half-Duplex\n" - "4 : 100Mb Full-Duplex\n" - "5 : 1000Mb Full-Duplex\n" - "0 : Auto Speed Auto Dublex"); - /** * et131x_hwaddr_init - set up the MAC Address on the ET1310 * @adapter: pointer to our private adapter structure @@ -531,29 +507,12 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, spin_lock_init(&adapter->fbr_lock); spin_lock_init(&adapter->phy_lock); - /* Parse configuration parameters into the private adapter struct */ - if (et131x_speed_set) - dev_info(&adapter->pdev->dev, - "Speed set manually to : %d\n", et131x_speed_set); - - adapter->speed_duplex = et131x_speed_set; + adapter->speed_duplex = 0; /* Auto Speed Auto Duplex */ adapter->registry_jumbo_packet = 1514; /* 1514-9216 */ /* Set the MAC address to a default */ memcpy(adapter->addr, default_mac, ETH_ALEN); - /* Decode speed_duplex - * - * Set up as if we are auto negotiating always and then change if we - * go into force mode - * - * If we are the 10/100 device, and gigabit is somehow requested then - * knock it down to 100 full. - */ - if (adapter->pdev->device == ET131X_PCI_DEVICE_ID_FAST && - adapter->speed_duplex == 5) - adapter->speed_duplex = 4; - adapter->ai_force_speed = speed[adapter->speed_duplex]; adapter->ai_force_duplex = duplex[adapter->speed_duplex]; /* Auto FDX */ @@ -790,11 +749,6 @@ static struct pci_driver et131x_driver = { */ static int __init et131x_init_module(void) { - if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN || - et131x_speed_set > PARM_SPEED_DUPLEX_MAX) { - printk(KERN_WARNING "et131x: invalid speed setting ignored.\n"); - et131x_speed_set = 0; - } return pci_register_driver(&et131x_driver); } From 0f18f767e5f9a4c5a9fa976df168d0f3e33c91da Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 29 Aug 2011 18:42:41 +0100 Subject: [PATCH 0706/1519] staging: et131x: Use phy-device, mii_bus and ethtool_ops Adding some basic ethtool ops and supporting functionality using a phy device. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/Makefile | 1 + drivers/staging/et131x/et1310_phy.c | 45 ++++++-- drivers/staging/et131x/et1310_phy.h | 4 +- drivers/staging/et131x/et131x.h | 6 + drivers/staging/et131x/et131x_adapter.h | 3 +- drivers/staging/et131x/et131x_ethtool.c | 71 ++++++++++++ drivers/staging/et131x/et131x_initpci.c | 147 +++++++++++++++++++++--- drivers/staging/et131x/et131x_netdev.c | 7 +- 8 files changed, 254 insertions(+), 30 deletions(-) create mode 100644 drivers/staging/et131x/et131x_ethtool.c diff --git a/drivers/staging/et131x/Makefile b/drivers/staging/et131x/Makefile index dfcd2bfcb94..5ea0272fc7a 100644 --- a/drivers/staging/et131x/Makefile +++ b/drivers/staging/et131x/Makefile @@ -11,5 +11,6 @@ et131x-y := et1310_eeprom.o \ et1310_rx.o \ et1310_tx.o \ et131x_initpci.o \ + et131x_ethtool.o \ et131x_isr.o \ et131x_netdev.o diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 21e07042795..5e21a180af9 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -1,6 +1,6 @@ /* * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs + * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright * 2005 Agere Systems Inc. * All rights reserved. @@ -82,6 +82,7 @@ #include #include #include +#include #include "et1310_phy.h" @@ -93,6 +94,40 @@ #include "et131x.h" +int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + u16 value; + int ret; + + ret = et131x_phy_mii_read(adapter, phy_addr, reg, &value); + + if (ret < 0) + return ret; + else + return value; +} + +int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* mii_write always uses the same phy_addr, xcvr_addr */ + return et131x_mii_write(adapter, reg, value); +} + +int et131x_mdio_reset(struct mii_bus *bus) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + + et1310_phy_reset(adapter); + + return 0; +} + /** * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC * @adapter: pointer to our private adapter structure @@ -107,7 +142,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, { struct mac_regs __iomem *mac = &adapter->regs->mac; int status = 0; - u32 delay; + u32 delay = 0; u32 mii_addr; u32 mii_cmd; u32 mii_indicator; @@ -124,9 +159,6 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, /* Set up the register we need to read from on the correct PHY */ writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); - /* Kick the read cycle off */ - delay = 0; - writel(0x1, &mac->mii_mgmt_cmd); do { @@ -176,7 +208,7 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) struct mac_regs __iomem *mac = &adapter->regs->mac; int status = 0; u8 xcvr_addr = adapter->stats.xcvr_addr; - u32 delay; + u32 delay = 0; u32 mii_addr; u32 mii_cmd; u32 mii_indicator; @@ -195,7 +227,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) /* Add the value to write to the registers to the mac */ writel(value, &mac->mii_mgmt_ctrl); - delay = 0; do { udelay(50); diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 6b38a3e0cab..8e9404e1473 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -121,8 +121,8 @@ struct mi_regs { u8 imr; /* Interrupt Mask Reg(Reg 0x18) */ u8 isr; /* Interrupt Status Reg(Reg 0x19) */ u8 psr; /* PHY Status Reg(Reg 0x1A) */ - u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */ - u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */ + u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */ + u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */ u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ }; diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 91fafc0331e..9dee7bce073 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -116,6 +116,10 @@ int32_t et131x_mii_write(struct et131x_adapter *adapter, void et131x_mii_check(struct et131x_adapter *pAdapter, u16 bmsr, u16 bmsr_ints); +int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg); +int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value); +int et131x_mdio_reset(struct mii_bus *bus); + /* et1310_rx.c */ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter); void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); @@ -145,3 +149,5 @@ void et131x_handle_send_interrupt(struct et131x_adapter *adapter); void et131x_free_busy_send_packets(struct et131x_adapter *adapter); int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev); +/* et131x_ethtool.c */ +void et131x_set_ethtool_ops(struct net_device *netdev); diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 508cc632ad8..dbb14fed2dd 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -144,7 +144,8 @@ struct ce_stats { struct et131x_adapter { struct net_device *netdev; struct pci_dev *pdev; - + struct mii_bus *mii_bus; + struct phy_device *phydev; struct work_struct task; /* Flags that indicate current state of the adapter */ diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c new file mode 100644 index 00000000000..d980ad6c552 --- /dev/null +++ b/drivers/staging/et131x/et131x_ethtool.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011 Mark Einon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Mark Einon + */ +#include "et131x_version.h" +#include "et131x_defs.h" + +#include +#include +#include +#include +#include +#include + +#include "et131x_adapter.h" +#include "et131x.h" + +static int et131x_get_settings(struct net_device *netdev, + struct ethtool_cmd *cmd) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + return phy_ethtool_gset(adapter->phydev, cmd); +} + +static int et131x_set_settings(struct net_device *netdev, + struct ethtool_cmd *cmd) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + return phy_ethtool_sset(adapter->phydev, cmd); +} + +#define ET131X_DRVINFO_LEN 32 /* value from ethtool.h */ +static void et131x_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *info) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + strncpy(info->driver, DRIVER_NAME, ET131X_DRVINFO_LEN); + strncpy(info->version, DRIVER_VERSION_STRING, ET131X_DRVINFO_LEN); + strncpy(info->bus_info, pci_name(adapter->pdev), ET131X_DRVINFO_LEN); +} + +static struct ethtool_ops et131x_ethtool_ops = { + .get_settings = et131x_get_settings, + .set_settings = et131x_set_settings, + .get_drvinfo = et131x_get_drvinfo, + .get_link = ethtool_op_get_link, +}; + +void et131x_set_ethtool_ops(struct net_device *netdev) +{ + SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops); +} + diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index a184ac1669e..fbbef7627bc 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -80,6 +80,7 @@ #include #include +#include #include #include #include @@ -329,7 +330,7 @@ void et131x_configure_global_regs(struct et131x_adapter *adapter) */ int et131x_adapter_setup(struct et131x_adapter *adapter) { - int status = 0; + int status; /* Configure the JAGCore */ et131x_configure_global_regs(adapter); @@ -351,7 +352,7 @@ int et131x_adapter_setup(struct et131x_adapter *adapter) /* Move the following code to Timer function?? */ status = et131x_xcvr_find(adapter); - if (status != 0) + if (status) dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n"); /* Prepare the TRUEPHY library. */ @@ -471,6 +472,80 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) et131x_rx_dma_memory_free(adapter); } +static void et131x_adjust_link(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev = adapter->phydev; + struct address_map __iomem *iomem = adapter->regs; + + u32 pm_csr; + u16 bmsr_ints; + u16 bmsr_data; + + /* If we are in coma mode, we need to disable it. */ + pm_csr = readl(&iomem->global.pm_csr); + if (pm_csr & ET_PM_PHY_SW_COMA) { + /* + * Check to see if we are in coma mode and if + * so, disable it because we will not be able + * to read PHY values until we are out. + */ + et1310_disable_phy_coma(adapter); + } + + et131x_mii_read(adapter, + (uint8_t) offsetof(struct mi_regs, bmsr), + &bmsr_data); + + bmsr_ints = adapter->bmsr ^ bmsr_data; + adapter->bmsr = bmsr_data; + + /* Do all the cable in / cable out stuff */ + et131x_mii_check(adapter, bmsr_data, bmsr_ints); + + phy_print_status(phydev); +} + +int et131x_mii_probe(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev = NULL; + + phydev = phy_find_first(adapter->mii_bus); + if (!phydev) { + dev_err(&adapter->pdev->dev, "no PHY found\n"); + return -ENODEV; + } + + phydev = phy_connect(netdev, dev_name(&phydev->dev), + &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII); + + if(IS_ERR(phydev)) { + dev_err(&adapter->pdev->dev, "Could not attach to PHY\n"); + return PTR_ERR(phydev); + } + + phydev->supported &= (SUPPORTED_10baseT_Half + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_Autoneg + | SUPPORTED_MII + | SUPPORTED_TP); + + if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) + phydev->supported |= SUPPORTED_1000baseT_Full; + + phydev->advertising = phydev->supported; + adapter->phydev = phydev; + + dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " + "(mii_bus:phy_addr=%s)\n", + phydev->drv->name, dev_name(&phydev->dev)); + + return 0; +} + /** * et131x_adapter_init * @adapter: pointer to the private adapter struct @@ -538,8 +613,8 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, int pm_cap; struct net_device *netdev; struct et131x_adapter *adapter; + int ii; - /* Enable the device via the PCI subsystem */ result = pci_enable_device(pdev); if (result) { dev_err(&pdev->dev, "pci_enable_device() failed\n"); @@ -602,8 +677,10 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, } SET_NETDEV_DEV(netdev, &pdev->dev); + et131x_set_ethtool_ops(netdev); adapter = et131x_adapter_init(netdev, pdev); + /* Initialise the PCI setup for the device */ et131x_pci_init(adapter, pdev); @@ -650,11 +727,43 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, adapter->error_timer.function = et131x_error_timer_handler; adapter->error_timer.data = (unsigned long)adapter; - /* Initialize link state */ - netif_carrier_off(adapter->netdev); - /* Init variable for counting how long we do not have link status */ adapter->boot_coma = 0; + et1310_disable_phy_coma(adapter); + + /* Setup the mii_bus struct */ + adapter->mii_bus = mdiobus_alloc(); + if (!adapter->mii_bus) { + dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); + goto err_mem_free; + } + + adapter->mii_bus->name = "et131x_eth_mii"; + snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", + (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); + adapter->mii_bus->priv = netdev; + adapter->mii_bus->read = et131x_mdio_read; + adapter->mii_bus->write = et131x_mdio_write; + adapter->mii_bus->reset = et131x_mdio_reset; + adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); + if (!adapter->mii_bus->irq) { + dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); + goto err_mdio_free; + } + + for (ii = 0; ii < PHY_MAX_ADDR; ii++) + adapter->mii_bus->irq[ii] = PHY_POLL; + + if (mdiobus_register(adapter->mii_bus)) { + dev_err(&pdev->dev, "failed to register MII bus\n"); + mdiobus_free(adapter->mii_bus); + goto err_mdio_free_irq; + } + + if (et131x_mii_probe(netdev)) { + dev_err(&pdev->dev, "failed to probe MII bus\n"); + goto err_mdio_unregister; + } /* We can enable interrupts now * @@ -667,7 +776,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, result = register_netdev(netdev); if (result != 0) { dev_err(&pdev->dev, "register_netdev() failed\n"); - goto err_mem_free; + goto err_mdio_unregister; } /* Register the net_device struct with the PCI subsystem. Save a copy @@ -679,6 +788,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, return result; +err_mdio_unregister: + mdiobus_unregister(adapter->mii_bus); +err_mdio_free_irq: + kfree(adapter->mii_bus->irq); +err_mdio_free: + mdiobus_free(adapter->mii_bus); err_mem_free: et131x_adapter_memory_free(adapter); err_iounmap: @@ -704,20 +819,18 @@ err_out: */ static void __devexit et131x_pci_remove(struct pci_dev *pdev) { - struct net_device *netdev; - struct et131x_adapter *adapter; + struct net_device *netdev = pci_get_drvdata(pdev); + struct et131x_adapter *adapter = netdev_priv(netdev); - /* Retrieve the net_device pointer from the pci_dev struct, as well - * as the private adapter struct - */ - netdev = pci_get_drvdata(pdev); - adapter = netdev_priv(netdev); - - /* Perform device cleanup */ unregister_netdev(netdev); + mdiobus_unregister(adapter->mii_bus); + kfree(adapter->mii_bus->irq); + mdiobus_free(adapter->mii_bus); + et131x_adapter_memory_free(adapter); iounmap(adapter->regs); - pci_dev_put(adapter->pdev); + pci_dev_put(pdev); + free_netdev(netdev); pci_release_regions(pdev); pci_disable_device(pdev); diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 20df1454117..ce214339739 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -1,6 +1,6 @@ /* * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs + * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved. @@ -82,6 +82,7 @@ #include #include #include +#include #include "et1310_phy.h" #include "et1310_tx.h" @@ -167,6 +168,8 @@ int et131x_open(struct net_device *netdev) adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; + phy_start(adapter->phydev); + /* We're ready to move some data, so start the queue */ netif_start_queue(netdev); return result; @@ -699,8 +702,6 @@ struct net_device *et131x_device_alloc(void) netdev->watchdog_timeo = ET131X_TX_TIMEOUT; netdev->netdev_ops = &et131x_netdev_ops; - /* netdev->ethtool_ops = &et131x_ethtool_ops; */ - /* Poll? */ /* netdev->poll = &et131x_poll; */ /* netdev->poll_controller = &et131x_poll_controller; */ From 22f88fcf407933321d08c45520fbeffca70b05d1 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Mon, 29 Aug 2011 21:46:57 +0400 Subject: [PATCH 0707/1519] staging/easycap: fix mismatch in easycap_poll() mutex lock-unlock In case if condition (kd != isdongle(peasycap)) becomes true, easycap_poll() returns without releasing easycapdc60_dongle[kd].mutex_video. The patch adds mutex_unlock() before that return. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/easycap_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index bea281624c4..3ea51c37391 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -953,8 +953,10 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait) * peasycap, IN WHICH CASE A REPEAT CALL TO isdongle() WILL FAIL. * IF NECESSARY, BAIL OUT. */ - if (kd != isdongle(peasycap)) + if (kd != isdongle(peasycap)) { + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; + } if (!file) { SAY("ERROR: file is NULL\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video); From 7cbf3c7cd59288fb5e9f31815c74773549668d43 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Mon, 29 Aug 2011 13:48:54 -0400 Subject: [PATCH 0708/1519] staging: serqt_usb2: remove ssu100 from supported devices The serqt_usb2 driver will not work properly with the ssu100 device even though it claims to support it. The ssu100 is supported by the ssu100 driver in mainline so there is no need to have it claimed by serqt_usb2. Signed-off-by: Bill Pemberton Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/serqt_usb2/serqt_usb2.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 2ea82c104d5..c44e41af288 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -24,7 +24,6 @@ static int debug; #define DRIVER_DESC "Quatech USB to Serial Driver" #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ -#define QUATECH_SSU100 0xC020 /* SSU100 */ #define QUATECH_SSU200 0xC030 /* SSU200 */ #define QUATECH_DSU100 0xC040 /* DSU100 */ #define QUATECH_DSU200 0xC050 /* DSU200 */ @@ -127,7 +126,6 @@ static int debug; #define RS232_MODE 0x00 static const struct usb_device_id serqt_id_table[] = { - {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU100)}, {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU200)}, {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100)}, {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU200)}, @@ -775,7 +773,6 @@ static int qt_startup(struct usb_serial *serial) } switch (serial->dev->descriptor.idProduct) { - case QUATECH_SSU100: case QUATECH_DSU100: case QUATECH_QSU100: case QUATECH_ESU100A: From e1b7f9155ecaa52c4723dbcab8e95382935c9ad0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:17 +0300 Subject: [PATCH 0709/1519] staging: xgifb: delete unused module parameters and options Delete parameters which have no effect. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 2 - drivers/staging/xgifb/XGI_main_26.c | 114 ---------------------------- 2 files changed, 116 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 59f741136cf..08f62e1e274 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -171,11 +171,9 @@ static int XGIfb_off; static int XGIfb_crt1off; static int XGIfb_forcecrt1 = -1; static int XGIfb_userom ; -/*static int XGIfb_useoem = -1; */ /* global flags */ static int XGIfb_tvmode; -static int XGIfb_pdc; static int enable_dstn; static int XGIfb_ypan = -1; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 7b36b7ea464..edd9b614e20 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1984,20 +1984,11 @@ static int __init XGIfb_setup(char *options) enable_dstn = 1; /* TW: DSTN overrules forcecrt2type */ XGIfb_crt2type = DISPTYPE_LCD; - } else if (!strncmp(this_opt, "pdc:", 4)) { - XGIfb_pdc = simple_strtoul(this_opt + 4, NULL, 0); - if (XGIfb_pdc & ~0x3c) { - printk(KERN_INFO "XGIfb: Illegal pdc parameter\n"); - XGIfb_pdc = 0; - } } else if (!strncmp(this_opt, "noypan", 6)) { XGIfb_ypan = 0; } else if (!strncmp(this_opt, "userom:", 7)) { XGIfb_userom = (int)simple_strtoul( this_opt + 7, NULL, 0); - /* } else if (!strncmp(this_opt, "useoem:", 7)) { */ - /* XGIfb_useoem = (int)simple_strtoul( - this_opt + 7, NULL, 0); */ } else { XGIfb_search_mode(this_opt); /* printk(KERN_INFO "XGIfb: Invalid option %s\n", @@ -2530,57 +2521,14 @@ module_init(xgifb_init); static char *mode; static int vesa; -static unsigned int rate; -static unsigned int mem; -static char *forcecrt2type; -static int forcecrt1 = -1; -static int pdc = -1; -static int pdc1 = -1; -static int noypan = -1; -static int userom = -1; -static int useoem = -1; -static char *tvstandard; -static int nocrt2rate; -static int scalelcd = -1; -static char *specialtiming; -static int lvdshl = -1; -static int tvxposoffset, tvyposoffset; -#if !defined(__i386__) && !defined(__x86_64__) -static int resetcard; -static int videoram; -#endif MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("XGITECH , Others"); -module_param(mem, int, 0); -module_param(noypan, int, 0); -module_param(userom, int, 0); -module_param(useoem, int, 0); module_param(mode, charp, 0); module_param(vesa, int, 0); -module_param(rate, int, 0); -module_param(forcecrt1, int, 0); -module_param(forcecrt2type, charp, 0); -module_param(scalelcd, int, 0); -module_param(pdc, int, 0); -module_param(pdc1, int, 0); -module_param(specialtiming, charp, 0); -module_param(lvdshl, int, 0); -module_param(tvstandard, charp, 0); -module_param(tvxposoffset, int, 0); -module_param(tvyposoffset, int, 0); module_param(filter, int, 0); -module_param(nocrt2rate, int, 0); -#if !defined(__i386__) && !defined(__x86_64__) -module_param(resetcard, int, 0); -module_param(videoram, int, 0); -#endif - -MODULE_PARM_DESC(noypan, - "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n" - "will be performed by redrawing the screen. (default: 0)\n"); MODULE_PARM_DESC(mode, "\nSelects the desired default display mode in the format XxYxDepth,\n" @@ -2592,72 +2540,10 @@ MODULE_PARM_DESC(vesa, "\nSelects the desired default display mode by VESA defined mode number, eg.\n" "0x117 (default: 0x0103)\n"); -MODULE_PARM_DESC(rate, - "\nSelects the desired vertical refresh rate for CRT1 (external VGA) in Hz.\n" - "If the mode is specified in the format XxY-Depth@Rate, this parameter\n" - "will be ignored (default: 60)\n"); - -MODULE_PARM_DESC(forcecrt1, - "\nNormally, the driver autodetects whether or not CRT1 (external VGA) is\n" - "connected. With this option, the detection can be overridden (1=CRT1 ON,\n" - "0=CRT1 OFF) (default: [autodetected])\n"); - -MODULE_PARM_DESC(forcecrt2type, - "\nIf this option is omitted, the driver autodetects CRT2 output devices, such as\n" - "LCD, TV or secondary VGA. With this option, this autodetection can be\n" - "overridden. Possible parameters are LCD, TV, VGA or NONE. NONE disables CRT2.\n" - "On systems with a SiS video bridge, parameters SVIDEO, COMPOSITE or SCART can\n" - "be used instead of TV to override the TV detection. Furthermore, on systems\n" - "with a SiS video bridge, SVIDEO+COMPOSITE, HIVISION, YPBPR480I, YPBPR480P,\n" - "YPBPR720P and YPBPR1080I are understood. However, whether or not these work\n" - "depends on the very hardware in use. (default: [autodetected])\n"); - -MODULE_PARM_DESC(scalelcd, - "\nSetting this to 1 will force the driver to scale the LCD image to the panel's\n" - "native resolution. Setting it to 0 will disable scaling; LVDS panels will\n" - "show black bars around the image, TMDS panels will probably do the scaling\n" - "themselves. Default: 1 on LVDS panels, 0 on TMDS panels\n"); - -MODULE_PARM_DESC(pdc, - "\nThis is for manually selecting the LCD panel delay compensation. The driver\n" - "should detect this correctly in most cases; however, sometimes this is not\n" - "possible. If you see 'small waves' on the LCD, try setting this to 4, 32 or 24\n" - "on a 300 series chipset; 6 on a 315 series chipset. If the problem persists,\n" - "try other values (on 300 series: between 4 and 60 in steps of 4; on 315 series:\n" - "any value from 0 to 31). (default: autodetected, if LCD is active during start)\n"); - -MODULE_PARM_DESC(pdc1, - "\nThis is same as pdc, but for LCD-via CRT1. Hence, this is for the 315/330\n" - "series only. (default: autodetected if LCD is in LCD-via-CRT1 mode during\n" - "startup) - Note: currently, this has no effect because LCD-via-CRT1 is not\n" - "implemented yet.\n"); - -MODULE_PARM_DESC(specialtiming, - "\nPlease refer to documentation for more information on this option.\n"); - -MODULE_PARM_DESC(lvdshl, - "\nPlease refer to documentation for more information on this option.\n"); - -MODULE_PARM_DESC(tvstandard, - "\nThis allows overriding the BIOS default for the TV standard. Valid choices are\n" - "pal, ntsc, palm and paln. (default: [auto; pal or ntsc only])\n"); - -MODULE_PARM_DESC(tvxposoffset, - "\nRelocate TV output horizontally. Possible parameters: -32 through 32.\n" - "Default: 0\n"); - -MODULE_PARM_DESC(tvyposoffset, - "\nRelocate TV output vertically. Possible parameters: -32 through 32.\n" - "Default: 0\n"); - MODULE_PARM_DESC(filter, "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n" "(Possible values 0-7, default: [no filter])\n"); -MODULE_PARM_DESC(nocrt2rate, - "\nSetting this to 1 will force the driver to use the default refresh rate for\n" - "CRT2 if CRT2 type is VGA. (default: 0, use same rate as CRT1)\n"); - static int __init xgifb_init_module(void) { printk("\nXGIfb_init_module"); From 3f5042dfb4eedd11d5fbe10dda4605fe8d7890c1 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:18 +0300 Subject: [PATCH 0710/1519] staging: xgifb: fix ypan disable option Setting any of the FB options will disable ypan as a side effect. It should be disabled only by the "noypan" option. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index edd9b614e20..eca5ed74feb 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1994,10 +1994,6 @@ static int __init XGIfb_setup(char *options) /* printk(KERN_INFO "XGIfb: Invalid option %s\n", this_opt); */ } - - /* TW: Panning only with acceleration */ - XGIfb_ypan = 0; - } printk("\nxgifb: outa xgifb_setup 3450"); return 0; From 20fc30b9412013f96005e5d8de6af6c555d6650f Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:19 +0300 Subject: [PATCH 0711/1519] staging: xgifb: delete duplicated code Delete redundant branches for "mode" and "vesa" options. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index eca5ed74feb..ceb0883ebf0 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1954,11 +1954,6 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "vesa:", 5)) { XGIfb_search_vesamode(simple_strtoul( this_opt + 5, NULL, 0)); - } else if (!strncmp(this_opt, "mode:", 5)) { - XGIfb_search_mode(this_opt + 5); - } else if (!strncmp(this_opt, "vesa:", 5)) { - XGIfb_search_vesamode(simple_strtoul( - this_opt + 5, NULL, 0)); } else if (!strncmp(this_opt, "vrate:", 6)) { xgi_video_info.refresh_rate = simple_strtoul( this_opt + 6, NULL, 0); From 87c8b8b3466b7e5977701b59dc92a1b9537a46e0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:20 +0300 Subject: [PATCH 0712/1519] staging: xgifb: delete "off" option handling It's possible to disable the built-in xgifb driver with the kernel command line option: video=xgifb:off This is already handled by the generic framebuffer layer (fb_get_options() will return TRUE resulting in init failure), so no need to process the option in the driver. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 08f62e1e274..b65ed6e6b81 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -167,7 +167,6 @@ static u32 pseudo_palette[17]; /* display status */ -static int XGIfb_off; static int XGIfb_crt1off; static int XGIfb_forcecrt1 = -1; static int XGIfb_userom ; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index ceb0883ebf0..442774508d2 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1960,8 +1960,6 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "rate:", 5)) { xgi_video_info.refresh_rate = simple_strtoul( this_opt + 5, NULL, 0); - } else if (!strncmp(this_opt, "off", 3)) { - XGIfb_off = 1; } else if (!strncmp(this_opt, "crt1off", 7)) { XGIfb_crt1off = 1; } else if (!strncmp(this_opt, "filter:", 7)) { @@ -2023,9 +2021,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, u8 CR48, CR38; int ret; - if (XGIfb_off) - return -ENXIO; - memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); if (!fb_info) From 79bea04cc963c018eb39e85776c1d2b30f9d2f68 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:21 +0300 Subject: [PATCH 0713/1519] staging: xgifb: XGIfb_setup(): clean up driver messages Print options only if they are given. Delete other messages. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 442774508d2..2a5227290bf 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1939,11 +1939,11 @@ static int __init XGIfb_setup(char *options) xgi_video_info.refresh_rate = 0; - printk(KERN_INFO "XGIfb: Options %s\n", options); - if (!options || !*options) return 0; + pr_info("xgifb: options: %s\n", options); + while ((this_opt = strsep(&options, ",")) != NULL) { if (!*this_opt) @@ -1984,11 +1984,8 @@ static int __init XGIfb_setup(char *options) this_opt + 7, NULL, 0); } else { XGIfb_search_mode(this_opt); - /* printk(KERN_INFO "XGIfb: Invalid option %s\n", - this_opt); */ } } - printk("\nxgifb: outa xgifb_setup 3450"); return 0; } From 7b0a95f89cdfa831995d14cf4fd97cbd0ee80460 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:22 +0300 Subject: [PATCH 0714/1519] staging: xgifb: XGIfb_setup(): delete redundant assignment The global data is already initialized to zero. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 2a5227290bf..2e930257fdf 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1937,8 +1937,6 @@ static int __init XGIfb_setup(char *options) { char *this_opt; - xgi_video_info.refresh_rate = 0; - if (!options || !*options) return 0; From d27c6bc9f4f4250b006b26ee4458b416676580b7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:23 +0300 Subject: [PATCH 0715/1519] staging: xgifb: check and report invalid option values Check option values with kstrtoul(). This will also eliminate some checkpatch warnings about simple_strtoul() usage. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 2e930257fdf..80716874eda 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1933,6 +1933,17 @@ static void XGIfb_get_VB_type(void) } } +static int __init xgifb_optval(char *fullopt, int validx) +{ + unsigned long lres; + + if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) { + pr_err("xgifb: invalid value for option: %s\n", fullopt); + return 0; + } + return lres; +} + static int __init XGIfb_setup(char *options) { char *this_opt; @@ -1950,23 +1961,19 @@ static int __init XGIfb_setup(char *options) if (!strncmp(this_opt, "mode:", 5)) { XGIfb_search_mode(this_opt + 5); } else if (!strncmp(this_opt, "vesa:", 5)) { - XGIfb_search_vesamode(simple_strtoul( - this_opt + 5, NULL, 0)); + XGIfb_search_vesamode(xgifb_optval(this_opt, 5)); } else if (!strncmp(this_opt, "vrate:", 6)) { - xgi_video_info.refresh_rate = simple_strtoul( - this_opt + 6, NULL, 0); + xgi_video_info.refresh_rate = xgifb_optval(this_opt, 6); } else if (!strncmp(this_opt, "rate:", 5)) { - xgi_video_info.refresh_rate = simple_strtoul( - this_opt + 5, NULL, 0); + xgi_video_info.refresh_rate = xgifb_optval(this_opt, 5); } else if (!strncmp(this_opt, "crt1off", 7)) { XGIfb_crt1off = 1; } else if (!strncmp(this_opt, "filter:", 7)) { - filter = (int)simple_strtoul(this_opt + 7, NULL, 0); + filter = xgifb_optval(this_opt, 7); } else if (!strncmp(this_opt, "forcecrt2type:", 14)) { XGIfb_search_crt2type(this_opt + 14); } else if (!strncmp(this_opt, "forcecrt1:", 10)) { - XGIfb_forcecrt1 = (int)simple_strtoul( - this_opt + 10, NULL, 0); + XGIfb_forcecrt1 = xgifb_optval(this_opt, 10); } else if (!strncmp(this_opt, "tvmode:", 7)) { XGIfb_search_tvstd(this_opt + 7); } else if (!strncmp(this_opt, "tvstandard:", 11)) { @@ -1978,8 +1985,7 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "noypan", 6)) { XGIfb_ypan = 0; } else if (!strncmp(this_opt, "userom:", 7)) { - XGIfb_userom = (int)simple_strtoul( - this_opt + 7, NULL, 0); + XGIfb_userom = xgifb_optval(this_opt, 7); } else { XGIfb_search_mode(this_opt); } From 009adf2d4be9479004e41fd9b49a6136498f256b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:24 +0300 Subject: [PATCH 0716/1519] staging: xgifb: fix LVDS LCD resolution data setup If the driver fails to get LVDS LCD data from the firmware, it falls back to using driver's hardcoded values. However, this is done too early in the probe. The selected video mode index is not yet known, and also in some cases it could be defaulting to -1 resulting in a read outside the array. Fix this by moving the array lookup after the video mode validation. Signed-off-by: Aaro Koskinen Reported-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 80716874eda..e8bad0296da 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2021,6 +2021,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, u8 reg, reg1; u8 CR48, CR38; int ret; + bool xgi21_drvlcdcaplist = false; memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); @@ -2174,15 +2175,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, CR38 = xgifb_reg_get(XGICR, 0x38); if ((CR38&0xE0) == 0xC0) { xgi_video_info.disp_state = DISPTYPE_LCD; - if (!XGIfb_GetXG21LVDSData()) { - int m; - for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) { - if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) && - (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) { - xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); - } - } - } + if (!XGIfb_GetXG21LVDSData()) + xgi21_drvlcdcaplist = true; } else if ((CR38&0xE0) == 0x60) { xgi_video_info.hasVB = HASVB_CHRONTEL; } else { @@ -2334,6 +2328,19 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } } + if (xgi21_drvlcdcaplist) { + int m; + + for (m = 0; m < ARRAY_SIZE(XGI21_LCDCapList); m++) + if ((XGI21_LCDCapList[m].LVDSHDE == + XGIbios_mode[xgifb_mode_idx].xres) && + (XGI21_LCDCapList[m].LVDSVDE == + XGIbios_mode[xgifb_mode_idx].yres)) { + xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); + break; + } + } + XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; /* yilin set default refresh rate */ From dfbdf805798bb56acca75bdf7b1cad7818772dba Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:25 +0300 Subject: [PATCH 0717/1519] staging: xgifb: search video mode later in probe When searching the video mode, some HW details needs to be known. Therefore it's not possible to do that reliably before probe(). Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e8bad0296da..a9dc9489e34 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -48,6 +48,9 @@ #define XGIFB_ROM_SIZE 65536 +static char *mode; +static int vesa; + /* -------------------- Macro definitions ---------------------------- */ #undef XGIFBDEBUG @@ -1959,9 +1962,9 @@ static int __init XGIfb_setup(char *options) continue; if (!strncmp(this_opt, "mode:", 5)) { - XGIfb_search_mode(this_opt + 5); + mode = this_opt + 5; } else if (!strncmp(this_opt, "vesa:", 5)) { - XGIfb_search_vesamode(xgifb_optval(this_opt, 5)); + vesa = xgifb_optval(this_opt, 5); } else if (!strncmp(this_opt, "vrate:", 6)) { xgi_video_info.refresh_rate = xgifb_optval(this_opt, 6); } else if (!strncmp(this_opt, "rate:", 5)) { @@ -1987,7 +1990,7 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "userom:", 7)) { XGIfb_userom = xgifb_optval(this_opt, 7); } else { - XGIfb_search_mode(this_opt); + mode = this_opt; } } return 0; @@ -2308,6 +2311,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } + if (mode) + XGIfb_search_mode(mode); + else if (vesa != -1) + XGIfb_search_vesamode(vesa); + if (xgifb_mode_idx >= 0) xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); @@ -2513,9 +2521,6 @@ module_init(xgifb_init); #ifdef MODULE -static char *mode; -static int vesa; - MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("XGITECH , Others"); @@ -2541,10 +2546,6 @@ MODULE_PARM_DESC(filter, static int __init xgifb_init_module(void) { printk("\nXGIfb_init_module"); - if (mode) - XGIfb_search_mode(mode); - else if (vesa != -1) - XGIfb_search_vesamode(vesa); return xgifb_init(); } From a952cc9057d644be3cd2c7c9e8728346e4257f3c Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:26 +0300 Subject: [PATCH 0718/1519] staging: xgifb: XGIfb_search_mode(): delete unreachable code XGIfb_search_mode() is always called with a valid string pointer. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index a9dc9489e34..074fe4f9606 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -458,17 +458,6 @@ static void XGIfb_search_mode(const char *name) { int i = 0, j = 0, l; - if (name == NULL) { - printk(KERN_ERR "XGIfb: Internal error, using default mode.\n"); - xgifb_mode_idx = DEFAULT_MODE; - if ((xgi_video_info.chip == XG21) - && ((xgi_video_info.disp_state & DISPTYPE_DISP2) - == DISPTYPE_LCD)) { - xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); - } - return; - } - if (!strcmp(name, XGIbios_mode[MODE_INDEX_NONE].name)) { printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n"); xgifb_mode_idx = DEFAULT_MODE; From 69a186986111a31c0473971104e89c4975955e57 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:27 +0300 Subject: [PATCH 0719/1519] staging: xgifb: assume the default video mode also when module The same default video mode should be assumed regardless if the driver is a module or not. This won't change the current behaviour, but it will simplify further changes. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index b65ed6e6b81..409b5150dcc 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -364,12 +364,7 @@ static struct _XGIbios_mode { }; /* mode-related variables */ -#ifdef MODULE -static int xgifb_mode_idx = 1; -#else -static int xgifb_mode_idx = -1; /* Use a default mode if we are - inside the kernel */ -#endif +static int xgifb_mode_idx = -1; static u8 XGIfb_mode_no; static u8 XGIfb_rate_idx; From 35c064da1b0c9525f51bb84e9ce55aa5961063f0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:28 +0300 Subject: [PATCH 0720/1519] staging: xgifb: delete duplicated default video mode setup code The code for determining the default video mode is unnecessarily duplicated in XGIfb_search_mode() and XGIfb_search_vesamode() functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 074fe4f9606..34678a3b0fc 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -460,12 +460,6 @@ static void XGIfb_search_mode(const char *name) if (!strcmp(name, XGIbios_mode[MODE_INDEX_NONE].name)) { printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n"); - xgifb_mode_idx = DEFAULT_MODE; - if ((xgi_video_info.chip == XG21) - && ((xgi_video_info.disp_state & DISPTYPE_DISP2) - == DISPTYPE_LCD)) { - xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); - } return; } @@ -489,12 +483,6 @@ static void XGIfb_search_vesamode(unsigned int vesamode) if (vesamode == 0) { printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n"); - xgifb_mode_idx = DEFAULT_MODE; - if ((xgi_video_info.chip == XG21) - && ((xgi_video_info.disp_state & DISPTYPE_DISP2) - == DISPTYPE_LCD)) { - xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); - } return; } From de736dbb2253679806a281f125983f58d1ae1218 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:29 +0300 Subject: [PATCH 0721/1519] staging: xgifb: fail the probe if no supported LCD video mode found Fail the probe if the LCD resolution described in card firmware does not match any of the supported modes. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 34678a3b0fc..e989eb4e516 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -449,7 +449,7 @@ static int XGIfb_GetXG21DefaultLVDSModeIdx(void) XGIfb_mode_idx++; } if (!found_mode) - XGIfb_mode_idx = 0; + XGIfb_mode_idx = -1; return XGIfb_mode_idx; } @@ -2313,6 +2313,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } } + if (xgifb_mode_idx < 0) { + dev_err(&pdev->dev, "no supported video mode found\n"); + goto error_1; + } + if (xgi21_drvlcdcaplist) { int m; From c8bec1f067b08a7a3baa66e6d8ab98aeda7df8d2 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:30 +0300 Subject: [PATCH 0722/1519] staging: xgifb: simplify default mode setup The default mode is the same regardless of the display type, except for XG21/LCD which is determined dynamically. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 2 -- drivers/staging/xgifb/XGI_main_26.c | 18 +++++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 409b5150dcc..35b1e9f8c2e 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -254,8 +254,6 @@ static struct _XGIbios_mode { {"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315}, #define DEFAULT_MODE 21 /* TW: index for 800x600x8 */ -#define DEFAULT_LCDMODE 21 /* TW: index for 800x600x8 */ -#define DEFAULT_TVMODE 21 /* TW: index for 800x600x8 */ {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37, MD_XGI300|MD_XGI315}, {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e989eb4e516..ff0392bb029 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2297,20 +2297,12 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); if (xgifb_mode_idx < 0) { - switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { - case DISPTYPE_LCD: - xgifb_mode_idx = DEFAULT_LCDMODE; - if (xgi_video_info.chip == XG21) - xgifb_mode_idx = - XGIfb_GetXG21DefaultLVDSModeIdx(); - break; - case DISPTYPE_TV: - xgifb_mode_idx = DEFAULT_TVMODE; - break; - default: + if ((xgi_video_info.disp_state & DISPTYPE_DISP2) == + DISPTYPE_LCD && + xgi_video_info.chip == XG21) + xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); + else xgifb_mode_idx = DEFAULT_MODE; - break; - } } if (xgifb_mode_idx < 0) { From 44d0244021b951a5473ae96107847f83a9511ed8 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:31 +0300 Subject: [PATCH 0723/1519] staging: xgifb: correct the default mode comment According to the comment, the default mode should be 800x600x8 while the index points actually to 800x600x16. Change the comment and move the definition instead of changing the current behaviour. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 35b1e9f8c2e..d3d58c0d56d 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -253,9 +253,9 @@ static struct _XGIbios_mode { MD_XGI300|MD_XGI315}, {"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315}, -#define DEFAULT_MODE 21 /* TW: index for 800x600x8 */ {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37, MD_XGI300|MD_XGI315}, +#define DEFAULT_MODE 21 /* index for 800x600x16 */ {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37, MD_XGI300|MD_XGI315}, {"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, From c32283089cf3c2dddfb251ff73c37cc24b92d55d Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:32 +0300 Subject: [PATCH 0724/1519] staging: xgifb: delete all references to mode "none" Delete all references to mode "none". It should be handled like any other invalid mode. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 5 +---- drivers/staging/xgifb/XGI_main_26.c | 16 +++++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index d3d58c0d56d..467df83860a 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -211,9 +211,6 @@ static struct _XGIbios_mode { u16 rows; u8 chipset; } XGIbios_mode[] = { -#define MODE_INDEX_NONE 0 /* TW: index for mode=none */ - {"none", 0xFF, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, - MD_XGI300|MD_XGI315}, /* TW: for mode "none" */ {"320x240x16", 0x56, 0x0000, 0x0000, 320, 240, 16, 1, 40, 15, MD_XGI315}, {"320x480x8", 0x5A, 0x0000, 0x0000, 320, 480, 8, 1, 40, 30, @@ -255,7 +252,7 @@ static struct _XGIbios_mode { MD_XGI300|MD_XGI315}, {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37, MD_XGI300|MD_XGI315}, -#define DEFAULT_MODE 21 /* index for 800x600x16 */ +#define DEFAULT_MODE 20 /* index for 800x600x16 */ {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37, MD_XGI300|MD_XGI315}, {"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index ff0392bb029..d903e8e7990 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -49,7 +49,7 @@ #define XGIFB_ROM_SIZE 65536 static char *mode; -static int vesa; +static int vesa = -1; /* -------------------- Macro definitions ---------------------------- */ @@ -458,11 +458,6 @@ static void XGIfb_search_mode(const char *name) { int i = 0, j = 0, l; - if (!strcmp(name, XGIbios_mode[MODE_INDEX_NONE].name)) { - printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n"); - return; - } - while (XGIbios_mode[i].mode_no != 0) { l = min(strlen(name), strlen(XGIbios_mode[i].name)); if (!strncmp(name, XGIbios_mode[i].name, l)) { @@ -480,11 +475,8 @@ static void XGIfb_search_vesamode(unsigned int vesamode) { int i = 0, j = 0; - if (vesamode == 0) { - - printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n"); - return; - } + if (vesamode == 0) + goto invalid; vesamode &= 0x1dff; /* Clean VESA mode number from other flags */ @@ -497,6 +489,8 @@ static void XGIfb_search_vesamode(unsigned int vesamode) } i++; } + +invalid: if (!j) printk(KERN_INFO "XGIfb: Invalid VESA mode 0x%x'\n", vesamode); } From 47c92d5f5f1bd2f712a9fcb11b9b7b25cb198761 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:33 +0300 Subject: [PATCH 0725/1519] stating: xgifb: update module parameter descriptions Remove incorrect/misleading text from parameter descriptions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index d903e8e7990..7702293c5d8 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2498,14 +2498,12 @@ module_param(vesa, int, 0); module_param(filter, int, 0); MODULE_PARM_DESC(mode, - "\nSelects the desired default display mode in the format XxYxDepth,\n" - "eg. 1024x768x16. Other formats supported include XxY-Depth and\n" - "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" - "number, it will be interpreted as a VESA mode number. (default: 800x600x8)\n"); + "\nSelects the desired default display mode in the format XxYxDepth,\n" + "eg. 1024x768x16.\n"); MODULE_PARM_DESC(vesa, - "\nSelects the desired default display mode by VESA defined mode number, eg.\n" - "0x117 (default: 0x0103)\n"); + "\nSelects the desired default display mode by VESA mode number, eg.\n" + "0x117.\n"); MODULE_PARM_DESC(filter, "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n" From b0a792818023a8d5f76a6867d9fd052a7f7dc76f Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Aug 2011 23:14:34 +0300 Subject: [PATCH 0726/1519] staging: xgifb: use common init for module and built-in Use a common init function for module and built-in driver. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 7702293c5d8..db9d27b04ce 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2479,9 +2479,7 @@ static int __init xgifb_init(void) return pci_register_driver(&xgifb_driver); } -#ifndef MODULE module_init(xgifb_init); -#endif /*****************************************************/ /* MODULE */ @@ -2509,20 +2507,12 @@ MODULE_PARM_DESC(filter, "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n" "(Possible values 0-7, default: [no filter])\n"); -static int __init xgifb_init_module(void) -{ - printk("\nXGIfb_init_module"); - - return xgifb_init(); -} - static void __exit xgifb_remove_module(void) { pci_unregister_driver(&xgifb_driver); printk(KERN_DEBUG "xgifb: Module unloaded\n"); } -module_init(xgifb_init_module); module_exit(xgifb_remove_module); #endif /* /MODULE */ From 9f52fc9a2d4a31accf5ff1eaf4feca76b7f559b3 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:45:55 +0300 Subject: [PATCH 0727/1519] staging: xgifb: delete XGI_OpenCRTC() Delete redundant function. Also eliminates the following sparse warning: drivers/staging/xgifb/vb_setmode.c:8033:6: warning: symbol 'XGI_OpenCRTC' was not declared. Should it be static? Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 845e036bd78..05860dabdd8 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -8030,13 +8030,6 @@ static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, } -void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) -{ - unsigned short tempbx; - tempbx = 0; -} - void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { @@ -8745,7 +8738,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); XGI_DisableBridge(HwDeviceExtension, pVBInfo); - /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */ if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { XGI_SetCRT1Group(HwDeviceExtension, ModeNo, From a35cd0ba7f0e39039333ade70c89af12f6e7eca0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:45:56 +0300 Subject: [PATCH 0728/1519] staging: xgifb: delete support for Chrontel 7017 TV output IF_DEF_CH7017 is hard-coded to 0, so this is all just dead code that can be deleted. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 1 - drivers/staging/xgifb/vb_setmode.c | 629 ++++++++++++----------------- drivers/staging/xgifb/vb_struct.h | 2 +- 3 files changed, 260 insertions(+), 372 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 06846868e9f..78b826855ca 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -90,7 +90,6 @@ #define VB_XGI301LV 0x0008 #define VB_XGI302LV 0x0010 #define VB_LVDS_NS 0x0001 /* 3rd party chip */ -#define VB_CH7017 0x0002 #define VB_CH7007 0x0080 /* [Billy] 07/05/03 */ #define ModeInfoFlag 0x0007 diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 05860dabdd8..0e72ddad58e 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2622,7 +2622,6 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, { unsigned short tempbx; struct XGI330_LVDSDataStruct *LCDPtr = NULL; - struct XGI330_CHTVDataStruct *TVPtr = NULL; tempbx = 2; @@ -2635,17 +2634,6 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->HT = LCDPtr->LCDHT; pVBInfo->VT = LCDPtr->LCDVT; } - if (pVBInfo->IF_DEF_CH7017 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) { - TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr( - tempbx, ModeNo, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); - pVBInfo->VGAHT = TVPtr->VGAHT; - pVBInfo->VGAVT = TVPtr->VGAVT; - pVBInfo->HT = TVPtr->LCDHT; - pVBInfo->VT = TVPtr->LCDVT; - } - } if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding @@ -2722,18 +2710,6 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, } } - /* if (pVBInfo->IF_DEF_CH7017 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) - TVPtr = (struct XGI330_CHTVDataStruct *) - XGI_GetTVPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } - */ - XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); if (pVBInfo->IF_DEF_CH7007 == 1) { @@ -2773,16 +2749,6 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, CH7007TV_TimingVPtr[0].data[i]; } } - /* if (pVBInfo->IF_DEF_CH7017 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) - TVPtr = (struct XGI330_CHTVDataStruct *) - XGI_GetTVPtr(tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } - */ XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); @@ -2885,285 +2851,282 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; if (!(pVBInfo->SetFlag & Win9xDOSMode)) { - if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo - & (SetCRT2ToLCD | SetCRT2ToLCDA))) { - if (pVBInfo->IF_DEF_OEMUtil == 1) { - tempbx = 8; - LCDPtr = (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr(tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } - - if ((pVBInfo->IF_DEF_OEMUtil == 0) || - (LCDPtr == NULL)) { - tempbx = 3; - if (pVBInfo->LCDInfo & EnableScalingLCD) - LCDPtr1 = - (struct XGI330_LCDDataDesStruct2 *) - XGI_GetLcdPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - else - LCDPtr = - (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } - - XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); - push1 = tempbx; - push2 = tempax; - - /* GetLCDResInfo */ - if ((pVBInfo->LCDResInfo == Panel1024x768) || - (pVBInfo->LCDResInfo == Panel1024x768x75)) { - tempax = 1024; - tempbx = 768; - } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || - (pVBInfo->LCDResInfo == Panel1280x1024x75)) { - tempax = 1280; - tempbx = 1024; - } else if (pVBInfo->LCDResInfo == Panel1400x1050) { - tempax = 1400; - tempbx = 1050; - } else { - tempax = 1600; - tempbx = 1200; - } - - if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { - pVBInfo->HDE = tempax; - pVBInfo->VDE = tempbx; - pVBInfo->VGAHDE = tempax; - pVBInfo->VGAVDE = tempbx; - } - - if ((pVBInfo->IF_DEF_ScaleLCD == 1) && - (pVBInfo->LCDInfo & EnableScalingLCD)) { - tempax = pVBInfo->HDE; - tempbx = pVBInfo->VDE; - } - - tempax = pVBInfo->HT; + if (pVBInfo->IF_DEF_OEMUtil == 1) { + tempbx = 8; + LCDPtr = (struct XGI330_LCDDataDesStruct *) + XGI_GetLcdPtr(tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + } + if ((pVBInfo->IF_DEF_OEMUtil == 0) || + (LCDPtr == NULL)) { + tempbx = 3; if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHDES; + LCDPtr1 = + (struct XGI330_LCDDataDesStruct2 *) + XGI_GetLcdPtr( + tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); else - tempbx = LCDPtr->LCDHDES; + LCDPtr = + (struct XGI330_LCDDataDesStruct *) + XGI_GetLcdPtr( + tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + } - tempcx = pVBInfo->HDE; - tempbx = tempbx & 0x0fff; - tempcx += tempbx; + XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); + push1 = tempbx; + push2 = tempax; - if (tempcx >= tempax) - tempcx -= tempax; + /* GetLCDResInfo */ + if ((pVBInfo->LCDResInfo == Panel1024x768) || + (pVBInfo->LCDResInfo == Panel1024x768x75)) { + tempax = 1024; + tempbx = 768; + } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || + (pVBInfo->LCDResInfo == Panel1280x1024x75)) { + tempax = 1280; + tempbx = 1024; + } else if (pVBInfo->LCDResInfo == Panel1400x1050) { + tempax = 1400; + tempbx = 1050; + } else { + tempax = 1600; + tempbx = 1200; + } - xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); + if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { + pVBInfo->HDE = tempax; + pVBInfo->VDE = tempbx; + pVBInfo->VGAHDE = tempax; + pVBInfo->VGAVDE = tempbx; + } - tempcx = tempcx >> 3; - tempbx = tempbx >> 3; - - xgifb_reg_set(pVBInfo->Part1Port, 0x16, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x17, - (unsigned short) (tempcx & 0xff)); - - tempax = pVBInfo->HT; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHRS; - else - tempbx = LCDPtr->LCDHRS; - - tempcx = push2; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempcx = LCDPtr1->LCDHSync; - - tempcx += tempbx; - - if (tempcx >= tempax) - tempcx -= tempax; - - tempax = tempbx & 0x07; - tempax = tempax >> 5; - tempcx = tempcx >> 3; - tempbx = tempbx >> 3; - - tempcx &= 0x1f; - tempax |= tempcx; - - xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); - xgifb_reg_set(pVBInfo->Part1Port, 0x14, - (unsigned short) (tempbx & 0xff)); - - tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVDES; - else - tempbx = LCDPtr->LCDVDES; - tempcx = pVBInfo->VDE; - - tempbx = tempbx & 0x0fff; - tempcx += tempbx; - if (tempcx >= tempax) - tempcx -= tempax; - - xgifb_reg_set(pVBInfo->Part1Port, 0x1b, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x1c, - (unsigned short) (tempcx & 0xff)); - - tempbx = (tempbx >> 8) & 0x07; - tempcx = (tempcx >> 8) & 0x07; - - xgifb_reg_set(pVBInfo->Part1Port, 0x1d, - (unsigned short) ((tempcx << 3) - | tempbx)); - - tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVRS; - else - tempbx = LCDPtr->LCDVRS; - - /* tempbx = tempbx >> 4; */ - tempcx = push1; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempcx = LCDPtr1->LCDVSync; - - tempcx += tempbx; - if (tempcx >= tempax) - tempcx -= tempax; - - xgifb_reg_set(pVBInfo->Part1Port, 0x18, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, - (unsigned short) (tempcx & 0x0f)); - - tempax = ((tempbx >> 8) & 0x07) << 3; - - tempbx = pVBInfo->VGAVDE; - if (tempbx != pVBInfo->VDE) - tempax |= 0x40; - - if (pVBInfo->LCDInfo & EnableLVDSDDA) - tempax |= 0x40; - - xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, - tempax); - - tempcx = pVBInfo->VGAVT; + if ((pVBInfo->IF_DEF_ScaleLCD == 1) && + (pVBInfo->LCDInfo & EnableScalingLCD)) { + tempax = pVBInfo->HDE; tempbx = pVBInfo->VDE; - tempax = pVBInfo->VGAVDE; + } + + tempax = pVBInfo->HT; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDHDES; + else + tempbx = LCDPtr->LCDHDES; + + tempcx = pVBInfo->HDE; + tempbx = tempbx & 0x0fff; + tempcx += tempbx; + + if (tempcx >= tempax) tempcx -= tempax; - temp = tempax; /* 0430 ylshieh */ - temp1 = (temp << 18) / tempbx; + xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); - tempdx = (unsigned short) ((temp << 18) % tempbx); + tempcx = tempcx >> 3; + tempbx = tempbx >> 3; - if (tempdx != 0) - temp1 += 1; + xgifb_reg_set(pVBInfo->Part1Port, 0x16, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x17, + (unsigned short) (tempcx & 0xff)); - temp2 = temp1; - push3 = temp2; + tempax = pVBInfo->HT; - xgifb_reg_set(pVBInfo->Part1Port, 0x37, - (unsigned short) (temp2 & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x36, - (unsigned short) ((temp2 >> 8) & 0xff)); + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDHRS; + else + tempbx = LCDPtr->LCDHRS; + tempcx = push2; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempcx = LCDPtr1->LCDHSync; + + tempcx += tempbx; + + if (tempcx >= tempax) + tempcx -= tempax; + + tempax = tempbx & 0x07; + tempax = tempax >> 5; + tempcx = tempcx >> 3; + tempbx = tempbx >> 3; + + tempcx &= 0x1f; + tempax |= tempcx; + + xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); + xgifb_reg_set(pVBInfo->Part1Port, 0x14, + (unsigned short) (tempbx & 0xff)); + + tempax = pVBInfo->VT; + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDVDES; + else + tempbx = LCDPtr->LCDVDES; + tempcx = pVBInfo->VDE; + + tempbx = tempbx & 0x0fff; + tempcx += tempbx; + if (tempcx >= tempax) + tempcx -= tempax; + + xgifb_reg_set(pVBInfo->Part1Port, 0x1b, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x1c, + (unsigned short) (tempcx & 0xff)); + + tempbx = (tempbx >> 8) & 0x07; + tempcx = (tempcx >> 8) & 0x07; + + xgifb_reg_set(pVBInfo->Part1Port, 0x1d, + (unsigned short) ((tempcx << 3) + | tempbx)); + + tempax = pVBInfo->VT; + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDVRS; + else + tempbx = LCDPtr->LCDVRS; + + /* tempbx = tempbx >> 4; */ + tempcx = push1; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempcx = LCDPtr1->LCDVSync; + + tempcx += tempbx; + if (tempcx >= tempax) + tempcx -= tempax; + + xgifb_reg_set(pVBInfo->Part1Port, 0x18, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, + (unsigned short) (tempcx & 0x0f)); + + tempax = ((tempbx >> 8) & 0x07) << 3; + + tempbx = pVBInfo->VGAVDE; + if (tempbx != pVBInfo->VDE) + tempax |= 0x40; + + if (pVBInfo->LCDInfo & EnableLVDSDDA) + tempax |= 0x40; + + xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, + tempax); + + tempcx = pVBInfo->VGAVT; + tempbx = pVBInfo->VDE; + tempax = pVBInfo->VGAVDE; + tempcx -= tempax; + + temp = tempax; /* 0430 ylshieh */ + temp1 = (temp << 18) / tempbx; + + tempdx = (unsigned short) ((temp << 18) % tempbx); + + if (tempdx != 0) + temp1 += 1; + + temp2 = temp1; + push3 = temp2; + + xgifb_reg_set(pVBInfo->Part1Port, 0x37, + (unsigned short) (temp2 & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x36, + (unsigned short) ((temp2 >> 8) & 0xff)); + + tempbx = (unsigned short) (temp2 >> 16); + tempax = tempbx & 0x03; + + tempbx = pVBInfo->VGAVDE; + if (tempbx == pVBInfo->VDE) + tempax |= 0x04; + + xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); + + if (pVBInfo->VBType & VB_XGI301C) { + temp2 = push3; + xgifb_reg_set(pVBInfo->Part4Port, + 0x3c, + (unsigned short) (temp2 & 0xff)); + xgifb_reg_set(pVBInfo->Part4Port, + 0x3b, + (unsigned short) ((temp2 >> 8) & + 0xff)); tempbx = (unsigned short) (temp2 >> 16); - tempax = tempbx & 0x03; + xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, + ~0xc0, + (unsigned short) ((tempbx & + 0xff) << 6)); - tempbx = pVBInfo->VGAVDE; - if (tempbx == pVBInfo->VDE) - tempax |= 0x04; - - xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); - - if (pVBInfo->VBType & VB_XGI301C) { - temp2 = push3; - xgifb_reg_set(pVBInfo->Part4Port, - 0x3c, - (unsigned short) (temp2 & 0xff)); - xgifb_reg_set(pVBInfo->Part4Port, - 0x3b, - (unsigned short) ((temp2 >> 8) & - 0xff)); - tempbx = (unsigned short) (temp2 >> 16); - xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, - ~0xc0, - (unsigned short) ((tempbx & - 0xff) << 6)); - - tempcx = pVBInfo->VGAVDE; - if (tempcx == pVBInfo->VDE) - xgifb_reg_and_or(pVBInfo->Part4Port, - 0x30, ~0x0c, 0x00); - else - xgifb_reg_and_or(pVBInfo->Part4Port, - 0x30, ~0x0c, 0x08); - } - - tempcx = pVBInfo->VGAHDE; - tempbx = pVBInfo->HDE; - - temp1 = tempcx << 16; - - tempax = (unsigned short) (temp1 / tempbx); - - if ((tempbx & 0xffff) == (tempcx & 0xffff)) - tempax = 65535; - - temp3 = tempax; - temp1 = pVBInfo->VGAHDE << 16; - - temp1 /= temp3; - temp3 = temp3 << 16; - temp1 -= 1; - - temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); - - tempax = (unsigned short) (temp3 & 0xff); - xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); - - temp1 = pVBInfo->VGAVDE << 18; - temp1 = temp1 / push3; - tempbx = (unsigned short) (temp1 & 0xffff); - - if (pVBInfo->LCDResInfo == Panel1024x768) - tempbx -= 1; - - tempax = ((tempbx >> 8) & 0xff) << 3; - tempax |= (unsigned short) ((temp3 >> 8) & 0x07); - xgifb_reg_set(pVBInfo->Part1Port, 0x20, - (unsigned short) (tempax & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x21, - (unsigned short) (tempbx & 0xff)); - - temp3 = temp3 >> 16; - - if (modeflag & HalfDCLK) - temp3 = temp3 >> 1; - - xgifb_reg_set(pVBInfo->Part1Port, 0x22, - (unsigned short) ((temp3 >> 8) & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x23, - (unsigned short) (temp3 & 0xff)); + tempcx = pVBInfo->VGAVDE; + if (tempcx == pVBInfo->VDE) + xgifb_reg_and_or(pVBInfo->Part4Port, + 0x30, ~0x0c, 0x00); + else + xgifb_reg_and_or(pVBInfo->Part4Port, + 0x30, ~0x0c, 0x08); } + + tempcx = pVBInfo->VGAHDE; + tempbx = pVBInfo->HDE; + + temp1 = tempcx << 16; + + tempax = (unsigned short) (temp1 / tempbx); + + if ((tempbx & 0xffff) == (tempcx & 0xffff)) + tempax = 65535; + + temp3 = tempax; + temp1 = pVBInfo->VGAHDE << 16; + + temp1 /= temp3; + temp3 = temp3 << 16; + temp1 -= 1; + + temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); + + tempax = (unsigned short) (temp3 & 0xff); + xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); + + temp1 = pVBInfo->VGAVDE << 18; + temp1 = temp1 / push3; + tempbx = (unsigned short) (temp1 & 0xffff); + + if (pVBInfo->LCDResInfo == Panel1024x768) + tempbx -= 1; + + tempax = ((tempbx >> 8) & 0xff) << 3; + tempax |= (unsigned short) ((temp3 >> 8) & 0x07); + xgifb_reg_set(pVBInfo->Part1Port, 0x20, + (unsigned short) (tempax & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x21, + (unsigned short) (tempbx & 0xff)); + + temp3 = temp3 >> 16; + + if (modeflag & HalfDCLK) + temp3 = temp3 >> 1; + + xgifb_reg_set(pVBInfo->Part1Port, 0x22, + (unsigned short) ((temp3 >> 8) & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x23, + (unsigned short) (temp3 & 0xff)); } } @@ -3264,22 +3227,6 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, if (pVBInfo->VBInfo & SetCRT2ToTV) return tempal; } - /* else if ((pVBInfo->IF_DEF_CH7017==1) && - (pVBInfo->VBType&VB_CH7017)) { - if (ModeNo<=0x13) - *tempal = pVBInfo->SModeIDTable[ModeIdIndex]. - St_CRT2CRTC; - else - *tempal = pVBInfo->RefIndex[ - RefreshRateTableIndex].Ext_CRT2CRTC; - *tempal = *tempal & 0x1F; - tempbx = 0; - if (pVBInfo->TVInfo & SetPALTV) - tempbx = tempbx + 2; - if (pVBInfo->TVInfo & SetCHTVOverScan) - tempbx++; - tempbx = tempbx << 1; - } */ } /* {End of VB} */ if ((pVBInfo->IF_DEF_CH7007 == 1) && @@ -3563,13 +3510,6 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo) } pVBInfo->VBType = tempbx; } - /* - else if (pVBInfo->IF_DEF_CH7017 == 1) - pVBInfo->VBType = VB_CH7017; - else //LVDS - pVBInfo->VBType = VB_LVDS_NS; - */ - } void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, @@ -3627,17 +3567,6 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, SetCRT2ToLCDA; } } - } else if (pVBInfo->IF_DEF_CH7017 == 1) { - if (pVBInfo->VBType & VB_CH7017) { - if (temp & EnableDualEdge) { - tempbx |= - SetCRT2ToDualEdge; - - if (temp & SetToLCDA) - tempbx |= - SetCRT2ToLCDA; - } - } } } } @@ -3648,8 +3577,6 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C))) || - ((pVBInfo->IF_DEF_CH7017 == 1) && - (pVBInfo->VBType & VB_CH7017)) || ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007))) { if (temp & SetYPbPr) { /* temp = CR38 */ @@ -3690,12 +3617,8 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, temp = 0x017C; } } else { /* 3nd party chip */ - if (pVBInfo->IF_DEF_CH7017 == 1) - temp = (SetCRT2ToTV | - SetCRT2ToLCD | - SetCRT2ToLCDA); /* [Billy] 07/05/03 */ - else if (pVBInfo->IF_DEF_CH7007 == 1) + if (pVBInfo->IF_DEF_CH7007 == 1) temp = SetCRT2ToTV; else temp = SetCRT2ToLCD; @@ -3880,13 +3803,6 @@ void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, */ } - if (pVBInfo->IF_DEF_CH7017 == 1) { - tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); - - if (tempbx & TVOverScan) - tempbx |= SetCHTVOverScan; - } - if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */ tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); @@ -4028,11 +3944,6 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, } } - if (pVBInfo->IF_DEF_CH7017 == 1) { - if (tempax & LCDDualLink) - tempbx |= SetLCDDualLink; - } - if (pVBInfo->IF_DEF_LVDS == 0) { if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo @@ -7209,27 +7120,6 @@ void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, if (pVBInfo->SetFlag == Win9xDOSMode) return; - /* - if (CH7017) { - if (!(pVBInfo->VBInfo & - (SetCRT2ToLCD | SetCRT2toLCDA)) || - (XGI_DisableChISLCD(pVBInfo))) { - if (!XGI_IsLCDON(pVBInfo)) { - if (DISCHARGE) { - tempbx = XGINew_GetCH7005(0x61); - // first time we power up - if (tempbx < 0x01) - // and disable power sequence - XGINew_SetCH7005(0x0066); - else - // leave VDD on - disable power - XGINew_SetCH7005(0x5f66); - } - } - } - } - */ - if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { tempah = 0x3F; @@ -8663,7 +8553,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_CH7005 = 0; pVBInfo->IF_DEF_LCDA = 1; - pVBInfo->IF_DEF_CH7017 = 0; pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */ pVBInfo->IF_DEF_VideoCapture = 0; pVBInfo->IF_DEF_ScaleLCD = 0; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 3ef79e08857..f4766b15cf9 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -297,7 +297,7 @@ struct vb_device_info { /* ,IF_DEF_FSTN; add for dstn */ unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; unsigned short IF_DEF_CRT2Monitor, IF_DEF_VideoCapture; - unsigned short IF_DEF_LCDA, IF_DEF_CH7017, IF_DEF_YPbPr, + unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD; unsigned short IF_DEF_ExpLink; unsigned short IF_DEF_CH7005, IF_DEF_HiVision; From 4c14bfd41dea0d8d40012d4113af4815ff7c4661 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:45:57 +0300 Subject: [PATCH 0729/1519] staging: xgifb: delete support for Chrontel 7005 TV output IF_DEF_CH7005 is hard-coded to 0, so this is all just dead code that can be deleted. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 76 ++++-------------------------- drivers/staging/xgifb/vb_struct.h | 2 +- 2 files changed, 10 insertions(+), 68 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 0e72ddad58e..853b6785545 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -487,11 +487,6 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, } } } else { /* for LVDS */ - if (pVBInfo->IF_DEF_CH7005 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) - tempax |= SupportCHTV; - } - if (pVBInfo->VBInfo & SetCRT2ToLCD) { tempax |= SupportLCD; @@ -1333,8 +1328,6 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { - unsigned short tempbx; - unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2, @@ -1355,7 +1348,6 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, unsigned short CRT2Index, VCLKIndex; unsigned short modeflag, resinfo; - unsigned char *CHTVVCLKPtr = NULL; if (ModeNo <= 0x13) { /* si+St_ResInfo */ @@ -1456,47 +1448,15 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, else VCLKIndex = CRT2Index; - if (pVBInfo->IF_DEF_CH7005 == 1) { - if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) { - VCLKIndex &= 0x1f; - tempbx = 0; - - if (pVBInfo->VBInfo & SetPALTV) - tempbx += 2; - - if (pVBInfo->VBInfo & SetCHTVOverScan) - tempbx += 1; - - switch (tempbx) { - case 0: - CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC; - break; - case 1: - CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC; - break; - case 2: - CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL; - break; - case 3: - CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL; - break; - default: - break; - } - - VCLKIndex = CHTVVCLKPtr[VCLKIndex]; - } - } else { - VCLKIndex = VCLKIndex >> 6; - if ((pVBInfo->LCDResInfo == Panel800x600) || - (pVBInfo->LCDResInfo == Panel320x480)) - VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; - else if ((pVBInfo->LCDResInfo == Panel1024x768) || - (pVBInfo->LCDResInfo == Panel1024x768x75)) - VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; - else - VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; - } + VCLKIndex = VCLKIndex >> 6; + if ((pVBInfo->LCDResInfo == Panel800x600) || + (pVBInfo->LCDResInfo == Panel320x480)) + VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; + else if ((pVBInfo->LCDResInfo == Panel1024x768) || + (pVBInfo->LCDResInfo == Panel1024x768x75)) + VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; + else + VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; } /* VCLKIndex = VCLKIndex&IndexMask; */ @@ -4934,11 +4894,6 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, tempcx = (pVBInfo->VGAVT - 1); temp = tempcx & 0x00FF; - if (pVBInfo->IF_DEF_CH7005 == 1) { - if (pVBInfo->VBInfo & 0x0C) - temp--; - } - xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); tempbx = pVBInfo->VGAVDE - 1; temp = tempbx & 0x00FF; @@ -8017,13 +7972,6 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, else modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; - if (pVBInfo->IF_DEF_CH7005 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) { - if (modeflag & HalfDCLK) - return 0; - } - } - if (ModeNo < 0x14) return 0xFFFF; @@ -8038,11 +7986,6 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, index--; if (pVBInfo->SetFlag & ProgrammingCRT2) { - if (pVBInfo->IF_DEF_CH7005 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) - index = 0; - } - if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if (pVBInfo->IF_DEF_LVDS == 0) { if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B @@ -8551,7 +8494,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; pVBInfo->IF_DEF_LVDS = 0; - pVBInfo->IF_DEF_CH7005 = 0; pVBInfo->IF_DEF_LCDA = 1; pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */ pVBInfo->IF_DEF_VideoCapture = 0; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index f4766b15cf9..9428d06677a 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -300,7 +300,7 @@ struct vb_device_info { unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD; unsigned short IF_DEF_ExpLink; - unsigned short IF_DEF_CH7005, IF_DEF_HiVision; + unsigned short IF_DEF_HiVision; unsigned short IF_DEF_CH7007; /* Billy 2007/05/03 */ unsigned short LCDResInfo, LCDTypeInfo, VBType;/*301b*/ unsigned short VBInfo, TVInfo, LCDInfo, Set_VGAType; From 83f76a9d7e055beb90e14f5986c06e24f60a131e Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:45:58 +0300 Subject: [PATCH 0730/1519] staging: xgifb: delete support for Chrontel 7007 TV output IF_DEF_CH7007 is hard-coded to 0, so this is all just dead code that can be deleted. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 12 -- drivers/staging/xgifb/vb_init.c | 9 -- drivers/staging/xgifb/vb_setmode.c | 181 +---------------------------- drivers/staging/xgifb/vb_struct.h | 9 -- drivers/staging/xgifb/vb_table.h | 59 ---------- 5 files changed, 5 insertions(+), 265 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 78b826855ca..fab44146de0 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -90,7 +90,6 @@ #define VB_XGI301LV 0x0008 #define VB_XGI302LV 0x0010 #define VB_LVDS_NS 0x0001 /* 3rd party chip */ -#define VB_CH7007 0x0080 /* [Billy] 07/05/03 */ #define ModeInfoFlag 0x0007 #define ModeText 0x0000 @@ -346,17 +345,6 @@ #define VCLK80_350 0x4B #define VCLK107_385 0x4C -#define CH7007TVVCLK30_2 0x00 /* [Billy] 2007/05/18 For CH7007 */ -#define CH7007TVVCLK28_1 0x01 -#define CH7007TVVCLK43_6 0x02 -#define CH7007TVVCLK26_4 0x03 -#define CH7007TVVCLK24_6 0x04 -#define CH7007TVVCLK47_8 0x05 -#define CH7007TVVCLK31_5 0x06 -#define CH7007TVVCLK26_2 0x07 -#define CH7007TVVCLK39 0x08 -#define CH7007TVVCLK36 0x09 - #define RES320x200 0x00 #define RES320x240 0x01 #define RES400x300 0x02 diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 493b5322039..262992ee70e 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -1732,15 +1732,6 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) printk("183"); /* XGINew_DetectMonitor(HwDeviceExtension); */ - pVBInfo->IF_DEF_CH7007 = 0; - if ((HwDeviceExtension->jChipType == XG21) && - (pVBInfo->IF_DEF_CH7007)) { - printk("184"); - /* sense CRT2 */ - XGI_GetSenseStatus(HwDeviceExtension, pVBInfo); - printk("185"); - - } if (HwDeviceExtension->jChipType == XG21) { printk("186"); diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 853b6785545..b4b5ea26c6a 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2456,15 +2456,9 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, switch (tempbx) { case 0: tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ - if (pVBInfo->IF_DEF_CH7007 == 1) - tempdi = XGI_EPLCHTVCRT1Ptr; - break; case 1: tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ - if (pVBInfo->IF_DEF_CH7007 == 1) - tempdi = XGI_EPLCHTVCRT1Ptr; - break; case 2: tempdi = XGI_EPLCHTVDataPtr; @@ -2626,9 +2620,6 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short tempbx, i; struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; - /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */ - struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL; - struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL; if (ModeNo <= 0x13) index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; @@ -2653,32 +2644,8 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; } - if (pVBInfo->IF_DEF_CH7007 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) { - CH7007TV_TimingHPtr = - (struct XGI_CH7007TV_TimingHStruct *) - XGI_GetTVPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - - for (i = 0; i < 8; i++) - pVBInfo->TimingH[0].data[i] = - CH7007TV_TimingHPtr[0].data[i]; - } - } - XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); - if (pVBInfo->IF_DEF_CH7007 == 1) { - xgifb_reg_set(pVBInfo->P3c4, 0x2E, - CH7007TV_TimingHPtr[0].data[8]); - xgifb_reg_set(pVBInfo->P3c4, 0x2F, - CH7007TV_TimingHPtr[0].data[9]); - } - tempbx = 1; if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { @@ -2693,34 +2660,7 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; } - if (pVBInfo->IF_DEF_CH7007 == 1) { - if (pVBInfo->VBInfo & SetCRT2ToTV) { - CH7007TV_TimingVPtr = - (struct XGI_CH7007TV_TimingVStruct *) - XGI_GetTVPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - - for (i = 0; i < 7; i++) - pVBInfo->TimingV[0].data[i] = - CH7007TV_TimingVPtr[0].data[i]; - } - } - XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); - - if (pVBInfo->IF_DEF_CH7007 == 1) { - xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01, - CH7007TV_TimingVPtr[0].data[7] & 0x01); - xgifb_reg_set(pVBInfo->P3c4, 0x34, - CH7007TV_TimingVPtr[0].data[8]); - xgifb_reg_set(pVBInfo->P3c4, 0x3F, - CH7007TV_TimingVPtr[0].data[9]); - - } } } @@ -3127,9 +3067,7 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, { unsigned short index, modeflag; - unsigned short tempbx; unsigned char tempal; - unsigned char *CHTVVCLKPtr = NULL; if (ModeNo <= 0x13) /* si+St_ResInfo */ @@ -3189,77 +3127,6 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, } } /* {End of VB} */ - if ((pVBInfo->IF_DEF_CH7007 == 1) && - (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */ - /* VideoDebugPrint(( - 0, - "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */ - if ((pVBInfo->VBInfo & SetCRT2ToTV)) { - if (ModeNo <= 0x13) { - tempal = pVBInfo->SModeIDTable[ModeIdIndex]. - St_CRT2CRTC; - } else { - tempal = pVBInfo->RefIndex[ - RefreshRateTableIndex].Ext_CRT2CRTC; - } - - tempal = tempal & 0x0F; - tempbx = 0; - - if (pVBInfo->TVInfo & SetPALTV) - tempbx = tempbx + 2; - - if (pVBInfo->TVInfo & SetCHTVOverScan) - tempbx++; - - /** tempbx = tempbx << 1; CH7007 ? **/ - - /* [Billy]07/05/29 CH7007 */ - if (pVBInfo->IF_DEF_CH7007 == 1) { - switch (tempbx) { - case 0: - CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC; - break; - case 1: - CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC; - break; - case 2: - CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL; - break; - case 3: - CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL; - break; - default: - break; - - } - } - /* else { - switch(tempbx) { - case 0: - CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC; - break; - case 1: - CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC; - break; - case 2: - CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL; - break; - case 3: - CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL; - break; - default: - break; - } - } - */ - - tempal = CHTVVCLKPtr[tempal]; - return tempal; - } - - } - tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); tempal = tempal >> 2; tempal &= 0x03; @@ -3278,13 +3145,7 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, unsigned char *di_1, struct vb_device_info *pVBInfo) { - if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */ - /* VideoDebugPrint(( - 0, - "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */ - *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B; - *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C; - } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B + if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag & ProgrammingCRT2)) { @@ -3312,10 +3173,7 @@ static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, for (i = 0; i < 4; i++) { xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, (unsigned short) (0x10 * i)); - if (pVBInfo->IF_DEF_CH7007 == 1) { - xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); - xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); - } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) + if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (!(pVBInfo->VBInfo & SetInSlaveMode))) { xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); @@ -3430,10 +3288,6 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo) { unsigned short flag, tempbx, tempah; - if (pVBInfo->IF_DEF_CH7007 == 1) { - pVBInfo->VBType = VB_CH7007; - return; - } if (pVBInfo->IF_DEF_LVDS == 0) { tempbx = VB_XGI302B; flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); @@ -3536,9 +3390,7 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || - (pVBInfo->VBType & VB_XGI301C))) || - ((pVBInfo->IF_DEF_CH7007 == 1) && - (pVBInfo->VBType & VB_CH7007))) { + (pVBInfo->VBType & VB_XGI301C)))) { if (temp & SetYPbPr) { /* temp = CR38 */ if (pVBInfo->IF_DEF_HiVision == 1) { /* shampoo add for new @@ -3577,11 +3429,7 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, temp = 0x017C; } } else { /* 3nd party chip */ - /* [Billy] 07/05/03 */ - if (pVBInfo->IF_DEF_CH7007 == 1) - temp = SetCRT2ToTV; - else - temp = SetCRT2ToLCD; + temp = SetCRT2ToLCD; } if (!(tempbx & temp)) { @@ -3763,13 +3611,6 @@ void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, */ } - if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */ - tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); - - if (tempbx & TVOverScan) - tempbx |= SetCHTVOverScan; - } - if (pVBInfo->IF_DEF_LVDS == 0) { if (pVBInfo->VBInfo & SetCRT2ToSCART) tempbx |= SetPALTV; @@ -4216,10 +4057,6 @@ void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, } - /* [Billy] 07/05/23 For CH7007 */ - if (pVBInfo->IF_DEF_CH7007 == 1) { - } - if (pXGIHWDE->jChipType == XG27) { if (pVBInfo->IF_DEF_LVDS == 1) { if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { @@ -4256,12 +4093,6 @@ void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, } } - if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ - /* if (IsCH7007TVMode(pVBInfo) == 0) */ - { - } - } - if (pXGIHWDE->jChipType == XG27) { if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { /* LVDS backlight off */ @@ -8495,7 +8326,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; - pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */ pVBInfo->IF_DEF_VideoCapture = 0; pVBInfo->IF_DEF_ScaleLCD = 0; pVBInfo->IF_DEF_OEMUtil = 0; @@ -8628,8 +8458,7 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, } pVBInfo->SetFlag = 0; - if (pVBInfo->IF_DEF_CH7007 != 1) - pVBInfo->VBInfo = DisableCRT2Display; + pVBInfo->VBInfo = DisableCRT2Display; XGI_DisplayOff(HwDeviceExtension, pVBInfo); diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 9428d06677a..ee4f5b376b5 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -208,14 +208,6 @@ struct XGI_TimingVStruct { unsigned char data[7]; }; -struct XGI_CH7007TV_TimingHStruct { - unsigned char data[10]; -}; - -struct XGI_CH7007TV_TimingVStruct { - unsigned char data[10]; -}; - struct XGI_XG21CRT1Struct { unsigned char ModeID, CR02, CR03, CR15, CR16; }; @@ -301,7 +293,6 @@ struct vb_device_info { IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD; unsigned short IF_DEF_ExpLink; unsigned short IF_DEF_HiVision; - unsigned short IF_DEF_CH7007; /* Billy 2007/05/03 */ unsigned short LCDResInfo, LCDTypeInfo, VBType;/*301b*/ unsigned short VBInfo, TVInfo, LCDInfo, Set_VGAType; unsigned short VBExtInfo;/*301lv*/ diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 0184292fc7e..c97b85c573e 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -2629,15 +2629,6 @@ static struct XGI330_TVDataTablStruct XGI_TVDataTable[] = { {0xffff, 0x0000, 12} /* END */ }; -/* Chrontel 7017 TV CRT1 Timing List */ -static struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] = { - {0x0011, 0x0000, 0}, /* XGI_CHTVCRT1UNTSC */ - {0x0011, 0x0010, 1}, /* XGI_CHTVCRT1ONTSC */ - {0x0011, 0x0001, 2}, /* XGI_CHTVCRT1UPAL */ - {0x0011, 0x0011, 3}, /* XGI_CHTVCRT1OPAL */ - {0xFFFF, 0x0000, 4} -}; - /* ;;Chrontel 7017 TV Timing List */ static struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] = { {0x0011, 0x0000, 0}, /* XGI_CHTVUNTSCData */ @@ -3009,56 +3000,6 @@ static unsigned char XGI330_CHTVVCLKUPAL[] = {0x00}; static unsigned char XGI330_CHTVVCLKOPAL[] = {0x00}; -static unsigned char XGI7007_CHTVVCLKUNTSC[] = { - CH7007TVVCLK30_2, - CH7007TVVCLK30_2, - CH7007TVVCLK30_2, - CH7007TVVCLK30_2, - CH7007TVVCLK28_1, - CH7007TVVCLK47_8 -}; - -static unsigned char XGI7007_CHTVVCLKONTSC[] = { - CH7007TVVCLK26_4, - CH7007TVVCLK26_4, - CH7007TVVCLK26_4, - CH7007TVVCLK26_4, - CH7007TVVCLK24_6, - CH7007TVVCLK43_6 -}; - -static unsigned char XGI7007_CHTVVCLKUPAL[] = { - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK26_2, - CH7007TVVCLK39 -}; - -static unsigned char XGI7007_CHTVVCLKOPAL[] = { - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK31_5, - CH7007TVVCLK26_2, - CH7007TVVCLK36 -}; - -static struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] = { - {0x60, 0x36, 30}, /* 0 30.2 MHZ */ - {0x40, 0x4A, 28}, /* 1 28.19 MHZ */ - {0x9F, 0x46, 44}, /* 2 43.6 MHZ */ - {0x97, 0x2C, 26}, /* 3 26.4 MHZ */ - {0x44, 0xE4, 25}, /* 4 24.6 MHZ */ - {0x7E, 0x32, 47}, /* 5 47.832 MHZ */ - {0x8A, 0x24, 31}, /* 6 31.5 MHZ */ - {0x97, 0x2C, 26}, /* 7 26.2 MHZ */ - {0xCE, 0x3C, 39}, /* 8 39 MHZ */ - {0x52, 0x4A, 36}, /* 9 36 MHZ */ - {0xFF, 0x00, 0} /* End mark */ -}; - static struct XGI330_VCLKDataStruct XGI_VCLKData[] = { /* SR2B,SR2C,SR2D */ {0x1B, 0xE1, 25}, /* 00 (25.175MHz) */ From 160b006ae90c821de3aace654159aa75da6d9c3d Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:45:59 +0300 Subject: [PATCH 0731/1519] staging: xgifb: delete redundant Chrontel TV data Delete redundant Chrontel TV data. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 5 ----- drivers/staging/xgifb/vb_struct.h | 4 ---- drivers/staging/xgifb/vb_table.h | 8 -------- 3 files changed, 17 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index b4b5ea26c6a..910d8d9afc4 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -141,11 +141,6 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; - pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC; - pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC; - pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL; - pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL; - /* 310 customization related */ if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV)) pVBInfo->LCDCapList = XGI_LCDDLCapList; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index ee4f5b376b5..3cb2e7e1b3b 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -357,10 +357,6 @@ struct vb_device_info { unsigned char *XGI_TVDelayList; unsigned char *XGI_TVDelayList2; - unsigned char *CHTVVCLKUNTSC; - unsigned char *CHTVVCLKONTSC; - unsigned char *CHTVVCLKUPAL; - unsigned char *CHTVVCLKOPAL; unsigned char *NTSCTiming; unsigned char *PALTiming; unsigned char *HiTVExtTiming; diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index c97b85c573e..e5e19ec950e 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -2992,14 +2992,6 @@ static unsigned char XG27_CRDE[] = {0, 0}; static unsigned char XG27_SR40 = 0x04 ; static unsigned char XG27_SR41 = 0x00 ; -static unsigned char XGI330_CHTVVCLKUNTSC[] = {0x00}; - -static unsigned char XGI330_CHTVVCLKONTSC[] = {0x00}; - -static unsigned char XGI330_CHTVVCLKUPAL[] = {0x00}; - -static unsigned char XGI330_CHTVVCLKOPAL[] = {0x00}; - static struct XGI330_VCLKDataStruct XGI_VCLKData[] = { /* SR2B,SR2C,SR2D */ {0x1B, 0xE1, 25}, /* 00 (25.175MHz) */ From 105d8d0d904f045aafe114ebb9304308032e7d1b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:00 +0300 Subject: [PATCH 0732/1519] staging: xgifb: refactor XGI_SetXG21LCD() and XGI_SetXG27LCD() The code is almost the same for XG21 and XG27, a single routine can cover both. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 94 ++++++++---------------------- 1 file changed, 23 insertions(+), 71 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 910d8d9afc4..9b2871ee6ab 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -988,14 +988,10 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, } } -/* --------------------------------------------------------------------- */ -/* Function : XGI_SetXG21LCD */ -/* Input : */ -/* Output : FCLK duty cycle, FCLK delay compensation */ -/* Description : All values set zero */ -/* --------------------------------------------------------------------- */ -static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, - unsigned short RefreshRateTableIndex, unsigned short ModeNo) +static void xgifb_set_lcd(int chip_id, + struct vb_device_info *pVBInfo, + unsigned short RefreshRateTableIndex, + unsigned short ModeNo) { unsigned short Data, Temp, b3CC; unsigned short XGI_P3cc; @@ -1006,6 +1002,15 @@ static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); + + if (chip_id == XG27) { + Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if ((Temp & 0x03) == 0) { /* dual 12 */ + xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); + xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); + } + } + if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); @@ -1013,65 +1018,16 @@ static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); } - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - - if (Temp & 0x01) { - xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ - xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); - } - - xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ - - xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); - xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); - - if (ModeNo <= 0x13) { - b3CC = (unsigned char) inb(XGI_P3cc); - if (b3CC & 0x40) - /* Hsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); - if (b3CC & 0x80) - /* Vsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); + if (chip_id == XG27) { + XGI_SetXG27FPBits(pVBInfo); } else { - Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - if (Data & 0x4000) - /* Hsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); - if (Data & 0x8000) - /* Vsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); + Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if (Temp & 0x01) { + /* 18 bits FP */ + xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); + xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); + } } -} - -static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, - unsigned short RefreshRateTableIndex, - unsigned short ModeNo) -{ - unsigned short Data, Temp, b3CC; - unsigned short XGI_P3cc; - - XGI_P3cc = pVBInfo->P3cc; - - xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); - - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - if ((Temp & 0x03) == 0) { /* dual 12 */ - xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); - xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); - } - - if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { - xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); - xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); - xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); - xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); - } - - XGI_SetXG27FPBits(pVBInfo); xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ @@ -8278,12 +8234,8 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, XGI_UpdateXG21CRTC(ModeNo, pVBInfo, RefreshRateTableIndex); - if (HwDeviceExtension->jChipType == XG27) - XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex, - ModeNo); - else - XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex, - ModeNo); + xgifb_set_lcd(HwDeviceExtension->jChipType, + pVBInfo, RefreshRateTableIndex, ModeNo); if (pVBInfo->IF_DEF_LVDS == 1) { if (HwDeviceExtension->jChipType == XG27) From 64db29f5f6cec54a58a0ff6bc9bc851aec189f8d Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:01 +0300 Subject: [PATCH 0733/1519] staging: xgifb: refactor XGI_SetXG21LVDSPara() and XGI_SetXG27LVDSPara() The code is almost the same for XG21 and XG27, a single routine can cover both. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 242 ++++------------------------- 1 file changed, 31 insertions(+), 211 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 9b2871ee6ab..cbba662940d 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -6387,204 +6387,10 @@ void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) } -static void XGI_SetXG21LVDSPara(unsigned short ModeNo, - unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) -{ - unsigned char temp, Miscdata; - unsigned short xres, yres, modeflag, resindex, lvdstableindex; - unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; - unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; - unsigned short value; - - lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); - - temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. - LVDS_Capability & - (LCDPolarity << 8)) >> 8); - temp &= LCDPolarity; - Miscdata = (unsigned char) inb(pVBInfo->P3cc); - - outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); - - temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. - LVDS_Capability & LCDPolarity); - /* SR35[7] FP VSync polarity */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); - /* SR30[5] FP HSync polarity */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); - - XGI_SetXG21FPBits(pVBInfo); - resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); - if (ModeNo <= 0x13) { - xres = pVBInfo->StResInfo[resindex].HTotal; - yres = pVBInfo->StResInfo[resindex].VTotal; - /* si+St_ResInfo */ - modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ - yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ - /* si+St_ModeFlag */ - modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - - if (!(modeflag & Charx8Dot)) - xres = xres * 8 / 9; - - LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; - - LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - - xres) / 2; - if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) - LVDSHBS -= xres / 4; - - if (LVDSHBS > LVDSHT) - LVDSHBS -= LVDSHT; - - LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; - if (LVDSHRS > LVDSHT) - LVDSHRS -= LVDSHT; - - LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; - if (LVDSHRE > LVDSHT) - LVDSHRE -= LVDSHT; - - LVDSHBE = LVDSHBS + LVDSHT - - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; - - LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; - - LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - - yres) / 2; - if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) - LVDSVBS += yres / 2; - - if (LVDSVBS > LVDSVT) - LVDSVBS -= LVDSVT; - - LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; - if (LVDSVRS > LVDSVT) - LVDSVRS -= LVDSVT; - - LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; - if (LVDSVRE > LVDSVT) - LVDSVRE -= LVDSVT; - - LVDSVBE = LVDSVBS + LVDSVT - - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; - - temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); - xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ - - if (!(modeflag & Charx8Dot)) - xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); - - /* HT SR0B[1:0] CR00 */ - value = (LVDSHT >> 3) - 5; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); - xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); - - /* HBS SR0B[5:4] CR02 */ - value = (LVDSHBS >> 3) - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); - xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); - - /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ - value = (LVDSHBE >> 3) - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); - xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); - xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); - - /* HRS SR0B[7:6] CR04 */ - value = (LVDSHRS >> 3) + 2; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); - xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); - - /* Panel HRS SR2F[1:0] SR2E[7:0] */ - value--; - xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); - xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); - - /* HRE SR0C[2] CR05[4:0] */ - value = (LVDSHRE >> 3) + 2; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); - xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); - - /* Panel HRE SR2F[7:2] */ - value--; - xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); - - /* VT SR0A[0] CR07[5][0] CR06 */ - value = LVDSVT - 2; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); - xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); - xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); - xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); - - /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ - value = LVDSVBS - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); - xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); - xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); - xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); - - /* VBE SR0A[4] CR16 */ - value = LVDSVBE - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); - xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); - - /* VRS SR0A[3] CR7[7][2] CR10 */ - value = LVDSVRS - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); - xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); - xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); - xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); - - /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); - xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); - xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); - - /* VRE SR0A[5] CR11[3:0] */ - value = LVDSVRE - 1; - xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); - xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); - - /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); - - for (temp = 0, value = 0; temp < 3; temp++) { - - xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); - xgifb_reg_set(pVBInfo->P3c4, - 0x2B, - pVBInfo->XG21_LVDSCapList[lvdstableindex]. - VCLKData1); - xgifb_reg_set(pVBInfo->P3c4, - 0x2C, - pVBInfo->XG21_LVDSCapList[lvdstableindex]. - VCLKData2); - value += 0x10; - } - - if (!(modeflag & Charx8Dot)) { - inb(pVBInfo->P3da); /* reset 3da */ - outb(0x13, pVBInfo->P3c0); /* set index */ - /* set data, panning = 0, shift left 1 dot*/ - outb(0x00, pVBInfo->P3c0); - - inb(pVBInfo->P3da); /* Enable Attribute */ - outb(0x20, pVBInfo->P3c0); - - inb(pVBInfo->P3da); /* reset 3da */ - } - -} - -/* no shadow case */ -static void XGI_SetXG27LVDSPara(unsigned short ModeNo, - unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void xgifb_set_lvds(int chip_id, + unsigned short ModeNo, + unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { unsigned char temp, Miscdata; unsigned short xres, yres, modeflag, resindex, lvdstableindex; @@ -6608,7 +6414,11 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, /* SR30[5] FP HSync polarity */ xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); - XGI_SetXG27FPBits(pVBInfo); + if (chip_id == XG27) + XGI_SetXG27FPBits(pVBInfo); + else + XGI_SetXG21FPBits(pVBInfo); + resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); if (ModeNo <= 0x13) { xres = pVBInfo->StResInfo[resindex].HTotal; @@ -6735,9 +6545,18 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); - /* Panel VRS SR35[2:0] SR34[7:0] */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); - xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); + if (chip_id == XG27) { + /* Panel VRS SR35[2:0] SR34[7:0] */ + xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, + (value & 0x700) >> 8); + xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); + } else { + /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ + xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, + (value & 0x600) >> 9); + xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); + xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); + } /* VRE SR0A[5] CR11[3:0] */ value = LVDSVRE - 1; @@ -6745,7 +6564,13 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); /* Panel VRE SR3F[7:2] */ - xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); + if (chip_id == XG27) + xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, + (value << 2) & 0xFC); + else + /* SR3F[7] has to be 0, h/w bug */ + xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, + (value << 2) & 0x7C); for (temp = 0, value = 0; temp < 3; temp++) { @@ -8237,14 +8062,9 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, xgifb_set_lcd(HwDeviceExtension->jChipType, pVBInfo, RefreshRateTableIndex, ModeNo); - if (pVBInfo->IF_DEF_LVDS == 1) { - if (HwDeviceExtension->jChipType == XG27) - XGI_SetXG27LVDSPara(ModeNo, - ModeIdIndex, pVBInfo); - else - XGI_SetXG21LVDSPara(ModeNo, - ModeIdIndex, pVBInfo); - } + if (pVBInfo->IF_DEF_LVDS == 1) + xgifb_set_lvds(HwDeviceExtension->jChipType, + ModeNo, ModeIdIndex, pVBInfo); /* P. ON */ /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ } From c071906146f51bbb90e4cb649398452212d67d57 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:02 +0300 Subject: [PATCH 0734/1519] staging: xgifb: delete commented-out routines Delete routines which have been commented out. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 173 ----------------------------- 1 file changed, 173 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index cbba662940d..aaa5fa0d27b 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -199,19 +199,6 @@ static unsigned char XGI_GetModePtr(unsigned short ModeNo, return index; /* Get pVBInfo->StandTable index */ } -/* -unsigned char XGI_SetBIOSData(unsigned short ModeNo, - unsigned short ModeIdIndex) { - return (0); -} -*/ - -/* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, - unsigned short ModeIdIndex) { - return( 0 ) ; -} -*/ - static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, @@ -1679,60 +1666,6 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, } -/* -void XGI_VesaLowResolution(unsigned short ModeNo, - unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) -{ - unsigned short modeflag; - - if (ModeNo > 0x13) - modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; - else - modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; - - if (ModeNo > 0x13) { - if (modeflag & DoubleScanMode) { - if (modeflag & HalfDCLK) { - if (pVBInfo->VBType & VB_XGI301B | - VB_XGI302B | - VB_XGI301LV | - VB_XGI302LV | - VB_XGI301C)) { - if (!(pVBInfo->VBInfo & - SetCRT2ToRAMDAC)) { - if (pVBInfo->VBInfo & - SetInSlaveMode) { - xgifb_reg_and_or( - pVBInfo->P3c4, - 0x01, - 0xf7, - 0x00); - xgifb_reg_and_or( - pVBInfo->P3c4, - 0x0f, - 0x7f, - 0x00); - return; - } - } - } - xgifb_reg_and_or(pVBInfo->P3c4, - 0x0f, - 0xff, - 0x80); - xgifb_reg_and_or(pVBInfo->P3c4, - 0x01, - 0xf7, - 0x00); - return; - } - } - } - xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); -} -*/ - static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, @@ -3829,102 +3762,6 @@ unsigned char XGI_SearchModeID(unsigned short ModeNo, return 1; } -/* win2000 MM adapter not support standard mode! */ - -#if 0 -static unsigned char XGINew_CheckMemorySize( - struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo, - unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) -{ - unsigned short memorysize, modeflag, temp, temp1, tmp; - - /* - if ((HwDeviceExtension->jChipType == XGI_650) || - (HwDeviceExtension->jChipType == XGI_650M)) { - return 1; - } - */ - - if (ModeNo <= 0x13) - modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; - - /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ - - memorysize = modeflag & MemoryInfoFlag; - memorysize = memorysize > MemorySizeShift; - memorysize++; /* Get memory size */ - - temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ - tmp = temp; - - if (HwDeviceExtension->jChipType == XG40) { - /* memory size per channel SR14[7:4] */ - temp = 1 << ((temp & 0x0F0) >> 4); - if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ - temp <<= 2; - } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */ - temp <<= 1; - } - } else if (HwDeviceExtension->jChipType == XG42) { - /* memory size per channel SR14[7:4] */ - temp = 1 << ((temp & 0x0F0) >> 4); - if ((tmp & 0x04) == 0x04) { /* Dual channels */ - temp <<= 1; - } - } else if (HwDeviceExtension->jChipType == XG45) { - /* memory size per channel SR14[7:4] */ - temp = 1 << ((temp & 0x0F0) >> 4); - if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ - temp <<= 2; - } else if ((tmp & 0x0c) == 0x08) { /* triple channels */ - temp1 = temp; - temp <<= 1; - temp += temp1; - } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */ - temp <<= 1; - } - } - if (temp < memorysize) - return 0; - else - return 1; -} -#endif - -/* -void XGINew_IsLowResolution(unsigned short ModeNo, - unsigned short ModeIdIndex, - unsigned char XGINew_CheckMemorySize( - struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo, - unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) -{ - unsigned short data ; - unsigned short ModeFlag ; - - data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); - data &= 0x7F; - xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); - - if (ModeNo > 0x13) { - ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; - if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { - data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); - data |= 0x80; - xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); - data = xgifb_reg_get(pVBInfo->P3c4, 0x01); - data &= 0xF7; - xgifb_reg_set(pVBInfo->P3c4, 0x01, data); - } - } -} -*/ - static unsigned char XG21GPIODataTransfer(unsigned char ujDate) { unsigned char ujRet = 0; @@ -4068,16 +3905,6 @@ static void XGI_WaitDisply(struct vb_device_info *pVBInfo) break; } -#if 0 -static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) -{ - while (!(inb(pVBInfo->P3da) & 0x01)) - ; - while (inb(pVBInfo->P3da) & 0x01) - ; -} -#endif - static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) { if (!(pVBInfo->SetFlag & Win9xDOSMode)) From 800d67cf9f77b2994521794f980fac798a1c13d8 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:03 +0300 Subject: [PATCH 0735/1519] staging: xgifb: eliminate #ifdef Tap4 Eliminate #define Tap4 and related checks. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 5 ----- drivers/staging/xgifb/vb_table.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index aaa5fa0d27b..040c9bf6d45 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -5688,10 +5688,6 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) if (!(pVBInfo->VBType & VB_XGI301C)) return; -#ifndef Tap4 - xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ -#else /* Tap4 Setting */ - Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ for (i = 0x80, j = 0; i <= 0xBF; i++, j++) xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); @@ -5713,7 +5709,6 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) else /* Enable H.Scaling */ xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); -#endif } static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index e5e19ec950e..770f859a6a9 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -1,5 +1,3 @@ -#define Tap4 - /* yilin modify for xgi20 */ static struct XGI_MCLKDataStruct XGI340New_MCLKData[] = { {0x16, 0x01, 0x01, 166}, From 3825b38e593c9c078f7b8aebca636b2219783ad5 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:04 +0300 Subject: [PATCH 0736/1519] staging: xgifb: do not initialize static data to 0 Remove redundant initializations. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_table.h | 92 +++++++------------------------- 1 file changed, 19 insertions(+), 73 deletions(-) diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 770f859a6a9..870e0f44090 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -107,62 +107,12 @@ static unsigned char XGI340_CR6B[8][4] = { {0x00, 0x00, 0x00, 0x00} }; -static unsigned char XGI340_CR6E[8][4] = { - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00} -}; +static unsigned char XGI340_CR6E[8][4]; -static unsigned char XGI340_CR6F[8][32] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; +static unsigned char XGI340_CR6F[8][32]; + +static unsigned char XGI340_CR89[8][2]; -static unsigned char XGI340_CR89[8][2] = { - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x00, 0x00} -}; /* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */ static unsigned char XGI340_AGPReg[12] = { 0x28, 0x23, 0x00, 0x20, 0x00, 0x20, @@ -171,10 +121,10 @@ static unsigned char XGI340_AGPReg[12] = { static unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83}; -static unsigned char XGI330_sr25[] = {0x00, 0x0}; +static unsigned char XGI330_sr25[2]; static unsigned char XGI330_sr31 = 0xc0; static unsigned char XGI330_sr32 = 0x11; -static unsigned char XGI330_SR33 = 0x00; +static unsigned char XGI330_SR33; static unsigned char XG40_CRCF = 0x13; static unsigned char XG40_DRAMTypeDefinition = 0xFF ; @@ -783,13 +733,9 @@ static struct XGI_StandTableStruct XGI330_StandTable[] = { } }; -static struct XGI_TimingHStruct XGI_TimingH[] = { - { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } -}; +static struct XGI_TimingHStruct XGI_TimingH[1]; -static struct XGI_TimingVStruct XGI_TimingV[] = { - { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } -}; +static struct XGI_TimingVStruct XGI_TimingV[1]; static struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] = { {0x01, 0x27, 0x91, 0x8f, 0xc0}, /* 00 */ @@ -2955,15 +2901,15 @@ static unsigned char XGI330_SoftSetting = 0x30; static unsigned char XGI330_SR07 = 0x18; static unsigned char XGI330_CR49[] = {0xaa, 0x88}; -static unsigned char XGI330_SR1F = 0x0; +static unsigned char XGI330_SR1F; static unsigned char XGI330_SR21 = 0xa3; static unsigned char XGI330_SR22 = 0xfb; static unsigned char XGI330_SR23 = 0xf6; static unsigned char XGI330_SR24 = 0xd; -static unsigned char XGI330_CRT2Data_1_2 = 0x0; -static unsigned char XGI330_CRT2Data_4_D = 0x0; -static unsigned char XGI330_CRT2Data_4_E = 0x0; +static unsigned char XGI330_CRT2Data_1_2; +static unsigned char XGI330_CRT2Data_4_D; +static unsigned char XGI330_CRT2Data_4_E; static unsigned char XGI330_CRT2Data_4_10 = 0x80; static unsigned short XGI330_RGBSenseData = 0xd1; static unsigned short XGI330_VideoSenseData = 0xb9; @@ -2971,14 +2917,14 @@ static unsigned short XGI330_YCSenseData = 0xb3; static unsigned short XGI330_RGBSenseData2 = 0x0190; /*301b*/ static unsigned short XGI330_VideoSenseData2 = 0x0110; static unsigned short XGI330_YCSenseData2 = 0x016B; -static unsigned char XG40_I2CDefinition = 0x00 ; +static unsigned char XG40_I2CDefinition; static unsigned char XG20_CR97 = 0x10 ; -static unsigned char XG21_DVOSetting = 0x00 ; -static unsigned char XG21_CR2E = 0x00 ; -static unsigned char XG21_CR2F = 0x00 ; -static unsigned char XG21_CR46 = 0x00 ; -static unsigned char XG21_CR47 = 0x00 ; +static unsigned char XG21_DVOSetting; +static unsigned char XG21_CR2E; +static unsigned char XG21_CR2F; +static unsigned char XG21_CR46; +static unsigned char XG21_CR47; static unsigned char XG27_CR97 = 0xC1 ; static unsigned char XG27_SR36 = 0x30 ; @@ -2986,7 +2932,7 @@ static unsigned char XG27_CR8F = 0x0C ; static unsigned char XG27_CRD0[] = { 0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00 }; -static unsigned char XG27_CRDE[] = {0, 0}; +static unsigned char XG27_CRDE[2]; static unsigned char XG27_SR40 = 0x04 ; static unsigned char XG27_SR41 = 0x00 ; From 80f86f8f2613370055b83e6bb5876caccab6d815 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:05 +0300 Subject: [PATCH 0737/1519] staging: xgifb: delete duplicated YFilter2 data All four "YFilter2" tables are identical. Replace as follows: NTSCYFilter2 ==> xgifb_yfilter2; PALMYFilter2 ==> xgifb_yfilter2; PALNYFilter2 ==> xgifb_yfilter2; PALYFilter2 ==> xgifb_yfilter2; Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 11 +--------- drivers/staging/xgifb/vb_table.h | 35 +----------------------------- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 040c9bf6d45..8544523d5e8 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -6992,19 +6992,10 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, case 0x08: case 0x0C: - filterPtr = NTSCYFilter2; - break; - case 0x0A: - filterPtr = PALMYFilter2; - break; - case 0x0B: - filterPtr = PALNYFilter2; - break; - case 0x09: - filterPtr = PALYFilter2; + filterPtr = xgifb_yfilter2; break; default: diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 870e0f44090..3a95e1c4067 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -3232,40 +3232,7 @@ static unsigned char PALNYFilter1[] = { 0xFF, 0xFF, 0xFF, 0xFF /* End of Table */ }; -static unsigned char NTSCYFilter2[] = { - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */ - 0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */ - 0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28 /* 7 : 1024xgra. mode */ -}; - -static unsigned char PALYFilter2[] = { - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */ - 0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */ - 0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28 /* 7 : 1024xgra. mode */ -}; - -static unsigned char PALMYFilter2[] = { - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */ - 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */ - 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */ - 0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */ - 0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28 /* 7 : 1024xgra. mode */ -}; - -static unsigned char PALNYFilter2[] = { +static unsigned char xgifb_yfilter2[] = { 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */ 0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */ 0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */ From 2555e9458fbdf00c02d6184fa1d2ea93f4651f46 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:06 +0300 Subject: [PATCH 0738/1519] staging: xgifb: delete duplicated YFilter1 data PAL-M and PAL-N "YFilter1" tables are identical. Replace as follows: PALMYFilter1 ==> xgifb_palmn_yfilter1 PALNYFilter1 ==> xgifb_palmn_yfilter1 Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 5 +---- drivers/staging/xgifb/vb_table.h | 13 +------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 8544523d5e8..aebdf05eb64 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -6983,11 +6983,8 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, case 0x02: case 0x05: case 0x0D: - filterPtr = PALMYFilter1; - break; - case 0x03: - filterPtr = PALNYFilter1; + filterPtr = xgifb_palmn_yfilter1; break; case 0x08: diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 3a95e1c4067..49d56da4c74 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -3210,18 +3210,7 @@ static unsigned char PALYFilter1[] = { 0xFC, 0xFB, 0x14, 0x2A /* 6 : 800x gra. mode */ }; -static unsigned char PALMYFilter1[] = { - 0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */ - 0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */ - 0xEB, 0x04, 0x10, 0x18, /* 2 : 640x text mode */ - 0xF7, 0x06, 0x19, 0x14, /* 3 : 720x text mode */ - 0x00, 0xF4, 0x10, 0x38, /* 4 : 320x gra. mode */ - 0xEB, 0x04, 0x25, 0x18, /* 5 : 640x gra. mode */ - 0xEB, 0x15, 0x25, 0xF6, /* 6 : 800x gra. mode */ - 0xFF, 0xFF, 0xFF, 0xFF /* End of Table */ -}; - -static unsigned char PALNYFilter1[] = { +static unsigned char xgifb_palmn_yfilter1[] = { 0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */ 0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */ 0xEB, 0x04, 0x10, 0x18, /* 2 : 640x text mode */ From ada2bda145722add7e790ff0dd9866434b1001f6 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:07 +0300 Subject: [PATCH 0739/1519] staging: xgifb: delete duplicated LCD data Delete duplicated LCD data tables. Replace as follows: XGI_ExtLCD1400x1050Data ==> xgifb_lcd_1400x1050 XGI_StLCD1400x1050Data ==> xgifb_lcd_1400x1050 XGI_ExtLCD1280x1024x75Data ==> xgifb_lcd_1280x1024x75 XGI_StLCD1280x1024x75Data ==> xgifb_lcd_1280x1024x75 XGI_ExtLCDDes1400x1050Data ==> xgifb_lcddes_1400x1050 XGI_StLCDDes1400x1050Data ==> xgifb_lcddes_1400x1050 XGI_ExtLCDDLDes1400x1050Data ==> xgifb_lcddldes_1400x1050 XGI_StLCDDLDes1400x1050Data ==> xgifb_lcddldes_1400x1050 XGI_ExtLCDDes1024x768x75Data ==> xgifb_lcddes_1024x768x75 XGI_StLCDDes1024x768x75Data ==> xgifb_lcddes_1024x768x75 XGI_ExtLCDDes1280x1024x75Data ==> xgifb_lcddes_1280x1024x75 XGI_StLCDDes1280x1024x75Data ==> xgifb_lcddes_1280x1024x75 XGI_ExtLCDDLDes1280x1024x75Data ==> xgifb_lcddldes_1280x1024x75 XGI_StLCDDLDes1280x1024x75Data ==> xgifb_lcddldes_1280x1024x75 Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 32 +++------- drivers/staging/xgifb/vb_table.h | 96 +++--------------------------- 2 files changed, 14 insertions(+), 114 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index aebdf05eb64..0e1833a9d5f 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2155,10 +2155,8 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, return &XGI_CetLCD1280x1024Data[tempal]; break; case 6: - return &XGI_ExtLCD1400x1050Data[tempal]; - break; case 7: - return &XGI_StLCD1400x1050Data[tempal]; + return &xgifb_lcd_1400x1050[tempal]; break; case 8: return &XGI_CetLCD1400x1050Data[tempal]; @@ -2182,10 +2180,8 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, return &XGI_CetLCD1024x768x75Data[tempal]; break; case 15: - return &XGI_ExtLCD1280x1024x75Data[tempal]; - break; case 16: - return &XGI_StLCD1280x1024x75Data[tempal]; + return &xgifb_lcd_1280x1024x75[tempal]; break; case 17: return &XGI_CetLCD1280x1024x75Data[tempal]; @@ -2229,18 +2225,12 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, return &XGI_CetLCDDes1280x1024Data[tempal]; break; case 6: - if ((pVBInfo->VBType & VB_XGI301LV) || - (pVBInfo->VBType & VB_XGI302LV)) - return &XGI_ExtLCDDLDes1400x1050Data[tempal]; - else - return &XGI_ExtLCDDes1400x1050Data[tempal]; - break; case 7: if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV)) - return &XGI_StLCDDLDes1400x1050Data[tempal]; + return &xgifb_lcddldes_1400x1050[tempal]; else - return &XGI_StLCDDes1400x1050Data[tempal]; + return &xgifb_lcddes_1400x1050[tempal]; break; case 8: return &XGI_CetLCDDes1400x1050Data[tempal]; @@ -2266,27 +2256,19 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, return &XGI_NoScalingDesData[tempal]; break; case 13: - return &XGI_ExtLCDDes1024x768x75Data[tempal]; - break; case 14: - return &XGI_StLCDDes1024x768x75Data[tempal]; + return &xgifb_lcddes_1024x768x75[tempal]; break; case 15: return &XGI_CetLCDDes1024x768x75Data[tempal]; break; case 16: - if ((pVBInfo->VBType & VB_XGI301LV) || - (pVBInfo->VBType & VB_XGI302LV)) - return &XGI_ExtLCDDLDes1280x1024x75Data[tempal]; - else - return &XGI_ExtLCDDes1280x1024x75Data[tempal]; - break; case 17: if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV)) - return &XGI_StLCDDLDes1280x1024x75Data[tempal]; + return &xgifb_lcddldes_1280x1024x75[tempal]; else - return &XGI_StLCDDes1280x1024x75Data[tempal]; + return &xgifb_lcddes_1280x1024x75[tempal]; break; case 18: if ((pVBInfo->VBType & VB_XGI301LV) || diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 49d56da4c74..8029b866a4b 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -1004,21 +1004,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] = { {1, 1, 1688, 1066, 1688, 1066} /* 08 (1400x1050x60Hz) */ }; -static struct XGI330_LCDDataStruct XGI_StLCD1400x1050Data[] = { - {211, 100, 2100, 408, 1688, 1066}, /* 00 (320x200,320x400, - 640x200,640x400) */ - {211, 64, 1536, 358, 1688, 1066}, /* 01 (320x350,640x350) */ - {211, 100, 2100, 408, 1688, 1066}, /* 02 (360x400,720x400) */ - {211, 64, 1536, 358, 1688, 1066}, /* 03 (720x350) */ - {211, 48, 840, 488, 1688, 1066}, /* 04 (640x480x60Hz) */ - {211, 72, 1008, 609, 1688, 1066}, /* 05 (800x600x60Hz) */ - {211, 128, 1400, 776, 1688, 1066}, /* 06 (1024x768x60Hz) */ - {1, 1, 1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz - w/o Scaling) */ - {1, 1, 1688, 1066, 1688, 1066} /* 08 (1400x1050x60Hz) */ -}; - -static struct XGI330_LCDDataStruct XGI_ExtLCD1400x1050Data[] = { +static struct XGI330_LCDDataStruct xgifb_lcd_1400x1050[] = { {211, 100, 2100, 408, 1688, 1066}, /* 00 (320x200,320x400, 640x200,640x400) */ {211, 64, 1536, 358, 1688, 1066}, /* 01 (320x350,640x350) */ @@ -1110,19 +1096,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] = { {1, 1, 1312, 800, 1312, 800} /* ; 06 (1024x768x75Hz) */ }; -static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024x75Data[] = { - {211, 60, 1024, 501, 1688, 1066}, /* ; 00 (320x200,320x400, - 640x200,640x400) */ - {211, 60, 1024, 508, 1688, 1066}, /* ; 01 (320x350,640x350) */ - {211, 60, 1024, 501, 1688, 1066}, /* ; 02 (360x400,720x400) */ - {211, 60, 1024, 508, 1688, 1066}, /* ; 03 (720x350) */ - {211, 45, 768, 498, 1688, 1066}, /* ; 04 (640x480x75Hz) */ - {211, 75, 1024, 625, 1688, 1066}, /* ; 05 (800x600x75Hz) */ - {211, 120, 1280, 798, 1688, 1066}, /* ; 06 (1024x768x75Hz) */ - {1, 1, 1688, 1066, 1688, 1066} /* ; 07 (1280x1024x75Hz) */ -}; - -static struct XGI330_LCDDataStruct XGI_StLCD1280x1024x75Data[] = { +static struct XGI330_LCDDataStruct xgifb_lcd_1280x1024x75[] = { {211, 60, 1024, 501, 1688, 1066}, /* ; 00 (320x200,320x400, 640x200,640x400) */ {211, 60, 1024, 508, 1688, 1066}, /* ; 01 (320x350,640x350) */ @@ -1258,7 +1232,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] = { {9, 1337, 1065, 1024} /* 07 (1280x1024x60Hz) */ }; -static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[] = { +static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1400x1050[] = { {18, 1464, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */ {18, 1464, 0, 1051}, /* 01 (320x350,640x350) */ {18, 1464, 0, 1051}, /* 02 (360x400,720x400) */ @@ -1270,31 +1244,7 @@ static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[] = { {18, 1464, 0, 1051} /* 08 (1400x1050x60Hz) */ }; -static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1400x1050Data[] = { - {18, 1464, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */ - {18, 1464, 0, 1051}, /* 01 (320x350,640x350) */ - {18, 1464, 0, 1051}, /* 02 (360x400,720x400) */ - {18, 1464, 0, 1051}, /* 03 (720x350) */ - {18, 1464, 0, 1051}, /* 04 (640x480x60Hz) */ - {18, 1464, 0, 1051}, /* 05 (800x600x60Hz) */ - {18, 1464, 0, 1051}, /* 06 (1024x768x60Hz) */ - {1646, 1406, 1053, 1038}, /* 07 (1280x1024x60Hz) */ - {18, 1464, 0, 1051} /* 08 (1400x1050x60Hz) */ -}; - -static struct XGI330_LCDDataDesStruct XGI_StLCDDes1400x1050Data[] = { - {9, 1455, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */ - {9, 1455, 0, 1051}, /* 01 (320x350,640x350) */ - {9, 1455, 0, 1051}, /* 02 (360x400,720x400) */ - {9, 1455, 0, 1051}, /* 03 (720x350) */ - {9, 1455, 0, 1051}, /* 04 (640x480x60Hz) */ - {9, 1455, 0, 1051}, /* 05 (800x600x60Hz) */ - {9, 1455, 0, 1051}, /* 06 (1024x768x60Hz) */ - {1637, 1397, 1053, 1038}, /* 07 (1280x1024x60Hz) */ - {9, 1455, 0, 1051} /* 08 (1400x1050x60Hz) */ -}; - -static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1400x1050Data[] = { +static struct XGI330_LCDDataDesStruct xgifb_lcddes_1400x1050[] = { {9, 1455, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */ {9, 1455, 0, 1051}, /* 01 (320x350,640x350) */ {9, 1455, 0, 1051}, /* 02 (360x400,720x400) */ @@ -1395,17 +1345,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] = { }; /* ;;1024x768x75Hz */ -static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768x75Data[] = { - {9, 1049, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */ - {9, 1049, 0, 769}, /* ; 01 (320x350,640x350) */ - {9, 1049, 0, 769}, /* ; 02 (360x400,720x400) */ - {9, 1049, 0, 769}, /* ; 03 (720x350) */ - {9, 1049, 0, 769}, /* ; 04 (640x480x75Hz) */ - {9, 1049, 0, 769}, /* ; 05 (800x600x75Hz) */ - {9, 1049, 0, 769} /* ; 06 (1024x768x75Hz) */ -}; - -static struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768x75Data[] = { +static struct XGI330_LCDDataDesStruct xgifb_lcddes_1024x768x75[] = { {9, 1049, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */ {9, 1049, 0, 769}, /* ; 01 (320x350,640x350) */ {9, 1049, 0, 769}, /* ; 02 (360x400,720x400) */ @@ -1427,18 +1367,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = { }; /* ;;1280x1024x75Hz */ -static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024x75Data[] = { - {18, 1314, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */ - {18, 1314, 0, 1025}, /* ; 01 (320x350,640x350) */ - {18, 1314, 0, 1025}, /* ; 02 (360x400,720x400) */ - {18, 1314, 0, 1025}, /* ; 03 (720x350) */ - {18, 1314, 0, 1025}, /* ; 04 (640x480x60Hz) */ - {18, 1314, 0, 1025}, /* ; 05 (800x600x60Hz) */ - {18, 1314, 0, 1025}, /* ; 06 (1024x768x60Hz) */ - {18, 1314, 0, 1025} /* ; 07 (1280x1024x60Hz) */ -}; - -static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024x75Data[] = { +static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1280x1024x75[] = { {18, 1314, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */ {18, 1314, 0, 1025}, /* ; 01 (320x350,640x350) */ {18, 1314, 0, 1025}, /* ; 02 (360x400,720x400) */ @@ -1462,18 +1391,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = { }; /* ;;1280x1024x75Hz */ -static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024x75Data[] = { - {9, 1305, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */ - {9, 1305, 0, 1025}, /* ; 01 (320x350,640x350) */ - {9, 1305, 0, 1025}, /* ; 02 (360x400,720x400) */ - {9, 1305, 0, 1025}, /* ; 03 (720x350) */ - {9, 1305, 0, 1025}, /* ; 04 (640x480x60Hz) */ - {9, 1305, 0, 1025}, /* ; 05 (800x600x60Hz) */ - {9, 1305, 0, 1025}, /* ; 06 (1024x768x60Hz) */ - {9, 1305, 0, 1025} /* ; 07 (1280x1024x60Hz) */ -}; - -static struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024x75Data[] = { +static struct XGI330_LCDDataDesStruct xgifb_lcddes_1280x1024x75[] = { {9, 1305, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */ {9, 1305, 0, 1025}, /* ; 01 (320x350,640x350) */ {9, 1305, 0, 1025}, /* ; 02 (360x400,720x400) */ From cc5c2aeb231bcb67697ef3f2c3ed8947229b1384 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:08 +0300 Subject: [PATCH 0740/1519] staging: xgifb: delete duplicated LCD table XGI_EPLLCDCRT1Ptr_H and XGI_EPLLCDCRT1Ptr_V tables are identical. Replace as follows: XGI_EPLLCDCRT1Ptr_H ==> xgifb_epllcd_crt1 XGI_EPLLCDCRT1Ptr_V ==> xgifb_epllcd_crt1 Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 4 +-- drivers/staging/xgifb/vb_table.h | 39 +++++++++--------------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 0e1833a9d5f..1d209292c5f 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -1902,10 +1902,8 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, switch (tempbx) { case 0: - tempdi = XGI_EPLLCDCRT1Ptr_H; - break; case 1: - tempdi = XGI_EPLLCDCRT1Ptr_V; + tempdi = xgifb_epllcd_crt1; break; case 2: tempdi = XGI_EPLLCDDataPtr; diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 8029b866a4b..1355c0b3bbd 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -2402,33 +2402,18 @@ static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] = { {0xFF, 0x0000, 0x0000, 0} }; -static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] = { - {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDSCRT11024x768_1_H */ - {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDSCRT11024x768_2_H */ - {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDSCRT11280x1024_1_H */ - {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDSCRT11280x1024_2_H */ - {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDSCRT11400x1050_1_H */ - {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDSCRT11400x1050_2_H */ - {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDSCRT11600x1200_1_H */ - {Panel1024x768x75, 0x0018, 0x0000, 7}, /* XGI_LVDSCRT11024x768_1_Hx75 */ - {Panel1024x768x75, 0x0018, 0x0010, 8}, /* XGI_LVDSCRT11024x768_2_Hx75 */ - {Panel1280x1024x75, 0x0018, 0x0000, 9}, /*XGI_LVDSCRT11280x1024_1_Hx75*/ - {Panel1280x1024x75, 0x0018, 0x0010, 10},/*XGI_LVDSCRT11280x1024_2_Hx75*/ - {0xFF, 0x0000, 0x0000, 0} -}; - -static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] = { - {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDSCRT11024x768_1_V */ - {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDSCRT11024x768_2_V */ - {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDSCRT11280x1024_1_V */ - {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDSCRT11280x1024_2_V */ - {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDSCRT11400x1050_1_V */ - {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDSCRT11400x1050_2_V */ - {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDSCRT11600x1200_1_V */ - {Panel1024x768x75, 0x0018, 0x0000, 7}, /* XGI_LVDSCRT11024x768_1_Vx75 */ - {Panel1024x768x75, 0x0018, 0x0010, 8}, /* XGI_LVDSCRT11024x768_2_Vx75 */ - {Panel1280x1024x75, 0x0018, 0x0000, 9}, /*XGI_LVDSCRT11280x1024_1_Vx75*/ - {Panel1280x1024x75, 0x0018, 0x0010, 10},/*XGI_LVDSCRT11280x1024_2_Vx75*/ +static struct XGI330_LCDDataTablStruct xgifb_epllcd_crt1[] = { + {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDSCRT11024x768_1 */ + {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDSCRT11024x768_2 */ + {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDSCRT11280x1024_1 */ + {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDSCRT11280x1024_2 */ + {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDSCRT11400x1050_1 */ + {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDSCRT11400x1050_2 */ + {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDSCRT11600x1200_1 */ + {Panel1024x768x75, 0x0018, 0x0000, 7}, /* XGI_LVDSCRT11024x768_1x75 */ + {Panel1024x768x75, 0x0018, 0x0010, 8}, /* XGI_LVDSCRT11024x768_2x75 */ + {Panel1280x1024x75, 0x0018, 0x0000, 9}, /*XGI_LVDSCRT11280x1024_1x75*/ + {Panel1280x1024x75, 0x0018, 0x0010, 10},/*XGI_LVDSCRT11280x1024_2x75*/ {0xFF, 0x0000, 0x0000, 0} }; From 0c23b6d2fe9303070e81eee07070ecb549b3996e Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:09 +0300 Subject: [PATCH 0741/1519] staging: xgifb: delete duplicated TV data tables Delete redundant TV data tables. Replace as follows: XGI_EPLCHTVDataPtr ==> xgifb_chrontel_tv XGI_EPLCHTVRegPtr ==> xgifb_chrontel_tv Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 6 ++---- drivers/staging/xgifb/vb_table.h | 21 ++++++--------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 1d209292c5f..db8944aa210 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2325,7 +2325,8 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ break; case 2: - tempdi = XGI_EPLCHTVDataPtr; + case 6: + tempdi = xgifb_chrontel_tv; break; case 3: tempdi = NULL; @@ -2336,9 +2337,6 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, case 5: tempdi = NULL; break; - case 6: - tempdi = XGI_EPLCHTVRegPtr; - break; default: break; } diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 1355c0b3bbd..cb58b2ea735 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -2476,21 +2476,12 @@ static struct XGI330_TVDataTablStruct XGI_TVDataTable[] = { {0xffff, 0x0000, 12} /* END */ }; -/* ;;Chrontel 7017 TV Timing List */ -static struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] = { - {0x0011, 0x0000, 0}, /* XGI_CHTVUNTSCData */ - {0x0011, 0x0010, 1}, /* XGI_CHTVONTSCData */ - {0x0011, 0x0001, 2}, /* XGI_CHTVUPALData */ - {0x0011, 0x0011, 3}, /* XGI_CHTVOPALData */ - {0xFFFF, 0x0000, 4} -}; - -/* ;;Chrontel 7017 TV Reg. List */ -static struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] = { - {0x0011, 0x0000, 0}, /* XGI_CHTVRegUNTSC */ - {0x0011, 0x0010, 1}, /* XGI_CHTVRegONTSC */ - {0x0011, 0x0001, 2}, /* XGI_CHTVRegUPAL */ - {0x0011, 0x0011, 3}, /* XGI_CHTVRegOPAL */ +/* Chrontel 7017 TV List */ +static struct XGI330_TVDataTablStruct xgifb_chrontel_tv[] = { + {0x0011, 0x0000, 0}, /* UNTSC */ + {0x0011, 0x0010, 1}, /* ONTSC */ + {0x0011, 0x0001, 2}, /* UPAL */ + {0x0011, 0x0011, 3}, /* OPAL */ {0xFFFF, 0x0000, 4} }; From 11fbdcde54db80130b8e9e37a9c8dd8f01dd2193 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:10 +0300 Subject: [PATCH 0742/1519] staging: xgifb: delete duplicated timing data Delete redundant timing data tables. Replace as follows: EnlargeTap4Timing ==> xgifb_tap4_timing NoScaleTap4Timing ==> xgifb_tap4_timing NTSCTap4Timing ==> xgifb_ntsc_525_tap4_timing YPbPr525iTap4Timing ==> xgifb_ntsc_525_tap4_timing YPbPr525pTap4Timing ==> xgifb_ntsc_525_tap4_timing Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 17 ++--- drivers/staging/xgifb/vb_table.h | 104 +---------------------------- 2 files changed, 9 insertions(+), 112 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index db8944aa210..100f63f0427 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -5626,27 +5626,24 @@ static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, tempbx = pVBInfo->VDE; } - if (tempax < tempbx) - return &EnlargeTap4Timing[0]; - else if (tempax == tempbx) - return &NoScaleTap4Timing[0]; /* 1:1 */ + if (tempax <= tempbx) + return &xgifb_tap4_timing[0]; else - Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ + Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ if (pVBInfo->TVInfo & SetPALTV) Tap4TimingPtr = PALTap4Timing; if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { - if (pVBInfo->TVInfo & SetYPbPrMode525i) - Tap4TimingPtr = YPbPr525iTap4Timing; - if (pVBInfo->TVInfo & SetYPbPrMode525p) - Tap4TimingPtr = YPbPr525pTap4Timing; + if ((pVBInfo->TVInfo & SetYPbPrMode525i) || + (pVBInfo->TVInfo & SetYPbPrMode525p)) + Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; if (pVBInfo->TVInfo & SetYPbPrMode750p) Tap4TimingPtr = YPbPr750pTap4Timing; } if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) - Tap4TimingPtr = HiTVTap4Timing; + Tap4TimingPtr = xgifb_tap4_timing; i = 0; while (Tap4TimingPtr[i].DE != 0xFFFF) { diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index cb58b2ea735..b81ac7726d1 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -3132,35 +3132,7 @@ static unsigned char XGI_NTSC1024AdjTime[] = { 0x58, 0xe4, 0x73, 0xd0, 0x13 }; -static struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] = { - {0, { - 0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */ - 0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */ - 0x7C, 0x1D, 0x09, 0x7E, 0x7C, 0x1B, 0x0B, 0x7E, /* ; D0-D7 */ - 0x7C, 0x19, 0x0E, 0x7D, 0x7C, 0x17, 0x11, 0x7C, /* ; D8-DF */ - 0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x11, 0x17, 0x7C, /* ; E0-E7 */ - 0x7D, 0x0E, 0x19, 0x7C, 0x7E, 0x0B, 0x1B, 0x7C, /* ; EA-EF */ - 0x7E, 0x09, 0x1D, 0x7C, 0x7F, 0x06, 0x1F, 0x7C, /* ; F0-F7 */ - 0x7F, 0x04, 0x20, 0x7D, 0x00, 0x02, 0x20, 0x7E /* ; F8-FF */ - } - } -}; - -static struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] = { - {0, { - 0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */ - 0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */ - 0x7C, 0x1D, 0x09, 0x7E, 0x7C, 0x1B, 0x0B, 0x7E, /* ; D0-D7 */ - 0x7C, 0x19, 0x0E, 0x7D, 0x7C, 0x17, 0x11, 0x7C, /* ; D8-DF */ - 0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x11, 0x17, 0x7C, /* ; E0-E7 */ - 0x7D, 0x0E, 0x19, 0x7C, 0x7E, 0x0B, 0x1B, 0x7C, /* ; EA-EF */ - 0x7E, 0x09, 0x1D, 0x7C, 0x7F, 0x06, 0x1F, 0x7C, /* ; F0-F7 */ - 0x7F, 0x04, 0x20, 0x7D, 0x00, 0x02, 0x20, 0x7E /* ; F8-FF */ - } - } -}; - -static struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] = { +static struct XGI301C_Tap4TimingStruct xgifb_tap4_timing[] = { {0, { 0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */ 0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */ @@ -3210,7 +3182,7 @@ static struct XGI301C_Tap4TimingStruct PALTap4Timing[] = { } }; -static struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] = { +static struct XGI301C_Tap4TimingStruct xgifb_ntsc_525_tap4_timing[] = { {480, { 0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */ 0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */ @@ -3246,78 +3218,6 @@ static struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] = { } }; -static struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] = { - {480, { - 0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */ - 0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */ - 0x7F, 0x19, 0x0C, 0x7C, 0x7E, 0x18, 0x0E, 0x7C, /* ; D0-D7 */ - 0x7E, 0x17, 0x10, 0x7B, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */ - 0x7D, 0x13, 0x13, 0x7D, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */ - 0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0E, 0x18, 0x7E, /* ; EA-EF */ - 0x7D, 0x0C, 0x19, 0x7E, 0x7D, 0x0A, 0x19, 0x00, /* ; F0-F7 */ - 0x7D, 0x08, 0x1A, 0x01, 0x7E, 0x06, 0x1A, 0x02 /* ; F8-FF */ - } - }, - {600, { - 0x07, 0x14, 0x07, 0x7E, 0x06, 0x14, 0x09, 0x7D, /* ; C0-C7 */ - 0x05, 0x14, 0x0A, 0x7D, 0x04, 0x13, 0x0B, 0x7E, /* ; C8-CF */ - 0x03, 0x13, 0x0C, 0x7E, 0x02, 0x12, 0x0D, 0x7F, /* ; D0-D7 */ - 0x01, 0x12, 0x0E, 0x7F, 0x01, 0x11, 0x0F, 0x7F, /* ; D8-DF */ - 0x01, 0x10, 0x10, 0x00, 0x7F, 0x0F, 0x11, 0x01, /* ; E0-E7 */ - 0x7F, 0x0E, 0x12, 0x01, 0x7E, 0x0D, 0x12, 0x03, /* ; EA-EF */ - 0x7E, 0x0C, 0x13, 0x03, 0x7E, 0x0B, 0x13, 0x04, /* ; F0-F7 */ - 0x7E, 0x0A, 0x14, 0x04, 0x7D, 0x09, 0x14, 0x06 /* ; F8-FF */ - } - }, - {0xFFFF, { - 0x09, 0x0F, 0x09, 0x7F, 0x08, 0x0F, 0x09, 0x00, /* ; C0-C7 */ - 0x07, 0x0F, 0x0A, 0x00, 0x06, 0x0F, 0x0A, 0x01, /* ; C8-CF */ - 0x06, 0x0E, 0x0B, 0x01, 0x05, 0x0E, 0x0B, 0x02, /* ; D0-D7 */ - 0x04, 0x0E, 0x0C, 0x02, 0x04, 0x0D, 0x0C, 0x03, /* ; D8-DF */ - 0x03, 0x0D, 0x0D, 0x03, 0x02, 0x0C, 0x0D, 0x05, /* ; E0-E7 */ - 0x02, 0x0C, 0x0E, 0x04, 0x01, 0x0B, 0x0E, 0x06, /* ; EA-EF */ - 0x01, 0x0B, 0x0E, 0x06, 0x00, 0x0A, 0x0F, 0x07, /* ; F0-F7 */ - 0x00, 0x0A, 0x0F, 0x07, 0x00, 0x09, 0x0F, 0x08 /* ; F8-FF */ - } - } -}; - -static struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] = { - {480, { - 0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */ - 0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */ - 0x7F, 0x19, 0x0C, 0x7C, 0x7E, 0x18, 0x0E, 0x7C, /* ; D0-D7 */ - 0x7E, 0x17, 0x10, 0x7B, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */ - 0x7D, 0x13, 0x13, 0x7D, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */ - 0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0E, 0x18, 0x7E, /* ; EA-EF */ - 0x7D, 0x0C, 0x19, 0x7E, 0x7D, 0x0A, 0x19, 0x00, /* ; F0-F7 */ - 0x7D, 0x08, 0x1A, 0x01, 0x7E, 0x06, 0x1A, 0x02 /* ; F8-FF */ - } - }, - {600, { - 0x07, 0x14, 0x07, 0x7E, 0x06, 0x14, 0x09, 0x7D, /* ; C0-C7 */ - 0x05, 0x14, 0x0A, 0x7D, 0x04, 0x13, 0x0B, 0x7E, /* ; C8-CF */ - 0x03, 0x13, 0x0C, 0x7E, 0x02, 0x12, 0x0D, 0x7F, /* ; D0-D7 */ - 0x01, 0x12, 0x0E, 0x7F, 0x01, 0x11, 0x0F, 0x7F, /* ; D8-DF */ - 0x01, 0x10, 0x10, 0x00, 0x7F, 0x0F, 0x11, 0x01, /* ; E0-E7 */ - 0x7F, 0x0E, 0x12, 0x01, 0x7E, 0x0D, 0x12, 0x03, /* ; EA-EF */ - 0x7E, 0x0C, 0x13, 0x03, 0x7E, 0x0B, 0x13, 0x04, /* ; F0-F7 */ - 0x7E, 0x0A, 0x14, 0x04, 0x7D, 0x09, 0x14, 0x06 /* ; F8-FF */ - } - }, - {0xFFFF, { - 0x09, 0x0F, 0x09, 0x7F, 0x08, 0x0F, 0x09, 0x00, /* ; C0-C7 */ - 0x07, 0x0F, 0x0A, 0x00, 0x06, 0x0F, 0x0A, 0x01, /* ; C8-CF */ - 0x06, 0x0E, 0x0B, 0x01, 0x05, 0x0E, 0x0B, 0x02, /* ; D0-D7 */ - 0x04, 0x0E, 0x0C, 0x02, 0x04, 0x0D, 0x0C, 0x03, /* ; D8-DF */ - 0x03, 0x0D, 0x0D, 0x03, 0x02, 0x0C, 0x0D, 0x05, /* ; E0-E7 */ - 0x02, 0x0C, 0x0E, 0x04, 0x01, 0x0B, 0x0E, 0x06, /* ; EA-EF */ - 0x01, 0x0B, 0x0E, 0x06, 0x00, 0x0A, 0x0F, 0x07, /* ; F0-F7 */ - 0x00, 0x0A, 0x0F, 0x07, 0x00, 0x09, 0x0F, 0x08 /* ; F8-FF */ - } - } -}; - static struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] = { {0xFFFF, { 0x05, 0x19, 0x05, 0x7D, 0x03, 0x19, 0x06, 0x7E, /* ; C0-C7 */ From d2de85c5da570977bb301c775b60b4a4a85d2338 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:11 +0300 Subject: [PATCH 0743/1519] staging: xgifb: delete IF_DEF_VideoCapture Delete already disabled code paths. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 1 - drivers/staging/xgifb/vb_setmode.c | 29 ----------------------------- drivers/staging/xgifb/vb_struct.h | 2 +- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index fab44146de0..00cdcb9cc69 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -148,7 +148,6 @@ #define SetCRT2ToDualEdge 0x8000 #define ProgrammingCRT2 0x0001 /* Set Flag */ -#define EnableVCMode 0x0002 #define ReserveTVOption 0x0008 #define Win9xDOSMode 0x0020 #define GatingCRT 0x0800 diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 100f63f0427..dc344f2efbb 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -3379,34 +3379,6 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, tempbx |= (SetInSlaveMode | SetSimuScanMode); } - - if (pVBInfo->IF_DEF_VideoCapture == 1) { - if (((HwDeviceExtension->jChipType == - XG40) && - (pVBInfo->Set_VGAType == XG40)) || - ((HwDeviceExtension->jChipType == - XG41) && - (pVBInfo->Set_VGAType == XG41)) || - ((HwDeviceExtension->jChipType == - XG42) && - (pVBInfo->Set_VGAType == XG42)) || - ((HwDeviceExtension->jChipType == - XG45) && - (pVBInfo->Set_VGAType == XG45))) { - if (ModeNo <= 13) { - if (!(tempbx & - SetCRT2ToRAMDAC)) { - /*CRT2 not need - * to support*/ - tempbx &= - (0x00FF | - (~SetInSlaveMode)); - pVBInfo->SetFlag - |= EnableVCMode; - } - } - } - } } /* LCD+TV can't support in slave mode @@ -7878,7 +7850,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; - pVBInfo->IF_DEF_VideoCapture = 0; pVBInfo->IF_DEF_ScaleLCD = 0; pVBInfo->IF_DEF_OEMUtil = 0; pVBInfo->IF_DEF_PWD = 0; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 3cb2e7e1b3b..2572e5cedde 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -288,7 +288,7 @@ struct vb_device_info { unsigned short ModeType; /* ,IF_DEF_FSTN; add for dstn */ unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; - unsigned short IF_DEF_CRT2Monitor, IF_DEF_VideoCapture; + unsigned short IF_DEF_CRT2Monitor; unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD; unsigned short IF_DEF_ExpLink; From 09cb8e509bfe9e2cf8f16772dac8df74c6a413a9 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:12 +0300 Subject: [PATCH 0744/1519] staging: xgifb: delete Win9xDOSMode Delete another useless flag. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 1 - drivers/staging/xgifb/vb_setmode.c | 536 ++++++++++++++--------------- 2 files changed, 256 insertions(+), 281 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 00cdcb9cc69..5beeef99bb1 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -149,7 +149,6 @@ #define ProgrammingCRT2 0x0001 /* Set Flag */ #define ReserveTVOption 0x0008 -#define Win9xDOSMode 0x0020 #define GatingCRT 0x0800 #define DisableChB 0x1000 #define EnableChB 0x2000 diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index dc344f2efbb..15eb00dce1c 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2612,284 +2612,282 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, else modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; - if (!(pVBInfo->SetFlag & Win9xDOSMode)) { - if (pVBInfo->IF_DEF_OEMUtil == 1) { - tempbx = 8; - LCDPtr = (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr(tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } + if (pVBInfo->IF_DEF_OEMUtil == 1) { + tempbx = 8; + LCDPtr = (struct XGI330_LCDDataDesStruct *) + XGI_GetLcdPtr(tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + } - if ((pVBInfo->IF_DEF_OEMUtil == 0) || - (LCDPtr == NULL)) { - tempbx = 3; - if (pVBInfo->LCDInfo & EnableScalingLCD) - LCDPtr1 = - (struct XGI330_LCDDataDesStruct2 *) - XGI_GetLcdPtr( + if ((pVBInfo->IF_DEF_OEMUtil == 0) || + (LCDPtr == NULL)) { + tempbx = 3; + if (pVBInfo->LCDInfo & EnableScalingLCD) + LCDPtr1 = + (struct XGI330_LCDDataDesStruct2 *) + XGI_GetLcdPtr( + tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + else + LCDPtr = + (struct XGI330_LCDDataDesStruct *) + XGI_GetLcdPtr( tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - else - LCDPtr = - (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } + } - XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); - push1 = tempbx; - push2 = tempax; + XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); + push1 = tempbx; + push2 = tempax; - /* GetLCDResInfo */ - if ((pVBInfo->LCDResInfo == Panel1024x768) || - (pVBInfo->LCDResInfo == Panel1024x768x75)) { - tempax = 1024; - tempbx = 768; - } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || - (pVBInfo->LCDResInfo == Panel1280x1024x75)) { - tempax = 1280; - tempbx = 1024; - } else if (pVBInfo->LCDResInfo == Panel1400x1050) { - tempax = 1400; - tempbx = 1050; - } else { - tempax = 1600; - tempbx = 1200; - } + /* GetLCDResInfo */ + if ((pVBInfo->LCDResInfo == Panel1024x768) || + (pVBInfo->LCDResInfo == Panel1024x768x75)) { + tempax = 1024; + tempbx = 768; + } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || + (pVBInfo->LCDResInfo == Panel1280x1024x75)) { + tempax = 1280; + tempbx = 1024; + } else if (pVBInfo->LCDResInfo == Panel1400x1050) { + tempax = 1400; + tempbx = 1050; + } else { + tempax = 1600; + tempbx = 1200; + } - if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { - pVBInfo->HDE = tempax; - pVBInfo->VDE = tempbx; - pVBInfo->VGAHDE = tempax; - pVBInfo->VGAVDE = tempbx; - } + if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { + pVBInfo->HDE = tempax; + pVBInfo->VDE = tempbx; + pVBInfo->VGAHDE = tempax; + pVBInfo->VGAVDE = tempbx; + } - if ((pVBInfo->IF_DEF_ScaleLCD == 1) && - (pVBInfo->LCDInfo & EnableScalingLCD)) { - tempax = pVBInfo->HDE; - tempbx = pVBInfo->VDE; - } - - tempax = pVBInfo->HT; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHDES; - else - tempbx = LCDPtr->LCDHDES; - - tempcx = pVBInfo->HDE; - tempbx = tempbx & 0x0fff; - tempcx += tempbx; - - if (tempcx >= tempax) - tempcx -= tempax; - - xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); - - tempcx = tempcx >> 3; - tempbx = tempbx >> 3; - - xgifb_reg_set(pVBInfo->Part1Port, 0x16, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x17, - (unsigned short) (tempcx & 0xff)); - - tempax = pVBInfo->HT; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHRS; - else - tempbx = LCDPtr->LCDHRS; - - tempcx = push2; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempcx = LCDPtr1->LCDHSync; - - tempcx += tempbx; - - if (tempcx >= tempax) - tempcx -= tempax; - - tempax = tempbx & 0x07; - tempax = tempax >> 5; - tempcx = tempcx >> 3; - tempbx = tempbx >> 3; - - tempcx &= 0x1f; - tempax |= tempcx; - - xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); - xgifb_reg_set(pVBInfo->Part1Port, 0x14, - (unsigned short) (tempbx & 0xff)); - - tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVDES; - else - tempbx = LCDPtr->LCDVDES; - tempcx = pVBInfo->VDE; - - tempbx = tempbx & 0x0fff; - tempcx += tempbx; - if (tempcx >= tempax) - tempcx -= tempax; - - xgifb_reg_set(pVBInfo->Part1Port, 0x1b, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x1c, - (unsigned short) (tempcx & 0xff)); - - tempbx = (tempbx >> 8) & 0x07; - tempcx = (tempcx >> 8) & 0x07; - - xgifb_reg_set(pVBInfo->Part1Port, 0x1d, - (unsigned short) ((tempcx << 3) - | tempbx)); - - tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVRS; - else - tempbx = LCDPtr->LCDVRS; - - /* tempbx = tempbx >> 4; */ - tempcx = push1; - - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempcx = LCDPtr1->LCDVSync; - - tempcx += tempbx; - if (tempcx >= tempax) - tempcx -= tempax; - - xgifb_reg_set(pVBInfo->Part1Port, 0x18, - (unsigned short) (tempbx & 0xff)); - xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, - (unsigned short) (tempcx & 0x0f)); - - tempax = ((tempbx >> 8) & 0x07) << 3; - - tempbx = pVBInfo->VGAVDE; - if (tempbx != pVBInfo->VDE) - tempax |= 0x40; - - if (pVBInfo->LCDInfo & EnableLVDSDDA) - tempax |= 0x40; - - xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, - tempax); - - tempcx = pVBInfo->VGAVT; + if ((pVBInfo->IF_DEF_ScaleLCD == 1) && + (pVBInfo->LCDInfo & EnableScalingLCD)) { + tempax = pVBInfo->HDE; tempbx = pVBInfo->VDE; - tempax = pVBInfo->VGAVDE; + } + + tempax = pVBInfo->HT; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDHDES; + else + tempbx = LCDPtr->LCDHDES; + + tempcx = pVBInfo->HDE; + tempbx = tempbx & 0x0fff; + tempcx += tempbx; + + if (tempcx >= tempax) tempcx -= tempax; - temp = tempax; /* 0430 ylshieh */ - temp1 = (temp << 18) / tempbx; + xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); - tempdx = (unsigned short) ((temp << 18) % tempbx); + tempcx = tempcx >> 3; + tempbx = tempbx >> 3; - if (tempdx != 0) - temp1 += 1; + xgifb_reg_set(pVBInfo->Part1Port, 0x16, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x17, + (unsigned short) (tempcx & 0xff)); - temp2 = temp1; - push3 = temp2; + tempax = pVBInfo->HT; - xgifb_reg_set(pVBInfo->Part1Port, 0x37, - (unsigned short) (temp2 & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x36, - (unsigned short) ((temp2 >> 8) & 0xff)); + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDHRS; + else + tempbx = LCDPtr->LCDHRS; + tempcx = push2; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempcx = LCDPtr1->LCDHSync; + + tempcx += tempbx; + + if (tempcx >= tempax) + tempcx -= tempax; + + tempax = tempbx & 0x07; + tempax = tempax >> 5; + tempcx = tempcx >> 3; + tempbx = tempbx >> 3; + + tempcx &= 0x1f; + tempax |= tempcx; + + xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); + xgifb_reg_set(pVBInfo->Part1Port, 0x14, + (unsigned short) (tempbx & 0xff)); + + tempax = pVBInfo->VT; + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDVDES; + else + tempbx = LCDPtr->LCDVDES; + tempcx = pVBInfo->VDE; + + tempbx = tempbx & 0x0fff; + tempcx += tempbx; + if (tempcx >= tempax) + tempcx -= tempax; + + xgifb_reg_set(pVBInfo->Part1Port, 0x1b, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x1c, + (unsigned short) (tempcx & 0xff)); + + tempbx = (tempbx >> 8) & 0x07; + tempcx = (tempcx >> 8) & 0x07; + + xgifb_reg_set(pVBInfo->Part1Port, 0x1d, + (unsigned short) ((tempcx << 3) + | tempbx)); + + tempax = pVBInfo->VT; + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempbx = LCDPtr1->LCDVRS; + else + tempbx = LCDPtr->LCDVRS; + + /* tempbx = tempbx >> 4; */ + tempcx = push1; + + if (pVBInfo->LCDInfo & EnableScalingLCD) + tempcx = LCDPtr1->LCDVSync; + + tempcx += tempbx; + if (tempcx >= tempax) + tempcx -= tempax; + + xgifb_reg_set(pVBInfo->Part1Port, 0x18, + (unsigned short) (tempbx & 0xff)); + xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, + (unsigned short) (tempcx & 0x0f)); + + tempax = ((tempbx >> 8) & 0x07) << 3; + + tempbx = pVBInfo->VGAVDE; + if (tempbx != pVBInfo->VDE) + tempax |= 0x40; + + if (pVBInfo->LCDInfo & EnableLVDSDDA) + tempax |= 0x40; + + xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, + tempax); + + tempcx = pVBInfo->VGAVT; + tempbx = pVBInfo->VDE; + tempax = pVBInfo->VGAVDE; + tempcx -= tempax; + + temp = tempax; /* 0430 ylshieh */ + temp1 = (temp << 18) / tempbx; + + tempdx = (unsigned short) ((temp << 18) % tempbx); + + if (tempdx != 0) + temp1 += 1; + + temp2 = temp1; + push3 = temp2; + + xgifb_reg_set(pVBInfo->Part1Port, 0x37, + (unsigned short) (temp2 & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x36, + (unsigned short) ((temp2 >> 8) & 0xff)); + + tempbx = (unsigned short) (temp2 >> 16); + tempax = tempbx & 0x03; + + tempbx = pVBInfo->VGAVDE; + if (tempbx == pVBInfo->VDE) + tempax |= 0x04; + + xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); + + if (pVBInfo->VBType & VB_XGI301C) { + temp2 = push3; + xgifb_reg_set(pVBInfo->Part4Port, + 0x3c, + (unsigned short) (temp2 & 0xff)); + xgifb_reg_set(pVBInfo->Part4Port, + 0x3b, + (unsigned short) ((temp2 >> 8) & + 0xff)); tempbx = (unsigned short) (temp2 >> 16); - tempax = tempbx & 0x03; + xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, + ~0xc0, + (unsigned short) ((tempbx & + 0xff) << 6)); - tempbx = pVBInfo->VGAVDE; - if (tempbx == pVBInfo->VDE) - tempax |= 0x04; - - xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); - - if (pVBInfo->VBType & VB_XGI301C) { - temp2 = push3; - xgifb_reg_set(pVBInfo->Part4Port, - 0x3c, - (unsigned short) (temp2 & 0xff)); - xgifb_reg_set(pVBInfo->Part4Port, - 0x3b, - (unsigned short) ((temp2 >> 8) & - 0xff)); - tempbx = (unsigned short) (temp2 >> 16); - xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, - ~0xc0, - (unsigned short) ((tempbx & - 0xff) << 6)); - - tempcx = pVBInfo->VGAVDE; - if (tempcx == pVBInfo->VDE) - xgifb_reg_and_or(pVBInfo->Part4Port, - 0x30, ~0x0c, 0x00); - else - xgifb_reg_and_or(pVBInfo->Part4Port, - 0x30, ~0x0c, 0x08); - } - - tempcx = pVBInfo->VGAHDE; - tempbx = pVBInfo->HDE; - - temp1 = tempcx << 16; - - tempax = (unsigned short) (temp1 / tempbx); - - if ((tempbx & 0xffff) == (tempcx & 0xffff)) - tempax = 65535; - - temp3 = tempax; - temp1 = pVBInfo->VGAHDE << 16; - - temp1 /= temp3; - temp3 = temp3 << 16; - temp1 -= 1; - - temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); - - tempax = (unsigned short) (temp3 & 0xff); - xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); - - temp1 = pVBInfo->VGAVDE << 18; - temp1 = temp1 / push3; - tempbx = (unsigned short) (temp1 & 0xffff); - - if (pVBInfo->LCDResInfo == Panel1024x768) - tempbx -= 1; - - tempax = ((tempbx >> 8) & 0xff) << 3; - tempax |= (unsigned short) ((temp3 >> 8) & 0x07); - xgifb_reg_set(pVBInfo->Part1Port, 0x20, - (unsigned short) (tempax & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x21, - (unsigned short) (tempbx & 0xff)); - - temp3 = temp3 >> 16; - - if (modeflag & HalfDCLK) - temp3 = temp3 >> 1; - - xgifb_reg_set(pVBInfo->Part1Port, 0x22, - (unsigned short) ((temp3 >> 8) & 0xff)); - xgifb_reg_set(pVBInfo->Part1Port, 0x23, - (unsigned short) (temp3 & 0xff)); + tempcx = pVBInfo->VGAVDE; + if (tempcx == pVBInfo->VDE) + xgifb_reg_and_or(pVBInfo->Part4Port, + 0x30, ~0x0c, 0x00); + else + xgifb_reg_and_or(pVBInfo->Part4Port, + 0x30, ~0x0c, 0x08); } + + tempcx = pVBInfo->VGAHDE; + tempbx = pVBInfo->HDE; + + temp1 = tempcx << 16; + + tempax = (unsigned short) (temp1 / tempbx); + + if ((tempbx & 0xffff) == (tempcx & 0xffff)) + tempax = 65535; + + temp3 = tempax; + temp1 = pVBInfo->VGAHDE << 16; + + temp1 /= temp3; + temp3 = temp3 << 16; + temp1 -= 1; + + temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); + + tempax = (unsigned short) (temp3 & 0xff); + xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); + + temp1 = pVBInfo->VGAVDE << 18; + temp1 = temp1 / push3; + tempbx = (unsigned short) (temp1 & 0xffff); + + if (pVBInfo->LCDResInfo == Panel1024x768) + tempbx -= 1; + + tempax = ((tempbx >> 8) & 0xff) << 3; + tempax |= (unsigned short) ((temp3 >> 8) & 0x07); + xgifb_reg_set(pVBInfo->Part1Port, 0x20, + (unsigned short) (tempax & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x21, + (unsigned short) (tempbx & 0xff)); + + temp3 = temp3 >> 16; + + if (modeflag & HalfDCLK) + temp3 = temp3 >> 1; + + xgifb_reg_set(pVBInfo->Part1Port, 0x22, + (unsigned short) ((temp3 >> 8) & 0xff)); + xgifb_reg_set(pVBInfo->Part1Port, 0x23, + (unsigned short) (temp3 & 0xff)); } /* --------------------------------------------------------------------- */ @@ -3857,8 +3855,7 @@ static void XGI_WaitDisply(struct vb_device_info *pVBInfo) static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) { - if (!(pVBInfo->SetFlag & Win9xDOSMode)) - xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); + xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); } static void XGI_SaveCRT2Info(unsigned short ModeNo, @@ -6448,9 +6445,6 @@ void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, { unsigned short tempah = 0; - if (pVBInfo->SetFlag == Win9xDOSMode) - return; - if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { tempah = 0x3F; @@ -6988,9 +6982,6 @@ static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - if (pVBInfo->SetFlag & Win9xDOSMode) - return; - /* GetPart1IO(); */ XGI_SetDelayComp(pVBInfo); @@ -7588,16 +7579,6 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, { unsigned short tempah; - if (pVBInfo->SetFlag == Win9xDOSMode) { - if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV - | VB_XGI302LV | VB_XGI301C)) { - XGI_DisplayOn(HwDeviceExtension, pVBInfo); - return; - } else - /* LVDS or CH7017 */ - return; - } - if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { if (!(pVBInfo->SetFlag & DisableChA)) { @@ -7698,11 +7679,6 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, /* EnablePart4_1F */ xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); - if (pVBInfo->SetFlag & Win9xDOSMode) { - XGI_DisplayOn(HwDeviceExtension, pVBInfo); - return; - } - if (!(pVBInfo->SetFlag & DisableChA)) { XGI_VBLongWait(pVBInfo); if (!(pVBInfo->SetFlag & GatingCRT)) { From 66cfacecc3c6c8cdb5d0c6259e2b5d668d264e48 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:13 +0300 Subject: [PATCH 0745/1519] staging: xgifb: delete IF_DEF_OEMUtil Delete already disabled code paths. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 45 ++++++++++-------------------- drivers/staging/xgifb/vb_struct.h | 2 +- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 15eb00dce1c..15606eabd0e 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2612,38 +2612,25 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, else modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; - if (pVBInfo->IF_DEF_OEMUtil == 1) { - tempbx = 8; - LCDPtr = (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr(tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } - - if ((pVBInfo->IF_DEF_OEMUtil == 0) || - (LCDPtr == NULL)) { - tempbx = 3; - if (pVBInfo->LCDInfo & EnableScalingLCD) - LCDPtr1 = - (struct XGI330_LCDDataDesStruct2 *) - XGI_GetLcdPtr( + tempbx = 3; + if (pVBInfo->LCDInfo & EnableScalingLCD) + LCDPtr1 = + (struct XGI330_LCDDataDesStruct2 *) + XGI_GetLcdPtr( + tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + else + LCDPtr = + (struct XGI330_LCDDataDesStruct *) + XGI_GetLcdPtr( tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - else - LCDPtr = - (struct XGI330_LCDDataDesStruct *) - XGI_GetLcdPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - } XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); push1 = tempbx; @@ -3549,9 +3536,6 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, /* End of LCD75 */ - if (pVBInfo->IF_DEF_OEMUtil == 1) - pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; - if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return 0; @@ -7827,7 +7811,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; pVBInfo->IF_DEF_ScaleLCD = 0; - pVBInfo->IF_DEF_OEMUtil = 0; pVBInfo->IF_DEF_PWD = 0; if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 2572e5cedde..3f6c688c88b 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -290,7 +290,7 @@ struct vb_device_info { unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; unsigned short IF_DEF_CRT2Monitor; unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, - IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD; + IF_DEF_ScaleLCD, IF_DEF_PWD; unsigned short IF_DEF_ExpLink; unsigned short IF_DEF_HiVision; unsigned short LCDResInfo, LCDTypeInfo, VBType;/*301b*/ From 3d6defaddaea531e37fb2e9a425668d387229809 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:14 +0300 Subject: [PATCH 0746/1519] staging: xgifb: delete IF_DEF_PWD Delete already disabled code paths. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 11 ----------- drivers/staging/xgifb/vb_struct.h | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 15606eabd0e..520747a5aed 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -3602,16 +3602,6 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->LCDInfo = tempbx; - if (pVBInfo->IF_DEF_PWD == 1) { - if (pVBInfo->LCDInfo & SetPWDEnable) { - if ((pVBInfo->VBType & VB_XGI302LV) || - (pVBInfo->VBType & VB_XGI301C)) { - if (!(tempax & PWDEnable)) - pVBInfo->LCDInfo &= ~SetPWDEnable; - } - } - } - if (pVBInfo->IF_DEF_LVDS == 0) { if (tempax & (LockLCDBToA | StLCDBToA)) { if (pVBInfo->VBInfo & SetInSlaveMode) { @@ -7811,7 +7801,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; pVBInfo->IF_DEF_ScaleLCD = 0; - pVBInfo->IF_DEF_PWD = 0; if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ pVBInfo->IF_DEF_YPbPr = 0; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 3f6c688c88b..2a38405c467 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -290,7 +290,7 @@ struct vb_device_info { unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; unsigned short IF_DEF_CRT2Monitor; unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, - IF_DEF_ScaleLCD, IF_DEF_PWD; + IF_DEF_ScaleLCD; unsigned short IF_DEF_ExpLink; unsigned short IF_DEF_HiVision; unsigned short LCDResInfo, LCDTypeInfo, VBType;/*301b*/ From aef6bc745880d5b97b3244d1bf7fdc3860a2fb2b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:15 +0300 Subject: [PATCH 0747/1519] staging: xgifb: delete IF_DEF_ScaleLCD Delete one more disabled feature. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 73 +++++++++++------------------- drivers/staging/xgifb/vb_struct.h | 3 +- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 520747a5aed..efdda2256b9 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2490,40 +2490,36 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, index = index & IndexMask; - if ((pVBInfo->IF_DEF_ScaleLCD == 0) || - ((pVBInfo->IF_DEF_ScaleLCD == 1) && - (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { - tempbx = 0; + tempbx = 0; - if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) - XGI_GetLcdPtr(tempbx, ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); + if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) + XGI_GetLcdPtr(tempbx, ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); - for (i = 0; i < 8; i++) - pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; - } - - XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); - - tempbx = 1; - - if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) - XGI_GetLcdPtr( - tempbx, - ModeNo, - ModeIdIndex, - RefreshRateTableIndex, - pVBInfo); - for (i = 0; i < 7; i++) - pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; - } - - XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); + for (i = 0; i < 8; i++) + pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; } + + XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); + + tempbx = 1; + + if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) + XGI_GetLcdPtr( + tempbx, + ModeNo, + ModeIdIndex, + RefreshRateTableIndex, + pVBInfo); + for (i = 0; i < 7; i++) + pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; + } + + XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); } static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) @@ -2660,12 +2656,6 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->VGAVDE = tempbx; } - if ((pVBInfo->IF_DEF_ScaleLCD == 1) && - (pVBInfo->LCDInfo & EnableScalingLCD)) { - tempax = pVBInfo->HDE; - tempbx = pVBInfo->VDE; - } - tempax = pVBInfo->HT; if (pVBInfo->LCDInfo & EnableScalingLCD) @@ -2889,11 +2879,6 @@ static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, unsigned short index; if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if (pVBInfo->IF_DEF_ScaleLCD == 1) { - if (pVBInfo->LCDInfo & EnableScalingLCD) - return; - } - /* index = XGI_GetLCDCapPtr(pVBInfo); */ index = XGI_GetLCDCapPtr1(pVBInfo); @@ -3545,9 +3530,6 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); - if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) - temp &= ~EnableScalingLCD; - tempbx |= temp; LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); @@ -7800,7 +7782,6 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; - pVBInfo->IF_DEF_ScaleLCD = 0; if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ pVBInfo->IF_DEF_YPbPr = 0; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 2a38405c467..6f13442bd6a 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -289,8 +289,7 @@ struct vb_device_info { /* ,IF_DEF_FSTN; add for dstn */ unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; unsigned short IF_DEF_CRT2Monitor; - unsigned short IF_DEF_LCDA, IF_DEF_YPbPr, - IF_DEF_ScaleLCD; + unsigned short IF_DEF_LCDA, IF_DEF_YPbPr; unsigned short IF_DEF_ExpLink; unsigned short IF_DEF_HiVision; unsigned short LCDResInfo, LCDTypeInfo, VBType;/*301b*/ From 939161571c01670ecc7e33a6b880ed812a17bbc6 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 29 Aug 2011 13:54:59 -0700 Subject: [PATCH 0748/1519] staging: fix rtl8192e build errors drivers/staging/rtl8192e/rtllib.h:2329: error: field 'wx_sem' has incomplete type drivers/staging/rtl8192e/rtllib.h:2330: error: field 'scan_sem' has incomplete type drivers/staging/rtl8192e/rtllib.h:2331: error: field 'ips_sem' has incomplete type drivers/staging/rtl8192e/rtllib_wx.c:267: error: implicit declaration of function 'down' drivers/staging/rtl8192e/rtllib_wx.c:290: error: implicit declaration of function 'up' Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b33caccb43a..c80460e0cfc 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include From 6699291f89aa3e22490c9c93620350f92015b699 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Tue, 30 Aug 2011 00:17:56 +0400 Subject: [PATCH 0749/1519] staging: lirc: fix mismatch in mutex lock-unlock in imon_probe If kzalloc failed for allocation of context, goto alloc_status_switch leads to unlock of unacquired driver_lock. The patch moves mutex_lock(&driver_lock) before allocation of context. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lirc/lirc_imon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c index 4a9e563f40f..f5308d5929c 100644 --- a/drivers/staging/lirc/lirc_imon.c +++ b/drivers/staging/lirc/lirc_imon.c @@ -727,6 +727,9 @@ static int imon_probe(struct usb_interface *interface, int i; u16 vendor, product; + /* prevent races probing devices w/multiple interfaces */ + mutex_lock(&driver_lock); + context = kzalloc(sizeof(struct imon_context), GFP_KERNEL); if (!context) { err("%s: kzalloc failed for context", __func__); @@ -753,9 +756,6 @@ static int imon_probe(struct usb_interface *interface, dev_dbg(dev, "%s: found iMON device (%04x:%04x, intf%d)\n", __func__, vendor, product, ifnum); - /* prevent races probing devices w/multiple interfaces */ - mutex_lock(&driver_lock); - /* * Scan the endpoint list and set: * first input endpoint = IR endpoint From 06b3f44a9784c48c64dfedf5f012deb93049a3aa Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Tue, 30 Aug 2011 00:54:21 +0400 Subject: [PATCH 0750/1519] staging: lirc_sasem: fix NULL pointer dereference in sasem_probe If any memory allocation failed, goto alloc_status_switch leads to mutex_unlock(&context->ctx_lock) while context is NULL. The patch moves alloc_status_switch to handle error conditions in correct way. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lirc/lirc_sasem.c | 46 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c index 7080cdeab5a..a2d18b0aa04 100644 --- a/drivers/staging/lirc/lirc_sasem.c +++ b/drivers/staging/lirc/lirc_sasem.c @@ -814,29 +814,6 @@ static int sasem_probe(struct usb_interface *interface, printk(KERN_INFO "%s: Registered Sasem driver (minor:%d)\n", __func__, lirc_minor); -alloc_status_switch: - - switch (alloc_status) { - - case 7: - if (vfd_ep_found) - usb_free_urb(tx_urb); - case 6: - usb_free_urb(rx_urb); - case 5: - lirc_buffer_free(rbuf); - case 4: - kfree(rbuf); - case 3: - kfree(driver); - case 2: - kfree(context); - context = NULL; - case 1: - retval = -ENOMEM; - goto unlock; - } - /* Needed while unregistering! */ driver->minor = lirc_minor; @@ -867,6 +844,29 @@ alloc_status_switch: __func__, dev->bus->busnum, dev->devnum); unlock: mutex_unlock(&context->ctx_lock); + +alloc_status_switch: + switch (alloc_status) { + + case 7: + if (vfd_ep_found) + usb_free_urb(tx_urb); + case 6: + usb_free_urb(rx_urb); + case 5: + lirc_buffer_free(rbuf); + case 4: + kfree(rbuf); + case 3: + kfree(driver); + case 2: + kfree(context); + context = NULL; + case 1: + if (retval == 0) + retval = -ENOMEM; + } + exit: return retval; } From d531babe8259992be32144f2c80fa5e15f9d4d26 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Wed, 31 Aug 2011 14:35:54 -0700 Subject: [PATCH 0751/1519] Staging: hv: util: Deal with driver register failures Properly deal with vmbus_driver_register() failures. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_util.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index e29a2a23eda..603921771b9 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -277,6 +277,7 @@ static struct hv_driver util_drv = { static int __init init_hyperv_utils(void) { + int ret; pr_info("Registering HyperV Utility Driver\n"); if (hv_kvp_init()) @@ -289,12 +290,15 @@ static int __init init_hyperv_utils(void) if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) { pr_info("Unable to allocate memory for receive buffer\n"); - kfree(shut_txf_buf); - kfree(time_txf_buf); - kfree(hbeat_txf_buf); - return -ENOMEM; + ret = -ENOMEM; + goto err; } + ret = vmbus_driver_register(&util_drv); + + if (ret != 0) + goto err; + hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; @@ -303,7 +307,14 @@ static int __init init_hyperv_utils(void) hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; - return vmbus_driver_register(&util_drv); + return 0; + +err: + kfree(shut_txf_buf); + kfree(time_txf_buf); + kfree(hbeat_txf_buf); + + return ret; } static void exit_hyperv_utils(void) From 8b9987e9050aeba12325a3f0ab0f4a2934c37c3c Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Wed, 31 Aug 2011 14:35:55 -0700 Subject: [PATCH 0752/1519] Staging: hv: vmbus: Fix a bug in error handling in vmbus_bus_init() Fix a bug in error handling in vmbus_bus_init(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 757943b5d40..b5e06d68f05 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -492,7 +492,7 @@ static int vmbus_bus_init(int irq) ret = bus_register(&hv_bus); if (ret) - return ret; + goto err_cleanup; ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM, driver_name, hv_acpi_dev); @@ -500,10 +500,7 @@ static int vmbus_bus_init(int irq) if (ret != 0) { pr_err("Unable to request IRQ %d\n", irq); - - bus_unregister(&hv_bus); - - return ret; + goto err_unregister; } vector = IRQ0_VECTOR + irq; @@ -514,16 +511,23 @@ static int vmbus_bus_init(int irq) */ on_each_cpu(hv_synic_init, (void *)&vector, 1); ret = vmbus_connect(); - if (ret) { - free_irq(irq, hv_acpi_dev); - bus_unregister(&hv_bus); - return ret; - } - + if (ret) + goto err_irq; vmbus_request_offers(); return 0; + +err_irq: + free_irq(irq, hv_acpi_dev); + +err_unregister: + bus_unregister(&hv_bus); + +err_cleanup: + hv_cleanup(); + + return ret; } /** From 7341d908af307a34098a9da52f49037d815c868f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Wed, 31 Aug 2011 14:35:56 -0700 Subject: [PATCH 0753/1519] Staging: hv: vmbus: Check for events before messages The Windows team has informed us that on Windows guests on Hyper-V, they check for events before messages. They also recommended that we do the same. This patch addresses this. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index b5e06d68f05..cd43ddd3cc8 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -442,14 +442,11 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) union hv_synic_event_flags *event; bool handled = false; - page_addr = hv_context.synic_message_page[cpu]; - msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; - - /* Check if there are actual msgs to be process */ - if (msg->header.message_type != HVMSG_NONE) { - handled = true; - tasklet_schedule(&msg_dpc); - } + /* + * Check for events before checking for messages. This is the order + * in which events and messages are checked in Windows guests on + * Hyper-V, and the Windows team suggested we do the same. + */ page_addr = hv_context.synic_event_page[cpu]; event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; @@ -460,6 +457,15 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) tasklet_schedule(&event_dpc); } + page_addr = hv_context.synic_message_page[cpu]; + msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; + + /* Check if there are actual msgs to be processed */ + if (msg->header.message_type != HVMSG_NONE) { + handled = true; + tasklet_schedule(&msg_dpc); + } + if (handled) return IRQ_HANDLED; else From 24326039b9685e8bfb1532932e18cb458f2a3517 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Wed, 31 Aug 2011 14:35:57 -0700 Subject: [PATCH 0754/1519] Staging: hv: vmbus: Cleanup the code in process_chn_event() A channel in Hyper-V is equivalent to a device. Thus, a channel is persistent once it is presented to the guest, even if the driver managing this device is unloaded. By checking and invoking the driver specific callback function under the protection of the channel inbound_lock, we can properly deal with racing driver unloads since an unloading driver sets the callback to NULL under the protection of this inbound_lock. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/connection.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 9e99c044b23..649b91bcd8c 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -219,11 +219,25 @@ static void process_chn_event(u32 relid) */ channel = relid2channel(relid); + if (!channel) { + pr_err("channel not found for relid - %u\n", relid); + return; + } + + /* + * A channel once created is persistent even when there + * is no driver handling the device. An unloading driver + * sets the onchannel_callback to NULL under the + * protection of the channel inbound_lock. Thus, checking + * and invoking the driver specific callback takes care of + * orderly unloading of the driver. + */ + spin_lock_irqsave(&channel->inbound_lock, flags); - if (channel && (channel->onchannel_callback != NULL)) + if (channel->onchannel_callback != NULL) channel->onchannel_callback(channel->channel_callback_context); else - pr_err("channel not found for relid - %u\n", relid); + pr_err("no channel callback for relid - %u\n", relid); spin_unlock_irqrestore(&channel->inbound_lock, flags); } From a3e8095886b65af402e24cd5c32173d9acd0123a Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:39 -0700 Subject: [PATCH 0755/1519] staging: hv: remove unnecessary includes in netvsc hyperv.h is included by hyperv_net.h already, so no need to include it again in these C files. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 1 - drivers/staging/hv/netvsc_drv.c | 1 - drivers/staging/hv/rndis_filter.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 30d31395285..9a9228c23d6 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -28,7 +28,6 @@ #include #include -#include "hyperv.h" #include "hyperv_net.h" diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 90a3198c997..30a0cb2c0fe 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -38,7 +38,6 @@ #include #include -#include "hyperv.h" #include "hyperv_net.h" struct net_device_context { diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 6db48b92fe9..8416bf2e2ea 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -27,7 +27,6 @@ #include #include -#include "hyperv.h" #include "hyperv_net.h" From c909ebbd0dcf19c617408c2cfde56c4bbd4f6cb4 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:40 -0700 Subject: [PATCH 0756/1519] staging: hv: add newline to log messages in netvsc Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 9a9228c23d6..ef764e614b0 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -108,7 +108,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) */ if (ret != 0) { dev_err(&net_device->dev->device, "unable to send " - "revoke receive buffer to netvsp"); + "revoke receive buffer to netvsp\n"); return ret; } } @@ -123,7 +123,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) */ if (ret != 0) { dev_err(&net_device->dev->device, - "unable to teardown receive buffer's gpadl"); + "unable to teardown receive buffer's gpadl\n"); return ret; } net_device->recv_buf_gpadl_handle = 0; @@ -155,7 +155,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device = get_outbound_net_device(device); if (!net_device) { dev_err(&device->device, "unable to get net device..." - "device being destroyed?"); + "device being destroyed?\n"); return -ENODEV; } @@ -164,7 +164,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) get_order(net_device->recv_buf_size)); if (!net_device->recv_buf) { dev_err(&device->device, "unable to allocate receive " - "buffer of size %d", net_device->recv_buf_size); + "buffer of size %d\n", net_device->recv_buf_size); ret = -ENOMEM; goto cleanup; } @@ -179,7 +179,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) &net_device->recv_buf_gpadl_handle); if (ret != 0) { dev_err(&device->device, - "unable to establish receive buffer's gpadl"); + "unable to establish receive buffer's gpadl\n"); goto cleanup; } @@ -203,7 +203,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { dev_err(&device->device, - "unable to send receive buffer's gpadl to netvsp"); + "unable to send receive buffer's gpadl to netvsp\n"); goto cleanup; } @@ -215,7 +215,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) if (init_packet->msg.v1_msg. send_recv_buf_complete.status != NVSP_STAT_SUCCESS) { dev_err(&device->device, "Unable to complete receive buffer " - "initialzation with NetVsp - status %d", + "initialzation with NetVsp - status %d\n", init_packet->msg.v1_msg. send_recv_buf_complete.status); ret = -EINVAL; @@ -270,7 +270,7 @@ static int netvsc_connect_vsp(struct hv_device *device) net_device = get_outbound_net_device(device); if (!net_device) { dev_err(&device->device, "unable to get net device..." - "device being destroyed?"); + "device being destroyed?\n"); return -ENODEV; } @@ -361,7 +361,7 @@ int netvsc_device_remove(struct hv_device *device) /* Wait for all send completions */ while (atomic_read(&net_device->num_outstanding_sends)) { dev_err(&device->device, - "waiting for %d requests to complete...", + "waiting for %d requests to complete...\n", atomic_read(&net_device->num_outstanding_sends)); udelay(100); } @@ -381,7 +381,7 @@ int netvsc_device_remove(struct hv_device *device) spin_unlock_irqrestore(&device->channel->inbound_lock, flags); /* At this point, no one should be accessing netDevice except in here */ - dev_notice(&device->device, "net device safe to remove"); + dev_notice(&device->device, "net device safe to remove\n"); /* Now, we can close the channel safely */ vmbus_close(device->channel); @@ -407,7 +407,7 @@ static void netvsc_send_completion(struct hv_device *device, net_device = get_inbound_net_device(device); if (!net_device) { dev_err(&device->device, "unable to get net device..." - "device being destroyed?"); + "device being destroyed?\n"); return; } @@ -436,7 +436,7 @@ static void netvsc_send_completion(struct hv_device *device, atomic_dec(&net_device->num_outstanding_sends); } else { dev_err(&device->device, "Unknown send completion packet type- " - "%d received!!", nvsp_packet->hdr.msg_type); + "%d received!!\n", nvsp_packet->hdr.msg_type); } } @@ -452,7 +452,7 @@ int netvsc_send(struct hv_device *device, net_device = get_outbound_net_device(device); if (!net_device) { dev_err(&device->device, "net device (%p) shutting down..." - "ignoring outbound packets", net_device); + "ignoring outbound packets\n", net_device); return -ENODEV; } @@ -487,7 +487,7 @@ int netvsc_send(struct hv_device *device, } if (ret != 0) - dev_err(&device->device, "Unable to send packet %p ret %d", + dev_err(&device->device, "Unable to send packet %p ret %d\n", packet, ret); atomic_inc(&net_device->num_outstanding_sends); @@ -520,19 +520,19 @@ retry_send_cmplt: /* no more room...wait a bit and attempt to retry 3 times */ retries++; dev_err(&device->device, "unable to send receive completion pkt" - " (tid %llx)...retrying %d", transaction_id, retries); + " (tid %llx)...retrying %d\n", transaction_id, retries); if (retries < 4) { udelay(100); goto retry_send_cmplt; } else { dev_err(&device->device, "unable to send receive " - "completion pkt (tid %llx)...give up retrying", + "completion pkt (tid %llx)...give up retrying\n", transaction_id); } } else { dev_err(&device->device, "unable to send receive " - "completion pkt - %llx", transaction_id); + "completion pkt - %llx\n", transaction_id); } } @@ -554,7 +554,7 @@ static void netvsc_receive_completion(void *context) net_device = get_inbound_net_device(device); if (!net_device) { dev_err(&device->device, "unable to get net device..." - "device being destroyed?"); + "device being destroyed?\n"); return; } @@ -605,7 +605,7 @@ static void netvsc_receive(struct hv_device *device, net_device = get_inbound_net_device(device); if (!net_device) { dev_err(&device->device, "unable to get net device..." - "device being destroyed?"); + "device being destroyed?\n"); return; } @@ -614,7 +614,7 @@ static void netvsc_receive(struct hv_device *device, * packet */ if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) { - dev_err(&device->device, "Unknown packet type received - %d", + dev_err(&device->device, "Unknown packet type received - %d\n", packet->type); return; } @@ -626,7 +626,7 @@ static void netvsc_receive(struct hv_device *device, if (nvsp_packet->hdr.msg_type != NVSP_MSG1_TYPE_SEND_RNDIS_PKT) { dev_err(&device->device, "Unknown nvsp packet type received-" - " %d", nvsp_packet->hdr.msg_type); + " %d\n", nvsp_packet->hdr.msg_type); return; } @@ -634,7 +634,7 @@ static void netvsc_receive(struct hv_device *device, if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) { dev_err(&device->device, "Invalid xfer page set id - " - "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID, + "expecting %x got %x\n", NETVSC_RECEIVE_BUFFER_ID, vmxferpage_packet->xfer_pageset_id); return; } @@ -660,7 +660,7 @@ static void netvsc_receive(struct hv_device *device, */ if (count < 2) { dev_err(&device->device, "Got only %d netvsc pkt...needed " - "%d pkts. Dropping this xfer page packet completely!", + "%d pkts. Dropping this xfer page packet completely!\n", count, vmxferpage_packet->range_cnt + 1); /* Return it to the freelist */ @@ -687,7 +687,7 @@ static void netvsc_receive(struct hv_device *device, if (xferpage_packet->count != vmxferpage_packet->range_cnt) { dev_err(&device->device, "Needed %d netvsc pkts to satisy " - "this xfer page...got %d", + "this xfer page...got %d\n", vmxferpage_packet->range_cnt, xferpage_packet->count); } @@ -785,7 +785,7 @@ static void netvsc_channel_cb(void *context) net_device = get_inbound_net_device(device); if (!net_device) { dev_err(&device->device, "net device (%p) shutting down..." - "ignoring inbound packets", net_device); + "ignoring inbound packets\n", net_device); goto out; } @@ -836,7 +836,7 @@ static void netvsc_channel_cb(void *context) /* Try again next time around */ dev_err(&device->device, "unable to allocate buffer of size " - "(%d)!!", bytes_recvd); + "(%d)!!\n", bytes_recvd); break; } @@ -892,18 +892,18 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device); if (ret != 0) { - dev_err(&device->device, "unable to open channel: %d", ret); + dev_err(&device->device, "unable to open channel: %d\n", ret); goto cleanup; } /* Channel is opened */ - pr_info("hv_netvsc channel opened successfully"); + pr_info("hv_netvsc channel opened successfully\n"); /* Connect with the NetVsp */ ret = netvsc_connect_vsp(device); if (ret != 0) { dev_err(&device->device, - "unable to connect to NetVSP - %d", ret); + "unable to connect to NetVSP - %d\n", ret); goto close; } From d9871158718778ff060f08cbee0c61eb23041671 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:41 -0700 Subject: [PATCH 0757/1519] staging: hv: convert dev_ to netdev_ in netvsc Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 68 ++++++++++++++++++------------- drivers/staging/hv/rndis_filter.c | 17 ++++---- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index ef764e614b0..82b129b7775 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "hyperv_net.h" @@ -80,6 +81,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) { struct nvsp_message *revoke_packet; int ret = 0; + struct net_device *ndev = dev_get_drvdata(&net_device->dev->device); /* * If we got a section count, it means we received a @@ -107,7 +109,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) * have a leak rather than continue and a bugchk */ if (ret != 0) { - dev_err(&net_device->dev->device, "unable to send " + netdev_err(ndev, "unable to send " "revoke receive buffer to netvsp\n"); return ret; } @@ -122,7 +124,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) * rather than continue and a bugchk */ if (ret != 0) { - dev_err(&net_device->dev->device, + netdev_err(ndev, "unable to teardown receive buffer's gpadl\n"); return ret; } @@ -151,10 +153,11 @@ static int netvsc_init_recv_buf(struct hv_device *device) int t; struct netvsc_device *net_device; struct nvsp_message *init_packet; + struct net_device *ndev = dev_get_drvdata(&device->device); net_device = get_outbound_net_device(device); if (!net_device) { - dev_err(&device->device, "unable to get net device..." + netdev_err(ndev, "unable to get net device..." "device being destroyed?\n"); return -ENODEV; } @@ -163,7 +166,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, get_order(net_device->recv_buf_size)); if (!net_device->recv_buf) { - dev_err(&device->device, "unable to allocate receive " + netdev_err(ndev, "unable to allocate receive " "buffer of size %d\n", net_device->recv_buf_size); ret = -ENOMEM; goto cleanup; @@ -178,7 +181,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device->recv_buf_size, &net_device->recv_buf_gpadl_handle); if (ret != 0) { - dev_err(&device->device, + netdev_err(ndev, "unable to establish receive buffer's gpadl\n"); goto cleanup; } @@ -202,7 +205,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) VM_PKT_DATA_INBAND, VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { - dev_err(&device->device, + netdev_err(ndev, "unable to send receive buffer's gpadl to netvsp\n"); goto cleanup; } @@ -214,7 +217,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) /* Check the response */ if (init_packet->msg.v1_msg. send_recv_buf_complete.status != NVSP_STAT_SUCCESS) { - dev_err(&device->device, "Unable to complete receive buffer " + netdev_err(ndev, "Unable to complete receive buffer " "initialzation with NetVsp - status %d\n", init_packet->msg.v1_msg. send_recv_buf_complete.status); @@ -266,10 +269,11 @@ static int netvsc_connect_vsp(struct hv_device *device) struct netvsc_device *net_device; struct nvsp_message *init_packet; int ndis_version; + struct net_device *ndev = dev_get_drvdata(&device->device); net_device = get_outbound_net_device(device); if (!net_device) { - dev_err(&device->device, "unable to get net device..." + netdev_err(ndev, "unable to get net device..." "device being destroyed?\n"); return -ENODEV; } @@ -360,7 +364,7 @@ int netvsc_device_remove(struct hv_device *device) /* Wait for all send completions */ while (atomic_read(&net_device->num_outstanding_sends)) { - dev_err(&device->device, + dev_info(&device->device, "waiting for %d requests to complete...\n", atomic_read(&net_device->num_outstanding_sends)); udelay(100); @@ -403,10 +407,11 @@ static void netvsc_send_completion(struct hv_device *device, struct netvsc_device *net_device; struct nvsp_message *nvsp_packet; struct hv_netvsc_packet *nvsc_packet; + struct net_device *ndev = dev_get_drvdata(&device->device); net_device = get_inbound_net_device(device); if (!net_device) { - dev_err(&device->device, "unable to get net device..." + netdev_err(ndev, "unable to get net device..." "device being destroyed?\n"); return; } @@ -435,7 +440,7 @@ static void netvsc_send_completion(struct hv_device *device, atomic_dec(&net_device->num_outstanding_sends); } else { - dev_err(&device->device, "Unknown send completion packet type- " + netdev_err(ndev, "Unknown send completion packet type- " "%d received!!\n", nvsp_packet->hdr.msg_type); } @@ -446,12 +451,12 @@ int netvsc_send(struct hv_device *device, { struct netvsc_device *net_device; int ret = 0; - struct nvsp_message sendMessage; + struct net_device *ndev = dev_get_drvdata(&device->device); net_device = get_outbound_net_device(device); if (!net_device) { - dev_err(&device->device, "net device (%p) shutting down..." + netdev_err(ndev, "net device (%p) shutting down..." "ignoring outbound packets\n", net_device); return -ENODEV; } @@ -487,7 +492,7 @@ int netvsc_send(struct hv_device *device, } if (ret != 0) - dev_err(&device->device, "Unable to send packet %p ret %d\n", + netdev_err(ndev, "Unable to send packet %p ret %d\n", packet, ret); atomic_inc(&net_device->num_outstanding_sends); @@ -500,6 +505,7 @@ static void netvsc_send_recv_completion(struct hv_device *device, struct nvsp_message recvcompMessage; int retries = 0; int ret; + struct net_device *ndev = dev_get_drvdata(&device->device); recvcompMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE; @@ -519,19 +525,19 @@ retry_send_cmplt: } else if (ret == -EAGAIN) { /* no more room...wait a bit and attempt to retry 3 times */ retries++; - dev_err(&device->device, "unable to send receive completion pkt" + netdev_err(ndev, "unable to send receive completion pkt" " (tid %llx)...retrying %d\n", transaction_id, retries); if (retries < 4) { udelay(100); goto retry_send_cmplt; } else { - dev_err(&device->device, "unable to send receive " + netdev_err(ndev, "unable to send receive " "completion pkt (tid %llx)...give up retrying\n", transaction_id); } } else { - dev_err(&device->device, "unable to send receive " + netdev_err(ndev, "unable to send receive " "completion pkt - %llx\n", transaction_id); } } @@ -545,6 +551,7 @@ static void netvsc_receive_completion(void *context) u64 transaction_id = 0; bool fsend_receive_comp = false; unsigned long flags; + struct net_device *ndev = dev_get_drvdata(&device->device); /* * Even though it seems logical to do a GetOutboundNetDevice() here to @@ -553,7 +560,7 @@ static void netvsc_receive_completion(void *context) */ net_device = get_inbound_net_device(device); if (!net_device) { - dev_err(&device->device, "unable to get net device..." + netdev_err(ndev, "unable to get net device..." "device being destroyed?\n"); return; } @@ -599,12 +606,13 @@ static void netvsc_receive(struct hv_device *device, int i, j; int count = 0, bytes_remain = 0; unsigned long flags; + struct net_device *ndev = dev_get_drvdata(&device->device); LIST_HEAD(listHead); net_device = get_inbound_net_device(device); if (!net_device) { - dev_err(&device->device, "unable to get net device..." + netdev_err(ndev, "unable to get net device..." "device being destroyed?\n"); return; } @@ -614,7 +622,7 @@ static void netvsc_receive(struct hv_device *device, * packet */ if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) { - dev_err(&device->device, "Unknown packet type received - %d\n", + netdev_err(ndev, "Unknown packet type received - %d\n", packet->type); return; } @@ -625,7 +633,7 @@ static void netvsc_receive(struct hv_device *device, /* Make sure this is a valid nvsp packet */ if (nvsp_packet->hdr.msg_type != NVSP_MSG1_TYPE_SEND_RNDIS_PKT) { - dev_err(&device->device, "Unknown nvsp packet type received-" + netdev_err(ndev, "Unknown nvsp packet type received-" " %d\n", nvsp_packet->hdr.msg_type); return; } @@ -633,7 +641,7 @@ static void netvsc_receive(struct hv_device *device, vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet; if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) { - dev_err(&device->device, "Invalid xfer page set id - " + netdev_err(ndev, "Invalid xfer page set id - " "expecting %x got %x\n", NETVSC_RECEIVE_BUFFER_ID, vmxferpage_packet->xfer_pageset_id); return; @@ -659,7 +667,7 @@ static void netvsc_receive(struct hv_device *device, * some of the xfer page packet ranges... */ if (count < 2) { - dev_err(&device->device, "Got only %d netvsc pkt...needed " + netdev_err(ndev, "Got only %d netvsc pkt...needed " "%d pkts. Dropping this xfer page packet completely!\n", count, vmxferpage_packet->range_cnt + 1); @@ -686,7 +694,7 @@ static void netvsc_receive(struct hv_device *device, xferpage_packet->count = count - 1; if (xferpage_packet->count != vmxferpage_packet->range_cnt) { - dev_err(&device->device, "Needed %d netvsc pkts to satisy " + netdev_err(ndev, "Needed %d netvsc pkts to satisy " "this xfer page...got %d\n", vmxferpage_packet->range_cnt, xferpage_packet->count); } @@ -775,6 +783,7 @@ static void netvsc_channel_cb(void *context) struct vmpacket_descriptor *desc; unsigned char *buffer; int bufferlen = NETVSC_PACKET_SIZE; + struct net_device *ndev = dev_get_drvdata(&device->device); packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), GFP_ATOMIC); @@ -784,7 +793,7 @@ static void netvsc_channel_cb(void *context) net_device = get_inbound_net_device(device); if (!net_device) { - dev_err(&device->device, "net device (%p) shutting down..." + netdev_err(ndev, "net device (%p) shutting down..." "ignoring inbound packets\n", net_device); goto out; } @@ -805,7 +814,7 @@ static void netvsc_channel_cb(void *context) break; default: - dev_err(&device->device, + netdev_err(ndev, "unhandled packet type %d, " "tid %llx len %d\n", desc->type, request_id, @@ -834,7 +843,7 @@ static void netvsc_channel_cb(void *context) buffer = kmalloc(bytes_recvd, GFP_ATOMIC); if (buffer == NULL) { /* Try again next time around */ - dev_err(&device->device, + netdev_err(ndev, "unable to allocate buffer of size " "(%d)!!\n", bytes_recvd); break; @@ -861,6 +870,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ((struct netvsc_device_info *)additional_info)->ring_size; struct netvsc_device *net_device; struct hv_netvsc_packet *packet, *pos; + struct net_device *ndev = dev_get_drvdata(&device->device); net_device = alloc_net_device(device); if (!net_device) { @@ -892,7 +902,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device); if (ret != 0) { - dev_err(&device->device, "unable to open channel: %d\n", ret); + netdev_err(ndev, "unable to open channel: %d\n", ret); goto cleanup; } @@ -902,7 +912,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) /* Connect with the NetVsp */ ret = netvsc_connect_vsp(device); if (ret != 0) { - dev_err(&device->device, + netdev_err(ndev, "unable to connect to NetVSP - %d\n", ret); goto close; } diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 8416bf2e2ea..20e673d9e4b 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -249,6 +249,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev, struct rndis_request *request = NULL; bool found = false; unsigned long flags; + struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device); spin_lock_irqsave(&dev->request_lock, flags); list_for_each_entry(request, &dev->req_list, list_ent) { @@ -269,7 +270,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev, memcpy(&request->response_msg, resp, resp->msg_len); } else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "rndis response buffer overflow " "detected (size %u max %zu)\n", resp->msg_len, @@ -289,7 +290,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev, complete(&request->wait_event); } else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "no rndis request found for this response " "(id 0x%x res type 0x%x)\n", resp->msg.init_complete.req_id, @@ -349,20 +350,21 @@ int rndis_filter_receive(struct hv_device *dev, struct rndis_device *rndis_dev; struct rndis_message rndis_msg; struct rndis_message *rndis_hdr; + struct net_device *ndev = dev_get_drvdata(&dev->device); if (!net_dev) return -EINVAL; /* Make sure the rndis device state is initialized */ if (!net_dev->extension) { - dev_err(&dev->device, "got rndis message but no rndis device - " + netdev_err(ndev, "got rndis message but no rndis device - " "dropping this message!\n"); return -ENODEV; } rndis_dev = (struct rndis_device *)net_dev->extension; if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) { - dev_err(&dev->device, "got rndis message but rndis device " + netdev_err(ndev, "got rndis message but rndis device " "uninitialized...dropping this message!\n"); return -ENODEV; } @@ -376,7 +378,7 @@ int rndis_filter_receive(struct hv_device *dev, /* Make sure we got a valid rndis message */ if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) && (rndis_hdr->msg_len > sizeof(struct rndis_message))) { - dev_err(&dev->device, "incoming rndis message buffer overflow " + netdev_err(ndev, "incoming rndis message buffer overflow " "detected (got %u, max %zu)..marking it an error!\n", rndis_hdr->msg_len, sizeof(struct rndis_message)); @@ -409,7 +411,7 @@ int rndis_filter_receive(struct hv_device *dev, rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg); break; default: - dev_err(&dev->device, + netdev_err(ndev, "unhandled rndis message (type %u len %u)\n", rndis_msg.ndis_msg_type, rndis_msg.msg_len); @@ -505,6 +507,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, struct rndis_set_complete *set_complete; u32 status; int ret, t; + struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device); request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG, RNDIS_MESSAGE_SIZE(struct rndis_set_request) + @@ -530,7 +533,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, t = wait_for_completion_timeout(&request->wait_event, 5*HZ); if (t == 0) { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "timeout before we got a set response...\n"); /* * We can't deallocate the request since we may still receive a From c4b6a2eaf1c14810a4803d658f68614365978738 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:42 -0700 Subject: [PATCH 0758/1519] staging: hv: fix a kernel warning in netvsc_linkstatus_callback() netif_notify_peers() caused a kernel warning in netvsc_linkstatus_callback(), because netvsc_linkstatus_callback() is within IRQ context. So we move the first call to netif_notify_peers() into queued work as well, but with zero delay. In addition to "staging-next", this should also be back-ported to stable kernels 2.6.32 and later. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 30a0cb2c0fe..e6513be00c4 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -214,8 +214,8 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, if (status == 1) { netif_carrier_on(net); netif_wake_queue(net); - netif_notify_peers(net); ndev_ctx = netdev_priv(net); + schedule_delayed_work(&ndev_ctx->dwork, 0); schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20)); } else { netif_carrier_off(net); From 692e084e773b76c30a3e5d823db131ed1a15924a Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:43 -0700 Subject: [PATCH 0759/1519] staging: hv: re-order the code in netvsc_probe() Re-order the code in netvsc_probe() to prevent a guest crash caused by packets possibly received from NetVSP before call to register_netdev(). Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index e6513be00c4..b49a08f4ed5 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -348,19 +348,6 @@ static int netvsc_probe(struct hv_device *dev) dev_set_drvdata(&dev->device, net); INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp); - /* Notify the netvsc driver of the new device */ - device_info.ring_size = ring_size; - ret = rndis_filter_device_add(dev, &device_info); - if (ret != 0) { - free_netdev(net); - dev_set_drvdata(&dev->device, NULL); - return ret; - } - - netif_carrier_on(net); - - memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); - net->netdev_ops = &device_ops; /* TODO: Add GSO and Checksum offload */ @@ -372,11 +359,26 @@ static int netvsc_probe(struct hv_device *dev) ret = register_netdev(net); if (ret != 0) { - /* Remove the device and release the resource */ - rndis_filter_device_remove(dev); + pr_err("Unable to register netdev.\n"); free_netdev(net); + goto out; } + /* Notify the netvsc driver of the new device */ + device_info.ring_size = ring_size; + ret = rndis_filter_device_add(dev, &device_info); + if (ret != 0) { + netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); + unregister_netdev(net); + free_netdev(net); + dev_set_drvdata(&dev->device, NULL); + return ret; + } + memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); + + netif_carrier_on(net); + +out: return ret; } From 7db1d946c4db748b631fe4885110349cc259987f Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:44 -0700 Subject: [PATCH 0760/1519] staging: hv: fix counting of #outstanding-sends in failed sends If the packet failed to be sent, we shouldn't count it as the number of outstanding sends. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 82b129b7775..efbc8a0913d 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -494,8 +494,9 @@ int netvsc_send(struct hv_device *device, if (ret != 0) netdev_err(ndev, "Unable to send packet %p ret %d\n", packet, ret); + else + atomic_inc(&net_device->num_outstanding_sends); - atomic_inc(&net_device->num_outstanding_sends); return ret; } From 8a5f9edc4dd6c1f9fb2446a36e7cd44b79412271 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:45 -0700 Subject: [PATCH 0761/1519] staging: hv: fix counting of available buffer slots when send fails Because the number of available buffer slots doesn't decrease for failed sends, we should not call netvsc_xmit_completion(), which increase the count of available slots. In this failed case, just free the memory is enough. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index b49a08f4ed5..81e3c496e28 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -190,7 +190,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) } else { /* we are shutting down or bus overloaded, just drop packet */ net->stats.tx_dropped++; - netvsc_xmit_completion(packet); + kfree(packet); + dev_kfree_skb_any(skb); } return NETDEV_TX_OK; From bf769375c9175b29fe72b10394888e0090c6b133 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:46 -0700 Subject: [PATCH 0762/1519] staging: hv: fix the return status of netvsc_start_xmit() Fix the return status, so the upper layer will retry if transmission fails. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 81e3c496e28..30b9c80e200 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -140,12 +140,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) (num_pages * sizeof(struct hv_page_buffer)) + sizeof(struct rndis_filter_packet), GFP_ATOMIC); if (!packet) { - /* out of memory, silently drop packet */ + /* out of memory, drop packet */ netdev_err(net, "unable to allocate hv_netvsc_packet\n"); dev_kfree_skb(skb); net->stats.tx_dropped++; - return NETDEV_TX_OK; + return NETDEV_TX_BUSY; } packet->extension = (void *)(unsigned long)packet + @@ -194,7 +194,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) dev_kfree_skb_any(skb); } - return NETDEV_TX_OK; + return ret ? NETDEV_TX_BUSY : NETDEV_TX_OK; } /* From 669c1fc61679f7e85f467c852bfe7b6c9dd75d25 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:47 -0700 Subject: [PATCH 0763/1519] staging: hv: fix the page buffer when rndis data go across page boundary In rndis_filter_receive_data(), we need to drop the 0th page and move the rest of pages forward if the rndis data go across page boundary, otherwise the page offset will overflow. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 20e673d9e4b..b32534507d4 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -323,6 +323,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev, { struct rndis_packet *rndis_pkt; u32 data_offset; + int i; rndis_pkt = &msg->msg.pkt; @@ -338,6 +339,15 @@ static void rndis_filter_receive_data(struct rndis_device *dev, pkt->page_buf[0].offset += data_offset; pkt->page_buf[0].len -= data_offset; + /* Drop the 0th page, if rndis data go beyond page boundary */ + if (pkt->page_buf[0].offset >= PAGE_SIZE) { + pkt->page_buf[1].offset = pkt->page_buf[0].offset - PAGE_SIZE; + pkt->page_buf[1].len -= pkt->page_buf[1].offset; + pkt->page_buf_cnt--; + for (i = 0; i < pkt->page_buf_cnt; i++) + pkt->page_buf[i] = pkt->page_buf[i+1]; + } + pkt->is_data_pkt = true; netvsc_recv_callback(dev->net_dev->dev, pkt); From 8bff33ab417f246dac4ab9835be6894eaddfb546 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 1 Sep 2011 12:19:48 -0700 Subject: [PATCH 0764/1519] staging: hv: fix some typos in netvsc.c Reported-by: Joe Perches Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index efbc8a0913d..115629f2d69 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -218,7 +218,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) if (init_packet->msg.v1_msg. send_recv_buf_complete.status != NVSP_STAT_SUCCESS) { netdev_err(ndev, "Unable to complete receive buffer " - "initialzation with NetVsp - status %d\n", + "initialization with NetVsp - status %d\n", init_packet->msg.v1_msg. send_recv_buf_complete.status); ret = -EINVAL; @@ -695,7 +695,7 @@ static void netvsc_receive(struct hv_device *device, xferpage_packet->count = count - 1; if (xferpage_packet->count != vmxferpage_packet->range_cnt) { - netdev_err(ndev, "Needed %d netvsc pkts to satisy " + netdev_err(ndev, "Needed %d netvsc pkts to satisfy " "this xfer page...got %d\n", vmxferpage_packet->range_cnt, xferpage_packet->count); } From b2451a4907fdcd718c3580d1e64d75fde04148fa Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Fri, 2 Sep 2011 08:55:41 -0700 Subject: [PATCH 0765/1519] Staging: hv: Update TODO file Based on input from Greg, update the TODO file. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/TODO | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO index 582fd4ab3f1..7c9a93fd30e 100644 --- a/drivers/staging/hv/TODO +++ b/drivers/staging/hv/TODO @@ -1,14 +1,11 @@ TODO: - - fix remaining checkpatch warnings and errors - audit the vmbus to verify it is working properly with the driver model - - see if the vmbus can be merged with the other virtual busses - in the kernel - audit the network driver - checking for carrier inside open is wrong, network device API confusion?? - - audit the block driver - audit the scsi driver Please send patches for this code to Greg Kroah-Hartman , -Hank Janssen , and Haiyang Zhang . +Hank Janssen , Haiyang Zhang , +K. Y. Srinivasan From fd776ba9abdb6a89aa1ef500d7046caa35a0905a Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 2 Sep 2011 18:25:56 +0200 Subject: [PATCH 0766/1519] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/ Show a modalias file in /sys/bus/vmbus/devices/*/ Add a helper function to print the same content in modalias and uevent. Signed-off-by: Olaf Hering Acked-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index cd43ddd3cc8..c0f3b7a1530 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -93,6 +93,14 @@ static void get_channel_info(struct hv_device *device, debug_info.outbound.bytes_avail_towrite; } +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2) +static void print_alias_name(struct hv_device *hv_dev, char *alias_name) +{ + int i; + for (i = 0; i < VMBUS_ALIAS_LEN; i += 2) + sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]); +} + /* * vmbus_show_device_attr - Show the device attribute in sysfs. * @@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev, { struct hv_device *hv_dev = device_to_hv_device(dev); struct hv_device_info device_info; + char alias_name[VMBUS_ALIAS_LEN + 1]; memset(&device_info, 0, sizeof(struct hv_device_info)); @@ -148,6 +157,9 @@ static ssize_t vmbus_show_device_attr(struct device *dev, device_info.chn_instance.b[13], device_info.chn_instance.b[14], device_info.chn_instance.b[15]); + } else if (!strcmp(dev_attr->attr.name, "modalias")) { + print_alias_name(hv_dev, alias_name); + return sprintf(buf, "vmbus:%s\n", alias_name); } else if (!strcmp(dev_attr->attr.name, "state")) { return sprintf(buf, "%d\n", device_info.chn_state); } else if (!strcmp(dev_attr->attr.name, "id")) { @@ -204,6 +216,7 @@ static struct device_attribute vmbus_device_attrs[] = { __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL), __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL), __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL), + __ATTR(modalias, S_IRUGO, vmbus_show_device_attr, NULL), __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL), __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL), @@ -242,12 +255,10 @@ static struct device_attribute vmbus_device_attrs[] = { static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) { struct hv_device *dev = device_to_hv_device(device); - int i, ret; - char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) * 2]; - - for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2) - sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]); + int ret; + char alias_name[VMBUS_ALIAS_LEN + 1]; + print_alias_name(dev, alias_name); ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name); return ret; } From a710cc77db9785993cddecc966a662cb772b3ad9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:43 +0100 Subject: [PATCH 0767/1519] staging: iio: kfifo buffer - push structure definition down into implementation. Nothing other than the implementation needs to know about this. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/kfifo_buf.c | 8 ++++++++ drivers/staging/iio/kfifo_buf.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c index 6002368fdcf..3c9516b2a67 100644 --- a/drivers/staging/iio/kfifo_buf.c +++ b/drivers/staging/iio/kfifo_buf.c @@ -8,6 +8,14 @@ #include "kfifo_buf.h" +struct iio_kfifo { + struct iio_ring_buffer ring; + struct kfifo kf; + int use_count; + int update_needed; + struct mutex use_lock; +}; + #define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring) static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, diff --git a/drivers/staging/iio/kfifo_buf.h b/drivers/staging/iio/kfifo_buf.h index aac30539b2c..fb48523748e 100644 --- a/drivers/staging/iio/kfifo_buf.h +++ b/drivers/staging/iio/kfifo_buf.h @@ -3,14 +3,6 @@ #include "iio.h" #include "ring_generic.h" -struct iio_kfifo { - struct iio_ring_buffer ring; - struct kfifo kf; - int use_count; - int update_needed; - struct mutex use_lock; -}; - extern const struct iio_ring_access_funcs kfifo_access_funcs; struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev); From 7ae8cf6275589a9ebb733eb5bdd093859ba1be36 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:44 +0100 Subject: [PATCH 0768/1519] staging: iio: chrdev.h rationalization. Push some functions out of header and include this where it is needed in other headers only. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/chrdev.h | 32 ------------------------- drivers/staging/iio/iio.h | 2 +- drivers/staging/iio/industrialio-core.c | 32 +++++++++++++++++++++++++ drivers/staging/iio/ring_generic.h | 1 + 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h index 3e31ee6220e..8a229e7c2eb 100644 --- a/drivers/staging/iio/chrdev.h +++ b/drivers/staging/iio/chrdev.h @@ -9,7 +9,6 @@ #ifndef _IIO_CHRDEV_H_ #define _IIO_CHRDEV_H_ -struct iio_dev; /** * struct iio_handler - Structure used to specify file operations @@ -41,35 +40,4 @@ struct iio_event_data { s64 timestamp; }; -/** - * struct iio_detected_event_list - list element for events that have occurred - * @list: linked list header - * @ev: the event itself - */ -struct iio_detected_event_list { - struct list_head list; - struct iio_event_data ev; -}; - -/** - * struct iio_event_interface - chrdev interface for an event line - * @dev: device assocated with event interface - * @handler: fileoperations and related control for the chrdev - * @wait: wait queue to allow blocking reads of events - * @event_list_lock: mutex to protect the list of detected events - * @det_events: list of detected events - * @max_events: maximum number of events before new ones are dropped - * @current_events: number of events in detected list - */ -struct iio_event_interface { - struct device dev; - struct iio_handler handler; - wait_queue_head_t wait; - struct mutex event_list_lock; - struct list_head det_events; - int max_events; - int current_events; - struct list_head dev_attr_list; -}; - #endif diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 753f769736e..cfa148091ba 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -15,7 +15,6 @@ #include #include #include "sysfs.h" -#include "chrdev.h" /* IIO TODO LIST */ /* @@ -178,6 +177,7 @@ static inline s64 iio_get_time_ns(void) #define IIO_VAL_INT_PLUS_NANO 3 struct iio_trigger; /* forward declaration */ +struct iio_dev; /** * struct iio_info - constant information about device diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index ed8a6df5bf4..8a21c5e7807 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -24,6 +24,7 @@ #include "iio.h" #include "iio_core.h" #include "iio_core_trigger.h" +#include "chrdev.h" #define IIO_ID_PREFIX "device" #define IIO_ID_FORMAT IIO_ID_PREFIX "%d" @@ -117,6 +118,37 @@ static void iio_free_ida_val(struct ida *this_ida, int id) spin_unlock(&iio_ida_lock); } +/** + * struct iio_detected_event_list - list element for events that have occurred + * @list: linked list header + * @ev: the event itself + */ +struct iio_detected_event_list { + struct list_head list; + struct iio_event_data ev; +}; + +/** + * struct iio_event_interface - chrdev interface for an event line + * @dev: device assocated with event interface + * @handler: fileoperations and related control for the chrdev + * @wait: wait queue to allow blocking reads of events + * @event_list_lock: mutex to protect the list of detected events + * @det_events: list of detected events + * @max_events: maximum number of events before new ones are dropped + * @current_events: number of events in detected list + */ +struct iio_event_interface { + struct device dev; + struct iio_handler handler; + wait_queue_head_t wait; + struct mutex event_list_lock; + struct list_head det_events; + int max_events; + int current_events; + struct list_head dev_attr_list; +}; + int iio_push_event(struct iio_dev *dev_info, int ev_line, int ev_code, diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 3f26f7175b6..d103262dc5b 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -10,6 +10,7 @@ #ifndef _IIO_RING_GENERIC_H_ #define _IIO_RING_GENERIC_H_ #include "iio.h" +#include "chrdev.h" #ifdef CONFIG_IIO_RING_BUFFER From 8e7d967244a8eebcdadb048efc5e66849ec0a6b6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:45 +0100 Subject: [PATCH 0769/1519] staging: iio: remove specific chrdev for event reading. Get fd from ioctl on buffer. Change suggested by Arnd Bergmann. No real reason to have two chrdevs per device. This step merges them into one. Currently this means that events will only work on devices with buffers. THat will be remedied shortly. V2: set name for event attribute groups. Otherwise they all sorts of fun occurs on dynamic channel event attribute creation. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/sca3000_core.c | 1 + drivers/staging/iio/adc/ad7150.c | 1 + drivers/staging/iio/adc/ad7745.c | 1 + drivers/staging/iio/adc/ad7816.c | 1 + drivers/staging/iio/adc/ad799x_core.c | 2 + drivers/staging/iio/adc/adt7310.c | 2 + drivers/staging/iio/adc/adt7410.c | 2 + drivers/staging/iio/adc/adt75.c | 1 + drivers/staging/iio/adc/max1363_core.c | 4 +- drivers/staging/iio/addac/adt7316.c | 2 + drivers/staging/iio/chrdev.h | 1 + drivers/staging/iio/dac/ad5504.c | 1 + drivers/staging/iio/iio.h | 1 + drivers/staging/iio/industrialio-core.c | 174 ++++++++--------------- drivers/staging/iio/industrialio-ring.c | 21 +++ 15 files changed, 98 insertions(+), 117 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index dbf1622e19f..d7f79b40353 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1036,6 +1036,7 @@ static struct attribute *sca3000_event_attributes[] = { static struct attribute_group sca3000_event_attribute_group = { .attrs = sca3000_event_attributes, + .name = "events", }; /** diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index c01acbc7b34..9fd108776d5 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -700,6 +700,7 @@ static struct attribute *ad7150_event_attributes[] = { static struct attribute_group ad7150_event_attribute_group = { .attrs = ad7150_event_attributes, + .name = "events", }; static const struct iio_info ad7150_info = { diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 91d598c1a14..414e6dd0d1d 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -563,6 +563,7 @@ static struct attribute *ad774x_event_attributes[] = { static struct attribute_group ad774x_event_attribute_group = { .attrs = ad774x_event_attributes, + .name = "events", }; static const struct iio_info ad774x_info = { diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index f5aa57bb8f2..8104ef47045 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -329,6 +329,7 @@ static struct attribute *ad7816_event_attributes[] = { static struct attribute_group ad7816_event_attribute_group = { .attrs = ad7816_event_attributes, + .name = "events", }; static const struct iio_info ad7816_info = { diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 33e4e219714..f1b044b6036 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -447,6 +447,7 @@ static struct attribute *ad7993_4_7_8_event_attributes[] = { static struct attribute_group ad7993_4_7_8_event_attrs_group = { .attrs = ad7993_4_7_8_event_attributes, + .name = "events", }; static struct attribute *ad7992_event_attributes[] = { @@ -463,6 +464,7 @@ static struct attribute *ad7992_event_attributes[] = { static struct attribute_group ad7992_event_attrs_group = { .attrs = ad7992_event_attributes, + .name = "events", }; static const struct iio_info ad7991_info = { diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index 697ad1b9195..b55066f0b23 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -741,8 +741,10 @@ static struct attribute *adt7310_event_ct_attributes[] = { static struct attribute_group adt7310_event_attribute_group[ADT7310_IRQS] = { { .attrs = adt7310_event_int_attributes, + .name = "events", }, { .attrs = adt7310_event_ct_attributes, + .name = "events", } }; diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index b7631f18ee2..2e56ae866dd 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -708,8 +708,10 @@ static struct attribute *adt7410_event_ct_attributes[] = { static struct attribute_group adt7410_event_attribute_group[ADT7410_IRQS] = { { .attrs = adt7410_event_int_attributes, + .name = "events", }, { .attrs = adt7410_event_ct_attributes, + .name = "events", } }; diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index dd782776ce3..66c50001d8c 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -530,6 +530,7 @@ static struct attribute *adt75_event_attributes[] = { static struct attribute_group adt75_event_attribute_group = { .attrs = adt75_event_attributes, + .name = "events", }; static const struct iio_info adt75_info = { diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index e10a4d82814..0bf7b74966b 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -827,6 +827,7 @@ static struct attribute *max1363_event_attributes[] = { static struct attribute_group max1363_event_attribute_group = { .attrs = max1363_event_attributes, + .name = "events", }; #define MAX1363_EVENT_FUNCS \ @@ -1296,7 +1297,8 @@ static int __devinit max1363_probe(struct i2c_client *client, /* Estabilish that the iio_dev is a child of the i2c device */ indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; - + indio_dev->channels = st->chip_info->channels; + indio_dev->num_channels = st->chip_info->num_channels; indio_dev->info = st->chip_info->info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 474d946866d..dca43a7af28 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2064,6 +2064,7 @@ static struct attribute *adt7316_event_attributes[] = { static struct attribute_group adt7316_event_attribute_group = { .attrs = adt7316_event_attributes, + .name = "events", }; static struct attribute *adt7516_event_attributes[] = { @@ -2084,6 +2085,7 @@ static struct attribute *adt7516_event_attributes[] = { static struct attribute_group adt7516_event_attribute_group = { .attrs = adt7516_event_attributes, + .name = "events", }; #ifdef CONFIG_PM diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h index 8a229e7c2eb..c6bd04c4bb4 100644 --- a/drivers/staging/iio/chrdev.h +++ b/drivers/staging/iio/chrdev.h @@ -40,4 +40,5 @@ struct iio_event_data { s64 timestamp; }; +#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int) #endif diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 5243ef962b5..5fb210652af 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -247,6 +247,7 @@ static struct attribute *ad5504_ev_attributes[] = { static struct attribute_group ad5504_ev_attribute_group = { .attrs = ad5504_ev_attributes, + .name = "events", }; static irqreturn_t ad5504_event_handler(int irq, void *private) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index cfa148091ba..5b61a7eaaf0 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -245,6 +245,7 @@ struct iio_info { }; +int iio_event_getfd(struct iio_dev *indio_dev); /** * struct iio_dev - industrial I/O device * @id: [INTERN] used to identify device internally diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 8a21c5e7807..a6ea96242cc 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "iio.h" #include "iio_core.h" #include "iio_core_trigger.h" @@ -128,6 +129,7 @@ struct iio_detected_event_list { struct iio_event_data ev; }; + /** * struct iio_event_interface - chrdev interface for an event line * @dev: device assocated with event interface @@ -139,7 +141,6 @@ struct iio_detected_event_list { * @current_events: number of events in detected list */ struct iio_event_interface { - struct device dev; struct iio_handler handler; wait_queue_head_t wait; struct mutex event_list_lock; @@ -187,7 +188,6 @@ error_ret: } EXPORT_SYMBOL(iio_push_event); - /* This turns up an awful lot */ ssize_t iio_read_const_attr(struct device *dev, struct device_attribute *attr, @@ -207,7 +207,6 @@ static ssize_t iio_event_chrdev_read(struct file *filep, struct iio_detected_event_list *el; int ret; size_t len; - mutex_lock(&ev_int->event_list_lock); if (list_empty(&ev_int->det_events)) { if (filep->f_flags & O_NONBLOCK) { @@ -249,10 +248,8 @@ error_ret: static int iio_event_chrdev_release(struct inode *inode, struct file *filep) { - struct iio_handler *hand = iio_cdev_to_handler(inode->i_cdev); - struct iio_event_interface *ev_int = hand->private; + struct iio_event_interface *ev_int = filep->private_data; struct iio_detected_event_list *el, *t; - mutex_lock(&ev_int->event_list_lock); clear_bit(IIO_BUSY_BIT_POS, &ev_int->handler.flags); /* @@ -264,23 +261,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) list_del(&el->list); kfree(el); } - mutex_unlock(&ev_int->event_list_lock); - - return 0; -} - -static int iio_event_chrdev_open(struct inode *inode, struct file *filep) -{ - struct iio_handler *hand = iio_cdev_to_handler(inode->i_cdev); - struct iio_event_interface *ev_int = hand->private; - - mutex_lock(&ev_int->event_list_lock); - if (test_and_set_bit(IIO_BUSY_BIT_POS, &hand->flags)) { - fops_put(filep->f_op); - mutex_unlock(&ev_int->event_list_lock); - return -EBUSY; - } - filep->private_data = hand->private; + ev_int->current_events = 0; mutex_unlock(&ev_int->event_list_lock); return 0; @@ -289,23 +270,10 @@ static int iio_event_chrdev_open(struct inode *inode, struct file *filep) static const struct file_operations iio_event_chrdev_fileops = { .read = iio_event_chrdev_read, .release = iio_event_chrdev_release, - .open = iio_event_chrdev_open, .owner = THIS_MODULE, .llseek = noop_llseek, }; -static void iio_event_dev_release(struct device *dev) -{ - struct iio_event_interface *ev_int - = container_of(dev, struct iio_event_interface, dev); - cdev_del(&ev_int->handler.chrdev); - iio_device_free_chrdev_minor(MINOR(dev->devt)); -}; - -static struct device_type iio_event_type = { - .release = iio_event_dev_release, -}; - int iio_device_get_chrdev_minor(void) { int ret; @@ -322,34 +290,29 @@ void iio_device_free_chrdev_minor(int val) iio_free_ida_val(&iio_chrdev_ida, val); } -static int iio_setup_ev_int(struct iio_event_interface *ev_int, +int iio_event_getfd(struct iio_dev *indio_dev) +{ + if (indio_dev->event_interfaces == NULL) + return -ENODEV; + + mutex_lock(&indio_dev->event_interfaces->event_list_lock); + if (test_and_set_bit(IIO_BUSY_BIT_POS, + &indio_dev->event_interfaces->handler.flags)) { + mutex_unlock(&indio_dev->event_interfaces->event_list_lock); + return -EBUSY; + } + mutex_unlock(&indio_dev->event_interfaces->event_list_lock); + return anon_inode_getfd("iio:event", + &iio_event_chrdev_fileops, + &indio_dev->event_interfaces[0], O_RDONLY); +} + +static void iio_setup_ev_int(struct iio_event_interface *ev_int, const char *dev_name, int index, struct module *owner, struct device *dev) { - int ret, minor; - - ev_int->dev.bus = &iio_bus_type; - ev_int->dev.parent = dev; - ev_int->dev.type = &iio_event_type; - device_initialize(&ev_int->dev); - - minor = iio_device_get_chrdev_minor(); - if (minor < 0) { - ret = minor; - goto error_device_put; - } - ev_int->dev.devt = MKDEV(MAJOR(iio_devt), minor); - dev_set_name(&ev_int->dev, "%s:event%d", dev_name, index); - - ret = device_add(&ev_int->dev); - if (ret) - goto error_free_minor; - - cdev_init(&ev_int->handler.chrdev, &iio_event_chrdev_fileops); - ev_int->handler.chrdev.owner = owner; - mutex_init(&ev_int->event_list_lock); /* discussion point - make this variable? */ ev_int->max_events = 10; @@ -358,27 +321,6 @@ static int iio_setup_ev_int(struct iio_event_interface *ev_int, init_waitqueue_head(&ev_int->wait); ev_int->handler.private = ev_int; ev_int->handler.flags = 0; - - ret = cdev_add(&ev_int->handler.chrdev, ev_int->dev.devt, 1); - if (ret) - goto error_unreg_device; - - return 0; - -error_unreg_device: - device_unregister(&ev_int->dev); -error_free_minor: - iio_device_free_chrdev_minor(minor); -error_device_put: - put_device(&ev_int->dev); - - return ret; -} - -static void iio_free_ev_int(struct iio_event_interface *ev_int) -{ - device_unregister(&ev_int->dev); - put_device(&ev_int->dev); } static int __init iio_init(void) @@ -970,7 +912,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, continue; } ret = __iio_add_chan_devattr(postfix, - NULL, + "events", chan, &iio_ev_state_show, iio_ev_state_store, @@ -980,7 +922,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, extending the bitmask - but how far*/ 0, - &dev_info->event_interfaces[0].dev, + &dev_info->dev, &dev_info->event_interfaces[0]. dev_attr_list); kfree(postfix); @@ -994,13 +936,12 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, ret = -ENOMEM; goto error_ret; } - ret = __iio_add_chan_devattr(postfix, NULL, chan, + ret = __iio_add_chan_devattr(postfix, "events", chan, iio_ev_value_show, iio_ev_value_store, mask, 0, - &dev_info->event_interfaces[0] - .dev, + &dev_info->dev, &dev_info->event_interfaces[0] .dev_attr_list); kfree(postfix); @@ -1020,8 +961,7 @@ static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info, list_for_each_entry_safe(p, n, &dev_info->event_interfaces[i]. dev_attr_list, l) { - sysfs_remove_file_from_group(&dev_info - ->event_interfaces[i].dev.kobj, + sysfs_remove_file_from_group(&dev_info->dev.kobj, &p->dev_attr.attr, NULL); kfree(p->dev_attr.attr.name); @@ -1052,6 +992,15 @@ error_clear_attrs: return ret; } +static struct attribute *iio_events_dummy_attrs[] = { + NULL +}; + +static struct attribute_group iio_events_dummy_group = { + .name = "events", + .attrs = iio_events_dummy_attrs +}; + static int iio_device_register_eventset(struct iio_dev *dev_info) { int ret = 0, i, j; @@ -1069,42 +1018,33 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) } for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { - ret = iio_setup_ev_int(&dev_info->event_interfaces[i], - dev_name(&dev_info->dev), - i, - dev_info->info->driver_module, - &dev_info->dev); - if (ret) { - dev_err(&dev_info->dev, - "Could not get chrdev interface\n"); - goto error_free_setup_event_lines; - } - - dev_set_drvdata(&dev_info->event_interfaces[i].dev, - (void *)dev_info); + iio_setup_ev_int(&dev_info->event_interfaces[i], + dev_name(&dev_info->dev), + i, + dev_info->info->driver_module, + &dev_info->dev); if (dev_info->info->event_attrs != NULL) - ret = sysfs_create_group(&dev_info - ->event_interfaces[i] - .dev.kobj, + ret = sysfs_create_group(&dev_info->dev.kobj, &dev_info->info ->event_attrs[i]); - + else + ret = sysfs_create_group(&dev_info->dev.kobj, + &iio_events_dummy_group); if (ret) { dev_err(&dev_info->dev, "Failed to register sysfs for event attrs"); - iio_free_ev_int(&dev_info->event_interfaces[i]); goto error_free_setup_event_lines; } ret = __iio_add_event_config_attrs(dev_info, i); if (ret) { if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info - ->event_interfaces[i] - .dev.kobj, + sysfs_remove_group(&dev_info->dev.kobj, &dev_info->info ->event_attrs[i]); - iio_free_ev_int(&dev_info->event_interfaces[i]); + else + sysfs_remove_group(&dev_info->dev.kobj, + &iio_events_dummy_group); goto error_free_setup_event_lines; } } @@ -1114,11 +1054,12 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) error_free_setup_event_lines: for (j = 0; j < i; j++) { __iio_remove_event_config_attrs(dev_info, j); - if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info - ->event_interfaces[j].dev.kobj, + if (dev_info->info->event_attrs != NULL) { + sysfs_remove_group(&dev_info->dev.kobj, &dev_info->info->event_attrs[j]); - iio_free_ev_int(&dev_info->event_interfaces[j]); + sysfs_remove_group(&dev_info->dev.kobj, + &iio_events_dummy_group); + } } kfree(dev_info->event_interfaces); error_ret: @@ -1135,10 +1076,11 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { __iio_remove_event_config_attrs(dev_info, i); if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info - ->event_interfaces[i].dev.kobj, + sysfs_remove_group(&dev_info->dev.kobj, &dev_info->info->event_attrs[i]); - iio_free_ev_int(&dev_info->event_interfaces[i]); + else + sysfs_remove_group(&dev_info->dev.kobj, + &iio_events_dummy_group); } kfree(dev_info->event_interfaces); } diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index dce50b1a4ee..e4554be2607 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -93,6 +93,25 @@ static unsigned int iio_ring_poll(struct file *filp, return 0; } +/* Somewhat of a cross file organization violation - ioctls here are actually + * event related */ +static long iio_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +{ + + struct iio_ring_buffer *rb = f->private_data; + struct iio_dev *indio_dev = rb->indio_dev; + int __user *ip = (int __user *)arg; + + if (cmd == IIO_GET_EVENT_FD_IOCTL) { + int fd; + fd = iio_event_getfd(indio_dev); + if (copy_to_user(ip, &fd, sizeof(fd))) + return -EFAULT; + return 0; + } + return -EINVAL; +} + static const struct file_operations iio_ring_fileops = { .read = iio_ring_read_first_n_outer, .release = iio_ring_release, @@ -100,6 +119,8 @@ static const struct file_operations iio_ring_fileops = { .poll = iio_ring_poll, .owner = THIS_MODULE, .llseek = noop_llseek, + .unlocked_ioctl = iio_ioctl, + .compat_ioctl = iio_ioctl, }; void iio_ring_access_release(struct device *dev) From 6356463cf4627f599547f0698853ef419b2d2f1d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:46 +0100 Subject: [PATCH 0770/1519] staging: iio: squash chrdev handler remains into users. This no longer has any purpose given all chrdevs are pretty much the same now the event interfaces are done via anon fds Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/chrdev.h | 19 ---------------- drivers/staging/iio/industrialio-core.c | 29 +++++++++---------------- drivers/staging/iio/industrialio-ring.c | 28 +++++++++++------------- drivers/staging/iio/ring_generic.h | 5 +++-- 4 files changed, 26 insertions(+), 55 deletions(-) diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h index c6bd04c4bb4..28cce12346a 100644 --- a/drivers/staging/iio/chrdev.h +++ b/drivers/staging/iio/chrdev.h @@ -10,25 +10,6 @@ #ifndef _IIO_CHRDEV_H_ #define _IIO_CHRDEV_H_ -/** - * struct iio_handler - Structure used to specify file operations - * for a particular chrdev - * @chrdev: character device structure - * @id: the location in the handler table - used for deallocation. - * @flags: file operations related flags including busy flag. - * @private: handler specific data used by the fileops registered with - * the chrdev. - */ -struct iio_handler { - struct cdev chrdev; - int id; - unsigned long flags; - void *private; -}; - -#define iio_cdev_to_handler(cd) \ - container_of(cd, struct iio_handler, chrdev) - /** * struct iio_event_data - The actual event being pushed to userspace * @id: event identifier diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index a6ea96242cc..2b72398ea73 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -129,25 +129,24 @@ struct iio_detected_event_list { struct iio_event_data ev; }; - /** * struct iio_event_interface - chrdev interface for an event line * @dev: device assocated with event interface - * @handler: fileoperations and related control for the chrdev * @wait: wait queue to allow blocking reads of events * @event_list_lock: mutex to protect the list of detected events * @det_events: list of detected events * @max_events: maximum number of events before new ones are dropped * @current_events: number of events in detected list + * @flags: file operations related flags including busy flag. */ struct iio_event_interface { - struct iio_handler handler; wait_queue_head_t wait; struct mutex event_list_lock; struct list_head det_events; int max_events; int current_events; struct list_head dev_attr_list; + unsigned long flags; }; int iio_push_event(struct iio_dev *dev_info, @@ -162,7 +161,7 @@ int iio_push_event(struct iio_dev *dev_info, /* Does anyone care? */ mutex_lock(&ev_int->event_list_lock); - if (test_bit(IIO_BUSY_BIT_POS, &ev_int->handler.flags)) { + if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { if (ev_int->current_events == ev_int->max_events) { mutex_unlock(&ev_int->event_list_lock); return 0; @@ -188,6 +187,7 @@ error_ret: } EXPORT_SYMBOL(iio_push_event); + /* This turns up an awful lot */ ssize_t iio_read_const_attr(struct device *dev, struct device_attribute *attr, @@ -207,6 +207,7 @@ static ssize_t iio_event_chrdev_read(struct file *filep, struct iio_detected_event_list *el; int ret; size_t len; + mutex_lock(&ev_int->event_list_lock); if (list_empty(&ev_int->det_events)) { if (filep->f_flags & O_NONBLOCK) { @@ -250,8 +251,9 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) { struct iio_event_interface *ev_int = filep->private_data; struct iio_detected_event_list *el, *t; + mutex_lock(&ev_int->event_list_lock); - clear_bit(IIO_BUSY_BIT_POS, &ev_int->handler.flags); + clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); /* * In order to maintain a clean state for reopening, * clear out any awaiting events. The mask will prevent @@ -297,7 +299,7 @@ int iio_event_getfd(struct iio_dev *indio_dev) mutex_lock(&indio_dev->event_interfaces->event_list_lock); if (test_and_set_bit(IIO_BUSY_BIT_POS, - &indio_dev->event_interfaces->handler.flags)) { + &indio_dev->event_interfaces->flags)) { mutex_unlock(&indio_dev->event_interfaces->event_list_lock); return -EBUSY; } @@ -307,11 +309,7 @@ int iio_event_getfd(struct iio_dev *indio_dev) &indio_dev->event_interfaces[0], O_RDONLY); } -static void iio_setup_ev_int(struct iio_event_interface *ev_int, - const char *dev_name, - int index, - struct module *owner, - struct device *dev) +static void iio_setup_ev_int(struct iio_event_interface *ev_int) { mutex_init(&ev_int->event_list_lock); /* discussion point - make this variable? */ @@ -319,8 +317,6 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int, ev_int->current_events = 0; INIT_LIST_HEAD(&ev_int->det_events); init_waitqueue_head(&ev_int->wait); - ev_int->handler.private = ev_int; - ev_int->handler.flags = 0; } static int __init iio_init(void) @@ -1018,12 +1014,7 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) } for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { - iio_setup_ev_int(&dev_info->event_interfaces[i], - dev_name(&dev_info->dev), - i, - dev_info->info->driver_module, - &dev_info->dev); - + iio_setup_ev_int(&dev_info->event_interfaces[i]); if (dev_info->info->event_attrs != NULL) ret = sysfs_create_group(&dev_info->dev.kobj, &dev_info->info diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index e4554be2607..cce02244ceb 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -32,11 +32,10 @@ **/ static int iio_ring_open(struct inode *inode, struct file *filp) { - struct iio_handler *hand - = container_of(inode->i_cdev, struct iio_handler, chrdev); - struct iio_ring_buffer *rb = hand->private; - - filp->private_data = hand->private; + struct iio_ring_buffer *rb + = container_of(inode->i_cdev, + struct iio_ring_buffer, chrdev); + filp->private_data = rb; if (rb->access->mark_in_use) rb->access->mark_in_use(rb); @@ -51,11 +50,11 @@ static int iio_ring_open(struct inode *inode, struct file *filp) **/ static int iio_ring_release(struct inode *inode, struct file *filp) { - struct cdev *cd = inode->i_cdev; - struct iio_handler *hand = iio_cdev_to_handler(cd); - struct iio_ring_buffer *rb = hand->private; + struct iio_ring_buffer *rb + = container_of(inode->i_cdev, + struct iio_ring_buffer, chrdev); - clear_bit(IIO_BUSY_BIT_POS, &rb->access_handler.flags); + clear_bit(IIO_BUSY_BIT_POS, &rb->flags); if (rb->access->unmark_in_use) rb->access->unmark_in_use(rb); @@ -127,7 +126,7 @@ void iio_ring_access_release(struct device *dev) { struct iio_ring_buffer *buf = container_of(dev, struct iio_ring_buffer, dev); - cdev_del(&buf->access_handler.chrdev); + cdev_del(&buf->chrdev); iio_device_free_chrdev_minor(MINOR(dev->devt)); } EXPORT_SYMBOL(iio_ring_access_release); @@ -139,7 +138,7 @@ __iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf, { int ret; - buf->access_handler.flags = 0; + buf->flags = 0; buf->dev.bus = &iio_bus_type; device_initialize(&buf->dev); @@ -156,9 +155,9 @@ __iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf, printk(KERN_ERR "failed to add the ring dev\n"); goto error_device_put; } - cdev_init(&buf->access_handler.chrdev, &iio_ring_fileops); - buf->access_handler.chrdev.owner = owner; - ret = cdev_add(&buf->access_handler.chrdev, buf->dev.devt, 1); + cdev_init(&buf->chrdev, &iio_ring_fileops); + buf->chrdev.owner = owner; + ret = cdev_add(&buf->chrdev, buf->dev.devt, 1); if (ret) { printk(KERN_ERR "failed to allocate ring chrdev\n"); goto error_device_unregister; @@ -182,7 +181,6 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring, struct iio_dev *dev_info) { ring->indio_dev = dev_info; - ring->access_handler.private = ring; init_waitqueue_head(&ring->pollq); } EXPORT_SYMBOL(iio_ring_buffer_init); diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index d103262dc5b..81bbe39ccc9 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -85,13 +85,13 @@ struct iio_ring_setup_ops { * @scan_count: [INTERN] the number of elements in the current scan mode * @scan_mask: [INTERN] bitmask used in masking scan mode elements * @scan_timestamp: [INTERN] does the scan mode include a timestamp - * @access_handler: [INTERN] chrdev access handling * @access: [DRIVER] ring access functions associated with the * implementation. * @preenable: [DRIVER] function to run prior to marking ring enabled * @postenable: [DRIVER] function to run after marking ring enabled * @predisable: [DRIVER] function to run prior to marking ring disabled * @postdisable: [DRIVER] function to run after marking ring disabled + * @flags: [INTERN] file ops related flags including busy flag. **/ struct iio_ring_buffer { struct device dev; @@ -104,13 +104,14 @@ struct iio_ring_buffer { int scan_count; unsigned long scan_mask; bool scan_timestamp; - struct iio_handler access_handler; const struct iio_ring_access_funcs *access; const struct iio_ring_setup_ops *setup_ops; struct list_head scan_el_dev_attr_list; wait_queue_head_t pollq; bool stufftoread; + unsigned long flags; + struct cdev chrdev; }; /** From 1aa042783251c27a93e31929c24647729db326d4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:47 +0100 Subject: [PATCH 0771/1519] staging: iio: push the main buffer chrdev down to the top level. Sorry all, this one is very invasive, though the driver changes are just trivial interface fixes. Not all done yet. V2 - bring the sca3000 with us. V3 - fix ade7758 bugs in conversion. V4 - add ad5933 Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- .../iio/Documentation/generic_buffer.c | 12 +- drivers/staging/iio/Documentation/iio_utils.h | 2 +- drivers/staging/iio/accel/adis16201_core.c | 6 +- drivers/staging/iio/accel/adis16203_core.c | 6 +- drivers/staging/iio/accel/adis16204_core.c | 6 +- drivers/staging/iio/accel/adis16209_core.c | 6 +- drivers/staging/iio/accel/adis16240_core.c | 6 +- drivers/staging/iio/accel/lis3l02dq_core.c | 6 +- drivers/staging/iio/accel/sca3000_core.c | 6 +- drivers/staging/iio/accel/sca3000_ring.c | 23 +- drivers/staging/iio/adc/ad7192.c | 6 +- drivers/staging/iio/adc/ad7298_core.c | 4 +- drivers/staging/iio/adc/ad7476_core.c | 4 +- drivers/staging/iio/adc/ad7606_core.c | 4 +- drivers/staging/iio/adc/ad7793.c | 6 +- drivers/staging/iio/adc/ad7887_core.c | 4 +- drivers/staging/iio/adc/ad799x_core.c | 4 +- drivers/staging/iio/adc/max1363_core.c | 6 +- drivers/staging/iio/gyro/adis16260_core.c | 6 +- drivers/staging/iio/iio.h | 2 +- drivers/staging/iio/iio_core.h | 32 +++ .../staging/iio/impedance-analyzer/ad5933.c | 8 +- drivers/staging/iio/imu/adis16400_core.c | 6 +- drivers/staging/iio/industrialio-core.c | 71 +++++- drivers/staging/iio/industrialio-ring.c | 239 ++++++------------ drivers/staging/iio/kfifo_buf.c | 26 +- drivers/staging/iio/meter/ade7758.h | 5 +- drivers/staging/iio/meter/ade7758_core.c | 6 +- drivers/staging/iio/meter/ade7758_ring.c | 4 +- drivers/staging/iio/ring_generic.h | 24 +- drivers/staging/iio/ring_sw.c | 25 +- 31 files changed, 254 insertions(+), 317 deletions(-) diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c index f82894f42d2..d5809532149 100644 --- a/drivers/staging/iio/Documentation/generic_buffer.c +++ b/drivers/staging/iio/Documentation/generic_buffer.c @@ -173,7 +173,7 @@ int main(int argc, char **argv) return -1; /* Find the device requested */ - dev_num = find_type_by_name(device_name, "device"); + dev_num = find_type_by_name(device_name, "iio:device"); if (dev_num < 0) { printf("Failed to find the %s\n", device_name); ret = -ENODEV; @@ -181,7 +181,7 @@ int main(int argc, char **argv) } printf("iio device number being used is %d\n", dev_num); - asprintf(&dev_dir_name, "%sdevice%d", iio_dir, dev_num); + asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); if (trigger_name == NULL) { /* * Build the trigger name. If it is device associated it's @@ -212,6 +212,7 @@ int main(int argc, char **argv) ret = build_channel_array(dev_dir_name, &infoarray, &num_channels); if (ret) { printf("Problem reading scan element information\n"); + printf("diag %s\n", dev_dir_name); goto error_free_triggername; } @@ -220,7 +221,8 @@ int main(int argc, char **argv) * As we know that the lis3l02dq has only one buffer this may * be built rather than found. */ - ret = asprintf(&buf_dir_name, "%sdevice%d:buffer0", iio_dir, dev_num); + ret = asprintf(&buf_dir_name, + "%siio:device%d/buffer", iio_dir, dev_num); if (ret < 0) { ret = -ENOMEM; goto error_free_triggername; @@ -251,9 +253,7 @@ int main(int argc, char **argv) goto error_free_buf_dir_name; } - ret = asprintf(&buffer_access, - "/dev/device%d:buffer0", - dev_num); + ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num); if (ret < 0) { ret = -ENOMEM; goto error_free_data; diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index 150f4407363..75938b2412f 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -16,7 +16,7 @@ #define IIO_MAX_NAME_LENGTH 30 -#define FORMAT_SCAN_ELEMENTS_DIR "%s:buffer0/scan_elements" +#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements" #define FORMAT_TYPE_FILE "%s_type" const char *iio_dir = "/sys/bus/iio/devices/"; diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 2b8c5e9c33e..d16c45959fd 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -497,7 +497,7 @@ static int __devinit adis16201_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, adis16201_channels, ARRAY_SIZE(adis16201_channels)); if (ret) { @@ -520,7 +520,7 @@ static int __devinit adis16201_probe(struct spi_device *spi) error_remove_trigger: adis16201_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16201_unconfigure_ring(indio_dev); error_free_dev: @@ -537,7 +537,7 @@ static int adis16201_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16201_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16201_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 14836762736..cc3869bbf46 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -451,7 +451,7 @@ static int __devinit adis16203_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, adis16203_channels, ARRAY_SIZE(adis16203_channels)); if (ret) { @@ -474,7 +474,7 @@ static int __devinit adis16203_probe(struct spi_device *spi) error_remove_trigger: adis16203_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16203_unconfigure_ring(indio_dev); error_free_dev: @@ -491,7 +491,7 @@ static int adis16203_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16203_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16203_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 445a75b1d54..3cc229d9564 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -526,7 +526,7 @@ static int __devinit adis16204_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, adis16204_channels, ARRAY_SIZE(adis16204_channels)); if (ret) { @@ -549,7 +549,7 @@ static int __devinit adis16204_probe(struct spi_device *spi) error_remove_trigger: adis16204_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16204_unconfigure_ring(indio_dev); error_free_dev: @@ -566,7 +566,7 @@ static int adis16204_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16204_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16204_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index ca671ddc152..fa4c6c055db 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -499,7 +499,7 @@ static int __devinit adis16209_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, adis16209_channels, ARRAY_SIZE(adis16209_channels)); if (ret) { @@ -522,7 +522,7 @@ static int __devinit adis16209_probe(struct spi_device *spi) error_remove_trigger: adis16209_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16209_unconfigure_ring(indio_dev); error_free_dev: @@ -541,7 +541,7 @@ static int adis16209_remove(struct spi_device *spi) flush_scheduled_work(); adis16209_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16209_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index d485f7342f8..2c6ced0366d 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -552,7 +552,7 @@ static int __devinit adis16240_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, adis16240_channels, ARRAY_SIZE(adis16240_channels)); if (ret) { @@ -575,7 +575,7 @@ static int __devinit adis16240_probe(struct spi_device *spi) error_remove_trigger: adis16240_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16240_unconfigure_ring(indio_dev); error_free_dev: @@ -595,7 +595,7 @@ static int adis16240_remove(struct spi_device *spi) flush_scheduled_work(); adis16240_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16240_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 33001f8992e..440b26bff34 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -696,7 +696,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, lis3l02dq_channels, ARRAY_SIZE(lis3l02dq_channels)); if (ret) { @@ -732,7 +732,7 @@ error_free_interrupt: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(st->us->irq, indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: lis3l02dq_unconfigure_ring(indio_dev); error_free_dev: @@ -789,7 +789,7 @@ static int lis3l02dq_remove(struct spi_device *spi) free_irq(st->us->irq, indio_dev); lis3l02dq_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); lis3l02dq_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index d7f79b40353..1a6780f9c5a 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1157,7 +1157,7 @@ static int __devinit sca3000_probe(struct spi_device *spi) if (ret < 0) goto error_free_dev; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, sca3000_channels, ARRAY_SIZE(sca3000_channels)); if (ret < 0) @@ -1182,7 +1182,7 @@ error_free_irq: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(spi->irq, indio_dev); error_unregister_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unregister_dev: error_free_dev: if (regdone) @@ -1223,7 +1223,7 @@ static int sca3000_remove(struct spi_device *spi) return ret; if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(spi->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 0b736dbe818..cc38521e6e2 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -144,11 +144,6 @@ static int sca3000_ring_get_bytes_per_datum(struct iio_ring_buffer *r) { return 6; } -static void sca3000_ring_release(struct device *dev) -{ - struct iio_ring_buffer *r = to_iio_ring_buffer(dev); - kfree(iio_to_hw_ring_buf(r)); -} static IIO_RING_ENABLE_ATTR; static IIO_RING_BYTES_PER_DATUM_ATTR; @@ -258,16 +253,7 @@ static struct attribute *sca3000_ring_attributes[] = { static struct attribute_group sca3000_ring_attr = { .attrs = sca3000_ring_attributes, -}; - -static const struct attribute_group *sca3000_ring_attr_groups[] = { - &sca3000_ring_attr, - NULL -}; - -static struct device_type sca3000_ring_type = { - .release = sca3000_ring_release, - .groups = sca3000_ring_attr_groups, + .name = "buffer", }; static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) @@ -282,18 +268,15 @@ static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) ring->private = indio_dev; buf = &ring->buf; buf->stufftoread = 0; + buf->attrs = &sca3000_ring_attr; iio_ring_buffer_init(buf, indio_dev); - buf->dev.type = &sca3000_ring_type; - buf->dev.parent = &indio_dev->dev; - dev_set_drvdata(&buf->dev, (void *)buf); return buf; } static inline void sca3000_rb_free(struct iio_ring_buffer *r) { - if (r) - iio_put_ring_buffer(r); + kfree(iio_to_hw_ring_buf(r)); } static const struct iio_ring_access_funcs sca3000_ring_access_funcs = { diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index adf6d95dd34..6e1656e44e3 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -1098,7 +1098,7 @@ static int __devinit ad7192_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, indio_dev->num_channels); if (ret) @@ -1111,7 +1111,7 @@ static int __devinit ad7192_probe(struct spi_device *spi) return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_remove_trigger: ad7192_remove_trigger(indio_dev); error_unreg_ring: @@ -1136,7 +1136,7 @@ static int ad7192_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7192_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7192_remove_trigger(indio_dev); ad7192_ring_cleanup(indio_dev); diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 3e5bead2636..9c50b022d10 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -223,7 +223,7 @@ static int __devinit ad7298_probe(struct spi_device *spi) goto error_disable_reg; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, &ad7298_channels[1], /* skip temp0 */ ARRAY_SIZE(ad7298_channels) - 1); if (ret) @@ -253,7 +253,7 @@ static int __devexit ad7298_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7298_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7298_ring_cleanup(indio_dev); iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index bb8be5daa6b..bea9e82057f 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -186,7 +186,7 @@ static int __devinit ad7476_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, st->chip_info->channel, ARRAY_SIZE(st->chip_info->channel)); if (ret) @@ -215,7 +215,7 @@ static int ad7476_remove(struct spi_device *spi) /* copy needed as st will have been freed */ struct regulator *reg = st->reg; - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7476_ring_cleanup(indio_dev); iio_device_unregister(indio_dev); if (!IS_ERR(reg)) { diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index ef0558130ca..7aef4d5188f 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -506,7 +506,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, goto error_free_irq; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, indio_dev->num_channels); if (ret) @@ -541,7 +541,7 @@ int ad7606_remove(struct iio_dev *indio_dev) { struct ad7606_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7606_ring_cleanup(indio_dev); free_irq(st->irq, indio_dev); diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 1bcb3ebb1bc..ed993e34908 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -895,7 +895,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, indio_dev->num_channels); if (ret) @@ -908,7 +908,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_remove_trigger: ad7793_remove_trigger(indio_dev); error_unreg_ring: @@ -933,7 +933,7 @@ static int ad7793_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7793_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7793_remove_trigger(indio_dev); ad7793_ring_cleanup(indio_dev); diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 74e222f9243..184ead17afc 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -194,7 +194,7 @@ static int __devinit ad7887_probe(struct spi_device *spi) goto error_disable_reg; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, indio_dev->num_channels); if (ret) @@ -222,7 +222,7 @@ static int ad7887_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7887_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad7887_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index f1b044b6036..ba6d4ed0d60 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -708,7 +708,7 @@ static int __devinit ad799x_probe(struct i2c_client *client, goto error_cleanup_ring; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, indio_dev->num_channels); if (ret) @@ -752,7 +752,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) if (client->irq > 0) free_irq(client->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); ad799x_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 0bf7b74966b..53b745143ae 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1315,7 +1315,7 @@ static int __devinit max1363_probe(struct i2c_client *client, if (ret) goto error_cleanup_ring; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, st->chip_info->channels, st->chip_info->num_channels); if (ret) @@ -1336,7 +1336,7 @@ static int __devinit max1363_probe(struct i2c_client *client, return 0; error_uninit_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: max1363_ring_cleanup(indio_dev); error_free_available_scan_masks: @@ -1362,7 +1362,7 @@ static int max1363_remove(struct i2c_client *client) if (client->irq) free_irq(st->client->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); max1363_ring_cleanup(indio_dev); kfree(indio_dev->available_scan_masks); if (!IS_ERR(reg)) { diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index fcd7819a124..5541cdda176 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -629,7 +629,7 @@ static int __devinit adis16260_probe(struct spi_device *spi) if (ret) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, indio_dev->channels, ARRAY_SIZE(adis16260_channels_x)); if (ret) { @@ -652,7 +652,7 @@ static int __devinit adis16260_probe(struct spi_device *spi) error_remove_trigger: adis16260_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16260_unconfigure_ring(indio_dev); error_free_dev: @@ -676,7 +676,7 @@ static int adis16260_remove(struct spi_device *spi) flush_scheduled_work(); adis16260_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_device_unregister(indio_dev); adis16260_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 5b61a7eaaf0..239219b9949 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -245,7 +245,6 @@ struct iio_info { }; -int iio_event_getfd(struct iio_dev *indio_dev); /** * struct iio_dev - industrial I/O device * @id: [INTERN] used to identify device internally @@ -288,6 +287,7 @@ struct iio_dev { struct list_head channel_attr_list; const char *name; const struct iio_info *info; + struct cdev chrdev; }; /** diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index 00e894d50e7..a27fa05d660 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -10,6 +10,9 @@ * drivers. */ +#ifndef _IIO_CORE_H_ +#define _IIO_CORE_H_ + /** * iio_device_get_chrdev_minor() - get an unused minor number **/ @@ -46,3 +49,32 @@ int __iio_add_chan_devattr(const char *postfix, /* Event interface flags */ #define IIO_BUSY_BIT_POS 1 + +#ifdef CONFIG_IIO_RING_BUFFER +struct poll_table_struct; + +void iio_chrdev_ring_open(struct iio_dev *indio_dev); +void iio_chrdev_ring_release(struct iio_dev *indio_dev); + +unsigned int iio_ring_poll(struct file *filp, + struct poll_table_struct *wait); +ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, + size_t n, loff_t *f_ps); + + +#define iio_ring_poll_addr (&iio_ring_poll) +#define iio_ring_read_first_n_outer_addr (&iio_ring_read_first_n_outer) + +#else + +static inline void iio_chrdev_ring_open(struct iio_dev *indio_dev) +{} +static inline void iio_chrdev_ring_release(struct iio_dev *indio_dev) +{} + +#define iio_ring_poll_addr NULL +#define iio_ring_read_first_n_outer_addr NULL + +#endif + +#endif diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index acc0e69cb58..8668291ffdc 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -733,9 +733,7 @@ static int __devinit ad5933_probe(struct i2c_client *client, regdone = 1; /* skip temp0_input, register in0_(real|imag)_raw */ - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, - &ad5933_channels[1], - 2); + ret = iio_ring_buffer_register_ex(indio_dev, 0, &ad5933_channels[1], 2); if (ret) goto error_unreg_ring; @@ -750,7 +748,7 @@ static int __devinit ad5933_probe(struct i2c_client *client, return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring: iio_sw_rb_free(indio_dev->ring); error_disable_reg: @@ -773,7 +771,7 @@ static __devexit int ad5933_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad5933_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); iio_sw_rb_free(indio_dev->ring); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 58a29b1e243..21c1a0768d6 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -853,7 +853,7 @@ static int __devinit adis16400_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, st->variant->channels, st->variant->num_channels); if (ret) { @@ -877,7 +877,7 @@ error_remove_trigger: if (indio_dev->modes & INDIO_RING_TRIGGERED) adis16400_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16400_unconfigure_ring(indio_dev); error_free_dev: @@ -900,7 +900,7 @@ static int adis16400_remove(struct spi_device *spi) goto err_ret; adis16400_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); + iio_ring_buffer_unregister(indio_dev); adis16400_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 2b72398ea73..e55edfa5586 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -292,7 +292,7 @@ void iio_device_free_chrdev_minor(int val) iio_free_ida_val(&iio_chrdev_ida, val); } -int iio_event_getfd(struct iio_dev *indio_dev) +static int iio_event_getfd(struct iio_dev *indio_dev) { if (indio_dev->event_interfaces == NULL) return -ENODEV; @@ -1079,6 +1079,8 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) static void iio_dev_release(struct device *device) { struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); + cdev_del(&dev_info->chrdev); + iio_device_free_chrdev_minor(MINOR(device->devt)); iio_put(); kfree(dev_info); } @@ -1118,11 +1120,63 @@ EXPORT_SYMBOL(iio_allocate_device); void iio_free_device(struct iio_dev *dev) { - if (dev) - iio_put_device(dev); + if (dev) { + iio_put(); + kfree(dev); + } } EXPORT_SYMBOL(iio_free_device); +/** + * iio_chrdev_open() - chrdev file open for ring buffer access and ioctls + **/ +static int iio_chrdev_open(struct inode *inode, struct file *filp) +{ + struct iio_dev *dev_info = container_of(inode->i_cdev, + struct iio_dev, chrdev); + filp->private_data = dev_info; + iio_chrdev_ring_open(dev_info); + return 0; +} + +/** + * iio_chrdev_release() - chrdev file close ring buffer access and ioctls + **/ +static int iio_chrdev_release(struct inode *inode, struct file *filp) +{ + iio_chrdev_ring_release(container_of(inode->i_cdev, + struct iio_dev, chrdev)); + return 0; +} + +/* Somewhat of a cross file organization violation - ioctls here are actually + * event related */ +static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + struct iio_dev *indio_dev = filp->private_data; + int __user *ip = (int __user *)arg; + int fd; + + if (cmd == IIO_GET_EVENT_FD_IOCTL) { + fd = iio_event_getfd(indio_dev); + if (copy_to_user(ip, &fd, sizeof(fd))) + return -EFAULT; + return 0; + } + return -EINVAL; +} + +static const struct file_operations iio_ring_fileops = { + .read = iio_ring_read_first_n_outer_addr, + .release = iio_chrdev_release, + .open = iio_chrdev_open, + .poll = iio_ring_poll_addr, + .owner = THIS_MODULE, + .llseek = noop_llseek, + .unlocked_ioctl = iio_ioctl, + .compat_ioctl = iio_ioctl, +}; + int iio_device_register(struct iio_dev *dev_info) { int ret; @@ -1133,7 +1187,13 @@ int iio_device_register(struct iio_dev *dev_info) dev_err(&dev_info->dev, "Failed to get id\n"); goto error_ret; } - dev_set_name(&dev_info->dev, "device%d", dev_info->id); + dev_set_name(&dev_info->dev, "iio:device%d", dev_info->id); + ret = iio_device_get_chrdev_minor(); + if (ret < 0) + goto error_free_ida; + + /* configure elements for the chrdev */ + dev_info->dev.devt = MKDEV(MAJOR(iio_devt), ret); ret = device_add(&dev_info->dev); if (ret) @@ -1153,6 +1213,9 @@ int iio_device_register(struct iio_dev *dev_info) if (dev_info->modes & INDIO_RING_TRIGGERED) iio_device_register_trigger_consumer(dev_info); + cdev_init(&dev_info->chrdev, &iio_ring_fileops); + dev_info->chrdev.owner = dev_info->info->driver_module; + ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1); return 0; error_free_sysfs: diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index cce02244ceb..1607293b036 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -24,42 +24,6 @@ #include "iio_core.h" #include "ring_generic.h" -/** - * iio_ring_open() - chrdev file open for ring buffer access - * - * This function relies on all ring buffer implementations having an - * iio_ring_buffer as their first element. - **/ -static int iio_ring_open(struct inode *inode, struct file *filp) -{ - struct iio_ring_buffer *rb - = container_of(inode->i_cdev, - struct iio_ring_buffer, chrdev); - filp->private_data = rb; - if (rb->access->mark_in_use) - rb->access->mark_in_use(rb); - - return 0; -} - -/** - * iio_ring_release() - chrdev file close ring buffer access - * - * This function relies on all ring buffer implementations having an - * iio_ring_buffer as their first element. - **/ -static int iio_ring_release(struct inode *inode, struct file *filp) -{ - struct iio_ring_buffer *rb - = container_of(inode->i_cdev, - struct iio_ring_buffer, chrdev); - - clear_bit(IIO_BUSY_BIT_POS, &rb->flags); - if (rb->access->unmark_in_use) - rb->access->unmark_in_use(rb); - - return 0; -} /** * iio_ring_read_first_n_outer() - chrdev read for ring buffer access @@ -67,10 +31,11 @@ static int iio_ring_release(struct inode *inode, struct file *filp) * This function relies on all ring buffer implementations having an * iio_ring _bufer as their first element. **/ -static ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, - size_t n, loff_t *f_ps) +ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, + size_t n, loff_t *f_ps) { - struct iio_ring_buffer *rb = filp->private_data; + struct iio_dev *indio_dev = filp->private_data; + struct iio_ring_buffer *rb = indio_dev->ring; if (!rb->access->read_first_n) return -EINVAL; @@ -80,10 +45,11 @@ static ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, /** * iio_ring_poll() - poll the ring to find out if it has data */ -static unsigned int iio_ring_poll(struct file *filp, - struct poll_table_struct *wait) +unsigned int iio_ring_poll(struct file *filp, + struct poll_table_struct *wait) { - struct iio_ring_buffer *rb = filp->private_data; + struct iio_dev *indio_dev = filp->private_data; + struct iio_ring_buffer *rb = indio_dev->ring; poll_wait(filp, &rb->pollq, wait); if (rb->stufftoread) @@ -92,89 +58,21 @@ static unsigned int iio_ring_poll(struct file *filp, return 0; } -/* Somewhat of a cross file organization violation - ioctls here are actually - * event related */ -static long iio_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +void iio_chrdev_ring_open(struct iio_dev *indio_dev) { - - struct iio_ring_buffer *rb = f->private_data; - struct iio_dev *indio_dev = rb->indio_dev; - int __user *ip = (int __user *)arg; - - if (cmd == IIO_GET_EVENT_FD_IOCTL) { - int fd; - fd = iio_event_getfd(indio_dev); - if (copy_to_user(ip, &fd, sizeof(fd))) - return -EFAULT; - return 0; - } - return -EINVAL; + struct iio_ring_buffer *rb = indio_dev->ring; + if (rb && rb->access->mark_in_use) + rb->access->mark_in_use(rb); } -static const struct file_operations iio_ring_fileops = { - .read = iio_ring_read_first_n_outer, - .release = iio_ring_release, - .open = iio_ring_open, - .poll = iio_ring_poll, - .owner = THIS_MODULE, - .llseek = noop_llseek, - .unlocked_ioctl = iio_ioctl, - .compat_ioctl = iio_ioctl, -}; - -void iio_ring_access_release(struct device *dev) +void iio_chrdev_ring_release(struct iio_dev *indio_dev) { - struct iio_ring_buffer *buf - = container_of(dev, struct iio_ring_buffer, dev); - cdev_del(&buf->chrdev); - iio_device_free_chrdev_minor(MINOR(dev->devt)); -} -EXPORT_SYMBOL(iio_ring_access_release); + struct iio_ring_buffer *rb = indio_dev->ring; -static inline int -__iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf, - struct module *owner, - int id) -{ - int ret; + clear_bit(IIO_BUSY_BIT_POS, &rb->flags); + if (rb->access->unmark_in_use) + rb->access->unmark_in_use(rb); - buf->flags = 0; - buf->dev.bus = &iio_bus_type; - device_initialize(&buf->dev); - - ret = iio_device_get_chrdev_minor(); - if (ret < 0) - goto error_device_put; - - buf->dev.devt = MKDEV(MAJOR(iio_devt), ret); - dev_set_name(&buf->dev, "%s:buffer%d", - dev_name(buf->dev.parent), - id); - ret = device_add(&buf->dev); - if (ret < 0) { - printk(KERN_ERR "failed to add the ring dev\n"); - goto error_device_put; - } - cdev_init(&buf->chrdev, &iio_ring_fileops); - buf->chrdev.owner = owner; - ret = cdev_add(&buf->chrdev, buf->dev.devt, 1); - if (ret) { - printk(KERN_ERR "failed to allocate ring chrdev\n"); - goto error_device_unregister; - } - return 0; - -error_device_unregister: - device_unregister(&buf->dev); -error_device_put: - put_device(&buf->dev); - - return ret; -} - -static void __iio_free_ring_buffer_chrdev(struct iio_ring_buffer *buf) -{ - device_unregister(&buf->dev); } void iio_ring_buffer_init(struct iio_ring_buffer *ring, @@ -209,9 +107,10 @@ static ssize_t iio_scan_el_show(struct device *dev, char *buf) { int ret; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *dev_info = dev_get_drvdata(dev); - ret = iio_scan_mask_query(ring, to_iio_dev_attr(attr)->address); + ret = iio_scan_mask_query(dev_info->ring, + to_iio_dev_attr(attr)->address); if (ret < 0) return ret; return sprintf(buf, "%d\n", ret); @@ -233,8 +132,8 @@ static ssize_t iio_scan_el_store(struct device *dev, { int ret = 0; bool state; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - struct iio_dev *indio_dev = ring->indio_dev; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = indio_dev->ring; struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); state = !(buf[0] == '0'); @@ -267,8 +166,8 @@ static ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", ring->scan_timestamp); + struct iio_dev *dev_info = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dev_info->ring->scan_timestamp); } static ssize_t iio_scan_el_ts_store(struct device *dev, @@ -277,26 +176,27 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, size_t len) { int ret = 0; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - struct iio_dev *indio_dev = ring->indio_dev; + struct iio_dev *indio_dev = dev_get_drvdata(dev); bool state; + state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); if (indio_dev->currentmode == INDIO_RING_TRIGGERED) { ret = -EBUSY; goto error_ret; } - ring->scan_timestamp = state; + indio_dev->ring->scan_timestamp = state; error_ret: mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } -static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring, +static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { int ret; + struct iio_ring_buffer *ring = indio_dev->ring; ret = __iio_add_chan_devattr("index", "scan_elements", chan, @@ -304,7 +204,7 @@ static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring, NULL, 0, 0, - &ring->dev, + &indio_dev->dev, &ring->scan_el_dev_attr_list); if (ret) goto error_ret; @@ -315,7 +215,7 @@ static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring, NULL, 0, 0, - &ring->dev, + &indio_dev->dev, &ring->scan_el_dev_attr_list); if (ret) goto error_ret; @@ -327,7 +227,7 @@ static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring, &iio_scan_el_store, chan->scan_index, 0, - &ring->dev, + &indio_dev->dev, &ring->scan_el_dev_attr_list); else ret = __iio_add_chan_devattr("en", "scan_elements", @@ -336,16 +236,16 @@ static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring, &iio_scan_el_ts_store, chan->scan_index, 0, - &ring->dev, + &indio_dev->dev, &ring->scan_el_dev_attr_list); error_ret: return ret; } -static void iio_ring_remove_and_free_scan_dev_attr(struct iio_ring_buffer *ring, +static void iio_ring_remove_and_free_scan_dev_attr(struct iio_dev *indio_dev, struct iio_dev_attr *p) { - sysfs_remove_file_from_group(&ring->dev.kobj, + sysfs_remove_file_from_group(&indio_dev->dev.kobj, &p->dev_attr.attr, "scan_elements"); kfree(p->dev_attr.attr.name); kfree(p); @@ -360,71 +260,79 @@ static struct attribute_group iio_scan_el_dummy_group = { .attrs = iio_scan_el_dummy_attrs }; -static void __iio_ring_attr_cleanup(struct iio_ring_buffer *ring) +static void __iio_ring_attr_cleanup(struct iio_dev *indio_dev) { struct iio_dev_attr *p, *n; + struct iio_ring_buffer *ring = indio_dev->ring; int anydynamic = !list_empty(&ring->scan_el_dev_attr_list); list_for_each_entry_safe(p, n, &ring->scan_el_dev_attr_list, l) - iio_ring_remove_and_free_scan_dev_attr(ring, p); + iio_ring_remove_and_free_scan_dev_attr(indio_dev, p); if (ring->scan_el_attrs) - sysfs_remove_group(&ring->dev.kobj, + sysfs_remove_group(&indio_dev->dev.kobj, ring->scan_el_attrs); else if (anydynamic) - sysfs_remove_group(&ring->dev.kobj, + sysfs_remove_group(&indio_dev->dev.kobj, &iio_scan_el_dummy_group); } -int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id, +int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, const struct iio_chan_spec *channels, int num_channels) { + struct iio_ring_buffer *ring = indio_dev->ring; int ret, i; - ret = __iio_request_ring_buffer_chrdev(ring, ring->owner, id); - if (ret) - goto error_ret; - if (ring->scan_el_attrs) { - ret = sysfs_create_group(&ring->dev.kobj, + ret = sysfs_create_group(&indio_dev->dev.kobj, ring->scan_el_attrs); if (ret) { - dev_err(&ring->dev, + dev_err(&indio_dev->dev, "Failed to add sysfs scan elements\n"); - goto error_free_ring_buffer_chrdev; + goto error_ret; } } else if (channels) { - ret = sysfs_create_group(&ring->dev.kobj, + ret = sysfs_create_group(&indio_dev->dev.kobj, &iio_scan_el_dummy_group); if (ret) - goto error_free_ring_buffer_chrdev; + goto error_ret; + } + if (ring->attrs) { + ret = sysfs_create_group(&indio_dev->dev.kobj, + ring->attrs); + if (ret) + goto error_cleanup_dynamic; } INIT_LIST_HEAD(&ring->scan_el_dev_attr_list); if (channels) { /* new magic */ for (i = 0; i < num_channels; i++) { - ret = iio_ring_add_channel_sysfs(ring, &channels[i]); + ret = iio_ring_add_channel_sysfs(indio_dev, + &channels[i]); if (ret < 0) - goto error_cleanup_dynamic; + goto error_cleanup_group; } } return 0; +error_cleanup_group: + if (ring->attrs) + sysfs_remove_group(&indio_dev->dev.kobj, ring->attrs); error_cleanup_dynamic: - __iio_ring_attr_cleanup(ring); -error_free_ring_buffer_chrdev: - __iio_free_ring_buffer_chrdev(ring); + __iio_ring_attr_cleanup(indio_dev); error_ret: return ret; } EXPORT_SYMBOL(iio_ring_buffer_register_ex); -void iio_ring_buffer_unregister(struct iio_ring_buffer *ring) +void iio_ring_buffer_unregister(struct iio_dev *indio_dev) { - __iio_ring_attr_cleanup(ring); - __iio_free_ring_buffer_chrdev(ring); + if (indio_dev->ring->attrs) + sysfs_remove_group(&indio_dev->dev.kobj, + indio_dev->ring->attrs); + __iio_ring_attr_cleanup(indio_dev); } EXPORT_SYMBOL(iio_ring_buffer_unregister); @@ -432,7 +340,8 @@ ssize_t iio_read_ring_length(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = indio_dev->ring; if (ring->access->get_length) return sprintf(buf, "%d\n", @@ -449,7 +358,8 @@ ssize_t iio_write_ring_length(struct device *dev, { int ret; ulong val; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = indio_dev->ring; ret = strict_strtoul(buf, 10, &val); if (ret) @@ -473,7 +383,8 @@ ssize_t iio_read_ring_bytes_per_datum(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = indio_dev->ring; if (ring->access->get_bytes_per_datum) return sprintf(buf, "%d\n", @@ -491,8 +402,8 @@ ssize_t iio_store_ring_enable(struct device *dev, int ret; bool requested_state, current_state; int previous_mode; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - struct iio_dev *dev_info = ring->indio_dev; + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = dev_info->ring; mutex_lock(&dev_info->mlock); previous_mode = dev_info->currentmode; @@ -584,8 +495,8 @@ ssize_t iio_show_ring_enable(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", !!(ring->indio_dev->currentmode + struct iio_dev *dev_info = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", !!(dev_info->currentmode & INDIO_ALL_RING_MODES)); } EXPORT_SYMBOL(iio_show_ring_enable); diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c index 3c9516b2a67..39b058557f6 100644 --- a/drivers/staging/iio/kfifo_buf.c +++ b/drivers/staging/iio/kfifo_buf.c @@ -87,24 +87,7 @@ static struct attribute *iio_kfifo_attributes[] = { static struct attribute_group iio_kfifo_attribute_group = { .attrs = iio_kfifo_attributes, -}; - -static const struct attribute_group *iio_kfifo_attribute_groups[] = { - &iio_kfifo_attribute_group, - NULL -}; - -static void iio_kfifo_release(struct device *dev) -{ - struct iio_ring_buffer *r = to_iio_ring_buffer(dev); - struct iio_kfifo *kf = iio_to_kfifo(r); - kfifo_free(&kf->kf); - kfree(kf); -} - -static struct device_type iio_kfifo_type = { - .release = iio_kfifo_release, - .groups = iio_kfifo_attribute_groups, + .name = "buffer", }; struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) @@ -116,10 +99,8 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) return NULL; kf->update_needed = true; iio_ring_buffer_init(&kf->ring, indio_dev); + kf->ring.attrs = &iio_kfifo_attribute_group; __iio_init_kfifo(kf); - kf->ring.dev.type = &iio_kfifo_type; - kf->ring.dev.parent = &indio_dev->dev; - dev_set_drvdata(&kf->ring.dev, (void *)&(kf->ring)); return &kf->ring; } @@ -159,8 +140,7 @@ static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length) void iio_kfifo_free(struct iio_ring_buffer *r) { - if (r) - iio_put_ring_buffer(r); + kfree(iio_to_kfifo(r)); } EXPORT_SYMBOL(iio_kfifo_free); diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h index fd74e156abf..4d73e1a3881 100644 --- a/drivers/staging/iio/meter/ade7758.h +++ b/drivers/staging/iio/meter/ade7758.h @@ -150,8 +150,7 @@ ssize_t ade7758_read_data_from_ring(struct device *dev, int ade7758_configure_ring(struct iio_dev *indio_dev); void ade7758_unconfigure_ring(struct iio_dev *indio_dev); -int ade7758_initialize_ring(struct iio_ring_buffer *ring); -void ade7758_uninitialize_ring(struct iio_ring_buffer *ring); +void ade7758_uninitialize_ring(struct iio_dev *indio_dev); int ade7758_set_irq(struct device *dev, bool enable); int ade7758_spi_write_reg_8(struct device *dev, @@ -180,7 +179,7 @@ static inline int ade7758_initialize_ring(struct iio_ring_buffer *ring) { return 0; } -static inline void ade7758_uninitialize_ring(struct iio_ring_buffer *ring) +static inline void ade7758_uninitialize_ring(struct iio_dev *indio_dev) { } #endif /* CONFIG_IIO_RING_BUFFER */ diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index ac0e092e49d..92c6dcc4f73 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -780,7 +780,7 @@ static int __devinit ade7758_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, + ret = iio_ring_buffer_register_ex(indio_dev, 0, &ade7758_channels[0], ARRAY_SIZE(ade7758_channels)); if (ret) { @@ -805,7 +805,7 @@ error_remove_trigger: if (indio_dev->modes & INDIO_RING_TRIGGERED) ade7758_remove_trigger(indio_dev); error_uninitialize_ring: - ade7758_uninitialize_ring(indio_dev->ring); + ade7758_uninitialize_ring(indio_dev); error_unreg_ring_funcs: ade7758_unconfigure_ring(indio_dev); error_free_tx: @@ -832,7 +832,7 @@ static int ade7758_remove(struct spi_device *spi) goto err_ret; ade7758_remove_trigger(indio_dev); - ade7758_uninitialize_ring(indio_dev->ring); + ade7758_uninitialize_ring(indio_dev); ade7758_unconfigure_ring(indio_dev); kfree(st->tx); kfree(st->rx); diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 1e2a09643a3..5e740e38616 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -200,7 +200,7 @@ error_iio_sw_rb_free: return ret; } -void ade7758_uninitialize_ring(struct iio_ring_buffer *ring) +void ade7758_uninitialize_ring(struct iio_dev *indio_dev) { - iio_ring_buffer_unregister(ring); + iio_ring_buffer_unregister(indio_dev); } diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 81bbe39ccc9..db8d0d1469b 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -94,7 +94,6 @@ struct iio_ring_setup_ops { * @flags: [INTERN] file ops related flags including busy flag. **/ struct iio_ring_buffer { - struct device dev; struct iio_dev *indio_dev; struct module *owner; int length; @@ -111,7 +110,7 @@ struct iio_ring_buffer { wait_queue_head_t pollq; bool stufftoread; unsigned long flags; - struct cdev chrdev; + const struct attribute_group *attrs; }; /** @@ -200,24 +199,15 @@ static inline int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) return 0; }; -/** - * iio_put_ring_buffer() - notify done with buffer - * @ring: the buffer we are done with. - **/ -static inline void iio_put_ring_buffer(struct iio_ring_buffer *ring) -{ - put_device(&ring->dev); -}; - #define to_iio_ring_buffer(d) \ container_of(d, struct iio_ring_buffer, dev) /** * iio_ring_buffer_register_ex() - register the buffer with IIO core - * @ring: the buffer to be registered + * @indio_dev: device with the buffer to be registered * @id: the id of the buffer (typically 0) **/ -int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id, +int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, const struct iio_chan_spec *channels, int num_channels); @@ -225,9 +215,9 @@ void iio_ring_access_release(struct device *dev); /** * iio_ring_buffer_unregister() - unregister the buffer from IIO core - * @ring: the buffer to be unregistered + * @indio_dev: the device with the buffer to be unregistered **/ -void iio_ring_buffer_unregister(struct iio_ring_buffer *ring); +void iio_ring_buffer_unregister(struct iio_dev *indio_dev); /** * iio_read_ring_length() - attr func to get number of datums in the buffer @@ -274,7 +264,7 @@ int iio_sw_ring_preenable(struct iio_dev *indio_dev); #else /* CONFIG_IIO_RING_BUFFER */ -static inline int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, +static inline int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, struct iio_chan_spec *channels, int num_channels) @@ -282,7 +272,7 @@ static inline int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, return 0; } -static inline void iio_ring_buffer_unregister(struct iio_ring_buffer *ring) +static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev) {}; #endif /* CONFIG_IIO_RING_BUFFER */ diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c index feb84e27c36..1905e033c41 100644 --- a/drivers/staging/iio/ring_sw.c +++ b/drivers/staging/iio/ring_sw.c @@ -392,13 +392,6 @@ static int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r) return 0; } -static void iio_sw_rb_release(struct device *dev) -{ - struct iio_ring_buffer *r = to_iio_ring_buffer(dev); - iio_ring_access_release(&r->dev); - kfree(iio_to_sw_ring(r)); -} - static IIO_RING_ENABLE_ATTR; static IIO_RING_BYTES_PER_DATUM_ATTR; static IIO_RING_LENGTH_ATTR; @@ -413,16 +406,7 @@ static struct attribute *iio_ring_attributes[] = { static struct attribute_group iio_ring_attribute_group = { .attrs = iio_ring_attributes, -}; - -static const struct attribute_group *iio_ring_attribute_groups[] = { - &iio_ring_attribute_group, - NULL -}; - -static struct device_type iio_sw_ring_type = { - .release = iio_sw_rb_release, - .groups = iio_ring_attribute_groups, + .name = "buffer", }; struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) @@ -437,9 +421,7 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) buf = &ring->buf; iio_ring_buffer_init(buf, indio_dev); __iio_init_sw_ring_buffer(ring); - buf->dev.type = &iio_sw_ring_type; - buf->dev.parent = &indio_dev->dev; - dev_set_drvdata(&buf->dev, (void *)buf); + buf->attrs = &iio_ring_attribute_group; return buf; } @@ -447,8 +429,7 @@ EXPORT_SYMBOL(iio_sw_rb_allocate); void iio_sw_rb_free(struct iio_ring_buffer *r) { - if (r) - iio_put_ring_buffer(r); + kfree(iio_to_sw_ring(r)); } EXPORT_SYMBOL(iio_sw_rb_free); From f625cb97d4d58f311a9606a4bcf9d9a334ca9952 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:48 +0100 Subject: [PATCH 0772/1519] staging: iio: remove now defunct header definitions and add some statics Now we have combined all chrdevs into one, some bits and bobs are only needed in industrialio-core.c and don't need to be in the core header. Also remove some unused defines. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core.h | 9 --------- drivers/staging/iio/industrialio-core.c | 9 +++------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index a27fa05d660..433952bb843 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -13,13 +13,6 @@ #ifndef _IIO_CORE_H_ #define _IIO_CORE_H_ -/** - * iio_device_get_chrdev_minor() - get an unused minor number - **/ -int iio_device_get_chrdev_minor(void); -void iio_device_free_chrdev_minor(int val); - - /** * iio_put() - internal module reference count reduce **/ @@ -30,8 +23,6 @@ void iio_put(void); **/ void iio_get(void); -extern dev_t iio_devt; - int __iio_add_chan_devattr(const char *postfix, const char *group, struct iio_chan_spec const *chan, diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index e55edfa5586..de918782d3b 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -27,9 +27,6 @@ #include "iio_core_trigger.h" #include "chrdev.h" -#define IIO_ID_PREFIX "device" -#define IIO_ID_FORMAT IIO_ID_PREFIX "%d" - /* IDR to assign each registered device a unique id*/ static DEFINE_IDA(iio_ida); /* IDR to allocate character device minor numbers */ @@ -37,7 +34,7 @@ static DEFINE_IDA(iio_chrdev_ida); /* Lock used to protect both of the above */ static DEFINE_SPINLOCK(iio_ida_lock); -dev_t iio_devt; +static dev_t iio_devt; #define IIO_DEV_MAX 256 struct bus_type iio_bus_type = { @@ -276,7 +273,7 @@ static const struct file_operations iio_event_chrdev_fileops = { .llseek = noop_llseek, }; -int iio_device_get_chrdev_minor(void) +static int iio_device_get_chrdev_minor(void) { int ret; @@ -287,7 +284,7 @@ int iio_device_get_chrdev_minor(void) return -ENOMEM; } -void iio_device_free_chrdev_minor(int val) +static void iio_device_free_chrdev_minor(int val) { iio_free_ida_val(&iio_chrdev_ida, val); } From b3874069f828117a9559e8b088680afa88449e3e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:32:49 +0100 Subject: [PATCH 0773/1519] staging: iio: Documentation sysfs-bus-iio update for chrdev merge. A few element in here have been wrong for some time so cleaned them up whilst here. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 573 +++++++++--------- 1 file changed, 276 insertions(+), 297 deletions(-) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index c19dbf4ab24..bed3bcb6b96 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -1,4 +1,4 @@ -What: /sys/bus/iio/devices/deviceX +What: /sys/bus/iio/devices/iio:deviceX KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -6,7 +6,7 @@ Description: Corresponds to a grouping of sensor channels. X is the IIO index of the device. -What: /sys/bus/iio/devices/device[n]/power_state +What: /sys/bus/iio/devices/iio:deviceX/power_state KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -25,21 +25,20 @@ Description: generalize well and hence are not documented in this file. X is the IIO index of the trigger. -What: /sys/bus/iio/devices/deviceX:buffer +What: /sys/bus/iio/devices/iio:deviceX/buffer KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: - Link to /sys/class/iio/deviceX/deviceX:buffer. X indicates - the device with which this buffer buffer is associated. + Directory of attributes relating to the buffer for the device. -What: /sys/bus/iio/devices/deviceX/name +What: /sys/bus/iio/devices/iio:deviceX/name KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Description of the physical chip / device for device X. Typically a part number. -What: /sys/bus/iio/devices/deviceX/sampling_frequency +What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -52,40 +51,40 @@ Description: relevant directories. If it effects all of the above then it is to be found in the base device directory as here. -What: /sys/bus/iio/devices/deviceX/sampling_frequency_available +What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency_available KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: When the internal sampling clock can only take a small discrete set of values, this file lists those available. -What: /sys/bus/iio/devices/deviceX/range +What: /sys/bus/iio/devices/iio:deviceX/range KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Hardware dependent ADC Full Scale Range in mVolt. -What: /sys/bus/iio/devices/deviceX/range_available +What: /sys/bus/iio/devices/iio:deviceX/range_available KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Hardware dependent supported vales for ADC Full Scale Range. -What: /sys/bus/iio/devices/deviceX/oversampling_ratio +What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Hardware dependent ADC oversampling. Controls the sampling ratio of the digital filter if available. -What: /sys/bus/iio/devices/deviceX/oversampling_ratio_available +What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio_available KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Hardware dependent values supported by the oversampling filter. -What: /sys/bus/iio/devices/deviceX/inY_raw -What: /sys/bus/iio/devices/deviceX/inY_supply_raw +What: /sys/bus/iio/devices/iio:deviceX/inY_raw +What: /sys/bus/iio/devices/iio:deviceX/inY_supply_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -95,7 +94,7 @@ Description: versions may be used. The number must always be specified and unique to allow association with event codes. -What: /sys/bus/iio/devices/deviceX/inY-inZ_raw +What: /sys/bus/iio/devices/iio:deviceX/inY-inZ_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -105,10 +104,10 @@ Description: separately available. In differential only parts, then all that is required is a consistent labeling. -What: /sys/bus/iio/devices/deviceX/temp_raw -What: /sys/bus/iio/devices/deviceX/temp_x_raw -What: /sys/bus/iio/devices/deviceX/temp_y_raw -What: /sys/bus/iio/devices/deviceX/temp_z_raw +What: /sys/bus/iio/devices/iio:deviceX/temp_raw +What: /sys/bus/iio/devices/iio:deviceX/temp_x_raw +What: /sys/bus/iio/devices/iio:deviceX/temp_y_raw +What: /sys/bus/iio/devices/iio:deviceX/temp_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -117,15 +116,15 @@ Description: sensor is associated with one part of a compound device (e.g. a gyroscope axis). -What: /sys/bus/iio/devices/deviceX/tempX_input +What: /sys/bus/iio/devices/iio:deviceX/tempX_input KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Scaled temperature measurement in milli degrees Celsius. -What: /sys/bus/iio/devices/deviceX/accel_x_raw -What: /sys/bus/iio/devices/deviceX/accel_y_raw -What: /sys/bus/iio/devices/deviceX/accel_z_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_x_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_y_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -135,9 +134,9 @@ Description: this orientation). Has all of the equivalent parameters as per inY. Units after application of scale and offset are m/s^2. -What: /sys/bus/iio/devices/deviceX/gyro_x_raw -What: /sys/bus/iio/devices/deviceX/gyro_y_raw -What: /sys/bus/iio/devices/deviceX/gyro_z_raw +What: /sys/bus/iio/devices/iio:deviceX/gyro_x_raw +What: /sys/bus/iio/devices/iio:deviceX/gyro_y_raw +What: /sys/bus/iio/devices/iio:deviceX/gyro_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -146,9 +145,9 @@ Description: radians per second. Has all the equivalent parameters as per inY. -What: /sys/bus/iio/devices/deviceX/incli_x_raw -What: /sys/bus/iio/devices/deviceX/incli_y_raw -What: /sys/bus/iio/devices/deviceX/incli_z_raw +What: /sys/bus/iio/devices/iio:deviceX/incli_x_raw +What: /sys/bus/iio/devices/iio:deviceX/incli_y_raw +What: /sys/bus/iio/devices/iio:deviceX/incli_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -156,9 +155,9 @@ Description: arbitrarily assigned). Data converted by application of offset and scale to Degrees. -What: /sys/bus/iio/devices/deviceX/magn_x_raw -What: /sys/bus/iio/devices/deviceX/magn_y_raw -What: /sys/bus/iio/devices/deviceX/magn_z_raw +What: /sys/bus/iio/devices/iio:deviceX/magn_x_raw +What: /sys/bus/iio/devices/iio:deviceX/magn_y_raw +What: /sys/bus/iio/devices/iio:deviceX/magn_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -168,9 +167,9 @@ Description: offset then scale to Gauss. Has all the equivalent modifiers as per inY. -What: /sys/bus/iio/devices/deviceX/accel_x_peak_raw -What: /sys/bus/iio/devices/deviceX/accel_y_peak_raw -What: /sys/bus/iio/devices/deviceX/accel_z_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_x_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_y_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_z_peak_raw KernelVersion: 2.6.36 Contact: linux-iio@vger.kernel.org Description: @@ -179,15 +178,15 @@ Description: and are otherwise the direct equivalent of the Y[_name]_raw attributes. -What: /sys/bus/iio/devices/deviceX/accel_xyz_squared_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/accel_xyz_squared_peak_raw KernelVersion: 2.6.36 Contact: linux-iio@vger.kernel.org Description: A computed peak value based on the sum squared magnitude of the underlying value in the specified directions. -What: /sys/bus/iio/devices/deviceX/accel_offset -What: /sys/bus/iio/devices/deviceX/temp_offset +What: /sys/bus/iio/devices/iio:deviceX/accel_offset +What: /sys/bus/iio/devices/iio:deviceX/temp_offset KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -202,17 +201,17 @@ Description: for variation between different instances of the part, typically adjusted by using some hardware supported calibration procedure. -What: /sys/bus/iio/devices/deviceX/inY_scale -What: /sys/bus/iio/devices/deviceX/inY_supply_scale -What: /sys/bus/iio/devices/deviceX/in_scale -What: /sys/bus/iio/devices/deviceX/outY_scale -What: /sys/bus/iio/devices/deviceX/accel_scale -What: /sys/bus/iio/devices/deviceX/accel_peak_scale -What: /sys/bus/iio/devices/deviceX/gyro_scale -What: /sys/bus/iio/devices/deviceX/magn_scale -What: /sys/bus/iio/devices/deviceX/magn_x_scale -What: /sys/bus/iio/devices/deviceX/magn_y_scale -What: /sys/bus/iio/devices/deviceX/magn_z_scale +What: /sys/bus/iio/devices/iio:deviceX/inY_scale +What: /sys/bus/iio/devices/iio:deviceX/inY_supply_scale +What: /sys/bus/iio/devices/iio:deviceX/in_scale +What: /sys/bus/iio/devices/iio:deviceX/outY_scale +What: /sys/bus/iio/devices/iio:deviceX/accel_scale +What: /sys/bus/iio/devices/iio:deviceX/accel_peak_scale +What: /sys/bus/iio/devices/iio:deviceX/gyro_scale +What: /sys/bus/iio/devices/iio:deviceX/magn_scale +What: /sys/bus/iio/devices/iio:deviceX/magn_x_scale +What: /sys/bus/iio/devices/iio:deviceX/magn_y_scale +What: /sys/bus/iio/devices/iio:deviceX/magn_z_scale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -224,12 +223,12 @@ Description: [Y][_name]_scale. The peak modifier means this value is applied to Y[_name]_peak_raw values. -What: /sys/bus/iio/devices/deviceX/accel_x_calibbias -What: /sys/bus/iio/devices/deviceX/accel_y_calibbias -What: /sys/bus/iio/devices/deviceX/accel_z_calibbias -What: /sys/bus/iio/devices/deviceX/gyro_x_calibbias -What: /sys/bus/iio/devices/deviceX/gyro_y_calibbias -What: /sys/bus/iio/devices/deviceX/gyro_z_calibbias +What: /sys/bus/iio/devices/iio:deviceX/accel_x_calibbias +What: /sys/bus/iio/devices/iio:deviceX/accel_y_calibbias +What: /sys/bus/iio/devices/iio:deviceX/accel_z_calibbias +What: /sys/bus/iio/devices/iio:deviceX/gyro_x_calibbias +What: /sys/bus/iio/devices/iio:deviceX/gyro_y_calibbias +What: /sys/bus/iio/devices/iio:deviceX/gyro_z_calibbias KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -237,15 +236,15 @@ Description: inaccuracies). If shared across all channels, _calibbias is used. -What /sys/bus/iio/devices/deviceX/inY_calibscale -What /sys/bus/iio/devices/deviceX/inY_supply_calibscale -What /sys/bus/iio/devices/deviceX/in_calibscale -What /sys/bus/iio/devices/deviceX/accel_x_calibscale -What /sys/bus/iio/devices/deviceX/accel_y_calibscale -What /sys/bus/iio/devices/deviceX/accel_z_calibscale -What /sys/bus/iio/devices/deviceX/gyro_x_calibscale -What /sys/bus/iio/devices/deviceX/gyro_y_calibscale -What /sys/bus/iio/devices/deviceX/gyro_z_calibscale +What /sys/bus/iio/devices/iio:deviceX/inY_calibscale +What /sys/bus/iio/devices/iio:deviceX/inY_supply_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_calibscale +What /sys/bus/iio/devices/iio:deviceX/accel_x_calibscale +What /sys/bus/iio/devices/iio:deviceX/accel_y_calibscale +What /sys/bus/iio/devices/iio:deviceX/accel_z_calibscale +What /sys/bus/iio/devices/iio:deviceX/gyro_x_calibscale +What /sys/bus/iio/devices/iio:deviceX/gyro_y_calibscale +What /sys/bus/iio/devices/iio:deviceX/gyro_z_calibscale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -253,14 +252,14 @@ Description: production inaccuracies). If shared across all channels, _calibscale is used. -What: /sys/bus/iio/devices/deviceX/accel_scale_available +What: /sys/bus/iio/devices/iio:deviceX/accel_scale_available KernelVersion: 2.635 Contact: linux-iio@vger.kernel.org Description: If a discrete set of scale values are available, they are listed in this attribute. -What: /sys/bus/iio/devices/deviceX/outY_raw +What: /sys/bus/iio/devices/iio:deviceX/outY_raw KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -268,7 +267,7 @@ Description: channel Y. The number must always be specified and unique if the output corresponds to a single channel. -What: /sys/bus/iio/devices/deviceX/outY&Z_raw +What: /sys/bus/iio/devices/iio:deviceX/outY&Z_raw KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -277,8 +276,8 @@ Description: where a single output sets the value for multiple channels simultaneously. -What: /sys/bus/iio/devices/deviceX/outY_powerdown_mode -What: /sys/bus/iio/devices/deviceX/out_powerdown_mode +What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown_mode +What: /sys/bus/iio/devices/iio:deviceX/out_powerdown_mode KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: @@ -291,16 +290,16 @@ Description: outX_powerdown_mode_available. If Y is not present the mode is shared across all outputs. -What: /sys/bus/iio/devices/deviceX/outY_powerdown_mode_available -What: /sys/bus/iio/devices/deviceX/out_powerdown_mode_available +What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown_mode_available +What: /sys/bus/iio/devices/iio:deviceX/out_powerdown_mode_available KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Lists all available output power down modes. If Y is not present the mode is shared across all outputs. -What: /sys/bus/iio/devices/deviceX/outY_powerdown -What: /sys/bus/iio/devices/deviceX/out_powerdown +What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown +What: /sys/bus/iio/devices/iio:deviceX/out_powerdown KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: @@ -309,45 +308,37 @@ Description: normal operation. Y may be suppressed if all outputs are controlled together. -What: /sys/bus/iio/devices/deviceX/deviceX:eventY +What: /sys/bus/iio/devices/iio:deviceX/events KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Configuration of which hardware generated events are passed up to user-space. -What: /sys/bus/iio/devices/deviceX:event/dev -What: /sys/bus/iio/devices/deviceX:eventY/dev -KernelVersion: 2.6.35 -Contact: linux-iio@vger.kernel.org -Description: - major:minor character device numbers for the event line Y of - device X. - -What: /sys/.../deviceX:eventY/accel_x_thresh_rising_en -What: /sys/.../deviceX:eventY/accel_x_thresh_falling_en -What: /sys/.../deviceX:eventY/accel_y_thresh_rising_en -What: /sys/.../deviceX:eventY/accel_y_thresh_falling_en -What: /sys/.../deviceX:eventY/accel_z_thresh_rising_en -What: /sys/.../deviceX:eventY/accel_z_thresh_falling_en -What: /sys/.../deviceX:eventY/gyro_x_thresh_rising_en -What: /sys/.../deviceX:eventY/gyro_x_thresh_falling_en -What: /sys/.../deviceX:eventY/gyro_y_thresh_rising_en -What: /sys/.../deviceX:eventY/gyro_y_thresh_falling_en -What: /sys/.../deviceX:eventY/gyro_z_thresh_rising_en -What: /sys/.../deviceX:eventY/gyro_z_thresh_falling_en -What: /sys/.../deviceX:eventY/magn_x_thresh_rising_en -What: /sys/.../deviceX:eventY/magn_x_thresh_falling_en -What: /sys/.../deviceX:eventY/magn_y_thresh_rising_en -What: /sys/.../deviceX:eventY/magn_y_thresh_falling_en -What: /sys/.../deviceX:eventY/magn_z_thresh_rising_en -What: /sys/.../deviceX:eventY/magn_z_thresh_falling_en -What: /sys/.../deviceX:eventY/inZ_supply_thresh_rising_en -What: /sys/.../deviceX:eventY/inZ_supply_thresh_falling_en -What: /sys/.../deviceX:eventY/inZ_thresh_rising_en -What: /sys/.../deviceX:eventY/inZ_thresh_falling_en -What: /sys/.../deviceX:eventY/temp_thresh_rising_en -What: /sys/.../deviceX:eventY/temp_thresh_falling_en +What: /sys/.../iio:deviceX/events/accel_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/accel_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/accel_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/accel_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/accel_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/accel_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/gyro_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/gyro_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/gyro_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/gyro_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/gyro_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/gyro_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/magn_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/magn_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/magn_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/magn_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/magn_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/magn_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/inZ_supply_thresh_rising_en +What: /sys/.../iio:deviceX/events/inZ_supply_thresh_falling_en +What: /sys/.../iio:deviceX/events/inZ_thresh_rising_en +What: /sys/.../iio:deviceX/events/inZ_thresh_falling_en +What: /sys/.../iio:deviceX/events/temp_thresh_rising_en +What: /sys/.../iio:deviceX/events/temp_thresh_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -369,30 +360,30 @@ Description: a given event type is enabled a future point (and not those for whatever event was previously enabled). -What: /sys/.../deviceX:eventY/accel_x_roc_rising_en -What: /sys/.../deviceX:eventY/accel_x_roc_falling_en -What: /sys/.../deviceX:eventY/accel_y_roc_rising_en -What: /sys/.../deviceX:eventY/accel_y_roc_falling_en -What: /sys/.../deviceX:eventY/accel_z_roc_rising_en -What: /sys/.../deviceX:eventY/accel_z_roc_falling_en -What: /sys/.../deviceX:eventY/gyro_x_roc_rising_en -What: /sys/.../deviceX:eventY/gyro_x_roc_falling_en -What: /sys/.../deviceX:eventY/gyro_y_roc_rising_en -What: /sys/.../deviceX:eventY/gyro_y_roc_falling_en -What: /sys/.../deviceX:eventY/gyro_z_roc_rising_en -What: /sys/.../deviceX:eventY/gyro_z_roc_falling_en -What: /sys/.../deviceX:eventY/magn_x_roc_rising_en -What: /sys/.../deviceX:eventY/magn_x_roc_falling_en -What: /sys/.../deviceX:eventY/magn_y_roc_rising_en -What: /sys/.../deviceX:eventY/magn_y_roc_falling_en -What: /sys/.../deviceX:eventY/magn_z_roc_rising_en -What: /sys/.../deviceX:eventY/magn_z_roc_falling_en -What: /sys/.../deviceX:eventY/inZ_supply_roc_rising_en -What: /sys/.../deviceX:eventY/inZ_supply_roc_falling_en -What: /sys/.../deviceX:eventY/inZ_roc_rising_en -What: /sys/.../deviceX:eventY/inZ_roc_falling_en -What: /sys/.../deviceX:eventY/temp_roc_rising_en -What: /sys/.../deviceX:eventY/temp_roc_falling_en +What: /sys/.../iio:deviceX/events/accel_x_roc_rising_en +What: /sys/.../iio:deviceX/events/accel_x_roc_falling_en +What: /sys/.../iio:deviceX/events/accel_y_roc_rising_en +What: /sys/.../iio:deviceX/events/accel_y_roc_falling_en +What: /sys/.../iio:deviceX/events/accel_z_roc_rising_en +What: /sys/.../iio:deviceX/events/accel_z_roc_falling_en +What: /sys/.../iio:deviceX/events/gyro_x_roc_rising_en +What: /sys/.../iio:deviceX/events/gyro_x_roc_falling_en +What: /sys/.../iio:deviceX/events/gyro_y_roc_rising_en +What: /sys/.../iio:deviceX/events/gyro_y_roc_falling_en +What: /sys/.../iio:deviceX/events/gyro_z_roc_rising_en +What: /sys/.../iio:deviceX/events/gyro_z_roc_falling_en +What: /sys/.../iio:deviceX/events/magn_x_roc_rising_en +What: /sys/.../iio:deviceX/events/magn_x_roc_falling_en +What: /sys/.../iio:deviceX/events/magn_y_roc_rising_en +What: /sys/.../iio:deviceX/events/magn_y_roc_falling_en +What: /sys/.../iio:deviceX/events/magn_z_roc_rising_en +What: /sys/.../iio:deviceX/events/magn_z_roc_falling_en +What: /sys/.../iio:deviceX/events/inZ_supply_roc_rising_en +What: /sys/.../iio:deviceX/events/inZ_supply_roc_falling_en +What: /sys/.../iio:deviceX/events/inZ_roc_rising_en +What: /sys/.../iio:deviceX/events/inZ_roc_falling_en +What: /sys/.../iio:deviceX/events/temp_roc_rising_en +What: /sys/.../iio:deviceX/events/temp_roc_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -415,30 +406,30 @@ Description: a given event type is enabled a future point (and not those for whatever event was previously enabled). -What: /sys/.../deviceX:eventY/accel_x_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/accel_x_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/accel_y_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/accel_y_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/accel_z_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/accel_z_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/gyro_x_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/gyro_x_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/gyro_y_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/gyro_y_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/gyro_z_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/gyro_z_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/magn_x_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/magn_x_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/magn_y_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/magn_y_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/magn_z_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/magn_z_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/inZ_supply_raw_thresh_rising_value -What: /sys/.../deviceX:eventY/inZ_supply_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/inZ_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/inZ_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/temp_raw_thresh_falling_value -What: /sys/.../deviceX:eventY/temp_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/accel_x_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/accel_x_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/accel_y_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/accel_y_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/accel_z_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/accel_z_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/gyro_x_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/gyro_x_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/gyro_y_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/gyro_y_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/gyro_z_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/gyro_z_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/magn_x_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/magn_x_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/magn_y_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/magn_y_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/magn_z_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/magn_z_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/inZ_supply_raw_thresh_rising_value +What: /sys/.../iio:deviceX/events/inZ_supply_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/inZ_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/inZ_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/temp_raw_thresh_falling_value +What: /sys/.../iio:deviceX/events/temp_raw_thresh_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -452,30 +443,30 @@ Description: value is in raw device units or in processed units (as _raw and _input do on sysfs direct channel read attributes). -What: /sys/.../deviceX:eventY/accel_x_raw_roc_rising_value -What: /sys/.../deviceX:eventY/accel_x_raw_roc_falling_value -What: /sys/.../deviceX:eventY/accel_y_raw_roc_rising_value -What: /sys/.../deviceX:eventY/accel_y_raw_roc_falling_value -What: /sys/.../deviceX:eventY/accel_z_raw_roc_rising_value -What: /sys/.../deviceX:eventY/accel_z_raw_roc_falling_value -What: /sys/.../deviceX:eventY/gyro_x_raw_roc_rising_value -What: /sys/.../deviceX:eventY/gyro_x_raw_roc_falling_value -What: /sys/.../deviceX:eventY/gyro_y_raw_roc_rising_value -What: /sys/.../deviceX:eventY/gyro_y_raw_roc_falling_value -What: /sys/.../deviceX:eventY/gyro_z_raw_roc_rising_value -What: /sys/.../deviceX:eventY/gyro_z_raw_roc_falling_value -What: /sys/.../deviceX:eventY/magn_x_raw_roc_rising_value -What: /sys/.../deviceX:eventY/magn_x_raw_roc_falling_value -What: /sys/.../deviceX:eventY/magn_y_raw_roc_rising_value -What: /sys/.../deviceX:eventY/magn_y_raw_roc_falling_value -What: /sys/.../deviceX:eventY/magn_z_raw_roc_rising_value -What: /sys/.../deviceX:eventY/magn_z_raw_roc_falling_value -What: /sys/.../deviceX:eventY/inZ_supply_raw_roc_rising_value -What: /sys/.../deviceX:eventY/inZ_supply_raw_roc_falling_value -What: /sys/.../deviceX:eventY/inZ_raw_roc_falling_value -What: /sys/.../deviceX:eventY/inZ_raw_roc_falling_value -What: /sys/.../deviceX:eventY/temp_raw_roc_falling_value -What: /sys/.../deviceX:eventY/temp_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/accel_x_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/accel_x_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/accel_y_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/accel_y_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/accel_z_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/accel_z_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/gyro_x_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/gyro_x_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/gyro_y_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/gyro_y_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/gyro_z_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/gyro_z_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/magn_x_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/magn_x_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/magn_y_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/magn_y_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/magn_z_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/magn_z_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/inZ_supply_raw_roc_rising_value +What: /sys/.../iio:deviceX/events/inZ_supply_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/inZ_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/inZ_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/temp_raw_roc_falling_value +What: /sys/.../iio:deviceX/events/temp_raw_roc_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -489,55 +480,55 @@ Description: value is in raw device units or in processed units (as _raw and _input do on sysfs direct channel read attributes). -What: /sys/.../deviceX:eventY/accel_x_thresh_rising_period -What: /sys/.../deviceX:eventY/accel_x_thresh_falling_period -hat: /sys/.../deviceX:eventY/accel_x_roc_rising_period -What: /sys/.../deviceX:eventY/accel_x_roc_falling_period -What: /sys/.../deviceX:eventY/accel_y_thresh_rising_period -What: /sys/.../deviceX:eventY/accel_y_thresh_falling_period -What: /sys/.../deviceX:eventY/accel_y_roc_rising_period -What: /sys/.../deviceX:eventY/accel_y_roc_falling_period -What: /sys/.../deviceX:eventY/accel_z_thresh_rising_period -What: /sys/.../deviceX:eventY/accel_z_thresh_falling_period -What: /sys/.../deviceX:eventY/accel_z_roc_rising_period -What: /sys/.../deviceX:eventY/accel_z_roc_falling_period -What: /sys/.../deviceX:eventY/gyro_x_thresh_rising_period -What: /sys/.../deviceX:eventY/gyro_x_thresh_falling_period -What: /sys/.../deviceX:eventY/gyro_x_roc_rising_period -What: /sys/.../deviceX:eventY/gyro_x_roc_falling_period -What: /sys/.../deviceX:eventY/gyro_y_thresh_rising_period -What: /sys/.../deviceX:eventY/gyro_y_thresh_falling_period -What: /sys/.../deviceX:eventY/gyro_y_roc_rising_period -What: /sys/.../deviceX:eventY/gyro_y_roc_falling_period -What: /sys/.../deviceX:eventY/gyro_z_thresh_rising_period -What: /sys/.../deviceX:eventY/gyro_z_thresh_falling_period -What: /sys/.../deviceX:eventY/gyro_z_roc_rising_period -What: /sys/.../deviceX:eventY/gyro_z_roc_falling_period -What: /sys/.../deviceX:eventY/magn_x_thresh_rising_period -What: /sys/.../deviceX:eventY/magn_x_thresh_falling_period -What: /sys/.../deviceX:eventY/magn_x_roc_rising_period -What: /sys/.../deviceX:eventY/magn_x_roc_falling_period -What: /sys/.../deviceX:eventY/magn_y_thresh_rising_period -What: /sys/.../deviceX:eventY/magn_y_thresh_falling_period -What: /sys/.../deviceX:eventY/magn_y_roc_rising_period -What: /sys/.../deviceX:eventY/magn_y_roc_falling_period -What: /sys/.../deviceX:eventY/magn_z_thresh_rising_period -What: /sys/.../deviceX:eventY/magn_z_thresh_falling_period -What: /sys/.../deviceX:eventY/magn_z_roc_rising_period -What: /sys/.../deviceX:eventY/magn_z_roc_falling_period -What: /sys/.../deviceX:eventY/inZ_supply_thresh_rising_period -What: /sys/.../deviceX:eventY/inZ_supply_thresh_falling_period -What: /sys/.../deviceX:eventY/inz_supply_roc_rising_period -What: /sys/.../deviceX:eventY/inZ_supply_roc_falling_period -What: /sys/.../deviceX:eventY/inZ_thresh_rising_period -What: /sys/.../deviceX:eventY/inZ_thresh_falling_period -What: /sys/.../deviceX:eventY/inZ_roc_rising_period -What: /sys/.../deviceX:eventY/inZ_roc_falling_period -What: /sys/.../deviceX:eventY/temp_thresh_rising_period -What: /sys/.../deviceX:eventY/temp_thresh_falling_period -What: /sys/.../deviceX:eventY/temp_roc_rising_period -What: /sys/.../deviceX:eventY/temp_roc_falling_period -What: /sys/.../deviceX:eventY/accel_x&y&z_mag_falling_period +What: /sys/.../iio:deviceX/events/accel_x_thresh_rising_period +What: /sys/.../iio:deviceX/events/accel_x_thresh_falling_period +hat: /sys/.../iio:deviceX/events/accel_x_roc_rising_period +What: /sys/.../iio:deviceX/events/accel_x_roc_falling_period +What: /sys/.../iio:deviceX/events/accel_y_thresh_rising_period +What: /sys/.../iio:deviceX/events/accel_y_thresh_falling_period +What: /sys/.../iio:deviceX/events/accel_y_roc_rising_period +What: /sys/.../iio:deviceX/events/accel_y_roc_falling_period +What: /sys/.../iio:deviceX/events/accel_z_thresh_rising_period +What: /sys/.../iio:deviceX/events/accel_z_thresh_falling_period +What: /sys/.../iio:deviceX/events/accel_z_roc_rising_period +What: /sys/.../iio:deviceX/events/accel_z_roc_falling_period +What: /sys/.../iio:deviceX/events/gyro_x_thresh_rising_period +What: /sys/.../iio:deviceX/events/gyro_x_thresh_falling_period +What: /sys/.../iio:deviceX/events/gyro_x_roc_rising_period +What: /sys/.../iio:deviceX/events/gyro_x_roc_falling_period +What: /sys/.../iio:deviceX/events/gyro_y_thresh_rising_period +What: /sys/.../iio:deviceX/events/gyro_y_thresh_falling_period +What: /sys/.../iio:deviceX/events/gyro_y_roc_rising_period +What: /sys/.../iio:deviceX/events/gyro_y_roc_falling_period +What: /sys/.../iio:deviceX/events/gyro_z_thresh_rising_period +What: /sys/.../iio:deviceX/events/gyro_z_thresh_falling_period +What: /sys/.../iio:deviceX/events/gyro_z_roc_rising_period +What: /sys/.../iio:deviceX/events/gyro_z_roc_falling_period +What: /sys/.../iio:deviceX/events/magn_x_thresh_rising_period +What: /sys/.../iio:deviceX/events/magn_x_thresh_falling_period +What: /sys/.../iio:deviceX/events/magn_x_roc_rising_period +What: /sys/.../iio:deviceX/events/magn_x_roc_falling_period +What: /sys/.../iio:deviceX/events/magn_y_thresh_rising_period +What: /sys/.../iio:deviceX/events/magn_y_thresh_falling_period +What: /sys/.../iio:deviceX/events/magn_y_roc_rising_period +What: /sys/.../iio:deviceX/events/magn_y_roc_falling_period +What: /sys/.../iio:deviceX/events/magn_z_thresh_rising_period +What: /sys/.../iio:deviceX/events/magn_z_thresh_falling_period +What: /sys/.../iio:deviceX/events/magn_z_roc_rising_period +What: /sys/.../iio:deviceX/events/magn_z_roc_falling_period +What: /sys/.../iio:deviceX/events/inZ_supply_thresh_rising_period +What: /sys/.../iio:deviceX/events/inZ_supply_thresh_falling_period +What: /sys/.../iio:deviceX/events/inz_supply_roc_rising_period +What: /sys/.../iio:deviceX/events/inZ_supply_roc_falling_period +What: /sys/.../iio:deviceX/events/inZ_thresh_rising_period +What: /sys/.../iio:deviceX/events/inZ_thresh_falling_period +What: /sys/.../iio:deviceX/events/inZ_roc_rising_period +What: /sys/.../iio:deviceX/events/inZ_roc_falling_period +What: /sys/.../iio:deviceX/events/temp_thresh_rising_period +What: /sys/.../iio:deviceX/events/temp_thresh_falling_period +What: /sys/.../iio:deviceX/events/temp_roc_rising_period +What: /sys/.../iio:deviceX/events/temp_roc_falling_period +What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_falling_period KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -545,20 +536,20 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions. -What: /sys/.../deviceX:eventY/accel_mag_en -What: /sys/.../deviceX:eventY/accel_mag_rising_en -What: /sys/.../deviceX:eventY/accel_mag_falling_en -What: /sys/.../deviceX:eventY/accel_x_mag_en -What: /sys/.../deviceX:eventY/accel_x_mag_rising_en -What: /sys/.../deviceX:eventY/accel_x_mag_falling_en -What: /sys/.../deviceX:eventY/accel_y_mag_en -What: /sys/.../deviceX:eventY/accel_y_mag_rising_en -What: /sys/.../deviceX:eventY/accel_y_mag_falling_en -What: /sys/.../deviceX:eventY/accel_z_mag_en -What: /sys/.../deviceX:eventY/accel_z_mag_rising_en -What: /sys/.../deviceX:eventY/accel_z_mag_falling_en -What: /sys/.../deviceX:eventY/accel_x&y&z_mag_rising_en -What: /sys/.../deviceX:eventY/accel_x&y&z_mag_falling_en +What: /sys/.../iio:deviceX/events/accel_mag_en +What: /sys/.../iio:deviceX/events/accel_mag_rising_en +What: /sys/.../iio:deviceX/events/accel_mag_falling_en +What: /sys/.../iio:deviceX/events/accel_x_mag_en +What: /sys/.../iio:deviceX/events/accel_x_mag_rising_en +What: /sys/.../iio:deviceX/events/accel_x_mag_falling_en +What: /sys/.../iio:deviceX/events/accel_y_mag_en +What: /sys/.../iio:deviceX/events/accel_y_mag_rising_en +What: /sys/.../iio:deviceX/events/accel_y_mag_falling_en +What: /sys/.../iio:deviceX/events/accel_z_mag_en +What: /sys/.../iio:deviceX/events/accel_z_mag_rising_en +What: /sys/.../iio:deviceX/events/accel_z_mag_falling_en +What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_rising_en +What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -577,80 +568,68 @@ Description: number or direction is not specified, applies to all channels of this type. -What: /sys/bus/iio/devices/deviceX:buffer:event/dev -KernelVersion: 2.6.35 -Contact: linux-iio@vger.kernel.org -Description: - Buffer for device X event character device major:minor numbers. - -What: /sys/bus/iio/devices/deviceX:buffer:access/dev -KernelVersion: 2.6.35 -Contact: linux-iio@vger.kernel.org -Description: - Buffer for device X access character device major:minor numbers. - -What: /sys/bus/iio/devices/deviceX:buffer/trigger +What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: The name of the trigger source being used, as per string given in /sys/class/iio/triggerY/name. -What: /sys/bus/iio/devices/deviceX:buffer/length +What: /sys/bus/iio/devices/iio:deviceX/buffer/length KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Number of scans contained by the buffer. -What: /sys/bus/iio/devices/deviceX:buffer/bytes_per_datum +What: /sys/bus/iio/devices/iio:deviceX/buffer/bytes_per_datum KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Bytes per scan. Due to alignment fun, the scan may be larger than implied directly by the scan_element parameters. -What: /sys/bus/iio/devices/deviceX:buffer/enable +What: /sys/bus/iio/devices/iio:deviceX/buffer/enable KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Actually start the buffer capture up. Will start trigger if first device and appropriate. -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements +What: /sys/bus/iio/devices/iio:deviceX/buffer/scan_elements KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Directory containing interfaces for elements that will be captured for a single triggered sample set in the buffer. -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_x_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_y_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_z_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_x_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_y_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_z_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_x_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_y_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_z_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/timestamp_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/inY_supply_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/inY_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/inY-inZ_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/incli_x_en -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/incli_y_en +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_x_en +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_y_en +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_z_en +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_x_en +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_y_en +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_z_en +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_x_en +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_y_en +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_z_en +What: /sys/.../iio:deviceX/buffer/scan_elements/timestamp_en +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_en +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_en +What: /sys/.../iio:deviceX/buffer/scan_elements/inY-inZ_en +What: /sys/.../iio:deviceX/buffer/scan_elements/incli_x_en +What: /sys/.../iio:deviceX/buffer/scan_elements/incli_y_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Scan element control for triggered data capture. -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_type -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_type -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_type -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/incli_type -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/inY_type -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/in-in_type -What: /sys/.../deviceX:buffer/scan_elements/inY_supply_type -What: /sys/.../deviceX:buffer/scan_elements/timestamp_type +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_type +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_type +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_type +What: /sys/.../iio:deviceX/buffer/scan_elements/incli_type +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_type +What: /sys/.../iio:deviceX/buffer/scan_elements/in-in_type +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_type +What: /sys/.../iio:deviceX/buffer/scan_elements/timestamp_type KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -673,27 +652,27 @@ Description: For other storage combinations this attribute will be extended appropriately. -What: /sys/.../deviceX:buffer/scan_elements/accel_type_available +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_type_available KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: If the type parameter can take one of a small set of values, this attribute lists them. -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/inY_index -What: /sys/.../deviceX:buffer/scan_elements/inY_supply_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_x_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_y_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/accel_z_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_x_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_y_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/gyro_z_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_x_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_y_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/magn_z_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/incli_x_index -What: /sys/bus/iio/devices/deviceX:buffer/scan_elements/incli_y_index -What: /sys/.../deviceX:buffer/scan_elements/timestamp_index +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_index +What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_index +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_x_index +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_y_index +What: /sys/.../iio:deviceX/buffer/scan_elements/accel_z_index +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_x_index +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_y_index +What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_z_index +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_x_index +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_y_index +What: /sys/.../iio:deviceX/buffer/scan_elements/magn_z_index +What: /sys/.../iio:deviceX/buffer/scan_elements/incli_x_index +What: /sys/.../iio:deviceX/buffer/scan_elements/incli_y_index +What: /sys/.../iio:deviceX/buffer/scan_elements/in_timestamp_index KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -705,7 +684,7 @@ Description: and the relevant _type attributes to establish the data storage format. -What: /sys/bus/iio/devices/deviceX/gyro_z_quadrature_correction_raw +What: /sys/.../iio:deviceX/gyro_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: linux-iio@xxxxxxxxxxxxxxx Description: From 5aa9618896e0ba49b444731f9fafa7f7c18a13ab Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:06 +0100 Subject: [PATCH 0774/1519] staging:iio: remove broken support for multiple event interfaces. We don't have a use case for these. Two drivers appeared to use them but both report all events on the first. V2: Remove now irrelevant comment. V3: Include fixup for adc/ad7280a.c Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq_core.c | 13 +- drivers/staging/iio/accel/sca3000_core.c | 9 +- drivers/staging/iio/adc/ad7150.c | 21 +-- drivers/staging/iio/adc/ad7280a.c | 9 +- drivers/staging/iio/adc/ad7291.c | 13 +- drivers/staging/iio/adc/ad7745.c | 5 +- drivers/staging/iio/adc/ad7816.c | 5 +- drivers/staging/iio/adc/ad799x_core.c | 4 +- drivers/staging/iio/adc/adt7310.c | 7 +- drivers/staging/iio/adc/adt7410.c | 7 +- drivers/staging/iio/adc/adt75.c | 3 +- drivers/staging/iio/adc/max1363_core.c | 4 +- drivers/staging/iio/addac/adt7316.c | 18 ++- drivers/staging/iio/dac/ad5504.c | 4 +- drivers/staging/iio/iio.h | 11 +- drivers/staging/iio/industrialio-core.c | 150 ++++++++++----------- drivers/staging/iio/light/tsl2563.c | 3 +- 17 files changed, 127 insertions(+), 159 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 440b26bff34..b57bf502950 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -452,7 +452,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) &t); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, @@ -461,7 +461,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, @@ -470,7 +470,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, @@ -479,7 +479,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, @@ -488,7 +488,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, @@ -497,7 +497,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, @@ -651,7 +651,6 @@ static const struct attribute_group lis3l02dq_attribute_group = { }; static const struct iio_info lis3l02dq_info = { - .num_interrupt_lines = 1, .read_raw = &lis3l02dq_read_raw, .write_raw = &lis3l02dq_write_raw, .read_event_value = &lis3l02dq_read_thresh, diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 1a6780f9c5a..449020054ee 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -815,7 +815,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) sca3000_ring_int_process(val, indio_dev->ring); if (val & SCA3000_INT_STATUS_FREE_FALL) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X_AND_Y_AND_Z, @@ -824,7 +824,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) last_timestamp); if (val & SCA3000_INT_STATUS_Y_TRIGGER) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, @@ -833,7 +833,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) last_timestamp); if (val & SCA3000_INT_STATUS_X_TRIGGER) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, @@ -842,7 +842,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) last_timestamp); if (val & SCA3000_INT_STATUS_Z_TRIGGER) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, @@ -1103,7 +1103,6 @@ error_ret: static const struct iio_info sca3000_info = { .attrs = &sca3000_attribute_group, .read_raw = &sca3000_read_raw, - .num_interrupt_lines = 1, .event_attrs = &sca3000_event_attribute_group, .read_event_value = &sca3000_read_thresh, .write_event_value = &sca3000_write_thresh, diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 9fd108776d5..d70623c1048 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -653,30 +653,34 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) ad7150_i2c_read(chip, AD7150_STATUS, &int_status, 1); - if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1)) - iio_push_event(indio_dev, 0, + if ((int_status & AD7150_STATUS_OUT1) && + !(chip->old_state & AD7150_STATUS_OUT1)) + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); - else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1)) - iio_push_event(indio_dev, 0, + else if ((!(int_status & AD7150_STATUS_OUT1)) && + (chip->old_state & AD7150_STATUS_OUT1)) + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); - if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2)) - iio_push_event(indio_dev, 0, + if ((int_status & AD7150_STATUS_OUT2) && + !(chip->old_state & AD7150_STATUS_OUT2)) + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); - else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2)) - iio_push_event(indio_dev, 0, + else if ((!(int_status & AD7150_STATUS_OUT2)) && + (chip->old_state & AD7150_STATUS_OUT2)) + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, @@ -705,7 +709,6 @@ static struct attribute_group ad7150_event_attribute_group = { static const struct iio_info ad7150_info = { .attrs = &ad7150_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &ad7150_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index ab6cf9cb5a7..bdc325dcb5b 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -691,7 +691,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) { if (((channels[i] >> 11) & 0xFFF) >= st->cell_threshhigh) - iio_push_event(dev_info, 0, + iio_push_event(dev_info, IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, 0, IIO_EV_TYPE_THRESH, @@ -699,7 +699,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->cell_threshlow) - iio_push_event(dev_info, 0, + iio_push_event(dev_info, IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, 0, IIO_EV_TYPE_THRESH, @@ -707,7 +707,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); } else { if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) - iio_push_event(dev_info, 0, + iio_push_event(dev_info, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -715,7 +715,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->aux_threshlow) - iio_push_event(dev_info, 0, + iio_push_event(dev_info, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -809,7 +809,6 @@ static int ad7280_read_raw(struct iio_dev *dev_info, static const struct iio_info ad7280_info = { .read_raw = &ad7280_read_raw, - .num_interrupt_lines = 1, .event_attrs = &ad7280_event_attrs_group, .attrs = &ad7280_attrs_group, .driver_module = THIS_MODULE, diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index e884c78d804..ac7c04ea4a2 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -479,28 +479,28 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) ad7291_i2c_write(chip, AD7291_COMMAND, command); if (t_status & (1 << 0)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t_status & (1 << 1)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t_status & (1 << 2)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t_status & (1 << 3)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -509,14 +509,14 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) { if (v_status & (1 << i)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, i/2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (v_status & (1 << (i + 1))) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, i/2, IIO_EV_TYPE_THRESH, @@ -780,7 +780,6 @@ static struct attribute_group ad7291_event_attribute_group = { static const struct iio_info ad7291_info = { .attrs = &ad7291_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &ad7291_event_attribute_group, }; diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 414e6dd0d1d..41150c60c20 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -540,12 +540,12 @@ static irqreturn_t ad774x_event_handler(int irq, void *private) ad774x_i2c_read(chip, AD774X_STATUS, &int_status, 1); if (int_status & AD774X_STATUS_RDYCAP) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_EVENT_CODE_CAP_RDY, iio_get_time_ns()); if (int_status & AD774X_STATUS_RDYVT) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_EVENT_CODE_VT_RDY, iio_get_time_ns()); @@ -569,7 +569,6 @@ static struct attribute_group ad774x_event_attribute_group = { static const struct iio_info ad774x_info = { .attrs = &ad774x_event_attribute_group, .event_attrs = &ad774x_event_attribute_group, - .num_interrupt_lines = 1, .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 8104ef47045..2706de30bc8 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -254,9 +254,7 @@ static const struct attribute_group ad7816_attribute_group = { static irqreturn_t ad7816_event_handler(int irq, void *private) { - iio_push_event(private, 0, - IIO_EVENT_CODE_AD7816_OTI, - iio_get_time_ns()); + iio_push_event(private, IIO_EVENT_CODE_AD7816_OTI, iio_get_time_ns()); return IRQ_HANDLED; } @@ -334,7 +332,6 @@ static struct attribute_group ad7816_event_attribute_group = { static const struct iio_info ad7816_info = { .attrs = &ad7816_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &ad7816_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index ba6d4ed0d60..b21e8688afd 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -334,7 +334,7 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) for (i = 0; i < 8; i++) { if (status & (1 << i)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, i & 0x1 ? IIO_UNMOD_EVENT_CODE(IIO_IN, (i >> 1), @@ -474,14 +474,12 @@ static const struct iio_info ad7991_info = { static const struct iio_info ad7992_info = { .read_raw = &ad799x_read_raw, - .num_interrupt_lines = 1, .event_attrs = &ad7992_event_attrs_group, .driver_module = THIS_MODULE, }; static const struct iio_info ad7993_4_7_8_info = { .read_raw = &ad799x_read_raw, - .num_interrupt_lines = 1, .event_attrs = &ad7993_4_7_8_event_attrs_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index b55066f0b23..e002e979035 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -400,19 +400,19 @@ static irqreturn_t adt7310_event_handler(int irq, void *private) return ret; if (status & ADT7310_STAT_T_HIGH) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (status & ADT7310_STAT_T_LOW) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (status & ADT7310_STAT_T_CRIT) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -750,7 +750,6 @@ static struct attribute_group adt7310_event_attribute_group[ADT7310_IRQS] = { static const struct iio_info adt7310_info = { .attrs = &adt7310_attribute_group, - .num_interrupt_lines = ADT7310_IRQS, .event_attrs = adt7310_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index 2e56ae866dd..e7e9e25d1e9 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -366,19 +366,19 @@ static irqreturn_t adt7410_event_handler(int irq, void *private) return IRQ_HANDLED; if (status & ADT7410_STAT_T_HIGH) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (status & ADT7410_STAT_T_LOW) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (status & ADT7410_STAT_T_CRIT) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -717,7 +717,6 @@ static struct attribute_group adt7410_event_attribute_group[ADT7410_IRQS] = { static const struct iio_info adt7410_info = { .attrs = &adt7410_attribute_group, - .num_interrupt_lines = ADT7410_IRQS, .event_attrs = adt7410_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index 66c50001d8c..440c7994659 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -265,7 +265,7 @@ static const struct attribute_group adt75_attribute_group = { static irqreturn_t adt75_event_handler(int irq, void *private) { - iio_push_event(private, 0, + iio_push_event(private, IIO_EVENT_CODE_ADT75_OTI, iio_get_time_ns()); @@ -535,7 +535,6 @@ static struct attribute_group adt75_event_attribute_group = { static const struct iio_info adt75_info = { .attrs = &adt75_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &adt75_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 53b745143ae..85fb74bf0ea 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -615,8 +615,7 @@ static irqreturn_t max1363_event_handler(int irq, void *private) i2c_master_recv(st->client, &rx, 1); mask = rx; for_each_set_bit(loc, &mask, 8) - iio_push_event(indio_dev, 0, max1363_event_codes[loc], - timestamp); + iio_push_event(indio_dev, max1363_event_codes[loc], timestamp); i2c_master_send(st->client, tx, 2); return IRQ_HANDLED; @@ -845,7 +844,6 @@ static const struct iio_info max1363_info = { .write_event_config = &max1363_write_event_config, .read_raw = &max1363_read_raw, .driver_module = THIS_MODULE, - .num_interrupt_lines = 1, .event_attrs = &max1363_event_attribute_group, }; diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dca43a7af28..0cb30915c00 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1777,43 +1777,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) time = iio_get_time_ns(); if (stat1 & (1 << 0)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), time); if (stat1 & (1 << 1)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), time); if (stat1 & (1 << 2)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), time); if (stat1 & (1 << 3)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), time); if (stat1 & (1 << 5)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); if (stat1 & (1 << 6)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); if (stat1 & (1 << 7)) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), @@ -1822,7 +1822,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2); if (!ret) { if (stat2 & ADT7316_INT_MASK2_VDD) - iio_push_event(indio_dev, 0, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, @@ -2110,14 +2110,12 @@ EXPORT_SYMBOL(adt7316_enable); static const struct iio_info adt7316_info = { .attrs = &adt7316_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &adt7316_event_attribute_group, .driver_module = THIS_MODULE, }; static const struct iio_info adt7516_info = { .attrs = &adt7516_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &adt7516_event_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 5fb210652af..9a421f2aceb 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -252,7 +252,7 @@ static struct attribute_group ad5504_ev_attribute_group = { static irqreturn_t ad5504_event_handler(int irq, void *private) { - iio_push_event(private, 0, + iio_push_event(private, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -264,14 +264,12 @@ static irqreturn_t ad5504_event_handler(int irq, void *private) static const struct iio_info ad5504_info = { .attrs = &ad5504_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &ad5504_ev_attribute_group, .driver_module = THIS_MODULE, }; static const struct iio_info ad5501_info = { .attrs = &ad5501_attribute_group, - .num_interrupt_lines = 1, .event_attrs = &ad5504_ev_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 239219b9949..098d827a790 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -183,7 +183,6 @@ struct iio_dev; * struct iio_info - constant information about device * @driver_module: module structure used to ensure correct * ownership of chrdevs etc - * @num_interrupt_lines:number of physical interrupt lines from device * @event_attrs: event control attributes * @attrs: general purpose device attributes * @read_raw: function to request a value from the device. @@ -207,7 +206,6 @@ struct iio_dev; **/ struct iio_info { struct module *driver_module; - int num_interrupt_lines; struct attribute_group *event_attrs; const struct attribute_group *attrs; @@ -252,7 +250,7 @@ struct iio_info { * @currentmode: [DRIVER] current operating mode * @dev: [DRIVER] device structure, should be assigned a parent * and owner - * @event_interfaces: [INTERN] event chrdevs associated with interrupt lines + * @event_interface: [INTERN] event chrdevs associated with interrupt lines * @ring: [DRIVER] any ring buffer present * @mlock: [INTERN] lock used to prevent simultaneous device state * changes @@ -272,7 +270,7 @@ struct iio_dev { int currentmode; struct device dev; - struct iio_event_interface *event_interfaces; + struct iio_event_interface *event_interface; struct iio_ring_buffer *ring; struct mutex mlock; @@ -309,10 +307,7 @@ void iio_device_unregister(struct iio_dev *dev_info); * @ev_code: What event * @timestamp: When the event occurred **/ -int iio_push_event(struct iio_dev *dev_info, - int ev_line, - int ev_code, - s64 timestamp); +int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); extern struct bus_type iio_bus_type; diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index de918782d3b..269a0f2bc3e 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -146,13 +146,9 @@ struct iio_event_interface { unsigned long flags; }; -int iio_push_event(struct iio_dev *dev_info, - int ev_line, - int ev_code, - s64 timestamp) +int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp) { - struct iio_event_interface *ev_int - = &dev_info->event_interfaces[ev_line]; + struct iio_event_interface *ev_int = dev_info->event_interface; struct iio_detected_event_list *ev; int ret = 0; @@ -291,19 +287,19 @@ static void iio_device_free_chrdev_minor(int val) static int iio_event_getfd(struct iio_dev *indio_dev) { - if (indio_dev->event_interfaces == NULL) + if (indio_dev->event_interface == NULL) return -ENODEV; - mutex_lock(&indio_dev->event_interfaces->event_list_lock); + mutex_lock(&indio_dev->event_interface->event_list_lock); if (test_and_set_bit(IIO_BUSY_BIT_POS, - &indio_dev->event_interfaces->flags)) { - mutex_unlock(&indio_dev->event_interfaces->event_list_lock); + &indio_dev->event_interface->flags)) { + mutex_unlock(&indio_dev->event_interface->event_list_lock); return -EBUSY; } - mutex_unlock(&indio_dev->event_interfaces->event_list_lock); + mutex_unlock(&indio_dev->event_interface->event_list_lock); return anon_inode_getfd("iio:event", &iio_event_chrdev_fileops, - &indio_dev->event_interfaces[0], O_RDONLY); + indio_dev->event_interface, O_RDONLY); } static void iio_setup_ev_int(struct iio_event_interface *ev_int) @@ -910,13 +906,9 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, &iio_ev_state_show, iio_ev_state_store, mask, - /*HACK. - limits us to one - event interface - fix by - extending the bitmask - but - how far*/ 0, &dev_info->dev, - &dev_info->event_interfaces[0]. + &dev_info->event_interface-> dev_attr_list); kfree(postfix); if (ret) @@ -935,8 +927,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, mask, 0, &dev_info->dev, - &dev_info->event_interfaces[0] - .dev_attr_list); + &dev_info->event_interface-> + dev_attr_list); kfree(postfix); if (ret) goto error_ret; @@ -947,12 +939,11 @@ error_ret: return ret; } -static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info, - int i) +static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info) { struct iio_dev_attr *p, *n; list_for_each_entry_safe(p, n, - &dev_info->event_interfaces[i]. + &dev_info->event_interface-> dev_attr_list, l) { sysfs_remove_file_from_group(&dev_info->dev.kobj, &p->dev_attr.attr, @@ -962,25 +953,23 @@ static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info, } } -static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info, int i) +static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info) { int j; int ret; - INIT_LIST_HEAD(&dev_info->event_interfaces[i].dev_attr_list); + INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list); /* Dynically created from the channels array */ - if (dev_info->channels) { - for (j = 0; j < dev_info->num_channels; j++) { - ret = iio_device_add_event_sysfs(dev_info, - &dev_info - ->channels[j]); - if (ret) - goto error_clear_attrs; - } + for (j = 0; j < dev_info->num_channels; j++) { + + ret = iio_device_add_event_sysfs(dev_info, + &dev_info->channels[j]); + if (ret) + goto error_clear_attrs; } return 0; error_clear_attrs: - __iio_remove_event_config_attrs(dev_info, i); + __iio_remove_event_config_attrs(dev_info); return ret; } @@ -994,42 +983,49 @@ static struct attribute_group iio_events_dummy_group = { .attrs = iio_events_dummy_attrs }; +static bool iio_check_for_dynamic_events(struct iio_dev *dev_info) +{ + int j; + for (j = 0; j < dev_info->num_channels; j++) + if (dev_info->channels[j].event_mask != 0) + return true; + return false; +} + static int iio_device_register_eventset(struct iio_dev *dev_info) { - int ret = 0, i, j; + int ret = 0; - if (dev_info->info->num_interrupt_lines == 0) + if (!(dev_info->info->event_attrs || + iio_check_for_dynamic_events(dev_info))) return 0; - dev_info->event_interfaces = - kzalloc(sizeof(struct iio_event_interface) - *dev_info->info->num_interrupt_lines, - GFP_KERNEL); - if (dev_info->event_interfaces == NULL) { + dev_info->event_interface = + kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL); + if (dev_info->event_interface == NULL) { ret = -ENOMEM; goto error_ret; } - for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { - iio_setup_ev_int(&dev_info->event_interfaces[i]); - if (dev_info->info->event_attrs != NULL) - ret = sysfs_create_group(&dev_info->dev.kobj, - &dev_info->info - ->event_attrs[i]); - else - ret = sysfs_create_group(&dev_info->dev.kobj, - &iio_events_dummy_group); - if (ret) { - dev_err(&dev_info->dev, - "Failed to register sysfs for event attrs"); - goto error_free_setup_event_lines; - } - ret = __iio_add_event_config_attrs(dev_info, i); + iio_setup_ev_int(dev_info->event_interface); + if (dev_info->info->event_attrs != NULL) + ret = sysfs_create_group(&dev_info->dev.kobj, + dev_info->info->event_attrs); + else + ret = sysfs_create_group(&dev_info->dev.kobj, + &iio_events_dummy_group); + if (ret) { + dev_err(&dev_info->dev, + "Failed to register sysfs for event attrs"); + goto error_free_setup_event_lines; + } + if (dev_info->channels) { + ret = __iio_add_event_config_attrs(dev_info); if (ret) { if (dev_info->info->event_attrs != NULL) sysfs_remove_group(&dev_info->dev.kobj, - &dev_info->info - ->event_attrs[i]); + dev_info->info + ->event_attrs); else sysfs_remove_group(&dev_info->dev.kobj, &iio_events_dummy_group); @@ -1040,16 +1036,14 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) return 0; error_free_setup_event_lines: - for (j = 0; j < i; j++) { - __iio_remove_event_config_attrs(dev_info, j); - if (dev_info->info->event_attrs != NULL) { - sysfs_remove_group(&dev_info->dev.kobj, - &dev_info->info->event_attrs[j]); - sysfs_remove_group(&dev_info->dev.kobj, - &iio_events_dummy_group); - } - } - kfree(dev_info->event_interfaces); + __iio_remove_event_config_attrs(dev_info); + if (dev_info->info->event_attrs != NULL) + sysfs_remove_group(&dev_info->dev.kobj, + dev_info->info->event_attrs); + else + sysfs_remove_group(&dev_info->dev.kobj, + &iio_events_dummy_group); + kfree(dev_info->event_interface); error_ret: return ret; @@ -1057,20 +1051,16 @@ error_ret: static void iio_device_unregister_eventset(struct iio_dev *dev_info) { - int i; - - if (dev_info->info->num_interrupt_lines == 0) + if (dev_info->event_interface == NULL) return; - for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { - __iio_remove_event_config_attrs(dev_info, i); - if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info->dev.kobj, - &dev_info->info->event_attrs[i]); - else - sysfs_remove_group(&dev_info->dev.kobj, - &iio_events_dummy_group); - } - kfree(dev_info->event_interfaces); + __iio_remove_event_config_attrs(dev_info); + if (dev_info->info->event_attrs != NULL) + sysfs_remove_group(&dev_info->dev.kobj, + dev_info->info->event_attrs); + else + sysfs_remove_group(&dev_info->dev.kobj, + &iio_events_dummy_group); + kfree(dev_info->event_interface); } static void iio_dev_release(struct device *device) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 665a7441b2e..60d21f3f060 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -595,7 +595,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) struct iio_dev *dev_info = private; struct tsl2563_chip *chip = iio_priv(dev_info); - iio_push_event(dev_info, 0, + iio_push_event(dev_info, IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, IIO_EV_TYPE_THRESH, @@ -680,7 +680,6 @@ static const struct iio_info tsl2563_info_no_irq = { static const struct iio_info tsl2563_info = { .driver_module = THIS_MODULE, - .num_interrupt_lines = 1, .read_raw = &tsl2563_read_raw, .write_raw = &tsl2563_write_raw, .read_event_value = &tsl2563_read_thresh, From 47c24fdd4253a2c8d730b978a186923b1af5e879 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:07 +0100 Subject: [PATCH 0775/1519] staging:iio: use ida_simple_get and ida_simple_remove + merge ids Use new simple ida allocation functions to remove some boilerplate code. Also, now we only have one chdev per device we don't need to maintain a separate ida for minor numbers. Just use the devices id. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 63 ++-------------------- drivers/staging/iio/industrialio-trigger.c | 48 +++-------------- 2 files changed, 12 insertions(+), 99 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 269a0f2bc3e..13f8c820f50 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -26,13 +26,8 @@ #include "iio_core.h" #include "iio_core_trigger.h" #include "chrdev.h" - -/* IDR to assign each registered device a unique id*/ +/* IDA to assign each registered device a unique id*/ static DEFINE_IDA(iio_ida); -/* IDR to allocate character device minor numbers */ -static DEFINE_IDA(iio_chrdev_ida); -/* Lock used to protect both of the above */ -static DEFINE_SPINLOCK(iio_ida_lock); static dev_t iio_devt; @@ -88,34 +83,6 @@ static const char * const iio_chan_info_postfix[] = { = "quadrature_correction_raw", }; -/* Return a negative errno on failure */ -static int iio_get_new_ida_val(struct ida *this_ida) -{ - int ret; - int val; - -ida_again: - if (unlikely(ida_pre_get(this_ida, GFP_KERNEL) == 0)) - return -ENOMEM; - - spin_lock(&iio_ida_lock); - ret = ida_get_new(this_ida, &val); - spin_unlock(&iio_ida_lock); - if (unlikely(ret == -EAGAIN)) - goto ida_again; - else if (unlikely(ret)) - return ret; - - return val; -} - -static void iio_free_ida_val(struct ida *this_ida, int id) -{ - spin_lock(&iio_ida_lock); - ida_remove(this_ida, id); - spin_unlock(&iio_ida_lock); -} - /** * struct iio_detected_event_list - list element for events that have occurred * @list: linked list header @@ -269,22 +236,6 @@ static const struct file_operations iio_event_chrdev_fileops = { .llseek = noop_llseek, }; -static int iio_device_get_chrdev_minor(void) -{ - int ret; - - ret = iio_get_new_ida_val(&iio_chrdev_ida); - if (ret < IIO_DEV_MAX) /* both errors and valid */ - return ret; - else - return -ENOMEM; -} - -static void iio_device_free_chrdev_minor(int val) -{ - iio_free_ida_val(&iio_chrdev_ida, val); -} - static int iio_event_getfd(struct iio_dev *indio_dev) { if (indio_dev->event_interface == NULL) @@ -1067,7 +1018,6 @@ static void iio_dev_release(struct device *device) { struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); cdev_del(&dev_info->chrdev); - iio_device_free_chrdev_minor(MINOR(device->devt)); iio_put(); kfree(dev_info); } @@ -1168,19 +1118,16 @@ int iio_device_register(struct iio_dev *dev_info) { int ret; - dev_info->id = iio_get_new_ida_val(&iio_ida); + dev_info->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); if (dev_info->id < 0) { ret = dev_info->id; dev_err(&dev_info->dev, "Failed to get id\n"); goto error_ret; } dev_set_name(&dev_info->dev, "iio:device%d", dev_info->id); - ret = iio_device_get_chrdev_minor(); - if (ret < 0) - goto error_free_ida; /* configure elements for the chrdev */ - dev_info->dev.devt = MKDEV(MAJOR(iio_devt), ret); + dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id); ret = device_add(&dev_info->dev); if (ret) @@ -1210,7 +1157,7 @@ error_free_sysfs: error_del_device: device_del(&dev_info->dev); error_free_ida: - iio_free_ida_val(&iio_ida, dev_info->id); + ida_simple_remove(&iio_ida, dev_info->id); error_ret: return ret; } @@ -1222,7 +1169,7 @@ void iio_device_unregister(struct iio_dev *dev_info) iio_device_unregister_trigger_consumer(dev_info); iio_device_unregister_eventset(dev_info); iio_device_unregister_sysfs(dev_info); - iio_free_ida_val(&iio_ida, dev_info->id); + ida_simple_remove(&iio_ida, dev_info->id); device_unregister(&dev_info->dev); } EXPORT_SYMBOL(iio_device_unregister); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index f1ece8619e8..b99d14e49e5 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -32,8 +32,7 @@ * Any other suggestions? */ -static DEFINE_IDR(iio_trigger_idr); -static DEFINE_SPINLOCK(iio_trigger_idr_lock); +static DEFINE_IDA(iio_trigger_ida); /* Single list of all available triggers */ static LIST_HEAD(iio_trigger_list); @@ -72,48 +71,15 @@ static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info) NULL); } - -/** - * iio_trigger_register_id() - get a unique id for this trigger - * @trig_info: the trigger - **/ -static int iio_trigger_register_id(struct iio_trigger *trig_info) -{ - int ret = 0; - -idr_again: - if (unlikely(idr_pre_get(&iio_trigger_idr, GFP_KERNEL) == 0)) - return -ENOMEM; - - spin_lock(&iio_trigger_idr_lock); - ret = idr_get_new(&iio_trigger_idr, NULL, &trig_info->id); - spin_unlock(&iio_trigger_idr_lock); - if (unlikely(ret == -EAGAIN)) - goto idr_again; - else if (likely(!ret)) - trig_info->id = trig_info->id & MAX_ID_MASK; - - return ret; -} - -/** - * iio_trigger_unregister_id() - free up unique id for use by another trigger - * @trig_info: the trigger - **/ -static void iio_trigger_unregister_id(struct iio_trigger *trig_info) -{ - spin_lock(&iio_trigger_idr_lock); - idr_remove(&iio_trigger_idr, trig_info->id); - spin_unlock(&iio_trigger_idr_lock); -} - int iio_trigger_register(struct iio_trigger *trig_info) { int ret; - ret = iio_trigger_register_id(trig_info); - if (ret) + trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); + if (trig_info->id < 0) { + ret = trig_info->id; goto error_ret; + } /* Set the name used for the sysfs directory etc */ dev_set_name(&trig_info->dev, "trigger%ld", (unsigned long) trig_info->id); @@ -136,7 +102,7 @@ int iio_trigger_register(struct iio_trigger *trig_info) error_device_del: device_del(&trig_info->dev); error_unregister_id: - iio_trigger_unregister_id(trig_info); + ida_simple_remove(&iio_trigger_ida, trig_info->id); error_ret: return ret; } @@ -149,7 +115,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) mutex_unlock(&iio_trigger_list_lock); iio_trigger_unregister_sysfs(trig_info); - iio_trigger_unregister_id(trig_info); + ida_simple_remove(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ device_unregister(&trig_info->dev); } From 9019309c2f32a4479c88047532552bdeea38585a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:08 +0100 Subject: [PATCH 0776/1519] staging:iio: remove defunct iio_put and iio_get. All iio dependent modules statically depend on industrialio so these aren't needed. Not sure why they originally existed, but they aren't now. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core.h | 10 ---------- drivers/staging/iio/industrialio-core.c | 17 +---------------- drivers/staging/iio/industrialio-trigger.c | 2 -- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index 433952bb843..edc295efc37 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -13,16 +13,6 @@ #ifndef _IIO_CORE_H_ #define _IIO_CORE_H_ -/** - * iio_put() - internal module reference count reduce - **/ -void iio_put(void); - -/** - * iio_get() - internal module reference count increase - **/ -void iio_get(void); - int __iio_add_chan_devattr(const char *postfix, const char *group, struct iio_chan_spec const *chan, diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 13f8c820f50..8b8e1fb5eda 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1018,7 +1018,6 @@ static void iio_dev_release(struct device *device) { struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); cdev_del(&dev_info->chrdev); - iio_put(); kfree(dev_info); } @@ -1048,7 +1047,6 @@ struct iio_dev *iio_allocate_device(int sizeof_priv) device_initialize(&dev->dev); dev_set_drvdata(&dev->dev, (void *)dev); mutex_init(&dev->mlock); - iio_get(); } return dev; @@ -1057,10 +1055,8 @@ EXPORT_SYMBOL(iio_allocate_device); void iio_free_device(struct iio_dev *dev) { - if (dev) { - iio_put(); + if (dev) kfree(dev); - } } EXPORT_SYMBOL(iio_free_device); @@ -1173,17 +1169,6 @@ void iio_device_unregister(struct iio_dev *dev_info) device_unregister(&dev_info->dev); } EXPORT_SYMBOL(iio_device_unregister); - -void iio_put(void) -{ - module_put(THIS_MODULE); -} - -void iio_get(void) -{ - __module_get(THIS_MODULE); -} - subsys_initcall(iio_init); module_exit(iio_exit); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index b99d14e49e5..3e60406d8f6 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -394,7 +394,6 @@ static void iio_trig_release(struct device *device) } kfree(trig->name); kfree(trig); - iio_put(); } static struct device_type iio_trig_type = { @@ -461,7 +460,6 @@ struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); } - iio_get(); get_device(&trig->dev); } return trig; From 36b6f4a7b647fcce0e1e578b1999f4a030be786c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:09 +0100 Subject: [PATCH 0777/1519] staging:iio: remove orphaned function definition. I have no idea what this was, or what it did, but it doesn't do it any more. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/ring_generic.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index db8d0d1469b..a63a9cb8112 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -211,8 +211,6 @@ int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, const struct iio_chan_spec *channels, int num_channels); -void iio_ring_access_release(struct device *dev); - /** * iio_ring_buffer_unregister() - unregister the buffer from IIO core * @indio_dev: the device with the buffer to be unregistered From cecfb931c87c52ae5fda842e4b5a74f1537d5f9d Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Tue, 30 Aug 2011 12:41:10 +0100 Subject: [PATCH 0778/1519] staging:iio: fix typo Signed-off-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index edc295efc37..d7eb0d81ee1 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -6,7 +6,7 @@ * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * - * These definitions are meant for use only within the IIO core, not indvidual + * These definitions are meant for use only within the IIO core, not individual * drivers. */ From 1e8dfcc6c3d36dabc77925104fc5769f79340be5 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:11 +0100 Subject: [PATCH 0779/1519] staging:iio:trivial add a string array for IIO_RAW and IIO_PROCESSED. Introduce IIO_RAW and IIO_PROCESSED and an array for their strings. Also move one function to just above where it is called. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 5 +++ drivers/staging/iio/industrialio-core.c | 57 ++++++++++++------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 098d827a790..1c24d138925 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -22,6 +22,11 @@ * Currently assumes nano seconds. */ +enum iio_data_type { + IIO_RAW, + IIO_PROCESSED, +}; + enum iio_chan_type { /* real channel types */ IIO_IN, diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 8b8e1fb5eda..e83d62609ec 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -37,6 +37,11 @@ struct bus_type iio_bus_type = { }; EXPORT_SYMBOL(iio_bus_type); +static const char * const iio_data_type_name[] = { + [IIO_RAW] = "raw", + [IIO_PROCESSED] = "input", +}; + static const char * const iio_chan_type_name_spec_shared[] = { [IIO_IN] = "in", [IIO_OUT] = "out", @@ -253,16 +258,6 @@ static int iio_event_getfd(struct iio_dev *indio_dev) indio_dev->event_interface, O_RDONLY); } -static void iio_setup_ev_int(struct iio_event_interface *ev_int) -{ - mutex_init(&ev_int->event_list_lock); - /* discussion point - make this variable? */ - ev_int->max_events = 10; - ev_int->current_events = 0; - INIT_LIST_HEAD(&ev_int->det_events); - init_waitqueue_head(&ev_int->wait); -} - static int __init iio_init(void) { int ret; @@ -584,26 +579,18 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, { int ret, i; - if (chan->channel < 0) return 0; - if (chan->processed_val) - ret = __iio_add_chan_devattr("input", NULL, chan, - &iio_read_channel_info, - NULL, - 0, - 0, - &dev_info->dev, - &dev_info->channel_attr_list); - else - ret = __iio_add_chan_devattr("raw", NULL, chan, - &iio_read_channel_info, - (chan->type == IIO_OUT ? - &iio_write_channel_info : NULL), - 0, - 0, - &dev_info->dev, - &dev_info->channel_attr_list); + + ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val], + NULL, chan, + &iio_read_channel_info, + (chan->type == IIO_OUT ? + &iio_write_channel_info : NULL), + 0, + 0, + &dev_info->dev, + &dev_info->channel_attr_list); if (ret) goto error_ret; @@ -815,7 +802,6 @@ static ssize_t iio_ev_value_store(struct device *dev, static int iio_device_add_event_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret = 0, i, mask = 0; char *postfix; if (!chan->event_mask) @@ -908,10 +894,10 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info) { int j; int ret; + INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list); /* Dynically created from the channels array */ for (j = 0; j < dev_info->num_channels; j++) { - ret = iio_device_add_event_sysfs(dev_info, &dev_info->channels[j]); if (ret) @@ -937,12 +923,23 @@ static struct attribute_group iio_events_dummy_group = { static bool iio_check_for_dynamic_events(struct iio_dev *dev_info) { int j; + for (j = 0; j < dev_info->num_channels; j++) if (dev_info->channels[j].event_mask != 0) return true; return false; } +static void iio_setup_ev_int(struct iio_event_interface *ev_int) +{ + mutex_init(&ev_int->event_list_lock); + /* discussion point - make this variable? */ + ev_int->max_events = 10; + ev_int->current_events = 0; + INIT_LIST_HEAD(&ev_int->det_events); + init_waitqueue_head(&ev_int->wait); +} + static int iio_device_register_eventset(struct iio_dev *dev_info) { int ret = 0; From 1a25e5928e5ff7612087aab06c4130bf0ebe6592 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:12 +0100 Subject: [PATCH 0780/1519] staging:iio: struct iio_dev formatting cleanup and documentation fixes. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 1c24d138925..36a826e6e65 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -265,8 +265,10 @@ struct iio_info { * @channels: [DRIVER] channel specification structure table * @num_channels: [DRIVER] number of chanels specified in @channels. * @channel_attr_list: [INTERN] keep track of automatically created channel - * attributes. + * attributes * @name: [DRIVER] name of the device. + * @info: [DRIVER] callbacks and constant info from driver + * @chrdev: [INTERN] associated character device **/ struct iio_dev { int id; @@ -284,13 +286,13 @@ struct iio_dev { struct iio_trigger *trig; struct iio_poll_func *pollfunc; - struct iio_chan_spec const *channels; - int num_channels; + struct iio_chan_spec const *channels; + int num_channels; - struct list_head channel_attr_list; - const char *name; - const struct iio_info *info; - struct cdev chrdev; + struct list_head channel_attr_list; + const char *name; + const struct iio_info *info; + struct cdev chrdev; }; /** @@ -308,11 +310,10 @@ void iio_device_unregister(struct iio_dev *dev_info); /** * iio_push_event() - try to add event to the list for userspace reading * @dev_info: IIO device structure - * @ev_line: Which event line (hardware interrupt) * @ev_code: What event * @timestamp: When the event occurred **/ -int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); +int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); extern struct bus_type iio_bus_type; From 6446e9cd2c1658f0afe856dfbe0b4623db39fb46 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:13 +0100 Subject: [PATCH 0781/1519] staging:iio:buffering drag some stray docs back to correct place. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/ring_generic.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index a63a9cb8112..37ab4dbc0c8 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -65,6 +65,13 @@ struct iio_ring_access_funcs { int (*enable)(struct iio_ring_buffer *ring); }; +/** + * struct iio_ring_setup_ops - buffer setup related callbacks + * @preenable: [DRIVER] function to run prior to marking ring enabled + * @postenable: [DRIVER] function to run after marking ring enabled + * @predisable: [DRIVER] function to run prior to marking ring disabled + * @postdisable: [DRIVER] function to run after marking ring disabled + */ struct iio_ring_setup_ops { int (*preenable)(struct iio_dev *); int (*postenable)(struct iio_dev *); @@ -87,10 +94,6 @@ struct iio_ring_setup_ops { * @scan_timestamp: [INTERN] does the scan mode include a timestamp * @access: [DRIVER] ring access functions associated with the * implementation. - * @preenable: [DRIVER] function to run prior to marking ring enabled - * @postenable: [DRIVER] function to run after marking ring enabled - * @predisable: [DRIVER] function to run prior to marking ring disabled - * @postdisable: [DRIVER] function to run after marking ring disabled * @flags: [INTERN] file ops related flags including busy flag. **/ struct iio_ring_buffer { From c009f7e42617bd52b61a35de621cd1deda08042b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:14 +0100 Subject: [PATCH 0782/1519] staging:iio:buffering cleanup ring_buffer_register_ex naming. Now the old method is long gone, lets get rid of the _ex and whilst here remove the unused id parameter. Trivial mechanical change, but will break any out of tree drivers using this. V2: rebase V3: rebase Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 6 +++--- drivers/staging/iio/accel/adis16203_core.c | 6 +++--- drivers/staging/iio/accel/adis16204_core.c | 6 +++--- drivers/staging/iio/accel/adis16209_core.c | 6 +++--- drivers/staging/iio/accel/adis16240_core.c | 6 +++--- drivers/staging/iio/accel/lis3l02dq_core.c | 6 +++--- drivers/staging/iio/accel/sca3000_core.c | 6 +++--- drivers/staging/iio/adc/ad7192.c | 6 +++--- drivers/staging/iio/adc/ad7298_core.c | 6 +++--- drivers/staging/iio/adc/ad7476_core.c | 6 +++--- drivers/staging/iio/adc/ad7606_core.c | 6 +++--- drivers/staging/iio/adc/ad7793.c | 6 +++--- drivers/staging/iio/adc/ad7887_core.c | 6 +++--- drivers/staging/iio/adc/ad799x_core.c | 6 +++--- drivers/staging/iio/adc/max1363_core.c | 6 +++--- drivers/staging/iio/gyro/adis16260_core.c | 6 +++--- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- drivers/staging/iio/imu/adis16400_core.c | 6 +++--- drivers/staging/iio/industrialio-ring.c | 8 ++++---- drivers/staging/iio/meter/ade7758_core.c | 6 +++--- drivers/staging/iio/ring_generic.h | 16 +++++++--------- 21 files changed, 66 insertions(+), 68 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index d16c45959fd..30ac7e2ee02 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -497,9 +497,9 @@ static int __devinit adis16201_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - adis16201_channels, - ARRAY_SIZE(adis16201_channels)); + ret = iio_ring_buffer_register(indio_dev, + adis16201_channels, + ARRAY_SIZE(adis16201_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index cc3869bbf46..dc52462ecf3 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -451,9 +451,9 @@ static int __devinit adis16203_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - adis16203_channels, - ARRAY_SIZE(adis16203_channels)); + ret = iio_ring_buffer_register(indio_dev, + adis16203_channels, + ARRAY_SIZE(adis16203_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 3cc229d9564..dedccddeb58 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -526,9 +526,9 @@ static int __devinit adis16204_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - adis16204_channels, - ARRAY_SIZE(adis16204_channels)); + ret = iio_ring_buffer_register(indio_dev, + adis16204_channels, + ARRAY_SIZE(adis16204_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index fa4c6c055db..d8f4b27efc7 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -499,9 +499,9 @@ static int __devinit adis16209_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - adis16209_channels, - ARRAY_SIZE(adis16209_channels)); + ret = iio_ring_buffer_register(indio_dev, + adis16209_channels, + ARRAY_SIZE(adis16209_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 2c6ced0366d..f6fa0ba4973 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -552,9 +552,9 @@ static int __devinit adis16240_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - adis16240_channels, - ARRAY_SIZE(adis16240_channels)); + ret = iio_ring_buffer_register(indio_dev, + adis16240_channels, + ARRAY_SIZE(adis16240_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index b57bf502950..ed07538d100 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -695,9 +695,9 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - lis3l02dq_channels, - ARRAY_SIZE(lis3l02dq_channels)); + ret = iio_ring_buffer_register(indio_dev, + lis3l02dq_channels, + ARRAY_SIZE(lis3l02dq_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 449020054ee..8281d66132d 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1156,9 +1156,9 @@ static int __devinit sca3000_probe(struct spi_device *spi) if (ret < 0) goto error_free_dev; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - sca3000_channels, - ARRAY_SIZE(sca3000_channels)); + ret = iio_ring_buffer_register(indio_dev, + sca3000_channels, + ARRAY_SIZE(sca3000_channels)); if (ret < 0) goto error_unregister_dev; if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 6e1656e44e3..80b067c5b21 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -1098,9 +1098,9 @@ static int __devinit ad7192_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_remove_trigger; diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 9c50b022d10..6487359dc4c 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -223,9 +223,9 @@ static int __devinit ad7298_probe(struct spi_device *spi) goto error_disable_reg; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - &ad7298_channels[1], /* skip temp0 */ - ARRAY_SIZE(ad7298_channels) - 1); + ret = iio_ring_buffer_register(indio_dev, + &ad7298_channels[1], /* skip temp0 */ + ARRAY_SIZE(ad7298_channels) - 1); if (ret) goto error_cleanup_ring; diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index bea9e82057f..f0393d59cca 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -186,9 +186,9 @@ static int __devinit ad7476_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - st->chip_info->channel, - ARRAY_SIZE(st->chip_info->channel)); + ret = iio_ring_buffer_register(indio_dev, + st->chip_info->channel, + ARRAY_SIZE(st->chip_info->channel)); if (ret) goto error_cleanup_ring; return 0; diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 7aef4d5188f..7b43da93d77 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -506,9 +506,9 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, goto error_free_irq; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index ed993e34908..38095eba099 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -895,9 +895,9 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_remove_trigger; diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 184ead17afc..e71d0884901 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -194,9 +194,9 @@ static int __devinit ad7887_probe(struct spi_device *spi) goto error_disable_reg; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; return 0; diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index b21e8688afd..299183c05d4 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -706,9 +706,9 @@ static int __devinit ad799x_probe(struct i2c_client *client, goto error_cleanup_ring; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 85fb74bf0ea..e921efa7196 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1313,9 +1313,9 @@ static int __devinit max1363_probe(struct i2c_client *client, if (ret) goto error_cleanup_ring; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - st->chip_info->channels, - st->chip_info->num_channels); + ret = iio_ring_buffer_register(indio_dev, + st->chip_info->channels, + st->chip_info->num_channels); if (ret) goto error_cleanup_ring; diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 5541cdda176..ed3b6db21f1 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -629,9 +629,9 @@ static int __devinit adis16260_probe(struct spi_device *spi) if (ret) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - indio_dev->channels, - ARRAY_SIZE(adis16260_channels_x)); + ret = iio_ring_buffer_register(indio_dev, + indio_dev->channels, + ARRAY_SIZE(adis16260_channels_x)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 8668291ffdc..1c1cd8eac9d 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -733,7 +733,7 @@ static int __devinit ad5933_probe(struct i2c_client *client, regdone = 1; /* skip temp0_input, register in0_(real|imag)_raw */ - ret = iio_ring_buffer_register_ex(indio_dev, 0, &ad5933_channels[1], 2); + ret = iio_ring_buffer_register(indio_dev, &ad5933_channels[1], 2); if (ret) goto error_unreg_ring; diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 21c1a0768d6..3e8fcd3354f 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -853,9 +853,9 @@ static int __devinit adis16400_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - st->variant->channels, - st->variant->num_channels); + ret = iio_ring_buffer_register(indio_dev, + st->variant->channels, + st->variant->num_channels); if (ret) { dev_err(&spi->dev, "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 1607293b036..947f5425ed7 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -277,9 +277,9 @@ static void __iio_ring_attr_cleanup(struct iio_dev *indio_dev) &iio_scan_el_dummy_group); } -int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, - const struct iio_chan_spec *channels, - int num_channels) +int iio_ring_buffer_register(struct iio_dev *indio_dev, + const struct iio_chan_spec *channels, + int num_channels) { struct iio_ring_buffer *ring = indio_dev->ring; int ret, i; @@ -325,7 +325,7 @@ error_cleanup_dynamic: error_ret: return ret; } -EXPORT_SYMBOL(iio_ring_buffer_register_ex); +EXPORT_SYMBOL(iio_ring_buffer_register); void iio_ring_buffer_unregister(struct iio_dev *indio_dev) { diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 92c6dcc4f73..77bd2761f27 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -780,9 +780,9 @@ static int __devinit ade7758_probe(struct spi_device *spi) goto error_unreg_ring_funcs; regdone = 1; - ret = iio_ring_buffer_register_ex(indio_dev, 0, - &ade7758_channels[0], - ARRAY_SIZE(ade7758_channels)); + ret = iio_ring_buffer_register(indio_dev, + &ade7758_channels[0], + ARRAY_SIZE(ade7758_channels)); if (ret) { dev_err(&spi->dev, "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 37ab4dbc0c8..25aacf3b893 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -206,13 +206,12 @@ static inline int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) container_of(d, struct iio_ring_buffer, dev) /** - * iio_ring_buffer_register_ex() - register the buffer with IIO core + * iio_ring_buffer_register() - register the buffer with IIO core * @indio_dev: device with the buffer to be registered - * @id: the id of the buffer (typically 0) **/ -int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, int id, - const struct iio_chan_spec *channels, - int num_channels); +int iio_ring_buffer_register(struct iio_dev *indio_dev, + const struct iio_chan_spec *channels, + int num_channels); /** * iio_ring_buffer_unregister() - unregister the buffer from IIO core @@ -265,10 +264,9 @@ int iio_sw_ring_preenable(struct iio_dev *indio_dev); #else /* CONFIG_IIO_RING_BUFFER */ -static inline int iio_ring_buffer_register_ex(struct iio_dev *indio_dev, - int id, - struct iio_chan_spec *channels, - int num_channels) +static inline int iio_ring_buffer_register(struct iio_dev *indio_dev, + struct iio_chan_spec *channels, + int num_channels) { return 0; } From 9dd1cb303c18f4508abc69f5b40f423ff36a9626 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:15 +0100 Subject: [PATCH 0783/1519] staging:iio: push "sysfs.h" and linux/irq.h out of iio.h These are no longer needed. Requires a few driver updates for places "sysfs.h" should have been present but wasn't. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/max517.c | 1 + drivers/staging/iio/iio.h | 2 -- drivers/staging/iio/industrialio-core.c | 2 ++ drivers/staging/iio/industrialio-ring.c | 1 + drivers/staging/iio/light/isl29018.c | 2 +- drivers/staging/iio/light/tsl2563.c | 1 + drivers/staging/iio/magnetometer/ak8975.c | 2 +- 7 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c index ed5d351b238..d54262ff0cd 100644 --- a/drivers/staging/iio/dac/max517.c +++ b/drivers/staging/iio/dac/max517.c @@ -26,6 +26,7 @@ #include #include "../iio.h" +#include "../sysfs.h" #include "dac.h" #include "max517.h" diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 36a826e6e65..6b896a511de 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -13,8 +13,6 @@ #include #include -#include -#include "sysfs.h" /* IIO TODO LIST */ /* diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index e83d62609ec..f59a603713c 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -26,6 +26,8 @@ #include "iio_core.h" #include "iio_core_trigger.h" #include "chrdev.h" +#include "sysfs.h" + /* IDA to assign each registered device a unique id*/ static DEFINE_IDA(iio_ida); diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 947f5425ed7..e844246bc32 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -22,6 +22,7 @@ #include "iio.h" #include "iio_core.h" +#include "sysfs.h" #include "ring_generic.h" diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index da5bb33a66c..f31e8c2fc5b 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -28,7 +28,7 @@ #include #include #include "../iio.h" - +#include "../sysfs.h" #define CONVERSION_TIME_MS 100 #define ISL29018_REG_ADD_COMMAND1 0x00 diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 60d21f3f060..bd879ad836a 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -38,6 +38,7 @@ #include #include "../iio.h" +#include "../sysfs.h" #include "tsl2563.h" /* Use this many bits for fraction part. */ diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index a17fa9f6a30..43936cb4381 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -31,7 +31,7 @@ #include #include "../iio.h" - +#include "../sysfs.h" /* * Register definitions, as well as various shifts and masks to get at the * individual fields of the registers. From 799390611daeabfdbee7a05891ad0c864c02a5e0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:16 +0100 Subject: [PATCH 0784/1519] staging:iio:light:tsl2563 remove use of IIO_CHAN macro and make use modifier defines. This avoids issues in the new event code introduced shortly + makes moving this one out of staging easier. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2563.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index bd879ad836a..3493d93e0eb 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -528,16 +528,26 @@ error_ret: return ret; } -#define INFO_MASK (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) -#define EVENT_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ - IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) -#define IIO_CHAN_2563(type, mod, proc, chan, imask, emask) \ - IIO_CHAN(type, mod, 1, proc, NULL, chan, 0, imask, 0, 0, {}, emask) - static const struct iio_chan_spec tsl2563_channels[] = { - IIO_CHAN_2563(IIO_LIGHT, 0, 1, 0, 0, 0), - IIO_CHAN_2563(IIO_INTENSITY, 1, 0, 0, INFO_MASK, EVENT_MASK), - IIO_CHAN_2563(IIO_INTENSITY, 1, 0, 1, INFO_MASK, 0), + { + .type = IIO_LIGHT, + .indexed = 1, + .channel = 0, + }, { + .type = IIO_INTENSITY, + .modified = 1, + .channel2 = IIO_MOD_LIGHT_BOTH, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), + .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING)), + }, { + .type = IIO_INTENSITY, + .modified = 1, + .channel2 = IIO_MOD_LIGHT_BOTH, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), + } }; static int tsl2563_read_thresh(struct iio_dev *indio_dev, From acc131fa9f9d81b2a031ab1e7115856ba33e057d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:17 +0100 Subject: [PATCH 0785/1519] staging:iio:light:tsl2563 remove unused headers. Guessing this is some ancient cut and paste issue. Signed-off-by: Jonathan Cammeron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2563.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 3493d93e0eb..2d01738c3de 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -31,9 +31,7 @@ #include #include #include -#include #include -#include #include #include From 3e39440789adef103422ce201538b4da8745fe8e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:18 +0100 Subject: [PATCH 0786/1519] staging:iio:fix using iio_priv or iio_dev after iio_unregister_device This includes calling iio_free_device as that should only be called before the device has been registered. Also one case of iio_free_device being called on a registered device. This has been pulled out of the reworking attributes patch. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 2 +- drivers/staging/iio/accel/adis16203_core.c | 2 +- drivers/staging/iio/accel/adis16204_core.c | 2 +- drivers/staging/iio/accel/adis16209_core.c | 2 +- drivers/staging/iio/accel/adis16240_core.c | 2 +- drivers/staging/iio/adc/ad7291.c | 1 - drivers/staging/iio/adc/ad7314.c | 1 - drivers/staging/iio/adc/ad7816.c | 1 - drivers/staging/iio/adc/adt7310.c | 1 - drivers/staging/iio/adc/adt75.c | 1 - drivers/staging/iio/addac/adt7316.c | 1 - drivers/staging/iio/dac/ad5624r_spi.c | 6 +++--- drivers/staging/iio/gyro/adis16260_core.c | 2 +- drivers/staging/iio/magnetometer/ak8975.c | 1 - drivers/staging/iio/resolver/ad2s1210.c | 2 +- 15 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 30ac7e2ee02..1e19aba115e 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -538,8 +538,8 @@ static int adis16201_remove(struct spi_device *spi) adis16201_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16201_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index dc52462ecf3..2a658f0e788 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -492,8 +492,8 @@ static int adis16203_remove(struct spi_device *spi) adis16203_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16203_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index dedccddeb58..42a37bb0136 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -567,8 +567,8 @@ static int adis16204_remove(struct spi_device *spi) adis16204_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16204_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index d8f4b27efc7..d59a9e4803b 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -542,8 +542,8 @@ static int adis16209_remove(struct spi_device *spi) adis16209_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16209_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index f6fa0ba4973..b6504f1479b 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -596,8 +596,8 @@ static int adis16240_remove(struct spi_device *spi) adis16240_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16240_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index ac7c04ea4a2..16ddbdec912 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -857,7 +857,6 @@ static int __devexit ad7291_remove(struct i2c_client *client) if (client->irq) free_irq(client->irq, indio_dev); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7314.c b/drivers/staging/iio/adc/ad7314.c index e3d38dbd846..094a4ee971c 100644 --- a/drivers/staging/iio/adc/ad7314.c +++ b/drivers/staging/iio/adc/ad7314.c @@ -240,7 +240,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev) dev_set_drvdata(&spi_dev->dev, NULL); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 2706de30bc8..5a4586fbe14 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -443,7 +443,6 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev) gpio_free(chip->convert_pin); gpio_free(chip->rdwr_pin); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index e002e979035..edc65c517f6 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -864,7 +864,6 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev) if (spi_dev->irq) free_irq(spi_dev->irq, indio_dev); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index 440c7994659..b56bfcdb337 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -618,7 +618,6 @@ static int __devexit adt75_remove(struct i2c_client *client) if (client->irq) free_irq(client->irq, indio_dev); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 0cb30915c00..e60a9d65821 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2225,7 +2225,6 @@ int __devexit adt7316_remove(struct device *dev) if (chip->bus.irq) free_irq(chip->bus.irq, indio_dev); iio_device_unregister(indio_dev); - iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index 7303bb13901..c4bdf42d544 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -262,12 +262,12 @@ static int __devinit ad5624r_probe(struct spi_device *spi) indio_dev->info = &ad5624r_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); + ret = ad5624r_spi_write(spi, AD5624R_CMD_INTERNAL_REFER_SETUP, 0, + !!voltage_uv, 16); if (ret) goto error_free_dev; - ret = ad5624r_spi_write(spi, AD5624R_CMD_INTERNAL_REFER_SETUP, 0, - !!voltage_uv, 16); + ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index ed3b6db21f1..6ea6d58fd1c 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -677,8 +677,8 @@ static int adis16260_remove(struct spi_device *spi) adis16260_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); - iio_device_unregister(indio_dev); adis16260_unconfigure_ring(indio_dev); + iio_device_unregister(indio_dev); err_ret: return ret; diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 43936cb4381..0697ab3c422 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -547,7 +547,6 @@ static int ak8975_remove(struct i2c_client *client) int eoc_gpio = data->eoc_gpio; iio_device_unregister(indio_dev); - iio_free_device(indio_dev); if (eoc_gpio) gpio_free(eoc_gpio); diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index f8459e8e855..5e83227da4b 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -784,8 +784,8 @@ static int __devexit ad2s1210_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad2s1210_state *st = iio_priv(indio_dev); - iio_device_unregister(indio_dev); ad2s1210_free_gpios(st); + iio_device_unregister(indio_dev); return 0; } From 26a54797c1b0941021a40a5973098fc28fe53d12 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:19 +0100 Subject: [PATCH 0787/1519] staging:iio:various cleanup regulator use paths. No way iio_device_allocate or iio_device_unregister effected by regulators so copying tricks not needed. This is really about regularizing the layout of drivers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7476_core.c | 26 ++++----- drivers/staging/iio/dac/ad5624r_spi.c | 47 ++++++++------- drivers/staging/iio/dac/ad5686.c | 7 +-- drivers/staging/iio/dac/ad5791.c | 84 ++++++++++++--------------- 4 files changed, 75 insertions(+), 89 deletions(-) diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index f0393d59cca..7329b009a71 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -130,7 +130,6 @@ static int __devinit ad7476_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret, voltage_uv = 0; bool reg_done = false; - struct regulator *reg; indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -138,15 +137,14 @@ static int __devinit ad7476_probe(struct spi_device *spi) goto error_ret; } st = iio_priv(indio_dev); - reg = regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(reg)) { - ret = regulator_enable(reg); + st->reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(st->reg)) { + ret = regulator_enable(st->reg); if (ret) goto error_put_reg; - voltage_uv = regulator_get_voltage(reg); + voltage_uv = regulator_get_voltage(st->reg); } - st->reg = reg; st->chip_info = &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data]; @@ -197,11 +195,11 @@ error_cleanup_ring: ad7476_ring_cleanup(indio_dev); iio_device_unregister(indio_dev); error_disable_reg: - if (!IS_ERR(reg)) + if (!IS_ERR(st->reg)) regulator_disable(st->reg); error_put_reg: - if (!IS_ERR(reg)) - regulator_put(reg); + if (!IS_ERR(st->reg)) + regulator_put(st->reg); if (!reg_done) iio_free_device(indio_dev); error_ret: @@ -212,16 +210,14 @@ static int ad7476_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7476_state *st = iio_priv(indio_dev); - /* copy needed as st will have been freed */ - struct regulator *reg = st->reg; iio_ring_buffer_unregister(indio_dev); ad7476_ring_cleanup(indio_dev); - iio_device_unregister(indio_dev); - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index c4bdf42d544..0f1d431c6fa 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -228,24 +228,23 @@ static int __devinit ad5624r_probe(struct spi_device *spi) { struct ad5624r_state *st; struct iio_dev *indio_dev; - struct regulator *reg; int ret, voltage_uv = 0; - reg = regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(reg)) { - ret = regulator_enable(reg); - if (ret) - goto error_put_reg; - - voltage_uv = regulator_get_voltage(reg); - } indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { ret = -ENOMEM; - goto error_disable_reg; + goto error_ret; } st = iio_priv(indio_dev); - st->reg = reg; + st->reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(st->reg)) { + ret = regulator_enable(st->reg); + if (ret) + goto error_put_reg; + + voltage_uv = regulator_get_voltage(st->reg); + } + spi_set_drvdata(spi, indio_dev); st->chip_info = &ad5624r_chip_info_tbl[spi_get_device_id(spi)->driver_data]; @@ -265,22 +264,23 @@ static int __devinit ad5624r_probe(struct spi_device *spi) ret = ad5624r_spi_write(spi, AD5624R_CMD_INTERNAL_REFER_SETUP, 0, !!voltage_uv, 16); if (ret) - goto error_free_dev; + goto error_disable_reg; ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + goto error_disable_reg; return 0; -error_free_dev: - iio_free_device(indio_dev); + error_disable_reg: - if (!IS_ERR(reg)) - regulator_disable(reg); + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); error_put_reg: - if (!IS_ERR(reg)) - regulator_put(reg); + if (!IS_ERR(st->reg)) + regulator_put(st->reg); + iio_free_device(indio_dev); +error_ret: return ret; } @@ -289,13 +289,12 @@ static int __devexit ad5624r_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5624r_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; - iio_device_unregister(indio_dev); - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_device_unregister(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index ae71d3f87d6..6d7a33f5d03 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -452,11 +452,10 @@ static int __devexit ad5686_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5686_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 5c45d0fe816..5a5de973139 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -297,38 +297,37 @@ static int __devinit ad5791_probe(struct spi_device *spi) { struct ad5791_platform_data *pdata = spi->dev.platform_data; struct iio_dev *indio_dev; - struct regulator *reg_vdd, *reg_vss; struct ad5791_state *st; int ret, pos_voltage_uv = 0, neg_voltage_uv = 0; - reg_vdd = regulator_get(&spi->dev, "vdd"); - if (!IS_ERR(reg_vdd)) { - ret = regulator_enable(reg_vdd); - if (ret) - goto error_put_reg_pos; - - pos_voltage_uv = regulator_get_voltage(reg_vdd); - } - - reg_vss = regulator_get(&spi->dev, "vss"); - if (!IS_ERR(reg_vss)) { - ret = regulator_enable(reg_vss); - if (ret) - goto error_put_reg_neg; - - neg_voltage_uv = regulator_get_voltage(reg_vss); - } - indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { ret = -ENOMEM; - goto error_disable_reg_neg; + goto error_ret; } st = iio_priv(indio_dev); + st->reg_vdd = regulator_get(&spi->dev, "vdd"); + if (!IS_ERR(st->reg_vdd)) { + ret = regulator_enable(st->reg_vdd); + if (ret) + goto error_put_reg_pos; + + pos_voltage_uv = regulator_get_voltage(st->reg_vdd); + } + + st->reg_vss = regulator_get(&spi->dev, "vss"); + if (!IS_ERR(st->reg_vss)) { + ret = regulator_enable(st->reg_vss); + if (ret) + goto error_put_reg_neg; + + neg_voltage_uv = regulator_get_voltage(st->reg_vss); + } + st->pwr_down = true; st->spi = spi; - if (!IS_ERR(reg_vss) && !IS_ERR(reg_vdd)) + if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) st->vref_mv = (pos_voltage_uv - neg_voltage_uv) / 1000; else if (pdata) st->vref_mv = pdata->vref_pos_mv - pdata->vref_neg_mv; @@ -337,7 +336,7 @@ static int __devinit ad5791_probe(struct spi_device *spi) ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); if (ret) - goto error_free_dev; + goto error_disable_reg_neg; st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi)->driver_data]; @@ -350,10 +349,7 @@ static int __devinit ad5791_probe(struct spi_device *spi) ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl | AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); if (ret) - goto error_free_dev; - - st->reg_vdd = reg_vdd; - st->reg_vss = reg_vss; + goto error_disable_reg_neg; spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev; @@ -362,25 +358,24 @@ static int __devinit ad5791_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + goto error_disable_reg_neg; return 0; -error_free_dev: - iio_free_device(indio_dev); - error_disable_reg_neg: - if (!IS_ERR(reg_vss)) - regulator_disable(reg_vss); + if (!IS_ERR(st->reg_vss)) + regulator_disable(st->reg_vss); error_put_reg_neg: - if (!IS_ERR(reg_vss)) - regulator_put(reg_vss); + if (!IS_ERR(st->reg_vss)) + regulator_put(st->reg_vss); - if (!IS_ERR(reg_vdd)) - regulator_disable(reg_vdd); + if (!IS_ERR(st->reg_vdd)) + regulator_disable(st->reg_vdd); error_put_reg_pos: - if (!IS_ERR(reg_vdd)) - regulator_put(reg_vdd); + if (!IS_ERR(st->reg_vdd)) + regulator_put(st->reg_vdd); + iio_free_device(indio_dev); +error_ret: return ret; } @@ -389,20 +384,17 @@ static int __devexit ad5791_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5791_state *st = iio_priv(indio_dev); - struct regulator *reg_vdd = st->reg_vdd; - struct regulator *reg_vss = st->reg_vss; - - iio_device_unregister(indio_dev); if (!IS_ERR(st->reg_vdd)) { - regulator_disable(reg_vdd); - regulator_put(reg_vdd); + regulator_disable(st->reg_vdd); + regulator_put(st->reg_vdd); } if (!IS_ERR(st->reg_vss)) { - regulator_disable(reg_vss); - regulator_put(reg_vss); + regulator_disable(st->reg_vss); + regulator_put(st->reg_vss); } + iio_device_unregister(indio_dev); return 0; } From c6fc806247be874c2e6d9a9494489a0430f92718 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:34 +0100 Subject: [PATCH 0788/1519] staging:iio: ABI rework - add in_ or out_ prefix to channnels Also involves changing current inX outX to in_voltageX and out_voltageX V2: squash users of the IIO_CHAN_OUT macro and get rid of it. There are very few of these, so it is easier to fix them. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5686.c | 70 ++++++++----------------- drivers/staging/iio/iio.h | 14 +++-- drivers/staging/iio/industrialio-core.c | 29 ++++++---- 3 files changed, 49 insertions(+), 64 deletions(-) diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index 6d7a33f5d03..c32789f1c15 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -97,63 +97,35 @@ enum ad5686_supported_device_ids { ID_AD5685, ID_AD5686, }; - +#define AD5868_CHANNEL(chan, bits, shift) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .output = 1, \ + .channel = chan, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .address = AD5686_ADDR_DAC0, \ + .scan_type = IIO_ST('u', bits, 16, shift) \ +} static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { [ID_AD5684] = { - .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC0, - 0, IIO_ST('u', 12, 16, 4), 0), - .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC1, - 1, IIO_ST('u', 12, 16, 4), 0), - .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC2, - 2, IIO_ST('u', 12, 16, 4), 0), - .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC3, - 3, IIO_ST('u', 12, 16, 4), 0), + .channel[0] = AD5868_CHANNEL(0, 12, 4), + .channel[1] = AD5868_CHANNEL(1, 12, 4), + .channel[2] = AD5868_CHANNEL(2, 12, 4), + .channel[3] = AD5868_CHANNEL(3, 12, 4), .int_vref_mv = 2500, }, [ID_AD5685] = { - .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC0, - 0, IIO_ST('u', 14, 16, 2), 0), - .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC1, - 1, IIO_ST('u', 14, 16, 2), 0), - .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC2, - 2, IIO_ST('u', 14, 16, 2), 0), - .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC3, - 3, IIO_ST('u', 14, 16, 2), 0), + .channel[0] = AD5868_CHANNEL(0, 14, 2), + .channel[1] = AD5868_CHANNEL(1, 14, 2), + .channel[2] = AD5868_CHANNEL(2, 14, 2), + .channel[3] = AD5868_CHANNEL(3, 14, 2), .int_vref_mv = 2500, }, [ID_AD5686] = { - .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC0, - 0, IIO_ST('u', 16, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC1, - 1, IIO_ST('u', 16, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC2, - 2, IIO_ST('u', 16, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD5686_ADDR_DAC3, - 3, IIO_ST('u', 16, 16, 0), 0), + .channel[0] = AD5868_CHANNEL(0, 16, 0), + .channel[1] = AD5868_CHANNEL(1, 16, 0), + .channel[2] = AD5868_CHANNEL(2, 16, 0), + .channel[3] = AD5868_CHANNEL(3, 16, 0), .int_vref_mv = 2500, }, }; diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 6b896a511de..f42387052ce 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -27,12 +27,11 @@ enum iio_data_type { enum iio_chan_type { /* real channel types */ - IIO_IN, - IIO_OUT, + IIO_VOLTAGE, IIO_CURRENT, IIO_POWER, IIO_ACCEL, - IIO_IN_DIFF, + IIO_VOLTAGE_DIFF, IIO_GYRO, IIO_MAGN, IIO_LIGHT, @@ -45,6 +44,10 @@ enum iio_chan_type { IIO_TIMESTAMP, }; +/* Nasty hack to avoid massive churn */ +#define IIO_IN IIO_VOLTAGE +#define IIO_IN_DIFF IIO_VOLTAGE_DIFF + #define IIO_MOD_X 0 #define IIO_MOD_LIGHT_BOTH 0 #define IIO_MOD_Y 1 @@ -127,14 +130,17 @@ struct iio_chan_spec { unsigned processed_val:1; unsigned modified:1; unsigned indexed:1; + unsigned output:1; }; #define IIO_ST(si, rb, sb, sh) \ { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } -#define IIO_CHAN(_type, _mod, _indexed, _proc, _name, _chan, _chan2, \ +/* Macro assumes input channels */ +#define IIO_CHAN(_type, _mod, _indexed, _proc, _name, _chan, _chan2, \ _inf_mask, _address, _si, _stype, _event_mask) \ { .type = _type, \ + .output = 0, \ .modified = _mod, \ .indexed = _indexed, \ .processed_val = _proc, \ diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index f59a603713c..5717f1945f4 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -44,13 +44,17 @@ static const char * const iio_data_type_name[] = { [IIO_PROCESSED] = "input", }; +static const char * const iio_direction[] = { + [0] = "in", + [1] = "out", +}; + static const char * const iio_chan_type_name_spec_shared[] = { - [IIO_IN] = "in", - [IIO_OUT] = "out", + [IIO_VOLTAGE] = "voltage", [IIO_CURRENT] = "current", [IIO_POWER] = "power", [IIO_ACCEL] = "accel", - [IIO_IN_DIFF] = "in-in", + [IIO_VOLTAGE_DIFF] = "voltage-voltage", [IIO_GYRO] = "gyro", [IIO_MAGN] = "magn", [IIO_LIGHT] = "illuminance", @@ -64,7 +68,7 @@ static const char * const iio_chan_type_name_spec_shared[] = { }; static const char * const iio_chan_type_name_spec_complex[] = { - [IIO_IN_DIFF] = "in%d-in%d", + [IIO_VOLTAGE_DIFF] = "voltage%d-voltage%d", }; static const char * const iio_modifier_names_light[] = { @@ -462,19 +466,22 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, goto error_ret; /* Special case for types that uses both channel numbers in naming */ - if (chan->type == IIO_IN_DIFF && !generic) + if (chan->type == IIO_VOLTAGE_DIFF && !generic) name_format - = kasprintf(GFP_KERNEL, "%s_%s", + = kasprintf(GFP_KERNEL, "%s_%s_%s", + iio_direction[chan->output], iio_chan_type_name_spec_complex[chan->type], full_postfix); else if (generic || !chan->indexed) name_format - = kasprintf(GFP_KERNEL, "%s_%s", + = kasprintf(GFP_KERNEL, "%s_%s_%s", + iio_direction[chan->output], iio_chan_type_name_spec_shared[chan->type], full_postfix); else name_format - = kasprintf(GFP_KERNEL, "%s%d_%s", + = kasprintf(GFP_KERNEL, "%s_%s%d_%s", + iio_direction[chan->output], iio_chan_type_name_spec_shared[chan->type], chan->channel, full_postfix); @@ -587,7 +594,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val], NULL, chan, &iio_read_channel_info, - (chan->type == IIO_OUT ? + (chan->output ? &iio_write_channel_info : NULL), 0, 0, @@ -819,7 +826,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, } switch (chan->type) { /* Switch this to a table at some point */ - case IIO_IN: + case IIO_VOLTAGE: mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, i/IIO_EV_TYPE_MAX, i%IIO_EV_TYPE_MAX); @@ -829,7 +836,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, i/IIO_EV_TYPE_MAX, i%IIO_EV_TYPE_MAX); break; - case IIO_IN_DIFF: + case IIO_VOLTAGE_DIFF: mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel, chan->channel2, i/IIO_EV_TYPE_MAX, From a37b549ec61d892aa99744750e97d994bc779cb6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:35 +0100 Subject: [PATCH 0789/1519] staging:iio:Documentation sysfs-bus-iio add in and out prefixes Also includes the inX -> in_voltageX and outX -> out_voltageX conversions. To keep lines short quite a lot of supressing of directories was needed. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 536 +++++++++--------- 1 file changed, 268 insertions(+), 268 deletions(-) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index bed3bcb6b96..1d52c963cb3 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -83,8 +83,8 @@ Contact: linux-iio@vger.kernel.org Description: Hardware dependent values supported by the oversampling filter. -What: /sys/bus/iio/devices/iio:deviceX/inY_raw -What: /sys/bus/iio/devices/iio:deviceX/inY_supply_raw +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -94,7 +94,7 @@ Description: versions may be used. The number must always be specified and unique to allow association with event codes. -What: /sys/bus/iio/devices/iio:deviceX/inY-inZ_raw +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -104,10 +104,10 @@ Description: separately available. In differential only parts, then all that is required is a consistent labeling. -What: /sys/bus/iio/devices/iio:deviceX/temp_raw -What: /sys/bus/iio/devices/iio:deviceX/temp_x_raw -What: /sys/bus/iio/devices/iio:deviceX/temp_y_raw -What: /sys/bus/iio/devices/iio:deviceX/temp_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -116,15 +116,15 @@ Description: sensor is associated with one part of a compound device (e.g. a gyroscope axis). -What: /sys/bus/iio/devices/iio:deviceX/tempX_input +What: /sys/bus/iio/devices/iio:deviceX/in_tempX_input KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Scaled temperature measurement in milli degrees Celsius. -What: /sys/bus/iio/devices/iio:deviceX/accel_x_raw -What: /sys/bus/iio/devices/iio:deviceX/accel_y_raw -What: /sys/bus/iio/devices/iio:deviceX/accel_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -132,22 +132,22 @@ Description: but should match other such assignments on device) channel m (not present if only one accelerometer channel at this orientation). Has all of the equivalent parameters as per - inY. Units after application of scale and offset are m/s^2. + voltageY. Units after application of scale and offset are m/s^2. -What: /sys/bus/iio/devices/iio:deviceX/gyro_x_raw -What: /sys/bus/iio/devices/iio:deviceX/gyro_y_raw -What: /sys/bus/iio/devices/iio:deviceX/gyro_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Angular velocity about axis x, y or z (may be arbitrarily assigned) Data converted by application of offset then scale to radians per second. Has all the equivalent parameters as - per inY. + per voltageY. -What: /sys/bus/iio/devices/iio:deviceX/incli_x_raw -What: /sys/bus/iio/devices/iio:deviceX/incli_y_raw -What: /sys/bus/iio/devices/iio:deviceX/incli_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_incli_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_incli_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_incli_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -155,9 +155,9 @@ Description: arbitrarily assigned). Data converted by application of offset and scale to Degrees. -What: /sys/bus/iio/devices/iio:deviceX/magn_x_raw -What: /sys/bus/iio/devices/iio:deviceX/magn_y_raw -What: /sys/bus/iio/devices/iio:deviceX/magn_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -165,11 +165,11 @@ Description: assigned) channel m (not present if only one magnetometer at this orientation). Data converted by application of offset then scale to Gauss. Has all the equivalent modifiers - as per inY. + as per voltageY. -What: /sys/bus/iio/devices/iio:deviceX/accel_x_peak_raw -What: /sys/bus/iio/devices/iio:deviceX/accel_y_peak_raw -What: /sys/bus/iio/devices/iio:deviceX/accel_z_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_peak_raw KernelVersion: 2.6.36 Contact: linux-iio@vger.kernel.org Description: @@ -178,15 +178,15 @@ Description: and are otherwise the direct equivalent of the Y[_name]_raw attributes. -What: /sys/bus/iio/devices/iio:deviceX/accel_xyz_squared_peak_raw +What: /sys/bus/iio/devices/iio:deviceX/in_accel_xyz_squared_peak_raw KernelVersion: 2.6.36 Contact: linux-iio@vger.kernel.org Description: A computed peak value based on the sum squared magnitude of the underlying value in the specified directions. -What: /sys/bus/iio/devices/iio:deviceX/accel_offset -What: /sys/bus/iio/devices/iio:deviceX/temp_offset +What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset +What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -201,17 +201,17 @@ Description: for variation between different instances of the part, typically adjusted by using some hardware supported calibration procedure. -What: /sys/bus/iio/devices/iio:deviceX/inY_scale -What: /sys/bus/iio/devices/iio:deviceX/inY_supply_scale -What: /sys/bus/iio/devices/iio:deviceX/in_scale -What: /sys/bus/iio/devices/iio:deviceX/outY_scale -What: /sys/bus/iio/devices/iio:deviceX/accel_scale -What: /sys/bus/iio/devices/iio:deviceX/accel_peak_scale -What: /sys/bus/iio/devices/iio:deviceX/gyro_scale -What: /sys/bus/iio/devices/iio:deviceX/magn_scale -What: /sys/bus/iio/devices/iio:deviceX/magn_x_scale -What: /sys/bus/iio/devices/iio:deviceX/magn_y_scale -What: /sys/bus/iio/devices/iio:deviceX/magn_z_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale +What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_scale +What: /sys/bus/iio/devices/iio:deviceX/in_magn_scale +What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_scale +What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_scale +What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_scale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -223,12 +223,12 @@ Description: [Y][_name]_scale. The peak modifier means this value is applied to Y[_name]_peak_raw values. -What: /sys/bus/iio/devices/iio:deviceX/accel_x_calibbias -What: /sys/bus/iio/devices/iio:deviceX/accel_y_calibbias -What: /sys/bus/iio/devices/iio:deviceX/accel_z_calibbias -What: /sys/bus/iio/devices/iio:deviceX/gyro_x_calibbias -What: /sys/bus/iio/devices/iio:deviceX/gyro_y_calibbias -What: /sys/bus/iio/devices/iio:deviceX/gyro_z_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibbias KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -236,15 +236,15 @@ Description: inaccuracies). If shared across all channels, _calibbias is used. -What /sys/bus/iio/devices/iio:deviceX/inY_calibscale -What /sys/bus/iio/devices/iio:deviceX/inY_supply_calibscale -What /sys/bus/iio/devices/iio:deviceX/in_calibscale -What /sys/bus/iio/devices/iio:deviceX/accel_x_calibscale -What /sys/bus/iio/devices/iio:deviceX/accel_y_calibscale -What /sys/bus/iio/devices/iio:deviceX/accel_z_calibscale -What /sys/bus/iio/devices/iio:deviceX/gyro_x_calibscale -What /sys/bus/iio/devices/iio:deviceX/gyro_y_calibscale -What /sys/bus/iio/devices/iio:deviceX/gyro_z_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibscale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -252,14 +252,14 @@ Description: production inaccuracies). If shared across all channels, _calibscale is used. -What: /sys/bus/iio/devices/iio:deviceX/accel_scale_available +What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available KernelVersion: 2.635 Contact: linux-iio@vger.kernel.org Description: If a discrete set of scale values are available, they are listed in this attribute. -What: /sys/bus/iio/devices/iio:deviceX/outY_raw +What: /sys/bus/iio/devices/iio:deviceX/out_votlageY_raw KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -267,7 +267,7 @@ Description: channel Y. The number must always be specified and unique if the output corresponds to a single channel. -What: /sys/bus/iio/devices/iio:deviceX/outY&Z_raw +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY&Z_raw KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -276,8 +276,8 @@ Description: where a single output sets the value for multiple channels simultaneously. -What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown_mode -What: /sys/bus/iio/devices/iio:deviceX/out_powerdown_mode +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown_mode +What: /sys/bus/iio/devices/iio:deviceX/out_voltage_powerdown_mode KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: @@ -290,16 +290,16 @@ Description: outX_powerdown_mode_available. If Y is not present the mode is shared across all outputs. -What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown_mode_available -What: /sys/bus/iio/devices/iio:deviceX/out_powerdown_mode_available +What: /sys/.../iio:deviceX/out_votlageY_powerdown_mode_available +What: /sys/.../iio:deviceX/out_voltage_powerdown_mode_available KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: Lists all available output power down modes. If Y is not present the mode is shared across all outputs. -What: /sys/bus/iio/devices/iio:deviceX/outY_powerdown -What: /sys/bus/iio/devices/iio:deviceX/out_powerdown +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown +What: /sys/bus/iio/devices/iio:deviceX/out_voltage_powerdown KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: @@ -315,30 +315,30 @@ Description: Configuration of which hardware generated events are passed up to user-space. -What: /sys/.../iio:deviceX/events/accel_x_thresh_rising_en -What: /sys/.../iio:deviceX/events/accel_x_thresh_falling_en -What: /sys/.../iio:deviceX/events/accel_y_thresh_rising_en -What: /sys/.../iio:deviceX/events/accel_y_thresh_falling_en -What: /sys/.../iio:deviceX/events/accel_z_thresh_rising_en -What: /sys/.../iio:deviceX/events/accel_z_thresh_falling_en -What: /sys/.../iio:deviceX/events/gyro_x_thresh_rising_en -What: /sys/.../iio:deviceX/events/gyro_x_thresh_falling_en -What: /sys/.../iio:deviceX/events/gyro_y_thresh_rising_en -What: /sys/.../iio:deviceX/events/gyro_y_thresh_falling_en -What: /sys/.../iio:deviceX/events/gyro_z_thresh_rising_en -What: /sys/.../iio:deviceX/events/gyro_z_thresh_falling_en -What: /sys/.../iio:deviceX/events/magn_x_thresh_rising_en -What: /sys/.../iio:deviceX/events/magn_x_thresh_falling_en -What: /sys/.../iio:deviceX/events/magn_y_thresh_rising_en -What: /sys/.../iio:deviceX/events/magn_y_thresh_falling_en -What: /sys/.../iio:deviceX/events/magn_z_thresh_rising_en -What: /sys/.../iio:deviceX/events/magn_z_thresh_falling_en -What: /sys/.../iio:deviceX/events/inZ_supply_thresh_rising_en -What: /sys/.../iio:deviceX/events/inZ_supply_thresh_falling_en -What: /sys/.../iio:deviceX/events/inZ_thresh_rising_en -What: /sys/.../iio:deviceX/events/inZ_thresh_falling_en -What: /sys/.../iio:deviceX/events/temp_thresh_rising_en -What: /sys/.../iio:deviceX/events/temp_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_accel_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_accel_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_accel_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_accel_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_accel_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_accel_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_magn_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_magn_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_magn_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_magn_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_magn_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_magn_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_voltageZ_supply_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_voltageZ_supply_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_voltageZ_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_voltageZ_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_temp_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_temp_thresh_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -360,30 +360,30 @@ Description: a given event type is enabled a future point (and not those for whatever event was previously enabled). -What: /sys/.../iio:deviceX/events/accel_x_roc_rising_en -What: /sys/.../iio:deviceX/events/accel_x_roc_falling_en -What: /sys/.../iio:deviceX/events/accel_y_roc_rising_en -What: /sys/.../iio:deviceX/events/accel_y_roc_falling_en -What: /sys/.../iio:deviceX/events/accel_z_roc_rising_en -What: /sys/.../iio:deviceX/events/accel_z_roc_falling_en -What: /sys/.../iio:deviceX/events/gyro_x_roc_rising_en -What: /sys/.../iio:deviceX/events/gyro_x_roc_falling_en -What: /sys/.../iio:deviceX/events/gyro_y_roc_rising_en -What: /sys/.../iio:deviceX/events/gyro_y_roc_falling_en -What: /sys/.../iio:deviceX/events/gyro_z_roc_rising_en -What: /sys/.../iio:deviceX/events/gyro_z_roc_falling_en -What: /sys/.../iio:deviceX/events/magn_x_roc_rising_en -What: /sys/.../iio:deviceX/events/magn_x_roc_falling_en -What: /sys/.../iio:deviceX/events/magn_y_roc_rising_en -What: /sys/.../iio:deviceX/events/magn_y_roc_falling_en -What: /sys/.../iio:deviceX/events/magn_z_roc_rising_en -What: /sys/.../iio:deviceX/events/magn_z_roc_falling_en -What: /sys/.../iio:deviceX/events/inZ_supply_roc_rising_en -What: /sys/.../iio:deviceX/events/inZ_supply_roc_falling_en -What: /sys/.../iio:deviceX/events/inZ_roc_rising_en -What: /sys/.../iio:deviceX/events/inZ_roc_falling_en -What: /sys/.../iio:deviceX/events/temp_roc_rising_en -What: /sys/.../iio:deviceX/events/temp_roc_falling_en +What: /sys/.../iio:deviceX/events/in_accel_x_roc_rising_en +What: /sys/.../iio:deviceX/events/in_accel_x_roc_falling_en +What: /sys/.../iio:deviceX/events/in_accel_y_roc_rising_en +What: /sys/.../iio:deviceX/events/in_accel_y_roc_falling_en +What: /sys/.../iio:deviceX/events/in_accel_z_roc_rising_en +What: /sys/.../iio:deviceX/events/in_accel_z_roc_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_x_roc_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_x_roc_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_y_roc_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_y_roc_falling_en +What: /sys/.../iio:deviceX/events/in_gyro_z_roc_rising_en +What: /sys/.../iio:deviceX/events/in_gyro_z_roc_falling_en +What: /sys/.../iio:deviceX/events/in_magn_x_roc_rising_en +What: /sys/.../iio:deviceX/events/in_magn_x_roc_falling_en +What: /sys/.../iio:deviceX/events/in_magn_y_roc_rising_en +What: /sys/.../iio:deviceX/events/in_magn_y_roc_falling_en +What: /sys/.../iio:deviceX/events/in_magn_z_roc_rising_en +What: /sys/.../iio:deviceX/events/in_magn_z_roc_falling_en +What: /sys/.../iio:deviceX/events/in_voltageZ_supply_roc_rising_en +What: /sys/.../iio:deviceX/events/in_voltageZ_supply_roc_falling_en +What: /sys/.../iio:deviceX/events/in_voltageZ_roc_rising_en +What: /sys/.../iio:deviceX/events/in_voltageZ_roc_falling_en +What: /sys/.../iio:deviceX/events/in_temp_roc_rising_en +What: /sys/.../iio:deviceX/events/in_temp_roc_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -406,30 +406,30 @@ Description: a given event type is enabled a future point (and not those for whatever event was previously enabled). -What: /sys/.../iio:deviceX/events/accel_x_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/accel_x_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/accel_y_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/accel_y_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/accel_z_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/accel_z_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/gyro_x_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/gyro_x_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/gyro_y_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/gyro_y_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/gyro_z_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/gyro_z_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/magn_x_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/magn_x_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/magn_y_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/magn_y_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/magn_z_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/magn_z_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/inZ_supply_raw_thresh_rising_value -What: /sys/.../iio:deviceX/events/inZ_supply_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/inZ_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/inZ_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/temp_raw_thresh_falling_value -What: /sys/.../iio:deviceX/events/temp_raw_thresh_falling_value +What: /sys/.../events/in_accel_x_raw_thresh_rising_value +What: /sys/.../events/in_accel_x_raw_thresh_falling_value +What: /sys/.../events/in_accel_y_raw_thresh_rising_value +What: /sys/.../events/in_accel_y_raw_thresh_falling_value +What: /sys/.../events/in_accel_z_raw_thresh_rising_value +What: /sys/.../events/in_accel_z_raw_thresh_falling_value +What: /sys/.../events/in_gyro_x_raw_thresh_rising_value +What: /sys/.../events/in_gyro_x_raw_thresh_falling_value +What: /sys/.../events/in_gyro_y_raw_thresh_rising_value +What: /sys/.../events/in_gyro_y_raw_thresh_falling_value +What: /sys/.../events/in_gyro_z_raw_thresh_rising_value +What: /sys/.../events/in_gyro_z_raw_thresh_falling_value +What: /sys/.../events/in_magn_x_raw_thresh_rising_value +What: /sys/.../events/in_magn_x_raw_thresh_falling_value +What: /sys/.../events/in_magn_y_raw_thresh_rising_value +What: /sys/.../events/in_magn_y_raw_thresh_falling_value +What: /sys/.../events/in_magn_z_raw_thresh_rising_value +What: /sys/.../events/in_magn_z_raw_thresh_falling_value +What: /sys/.../events/in_voltageZ_supply_raw_thresh_rising_value +What: /sys/.../events/in_voltageZ_supply_raw_thresh_falling_value +What: /sys/.../events/in_voltageZ_raw_thresh_falling_value +What: /sys/.../events/in_voltageZ_raw_thresh_falling_value +What: /sys/.../events/in_temp_raw_thresh_falling_value +What: /sys/.../events/in_temp_raw_thresh_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -443,30 +443,30 @@ Description: value is in raw device units or in processed units (as _raw and _input do on sysfs direct channel read attributes). -What: /sys/.../iio:deviceX/events/accel_x_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/accel_x_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/accel_y_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/accel_y_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/accel_z_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/accel_z_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/gyro_x_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/gyro_x_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/gyro_y_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/gyro_y_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/gyro_z_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/gyro_z_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/magn_x_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/magn_x_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/magn_y_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/magn_y_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/magn_z_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/magn_z_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/inZ_supply_raw_roc_rising_value -What: /sys/.../iio:deviceX/events/inZ_supply_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/inZ_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/inZ_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/temp_raw_roc_falling_value -What: /sys/.../iio:deviceX/events/temp_raw_roc_falling_value +What: /sys/.../events/in_accel_x_raw_roc_rising_value +What: /sys/.../events/in_accel_x_raw_roc_falling_value +What: /sys/.../events/in_accel_y_raw_roc_rising_value +What: /sys/.../events/in_accel_y_raw_roc_falling_value +What: /sys/.../events/in_accel_z_raw_roc_rising_value +What: /sys/.../events/in_accel_z_raw_roc_falling_value +What: /sys/.../events/in_gyro_x_raw_roc_rising_value +What: /sys/.../events/in_gyro_x_raw_roc_falling_value +What: /sys/.../events/in_gyro_y_raw_roc_rising_value +What: /sys/.../events/in_gyro_y_raw_roc_falling_value +What: /sys/.../events/in_gyro_z_raw_roc_rising_value +What: /sys/.../events/in_gyro_z_raw_roc_falling_value +What: /sys/.../events/in_magn_x_raw_roc_rising_value +What: /sys/.../events/in_magn_x_raw_roc_falling_value +What: /sys/.../events/in_magn_y_raw_roc_rising_value +What: /sys/.../events/in_magn_y_raw_roc_falling_value +What: /sys/.../events/in_magn_z_raw_roc_rising_value +What: /sys/.../events/in_magn_z_raw_roc_falling_value +What: /sys/.../events/in_voltageZ_supply_raw_roc_rising_value +What: /sys/.../events/in_voltageZ_supply_raw_roc_falling_value +What: /sys/.../events/in_voltageZ_raw_roc_falling_value +What: /sys/.../events/in_voltageZ_raw_roc_falling_value +What: /sys/.../events/in_temp_raw_roc_falling_value +What: /sys/.../events/in_temp_raw_roc_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -480,55 +480,55 @@ Description: value is in raw device units or in processed units (as _raw and _input do on sysfs direct channel read attributes). -What: /sys/.../iio:deviceX/events/accel_x_thresh_rising_period -What: /sys/.../iio:deviceX/events/accel_x_thresh_falling_period -hat: /sys/.../iio:deviceX/events/accel_x_roc_rising_period -What: /sys/.../iio:deviceX/events/accel_x_roc_falling_period -What: /sys/.../iio:deviceX/events/accel_y_thresh_rising_period -What: /sys/.../iio:deviceX/events/accel_y_thresh_falling_period -What: /sys/.../iio:deviceX/events/accel_y_roc_rising_period -What: /sys/.../iio:deviceX/events/accel_y_roc_falling_period -What: /sys/.../iio:deviceX/events/accel_z_thresh_rising_period -What: /sys/.../iio:deviceX/events/accel_z_thresh_falling_period -What: /sys/.../iio:deviceX/events/accel_z_roc_rising_period -What: /sys/.../iio:deviceX/events/accel_z_roc_falling_period -What: /sys/.../iio:deviceX/events/gyro_x_thresh_rising_period -What: /sys/.../iio:deviceX/events/gyro_x_thresh_falling_period -What: /sys/.../iio:deviceX/events/gyro_x_roc_rising_period -What: /sys/.../iio:deviceX/events/gyro_x_roc_falling_period -What: /sys/.../iio:deviceX/events/gyro_y_thresh_rising_period -What: /sys/.../iio:deviceX/events/gyro_y_thresh_falling_period -What: /sys/.../iio:deviceX/events/gyro_y_roc_rising_period -What: /sys/.../iio:deviceX/events/gyro_y_roc_falling_period -What: /sys/.../iio:deviceX/events/gyro_z_thresh_rising_period -What: /sys/.../iio:deviceX/events/gyro_z_thresh_falling_period -What: /sys/.../iio:deviceX/events/gyro_z_roc_rising_period -What: /sys/.../iio:deviceX/events/gyro_z_roc_falling_period -What: /sys/.../iio:deviceX/events/magn_x_thresh_rising_period -What: /sys/.../iio:deviceX/events/magn_x_thresh_falling_period -What: /sys/.../iio:deviceX/events/magn_x_roc_rising_period -What: /sys/.../iio:deviceX/events/magn_x_roc_falling_period -What: /sys/.../iio:deviceX/events/magn_y_thresh_rising_period -What: /sys/.../iio:deviceX/events/magn_y_thresh_falling_period -What: /sys/.../iio:deviceX/events/magn_y_roc_rising_period -What: /sys/.../iio:deviceX/events/magn_y_roc_falling_period -What: /sys/.../iio:deviceX/events/magn_z_thresh_rising_period -What: /sys/.../iio:deviceX/events/magn_z_thresh_falling_period -What: /sys/.../iio:deviceX/events/magn_z_roc_rising_period -What: /sys/.../iio:deviceX/events/magn_z_roc_falling_period -What: /sys/.../iio:deviceX/events/inZ_supply_thresh_rising_period -What: /sys/.../iio:deviceX/events/inZ_supply_thresh_falling_period -What: /sys/.../iio:deviceX/events/inz_supply_roc_rising_period -What: /sys/.../iio:deviceX/events/inZ_supply_roc_falling_period -What: /sys/.../iio:deviceX/events/inZ_thresh_rising_period -What: /sys/.../iio:deviceX/events/inZ_thresh_falling_period -What: /sys/.../iio:deviceX/events/inZ_roc_rising_period -What: /sys/.../iio:deviceX/events/inZ_roc_falling_period -What: /sys/.../iio:deviceX/events/temp_thresh_rising_period -What: /sys/.../iio:deviceX/events/temp_thresh_falling_period -What: /sys/.../iio:deviceX/events/temp_roc_rising_period -What: /sys/.../iio:deviceX/events/temp_roc_falling_period -What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_falling_period +What: /sys/.../events/in_accel_x_thresh_rising_period +What: /sys/.../events/in_accel_x_thresh_falling_period +hat: /sys/.../events/in_accel_x_roc_rising_period +What: /sys/.../events/in_accel_x_roc_falling_period +What: /sys/.../events/in_accel_y_thresh_rising_period +What: /sys/.../events/in_accel_y_thresh_falling_period +What: /sys/.../events/in_accel_y_roc_rising_period +What: /sys/.../events/in_accel_y_roc_falling_period +What: /sys/.../events/in_accel_z_thresh_rising_period +What: /sys/.../events/in_accel_z_thresh_falling_period +What: /sys/.../events/in_accel_z_roc_rising_period +What: /sys/.../events/in_accel_z_roc_falling_period +What: /sys/.../events/in_gyro_x_thresh_rising_period +What: /sys/.../events/in_gyro_x_thresh_falling_period +What: /sys/.../events/in_gyro_x_roc_rising_period +What: /sys/.../events/in_gyro_x_roc_falling_period +What: /sys/.../events/in_gyro_y_thresh_rising_period +What: /sys/.../events/in_gyro_y_thresh_falling_period +What: /sys/.../events/in_gyro_y_roc_rising_period +What: /sys/.../events/in_gyro_y_roc_falling_period +What: /sys/.../events/in_gyro_z_thresh_rising_period +What: /sys/.../events/in_gyro_z_thresh_falling_period +What: /sys/.../events/in_gyro_z_roc_rising_period +What: /sys/.../events/in_gyro_z_roc_falling_period +What: /sys/.../events/in_magn_x_thresh_rising_period +What: /sys/.../events/in_magn_x_thresh_falling_period +What: /sys/.../events/in_magn_x_roc_rising_period +What: /sys/.../events/in_magn_x_roc_falling_period +What: /sys/.../events/in_magn_y_thresh_rising_period +What: /sys/.../events/in_magn_y_thresh_falling_period +What: /sys/.../events/in_magn_y_roc_rising_period +What: /sys/.../events/in_magn_y_roc_falling_period +What: /sys/.../events/in_magn_z_thresh_rising_period +What: /sys/.../events/in_magn_z_thresh_falling_period +What: /sys/.../events/in_magn_z_roc_rising_period +What: /sys/.../events/in_magn_z_roc_falling_period +What: /sys/.../events/in_voltageZ_supply_thresh_rising_period +What: /sys/.../events/in_voltageZ_supply_thresh_falling_period +What: /sys/.../events/in_voltagez_supply_roc_rising_period +What: /sys/.../events/in_voltageZ_supply_roc_falling_period +What: /sys/.../events/in_voltageZ_thresh_rising_period +What: /sys/.../events/in_voltageZ_thresh_falling_period +What: /sys/.../events/in_voltageZ_roc_rising_period +What: /sys/.../events/in_voltageZ_roc_falling_period +What: /sys/.../events/in_temp_thresh_rising_period +What: /sys/.../events/in_temp_thresh_falling_period +What: /sys/.../events/in_temp_roc_rising_period +What: /sys/.../events/in_temp_roc_falling_period +What: /sys/.../events/in_accel_x&y&z_mag_falling_period KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -536,31 +536,31 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions. -What: /sys/.../iio:deviceX/events/accel_mag_en -What: /sys/.../iio:deviceX/events/accel_mag_rising_en -What: /sys/.../iio:deviceX/events/accel_mag_falling_en -What: /sys/.../iio:deviceX/events/accel_x_mag_en -What: /sys/.../iio:deviceX/events/accel_x_mag_rising_en -What: /sys/.../iio:deviceX/events/accel_x_mag_falling_en -What: /sys/.../iio:deviceX/events/accel_y_mag_en -What: /sys/.../iio:deviceX/events/accel_y_mag_rising_en -What: /sys/.../iio:deviceX/events/accel_y_mag_falling_en -What: /sys/.../iio:deviceX/events/accel_z_mag_en -What: /sys/.../iio:deviceX/events/accel_z_mag_rising_en -What: /sys/.../iio:deviceX/events/accel_z_mag_falling_en -What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_rising_en -What: /sys/.../iio:deviceX/events/accel_x&y&z_mag_falling_en +What: /sys/.../iio:deviceX/events/in_accel_mag_en +What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en +What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en +What: /sys/.../iio:deviceX/events/in_accel_x_mag_en +What: /sys/.../iio:deviceX/events/in_accel_x_mag_rising_en +What: /sys/.../iio:deviceX/events/in_accel_x_mag_falling_en +What: /sys/.../iio:deviceX/events/in_accel_y_mag_en +What: /sys/.../iio:deviceX/events/in_accel_y_mag_rising_en +What: /sys/.../iio:deviceX/events/in_accel_y_mag_falling_en +What: /sys/.../iio:deviceX/events/in_accel_z_mag_en +What: /sys/.../iio:deviceX/events/in_accel_z_mag_rising_en +What: /sys/.../iio:deviceX/events/in_accel_z_mag_falling_en +What: /sys/.../iio:deviceX/events/in_accel_x&y&z_mag_rising_en +What: /sys/.../iio:deviceX/events/in_accel_x&y&z_mag_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: - Similar to accel_x_thresh[_rising|_falling]_en, but here the + Similar to in_accel_x_thresh[_rising|_falling]_en, but here the magnitude of the channel is compared to the threshold, not its signed value. -What: /sys/.../accel_raw_mag_value -What: /sys/.../accel_x_raw_mag_rising_value -What: /sys/.../accel_y_raw_mag_rising_value -What: /sys/.../accel_z_raw_mag_rising_value +What: /sys/.../events/in_accel_raw_mag_value +What: /sys/.../events/in_accel_x_raw_mag_rising_value +What: /sys/.../events/in_accel_y_raw_mag_rising_value +What: /sys/.../events/in_accel_z_raw_mag_rising_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -602,34 +602,34 @@ Description: Directory containing interfaces for elements that will be captured for a single triggered sample set in the buffer. -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_x_en -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_y_en -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_z_en -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_x_en -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_y_en -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_z_en -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_x_en -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_y_en -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_z_en -What: /sys/.../iio:deviceX/buffer/scan_elements/timestamp_en -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_en -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_en -What: /sys/.../iio:deviceX/buffer/scan_elements/inY-inZ_en -What: /sys/.../iio:deviceX/buffer/scan_elements/incli_x_en -What: /sys/.../iio:deviceX/buffer/scan_elements/incli_y_en +What: /sys/.../buffer/scan_elements/in_accel_x_en +What: /sys/.../buffer/scan_elements/in_accel_y_en +What: /sys/.../buffer/scan_elements/in_accel_z_en +What: /sys/.../buffer/scan_elements/in_gyro_x_en +What: /sys/.../buffer/scan_elements/in_gyro_y_en +What: /sys/.../buffer/scan_elements/in_gyro_z_en +What: /sys/.../buffer/scan_elements/in_magn_x_en +What: /sys/.../buffer/scan_elements/in_magn_y_en +What: /sys/.../buffer/scan_elements/in_magn_z_en +What: /sys/.../buffer/scan_elements/in_timestamp_en +What: /sys/.../buffer/scan_elements/in_voltageY_supply_en +What: /sys/.../buffer/scan_elements/in_voltageY_en +What: /sys/.../buffer/scan_elements/in_voltageY-voltageZ_en +What: /sys/.../buffer/scan_elements/in_incli_x_en +What: /sys/.../buffer/scan_elements/in_incli_y_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Scan element control for triggered data capture. -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_type -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_type -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_type -What: /sys/.../iio:deviceX/buffer/scan_elements/incli_type -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_type -What: /sys/.../iio:deviceX/buffer/scan_elements/in-in_type -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_type -What: /sys/.../iio:deviceX/buffer/scan_elements/timestamp_type +What: /sys/.../buffer/scan_elements/in_accel_type +What: /sys/.../buffer/scan_elements/in_gyro_type +What: /sys/.../buffer/scan_elements/in_magn_type +What: /sys/.../buffer/scan_elements/in_incli_type +What: /sys/.../buffer/scan_elements/in_voltageY_type +What: /sys/.../buffer/scan_elements/in_voltage-in_type +What: /sys/.../buffer/scan_elements/in_voltageY_supply_type +What: /sys/.../buffer/scan_elements/in_timestamp_type KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -652,27 +652,27 @@ Description: For other storage combinations this attribute will be extended appropriately. -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_type_available +What: /sys/.../buffer/scan_elements/in_accel_type_available KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: If the type parameter can take one of a small set of values, this attribute lists them. -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_index -What: /sys/.../iio:deviceX/buffer/scan_elements/inY_supply_index -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_x_index -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_y_index -What: /sys/.../iio:deviceX/buffer/scan_elements/accel_z_index -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_x_index -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_y_index -What: /sys/.../iio:deviceX/buffer/scan_elements/gyro_z_index -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_x_index -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_y_index -What: /sys/.../iio:deviceX/buffer/scan_elements/magn_z_index -What: /sys/.../iio:deviceX/buffer/scan_elements/incli_x_index -What: /sys/.../iio:deviceX/buffer/scan_elements/incli_y_index -What: /sys/.../iio:deviceX/buffer/scan_elements/in_timestamp_index +What: /sys/.../buffer/scan_elements/in_voltageY_index +What: /sys/.../buffer/scan_elements/in_voltageY_supply_index +What: /sys/.../buffer/scan_elements/in_accel_x_index +What: /sys/.../buffer/scan_elements/in_accel_y_index +What: /sys/.../buffer/scan_elements/in_accel_z_index +What: /sys/.../buffer/scan_elements/in_gyro_x_index +What: /sys/.../buffer/scan_elements/in_gyro_y_index +What: /sys/.../buffer/scan_elements/in_gyro_z_index +What: /sys/.../buffer/scan_elements/in_magn_x_index +What: /sys/.../buffer/scan_elements/in_magn_y_index +What: /sys/.../buffer/scan_elements/in_magn_z_index +What: /sys/.../buffer/scan_elements/in_incli_x_index +What: /sys/.../buffer/scan_elements/in_incli_y_index +What: /sys/.../buffer/scan_elements/in_voltage_timestamp_index KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -684,9 +684,9 @@ Description: and the relevant _type attributes to establish the data storage format. -What: /sys/.../iio:deviceX/gyro_z_quadrature_correction_raw +What: /sys/.../iio:deviceX/in_gyro_z_quadrature_correction_raw KernelVersion: 2.6.38 -Contact: linux-iio@xxxxxxxxxxxxxxx +Contact: linux-iio@vger.kernel.org Description: This attribute is used to read the amount of quadrature error present in the device at a given time. From 8310b86c3cd2f813bb9ed330447bcb2877b8328a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:36 +0100 Subject: [PATCH 0790/1519] staging:iio:scan element types: introduce endian description to the data format. If not set in chan_spec, cpu endianness used. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 8 ++++++++ drivers/staging/iio/industrialio-ring.c | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index f42387052ce..daaea94a5e6 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -80,6 +80,12 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE, }; +enum iio_endian { + IIO_CPU, + IIO_BE, + IIO_LE, +}; + /** * struct iio_chan_spec - specification of a single channel * @type: What type of measurement is the channel making. @@ -95,6 +101,7 @@ enum iio_chan_info_enum { * storage_bits: Realbits + padding * shift: Shift right by this before masking out * realbits. + * endianness: little or big endian * @info_mask: What information is to be exported about this channel. * This includes calibbias, scale etc. * @event_mask: What events can this channel produce. @@ -123,6 +130,7 @@ struct iio_chan_spec { u8 realbits; u8 storagebits; u8 shift; + enum iio_endian endianness; } scan_type; long info_mask; long event_mask; diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index e844246bc32..23967d49192 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -25,6 +25,10 @@ #include "sysfs.h" #include "ring_generic.h" +static const char * const iio_endian_prefix[] = { + [IIO_BE] = "be", + [IIO_LE] = "le", +}; /** * iio_ring_read_first_n_outer() - chrdev read for ring buffer access @@ -96,7 +100,16 @@ static ssize_t iio_show_fixed_type(struct device *dev, char *buf) { struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - return sprintf(buf, "%c%d/%d>>%u\n", + u8 type = this_attr->c->scan_type.endianness; + + if (type == IIO_CPU) { + if (__LITTLE_ENDIAN) + type = IIO_LE; + else + type = IIO_BE; + } + return sprintf(buf, "%s:%c%d/%d>>%u\n", + iio_endian_prefix[type], this_attr->c->scan_type.sign, this_attr->c->scan_type.realbits, this_attr->c->scan_type.storagebits, From bd94c6a8a6d3499e857002b1f445162fba941029 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:37 +0100 Subject: [PATCH 0791/1519] staging:iio:various move default scan mask setting after ring register or remove The scan mask will be dynamically assigned in register, so don't use it before that. In adis16260 I've moved it as I know this driver has userspace code. Same for sca3000 where it is cost free due to hardware buffer. Can do that for the others, but in theory userspace code should always have been checking these and setting them appropriately anyway! V2: Clear default mask out of adis16400 as reported by Michael Signed-off-by: Jonathan Cameron Reported-by: Michael Hennerich Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 9 --------- drivers/staging/iio/accel/adis16203_ring.c | 7 ------- drivers/staging/iio/accel/adis16204_ring.c | 7 ------- drivers/staging/iio/accel/adis16209_ring.c | 10 ---------- drivers/staging/iio/accel/adis16240_ring.c | 8 -------- drivers/staging/iio/accel/lis3l02dq_ring.c | 5 ----- drivers/staging/iio/accel/sca3000_core.c | 6 ++++++ drivers/staging/iio/accel/sca3000_ring.c | 4 ---- drivers/staging/iio/gyro/adis16260_core.c | 9 ++++++++- drivers/staging/iio/gyro/adis16260_ring.c | 7 ------- drivers/staging/iio/imu/adis16400_ring.c | 3 --- 11 files changed, 14 insertions(+), 61 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 4b433c53e5c..1c1f35d77c3 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -121,15 +121,6 @@ int adis16201_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16201_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16201_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16201_SCAN_ACC_X); - iio_scan_mask_set(ring, ADIS16201_SCAN_ACC_Y); - iio_scan_mask_set(ring, ADIS16201_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16201_SCAN_TEMP); - iio_scan_mask_set(ring, ADIS16201_SCAN_INCLI_X); - iio_scan_mask_set(ring, ADIS16201_SCAN_INCLI_Y); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16201_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index 993e239f942..d7d692c17b4 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -123,13 +123,6 @@ int adis16203_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16203_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16203_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16203_SCAN_TEMP); - iio_scan_mask_set(ring, ADIS16203_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16203_SCAN_INCLI_X); - iio_scan_mask_set(ring, ADIS16203_SCAN_INCLI_Y); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16203_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 847f43858f5..273293aa200 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -118,13 +118,6 @@ int adis16204_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16204_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16204_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_X); - iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_Y); - iio_scan_mask_set(ring, ADIS16204_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16204_SCAN_TEMP); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16204_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index f889fe72f33..bc654e2e477 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -118,16 +118,6 @@ int adis16209_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16209_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16209_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16209_SCAN_ACC_X); - iio_scan_mask_set(ring, ADIS16209_SCAN_ACC_Y); - iio_scan_mask_set(ring, ADIS16209_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16209_SCAN_TEMP); - iio_scan_mask_set(ring, ADIS16209_SCAN_INCLI_X); - iio_scan_mask_set(ring, ADIS16209_SCAN_INCLI_Y); - iio_scan_mask_set(ring, ADIS16209_SCAN_ROT); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16209_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 051ba643d34..b41e24f02a9 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -115,14 +115,6 @@ int adis16240_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16240_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16240_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_X); - iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_Y); - iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_Z); - iio_scan_mask_set(ring, ADIS16240_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16240_SCAN_TEMP); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16240_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 5c6fe13408b..d67d78394cb 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -441,11 +441,6 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &lis3l02dq_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, 0); - iio_scan_mask_set(ring, 1); - iio_scan_mask_set(ring, 2); - /* Functions are NULL as we set handler below */ indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &lis3l02dq_trigger_handler, diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 8281d66132d..3707acc6c79 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1161,6 +1161,12 @@ static int __devinit sca3000_probe(struct spi_device *spi) ARRAY_SIZE(sca3000_channels)); if (ret < 0) goto error_unregister_dev; + if (indio_dev->ring) { + iio_scan_mask_set(indio_dev->ring, 0); + iio_scan_mask_set(indio_dev->ring, 1); + iio_scan_mask_set(indio_dev->ring, 2); + } + if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { ret = request_threaded_irq(spi->irq, NULL, diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index cc38521e6e2..3d6dafa11e5 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -294,10 +294,6 @@ int sca3000_configure_ring(struct iio_dev *indio_dev) indio_dev->ring->access = &sca3000_ring_access_funcs; - iio_scan_mask_set(indio_dev->ring, 0); - iio_scan_mask_set(indio_dev->ring, 1); - iio_scan_mask_set(indio_dev->ring, 2); - return 0; } diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 6ea6d58fd1c..acd17e50df5 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -636,7 +636,14 @@ static int __devinit adis16260_probe(struct spi_device *spi) printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; } - + if (indio_dev->ring) { + /* Set default scan mode */ + iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_SUPPLY); + iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_GYRO); + iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_AUX_ADC); + iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_TEMP); + iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_ANGL); + } if (spi->irq) { ret = adis16260_probe_trigger(indio_dev); if (ret) diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 10f8a666226..40226f72d86 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -120,13 +120,6 @@ int adis16260_configure_ring(struct iio_dev *indio_dev) ring->setup_ops = &adis16260_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - iio_scan_mask_set(ring, ADIS16260_SCAN_SUPPLY); - iio_scan_mask_set(ring, ADIS16260_SCAN_GYRO); - iio_scan_mask_set(ring, ADIS16260_SCAN_AUX_ADC); - iio_scan_mask_set(ring, ADIS16260_SCAN_TEMP); - iio_scan_mask_set(ring, ADIS16260_SCAN_ANGL); - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16260_trigger_handler, IRQF_ONESHOT, diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 3fc24037db2..d2506b1b2db 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -189,9 +189,6 @@ int adis16400_configure_ring(struct iio_dev *indio_dev) ring->scan_timestamp = true; ring->setup_ops = &adis16400_ring_setup_ops; ring->owner = THIS_MODULE; - /* Set default scan mode */ - ring->scan_mask = st->variant->default_scan_mask; - ring->scan_count = hweight_long(st->variant->default_scan_mask); indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16400_trigger_handler, From 32b5eecab0f2d6f66f2e237e161d58d5916f8b13 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:38 +0100 Subject: [PATCH 0792/1519] staging:iio: Switch the channel masks to bitmaps so as to allow for more channels. This is as light as possible on changes to current drivers. Some drivers make assumptions that their masks fit in a single long. Given they were previously working this is clearly valid if not tidy. The max1363 is an example where there should be no such assumptions. V2: Add the new ad5933 Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq_ring.c | 5 +- drivers/staging/iio/adc/ad7192.c | 6 +- drivers/staging/iio/adc/ad7298_ring.c | 4 +- drivers/staging/iio/adc/ad7793.c | 18 +-- drivers/staging/iio/adc/ad7887.h | 4 +- drivers/staging/iio/adc/ad7887_ring.c | 10 +- drivers/staging/iio/adc/ad799x.h | 4 +- drivers/staging/iio/adc/ad799x_core.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 18 +-- drivers/staging/iio/adc/max1363.h | 8 +- drivers/staging/iio/adc/max1363_core.c | 37 ++++--- drivers/staging/iio/adc/max1363_ring.c | 22 ++-- drivers/staging/iio/iio.h | 5 +- .../staging/iio/impedance-analyzer/ad5933.c | 2 +- drivers/staging/iio/imu/adis16400_ring.c | 5 +- drivers/staging/iio/industrialio-ring.c | 103 +++++++++++++++++- drivers/staging/iio/meter/ade7758.h | 2 +- drivers/staging/iio/meter/ade7758_core.c | 2 +- drivers/staging/iio/meter/ade7758_ring.c | 2 +- drivers/staging/iio/ring_generic.h | 64 +---------- 20 files changed, 188 insertions(+), 135 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index d67d78394cb..c8169338b27 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -61,8 +61,9 @@ ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, ret = ring->access->read_last(ring, (u8 *)data); if (ret) goto error_free_data; - *val = data[bitmap_weight(&ring->scan_mask, index)]; + *val = data[bitmap_weight(ring->scan_mask, index)]; error_free_data: + kfree(data); return ret; @@ -99,7 +100,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) mutex_lock(&st->buf_lock); for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) - if (ring->scan_mask & (1 << i)) { + if (test_bit(i, ring->scan_mask)) { /* lower byte */ xfers[j].tx_buf = st->tx + 2*j; st->tx[2*j] = read_all_tx_array[i*4]; diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 80b067c5b21..c67da6aac99 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -146,7 +146,7 @@ struct ad7192_state { u32 mode; u32 conf; u32 scale_avail[8][2]; - u32 available_scan_masks[9]; + long available_scan_masks[9]; u8 gpocon; u8 devid; /* @@ -460,7 +460,7 @@ static int ad7192_scan_from_ring(struct ad7192_state *st, unsigned ch, int *val) s64 dat64[2]; u32 *dat32 = (u32 *)dat64; - if (!(ring->scan_mask & (1 << ch))) + if (!(test_bit(ch, ring->scan_mask))) return -EBUSY; ret = ring->access->read_last(ring, (u8 *) &dat64); @@ -482,7 +482,7 @@ static int ad7192_ring_preenable(struct iio_dev *indio_dev) if (!ring->scan_count) return -EINVAL; - channel = __ffs(ring->scan_mask); + channel = find_first_bit(ring->scan_mask, indio_dev->masklength); d_size = ring->scan_count * indio_dev->channels[0].scan_type.storagebits / 8; diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 741818c0b82..246b2e724d3 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -24,7 +24,7 @@ int ad7298_scan_from_ring(struct iio_dev *dev_info, long ch) int ret; u16 *ring_data; - if (!(ring->scan_mask & (1 << ch))) { + if (!(test_bit(ch, ring->scan_mask))) { ret = -EBUSY; goto error_ret; } @@ -79,7 +79,7 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev) command = AD7298_WRITE | st->ext_ref; for (i = 0, m = AD7298_CH(0); i < AD7298_MAX_CHAN; i++, m >>= 1) - if (ring->scan_mask & (1 << i)) + if (test_bit(i, ring->scan_mask)) command |= m; st->tx_buf[0] = cpu_to_be16(command); diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 38095eba099..b42a7ace426 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -51,7 +51,8 @@ struct ad7793_state { u16 mode; u16 conf; u32 scale_avail[8][2]; - u32 available_scan_masks[7]; + /* Note this uses fact that 8 the mask always fits in a long */ + unsigned long available_scan_masks[7]; /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -321,7 +322,7 @@ static int ad7793_scan_from_ring(struct ad7793_state *st, unsigned ch, int *val) s64 dat64[2]; u32 *dat32 = (u32 *)dat64; - if (!(ring->scan_mask & (1 << ch))) + if (!(test_bit(ch, ring->scan_mask))) return -EBUSY; ret = ring->access->read_last(ring, (u8 *) &dat64); @@ -343,7 +344,8 @@ static int ad7793_ring_preenable(struct iio_dev *indio_dev) if (!ring->scan_count) return -EINVAL; - channel = __ffs(ring->scan_mask); + channel = find_first_bit(ring->scan_mask, + indio_dev->masklength); d_size = ring->scan_count * indio_dev->channels[0].scan_type.storagebits / 8; @@ -875,10 +877,12 @@ static int __devinit ad7793_probe(struct spi_device *spi) indio_dev->num_channels = 7; indio_dev->info = &ad7793_info; - for (i = 0; i < indio_dev->num_channels; i++) - st->available_scan_masks[i] = (1 << i) | (1 << - indio_dev->channels[indio_dev->num_channels - 1]. - scan_index); + for (i = 0; i < indio_dev->num_channels; i++) { + set_bit(i, &st->available_scan_masks[i]); + set_bit(indio_dev-> + channels[indio_dev->num_channels - 1].scan_index, + &st->available_scan_masks[i]); + } init_waitqueue_head(&st->wq_data_avail); diff --git a/drivers/staging/iio/adc/ad7887.h b/drivers/staging/iio/adc/ad7887.h index 837046c7b89..1b7a772934c 100644 --- a/drivers/staging/iio/adc/ad7887.h +++ b/drivers/staging/iio/adc/ad7887.h @@ -83,11 +83,11 @@ enum ad7887_supported_device_ids { }; #ifdef CONFIG_IIO_RING_BUFFER -int ad7887_scan_from_ring(struct ad7887_state *st, long mask); +int ad7887_scan_from_ring(struct ad7887_state *st, int channum); int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad7887_ring_cleanup(struct iio_dev *indio_dev); #else /* CONFIG_IIO_RING_BUFFER */ -static inline int ad7887_scan_from_ring(struct ad7887_state *st, long mask) +static inline int ad7887_scan_from_ring(struct ad7887_state *st, int channum) { return 0; } diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 6b3daf41e0c..36e118cf32e 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -19,13 +19,13 @@ #include "ad7887.h" -int ad7887_scan_from_ring(struct ad7887_state *st, long mask) +int ad7887_scan_from_ring(struct ad7887_state *st, int channum) { struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; int count = 0, ret; u16 *ring_data; - if (!(ring->scan_mask & mask)) { + if (!(test_bit(channum, ring->scan_mask))) { ret = -EBUSY; goto error_ret; } @@ -41,7 +41,8 @@ int ad7887_scan_from_ring(struct ad7887_state *st, long mask) goto error_free_ring_data; /* for single channel scan the result is stored with zero offset */ - if ((ring->scan_mask == ((1 << 1) | (1 << 0))) && (mask == (1 << 1))) + if ((test_bit(1, ring->scan_mask) || test_bit(0, ring->scan_mask)) && + (channum == 1)) count = 1; ret = be16_to_cpu(ring_data[count]); @@ -78,7 +79,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev) indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, st->d_size); - switch (ring->scan_mask) { + /* We know this is a single long so can 'cheat' */ + switch (*ring->scan_mask) { case (1 << 0): st->ring_msg = &st->msg[AD7887_CH0]; break; diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index 0dc9b4c73a3..98f06f682b8 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h @@ -124,11 +124,11 @@ struct ad799x_platform_data { int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask); #ifdef CONFIG_AD799X_RING_BUFFER -int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask); +int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum); int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad799x_ring_cleanup(struct iio_dev *indio_dev); #else /* CONFIG_AD799X_RING_BUFFER */ -int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask) +int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum) { return -EINVAL; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 299183c05d4..cfe4b2caea8 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -151,7 +151,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info, mutex_lock(&dev_info->mlock); if (iio_ring_enabled(dev_info)) ret = ad799x_single_channel_from_ring(st, - 1 << chan->address); + chan->address); else ret = ad799x_scan_direct(st, chan->address); mutex_unlock(&dev_info->mlock); diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 8f1fc52560f..438e81d190c 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -23,13 +23,13 @@ #include "ad799x.h" -int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask) +int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum) { struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; int count = 0, ret; u16 *ring_data; - if (!(ring->scan_mask & mask)) { + if (!(test_bit(channum, ring->scan_mask))) { ret = -EBUSY; goto error_ret; } @@ -44,13 +44,7 @@ int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask) if (ret) goto error_free_ring_data; /* Need a count of channels prior to this one */ - mask >>= 1; - while (mask) { - if (mask & ring->scan_mask) - count++; - mask >>= 1; - } - + count = bitmap_weight(ring->scan_mask, channum); ret = be16_to_cpu(ring_data[count]); error_free_ring_data: @@ -77,7 +71,7 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev) */ if (st->id == ad7997 || st->id == ad7998) - ad7997_8_set_scan_mode(st, ring->scan_mask); + ad7997_8_set_scan_mode(st, *ring->scan_mask); st->d_size = ring->scan_count * 2; @@ -121,12 +115,12 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) case ad7991: case ad7995: case ad7999: - cmd = st->config | (ring->scan_mask << AD799X_CHANNEL_SHIFT); + cmd = st->config | (*ring->scan_mask << AD799X_CHANNEL_SHIFT); break; case ad7992: case ad7993: case ad7994: - cmd = (ring->scan_mask << AD799X_CHANNEL_SHIFT) | + cmd = (*ring->scan_mask << AD799X_CHANNEL_SHIFT) | AD7998_CONV_RES_REG; break; case ad7997: diff --git a/drivers/staging/iio/adc/max1363.h b/drivers/staging/iio/adc/max1363.h index 360bfc5398f..cbcb08a2cb5 100644 --- a/drivers/staging/iio/adc/max1363.h +++ b/drivers/staging/iio/adc/max1363.h @@ -57,6 +57,7 @@ #define MAX1363_SCAN_MASK 0x60 #define MAX1363_SE_DE_MASK 0x01 +#define MAX1363_MAX_CHANNELS 25 /** * struct max1363_mode - scan mode information * @conf: The corresponding value of the configuration register @@ -64,7 +65,7 @@ */ struct max1363_mode { int8_t conf; - long modemask; + DECLARE_BITMAP(modemask, MAX1363_MAX_CHANNELS); }; /* This must be maintained along side the max1363_mode_table in max1363_core */ @@ -145,13 +146,14 @@ struct max1363_state { }; const struct max1363_mode -*max1363_match_mode(u32 mask, const struct max1363_chip_info *ci); +*max1363_match_mode(unsigned long *mask, const struct max1363_chip_info *ci); int max1363_set_scan_mode(struct max1363_state *st); #ifdef CONFIG_MAX1363_RING_BUFFER -int max1363_single_channel_from_ring(long mask, struct max1363_state *st); +int max1363_single_channel_from_ring(const long *mask, + struct max1363_state *st); int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev); void max1363_ring_cleanup(struct iio_dev *indio_dev); diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index e921efa7196..49b2ce22e6e 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -42,14 +42,14 @@ .conf = MAX1363_CHANNEL_SEL(_num) \ | MAX1363_CONFIG_SCAN_SINGLE_1 \ | MAX1363_CONFIG_SE, \ - .modemask = _mask, \ + .modemask[0] = _mask, \ } #define MAX1363_MODE_SCAN_TO_CHANNEL(_num, _mask) { \ .conf = MAX1363_CHANNEL_SEL(_num) \ | MAX1363_CONFIG_SCAN_TO_CS \ | MAX1363_CONFIG_SE, \ - .modemask = _mask, \ + .modemask[0] = _mask, \ } /* note not available for max1363 hence naming */ @@ -57,14 +57,14 @@ .conf = MAX1363_CHANNEL_SEL(_num) \ | MAX1236_SCAN_MID_TO_CHANNEL \ | MAX1363_CONFIG_SE, \ - .modemask = _mask \ + .modemask[0] = _mask \ } #define MAX1363_MODE_DIFF_SINGLE(_nump, _numm, _mask) { \ .conf = MAX1363_CHANNEL_SEL(_nump) \ | MAX1363_CONFIG_SCAN_SINGLE_1 \ | MAX1363_CONFIG_DE, \ - .modemask = _mask \ + .modemask[0] = _mask \ } /* Can't think how to automate naming so specify for now */ @@ -72,7 +72,7 @@ .conf = MAX1363_CHANNEL_SEL(_num) \ | MAX1363_CONFIG_SCAN_TO_CS \ | MAX1363_CONFIG_DE, \ - .modemask = _mask \ + .modemask[0] = _mask \ } /* note only available for max1363 hence naming */ @@ -80,7 +80,7 @@ .conf = MAX1363_CHANNEL_SEL(_num) \ | MAX1236_SCAN_MID_TO_CHANNEL \ | MAX1363_CONFIG_SE, \ - .modemask = _mask \ + .modemask[0] = _mask \ } static const struct max1363_mode max1363_mode_table[] = { @@ -147,13 +147,15 @@ static const struct max1363_mode max1363_mode_table[] = { }; const struct max1363_mode -*max1363_match_mode(u32 mask, const struct max1363_chip_info *ci) +*max1363_match_mode(unsigned long *mask, const struct max1363_chip_info *ci) { int i; if (mask) for (i = 0; i < ci->num_modes; i++) - if (!((~max1363_mode_table[ci->mode_list[i]].modemask) & - mask)) + if (bitmap_subset(mask, + max1363_mode_table[ci->mode_list[i]]. + modemask, + MAX1363_MAX_CHANNELS)) return &max1363_mode_table[ci->mode_list[i]]; return NULL; } @@ -187,7 +189,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, int ret = 0; s32 data; char rxbuf[2]; - long mask; + const unsigned long *mask; struct max1363_state *st = iio_priv(indio_dev); struct i2c_client *client = st->client; @@ -644,7 +646,7 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) int ret, i = 3, j; unsigned long numelements; int len; - long modemask; + const long *modemask; if (!enabled) { /* transition to ring capture is not currently supported */ @@ -672,7 +674,7 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) st->configbyte |= max1363_mode_table[d1m0to3m2].conf; modemask = max1363_mode_table[d1m0to3m2].modemask; } - numelements = hweight_long(modemask); + numelements = bitmap_weight(modemask, MAX1363_MAX_CHANNELS); len = 3 * numelements + 3; tx_buf = kmalloc(len, GFP_KERNEL); if (!tx_buf) { @@ -688,7 +690,7 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) * setup to match what we need. */ for (j = 0; j < 8; j++) - if (modemask & (1 << j)) { + if (test_bit(j, modemask)) { /* Establish the mode is in the scan */ if (st->mask_low & (1 << j)) { tx_buf[i] = (st->thresh_low[j] >> 4) & 0xFF; @@ -1281,7 +1283,7 @@ static int __devinit max1363_probe(struct i2c_client *client, st->client = client; indio_dev->available_scan_masks - = kzalloc(sizeof(*indio_dev->available_scan_masks)* + = kzalloc(BITS_TO_LONGS(MAX1363_MAX_CHANNELS)* (st->chip_info->num_modes + 1), GFP_KERNEL); if (!indio_dev->available_scan_masks) { ret = -ENOMEM; @@ -1289,9 +1291,10 @@ static int __devinit max1363_probe(struct i2c_client *client, } for (i = 0; i < st->chip_info->num_modes; i++) - indio_dev->available_scan_masks[i] = - max1363_mode_table[st->chip_info->mode_list[i]] - .modemask; + bitmap_copy(indio_dev->available_scan_masks + + BITS_TO_LONGS(MAX1363_MAX_CHANNELS)*i, + max1363_mode_table[st->chip_info->mode_list[i]] + .modemask, MAX1363_MAX_CHANNELS); /* Estabilish that the iio_dev is a child of the i2c device */ indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index be601e07639..abe9e03f36e 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -21,12 +21,14 @@ #include "max1363.h" -int max1363_single_channel_from_ring(long mask, struct max1363_state *st) +int max1363_single_channel_from_ring(const long *mask, struct max1363_state *st) { struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; - int count = 0, ret; + int count = 0, ret, index; u8 *ring_data; - if (!(st->current_mode->modemask & mask)) { + index = find_first_bit(mask, MAX1363_MAX_CHANNELS); + + if (!(test_bit(index, st->current_mode->modemask))) { ret = -EBUSY; goto error_ret; } @@ -41,12 +43,8 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st) if (ret) goto error_free_ring_data; /* Need a count of channels prior to this one */ - mask >>= 1; - while (mask) { - if (mask & st->current_mode->modemask) - count++; - mask >>= 1; - } + + count = bitmap_weight(mask, index - 1); if (st->chip_info->bits != 8) ret = ((int)(ring_data[count*2 + 0] & 0x0F) << 8) + (int)(ring_data[count*2 + 1]); @@ -85,7 +83,8 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev) max1363_set_scan_mode(st); - numvals = hweight_long(st->current_mode->modemask); + numvals = bitmap_weight(st->current_mode->modemask, + indio_dev->masklength); if (ring->access->set_bytes_per_datum) { if (ring->scan_timestamp) d_size += sizeof(s64); @@ -110,7 +109,8 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) __u8 *rxbuf; int b_sent; size_t d_size; - unsigned long numvals = hweight_long(st->current_mode->modemask); + unsigned long numvals = bitmap_weight(st->current_mode->modemask, + MAX1363_MAX_CHANNELS); /* Ensure the timestamp is 8 byte aligned */ if (st->chip_info->bits != 8) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index daaea94a5e6..635fa73e462 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -272,6 +272,8 @@ struct iio_info { * @mlock: [INTERN] lock used to prevent simultaneous device state * changes * @available_scan_masks: [DRIVER] optional array of allowed bitmasks + * @masklength: [INTERN] the length of the mask established from + * channels * @trig: [INTERN] current device trigger (ring buffer modes) * @pollfunc: [DRIVER] function run on trigger being received * @channels: [DRIVER] channel specification structure table @@ -294,7 +296,8 @@ struct iio_dev { struct iio_ring_buffer *ring; struct mutex mlock; - u32 *available_scan_masks; + unsigned long *available_scan_masks; + unsigned masklength; struct iio_trigger *trig; struct iio_poll_func *pollfunc; diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 1c1cd8eac9d..e199bbed75e 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -640,7 +640,7 @@ static void ad5933_work(struct work_struct *work) if (status & AD5933_STAT_DATA_VALID) { ad5933_i2c_read(st->client, - (ring->scan_mask & (1 << 0)) ? + test_bit(1, ring->scan_mask) ? AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA, ring->scan_count * 2, (u8 *)buf); diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index d2506b1b2db..af25697dab9 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -85,7 +85,7 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++) - if (indio_dev->ring->scan_mask & (1 << i)) { + if (test_bit(i, indio_dev->ring->scan_mask)) { xfers[j].tx_buf = &read_all_tx_array[i]; xfers[j].bits_per_word = 16; xfers[j].len = 2; @@ -117,7 +117,8 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) int i = 0, j, ret = 0; s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); - unsigned long mask = ring->scan_mask; + /* Asumption that long is enough for maximum channels */ + unsigned long mask = *ring->scan_mask; data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 23967d49192..6f14c0d8486 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -132,9 +132,7 @@ static ssize_t iio_scan_el_show(struct device *dev, static int iio_scan_mask_clear(struct iio_ring_buffer *ring, int bit) { - if (bit > IIO_MAX_SCAN_LENGTH) - return -EINVAL; - ring->scan_mask &= ~(1 << bit); + clear_bit(bit, ring->scan_mask); ring->scan_count--; return 0; } @@ -323,11 +321,27 @@ int iio_ring_buffer_register(struct iio_dev *indio_dev, if (channels) { /* new magic */ for (i = 0; i < num_channels; i++) { + /* Establish necessary mask length */ + if (channels[i].scan_index > + (int)indio_dev->masklength - 1) + indio_dev->masklength + = indio_dev->channels[i].scan_index + 1; + ret = iio_ring_add_channel_sysfs(indio_dev, &channels[i]); if (ret < 0) goto error_cleanup_group; } + if (indio_dev->masklength && ring->scan_mask == NULL) { + ring->scan_mask + = kzalloc(sizeof(*ring->scan_mask)* + BITS_TO_LONGS(indio_dev->masklength), + GFP_KERNEL); + if (ring->scan_mask == NULL) { + ret = -ENOMEM; + goto error_cleanup_group; + } + } } return 0; @@ -343,6 +357,7 @@ EXPORT_SYMBOL(iio_ring_buffer_register); void iio_ring_buffer_unregister(struct iio_dev *indio_dev) { + kfree(indio_dev->ring->scan_mask); if (indio_dev->ring->attrs) sysfs_remove_group(&indio_dev->dev.kobj, indio_dev->ring->attrs); @@ -539,3 +554,85 @@ int iio_sw_ring_preenable(struct iio_dev *indio_dev) return 0; } EXPORT_SYMBOL(iio_sw_ring_preenable); + + +/* note NULL used as error indicator as it doesn't make sense. */ +static unsigned long *iio_scan_mask_match(unsigned long *av_masks, + unsigned int masklength, + unsigned long *mask) +{ + if (bitmap_empty(mask, masklength)) + return NULL; + while (*av_masks) { + if (bitmap_subset(mask, av_masks, masklength)) + return av_masks; + av_masks += BITS_TO_LONGS(masklength); + } + return NULL; +} + +/** + * iio_scan_mask_set() - set particular bit in the scan mask + * @ring: the ring buffer whose scan mask we are interested in + * @bit: the bit to be set. + **/ +int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) +{ + struct iio_dev *dev_info = ring->indio_dev; + unsigned long *mask; + unsigned long *trialmask; + + trialmask = kmalloc(sizeof(*trialmask)* + BITS_TO_LONGS(dev_info->masklength), + GFP_KERNEL); + + if (trialmask == NULL) + return -ENOMEM; + if (!dev_info->masklength) { + WARN_ON("trying to set scan mask prior to registering ring\n"); + kfree(trialmask); + return -EINVAL; + } + bitmap_copy(trialmask, ring->scan_mask, dev_info->masklength); + set_bit(bit, trialmask); + + if (dev_info->available_scan_masks) { + mask = iio_scan_mask_match(dev_info->available_scan_masks, + dev_info->masklength, + trialmask); + if (!mask) { + kfree(trialmask); + return -EINVAL; + } + } + bitmap_copy(ring->scan_mask, trialmask, dev_info->masklength); + ring->scan_count++; + + kfree(trialmask); + + return 0; +}; +EXPORT_SYMBOL_GPL(iio_scan_mask_set); + +int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit) +{ + struct iio_dev *dev_info = ring->indio_dev; + long *mask; + + if (bit > dev_info->masklength) + return -EINVAL; + + if (!ring->scan_mask) + return 0; + if (dev_info->available_scan_masks) + mask = iio_scan_mask_match(dev_info->available_scan_masks, + dev_info->masklength, + ring->scan_mask); + else + mask = ring->scan_mask; + if (!mask) + return 0; + + return test_bit(bit, mask); +}; +EXPORT_SYMBOL_GPL(iio_scan_mask_query); diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h index 4d73e1a3881..20a2bcace7f 100644 --- a/drivers/staging/iio/meter/ade7758.h +++ b/drivers/staging/iio/meter/ade7758.h @@ -122,7 +122,7 @@ struct ade7758_state { u8 *tx; u8 *rx; struct mutex buf_lock; - u32 available_scan_masks[AD7758_NUM_WAVESRC]; + unsigned long available_scan_masks[AD7758_NUM_WAVESRC]; struct iio_chan_spec *ade7758_ring_channels; struct spi_transfer ring_xfer[4]; struct spi_message ring_msg; diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 77bd2761f27..ce513bda021 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -767,7 +767,7 @@ static int __devinit ade7758_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; for (i = 0; i < AD7758_NUM_WAVESRC; i++) - st->available_scan_masks[i] = 1 << i; + set_bit(i, &st->available_scan_masks[i]); indio_dev->available_scan_masks = st->available_scan_masks; diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 5e740e38616..9934f508ded 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -98,7 +98,7 @@ static int ade7758_ring_preenable(struct iio_dev *indio_dev) if (!ring->scan_count) return -EINVAL; - channel = __ffs(ring->scan_mask); + channel = find_first_bit(ring->scan_mask, indio_dev->masklength); d_size = st->ade7758_ring_channels[channel].scan_type.storagebits / 8; diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 25aacf3b893..7a47f627556 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -104,7 +104,7 @@ struct iio_ring_buffer { int bpe; struct attribute_group *scan_el_attrs; int scan_count; - unsigned long scan_mask; + long *scan_mask; bool scan_timestamp; const struct iio_ring_access_funcs *access; const struct iio_ring_setup_ops *setup_ops; @@ -124,6 +124,8 @@ struct iio_ring_buffer { void iio_ring_buffer_init(struct iio_ring_buffer *ring, struct iio_dev *dev_info); +void iio_ring_buffer_deinit(struct iio_ring_buffer *ring); + /** * __iio_update_ring_buffer() - update common elements of ring buffers * @ring: ring buffer that is the event source @@ -137,70 +139,14 @@ static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring, ring->length = length; } -/* - * These are mainly provided to allow for a change of implementation if a device - * has a large number of scan elements - */ -#define IIO_MAX_SCAN_LENGTH 31 - -/* note 0 used as error indicator as it doesn't make sense. */ -static inline u32 iio_scan_mask_match(u32 *av_masks, u32 mask) -{ - while (*av_masks) { - if (!(~*av_masks & mask)) - return *av_masks; - av_masks++; - } - return 0; -} - -static inline int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit) -{ - struct iio_dev *dev_info = ring->indio_dev; - u32 mask; - - if (bit > IIO_MAX_SCAN_LENGTH) - return -EINVAL; - - if (!ring->scan_mask) - return 0; - - if (dev_info->available_scan_masks) - mask = iio_scan_mask_match(dev_info->available_scan_masks, - ring->scan_mask); - else - mask = ring->scan_mask; - - if (!mask) - return -EINVAL; - - return !!(mask & (1 << bit)); -}; +int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit); /** * iio_scan_mask_set() - set particular bit in the scan mask * @ring: the ring buffer whose scan mask we are interested in * @bit: the bit to be set. **/ -static inline int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) -{ - struct iio_dev *dev_info = ring->indio_dev; - u32 mask; - u32 trialmask = ring->scan_mask | (1 << bit); - - if (bit > IIO_MAX_SCAN_LENGTH) - return -EINVAL; - if (dev_info->available_scan_masks) { - mask = iio_scan_mask_match(dev_info->available_scan_masks, - trialmask); - if (!mask) - return -EINVAL; - } - ring->scan_mask = trialmask; - ring->scan_count++; - - return 0; -}; +int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit); #define to_iio_ring_buffer(d) \ container_of(d, struct iio_ring_buffer, dev) From 330c6c57e6284a755d7e8a031b3c917571ee6dc3 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:39 +0100 Subject: [PATCH 0793/1519] staging:iio:events - new 64 bit code structure and push out drivers. This costs us nothing in event storage (as we are carrying a 64 bit timestamp in the structure) and gives us lots more room to play with. Also allows for more channels which some parts need. V2: Cleanup some loose ends (such as the switch with only one option now). Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq_core.c | 8 +-- drivers/staging/iio/accel/sca3000_core.c | 10 ++-- drivers/staging/iio/adc/max1363_core.c | 10 ++-- drivers/staging/iio/chrdev.h | 2 +- drivers/staging/iio/iio.h | 39 +++++++------- drivers/staging/iio/industrialio-core.c | 59 ++++++---------------- drivers/staging/iio/light/tsl2563.c | 12 ++--- drivers/staging/iio/sysfs.h | 36 +++++++------ 8 files changed, 78 insertions(+), 98 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index ed07538d100..61d114a8b19 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -200,14 +200,14 @@ static u8 lis3l02dq_axis_map[3][3] = { }; static int lis3l02dq_read_thresh(struct iio_dev *indio_dev, - int e, + u64 e, int *val) { return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val); } static int lis3l02dq_write_thresh(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int val) { u16 value = val; @@ -534,7 +534,7 @@ static struct iio_chan_spec lis3l02dq_channels[] = { static ssize_t lis3l02dq_read_event_config(struct iio_dev *indio_dev, - int event_code) + u64 event_code) { u8 val; @@ -586,7 +586,7 @@ error_ret: } static int lis3l02dq_write_event_config(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int state) { int ret = 0; diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 3707acc6c79..e0407e24faa 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -695,7 +695,7 @@ static IIO_CONST_ATTR_TEMP_OFFSET("-214.6"); * sca3000_read_thresh() - query of a threshold **/ static int sca3000_read_thresh(struct iio_dev *indio_dev, - int e, + u64 e, int *val) { int ret, i; @@ -723,8 +723,8 @@ static int sca3000_read_thresh(struct iio_dev *indio_dev, * sca3000_write_thresh() control of threshold **/ static int sca3000_write_thresh(struct iio_dev *indio_dev, - int e, - int val) + u64 e, + int val) { struct sca3000_state *st = iio_priv(indio_dev); int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e); @@ -858,7 +858,7 @@ done: * sca3000_read_event_config() what events are enabled **/ static int sca3000_read_event_config(struct iio_dev *indio_dev, - int e) + u64 e) { struct sca3000_state *st = iio_priv(indio_dev); int ret; @@ -961,7 +961,7 @@ error_ret: * this mode is disabled. Currently normal mode is assumed. **/ static int sca3000_write_event_config(struct iio_dev *indio_dev, - int e, + u64 e, int state) { struct sca3000_state *st = iio_priv(indio_dev); diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 49b2ce22e6e..adbd89b9a57 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -553,7 +553,7 @@ static IIO_CONST_ATTR(sampling_frequency_available, "133000 665000 33300 16600 8300 4200 2000 1000"); static int max1363_read_thresh(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int *val) { struct max1363_state *st = iio_priv(indio_dev); @@ -565,7 +565,7 @@ static int max1363_read_thresh(struct iio_dev *indio_dev, } static int max1363_write_thresh(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int val) { struct max1363_state *st = iio_priv(indio_dev); @@ -593,7 +593,7 @@ static int max1363_write_thresh(struct iio_dev *indio_dev, return 0; } -static const int max1363_event_codes[] = { +static const u64 max1363_event_codes[] = { IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), @@ -624,7 +624,7 @@ static irqreturn_t max1363_event_handler(int irq, void *private) } static int max1363_read_event_config(struct iio_dev *indio_dev, - int event_code) + u64 event_code) { struct max1363_state *st = iio_priv(indio_dev); @@ -776,7 +776,7 @@ error_ret: } static int max1363_write_event_config(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int state) { int ret = 0; diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h index 28cce12346a..d8e736f6052 100644 --- a/drivers/staging/iio/chrdev.h +++ b/drivers/staging/iio/chrdev.h @@ -17,7 +17,7 @@ * the interrupt handler) */ struct iio_event_data { - int id; + u64 id; s64 timestamp; }; diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 635fa73e462..fad88fcad7e 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -48,19 +48,22 @@ enum iio_chan_type { #define IIO_IN IIO_VOLTAGE #define IIO_IN_DIFF IIO_VOLTAGE_DIFF -#define IIO_MOD_X 0 -#define IIO_MOD_LIGHT_BOTH 0 -#define IIO_MOD_Y 1 -#define IIO_MOD_LIGHT_IR 1 -#define IIO_MOD_Z 2 -#define IIO_MOD_X_AND_Y 3 -#define IIO_MOD_X_ANX_Z 4 -#define IIO_MOD_Y_AND_Z 5 -#define IIO_MOD_X_AND_Y_AND_Z 6 -#define IIO_MOD_X_OR_Y 7 -#define IIO_MOD_X_OR_Z 8 -#define IIO_MOD_Y_OR_Z 9 -#define IIO_MOD_X_OR_Y_OR_Z 10 +enum iio_modifier { + IIO_NO_MOD, + IIO_MOD_X, + IIO_MOD_Y, + IIO_MOD_Z, + IIO_MOD_X_AND_Y, + IIO_MOD_X_ANX_Z, + IIO_MOD_Y_AND_Z, + IIO_MOD_X_AND_Y_AND_Z, + IIO_MOD_X_OR_Y, + IIO_MOD_X_OR_Z, + IIO_MOD_Y_OR_Z, + IIO_MOD_X_OR_Y_OR_Z, + IIO_MOD_LIGHT_BOTH, + IIO_MOD_LIGHT_IR, +}; /* Could add the raw attributes as well - allowing buffer only devices */ enum iio_chan_info_enum { @@ -243,17 +246,17 @@ struct iio_info { long mask); int (*read_event_config)(struct iio_dev *indio_dev, - int event_code); + u64 event_code); int (*write_event_config)(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int state); int (*read_event_value)(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int *val); int (*write_event_value)(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int val); int (*validate_trigger)(struct iio_dev *indio_dev, struct iio_trigger *trig); @@ -328,7 +331,7 @@ void iio_device_unregister(struct iio_dev *dev_info); * @ev_code: What event * @timestamp: When the event occurred **/ -int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); +int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp); extern struct bus_type iio_bus_type; diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 5717f1945f4..2af056cc10a 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -71,15 +71,12 @@ static const char * const iio_chan_type_name_spec_complex[] = { [IIO_VOLTAGE_DIFF] = "voltage%d-voltage%d", }; -static const char * const iio_modifier_names_light[] = { - [IIO_MOD_LIGHT_BOTH] = "both", - [IIO_MOD_LIGHT_IR] = "ir", -}; - -static const char * const iio_modifier_names_axial[] = { +static const char * const iio_modifier_names[] = { [IIO_MOD_X] = "x", [IIO_MOD_Y] = "y", [IIO_MOD_Z] = "z", + [IIO_MOD_LIGHT_BOTH] = "both", + [IIO_MOD_LIGHT_IR] = "ir", }; /* relies on pairs of these shared then separate */ @@ -124,7 +121,7 @@ struct iio_event_interface { unsigned long flags; }; -int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp) +int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp) { struct iio_event_interface *ev_int = dev_info->event_interface; struct iio_detected_event_list *ev; @@ -409,32 +406,14 @@ static int __iio_build_postfix(struct iio_chan_spec const *chan, if (generic || (!chan->modified && !chan->extend_name)) { all_post = kasprintf(GFP_KERNEL, "%s", postfix); } else if (chan->modified) { - const char *intermediate; - switch (chan->type) { - case IIO_INTENSITY: - intermediate - = iio_modifier_names_light[chan->channel2]; - break; - case IIO_ACCEL: - case IIO_GYRO: - case IIO_MAGN: - case IIO_INCLI: - case IIO_ROT: - case IIO_ANGL: - intermediate - = iio_modifier_names_axial[chan->channel2]; - break; - default: - return -EINVAL; - } if (chan->extend_name) all_post = kasprintf(GFP_KERNEL, "%s_%s_%s", - intermediate, + iio_modifier_names[chan->channel2], chan->extend_name, postfix); else all_post = kasprintf(GFP_KERNEL, "%s_%s", - intermediate, + iio_modifier_names[chan->channel2], postfix); } else all_post = kasprintf(GFP_KERNEL, "%s_%s", chan->extend_name, @@ -824,28 +803,22 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, ret = -ENOMEM; goto error_ret; } - switch (chan->type) { - /* Switch this to a table at some point */ - case IIO_VOLTAGE: - mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, - i/IIO_EV_TYPE_MAX, - i%IIO_EV_TYPE_MAX); - break; - case IIO_ACCEL: + if (chan->modified) mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel, i/IIO_EV_TYPE_MAX, i%IIO_EV_TYPE_MAX); - break; - case IIO_VOLTAGE_DIFF: - mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel, + else if (chan->type == IIO_VOLTAGE_DIFF) + mask = IIO_MOD_EVENT_CODE(chan->type, + chan->channel, chan->channel2, i/IIO_EV_TYPE_MAX, i%IIO_EV_TYPE_MAX); - break; - default: - printk(KERN_INFO "currently unhandled type of event\n"); - continue; - } + else + mask = IIO_UNMOD_EVENT_CODE(chan->type, + chan->channel, + i/IIO_EV_TYPE_MAX, + i%IIO_EV_TYPE_MAX); + ret = __iio_add_chan_devattr(postfix, "events", chan, diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 2d01738c3de..7a57791521f 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -549,8 +549,8 @@ static const struct iio_chan_spec tsl2563_channels[] = { }; static int tsl2563_read_thresh(struct iio_dev *indio_dev, - int event_code, - int *val) + u64 event_code, + int *val) { struct tsl2563_chip *chip = iio_priv(indio_dev); @@ -569,7 +569,7 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev, } static ssize_t tsl2563_write_thresh(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int val) { struct tsl2563_chip *chip = iio_priv(indio_dev); @@ -617,8 +617,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) } static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, - int event_code, - int state) + u64 event_code, + int state) { struct tsl2563_chip *chip = iio_priv(indio_dev); int ret = 0; @@ -659,7 +659,7 @@ out: } static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, - int event_code) + u64 event_code) { struct tsl2563_chip *chip = iio_priv(indio_dev); int ret; diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 0b75823fbe1..30f9a4df848 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -114,36 +114,40 @@ struct iio_const_attr { #define IIO_CONST_ATTR_TEMP_SCALE(_string) \ IIO_CONST_ATTR(temp_scale, _string) -#define IIO_EV_TYPE_THRESH 0 -#define IIO_EV_TYPE_MAG 1 -#define IIO_EV_TYPE_ROC 2 +enum iio_event_type { + IIO_EV_TYPE_THRESH, + IIO_EV_TYPE_MAG, + IIO_EV_TYPE_ROC, +}; -#define IIO_EV_DIR_EITHER 0 -#define IIO_EV_DIR_RISING 1 -#define IIO_EV_DIR_FALLING 2 +enum iio_event_direction { + IIO_EV_DIR_EITHER, + IIO_EV_DIR_RISING, + IIO_EV_DIR_FALLING, +}; + +#define IIO_EVENT_CODE(chan_type, modifier, direction, \ + type, chan, chan1, chan2) \ + (((u64)type << 56) | ((u64)direction << 48) | ((u64)modifier << 40) | \ + ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan) #define IIO_EV_TYPE_MAX 8 #define IIO_EV_BIT(type, direction) \ (1 << (type*IIO_EV_TYPE_MAX + direction)) -#define IIO_EVENT_CODE(channelclass, orient_bit, number, \ - modifier, type, direction) \ - (channelclass | (orient_bit << 8) | ((number) << 9) | \ - ((modifier) << 13) | ((type) << 16) | ((direction) << 24)) - #define IIO_MOD_EVENT_CODE(channelclass, number, modifier, \ type, direction) \ - IIO_EVENT_CODE(channelclass, 1, number, modifier, type, direction) + IIO_EVENT_CODE(channelclass, modifier, direction, type, number, 0, 0) #define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction) \ - IIO_EVENT_CODE(channelclass, 0, number, 0, type, direction) + IIO_EVENT_CODE(channelclass, 0, direction, type, number, 0, 0) -#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 24) & 0xf) +#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xFF) /* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ -#define IIO_EVENT_CODE_EXTRACT_NUM(mask) ((mask >> 9) & 0x0f) +#define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF) -#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 13) & 0x7) +#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF) #endif /* _INDUSTRIAL_IO_SYSFS_H_ */ From 26d25ae3f0d8ffe350aacc75b71198d6b35bd1f4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:40 +0100 Subject: [PATCH 0794/1519] staging:iio: rework of attribute registration. This set also includes quite a number of bug fixes of particularly remove functions. Necessary due to issue pointed out in Bart Van Assche's patch: docs/driver-model: Document device.groups V2: Rebase due to patch reordering. V3: Pull various error fixes and cleanups out into their own patches. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 16 +- drivers/staging/iio/accel/adis16203_core.c | 17 +- drivers/staging/iio/accel/adis16204_core.c | 16 +- drivers/staging/iio/accel/adis16209_core.c | 16 +- drivers/staging/iio/accel/adis16240_core.c | 15 +- drivers/staging/iio/accel/lis3l02dq_core.c | 18 +- drivers/staging/iio/adc/ad7150.c | 20 +- drivers/staging/iio/adc/ad7291.c | 12 +- drivers/staging/iio/adc/ad7298_core.c | 18 +- drivers/staging/iio/adc/ad7476_core.c | 16 +- drivers/staging/iio/adc/ad7606_core.c | 17 +- drivers/staging/iio/adc/ad7745.c | 18 +- drivers/staging/iio/adc/ad7793.c | 16 +- drivers/staging/iio/adc/ad7816.c | 15 +- drivers/staging/iio/adc/ad7887_core.c | 20 +- drivers/staging/iio/adc/ad799x_core.c | 17 +- drivers/staging/iio/adc/adt7310.c | 12 +- drivers/staging/iio/adc/adt7410.c | 11 +- drivers/staging/iio/adc/adt75.c | 12 +- drivers/staging/iio/adc/max1363_core.c | 18 +- drivers/staging/iio/addac/adt7316.c | 13 +- drivers/staging/iio/dac/ad5504.c | 40 ++-- drivers/staging/iio/dac/ad5624r_spi.c | 1 - drivers/staging/iio/dac/ad5686.c | 13 +- drivers/staging/iio/dac/ad5791.c | 2 + drivers/staging/iio/gyro/adis16060_core.c | 8 +- drivers/staging/iio/gyro/adis16080_core.c | 9 +- drivers/staging/iio/gyro/adis16260_core.c | 15 +- drivers/staging/iio/iio.h | 7 + drivers/staging/iio/iio_core.h | 1 - .../staging/iio/impedance-analyzer/ad5933.c | 16 +- drivers/staging/iio/imu/adis16400_core.c | 16 +- drivers/staging/iio/industrialio-core.c | 226 +++++++++--------- drivers/staging/iio/industrialio-ring.c | 105 ++++---- drivers/staging/iio/industrialio-trigger.c | 8 +- drivers/staging/iio/light/tsl2563.c | 9 +- drivers/staging/iio/meter/ade7753.c | 17 +- drivers/staging/iio/meter/ade7754.c | 16 +- drivers/staging/iio/meter/ade7758_core.c | 18 +- drivers/staging/iio/meter/ade7759.c | 12 +- drivers/staging/iio/resolver/ad2s1210.c | 1 + drivers/staging/iio/ring_generic.h | 3 +- 42 files changed, 388 insertions(+), 488 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 1e19aba115e..2785460b385 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -463,7 +463,7 @@ static const struct iio_info adis16201_info = { static int __devinit adis16201_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16201_state *st; struct iio_dev *indio_dev; @@ -492,11 +492,6 @@ static int __devinit adis16201_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, adis16201_channels, ARRAY_SIZE(adis16201_channels)); @@ -515,6 +510,10 @@ static int __devinit adis16201_probe(struct spi_device *spi) ret = adis16201_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_remove_trigger; return 0; error_remove_trigger: @@ -524,10 +523,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16201_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 2a658f0e788..27079a95d4b 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -419,7 +419,7 @@ static const struct iio_info adis16203_info = { static int __devinit adis16203_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct iio_dev *indio_dev; struct adis16203_state *st; @@ -446,11 +446,6 @@ static int __devinit adis16203_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, adis16203_channels, ARRAY_SIZE(adis16203_channels)); @@ -469,6 +464,11 @@ static int __devinit adis16203_probe(struct spi_device *spi) ret = adis16203_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -478,10 +478,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16203_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 42a37bb0136..e0b87840133 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -494,7 +494,7 @@ static const struct iio_info adis16204_info = { static int __devinit adis16204_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16204_state *st; struct iio_dev *indio_dev; @@ -521,11 +521,6 @@ static int __devinit adis16204_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, adis16204_channels, ARRAY_SIZE(adis16204_channels)); @@ -544,6 +539,10 @@ static int __devinit adis16204_probe(struct spi_device *spi) ret = adis16204_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -553,10 +552,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16204_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index d59a9e4803b..377c6d790ca 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -467,7 +467,7 @@ static const struct iio_info adis16209_info = { static int __devinit adis16209_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16209_state *st; struct iio_dev *indio_dev; @@ -494,11 +494,6 @@ static int __devinit adis16209_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, adis16209_channels, ARRAY_SIZE(adis16209_channels)); @@ -517,6 +512,10 @@ static int __devinit adis16209_probe(struct spi_device *spi) ret = adis16209_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -526,10 +525,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16209_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index b6504f1479b..0dd02a3ba15 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -519,7 +519,7 @@ static const struct iio_info adis16240_info = { static int __devinit adis16240_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16240_state *st; struct iio_dev *indio_dev; @@ -547,11 +547,6 @@ static int __devinit adis16240_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, adis16240_channels, ARRAY_SIZE(adis16240_channels)); @@ -568,6 +563,9 @@ static int __devinit adis16240_probe(struct spi_device *spi) /* Get the device into a sane initial state */ ret = adis16240_initial_setup(indio_dev); + if (ret) + goto error_remove_trigger; + ret = iio_device_register(indio_dev); if (ret) goto error_remove_trigger; return 0; @@ -579,10 +577,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16240_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 61d114a8b19..ee91cc719bc 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -663,7 +663,7 @@ static const struct iio_info lis3l02dq_info = { static int __devinit lis3l02dq_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct lis3l02dq_state *st; struct iio_dev *indio_dev; @@ -690,11 +690,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, lis3l02dq_channels, ARRAY_SIZE(lis3l02dq_channels)); @@ -722,6 +717,11 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) ret = lis3l02dq_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -735,9 +735,6 @@ error_uninitialize_ring: error_unreg_ring_funcs: lis3l02dq_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else iio_free_device(indio_dev); error_ret: return ret; @@ -790,9 +787,8 @@ static int lis3l02dq_remove(struct spi_device *spi) lis3l02dq_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); lis3l02dq_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); - return 0; + iio_device_unregister(indio_dev); err_ret: return ret; diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index d70623c1048..3d154b87f55 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -719,7 +719,7 @@ static const struct iio_info ad7150_info = { static int __devinit ad7150_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret = 0, regdone = 0; + int ret; struct ad7150_chip_info *chip; struct iio_dev *indio_dev; @@ -742,11 +742,6 @@ static int __devinit ad7150_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - regdone = 1; - if (client->irq) { ret = request_threaded_irq(client->irq, NULL, @@ -759,15 +754,20 @@ static int __devinit ad7150_probe(struct i2c_client *client, goto error_free_dev; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; + + dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq); return 0; +error_free_irq: + if (client->irq) + free_irq(client->irq, indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 16ddbdec912..46a891d4d2e 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -811,10 +811,6 @@ static int __devinit ad7291_probe(struct i2c_client *client, indio_dev->info = &ad7291_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - if (client->irq > 0) { ret = request_threaded_irq(client->irq, NULL, @@ -823,7 +819,7 @@ static int __devinit ad7291_probe(struct i2c_client *client, id->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; /* set irq polarity low level */ chip->command |= AD7291_ALART_POLARITY; @@ -835,6 +831,10 @@ static int __devinit ad7291_probe(struct i2c_client *client, goto error_unreg_irq; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_irq; + dev_info(&client->dev, "%s temperature sensor registered.\n", id->name); @@ -842,8 +842,6 @@ static int __devinit ad7291_probe(struct i2c_client *client, error_unreg_irq: free_irq(client->irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 6487359dc4c..a627bfe208a 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -165,7 +165,7 @@ static int __devinit ad7298_probe(struct spi_device *spi) { struct ad7298_platform_data *pdata = spi->dev.platform_data; struct ad7298_state *st; - int ret, regdone = 0; + int ret; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) @@ -218,19 +218,19 @@ static int __devinit ad7298_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, &ad7298_channels[1], /* skip temp0 */ ARRAY_SIZE(ad7298_channels) - 1); if (ret) goto error_cleanup_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; return 0; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7298_ring_cleanup(indio_dev); error_disable_reg: @@ -239,11 +239,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 7329b009a71..edf25ce8970 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -129,7 +129,6 @@ static int __devinit ad7476_probe(struct spi_device *spi) struct ad7476_state *st; struct iio_dev *indio_dev; int ret, voltage_uv = 0; - bool reg_done = false; indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -180,28 +179,29 @@ static int __devinit ad7476_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, st->chip_info->channel, ARRAY_SIZE(st->chip_info->channel)); if (ret) goto error_cleanup_ring; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_ring_unregister; return 0; +error_ring_unregister: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7476_ring_cleanup(indio_dev); - iio_device_unregister(indio_dev); error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (!reg_done) - iio_free_device(indio_dev); + iio_free_device(indio_dev); + error_ret: return ret; } diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 7b43da93d77..bea663dc25d 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -439,7 +439,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, { struct ad7606_platform_data *pdata = dev->platform_data; struct ad7606_state *st; - int ret, regdone = 0; + int ret; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -501,18 +501,18 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, if (ret) goto error_free_irq; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_irq; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_cleanup_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; return indio_dev; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7606_ring_cleanup(indio_dev); @@ -529,10 +529,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ERR_PTR(ret); } diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 41150c60c20..eea77f1603d 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -578,7 +578,7 @@ static const struct iio_info ad774x_info = { static int __devinit ad774x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret = 0, regdone = 0; + int ret; struct ad774x_chip_info *chip; struct iio_dev *indio_dev; @@ -599,11 +599,6 @@ static int __devinit ad774x_probe(struct i2c_client *client, indio_dev->info = &ad774x_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - regdone = 1; - if (client->irq) { ret = request_threaded_irq(client->irq, NULL, @@ -615,15 +610,18 @@ static int __devinit ad774x_probe(struct i2c_client *client, goto error_free_dev; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; + dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq); return 0; +error_free_irq: + free_irq(client->irq, indio_dev); error_free_dev: - if (regdone) - free_irq(client->irq, indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index b42a7ace426..17d18fc7b46 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -827,7 +827,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) struct ad7793_platform_data *pdata = spi->dev.platform_data; struct ad7793_state *st; struct iio_dev *indio_dev; - int ret, i, voltage_uv = 0, regdone = 0; + int ret, i, voltage_uv = 0; if (!pdata) { dev_err(&spi->dev, "no platform data?\n"); @@ -890,11 +890,6 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring; - regdone = 1; - ret = ad7793_probe_trigger(indio_dev); if (ret) goto error_unreg_ring; @@ -909,6 +904,10 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_uninitialize_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_uninitialize_ring; + return 0; error_uninitialize_ring: @@ -924,10 +923,7 @@ error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 5a4586fbe14..deec8f245f9 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -396,10 +396,6 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev) indio_dev->info = &ad7816_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_gpio; - if (spi_dev->irq) { /* Only low trigger is supported in ad7816/7/8 */ ret = request_threaded_irq(spi_dev->irq, @@ -409,16 +405,19 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev) indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_gpio; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; + dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n", indio_dev->name); return 0; - -error_unreg_dev: - iio_device_unregister(indio_dev); +error_free_irq: + free_irq(spi_dev->irq, indio_dev); error_free_gpio: gpio_free(chip->busy_pin); error_free_gpio_convert: diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index e71d0884901..cdd7c130aa1 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -93,7 +93,7 @@ static int __devinit ad7887_probe(struct spi_device *spi) { struct ad7887_platform_data *pdata = spi->dev.platform_data; struct ad7887_state *st; - int ret, voltage_uv = 0, regdone = 0; + int ret, voltage_uv = 0; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) @@ -189,18 +189,19 @@ static int __devinit ad7887_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_cleanup_ring; - return 0; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; + + return 0; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7887_ring_cleanup(indio_dev); error_disable_reg: @@ -209,10 +210,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index cfe4b2caea8..75b8c37ca1e 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -657,7 +657,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { static int __devinit ad799x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, regdone = 0; + int ret; struct ad799x_platform_data *pdata = client->dev.platform_data; struct ad799x_state *st; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -701,11 +701,6 @@ static int __devinit ad799x_probe(struct i2c_client *client, if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); @@ -723,9 +718,14 @@ static int __devinit ad799x_probe(struct i2c_client *client, if (ret) goto error_cleanup_ring; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; return 0; +error_free_irq: + free_irq(client->irq, indio_dev); error_cleanup_ring: ad799x_ring_cleanup(indio_dev); error_disable_reg: @@ -734,10 +734,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index edc65c517f6..cbbd34922d4 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -782,10 +782,6 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) indio_dev->info = &adt7310_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - /* CT critcal temperature event. line 0 */ if (spi_dev->irq) { if (adt7310_platform_data[2]) @@ -799,7 +795,7 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; } /* INT bound temperature alarm event. line 1 */ @@ -836,6 +832,10 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_int_irq; + dev_info(&spi_dev->dev, "%s temperature sensor registered.\n", indio_dev->name); @@ -845,8 +845,6 @@ error_unreg_int_irq: free_irq(adt7310_platform_data[0], indio_dev); error_unreg_ct_irq: free_irq(spi_dev->irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index e7e9e25d1e9..cc913bc3510 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -749,10 +749,6 @@ static int __devinit adt7410_probe(struct i2c_client *client, indio_dev->info = &adt7410_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - /* CT critcal temperature event. line 0 */ if (client->irq) { ret = request_threaded_irq(client->irq, @@ -762,7 +758,7 @@ static int __devinit adt7410_probe(struct i2c_client *client, id->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; } /* INT bound temperature alarm event. line 1 */ @@ -799,6 +795,9 @@ static int __devinit adt7410_probe(struct i2c_client *client, goto error_unreg_int_irq; } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_int_irq; dev_info(&client->dev, "%s temperature sensor registered.\n", id->name); @@ -809,8 +808,6 @@ error_unreg_int_irq: free_irq(adt7410_platform_data[0], indio_dev); error_unreg_ct_irq: free_irq(client->irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index b56bfcdb337..08215e9edc8 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -567,10 +567,6 @@ static int __devinit adt75_probe(struct i2c_client *client, indio_dev->info = &adt75_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - if (client->irq > 0) { ret = request_threaded_irq(client->irq, NULL, @@ -579,7 +575,7 @@ static int __devinit adt75_probe(struct i2c_client *client, indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; ret = adt75_i2c_read(indio_dev, ADT75_CONFIG, &chip->config); if (ret) { @@ -597,14 +593,16 @@ static int __devinit adt75_probe(struct i2c_client *client, } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_irq; + dev_info(&client->dev, "%s temperature sensor registered.\n", indio_dev->name); return 0; error_unreg_irq: free_irq(client->irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index adbd89b9a57..9962f594d3a 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1254,7 +1254,7 @@ static int max1363_initial_setup(struct max1363_state *st) static int __devinit max1363_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, i, regdone = 0; + int ret, i; struct max1363_state *st; struct iio_dev *indio_dev; struct regulator *reg; @@ -1312,10 +1312,6 @@ static int __devinit max1363_probe(struct i2c_client *client, if (ret) goto error_free_available_scan_masks; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - regdone = 1; ret = iio_ring_buffer_register(indio_dev, st->chip_info->channels, st->chip_info->num_channels); @@ -1334,8 +1330,13 @@ static int __devinit max1363_probe(struct i2c_client *client, goto error_uninit_ring; } - return 0; + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_free_irq; + return 0; +error_free_irq: + free_irq(st->client->irq, indio_dev); error_uninit_ring: iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: @@ -1343,10 +1344,7 @@ error_cleanup_ring: error_free_available_scan_masks: kfree(indio_dev->available_scan_masks); error_free_device: - if (!regdone) - iio_free_device(indio_dev); - else - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); error_disable_reg: regulator_disable(reg); error_put_reg: diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index e60a9d65821..17b6c1332ae 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2167,10 +2167,6 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) chip->bus.irq_flags = adt7316_platform_data[0]; @@ -2182,7 +2178,7 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; @@ -2200,6 +2196,10 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, goto error_unreg_irq; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_irq; + dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n", indio_dev->name); @@ -2207,8 +2207,6 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, error_unreg_irq: free_irq(chip->bus.irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: @@ -2221,7 +2219,6 @@ int __devexit adt7316_remove(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adt7316_chip_info *chip = iio_priv(indio_dev); - dev_set_drvdata(dev, NULL); if (chip->bus.irq) free_irq(chip->bus.irq, indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 9a421f2aceb..c528dff5b5b 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -282,6 +282,11 @@ static int __devinit ad5504_probe(struct spi_device *spi) struct regulator *reg; int ret, voltage_uv = 0; + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) { + ret = -ENOMEM; + goto error_ret; + } reg = regulator_get(&spi->dev, "vcc"); if (!IS_ERR(reg)) { ret = regulator_enable(reg); @@ -291,11 +296,6 @@ static int __devinit ad5504_probe(struct spi_device *spi) voltage_uv = regulator_get_voltage(reg); } - indio_dev = iio_allocate_device(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_disable_reg; - } spi_set_drvdata(spi, indio_dev); st = iio_priv(indio_dev); if (voltage_uv) @@ -315,10 +315,6 @@ static int __devinit ad5504_probe(struct spi_device *spi) indio_dev->info = &ad5504_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - if (spi->irq) { ret = request_threaded_irq(spi->irq, NULL, @@ -327,15 +323,17 @@ static int __devinit ad5504_probe(struct spi_device *spi) spi_get_device_id(st->spi)->name, indio_dev); if (ret) - goto error_unreg_iio_device; + goto error_disable_reg; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; + return 0; -error_unreg_iio_device: - iio_device_unregister(indio_dev); -error_free_dev: - iio_free_device(indio_dev); +error_free_irq: + free_irq(spi->irq, indio_dev); error_disable_reg: if (!IS_ERR(reg)) regulator_disable(reg); @@ -343,6 +341,8 @@ error_put_reg: if (!IS_ERR(reg)) regulator_put(reg); + iio_free_device(indio_dev); +error_ret: return ret; } @@ -350,17 +350,17 @@ static int __devexit ad5504_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5504_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; + if (spi->irq) free_irq(spi->irq, indio_dev); - iio_device_unregister(indio_dev); - - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_device_unregister(indio_dev); + return 0; } diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index 0f1d431c6fa..e5edf590f92 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -272,7 +272,6 @@ static int __devinit ad5624r_probe(struct spi_device *spi) return 0; - error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index c32789f1c15..6e768206a87 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -393,16 +393,16 @@ static int __devinit ad5686_probe(struct spi_device *spi) indio_dev->channels = st->chip_info->channel; indio_dev->num_channels = AD5686_DAC_CHANNELS; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - regdone = 1; ret = ad5686_spi_write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, !!voltage_uv, 0); if (ret) goto error_disable_reg; + ret = iio_device_register(indio_dev); + if (ret) + goto error_disable_reg; + return 0; error_disable_reg: @@ -412,10 +412,7 @@ error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 5a5de973139..74f54068724 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -396,6 +396,8 @@ static int __devexit ad5791_remove(struct spi_device *spi) } iio_device_unregister(indio_dev); + iio_device_unregister(indio_dev); + return 0; } diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 3f5087329e5..481080588b1 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -143,7 +143,7 @@ static const struct iio_chan_spec adis16060_channels[] = { static int __devinit adis16060_r_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16060_state *st; struct iio_dev *indio_dev; @@ -169,16 +169,12 @@ static int __devinit adis16060_r_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - regdone = 1; adis16060_iio_dev = indio_dev; return 0; error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index 16ba0e11e44..826f8f1db0d 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -137,7 +137,7 @@ static const struct iio_info adis16080_info = { static int __devinit adis16080_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16080_state *st; struct iio_dev *indio_dev; @@ -165,15 +165,10 @@ static int __devinit adis16080_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - regdone = 1; - return 0; error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index acd17e50df5..73157b21252 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -577,7 +577,7 @@ static const struct iio_info adis16260_info = { static int __devinit adis16260_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16260_platform_data *pd = spi->dev.platform_data; struct adis16260_state *st; struct iio_dev *indio_dev; @@ -625,10 +625,6 @@ static int __devinit adis16260_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, ARRAY_SIZE(adis16260_channels_x)); @@ -654,6 +650,10 @@ static int __devinit adis16260_probe(struct spi_device *spi) ret = adis16260_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -663,10 +663,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16260_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index fad88fcad7e..a59988fd836 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -283,9 +283,12 @@ struct iio_info { * @num_channels: [DRIVER] number of chanels specified in @channels. * @channel_attr_list: [INTERN] keep track of automatically created channel * attributes + * @chan_attr_group: [INTERN] group for all attrs in base directory * @name: [DRIVER] name of the device. * @info: [DRIVER] callbacks and constant info from driver * @chrdev: [INTERN] associated character device + * @groups: [INTERN] attribute groups + * @groupcounter: [INTERN] index of next attribute group **/ struct iio_dev { int id; @@ -308,9 +311,13 @@ struct iio_dev { int num_channels; struct list_head channel_attr_list; + struct attribute_group chan_attr_group; const char *name; const struct iio_info *info; struct cdev chrdev; +#define IIO_MAX_GROUPS 6 + const struct attribute_group *groups[IIO_MAX_GROUPS + 1]; + int groupcounter; }; /** diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index d7eb0d81ee1..3a80dbf2220 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -14,7 +14,6 @@ #define _IIO_CORE_H_ int __iio_add_chan_devattr(const char *postfix, - const char *group, struct iio_chan_spec const *chan, ssize_t (*func)(struct device *dev, struct device_attribute *attr, diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index e199bbed75e..65399d1467c 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -675,7 +675,7 @@ static void ad5933_work(struct work_struct *work) static int __devinit ad5933_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, regdone = 0, voltage_uv = 0; + int ret, voltage_uv = 0; struct ad5933_platform_data *pdata = client->dev.platform_data; struct ad5933_state *st; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -727,11 +727,6 @@ static int __devinit ad5933_probe(struct i2c_client *client, if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring; - regdone = 1; - /* skip temp0_input, register in0_(real|imag)_raw */ ret = iio_ring_buffer_register(indio_dev, &ad5933_channels[1], 2); if (ret) @@ -745,6 +740,10 @@ static int __devinit ad5933_probe(struct i2c_client *client, if (ret) goto error_uninitialize_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_uninitialize_ring; + return 0; error_uninitialize_ring: @@ -758,10 +757,7 @@ error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 3e8fcd3354f..0fca3bf8ef3 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -821,7 +821,7 @@ static const struct iio_info adis16400_info = { static int __devinit adis16400_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16400_state *st; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -848,11 +848,6 @@ static int __devinit adis16400_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, st->variant->channels, st->variant->num_channels); @@ -871,6 +866,10 @@ static int __devinit adis16400_probe(struct spi_device *spi) ret = adis16400_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -881,10 +880,7 @@ error_uninitialize_ring: error_unreg_ring_funcs: adis16400_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 2af056cc10a..49322bf5ac3 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -119,6 +119,7 @@ struct iio_event_interface { int current_events; struct list_head dev_attr_list; unsigned long flags; + struct attribute_group group; }; int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp) @@ -506,7 +507,6 @@ static void __iio_device_attr_deinit(struct device_attribute *dev_attr) } int __iio_add_chan_devattr(const char *postfix, - const char *group, struct iio_chan_spec const *chan, ssize_t (*readfunc)(struct device *dev, struct device_attribute *attr, @@ -544,12 +544,6 @@ int __iio_add_chan_devattr(const char *postfix, ret = -EBUSY; goto error_device_attr_deinit; } - - ret = sysfs_add_file_to_group(&dev->kobj, - &iio_attr->dev_attr.attr, group); - if (ret < 0) - goto error_device_attr_deinit; - list_add(&iio_attr->l, attr_list); return 0; @@ -565,13 +559,13 @@ error_ret: static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret, i; + int ret, i, attrcount = 0; if (chan->channel < 0) return 0; ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val], - NULL, chan, + chan, &iio_read_channel_info, (chan->output ? &iio_write_channel_info : NULL), @@ -581,10 +575,11 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, &dev_info->channel_attr_list); if (ret) goto error_ret; + attrcount++; for_each_set_bit(i, &chan->info_mask, sizeof(long)*8) { ret = __iio_add_chan_devattr(iio_chan_info_postfix[i/2], - NULL, chan, + chan, &iio_read_channel_info, &iio_write_channel_info, (1 << i), @@ -597,7 +592,9 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, } if (ret < 0) goto error_ret; + attrcount++; } + ret = attrcount; error_ret: return ret; } @@ -605,8 +602,6 @@ error_ret: static void iio_device_remove_and_free_read_attr(struct iio_dev *dev_info, struct iio_dev_attr *p) { - sysfs_remove_file_from_group(&dev_info->dev.kobj, - &p->dev_attr.attr, NULL); kfree(p->dev_attr.attr.name); kfree(p); } @@ -621,31 +616,19 @@ static ssize_t iio_show_dev_name(struct device *dev, static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); -static struct attribute *iio_base_dummy_attrs[] = { - NULL -}; -static struct attribute_group iio_base_dummy_group = { - .attrs = iio_base_dummy_attrs, -}; - static int iio_device_register_sysfs(struct iio_dev *dev_info) { - int i, ret = 0; + int i, ret = 0, attrcount, attrn, attrcount_orig = 0; struct iio_dev_attr *p, *n; + struct attribute **attr; - if (dev_info->info->attrs) - ret = sysfs_create_group(&dev_info->dev.kobj, - dev_info->info->attrs); - else - ret = sysfs_create_group(&dev_info->dev.kobj, - &iio_base_dummy_group); - - if (ret) { - dev_err(dev_info->dev.parent, - "Failed to register sysfs hooks\n"); - goto error_ret; + /* First count elements in any existing group */ + if (dev_info->info->attrs) { + attr = dev_info->info->attrs->attrs; + while (*attr++ != NULL) + attrcount_orig++; } - + attrcount = attrcount_orig; /* * New channel registration method - relies on the fact a group does * not need to be initialized if it is name is NULL. @@ -658,14 +641,36 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) ->channels[i]); if (ret < 0) goto error_clear_attrs; + attrcount += ret; } - if (dev_info->name) { - ret = sysfs_add_file_to_group(&dev_info->dev.kobj, - &dev_attr_name.attr, - NULL); - if (ret) - goto error_clear_attrs; + + if (dev_info->name) + attrcount++; + + dev_info->chan_attr_group.attrs + = kzalloc(sizeof(dev_info->chan_attr_group.attrs[0])* + (attrcount + 1), + GFP_KERNEL); + if (dev_info->chan_attr_group.attrs == NULL) { + ret = -ENOMEM; + goto error_clear_attrs; } + /* Copy across original attributes */ + if (dev_info->info->attrs) + memcpy(dev_info->chan_attr_group.attrs, + dev_info->info->attrs->attrs, + sizeof(dev_info->chan_attr_group.attrs[0]) + *attrcount_orig); + attrn = attrcount_orig; + /* Add all elements from the list. */ + list_for_each_entry(p, &dev_info->channel_attr_list, l) + dev_info->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr; + if (dev_info->name) + dev_info->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr; + + dev_info->groups[dev_info->groupcounter++] = + &dev_info->chan_attr_group; + return 0; error_clear_attrs: @@ -674,32 +679,20 @@ error_clear_attrs: list_del(&p->l); iio_device_remove_and_free_read_attr(dev_info, p); } - if (dev_info->info->attrs) - sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); - else - sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group); -error_ret: - return ret; + return ret; } static void iio_device_unregister_sysfs(struct iio_dev *dev_info) { struct iio_dev_attr *p, *n; - if (dev_info->name) - sysfs_remove_file_from_group(&dev_info->dev.kobj, - &dev_attr_name.attr, - NULL); + list_for_each_entry_safe(p, n, &dev_info->channel_attr_list, l) { list_del(&p->l); iio_device_remove_and_free_read_attr(dev_info, p); } - - if (dev_info->info->attrs) - sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); - else - sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group); + kfree(dev_info->chan_attr_group.attrs); } static const char * const iio_ev_type_text[] = { @@ -790,7 +783,7 @@ static ssize_t iio_ev_value_store(struct device *dev, static int iio_device_add_event_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret = 0, i, mask = 0; + int ret = 0, i, mask = 0, attrcount = 0; char *postfix; if (!chan->event_mask) return 0; @@ -820,7 +813,6 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, i%IIO_EV_TYPE_MAX); ret = __iio_add_chan_devattr(postfix, - "events", chan, &iio_ev_state_show, iio_ev_state_store, @@ -832,7 +824,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, kfree(postfix); if (ret) goto error_ret; - + attrcount++; postfix = kasprintf(GFP_KERNEL, "%s_%s_value", iio_ev_type_text[i/IIO_EV_TYPE_MAX], iio_ev_dir_text[i%IIO_EV_TYPE_MAX]); @@ -840,7 +832,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, ret = -ENOMEM; goto error_ret; } - ret = __iio_add_chan_devattr(postfix, "events", chan, + ret = __iio_add_chan_devattr(postfix, chan, iio_ev_value_show, iio_ev_value_store, mask, @@ -851,9 +843,9 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, kfree(postfix); if (ret) goto error_ret; - + attrcount++; } - + ret = attrcount; error_ret: return ret; } @@ -864,9 +856,6 @@ static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info) list_for_each_entry_safe(p, n, &dev_info->event_interface-> dev_attr_list, l) { - sysfs_remove_file_from_group(&dev_info->dev.kobj, - &p->dev_attr.attr, - NULL); kfree(p->dev_attr.attr.name); kfree(p); } @@ -874,18 +863,18 @@ static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info) static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info) { - int j; - int ret; + int j, ret, attrcount = 0; INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list); /* Dynically created from the channels array */ for (j = 0; j < dev_info->num_channels; j++) { ret = iio_device_add_event_sysfs(dev_info, &dev_info->channels[j]); - if (ret) + if (ret < 0) goto error_clear_attrs; + attrcount += ret; } - return 0; + return attrcount; error_clear_attrs: __iio_remove_event_config_attrs(dev_info); @@ -893,15 +882,6 @@ error_clear_attrs: return ret; } -static struct attribute *iio_events_dummy_attrs[] = { - NULL -}; - -static struct attribute_group iio_events_dummy_group = { - .name = "events", - .attrs = iio_events_dummy_attrs -}; - static bool iio_check_for_dynamic_events(struct iio_dev *dev_info) { int j; @@ -922,9 +902,12 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int) init_waitqueue_head(&ev_int->wait); } +static const char *iio_event_group_name = "events"; static int iio_device_register_eventset(struct iio_dev *dev_info) { - int ret = 0; + struct iio_dev_attr *p; + int ret = 0, attrcount_orig = 0, attrcount, attrn; + struct attribute **attr; if (!(dev_info->info->event_attrs || iio_check_for_dynamic_events(dev_info))) @@ -938,41 +921,48 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) } iio_setup_ev_int(dev_info->event_interface); - if (dev_info->info->event_attrs != NULL) - ret = sysfs_create_group(&dev_info->dev.kobj, - dev_info->info->event_attrs); - else - ret = sysfs_create_group(&dev_info->dev.kobj, - &iio_events_dummy_group); - if (ret) { - dev_err(&dev_info->dev, - "Failed to register sysfs for event attrs"); - goto error_free_setup_event_lines; + if (dev_info->info->event_attrs != NULL) { + attr = dev_info->info->event_attrs->attrs; + while (*attr++ != NULL) + attrcount_orig++; } + attrcount = attrcount_orig; if (dev_info->channels) { ret = __iio_add_event_config_attrs(dev_info); - if (ret) { - if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info->dev.kobj, - dev_info->info - ->event_attrs); - else - sysfs_remove_group(&dev_info->dev.kobj, - &iio_events_dummy_group); + if (ret < 0) goto error_free_setup_event_lines; - } + attrcount += ret; } + dev_info->event_interface->group.name = iio_event_group_name; + dev_info->event_interface->group.attrs = + kzalloc(sizeof(dev_info->event_interface->group.attrs[0]) + *(attrcount + 1), + GFP_KERNEL); + if (dev_info->event_interface->group.attrs == NULL) { + ret = -ENOMEM; + goto error_free_setup_event_lines; + } + if (dev_info->info->event_attrs) + memcpy(dev_info->event_interface->group.attrs, + dev_info->info->event_attrs->attrs, + sizeof(dev_info->event_interface->group.attrs[0]) + *attrcount_orig); + attrn = attrcount_orig; + /* Add all elements from the list. */ + list_for_each_entry(p, + &dev_info->event_interface->dev_attr_list, + l) + dev_info->event_interface->group.attrs[attrn++] = + &p->dev_attr.attr; + + dev_info->groups[dev_info->groupcounter++] = + &dev_info->event_interface->group; + return 0; error_free_setup_event_lines: __iio_remove_event_config_attrs(dev_info); - if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info->dev.kobj, - dev_info->info->event_attrs); - else - sysfs_remove_group(&dev_info->dev.kobj, - &iio_events_dummy_group); kfree(dev_info->event_interface); error_ret: @@ -984,12 +974,7 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) if (dev_info->event_interface == NULL) return; __iio_remove_event_config_attrs(dev_info); - if (dev_info->info->event_attrs != NULL) - sysfs_remove_group(&dev_info->dev.kobj, - dev_info->info->event_attrs); - else - sysfs_remove_group(&dev_info->dev.kobj, - &iio_events_dummy_group); + kfree(dev_info->event_interface->group.attrs); kfree(dev_info->event_interface); } @@ -997,6 +982,11 @@ static void iio_dev_release(struct device *device) { struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); cdev_del(&dev_info->chrdev); + if (dev_info->modes & INDIO_RING_TRIGGERED) + iio_device_unregister_trigger_consumer(dev_info); + iio_device_unregister_eventset(dev_info); + iio_device_unregister_sysfs(dev_info); + ida_simple_remove(&iio_ida, dev_info->id); kfree(dev_info); } @@ -1021,6 +1011,7 @@ struct iio_dev *iio_allocate_device(int sizeof_priv) dev = kzalloc(alloc_size, GFP_KERNEL); if (dev) { + dev->dev.groups = dev->groups; dev->dev.type = &iio_dev_type; dev->dev.bus = &iio_bus_type; device_initialize(&dev->dev); @@ -1104,14 +1095,11 @@ int iio_device_register(struct iio_dev *dev_info) /* configure elements for the chrdev */ dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id); - ret = device_add(&dev_info->dev); - if (ret) - goto error_free_ida; ret = iio_device_register_sysfs(dev_info); if (ret) { dev_err(dev_info->dev.parent, "Failed to register sysfs interfaces\n"); - goto error_del_device; + goto error_free_ida; } ret = iio_device_register_eventset(dev_info); if (ret) { @@ -1122,15 +1110,22 @@ int iio_device_register(struct iio_dev *dev_info) if (dev_info->modes & INDIO_RING_TRIGGERED) iio_device_register_trigger_consumer(dev_info); + ret = device_add(&dev_info->dev); + if (ret < 0) + goto error_unreg_eventset; cdev_init(&dev_info->chrdev, &iio_ring_fileops); dev_info->chrdev.owner = dev_info->info->driver_module; ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1); + if (ret < 0) + goto error_del_device; return 0; -error_free_sysfs: - iio_device_unregister_sysfs(dev_info); error_del_device: device_del(&dev_info->dev); +error_unreg_eventset: + iio_device_unregister_eventset(dev_info); +error_free_sysfs: + iio_device_unregister_sysfs(dev_info); error_free_ida: ida_simple_remove(&iio_ida, dev_info->id); error_ret: @@ -1140,11 +1135,6 @@ EXPORT_SYMBOL(iio_device_register); void iio_device_unregister(struct iio_dev *dev_info) { - if (dev_info->modes & INDIO_RING_TRIGGERED) - iio_device_unregister_trigger_consumer(dev_info); - iio_device_unregister_eventset(dev_info); - iio_device_unregister_sysfs(dev_info); - ida_simple_remove(&iio_ida, dev_info->id); device_unregister(&dev_info->dev); } EXPORT_SYMBOL(iio_device_unregister); diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 6f14c0d8486..7a95fbe0eed 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -207,10 +207,10 @@ error_ret: static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { - int ret; + int ret, attrcount = 0; struct iio_ring_buffer *ring = indio_dev->ring; - ret = __iio_add_chan_devattr("index", "scan_elements", + ret = __iio_add_chan_devattr("index", chan, &iio_show_scan_index, NULL, @@ -220,8 +220,8 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, &ring->scan_el_dev_attr_list); if (ret) goto error_ret; - - ret = __iio_add_chan_devattr("type", "scan_elements", + attrcount++; + ret = __iio_add_chan_devattr("type", chan, &iio_show_fixed_type, NULL, @@ -231,9 +231,9 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, &ring->scan_el_dev_attr_list); if (ret) goto error_ret; - + attrcount++; if (chan->type != IIO_TIMESTAMP) - ret = __iio_add_chan_devattr("en", "scan_elements", + ret = __iio_add_chan_devattr("en", chan, &iio_scan_el_show, &iio_scan_el_store, @@ -242,7 +242,7 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, &indio_dev->dev, &ring->scan_el_dev_attr_list); else - ret = __iio_add_chan_devattr("en", "scan_elements", + ret = __iio_add_chan_devattr("en", chan, &iio_scan_el_ts_show, &iio_scan_el_ts_store, @@ -250,6 +250,8 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, 0, &indio_dev->dev, &ring->scan_el_dev_attr_list); + attrcount++; + ret = attrcount; error_ret: return ret; } @@ -257,66 +259,40 @@ error_ret: static void iio_ring_remove_and_free_scan_dev_attr(struct iio_dev *indio_dev, struct iio_dev_attr *p) { - sysfs_remove_file_from_group(&indio_dev->dev.kobj, - &p->dev_attr.attr, "scan_elements"); kfree(p->dev_attr.attr.name); kfree(p); } -static struct attribute *iio_scan_el_dummy_attrs[] = { - NULL -}; - -static struct attribute_group iio_scan_el_dummy_group = { - .name = "scan_elements", - .attrs = iio_scan_el_dummy_attrs -}; - static void __iio_ring_attr_cleanup(struct iio_dev *indio_dev) { struct iio_dev_attr *p, *n; struct iio_ring_buffer *ring = indio_dev->ring; - int anydynamic = !list_empty(&ring->scan_el_dev_attr_list); + list_for_each_entry_safe(p, n, &ring->scan_el_dev_attr_list, l) iio_ring_remove_and_free_scan_dev_attr(indio_dev, p); - - if (ring->scan_el_attrs) - sysfs_remove_group(&indio_dev->dev.kobj, - ring->scan_el_attrs); - else if (anydynamic) - sysfs_remove_group(&indio_dev->dev.kobj, - &iio_scan_el_dummy_group); } +static const char * const iio_scan_elements_group_name = "scan_elements"; + int iio_ring_buffer_register(struct iio_dev *indio_dev, const struct iio_chan_spec *channels, int num_channels) { + struct iio_dev_attr *p; + struct attribute **attr; struct iio_ring_buffer *ring = indio_dev->ring; - int ret, i; + int ret, i, attrn, attrcount, attrcount_orig = 0; - if (ring->scan_el_attrs) { - ret = sysfs_create_group(&indio_dev->dev.kobj, - ring->scan_el_attrs); - if (ret) { - dev_err(&indio_dev->dev, - "Failed to add sysfs scan elements\n"); - goto error_ret; - } - } else if (channels) { - ret = sysfs_create_group(&indio_dev->dev.kobj, - &iio_scan_el_dummy_group); - if (ret) - goto error_ret; - } - if (ring->attrs) { - ret = sysfs_create_group(&indio_dev->dev.kobj, - ring->attrs); - if (ret) - goto error_cleanup_dynamic; - } + if (ring->attrs) + indio_dev->groups[indio_dev->groupcounter++] = ring->attrs; + if (ring->scan_el_attrs != NULL) { + attr = ring->scan_el_attrs->attrs; + while (*attr++ != NULL) + attrcount_orig++; + } + attrcount = attrcount_orig; INIT_LIST_HEAD(&ring->scan_el_dev_attr_list); if (channels) { /* new magic */ @@ -330,7 +306,8 @@ int iio_ring_buffer_register(struct iio_dev *indio_dev, ret = iio_ring_add_channel_sysfs(indio_dev, &channels[i]); if (ret < 0) - goto error_cleanup_group; + goto error_cleanup_dynamic; + attrcount += ret; } if (indio_dev->masklength && ring->scan_mask == NULL) { ring->scan_mask @@ -339,18 +316,36 @@ int iio_ring_buffer_register(struct iio_dev *indio_dev, GFP_KERNEL); if (ring->scan_mask == NULL) { ret = -ENOMEM; - goto error_cleanup_group; + goto error_cleanup_dynamic; } } } + ring->scan_el_group.name = iio_scan_elements_group_name; + + ring->scan_el_group.attrs + = kzalloc(sizeof(ring->scan_el_group.attrs[0])*(attrcount + 1), + GFP_KERNEL); + if (ring->scan_el_group.attrs == NULL) { + ret = -ENOMEM; + goto error_free_scan_mask; + } + if (ring->scan_el_attrs) + memcpy(ring->scan_el_group.attrs, ring->scan_el_attrs, + sizeof(ring->scan_el_group.attrs[0])*attrcount_orig); + attrn = attrcount_orig; + + list_for_each_entry(p, &ring->scan_el_dev_attr_list, l) + ring->scan_el_group.attrs[attrn++] = &p->dev_attr.attr; + indio_dev->groups[indio_dev->groupcounter++] = &ring->scan_el_group; + return 0; -error_cleanup_group: - if (ring->attrs) - sysfs_remove_group(&indio_dev->dev.kobj, ring->attrs); + +error_free_scan_mask: + kfree(ring->scan_mask); error_cleanup_dynamic: __iio_ring_attr_cleanup(indio_dev); -error_ret: + return ret; } EXPORT_SYMBOL(iio_ring_buffer_register); @@ -358,9 +353,7 @@ EXPORT_SYMBOL(iio_ring_buffer_register); void iio_ring_buffer_unregister(struct iio_dev *indio_dev) { kfree(indio_dev->ring->scan_mask); - if (indio_dev->ring->attrs) - sysfs_remove_group(&indio_dev->dev.kobj, - indio_dev->ring->attrs); + kfree(indio_dev->ring->scan_el_group.attrs); __iio_ring_attr_cleanup(indio_dev); } EXPORT_SYMBOL(iio_ring_buffer_unregister); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 3e60406d8f6..a66dcf7ad62 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -475,8 +475,10 @@ EXPORT_SYMBOL(iio_free_trigger); int iio_device_register_trigger_consumer(struct iio_dev *dev_info) { - return sysfs_create_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); + dev_info->groups[dev_info->groupcounter++] = + &iio_trigger_consumer_attr_group; + + return 0; } void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) @@ -484,8 +486,6 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) /* Clean up and associated but not attached triggers references */ if (dev_info->trig) iio_put_trigger(dev_info->trig); - sysfs_remove_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); } int iio_triggered_ring_postenable(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 7a57791521f..370777245f8 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -751,9 +751,6 @@ static int __devinit tsl2563_probe(struct i2c_client *client, indio_dev->info = &tsl2563_info; else indio_dev->info = &tsl2563_info_no_irq; - ret = iio_device_register(indio_dev); - if (ret) - goto fail1; if (client->irq) { ret = request_threaded_irq(client->irq, NULL, @@ -772,12 +769,16 @@ static int __devinit tsl2563_probe(struct i2c_client *client, /* The interrupt cannot yet be enabled so this is fine without lock */ schedule_delayed_work(&chip->poweroff_work, 5 * HZ); + ret = iio_device_register(indio_dev); + if (ret) + goto fail3; + return 0; fail3: if (client->irq) free_irq(client->irq, indio_dev); fail2: - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); fail1: kfree(chip); return err; diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index bccc5798fa5..8cf7308874b 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -513,7 +513,7 @@ static const struct iio_info ade7753_info = { static int __devinit ade7753_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct ade7753_state *st; struct iio_dev *indio_dev; @@ -535,22 +535,19 @@ static int __devinit ade7753_probe(struct spi_device *spi) indio_dev->info = &ade7753_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - regdone = 1; - /* Get the device into a sane initial state */ ret = ade7753_initial_setup(indio_dev); if (ret) goto error_free_dev; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_dev; + return 0; error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 6f0f464aba3..8adb2a98bb3 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -536,7 +536,7 @@ static const struct iio_info ade7754_info = { static int __devinit ade7754_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct ade7754_state *st; struct iio_dev *indio_dev; @@ -558,22 +558,18 @@ static int __devinit ade7754_probe(struct spi_device *spi) indio_dev->info = &ade7754_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - regdone = 1; - /* Get the device into a sane initial state */ ret = ade7754_initial_setup(indio_dev); if (ret) goto error_free_dev; + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_dev; + return 0; error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index ce513bda021..7cbf1cb198f 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -733,7 +733,7 @@ static const struct iio_info ade7758_info = { static int __devinit ade7758_probe(struct spi_device *spi) { - int i, ret, regdone = 0; + int i, ret; struct ade7758_state *st; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -775,11 +775,6 @@ static int __devinit ade7758_probe(struct spi_device *spi) if (ret) goto error_free_tx; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, &ade7758_channels[0], ARRAY_SIZE(ade7758_channels)); @@ -796,9 +791,13 @@ static int __devinit ade7758_probe(struct spi_device *spi) if (spi->irq) { ret = ade7758_probe_trigger(indio_dev); if (ret) - goto error_remove_trigger; + goto error_uninitialize_ring; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -813,10 +812,7 @@ error_free_tx: error_free_rx: kfree(st->rx); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 31723e8e64f..8e44e46d82a 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -480,19 +480,17 @@ static int __devinit ade7759_probe(struct spi_device *spi) indio_dev->info = &ade7759_info; indio_dev->modes = INDIO_DIRECT_MODE; + /* Get the device into a sane initial state */ + ret = ade7759_initial_setup(indio_dev); + if (ret) + goto error_free_dev; + ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - /* Get the device into a sane initial state */ - ret = ade7759_initial_setup(indio_dev); - if (ret) - goto error_unreg_dev; return 0; - -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 5e83227da4b..5c9c409ec7c 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -784,6 +784,7 @@ static int __devexit ad2s1210_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad2s1210_state *st = iio_priv(indio_dev); + ad2s1210_free_gpios(st); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 7a47f627556..8f6ecde1061 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -9,6 +9,7 @@ #ifndef _IIO_RING_GENERIC_H_ #define _IIO_RING_GENERIC_H_ +#include #include "iio.h" #include "chrdev.h" @@ -109,7 +110,7 @@ struct iio_ring_buffer { const struct iio_ring_access_funcs *access; const struct iio_ring_setup_ops *setup_ops; struct list_head scan_el_dev_attr_list; - + struct attribute_group scan_el_group; wait_queue_head_t pollq; bool stufftoread; unsigned long flags; From e614a54b296185b266b4bd91193e08a5fbd32422 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:41 +0100 Subject: [PATCH 0795/1519] staging:iio:attrs - make address a u64 to allow event codes to be used. Makes unusual event related attributes look a lot more like the core ones. V2: Make sure the utils that set these up can handle the codes. V3: rebase Reported-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core.h | 2 +- drivers/staging/iio/industrialio-core.c | 5 +++-- drivers/staging/iio/sysfs.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index 3a80dbf2220..803bdd8a20e 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -22,7 +22,7 @@ int __iio_add_chan_devattr(const char *postfix, struct device_attribute *attr, const char *buf, size_t len), - int mask, + u64 mask, bool generic, struct device *dev, struct list_head *attr_list); diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 49322bf5ac3..c4985cb0947 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -515,7 +515,7 @@ int __iio_add_chan_devattr(const char *postfix, struct device_attribute *attr, const char *buf, size_t len), - int mask, + u64 mask, bool generic, struct device *dev, struct list_head *attr_list) @@ -783,7 +783,8 @@ static ssize_t iio_ev_value_store(struct device *dev, static int iio_device_add_event_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret = 0, i, mask = 0, attrcount = 0; + int ret = 0, i, attrcount = 0; + u64 mask = 0; char *postfix; if (!chan->event_mask) return 0; diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 30f9a4df848..dcb413de2af 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -22,7 +22,7 @@ struct iio_chan_spec; */ struct iio_dev_attr { struct device_attribute dev_attr; - int address; + u64 address; struct list_head l; struct iio_chan_spec const *c; }; From c04ea8ae99d71182b525cb8e4d48dc2fde0dd0ee Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:42 +0100 Subject: [PATCH 0796/1519] staging:iio:naming in the EV_BIT macro fix. Should always have been IIO_EV_DIR_MAX as that's what it actually controls. Also reduced the number to 4 as not yet seen a case needing more and this is not userspace visible anyway. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 20 ++++++++++---------- drivers/staging/iio/sysfs.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index c4985cb0947..8c054c0a715 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -791,27 +791,27 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, for_each_set_bit(i, &chan->event_mask, sizeof(chan->event_mask)*8) { postfix = kasprintf(GFP_KERNEL, "%s_%s_en", - iio_ev_type_text[i/IIO_EV_TYPE_MAX], - iio_ev_dir_text[i%IIO_EV_TYPE_MAX]); + iio_ev_type_text[i/IIO_EV_DIR_MAX], + iio_ev_dir_text[i%IIO_EV_DIR_MAX]); if (postfix == NULL) { ret = -ENOMEM; goto error_ret; } if (chan->modified) mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel, - i/IIO_EV_TYPE_MAX, - i%IIO_EV_TYPE_MAX); + i/IIO_EV_DIR_MAX, + i%IIO_EV_DIR_MAX); else if (chan->type == IIO_VOLTAGE_DIFF) mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel, chan->channel2, - i/IIO_EV_TYPE_MAX, - i%IIO_EV_TYPE_MAX); + i/IIO_EV_DIR_MAX, + i%IIO_EV_DIR_MAX); else mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, - i/IIO_EV_TYPE_MAX, - i%IIO_EV_TYPE_MAX); + i/IIO_EV_DIR_MAX, + i%IIO_EV_DIR_MAX); ret = __iio_add_chan_devattr(postfix, chan, @@ -827,8 +827,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, goto error_ret; attrcount++; postfix = kasprintf(GFP_KERNEL, "%s_%s_value", - iio_ev_type_text[i/IIO_EV_TYPE_MAX], - iio_ev_dir_text[i%IIO_EV_TYPE_MAX]); + iio_ev_type_text[i/IIO_EV_DIR_MAX], + iio_ev_dir_text[i%IIO_EV_DIR_MAX]); if (postfix == NULL) { ret = -ENOMEM; goto error_ret; diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index dcb413de2af..9224f306fba 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -131,9 +131,9 @@ enum iio_event_direction { (((u64)type << 56) | ((u64)direction << 48) | ((u64)modifier << 40) | \ ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan) -#define IIO_EV_TYPE_MAX 8 +#define IIO_EV_DIR_MAX 4 #define IIO_EV_BIT(type, direction) \ - (1 << (type*IIO_EV_TYPE_MAX + direction)) + (1 << (type*IIO_EV_DIR_MAX + direction)) #define IIO_MOD_EVENT_CODE(channelclass, number, modifier, \ type, direction) \ From 66dbe70437b561c241d1117dd291c11db21072fd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:43 +0100 Subject: [PATCH 0797/1519] staging:iio: Add capacitance type and average_raw chan info. These are both needed for CAPADCs Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio.h | 3 +++ drivers/staging/iio/industrialio-core.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index a59988fd836..742f6c659a7 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -42,6 +42,7 @@ enum iio_chan_type { IIO_ROT, IIO_ANGL, IIO_TIMESTAMP, + IIO_CAPACITANCE, }; /* Nasty hack to avoid massive churn */ @@ -81,6 +82,8 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_PEAK_SCALE_SEPARATE, IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SHARED, IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE, + IIO_CHAN_INFO_AVERAGE_RAW_SHARED, + IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE, }; enum iio_endian { diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 8c054c0a715..44a5be56208 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -65,6 +65,7 @@ static const char * const iio_chan_type_name_spec_shared[] = { [IIO_ROT] = "rot", [IIO_ANGL] = "angl", [IIO_TIMESTAMP] = "timestamp", + [IIO_CAPACITANCE] = "capacitance", }; static const char * const iio_chan_type_name_spec_complex[] = { @@ -89,6 +90,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_PEAK_SCALE_SHARED/2] = "peak_scale", [IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SHARED/2] = "quadrature_correction_raw", + [IIO_CHAN_INFO_AVERAGE_RAW_SHARED/2] = "mean_raw", }; /** From 8ce7375be7036d6e536b6341ec83e5db849cda6e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:44 +0100 Subject: [PATCH 0798/1519] staging:iio:add adaptive event types and missing extract_type macro. I'm not entirely sure this is the right way to go. Suggestions of other options welcome! Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 4 +++- drivers/staging/iio/sysfs.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 44a5be56208..83e55b1d640 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -700,7 +700,9 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info) static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_THRESH] = "thresh", [IIO_EV_TYPE_MAG] = "mag", - [IIO_EV_TYPE_ROC] = "roc" + [IIO_EV_TYPE_ROC] = "roc", + [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", + [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", }; static const char * const iio_ev_dir_text[] = { diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 9224f306fba..3388b8c48a4 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -118,6 +118,8 @@ enum iio_event_type { IIO_EV_TYPE_THRESH, IIO_EV_TYPE_MAG, IIO_EV_TYPE_ROC, + IIO_EV_TYPE_THRESH_ADAPTIVE, + IIO_EV_TYPE_MAG_ADAPTIVE, }; enum iio_event_direction { @@ -142,6 +144,7 @@ enum iio_event_direction { #define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction) \ IIO_EVENT_CODE(channelclass, 0, direction, type, number, 0, 0) +#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xFF) /* Event code number extraction depends on which type of event we have. From ade7ef7ba3bf888b90269f8ca864841b2cd9803f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:45 +0100 Subject: [PATCH 0799/1519] staging:iio: Differential channel handling - use explicit flag rather than types. Straight forward change in the core, but required some drivers to not use the IIO_CHAN macro as that doesn't allow setting this bit (and is going away anyway). Hence the churn. Tested on max1363 with a couple of supported parts. V2: differential bit in code got 7 bits and direction 1. Reversed that. Issue spotted by Michael - thanks! Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7192.c | 8 +- drivers/staging/iio/adc/ad7280a.c | 26 +-- drivers/staging/iio/adc/ad7793.c | 176 +++++++++++++++------ drivers/staging/iio/adc/max1363_core.c | 202 +++++++++++------------- drivers/staging/iio/iio.h | 3 +- drivers/staging/iio/industrialio-core.c | 145 +++++++++-------- drivers/staging/iio/sysfs.h | 11 +- 7 files changed, 325 insertions(+), 246 deletions(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index c67da6aac99..5bc1051b24b 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -886,8 +886,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, ((1 << (chan->scan_type.realbits)) - 1); switch (chan->type) { - case IIO_IN: - case IIO_IN_DIFF: + case IIO_VOLTAGE: if (!unipolar) *val -= (1 << (chan->scan_type.realbits - 1)); break; @@ -986,7 +985,8 @@ static const struct iio_info ad7192_info = { }; #define AD7192_CHAN_DIFF(_chan, _chan2, _name, _address, _si) \ - { .type = IIO_IN_DIFF, \ + { .type = IIO_VOLTAGE, \ + .differential = 1, \ .indexed = 1, \ .extend_name = _name, \ .channel = _chan, \ @@ -997,7 +997,7 @@ static const struct iio_info ad7192_info = { .scan_type = IIO_ST('s', 24, 32, 0)} #define AD7192_CHAN(_chan, _address, _si) \ - { .type = IIO_IN, \ + { .type = IIO_VOLTAGE, \ .indexed = 1, \ .channel = _chan, \ .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index bdc325dcb5b..2d8d650dc27 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -495,7 +495,8 @@ static int ad7280_channel_init(struct ad7280_state *st) for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++, cnt++) { if (ch < AD7280A_AUX_ADC_1) { - st->channels[cnt].type = IIO_IN_DIFF; + st->channels[cnt].type = IIO_VOLTAGE; + st->channels[cnt].differential = 1; st->channels[cnt].channel = (dev * 6) + ch; st->channels[cnt].channel2 = st->channels[cnt].channel + 1; @@ -515,7 +516,8 @@ static int ad7280_channel_init(struct ad7280_state *st) st->channels[cnt].scan_type.shift = 0; } - st->channels[cnt].type = IIO_IN_DIFF; + st->channels[cnt].type = IIO_VOLTAGE; + st->channels[cnt].differential = 1; st->channels[cnt].channel = 0; st->channels[cnt].channel2 = dev * 6; st->channels[cnt].address = AD7280A_ALL_CELLS; @@ -692,18 +694,22 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) if (((channels[i] >> 11) & 0xFFF) >= st->cell_threshhigh) iio_push_event(dev_info, - IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), + IIO_EVENT_CODE(IIO_VOLTAGE, + 1, + 0, + IIO_EV_DIR_RISING, + IIO_EV_TYPE_THRESH, + 0, 0, 0), iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->cell_threshlow) iio_push_event(dev_info, - IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), + IIO_EVENT_CODE(IIO_VOLTAGE, + 1, + 0, + IIO_EV_DIR_FALLING, + IIO_EV_TYPE_THRESH, + 0, 0, 0), iio_get_time_ns()); } else { if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 17d18fc7b46..7044ed2932a 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -767,57 +767,137 @@ static const struct iio_info ad7793_info = { static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { [ID_AD7793] = { - .channel[0] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN1P_AIN1M, - 0, IIO_ST('s', 24, 32, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 1, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN2P_AIN2M, - 1, IIO_ST('s', 24, 32, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 2, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN3P_AIN3M, - 2, IIO_ST('s', 24, 32, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, "shorted", 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN1M_AIN1M, - 3, IIO_ST('s', 24, 32, 0), 0), - .channel[4] = IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - AD7793_CH_TEMP, - 4, IIO_ST('s', 24, 32, 0), 0), - .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - AD7793_CH_AVDD_MONITOR, - 5, IIO_ST('s', 24, 32, 0), 0), + .channel[0] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 0, + .channel2 = 0, + .address = AD7793_CH_AIN1P_AIN1M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 0, + .scan_type = IIO_ST('s', 24, 32, 0) + }, + .channel[1] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 1, + .channel2 = 1, + .address = AD7793_CH_AIN2P_AIN2M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 1, + .scan_type = IIO_ST('s', 24, 32, 0) + }, + .channel[2] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 2, + .channel2 = 2, + .address = AD7793_CH_AIN3P_AIN3M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 2, + .scan_type = IIO_ST('s', 24, 32, 0) + }, + .channel[3] = { + .type = IIO_VOLTAGE, + .differential = 1, + .extend_name = "shorted", + .indexed = 1, + .channel = 2, + .channel2 = 2, + .address = AD7793_CH_AIN1M_AIN1M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 2, + .scan_type = IIO_ST('s', 24, 32, 0) + }, + .channel[4] = { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .address = AD7793_CH_TEMP, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .scan_index = 4, + .scan_type = IIO_ST('s', 24, 32, 0), + }, + .channel[5] = { + .type = IIO_VOLTAGE, + .extend_name = "supply", + .indexed = 1, + .channel = 4, + .address = AD7793_CH_AVDD_MONITOR, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .scan_index = 5, + .scan_type = IIO_ST('s', 24, 32, 0), + }, .channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6), }, [ID_AD7792] = { - .channel[0] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN1P_AIN1M, - 0, IIO_ST('s', 16, 32, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 1, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN2P_AIN2M, - 1, IIO_ST('s', 16, 32, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 2, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN3P_AIN3M, - 2, IIO_ST('s', 16, 32, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, "shorted", 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - AD7793_CH_AIN1M_AIN1M, - 3, IIO_ST('s', 16, 32, 0), 0), - .channel[4] = IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - AD7793_CH_TEMP, - 4, IIO_ST('s', 16, 32, 0), 0), - .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - AD7793_CH_AVDD_MONITOR, - 5, IIO_ST('s', 16, 32, 0), 0), + .channel[0] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 0, + .channel2 = 0, + .address = AD7793_CH_AIN1P_AIN1M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 0, + .scan_type = IIO_ST('s', 16, 32, 0) + }, + .channel[1] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 1, + .channel2 = 1, + .address = AD7793_CH_AIN2P_AIN2M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 1, + .scan_type = IIO_ST('s', 16, 32, 0) + }, + .channel[2] = { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 2, + .channel2 = 2, + .address = AD7793_CH_AIN3P_AIN3M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 2, + .scan_type = IIO_ST('s', 16, 32, 0) + }, + .channel[3] = { + .type = IIO_VOLTAGE, + .differential = 1, + .extend_name = "shorted", + .indexed = 1, + .channel = 2, + .channel2 = 2, + .address = AD7793_CH_AIN1M_AIN1M, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = 2, + .scan_type = IIO_ST('s', 16, 32, 0) + }, + .channel[4] = { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .address = AD7793_CH_TEMP, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .scan_index = 4, + .scan_type = IIO_ST('s', 16, 32, 0), + }, + .channel[5] = { + .type = IIO_VOLTAGE, + .extend_name = "supply", + .indexed = 1, + .channel = 4, + .address = AD7793_CH_AVDD_MONITOR, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .scan_index = 5, + .scan_type = IIO_ST('s', 16, 32, 0), + }, .channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6), }, }; diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 9962f594d3a..b7c46aeceb5 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -289,72 +289,52 @@ static const enum max1363_modes max1363_mode_list[] = { (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) \ | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) #define MAX1363_INFO_MASK (1 << IIO_CHAN_INFO_SCALE_SHARED) - -static struct iio_chan_spec max1363_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK, - _s0, 0, IIO_ST('u', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK, - _s1, 1, IIO_ST('u', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK, - _s2, 2, IIO_ST('u', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK, - _s3, 3, IIO_ST('u', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK, - d0m1, 4, IIO_ST('s', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK, - d2m3, 5, IIO_ST('s', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK, - d1m0, 6, IIO_ST('s', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK, - d3m2, 7, IIO_ST('s', 12, 16, 0), MAX1363_EV_M), - IIO_CHAN_SOFT_TIMESTAMP(8) -}; - -static struct iio_chan_spec max1361_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK, - _s0, 0, IIO_ST('u', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK, - _s1, 1, IIO_ST('u', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK, - _s2, 2, IIO_ST('u', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK, - _s3, 3, IIO_ST('u', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK, - d0m1, 4, IIO_ST('s', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK, - d2m3, 5, IIO_ST('s', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK, - d1m0, 6, IIO_ST('s', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK, - d3m2, 7, IIO_ST('s', 10, 16, 0), MAX1363_EV_M), - IIO_CHAN_SOFT_TIMESTAMP(8) -}; - -#define MAX1363_CHAN_U(num, address, scan_index, bits) \ - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, num, 0, MAX1363_INFO_MASK, \ - address, scan_index, IIO_ST('u', bits, \ - (bits == 8) ? 8 : 16, 0), 0) -/* bipolar channel */ -#define MAX1363_CHAN_B(num, num2, address, scan_index, bits) \ - IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, num, num2, MAX1363_INFO_MASK,\ - address, scan_index, IIO_ST('s', bits, \ - (bits == 8) ? 8 : 16, 0), 0) - -#define MAX1363_4X_CHANS(bits) { \ - MAX1363_CHAN_U(0, _s0, 0, bits), \ - MAX1363_CHAN_U(1, _s1, 1, bits), \ - MAX1363_CHAN_U(2, _s2, 2, bits), \ - MAX1363_CHAN_U(3, _s3, 3, bits), \ - MAX1363_CHAN_B(0, 1, d0m1, 4, bits), \ - MAX1363_CHAN_B(2, 3, d2m3, 5, bits), \ - MAX1363_CHAN_B(1, 0, d1m0, 6, bits), \ - MAX1363_CHAN_B(3, 2, d3m2, 7, bits), \ - IIO_CHAN_SOFT_TIMESTAMP(8) \ +#define MAX1363_CHAN_U(num, addr, si, bits, evmask) \ + { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = num, \ + .address = addr, \ + .info_mask = MAX1363_INFO_MASK, \ + .scan_type = IIO_ST('u', bits, (bits > 8) ? 16 : 8, 0), \ + .scan_index = si, \ + .event_mask = evmask, \ } -static struct iio_chan_spec max1036_channels[] = MAX1363_4X_CHANS(8); -static struct iio_chan_spec max1136_channels[] = MAX1363_4X_CHANS(10); -static struct iio_chan_spec max1236_channels[] = MAX1363_4X_CHANS(12); +/* bipolar channel */ +#define MAX1363_CHAN_B(num, num2, addr, si, bits, evmask) \ + { \ + .type = IIO_VOLTAGE, \ + .differential = 1, \ + .indexed = 1, \ + .channel = num, \ + .channel2 = num2, \ + .address = addr, \ + .info_mask = MAX1363_INFO_MASK, \ + .scan_type = IIO_ST('u', bits, (bits > 8) ? 16 : 8, 0), \ + .scan_index = si, \ + .event_mask = evmask, \ + } + +#define MAX1363_4X_CHANS(bits, em) { \ + MAX1363_CHAN_U(0, _s0, 0, bits, em), \ + MAX1363_CHAN_U(1, _s1, 1, bits, em), \ + MAX1363_CHAN_U(2, _s2, 2, bits, em), \ + MAX1363_CHAN_U(3, _s3, 3, bits, em), \ + MAX1363_CHAN_B(0, 1, d0m1, 4, bits, em), \ + MAX1363_CHAN_B(2, 3, d2m3, 5, bits, em), \ + MAX1363_CHAN_B(1, 0, d1m0, 6, bits, em), \ + MAX1363_CHAN_B(3, 2, d3m2, 7, bits, em), \ + IIO_CHAN_SOFT_TIMESTAMP(8) \ + } + +static struct iio_chan_spec max1036_channels[] = MAX1363_4X_CHANS(8, 0); +static struct iio_chan_spec max1136_channels[] = MAX1363_4X_CHANS(10, 0); +static struct iio_chan_spec max1236_channels[] = MAX1363_4X_CHANS(12, 0); +static struct iio_chan_spec max1361_channels[] = + MAX1363_4X_CHANS(10, MAX1363_EV_M); +static struct iio_chan_spec max1363_channels[] = + MAX1363_4X_CHANS(12, MAX1363_EV_M); /* Appies to max1236, max1237 */ static const enum max1363_modes max1236_mode_list[] = { @@ -379,30 +359,30 @@ static const enum max1363_modes max1238_mode_list[] = { }; #define MAX1363_12X_CHANS(bits) { \ - MAX1363_CHAN_U(0, _s0, 0, bits), \ - MAX1363_CHAN_U(1, _s1, 1, bits), \ - MAX1363_CHAN_U(2, _s2, 2, bits), \ - MAX1363_CHAN_U(3, _s3, 3, bits), \ - MAX1363_CHAN_U(4, _s4, 4, bits), \ - MAX1363_CHAN_U(5, _s5, 5, bits), \ - MAX1363_CHAN_U(6, _s6, 6, bits), \ - MAX1363_CHAN_U(7, _s7, 7, bits), \ - MAX1363_CHAN_U(8, _s8, 8, bits), \ - MAX1363_CHAN_U(9, _s9, 9, bits), \ - MAX1363_CHAN_U(10, _s10, 10, bits), \ - MAX1363_CHAN_U(11, _s11, 11, bits), \ - MAX1363_CHAN_B(0, 1, d0m1, 12, bits), \ - MAX1363_CHAN_B(2, 3, d2m3, 13, bits), \ - MAX1363_CHAN_B(4, 5, d4m5, 14, bits), \ - MAX1363_CHAN_B(6, 7, d6m7, 15, bits), \ - MAX1363_CHAN_B(8, 9, d8m9, 16, bits), \ - MAX1363_CHAN_B(10, 11, d10m11, 17, bits), \ - MAX1363_CHAN_B(1, 0, d1m0, 18, bits), \ - MAX1363_CHAN_B(3, 2, d3m2, 19, bits), \ - MAX1363_CHAN_B(5, 4, d5m4, 20, bits), \ - MAX1363_CHAN_B(7, 6, d7m6, 21, bits), \ - MAX1363_CHAN_B(9, 8, d9m8, 22, bits), \ - MAX1363_CHAN_B(11, 10, d11m10, 23, bits), \ + MAX1363_CHAN_U(0, _s0, 0, bits, 0), \ + MAX1363_CHAN_U(1, _s1, 1, bits, 0), \ + MAX1363_CHAN_U(2, _s2, 2, bits, 0), \ + MAX1363_CHAN_U(3, _s3, 3, bits, 0), \ + MAX1363_CHAN_U(4, _s4, 4, bits, 0), \ + MAX1363_CHAN_U(5, _s5, 5, bits, 0), \ + MAX1363_CHAN_U(6, _s6, 6, bits, 0), \ + MAX1363_CHAN_U(7, _s7, 7, bits, 0), \ + MAX1363_CHAN_U(8, _s8, 8, bits, 0), \ + MAX1363_CHAN_U(9, _s9, 9, bits, 0), \ + MAX1363_CHAN_U(10, _s10, 10, bits, 0), \ + MAX1363_CHAN_U(11, _s11, 11, bits, 0), \ + MAX1363_CHAN_B(0, 1, d0m1, 12, bits, 0), \ + MAX1363_CHAN_B(2, 3, d2m3, 13, bits, 0), \ + MAX1363_CHAN_B(4, 5, d4m5, 14, bits, 0), \ + MAX1363_CHAN_B(6, 7, d6m7, 15, bits, 0), \ + MAX1363_CHAN_B(8, 9, d8m9, 16, bits, 0), \ + MAX1363_CHAN_B(10, 11, d10m11, 17, bits, 0), \ + MAX1363_CHAN_B(1, 0, d1m0, 18, bits, 0), \ + MAX1363_CHAN_B(3, 2, d3m2, 19, bits, 0), \ + MAX1363_CHAN_B(5, 4, d5m4, 20, bits, 0), \ + MAX1363_CHAN_B(7, 6, d7m6, 21, bits, 0), \ + MAX1363_CHAN_B(9, 8, d9m8, 22, bits, 0), \ + MAX1363_CHAN_B(11, 10, d11m10, 23, bits, 0), \ IIO_CHAN_SOFT_TIMESTAMP(24) \ } static struct iio_chan_spec max1038_channels[] = MAX1363_12X_CHANS(8); @@ -427,25 +407,25 @@ static const enum max1363_modes max11608_mode_list[] = { d1m0to3m2, d1m0to5m4, d1m0to7m6, }; -#define MAX1363_8X_CHANS(bits) { \ - MAX1363_CHAN_U(0, _s0, 0, bits), \ - MAX1363_CHAN_U(1, _s1, 1, bits), \ - MAX1363_CHAN_U(2, _s2, 2, bits), \ - MAX1363_CHAN_U(3, _s3, 3, bits), \ - MAX1363_CHAN_U(4, _s4, 4, bits), \ - MAX1363_CHAN_U(5, _s5, 5, bits), \ - MAX1363_CHAN_U(6, _s6, 6, bits), \ - MAX1363_CHAN_U(7, _s7, 7, bits), \ - MAX1363_CHAN_B(0, 1, d0m1, 8, bits), \ - MAX1363_CHAN_B(2, 3, d2m3, 9, bits), \ - MAX1363_CHAN_B(4, 5, d4m5, 10, bits), \ - MAX1363_CHAN_B(6, 7, d6m7, 11, bits), \ - MAX1363_CHAN_B(1, 0, d1m0, 12, bits), \ - MAX1363_CHAN_B(3, 2, d3m2, 13, bits), \ - MAX1363_CHAN_B(5, 4, d5m4, 14, bits), \ - MAX1363_CHAN_B(7, 6, d7m6, 15, bits), \ - IIO_CHAN_SOFT_TIMESTAMP(16) \ - } +#define MAX1363_8X_CHANS(bits) { \ + MAX1363_CHAN_U(0, _s0, 0, bits, 0), \ + MAX1363_CHAN_U(1, _s1, 1, bits, 0), \ + MAX1363_CHAN_U(2, _s2, 2, bits, 0), \ + MAX1363_CHAN_U(3, _s3, 3, bits, 0), \ + MAX1363_CHAN_U(4, _s4, 4, bits, 0), \ + MAX1363_CHAN_U(5, _s5, 5, bits, 0), \ + MAX1363_CHAN_U(6, _s6, 6, bits, 0), \ + MAX1363_CHAN_U(7, _s7, 7, bits, 0), \ + MAX1363_CHAN_B(0, 1, d0m1, 8, bits, 0), \ + MAX1363_CHAN_B(2, 3, d2m3, 9, bits, 0), \ + MAX1363_CHAN_B(4, 5, d4m5, 10, bits, 0), \ + MAX1363_CHAN_B(6, 7, d6m7, 11, bits, 0), \ + MAX1363_CHAN_B(1, 0, d1m0, 12, bits, 0), \ + MAX1363_CHAN_B(3, 2, d3m2, 13, bits, 0), \ + MAX1363_CHAN_B(5, 4, d5m4, 14, bits, 0), \ + MAX1363_CHAN_B(7, 6, d7m6, 15, bits, 0), \ + IIO_CHAN_SOFT_TIMESTAMP(16) \ +} static struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8); static struct iio_chan_spec max11608_channels[] = MAX1363_8X_CHANS(10); static struct iio_chan_spec max11614_channels[] = MAX1363_8X_CHANS(12); @@ -455,10 +435,10 @@ static const enum max1363_modes max11644_mode_list[] = { }; #define MAX1363_2X_CHANS(bits) { \ - MAX1363_CHAN_U(0, _s0, 0, bits), \ - MAX1363_CHAN_U(1, _s1, 1, bits), \ - MAX1363_CHAN_B(0, 1, d0m1, 2, bits), \ - MAX1363_CHAN_B(1, 0, d1m0, 3, bits), \ + MAX1363_CHAN_U(0, _s0, 0, bits, 0), \ + MAX1363_CHAN_U(1, _s1, 1, bits, 0), \ + MAX1363_CHAN_B(0, 1, d0m1, 2, bits, 0), \ + MAX1363_CHAN_B(1, 0, d1m0, 3, bits, 0), \ IIO_CHAN_SOFT_TIMESTAMP(4) \ } diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 742f6c659a7..8ef04f83336 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -31,7 +31,6 @@ enum iio_chan_type { IIO_CURRENT, IIO_POWER, IIO_ACCEL, - IIO_VOLTAGE_DIFF, IIO_GYRO, IIO_MAGN, IIO_LIGHT, @@ -124,6 +123,7 @@ enum iio_endian { * the value in channel will be suppressed for attribute * but not for event codes. Typically set it to 0 when * the index is false. + * @differential: Channel is differential. */ struct iio_chan_spec { enum iio_chan_type type; @@ -145,6 +145,7 @@ struct iio_chan_spec { unsigned modified:1; unsigned indexed:1; unsigned output:1; + unsigned differential:1; }; #define IIO_ST(si, rb, sb, sh) \ diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 83e55b1d640..fd4aadaa06f 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -49,12 +49,11 @@ static const char * const iio_direction[] = { [1] = "out", }; -static const char * const iio_chan_type_name_spec_shared[] = { +static const char * const iio_chan_type_name_spec[] = { [IIO_VOLTAGE] = "voltage", [IIO_CURRENT] = "current", [IIO_POWER] = "power", [IIO_ACCEL] = "accel", - [IIO_VOLTAGE_DIFF] = "voltage-voltage", [IIO_GYRO] = "gyro", [IIO_MAGN] = "magn", [IIO_LIGHT] = "illuminance", @@ -68,10 +67,6 @@ static const char * const iio_chan_type_name_spec_shared[] = { [IIO_CAPACITANCE] = "capacitance", }; -static const char * const iio_chan_type_name_spec_complex[] = { - [IIO_VOLTAGE_DIFF] = "voltage%d-voltage%d", -}; - static const char * const iio_modifier_names[] = { [IIO_MOD_X] = "x", [IIO_MOD_Y] = "y", @@ -158,7 +153,6 @@ error_ret: } EXPORT_SYMBOL(iio_push_event); - /* This turns up an awful lot */ ssize_t iio_read_const_attr(struct device *dev, struct device_attribute *attr, @@ -168,7 +162,6 @@ ssize_t iio_read_const_attr(struct device *dev, } EXPORT_SYMBOL(iio_read_const_attr); - static ssize_t iio_event_chrdev_read(struct file *filep, char __user *buf, size_t count, @@ -397,36 +390,6 @@ static ssize_t iio_write_channel_info(struct device *dev, return len; } -static int __iio_build_postfix(struct iio_chan_spec const *chan, - bool generic, - const char *postfix, - char **result) -{ - char *all_post; - /* 3 options - generic, extend_name, modified - if generic, extend_name - * and modified cannot apply.*/ - - if (generic || (!chan->modified && !chan->extend_name)) { - all_post = kasprintf(GFP_KERNEL, "%s", postfix); - } else if (chan->modified) { - if (chan->extend_name) - all_post = kasprintf(GFP_KERNEL, "%s_%s_%s", - iio_modifier_names[chan->channel2], - chan->extend_name, - postfix); - else - all_post = kasprintf(GFP_KERNEL, "%s_%s", - iio_modifier_names[chan->channel2], - postfix); - } else - all_post = kasprintf(GFP_KERNEL, "%s_%s", chan->extend_name, - postfix); - if (all_post == NULL) - return -ENOMEM; - *result = all_post; - return 0; -} - static int __iio_device_attr_init(struct device_attribute *dev_attr, const char *postfix, @@ -443,31 +406,77 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, int ret; char *name_format, *full_postfix; sysfs_attr_init(&dev_attr->attr); - ret = __iio_build_postfix(chan, generic, postfix, &full_postfix); - if (ret) + + /* Build up postfix of __postfix */ + if (chan->modified) { + if (chan->extend_name) + full_postfix = kasprintf(GFP_KERNEL, "%s_%s_%s", + iio_modifier_names[chan + ->channel2], + chan->extend_name, + postfix); + else + full_postfix = kasprintf(GFP_KERNEL, "%s_%s", + iio_modifier_names[chan + ->channel2], + postfix); + } else { + if (chan->extend_name == NULL) + full_postfix = kstrdup(postfix, GFP_KERNEL); + else + full_postfix = kasprintf(GFP_KERNEL, + "%s_%s", + chan->extend_name, + postfix); + } + if (full_postfix == NULL) { + ret = -ENOMEM; goto error_ret; + } - /* Special case for types that uses both channel numbers in naming */ - if (chan->type == IIO_VOLTAGE_DIFF && !generic) - name_format - = kasprintf(GFP_KERNEL, "%s_%s_%s", - iio_direction[chan->output], - iio_chan_type_name_spec_complex[chan->type], - full_postfix); - else if (generic || !chan->indexed) - name_format - = kasprintf(GFP_KERNEL, "%s_%s_%s", - iio_direction[chan->output], - iio_chan_type_name_spec_shared[chan->type], - full_postfix); - else - name_format - = kasprintf(GFP_KERNEL, "%s_%s%d_%s", - iio_direction[chan->output], - iio_chan_type_name_spec_shared[chan->type], - chan->channel, - full_postfix); - + if (chan->differential) { /* Differential can not have modifier */ + if (generic) + name_format + = kasprintf(GFP_KERNEL, "%s_%s-%s_%s", + iio_direction[chan->output], + iio_chan_type_name_spec[chan->type], + iio_chan_type_name_spec[chan->type], + full_postfix); + else if (chan->indexed) + name_format + = kasprintf(GFP_KERNEL, "%s_%s%d-%s%d_%s", + iio_direction[chan->output], + iio_chan_type_name_spec[chan->type], + chan->channel, + iio_chan_type_name_spec[chan->type], + chan->channel2, + full_postfix); + else { + WARN_ON("Differential channels must be indexed\n"); + ret = -EINVAL; + goto error_free_full_postfix; + } + } else { /* Single ended */ + if (generic) + name_format + = kasprintf(GFP_KERNEL, "%s_%s_%s", + iio_direction[chan->output], + iio_chan_type_name_spec[chan->type], + full_postfix); + else if (chan->indexed) + name_format + = kasprintf(GFP_KERNEL, "%s_%s%d_%s", + iio_direction[chan->output], + iio_chan_type_name_spec[chan->type], + chan->channel, + full_postfix); + else + name_format + = kasprintf(GFP_KERNEL, "%s_%s_%s", + iio_direction[chan->output], + iio_chan_type_name_spec[chan->type], + full_postfix); + } if (name_format == NULL) { ret = -ENOMEM; goto error_free_full_postfix; @@ -805,12 +814,14 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel, i/IIO_EV_DIR_MAX, i%IIO_EV_DIR_MAX); - else if (chan->type == IIO_VOLTAGE_DIFF) - mask = IIO_MOD_EVENT_CODE(chan->type, - chan->channel, - chan->channel2, - i/IIO_EV_DIR_MAX, - i%IIO_EV_DIR_MAX); + else if (chan->differential) + mask = IIO_EVENT_CODE(chan->type, + 0, 0, + i%IIO_EV_DIR_MAX, + i/IIO_EV_DIR_MAX, + 0, + chan->channel, + chan->channel2); else mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 3388b8c48a4..12152461ca5 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -128,9 +128,10 @@ enum iio_event_direction { IIO_EV_DIR_FALLING, }; -#define IIO_EVENT_CODE(chan_type, modifier, direction, \ +#define IIO_EVENT_CODE(chan_type, diff, modifier, direction, \ type, chan, chan1, chan2) \ - (((u64)type << 56) | ((u64)direction << 48) | ((u64)modifier << 40) | \ + (((u64)type << 56) | ((u64)diff << 55) | \ + ((u64)direction << 48) | ((u64)modifier << 40) | \ ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan) #define IIO_EV_DIR_MAX 4 @@ -139,13 +140,13 @@ enum iio_event_direction { #define IIO_MOD_EVENT_CODE(channelclass, number, modifier, \ type, direction) \ - IIO_EVENT_CODE(channelclass, modifier, direction, type, number, 0, 0) + IIO_EVENT_CODE(channelclass, 0, modifier, direction, type, number, 0, 0) #define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction) \ - IIO_EVENT_CODE(channelclass, 0, direction, type, number, 0, 0) + IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0) #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) -#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xFF) +#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF) /* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ From c5b99396c70a1287bd49813121da37a828f69d23 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:19 +0100 Subject: [PATCH 0800/1519] staging:iio:dac:ad5791 chan spec conversion. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5791.c | 158 ++++++++++++++----------------- drivers/staging/iio/dac/ad5791.h | 4 - 2 files changed, 72 insertions(+), 90 deletions(-) diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 74f54068724..6c34700b9ed 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -72,48 +72,22 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) return ret; } -static ssize_t ad5791_write_dac(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ad5791_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - long readin; - int ret; - - ret = strict_strtol(buf, 10, &readin); - if (ret) - return ret; - - readin += (1 << (st->chip_info->bits - 1)); - readin &= AD5791_RES_MASK(st->chip_info->bits); - readin <<= st->chip_info->left_shift; - - ret = ad5791_spi_write(st->spi, this_attr->address, readin); - return ret ? ret : len; +#define AD5791_CHAN(bits, shift) { \ + .type = IIO_VOLTAGE, \ + .output = 1, \ + .indexed = 1, \ + .address = AD5791_ADDR_DAC0, \ + .channel = 0, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .scan_type = IIO_ST('u', bits, 24, shift) \ } -static ssize_t ad5791_read_dac(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ad5791_state *st = iio_priv(indio_dev); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int ret; - int val; - - ret = ad5791_spi_read(st->spi, this_attr->address, &val); - if (ret) - return ret; - - val &= AD5791_DAC_MASK; - val >>= st->chip_info->left_shift; - val -= (1 << (st->chip_info->bits - 1)); - - return sprintf(buf, "%d\n", val); -} +static const struct iio_chan_spec ad5791_channels[] = { + [ID_AD5760] = AD5791_CHAN(16, 4), + [ID_AD5780] = AD5791_CHAN(18, 2), + [ID_AD5781] = AD5791_CHAN(18, 2), + [ID_AD5791] = AD5791_CHAN(20, 0) +}; static ssize_t ad5791_read_powerdown_mode(struct device *dev, struct device_attribute *attr, char *buf) @@ -184,37 +158,6 @@ static ssize_t ad5791_write_dac_powerdown(struct device *dev, return ret ? ret : len; } -static ssize_t ad5791_show_scale(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ad5791_state *st = iio_priv(indio_dev); - /* Corresponds to Vref / 2^(bits) */ - unsigned int scale_uv = (st->vref_mv * 1000) >> st->chip_info->bits; - - return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000); -} -static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5791_show_scale, NULL, 0); - -static ssize_t ad5791_show_name(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct ad5791_state *st = iio_priv(indio_dev); - - return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name); -} -static IIO_DEVICE_ATTR(name, S_IRUGO, ad5791_show_name, NULL, 0); - -#define IIO_DEV_ATTR_OUT_RW_RAW(_num, _show, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_raw, \ - S_IRUGO | S_IWUSR, _show, _store, _addr) - -static IIO_DEV_ATTR_OUT_RW_RAW(0, ad5791_read_dac, - ad5791_write_dac, AD5791_ADDR_DAC0); - static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO | S_IWUSR, ad5791_read_powerdown_mode, ad5791_write_powerdown_mode, 0); @@ -230,12 +173,9 @@ static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5791_read_dac_powerdown, ad5791_write_dac_powerdown, 0); static struct attribute *ad5791_attributes[] = { - &iio_dev_attr_out0_raw.dev_attr.attr, &iio_dev_attr_out0_powerdown.dev_attr.attr, &iio_dev_attr_out_powerdown_mode.dev_attr.attr, &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, - &iio_dev_attr_out_scale.dev_attr.attr, - &iio_dev_attr_name.dev_attr.attr, NULL, }; @@ -264,31 +204,74 @@ static int ad5780_get_lin_comp(unsigned int span) else return AD5780_LINCOMP_10_20; } - static const struct ad5791_chip_info ad5791_chip_info_tbl[] = { [ID_AD5760] = { - .bits = 16, - .left_shift = 4, .get_lin_comp = ad5780_get_lin_comp, }, [ID_AD5780] = { - .bits = 18, - .left_shift = 2, .get_lin_comp = ad5780_get_lin_comp, }, [ID_AD5781] = { - .bits = 18, - .left_shift = 2, .get_lin_comp = ad5791_get_lin_comp, }, [ID_AD5791] = { - .bits = 20, - .left_shift = 0, .get_lin_comp = ad5791_get_lin_comp, }, }; +static int ad5791_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad5791_state *st = iio_priv(indio_dev); + int ret; + + switch (m) { + case 0: + ret = ad5791_spi_read(st->spi, chan->address, val); + if (ret) + return ret; + *val &= AD5791_DAC_MASK; + *val >>= chan->scan_type.shift; + *val -= (1 << (chan->scan_type.storagebits - 1)); + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + *val = 0; + *val2 = (st->vref_mv * 1000) >> chan->scan_type.storagebits; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + +}; + + +static int ad5791_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct ad5791_state *st = iio_priv(indio_dev); + + switch (mask) { + case 0: + val += (1 << (chan->scan_type.storagebits - 1)); + val &= AD5791_RES_MASK(chan->scan_type.storagebits); + val <<= chan->scan_type.shift; + + return ad5791_spi_write(st->spi, chan->address, val); + + default: + return -EINVAL; + } +} + static const struct iio_info ad5791_info = { + .read_raw = &ad5791_read_raw, + .write_raw = &ad5791_write_raw, .attrs = &ad5791_attribute_group, .driver_module = THIS_MODULE, }; @@ -338,8 +321,8 @@ static int __devinit ad5791_probe(struct spi_device *spi) if (ret) goto error_disable_reg_neg; - st->chip_info = - &ad5791_chip_info_tbl[spi_get_device_id(spi)->driver_data]; + st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi) + ->driver_data]; st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) @@ -355,7 +338,10 @@ static int __devinit ad5791_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; - + indio_dev->channels + = &ad5791_channels[spi_get_device_id(spi)->driver_data]; + indio_dev->num_channels = 1; + indio_dev->name = spi_get_device_id(st->spi)->name; ret = iio_device_register(indio_dev); if (ret) goto error_disable_reg_neg; diff --git a/drivers/staging/iio/dac/ad5791.h b/drivers/staging/iio/dac/ad5791.h index c807f26539d..2a50a112b96 100644 --- a/drivers/staging/iio/dac/ad5791.h +++ b/drivers/staging/iio/dac/ad5791.h @@ -68,14 +68,10 @@ struct ad5791_platform_data { /** * struct ad5791_chip_info - chip specific information - * @bits: accuracy of the DAC in bits - * @left_shift: number of bits the datum must be shifted * @get_lin_comp: function pointer to the device specific function */ struct ad5791_chip_info { - u8 bits; - u8 left_shift; int (*get_lin_comp) (unsigned int span); }; From 531efd6aa09916ef93f3788a9e67175e18461239 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:20 +0100 Subject: [PATCH 0801/1519] staging:iio:adc:ad7150: chan_spec conv + i2c_smbus commands + drop unused poweroff timeout control. Minimal changes to code layout as going to do chan spec conversion shortly. Otherwise, there are numerous code sharing opportunities in here and abi elements that are uterly non compliant. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7150.c | 916 ++++++++++++++----------------- 1 file changed, 427 insertions(+), 489 deletions(-) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 3d154b87f55..0685b8a0ffd 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -24,22 +24,16 @@ #define AD7150_STATUS_OUT1 (1 << 3) #define AD7150_STATUS_OUT2 (1 << 5) #define AD7150_CH1_DATA_HIGH 1 -#define AD7150_CH1_DATA_LOW 2 #define AD7150_CH2_DATA_HIGH 3 -#define AD7150_CH2_DATA_LOW 4 #define AD7150_CH1_AVG_HIGH 5 -#define AD7150_CH1_AVG_LOW 6 #define AD7150_CH2_AVG_HIGH 7 -#define AD7150_CH2_AVG_LOW 8 #define AD7150_CH1_SENSITIVITY 9 #define AD7150_CH1_THR_HOLD_H 9 #define AD7150_CH1_TIMEOUT 10 -#define AD7150_CH1_THR_HOLD_L 10 #define AD7150_CH1_SETUP 11 #define AD7150_CH2_SENSITIVITY 12 #define AD7150_CH2_THR_HOLD_H 12 #define AD7150_CH2_TIMEOUT 13 -#define AD7150_CH2_THR_HOLD_L 13 #define AD7150_CH2_SETUP 14 #define AD7150_CFG 15 #define AD7150_CFG_FIX (1 << 7) @@ -54,25 +48,45 @@ #define AD7150_MAX_CONV_MODE 4 -/* - * struct ad7150_chip_info - chip specifc information +/** + * Todo list: + * - Review whether old_state usage makes sense. + * - get rid of explicit control of conversion mode */ +/** + * struct ad7150_chip_info - instance specific chip data + * @client: i2c client for this device + * @current_event: device always has one type of event enabled. + * This element stores the event code of the current one. + * @threshold: thresholds for simple capacitance value events + * @thresh_sensitivity: threshold for simple capacitance offset + * from 'average' value. + * @mag_sensitity: threshold for magnitude of capacitance offset from + * from 'average' value. + * @thresh_timeout: a timeout, in samples from the moment an + * adaptive threshold event occurs to when the average + * value jumps to current value. + * @mag_timeout: a timeout, in sample from the moment an + * adaptive magnitude event occurs to when the average + * value jumps to the current value. + * @old_state: store state from previous event, allowing confirmation + * of new condition. + * @conversion_mode: the current conversion mode. + * @state_lock: ensure consistent state of this structure wrt the + * hardware. + */ struct ad7150_chip_info { struct i2c_client *client; - bool inter; - u16 ch1_threshold; /* Ch1 Threshold (in fixed threshold mode) */ - u8 ch1_sensitivity; /* Ch1 Sensitivity (in adaptive threshold mode) */ - u8 ch1_timeout; /* Ch1 Timeout (in adaptive threshold mode) */ - u8 ch1_setup; - u16 ch2_threshold; /* Ch2 Threshold (in fixed threshold mode) */ - u8 ch2_sensitivity; /* Ch1 Sensitivity (in adaptive threshold mode) */ - u8 ch2_timeout; /* Ch1 Timeout (in adaptive threshold mode) */ - u8 ch2_setup; - u8 powerdown_timer; - char threshold_mode[10]; /* adaptive/fixed threshold mode */ + u64 current_event; + u16 threshold[2][2]; + u8 thresh_sensitivity[2][2]; + u8 mag_sensitivity[2][2]; + u8 thresh_timeout[2][2]; + u8 mag_timeout[2][2]; int old_state; char *conversion_mode; + struct mutex state_lock; }; struct ad7150_conversion_mode { @@ -88,81 +102,14 @@ ad7150_conv_mode_table[AD7150_MAX_CONV_MODE] = { { "power-down", 3 }, }; -/* - * ad7150 register access by I2C - */ - -static int ad7150_i2c_read(struct ad7150_chip_info *chip, u8 reg, u8 *data, int len) -{ - struct i2c_client *client = chip->client; - int ret = 0; - - ret = i2c_master_send(client, ®, 1); - if (ret < 0) { - dev_err(&client->dev, "I2C write error\n"); - return ret; - } - - ret = i2c_master_recv(client, data, len); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - return ret; -} - -static int ad7150_i2c_write(struct ad7150_chip_info *chip, u8 reg, u8 data) -{ - struct i2c_client *client = chip->client; - int ret = 0; - - u8 tx[2] = { - reg, - data, - }; - - ret = i2c_master_send(client, tx, 2); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - /* * sysfs nodes */ -#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ +#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0) #define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_AVAIL_THRESHOLD_MODES(_show) \ - IIO_DEVICE_ATTR(available_threshold_modes, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_THRESHOLD_MODE(_mode, _show, _store) \ - IIO_DEVICE_ATTR(threshold_mode, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_THRESHOLD(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_threshold, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_THRESHOLD(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_threshold, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_SENSITIVITY(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_sensitivity, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_SENSITIVITY(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_sensitivity, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_TIMEOUT(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_timeout, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_TIMEOUT(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_timeout, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_VALUE(_show) \ - IIO_DEVICE_ATTR(ch1_value, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CH2_VALUE(_show) \ - IIO_DEVICE_ATTR(ch2_value, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CH1_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_POWERDOWN_TIMER(_mode, _show, _store) \ - IIO_DEVICE_ATTR(powerdown_timer, _mode, _show, _store, 0) static ssize_t ad7150_show_conversion_modes(struct device *dev, struct device_attribute *attr, @@ -172,7 +119,8 @@ static ssize_t ad7150_show_conversion_modes(struct device *dev, int len = 0; for (i = 0; i < AD7150_MAX_CONV_MODE; i++) - len += sprintf(buf + len, "%s\n", ad7150_conv_mode_table[i].name); + len += sprintf(buf + len, "%s\n", + ad7150_conv_mode_table[i].name); return len; } @@ -197,16 +145,24 @@ static ssize_t ad7150_store_conversion_mode(struct device *dev, struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7150_chip_info *chip = iio_priv(dev_info); u8 cfg; - int i; + int i, ret; - ad7150_i2c_read(chip, AD7150_CFG, &cfg, 1); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); + if (ret < 0) + return ret; + cfg = ret; for (i = 0; i < AD7150_MAX_CONV_MODE; i++) { if (strncmp(buf, ad7150_conv_mode_table[i].name, - strlen(ad7150_conv_mode_table[i].name) - 1) == 0) { + strlen(ad7150_conv_mode_table[i].name) - 1) == + 0) { chip->conversion_mode = ad7150_conv_mode_table[i].name; cfg |= 0x18 | ad7150_conv_mode_table[i].reg_cfg; - ad7150_i2c_write(chip, AD7150_CFG, cfg); + ret = i2c_smbus_write_byte_data(chip->client, + AD7150_CFG, + cfg); + if (ret < 0) + return ret; return len; } } @@ -220,419 +176,376 @@ static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR, ad7150_show_conversion_mode, ad7150_store_conversion_mode); -static ssize_t ad7150_show_threshold_modes(struct device *dev, - struct device_attribute *attr, - char *buf) +static const u8 ad7150_addresses[][6] = { + { AD7150_CH1_DATA_HIGH, AD7150_CH1_AVG_HIGH, + AD7150_CH1_SETUP, AD7150_CH1_THR_HOLD_H, + AD7150_CH1_SENSITIVITY, AD7150_CH1_TIMEOUT }, + { AD7150_CH2_DATA_HIGH, AD7150_CH2_AVG_HIGH, + AD7150_CH2_SETUP, AD7150_CH2_THR_HOLD_H, + AD7150_CH2_SENSITIVITY, AD7150_CH2_TIMEOUT }, +}; + +static int ad7150_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) { - return sprintf(buf, "adaptive\nfixed\n"); -} + int ret; + struct ad7150_chip_info *chip = iio_priv(indio_dev); -static IIO_DEV_ATTR_AVAIL_THRESHOLD_MODES(ad7150_show_threshold_modes); - -static ssize_t ad7150_show_ch1_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - u8 data[2]; - - ad7150_i2c_read(chip, AD7150_CH1_DATA_HIGH, data, 2); - return sprintf(buf, "%d\n", ((int) data[0] << 8) | data[1]); -} - -static IIO_DEV_ATTR_CH1_VALUE(ad7150_show_ch1_value); - -static ssize_t ad7150_show_ch2_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - u8 data[2]; - - ad7150_i2c_read(chip, AD7150_CH2_DATA_HIGH, data, 2); - return sprintf(buf, "%d\n", ((int) data[0] << 8) | data[1]); -} - -static IIO_DEV_ATTR_CH2_VALUE(ad7150_show_ch2_value); - -static ssize_t ad7150_show_threshold_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%s\n", chip->threshold_mode); -} - -static ssize_t ad7150_store_threshold_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - u8 cfg; - - ad7150_i2c_read(chip, AD7150_CFG, &cfg, 1); - - if (strncmp(buf, "fixed", 5) == 0) { - strcpy(chip->threshold_mode, "fixed"); - cfg |= AD7150_CFG_FIX; - ad7150_i2c_write(chip, AD7150_CFG, cfg); - - return len; - } else if (strncmp(buf, "adaptive", 8) == 0) { - strcpy(chip->threshold_mode, "adaptive"); - cfg &= ~AD7150_CFG_FIX; - ad7150_i2c_write(chip, AD7150_CFG, cfg); - - return len; + switch (mask) { + case 0: + ret = i2c_smbus_read_word_data(chip->client, + ad7150_addresses[chan->channel][0]); + if (ret < 0) + return ret; + *val = swab16(ret); + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE): + ret = i2c_smbus_read_word_data(chip->client, + ad7150_addresses[chan->channel][1]); + if (ret < 0) + return ret; + *val = swab16(ret); + return IIO_VAL_INT; + default: + return -EINVAL; } +} - dev_err(dev, "not supported threshold mode\n"); +static int ad7150_read_event_config(struct iio_dev *indio_dev, u64 event_code) +{ + int ret; + u8 threshtype; + bool adaptive; + struct ad7150_chip_info *chip = iio_priv(indio_dev); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING); + + ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); + if (ret < 0) + return ret; + + threshtype = (ret >> 5) & 0x03; + adaptive = !!(ret & 0x80); + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + if (rising) + return adaptive && (threshtype == 0x1); + else + return adaptive && (threshtype == 0x0); + case IIO_EV_TYPE_THRESH_ADAPTIVE: + if (rising) + return adaptive && (threshtype == 0x3); + else + return adaptive && (threshtype == 0x2); + + case IIO_EV_TYPE_THRESH: + if (rising) + return !adaptive && (threshtype == 0x1); + else + return !adaptive && (threshtype == 0x0); + }; return -EINVAL; } -static IIO_DEV_ATTR_THRESHOLD_MODE(S_IRUGO | S_IWUSR, - ad7150_show_threshold_mode, - ad7150_store_threshold_mode); +/* lock should be held */ +static int ad7150_write_event_params(struct iio_dev *indio_dev, u64 event_code) +{ + int ret; + u16 value; + u8 sens, timeout; + struct ad7150_chip_info *chip = iio_priv(indio_dev); + int chan = IIO_EVENT_CODE_EXTRACT_NUM(event_code); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING); -static ssize_t ad7150_show_ch1_threshold(struct device *dev, - struct device_attribute *attr, - char *buf) + if (event_code != chip->current_event) + return 0; + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + /* Note completely different from the adaptive versions */ + case IIO_EV_TYPE_THRESH: + value = chip->threshold[rising][chan]; + ret = i2c_smbus_write_word_data(chip->client, + ad7150_addresses[chan][3], + swab16(value)); + if (ret < 0) + return ret; + return 0; + case IIO_EV_TYPE_MAG_ADAPTIVE: + sens = chip->mag_sensitivity[rising][chan]; + timeout = chip->mag_timeout[rising][chan]; + break; + case IIO_EV_TYPE_THRESH_ADAPTIVE: + sens = chip->thresh_sensitivity[rising][chan]; + timeout = chip->thresh_timeout[rising][chan]; + break; + default: + return -EINVAL; + }; + ret = i2c_smbus_write_byte_data(chip->client, + ad7150_addresses[chan][4], + sens); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_byte_data(chip->client, + ad7150_addresses[chan][5], + timeout); + if (ret < 0) + return ret; + + return 0; +} + +static int ad7150_write_event_config(struct iio_dev *indio_dev, + u64 event_code, int state) +{ + u8 thresh_type, cfg, adaptive; + int ret; + struct ad7150_chip_info *chip = iio_priv(indio_dev); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING); + + /* Something must always be turned on */ + if (state == 0) + return -EINVAL; + + if (event_code == chip->current_event) + return 0; + mutex_lock(&chip->state_lock); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); + if (ret < 0) + goto error_ret; + + cfg = ret & ~((0x03 << 5) | (0x1 << 7)); + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + adaptive = 1; + if (rising) + thresh_type = 0x1; + else + thresh_type = 0x0; + break; + case IIO_EV_TYPE_THRESH_ADAPTIVE: + adaptive = 1; + if (rising) + thresh_type = 0x3; + else + thresh_type = 0x2; + break; + case IIO_EV_TYPE_THRESH: + adaptive = 0; + if (rising) + thresh_type = 0x1; + else + thresh_type = 0x0; + break; + default: + ret = -EINVAL; + goto error_ret; + }; + + cfg |= (!adaptive << 7) | (thresh_type << 5); + + ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG, cfg); + if (ret < 0) + goto error_ret; + + chip->current_event = event_code; + + /* update control attributes */ + ret = ad7150_write_event_params(indio_dev, event_code); +error_ret: + mutex_unlock(&chip->state_lock); + + return 0; +} + +static int ad7150_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val) +{ + int chan = IIO_EVENT_CODE_EXTRACT_NUM(event_code); + struct ad7150_chip_info *chip = iio_priv(indio_dev); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING); + + /* Complex register sharing going on here */ + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + *val = chip->mag_sensitivity[rising][chan]; + return 0; + + case IIO_EV_TYPE_THRESH_ADAPTIVE: + *val = chip->thresh_sensitivity[rising][chan]; + return 0; + + case IIO_EV_TYPE_THRESH: + *val = chip->threshold[rising][chan]; + return 0; + + default: + return -EINVAL; + }; +} + +static int ad7150_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val) +{ + int ret; + struct ad7150_chip_info *chip = iio_priv(indio_dev); + int chan = IIO_EVENT_CODE_EXTRACT_NUM(event_code); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING); + + mutex_lock(&chip->state_lock); + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + chip->mag_sensitivity[rising][chan] = val; + break; + case IIO_EV_TYPE_THRESH_ADAPTIVE: + chip->thresh_sensitivity[rising][chan] = val; + break; + case IIO_EV_TYPE_THRESH: + chip->threshold[rising][chan] = val; + break; + default: + ret = -EINVAL; + goto error_ret; + }; + + /* write back if active */ + ret = ad7150_write_event_params(indio_dev, event_code); + + mutex_unlock(&chip->state_lock); +error_ret: + return ret; +} + +static ssize_t ad7150_show_timeout(struct device *dev, + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7150_chip_info *chip = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + u8 value; - return sprintf(buf, "%d\n", chip->ch1_threshold); + /* use the event code for consistency reasons */ + int chan = IIO_EVENT_CODE_EXTRACT_NUM(this_attr->address); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address) + == IIO_EV_DIR_RISING); + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + value = chip->mag_timeout[rising][chan]; + break; + case IIO_EV_TYPE_THRESH_ADAPTIVE: + value = chip->thresh_timeout[rising][chan]; + break; + default: + return -EINVAL; + }; + + return sprintf(buf, "%d\n", value); } -static ssize_t ad7150_store_ch1_threshold(struct device *dev, +static ssize_t ad7150_store_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7150_chip_info *chip = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int chan = IIO_EVENT_CODE_EXTRACT_NUM(this_attr->address); + int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address) == + IIO_EV_DIR_RISING); + u8 data; int ret; - ret = strict_strtoul(buf, 10, &data); + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; - if ((!ret) && (data < 0x10000)) { - ad7150_i2c_write(chip, AD7150_CH1_THR_HOLD_H, data >> 8); - ad7150_i2c_write(chip, AD7150_CH1_THR_HOLD_L, data); - chip->ch1_threshold = data; - return len; - } + mutex_lock(&chip->state_lock); + switch (IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address)) { + case IIO_EV_TYPE_MAG_ADAPTIVE: + chip->mag_timeout[rising][chan] = data; + break; + case IIO_EV_TYPE_THRESH_ADAPTIVE: + chip->thresh_timeout[rising][chan] = data; + break; + default: + ret = -EINVAL; + goto error_ret; + }; - return -EINVAL; + ret = ad7150_write_event_params(indio_dev, this_attr->address); +error_ret: + mutex_unlock(&chip->state_lock); + + if (ret < 0) + return ret; + + return len; } -static IIO_DEV_ATTR_CH1_THRESHOLD(S_IRUGO | S_IWUSR, - ad7150_show_ch1_threshold, - ad7150_store_ch1_threshold); +#define AD7150_TIMEOUT(chan, type, dir, ev_type, ev_dir) \ + IIO_DEVICE_ATTR(in_capacitance##chan##_##type##_##dir##_timeout, \ + S_IRUGO | S_IWUSR, \ + &ad7150_show_timeout, \ + &ad7150_store_timeout, \ + IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, \ + chan, \ + IIO_EV_TYPE_##ev_type, \ + IIO_EV_DIR_##ev_dir)) +static AD7150_TIMEOUT(0, mag_adaptive, rising, MAG_ADAPTIVE, RISING); +static AD7150_TIMEOUT(0, mag_adaptive, falling, MAG_ADAPTIVE, FALLING); +static AD7150_TIMEOUT(1, mag_adaptive, rising, MAG_ADAPTIVE, RISING); +static AD7150_TIMEOUT(1, mag_adaptive, falling, MAG_ADAPTIVE, FALLING); +static AD7150_TIMEOUT(0, thresh_adaptive, rising, THRESH_ADAPTIVE, RISING); +static AD7150_TIMEOUT(0, thresh_adaptive, falling, THRESH_ADAPTIVE, FALLING); +static AD7150_TIMEOUT(1, thresh_adaptive, rising, THRESH_ADAPTIVE, RISING); +static AD7150_TIMEOUT(1, thresh_adaptive, falling, THRESH_ADAPTIVE, FALLING); -static ssize_t ad7150_show_ch2_threshold(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch2_threshold); -} - -static ssize_t ad7150_store_ch2_threshold(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad7150_i2c_write(chip, AD7150_CH2_THR_HOLD_H, data >> 8); - ad7150_i2c_write(chip, AD7150_CH2_THR_HOLD_L, data); - chip->ch2_threshold = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_THRESHOLD(S_IRUGO | S_IWUSR, - ad7150_show_ch2_threshold, - ad7150_store_ch2_threshold); - -static ssize_t ad7150_show_ch1_sensitivity(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch1_sensitivity); -} - -static ssize_t ad7150_store_ch1_sensitivity(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH1_SENSITIVITY, data); - chip->ch1_sensitivity = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH1_SENSITIVITY(S_IRUGO | S_IWUSR, - ad7150_show_ch1_sensitivity, - ad7150_store_ch1_sensitivity); - -static ssize_t ad7150_show_ch2_sensitivity(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch2_sensitivity); -} - -static ssize_t ad7150_store_ch2_sensitivity(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH2_SENSITIVITY, data); - chip->ch2_sensitivity = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_SENSITIVITY(S_IRUGO | S_IWUSR, - ad7150_show_ch2_sensitivity, - ad7150_store_ch2_sensitivity); - -static ssize_t ad7150_show_ch1_timeout(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch1_timeout); -} - -static ssize_t ad7150_store_ch1_timeout(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH1_TIMEOUT, data); - chip->ch1_timeout = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH1_TIMEOUT(S_IRUGO | S_IWUSR, - ad7150_show_ch1_timeout, - ad7150_store_ch1_timeout); - -static ssize_t ad7150_show_ch2_timeout(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch2_timeout); -} - -static ssize_t ad7150_store_ch2_timeout(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH2_TIMEOUT, data); - chip->ch2_timeout = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_TIMEOUT(S_IRUGO | S_IWUSR, - ad7150_show_ch2_timeout, - ad7150_store_ch2_timeout); - -static ssize_t ad7150_show_ch1_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->ch1_setup); -} - -static ssize_t ad7150_store_ch1_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH1_SETUP, data); - chip->ch1_setup = data; - return len; - } - - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH1_SETUP(S_IRUGO | S_IWUSR, - ad7150_show_ch1_setup, - ad7150_store_ch1_setup); - -static ssize_t ad7150_show_ch2_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->ch2_setup); -} - -static ssize_t ad7150_store_ch2_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad7150_i2c_write(chip, AD7150_CH2_SETUP, data); - chip->ch2_setup = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_SETUP(S_IRUGO | S_IWUSR, - ad7150_show_ch2_setup, - ad7150_store_ch2_setup); - -static ssize_t ad7150_show_powerdown_timer(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->powerdown_timer); -} - -static ssize_t ad7150_store_powerdown_timer(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x40)) { - chip->powerdown_timer = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_POWERDOWN_TIMER(S_IRUGO | S_IWUSR, - ad7150_show_powerdown_timer, - ad7150_store_powerdown_timer); +static const struct iio_chan_spec ad7150_channels[] = { + { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE), + .event_mask = + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH_ADAPTIVE, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH_ADAPTIVE, IIO_EV_DIR_FALLING) | + IIO_EV_BIT(IIO_EV_TYPE_MAG_ADAPTIVE, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_MAG_ADAPTIVE, IIO_EV_DIR_FALLING) + }, { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE), + .event_mask = + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH_ADAPTIVE, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH_ADAPTIVE, IIO_EV_DIR_FALLING) | + IIO_EV_BIT(IIO_EV_TYPE_MAG_ADAPTIVE, IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_MAG_ADAPTIVE, IIO_EV_DIR_FALLING) + }, +}; static struct attribute *ad7150_attributes[] = { &iio_dev_attr_available_conversion_modes.dev_attr.attr, &iio_dev_attr_conversion_mode.dev_attr.attr, - &iio_dev_attr_available_threshold_modes.dev_attr.attr, - &iio_dev_attr_threshold_mode.dev_attr.attr, - &iio_dev_attr_ch1_threshold.dev_attr.attr, - &iio_dev_attr_ch2_threshold.dev_attr.attr, - &iio_dev_attr_ch1_timeout.dev_attr.attr, - &iio_dev_attr_ch2_timeout.dev_attr.attr, - &iio_dev_attr_ch1_setup.dev_attr.attr, - &iio_dev_attr_ch2_setup.dev_attr.attr, - &iio_dev_attr_ch1_sensitivity.dev_attr.attr, - &iio_dev_attr_ch2_sensitivity.dev_attr.attr, - &iio_dev_attr_powerdown_timer.dev_attr.attr, - &iio_dev_attr_ch1_value.dev_attr.attr, - &iio_dev_attr_ch2_value.dev_attr.attr, NULL, }; @@ -650,8 +563,13 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) struct ad7150_chip_info *chip = iio_priv(indio_dev); u8 int_status; s64 timestamp = iio_get_time_ns(); + int ret; - ad7150_i2c_read(chip, AD7150_STATUS, &int_status, 1); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS); + if (ret < 0) + return IRQ_HANDLED; + + int_status = ret; if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1)) @@ -686,19 +604,30 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); + /* store the status to avoid repushing same events */ + chip->old_state = int_status; + return IRQ_HANDLED; } -static IIO_CONST_ATTR(ch1_high_en, "1"); -static IIO_CONST_ATTR(ch2_high_en, "1"); -static IIO_CONST_ATTR(ch1_low_en, "1"); -static IIO_CONST_ATTR(ch2_low_en, "1"); - +/* Timeouts not currently handled by core */ static struct attribute *ad7150_event_attributes[] = { - &iio_const_attr_ch1_high_en.dev_attr.attr, - &iio_const_attr_ch2_high_en.dev_attr.attr, - &iio_const_attr_ch1_low_en.dev_attr.attr, - &iio_const_attr_ch2_low_en.dev_attr.attr, + &iio_dev_attr_in_capacitance0_mag_adaptive_rising_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance0_mag_adaptive_falling_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance1_mag_adaptive_rising_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance1_mag_adaptive_falling_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance0_thresh_adaptive_rising_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance0_thresh_adaptive_falling_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance1_thresh_adaptive_rising_timeout + .dev_attr.attr, + &iio_dev_attr_in_capacitance1_thresh_adaptive_falling_timeout + .dev_attr.attr, NULL, }; @@ -711,7 +640,13 @@ static const struct iio_info ad7150_info = { .attrs = &ad7150_attribute_group, .event_attrs = &ad7150_event_attribute_group, .driver_module = THIS_MODULE, + .read_raw = &ad7150_read_raw, + .read_event_config = &ad7150_read_event_config, + .write_event_config = &ad7150_write_event_config, + .read_event_value = &ad7150_read_event_value, + .write_event_value = &ad7150_write_event_value, }; + /* * device probe and remove */ @@ -729,13 +664,16 @@ static int __devinit ad7150_probe(struct i2c_client *client, goto error_ret; } chip = iio_priv(indio_dev); + mutex_init(&chip->state_lock); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); chip->client = client; - /* Establish that the iio_dev is a child of the i2c device */ indio_dev->name = id->name; + indio_dev->channels = ad7150_channels; + indio_dev->num_channels = ARRAY_SIZE(ad7150_channels); + /* Establish that the iio_dev is a child of the i2c device */ indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7150_info; @@ -758,8 +696,8 @@ static int __devinit ad7150_probe(struct i2c_client *client, if (ret) goto error_free_irq; - - dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq); + dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n", + id->name, client->irq); return 0; error_free_irq: From cd400fc94dc94d89876b38c0267ebe4e8ffb8675 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:21 +0100 Subject: [PATCH 0802/1519] staging:iio:adc:ad7150: remove conversion mode handling. The AD7150 family of devices power up in continues conversion mode. We can stay in this mode, unless power consumption becomes a real issue. Actually the event generation as well as the running average relies on continues conversion mode, so we better stay there. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7150.c | 94 -------------------------------- 1 file changed, 94 deletions(-) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 0685b8a0ffd..c561044363e 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -89,93 +89,10 @@ struct ad7150_chip_info { struct mutex state_lock; }; -struct ad7150_conversion_mode { - char *name; - u8 reg_cfg; -}; - -static struct ad7150_conversion_mode -ad7150_conv_mode_table[AD7150_MAX_CONV_MODE] = { - { "idle", 0 }, - { "continuous-conversion", 1 }, - { "single-conversion", 2 }, - { "power-down", 3 }, -}; - /* * sysfs nodes */ -#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ - IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ - IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) - -static ssize_t ad7150_show_conversion_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int i; - int len = 0; - - for (i = 0; i < AD7150_MAX_CONV_MODE; i++) - len += sprintf(buf + len, "%s\n", - ad7150_conv_mode_table[i].name); - - return len; -} - -static IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(ad7150_show_conversion_modes); - -static ssize_t ad7150_show_conversion_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%s\n", chip->conversion_mode); -} - -static ssize_t ad7150_store_conversion_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); - u8 cfg; - int i, ret; - - ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); - if (ret < 0) - return ret; - cfg = ret; - - for (i = 0; i < AD7150_MAX_CONV_MODE; i++) { - if (strncmp(buf, ad7150_conv_mode_table[i].name, - strlen(ad7150_conv_mode_table[i].name) - 1) == - 0) { - chip->conversion_mode = ad7150_conv_mode_table[i].name; - cfg |= 0x18 | ad7150_conv_mode_table[i].reg_cfg; - ret = i2c_smbus_write_byte_data(chip->client, - AD7150_CFG, - cfg); - if (ret < 0) - return ret; - return len; - } - } - - dev_err(dev, "not supported conversion mode\n"); - - return -EINVAL; -} - -static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR, - ad7150_show_conversion_mode, - ad7150_store_conversion_mode); - static const u8 ad7150_addresses[][6] = { { AD7150_CH1_DATA_HIGH, AD7150_CH1_AVG_HIGH, AD7150_CH1_SETUP, AD7150_CH1_THR_HOLD_H, @@ -543,16 +460,6 @@ static const struct iio_chan_spec ad7150_channels[] = { }, }; -static struct attribute *ad7150_attributes[] = { - &iio_dev_attr_available_conversion_modes.dev_attr.attr, - &iio_dev_attr_conversion_mode.dev_attr.attr, - NULL, -}; - -static const struct attribute_group ad7150_attribute_group = { - .attrs = ad7150_attributes, -}; - /* * threshold events */ @@ -637,7 +544,6 @@ static struct attribute_group ad7150_event_attribute_group = { }; static const struct iio_info ad7150_info = { - .attrs = &ad7150_attribute_group, .event_attrs = &ad7150_event_attribute_group, .driver_module = THIS_MODULE, .read_raw = &ad7150_read_raw, From 4e687ddba3349c410f82412b85e9151aeadcd2d2 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:22 +0100 Subject: [PATCH 0803/1519] staging:iio:adc:ad7150: Add support for the second interrupt strobe. The AD7150 features two outputs that can be used as interrupt strobes to the host processor. In order to receive all events independently, both need to utilized. Update copyright notice. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7150.c | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index c561044363e..d5102e5efda 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -1,7 +1,7 @@ /* * AD7150 capacitive sensor driver supporting AD7150/1/6 * - * Copyright 2010 Analog Devices Inc. + * Copyright 2010-2011 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ @@ -46,14 +46,6 @@ #define AD7150_SN0 22 #define AD7150_ID 23 -#define AD7150_MAX_CONV_MODE 4 - -/** - * Todo list: - * - Review whether old_state usage makes sense. - * - get rid of explicit control of conversion mode - */ - /** * struct ad7150_chip_info - instance specific chip data * @client: i2c client for this device @@ -592,24 +584,40 @@ static int __devinit ad7150_probe(struct i2c_client *client, &ad7150_event_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - "ad7150", + "ad7150_irq1", indio_dev); if (ret) goto error_free_dev; } + if (client->dev.platform_data) { + ret = request_threaded_irq(*(unsigned int *) + client->dev.platform_data, + NULL, + &ad7150_event_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING, + "ad7150_irq2", + indio_dev); + if (ret) + goto error_free_irq; + } + ret = iio_device_register(indio_dev); if (ret) - goto error_free_irq; + goto error_free_irq2; dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n", id->name, client->irq); return 0; +error_free_irq2: + if (client->dev.platform_data) + free_irq(*(unsigned int *)client->dev.platform_data, + indio_dev); error_free_irq: if (client->irq) free_irq(client->irq, indio_dev); - error_free_dev: iio_free_device(indio_dev); error_ret: @@ -622,6 +630,10 @@ static int __devexit ad7150_remove(struct i2c_client *client) if (client->irq) free_irq(client->irq, indio_dev); + + if (client->dev.platform_data) + free_irq(*(unsigned int *)client->dev.platform_data, indio_dev); + iio_device_unregister(indio_dev); return 0; @@ -656,7 +668,7 @@ static __exit void ad7150_exit(void) } MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ad7150/1/6 capacitive sensor driver"); +MODULE_DESCRIPTION("Analog Devices AD7150/1/6 capacitive sensor driver"); MODULE_LICENSE("GPL v2"); module_init(ad7150_init); From 3995f917827a523e8b0681b83e9260862659f5c9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:23 +0100 Subject: [PATCH 0804/1519] staging:iio:adc:ad7152 use smbus read / write functions + checkpatch fixes This is fine IF I have read the data sheet correctly. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 418 +++++++++++-------------------- 1 file changed, 147 insertions(+), 271 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index fcec9b620c6..ed8fdc6b7e3 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -17,6 +17,9 @@ #include "../iio.h" #include "../sysfs.h" +/* + * TODO: Check compliance of calibscale and calibbias with abi (units) + */ /* * AD7152 registers definition */ @@ -25,18 +28,12 @@ #define AD7152_STATUS_RDY1 (1 << 0) #define AD7152_STATUS_RDY2 (1 << 1) #define AD7152_CH1_DATA_HIGH 1 -#define AD7152_CH1_DATA_LOW 2 #define AD7152_CH2_DATA_HIGH 3 -#define AD7152_CH2_DATA_LOW 4 #define AD7152_CH1_OFFS_HIGH 5 -#define AD7152_CH1_OFFS_LOW 6 #define AD7152_CH2_OFFS_HIGH 7 -#define AD7152_CH2_OFFS_LOW 8 #define AD7152_CH1_GAIN_HIGH 9 -#define AD7152_CH1_GAIN_LOW 10 #define AD7152_CH1_SETUP 11 #define AD7152_CH2_GAIN_HIGH 12 -#define AD7152_CH2_GAIN_LOW 13 #define AD7152_CH2_SETUP 14 #define AD7152_CFG 15 #define AD7152_RESEVERD 16 @@ -52,13 +49,13 @@ struct ad7152_chip_info { struct i2c_client *client; - u16 ch1_offset; /* Channel 1 offset calibration coefficient */ - u16 ch1_gain; /* Channel 1 gain coefficient */ u8 ch1_setup; - u16 ch2_offset; /* Channel 2 offset calibration coefficient */ - u16 ch2_gain; /* Channel 1 gain coefficient */ u8 ch2_setup; - u8 filter_rate_setup; /* Capacitive channel digital filter setup; conversion time/update rate setup per channel */ + /* + * Capacitive channel digital filter setup; + * conversion time/update rate setup per channel + */ + u8 filter_rate_setup; char *conversion_mode; }; @@ -77,66 +74,14 @@ ad7152_conv_mode_table[AD7152_MAX_CONV_MODE] = { { "gain-calibration", 6 }, }; -/* - * ad7152 register access by I2C - */ - -static int ad7152_i2c_read(struct ad7152_chip_info *chip, u8 reg, u8 *data, int len) -{ - struct i2c_client *client = chip->client; - int ret; - - ret = i2c_master_send(client, ®, 1); - if (ret < 0) { - dev_err(&client->dev, "I2C write error\n"); - return ret; - } - - ret = i2c_master_recv(client, data, len); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - } - - return ret; -} - -static int ad7152_i2c_write(struct ad7152_chip_info *chip, u8 reg, u8 data) -{ - struct i2c_client *client = chip->client; - int ret; - - u8 tx[2] = { - reg, - data, - }; - - ret = i2c_master_send(client, tx, 2); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - /* * sysfs nodes */ -#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ +#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0) #define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_OFFSET(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_offset, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_OFFSET(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_offset, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_gain, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_gain, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_VALUE(_show) \ - IIO_DEVICE_ATTR(ch1_value, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CH2_VALUE(_show) \ - IIO_DEVICE_ATTR(ch2_value, S_IRUGO, _show, NULL, 0) #define IIO_DEV_ATTR_CH1_SETUP(_mode, _show, _store) \ IIO_DEVICE_ATTR(ch1_setup, _mode, _show, _store, 0) #define IIO_DEV_ATTR_CH2_SETUP(_mode, _show, _store) \ @@ -152,7 +97,8 @@ static ssize_t ad7152_show_conversion_modes(struct device *dev, int len = 0; for (i = 0; i < AD7152_MAX_CONV_MODE; i++) - len += sprintf(buf + len, "%s ", ad7152_conv_mode_table[i].name); + len += sprintf(buf + len, "%s ", + ad7152_conv_mode_table[i].name); len += sprintf(buf + len, "\n"); @@ -161,34 +107,6 @@ static ssize_t ad7152_show_conversion_modes(struct device *dev, static IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(ad7152_show_conversion_modes); -static ssize_t ad7152_show_ch1_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - u8 data[2]; - - ad7152_i2c_read(chip, AD7152_CH1_DATA_HIGH, data, 2); - return sprintf(buf, "%d\n", ((int)data[0] << 8) | data[1]); -} - -static IIO_DEV_ATTR_CH1_VALUE(ad7152_show_ch1_value); - -static ssize_t ad7152_show_ch2_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - u8 data[2]; - - ad7152_i2c_read(chip, AD7152_CH2_DATA_HIGH, data, 2); - return sprintf(buf, "%d\n", ((int)data[0] << 8) | data[1]); -} - -static IIO_DEV_ATTR_CH2_VALUE(ad7152_show_ch2_value); - static ssize_t ad7152_show_conversion_mode(struct device *dev, struct device_attribute *attr, char *buf) @@ -207,16 +125,23 @@ static ssize_t ad7152_store_conversion_mode(struct device *dev, struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(dev_info); u8 cfg; - int i; + int i, ret; - ad7152_i2c_read(chip, AD7152_CFG, &cfg, 1); + ret = i2c_smbus_read_byte_data(chip->client, AD7152_CFG); + if (ret < 0) + return ret; + cfg = ret; for (i = 0; i < AD7152_MAX_CONV_MODE; i++) if (strncmp(buf, ad7152_conv_mode_table[i].name, - strlen(ad7152_conv_mode_table[i].name) - 1) == 0) { + strlen(ad7152_conv_mode_table[i].name) - 1) == + 0) { chip->conversion_mode = ad7152_conv_mode_table[i].name; cfg |= 0x18 | ad7152_conv_mode_table[i].reg_cfg; - ad7152_i2c_write(chip, AD7152_CFG, cfg); + ret = i2c_smbus_write_byte_data(chip->client, + AD7152_CFG, cfg); + if (ret < 0) + return ret; return len; } @@ -229,150 +154,6 @@ static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR, ad7152_show_conversion_mode, ad7152_store_conversion_mode); -static ssize_t ad7152_show_ch1_offset(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch1_offset); -} - -static ssize_t ad7152_store_ch1_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad7152_i2c_write(chip, AD7152_CH1_OFFS_HIGH, data >> 8); - ad7152_i2c_write(chip, AD7152_CH1_OFFS_LOW, data); - chip->ch1_offset = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH1_OFFSET(S_IRUGO | S_IWUSR, - ad7152_show_ch1_offset, - ad7152_store_ch1_offset); - -static ssize_t ad7152_show_ch2_offset(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch2_offset); -} - -static ssize_t ad7152_store_ch2_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad7152_i2c_write(chip, AD7152_CH2_OFFS_HIGH, data >> 8); - ad7152_i2c_write(chip, AD7152_CH2_OFFS_LOW, data); - chip->ch2_offset = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_OFFSET(S_IRUGO | S_IWUSR, - ad7152_show_ch2_offset, - ad7152_store_ch2_offset); - -static ssize_t ad7152_show_ch1_gain(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch1_gain); -} - -static ssize_t ad7152_store_ch1_gain(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad7152_i2c_write(chip, AD7152_CH1_GAIN_HIGH, data >> 8); - ad7152_i2c_write(chip, AD7152_CH1_GAIN_LOW, data); - chip->ch1_gain = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH1_GAIN(S_IRUGO | S_IWUSR, - ad7152_show_ch1_gain, - ad7152_store_ch1_gain); - -static ssize_t ad7152_show_ch2_gain(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->ch2_gain); -} - -static ssize_t ad7152_store_ch2_gain(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad7152_i2c_write(chip, AD7152_CH2_GAIN_HIGH, data >> 8); - ad7152_i2c_write(chip, AD7152_CH2_GAIN_LOW, data); - chip->ch2_gain = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CH2_GAIN(S_IRUGO | S_IWUSR, - ad7152_show_ch2_gain, - ad7152_store_ch2_gain); - static ssize_t ad7152_show_ch1_setup(struct device *dev, struct device_attribute *attr, char *buf) @@ -390,18 +171,20 @@ static ssize_t ad7152_store_ch1_setup(struct device *dev, { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; + u8 data; int ret; - ret = strict_strtoul(buf, 10, &data); + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; - if ((!ret) && (data < 0x100)) { - ad7152_i2c_write(chip, AD7152_CH1_SETUP, data); - chip->ch1_setup = data; - return len; - } + ret = i2c_smbus_write_byte_data(chip->client, AD7152_CH1_SETUP, data); + if (ret < 0) + return ret; - return -EINVAL; + chip->ch1_setup = data; + + return len; } static IIO_DEV_ATTR_CH1_SETUP(S_IRUGO | S_IWUSR, @@ -425,18 +208,20 @@ static ssize_t ad7152_store_ch2_setup(struct device *dev, { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; + u8 data; int ret; - ret = strict_strtoul(buf, 10, &data); + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; - if ((!ret) && (data < 0x100)) { - ad7152_i2c_write(chip, AD7152_CH2_SETUP, data); - chip->ch2_setup = data; - return len; - } + ret = i2c_smbus_write_byte_data(chip->client, AD7152_CH2_SETUP, data); + if (ret < 0) + return ret; - return -EINVAL; + chip->ch2_setup = data; + + return len; } static IIO_DEV_ATTR_CH2_SETUP(S_IRUGO | S_IWUSR, @@ -460,18 +245,20 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev, { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(dev_info); - unsigned long data; + u8 data; int ret; - ret = strict_strtoul(buf, 10, &data); + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; - if ((!ret) && (data < 0x100)) { - ad7152_i2c_write(chip, AD7152_CFG2, data); - chip->filter_rate_setup = data; - return len; - } + ret = i2c_smbus_write_byte_data(chip->client, AD7152_CFG2, data); + if (ret < 0) + return ret; - return -EINVAL; + chip->filter_rate_setup = data; + + return len; } static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR, @@ -481,12 +268,6 @@ static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR, static struct attribute *ad7152_attributes[] = { &iio_dev_attr_available_conversion_modes.dev_attr.attr, &iio_dev_attr_conversion_mode.dev_attr.attr, - &iio_dev_attr_ch1_gain.dev_attr.attr, - &iio_dev_attr_ch2_gain.dev_attr.attr, - &iio_dev_attr_ch1_offset.dev_attr.attr, - &iio_dev_attr_ch2_offset.dev_attr.attr, - &iio_dev_attr_ch1_value.dev_attr.attr, - &iio_dev_attr_ch2_value.dev_attr.attr, &iio_dev_attr_ch1_setup.dev_attr.attr, &iio_dev_attr_ch2_setup.dev_attr.attr, &iio_dev_attr_filter_rate_setup.dev_attr.attr, @@ -497,10 +278,103 @@ static const struct attribute_group ad7152_attribute_group = { .attrs = ad7152_attributes, }; +static const u8 ad7152_addresses[][3] = { + { AD7152_CH1_DATA_HIGH, AD7152_CH1_OFFS_HIGH, AD7152_CH1_GAIN_HIGH }, + { AD7152_CH2_DATA_HIGH, AD7152_CH2_OFFS_HIGH, AD7152_CH2_GAIN_HIGH }, +}; +static int ad7152_write_raw(struct iio_dev *dev_info, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct ad7152_chip_info *chip = iio_priv(dev_info); + int ret; + + switch (mask) { + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + if ((val < 0) | (val > 0xFFFF)) + return -EINVAL; + ret = i2c_smbus_write_word_data(chip->client, + ad7152_addresses[chan->channel][2], + val); + if (ret < 0) + return ret; + + return 0; + + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + if ((val < 0) | (val > 0xFFFF)) + return -EINVAL; + ret = i2c_smbus_write_word_data(chip->client, + ad7152_addresses[chan->channel][1], + val); + if (ret < 0) + return ret; + + return 0; + + default: + return -EINVAL; + } +} +static int ad7152_read_raw(struct iio_dev *dev_info, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + struct ad7152_chip_info *chip = iio_priv(dev_info); + int ret; + + switch (mask) { + case 0: + ret = i2c_smbus_read_word_data(chip->client, + ad7152_addresses[chan->channel][0]); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + /* FIXME: Hmm. very small. it's 1+ 1/(2^16 *val) */ + ret = i2c_smbus_read_word_data(chip->client, + ad7152_addresses[chan->channel][2]); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + ret = i2c_smbus_read_word_data(chip->client, + ad7152_addresses[chan->channel][1]); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + default: + return -EINVAL; + }; +} static const struct iio_info ad7152_info = { .attrs = &ad7152_attribute_group, + .read_raw = &ad7152_read_raw, + .write_raw = &ad7152_write_raw, .driver_module = THIS_MODULE, }; + +static const struct iio_chan_spec ad7152_channels[] = { + { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + }, { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + } +}; /* * device probe and remove */ @@ -527,6 +401,8 @@ static int __devinit ad7152_probe(struct i2c_client *client, indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7152_info; + indio_dev->channels = ad7152_channels; + indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); indio_dev->modes = INDIO_DIRECT_MODE; ret = iio_device_register(indio_dev); From 4050f493996b3fbebe4ee0db4a16083d67d6e85b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:24 +0100 Subject: [PATCH 0805/1519] staging:iio:adc:ad7152 set correct number of channels for ad7153. Has been broken for some time. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index ed8fdc6b7e3..1ec012dfacc 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -402,6 +402,10 @@ static int __devinit ad7152_probe(struct i2c_client *client, indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7152_info; indio_dev->channels = ad7152_channels; + if (id->driver_data == 0) + indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); + else + indio_dev->num_channels = 1; indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); indio_dev->modes = INDIO_DIRECT_MODE; @@ -430,7 +434,7 @@ static int __devexit ad7152_remove(struct i2c_client *client) static const struct i2c_device_id ad7152_id[] = { { "ad7152", 0 }, - { "ad7153", 0 }, + { "ad7153", 1 }, {} }; From ea993a5193874117fa0278c3b08e9e050089d860 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:25 +0100 Subject: [PATCH 0806/1519] staging:iio:adc:ad7152 bring more into line with abi. Get rid of explicit writes to registers and conversion mode control. Couple of bits I'm unsure about. * Do calibration modes self reset when done? How do you tell they are done? * Should we poll the status register just to be sure we have a new conversion? All done sans hardware. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 322 ++++++++++++++----------------- 1 file changed, 143 insertions(+), 179 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 1ec012dfacc..4ac5d7f26d6 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" @@ -49,185 +50,72 @@ struct ad7152_chip_info { struct i2c_client *client; - u8 ch1_setup; - u8 ch2_setup; /* * Capacitive channel digital filter setup; * conversion time/update rate setup per channel */ u8 filter_rate_setup; - char *conversion_mode; }; -struct ad7152_conversion_mode { - char *name; - u8 reg_cfg; -}; +static inline ssize_t ad7152_start_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len, + u8 regval) +{ + struct iio_dev *dev_info = dev_get_drvdata(dev); + struct ad7152_chip_info *chip = iio_priv(dev_info); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + bool doit; + int ret; -static struct ad7152_conversion_mode -ad7152_conv_mode_table[AD7152_MAX_CONV_MODE] = { - { "idle", 0 }, - { "continuous-conversion", 1 }, - { "single-conversion", 2 }, - { "power-down", 3 }, - { "offset-calibration", 5 }, - { "gain-calibration", 6 }, -}; + ret = strtobool(buf, &doit); + if (ret < 0) + return ret; -/* - * sysfs nodes - */ + if (!doit) + return 0; + + if (this_attr->address == 0) + regval |= (1 << 4); + else + regval |= (1 << 3); + + ret = i2c_smbus_write_byte_data(chip->client, AD7152_CFG, regval); + if (ret < 0) + return ret; + /* Unclear on period this should be set for or whether it flips back + * to idle automatically */ + return len; +} +static ssize_t ad7152_start_offset_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + + return ad7152_start_calib(dev, attr, buf, len, 5); +} +static ssize_t ad7152_start_gain_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + return ad7152_start_calib(dev, attr, buf, len, 6); +} + +static IIO_DEVICE_ATTR(in_capacitance0_calibbias_calibration, + S_IWUSR, NULL, ad7152_start_offset_calib, 0); +static IIO_DEVICE_ATTR(in_capacitance1_calibbias_calibration, + S_IWUSR, NULL, ad7152_start_offset_calib, 1); +static IIO_DEVICE_ATTR(in_capacitance0_calibscale_calibration, + S_IWUSR, NULL, ad7152_start_gain_calib, 0); +static IIO_DEVICE_ATTR(in_capacitance1_calibscale_calibration, + S_IWUSR, NULL, ad7152_start_gain_calib, 1); -#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ - IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ - IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH1_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch1_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CH2_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(ch2_setup, _mode, _show, _store, 0) #define IIO_DEV_ATTR_FILTER_RATE_SETUP(_mode, _show, _store) \ IIO_DEVICE_ATTR(filter_rate_setup, _mode, _show, _store, 0) -static ssize_t ad7152_show_conversion_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int i; - int len = 0; - - for (i = 0; i < AD7152_MAX_CONV_MODE; i++) - len += sprintf(buf + len, "%s ", - ad7152_conv_mode_table[i].name); - - len += sprintf(buf + len, "\n"); - - return len; -} - -static IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(ad7152_show_conversion_modes); - -static ssize_t ad7152_show_conversion_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%s\n", chip->conversion_mode); -} - -static ssize_t ad7152_store_conversion_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - u8 cfg; - int i, ret; - - ret = i2c_smbus_read_byte_data(chip->client, AD7152_CFG); - if (ret < 0) - return ret; - cfg = ret; - - for (i = 0; i < AD7152_MAX_CONV_MODE; i++) - if (strncmp(buf, ad7152_conv_mode_table[i].name, - strlen(ad7152_conv_mode_table[i].name) - 1) == - 0) { - chip->conversion_mode = ad7152_conv_mode_table[i].name; - cfg |= 0x18 | ad7152_conv_mode_table[i].reg_cfg; - ret = i2c_smbus_write_byte_data(chip->client, - AD7152_CFG, cfg); - if (ret < 0) - return ret; - return len; - } - - dev_err(dev, "not supported conversion mode\n"); - - return -EINVAL; -} - -static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR, - ad7152_show_conversion_mode, - ad7152_store_conversion_mode); - -static ssize_t ad7152_show_ch1_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->ch1_setup); -} - -static ssize_t ad7152_store_ch1_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - u8 data; - int ret; - - ret = kstrtou8(buf, 10, &data); - if (ret < 0) - return ret; - - ret = i2c_smbus_write_byte_data(chip->client, AD7152_CH1_SETUP, data); - if (ret < 0) - return ret; - - chip->ch1_setup = data; - - return len; -} - -static IIO_DEV_ATTR_CH1_SETUP(S_IRUGO | S_IWUSR, - ad7152_show_ch1_setup, - ad7152_store_ch1_setup); - -static ssize_t ad7152_show_ch2_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->ch2_setup); -} - -static ssize_t ad7152_store_ch2_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); - u8 data; - int ret; - - ret = kstrtou8(buf, 10, &data); - if (ret < 0) - return ret; - - ret = i2c_smbus_write_byte_data(chip->client, AD7152_CH2_SETUP, data); - if (ret < 0) - return ret; - - chip->ch2_setup = data; - - return len; -} - -static IIO_DEV_ATTR_CH2_SETUP(S_IRUGO | S_IWUSR, - ad7152_show_ch2_setup, - ad7152_store_ch2_setup); - static ssize_t ad7152_show_filter_rate_setup(struct device *dev, struct device_attribute *attr, char *buf) @@ -266,11 +154,11 @@ static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR, ad7152_store_filter_rate_setup); static struct attribute *ad7152_attributes[] = { - &iio_dev_attr_available_conversion_modes.dev_attr.attr, - &iio_dev_attr_conversion_mode.dev_attr.attr, - &iio_dev_attr_ch1_setup.dev_attr.attr, - &iio_dev_attr_ch2_setup.dev_attr.attr, &iio_dev_attr_filter_rate_setup.dev_attr.attr, + &iio_dev_attr_in_capacitance0_calibbias_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance1_calibbias_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance0_calibscale_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance1_calibscale_calibration.dev_attr.attr, NULL, }; @@ -278,10 +166,18 @@ static const struct attribute_group ad7152_attribute_group = { .attrs = ad7152_attributes, }; -static const u8 ad7152_addresses[][3] = { - { AD7152_CH1_DATA_HIGH, AD7152_CH1_OFFS_HIGH, AD7152_CH1_GAIN_HIGH }, - { AD7152_CH2_DATA_HIGH, AD7152_CH2_OFFS_HIGH, AD7152_CH2_GAIN_HIGH }, +static const u8 ad7152_addresses[][4] = { + { AD7152_CH1_DATA_HIGH, AD7152_CH1_OFFS_HIGH, + AD7152_CH1_GAIN_HIGH, AD7152_CH1_SETUP }, + { AD7152_CH2_DATA_HIGH, AD7152_CH2_OFFS_HIGH, + AD7152_CH2_GAIN_HIGH, AD7152_CH2_SETUP }, }; + +/* Values are micro relative to pf base. */ +static const int ad7152_scale_table[] = { + 488, 244, 122, 61 +}; + static int ad7152_write_raw(struct iio_dev *dev_info, struct iio_chan_spec const *chan, int val, @@ -289,7 +185,7 @@ static int ad7152_write_raw(struct iio_dev *dev_info, long mask) { struct ad7152_chip_info *chip = iio_priv(dev_info); - int ret; + int ret, i; switch (mask) { case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): @@ -313,7 +209,24 @@ static int ad7152_write_raw(struct iio_dev *dev_info, return ret; return 0; - + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + if (val != 0) + return -EINVAL; + for (i = 0; i < ARRAY_SIZE(ad7152_scale_table); i++) + if (val2 <= ad7152_scale_table[i]) + break; + ret = i2c_smbus_read_byte_data(chip->client, + ad7152_addresses[chan->channel][3]); + if (ret < 0) + return ret; + if ((ret & 0xC0) != i) + ret = i2c_smbus_write_byte_data(chip->client, + ad7152_addresses[chan->channel][3], + (ret & ~0xC0) | i); + if (ret < 0) + return ret; + else + return 0; default: return -EINVAL; } @@ -325,14 +238,34 @@ static int ad7152_read_raw(struct iio_dev *dev_info, { struct ad7152_chip_info *chip = iio_priv(dev_info); int ret; - + u8 regval = 0; switch (mask) { case 0: + /* First set whether in differential mode */ + if (chan->differential) + regval = (1 << 5); + + /* Make sure the channel is enabled */ + if (chan->channel == 0) + regval |= (1 << 4); + else + regval |= (1 << 3); + /* Trigger a single read */ + regval |= 0x02; + ret = i2c_smbus_write_byte_data(chip->client, + ad7152_addresses[chan->channel][3], + regval); + if (ret < 0) + return ret; + + msleep(60); /* Slowest conversion time */ + /* Now read the actual register */ ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][0]); if (ret < 0) return ret; *val = ret; + return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): /* FIXME: Hmm. very small. it's 1+ 1/(2^16 *val) */ @@ -341,6 +274,7 @@ static int ad7152_read_raw(struct iio_dev *dev_info, if (ret < 0) return ret; *val = ret; + return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): ret = i2c_smbus_read_word_data(chip->client, @@ -348,7 +282,17 @@ static int ad7152_read_raw(struct iio_dev *dev_info, if (ret < 0) return ret; *val = ret; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + ret = i2c_smbus_read_byte_data(chip->client, + ad7152_addresses[chan->channel][3]); + if (ret < 0) + return ret; + *val = 0; + *val2 = ad7152_scale_table[ret >> 6]; + + return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; }; @@ -366,13 +310,33 @@ static const struct iio_chan_spec ad7152_channels[] = { .indexed = 1, .channel = 0, .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), }, { .type = IIO_CAPACITANCE, .indexed = 1, .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + }, { + .type = IIO_CAPACITANCE, + .differential = 1, + .indexed = 1, + .channel = 0, + .channel2 = 2, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + }, { + .type = IIO_CAPACITANCE, + .differential = 1, + .indexed = 1, + .channel = 1, + .channel2 = 3, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), } }; /* @@ -405,7 +369,7 @@ static int __devinit ad7152_probe(struct i2c_client *client, if (id->driver_data == 0) indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); else - indio_dev->num_channels = 1; + indio_dev->num_channels = 2; indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); indio_dev->modes = INDIO_DIRECT_MODE; From e5664293992e7483cf70b82390cd0ce45fa53218 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:26 +0100 Subject: [PATCH 0807/1519] staging:iio:adc:ad7152: increase readability by introducing proper bit defines Some other miscellaneous cleanup. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 131 +++++++++++++++++++------------ 1 file changed, 82 insertions(+), 49 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 4ac5d7f26d6..a43cf63a9ed 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -1,7 +1,7 @@ /* * AD7152 capacitive sensor driver supporting AD7152/3 * - * Copyright 2010 Analog Devices Inc. + * Copyright 2010-2011a Analog Devices Inc. * * Licensed under the GPL-2 or later. */ @@ -25,24 +25,55 @@ * AD7152 registers definition */ -#define AD7152_STATUS 0 -#define AD7152_STATUS_RDY1 (1 << 0) -#define AD7152_STATUS_RDY2 (1 << 1) -#define AD7152_CH1_DATA_HIGH 1 -#define AD7152_CH2_DATA_HIGH 3 -#define AD7152_CH1_OFFS_HIGH 5 -#define AD7152_CH2_OFFS_HIGH 7 -#define AD7152_CH1_GAIN_HIGH 9 -#define AD7152_CH1_SETUP 11 -#define AD7152_CH2_GAIN_HIGH 12 -#define AD7152_CH2_SETUP 14 -#define AD7152_CFG 15 -#define AD7152_RESEVERD 16 -#define AD7152_CAPDAC_POS 17 -#define AD7152_CAPDAC_NEG 18 -#define AD7152_CFG2 26 +#define AD7152_REG_STATUS 0 +#define AD7152_REG_CH1_DATA_HIGH 1 +#define AD7152_REG_CH2_DATA_HIGH 3 +#define AD7152_REG_CH1_OFFS_HIGH 5 +#define AD7152_REG_CH2_OFFS_HIGH 7 +#define AD7152_REG_CH1_GAIN_HIGH 9 +#define AD7152_REG_CH1_SETUP 11 +#define AD7152_REG_CH2_GAIN_HIGH 12 +#define AD7152_REG_CH2_SETUP 14 +#define AD7152_REG_CFG 15 +#define AD7152_REG_RESEVERD 16 +#define AD7152_REG_CAPDAC_POS 17 +#define AD7152_REG_CAPDAC_NEG 18 +#define AD7152_REG_CFG2 26 -#define AD7152_MAX_CONV_MODE 6 +/* Status Register Bit Designations (AD7152_REG_STATUS) */ +#define AD7152_STATUS_RDY1 (1 << 0) +#define AD7152_STATUS_RDY2 (1 << 1) +#define AD7152_STATUS_C1C2 (1 << 2) +#define AD7152_STATUS_PWDN (1 << 7) + +/* Setup Register Bit Designations (AD7152_REG_CHx_SETUP) */ +#define AD7152_SETUP_CAPDIFF (1 << 5) +#define AD7152_SETUP_RANGE_2pF (0 << 6) +#define AD7152_SETUP_RANGE_0_5pF (1 << 6) +#define AD7152_SETUP_RANGE_1pF (2 << 6) +#define AD7152_SETUP_RANGE_4pF (3 << 6) + +/* Config Register Bit Designations (AD7152_REG_CFG) */ +#define AD7152_CONF_CH2EN (1 << 3) +#define AD7152_CONF_CH1EN (1 << 4) +#define AD7152_CONF_MODE_IDLE (0 << 0) +#define AD7152_CONF_MODE_CONT_CONV (1 << 0) +#define AD7152_CONF_MODE_SINGLE_CONV (2 << 0) +#define AD7152_CONF_MODE_OFFS_CAL (5 << 0) +#define AD7152_CONF_MODE_GAIN_CAL (6 << 0) + +/* Capdac Register Bit Designations (AD7152_REG_CAPDAC_XXX) */ +#define AD7152_CAPDAC_DACEN (1 << 7) +#define AD7152_CAPDAC_DACP(x) ((x) & 0x1F) + +#define AD7152_MAX_CONV_MODE 6 + +enum { + AD7152_DATA, + AD7152_OFFS, + AD7152_GAIN, + AD7152_SETUP +}; /* * struct ad7152_chip_info - chip specifc information @@ -77,11 +108,11 @@ static inline ssize_t ad7152_start_calib(struct device *dev, return 0; if (this_attr->address == 0) - regval |= (1 << 4); + regval |= AD7152_CONF_CH1EN; else - regval |= (1 << 3); + regval |= AD7152_CONF_CH2EN; - ret = i2c_smbus_write_byte_data(chip->client, AD7152_CFG, regval); + ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); if (ret < 0) return ret; /* Unclear on period this should be set for or whether it flips back @@ -94,14 +125,16 @@ static ssize_t ad7152_start_offset_calib(struct device *dev, size_t len) { - return ad7152_start_calib(dev, attr, buf, len, 5); + return ad7152_start_calib(dev, attr, buf, len, + AD7152_CONF_MODE_OFFS_CAL); } static ssize_t ad7152_start_gain_calib(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - return ad7152_start_calib(dev, attr, buf, len, 6); + return ad7152_start_calib(dev, attr, buf, len, + AD7152_CONF_MODE_GAIN_CAL); } static IIO_DEVICE_ATTR(in_capacitance0_calibbias_calibration, @@ -140,7 +173,7 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev, if (ret < 0) return ret; - ret = i2c_smbus_write_byte_data(chip->client, AD7152_CFG2, data); + ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG2, data); if (ret < 0) return ret; @@ -167,10 +200,10 @@ static const struct attribute_group ad7152_attribute_group = { }; static const u8 ad7152_addresses[][4] = { - { AD7152_CH1_DATA_HIGH, AD7152_CH1_OFFS_HIGH, - AD7152_CH1_GAIN_HIGH, AD7152_CH1_SETUP }, - { AD7152_CH2_DATA_HIGH, AD7152_CH2_OFFS_HIGH, - AD7152_CH2_GAIN_HIGH, AD7152_CH2_SETUP }, + { AD7152_REG_CH1_DATA_HIGH, AD7152_REG_CH1_OFFS_HIGH, + AD7152_REG_CH1_GAIN_HIGH, AD7152_REG_CH1_SETUP }, + { AD7152_REG_CH2_DATA_HIGH, AD7152_REG_CH2_OFFS_HIGH, + AD7152_REG_CH2_GAIN_HIGH, AD7152_REG_CH2_SETUP }, }; /* Values are micro relative to pf base. */ @@ -192,8 +225,8 @@ static int ad7152_write_raw(struct iio_dev *dev_info, if ((val < 0) | (val > 0xFFFF)) return -EINVAL; ret = i2c_smbus_write_word_data(chip->client, - ad7152_addresses[chan->channel][2], - val); + ad7152_addresses[chan->channel][AD7152_GAIN], + val); if (ret < 0) return ret; @@ -203,8 +236,8 @@ static int ad7152_write_raw(struct iio_dev *dev_info, if ((val < 0) | (val > 0xFFFF)) return -EINVAL; ret = i2c_smbus_write_word_data(chip->client, - ad7152_addresses[chan->channel][1], - val); + ad7152_addresses[chan->channel][AD7152_OFFS], + val); if (ret < 0) return ret; @@ -216,13 +249,13 @@ static int ad7152_write_raw(struct iio_dev *dev_info, if (val2 <= ad7152_scale_table[i]) break; ret = i2c_smbus_read_byte_data(chip->client, - ad7152_addresses[chan->channel][3]); + ad7152_addresses[chan->channel][AD7152_SETUP]); if (ret < 0) return ret; if ((ret & 0xC0) != i) ret = i2c_smbus_write_byte_data(chip->client, - ad7152_addresses[chan->channel][3], - (ret & ~0xC0) | i); + ad7152_addresses[chan->channel][AD7152_SETUP], + (ret & ~0xC0) | i); if (ret < 0) return ret; else @@ -243,25 +276,25 @@ static int ad7152_read_raw(struct iio_dev *dev_info, case 0: /* First set whether in differential mode */ if (chan->differential) - regval = (1 << 5); + regval = AD7152_SETUP_CAPDIFF; /* Make sure the channel is enabled */ - if (chan->channel == 0) - regval |= (1 << 4); + if (chan->address == 0) + regval |= AD7152_CONF_CH1EN; else - regval |= (1 << 3); + regval |= AD7152_CONF_CH2EN; /* Trigger a single read */ - regval |= 0x02; + regval |= AD7152_CONF_MODE_SINGLE_CONV; ret = i2c_smbus_write_byte_data(chip->client, - ad7152_addresses[chan->channel][3], - regval); + ad7152_addresses[chan->channel][AD7152_SETUP], + regval); if (ret < 0) return ret; msleep(60); /* Slowest conversion time */ /* Now read the actual register */ ret = i2c_smbus_read_word_data(chip->client, - ad7152_addresses[chan->channel][0]); + ad7152_addresses[chan->channel][AD7152_DATA]); if (ret < 0) return ret; *val = ret; @@ -270,7 +303,7 @@ static int ad7152_read_raw(struct iio_dev *dev_info, case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): /* FIXME: Hmm. very small. it's 1+ 1/(2^16 *val) */ ret = i2c_smbus_read_word_data(chip->client, - ad7152_addresses[chan->channel][2]); + ad7152_addresses[chan->channel][AD7152_GAIN]); if (ret < 0) return ret; *val = ret; @@ -278,7 +311,7 @@ static int ad7152_read_raw(struct iio_dev *dev_info, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): ret = i2c_smbus_read_word_data(chip->client, - ad7152_addresses[chan->channel][1]); + ad7152_addresses[chan->channel][AD7152_OFFS]); if (ret < 0) return ret; *val = ret; @@ -286,7 +319,7 @@ static int ad7152_read_raw(struct iio_dev *dev_info, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): ret = i2c_smbus_read_byte_data(chip->client, - ad7152_addresses[chan->channel][3]); + ad7152_addresses[chan->channel][AD7152_SETUP]); if (ret < 0) return ret; *val = 0; @@ -361,7 +394,7 @@ static int __devinit ad7152_probe(struct i2c_client *client, chip->client = client; - /* Echipabilish that the iio_dev is a child of the i2c device */ + /* Establish that the iio_dev is a child of the i2c device */ indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7152_info; @@ -406,7 +439,7 @@ MODULE_DEVICE_TABLE(i2c, ad7152_id); static struct i2c_driver ad7152_driver = { .driver = { - .name = "ad7152", + .name = KBUILD_MODNAME, }, .probe = ad7152_probe, .remove = __devexit_p(ad7152_remove), @@ -424,7 +457,7 @@ static __exit void ad7152_exit(void) } MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ad7152/3 capacitive sensor driver"); +MODULE_DESCRIPTION("Analog Devices AD7152/3 capacitive sensor driver"); MODULE_LICENSE("GPL v2"); module_init(ad7152_init); From 2b8cb40c9c788929bacbd0c2fdac847e66906805 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:27 +0100 Subject: [PATCH 0808/1519] staging:iio:adc:ad7152: Miscellaneous fixes and touch-up Remove unused define. Introduce cached SETUP variables. Wait until calibration finished. (Device returns to idle state) IIO_CHAN_INFO_CALIBSCALE_SEPARATE use proper scales. (range 1.0 to 1.99999) i2c_smbus word transactions expect low byte first, therefore swap bytes. CAPDIFF is bit in SETUP not CFG. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 81 ++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index a43cf63a9ed..6b9d7eae073 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -52,6 +52,7 @@ #define AD7152_SETUP_RANGE_0_5pF (1 << 6) #define AD7152_SETUP_RANGE_1pF (2 << 6) #define AD7152_SETUP_RANGE_4pF (3 << 6) +#define AD7152_SETUP_RANGE(x) ((x) << 6) /* Config Register Bit Designations (AD7152_REG_CFG) */ #define AD7152_CONF_CH2EN (1 << 3) @@ -66,8 +67,6 @@ #define AD7152_CAPDAC_DACEN (1 << 7) #define AD7152_CAPDAC_DACP(x) ((x) & 0x1F) -#define AD7152_MAX_CONV_MODE 6 - enum { AD7152_DATA, AD7152_OFFS, @@ -85,7 +84,8 @@ struct ad7152_chip_info { * Capacitive channel digital filter setup; * conversion time/update rate setup per channel */ - u8 filter_rate_setup; + u8 filter_rate_setup; + u8 setup[2]; }; static inline ssize_t ad7152_start_calib(struct device *dev, @@ -98,7 +98,7 @@ static inline ssize_t ad7152_start_calib(struct device *dev, struct ad7152_chip_info *chip = iio_priv(dev_info); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); bool doit; - int ret; + int ret, timeout = 10; ret = strtobool(buf, &doit); if (ret < 0) @@ -115,8 +115,14 @@ static inline ssize_t ad7152_start_calib(struct device *dev, ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); if (ret < 0) return ret; - /* Unclear on period this should be set for or whether it flips back - * to idle automatically */ + + do { + mdelay(20); + ret = i2c_smbus_read_byte_data(chip->client, AD7152_REG_CFG); + if (ret < 0) + return ret; + } while ((ret == regval) && timeout--); + return len; } static ssize_t ad7152_start_offset_calib(struct device *dev, @@ -124,7 +130,6 @@ static ssize_t ad7152_start_offset_calib(struct device *dev, const char *buf, size_t len) { - return ad7152_start_calib(dev, attr, buf, len, AD7152_CONF_MODE_OFFS_CAL); } @@ -222,11 +227,14 @@ static int ad7152_write_raw(struct iio_dev *dev_info, switch (mask) { case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): - if ((val < 0) | (val > 0xFFFF)) + if (val != 1) return -EINVAL; + + val = (val2 * 1024) / 15625; + ret = i2c_smbus_write_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_GAIN], - val); + swab16(val)); if (ret < 0) return ret; @@ -237,7 +245,7 @@ static int ad7152_write_raw(struct iio_dev *dev_info, return -EINVAL; ret = i2c_smbus_write_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_OFFS], - val); + swab16(val)); if (ret < 0) return ret; @@ -248,14 +256,13 @@ static int ad7152_write_raw(struct iio_dev *dev_info, for (i = 0; i < ARRAY_SIZE(ad7152_scale_table); i++) if (val2 <= ad7152_scale_table[i]) break; - ret = i2c_smbus_read_byte_data(chip->client, - ad7152_addresses[chan->channel][AD7152_SETUP]); - if (ret < 0) - return ret; - if ((ret & 0xC0) != i) - ret = i2c_smbus_write_byte_data(chip->client, + + chip->setup[chan->channel] &= ~AD7152_SETUP_RANGE_4pF; + chip->setup[chan->channel] |= AD7152_SETUP_RANGE(i); + + ret = i2c_smbus_write_byte_data(chip->client, ad7152_addresses[chan->channel][AD7152_SETUP], - (ret & ~0xC0) | i); + chip->setup[chan->channel]); if (ret < 0) return ret; else @@ -275,18 +282,30 @@ static int ad7152_read_raw(struct iio_dev *dev_info, switch (mask) { case 0: /* First set whether in differential mode */ - if (chan->differential) - regval = AD7152_SETUP_CAPDIFF; - /* Make sure the channel is enabled */ - if (chan->address == 0) - regval |= AD7152_CONF_CH1EN; + regval = chip->setup[chan->channel]; + + if (chan->differential) + chip->setup[chan->channel] |= AD7152_SETUP_CAPDIFF; else - regval |= AD7152_CONF_CH2EN; + chip->setup[chan->channel] &= ~AD7152_SETUP_CAPDIFF; + + if (regval != chip->setup[chan->channel]) { + ret = i2c_smbus_write_byte_data(chip->client, + ad7152_addresses[chan->channel][AD7152_SETUP], + chip->setup[chan->channel]); + if (ret < 0) + return ret; + } + /* Make sure the channel is enabled */ + if (chan->channel == 0) + regval = AD7152_CONF_CH1EN; + else + regval = AD7152_CONF_CH2EN; + /* Trigger a single read */ regval |= AD7152_CONF_MODE_SINGLE_CONV; - ret = i2c_smbus_write_byte_data(chip->client, - ad7152_addresses[chan->channel][AD7152_SETUP], + ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); if (ret < 0) return ret; @@ -297,24 +316,26 @@ static int ad7152_read_raw(struct iio_dev *dev_info, ad7152_addresses[chan->channel][AD7152_DATA]); if (ret < 0) return ret; - *val = ret; + *val = swab16(ret); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): - /* FIXME: Hmm. very small. it's 1+ 1/(2^16 *val) */ + ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_GAIN]); if (ret < 0) return ret; - *val = ret; + /* 1 + gain_val / 2^16 */ + *val = 1; + *val2 = (15625 * swab16(ret)) / 1024; - return IIO_VAL_INT; + return IIO_VAL_INT_PLUS_MICRO; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_OFFS]); if (ret < 0) return ret; - *val = ret; + *val = swab16(ret); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): From 9b7244192fb310b3ca8352250e2fd0946ebebc54 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:28 +0100 Subject: [PATCH 0809/1519] staging:iio:adc:ad7152: update scale handling Add scale_available attribute. fix ad7152_scale_table, values are not sorted descending. Use IIO_VAL_INT_PLUS_NANO, to increase granularity. Update scale handling accordingly. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 6b9d7eae073..92a9c90b481 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -191,12 +191,16 @@ static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR, ad7152_show_filter_rate_setup, ad7152_store_filter_rate_setup); +static IIO_CONST_ATTR(in_capacitance_scale_available, + "0.000061050 0.000030525 0.000015263 0.000007631"); + static struct attribute *ad7152_attributes[] = { &iio_dev_attr_filter_rate_setup.dev_attr.attr, &iio_dev_attr_in_capacitance0_calibbias_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance1_calibbias_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance0_calibscale_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance1_calibscale_calibration.dev_attr.attr, + &iio_const_attr_in_capacitance_scale_available.dev_attr.attr, NULL, }; @@ -211,9 +215,9 @@ static const u8 ad7152_addresses[][4] = { AD7152_REG_CH2_GAIN_HIGH, AD7152_REG_CH2_SETUP }, }; -/* Values are micro relative to pf base. */ +/* Values are nano relative to pf base. */ static const int ad7152_scale_table[] = { - 488, 244, 122, 61 + 30525, 7631, 15263, 61050 }; static int ad7152_write_raw(struct iio_dev *dev_info, @@ -254,7 +258,7 @@ static int ad7152_write_raw(struct iio_dev *dev_info, if (val != 0) return -EINVAL; for (i = 0; i < ARRAY_SIZE(ad7152_scale_table); i++) - if (val2 <= ad7152_scale_table[i]) + if (val2 == ad7152_scale_table[i]) break; chip->setup[chan->channel] &= ~AD7152_SETUP_RANGE_4pF; @@ -346,15 +350,29 @@ static int ad7152_read_raw(struct iio_dev *dev_info, *val = 0; *val2 = ad7152_scale_table[ret >> 6]; - return IIO_VAL_INT_PLUS_MICRO; + return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; }; } + +static int ad7152_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + switch (mask) { + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + return IIO_VAL_INT_PLUS_NANO; + default: + return IIO_VAL_INT_PLUS_MICRO; + } +} + static const struct iio_info ad7152_info = { .attrs = &ad7152_attribute_group, .read_raw = &ad7152_read_raw, .write_raw = &ad7152_write_raw, + .write_raw_get_fmt = &ad7152_write_raw_get_fmt, .driver_module = THIS_MODULE, }; From bb90cf8d7b752c466b41e3f2dc4dcf33ba3752b2 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:29 +0100 Subject: [PATCH 0810/1519] staging:iio:adc:ad7152: Add proper locking Add proper locking. Consistently use indio_dev. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 109 ++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 38 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 92a9c90b481..f2e1df1b05c 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -19,7 +19,7 @@ #include "../sysfs.h" /* - * TODO: Check compliance of calibscale and calibbias with abi (units) + * TODO: Check compliance of calibbias with abi (units) */ /* * AD7152 registers definition @@ -94,8 +94,8 @@ static inline ssize_t ad7152_start_calib(struct device *dev, size_t len, u8 regval) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7152_chip_info *chip = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); bool doit; int ret, timeout = 10; @@ -112,17 +112,23 @@ static inline ssize_t ad7152_start_calib(struct device *dev, else regval |= AD7152_CONF_CH2EN; + mutex_lock(&indio_dev->mlock); ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); - if (ret < 0) + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); return ret; + } do { mdelay(20); ret = i2c_smbus_read_byte_data(chip->client, AD7152_REG_CFG); - if (ret < 0) + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); return ret; + } } while ((ret == regval) && timeout--); + mutex_unlock(&indio_dev->mlock); return len; } static ssize_t ad7152_start_offset_calib(struct device *dev, @@ -158,8 +164,8 @@ static ssize_t ad7152_show_filter_rate_setup(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7152_chip_info *chip = iio_priv(indio_dev); return sprintf(buf, "0x%02x\n", chip->filter_rate_setup); } @@ -169,8 +175,8 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7152_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7152_chip_info *chip = iio_priv(indio_dev); u8 data; int ret; @@ -178,11 +184,13 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev, if (ret < 0) return ret; + mutex_lock(&indio_dev->mlock); ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG2, data); if (ret < 0) return ret; chip->filter_rate_setup = data; + mutex_unlock(&indio_dev->mlock); return len; } @@ -220,19 +228,23 @@ static const int ad7152_scale_table[] = { 30525, 7631, 15263, 61050 }; -static int ad7152_write_raw(struct iio_dev *dev_info, +static int ad7152_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { - struct ad7152_chip_info *chip = iio_priv(dev_info); + struct ad7152_chip_info *chip = iio_priv(indio_dev); int ret, i; + mutex_lock(&indio_dev->mlock); + switch (mask) { case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): - if (val != 1) - return -EINVAL; + if (val != 1) { + ret = -EINVAL; + goto out; + } val = (val2 * 1024) / 15625; @@ -240,23 +252,29 @@ static int ad7152_write_raw(struct iio_dev *dev_info, ad7152_addresses[chan->channel][AD7152_GAIN], swab16(val)); if (ret < 0) - return ret; + goto out; - return 0; + ret = 0; + break; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): - if ((val < 0) | (val > 0xFFFF)) - return -EINVAL; + if ((val < 0) | (val > 0xFFFF)) { + ret = -EINVAL; + goto out; + } ret = i2c_smbus_write_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_OFFS], swab16(val)); if (ret < 0) - return ret; + goto out; - return 0; + ret = 0; + break; case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): - if (val != 0) - return -EINVAL; + if (val != 0) { + ret = -EINVAL; + goto out; + } for (i = 0; i < ARRAY_SIZE(ad7152_scale_table); i++) if (val2 == ad7152_scale_table[i]) break; @@ -268,21 +286,29 @@ static int ad7152_write_raw(struct iio_dev *dev_info, ad7152_addresses[chan->channel][AD7152_SETUP], chip->setup[chan->channel]); if (ret < 0) - return ret; - else - return 0; + goto out; + + ret = 0; + break; default: - return -EINVAL; + ret = -EINVAL; } + +out: + mutex_unlock(&indio_dev->mlock); + return ret; } -static int ad7152_read_raw(struct iio_dev *dev_info, +static int ad7152_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { - struct ad7152_chip_info *chip = iio_priv(dev_info); + struct ad7152_chip_info *chip = iio_priv(indio_dev); int ret; u8 regval = 0; + + mutex_lock(&indio_dev->mlock); + switch (mask) { case 0: /* First set whether in differential mode */ @@ -299,7 +325,7 @@ static int ad7152_read_raw(struct iio_dev *dev_info, ad7152_addresses[chan->channel][AD7152_SETUP], chip->setup[chan->channel]); if (ret < 0) - return ret; + goto out; } /* Make sure the channel is enabled */ if (chan->channel == 0) @@ -312,48 +338,55 @@ static int ad7152_read_raw(struct iio_dev *dev_info, ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); if (ret < 0) - return ret; + goto out; msleep(60); /* Slowest conversion time */ /* Now read the actual register */ ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_DATA]); if (ret < 0) - return ret; + goto out; *val = swab16(ret); - return IIO_VAL_INT; + ret = IIO_VAL_INT; + break; case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_GAIN]); if (ret < 0) - return ret; + goto out; /* 1 + gain_val / 2^16 */ *val = 1; *val2 = (15625 * swab16(ret)) / 1024; - return IIO_VAL_INT_PLUS_MICRO; + ret = IIO_VAL_INT_PLUS_MICRO; + break; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_OFFS]); if (ret < 0) - return ret; + goto out; *val = swab16(ret); - return IIO_VAL_INT; + ret = IIO_VAL_INT; + break; case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): ret = i2c_smbus_read_byte_data(chip->client, ad7152_addresses[chan->channel][AD7152_SETUP]); if (ret < 0) - return ret; + goto out; *val = 0; *val2 = ad7152_scale_table[ret >> 6]; - return IIO_VAL_INT_PLUS_NANO; + ret = IIO_VAL_INT_PLUS_NANO; + break; default: - return -EINVAL; + ret = -EINVAL; }; +out: + mutex_unlock(&indio_dev->mlock); + return ret; } static int ad7152_write_raw_get_fmt(struct iio_dev *indio_dev, From c3b7915df6356cee6412f24fbdcbf4f7ec107a5a Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:30 +0100 Subject: [PATCH 0811/1519] staging:iio:adc:ad7152: Update sample rate, conversion time, digital filter handling Rename attribute, use sampling_frequency instead. Attribute now accepts values in Hz. Delay readout accordingly. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 43 +++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index f2e1df1b05c..122d56cd445 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -67,6 +67,9 @@ #define AD7152_CAPDAC_DACEN (1 << 7) #define AD7152_CAPDAC_DACP(x) ((x) & 0x1F) +/* CFG2 Register Bit Designations (AD7152_REG_CFG2) */ +#define AD7152_CFG2_OSR(x) (((x) & 0x3) << 4) + enum { AD7152_DATA, AD7152_OFFS, @@ -157,8 +160,10 @@ static IIO_DEVICE_ATTR(in_capacitance0_calibscale_calibration, static IIO_DEVICE_ATTR(in_capacitance1_calibscale_calibration, S_IWUSR, NULL, ad7152_start_gain_calib, 1); -#define IIO_DEV_ATTR_FILTER_RATE_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(filter_rate_setup, _mode, _show, _store, 0) +/* Values are Update Rate (Hz), Conversion Time (ms) */ +static const unsigned char ad7152_filter_rate_table[][2] = { + {200, 5}, {50, 20}, {20, 50}, {17, 60}, +}; static ssize_t ad7152_show_filter_rate_setup(struct device *dev, struct device_attribute *attr, @@ -167,7 +172,8 @@ static ssize_t ad7152_show_filter_rate_setup(struct device *dev, struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(indio_dev); - return sprintf(buf, "0x%02x\n", chip->filter_rate_setup); + return sprintf(buf, "%d\n", + ad7152_filter_rate_table[chip->filter_rate_setup][0]); } static ssize_t ad7152_store_filter_rate_setup(struct device *dev, @@ -178,37 +184,50 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev, struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad7152_chip_info *chip = iio_priv(indio_dev); u8 data; - int ret; + int ret, i; ret = kstrtou8(buf, 10, &data); if (ret < 0) return ret; - mutex_lock(&indio_dev->mlock); - ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG2, data); - if (ret < 0) - return ret; + for (i = 0; i < ARRAY_SIZE(ad7152_filter_rate_table); i++) + if (data >= ad7152_filter_rate_table[i][0]) + break; - chip->filter_rate_setup = data; + if (i >= ARRAY_SIZE(ad7152_filter_rate_table)) + i = ARRAY_SIZE(ad7152_filter_rate_table) - 1; + + mutex_lock(&indio_dev->mlock); + ret = i2c_smbus_write_byte_data(chip->client, + AD7152_REG_CFG2, AD7152_CFG2_OSR(i)); + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); + return ret; + } + + chip->filter_rate_setup = i; mutex_unlock(&indio_dev->mlock); return len; } -static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR, +static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, ad7152_show_filter_rate_setup, ad7152_store_filter_rate_setup); +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("200 50 20 17"); + static IIO_CONST_ATTR(in_capacitance_scale_available, "0.000061050 0.000030525 0.000015263 0.000007631"); static struct attribute *ad7152_attributes[] = { - &iio_dev_attr_filter_rate_setup.dev_attr.attr, + &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_in_capacitance0_calibbias_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance1_calibbias_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance0_calibscale_calibration.dev_attr.attr, &iio_dev_attr_in_capacitance1_calibscale_calibration.dev_attr.attr, &iio_const_attr_in_capacitance_scale_available.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL, }; @@ -340,7 +359,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev, if (ret < 0) goto out; - msleep(60); /* Slowest conversion time */ + msleep(ad7152_filter_rate_table[chip->filter_rate_setup][1]); /* Now read the actual register */ ret = i2c_smbus_read_word_data(chip->client, ad7152_addresses[chan->channel][AD7152_DATA]); From fe55a170399a0f30d1268848d2cb99dcf8fa413b Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:31 +0100 Subject: [PATCH 0812/1519] staging:iio:adc:ad7152: Fix differential channel return value and increase delay. In differential mode zero scale equals to 0x8000. Increase readout delay by 1ms. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 122d56cd445..42996b96b85 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -160,9 +160,9 @@ static IIO_DEVICE_ATTR(in_capacitance0_calibscale_calibration, static IIO_DEVICE_ATTR(in_capacitance1_calibscale_calibration, S_IWUSR, NULL, ad7152_start_gain_calib, 1); -/* Values are Update Rate (Hz), Conversion Time (ms) */ +/* Values are Update Rate (Hz), Conversion Time (ms) + 1*/ static const unsigned char ad7152_filter_rate_table[][2] = { - {200, 5}, {50, 20}, {20, 50}, {17, 60}, + {200, 5 + 1}, {50, 20 + 1}, {20, 50 + 1}, {17, 60 + 1}, }; static ssize_t ad7152_show_filter_rate_setup(struct device *dev, @@ -367,6 +367,9 @@ static int ad7152_read_raw(struct iio_dev *indio_dev, goto out; *val = swab16(ret); + if (chan->differential) + *val -= 0x8000; + ret = IIO_VAL_INT; break; case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): From 4fd242471e4c851a1e04e06f8a5f3e977670ce4a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:32 +0100 Subject: [PATCH 0813/1519] staging:iio:adc:ad7291 bring into line with current abi + chan_spec conversion. Also add some locking. Some major changes to how this driver works. For voltage channels it is currently either in single read mode or in a monitor mode (events only). Could be much cleverer and allow reading of any channels that happend to be monitored, but haven't done that yet. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 906 +++++++++++-------------------- 1 file changed, 322 insertions(+), 584 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 46a891d4d2e..ebb1e281e3f 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -7,18 +7,28 @@ */ #include -#include #include #include #include #include -#include #include #include +#include #include "../iio.h" #include "../sysfs.h" +/* + * Simplified handling + * + * If no events enabled - single polled channel read + * If event enabled direct reads disable unless channel + * is in the read mask. + * + * The noise-delayed bit as per datasheet suggestion is always enabled. + * + * Extref control should be based on regulator provision - not handled. + */ /* * AD7291 registers definition */ @@ -56,29 +66,13 @@ #define AD7291_T_VALUE_FLOAT_OFFSET 2 #define AD7291_T_VALUE_FLOAT_MASK 0x2 -/* - * struct ad7291_chip_info - chip specifc information - */ - struct ad7291_chip_info { struct i2c_client *client; u16 command; - u8 channels; /* Active voltage channels */ + u8 c_mask; /* Active voltage channels for events */ + struct mutex state_lock; }; -/* - * struct ad7291_chip_info - chip specifc information - */ - -struct ad7291_limit_regs { - u16 data_high; - u16 data_low; - u16 hysteresis; -}; - -/* - * ad7291 register access by I2C - */ static int ad7291_i2c_read(struct ad7291_chip_info *chip, u8 reg, u16 *data) { struct i2c_client *client = chip->client; @@ -97,111 +91,9 @@ static int ad7291_i2c_read(struct ad7291_chip_info *chip, u8 reg, u16 *data) static int ad7291_i2c_write(struct ad7291_chip_info *chip, u8 reg, u16 data) { - struct i2c_client *client = chip->client; - int ret = 0; - - ret = i2c_smbus_write_word_data(client, reg, swab16(data)); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; + return i2c_smbus_write_word_data(chip->client, reg, swab16(data)); } -/* Returns negative errno, or else the number of words read. */ -static int ad7291_i2c_read_data(struct ad7291_chip_info *chip, u8 reg, u16 *data) -{ - struct i2c_client *client = chip->client; - u8 commands[4]; - int ret = 0; - int i, count; - - if (reg == AD7291_T_SENSE || reg == AD7291_T_AVERAGE) - count = 2; - else if (reg == AD7291_VOLTAGE) { - if (!chip->channels) { - dev_err(&client->dev, "No voltage channel is selected.\n"); - return -EINVAL; - } - count = 2 + chip->channels * 2; - } else { - dev_err(&client->dev, "I2C wrong data register\n"); - return -EINVAL; - } - - commands[0] = 0; - commands[1] = (chip->command >> 8) & 0xff; - commands[2] = chip->command & 0xff; - commands[3] = reg; - - ret = i2c_master_send(client, commands, 4); - if (ret < 0) { - dev_err(&client->dev, "I2C master send error\n"); - return ret; - } - - ret = i2c_master_recv(client, (u8 *)data, count); - if (ret < 0) { - dev_err(&client->dev, "I2C master receive error\n"); - return ret; - } - ret >>= 2; - - for (i = 0; i < ret; i++) - data[i] = swab16(data[i]); - - return ret; -} - -static ssize_t ad7291_show_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - - if (chip->command & AD7291_AUTOCYCLE) - return sprintf(buf, "autocycle\n"); - else - return sprintf(buf, "command\n"); -} - -static ssize_t ad7291_store_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 command; - int ret; - - command = chip->command & (~AD7291_AUTOCYCLE); - if (strcmp(buf, "autocycle")) - command |= AD7291_AUTOCYCLE; - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (ret) - return -EIO; - - chip->command = command; - - return ret; -} - -static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, - ad7291_show_mode, - ad7291_store_mode, - 0); - -static ssize_t ad7291_show_available_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "command\nautocycle\n"); -} - -static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7291_show_available_modes, NULL, 0); - static ssize_t ad7291_store_reset(struct device *dev, struct device_attribute *attr, const char *buf, @@ -209,240 +101,15 @@ static ssize_t ad7291_store_reset(struct device *dev, { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 command; - int ret; - command = chip->command | AD7291_RESET; - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (ret) - return -EIO; - - return ret; + return ad7291_i2c_write(chip, AD7291_COMMAND, + chip->command | AD7291_RESET); } -static IIO_DEVICE_ATTR(reset, S_IWUSR, - NULL, - ad7291_store_reset, - 0); - -static ssize_t ad7291_show_ext_ref(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", !!(chip->command & AD7291_EXT_REF)); -} - -static ssize_t ad7291_store_ext_ref(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 command; - int ret; - - command = chip->command & (~AD7291_EXT_REF); - if (strcmp(buf, "1")) - command |= AD7291_EXT_REF; - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (ret) - return -EIO; - - chip->command = command; - - return ret; -} - -static IIO_DEVICE_ATTR(ext_ref, S_IRUGO | S_IWUSR, - ad7291_show_ext_ref, - ad7291_store_ext_ref, - 0); - -static ssize_t ad7291_show_noise_delay(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", !!(chip->command & AD7291_NOISE_DELAY)); -} - -static ssize_t ad7291_store_noise_delay(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 command; - int ret; - - command = chip->command & (~AD7291_NOISE_DELAY); - if (strcmp(buf, "1")) - command |= AD7291_NOISE_DELAY; - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (ret) - return -EIO; - - chip->command = command; - - return ret; -} - -static IIO_DEVICE_ATTR(noise_delay, S_IRUGO | S_IWUSR, - ad7291_show_noise_delay, - ad7291_store_noise_delay, - 0); - -static ssize_t ad7291_show_t_sense(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 data; - char sign = ' '; - int ret; - - ret = ad7291_i2c_read_data(chip, AD7291_T_SENSE, &data); - if (ret) - return -EIO; - - if (data & AD7291_T_VALUE_SIGN) { - /* convert supplement to positive value */ - data = (AD7291_T_VALUE_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.2d\n", sign, - (data >> AD7291_T_VALUE_FLOAT_OFFSET), - (data & AD7291_T_VALUE_FLOAT_MASK) * 25); -} - -static IIO_DEVICE_ATTR(t_sense, S_IRUGO, ad7291_show_t_sense, NULL, 0); - -static ssize_t ad7291_show_t_average(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 data; - char sign = ' '; - int ret; - - ret = ad7291_i2c_read_data(chip, AD7291_T_AVERAGE, &data); - if (ret) - return -EIO; - - if (data & AD7291_T_VALUE_SIGN) { - /* convert supplement to positive value */ - data = (AD7291_T_VALUE_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.2d\n", sign, - (data >> AD7291_T_VALUE_FLOAT_OFFSET), - (data & AD7291_T_VALUE_FLOAT_MASK) * 25); -} - -static IIO_DEVICE_ATTR(t_average, S_IRUGO, ad7291_show_t_average, NULL, 0); - -static ssize_t ad7291_show_voltage(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 data[AD7291_VOLTAGE_LIMIT_COUNT]; - int i, size, ret; - - ret = ad7291_i2c_read_data(chip, AD7291_VOLTAGE, data); - if (ret) - return -EIO; - - for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) { - if (chip->command & (AD7291_T_SENSE_MASK << i)) { - ret = sprintf(buf, "channel[%d]=%d\n", i, - data[i] & AD7291_VALUE_MASK); - if (ret < 0) - break; - buf += ret; - size += ret; - } - } - - return size; -} - -static IIO_DEVICE_ATTR(voltage, S_IRUGO, ad7291_show_voltage, NULL, 0); - -static ssize_t ad7291_show_channel_mask(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%x\n", (chip->command & AD7291_VOLTAGE_MASK) >> - AD7291_VOLTAGE_OFFSET); -} - -static ssize_t ad7291_store_channel_mask(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - u16 command; - unsigned long data; - int i, ret; - - ret = strict_strtoul(buf, 16, &data); - if (ret || data > 0xff) - return -EINVAL; - - command = chip->command & (~AD7291_VOLTAGE_MASK); - command |= data << AD7291_VOLTAGE_OFFSET; - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (ret) - return -EIO; - - chip->command = command; - - for (i = 0, chip->channels = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) { - if (chip->command & (AD7291_T_SENSE_MASK << i)) - chip->channels++; - } - - return ret; -} - -static IIO_DEVICE_ATTR(channel_mask, S_IRUGO | S_IWUSR, - ad7291_show_channel_mask, - ad7291_store_channel_mask, - 0); +static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, ad7291_store_reset, 0); static struct attribute *ad7291_attributes[] = { - &iio_dev_attr_available_modes.dev_attr.attr, - &iio_dev_attr_mode.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, - &iio_dev_attr_ext_ref.dev_attr.attr, - &iio_dev_attr_noise_delay.dev_attr.attr, - &iio_dev_attr_t_sense.dev_attr.attr, - &iio_dev_attr_t_average.dev_attr.attr, - &iio_dev_attr_voltage.dev_attr.attr, - &iio_dev_attr_channel_mask.dev_attr.attr, NULL, }; @@ -450,10 +117,6 @@ static const struct attribute_group ad7291_attribute_group = { .attrs = ad7291_attributes, }; -/* - * temperature bound events - */ - static irqreturn_t ad7291_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; @@ -478,28 +141,15 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) command = chip->command & ~AD7291_ALART_CLEAR; ad7291_i2c_write(chip, AD7291_COMMAND, command); - if (t_status & (1 << 0)) + /* For now treat t_sense and t_sense_average the same */ + if ((t_status & (1 << 0)) || (t_status & (1 << 2))) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); - if (t_status & (1 << 1)) - iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_TEMP, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), - timestamp); - if (t_status & (1 << 2)) - iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_TEMP, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - timestamp); - if (t_status & (1 << 3)) + if ((t_status & (1 << 1)) || (t_status & (1 << 3))) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, @@ -527,7 +177,7 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) return IRQ_HANDLED; } -static inline ssize_t ad7291_show_t_bound(struct device *dev, +static inline ssize_t ad7291_show_hyst(struct device *dev, struct device_attribute *attr, char *buf) { @@ -535,258 +185,340 @@ static inline ssize_t ad7291_show_t_bound(struct device *dev, struct ad7291_chip_info *chip = iio_priv(dev_info); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); u16 data; - char sign = ' '; int ret; ret = ad7291_i2c_read(chip, this_attr->address, &data); - if (ret) - return -EIO; + if (ret < 0) + return ret; - data &= AD7291_VALUE_MASK; - if (data & AD7291_T_VALUE_SIGN) { - /* convert supplement to positive value */ - data = (AD7291_T_VALUE_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.2d\n", sign, - data >> AD7291_T_VALUE_FLOAT_OFFSET, - (data & AD7291_T_VALUE_FLOAT_MASK) * 25); + return sprintf(buf, "%d\n", data & 0x0FFF); } -static inline ssize_t ad7291_set_t_bound(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) +static inline ssize_t ad7291_set_hyst(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad7291_chip_info *chip = iio_priv(dev_info); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - long tmp1, tmp2; - u16 data; - char *pos; - int ret; - - pos = strchr(buf, '.'); - - ret = strict_strtol(buf, 10, &tmp1); - - if (ret || tmp1 > 127 || tmp1 < -128) - return -EINVAL; - - if (pos) { - len = strlen(pos); - if (len > AD7291_T_VALUE_FLOAT_OFFSET) - len = AD7291_T_VALUE_FLOAT_OFFSET; - pos[len] = 0; - ret = strict_strtol(pos, 10, &tmp2); - - if (!ret) - tmp2 = (tmp2 / 25) * 25; - } - - if (tmp1 < 0) - data = (u16)(-tmp1); - else - data = (u16)tmp1; - data = (data << AD7291_T_VALUE_FLOAT_OFFSET) | - (tmp2 & AD7291_T_VALUE_FLOAT_MASK); - if (tmp1 < 0) - /* convert positive value to supplyment */ - data = (AD7291_T_VALUE_SIGN << 1) - data; - - ret = ad7291_i2c_write(chip, this_attr->address, data); - if (ret) - return -EIO; - - return ret; -} - -static inline ssize_t ad7291_show_v_bound(struct device *dev, - struct device_attribute *attr, - u8 bound_reg, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); u16 data; int ret; - if (bound_reg < AD7291_VOLTAGE_LIMIT_BASE || - bound_reg >= AD7291_VOLTAGE_LIMIT_BASE + - AD7291_VOLTAGE_LIMIT_COUNT) + ret = kstrtou16(buf, 10, &data); + + if (ret < 0) + return ret; + if (data < 4096) return -EINVAL; - ret = ad7291_i2c_read(chip, bound_reg, &data); - if (ret) - return -EIO; - - data &= AD7291_VALUE_MASK; - - return sprintf(buf, "%d\n", data); + return ad7291_i2c_write(chip, this_attr->address, data); } -static inline ssize_t ad7291_set_v_bound(struct device *dev, - struct device_attribute *attr, - u8 bound_reg, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); - unsigned long value; - u16 data; - int ret; - - if (bound_reg < AD7291_VOLTAGE_LIMIT_BASE || - bound_reg >= AD7291_VOLTAGE_LIMIT_BASE + - AD7291_VOLTAGE_LIMIT_COUNT) - return -EINVAL; - - ret = strict_strtoul(buf, 10, &value); - - if (ret || value >= 4096) - return -EINVAL; - - data = (u16)value; - ret = ad7291_i2c_write(chip, bound_reg, data); - if (ret) - return -EIO; - - return ret; -} - -static IIO_DEVICE_ATTR(t_sense_high_value, +static IIO_DEVICE_ATTR(in_temp0_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, - AD7291_T_SENSE_HIGH); -static IIO_DEVICE_ATTR(t_sense_low_value, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, - AD7291_T_SENSE_LOW); -static IIO_DEVICE_ATTR(t_sense_hyst_value, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, + ad7291_show_hyst, ad7291_set_hyst, AD7291_T_SENSE_HYST); -static IIO_DEVICE_ATTR(v0_high, +static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x04); -static IIO_DEVICE_ATTR(v0_low, + ad7291_show_hyst, ad7291_set_hyst, 0x06); +static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x05); -static IIO_DEVICE_ATTR(v0_hyst, + ad7291_show_hyst, ad7291_set_hyst, 0x09); +static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x06); -static IIO_DEVICE_ATTR(v1_high, + ad7291_show_hyst, ad7291_set_hyst, 0x0C); +static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x07); -static IIO_DEVICE_ATTR(v1_low, + ad7291_show_hyst, ad7291_set_hyst, 0x0F); +static IIO_DEVICE_ATTR(in_voltage4_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x08); -static IIO_DEVICE_ATTR(v1_hyst, + ad7291_show_hyst, ad7291_set_hyst, 0x12); +static IIO_DEVICE_ATTR(in_voltage5_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x09); -static IIO_DEVICE_ATTR(v2_high, + ad7291_show_hyst, ad7291_set_hyst, 0x15); +static IIO_DEVICE_ATTR(in_voltage6_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x0A); -static IIO_DEVICE_ATTR(v2_low, + ad7291_show_hyst, ad7291_set_hyst, 0x18); +static IIO_DEVICE_ATTR(in_voltage7_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x0B); -static IIO_DEVICE_ATTR(v2_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x0C); -static IIO_DEVICE_ATTR(v3_high, - S_IRUGO | S_IWUSR, - /* Datasheet suggests this one and this one only - has the registers in different order */ - ad7291_show_t_bound, ad7291_set_t_bound, 0x0E); -static IIO_DEVICE_ATTR(v3_low, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x0D); -static IIO_DEVICE_ATTR(v3_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x0F); -static IIO_DEVICE_ATTR(v4_high, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x10); -static IIO_DEVICE_ATTR(v4_low, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x11); -static IIO_DEVICE_ATTR(v4_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x12); -static IIO_DEVICE_ATTR(v5_high, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x13); -static IIO_DEVICE_ATTR(v5_low, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x14); -static IIO_DEVICE_ATTR(v5_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x15); -static IIO_DEVICE_ATTR(v6_high, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x16); -static IIO_DEVICE_ATTR(v6_low, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x17); -static IIO_DEVICE_ATTR(v6_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x18); -static IIO_DEVICE_ATTR(v7_high, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x19); -static IIO_DEVICE_ATTR(v7_low, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x1A); -static IIO_DEVICE_ATTR(v7_hyst, - S_IRUGO | S_IWUSR, - ad7291_show_t_bound, ad7291_set_t_bound, 0x1B); + ad7291_show_hyst, ad7291_set_hyst, 0x1B); static struct attribute *ad7291_event_attributes[] = { - &iio_dev_attr_t_sense_high_value.dev_attr.attr, - &iio_dev_attr_t_sense_low_value.dev_attr.attr, - &iio_dev_attr_t_sense_hyst_value.dev_attr.attr, - &iio_dev_attr_v0_high.dev_attr.attr, - &iio_dev_attr_v0_low.dev_attr.attr, - &iio_dev_attr_v0_hyst.dev_attr.attr, - &iio_dev_attr_v1_high.dev_attr.attr, - &iio_dev_attr_v1_low.dev_attr.attr, - &iio_dev_attr_v1_hyst.dev_attr.attr, - &iio_dev_attr_v2_high.dev_attr.attr, - &iio_dev_attr_v2_low.dev_attr.attr, - &iio_dev_attr_v2_hyst.dev_attr.attr, - &iio_dev_attr_v3_high.dev_attr.attr, - &iio_dev_attr_v3_low.dev_attr.attr, - &iio_dev_attr_v3_hyst.dev_attr.attr, - &iio_dev_attr_v4_high.dev_attr.attr, - &iio_dev_attr_v4_low.dev_attr.attr, - &iio_dev_attr_v4_hyst.dev_attr.attr, - &iio_dev_attr_v5_high.dev_attr.attr, - &iio_dev_attr_v5_low.dev_attr.attr, - &iio_dev_attr_v5_hyst.dev_attr.attr, - &iio_dev_attr_v6_high.dev_attr.attr, - &iio_dev_attr_v6_low.dev_attr.attr, - &iio_dev_attr_v6_hyst.dev_attr.attr, - &iio_dev_attr_v7_high.dev_attr.attr, - &iio_dev_attr_v7_low.dev_attr.attr, - &iio_dev_attr_v7_hyst.dev_attr.attr, + &iio_dev_attr_in_temp0_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage4_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage5_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage6_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage7_thresh_both_hyst_raw.dev_attr.attr, NULL, }; +/* high / low */ +static u8 ad7291_limit_regs[9][2] = { + { 0x04, 0x05 }, + { 0x07, 0x08 }, + { 0x0A, 0x0B }, + { 0x0E, 0x0D }, /* note reversed order */ + { 0x10, 0x11 }, + { 0x13, 0x14 }, + { 0x16, 0x17 }, + { 0x19, 0x1A }, + /* temp */ + { 0x1C, 0x1D }, +}; + +static int ad7291_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val) +{ + struct ad7291_chip_info *chip = iio_priv(indio_dev); + + int ret; + u8 reg; + u16 uval; + s16 signval; + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_VOLTAGE: + reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] + [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING)]; + + ret = ad7291_i2c_read(chip, reg, &uval); + if (ret < 0) + return ret; + *val = swab16(uval) & 0x0FFF; + return 0; + + case IIO_TEMP: + reg = ad7291_limit_regs[8] + [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING)]; + + ret = ad7291_i2c_read(chip, reg, &signval); + if (ret < 0) + return ret; + signval = (s16)((swab16(signval) & 0x0FFF) << 4) >> 4; + *val = signval; + return 0; + default: + return -EINVAL; + }; +} + +static int ad7291_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val) +{ + struct ad7291_chip_info *chip = iio_priv(indio_dev); + u8 reg; + s16 signval; + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_VOLTAGE: + if (val > 0xFFF || val < 0) + return -EINVAL; + reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] + [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING)]; + + return ad7291_i2c_write(chip, reg, val); + + case IIO_TEMP: + if (val > 2047 || val < -2048) + return -EINVAL; + reg = ad7291_limit_regs[8] + [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING)]; + signval = val; + return ad7291_i2c_write(chip, reg, *(u16 *)&signval); + default: + return -EINVAL; + }; +} + +static int ad7291_read_event_config(struct iio_dev *indio_dev, + u64 event_code) +{ + struct ad7291_chip_info *chip = iio_priv(indio_dev); + /* To be enabled the channel must simply be on. If any are enabled + we are in continuous sampling mode */ + + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_VOLTAGE: + if (chip->c_mask & + (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))) + return 1; + else + return 0; + case IIO_TEMP: + /* always on */ + return 1; + default: + return -EINVAL; + } + +} + +static int ad7291_write_event_config(struct iio_dev *indio_dev, + u64 event_code, + int state) +{ + int ret = 0; + struct ad7291_chip_info *chip = iio_priv(indio_dev); + u16 regval; + + mutex_lock(&chip->state_lock); + regval = chip->command; + /* + * To be enabled the channel must simply be on. If any are enabled + * use continuous sampling mode. + * Possible to disable temp as well but that makes single read tricky. + */ + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_VOLTAGE: + if ((!state) && (chip->c_mask & + (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)))) + chip->c_mask &= + ~(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); + else if (state && (!(chip->c_mask & + (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))))) + chip->c_mask &= + (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); + else + break; + + regval &= 0xFFFE; + regval |= ((u16)chip->c_mask << 8); + if (chip->c_mask) /* Enable autocycle? */ + regval |= AD7291_AUTOCYCLE; + + ret = ad7291_i2c_write(chip, AD7291_COMMAND, regval); + if (ret < 0) + goto error_ret; + + chip->command = regval; + break; + default: + ret = -EINVAL; + } + +error_ret: + mutex_unlock(&chip->state_lock); + return ret; +} + +static int ad7291_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) +{ + int ret; + struct ad7291_chip_info *chip = iio_priv(indio_dev); + u16 regval; + s16 signval; + + switch (mask) { + case 0: + switch (chan->type) { + case IIO_VOLTAGE: + mutex_lock(&chip->state_lock); + /* If in autocycle mode drop through */ + if (chip->command & 0x1) { + mutex_unlock(&chip->state_lock); + return -EBUSY; + } + /* Enable this channel alone */ + regval = chip->command & (~AD7291_VOLTAGE_MASK); + regval |= 1 << (chan->channel + 8); + ret = ad7291_i2c_write(chip, AD7291_COMMAND, regval); + if (ret < 0) { + mutex_unlock(&chip->state_lock); + return ret; + } + /* Read voltage */ + ret = i2c_smbus_read_word_data(chip->client, + AD7291_VOLTAGE); + if (ret < 0) { + mutex_unlock(&chip->state_lock); + return ret; + } + *val = swab16((u16)ret) & 0x0FFF; + mutex_unlock(&chip->state_lock); + return IIO_VAL_INT; + case IIO_TEMP: + /* Assumes tsense bit of command register always set */ + ret = i2c_smbus_read_word_data(chip->client, + AD7291_T_SENSE); + if (ret < 0) + return ret; + signval = (s16)((swab16((u16)ret) & 0x0FFF) << 4) >> 4; + *val = signval; + return IIO_VAL_INT; + default: + return -EINVAL; + } + case (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE): + ret = i2c_smbus_read_word_data(chip->client, + AD7291_T_AVERAGE); + if (ret < 0) + return ret; + signval = (s16)((swab16((u16)ret) & 0x0FFF) << 4) >> 4; + *val = signval; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +#define AD7291_VOLTAGE_CHAN(_chan) \ +{ \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = _chan, \ + .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)|\ + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) \ +} + +static const struct iio_chan_spec ad7291_channels[] = { + AD7291_VOLTAGE_CHAN(0), + AD7291_VOLTAGE_CHAN(1), + AD7291_VOLTAGE_CHAN(2), + AD7291_VOLTAGE_CHAN(3), + AD7291_VOLTAGE_CHAN(4), + AD7291_VOLTAGE_CHAN(5), + AD7291_VOLTAGE_CHAN(6), + AD7291_VOLTAGE_CHAN(7), + { + .type = IIO_TEMP, + .info_mask = (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE), + .indexed = 1, + .channel = 0, + .event_mask = + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)| + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) + } +}; + static struct attribute_group ad7291_event_attribute_group = { .attrs = ad7291_event_attributes, }; static const struct iio_info ad7291_info = { .attrs = &ad7291_attribute_group, + .read_raw = &ad7291_read_raw, + .read_event_config = &ad7291_read_event_config, + .write_event_config = &ad7291_write_event_config, + .read_event_value = &ad7291_read_event_value, + .write_event_value = &ad7291_write_event_value, .event_attrs = &ad7291_event_attribute_group, }; -/* - * device probe and remove - */ - static int __devinit ad7291_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -800,13 +532,18 @@ static int __devinit ad7291_probe(struct i2c_client *client, goto error_ret; } chip = iio_priv(indio_dev); + mutex_init(&chip->state_lock); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); chip->client = client; + /* Tsense always enabled */ chip->command = AD7291_NOISE_DELAY | AD7291_T_SENSE_MASK; indio_dev->name = id->name; + indio_dev->channels = ad7291_channels; + indio_dev->num_channels = ARRAY_SIZE(ad7291_channels); + indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7291_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -841,7 +578,8 @@ static int __devinit ad7291_probe(struct i2c_client *client, return 0; error_unreg_irq: - free_irq(client->irq, indio_dev); + if (client->irq) + free_irq(client->irq, indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: From 521de51871fdb89b8530ddd694401d689e1f94ad Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:25:33 +0100 Subject: [PATCH 0814/1519] staging:iio:imu:adis16400 cleanups a) remove irq is gpio requirement - No reason this needs to be true. b) use actual part name in info message rather than adis16400 in all cases. c) scrap use of IIO_CHAN to simplify move out of staging. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_core.c | 607 +++++++++++++------- drivers/staging/iio/imu/adis16400_trigger.c | 2 +- 2 files changed, 403 insertions(+), 206 deletions(-) diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 0fca3bf8ef3..1f07773172b 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -32,8 +31,6 @@ #include "../ring_generic.h" #include "adis16400.h" -#define DRIVER_NAME "adis16400" - enum adis16400_chip_variant { ADIS16300, ADIS16344, @@ -45,19 +42,12 @@ enum adis16400_chip_variant { ADIS16400, }; -static int adis16400_check_status(struct iio_dev *indio_dev); - -/* At the moment the spi framework doesn't allow global setting of cs_change. - * It's in the likely to be added comment at the top of spi.h. - * This means that use cannot be made of spi_write etc. - */ - /** * adis16400_spi_write_reg_8() - write single byte to a register * @dev: device associated with child of actual device (iio_dev or iio_trig) * @reg_address: the address of the register to be written * @val: the value to write - **/ + */ static int adis16400_spi_write_reg_8(struct iio_dev *indio_dev, u8 reg_address, u8 val) @@ -81,7 +71,10 @@ static int adis16400_spi_write_reg_8(struct iio_dev *indio_dev, * @reg_address: the address of the lower of the two registers. Second register * is assumed to have address one greater. * @val: value to be written - **/ + * + * At the moment the spi framework doesn't allow global setting of cs_change. + * This means that use cannot be made of spi_write. + */ static int adis16400_spi_write_reg_16(struct iio_dev *indio_dev, u8 lower_reg_address, u16 value) @@ -123,6 +116,9 @@ static int adis16400_spi_write_reg_16(struct iio_dev *indio_dev, * @reg_address: the address of the lower of the two registers. Second register * is assumed to have address one greater. * @val: somewhere to pass back the value read + * + * At the moment the spi framework doesn't allow global setting of cs_change. + * This means that use cannot be made of spi_read. **/ static int adis16400_spi_read_reg_16(struct iio_dev *indio_dev, u8 lower_reg_address, @@ -241,10 +237,11 @@ static ssize_t adis16400_write_reset(struct device *dev, ret = strtobool(buf, &val); if (ret < 0) return ret; - if (val) + if (val) { ret = adis16400_reset(dev_get_drvdata(dev)); - if (ret < 0) - return ret; + if (ret < 0) + return ret; + } return len; } @@ -253,6 +250,7 @@ int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) { int ret; u16 msc; + ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_MSC_CTRL, &msc); if (ret) goto error_ret; @@ -285,24 +283,6 @@ static int adis16400_stop_device(struct iio_dev *indio_dev) return ret; } -static int adis16400_self_test(struct iio_dev *indio_dev) -{ - int ret; - ret = adis16400_spi_write_reg_16(indio_dev, - ADIS16400_MSC_CTRL, - ADIS16400_MSC_CTRL_MEM_TEST); - if (ret) { - dev_err(&indio_dev->dev, "problem starting self test"); - goto err_ret; - } - - msleep(ADIS16400_MTEST_DELAY); - adis16400_check_status(indio_dev); - -err_ret: - return ret; -} - static int adis16400_check_status(struct iio_dev *indio_dev) { u16 status; @@ -352,11 +332,28 @@ error_ret: return ret; } +static int adis16400_self_test(struct iio_dev *indio_dev) +{ + int ret; + ret = adis16400_spi_write_reg_16(indio_dev, + ADIS16400_MSC_CTRL, + ADIS16400_MSC_CTRL_MEM_TEST); + if (ret) { + dev_err(&indio_dev->dev, "problem starting self test"); + goto err_ret; + } + + msleep(ADIS16400_MTEST_DELAY); + adis16400_check_status(indio_dev); + +err_ret: + return ret; +} + static int adis16400_initial_setup(struct iio_dev *indio_dev) { int ret; u16 prod_id, smp_prd; - struct device *dev = &indio_dev->dev; struct adis16400_state *st = iio_priv(indio_dev); /* use low spi speed for init */ @@ -364,29 +361,26 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev) st->us->mode = SPI_MODE_3; spi_setup(st->us); - /* Disable IRQ */ ret = adis16400_set_irq(indio_dev, false); if (ret) { - dev_err(dev, "disable irq failed"); + dev_err(&indio_dev->dev, "disable irq failed"); goto err_ret; } - /* Do self test */ ret = adis16400_self_test(indio_dev); if (ret) { - dev_err(dev, "self test failure"); + dev_err(&indio_dev->dev, "self test failure"); goto err_ret; } - /* Read status register to check the result */ ret = adis16400_check_status(indio_dev); if (ret) { adis16400_reset(indio_dev); - dev_err(dev, "device not playing ball -> reset"); + dev_err(&indio_dev->dev, "device not playing ball -> reset"); msleep(ADIS16400_STARTUP_DELAY); ret = adis16400_check_status(indio_dev); if (ret) { - dev_err(dev, "giving up"); + dev_err(&indio_dev->dev, "giving up"); goto err_ret; } } @@ -397,10 +391,11 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev) goto err_ret; if ((prod_id & 0xF000) != st->variant->product_id) - dev_warn(dev, "incorrect id"); + dev_warn(&indio_dev->dev, "incorrect id"); - printk(KERN_INFO DRIVER_NAME ": prod_id 0x%04x at CS%d (irq %d)\n", - prod_id, st->us->chip_select, st->us->irq); + printk(KERN_INFO "%s: prod_id 0x%04x at CS%d (irq %d)\n", + indio_dev->name, prod_id, + st->us->chip_select, st->us->irq); } /* use high spi speed if possible */ ret = adis16400_spi_read_reg_16(indio_dev, @@ -410,15 +405,13 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev) spi_setup(st->us); } - err_ret: - return ret; } static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - adis16400_read_frequency, - adis16400_write_frequency); + adis16400_read_frequency, + adis16400_write_frequency); static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0); @@ -443,23 +436,23 @@ enum adis16400_chan { }; static u8 adis16400_addresses[17][2] = { - [in_supply] = { ADIS16400_SUPPLY_OUT, 0 }, + [in_supply] = { ADIS16400_SUPPLY_OUT }, [gyro_x] = { ADIS16400_XGYRO_OUT, ADIS16400_XGYRO_OFF }, [gyro_y] = { ADIS16400_YGYRO_OUT, ADIS16400_YGYRO_OFF }, [gyro_z] = { ADIS16400_ZGYRO_OUT, ADIS16400_ZGYRO_OFF }, [accel_x] = { ADIS16400_XACCL_OUT, ADIS16400_XACCL_OFF }, [accel_y] = { ADIS16400_YACCL_OUT, ADIS16400_YACCL_OFF }, [accel_z] = { ADIS16400_ZACCL_OUT, ADIS16400_ZACCL_OFF }, - [magn_x] = { ADIS16400_XMAGN_OUT, 0 }, - [magn_y] = { ADIS16400_YMAGN_OUT, 0 }, - [magn_z] = { ADIS16400_ZMAGN_OUT, 0 }, - [temp] = { ADIS16400_TEMP_OUT, 0 }, + [magn_x] = { ADIS16400_XMAGN_OUT }, + [magn_y] = { ADIS16400_YMAGN_OUT }, + [magn_z] = { ADIS16400_ZMAGN_OUT }, + [temp] = { ADIS16400_TEMP_OUT }, [temp0] = { ADIS16350_XTEMP_OUT }, [temp1] = { ADIS16350_YTEMP_OUT }, [temp2] = { ADIS16350_ZTEMP_OUT }, - [in1] = { ADIS16400_AUX_ADC, 0 }, - [incli_x] = { ADIS16300_PITCH_OUT, 0 }, - [incli_y] = { ADIS16300_ROLL_OUT, 0 } + [in1] = { ADIS16400_AUX_ADC }, + [incli_x] = { ADIS16300_PITCH_OUT }, + [incli_y] = { ADIS16300_ROLL_OUT } }; static int adis16400_write_raw(struct iio_dev *indio_dev, @@ -469,6 +462,7 @@ static int adis16400_write_raw(struct iio_dev *indio_dev, long mask) { int ret; + switch (mask) { case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): mutex_lock(&indio_dev->mlock); @@ -489,9 +483,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, long mask) { struct adis16400_state *st = iio_priv(indio_dev); - int ret; + int ret, shift; s16 val16; - int shift; switch (mask) { case 0: @@ -562,164 +555,368 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16400_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in_supply, ADIS16400_SCAN_SUPPLY, - IIO_ST('u', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_y, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_z, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - magn_x, ADIS16400_SCAN_MAGN_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - magn_y, ADIS16400_SCAN_MAGN_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - magn_z, ADIS16400_SCAN_MAGN_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp, ADIS16400_SCAN_TEMP, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in1, ADIS16400_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0), + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .extend_name = "supply", + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in_supply, + .scan_index = ADIS16400_SCAN_SUPPLY, + .scan_type = IIO_ST('u', 14, 16, 0) + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_x, + .scan_index = ADIS16400_SCAN_GYRO_X, + .scan_type = IIO_ST('s', 14, 16, 0) + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_y, + .scan_index = ADIS16400_SCAN_GYRO_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_z, + .scan_index = ADIS16400_SCAN_GYRO_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_x, + .scan_index = ADIS16400_SCAN_ACC_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_y, + .scan_index = ADIS16400_SCAN_ACC_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_z, + .scan_index = ADIS16400_SCAN_ACC_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_MAGN, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = magn_x, + .scan_index = ADIS16400_SCAN_MAGN_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_MAGN, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = magn_y, + .scan_index = ADIS16400_SCAN_MAGN_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_MAGN, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = magn_z, + .scan_index = ADIS16400_SCAN_MAGN_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp, + .scan_index = ADIS16400_SCAN_TEMP, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in1, + .scan_index = ADIS16400_SCAN_ADC_0, + .scan_type = IIO_ST('s', 12, 16, 0), + }, IIO_CHAN_SOFT_TIMESTAMP(12) }; static struct iio_chan_spec adis16350_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in_supply, ADIS16400_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_y, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_z, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, "x", 0, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp0, ADIS16350_SCAN_TEMP_X, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, "y", 1, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp1, ADIS16350_SCAN_TEMP_Y, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, "z", 2, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp2, ADIS16350_SCAN_TEMP_Z, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in1, ADIS16350_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0), + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .extend_name = "supply", + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in_supply, + .scan_index = ADIS16400_SCAN_SUPPLY, + .scan_type = IIO_ST('u', 12, 16, 0) + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_x, + .scan_index = ADIS16400_SCAN_GYRO_X, + .scan_type = IIO_ST('s', 14, 16, 0) + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_y, + .scan_index = ADIS16400_SCAN_GYRO_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_z, + .scan_index = ADIS16400_SCAN_GYRO_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_x, + .scan_index = ADIS16400_SCAN_ACC_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_y, + .scan_index = ADIS16400_SCAN_ACC_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_z, + .scan_index = ADIS16400_SCAN_ACC_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .extend_name = "x", + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp0, + .scan_index = ADIS16350_SCAN_TEMP_X, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 1, + .extend_name = "y", + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp1, + .scan_index = ADIS16350_SCAN_TEMP_Y, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 2, + .extend_name = "z", + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp2, + .scan_index = ADIS16350_SCAN_TEMP_Z, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in1, + .scan_index = ADIS16350_SCAN_ADC_0, + .scan_type = IIO_ST('s', 12, 16, 0), + }, IIO_CHAN_SOFT_TIMESTAMP(11) }; static struct iio_chan_spec adis16300_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in_supply, ADIS16400_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp, ADIS16400_SCAN_TEMP, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - in1, ADIS16350_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0), - IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - incli_x, ADIS16300_SCAN_INCLI_X, IIO_ST('s', 13, 16, 0), 0), - IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - incli_y, ADIS16300_SCAN_INCLI_Y, IIO_ST('s', 13, 16, 0), 0), + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .extend_name = "supply", + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in_supply, + .scan_index = ADIS16400_SCAN_SUPPLY, + .scan_type = IIO_ST('u', 12, 16, 0) + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_x, + .scan_index = ADIS16400_SCAN_GYRO_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_x, + .scan_index = ADIS16400_SCAN_ACC_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_y, + .scan_index = ADIS16400_SCAN_ACC_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_z, + .scan_index = ADIS16400_SCAN_ACC_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = temp, + .scan_index = ADIS16400_SCAN_TEMP, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_IN, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + .address = in1, + .scan_index = ADIS16350_SCAN_ADC_0, + .scan_type = IIO_ST('s', 12, 16, 0), + }, { + .type = IIO_INCLI, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = incli_x, + .scan_index = ADIS16300_SCAN_INCLI_X, + .scan_type = IIO_ST('s', 13, 16, 0), + }, { + .type = IIO_INCLI, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = incli_y, + .scan_index = ADIS16300_SCAN_INCLI_Y, + .scan_type = IIO_ST('s', 13, 16, 0), + }, IIO_CHAN_SOFT_TIMESTAMP(14) }; static const struct iio_chan_spec adis16344_channels[] = { - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_y, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - gyro_z, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, - (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SHARED), - accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | - (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - temp0, ADIS16350_SCAN_TEMP_X, IIO_ST('s', 12, 16, 0), 0), + { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_x, + .scan_index = ADIS16400_SCAN_GYRO_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_y, + .scan_index = ADIS16400_SCAN_GYRO_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_GYRO, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = gyro_z, + .scan_index = ADIS16400_SCAN_GYRO_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_x, + .scan_index = ADIS16400_SCAN_ACC_X, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_y, + .scan_index = ADIS16400_SCAN_ACC_Y, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_ACCEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_z, + .scan_index = ADIS16400_SCAN_ACC_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = accel_z, + .scan_index = ADIS16400_SCAN_ACC_Z, + .scan_type = IIO_ST('s', 14, 16, 0), + }, IIO_CHAN_SOFT_TIMESTAMP(12) }; @@ -856,7 +1053,7 @@ static int __devinit adis16400_probe(struct spi_device *spi) goto error_unreg_ring_funcs; } - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { + if (spi->irq) { ret = adis16400_probe_trigger(indio_dev); if (ret) goto error_uninitialize_ring; diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c index 3860d92f1ae..bf991531e0d 100644 --- a/drivers/staging/iio/imu/adis16400_trigger.c +++ b/drivers/staging/iio/imu/adis16400_trigger.c @@ -29,7 +29,7 @@ int adis16400_probe_trigger(struct iio_dev *indio_dev) struct adis16400_state *st = iio_priv(indio_dev); st->trig = iio_allocate_trigger("%s-dev%d", - spi_get_device_id(st->us)->name, + indio_dev->name, indio_dev->id); if (st->trig == NULL) { ret = -ENOMEM; From 69d80bae9b2009ba36c4bb7032354c27a97b198a Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:34 +0100 Subject: [PATCH 0815/1519] staging:iio:imu: adis16400: Avoid using printk facility use dev_info() instead. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 1f07773172b..b6d824f5dbf 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -393,7 +393,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev) if ((prod_id & 0xF000) != st->variant->product_id) dev_warn(&indio_dev->dev, "incorrect id"); - printk(KERN_INFO "%s: prod_id 0x%04x at CS%d (irq %d)\n", + dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n", indio_dev->name, prod_id, st->us->chip_select, st->us->irq); } From 1067291a23ee1720631c7f81e28b30b9c324df8c Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:35 +0100 Subject: [PATCH 0816/1519] staging:iio:accel:adis16209: Fix double registration of in_incli0_index iio (null): tried to double register : in_incli0_index Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16209_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 377c6d790ca..97dca8866df 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -432,11 +432,11 @@ static struct iio_chan_spec adis16209_channels[] = { (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_aux, ADIS16209_SCAN_AUX_ADC, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_INCLI, 0, 1, 0, NULL, 0, IIO_MOD_X, + IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X, (1 << IIO_CHAN_INFO_SCALE_SHARED), incli_x, ADIS16209_SCAN_INCLI_X, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_INCLI, 0, 1, 0, NULL, 0, IIO_MOD_Y, + IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y, (1 << IIO_CHAN_INFO_SCALE_SHARED), incli_y, ADIS16209_SCAN_INCLI_Y, IIO_ST('s', 14, 16, 0), 0), From e70ab21849730fccacbd39c0ea76c7b80ac1e090 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:36 +0100 Subject: [PATCH 0817/1519] staging:iio:adc:ad7291: fix channel mapping ideally in_voltageX_raw should map to AD7291 VINX. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index ebb1e281e3f..014df624861 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -435,7 +435,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, } /* Enable this channel alone */ regval = chip->command & (~AD7291_VOLTAGE_MASK); - regval |= 1 << (chan->channel + 8); + regval |= 1 << (15 - chan->channel); ret = ad7291_i2c_write(chip, AD7291_COMMAND, regval); if (ret < 0) { mutex_unlock(&chip->state_lock); From f22c1cf0d8735e349c998775e58ccb016f6ec367 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:37 +0100 Subject: [PATCH 0818/1519] staging:iio:adc:ad7291: Fix typos, change kconfig description and file header Make clear the AD7291 is primarily an ADC, and not a temp sensor. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/Kconfig | 4 ++-- drivers/staging/iio/adc/ad7291.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 25566c62467..7867ab18913 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -18,11 +18,11 @@ config AD7152 (ad7152, ad7153) Provides direct access via sysfs. config AD7291 - tristate "Analog Devices AD7291 temperature sensor driver" + tristate "Analog Devices AD7291 ADC driver" depends on I2C help Say yes here to build support for Analog Devices AD7291 - temperature sensors. + 8 Channel ADC with temperature sensor. config AD7298 tristate "Analog Devices AD7298 ADC driver" diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 014df624861..9ea3c8be870 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -1,7 +1,7 @@ /* - * AD7291 digital temperature sensor driver supporting AD7291 + * AD7291 8-Channel, I2C, 12-Bit SAR ADC with Temperature Sensor * - * Copyright 2010 Analog Devices Inc. + * Copyright 2010-2011 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ @@ -49,8 +49,8 @@ */ #define AD7291_AUTOCYCLE 0x1 #define AD7291_RESET 0x2 -#define AD7291_ALART_CLEAR 0x4 -#define AD7291_ALART_POLARITY 0x8 +#define AD7291_ALERT_CLEAR 0x4 +#define AD7291_ALERT_POLARITY 0x8 #define AD7291_EXT_REF 0x10 #define AD7291_NOISE_DELAY 0x20 #define AD7291_T_SENSE_MASK 0x40 @@ -135,10 +135,10 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) if (!(t_status || v_status)) return IRQ_HANDLED; - command = chip->command | AD7291_ALART_CLEAR; + command = chip->command | AD7291_ALERT_CLEAR; ad7291_i2c_write(chip, AD7291_COMMAND, command); - command = chip->command & ~AD7291_ALART_CLEAR; + command = chip->command & ~AD7291_ALERT_CLEAR; ad7291_i2c_write(chip, AD7291_COMMAND, command); /* For now treat t_sense and t_sense_average the same */ @@ -559,7 +559,7 @@ static int __devinit ad7291_probe(struct i2c_client *client, goto error_free_dev; /* set irq polarity low level */ - chip->command |= AD7291_ALART_POLARITY; + chip->command |= AD7291_ALERT_POLARITY; } ret = ad7291_i2c_write(chip, AD7291_COMMAND, chip->command); From 00feefbb5abf3877de9f81538c6dd24921467427 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:38 +0100 Subject: [PATCH 0819/1519] staging:iio:adc:ad7291: Fix AD7291_T_SENSE_MASK AD7291_T_SENSE_MASK must set bit-7. Change definition style. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 9ea3c8be870..b34af692612 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -38,30 +38,30 @@ #define AD7291_T_AVERAGE 3 #define AD7291_VOLTAGE_LIMIT_BASE 4 #define AD7291_VOLTAGE_LIMIT_COUNT 8 -#define AD7291_T_SENSE_HIGH 0x1c -#define AD7291_T_SENSE_LOW 0x1d -#define AD7291_T_SENSE_HYST 0x1e -#define AD7291_VOLTAGE_ALERT_STATUS 0x1f +#define AD7291_T_SENSE_HIGH 0x1C +#define AD7291_T_SENSE_LOW 0x1D +#define AD7291_T_SENSE_HYST 0x1E +#define AD7291_VOLTAGE_ALERT_STATUS 0x1F #define AD7291_T_ALERT_STATUS 0x20 /* * AD7291 command */ -#define AD7291_AUTOCYCLE 0x1 -#define AD7291_RESET 0x2 -#define AD7291_ALERT_CLEAR 0x4 -#define AD7291_ALERT_POLARITY 0x8 -#define AD7291_EXT_REF 0x10 -#define AD7291_NOISE_DELAY 0x20 -#define AD7291_T_SENSE_MASK 0x40 -#define AD7291_VOLTAGE_MASK 0xff00 +#define AD7291_AUTOCYCLE (1 << 0) +#define AD7291_RESET (1 << 1) +#define AD7291_ALERT_CLEAR (1 << 2) +#define AD7291_ALERT_POLARITY (1 << 3) +#define AD7291_EXT_REF (1 << 4) +#define AD7291_NOISE_DELAY (1 << 5) +#define AD7291_T_SENSE_MASK (1 << 7) +#define AD7291_VOLTAGE_MASK 0xFF00 #define AD7291_VOLTAGE_OFFSET 0x8 /* * AD7291 value masks */ -#define AD7291_CHANNEL_MASK 0xf000 -#define AD7291_VALUE_MASK 0xfff +#define AD7291_CHANNEL_MASK 0xF000 +#define AD7291_VALUE_MASK 0xFFF #define AD7291_T_VALUE_SIGN 0x400 #define AD7291_T_VALUE_FLOAT_OFFSET 2 #define AD7291_T_VALUE_FLOAT_MASK 0x2 From 3b424f33d7a3f1f4f928845d4f6f6bdf8f577205 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:39 +0100 Subject: [PATCH 0820/1519] staging:iio:adc:ad7291: Add regulator, reference voltage and scale handling Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 61 +++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index b34af692612..84c638d4f34 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "../iio.h" #include "../sysfs.h" @@ -27,8 +29,8 @@ * * The noise-delayed bit as per datasheet suggestion is always enabled. * - * Extref control should be based on regulator provision - not handled. */ + /* * AD7291 registers definition */ @@ -61,16 +63,21 @@ * AD7291 value masks */ #define AD7291_CHANNEL_MASK 0xF000 +#define AD7291_BITS 12 #define AD7291_VALUE_MASK 0xFFF #define AD7291_T_VALUE_SIGN 0x400 #define AD7291_T_VALUE_FLOAT_OFFSET 2 #define AD7291_T_VALUE_FLOAT_MASK 0x2 +#define AD7291_BITS 12 + struct ad7291_chip_info { - struct i2c_client *client; - u16 command; - u8 c_mask; /* Active voltage channels for events */ - struct mutex state_lock; + struct i2c_client *client; + struct regulator *reg; + u16 int_vref_mv; + u16 command; + u8 c_mask; /* Active voltage channels for events */ + struct mutex state_lock; }; static int ad7291_i2c_read(struct ad7291_chip_info *chip, u8 reg, u16 *data) @@ -420,6 +427,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, { int ret; struct ad7291_chip_info *chip = iio_priv(indio_dev); + unsigned int scale_uv; u16 regval; s16 signval; @@ -471,6 +479,11 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, signval = (s16)((swab16((u16)ret) & 0x0FFF) << 4) >> 4; *val = signval; return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + scale_uv = (chip->int_vref_mv * 1000) >> AD7291_BITS; + *val = scale_uv / 1000; + *val2 = (scale_uv % 1000) * 1000; + return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; } @@ -479,6 +492,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, #define AD7291_VOLTAGE_CHAN(_chan) \ { \ .type = IIO_VOLTAGE, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ .indexed = 1, \ .channel = _chan, \ .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)|\ @@ -524,7 +538,7 @@ static int __devinit ad7291_probe(struct i2c_client *client, { struct ad7291_chip_info *chip; struct iio_dev *indio_dev; - int ret = 0; + int ret = 0, voltage_uv = 0; indio_dev = iio_allocate_device(sizeof(*chip)); if (indio_dev == NULL) { @@ -532,6 +546,15 @@ static int __devinit ad7291_probe(struct i2c_client *client, goto error_ret; } chip = iio_priv(indio_dev); + + chip->reg = regulator_get(&client->dev, "vcc"); + if (!IS_ERR(chip->reg)) { + ret = regulator_enable(chip->reg); + if (ret) + goto error_put_reg; + voltage_uv = regulator_get_voltage(chip->reg); + } + mutex_init(&chip->state_lock); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); @@ -540,6 +563,13 @@ static int __devinit ad7291_probe(struct i2c_client *client, /* Tsense always enabled */ chip->command = AD7291_NOISE_DELAY | AD7291_T_SENSE_MASK; + if (voltage_uv) { + chip->int_vref_mv = voltage_uv / 1000; + chip->command |= AD7291_EXT_REF; + } else { + chip->int_vref_mv = 2500; /* Build-in ref */ + } + indio_dev->name = id->name; indio_dev->channels = ad7291_channels; indio_dev->num_channels = ARRAY_SIZE(ad7291_channels); @@ -556,7 +586,7 @@ static int __devinit ad7291_probe(struct i2c_client *client, id->name, indio_dev); if (ret) - goto error_free_dev; + goto error_disable_reg; /* set irq polarity low level */ chip->command |= AD7291_ALERT_POLARITY; @@ -572,7 +602,7 @@ static int __devinit ad7291_probe(struct i2c_client *client, if (ret) goto error_unreg_irq; - dev_info(&client->dev, "%s temperature sensor registered.\n", + dev_info(&client->dev, "%s ADC registered.\n", id->name); return 0; @@ -580,7 +610,13 @@ static int __devinit ad7291_probe(struct i2c_client *client, error_unreg_irq: if (client->irq) free_irq(client->irq, indio_dev); -error_free_dev: +error_disable_reg: + if (!IS_ERR(chip->reg)) + regulator_disable(chip->reg); +error_put_reg: + if (!IS_ERR(chip->reg)) + regulator_put(chip->reg); + iio_free_device(indio_dev); error_ret: return ret; @@ -589,9 +625,16 @@ error_ret: static int __devexit ad7291_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad7291_chip_info *chip = iio_priv(indio_dev); if (client->irq) free_irq(client->irq, indio_dev); + + if (!IS_ERR(chip->reg)) { + regulator_disable(chip->reg); + regulator_put(chip->reg); + } + iio_device_unregister(indio_dev); return 0; From 81e2edbe93fc720ec6ebf0cca50e0507dfe2efc7 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:40 +0100 Subject: [PATCH 0821/1519] staging:iio:adc:ad7291: don't swab results twice and introduce more register defines Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 90 ++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 84c638d4f34..9d1af0e9cc0 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -34,18 +34,43 @@ /* * AD7291 registers definition */ -#define AD7291_COMMAND 0 -#define AD7291_VOLTAGE 1 -#define AD7291_T_SENSE 2 -#define AD7291_T_AVERAGE 3 -#define AD7291_VOLTAGE_LIMIT_BASE 4 -#define AD7291_VOLTAGE_LIMIT_COUNT 8 +#define AD7291_COMMAND 0x00 +#define AD7291_VOLTAGE 0x01 +#define AD7291_T_SENSE 0x02 +#define AD7291_T_AVERAGE 0x03 +#define AD7291_CH0_DATA_HIGH 0x04 +#define AD7291_CH0_DATA_LOW 0x05 +#define AD7291_CH0_HYST 0x06 +#define AD7291_CH1_DATA_HIGH 0x07 +#define AD7291_CH1_DATA_LOW 0x08 +#define AD7291_CH1_HYST 0x09 +#define AD7291_CH2_DATA_HIGH 0x0A +#define AD7291_CH2_DATA_LOW 0x0B +#define AD7291_CH2_HYST 0x0C +#define AD7291_CH3_DATA_HIGH 0x0D +#define AD7291_CH3_DATA_LOW 0x0E +#define AD7291_CH3_HYST 0x0F +#define AD7291_CH4_DATA_HIGH 0x10 +#define AD7291_CH4_DATA_LOW 0x11 +#define AD7291_CH4_HYST 0x12 +#define AD7291_CH5_DATA_HIGH 0x13 +#define AD7291_CH5_DATA_LOW 0x14 +#define AD7291_CH5_HYST 0x15 +#define AD7291_CH6_DATA_HIGH 0x16 +#define AD7291_CH6_DATA_LOW 0x17 +#define AD7291_CH6_HYST 0x18 +#define AD7291_CH7_DATA_HIGH 0x19 +#define AD7291_CH7_DATA_LOW 0x1A +#define AD7291_CH7_HYST 0x2B #define AD7291_T_SENSE_HIGH 0x1C #define AD7291_T_SENSE_LOW 0x1D #define AD7291_T_SENSE_HYST 0x1E #define AD7291_VOLTAGE_ALERT_STATUS 0x1F #define AD7291_T_ALERT_STATUS 0x20 +#define AD7291_VOLTAGE_LIMIT_COUNT 8 + + /* * AD7291 command */ @@ -198,7 +223,7 @@ static inline ssize_t ad7291_show_hyst(struct device *dev, if (ret < 0) return ret; - return sprintf(buf, "%d\n", data & 0x0FFF); + return sprintf(buf, "%d\n", data & AD7291_VALUE_MASK); } static inline ssize_t ad7291_set_hyst(struct device *dev, @@ -228,28 +253,28 @@ static IIO_DEVICE_ATTR(in_temp0_thresh_both_hyst_raw, AD7291_T_SENSE_HYST); static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x06); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH0_HYST); static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x09); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH1_HYST); static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x0C); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH2_HYST); static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x0F); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH3_HYST); static IIO_DEVICE_ATTR(in_voltage4_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x12); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH4_HYST); static IIO_DEVICE_ATTR(in_voltage5_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x15); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH5_HYST); static IIO_DEVICE_ATTR(in_voltage6_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x18); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH6_HYST); static IIO_DEVICE_ATTR(in_voltage7_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, - ad7291_show_hyst, ad7291_set_hyst, 0x1B); + ad7291_show_hyst, ad7291_set_hyst, AD7291_CH7_HYST); static struct attribute *ad7291_event_attributes[] = { &iio_dev_attr_in_temp0_thresh_both_hyst_raw.dev_attr.attr, @@ -266,16 +291,16 @@ static struct attribute *ad7291_event_attributes[] = { /* high / low */ static u8 ad7291_limit_regs[9][2] = { - { 0x04, 0x05 }, - { 0x07, 0x08 }, - { 0x0A, 0x0B }, - { 0x0E, 0x0D }, /* note reversed order */ - { 0x10, 0x11 }, - { 0x13, 0x14 }, - { 0x16, 0x17 }, - { 0x19, 0x1A }, + { AD7291_CH0_DATA_HIGH, AD7291_CH0_DATA_LOW }, + { AD7291_CH1_DATA_HIGH, AD7291_CH1_DATA_LOW }, + { AD7291_CH2_DATA_HIGH, AD7291_CH2_DATA_LOW }, + { AD7291_CH3_DATA_HIGH, AD7291_CH3_DATA_LOW }, /* FIXME: ? */ + { AD7291_CH4_DATA_HIGH, AD7291_CH4_DATA_LOW }, + { AD7291_CH5_DATA_HIGH, AD7291_CH5_DATA_LOW }, + { AD7291_CH6_DATA_HIGH, AD7291_CH6_DATA_LOW }, + { AD7291_CH7_DATA_HIGH, AD7291_CH7_DATA_LOW }, /* temp */ - { 0x1C, 0x1D }, + { AD7291_T_SENSE_HIGH, AD7291_T_SENSE_LOW }, }; static int ad7291_read_event_value(struct iio_dev *indio_dev, @@ -298,7 +323,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, ret = ad7291_i2c_read(chip, reg, &uval); if (ret < 0) return ret; - *val = swab16(uval) & 0x0FFF; + *val = uval & AD7291_VALUE_MASK; return 0; case IIO_TEMP: @@ -309,7 +334,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, ret = ad7291_i2c_read(chip, reg, &signval); if (ret < 0) return ret; - signval = (s16)((swab16(signval) & 0x0FFF) << 4) >> 4; + signval = (s16)((signval & AD7291_VALUE_MASK) << 4) >> 4; *val = signval; return 0; default: @@ -332,9 +357,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev, reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING)]; - return ad7291_i2c_write(chip, reg, val); - case IIO_TEMP: if (val > 2047 || val < -2048) return -EINVAL; @@ -386,6 +409,7 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev, * use continuous sampling mode. * Possible to disable temp as well but that makes single read tricky. */ + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { case IIO_VOLTAGE: if ((!state) && (chip->c_mask & @@ -399,7 +423,7 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev, else break; - regval &= 0xFFFE; + regval &= ~AD7291_AUTOCYCLE; regval |= ((u16)chip->c_mask << 8); if (chip->c_mask) /* Enable autocycle? */ regval |= AD7291_AUTOCYCLE; @@ -456,7 +480,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, mutex_unlock(&chip->state_lock); return ret; } - *val = swab16((u16)ret) & 0x0FFF; + *val = swab16((u16)ret) & AD7291_VALUE_MASK; mutex_unlock(&chip->state_lock); return IIO_VAL_INT; case IIO_TEMP: @@ -465,7 +489,8 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, AD7291_T_SENSE); if (ret < 0) return ret; - signval = (s16)((swab16((u16)ret) & 0x0FFF) << 4) >> 4; + signval = (s16)((swab16((u16)ret) & + AD7291_VALUE_MASK) << 4) >> 4; *val = signval; return IIO_VAL_INT; default: @@ -476,7 +501,8 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, AD7291_T_AVERAGE); if (ret < 0) return ret; - signval = (s16)((swab16((u16)ret) & 0x0FFF) << 4) >> 4; + signval = (s16)((swab16((u16)ret) & + AD7291_VALUE_MASK) << 4) >> 4; *val = signval; return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): From 94c93dbde974b074a4301fb7c44f9dbb04da8712 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:41 +0100 Subject: [PATCH 0822/1519] staging:iio:adc:ad7291: fix mask bit generation Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 9d1af0e9cc0..d125af0ccf5 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -418,7 +418,7 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev, ~(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); else if (state && (!(chip->c_mask & (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))))) - chip->c_mask &= + chip->c_mask |= (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); else break; From b576590dcd4ef4774b155540e392491afb1d1da0 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:42 +0100 Subject: [PATCH 0823/1519] staging:iio:adc:ad7291: introduce IIO_EVENT_CODE_EXTRACT_CHAN_TYPE and use accordingly Fix channel type handling Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 6 +++--- drivers/staging/iio/sysfs.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index d125af0ccf5..840353624a7 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -314,7 +314,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, u16 uval; s16 signval; - switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { case IIO_VOLTAGE: reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == @@ -350,7 +350,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev, u8 reg; s16 signval; - switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { case IIO_VOLTAGE: if (val > 0xFFF || val < 0) return -EINVAL; @@ -378,7 +378,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev, /* To be enabled the channel must simply be on. If any are enabled we are in continuous sampling mode */ - switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { case IIO_VOLTAGE: if (chip->c_mask & (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))) diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 12152461ca5..174f2c6bf3f 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -146,8 +146,11 @@ enum iio_event_direction { IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0) #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) + #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF) +#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF) + /* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ #define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF) From 06420c2d61f3ec838f15933b8c03ae2e658d0d56 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:43 +0100 Subject: [PATCH 0824/1519] staging:iio:adc:ad7291: fix channel mapping for event enables Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 840353624a7..687509fcc97 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -101,7 +101,7 @@ struct ad7291_chip_info { struct regulator *reg; u16 int_vref_mv; u16 command; - u8 c_mask; /* Active voltage channels for events */ + u16 c_mask; /* Active voltage channels for events */ struct mutex state_lock; }; @@ -381,7 +381,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev, switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { case IIO_VOLTAGE: if (chip->c_mask & - (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))) + (1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM(event_code)))) return 1; else return 0; @@ -412,19 +412,19 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev, switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { case IIO_VOLTAGE: - if ((!state) && (chip->c_mask & - (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)))) - chip->c_mask &= - ~(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); - else if (state && (!(chip->c_mask & - (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))))) - chip->c_mask |= - (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)); + if ((!state) && (chip->c_mask & (1 << (15 - + IIO_EVENT_CODE_EXTRACT_NUM(event_code))))) + chip->c_mask &= ~(1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM + (event_code))); + else if (state && (!(chip->c_mask & (1 << (15 - + IIO_EVENT_CODE_EXTRACT_NUM(event_code)))))) + chip->c_mask |= (1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM + (event_code))); else break; regval &= ~AD7291_AUTOCYCLE; - regval |= ((u16)chip->c_mask << 8); + regval |= chip->c_mask; if (chip->c_mask) /* Enable autocycle? */ regval |= AD7291_AUTOCYCLE; @@ -461,7 +461,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, case IIO_VOLTAGE: mutex_lock(&chip->state_lock); /* If in autocycle mode drop through */ - if (chip->command & 0x1) { + if (chip->command & AD7291_AUTOCYCLE) { mutex_unlock(&chip->state_lock); return -EBUSY; } From c11f02ed4274a007f44c24bcafc07b203960c60e Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:44 +0100 Subject: [PATCH 0825/1519] staging:iio:adc:ad7291: reset device and setup irq before it is enabled Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 687509fcc97..e08619b3d36 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -586,8 +586,10 @@ static int __devinit ad7291_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); chip->client = client; - /* Tsense always enabled */ - chip->command = AD7291_NOISE_DELAY | AD7291_T_SENSE_MASK; + + chip->command = AD7291_NOISE_DELAY | + AD7291_T_SENSE_MASK | /* Tsense always enabled */ + AD7291_ALERT_POLARITY; /* set irq polarity low level */ if (voltage_uv) { chip->int_vref_mv = voltage_uv / 1000; @@ -604,6 +606,18 @@ static int __devinit ad7291_probe(struct i2c_client *client, indio_dev->info = &ad7291_info; indio_dev->modes = INDIO_DIRECT_MODE; + ret = ad7291_i2c_write(chip, AD7291_COMMAND, AD7291_RESET); + if (ret) { + ret = -EIO; + goto error_disable_reg; + } + + ret = ad7291_i2c_write(chip, AD7291_COMMAND, chip->command); + if (ret) { + ret = -EIO; + goto error_disable_reg; + } + if (client->irq > 0) { ret = request_threaded_irq(client->irq, NULL, @@ -613,15 +627,6 @@ static int __devinit ad7291_probe(struct i2c_client *client, indio_dev); if (ret) goto error_disable_reg; - - /* set irq polarity low level */ - chip->command |= AD7291_ALERT_POLARITY; - } - - ret = ad7291_i2c_write(chip, AD7291_COMMAND, chip->command); - if (ret) { - ret = -EIO; - goto error_unreg_irq; } ret = iio_device_register(indio_dev); From e68b1db1b573ddb5b9d793df01ddd9aaa3d120c3 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:45 +0100 Subject: [PATCH 0826/1519] staging:iio:adc:ad7192: add temp_scale attribute, change module description Use KBUILD_MODNAME Fix indention style Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index e08619b3d36..4697ebbfd08 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -102,7 +102,7 @@ struct ad7291_chip_info { u16 int_vref_mv; u16 command; u16 c_mask; /* Active voltage channels for events */ - struct mutex state_lock; + struct mutex state_lock; }; static int ad7291_i2c_read(struct ad7291_chip_info *chip, u8 reg, u16 *data) @@ -510,6 +510,13 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, *val = scale_uv / 1000; *val2 = (scale_uv % 1000) * 1000; return IIO_VAL_INT_PLUS_MICRO; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + /* + * One LSB of the ADC corresponds to 0.25 deg C. + * The temperature reading is in 12-bit twos complement format + */ + *val = 250; + return IIO_VAL_INT; default: return -EINVAL; } @@ -536,7 +543,8 @@ static const struct iio_chan_spec ad7291_channels[] = { AD7291_VOLTAGE_CHAN(7), { .type = IIO_TEMP, - .info_mask = (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE), + .info_mask = (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), .indexed = 1, .channel = 0, .event_mask = @@ -680,7 +688,7 @@ MODULE_DEVICE_TABLE(i2c, ad7291_id); static struct i2c_driver ad7291_driver = { .driver = { - .name = "ad7291", + .name = KBUILD_MODNAME, }, .probe = ad7291_probe, .remove = __devexit_p(ad7291_remove), @@ -698,8 +706,7 @@ static __exit void ad7291_exit(void) } MODULE_AUTHOR("Sonic Zhang "); -MODULE_DESCRIPTION("Analog Devices AD7291 digital" - " temperature sensor driver"); +MODULE_DESCRIPTION("Analog Devices AD7291 ADC driver"); MODULE_LICENSE("GPL v2"); module_init(ad7291_init); From a3ef65d3225f1ff378da4798b9c0c68f13265900 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:46 +0100 Subject: [PATCH 0827/1519] staging:iio:adc:ad7192: return len and fix out of range checking Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7291.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 4697ebbfd08..c486d72167b 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -241,10 +241,14 @@ static inline ssize_t ad7291_set_hyst(struct device *dev, if (ret < 0) return ret; - if (data < 4096) + if (data > AD7291_VALUE_MASK) return -EINVAL; - return ad7291_i2c_write(chip, this_attr->address, data); + ret = ad7291_i2c_write(chip, this_attr->address, data); + if (ret < 0) + return ret; + + return len; } static IIO_DEVICE_ATTR(in_temp0_thresh_both_hyst_raw, @@ -352,7 +356,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev, switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { case IIO_VOLTAGE: - if (val > 0xFFF || val < 0) + if (val > AD7291_VALUE_MASK || val < 0) return -EINVAL; reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == From 15e3276fd020621236e8443a599b80ae28d6832b Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 2 Sep 2011 17:25:47 +0100 Subject: [PATCH 0828/1519] staging:iio: ad7152: fix channel assignment for AD7153 In case the AD7153 is selected we need to make sure we provide channel info for the first capacitance input in both single ended and differential configuration. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7152.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index 42996b96b85..f980a093882 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -441,17 +441,17 @@ static const struct iio_chan_spec ad7152_channels[] = { (1 << IIO_CHAN_INFO_SCALE_SEPARATE), }, { .type = IIO_CAPACITANCE, + .differential = 1, .indexed = 1, - .channel = 1, + .channel = 0, + .channel2 = 2, .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | (1 << IIO_CHAN_INFO_SCALE_SEPARATE), }, { .type = IIO_CAPACITANCE, - .differential = 1, .indexed = 1, - .channel = 0, - .channel2 = 2, + .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | (1 << IIO_CHAN_INFO_SCALE_SEPARATE), From cf55f4a8b6243b42fb91c56d1421db0d36d60f96 Mon Sep 17 00:00:00 2001 From: Mike Sterling Date: Tue, 6 Sep 2011 16:10:55 -0700 Subject: [PATCH 0829/1519] Staging: hv: Add support for >2 TB LUN in storage driver. If a LUN larger than 2 TB is attached to a Linux VM on Hyper-V, we currently report a maximum size of 2 TB. This patch resolves the issue in hv_storvsc. Thanks to Robert Scheck for reporting the issue. Reported-by: Robert Scheck Signed-off-by: Mike Sterling Signed-off-by: K.Y. Srinivasan Signed-off-by: Haiyang Zhang Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 3686d1048e3..b0c4e56304e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -232,6 +232,7 @@ struct vstor_packet { #define STORVSC_MAX_LUNS_PER_TARGET 64 #define STORVSC_MAX_TARGETS 1 #define STORVSC_MAX_CHANNELS 1 +#define STORVSC_MAX_CMD_LEN 16 struct hv_storvsc_request; @@ -1440,6 +1441,8 @@ static int storvsc_probe(struct hv_device *device) host->max_id = STORVSC_MAX_TARGETS; /* max # of channels */ host->max_channel = STORVSC_MAX_CHANNELS - 1; + /* max cmd length */ + host->max_cmd_len = STORVSC_MAX_CMD_LEN; /* Register the HBA and start the scsi bus scan */ ret = scsi_add_host(host, &device->device); From aa9af000a30e81a40294c21861402dd3c8d610ea Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:13 -0500 Subject: [PATCH 0830/1519] staging: rtl8192e: Remove dead code involving MOVE_INTO_HANDLER File rtl_core.c contains the statement "#define MOVE_INTO_HANDLER". As a result, everything inside an "ifndef MOVE_INTO_HANDLER" is dead code and can be removed. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 6530058eab6..ce0b2ff9273 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -588,7 +588,6 @@ static void rtl8192_update_beacon(void *data) rtl8192_update_cap(dev, net->capability); } -#define MOVE_INTO_HANDLER int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; static void rtl8192_qos_activate(void *data) @@ -596,13 +595,6 @@ static void rtl8192_qos_activate(void *data) struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); struct net_device *dev = priv->rtllib->dev; -#ifndef MOVE_INTO_HANDLER - struct rtllib_qos_parameters *qos_parameters = - &priv->rtllib->current_network.qos_data.parameters; - u8 mode = priv->rtllib->current_network.mode; - u8 u1bAIFS; - u32 u4bAcParam; -#endif int i; if (priv == NULL) @@ -615,21 +607,7 @@ static void rtl8192_qos_activate(void *data) "received\n"); for (i = 0; i < QOS_QUEUE_NUM; i++) { -#ifndef MOVE_INTO_HANDLER - u1bAIFS = qos_parameters->aifs[i] * - ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i])) << - AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(qos_parameters->cw_max[i])) << - AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(qos_parameters->cw_min[i])) << - AC_PARAM_ECW_MIN_OFFSET) | - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); - RT_TRACE(COMP_DBG, "===>ACI:%d:u4bAcParam:%x\n", i, u4bAcParam); - write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); -#else priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); -#endif } success: From 35f8673d11b60c6c887f8f28734233a7aa580afa Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:14 -0500 Subject: [PATCH 0831/1519] staging: rtl8192e: Fix smatch error and warning in rtl_core.c Smatch shows the following errors: CHECK drivers/staging/rtl8192e/rtl_core.c drivers/staging/rtl8192e/rtl_core.c +600 rtl8192_qos_activate(7) warn: variable dereferenced before check 'priv' drivers/staging/rtl8192e/rtl_core.c +1345 rtl8192_init(40) warn: 'dev->irq' was not released on error drivers/staging/rtl8192e/rtl_core.c +2120 rtl8192_alloc_rx_desc_ring(43) error: potential null derefence 'entry'. drivers/staging/rtl8192e/rtl_core.c +3010 rtl8192_pci_probe(153) warn: 'pmem_start' was not released on error Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 58 ++++++++++++----------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index ce0b2ff9273..4c5d7abd9be 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -448,7 +448,7 @@ bool MgntActSet_RF_State(struct net_device *dev, spin_unlock_irqrestore(&priv->rf_ps_lock, flag); } - RT_TRACE((COMP_PS && COMP_RF), "<===MgntActSet_RF_State()\n"); + RT_TRACE((COMP_PS | COMP_RF), "<===MgntActSet_RF_State()\n"); return bActionAllowed; } @@ -597,9 +597,6 @@ static void rtl8192_qos_activate(void *data) struct net_device *dev = priv->rtllib->dev; int i; - if (priv == NULL) - return; - mutex_lock(&priv->mutex); if (priv->rtllib->state != RTLLIB_LINKED) goto success; @@ -1342,6 +1339,7 @@ static short rtl8192_init(struct net_device *dev) if (rtl8192_pci_initdescring(dev) != 0) { printk(KERN_ERR "Endopoints initialization failed"); + free_irq(dev->irq, dev); return -1; } @@ -2117,7 +2115,8 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) entry->OWN = 1; } - entry->EOR = 1; + if(entry) + entry->EOR = 1; } return 0; } @@ -2862,7 +2861,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, struct r8192_priv *priv = NULL; struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); unsigned long pmem_start, pmem_len, pmem_flags; - int err = 0; + int err = -ENOMEM; bool bdma64 = false; u8 revision_id; @@ -2878,14 +2877,14 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { printk(KERN_INFO "Unable to obtain 32bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; + goto err_pci_disable; } } dev = alloc_rtllib(sizeof(struct r8192_priv)); if (!dev) - return -ENOMEM; + goto err_pci_disable; + err = -ENODEV; if (bdma64) dev->features |= NETIF_F_HIGHDMA; @@ -2907,20 +2906,20 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, if (!(pmem_flags & IORESOURCE_MEM)) { RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting"); - goto fail; + goto err_rel_rtllib; } printk(KERN_INFO "Memory mapped space start: 0x%08lx\n", pmem_start); if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { RT_TRACE(COMP_ERR, "request_mem_region failed!"); - goto fail; + goto err_rel_rtllib; } ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); if (ioaddr == (unsigned long)NULL) { RT_TRACE(COMP_ERR, "ioremap failed!"); - goto fail1; + goto err_rel_mem; } dev->mem_start = ioaddr; @@ -2929,12 +2928,12 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, pci_read_config_byte(pdev, 0x08, &revision_id); /* If the revisionid is 0x10, the device uses rtl8192se. */ if (pdev->device == 0x8192 && revision_id == 0x10) - goto fail1; + goto err_rel_mem; priv->ops = ops; if (rtl8192_pci_findadapter(pdev, dev) == false) - goto fail1; + goto err_rel_mem; dev->irq = pdev->irq; priv->irq = 0; @@ -2967,7 +2966,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, RT_TRACE(COMP_INIT, "Driver probe completed1\n"); if (rtl8192_init(dev) != 0) { RT_TRACE(COMP_ERR, "Initialization failed"); - goto fail1; + goto err_free_irq; } netif_carrier_off(dev); @@ -2987,28 +2986,19 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; -fail1: - if (dev->mem_start != (unsigned long)NULL) { - iounmap((void *)dev->mem_start); - release_mem_region(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); - } - -fail: - if (dev) { - if (priv->irq) { - free_irq(dev->irq, dev); - priv->irq = 0; - } - free_rtllib(dev); - } - - pci_disable_device(pdev); +err_free_irq: + free_irq(dev->irq, dev); + priv->irq = 0; +err_rel_mem: + release_mem_region(pmem_start, pmem_len); +err_rel_rtllib: + free_rtllib(dev); DMESG("wlan driver load failed\n"); pci_set_drvdata(pdev, NULL); - return -ENODEV; - +err_pci_disable: + pci_disable_device(pdev); + return err; } static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) From 77a04453eb467db0b00b6134ec4c26fa1201860c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:15 -0500 Subject: [PATCH 0832/1519] staging: rtl8192e: Fix smatch info output for r8192E_dev.c Smatch reports the following informational output: CHECK drivers/staging/rtl8192e/r8192E_dev.c drivers/staging/rtl8192e/r8192E_dev.c +2404 ActUpdateChannelAccessSetting(13) info: ignoring unreachable code. drivers/staging/rtl8192e/r8192E_dev.c +2404 ActUpdateChannelAccessSetting(13) info: ignoring unreachable code. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_dev.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 899e4e5e98f..808aab6fa5e 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -2387,27 +2387,9 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) return tmp_Short; } -void -ActUpdateChannelAccessSetting( - struct net_device *dev, +void ActUpdateChannelAccessSetting(struct net_device *dev, enum wireless_mode WirelessMode, - struct channel_access_setting *ChnlAccessSetting - ) + struct channel_access_setting *ChnlAccessSetting) { - struct r8192_priv *priv = rtllib_priv(dev); - - return; - - { - u16 SIFS_Timer; - - if (WirelessMode == WIRELESS_MODE_G) - SIFS_Timer = 0x0e0e; - else - SIFS_Timer = priv->SifsTime; - - priv->rtllib->SetHwRegHandler(dev, HW_VAR_SIFS, - (u8 *)&SIFS_Timer); - } - + return; } From e25316a08e7e1ebd3f152b14ed251067b45d2da8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:16 -0500 Subject: [PATCH 0833/1519] staging: rtl8192e: Fix smatch warning in rtl_wx.c Smatch reports the following warning: CHECK drivers/staging/rtl8192e/rtl_wx.c drivers/staging/rtl8192e/rtl_wx.c +262 r8192se_wx_set_radio(16) warn: inconsistent returns sem:&priv->wx_sem: locked (258) unlocked (262) Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_wx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index 77ea4bb8c7a..93b1edbe6ba 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -255,6 +255,7 @@ static int r8192se_wx_set_radio(struct net_device *dev, if ((*extra != 0) && (*extra != 1)) { RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio " "off) or 1(radio on)\n", __func__); + up(&priv->wx_sem); return -1; } priv->sw_radio_on = *extra; From a07663eddb2dc84361497352233adfb2ed6f55de Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:17 -0500 Subject: [PATCH 0834/1519] staging: rtl8192e: Silence smatch info in r8192E_cmdpkt.c Smatch outputs the following informational message: CHECK drivers/staging/rtl8192e/r8192E_cmdpkt.c drivers/staging/rtl8192e/r8192E_cmdpkt.c +419 cmpk_message_handle_rx(77) info: ignoring unreachable code. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 09978b6428f..58d044ea552 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -415,6 +415,4 @@ u32 cmpk_message_handle_rx(struct net_device *dev, pcmd_buff += cmd_length; } return 1; - - RT_TRACE(COMP_CMDPKT, "<----cmpk_message_handle_rx()\n"); } From ce7b393f50e93da441a4a532ff6ca393fb6bd64a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:18 -0500 Subject: [PATCH 0835/1519] staging: rtl8192e: Fix smatch warning in rtl819x_BAProc.c Smatch outputs the following warning: CHECK drivers/staging/rtl8192e/rtl819x_BAProc.c drivers/staging/rtl8192e/rtl819x_BAProc.c +88 rtllib_ADDBA(12) warn: variable dereferenced before check 'ieee' As ieee cannot be NULL at this point, remove all such checks. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 48f9f71051e..330a3a96bab 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -82,12 +82,12 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, u8 *tag = NULL; u16 tmp = 0; u16 len = ieee->tx_headroom + 9; + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" " sentd to: %pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); - if (pBA == NULL || ieee == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " - "NULL\n", pBA, ieee); + if (pBA == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL\n"); return NULL; } skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); From 52a7fb0951b35840a79a5b162fb853b78cec3c09 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:19 -0500 Subject: [PATCH 0836/1519] staging: rtl8192e: Fix smatch error in r8192E_phy.c Smatch reports the following: CHECK drivers/staging/rtl8192e/r8192E_phy.c drivers/staging/rtl8192e/r8192E_phy.c +940 rtl8192_phy_SwChnlStepByStep(92) error: potential null derefence 'CurrentCmd'. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_phy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 83e00d72199..7ec6139cb4f 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -937,7 +937,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; } - if (CurrentCmd->CmdID == CmdID_End) { + if (CurrentCmd && CurrentCmd->CmdID == CmdID_End) { if ((*stage) == 2) { return true; } else { @@ -947,6 +947,8 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, } } + if (!CurrentCmd) + continue; switch (CurrentCmd->CmdID) { case CmdID_SetTxPowerLevel: if (priv->IC_Cut > (u8)VERSION_8190_BD) From 2eed3dee92453c1798f0932613b1b66f0763ab2e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:20 -0500 Subject: [PATCH 0837/1519] staging: rtl8192e: Fix smatch warnings regarding large arrays on stack Smatch reports the follwing warnings: CHECK drivers/staging/rtl8192e/rtllib_rx.c drivers/staging/rtl8192e/rtllib_rx.c +552 RxReorderIndicatePacket(6) warn: 'prxbIndicateArray' puts 1024 bytes on stack CHECK drivers/staging/rtl8192e/rtl819x_TSProc.c drivers/staging/rtl8192e/rtl819x_TSProc.c +40 RxPktPendingTimeout(9) warn: 'stats_IndicateArray' puts 1024 bytes on stack CHECK drivers/staging/rtl8192e/r8192E_phy.c drivers/staging/rtl8192e/r8192E_phy.c +859 rtl8192_phy_SwChnlStepByStep(11) warn: function puts 797 bytes on stack CHECK drivers/staging/rtl8192e/rtllib_rx.c drivers/staging/rtl8192e/rtllib_rx.c +552 RxReorderIndicatePacket(6) warn: 'prxbIndicateArray' puts 1024 bytes on stack These are fixed by adding the arrays in question as a union in a struct used by nearly all routines. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/r8192E_phy.c | 28 ++++++++++---------- drivers/staging/rtl8192e/r8192E_phy.h | 24 ------------------ drivers/staging/rtl8192e/rtl819x_TSProc.c | 5 ++-- drivers/staging/rtl8192e/rtllib.h | 31 +++++++++++++++++++++++ drivers/staging/rtl8192e/rtllib_rx.c | 12 ++++----- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 7ec6139cb4f..7fe69a3348d 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -849,11 +849,9 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); - struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; + struct rtllib_device *ieee = priv->rtllib; u32 PreCommonCmdCnt; - struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT]; u32 PostCommonCmdCnt; - struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; u32 RfDependCmdCnt; struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; @@ -869,15 +867,18 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, { PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd, + PreCommonCmdCnt++, MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd, + PreCommonCmdCnt++, MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); PostCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(ieee->PostCommonCmd, + PostCommonCmdCnt++, MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); RfDependCmdCnt = 0; @@ -888,11 +889,11 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, "8225: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; @@ -903,11 +904,12 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, " 8256: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); @@ -927,13 +929,13 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, do { switch (*stage) { case 0: - CurrentCmd = &PreCommonCmd[*step]; + CurrentCmd = &ieee->PreCommonCmd[*step]; break; case 1: - CurrentCmd = &RfDependCmd[*step]; + CurrentCmd = &ieee->RfDependCmd[*step]; break; case 2: - CurrentCmd = &PostCommonCmd[*step]; + CurrentCmd = &ieee->PostCommonCmd[*step]; break; } diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 86c6acd0c54..7318f8857af 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -21,10 +21,6 @@ #define MAX_DOZE_WAITING_TIMES_9x 64 -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - #define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE #define MACPHY_ArrayLength MACPHY_ArrayLengthPciE #define RadioA_ArrayLength RadioA_ArrayLengthPciE @@ -45,26 +41,6 @@ #define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray #define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray - - -enum sw_chnl_cmd_id { - CmdID_End, - CmdID_SetTxPowerLevel, - CmdID_BBRegWrite10, - CmdID_WritePortUlong, - CmdID_WritePortUshort, - CmdID_WritePortUchar, - CmdID_RF_WriteReg, -}; - -/*--------------------------------Define structure----------------------------*/ -struct sw_chnl_cmd { - enum sw_chnl_cmd_id CmdID; - u32 Para1; - u32 Para2; - u32 msDelay; -} __packed; - extern u32 rtl819XMACPHY_Array_PG[]; extern u32 rtl819XPHY_REG_1T2RArray[]; extern u32 rtl819XAGCTAB_Array[]; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index ccec382cea2..5323a9c7bca 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -37,7 +37,6 @@ static void RxPktPendingTimeout(unsigned long data) struct rx_reorder_entry *pReorderEntry = NULL; unsigned long flags = 0; - struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; u8 index = 0; bool bPktInBuf = false; @@ -62,7 +61,7 @@ static void RxPktPendingTimeout(unsigned long data) RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate" " SeqNum: %d\n", __func__, pReorderEntry->SeqNum); - stats_IndicateArray[index] = + ieee->stats_IndicateArray[index] = pReorderEntry->prxb; index++; @@ -85,7 +84,7 @@ static void RxPktPendingTimeout(unsigned long data) flags); return; } - rtllib_indicate_packets(ieee, stats_IndicateArray, index); + rtllib_indicate_packets(ieee, ieee->stats_IndicateArray, index); bPktInBuf = false; } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c80460e0cfc..de25975ccee 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -43,6 +43,10 @@ #include #include /* ARPHRD_ETHER */ +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + #ifndef WIRELESS_SPY #define WIRELESS_SPY #endif @@ -208,6 +212,23 @@ struct cb_desc { u8 bIsBTProbRsp; }; +enum sw_chnl_cmd_id { + CmdID_End, + CmdID_SetTxPowerLevel, + CmdID_BBRegWrite10, + CmdID_WritePortUlong, + CmdID_WritePortUshort, + CmdID_WritePortUchar, + CmdID_RF_WriteReg, +}; + +struct sw_chnl_cmd { + enum sw_chnl_cmd_id CmdID; + u32 Para1; + u32 Para2; + u32 msDelay; +} __packed; + /*--------------------------Define -------------------------------------------*/ #define MGN_1M 0x02 #define MGN_2M 0x04 @@ -2416,6 +2437,16 @@ struct rtllib_device { struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; + union { + struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; + struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; + struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; + struct { + struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; + struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT]; + struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; + }; + }; /* Callback functions */ void (*set_security)(struct net_device *dev, diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 745ae0861df..8d0af5ed8ec 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -520,7 +520,6 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { struct rx_reorder_entry *pRxReorderEntry; - struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; u8 RfdCnt = 0; del_timer_sync(&pTS->RxPktPendingTimer); @@ -534,12 +533,12 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); - RfdArray[RfdCnt] = pRxReorderEntry->prxb; + ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb; RfdCnt = RfdCnt + 1; list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List); } - rtllib_indicate_packets(ieee, RfdArray, RfdCnt); + rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt); pTS->RxIndicateSeq = 0xffff; } @@ -550,7 +549,6 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; - struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; u8 WinSize = pHTInfo->RxReorderWinSize; u16 WinEnd = 0; u8 index = 0; @@ -617,7 +615,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! " "IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); - prxbIndicateArray[0] = prxb; + ieee->prxbIndicateArray[0] = prxb; index = 1; } else { /* Current packet is going to be inserted into pending list.*/ @@ -693,7 +691,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; - prxbIndicateArray[index] = pReorderEntry->prxb; + ieee->prxbIndicateArray[index] = pReorderEntry->prxb; RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum" " %d!\n", __func__, pReorderEntry->SeqNum); index++; @@ -720,7 +718,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, flags); return; } - rtllib_indicate_packets(ieee, prxbIndicateArray, index); + rtllib_indicate_packets(ieee, ieee->prxbIndicateArray, index); bPktInBuf = false; } From d7613e535e9892ff12aa31b3c62f1be839546ff9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:23:21 -0500 Subject: [PATCH 0838/1519] staging: rtl8192e: Fix various problems noted by smatch Smatch reports the following problems: CHECK drivers/staging/rtl8192e/rtllib_softmac.c drivers/staging/rtl8192e/rtllib_softmac.c +3143 rtllib_softmac_free(4) info: redundant null check on ieee->pDot11dInfo calling kfree() CHECK drivers/staging/rtl8192e/rtllib_module.c drivers/staging/rtl8192e/rtllib_module.c +198 free_rtllib(6) info: redundant null check on ieee->pHTInfo calling kfree() CHECK drivers/staging/rtl8192e/rtl819x_TSProc.c drivers/staging/rtl8192e/rtl819x_TSProc.c +280 SearchAdmitTRStream(52) error: potential null derefence 'pRet'. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- drivers/staging/rtl8192e/rtllib_module.c | 7 +++---- drivers/staging/rtl8192e/rtllib_softmac.c | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 5323a9c7bca..09a602f7432 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -277,7 +277,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, break; } - if (&pRet->List != psearch_list) + if (pRet && &pRet->List != psearch_list) return pRet ; else return NULL; diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 0fe67a54edd..c36a140a456 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -194,10 +194,9 @@ void free_rtllib(struct net_device *dev) struct rtllib_device *ieee = (struct rtllib_device *) netdev_priv_rsl(dev); int i; - if (ieee->pHTInfo != NULL) { - kfree(ieee->pHTInfo); - ieee->pHTInfo = NULL; - } + + kfree(ieee->pHTInfo); + ieee->pHTInfo = NULL; rtllib_softmac_free(ieee); del_timer_sync(&ieee->crypt_deinit_timer); rtllib_crypt_deinit_entries(ieee, 1); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a420ed1a947..b5086850f0d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3139,10 +3139,8 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { down(&ieee->wx_sem); - if (NULL != ieee->pDot11dInfo) { - kfree(ieee->pDot11dInfo); - ieee->pDot11dInfo = NULL; - } + kfree(ieee->pDot11dInfo); + ieee->pDot11dInfo = NULL; del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); From 95ccc2f72c3a74cef5b0eebdbbf813cdcc10086a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:51 +0200 Subject: [PATCH 0839/1519] staging: brcm80211: removed static function declarations in aiutils.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 211 +++++++++---------- 1 file changed, 97 insertions(+), 114 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 62186b7db69..07f9d373f2a 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -407,6 +407,9 @@ struct aidmp { u32 componentid3; /* 0xffc */ }; +/* global kernel resource */ +static struct si_info ksii; + /* EROM parsing */ static u32 @@ -839,6 +842,28 @@ u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) return R_REG(&ai->ioctrl); } +/* return true if PCIE capability exists in the pci config space */ +static bool ai_ispcie(struct si_info *sii) +{ + u8 cap_ptr; + + cap_ptr = + pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL, + NULL); + if (!cap_ptr) + return false; + + return true; +} + +static bool ai_buscore_prep(struct si_info *sii) +{ + /* kludge to enable the clock on the 4306 which lacks a slowclock */ + if (!ai_ispcie(sii)) + ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON); + return true; +} + u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) { struct si_info *sii; @@ -862,62 +887,6 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) return R_REG(&ai->iostatus); } -/* *************** from siutils.c ************** */ -/* local prototypes */ -static struct si_info *ai_doattach(struct si_info *sii, void *regs, - struct pci_dev *sdh, - char **vars, uint *varsz); -static bool ai_buscore_prep(struct si_info *sii); -static bool ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx); -static void ai_nvram_process(struct si_info *sii, char *pvars); - -/* dev path concatenation util */ -static char *ai_devpathvar(struct si_pub *sih, char *var, int len, - const char *name); -static bool _ai_clkctl_cc(struct si_info *sii, uint mode); -static bool ai_ispcie(struct si_info *sii); - -/* - * Allocate a si handle. - * devid - pci device id (used to determine chip#) - * osh - opaque OS handle - * regs - virtual address of initial core registers - * vars - pointer to a pointer area for "environment" variables - * varsz - pointer to int to return the size of the vars - */ -struct si_pub * -ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz) -{ - struct si_info *sii; - - /* alloc struct si_info */ - sii = kmalloc(sizeof(struct si_info), GFP_ATOMIC); - if (sii == NULL) { - SI_ERROR(("si_attach: malloc failed!\n")); - return NULL; - } - - if (ai_doattach(sii, regs, sdh, vars, varsz) == NULL) { - kfree(sii); - return NULL; - } - sii->vars = vars ? *vars : NULL; - sii->varsz = varsz ? *varsz : 0; - - return (struct si_pub *) sii; -} - -/* global kernel resource */ -static struct si_info ksii; - -static bool ai_buscore_prep(struct si_info *sii) -{ - /* kludge to enable the clock on the 4306 which lacks a slowclock */ - if (!ai_ispcie(sii)) - ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON); - return true; -} - static bool ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) { @@ -1206,6 +1175,34 @@ static struct si_info *ai_doattach(struct si_info *sii, return NULL; } +/* + * Allocate a si handle. + * devid - pci device id (used to determine chip#) + * osh - opaque OS handle + * regs - virtual address of initial core registers + * vars - pointer to a pointer area for "environment" variables + * varsz - pointer to int to return the size of the vars + */ +struct si_pub * +ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz) +{ + struct si_info *sii; + + /* alloc struct si_info */ + sii = kmalloc(sizeof(struct si_info), GFP_ATOMIC); + if (sii == NULL) + return NULL; + + if (ai_doattach(sii, regs, sdh, vars, varsz) == NULL) { + kfree(sii); + return NULL; + } + sii->vars = vars ? *vars : NULL; + sii->varsz = varsz ? *varsz : 0; + + return (struct si_pub *) sii; +} + /* may be called with core in reset */ void ai_detach(struct si_pub *sih) { @@ -1732,30 +1729,6 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) return 0; } -/* - * clock control policy function throught chipcommon - * - * set dynamic clk control mode (forceslow, forcefast, dynamic) - * returns true if we are forcing fast clock - * this is a wrapper over the next internal function - * to allow flexible policy settings for outside caller - */ -bool ai_clkctl_cc(struct si_pub *sih, uint mode) -{ - struct si_info *sii; - - sii = SI_INFO(sih); - - /* chipcommon cores prior to rev6 don't support dynamic clock control */ - if (sih->ccrev < 6) - return false; - - if (PCI_FORCEHT(sii)) - return mode == CLK_FAST; - - return _ai_clkctl_cc(sii, mode); -} - /* clk control mechanism through chipcommon, no policy checking */ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) { @@ -1842,6 +1815,30 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) return mode == CLK_FAST; } +/* + * clock control policy function throught chipcommon + * + * set dynamic clk control mode (forceslow, forcefast, dynamic) + * returns true if we are forcing fast clock + * this is a wrapper over the next internal function + * to allow flexible policy settings for outside caller + */ +bool ai_clkctl_cc(struct si_pub *sih, uint mode) +{ + struct si_info *sii; + + sii = SI_INFO(sih); + + /* chipcommon cores prior to rev6 don't support dynamic clock control */ + if (sih->ccrev < 6) + return false; + + if (PCI_FORCEHT(sii)) + return mode == CLK_FAST; + + return _ai_clkctl_cc(sii, mode); +} + /* Build device path */ int ai_devpath(struct si_pub *sih, char *path, int size) { @@ -1862,31 +1859,6 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return 0; } -/* Get a variable, but only if it has a devpath prefix */ -char *ai_getdevpathvar(struct si_pub *sih, const char *name) -{ - char varname[SI_DEVPATH_BUFSZ + 32]; - - ai_devpathvar(sih, varname, sizeof(varname), name); - - return getvar(NULL, varname); -} - -/* Get a variable, but only if it has a devpath prefix */ -int ai_getdevpathintvar(struct si_pub *sih, const char *name) -{ - char varname[SI_DEVPATH_BUFSZ + 32]; - - ai_devpathvar(sih, varname, sizeof(varname), name); - - return getintvar(NULL, varname); -} - -char *ai_getnvramflvar(struct si_pub *sih, const char *name) -{ - return getvar(NULL, name); -} - /* Concatenate the dev path with a varname into the given 'var' buffer * and return the 'var' pointer. Nothing is done to the arguments if * len == 0 or var is NULL, var is still returned. On overflow, the @@ -1912,18 +1884,29 @@ static char *ai_devpathvar(struct si_pub *sih, char *var, int len, return var; } -/* return true if PCIE capability exists in the pci config space */ -static bool ai_ispcie(struct si_info *sii) +/* Get a variable, but only if it has a devpath prefix */ +char *ai_getdevpathvar(struct si_pub *sih, const char *name) { - u8 cap_ptr; + char varname[SI_DEVPATH_BUFSZ + 32]; - cap_ptr = - pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL, - NULL); - if (!cap_ptr) - return false; + ai_devpathvar(sih, varname, sizeof(varname), name); - return true; + return getvar(NULL, varname); +} + +/* Get a variable, but only if it has a devpath prefix */ +int ai_getdevpathintvar(struct si_pub *sih, const char *name) +{ + char varname[SI_DEVPATH_BUFSZ + 32]; + + ai_devpathvar(sih, varname, sizeof(varname), name); + + return getintvar(NULL, varname); +} + +char *ai_getnvramflvar(struct si_pub *sih, const char *name) +{ + return getvar(NULL, name); } bool ai_pci_war16165(struct si_pub *sih) From d2bac23d7640d7fa709954befbbe2e5ea13c63f8 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:52 +0200 Subject: [PATCH 0840/1519] staging: brcm80211: removed static function declarations in alloc.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/alloc.c | 39 +++++++++------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 7dc287576cb..52ca7e3f9a9 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -1,4 +1,4 @@ -/* +#/* * Copyright (c) 2010 Broadcom Corporation * * Permission to use, copy, modify, and/or distribute this software for any @@ -20,13 +20,6 @@ #include "main.h" #include "alloc.h" -static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit); -static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg); -static struct brcms_pub *brcms_c_pub_malloc(uint unit, - uint *err, uint devid); -static void brcms_c_pub_mfree(struct brcms_pub *pub); -static void brcms_c_tunables_init(struct brcms_tunables *tunables, uint devid); - static void brcms_c_tunables_init(struct brcms_tunables *tunables, uint devid) { tunables->ntxd = NTXD; @@ -45,6 +38,16 @@ static void brcms_c_tunables_init(struct brcms_tunables *tunables, uint devid) tunables->txsbnd = TXSBND; } +static void brcms_c_pub_mfree(struct brcms_pub *pub) +{ + if (pub == NULL) + return; + + kfree(pub->multicast); + kfree(pub->tunables); + kfree(pub); +} + static struct brcms_pub *brcms_c_pub_malloc(uint unit, uint *err, uint devid) { struct brcms_pub *pub; @@ -77,14 +80,14 @@ static struct brcms_pub *brcms_c_pub_malloc(uint unit, uint *err, uint devid) return NULL; } -static void brcms_c_pub_mfree(struct brcms_pub *pub) +static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) { - if (pub == NULL) + if (cfg == NULL) return; - kfree(pub->multicast); - kfree(pub->tunables); - kfree(pub); + kfree(cfg->maclist); + kfree(cfg->current_bss); + kfree(cfg); } static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) @@ -106,16 +109,6 @@ static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) return NULL; } -static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) -{ - if (cfg == NULL) - return; - - kfree(cfg->maclist); - kfree(cfg->current_bss); - kfree(cfg); -} - static void brcms_c_bsscfg_ID_assign(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg) { From 7bd6e89c6d756bfe4cd6183bbd511b6700ab443a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:53 +0200 Subject: [PATCH 0841/1519] staging: brcm80211: removed static function declarations in ampdu.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 301 ++++++++++----------- 1 file changed, 141 insertions(+), 160 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 6fc15918b5b..318235dfdd4 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -60,6 +60,8 @@ * accumulate between resets. */ +#define SHORTNAME "AMPDU status" + #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ @@ -148,26 +150,77 @@ struct cb_del_ampdu_pars { #define SCB_AMPDU_CUBBY(ampdu, scb) (&(scb->scb_ampdu)) #define SCB_AMPDU_INI(scb_ampdu, tid) (&(scb_ampdu->ini[tid])) -static void brcms_c_ffpld_init(struct ampdu_info *ampdu); -static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int f); -static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f); - -static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, - u8 dur); -static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, - struct scb *scb); -static void brcms_c_scb_ampdu_update_config_all(struct ampdu_info *ampdu); - #define brcms_c_ampdu_txflowcontrol(a, b, c) do {} while (0) -static void -brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, - struct scb *scb, - struct sk_buff *p, struct tx_status *txs, - u32 frmtxstatus, u32 frmtxstatus2); +static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) +{ + u32 rate, mcs; -static bool brcms_c_ampdu_cap(struct ampdu_info *ampdu); -static int brcms_c_ampdu_set(struct ampdu_info *ampdu, bool on); + for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) { + /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */ + /* 20MHz, No SGI */ + rate = MCS_RATE(mcs, false, false); + ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3; + /* 40 MHz, No SGI */ + rate = MCS_RATE(mcs, true, false); + ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3; + /* 20MHz, SGI */ + rate = MCS_RATE(mcs, false, true); + ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3; + /* 40 MHz, SGI */ + rate = MCS_RATE(mcs, true, true); + ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3; + } +} + +static bool brcms_c_ampdu_cap(struct ampdu_info *ampdu) +{ + if (BRCMS_PHY_11N_CAP(ampdu->wlc->band)) + return true; + else + return false; +} + +static int brcms_c_ampdu_set(struct ampdu_info *ampdu, bool on) +{ + struct brcms_c_info *wlc = ampdu->wlc; + + wlc->pub->_ampdu = false; + + if (on) { + if (!N_ENAB(wlc->pub)) { + wiphy_err(ampdu->wlc->wiphy, "wl%d: driver not " + "nmode enabled\n", wlc->pub->unit); + return -ENOTSUPP; + } + if (!brcms_c_ampdu_cap(ampdu)) { + wiphy_err(ampdu->wlc->wiphy, "wl%d: device not " + "ampdu capable\n", wlc->pub->unit); + return -ENOTSUPP; + } + wlc->pub->_ampdu = on; + } + + return 0; +} + +static void brcms_c_ffpld_init(struct ampdu_info *ampdu) +{ + int i, j; + struct brcms_fifo_info *fifo; + + for (j = 0; j < NUM_FFPLD_FIFO; j++) { + fifo = (ampdu->fifo_tb + j); + fifo->ampdu_pld_size = 0; + for (i = 0; i <= FFPLD_MAX_MCS; i++) + fifo->mcs2ampdu_table[i] = 255; + fifo->dmaxferrate = 0; + fifo->accum_txampdu = 0; + fifo->prev_txfunfl = 0; + fifo->accum_txfunfl = 0; + + } +} struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc) { @@ -267,21 +320,35 @@ static void brcms_c_scb_ampdu_update_config_all(struct ampdu_info *ampdu) brcms_c_scb_ampdu_update_config(ampdu, ampdu->wlc->pub->global_scb); } -static void brcms_c_ffpld_init(struct ampdu_info *ampdu) +static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) { - int i, j; - struct brcms_fifo_info *fifo; + int i; + u32 phy_rate, dma_rate, tmp; + u8 max_mpdu; + struct brcms_fifo_info *fifo = (ampdu->fifo_tb + f); - for (j = 0; j < NUM_FFPLD_FIFO; j++) { - fifo = (ampdu->fifo_tb + j); - fifo->ampdu_pld_size = 0; - for (i = 0; i <= FFPLD_MAX_MCS; i++) - fifo->mcs2ampdu_table[i] = 255; - fifo->dmaxferrate = 0; - fifo->accum_txampdu = 0; - fifo->prev_txfunfl = 0; - fifo->accum_txfunfl = 0; + /* recompute the dma rate */ + /* note : we divide/multiply by 100 to avoid integer overflows */ + max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], + AMPDU_NUM_MPDU_LEGACY); + phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); + dma_rate = + (((phy_rate / 100) * + (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) + / (max_mpdu * FFPLD_MPDU_SIZE)) * 100; + fifo->dmaxferrate = dma_rate; + /* fill up the mcs2ampdu table; do not recalc the last mcs */ + dma_rate = dma_rate >> 7; + for (i = 0; i < FFPLD_MAX_MCS; i++) { + /* shifting to keep it within integer range */ + phy_rate = MCS_RATE(i, true, false) >> 7; + if (phy_rate > dma_rate) { + tmp = ((fifo->ampdu_pld_size * phy_rate) / + ((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1; + tmp = min_t(u32, tmp, 255); + fifo->mcs2ampdu_table[i] = (u8) tmp; + } } } @@ -410,38 +477,6 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) return 0; } -static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) -{ - int i; - u32 phy_rate, dma_rate, tmp; - u8 max_mpdu; - struct brcms_fifo_info *fifo = (ampdu->fifo_tb + f); - - /* recompute the dma rate */ - /* note : we divide/multiply by 100 to avoid integer overflows */ - max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], - AMPDU_NUM_MPDU_LEGACY); - phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); - dma_rate = - (((phy_rate / 100) * - (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) - / (max_mpdu * FFPLD_MPDU_SIZE)) * 100; - fifo->dmaxferrate = dma_rate; - - /* fill up the mcs2ampdu table; do not recalc the last mcs */ - dma_rate = dma_rate >> 7; - for (i = 0; i < FFPLD_MAX_MCS; i++) { - /* shifting to keep it within integer range */ - phy_rate = MCS_RATE(i, true, false) >> 7; - if (phy_rate > dma_rate) { - tmp = ((fifo->ampdu_pld_size * phy_rate) / - ((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1; - tmp = min_t(u32, tmp, 255); - fifo->mcs2ampdu_table[i] = (u8) tmp; - } - } -} - void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, u8 ba_wsize, /* negotiated ba window size (in pdu) */ @@ -846,61 +881,6 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, return err; } -void -brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, - struct sk_buff *p, struct tx_status *txs) -{ - struct scb_ampdu *scb_ampdu; - struct brcms_c_info *wlc = ampdu->wlc; - struct scb_ampdu_tid_ini *ini; - u32 s1 = 0, s2 = 0; - struct ieee80211_tx_info *tx_info; - - tx_info = IEEE80211_SKB_CB(p); - - /* BMAC_NOTE: For the split driver, second level txstatus comes later - * So if the ACK was received then wait for the second level else just - * call the first one - */ - if (txs->status & TX_STATUS_ACK_RCV) { - u8 status_delay = 0; - - /* wait till the next 8 bytes of txstatus is available */ - while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { - udelay(1); - status_delay++; - if (status_delay > 10) - return; /* error condition */ - } - - s2 = R_REG(&wlc->regs->frmtxstatus2); - } - - if (likely(scb)) { - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); - ini = SCB_AMPDU_INI(scb_ampdu, p->priority); - brcms_c_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); - } else { - /* loop through all pkts and free */ - u8 queue = txs->frameid & TXFID_QUEUE_MASK; - struct d11txh *txh; - u16 mcl; - while (p) { - tx_info = IEEE80211_SKB_CB(p); - txh = (struct d11txh *) p->data; - mcl = le16_to_cpu(txh->MacTxControlLow); - brcmu_pkt_buf_free_skb(p); - /* break out if last packet of ampdu */ - if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == - TXC_AMPDU_LAST) - break; - p = GETNEXTTXP(wlc, queue); - } - brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); - } - brcms_c_ampdu_txflowcontrol(wlc, scb_ampdu, ini); -} - static void brcms_c_ampdu_rate_status(struct brcms_c_info *wlc, struct ieee80211_tx_info *tx_info, @@ -916,8 +896,6 @@ brcms_c_ampdu_rate_status(struct brcms_c_info *wlc, } } -#define SHORTNAME "AMPDU status" - static void brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p, struct tx_status *txs, @@ -1125,56 +1103,59 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); } -static int brcms_c_ampdu_set(struct ampdu_info *ampdu, bool on) +void +brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, + struct sk_buff *p, struct tx_status *txs) { + struct scb_ampdu *scb_ampdu; struct brcms_c_info *wlc = ampdu->wlc; + struct scb_ampdu_tid_ini *ini; + u32 s1 = 0, s2 = 0; + struct ieee80211_tx_info *tx_info; - wlc->pub->_ampdu = false; + tx_info = IEEE80211_SKB_CB(p); - if (on) { - if (!N_ENAB(wlc->pub)) { - wiphy_err(ampdu->wlc->wiphy, "wl%d: driver not " - "nmode enabled\n", wlc->pub->unit); - return -ENOTSUPP; + /* BMAC_NOTE: For the split driver, second level txstatus comes later + * So if the ACK was received then wait for the second level else just + * call the first one + */ + if (txs->status & TX_STATUS_ACK_RCV) { + u8 status_delay = 0; + + /* wait till the next 8 bytes of txstatus is available */ + while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { + udelay(1); + status_delay++; + if (status_delay > 10) + return; /* error condition */ } - if (!brcms_c_ampdu_cap(ampdu)) { - wiphy_err(ampdu->wlc->wiphy, "wl%d: device not " - "ampdu capable\n", wlc->pub->unit); - return -ENOTSUPP; - } - wlc->pub->_ampdu = on; + + s2 = R_REG(&wlc->regs->frmtxstatus2); } - return 0; -} - -static bool brcms_c_ampdu_cap(struct ampdu_info *ampdu) -{ - if (BRCMS_PHY_11N_CAP(ampdu->wlc->band)) - return true; - else - return false; -} - -static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) -{ - u32 rate, mcs; - - for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) { - /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */ - /* 20MHz, No SGI */ - rate = MCS_RATE(mcs, false, false); - ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3; - /* 40 MHz, No SGI */ - rate = MCS_RATE(mcs, true, false); - ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3; - /* 20MHz, SGI */ - rate = MCS_RATE(mcs, false, true); - ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3; - /* 40 MHz, SGI */ - rate = MCS_RATE(mcs, true, true); - ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3; + if (likely(scb)) { + scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + ini = SCB_AMPDU_INI(scb_ampdu, p->priority); + brcms_c_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); + } else { + /* loop through all pkts and free */ + u8 queue = txs->frameid & TXFID_QUEUE_MASK; + struct d11txh *txh; + u16 mcl; + while (p) { + tx_info = IEEE80211_SKB_CB(p); + txh = (struct d11txh *) p->data; + mcl = le16_to_cpu(txh->MacTxControlLow); + brcmu_pkt_buf_free_skb(p); + /* break out if last packet of ampdu */ + if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == + TXC_AMPDU_LAST) + break; + p = GETNEXTTXP(wlc, queue); + } + brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); } + brcms_c_ampdu_txflowcontrol(wlc, scb_ampdu, ini); } void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc) From d5adafb049d826a35a9403d1567b3d8e5f14e221 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:54 +0200 Subject: [PATCH 0842/1519] staging: brcm80211: removed static function declarations in antsel.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/antsel.c | 228 ++++++++++---------- 1 file changed, 110 insertions(+), 118 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index 23e04537995..9dfc2efaf30 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -49,15 +49,6 @@ #define ANT_SELCFG_NUM_2x4 4 #define ANT_SELCFG_DEF_2x4 0x02 /* default antenna configuration */ -/* static functions */ -static int brcms_c_antsel_cfgupd(struct antsel_info *asi, - struct brcms_antselcfg *antsel); -static u8 brcms_c_antsel_id2antcfg(struct antsel_info *asi, u8 id); -static u16 brcms_c_antsel_antcfg2antsel(struct antsel_info *asi, u8 ant_cfg); -static void brcms_c_antsel_init_cfg(struct antsel_info *asi, - struct brcms_antselcfg *antsel, - bool auto_sel); - const u16 mimo_2x4_div_antselpat_tbl[] = { 0, 0, 0x9, 0xa, /* ant0: 0 ant1: 2,3 */ 0, 0, 0x5, 0x6, /* ant0: 1 ant1: 2,3 */ @@ -82,6 +73,38 @@ const u8 mimo_2x3_div_antselid_tbl[16] = { 0, 0, 0, 0, 0, 0, 0, 0 /* pat to antselid */ }; +/* boardlevel antenna selection: init antenna selection structure */ +static void +brcms_c_antsel_init_cfg(struct antsel_info *asi, struct brcms_antselcfg *antsel, + bool auto_sel) +{ + if (asi->antsel_type == ANTSEL_2x3) { + u8 antcfg_def = ANT_SELCFG_DEF_2x3 | + ((asi->antsel_avail && auto_sel) ? ANT_SELCFG_AUTO : 0); + antsel->ant_config[ANT_SELCFG_TX_DEF] = antcfg_def; + antsel->ant_config[ANT_SELCFG_TX_UNICAST] = antcfg_def; + antsel->ant_config[ANT_SELCFG_RX_DEF] = antcfg_def; + antsel->ant_config[ANT_SELCFG_RX_UNICAST] = antcfg_def; + antsel->num_antcfg = ANT_SELCFG_NUM_2x3; + + } else if (asi->antsel_type == ANTSEL_2x4) { + + antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x4; + antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x4; + antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x4; + antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x4; + antsel->num_antcfg = ANT_SELCFG_NUM_2x4; + + } else { /* no antenna selection available */ + + antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x2; + antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x2; + antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x2; + antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x2; + antsel->num_antcfg = 0; + } +} + struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) { struct antsel_info *asi; @@ -150,115 +173,6 @@ void brcms_c_antsel_detach(struct antsel_info *asi) kfree(asi); } -void brcms_c_antsel_init(struct antsel_info *asi) -{ - if ((asi->antsel_type == ANTSEL_2x3) || - (asi->antsel_type == ANTSEL_2x4)) - brcms_c_antsel_cfgupd(asi, &asi->antcfg_11n); -} - -/* boardlevel antenna selection: init antenna selection structure */ -static void -brcms_c_antsel_init_cfg(struct antsel_info *asi, struct brcms_antselcfg *antsel, - bool auto_sel) -{ - if (asi->antsel_type == ANTSEL_2x3) { - u8 antcfg_def = ANT_SELCFG_DEF_2x3 | - ((asi->antsel_avail && auto_sel) ? ANT_SELCFG_AUTO : 0); - antsel->ant_config[ANT_SELCFG_TX_DEF] = antcfg_def; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = antcfg_def; - antsel->ant_config[ANT_SELCFG_RX_DEF] = antcfg_def; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = antcfg_def; - antsel->num_antcfg = ANT_SELCFG_NUM_2x3; - - } else if (asi->antsel_type == ANTSEL_2x4) { - - antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x4; - antsel->num_antcfg = ANT_SELCFG_NUM_2x4; - - } else { /* no antenna selection available */ - - antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x2; - antsel->num_antcfg = 0; - } -} - -void -brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef, bool sel, - u8 antselid, u8 fbantselid, u8 *antcfg, - u8 *fbantcfg) -{ - u8 ant; - - /* if use default, assign it and return */ - if (usedef) { - *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_DEF]; - *fbantcfg = *antcfg; - return; - } - - if (!sel) { - *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - *fbantcfg = *antcfg; - - } else { - ant = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - if ((ant & ANT_SELCFG_AUTO) == ANT_SELCFG_AUTO) { - *antcfg = brcms_c_antsel_id2antcfg(asi, antselid); - *fbantcfg = brcms_c_antsel_id2antcfg(asi, fbantselid); - } else { - *antcfg = - asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - *fbantcfg = *antcfg; - } - } - return; -} - -/* boardlevel antenna selection: convert mimo_antsel (ucode interface) to id */ -u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel) -{ - u8 antselid = 0; - - if (asi->antsel_type == ANTSEL_2x4) { - /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ - antselid = mimo_2x4_div_antselid_tbl[(antsel & 0xf)]; - return antselid; - - } else if (asi->antsel_type == ANTSEL_2x3) { - /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ - antselid = mimo_2x3_div_antselid_tbl[(antsel & 0xf)]; - return antselid; - } - - return antselid; -} - -/* boardlevel antenna selection: convert id to ant_cfg */ -static u8 brcms_c_antsel_id2antcfg(struct antsel_info *asi, u8 id) -{ - u8 antcfg = ANT_SELCFG_DEF_2x2; - - if (asi->antsel_type == ANTSEL_2x4) { - /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ - antcfg = (((id & 0x2) << 3) | ((id & 0x1) + 2)); - return antcfg; - - } else if (asi->antsel_type == ANTSEL_2x3) { - /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ - antcfg = (((id & 0x02) << 4) | ((id & 0x1) + 1)); - return antcfg; - } - - return antcfg; -} - /* * boardlevel antenna selection: * convert ant_cfg to mimo_antsel (ucode interface) @@ -316,3 +230,81 @@ static int brcms_c_antsel_cfgupd(struct antsel_info *asi, return 0; } + +void brcms_c_antsel_init(struct antsel_info *asi) +{ + if ((asi->antsel_type == ANTSEL_2x3) || + (asi->antsel_type == ANTSEL_2x4)) + brcms_c_antsel_cfgupd(asi, &asi->antcfg_11n); +} + +/* boardlevel antenna selection: convert id to ant_cfg */ +static u8 brcms_c_antsel_id2antcfg(struct antsel_info *asi, u8 id) +{ + u8 antcfg = ANT_SELCFG_DEF_2x2; + + if (asi->antsel_type == ANTSEL_2x4) { + /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ + antcfg = (((id & 0x2) << 3) | ((id & 0x1) + 2)); + return antcfg; + + } else if (asi->antsel_type == ANTSEL_2x3) { + /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ + antcfg = (((id & 0x02) << 4) | ((id & 0x1) + 1)); + return antcfg; + } + + return antcfg; +} + +void +brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef, bool sel, + u8 antselid, u8 fbantselid, u8 *antcfg, + u8 *fbantcfg) +{ + u8 ant; + + /* if use default, assign it and return */ + if (usedef) { + *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_DEF]; + *fbantcfg = *antcfg; + return; + } + + if (!sel) { + *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; + *fbantcfg = *antcfg; + + } else { + ant = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; + if ((ant & ANT_SELCFG_AUTO) == ANT_SELCFG_AUTO) { + *antcfg = brcms_c_antsel_id2antcfg(asi, antselid); + *fbantcfg = brcms_c_antsel_id2antcfg(asi, fbantselid); + } else { + *antcfg = + asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; + *fbantcfg = *antcfg; + } + } + return; +} + +/* boardlevel antenna selection: convert mimo_antsel (ucode interface) to id */ +u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel) +{ + u8 antselid = 0; + + if (asi->antsel_type == ANTSEL_2x4) { + /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ + antselid = mimo_2x4_div_antselid_tbl[(antsel & 0xf)]; + return antselid; + + } else if (asi->antsel_type == ANTSEL_2x3) { + /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ + antselid = mimo_2x3_div_antselid_tbl[(antsel & 0xf)]; + return antselid; + } + + return antselid; +} + From 0390bf7accc43d15d5bd6ddb48924a7003388e52 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:55 +0200 Subject: [PATCH 0843/1519] staging: brcm80211: removed static function declarations in channel.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 807 +++++++++---------- 1 file changed, 379 insertions(+), 428 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 89d8fa7330b..6c5272e1bd9 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -29,6 +29,53 @@ brcms_c_valid_channel20_in_band((wlc)->cmi, bandunit, val) #define VALID_CHANNEL20(wlc, val) brcms_c_valid_channel20((wlc)->cmi, val) +/* QDB() macro takes a dB value and converts to a quarter dB value */ +#define QDB(n) ((n) * BRCMS_TXPWR_DB_FACTOR) + +#define LOCALE_CHAN_01_11 (1<<0) +#define LOCALE_CHAN_12_13 (1<<1) +#define LOCALE_CHAN_14 (1<<2) +#define LOCALE_SET_5G_LOW_JP1 (1<<3) /* 34-48, step 2 */ +#define LOCALE_SET_5G_LOW_JP2 (1<<4) /* 34-46, step 4 */ +#define LOCALE_SET_5G_LOW1 (1<<5) /* 36-48, step 4 */ +#define LOCALE_SET_5G_LOW2 (1<<6) /* 52 */ +#define LOCALE_SET_5G_LOW3 (1<<7) /* 56-64, step 4 */ +#define LOCALE_SET_5G_MID1 (1<<8) /* 100-116, step 4 */ +#define LOCALE_SET_5G_MID2 (1<<9) /* 120-124, step 4 */ +#define LOCALE_SET_5G_MID3 (1<<10) /* 128 */ +#define LOCALE_SET_5G_HIGH1 (1<<11) /* 132-140, step 4 */ +#define LOCALE_SET_5G_HIGH2 (1<<12) /* 149-161, step 4 */ +#define LOCALE_SET_5G_HIGH3 (1<<13) /* 165 */ +#define LOCALE_CHAN_52_140_ALL (1<<14) +#define LOCALE_SET_5G_HIGH4 (1<<15) /* 184-216 */ + +#define LOCALE_CHAN_36_64 (LOCALE_SET_5G_LOW1 | \ + LOCALE_SET_5G_LOW2 | \ + LOCALE_SET_5G_LOW3) +#define LOCALE_CHAN_52_64 (LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) +#define LOCALE_CHAN_100_124 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2) +#define LOCALE_CHAN_100_140 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2 | \ + LOCALE_SET_5G_MID3 | LOCALE_SET_5G_HIGH1) +#define LOCALE_CHAN_149_165 (LOCALE_SET_5G_HIGH2 | LOCALE_SET_5G_HIGH3) +#define LOCALE_CHAN_184_216 LOCALE_SET_5G_HIGH4 + +#define LOCALE_CHAN_01_14 (LOCALE_CHAN_01_11 | \ + LOCALE_CHAN_12_13 | \ + LOCALE_CHAN_14) + +#define LOCALE_RADAR_SET_NONE 0 +#define LOCALE_RADAR_SET_1 1 + +#define LOCALE_RESTRICTED_NONE 0 +#define LOCALE_RESTRICTED_SET_2G_SHORT 1 +#define LOCALE_RESTRICTED_CHAN_165 2 +#define LOCALE_CHAN_ALL_5G 3 +#define LOCALE_RESTRICTED_JAPAN_LEGACY 4 +#define LOCALE_RESTRICTED_11D_2G 5 +#define LOCALE_RESTRICTED_11D_5G 6 +#define LOCALE_RESTRICTED_LOW_HI 7 +#define LOCALE_RESTRICTED_12_13_14 8 + struct brcms_cm_band { /* struct locale_info flags */ u8 locale_flags; @@ -57,58 +104,6 @@ struct brcms_cm_info { struct brcms_chanvec quiet_channels; }; -static int brcms_c_channels_init(struct brcms_cm_info *wlc_cm, - const struct country_info *country); -static void brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, uint regrev, - const struct country_info *country); -static int brcms_c_set_countrycode(struct brcms_cm_info *wlc_cm, - const char *ccode); -static int brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, int regrev); -static int brcms_c_country_aggregate_map(struct brcms_cm_info *wlc_cm, - const char *ccode, - char *mapped_ccode, uint *mapped_regrev); - -static const struct country_info * -brcms_c_country_lookup_direct(const char *ccode, uint regrev); - -static const struct country_info * -brcms_c_countrycode_map(struct brcms_cm_info *wlc_cm, - const char *ccode, char *mapped_ccode, - uint *mapped_regrev); - -static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm); -static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm); -static bool brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, - u16 chspec); -static bool brcms_c_valid_channel20_db(struct brcms_cm_info *wlc_cm, uint val); -static bool brcms_c_valid_channel20_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit, uint val); -static bool brcms_c_valid_channel20(struct brcms_cm_info *wlc_cm, uint val); - -static const struct country_info * -brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode); - -static void brcms_c_locale_get_channels(const struct locale_info *locale, - struct brcms_chanvec *valid_channels); -static const struct locale_info *brcms_c_get_locale_2g(u8 locale_idx); -static const struct locale_info *brcms_c_get_locale_5g(u8 locale_idx); -static bool brcms_c_japan(struct brcms_c_info *wlc); -static bool brcms_c_japan_ccode(const char *ccode); -static void brcms_c_channel_min_txpower_limits_with_local_constraint( - struct brcms_cm_info *wlc_cm, struct txpwr_limits *txpwr, - u8 local_constraint_qdbm); -static void brcms_c_locale_add_channels(struct brcms_chanvec *target, - const struct brcms_chanvec *channels); -static const struct locale_mimo_info *brcms_c_get_mimo_2g(u8 locale_idx); -static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx); - -/* QDB() macro takes a dB value and converts to a quarter dB value */ -#define QDB(n) ((n) * BRCMS_TXPWR_DB_FACTOR) - /* Regulatory Matrix Spreadsheet (CLM) MIMO v3.7.9 */ /* @@ -200,50 +195,6 @@ static const struct brcms_chanvec restricted_set_12_13_14 = { 0x00, 0x00, 0x00, 0x00} }; -#define LOCALE_CHAN_01_11 (1<<0) -#define LOCALE_CHAN_12_13 (1<<1) -#define LOCALE_CHAN_14 (1<<2) -#define LOCALE_SET_5G_LOW_JP1 (1<<3) /* 34-48, step 2 */ -#define LOCALE_SET_5G_LOW_JP2 (1<<4) /* 34-46, step 4 */ -#define LOCALE_SET_5G_LOW1 (1<<5) /* 36-48, step 4 */ -#define LOCALE_SET_5G_LOW2 (1<<6) /* 52 */ -#define LOCALE_SET_5G_LOW3 (1<<7) /* 56-64, step 4 */ -#define LOCALE_SET_5G_MID1 (1<<8) /* 100-116, step 4 */ -#define LOCALE_SET_5G_MID2 (1<<9) /* 120-124, step 4 */ -#define LOCALE_SET_5G_MID3 (1<<10) /* 128 */ -#define LOCALE_SET_5G_HIGH1 (1<<11) /* 132-140, step 4 */ -#define LOCALE_SET_5G_HIGH2 (1<<12) /* 149-161, step 4 */ -#define LOCALE_SET_5G_HIGH3 (1<<13) /* 165 */ -#define LOCALE_CHAN_52_140_ALL (1<<14) -#define LOCALE_SET_5G_HIGH4 (1<<15) /* 184-216 */ - -#define LOCALE_CHAN_36_64 (LOCALE_SET_5G_LOW1 | \ - LOCALE_SET_5G_LOW2 | \ - LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_52_64 (LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_100_124 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2) -#define LOCALE_CHAN_100_140 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2 | \ - LOCALE_SET_5G_MID3 | LOCALE_SET_5G_HIGH1) -#define LOCALE_CHAN_149_165 (LOCALE_SET_5G_HIGH2 | LOCALE_SET_5G_HIGH3) -#define LOCALE_CHAN_184_216 LOCALE_SET_5G_HIGH4 - -#define LOCALE_CHAN_01_14 (LOCALE_CHAN_01_11 | \ - LOCALE_CHAN_12_13 | \ - LOCALE_CHAN_14) - -#define LOCALE_RADAR_SET_NONE 0 -#define LOCALE_RADAR_SET_1 1 - -#define LOCALE_RESTRICTED_NONE 0 -#define LOCALE_RESTRICTED_SET_2G_SHORT 1 -#define LOCALE_RESTRICTED_CHAN_165 2 -#define LOCALE_CHAN_ALL_5G 3 -#define LOCALE_RESTRICTED_JAPAN_LEGACY 4 -#define LOCALE_RESTRICTED_11D_2G 5 -#define LOCALE_RESTRICTED_11D_5G 6 -#define LOCALE_RESTRICTED_LOW_HI 7 -#define LOCALE_RESTRICTED_12_13_14 8 - /* global memory to provide working buffer for expanded locale */ static const struct brcms_chanvec *g_table_radar_set[] = { @@ -612,182 +563,38 @@ static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx) return g_mimo_5g_table[locale_idx]; } -struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) -{ - struct brcms_cm_info *wlc_cm; - char country_abbrev[BRCM_CNTRY_BUF_SZ]; - const struct country_info *country; - struct brcms_pub *pub = wlc->pub; - char *ccode; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - wlc_cm = kzalloc(sizeof(struct brcms_cm_info), GFP_ATOMIC); - if (wlc_cm == NULL) { - wiphy_err(wlc->wiphy, "wl%d: %s: out of memory", pub->unit, - __func__); - return NULL; - } - wlc_cm->pub = pub; - wlc_cm->wlc = wlc; - wlc->cmi = wlc_cm; - - /* store the country code for passing up as a regulatory hint */ - ccode = getvar(wlc->pub->vars, "ccode"); - if (ccode) - strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - - /* - * internal country information which must match - * regulatory constraints in firmware - */ - memset(country_abbrev, 0, BRCM_CNTRY_BUF_SZ); - strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1); - country = brcms_c_country_lookup(wlc, country_abbrev); - - /* save default country for exiting 11d regulatory mode */ - strncpy(wlc->country_default, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); - - /* initialize autocountry_default to driver default */ - strncpy(wlc->autocountry_default, "X2", BRCM_CNTRY_BUF_SZ - 1); - - brcms_c_set_countrycode(wlc_cm, country_abbrev); - - return wlc_cm; -} - -void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm) -{ - kfree(wlc_cm); -} - -u8 -brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit) -{ - return wlc_cm->bandstate[bandunit].locale_flags; -} - -/* - * set the driver's current country and regulatory information using - * a country code as the source. Lookup built in country information - * found with the country code. - */ static int -brcms_c_set_countrycode(struct brcms_cm_info *wlc_cm, const char *ccode) +brcms_c_country_aggregate_map(struct brcms_cm_info *wlc_cm, const char *ccode, + char *mapped_ccode, uint *mapped_regrev) { - char country_abbrev[BRCM_CNTRY_BUF_SZ]; - strncpy(country_abbrev, ccode, BRCM_CNTRY_BUF_SZ); - return brcms_c_set_countrycode_rev(wlc_cm, country_abbrev, ccode, -1); + return false; } -static int -brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, int regrev) -{ - const struct country_info *country; - char mapped_ccode[BRCM_CNTRY_BUF_SZ]; - uint mapped_regrev; - - /* if regrev is -1, lookup the mapped country code, - * otherwise use the ccode and regrev directly - */ - if (regrev == -1) { - /* - * map the country code to a built-in country - * code, regrev, and country_info - */ - country = - brcms_c_countrycode_map(wlc_cm, ccode, mapped_ccode, - &mapped_regrev); - } else { - /* find the matching built-in country definition */ - country = brcms_c_country_lookup_direct(ccode, regrev); - strncpy(mapped_ccode, ccode, BRCM_CNTRY_BUF_SZ); - mapped_regrev = regrev; - } - - if (country == NULL) - return -EINVAL; - - /* set the driver state for the country */ - brcms_c_set_country_common(wlc_cm, country_abbrev, mapped_ccode, - mapped_regrev, country); - - return 0; -} - -/* - * set the driver's current country and regulatory information - * using a country code as the source. Look up built in country - * information found with the country code. - */ -static void -brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, uint regrev, - const struct country_info *country) -{ - const struct locale_mimo_info *li_mimo; - const struct locale_info *locale; - struct brcms_c_info *wlc = wlc_cm->wlc; - char prev_country_abbrev[BRCM_CNTRY_BUF_SZ]; - - /* save current country state */ - wlc_cm->country = country; - - memset(&prev_country_abbrev, 0, BRCM_CNTRY_BUF_SZ); - strncpy(prev_country_abbrev, wlc_cm->country_abbrev, - BRCM_CNTRY_BUF_SZ - 1); - - strncpy(wlc_cm->country_abbrev, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); - strncpy(wlc_cm->ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - wlc_cm->regrev = regrev; - - /* disable/restore nmode based on country regulations */ - li_mimo = brcms_c_get_mimo_2g(country->locale_mimo_2G); - if (li_mimo && (li_mimo->flags & BRCMS_NO_MIMO)) { - brcms_c_set_nmode(wlc, OFF); - wlc->stf->no_cddstbc = true; - } else { - wlc->stf->no_cddstbc = false; - if (N_ENAB(wlc->pub) != wlc->protection->nmode_user) - brcms_c_set_nmode(wlc, wlc->protection->nmode_user); - } - - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); - /* set or restore gmode as required by regulatory */ - locale = brcms_c_get_locale_2g(country->locale_2G); - if (locale && (locale->flags & BRCMS_NO_OFDM)) - brcms_c_set_gmode(wlc, GMODE_LEGACY_B, false); - else - brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); - - brcms_c_channels_init(wlc_cm, country); - - return; -} - -/* Lookup a country info structure from a null terminated country code - * The lookup is case sensitive. +/* Lookup a country info structure from a null terminated country + * abbreviation and regrev directly with no translation. */ static const struct country_info * -brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode) +brcms_c_country_lookup_direct(const char *ccode, uint regrev) { - const struct country_info *country; - char mapped_ccode[BRCM_CNTRY_BUF_SZ]; - uint mapped_regrev; + uint size, i; + + /* Should just return 0 for single locale driver. */ + /* Keep it this way in case we add more locales. (for now anyway) */ /* - * map the country code to a built-in country code, regrev, and - * country_info struct + * all other country def arrays are for regrev == 0, so if + * regrev is non-zero, fail */ - country = brcms_c_countrycode_map(wlc->cmi, ccode, mapped_ccode, - &mapped_regrev); + if (regrev > 0) + return NULL; - return country; + /* find matched table entry from country code */ + size = ARRAY_SIZE(cntry_locales); + for (i = 0; i < size; i++) { + if (strcmp(ccode, cntry_locales[i].abbrev) == 0) + return &cntry_locales[i].country; + } + return NULL; } static const struct country_info * @@ -838,147 +645,24 @@ brcms_c_countrycode_map(struct brcms_cm_info *wlc_cm, const char *ccode, return country; } -static int -brcms_c_country_aggregate_map(struct brcms_cm_info *wlc_cm, const char *ccode, - char *mapped_ccode, uint *mapped_regrev) -{ - return false; -} - -/* Lookup a country info structure from a null terminated country - * abbreviation and regrev directly with no translation. +/* Lookup a country info structure from a null terminated country code + * The lookup is case sensitive. */ static const struct country_info * -brcms_c_country_lookup_direct(const char *ccode, uint regrev) +brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode) { - uint size, i; - - /* Should just return 0 for single locale driver. */ - /* Keep it this way in case we add more locales. (for now anyway) */ + const struct country_info *country; + char mapped_ccode[BRCM_CNTRY_BUF_SZ]; + uint mapped_regrev; /* - * all other country def arrays are for regrev == 0, so if - * regrev is non-zero, fail + * map the country code to a built-in country code, regrev, and + * country_info struct */ - if (regrev > 0) - return NULL; + country = brcms_c_countrycode_map(wlc->cmi, ccode, mapped_ccode, + &mapped_regrev); - /* find matched table entry from country code */ - size = ARRAY_SIZE(cntry_locales); - for (i = 0; i < size; i++) { - if (strcmp(ccode, cntry_locales[i].abbrev) == 0) - return &cntry_locales[i].country; - } - return NULL; -} - -static int -brcms_c_channels_init(struct brcms_cm_info *wlc_cm, - const struct country_info *country) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint i, j; - struct brcms_band *band; - const struct locale_info *li; - struct brcms_chanvec sup_chan; - const struct locale_mimo_info *li_mimo; - - band = wlc->band; - for (i = 0; i < NBANDS(wlc); - i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { - - li = BAND_5G(band->bandtype) ? - brcms_c_get_locale_5g(country->locale_5G) : - brcms_c_get_locale_2g(country->locale_2G); - wlc_cm->bandstate[band->bandunit].locale_flags = li->flags; - li_mimo = BAND_5G(band->bandtype) ? - brcms_c_get_mimo_5g(country->locale_mimo_5G) : - brcms_c_get_mimo_2g(country->locale_mimo_2G); - - /* merge the mimo non-mimo locale flags */ - wlc_cm->bandstate[band->bandunit].locale_flags |= - li_mimo->flags; - - wlc_cm->bandstate[band->bandunit].restricted_channels = - g_table_restricted_chan[li->restricted_channels]; - wlc_cm->bandstate[band->bandunit].radar_channels = - g_table_radar_set[li->radar_channels]; - - /* - * set the channel availability, masking out the channels - * that may not be supported on this phy. - */ - wlc_phy_chanspec_band_validch(band->pi, band->bandtype, - &sup_chan); - brcms_c_locale_get_channels(li, - &wlc_cm->bandstate[band->bandunit]. - valid_channels); - for (j = 0; j < sizeof(struct brcms_chanvec); j++) - wlc_cm->bandstate[band->bandunit].valid_channels. - vec[j] &= sup_chan.vec[j]; - } - - brcms_c_quiet_channels_reset(wlc_cm); - brcms_c_channels_commit(wlc_cm); - - return 0; -} - -/* Update the radio state (enable/disable) and tx power targets - * based on a new set of channel/regulatory information - */ -static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint chan; - struct txpwr_limits txpwr; - - /* search for the existence of any valid channel */ - for (chan = 0; chan < MAXCHANNEL; chan++) { - if (VALID_CHANNEL20_DB(wlc, chan)) - break; - } - if (chan == MAXCHANNEL) - chan = INVCHANNEL; - - /* - * based on the channel search above, set or - * clear WL_RADIO_COUNTRY_DISABLE. - */ - if (chan == INVCHANNEL) { - /* - * country/locale with no valid channels, set - * the radio disable bit - */ - mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); - wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" " - "nbands %d bandlocked %d\n", wlc->pub->unit, - __func__, wlc_cm->country_abbrev, NBANDS(wlc), - wlc->bandlocked); - } else if (mboolisset(wlc->pub->radio_disabled, - WL_RADIO_COUNTRY_DISABLE)) { - /* - * country/locale with valid channel, clear - * the radio disable bit - */ - mboolclr(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); - } - - /* - * Now that the country abbreviation is set, if the radio supports 2G, - * then set channel 14 restrictions based on the new locale. - */ - if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) - wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, - brcms_c_japan(wlc) ? true : - false); - - if (wlc->pub->up && chan != INVCHANNEL) { - brcms_c_channel_reg_limits(wlc_cm, wlc->chanspec, &txpwr); - brcms_c_channel_min_txpower_limits_with_local_constraint(wlc_cm, - &txpwr, BRCMS_TXPWR_MAX); - wlc_phy_txpower_limit_set(wlc->band->pi, &txpwr, wlc->chanspec); - } + return country; } /* @@ -1006,15 +690,22 @@ static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) } } -static bool -brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) +/* Is the channel valid for the current locale and current band? */ +static bool brcms_c_valid_channel20(struct brcms_cm_info *wlc_cm, uint val) { - return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? - (isset(wlc_cm->quiet_channels.vec, - LOWER_20_SB(CHSPEC_CHANNEL(chspec))) || - isset(wlc_cm->quiet_channels.vec, - UPPER_20_SB(CHSPEC_CHANNEL(chspec)))) : - isset(wlc_cm->quiet_channels.vec, CHSPEC_CHANNEL(chspec)); + struct brcms_c_info *wlc = wlc_cm->wlc; + + return ((val < MAXCHANNEL) && + isset(wlc_cm->bandstate[wlc->band->bandunit].valid_channels.vec, + val)); +} + +/* Is the channel valid for the current locale and specified band? */ +static bool brcms_c_valid_channel20_in_band(struct brcms_cm_info *wlc_cm, + uint bandunit, uint val) +{ + return ((val < MAXCHANNEL) + && isset(wlc_cm->bandstate[bandunit].valid_channels.vec, val)); } /* Is the channel valid for the current locale? (but don't consider channels not @@ -1029,22 +720,17 @@ static bool brcms_c_valid_channel20_db(struct brcms_cm_info *wlc_cm, uint val) && VALID_CHANNEL20_IN_BAND(wlc, OTHERBANDUNIT(wlc), val)); } -/* Is the channel valid for the current locale and specified band? */ -static bool brcms_c_valid_channel20_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit, uint val) +/* JP, J1 - J10 are Japan ccodes */ +static bool brcms_c_japan_ccode(const char *ccode) { - return ((val < MAXCHANNEL) - && isset(wlc_cm->bandstate[bandunit].valid_channels.vec, val)); + return (ccode[0] == 'J' && + (ccode[1] == 'P' || (ccode[1] >= '1' && ccode[1] <= '9'))); } -/* Is the channel valid for the current locale and current band? */ -static bool brcms_c_valid_channel20(struct brcms_cm_info *wlc_cm, uint val) +/* Returns true if currently set country is Japan or variant */ +static bool brcms_c_japan(struct brcms_c_info *wlc) { - struct brcms_c_info *wlc = wlc_cm->wlc; - - return ((val < MAXCHANNEL) && - isset(wlc_cm->bandstate[wlc->band->bandunit].valid_channels.vec, - val)); + return brcms_c_japan_ccode(wlc->cmi->country_abbrev); } static void @@ -1122,6 +808,284 @@ brcms_c_channel_min_txpower_limits_with_local_constraint( } +/* Update the radio state (enable/disable) and tx power targets + * based on a new set of channel/regulatory information + */ +static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) +{ + struct brcms_c_info *wlc = wlc_cm->wlc; + uint chan; + struct txpwr_limits txpwr; + + /* search for the existence of any valid channel */ + for (chan = 0; chan < MAXCHANNEL; chan++) { + if (VALID_CHANNEL20_DB(wlc, chan)) + break; + } + if (chan == MAXCHANNEL) + chan = INVCHANNEL; + + /* + * based on the channel search above, set or + * clear WL_RADIO_COUNTRY_DISABLE. + */ + if (chan == INVCHANNEL) { + /* + * country/locale with no valid channels, set + * the radio disable bit + */ + mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); + wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" " + "nbands %d bandlocked %d\n", wlc->pub->unit, + __func__, wlc_cm->country_abbrev, NBANDS(wlc), + wlc->bandlocked); + } else if (mboolisset(wlc->pub->radio_disabled, + WL_RADIO_COUNTRY_DISABLE)) { + /* + * country/locale with valid channel, clear + * the radio disable bit + */ + mboolclr(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); + } + + /* + * Now that the country abbreviation is set, if the radio supports 2G, + * then set channel 14 restrictions based on the new locale. + */ + if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) + wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, + brcms_c_japan(wlc) ? true : + false); + + if (wlc->pub->up && chan != INVCHANNEL) { + brcms_c_channel_reg_limits(wlc_cm, wlc->chanspec, &txpwr); + brcms_c_channel_min_txpower_limits_with_local_constraint(wlc_cm, + &txpwr, BRCMS_TXPWR_MAX); + wlc_phy_txpower_limit_set(wlc->band->pi, &txpwr, wlc->chanspec); + } +} + +static int +brcms_c_channels_init(struct brcms_cm_info *wlc_cm, + const struct country_info *country) +{ + struct brcms_c_info *wlc = wlc_cm->wlc; + uint i, j; + struct brcms_band *band; + const struct locale_info *li; + struct brcms_chanvec sup_chan; + const struct locale_mimo_info *li_mimo; + + band = wlc->band; + for (i = 0; i < NBANDS(wlc); + i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { + + li = BAND_5G(band->bandtype) ? + brcms_c_get_locale_5g(country->locale_5G) : + brcms_c_get_locale_2g(country->locale_2G); + wlc_cm->bandstate[band->bandunit].locale_flags = li->flags; + li_mimo = BAND_5G(band->bandtype) ? + brcms_c_get_mimo_5g(country->locale_mimo_5G) : + brcms_c_get_mimo_2g(country->locale_mimo_2G); + + /* merge the mimo non-mimo locale flags */ + wlc_cm->bandstate[band->bandunit].locale_flags |= + li_mimo->flags; + + wlc_cm->bandstate[band->bandunit].restricted_channels = + g_table_restricted_chan[li->restricted_channels]; + wlc_cm->bandstate[band->bandunit].radar_channels = + g_table_radar_set[li->radar_channels]; + + /* + * set the channel availability, masking out the channels + * that may not be supported on this phy. + */ + wlc_phy_chanspec_band_validch(band->pi, band->bandtype, + &sup_chan); + brcms_c_locale_get_channels(li, + &wlc_cm->bandstate[band->bandunit]. + valid_channels); + for (j = 0; j < sizeof(struct brcms_chanvec); j++) + wlc_cm->bandstate[band->bandunit].valid_channels. + vec[j] &= sup_chan.vec[j]; + } + + brcms_c_quiet_channels_reset(wlc_cm); + brcms_c_channels_commit(wlc_cm); + + return 0; +} + +/* + * set the driver's current country and regulatory information + * using a country code as the source. Look up built in country + * information found with the country code. + */ +static void +brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, + const char *country_abbrev, + const char *ccode, uint regrev, + const struct country_info *country) +{ + const struct locale_mimo_info *li_mimo; + const struct locale_info *locale; + struct brcms_c_info *wlc = wlc_cm->wlc; + char prev_country_abbrev[BRCM_CNTRY_BUF_SZ]; + + /* save current country state */ + wlc_cm->country = country; + + memset(&prev_country_abbrev, 0, BRCM_CNTRY_BUF_SZ); + strncpy(prev_country_abbrev, wlc_cm->country_abbrev, + BRCM_CNTRY_BUF_SZ - 1); + + strncpy(wlc_cm->country_abbrev, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); + strncpy(wlc_cm->ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); + wlc_cm->regrev = regrev; + + /* disable/restore nmode based on country regulations */ + li_mimo = brcms_c_get_mimo_2g(country->locale_mimo_2G); + if (li_mimo && (li_mimo->flags & BRCMS_NO_MIMO)) { + brcms_c_set_nmode(wlc, OFF); + wlc->stf->no_cddstbc = true; + } else { + wlc->stf->no_cddstbc = false; + if (N_ENAB(wlc->pub) != wlc->protection->nmode_user) + brcms_c_set_nmode(wlc, wlc->protection->nmode_user); + } + + brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); + brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); + /* set or restore gmode as required by regulatory */ + locale = brcms_c_get_locale_2g(country->locale_2G); + if (locale && (locale->flags & BRCMS_NO_OFDM)) + brcms_c_set_gmode(wlc, GMODE_LEGACY_B, false); + else + brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); + + brcms_c_channels_init(wlc_cm, country); + + return; +} + +static int +brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, + const char *country_abbrev, + const char *ccode, int regrev) +{ + const struct country_info *country; + char mapped_ccode[BRCM_CNTRY_BUF_SZ]; + uint mapped_regrev; + + /* if regrev is -1, lookup the mapped country code, + * otherwise use the ccode and regrev directly + */ + if (regrev == -1) { + /* + * map the country code to a built-in country + * code, regrev, and country_info + */ + country = + brcms_c_countrycode_map(wlc_cm, ccode, mapped_ccode, + &mapped_regrev); + } else { + /* find the matching built-in country definition */ + country = brcms_c_country_lookup_direct(ccode, regrev); + strncpy(mapped_ccode, ccode, BRCM_CNTRY_BUF_SZ); + mapped_regrev = regrev; + } + + if (country == NULL) + return -EINVAL; + + /* set the driver state for the country */ + brcms_c_set_country_common(wlc_cm, country_abbrev, mapped_ccode, + mapped_regrev, country); + + return 0; +} + +/* + * set the driver's current country and regulatory information using + * a country code as the source. Lookup built in country information + * found with the country code. + */ +static int +brcms_c_set_countrycode(struct brcms_cm_info *wlc_cm, const char *ccode) +{ + char country_abbrev[BRCM_CNTRY_BUF_SZ]; + strncpy(country_abbrev, ccode, BRCM_CNTRY_BUF_SZ); + return brcms_c_set_countrycode_rev(wlc_cm, country_abbrev, ccode, -1); +} + +struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) +{ + struct brcms_cm_info *wlc_cm; + char country_abbrev[BRCM_CNTRY_BUF_SZ]; + const struct country_info *country; + struct brcms_pub *pub = wlc->pub; + char *ccode; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); + + wlc_cm = kzalloc(sizeof(struct brcms_cm_info), GFP_ATOMIC); + if (wlc_cm == NULL) { + wiphy_err(wlc->wiphy, "wl%d: %s: out of memory", pub->unit, + __func__); + return NULL; + } + wlc_cm->pub = pub; + wlc_cm->wlc = wlc; + wlc->cmi = wlc_cm; + + /* store the country code for passing up as a regulatory hint */ + ccode = getvar(wlc->pub->vars, "ccode"); + if (ccode) + strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); + + /* + * internal country information which must match + * regulatory constraints in firmware + */ + memset(country_abbrev, 0, BRCM_CNTRY_BUF_SZ); + strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1); + country = brcms_c_country_lookup(wlc, country_abbrev); + + /* save default country for exiting 11d regulatory mode */ + strncpy(wlc->country_default, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); + + /* initialize autocountry_default to driver default */ + strncpy(wlc->autocountry_default, "X2", BRCM_CNTRY_BUF_SZ - 1); + + brcms_c_set_countrycode(wlc_cm, country_abbrev); + + return wlc_cm; +} + +void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm) +{ + kfree(wlc_cm); +} + +u8 +brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, + uint bandunit) +{ + return wlc_cm->bandstate[bandunit].locale_flags; +} + +static bool +brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) +{ + return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? + (isset(wlc_cm->quiet_channels.vec, + LOWER_20_SB(CHSPEC_CHANNEL(chspec))) || + isset(wlc_cm->quiet_channels.vec, + UPPER_20_SB(CHSPEC_CHANNEL(chspec)))) : + isset(wlc_cm->quiet_channels.vec, CHSPEC_CHANNEL(chspec)); +} + void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, u8 local_constraint_qdbm) @@ -1471,19 +1435,6 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, return; } -/* Returns true if currently set country is Japan or variant */ -static bool brcms_c_japan(struct brcms_c_info *wlc) -{ - return brcms_c_japan_ccode(wlc->cmi->country_abbrev); -} - -/* JP, J1 - J10 are Japan ccodes */ -static bool brcms_c_japan_ccode(const char *ccode) -{ - return (ccode[0] == 'J' && - (ccode[1] == 'P' || (ccode[1] >= '1' && ccode[1] <= '9'))); -} - /* * Validate the chanspec for this locale, for 40MHZ we need to also * check that the sidebands are valid 20MZH channels in this locale From 6bccc65a6aa3f8e485228a86948cb96730549967 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:56 +0200 Subject: [PATCH 0844/1519] staging: brcm80211: removed static function declarations in dma.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 580 +++++++++++------------ 1 file changed, 279 insertions(+), 301 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 42446cda0a0..8859a77e675 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -197,16 +197,34 @@ #define txd64 dregs.d64_u.txd_64 #define rxd64 dregs.d64_u.rxd_64 -/* - * default dma message level (if input msg_level - * pointer is null in dma_attach()) - */ -static uint dma_msg_level; - #define MAXNAMEL 8 /* 8 char names */ #define DI_INFO(dmah) ((dma_info_t *)dmah) +/* descriptor bumping macros */ +/* faster than %, but n must be power of 2 */ +#define XXD(x, n) ((x) & ((n) - 1)) + +#define TXD(x) XXD((x), di->ntxd) +#define RXD(x) XXD((x), di->nrxd) +#define NEXTTXD(i) TXD((i) + 1) +#define PREVTXD(i) TXD((i) - 1) +#define NEXTRXD(i) RXD((i) + 1) +#define PREVRXD(i) RXD((i) - 1) + +#define NTXDACTIVE(h, t) TXD((t) - (h)) +#define NRXDACTIVE(h, t) RXD((t) - (h)) + +/* macros to convert between byte offsets and indexes */ +#define B2I(bytes, type) ((bytes) / sizeof(type)) +#define I2B(index, type) ((index) * sizeof(type)) + +#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */ +#define PCI32ADDR_HIGH_SHIFT 30 /* address[31:30] */ + +#define PCI64ADDR_HIGH 0x80000000 /* address[63] */ +#define PCI64ADDR_HIGH_SHIFT 31 /* address[63] */ + /* * DMA Descriptor * Descriptors are only read by the hardware, never written back. @@ -298,51 +316,202 @@ struct dma_info { bool aligndesc_4k; }; -/* descriptor bumping macros */ -/* faster than %, but n must be power of 2 */ -#define XXD(x, n) ((x) & ((n) - 1)) +/* + * default dma message level (if input msg_level + * pointer is null in dma_attach()) + */ +static uint dma_msg_level; -#define TXD(x) XXD((x), di->ntxd) -#define RXD(x) XXD((x), di->nrxd) -#define NEXTTXD(i) TXD((i) + 1) -#define PREVTXD(i) TXD((i) - 1) -#define NEXTRXD(i) RXD((i) + 1) -#define PREVRXD(i) RXD((i) - 1) +static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) +{ + uint dmactrlflags = di->dma.dmactrlflags; -#define NTXDACTIVE(h, t) TXD((t) - (h)) -#define NRXDACTIVE(h, t) RXD((t) - (h)) + if (di == NULL) { + DMA_ERROR(("%s: _dma_ctrlflags: NULL dma handle\n", di->name)); + return 0; + } -/* macros to convert between byte offsets and indexes */ -#define B2I(bytes, type) ((bytes) / sizeof(type)) -#define I2B(index, type) ((index) * sizeof(type)) + dmactrlflags &= ~mask; + dmactrlflags |= flags; -#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */ -#define PCI32ADDR_HIGH_SHIFT 30 /* address[31:30] */ + /* If trying to enable parity, check if parity is actually supported */ + if (dmactrlflags & DMA_CTRL_PEN) { + u32 control; -#define PCI64ADDR_HIGH 0x80000000 /* address[63] */ -#define PCI64ADDR_HIGH_SHIFT 31 /* address[63] */ + control = R_REG(&di->d64txregs->control); + W_REG(&di->d64txregs->control, + control | D64_XC_PD); + if (R_REG(&di->d64txregs->control) & D64_XC_PD) + /* We *can* disable it so it is supported, + * restore control register + */ + W_REG(&di->d64txregs->control, + control); + else + /* Not supported, don't allow it to be enabled */ + dmactrlflags &= ~DMA_CTRL_PEN; + } -/* Common prototypes */ -static bool _dma_isaddrext(struct dma_info *di); -static bool _dma_descriptor_align(struct dma_info *di); -static bool _dma_alloc(struct dma_info *di, uint direction); -static void _dma_ddtable_init(struct dma_info *di, uint direction, - dma_addr_t pa); -static void _dma_rxenable(struct dma_info *di); -static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall); -static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags); -static u8 dma_align_sizetobits(uint size); + di->dma.dmactrlflags = dmactrlflags; + + return dmactrlflags; +} + +static bool _dma64_addrext(struct dma64regs *dma64regs) +{ + u32 w; + OR_REG(&dma64regs->control, D64_XC_AE); + w = R_REG(&dma64regs->control); + AND_REG(&dma64regs->control, ~D64_XC_AE); + return (w & D64_XC_AE) == D64_XC_AE; +} + +/* + * return true if this dma engine supports DmaExtendedAddrChanges, + * otherwise false + */ +static bool _dma_isaddrext(struct dma_info *di) +{ + /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ + + /* not all tx or rx channel are available */ + if (di->d64txregs != NULL) { + if (!_dma64_addrext(di->d64txregs)) + DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have " + "AE set\n", di->name)); + return true; + } else if (di->d64rxregs != NULL) { + if (!_dma64_addrext(di->d64rxregs)) + DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have " + "AE set\n", di->name)); + return true; + } + + return false; +} + +static bool _dma_descriptor_align(struct dma_info *di) +{ + u32 addrl; + + /* Check to see if the descriptors need to be aligned on 4K/8K or not */ + if (di->d64txregs != NULL) { + W_REG(&di->d64txregs->addrlow, 0xff0); + addrl = R_REG(&di->d64txregs->addrlow); + if (addrl != 0) + return false; + } else if (di->d64rxregs != NULL) { + W_REG(&di->d64rxregs->addrlow, 0xff0); + addrl = R_REG(&di->d64rxregs->addrlow); + if (addrl != 0) + return false; + } + return true; +} + +void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, + uint *alloced, dma_addr_t *pap) +{ + if (align_bits) { + u16 align = (1 << align_bits); + if (!IS_ALIGNED(PAGE_SIZE, align)) + size += align; + *alloced = size; + } + return pci_alloc_consistent(pdev, size, pap); +} + +static +u8 dma_align_sizetobits(uint size) +{ + u8 bitpos = 0; + while (size >>= 1) + bitpos++; + return bitpos; +} + +/* This function ensures that the DMA descriptor ring will not get allocated + * across Page boundary. If the allocation is done across the page boundary + * at the first time, then it is freed and the allocation is done at + * descriptor ring size aligned location. This will ensure that the ring will + * not cross page boundary + */ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - dma_addr_t *descpa); + dma_addr_t *descpa) +{ + void *va; + u32 desc_strtaddr; + u32 alignbytes = 1 << *alignbits; -/* Prototypes for 64-bit routines */ -static bool dma64_alloc(struct dma_info *di, uint direction); -static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall); -static bool dma64_rxidle(struct dma_info *di); -static bool _dma64_addrext(struct dma64regs *dma64regs); + va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); -static inline u32 parity32(u32 data); + if (NULL == va) + return NULL; + + desc_strtaddr = (u32) roundup((unsigned long)va, alignbytes); + if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr + & boundary)) { + *alignbits = dma_align_sizetobits(size); + pci_free_consistent(di->pbus, size, va, *descpa); + va = dma_alloc_consistent(di->pbus, size, *alignbits, + alloced, descpa); + } + return va; +} + +static bool dma64_alloc(struct dma_info *di, uint direction) +{ + u16 size; + uint ddlen; + void *va; + uint alloced = 0; + u16 align; + u16 align_bits; + + ddlen = sizeof(struct dma64desc); + + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen); + align_bits = di->dmadesc_align; + align = (1 << align_bits); + + if (direction == DMA_TX) { + va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, + &alloced, &di->txdpaorig); + if (va == NULL) { + DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd)" + " failed\n", di->name)); + return false; + } + align = (1 << align_bits); + di->txd64 = (struct dma64desc *) + roundup((unsigned long)va, align); + di->txdalign = (uint) ((s8 *)di->txd64 - (s8 *) va); + di->txdpa = di->txdpaorig + di->txdalign; + di->txdalloc = alloced; + } else { + va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, + &alloced, &di->rxdpaorig); + if (va == NULL) { + DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd)" + " failed\n", di->name)); + return false; + } + align = (1 << align_bits); + di->rxd64 = (struct dma64desc *) + roundup((unsigned long)va, align); + di->rxdalign = (uint) ((s8 *)di->rxd64 - (s8 *) va); + di->rxdpa = di->rxdpaorig + di->rxdalign; + di->rxdalloc = alloced; + } + + return true; +} + +static bool _dma_alloc(struct dma_info *di, uint direction) +{ + return dma64_alloc(di, direction); +} struct dma_pub *dma_attach(char *name, struct si_pub *sih, void *dmaregstx, void *dmaregsrx, uint ntxd, @@ -551,23 +720,6 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, } } -static bool _dma_alloc(struct dma_info *di, uint direction) -{ - return dma64_alloc(di, direction); -} - -void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, - uint *alloced, dma_addr_t *pap) -{ - if (align_bits) { - u16 align = (1 << align_bits); - if (!IS_ALIGNED(PAGE_SIZE, align)) - size += align; - *alloced = size; - } - return pci_alloc_consistent(pdev, size, pap); -} - /* !! may be called with core in reset */ void dma_detach(struct dma_pub *pub) { @@ -594,49 +746,6 @@ void dma_detach(struct dma_pub *pub) } -static bool _dma_descriptor_align(struct dma_info *di) -{ - u32 addrl; - - /* Check to see if the descriptors need to be aligned on 4K/8K or not */ - if (di->d64txregs != NULL) { - W_REG(&di->d64txregs->addrlow, 0xff0); - addrl = R_REG(&di->d64txregs->addrlow); - if (addrl != 0) - return false; - } else if (di->d64rxregs != NULL) { - W_REG(&di->d64rxregs->addrlow, 0xff0); - addrl = R_REG(&di->d64rxregs->addrlow); - if (addrl != 0) - return false; - } - return true; -} - -/* - * return true if this dma engine supports DmaExtendedAddrChanges, - * otherwise false - */ -static bool _dma_isaddrext(struct dma_info *di) -{ - /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ - - /* not all tx or rx channel are available */ - if (di->d64txregs != NULL) { - if (!_dma64_addrext(di->d64txregs)) - DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have " - "AE set\n", di->name)); - return true; - } else if (di->d64rxregs != NULL) { - if (!_dma64_addrext(di->d64rxregs)) - DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have " - "AE set\n", di->name)); - return true; - } - - return false; -} - /* initialize descriptor table base address */ static void _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) @@ -679,6 +788,27 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) } } +static void _dma_rxenable(struct dma_info *di) +{ + uint dmactrlflags = di->dma.dmactrlflags; + u32 control; + + DMA_TRACE(("%s: dma_rxenable\n", di->name)); + + control = + (R_REG(&di->d64rxregs->control) & D64_RC_AE) | + D64_RC_RE; + + if ((dmactrlflags & DMA_CTRL_PEN) == 0) + control |= D64_RC_PD; + + if (dmactrlflags & DMA_CTRL_ROC) + control |= D64_RC_OC; + + W_REG(&di->d64rxregs->control, + ((di->rxoffset << D64_RC_RO_SHIFT) | control)); +} + void dma_rxinit(struct dma_pub *pub) { struct dma_info *di = (struct dma_info *)pub; @@ -705,25 +835,49 @@ void dma_rxinit(struct dma_pub *pub) _dma_ddtable_init(di, DMA_RX, di->rxdpa); } -static void _dma_rxenable(struct dma_info *di) +static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) { - uint dmactrlflags = di->dma.dmactrlflags; - u32 control; + uint i, curr; + struct sk_buff *rxp; + dma_addr_t pa; - DMA_TRACE(("%s: dma_rxenable\n", di->name)); + i = di->rxin; - control = - (R_REG(&di->d64rxregs->control) & D64_RC_AE) | - D64_RC_RE; + /* return if no packets posted */ + if (i == di->rxout) + return NULL; - if ((dmactrlflags & DMA_CTRL_PEN) == 0) - control |= D64_RC_PD; + curr = + B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - + di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); - if (dmactrlflags & DMA_CTRL_ROC) - control |= D64_RC_OC; + /* ignore curr if forceall */ + if (!forceall && (i == curr)) + return NULL; - W_REG(&di->d64rxregs->control, - ((di->rxoffset << D64_RC_RO_SHIFT) | control)); + /* get the packet pointer that corresponds to the rx descriptor */ + rxp = di->rxp[i]; + di->rxp[i] = NULL; + + pa = cpu_to_le32(di->rxd64[i].addrlow) - di->dataoffsetlow; + + /* clear this packet from the descriptor ring */ + pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); + + di->rxd64[i].addrlow = 0xdeadbeef; + di->rxd64[i].addrhigh = 0xdeadbeef; + + di->rxin = NEXTRXD(i); + + return rxp; +} + +static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) +{ + if (di->nrxd == 0) + return NULL; + + return dma64_getnextrxp(di, forceall); } /* @@ -795,6 +949,17 @@ struct sk_buff *dma_rx(struct dma_pub *pub) return head; } +static bool dma64_rxidle(struct dma_info *di) +{ + DMA_TRACE(("%s: dma_rxidle\n", di->name)); + + if (di->nrxd == 0) + return true; + + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) == + (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); +} + /* * post receive buffers * return false is refill failed completely and ring is empty this will stall @@ -894,14 +1059,6 @@ void dma_rxreclaim(struct dma_pub *pub) brcmu_pkt_buf_free_skb(p); } -static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) -{ - if (di->nrxd == 0) - return NULL; - - return dma64_getnextrxp(di, forceall); -} - void dma_counterreset(struct dma_pub *pub) { /* reset all software counters */ @@ -910,41 +1067,6 @@ void dma_counterreset(struct dma_pub *pub) pub->txnobuf = 0; } -static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) -{ - uint dmactrlflags = di->dma.dmactrlflags; - - if (di == NULL) { - DMA_ERROR(("%s: _dma_ctrlflags: NULL dma handle\n", di->name)); - return 0; - } - - dmactrlflags &= ~mask; - dmactrlflags |= flags; - - /* If trying to enable parity, check if parity is actually supported */ - if (dmactrlflags & DMA_CTRL_PEN) { - u32 control; - - control = R_REG(&di->d64txregs->control); - W_REG(&di->d64txregs->control, - control | D64_XC_PD); - if (R_REG(&di->d64txregs->control) & D64_XC_PD) - /* We *can* disable it so it is supported, - * restore control register - */ - W_REG(&di->d64txregs->control, - control); - else - /* Not supported, don't allow it to be enabled */ - dmactrlflags &= ~DMA_CTRL_PEN; - } - - di->dma.dmactrlflags = dmactrlflags; - - return dmactrlflags; -} - /* get the address of the var in order to change later */ unsigned long dma_getvar(struct dma_pub *pub, const char *name) { @@ -955,45 +1077,6 @@ unsigned long dma_getvar(struct dma_pub *pub, const char *name) return 0; } -static -u8 dma_align_sizetobits(uint size) -{ - u8 bitpos = 0; - while (size >>= 1) - bitpos++; - return bitpos; -} - -/* This function ensures that the DMA descriptor ring will not get allocated - * across Page boundary. If the allocation is done across the page boundary - * at the first time, then it is freed and the allocation is done at - * descriptor ring size aligned location. This will ensure that the ring will - * not cross page boundary - */ -static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, - u16 *alignbits, uint *alloced, - dma_addr_t *descpa) -{ - void *va; - u32 desc_strtaddr; - u32 alignbytes = 1 << *alignbits; - - va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); - - if (NULL == va) - return NULL; - - desc_strtaddr = (u32) roundup((unsigned long)va, alignbytes); - if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr - & boundary)) { - *alignbits = dma_align_sizetobits(size); - pci_free_consistent(di->pbus, size, va, *descpa); - va = dma_alloc_consistent(di->pbus, size, *alignbits, - alloced, descpa); - } - return va; -} - /* 64-bit DMA functions */ void dma_txinit(struct dma_pub *pub) @@ -1083,54 +1166,6 @@ void dma_txreclaim(struct dma_pub *pub, enum txd_range range) } } -static bool dma64_alloc(struct dma_info *di, uint direction) -{ - u16 size; - uint ddlen; - void *va; - uint alloced = 0; - u16 align; - u16 align_bits; - - ddlen = sizeof(struct dma64desc); - - size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen); - align_bits = di->dmadesc_align; - align = (1 << align_bits); - - if (direction == DMA_TX) { - va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig); - if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd)" - " failed\n", di->name)); - return false; - } - align = (1 << align_bits); - di->txd64 = (struct dma64desc *) - roundup((unsigned long)va, align); - di->txdalign = (uint) ((s8 *)di->txd64 - (s8 *) va); - di->txdpa = di->txdpaorig + di->txdalign; - di->txdalloc = alloced; - } else { - va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig); - if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd)" - " failed\n", di->name)); - return false; - } - align = (1 << align_bits); - di->rxd64 = (struct dma64desc *) - roundup((unsigned long)va, align); - di->rxdalign = (uint) ((s8 *)di->rxd64 - (s8 *) va); - di->rxdpa = di->rxdpaorig + di->rxdalign; - di->rxdalloc = alloced; - } - - return true; -} - bool dma_txreset(struct dma_pub *pub) { struct dma_info *di = (struct dma_info *)pub; @@ -1157,17 +1192,6 @@ bool dma_txreset(struct dma_pub *pub) return status == D64_XS0_XS_DISABLED; } -static bool dma64_rxidle(struct dma_info *di) -{ - DMA_TRACE(("%s: dma_rxidle\n", di->name)); - - if (di->nrxd == 0) - return true; - - return ((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) == - (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); -} - bool dma_rxreset(struct dma_pub *pub) { struct dma_info *di = (struct dma_info *)pub; @@ -1357,52 +1381,6 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) return NULL; } -static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) -{ - uint i, curr; - struct sk_buff *rxp; - dma_addr_t pa; - - i = di->rxin; - - /* return if no packets posted */ - if (i == di->rxout) - return NULL; - - curr = - B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); - - /* ignore curr if forceall */ - if (!forceall && (i == curr)) - return NULL; - - /* get the packet pointer that corresponds to the rx descriptor */ - rxp = di->rxp[i]; - di->rxp[i] = NULL; - - pa = cpu_to_le32(di->rxd64[i].addrlow) - di->dataoffsetlow; - - /* clear this packet from the descriptor ring */ - pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); - - di->rxd64[i].addrlow = 0xdeadbeef; - di->rxd64[i].addrhigh = 0xdeadbeef; - - di->rxin = NEXTRXD(i); - - return rxp; -} - -static bool _dma64_addrext(struct dma64regs *dma64regs) -{ - u32 w; - OR_REG(&dma64regs->control, D64_XC_AE); - w = R_REG(&dma64regs->control); - AND_REG(&dma64regs->control, ~D64_XC_AE); - return (w & D64_XC_AE) == D64_XC_AE; -} - /* * Mac80211 initiated actions sometimes require packets in the DMA queue to be * modified. The modified portion of the packet is not under control of the DMA From 5871e4926054ae8678e8893e48f7a7568aa3d9e6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:57 +0200 Subject: [PATCH 0845/1519] staging: brcm80211: removed static function declarations in mac80211_if.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 1036 ++++++++--------- 1 file changed, 486 insertions(+), 550 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 01829db4fe8..bd989737905 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -37,6 +37,9 @@ #define LOCK(wl) spin_lock_bh(&(wl)->lock) #define UNLOCK(wl) spin_unlock_bh(&(wl)->lock) +#define HW_TO_WL(hw) (hw->priv) +#define WL_TO_HW(wl) (wl->pub->ieee_hw) + /* locking from inside brcms_isr */ #define ISR_LOCK(wl, flags)\ do {\ @@ -54,13 +57,6 @@ #define INT_LOCK(wl, flags) spin_lock_irqsave(&(wl)->isr_lock, flags) #define INT_UNLOCK(wl, flags) spin_unlock_irqrestore(&(wl)->isr_lock, flags) -static void brcms_timer(unsigned long data); -static void _brcms_timer(struct brcms_timer *t); - - -static int ieee_hw_init(struct ieee80211_hw *hw); -static int ieee_hw_rate_init(struct ieee80211_hw *hw); - /* Flags we support */ #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | \ @@ -70,22 +66,43 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw); FIF_OTHER_BSS | \ FIF_BCN_PRBRESP_PROMISC) +#define CHAN2GHZ(channel, freqency, chflags) { \ + .band = IEEE80211_BAND_2GHZ, \ + .center_freq = (freqency), \ + .hw_value = (channel), \ + .flags = chflags, \ + .max_antenna_gain = 0, \ + .max_power = 19, \ +} + +#define CHAN5GHZ(channel, chflags) { \ + .band = IEEE80211_BAND_5GHZ, \ + .center_freq = 5000 + 5*(channel), \ + .hw_value = (channel), \ + .flags = chflags, \ + .max_antenna_gain = 0, \ + .max_power = 21, \ +} + +#define RATE(rate100m, _flags) { \ + .bitrate = (rate100m), \ + .flags = (_flags), \ + .hw_value = (rate100m / 5), \ +} + +struct firmware_hdr { + u32 offset; + u32 len; + u32 idx; +}; + +char *brcms_firmwares[MAX_FW_IMAGES] = { + "brcm/bcm43xx", + NULL +}; + static int n_adapters_found; -static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev); -static void brcms_release_fw(struct brcms_info *wl); - -/* local prototypes */ -static void brcms_dpc(unsigned long data); -static irqreturn_t brcms_isr(int irq, void *dev_id); - -static int __devinit brcms_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent); -static void brcms_remove(struct pci_dev *pdev); -static void brcms_free(struct brcms_info *wl); -static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, - bool is_br); - MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); @@ -107,50 +124,170 @@ static int msglevel = 0xdeadbeef; module_param(msglevel, int, 0); #endif /* BCMDBG */ -#define HW_TO_WL(hw) (hw->priv) -#define WL_TO_HW(wl) (wl->pub->ieee_hw) +static struct ieee80211_channel brcms_2ghz_chantable[] = { + CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), + CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS), + CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS), + CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS), + CHAN2GHZ(5, 2432, 0), + CHAN2GHZ(6, 2437, 0), + CHAN2GHZ(7, 2442, 0), + CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(12, 2467, + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(13, 2472, + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_NO_HT40PLUS), + CHAN2GHZ(14, 2484, + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) +}; -/* MAC80211 callback functions */ -static int brcms_ops_start(struct ieee80211_hw *hw); -static void brcms_ops_stop(struct ieee80211_hw *hw); -static int brcms_ops_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -static void brcms_ops_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed); -static void brcms_ops_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *info, - u32 changed); -static void brcms_ops_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, u64 multicast); -static int brcms_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, - bool set); -static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw); -static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw); -static void brcms_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf); -static int brcms_ops_get_stats(struct ieee80211_hw *hw, - struct ieee80211_low_level_stats *stats); -static void brcms_ops_sta_notify(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum sta_notify_cmd cmd, - struct ieee80211_sta *sta); -static int brcms_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, - const struct ieee80211_tx_queue_params *params); -static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw); -static int brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta); -static int brcms_ops_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); -static int brcms_ops_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size); -static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw); -static void brcms_ops_flush(struct ieee80211_hw *hw, bool drop); +static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { + /* UNII-1 */ + CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS), + /* UNII-2 */ + CHAN5GHZ(52, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(56, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(60, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(64, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + /* MID */ + CHAN5GHZ(100, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(104, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(108, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(112, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(116, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(120, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(124, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(128, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(132, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(136, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(140, + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS | + IEEE80211_CHAN_NO_HT40MINUS), + /* UNII-3 */ + CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS), + CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS), + CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) +}; + +/* + * The rate table is used for both 2.4G and 5G rates. The + * latter being a subset as it does not support CCK rates. + */ +static struct ieee80211_rate legacy_ratetable[] = { + RATE(10, 0), + RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), + RATE(55, IEEE80211_RATE_SHORT_PREAMBLE), + RATE(110, IEEE80211_RATE_SHORT_PREAMBLE), + RATE(60, 0), + RATE(90, 0), + RATE(120, 0), + RATE(180, 0), + RATE(240, 0), + RATE(360, 0), + RATE(480, 0), + RATE(540, 0), +}; + +static struct ieee80211_supported_band brcms_band_2GHz_nphy = { + .band = IEEE80211_BAND_2GHZ, + .channels = brcms_2ghz_chantable, + .n_channels = ARRAY_SIZE(brcms_2ghz_chantable), + .bitrates = legacy_ratetable, + .n_bitrates = ARRAY_SIZE(legacy_ratetable), + .ht_cap = { + /* from include/linux/ieee80211.h */ + .cap = IEEE80211_HT_CAP_GRN_FLD | + IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, + .ht_supported = true, + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, + .ampdu_density = AMPDU_DEF_MPDU_DENSITY, + .mcs = { + /* placeholders for now */ + .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, + .rx_highest = 500, + .tx_params = IEEE80211_HT_MCS_TX_DEFINED} + } +}; + +static struct ieee80211_supported_band brcms_band_5GHz_nphy = { + .band = IEEE80211_BAND_5GHZ, + .channels = brcms_5ghz_nphy_chantable, + .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), + .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET, + .n_bitrates = ARRAY_SIZE(legacy_ratetable) - + BRCMS_LEGACY_5G_RATE_OFFSET, + .ht_cap = { + .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40 | + IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ + .ht_supported = true, + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, + .ampdu_density = AMPDU_DEF_MPDU_DENSITY, + .mcs = { + /* placeholders for now */ + .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, + .rx_highest = 500, + .tx_params = IEEE80211_HT_MCS_TX_DEFINED} + } +}; + +/* flags the given rate in rateset as requested */ +static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br) +{ + u32 i; + + for (i = 0; i < rs->count; i++) { + if (rate != (rs->rates[i] & 0x7f)) + continue; + + if (is_br) + rs->rates[i] |= BRCMS_RATE_FLAG; + else + rs->rates[i] &= BRCMS_RATE_MASK; + return; + } +} static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { @@ -735,6 +872,283 @@ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); } +static void brcms_dpc(unsigned long data) +{ + struct brcms_info *wl; + + wl = (struct brcms_info *) data; + + LOCK(wl); + + /* call the common second level interrupt handler */ + if (wl->pub->up) { + if (wl->resched) { + unsigned long flags; + + INT_LOCK(wl, flags); + brcms_c_intrsupd(wl->wlc); + INT_UNLOCK(wl, flags); + } + + wl->resched = brcms_c_dpc(wl->wlc, true); + } + + /* brcms_c_dpc() may bring the driver down */ + if (!wl->pub->up) + goto done; + + /* re-schedule dpc */ + if (wl->resched) + tasklet_schedule(&wl->tasklet); + else + /* re-enable interrupts */ + brcms_intrson(wl); + + done: + UNLOCK(wl); +} + +/* + * Precondition: Since this function is called in brcms_pci_probe() context, + * no locking is required. + */ +static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev) +{ + int status; + struct device *device = &pdev->dev; + char fw_name[100]; + int i; + + memset(&wl->fw, 0, sizeof(struct brcms_firmware)); + for (i = 0; i < MAX_FW_IMAGES; i++) { + if (brcms_firmwares[i] == NULL) + break; + sprintf(fw_name, "%s-%d.fw", brcms_firmwares[i], + UCODE_LOADER_API_VER); + status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); + if (status) { + wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", + KBUILD_MODNAME, fw_name); + return status; + } + sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i], + UCODE_LOADER_API_VER); + status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); + if (status) { + wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", + KBUILD_MODNAME, fw_name); + return status; + } + wl->fw.hdr_num_entries[i] = + wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr)); + } + wl->fw.fw_cnt = i; + return brcms_ucode_data_init(wl); +} + +/* + * Precondition: Since this function is called in brcms_pci_probe() context, + * no locking is required. + */ +static void brcms_release_fw(struct brcms_info *wl) +{ + int i; + for (i = 0; i < MAX_FW_IMAGES; i++) { + release_firmware(wl->fw.fw_bin[i]); + release_firmware(wl->fw.fw_hdr[i]); + } +} + +/** + * This function frees the WL per-device resources. + * + * This function frees resources owned by the WL device pointed to + * by the wl parameter. + * + * precondition: can both be called locked and unlocked + * + */ +static void brcms_free(struct brcms_info *wl) +{ + struct brcms_timer *t, *next; + + /* free ucode data */ + if (wl->fw.fw_cnt) + brcms_ucode_data_free(); + if (wl->irq) + free_irq(wl->irq, wl); + + /* kill dpc */ + tasklet_kill(&wl->tasklet); + + if (wl->pub) + brcms_c_module_unregister(wl->pub, "linux", wl); + + /* free common resources */ + if (wl->wlc) { + brcms_c_detach(wl->wlc); + wl->wlc = NULL; + wl->pub = NULL; + } + + /* virtual interface deletion is deferred so we cannot spinwait */ + + /* wait for all pending callbacks to complete */ + while (atomic_read(&wl->callbacks) > 0) + schedule(); + + /* free timers */ + for (t = wl->timers; t; t = next) { + next = t->next; +#ifdef BCMDBG + kfree(t->name); +#endif + kfree(t); + } + + /* + * unregister_netdev() calls get_stats() which may read chip + * registers so we cannot unmap the chip registers until + * after calling unregister_netdev() . + */ + if (wl->regsva) + iounmap((void *)wl->regsva); + + wl->regsva = NULL; +} + +/* +* called from both kernel as from this kernel module. +* precondition: perimeter lock is not acquired. +*/ +static void brcms_remove(struct pci_dev *pdev) +{ + struct brcms_info *wl; + struct ieee80211_hw *hw; + int status; + + hw = pci_get_drvdata(pdev); + wl = HW_TO_WL(hw); + if (!wl) { + pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); + return; + } + + LOCK(wl); + status = brcms_c_chipmatch(pdev->vendor, pdev->device); + UNLOCK(wl); + if (!status) { + wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " + "failed\n"); + return; + } + if (wl->wlc) { + wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); + wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); + ieee80211_unregister_hw(hw); + LOCK(wl); + brcms_down(wl); + UNLOCK(wl); + } + pci_disable_device(pdev); + + brcms_free(wl); + + pci_set_drvdata(pdev, NULL); + ieee80211_free_hw(hw); +} + +static irqreturn_t brcms_isr(int irq, void *dev_id) +{ + struct brcms_info *wl; + bool ours, wantdpc; + unsigned long flags; + + wl = (struct brcms_info *) dev_id; + + ISR_LOCK(wl, flags); + + /* call common first level interrupt handler */ + ours = brcms_c_isr(wl->wlc, &wantdpc); + if (ours) { + /* if more to do... */ + if (wantdpc) { + + /* ...and call the second level interrupt handler */ + /* schedule dpc */ + tasklet_schedule(&wl->tasklet); + } + } + + ISR_UNLOCK(wl, flags); + + return IRQ_RETVAL(ours); +} + +/* + * is called in brcms_pci_probe() context, therefore no locking required. + */ +static int ieee_hw_rate_init(struct ieee80211_hw *hw) +{ + struct brcms_info *wl = HW_TO_WL(hw); + int has_5g; + char phy_list[4]; + + has_5g = 0; + + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; + + if (brcms_c_get(wl->wlc, BRCM_GET_PHYLIST, (int *)&phy_list) < 0) + wiphy_err(hw->wiphy, "Phy list failed\n"); + + if (phy_list[0] == 'n' || phy_list[0] == 'c') { + if (phy_list[0] == 'c') { + /* Single stream */ + brcms_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; + brcms_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; + } + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &brcms_band_2GHz_nphy; + } else { + return -EPERM; + } + + /* Assume all bands use the same phy. True for 11n devices. */ + if (NBANDS_PUB(wl->pub) > 1) { + has_5g++; + if (phy_list[0] == 'n' || phy_list[0] == 'c') + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &brcms_band_5GHz_nphy; + else + return -EPERM; + } + return 0; +} + +/* + * is called in brcms_pci_probe() context, therefore no locking required. + */ +static int ieee_hw_init(struct ieee80211_hw *hw) +{ + hw->flags = IEEE80211_HW_SIGNAL_DBM + /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */ + | IEEE80211_HW_REPORTS_TX_ACK_STATUS + | IEEE80211_HW_AMPDU_AGGREGATION; + + hw->extra_tx_headroom = brcms_c_get_header_len(); + hw->queues = N_TX_QUEUES; + hw->max_rates = 2; /* Primary rate and 1 fallback rate */ + + /* channel change time is dependent on chip and band */ + hw->channel_change_time = 7 * 1000; + hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); + + hw->rate_control_algorithm = "minstrel_ht"; + + hw->sta_data_size = sizeof(struct scb); + return ieee_hw_rate_init(hw); +} + /** * attach to the WL device. * @@ -855,242 +1269,6 @@ fail: -#define CHAN2GHZ(channel, freqency, chflags) { \ - .band = IEEE80211_BAND_2GHZ, \ - .center_freq = (freqency), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 19, \ -} - -static struct ieee80211_channel brcms_2ghz_chantable[] = { - CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(5, 2432, 0), - CHAN2GHZ(6, 2437, 0), - CHAN2GHZ(7, 2442, 0), - CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(12, 2467, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(13, 2472, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(14, 2484, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) -}; - -#define CHAN5GHZ(channel, chflags) { \ - .band = IEEE80211_BAND_5GHZ, \ - .center_freq = 5000 + 5*(channel), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 21, \ -} - -static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { - /* UNII-1 */ - CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS), - /* UNII-2 */ - CHAN5GHZ(52, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(56, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(60, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(64, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - /* MID */ - CHAN5GHZ(100, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(104, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(108, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(112, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(116, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(120, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(124, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(128, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(132, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(136, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(140, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS | - IEEE80211_CHAN_NO_HT40MINUS), - /* UNII-3 */ - CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) -}; - -#define RATE(rate100m, _flags) { \ - .bitrate = (rate100m), \ - .flags = (_flags), \ - .hw_value = (rate100m / 5), \ -} - -/* - * The rate table is used for both 2.4G and 5G rates. The - * latter being a subset as it does not support CCK rates. - */ -static struct ieee80211_rate legacy_ratetable[] = { - RATE(10, 0), - RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(55, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(110, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(60, 0), - RATE(90, 0), - RATE(120, 0), - RATE(180, 0), - RATE(240, 0), - RATE(360, 0), - RATE(480, 0), - RATE(540, 0), -}; - -static struct ieee80211_supported_band brcms_band_2GHz_nphy = { - .band = IEEE80211_BAND_2GHZ, - .channels = brcms_2ghz_chantable, - .n_channels = ARRAY_SIZE(brcms_2ghz_chantable), - .bitrates = legacy_ratetable, - .n_bitrates = ARRAY_SIZE(legacy_ratetable), - .ht_cap = { - /* from include/linux/ieee80211.h */ - .cap = IEEE80211_HT_CAP_GRN_FLD | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, - .ht_supported = true, - .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, - .ampdu_density = AMPDU_DEF_MPDU_DENSITY, - .mcs = { - /* placeholders for now */ - .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = 500, - .tx_params = IEEE80211_HT_MCS_TX_DEFINED} - } -}; - -static struct ieee80211_supported_band brcms_band_5GHz_nphy = { - .band = IEEE80211_BAND_5GHZ, - .channels = brcms_5ghz_nphy_chantable, - .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), - .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET, - .n_bitrates = ARRAY_SIZE(legacy_ratetable) - - BRCMS_LEGACY_5G_RATE_OFFSET, - .ht_cap = { - .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ - .ht_supported = true, - .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, - .ampdu_density = AMPDU_DEF_MPDU_DENSITY, - .mcs = { - /* placeholders for now */ - .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = 500, - .tx_params = IEEE80211_HT_MCS_TX_DEFINED} - } -}; - -/* - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static int ieee_hw_rate_init(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = HW_TO_WL(hw); - int has_5g; - char phy_list[4]; - - has_5g = 0; - - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; - hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; - - if (brcms_c_get(wl->wlc, BRCM_GET_PHYLIST, (int *)&phy_list) < 0) - wiphy_err(hw->wiphy, "Phy list failed\n"); - - if (phy_list[0] == 'n' || phy_list[0] == 'c') { - if (phy_list[0] == 'c') { - /* Single stream */ - brcms_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; - brcms_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; - } - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &brcms_band_2GHz_nphy; - } else { - return -EPERM; - } - - /* Assume all bands use the same phy. True for 11n devices. */ - if (NBANDS_PUB(wl->pub) > 1) { - has_5g++; - if (phy_list[0] == 'n' || phy_list[0] == 'c') - hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &brcms_band_5GHz_nphy; - else - return -EPERM; - } - return 0; -} - -/* - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static int ieee_hw_init(struct ieee80211_hw *hw) -{ - hw->flags = IEEE80211_HW_SIGNAL_DBM - /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */ - | IEEE80211_HW_REPORTS_TX_ACK_STATUS - | IEEE80211_HW_AMPDU_AGGREGATION; - - hw->extra_tx_headroom = brcms_c_get_header_len(); - hw->queues = N_TX_QUEUES; - hw->max_rates = 2; /* Primary rate and 1 fallback rate */ - - /* channel change time is dependent on chip and band */ - hw->channel_change_time = 7 * 1000; - hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); - - hw->rate_control_algorithm = "minstrel_ht"; - - hw->sta_data_size = sizeof(struct scb); - return ieee_hw_rate_init(hw); -} - /** * determines if a device is a WL device, and if so, attaches it. * @@ -1216,47 +1394,6 @@ static int brcms_resume(struct pci_dev *pdev) return err; } -/* -* called from both kernel as from this kernel module. -* precondition: perimeter lock is not acquired. -*/ -static void brcms_remove(struct pci_dev *pdev) -{ - struct brcms_info *wl; - struct ieee80211_hw *hw; - int status; - - hw = pci_get_drvdata(pdev); - wl = HW_TO_WL(hw); - if (!wl) { - pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); - return; - } - - LOCK(wl); - status = brcms_c_chipmatch(pdev->vendor, pdev->device); - UNLOCK(wl); - if (!status) { - wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " - "failed\n"); - return; - } - if (wl->wlc) { - wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); - wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); - ieee80211_unregister_hw(hw); - LOCK(wl); - brcms_down(wl); - UNLOCK(wl); - } - pci_disable_device(pdev); - - brcms_free(wl); - - pci_set_drvdata(pdev, NULL); - ieee80211_free_hw(hw); -} - static struct pci_driver brcms_pci_driver = { .name = KBUILD_MODNAME, .probe = brcms_pci_probe, @@ -1307,81 +1444,6 @@ static void __exit brcms_module_exit(void) module_init(brcms_module_init); module_exit(brcms_module_exit); -/** - * This function frees the WL per-device resources. - * - * This function frees resources owned by the WL device pointed to - * by the wl parameter. - * - * precondition: can both be called locked and unlocked - * - */ -static void brcms_free(struct brcms_info *wl) -{ - struct brcms_timer *t, *next; - - /* free ucode data */ - if (wl->fw.fw_cnt) - brcms_ucode_data_free(); - if (wl->irq) - free_irq(wl->irq, wl); - - /* kill dpc */ - tasklet_kill(&wl->tasklet); - - if (wl->pub) - brcms_c_module_unregister(wl->pub, "linux", wl); - - /* free common resources */ - if (wl->wlc) { - brcms_c_detach(wl->wlc); - wl->wlc = NULL; - wl->pub = NULL; - } - - /* virtual interface deletion is deferred so we cannot spinwait */ - - /* wait for all pending callbacks to complete */ - while (atomic_read(&wl->callbacks) > 0) - schedule(); - - /* free timers */ - for (t = wl->timers; t; t = next) { - next = t->next; -#ifdef BCMDBG - kfree(t->name); -#endif - kfree(t); - } - - /* - * unregister_netdev() calls get_stats() which may read chip - * registers so we cannot unmap the chip registers until - * after calling unregister_netdev() . - */ - if (wl->regsva) - iounmap((void *)wl->regsva); - - wl->regsva = NULL; -} - -/* flags the given rate in rateset as requested */ -static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br) -{ - u32 i; - - for (i = 0; i < rs->count; i++) { - if (rate != (rs->rates[i] & 0x7f)) - continue; - - if (is_br) - rs->rates[i] |= BRCMS_RATE_FLAG; - else - rs->rates[i] &= BRCMS_RATE_MASK; - return; - } -} - /* * precondition: perimeter lock has been acquired */ @@ -1486,77 +1548,6 @@ void brcms_down(struct brcms_info *wl) LOCK(wl); } -static irqreturn_t brcms_isr(int irq, void *dev_id) -{ - struct brcms_info *wl; - bool ours, wantdpc; - unsigned long flags; - - wl = (struct brcms_info *) dev_id; - - ISR_LOCK(wl, flags); - - /* call common first level interrupt handler */ - ours = brcms_c_isr(wl->wlc, &wantdpc); - if (ours) { - /* if more to do... */ - if (wantdpc) { - - /* ...and call the second level interrupt handler */ - /* schedule dpc */ - tasklet_schedule(&wl->tasklet); - } - } - - ISR_UNLOCK(wl, flags); - - return IRQ_RETVAL(ours); -} - -static void brcms_dpc(unsigned long data) -{ - struct brcms_info *wl; - - wl = (struct brcms_info *) data; - - LOCK(wl); - - /* call the common second level interrupt handler */ - if (wl->pub->up) { - if (wl->resched) { - unsigned long flags; - - INT_LOCK(wl, flags); - brcms_c_intrsupd(wl->wlc); - INT_UNLOCK(wl, flags); - } - - wl->resched = brcms_c_dpc(wl->wlc, true); - } - - /* brcms_c_dpc() may bring the driver down */ - if (!wl->pub->up) - goto done; - - /* re-schedule dpc */ - if (wl->resched) - tasklet_schedule(&wl->tasklet); - else - /* re-enable interrupts */ - brcms_intrson(wl); - - done: - UNLOCK(wl); -} - -/* - * is called by the kernel from software irq context - */ -static void brcms_timer(unsigned long data) -{ - _brcms_timer((struct brcms_timer *) data); -} - /* * precondition: perimeter lock is not acquired */ @@ -1581,6 +1572,14 @@ static void _brcms_timer(struct brcms_timer *t) UNLOCK(t->wl); } +/* + * is called by the kernel from software irq context + */ +static void brcms_timer(unsigned long data) +{ + _brcms_timer((struct brcms_timer *) data); +} + /* * Adds a timer to the list. Caller supplies a timer function. * Is called from wlc. @@ -1695,17 +1694,6 @@ void brcms_free_timer(struct brcms_info *wl, struct brcms_timer *t) } -struct firmware_hdr { - u32 offset; - u32 len; - u32 idx; -}; - -char *brcms_firmwares[MAX_FW_IMAGES] = { - "brcm/bcm43xx", - NULL -}; - /* * precondition: perimeter lock has been acquired */ @@ -1770,44 +1758,6 @@ int brcms_ucode_init_uint(struct brcms_info *wl, u32 *data, u32 idx) return -ENOMSG; } -/* - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev) -{ - int status; - struct device *device = &pdev->dev; - char fw_name[100]; - int i; - - memset(&wl->fw, 0, sizeof(struct brcms_firmware)); - for (i = 0; i < MAX_FW_IMAGES; i++) { - if (brcms_firmwares[i] == NULL) - break; - sprintf(fw_name, "%s-%d.fw", brcms_firmwares[i], - UCODE_LOADER_API_VER); - status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); - if (status) { - wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - return status; - } - sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i], - UCODE_LOADER_API_VER); - status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); - if (status) { - wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - return status; - } - wl->fw.hdr_num_entries[i] = - wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr)); - } - wl->fw.fw_cnt = i; - return brcms_ucode_data_init(wl); -} - /* * precondition: can both be called locked and unlocked */ @@ -1816,20 +1766,6 @@ void brcms_ucode_free_buf(void *p) kfree(p); } -/* - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -static void brcms_release_fw(struct brcms_info *wl) -{ - int i; - for (i = 0; i < MAX_FW_IMAGES; i++) { - release_firmware(wl->fw.fw_bin[i]); - release_firmware(wl->fw.fw_hdr[i]); - } -} - - /* * checks validity of all firmware images loaded from user space * From fa188ec8b6b44d3697b96900929ac55c0a88dcf4 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:16:58 +0200 Subject: [PATCH 0846/1519] staging: brcm80211: removed static function declarations in 3 files nicpci.c, srom.c and stf.c Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/nicpci.c | 18 -- drivers/staging/brcm80211/brcmsmac/srom.c | 329 ++++++++++---------- drivers/staging/brcm80211/brcmsmac/stf.c | 117 ++++--- 3 files changed, 213 insertions(+), 251 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 2d46e701dd2..b34fe7d3100 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -215,24 +215,6 @@ struct pcicore_info { #define PCI_ERROR(args) #define PCIE_PUB(sih) ((sih)->buscoretype == PCIE_CORE_ID) -/* routines to access mdio slave device registers */ -static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk); -static int pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, - bool write, uint *val); -static int pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint readdr, - uint val); -static int pcie_mdioread(struct pcicore_info *pi, uint physmedia, uint readdr, - uint *ret_val); - -static void pcie_extendL1timer(struct pcicore_info *pi, bool extend); -static void pcie_clkreq_upd(struct pcicore_info *pi, uint state); - -static void pcie_war_aspm_clkreq(struct pcicore_info *pi); -static void pcie_war_serdes(struct pcicore_info *pi); -static void pcie_war_noplldown(struct pcicore_info *pi); -static void pcie_war_polarity(struct pcicore_info *pi); -static void pcie_war_pci_setup(struct pcicore_info *pi); - #define PCIE_ASPM(sih) \ ((PCIE_PUB(sih)) && \ (((sih)->buscorerev >= 3) && \ diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index a8f7c008628..c8f6897cb37 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -792,16 +792,45 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { static u8 srom_crc8_table[CRC8_TABLE_SIZE]; -static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, - struct brcms_varbuf *b); -static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, - uint *count); -static int sprom_read_pci(struct si_pub *sih, u16 *sprom, - uint wordoff, u16 *buf, uint nwords, bool check_crc); -static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz); +/* Parse SROM and create name=value pairs. 'srom' points to + * the SROM word array. 'off' specifies the offset of the + * first word 'srom' points to, which should be either 0 or + * SROM3_SWRG_OFF (full SROM or software region). + */ -static int initvars_table(char *start, char *end, - char **vars, uint *count); +static uint mask_shift(u16 mask) +{ + uint i; + for (i = 0; i < (sizeof(mask) << 3); i++) { + if (mask & (1 << i)) + return i; + } + return 0; +} + +static uint mask_width(u16 mask) +{ + int i; + for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) { + if (mask & (1 << i)) + return (uint) (i - mask_shift(mask) + 1); + } + return 0; +} + +static inline void ltoh16_buf(u16 *buf, unsigned int size) +{ + size /= 2; + while (size--) + *(buf + size) = le16_to_cpu(*(buf + size)); +} + +static inline void htol16_buf(u16 *buf, unsigned int size) +{ + size /= 2; + while (size--) + *(buf + size) = cpu_to_le16(*(buf + size)); +} /* Initialization of varbuf structure */ static void varbuf_init(struct brcms_varbuf *b, char *buf, uint size) @@ -864,167 +893,6 @@ static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) return r; } -/* - * Initialize local vars from the right source for this platform. - * Return 0 on success, nonzero on error. - */ -int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) -{ - uint len; - - len = 0; - - if (vars == NULL || count == NULL) - return 0; - - *vars = NULL; - *count = 0; - - if (curmap != NULL) - return initvars_srom_pci(sih, curmap, vars, count); - - return -EINVAL; -} - -static inline void ltoh16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(buf + size) = le16_to_cpu(*(buf + size)); -} - -static inline void htol16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(buf + size) = cpu_to_le16(*(buf + size)); -} - -/* - * Read in and validate sprom. - * Return 0 on success, nonzero on error. - */ -static int -sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, - u16 *buf, uint nwords, bool check_crc) -{ - int err = 0; - uint i; - - /* read the sprom */ - for (i = 0; i < nwords; i++) - buf[i] = R_REG(&sprom[wordoff + i]); - - if (check_crc) { - - if (buf[0] == 0xffff) - /* - * The hardware thinks that an srom that starts with - * 0xffff is blank, regardless of the rest of the - * content, so declare it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, nwords * 2); - if (crc8(srom_crc8_table, (u8 *) buf, nwords * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) - /* DBG only pci always read srom4 first, then srom8/9 */ - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, nwords * 2); - } - return err; -} - -static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) -{ - u8 *otp; - uint sz = OTP_SZ_MAX / 2; /* size in words */ - int err = 0; - - otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); - if (otp == NULL) - return -ENOMEM; - - err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); - - memcpy(buf, otp, bufsz); - - kfree(otp); - - /* Check CRC */ - if (buf[0] == 0xffff) - /* The hardware thinks that an srom that starts with 0xffff - * is blank, regardless of the rest of the content, so declare - * it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, bufsz); - if (crc8(srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, bufsz); - - return err; -} - -/* -* Create variable table from memory. -* Return 0 on success, nonzero on error. -*/ -static int initvars_table(char *start, char *end, - char **vars, uint *count) -{ - int c = (int)(end - start); - - /* do it only when there is more than just the null string */ - if (c > 1) { - char *vp = kmalloc(c, GFP_ATOMIC); - if (!vp) - return -ENOMEM; - memcpy(vp, start, c); - *vars = vp; - *count = c; - } else { - *vars = NULL; - *count = 0; - } - - return 0; -} - -/* Parse SROM and create name=value pairs. 'srom' points to - * the SROM word array. 'off' specifies the offset of the - * first word 'srom' points to, which should be either 0 or - * SROM3_SWRG_OFF (full SROM or software region). - */ - -static uint mask_shift(u16 mask) -{ - uint i; - for (i = 0; i < (sizeof(mask) << 3); i++) { - if (mask & (1 << i)) - return i; - } - return 0; -} - -static uint mask_width(u16 mask) -{ - int i; - for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) { - if (mask & (1 << i)) - return (uint) (i - mask_shift(mask) + 1); - } - return 0; -} - static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) { @@ -1159,6 +1027,105 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) } } +/* + * Read in and validate sprom. + * Return 0 on success, nonzero on error. + */ +static int +sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, + u16 *buf, uint nwords, bool check_crc) +{ + int err = 0; + uint i; + + /* read the sprom */ + for (i = 0; i < nwords; i++) + buf[i] = R_REG(&sprom[wordoff + i]); + + if (check_crc) { + + if (buf[0] == 0xffff) + /* + * The hardware thinks that an srom that starts with + * 0xffff is blank, regardless of the rest of the + * content, so declare it bad. + */ + return -ENODATA; + + /* fixup the endianness so crc8 will pass */ + htol16_buf(buf, nwords * 2); + if (crc8(srom_crc8_table, (u8 *) buf, nwords * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) + /* DBG only pci always read srom4 first, then srom8/9 */ + err = -EIO; + + /* now correct the endianness of the byte array */ + ltoh16_buf(buf, nwords * 2); + } + return err; +} + +static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) +{ + u8 *otp; + uint sz = OTP_SZ_MAX / 2; /* size in words */ + int err = 0; + + otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); + if (otp == NULL) + return -ENOMEM; + + err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); + + memcpy(buf, otp, bufsz); + + kfree(otp); + + /* Check CRC */ + if (buf[0] == 0xffff) + /* The hardware thinks that an srom that starts with 0xffff + * is blank, regardless of the rest of the content, so declare + * it bad. + */ + return -ENODATA; + + /* fixup the endianness so crc8 will pass */ + htol16_buf(buf, bufsz); + if (crc8(srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) + err = -EIO; + + /* now correct the endianness of the byte array */ + ltoh16_buf(buf, bufsz); + + return err; +} + +/* +* Create variable table from memory. +* Return 0 on success, nonzero on error. +*/ +static int initvars_table(char *start, char *end, + char **vars, uint *count) +{ + int c = (int)(end - start); + + /* do it only when there is more than just the null string */ + if (c > 1) { + char *vp = kmalloc(c, GFP_ATOMIC); + if (!vp) + return -ENOMEM; + memcpy(vp, start, c); + *vars = vp; + *count = c; + } else { + *vars = NULL; + *count = 0; + } + + return 0; +} + /* * Initialize nonvolatile variable table from sprom. * Return 0 on success, nonzero on error. @@ -1249,3 +1216,25 @@ errout: kfree(srom); return err; } + +/* + * Initialize local vars from the right source for this platform. + * Return 0 on success, nonzero on error. + */ +int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) +{ + uint len; + + len = 0; + + if (vars == NULL || count == NULL) + return 0; + + *vars = NULL; + *count = 0; + + if (curmap != NULL) + return initvars_srom_pci(sih, curmap, vars, count); + + return -EINVAL; +} diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index a4c5c637744..0c32e20ec47 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -30,15 +30,6 @@ #define BRCMS_STF_SS_STBC_RX(wlc) (BRCMS_ISNPHY(wlc->band) && \ NREV_GT(wlc->band->phyrev, 3) && NREV_LE(wlc->band->phyrev, 6)) -static bool brcms_c_stf_stbc_tx_set(struct brcms_c_info *wlc, s32 int_val); -static int brcms_c_stf_txcore_set(struct brcms_c_info *wlc, u8 Nsts, u8 val); -static int brcms_c_stf_spatial_policy_set(struct brcms_c_info *wlc, int val); -static void brcms_c_stf_stbc_rx_ht_update(struct brcms_c_info *wlc, int val); - -static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); -static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - u32 rspec); - #define NSTS_1 1 #define NSTS_2 2 #define NSTS_3 3 @@ -222,6 +213,60 @@ static int brcms_c_stf_spatial_policy_set(struct brcms_c_info *wlc, int val) return 0; } +/* + * Centralized txant update function. call it whenever wlc->stf->txant and/or + * wlc->stf->txchain change. + * + * Antennas are controlled by ucode indirectly, which drives PHY or GPIO to + * achieve various tx/rx antenna selection schemes + * + * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 + * means auto(last rx). + * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 + * means last rx and do tx-antenna selection for SISO transmissions + * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 + * means last rx and do tx-antenna selection for SISO transmissions + * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 + * means both cores active +*/ +static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) +{ + s8 txant; + + txant = (s8) wlc->stf->txant; + if (BRCMS_PHY_11N_CAP(wlc->band)) { + if (txant == ANT_TX_FORCE_0) { + wlc->stf->phytxant = PHY_TXC_ANT_0; + } else if (txant == ANT_TX_FORCE_1) { + wlc->stf->phytxant = PHY_TXC_ANT_1; + + if (BRCMS_ISNPHY(wlc->band) && + NREV_GE(wlc->band->phyrev, 3) + && NREV_LT(wlc->band->phyrev, 7)) + wlc->stf->phytxant = PHY_TXC_ANT_2; + } else { + if (BRCMS_ISLCNPHY(wlc->band) || + BRCMS_ISSSLPNPHY(wlc->band)) + wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST; + else { + /* catch out of sync wlc->stf->txcore */ + WARN_ON(wlc->stf->txchain <= 0); + wlc->stf->phytxant = + wlc->stf->txchain << PHY_TXC_ANT_SHIFT; + } + } + } else { + if (txant == ANT_TX_FORCE_0) + wlc->stf->phytxant = PHY_TXC_OLD_ANT_0; + else if (txant == ANT_TX_FORCE_1) + wlc->stf->phytxant = PHY_TXC_OLD_ANT_1; + else + wlc->stf->phytxant = PHY_TXC_OLD_ANT_LAST; + } + + brcms_b_txant_set(wlc->hw, wlc->stf->phytxant); +} + int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) { u8 txchain = (u8) int_val; @@ -358,60 +403,6 @@ void brcms_c_stf_detach(struct brcms_c_info *wlc) { } -/* - * Centralized txant update function. call it whenever wlc->stf->txant and/or - * wlc->stf->txchain change. - * - * Antennas are controlled by ucode indirectly, which drives PHY or GPIO to - * achieve various tx/rx antenna selection schemes - * - * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 - * means auto(last rx). - * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 - * means last rx and do tx-antenna selection for SISO transmissions - * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 - * means last rx and do tx-antenna selection for SISO transmissions - * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 - * means both cores active -*/ -static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) -{ - s8 txant; - - txant = (s8) wlc->stf->txant; - if (BRCMS_PHY_11N_CAP(wlc->band)) { - if (txant == ANT_TX_FORCE_0) { - wlc->stf->phytxant = PHY_TXC_ANT_0; - } else if (txant == ANT_TX_FORCE_1) { - wlc->stf->phytxant = PHY_TXC_ANT_1; - - if (BRCMS_ISNPHY(wlc->band) && - NREV_GE(wlc->band->phyrev, 3) - && NREV_LT(wlc->band->phyrev, 7)) - wlc->stf->phytxant = PHY_TXC_ANT_2; - } else { - if (BRCMS_ISLCNPHY(wlc->band) || - BRCMS_ISSSLPNPHY(wlc->band)) - wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST; - else { - /* catch out of sync wlc->stf->txcore */ - WARN_ON(wlc->stf->txchain <= 0); - wlc->stf->phytxant = - wlc->stf->txchain << PHY_TXC_ANT_SHIFT; - } - } - } else { - if (txant == ANT_TX_FORCE_0) - wlc->stf->phytxant = PHY_TXC_OLD_ANT_0; - else if (txant == ANT_TX_FORCE_1) - wlc->stf->phytxant = PHY_TXC_OLD_ANT_1; - else - wlc->stf->phytxant = PHY_TXC_OLD_ANT_LAST; - } - - brcms_b_txant_set(wlc->hw, wlc->stf->phytxant); -} - void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) { _brcms_c_stf_phy_txant_upd(wlc); From 2618f3a63c968ba106832e26bf43a20dd3a119ec Mon Sep 17 00:00:00 2001 From: Henry Ptasinski Date: Thu, 1 Sep 2011 11:16:59 +0200 Subject: [PATCH 0847/1519] staging: brcm80211: use min_t() instead of min() Also eliminate a cast to int that could cause issues with very large values of di->rxbufsize (as suggested by Dan Carpenter). Signed-off-by: Henry Ptasinski Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 8859a77e675..6d9a0feafa5 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -917,7 +917,7 @@ struct sk_buff *dma_rx(struct dma_pub *pub) tail = head; while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { tail->next = p; - pkt_len = min(resid, (int)di->rxbufsize); + pkt_len = min_t(uint, resid, di->rxbufsize); __skb_trim(p, pkt_len); tail = p; From 2682e2a34503890f92ce4564dcfba43ba70bad00 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 1 Sep 2011 11:17:00 +0200 Subject: [PATCH 0848/1519] staging: brcm80211: remove static function prototypes from main.c Function prototypes for static functions are not strictly needed and considered unwanted by linux community. This patch reorders the functions in brcmsmac/main.c and gets rid of the prototypes. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 3237 ++++++++++----------- 1 file changed, 1530 insertions(+), 1707 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 3aa03090b01..2825b1e755b 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -285,181 +285,6 @@ struct brcms_b_state { u32 preamble_ovr; /* preamble override */ }; -/* local prototypes */ -static void brcms_b_clkctl_clk(struct brcms_hardware *wlc, uint mode); - -/* used by wlc_wakeucode_init() */ -static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, - const struct d11init *inits); -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], - const uint nbytes); -static void brcms_ucode_download(struct brcms_hardware *wlc); -static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw); - -/* used by brcms_c_down() */ -static void brcms_c_flushqueues(struct brcms_c_info *wlc); - -static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs); -static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw); -static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw); -static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, - uint tx_fifo); -static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, - uint tx_fifo); - -/* Low Level Prototypes */ - -struct brcms_b_state; - -static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, - struct pci_dev *btparam); - -/* up/down, reset, clk */ -static void brcms_b_reset(struct brcms_hardware *wlc_hw); -static int brcms_b_state_get(struct brcms_hardware *wlc_hw, - struct brcms_b_state *state); -static void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, - uint *len); - -static void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, - u8 *ea); - -static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw); -static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw); - -static void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, - int match_reg_offset, - const u8 *addr); -static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin); -static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax); - -static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, - u16 LRL); - -static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw); - -static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, - u32 req_bit); -static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, - u32 antsel_avail); -static int brcms_b_bandtype(struct brcms_hardware *wlc_hw); -static void brcms_b_info_init(struct brcms_hardware *wlc_hw); -static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want); -static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, - u32 sel); -static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, - u16 v, u32 sel); -static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk); -static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme); -static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw); -static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw); -static bool brcms_c_validboardtype(struct brcms_hardware *wlc); -static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw); -static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw); -static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw); -static void brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init); -static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw); -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool want, u32 flags); -static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw); -static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw); -static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc); -static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask); -static void brcms_c_gpio_init(struct brcms_c_info *wlc); -static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, - u16 bcn[], int len); -static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, - u16 bcn[], int len); -static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec); -static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit); -static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - u16 chanspec); -static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, - bool shortslot); -static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw); -static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, - u8 rate); - -static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, - struct ieee80211_hw *hw, - struct sk_buff *p, - struct scb *scb, uint frag, - uint nfrags, uint queue, - uint next_frag_len, - struct wsec_key *key, - u32 rspec_override); -static void brcms_c_bss_default_init(struct brcms_c_info *wlc); -static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc); -static u32 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, - struct brcms_band *cur_band, - u32 int_val); -static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc); -static void brcms_c_watchdog(void *arg); -static void brcms_c_watchdog_by_timer(void *arg); -static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate); -static int brcms_c_set_rateset(struct brcms_c_info *wlc, - struct brcms_c_rateset *rs_arg); -static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc); - -/* send and receive */ -static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc); -static void brcms_c_txq_free(struct brcms_c_info *wlc, - struct brcms_txq_info *qi); -static void brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - bool on, int prio); -static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc); -static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rate, - uint length, u8 *plcp); -static void brcms_c_compute_ofdm_plcp(u32 rate, uint length, u8 *plcp); -static void brcms_c_compute_mimo_plcp(u32 rate, uint length, u8 *plcp); -static u16 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type, uint next_frag_len); -static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, - struct brcms_d11rxhdr *rxh); -static void brcms_c_recvctl(struct brcms_c_info *wlc, - struct d11rxhdr *rxh, struct sk_buff *p); -static uint brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type, uint dur); -static uint brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type); -static uint brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type); -/* interrupt, up/down, band */ -static void brcms_c_setband(struct brcms_c_info *wlc, uint bandunit); -static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc); -static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, - u16 chanspec); -static void brcms_c_bsinit(struct brcms_c_info *wlc); -static int brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, - bool isOFDM, bool writeToShm); -static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc); -static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc); -static void brcms_c_radio_timer(void *arg); -static void brcms_c_radio_enable(struct brcms_c_info *wlc); -static void brcms_c_radio_upd(struct brcms_c_info *wlc); - -/* scan, association, BSS */ -static uint brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type); -static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap); -static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val); -static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val); -static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx); - -static void brcms_c_wme_retries_write(struct brcms_c_info *wlc); -static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc); -static uint brcms_c_attach_module(struct brcms_c_info *wlc); -static void brcms_c_detach_module(struct brcms_c_info *wlc); -static void brcms_c_timers_deinit(struct brcms_c_info *wlc); -static void brcms_c_down_led_upd(struct brcms_c_info *wlc); -static uint brcms_c_down_del_timer(struct brcms_c_info *wlc); -static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc); -static int _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, - struct brcms_c_if *wlcif); -static void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], - int len, bool both); - const u8 prio2fifo[NUMPRIO] = { TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ TX_AC_BK_FIFO, /* 1 BK AC_BK Background */ @@ -554,6 +379,44 @@ static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, } } +static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, + const struct d11init *inits) +{ + int i; + u8 *base; + u8 *addr; + u16 size; + u32 value; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + base = (u8 *)wlc_hw->regs; + + for (i = 0; inits[i].addr != 0xffff; i++) { + size = le16_to_cpu(inits[i].size); + addr = base + le16_to_cpu(inits[i].addr); + value = le32_to_cpu(inits[i].value); + if (size == 2) + W_REG((u16 *)addr, value); + else if (size == 4) + W_REG((u32 *)addr, value); + else + break; + } +} + +static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) +{ + u8 idx; + u16 addr[] = { + M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, + M_HOST_FLAGS5 + }; + + for (idx = 0; idx < MHFMAX; idx++) + brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); +} + static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) { struct wiphy *wiphy = wlc_hw->wlc->wiphy; @@ -585,6 +448,30 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) } } +static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); + + wlc_hw->phyclk = clk; + + if (OFF == clk) { /* clear gmode bit, put phy into reset */ + + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), + (SICF_PRST | SICF_FGC)); + udelay(1); + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); + udelay(1); + + } else { /* take phy out of reset */ + + ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); + udelay(1); + ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); + udelay(1); + + } +} + /* switch to new band but leave it inactive */ static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) { @@ -734,6 +621,36 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) return morepending; } +/* brcms_b_tx_fifo_suspended: + * Check the MAC's tx suspend status for a tx fifo. + * + * When the MAC acknowledges a tx suspend, it indicates that no more + * packets will be transmitted out the radio. This is independent of + * DMA channel suspension---the DMA may have finished suspending, or may still + * be pulling data into a tx fifo, by the time the MAC acks the suspend + * request. + */ +static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + /* check that a suspend has been requested and is no longer pending */ + + /* + * for DMA mode, the suspend request is set in xmtcontrol of the DMA + * engine, and the tx fifo suspend at the lower end of the MAC is + * acknowledged in the chnstatus register. + * + * The tx fifo suspend completion is independent of the DMA suspend + * completion and may be acked before or after the DMA is suspended. + */ + if (dma_txsuspended(wlc_hw->di[tx_fifo]) && + (R_REG(&wlc_hw->regs->chnstatus) & + (1 << tx_fifo)) == 0) + return true; + + return false; +} + /* second-level interrupt processing * Return true if another dpc needs to be re-scheduled. false otherwise. * Param 'bounded' indicates if applicable loops should be bounded. @@ -845,6 +762,26 @@ int brcms_b_state_get(struct brcms_hardware *wlc_hw, return 0; } +/* set initial host flags value */ +static void +brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) +{ + struct brcms_hardware *wlc_hw = wlc->hw; + + memset(mhfs, 0, MHFMAX * sizeof(u16)); + + mhfs[MHF2] |= mhf2_init; + + /* prohibit use of slowclock on multifunction boards */ + if (wlc_hw->boardflags & BFL_NOPLLDOWN) + mhfs[MHF1] |= MHF1_FORCEFASTCLK; + + if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { + mhfs[MHF2] |= MHF2_NPHY40MHZ_WAR; + mhfs[MHF1] |= MHF1_IQSWAP_WAR; + } +} + static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) { uint i; @@ -1058,26 +995,6 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) } } -/* set initial host flags value */ -static void -brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - - memset(mhfs, 0, MHFMAX * sizeof(u16)); - - mhfs[MHF2] |= mhf2_init; - - /* prohibit use of slowclock on multifunction boards */ - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - mhfs[MHF1] |= MHF1_FORCEFASTCLK; - - if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { - mhfs[MHF2] |= MHF2_NPHY40MHZ_WAR; - mhfs[MHF1] |= MHF1_IQSWAP_WAR; - } -} - /* set or clear ucode host flag bits * it has an optimization for no-change write * it only writes through shared memory when the core has clock; @@ -1142,18 +1059,6 @@ brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, } } -static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) -{ - u8 idx; - u16 addr[] = { - M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, - M_HOST_FLAGS5 - }; - - for (idx = 0; idx < MHFMAX; idx++) - brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); -} - /* set the maccontrol register to desired reset state and * initialize the sw cache of the register */ @@ -1167,6 +1072,27 @@ static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw) brcms_b_mctrl(wlc_hw, ~0, MCTL_IHR_EN | MCTL_WAKE); } +/* + * write the software state of maccontrol and + * overrides to the maccontrol register + */ +static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) +{ + u32 maccontrol = wlc_hw->maccontrol; + + /* OR in the wake bit if overridden */ + if (wlc_hw->wake_override) + maccontrol |= MCTL_WAKE; + + /* set AP and INFRA bits for mute if needed */ + if (wlc_hw->mute_override) { + maccontrol &= ~(MCTL_AP); + maccontrol |= MCTL_INFRA; + } + + W_REG(&wlc_hw->regs->maccontrol, maccontrol); +} + /* set or clear maccontrol bits */ void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) { @@ -1189,27 +1115,6 @@ void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) brcms_c_mctrl_write(wlc_hw); } -/* - * write the software state of maccontrol and - * overrides to the maccontrol register - */ -static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) -{ - u32 maccontrol = wlc_hw->maccontrol; - - /* OR in the wake bit if overridden */ - if (wlc_hw->wake_override) - maccontrol |= MCTL_WAKE; - - /* set AP and INFRA bits for mute if needed */ - if (wlc_hw->mute_override) { - maccontrol &= ~(MCTL_AP); - maccontrol |= MCTL_INFRA; - } - - W_REG(&wlc_hw->regs->maccontrol, maccontrol); -} - void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, u32 override_bit) { @@ -1420,6 +1325,91 @@ static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); } +static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) +{ + u16 phyctl; + u16 phytxant = wlc_hw->bmac_phytxant; + u16 mask = PHY_TXC_ANT_MASK; + + /* set the Probe Response frame phy control word */ + phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); + phyctl = (phyctl & ~mask) | phytxant; + brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); + + /* set the Response (ACK/CTS) frame phy control word */ + phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); + phyctl = (phyctl & ~mask) | phytxant; + brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); +} + +static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, + u8 rate) +{ + uint i; + u8 plcp_rate = 0; + struct plcp_signal_rate_lookup { + u8 rate; + u8 signal_rate; + }; + /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ + const struct plcp_signal_rate_lookup rate_lookup[] = { + {BRCM_RATE_6M, 0xB}, + {BRCM_RATE_9M, 0xF}, + {BRCM_RATE_12M, 0xA}, + {BRCM_RATE_18M, 0xE}, + {BRCM_RATE_24M, 0x9}, + {BRCM_RATE_36M, 0xD}, + {BRCM_RATE_48M, 0x8}, + {BRCM_RATE_54M, 0xC} + }; + + for (i = 0; i < ARRAY_SIZE(rate_lookup); i++) { + if (rate == rate_lookup[i].rate) { + plcp_rate = rate_lookup[i].signal_rate; + break; + } + } + + /* Find the SHM pointer to the rate table entry by looking in the + * Direct-map Table + */ + return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); +} + +static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) +{ + u8 rate; + u8 rates[8] = { + BRCM_RATE_6M, BRCM_RATE_9M, BRCM_RATE_12M, BRCM_RATE_18M, + BRCM_RATE_24M, BRCM_RATE_36M, BRCM_RATE_48M, BRCM_RATE_54M + }; + u16 entry_ptr; + u16 pctl1; + uint i; + + if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) + return; + + /* walk the phy rate table and update the entries */ + for (i = 0; i < ARRAY_SIZE(rates); i++) { + rate = rates[i]; + + entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); + + /* read the SHM Rate Table entry OFDM PCTL1 values */ + pctl1 = + brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); + + /* modify the value */ + pctl1 &= ~PHY_TXC1_MODE_MASK; + pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); + + /* Update the SHM Rate Table entry OFDM PCTL1 values */ + brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, + pctl1); + } +} + /* band-specific init */ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) { @@ -1459,30 +1449,6 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) brcms_b_upd_synthpu(wlc_hw); } -static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); - - wlc_hw->phyclk = clk; - - if (OFF == clk) { /* clear gmode bit, put phy into reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), - (SICF_PRST | SICF_FGC)); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); - udelay(1); - - } else { /* take phy out of reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); - udelay(1); - - } -} - /* Perform a soft reset of the PHY PLL */ void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) { @@ -1689,6 +1655,29 @@ static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) return macaddr; } +/* power both the pll and external oscillator on/off */ +static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) +{ + BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); + + /* + * dont power down if plldown is false or + * we must poll hw radio disable + */ + if (!want && wlc_hw->pllreq) + return; + + if (wlc_hw->sih) + ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want); + + wlc_hw->sbclk = want; + if (!wlc_hw->sbclk) { + wlc_hw->clk = false; + if (wlc_hw->band && wlc_hw->band->pi) + wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); + } +} + /* * Return true if radio is disabled, otherwise false. * hw radio disable signal is an external pin, users activate it asynchronously @@ -1990,6 +1979,23 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY); } +static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], + const uint nbytes) { + struct d11regs *regs = wlc_hw->regs; + uint i; + uint count; + + BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); + + count = (nbytes / sizeof(u32)); + + W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); + (void)R_REG(®s->objaddr); + for (i = 0; i < count; i++) + W_REG(®s->objdata, le32_to_cpu(ucode[i])); + +} + static void brcms_ucode_download(struct brcms_hardware *wlc_hw) { struct brcms_c_info *wlc; @@ -2020,66 +2026,6 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw) } } -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], - const uint nbytes) { - struct d11regs *regs = wlc_hw->regs; - uint i; - uint count; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - count = (nbytes / sizeof(u32)); - - W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); - (void)R_REG(®s->objaddr); - for (i = 0; i < count; i++) - W_REG(®s->objdata, le32_to_cpu(ucode[i])); - -} - -static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, - const struct d11init *inits) -{ - int i; - u8 *base; - u8 *addr; - u16 size; - u32 value; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - base = (u8 *)wlc_hw->regs; - - for (i = 0; inits[i].addr != 0xffff; i++) { - size = le16_to_cpu(inits[i].size); - addr = base + le16_to_cpu(inits[i].addr); - value = le32_to_cpu(inits[i].value); - if (size == 2) - W_REG((u16 *)addr, value); - else if (size == 4) - W_REG((u32 *)addr, value); - else - break; - } -} - -static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) -{ - u16 phyctl; - u16 phytxant = wlc_hw->bmac_phytxant; - u16 mask = PHY_TXC_ANT_MASK; - - /* set the Probe Response frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); - - /* set the Response (ACK/CTS) frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); -} - void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant) { /* update sw state */ @@ -2259,6 +2205,28 @@ static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, } } +static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, + uint tx_fifo) +{ + /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case + * but need to be done here for PIO otherwise the watchdog will catch + * the inconsistency and fire + */ + /* Two clients of this code, 11h Quiet period and scanning. */ + if (wlc_hw->di[tx_fifo]) + dma_txresume(wlc_hw->di[tx_fifo]); + + /* allow core to sleep again */ + if (wlc_hw->suspended_fifos == 0) + return; + else { + wlc_hw->suspended_fifos &= ~(1 << tx_fifo); + if (wlc_hw->suspended_fifos == 0) + brcms_c_ucode_wake_override_clear(wlc_hw, + BRCMS_WAKE_OVERRIDE_TXFIFO); + } +} + static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) { u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; @@ -2295,58 +2263,6 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) brcms_c_ucode_mute_override_clear(wlc_hw); } -/* brcms_b_tx_fifo_suspended: - * Check the MAC's tx suspend status for a tx fifo. - * - * When the MAC acknowledges a tx suspend, it indicates that no more - * packets will be transmitted out the radio. This is independent of - * DMA channel suspension---the DMA may have finished suspending, or may still - * be pulling data into a tx fifo, by the time the MAC acks the suspend - * request. - */ -static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* check that a suspend has been requested and is no longer pending */ - - /* - * for DMA mode, the suspend request is set in xmtcontrol of the DMA - * engine, and the tx fifo suspend at the lower end of the MAC is - * acknowledged in the chnstatus register. - * - * The tx fifo suspend completion is independent of the DMA suspend - * completion and may be acked before or after the DMA is suspended. - */ - if (dma_txsuspended(wlc_hw->di[tx_fifo]) && - (R_REG(&wlc_hw->regs->chnstatus) & - (1 << tx_fifo)) == 0) - return true; - - return false; -} - -static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case - * but need to be done here for PIO otherwise the watchdog will catch - * the inconsistency and fire - */ - /* Two clients of this code, 11h Quiet period and scanning. */ - if (wlc_hw->di[tx_fifo]) - dma_txresume(wlc_hw->di[tx_fifo]); - - /* allow core to sleep again */ - if (wlc_hw->suspended_fifos == 0) - return; - else { - wlc_hw->suspended_fifos &= ~(1 << tx_fifo); - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_clear(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - } -} - /* * Read and clear macintmask and macintstatus and intstatus registers. * This routine should be called with interrupts off @@ -2569,74 +2485,6 @@ void brcms_c_enable_mac(struct brcms_c_info *wlc) BRCMS_WAKE_OVERRIDE_MACSUSPEND); } -static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) -{ - u8 rate; - u8 rates[8] = { - BRCM_RATE_6M, BRCM_RATE_9M, BRCM_RATE_12M, BRCM_RATE_18M, - BRCM_RATE_24M, BRCM_RATE_36M, BRCM_RATE_48M, BRCM_RATE_54M - }; - u16 entry_ptr; - u16 pctl1; - uint i; - - if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) - return; - - /* walk the phy rate table and update the entries */ - for (i = 0; i < ARRAY_SIZE(rates); i++) { - rate = rates[i]; - - entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); - - /* read the SHM Rate Table entry OFDM PCTL1 values */ - pctl1 = - brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); - - /* modify the value */ - pctl1 &= ~PHY_TXC1_MODE_MASK; - pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); - - /* Update the SHM Rate Table entry OFDM PCTL1 values */ - brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, - pctl1); - } -} - -static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, - u8 rate) -{ - uint i; - u8 plcp_rate = 0; - struct plcp_signal_rate_lookup { - u8 rate; - u8 signal_rate; - }; - /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ - const struct plcp_signal_rate_lookup rate_lookup[] = { - {BRCM_RATE_6M, 0xB}, - {BRCM_RATE_9M, 0xF}, - {BRCM_RATE_12M, 0xA}, - {BRCM_RATE_18M, 0xE}, - {BRCM_RATE_24M, 0x9}, - {BRCM_RATE_36M, 0xD}, - {BRCM_RATE_48M, 0x8}, - {BRCM_RATE_54M, 0xC} - }; - - for (i = 0; i < ARRAY_SIZE(rate_lookup); i++) { - if (rate == rate_lookup[i].rate) { - plcp_rate = rate_lookup[i].signal_rate; - break; - } - } - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); -} - void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) { wlc_hw->hw_stf_ss_opmode = stf_mode; @@ -2799,29 +2647,6 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw) wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); } -/* power both the pll and external oscillator on/off */ -static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); - - /* - * dont power down if plldown is false or - * we must poll hw radio disable - */ - if (!want && wlc_hw->pllreq) - return; - - if (wlc_hw->sih) - ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want); - - wlc_hw->sbclk = want; - if (!wlc_hw->sbclk) { - wlc_hw->clk = false; - if (wlc_hw->band && wlc_hw->band->pi) - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - } -} - static void brcms_c_flushqueues(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; @@ -2841,16 +2666,6 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) dma_rxreclaim(wlc_hw->di[RX_FIFO]); } -u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) -{ - return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); -} - -void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) -{ - brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); -} - static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) { @@ -2885,6 +2700,16 @@ brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, W_REG(objdata_lo, v); } +u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) +{ + return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); +} + +void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) +{ + brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); +} + /* Copy a buffer to shared memory of specified type . * SHM 'offset' needs to be an even address and * Buffer length 'len' must be an even number of bytes @@ -3319,6 +3144,220 @@ brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); } +static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc) +{ + u8 local; + s16 local_max; + + local = BRCMS_TXPWR_MAX; + if (wlc->pub->associated && + (brcmu_chspec_ctlchan(wlc->chanspec) == + brcmu_chspec_ctlchan(wlc->home_chanspec))) { + + /* get the local power constraint if we are on the AP's + * channel [802.11h, 7.3.2.13] + */ + /* Clamp the value between 0 and BRCMS_TXPWR_MAX w/o + * overflowing the target */ + local_max = + (wlc->txpwr_local_max - + wlc->txpwr_local_constraint) * BRCMS_TXPWR_DB_FACTOR; + if (local_max > 0 && local_max < BRCMS_TXPWR_MAX) + return (u8) local_max; + if (local_max < 0) + return 0; + } + + return local; +} + +static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, + u16 chanspec) +{ + /* Save our copy of the chanspec */ + wlc->chanspec = chanspec; + + /* Set the chanspec and power limits for this locale after computing + * any 11h local tx power constraints. + */ + brcms_c_channel_set_chanspec(wlc->cmi, chanspec, + brcms_c_local_constraint_qdbm(wlc)); + + if (wlc->stf->ss_algosel_auto) + brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, + chanspec); + + brcms_c_stf_ss_update(wlc, wlc->band); + +} + +static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, + u16 chanspec) +{ + struct brcms_c_rateset default_rateset; + uint parkband; + uint i, band_order[2]; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); + /* + * We might have been bandlocked during down and the chip + * power-cycled (hibernate). Figure out the right band to park on + */ + if (wlc->bandlocked || NBANDS(wlc) == 1) { + /* updated in brcms_c_bandlock() */ + parkband = wlc->band->bandunit; + band_order[0] = band_order[1] = parkband; + } else { + /* park on the band of the specified chanspec */ + parkband = CHSPEC_BANDUNIT(chanspec); + + /* order so that parkband initialize last */ + band_order[0] = parkband ^ 1; + band_order[1] = parkband; + } + + /* make each band operational, software state init */ + for (i = 0; i < NBANDS(wlc); i++) { + uint j = band_order[i]; + + wlc->band = wlc->bandstate[j]; + + brcms_default_rateset(wlc, &default_rateset); + + /* fill in hw_rate */ + brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, + false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, + (bool) N_ENAB(wlc->pub)); + + /* init basic rate lookup */ + brcms_c_rate_lookup_init(wlc, &default_rateset); + } + + /* sync up phy/radio chanspec */ + brcms_c_set_phy_chanspec(wlc, chanspec); +} + +/* + * ucode, hwmac update + * Channel dependent updates for ucode and hw + */ +static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) +{ + /* enable or disable any active IBSSs depending on whether or not + * we are on the home channel + */ + if (wlc->home_chanspec == BRCMS_BAND_PI_RADIO_CHANSPEC) { + if (wlc->pub->associated) { + /* + * BMAC_NOTE: This is something that should be fixed + * in ucode inits. I think that the ucode inits set + * up the bcn templates and shm values with a bogus + * beacon. This should not be done in the inits. If + * ucode needs to set up a beacon for testing, the + * test routines should write it down, not expect the + * inits to populate a bogus beacon. + */ + if (BRCMS_PHY_11N_CAP(wlc->band)) + brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, + wlc->band->bcntsfoff); + } + } else { + /* disable an active IBSS if we are not on the home channel */ + } + + /* update the various promisc bits */ + brcms_c_mac_bcn_promisc(wlc); + brcms_c_mac_promisc(wlc); +} + +/* band-specific init */ +static void brcms_c_bsinit(struct brcms_c_info *wlc) +{ + BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", + wlc->pub->unit, wlc->band->bandunit); + + /* write ucode ACK/CTS rate table */ + brcms_c_set_ratetable(wlc); + + /* update some band specific mac configuration */ + brcms_c_ucode_mac_upd(wlc); + + /* init antenna selection */ + brcms_c_antsel_init(wlc->asi); + +} + +/* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */ +static int +brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, + bool writeToShm) +{ + int idle_busy_ratio_x_16 = 0; + uint offset = + isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM : + M_TX_IDLE_BUSY_RATIO_X_16_CCK; + if (duty_cycle > 100 || duty_cycle < 0) { + wiphy_err(wlc->wiphy, "wl%d: duty cycle value off limit\n", + wlc->pub->unit); + return -EINVAL; + } + if (duty_cycle) + idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; + /* Only write to shared memory when wl is up */ + if (writeToShm) + brcms_c_write_shm(wlc, offset, (u16) idle_busy_ratio_x_16); + + if (isOFDM) + wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; + else + wlc->tx_duty_cycle_cck = (u16) duty_cycle; + + return 0; +} + +/* + * Initialize the base precedence map for dequeueing + * from txq based on WME settings + */ +static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc) +{ + wlc->tx_prec_map = BRCMS_PREC_BMP_ALL; + memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16)); + + /* + * For non-WME, both fifos have overlapping MAXPRIO. So just + * disable all precedences if either is full. + */ + if (!EDCF_ENAB(wlc->pub)) { + wlc->fifo2prec_map[TX_DATA_FIFO] = BRCMS_PREC_BMP_ALL; + wlc->fifo2prec_map[TX_CTL_FIFO] = BRCMS_PREC_BMP_ALL; + } else { + wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK; + wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE; + wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI; + wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO; + } +} + +static void +brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, + struct brcms_txq_info *qi, bool on, int prio) +{ + /* transmit flowcontrol is not yet implemented */ +} + +static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc) +{ + struct brcms_txq_info *qi; + + for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { + if (qi->stopped) { + brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO); + qi->stopped = 0; + } + } +} + void brcms_c_init(struct brcms_c_info *wlc) { struct d11regs *regs; @@ -3585,33 +3624,6 @@ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) brcms_b_set_shortslot(wlc->hw, shortslot); } -static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc) -{ - u8 local; - s16 local_max; - - local = BRCMS_TXPWR_MAX; - if (wlc->pub->associated && - (brcmu_chspec_ctlchan(wlc->chanspec) == - brcmu_chspec_ctlchan(wlc->home_chanspec))) { - - /* get the local power constraint if we are on the AP's - * channel [802.11h, 7.3.2.13] - */ - /* Clamp the value between 0 and BRCMS_TXPWR_MAX w/o - * overflowing the target */ - local_max = - (wlc->txpwr_local_max - - wlc->txpwr_local_constraint) * BRCMS_TXPWR_DB_FACTOR; - if (local_max > 0 && local_max < BRCMS_TXPWR_MAX) - return (u8) local_max; - if (local_max < 0) - return 0; - } - - return local; -} - /* * propagate home chanspec to all bsscfgs in * case bsscfg->current_bss->chanspec is referenced @@ -3635,26 +3647,6 @@ void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) } } -static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, - u16 chanspec) -{ - /* Save our copy of the chanspec */ - wlc->chanspec = chanspec; - - /* Set the chanspec and power limits for this locale after computing - * any 11h local tx power constraints. - */ - brcms_c_channel_set_chanspec(wlc->cmi, chanspec, - brcms_c_local_constraint_qdbm(wlc)); - - if (wlc->stf->ss_algosel_auto) - brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, - chanspec); - - brcms_c_stf_ss_update(wlc, wlc->band); - -} - void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, bool mute, struct txpwr_limits *txpwr) @@ -3699,6 +3691,30 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, } } +/* switch to and initialize new band */ +static void brcms_c_setband(struct brcms_c_info *wlc, + uint bandunit) +{ + int idx; + struct brcms_bss_cfg *cfg; + + wlc->band = wlc->bandstate[bandunit]; + + if (!wlc->pub->up) + return; + + /* wait for at least one beacon before entering sleeping state */ + for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { + cfg = wlc->bsscfg[idx]; + if (cfg && BSSCFG_STA(cfg) && cfg->associated) + cfg->PMawakebcn = true; + } + brcms_c_set_ps_ctrl(wlc); + + /* band-specific initializations */ + brcms_c_bsinit(wlc); +} + void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) { uint bandunit; @@ -3882,126 +3898,6 @@ static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) } } -/* - * ucode, hwmac update - * Channel dependent updates for ucode and hw - */ -static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) -{ - /* enable or disable any active IBSSs depending on whether or not - * we are on the home channel - */ - if (wlc->home_chanspec == BRCMS_BAND_PI_RADIO_CHANSPEC) { - if (wlc->pub->associated) { - /* - * BMAC_NOTE: This is something that should be fixed - * in ucode inits. I think that the ucode inits set - * up the bcn templates and shm values with a bogus - * beacon. This should not be done in the inits. If - * ucode needs to set up a beacon for testing, the - * test routines should write it down, not expect the - * inits to populate a bogus beacon. - */ - if (BRCMS_PHY_11N_CAP(wlc->band)) - brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, - wlc->band->bcntsfoff); - } - } else { - /* disable an active IBSS if we are not on the home channel */ - } - - /* update the various promisc bits */ - brcms_c_mac_bcn_promisc(wlc); - brcms_c_mac_promisc(wlc); -} - -static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, - u16 chanspec) -{ - struct brcms_c_rateset default_rateset; - uint parkband; - uint i, band_order[2]; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - /* - * We might have been bandlocked during down and the chip - * power-cycled (hibernate). Figure out the right band to park on - */ - if (wlc->bandlocked || NBANDS(wlc) == 1) { - /* updated in brcms_c_bandlock() */ - parkband = wlc->band->bandunit; - band_order[0] = band_order[1] = parkband; - } else { - /* park on the band of the specified chanspec */ - parkband = CHSPEC_BANDUNIT(chanspec); - - /* order so that parkband initialize last */ - band_order[0] = parkband ^ 1; - band_order[1] = parkband; - } - - /* make each band operational, software state init */ - for (i = 0; i < NBANDS(wlc); i++) { - uint j = band_order[i]; - - wlc->band = wlc->bandstate[j]; - - brcms_default_rateset(wlc, &default_rateset); - - /* fill in hw_rate */ - brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, - false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, - (bool) N_ENAB(wlc->pub)); - - /* init basic rate lookup */ - brcms_c_rate_lookup_init(wlc, &default_rateset); - } - - /* sync up phy/radio chanspec */ - brcms_c_set_phy_chanspec(wlc, chanspec); -} - -/* band-specific init */ -static void brcms_c_bsinit(struct brcms_c_info *wlc) -{ - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", - wlc->pub->unit, wlc->band->bandunit); - - /* write ucode ACK/CTS rate table */ - brcms_c_set_ratetable(wlc); - - /* update some band specific mac configuration */ - brcms_c_ucode_mac_upd(wlc); - - /* init antenna selection */ - brcms_c_antsel_init(wlc->asi); - -} - -/* switch to and initialize new band */ -static void brcms_c_setband(struct brcms_c_info *wlc, - uint bandunit) -{ - int idx; - struct brcms_bss_cfg *cfg; - - wlc->band = wlc->bandstate[bandunit]; - - if (!wlc->pub->up) - return; - - /* wait for at least one beacon before entering sleeping state */ - for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { - cfg = wlc->bsscfg[idx]; - if (cfg && BSSCFG_STA(cfg) && cfg->associated) - cfg->PMawakebcn = true; - } - brcms_c_set_ps_ctrl(wlc); - - /* band-specific initializations */ - brcms_c_bsinit(wlc); -} - /* * Initialize a WME Parameter Info Element with default * STA parameters from WMM Spec, Table 12 @@ -4142,6 +4038,213 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) } +/* maintain LED behavior in down state */ +static void brcms_c_down_led_upd(struct brcms_c_info *wlc) +{ + /* + * maintain LEDs while in down state, turn on sbclk if + * not available yet. Turn on sbclk if necessary + */ + if (!AP_ENAB(wlc->pub)) { + brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); + + brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); + } +} + +static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc) +{ + /* Don't start the timer if HWRADIO feature is disabled */ + if (wlc->radio_monitor || (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO)) + return true; + + wlc->radio_monitor = true; + brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_RADIO_MON); + brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, + true); + return true; +} + +void brcms_c_radio_disable(struct brcms_c_info *wlc) +{ + if (!wlc->pub->up) { + brcms_c_down_led_upd(wlc); + return; + } + + brcms_c_radio_monitor_start(wlc); + brcms_down(wlc->wl); +} + +static void brcms_c_radio_enable(struct brcms_c_info *wlc) +{ + if (wlc->pub->up) + return; + + if (DEVICEREMOVED(wlc)) + return; + + brcms_up(wlc->wl); +} + +bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) +{ + if (!wlc->radio_monitor) + return true; + + wlc->radio_monitor = false; + brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_RADIO_MON); + return brcms_del_timer(wlc->wl, wlc->radio_timer); +} + +/* read hwdisable state and propagate to wlc flag */ +static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) +{ + if (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO || wlc->pub->hw_off) + return; + + if (brcms_b_radio_read_hwdisabled(wlc->hw)) + mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); + else + mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); +} + +/* + * centralized radio disable/enable function, + * invoke radio enable/disable after updating hwradio status + */ +static void brcms_c_radio_upd(struct brcms_c_info *wlc) +{ + if (wlc->pub->radio_disabled) + brcms_c_radio_disable(wlc); + else + brcms_c_radio_enable(wlc); +} + +/* update hwradio status and return it */ +bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) +{ + brcms_c_radio_hwdisable_upd(wlc); + + return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? + true : false; +} + +/* periodical query hw radio button while driver is "down" */ +static void brcms_c_radio_timer(void *arg) +{ + struct brcms_c_info *wlc = (struct brcms_c_info *) arg; + + if (DEVICEREMOVED(wlc)) { + wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, + __func__); + brcms_down(wlc->wl); + return; + } + + /* cap mpc off count */ + if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) + wlc->mpc_offcnt++; + + brcms_c_radio_hwdisable_upd(wlc); + brcms_c_radio_upd(wlc); +} + +/* common low-level watchdog code */ +void brcms_b_watchdog(void *arg) +{ + struct brcms_c_info *wlc = (struct brcms_c_info *) arg; + struct brcms_hardware *wlc_hw = wlc->hw; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); + + if (!wlc_hw->up) + return; + + /* increment second count */ + wlc_hw->now++; + + /* Check for FIFO error interrupts */ + brcms_b_fifoerrors(wlc_hw); + + /* make sure RX dma has buffers */ + dma_rxfill(wlc->hw->di[RX_FIFO]); + + wlc_phy_watchdog(wlc_hw->band->pi); +} + +/* common watchdog code */ +static void brcms_c_watchdog(void *arg) +{ + struct brcms_c_info *wlc = (struct brcms_c_info *) arg; + int i; + struct brcms_bss_cfg *cfg; + + BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); + + if (!wlc->pub->up) + return; + + if (DEVICEREMOVED(wlc)) { + wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, + __func__); + brcms_down(wlc->wl); + return; + } + + /* increment second count */ + wlc->pub->now++; + + /* delay radio disable */ + if (wlc->mpc_delay_off) { + if (--wlc->mpc_delay_off == 0) { + mboolset(wlc->pub->radio_disabled, + WL_RADIO_MPC_DISABLE); + if (wlc->mpc && brcms_c_ismpc(wlc)) + wlc->mpc_offcnt = 0; + wlc->mpc_laston_ts = OSL_SYSUPTIME(); + } + } + + /* mpc sync */ + brcms_c_radio_mpc_upd(wlc); + /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ + brcms_c_radio_hwdisable_upd(wlc); + brcms_c_radio_upd(wlc); + /* if radio is disable, driver may be down, quit here */ + if (wlc->pub->radio_disabled) + return; + + brcms_b_watchdog(wlc); + + /* + * occasionally sample mac stat counters to + * detect 16-bit counter wrap + */ + if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) + brcms_c_statsupd(wlc); + + /* Manage TKIP countermeasures timers */ + FOREACH_BSS(wlc, i, cfg) + if (cfg->tk_cm_dt) + cfg->tk_cm_dt--; + if (cfg->tk_cm_bt) + cfg->tk_cm_bt--; + END_FOREACH_BSS() + + if (BRCMS_ISNPHY(wlc->band) && !wlc->pub->tempsense_disable && + ((wlc->pub->now - wlc->tempsense_lasttime) >= + BRCMS_TEMPSENSE_PERIOD)) { + wlc->tempsense_lasttime = wlc->pub->now; + brcms_c_tempsense_upd(wlc); + } +} + +static void brcms_c_watchdog_by_timer(void *arg) +{ + brcms_c_watchdog(arg); +} + bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) { wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, @@ -4637,6 +4740,188 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, return err; } +static void brcms_c_attach_antgain_init(struct brcms_c_info *wlc) +{ + uint unit; + unit = wlc->pub->unit; + + if ((wlc->band->antgain == -1) && (wlc->pub->sromrev == 1)) { + /* default antenna gain for srom rev 1 is 2 dBm (8 qdbm) */ + wlc->band->antgain = 8; + } else if (wlc->band->antgain == -1) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" + " srom, using 2dB\n", unit, __func__); + wlc->band->antgain = 8; + } else { + s8 gain, fract; + /* Older sroms specified gain in whole dbm only. In order + * be able to specify qdbm granularity and remain backward + * compatible the whole dbms are now encoded in only + * low 6 bits and remaining qdbms are encoded in the hi 2 bits. + * 6 bit signed number ranges from -32 - 31. + * + * Examples: + * 0x1 = 1 db, + * 0xc1 = 1.75 db (1 + 3 quarters), + * 0x3f = -1 (-1 + 0 quarters), + * 0x7f = -.75 (-1 + 1 quarters) = -3 qdbm. + * 0xbf = -.50 (-1 + 2 quarters) = -2 qdbm. + */ + gain = wlc->band->antgain & 0x3f; + gain <<= 2; /* Sign extend */ + gain >>= 2; + fract = (wlc->band->antgain & 0xc0) >> 6; + wlc->band->antgain = 4 * gain + fract; + } +} + +static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) +{ + int aa; + uint unit; + char *vars; + int bandtype; + + unit = wlc->pub->unit; + vars = wlc->pub->vars; + bandtype = wlc->band->bandtype; + + /* get antennas available */ + aa = (s8) getintvar(vars, (BAND_5G(bandtype) ? "aa5g" : "aa2g")); + if (aa == 0) + aa = (s8) getintvar(vars, + (BAND_5G(bandtype) ? "aa1" : "aa0")); + if ((aa < 1) || (aa > 15)) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" + " srom (0x%x), using 3\n", unit, __func__, aa); + aa = 3; + } + + /* reset the defaults if we have a single antenna */ + if (aa == 1) { + wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; + wlc->stf->txant = ANT_TX_FORCE_0; + } else if (aa == 2) { + wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; + wlc->stf->txant = ANT_TX_FORCE_1; + } else { + } + + /* Compute Antenna Gain */ + wlc->band->antgain = + (s8) getintvar(vars, (BAND_5G(bandtype) ? "ag1" : "ag0")); + brcms_c_attach_antgain_init(wlc); + + return true; +} + +static void brcms_c_bss_default_init(struct brcms_c_info *wlc) +{ + u16 chanspec; + struct brcms_band *band; + struct brcms_bss_info *bi = wlc->default_bss; + + /* init default and target BSS with some sane initial values */ + memset((char *)(bi), 0, sizeof(struct brcms_bss_info)); + bi->beacon_period = BEACON_INTERVAL_DEFAULT; + bi->dtim_period = DTIM_INTERVAL_DEFAULT; + + /* fill the default channel as the first valid channel + * starting from the 2G channels + */ + chanspec = CH20MHZ_CHSPEC(1); + wlc->home_chanspec = bi->chanspec = chanspec; + + /* find the band of our default channel */ + band = wlc->band; + if (NBANDS(wlc) > 1 && band->bandunit != CHSPEC_BANDUNIT(chanspec)) + band = wlc->bandstate[OTHERBANDUNIT(wlc)]; + + /* init bss rates to the band specific default rate set */ + brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, + band->bandtype, false, BRCMS_RATE_MASK_FULL, + (bool) N_ENAB(wlc->pub), CHSPEC_WLC_BW(chanspec), + wlc->stf->txstreams); + + if (N_ENAB(wlc->pub)) + bi->flags |= BRCMS_BSS_HT; +} + +static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) +{ + struct brcms_txq_info *qi, *p; + + qi = kzalloc(sizeof(struct brcms_txq_info), GFP_ATOMIC); + if (qi != NULL) { + /* + * Have enough room for control packets along with HI watermark + * Also, add room to txq for total psq packets if all the SCBs + * leave PS mode. The watermark for flowcontrol to OS packets + * will remain the same + */ + brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT, + (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT + + wlc->pub->psq_pkts_total); + + /* add this queue to the the global list */ + p = wlc->tx_queues; + if (p == NULL) { + wlc->tx_queues = qi; + } else { + while (p->next != NULL) + p = p->next; + p->next = qi; + } + } + return qi; +} + +static void brcms_c_txq_free(struct brcms_c_info *wlc, + struct brcms_txq_info *qi) +{ + struct brcms_txq_info *p; + + if (qi == NULL) + return; + + /* remove the queue from the linked list */ + p = wlc->tx_queues; + if (p == qi) + wlc->tx_queues = p->next; + else { + while (p != NULL && p->next != qi) + p = p->next; + if (p != NULL) + p->next = p->next->next; + } + + kfree(qi); +} + +static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) +{ + uint i; + struct brcms_band *band; + + for (i = 0; i < NBANDS(wlc); i++) { + if (IS_SINGLEBAND_5G(wlc->deviceid)) + i = BAND_5G_INDEX; + band = wlc->bandstate[i]; + if (band->bandtype == BRCM_BAND_5G) { + if ((bwcap == BRCMS_N_BW_40ALL) + || (bwcap == BRCMS_N_BW_20IN2G_40IN5G)) + band->mimo_cap_40 = true; + else + band->mimo_cap_40 = false; + } else { + if (bwcap == BRCMS_N_BW_40ALL) + band->mimo_cap_40 = true; + else + band->mimo_cap_40 = false; + } + } +} + /* * The common driver entry routine. Error codes should be unique */ @@ -4893,82 +5178,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, return NULL; } -static void brcms_c_attach_antgain_init(struct brcms_c_info *wlc) -{ - uint unit; - unit = wlc->pub->unit; - - if ((wlc->band->antgain == -1) && (wlc->pub->sromrev == 1)) { - /* default antenna gain for srom rev 1 is 2 dBm (8 qdbm) */ - wlc->band->antgain = 8; - } else if (wlc->band->antgain == -1) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" - " srom, using 2dB\n", unit, __func__); - wlc->band->antgain = 8; - } else { - s8 gain, fract; - /* Older sroms specified gain in whole dbm only. In order - * be able to specify qdbm granularity and remain backward - * compatible the whole dbms are now encoded in only - * low 6 bits and remaining qdbms are encoded in the hi 2 bits. - * 6 bit signed number ranges from -32 - 31. - * - * Examples: - * 0x1 = 1 db, - * 0xc1 = 1.75 db (1 + 3 quarters), - * 0x3f = -1 (-1 + 0 quarters), - * 0x7f = -.75 (-1 + 1 quarters) = -3 qdbm. - * 0xbf = -.50 (-1 + 2 quarters) = -2 qdbm. - */ - gain = wlc->band->antgain & 0x3f; - gain <<= 2; /* Sign extend */ - gain >>= 2; - fract = (wlc->band->antgain & 0xc0) >> 6; - wlc->band->antgain = 4 * gain + fract; - } -} - -static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) -{ - int aa; - uint unit; - char *vars; - int bandtype; - - unit = wlc->pub->unit; - vars = wlc->pub->vars; - bandtype = wlc->band->bandtype; - - /* get antennas available */ - aa = (s8) getintvar(vars, (BAND_5G(bandtype) ? "aa5g" : "aa2g")); - if (aa == 0) - aa = (s8) getintvar(vars, - (BAND_5G(bandtype) ? "aa1" : "aa0")); - if ((aa < 1) || (aa > 15)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" - " srom (0x%x), using 3\n", unit, __func__, aa); - aa = 3; - } - - /* reset the defaults if we have a single antenna */ - if (aa == 1) { - wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; - wlc->stf->txant = ANT_TX_FORCE_0; - } else if (aa == 2) { - wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; - wlc->stf->txant = ANT_TX_FORCE_1; - } else { - } - - /* Compute Antenna Gain */ - wlc->band->antgain = - (s8) getintvar(vars, (BAND_5G(bandtype) ? "ag1" : "ag0")); - brcms_c_attach_antgain_init(wlc); - - return true; -} - - static void brcms_c_timers_deinit(struct brcms_c_info *wlc) { /* free timer state */ @@ -5102,18 +5311,6 @@ void brcms_c_ap_upd(struct brcms_c_info *wlc) wlc->mpc = true; } -/* read hwdisable state and propagate to wlc flag */ -static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) -{ - if (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO || wlc->pub->hw_off) - return; - - if (brcms_b_radio_read_hwdisabled(wlc->hw)) - mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - else - mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); -} - /* * return true if Minimum Power Consumption should * be entered, false otherwise @@ -5182,202 +5379,6 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); } - -/* - * centralized radio disable/enable function, - * invoke radio enable/disable after updating hwradio status - */ -static void brcms_c_radio_upd(struct brcms_c_info *wlc) -{ - if (wlc->pub->radio_disabled) - brcms_c_radio_disable(wlc); - else - brcms_c_radio_enable(wlc); -} - -/* maintain LED behavior in down state */ -static void brcms_c_down_led_upd(struct brcms_c_info *wlc) -{ - /* - * maintain LEDs while in down state, turn on sbclk if - * not available yet. Turn on sbclk if necessary - */ - if (!AP_ENAB(wlc->pub)) { - brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); - - brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); - } -} - -/* update hwradio status and return it */ -bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) -{ - brcms_c_radio_hwdisable_upd(wlc); - - return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? - true : false; -} - -void brcms_c_radio_disable(struct brcms_c_info *wlc) -{ - if (!wlc->pub->up) { - brcms_c_down_led_upd(wlc); - return; - } - - brcms_c_radio_monitor_start(wlc); - brcms_down(wlc->wl); -} - -static void brcms_c_radio_enable(struct brcms_c_info *wlc) -{ - if (wlc->pub->up) - return; - - if (DEVICEREMOVED(wlc)) - return; - - brcms_up(wlc->wl); -} - -/* periodical query hw radio button while driver is "down" */ -static void brcms_c_radio_timer(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - - if (DEVICEREMOVED(wlc)) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, - __func__); - brcms_down(wlc->wl); - return; - } - - /* cap mpc off count */ - if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) - wlc->mpc_offcnt++; - - brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); -} - -static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc) -{ - /* Don't start the timer if HWRADIO feature is disabled */ - if (wlc->radio_monitor || (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO)) - return true; - - wlc->radio_monitor = true; - brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_RADIO_MON); - brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, - true); - return true; -} - -bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) -{ - if (!wlc->radio_monitor) - return true; - - wlc->radio_monitor = false; - brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_RADIO_MON); - return brcms_del_timer(wlc->wl, wlc->radio_timer); -} - -/* common low-level watchdog code */ -void brcms_b_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return; - - /* increment second count */ - wlc_hw->now++; - - /* Check for FIFO error interrupts */ - brcms_b_fifoerrors(wlc_hw); - - /* make sure RX dma has buffers */ - dma_rxfill(wlc->hw->di[RX_FIFO]); - - wlc_phy_watchdog(wlc_hw->band->pi); -} - -static void brcms_c_watchdog_by_timer(void *arg) -{ - brcms_c_watchdog(arg); -} - -/* common watchdog code */ -static void brcms_c_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - int i; - struct brcms_bss_cfg *cfg; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - if (!wlc->pub->up) - return; - - if (DEVICEREMOVED(wlc)) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, - __func__); - brcms_down(wlc->wl); - return; - } - - /* increment second count */ - wlc->pub->now++; - - /* delay radio disable */ - if (wlc->mpc_delay_off) { - if (--wlc->mpc_delay_off == 0) { - mboolset(wlc->pub->radio_disabled, - WL_RADIO_MPC_DISABLE); - if (wlc->mpc && brcms_c_ismpc(wlc)) - wlc->mpc_offcnt = 0; - wlc->mpc_laston_ts = OSL_SYSUPTIME(); - } - } - - /* mpc sync */ - brcms_c_radio_mpc_upd(wlc); - /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ - brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); - /* if radio is disable, driver may be down, quit here */ - if (wlc->pub->radio_disabled) - return; - - brcms_b_watchdog(wlc); - - /* - * occasionally sample mac stat counters to - * detect 16-bit counter wrap - */ - if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) - brcms_c_statsupd(wlc); - - /* Manage TKIP countermeasures timers */ - FOREACH_BSS(wlc, i, cfg) - if (cfg->tk_cm_dt) - cfg->tk_cm_dt--; - if (cfg->tk_cm_bt) - cfg->tk_cm_bt--; - END_FOREACH_BSS() - - if (BRCMS_ISNPHY(wlc->band) && !wlc->pub->tempsense_disable && - ((wlc->pub->now - wlc->tempsense_lasttime) >= - BRCMS_TEMPSENSE_PERIOD)) { - wlc->tempsense_lasttime = wlc->pub->now; - brcms_c_tempsense_upd(wlc); - } -} - /* Initialize just the hardware when coming out of POR or S3/S5 system states */ void brcms_b_hw_up(struct brcms_hardware *wlc_hw) { @@ -5478,6 +5479,23 @@ int brcms_b_up_finish(struct brcms_hardware *wlc_hw) return 0; } +/* + * Write WME tunable parameters for retransmit/max rate + * from wlc struct to ucode + */ +static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) +{ + int ac; + + /* Need clock to do this */ + if (!wlc->clk) + return; + + for (ac = 0; ac < AC_COUNT; ac++) + brcms_c_write_shm(wlc, M_AC_TXLMT_ADDR(ac), + wlc->wme_retries[ac]); +} + /* make interface operational */ int brcms_c_up(struct brcms_c_info *wlc) { @@ -5586,30 +5604,6 @@ int brcms_c_up(struct brcms_c_info *wlc) return 0; } -/* - * Initialize the base precedence map for dequeueing - * from txq based on WME settings - */ -static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc) -{ - wlc->tx_prec_map = BRCMS_PREC_BMP_ALL; - memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16)); - - /* - * For non-WME, both fifos have overlapping MAXPRIO. So just - * disable all precedences if either is full. - */ - if (!EDCF_ENAB(wlc->pub)) { - wlc->fifo2prec_map[TX_DATA_FIFO] = BRCMS_PREC_BMP_ALL; - wlc->fifo2prec_map[TX_CTL_FIFO] = BRCMS_PREC_BMP_ALL; - } else { - wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK; - wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE; - wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI; - wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO; - } -} - static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) { uint callbacks = 0; @@ -6057,13 +6051,6 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) return; } -int -brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, - struct brcms_c_if *wlcif) -{ - return _brcms_c_ioctl(wlc, cmd, arg, len, wlcif); -} - /* common ioctl handler. return: 0=ok, -1=error, positive=particular error */ static int _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, @@ -6314,6 +6301,13 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, return bcmerror; } +int +brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, + struct brcms_c_if *wlcif) +{ + return _brcms_c_ioctl(wlc, cmd, arg, len, wlcif); +} + /* * register watchdog and down handlers. */ @@ -6360,23 +6354,6 @@ int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, return -ENODATA; } -/* - * Write WME tunable parameters for retransmit/max rate - * from wlc struct to ucode - */ -static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) -{ - int ac; - - /* Need clock to do this */ - if (!wlc->clk) - return; - - for (ac = 0; ac < AC_COUNT; ac++) - brcms_c_write_shm(wlc, M_AC_TXLMT_ADDR(ac), - wlc->wme_retries[ac]); -} - #ifdef BCMDBG static const char * const supr_reason[] = { "None", "PMQ Entry", "Flush request", @@ -6759,100 +6736,6 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, } } -bool -brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, - struct ieee80211_hw *hw) -{ - u8 prio; - uint fifo; - struct scb *scb = &global_scb; - struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); - - /* - * 802.11 standard requires management traffic - * to go at highest priority - */ - prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : - MAXPRIO; - fifo = prio2fifo[prio]; - if (unlikely - (brcms_c_d11hdrs_mac80211( - wlc, hw, sdu, scb, 0, 1, fifo, 0, NULL, 0))) - return -EINVAL; - brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); - brcms_c_send_q(wlc); - return 0; -} - -void brcms_c_send_q(struct brcms_c_info *wlc) -{ - struct sk_buff *pkt[DOT11_MAXNUMFRAGS]; - int prec; - u16 prec_map; - int err = 0, i, count; - uint fifo; - struct brcms_txq_info *qi = wlc->pkt_queue; - struct pktq *q = &qi->q; - struct ieee80211_tx_info *tx_info; - - if (in_send_q) - return; - else - in_send_q = true; - - prec_map = wlc->tx_prec_map; - - /* Send all the enq'd pkts that we can. - * Dequeue packets with precedence with empty HW fifo only - */ - while (prec_map && (pkt[0] = brcmu_pktq_mdeq(q, prec_map, &prec))) { - tx_info = IEEE80211_SKB_CB(pkt[0]); - if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { - err = brcms_c_sendampdu(wlc->ampdu, qi, pkt, prec); - } else { - count = 1; - err = brcms_c_prep_pdu(wlc, pkt[0], &fifo); - if (!err) { - for (i = 0; i < count; i++) - brcms_c_txfifo(wlc, fifo, pkt[i], true, - 1); - } - } - - if (err == -EBUSY) { - brcmu_pktq_penq_head(q, prec, pkt[0]); - /* - * If send failed due to any other reason than a - * change in HW FIFO condition, quit. Otherwise, - * read the new prec_map! - */ - if (prec_map == wlc->tx_prec_map) - break; - prec_map = wlc->tx_prec_map; - } - } - - /* - * Check if flow control needs to be turned off after - * sending the packet - */ - if (!EDCF_ENAB(wlc->pub) - || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { - if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) - && (pktq_len(q) < wlc->pub->tunables->datahiwat / 2)) - brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); - } else if (wlc->pub->_priofc) { - int prio; - for (prio = MAXPRIO; prio >= 0; prio--) { - if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && - (pktq_plen(q, wlc_prio2prec_map[prio]) < - wlc->pub->tunables->datahiwat / 2)) - brcms_c_txflowcontrol(wlc, qi, OFF, prio); - } - } - in_send_q = false; -} - /* * bcmc_fid_generate: * Generate frame ID for a BCMC packet. The frag field is not used @@ -6874,155 +6757,52 @@ bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, return frameid; } -void -brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, - bool commit, s8 txpktpend) +static uint +brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, + u8 preamble_type) { - u16 frameid = INVALIDFID; - struct d11txh *txh; - - txh = (struct d11txh *) (p->data); - - /* When a BC/MC frame is being committed to the BCMC fifo - * via DMA (NOT PIO), update ucode or BSS info as appropriate. - */ - if (fifo == TX_BCMC_FIFO) - frameid = le16_to_cpu(txh->TxFrameID); - - if (BRCMS_WAR16165(wlc)) - brcms_c_war16165(wlc, true); - + uint dur = 0; + BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n", + wlc->pub->unit, rspec, preamble_type); /* - * Bump up pending count for if not using rpc. If rpc is - * used, this will be handled in brcms_b_txfifo() + * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that + * is less than or equal to the rate of the immediately previous + * frame in the FES */ - if (commit) { - TXPKTPENDINC(wlc, fifo, txpktpend); - BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n", - txpktpend, TXPKTPENDGET(wlc, fifo)); - } - - /* Commit BCMC sequence number in the SHM frame ID location */ - if (frameid != INVALIDFID) - BCMCFID(wlc, frameid); - - if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) - wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); + rspec = BRCMS_BASIC_RATE(wlc, rspec); + /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ + dur = + brcms_c_calc_frame_time(wlc, rspec, preamble_type, + (DOT11_ACK_LEN + FCS_LEN)); + return dur; } -void -brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, - uint length, u8 *plcp) +static uint +brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, + u8 preamble_type) { - if (IS_MCS(rspec)) - brcms_c_compute_mimo_plcp(rspec, length, plcp); - else if (IS_OFDM(rspec)) - brcms_c_compute_ofdm_plcp(rspec, length, plcp); - else - brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); - return; + BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n", + wlc->pub->unit, rspec, preamble_type); + return brcms_c_calc_ack_time(wlc, rspec, preamble_type); } -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) +static uint +brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, + u8 preamble_type) { - u8 mcs = (u8) (rspec & RSPEC_RATE_MASK); - plcp[0] = mcs; - if (RSPEC_IS40MHZ(rspec) || (mcs == 32)) - plcp[0] |= MIMO_PLCP_40MHZ; - BRCMS_SET_MIMO_PLCP_LEN(plcp, length); - plcp[3] = RSPEC_MIMOPLCP3(rspec); /* rspec already holds this byte */ - plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ - plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ - plcp[5] = 0; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void -brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) -{ - u8 rate_signal; - u32 tmp = 0; - int rate = RSPEC2RATE(rspec); - + BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, " + "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type); /* - * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb - * transmitted first + * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that + * is less than or equal to the rate of the immediately previous + * frame in the FES */ - rate_signal = rate_info[rate] & BRCMS_RATE_MASK; - memset(plcp, 0, D11_PHY_HDR_LEN); - D11A_PHY_HDR_SRATE((struct ofdm_phy_hdr *) plcp, rate_signal); - - tmp = (length & 0xfff) << 5; - plcp[2] |= (tmp >> 16) & 0xff; - plcp[1] |= (tmp >> 8) & 0xff; - plcp[0] |= tmp & 0xff; - - return; -} - -/* - * Compute PLCP, but only requires actual rate and length of pkt. - * Rate is given in the driver standard multiple of 500 kbps. - * le is set for 11 Mbps rate if necessary. - * Broken out for PRQ. - */ - -static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, - uint length, u8 *plcp) -{ - u16 usec = 0; - u8 le = 0; - - switch (rate_500) { - case BRCM_RATE_1M: - usec = length << 3; - break; - case BRCM_RATE_2M: - usec = length << 2; - break; - case BRCM_RATE_5M5: - usec = (length << 4) / 11; - if ((length << 4) - (usec * 11) > 0) - usec++; - break; - case BRCM_RATE_11M: - usec = (length << 3) / 11; - if ((length << 3) - (usec * 11) > 0) { - usec++; - if ((usec * 11) - (length << 3) >= 8) - le = D11B_PLCP_SIGNAL_LE; - } - break; - - default: - wiphy_err(wlc->wiphy, - "brcms_c_cck_plcp_set: unsupported rate %d\n", - rate_500); - rate_500 = BRCM_RATE_1M; - usec = length << 3; - break; - } - /* PLCP signal byte */ - plcp[0] = rate_500 * 5; /* r (500kbps) * 5 == r (100kbps) */ - /* PLCP service byte */ - plcp[1] = (u8) (le | D11B_PLCP_SIGNAL_LOCKED); - /* PLCP length u16, little endian */ - plcp[2] = usec & 0xff; - plcp[3] = (usec >> 8) & 0xff; - /* PLCP CRC16 */ - plcp[4] = 0; - plcp[5] = 0; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, - uint length, u8 *plcp) -{ - int rate = RSPEC2RATE(rspec); - - brcms_c_cck_plcp_set(wlc, rate, length, plcp); + rspec = BRCMS_BASIC_RATE(wlc, rspec); + /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ + return brcms_c_calc_frame_time(wlc, rspec, preamble_type, + (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + + FCS_LEN)); } /* brcms_c_compute_frame_dur() @@ -7058,147 +6838,167 @@ brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, return dur; } -/* brcms_c_compute_rtscts_dur() - * - * Calculate the 802.11 MAC header DUR field for an RTS or CTS frame - * DUR for normal RTS/CTS w/ frame = 3 SIFS + 1 CTS + next frame time + 1 ACK - * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK - * - * cts cts-to-self or rts/cts - * rts_rate rts or cts rate in unit of 500kbps - * rate next MPDU rate in unit of 500kbps - * frame_len next MPDU frame length in bytes - */ -u16 -brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, - u32 rts_rate, - u32 frame_rate, u8 rts_preamble_type, - u8 frame_preamble_type, uint frame_len, bool ba) +/* The opposite of brcms_c_calc_frame_time */ +static uint +brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, + u8 preamble_type, uint dur) { - u16 dur, sifs; + uint nsyms, mac_len, Ndps, kNdps; + uint rate = RSPEC2RATE(ratespec); - sifs = SIFS(wlc->band); + BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n", + wlc->pub->unit, ratespec, preamble_type, dur); - if (!cts_only) { - /* RTS/CTS */ - dur = 3 * sifs; - dur += - (u16) brcms_c_calc_cts_time(wlc, rts_rate, - rts_preamble_type); + if (IS_MCS(ratespec)) { + uint mcs = ratespec & RSPEC_RATE_MASK; + int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec); + dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); + /* payload calculation matches that of regular ofdm */ + if (BAND_2G(wlc->band->bandtype)) + dur -= DOT11_OFDM_SIGNAL_EXTENSION; + /* kNdbps = kbps * 4 */ + kNdps = + MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), + RSPEC_ISSGI(ratespec)) * 4; + nsyms = dur / APHY_SYMBOL_TIME; + mac_len = + ((nsyms * kNdps) - + ((APHY_SERVICE_NBITS + APHY_TAIL_NBITS) * 1000)) / 8000; + } else if (IS_OFDM(ratespec)) { + dur -= APHY_PREAMBLE_TIME; + dur -= APHY_SIGNAL_TIME; + /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ + Ndps = rate * 2; + nsyms = dur / APHY_SYMBOL_TIME; + mac_len = + ((nsyms * Ndps) - + (APHY_SERVICE_NBITS + APHY_TAIL_NBITS)) / 8; } else { - /* CTS-TO-SELF */ - dur = 2 * sifs; - } - - dur += - (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, - frame_len); - if (ba) - dur += - (u16) brcms_c_calc_ba_time(wlc, frame_rate, - BRCMS_SHORT_PREAMBLE); - else - dur += - (u16) brcms_c_calc_ack_time(wlc, frame_rate, - frame_preamble_type); - return dur; -} - -u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) -{ - u16 phyctl1 = 0; - u16 bw; - - if (BRCMS_ISLCNPHY(wlc->band)) { - bw = PHY_TXC1_BW_20MHZ; - } else { - bw = RSPEC_GET_BW(rspec); - /* 10Mhz is not supported yet */ - if (bw < PHY_TXC1_BW_20MHZ) { - wiphy_err(wlc->wiphy, "phytxctl1_calc: bw %d is " - "not supported yet, set to 20L\n", bw); - bw = PHY_TXC1_BW_20MHZ; - } - } - - if (IS_MCS(rspec)) { - uint mcs = rspec & RSPEC_RATE_MASK; - - /* bw, stf, coding-type is part of RSPEC_PHYTXBYTE2 returns */ - phyctl1 = RSPEC_PHYTXBYTE2(rspec); - /* set the upper byte of phyctl1 */ - phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 << 8); - } else if (IS_CCK(rspec) && !BRCMS_ISLCNPHY(wlc->band) - && !BRCMS_ISSSLPNPHY(wlc->band)) { - /* - * In CCK mode LPPHY overloads OFDM Modulation bits with CCK - * Data Rate. Eventually MIMOPHY would also be converted to - * this format - */ - /* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ - phyctl1 = (bw | (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); - } else { /* legacy OFDM/CCK */ - s16 phycfg; - /* get the phyctl byte from rate phycfg table */ - phycfg = brcms_c_rate_legacy_phyctl(RSPEC2RATE(rspec)); - if (phycfg == -1) { - wiphy_err(wlc->wiphy, "phytxctl1_calc: wrong " - "legacy OFDM/CCK rate\n"); - phycfg = 0; - } - /* set the upper byte of phyctl1 */ - phyctl1 = - (bw | (phycfg << 8) | - (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); - } - return phyctl1; -} - -u32 -brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, - bool use_rspec, u16 mimo_ctlchbw) -{ - u32 rts_rspec = 0; - - if (use_rspec) - /* use frame rate as rts rate */ - rts_rspec = rspec; - else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) - /* Use 11Mbps as the g protection RTS target rate and fallback. - * Use the BRCMS_BASIC_RATE() lookup to find the best basic rate - * under the target in case 11 Mbps is not Basic. - * 6 and 9 Mbps are not usually selected by rate selection, but - * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 - * is more robust. - */ - rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); - else - /* calculate RTS rate and fallback rate based on the frame rate - * RTS must be sent at a basic rate since it is a - * control frame, sec 9.6 of 802.11 spec - */ - rts_rspec = BRCMS_BASIC_RATE(wlc, rspec); - - if (BRCMS_PHY_11N_CAP(wlc->band)) { - /* set rts txbw to correct side band */ - rts_rspec &= ~RSPEC_BW_MASK; - - /* - * if rspec/rspec_fallback is 40MHz, then send RTS on both - * 20MHz channel (DUP), otherwise send RTS on control channel - */ - if (RSPEC_IS40MHZ(rspec) && !IS_CCK(rts_rspec)) - rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT); + if (preamble_type & BRCMS_SHORT_PREAMBLE) + dur -= BPHY_PLCP_SHORT_TIME; else - rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT); + dur -= BPHY_PLCP_TIME; + mac_len = dur * rate; + /* divide out factor of 2 in rate (1/2 mbps) */ + mac_len = mac_len / 8 / 2; + } + return mac_len; +} - /* pick siso/cdd as default for ofdm */ - if (IS_OFDM(rts_rspec)) { - rts_rspec &= ~RSPEC_STF_MASK; - rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); +static u32 +mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, + u32 int_val) +{ + u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT; + u8 rate = int_val & NRATE_RATE_MASK; + u32 rspec; + bool ismcs = ((int_val & NRATE_MCS_INUSE) == NRATE_MCS_INUSE); + bool issgi = ((int_val & NRATE_SGI_MASK) >> NRATE_SGI_SHIFT); + bool override_mcs_only = ((int_val & NRATE_OVERRIDE_MCS_ONLY) + == NRATE_OVERRIDE_MCS_ONLY); + int bcmerror = 0; + + if (!ismcs) + return (u32) rate; + + /* validate the combination of rate/mcs/stf is allowed */ + if (N_ENAB(wlc->pub) && ismcs) { + /* mcs only allowed when nmode */ + if (stf > PHY_TXC1_MODE_SDM) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", + BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + + /* mcs 32 is a special case, DUP mode 40 only */ + if (rate == 32) { + if (!CHSPEC_IS40(wlc->home_chanspec) || + ((stf != PHY_TXC1_MODE_SISO) + && (stf != PHY_TXC1_MODE_CDD))) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs " + "32\n", BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + /* mcs > 7 must use stf SDM */ + } else if (rate > HIGHEST_SINGLE_STREAM_MCS) { + /* mcs > 7 must use stf SDM */ + if (stf != PHY_TXC1_MODE_SDM) { + BCMMSG(wlc->wiphy, "wl%d: enabling " + "SDM mode for mcs %d\n", + BRCMS_UNIT(wlc), rate); + stf = PHY_TXC1_MODE_SDM; + } + } else { + /* + * MCS 0-7 may use SISO, CDD, and for + * phy_rev >= 3 STBC + */ + if ((stf > PHY_TXC1_MODE_STBC) || + (!BRCMS_STBC_CAP_PHY(wlc) + && (stf == PHY_TXC1_MODE_STBC))) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC" + "\n", BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + } + } else if (IS_OFDM(rate)) { + if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", + BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + } else if (IS_CCK(rate)) { + if ((cur_band->bandtype != BRCM_BAND_2G) + || (stf != PHY_TXC1_MODE_SISO)) { + wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", + BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + } else { + wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n", + BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + /* make sure multiple antennae are available for non-siso rates */ + if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { + wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO " + "request\n", BRCMS_UNIT(wlc), __func__); + bcmerror = -EINVAL; + goto done; + } + + rspec = rate; + if (ismcs) { + rspec |= RSPEC_MIMORATE; + /* For STBC populate the STC field of the ratespec */ + if (stf == PHY_TXC1_MODE_STBC) { + u8 stc; + stc = 1; /* Nss for single stream is always 1 */ + rspec |= (stc << RSPEC_STC_SHIFT); } } - return rts_rspec; + + rspec |= (stf << RSPEC_STF_SHIFT); + + if (override_mcs_only) + rspec |= RSPEC_OVERRIDE_MCS_ONLY; + + if (issgi) + rspec |= RSPEC_SHORT_GI; + + if ((rate != 0) + && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) + return rate; + + return rspec; +done: + return rate; } /* @@ -7866,16 +7666,98 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, return 0; } -void brcms_c_tbtt(struct brcms_c_info *wlc) +bool +brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, + struct ieee80211_hw *hw) { - struct brcms_bss_cfg *cfg = wlc->cfg; + u8 prio; + uint fifo; + struct scb *scb = &global_scb; + struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); - if (!cfg->BSS) - /* - * DirFrmQ is now valid...defer setting until end - * of ATIM window - */ - wlc->qvalid |= MCMD_DIRFRMQVAL; + /* + * 802.11 standard requires management traffic + * to go at highest priority + */ + prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : + MAXPRIO; + fifo = prio2fifo[prio]; + if (unlikely + (brcms_c_d11hdrs_mac80211( + wlc, hw, sdu, scb, 0, 1, fifo, 0, NULL, 0))) + return -EINVAL; + brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); + brcms_c_send_q(wlc); + return 0; +} + +void brcms_c_send_q(struct brcms_c_info *wlc) +{ + struct sk_buff *pkt[DOT11_MAXNUMFRAGS]; + int prec; + u16 prec_map; + int err = 0, i, count; + uint fifo; + struct brcms_txq_info *qi = wlc->pkt_queue; + struct pktq *q = &qi->q; + struct ieee80211_tx_info *tx_info; + + if (in_send_q) + return; + else + in_send_q = true; + + prec_map = wlc->tx_prec_map; + + /* Send all the enq'd pkts that we can. + * Dequeue packets with precedence with empty HW fifo only + */ + while (prec_map && (pkt[0] = brcmu_pktq_mdeq(q, prec_map, &prec))) { + tx_info = IEEE80211_SKB_CB(pkt[0]); + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { + err = brcms_c_sendampdu(wlc->ampdu, qi, pkt, prec); + } else { + count = 1; + err = brcms_c_prep_pdu(wlc, pkt[0], &fifo); + if (!err) { + for (i = 0; i < count; i++) + brcms_c_txfifo(wlc, fifo, pkt[i], true, + 1); + } + } + + if (err == -EBUSY) { + brcmu_pktq_penq_head(q, prec, pkt[0]); + /* + * If send failed due to any other reason than a + * change in HW FIFO condition, quit. Otherwise, + * read the new prec_map! + */ + if (prec_map == wlc->tx_prec_map) + break; + prec_map = wlc->tx_prec_map; + } + } + + /* + * Check if flow control needs to be turned off after + * sending the packet + */ + if (!EDCF_ENAB(wlc->pub) + || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { + if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) + && (pktq_len(q) < wlc->pub->tunables->datahiwat / 2)) + brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); + } else if (wlc->pub->_priofc) { + int prio; + for (prio = MAXPRIO; prio >= 0; prio--) { + if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && + (pktq_plen(q, wlc_prio2prec_map[prio]) < + wlc->pub->tunables->datahiwat / 2)) + brcms_c_txflowcontrol(wlc, qi, OFF, prio); + } + } + in_send_q = false; } static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) @@ -7891,6 +7773,312 @@ static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) } } +void +brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, + bool commit, s8 txpktpend) +{ + u16 frameid = INVALIDFID; + struct d11txh *txh; + + txh = (struct d11txh *) (p->data); + + /* When a BC/MC frame is being committed to the BCMC fifo + * via DMA (NOT PIO), update ucode or BSS info as appropriate. + */ + if (fifo == TX_BCMC_FIFO) + frameid = le16_to_cpu(txh->TxFrameID); + + if (BRCMS_WAR16165(wlc)) + brcms_c_war16165(wlc, true); + + + /* + * Bump up pending count for if not using rpc. If rpc is + * used, this will be handled in brcms_b_txfifo() + */ + if (commit) { + TXPKTPENDINC(wlc, fifo, txpktpend); + BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n", + txpktpend, TXPKTPENDGET(wlc, fifo)); + } + + /* Commit BCMC sequence number in the SHM frame ID location */ + if (frameid != INVALIDFID) + BCMCFID(wlc, frameid); + + if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) + wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); +} + +/* + * Compute PLCP, but only requires actual rate and length of pkt. + * Rate is given in the driver standard multiple of 500 kbps. + * le is set for 11 Mbps rate if necessary. + * Broken out for PRQ. + */ + +static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, + uint length, u8 *plcp) +{ + u16 usec = 0; + u8 le = 0; + + switch (rate_500) { + case BRCM_RATE_1M: + usec = length << 3; + break; + case BRCM_RATE_2M: + usec = length << 2; + break; + case BRCM_RATE_5M5: + usec = (length << 4) / 11; + if ((length << 4) - (usec * 11) > 0) + usec++; + break; + case BRCM_RATE_11M: + usec = (length << 3) / 11; + if ((length << 3) - (usec * 11) > 0) { + usec++; + if ((usec * 11) - (length << 3) >= 8) + le = D11B_PLCP_SIGNAL_LE; + } + break; + + default: + wiphy_err(wlc->wiphy, + "brcms_c_cck_plcp_set: unsupported rate %d\n", + rate_500); + rate_500 = BRCM_RATE_1M; + usec = length << 3; + break; + } + /* PLCP signal byte */ + plcp[0] = rate_500 * 5; /* r (500kbps) * 5 == r (100kbps) */ + /* PLCP service byte */ + plcp[1] = (u8) (le | D11B_PLCP_SIGNAL_LOCKED); + /* PLCP length u16, little endian */ + plcp[2] = usec & 0xff; + plcp[3] = (usec >> 8) & 0xff; + /* PLCP CRC16 */ + plcp[4] = 0; + plcp[5] = 0; +} + +/* Rate: 802.11 rate code, length: PSDU length in octets */ +static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) +{ + u8 mcs = (u8) (rspec & RSPEC_RATE_MASK); + plcp[0] = mcs; + if (RSPEC_IS40MHZ(rspec) || (mcs == 32)) + plcp[0] |= MIMO_PLCP_40MHZ; + BRCMS_SET_MIMO_PLCP_LEN(plcp, length); + plcp[3] = RSPEC_MIMOPLCP3(rspec); /* rspec already holds this byte */ + plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ + plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ + plcp[5] = 0; +} + +/* Rate: 802.11 rate code, length: PSDU length in octets */ +static void +brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) +{ + u8 rate_signal; + u32 tmp = 0; + int rate = RSPEC2RATE(rspec); + + /* + * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb + * transmitted first + */ + rate_signal = rate_info[rate] & BRCMS_RATE_MASK; + memset(plcp, 0, D11_PHY_HDR_LEN); + D11A_PHY_HDR_SRATE((struct ofdm_phy_hdr *) plcp, rate_signal); + + tmp = (length & 0xfff) << 5; + plcp[2] |= (tmp >> 16) & 0xff; + plcp[1] |= (tmp >> 8) & 0xff; + plcp[0] |= tmp & 0xff; + + return; +} + +/* Rate: 802.11 rate code, length: PSDU length in octets */ +static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, + uint length, u8 *plcp) +{ + int rate = RSPEC2RATE(rspec); + + brcms_c_cck_plcp_set(wlc, rate, length, plcp); +} + +void +brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, + uint length, u8 *plcp) +{ + if (IS_MCS(rspec)) + brcms_c_compute_mimo_plcp(rspec, length, plcp); + else if (IS_OFDM(rspec)) + brcms_c_compute_ofdm_plcp(rspec, length, plcp); + else + brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); + return; +} + +/* brcms_c_compute_rtscts_dur() + * + * Calculate the 802.11 MAC header DUR field for an RTS or CTS frame + * DUR for normal RTS/CTS w/ frame = 3 SIFS + 1 CTS + next frame time + 1 ACK + * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK + * + * cts cts-to-self or rts/cts + * rts_rate rts or cts rate in unit of 500kbps + * rate next MPDU rate in unit of 500kbps + * frame_len next MPDU frame length in bytes + */ +u16 +brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, + u32 rts_rate, + u32 frame_rate, u8 rts_preamble_type, + u8 frame_preamble_type, uint frame_len, bool ba) +{ + u16 dur, sifs; + + sifs = SIFS(wlc->band); + + if (!cts_only) { + /* RTS/CTS */ + dur = 3 * sifs; + dur += + (u16) brcms_c_calc_cts_time(wlc, rts_rate, + rts_preamble_type); + } else { + /* CTS-TO-SELF */ + dur = 2 * sifs; + } + + dur += + (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, + frame_len); + if (ba) + dur += + (u16) brcms_c_calc_ba_time(wlc, frame_rate, + BRCMS_SHORT_PREAMBLE); + else + dur += + (u16) brcms_c_calc_ack_time(wlc, frame_rate, + frame_preamble_type); + return dur; +} + +u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) +{ + u16 phyctl1 = 0; + u16 bw; + + if (BRCMS_ISLCNPHY(wlc->band)) { + bw = PHY_TXC1_BW_20MHZ; + } else { + bw = RSPEC_GET_BW(rspec); + /* 10Mhz is not supported yet */ + if (bw < PHY_TXC1_BW_20MHZ) { + wiphy_err(wlc->wiphy, "phytxctl1_calc: bw %d is " + "not supported yet, set to 20L\n", bw); + bw = PHY_TXC1_BW_20MHZ; + } + } + + if (IS_MCS(rspec)) { + uint mcs = rspec & RSPEC_RATE_MASK; + + /* bw, stf, coding-type is part of RSPEC_PHYTXBYTE2 returns */ + phyctl1 = RSPEC_PHYTXBYTE2(rspec); + /* set the upper byte of phyctl1 */ + phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 << 8); + } else if (IS_CCK(rspec) && !BRCMS_ISLCNPHY(wlc->band) + && !BRCMS_ISSSLPNPHY(wlc->band)) { + /* + * In CCK mode LPPHY overloads OFDM Modulation bits with CCK + * Data Rate. Eventually MIMOPHY would also be converted to + * this format + */ + /* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ + phyctl1 = (bw | (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); + } else { /* legacy OFDM/CCK */ + s16 phycfg; + /* get the phyctl byte from rate phycfg table */ + phycfg = brcms_c_rate_legacy_phyctl(RSPEC2RATE(rspec)); + if (phycfg == -1) { + wiphy_err(wlc->wiphy, "phytxctl1_calc: wrong " + "legacy OFDM/CCK rate\n"); + phycfg = 0; + } + /* set the upper byte of phyctl1 */ + phyctl1 = + (bw | (phycfg << 8) | + (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); + } + return phyctl1; +} + +u32 +brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, + bool use_rspec, u16 mimo_ctlchbw) +{ + u32 rts_rspec = 0; + + if (use_rspec) + /* use frame rate as rts rate */ + rts_rspec = rspec; + else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) + /* Use 11Mbps as the g protection RTS target rate and fallback. + * Use the BRCMS_BASIC_RATE() lookup to find the best basic rate + * under the target in case 11 Mbps is not Basic. + * 6 and 9 Mbps are not usually selected by rate selection, but + * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 + * is more robust. + */ + rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); + else + /* calculate RTS rate and fallback rate based on the frame rate + * RTS must be sent at a basic rate since it is a + * control frame, sec 9.6 of 802.11 spec + */ + rts_rspec = BRCMS_BASIC_RATE(wlc, rspec); + + if (BRCMS_PHY_11N_CAP(wlc->band)) { + /* set rts txbw to correct side band */ + rts_rspec &= ~RSPEC_BW_MASK; + + /* + * if rspec/rspec_fallback is 40MHz, then send RTS on both + * 20MHz channel (DUP), otherwise send RTS on control channel + */ + if (RSPEC_IS40MHZ(rspec) && !IS_CCK(rts_rspec)) + rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT); + else + rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT); + + /* pick siso/cdd as default for ofdm */ + if (IS_OFDM(rts_rspec)) { + rts_rspec &= ~RSPEC_STF_MASK; + rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); + } + } + return rts_rspec; +} + +void brcms_c_tbtt(struct brcms_c_info *wlc) +{ + struct brcms_bss_cfg *cfg = wlc->cfg; + + if (!cfg->BSS) + /* + * DirFrmQ is now valid...defer setting until end + * of ATIM window + */ + wlc->qvalid |= MCMD_DIRFRMQVAL; +} + /* process an individual struct tx_status */ bool brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) @@ -8507,101 +8695,6 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, return dur; } -/* The opposite of brcms_c_calc_frame_time */ -static uint -brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, - u8 preamble_type, uint dur) -{ - uint nsyms, mac_len, Ndps, kNdps; - uint rate = RSPEC2RATE(ratespec); - - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n", - wlc->pub->unit, ratespec, preamble_type, dur); - - if (IS_MCS(ratespec)) { - uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec); - dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); - /* payload calculation matches that of regular ofdm */ - if (BAND_2G(wlc->band->bandtype)) - dur -= DOT11_OFDM_SIGNAL_EXTENSION; - /* kNdbps = kbps * 4 */ - kNdps = - MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), - RSPEC_ISSGI(ratespec)) * 4; - nsyms = dur / APHY_SYMBOL_TIME; - mac_len = - ((nsyms * kNdps) - - ((APHY_SERVICE_NBITS + APHY_TAIL_NBITS) * 1000)) / 8000; - } else if (IS_OFDM(ratespec)) { - dur -= APHY_PREAMBLE_TIME; - dur -= APHY_SIGNAL_TIME; - /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ - Ndps = rate * 2; - nsyms = dur / APHY_SYMBOL_TIME; - mac_len = - ((nsyms * Ndps) - - (APHY_SERVICE_NBITS + APHY_TAIL_NBITS)) / 8; - } else { - if (preamble_type & BRCMS_SHORT_PREAMBLE) - dur -= BPHY_PLCP_SHORT_TIME; - else - dur -= BPHY_PLCP_TIME; - mac_len = dur * rate; - /* divide out factor of 2 in rate (1/2 mbps) */ - mac_len = mac_len / 8 / 2; - } - return mac_len; -} - -static uint -brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, " - "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type); - /* - * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that - * is less than or equal to the rate of the immediately previous - * frame in the FES - */ - rspec = BRCMS_BASIC_RATE(wlc, rspec); - /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ - return brcms_c_calc_frame_time(wlc, rspec, preamble_type, - (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + - FCS_LEN)); -} - -static uint -brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - uint dur = 0; - - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n", - wlc->pub->unit, rspec, preamble_type); - /* - * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that - * is less than or equal to the rate of the immediately previous - * frame in the FES - */ - rspec = BRCMS_BASIC_RATE(wlc, rspec); - /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ - dur = - brcms_c_calc_frame_time(wlc, rspec, preamble_type, - (DOT11_ACK_LEN + FCS_LEN)); - return dur; -} - -static uint -brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n", - wlc->pub->unit, rspec, preamble_type); - return brcms_c_calc_ack_time(wlc, rspec, preamble_type); -} - /* derive wlc->band->basic_rate[] table from 'rateset' */ void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, struct brcms_c_rateset *rateset) @@ -8816,30 +8909,6 @@ bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, return false; } -static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) -{ - uint i; - struct brcms_band *band; - - for (i = 0; i < NBANDS(wlc); i++) { - if (IS_SINGLEBAND_5G(wlc->deviceid)) - i = BAND_5G_INDEX; - band = wlc->bandstate[i]; - if (band->bandtype == BRCM_BAND_5G) { - if ((bwcap == BRCMS_N_BW_40ALL) - || (bwcap == BRCMS_N_BW_20IN2G_40IN5G)) - band->mimo_cap_40 = true; - else - band->mimo_cap_40 = false; - } else { - if (bwcap == BRCMS_N_BW_40ALL) - band->mimo_cap_40 = true; - else - band->mimo_cap_40 = false; - } - } -} - void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) { const struct brcms_c_rateset *rs_dflt; @@ -8984,6 +9053,12 @@ brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], } } +void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], int len, + bool both) +{ + brcms_b_write_hw_bcntemplates(wlc->hw, bcn, len, both); +} + /* * Update a beacon for a particular BSS * For MBSS, this updates the software template and sets "latest" to @@ -9180,182 +9255,6 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) wlc->stf->txstreams); } -static void brcms_c_bss_default_init(struct brcms_c_info *wlc) -{ - u16 chanspec; - struct brcms_band *band; - struct brcms_bss_info *bi = wlc->default_bss; - - /* init default and target BSS with some sane initial values */ - memset((char *)(bi), 0, sizeof(struct brcms_bss_info)); - bi->beacon_period = BEACON_INTERVAL_DEFAULT; - bi->dtim_period = DTIM_INTERVAL_DEFAULT; - - /* fill the default channel as the first valid channel - * starting from the 2G channels - */ - chanspec = CH20MHZ_CHSPEC(1); - wlc->home_chanspec = bi->chanspec = chanspec; - - /* find the band of our default channel */ - band = wlc->band; - if (NBANDS(wlc) > 1 && band->bandunit != CHSPEC_BANDUNIT(chanspec)) - band = wlc->bandstate[OTHERBANDUNIT(wlc)]; - - /* init bss rates to the band specific default rate set */ - brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, - band->bandtype, false, BRCMS_RATE_MASK_FULL, - (bool) N_ENAB(wlc->pub), CHSPEC_WLC_BW(chanspec), - wlc->stf->txstreams); - - if (N_ENAB(wlc->pub)) - bi->flags |= BRCMS_BSS_HT; -} - -static u32 -mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, - u32 int_val) -{ - u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT; - u8 rate = int_val & NRATE_RATE_MASK; - u32 rspec; - bool ismcs = ((int_val & NRATE_MCS_INUSE) == NRATE_MCS_INUSE); - bool issgi = ((int_val & NRATE_SGI_MASK) >> NRATE_SGI_SHIFT); - bool override_mcs_only = ((int_val & NRATE_OVERRIDE_MCS_ONLY) - == NRATE_OVERRIDE_MCS_ONLY); - int bcmerror = 0; - - if (!ismcs) - return (u32) rate; - - /* validate the combination of rate/mcs/stf is allowed */ - if (N_ENAB(wlc->pub) && ismcs) { - /* mcs only allowed when nmode */ - if (stf > PHY_TXC1_MODE_SDM) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", - BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - - /* mcs 32 is a special case, DUP mode 40 only */ - if (rate == 32) { - if (!CHSPEC_IS40(wlc->home_chanspec) || - ((stf != PHY_TXC1_MODE_SISO) - && (stf != PHY_TXC1_MODE_CDD))) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs " - "32\n", BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - /* mcs > 7 must use stf SDM */ - } else if (rate > HIGHEST_SINGLE_STREAM_MCS) { - /* mcs > 7 must use stf SDM */ - if (stf != PHY_TXC1_MODE_SDM) { - BCMMSG(wlc->wiphy, "wl%d: enabling " - "SDM mode for mcs %d\n", - BRCMS_UNIT(wlc), rate); - stf = PHY_TXC1_MODE_SDM; - } - } else { - /* - * MCS 0-7 may use SISO, CDD, and for - * phy_rev >= 3 STBC - */ - if ((stf > PHY_TXC1_MODE_STBC) || - (!BRCMS_STBC_CAP_PHY(wlc) - && (stf == PHY_TXC1_MODE_STBC))) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC" - "\n", BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - } - } else if (IS_OFDM(rate)) { - if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", - BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - } else if (IS_CCK(rate)) { - if ((cur_band->bandtype != BRCM_BAND_2G) - || (stf != PHY_TXC1_MODE_SISO)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", - BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - } else { - wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n", - BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - /* make sure multiple antennae are available for non-siso rates */ - if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { - wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO " - "request\n", BRCMS_UNIT(wlc), __func__); - bcmerror = -EINVAL; - goto done; - } - - rspec = rate; - if (ismcs) { - rspec |= RSPEC_MIMORATE; - /* For STBC populate the STC field of the ratespec */ - if (stf == PHY_TXC1_MODE_STBC) { - u8 stc; - stc = 1; /* Nss for single stream is always 1 */ - rspec |= (stc << RSPEC_STC_SHIFT); - } - } - - rspec |= (stf << RSPEC_STF_SHIFT); - - if (override_mcs_only) - rspec |= RSPEC_OVERRIDE_MCS_ONLY; - - if (issgi) - rspec |= RSPEC_SHORT_GI; - - if ((rate != 0) - && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) - return rate; - - return rspec; -done: - return rate; -} - -/* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */ -static int -brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, - bool writeToShm) -{ - int idle_busy_ratio_x_16 = 0; - uint offset = - isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM : - M_TX_IDLE_BUSY_RATIO_X_16_CCK; - if (duty_cycle > 100 || duty_cycle < 0) { - wiphy_err(wlc->wiphy, "wl%d: duty cycle value off limit\n", - wlc->pub->unit); - return -EINVAL; - } - if (duty_cycle) - idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; - /* Only write to shared memory when wl is up */ - if (writeToShm) - brcms_c_write_shm(wlc, offset, (u16) idle_busy_ratio_x_16); - - if (isOFDM) - wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; - else - wlc->tx_duty_cycle_cck = (u16) duty_cycle; - - return 0; -} - /* Read a single u16 from shared memory. * SHM 'offset' needs to be an even address */ @@ -9420,12 +9319,6 @@ void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, brcms_b_write_template_ram(wlc->hw, offset, len, buf); } -void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], int len, - bool both) -{ - brcms_b_write_hw_bcntemplates(wlc->hw, bcn, len, both); -} - void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, const u8 *addr) @@ -9545,76 +9438,6 @@ brcms_c_txflowcontrol_override(struct brcms_c_info *wlc, } } -static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc) -{ - struct brcms_txq_info *qi; - - for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { - if (qi->stopped) { - brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO); - qi->stopped = 0; - } - } -} - -static void -brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, bool on, int prio) -{ - /* wlcif_list is never filled so this function is not functional yet */ -} - -static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) -{ - struct brcms_txq_info *qi, *p; - - qi = kzalloc(sizeof(struct brcms_txq_info), GFP_ATOMIC); - if (qi != NULL) { - /* - * Have enough room for control packets along with HI watermark - * Also, add room to txq for total psq packets if all the SCBs - * leave PS mode. The watermark for flowcontrol to OS packets - * will remain the same - */ - brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT, - (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT - + wlc->pub->psq_pkts_total); - - /* add this queue to the the global list */ - p = wlc->tx_queues; - if (p == NULL) { - wlc->tx_queues = qi; - } else { - while (p->next != NULL) - p = p->next; - p->next = qi; - } - } - return qi; -} - -static void brcms_c_txq_free(struct brcms_c_info *wlc, - struct brcms_txq_info *qi) -{ - struct brcms_txq_info *p; - - if (qi == NULL) - return; - - /* remove the queue from the linked list */ - p = wlc->tx_queues; - if (p == qi) - wlc->tx_queues = p->next; - else { - while (p != NULL && p->next != qi) - p = p->next; - if (p != NULL) - p->next = p->next->next; - } - - kfree(qi); -} - /* * Flag 'scan in progress' to withhold dynamic phy calibration */ From 72a4915f9b503fefdd18e62bf9baad14ee08d759 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:01 +0200 Subject: [PATCH 0849/1519] staging: brcm80211: cleaned up fullmac macro BRCMF_PM_RESUME_RETURN_ERROR Macros impacting the code flow are sort of frowned upon. No other macro's in the source code impact the code flow. Replaced macro by function. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Franky Lin Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index a15765b6d88..d3d389072b5 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -90,17 +90,24 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); wait_event_timeout(a, false, HZ/100); \ } \ } while (0) -#define BRCMF_PM_RESUME_RETURN_ERROR(a, b) \ - do { if (atomic_read(&b->suspend)) return a; } while (0) #else #define BRCMF_PM_RESUME_WAIT(a, b) -#define BRCMF_PM_RESUME_RETURN_ERROR(a, b) #endif /* CONFIG_PM_SLEEP */ static int brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, int regsize, u32 *data); +static bool +brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) +{ + bool is_err = false; +#ifdef CONFIG_PM_SLEEP + is_err = atomic_read(&sdiodev->suspend); +#endif + return is_err; +} + static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) { int err_ret; @@ -249,7 +256,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); + if (brcmf_pm_resume_error(sdiodev)) + return -EIO; if (rw) { /* CMD52 Write */ if (func == 0) { /* Can only directly write to some F0 registers. @@ -351,7 +359,8 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, cmd_type, rw, func, addr, nbytes); BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); + if (brcmf_pm_resume_error(sdiodev)) + return -EIO; /* Claim host controller */ sdio_claim_host(sdiodev->func[func]); @@ -400,7 +409,8 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, brcmf_dbg(TRACE, "Enter\n"); BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); + if (brcmf_pm_resume_error(sdiodev)) + return -EIO; /* Claim host controller */ sdio_claim_host(sdiodev->func[func]); @@ -477,7 +487,8 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, brcmf_dbg(TRACE, "Enter\n"); BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev); - BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev); + if (brcmf_pm_resume_error(sdiodev)) + return -EIO; /* Case 1: we don't have a packet. */ if (pkt == NULL) { brcmf_dbg(DATA, "Creating new %s Packet, len=%d\n", From 0629eaebf3844f2855dd1d8bb74ee5b8f529cb78 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:02 +0200 Subject: [PATCH 0850/1519] staging: brcm80211: replaced fullmac BRCMF_PM_RESUME_WAIT macro with function Code cleanup. Advantage is more readable code and better type checking. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Franky Lin Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index d3d389072b5..be022d273d5 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -84,14 +84,6 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); -#define BRCMF_PM_RESUME_WAIT(a, b) do { \ - int retry = 0; \ - while (atomic_read(&b->suspend) && retry++ != 30) { \ - wait_event_timeout(a, false, HZ/100); \ - } \ - } while (0) -#else -#define BRCMF_PM_RESUME_WAIT(a, b) #endif /* CONFIG_PM_SLEEP */ static int @@ -108,6 +100,16 @@ brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) return is_err; } +static void +brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t wq) +{ +#ifdef CONFIG_PM_SLEEP + int retry = 0; + while (atomic_read(&sdiodev->suspend) && retry++ != 30) + wait_event_timeout(wq, false, HZ/100); +#endif +} + static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) { int err_ret; @@ -255,7 +257,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); - BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev); + brcmf_pm_resume_wait(sdiodev, sdioh_request_byte_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; if (rw) { /* CMD52 Write */ @@ -358,7 +360,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, brcmf_dbg(INFO, "cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", cmd_type, rw, func, addr, nbytes); - BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev); + brcmf_pm_resume_wait(sdiodev, sdioh_request_word_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; /* Claim host controller */ @@ -408,7 +410,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, brcmf_dbg(TRACE, "Enter\n"); - BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev); + brcmf_pm_resume_wait(sdiodev, sdioh_request_packet_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; @@ -486,7 +488,7 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, brcmf_dbg(TRACE, "Enter\n"); - BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev); + brcmf_pm_resume_wait(sdiodev, sdioh_request_buffer_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; /* Case 1: we don't have a packet. */ From 9904663c5eab141ae13a0412b178a8331a3dba5d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:03 +0200 Subject: [PATCH 0851/1519] staging: brcm80211: consolidate SHOW_EVENTS code under BCMDBG in fullmac Use unify config marco for debug info. Related event debug print out can be enabled/disabled by the dedicated event message level. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/Makefile | 2 -- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/Makefile b/drivers/staging/brcm80211/brcmfmac/Makefile index 826a2ba6a73..3d0878fac7d 100644 --- a/drivers/staging/brcm80211/brcmfmac/Makefile +++ b/drivers/staging/brcm80211/brcmfmac/Makefile @@ -15,8 +15,6 @@ # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -ccflags-$(CONFIG_BRCMDBG) += -DSHOW_EVENTS - ccflags-y += \ -Idrivers/staging/brcm80211/brcmfmac \ -Idrivers/staging/brcm80211/include diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 059289a5d82..e5214b2908d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -411,7 +411,7 @@ int brcmf_c_ioctl(struct brcmf_pub *drvr, struct brcmf_c_ioctl *ioc, void *buf, return bcmerror; } -#ifdef SHOW_EVENTS +#ifdef BCMDBG static void brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) { @@ -705,7 +705,7 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) brcmf_dbg(EVENT, "\n"); } } -#endif /* SHOW_EVENTS */ +#endif /* BCMDBG */ int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, @@ -796,9 +796,9 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, break; } -#ifdef SHOW_EVENTS +#ifdef BCMDBG brcmf_c_show_host_event(event, event_data); -#endif /* SHOW_EVENTS */ +#endif /* BCMDBG */ return 0; } From a723a22de640c09147889143dc2d94e452f11986 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:04 +0200 Subject: [PATCH 0852/1519] staging: brcm80211: remove duplicate set sb window address function In fullmac, brcmf_sdbrcm_set_siaddr_window and brcmf_sdcard_set_sbaddr_window have identical fucntionality. Remove the one in dhd_sdio.c Reported-by: Rafal Milecki Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 27 ++++--------------- .../staging/brcm80211/brcmfmac/sdio_host.h | 3 +++ 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 8448b8bb549..367277608a4 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -275,7 +275,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, return status; } -static int +int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) { int err = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index c1647ebafb5..72e5629b1f9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -948,24 +948,6 @@ static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size) bus->ramsize = brcmf_dongle_memsize; } -static int brcmf_sdbrcm_set_siaddr_window(struct brcmf_bus *bus, u32 address) -{ - int err = 0; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SBADDRLOW, - (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); - if (!err) - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SBADDRMID, - (address >> 16) & SBSDIO_SBADDRMID_MASK, &err); - if (!err) - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SBADDRHIGH, - (address >> 24) & SBSDIO_SBADDRHIGH_MASK, - &err); - return err; -} - /* Turn backplane clock on or off */ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) { @@ -1958,7 +1940,7 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, dsize = size; /* Set the backplane window to include the start address */ - bcmerror = brcmf_sdbrcm_set_siaddr_window(bus, address); + bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, address); if (bcmerror) { brcmf_dbg(ERROR, "window change failed\n"); goto xfer_done; @@ -1981,7 +1963,8 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, if (size) { data += dsize; address += dsize; - bcmerror = brcmf_sdbrcm_set_siaddr_window(bus, address); + bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, + address); if (bcmerror) { brcmf_dbg(ERROR, "window change failed\n"); break; @@ -1993,7 +1976,7 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, xfer_done: /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdbrcm_set_siaddr_window(bus, + if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, brcmf_sdcard_cur_sbwad( bus->sdiodev))) brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", @@ -4838,7 +4821,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) bus->alp_only = true; /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdbrcm_set_siaddr_window(bus, SI_ENUM_BASE)) + if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); #ifdef BCMDBG diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 03ae16aac32..9c55c4a600f 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -234,6 +234,9 @@ extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); /* Function to return current window addr */ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); +extern int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, + u32 address); + /* attach, return handler on success, NULL if failed. * The handler shall be provided by all subsequent calls. No local cache * cfghdl points to the starting address of pci device mapped memory From 27a29906ec0fa204cd35a61ef72fdd9d3776a9da Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:05 +0200 Subject: [PATCH 0853/1519] staging: brcm80211: remove function wrapper of getting sb window address The address stored in sdiodev can be used directly instead of using the wrapper function brcmf_sdcard_cur_sbwad. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 5 --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 36 ++++++++----------- .../staging/brcm80211/brcmfmac/sdio_host.h | 3 -- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 367277608a4..e4c785244ea 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -476,11 +476,6 @@ int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) return 0; } -u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev) -{ - return sdiodev->sbwad; -} - int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) { u32 regs = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 72e5629b1f9..49914c6da73 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1336,9 +1336,9 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, len = roundup(len, ALIGNMENT); do { - ret = brcmf_sdbrcm_send_buf(bus, - brcmf_sdcard_cur_sbwad(bus->sdiodev), - SDIO_FUNC_2, F2SYNC, frame, len, pkt); + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, + len, pkt); bus->f2txdata++; if (ret < 0) { @@ -1625,10 +1625,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) do { bus->ctrl_frame_stat = false; - ret = brcmf_sdbrcm_send_buf(bus, - brcmf_sdcard_cur_sbwad(bus->sdiodev), - SDIO_FUNC_2, - F2SYNC, frame, len, NULL); + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, len, NULL); if (ret < 0) { /* On failure, abort the command and @@ -1976,11 +1974,9 @@ brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, xfer_done: /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, - brcmf_sdcard_cur_sbwad( - bus->sdiodev))) + if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, bus->sdiodev->sbwad)) brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", - brcmf_sdcard_cur_sbwad(bus->sdiodev)); + bus->sdiodev->sbwad); return bcmerror; } @@ -3256,7 +3252,7 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) /* Read remainder of frame body into the rxctl buffer */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, (bus->rxctl + firstread), rdlen, NULL); @@ -3412,13 +3408,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) */ if (usechain) { errcode = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, (u8 *) pfirst->data, dlen, pfirst); } else if (bus->dataptr) { errcode = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, bus->dataptr, dlen, NULL); @@ -3756,8 +3752,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) rxbuf = (u8 *) (pkt->data); /* Read the entire frame */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad( - bus->sdiodev), + bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, rxbuf, rdlen, pkt); @@ -3910,8 +3905,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) } /* Read frame header (hardware and software) */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread, NULL); bus->f2rxhdrs++; @@ -4061,8 +4055,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); /* Read the remaining frame data */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), rdlen, pkt); bus->f2rxdata++; @@ -4388,8 +4381,7 @@ clkwait: (bus->clkstate == CLK_AVAIL)) { int ret, i; - ret = brcmf_sdbrcm_send_buf(bus, - brcmf_sdcard_cur_sbwad(bus->sdiodev), + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, (u32) bus->ctrl_frame_len, NULL); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 9c55c4a600f..4565aef9cb6 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -231,9 +231,6 @@ extern void brcmf_sdio_function_cleanup(void); extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); -/* Function to return current window addr */ -extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); - extern int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address); From fee3b8ba8befee5f944d3039e51cb439d9771120 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:06 +0200 Subject: [PATCH 0854/1519] staging: brcm80211: remove unused sdioh data mode code in fullmac sdioh data mode is not used in brcmf_sdioh_request_buffer. The patch removes the related code. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 15 ++++++--------- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 2 +- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index e4c785244ea..e0fe7c2ae51 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -41,9 +41,6 @@ #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ -#define SDIOH_DATA_PIO 0 /* PIO mode */ -#define SDIOH_DATA_DMA 1 /* DMA mode */ - /* Module parameters specific to each host-controller driver */ module_param(sd_f2_blocksize, int, 0); @@ -412,8 +409,8 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, - incr_fix, SDIOH_READ, fn, addr, width, nbytes, buf, pkt); + status = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, + fn, addr, width, nbytes, buf, pkt); return status; } @@ -448,8 +445,8 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, if (width == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, - incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt); + return brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_WRITE, fn, + addr, width, nbytes, buf, pkt); } int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, @@ -458,8 +455,8 @@ int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, addr &= SBSDIO_SB_OFT_ADDR_MASK; addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_PIO, - SDIOH_DATA_INC, (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, + return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_INC, + (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, addr, 4, nbytes, buf, NULL); } diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index be022d273d5..b31686698c6 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -478,7 +478,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, * */ extern int -brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, +brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, uint reg_width, uint buflen_u, u8 *buffer, struct sk_buff *pkt) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 4565aef9cb6..d0778b3a9aa 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -253,7 +253,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, /* read or write any buffer using cmd53 */ extern int -brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, +brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint rw, uint fnc_num, u32 addr, uint regwidth, u32 buflen, u8 *buffer, struct sk_buff *pkt); From b0dea9c07c12e4b7e35cc5558d18ede8c5e051d6 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:07 +0200 Subject: [PATCH 0855/1519] staging: brcm80211: remove unused sdioh command type code in fullmac sdioh command type is not used in brcmf_sdioh_request_word. This patch removes the related code. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 12 ++++-------- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 8 ++++---- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index e0fe7c2ae51..e35c56aa30f 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -37,10 +37,6 @@ #define SDIOH_API_ACCESS_RETRY_LIMIT 2 -#define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */ -#define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ -#define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ - /* Module parameters specific to each host-controller driver */ module_param(sd_f2_blocksize, int, 0); @@ -311,8 +307,8 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = brcmf_sdioh_request_word(sdiodev, SDIOH_CMD_TYPE_NORMAL, - SDIOH_READ, SDIO_FUNC_1, addr, &word, size); + status = brcmf_sdioh_request_word(sdiodev, SDIOH_READ, SDIO_FUNC_1, + addr, &word, size); sdiodev->regfail = (status != 0); @@ -360,8 +356,8 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, if (size == 4) addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; status = - brcmf_sdioh_request_word(sdiodev, SDIOH_CMD_TYPE_NORMAL, - SDIOH_WRITE, SDIO_FUNC_1, addr, &data, size); + brcmf_sdioh_request_word(sdiodev, SDIOH_WRITE, SDIO_FUNC_1, + addr, &data, size); sdiodev->regfail = (status != 0); if (status == 0) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index b31686698c6..ef09a63d77d 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -347,7 +347,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, } extern int -brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, +brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint addr, u32 *word, uint nbytes) { int err_ret = -EIO; @@ -357,8 +357,8 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, return -EINVAL; } - brcmf_dbg(INFO, "cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", - cmd_type, rw, func, addr, nbytes); + brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", + rw, func, addr, nbytes); brcmf_pm_resume_wait(sdiodev, sdioh_request_word_wait); if (brcmf_pm_resume_error(sdiodev)) @@ -566,7 +566,7 @@ brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, *data &= 0xff; brcmf_dbg(DATA, "byte read data=0x%02x\n", *data); } else { - brcmf_sdioh_request_word(sdiodev, 0, SDIOH_READ, func, regaddr, + brcmf_sdioh_request_word(sdiodev, SDIOH_READ, func, regaddr, data, regsize); if (regsize == 2) *data &= 0xffff; diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index d0778b3a9aa..67368b93297 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -247,7 +247,7 @@ extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, /* read or write 2/4 bytes using cmd53 */ extern int -brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, +brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint rw, uint fnc, uint addr, u32 *word, uint nbyte); From bc4fbdadc1ed7ec9d8d4493da85dafb4888e2593 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:08 +0200 Subject: [PATCH 0856/1519] staging: brcm80211: remove static function declaration in bcmsdh_sdmmc Reshuffle function order in bcmsdh_sdmmc of fullmac to get rid of static function declaration Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 332 +++++++++--------- 1 file changed, 157 insertions(+), 175 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index ef09a63d77d..fd34dd48112 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -40,16 +40,6 @@ #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 -static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr); -static int brcmf_ops_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *id); -static void brcmf_ops_sdio_remove(struct sdio_func *func); - -#ifdef CONFIG_PM -static int brcmf_sdio_suspend(struct device *dev); -static int brcmf_sdio_resume(struct device *dev); -#endif /* CONFIG_PM */ - uint sd_f2_blocksize = 512; /* Default blocksize */ /* devices we support, null terminated */ @@ -57,26 +47,6 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, { /* end: all zeroes */ }, }; - -#ifdef CONFIG_PM_SLEEP -static const struct dev_pm_ops brcmf_sdio_pm_ops = { - .suspend = brcmf_sdio_suspend, - .resume = brcmf_sdio_resume, -}; -#endif /* CONFIG_PM_SLEEP */ - -static struct sdio_driver brcmf_sdmmc_driver = { - .probe = brcmf_ops_sdio_probe, - .remove = brcmf_ops_sdio_remove, - .name = "brcmfmac", - .id_table = brcmf_sdmmc_ids, -#ifdef CONFIG_PM_SLEEP - .drv = { - .pm = &brcmf_sdio_pm_ops, - }, -#endif /* CONFIG_PM_SLEEP */ -}; - MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); #ifdef CONFIG_PM_SLEEP @@ -86,10 +56,6 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); #endif /* CONFIG_PM_SLEEP */ -static int -brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, - int regsize, u32 *data); - static bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) { @@ -110,145 +76,6 @@ brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t wq) #endif } -static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) -{ - int err_ret; - u32 fbraddr; - u8 func; - - brcmf_dbg(TRACE, "\n"); - - /* Get the Card's common CIS address */ - sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev, - SDIO_CCCR_CIS); - brcmf_dbg(INFO, "Card's Common CIS Ptr = 0x%x\n", - sdiodev->func_cis_ptr[0]); - - /* Get the Card's function CIS (for each function) */ - for (fbraddr = SDIO_FBR_BASE(1), func = 1; - func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { - sdiodev->func_cis_ptr[func] = - brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr); - brcmf_dbg(INFO, "Function %d CIS Ptr = 0x%x\n", - func, sdiodev->func_cis_ptr[func]); - } - - /* Enable Function 1 */ - sdio_claim_host(sdiodev->func[1]); - err_ret = sdio_enable_func(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - if (err_ret) - brcmf_dbg(ERROR, "Failed to enable F1 Err: 0x%08x\n", err_ret); - - return false; -} - -/* - * Public entry points & extern's - */ -int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) -{ - int err_ret = 0; - - brcmf_dbg(TRACE, "\n"); - - sdiodev->num_funcs = 2; - - sdio_claim_host(sdiodev->func[1]); - err_ret = sdio_set_block_size(sdiodev->func[1], 64); - sdio_release_host(sdiodev->func[1]); - if (err_ret) { - brcmf_dbg(ERROR, "Failed to set F1 blocksize\n"); - goto out; - } - - sdio_claim_host(sdiodev->func[2]); - err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize); - sdio_release_host(sdiodev->func[2]); - if (err_ret) { - brcmf_dbg(ERROR, "Failed to set F2 blocksize to %d\n", - sd_f2_blocksize); - goto out; - } - - brcmf_sdioh_enablefuncs(sdiodev); - -out: - brcmf_dbg(TRACE, "Done\n"); - return err_ret; -} - -void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) -{ - brcmf_dbg(TRACE, "\n"); - - /* Disable Function 2 */ - sdio_claim_host(sdiodev->func[2]); - sdio_disable_func(sdiodev->func[2]); - sdio_release_host(sdiodev->func[2]); - - /* Disable Function 1 */ - sdio_claim_host(sdiodev->func[1]); - sdio_disable_func(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - -} - -static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) -{ - /* read 24 bits and return valid 17 bit addr */ - int i; - u32 scratch, regdata; - u8 *ptr = (u8 *)&scratch; - for (i = 0; i < 3; i++) { - if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, - ®data)) != SUCCESS) - brcmf_dbg(ERROR, "Can't read!\n"); - - *ptr++ = (u8) regdata; - regaddr++; - } - - /* Only the lower 17-bits are valid */ - scratch = le32_to_cpu(scratch); - scratch &= 0x0001FFFF; - return scratch; -} - -extern int -brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, - u8 *cisd, u32 length) -{ - u32 count; - int offset; - u32 foo; - u8 *cis = cisd; - - brcmf_dbg(TRACE, "Func = %d\n", func); - - if (!sdiodev->func_cis_ptr[func]) { - memset(cis, 0, length); - brcmf_dbg(ERROR, "no func_cis_ptr[%d]\n", func); - return -ENOTSUPP; - } - - brcmf_dbg(ERROR, "func_cis_ptr[%d]=0x%04x\n", - func, sdiodev->func_cis_ptr[func]); - - for (count = 0; count < length; count++) { - offset = sdiodev->func_cis_ptr[func] + count; - if (brcmf_sdioh_card_regread(sdiodev, 0, offset, 1, &foo) < 0) { - brcmf_dbg(ERROR, "regread failed: Can't read CIS\n"); - return -EIO; - } - - *cis = (u8) (foo & 0xff); - cis++; - } - - return 0; -} - extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint regaddr, u8 *byte) @@ -577,6 +404,145 @@ brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, return SUCCESS; } +static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) +{ + /* read 24 bits and return valid 17 bit addr */ + int i; + u32 scratch, regdata; + u8 *ptr = (u8 *)&scratch; + for (i = 0; i < 3; i++) { + if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, + ®data)) != SUCCESS) + brcmf_dbg(ERROR, "Can't read!\n"); + + *ptr++ = (u8) regdata; + regaddr++; + } + + /* Only the lower 17-bits are valid */ + scratch = le32_to_cpu(scratch); + scratch &= 0x0001FFFF; + return scratch; +} + +extern int +brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, + u8 *cisd, u32 length) +{ + u32 count; + int offset; + u32 foo; + u8 *cis = cisd; + + brcmf_dbg(TRACE, "Func = %d\n", func); + + if (!sdiodev->func_cis_ptr[func]) { + memset(cis, 0, length); + brcmf_dbg(ERROR, "no func_cis_ptr[%d]\n", func); + return -ENOTSUPP; + } + + brcmf_dbg(ERROR, "func_cis_ptr[%d]=0x%04x\n", + func, sdiodev->func_cis_ptr[func]); + + for (count = 0; count < length; count++) { + offset = sdiodev->func_cis_ptr[func] + count; + if (brcmf_sdioh_card_regread(sdiodev, 0, offset, 1, &foo) < 0) { + brcmf_dbg(ERROR, "regread failed: Can't read CIS\n"); + return -EIO; + } + + *cis = (u8) (foo & 0xff); + cis++; + } + + return 0; +} + +static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) +{ + int err_ret; + u32 fbraddr; + u8 func; + + brcmf_dbg(TRACE, "\n"); + + /* Get the Card's common CIS address */ + sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev, + SDIO_CCCR_CIS); + brcmf_dbg(INFO, "Card's Common CIS Ptr = 0x%x\n", + sdiodev->func_cis_ptr[0]); + + /* Get the Card's function CIS (for each function) */ + for (fbraddr = SDIO_FBR_BASE(1), func = 1; + func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { + sdiodev->func_cis_ptr[func] = + brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr); + brcmf_dbg(INFO, "Function %d CIS Ptr = 0x%x\n", + func, sdiodev->func_cis_ptr[func]); + } + + /* Enable Function 1 */ + sdio_claim_host(sdiodev->func[1]); + err_ret = sdio_enable_func(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); + if (err_ret) + brcmf_dbg(ERROR, "Failed to enable F1 Err: 0x%08x\n", err_ret); + + return false; +} + +/* + * Public entry points & extern's + */ +int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) +{ + int err_ret = 0; + + brcmf_dbg(TRACE, "\n"); + + sdiodev->num_funcs = 2; + + sdio_claim_host(sdiodev->func[1]); + err_ret = sdio_set_block_size(sdiodev->func[1], 64); + sdio_release_host(sdiodev->func[1]); + if (err_ret) { + brcmf_dbg(ERROR, "Failed to set F1 blocksize\n"); + goto out; + } + + sdio_claim_host(sdiodev->func[2]); + err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize); + sdio_release_host(sdiodev->func[2]); + if (err_ret) { + brcmf_dbg(ERROR, "Failed to set F2 blocksize to %d\n", + sd_f2_blocksize); + goto out; + } + + brcmf_sdioh_enablefuncs(sdiodev); + +out: + brcmf_dbg(TRACE, "Done\n"); + return err_ret; +} + +void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) +{ + brcmf_dbg(TRACE, "\n"); + + /* Disable Function 2 */ + sdio_claim_host(sdiodev->func[2]); + sdio_disable_func(sdiodev->func[2]); + sdio_release_host(sdiodev->func[2]); + + /* Disable Function 1 */ + sdio_claim_host(sdiodev->func[1]); + sdio_disable_func(sdiodev->func[1]); + sdio_release_host(sdiodev->func[1]); + +} + static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { @@ -635,7 +601,6 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) } } - #ifdef CONFIG_PM_SLEEP static int brcmf_sdio_suspend(struct device *dev) { @@ -677,7 +642,24 @@ static int brcmf_sdio_resume(struct device *dev) atomic_set(&sdiodev->suspend, false); return 0; } -#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops brcmf_sdio_pm_ops = { + .suspend = brcmf_sdio_suspend, + .resume = brcmf_sdio_resume, +}; +#endif /* CONFIG_PM_SLEEP */ + +static struct sdio_driver brcmf_sdmmc_driver = { + .probe = brcmf_ops_sdio_probe, + .remove = brcmf_ops_sdio_remove, + .name = "brcmfmac", + .id_table = brcmf_sdmmc_ids, +#ifdef CONFIG_PM_SLEEP + .drv = { + .pm = &brcmf_sdio_pm_ops, + }, +#endif /* CONFIG_PM_SLEEP */ +}; /* * module init From debc71cd897b63880385e208e83714cb028e2177 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 1 Sep 2011 11:17:09 +0200 Subject: [PATCH 0857/1519] staging: brcm80211: remove static function declaration in dhd_linux Reshuffle function order in dhd_linux of fullmac to get rid of static function declaration Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 46f75b7f7be..7121b1658e9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -120,12 +120,6 @@ uint brcmf_radio_up = 1; char iface_name[IFNAMSIZ] = "wlan"; module_param_string(iface_name, iface_name, IFNAMSIZ, 0); -static int brcmf_toe_get(struct brcmf_info *drvr_priv, int idx, u32 *toe_ol); -static int brcmf_toe_set(struct brcmf_info *drvr_priv, int idx, u32 toe_ol); -static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, - void *pktdata, struct brcmf_event_msg *event_ptr, - void **data_ptr); - static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net) { int i = 0; @@ -600,6 +594,23 @@ void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool state) netif_wake_queue(net); } +static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, + void *pktdata, struct brcmf_event_msg *event, + void **data) +{ + int bcmerror = 0; + + bcmerror = brcmf_c_host_event(drvr_priv, ifidx, pktdata, event, data); + if (bcmerror != 0) + return bcmerror; + + if (drvr_priv->iflist[*ifidx]->net) + brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->net, + event, *data); + + return bcmerror; +} + void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, int numpkt) { @@ -1483,23 +1494,6 @@ int brcmf_os_proto_unblock(struct brcmf_pub *drvr) return 0; } -static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, - void *pktdata, struct brcmf_event_msg *event, - void **data) -{ - int bcmerror = 0; - - bcmerror = brcmf_c_host_event(drvr_priv, ifidx, pktdata, event, data); - if (bcmerror != 0) - return bcmerror; - - if (drvr_priv->iflist[*ifidx]->net) - brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->net, - event, *data); - - return bcmerror; -} - int brcmf_netdev_reset(struct net_device *dev, u8 flag) { struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev); From 934c3e471c72ba468ca2d5573115824aeec452e0 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 1 Sep 2011 11:17:10 +0200 Subject: [PATCH 0858/1519] staging: brcm80211: use static qualifier for local symbols in brcmfmac Cleanup resulted in merging several files and made several symbols local to a source file. These were found by running sparse as it gave the warning: symbol 'foo' was not declared. Should it be static? Reported-by: Aaro Koskinen Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 2 +- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 10 +++++----- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 15 ++++++++------- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 11 +---------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 10 +++++----- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 5 +++-- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index e35c56aa30f..2490dde1c2b 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -49,7 +49,7 @@ enum { IOV_RXCHAIN }; -const struct brcmu_iovar sdioh_iovars[] = { +static const struct brcmu_iovar sdioh_iovars[] = { {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} , {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index fd34dd48112..5482005c656 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -50,10 +50,10 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = { MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); #ifdef CONFIG_PM_SLEEP -DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); -DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); -DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); -DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); +static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); +static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); +static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); +static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); #endif /* CONFIG_PM_SLEEP */ static bool @@ -379,7 +379,7 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, } /* Read client card reg */ -int +static int brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, int regsize, u32 *data) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index e5214b2908d..3abd434ba52 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -36,11 +36,12 @@ int brcmf_msg_level; #define MSGTRACE_VERSION 1 #ifdef BCMDBG -const char brcmf_version[] = -"Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " __DATE__ -" at " __TIME__; +static const char brcmf_version[] = + "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " + __DATE__ " at " __TIME__; #else -const char brcmf_version[] = "Dongle Host Driver, version " BRCMF_VERSION_STR; +static const char brcmf_version[] = + "Dongle Host Driver, version " BRCMF_VERSION_STR; #endif /* IOVar table */ @@ -58,7 +59,7 @@ enum { IOV_LAST }; -const struct brcmu_iovar brcmf_iovars[] = { +static const struct brcmu_iovar brcmf_iovars[] = { {"version", IOV_VERSION, 0, IOVT_BUFFER, sizeof(brcmf_version)} , #ifdef BCMDBG @@ -1038,7 +1039,7 @@ fail: kfree(buf); } -void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) +static void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) { char iovbuf[32]; int retcode; @@ -1055,7 +1056,7 @@ void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) arp_mode); } -void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) +static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) { char iovbuf[32]; int retcode; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 7121b1658e9..470759a1f10 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -831,7 +831,7 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *net, dev_name(&brcmf_cfg80211_get_sdio_func()->dev)); } -struct ethtool_ops brcmf_ethtool_ops = { +static struct ethtool_ops brcmf_ethtool_ops = { .get_drvinfo = brcmf_ethtool_get_drvinfo }; @@ -1494,15 +1494,6 @@ int brcmf_os_proto_unblock(struct brcmf_pub *drvr) return 0; } -int brcmf_netdev_reset(struct net_device *dev, u8 flag) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev); - - brcmf_bus_devreset(&drvr_priv->pub, flag); - - return 1; -} - static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv) { return atomic_read(&drvr_priv->pend_8021x_cnt); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 49914c6da73..8e4e0d00183 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -769,7 +769,7 @@ uint brcmf_txbound; uint brcmf_rxbound; module_param(brcmf_txbound, uint, 0); module_param(brcmf_rxbound, uint, 0); -uint brcmf_txminmax; +static uint brcmf_txminmax; int brcmf_idletime = 1; module_param(brcmf_idletime, int, 0); @@ -1151,7 +1151,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) return 0; } -int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) +static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) { uint retries = 0; @@ -1765,7 +1765,7 @@ enum { IOV_VARS }; -const struct brcmu_iovar brcmf_sdio_iovars[] = { +static const struct brcmu_iovar brcmf_sdio_iovars[] = { {"intr", IOV_INTR, 0, IOVT_BOOL, 0}, {"sleep", IOV_SLEEP, 0, IOVT_BOOL, 0}, {"pollrate", IOV_POLLRATE, 0, IOVT_UINT32, 0}, @@ -2287,7 +2287,7 @@ break2: } #endif /* BCMDBG */ -int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) +static int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) { int bcmerror = 0; @@ -4497,7 +4497,7 @@ void brcmf_sdbrcm_isr(void *arg) brcmf_sdbrcm_sched_dpc(bus); } -extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) +static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) { struct brcmf_bus *bus; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 9010ce73b31..60a04b37a3d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -38,7 +38,7 @@ static struct sdio_func *cfg80211_sdio_func; static struct brcmf_cfg80211_dev *cfg80211_dev; static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; -u32 brcmf_dbg_level = WL_DBG_ERR; +static u32 brcmf_dbg_level = WL_DBG_ERR; /* ** cfg80211_ops api/callback list @@ -3830,7 +3830,8 @@ dongle_scantime_out: return err; } -s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, bool need_lock) +static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, + bool need_lock) { struct net_device *ndev; struct wireless_dev *wdev; From bc1275218c999d14b876689454e06412d1740806 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 1 Sep 2011 11:17:11 +0200 Subject: [PATCH 0859/1519] staging: brcm80211: reduce sparse messages on brcmsmac sources Running sparse over the driver sources showed 1356 sparse messages and quite a number are due to missing __iomem attribute in some places. This patch reduces the number significantly. Reported-by: Aaro Koskinen Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/types.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 6d17d7fa9b7..cf65f6e7522 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -328,13 +328,13 @@ do { \ __typeof(*(r)) __osl_v; \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - __osl_v = readb((u8 *)(r)); \ + __osl_v = readb((u8 __iomem *)(r)); \ break; \ case sizeof(u16): \ - __osl_v = readw((u16 *)(r)); \ + __osl_v = readw((u16 __iomem *)(r)); \ break; \ case sizeof(u32): \ - __osl_v = readl((u32 *)(r)); \ + __osl_v = readl((u32 __iomem *)(r)); \ break; \ } \ __osl_v; \ @@ -343,13 +343,13 @@ do { \ #define W_REG(r, v) do { \ switch (sizeof(*(r))) { \ case sizeof(u8): \ - writeb((u8)(v), (u8 *)(r)); \ + writeb((u8)((v) & 0xFF), (u8 __iomem *)(r)); \ break; \ case sizeof(u16): \ - writew((u16)(v), (u16 *)(r)); \ + writew((u16)((v) & 0xFFFF), (u16 __iomem *)(r)); \ break; \ case sizeof(u32): \ - writel((u32)(v), (u32 *)(r)); \ + writel((u32)(v), (u32 __iomem *)(r)); \ break; \ } \ } while (0) From 4f80f93e63d73cf96d458de069a22cee47e98898 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 1 Sep 2011 11:17:12 +0200 Subject: [PATCH 0860/1519] staging: brcm80211: remove sparse warnings from mac80211_if.c Some changes have been made to get rid of sparse warnings in the source file mac80211_if.c. Reported-by: Aaro Koskinen Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 6 +++--- drivers/staging/brcm80211/brcmsmac/mac80211_if.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index bd989737905..6ed80b22af5 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -96,7 +96,7 @@ struct firmware_hdr { u32 idx; }; -char *brcms_firmwares[MAX_FW_IMAGES] = { +static const char * const brcms_firmwares[MAX_FW_IMAGES] = { "brcm/bcm43xx", NULL }; @@ -1012,7 +1012,7 @@ static void brcms_free(struct brcms_info *wl) * after calling unregister_netdev() . */ if (wl->regsva) - iounmap((void *)wl->regsva); + iounmap(wl->regsva); wl->regsva = NULL; } @@ -1596,7 +1596,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl, if (!t) { wiphy_err(wl->wiphy, "wl%d: brcms_init_timer: out of memory\n", wl->pub->unit); - return 0; + return NULL; } init_timer(&t->timer); diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 1d528036019..1eb36eda89d 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -67,7 +67,7 @@ struct brcms_info { spinlock_t isr_lock; /* per-device ISR synchronization lock */ /* regsva for unmap in brcms_free() */ - void *regsva; /* opaque chip registers virtual address */ + void __iomem *regsva; /* opaque chip registers virtual address */ /* timer related fields */ atomic_t callbacks; /* # outstanding callback functions */ From 11431424cdf6d1b07c14989fab5fcbfc63b74b92 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 1 Sep 2011 11:17:13 +0200 Subject: [PATCH 0861/1519] staging: brcm80211: use static qualifier for local symbols in brcmsmac Cleanup resulted in merging several files and made several symbols local to a source file. These were found by running sparse as it gave the warning: symbol 'foo' was not declared. Should it be static? Reported-by: Aaro Koskinen Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 8 +- drivers/staging/brcm80211/brcmsmac/antsel.c | 8 +- drivers/staging/brcm80211/brcmsmac/dma.c | 5 +- drivers/staging/brcm80211/brcmsmac/main.c | 64 ++++----- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 7 +- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 26 ++-- .../brcm80211/brcmsmac/phy/phytbl_lcn.c | 66 ++++----- .../staging/brcm80211/brcmsmac/phy/phytbl_n.c | 128 +++++++++--------- drivers/staging/brcm80211/brcmsmac/rate.c | 4 +- drivers/staging/brcm80211/brcmsmac/stf.c | 3 +- .../staging/brcm80211/brcmsmac/ucode_loader.c | 5 +- 13 files changed, 168 insertions(+), 162 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 07f9d373f2a..f78cc501d40 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -487,7 +487,7 @@ static void ai_hwfixup(struct si_info *sii) } /* parse the enumeration rom to identify all cores */ -void ai_scan(struct si_pub *sih, struct chipcregs *cc) +static void ai_scan(struct si_pub *sih, struct chipcregs *cc) { struct si_info *sii = SI_INFO(sih); u32 erombase, *eromptr, *eromlim; @@ -2057,12 +2057,12 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) if (sih->chippkg == 9 || sih->chippkg == 0xb) /* Ext PA Controls for 4331 12x9 Package */ W_REG(&cc->chipcontrol, val | - (CCTRL4331_EXTPA_EN | - CCTRL4331_EXTPA_ON_GPIO2_5)); + CCTRL4331_EXTPA_EN | + CCTRL4331_EXTPA_ON_GPIO2_5); else /* Ext PA Controls for 4331 12x12 Package */ W_REG(&cc->chipcontrol, - val | (CCTRL4331_EXTPA_EN)); + val | CCTRL4331_EXTPA_EN); } else { val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); W_REG(&cc->chipcontrol, val); diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index 9dfc2efaf30..29b51a13d29 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -49,26 +49,26 @@ #define ANT_SELCFG_NUM_2x4 4 #define ANT_SELCFG_DEF_2x4 0x02 /* default antenna configuration */ -const u16 mimo_2x4_div_antselpat_tbl[] = { +static const u16 mimo_2x4_div_antselpat_tbl[] = { 0, 0, 0x9, 0xa, /* ant0: 0 ant1: 2,3 */ 0, 0, 0x5, 0x6, /* ant0: 1 ant1: 2,3 */ 0, 0, 0, 0, /* n.a. */ 0, 0, 0, 0 /* n.a. */ }; -const u8 mimo_2x4_div_antselid_tbl[16] = { +static const u8 mimo_2x4_div_antselid_tbl[16] = { 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0 /* pat to antselid */ }; -const u16 mimo_2x3_div_antselpat_tbl[] = { +static const u16 mimo_2x3_div_antselpat_tbl[] = { 16, 0, 1, 16, /* ant0: 0 ant1: 1,2 */ 16, 16, 16, 16, /* n.a. */ 16, 2, 16, 16, /* ant0: 2 ant1: 1 */ 16, 16, 16, 16 /* n.a. */ }; -const u8 mimo_2x3_div_antselid_tbl[16] = { +static const u8 mimo_2x3_div_antselid_tbl[16] = { 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* pat to antselid */ }; diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 6d9a0feafa5..85680c81c3b 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -409,8 +409,9 @@ static bool _dma_descriptor_align(struct dma_info *di) return true; } -void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, - uint *alloced, dma_addr_t *pap) +static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, + u16 align_bits, uint *alloced, + dma_addr_t *pap) { if (align_bits) { u16 align = (1 << align_bits); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 2825b1e755b..6ded4fbdcc1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -754,7 +754,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) return wlc->macintstatus != 0; } -int brcms_b_state_get(struct brcms_hardware *wlc_hw, +static int brcms_b_state_get(struct brcms_hardware *wlc_hw, struct brcms_b_state *state) { state->machwcap = wlc_hw->machwcap; @@ -904,7 +904,7 @@ static void brcms_b_info_init(struct brcms_hardware *wlc_hw) wlc_hw->chanspec = CH20MHZ_CHSPEC(1); } -void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) +static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) { /* delay before first read of ucode state */ udelay(40); @@ -914,7 +914,7 @@ void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); } -void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea) +static void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea) { memcpy(ea, wlc_hw->etheraddr, ETH_ALEN); } @@ -1186,7 +1186,7 @@ static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw) /* * Write a MAC address to the given match reg offset in the RXE match engine. */ -void +static void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, const u8 *addr) { @@ -1244,7 +1244,7 @@ brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, } } -void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) +static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) { wlc_hw->band->CWmin = newmin; @@ -1253,7 +1253,7 @@ void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) W_REG(&wlc_hw->regs->objdata, newmin); } -void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) +static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) { wlc_hw->band->CWmax = newmax; @@ -1684,7 +1684,7 @@ static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) * this function could be called when driver is down and w/o clock * it operates on different registers depending on corerev and boardflag. */ -bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) +static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) { bool v, clk, xtal; u32 resetbits = 0, flags = 0; @@ -2051,7 +2051,7 @@ void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); } -void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) +static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) { bool fatal = false; uint unit; @@ -2755,7 +2755,7 @@ brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, } } -void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, +static void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, uint *len) { BCMMSG(wlc_hw->wlc->wiphy, "nvram vars totlen=%d\n", @@ -2765,7 +2765,8 @@ void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, *len = wlc_hw->vars_size; } -void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) +static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, + u16 SRL, u16 LRL) { wlc_hw->SRL = SRL; wlc_hw->LRL = LRL; @@ -2783,7 +2784,7 @@ void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) } } -void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) +static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) { if (set) { if (mboolisset(wlc_hw->pllreq, req_bit)) @@ -2810,7 +2811,7 @@ void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) return; } -void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) +static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) { wlc_hw->antsel_avail = antsel_avail; } @@ -2850,7 +2851,7 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) return true; } -void brcms_b_reset(struct brcms_hardware *wlc_hw) +static void brcms_b_reset(struct brcms_hardware *wlc_hw) { BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -2899,7 +2900,7 @@ static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc) return chanspec; } -struct scb global_scb; +static struct scb global_scb; static void brcms_c_init_scb(struct brcms_c_info *wlc, struct scb *scb) { @@ -3092,7 +3093,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) } void -brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, +static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, bool mute) { u32 macintmask; bool fastclk; @@ -3581,7 +3582,7 @@ void brcms_c_set_bssid(struct brcms_bss_cfg *cfg) brcms_c_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID); } -void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) +static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) { wlc_hw->shortslot = shortslot; @@ -4151,7 +4152,7 @@ static void brcms_c_radio_timer(void *arg) } /* common low-level watchdog code */ -void brcms_b_watchdog(void *arg) +static void brcms_b_watchdog(void *arg) { struct brcms_c_info *wlc = (struct brcms_c_info *) arg; struct brcms_hardware *wlc_hw = wlc->hw; @@ -4399,8 +4400,9 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) * initialize software state for each core and band * put the whole chip in reset(driver down state), no clock */ -int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, struct pci_dev *btparam) +static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, + uint unit, bool piomode, void *regsva, + struct pci_dev *btparam) { struct brcms_hardware *wlc_hw; struct d11regs *regs; @@ -5209,7 +5211,7 @@ static void brcms_c_detach_module(struct brcms_c_info *wlc) /* * low level detach */ -int brcms_b_detach(struct brcms_c_info *wlc) +static int brcms_b_detach(struct brcms_c_info *wlc) { uint i; struct brcms_hw_band *band; @@ -5380,7 +5382,7 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); } /* Initialize just the hardware when coming out of POR or S3/S5 system states */ -void brcms_b_hw_up(struct brcms_hardware *wlc_hw) +static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) { if (wlc_hw->wlc->pub->hw_up) return; @@ -5424,7 +5426,7 @@ void brcms_b_hw_up(struct brcms_hardware *wlc_hw) } } -int brcms_b_up_prep(struct brcms_hardware *wlc_hw) +static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) { uint coremask; @@ -5466,7 +5468,7 @@ int brcms_b_up_prep(struct brcms_hardware *wlc_hw) return 0; } -int brcms_b_up_finish(struct brcms_hardware *wlc_hw) +static int brcms_b_up_finish(struct brcms_hardware *wlc_hw) { BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -5611,7 +5613,7 @@ static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) return callbacks; } -int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) +static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) { bool dev_gone; uint callbacks = 0; @@ -5639,7 +5641,7 @@ int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) return callbacks; } -int brcms_b_down_finish(struct brcms_hardware *wlc_hw) +static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) { uint callbacks = 0; bool dev_gone; @@ -6644,7 +6646,7 @@ static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate) * * Returns true if packet consumed (queued), false if not. */ -bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, +static bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, struct sk_buff *pkt, int prec) { return brcms_c_prec_enq_head(wlc, q, pkt, prec, false); @@ -8284,7 +8286,7 @@ void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); } -void +static void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, u32 *tsf_h_ptr) { @@ -9033,7 +9035,7 @@ int brcms_c_get_header_len() } /* mac is assumed to be suspended at this point */ -void +static void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], int len, bool both) { @@ -9053,8 +9055,8 @@ brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], } } -void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], int len, - bool both) +static void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], + int len, bool both) { brcms_b_write_hw_bcntemplates(wlc->hw, bcn, len, both); } @@ -9297,7 +9299,7 @@ void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, int bands) brcms_b_mhf(wlc->hw, idx, mask, val, bands); } -int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, +static int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, uint *blocks) { if (fifo >= NFIFO) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 3955d6eb83c..eec83abce9a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -1019,7 +1019,8 @@ wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, } uint -wlc_phy_init_radio_regs(struct brcms_phy *pi, struct radio_regs *radioregs, +wlc_phy_init_radio_regs(struct brcms_phy *pi, + const struct radio_regs *radioregs, u16 core_offset) { uint i = 0; @@ -1724,7 +1725,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) (*txpwr_recalc_fn)(pi); } -void +static void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, u16 chanspec) { @@ -2539,7 +2540,7 @@ void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *pih) wlc_phy_noise_sample_request(pih, PHY_NOISE_SAMPLE_EXTERNAL, channel); } -s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { +static const s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { 8, 8, 8, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index a06e7190bcd..e09752d25c5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -1023,7 +1023,7 @@ extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core); extern uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, struct radio_20xx_regs *radioregs); extern uint wlc_phy_init_radio_regs(struct brcms_phy *pi, - struct radio_regs *radioregs, + const struct radio_regs *radioregs, u16 core_offset); extern void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 941b7fa3f1a..fa21734902a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -878,7 +878,7 @@ struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { #define LCNPHY_NUM_DIG_FILT_COEFFS 16 #define LCNPHY_NUM_TX_DIG_FILTERS_CCK 13 -u16 LCNPHY_txdigfiltcoeffs_cck[LCNPHY_NUM_TX_DIG_FILTERS_CCK] +static const u16 LCNPHY_txdigfiltcoeffs_cck[LCNPHY_NUM_TX_DIG_FILTERS_CCK] [LCNPHY_NUM_DIG_FILT_COEFFS + 1] = { {0, 1, 415, 1874, 64, 128, 64, 792, 1656, 64, 128, 64, 778, 1582, 64, 128, 64,}, @@ -909,7 +909,7 @@ u16 LCNPHY_txdigfiltcoeffs_cck[LCNPHY_NUM_TX_DIG_FILTERS_CCK] }; #define LCNPHY_NUM_TX_DIG_FILTERS_OFDM 3 -u16 LCNPHY_txdigfiltcoeffs_ofdm[LCNPHY_NUM_TX_DIG_FILTERS_OFDM] +static const u16 LCNPHY_txdigfiltcoeffs_ofdm[LCNPHY_NUM_TX_DIG_FILTERS_OFDM] [LCNPHY_NUM_DIG_FILT_COEFFS + 1] = { {0, 0, 0xa2, 0x0, 0x100, 0x100, 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x278, 0xfea0, 0x80, 0x100, 0x80,}, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index cdf61858051..f4c89ae8405 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -218,7 +218,7 @@ struct nphy_ipa_txrxgain { #define NPHY_IPA_RXCAL_MAXGAININDEX (6 - 1) -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { +static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { {0, 0, 0, 0, 0, 100}, {0, 0, 0, 0, 0, 50}, {0, 0, 0, 0, 0, -1}, @@ -227,7 +227,7 @@ struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { {0, 2, 3, 3, 0, -1} }; -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { +static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { {0, 0, 0, 0, 0, 128}, {0, 0, 0, 0, 0, 70}, {0, 0, 0, 0, 0, 20}, @@ -236,7 +236,7 @@ struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { {0, 2, 3, 3, 0, 20} }; -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz_rev7[] = { +static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz_rev7[] = { {0, 0, 0, 0, 0, 100}, {0, 0, 0, 0, 0, 50}, {0, 0, 0, 0, 0, -1}, @@ -245,7 +245,7 @@ struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz_rev7[] = { {0, 0, 5, 3, 0, -1} }; -struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz_rev7[] = { +static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz_rev7[] = { {0, 0, 0, 0, 0, 10}, {0, 0, 0, 1, 0, 10}, {0, 0, 1, 2, 0, 10}, @@ -266,7 +266,7 @@ enum { (0x1 << 14) | \ (0x1 << 13))) -u16 NPHY_IPA_REV4_txdigi_filtcoeffs[][NPHY_NUM_DIG_FILT_COEFFS] = { +static const u16 NPHY_IPA_REV4_txdigi_filtcoeffs[][NPHY_NUM_DIG_FILT_COEFFS] = { {-377, 137, -407, 208, -1527, 956, 93, 186, 93, 230, -44, 230, 201, -191, 201}, {-77, 20, -98, 49, -93, 60, 56, 111, 56, 26, -5, @@ -10930,7 +10930,7 @@ struct radio_regs regs_RX_2056_rev8[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_SYN_2056_rev11[] = { +static const struct radio_regs regs_SYN_2056_rev11[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -11115,7 +11115,7 @@ struct radio_regs regs_SYN_2056_rev11[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_TX_2056_rev11[] = { +static const struct radio_regs regs_TX_2056_rev11[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -11272,7 +11272,7 @@ struct radio_regs regs_TX_2056_rev11[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_RX_2056_rev11[] = { +static const struct radio_regs regs_RX_2056_rev11[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -20140,9 +20140,9 @@ static void wlc_phy_radio_postinit_2057(struct brcms_phy *pi) static void wlc_phy_radio_init_2056(struct brcms_phy *pi) { - struct radio_regs *regs_SYN_2056_ptr = NULL; - struct radio_regs *regs_TX_2056_ptr = NULL; - struct radio_regs *regs_RX_2056_ptr = NULL; + const struct radio_regs *regs_SYN_2056_ptr = NULL; + const struct radio_regs *regs_TX_2056_ptr = NULL; + const struct radio_regs *regs_RX_2056_ptr = NULL; if (NREV_IS(pi->pubpi.phy_rev, 3)) { regs_SYN_2056_ptr = regs_SYN_2056; @@ -20637,7 +20637,7 @@ static void wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, const struct chan_info_nphy_radio205x *ci) { - struct radio_regs *regs_SYN_2056_ptr = NULL; + const struct radio_regs *regs_SYN_2056_ptr = NULL; write_radio_reg(pi, RADIO_2056_SYN_PLL_VCOCAL1 | RADIO_2056_SYN, @@ -27041,7 +27041,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, s8 optim_gaintbl_index = 0, prev_gaintbl_index = 0; s8 curr_gaintbl_index = 3; u8 gainctrl_dirn = NPHY_RXCAL_GAIN_INIT; - struct nphy_ipa_txrxgain *nphy_rxcal_gaintbl; + const struct nphy_ipa_txrxgain *nphy_rxcal_gaintbl; u16 hpvga, lpf_biq1, lpf_biq0, lna2, lna1; int fine_gain_idx; s8 txpwrindex; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c index c354496d3e7..15c5ffcc30a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c @@ -17,7 +17,7 @@ #include #include "phytbl_lcn.h" -const u32 dot11lcn_gain_tbl_rev0[] = { +static const u32 dot11lcn_gain_tbl_rev0[] = { 0x00000000, 0x00000000, 0x00000000, @@ -116,7 +116,7 @@ const u32 dot11lcn_gain_tbl_rev0[] = { 0x00000000, }; -const u32 dot11lcn_gain_tbl_rev1[] = { +static const u32 dot11lcn_gain_tbl_rev1[] = { 0x00000000, 0x00000000, 0x00000000, @@ -215,7 +215,7 @@ const u32 dot11lcn_gain_tbl_rev1[] = { 0x00000000, }; -const u16 dot11lcn_aux_gain_idx_tbl_rev0[] = { +static const u16 dot11lcn_aux_gain_idx_tbl_rev0[] = { 0x0401, 0x0402, 0x0403, @@ -256,7 +256,7 @@ const u16 dot11lcn_aux_gain_idx_tbl_rev0[] = { 0x0000, }; -const u32 dot11lcn_gain_idx_tbl_rev0[] = { +static const u32 dot11lcn_gain_idx_tbl_rev0[] = { 0x00000000, 0x00000000, 0x10000000, @@ -407,7 +407,7 @@ const u32 dot11lcn_gain_idx_tbl_rev0[] = { 0x0000001c, }; -const u16 dot11lcn_aux_gain_idx_tbl_2G[] = { +static const u16 dot11lcn_aux_gain_idx_tbl_2G[] = { 0x0000, 0x0000, 0x0000, @@ -448,7 +448,7 @@ const u16 dot11lcn_aux_gain_idx_tbl_2G[] = { 0x0000 }; -const u8 dot11lcn_gain_val_tbl_2G[] = { +static const u8 dot11lcn_gain_val_tbl_2G[] = { 0xfc, 0x02, 0x08, @@ -519,7 +519,7 @@ const u8 dot11lcn_gain_val_tbl_2G[] = { 0x00 }; -const u32 dot11lcn_gain_idx_tbl_2G[] = { +static const u32 dot11lcn_gain_idx_tbl_2G[] = { 0x00000000, 0x00000000, 0x00000000, @@ -674,7 +674,7 @@ const u32 dot11lcn_gain_idx_tbl_2G[] = { 0x00000000 }; -const u32 dot11lcn_gain_tbl_2G[] = { +static const u32 dot11lcn_gain_tbl_2G[] = { 0x00000000, 0x00000004, 0x00000008, @@ -773,7 +773,7 @@ const u32 dot11lcn_gain_tbl_2G[] = { 0x00000000 }; -const u32 dot11lcn_gain_tbl_extlna_2G[] = { +static const u32 dot11lcn_gain_tbl_extlna_2G[] = { 0x00000000, 0x00000004, 0x00000008, @@ -872,7 +872,7 @@ const u32 dot11lcn_gain_tbl_extlna_2G[] = { 0x00000000 }; -const u16 dot11lcn_aux_gain_idx_tbl_extlna_2G[] = { +static const u16 dot11lcn_aux_gain_idx_tbl_extlna_2G[] = { 0x0400, 0x0400, 0x0400, @@ -913,7 +913,7 @@ const u16 dot11lcn_aux_gain_idx_tbl_extlna_2G[] = { 0x0000 }; -const u8 dot11lcn_gain_val_tbl_extlna_2G[] = { +static const u8 dot11lcn_gain_val_tbl_extlna_2G[] = { 0xfc, 0x02, 0x08, @@ -984,7 +984,7 @@ const u8 dot11lcn_gain_val_tbl_extlna_2G[] = { 0x00 }; -const u32 dot11lcn_gain_idx_tbl_extlna_2G[] = { +static const u32 dot11lcn_gain_idx_tbl_extlna_2G[] = { 0x00000000, 0x00000040, 0x00000000, @@ -1139,7 +1139,7 @@ const u32 dot11lcn_gain_idx_tbl_extlna_2G[] = { 0x00000000 }; -const u32 dot11lcn_aux_gain_idx_tbl_5G[] = { +static const u32 dot11lcn_aux_gain_idx_tbl_5G[] = { 0x0000, 0x0000, 0x0000, @@ -1180,7 +1180,7 @@ const u32 dot11lcn_aux_gain_idx_tbl_5G[] = { 0x0000 }; -const u32 dot11lcn_gain_val_tbl_5G[] = { +static const u32 dot11lcn_gain_val_tbl_5G[] = { 0xf7, 0xfd, 0x00, @@ -1251,7 +1251,7 @@ const u32 dot11lcn_gain_val_tbl_5G[] = { 0x00 }; -const u32 dot11lcn_gain_idx_tbl_5G[] = { +static const u32 dot11lcn_gain_idx_tbl_5G[] = { 0x00000000, 0x00000000, 0x00000000, @@ -1406,7 +1406,7 @@ const u32 dot11lcn_gain_idx_tbl_5G[] = { 0x00000000 }; -const u32 dot11lcn_gain_tbl_5G[] = { +static const u32 dot11lcn_gain_tbl_5G[] = { 0x00000000, 0x00000040, 0x00000080, @@ -1520,7 +1520,7 @@ const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[] = { , }; -const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev1[] = { +static const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev1[] = { {&dot11lcn_gain_tbl_rev1, sizeof(dot11lcn_gain_tbl_rev1) / sizeof(dot11lcn_gain_tbl_rev1[0]), 18, 0, 32} @@ -1611,7 +1611,7 @@ const u32 dot11lcnphytbl_rx_gain_info_sz_rev0 = sizeof(dot11lcnphytbl_rx_gain_info_rev0) / sizeof(dot11lcnphytbl_rx_gain_info_rev0[0]); -const u32 dot11lcnphytbl_rx_gain_info_sz_rev1 = +static const u32 dot11lcnphytbl_rx_gain_info_sz_rev1 = sizeof(dot11lcnphytbl_rx_gain_info_rev1) / sizeof(dot11lcnphytbl_rx_gain_info_rev1[0]); @@ -1623,7 +1623,7 @@ const u32 dot11lcnphytbl_rx_gain_info_5G_rev2_sz = sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2) / sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2[0]); -const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { +static const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { 0x014d, 0x014d, 0x014d, @@ -1690,7 +1690,7 @@ const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { 0x014d, }; -const u16 dot11lcn_noise_scale_tbl_rev0[] = { +static const u16 dot11lcn_noise_scale_tbl_rev0[] = { 0x0000, 0x0000, 0x0000, @@ -1757,7 +1757,7 @@ const u16 dot11lcn_noise_scale_tbl_rev0[] = { 0x0000, }; -const u32 dot11lcn_fltr_ctrl_tbl_rev0[] = { +static const u32 dot11lcn_fltr_ctrl_tbl_rev0[] = { 0x000141f8, 0x000021f8, 0x000021fb, @@ -1770,7 +1770,7 @@ const u32 dot11lcn_fltr_ctrl_tbl_rev0[] = { 0x0000024b, }; -const u32 dot11lcn_ps_ctrl_tbl_rev0[] = { +static const u32 dot11lcn_ps_ctrl_tbl_rev0[] = { 0x00100001, 0x00200010, 0x00300001, @@ -1793,7 +1793,7 @@ const u32 dot11lcn_ps_ctrl_tbl_rev0[] = { 0x00600f22, }; -const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[] = { +static const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[] = { 0x0007, 0x0005, 0x0006, @@ -1861,7 +1861,7 @@ const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[] = { }; -const u16 dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[] = { +static const u16 dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[] = { 0x0007, 0x0005, 0x0002, @@ -1928,7 +1928,7 @@ const u16 dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[] = { 0x0002, }; -const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0[] = { +static const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0[] = { 0x0002, 0x0008, 0x0004, @@ -1995,7 +1995,7 @@ const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0[] = { 0x0001, }; -const u16 dot11lcn_sw_ctrl_tbl_4313_rev0[] = { +static const u16 dot11lcn_sw_ctrl_tbl_4313_rev0[] = { 0x000a, 0x0009, 0x0006, @@ -2062,7 +2062,7 @@ const u16 dot11lcn_sw_ctrl_tbl_4313_rev0[] = { 0x0005, }; -const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { +static const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { 0x0004, 0x0004, 0x0002, @@ -2129,7 +2129,7 @@ const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { 0x0002, }; -const u8 dot11lcn_nf_table_rev0[] = { +static const u8 dot11lcn_nf_table_rev0[] = { 0x5f, 0x36, 0x29, @@ -2148,7 +2148,7 @@ const u8 dot11lcn_nf_table_rev0[] = { 0x1f, }; -const u8 dot11lcn_gain_val_tbl_rev0[] = { +static const u8 dot11lcn_gain_val_tbl_rev0[] = { 0x09, 0x0f, 0x14, @@ -2211,7 +2211,7 @@ const u8 dot11lcn_gain_val_tbl_rev0[] = { 0x00, }; -const u8 dot11lcn_spur_tbl_rev0[] = { +static const u8 dot11lcn_spur_tbl_rev0[] = { 0x01, 0x01, 0x01, @@ -2342,7 +2342,7 @@ const u8 dot11lcn_spur_tbl_rev0[] = { 0x01, }; -const u16 dot11lcn_unsup_mcs_tbl_rev0[] = { +static const u16 dot11lcn_unsup_mcs_tbl_rev0[] = { 0x001a, 0x0034, 0x004e, @@ -2499,7 +2499,7 @@ const u16 dot11lcn_unsup_mcs_tbl_rev0[] = { 0x06f6, }; -const u16 dot11lcn_iq_local_tbl_rev0[] = { +static const u16 dot11lcn_iq_local_tbl_rev0[] = { 0x0200, 0x0300, 0x0400, @@ -2610,7 +2610,7 @@ const u16 dot11lcn_iq_local_tbl_rev0[] = { 0x0000, }; -const u32 dot11lcn_papd_compdelta_tbl_rev0[] = { +static const u32 dot11lcn_papd_compdelta_tbl_rev0[] = { 0x00080000, 0x00080000, 0x00080000, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c index d1455aeebf4..dbf50ef6cd7 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c @@ -17,7 +17,7 @@ #include #include "phytbl_n.h" -const u32 frame_struct_rev0[] = { +static const u32 frame_struct_rev0[] = { 0x08004a04, 0x00100000, 0x01000a05, @@ -852,7 +852,7 @@ const u32 frame_struct_rev0[] = { 0x00000000, }; -const u8 frame_lut_rev0[] = { +static const u8 frame_lut_rev0[] = { 0x02, 0x04, 0x14, @@ -887,7 +887,7 @@ const u8 frame_lut_rev0[] = { 0x2a, }; -const u32 tmap_tbl_rev0[] = { +static const u32 tmap_tbl_rev0[] = { 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, @@ -1338,7 +1338,7 @@ const u32 tmap_tbl_rev0[] = { 0x00000000, }; -const u32 tdtrn_tbl_rev0[] = { +static const u32 tdtrn_tbl_rev0[] = { 0x061c061c, 0x0050ee68, 0xf592fe36, @@ -2045,7 +2045,7 @@ const u32 tdtrn_tbl_rev0[] = { 0x00f006be, }; -const u32 intlv_tbl_rev0[] = { +static const u32 intlv_tbl_rev0[] = { 0x00802070, 0x0671188d, 0x0a60192c, @@ -2055,7 +2055,7 @@ const u32 intlv_tbl_rev0[] = { 0x00000070, }; -const u16 pilot_tbl_rev0[] = { +static const u16 pilot_tbl_rev0[] = { 0xff08, 0xff08, 0xff08, @@ -2146,7 +2146,7 @@ const u16 pilot_tbl_rev0[] = { 0xffff, }; -const u32 pltlut_tbl_rev0[] = { +static const u32 pltlut_tbl_rev0[] = { 0x76540123, 0x62407351, 0x76543201, @@ -2155,7 +2155,7 @@ const u32 pltlut_tbl_rev0[] = { 0x76430521, }; -const u32 tdi_tbl20_ant0_rev0[] = { +static const u32 tdi_tbl20_ant0_rev0[] = { 0x00091226, 0x000a1429, 0x000b56ad, @@ -2213,7 +2213,7 @@ const u32 tdi_tbl20_ant0_rev0[] = { 0x00000000, }; -const u32 tdi_tbl20_ant1_rev0[] = { +static const u32 tdi_tbl20_ant1_rev0[] = { 0x00014b26, 0x00028d29, 0x000393ad, @@ -2271,7 +2271,7 @@ const u32 tdi_tbl20_ant1_rev0[] = { 0x00000000, }; -const u32 tdi_tbl40_ant0_rev0[] = { +static const u32 tdi_tbl40_ant0_rev0[] = { 0x0011a346, 0x00136ccf, 0x0014f5d9, @@ -2384,7 +2384,7 @@ const u32 tdi_tbl40_ant0_rev0[] = { 0x00000000, }; -const u32 tdi_tbl40_ant1_rev0[] = { +static const u32 tdi_tbl40_ant1_rev0[] = { 0x001edb36, 0x000129ca, 0x0002b353, @@ -2497,7 +2497,7 @@ const u32 tdi_tbl40_ant1_rev0[] = { 0x00000000, }; -const u16 bdi_tbl_rev0[] = { +static const u16 bdi_tbl_rev0[] = { 0x0070, 0x0126, 0x012c, @@ -2506,7 +2506,7 @@ const u16 bdi_tbl_rev0[] = { 0x04d2, }; -const u32 chanest_tbl_rev0[] = { +static const u32 chanest_tbl_rev0[] = { 0x44444444, 0x44444444, 0x44444444, @@ -2605,7 +2605,7 @@ const u32 chanest_tbl_rev0[] = { 0x10101010, }; -const u8 mcs_tbl_rev0[] = { +static const u8 mcs_tbl_rev0[] = { 0x00, 0x08, 0x0a, @@ -2736,7 +2736,7 @@ const u8 mcs_tbl_rev0[] = { 0x00, }; -const u32 noise_var_tbl0_rev0[] = { +static const u32 noise_var_tbl0_rev0[] = { 0x020c020c, 0x0000014d, 0x020c020c, @@ -2995,7 +2995,7 @@ const u32 noise_var_tbl0_rev0[] = { 0x0000014d, }; -const u32 noise_var_tbl1_rev0[] = { +static const u32 noise_var_tbl1_rev0[] = { 0x020c020c, 0x0000014d, 0x020c020c, @@ -3254,7 +3254,7 @@ const u32 noise_var_tbl1_rev0[] = { 0x0000014d, }; -const u8 est_pwr_lut_core0_rev0[] = { +static const u8 est_pwr_lut_core0_rev0[] = { 0x50, 0x4f, 0x4e, @@ -3321,7 +3321,7 @@ const u8 est_pwr_lut_core0_rev0[] = { 0x11, }; -const u8 est_pwr_lut_core1_rev0[] = { +static const u8 est_pwr_lut_core1_rev0[] = { 0x50, 0x4f, 0x4e, @@ -3388,7 +3388,7 @@ const u8 est_pwr_lut_core1_rev0[] = { 0x11, }; -const u8 adj_pwr_lut_core0_rev0[] = { +static const u8 adj_pwr_lut_core0_rev0[] = { 0x00, 0x00, 0x00, @@ -3519,7 +3519,7 @@ const u8 adj_pwr_lut_core0_rev0[] = { 0x00, }; -const u8 adj_pwr_lut_core1_rev0[] = { +static const u8 adj_pwr_lut_core1_rev0[] = { 0x00, 0x00, 0x00, @@ -3650,7 +3650,7 @@ const u8 adj_pwr_lut_core1_rev0[] = { 0x00, }; -const u32 gainctrl_lut_core0_rev0[] = { +static const u32 gainctrl_lut_core0_rev0[] = { 0x03cc2b44, 0x03cc2b42, 0x03cc2b40, @@ -3781,7 +3781,7 @@ const u32 gainctrl_lut_core0_rev0[] = { 0x00002b00, }; -const u32 gainctrl_lut_core1_rev0[] = { +static const u32 gainctrl_lut_core1_rev0[] = { 0x03cc2b44, 0x03cc2b42, 0x03cc2b40, @@ -3912,7 +3912,7 @@ const u32 gainctrl_lut_core1_rev0[] = { 0x00002b00, }; -const u32 iq_lut_core0_rev0[] = { +static const u32 iq_lut_core0_rev0[] = { 0x0000007f, 0x0000007f, 0x0000007f, @@ -4043,7 +4043,7 @@ const u32 iq_lut_core0_rev0[] = { 0x0000007f, }; -const u32 iq_lut_core1_rev0[] = { +static const u32 iq_lut_core1_rev0[] = { 0x0000007f, 0x0000007f, 0x0000007f, @@ -4174,7 +4174,7 @@ const u32 iq_lut_core1_rev0[] = { 0x0000007f, }; -const u16 loft_lut_core0_rev0[] = { +static const u16 loft_lut_core0_rev0[] = { 0x0000, 0x0101, 0x0002, @@ -4305,7 +4305,7 @@ const u16 loft_lut_core0_rev0[] = { 0x0103, }; -const u16 loft_lut_core1_rev0[] = { +static const u16 loft_lut_core1_rev0[] = { 0x0000, 0x0101, 0x0002, @@ -4541,7 +4541,7 @@ const u32 mimophytbl_info_sz_rev0_volatile = sizeof(mimophytbl_info_rev0_volatile) / sizeof(mimophytbl_info_rev0_volatile[0]); -const u16 ant_swctrl_tbl_rev3[] = { +static const u16 ant_swctrl_tbl_rev3[] = { 0x0082, 0x0082, 0x0211, @@ -4576,7 +4576,7 @@ const u16 ant_swctrl_tbl_rev3[] = { 0x0000, }; -const u16 ant_swctrl_tbl_rev3_1[] = { +static const u16 ant_swctrl_tbl_rev3_1[] = { 0x0022, 0x0022, 0x0011, @@ -4611,7 +4611,7 @@ const u16 ant_swctrl_tbl_rev3_1[] = { 0x0000, }; -const u16 ant_swctrl_tbl_rev3_2[] = { +static const u16 ant_swctrl_tbl_rev3_2[] = { 0x0088, 0x0088, 0x0044, @@ -4646,7 +4646,7 @@ const u16 ant_swctrl_tbl_rev3_2[] = { 0x0000, }; -const u16 ant_swctrl_tbl_rev3_3[] = { +static const u16 ant_swctrl_tbl_rev3_3[] = { 0x022, 0x022, 0x011, @@ -4681,7 +4681,7 @@ const u16 ant_swctrl_tbl_rev3_3[] = { 0x3cc }; -const u32 frame_struct_rev3[] = { +static const u32 frame_struct_rev3[] = { 0x08004a04, 0x00100000, 0x01000a05, @@ -5516,7 +5516,7 @@ const u32 frame_struct_rev3[] = { 0x00000000, }; -const u16 pilot_tbl_rev3[] = { +static const u16 pilot_tbl_rev3[] = { 0xff08, 0xff08, 0xff08, @@ -5607,7 +5607,7 @@ const u16 pilot_tbl_rev3[] = { 0xffff, }; -const u32 tmap_tbl_rev3[] = { +static const u32 tmap_tbl_rev3[] = { 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, @@ -6058,7 +6058,7 @@ const u32 tmap_tbl_rev3[] = { 0x00000000, }; -const u32 intlv_tbl_rev3[] = { +static const u32 intlv_tbl_rev3[] = { 0x00802070, 0x0671188d, 0x0a60192c, @@ -6068,7 +6068,7 @@ const u32 intlv_tbl_rev3[] = { 0x00000070, }; -const u32 tdtrn_tbl_rev3[] = { +static const u32 tdtrn_tbl_rev3[] = { 0x061c061c, 0x0050ee68, 0xf592fe36, @@ -7034,7 +7034,7 @@ const u32 noise_var_tbl_rev3[] = { 0x0000014d, }; -const u16 mcs_tbl_rev3[] = { +static const u16 mcs_tbl_rev3[] = { 0x0000, 0x0008, 0x000a, @@ -7165,7 +7165,7 @@ const u16 mcs_tbl_rev3[] = { 0x0007, }; -const u32 tdi_tbl20_ant0_rev3[] = { +static const u32 tdi_tbl20_ant0_rev3[] = { 0x00091226, 0x000a1429, 0x000b56ad, @@ -7223,7 +7223,7 @@ const u32 tdi_tbl20_ant0_rev3[] = { 0x00000000, }; -const u32 tdi_tbl20_ant1_rev3[] = { +static const u32 tdi_tbl20_ant1_rev3[] = { 0x00014b26, 0x00028d29, 0x000393ad, @@ -7281,7 +7281,7 @@ const u32 tdi_tbl20_ant1_rev3[] = { 0x00000000, }; -const u32 tdi_tbl40_ant0_rev3[] = { +static const u32 tdi_tbl40_ant0_rev3[] = { 0x0011a346, 0x00136ccf, 0x0014f5d9, @@ -7394,7 +7394,7 @@ const u32 tdi_tbl40_ant0_rev3[] = { 0x00000000, }; -const u32 tdi_tbl40_ant1_rev3[] = { +static const u32 tdi_tbl40_ant1_rev3[] = { 0x001edb36, 0x000129ca, 0x0002b353, @@ -7507,7 +7507,7 @@ const u32 tdi_tbl40_ant1_rev3[] = { 0x00000000, }; -const u32 pltlut_tbl_rev3[] = { +static const u32 pltlut_tbl_rev3[] = { 0x76540213, 0x62407351, 0x76543210, @@ -7516,7 +7516,7 @@ const u32 pltlut_tbl_rev3[] = { 0x76430521, }; -const u32 chanest_tbl_rev3[] = { +static const u32 chanest_tbl_rev3[] = { 0x44444444, 0x44444444, 0x44444444, @@ -7615,7 +7615,7 @@ const u32 chanest_tbl_rev3[] = { 0x10101010, }; -const u8 frame_lut_rev3[] = { +static const u8 frame_lut_rev3[] = { 0x02, 0x04, 0x14, @@ -7650,7 +7650,7 @@ const u8 frame_lut_rev3[] = { 0x2a, }; -const u8 est_pwr_lut_core0_rev3[] = { +static const u8 est_pwr_lut_core0_rev3[] = { 0x55, 0x54, 0x54, @@ -7717,7 +7717,7 @@ const u8 est_pwr_lut_core0_rev3[] = { 0xfd, }; -const u8 est_pwr_lut_core1_rev3[] = { +static const u8 est_pwr_lut_core1_rev3[] = { 0x55, 0x54, 0x54, @@ -7784,7 +7784,7 @@ const u8 est_pwr_lut_core1_rev3[] = { 0xfd, }; -const u8 adj_pwr_lut_core0_rev3[] = { +static const u8 adj_pwr_lut_core0_rev3[] = { 0x00, 0x00, 0x00, @@ -7915,7 +7915,7 @@ const u8 adj_pwr_lut_core0_rev3[] = { 0x00, }; -const u8 adj_pwr_lut_core1_rev3[] = { +static const u8 adj_pwr_lut_core1_rev3[] = { 0x00, 0x00, 0x00, @@ -8046,7 +8046,7 @@ const u8 adj_pwr_lut_core1_rev3[] = { 0x00, }; -const u32 gainctrl_lut_core0_rev3[] = { +static const u32 gainctrl_lut_core0_rev3[] = { 0x5bf70044, 0x5bf70042, 0x5bf70040, @@ -8177,7 +8177,7 @@ const u32 gainctrl_lut_core0_rev3[] = { 0x5b07001c, }; -const u32 gainctrl_lut_core1_rev3[] = { +static const u32 gainctrl_lut_core1_rev3[] = { 0x5bf70044, 0x5bf70042, 0x5bf70040, @@ -8308,7 +8308,7 @@ const u32 gainctrl_lut_core1_rev3[] = { 0x5b07001c, }; -const u32 iq_lut_core0_rev3[] = { +static const u32 iq_lut_core0_rev3[] = { 0x00000000, 0x00000000, 0x00000000, @@ -8439,7 +8439,7 @@ const u32 iq_lut_core0_rev3[] = { 0x00000000, }; -const u32 iq_lut_core1_rev3[] = { +static const u32 iq_lut_core1_rev3[] = { 0x00000000, 0x00000000, 0x00000000, @@ -8570,7 +8570,7 @@ const u32 iq_lut_core1_rev3[] = { 0x00000000, }; -const u16 loft_lut_core0_rev3[] = { +static const u16 loft_lut_core0_rev3[] = { 0x0000, 0x0000, 0x0000, @@ -8701,7 +8701,7 @@ const u16 loft_lut_core0_rev3[] = { 0x0000, }; -const u16 loft_lut_core1_rev3[] = { +static const u16 loft_lut_core1_rev3[] = { 0x0000, 0x0000, 0x0000, @@ -8832,7 +8832,7 @@ const u16 loft_lut_core1_rev3[] = { 0x0000, }; -const u16 papd_comp_rfpwr_tbl_core0_rev3[] = { +static const u16 papd_comp_rfpwr_tbl_core0_rev3[] = { 0x0036, 0x0036, 0x0036, @@ -8963,7 +8963,7 @@ const u16 papd_comp_rfpwr_tbl_core0_rev3[] = { 0x01d6, }; -const u16 papd_comp_rfpwr_tbl_core1_rev3[] = { +static const u16 papd_comp_rfpwr_tbl_core1_rev3[] = { 0x0036, 0x0036, 0x0036, @@ -9094,7 +9094,7 @@ const u16 papd_comp_rfpwr_tbl_core1_rev3[] = { 0x01d6, }; -const u32 papd_comp_epsilon_tbl_core0_rev3[] = { +static const u32 papd_comp_epsilon_tbl_core0_rev3[] = { 0x00000000, 0x00001fa0, 0x00019f78, @@ -9161,7 +9161,7 @@ const u32 papd_comp_epsilon_tbl_core0_rev3[] = { 0x03e38ffe, }; -const u32 papd_cal_scalars_tbl_core0_rev3[] = { +static const u32 papd_cal_scalars_tbl_core0_rev3[] = { 0x05af005a, 0x0571005e, 0x05040066, @@ -9228,7 +9228,7 @@ const u32 papd_cal_scalars_tbl_core0_rev3[] = { 0x002606a4, }; -const u32 papd_comp_epsilon_tbl_core1_rev3[] = { +static const u32 papd_comp_epsilon_tbl_core1_rev3[] = { 0x00000000, 0x00001fa0, 0x00019f78, @@ -9295,7 +9295,7 @@ const u32 papd_comp_epsilon_tbl_core1_rev3[] = { 0x03e38ffe, }; -const u32 papd_cal_scalars_tbl_core1_rev3[] = { +static const u32 papd_cal_scalars_tbl_core1_rev3[] = { 0x05af005a, 0x0571005e, 0x05040066, @@ -9490,7 +9490,7 @@ const u32 mimophytbl_info_sz_rev3_volatile3 = sizeof(mimophytbl_info_rev3_volatile3) / sizeof(mimophytbl_info_rev3_volatile3[0]); -const u32 tmap_tbl_rev7[] = { +static const u32 tmap_tbl_rev7[] = { 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, @@ -10200,7 +10200,7 @@ const u32 noise_var_tbl_rev7[] = { 0x0000014d, }; -const u32 papd_comp_epsilon_tbl_core0_rev7[] = { +static const u32 papd_comp_epsilon_tbl_core0_rev7[] = { 0x00000000, 0x00000000, 0x00016023, @@ -10267,7 +10267,7 @@ const u32 papd_comp_epsilon_tbl_core0_rev7[] = { 0x0156cfff, }; -const u32 papd_cal_scalars_tbl_core0_rev7[] = { +static const u32 papd_cal_scalars_tbl_core0_rev7[] = { 0x0b5e002d, 0x0ae2002f, 0x0a3b0032, @@ -10334,7 +10334,7 @@ const u32 papd_cal_scalars_tbl_core0_rev7[] = { 0x004e068c, }; -const u32 papd_comp_epsilon_tbl_core1_rev7[] = { +static const u32 papd_comp_epsilon_tbl_core1_rev7[] = { 0x00000000, 0x00000000, 0x00016023, @@ -10401,7 +10401,7 @@ const u32 papd_comp_epsilon_tbl_core1_rev7[] = { 0x0156cfff, }; -const u32 papd_cal_scalars_tbl_core1_rev7[] = { +static const u32 papd_cal_scalars_tbl_core1_rev7[] = { 0x0b5e002d, 0x0ae2002f, 0x0a3b0032, diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index 5fb0d9e8c5e..9730139f590 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -208,7 +208,7 @@ const struct brcms_c_rateset ofdm_mimo_rates = { }; /* Default ratesets that include MCS32 for 40BW channels */ -const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { +static const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { 12, /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48 */ { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, @@ -219,7 +219,7 @@ const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { 0x00, 0x00, 0x00, 0x00, 0x00} }; -const struct brcms_c_rateset ofdm_40bw_mimo_rates = { +static const struct brcms_c_rateset ofdm_40bw_mimo_rates = { 8, /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 0c32e20ec47..7a9349c9918 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -34,7 +34,8 @@ #define NSTS_2 2 #define NSTS_3 3 #define NSTS_4 4 -const u8 txcore_default[5] = { + +static const u8 txcore_default[5] = { (0), /* bitmap of the core enabled */ (0x01), /* For Nsts = 1, enable core 1 */ (0x03), /* For Nsts = 2, enable core 1 & 2 */ diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c b/drivers/staging/brcm80211/brcmsmac/ucode_loader.c index bf733fb18ce..c14bce87358 100644 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c +++ b/drivers/staging/brcm80211/brcmsmac/ucode_loader.c @@ -50,8 +50,9 @@ u32 *bcm43xx_16_mimo; u32 bcm43xx_16_mimosz; u32 *bcm43xx_24_lcn; u32 bcm43xx_24_lcnsz; -u32 *bcm43xx_bommajor; -u32 *bcm43xx_bomminor; + +static u32 *bcm43xx_bommajor; +static u32 *bcm43xx_bomminor; int brcms_ucode_data_init(struct brcms_info *wl) { From 33988fc3f9a82ea909764b7bd564b3c2568cbc68 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:14 +0200 Subject: [PATCH 0862/1519] staging: brcm80211: removed redundant macro's in softmac Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 29 +-------------- drivers/staging/brcm80211/brcmsmac/aiutils.h | 36 ------------------- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 21 ++++++++--- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 34 ------------------ .../staging/brcm80211/brcmsmac/phy/phy_n.c | 31 +++++++++------- 5 files changed, 37 insertions(+), 114 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index f78cc501d40..e98eb2795af 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -202,10 +202,6 @@ /* 12 mA drive strengh for later 4313 */ #define CCTRL_4313_12MA_LED_DRIVE 0x00000007 -#define BCM47162_DMP() ((sih->chip == BCM47162_CHIP_ID) && \ - (sih->chiprev == 0) && \ - (sii->coreid[sii->curidx] == MIPS74K_CORE_ID)) - /* Manufacturer Ids */ #define MFGID_ARM 0x43b #define MFGID_BRCM 0x4bf @@ -750,11 +746,6 @@ uint ai_flag(struct si_pub *sih) struct aidmp *ai; sii = SI_INFO(sih); - if (BCM47162_DMP()) { - SI_ERROR(("%s: Attempting to read MIPS DMP registers " - "on 47162a0", __func__)); - return sii->curidx; - } ai = sii->curwrap; return R_REG(&ai->oobselouta30) & 0x1f; @@ -805,12 +796,6 @@ void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val) sii = SI_INFO(sih); - if (BCM47162_DMP()) { - SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0", - __func__)); - return; - } - ai = sii->curwrap; if (mask || val) { @@ -826,12 +811,6 @@ u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) u32 w; sii = SI_INFO(sih); - if (BCM47162_DMP()) { - SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0", - __func__)); - return 0; - } - ai = sii->curwrap; if (mask || val) { @@ -871,12 +850,6 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) u32 w; sii = SI_INFO(sih); - if (BCM47162_DMP()) { - SI_ERROR(("%s: Accessing MIPS DMP register (iostatus) " - "on 47162a0", __func__)); - return 0; - } - ai = sii->curwrap; if (mask || val) { @@ -1073,7 +1046,7 @@ static struct si_info *ai_doattach(struct si_info *sii, sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT; sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT; - sih->issim = IS_SIM(sih->chippkg); + sih->issim = false; /* scan for cores */ if (socitype == SOCI_AI) { diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 5dee80ffd83..b1f2c38814f 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -233,48 +233,15 @@ #define SRC_SIZE_SHIFT 1 #define SRC_PRESENT 0x00000001 -/* 4330 chip-specific ChipStatus register bits */ - /* SDIO || gSPI */ -#define CST4330_CHIPMODE_SDIOD(cs) (((cs) & 0x7) < 6) - /* USB || USBDA */ -#define CST4330_CHIPMODE_USB20D(cs) (((cs) & 0x7) >= 6) - /* SDIO */ -#define CST4330_CHIPMODE_SDIO(cs) (((cs) & 0x4) == 0) - /* gSPI */ -#define CST4330_CHIPMODE_GSPI(cs) (((cs) & 0x6) == 4) - /* USB packet-oriented */ -#define CST4330_CHIPMODE_USB(cs) (((cs) & 0x7) == 6) - /* USB Direct Access */ -#define CST4330_CHIPMODE_USBDA(cs) (((cs) & 0x7) == 7) -#define CST4330_OTP_PRESENT 0x00000010 -#define CST4330_LPO_AUTODET_EN 0x00000020 -#define CST4330_ARMREMAP_0 0x00000040 - /* takes priority over OTP if both set */ -#define CST4330_SPROM_PRESENT 0x00000080 -#define CST4330_ILPDIV_EN 0x00000100 -#define CST4330_LPO_SEL 0x00000200 -#define CST4330_RES_INIT_MODE_SHIFT 10 -#define CST4330_RES_INIT_MODE_MASK 0x00000c00 -#define CST4330_CBUCK_MODE_SHIFT 12 -#define CST4330_CBUCK_MODE_MASK 0x00003000 -#define CST4330_CBUCK_POWER_OK 0x00004000 -#define CST4330_BB_PLL_LOCKED 0x00008000 - /* Package IDs */ -#define BCM4329_289PIN_PKG_ID 0 /* 4329 289-pin package id */ -#define BCM4329_182PIN_PKG_ID 1 /* 4329N 182-pin package id */ #define BCM4717_PKG_ID 9 /* 4717 package id */ #define BCM4718_PKG_ID 10 /* 4718 package id */ -#define HDLSIM_PKG_ID 14 /* HDL simulator package id */ -#define HWSIM_PKG_ID 15 /* Hardware simulator package id */ #define BCM43224_FAB_SMIC 0xa /* the chip is manufactured by SMIC */ /* these are router chips */ #define BCM4716_CHIP_ID 0x4716 /* 4716 chipcommon chipid */ #define BCM47162_CHIP_ID 47162 /* 47162 chipcommon chipid */ #define BCM4748_CHIP_ID 0x4748 /* 4716 chipcommon chipid (OTP, RBBU) */ -#define BCM5356_CHIP_ID 0x5356 /* 5356 chipcommon chipid */ -#define BCM5357_CHIP_ID 0x5357 /* 5357 chipcommon chipid */ #define SI_INFO(sih) ((struct si_info *)sih) @@ -424,9 +391,6 @@ struct si_pub { /* Define SI_VMSG to printf for verbose debugging, but don't check it in */ #define SI_VMSG(args) -#define IS_SIM(chippkg) \ - ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) - struct pci_dev; struct gpioh_item { diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index eec83abce9a..b52b30589c1 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -27,6 +27,16 @@ #include "phy_lcn.h" #include "phyreg_n.h" +#define VALID_N_RADIO(radioid) ((radioid == BCM2055_ID) || \ + (radioid == BCM2056_ID) || \ + (radioid == BCM2057_ID)) + +#define VALID_LCN_RADIO(radioid) (radioid == BCM2064_ID) + +#define VALID_RADIO(pi, radioid) ( \ + (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ + (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) + struct chan_info_basic { u16 chan; u16 freq; @@ -545,7 +555,8 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, pi->pubpi.phy_corenum = PHY_CORE_NUM_2; pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; - if (!VALID_PHYTYPE(pi->pubpi.phy_type)) + if (!pi->pubpi.phy_type == PHY_TYPE_N && + !pi->pubpi.phy_type == PHY_TYPE_LCN) goto err; if (BAND_5G(bandtype)) { @@ -1340,7 +1351,7 @@ u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { channel = chan_info_all[i].chan; - if (ISNPHY(pi) && IS40MHZ(pi)) { + if (ISNPHY(pi) && pi->bw == WL_CHANSPEC_BW_40) { uint j; for (j = 0; j < ARRAY_SIZE(chan_info_all); j++) { @@ -2881,7 +2892,8 @@ void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) pi->sh->hw_phyrxchain = rxchain; pi->sh->phytxchain = txchain; pi->sh->phyrxchain = rxchain; - pi->pubpi.phy_corenum = (u8) PHY_BITSCNT(pi->sh->phyrxchain); + pi->pubpi.phy_corenum = (u8) brcmu_bitcount((u8 *)&pi->sh->phyrxchain, + sizeof(u8)); } void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) @@ -2893,7 +2905,8 @@ void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) if (ISNPHY(pi)) wlc_phy_rxcore_setstate_nphy(pih, rxchain); - pi->pubpi.phy_corenum = (u8) PHY_BITSCNT(pi->sh->phyrxchain); + pi->pubpi.phy_corenum = (u8) brcmu_bitcount((u8 *)&pi->sh->phyrxchain, + sizeof(u8)); } void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index e09752d25c5..b94117b006e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -40,16 +40,9 @@ struct brcms_phy_srom_fem { u8 antswctrllut; }; -#undef ISNPHY -#undef ISLCNPHY #define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N) #define ISLCNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_LCN) -#define ISPHY_11N_CAP(pi) (ISNPHY(pi) || ISLCNPHY(pi)) - -#define IS20MHZ(pi) ((pi)->bw == WL_CHANSPEC_BW_20) -#define IS40MHZ(pi) ((pi)->bw == WL_CHANSPEC_BW_40) - #define PHY_GET_RFATTN(rfgain) ((rfgain) & 0x0f) #define PHY_GET_PADMIX(rfgain) (((rfgain) & 0x10) >> 4) #define PHY_GET_RFGAINID(rfattn, padmix, width) ((rfattn) + ((padmix)*(width))) @@ -237,36 +230,9 @@ enum phy_cal_mode { #define PHY_CHAIN_TX_DISABLE_TEMP 115 #define PHY_HYSTERESIS_DELTATEMP 5 -#define PHY_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8)) - -#define MOD_PHY_REG(pi, phy_type, reg_name, field, value) \ - mod_phy_reg(pi, phy_type##_##reg_name, \ - phy_type##_##reg_name##_##field##_MASK, \ - (value) << phy_type##_##reg_name##_##field##_##SHIFT) - -#define READ_PHY_REG(pi, phy_type, reg_name, field) \ - ((read_phy_reg(pi, phy_type##_##reg_name) & \ - phy_type##_##reg_name##_##field##_##MASK) \ - >> phy_type##_##reg_name##_##field##_##SHIFT) - -#define VALID_PHYTYPE(phytype) (((uint)phytype == PHY_TYPE_N) || \ - ((uint)phytype == PHY_TYPE_LCN)) - -#define VALID_N_RADIO(radioid) ((radioid == BCM2055_ID) || \ - (radioid == BCM2056_ID) || \ - (radioid == BCM2057_ID)) - -#define VALID_LCN_RADIO(radioid) (radioid == BCM2064_ID) - -#define VALID_RADIO(pi, radioid) ( \ - (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ - (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) - #define SCAN_INPROG_PHY(pi) \ (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN)) -#define RM_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_RM)) - #define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT)) #define ASSOC_INPROG_PHY(pi) \ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index f4c89ae8405..7a50a23727f 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14756,7 +14756,7 @@ static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); } - if (IS40MHZ(pi)) { + if (pi->bw == WL_CHANSPEC_BW_40) { for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x186 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); @@ -14779,7 +14779,7 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) { int j; - if (IS40MHZ(pi)) { + if (pi->bw == WL_CHANSPEC_BW_40) { for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) write_phy_reg(pi, 0x195 + j, NPHY_IPA_REV4_txdigi_filtcoeffs[4][j]); @@ -20851,7 +20851,8 @@ wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, mixg_boost_tune); } else { - bias = IS40MHZ(pi) ? 0x40 : 0x20; + bias = (pi->bw == WL_CHANSPEC_BW_40) ? + 0x40 : 0x20; WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, INTPAG_IMAIN_STAT, bias); @@ -24872,11 +24873,13 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, if (CHSPEC_IS2G(pi->radio_chanspec)) { if ((pi->pubpi.radiorev <= 4) || (pi->pubpi.radiorev == 6)) - m[core] = IS40MHZ(pi) ? 60 : 79; + m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? + 60 : 79; else - m[core] = IS40MHZ(pi) ? 45 : 64; + m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? + 45 : 64; } else { - m[core] = IS40MHZ(pi) ? 75 : 107; + m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 75 : 107; } m[phy_a7] = 0; @@ -25015,9 +25018,9 @@ wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, } if (CHSPEC_IS2G(pi->radio_chanspec)) - m[core] = IS40MHZ(pi) ? 45 : 64; + m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 45 : 64; else - m[core] = IS40MHZ(pi) ? 75 : 107; + m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 75 : 107; m[phy_a7] = 0; wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); @@ -27583,8 +27586,10 @@ static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, txlpf_rccal_lpc = ((int)best_rccal[rx_core] - 12) + 10; if (PHY_IPA(pi)) { - txlpf_rccal_lpc += IS40MHZ(pi) ? 24 : 12; - txlpf_idac = IS40MHZ(pi) ? 0x0e : 0x13; + txlpf_rccal_lpc += + (pi->bw == WL_CHANSPEC_BW_40) ? 24 : 12; + txlpf_idac = (pi->bw == WL_CHANSPEC_BW_40) ? + 0x0e : 0x13; WRITE_RADIO_REG2(pi, RADIO_2056, TX, rx_core, TXLPF_IDAC_4, txlpf_idac); } @@ -28391,7 +28396,8 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) else if (NREV_LT(pi->pubpi.phy_rev, 2)) mod_phy_reg(pi, 0xdc, 0x00ff, 0x5a); - if (NREV_LT(pi->pubpi.phy_rev, 2) && IS40MHZ(pi)) + if (NREV_LT(pi->pubpi.phy_rev, 2) && + pi->bw == WL_CHANSPEC_BW_40) wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_IQSWAP_WAR, MHF1_IQSWAP_WAR, BRCM_BAND_ALL); @@ -28449,7 +28455,8 @@ void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) else if (NREV_LT(pi->pubpi.phy_rev, 2)) mod_phy_reg(pi, 0xdc, 0x00ff, 0x40); - if (NREV_LT(pi->pubpi.phy_rev, 2) && IS40MHZ(pi)) + if (NREV_LT(pi->pubpi.phy_rev, 2) && + pi->bw == WL_CHANSPEC_BW_40) wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_IQSWAP_WAR, 0x0, BRCM_BAND_ALL); From b9b1ce791baf3d55fad6273c4a7478c645e2d92d Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:15 +0200 Subject: [PATCH 0863/1519] staging: brcm80211: removed redundant SI_INFO() macro from softmac Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 80 ++++++++++---------- drivers/staging/brcm80211/brcmsmac/aiutils.h | 3 - drivers/staging/brcm80211/brcmsmac/nicpci.c | 4 +- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index e98eb2795af..48489ceeaac 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -485,7 +485,8 @@ static void ai_hwfixup(struct si_info *sii) /* parse the enumeration rom to identify all cores */ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) { - struct si_info *sii = SI_INFO(sih); + struct si_info *sii = (struct si_info *)sih; + u32 erombase, *eromptr, *eromlim; void *regs = cc; @@ -678,7 +679,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) */ void *ai_setcoreidx(struct si_pub *sih, uint coreidx) { - struct si_info *sii = SI_INFO(sih); + struct si_info *sii = (struct si_info *)sih; u32 addr = sii->coresba[coreidx]; u32 wrap = sii->wrapba[coreidx]; @@ -706,7 +707,7 @@ u32 ai_addrspace(struct si_pub *sih, uint asidx) struct si_info *sii; uint cidx; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; cidx = sii->curidx; if (asidx == 0) @@ -726,7 +727,7 @@ u32 ai_addrspacesize(struct si_pub *sih, uint asidx) struct si_info *sii; uint cidx; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; cidx = sii->curidx; if (asidx == 0) @@ -745,7 +746,7 @@ uint ai_flag(struct si_pub *sih) struct si_info *sii; struct aidmp *ai; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; return R_REG(&ai->oobselouta30) & 0x1f; @@ -760,7 +761,7 @@ uint ai_corevendor(struct si_pub *sih) struct si_info *sii; u32 cia; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; cia = sii->cia[sii->curidx]; return (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT; } @@ -770,7 +771,7 @@ uint ai_corerev(struct si_pub *sih) struct si_info *sii; u32 cib; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; cib = sii->cib[sii->curidx]; return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; } @@ -780,7 +781,7 @@ bool ai_iscoreup(struct si_pub *sih) struct si_info *sii; struct aidmp *ai; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) == @@ -794,7 +795,7 @@ void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val) struct aidmp *ai; u32 w; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; @@ -810,7 +811,7 @@ u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) struct aidmp *ai; u32 w; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; if (mask || val) { @@ -849,7 +850,7 @@ u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) struct aidmp *ai; u32 w; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; if (mask || val) { @@ -1184,7 +1185,7 @@ void ai_detach(struct si_pub *sih) struct si_pub *si_local = NULL; memcpy(&si_local, &sih, sizeof(struct si_pub **)); - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (sii == NULL) return; @@ -1205,7 +1206,7 @@ ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; sii->intr_arg = intr_arg; sii->intrsoff_fn = (u32 (*)(void *)) intrsoff_fn; sii->intrsrestore_fn = (void (*) (void *, u32)) intrsrestore_fn; @@ -1220,7 +1221,7 @@ void ai_deregister_intr_callback(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; sii->intrsoff_fn = NULL; } @@ -1228,7 +1229,7 @@ uint ai_coreid(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; return sii->coreid[sii->curidx]; } @@ -1236,7 +1237,7 @@ uint ai_coreidx(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; return sii->curidx; } @@ -1252,7 +1253,7 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) uint found; uint i; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; found = 0; @@ -1290,7 +1291,7 @@ void *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, void *cc; struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (SI_FAST(sii)) { /* Overloading the origidx variable to remember the coreid, @@ -1314,7 +1315,7 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (SI_FAST(sii) && ((coreid == CC_CORE_ID) || (coreid == sih->buscoretype))) return; @@ -1325,7 +1326,7 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val) { - struct si_info *sii = SI_INFO(sih); + struct si_info *sii = (struct si_info *)sih; u32 *w = (u32 *) sii->curwrap; W_REG(w + (offset / 4), val); return; @@ -1351,7 +1352,7 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, bool fast = false; struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (coreidx >= SI_MAXCORES) return 0; @@ -1418,7 +1419,7 @@ void ai_core_disable(struct si_pub *sih, u32 bits) u32 dummy; struct aidmp *ai; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; @@ -1445,7 +1446,7 @@ void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits) struct aidmp *ai; u32 dummy; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; ai = sii->curwrap; /* @@ -1564,7 +1565,7 @@ void ai_clkctl_init(struct si_pub *sih) if (!CCCTL_ENAB(sih)) return; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; fast = SI_FAST(sii); if (!fast) { origidx = sii->curidx; @@ -1602,7 +1603,7 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) uint intr_val = 0; bool fast; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (PMUCTL_ENAB(sih)) { INTR_OFF(sii, intr_val); fpdelay = si_pmu_fast_pwrup_delay(sih); @@ -1645,7 +1646,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) struct si_info *sii; u32 in, out, outen; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; /* pcie core doesn't have any mapping to control the xtal pu */ if (PCIE(sii)) @@ -1800,7 +1801,7 @@ bool ai_clkctl_cc(struct si_pub *sih, uint mode) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; /* chipcommon cores prior to rev6 don't support dynamic clock control */ if (sih->ccrev < 6) @@ -1821,8 +1822,9 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return -1; slen = snprintf(path, (size_t) size, "pci/%u/%u/", - (((SI_INFO(sih))->pbus))->bus->number, - PCI_SLOT(((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn)); + ((struct si_info *)sih)->pbus->bus->number, + PCI_SLOT(((struct pci_dev *) + (((struct si_info *)(sih))->pbus))->devfn)); if (slen < 0 || slen >= size) { path[0] = '\0'; @@ -1886,7 +1888,7 @@ bool ai_pci_war16165(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; return PCI(sii) && (sih->buscorerev <= 10); } @@ -1895,7 +1897,7 @@ void ai_pci_up(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (PCI_FORCEHT(sii)) _ai_clkctl_cc(sii, CLK_FAST); @@ -1910,7 +1912,7 @@ void ai_pci_sleep(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; pcicore_sleep(sii->pch); } @@ -1920,7 +1922,7 @@ void ai_pci_down(struct si_pub *sih) { struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; /* release FORCEHT since chip is going to "down" state */ if (PCI_FORCEHT(sii)) @@ -1940,7 +1942,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) u32 siflag = 0, w; uint idx = 0; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; if (PCI(sii)) { /* get current core index */ @@ -1983,7 +1985,7 @@ int ai_pci_fixcfg(struct si_pub *sih) { uint origidx; void *regs = NULL; - struct si_info *sii = SI_INFO(sih); + struct si_info *sii = (struct si_info *)sih; /* Fixup PI in SROM shadow area to enable the correct PCI core access */ /* save the current index */ @@ -2019,7 +2021,7 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) uint origidx; u32 val; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; origidx = ai_coreidx(sih); cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); @@ -2051,7 +2053,7 @@ void ai_epa_4313war(struct si_pub *sih) struct chipcregs *cc; uint origidx; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; origidx = ai_coreidx(sih); cc = ai_setcore(sih, CC_CORE_ID, 0); @@ -2069,7 +2071,7 @@ bool ai_deviceremoved(struct si_pub *sih) u32 w; struct si_info *sii; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w); if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM) @@ -2089,7 +2091,7 @@ bool ai_is_sprom_available(struct si_pub *sih) if ((sih->cccaps & CC_CAP_SROM) == 0) return false; - sii = SI_INFO(sih); + sii = (struct si_info *)sih; origidx = sii->curidx; cc = ai_setcoreidx(sih, SI_CC_IDX); sromctrl = R_REG(&cc->sromcontrol); diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index b1f2c38814f..fcf38b8eff2 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -243,9 +243,6 @@ #define BCM47162_CHIP_ID 47162 /* 47162 chipcommon chipid */ #define BCM4748_CHIP_ID 0x4748 /* 4716 chipcommon chipid (OTP, RBBU) */ - -#define SI_INFO(sih) ((struct si_info *)sih) - #define GOODCOREADDR(x, b) \ (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ IS_ALIGNED((x), SI_CORE_SIZE)) diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index b34fe7d3100..6bffca002ab 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -784,7 +784,7 @@ void pcicore_down(struct pcicore_info *pi, int state) /* precondition: current core is sii->buscoretype */ static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16) { - struct si_info *sii = SI_INFO(pi->sih); + struct si_info *sii = (struct si_info *)(pi->sih); u16 val16; uint pciidx; @@ -814,7 +814,7 @@ void pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs *pciregs) OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); - if (SI_INFO(pi->sih)->pub.buscorerev >= 11) { + if (((struct si_info *)(pi->sih))->pub.buscorerev >= 11) { OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); w = R_REG(&pciregs->clkrun); W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL); From 47eef483666387260f8109832dec5c3c9e7218ec Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:16 +0200 Subject: [PATCH 0864/1519] staging: brcm80211: macro cleanup in softmac aiutils.h Moved, deleted or substituted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 160 ++++++++------ drivers/staging/brcm80211/brcmsmac/aiutils.h | 207 ++++--------------- drivers/staging/brcm80211/brcmsmac/main.c | 45 ++-- drivers/staging/brcm80211/brcmsmac/pmu.c | 4 +- 4 files changed, 151 insertions(+), 265 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 48489ceeaac..9510d838009 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -285,6 +285,80 @@ /* resetctrl */ #define AIRC_RESET 1 +#define NOREV -1 /* Invalid rev */ + +/* GPIO Based LED powersave defines */ +#define DEFAULT_GPIO_ONTIME 10 /* Default: 10% on */ +#define DEFAULT_GPIO_OFFTIME 90 /* Default: 10% on */ + +/* When Srom support present, fields in sromcontrol */ +#define SRC_START 0x80000000 +#define SRC_BUSY 0x80000000 +#define SRC_OPCODE 0x60000000 +#define SRC_OP_READ 0x00000000 +#define SRC_OP_WRITE 0x20000000 +#define SRC_OP_WRDIS 0x40000000 +#define SRC_OP_WREN 0x60000000 +#define SRC_OTPSEL 0x00000010 +#define SRC_LOCK 0x00000008 +#define SRC_SIZE_MASK 0x00000006 +#define SRC_SIZE_1K 0x00000000 +#define SRC_SIZE_4K 0x00000002 +#define SRC_SIZE_16K 0x00000004 +#define SRC_SIZE_SHIFT 1 +#define SRC_PRESENT 0x00000001 + +/* External PA enable mask */ +#define GPIO_CTRL_EPA_EN_MASK 0x40 + +#define DEFAULT_GPIOTIMERVAL \ + ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME) + +#define BADIDX (SI_MAXCORES + 1) + +/* Newer chips can access PCI/PCIE and CC core without requiring to change + * PCI BAR0 WIN + */ +#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) || \ + (((si)->pub.buscoretype == PCI_CORE_ID) && \ + (si)->pub.buscorerev >= 13)) + +#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET)) + +#define IS_SIM(chippkg) \ + ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) + +/* + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts + * before after core switching to avoid invalid register accesss inside ISR. + */ +#define INTR_OFF(si, intr_val) \ + if ((si)->intrsoff_fn && \ + (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg) + +#define INTR_RESTORE(si, intr_val) \ + if ((si)->intrsrestore_fn && \ + (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val) + +#define PCI(si) ((si)->pub.buscoretype == PCI_CORE_ID) +#define PCIE(si) ((si)->pub.buscoretype == PCIE_CORE_ID) + +#define PCI_FORCEHT(si) (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID)) + +#ifdef BCMDBG +#define SI_MSG(args) printk args +#else +#define SI_MSG(args) +#endif /* BCMDBG */ + +#define GOODCOREADDR(x, b) \ + (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ + IS_ALIGNED((x), SI_CORE_SIZE)) + +#define PCIEREGS(si) (((char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET)) + struct aidmp { u32 oobselina30; /* 0x000 */ u32 oobselina74; /* 0x004 */ @@ -435,11 +509,6 @@ get_erom_ent(struct si_pub *sih, u32 **eromptr, u32 mask, u32 match) nom++; } - SI_VMSG(("%s: Returning ent 0x%08x\n", __func__, ent)); - if (inv + nom) - SI_VMSG((" after %d invalid and %d non-matching entries\n", - inv, nom)); - return ent; } @@ -472,9 +541,6 @@ get_asd(struct si_pub *sih, u32 **eromptr, uint sp, uint ad, uint st, } else *sizel = AD_SZ_BASE << (sz >> AD_SZ_SHIFT); - SI_VMSG((" SP %d, ad %d: st = %d, 0x%08x_0x%08x @ 0x%08x_0x%08x\n", - sp, ad, st, *sizeh, *sizel, *addrh, *addrl)); - return asd; } @@ -500,8 +566,6 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) eromptr = regs; eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); - SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, " - "eromlim = 0x%p\n", regs, erombase, eromptr, eromlim)); while (eromptr < eromlim) { u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp; u32 mpd, asd, addrl, addrh, sizel, sizeh; @@ -514,8 +578,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) /* Grok a component */ cia = get_erom_ent(sih, &eromptr, ER_TAG, ER_CI); if (cia == (ER_END | ER_VALID)) { - SI_VMSG(("Found END of erom after %d cores\n", - sii->numcores)); + /* Found END of erom */ ai_hwfixup(sii); return; } @@ -523,7 +586,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) cib = get_erom_ent(sih, &eromptr, 0, 0); if ((cib & ER_TAG) != ER_CI) { - SI_ERROR(("CIA not followed by CIB\n")); + /* CIA not followed by CIB */ goto error; } @@ -535,10 +598,6 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT; nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT; - SI_VMSG(("Found component 0x%04x/0x%04x rev %d at erom addr " - "0x%p, with nmw = %d, nsw = %d, nmp = %d & nsp = %d\n", - mfg, cid, crev, base, nmw, nsw, nmp, nsp)); - if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0)) continue; if ((nmw + nsw == 0)) { @@ -561,13 +620,9 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) for (i = 0; i < nmp; i++) { mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID); if ((mpd & ER_TAG) != ER_MP) { - SI_ERROR(("Not enough MP entries for " - "component 0x%x\n", cid)); + /* Not enough MP entries for component */ goto error; } - SI_VMSG((" Master port %d, mp: %d id: %d\n", i, - (mpd & MPD_MP_MASK) >> MPD_MP_SHIFT, - (mpd & MPD_MUI_MASK) >> MPD_MUI_SHIFT)); } /* First Slave Address Descriptor should be port 0: @@ -585,8 +640,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) br = true; else if ((addrh != 0) || (sizeh != 0) || (sizel != SI_CORE_SIZE)) { - SI_ERROR(("First Slave ASD for core 0x%04x " - "malformed (0x%08x)\n", cid, asd)); + /* First Slave ASD for core malformed */ goto error; } } @@ -614,8 +668,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) &addrl, &addrh, &sizel, &sizeh); } while (asd != 0); if (j == 0) { - SI_ERROR((" SP %d has no address descriptors\n", - i)); + /* SP has no address descriptors */ goto error; } } @@ -626,11 +679,11 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) get_asd(sih, &eromptr, i, 0, AD_ST_MWRAP, &addrl, &addrh, &sizel, &sizeh); if (asd == 0) { - SI_ERROR(("Missing descriptor for MW %d\n", i)); + /* Missing descriptor for MW */ goto error; } if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - SI_ERROR(("Master wrapper %d is not 4KB\n", i)); + /* Master wrapper %d is not 4KB */ goto error; } if (i == 0) @@ -644,11 +697,11 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) get_asd(sih, &eromptr, fwp + i, 0, AD_ST_SWRAP, &addrl, &addrh, &sizel, &sizeh); if (asd == 0) { - SI_ERROR(("Missing descriptor for SW %d\n", i)); + /* Missing descriptor for SW */ goto error; } if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - SI_ERROR(("Slave wrapper %d is not 4KB\n", i)); + /* Slave wrapper is not 4KB */ goto error; } if ((nmw == 0) && (i == 0)) @@ -663,9 +716,8 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) sii->numcores++; } - SI_ERROR(("Reached end of erom without finding END")); - error: + /* Reached end of erom without finding END */ sii->numcores = 0; return; } @@ -715,8 +767,7 @@ u32 ai_addrspace(struct si_pub *sih, uint asidx) else if (asidx == 1) return sii->coresba2[cidx]; else { - SI_ERROR(("%s: Need to parse the erom again to find addr " - "space %d\n", __func__, asidx)); + /* Need to parse the erom again to find addr space */ return 0; } } @@ -735,8 +786,7 @@ u32 ai_addrspacesize(struct si_pub *sih, uint asidx) else if (asidx == 1) return sii->coresba2_size[cidx]; else { - SI_ERROR(("%s: Need to parse the erom again to find addr " - "space %d\n", __func__, asidx)); + /* Need to parse the erom again to find addr */ return 0; } } @@ -907,10 +957,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) cid = ai_coreid(&sii->pub); crev = ai_corerev(&sii->pub); - /* Display cores found */ - SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x regs 0x%p\n", - i, cid, crev, sii->coresba[i], sii->regs[i])); - if (cid == PCI_CORE_ID) { pciidx = i; pcirev = crev; @@ -943,9 +989,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) sii->pub.buscoreidx = pcieidx; } - SI_VMSG(("Buscore id/type/rev %d/0x%x/%d\n", sii->pub.buscoreidx, - sii->pub.buscoretype, sii->pub.buscorerev)); - /* fixup necessary chip/core configurations */ if (SI_FAST(sii)) { if (!sii->pch) { @@ -956,7 +999,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) } } if (ai_pci_fixcfg(&sii->pub)) { - SI_ERROR(("si_doattach: si_pci_fixcfg failed\n")); + /* si_doattach: si_pci_fixcfg failed */ return false; } @@ -980,20 +1023,11 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) "boardvendor"); if (sii->pub.boardvendor == 0) sii->pub.boardvendor = w & 0xffff; - else - SI_ERROR(("Overriding boardvendor: 0x%x instead of " - "0x%x\n", sii->pub.boardvendor, w & 0xffff)); sii->pub.boardtype = (u16)ai_getdevpathintvar(&sii->pub, "boardtype"); if (sii->pub.boardtype == 0) sii->pub.boardtype = (w >> 16) & 0xffff; - else - SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n" - , sii->pub.boardtype, (w >> 16) & 0xffff)); - - if (sii->pub.boardtype == 0) - SI_ERROR(("si_doattach: unknown board type\n")); sii->pub.boardflags = getintvar(pvars, "boardflags"); } @@ -1029,7 +1063,6 @@ static struct si_info *ai_doattach(struct si_info *sii, /* bus/core/clk setup for register access */ if (!ai_buscore_prep(sii)) { - SI_ERROR(("si_doattach: si_core_clk_prep failed\n")); return NULL; } @@ -1055,24 +1088,21 @@ static struct si_info *ai_doattach(struct si_info *sii, /* pass chipc address instead of original core base */ ai_scan(&sii->pub, cc); } else { - SI_ERROR(("Found chip of unknown type (0x%08x)\n", w)); + /* Found chip of unknown type */ return NULL; } /* no cores found, bail out */ if (sii->numcores == 0) { - SI_ERROR(("si_doattach: could not find any cores\n")); return NULL; } /* bus/core/clk setup */ origidx = SI_CC_IDX; if (!ai_buscore_setup(sii, savewin, &origidx)) { - SI_ERROR(("si_doattach: si_buscore_setup failed\n")); goto exit; } /* Init nvram from sprom/otp if they exist */ if (srom_var_init(&sii->pub, cc, vars, varsz)) { - SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } pvars = vars ? *vars : NULL; @@ -1085,7 +1115,7 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_setcoreidx(sih, origidx); /* PMU specific initializations */ - if (PMUCTL_ENAB(sih)) { + if (sih->cccaps & CC_CAP_PMU) { u32 xtalfreq; si_pmu_init(sih); si_pmu_chip_init(sih); @@ -1278,7 +1308,7 @@ void *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) uint idx; idx = ai_findcoreidx(sih, coreid, coreunit); - if (!GOODIDX(idx)) + if (idx >= SI_MAXCORES) return NULL; return ai_setcoreidx(sih, idx); @@ -1562,7 +1592,7 @@ void ai_clkctl_init(struct si_pub *sih) struct chipcregs *cc; bool fast; - if (!CCCTL_ENAB(sih)) + if (!(sih->cccaps & CC_CAP_PWR_CTL)) return; sii = (struct si_info *)sih; @@ -1604,14 +1634,14 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) bool fast; sii = (struct si_info *)sih; - if (PMUCTL_ENAB(sih)) { + if (sih->cccaps & CC_CAP_PMU) { INTR_OFF(sii, intr_val); fpdelay = si_pmu_fast_pwrup_delay(sih); INTR_RESTORE(sii, intr_val); return fpdelay; } - if (!CCCTL_ENAB(sih)) + if (!(sih->cccaps & CC_CAP_PWR_CTL)) return 0; fast = SI_FAST(sii); @@ -1726,7 +1756,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) goto done; } - if (!CCCTL_ENAB(&sii->pub) && (sii->pub.ccrev < 20)) + if (!(sii->pub.cccaps & CC_CAP_PWR_CTL) && (sii->pub.ccrev < 20)) goto done; switch (mode) { @@ -1746,7 +1776,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) } /* wait for the PLL */ - if (PMUCTL_ENAB(&sii->pub)) { + if (sii->pub.cccaps & CC_CAP_PMU) { u32 htavail = CCS_HTAVAIL; SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) == 0), PMU_MAX_TRANSITION_DLY); diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index fcf38b8eff2..0d4fa85f9be 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -23,18 +23,6 @@ * SOC Interconnect Address Map. * All regions may not exist on all chips. */ -/* Physical SDRAM */ -#define SI_SDRAM_BASE 0x00000000 -/* Host Mode sb2pcitranslation0 (64 MB) */ -#define SI_PCI_MEM 0x08000000 -#define SI_PCI_MEM_SZ (64 * 1024 * 1024) -/* Host Mode sb2pcitranslation1 (64 MB) */ -#define SI_PCI_CFG 0x0c000000 -/* Region 2 for sdram (512 MB) */ -#define SI_SDRAM_R2 0x80000000 - -/* Wrapper space base */ -#define SI_WRAP_BASE 0x18100000 /* each core gets 4Kbytes for registers */ #define SI_CORE_SIZE 0x1000 /* @@ -44,39 +32,9 @@ */ #define SI_MAXCORES 16 -/* On-chip RAM on chips that also have DDR */ -#define SI_FASTRAM 0x19000000 -#define SI_FASTRAM_SWAPPED 0x19800000 - -/* Flash Region 2 (region 1 shadowed here) */ -#define SI_FLASH2 0x1c000000 -/* Size of Flash Region 2 */ -#define SI_FLASH2_SZ 0x02000000 -/* ARM Cortex-M3 ROM */ -#define SI_ARMCM3_ROM 0x1e000000 -/* MIPS Flash Region 1 */ -#define SI_FLASH1 0x1fc00000 -/* MIPS Size of Flash Region 1 */ -#define SI_FLASH1_SZ 0x00400000 -/* ARM7TDMI-S ROM */ -#define SI_ARM7S_ROM 0x20000000 -/* ARM Cortex-M3 SRAM Region 2 */ -#define SI_ARMCM3_SRAM2 0x60000000 -/* ARM7TDMI-S SRAM Region 2 */ -#define SI_ARM7S_SRAM2 0x80000000 -/* ARM Flash Region 1 */ -#define SI_ARM_FLASH1 0xffff0000 -/* ARM Size of Flash Region 1 */ -#define SI_ARM_FLASH1_SZ 0x00010000 - -/* Client Mode sb2pcitranslation2 (1 GB) */ -#define SI_PCI_DMA 0x40000000 -/* Client Mode sb2pcitranslation2 (1 GB) */ -#define SI_PCI_DMA2 0x80000000 /* Client Mode sb2pcitranslation2 size in bytes */ #define SI_PCI_DMA_SZ 0x40000000 -/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */ -#define SI_PCIE_DMA_L32 0x00000000 + /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ #define SI_PCIE_DMA_H32 0x80000000 @@ -195,18 +153,6 @@ /* Minumum amount of flash we support */ #define FLASH_MIN 0x00020000 /* Minimum flash size */ -/* A boot/binary may have an embedded block that describes its size */ -#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */ -#define BISZ_MAGIC 0x4249535a /* Marked with value: 'BISZ' */ -#define BISZ_MAGIC_IDX 0 /* Word 0: magic */ -#define BISZ_TXTST_IDX 1 /* 1: text start */ -#define BISZ_TXTEND_IDX 2 /* 2: text end */ -#define BISZ_DATAST_IDX 3 /* 3: data start */ -#define BISZ_DATAEND_IDX 4 /* 4: data end */ -#define BISZ_BSSST_IDX 5 /* 5: bss start */ -#define BISZ_BSSEND_IDX 6 /* 6: bss end */ -#define BISZ_SIZE 7 /* descriptor size in 32-bit integers */ - #define CC_SROM_OTP 0x800 /* SROM/OTP address space */ /* gpiotimerval */ @@ -216,23 +162,6 @@ #define CLKD_OTP 0x000f0000 #define CLKD_OTP_SHIFT 16 -/* When Srom support present, fields in sromcontrol */ -#define SRC_START 0x80000000 -#define SRC_BUSY 0x80000000 -#define SRC_OPCODE 0x60000000 -#define SRC_OP_READ 0x00000000 -#define SRC_OP_WRITE 0x20000000 -#define SRC_OP_WRDIS 0x40000000 -#define SRC_OP_WREN 0x60000000 -#define SRC_OTPSEL 0x00000010 -#define SRC_LOCK 0x00000008 -#define SRC_SIZE_MASK 0x00000006 -#define SRC_SIZE_1K 0x00000000 -#define SRC_SIZE_4K 0x00000002 -#define SRC_SIZE_16K 0x00000004 -#define SRC_SIZE_SHIFT 1 -#define SRC_PRESENT 0x00000001 - /* Package IDs */ #define BCM4717_PKG_ID 9 /* 4717 package id */ #define BCM4718_PKG_ID 10 /* 4718 package id */ @@ -243,38 +172,6 @@ #define BCM47162_CHIP_ID 47162 /* 47162 chipcommon chipid */ #define BCM4748_CHIP_ID 0x4748 /* 4716 chipcommon chipid (OTP, RBBU) */ -#define GOODCOREADDR(x, b) \ - (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ - IS_ALIGNED((x), SI_CORE_SIZE)) -#define GOODREGS(regs) \ - ((regs) != NULL && IS_ALIGNED((unsigned long)(regs), SI_CORE_SIZE)) -#define BADCOREADDR 0 -#define GOODIDX(idx) (((uint)idx) < SI_MAXCORES) -#define NOREV -1 /* Invalid rev */ - -/* Newer chips can access PCI/PCIE and CC core without requiring to change - * PCI BAR0 WIN - */ -#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) || \ - (((si)->pub.buscoretype == PCI_CORE_ID) && \ - (si)->pub.buscorerev >= 13)) - -#define PCIEREGS(si) (((char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET)) -#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET)) - -/* - * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts - * before after core switching to avoid invalid register accesss inside ISR. - */ -#define INTR_OFF(si, intr_val) \ - if ((si)->intrsoff_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - intr_val = (*(si)->intrsoff_fn)((si)->intr_arg) -#define INTR_RESTORE(si, intr_val) \ - if ((si)->intrsrestore_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val) - /* dynamic clock control defines */ #define LPOMINFREQ 25000 /* low power oscillator min */ #define LPOMAXFREQ 43000 /* low power oscillator max */ @@ -286,55 +183,6 @@ #define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */ #define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */ -#define PCI(si) ((si)->pub.buscoretype == PCI_CORE_ID) -#define PCIE(si) ((si)->pub.buscoretype == PCIE_CORE_ID) -#define PCI_FORCEHT(si) \ - (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID)) - -/* GPIO Based LED powersave defines */ -#define DEFAULT_GPIO_ONTIME 10 /* Default: 10% on */ -#define DEFAULT_GPIO_OFFTIME 90 /* Default: 10% on */ - -#define DEFAULT_GPIOTIMERVAL \ - ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME) - -/* - * Data structure to export all chip specific common variables - * public (read-only) portion of aiutils handle returned by si_attach() - */ -struct si_pub { - uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ - uint buscorerev; /* buscore rev */ - uint buscoreidx; /* buscore index */ - int ccrev; /* chip common core rev */ - u32 cccaps; /* chip common capabilities */ - u32 cccaps_ext; /* chip common capabilities extension */ - int pmurev; /* pmu core rev */ - u32 pmucaps; /* pmu capabilities */ - uint boardtype; /* board type */ - uint boardvendor; /* board vendor */ - uint boardflags; /* board flags */ - uint boardflags2; /* board flags2 */ - uint chip; /* chip number */ - uint chiprev; /* chip revision */ - uint chippkg; /* chip package option */ - u32 chipst; /* chip status */ - bool issim; /* chip is in simulation or emulation */ - uint socirev; /* SOC interconnect rev */ - bool pci_pr32414; - -}; - -/* - * Many of the routines below take an 'sih' handle as their first arg. - * Allocate this by calling si_attach(). Free it by calling si_detach(). - * At any one time, the sih is logically focused on one particular si core - * (the "current core"). - * Use si_setcore() or si_setcoreidx() to change the association to another core - */ - -#define BADIDX (SI_MAXCORES + 1) - /* clkctl xtal what flags */ #define XTAL 0x1 /* primary crystal oscillator (2050) */ #define PLL 0x2 /* main chip pll */ @@ -367,26 +215,32 @@ struct si_pub { #define SI_PCIDOWN 2 #define SI_PCIUP 3 -/* PMU clock/power control */ -#define PMUCTL_ENAB(sih) ((sih)->cccaps & CC_CAP_PMU) +/* + * Data structure to export all chip specific common variables + * public (read-only) portion of aiutils handle returned by si_attach() + */ +struct si_pub { + uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ + uint buscorerev; /* buscore rev */ + uint buscoreidx; /* buscore index */ + int ccrev; /* chip common core rev */ + u32 cccaps; /* chip common capabilities */ + u32 cccaps_ext; /* chip common capabilities extension */ + int pmurev; /* pmu core rev */ + u32 pmucaps; /* pmu capabilities */ + uint boardtype; /* board type */ + uint boardvendor; /* board vendor */ + uint boardflags; /* board flags */ + uint boardflags2; /* board flags2 */ + uint chip; /* chip number */ + uint chiprev; /* chip revision */ + uint chippkg; /* chip package option */ + u32 chipst; /* chip status */ + bool issim; /* chip is in simulation or emulation */ + uint socirev; /* SOC interconnect rev */ + bool pci_pr32414; -/* chipcommon clock/power control (exclusive with PMU's) */ -#define CCCTL_ENAB(sih) ((sih)->cccaps & CC_CAP_PWR_CTL) -#define CCPLL_ENAB(sih) ((sih)->cccaps & CC_CAP_PLL_MASK) - -/* External PA enable mask */ -#define GPIO_CTRL_EPA_EN_MASK 0x40 - -#define SI_ERROR(args) - -#ifdef BCMDBG -#define SI_MSG(args) printk args -#else -#define SI_MSG(args) -#endif /* BCMDBG */ - -/* Define SI_VMSG to printf for verbose debugging, but don't check it in */ -#define SI_VMSG(args) +}; struct pci_dev; @@ -436,6 +290,15 @@ struct si_info { u32 oob_router; /* oob router registers for axi */ }; +/* + * Many of the routines below take an 'sih' handle as their first arg. + * Allocate this by calling si_attach(). Free it by calling si_detach(). + * At any one time, the sih is logically focused on one particular si core + * (the "current core"). + * Use si_setcore() or si_setcoreidx() to change the association to another core + */ + + /* AMBA Interconnect exported externs */ extern uint ai_flag(struct si_pub *sih); extern void ai_setint(struct si_pub *sih, int siflag); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 6ded4fbdcc1..03985ca17f0 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -168,6 +168,8 @@ #define AC_VI 2 #define AC_VO 3 +#define BCN_TMPL_LEN 512 /* length of the BCN template area */ + /* * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s * OS timer(soft watchdog) it is not a wall clock and won't increment when @@ -927,7 +929,7 @@ static int brcms_b_bandtype(struct brcms_hardware *wlc_hw) /* control chip clock to save power, enable dynamic clock or force fast clock */ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) { - if (PMUCTL_ENAB(wlc_hw->sih)) { + if (wlc_hw->sih->cccaps & CC_CAP_PMU) { /* new chips with PMU, CCS_FORCEHT will distribute the HT clock * on backplane, but mac core will still run on ALP(not HT) when * it enters powersave mode, which means the FCA bit may not be @@ -1642,7 +1644,7 @@ static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) if (macaddr != NULL) return macaddr; - if (NBANDS_HW(wlc_hw) > 1) + if (wlc_hw->_nbands > 1) varname = "et1macaddr"; else varname = "il0macaddr"; @@ -1806,7 +1808,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) brcms_c_mctrl_reset(wlc_hw); - if (PMUCTL_ENAB(wlc_hw->sih)) + if (wlc_hw->sih->cccaps & CC_CAP_PMU) brcms_b_clkctl_clk(wlc_hw, CLK_FAST); brcms_b_phy_reset(wlc_hw); @@ -3204,7 +3206,7 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, * We might have been bandlocked during down and the chip * power-cycled (hibernate). Figure out the right band to park on */ - if (wlc->bandlocked || NBANDS(wlc) == 1) { + if (wlc->bandlocked || wlc->pub->_nbands == 1) { /* updated in brcms_c_bandlock() */ parkband = wlc->band->bandunit; band_order[0] = band_order[1] = parkband; @@ -3218,7 +3220,7 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, } /* make each band operational, software state init */ - for (i = 0; i < NBANDS(wlc); i++) { + for (i = 0; i < wlc->pub->_nbands; i++) { uint j = band_order[i]; wlc->band = wlc->bandstate[j]; @@ -3659,7 +3661,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, wlc_hw->chanspec = chanspec; /* Switch bands if necessary */ - if (NBANDS_HW(wlc_hw) > 1) { + if (wlc_hw->_nbands > 1) { bandunit = CHSPEC_BANDUNIT(chanspec); if (wlc_hw->band->bandunit != bandunit) { /* brcms_b_setband disables other bandunit, @@ -3729,7 +3731,7 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) } /* Switch bands if necessary */ - if (NBANDS(wlc) > 1) { + if (wlc->pub->_nbands > 1) { bandunit = CHSPEC_BANDUNIT(chanspec); if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { switchband = true; @@ -4594,16 +4596,12 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, } /* initialize software state for each core and band */ - for (j = 0; j < NBANDS_HW(wlc_hw); j++) { + for (j = 0; j < wlc_hw->_nbands; j++) { /* * band0 is always 2.4Ghz * band1, if present, is 5Ghz */ - /* So if this is a single band 11a card, use band 1 */ - if (IS_SINGLEBAND_5G(wlc_hw->deviceid)) - j = BAND_5G_INDEX; - brcms_c_setxband(wlc_hw, j); wlc_hw->band->bandunit = j; @@ -4836,7 +4834,8 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) /* find the band of our default channel */ band = wlc->band; - if (NBANDS(wlc) > 1 && band->bandunit != CHSPEC_BANDUNIT(chanspec)) + if (wlc->pub->_nbands > 1 && + band->bandunit != CHSPEC_BANDUNIT(chanspec)) band = wlc->bandstate[OTHERBANDUNIT(wlc)]; /* init bss rates to the band specific default rate set */ @@ -4905,9 +4904,7 @@ static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) uint i; struct brcms_band *band; - for (i = 0; i < NBANDS(wlc); i++) { - if (IS_SINGLEBAND_5G(wlc->deviceid)) - i = BAND_5G_INDEX; + for (i = 0; i < wlc->pub->_nbands; i++) { band = wlc->bandstate[i]; if (band->bandtype == BRCM_BAND_5G) { if ((bwcap == BRCMS_N_BW_40ALL) @@ -5016,11 +5013,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, memcpy(&pub->cur_etheraddr, &wlc->perm_etheraddr, ETH_ALEN); - for (j = 0; j < NBANDS(wlc); j++) { - /* Use band 1 for single band 11a */ - if (IS_SINGLEBAND_5G(wlc->deviceid)) - j = BAND_5G_INDEX; - + for (j = 0; j < wlc->pub->_nbands; j++) { wlc->band = wlc->bandstate[j]; if (!brcms_c_attach_stf_ant_init(wlc)) { @@ -5233,7 +5226,7 @@ static int brcms_b_detach(struct brcms_c_info *wlc) brcms_b_detach_dmapio(wlc_hw); band = wlc_hw->band; - for (i = 0; i < NBANDS_HW(wlc_hw); i++) { + for (i = 0; i < wlc_hw->_nbands; i++) { if (band->pi) { /* Detach this band's phy */ wlc_phy_detach(band->pi); @@ -5780,7 +5773,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) /* verify that we are dealing with 2G band and grab the band pointer */ if (wlc->band->bandtype == BRCM_BAND_2G) band = wlc->band; - else if ((NBANDS(wlc) > 1) && + else if ((wlc->pub->_nbands > 1) && (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) band = wlc->bandstate[OTHERBANDUNIT(wlc)]; else @@ -5942,7 +5935,7 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) wlc->default_bss->flags &= ~BRCMS_BSS_HT; /* delete the mcs rates from the default and hw ratesets */ brcms_c_rateset_mcs_clear(&wlc->default_bss->rateset); - for (i = 0; i < NBANDS(wlc); i++) { + for (i = 0; i < wlc->pub->_nbands; i++) { memset(wlc->bandstate[i]->hw_rateset.mcs, 0, MCSSET_LEN); if (IS_MCS(wlc->band->rspec_override)) { @@ -5971,7 +5964,7 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) /* add the mcs rates to the default and hw ratesets */ brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, wlc->stf->txstreams); - for (i = 0; i < NBANDS(wlc); i++) + for (i = 0; i < wlc->pub->_nbands; i++) memcpy(wlc->bandstate[i]->hw_rateset.mcs, wlc->default_bss->rateset.mcs, MCSSET_LEN); break; @@ -8886,7 +8879,7 @@ bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) hw_rateset = &wlc->band->hw_rateset; - else if (NBANDS(wlc) > 1) + else if (wlc->pub->_nbands > 1) hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; else /* other band specified and we are a single band device */ diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index cdeaa4e534c..61ba3735a4f 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -206,7 +206,7 @@ u32 si_pmu_ilp_clock(struct si_pub *sih) { static u32 ilpcycles_per_sec; - if (!PMUCTL_ENAB(sih)) + if (!(sih->cccaps & CC_CAP_PMU)) return ILP_CLOCK; if (ilpcycles_per_sec == 0) { @@ -297,7 +297,7 @@ u32 si_pmu_alp_clock(struct si_pub *sih) u32 clock = ALP_CLOCK; /* bail out with default */ - if (!PMUCTL_ENAB(sih)) + if (!(sih->cccaps & CC_CAP_PMU)) return clock; switch (sih->chip) { From fc8e5292b353a40da6b9850f41f6c69d2207807f Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:17 +0200 Subject: [PATCH 0865/1519] staging: brcm80211: macro cleanup in softmac ampdu.c Moved, deleted or substituted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 29 +++++++--------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 318235dfdd4..341768dbacd 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -60,8 +60,6 @@ * accumulate between resets. */ -#define SHORTNAME "AMPDU status" - #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ @@ -144,14 +142,6 @@ struct cb_del_ampdu_pars { u16 tid; }; -#define AMPDU_CLEANUPFLAG_RX (0x1) -#define AMPDU_CLEANUPFLAG_TX (0x2) - -#define SCB_AMPDU_CUBBY(ampdu, scb) (&(scb->scb_ampdu)) -#define SCB_AMPDU_INI(scb_ampdu, tid) (&(scb_ampdu->ini[tid])) - -#define brcms_c_ampdu_txflowcontrol(a, b, c) do {} while (0) - static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) { u32 rate, mcs; @@ -288,7 +278,7 @@ void brcms_c_ampdu_detach(struct ampdu_info *ampdu) static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, struct scb *scb) { - struct scb_ampdu *scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + struct scb_ampdu *scb_ampdu = &scb->scb_ampdu; int i; scb_ampdu->max_pdu = (u8) ampdu->wlc->pub->tunables->ampdunummpdu; @@ -486,7 +476,7 @@ brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, struct scb_ampdu_tid_ini *ini; struct ampdu_info *ampdu = wlc->ampdu; struct scb *scb = wlc->pub->global_scb; - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + scb_ampdu = &scb->scb_ampdu; if (!ampdu->ini_enable[tid]) { wiphy_err(ampdu->wlc->wiphy, "%s: Rejecting tid %d\n", @@ -494,7 +484,7 @@ brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, return; } - ini = SCB_AMPDU_INI(scb_ampdu, tid); + ini = &scb_ampdu->ini[tid]; ini->tid = tid; ini->scb = scb_ampdu->scb; ini->ba_wsize = ba_wsize; @@ -546,7 +536,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, f = ampdu->fifo_tb + prio2fifo[tid]; scb = wlc->pub->global_scb; - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + scb_ampdu = &scb->scb_ampdu; ini = &scb_ampdu->ini[tid]; /* Let pressure continue to build ... */ @@ -925,10 +915,10 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, memset(hole, 0, sizeof(hole)); #endif - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + scb_ampdu = &scb->scb_ampdu; tid = (u8) (p->priority); - ini = SCB_AMPDU_INI(scb_ampdu, tid); + ini = &scb_ampdu->ini[tid]; retry_limit = ampdu->retry_limit_tid[tid]; rr_retry_limit = ampdu->rr_retry_limit_tid[tid]; memset(bitmap, 0, sizeof(bitmap)); @@ -1080,7 +1070,7 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, skb_pull(p, D11_PHY_HDR_LEN); skb_pull(p, D11_TXH_LEN); wiphy_err(wiphy, "%s: BA Timeout, seq %d, in_" - "transit %d\n", SHORTNAME, seq, + "transit %d\n", "AMPDU status", seq, ini->tx_in_transit); ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); @@ -1134,8 +1124,8 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, } if (likely(scb)) { - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); - ini = SCB_AMPDU_INI(scb_ampdu, p->priority); + scb_ampdu = &scb->scb_ampdu; + ini = &scb_ampdu->ini[p->priority]; brcms_c_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); } else { /* loop through all pkts and free */ @@ -1155,7 +1145,6 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, } brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); } - brcms_c_ampdu_txflowcontrol(wlc, scb_ampdu, ini); } void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc) From fa2254493c59391c11aaf64f5567216dc7a4e410 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:18 +0200 Subject: [PATCH 0866/1519] staging: brcm80211: cleaned up softmac channel related macro's Moved, deleted or substituted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 141 +++++++++++++----- drivers/staging/brcm80211/brcmsmac/channel.h | 82 +--------- .../staging/brcm80211/brcmsmac/mac80211_if.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.h | 2 +- drivers/staging/brcm80211/brcmsmac/stf.c | 2 +- 5 files changed, 107 insertions(+), 122 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 6c5272e1bd9..e6afdc95ace 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -24,11 +24,6 @@ #include "stf.h" #include "channel.h" -#define VALID_CHANNEL20_DB(wlc, val) brcms_c_valid_channel20_db((wlc)->cmi, val) -#define VALID_CHANNEL20_IN_BAND(wlc, bandunit, val) \ - brcms_c_valid_channel20_in_band((wlc)->cmi, bandunit, val) -#define VALID_CHANNEL20(wlc, val) brcms_c_valid_channel20((wlc)->cmi, val) - /* QDB() macro takes a dB value and converts to a quarter dB value */ #define QDB(n) ((n) * BRCMS_TXPWR_DB_FACTOR) @@ -76,6 +71,55 @@ #define LOCALE_RESTRICTED_LOW_HI 7 #define LOCALE_RESTRICTED_12_13_14 8 +#define LOCALE_2G_IDX_i 0 +#define LOCALE_5G_IDX_11 0 +#define LOCALE_MIMO_IDX_bn 0 +#define LOCALE_MIMO_IDX_11n 0 + +/* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */ +#define BRCMS_MAXPWR_TBL_SIZE 6 +/* max of BAND_5G_PWR_LVLS and 14 for 2.4 GHz */ +#define BRCMS_MAXPWR_MIMO_TBL_SIZE 14 + +/* power level in group of 2.4GHz band channels: + * maxpwr[0] - CCK channels [1] + * maxpwr[1] - CCK channels [2-10] + * maxpwr[2] - CCK channels [11-14] + * maxpwr[3] - OFDM channels [1] + * maxpwr[4] - OFDM channels [2-10] + * maxpwr[5] - OFDM channels [11-14] + */ + +/* maxpwr mapping to 5GHz band channels: + * maxpwr[0] - channels [34-48] + * maxpwr[1] - channels [52-60] + * maxpwr[2] - channels [62-64] + * maxpwr[3] - channels [100-140] + * maxpwr[4] - channels [149-165] + */ +#define BAND_5G_PWR_LVLS 5 /* 5 power levels for 5G */ + +#define LC(id) LOCALE_MIMO_IDX_ ## id + +#define LC_2G(id) LOCALE_2G_IDX_ ## id + +#define LC_5G(id) LOCALE_5G_IDX_ ## id + +#define LOCALES(band2, band5, mimo2, mimo5) \ + {LC_2G(band2), LC_5G(band5), LC(mimo2), LC(mimo5)} + +/* macro to get 2.4 GHz channel group index for tx power */ +#define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) +#define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) + +/* macro to get 5 GHz channel group index for tx power */ +#define CHANNEL_POWER_IDX_5G(c) (((c) < 52) ? 0 : \ + (((c) < 62) ? 1 : \ + (((c) < 100) ? 2 : \ + (((c) < 149) ? 3 : 4)))) + +#define ISDFS_EU(fl) (((fl) & BRCMS_DFS_EU) == BRCMS_DFS_EU) + struct brcms_cm_band { /* struct locale_info flags */ u8 locale_flags; @@ -88,6 +132,26 @@ struct brcms_cm_band { u8 PAD[8]; }; + /* locale per-channel tx power limits for MIMO frames + * maxpwr arrays are index by channel for 2.4 GHz limits, and + * by sub-band for 5 GHz limits using CHANNEL_POWER_IDX_5G(channel) + */ +struct locale_mimo_info { + /* tx 20 MHz power limits, qdBm units */ + s8 maxpwr20[BRCMS_MAXPWR_MIMO_TBL_SIZE]; + /* tx 40 MHz power limits, qdBm units */ + s8 maxpwr40[BRCMS_MAXPWR_MIMO_TBL_SIZE]; + u8 flags; +}; + +/* Country names and abbreviations with locale defined from ISO 3166 */ +struct country_info { + const u8 locale_2G; /* 2.4G band locale */ + const u8 locale_5G; /* 5G band locale */ + const u8 locale_mimo_2G; /* 2.4G mimo info */ + const u8 locale_mimo_5G; /* 5G mimo info */ +}; + struct brcms_cm_info { struct brcms_pub *pub; struct brcms_c_info *wlc; @@ -104,6 +168,20 @@ struct brcms_cm_info { struct brcms_chanvec quiet_channels; }; +/* locale channel and power info. */ +struct locale_info { + u32 valid_channels; + /* List of radar sensitive channels */ + u8 radar_channels; + /* List of channels used only if APs are detected */ + u8 restricted_channels; + /* Max tx pwr in qdBm for each sub-band */ + s8 maxpwr[BRCMS_MAXPWR_TBL_SIZE]; + /* Country IE advertised max tx pwr in dBm per sub-band */ + s8 pub_maxpwr[BAND_5G_PWR_LVLS]; + u8 flags; +}; + /* Regulatory Matrix Spreadsheet (CLM) MIMO v3.7.9 */ /* @@ -138,9 +216,6 @@ const struct brcms_chanvec chanvec_all_5G = { * Radar channel sets */ -/* No radar */ -#define radar_set_none chanvec_none - /* Channels 52 - 64, 100 - 140 */ static const struct brcms_chanvec radar_set1 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, /* 52 - 60 */ @@ -153,8 +228,6 @@ static const struct brcms_chanvec radar_set1 = { * Restricted channel sets */ -#define restricted_set_none chanvec_none - /* Channels 34, 38, 42, 46 */ static const struct brcms_chanvec restricted_set_japan_legacy = { {0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, @@ -393,12 +466,10 @@ static const struct locale_info locale_11 = { BRCMS_EIRP | BRCMS_DFS_EU }; -#define LOCALE_2G_IDX_i 0 static const struct locale_info *g_locale_2g_table[] = { &locale_i }; -#define LOCALE_5G_IDX_11 0 static const struct locale_info *g_locale_5g_table[] = { &locale_11 }; @@ -416,9 +487,6 @@ static const struct locale_mimo_info locale_bn = { 0 }; -/* locale mimo 2g indexes */ -#define LOCALE_MIMO_IDX_bn 0 - static const struct locale_mimo_info *g_mimo_2g_table[] = { &locale_bn }; @@ -432,20 +500,10 @@ static const struct locale_mimo_info locale_11n = { 0 }; -#define LOCALE_MIMO_IDX_11n 0 static const struct locale_mimo_info *g_mimo_5g_table[] = { &locale_11n }; -#define LC(id) LOCALE_MIMO_IDX_ ## id - -#define LC_2G(id) LOCALE_2G_IDX_ ## id - -#define LC_5G(id) LOCALE_5G_IDX_ ## id - -#define LOCALES(band2, band5, mimo2, mimo5) \ - {LC_2G(band2), LC_5G(band5), LC(mimo2), LC(mimo5)} - static const struct { char abbrev[BRCM_CNTRY_BUF_SZ]; /* country abbreviation */ struct country_info country; @@ -679,7 +737,7 @@ static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) memset(&wlc_cm->quiet_channels, 0, sizeof(struct brcms_chanvec)); band = wlc->band; - for (i = 0; i < NBANDS(wlc); + for (i = 0; i < wlc->pub->_nbands; i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { /* initialize quiet channels for restricted channels */ @@ -715,9 +773,10 @@ static bool brcms_c_valid_channel20_db(struct brcms_cm_info *wlc_cm, uint val) { struct brcms_c_info *wlc = wlc_cm->wlc; - return VALID_CHANNEL20(wlc, val) || + return brcms_c_valid_channel20(wlc->cmi, val) || (!wlc->bandlocked - && VALID_CHANNEL20_IN_BAND(wlc, OTHERBANDUNIT(wlc), val)); + && brcms_c_valid_channel20_in_band(wlc->cmi, + OTHERBANDUNIT(wlc), val)); } /* JP, J1 - J10 are Japan ccodes */ @@ -819,7 +878,7 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) /* search for the existence of any valid channel */ for (chan = 0; chan < MAXCHANNEL; chan++) { - if (VALID_CHANNEL20_DB(wlc, chan)) + if (brcms_c_valid_channel20_db(wlc->cmi, chan)) break; } if (chan == MAXCHANNEL) @@ -837,7 +896,7 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" " "nbands %d bandlocked %d\n", wlc->pub->unit, - __func__, wlc_cm->country_abbrev, NBANDS(wlc), + __func__, wlc_cm->country_abbrev, wlc->pub->_nbands, wlc->bandlocked); } else if (mboolisset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE)) { @@ -852,7 +911,7 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) * Now that the country abbreviation is set, if the radio supports 2G, * then set channel 14 restrictions based on the new locale. */ - if (NBANDS(wlc) > 1 || BAND_2G(wlc->band->bandtype)) + if (wlc->pub->_nbands > 1 || BAND_2G(wlc->band->bandtype)) wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, brcms_c_japan(wlc) ? true : false); @@ -877,7 +936,7 @@ brcms_c_channels_init(struct brcms_cm_info *wlc_cm, const struct locale_mimo_info *li_mimo; band = wlc->band; - for (i = 0; i < NBANDS(wlc); + for (i = 0; i < wlc->pub->_nbands; i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { li = BAND_5G(band->bandtype) ? @@ -1461,9 +1520,11 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, /* Check a 20Mhz channel */ if (CHSPEC_IS20(chspec)) { if (dualband) - return VALID_CHANNEL20_DB(wlc_cm->wlc, channel); + return brcms_c_valid_channel20_db(wlc_cm->wlc->cmi, + channel); else - return VALID_CHANNEL20(wlc_cm->wlc, channel); + return brcms_c_valid_channel20(wlc_cm->wlc->cmi, + channel); } #ifdef SUPPORT_40MHZ /* @@ -1479,12 +1540,16 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, return false; if (dualband) { - if (!VALID_CHANNEL20_DB(wlc, LOWER_20_SB(channel)) || - !VALID_CHANNEL20_DB(wlc, UPPER_20_SB(channel))) + if (!brcms_c_valid_channel20_db(wlc->cmi, + LOWER_20_SB(channel)) || + !brcms_c_valid_channel20_db(wlc->cmi, + UPPER_20_SB(channel))) return false; } else { - if (!VALID_CHANNEL20(wlc, LOWER_20_SB(channel)) || - !VALID_CHANNEL20(wlc, UPPER_20_SB(channel))) + if (!brcms_c_valid_channel20(wlc->cmi, + LOWER_20_SB(channel)) || + !brcms_c_valid_channel20(wlc->cmi, + UPPER_20_SB(channel))) return false; } diff --git a/drivers/staging/brcm80211/brcmsmac/channel.h b/drivers/staging/brcm80211/brcmsmac/channel.h index 3e85844ec87..808cb4fbfbe 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.h +++ b/drivers/staging/brcm80211/brcmsmac/channel.h @@ -20,60 +20,6 @@ /* conversion for phy txpwr calculations that use .25 dB units */ #define BRCMS_TXPWR_DB_FACTOR 4 - -/* maxpwr mapping to 5GHz band channels: - * maxpwr[0] - channels [34-48] - * maxpwr[1] - channels [52-60] - * maxpwr[2] - channels [62-64] - * maxpwr[3] - channels [100-140] - * maxpwr[4] - channels [149-165] - */ -#define BAND_5G_PWR_LVLS 5 /* 5 power levels for 5G */ - -/* power level in group of 2.4GHz band channels: - * maxpwr[0] - CCK channels [1] - * maxpwr[1] - CCK channels [2-10] - * maxpwr[2] - CCK channels [11-14] - * maxpwr[3] - OFDM channels [1] - * maxpwr[4] - OFDM channels [2-10] - * maxpwr[5] - OFDM channels [11-14] - */ - -/* macro to get 2.4 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) -#define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) - -/* macro to get 5 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_5G(c) (((c) < 52) ? 0 : \ - (((c) < 62) ? 1 : \ - (((c) < 100) ? 2 : \ - (((c) < 149) ? 3 : 4)))) - -/* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */ -#define BRCMS_MAXPWR_TBL_SIZE 6 -/* max of BAND_5G_PWR_LVLS and 14 for 2.4 GHz */ -#define BRCMS_MAXPWR_MIMO_TBL_SIZE 14 - -#define NBANDS(wlc) ((wlc)->pub->_nbands) -#define NBANDS_PUB(pub) ((pub)->_nbands) -#define NBANDS_HW(hw) ((hw)->_nbands) - -#define IS_SINGLEBAND_5G(device) 0 - -/* locale channel and power info. */ -struct locale_info { - u32 valid_channels; - /* List of radar sensitive channels */ - u8 radar_channels; - /* List of channels used only if APs are detected */ - u8 restricted_channels; - /* Max tx pwr in qdBm for each sub-band */ - s8 maxpwr[BRCMS_MAXPWR_TBL_SIZE]; - /* Country IE advertised max tx pwr in dBm per sub-band */ - s8 pub_maxpwr[BAND_5G_PWR_LVLS]; - u8 flags; -}; - /* bits for locale_info flags */ #define BRCMS_PEAK_CONDUCTED 0x00 /* Peak for locals */ #define BRCMS_EIRP 0x01 /* Flag for EIRP */ @@ -83,35 +29,9 @@ struct locale_info { #define BRCMS_NO_MIMO 0x10 /* Flag for No MIMO, 20 or 40 MHz */ #define BRCMS_RADAR_TYPE_EU 0x20 /* Flag for EU */ #define BRCMS_DFS_FCC BRCMS_DFS_TPC /* Flag for DFS FCC */ + #define BRCMS_DFS_EU (BRCMS_DFS_TPC | BRCMS_RADAR_TYPE_EU) /* Flag for DFS EU */ -#define ISDFS_EU(fl) (((fl) & BRCMS_DFS_EU) == BRCMS_DFS_EU) - -/* locale per-channel tx power limits for MIMO frames - * maxpwr arrays are index by channel for 2.4 GHz limits, and - * by sub-band for 5 GHz limits using CHANNEL_POWER_IDX_5G(channel) - */ -struct locale_mimo_info { - /* tx 20 MHz power limits, qdBm units */ - s8 maxpwr20[BRCMS_MAXPWR_MIMO_TBL_SIZE]; - /* tx 40 MHz power limits, qdBm units */ - s8 maxpwr40[BRCMS_MAXPWR_MIMO_TBL_SIZE]; - u8 flags; -}; - -extern const struct brcms_chanvec chanvec_all_2G; -extern const struct brcms_chanvec chanvec_all_5G; - -/* - * Country names and abbreviations with locale defined from ISO 3166 - */ -struct country_info { - const u8 locale_2G; /* 2.4G band locale */ - const u8 locale_5G; /* 5G band locale */ - const u8 locale_mimo_2G; /* 2.4G mimo info */ - const u8 locale_mimo_5G; /* 5G mimo info */ -}; - extern struct brcms_cm_info * brcms_c_channel_mgr_attach(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 6ed80b22af5..227beb6794b 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -1114,7 +1114,7 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) } /* Assume all bands use the same phy. True for 11n devices. */ - if (NBANDS_PUB(wl->pub) > 1) { + if (wl->pub->_nbands > 1) { has_5g++; if (phy_list[0] == 'n' || phy_list[0] == 'c') hw->wiphy->bands[IEEE80211_BAND_5GHZ] = diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 433e6a94c5d..d151a5c4af7 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -1044,7 +1044,7 @@ struct brcms_bss_cfg { ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) #define IS_MBAND_UNLOCKED(wlc) \ - ((NBANDS(wlc) > 1) && !(wlc)->bandlocked) + ((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) #define BRCMS_BAND_PI_RADIO_CHANSPEC wlc_phy_chanspec_get(wlc->band->pi) diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 7a9349c9918..62f3efefdf4 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -290,7 +290,7 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) return -EINVAL; if (txstreams == 1) { - for (i = 0; i < NBANDS(wlc); i++) + for (i = 0; i < wlc->pub->_nbands; i++) if ((RSPEC_STF(wlc->bandstate[i]->rspec_override) != PHY_TXC1_MODE_SISO) || (RSPEC_STF(wlc->bandstate[i]->mrspec_override) != From 482df3281aa14b7ad2d5c06c67bdbd9327a80a92 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:19 +0200 Subject: [PATCH 0867/1519] staging: brcm80211: cleaned up several softmac macro's Moved, deleted or substituted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/d11.h | 5 --- drivers/staging/brcm80211/brcmsmac/dma.c | 2 -- drivers/staging/brcm80211/brcmsmac/dma.h | 9 +++--- .../staging/brcm80211/brcmsmac/mac80211_if.c | 32 ++++++++----------- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index f0c3f5a75a2..14e60a5d130 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -23,8 +23,6 @@ #include "pub.h" #include "dma.h" -#define BCN_TMPL_LEN 512 /* length of the BCN template area */ - /* RX FIFO numbers */ #define RX_FIFO 0 /* data and ctl frames */ #define RX_TXSTATUS_FIFO 3 /* RX fifo for tx status packages */ @@ -1397,9 +1395,6 @@ struct d11rxhdr { u16 RxChan; } __packed; -#define RXHDR_LEN 24 /* sizeof struct d11rxhdr */ -#define FRAMELEN(h) ((h)->RxFrameSize) - /* * rxhdr: received frame header data * tsf_l: TSF_L reading diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 85680c81c3b..63e5e0e8cfb 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -199,8 +199,6 @@ #define MAXNAMEL 8 /* 8 char names */ -#define DI_INFO(dmah) ((dma_info_t *)dmah) - /* descriptor bumping macros */ /* faster than %, but n must be power of 2 */ #define XXD(x, n) ((x) & ((n) - 1)) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 2ce5963818d..4075dc9c74b 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -20,6 +20,10 @@ #include #include "types.h" /* forward structure declarations */ +/* map/unmap direction */ +#define DMA_TX 1 /* TX direction for DMA */ +#define DMA_RX 2 /* RX direction for DMA */ + /* DMA structure: * support two DMA engines: 32 bits address or 64 bit addressing * basic DMA register set is per channel(transmit or receive) @@ -47,11 +51,6 @@ struct dma64regs { u32 status1; /* active descriptor, xmt error */ }; -/* map/unmap direction */ -#define DMA_TX 1 /* TX direction for DMA */ -#define DMA_RX 2 /* RX direction for DMA */ -#define BUS_SWAP32(v) (v) - /* range param for dma_getnexttxp() and dma_txreclaim */ enum txd_range { DMA_RANGE_ALL = 1, diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 227beb6794b..23001c25247 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -37,9 +37,6 @@ #define LOCK(wl) spin_lock_bh(&(wl)->lock) #define UNLOCK(wl) spin_unlock_bh(&(wl)->lock) -#define HW_TO_WL(hw) (hw->priv) -#define WL_TO_HW(wl) (wl->pub->ieee_hw) - /* locking from inside brcms_isr */ #define ISR_LOCK(wl, flags)\ do {\ @@ -308,9 +305,6 @@ static int brcms_ops_start(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; bool blocked; - /* - struct ieee80211_channel *curchan = hw->conf.channel; - */ ieee80211_wake_queues(hw); LOCK(wl); @@ -344,7 +338,7 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return -EOPNOTSUPP; } - wl = HW_TO_WL(hw); + wl = hw->priv; LOCK(wl); err = brcms_up(wl); UNLOCK(wl); @@ -361,7 +355,7 @@ brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct brcms_info *wl; - wl = HW_TO_WL(hw); + wl = hw->priv; /* put driver in down state */ LOCK(wl); @@ -376,7 +370,7 @@ static int ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, enum nl80211_channel_type type) { - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; int err = 0; switch (type) { @@ -400,7 +394,7 @@ ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) { struct ieee80211_conf *conf = &hw->conf; - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; int err = 0; int new_int; struct wiphy *wiphy = hw->wiphy; @@ -468,7 +462,7 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, u32 changed) { - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; struct wiphy *wiphy = hw->wiphy; int val; @@ -818,7 +812,7 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw) { - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; bool blocked; LOCK(wl); @@ -830,7 +824,7 @@ static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw) static void brcms_ops_flush(struct ieee80211_hw *hw, bool drop) { - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false"); @@ -1028,7 +1022,7 @@ static void brcms_remove(struct pci_dev *pdev) int status; hw = pci_get_drvdata(pdev); - wl = HW_TO_WL(hw); + wl = hw->priv; if (!wl) { pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); return; @@ -1090,7 +1084,7 @@ static irqreturn_t brcms_isr(int irq, void *dev_id) */ static int ieee_hw_rate_init(struct ieee80211_hw *hw) { - struct brcms_info *wl = HW_TO_WL(hw); + struct brcms_info *wl = hw->priv; int has_5g; char phy_list[4]; @@ -1339,7 +1333,7 @@ static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) struct ieee80211_hw *hw; hw = pci_get_drvdata(pdev); - wl = HW_TO_WL(hw); + wl = hw->priv; if (!wl) { wiphy_err(wl->wiphy, "brcms_suspend: pci_get_drvdata failed\n"); @@ -1364,7 +1358,7 @@ static int brcms_resume(struct pci_dev *pdev) u32 val; hw = pci_get_drvdata(pdev); - wl = HW_TO_WL(hw); + wl = hw->priv; if (!wl) { wiphy_err(wl->wiphy, "wl: brcms_resume: pci_get_drvdata failed\n"); @@ -1458,7 +1452,7 @@ void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif, */ void brcms_init(struct brcms_info *wl) { - BCMMSG(WL_TO_HW(wl)->wiphy, "wl%d\n", wl->pub->unit); + BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); brcms_reset(wl); brcms_c_init(wl->wlc); @@ -1469,7 +1463,7 @@ void brcms_init(struct brcms_info *wl) */ uint brcms_reset(struct brcms_info *wl) { - BCMMSG(WL_TO_HW(wl)->wiphy, "wl%d\n", wl->pub->unit); + BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); brcms_c_reset(wl->wlc); /* dpc will not be rescheduled */ From 89591e296e99c90bc5ebf29914b5471dcaff7488 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 1 Sep 2011 11:17:20 +0200 Subject: [PATCH 0868/1519] staging: brcm80211: cleaned up several main.h/main.c related macro's Moved, deleted or substituted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 12 +- drivers/staging/brcm80211/brcmsmac/main.c | 283 +++++++++++++-------- drivers/staging/brcm80211/brcmsmac/main.h | 164 +----------- drivers/staging/brcm80211/brcmsmac/stf.c | 2 + 4 files changed, 195 insertions(+), 266 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 341768dbacd..cbf6c6d0fe6 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -60,6 +60,8 @@ * accumulate between resets. */ +#define AMPDU_DELIMITER_LEN 4 + #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ @@ -677,7 +679,8 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, if (is40) mimo_ctlchbw = - CHSPEC_SB_UPPER(BRCMS_BAND_PI_RADIO_CHANSPEC) + CHSPEC_SB_UPPER(wlc_phy_chanspec_get( + wlc->band->pi)) ? PHY_TXC1_BW_20MHZ_UP : PHY_TXC1_BW_20MHZ; /* rebuild the rspec and rspec_fallback */ @@ -748,7 +751,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, * check if there are enough * descriptors available */ - if (TXAVAIL(wlc, fifo) <= (seg_cnt + 1)) { + if (*wlc->core->txavail[fifo] <= seg_cnt + 1) { wiphy_err(wiphy, "%s: No fifo space " "!!\n", __func__); p = NULL; @@ -1083,7 +1086,7 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, TXC_AMPDU_LAST) break; - p = GETNEXTTXP(wlc, queue); + p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); } brcms_c_send_q(wlc); @@ -1141,7 +1144,8 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == TXC_AMPDU_LAST) break; - p = GETNEXTTXP(wlc, queue); + p = dma_getnexttxp(wlc->hw->di[queue], + DMA_RANGE_TRANSMITTED); } brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 03985ca17f0..6b694b15979 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -170,6 +170,22 @@ #define BCN_TMPL_LEN 512 /* length of the BCN template area */ +/* brcms_bss_info flag bit values */ +#define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ + +/* Flags used in brcms_c_txq_info.stopped */ +/* per prio flow control bits */ +#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF +/* stop txq enqueue for packet drain */ +#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 +/* stop txq enqueue for ampdu flow control */ +#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 + +/* number of 802.11 default (non-paired, group keys) */ +#define WSEC_MAX_DEFAULT_KEYS 4 /* # of default keys */ + +#define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ + /* * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s * OS timer(soft watchdog) it is not a wall clock and won't increment when @@ -177,12 +193,6 @@ * for maintenance tasks such as phy calibration and scb update */ -/* - * To inform the ucode of the last mcast frame posted - * so that it can clear moredata bit - */ -#define BCMCFID(wlc, fid) brcms_b_write_shm((wlc)->hw, M_BCMC_FID, (fid)) - #define BRCMS_WAR16165(wlc) ((!AP_ENAB(wlc->pub)) && (wlc->war16165)) /* Find basic rate for a given rate */ @@ -199,10 +209,6 @@ #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ -#define SCAN_IN_PROGRESS(x) 0 - -#define EPI_VERSION_NUM 0x054b0b00 - /* precedences numbers for wlc queues. These are twice as may levels as * 802.1D priorities. * Odd numbers are used for HI priority traffic at same precedence levels @@ -218,18 +224,9 @@ #define _BRCMS_PREC_VO 12 /* Vo - Voice */ #define _BRCMS_PREC_NC 14 /* NC - Network Control */ -#define MAXMACLIST 64 /* max # source MAC matches */ -#define BCN_TEMPLATE_COUNT 2 - /* The BSS is generating beacons in HW */ #define BRCMS_BSSCFG_HW_BCN 0x20 -#define HWBCN_ENAB(cfg) (((cfg)->flags & BRCMS_BSSCFG_HW_BCN) != 0) - -#define MBSS_BCN_ENAB(cfg) 0 -#define MBSS_PRB_ENAB(cfg) 0 -#define SOFTBCN_ENAB(pub) (0) - #define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ #define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ #define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ @@ -239,6 +236,29 @@ #define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ +/* Per-AC retry limit register definitions; uses defs.h bitfield macros */ +#define EDCF_SHORT_S 0 +#define EDCF_SFB_S 4 +#define EDCF_LONG_S 8 +#define EDCF_LFB_S 12 +#define EDCF_SHORT_M BITFIELD_MASK(4) +#define EDCF_SFB_M BITFIELD_MASK(4) +#define EDCF_LONG_M BITFIELD_MASK(4) +#define EDCF_LFB_M BITFIELD_MASK(4) + +#define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ +#define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ +#define RETRY_LONG_DEF 4 /* Default Long retry count */ +#define RETRY_SHORT_FB 3 /* Short count for fallback rate */ +#define RETRY_LONG_FB 2 /* Long count for fallback rate */ + +#define APHY_CWMIN 15 +#define PHY_CWMAX 1023 + +#define EDCF_AIFSN_MIN 1 + +#define FRAGNUM_MASK 0xF + #define DMAREG(wlc_hw, direction, fifonum) \ ((direction == DMA_TX) ? \ &(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ @@ -259,11 +279,6 @@ /* Starting corerev for the fifo size table */ #define XMTFIFOTBL_STARTREV 20 -/* Check if a particular BSS config is AP or STA */ -#define BSSCFG_AP(cfg) (0) -#define BSSCFG_STA(cfg) (1) -#define BSSCFG_IBSS(cfg) (!(cfg)->BSS) - /* iterate through all valid bsscfg entries */ #define FOREACH_BSS(wlc, idx, cfg) \ for (idx = 0; (int) idx < BRCMS_MAXBSSCFG; idx++) { \ @@ -273,13 +288,79 @@ /* close marker for iterator code block */ #define END_FOREACH_BSS() } -/* Shared memory location index for various AC params */ -#define wme_shmemacindex(ac) wme_ac2fifo[ac] - /* currently the best mechanism for determining SIFS is the band in use */ #define SIFS(band) ((band)->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : \ BPHY_SIFS_TIME); +/* A fifo is full. Clear precedences related to that FIFO */ +#define BRCMS_TX_FIFO_CLEAR(wlc, fifo) \ + ((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo]) + +/* Fifo is NOT full. Enable precedences for that FIFO */ +#define BRCMS_TX_FIFO_ENAB(wlc, fifo) \ + ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo]) + +/* + * if wpa is in use then portopen is true when the + * group key is plumbed otherwise it is always true + */ +#define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED)) + +#define BRCMS_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \ + ((bsscfg)->wsec & WSEC_SWFLAG))) + +#define BRCMS_PORTOPEN(cfg) \ + (((cfg)->WPA_auth != WPA_AUTH_DISABLED && WSEC_ENABLED((cfg)->wsec)) ? \ + (cfg)->wsec_portopen : true) + +#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ + brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) + +/* + * Detect Card removed. + * Even checking an sbconfig register read will not false trigger when the core + * is in reset it breaks CF address mechanism. Accessing gphy phyversion will + * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible + * reg with fixed 0/1 pattern (some platforms return all 0). + * If clocks are present, call the sb routine which will figure out if the + * device is removed. + */ +#define DEVICEREMOVED(wlc) \ + ((wlc->hw->clk) ? \ + ((R_REG(&wlc->hw->regs->maccontrol) & \ + (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \ + (ai_deviceremoved(wlc->hw->sih))) + +#define BRCMS_WME_RETRY_SHORT_GET(wlc, ac) \ + GFIELD(wlc->wme_retries[ac], EDCF_SHORT) +#define BRCMS_WME_RETRY_SFB_GET(wlc, ac) \ + GFIELD(wlc->wme_retries[ac], EDCF_SFB) +#define BRCMS_WME_RETRY_LONG_GET(wlc, ac) \ + GFIELD(wlc->wme_retries[ac], EDCF_LONG) +#define BRCMS_WME_RETRY_LFB_GET(wlc, ac) \ + GFIELD(wlc->wme_retries[ac], EDCF_LFB) + +#define BRCMS_WME_RETRY_SHORT_SET(wlc, ac, val) \ + (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val)) +#define BRCMS_WME_RETRY_SFB_SET(wlc, ac, val) \ + (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val)) +#define BRCMS_WME_RETRY_LONG_SET(wlc, ac, val) \ + (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val)) +#define BRCMS_WME_RETRY_LFB_SET(wlc, ac, val) \ + (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val)) + +/* sum the individual fifo tx pending packet counts */ +#define TXPKTPENDTOT(wlc) \ + ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ + (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) +#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) +#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) +#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val)) +#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) + +#define IS_MBAND_UNLOCKED(wlc) \ + ((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) + /* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) driver */ struct brcms_b_state { @@ -682,7 +763,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ /* BCN template is available */ - /* ZZZ: Use AP_ACTIVE ? */ if (AP_ENAB(wlc->pub) && (!APSTA_ENAB(wlc->pub)) && (macintstatus & MI_BCNTPL)) brcms_c_update_beacon(wlc); @@ -1596,7 +1676,7 @@ static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) { /* reject unsupported corerev */ - if (!VALID_COREREV(wlc_hw->corerev)) { + if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", wlc_hw->corerev); return false; @@ -2832,12 +2912,12 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) return false; /* disallow PS when one of these meets when not scanning */ - if (AP_ACTIVE(wlc) || wlc->monitor) + if (wlc->monitor) return false; for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { cfg = wlc->bsscfg[idx]; - if (cfg && BSSCFG_STA(cfg) && cfg->associated) { + if (cfg && cfg->associated) { /* * disallow PS when one of the following * bsscfg specific conditions meets @@ -3249,7 +3329,7 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) /* enable or disable any active IBSSs depending on whether or not * we are on the home channel */ - if (wlc->home_chanspec == BRCMS_BAND_PI_RADIO_CHANSPEC) { + if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { if (wlc->pub->associated) { /* * BMAC_NOTE: This is something that should be fixed @@ -3536,7 +3616,7 @@ void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) bool hps; bool awake_before; - hps = PS_ALLOWED(wlc); + hps = brcms_c_ps_allowed(wlc); BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps); @@ -3709,7 +3789,7 @@ static void brcms_c_setband(struct brcms_c_info *wlc, /* wait for at least one beacon before entering sleeping state */ for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { cfg = wlc->bsscfg[idx]; - if (cfg && BSSCFG_STA(cfg) && cfg->associated) + if (cfg && cfg->associated) cfg->PMawakebcn = true; } brcms_c_set_ps_ctrl(wlc); @@ -3972,18 +4052,18 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; /* Indicate the new params to the ucode */ acp_shm.status = brcms_c_read_shm(wlc, (M_EDCF_QINFO + - wme_shmemacindex(aci) * - M_EDCF_QLEN + - M_EDCF_STATUS_OFF)); + wme_ac2fifo[aci] * + M_EDCF_QLEN + + M_EDCF_STATUS_OFF)); acp_shm.status |= WME_STATUS_NEWAC; /* Fill in shm acparam table */ shm_entry = (u16 *) &acp_shm; for (i = 0; i < (int)sizeof(struct shm_acparams); i += 2) brcms_c_write_shm(wlc, - M_EDCF_QINFO + - wme_shmemacindex(aci) * M_EDCF_QLEN + i, - *shm_entry++); + M_EDCF_QINFO + + wme_ac2fifo[aci] * M_EDCF_QLEN + i, + *shm_entry++); } while (0); @@ -5536,8 +5616,7 @@ int brcms_c_up(struct brcms_c_info *wlc) WL_RADIO_HW_DISABLE); FOREACH_BSS(wlc, idx, bsscfg) - if (!BSSCFG_STA(bsscfg) - || !bsscfg->enable || !bsscfg->BSS) + if (!bsscfg->enable || !bsscfg->BSS) continue; wiphy_err(wlc->wiphy, "wl%d.%d: up" ": rfdisable -> " @@ -6127,7 +6206,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, /* brcms_c_BSSinit() will sanitize the rateset before * using it.. */ if (wlc->pub->up && - (BRCMS_BAND_PI_RADIO_CHANSPEC != chspec)) { + (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { brcms_c_set_home_chanspec(wlc, chspec); brcms_c_suspend_mac_and_wait(wlc); brcms_c_set_chanspec(wlc, chspec); @@ -6901,7 +6980,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, /* mcs only allowed when nmode */ if (stf > PHY_TXC1_MODE_SDM) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", - BRCMS_UNIT(wlc), __func__); + wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } @@ -6912,7 +6991,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, ((stf != PHY_TXC1_MODE_SISO) && (stf != PHY_TXC1_MODE_CDD))) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs " - "32\n", BRCMS_UNIT(wlc), __func__); + "32\n", wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } @@ -6921,8 +7000,8 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, /* mcs > 7 must use stf SDM */ if (stf != PHY_TXC1_MODE_SDM) { BCMMSG(wlc->wiphy, "wl%d: enabling " - "SDM mode for mcs %d\n", - BRCMS_UNIT(wlc), rate); + "SDM mode for mcs %d\n", + wlc->pub->unit, rate); stf = PHY_TXC1_MODE_SDM; } } else { @@ -6934,7 +7013,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, (!BRCMS_STBC_CAP_PHY(wlc) && (stf == PHY_TXC1_MODE_STBC))) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC" - "\n", BRCMS_UNIT(wlc), __func__); + "\n", wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } @@ -6942,7 +7021,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, } else if (IS_OFDM(rate)) { if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", - BRCMS_UNIT(wlc), __func__); + wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } @@ -6950,20 +7029,20 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, if ((cur_band->bandtype != BRCM_BAND_2G) || (stf != PHY_TXC1_MODE_SISO)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", - BRCMS_UNIT(wlc), __func__); + wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } } else { wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n", - BRCMS_UNIT(wlc), __func__); + wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } /* make sure multiple antennae are available for non-siso rates */ if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO " - "request\n", BRCMS_UNIT(wlc), __func__); + "request\n", wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } @@ -7075,7 +7154,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* non-AP STA should never use BCMC queue */ if (queue == TX_BCMC_FIFO) { wiphy_err(wlc->wiphy, "wl%d: %s: ASSERT queue == " - "TX_BCMC!\n", BRCMS_UNIT(wlc), __func__); + "TX_BCMC!\n", wlc->pub->unit, __func__); frameid = bcmc_fid_generate(wlc, NULL, txh); } else { /* Increment the counter for first fragment */ @@ -7198,7 +7277,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (CHSPEC_WLC_BW(wlc->chanspec) == BRCMS_40_MHZ) { /* default txbw is 20in40 SB */ mimo_ctlchbw = mimo_txbw = - CHSPEC_SB_UPPER(BRCMS_BAND_PI_RADIO_CHANSPEC) + CHSPEC_SB_UPPER(wlc_phy_chanspec_get( + wlc->band->pi)) ? PHY_TXC1_BW_20MHZ_UP : PHY_TXC1_BW_20MHZ; if (IS_MCS(rspec[k])) { @@ -7250,7 +7330,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, && (!IS_MCS(rspec[k]))) { wiphy_err(wlc->wiphy, "wl%d: %s: IEEE80211_TX_" "RC_MCS != IS_MCS(rspec)\n", - BRCMS_UNIT(wlc), __func__); + wlc->pub->unit, __func__); } if (IS_MCS(rspec[k])) { @@ -7352,7 +7432,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (BAND_5G(wlc->band->bandtype)) mcl |= TXC_FREQBAND_5G; - if (CHSPEC_IS40(BRCMS_BAND_PI_RADIO_CHANSPEC)) + if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) mcl |= TXC_BW_40; /* set AMIC bit if using hardware TKIP MIC */ @@ -7515,8 +7595,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, xfts = FRAMETYPE(rspec[1], wlc->mimoft); xfts |= (FRAMETYPE(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); xfts |= (FRAMETYPE(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); - xfts |= - CHSPEC_CHANNEL(BRCMS_BAND_PI_RADIO_CHANSPEC) << XFTS_CHANNEL_SHIFT; + xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << + XFTS_CHANNEL_SHIFT; txh->XtraFrameTypes = cpu_to_le16(xfts); /* PhyTxControlWord */ @@ -7798,8 +7878,13 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, } /* Commit BCMC sequence number in the SHM frame ID location */ - if (frameid != INVALIDFID) - BCMCFID(wlc, frameid); + if (frameid != INVALIDFID) { + /* + * To inform the ucode of the last mcast frame posted + * so that it can clear moredata bit + */ + brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); + } if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); @@ -8113,7 +8198,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) goto fatal; } - p = GETNEXTTXP(wlc, queue); + p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); if (BRCMS_WAR16165(wlc)) brcms_c_war16165(wlc, false); if (p == NULL) @@ -8972,10 +9057,7 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, struct ieee80211_mgmt *h; int hdr_len, body_len; - if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON) - hdr_len = DOT11_MAC_HDR_LEN; - else - hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN; + hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN; /* calc buffer size provided for frame body */ body_len = *len - hdr_len; @@ -8991,7 +9073,7 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, * PLCP for Probe Response frames are filled in from * core's rate table */ - if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) + if (type == IEEE80211_STYPE_BEACON) /* fill in PLCP */ brcms_c_compute_plcp(wlc, bcn_rspec, (DOT11_MAC_HDR_LEN + body_len + FCS_LEN), @@ -8999,13 +9081,9 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, /* "Regular" and 16 MBSS but not for 4 MBSS */ /* Update the phytxctl for the beacon based on the rspec */ - if (!SOFTBCN_ENAB(cfg)) - brcms_c_beacon_phytxctl_txant_upd(wlc, bcn_rspec); + brcms_c_beacon_phytxctl_txant_upd(wlc, bcn_rspec); - if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON) - h = (struct ieee80211_mgmt *)&plcp[0]; - else - h = (struct ieee80211_mgmt *)&plcp[1]; + h = (struct ieee80211_mgmt *)&plcp[1]; /* fill in 802.11 header */ h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type); @@ -9073,7 +9151,7 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, return; /* Optimize: Some of if/else could be combined */ - if (!MBSS_BCN_ENAB(cfg) && HWBCN_ENAB(cfg)) { + if ((cfg->flags & BRCMS_BSSCFG_HW_BCN) != 0) { /* Hardware beaconing for this config */ u16 bcn[BCN_TMPL_LEN / 2]; u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD; @@ -9113,7 +9191,7 @@ void brcms_c_update_beacon(struct brcms_c_info *wlc) /* update AP or IBSS beacons */ FOREACH_BSS(wlc, idx, bsscfg) - if (bsscfg->up && (BSSCFG_AP(bsscfg) || !bsscfg->BSS)) + if (bsscfg->up && !bsscfg->BSS) brcms_c_bss_update_beacon(wlc, bsscfg); END_FOREACH_BSS() } @@ -9130,9 +9208,7 @@ void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) memcpy(ssidbuf, ssidptr, cfg->SSID_len); brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); - - if (!MBSS_BCN_ENAB(cfg)) - brcms_c_write_shm(wlc, M_SSIDLEN, (u16) cfg->SSID_len); + brcms_c_write_shm(wlc, M_SSIDLEN, (u16) cfg->SSID_len); } void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) @@ -9142,7 +9218,7 @@ void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) /* update AP or IBSS probe responses */ FOREACH_BSS(wlc, idx, bsscfg) - if (bsscfg->up && (BSSCFG_AP(bsscfg) || !bsscfg->BSS)) + if (bsscfg->up && !bsscfg->BSS) brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); END_FOREACH_BSS() } @@ -9159,40 +9235,35 @@ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, * write the probe response to hardware, or save in * the config structure */ - if (!MBSS_PRB_ENAB(cfg)) { - /* create the probe response template */ - brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, - cfg, prb_resp, &len); + /* create the probe response template */ + brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, + cfg, prb_resp, &len); - if (suspend) - brcms_c_suspend_mac_and_wait(wlc); + if (suspend) + brcms_c_suspend_mac_and_wait(wlc); - /* write the probe response into the template region */ - brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, - (len + 3) & ~3, prb_resp); + /* write the probe response into the template region */ + brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, + (len + 3) & ~3, prb_resp); - /* write the length of the probe response frame (+PLCP/-FCS) */ - brcms_c_write_shm(wlc, M_PRB_RESP_FRM_LEN, (u16) len); + /* write the length of the probe response frame (+PLCP/-FCS) */ + brcms_c_write_shm(wlc, M_PRB_RESP_FRM_LEN, (u16) len); - /* write the SSID and SSID length */ - brcms_c_shm_ssid_upd(wlc, cfg); + /* write the SSID and SSID length */ + brcms_c_shm_ssid_upd(wlc, cfg); - /* - * Write PLCP headers and durations for probe response frames - * at all rates. Use the actual frame length covered by the - * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table() - * by subtracting the PLCP len and adding the FCS. - */ - len += (-D11_PHY_HDR_LEN + FCS_LEN); - brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len); + /* + * Write PLCP headers and durations for probe response frames + * at all rates. Use the actual frame length covered by the + * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table() + * by subtracting the PLCP len and adding the FCS. + */ + len += (-D11_PHY_HDR_LEN + FCS_LEN); + brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len); - if (suspend) - brcms_c_enable_mac(wlc); - } else { - /* Generating probe resp in sw; update local template */ - /* error: No software probe response support without MBSS */ - } + if (suspend) + brcms_c_enable_mac(wlc); } /* prepares pdu for transmission. returns BCM error codes */ @@ -9215,7 +9286,7 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) *fifop = fifo; /* return if insufficient dma resources */ - if (TXAVAIL(wlc, fifo) < MAX_DMA_SEGS) { + if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) { /* Mark precedences related to this FIFO, unsendable */ BRCMS_TX_FIFO_CLEAR(wlc, fifo); return -EBUSY; diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index d151a5c4af7..e8a854bfb12 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -24,27 +24,16 @@ #include "d11.h" #define MA_WINDOW_SZ 8 /* moving average window size */ -#define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ #define INVCHANNEL 255 /* invalid channel */ -/* max # supported core revisions (0 .. MAXCOREREV - 1) */ -#define MAXCOREREV 28 + /* max # brcms_c_module_register() calls */ #define BRCMS_MAXMODULES 22 #define SEQNUM_SHIFT 4 -#define AMPDU_DELIMITER_LEN 4 #define SEQNUM_MAX 0x1000 -#define APHY_CWMIN 15 -#define PHY_CWMAX 1023 - -#define EDCF_AIFSN_MIN 1 -#define FRAGNUM_MASK 0xF - #define NTXRATE 64 /* # tx MPDUs rate is reported for */ -#define BRCMS_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8)) - /* Maximum wait time for a MAC suspend */ /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */ #define BRCMS_MAX_MAC_SUSPEND 83000 @@ -77,13 +66,14 @@ #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */ +/* max # supported core revisions (0 .. MAXCOREREV - 1) */ +#define MAXCOREREV 28 + /* Double check that unsupported cores are not enabled */ #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV) #error "Configuration for D11CONF includes unsupported versions." #endif /* Bad versions */ -#define VALID_COREREV(corerev) CONF_HAS(D11CONF, corerev) - /* values for shortslot_override */ #define BRCMS_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */ #define BRCMS_SHORTSLOT_OFF 0 /* Turn off short slot */ @@ -97,17 +87,6 @@ #define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \ ((_pre) == BRCMS_MM_PREAMBLE)) -/* values for barker_preamble */ -#define BRCMS_BARKER_SHORT_ALLOWED 0 /* Short pre-amble allowed */ - -/* A fifo is full. Clear precedences related to that FIFO */ -#define BRCMS_TX_FIFO_CLEAR(wlc, fifo) \ - ((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo]) - -/* Fifo is NOT full. Enable precedences for that FIFO */ -#define BRCMS_TX_FIFO_ENAB(wlc, fifo) \ - ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo]) - /* TxFrameID */ /* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */ /* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */ @@ -122,20 +101,6 @@ #define BOARDREV_PROMOTABLE 0xFF /* from */ #define BOARDREV_PROMOTED 1 /* to */ -/* - * if wpa is in use then portopen is true when the - * group key is plumbed otherwise it is always true - */ -#define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED)) -#define BRCMS_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \ - ((bsscfg)->wsec & WSEC_SWFLAG))) - -#define BRCMS_PORTOPEN(cfg) \ - (((cfg)->WPA_auth != WPA_AUTH_DISABLED && WSEC_ENABLED((cfg)->wsec)) ? \ - (cfg)->wsec_portopen : true) - -#define PS_ALLOWED(wlc) brcms_c_ps_allowed(wlc) - #define DATA_BLOCK_TX_SUPR (1 << 4) /* 802.1D Priority to TX FIFO number for wme */ @@ -161,48 +126,14 @@ extern const u8 prio2fifo[]; MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \ MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP) -#define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ -#define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ -#define RETRY_LONG_DEF 4 /* Default Long retry count */ -#define RETRY_SHORT_FB 3 /* Short count for fallback rate */ -#define RETRY_LONG_FB 2 /* Long count for fallback rate */ - #define MAXTXPKTS 6 /* max # pkts pending */ /* frameburst */ #define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */ #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */ -/* Per-AC retry limit register definitions; uses defs.h bitfield macros */ -#define EDCF_SHORT_S 0 -#define EDCF_SFB_S 4 -#define EDCF_LONG_S 8 -#define EDCF_LFB_S 12 -#define EDCF_SHORT_M BITFIELD_MASK(4) -#define EDCF_SFB_M BITFIELD_MASK(4) -#define EDCF_LONG_M BITFIELD_MASK(4) -#define EDCF_LFB_M BITFIELD_MASK(4) - #define NFIFO 6 /* # tx/rx fifopairs */ -#define BRCMS_WME_RETRY_SHORT_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_SHORT) -#define BRCMS_WME_RETRY_SFB_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_SFB) -#define BRCMS_WME_RETRY_LONG_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_LONG) -#define BRCMS_WME_RETRY_LFB_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_LFB) - -#define BRCMS_WME_RETRY_SHORT_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val)) -#define BRCMS_WME_RETRY_SFB_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val)) -#define BRCMS_WME_RETRY_LONG_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val)) -#define BRCMS_WME_RETRY_LFB_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val)) - /* PLL requests */ /* pll is shared on old chips */ @@ -212,43 +143,11 @@ extern const u8 prio2fifo[]; /* hold/release pll for some short operation */ #define BRCMS_PLLREQ_FLIP 0x4 -/* - * Macros to check if AP or STA is active. - * AP Active means more than just configured: driver and BSS are "up"; - * that is, we are beaconing/responding as an AP (aps_associated). - * STA Active similarly means the driver is up and a configured STA BSS - * is up: either associated (stas_associated) or trying. - * - * Macro definitions vary as per AP/STA ifdefs, allowing references to - * ifdef'd structure fields and constant values (0) for optimization. - * Make sure to enclose blocks of code such that any routines they - * reference can also be unused and optimized out by the linker. - */ -/* NOTE: References structure fields defined in wlc.h */ -#define AP_ACTIVE(wlc) (0) +#define CHANNEL_BANDUNIT(wlc, ch) \ + (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) -/* - * Detect Card removed. - * Even checking an sbconfig register read will not false trigger when the core - * is in reset it breaks CF address mechanism. Accessing gphy phyversion will - * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible - * reg with fixed 0/1 pattern (some platforms return all 0). - * If clocks are present, call the sb routine which will figure out if the - * device is removed. - */ -#define DEVICEREMOVED(wlc) \ - ((wlc->hw->clk) ? \ - ((R_REG(&wlc->hw->regs->maccontrol) & \ - (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \ - (ai_deviceremoved(wlc->hw->sih))) - -#define BRCMS_UNIT(wlc) ((wlc)->pub->unit) - -#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ - brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) - -#define brcms_b_copyto_shm(wlc_hw, offset, buf, len) \ - brcms_b_copyto_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) +#define OTHERBANDUNIT(wlc) \ + ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) /* * 802.11 protection information @@ -337,21 +236,6 @@ struct brcms_stf { >> RXS_CHAN_PHYTYPE_SHIFT) #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \ >> RXS_CHAN_ID_SHIFT) -#define BRCMS_RX_CHANNEL(rxh) (BRCMS_CHAN_CHANNEL((rxh)->RxChan)) - -/* brcms_bss_info flag bit values */ -#define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ - -/* Flags used in brcms_c_txq_info.stopped */ -/* per prio flow control bits */ -#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF -/* stop txq enqueue for packet drain */ -#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 -/* stop txq enqueue for ampdu flow control */ -#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 - -#define BRCMS_HT_WEP_RESTRICT 0x01 /* restrict HT with WEP */ -#define BRCMS_HT_TKIP_RESTRICT 0x02 /* restrict HT with TKIP */ /* Maximum # of keys that wl driver supports in S/W. * Keys supported in H/W is less than or equal to WSEC_MAX_KEYS. @@ -365,10 +249,6 @@ struct brcms_stf { * s/w keys if WSEC_SW(wlc->wsec). * h/w keys otherwise. */ -#define BRCMS_MAX_WSEC_KEYS(wlc) WSEC_MAX_KEYS - -/* number of 802.11 default (non-paired, group keys) */ -#define WSEC_MAX_DEFAULT_KEYS 4 /* # of default keys */ struct wsec_iv { u32 hi; /* upper 32 bits of IV */ @@ -526,9 +406,6 @@ struct brcms_c_if { } u; }; -/* flags for the interface, this interface is linked to a brcms_if */ -#define BRCMS_IF_LINKED 0x02 - struct brcms_hw_band { int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */ uint bandunit; /* bandstate[] index */ @@ -1038,31 +915,6 @@ struct brcms_bss_cfg { u32 txrspec[NTXRATE][2]; }; -#define CHANNEL_BANDUNIT(wlc, ch) \ - (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) -#define OTHERBANDUNIT(wlc) \ - ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) - -#define IS_MBAND_UNLOCKED(wlc) \ - ((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) - -#define BRCMS_BAND_PI_RADIO_CHANSPEC wlc_phy_chanspec_get(wlc->band->pi) - -/* sum the individual fifo tx pending packet counts */ -#define TXPKTPENDTOT(wlc) \ - ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ - (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) -#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) -#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) -#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val)) -#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) -#define TXAVAIL(wlc, fifo) (*(wlc)->core->txavail[(fifo)]) -#define GETNEXTTXP(wlc, _queue) \ - dma_getnexttxp((wlc)->hw->di[(_queue)], DMA_RANGE_TRANSMITTED) - -#define BRCMS_IS_MATCH_SSID(wlc, ssid1, ssid2, len1, len2) \ - ((len1 == len2) && !memcmp(ssid1, ssid2, len1)) - extern void brcms_c_fatal_error(struct brcms_c_info *wlc); extern void brcms_b_rpc_watchdog(struct brcms_c_info *wlc); extern void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p); diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 62f3efefdf4..0a101a4ee62 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -30,6 +30,8 @@ #define BRCMS_STF_SS_STBC_RX(wlc) (BRCMS_ISNPHY(wlc->band) && \ NREV_GT(wlc->band->phyrev, 3) && NREV_LE(wlc->band->phyrev, 6)) +#define BRCMS_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8)) + #define NSTS_1 1 #define NSTS_2 2 #define NSTS_3 3 From e6b8641f45bd79dbc26931972431c4697686472d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Sep 2011 16:00:28 +0200 Subject: [PATCH 0869/1519] staging: brcm80211: remove extern keyword from function definition Sparse warning was given when using the extern keyword in the function definition. This patch removes those instances. Reported-by: Aaro Koskinen Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 5482005c656..6adf5c0e1a8 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -76,9 +76,8 @@ brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t wq) #endif } -extern int -brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, - uint regaddr, u8 *byte) +int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, + uint regaddr, u8 *byte) { int err_ret; @@ -173,9 +172,9 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, return err_ret; } -extern int -brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint rw, - uint func, uint addr, u32 *word, uint nbytes) +int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, + uint rw, uint func, uint addr, u32 *word, + uint nbytes) { int err_ret = -EIO; @@ -304,11 +303,10 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, * aligned packet. * */ -extern int -brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, - uint fix_inc, uint write, uint func, uint addr, - uint reg_width, uint buflen_u, u8 *buffer, - struct sk_buff *pkt) +int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, + uint fix_inc, uint write, uint func, uint addr, + uint reg_width, uint buflen_u, u8 *buffer, + struct sk_buff *pkt) { int Status; struct sk_buff *mypkt = NULL; @@ -425,9 +423,8 @@ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) return scratch; } -extern int -brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, - u8 *cisd, u32 length) +int brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, + u8 *cisd, u32 length) { u32 count; int offset; From 7e9f621cb958fb4d2a8ba922465b2be699b7eeb0 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Sep 2011 16:00:29 +0200 Subject: [PATCH 0870/1519] staging: brcm80211: replace 0 integer with NULL pointer Running sparse showed following warning: Using plain integer as NULL pointer. This has been fixed. Reported-by: Aaro Koskinen Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 3abd434ba52..cb7393c64ba 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -840,7 +840,7 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, const char *str; int buf_len; int str_len; - char *arg_save = 0, *arg_org = 0; + char *arg_save = NULL, *arg_org = NULL; int rc; char buf[128]; struct brcmf_pkt_filter_enable enable_parm; @@ -915,9 +915,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) int rc; u32 mask_size; u32 pattern_size; - char *argv[8], *buf = 0; + char *argv[8], *buf = NULL; int i = 0; - char *arg_save = 0, *arg_org = 0; + char *arg_save = NULL, *arg_org = NULL; arg_save = kstrdup(arg, GFP_ATOMIC); if (!arg_save) { @@ -1099,7 +1099,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* query for 'ver' to get version info from firmware */ memset(buf, 0, sizeof(buf)); ptr = buf; - brcmu_mkiovar("ver", 0, 0, buf, sizeof(buf)); + brcmu_mkiovar("ver", NULL, 0, buf, sizeof(buf)); brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); strsep(&ptr, "\n"); /* Print fw version info */ From 8155f3681549fd590fa1acff4d6c2edd35958c79 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Sep 2011 16:00:30 +0200 Subject: [PATCH 0871/1519] staging: brcm80211: use address space qualifier in brcmfmac Several sparse warning were issued due to missing __user qualifier for brcmfmac variables. This patch adds those. Reported-by: Aaro Koskinen Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 4 ++-- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index ee09c17db58..4d06d874e17 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -779,7 +779,7 @@ extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, /* Linux network driver ioctl encoding */ struct brcmf_c_ioctl { uint cmd; /* common ioctl definition */ - void *buf; /* pointer to user buffer */ + void __user *buf; /* pointer to user buffer */ uint len; /* length of user buffer */ bool set; /* get or set request (optional) */ uint used; /* bytes read or written (optional) */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 470759a1f10..bb0f71866a6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -835,7 +835,7 @@ static struct ethtool_ops brcmf_ethtool_ops = { .get_drvinfo = brcmf_ethtool_get_drvinfo }; -static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr) +static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) { struct ethtool_drvinfo info; char drvname[sizeof(info.driver)]; @@ -1001,7 +1001,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, } /* To differentiate read 4 more byes */ - if ((copy_from_user(&driver, (char *)ifr->ifr_data + + if ((copy_from_user(&driver, (char __user *)ifr->ifr_data + sizeof(struct brcmf_ioctl), sizeof(uint)) != 0)) { bcmerror = -EINVAL; goto done; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 60a04b37a3d..db51c466f2e 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -540,7 +540,7 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) ioc.buf = arg; ioc.len = len; strcpy(ifr.ifr_name, dev->name); - ifr.ifr_data = (caddr_t)&ioc; + ifr.ifr_data = (char __user *)&ioc; fs = get_fs(); set_fs(get_ds()); From ef6cc1d6a2b625d2780914caa0d7bca61bdb14be Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Sep 2011 16:00:31 +0200 Subject: [PATCH 0872/1519] staging: brcm80211: remove sparse warning from main.c The source file main.c contained several sparse warnings which have been cleaned up. Reported-by: Aaro Koskinen Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 19 +++++++++---------- drivers/staging/brcm80211/brcmsmac/pub.h | 5 +++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 6b694b15979..9e73b429cf4 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -880,7 +880,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) /* name and offsets for dma_attach */ snprintf(name, sizeof(name), "wl%d", unit); - if (wlc_hw->di[0] == 0) { /* Init FIFOs */ + if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ int dma_attach_err = 0; /* @@ -5006,7 +5006,8 @@ static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) */ struct brcms_c_info * brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, struct pci_dev *btparam, uint *perr) + bool piomode, void __iomem *regsva, struct pci_dev *btparam, + uint *perr) { struct brcms_c_info *wlc; uint err = 0; @@ -7096,8 +7097,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, int len, phylen, rts_phylen; u16 mch, phyctl, xfts, mainrates; u16 seq = 0, mcl = 0, status = 0, frameid = 0; - u32 rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }, rts_rspec[2] = { - BRCM_RATE_1M, BRCM_RATE_1M}; + u32 rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }; + u32 rts_rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }; bool use_rts = false; bool use_cts = false; bool use_rifs = false; @@ -7741,9 +7742,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, return 0; } -bool -brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, - struct ieee80211_hw *hw) +void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, + struct ieee80211_hw *hw) { u8 prio; uint fifo; @@ -7760,10 +7760,9 @@ brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, if (unlikely (brcms_c_d11hdrs_mac80211( wlc, hw, sdu, scb, 0, 1, fifo, 0, NULL, 0))) - return -EINVAL; + return; brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); brcms_c_send_q(wlc); - return 0; } void brcms_c_send_q(struct brcms_c_info *wlc) @@ -9100,7 +9099,7 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, return; } -int brcms_c_get_header_len() +int brcms_c_get_header_len(void) { return TXOFF; } diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index f4e47e8487c..5bca2fbc6d4 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -536,7 +536,8 @@ struct brcms_antselcfg { /* common functions for every port */ struct brcms_c_info * brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void *regsva, struct pci_dev *btparam, uint *perr); + bool piomode, void __iomem *regsva, struct pci_dev *btparam, + uint *perr); extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); @@ -553,7 +554,7 @@ extern void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask); extern bool brcms_c_intrsupd(struct brcms_c_info *wlc); extern bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc); extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded); -extern bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, +extern void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, struct ieee80211_hw *hw); extern int brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, From 33bc95513c801b1637b6fb925155fb794b5da4f0 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Sep 2011 16:00:32 +0200 Subject: [PATCH 0873/1519] staging: brcm80211: remove 'default n' from Kconfig Kconfig options are by default not selected so adding the statement 'default n' to the option is not needed. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/Kconfig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index 59e9c8548d0..f51e0f17d70 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -1,10 +1,8 @@ config BRCMUTIL tristate - default n config BRCMSMAC tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - default n depends on PCI depends on WLAN && MAC80211 depends on BCMA=n @@ -20,7 +18,6 @@ config BRCMSMAC config BRCMFMAC tristate "Broadcom IEEE802.11n embedded FullMAC WLAN driver" - default n depends on MMC depends on WLAN && CFG80211 select BRCMUTIL @@ -33,7 +30,6 @@ config BRCMFMAC config BRCMDBG bool "Broadcom driver debug functions" - default n depends on BRCMSMAC || BRCMFMAC ---help--- Selecting this enables additional code for debug purposes. From 0d62b4db565084d33fb9ca3ae8d3814e4dd1a797 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:33 +0200 Subject: [PATCH 0874/1519] staging: brcm80211: cleaned up softmac phy macro's affecting code flow Substituted macro's. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 6 ++++-- drivers/staging/brcm80211/brcmsmac/types.h | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index b52b30589c1..5f30de20f6d 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -204,7 +204,8 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) switch (pi->pubpi.phy_type) { case PHY_TYPE_N: - CASECHECK(PHYTYPE, PHY_TYPE_N); + if (!CONF_HAS(PHYTYPE, PHY_TYPE_N)) + break; if (NREV_GE(pi->pubpi.phy_rev, 7)) addr |= RADIO_2057_READ_OFF; else @@ -212,7 +213,8 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) break; case PHY_TYPE_LCN: - CASECHECK(PHYTYPE, PHY_TYPE_LCN); + if (!CONF_HAS(PHYTYPE, PHY_TYPE_LCN)) + break; addr |= RADIO_2064_READ_OFF; break; diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index cf65f6e7522..792df079364 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -220,11 +220,6 @@ #define PHYTYPE_IS(var, val)\ (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val)))) -/* Finally, early-exit from switch case if anyone wants it... */ - -#define CASECHECK(config, val) if (!(CONF_HAS(config, val))) break -#define CASEMSK(config, mask) if (!(CONF_MSK(config, mask))) break - /* Set up PHYTYPE automatically: (depends on PHY_TYPE_X, from d11.h) */ #define _PHYCONF_N (1 << PHY_TYPE_N) From d708438019464031bfbe7c035c19047bf9195c6f Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:34 +0200 Subject: [PATCH 0875/1519] staging: brcm80211: cleaned up softmac nicpci.c/nicpci.h macro's Substituted macro's. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/nicpci.c | 42 ++++++++++++--------- drivers/staging/brcm80211/brcmsmac/nicpci.h | 12 ------ 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 6bffca002ab..a2cab5c312e 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -127,6 +127,18 @@ /* PCIE protocol TLP diagnostic registers */ #define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */ +/* Sonics to PCI translation types */ +#define SBTOPCI_PREF 0x4 /* prefetch enable */ +#define SBTOPCI_BURST 0x8 /* burst enable */ +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */ + +#define PCI_CLKRUN_DSBL 0x8000 /* Bit 15 forceClkrun */ + +/* PCI core index in SROM shadow area */ +#define SRSH_PI_OFFSET 0 /* first word */ +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */ +#define SRSH_PI_SHIFT 12 /* bit 15:12 */ + /* Sonics side: PCI core and host control registers */ struct sbpciregs { u32 control; /* PCI control */ @@ -211,18 +223,17 @@ struct pcicore_info { bool pmecap; /* Capable of generating PME */ }; -/* debug/trace */ -#define PCI_ERROR(args) -#define PCIE_PUB(sih) ((sih)->buscoretype == PCIE_CORE_ID) - #define PCIE_ASPM(sih) \ - ((PCIE_PUB(sih)) && \ + (((sih)->buscoretype == PCIE_CORE_ID) && \ (((sih)->buscorerev >= 3) && \ ((sih)->buscorerev <= 5))) /* delay needed between the mdio control/ mdiodata register data access */ -#define PR28829_DELAY() udelay(10) +static void pr28829_delay(void) +{ + udelay(10); +} /* Initialize the PCI core. * It's caller's responsibility to make sure that this is done only once @@ -235,7 +246,6 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, /* alloc struct pcicore_info */ pi = kzalloc(sizeof(struct pcicore_info), GFP_ATOMIC); if (pi == NULL) { - PCI_ERROR(("pci_attach: malloc failed!\n")); return NULL; } @@ -375,7 +385,7 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) (blk << 4)); W_REG(&pcieregs->mdiodata, mdiodata); - PR28829_DELAY(); + pr28829_delay(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) @@ -386,7 +396,6 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) } if (i >= pcie_serdes_spinwait) { - PCI_ERROR(("pcie_mdiosetblock: timed out\n")); return false; } @@ -427,13 +436,13 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, W_REG(&pcieregs->mdiodata, mdiodata); - PR28829_DELAY(); + pr28829_delay(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) { if (!write) { - PR28829_DELAY(); + pr28829_delay(); *val = (R_REG(&pcieregs->mdiodata) & MDIODATA_MASK); } @@ -445,8 +454,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, i++; } - PCI_ERROR(("pcie_mdioop: timed out op: %d\n", write)); - /* Disable mdio access to SERDES */ + /* Timed out. Disable mdio access to SERDES. */ W_REG(&pcieregs->mdiocontrol, 0); return 1; } @@ -498,7 +506,7 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend) struct si_pub *sih = pi->sih; struct sbpcieregs *pcieregs = pi->regs.pcieregs; - if (!PCIE_PUB(sih) || sih->buscorerev < 7) + if (sih->buscoretype != PCIE_CORE_ID || sih->buscorerev < 7) return; w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); @@ -736,7 +744,7 @@ void pcicore_attach(struct pcicore_info *pi, char *pvars, int state) void pcicore_hwup(struct pcicore_info *pi) { - if (!pi || !PCIE_PUB(pi->sih)) + if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) return; pcie_war_pci_setup(pi); @@ -744,7 +752,7 @@ void pcicore_hwup(struct pcicore_info *pi) void pcicore_up(struct pcicore_info *pi, int state) { - if (!pi || !PCIE_PUB(pi->sih)) + if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) return; /* Restore L1 timer for better performance */ @@ -772,7 +780,7 @@ void pcicore_sleep(struct pcicore_info *pi) void pcicore_down(struct pcicore_info *pi, int state) { - if (!pi || !PCIE_PUB(pi->sih)) + if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) return; pcie_clkreq_upd(pi, state); diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.h b/drivers/staging/brcm80211/brcmsmac/nicpci.h index 3082db0d4f4..49952039841 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.h +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.h @@ -58,18 +58,6 @@ /* bar0 + 12K accesses chipc core registers */ #define PCI_16KB0_CCREGS_OFFSET (12 * 1024) -#define PCI_CLKRUN_DSBL 0x8000 /* Bit 15 forceClkrun */ - -/* Sonics to PCI translation types */ -#define SBTOPCI_PREF 0x4 /* prefetch enable */ -#define SBTOPCI_BURST 0x8 /* burst enable */ -#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */ - -/* PCI core index in SROM shadow area */ -#define SRSH_PI_OFFSET 0 /* first word */ -#define SRSH_PI_MASK 0xf000 /* bit 15:12 */ -#define SRSH_PI_SHIFT 12 /* bit 15:12 */ - struct sbpciregs; struct sbpcieregs; From 9b5795a7624153dd78e03f0e1c99b2d54cee5b8c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:35 +0200 Subject: [PATCH 0876/1519] staging: brcm80211: cleaned up more softmac macro's Substituted/removed macro's. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 18 +++++++++ drivers/staging/brcm80211/brcmsmac/main.h | 1 - drivers/staging/brcm80211/brcmsmac/otp.c | 5 ++- drivers/staging/brcm80211/brcmsmac/otp.h | 6 --- drivers/staging/brcm80211/brcmsmac/pmu.h | 13 ------ drivers/staging/brcm80211/brcmsmac/pub.h | 49 ----------------------- 6 files changed, 21 insertions(+), 71 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 9e73b429cf4..fff3ba9dc5b 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -267,6 +267,20 @@ #define APHY_SLOT_TIME 9 #define BPHY_SLOT_TIME 20 +#define WL_SPURAVOID_OFF 0 +#define WL_SPURAVOID_ON1 1 +#define WL_SPURAVOID_ON2 2 + +/* + * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. + */ +#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) + +/* defaults for the HT (MIMO) bss */ +#define HT_CAP (IEEE80211_HT_CAP_SM_PS |\ + IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |\ + IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40) + /* * The following table lists the buffer memory allocated to xmt fifos in HW. * the size is in units of 256bytes(one block), total size is HW dependent @@ -361,6 +375,10 @@ #define IS_MBAND_UNLOCKED(wlc) \ ((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) +#define CHSPEC_WLC_BW(chanspec) (CHSPEC_IS40(chanspec) ? BRCMS_40_MHZ : \ + CHSPEC_IS20(chanspec) ? BRCMS_20_MHZ : \ + BRCMS_10_MHZ) + /* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) driver */ struct brcms_b_state { diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index e8a854bfb12..047c422174d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -23,7 +23,6 @@ #include "types.h" #include "d11.h" -#define MA_WINDOW_SZ 8 /* moving average window size */ #define INVCHANNEL 255 /* invalid channel */ /* max # brcms_c_module_register() calls */ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 1e0093c71ca..05c78c7f33c 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -64,6 +64,9 @@ #define MAXNUMRDES 9 /* Maximum OTP redundancy entries */ +/* Fixed size subregions sizes in words */ +#define OTPGU_CI_SZ 2 + /* OTP function struct */ struct otp_fn_s { int (*size)(struct otpinfo *oi); @@ -111,8 +114,6 @@ static struct otpinfo otpinfo; * */ -#define HWSW_RGN(rgn) (((rgn) == OTP_HW_RGN) ? "h/w" : "s/w") - /* OTP layout */ /* CC revs 21, 24 and 27 OTP General Use Region word offset */ #define REVA4_OTPGU_BASE 12 diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h index 938100e2548..bf2f76f96ac 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.h +++ b/drivers/staging/brcm80211/brcmsmac/otp.h @@ -30,12 +30,6 @@ /* OTP Size */ #define OTP_SZ_MAX (6144/8) /* maximum bytes in one CIS */ -/* Fixed size subregions sizes in words */ -#define OTPGU_CI_SZ 2 - -/* OTP usage */ -#define OTP4325_FM_DISABLED_OFFSET 188 - struct otpinfo; /* Exported functions */ diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.h b/drivers/staging/brcm80211/brcmsmac/pmu.h index 0c7e48c4bcd..2917e6ff862 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.h +++ b/drivers/staging/brcm80211/brcmsmac/pmu.h @@ -19,19 +19,6 @@ #define _BRCM_PMU_H_ #include "types.h" -/* - * LDO selections used in si_pmu_set_ldo_voltage - */ -#define SET_LDO_VOLTAGE_LDO1 1 -#define SET_LDO_VOLTAGE_LDO2 2 -#define SET_LDO_VOLTAGE_LDO3 3 -#define SET_LDO_VOLTAGE_PAREF 4 -#define SET_LDO_VOLTAGE_CLDO_PWM 5 -#define SET_LDO_VOLTAGE_CLDO_BURST 6 -#define SET_LDO_VOLTAGE_CBUCK_PWM 7 -#define SET_LDO_VOLTAGE_CBUCK_BURST 8 -#define SET_LDO_VOLTAGE_LNLDO1 9 -#define SET_LDO_VOLTAGE_LNLDO2_SEL 10 extern u16 si_pmu_fast_pwrup_delay(struct si_pub *sih); extern void si_pmu_sprom_enable(struct si_pub *sih, bool enable); diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 5bca2fbc6d4..ab2fb119f23 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -40,10 +40,6 @@ #define BRCMS_20_MHZ 20 /* 20Mhz nphy channel bandwidth */ #define BRCMS_40_MHZ 40 /* 40Mhz nphy channel bandwidth */ -#define CHSPEC_WLC_BW(chanspec) (CHSPEC_IS40(chanspec) ? BRCMS_40_MHZ : \ - CHSPEC_IS20(chanspec) ? BRCMS_20_MHZ : \ - BRCMS_10_MHZ) - #define BRCMS_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */ #define BRCMS_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */ #define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */ @@ -52,13 +48,6 @@ #define BRCMS_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */ #define BRCMS_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */ -/* macro to perform PHY -> D11 PHY TYPE, currently 1:1 */ -#define BRCMS_PHYTYPE(_x) (_x) - -#define MA_WINDOW_SZ 8 /* moving average window size */ - -#define BRCMS_SNR_INVALID 0 /* invalid SNR value */ - /* a large TX Power as an init value to factor out of min() calculations, * keep low enough to fit in an s8, units are .25 dBm */ @@ -87,9 +76,6 @@ /* driver's default tx antenna setting */ #define ANT_TX_DEF 3 -/* use all available core for transmit */ -#define TXCORE_POLICY_ALL 0x1 - /* Tx Chain values */ /* def bitmap of txchain */ #define TXCHAIN_DEF 0x1 @@ -113,15 +99,9 @@ #define ANTSWITCH_TYPE_3 3 #define RXBUFSZ PKTBUFSZ -/* aid bitmap size in bytes */ -#define AIDMAPSZ (roundup(MAXSCB, NBBY)/NBBY) #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ -#define WL_SPURAVOID_OFF 0 -#define WL_SPURAVOID_ON1 1 -#define WL_SPURAVOID_ON2 2 - struct brcms_tunables { int ntxd; /* size of tx descriptor table */ int nrxd; /* size of rx descriptor table */ @@ -158,24 +138,11 @@ struct rsn_parms { u8 PAD[4]; /* padding for future growth */ }; -/* - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. - */ -#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) - -#define RSN_FLAGS_SUPPORTED 0x1 /* Flag for rsn_params */ -#define RSN_FLAGS_PREAUTH 0x2 /* Flag for WPA2 rsn_params */ - /* All the HT-specific default advertised capabilities (including AMPDU) * should be grouped here at one place */ #define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */ -/* defaults for the HT (MIMO) bss */ -#define HT_CAP (IEEE80211_HT_CAP_SM_PS |\ - IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |\ - IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40) - /* wlc internal bss_info */ struct brcms_bss_info { u8 BSSID[ETH_ALEN]; /* network BSSID */ @@ -202,22 +169,6 @@ struct brcms_bss_info { u8 wpacfg; /* wpa config index */ }; -/* IOVar flags for common error checks */ -#define IOVF_MFG (1<<3) /* flag for mfgtest iovars */ -#define IOVF_WHL (1<<4) /* value must be whole (0-max) */ -#define IOVF_NTRL (1<<5) /* value must be natural (1-max) */ - -#define IOVF_SET_UP (1<<6) /* set requires driver be up */ -#define IOVF_SET_DOWN (1<<7) /* set requires driver be down */ -#define IOVF_SET_CLK (1<<8) /* set requires core clock */ -#define IOVF_SET_BAND (1<<9) /* set requires fixed band */ - -#define IOVF_GET_UP (1<<10) /* get requires driver be up */ -#define IOVF_GET_DOWN (1<<11) /* get requires driver be down */ -#define IOVF_GET_CLK (1<<12) /* get requires core clock */ -#define IOVF_GET_BAND (1<<13) /* get requires fixed band */ -#define IOVF_OPEN_ALLOW (1<<14) /* set allowed iovar for opensrc */ - #define MAC80211_PROMISC_BCNS (1 << 0) #define MAC80211_SCAN (1 << 1) From c43f1e05bfd8aa39beecab83c7f812cb254fe625 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:36 +0200 Subject: [PATCH 0877/1519] staging: brcm80211: remove AP related code from softmac AP support was only partially implemented and never invoked. AP related code sections removed. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 64 ++++------------------- drivers/staging/brcm80211/brcmsmac/pub.h | 11 +--- 2 files changed, 10 insertions(+), 65 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index fff3ba9dc5b..4de57f4df6e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -193,7 +193,7 @@ * for maintenance tasks such as phy calibration and scb update */ -#define BRCMS_WAR16165(wlc) ((!AP_ENAB(wlc->pub)) && (wlc->war16165)) +#define BRCMS_WAR16165(wlc) (wlc->war16165) /* Find basic rate for a given rate */ #define BRCMS_BASIC_RATE(wlc, rspec) \ @@ -780,11 +780,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ - /* BCN template is available */ - if (AP_ENAB(wlc->pub) && (!APSTA_ENAB(wlc->pub)) - && (macintstatus & MI_BCNTPL)) - brcms_c_update_beacon(wlc); - /* tx status */ if (macintstatus & MI_TFS) { if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) @@ -3596,8 +3591,7 @@ void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) { - if ((AP_ENAB(wlc->pub) && (N_ENAB(wlc->pub) || wlc->band->gmode)) || - wlc->bcnmisc_ibss || wlc->bcnmisc_scan || wlc->bcnmisc_monitor) + if (wlc->bcnmisc_ibss || wlc->bcnmisc_scan || wlc->bcnmisc_monitor) brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); else brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, 0); @@ -3614,7 +3608,7 @@ void brcms_c_mac_promisc(struct brcms_c_info *wlc) * the MCTL_PROMISC bit since all BSS data traffic is * directed at the AP */ - if (PROMISC_ENAB(wlc->pub) && !AP_ENAB(wlc->pub)) + if (PROMISC_ENAB(wlc->pub)) promisc_bits |= MCTL_PROMISC; /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL @@ -4129,11 +4123,6 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) if (suspend) brcms_c_suspend_mac_and_wait(wlc); - if (AP_ENAB(wlc->pub) && WME_ENAB(wlc->pub)) { - brcms_c_update_beacon(wlc); - brcms_c_update_probe_resp(wlc, false); - } - if (suspend) brcms_c_enable_mac(wlc); @@ -4146,11 +4135,8 @@ static void brcms_c_down_led_upd(struct brcms_c_info *wlc) * maintain LEDs while in down state, turn on sbclk if * not available yet. Turn on sbclk if necessary */ - if (!AP_ENAB(wlc->pub)) { - brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); - - brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); - } + brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); + brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); } static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc) @@ -5394,12 +5380,8 @@ uint brcms_c_detach(struct brcms_c_info *wlc) /* update state that depends on the current value of "ap" */ void brcms_c_ap_upd(struct brcms_c_info *wlc) { - if (AP_ENAB(wlc->pub)) - /* AP: short not allowed, but not enforced */ - wlc->PLCPHdr_override = BRCMS_PLCP_AUTO; - else - /* STA-BSS; short capable */ - wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; + /* STA-BSS; short capable */ + wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; /* fixup mpc */ wlc->mpc = true; @@ -5678,10 +5660,6 @@ int brcms_c_up(struct brcms_c_info *wlc) brcms_b_up_finish(wlc->hw); - /* other software states up after ISR is running */ - /* start APs that were to be brought up but are not up yet */ - /* if (AP_ENAB(wlc->pub)) brcms_c_restart_ap(wlc->ap); */ - /* Program the TX wme params with the current settings */ brcms_c_wme_retries_write(wlc); @@ -5900,9 +5878,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) break; case GMODE_LRS: - if (AP_ENAB(wlc->pub)) - brcms_c_rateset_copy(&cck_rates, - &wlc->sup_rates_override); break; case GMODE_AUTO: @@ -5916,11 +5891,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) break; case GMODE_PERFORMANCE: - if (AP_ENAB(wlc->pub)) - /* Put all rates into the Supported Rates element */ - brcms_c_rateset_copy(&cck_ofdm_rates, - &wlc->sup_rates_override); - shortslot = BRCMS_SHORTSLOT_ON; shortslot_restrict = true; ofdm_basic = true; @@ -5953,21 +5923,13 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) wlc->shortslot_override = shortslot; - if (AP_ENAB(wlc->pub)) - /* wlc->ap->shortslot_restrict = shortslot_restrict; */ - wlc->PLCPHdr_override = - (preamble != - BRCMS_PLCP_LONG) ? BRCMS_PLCP_SHORT : BRCMS_PLCP_AUTO; - - if ((AP_ENAB(wlc->pub) && preamble != BRCMS_PLCP_LONG) - || preamble == BRCMS_PLCP_SHORT) + if (preamble == BRCMS_PLCP_SHORT) wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; else wlc->default_bss->capability &= ~WLAN_CAPABILITY_SHORT_PREAMBLE; /* Update shortslot capability bit for AP and IBSS */ - if ((AP_ENAB(wlc->pub) && shortslot == BRCMS_SHORTSLOT_AUTO) || - shortslot == BRCMS_SHORTSLOT_ON) + if (shortslot == BRCMS_SHORTSLOT_ON) wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME; else wlc->default_bss->capability &= @@ -8359,20 +8321,12 @@ brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) /* There is more room; mark precedences related to this FIFO sendable */ BRCMS_TX_FIFO_ENAB(wlc, fifo); - /* Clear MHF2_TXBCMC_NOW flag if BCMC fifo has drained */ - if (AP_ENAB(wlc->pub) && - !TXPKTPENDGET(wlc, TX_BCMC_FIFO)) - brcms_c_mhf(wlc, MHF2, MHF2_TXBCMC_NOW, 0, BRCM_BAND_AUTO); - /* figure out which bsscfg is being worked on... */ } /* Update beacon listen interval in shared memory */ void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) { - if (AP_ENAB(wlc->pub)) - return; - /* wake up every DTIM is the default */ if (wlc->bcn_li_dtim == 1) brcms_c_write_shm(wlc, M_BCN_LI, 0); diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index ab2fb119f23..a56239a763c 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -285,22 +285,13 @@ enum wlc_par_id { * ********************************************* */ -/* AP Support (versus STA) */ -#define AP_ENAB(pub) (0) - -/* Macro to check if APSTA mode enabled */ -#define APSTA_ENAB(pub) (0) - -/* Some useful combinations */ -#define STA_ONLY(pub) (!AP_ENAB(pub)) -#define AP_ONLY(pub) (AP_ENAB(pub) && !APSTA_ENAB(pub)) - #define ENAB_1x1 0x01 #define ENAB_2x2 0x02 #define ENAB_3x3 0x04 #define ENAB_4x4 0x08 #define SUPPORT_11N (ENAB_1x1|ENAB_2x2) #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) + /* WL11N Support */ #define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N) #define N_REQD(pub) ((pub)->_n_reqd) From e95606562d640ebcdabf66f99b3af296487c0bc5 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:37 +0200 Subject: [PATCH 0878/1519] staging: brcm80211: cleaned up softmac pub.h macro's Substituted/removed macro's. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 2 +- drivers/staging/brcm80211/brcmsmac/channel.c | 6 +- drivers/staging/brcm80211/brcmsmac/main.c | 84 ++++++++++++--- drivers/staging/brcm80211/brcmsmac/pub.h | 104 +++---------------- drivers/staging/brcm80211/brcmsmac/scb.h | 4 +- 5 files changed, 90 insertions(+), 110 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index cbf6c6d0fe6..7c44598e630 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -180,7 +180,7 @@ static int brcms_c_ampdu_set(struct ampdu_info *ampdu, bool on) wlc->pub->_ampdu = false; if (on) { - if (!N_ENAB(wlc->pub)) { + if (!(wlc->pub->_n_enab & SUPPORT_11N)) { wiphy_err(ampdu->wlc->wiphy, "wl%d: driver not " "nmode enabled\n", wlc->pub->unit); return -ENOTSUPP; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index e6afdc95ace..282adcefbb3 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1010,7 +1010,8 @@ brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, wlc->stf->no_cddstbc = true; } else { wlc->stf->no_cddstbc = false; - if (N_ENAB(wlc->pub) != wlc->protection->nmode_user) + if ((wlc->pub->_n_enab & SUPPORT_11N) != + wlc->protection->nmode_user) brcms_c_set_nmode(wlc, wlc->protection->nmode_user); } @@ -1137,7 +1138,8 @@ brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, static bool brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) { - return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? + return (wlc_cm->wlc->pub->_n_enab & SUPPORT_11N) && + CHSPEC_IS40(chspec) ? (isset(wlc_cm->quiet_channels.vec, LOWER_20_SB(CHSPEC_CHANNEL(chspec))) || isset(wlc_cm->quiet_channels.vec, diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 4de57f4df6e..4436b4fcdb6 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -271,6 +271,64 @@ #define WL_SPURAVOID_ON1 1 #define WL_SPURAVOID_ON2 2 +/* invalid core flags, use the saved coreflags */ +#define BRCMS_USE_COREFLAGS 0xffffffff + +/* values for PLCPHdr_override */ +#define BRCMS_PLCP_AUTO -1 +#define BRCMS_PLCP_SHORT 0 +#define BRCMS_PLCP_LONG 1 + +/* values for g_protection_override and n_protection_override */ +#define BRCMS_PROTECTION_AUTO -1 +#define BRCMS_PROTECTION_OFF 0 +#define BRCMS_PROTECTION_ON 1 +#define BRCMS_PROTECTION_MMHDR_ONLY 2 +#define BRCMS_PROTECTION_CTS_ONLY 3 + +/* values for g_protection_control and n_protection_control */ +#define BRCMS_PROTECTION_CTL_OFF 0 +#define BRCMS_PROTECTION_CTL_LOCAL 1 +#define BRCMS_PROTECTION_CTL_OVERLAP 2 + +/* values for n_protection */ +#define BRCMS_N_PROTECTION_OFF 0 +#define BRCMS_N_PROTECTION_OPTIONAL 1 +#define BRCMS_N_PROTECTION_20IN40 2 +#define BRCMS_N_PROTECTION_MIXEDMODE 3 + +/* values for band specific 40MHz capabilities */ +#define BRCMS_N_BW_20ALL 0 +#define BRCMS_N_BW_40ALL 1 +#define BRCMS_N_BW_20IN2G_40IN5G 2 + +/* bitflags for SGI support (sgi_rx iovar) */ +#define BRCMS_N_SGI_20 0x01 +#define BRCMS_N_SGI_40 0x02 + +/* defines used by the nrate iovar */ +/* MSC in use,indicates b0-6 holds an mcs */ +#define NRATE_MCS_INUSE 0x00000080 +/* rate/mcs value */ +#define NRATE_RATE_MASK 0x0000007f +/* stf mode mask: siso, cdd, stbc, sdm */ +#define NRATE_STF_MASK 0x0000ff00 +/* stf mode shift */ +#define NRATE_STF_SHIFT 8 +/* bit indicates override both rate & mode */ +#define NRATE_OVERRIDE 0x80000000 +/* bit indicate to override mcs only */ +#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 +#define NRATE_SGI_MASK 0x00800000 /* sgi mode */ +#define NRATE_SGI_SHIFT 23 /* sgi mode */ +#define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ +#define NRATE_LDPC_SHIFT 22 /* ldpc shift */ + +#define NRATE_STF_SISO 0 /* stf mode SISO */ +#define NRATE_STF_CDD 1 /* stf mode CDD */ +#define NRATE_STF_STBC 2 /* stf mode STBC */ +#define NRATE_STF_SDM 3 /* stf mode SDM */ + /* * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. */ @@ -3323,7 +3381,7 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, /* fill in hw_rate */ brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, - (bool) N_ENAB(wlc->pub)); + (bool) (wlc->pub->_n_enab & SUPPORT_11N)); /* init basic rate lookup */ brcms_c_rate_lookup_init(wlc, &default_rateset); @@ -3608,14 +3666,14 @@ void brcms_c_mac_promisc(struct brcms_c_info *wlc) * the MCTL_PROMISC bit since all BSS data traffic is * directed at the AP */ - if (PROMISC_ENAB(wlc->pub)) + if (wlc->pub->promisc) promisc_bits |= MCTL_PROMISC; /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL * Note: monitor mode also needs MCTL_BCNS_PROMISC, but that is * handled in brcms_c_mac_bcn_promisc() */ - if (MONITOR_ENAB(wlc)) + if (wlc->monitor) promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; brcms_c_mctrl(wlc, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); @@ -4925,10 +4983,10 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) /* init bss rates to the band specific default rate set */ brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, band->bandtype, false, BRCMS_RATE_MASK_FULL, - (bool) N_ENAB(wlc->pub), CHSPEC_WLC_BW(chanspec), - wlc->stf->txstreams); + (bool) (wlc->pub->_n_enab & SUPPORT_11N), + CHSPEC_WLC_BW(chanspec), wlc->stf->txstreams); - if (N_ENAB(wlc->pub)) + if (wlc->pub->_n_enab & SUPPORT_11N) bi->flags |= BRCMS_BSS_HT; } @@ -5139,7 +5197,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, brcms_c_rateset_filter(&wlc->band->defrateset, &wlc->band->hw_rateset, false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, - (bool) N_ENAB(wlc->pub)); + (bool) (wlc->pub->_n_enab & SUPPORT_11N)); } /* @@ -5194,8 +5252,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->mimoft = FT_HT; wlc->ht_cap.cap_info = HT_CAP; - if (HT_ENAB(wlc->pub)) - wlc->stf->ldpc = AUTO; wlc->mimo_40txbw = AUTO; wlc->ofdm_40txbw = AUTO; @@ -5843,7 +5899,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) /* if N-support is enabled, allow Gmode set as long as requested * Gmode is not GMODE_LEGACY_B */ - if (N_ENAB(wlc->pub) && gmode == GMODE_LEGACY_B) + if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) return -ENOTSUPP; /* verify that we are dealing with 2G band and grab the band pointer */ @@ -6269,7 +6325,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, memcpy(&rs.rates, &in_rs->rates, rs.count); /* merge rateset coming in with the current mcsset */ - if (N_ENAB(wlc->pub)) { + if (wlc->pub->_n_enab & SUPPORT_11N) { struct brcms_bss_info *mcsset_bss; if (bsscfg->associated) mcsset_bss = current_bss; @@ -6957,7 +7013,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, return (u32) rate; /* validate the combination of rate/mcs/stf is allowed */ - if (N_ENAB(wlc->pub) && ismcs) { + if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { /* mcs only allowed when nmode */ if (stf > PHY_TXC1_MODE_SDM) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", @@ -7223,7 +7279,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, phyctl1_stf = wlc->stf->ss_opmode; - if (N_ENAB(wlc->pub)) { + if (wlc->pub->_n_enab & SUPPORT_11N) { for (k = 0; k < hw->max_rates; k++) { /* * apply siso/cdd to single stream mcs's or ofdm @@ -9287,7 +9343,7 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) { brcms_c_rateset_default(rs, NULL, wlc->band->phytype, wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, - (bool) N_ENAB(wlc->pub), + (bool) (wlc->pub->_n_enab & SUPPORT_11N), CHSPEC_WLC_BW(wlc->default_bss->chanspec), wlc->stf->txstreams); } diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index a56239a763c..f623d6e83e0 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -293,22 +293,10 @@ enum wlc_par_id { #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) /* WL11N Support */ -#define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N) -#define N_REQD(pub) ((pub)->_n_reqd) - -#define HT_ENAB(pub) 0 - #define AMPDU_AGG_HOST 1 -#define AMPDU_ENAB(pub) ((pub)->_ampdu) -#define EDCF_ENAB(pub) (WME_ENAB(pub)) -#define QOS_ENAB(pub) (WME_ENAB(pub) || N_ENAB(pub)) - -#define MONITOR_ENAB(wlc) ((wlc)->monitor) - -#define PROMISC_ENAB(wlc) ((wlc)->promisc) - -#define BRCMS_PREC_COUNT 16 /* Max precedence level implemented */ +#define EDCF_ENAB(pub) ((pub)->_wme != OFF) +#define QOS_ENAB(pub) ((pub)->_wme != OFF || (pub)->_n_enab & SUPPORT_11N) /* pri is priority encoded in the packet. This maps the Packet priority to * enqueue precedence as defined in wlc_prec_map @@ -316,6 +304,11 @@ enum wlc_par_id { extern const u8 wlc_prio2prec_map[]; #define BRCMS_PRIO_TO_PREC(pri) wlc_prio2prec_map[(pri) & 7] +#define BRCMS_PREC_COUNT 16 /* Max precedence level implemented */ + +/* Mask to describe all precedence levels */ +#define BRCMS_PREC_BMP_ALL MAXBITVAL(BRCMS_PREC_COUNT) + /* * This maps priority to one precedence higher - Used by PS-Poll response * packets to simulate enqueue-at-head operation, but still maintain the @@ -324,12 +317,6 @@ extern const u8 wlc_prio2prec_map[]; #define BRCMS_PRIO_TO_HI_PREC(pri) min(BRCMS_PRIO_TO_PREC(pri) + 1,\ BRCMS_PREC_COUNT - 1) -extern const u8 wme_fifo2ac[]; -#define WME_PRIO2AC(prio) wme_fifo2ac[prio2fifo[(prio)]] - -/* Mask to describe all precedence levels */ -#define BRCMS_PREC_BMP_ALL MAXBITVAL(BRCMS_PREC_COUNT) - /* Define a bitmap of precedences comprised by each AC */ #define BRCMS_PREC_BMP_AC_BE (NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_BE)) | \ NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_BE)) | \ @@ -348,14 +335,6 @@ extern const u8 wme_fifo2ac[]; NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_NC)) | \ NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_NC))) -/* WME Support */ -#define WME_ENAB(pub) ((pub)->_wme != OFF) -#define WME_AUTO(wlc) ((wlc)->pub->_wme == AUTO) - -/* invalid core flags, use the saved coreflags */ -#define BRCMS_USE_COREFLAGS 0xffffffff - - /* network protection config */ #define BRCMS_PROT_G_SPEC 1 /* SPEC g protection */ #define BRCMS_PROT_G_OVR 2 /* SPEC g prot override */ @@ -409,67 +388,18 @@ extern const u8 wme_fifo2ac[]; #define GMODE_LRS 5 #define GMODE_MAX 6 -/* values for PLCPHdr_override */ -#define BRCMS_PLCP_AUTO -1 -#define BRCMS_PLCP_SHORT 0 -#define BRCMS_PLCP_LONG 1 +/* MCS values greater than this enable multiple streams */ +#define HIGHEST_SINGLE_STREAM_MCS 7 -/* values for g_protection_override and n_protection_override */ -#define BRCMS_PROTECTION_AUTO -1 -#define BRCMS_PROTECTION_OFF 0 -#define BRCMS_PROTECTION_ON 1 -#define BRCMS_PROTECTION_MMHDR_ONLY 2 -#define BRCMS_PROTECTION_CTS_ONLY 3 +#define MAXBANDS 2 /* Maximum #of bands */ -/* values for g_protection_control and n_protection_control */ -#define BRCMS_PROTECTION_CTL_OFF 0 -#define BRCMS_PROTECTION_CTL_LOCAL 1 -#define BRCMS_PROTECTION_CTL_OVERLAP 2 - -/* values for n_protection */ -#define BRCMS_N_PROTECTION_OFF 0 -#define BRCMS_N_PROTECTION_OPTIONAL 1 -#define BRCMS_N_PROTECTION_20IN40 2 -#define BRCMS_N_PROTECTION_MIXEDMODE 3 - -/* values for band specific 40MHz capabilities */ -#define BRCMS_N_BW_20ALL 0 -#define BRCMS_N_BW_40ALL 1 -#define BRCMS_N_BW_20IN2G_40IN5G 2 - -/* bitflags for SGI support (sgi_rx iovar) */ -#define BRCMS_N_SGI_20 0x01 -#define BRCMS_N_SGI_40 0x02 - -/* defines used by the nrate iovar */ -/* MSC in use,indicates b0-6 holds an mcs */ -#define NRATE_MCS_INUSE 0x00000080 -/* rate/mcs value */ -#define NRATE_RATE_MASK 0x0000007f -/* stf mode mask: siso, cdd, stbc, sdm */ -#define NRATE_STF_MASK 0x0000ff00 -/* stf mode shift */ -#define NRATE_STF_SHIFT 8 -/* bit indicates override both rate & mode */ -#define NRATE_OVERRIDE 0x80000000 -/* bit indicate to override mcs only */ -#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 -#define NRATE_SGI_MASK 0x00800000 /* sgi mode */ -#define NRATE_SGI_SHIFT 23 /* sgi mode */ -#define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ -#define NRATE_LDPC_SHIFT 22 /* ldpc shift */ - -#define NRATE_STF_SISO 0 /* stf mode SISO */ -#define NRATE_STF_CDD 1 /* stf mode CDD */ -#define NRATE_STF_STBC 2 /* stf mode STBC */ -#define NRATE_STF_SDM 3 /* stf mode SDM */ +/* bandstate array indices */ +#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ +#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ /* max number of antenna configurations */ #define ANT_SELCFG_MAX 4 -/* MCS values greater than this enable multiple streams */ -#define HIGHEST_SINGLE_STREAM_MCS 7 - struct brcms_antselcfg { u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */ u8 num_antcfg; /* number of available antenna configurations */ @@ -559,12 +489,4 @@ extern void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); extern bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc); -#define MAXBANDS 2 /* Maximum #of bands */ -/* bandstate array indices */ -#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ -#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ - -#define BAND_2G_NAME "2.4G" -#define BAND_5G_NAME "5G" - #endif /* _BRCM_PUB_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index efa50471661..3fe9cf20260 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -75,11 +75,11 @@ struct scb { }; /* scb flags */ -#define SCB_WMECAP 0x0040 /* may ONLY be set if WME_ENAB(wlc) */ +#define SCB_WMECAP 0x0040 /* may ONLY be set if pub->_wme!=OFF */ #define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */ #define SCB_IS40 0x80000 /* 40MHz capable */ #define SCB_STBCCAP 0x40000000 /* STBC Capable */ -#define SCB_WME(a) ((a)->flags & SCB_WMECAP)/* implies WME_ENAB */ +#define SCB_WME(a) ((a)->flags & SCB_WMECAP)/* implies WME enab */ #define SCB_SEQNUM(scb, prio) ((scb)->seqnum[(prio)]) #define SCB_PS(a) NULL #define SCB_STBC_CAP(a) ((a)->flags & SCB_STBCCAP) From 94dde6f46df0ab242875d14be9f454b414f1c0fe Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 2 Sep 2011 16:00:38 +0200 Subject: [PATCH 0879/1519] staging: brcm80211: cleaned up softmac scb.h macro's Substituted/removed macro's. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 8 ++++---- drivers/staging/brcm80211/brcmsmac/main.h | 3 ++- drivers/staging/brcm80211/brcmsmac/rate.h | 16 --------------- drivers/staging/brcm80211/brcmsmac/scb.h | 24 ++++++++++------------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 4436b4fcdb6..6d2fc10318a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -7196,11 +7196,11 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } else { /* Increment the counter for first fragment */ if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) - SCB_SEQNUM(scb, p->priority)++; + scb->seqnum[p->priority]++; /* extract fragment number from frame first */ seq = le16_to_cpu(seq) & FRAGNUM_MASK; - seq |= (SCB_SEQNUM(scb, p->priority) << SEQNUM_SHIFT); + seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); h->seq_ctrl = cpu_to_le16(seq); frameid = ((seq << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) | @@ -7210,7 +7210,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, frameid |= queue & TXFID_QUEUE_MASK; /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */ - if (SCB_PS(scb) || ieee80211_is_beacon(h->frame_control)) + if (ieee80211_is_beacon(h->frame_control)) mcl |= TXC_IGNOREPMQ; txrate[0] = tx_info->control.rates; @@ -7685,7 +7685,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, } ac = skb_get_queue_mapping(p); - if (SCB_WME(scb) && qos && wlc->edcf_txop[ac]) { + if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { uint frag_dur, dur, dur_fallback; /* WME: Update TXOP threshold */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 047c422174d..a0dcacc8ec4 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -221,7 +221,8 @@ struct brcms_stf { #define BRCMS_STF_SS_STBC_TX(wlc, scb) \ (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \ - || (SCB_STBC_CAP((scb)) && (wlc)->band->band_stf_stbc_tx == AUTO && \ + || (((scb)->flags & SCB_STBCCAP) && \ + (wlc)->band->band_stf_stbc_tx == AUTO && \ isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC)))) #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \ diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index 39e1796e924..ae5479b4609 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -123,22 +123,6 @@ extern const struct brcms_mcs_info mcs_table[]; RSPEC_ISSGI(rspec)) : \ (rspec & RSPEC_RATE_MASK)) -/* return rate in unit of 500Kbps -- for internal use in wlc_rate_sel.c */ -#define RSPEC2RATE500K(rspec) \ - ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), state->is40bw, \ - RSPEC_ISSGI(rspec))/500 : \ - (rspec & RSPEC_RATE_MASK)) - -#define CRSPEC2RATE500K(rspec) \ - ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), \ - RSPEC_ISSGI(rspec))/500 :\ - (rspec & RSPEC_RATE_MASK)) - -#define RSPEC2KBPS(rspec) \ - (IS_MCS(rspec) ? RSPEC2RATE(rspec) : RSPEC2RATE(rspec)*500) - #define RSPEC_PHYTXBYTE2(rspec) ((rspec & 0xff00) >> 8) #define RSPEC_GET_BW(rspec) ((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index 3fe9cf20260..b2aacf3bf3f 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -24,6 +24,16 @@ #define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */ +#define AMPDU_MAX_SCB_TID NUMPRIO + +/* scb flags */ +#define SCB_WMECAP 0x0040 /* may ONLY be set if pub->_wme!=OFF */ +#define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */ +#define SCB_IS40 0x80000 /* 40MHz capable */ +#define SCB_STBCCAP 0x40000000 /* STBC Capable */ + +#define SCB_MAGIC 0xbeefcafe + /* structure to store per-tid state for the ampdu initiator */ struct scb_ampdu_tid_ini { u8 tx_in_transit; /* number of pending mpdus in transit in driver */ @@ -34,8 +44,6 @@ struct scb_ampdu_tid_ini { u8 ba_wsize; /* negotiated ba window size (in pdu) */ }; -#define AMPDU_MAX_SCB_TID NUMPRIO - struct scb_ampdu { struct scb *scb; /* back pointer for easy reference */ u8 mpdu_density; /* mpdu density */ @@ -54,8 +62,6 @@ struct scb_ampdu { struct scb_ampdu_tid_ini ini[AMPDU_MAX_SCB_TID]; }; -#define SCB_MAGIC 0xbeefcafe - /* station control block - one per remote MAC address */ struct scb { u32 magic; @@ -74,14 +80,4 @@ struct scb { struct scb_ampdu scb_ampdu; /* AMPDU state including per tid info */ }; -/* scb flags */ -#define SCB_WMECAP 0x0040 /* may ONLY be set if pub->_wme!=OFF */ -#define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */ -#define SCB_IS40 0x80000 /* 40MHz capable */ -#define SCB_STBCCAP 0x40000000 /* STBC Capable */ -#define SCB_WME(a) ((a)->flags & SCB_WMECAP)/* implies WME enab */ -#define SCB_SEQNUM(scb, prio) ((scb)->seqnum[(prio)]) -#define SCB_PS(a) NULL -#define SCB_STBC_CAP(a) ((a)->flags & SCB_STBCCAP) -#define SCB_AMPDU(a) true #endif /* _BRCM_SCB_H_ */ From 17966e3bb8a3a0d883f4893e515c174ac5980413 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 5 Sep 2011 10:47:35 +0200 Subject: [PATCH 0880/1519] staging: brcm80211: cleaned up softmac srom macro Substituted macro. Reported-by: Johannes Berg Reported-by: Joe Perches Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/srom.c | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index c8f6897cb37..5bf07328cea 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -28,18 +28,6 @@ #include "otp.h" #include "srom.h" -#define SROM_OFFSET(sih) ((sih->ccrev > 31) ? \ - (((sih->cccaps & CC_CAP_SROM) == 0) ? NULL : \ - ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) : \ - ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET)) - -#if defined(BCMDBG) -/* 500 ms after write enable/disable toggle */ -#define WRITE_ENABLE_DELAY 500 -/* 20 ms between each word write */ -#define WRITE_WORD_DELAY 20 -#endif - /* * SROM CRC8 polynomial value: * @@ -792,6 +780,16 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { static u8 srom_crc8_table[CRC8_TABLE_SIZE]; +static u16 *srom_window_address(struct si_pub *sih, u8 *curmap) +{ + if (sih->ccrev < 32) + return (u16 *)(curmap + PCI_BAR0_SPROM_OFFSET); + if (sih->cccaps & CC_CAP_SROM) + return (u16 *)(curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); + + return NULL; +} + /* Parse SROM and create name=value pairs. 'srom' points to * the SROM word array. 'off' specifies the offset of the * first word 'srom' points to, which should be either 0 or @@ -1147,7 +1145,7 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, if (!srom) return -ENOMEM; - sromwindow = (u16 *) SROM_OFFSET(sih); + sromwindow = srom_window_address(sih, curmap); crc8_populate_lsb(srom_crc8_table, SROM_CRC8_POLY); if (ai_is_sprom_available(sih)) { From 303dfbf5727410bfa3e82d4e2554813f1e8f2de6 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Wed, 31 Aug 2011 00:41:14 +0400 Subject: [PATCH 0881/1519] staging: mei: unlock dev->device_lock mutex on error path in mei_open() mei_open() acquires dev->device_lock mutex and try to allocate mei_cl, but if the allocation fails it goes to return statement. As a result dev->device_lock left locked. The patch fixes goto to unlock dev->device_lock mutex on this path. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index 8d7678569e7..78028f8c0b8 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -413,7 +413,7 @@ static int mei_open(struct inode *inode, struct file *file) err = -ENOMEM; cl = mei_cl_allocate(dev); if (!cl) - goto out; + goto out_unlock; err = -ENODEV; if (dev->mei_state != MEI_ENABLED) { From f6807514910f2d3c9d19e2cdd369a31aade73e6f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 30 Aug 2011 12:47:22 +0100 Subject: [PATCH 0882/1519] staging: et131x: converting et131x_ioctl to use phy_mii_ioctl Handing over ioctls handled by the driver to the phydev. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_netdev.c | 56 ++------------------------ 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index ce214339739..d12e05ec3b8 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -207,47 +207,6 @@ int et131x_close(struct net_device *netdev) return 0; } -/** - * et131x_ioctl_mii - The function which handles MII IOCTLs - * @netdev: device on which the query is being made - * @reqbuf: the request-specific data buffer - * @cmd: the command request code - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) -{ - int status = 0; - struct et131x_adapter *adapter = netdev_priv(netdev); - struct mii_ioctl_data *data = if_mii(reqbuf); - - switch (cmd) { - case SIOCGMIIPHY: - data->phy_id = adapter->stats.xcvr_addr; - break; - - case SIOCGMIIREG: - if (!capable(CAP_NET_ADMIN)) - status = -EPERM; - else - status = et131x_mii_read(adapter, - data->reg_num, &data->val_out); - break; - - case SIOCSMIIREG: - if (!capable(CAP_NET_ADMIN)) - status = -EPERM; - else - status = et131x_mii_write(adapter, data->reg_num, - data->val_in); - break; - - default: - status = -EOPNOTSUPP; - } - return status; -} - /** * et131x_ioctl - The I/O Control handler for the driver * @netdev: device on which the control request is being made @@ -258,19 +217,12 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd) */ int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) { - int status = 0; + struct et131x_adapter *adapter = netdev_priv(netdev); - switch (cmd) { - case SIOCGMIIPHY: - case SIOCGMIIREG: - case SIOCSMIIREG: - status = et131x_ioctl_mii(netdev, reqbuf, cmd); - break; + if (!adapter->phydev) + return -EINVAL; - default: - status = -EOPNOTSUPP; - } - return status; + return phy_mii_ioctl(adapter->phydev, reqbuf, cmd); } /** From f660732fdcf2b7eaf3ebfd9f7b6bc921837536f5 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 30 Aug 2011 12:47:23 +0100 Subject: [PATCH 0883/1519] staging: et131x: Remove xcvr_addr and et131x_xcvr_find Use the phy_device equivalents instead. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 72 ++++++++++--------------- drivers/staging/et131x/et131x.h | 17 +++--- drivers/staging/et131x/et131x_adapter.h | 3 -- drivers/staging/et131x/et131x_initpci.c | 15 +----- 4 files changed, 38 insertions(+), 69 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 5e21a180af9..961384610d6 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -114,7 +114,6 @@ int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value) struct net_device *netdev = bus->priv; struct et131x_adapter *adapter = netdev_priv(netdev); - /* mii_write always uses the same phy_addr, xcvr_addr */ return et131x_mii_write(adapter, reg, value); } @@ -128,17 +127,28 @@ int et131x_mdio_reset(struct mii_bus *bus) return 0; } + +int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) +{ + struct phy_device *phydev = adapter->phydev; + + if(!phydev) + return -EIO; + + return et131x_phy_mii_read(adapter, phydev->addr, reg, value); +} + /** * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC * @adapter: pointer to our private adapter structure - * @xcvr_addr: the address of the transceiver - * @xcvr_reg: the register to read + * @addr: the address of the transceiver + * @reg: the register to read * @value: pointer to a 16-bit value in which the value will be stored * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, - u8 xcvr_reg, u16 *value) +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, + u8 reg, u16 *value) { struct mac_regs __iomem *mac = &adapter->regs->mac; int status = 0; @@ -157,7 +167,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to read from on the correct PHY */ - writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); writel(0x1, &mac->mii_mgmt_cmd); @@ -170,7 +180,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, /* If we hit the max delay, we could not read the register */ if (delay == 50) { dev_warn(&adapter->pdev->dev, - "xcvrReg 0x%08x could not be read\n", xcvr_reg); + "reg 0x%08x could not be read\n", reg); dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", mii_indicator); @@ -196,23 +206,29 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, /** * et131x_mii_write - Write to a PHY register through the MII interface of the MAC * @adapter: pointer to our private adapter structure - * @xcvr_reg: the register to read + * @reg: the register to read * @value: 16-bit value to write * * FIXME: one caller in netdev still * * Return 0 on success, errno on failure (as defined in errno.h) */ -int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) +int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) { struct mac_regs __iomem *mac = &adapter->regs->mac; + struct phy_device *phydev = adapter->phydev; int status = 0; - u8 xcvr_addr = adapter->stats.xcvr_addr; + u8 addr; u32 delay = 0; u32 mii_addr; u32 mii_cmd; u32 mii_indicator; + if(!phydev) + return -EIO; + + addr = phydev->addr; + /* Save a local copy of the registers we are dealing with so we can * set them back */ @@ -223,7 +239,7 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to write to on the correct PHY */ - writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); /* Add the value to write to the registers to the mac */ writel(value, &mac->mii_mgmt_ctrl); @@ -239,13 +255,13 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) u16 tmp; dev_warn(&adapter->pdev->dev, - "xcvrReg 0x%08x could not be written", xcvr_reg); + "reg 0x%08x could not be written", reg); dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", mii_indicator); dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", readl(&mac->mii_mgmt_cmd)); - et131x_mii_read(adapter, xcvr_reg, &tmp); + et131x_mii_read(adapter, reg, &tmp); status = -EIO; } @@ -262,36 +278,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) return status; } -/** - * et131x_xcvr_find - Find the PHY ID - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_xcvr_find(struct et131x_adapter *adapter) -{ - u8 xcvr_addr; - u16 idr1; - u16 idr2; - - /* We need to get xcvr id and address we just get the first one */ - for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) { - /* Read the ID from the PHY */ - et131x_phy_mii_read(adapter, xcvr_addr, - (u8) offsetof(struct mi_regs, idr1), - &idr1); - et131x_phy_mii_read(adapter, xcvr_addr, - (u8) offsetof(struct mi_regs, idr2), - &idr2); - - if (idr1 != 0 && idr1 != 0xffff) { - adapter->stats.xcvr_addr = xcvr_addr; - return 0; - } - } - return -ENODEV; -} - void et1310_phy_reset(struct et131x_adapter *adapter) { et131x_mii_write(adapter, PHY_CONTROL, 0x8000); diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 9dee7bce073..763396a9a59 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -59,7 +59,7 @@ void et131x_align_allocated_memory(struct et131x_adapter *adapter, u64 *phys_addr, u64 *offset, u64 mask); -int et131x_adapter_setup(struct et131x_adapter *adapter); +void et131x_adapter_setup(struct et131x_adapter *adapter); int et131x_adapter_memory_alloc(struct et131x_adapter *adapter); void et131x_adapter_memory_free(struct et131x_adapter *adapter); void et131x_hwaddr_init(struct et131x_adapter *adapter); @@ -104,16 +104,13 @@ void et131x_setphy_normal(struct et131x_adapter *adapter); /* static inline function does not work because et131x_adapter is not always * defined */ -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvrAddr, - u8 xcvrReg, u16 *value); -#define et131x_mii_read(adapter, xcvrReg, value) \ - et131x_phy_mii_read((adapter), \ - (adapter)->stats.xcvr_addr, \ - (xcvrReg), (value)) - +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, + u8 reg, u16 *value); +int32_t et131x_mii_read(struct et131x_adapter *adapter, + u8 reg, u16 *value); int32_t et131x_mii_write(struct et131x_adapter *adapter, - u8 xcvReg, u16 value); -void et131x_mii_check(struct et131x_adapter *pAdapter, + u8 reg, u16 value); +void et131x_mii_check(struct et131x_adapter *adapter, u16 bmsr, u16 bmsr_ints); int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg); diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index dbb14fed2dd..fbefd2e88d8 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -113,9 +113,6 @@ struct ce_stats { atomic_t broadcast_pkts_xmtd; u32 rcvd_pkts_dropped; - /* Transceiver state informations. */ - u8 xcvr_addr; - /* Tx Statistics. */ u32 tx_underflows; diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index fbbef7627bc..66cf1ce296e 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -328,10 +328,8 @@ void et131x_configure_global_regs(struct et131x_adapter *adapter) * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_adapter_setup(struct et131x_adapter *adapter) +void et131x_adapter_setup(struct et131x_adapter *adapter) { - int status; - /* Configure the JAGCore */ et131x_configure_global_regs(adapter); @@ -349,12 +347,6 @@ int et131x_adapter_setup(struct et131x_adapter *adapter) et1310_config_macstat_regs(adapter); - /* Move the following code to Timer function?? */ - status = et131x_xcvr_find(adapter); - - if (status) - dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n"); - /* Prepare the TRUEPHY library. */ et1310_phy_init(adapter); @@ -377,7 +369,6 @@ int et131x_adapter_setup(struct et131x_adapter *adapter) et1310_phy_power_down(adapter, 0); et131x_setphy_normal(adapter); - return status; } /** @@ -493,9 +484,7 @@ static void et131x_adjust_link(struct net_device *netdev) et1310_disable_phy_coma(adapter); } - et131x_mii_read(adapter, - (uint8_t) offsetof(struct mi_regs, bmsr), - &bmsr_data); + et131x_phy_mii_read(adapter, phydev->addr, MII_BMSR, &bmsr_data); bmsr_ints = adapter->bmsr ^ bmsr_data; adapter->bmsr = bmsr_data; From 3cecd9203c211c514ef9022b6d54c06996f71d30 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 30 Aug 2011 12:47:24 +0100 Subject: [PATCH 0884/1519] staging: et131x: Remove redundant phy code Now we are using a phy_device, remove driver functionality that is now handled by the phydev. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 415 +----------------------- drivers/staging/et131x/et1310_pm.c | 15 +- drivers/staging/et131x/et131x.h | 7 +- drivers/staging/et131x/et131x_initpci.c | 30 +- 4 files changed, 15 insertions(+), 452 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 961384610d6..c216bbba4cc 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -122,7 +122,7 @@ int et131x_mdio_reset(struct mii_bus *bus) struct net_device *netdev = bus->priv; struct et131x_adapter *adapter = netdev_priv(netdev); - et1310_phy_reset(adapter); + et131x_mii_write(adapter, PHY_CONTROL, 0x8000); return 0; } @@ -278,11 +278,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) return status; } -void et1310_phy_reset(struct et131x_adapter *adapter) -{ - et131x_mii_write(adapter, PHY_CONTROL, 0x8000); -} - /** * et1310_phy_power_down - PHY power control * @adapter: device to control @@ -304,63 +299,6 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) et131x_mii_write(adapter, PHY_CONTROL, data); } -/** - * et1310_phy_auto_neg - autonegotiate control - * @adapter: device to control - * @enabe: autoneg on/off - * - * Set up the autonegotiation state according to whether we will be - * negotiating the state or forcing a speed. - */ -static void et1310_phy_auto_neg(struct et131x_adapter *adapter, bool enable) -{ - u16 data; - - et131x_mii_read(adapter, PHY_CONTROL, &data); - data &= ~0x1000; /* Autonegotiation OFF */ - if (enable) - data |= 0x1000; /* Autonegotiation ON */ - et131x_mii_write(adapter, PHY_CONTROL, data); -} - -/** - * et1310_phy_duplex_mode - duplex control - * @adapter: device to control - * @duplex: duplex on/off - * - * Set up the duplex state on the PHY - */ -static void et1310_phy_duplex_mode(struct et131x_adapter *adapter, u16 duplex) -{ - u16 data; - - et131x_mii_read(adapter, PHY_CONTROL, &data); - data &= ~0x100; /* Set Half Duplex */ - if (duplex == TRUEPHY_DUPLEX_FULL) - data |= 0x100; /* Set Full Duplex */ - et131x_mii_write(adapter, PHY_CONTROL, data); -} - -/** - * et1310_phy_speed_select - speed control - * @adapter: device to control - * @duplex: duplex on/off - * - * Set the speed of our PHY. - */ -static void et1310_phy_speed_select(struct et131x_adapter *adapter, u16 speed) -{ - u16 data; - static const u16 bits[3] = {0x0000, 0x2000, 0x0040}; - - /* Read the PHY control register */ - et131x_mii_read(adapter, PHY_CONTROL, &data); - /* Clear all Speed settings (Bits 6, 13) */ - data &= ~0x2040; - /* Write back the new speed */ - et131x_mii_write(adapter, PHY_CONTROL, data | bits[speed]); -} - /** * et1310_phy_link_status - read link state * @adapter: device to read @@ -450,122 +388,12 @@ void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, } } -void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter, - u16 duplex) -{ - u16 data; - - /* Read the PHY 1000 Base-T Control Register */ - et131x_mii_read(adapter, PHY_1000_CONTROL, &data); - - /* Clear Bits 8,9 */ - data &= ~0x0300; - - switch (duplex) { - case TRUEPHY_ADV_DUPLEX_NONE: - /* Duplex already cleared, do nothing */ - break; - - case TRUEPHY_ADV_DUPLEX_FULL: - /* Set Bit 9 */ - data |= 0x0200; - break; - - case TRUEPHY_ADV_DUPLEX_HALF: - /* Set Bit 8 */ - data |= 0x0100; - break; - - case TRUEPHY_ADV_DUPLEX_BOTH: - default: - data |= 0x0300; - break; - } - - /* Write back advertisement */ - et131x_mii_write(adapter, PHY_1000_CONTROL, data); -} - -static void et1310_phy_advertise_100BaseT(struct et131x_adapter *adapter, - u16 duplex) -{ - u16 data; - - /* Read the Autonegotiation Register (10/100) */ - et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data); - - /* Clear bits 7,8 */ - data &= ~0x0180; - - switch (duplex) { - case TRUEPHY_ADV_DUPLEX_NONE: - /* Duplex already cleared, do nothing */ - break; - - case TRUEPHY_ADV_DUPLEX_FULL: - /* Set Bit 8 */ - data |= 0x0100; - break; - - case TRUEPHY_ADV_DUPLEX_HALF: - /* Set Bit 7 */ - data |= 0x0080; - break; - - case TRUEPHY_ADV_DUPLEX_BOTH: - default: - /* Set Bits 7,8 */ - data |= 0x0180; - break; - } - - /* Write back advertisement */ - et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data); -} - -static void et1310_phy_advertise_10BaseT(struct et131x_adapter *adapter, - u16 duplex) -{ - u16 data; - - /* Read the Autonegotiation Register (10/100) */ - et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data); - - /* Clear bits 5,6 */ - data &= ~0x0060; - - switch (duplex) { - case TRUEPHY_ADV_DUPLEX_NONE: - /* Duplex already cleared, do nothing */ - break; - - case TRUEPHY_ADV_DUPLEX_FULL: - /* Set Bit 6 */ - data |= 0x0040; - break; - - case TRUEPHY_ADV_DUPLEX_HALF: - /* Set Bit 5 */ - data |= 0x0020; - break; - - case TRUEPHY_ADV_DUPLEX_BOTH: - default: - /* Set Bits 5,6 */ - data |= 0x0060; - break; - } - - /* Write back advertisement */ - et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data); -} - /** * et131x_xcvr_init - Init the phy if we are setting it into force mode * @adapter: pointer to our private adapter structure * */ -static void et131x_xcvr_init(struct et131x_adapter *adapter) +void et131x_xcvr_init(struct et131x_adapter *adapter) { u16 imr; u16 isr; @@ -607,132 +435,6 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter) et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, lcr2), lcr2); } - - /* Determine if we need to go into a force mode and set it */ - if (adapter->ai_force_speed == 0 && adapter->ai_force_duplex == 0) { - if (adapter->wanted_flow == FLOW_TXONLY || - adapter->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_SET, 4, 11, NULL); - else - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_CLEAR, 4, 11, NULL); - - if (adapter->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_SET, 4, 10, NULL); - else - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_CLEAR, 4, 10, NULL); - - /* Set the phy to autonegotiation */ - et1310_phy_auto_neg(adapter, true); - - /* NOTE - Do we need this? */ - et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL); - return; - } - - et1310_phy_auto_neg(adapter, false); - - /* Set to the correct force mode. */ - if (adapter->ai_force_duplex != 1) { - if (adapter->wanted_flow == FLOW_TXONLY || - adapter->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_SET, 4, 11, NULL); - else - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_CLEAR, 4, 11, NULL); - - if (adapter->wanted_flow == FLOW_BOTH) - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_SET, 4, 10, NULL); - else - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_CLEAR, 4, 10, NULL); - } else { - et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, - 4, 10, NULL); - et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR, - 4, 11, NULL); - } - et1310_phy_power_down(adapter, 1); - switch (adapter->ai_force_speed) { - case 10: - /* First we need to turn off all other advertisement */ - et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - if (adapter->ai_force_duplex == 1) { - /* Set our advertise values accordingly */ - et1310_phy_advertise_10BaseT(adapter, - TRUEPHY_ADV_DUPLEX_HALF); - } else if (adapter->ai_force_duplex == 2) { - /* Set our advertise values accordingly */ - et1310_phy_advertise_10BaseT(adapter, - TRUEPHY_ADV_DUPLEX_FULL); - } else { - /* Disable autoneg */ - et1310_phy_auto_neg(adapter, false); - /* Disable rest of the advertisements */ - et1310_phy_advertise_10BaseT(adapter, - TRUEPHY_ADV_DUPLEX_NONE); - /* Force 10 Mbps */ - et1310_phy_speed_select(adapter, TRUEPHY_SPEED_10MBPS); - /* Force Full duplex */ - et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL); - } - break; - case 100: - /* first we need to turn off all other advertisement */ - et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - if (adapter->ai_force_duplex == 1) { - /* Set our advertise values accordingly */ - et1310_phy_advertise_100BaseT(adapter, - TRUEPHY_ADV_DUPLEX_HALF); - /* Set speed */ - et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS); - } else if (adapter->ai_force_duplex == 2) { - /* Set our advertise values accordingly */ - et1310_phy_advertise_100BaseT(adapter, - TRUEPHY_ADV_DUPLEX_FULL); - } else { - /* Disable autoneg */ - et1310_phy_auto_neg(adapter, false); - /* Disable other advertisement */ - et1310_phy_advertise_100BaseT(adapter, - TRUEPHY_ADV_DUPLEX_NONE); - /* Force 100 Mbps */ - et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS); - /* Force Full duplex */ - et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL); - } - break; - case 1000: - /* first we need to turn off all other advertisement */ - et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - /* set our advertise values accordingly */ - et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); - break; - } - et1310_phy_power_down(adapter, 0); -} - -/** - * et131x_setphy_normal - Set PHY for normal operation. - * @adapter: pointer to our private adapter structure - * - * Used by Power Management to force the PHY into 10 Base T half-duplex mode, - * when going to D3 in WOL mode. Also used during initialization to set the - * PHY for normal operation. - */ -void et131x_setphy_normal(struct et131x_adapter *adapter) -{ - /* Make sure the PHY is powered up */ - et1310_phy_power_down(adapter, 0); - et131x_xcvr_init(adapter); } void et131x_mii_check(struct et131x_adapter *adapter, @@ -847,116 +549,3 @@ void et131x_mii_check(struct et131x_adapter *adapter, } } -/* - * The routines which follow provide low-level access to the PHY, and are used - * primarily by the routines above (although there are a few places elsewhere - * in the driver where this level of access is required). - */ -static const u16 config_phy[25][2] = { - /* Reg Value Register */ - /* Addr */ - {0x880B, 0x0926}, /* AfeIfCreg4B1000Msbs */ - {0x880C, 0x0926}, /* AfeIfCreg4B100Msbs */ - {0x880D, 0x0926}, /* AfeIfCreg4B10Msbs */ - - {0x880E, 0xB4D3}, /* AfeIfCreg4B1000Lsbs */ - {0x880F, 0xB4D3}, /* AfeIfCreg4B100Lsbs */ - {0x8810, 0xB4D3}, /* AfeIfCreg4B10Lsbs */ - - {0x8805, 0xB03E}, /* AfeIfCreg3B1000Msbs */ - {0x8806, 0xB03E}, /* AfeIfCreg3B100Msbs */ - {0x8807, 0xFF00}, /* AfeIfCreg3B10Msbs */ - - {0x8808, 0xE090}, /* AfeIfCreg3B1000Lsbs */ - {0x8809, 0xE110}, /* AfeIfCreg3B100Lsbs */ - {0x880A, 0x0000}, /* AfeIfCreg3B10Lsbs */ - - {0x300D, 1}, /* DisableNorm */ - - {0x280C, 0x0180}, /* LinkHoldEnd */ - - {0x1C21, 0x0002}, /* AlphaM */ - - {0x3821, 6}, /* FfeLkgTx0 */ - {0x381D, 1}, /* FfeLkg1g4 */ - {0x381E, 1}, /* FfeLkg1g5 */ - {0x381F, 1}, /* FfeLkg1g6 */ - {0x3820, 1}, /* FfeLkg1g7 */ - - {0x8402, 0x01F0}, /* Btinact */ - {0x800E, 20}, /* LftrainTime */ - {0x800F, 24}, /* DvguardTime */ - {0x8010, 46}, /* IdlguardTime */ - - {0, 0} -}; - -/* condensed version of the phy initialization routine */ -void et1310_phy_init(struct et131x_adapter *adapter) -{ - u16 data, index; - - /* get the identity (again ?) */ - et131x_mii_read(adapter, PHY_ID_1, &data); - et131x_mii_read(adapter, PHY_ID_2, &data); - - /* what does this do/achieve ? */ - /* should read 0002 */ - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0006); - - /* read modem register 0402, should I do something with the return - data ? */ - et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402); - et131x_mii_read(adapter, PHY_DATA_REG, &data); - - /* what does this do/achieve ? */ - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); - - /* get the identity (again ?) */ - et131x_mii_read(adapter, PHY_ID_1, &data); - et131x_mii_read(adapter, PHY_ID_2, &data); - - /* what does this achieve ? */ - /* should read 0002 */ - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0006); - - /* read modem register 0402, should I do something with - the return data? */ - et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402); - et131x_mii_read(adapter, PHY_DATA_REG, &data); - - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); - - /* what does this achieve (should return 0x1040) */ - et131x_mii_read(adapter, PHY_CONTROL, &data); - /* should read 0002 */ - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(adapter, PHY_CONTROL, 0x1840); - - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0007); - - /* here the writing of the array starts.... */ - index = 0; - while (config_phy[index][0] != 0x0000) { - /* write value */ - et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]); - et131x_mii_write(adapter, PHY_DATA_REG, config_phy[index][1]); - - /* read it back */ - et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]); - et131x_mii_read(adapter, PHY_DATA_REG, &data); - - /* do a check on the value read back ? */ - index++; - } - /* here the writing of the array ends... */ - - et131x_mii_read(adapter, PHY_CONTROL, &data); /* 0x1840 */ - /* should read 0007 */ - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data); - et131x_mii_write(adapter, PHY_CONTROL, 0x1040); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002); -} - diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index 5ebf0645c1c..b20d5d627ef 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -116,8 +116,12 @@ void et1310_enable_phy_coma(struct et131x_adapter *adapter) /* Save the GbE PHY speed and duplex modes. Need to restore this * when cable is plugged back in */ - adapter->pdown_speed = adapter->ai_force_speed; - adapter->pdown_duplex = adapter->ai_force_duplex; + /* + * TODO - when PM is re-enabled, check if we need to + * perform a similar task as this - + * adapter->pdown_speed = adapter->ai_force_speed; + * adapter->pdown_duplex = adapter->ai_force_duplex; + */ /* Stop sending packets. */ spin_lock_irqsave(&adapter->send_hw_lock, flags); @@ -153,8 +157,11 @@ void et1310_disable_phy_coma(struct et131x_adapter *adapter) /* Restore the GbE PHY speed and duplex modes; * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY */ - adapter->ai_force_speed = adapter->pdown_speed; - adapter->ai_force_duplex = adapter->pdown_duplex; + /* TODO - when PM is re-enabled, check if we need to + * perform a similar task as this - + * adapter->ai_force_speed = adapter->pdown_speed; + * adapter->ai_force_duplex = adapter->pdown_duplex; + */ /* Re-initialize the send structures */ et131x_init_send(adapter); diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 763396a9a59..f52fa182987 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -89,17 +89,12 @@ void et1310_enable_phy_coma(struct et131x_adapter *adapter); void et1310_disable_phy_coma(struct et131x_adapter *adapter); /* et1310_phy.c */ -void et1310_phy_init(struct et131x_adapter *adapter); -void et1310_phy_reset(struct et131x_adapter *adapter); void et1310_phy_power_down(struct et131x_adapter *adapter, bool down); -void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter, - u16 duplex); void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, u16 regnum, u16 bitnum, u8 *value); -int et131x_xcvr_find(struct et131x_adapter *adapter); -void et131x_setphy_normal(struct et131x_adapter *adapter); +void et131x_xcvr_init(struct et131x_adapter *adapter); /* static inline function does not work because et131x_adapter is not always * defined diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 66cf1ce296e..6ffebfadcf9 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -137,7 +137,6 @@ void et131x_hwaddr_init(struct et131x_adapter *adapter) } } - /** * et131x_pci_init - initial PCI setup * @adapter: pointer to our private adapter structure @@ -146,7 +145,6 @@ void et131x_hwaddr_init(struct et131x_adapter *adapter) * Perform the initial setup of PCI registers and if possible initialise * the MAC address. At this point the I/O registers have yet to be mapped */ - static int et131x_pci_init(struct et131x_adapter *adapter, struct pci_dev *pdev) { @@ -347,28 +345,8 @@ void et131x_adapter_setup(struct et131x_adapter *adapter) et1310_config_macstat_regs(adapter); - /* Prepare the TRUEPHY library. */ - et1310_phy_init(adapter); - - /* Reset the phy now so changes take place */ - et1310_phy_reset(adapter); - - /* Power down PHY */ - et1310_phy_power_down(adapter, 1); - - /* - * We need to turn off 1000 base half dulplex, the mac does not - * support it. For the 10/100 part, turn off all gig advertisement - */ - if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) - et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL); - else - et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE); - - /* Power up PHY */ et1310_phy_power_down(adapter, 0); - - et131x_setphy_normal(adapter); + et131x_xcvr_init(adapter); } /** @@ -547,8 +525,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, struct pci_dev *pdev) { static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 }; - static const u8 duplex[] = { 0, 1, 2, 1, 2, 2 }; - static const u16 speed[] = { 0, 10, 10, 100, 100, 1000 }; struct et131x_adapter *adapter; @@ -571,15 +547,11 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, spin_lock_init(&adapter->fbr_lock); spin_lock_init(&adapter->phy_lock); - adapter->speed_duplex = 0; /* Auto Speed Auto Duplex */ adapter->registry_jumbo_packet = 1514; /* 1514-9216 */ /* Set the MAC address to a default */ memcpy(adapter->addr, default_mac, ETH_ALEN); - adapter->ai_force_speed = speed[adapter->speed_duplex]; - adapter->ai_force_duplex = duplex[adapter->speed_duplex]; /* Auto FDX */ - return adapter; } From 129957069e6af42a6e021d90679c56662c95f7e1 Mon Sep 17 00:00:00 2001 From: Pelle Windestam Date: Tue, 30 Aug 2011 20:29:24 +0200 Subject: [PATCH 0885/1519] staging: panel: Fixed checkpatch warning about simple_strtoul() Fixed the checkpatch warning about sing simple_strtoul instead of kstrtoul() in panel.c. Signed-off-by: Pelle Windestam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index b303b7e42b6..4683d5f355c 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1179,16 +1179,14 @@ static inline int handle_lcd_special_code(void) break; while (*esc) { - char *endp; - if (*esc == 'x') { esc++; - lcd_addr_x = simple_strtoul(esc, &endp, 10); - esc = endp; + if (kstrtoul(esc, 10, &lcd_addr_x) < 0) + break; } else if (*esc == 'y') { esc++; - lcd_addr_y = simple_strtoul(esc, &endp, 10); - esc = endp; + if (kstrtoul(esc, 10, &lcd_addr_y) < 0) + break; } else break; } From f19885fadfdb0bf410b5e31c7dc2f2be7815e454 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Wed, 31 Aug 2011 01:57:10 +0400 Subject: [PATCH 0886/1519] staging: sep: call to sep_ioctl() may leave driver in unusable state If sep_ioctl() is called from a process that does not own current transaction, it unlocks unheld sep->ioctl_mutex and returns -EACCES leaving sep->sep_mutex acquired. The patch fixes the mutex lock-unlock mismatch. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sep/sep_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c index bf7286e01a3..8ac3faea2d2 100644 --- a/drivers/staging/sep/sep_driver.c +++ b/drivers/staging/sep/sep_driver.c @@ -2420,11 +2420,12 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) (sep->pid_doing_transaction != 0)) { dev_dbg(&sep->pdev->dev, "ioctl pid is not owner\n"); error = -EACCES; - goto end_function; } - mutex_unlock(&sep->sep_mutex); + if (error) + return error; + if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) return -ENOTTY; @@ -2461,7 +2462,6 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) break; } -end_function: mutex_unlock(&sep->ioctl_mutex); return error; } From ce92b7ad6c718b1e228e83137af87ed8c558d358 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 31 Aug 2011 15:31:01 +0200 Subject: [PATCH 0887/1519] staging/cxt1e1: Header cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove dead and unused code in sbecom_inline_linux.h. This also fixes a build failure under Turkish locale, where include/config/modversions.h is incorrectly named as modversIons.h (an unrelated kbuild bug) and the driver tries to needlessly include the empty file. Reported-by: Serdar KÖYLÃœ Cc: Bob Beers Signed-off-by: Michal Marek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/sbecom_inline_linux.h | 64 -------------------- 1 file changed, 64 deletions(-) diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h b/drivers/staging/cxt1e1/sbecom_inline_linux.h index c0563e68997..9ea2c0c2061 100644 --- a/drivers/staging/cxt1e1/sbecom_inline_linux.h +++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h @@ -43,81 +43,17 @@ */ -#if defined (__FreeBSD__) || defined (__NetBSD__) -#include -#else #include -#if defined(CONFIG_SMP) && ! defined(__SMP__) -#define __SMP__ -#endif -#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && ! defined(MODVERSIONS) -#define MODVERSIONS -#endif - -#ifdef MODULE -#ifdef MODVERSIONS -#include -#endif #include -#endif -#endif - #include /* resolves kmalloc references */ #include /* resolves skb references */ #include /* resolves dev_kree_skb_any */ #include /* resolves cpu_to_le32 */ -#if 0 - -/*** PORT POINT WARNING - *** - *** Under Linux 2.6 it has been found that compiler is re-ordering - *** in-lined pci_write_32() functions to the detrement of correct - *** hardware setup. Therefore, inlining of PCI accesses has been - *** de-implemented, and subroutine calls have been implemented. - ***/ - -static inline u_int32_t -pci_read_32 (u_int32_t *p) -{ -#ifdef FLOW_DEBUG - u_int32_t v; - - FLUSH_PCI_READ (); - v = le32_to_cpu (*p); - if (cxt1e1_log_level >= LOG_DEBUG) - pr_info("pci_read : %x = %x\n", (u_int32_t) p, v); - return v; -#else - FLUSH_PCI_READ (); /* */ - return le32_to_cpu (*p); -#endif -} - -static inline void -pci_write_32 (u_int32_t *p, u_int32_t v) -{ -#ifdef FLOW_DEBUG - if (cxt1e1_log_level >= LOG_DEBUG) - pr_info("pci_write: %x = %x\n", (u_int32_t) p, v); -#endif - *p = cpu_to_le32 (v); - FLUSH_PCI_WRITE (); /* This routine is called from routines - * which do multiple register writes - * which themselves need flushing between - * writes in order to guarantee write - * ordering. It is less code-cumbersome - * to flush here-in then to investigate - * and code the many other register - * writing routines. */ -} -#else /* forward reference */ u_int32_t pci_read_32 (u_int32_t *p); void pci_write_32 (u_int32_t *p, u_int32_t v); -#endif - /* * system dependent callbacks From e451d7b22013a95c725e581fd83da0d9c6d79445 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Wed, 31 Aug 2011 17:46:41 +0100 Subject: [PATCH 0888/1519] staging: et131x: Use MII register defines from mii.h Use defines from include/linux/mii.h instead of et131x_phy.h and delete the latter defines. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 22 ++-- drivers/staging/et131x/et1310_phy.h | 160 ------------------------ drivers/staging/et131x/et131x_initpci.c | 4 +- 3 files changed, 13 insertions(+), 173 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index c216bbba4cc..fedde6b2f1e 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -122,7 +122,7 @@ int et131x_mdio_reset(struct mii_bus *bus) struct net_device *netdev = bus->priv; struct et131x_adapter *adapter = netdev_priv(netdev); - et131x_mii_write(adapter, PHY_CONTROL, 0x8000); + et131x_mii_write(adapter, MII_BMCR, 0x8000); return 0; } @@ -292,11 +292,11 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) { u16 data; - et131x_mii_read(adapter, PHY_CONTROL, &data); + et131x_mii_read(adapter, MII_BMCR, &data); data &= ~0x0800; /* Power UP */ if (down) /* Power DOWN */ data |= 0x0800; - et131x_mii_write(adapter, PHY_CONTROL, data); + et131x_mii_write(adapter, MII_BMCR, data); } /** @@ -328,10 +328,10 @@ static void et1310_phy_link_status(struct et131x_adapter *adapter, u16 vmi_phystatus = 0; u16 control = 0; - et131x_mii_read(adapter, PHY_STATUS, &mistatus); - et131x_mii_read(adapter, PHY_1000_STATUS, &is1000BaseT); + et131x_mii_read(adapter, MII_BMSR, &mistatus); + et131x_mii_read(adapter, MII_STAT1000, &is1000BaseT); et131x_mii_read(adapter, PHY_PHY_STATUS, &vmi_phystatus); - et131x_mii_read(adapter, PHY_CONTROL, &control); + et131x_mii_read(adapter, MII_BMCR, &control); *link_status = (vmi_phystatus & 0x0040) ? 1 : 0; *autoneg = (control & 0x1000) ? ((vmi_phystatus & 0x0020) ? @@ -448,8 +448,8 @@ void et131x_mii_check(struct et131x_adapter *adapter, u32 masterslave; u32 polarity; - if (bmsr_ints & MI_BMSR_LINK_STATUS) { - if (bmsr & MI_BMSR_LINK_STATUS) { + if (bmsr_ints & BMSR_LSTATUS) { + if (bmsr & BMSR_LSTATUS) { adapter->boot_coma = 20; netif_carrier_on(adapter->netdev); } else { @@ -505,9 +505,9 @@ void et131x_mii_check(struct et131x_adapter *adapter, } } - if ((bmsr_ints & MI_BMSR_AUTO_NEG_COMPLETE) || - (adapter->ai_force_duplex == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) { - if ((bmsr & MI_BMSR_AUTO_NEG_COMPLETE) || + if ((bmsr_ints & BMSR_ANEGCOMPLETE) || + (adapter->ai_force_duplex == 3 && (bmsr_ints & BMSR_LSTATUS))) { + if ((bmsr & BMSR_ANEGCOMPLETE) || adapter->ai_force_duplex == 3) { et1310_phy_link_status(adapter, &link_status, &autoneg_status, diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 8e9404e1473..d8753f1265c 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -61,24 +61,6 @@ #include "et1310_address_map.h" -/* MI Register Addresses */ -#define MI_CONTROL_REG 0 -#define MI_STATUS_REG 1 -#define MI_PHY_IDENTIFIER_1_REG 2 -#define MI_PHY_IDENTIFIER_2_REG 3 -#define MI_AUTONEG_ADVERTISEMENT_REG 4 -#define MI_AUTONEG_LINK_PARTNER_ABILITY_REG 5 -#define MI_AUTONEG_EXPANSION_REG 6 -#define MI_AUTONEG_NEXT_PAGE_TRANSMIT_REG 7 -#define MI_LINK_PARTNER_NEXT_PAGE_REG 8 -#define MI_1000BASET_CONTROL_REG 9 -#define MI_1000BASET_STATUS_REG 10 -#define MI_RESERVED11_REG 11 -#define MI_RESERVED12_REG 12 -#define MI_RESERVED13_REG 13 -#define MI_RESERVED14_REG 14 -#define MI_EXTENDED_STATUS_REG 15 - /* VMI Register Addresses */ #define VMI_RESERVED16_REG 16 #define VMI_RESERVED17_REG 17 @@ -126,134 +108,6 @@ struct mi_regs { u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ }; -/* - * MI Register 0: Basic mode control register - * 15: reset - * 14: loopback - * 13: speed_sel - * 12: enable_autoneg - * 11: power_down - * 10: isolate - * 9: restart_autoneg - * 8: duplex_mode - * 7: col_test - * 6: speed_1000_sel - * 5-0: res1 - */ - -/* - * MI Register 1: Basic mode status register - * 15: link_100T4 - * 14: link_100fdx - * 13: link_100hdx - * 12: link_10fdx - * 11: link_10hdx - * 10: link_100T2fdx - * 9: link_100T2hdx - * 8: extend_status - * 7: res1 - * 6: preamble_supress - * 5: auto_neg_complete - * 4: remote_fault - * 3: auto_neg_able - * 2: link_status - * 1: jabber_detect - * 0: ext_cap - */ - -#define MI_BMSR_LINK_STATUS 0x04 -#define MI_BMSR_AUTO_NEG_COMPLETE 0x20 - -/* - * MI Register 4: Auto-negotiation advertisement register - * - * 15: np_indication - * 14: res2 - * 13: remote_fault - * 12: res1 - * 11: cap_asmpause - * 10: cap_pause - * 9: cap_100T4 - * 8: cap_100fdx - * 7: cap_100hdx - * 6: cap_10fdx - * 5: cap_10hdx - * 4-0: selector - */ - -/* MI Register 5: Auto-negotiation link partner advertisement register - * 15: np_indication - * 14: acknowledge - * 13: remote_fault - * 12: res1 - * 11: cap_asmpause - * 10: cap_pause - * 9: cap_100T4 - * 8: cap_100fdx - * 7: cap_100hdx - * 6: cap_10fdx - * 5: cap_10hdx - * 4-0: selector - */ - -/* MI Register 6: Auto-negotiation expansion register - * 15-5: reserved - * 4: pdf - * 3: lp_np_able - * 2: np_able - * 1: page_rx - * 0: lp_an_able - */ - -/* MI Register 7: Auto-negotiation next page transmit reg(0x07) - * 15: np - * 14: reserved - * 13: msg_page - * 12: ack2 - * 11: toggle - * 10-0 msg - */ - -/* MI Register 8: Link Partner Next Page Reg(0x08) - * 15: np - * 14: ack - * 13: msg_page - * 12: ack2 - * 11: toggle - * 10-0: msg - */ - -/* MI Register 9: 1000BaseT Control Reg(0x09) - * 15-13: test_mode - * 12: ms_config_en - * 11: ms_value - * 10: port_type - * 9: link_1000fdx - * 8: link_1000hdx - * 7-0: reserved - */ - -/* MI Register 10: 1000BaseT Status Reg(0x0A) - * 15: ms_config_fault - * 14: ms_resolve - * 13: local_rx_status - * 12: remote_rx_status - * 11: link_1000fdx - * 10: link_1000hdx - * 9-8: reserved - * 7-0: idle_err_cnt - */ - -/* MI Register 11 - 14: Reserved Regs(0x0B - 0x0E) */ - -/* MI Register 15: Extended status Reg(0x0F) - * 15: link_1000Xfdx - * 14: link_1000Xhdx - * 13: link_1000fdx - * 12: link_1000hdx - * 11-0: reserved - */ - /* MI Register 16 - 18: Reserved Reg(0x10-0x12) */ /* MI Register 19: Loopback Control Reg(0x13) @@ -422,20 +276,6 @@ struct mi_regs { #define TRUEPHY_ADV_DUPLEX_BOTH \ (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF) -#define PHY_CONTROL 0x00 /* #define TRU_MI_CONTROL_REGISTER 0 */ -#define PHY_STATUS 0x01 /* #define TRU_MI_STATUS_REGISTER 1 */ -#define PHY_ID_1 0x02 /* #define TRU_MI_PHY_IDENTIFIER_1_REGISTER 2 */ -#define PHY_ID_2 0x03 /* #define TRU_MI_PHY_IDENTIFIER_2_REGISTER 3 */ -#define PHY_AUTO_ADVERTISEMENT 0x04 /* #define TRU_MI_ADVERTISEMENT_REGISTER 4 */ -#define PHY_AUTO_LINK_PARTNER 0x05 /* #define TRU_MI_LINK_PARTNER_ABILITY_REGISTER 5 */ -#define PHY_AUTO_EXPANSION 0x06 /* #define TRU_MI_EXPANSION_REGISTER 6 */ -#define PHY_AUTO_NEXT_PAGE_TX 0x07 /* #define TRU_MI_NEXT_PAGE_TRANSMIT_REGISTER 7 */ -#define PHY_LINK_PARTNER_NEXT_PAGE 0x08 /* #define TRU_MI_LINK_PARTNER_NEXT_PAGE_REGISTER 8 */ -#define PHY_1000_CONTROL 0x09 /* #define TRU_MI_1000BASET_CONTROL_REGISTER 9 */ -#define PHY_1000_STATUS 0x0A /* #define TRU_MI_1000BASET_STATUS_REGISTER 10 */ - -#define PHY_EXTENDED_STATUS 0x0F /* #define TRU_MI_EXTENDED_STATUS_REGISTER 15 */ - /* some defines for modem registers that seem to be 'reserved' */ #define PHY_INDEX_REG 0x10 #define PHY_DATA_REG 0x11 diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 6ffebfadcf9..2ef2a706241 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -249,14 +249,14 @@ void et131x_error_timer_handler(unsigned long data) dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); - if (!(adapter->bmsr & MI_BMSR_LINK_STATUS) && + if (!(adapter->bmsr & BMSR_LSTATUS) && adapter->registry_phy_coma && adapter->boot_coma < 11) { adapter->boot_coma++; } if (adapter->boot_coma == 10) { - if (!(adapter->bmsr & MI_BMSR_LINK_STATUS) + if (!(adapter->bmsr & BMSR_LSTATUS) && adapter->registry_phy_coma) { if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { /* NOTE - This was originally a 'sync with From a85fe2c626b6e9d7f04998810406556eb64e3070 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 1 Sep 2011 12:32:28 -0500 Subject: [PATCH 0889/1519] staging: rtl8192e: Fix format warning Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 330a3a96bab..8b9d85c48be 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -87,7 +87,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, " sentd to: %pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); if (pBA == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n"); return NULL; } skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); From 64df17c6fc95740f1e5dfb0ab257bbee9bdb4147 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 3 Sep 2011 12:49:06 +0100 Subject: [PATCH 0890/1519] staging: et131x: Fix checkpatch whitespace warnings Some of my previous hacking attempts have not been following the rules. All fixes either lines > 80 chars or whitespace corrections (spaces->tabs etc). Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 5 +-- drivers/staging/et131x/et1310_phy.c | 16 +++++---- drivers/staging/et131x/et1310_phy.h | 27 ++++++++------- drivers/staging/et131x/et1310_tx.c | 5 +-- drivers/staging/et131x/et131x_ethtool.c | 8 ++--- drivers/staging/et131x/et131x_initpci.c | 44 ++++++++++++------------- drivers/staging/et131x/et131x_isr.c | 6 ++-- drivers/staging/et131x/et131x_netdev.c | 7 ++-- 8 files changed, 64 insertions(+), 54 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index ab85cb3babd..36f21685599 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -191,7 +191,8 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; /* Initialize loop back to off */ cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); - if (adapter->flowcontrol == FLOW_RXONLY || adapter->flowcontrol == FLOW_BOTH) + if (adapter->flowcontrol == FLOW_RXONLY || + adapter->flowcontrol == FLOW_BOTH) cfg1 |= CFG1_RX_FLOW; writel(cfg1, &mac->cfg1); @@ -287,7 +288,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter) writel(sa_lo, &rxmac->sa_lo); sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) | - adapter->addr[1]; + adapter->addr[1]; writel(sa_hi, &rxmac->sa_hi); /* Disable all Packet Filtering */ diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index fedde6b2f1e..12345c7d32d 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -132,7 +132,7 @@ int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) { struct phy_device *phydev = adapter->phydev; - if(!phydev) + if (!phydev) return -EIO; return et131x_phy_mii_read(adapter, phydev->addr, reg, value); @@ -224,7 +224,7 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) u32 mii_cmd; u32 mii_indicator; - if(!phydev) + if (!phydev) return -EIO; addr = phydev->addr; @@ -465,10 +465,12 @@ void et131x_mii_check(struct et131x_adapter *adapter, u16 register18; et131x_mii_read(adapter, 0x12, ®ister18); - et131x_mii_write(adapter, 0x12, register18 | 0x4); + et131x_mii_write(adapter, 0x12, + register18 | 0x4); et131x_mii_write(adapter, 0x10, register18 | 0x8402); - et131x_mii_write(adapter, 0x11, register18 | 511); + et131x_mii_write(adapter, 0x11, + register18 | 511); et131x_mii_write(adapter, 0x12, register18); } @@ -529,10 +531,12 @@ void et131x_mii_check(struct et131x_adapter *adapter, u16 register18; et131x_mii_read(adapter, 0x12, ®ister18); - et131x_mii_write(adapter, 0x12, register18 | 0x4); + et131x_mii_write(adapter, 0x12, + register18 | 0x4); et131x_mii_write(adapter, 0x10, register18 | 0x8402); - et131x_mii_write(adapter, 0x11, register18 | 511); + et131x_mii_write(adapter, 0x11, + register18 | 511); et131x_mii_write(adapter, 0x12, register18); } diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index d8753f1265c..88dc8cdb6ef 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -280,19 +280,18 @@ struct mi_regs { #define PHY_INDEX_REG 0x10 #define PHY_DATA_REG 0x11 -#define PHY_MPHY_CONTROL_REG 0x12 /* #define TRU_VMI_MPHY_CONTROL_REGISTER 18 */ - -#define PHY_LOOPBACK_CONTROL 0x13 /* #define TRU_VMI_LOOPBACK_CONTROL_1_REGISTER 19 */ - /* #define TRU_VMI_LOOPBACK_CONTROL_2_REGISTER 20 */ -#define PHY_REGISTER_MGMT_CONTROL 0x15 /* #define TRU_VMI_MI_SEQ_CONTROL_REGISTER 21 */ -#define PHY_CONFIG 0x16 /* #define TRU_VMI_CONFIGURATION_REGISTER 22 */ -#define PHY_PHY_CONTROL 0x17 /* #define TRU_VMI_PHY_CONTROL_REGISTER 23 */ -#define PHY_INTERRUPT_MASK 0x18 /* #define TRU_VMI_INTERRUPT_MASK_REGISTER 24 */ -#define PHY_INTERRUPT_STATUS 0x19 /* #define TRU_VMI_INTERRUPT_STATUS_REGISTER 25 */ -#define PHY_PHY_STATUS 0x1A /* #define TRU_VMI_PHY_STATUS_REGISTER 26 */ -#define PHY_LED_1 0x1B /* #define TRU_VMI_LED_CONTROL_1_REGISTER 27 */ -#define PHY_LED_2 0x1C /* #define TRU_VMI_LED_CONTROL_2_REGISTER 28 */ - /* #define TRU_VMI_LINK_CONTROL_REGISTER 29 */ - /* #define TRU_VMI_TIMING_CONTROL_REGISTER */ +#define PHY_MPHY_CONTROL_REG 0x12 +#define PHY_LOOPBACK_CONTROL 0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */ + /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */ +#define PHY_REGISTER_MGMT_CONTROL 0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG 21 */ +#define PHY_CONFIG 0x16 /* TRU_VMI_CONFIGURATION_REG 22 */ +#define PHY_PHY_CONTROL 0x17 /* TRU_VMI_PHY_CONTROL_REG 23 */ +#define PHY_INTERRUPT_MASK 0x18 /* TRU_VMI_INTERRUPT_MASK_REG 24 */ +#define PHY_INTERRUPT_STATUS 0x19 /* TRU_VMI_INTERRUPT_STATUS_REG 25 */ +#define PHY_PHY_STATUS 0x1A /* TRU_VMI_PHY_STATUS_REG 26 */ +#define PHY_LED_1 0x1B /* TRU_VMI_LED_CONTROL_1_REG 27 */ +#define PHY_LED_2 0x1C /* TRU_VMI_LED_CONTROL_2_REG 28 */ + /* TRU_VMI_LINK_CONTROL_REG 29 */ + /* TRU_VMI_TIMING_CONTROL_REG */ #endif /* _ET1310_PHY_H_ */ diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index f8211048f6b..aa07138069f 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -435,7 +435,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) add_10bit(&adapter->tx_ring.send_idx, thiscopy); if (INDEX10(adapter->tx_ring.send_idx) == 0 || - INDEX10(adapter->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { + INDEX10(adapter->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { adapter->tx_ring.send_idx &= ~ET_DMA10_MASK; adapter->tx_ring.send_idx ^= ET_DMA10_WRAP; } @@ -641,7 +641,8 @@ static inline void free_send_packet(struct et131x_adapter *adapter, * they point to */ do { - desc = (struct tx_desc *)(adapter->tx_ring.tx_desc_ring + + desc = (struct tx_desc *) + (adapter->tx_ring.tx_desc_ring + INDEX10(tcb->index_start)); pci_unmap_single(adapter->pdev, diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c index d980ad6c552..b92633fa6d4 100644 --- a/drivers/staging/et131x/et131x_ethtool.c +++ b/drivers/staging/et131x/et131x_ethtool.c @@ -58,10 +58,10 @@ static void et131x_get_drvinfo(struct net_device *netdev, } static struct ethtool_ops et131x_ethtool_ops = { - .get_settings = et131x_get_settings, - .set_settings = et131x_set_settings, - .get_drvinfo = et131x_get_drvinfo, - .get_link = ethtool_op_get_link, + .get_settings = et131x_get_settings, + .set_settings = et131x_set_settings, + .get_drvinfo = et131x_get_drvinfo, + .get_link = ethtool_op_get_link, }; void et131x_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 2ef2a706241..3cfcc2d07b7 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -487,30 +487,30 @@ int et131x_mii_probe(struct net_device *netdev) phydev = phy_connect(netdev, dev_name(&phydev->dev), &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII); - if(IS_ERR(phydev)) { + if (IS_ERR(phydev)) { dev_err(&adapter->pdev->dev, "Could not attach to PHY\n"); return PTR_ERR(phydev); } phydev->supported &= (SUPPORTED_10baseT_Half - | SUPPORTED_10baseT_Full - | SUPPORTED_100baseT_Half - | SUPPORTED_100baseT_Full - | SUPPORTED_Autoneg - | SUPPORTED_MII - | SUPPORTED_TP); + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_Autoneg + | SUPPORTED_MII + | SUPPORTED_TP); if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) phydev->supported |= SUPPORTED_1000baseT_Full; - phydev->advertising = phydev->supported; - adapter->phydev = phydev; + phydev->advertising = phydev->supported; + adapter->phydev = phydev; - dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " - "(mii_bus:phy_addr=%s)\n", - phydev->drv->name, dev_name(&phydev->dev)); + dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " + "(mii_bus:phy_addr=%s)\n", + phydev->drv->name, dev_name(&phydev->dev)); - return 0; + return 0; } /** @@ -707,22 +707,22 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, adapter->mii_bus->write = et131x_mdio_write; adapter->mii_bus->reset = et131x_mdio_reset; adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); - if (!adapter->mii_bus->irq) { - dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); + if (!adapter->mii_bus->irq) { + dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); goto err_mdio_free; - } + } - for (ii = 0; ii < PHY_MAX_ADDR; ii++) - adapter->mii_bus->irq[ii] = PHY_POLL; + for (ii = 0; ii < PHY_MAX_ADDR; ii++) + adapter->mii_bus->irq[ii] = PHY_POLL; - if (mdiobus_register(adapter->mii_bus)) { - dev_err(&pdev->dev, "failed to register MII bus\n"); + if (mdiobus_register(adapter->mii_bus)) { + dev_err(&pdev->dev, "failed to register MII bus\n"); mdiobus_free(adapter->mii_bus); goto err_mdio_free_irq; - } + } if (et131x_mii_probe(netdev)) { - dev_err(&pdev->dev, "failed to probe MII bus\n"); + dev_err(&pdev->dev, "failed to probe MII bus\n"); goto err_mdio_unregister; } diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 4d75690e7af..94565c10f1b 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -119,7 +119,8 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter) u32 mask; /* Enable all global interrupts */ - if (adapter->flowcontrol == FLOW_TXONLY || adapter->flowcontrol == FLOW_BOTH) + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) mask = INT_MASK_ENABLE; else mask = INT_MASK_ENABLE_NO_FLOW; @@ -276,7 +277,8 @@ void et131x_isr_handler(struct work_struct *work) } /* Handle Free Buffer Ring 0 and 1 Low interrupt */ - if (status & (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) { + if (status & + (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) { /* * This indicates the number of unused buffers in * RXDMA free buffer ring 0 is <= the limit you diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index d12e05ec3b8..5fb40560c15 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -408,7 +408,7 @@ void et131x_tx_timeout(struct net_device *netdev) unsigned long flags; /* If the device is closed, ignore the timeout */ - if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)); + if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)) return; /* Any nonrecoverable hardware error? @@ -453,7 +453,10 @@ void et131x_tx_timeout(struct net_device *netdev) /* Disable device interrupts */ et131x_disable_interrupts(adapter); - /* Enable the Tx and Rx DMA engines (if not already enabled) */ + /* + * Enable the Tx and Rx DMA engines + * (if not already enabled) + */ et131x_rx_dma_enable(adapter); et131x_tx_dma_enable(adapter); From 740b7a2cb18206374aabe38c0ec1f1344214ac97 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 3 Sep 2011 12:49:07 +0100 Subject: [PATCH 0891/1519] staging: et131x: Amend README file I think the kernel style cleanups are done now. Adding myself as a recipient of patches. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 28752a50231..c6bcc6a0573 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - kernel coding style cleanups - forward port for latest network driver changes - kill useless typecasts (e.g. in et1310_phy.c) - alloc_etherdev is initializing memory with zero?!? @@ -19,6 +18,7 @@ TODO: Please send patches to: Greg Kroah-Hartman + Mark Einon And Cc: Olaf Hartmann as he has this device and can test any changes. From 412f8e0c52b126c6f54d0626a9dede9438d76c03 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:32 +0100 Subject: [PATCH 0892/1519] staging: et131x: Remove private adapter->linkspeed and use phydev->speed instead The phy device keeps a note of the link speed, so use that value instead of the driver private one. Also use the phydev defines for link speeds, and remove the driver private ones. adapter->hw_errs was never used, even in the vendor driver, so remove that too. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 7 +++++-- drivers/staging/et131x/et1310_phy.c | 9 ++++----- drivers/staging/et131x/et1310_phy.h | 5 ----- drivers/staging/et131x/et1310_rx.c | 9 +++++++-- drivers/staging/et131x/et1310_tx.c | 6 ++++-- drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_initpci.c | 12 ++++++------ 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 36f21685599..efabc038bb4 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -82,6 +82,7 @@ #include #include #include +#include #include "et1310_phy.h" #include "et131x_adapter.h" @@ -166,6 +167,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) { int32_t delay = 0; struct mac_regs __iomem *mac = &adapter->regs->mac; + struct phy_device *phydev = adapter->phydev; u32 cfg1; u32 cfg2; u32 ifctrl; @@ -178,7 +180,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) /* Set up the if mode bits */ cfg2 &= ~0x300; - if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (phydev && phydev->speed == SPEED_1000) { cfg2 |= 0x200; /* Phy mode bit */ ifctrl &= ~(1 << 24); @@ -239,6 +241,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) void et1310_config_rxmac_regs(struct et131x_adapter *adapter) { struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + struct phy_device *phydev = adapter->phydev; u32 sa_lo; u32 sa_hi = 0; u32 pf_ctrl = 0; @@ -351,7 +354,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter) * bit 16: Receive frame truncated. * bit 17: Drop packet enable */ - if (adapter->linkspeed == TRUEPHY_SPEED_100MBPS) + if (phydev && phydev->speed == SPEED_100) writel(0x30038, &rxmac->mif_ctrl); else writel(0x30030, &rxmac->mif_ctrl); diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 12345c7d32d..c5d0d02f4ca 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -440,6 +440,7 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) void et131x_mii_check(struct et131x_adapter *adapter, u16 bmsr, u16 bmsr_ints) { + struct phy_device *phydev = adapter->phydev; u8 link_status; u32 autoneg_status; u32 speed; @@ -456,7 +457,7 @@ void et131x_mii_check(struct et131x_adapter *adapter, dev_warn(&adapter->pdev->dev, "Link down - cable problem ?\n"); - if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { + if (phydev && phydev->speed == SPEED_10) { /* NOTE - Is there a way to query this without * TruePHY? * && TRU_QueryCoreType(adapter->hTruePhy, 0) == @@ -476,7 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, netif_carrier_off(adapter->netdev); - adapter->linkspeed = 0; adapter->duplex_mode = 0; /* Free the packets being actively sent & stopped */ @@ -516,12 +516,11 @@ void et131x_mii_check(struct et131x_adapter *adapter, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); - adapter->linkspeed = speed; adapter->duplex_mode = duplex; adapter->boot_coma = 20; - if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { + if (phydev && phydev->speed == SPEED_10) { /* * NOTE - Is there a way to query this without * TruePHY? @@ -542,7 +541,7 @@ void et131x_mii_check(struct et131x_adapter *adapter, et1310_config_flow_control(adapter); - if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS && + if (phydev && phydev->speed == SPEED_1000 && adapter->registry_jumbo_packet > 2048) et1310_phy_and_or_reg(adapter, 0x16, 0xcfff, 0x2000); diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 88dc8cdb6ef..3e95c66dfde 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -242,11 +242,6 @@ struct mi_regs { #define TRUEPHY_MASK 2 #endif -/* Define speeds */ -#define TRUEPHY_SPEED_10MBPS 0 -#define TRUEPHY_SPEED_100MBPS 1 -#define TRUEPHY_SPEED_1000MBPS 2 - /* Define duplex modes */ #define TRUEPHY_DUPLEX_HALF 0 #define TRUEPHY_DUPLEX_FULL 1 diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index f50420c582a..c402c5e61e4 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -82,6 +82,7 @@ #include #include #include +#include #include "et1310_phy.h" #include "et131x_adapter.h" @@ -724,11 +725,15 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) */ void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) { + struct phy_device *phydev = adapter->phydev; + + if (!phydev) + return; + /* For version B silicon, we do not use the RxDMA timer for 10 and 100 * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. */ - if ((adapter->linkspeed == TRUEPHY_SPEED_100MBPS) || - (adapter->linkspeed == TRUEPHY_SPEED_10MBPS)) { + if ((phydev->speed == SPEED_100) || (phydev->speed == SPEED_10)) { writel(0, &adapter->regs->rxdma.max_pkt_time); writel(1, &adapter->regs->rxdma.num_pkt_done); } diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index aa07138069f..1f806511f6c 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -82,6 +82,7 @@ #include #include #include +#include #include "et1310_phy.h" #include "et131x_adapter.h" @@ -287,6 +288,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) u32 nr_frags = skb_shinfo(skb)->nr_frags + 1; struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0]; unsigned long flags; + struct phy_device *phydev = adapter->phydev; /* Part of the optimizations of this send routine restrict us to * sending 24 fragments at a pass. In practice we should never see @@ -400,7 +402,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) if (frag == 0) return -EIO; - if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (phydev && phydev->speed == SPEED_1000) { if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { /* Last element & Interrupt flag */ desc[frag - 1].flags = 0x5; @@ -478,7 +480,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) /* For Gig only, we use Tx Interrupt coalescing. Enable the software * timer to wake us up if this packet isn't followed by N more. */ - if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { + if (phydev && phydev->speed == SPEED_1000) { writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, &adapter->regs->global.watchdog_timer); } diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index fbefd2e88d8..1e65e798282 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -147,7 +147,6 @@ struct et131x_adapter { /* Flags that indicate current state of the adapter */ u32 flags; - u32 hw_errs; /* Configuration */ u8 rom_addr[ETH_ALEN]; @@ -170,7 +169,6 @@ struct et131x_adapter { /* Packet Filter and look ahead size */ u32 packet_filter; - u32 linkspeed; u32 duplex_mode; /* multicast list */ diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 3cfcc2d07b7..eb08889e20b 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -678,12 +678,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Copy address into the net_device struct */ memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); - /* Setup et1310 as per the documentation */ - et131x_adapter_setup(adapter); - - /* Create a timer to count errors received by the NIC */ - init_timer(&adapter->error_timer); - adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; adapter->error_timer.function = et131x_error_timer_handler; adapter->error_timer.data = (unsigned long)adapter; @@ -726,6 +720,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, goto err_mdio_unregister; } + /* Setup et1310 as per the documentation */ + et131x_adapter_setup(adapter); + + /* Create a timer to count errors received by the NIC */ + init_timer(&adapter->error_timer); + /* We can enable interrupts now * * NOTE - Because registration of interrupt handler is done in the From 06530d81d6a6b9cccd6433868fc0bb68fe0361e3 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:33 +0100 Subject: [PATCH 0893/1519] staging: et131x: Remove private adapter->duplex_mode and use phydev->duplex instead The phy device keeps a note of the duplex mode, so use that value instead of duplex mode. Also use the phydev defines for duplex modes, and remove the driver private ones. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 8 +++++--- drivers/staging/et131x/et1310_phy.c | 4 ---- drivers/staging/et131x/et1310_phy.h | 4 ---- drivers/staging/et131x/et131x_adapter.h | 1 - 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index efabc038bb4..08d7691ce19 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -205,11 +205,11 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) cfg2 &= ~0x0021; /* Turn on duplex if needed */ - if (adapter->duplex_mode) + if (phydev && phydev->duplex == DUPLEX_FULL) cfg2 |= 0x01; ifctrl &= ~(1 << 26); - if (!adapter->duplex_mode) + if (phydev && phydev->duplex == DUPLEX_HALF) ifctrl |= (1<<26); /* Enable ghd */ writel(ifctrl, &mac->if_ctrl); @@ -450,7 +450,9 @@ void et1310_config_macstat_regs(struct et131x_adapter *adapter) void et1310_config_flow_control(struct et131x_adapter *adapter) { - if (adapter->duplex_mode == 0) { + struct phy_device *phydev = adapter->phydev; + + if (phydev->duplex == DUPLEX_HALF) { adapter->flowcontrol = FLOW_NONE; } else { char remote_pause, remote_async_pause; diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index c5d0d02f4ca..41f0afa4a13 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -477,8 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, netif_carrier_off(adapter->netdev); - adapter->duplex_mode = 0; - /* Free the packets being actively sent & stopped */ et131x_free_busy_send_packets(adapter); @@ -516,8 +514,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); - adapter->duplex_mode = duplex; - adapter->boot_coma = 20; if (phydev && phydev->speed == SPEED_10) { diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 3e95c66dfde..d996e8e746c 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -242,10 +242,6 @@ struct mi_regs { #define TRUEPHY_MASK 2 #endif -/* Define duplex modes */ -#define TRUEPHY_DUPLEX_HALF 0 -#define TRUEPHY_DUPLEX_FULL 1 - /* Define master/slave configuration values */ #define TRUEPHY_CFG_SLAVE 0 #define TRUEPHY_CFG_MASTER 1 diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 1e65e798282..a63f3768daa 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -169,7 +169,6 @@ struct et131x_adapter { /* Packet Filter and look ahead size */ u32 packet_filter; - u32 duplex_mode; /* multicast list */ u32 multicast_addr_count; From e2963962aec7e953063c6a1e031a64ca9f5fd47b Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:34 +0100 Subject: [PATCH 0894/1519] staging: et131x: Remove redundant struct adapter members adapter->speed_duplex was never referenced. adapter->registry_phy_coma was always set to zero, even in the vendor driver. Removing all member references and associated dead code. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 6 ------ drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_initpci.c | 4 +--- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 41f0afa4a13..0fccb86810c 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -496,12 +496,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, /* Setup ET1310 as per the documentation */ et131x_adapter_setup(adapter); - - /* Setup the PHY into coma mode until the cable is - * plugged back in - */ - if (adapter->registry_phy_coma == 1) - et1310_enable_phy_coma(adapter); } } diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index a63f3768daa..5656472c9d3 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -178,9 +178,7 @@ struct et131x_adapter { struct address_map __iomem *regs; /* Registry parameters */ - u8 speed_duplex; /* speed/duplex */ u8 wanted_flow; /* Flow we want for 802.3x flow control */ - u8 registry_phy_coma; /* Phy Coma mode enable/disable */ u32 registry_rx_mem_end; /* Size of internal rx memory */ u32 registry_jumbo_packet; /* Max supported ethernet packet size */ diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index eb08889e20b..799aad68547 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -250,14 +250,12 @@ void et131x_error_timer_handler(unsigned long data) "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); if (!(adapter->bmsr & BMSR_LSTATUS) && - adapter->registry_phy_coma && adapter->boot_coma < 11) { adapter->boot_coma++; } if (adapter->boot_coma == 10) { - if (!(adapter->bmsr & BMSR_LSTATUS) - && adapter->registry_phy_coma) { + if (!(adapter->bmsr & BMSR_LSTATUS)) { if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { /* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux? From 3e3b5f39159b97baa1dd38bff848aeccd996b7f0 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:35 +0100 Subject: [PATCH 0895/1519] staging: et131x: Remove PHY interrupt handling code from driver isr handler The PHY interrupt is now handled by the phy_device, and the equivalent code is present in et131x_adjust_link, called from the phy_device when needed. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_isr.c | 38 ----------------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 94565c10f1b..b3290e9356e 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -364,44 +364,6 @@ void et131x_isr_handler(struct work_struct *work) dev_err(&adapter->pdev->dev, "WAKE_ON_LAN interrupt\n"); } - /* Handle the PHY interrupt */ - if (status & ET_INTR_PHY) { - u32 pm_csr; - u16 bmsr_ints; - u16 bmsr_data; - u16 myisr; - - /* If we are in coma mode when we get this interrupt, - * we need to disable it. - */ - pm_csr = readl(&iomem->global.pm_csr); - if (pm_csr & ET_PM_PHY_SW_COMA) { - /* - * Check to see if we are in coma mode and if - * so, disable it because we will not be able - * to read PHY values until we are out. - */ - et1310_disable_phy_coma(adapter); - } - - /* Read the PHY ISR to clear the reason for the - * interrupt. - */ - et131x_mii_read(adapter, - (uint8_t) offsetof(struct mi_regs, isr), - &myisr); - - et131x_mii_read(adapter, - (uint8_t) offsetof(struct mi_regs, bmsr), - &bmsr_data); - - bmsr_ints = adapter->bmsr ^ bmsr_data; - adapter->bmsr = bmsr_data; - - /* Do all the cable in / cable out stuff */ - et131x_mii_check(adapter, bmsr_data, bmsr_ints); - } - /* Let's move on to the TxMac */ if (status & ET_INTR_TXMAC) { u32 err = readl(&iomem->txmac.err); From 5ee574e0c4ff86f3759987f833f06d4f0cdeb953 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:36 +0100 Subject: [PATCH 0896/1519] staging: et131x: remove calls to netif_carrier_[on|off] from et131x_mii_check As et131x_adjust_link is called from the phydev in response to a netif_carrier_[on|off], and is the only caller of et131x_mii_check, we don't need to call netif_carrier_[on|off] again. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 0fccb86810c..6c3ceed8aa5 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -452,7 +452,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, if (bmsr_ints & BMSR_LSTATUS) { if (bmsr & BMSR_LSTATUS) { adapter->boot_coma = 20; - netif_carrier_on(adapter->netdev); } else { dev_warn(&adapter->pdev->dev, "Link down - cable problem ?\n"); @@ -475,8 +474,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, et131x_mii_write(adapter, 0x12, register18); } - netif_carrier_off(adapter->netdev); - /* Free the packets being actively sent & stopped */ et131x_free_busy_send_packets(adapter); From ddf488baf638af36c49ed71171b8375582e5bd5f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:37 +0100 Subject: [PATCH 0897/1519] staging: et131x: Remove registry_rx_mem_end from struct et131x_adapter registry_rx_mem_end is not referenced anywhere in the driver. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_adapter.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 5656472c9d3..8c6d5f93c35 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -136,7 +136,6 @@ struct ce_stats { u32 interrupt_status; }; - /* The private adapter structure */ struct et131x_adapter { struct net_device *netdev; @@ -179,11 +178,8 @@ struct et131x_adapter { /* Registry parameters */ u8 wanted_flow; /* Flow we want for 802.3x flow control */ - - u32 registry_rx_mem_end; /* Size of internal rx memory */ u32 registry_jumbo_packet; /* Max supported ethernet packet size */ - /* Derived from the registry: */ u8 ai_force_duplex; /* duplex setting */ u16 ai_force_speed; /* 'Speed', user over-ride of line speed */ From 9c898c7ad5c2eed0a0fc5a7ca0033315f30cb3df Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:38 +0100 Subject: [PATCH 0898/1519] staging: et131x: Remove cached_mask_value from et131x_adapter cached_mask_value is only ever assigned, never read. Remove it. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_isr.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 8c6d5f93c35..292a7719b59 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -200,8 +200,6 @@ struct et131x_adapter { u16 pdown_speed; u8 pdown_duplex; - u32 cached_mask_value; - /* Xcvr status at last poll */ u16 bmsr; diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index b3290e9356e..0747935fb3c 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -125,7 +125,6 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter) else mask = INT_MASK_ENABLE_NO_FLOW; - adapter->cached_mask_value = mask; writel(mask, &adapter->regs->global.int_mask); } @@ -139,7 +138,6 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter) void et131x_disable_interrupts(struct et131x_adapter *adapter) { /* Disable all global interrupts */ - adapter->cached_mask_value = INT_MASK_DISABLE; writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); } From 88982cb1b1d9c2b90a40bf65649424022e300674 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:39 +0100 Subject: [PATCH 0899/1519] staging: et131x: Remove duplicated register defines from et1310_phy.h The VMI_* set of register defines are not used, and duplicate the set of PHY_* registers from the same file, which are used - hence removing. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index d996e8e746c..9cbc185496a 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -61,24 +61,6 @@ #include "et1310_address_map.h" -/* VMI Register Addresses */ -#define VMI_RESERVED16_REG 16 -#define VMI_RESERVED17_REG 17 -#define VMI_RESERVED18_REG 18 -#define VMI_LOOPBACK_CONTROL_REG 19 -#define VMI_RESERVED20_REG 20 -#define VMI_MI_CONTROL_REG 21 -#define VMI_PHY_CONFIGURATION_REG 22 -#define VMI_PHY_CONTROL_REG 23 -#define VMI_INTERRUPT_MASK_REG 24 -#define VMI_INTERRUPT_STATUS_REG 25 -#define VMI_PHY_STATUS_REG 26 -#define VMI_LED_CONTROL_1_REG 27 -#define VMI_LED_CONTROL_2_REG 28 -#define VMI_RESERVED29_REG 29 -#define VMI_RESERVED30_REG 30 -#define VMI_RESERVED31_REG 31 - /* PHY Register Mapping(MI) Management Interface Regs */ struct mi_regs { u8 bmcr; /* Basic mode control reg(Reg 0x00) */ From 46df22bd12c8ed6dc16a515ff7fea27464ffa589 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:40 +0100 Subject: [PATCH 0900/1519] staging: et131x: Replace magic numbers in et1310_phy.c with defines Replaced et131x_phy.c magic numbers specifying registers and their values with defines, defined in et131x_phy.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 77 +++++++++++++------------- drivers/staging/et131x/et1310_phy.h | 84 ++++++++++++++++++++++------- 2 files changed, 105 insertions(+), 56 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 6c3ceed8aa5..3c82f44a961 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -122,12 +122,11 @@ int et131x_mdio_reset(struct mii_bus *bus) struct net_device *netdev = bus->priv; struct et131x_adapter *adapter = netdev_priv(netdev); - et131x_mii_write(adapter, MII_BMCR, 0x8000); + et131x_mii_write(adapter, MII_BMCR, BMCR_RESET); return 0; } - int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) { struct phy_device *phydev = adapter->phydev; @@ -293,9 +292,9 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) u16 data; et131x_mii_read(adapter, MII_BMCR, &data); - data &= ~0x0800; /* Power UP */ - if (down) /* Power DOWN */ - data |= 0x0800; + data &= ~BMCR_PDOWN; + if (down) + data |= BMCR_PDOWN; et131x_mii_write(adapter, MII_BMCR, data); } @@ -333,19 +332,20 @@ static void et1310_phy_link_status(struct et131x_adapter *adapter, et131x_mii_read(adapter, PHY_PHY_STATUS, &vmi_phystatus); et131x_mii_read(adapter, MII_BMCR, &control); - *link_status = (vmi_phystatus & 0x0040) ? 1 : 0; - *autoneg = (control & 0x1000) ? ((vmi_phystatus & 0x0020) ? + *link_status = (vmi_phystatus & ET_PHY_LSTATUS) ? 1 : 0; + *autoneg = (control & ET_PHY_AUTONEG_STATUS) ? + ((vmi_phystatus & ET_PHY_AUTONEG_ENABLE) ? TRUEPHY_ANEG_COMPLETE : TRUEPHY_ANEG_NOT_COMPLETE) : - TRUEPHY_ANEG_DISABLED; - *linkspeed = (vmi_phystatus & 0x0300) >> 8; - *duplex_mode = (vmi_phystatus & 0x0080) >> 7; + TRUEPHY_ANEG_DISABLED; + *linkspeed = (vmi_phystatus & ET_PHY_SPEED_STATUS) >> 8; + *duplex_mode = (vmi_phystatus & ET_PHY_DUPLEX_STATUS) >> 7; /* NOTE: Need to complete this */ *mdi_mdix = 0; - *masterslave = (is1000BaseT & 0x4000) ? + *masterslave = (is1000BaseT & ET_1000BT_MSTR_SLV) ? TRUEPHY_CFG_MASTER : TRUEPHY_CFG_SLAVE; - *polarity = (vmi_phystatus & 0x0400) ? + *polarity = (vmi_phystatus & ET_PHY_POLARITY_STATUS) ? TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL; } @@ -402,15 +402,17 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) /* Zero out the adapter structure variable representing BMSR */ adapter->bmsr = 0; - et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, isr), &isr); - et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, imr), &imr); + et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &isr); + et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &imr); /* Set the link status interrupt only. Bad behavior when link status * and auto neg are set, we run into a nested interrupt problem */ - imr |= 0x0105; + imr |= (ET_PHY_INT_MASK_AUTONEGSTAT & + ET_PHY_INT_MASK_LINKSTAT & + ET_PHY_INT_MASK_ENABLE); - et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, imr), imr); + et131x_mii_write(adapter, PHY_INTERRUPT_MASK, imr); /* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates @@ -421,19 +423,17 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) * EEPROM. However, the above description is the default. */ if ((adapter->eeprom_data[1] & 0x4) == 0) { - et131x_mii_read(adapter, (u8) offsetof(struct mi_regs, lcr2), - &lcr2); + et131x_mii_read(adapter, PHY_LED_2, &lcr2); - lcr2 &= 0x00FF; - lcr2 |= 0xA000; /* led link */ + lcr2 &= (ET_LED2_LED_100TX & ET_LED2_LED_1000T); + lcr2 |= (LED_VAL_LINKON_ACTIVE << LED_LINK_SHIFT); if ((adapter->eeprom_data[1] & 0x8) == 0) - lcr2 |= 0x0300; + lcr2 |= (LED_VAL_1000BT_100BTX << LED_TXRX_SHIFT); else - lcr2 |= 0x0400; + lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); - et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, lcr2), - lcr2); + et131x_mii_write(adapter, PHY_LED_2, lcr2); } } @@ -464,14 +464,16 @@ void et131x_mii_check(struct et131x_adapter *adapter, */ u16 register18; - et131x_mii_read(adapter, 0x12, ®ister18); - et131x_mii_write(adapter, 0x12, + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, register18 | 0x4); - et131x_mii_write(adapter, 0x10, + et131x_mii_write(adapter, PHY_INDEX_REG, register18 | 0x8402); - et131x_mii_write(adapter, 0x11, + et131x_mii_write(adapter, PHY_DATA_REG, register18 | 511); - et131x_mii_write(adapter, 0x12, register18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); } /* Free the packets being actively sent & stopped */ @@ -516,22 +518,25 @@ void et131x_mii_check(struct et131x_adapter *adapter, */ u16 register18; - et131x_mii_read(adapter, 0x12, ®ister18); - et131x_mii_write(adapter, 0x12, + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, register18 | 0x4); - et131x_mii_write(adapter, 0x10, + et131x_mii_write(adapter, PHY_INDEX_REG, register18 | 0x8402); - et131x_mii_write(adapter, 0x11, + et131x_mii_write(adapter, PHY_DATA_REG, register18 | 511); - et131x_mii_write(adapter, 0x12, register18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); } et1310_config_flow_control(adapter); if (phydev && phydev->speed == SPEED_1000 && adapter->registry_jumbo_packet > 2048) - et1310_phy_and_or_reg(adapter, 0x16, 0xcfff, - 0x2000); + et1310_phy_and_or_reg(adapter, PHY_CONFIG, + ~ET_PHY_CONFIG_TX_FIFO_DEPTH, + ET_PHY_CONFIG_FIFO_DEPTH_32); et131x_set_rx_dma_timer(adapter); et1310_config_mac_regs2(adapter); diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 9cbc185496a..104008ea053 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -61,6 +61,25 @@ #include "et1310_address_map.h" +/* some defines for modem registers that seem to be 'reserved' */ +#define PHY_INDEX_REG 0x10 +#define PHY_DATA_REG 0x11 +#define PHY_MPHY_CONTROL_REG 0x12 + +/* defines for specified registers */ +#define PHY_LOOPBACK_CONTROL 0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */ + /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */ +#define PHY_REGISTER_MGMT_CONTROL 0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG 21 */ +#define PHY_CONFIG 0x16 /* TRU_VMI_CONFIGURATION_REG 22 */ +#define PHY_PHY_CONTROL 0x17 /* TRU_VMI_PHY_CONTROL_REG 23 */ +#define PHY_INTERRUPT_MASK 0x18 /* TRU_VMI_INTERRUPT_MASK_REG 24 */ +#define PHY_INTERRUPT_STATUS 0x19 /* TRU_VMI_INTERRUPT_STATUS_REG 25 */ +#define PHY_PHY_STATUS 0x1A /* TRU_VMI_PHY_STATUS_REG 26 */ +#define PHY_LED_1 0x1B /* TRU_VMI_LED_CONTROL_1_REG 27 */ +#define PHY_LED_2 0x1C /* TRU_VMI_LED_CONTROL_2_REG 28 */ + /* TRU_VMI_LINK_CONTROL_REG 29 */ + /* TRU_VMI_TIMING_CONTROL_REG */ + /* PHY Register Mapping(MI) Management Interface Regs */ struct mi_regs { u8 bmcr; /* Basic mode control reg(Reg 0x00) */ @@ -90,6 +109,9 @@ struct mi_regs { u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ }; +/* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */ +#define ET_1000BT_MSTR_SLV 0x4000 + /* MI Register 16 - 18: Reserved Reg(0x10-0x12) */ /* MI Register 19: Loopback Control Reg(0x13) @@ -128,6 +150,13 @@ struct mi_regs { * 2-0: mac_if_mode */ +#define ET_PHY_CONFIG_TX_FIFO_DEPTH 0x3000 + +#define ET_PHY_CONFIG_FIFO_DEPTH_8 0x0000 +#define ET_PHY_CONFIG_FIFO_DEPTH_16 0x1000 +#define ET_PHY_CONFIG_FIFO_DEPTH_32 0x2000 +#define ET_PHY_CONFIG_FIFO_DEPTH_64 0x3000 + /* MI Register 23: PHY CONTROL Reg(0x17) * 15: reserved * 14: tdr_en @@ -156,6 +185,9 @@ struct mi_regs { * 0: int_en */ +#define ET_PHY_INT_MASK_AUTONEGSTAT 0x0100 +#define ET_PHY_INT_MASK_LINKSTAT 0x0004 +#define ET_PHY_INT_MASK_ENABLE 0x0001 /* MI Register 25: Interrupt Status Reg(0x19) * 15-10: reserved @@ -187,6 +219,12 @@ struct mi_regs { * 1: pause_en * 0: asymmetric_dir */ +#define ET_PHY_AUTONEG_STATUS 0x1000 +#define ET_PHY_POLARITY_STATUS 0x0400 +#define ET_PHY_SPEED_STATUS 0x0300 +#define ET_PHY_DUPLEX_STATUS 0x0080 +#define ET_PHY_LSTATUS 0x0040 +#define ET_PHY_AUTONEG_ENABLE 0x0020 /* MI Register 27: LED Control Reg 1(0x1B) * 15-14: reserved @@ -205,11 +243,35 @@ struct mi_regs { * 7-4: led_100BaseTX * 3-0: led_1000BaseT */ +#define ET_LED2_LED_LINK 0xF000 +#define ET_LED2_LED_TXRX 0x0F00 +#define ET_LED2_LED_100TX 0x00F0 +#define ET_LED2_LED_1000T 0x000F + +/* defines for LED control reg 2 values */ +#define LED_VAL_1000BT 0x0 +#define LED_VAL_100BTX 0x1 +#define LED_VAL_10BT 0x2 +#define LED_VAL_1000BT_100BTX 0x3 /* 1000BT on, 100BTX blink */ +#define LED_VAL_LINKON 0x4 +#define LED_VAL_TX 0x5 +#define LED_VAL_RX 0x6 +#define LED_VAL_TXRX 0x7 /* TX or RX */ +#define LED_VAL_DUPLEXFULL 0x8 +#define LED_VAL_COLLISION 0x9 +#define LED_VAL_LINKON_ACTIVE 0xA /* Link on, activity blink */ +#define LED_VAL_LINKON_RECV 0xB /* Link on, receive blink */ +#define LED_VAL_DUPLEXFULL_COLLISION 0xC /* Duplex on, collision blink */ +#define LED_VAL_BLINK 0xD +#define LED_VAL_ON 0xE +#define LED_VAL_OFF 0xF + +#define LED_LINK_SHIFT 12 +#define LED_TXRX_SHIFT 8 +#define LED_100TX_SHIFT 4 /* MI Register 29 - 31: Reserved Reg(0x1D - 0x1E) */ - -/* Prototypes for ET1310_phy.c */ /* Defines for PHY access routines */ /* Define bit operation flags */ @@ -249,22 +311,4 @@ struct mi_regs { #define TRUEPHY_ADV_DUPLEX_BOTH \ (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF) -/* some defines for modem registers that seem to be 'reserved' */ -#define PHY_INDEX_REG 0x10 -#define PHY_DATA_REG 0x11 - -#define PHY_MPHY_CONTROL_REG 0x12 -#define PHY_LOOPBACK_CONTROL 0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */ - /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */ -#define PHY_REGISTER_MGMT_CONTROL 0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG 21 */ -#define PHY_CONFIG 0x16 /* TRU_VMI_CONFIGURATION_REG 22 */ -#define PHY_PHY_CONTROL 0x17 /* TRU_VMI_PHY_CONTROL_REG 23 */ -#define PHY_INTERRUPT_MASK 0x18 /* TRU_VMI_INTERRUPT_MASK_REG 24 */ -#define PHY_INTERRUPT_STATUS 0x19 /* TRU_VMI_INTERRUPT_STATUS_REG 25 */ -#define PHY_PHY_STATUS 0x1A /* TRU_VMI_PHY_STATUS_REG 26 */ -#define PHY_LED_1 0x1B /* TRU_VMI_LED_CONTROL_1_REG 27 */ -#define PHY_LED_2 0x1C /* TRU_VMI_LED_CONTROL_2_REG 28 */ - /* TRU_VMI_LINK_CONTROL_REG 29 */ - /* TRU_VMI_TIMING_CONTROL_REG */ - #endif /* _ET1310_PHY_H_ */ From b84981c80847999c23a87b9e6810978ccf14f14e Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:41 +0100 Subject: [PATCH 0901/1519] staging: et131x: Remove struct mi_regs from et1310_phy.h This structure is no longer used, and references registers defined in mii.h and other parts of et1310_phy.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.h | 34 +++++------------------------ 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 104008ea053..82037ac7d93 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -61,6 +61,11 @@ #include "et1310_address_map.h" +/* + * Defines for generic MII registers 0x00 -> 0x0F can be found in + * include/linux/mii.h + */ + /* some defines for modem registers that seem to be 'reserved' */ #define PHY_INDEX_REG 0x10 #define PHY_DATA_REG 0x11 @@ -80,35 +85,6 @@ /* TRU_VMI_LINK_CONTROL_REG 29 */ /* TRU_VMI_TIMING_CONTROL_REG */ -/* PHY Register Mapping(MI) Management Interface Regs */ -struct mi_regs { - u8 bmcr; /* Basic mode control reg(Reg 0x00) */ - u8 bmsr; /* Basic mode status reg(Reg 0x01) */ - u8 idr1; /* Phy identifier reg 1(Reg 0x02) */ - u8 idr2; /* Phy identifier reg 2(Reg 0x03) */ - u8 anar; /* Auto-Negotiation advertisement(Reg 0x04) */ - u8 anlpar; /* Auto-Negotiation link Partner Ability(Reg 0x05) */ - u8 aner; /* Auto-Negotiation expansion reg(Reg 0x06) */ - u8 annptr; /* Auto-Negotiation next page transmit reg(Reg 0x07) */ - u8 lpnpr; /* link partner next page reg(Reg 0x08) */ - u8 gcr; /* Gigabit basic mode control reg(Reg 0x09) */ - u8 gsr; /* Gigabit basic mode status reg(Reg 0x0A) */ - u8 mi_res1[4]; /* Future use by MI working group(Reg 0x0B - 0x0E) */ - u8 esr; /* Extended status reg(Reg 0x0F) */ - u8 mi_res2[3]; /* Future use by MI working group(Reg 0x10 - 0x12) */ - u8 loop_ctl; /* Loopback Control Reg(Reg 0x13) */ - u8 mi_res3; /* Future use by MI working group(Reg 0x14) */ - u8 mcr; /* MI Control Reg(Reg 0x15) */ - u8 pcr; /* Configuration Reg(Reg 0x16) */ - u8 phy_ctl; /* PHY Control Reg(Reg 0x17) */ - u8 imr; /* Interrupt Mask Reg(Reg 0x18) */ - u8 isr; /* Interrupt Status Reg(Reg 0x19) */ - u8 psr; /* PHY Status Reg(Reg 0x1A) */ - u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */ - u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */ - u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ -}; - /* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */ #define ET_1000BT_MSTR_SLV 0x4000 From cd9bb52bfadf31ca51a5b67d967ec06061ac4b04 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:42 +0100 Subject: [PATCH 0902/1519] staging: et131x: Remove ai_force_[duplex|speed] from et131x_adapter The ai_force settings were used to set the ethernet speed and duplex manually. This is now being done by the phy_device, so remove. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 6 ++---- drivers/staging/et131x/et131x_adapter.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 3c82f44a961..c4bc41dd185 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -498,10 +498,8 @@ void et131x_mii_check(struct et131x_adapter *adapter, } } - if ((bmsr_ints & BMSR_ANEGCOMPLETE) || - (adapter->ai_force_duplex == 3 && (bmsr_ints & BMSR_LSTATUS))) { - if ((bmsr & BMSR_ANEGCOMPLETE) || - adapter->ai_force_duplex == 3) { + if (bmsr_ints & BMSR_ANEGCOMPLETE) { + if (bmsr & BMSR_ANEGCOMPLETE) { et1310_phy_link_status(adapter, &link_status, &autoneg_status, &speed, &duplex, &mdi_mdix, diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 292a7719b59..78f2894d76e 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -181,8 +181,6 @@ struct et131x_adapter { u32 registry_jumbo_packet; /* Max supported ethernet packet size */ /* Derived from the registry: */ - u8 ai_force_duplex; /* duplex setting */ - u16 ai_force_speed; /* 'Speed', user over-ride of line speed */ u8 flowcontrol; /* flow control validated by the far-end */ /* Minimize init-time */ From a1c821ae6c63d9ac648374f4953295e350572d3c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 4 Sep 2011 11:24:43 +0100 Subject: [PATCH 0903/1519] staging: et131x: Update README file I believe that the driver is up to date with the latest network driver changes, so removing this line from the TODO to see if anyone else disagrees. Also all useless typecasts are now dead. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index c6bcc6a0573..7e846b2c26d 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,8 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - forward port for latest network driver changes - - kill useless typecasts (e.g. in et1310_phy.c) - alloc_etherdev is initializing memory with zero?!? - add_timer call in et131x_netdev.c is correct? - Add power saving functionality (suspend, sleep, resume) From 0900beae178a84e653d9088979cf3014babc097e Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Tue, 6 Sep 2011 15:02:11 +0200 Subject: [PATCH 0904/1519] staging: zram: fix zram locking Currently init_lock only prevents concurrent execution of zram_init_device() and zram_reset_device() but not zram_make_request() nor sysfs store functions. This patch changes init_lock into a rw_semaphore. A write lock is taken by init, reset and store functions, a read lock is taken by zram_make_request(). Also, avoids to release the lock before calling __zram_reset_device() for cleaning after a failed init, thus preventing any concurrent task to see an inconsistent state of zram. Signed-off-by: Jerome Marchand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 46 +++++++++++++++++++------------ drivers/staging/zram/zram_drv.h | 6 ++-- drivers/staging/zram/zram_sysfs.c | 18 ++++++++---- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index ec66b0a5873..6fb2be31b3f 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -560,27 +560,34 @@ static int zram_make_request(struct request_queue *queue, struct bio *bio) { struct zram *zram = queue->queuedata; + if (unlikely(!zram->init_done) && zram_init_device(zram)) + goto error; + + down_read(&zram->init_lock); + if (unlikely(!zram->init_done)) + goto error_unlock; + if (!valid_io_request(zram, bio)) { zram_stat64_inc(zram, &zram->stats.invalid_io); - bio_io_error(bio); - return 0; - } - - if (unlikely(!zram->init_done) && zram_init_device(zram)) { - bio_io_error(bio); - return 0; + goto error_unlock; } __zram_make_request(zram, bio, bio_data_dir(bio)); + up_read(&zram->init_lock); return 0; + +error_unlock: + up_read(&zram->init_lock); +error: + bio_io_error(bio); + return 0; } -void zram_reset_device(struct zram *zram) +void __zram_reset_device(struct zram *zram) { size_t index; - mutex_lock(&zram->init_lock); zram->init_done = 0; /* Free various per-device buffers */ @@ -617,7 +624,13 @@ void zram_reset_device(struct zram *zram) memset(&zram->stats, 0, sizeof(zram->stats)); zram->disksize = 0; - mutex_unlock(&zram->init_lock); +} + +void zram_reset_device(struct zram *zram) +{ + down_write(&zram->init_lock); + __zram_reset_device(zram); + up_write(&zram->init_lock); } int zram_init_device(struct zram *zram) @@ -625,10 +638,10 @@ int zram_init_device(struct zram *zram) int ret; size_t num_pages; - mutex_lock(&zram->init_lock); + down_write(&zram->init_lock); if (zram->init_done) { - mutex_unlock(&zram->init_lock); + up_write(&zram->init_lock); return 0; } @@ -671,15 +684,14 @@ int zram_init_device(struct zram *zram) } zram->init_done = 1; - mutex_unlock(&zram->init_lock); + up_write(&zram->init_lock); pr_debug("Initialization done!\n"); return 0; fail: - mutex_unlock(&zram->init_lock); - zram_reset_device(zram); - + __zram_reset_device(zram); + up_write(&zram->init_lock); pr_err("Initialization failed: err=%d\n", ret); return ret; } @@ -703,7 +715,7 @@ static int create_device(struct zram *zram, int device_id) int ret = 0; init_rwsem(&zram->lock); - mutex_init(&zram->init_lock); + init_rwsem(&zram->init_lock); spin_lock_init(&zram->stat64_lock); zram->queue = blk_alloc_queue(GFP_KERNEL); diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 59b01d602f4..7fdeb7d39ae 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -112,8 +112,8 @@ struct zram { struct request_queue *queue; struct gendisk *disk; int init_done; - /* Prevent concurrent execution of device init and reset */ - struct mutex init_lock; + /* Prevent concurrent execution of device init, reset and R/W request */ + struct rw_semaphore init_lock; /* * This is the limit on amount of *uncompressed* worth of data * we can store in a disk. @@ -130,6 +130,6 @@ extern struct attribute_group zram_disk_attr_group; #endif extern int zram_init_device(struct zram *zram); -extern void zram_reset_device(struct zram *zram); +extern void __zram_reset_device(struct zram *zram); #endif diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index df1f9dc4269..0ea8ed296a9 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -55,19 +55,23 @@ static ssize_t disksize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { int ret; + u64 disksize; struct zram *zram = dev_to_zram(dev); + ret = strict_strtoull(buf, 10, &disksize); + if (ret) + return ret; + + down_write(&zram->init_lock); if (zram->init_done) { + up_write(&zram->init_lock); pr_info("Cannot change disksize for initialized device\n"); return -EBUSY; } - ret = strict_strtoull(buf, 10, &zram->disksize); - if (ret) - return ret; - - zram->disksize = PAGE_ALIGN(zram->disksize); + zram->disksize = PAGE_ALIGN(disksize); set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); + up_write(&zram->init_lock); return len; } @@ -106,8 +110,10 @@ static ssize_t reset_store(struct device *dev, if (bdev) fsync_bdev(bdev); + down_write(&zram->init_lock); if (zram->init_done) - zram_reset_device(zram); + __zram_reset_device(zram); + up_write(&zram->init_lock); return len; } From 5a18c53147205797da3dbc5a7c2678d16709d2dc Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Tue, 6 Sep 2011 15:02:12 +0200 Subject: [PATCH 0905/1519] staging: zram: prevent accessing an unallocated table when init fails early When the allocation of zram->table fails, we set zram->disksize to zero to prevent accessing the unallocated table entries during cleanup. However, we currently don't take this precaution when the initialization fails earlier. Signed-off-by: Jerome Marchand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 6fb2be31b3f..dbb436863e7 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -651,24 +651,22 @@ int zram_init_device(struct zram *zram) if (!zram->compress_workmem) { pr_err("Error allocating compressor working memory!\n"); ret = -ENOMEM; - goto fail; + goto fail_no_table; } zram->compress_buffer = (void *)__get_free_pages(__GFP_ZERO, 1); if (!zram->compress_buffer) { pr_err("Error allocating compressor buffer space\n"); ret = -ENOMEM; - goto fail; + goto fail_no_table; } num_pages = zram->disksize >> PAGE_SHIFT; zram->table = vzalloc(num_pages * sizeof(*zram->table)); if (!zram->table) { pr_err("Error allocating zram address table\n"); - /* To prevent accessing table entries during cleanup */ - zram->disksize = 0; ret = -ENOMEM; - goto fail; + goto fail_no_table; } set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); @@ -689,6 +687,9 @@ int zram_init_device(struct zram *zram) pr_debug("Initialization done!\n"); return 0; +fail_no_table: + /* To prevent accessing table entries during cleanup */ + zram->disksize = 0; fail: __zram_reset_device(zram); up_write(&zram->init_lock); From cf3e6881e38d348c7eabcb354631ae646d115c1f Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:04 +0800 Subject: [PATCH 0906/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Copyright banners. Only copyright banners have been added to these files. No functional changes. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/basic_types.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/drv_types.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/ieee80211.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/osdep_intf.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/osdep_service.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl8712_cmd.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl8712_event.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl8712_recv.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl8712_xmit.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_cmd.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_debug.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_io.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_ioctl_rtl.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_led.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_mlme.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_mp.c | 26 ++++++++++++++------- drivers/staging/rtl8712/rtl871x_mp_ioctl.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_xmit.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/sta_info.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/wifi.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/wlan_bssdef.h | 25 ++++++++++++++++++++ drivers/staging/rtl8712/xmit_osdep.h | 25 ++++++++++++++++++++ 22 files changed, 543 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8712/basic_types.h b/drivers/staging/rtl8712/basic_types.h index a0538a8a670..7561bed5dd4 100644 --- a/drivers/staging/rtl8712/basic_types.h +++ b/drivers/staging/rtl8712/basic_types.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __BASIC_TYPES_H__ #define __BASIC_TYPES_H__ diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index c5303c3fda1..6e16d58332a 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ /*--------------------------------------------------------------------- For type defines and data structure defines diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index d62c6ac0955..d1d08681136 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __IEEE80211_H #define __IEEE80211_H diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h index 3bc20257b03..aa0ec74af51 100644 --- a/drivers/staging/rtl8712/osdep_intf.h +++ b/drivers/staging/rtl8712/osdep_intf.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __OSDEP_INTF_H_ #define __OSDEP_INTF_H_ diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index aac97bb8b80..e85774c1163 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __OSDEP_SERVICE_H_ #define __OSDEP_SERVICE_H_ diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h index 13ef0626b28..a4eecc6716a 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.h +++ b/drivers/staging/rtl8712/rtl8712_cmd.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __RTL8712_CMD_H_ #define __RTL8712_CMD_H_ diff --git a/drivers/staging/rtl8712/rtl8712_event.h b/drivers/staging/rtl8712/rtl8712_event.h index 27316934b1a..3d7f79efa2c 100644 --- a/drivers/staging/rtl8712/rtl8712_event.h +++ b/drivers/staging/rtl8712/rtl8712_event.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL8712_EVENT_H_ #define _RTL8712_EVENT_H_ diff --git a/drivers/staging/rtl8712/rtl8712_recv.h b/drivers/staging/rtl8712/rtl8712_recv.h index c48757f97da..1d6c9c73adb 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.h +++ b/drivers/staging/rtl8712/rtl8712_recv.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL8712_RECV_H_ #define _RTL8712_RECV_H_ diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h b/drivers/staging/rtl8712/rtl8712_xmit.h index 12a080f545a..1e8f3feffab 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.h +++ b/drivers/staging/rtl8712/rtl8712_xmit.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL8712_XMIT_H_ #define _RTL8712_XMIT_H_ diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index dcf256d44d1..25ef848dcc4 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __RTL871X_CMD_H_ #define __RTL871X_CMD_H_ diff --git a/drivers/staging/rtl8712/rtl871x_debug.h b/drivers/staging/rtl8712/rtl871x_debug.h index c392fd958e4..74468b05825 100644 --- a/drivers/staging/rtl8712/rtl871x_debug.h +++ b/drivers/staging/rtl8712/rtl871x_debug.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __RTL871X_DEBUG_H__ #define __RTL871X_DEBUG_H__ diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h index b70cb2b6296..86308a0093e 100644 --- a/drivers/staging/rtl8712/rtl871x_io.h +++ b/drivers/staging/rtl8712/rtl871x_io.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _IO_H_ #define _IO_H_ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h index 4f1aa876d75..3bcceae3cbe 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h +++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL871X_IOCTL_RTL_H #define _RTL871X_IOCTL_RTL_H diff --git a/drivers/staging/rtl8712/rtl871x_led.h b/drivers/staging/rtl8712/rtl871x_led.h index 8085e5eb82b..1a90c7f4d8f 100644 --- a/drivers/staging/rtl8712/rtl871x_led.h +++ b/drivers/staging/rtl8712/rtl871x_led.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __RTL8712_LED_H #define __RTL8712_LED_H diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h index 2794804d082..b8810a9d9dd 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.h +++ b/drivers/staging/rtl8712/rtl871x_mlme.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __RTL871X_MLME_H_ #define __RTL871X_MLME_H_ diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 41e00a2c862..5638d5e065f 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -1,18 +1,28 @@ /****************************************************************************** - * rtl871x_mp.c * - * Description : + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. * - * Author : + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. * - * History : + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * Copyright 2007, Realtek Corp. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * The contents of this file is the sole property of Realtek Corp. It can not be - * be used, copied or modified without written permission from Realtek Corp. + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. * -*******************************************************************************/ + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #define _RTL871X_MP_C_ #include "osdep_service.h" diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h index 67759c31b1d..b5ddcb6d6ec 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL871X_MP_IOCTL_H #define _RTL871X_MP_IOCTL_H diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index df13e67b3eb..63041008f94 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _RTL871X_XMIT_H_ #define _RTL871X_XMIT_H_ diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h index 79ad1593214..2ac8d330ca5 100644 --- a/drivers/staging/rtl8712/sta_info.h +++ b/drivers/staging/rtl8712/sta_info.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __STA_INFO_H_ #define __STA_INFO_H_ diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 427ab7e2705..277398cff0a 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef _WIFI_H_ #define _WIFI_H_ diff --git a/drivers/staging/rtl8712/wlan_bssdef.h b/drivers/staging/rtl8712/wlan_bssdef.h index 0d90e1f5b29..2ea8a3d6b70 100644 --- a/drivers/staging/rtl8712/wlan_bssdef.h +++ b/drivers/staging/rtl8712/wlan_bssdef.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __WLAN_BSSDEF_H__ #define __WLAN_BSSDEF_H__ diff --git a/drivers/staging/rtl8712/xmit_osdep.h b/drivers/staging/rtl8712/xmit_osdep.h index ca439378953..19f6f3c2777 100644 --- a/drivers/staging/rtl8712/xmit_osdep.h +++ b/drivers/staging/rtl8712/xmit_osdep.h @@ -1,3 +1,28 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Modifications for inclusion into the Linux staging tree are + * Copyright(c) 2010 Larry Finger. All rights reserved. + * + * Contact information: + * WLAN FAE + * Larry Finger + * + ******************************************************************************/ #ifndef __XMIT_OSDEP_H_ #define __XMIT_OSDEP_H_ From 7c1f4203a2883c50e2d754b176fcfcd5be34549b Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:05 +0800 Subject: [PATCH 0907/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Renamed _netdev_priv. Renamed _netdev_priv to netdev_priv. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 10 +-- drivers/staging/rtl8712/osdep_service.h | 5 -- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 68 +++++++++---------- drivers/staging/rtl8712/usb_intf.c | 2 +- drivers/staging/rtl8712/xmit_linux.c | 2 +- 5 files changed, 41 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 6697941e232..90949cfacd6 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -177,7 +177,7 @@ static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev) static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev); struct sockaddr *addr = p; if (padapter->bup == false) @@ -187,7 +187,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p) static struct net_device_stats *r871x_net_get_stats(struct net_device *pnetdev) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(pnetdev); struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct recv_priv *precvpriv = &(padapter->recvpriv); @@ -221,7 +221,7 @@ struct net_device *r8712_init_netdev(void) strcpy(ifname, "wlan%d"); dev_alloc_name(pnetdev, ifname); } - padapter = (struct _adapter *) _netdev_priv(pnetdev); + padapter = (struct _adapter *) netdev_priv(pnetdev); padapter->pnetdev = pnetdev; printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to" " netdev_ops\n"); @@ -383,7 +383,7 @@ static void enable_video_mode(struct _adapter *padapter, int cbw40_value) */ static int netdev_open(struct net_device *pnetdev) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev); if (padapter->bup == false) { padapter->bDriverStopped = false; @@ -448,7 +448,7 @@ netdev_open_error: */ static int netdev_close(struct net_device *pnetdev) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(pnetdev); /* Close LED*/ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_POWER_OFF); diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index e85774c1163..60e586c7d60 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -78,11 +78,6 @@ struct __queue { spin_lock_init(&((pqueue)->lock)); \ } while (0) -static inline void *_netdev_priv(struct net_device *dev) -{ - return netdev_priv(dev); -} - static inline void os_free_netdev(struct net_device *dev) { free_netdev(dev); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index d310a6174b9..ba700815ead 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -363,7 +363,7 @@ static inline char *translate_scan(struct _adapter *padapter, static int wpa_set_auth_algs(struct net_device *dev, u32 value) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); int ret = 0; if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { @@ -395,7 +395,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, int ret = 0; u32 wep_key_idx, wep_key_len = 0; struct NDIS_802_11_WEP *pwep = NULL; - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -637,7 +637,7 @@ static int r8711_wx_get_name(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); u32 ht_ielen = 0; char *p; u8 ht_cap = false; @@ -693,7 +693,7 @@ static int r8711_wx_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_freq *fwrq = &wrqu->freq; int rc = 0; @@ -727,7 +727,7 @@ static int r8711_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -745,7 +745,7 @@ static int r8711_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType; switch (wrqu->mode) { @@ -776,7 +776,7 @@ static int r8711_wx_set_mode(struct net_device *dev, static int r8711_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) @@ -795,7 +795,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct security_priv *psecuritypriv = &padapter->securitypriv; struct iw_pmksa *pPMK = (struct iw_pmksa *) extra; u8 strZeroMacAddress[ETH_ALEN] = {0x00}; @@ -989,7 +989,7 @@ static int r8711_wx_set_wap(struct net_device *dev, char *extra) { int ret = -EINPROGRESS; - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; struct sockaddr *temp = (struct sockaddr *)awrq; @@ -1039,7 +1039,7 @@ static int r8711_wx_get_wap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -1058,7 +1058,7 @@ static int r871x_wx_set_mlme(struct net_device *dev, { int ret = 0; u16 reason; - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *) extra; if (mlme == NULL) @@ -1091,7 +1091,7 @@ static int r8711_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 status = true; @@ -1139,7 +1139,7 @@ static int r8711_wx_get_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; @@ -1193,7 +1193,7 @@ static int r8711_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; @@ -1246,7 +1246,7 @@ static int r8711_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; u32 len, ret = 0; @@ -1265,7 +1265,7 @@ static int r8711_wx_set_rate(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; u32 ratevalue = 0; @@ -1337,7 +1337,7 @@ static int r8711_wx_get_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; struct ieee80211_ht_cap *pht_capie; @@ -1396,7 +1396,7 @@ static int r8711_wx_get_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); wrqu->rts.value = padapter->registrypriv.rts_thresh; wrqu->rts.fixed = 0; /* no auto select */ @@ -1407,7 +1407,7 @@ static int r8711_wx_set_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); if (wrqu->frag.disabled) padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; @@ -1424,7 +1424,7 @@ static int r8711_wx_get_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); wrqu->frag.value = padapter->xmitpriv.frag_len; wrqu->frag.fixed = 0; /* no auto select */ @@ -1450,7 +1450,7 @@ static int r8711_wx_set_enc(struct net_device *dev, struct NDIS_802_11_WEP wep; enum NDIS_802_11_AUTHENTICATION_MODE authmode; struct iw_point *erq = &(wrqu->encoding); - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); key = erq->flags & IW_ENCODE_INDEX; memset(&wep, 0, sizeof(struct NDIS_802_11_WEP)); @@ -1544,7 +1544,7 @@ static int r8711_wx_get_enc(struct net_device *dev, union iwreq_data *wrqu, char *keybuf) { uint key, ret = 0; - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -1616,7 +1616,7 @@ static int r871x_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); return r871x_set_wpa_ie(padapter, extra, wrqu->data.length); } @@ -1625,7 +1625,7 @@ static int r871x_wx_set_auth(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_param *param = (struct iw_param *)&(wrqu->param); int paramid; int paramval; @@ -1771,7 +1771,7 @@ static int r8711_wx_read32(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); u32 addr; u32 data32; @@ -1788,7 +1788,7 @@ static int r8711_wx_write32(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); u32 addr; u32 data32; @@ -1816,7 +1816,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_point *p = &wrqu->data; struct oid_par_priv oid_par; struct mp_ioctl_handler *phandler; @@ -1899,7 +1899,7 @@ static int r871x_get_ap_info(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; struct iw_point *pdata = &wrqu->data; @@ -1970,7 +1970,7 @@ static int r871x_set_pid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); struct iw_point *pdata = &wrqu->data; if ((padapter->bDriverStopped) || (pdata == NULL)) @@ -1984,7 +1984,7 @@ static int r871x_wps_start(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_point *pdata = &wrqu->data; u32 u32wps_start = 0; @@ -2008,7 +2008,7 @@ static int r871x_wps_start(struct net_device *dev, static int wpa_set_param(struct net_device *dev, u8 name, u32 value) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); switch (name) { case IEEE_PARAM_WPA_ENABLED: @@ -2061,7 +2061,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); switch (command) { case IEEE_MLME_STA_DEAUTH: @@ -2082,7 +2082,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) { struct ieee_param *param; int ret = 0; - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); if (p->length < sizeof(struct ieee_param) || !p->pointer) return -EINVAL; @@ -2234,7 +2234,7 @@ static iw_handler r8711_private_handler[] = { static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev) { - struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev); + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); struct iw_statistics *piwstats = &padapter->iwstats; int tmp_level = 0; int tmp_qual = 0; diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 21ce2af447b..e590ebd3a45 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -378,7 +378,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, pnetdev = r8712_init_netdev(); if (!pnetdev) goto error; - padapter = (struct _adapter *)_netdev_priv(pnetdev); + padapter = (struct _adapter *)netdev_priv(pnetdev); disable_ht_for_spec_devid(pdid, padapter); pdvobjpriv = &padapter->dvobjpriv; pdvobjpriv->padapter = padapter; diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 7dea8b5b7e7..3efebeb4bcc 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -146,7 +146,7 @@ void r8712_xmit_complete(struct _adapter *padapter, struct xmit_frame *pxframe) int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev) { struct xmit_frame *pxmitframe = NULL; - struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev); + struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev); struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); int ret = 0; From 7bcd9ce6de23fc11c7cfe42b4d541922b77d6867 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:06 +0800 Subject: [PATCH 0908/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Removed os_free_netdev. Replaced (Realtek's) os_free_netdev by (linux's own) free_netdev. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 2 +- drivers/staging/rtl8712/osdep_service.h | 5 ----- drivers/staging/rtl8712/usb_intf.c | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 90949cfacd6..a46d4bb567a 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -348,7 +348,7 @@ u8 r8712_free_drv_sw(struct _adapter *padapter) _r8712_free_recv_priv(&padapter->recvpriv); mp871xdeinit(padapter); if (pnetdev) - os_free_netdev(pnetdev); + free_netdev(pnetdev); return _SUCCESS; } diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 60e586c7d60..799ebaca2da 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -78,11 +78,6 @@ struct __queue { spin_lock_init(&((pqueue)->lock)); \ } while (0) -static inline void os_free_netdev(struct net_device *dev) -{ - free_netdev(dev); -} - static inline struct list_head *get_next(struct list_head *list) { return list->next; diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index e590ebd3a45..263a4b510ed 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -599,7 +599,7 @@ error: if (padapter->dvobj_deinit != NULL) padapter->dvobj_deinit(padapter); if (pnetdev) - os_free_netdev(pnetdev); + free_netdev(pnetdev); return -ENODEV; } From 68e9b249565ef2786eee2b4676c8f04c8154215d Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:07 +0800 Subject: [PATCH 0909/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Removed _usb_alloc_urb. Replaced (Realtek's) _usb_alloc_urb by (linux's own) usb_alloc_urb. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 1 - drivers/staging/rtl8712/recv_linux.c | 2 +- drivers/staging/rtl8712/usb_ops_linux.c | 2 +- drivers/staging/rtl8712/xmit_linux.c | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 799ebaca2da..72bb19520b4 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -58,7 +58,6 @@ #include "ethernet.h" #include #include -#define _usb_alloc_urb(x, y) usb_alloc_urb(x, y) #define _usb_submit_urb(x, y) usb_submit_urb(x, y) struct __queue { diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 1f0949ed7ee..1e5c59be3a2 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -51,7 +51,7 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter, int res = _SUCCESS; precvbuf->irp_pending = false; - precvbuf->purb = _usb_alloc_urb(0, GFP_KERNEL); + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); if (precvbuf->purb == NULL) res = _FAIL; precvbuf->pskb = NULL; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 7933ea4f632..509b81a98d4 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -48,7 +48,7 @@ struct zero_bulkout_context { uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv) { - pintfpriv->piorw_urb = _usb_alloc_urb(0, GFP_ATOMIC); + pintfpriv->piorw_urb = usb_alloc_urb(0, GFP_ATOMIC); if (!pintfpriv->piorw_urb) return _FAIL; sema_init(&(pintfpriv->io_retevt), 0); diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 3efebeb4bcc..6b7987d3a1c 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -113,7 +113,7 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter, int i; for (i = 0; i < 8; i++) { - pxmitbuf->pxmit_urb[i] = _usb_alloc_urb(0, GFP_KERNEL); + pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); if (pxmitbuf->pxmit_urb[i] == NULL) { printk(KERN_ERR "r8712u: pxmitbuf->pxmit_urb[i]" " == NULL"); From 302d37a4b333d8252ba386554a90809833092cba Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:08 +0800 Subject: [PATCH 0910/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Removed _usb_submit_urb. Replaced (Realtek's) _usb_submit_urb by (linux's own) usb_submit_urb. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 1 - drivers/staging/rtl8712/usb_ops_linux.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 72bb19520b4..4847a68d595 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -58,7 +58,6 @@ #include "ethernet.h" #include #include -#define _usb_submit_urb(x, y) usb_submit_urb(x, y) struct __queue { struct list_head queue; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 509b81a98d4..54757dd2114 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -187,7 +187,7 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) usb_fill_bulk_urb(piorw_urb, pusbd, pipe, wmem, cnt, usb_write_mem_complete, pio_queue); - status = _usb_submit_urb(piorw_urb, GFP_ATOMIC); + status = usb_submit_urb(piorw_urb, GFP_ATOMIC); _down_sema(&pintfpriv->io_retevt); } @@ -305,7 +305,7 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) precvbuf->pbuf, MAX_RECVBUF_SZ, r8712_usb_read_port_complete, precvbuf); - err = _usb_submit_urb(purb, GFP_ATOMIC); + err = usb_submit_urb(purb, GFP_ATOMIC); if ((err) && (err != (-EPERM))) ret = _FAIL; } else @@ -462,7 +462,7 @@ u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) pxmitframe->mem_addr, cnt, usb_write_port_complete, pxmitframe); /* context is xmit_frame */ - status = _usb_submit_urb(purb, GFP_ATOMIC); + status = usb_submit_urb(purb, GFP_ATOMIC); if (!status) ret = _SUCCESS; else From 7568ac94fa4e776a69603916b759d341d98423d9 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:09 +0800 Subject: [PATCH 0911/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Removed unused MSECS. MSECS was never used in this driver. So removed. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 4847a68d595..66195601e71 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -68,7 +68,6 @@ struct __queue { #define _buffer unsigned char #define thread_exit() complete_and_exit(NULL, 0) #define _workitem struct work_struct -#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) #define _init_queue(pqueue) \ do { \ From 99f5ff39d24915533d5bcf557e75116c706bd6dd Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:10 +0800 Subject: [PATCH 0912/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Redundant NULL check. Removed the redundant NULL check in LedControl871x. As noted by Dan Carpenter, the address of a stack variable is never NULL. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index cb1751e95f0..bac56e5caf1 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -1786,7 +1786,7 @@ void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &(padapter->ledpriv); - if (ledpriv == NULL || ledpriv->bRegUseLed == false) + if (ledpriv->bRegUseLed == false) return; switch (ledpriv->LedStrategy) { case SW_LED_MODE0: From 359140aaea5bc3123356d46d0daa9dac8cfb12bc Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:11 +0800 Subject: [PATCH 0913/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Updated include directives. These are the new include directives for header files. The following were (somehow!) not explicity in Realtek's, but proved necessary: "linux/usb.h" is needed for usb_alloc_urb(); "linux/interrupt.h" is needed for tasklet_struct. It was often a nested include. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 5 ++++ drivers/staging/rtl8712/osdep_service.h | 30 +++++-------------- drivers/staging/rtl8712/recv_linux.c | 4 +++ drivers/staging/rtl8712/rtl8712_cmd.c | 18 +++++++++++ drivers/staging/rtl8712/rtl871x_cmd.c | 18 +++++++++++ drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 9 ++++++ drivers/staging/rtl8712/rtl871x_security.c | 15 ++++++++++ drivers/staging/rtl8712/usb_intf.c | 2 ++ drivers/staging/rtl8712/usb_ops_linux.c | 2 ++ drivers/staging/rtl8712/xmit_linux.c | 2 ++ 10 files changed, 82 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 1411c7bf0d4..1bd9c374a5f 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -28,6 +28,11 @@ #define _HAL_INIT_C_ +#include +#include +#include +#include + #include "osdep_service.h" #include "drv_types.h" #include "rtl871x_byteorder.h" diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 66195601e71..1ee943a58c4 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -29,35 +29,19 @@ #define _SUCCESS 1 #define _FAIL 0 -#include "basic_types.h" +#include #include + +#include #include +#include #include #include #include #include -#include /* Necessary because we use the proc fs */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ethernet.h" -#include -#include +#include /* Necessary because we use the proc fs */ + +#include "basic_types.h" struct __queue { struct list_head queue; diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 1e5c59be3a2..0e26d5f6cf2 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -28,11 +28,15 @@ #define _RECV_OSDEP_C_ +#include + #include "osdep_service.h" #include "drv_types.h" #include "wifi.h" #include "recv_osdep.h" #include "osdep_intf.h" +#include "ethernet.h" +#include #include "usb_ops.h" /*init os related resource in struct recv_priv*/ diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 26c605e8cd6..9f6ebc419b0 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -28,6 +28,24 @@ #define _RTL8712_CMD_C_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "osdep_service.h" #include "drv_types.h" #include "recv_osdep.h" diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index ba92762dbb1..e188d8dcfde 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -28,6 +28,24 @@ #define _RTL871X_CMD_C_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "osdep_service.h" #include "drv_types.h" #include "recv_osdep.h" diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index ba700815ead..ec58b6636fa 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -39,6 +39,15 @@ #include "rtl871x_ioctl_set.h" #include "rtl871x_mp_ioctl.h" #include "mlme_osdep.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 65321bed4d5..7b92927a04d 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -28,6 +28,21 @@ #define _RTL871X_SECURITY_C_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "osdep_service.h" #include "drv_types.h" #include "wifi.h" diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 263a4b510ed..3447d755a60 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -28,6 +28,8 @@ #define _HCI_INTF_C_ +#include + #include "osdep_service.h" #include "drv_types.h" #include "recv_osdep.h" diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 54757dd2114..b796c6bb593 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -28,6 +28,8 @@ #define _HCI_OPS_OS_C_ +#include + #include "osdep_service.h" #include "drv_types.h" #include "osdep_intf.h" diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 6b7987d3a1c..d3535ba5dd4 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -28,6 +28,8 @@ #define _XMIT_OSDEP_C_ +#include + #include "osdep_service.h" #include "drv_types.h" From 29e75494236459d6259bc4a019129574f1f72733 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:12 +0800 Subject: [PATCH 0914/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Removed redundant .mem. recv_frame.mem mp_xmit_frame.mem mp_xmit_packet.mem were not used, and so are now removed. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.h | 1 - drivers/staging/rtl8712/rtl871x_mp.h | 1 - drivers/staging/rtl8712/rtl871x_mp_ioctl.h | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_recv.h b/drivers/staging/rtl8712/rtl8712_recv.h index 1d6c9c73adb..6626c8ffe71 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.h +++ b/drivers/staging/rtl8712/rtl8712_recv.h @@ -140,7 +140,6 @@ union recv_frame { union { struct list_head list; struct recv_frame_hdr hdr; - addr_t mem[RECVFRAME_HDR_ALIGN>>2]; } u; }; diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h index a42d4f40d14..255dc94f090 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.h +++ b/drivers/staging/rtl8712/rtl871x_mp.h @@ -126,7 +126,6 @@ struct mp_xmit_frame { struct urb *pxmit_urb[8]; u8 bpending[8]; u8 last[8]; - uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; }; struct mp_wiparam { diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h index b5ddcb6d6ec..1c38a111bfd 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h @@ -332,7 +332,6 @@ struct rfintfs_parm { struct mp_xmit_packet { unsigned int len; - unsigned int mem[MAX_MP_XMITBUF_SZ >> 2]; }; struct psmode_param { From ac9bfc14ad3123f636dee049a5a64b94def2a273 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:13 +0800 Subject: [PATCH 0915/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). No power tracking OID. The call to oid_rt_pro_set_power_tracking_hdl() is no longer available. The function's definition remains, though it is currently unused. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp_ioctl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h index 1c38a111bfd..850143d5dee 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h @@ -434,8 +434,7 @@ static struct mp_ioctl_handler mp_ioctl_hdl[] = { {sizeof(struct psmode_param), NULL, 0},/*13*/ {sizeof(struct eeprom_rw_param), NULL, 0},/*14*/ {sizeof(struct eeprom_rw_param), NULL, 0},/*15*/ - {sizeof(u8), oid_rt_pro_set_power_tracking_hdl, - OID_RT_PRO_SET_POWER_TRACKING},/*16*/ + {sizeof(unsigned char), NULL, 0},/*16*/ {sizeof(u32), NULL, 0},/*17*/ {sizeof(u32), oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX},/*18*/ From 6c19d86b9bd03d32d727d0b1d56a0716dfe6eb83 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:14 +0800 Subject: [PATCH 0916/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). stop_drv_timers moved. stop_drv_timers() is now done in r871xu_dev_remove(), not netdev_close(). Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 4 +--- drivers/staging/rtl8712/usb_intf.c | 2 ++ drivers/staging/rtl8712/usb_osintf.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index a46d4bb567a..961d6e5a26c 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -261,7 +261,7 @@ static void start_drv_timers(struct _adapter *padapter) _set_timer(&padapter->mlmepriv.wdg_timer, 2000); } -static void stop_drv_timers(struct _adapter *padapter) +void r8712_stop_drv_timers(struct _adapter *padapter) { _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); _cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl. @@ -468,8 +468,6 @@ static int netdev_close(struct net_device *pnetdev) r8712_free_assoc_resources(padapter); /*s2-4.*/ r8712_free_network_queue(padapter); - /*Stop driver mlme relation timer*/ - stop_drv_timers(padapter); /* The interface is no longer Up: */ padapter->bup = false; return 0; diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 3447d755a60..3bcb669a7ea 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -622,6 +622,8 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) } flush_scheduled_work(); udelay(1); + /*Stop driver mlme relation timer */ + r8712_stop_drv_timers(padapter); r871x_dev_unload(padapter); r8712_free_drv_sw(padapter); } diff --git a/drivers/staging/rtl8712/usb_osintf.h b/drivers/staging/rtl8712/usb_osintf.h index d397a82986d..d95797aac37 100644 --- a/drivers/staging/rtl8712/usb_osintf.h +++ b/drivers/staging/rtl8712/usb_osintf.h @@ -42,6 +42,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter); void rtl871x_intf_stop(struct _adapter *padapter); void r871x_dev_unload(struct _adapter *padapter); void r8712_stop_drv_threads(struct _adapter *padapter); +void r8712_stop_drv_timers(struct _adapter *padapter); u8 r8712_init_drv_sw(struct _adapter *padapter); u8 r8712_free_drv_sw(struct _adapter *padapter); struct net_device *r8712_init_netdev(void); From c13b6f24986de17b29a56be7b6b851d565f455fa Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:15 +0800 Subject: [PATCH 0917/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Use stack, not malloc. translate_scan() now uses the stack for some variables, instead of mallocing. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index ec58b6636fa..45225530c35 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -169,10 +169,6 @@ static inline char *translate_scan(struct _adapter *padapter, struct iw_event iwe; struct ieee80211_ht_cap *pht_capie; char *current_val; - u8 *buf = (u8 *)_malloc(pnetwork->network.IELength * 2); - u8 *wpa_ie = (u8 *)_malloc(255); - u8 *rsn_ie = (u8 *)_malloc(255); - u8 *wps_ie = (u8 *)_malloc(MAX_WPS_IE_LEN); s8 *p; u32 i = 0, ht_ielen = 0; u16 cap, ht_cap = false, mcs_rate; @@ -289,6 +285,8 @@ static inline char *translate_scan(struct _adapter *padapter, start = current_val; /* parsing WPA/WPA2 IE */ { + u8 buf[MAX_WPA_IE_LEN]; + u8 wpa_ie[255], rsn_ie[255]; u16 wpa_len = 0, rsn_len = 0; int n; sint out_len = 0; @@ -339,6 +337,7 @@ static inline char *translate_scan(struct _adapter *padapter, } { /* parsing WPS IE */ + u8 wps_ie[512]; uint wps_ielen; if (r8712_get_wps_ie(pnetwork->network.IEs, @@ -363,10 +362,6 @@ static inline char *translate_scan(struct _adapter *padapter, iwe.u.qual.noise = 0; /* noise level */ start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); /* how to translate rssi to ?% */ - kfree(buf); - kfree(wpa_ie); - kfree(rsn_ie); - kfree(wps_ie); return start; } From 07a6b03707d3e6c5e1de2869a79b0bdca97ee2ac Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:16 +0800 Subject: [PATCH 0918/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Tx-code refactoring. Refactor the TX code to prepare for aggregation. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_xmit.c | 48 +++++++++++++------------- drivers/staging/rtl8712/rtl871x_xmit.c | 17 +++++++-- drivers/staging/rtl8712/rtl871x_xmit.h | 5 +++ 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index 88a15049bc2..c1e478465ad 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -423,31 +423,31 @@ int r8712_xmitframe_complete(struct _adapter *padapter, if (!pxmitbuf) return false; } - do { - pxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, hwentry); - if (pxmitframe) { - pxmitframe->pxmitbuf = pxmitbuf; - pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; - pxmitframe->buf_addr = pxmitbuf->pbuf; - if (pxmitframe->frame_tag == DATA_FRAMETAG) { - if (pxmitframe->attrib.priority <= 15) - res = r8712_xmitframe_coalesce(padapter, - pxmitframe->pkt, pxmitframe); - /* always return ndis_packet after - * r8712_xmitframe_coalesce */ - r8712_xmit_complete(padapter, pxmitframe); - } - if (res == _SUCCESS) - dump_xframe(padapter, pxmitframe); - else - r8712_free_xmitframe_ex(pxmitpriv, pxmitframe); - xcnt++; - } else { - r8712_free_xmitbuf(pxmitpriv, pxmitbuf); - return false; + /* 1st frame dequeued */ + pxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, hwentry); + /* need to remember the 1st frame */ + if (pxmitframe != NULL) { + + + xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); + if (pxmitframe->frame_tag == DATA_FRAMETAG) { + if (pxmitframe->attrib.priority <= 15) + res = r8712_xmitframe_coalesce(padapter, + pxmitframe->pkt, pxmitframe); + /* always return ndis_packet after + * r8712_xmitframe_coalesce */ + r8712_xmit_complete(padapter, pxmitframe); } - break; - } while (0); + if (res == _SUCCESS) + dump_xframe(padapter, pxmitframe); + else + r8712_free_xmitframe_ex(pxmitpriv, pxmitframe); + xcnt++; + + } else { /* pxmitframe == NULL && p2ndxmitframe == NULL */ + r8712_free_xmitbuf(pxmitpriv, pxmitbuf); + return false; + } return true; } diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index ccf08911f58..073493b30f4 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -1011,6 +1011,19 @@ static void init_hwxmits(struct hw_xmit *phwxmit, sint entry) } } +void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe, + struct xmit_buf *pxmitbuf) +{ + /* pxmitbuf attach to pxmitframe */ + pxmitframe->pxmitbuf = pxmitbuf; + /* urb and irp connection */ + pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; + /* buffer addr assoc */ + pxmitframe->buf_addr = pxmitbuf->pbuf; + /* pxmitframe attach to pxmitbuf */ + pxmitbuf->priv_data = pxmitframe; +} + /* * tx_action == 0 == no frames to transmit * tx_action > 0 ==> we have frames to transmit @@ -1042,9 +1055,7 @@ int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe) } else { /*dump packet directly*/ spin_unlock_irqrestore(&pxmitpriv->lock, irqL); ret = true; - pxmitframe->pxmitbuf = pxmitbuf; - pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; - pxmitframe->buf_addr = pxmitbuf->pbuf; + xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); r8712_xmit_direct(padapter, pxmitframe); } return ret; diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index 63041008f94..81987788917 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -135,7 +135,9 @@ struct xmit_buf { u8 *pallocated_buf; u8 *pbuf; + void *priv_data; struct urb *pxmit_urb[8]; + u32 aggr_nr; }; struct xmit_frame { @@ -280,6 +282,9 @@ int r8712_xmit_enqueue(struct _adapter *padapter, int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe); void r8712_xmit_bh(void *priv); +void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe, + struct xmit_buf *pxmitbuf); + #include "rtl8712_xmit.h" #endif /*_RTL871X_XMIT_H_*/ From 0aeb623d376c05a8618bf10418b9a0cb2b43e944 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:17 +0800 Subject: [PATCH 0919/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Rework efuse data handling. Rework efuse data handling. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_efuse.c | 75 ++++++++++++++----------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c index 1dc12b7a2f5..b08e9a25c9c 100644 --- a/drivers/staging/rtl8712/rtl8712_efuse.c +++ b/drivers/staging/rtl8712/rtl8712_efuse.c @@ -307,21 +307,25 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) continue; } for (i = 0; i < PGPKG_MAX_WORDS; i++) { - if (BIT(i) & word_en) - continue; - if (!(BIT(i) & pkt.word_en)) { - if (efuse_one_byte_read(padapter, addr, - &value) == true) - pkt.data[i*2] = value; - else - return false; - if (efuse_one_byte_read(padapter, addr + 1, - &value) == true) - pkt.data[i*2 + 1] = value; - else - return false; + if (BIT(i) & word_en) { + if (BIT(i) & pkt.word_en) { + if (efuse_one_byte_read( + padapter, addr, + &value) == true) + pkt.data[i*2] = value; + else + return false; + if (efuse_one_byte_read( + padapter, + addr + 1, + &value) == true) + pkt.data[i*2 + 1] = + value; + else + return false; + } + addr += 2; } - addr += 2; } } if (addr != header_addr) @@ -329,26 +333,29 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) addr++; /* fill original data */ for (i = 0; i < PGPKG_MAX_WORDS; i++) { - if (BIT(i) & pkt.word_en) - continue; - efuse_one_byte_write(padapter, addr, pkt.data[i*2]); - efuse_one_byte_write(padapter, addr+1, pkt.data[i*2 + 1]); - /* additional check */ - if (efuse_one_byte_read(padapter, addr, &value) == false) - ret = false; - else if (pkt.data[i*2] != value) { - ret = false; - if (0xFF == value) /* write again */ - efuse_one_byte_write(padapter, addr, - pkt.data[i * 2]); - } - if (efuse_one_byte_read(padapter, addr+1, &value) == false) - ret = false; - else if (pkt.data[i*2 + 1] != value) { - ret = false; - if (0xFF == value) /* write again */ - efuse_one_byte_write(padapter, addr+1, - pkt.data[i*2 + 1]); + if (BIT(i) & pkt.word_en) { + efuse_one_byte_write(padapter, addr, pkt.data[i*2]); + efuse_one_byte_write(padapter, addr+1, + pkt.data[i*2 + 1]); + /* additional check */ + if (efuse_one_byte_read(padapter, addr, &value) + == false) + ret = false; + else if (pkt.data[i*2] != value) { + ret = false; + if (0xFF == value) /* write again */ + efuse_one_byte_write(padapter, addr, + pkt.data[i * 2]); + } + if (efuse_one_byte_read(padapter, addr+1, &value) == + false) + ret = false; + else if (pkt.data[i*2 + 1] != value) { + ret = false; + if (0xFF == value) /* write again */ + efuse_one_byte_write(padapter, addr+1, + pkt.data[i*2 + 1]); + } } addr += 2; } From f95302eed91061d1d9440d572166e46d58d35b7c Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:18 +0800 Subject: [PATCH 0920/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). tx: NULL _in_ spin lock. In transmit path, r8712_free_xmitframe(), the pkt pointer is now NULLed _within_ the spin lock. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 3 +++ drivers/staging/rtl8712/rtl871x_xmit.c | 14 +++++++++----- drivers/staging/rtl8712/xmit_linux.c | 21 ++++++++++++++++++++- drivers/staging/rtl8712/xmit_osdep.h | 1 + 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 6e16d58332a..9b5d771e650 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -181,6 +181,9 @@ struct _adapter { struct net_device_stats stats; struct iw_statistics iwstats; int pid; /*process id from UI*/ + _workitem wkFilterRxFF0; + u8 blnEnableRxFF0Filter; + spinlock_t lockRxFF0Filter; }; static inline u8 *myid(struct eeprom_priv *peepriv) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 073493b30f4..8bbdee70f86 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -152,11 +152,12 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, pxmitbuf++; } pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; + _init_workitem(&padapter->wkFilterRxFF0, r8712_SetFilter, padapter); alloc_hwxmits(padapter); init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(addr_t))r8712_xmit_bh, - (addr_t)padapter); + (void(*)(unsigned long))r8712_xmit_bh, + (unsigned long)padapter); return _SUCCESS; } @@ -612,7 +613,7 @@ sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt, if (make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) return _FAIL; _r8712_open_pktfile(pkt, &pktfile); - _r8712_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen); + _r8712_pktfile_read(&pktfile, NULL, (uint) pattrib->pkt_hdrlen); if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { /* truncate TXDESC_SIZE bytes txcmd if at mp mode for 871x */ if (pattrib->ether_type == 0x8712) { @@ -826,13 +827,16 @@ void r8712_free_xmitframe(struct xmit_priv *pxmitpriv, unsigned long irqL; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; struct _adapter *padapter = pxmitpriv->adapter; + struct sk_buff *pndis_pkt = NULL; if (pxmitframe == NULL) return; - if (pxmitframe->pkt) - r8712_xmit_complete(padapter, pxmitframe); spin_lock_irqsave(&pfree_xmit_queue->lock, irqL); list_delete(&pxmitframe->list); + if (pxmitframe->pkt) { + pndis_pkt = pxmitframe->pkt; + pxmitframe->pkt = NULL; + } list_insert_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); pxmitpriv->free_xmitframe_cnt++; spin_unlock_irqrestore(&pfree_xmit_queue->lock, irqL); diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index d3535ba5dd4..c9703627c8f 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -44,7 +44,6 @@ static uint remainder_len(struct pkt_file *pfile) { - /* Kovich: Need to extend the buf_len to 64 bit ?(unsigned long long) */ return (uint)(pfile->buf_len - ((addr_t)(pfile->cur_addr) - (addr_t)(pfile->buf_start))); } @@ -109,6 +108,26 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) pattrib->subtype = WIFI_QOS_DATA_TYPE; } +void r8712_SetFilter(struct work_struct *work) +{ + struct _adapter *padapter = container_of(work, struct _adapter, + wkFilterRxFF0); + u8 oldvalue = 0x00, newvalue = 0x00; + unsigned long irqL; + + oldvalue = r8712_read8(padapter, 0x117); + newvalue = oldvalue & 0xfe; + r8712_write8(padapter, 0x117, newvalue); + + spin_lock_irqsave(&padapter->lockRxFF0Filter, irqL); + padapter->blnEnableRxFF0Filter = 1; + spin_unlock_irqrestore(&padapter->lockRxFF0Filter, irqL); + do { + msleep(100); + } while (padapter->blnEnableRxFF0Filter == 1); + r8712_write8(padapter, 0x117, oldvalue); +} + int r8712_xmit_resource_alloc(struct _adapter *padapter, struct xmit_buf *pxmitbuf) { diff --git a/drivers/staging/rtl8712/xmit_osdep.h b/drivers/staging/rtl8712/xmit_osdep.h index 19f6f3c2777..8eba7ca0dde 100644 --- a/drivers/staging/rtl8712/xmit_osdep.h +++ b/drivers/staging/rtl8712/xmit_osdep.h @@ -47,6 +47,7 @@ struct xmit_frame; struct xmit_buf; int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev); +void r8712_SetFilter(struct work_struct *work); int r8712_xmit_resource_alloc(struct _adapter *padapter, struct xmit_buf *pxmitbuf); void r8712_xmit_resource_free(struct _adapter *padapter, From f15abb8b2051fb99bebcdb45a21e97b20b665872 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:19 +0800 Subject: [PATCH 0921/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). New decl's and defines. Removed unnecessary casts in kfree calls. A few new types, defines and prototypes. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_cmd.h | 62 +++++++++++++++++++++++++++ drivers/staging/rtl8712/rtl871x_cmd.c | 13 +++++- drivers/staging/rtl8712/rtl871x_cmd.h | 4 ++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h index a4eecc6716a..766a6463266 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.h +++ b/drivers/staging/rtl8712/rtl8712_cmd.h @@ -26,9 +26,15 @@ #ifndef __RTL8712_CMD_H_ #define __RTL8712_CMD_H_ +#define CMD_HDR_SZ 8 + u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd); void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag); +struct cmd_hdr { + u32 cmd_dw0; + u32 cmd_dw1; +}; enum rtl8712_h2c_cmd { GEN_CMD_CODE(_Read_MACREG), /*0*/ @@ -97,6 +103,40 @@ enum rtl8712_h2c_cmd { GEN_CMD_CODE(_SetPowerTracking), GEN_CMD_CODE(_AMSDU_TO_AMPDU), /*57*/ GEN_CMD_CODE(_SetMacAddress), /*58*/ + + GEN_CMD_CODE(_DisconnectCtrl), /*59*/ + GEN_CMD_CODE(_SetChannelPlan), /*60*/ + GEN_CMD_CODE(_DisconnectCtrlEx), /*61*/ + + /* To do, modify these h2c cmd, add or delete */ + GEN_CMD_CODE(_GetH2cLbk) , + + /* WPS extra IE */ + GEN_CMD_CODE(_SetProbeReqExtraIE) , + GEN_CMD_CODE(_SetAssocReqExtraIE) , + GEN_CMD_CODE(_SetProbeRspExtraIE) , + GEN_CMD_CODE(_SetAssocRspExtraIE) , + + /* the following is driver will do */ + GEN_CMD_CODE(_GetCurDataRate) , + + GEN_CMD_CODE(_GetTxRetrycnt), /* to record times that Tx retry to + * transmmit packet after association + */ + GEN_CMD_CODE(_GetRxRetrycnt), /* to record total number of the + * received frame with ReTry bit set in + * the WLAN header + */ + + GEN_CMD_CODE(_GetBCNOKcnt), + GEN_CMD_CODE(_GetBCNERRcnt), + GEN_CMD_CODE(_GetCurTxPwrLevel), + + GEN_CMD_CODE(_SetDIG), + GEN_CMD_CODE(_SetRA), + GEN_CMD_CODE(_SetPT), + GEN_CMD_CODE(_ReadTSSI), + MAX_H2CCMD }; @@ -176,6 +216,28 @@ static struct _cmd_callback cmd_callback[] = { {GEN_CMD_CODE(_SetPowerTracking), NULL}, {GEN_CMD_CODE(_AMSDU_TO_AMPDU), NULL}, /*57*/ {GEN_CMD_CODE(_SetMacAddress), NULL}, /*58*/ + + {GEN_CMD_CODE(_DisconnectCtrl), NULL}, /*59*/ + {GEN_CMD_CODE(_SetChannelPlan), NULL}, /*60*/ + {GEN_CMD_CODE(_DisconnectCtrlEx), NULL}, /*61*/ + + /* To do, modify these h2c cmd, add or delete */ + {GEN_CMD_CODE(_GetH2cLbk), NULL}, + + {_SetProbeReqExtraIE_CMD_, NULL}, + {_SetAssocReqExtraIE_CMD_, NULL}, + {_SetProbeRspExtraIE_CMD_, NULL}, + {_SetAssocRspExtraIE_CMD_, NULL}, + {_GetCurDataRate_CMD_, NULL}, + {_GetTxRetrycnt_CMD_, NULL}, + {_GetRxRetrycnt_CMD_, NULL}, + {_GetBCNOKcnt_CMD_, NULL}, + {_GetBCNERRcnt_CMD_, NULL}, + {_GetCurTxPwrLevel_CMD_, NULL}, + {_SetDIG_CMD_, NULL}, + {_SetRA_CMD_, NULL}, + {_SetPT_CMD_, NULL}, + {GEN_CMD_CODE(_ReadTSSI), &r8712_readtssi_cmdrsp_callback} }; #endif diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index e188d8dcfde..c416ee3151e 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -371,8 +371,17 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd) { - kfree((unsigned char *) pcmd->parmbuf); - kfree((unsigned char *) pcmd); + kfree(pcmd->parmbuf); + kfree(pcmd); + padapter->mppriv.workparam.bcompleted = true; +} + +void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter, + struct cmd_obj *pcmd) +{ + kfree(pcmd->parmbuf); + kfree(pcmd); + padapter->mppriv.workparam.bcompleted = true; } diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 25ef848dcc4..2aab78aaf33 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -728,10 +728,14 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd); void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd); +void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter, + struct cmd_obj *pcmd); void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd); void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd); +u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, + u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO); struct _cmd_callback { u32 cmd_code; From c6dc001f2add6d6609f94246bbec30d81494f5f7 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:20 +0800 Subject: [PATCH 0922/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Various fixes. passive_mode added to private ioctls. New private ioctls added for RSSI, link speed, mac address, scan type, and DCE-D. In r8711_wx_get_scan(), we now sleep only 100 times, instead of 1000. In r8711_wx_set_essid(), added a check for Ad-Hoc state. In r8711_wx_get_rate(), added a check for RTL8712_RF_2T2R RF type. Added Set chplan. In r871x_get_wireless_stats(), updated the mechanism for displaying link quality. Added SetDIG and SetRA commands. r8712_joinbss_cmd() no longer checks for Ad-Hoc mode. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 111 ++++++++++++-- drivers/staging/rtl8712/rtl871x_cmd.h | 48 +++++- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 144 +++++++++++++++++- drivers/staging/rtl8712/rtl871x_mlme.h | 3 +- 4 files changed, 283 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index c416ee3151e..2d8f48c2c52 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -277,6 +277,28 @@ u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) return _SUCCESS; } +u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) +{ + struct cmd_obj *ph2c; + struct SetChannelPlan_param *psetchplanpara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + psetchplanpara = (struct SetChannelPlan_param *) + _malloc(sizeof(struct SetChannelPlan_param)); + if (psetchplanpara == NULL) { + kfree((u8 *) ph2c); + return _FAIL; + } + init_h2fwcmd_w_parm_no_rsp(ph2c, psetchplanpara, + GEN_CMD_CODE(_SetChannelPlan)); + psetchplanpara->ChannelPlan = chplan; + r8712_enqueue_cmd(pcmdpriv, ph2c); + return _SUCCESS; +} + u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) { struct cmd_obj *ph2c; @@ -303,20 +325,62 @@ u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type) { struct cmd_obj *ph2c; - struct PT_param *pptparm; + struct writePTM_parm *pwriteptmparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); if (ph2c == NULL) return _FAIL; - pptparm = (struct PT_param *)_malloc(sizeof(struct PT_param)); - if (pptparm == NULL) { + pwriteptmparm = (struct writePTM_parm *) + _malloc(sizeof(struct writePTM_parm)); + if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; } - init_h2fwcmd_w_parm_no_rsp(ph2c, pptparm, - GEN_CMD_CODE(_SetPowerTracking)); - pptparm->PT_En = type; + init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetPT)); + pwriteptmparm->type = type; + r8712_enqueue_cmd(pcmdpriv, ph2c); + return _SUCCESS; +} + +u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) +{ + struct cmd_obj *ph2c; + struct writePTM_parm *pwriteptmparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + pwriteptmparm = (struct writePTM_parm *) + _malloc(sizeof(struct setdig_parm)); + if (pwriteptmparm == NULL) { + kfree((u8 *) ph2c); + return _FAIL; + } + init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetDIG)); + pwriteptmparm->type = type; + r8712_enqueue_cmd(pcmdpriv, ph2c); + return _SUCCESS; +} + +u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) +{ + struct cmd_obj *ph2c; + struct writePTM_parm *pwriteptmparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + pwriteptmparm = (struct writePTM_parm *) + _malloc(sizeof(struct setra_parm)); + if (pwriteptmparm == NULL) { + kfree((u8 *) ph2c); + return _FAIL; + } + init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetRA)); + pwriteptmparm->type = type; r8712_enqueue_cmd(pcmdpriv, ph2c); return _SUCCESS; } @@ -512,12 +576,6 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) &psecnetwork->IEs[0], pnetwork->network.IELength, &psecnetwork->IELength); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - r8712_add_ht_addt_info(padapter, - &pnetwork->network.IEs[0], - &psecnetwork->IEs[0], - pnetwork->network.IELength, - &psecnetwork->IELength); } } psecuritypriv->supplicant_ie[0] = (u8)psecnetwork->IELength; @@ -950,3 +1008,32 @@ void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter, spin_unlock_irqrestore(&pmlmepriv->lock, irqL); r8712_free_cmd_obj(pcmd); } + +u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, + u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO) +{ + struct cmd_obj *ph2c; + struct DisconnectCtrlEx_param *param; + struct cmd_priv *pcmdpriv = &adapter->cmdpriv; + + ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + param = (struct DisconnectCtrlEx_param *) + _malloc(sizeof(struct DisconnectCtrlEx_param)); + if (param == NULL) { + kfree((unsigned char *) ph2c); + return _FAIL; + } + memset(param, 0, sizeof(struct DisconnectCtrlEx_param)); + + param->EnableDrvCtrl = (unsigned char)enableDrvCtrl; + param->TryPktCnt = (unsigned char)tryPktCnt; + param->TryPktInterval = (unsigned char)tryPktInterval; + param->FirstStageTO = (unsigned int)firstStageTO; + + init_h2fwcmd_w_parm_no_rsp(ph2c, param, + GEN_CMD_CODE(_DisconnectCtrlEx)); + r8712_enqueue_cmd(pcmdpriv, ph2c); + return _SUCCESS; +} diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 2aab78aaf33..757ebf77e9d 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -320,6 +320,35 @@ struct setdatarate_parm { u8 datarates[NumRates]; }; +enum _RT_CHANNEL_DOMAIN { + RT_CHANNEL_DOMAIN_FCC = 0, + RT_CHANNEL_DOMAIN_IC = 1, + RT_CHANNEL_DOMAIN_ETSI = 2, + RT_CHANNEL_DOMAIN_SPAIN = 3, + RT_CHANNEL_DOMAIN_FRANCE = 4, + RT_CHANNEL_DOMAIN_MKK = 5, + RT_CHANNEL_DOMAIN_MKK1 = 6, + RT_CHANNEL_DOMAIN_ISRAEL = 7, + RT_CHANNEL_DOMAIN_TELEC = 8, + + /* Be compatible with old channel plan. No good! */ + RT_CHANNEL_DOMAIN_MIC = 9, + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 10, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 11, + RT_CHANNEL_DOMAIN_TELEC_NETGEAR = 12, + + RT_CHANNEL_DOMAIN_NCC = 13, + RT_CHANNEL_DOMAIN_5G = 14, + RT_CHANNEL_DOMAIN_5G_40M = 15, + /*===== Add new channel plan above this line===============*/ + RT_CHANNEL_DOMAIN_MAX, +}; + + +struct SetChannelPlan_param { + enum _RT_CHANNEL_DOMAIN ChannelPlan; +}; + /* Caller Mode: Any @@ -392,6 +421,10 @@ struct writeBB_parm { u8 value; }; +struct writePTM_parm { + u8 type; +}; + struct readRF_parm { u8 offset; }; @@ -671,9 +704,14 @@ struct SetChannel_parm { u32 curr_ch; }; -/*H2C Handler index: 56 */ -struct PT_param { - u8 PT_En; +/*H2C Handler index: 61 */ +struct DisconnectCtrlEx_param { + /* MAXTIME = (2 * FirstStageTO) + (TryPktCnt * TryPktInterval) */ + unsigned char EnableDrvCtrl; + unsigned char TryPktCnt; + unsigned char TryPktInterval; /* Unit: ms */ + unsigned char rsvd; + unsigned int FirstStageTO; /* Unit: ms */ }; #define GEN_CMD_CODE(cmd) cmd ## _CMD_ @@ -709,13 +747,17 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter); u8 r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); +u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval); u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table); +u8 r8712_gettssi_cmd(struct _adapter *padapter, u8 offset, u8 *pval); u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type); +u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type); +u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type); u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); u8 r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 45225530c35..6b15ab83f78 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -49,7 +49,7 @@ #include #include -#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 0x1E) #define SCAN_ITEM_SIZE 768 #define MAX_CUSTOM_LEN 64 @@ -953,6 +953,10 @@ static int r8711_wx_get_range(struct net_device *dev, return 0; } +static int r8711_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); + static int r871x_wx_set_priv(struct net_device *dev, struct iw_request_info *info, union iwreq_data *awrq, @@ -960,6 +964,7 @@ static int r871x_wx_set_priv(struct net_device *dev, { int ret = 0, len = 0; char *ext; + struct _adapter *padapter = netdev_priv(dev); struct iw_point *dwrq = (struct iw_point *)awrq; len = dwrq->length; @@ -970,6 +975,87 @@ static int r871x_wx_set_priv(struct net_device *dev, kfree(ext); return -EFAULT; } + + if (0 == strcasecmp(ext, "RSSI")) { + /*Return received signal strength indicator in -db for */ + /* current AP */ + /* Rssi xx */ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_network *pcur_network = &pmlmepriv->cur_network; + /*static u8 xxxx; */ + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + sprintf(ext, "%s rssi %d", + pcur_network->network.Ssid.Ssid, + /*(xxxx=xxxx+10) */ + ((padapter->recvpriv.fw_rssi)>>1)-95 + /*pcur_network->network.Rssi */ + ); + } else { + sprintf(ext, "OK"); + } + } else if (0 == strcasecmp(ext, "LINKSPEED")) { + /*Return link speed in MBPS */ + /*LinkSpeed xx */ + union iwreq_data wrqd; + int ret_inner; + int mbps; + + ret_inner = r8711_wx_get_rate(dev, info, &wrqd, extra); + if (0 != ret_inner) + mbps = 0; + else + mbps = wrqd.bitrate.value / 1000000; + sprintf(ext, "LINKSPEED %d", mbps); + } else if (0 == strcasecmp(ext, "MACADDR")) { + /*Return mac address of the station */ + /*Macaddr = xx.xx.xx.xx.xx.xx */ + sprintf(ext, + "MACADDR = %02x.%02x.%02x.%02x.%02x.%02x", + *(dev->dev_addr), *(dev->dev_addr+1), + *(dev->dev_addr+2), *(dev->dev_addr+3), + *(dev->dev_addr+4), *(dev->dev_addr+5)); + } else if (0 == strcasecmp(ext, "SCAN-ACTIVE")) { + /*Set scan type to active */ + /*OK if successful */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + pmlmepriv->passive_mode = 1; + sprintf(ext, "OK"); + } else if (0 == strcasecmp(ext, "SCAN-PASSIVE")) { + /*Set scan type to passive */ + /*OK if successful */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + pmlmepriv->passive_mode = 0; + sprintf(ext, "OK"); + } else if (0 == strncmp(ext, "DCE-E", 5)) { + /*Set scan type to passive */ + /*OK if successful */ + r8712_disconnectCtrlEx_cmd(padapter + , 1 /*u32 enableDrvCtrl */ + , 5 /*u32 tryPktCnt */ + , 100 /*u32 tryPktInterval */ + , 5000 /*u32 firstStageTO */ + ); + sprintf(ext, "OK"); + } else if (0 == strncmp(ext, "DCE-D", 5)) { + /*Set scan type to passive */ + /*OK if successfu */ + r8712_disconnectCtrlEx_cmd(padapter + , 0 /*u32 enableDrvCtrl */ + , 5 /*u32 tryPktCnt */ + , 100 /*u32 tryPktInterval */ + , 5000 /*u32 firstStageTO */ + ); + sprintf(ext, "OK"); + } else { + printk(KERN_INFO "r8712u: r871x_wx_set_priv: unknown Command" + " %s.\n", ext); + goto FREE_EXT; + } + if (copy_to_user(dwrq->pointer, ext, + min(dwrq->length, (__u16)(strlen(ext)+1)))) + ret = -EFAULT; + +FREE_EXT: kfree(ext); return ret; } @@ -1158,7 +1244,7 @@ static int r8711_wx_get_scan(struct net_device *dev, while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { msleep(30); cnt++; - if (cnt > 1000) + if (cnt > 100) break; } spin_lock_irqsave(&queue->lock, irqL); @@ -1233,6 +1319,17 @@ static int r8711_wx_set_essid(struct net_device *dev, if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { + if (check_fwstate(pmlmepriv, + WIFI_ADHOC_STATE)) { + if (pnetwork->network. + InfrastructureMode + != + padapter->mlmepriv. + cur_network.network. + InfrastructureMode) + continue; + } + if (!r8712_set_802_11_infrastructure_mode( padapter, pnetwork->network.InfrastructureMode)) @@ -1345,6 +1442,7 @@ static int r8711_wx_get_rate(struct net_device *dev, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; struct ieee80211_ht_cap *pht_capie; + unsigned char rf_type = padapter->registrypriv.rf_config; int i; u8 *p; u16 rate, max_rate = 0, ht_cap = false; @@ -1377,7 +1475,9 @@ static int r8711_wx_get_rate(struct net_device *dev, i++; } if (ht_cap == true) { - if (mcs_rate & 0x8000) /* MCS15 */ + if (mcs_rate & 0x8000 /* MCS15 */ + && + RTL8712_RF_2T2R == rf_type) max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); else if (mcs_rate & 0x0080) /* MCS7 */ @@ -1984,6 +2084,27 @@ static int r871x_set_pid(struct net_device *dev, return 0; } +static int r871x_set_chplan(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct _adapter *padapter = (struct _adapter *) netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + int ch_plan = -1; + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + ch_plan = (int)*extra; + r8712_set_chplan_cmd(padapter, ch_plan); + +exit: + + return ret; +} + static int r871x_wps_start(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -2223,6 +2344,10 @@ static const struct iw_priv_args r8711_private_args[] = { { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" + }, + { + SIOCIWFIRSTPRIV + 0x7, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "chplan" } }; @@ -2233,7 +2358,8 @@ static iw_handler r8711_private_handler[] = { r871x_mp_ioctl_hdl, r871x_get_ap_info, /*for MM DTV platform*/ r871x_set_pid, - r871x_wps_start, + r871x_wps_start, + r871x_set_chplan }; static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev) @@ -2254,7 +2380,13 @@ static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev) tmp_qual = padapter->recvpriv.signal; tmp_noise = padapter->recvpriv.noise; piwstats->qual.level = tmp_level; - piwstats->qual.qual = tmp_qual; + /*piwstats->qual.qual = tmp_qual; + * The NetworkManager of Fedora 10, 13 will use the link + * quality for its display. + * So, use the fw_rssi on link quality variable because + * fw_rssi will be updated per 2 seconds. + */ + piwstats->qual.qual = tmp_level; piwstats->qual.noise = tmp_noise; } piwstats->qual.updated = IW_QUAL_ALL_UPDATED; @@ -2269,5 +2401,5 @@ struct iw_handler_def r871x_handlers_def = { .num_private = sizeof(r8711_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8711_private_args) / sizeof(struct iw_priv_args), - .get_wireless_stats = r871x_get_wireless_stats, + .get_wireless_stats = r871x_get_wireless_stats }; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h index b8810a9d9dd..71ca01350b5 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.h +++ b/drivers/staging/rtl8712/rtl871x_mlme.h @@ -95,6 +95,7 @@ struct mlme_priv { struct __queue scanned_queue; u8 *free_bss_buf; unsigned long num_of_scanned; + u8 passive_mode; /*add for Android's SCAN-ACTIVE/SCAN-PASSIVE */ struct ndis_802_11_ssid assoc_ssid; u8 assoc_bssid[6]; struct wlan_network cur_network; @@ -226,8 +227,6 @@ void r8712_joinbss_reset(struct _adapter *padapter); unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len); void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority); -unsigned int r8712_add_ht_addt_info(struct _adapter *padapter, u8 *in_ie, - u8 *out_ie, uint in_len, uint *pout_len); int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork); #endif /*__RTL871X_MLME_H_*/ From ee5b1aadfd5cda257337a9b9777114a10c18c31e Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:21 +0800 Subject: [PATCH 0923/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Various fixes. In r8712_generate_ie(), HT check is no longer done. Removed r8712_add_ht_addt_info(). Changes to defragmentation handling, and queue selection. Get TSSI command. Added an Ad-Hoc check to is_desired_network() r8712_ind_disconnect() now checks for Linked state. r8712_xmit_bh() now schedules an xmit tasklet. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 35 +-------------- drivers/staging/rtl8712/ieee80211.h | 6 +-- drivers/staging/rtl8712/os_intfs.c | 3 ++ drivers/staging/rtl8712/rtl8712_recv.c | 24 +++++----- drivers/staging/rtl8712/rtl8712_recv.h | 5 +++ drivers/staging/rtl8712/rtl8712_xmit.c | 20 +++++++-- drivers/staging/rtl8712/rtl8712_xmit.h | 5 +++ drivers/staging/rtl8712/rtl871x_cmd.c | 30 ++++++++++++- drivers/staging/rtl8712/rtl871x_mlme.c | 58 +++++++------------------ drivers/staging/rtl8712/rtl871x_xmit.h | 7 ++- drivers/staging/rtl8712/sta_info.h | 4 +- drivers/staging/rtl8712/usb_intf.c | 12 +++-- drivers/staging/rtl8712/usb_ops_linux.c | 19 ++++---- 13 files changed, 114 insertions(+), 114 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index f06addcf063..cc68d9748ed 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -170,17 +170,11 @@ static uint r8712_get_rateset_len(u8 *rateset) return i; } -int r8712_generate_ie(struct registry_priv *pregistrypriv, - struct _adapter *padapter) +int r8712_generate_ie(struct registry_priv *pregistrypriv) { int sz = 0, rateLen; struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *ie = pdev_network->IEs; - struct ieee80211_ht_cap ht_capie; - struct ieee80211_ht_addt_info ht_addt_info; - unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; /*timestamp will be inserted by hardware*/ sz += 8; @@ -219,33 +213,6 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv, /*IBSS Parameter Set*/ ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); - if (pregistrypriv->ht_enable == 1) { - if (pqospriv->qos_option == 0) { - ie = r8712_set_ie(ie, _VENDOR_SPECIFIC_IE_, - _WMM_IE_Length_, WMM_IE, &sz); - pqospriv->qos_option = 1; - } - memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); - ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_TX_STBC | - IEEE80211_HT_CAP_MAX_AMSDU | - IEEE80211_HT_CAP_DSSSCCK40; - ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR & - 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); - ie = r8712_set_ie(ie, _HT_CAPABILITY_IE_, - sizeof(struct ieee80211_ht_cap), - (unsigned char *)&ht_capie, &sz); - /*add HT info ie*/ - memset(&ht_addt_info, 0, - sizeof(struct ieee80211_ht_addt_info)); - /*need to add the HT additional IEs*/ - ht_addt_info.control_chan = pregistrypriv->channel; - ie = r8712_set_ie(ie, _HT_ADD_INFO_IE_, - sizeof(struct ieee80211_ht_addt_info), - (unsigned char *)&ht_addt_info, &sz); - } return sz; } diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index d1d08681136..3c0092b7de0 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -137,7 +137,7 @@ struct ieee_ibss_seq { u8 mac[ETH_ALEN]; u16 seq_num; u16 frag_num; - unsigned int packet_time; + unsigned long packet_time; struct list_head list; }; @@ -669,7 +669,6 @@ struct ieee80211_txb { #define CRC_LENGTH 4U #define MAX_WPA_IE_LEN 128 -#define MAX_WPS_IE_LEN 512 #define NETWORK_EMPTY_ESSID (1<<0) #define NETWORK_HAS_OFDM (1<<1) @@ -789,8 +788,7 @@ int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); -int r8712_generate_ie(struct registry_priv *pregistrypriv, - struct _adapter *padapter); +int r8712_generate_ie(struct registry_priv *pregistrypriv); uint r8712_is_cckrates_included(u8 *rate); uint r8712_is_cckratesonly_included(u8 *rate); diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 961d6e5a26c..9a75c6dbe50 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -286,6 +286,9 @@ static u8 init_default_value(struct _adapter *padapter) pxmitpriv->vcs_type = pregistrypriv->vcs_type; pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; pxmitpriv->frag_len = pregistrypriv->frag_thresh; + /* mlme_priv */ + /* Maybe someday we should rename this variable to "active_mode"(Jeff)*/ + pmlmepriv->passive_mode = 1; /* 1: active, 0: passive. */ /*ht_priv*/ { int i; diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 625a8a03966..6d692657e78 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -192,7 +192,7 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, } else pattrib->tcpchk_valid = 0; /* invalid */ pattrib->mcs_rate = (u8)((le32_to_cpu(prxstat->rxdw3)) & 0x3f); - pattrib->htc = (u8)((le32_to_cpu(prxstat->rxdw3) >> 6) & 0x1); + pattrib->htc = (u8)((le32_to_cpu(prxstat->rxdw3) >> 14) & 0x1); /*Offset 16*/ /*Offset 20*/ /*phy_info*/ @@ -207,7 +207,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, struct __queue *defrag_q) { struct list_head *plist, *phead; - u8 wlanhdr_offset; + u8 *data, wlanhdr_offset; u8 curfragnum; struct recv_frame_hdr *pfhdr, *pnfhdr; union recv_frame *prframe, *pnextrframe; @@ -224,22 +224,25 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, /*the first fragment number must be 0 *free the whole queue*/ r8712_free_recvframe(prframe, pfree_recv_queue); - prframe = NULL; - goto exit; + r8712_free_recvframe_queue(defrag_q, pfree_recv_queue); + return NULL; } - plist = get_next(phead); + curfragnum++; + plist = get_list_head(defrag_q); + plist = get_next(plist); + data = get_recvframe_data(prframe); while (end_of_queue_search(phead, plist) == false) { pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); - /*check the fragment sequence (2nd ~n fragment frame) */ pnfhdr = &pnextrframe->u.hdr; - curfragnum++; + /*check the fragment sequence (2nd ~n fragment frame) */ if (curfragnum != pnfhdr->attrib.frag_num) { /* the fragment number must increase (after decache) * release the defrag_q & prframe */ r8712_free_recvframe(prframe, pfree_recv_queue); - prframe = NULL; - goto exit; + r8712_free_recvframe_queue(defrag_q, pfree_recv_queue); + return NULL; } + curfragnum++; /* copy the 2nd~n fragment frame's payload to the first fragment * get the 2nd~last fragment frame's payload */ wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len; @@ -252,7 +255,6 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; plist = get_next(plist); } -exit: /* free the defrag_q queue and return the prframe */ r8712_free_recvframe_queue(defrag_q, pfree_recv_queue); return prframe; @@ -1074,7 +1076,7 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) /* for first fragment packet, driver need allocate 1536 + * drvinfo_sz + RXDESC_SIZE to defrag packet. */ if ((mf == 1) && (frag == 0)) - alloc_sz = 1658; + alloc_sz = 1658;/*1658+6=1664, 1664 is 128 alignment.*/ else alloc_sz = tmp_len; /* 2 is for IP header 4 bytes alignment in QoS packet case. diff --git a/drivers/staging/rtl8712/rtl8712_recv.h b/drivers/staging/rtl8712/rtl8712_recv.h index 6626c8ffe71..8efbd1fa035 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.h +++ b/drivers/staging/rtl8712/rtl8712_recv.h @@ -29,7 +29,12 @@ #include "osdep_service.h" #include "drv_types.h" +/* Realtek's v2.6.6 reduced this to 4. However, under heavy network and CPU + * loads, even 8 receive buffers might not be enough; cutting it to 4 seemed + * unwise. + */ #define NR_RECVBUFF (8) + #define NR_PREALLOC_RECV_SKB (8) #define RXDESC_SIZE 24 #define RXDESC_OFFSET RXDESC_SIZE diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index c1e478465ad..d09fbba471b 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -37,6 +37,7 @@ static void dump_xframe(struct _adapter *padapter, struct xmit_frame *pxmitframe); +static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz); sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag) { @@ -238,13 +239,24 @@ exit_dequeue_xframe_ex: void r8712_do_queue_select(struct _adapter *padapter, struct pkt_attrib *pattrib) { - u8 qsel = 0; + unsigned int qsel = 0; struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; if (pdvobj->nr_endpoint == 6) - qsel = pattrib->priority; - else if (pdvobj->nr_endpoint == 4) - qsel = pattrib->priority; + qsel = (unsigned int) pattrib->priority; + else if (pdvobj->nr_endpoint == 4) { + qsel = (unsigned int) pattrib->priority; + if (qsel == 0 || qsel == 3) + qsel = 3; + else if (qsel == 1 || qsel == 2) + qsel = 1; + else if (qsel == 4 || qsel == 5) + qsel = 5; + else if (qsel == 6 || qsel == 7) + qsel = 7; + else + qsel = 3; + } pattrib->qsel = qsel; } diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h b/drivers/staging/rtl8712/rtl8712_xmit.h index 1e8f3feffab..db52d13a686 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.h +++ b/drivers/staging/rtl8712/rtl8712_xmit.h @@ -64,6 +64,8 @@ #define OWN BIT(31) #define FSG BIT(27) #define LSG BIT(26) +#define TYPE_SHT (24) +#define TYPE_MSK (0x03000000) /*OFFSET 4*/ #define PKT_OFFSET_SZ (0) @@ -74,6 +76,7 @@ #define BMC BIT(7) #define BK BIT(30) #define AGG_EN BIT(29) +#define RTS_RC_SHT (16) /*OFFSET 12*/ #define SEQ_SHT (16) @@ -83,6 +86,8 @@ /*OFFSET 20*/ #define DISFB BIT(15) +#define RSVD6_MSK (0x00E00000) +#define RSVD6_SHT (21) struct tx_desc { /*DWORD 0*/ diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 2d8f48c2c52..d77388bdba7 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -240,7 +240,7 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); psurveyPara->bsslimit = cpu_to_le32(48); - psurveyPara->passive_mode = cpu_to_le32(1); + psurveyPara->passive_mode = cpu_to_le32(pmlmepriv->passive_mode); psurveyPara->ss_ssidlen = 0; memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1); if ((pssid != NULL) && (pssid->SsidLength)) { @@ -251,6 +251,7 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, r8712_enqueue_cmd(pcmdpriv, ph2c); _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY); + padapter->blnEnableRxFF0Filter = 0; return _SUCCESS; } @@ -760,6 +761,33 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, return _SUCCESS; } +u8 r8712_gettssi_cmd(struct _adapter *padapter, u8 offset, u8 *pval) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct cmd_obj *ph2c; + struct readTSSI_parm *prdtssiparm; + + ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + prdtssiparm = (struct readTSSI_parm *) + _malloc(sizeof(struct readTSSI_parm)); + if (prdtssiparm == NULL) { + kfree((unsigned char *) ph2c); + return _FAIL; + } + _init_listhead(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_ReadTSSI); + ph2c->parmbuf = (unsigned char *)prdtssiparm; + ph2c->cmdsz = sizeof(struct readTSSI_parm); + ph2c->rsp = pval; + ph2c->rspsz = sizeof(struct readTSSI_rsp); + + prdtssiparm->offset = offset; + r8712_enqueue_cmd(pcmdpriv, ph2c); + return _SUCCESS; +} + u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 866554d48d8..c475b961308 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -52,6 +52,8 @@ static sint _init_mlme_priv(struct _adapter *padapter) pmlmepriv->fw_state = 0; pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; + /* Maybe someday we should rename this variable to "active_mode"(Jeff)*/ + pmlmepriv->passive_mode = 1; /* 1: active, 0: passive. */ spin_lock_init(&(pmlmepriv->lock)); spin_lock_init(&(pmlmepriv->lock2)); _init_queue(&(pmlmepriv->free_bss_pool)); @@ -485,6 +487,12 @@ static int is_desired_network(struct _adapter *adapter, if ((psecuritypriv->PrivacyAlgrthm != _NO_PRIVACY_) && (pnetwork->network.Privacy == 0)) bselected = false; + if (check_fwstate(&adapter->mlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != + adapter->mlmepriv.cur_network.network. + InfrastructureMode) + bselected = false; + } return bselected; } @@ -683,9 +691,11 @@ void r8712_ind_disconnect(struct _adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - _clr_fwstate_(pmlmepriv, _FW_LINKED); - padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK); - r8712_os_indicate_disconnect(padapter); + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); + padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK); + r8712_os_indicate_disconnect(padapter); + } if (padapter->pwrctrlpriv.pwr_mode != padapter->registrypriv.power_mgnt) { _cancel_timer_ex(&pmlmepriv->dhcp_timer); @@ -718,9 +728,9 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) if (sizeof(struct list_head) == 4 * sizeof(u32)) { pnetwork = (struct wlan_network *) - _malloc(sizeof(struct wlan_network)); + _malloc(sizeof(struct wlan_network)); memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8, - sizeof(struct wlan_network) - 16); + sizeof(struct wlan_network) - 16); } else pnetwork = (struct wlan_network *)pbuf; @@ -1657,7 +1667,7 @@ void r8712_update_registrypriv_dev_network(struct _adapter *adapter) /* 1. Supported rates * 2. IE */ - sz = r8712_generate_ie(pregistrypriv, adapter); + sz = r8712_generate_ie(pregistrypriv); pdev_network->IELength = sz; pdev_network->Length = r8712_get_ndis_wlan_bssid_ex_sz( (struct ndis_wlan_bssid_ex *)pdev_network); @@ -1802,39 +1812,3 @@ void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority) } } } - -/*the function is >= passive_level*/ -unsigned int r8712_add_ht_addt_info(struct _adapter *padapter, - u8 *in_ie, u8 *out_ie, - uint in_len, uint *pout_len) -{ - u32 ielen, out_len = 0; - unsigned char *p, *pframe; - struct ieee80211_ht_addt_info ht_addt_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - out_len = *pout_len; - - if (pregistrypriv->ht_enable == 1) { - p = r8712_get_ie(in_ie+12, _HT_ADD_INFO_IE_, - &ielen, in_len - 12); - if (p && (ielen > 0)) { - ; /* dummy branch */ - } else { - if (p == NULL) { - int sz = sizeof(struct ieee80211_ht_addt_info); - memset(&ht_addt_info, 0, sz); - /*need to add the HT additional IEs*/ - ht_addt_info.control_chan = - pregistrypriv->channel; - pframe = r8712_set_ie(out_ie + out_len, - _HT_ADD_INFO_IE_, - sz, - (unsigned char *)&ht_addt_info, - pout_len); - } - } - } - return phtpriv->ht_option; -} diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index 81987788917..a1dccec2a59 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -93,9 +93,9 @@ struct pkt_attrib { u16 seqnum; u16 ether_type; - u32 pktlen; /* the original 802.3 pkt raw_data len + u16 pktlen; /* the original 802.3 pkt raw_data len * (not include ether_hdr data) */ - u32 last_txcmdsz; + u16 last_txcmdsz; u8 pkt_hdrlen; /*the original 802.3 pkt header len*/ u8 hdrlen; /*the WLAN Header Len*/ @@ -225,6 +225,9 @@ struct xmit_priv { struct semaphore tx_retevt;/*all tx return event;*/ u8 txirp_cnt; struct tasklet_struct xmit_tasklet; + _workitem xmit_pipe4_reset_wi; + _workitem xmit_pipe6_reset_wi; + _workitem xmit_piped_reset_wi; /*per AC pending irp*/ int beq_cnt; int bkq_cnt; diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h index 2ac8d330ca5..48d6a14c8f5 100644 --- a/drivers/staging/rtl8712/sta_info.h +++ b/drivers/staging/rtl8712/sta_info.h @@ -63,8 +63,8 @@ struct sta_info { struct sta_recv_priv sta_recvpriv; uint state; uint aid; - u8 mac_id; - u8 qos_option; + uint mac_id; + uint qos_option; u8 hwaddr[ETH_ALEN]; uint ieee8021x_blocked; /*0: allowed, 1:blocked */ uint XPrivacy; /*aes, tkip...*/ diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 3bcb669a7ea..0a2f2743165 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -368,23 +368,25 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, struct _adapter *padapter = NULL; struct dvobj_priv *pdvobjpriv; struct net_device *pnetdev; + struct usb_device *udev; printk(KERN_INFO "r8712u: DriverVersion: %s\n", DRVER); /* In this probe function, O.S. will provide the usb interface pointer * to driver. We have to increase the reference count of the usb device * structure by using the usb_get_dev function. */ - usb_get_dev(interface_to_usbdev(pusb_intf)); + udev = interface_to_usbdev(pusb_intf); + usb_get_dev(udev); pintf = pusb_intf; /* step 1. */ pnetdev = r8712_init_netdev(); if (!pnetdev) goto error; - padapter = (struct _adapter *)netdev_priv(pnetdev); + padapter = netdev_priv(pnetdev); disable_ht_for_spec_devid(pdid, padapter); pdvobjpriv = &padapter->dvobjpriv; pdvobjpriv->padapter = padapter; - padapter->dvobjpriv.pusbdev = interface_to_usbdev(pusb_intf); + padapter->dvobjpriv.pusbdev = udev; usb_set_intfdata(pusb_intf, pnetdev); SET_NETDEV_DEV(pnetdev, &pusb_intf->dev); /* step 2. */ @@ -594,9 +596,10 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, /* step 6. Tell the network stack we exist */ if (register_netdev(pnetdev) != 0) goto error; + spin_lock_init(&padapter->lockRxFF0Filter); return 0; error: - usb_put_dev(interface_to_usbdev(pusb_intf)); + usb_put_dev(udev); usb_set_intfdata(pusb_intf, NULL); if (padapter->dvobj_deinit != NULL) padapter->dvobj_deinit(padapter); @@ -613,6 +616,7 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) struct _adapter *padapter = netdev_priv(pnetdev); struct usb_device *udev = interface_to_usbdev(pusb_intf); + usb_set_intfdata(pusb_intf, NULL); if (padapter) { if (drvpriv.drv_registered == true) padapter->bSurpriseRemoved = true; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index b796c6bb593..24e1ec5f006 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -334,17 +334,16 @@ void r8712_xmit_bh(void *priv) struct _adapter *padapter = (struct _adapter *)priv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - while (1) { - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) { - printk(KERN_ERR "r8712u: xmit_bh => bDriverStopped" - " or bSurpriseRemoved\n"); - break; - } - ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL); - if (ret == false) - break; + if ((padapter->bDriverStopped == true) || + (padapter->bSurpriseRemoved == true)) { + printk(KERN_ERR "r8712u: xmit_bh => bDriverStopped" + " or bSurpriseRemoved\n"); + return; } + ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL); + if (ret == false) + return; + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } static void usb_write_port_complete(struct urb *purb) From 93c55dda092c7ec2a0bc6a93b5ab220ddbdffb95 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:22 +0800 Subject: [PATCH 0924/1519] staging: r8712u: Merging Realtek's latest (v2.6.6). Tx aggregation. Tx Aggregation (CONFIG_R8712_TX_AGGR, known as CONFIG_USB_TX_AGGR in the Realtek tarball) is now added. However, its tests have not been successful! The default in the Realtek tarball is to not build it -- and the Release Notes does not seem to list this as a feature. I have tested the driver with and without this feature; the former does not successfully associate when WPA2 is used. Signed-off-by: Ali Bahar Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/Kconfig | 7 + drivers/staging/rtl8712/rtl8712_xmit.c | 239 +++++++++++++++++++++++++ drivers/staging/rtl8712/rtl8712_xmit.h | 7 + drivers/staging/rtl8712/rtl871x_xmit.h | 15 +- 4 files changed, 266 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/Kconfig b/drivers/staging/rtl8712/Kconfig index 041e1e81f31..ea37473f71e 100644 --- a/drivers/staging/rtl8712/Kconfig +++ b/drivers/staging/rtl8712/Kconfig @@ -16,4 +16,11 @@ config R8712_AP ---help--- This option allows the Realtek RTL8712 USB device to be an Access Point. +config R8712_TX_AGGR + bool "Realtek RTL8712U Transmit Aggregation code" + depends on R8712U && BROKEN + default N + ---help--- + This option provides transmit aggregation for the Realtek RTL8712 USB device. + diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index d09fbba471b..693331955d6 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -260,6 +260,159 @@ void r8712_do_queue_select(struct _adapter *padapter, pattrib->qsel = qsel; } +#ifdef CONFIG_R8712_TX_AGGR +u8 r8712_construct_txaggr_cmd_desc(struct xmit_buf *pxmitbuf) +{ + struct tx_desc *ptx_desc = (struct tx_desc *)pxmitbuf->pbuf; + + /* Fill up TxCmd Descriptor according as USB FW Tx Aaggregation info.*/ + /* dw0 */ + ptx_desc->txdw0 = cpu_to_le32(CMD_HDR_SZ&0xffff); + ptx_desc->txdw0 |= + cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(OWN | FSG | LSG); + + /* dw1 */ + ptx_desc->txdw1 |= cpu_to_le32((0x13<priv_data; + struct _adapter *padapter = pxmitframe->padapter; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct cmd_hdr *pcmd_hdr = (struct cmd_hdr *) + (pxmitbuf->pbuf + TXDESC_SIZE); + + /* Fill up Cmd Header for USB FW Tx Aggregation.*/ + /* dw0 */ + pcmd_hdr->cmd_dw0 = cpu_to_le32((GEN_CMD_CODE(_AMSDU_TO_AMPDU) << 16) | + (pcmdpriv->cmd_seq << 24)); + pcmdpriv->cmd_seq++; + + return _SUCCESS; +} + +u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe) +{ + struct _adapter *padapter = pxmitframe->padapter; + struct tx_desc *ptx_desc = (struct tx_desc *)pxmitbuf->pbuf; + int last_txcmdsz = 0; + int padding_sz = 0; + + /* 802.3->802.11 convertor */ + r8712_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); + /* free skb struct */ + r8712_xmit_complete(padapter, pxmitframe); + if (pxmitframe->attrib.ether_type != 0x0806) { + if ((pxmitframe->attrib.ether_type != 0x888e) && + (pxmitframe->attrib.dhcp_pkt != 1)) { + r8712_issue_addbareq_cmd(padapter, + pxmitframe->attrib.priority); + } + } + pxmitframe->last[0] = 1; + update_txdesc(pxmitframe, (uint *)(pxmitframe->buf_addr), + pxmitframe->attrib.last_txcmdsz); + /*padding zero */ + last_txcmdsz = pxmitframe->attrib.last_txcmdsz; + padding_sz = (8 - (last_txcmdsz % 8)); + if ((last_txcmdsz % 8) != 0) { + int i; + for (i = 0; i < padding_sz; i++) + *(pxmitframe->buf_addr+TXDESC_SIZE+last_txcmdsz+i) = 0; + } + /* Add the new mpdu's length */ + ptx_desc->txdw0 = cpu_to_le32((ptx_desc->txdw0&0xffff0000) | + ((ptx_desc->txdw0&0x0000ffff)+ + ((TXDESC_SIZE+last_txcmdsz+padding_sz)&0x0000ffff))); + + return _SUCCESS; +} + + +u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe) +{ + /* linux complete context doesnt need to protect */ + pxmitframe->pxmitbuf = pxmitbuf; + pxmitbuf->priv_data = pxmitframe; + pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; + /* buffer addr assoc */ + pxmitframe->buf_addr = pxmitbuf->pbuf+TXDESC_SIZE+CMD_HDR_SZ; + /*RTL8712_DMA_H2CCMD */ + r8712_construct_txaggr_cmd_desc(pxmitbuf); + r8712_construct_txaggr_cmd_hdr(pxmitbuf); + if (r8712_append_mpdu_unit(pxmitbuf, pxmitframe) == _SUCCESS) + pxmitbuf->aggr_nr = 1; + + return _SUCCESS; +} + +u16 r8712_xmitframe_aggr_next(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe) +{ + pxmitframe->pxmitbuf = pxmitbuf; + pxmitbuf->priv_data = pxmitframe; + pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; + /* buffer addr assoc */ + pxmitframe->buf_addr = pxmitbuf->pbuf + TXDESC_SIZE + + (((struct tx_desc *)pxmitbuf->pbuf)->txdw0 & 0x0000ffff); + if (r8712_append_mpdu_unit(pxmitbuf, pxmitframe) == _SUCCESS) { + r8712_free_xmitframe_ex(&pxmitframe->padapter->xmitpriv, + pxmitframe); + pxmitbuf->aggr_nr++; + } + + return TXDESC_SIZE + + (((struct tx_desc *)pxmitbuf->pbuf)->txdw0 & 0x0000ffff); +} + +u8 r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe) +{ + struct _adapter *padapter = pxmitframe->padapter; + struct dvobj_priv *pdvobj = (struct dvobj_priv *) &padapter->dvobjpriv; + struct tx_desc * ptxdesc = (struct tx_desc *)pxmitbuf->pbuf; + struct cmd_hdr *pcmd_hdr = (struct cmd_hdr *) + (pxmitbuf->pbuf + TXDESC_SIZE); + u16 total_length = (u16) (ptxdesc->txdw0 & 0xffff); + + /* use 1st xmitframe as media */ + xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); + pcmd_hdr->cmd_dw0 = cpu_to_le32(((total_length-CMD_HDR_SZ)&0x0000ffff)| + (pcmd_hdr->cmd_dw0&0xffff0000)); + + /* urb length in cmd_dw1 */ + pcmd_hdr->cmd_dw1 = cpu_to_le32((pxmitbuf->aggr_nr & 0xff)| + ((total_length+TXDESC_SIZE) << 16)); + pxmitframe->last[0] = 1; + pxmitframe->bpending[0] = false; + pxmitframe->mem_addr = pxmitbuf->pbuf; + + if ((pdvobj->ishighspeed && ((total_length+TXDESC_SIZE)%0x200) == 0) || + ((!pdvobj->ishighspeed && + ((total_length+TXDESC_SIZE)%0x40) == 0))) { + ptxdesc->txdw0 |= cpu_to_le32 + (((TXDESC_SIZE+OFFSET_SZ+8)<txdw0 |= cpu_to_le32 + (((TXDESC_SIZE+OFFSET_SZ)<padapter, RTL8712_DMA_H2CCMD, + total_length+TXDESC_SIZE, (u8 *)pxmitframe); + + return _SUCCESS; +} + +#endif + static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) { uint qsel; @@ -270,6 +423,9 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) struct pkt_attrib *pattrib = &pxmitframe->attrib; struct tx_desc *ptxdesc = (struct tx_desc *)pmem; struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; +#ifdef CONFIG_R8712_TX_AGGR + struct cmd_priv *pcmdpriv = (struct cmd_priv *)&padapter->cmdpriv; +#endif u8 blnSetTxDescOffset; sint bmcst = IS_MCAST(pattrib->ra); struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -303,8 +459,40 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) if (pxmitframe->frame_tag == DATA_FRAMETAG) { /* offset 4 */ ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id)&0x1f); + +#ifdef CONFIG_R8712_TX_AGGR + /* dirty workaround, need to check if it is aggr cmd. */ + if ((u8 *)pmem != (u8 *)pxmitframe->pxmitbuf->pbuf) { + ptxdesc->txdw0 |= cpu_to_le32 + ((0x3 << TYPE_SHT)&TYPE_MSK); + qsel = (uint)(pattrib->qsel & 0x0000001f); + if (qsel == 2) + qsel = 0; + ptxdesc->txdw1 |= cpu_to_le32 + ((qsel << QSEL_SHT) & 0x00001f00); + ptxdesc->txdw2 = cpu_to_le32 + ((qsel << RTS_RC_SHT)&0x001f0000); + ptxdesc->txdw6 |= cpu_to_le32 + ((0x5 << RSVD6_SHT)&RSVD6_MSK); + } else { + ptxdesc->txdw0 |= cpu_to_le32 + ((0x3 << TYPE_SHT)&TYPE_MSK); + ptxdesc->txdw1 |= cpu_to_le32 + ((0x13 << QSEL_SHT) & 0x00001f00); + qsel = (uint)(pattrib->qsel & 0x0000001f); + if (qsel == 2) + qsel = 0; + ptxdesc->txdw2 = cpu_to_le32 + ((qsel << RTS_RC_SHT)&0x0001f000); + ptxdesc->txdw7 |= cpu_to_le32 + (pcmdpriv->cmd_seq << 24); + pcmdpriv->cmd_seq++; + } + pattrib->qsel = 0x13; +#else qsel = (uint)(pattrib->qsel & 0x0000001f); ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); +#endif if (!pqospriv->qos_option) ptxdesc->txdw1 |= cpu_to_le32(BIT(16));/*Non-QoS*/ if ((pattrib->encrypt > 0) && !pattrib->bswenc) { @@ -426,7 +614,11 @@ int r8712_xmitframe_complete(struct _adapter *padapter, struct hw_xmit *phwxmits; sint hwentry; struct xmit_frame *pxmitframe = NULL; +#ifdef CONFIG_R8712_TX_AGGR + struct xmit_frame *p2ndxmitframe = NULL; +#else int res = _SUCCESS, xcnt = 0; +#endif phwxmits = pxmitpriv->hwxmits; hwentry = pxmitpriv->hwxmit_entry; @@ -434,12 +626,53 @@ int r8712_xmitframe_complete(struct _adapter *padapter, pxmitbuf = r8712_alloc_xmitbuf(pxmitpriv); if (!pxmitbuf) return false; +#ifdef CONFIG_R8712_TX_AGGR + pxmitbuf->aggr_nr = 0; +#endif } /* 1st frame dequeued */ pxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, hwentry); /* need to remember the 1st frame */ if (pxmitframe != NULL) { +#ifdef CONFIG_R8712_TX_AGGR + /* 1. dequeue 2nd frame + * 2. aggr if 2nd xframe is dequeued, else dump directly + */ + if (AGGR_NR_HIGH_BOUND > 1) + p2ndxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, + hwentry); + if (pxmitframe->frame_tag != DATA_FRAMETAG) { + r8712_free_xmitbuf(pxmitpriv, pxmitbuf); + return false; + } + if (p2ndxmitframe != NULL) + if (p2ndxmitframe->frame_tag != DATA_FRAMETAG) { + r8712_free_xmitbuf(pxmitpriv, pxmitbuf); + return false; + } + r8712_xmitframe_aggr_1st(pxmitbuf, pxmitframe); + if (p2ndxmitframe != NULL) { + u16 total_length; + total_length = r8712_xmitframe_aggr_next( + pxmitbuf, p2ndxmitframe); + do { + p2ndxmitframe = dequeue_xframe_ex( + pxmitpriv, phwxmits, hwentry); + if (p2ndxmitframe != NULL) + total_length = + r8712_xmitframe_aggr_next( + pxmitbuf, + p2ndxmitframe); + else + break; + } while (total_length <= 0x1800 && + pxmitbuf->aggr_nr <= AGGR_NR_HIGH_BOUND); + } + if (pxmitbuf->aggr_nr > 0) + r8712_dump_aggr_xframe(pxmitbuf, pxmitframe); + +#else xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); if (pxmitframe->frame_tag == DATA_FRAMETAG) { @@ -455,6 +688,7 @@ int r8712_xmitframe_complete(struct _adapter *padapter, else r8712_free_xmitframe_ex(pxmitpriv, pxmitframe); xcnt++; +#endif } else { /* pxmitframe == NULL && p2ndxmitframe == NULL */ r8712_free_xmitbuf(pxmitpriv, pxmitbuf); @@ -493,8 +727,13 @@ static void dump_xframe(struct _adapter *padapter, pxmitframe->mem_addr = mem_addr; pxmitframe->bpending[t] = false; ff_hwaddr = get_ff_hwaddr(pxmitframe); +#ifdef CONFIG_R8712_TX_AGGR + r8712_write_port(padapter, RTL8712_DMA_H2CCMD, w_sz, + (unsigned char *)pxmitframe); +#else r8712_write_port(padapter, ff_hwaddr, w_sz, (unsigned char *)pxmitframe); +#endif mem_addr += w_sz; mem_addr = (u8 *)RND4(((addr_t)(mem_addr))); } diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h b/drivers/staging/rtl8712/rtl8712_xmit.h index db52d13a686..b50e7a1f3a4 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.h +++ b/drivers/staging/rtl8712/rtl8712_xmit.h @@ -113,4 +113,11 @@ int r8712_xmitframe_complete(struct _adapter *padapter, void r8712_do_queue_select(struct _adapter *padapter, struct pkt_attrib *pattrib); +#ifdef CONFIG_R8712_TX_AGGR +u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe); +u8 r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf, + struct xmit_frame *pxmitframe); +#endif + #endif diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index a1dccec2a59..a034c0fec71 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -30,8 +30,19 @@ #include "drv_types.h" #include "xmit_osdep.h" -#define MAX_XMITBUF_SZ (2048) -#define NR_XMITBUFF (4) +#ifdef CONFIG_R8712_TX_AGGR +#define MAX_XMITBUF_SZ (16384) +#else +#define MAX_XMITBUF_SZ (2048) +#endif + +#define NR_XMITBUFF (4) + +#ifdef CONFIG_R8712_TX_AGGR +#define AGGR_NR_HIGH_BOUND (4) /*(8) */ +#define AGGR_NR_LOW_BOUND (2) +#endif + #define XMITBUF_ALIGN_SZ 512 #define TX_GUARD_BAND 5 #define MAX_NUMBLKS (1) From 5d3da4a20a271e3cf5496a50cbb8118aa019374f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 4 Sep 2011 03:14:23 +0800 Subject: [PATCH 0925/1519] staging: r8712u: Tracking kmemleak false positives. The frame buffers allocated in _r8712_init_recv_priv() are not tracked by kmemleak, but they are freed when the driver is unloaded. To help find any real leaks, these false positives are annotated for kmemleak. Signed-off-by: Larry Finger Signed-off-by: Ali Bahar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_recv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index aec83dd8a01..7069f06d9b5 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -28,6 +28,9 @@ #define _RTL871X_RECV_C_ +#include +#include + #include "osdep_service.h" #include "drv_types.h" #include "recv_osdep.h" @@ -73,6 +76,7 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv, RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) return _FAIL; + kmemleak_not_leak(precvpriv->pallocated_frame_buf); memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + From 2192e60654c2b91de45dce44a23723f725603ce1 Mon Sep 17 00:00:00 2001 From: Ali Bahar Date: Sun, 4 Sep 2011 03:14:24 +0800 Subject: [PATCH 0926/1519] staging: r8712u: Most return-values changed from -1 to proper errno macros. The ioctl handlers were frequently returning -1 upon failure. Most of these have now been changed to proper errno macros. The few remaining ones have been left untouched because either the handler is not called (and so cannot be tested), or the function never fails (and so cannot be system-tested), or requires new code to distinguish its failures. Signed-off-by: Ali Bahar Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 44 +++++++++---------- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 3 +- drivers/staging/rtl8712/rtl871x_ioctl_set.h | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 6b15ab83f78..507584b837c 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -530,7 +530,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, memcpy(buf, pie , ielen); pos = buf; if (ielen < RSN_HEADER_LEN) { - ret = -1; + ret = -EINVAL; goto exit; } if (r8712_parse_wpa_ie(buf, ielen, &group_cipher, @@ -740,8 +740,9 @@ static int r8711_wx_get_freq(struct net_device *dev, pcur_bss->Configuration.DSConfig-1] * 100000; wrqu->freq.e = 1; wrqu->freq.i = pcur_bss->Configuration.DSConfig; - } else - return -1; + } else { + return -ENOLINK; + } return 0; } @@ -772,8 +773,8 @@ static int r8711_wx_set_mode(struct net_device *dev, r8712_setopmode_cmd(padapter, networkType); else r8712_setopmode_cmd(padapter, Ndis802_11AutoUnknown); - if (!r8712_set_802_11_infrastructure_mode(padapter, networkType)) - return -1; + + r8712_set_802_11_infrastructure_mode(padapter, networkType); return 0; } @@ -1090,7 +1091,7 @@ static int r8711_wx_set_wap(struct net_device *dev, enum NDIS_802_11_AUTHENTICATION_MODE authmode; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) - return -1; + return -EBUSY; if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) return ret; if (temp->sa_family != ARPHRD_ETHER) @@ -1107,16 +1108,15 @@ static int r8711_wx_set_wap(struct net_device *dev, pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); dst_bssid = pnetwork->network.MacAddress; if (!memcmp(dst_bssid, temp->sa_data, ETH_ALEN)) { - if (r8712_set_802_11_infrastructure_mode(padapter, - pnetwork->network.InfrastructureMode) == false) - ret = -1; + r8712_set_802_11_infrastructure_mode(padapter, + pnetwork->network.InfrastructureMode); break; } } spin_unlock_irqrestore(&queue->lock, irqL); if (!ret) { if (!r8712_set_802_11_authentication_mode(padapter, authmode)) - ret = -1; + ret = -ENOMEM; else { if (!r8712_set_802_11_bssid(padapter, temp->sa_data)) ret = -1; @@ -1191,7 +1191,7 @@ static int r8711_wx_set_scan(struct net_device *dev, return -1; } if (padapter->bup == false) - return -1; + return -ENETDOWN; if (padapter->hw_init_completed == false) return -1; if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || @@ -1294,7 +1294,7 @@ static int r8711_wx_set_essid(struct net_device *dev, u32 len; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - return -1; + return -EBUSY; if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) return 0; if (wrqu->essid.length > IW_ESSID_MAX_SIZE) @@ -1330,10 +1330,9 @@ static int r8711_wx_set_essid(struct net_device *dev, continue; } - if (!r8712_set_802_11_infrastructure_mode( + r8712_set_802_11_infrastructure_mode( padapter, - pnetwork->network.InfrastructureMode)) - return -1; + pnetwork->network.InfrastructureMode); break; } } @@ -1357,8 +1356,9 @@ static int r8711_wx_get_essid(struct net_device *dev, wrqu->essid.length = len; memcpy(extra, pcur_bss->Ssid.Ssid, len); wrqu->essid.flags = 1; - } else - ret = -1; + } else { + ret = -ENOLINK; + } return ret; } @@ -1430,7 +1430,7 @@ set_rate: datarates[i] = 0xff; } if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS) - ret = -1; + ret = -ENOMEM; return ret; } @@ -1492,7 +1492,7 @@ static int r8711_wx_get_rate(struct net_device *dev, wrqu->bitrate.value = max_rate * 500000; } } else - return -1; + return -ENOLINK; return 0; } @@ -1822,7 +1822,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, param_len = sizeof(struct ieee_param) + pext->key_len; param = (struct ieee_param *)_malloc(param_len); if (param == NULL) - return -1; + return -ENOMEM; memset(param, 0, param_len); param->cmd = IEEE_CMD_SET_ENCRYPTION; memset(param->sta_addr, 0xff, ETH_ALEN); @@ -1840,7 +1840,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, alg_name = "CCMP"; break; default: - return -1; + return -EINVAL; } strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) @@ -1906,7 +1906,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - return -1; + return -ENOSYS; } static int r8711_drvext_hdl(struct net_device *dev, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index 8486eb1503c..fb29b423752 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -243,7 +243,7 @@ done: spin_unlock_irqrestore(&pmlmepriv->lock, irqL); } -u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, +void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype) { unsigned long irqL; @@ -290,7 +290,6 @@ u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, } spin_unlock_irqrestore(&pmlmepriv->lock, irqL); } - return true; } u8 r8712_set_802_11_disassociate(struct _adapter *padapter) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.h b/drivers/staging/rtl8712/rtl871x_ioctl_set.h index de0a8482c98..2c94cd151c9 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.h +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.h @@ -47,7 +47,7 @@ u8 r8712_set_802_11_disassociate(struct _adapter *padapter); u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter); -u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, +void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); void r8712_set_802_11_ssid(struct _adapter *padapter, From f6c39d4f2d350df049a844b658eb6b08c5833e51 Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Thu, 1 Sep 2011 11:15:24 +0200 Subject: [PATCH 0927/1519] staging: vme: change static device array to pointers Change the static array of 'struct device''s in struct vme_bridge to instead use an array of pointers. This is in accordance with the requirement that all kobjects be dynamically allocated (see Documentation/kobject.txt) and never be statically allocated. Signed-off-by: Manohar Vanga Acked-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/vme.c | 21 +++++++++++++++++---- drivers/staging/vme/vme_bridge.h | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index b2968f8588f..63a8fa2ebc0 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -1338,6 +1338,11 @@ static void vme_remove_bus(struct vme_bridge *bridge) mutex_unlock(&vme_buses_lock); } +static void vme_dev_release(struct device *dev) +{ + kfree(dev); +} + int vme_register_bridge(struct vme_bridge *bridge) { struct device *dev; @@ -1353,11 +1358,17 @@ int vme_register_bridge(struct vme_bridge *bridge) * specification. */ for (i = 0; i < VME_SLOTS_MAX; i++) { - dev = &bridge->dev[i]; + bridge->dev[i] = kzalloc(sizeof(struct device), GFP_KERNEL); + if (!bridge->dev[i]) { + retval = -ENOMEM; + goto err_devalloc; + } + dev = bridge->dev[i]; memset(dev, 0, sizeof(struct device)); dev->parent = bridge->parent; dev->bus = &vme_bus_type; + dev->release = vme_dev_release; /* * We save a pointer to the bridge in platform_data so that we * can get to it later. We keep driver_data for use by the @@ -1374,8 +1385,10 @@ int vme_register_bridge(struct vme_bridge *bridge) return retval; err_reg: + kfree(dev); +err_devalloc: while (--i >= 0) { - dev = &bridge->dev[i]; + dev = bridge->dev[i]; device_unregister(dev); } vme_remove_bus(bridge); @@ -1390,7 +1403,7 @@ void vme_unregister_bridge(struct vme_bridge *bridge) for (i = 0; i < VME_SLOTS_MAX; i++) { - dev = &bridge->dev[i]; + dev = bridge->dev[i]; device_unregister(dev); } vme_remove_bus(bridge); @@ -1427,7 +1440,7 @@ static int vme_calc_slot(struct device *dev) /* Determine slot number */ num = 0; while (num < VME_SLOTS_MAX) { - if (&bridge->dev[num] == dev) + if (bridge->dev[num] == dev) break; num++; diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h index 89596705829..4b8566eb7e3 100644 --- a/drivers/staging/vme/vme_bridge.h +++ b/drivers/staging/vme/vme_bridge.h @@ -114,7 +114,7 @@ struct vme_bridge { void *driver_priv; /* Private pointer for the bridge driver */ struct list_head bus_list; /* list of VME buses */ - struct device dev[VME_SLOTS_MAX]; /* Device registered with + struct device *dev[VME_SLOTS_MAX]; /* Device registered with * device model on VME bus */ From 617aa39639943626fa262757d176be413c54571b Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:07 +0300 Subject: [PATCH 0928/1519] staging: mei: removing dependency between WD and AMTHI init function. AMTHI need to be initialized after WD Client was initialized, moving the AMTHI outside of the WD initialization function. in order to remove the coupling between the initialization of those clients. AMTHI is getting initialized (getting connected to the FW feature/client) in two ways: 1) if mei driver fails to send connect message to watchdog client (WD initialization), then immediately the AMTHI client getting initialized right after the watchdog initialization function. 2) if Watchdog client success to send connect message to watchdog client, then only after the driver is getting the connect response message the AMTHI client is getting initialized Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/init.c | 8 +++++++- drivers/staging/mei/interface.h | 2 +- drivers/staging/mei/wd.c | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c index 0fa8216fd0e..69a57e77a09 100644 --- a/drivers/staging/mei/init.c +++ b/drivers/staging/mei/init.c @@ -521,7 +521,13 @@ void mei_host_client_properties(struct mei_device *dev) bitmap_set(dev->host_clients_map, 0, 3); dev->mei_state = MEI_ENABLED; - mei_wd_host_init(dev); + /* if wd initialization fails, initialization the AMTHI client, + * otherwise the AMTHI client will be initialized after the WD client connect response + * will be received + */ + if (mei_wd_host_init(dev)) + mei_host_init_iamthif(dev); + return; } diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h index d0bf5cf4f3e..7bcf0966030 100644 --- a/drivers/staging/mei/interface.h +++ b/drivers/staging/mei/interface.h @@ -48,7 +48,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); int mei_wd_send(struct mei_device *dev); int mei_wd_stop(struct mei_device *dev, bool preserve); -void mei_wd_host_init(struct mei_device *dev); +bool mei_wd_host_init(struct mei_device *dev); void mei_wd_start_setup(struct mei_device *dev); int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl); diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index 42f04efc90e..721487d05ba 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -63,8 +63,10 @@ void mei_wd_start_setup(struct mei_device *dev) * * @dev: the device structure */ -void mei_wd_host_init(struct mei_device *dev) +bool mei_wd_host_init(struct mei_device *dev) { + bool ret = false; + mei_cl_init(&dev->wd_cl, dev); /* look for WD client and connect to it */ @@ -83,19 +85,25 @@ void mei_wd_host_init(struct mei_device *dev) dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n"); dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_cl.host_client_id = 0; - mei_host_init_iamthif(dev) ; + ret = false; + goto end; } else { dev->wd_cl.timer_count = CONNECT_TIMEOUT; } } else { dev_dbg(&dev->pdev->dev, "Failed to find WD client\n"); - mei_host_init_iamthif(dev) ; + ret = false; + goto end; } } else { dev->wd_bypass = true; dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n"); - mei_host_init_iamthif(dev) ; + ret = false; + goto end; } + +end: + return ret; } /** From 92eb40134332eba28cde3c2aecdb48a561c437b1 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:08 +0300 Subject: [PATCH 0929/1519] staging: mei: fix register access function comments Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/mei_dev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h index d7bc10c612b..2e1107762ef 100644 --- a/drivers/staging/mei/mei_dev.h +++ b/drivers/staging/mei/mei_dev.h @@ -356,7 +356,7 @@ int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid); * @dev: the device structure * @offset: offset from which to read the data * - * returns the byte read. + * returns register value (u32) */ static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset) { @@ -368,7 +368,7 @@ static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset) * * @dev: the device structure * @offset: offset from which to write the data - * @value: the byte to write + * @value: register value to write (u32) */ static inline void mei_reg_write(struct mei_device *dev, unsigned long offset, u32 value) From 9ce178e539e0511571a9517e63980e68427b5585 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:09 +0300 Subject: [PATCH 0930/1519] staging: mei: registering the MEI driver with the kernel watchdog core interface Adding kernel watchdog interface (/dev/watchdog) to the MEI Driver to support AMT Watchdog feature. This patch and the following one will replace MEI Driver self management of the AMT watchdog with the standard kernel watchdog interface. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/init.c | 1 + drivers/staging/mei/interface.h | 4 +++- drivers/staging/mei/interrupt.c | 12 ++++++++++++ drivers/staging/mei/main.c | 4 ++++ drivers/staging/mei/mei_dev.h | 9 +++++++++ drivers/staging/mei/wd.c | 20 ++++++++++++++++++-- 6 files changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c index 69a57e77a09..cb0ebbedf67 100644 --- a/drivers/staging/mei/init.c +++ b/drivers/staging/mei/init.c @@ -133,6 +133,7 @@ struct mei_device *mei_device_init(struct pci_dev *pdev) init_waitqueue_head(&dev->wait_stop_wd); dev->mei_state = MEI_INITIALIZING; dev->iamthif_state = MEI_IAMTHIF_IDLE; + dev->wd_interface_reg = false; mei_io_list_init(&dev->read_list); diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h index 7bcf0966030..2b5a22c23f7 100644 --- a/drivers/staging/mei/interface.h +++ b/drivers/staging/mei/interface.h @@ -23,7 +23,9 @@ #include "mei_dev.h" -#define AMT_WD_VALUE 120 /* seconds */ +#define AMT_WD_DEFAULT_TIMEOUT 120 /* seconds */ +#define AMT_WD_MIN_TIMEOUT 120 /* seconds */ +#define AMT_WD_MAX_TIMEOUT 65535 /* seconds */ #define MEI_WATCHDOG_DATA_SIZE 16 #define MEI_START_WD_DATA_SIZE 20 diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index ca1e0c90a94..958a7e2958b 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -396,6 +396,18 @@ static void mei_client_connect_response(struct mei_device *dev, dev->wd_due_counter = (dev->wd_timeout) ? 1 : 0; dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n"); + + /* Registering watchdog interface device once we got connection + to the WD Client + */ + if (watchdog_register_device(&amt_wd_dev)) { + printk(KERN_ERR "mei: unable to register watchdog device.\n"); + dev->wd_interface_reg = false; + } else { + dev_dbg(&dev->pdev->dev, "successfully register watchdog interface.\n"); + dev->wd_interface_reg = true; + } + mei_host_init_iamthif(dev); return; } diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index 78028f8c0b8..c4ebd07a2dd 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -241,6 +241,10 @@ static void __devexit mei_remove(struct pci_dev *pdev) mei_disconnect_host_client(dev, &dev->wd_cl); } + /* Unregistering watchdog device */ + if (dev->wd_interface_reg) + watchdog_unregister_device(&amt_wd_dev); + /* remove entry if already in list */ dev_dbg(&pdev->dev, "list del iamthif and wd file list.\n"); mei_remove_client_from_file_list(dev, dev->wd_cl.host_client_id); diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h index 2e1107762ef..d434afc3ffe 100644 --- a/drivers/staging/mei/mei_dev.h +++ b/drivers/staging/mei/mei_dev.h @@ -18,6 +18,7 @@ #define _MEI_DEV_H_ #include +#include #include "mei.h" #include "hw.h" @@ -36,6 +37,12 @@ #define MEI_WD_PARAMS_SIZE 4 #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) +/* + * AMT Watchdog Device + */ +#define INTEL_AMT_WATCHDOG_ID "INTCAMT" +extern struct watchdog_device amt_wd_dev; + /* * AMTHI Client UUID */ @@ -258,6 +265,8 @@ struct mei_device { bool iamthif_flow_control_pending; bool iamthif_ioctl; bool iamthif_canceled; + + bool wd_interface_reg; }; diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index 721487d05ba..d9e41a7a5af 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -19,20 +19,36 @@ #include #include #include +#include #include "mei_dev.h" #include "hw.h" #include "interface.h" #include "mei.h" +/* + * Watchdog Device structs + */ +const struct watchdog_info wd_info = { + .identity = INTEL_AMT_WATCHDOG_ID, +}; + +struct watchdog_device amt_wd_dev = { + .info = &wd_info, + .timeout = AMT_WD_DEFAULT_TIMEOUT, + .min_timeout = AMT_WD_MIN_TIMEOUT, + .max_timeout = AMT_WD_MAX_TIMEOUT, +}; + + /* * MEI Watchdog Module Parameters */ -static u16 watchdog_timeout = AMT_WD_VALUE; +static u16 watchdog_timeout = AMT_WD_DEFAULT_TIMEOUT; module_param(watchdog_timeout, ushort, 0); MODULE_PARM_DESC(watchdog_timeout, "Intel(R) AMT Watchdog timeout value in seconds. (default=" - __MODULE_STRING(AMT_WD_VALUE) + __MODULE_STRING(AMT_WD_DEFAULT_TIMEOUT) ", disable=0)"); static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 }; From 4a3cafd5d98e7442471e1dae821b044ec49348de Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:10 +0300 Subject: [PATCH 0931/1519] staging: mei: adding watchdog ops adding start and stop function. start - check if AMT wd client is connected, which is been connected on driver load. stop - send stop command to AMT wd. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/main.c | 2 +- drivers/staging/mei/mei_dev.h | 5 ++ drivers/staging/mei/wd.c | 95 +++++++++++++++++++++++++++++------ 3 files changed, 86 insertions(+), 16 deletions(-) diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index c4ebd07a2dd..386c27952d1 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -58,7 +58,7 @@ static struct cdev mei_cdev; static int mei_major; /* The device pointer */ /* Currently this driver works as long as there is only a single AMT device. */ -static struct pci_dev *mei_device; +struct pci_dev *mei_device; static struct class *mei_class; diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h index d434afc3ffe..43d7e1c0441 100644 --- a/drivers/staging/mei/mei_dev.h +++ b/drivers/staging/mei/mei_dev.h @@ -37,6 +37,11 @@ #define MEI_WD_PARAMS_SIZE 4 #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) +/* + * MEI PCI Device object + */ +extern struct pci_dev *mei_device; + /* * AMT Watchdog Device */ diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index d9e41a7a5af..fb2bd3d4334 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -26,21 +26,6 @@ #include "interface.h" #include "mei.h" -/* - * Watchdog Device structs - */ -const struct watchdog_info wd_info = { - .identity = INTEL_AMT_WATCHDOG_ID, -}; - -struct watchdog_device amt_wd_dev = { - .info = &wd_info, - .timeout = AMT_WD_DEFAULT_TIMEOUT, - .min_timeout = AMT_WD_MIN_TIMEOUT, - .max_timeout = AMT_WD_MAX_TIMEOUT, -}; - - /* * MEI Watchdog Module Parameters */ @@ -210,3 +195,83 @@ out: return ret; } +/* + * mei_wd_ops_start - wd start command from the watchdog core. + * + * @wd_dev - watchdog device struct + * + * returns 0 if success, negative errno code for failure + */ +static int mei_wd_ops_start(struct watchdog_device *wd_dev) +{ + int err = -ENODEV; + struct mei_device *dev; + + dev = pci_get_drvdata(mei_device); + if (!dev) + return -ENODEV; + + mutex_lock(&dev->device_lock); + + if (dev->mei_state != MEI_ENABLED) { + dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n", + dev->mei_state); + goto end_unlock; + } + + if (dev->wd_cl.state != MEI_FILE_CONNECTED) { + dev_dbg(&dev->pdev->dev, "MEI Driver is not connected to Watchdog Client\n"); + goto end_unlock; + } + + mei_wd_start_setup(dev); + + err = 0; +end_unlock: + mutex_unlock(&dev->device_lock); + return err; +} + +/* + * mei_wd_ops_stop - wd stop command from the watchdog core. + * + * @wd_dev - watchdog device struct + * + * returns 0 if success, negative errno code for failure + */ +static int mei_wd_ops_stop(struct watchdog_device *wd_dev) +{ + struct mei_device *dev; + dev = pci_get_drvdata(mei_device); + + if (!dev) + return -ENODEV; + + mutex_lock(&dev->device_lock); + mei_wd_stop(dev, false); + mutex_unlock(&dev->device_lock); + + return 0; +} + +/* + * Watchdog Device structs + */ +const struct watchdog_ops wd_ops = { + .owner = THIS_MODULE, + .start = mei_wd_ops_start, + .stop = mei_wd_ops_stop, +}; +const struct watchdog_info wd_info = { + .identity = INTEL_AMT_WATCHDOG_ID, +}; + +struct watchdog_device amt_wd_dev = { + .info = &wd_info, + .ops = &wd_ops, + .timeout = AMT_WD_DEFAULT_TIMEOUT, + .min_timeout = AMT_WD_MIN_TIMEOUT, + .max_timeout = AMT_WD_MAX_TIMEOUT, +}; + + From 8c4a59a789dfee1e66d7597521e860d2fd8cd638 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:11 +0300 Subject: [PATCH 0932/1519] staging: mei: adding watchdog ping adding watchdog ping to send ping/heartbeat to the the AMT watchdog client. in addition removing the heartbeat sending from the driver timers function. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/interrupt.c | 27 ----------------- drivers/staging/mei/wd.c | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index 958a7e2958b..62b8001ba1d 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -1430,33 +1430,6 @@ void mei_wd_timer(struct work_struct *work) } } - if (dev->wd_cl.state != MEI_FILE_CONNECTED) - goto out; - - /* Watchdog */ - if (dev->wd_due_counter && !dev->wd_bypass) { - if (--dev->wd_due_counter == 0) { - if (dev->mei_host_buffer_is_empty && - mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { - dev->mei_host_buffer_is_empty = false; - dev_dbg(&dev->pdev->dev, "send watchdog.\n"); - - if (mei_wd_send(dev)) - dev_dbg(&dev->pdev->dev, "wd send failed.\n"); - else - if (mei_flow_ctrl_reduce(dev, &dev->wd_cl)) - goto out; - - if (dev->wd_timeout) - dev->wd_due_counter = 2; - else - dev->wd_due_counter = 0; - - } else - dev->wd_pending = true; - - } - } if (dev->iamthif_stall_timer) { if (--dev->iamthif_stall_timer == 0) { dev_dbg(&dev->pdev->dev, "reseting because of hang to amthi.\n"); diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index fb2bd3d4334..9338394b236 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -254,6 +254,58 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev) return 0; } +/* + * mei_wd_ops_ping - wd ping command from the watchdog core. + * + * @wd_dev - watchdog device struct + * + * returns 0 if success, negative errno code for failure + */ +static int mei_wd_ops_ping(struct watchdog_device *wd_dev) +{ + int ret = 0; + struct mei_device *dev; + dev = pci_get_drvdata(mei_device); + + if (!dev) + return -ENODEV; + + mutex_lock(&dev->device_lock); + + if (dev->wd_cl.state != MEI_FILE_CONNECTED) { + dev_dbg(&dev->pdev->dev, "wd is not connected.\n"); + ret = -ENODEV; + goto end; + } + + /* Check if we can send the ping to HW*/ + if (dev->mei_host_buffer_is_empty && + mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { + + dev->mei_host_buffer_is_empty = false; + dev_dbg(&dev->pdev->dev, "sending watchdog ping\n"); + + if (mei_wd_send(dev)) { + dev_dbg(&dev->pdev->dev, "wd send failed.\n"); + ret = -EIO; + goto end; + } + + if (mei_flow_ctrl_reduce(dev, &dev->wd_cl)) { + dev_dbg(&dev->pdev->dev, "mei_flow_ctrl_reduce() failed.\n"); + ret = -EIO; + goto end; + } + + } else { + dev->wd_pending = true; + } + +end: + mutex_unlock(&dev->device_lock); + return ret; +} + /* * Watchdog Device structs */ @@ -261,9 +313,11 @@ const struct watchdog_ops wd_ops = { .owner = THIS_MODULE, .start = mei_wd_ops_start, .stop = mei_wd_ops_stop, + .ping = mei_wd_ops_ping, }; const struct watchdog_info wd_info = { .identity = INTEL_AMT_WATCHDOG_ID, + .options = WDIOF_KEEPALIVEPING, }; struct watchdog_device amt_wd_dev = { From 55d3385672ba6315d45b396e9668e2660e426179 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:12 +0300 Subject: [PATCH 0933/1519] staging: mei: adding set_timeout watchdog function add the ability to let the watchdog core set the AMT watchdog timeout value. the default value will be only set in the start function. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/interface.h | 2 +- drivers/staging/mei/main.c | 1 - drivers/staging/mei/wd.c | 40 ++++++++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h index 2b5a22c23f7..7bd38ae2c23 100644 --- a/drivers/staging/mei/interface.h +++ b/drivers/staging/mei/interface.h @@ -51,7 +51,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); int mei_wd_send(struct mei_device *dev); int mei_wd_stop(struct mei_device *dev, bool preserve); bool mei_wd_host_init(struct mei_device *dev); -void mei_wd_start_setup(struct mei_device *dev); +void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout); int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl); diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index 386c27952d1..670feb7f91a 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -1153,7 +1153,6 @@ static int mei_pci_resume(struct device *device) /* Start watchdog if stopped in suspend */ if (dev->wd_timeout) { - mei_wd_start_setup(dev); dev->wd_due_counter = 1; schedule_delayed_work(&dev->wd_work, HZ); } diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index 9338394b236..6643f7aa97d 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -51,12 +51,12 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89, 0x32, 0xAB); -void mei_wd_start_setup(struct mei_device *dev) +void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) { - dev_dbg(&dev->pdev->dev, "dev->wd_timeout=%d.\n", dev->wd_timeout); + dev_dbg(&dev->pdev->dev, "timeout=%d.\n", timeout); memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE); memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE, - &dev->wd_timeout, sizeof(u16)); + &timeout, sizeof(u16)); } /** @@ -75,7 +75,6 @@ bool mei_wd_host_init(struct mei_device *dev) dev->wd_timeout = watchdog_timeout; if (dev->wd_timeout > 0) { - mei_wd_start_setup(dev); /* find ME WD client */ mei_find_me_client_update_filext(dev, &dev->wd_cl, &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); @@ -224,7 +223,7 @@ static int mei_wd_ops_start(struct watchdog_device *wd_dev) goto end_unlock; } - mei_wd_start_setup(dev); + mei_wd_set_start_timeout(dev, dev->wd_timeout); err = 0; end_unlock: @@ -306,6 +305,36 @@ end: return ret; } +/* + * mei_wd_ops_set_timeout - wd set timeout command from the watchdog core. + * + * @wd_dev - watchdog device struct + * @timeout - timeout value to set + * + * returns 0 if success, negative errno code for failure + */ +static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout) +{ + struct mei_device *dev; + dev = pci_get_drvdata(mei_device); + + if (!dev) + return -ENODEV; + + /* Check Timeout value */ + if (timeout < AMT_WD_MIN_TIMEOUT || timeout > AMT_WD_MAX_TIMEOUT) + return -EINVAL; + + mutex_lock(&dev->device_lock); + + dev->wd_timeout = timeout; + mei_wd_set_start_timeout(dev, dev->wd_timeout); + + mutex_unlock(&dev->device_lock); + + return 0; +} + /* * Watchdog Device structs */ @@ -314,6 +343,7 @@ const struct watchdog_ops wd_ops = { .start = mei_wd_ops_start, .stop = mei_wd_ops_stop, .ping = mei_wd_ops_ping, + .set_timeout = mei_wd_ops_set_timeout, }; const struct watchdog_info wd_info = { .identity = INTEL_AMT_WATCHDOG_ID, From a61c6530a6e2fb74f3e1a80bd367412ac4aa6925 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:13 +0300 Subject: [PATCH 0934/1519] staging: mei: renaming delayed work field and function to a meaningful name. the wd_work and mei_wd_timer() function was not just for watchdog. mei managing the AMT watchdog going to be replace by the kernel watchdog interface. the mei_timer() will still manage the mei driver timeouts. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/interrupt.c | 6 +++--- drivers/staging/mei/main.c | 6 +++--- drivers/staging/mei/mei_dev.h | 4 ++-- drivers/staging/mei/wd.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index 62b8001ba1d..d1da3aa1cd5 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -1393,7 +1393,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, * * NOTE: This function is called by timer interrupt work */ -void mei_wd_timer(struct work_struct *work) +void mei_timer(struct work_struct *work) { unsigned long timeout; struct mei_cl *cl_pos = NULL; @@ -1403,7 +1403,7 @@ void mei_wd_timer(struct work_struct *work) struct mei_cl_cb *cb_next = NULL; struct mei_device *dev = container_of(work, - struct mei_device, wd_work.work); + struct mei_device, timer_work.work); mutex_lock(&dev->device_lock); @@ -1495,7 +1495,7 @@ void mei_wd_timer(struct work_struct *work) } } out: - schedule_delayed_work(&dev->wd_work, 2 * HZ); + schedule_delayed_work(&dev->timer_work, 2 * HZ); mutex_unlock(&dev->device_lock); } diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index 670feb7f91a..925de38adc8 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -170,7 +170,7 @@ static int __devinit mei_probe(struct pci_dev *pdev, pdev->irq); goto unmap_memory; } - INIT_DELAYED_WORK(&dev->wd_work, mei_wd_timer); + INIT_DELAYED_WORK(&dev->timer_work, mei_timer); if (mei_hw_init(dev)) { printk(KERN_ERR "mei: Init hw failure.\n"); err = -ENODEV; @@ -178,7 +178,7 @@ static int __devinit mei_probe(struct pci_dev *pdev, } mei_device = pdev; pci_set_drvdata(pdev, dev); - schedule_delayed_work(&dev->wd_work, HZ); + schedule_delayed_work(&dev->timer_work, HZ); mutex_unlock(&mei_mutex); @@ -1154,7 +1154,7 @@ static int mei_pci_resume(struct device *device) /* Start watchdog if stopped in suspend */ if (dev->wd_timeout) { dev->wd_due_counter = 1; - schedule_delayed_work(&dev->wd_work, HZ); + schedule_delayed_work(&dev->timer_work, HZ); } return err; } diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h index 43d7e1c0441..6487be1a4bf 100644 --- a/drivers/staging/mei/mei_dev.h +++ b/drivers/staging/mei/mei_dev.h @@ -209,7 +209,7 @@ struct mei_device { * lock for the device */ struct mutex device_lock; /* device lock */ - struct delayed_work wd_work; /* watch dog deleye work */ + struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ bool recvd_msg; /* * hw states of host and fw(ME) @@ -336,7 +336,7 @@ void mei_host_client_properties(struct mei_device *dev); */ irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id); irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id); -void mei_wd_timer(struct work_struct *work); +void mei_timer(struct work_struct *work); /* * MEI input output function prototype diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index 6643f7aa97d..68c177be7e4 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -142,7 +142,7 @@ int mei_wd_stop(struct mei_device *dev, bool preserve) int ret; u16 wd_timeout = dev->wd_timeout; - cancel_delayed_work(&dev->wd_work); + cancel_delayed_work(&dev->timer_work); if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout) return 0; From 6d70e935596a51742ecc899b3d9629f11e506522 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:14 +0300 Subject: [PATCH 0935/1519] staging: mei: resuming timer regardless of the watchdog timeout value. the timer_work does not only handle watchdog but also handles mei timeouts. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c index 925de38adc8..eb05c36f45d 100644 --- a/drivers/staging/mei/main.c +++ b/drivers/staging/mei/main.c @@ -1151,11 +1151,9 @@ static int mei_pci_resume(struct device *device) mei_reset(dev, 1); mutex_unlock(&dev->device_lock); - /* Start watchdog if stopped in suspend */ - if (dev->wd_timeout) { - dev->wd_due_counter = 1; - schedule_delayed_work(&dev->timer_work, HZ); - } + /* Start timer if stopped in suspend */ + schedule_delayed_work(&dev->timer_work, HZ); + return err; } static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume); From 2ad64ba8ea55319ddc3c7534e77a4abee5d6fa43 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:15 +0300 Subject: [PATCH 0936/1519] staging: mei: client init code cleanup starting removing the dependency from the module parameters. setting the default timeout on init so don't need to check if it is bigger then zero. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/wd.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index 68c177be7e4..fd679524f38 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -72,32 +72,25 @@ bool mei_wd_host_init(struct mei_device *dev) /* look for WD client and connect to it */ dev->wd_cl.state = MEI_FILE_DISCONNECTED; - dev->wd_timeout = watchdog_timeout; + dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT; - if (dev->wd_timeout > 0) { - /* find ME WD client */ - mei_find_me_client_update_filext(dev, &dev->wd_cl, - &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); + /* find ME WD client */ + mei_find_me_client_update_filext(dev, &dev->wd_cl, + &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); - dev_dbg(&dev->pdev->dev, "check wd_cl\n"); - if (MEI_FILE_CONNECTING == dev->wd_cl.state) { - if (!mei_connect(dev, &dev->wd_cl)) { - dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n"); - dev->wd_cl.state = MEI_FILE_DISCONNECTED; - dev->wd_cl.host_client_id = 0; - ret = false; - goto end; - } else { - dev->wd_cl.timer_count = CONNECT_TIMEOUT; - } - } else { - dev_dbg(&dev->pdev->dev, "Failed to find WD client\n"); + dev_dbg(&dev->pdev->dev, "check wd_cl\n"); + if (MEI_FILE_CONNECTING == dev->wd_cl.state) { + if (!mei_connect(dev, &dev->wd_cl)) { + dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n"); + dev->wd_cl.state = MEI_FILE_DISCONNECTED; + dev->wd_cl.host_client_id = 0; ret = false; goto end; + } else { + dev->wd_cl.timer_count = CONNECT_TIMEOUT; } } else { - dev->wd_bypass = true; - dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n"); + dev_dbg(&dev->pdev->dev, "Failed to find WD client\n"); ret = false; goto end; } From 214b99fd418527447eade85df581a97d12fc31f8 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:16 +0300 Subject: [PATCH 0937/1519] staging: mei: removing wd module parameters wd module parameter is not needed now that driver is using watchdog core. Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/wd.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index fd679524f38..b56b1cc1e8d 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -26,16 +26,6 @@ #include "interface.h" #include "mei.h" -/* - * MEI Watchdog Module Parameters - */ -static u16 watchdog_timeout = AMT_WD_DEFAULT_TIMEOUT; -module_param(watchdog_timeout, ushort, 0); -MODULE_PARM_DESC(watchdog_timeout, - "Intel(R) AMT Watchdog timeout value in seconds. (default=" - __MODULE_STRING(AMT_WD_DEFAULT_TIMEOUT) - ", disable=0)"); - static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 }; static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 }; From d8deca315b99fca4f4c9ba559468145e52109ecc Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 7 Sep 2011 09:03:17 +0300 Subject: [PATCH 0938/1519] staging: mei: adding mei_wd_stop function comment Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/wd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c index b56b1cc1e8d..ffca7ca3265 100644 --- a/drivers/staging/mei/wd.c +++ b/drivers/staging/mei/wd.c @@ -120,6 +120,16 @@ int mei_wd_send(struct mei_device *dev) return -EIO; } +/** + * mei_wd_stop - sends watchdog stop message to fw. + * + * @dev: the device structure + * @preserve: indicate if to keep the timeout value + * + * returns 0 if success, + * -EIO when message send fails + * -EINVAL when invalid message is to be sent + */ int mei_wd_stop(struct mei_device *dev, bool preserve) { int ret; From cf05e52b026fcfb76e846596bd8e1c3f3e9420ea Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 17 Aug 2011 13:22:12 +0300 Subject: [PATCH 0939/1519] staging: mei: adding watchdog core dependency to kconfig Signed-off-by: Oren Weil Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mei/Kconfig b/drivers/staging/mei/Kconfig index 3f3f170890e..47d78a72db2 100644 --- a/drivers/staging/mei/Kconfig +++ b/drivers/staging/mei/Kconfig @@ -1,6 +1,6 @@ config INTEL_MEI tristate "Intel Management Engine Interface (Intel MEI)" - depends on X86 && PCI && EXPERIMENTAL + depends on X86 && PCI && EXPERIMENTAL && WATCHDOG_CORE help The Intel Management Engine (Intel ME) provides Manageability, Security and Media services for system containing Intel chipsets. From c94a2e47379dd647e4391a5ec9db1301b48b3e76 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 7 Sep 2011 10:20:48 -0700 Subject: [PATCH 0940/1519] staging: dt3155v4l: Remove printk noise Most of the printk's in this driver are just noise. Proper error codes are being returned so just remove the noise and clean up the whitespace in the code due to the removal. The two messages left in the probe are useful. Convert them to dev_info messages. Signed-off-by: H Hartley Sweeten Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Cc: Paul Gortmaker Cc: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155v4l/dt3155v4l.c | 122 +++++++------------------- 1 file changed, 30 insertions(+), 92 deletions(-) diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c index 4059ea60951..421df438e70 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -104,18 +104,13 @@ read_i2c_reg(void __iomem *addr, u8 index, u8 *data) iowrite32((tmp<<17) | IIC_READ, addr + IIC_CSR2); mmiowb(); udelay(45); /* wait at least 43 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { - /* error: NEW_CYCLE not cleared */ - printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); - return -EIO; - } + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) + return -EIO; /* error: NEW_CYCLE not cleared */ tmp = ioread32(addr + IIC_CSR1); if (tmp & DIRECT_ABORT) { - /* error: DIRECT_ABORT set */ - printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); /* reset DIRECT_ABORT bit */ iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; + return -EIO; /* error: DIRECT_ABORT set */ } *data = tmp>>24; return 0; @@ -141,17 +136,12 @@ write_i2c_reg(void __iomem *addr, u8 index, u8 data) iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2); mmiowb(); udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { - /* error: NEW_CYCLE not cleared */ - printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); - return -EIO; - } + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) + return -EIO; /* error: NEW_CYCLE not cleared */ if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { - /* error: DIRECT_ABORT set */ - printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); /* reset DIRECT_ABORT bit */ iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; + return -EIO; /* error: DIRECT_ABORT set */ } return 0; } @@ -187,17 +177,12 @@ static int wait_i2c_reg(void __iomem *addr) { if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { - /* error: NEW_CYCLE not cleared */ - printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); - return -EIO; - } + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) + return -EIO; /* error: NEW_CYCLE not cleared */ if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { - /* error: DIRECT_ABORT set */ - printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); /* reset DIRECT_ABORT bit */ iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; + return -EIO; /* error: DIRECT_ABORT set */ } return 0; } @@ -345,17 +330,14 @@ dt3155_irq_handler_even(int irq, void *dev_id) ipd->field_count++; return IRQ_HANDLED; /* start of field irq */ } - if ((tmp & FLD_START) && (tmp & FLD_END_ODD)) { - if (!ipd->stats.start_before_end++) - printk(KERN_ERR "dt3155: irq: START before END\n"); - } + if ((tmp & FLD_START) && (tmp & FLD_END_ODD)) + !ipd->stats.start_before_end++; /* check for corrupted fields */ /* write_i2c_reg(ipd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); */ /* write_i2c_reg(ipd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); */ tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD); if (tmp) { - if (!ipd->stats.corrupted_fields++) - printk(KERN_ERR "dt3155: corrupted field %u\n", tmp); + ipd->stats.corrupted_fields++; iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD, @@ -405,13 +387,9 @@ dt3155_open(struct file *filp) int ret = 0; struct dt3155_priv *pd = video_drvdata(filp); - printk(KERN_INFO "dt3155: open(): minor: %i, users: %i\n", - pd->vdev->minor, pd->users); - if (!pd->users) { pd->q = kzalloc(sizeof(*pd->q), GFP_KERNEL); if (!pd->q) { - printk(KERN_ERR "dt3155: error: alloc queue\n"); ret = -ENOMEM; goto err_alloc_queue; } @@ -431,10 +409,8 @@ dt3155_open(struct file *filp) pd->irq_handler = dt3155_irq_handler_even; ret = request_irq(pd->pdev->irq, pd->irq_handler, IRQF_SHARED, DT3155_NAME, pd); - if (ret) { - printk(KERN_ERR "dt3155: error: request_irq\n"); + if (ret) goto err_request_irq; - } } pd->users++; return 0; /* success */ @@ -450,9 +426,6 @@ dt3155_release(struct file *filp) { struct dt3155_priv *pd = video_drvdata(filp); - printk(KERN_INFO "dt3155: release(): minor: %i, users: %i\n", - pd->vdev->minor, pd->users - 1); - pd->users--; BUG_ON(pd->users < 0); if (!pd->users) { @@ -805,11 +778,8 @@ dt3155_init_board(struct pci_dev *pdev) /* allocate memory, and initialize the DMA machine */ buf_cpu = dma_alloc_coherent(&pdev->dev, DT3155_BUF_SIZE, &buf_dma, GFP_KERNEL); - if (!buf_cpu) { - printk(KERN_ERR "dt3155: dma_alloc_coherent " - "(in dt3155_init_board) failed\n"); + if (!buf_cpu) return -ENOMEM; - } iowrite32(buf_dma, pd->regs + EVEN_DMA_START); iowrite32(buf_dma, pd->regs + ODD_DMA_START); iowrite32(0, pd->regs + EVEN_DMA_STRIDE); @@ -830,10 +800,8 @@ dt3155_init_board(struct pci_dev *pdev) /* deallocate memory */ dma_free_coherent(&pdev->dev, DT3155_BUF_SIZE, buf_cpu, buf_dma); - if (tmp & BUSY_EVEN) { - printk(KERN_ERR "dt3155: BUSY_EVEN not cleared\n"); + if (tmp & BUSY_EVEN) return -EIO; - } return 0; } @@ -917,27 +885,18 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) int err; struct dt3155_priv *pd; - printk(KERN_INFO "dt3155: probe()\n"); err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (err) { - printk(KERN_ERR "dt3155: cannot set dma_mask\n"); + if (err) return -ENODEV; - } err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (err) { - printk(KERN_ERR "dt3155: cannot set dma_coherent_mask\n"); + if (err) return -ENODEV; - } pd = kzalloc(sizeof(*pd), GFP_KERNEL); - if (!pd) { - printk(KERN_ERR "dt3155: cannot allocate dt3155_priv\n"); + if (!pd) return -ENOMEM; - } pd->vdev = video_device_alloc(); - if (!pd->vdev) { - printk(KERN_ERR "dt3155: cannot allocate vdev structure\n"); + if (!pd->vdev) goto err_video_device_alloc; - } *pd->vdev = dt3155_vdev; pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */ video_set_drvdata(pd->vdev, pd); /* for use in video_fops */ @@ -950,34 +909,25 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) pd->csr2 = csr2_init; pd->config = config_init; err = pci_enable_device(pdev); - if (err) { - printk(KERN_ERR "dt3155: pci_dev not enabled\n"); + if (err) goto err_enable_dev; - } err = pci_request_region(pdev, 0, pci_name(pdev)); if (err) goto err_req_region; pd->regs = pci_iomap(pdev, 0, pci_resource_len(pd->pdev, 0)); - if (!pd->regs) { + if (!pd->regs) err = -ENOMEM; - printk(KERN_ERR "dt3155: pci_iomap failed\n"); goto err_pci_iomap; - } err = dt3155_init_board(pdev); - if (err) { - printk(KERN_ERR "dt3155: dt3155_init_board failed\n"); - goto err_init_board; - } - err = video_register_device(pd->vdev, VFL_TYPE_GRABBER, -1); - if (err) { - printk(KERN_ERR "dt3155: Cannot register video device\n"); - goto err_init_board; - } - err = dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE, - DMA_MEMORY_MAP); if (err) - printk(KERN_INFO "dt3155: preallocated 8 buffers\n"); - printk(KERN_INFO "dt3155: /dev/video%i is ready\n", pd->vdev->minor); + goto err_init_board; + err = video_register_device(pd->vdev, VFL_TYPE_GRABBER, -1); + if (err) + goto err_init_board; + if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE, + DMA_MEMORY_MAP)) + dev_info(&pdev->dev, "preallocated 8 buffers\n"); + dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev->minor); return 0; /* success */ err_init_board: @@ -998,7 +948,6 @@ dt3155_remove(struct pci_dev *pdev) { struct dt3155_priv *pd = pci_get_drvdata(pdev); - printk(KERN_INFO "dt3155: remove()\n"); dt3155_free_coherent(&pdev->dev); video_unregister_device(pd->vdev); pci_iounmap(pdev, pd->regs); @@ -1027,24 +976,13 @@ static struct pci_driver pci_driver = { static int __init dt3155_init_module(void) { - int err; - - printk(KERN_INFO "dt3155: ==================\n"); - printk(KERN_INFO "dt3155: init()\n"); - err = pci_register_driver(&pci_driver); - if (err) { - printk(KERN_ERR "dt3155: cannot register pci_driver\n"); - return err; - } - return 0; /* succes */ + return pci_register_driver(&pci_driver); } static void __exit dt3155_exit_module(void) { pci_unregister_driver(&pci_driver); - printk(KERN_INFO "dt3155: exit()\n"); - printk(KERN_INFO "dt3155: ==================\n"); } module_init(dt3155_init_module); From f748b65bfc8cabdf50f1a6934a9cd43f173f2264 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 7 Sep 2011 14:46:05 -0700 Subject: [PATCH 0941/1519] staging: dt3155v4l: pci_iomap returns a void __iomem * not a void * Signed-off-by: H Hartley Sweeten Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155v4l/dt3155v4l.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dt3155v4l/dt3155v4l.h b/drivers/staging/dt3155v4l/dt3155v4l.h index b0792b3d9b7..c064ebac318 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.h +++ b/drivers/staging/dt3155v4l/dt3155v4l.h @@ -204,7 +204,7 @@ struct dt3155_priv { spinlock_t lock; unsigned int field_count; struct dt3155_stats stats; - void *regs; + void __iomem *regs; int users; u8 csr2, config; }; From 170786474a6e6005f865327960da1f534b67ee84 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 7 Sep 2011 14:37:59 -0700 Subject: [PATCH 0942/1519] staging: dt3155v4l: remove irq_handler from struct dt3155_priv There is no reason to cache the irq_handler in struct dt3155_priv. Just pass the function directly in request_irq. Signed-off-by: H Hartley Sweeten Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155v4l/dt3155v4l.c | 3 +-- drivers/staging/dt3155v4l/dt3155v4l.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c index 421df438e70..05b6a2a31ac 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -406,8 +406,7 @@ dt3155_open(struct file *filp) /* disable all irqs, clear all irq flags */ iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR); - pd->irq_handler = dt3155_irq_handler_even; - ret = request_irq(pd->pdev->irq, pd->irq_handler, + ret = request_irq(pd->pdev->irq, dt3155_irq_handler_even, IRQF_SHARED, DT3155_NAME, pd); if (ret) goto err_request_irq; diff --git a/drivers/staging/dt3155v4l/dt3155v4l.h b/drivers/staging/dt3155v4l/dt3155v4l.h index c064ebac318..2e4f89d402e 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.h +++ b/drivers/staging/dt3155v4l/dt3155v4l.h @@ -183,7 +183,6 @@ struct dt3155_stats { * @q pointer to vb2_queue structure * @curr_buf: pointer to curren buffer * @mux: mutex to protect the instance - * @irq_handler: irq handler for the driver * @dmaq queue for dma buffers * @lock spinlock for dma queue * @field_count fields counter @@ -199,7 +198,6 @@ struct dt3155_priv { struct vb2_queue *q; struct vb2_buffer *curr_buf; struct mutex mux; - irq_handler_t irq_handler; struct list_head dmaq; spinlock_t lock; unsigned int field_count; From f2c73011117f6b45dea01f5450285405b5e88efb Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 8 Sep 2011 07:24:12 -0700 Subject: [PATCH 0943/1519] Staging: hv: vmbus: Rename vmbus_child_device_create The vmbus devices are NOT child devices; rename vmbus_child_device_create to reflect this. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 2 +- drivers/staging/hv/hyperv_vmbus.h | 2 +- drivers/staging/hv/vmbus_drv.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 11beb41c373..f99b944a9a7 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -383,7 +383,7 @@ static void vmbus_process_offer(struct work_struct *work) * We need to set the DeviceObject field before calling * vmbus_child_dev_add() */ - newchannel->device_obj = vmbus_child_device_create( + newchannel->device_obj = vmbus_device_create( &newchannel->offermsg.offer.if_type, &newchannel->offermsg.offer.if_instance, newchannel); diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h index 16ca90d9ac2..e97e2cf0fa4 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/staging/hv/hyperv_vmbus.h @@ -601,7 +601,7 @@ extern struct vmbus_connection vmbus_connection; /* General vmbus interface */ -struct hv_device *vmbus_child_device_create(uuid_le *type, +struct hv_device *vmbus_device_create(uuid_le *type, uuid_le *instance, struct vmbus_channel *channel); diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index c0f3b7a1530..382baee4dfb 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -594,10 +594,10 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver) EXPORT_SYMBOL_GPL(vmbus_driver_unregister); /* - * vmbus_child_device_create - Creates and registers a new child device + * vmbus_device_create - Creates and registers a new child device * on the vmbus. */ -struct hv_device *vmbus_child_device_create(uuid_le *type, +struct hv_device *vmbus_device_create(uuid_le *type, uuid_le *instance, struct vmbus_channel *channel) { From 22794281974f9ba7770615191c382cca03067736 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 8 Sep 2011 07:24:13 -0700 Subject: [PATCH 0944/1519] Staging: hv: vmbus: Rename vmbus_child_device_register The vmbus devices are NOT child devices; rename vmbus_child_device_register to reflect this. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 2 +- drivers/staging/hv/hyperv_vmbus.h | 2 +- drivers/staging/hv/vmbus_drv.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index f99b944a9a7..a9270467bb9 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -393,7 +393,7 @@ static void vmbus_process_offer(struct work_struct *work) * binding which eventually invokes the device driver's AddDevice() * method. */ - ret = vmbus_child_device_register(newchannel->device_obj); + ret = vmbus_device_register(newchannel->device_obj); if (ret != 0) { pr_err("unable to add child device object (relid %d)\n", newchannel->offermsg.child_relid); diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h index e97e2cf0fa4..b2dfcd650f1 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/staging/hv/hyperv_vmbus.h @@ -605,7 +605,7 @@ struct hv_device *vmbus_device_create(uuid_le *type, uuid_le *instance, struct vmbus_channel *channel); -int vmbus_child_device_register(struct hv_device *child_device_obj); +int vmbus_device_register(struct hv_device *child_device_obj); void vmbus_child_device_unregister(struct hv_device *device_obj); /* static void */ diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 382baee4dfb..6d54ea1fbc3 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -619,9 +619,9 @@ struct hv_device *vmbus_device_create(uuid_le *type, } /* - * vmbus_child_device_register - Register the child device + * vmbus_device_register - Register the child device */ -int vmbus_child_device_register(struct hv_device *child_device_obj) +int vmbus_device_register(struct hv_device *child_device_obj) { int ret = 0; From 696453ba2830501274b17a5953c40f7794a56df0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 8 Sep 2011 07:24:14 -0700 Subject: [PATCH 0945/1519] Staging: hv: vmbus: Rename vmbus_child_device_unregister The vmbus devices are NOT child devices; rename vmbus_child_device_unregister to reflect this. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 2 +- drivers/staging/hv/hyperv_vmbus.h | 2 +- drivers/staging/hv/vmbus_drv.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index a9270467bb9..60ce1d1492f 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -333,7 +333,7 @@ static void vmbus_process_rescind_offer(struct work_struct *work) struct vmbus_channel, work); - vmbus_child_device_unregister(channel->device_obj); + vmbus_device_unregister(channel->device_obj); } /* diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h index b2dfcd650f1..3d2d836c3cc 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/staging/hv/hyperv_vmbus.h @@ -606,7 +606,7 @@ struct hv_device *vmbus_device_create(uuid_le *type, struct vmbus_channel *channel); int vmbus_device_register(struct hv_device *child_device_obj); -void vmbus_child_device_unregister(struct hv_device *device_obj); +void vmbus_device_unregister(struct hv_device *device_obj); /* static void */ /* VmbusChildDeviceDestroy( */ diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 6d54ea1fbc3..375e45184d2 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -650,10 +650,10 @@ int vmbus_device_register(struct hv_device *child_device_obj) } /* - * vmbus_child_device_unregister - Remove the specified child device + * vmbus_device_unregister - Remove the specified child device * from the vmbus. */ -void vmbus_child_device_unregister(struct hv_device *device_obj) +void vmbus_device_unregister(struct hv_device *device_obj) { /* * Kick off the process of unregistering the device. From 66e60413db488e4830286220152ae63d31c32a6a Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 8 Sep 2011 07:24:15 -0700 Subject: [PATCH 0946/1519] Staging: hv: vmbus: Cleanup dated comments in channel_mgmt.c Cleanup dated comments in channel_mgmt.c. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 60ce1d1492f..c68e5fad0f9 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -433,9 +433,6 @@ static void vmbus_process_offer(struct work_struct *work) /* * vmbus_onoffer - Handler for channel offers from vmbus in parent partition. * - * We ignore all offers except network and storage offers. For each network and - * storage offers, we create a channel object and queue a work item to the - * channel object to process the offer synchronously */ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) { From 25d7315a19bae4c880ca25b75fe8c632b79a21b7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 9 Sep 2011 09:53:05 +0100 Subject: [PATCH 0947/1519] staging:iio:light: V3 fix out of bounds reg_cache[] access V3 is a straightforward forward port to teh current tree of V2. Simple fix is to just not cache REG_TEST (offset 8). Cache doesn't help REG_TEST anyway since we write all 8 bits exactly once (at resume/init time). Also fix an "off-by-one" allocation of reg_cache[] array size that was in the original code before I touched it. Reported-by: Dan Carpenter Signed-off-by: Grant Grundler Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/isl29018.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index f31e8c2fc5b..3e9a06c2050 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -51,7 +51,7 @@ #define ISL29018_REG_ADD_DATA_LSB 0x02 #define ISL29018_REG_ADD_DATA_MSB 0x03 -#define ISL29018_MAX_REGS ISL29018_REG_ADD_DATA_MSB +#define ISL29018_MAX_REGS (ISL29018_REG_ADD_DATA_MSB+1) #define ISL29018_REG_TEST 0x08 #define ISL29018_TEST_SHIFT 0 @@ -70,22 +70,27 @@ struct isl29018_chip { static int isl29018_write_data(struct i2c_client *client, u8 reg, u8 val, u8 mask, u8 shift) { - u8 regval; - int ret = 0; + u8 regval = val; + int ret; struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client)); - regval = chip->reg_cache[reg]; - regval &= ~mask; - regval |= val << shift; + /* don't cache or mask REG_TEST */ + if (reg < ISL29018_MAX_REGS) { + regval = chip->reg_cache[reg]; + regval &= ~mask; + regval |= val << shift; + } ret = i2c_smbus_write_byte_data(client, reg, regval); if (ret) { dev_err(&client->dev, "Write to device fails status %x\n", ret); - return ret; + } else { + /* don't update cache on err */ + if (reg < ISL29018_MAX_REGS) + chip->reg_cache[reg] = regval; } - chip->reg_cache[reg] = regval; - return 0; + return ret; } static int isl29018_set_range(struct i2c_client *client, unsigned long range, From 2ccbec05ac9917a09aeb2f647667b734b4f02ce1 Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Fri, 9 Sep 2011 19:01:00 -0400 Subject: [PATCH 0948/1519] zram: Fix sparse warnings Fixes sparse warning: zram_drv.c:666:6: warning: symbol 'zram_slot_free_notify' was not declared. Should it be static? Also, max_zpage_size is now size_t just to be consistent with data-type of other variables maintaining sizes of various kinds. Signed-off-by: Nitin Gupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 3 ++- drivers/staging/zram/zram_drv.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index dbb436863e7..b9926ee0052 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -697,7 +697,8 @@ fail: return ret; } -void zram_slot_free_notify(struct block_device *bdev, unsigned long index) +static void zram_slot_free_notify(struct block_device *bdev, + unsigned long index) { struct zram *zram; diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 7fdeb7d39ae..e5cd2469b6a 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -47,7 +47,7 @@ static const unsigned default_disksize_perc_ram = 25; * Pages that compress to size greater than this are stored * uncompressed in memory. */ -static const unsigned max_zpage_size = PAGE_SIZE / 4 * 3; +static const size_t max_zpage_size = PAGE_SIZE / 4 * 3; /* * NOTE: max_zpage_size must be less than or equal to: From 7ae70c8b8c8c22d4a4f333fa132b01da3c25a453 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:29 +0800 Subject: [PATCH 0949/1519] Staging: cx25821: Get rid of typedef in cx25821.h Get rid of typedef in cx25821.h Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h index 6230243e2cc..a282592a827 100644 --- a/drivers/staging/cx25821/cx25821.h +++ b/drivers/staging/cx25821/cx25821.h @@ -179,15 +179,17 @@ struct cx25821_input { u32 gpio0, gpio1, gpio2, gpio3; }; -typedef enum { +enum port { CX25821_UNDEFINED = 0, CX25821_RAW, CX25821_264 -} port_t; +}; struct cx25821_board { char *name; - port_t porta, portb, portc; + enum port porta; + enum port portb; + enum port portc; unsigned int tuner_type; unsigned int radio_type; unsigned char tuner_addr; From 6100c579428cc31c636cf413beecb59bedc952c9 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:30 +0800 Subject: [PATCH 0950/1519] Staging: cx25821: Rename member name in struct cx25821_dev Rename _audio_upstream_channel_select to _audio_upstream_channel in in struct cx25821_dev in cx25821.h and all usages of that struct member as well, because _audio_upstream_channel_select is seems to be too long for a variable name. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-audio-upstream.c | 10 +++++----- drivers/staging/cx25821/cx25821.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c index 0f9ca777bd4..55df658b52c 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.c +++ b/drivers/staging/cx25821/cx25821-audio-upstream.c @@ -107,7 +107,7 @@ static __le32 *cx25821_risc_field_upstream_audio(struct cx25821_dev *dev, { unsigned int line; struct sram_channel *sram_ch = - dev->channels[dev->_audio_upstream_channel_select].sram_channels; + dev->channels[dev->_audio_upstream_channel].sram_channels; int offset = 0; /* scan lines */ @@ -351,7 +351,7 @@ static void cx25821_audioups_handler(struct work_struct *work) cx25821_get_audio_data(dev, dev->channels[dev-> - _audio_upstream_channel_select]. + _audio_upstream_channel]. sram_channels); } @@ -604,7 +604,7 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id) if (!dev) return -1; - sram_ch = dev->channels[dev->_audio_upstream_channel_select].sram_channels; + sram_ch = dev->channels[dev->_audio_upstream_channel].sram_channels; msk_stat = cx_read(sram_ch->int_mstat); audio_status = cx_read(sram_ch->int_stat); @@ -614,7 +614,7 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id) handled = cx25821_audio_upstream_irq(dev, dev-> - _audio_upstream_channel_select, + _audio_upstream_channel, audio_status); } @@ -726,7 +726,7 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) return 0; } - dev->_audio_upstream_channel_select = channel_select; + dev->_audio_upstream_channel = channel_select; sram_ch = dev->channels[channel_select].sram_channels; /* Work queue */ diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h index a282592a827..db2615b2bac 100644 --- a/drivers/staging/cx25821/cx25821.h +++ b/drivers/staging/cx25821/cx25821.h @@ -310,7 +310,7 @@ struct cx25821_dev { int _audiofile_status; int _audio_lines_count; int _audioframe_count; - int _audio_upstream_channel_select; + int _audio_upstream_channel; int _last_index_irq; /* The last interrupt index processed. */ __le32 *_risc_audio_jmp_addr; From bde780a17a628d46e6458433611a18ad861deb34 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:31 +0800 Subject: [PATCH 0951/1519] Staging: cx25821: Delete file cx25821-gpio.h Delete file cx25821-gpio.h since it is not used. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-gpio.h | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 drivers/staging/cx25821/cx25821-gpio.h diff --git a/drivers/staging/cx25821/cx25821-gpio.h b/drivers/staging/cx25821/cx25821-gpio.h deleted file mode 100644 index ca07644154a..00000000000 --- a/drivers/staging/cx25821/cx25821-gpio.h +++ /dev/null @@ -1,2 +0,0 @@ - -void cx25821_gpio_init(struct athena_dev *dev); From 8eea455e6dae0fc9e509d4f32c3773567c4cb802 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:32 +0800 Subject: [PATCH 0952/1519] Staging: cx25821: Move EXPORT_SYMBOL() to the right place Move EXPORT_SYMBOL(cx25821_set_gpiopin_direction) to the right place. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-core.c | 1 - drivers/staging/cx25821/cx25821-gpio.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c index 523ac5e16c1..8e8a56d253e 100644 --- a/drivers/staging/cx25821/cx25821-core.c +++ b/drivers/staging/cx25821/cx25821-core.c @@ -1512,7 +1512,6 @@ static void __exit cx25821_fini(void) pci_unregister_driver(&cx25821_pci_driver); } -EXPORT_SYMBOL(cx25821_set_gpiopin_direction); module_init(cx25821_init); module_exit(cx25821_fini); diff --git a/drivers/staging/cx25821/cx25821-gpio.c b/drivers/staging/cx25821/cx25821-gpio.c index 2f154b3658a..29e43b03c85 100644 --- a/drivers/staging/cx25821/cx25821-gpio.c +++ b/drivers/staging/cx25821/cx25821-gpio.c @@ -50,6 +50,7 @@ void cx25821_set_gpiopin_direction(struct cx25821_dev *dev, cx_write(gpio_oe_reg, value); } +EXPORT_SYMBOL(cx25821_set_gpiopin_direction); static void cx25821_set_gpiopin_logicvalue(struct cx25821_dev *dev, int pin_number, int pin_logic_value) From 00fc8958c98d9f03e27fe81c8b3a3eeb82edb4cd Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:33 +0800 Subject: [PATCH 0953/1519] Staging: cx25821: Use DEFINE_PCI_DEVICE_TABLE for cx25821_pci_tbl Use DEFINE_PCI_DEVICE_TABLE for cx25821_pci_tbl Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c index 8e8a56d253e..26d2879f60e 100644 --- a/drivers/staging/cx25821/cx25821-core.c +++ b/drivers/staging/cx25821/cx25821-core.c @@ -1473,7 +1473,7 @@ static void __devexit cx25821_finidev(struct pci_dev *pci_dev) kfree(dev); } -static struct pci_device_id cx25821_pci_tbl[] = { +static DEFINE_PCI_DEVICE_TABLE(cx25821_pci_tbl) = { { /* CX25821 Athena */ .vendor = 0x14f1, From 0fe773df501741e97abbec24f0190b2176039eda Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:34 +0800 Subject: [PATCH 0954/1519] Staging: cx25821: Fix wrong statement indent in cx25821-cards.c Fix wrong brace placement and statement indent in cx25821-cards.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-cards.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-cards.c b/drivers/staging/cx25821/cx25821-cards.c index 94e8d685c88..6ace60313b4 100644 --- a/drivers/staging/cx25821/cx25821-cards.c +++ b/drivers/staging/cx25821/cx25821-cards.c @@ -36,17 +36,17 @@ struct cx25821_board cx25821_boards[] = { [UNKNOWN_BOARD] = { - .name = "UNKNOWN/GENERIC", - /* Ensure safe default for unknown boards */ - .clk_freq = 0, - }, + .name = "UNKNOWN/GENERIC", + /* Ensure safe default for unknown boards */ + .clk_freq = 0, + }, [CX25821_BOARD] = { - .name = "CX25821", - .portb = CX25821_RAW, - .portc = CX25821_264, - .input[0].type = CX25821_VMUX_COMPOSITE, - }, + .name = "CX25821", + .portb = CX25821_RAW, + .portc = CX25821_264, + .input[0].type = CX25821_VMUX_COMPOSITE, + }, }; @@ -54,10 +54,10 @@ const unsigned int cx25821_bcount = ARRAY_SIZE(cx25821_boards); struct cx25821_subid cx25821_subids[] = { { - .subvendor = 0x14f1, - .subdevice = 0x0920, - .card = CX25821_BOARD, - }, + .subvendor = 0x14f1, + .subdevice = 0x0920, + .card = CX25821_BOARD, + }, }; void cx25821_card_setup(struct cx25821_dev *dev) From 1c2b5520325a27efa2ac40edaa0ed62f3575d081 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:35 +0800 Subject: [PATCH 0955/1519] Staging: cx25821: Fix wrong statement indent in cx25821-core.c Fix wrong brace placement and statement indent in cx25821-core.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-core.c | 496 ++++++++++++------------- 1 file changed, 248 insertions(+), 248 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c index 26d2879f60e..3ec58af0e26 100644 --- a/drivers/staging/cx25821/cx25821-core.c +++ b/drivers/staging/cx25821/cx25821-core.c @@ -50,270 +50,270 @@ EXPORT_SYMBOL(cx25821_devlist); struct sram_channel cx25821_sram_channels[] = { [SRAM_CH00] = { - .i = SRAM_CH00, - .name = "VID A", - .cmds_start = VID_A_DOWN_CMDS, - .ctrl_start = VID_A_IQ, - .cdt = VID_A_CDT, - .fifo_start = VID_A_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA1_PTR1, - .ptr2_reg = DMA1_PTR2, - .cnt1_reg = DMA1_CNT1, - .cnt2_reg = DMA1_CNT2, - .int_msk = VID_A_INT_MSK, - .int_stat = VID_A_INT_STAT, - .int_mstat = VID_A_INT_MSTAT, - .dma_ctl = VID_DST_A_DMA_CTL, - .gpcnt_ctl = VID_DST_A_GPCNT_CTL, - .gpcnt = VID_DST_A_GPCNT, - .vip_ctl = VID_DST_A_VIP_CTL, - .pix_frmt = VID_DST_A_PIX_FRMT, - }, + .i = SRAM_CH00, + .name = "VID A", + .cmds_start = VID_A_DOWN_CMDS, + .ctrl_start = VID_A_IQ, + .cdt = VID_A_CDT, + .fifo_start = VID_A_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA1_PTR1, + .ptr2_reg = DMA1_PTR2, + .cnt1_reg = DMA1_CNT1, + .cnt2_reg = DMA1_CNT2, + .int_msk = VID_A_INT_MSK, + .int_stat = VID_A_INT_STAT, + .int_mstat = VID_A_INT_MSTAT, + .dma_ctl = VID_DST_A_DMA_CTL, + .gpcnt_ctl = VID_DST_A_GPCNT_CTL, + .gpcnt = VID_DST_A_GPCNT, + .vip_ctl = VID_DST_A_VIP_CTL, + .pix_frmt = VID_DST_A_PIX_FRMT, + }, [SRAM_CH01] = { - .i = SRAM_CH01, - .name = "VID B", - .cmds_start = VID_B_DOWN_CMDS, - .ctrl_start = VID_B_IQ, - .cdt = VID_B_CDT, - .fifo_start = VID_B_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA2_PTR1, - .ptr2_reg = DMA2_PTR2, - .cnt1_reg = DMA2_CNT1, - .cnt2_reg = DMA2_CNT2, - .int_msk = VID_B_INT_MSK, - .int_stat = VID_B_INT_STAT, - .int_mstat = VID_B_INT_MSTAT, - .dma_ctl = VID_DST_B_DMA_CTL, - .gpcnt_ctl = VID_DST_B_GPCNT_CTL, - .gpcnt = VID_DST_B_GPCNT, - .vip_ctl = VID_DST_B_VIP_CTL, - .pix_frmt = VID_DST_B_PIX_FRMT, - }, + .i = SRAM_CH01, + .name = "VID B", + .cmds_start = VID_B_DOWN_CMDS, + .ctrl_start = VID_B_IQ, + .cdt = VID_B_CDT, + .fifo_start = VID_B_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA2_PTR1, + .ptr2_reg = DMA2_PTR2, + .cnt1_reg = DMA2_CNT1, + .cnt2_reg = DMA2_CNT2, + .int_msk = VID_B_INT_MSK, + .int_stat = VID_B_INT_STAT, + .int_mstat = VID_B_INT_MSTAT, + .dma_ctl = VID_DST_B_DMA_CTL, + .gpcnt_ctl = VID_DST_B_GPCNT_CTL, + .gpcnt = VID_DST_B_GPCNT, + .vip_ctl = VID_DST_B_VIP_CTL, + .pix_frmt = VID_DST_B_PIX_FRMT, + }, [SRAM_CH02] = { - .i = SRAM_CH02, - .name = "VID C", - .cmds_start = VID_C_DOWN_CMDS, - .ctrl_start = VID_C_IQ, - .cdt = VID_C_CDT, - .fifo_start = VID_C_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA3_PTR1, - .ptr2_reg = DMA3_PTR2, - .cnt1_reg = DMA3_CNT1, - .cnt2_reg = DMA3_CNT2, - .int_msk = VID_C_INT_MSK, - .int_stat = VID_C_INT_STAT, - .int_mstat = VID_C_INT_MSTAT, - .dma_ctl = VID_DST_C_DMA_CTL, - .gpcnt_ctl = VID_DST_C_GPCNT_CTL, - .gpcnt = VID_DST_C_GPCNT, - .vip_ctl = VID_DST_C_VIP_CTL, - .pix_frmt = VID_DST_C_PIX_FRMT, - }, + .i = SRAM_CH02, + .name = "VID C", + .cmds_start = VID_C_DOWN_CMDS, + .ctrl_start = VID_C_IQ, + .cdt = VID_C_CDT, + .fifo_start = VID_C_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA3_PTR1, + .ptr2_reg = DMA3_PTR2, + .cnt1_reg = DMA3_CNT1, + .cnt2_reg = DMA3_CNT2, + .int_msk = VID_C_INT_MSK, + .int_stat = VID_C_INT_STAT, + .int_mstat = VID_C_INT_MSTAT, + .dma_ctl = VID_DST_C_DMA_CTL, + .gpcnt_ctl = VID_DST_C_GPCNT_CTL, + .gpcnt = VID_DST_C_GPCNT, + .vip_ctl = VID_DST_C_VIP_CTL, + .pix_frmt = VID_DST_C_PIX_FRMT, + }, [SRAM_CH03] = { - .i = SRAM_CH03, - .name = "VID D", - .cmds_start = VID_D_DOWN_CMDS, - .ctrl_start = VID_D_IQ, - .cdt = VID_D_CDT, - .fifo_start = VID_D_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA4_PTR1, - .ptr2_reg = DMA4_PTR2, - .cnt1_reg = DMA4_CNT1, - .cnt2_reg = DMA4_CNT2, - .int_msk = VID_D_INT_MSK, - .int_stat = VID_D_INT_STAT, - .int_mstat = VID_D_INT_MSTAT, - .dma_ctl = VID_DST_D_DMA_CTL, - .gpcnt_ctl = VID_DST_D_GPCNT_CTL, - .gpcnt = VID_DST_D_GPCNT, - .vip_ctl = VID_DST_D_VIP_CTL, - .pix_frmt = VID_DST_D_PIX_FRMT, - }, + .i = SRAM_CH03, + .name = "VID D", + .cmds_start = VID_D_DOWN_CMDS, + .ctrl_start = VID_D_IQ, + .cdt = VID_D_CDT, + .fifo_start = VID_D_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA4_PTR1, + .ptr2_reg = DMA4_PTR2, + .cnt1_reg = DMA4_CNT1, + .cnt2_reg = DMA4_CNT2, + .int_msk = VID_D_INT_MSK, + .int_stat = VID_D_INT_STAT, + .int_mstat = VID_D_INT_MSTAT, + .dma_ctl = VID_DST_D_DMA_CTL, + .gpcnt_ctl = VID_DST_D_GPCNT_CTL, + .gpcnt = VID_DST_D_GPCNT, + .vip_ctl = VID_DST_D_VIP_CTL, + .pix_frmt = VID_DST_D_PIX_FRMT, + }, [SRAM_CH04] = { - .i = SRAM_CH04, - .name = "VID E", - .cmds_start = VID_E_DOWN_CMDS, - .ctrl_start = VID_E_IQ, - .cdt = VID_E_CDT, - .fifo_start = VID_E_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA5_PTR1, - .ptr2_reg = DMA5_PTR2, - .cnt1_reg = DMA5_CNT1, - .cnt2_reg = DMA5_CNT2, - .int_msk = VID_E_INT_MSK, - .int_stat = VID_E_INT_STAT, - .int_mstat = VID_E_INT_MSTAT, - .dma_ctl = VID_DST_E_DMA_CTL, - .gpcnt_ctl = VID_DST_E_GPCNT_CTL, - .gpcnt = VID_DST_E_GPCNT, - .vip_ctl = VID_DST_E_VIP_CTL, - .pix_frmt = VID_DST_E_PIX_FRMT, - }, + .i = SRAM_CH04, + .name = "VID E", + .cmds_start = VID_E_DOWN_CMDS, + .ctrl_start = VID_E_IQ, + .cdt = VID_E_CDT, + .fifo_start = VID_E_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA5_PTR1, + .ptr2_reg = DMA5_PTR2, + .cnt1_reg = DMA5_CNT1, + .cnt2_reg = DMA5_CNT2, + .int_msk = VID_E_INT_MSK, + .int_stat = VID_E_INT_STAT, + .int_mstat = VID_E_INT_MSTAT, + .dma_ctl = VID_DST_E_DMA_CTL, + .gpcnt_ctl = VID_DST_E_GPCNT_CTL, + .gpcnt = VID_DST_E_GPCNT, + .vip_ctl = VID_DST_E_VIP_CTL, + .pix_frmt = VID_DST_E_PIX_FRMT, + }, [SRAM_CH05] = { - .i = SRAM_CH05, - .name = "VID F", - .cmds_start = VID_F_DOWN_CMDS, - .ctrl_start = VID_F_IQ, - .cdt = VID_F_CDT, - .fifo_start = VID_F_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA6_PTR1, - .ptr2_reg = DMA6_PTR2, - .cnt1_reg = DMA6_CNT1, - .cnt2_reg = DMA6_CNT2, - .int_msk = VID_F_INT_MSK, - .int_stat = VID_F_INT_STAT, - .int_mstat = VID_F_INT_MSTAT, - .dma_ctl = VID_DST_F_DMA_CTL, - .gpcnt_ctl = VID_DST_F_GPCNT_CTL, - .gpcnt = VID_DST_F_GPCNT, - .vip_ctl = VID_DST_F_VIP_CTL, - .pix_frmt = VID_DST_F_PIX_FRMT, - }, + .i = SRAM_CH05, + .name = "VID F", + .cmds_start = VID_F_DOWN_CMDS, + .ctrl_start = VID_F_IQ, + .cdt = VID_F_CDT, + .fifo_start = VID_F_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA6_PTR1, + .ptr2_reg = DMA6_PTR2, + .cnt1_reg = DMA6_CNT1, + .cnt2_reg = DMA6_CNT2, + .int_msk = VID_F_INT_MSK, + .int_stat = VID_F_INT_STAT, + .int_mstat = VID_F_INT_MSTAT, + .dma_ctl = VID_DST_F_DMA_CTL, + .gpcnt_ctl = VID_DST_F_GPCNT_CTL, + .gpcnt = VID_DST_F_GPCNT, + .vip_ctl = VID_DST_F_VIP_CTL, + .pix_frmt = VID_DST_F_PIX_FRMT, + }, [SRAM_CH06] = { - .i = SRAM_CH06, - .name = "VID G", - .cmds_start = VID_G_DOWN_CMDS, - .ctrl_start = VID_G_IQ, - .cdt = VID_G_CDT, - .fifo_start = VID_G_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA7_PTR1, - .ptr2_reg = DMA7_PTR2, - .cnt1_reg = DMA7_CNT1, - .cnt2_reg = DMA7_CNT2, - .int_msk = VID_G_INT_MSK, - .int_stat = VID_G_INT_STAT, - .int_mstat = VID_G_INT_MSTAT, - .dma_ctl = VID_DST_G_DMA_CTL, - .gpcnt_ctl = VID_DST_G_GPCNT_CTL, - .gpcnt = VID_DST_G_GPCNT, - .vip_ctl = VID_DST_G_VIP_CTL, - .pix_frmt = VID_DST_G_PIX_FRMT, - }, + .i = SRAM_CH06, + .name = "VID G", + .cmds_start = VID_G_DOWN_CMDS, + .ctrl_start = VID_G_IQ, + .cdt = VID_G_CDT, + .fifo_start = VID_G_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA7_PTR1, + .ptr2_reg = DMA7_PTR2, + .cnt1_reg = DMA7_CNT1, + .cnt2_reg = DMA7_CNT2, + .int_msk = VID_G_INT_MSK, + .int_stat = VID_G_INT_STAT, + .int_mstat = VID_G_INT_MSTAT, + .dma_ctl = VID_DST_G_DMA_CTL, + .gpcnt_ctl = VID_DST_G_GPCNT_CTL, + .gpcnt = VID_DST_G_GPCNT, + .vip_ctl = VID_DST_G_VIP_CTL, + .pix_frmt = VID_DST_G_PIX_FRMT, + }, [SRAM_CH07] = { - .i = SRAM_CH07, - .name = "VID H", - .cmds_start = VID_H_DOWN_CMDS, - .ctrl_start = VID_H_IQ, - .cdt = VID_H_CDT, - .fifo_start = VID_H_DOWN_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA8_PTR1, - .ptr2_reg = DMA8_PTR2, - .cnt1_reg = DMA8_CNT1, - .cnt2_reg = DMA8_CNT2, - .int_msk = VID_H_INT_MSK, - .int_stat = VID_H_INT_STAT, - .int_mstat = VID_H_INT_MSTAT, - .dma_ctl = VID_DST_H_DMA_CTL, - .gpcnt_ctl = VID_DST_H_GPCNT_CTL, - .gpcnt = VID_DST_H_GPCNT, - .vip_ctl = VID_DST_H_VIP_CTL, - .pix_frmt = VID_DST_H_PIX_FRMT, - }, + .i = SRAM_CH07, + .name = "VID H", + .cmds_start = VID_H_DOWN_CMDS, + .ctrl_start = VID_H_IQ, + .cdt = VID_H_CDT, + .fifo_start = VID_H_DOWN_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA8_PTR1, + .ptr2_reg = DMA8_PTR2, + .cnt1_reg = DMA8_CNT1, + .cnt2_reg = DMA8_CNT2, + .int_msk = VID_H_INT_MSK, + .int_stat = VID_H_INT_STAT, + .int_mstat = VID_H_INT_MSTAT, + .dma_ctl = VID_DST_H_DMA_CTL, + .gpcnt_ctl = VID_DST_H_GPCNT_CTL, + .gpcnt = VID_DST_H_GPCNT, + .vip_ctl = VID_DST_H_VIP_CTL, + .pix_frmt = VID_DST_H_PIX_FRMT, + }, [SRAM_CH08] = { - .name = "audio from", - .cmds_start = AUD_A_DOWN_CMDS, - .ctrl_start = AUD_A_IQ, - .cdt = AUD_A_CDT, - .fifo_start = AUD_A_DOWN_CLUSTER_1, - .fifo_size = AUDIO_CLUSTER_SIZE * 3, - .ptr1_reg = DMA17_PTR1, - .ptr2_reg = DMA17_PTR2, - .cnt1_reg = DMA17_CNT1, - .cnt2_reg = DMA17_CNT2, - }, + .name = "audio from", + .cmds_start = AUD_A_DOWN_CMDS, + .ctrl_start = AUD_A_IQ, + .cdt = AUD_A_CDT, + .fifo_start = AUD_A_DOWN_CLUSTER_1, + .fifo_size = AUDIO_CLUSTER_SIZE * 3, + .ptr1_reg = DMA17_PTR1, + .ptr2_reg = DMA17_PTR2, + .cnt1_reg = DMA17_CNT1, + .cnt2_reg = DMA17_CNT2, + }, [SRAM_CH09] = { - .i = SRAM_CH09, - .name = "VID Upstream I", - .cmds_start = VID_I_UP_CMDS, - .ctrl_start = VID_I_IQ, - .cdt = VID_I_CDT, - .fifo_start = VID_I_UP_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA15_PTR1, - .ptr2_reg = DMA15_PTR2, - .cnt1_reg = DMA15_CNT1, - .cnt2_reg = DMA15_CNT2, - .int_msk = VID_I_INT_MSK, - .int_stat = VID_I_INT_STAT, - .int_mstat = VID_I_INT_MSTAT, - .dma_ctl = VID_SRC_I_DMA_CTL, - .gpcnt_ctl = VID_SRC_I_GPCNT_CTL, - .gpcnt = VID_SRC_I_GPCNT, + .i = SRAM_CH09, + .name = "VID Upstream I", + .cmds_start = VID_I_UP_CMDS, + .ctrl_start = VID_I_IQ, + .cdt = VID_I_CDT, + .fifo_start = VID_I_UP_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA15_PTR1, + .ptr2_reg = DMA15_PTR2, + .cnt1_reg = DMA15_CNT1, + .cnt2_reg = DMA15_CNT2, + .int_msk = VID_I_INT_MSK, + .int_stat = VID_I_INT_STAT, + .int_mstat = VID_I_INT_MSTAT, + .dma_ctl = VID_SRC_I_DMA_CTL, + .gpcnt_ctl = VID_SRC_I_GPCNT_CTL, + .gpcnt = VID_SRC_I_GPCNT, - .vid_fmt_ctl = VID_SRC_I_FMT_CTL, - .vid_active_ctl1 = VID_SRC_I_ACTIVE_CTL1, - .vid_active_ctl2 = VID_SRC_I_ACTIVE_CTL2, - .vid_cdt_size = VID_SRC_I_CDT_SZ, - .irq_bit = 8, - }, + .vid_fmt_ctl = VID_SRC_I_FMT_CTL, + .vid_active_ctl1 = VID_SRC_I_ACTIVE_CTL1, + .vid_active_ctl2 = VID_SRC_I_ACTIVE_CTL2, + .vid_cdt_size = VID_SRC_I_CDT_SZ, + .irq_bit = 8, + }, [SRAM_CH10] = { - .i = SRAM_CH10, - .name = "VID Upstream J", - .cmds_start = VID_J_UP_CMDS, - .ctrl_start = VID_J_IQ, - .cdt = VID_J_CDT, - .fifo_start = VID_J_UP_CLUSTER_1, - .fifo_size = (VID_CLUSTER_SIZE << 2), - .ptr1_reg = DMA16_PTR1, - .ptr2_reg = DMA16_PTR2, - .cnt1_reg = DMA16_CNT1, - .cnt2_reg = DMA16_CNT2, - .int_msk = VID_J_INT_MSK, - .int_stat = VID_J_INT_STAT, - .int_mstat = VID_J_INT_MSTAT, - .dma_ctl = VID_SRC_J_DMA_CTL, - .gpcnt_ctl = VID_SRC_J_GPCNT_CTL, - .gpcnt = VID_SRC_J_GPCNT, + .i = SRAM_CH10, + .name = "VID Upstream J", + .cmds_start = VID_J_UP_CMDS, + .ctrl_start = VID_J_IQ, + .cdt = VID_J_CDT, + .fifo_start = VID_J_UP_CLUSTER_1, + .fifo_size = (VID_CLUSTER_SIZE << 2), + .ptr1_reg = DMA16_PTR1, + .ptr2_reg = DMA16_PTR2, + .cnt1_reg = DMA16_CNT1, + .cnt2_reg = DMA16_CNT2, + .int_msk = VID_J_INT_MSK, + .int_stat = VID_J_INT_STAT, + .int_mstat = VID_J_INT_MSTAT, + .dma_ctl = VID_SRC_J_DMA_CTL, + .gpcnt_ctl = VID_SRC_J_GPCNT_CTL, + .gpcnt = VID_SRC_J_GPCNT, - .vid_fmt_ctl = VID_SRC_J_FMT_CTL, - .vid_active_ctl1 = VID_SRC_J_ACTIVE_CTL1, - .vid_active_ctl2 = VID_SRC_J_ACTIVE_CTL2, - .vid_cdt_size = VID_SRC_J_CDT_SZ, - .irq_bit = 9, - }, + .vid_fmt_ctl = VID_SRC_J_FMT_CTL, + .vid_active_ctl1 = VID_SRC_J_ACTIVE_CTL1, + .vid_active_ctl2 = VID_SRC_J_ACTIVE_CTL2, + .vid_cdt_size = VID_SRC_J_CDT_SZ, + .irq_bit = 9, + }, [SRAM_CH11] = { - .i = SRAM_CH11, - .name = "Audio Upstream Channel B", - .cmds_start = AUD_B_UP_CMDS, - .ctrl_start = AUD_B_IQ, - .cdt = AUD_B_CDT, - .fifo_start = AUD_B_UP_CLUSTER_1, - .fifo_size = (AUDIO_CLUSTER_SIZE * 3), - .ptr1_reg = DMA22_PTR1, - .ptr2_reg = DMA22_PTR2, - .cnt1_reg = DMA22_CNT1, - .cnt2_reg = DMA22_CNT2, - .int_msk = AUD_B_INT_MSK, - .int_stat = AUD_B_INT_STAT, - .int_mstat = AUD_B_INT_MSTAT, - .dma_ctl = AUD_INT_DMA_CTL, - .gpcnt_ctl = AUD_B_GPCNT_CTL, - .gpcnt = AUD_B_GPCNT, - .aud_length = AUD_B_LNGTH, - .aud_cfg = AUD_B_CFG, - .fld_aud_fifo_en = FLD_AUD_SRC_B_FIFO_EN, - .fld_aud_risc_en = FLD_AUD_SRC_B_RISC_EN, - .irq_bit = 11, - }, + .i = SRAM_CH11, + .name = "Audio Upstream Channel B", + .cmds_start = AUD_B_UP_CMDS, + .ctrl_start = AUD_B_IQ, + .cdt = AUD_B_CDT, + .fifo_start = AUD_B_UP_CLUSTER_1, + .fifo_size = (AUDIO_CLUSTER_SIZE * 3), + .ptr1_reg = DMA22_PTR1, + .ptr2_reg = DMA22_PTR2, + .cnt1_reg = DMA22_CNT1, + .cnt2_reg = DMA22_CNT2, + .int_msk = AUD_B_INT_MSK, + .int_stat = AUD_B_INT_STAT, + .int_mstat = AUD_B_INT_MSTAT, + .dma_ctl = AUD_INT_DMA_CTL, + .gpcnt_ctl = AUD_B_GPCNT_CTL, + .gpcnt = AUD_B_GPCNT, + .aud_length = AUD_B_LNGTH, + .aud_cfg = AUD_B_CFG, + .fld_aud_fifo_en = FLD_AUD_SRC_B_FIFO_EN, + .fld_aud_risc_en = FLD_AUD_SRC_B_RISC_EN, + .irq_bit = 11, + }, }; EXPORT_SYMBOL(cx25821_sram_channels); @@ -1475,15 +1475,15 @@ static void __devexit cx25821_finidev(struct pci_dev *pci_dev) static DEFINE_PCI_DEVICE_TABLE(cx25821_pci_tbl) = { { - /* CX25821 Athena */ - .vendor = 0x14f1, - .device = 0x8210, - .subvendor = 0x14f1, - .subdevice = 0x0920, - }, + /* CX25821 Athena */ + .vendor = 0x14f1, + .device = 0x8210, + .subvendor = 0x14f1, + .subdevice = 0x0920, + }, { - /* --- end of list --- */ - } + /* --- end of list --- */ + } }; MODULE_DEVICE_TABLE(pci, cx25821_pci_tbl); From 7bfcbd6733bec1c555e62fbc39d1d9dc47ccd852 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:36 +0800 Subject: [PATCH 0956/1519] Staging: cx25821: Fix wrong statement indent in cx25821-i2c.c Fix wrong brace placement and statement indent in cx25821-i2c.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-i2c.c | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-i2c.c b/drivers/staging/cx25821/cx25821-i2c.c index 130dfebebe2..4d3d0ce4078 100644 --- a/drivers/staging/cx25821/cx25821-i2c.c +++ b/drivers/staging/cx25821/cx25821-i2c.c @@ -370,16 +370,16 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) struct i2c_msg msgs[2] = { { - .addr = client->addr, - .flags = 0, - .len = 2, - .buf = addr, - }, { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 4, - .buf = buf, - } + .addr = client->addr, + .flags = 0, + .len = 2, + .buf = addr, + }, { + .addr = client->addr, + .flags = I2C_M_RD, + .len = 4, + .buf = buf, + } }; addr[0] = (reg_addr >> 8); @@ -403,11 +403,11 @@ int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) struct i2c_msg msgs[1] = { { - .addr = client->addr, - .flags = 0, - .len = 6, - .buf = buf, - } + .addr = client->addr, + .flags = 0, + .len = 6, + .buf = buf, + } }; buf[0] = reg_addr >> 8; From cc4600c9f46d83d2ced3310e05ea9e94a5c130fb Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:37 +0800 Subject: [PATCH 0957/1519] Staging: cx25821: Fix too long lines in cx25821-audio.h Fix too long lines in cx25821-audio.h Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-audio.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audio.h b/drivers/staging/cx25821/cx25821-audio.h index 27717253227..8eb55b7b88c 100644 --- a/drivers/staging/cx25821/cx25821-audio.h +++ b/drivers/staging/cx25821/cx25821-audio.h @@ -36,13 +36,15 @@ */ #ifndef USE_RISC_NOOP #define MAX_BUFFER_PROGRAM_SIZE \ - (2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE*4) + (2 * LINES_PER_BUFFER * RISC_WRITE_INSTRUCTION_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE * 4) #endif /* MAE 12 July 2005 Try to use NOOP RISC instruction instead */ #ifdef USE_RISC_NOOP #define MAX_BUFFER_PROGRAM_SIZE \ - (2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_NOOP_INSTRUCTION_SIZE*4) + (2 * LINES_PER_BUFFER * RISC_WRITE_INSTRUCTION_SIZE + \ + RISC_NOOP_INSTRUCTION_SIZE * 4) #endif /* Sizes of various instructions in bytes. Used when adding instructions. */ From 1531e889ab5eaaa87f1a5440c7cbf4af3c1a9bb9 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:38 +0800 Subject: [PATCH 0958/1519] Staging: cx25821: Fix obscure line endings in cx25821-audio-upstream.c Change obscure line endings to less obscure ones. Rationale: more readable. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/cx25821/cx25821-audio-upstream.c | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c index 55df658b52c..e6c4b345cb6 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.c +++ b/drivers/staging/cx25821/cx25821-audio-upstream.c @@ -349,10 +349,8 @@ static void cx25821_audioups_handler(struct work_struct *work) return; } - cx25821_get_audio_data(dev, - dev->channels[dev-> - _audio_upstream_channel]. - sram_channels); + cx25821_get_audio_data(dev, dev->channels[dev->_audio_upstream_channel]. + sram_channels); } int cx25821_openfile_audio(struct cx25821_dev *dev, @@ -555,8 +553,7 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, } } /* Jump to 2nd Audio Frame */ - *(rp++) = - cpu_to_le32(RISC_JUMP | RISC_IRQ1 | + *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET); *(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(0); @@ -611,11 +608,8 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id) /* Only deal with our interrupt */ if (audio_status) { - handled = - cx25821_audio_upstream_irq(dev, - dev-> - _audio_upstream_channel, - audio_status); + handled = cx25821_audio_upstream_irq(dev, + dev->_audio_upstream_channel, audio_status); } if (handled < 0) @@ -770,9 +764,8 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); } - retval = - cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, _line_size, - 0); + retval = cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, + _line_size, 0); dev->audio_upstream_riscbuf_size = AUDIO_RISC_DMA_BUF_SIZE * NUM_AUDIO_PROGS + @@ -780,8 +773,8 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS; /* Allocating buffers and prepare RISC program */ - retval = - cx25821_audio_upstream_buffer_prepare(dev, sram_ch, _line_size); + retval = cx25821_audio_upstream_buffer_prepare(dev, sram_ch, + _line_size); if (retval < 0) { pr_err("%s: Failed to set up Audio upstream buffers!\n", dev->name); From 54082f1db22589481dd3dae7e66a16d07dbd8c10 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:39 +0800 Subject: [PATCH 0959/1519] Staging: cx25821: Fix long lines in cx25821-audio-upstream.c Fix long lines in cx25821-audio-upstream.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-audio-upstream.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c index e6c4b345cb6..50e56a64112 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.c +++ b/drivers/staging/cx25821/cx25821-audio-upstream.c @@ -538,13 +538,9 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, AUDIO_RISC_DMA_BUF_SIZE; rp = cx25821_risc_field_upstream_audio(dev, - dev-> - _risc_virt_start_addr - + 1, - dev-> - _audiodata_buf_phys_addr, - AUDIO_LINE_SIZE, - FIFO_DISABLE); + dev->_risc_virt_start_addr + 1, + dev->_audiodata_buf_phys_addr, + AUDIO_LINE_SIZE, FIFO_DISABLE); if (USE_RISC_NOOP_AUDIO) { for (i = 0; i < NUM_NO_OPS; i++) { From 49acf735c1bb78b3387c8fa80da8f386ea1e62fb Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:40 +0800 Subject: [PATCH 0960/1519] Staging: cx25821: Fix long lines in cx25821-audio-upstream.h Fix long lines in cx25821-audio-upstream.h Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-audio-upstream.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.h b/drivers/staging/cx25821/cx25821-audio-upstream.h index 668a4f11e80..af2ae7c5815 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.h +++ b/drivers/staging/cx25821/cx25821-audio-upstream.h @@ -46,11 +46,16 @@ #define USE_RISC_NOOP_AUDIO 1 #ifdef USE_RISC_NOOP_AUDIO -#define AUDIO_RISC_DMA_BUF_SIZE (LINES_PER_AUDIO_BUFFER*RISC_READ_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE + RISC_JUMP_INSTRUCTION_SIZE) +#define AUDIO_RISC_DMA_BUF_SIZE \ + (LINES_PER_AUDIO_BUFFER * RISC_READ_INSTRUCTION_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS * DWORD_SIZE + \ + RISC_JUMP_INSTRUCTION_SIZE) #endif #ifndef USE_RISC_NOOP_AUDIO -#define AUDIO_RISC_DMA_BUF_SIZE (LINES_PER_AUDIO_BUFFER*RISC_READ_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + RISC_JUMP_INSTRUCTION_SIZE) +#define AUDIO_RISC_DMA_BUF_SIZE \ + (LINES_PER_AUDIO_BUFFER * RISC_READ_INSTRUCTION_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + RISC_JUMP_INSTRUCTION_SIZE) #endif static int _line_size; From 9737153bf048a01781b69a7266df1db17e437b42 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:41 +0800 Subject: [PATCH 0961/1519] Staging: cx25821: Replace :? by if-else in cx25821-video-upstream-ch2.c Replace :? operator by if-else equivalent where it improves readability. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../cx25821/cx25821-video-upstream-ch2.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index 655357da3d6..a6424165bb6 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c @@ -145,15 +145,16 @@ int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev, if (dev->_isNTSC_ch2) { odd_num_lines = singlefield_lines + 1; risc_program_size = FRAME1_VID_PROG_SIZE; - frame_size = - (bpl == - Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : - FRAME_SIZE_NTSC_Y422; + if (bpl == Y411_LINE_SZ) + frame_size = FRAME_SIZE_NTSC_Y411; + else + frame_size = FRAME_SIZE_NTSC_Y422; } else { risc_program_size = PAL_VID_PROG_SIZE; - frame_size = - (bpl == - Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; + if (bpl == Y411_LINE_SZ) + frame_size = FRAME_SIZE_PAL_Y411; + else + frame_size = FRAME_SIZE_PAL_Y422; } /* Virtual address of Risc buffer program */ @@ -565,10 +566,10 @@ int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, } if (dev->_dma_virt_start_addr_ch2 != NULL) { - line_size_in_bytes = - (dev->_pixel_format_ch2 == - PIXEL_FRMT_411) ? Y411_LINE_SZ : - Y422_LINE_SZ; + if (dev->_pixel_format_ch2 == PIXEL_FRMT_411) + line_size_in_bytes = Y411_LINE_SZ; + else + line_size_in_bytes = Y422_LINE_SZ; risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + odd_risc_prog_size; From cc9518fe1466a8f0a9c761618b236db905d350be Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:42 +0800 Subject: [PATCH 0962/1519] Staging: cx25821: Fix labels' placement in cx25821-video-upstream-ch2.c Delete whitespace characters before labels. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video-upstream-ch2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index a6424165bb6..b02dbe004b1 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c @@ -521,7 +521,7 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, return 0; - error: +error: return ret; } @@ -720,7 +720,7 @@ int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, return 0; - fail_irq: +fail_irq: cx25821_dev_unregister(dev); return err; } @@ -830,7 +830,7 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, return 0; - error: +error: cx25821_dev_unregister(dev); return err; From 6d71b8f223451e020f4fa8c1f16bc902375c2613 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:43 +0800 Subject: [PATCH 0963/1519] Staging: cx25821: Fix wrong line endings in cx25821-video-upstream-ch2.c Change obscure line endings to less obscure ones. Rationale: improve readability. Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../cx25821/cx25821-video-upstream-ch2.c | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index b02dbe004b1..b281ced5343 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c @@ -179,17 +179,14 @@ int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev, /* Even field */ rp = cx25821_risc_field_upstream_ch2(dev, rp, - dev-> - _data_buf_phys_addr_ch2 + - databuf_offset, - bottom_offset, 0x200, bpl, - singlefield_lines, - fifo_enable, EVEN_FIELD); + dev->_data_buf_phys_addr_ch2 + databuf_offset, + bottom_offset, 0x200, bpl, singlefield_lines, + fifo_enable, EVEN_FIELD); if (frame == 0) { risc_flag = RISC_CNT_RESET; - risc_phys_jump_addr = - dev->_dma_phys_start_addr_ch2 + risc_program_size; + risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + + risc_program_size; } else { risc_flag = RISC_CNT_INC; risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2; @@ -511,9 +508,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, return ret; /* Creating RISC programs */ - ret = - cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, - dev->_lines_count_ch2); + ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, + dev->_lines_count_ch2); if (ret < 0) { pr_info("Failed creating Video Upstream Risc programs!\n"); goto error; @@ -806,8 +802,7 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, } } - retval = - cx25821_sram_channel_setup_upstream(dev, sram_ch, + retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size_ch2, 0); /* setup fifo + format */ @@ -817,8 +812,7 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, dev->upstream_databuf_size_ch2 = data_frame_size * 2; /* Allocating buffers and prepare RISC program */ - retval = - cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, + retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2); if (retval < 0) { pr_err("%s: Failed to set up Video upstream buffers!\n", From 0b225970d2a27501082072df7e2899f7edb70b4b Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:44 +0800 Subject: [PATCH 0964/1519] Staging: cx25821: Fix long lines in cx25821-video-upstream-ch2.c Fix long lines in cx25821-video-upstream-ch2.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../cx25821/cx25821-video-upstream-ch2.c | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index b281ced5343..08ac7c1a7bb 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c @@ -40,8 +40,8 @@ MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); MODULE_AUTHOR("Hiep Huynh "); MODULE_LICENSE("GPL"); -static int _intr_msk = - FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR; +static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | + FLD_VID_SRC_OPC_ERR; static __le32 *cx25821_update_riscprogram_ch2(struct cx25821_dev *dev, __le32 *rp, unsigned int offset, @@ -166,13 +166,9 @@ int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev, if (UNSET != top_offset) { fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; rp = cx25821_risc_field_upstream_ch2(dev, rp, - dev-> - _data_buf_phys_addr_ch2 - + databuf_offset, - top_offset, 0, bpl, - odd_num_lines, - fifo_enable, - ODD_FIELD); + dev->_data_buf_phys_addr_ch2 + databuf_offset, + top_offset, 0, bpl, odd_num_lines, fifo_enable, + ODD_FIELD); } fifo_enable = FIFO_DISABLE; @@ -571,14 +567,10 @@ int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, odd_risc_prog_size; rp = cx25821_update_riscprogram_ch2(dev, - dev-> - _dma_virt_start_addr_ch2, - TOP_OFFSET, - line_size_in_bytes, - 0x0, - singlefield_lines, - FIFO_DISABLE, - ODD_FIELD); + dev->_dma_virt_start_addr_ch2, + TOP_OFFSET, line_size_in_bytes, + 0x0, singlefield_lines, + FIFO_DISABLE, ODD_FIELD); /* Jump to Even Risc program of 1st Frame */ *(rp++) = cpu_to_le32(RISC_JUMP); From 269efc688eb5ed153958c7fc0fff2558f07f7f3f Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:45 +0800 Subject: [PATCH 0965/1519] Staging: cx25821: Fix long lines in cx25821-video-upstream-ch2.h Fix long lines in cx25821-video-upstream-ch2.h Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../cx25821/cx25821-video-upstream-ch2.h | 83 ++++++++++++++----- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.h b/drivers/staging/cx25821/cx25821-video-upstream-ch2.h index 029e8305724..d42dab59b66 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.h +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.h @@ -65,37 +65,74 @@ #define USE_RISC_NOOP_VIDEO 1 #ifdef USE_RISC_NOOP_VIDEO -#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ - RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define PAL_US_VID_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) -#define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) +#define PAL_VID_PROG_SIZE \ + ((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE + 2 * NUM_NO_OPS * DWORD_SIZE) -#define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define ODD_FLD_PAL_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) -#define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ - JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define NTSC_US_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) -#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) +#define NTSC_RISC_BUF_SIZE \ + (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) -#define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) -#define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define FRAME1_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \ + 3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \ + 2 * NUM_NO_OPS * DWORD_SIZE) + +#define ODD_FLD_NTSC_PROG_SIZE \ + (NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) #endif #ifndef USE_RISC_NOOP_VIDEO -#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) -#define PAL_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE)) -#define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) -#define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) -#define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) -#define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) -#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) -#define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) +#define PAL_US_VID_PROG_SIZE \ + ((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE) + +#define PAL_RISC_BUF_SIZE \ + (2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE)) + +#define PAL_VID_PROG_SIZE \ + ((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE) + +#define ODD_FLD_PAL_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) + +#define ODD_FLD_NTSC_PROG_SIZE \ + (NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) + +#define NTSC_US_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) + +#define NTSC_RISC_BUF_SIZE \ + (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) + +#define FRAME1_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \ + 3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) + #endif From 2b2d039507619949c26f28651db0ed15b7b16703 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:46 +0800 Subject: [PATCH 0966/1519] Staging: cx25821: Fix long lines in cx25821-video-upstream.c Fix long lines in cx25821-video-upstream.c Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video-upstream.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c index eb0172bf39d..14a6a6c0340 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream.c +++ b/drivers/staging/cx25821/cx25821-video-upstream.c @@ -40,8 +40,8 @@ MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); MODULE_AUTHOR("Hiep Huynh "); MODULE_LICENSE("GPL"); -static int _intr_msk = - FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR; +static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | + FLD_VID_SRC_OPC_ERR; int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, struct sram_channel *ch, @@ -615,14 +615,10 @@ int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num, odd_risc_prog_size; rp = cx25821_update_riscprogram(dev, - dev-> - _dma_virt_start_addr, - TOP_OFFSET, - line_size_in_bytes, - 0x0, - singlefield_lines, - FIFO_DISABLE, - ODD_FIELD); + dev->_dma_virt_start_addr, TOP_OFFSET, + line_size_in_bytes, 0x0, + singlefield_lines, FIFO_DISABLE, + ODD_FIELD); /* Jump to Even Risc program of 1st Frame */ *(rp++) = cpu_to_le32(RISC_JUMP); From 41344f6f36978e968afdbe3121262a47bc5084ad Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 2 Sep 2011 11:55:47 +0800 Subject: [PATCH 0967/1519] Staging: cx25821: Fix long lines in cx25821-video-upstream.h Fix long lines in cx25821-video-upstream.h Signed-off-by: Leonid V. Fedorenchik Reviewed-By: Valdis Kletnieks Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/cx25821/cx25821-video-upstream.h | 78 +++++++++++++------ 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video-upstream.h b/drivers/staging/cx25821/cx25821-video-upstream.h index f0b3ac0880a..268ec8aa6a6 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream.h +++ b/drivers/staging/cx25821/cx25821-video-upstream.h @@ -66,44 +66,74 @@ #define USE_RISC_NOOP_VIDEO 1 #ifdef USE_RISC_NOOP_VIDEO -#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ - RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define PAL_US_VID_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) -#define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) +#define PAL_VID_PROG_SIZE \ + ((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE + 2 * NUM_NO_OPS * DWORD_SIZE) -#define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define ODD_FLD_PAL_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) -#define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define ODD_FLD_NTSC_PROG_SIZE \ + (NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) -#define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ - JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) +#define NTSC_US_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \ + NUM_NO_OPS * DWORD_SIZE) -#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) +#define NTSC_RISC_BUF_SIZE \ + (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) -#define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) +#define FRAME1_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE + 2 * NUM_NO_OPS * DWORD_SIZE) #endif #ifndef USE_RISC_NOOP_VIDEO -#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ - RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) +#define PAL_US_VID_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE) -#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) +#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) -#define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) +#define PAL_VID_PROG_SIZE \ + ((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE) -#define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) -#define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) +#define ODD_FLD_PAL_PROG_SIZE \ + (PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) + +#define ODD_FLD_NTSC_PROG_SIZE \ + (NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \ + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE) + +#define NTSC_US_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \ + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) + +#define NTSC_RISC_BUF_SIZE \ + (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) + +#define FRAME1_VID_PROG_SIZE \ + ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + \ + 2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ + JUMP_INSTRUCTION_SIZE) -#define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) -#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) -#define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ - RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) #endif From 831e5bad5f74d6147d2d70587a230687181e4e00 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Thu, 8 Sep 2011 18:46:08 +0200 Subject: [PATCH 0968/1519] drivers/staging/crystalhd/: Fix a coding style issues crystalhd_fw_if.h: indentation fix (spaces to tabs) The rest are brackets. NOTE: there are quite some 80 character warnings, but they look in place, comments mostly on the right next to the constants and stuff like that. I haven't touched them, since this rule is 'going away', but in case you would like it to be fixed, let me know. I'm sending 2 patches, but it they aren't connected in any way, so doesn't matter the apply order. It's just a cleanup. P.S sorry for the first lame patches a couple of days ago Signed-off-by: Arvydas Sidorenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/bc_dts_defs.h | 4 +- drivers/staging/crystalhd/bc_dts_glob_lnx.h | 6 +- drivers/staging/crystalhd/crystalhd_cmds.h | 2 +- drivers/staging/crystalhd/crystalhd_fw_if.h | 482 ++++++++++---------- drivers/staging/crystalhd/crystalhd_misc.h | 6 +- 5 files changed, 250 insertions(+), 250 deletions(-) diff --git a/drivers/staging/crystalhd/bc_dts_defs.h b/drivers/staging/crystalhd/bc_dts_defs.h index 778e76af052..fde5b0627f6 100644 --- a/drivers/staging/crystalhd/bc_dts_defs.h +++ b/drivers/staging/crystalhd/bc_dts_defs.h @@ -84,7 +84,7 @@ enum BC_SW_OPTIONS { BC_OPT_LINK_OUT_ENCRYPT = BC_BIT(29), }; -struct BC_REG_CONFIG{ +struct BC_REG_CONFIG { uint32_t DbgOptions; }; @@ -391,7 +391,7 @@ struct BC_PIC_INFO_BLOCK { * ProcOut Info * *------------------------------------------------------*/ /* Optional flags for ProcOut Interface.*/ -enum POUT_OPTIONAL_IN_FLAGS_{ +enum POUT_OPTIONAL_IN_FLAGS_ { /* Flags from App to Device */ BC_POUT_FLAGS_YV12 = 0x01, /* Copy Data in YV12 format */ BC_POUT_FLAGS_STRIDE = 0x02, /* Stride size is valid. */ diff --git a/drivers/staging/crystalhd/bc_dts_glob_lnx.h b/drivers/staging/crystalhd/bc_dts_glob_lnx.h index 80b7a73a9d4..bbe5119761f 100644 --- a/drivers/staging/crystalhd/bc_dts_glob_lnx.h +++ b/drivers/staging/crystalhd/bc_dts_glob_lnx.h @@ -175,7 +175,7 @@ struct BC_DEC_YUV_BUFFS { uint32_t RefCnt; }; -enum DECOUT_COMPLETION_FLAGS{ +enum DECOUT_COMPLETION_FLAGS { COMP_FLAG_NO_INFO = 0x00, COMP_FLAG_FMT_CHANGE = 0x01, COMP_FLAG_PIB_VALID = 0x02, @@ -184,7 +184,7 @@ enum DECOUT_COMPLETION_FLAGS{ COMP_FLAG_DATA_BOT = 0x10, }; -struct BC_DEC_OUT_BUFF{ +struct BC_DEC_OUT_BUFF { struct BC_DEC_YUV_BUFFS OutPutBuffs; struct BC_PIC_INFO_BLOCK PibInfo; uint32_t Flags; @@ -289,7 +289,7 @@ struct crystalhd_ioctl_data { struct crystalhd_ioctl_data *next; /* List/Fifo management */ }; -enum crystalhd_kmod_ver{ +enum crystalhd_kmod_ver { crystalhd_kmod_major = 0, crystalhd_kmod_minor = 9, crystalhd_kmod_rev = 27, diff --git a/drivers/staging/crystalhd/crystalhd_cmds.h b/drivers/staging/crystalhd/crystalhd_cmds.h index 10130296601..f0a2796045c 100644 --- a/drivers/staging/crystalhd/crystalhd_cmds.h +++ b/drivers/staging/crystalhd/crystalhd_cmds.h @@ -36,7 +36,7 @@ #include "crystalhd_misc.h" #include "crystalhd_hw.h" -enum crystalhd_state{ +enum crystalhd_state { BC_LINK_INVALID = 0x00, BC_LINK_INIT = 0x01, BC_LINK_CAP_EN = 0x02, diff --git a/drivers/staging/crystalhd/crystalhd_fw_if.h b/drivers/staging/crystalhd/crystalhd_fw_if.h index 77560d4b680..9e2831e68bb 100644 --- a/drivers/staging/crystalhd/crystalhd_fw_if.h +++ b/drivers/staging/crystalhd/crystalhd_fw_if.h @@ -31,33 +31,33 @@ /* User Data Header */ struct user_data { - struct user_data *next; - uint32_t type; - uint32_t size; + struct user_data *next; + uint32_t type; + uint32_t size; }; /*------------------------------------------------------* * MPEG Extension to the PPB * *------------------------------------------------------*/ struct ppb_mpeg { - uint32_t to_be_defined; - uint32_t valid; + uint32_t to_be_defined; + uint32_t valid; - /* Always valid, defaults to picture size if no - sequence display extension in the stream. */ - uint32_t display_horizontal_size; - uint32_t display_vertical_size; + /* Always valid, defaults to picture size if no + sequence display extension in the stream. */ + uint32_t display_horizontal_size; + uint32_t display_vertical_size; - /* MPEG_VALID_PANSCAN - Offsets are a copy values from the MPEG stream. */ - uint32_t offset_count; - int32_t horizontal_offset[3]; - int32_t vertical_offset[3]; + /* MPEG_VALID_PANSCAN + Offsets are a copy values from the MPEG stream. */ + uint32_t offset_count; + int32_t horizontal_offset[3]; + int32_t vertical_offset[3]; - /* MPEG_VALID_USERDATA - User data is in the form of a linked list. */ - int32_t userDataSize; - struct user_data *userData; + /* MPEG_VALID_USERDATA + User data is in the form of a linked list. */ + int32_t userDataSize; + struct user_data *userData; }; @@ -66,25 +66,25 @@ struct ppb_mpeg { * VC1 Extension to the PPB * *------------------------------------------------------*/ struct ppb_vc1 { - uint32_t to_be_defined; - uint32_t valid; + uint32_t to_be_defined; + uint32_t valid; - /* Always valid, defaults to picture size if no - sequence display extension in the stream. */ - uint32_t display_horizontal_size; - uint32_t display_vertical_size; + /* Always valid, defaults to picture size if no + sequence display extension in the stream. */ + uint32_t display_horizontal_size; + uint32_t display_vertical_size; - /* VC1 pan scan windows */ - uint32_t num_panscan_windows; - int32_t ps_horiz_offset[4]; - int32_t ps_vert_offset[4]; - int32_t ps_width[4]; - int32_t ps_height[4]; + /* VC1 pan scan windows */ + uint32_t num_panscan_windows; + int32_t ps_horiz_offset[4]; + int32_t ps_vert_offset[4]; + int32_t ps_width[4]; + int32_t ps_height[4]; - /* VC1_VALID_USERDATA - User data is in the form of a linked list. */ - int32_t userDataSize; - struct user_data *userData; + /* VC1_VALID_USERDATA + User data is in the form of a linked list. */ + int32_t userDataSize; + struct user_data *userData; }; @@ -105,145 +105,145 @@ struct ppb_vc1 { #define MAX_FGT_VALUE_INTERVAL (256) struct fgt_sei { - struct fgt_sei *next; - unsigned char model_values[3][MAX_FGT_VALUE_INTERVAL][MAX_FGT_MODEL_VALUE]; - unsigned char upper_bound[3][MAX_FGT_VALUE_INTERVAL]; - unsigned char lower_bound[3][MAX_FGT_VALUE_INTERVAL]; + struct fgt_sei *next; + unsigned char model_values[3][MAX_FGT_VALUE_INTERVAL][MAX_FGT_MODEL_VALUE]; + unsigned char upper_bound[3][MAX_FGT_VALUE_INTERVAL]; + unsigned char lower_bound[3][MAX_FGT_VALUE_INTERVAL]; - unsigned char cancel_flag; /* Cancel flag: 1 no film grain. */ - unsigned char model_id; /* Model id. */ + unsigned char cancel_flag; /* Cancel flag: 1 no film grain. */ + unsigned char model_id; /* Model id. */ - /* +unused SE based on Thomson spec */ - unsigned char color_desc_flag; /* Separate color descrition flag. */ - unsigned char bit_depth_luma; /* Bit depth luma minus 8. */ - unsigned char bit_depth_chroma; /* Bit depth chroma minus 8. */ - unsigned char full_range_flag; /* Full range flag. */ - unsigned char color_primaries; /* Color primaries. */ - unsigned char transfer_charact; /* Transfer characteristics. */ - unsigned char matrix_coeff; /*< Matrix coefficients. */ - /* -unused SE based on Thomson spec */ + /* +unused SE based on Thomson spec */ + unsigned char color_desc_flag; /* Separate color descrition flag. */ + unsigned char bit_depth_luma; /* Bit depth luma minus 8. */ + unsigned char bit_depth_chroma; /* Bit depth chroma minus 8. */ + unsigned char full_range_flag; /* Full range flag. */ + unsigned char color_primaries; /* Color primaries. */ + unsigned char transfer_charact; /* Transfer characteristics. */ + unsigned char matrix_coeff; /*< Matrix coefficients. */ + /* -unused SE based on Thomson spec */ - unsigned char blending_mode_id; /* Blending mode. */ - unsigned char log2_scale_factor; /* Log2 scale factor (2-7). */ - unsigned char comp_flag[3]; /* Components [0,2] parameters present flag. */ - unsigned char num_intervals_minus1[3]; /* Number of intensity level intervals. */ - unsigned char num_model_values[3]; /* Number of model values. */ - uint16_t repetition_period; /* Repetition period (0-16384) */ + unsigned char blending_mode_id; /* Blending mode. */ + unsigned char log2_scale_factor; /* Log2 scale factor (2-7). */ + unsigned char comp_flag[3]; /* Components [0,2] parameters present flag. */ + unsigned char num_intervals_minus1[3]; /* Number of intensity level intervals. */ + unsigned char num_model_values[3]; /* Number of model values. */ + uint16_t repetition_period; /* Repetition period (0-16384) */ }; struct ppb_h264 { - /* 'valid' specifies which fields (or sets of - * fields) below are valid. If the corresponding - * bit in 'valid' is NOT set then that field(s) - * is (are) not initialized. */ - uint32_t valid; + /* 'valid' specifies which fields (or sets of + * fields) below are valid. If the corresponding + * bit in 'valid' is NOT set then that field(s) + * is (are) not initialized. */ + uint32_t valid; - int32_t poc_top; /* POC for Top Field/Frame */ - int32_t poc_bottom; /* POC for Bottom Field */ - uint32_t idr_pic_id; + int32_t poc_top; /* POC for Top Field/Frame */ + int32_t poc_bottom; /* POC for Bottom Field */ + uint32_t idr_pic_id; - /* H264_VALID_PANSCAN */ - uint32_t pan_scan_count; - int32_t pan_scan_left[3]; - int32_t pan_scan_right[3]; - int32_t pan_scan_top[3]; - int32_t pan_scan_bottom[3]; + /* H264_VALID_PANSCAN */ + uint32_t pan_scan_count; + int32_t pan_scan_left[3]; + int32_t pan_scan_right[3]; + int32_t pan_scan_top[3]; + int32_t pan_scan_bottom[3]; - /* H264_VALID_CT_TYPE */ - uint32_t ct_type_count; - uint32_t ct_type[3]; + /* H264_VALID_CT_TYPE */ + uint32_t ct_type_count; + uint32_t ct_type[3]; - /* H264_VALID_SPS_CROP */ - int32_t sps_crop_left; - int32_t sps_crop_right; - int32_t sps_crop_top; - int32_t sps_crop_bottom; + /* H264_VALID_SPS_CROP */ + int32_t sps_crop_left; + int32_t sps_crop_right; + int32_t sps_crop_top; + int32_t sps_crop_bottom; - /* H264_VALID_VUI */ - uint32_t chroma_top; - uint32_t chroma_bottom; + /* H264_VALID_VUI */ + uint32_t chroma_top; + uint32_t chroma_bottom; - /* H264_VALID_USER */ - uint32_t user_data_size; - struct user_data *user_data; + /* H264_VALID_USER */ + uint32_t user_data_size; + struct user_data *user_data; - /* H264 VALID FGT */ - struct fgt_sei *pfgt; + /* H264 VALID FGT */ + struct fgt_sei *pfgt; }; struct ppb { - /* Common fields. */ - uint32_t picture_number; /* Ordinal display number */ - uint32_t video_buffer; /* Video (picbuf) number */ - uint32_t video_address; /* Address of picbuf Y */ - uint32_t video_address_uv; /* Address of picbuf UV */ - uint32_t video_stripe; /* Picbuf stripe */ - uint32_t video_width; /* Picbuf width */ - uint32_t video_height; /* Picbuf height */ + /* Common fields. */ + uint32_t picture_number; /* Ordinal display number */ + uint32_t video_buffer; /* Video (picbuf) number */ + uint32_t video_address; /* Address of picbuf Y */ + uint32_t video_address_uv; /* Address of picbuf UV */ + uint32_t video_stripe; /* Picbuf stripe */ + uint32_t video_width; /* Picbuf width */ + uint32_t video_height; /* Picbuf height */ - uint32_t channel_id; /* Decoder channel ID */ - uint32_t status; /* reserved */ - uint32_t width; /* pixels */ - uint32_t height; /* pixels */ - uint32_t chroma_format; /* see above */ - uint32_t pulldown; /* see above */ - uint32_t flags; /* see above */ - uint32_t pts; /* 32 LSBs of PTS */ - uint32_t protocol; /* protocolXXX (above) */ + uint32_t channel_id; /* Decoder channel ID */ + uint32_t status; /* reserved */ + uint32_t width; /* pixels */ + uint32_t height; /* pixels */ + uint32_t chroma_format; /* see above */ + uint32_t pulldown; /* see above */ + uint32_t flags; /* see above */ + uint32_t pts; /* 32 LSBs of PTS */ + uint32_t protocol; /* protocolXXX (above) */ - uint32_t frame_rate; /* see above */ - uint32_t matrix_coeff; /* see above */ - uint32_t aspect_ratio; /* see above */ - uint32_t colour_primaries; /* see above */ - uint32_t transfer_char; /* see above */ - uint32_t pcr_offset; /* 45kHz if PCR type; else 27MHz */ - uint32_t n_drop; /* Number of pictures to be dropped */ + uint32_t frame_rate; /* see above */ + uint32_t matrix_coeff; /* see above */ + uint32_t aspect_ratio; /* see above */ + uint32_t colour_primaries; /* see above */ + uint32_t transfer_char; /* see above */ + uint32_t pcr_offset; /* 45kHz if PCR type; else 27MHz */ + uint32_t n_drop; /* Number of pictures to be dropped */ - uint32_t custom_aspect_ratio_width_height; - /* upper 16-bits is Y and lower 16-bits is X */ + uint32_t custom_aspect_ratio_width_height; + /* upper 16-bits is Y and lower 16-bits is X */ - uint32_t picture_tag; /* Indexing tag from BUD packets */ - uint32_t picture_done_payload; - uint32_t picture_meta_payload; - uint32_t reserved[1]; + uint32_t picture_tag; /* Indexing tag from BUD packets */ + uint32_t picture_done_payload; + uint32_t picture_meta_payload; + uint32_t reserved[1]; - /* Protocol-specific extensions. */ - union { - struct ppb_h264 h264; - struct ppb_mpeg mpeg; - struct ppb_vc1 vc1; - } other; + /* Protocol-specific extensions. */ + union { + struct ppb_h264 h264; + struct ppb_mpeg mpeg; + struct ppb_vc1 vc1; + } other; }; struct c011_pib { - uint32_t bFormatChange; - uint32_t resolution; - uint32_t channelId; - uint32_t ppbPtr; - int32_t ptsStcOffset; - uint32_t zeroPanscanValid; - uint32_t dramOutBufAddr; - uint32_t yComponent; - struct ppb ppb; + uint32_t bFormatChange; + uint32_t resolution; + uint32_t channelId; + uint32_t ppbPtr; + int32_t ptsStcOffset; + uint32_t zeroPanscanValid; + uint32_t dramOutBufAddr; + uint32_t yComponent; + struct ppb ppb; }; struct dec_rsp_channel_start_video { - uint32_t command; - uint32_t sequence; - uint32_t status; - uint32_t picBuf; - uint32_t picRelBuf; - uint32_t picInfoDeliveryQ; - uint32_t picInfoReleaseQ; - uint32_t channelStatus; - uint32_t userDataDeliveryQ; - uint32_t userDataReleaseQ; - uint32_t transportStreamCaptureAddr; - uint32_t asyncEventQ; + uint32_t command; + uint32_t sequence; + uint32_t status; + uint32_t picBuf; + uint32_t picRelBuf; + uint32_t picInfoDeliveryQ; + uint32_t picInfoReleaseQ; + uint32_t channelStatus; + uint32_t userDataDeliveryQ; + uint32_t userDataReleaseQ; + uint32_t transportStreamCaptureAddr; + uint32_t asyncEventQ; }; @@ -251,112 +251,112 @@ struct dec_rsp_channel_start_video { /* host commands */ enum c011_ts_cmd { - eCMD_TS_GET_NEXT_PIC = 0x7376F100, /* debug get next picture */ - eCMD_TS_GET_LAST_PIC = 0x7376F102, /* debug get last pic status */ - eCMD_TS_READ_WRITE_MEM = 0x7376F104, /* debug read write memory */ + eCMD_TS_GET_NEXT_PIC = 0x7376F100, /* debug get next picture */ + eCMD_TS_GET_LAST_PIC = 0x7376F102, /* debug get last pic status */ + eCMD_TS_READ_WRITE_MEM = 0x7376F104, /* debug read write memory */ - /* New API commands */ - /* General commands */ - eCMD_C011_INIT = eCMD_C011_CMD_BASE + 0x01, - eCMD_C011_RESET = eCMD_C011_CMD_BASE + 0x02, - eCMD_C011_SELF_TEST = eCMD_C011_CMD_BASE + 0x03, - eCMD_C011_GET_VERSION = eCMD_C011_CMD_BASE + 0x04, - eCMD_C011_GPIO = eCMD_C011_CMD_BASE + 0x05, - eCMD_C011_DEBUG_SETUP = eCMD_C011_CMD_BASE + 0x06, + /* New API commands */ + /* General commands */ + eCMD_C011_INIT = eCMD_C011_CMD_BASE + 0x01, + eCMD_C011_RESET = eCMD_C011_CMD_BASE + 0x02, + eCMD_C011_SELF_TEST = eCMD_C011_CMD_BASE + 0x03, + eCMD_C011_GET_VERSION = eCMD_C011_CMD_BASE + 0x04, + eCMD_C011_GPIO = eCMD_C011_CMD_BASE + 0x05, + eCMD_C011_DEBUG_SETUP = eCMD_C011_CMD_BASE + 0x06, - /* Decoding commands */ - eCMD_C011_DEC_CHAN_OPEN = eCMD_C011_CMD_BASE + 0x100, - eCMD_C011_DEC_CHAN_CLOSE = eCMD_C011_CMD_BASE + 0x101, - eCMD_C011_DEC_CHAN_ACTIVATE = eCMD_C011_CMD_BASE + 0x102, - eCMD_C011_DEC_CHAN_STATUS = eCMD_C011_CMD_BASE + 0x103, - eCMD_C011_DEC_CHAN_FLUSH = eCMD_C011_CMD_BASE + 0x104, - eCMD_C011_DEC_CHAN_TRICK_PLAY = eCMD_C011_CMD_BASE + 0x105, - eCMD_C011_DEC_CHAN_TS_PIDS = eCMD_C011_CMD_BASE + 0x106, - eCMD_C011_DEC_CHAN_PS_STREAM_ID = eCMD_C011_CMD_BASE + 0x107, - eCMD_C011_DEC_CHAN_INPUT_PARAMS = eCMD_C011_CMD_BASE + 0x108, - eCMD_C011_DEC_CHAN_VIDEO_OUTPUT = eCMD_C011_CMD_BASE + 0x109, - eCMD_C011_DEC_CHAN_OUTPUT_FORMAT = eCMD_C011_CMD_BASE + 0x10A, - eCMD_C011_DEC_CHAN_SCALING_FILTERS = eCMD_C011_CMD_BASE + 0x10B, - eCMD_C011_DEC_CHAN_OSD_MODE = eCMD_C011_CMD_BASE + 0x10D, - eCMD_C011_DEC_CHAN_DROP = eCMD_C011_CMD_BASE + 0x10E, - eCMD_C011_DEC_CHAN_RELEASE = eCMD_C011_CMD_BASE + 0x10F, - eCMD_C011_DEC_CHAN_STREAM_SETTINGS = eCMD_C011_CMD_BASE + 0x110, - eCMD_C011_DEC_CHAN_PAUSE_OUTPUT = eCMD_C011_CMD_BASE + 0x111, - eCMD_C011_DEC_CHAN_CHANGE = eCMD_C011_CMD_BASE + 0x112, - eCMD_C011_DEC_CHAN_SET_STC = eCMD_C011_CMD_BASE + 0x113, - eCMD_C011_DEC_CHAN_SET_PTS = eCMD_C011_CMD_BASE + 0x114, - eCMD_C011_DEC_CHAN_CC_MODE = eCMD_C011_CMD_BASE + 0x115, - eCMD_C011_DEC_CREATE_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x116, - eCMD_C011_DEC_COPY_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x117, - eCMD_C011_DEC_DELETE_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x118, - eCMD_C011_DEC_CHAN_SET_DECYPTION = eCMD_C011_CMD_BASE + 0x119, - eCMD_C011_DEC_CHAN_START_VIDEO = eCMD_C011_CMD_BASE + 0x11A, - eCMD_C011_DEC_CHAN_STOP_VIDEO = eCMD_C011_CMD_BASE + 0x11B, - eCMD_C011_DEC_CHAN_PIC_CAPTURE = eCMD_C011_CMD_BASE + 0x11C, - eCMD_C011_DEC_CHAN_PAUSE = eCMD_C011_CMD_BASE + 0x11D, - eCMD_C011_DEC_CHAN_PAUSE_STATE = eCMD_C011_CMD_BASE + 0x11E, - eCMD_C011_DEC_CHAN_SET_SLOWM_RATE = eCMD_C011_CMD_BASE + 0x11F, - eCMD_C011_DEC_CHAN_GET_SLOWM_RATE = eCMD_C011_CMD_BASE + 0x120, - eCMD_C011_DEC_CHAN_SET_FF_RATE = eCMD_C011_CMD_BASE + 0x121, - eCMD_C011_DEC_CHAN_GET_FF_RATE = eCMD_C011_CMD_BASE + 0x122, - eCMD_C011_DEC_CHAN_FRAME_ADVANCE = eCMD_C011_CMD_BASE + 0x123, - eCMD_C011_DEC_CHAN_SET_SKIP_PIC_MODE = eCMD_C011_CMD_BASE + 0x124, - eCMD_C011_DEC_CHAN_GET_SKIP_PIC_MODE = eCMD_C011_CMD_BASE + 0x125, - eCMD_C011_DEC_CHAN_FILL_PIC_BUF = eCMD_C011_CMD_BASE + 0x126, - eCMD_C011_DEC_CHAN_SET_CONTINUITY_CHECK = eCMD_C011_CMD_BASE + 0x127, - eCMD_C011_DEC_CHAN_GET_CONTINUITY_CHECK = eCMD_C011_CMD_BASE + 0x128, - eCMD_C011_DEC_CHAN_SET_BRCM_TRICK_MODE = eCMD_C011_CMD_BASE + 0x129, - eCMD_C011_DEC_CHAN_GET_BRCM_TRICK_MODE = eCMD_C011_CMD_BASE + 0x12A, - eCMD_C011_DEC_CHAN_REVERSE_FIELD_STATUS = eCMD_C011_CMD_BASE + 0x12B, - eCMD_C011_DEC_CHAN_I_PICTURE_FOUND = eCMD_C011_CMD_BASE + 0x12C, - eCMD_C011_DEC_CHAN_SET_PARAMETER = eCMD_C011_CMD_BASE + 0x12D, - eCMD_C011_DEC_CHAN_SET_USER_DATA_MODE = eCMD_C011_CMD_BASE + 0x12E, - eCMD_C011_DEC_CHAN_SET_PAUSE_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x12F, - eCMD_C011_DEC_CHAN_SET_SLOW_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x130, - eCMD_C011_DEC_CHAN_SET_FF_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x131, - eCMD_C011_DEC_CHAN_SET_DISPLAY_TIMING_MODE = eCMD_C011_CMD_BASE + 0x132, - eCMD_C011_DEC_CHAN_SET_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x133, - eCMD_C011_DEC_CHAN_GET_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x134, - eCMD_C011_DEC_CHAN_SET_REVERSE_FIELD = eCMD_C011_CMD_BASE + 0x135, - eCMD_C011_DEC_CHAN_STREAM_OPEN = eCMD_C011_CMD_BASE + 0x136, - eCMD_C011_DEC_CHAN_SET_PCR_PID = eCMD_C011_CMD_BASE + 0x137, - eCMD_C011_DEC_CHAN_SET_VID_PID = eCMD_C011_CMD_BASE + 0x138, - eCMD_C011_DEC_CHAN_SET_PAN_SCAN_MODE = eCMD_C011_CMD_BASE + 0x139, - eCMD_C011_DEC_CHAN_START_DISPLAY_AT_PTS = eCMD_C011_CMD_BASE + 0x140, - eCMD_C011_DEC_CHAN_STOP_DISPLAY_AT_PTS = eCMD_C011_CMD_BASE + 0x141, - eCMD_C011_DEC_CHAN_SET_DISPLAY_ORDER = eCMD_C011_CMD_BASE + 0x142, - eCMD_C011_DEC_CHAN_GET_DISPLAY_ORDER = eCMD_C011_CMD_BASE + 0x143, - eCMD_C011_DEC_CHAN_SET_HOST_TRICK_MODE = eCMD_C011_CMD_BASE + 0x144, - eCMD_C011_DEC_CHAN_SET_OPERATION_MODE = eCMD_C011_CMD_BASE + 0x145, - eCMD_C011_DEC_CHAN_DISPLAY_PAUSE_UNTO_PTS = eCMD_C011_CMD_BASE + 0x146, - eCMD_C011_DEC_CHAN_SET_PTS_STC_DIFF_THRESHOLD = eCMD_C011_CMD_BASE + 0x147, - eCMD_C011_DEC_CHAN_SEND_COMPRESSED_BUF = eCMD_C011_CMD_BASE + 0x148, - eCMD_C011_DEC_CHAN_SET_CLIPPING = eCMD_C011_CMD_BASE + 0x149, - eCMD_C011_DEC_CHAN_SET_PARAMETERS_FOR_HARD_RESET_INTERRUPT_TO_HOST - = eCMD_C011_CMD_BASE + 0x150, + /* Decoding commands */ + eCMD_C011_DEC_CHAN_OPEN = eCMD_C011_CMD_BASE + 0x100, + eCMD_C011_DEC_CHAN_CLOSE = eCMD_C011_CMD_BASE + 0x101, + eCMD_C011_DEC_CHAN_ACTIVATE = eCMD_C011_CMD_BASE + 0x102, + eCMD_C011_DEC_CHAN_STATUS = eCMD_C011_CMD_BASE + 0x103, + eCMD_C011_DEC_CHAN_FLUSH = eCMD_C011_CMD_BASE + 0x104, + eCMD_C011_DEC_CHAN_TRICK_PLAY = eCMD_C011_CMD_BASE + 0x105, + eCMD_C011_DEC_CHAN_TS_PIDS = eCMD_C011_CMD_BASE + 0x106, + eCMD_C011_DEC_CHAN_PS_STREAM_ID = eCMD_C011_CMD_BASE + 0x107, + eCMD_C011_DEC_CHAN_INPUT_PARAMS = eCMD_C011_CMD_BASE + 0x108, + eCMD_C011_DEC_CHAN_VIDEO_OUTPUT = eCMD_C011_CMD_BASE + 0x109, + eCMD_C011_DEC_CHAN_OUTPUT_FORMAT = eCMD_C011_CMD_BASE + 0x10A, + eCMD_C011_DEC_CHAN_SCALING_FILTERS = eCMD_C011_CMD_BASE + 0x10B, + eCMD_C011_DEC_CHAN_OSD_MODE = eCMD_C011_CMD_BASE + 0x10D, + eCMD_C011_DEC_CHAN_DROP = eCMD_C011_CMD_BASE + 0x10E, + eCMD_C011_DEC_CHAN_RELEASE = eCMD_C011_CMD_BASE + 0x10F, + eCMD_C011_DEC_CHAN_STREAM_SETTINGS = eCMD_C011_CMD_BASE + 0x110, + eCMD_C011_DEC_CHAN_PAUSE_OUTPUT = eCMD_C011_CMD_BASE + 0x111, + eCMD_C011_DEC_CHAN_CHANGE = eCMD_C011_CMD_BASE + 0x112, + eCMD_C011_DEC_CHAN_SET_STC = eCMD_C011_CMD_BASE + 0x113, + eCMD_C011_DEC_CHAN_SET_PTS = eCMD_C011_CMD_BASE + 0x114, + eCMD_C011_DEC_CHAN_CC_MODE = eCMD_C011_CMD_BASE + 0x115, + eCMD_C011_DEC_CREATE_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x116, + eCMD_C011_DEC_COPY_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x117, + eCMD_C011_DEC_DELETE_AUDIO_CONTEXT = eCMD_C011_CMD_BASE + 0x118, + eCMD_C011_DEC_CHAN_SET_DECYPTION = eCMD_C011_CMD_BASE + 0x119, + eCMD_C011_DEC_CHAN_START_VIDEO = eCMD_C011_CMD_BASE + 0x11A, + eCMD_C011_DEC_CHAN_STOP_VIDEO = eCMD_C011_CMD_BASE + 0x11B, + eCMD_C011_DEC_CHAN_PIC_CAPTURE = eCMD_C011_CMD_BASE + 0x11C, + eCMD_C011_DEC_CHAN_PAUSE = eCMD_C011_CMD_BASE + 0x11D, + eCMD_C011_DEC_CHAN_PAUSE_STATE = eCMD_C011_CMD_BASE + 0x11E, + eCMD_C011_DEC_CHAN_SET_SLOWM_RATE = eCMD_C011_CMD_BASE + 0x11F, + eCMD_C011_DEC_CHAN_GET_SLOWM_RATE = eCMD_C011_CMD_BASE + 0x120, + eCMD_C011_DEC_CHAN_SET_FF_RATE = eCMD_C011_CMD_BASE + 0x121, + eCMD_C011_DEC_CHAN_GET_FF_RATE = eCMD_C011_CMD_BASE + 0x122, + eCMD_C011_DEC_CHAN_FRAME_ADVANCE = eCMD_C011_CMD_BASE + 0x123, + eCMD_C011_DEC_CHAN_SET_SKIP_PIC_MODE = eCMD_C011_CMD_BASE + 0x124, + eCMD_C011_DEC_CHAN_GET_SKIP_PIC_MODE = eCMD_C011_CMD_BASE + 0x125, + eCMD_C011_DEC_CHAN_FILL_PIC_BUF = eCMD_C011_CMD_BASE + 0x126, + eCMD_C011_DEC_CHAN_SET_CONTINUITY_CHECK = eCMD_C011_CMD_BASE + 0x127, + eCMD_C011_DEC_CHAN_GET_CONTINUITY_CHECK = eCMD_C011_CMD_BASE + 0x128, + eCMD_C011_DEC_CHAN_SET_BRCM_TRICK_MODE = eCMD_C011_CMD_BASE + 0x129, + eCMD_C011_DEC_CHAN_GET_BRCM_TRICK_MODE = eCMD_C011_CMD_BASE + 0x12A, + eCMD_C011_DEC_CHAN_REVERSE_FIELD_STATUS = eCMD_C011_CMD_BASE + 0x12B, + eCMD_C011_DEC_CHAN_I_PICTURE_FOUND = eCMD_C011_CMD_BASE + 0x12C, + eCMD_C011_DEC_CHAN_SET_PARAMETER = eCMD_C011_CMD_BASE + 0x12D, + eCMD_C011_DEC_CHAN_SET_USER_DATA_MODE = eCMD_C011_CMD_BASE + 0x12E, + eCMD_C011_DEC_CHAN_SET_PAUSE_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x12F, + eCMD_C011_DEC_CHAN_SET_SLOW_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x130, + eCMD_C011_DEC_CHAN_SET_FF_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x131, + eCMD_C011_DEC_CHAN_SET_DISPLAY_TIMING_MODE = eCMD_C011_CMD_BASE + 0x132, + eCMD_C011_DEC_CHAN_SET_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x133, + eCMD_C011_DEC_CHAN_GET_DISPLAY_MODE = eCMD_C011_CMD_BASE + 0x134, + eCMD_C011_DEC_CHAN_SET_REVERSE_FIELD = eCMD_C011_CMD_BASE + 0x135, + eCMD_C011_DEC_CHAN_STREAM_OPEN = eCMD_C011_CMD_BASE + 0x136, + eCMD_C011_DEC_CHAN_SET_PCR_PID = eCMD_C011_CMD_BASE + 0x137, + eCMD_C011_DEC_CHAN_SET_VID_PID = eCMD_C011_CMD_BASE + 0x138, + eCMD_C011_DEC_CHAN_SET_PAN_SCAN_MODE = eCMD_C011_CMD_BASE + 0x139, + eCMD_C011_DEC_CHAN_START_DISPLAY_AT_PTS = eCMD_C011_CMD_BASE + 0x140, + eCMD_C011_DEC_CHAN_STOP_DISPLAY_AT_PTS = eCMD_C011_CMD_BASE + 0x141, + eCMD_C011_DEC_CHAN_SET_DISPLAY_ORDER = eCMD_C011_CMD_BASE + 0x142, + eCMD_C011_DEC_CHAN_GET_DISPLAY_ORDER = eCMD_C011_CMD_BASE + 0x143, + eCMD_C011_DEC_CHAN_SET_HOST_TRICK_MODE = eCMD_C011_CMD_BASE + 0x144, + eCMD_C011_DEC_CHAN_SET_OPERATION_MODE = eCMD_C011_CMD_BASE + 0x145, + eCMD_C011_DEC_CHAN_DISPLAY_PAUSE_UNTO_PTS = eCMD_C011_CMD_BASE + 0x146, + eCMD_C011_DEC_CHAN_SET_PTS_STC_DIFF_THRESHOLD = eCMD_C011_CMD_BASE + 0x147, + eCMD_C011_DEC_CHAN_SEND_COMPRESSED_BUF = eCMD_C011_CMD_BASE + 0x148, + eCMD_C011_DEC_CHAN_SET_CLIPPING = eCMD_C011_CMD_BASE + 0x149, + eCMD_C011_DEC_CHAN_SET_PARAMETERS_FOR_HARD_RESET_INTERRUPT_TO_HOST + = eCMD_C011_CMD_BASE + 0x150, - /* Decoder RevD commands */ - eCMD_C011_DEC_CHAN_SET_CSC = eCMD_C011_CMD_BASE + 0x180, /* color space conversion */ - eCMD_C011_DEC_CHAN_SET_RANGE_REMAP = eCMD_C011_CMD_BASE + 0x181, - eCMD_C011_DEC_CHAN_SET_FGT = eCMD_C011_CMD_BASE + 0x182, - /* Note: 0x183 not implemented yet in Rev D main */ - eCMD_C011_DEC_CHAN_SET_LASTPICTURE_PADDING = eCMD_C011_CMD_BASE + 0x183, + /* Decoder RevD commands */ + eCMD_C011_DEC_CHAN_SET_CSC = eCMD_C011_CMD_BASE + 0x180, /* color space conversion */ + eCMD_C011_DEC_CHAN_SET_RANGE_REMAP = eCMD_C011_CMD_BASE + 0x181, + eCMD_C011_DEC_CHAN_SET_FGT = eCMD_C011_CMD_BASE + 0x182, + /* Note: 0x183 not implemented yet in Rev D main */ + eCMD_C011_DEC_CHAN_SET_LASTPICTURE_PADDING = eCMD_C011_CMD_BASE + 0x183, - /* Decoder 7412 commands (7412-only) */ - eCMD_C011_DEC_CHAN_SET_CONTENT_KEY = eCMD_C011_CMD_BASE + 0x190, - eCMD_C011_DEC_CHAN_SET_SESSION_KEY = eCMD_C011_CMD_BASE + 0x191, - eCMD_C011_DEC_CHAN_FMT_CHANGE_ACK = eCMD_C011_CMD_BASE + 0x192, + /* Decoder 7412 commands (7412-only) */ + eCMD_C011_DEC_CHAN_SET_CONTENT_KEY = eCMD_C011_CMD_BASE + 0x190, + eCMD_C011_DEC_CHAN_SET_SESSION_KEY = eCMD_C011_CMD_BASE + 0x191, + eCMD_C011_DEC_CHAN_FMT_CHANGE_ACK = eCMD_C011_CMD_BASE + 0x192, - eCMD_C011_DEC_CHAN_CUSTOM_VIDOUT = eCMD_C011_CMD_BASE + 0x1FF, + eCMD_C011_DEC_CHAN_CUSTOM_VIDOUT = eCMD_C011_CMD_BASE + 0x1FF, - /* Encoding commands */ - eCMD_C011_ENC_CHAN_OPEN = eCMD_C011_CMD_BASE + 0x200, - eCMD_C011_ENC_CHAN_CLOSE = eCMD_C011_CMD_BASE + 0x201, - eCMD_C011_ENC_CHAN_ACTIVATE = eCMD_C011_CMD_BASE + 0x202, - eCMD_C011_ENC_CHAN_CONTROL = eCMD_C011_CMD_BASE + 0x203, - eCMD_C011_ENC_CHAN_STATISTICS = eCMD_C011_CMD_BASE + 0x204, + /* Encoding commands */ + eCMD_C011_ENC_CHAN_OPEN = eCMD_C011_CMD_BASE + 0x200, + eCMD_C011_ENC_CHAN_CLOSE = eCMD_C011_CMD_BASE + 0x201, + eCMD_C011_ENC_CHAN_ACTIVATE = eCMD_C011_CMD_BASE + 0x202, + eCMD_C011_ENC_CHAN_CONTROL = eCMD_C011_CMD_BASE + 0x203, + eCMD_C011_ENC_CHAN_STATISTICS = eCMD_C011_CMD_BASE + 0x204, - eNOTIFY_C011_ENC_CHAN_EVENT = eCMD_C011_CMD_BASE + 0x210, + eNOTIFY_C011_ENC_CHAN_EVENT = eCMD_C011_CMD_BASE + 0x210, }; diff --git a/drivers/staging/crystalhd/crystalhd_misc.h b/drivers/staging/crystalhd/crystalhd_misc.h index 382078eafa0..4d617235742 100644 --- a/drivers/staging/crystalhd/crystalhd_misc.h +++ b/drivers/staging/crystalhd/crystalhd_misc.h @@ -205,12 +205,12 @@ enum _chd_log_levels { #define BCMLOG_ENTER \ if (g_linklog_level & BCMLOG_ENTER_LEAVE) { \ - printk("Entered %s\n", __func__); \ + printk(KERN_DEBUG "Entered %s\n", __func__); \ } #define BCMLOG_LEAVE \ if (g_linklog_level & BCMLOG_ENTER_LEAVE) { \ - printk("Leaving %s\n", __func__); \ + printk(KERN_DEBUG "Leaving %s\n", __func__); \ } #define BCMLOG(trace, fmt, args...) \ @@ -221,7 +221,7 @@ if (g_linklog_level & trace) { \ #define BCMLOG_ERR(fmt, args...) \ do { \ if (g_linklog_level & BCMLOG_ERROR) { \ - printk("*ERR*:%s:%d: "fmt, __FILE__, __LINE__, ##args); \ + printk(KERN_ERR "*ERR*:%s:%d: "fmt, __FILE__, __LINE__, ##args); \ } \ } while (0); From 3028474cb469ff5352bbc7cc685eee46ab8e888b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 11 Sep 2011 00:29:53 +0300 Subject: [PATCH 0969/1519] staging: xgifb: properly delete MTRR region MTRR region should be deleted on probe failure and driver removal. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index db9d27b04ce..e018b9a43bc 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2424,13 +2424,19 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (register_framebuffer(fb_info) < 0) { ret = -EINVAL; - goto error_1; + goto error_mtrr; } dumpVGAReg(); return 0; +error_mtrr: +#ifdef CONFIG_MTRR + if (xgi_video_info.mtrr >= 0) + mtrr_del(xgi_video_info.mtrr, xgi_video_info.video_base, + xgi_video_info.video_size); +#endif /* CONFIG_MTRR */ error_1: iounmap(xgi_video_info.mmio_vbase); iounmap(xgi_video_info.video_vbase); @@ -2451,6 +2457,11 @@ error: static void __devexit xgifb_remove(struct pci_dev *pdev) { unregister_framebuffer(fb_info); +#ifdef CONFIG_MTRR + if (xgi_video_info.mtrr >= 0) + mtrr_del(xgi_video_info.mtrr, xgi_video_info.video_base, + xgi_video_info.video_size); +#endif /* CONFIG_MTRR */ iounmap(xgi_video_info.mmio_vbase); iounmap(xgi_video_info.video_vbase); release_mem_region(xgi_video_info.mmio_base, xgi_video_info.mmio_size); From 15ebe6c657db155fbb04143b1a655b8a58b0402e Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 11 Sep 2011 00:29:54 +0300 Subject: [PATCH 0970/1519] staging: xgifb: fix up MTRR printk The condition for printk() is wrong. Also change it to dev_info(). Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e018b9a43bc..1bff7f6caa4 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2418,8 +2418,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, (unsigned int) xgi_video_info.video_base, (unsigned int) xgi_video_info.video_size, MTRR_TYPE_WRCOMB, 1); - if (xgi_video_info.mtrr) - printk(KERN_INFO "XGIfb: Added MTRRs\n"); + if (xgi_video_info.mtrr >= 0) + dev_info(&pdev->dev, "added MTRR\n"); #endif if (register_framebuffer(fb_info) < 0) { From 7c1387e0ec02f5b44f292b6639a93a2aea949ba0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 11 Sep 2011 00:29:55 +0300 Subject: [PATCH 0971/1519] staging: xgifb: delete redundant casts from mtrr_add() call Delete redundant casts from mtrr_add() call. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 1bff7f6caa4..8c5a6e8a695 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2414,10 +2414,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, fb_alloc_cmap(&fb_info->cmap, 256 , 0); #ifdef CONFIG_MTRR - xgi_video_info.mtrr = mtrr_add( - (unsigned int) xgi_video_info.video_base, - (unsigned int) xgi_video_info.video_size, - MTRR_TYPE_WRCOMB, 1); + xgi_video_info.mtrr = mtrr_add(xgi_video_info.video_base, + xgi_video_info.video_size, MTRR_TYPE_WRCOMB, 1); if (xgi_video_info.mtrr >= 0) dev_info(&pdev->dev, "added MTRR\n"); #endif From fc008b9adaebf9a186afcc71063c56d8c6a1fd51 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 12 Sep 2011 12:14:45 +0200 Subject: [PATCH 0972/1519] staging: brcm80211: stop using kthread for iscan status check in fullmac Use work queue instead. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Howard Harte Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 76 ++++++------------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 3 +- 2 files changed, 23 insertions(+), 56 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index db51c466f2e..c8e47ff9117 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -271,7 +271,6 @@ static s32 brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, static void brcmf_iscan_timer(unsigned long data); static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv); static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_iscan_thread(void *data); static s32 brcmf_dev_iovar_setbuf(struct net_device *dev, s8 *iovar, void *param, s32 paramlen, void *bufptr, s32 buflen); @@ -3151,18 +3150,15 @@ static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); struct brcmf_ssid ssid; - if (cfg_priv->iscan_on && iscan->tsk) { + if (cfg_priv->iscan_on) { iscan->state = WL_ISCAN_STATE_IDLE; - send_sig(SIGTERM, iscan->tsk, 1); - /* - * The iscan task may want to acquire the rtnl_lock - * so release it here upon stopping the task. - */ - rtnl_unlock(); - kthread_stop(iscan->tsk); - rtnl_lock(); - iscan->tsk = NULL; + if (iscan->timer_on) { + del_timer_sync(&iscan->timer); + iscan->timer_on = 0; + } + + cancel_work_sync(&iscan->work); /* Abort iscan running in FW */ memset(&ssid, 0, sizeof(ssid)); @@ -3195,7 +3191,7 @@ static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) { if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) { WL_SCAN("wake up iscan\n"); - wake_up(&iscan->waitq); + schedule_work(&iscan->work); return 0; } @@ -3294,50 +3290,28 @@ static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv) return err; } -static s32 brcmf_iscan_thread(void *data) +static void brcmf_cfg80211_iscan_handler(struct work_struct *work) { - struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; struct brcmf_cfg80211_iscan_ctrl *iscan = - (struct brcmf_cfg80211_iscan_ctrl *)data; + container_of(work, struct brcmf_cfg80211_iscan_ctrl, + work); struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); struct brcmf_cfg80211_iscan_eloop *el = &iscan->el; - DECLARE_WAITQUEUE(wait, current); - u32 status; - int err = 0; + u32 status = BRCMF_SCAN_RESULTS_PARTIAL; - sched_setscheduler(current, SCHED_FIFO, ¶m); - allow_signal(SIGTERM); - status = BRCMF_SCAN_RESULTS_PARTIAL; - add_wait_queue(&iscan->waitq, &wait); - while (1) { - prepare_to_wait(&iscan->waitq, &wait, TASK_INTERRUPTIBLE); - - schedule(); - - if (kthread_should_stop()) - break; - if (iscan->timer_on) { - del_timer_sync(&iscan->timer); - iscan->timer_on = 0; - } - rtnl_lock(); - err = brcmf_get_iscan_results(iscan, &status, - &cfg_priv->bss_list); - if (unlikely(err)) { - status = BRCMF_SCAN_RESULTS_ABORTED; - WL_ERR("Abort iscan\n"); - } - rtnl_unlock(); - el->handler[status](cfg_priv); - } - finish_wait(&iscan->waitq, &wait); if (iscan->timer_on) { del_timer_sync(&iscan->timer); iscan->timer_on = 0; } - WL_SCAN("ISCAN thread terminated\n"); - return 0; + rtnl_lock(); + if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) { + status = BRCMF_SCAN_RESULTS_ABORTED; + WL_ERR("Abort iscan\n"); + } + rtnl_unlock(); + + el->handler[status](cfg_priv); } static void brcmf_iscan_timer(unsigned long data) @@ -3356,15 +3330,9 @@ static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - if (cfg_priv->iscan_on && !iscan->tsk) { + if (cfg_priv->iscan_on) { iscan->state = WL_ISCAN_STATE_IDLE; - init_waitqueue_head(&iscan->waitq); - iscan->tsk = kthread_run(brcmf_iscan_thread, iscan, "wl_iscan"); - if (IS_ERR(iscan->tsk)) { - WL_ERR("Could not create iscan thread\n"); - iscan->tsk = NULL; - return -ENOMEM; - } + INIT_WORK(&iscan->work, brcmf_cfg80211_iscan_handler); } return 0; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 0542bac2d79..98cd47da86b 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -248,8 +248,7 @@ struct brcmf_cfg80211_iscan_ctrl { u32 timer_ms; u32 timer_on; s32 state; - struct task_struct *tsk; - wait_queue_head_t waitq; + struct work_struct work; struct brcmf_cfg80211_iscan_eloop el; void *data; s8 ioctl_buf[BRCMF_C_IOCTL_SMLEN]; From 21f070df39ab6784fc628db3219189d77fb8b968 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:46 +0200 Subject: [PATCH 0973/1519] staging: brcm80211: cleaned up softmac types.h macro's Substituted/removed macro's. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/alloc.c | 30 ++++++++++++++++ drivers/staging/brcm80211/brcmsmac/ampdu.c | 2 +- drivers/staging/brcm80211/brcmsmac/channel.c | 18 +++++----- drivers/staging/brcm80211/brcmsmac/main.c | 31 ++++++++-------- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 10 +++--- drivers/staging/brcm80211/brcmsmac/rate.c | 5 +-- drivers/staging/brcm80211/brcmsmac/types.h | 35 ------------------- 7 files changed, 64 insertions(+), 67 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 52ca7e3f9a9..7a499ba1858 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -20,6 +20,36 @@ #include "main.h" #include "alloc.h" +/* Max # of entries in Tx FIFO based on 4kb page size */ +#define NTXD 256 +/* Max # of entries in Rx FIFO based on 4kb page size */ +#define NRXD 256 +/* try to keep this # rbufs posted to the chip */ +#define NRXBUFPOST 32 +/* Maximum SCBs in cache for STA */ +#define MAXSCB 32 + +/* Count of packet callback structures. either of following + * 1. Set to the number of SCBs since a STA + * can queue up a rate callback for each IBSS STA it knows about, and an AP can + * queue up an "are you there?" Null Data callback for each associated STA + * 2. controlled by tunable config file + */ +#define MAXPKTCB MAXSCB /* Max number of packet callbacks */ + +/* Number of BSS handled in ucode bcn/prb */ +#define BRCMS_MAX_UCODE_BSS (16) +/* Number of BSS handled in sw bcn/prb */ +#define BRCMS_MAX_UCODE_BSS4 (4) + +/* data msg txq hiwat mark */ +#define BRCMS_DATAHIWAT 50 +#define BRCMS_AMPDUDATAHIWAT 255 + +/* bounded rx loops */ +#define RXBND 8 /* max # frames to process in brcms_c_recv() */ +#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ + static void brcms_c_tunables_init(struct brcms_tunables *tunables, uint devid) { tunables->ntxd = NTXD; diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 7c44598e630..9c1ae7cde50 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -990,7 +990,7 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, "error (0x%x)\n", wlc->pub->unit, txs->phyerr); - if (WL_ERROR_ON()) { + if (brcm_msg_level & LOG_ERROR_VAL) { brcmu_prpkt("txpkt (AMPDU)", p); brcms_c_print_txdesc((struct d11txh *) p->data); } diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 282adcefbb3..27c62c7d5cd 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -911,7 +911,7 @@ static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) * Now that the country abbreviation is set, if the radio supports 2G, * then set channel 14 restrictions based on the new locale. */ - if (wlc->pub->_nbands > 1 || BAND_2G(wlc->band->bandtype)) + if (wlc->pub->_nbands > 1 || wlc->band->bandtype == BRCM_BAND_2G) wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, brcms_c_japan(wlc) ? true : false); @@ -939,11 +939,11 @@ brcms_c_channels_init(struct brcms_cm_info *wlc_cm, for (i = 0; i < wlc->pub->_nbands; i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { - li = BAND_5G(band->bandtype) ? + li = (band->bandtype == BRCM_BAND_5G) ? brcms_c_get_locale_5g(country->locale_5G) : brcms_c_get_locale_2g(country->locale_2G); wlc_cm->bandstate[band->bandunit].locale_flags = li->flags; - li_mimo = BAND_5G(band->bandtype) ? + li_mimo = (band->bandtype == BRCM_BAND_5G) ? brcms_c_get_mimo_5g(country->locale_mimo_5G) : brcms_c_get_mimo_2g(country->locale_mimo_2G); @@ -1311,11 +1311,11 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, chan = CHSPEC_CHANNEL(chanspec); band = wlc->bandstate[CHSPEC_BANDUNIT(chanspec)]; - li = BAND_5G(band->bandtype) ? + li = (band->bandtype == BRCM_BAND_5G) ? brcms_c_get_locale_5g(country->locale_5G) : brcms_c_get_locale_2g(country->locale_2G); - li_mimo = BAND_5G(band->bandtype) ? + li_mimo = (band->bandtype == BRCM_BAND_5G) ? brcms_c_get_mimo_5g(country->locale_mimo_5G) : brcms_c_get_mimo_2g(country->locale_mimo_2G); @@ -1333,7 +1333,7 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } /* CCK txpwr limits for 2.4G band */ - if (BAND_2G(band->bandtype)) { + if (band->bandtype == BRCM_BAND_2G) { maxpwr = li->maxpwr[CHANNEL_POWER_IDX_2G_CCK(chan)]; maxpwr = maxpwr - delta; @@ -1345,7 +1345,7 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } /* OFDM txpwr limits for 2.4G or 5G bands */ - if (BAND_2G(band->bandtype)) + if (band->bandtype == BRCM_BAND_2G) maxpwr = li->maxpwr[CHANNEL_POWER_IDX_2G_OFDM(chan)]; else maxpwr = li->maxpwr[CHANNEL_POWER_IDX_5G(chan)]; @@ -1355,7 +1355,7 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, maxpwr = min(maxpwr, conducted_ofdm_max); /* Keep OFDM lmit below CCK limit */ - if (BAND_2G(band->bandtype)) + if (band->bandtype == BRCM_BAND_2G) maxpwr = min_t(int, maxpwr, txpwr->cck[0]); for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) @@ -1385,7 +1385,7 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, delta = band->antgain - QDB(6); /* Excess over 6 dB */ } - if (BAND_2G(band->bandtype)) + if (band->bandtype == BRCM_BAND_2G) maxpwr_idx = (chan - 1); else maxpwr_idx = CHANNEL_POWER_IDX_5G(chan); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 6d2fc10318a..7cd3b9ea2fb 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -329,6 +329,8 @@ #define NRATE_STF_STBC 2 /* stf mode STBC */ #define NRATE_STF_SDM 3 /* stf mode SDM */ +#define MAX_DMA_SEGS 4 + /* * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. */ @@ -1585,9 +1587,8 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); brcms_b_update_slot_timing(wlc_hw, - BAND_5G(wlc_hw->band-> - bandtype) ? true : wlc_hw-> - shortslot); + wlc_hw->band->bandtype == BRCM_BAND_5G ? + true : wlc_hw->shortslot); /* write phytype and phyvers */ brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); @@ -3738,7 +3739,7 @@ static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) { wlc_hw->shortslot = shortslot; - if (BAND_2G(brcms_b_bandtype(wlc_hw)) && wlc_hw->up) { + if (brcms_b_bandtype(wlc_hw) == BRCM_BAND_2G && wlc_hw->up) { brcms_c_suspend_mac_and_wait(wlc_hw->wlc); brcms_b_update_slot_timing(wlc_hw, shortslot); brcms_c_enable_mac(wlc_hw->wlc); @@ -4929,10 +4930,10 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) bandtype = wlc->band->bandtype; /* get antennas available */ - aa = (s8) getintvar(vars, (BAND_5G(bandtype) ? "aa5g" : "aa2g")); + aa = (s8) getintvar(vars, bandtype == BRCM_BAND_5G ? "aa5g" : "aa2g"); if (aa == 0) aa = (s8) getintvar(vars, - (BAND_5G(bandtype) ? "aa1" : "aa0")); + bandtype == BRCM_BAND_5G ? "aa1" : "aa0"); if ((aa < 1) || (aa > 15)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" " srom (0x%x), using 3\n", unit, __func__, aa); @@ -4951,7 +4952,7 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) /* Compute Antenna Gain */ wlc->band->antgain = - (s8) getintvar(vars, (BAND_5G(bandtype) ? "ag1" : "ag0")); + (s8) getintvar(vars, bandtype == BRCM_BAND_5G ? "ag1" : "ag0"); brcms_c_attach_antgain_init(wlc); return true; @@ -5169,7 +5170,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->band->CWmax = PHY_CWMAX; /* init gmode value */ - if (BAND_2G(wlc->band->bandtype)) { + if (wlc->band->bandtype == BRCM_BAND_2G) { wlc->band->gmode = GMODE_AUTO; brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, wlc->band->gmode); @@ -6382,7 +6383,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, /* shortslot is an 11g feature, so no more work if we are * currently on the 5G band */ - if (BAND_5G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_5G) break; if (wlc->pub->up && wlc->pub->associated) { @@ -6965,7 +6966,7 @@ brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec); dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); /* payload calculation matches that of regular ofdm */ - if (BAND_2G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_2G) dur -= DOT11_OFDM_SIGNAL_EXTENSION; /* kNdbps = kbps * 4 */ kNdps = @@ -7466,7 +7467,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, if (!is_multicast_ether_addr(h->addr1)) mcl |= TXC_IMMEDACK; - if (BAND_5G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_5G) mcl |= TXC_FREQBAND_5G; if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) @@ -8243,7 +8244,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) mcl = le16_to_cpu(txh->MacTxControlLow); if (txs->phyerr) { - if (WL_ERROR_ON()) { + if (brcm_msg_level & LOG_ERROR_VAL) { wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n", txs->phyerr, txh->MainRates); brcms_c_print_txdesc(txh); @@ -8772,7 +8773,7 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, APHY_TAIL_NBITS) * 1000, 2 * kNdps); dur += APHY_SYMBOL_TIME * nsyms; - if (BAND_2G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_2G) dur += DOT11_OFDM_SIGNAL_EXTENSION; } else if (IS_OFDM(rate)) { dur = APHY_PREAMBLE_TIME; @@ -8784,7 +8785,7 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS), Ndps); dur += APHY_SYMBOL_TIME * nsyms; - if (BAND_2G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_2G) dur += DOT11_OFDM_SIGNAL_EXTENSION; } else { /* @@ -8937,7 +8938,7 @@ brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) const struct brcms_c_rateset *rs_dflt; if (BRCMS_PHY_11N_CAP(wlc->band)) { - if (BAND_5G(wlc->band->bandtype)) + if (wlc->band->bandtype == BRCM_BAND_5G) rs_dflt = &ofdm_mimo_rates; else rs_dflt = &cck_ofdm_mimo_rates; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 5f30de20f6d..a159961972a 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -512,7 +512,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, else sflags = ai_core_sflags(sh->sih, 0, 0); - if (BAND_5G(bandtype)) { + if (bandtype == BRCM_BAND_5G) { if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) return NULL; } @@ -541,7 +541,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, pi->phycal_tempdelta = 0; - if (BAND_2G(bandtype) && (sflags & SISF_2G_PHY)) + if (bandtype == BRCM_BAND_2G && (sflags & SISF_2G_PHY)) pi->pubpi.coreflags = SICF_GMODE; wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); @@ -561,7 +561,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, !pi->pubpi.phy_type == PHY_TYPE_LCN) goto err; - if (BAND_5G(bandtype)) { + if (bandtype == BRCM_BAND_5G) { if (!ISNPHY(pi)) goto err; } else if (!ISNPHY(pi) && !ISLCNPHY(pi)) { @@ -585,8 +585,8 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, wlc_set_phy_uninitted(pi); pi->bw = WL_CHANSPEC_BW_20; - pi->radio_chanspec = - BAND_2G(bandtype) ? CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36); + pi->radio_chanspec = (bandtype == BRCM_BAND_2G) ? + CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36); pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; pi->rxiq_antsel = ANT_RX_DIV_DEF; diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index 9730139f590..1241dc9e1ae 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -447,7 +447,7 @@ brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, (PHYTYPE_IS(phy_type, PHY_TYPE_N)) || (PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) || (PHYTYPE_IS(phy_type, PHY_TYPE_SSN))) { - if (BAND_5G(bandtype)) + if (bandtype == BRCM_BAND_5G) rs_dflt = (bw == BRCMS_20_MHZ ? &ofdm_mimo_rates : &ofdm_40bw_mimo_rates); else @@ -455,7 +455,8 @@ brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, &cck_ofdm_mimo_rates : &cck_ofdm_40bw_mimo_rates); } else if (PHYTYPE_IS(phy_type, PHY_TYPE_LP)) { - rs_dflt = (BAND_5G(bandtype)) ? &ofdm_rates : &cck_ofdm_rates; + rs_dflt = (bandtype == BRCM_BAND_5G) ? + &ofdm_rates : &cck_ofdm_rates; } else if (PHYTYPE_IS(phy_type, PHY_TYPE_A)) { rs_dflt = &ofdm_rates; } else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) { diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 792df079364..f9794dcf6ef 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -25,8 +25,6 @@ #define WL_CHAN_FREQ_RANGE_5GM 2 #define WL_CHAN_FREQ_RANGE_5GH 3 -#define MAX_DMA_SEGS 4 - /* boardflags */ /* Board has gpio 9 controlling the PA */ @@ -257,46 +255,15 @@ * *********************************************** */ -/* Max # of entries in Tx FIFO based on 4kb page size */ -#define NTXD 256 -/* Max # of entries in Rx FIFO based on 4kb page size */ -#define NRXD 256 -/* try to keep this # rbufs posted to the chip */ -#define NRXBUFPOST 32 -/* Maximum SCBs in cache for STA */ -#define MAXSCB 32 - /* max allowed number of mpdus in an ampdu (2 streams) */ #define AMPDU_NUM_MPDU 16 -/* Count of packet callback structures. either of following - * 1. Set to the number of SCBs since a STA - * can queue up a rate callback for each IBSS STA it knows about, and an AP can - * queue up an "are you there?" Null Data callback for each associated STA - * 2. controlled by tunable config file - */ -#define MAXPKTCB MAXSCB /* Max number of packet callbacks */ - /* NetBSD also needs to keep track of this */ -/* Number of BSS handled in ucode bcn/prb */ -#define BRCMS_MAX_UCODE_BSS (16) -/* Number of BSS handled in sw bcn/prb */ -#define BRCMS_MAX_UCODE_BSS4 (4) /* max # BSS configs */ #define BRCMS_MAXBSSCFG (1) /* max # available networks */ #define MAXBSS 64 -/* data msg txq hiwat mark */ -#define BRCMS_DATAHIWAT 50 -#define BRCMS_AMPDUDATAHIWAT 255 - -/* bounded rx loops */ -#define RXBND 8 /* max # frames to process in brcms_c_recv() */ -#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ - -#define BAND_5G(bt) ((bt) == BRCM_BAND_5G) -#define BAND_2G(bt) ((bt) == BRCM_BAND_2G) #define BCMMSG(dev, fmt, args...) \ do { \ @@ -304,8 +271,6 @@ do { \ wiphy_err(dev, "%s: " fmt, __func__, ##args); \ } while (0) -#define WL_ERROR_ON() (brcm_msg_level & LOG_ERROR_VAL) - /* * Register access macros. * From ea2380f79172f25dc19c972efed0ac9af3c5d192 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:47 +0200 Subject: [PATCH 0974/1519] staging: brcm80211: cleaned up brcmu_utils.h macro's Substituted/removed macro's. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 4 + drivers/staging/brcm80211/brcmsmac/main.c | 6 +- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 14 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 7 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 17 +- drivers/staging/brcm80211/brcmsmac/pub.h | 6 +- drivers/staging/brcm80211/brcmsmac/types.h | 2 + .../staging/brcm80211/include/brcmu_utils.h | 161 +++++++++--------- 8 files changed, 115 insertions(+), 102 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 9c1ae7cde50..efae10f99c0 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -69,6 +69,10 @@ AMPDU_DELIMITER_LEN + 3\ + DOT11_A4_HDR_LEN + DOT11_QOS_LEN + DOT11_IV_MAX_LEN) +/* modulo add/sub, bound = 2^k */ +#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) +#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) + /* structure to hold tx fifo information and pre-loading state * counters specific to tx underflows of ampdus * some counters might be redundant with the ones in wlc or ampdu structures. diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 7cd3b9ea2fb..51ad7f003b1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -186,6 +186,8 @@ #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ +#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) + /* * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s * OS timer(soft watchdog) it is not a wall clock and won't increment when @@ -7863,8 +7865,8 @@ void brcms_c_send_q(struct brcms_c_info *wlc) int prio; for (prio = MAXPRIO; prio >= 0; prio--) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && - (pktq_plen(q, wlc_prio2prec_map[prio]) < - wlc->pub->tunables->datahiwat / 2)) + q->q[wlc_prio2prec_map[prio]].len < + wlc->pub->tunables->datahiwat / 2) brcms_c_txflowcontrol(wlc, qi, OFF, prio); } } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index a159961972a..119a1270beb 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -13,7 +13,7 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - +#include #include #include @@ -37,6 +37,16 @@ (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) +/* basic mux operation - can be optimized on several architectures */ +#define MUX(pred, true, false) ((pred) ? (true) : (false)) + +/* modulo inc/dec - assumes x E [0, bound - 1] */ +#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) + +/* modulo inc/dec, bound = 2^k */ +#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) +#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) + struct chan_info_basic { u16 chan; u16 freq; @@ -2879,7 +2889,7 @@ u8 wlc_phy_nbits(s32 value) s32 abs_val; u8 nbits = 0; - abs_val = ABS(value); + abs_val = abs(value); while ((abs_val >> nbits) > 0) nbits++; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index fa21734902a..46661b833b8 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -14,6 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include @@ -3378,9 +3379,9 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, k = 1; do { bw = phy_bw * 1000 * k; - num_samps = bw / ABS(f_kHz); + num_samps = bw / abs(f_kHz); k++; - } while ((num_samps * (u32) (ABS(f_kHz))) != bw); + } while ((num_samps * (u32) (abs(f_kHz))) != bw); } else num_samps = 2; @@ -3894,7 +3895,7 @@ static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) } wlc_lcnphy_get_radio_loft(pi, &ei0, &eq0, &fi0, &fq0); - if ((ABS((s8) fi0) == 15) && (ABS((s8) fq0) == 15)) { + if ((abs((s8) fi0) == 15) && (abs((s8) fq0) == 15)) { if (CHSPEC_IS5G(pi->radio_chanspec)) { target_gains.gm_gain = 255; target_gains.pga_gain = 255; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 7a50a23727f..58645d2b79d 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14,6 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include @@ -22648,7 +22649,7 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) poll_results[vcm_final][result_idx]; if (fine_digital_offset[result_idx] < 0) { fine_digital_offset[result_idx] = - ABS(fine_digital_offset + abs(fine_digital_offset [result_idx]); fine_digital_offset[result_idx] += (NPHY_RSSICAL_NPOLL / 2); @@ -22727,7 +22728,7 @@ static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) if (fine_digital_offset[result_idx] < 0) { fine_digital_offset[result_idx] - = ABS( + = abs( fine_digital_offset [result_idx]); fine_digital_offset[result_idx] @@ -23004,7 +23005,7 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) min_vcm = 0; min_poll = NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL + 1; for (vcm = 0; vcm < 4; vcm++) { - curr_d = ABS(((rssi_type == NPHY_RSSI_SEL_NB) ? + curr_d = abs(((rssi_type == NPHY_RSSI_SEL_NB) ? poll_results[vcm][result_idx] : poll_miniq[vcm][result_idx / 2]) - (target_code * NPHY_RSSICAL_NPOLL)); @@ -23028,7 +23029,7 @@ static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) poll_results[vcm_final[result_idx]][result_idx]; if (fine_digital_offset[result_idx] < 0) { fine_digital_offset[result_idx] = - ABS(fine_digital_offset[result_idx]); + abs(fine_digital_offset[result_idx]); fine_digital_offset[result_idx] += (NPHY_RSSICAL_NPOLL / 2); fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; @@ -27422,9 +27423,9 @@ wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) if (rccal_stepsize == -1) { best_rccal_val = - (ABS((int)last_pwr_ratio - + (abs((int)last_pwr_ratio - (int)target_pwr_ratio) < - ABS((int)pwr_ratio - + abs((int)pwr_ratio - (int)target_pwr_ratio)) ? last_rccal_val : rccal_val; @@ -28324,10 +28325,10 @@ void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi) || (wlc_phy_txpwr_ison_nphy(pi) && (((u32) - ABS(wlc_phy_txpwr_idx_cur_get_nphy(pi, 0) - + abs(wlc_phy_txpwr_idx_cur_get_nphy(pi, 0) - pi->nphy_papd_tx_gain_at_last_cal[0]) >= 4) || ((u32) - ABS(wlc_phy_txpwr_idx_cur_get_nphy(pi, 1) - + abs(wlc_phy_txpwr_idx_cur_get_nphy(pi, 1) - pi->nphy_papd_tx_gain_at_last_cal[1]) >= 4))))) wlc_phy_a4(pi, true); } diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index f623d6e83e0..381ddb4cf2e 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -237,11 +237,7 @@ struct brcms_pub { */ bool align_wd_tbtt; /* Align watchdog with tbtt indication * handling. This flag is cleared by default - * and is set by per port code explicitly and - * you need to make sure the OSL_SYSUPTIME() - * is implemented properly in osl of that port - * when it enables this Power Save feature. - */ + * and is set explicitly */ u16 boardrev; /* version # of particular board */ u8 sromrev; /* version # of the srom */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index f9794dcf6ef..a3af57c535a 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -341,6 +341,8 @@ do { \ #define mboolisset(mb, bit) (((mb) & (bit)) != 0) #define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) +#define CEIL(x, y) (((x) + ((y)-1)) / (y)) + /* forward declarations */ struct wiphy; struct ieee80211_sta; diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index de627c211f6..633972125eb 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -48,6 +48,34 @@ struct brcmu_strbuf { #define PKTQ_LEN_DEFAULT 128 /* Max 128 packets */ #define PKTQ_MAX_PREC 16 /* Maximum precedence levels */ +#define BCME_STRLEN 64 /* Max string length for BCM errors */ + +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ +#define PKTBUFSZ 2048 + +#ifndef setbit +#ifndef NBBY /* the BSD family defines NBBY */ +#define NBBY 8 /* 8 bits per byte */ +#endif /* #ifndef NBBY */ +#define setbit(a, i) (((u8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a, i) (((u8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a, i) (((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a, i) ((((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +#endif /* setbit */ + +#define NBITS(type) (sizeof(type) * 8) +#define NBITVAL(nbits) (1 << (nbits)) +#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) +#define NBITMASK(nbits) MAXBITVAL(nbits) +#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) + +/* crc defines */ +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */ +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */ + +/* 18-bytes of Ethernet address buffer length */ +#define ETHER_ADDR_STR_LEN 18 + struct pktq_prec { struct sk_buff *head; /* first packet to dequeue */ struct sk_buff *tail; /* last packet to dequeue */ @@ -70,14 +98,35 @@ struct pktq { /* operations on a specific precedence in packet queue */ -#define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max)) -#define pktq_plen(pq, prec) ((pq)->q[prec].len) -#define pktq_pavail(pq, prec) ((pq)->q[prec].max - (pq)->q[prec].len) -#define pktq_pfull(pq, prec) ((pq)->q[prec].len >= (pq)->q[prec].max) -#define pktq_pempty(pq, prec) ((pq)->q[prec].len == 0) +static inline int pktq_plen(struct pktq *pq, int prec) +{ + return pq->q[prec].len; +} -#define pktq_ppeek(pq, prec) ((pq)->q[prec].head) -#define pktq_ppeek_tail(pq, prec) ((pq)->q[prec].tail) +static inline int pktq_pavail(struct pktq *pq, int prec) +{ + return pq->q[prec].max - pq->q[prec].len; +} + +static inline bool pktq_pfull(struct pktq *pq, int prec) +{ + return pq->q[prec].len >= pq->q[prec].max; +} + +static inline bool pktq_pempty(struct pktq *pq, int prec) +{ + return pq->q[prec].len == 0; +} + +static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) +{ + return pq->q[prec].head; +} + +static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) +{ + return pq->q[prec].tail; +} extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, struct sk_buff *p); @@ -103,19 +152,30 @@ extern struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, /* operations on packet queue as a whole */ -#define pktq_len(pq) ((int)(pq)->len) -#define pktq_max(pq) ((int)(pq)->max) -#define pktq_avail(pq) ((int)((pq)->max - (pq)->len)) -#define pktq_full(pq) ((pq)->len >= (pq)->max) -#define pktq_empty(pq) ((pq)->len == 0) +static inline int pktq_len(struct pktq *pq) +{ + return (int)pq->len; +} -/* operations for single precedence queues */ -#define pktenq(pq, p) brcmu_pktq_penq(((struct pktq *)pq), 0, (p)) -#define pktenq_head(pq, p)\ - brcmu_pktq_penq_head(((struct pktq *)pq), 0, (p)) -#define pktdeq(pq) brcmu_pktq_pdeq(((struct pktq *)pq), 0) -#define pktdeq_tail(pq) brcmu_pktq_pdeq_tail(((struct pktq *)pq), 0) -#define pktqinit(pq, len) brcmu_pktq_init(((struct pktq *)pq), 1, len) +static inline int pktq_max(struct pktq *pq) +{ + return (int)pq->max; +} + +static inline int pktq_avail(struct pktq *pq) +{ + return (int)(pq->max - pq->len); +} + +static inline bool pktq_full(struct pktq *pq) +{ + return pq->len >= pq->max; +} + +static inline bool pktq_empty(struct pktq *pq) +{ + return pq->len == 0; +} extern void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len); /* prec_out may be NULL if caller is not interested in return value */ @@ -182,66 +242,6 @@ extern int brcmu_iovar_lencheck(const struct brcmu_iovar *table, void *arg, #define IOVT_INT32 6 /* int 32 bits */ #define IOVT_UINT32 7 /* unsigned int 32 bits */ #define IOVT_BUFFER 8 /* buffer is size-checked as per minlen */ -#define BCM_IOVT_VALID(type) (((unsigned int)(type)) <= IOVT_BUFFER) - -/* ** driver/apps-shared section ** */ - -#define BCME_STRLEN 64 /* Max string length for BCM errors */ - -#define ABS(a) (((a) < 0) ? -(a) : (a)) - -#define CEIL(x, y) (((x) + ((y)-1)) / (y)) -#define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) - -/* map physical to virtual I/O */ -#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), \ - (unsigned long)(size)) - -/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ -#define PKTBUFSZ 2048 - -#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) - -#ifndef setbit -#ifndef NBBY /* the BSD family defines NBBY */ -#define NBBY 8 /* 8 bits per byte */ -#endif /* #ifndef NBBY */ -#define setbit(a, i) (((u8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) -#define clrbit(a, i) (((u8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) -#define isset(a, i) (((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) -#define isclr(a, i) ((((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) -#endif /* setbit */ - -#define NBITS(type) (sizeof(type) * 8) -#define NBITVAL(nbits) (1 << (nbits)) -#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) -#define NBITMASK(nbits) MAXBITVAL(nbits) -#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) - -/* basic mux operation - can be optimized on several architectures */ -#define MUX(pred, true, false) ((pred) ? (true) : (false)) - -/* modulo inc/dec - assumes x E [0, bound - 1] */ -#define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1) -#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) - -/* modulo inc/dec, bound = 2^k */ -#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) -#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) - -/* modulo add/sub - assumes x, y E [0, bound - 1] */ -#define MODADD(x, y, bound) \ - MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y)) -#define MODSUB(x, y, bound) \ - MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y)) - -/* module add/sub, bound = 2^k */ -#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) -#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) - -/* crc defines */ -#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */ -#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */ /* brcmu_format_flags() bit description structure */ struct brcmu_bit_desc { @@ -256,9 +256,6 @@ struct brcmu_tlv { u8 data[1]; }; -/* 18-bytes of Ethernet address buffer length */ -#define ETHER_ADDR_STR_LEN 18 - /* externs */ /* format/print */ #if defined(BCMDBG) From 3a099fadb348119809496495d07734267419ba26 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:48 +0200 Subject: [PATCH 0975/1519] staging: brcm80211: cleaned up brcmu_wifi.h macro's Substituted/removed macro's. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_common.c | 2 +- drivers/staging/brcm80211/brcmsmac/channel.c | 20 +++--- drivers/staging/brcm80211/brcmsmac/main.c | 22 +++--- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 10 +-- drivers/staging/brcm80211/brcmsmac/pub.h | 4 -- drivers/staging/brcm80211/brcmutil/wifi.c | 4 +- .../staging/brcm80211/include/brcmu_wifi.h | 69 +++++++++++-------- 7 files changed, 70 insertions(+), 61 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index cb7393c64ba..1a5f7305ed6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -261,7 +261,7 @@ bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, /* Evict if needed */ if (eprec >= 0) { /* Detect queueing to unconfigured precedence */ - discard_oldest = AC_BITMAP_TST(drvr->wme_dp, eprec); + discard_oldest = ac_bitmap_tst(drvr->wme_dp, eprec); if (eprec == prec && !discard_oldest) return false; /* refuse newer (incoming) packet */ /* Evict packet according to discard policy */ diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 27c62c7d5cd..af01c9d5ec3 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1141,9 +1141,9 @@ brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) return (wlc_cm->wlc->pub->_n_enab & SUPPORT_11N) && CHSPEC_IS40(chspec) ? (isset(wlc_cm->quiet_channels.vec, - LOWER_20_SB(CHSPEC_CHANNEL(chspec))) || + lower_20_sb(CHSPEC_CHANNEL(chspec))) || isset(wlc_cm->quiet_channels.vec, - UPPER_20_SB(CHSPEC_CHANNEL(chspec)))) : + upper_20_sb(CHSPEC_CHANNEL(chspec)))) : isset(wlc_cm->quiet_channels.vec, CHSPEC_CHANNEL(chspec)); } @@ -1310,7 +1310,7 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, } chan = CHSPEC_CHANNEL(chanspec); - band = wlc->bandstate[CHSPEC_BANDUNIT(chanspec)]; + band = wlc->bandstate[chspec_bandunit(chanspec)]; li = (band->bandtype == BRCM_BAND_5G) ? brcms_c_get_locale_5g(country->locale_5G) : brcms_c_get_locale_2g(country->locale_2G); @@ -1516,7 +1516,7 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, } if (CHANNEL_BANDUNIT(wlc_cm->wlc, channel) != - CHSPEC_BANDUNIT(chspec)) + chspec_bandunit(chspec)) return false; /* Check a 20Mhz channel */ @@ -1538,26 +1538,26 @@ brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, u8 num_ch20_entries = sizeof(chan20_info) / sizeof(struct chan20_info); - if (!VALID_40CHANSPEC_IN_BAND(wlc, CHSPEC_BANDUNIT(chspec))) + if (!VALID_40CHANSPEC_IN_BAND(wlc, chspec_bandunit(chspec))) return false; if (dualband) { if (!brcms_c_valid_channel20_db(wlc->cmi, - LOWER_20_SB(channel)) || + lower_20_sb(channel)) || !brcms_c_valid_channel20_db(wlc->cmi, - UPPER_20_SB(channel))) + upper_20_sb(channel))) return false; } else { if (!brcms_c_valid_channel20(wlc->cmi, - LOWER_20_SB(channel)) || + lower_20_sb(channel)) || !brcms_c_valid_channel20(wlc->cmi, - UPPER_20_SB(channel))) + upper_20_sb(channel))) return false; } /* find the lower sideband info in the sideband array */ for (idx = 0; idx < num_ch20_entries; idx++) { - if (chan20_info[idx].sb == LOWER_20_SB(channel)) + if (chan20_info[idx].sb == lower_20_sb(channel)) upper_sideband = chan20_info[idx].adj_sbs; } /* check that the lower sideband allows an upper sideband */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 51ad7f003b1..d755c185a5d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1058,7 +1058,7 @@ static void brcms_b_info_init(struct brcms_hardware *wlc_hw) /* default mac retry limits */ wlc_hw->SRL = RETRY_SHORT_DEF; wlc_hw->LRL = RETRY_LONG_DEF; - wlc_hw->chanspec = CH20MHZ_CHSPEC(1); + wlc_hw->chanspec = ch20mhz_chspec(1); } static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) @@ -3266,7 +3266,7 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, macintmask = brcms_intrsoff(wlc->wl); /* set up the specified band and chanspec */ - brcms_c_setxband(wlc_hw, CHSPEC_BANDUNIT(chanspec)); + brcms_c_setxband(wlc_hw, chspec_bandunit(chanspec)); wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); /* do one-time phy inits and calibration */ @@ -3366,7 +3366,7 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, band_order[0] = band_order[1] = parkband; } else { /* park on the band of the specified chanspec */ - parkband = CHSPEC_BANDUNIT(chanspec); + parkband = chspec_bandunit(chanspec); /* order so that parkband initialize last */ band_order[0] = parkband ^ 1; @@ -3815,7 +3815,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, /* Switch bands if necessary */ if (wlc_hw->_nbands > 1) { - bandunit = CHSPEC_BANDUNIT(chanspec); + bandunit = chspec_bandunit(chanspec); if (wlc_hw->band->bandunit != bandunit) { /* brcms_b_setband disables other bandunit, * use light band switch if not up yet @@ -3885,7 +3885,7 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) /* Switch bands if necessary */ if (wlc->pub->_nbands > 1) { - bandunit = CHSPEC_BANDUNIT(chanspec); + bandunit = chspec_bandunit(chanspec); if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { switchband = true; if (wlc->bandlocked) { @@ -4428,7 +4428,7 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->device_present = true; /* Save our copy of the chanspec */ - wlc->chanspec = CH20MHZ_CHSPEC(1); + wlc->chanspec = ch20mhz_chspec(1); /* various 802.11g modes */ wlc->shortslot = false; @@ -4974,13 +4974,13 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) /* fill the default channel as the first valid channel * starting from the 2G channels */ - chanspec = CH20MHZ_CHSPEC(1); + chanspec = ch20mhz_chspec(1); wlc->home_chanspec = bi->chanspec = chanspec; /* find the band of our default channel */ band = wlc->band; if (wlc->pub->_nbands > 1 && - band->bandunit != CHSPEC_BANDUNIT(chanspec)) + band->bandunit != chspec_bandunit(chanspec)) band = wlc->bandstate[OTHERBANDUNIT(wlc)]; /* init bss rates to the band specific default rate set */ @@ -6222,7 +6222,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, switch (cmd) { case BRCM_SET_CHANNEL:{ - u16 chspec = CH20MHZ_CHSPEC(val); + u16 chspec = ch20mhz_chspec(val); if (val < 0 || val > MAXCHANNEL) { bcmerror = -EINVAL; @@ -6236,7 +6236,7 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, if (!wlc->pub->up && IS_MBAND_UNLOCKED(wlc)) { if (wlc->band->bandunit != - CHSPEC_BANDUNIT(chspec)) + chspec_bandunit(chspec)) wlc->bandinit_pending = true; else wlc->bandinit_pending = false; @@ -6787,7 +6787,7 @@ brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, if (eprec >= 0) { bool discard_oldest; - discard_oldest = AC_BITMAP_TST(wlc->wme_dp, eprec); + discard_oldest = ac_bitmap_tst(wlc->wme_dp, eprec); /* Refuse newer packet unless configured to discard oldest */ if (eprec == prec && !discard_oldest) { diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 119a1270beb..eb171f0269c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -596,7 +596,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, pi->bw = WL_CHANSPEC_BW_20; pi->radio_chanspec = (bandtype == BRCM_BAND_2G) ? - CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36); + ch20mhz_chspec(1) : ch20mhz_chspec(36); pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; pi->rxiq_antsel = ANT_RX_DIV_DEF; @@ -1375,7 +1375,7 @@ u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) if (j == ARRAY_SIZE(chan_info_all)) continue; - channel = UPPER_20_SB(channel); + channel = upper_20_sb(channel); chspec = channel | WL_CHANSPEC_BW_40 | WL_CHANSPEC_CTL_SB_LOWER; if (band == BRCM_BAND_2G) @@ -1383,7 +1383,7 @@ u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) else chspec |= WL_CHANSPEC_BAND_5G; } else - chspec = CH20MHZ_CHSPEC(channel); + chspec = ch20mhz_chspec(channel); if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) && (channel <= LAST_REF5_CHANNUM)) @@ -1650,9 +1650,9 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) target_chan = CHSPEC_CHANNEL(chspec); else if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) - target_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec)); + target_chan = upper_20_sb(CHSPEC_CHANNEL(chspec)); else - target_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec)); + target_chan = lower_20_sb(CHSPEC_CHANNEL(chspec)); pactrl = 0; if (ISLCNPHY(pi)) { diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 381ddb4cf2e..20582f10059 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -389,10 +389,6 @@ extern const u8 wlc_prio2prec_map[]; #define MAXBANDS 2 /* Maximum #of bands */ -/* bandstate array indices */ -#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ -#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ - /* max number of antenna configurations */ #define ANT_SELCFG_MAX 4 diff --git a/drivers/staging/brcm80211/brcmutil/wifi.c b/drivers/staging/brcm80211/brcmutil/wifi.c index 636515cc192..509e25c9c86 100644 --- a/drivers/staging/brcm80211/brcmutil/wifi.c +++ b/drivers/staging/brcm80211/brcmutil/wifi.c @@ -65,13 +65,13 @@ u8 brcmu_chspec_ctlchan(u16 chspec) * control chan is the upper 20 MHZ SB of the * 40MHZ channel */ - ctl_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec)); + ctl_chan = upper_20_sb(CHSPEC_CHANNEL(chspec)); else /* * control chan is the lower 20 MHZ SB of the * 40MHZ channel */ - ctl_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec)); + ctl_chan = lower_20_sb(CHSPEC_CHANNEL(chspec)); } return ctl_chan; diff --git a/drivers/staging/brcm80211/include/brcmu_wifi.h b/drivers/staging/brcm80211/include/brcmu_wifi.h index 0ab432d91d2..e98ed50c67c 100644 --- a/drivers/staging/brcm80211/include/brcmu_wifi.h +++ b/drivers/staging/brcm80211/include/brcmu_wifi.h @@ -35,6 +35,10 @@ #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */ #define BRCM_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */ +/* bandstate array indices */ +#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ +#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ + /* * max # supported channels. The max channel no is 216, this is that + 1 * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are @@ -68,31 +72,6 @@ #define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */ #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */ -/* channel defines */ -#define LOWER_20_SB(channel) \ - (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0) - -#define UPPER_20_SB(channel) \ - (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \ - ((channel) + CH_10MHZ_APART) : 0) - -#define CHSPEC_BANDUNIT(chspec) \ - (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX) - -#define CH20MHZ_CHSPEC(channel) \ - (u16)((u16)(channel) | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE | \ - (((channel) <= CH_MAX_2G_CHANNEL) ? \ - WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) - -#define NEXT_20MHZ_CHAN(channel) \ - (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ - ((channel) + CH_20MHZ_APART) : 0) - -#define CH40MHZ_CHSPEC(channel, ctlsb) \ - (u16)((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ - ((channel) <= CH_MAX_2G_CHANNEL ? \ - WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) - #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK)) #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) @@ -127,13 +106,44 @@ #define CHSPEC_CTL_CHAN(chspec) \ ((CHSPEC_SB_LOWER(chspec)) ? \ - (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ - (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK)))) + (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ + (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK)))) #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G) #define CHANSPEC_STR_LEN 8 +static inline int lower_20_sb(int channel) +{ + return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0; +} + +static inline int upper_20_sb(int channel) +{ + return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ? + channel + CH_10MHZ_APART : 0; +} + +static inline int chspec_bandunit(u16 chspec) +{ + return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX; +} + +static inline u16 ch20mhz_chspec(int channel) +{ + u16 rc = channel <= CH_MAX_2G_CHANNEL ? + WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G; + + return (u16)((u16)channel | WL_CHANSPEC_BW_20 | + WL_CHANSPEC_CTL_SB_NONE | rc); +} + +static inline int next_20mhz_chan(int channel) +{ + return channel < (MAXCHANNEL - CH_20MHZ_APART) ? + channel + CH_20MHZ_APART : 0; +} + /* defined rate in 500kbps */ #define BRCM_MAXRATE 108 /* in 500kbps units */ #define BRCM_RATE_1M 2 /* in 500kbps units */ @@ -153,7 +163,10 @@ #define MCSSET_LEN 16 -#define AC_BITMAP_TST(ab, ac) (((ab) & (1 << (ac))) != 0) +static inline bool ac_bitmap_tst(u8 bitmap, int prec) +{ + return (bitmap & (1 << (prec))) != 0; +} /* * Verify the chanspec is using a legal set of parameters, i.e. that the From 6514e853f647fc2579380eb3255f7540410e7e26 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:49 +0200 Subject: [PATCH 0976/1519] staging: brcm80211: cleaned up fullmac macro's Substituted/moved/removed macro's. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 6 - drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 18 +-- .../staging/brcm80211/brcmfmac/dhd_common.c | 4 + drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 104 +++++++----------- .../staging/brcm80211/brcmfmac/sdio_host.h | 3 - .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 103 ++++++++++------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 38 +++++-- 7 files changed, 149 insertions(+), 127 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 4d06d874e17..a1262a6341d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -83,10 +83,6 @@ #define WLC_PHY_TYPE_LCN 8 #define WLC_PHY_TYPE_NULL 0xf -#define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter, u) -#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \ - offsetof(struct brcmf_pkt_filter_pattern, mask_and_pattern) - #define BRCMF_EVENTING_MASK_LEN 16 #define TOE_TX_CSUM_OL 0x00000001 @@ -478,8 +474,6 @@ struct brcmf_assoc_params { /* list of chanspecs */ u16 chanspec_list[1]; }; -#define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ - (sizeof(struct brcmf_assoc_params) - sizeof(u16)) /* used for join with or without a specific bssid and channel list */ struct brcmf_join_params { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 1ac8057c39e..eacbe3133c7 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -338,11 +338,15 @@ done: return ret; } -#define PKTSUMNEEDED(skb) \ - (((struct sk_buff *)(skb))->ip_summed == CHECKSUM_PARTIAL) -#define PKTSETSUMGOOD(skb, x) \ - (((struct sk_buff *)(skb))->ip_summed = \ - ((x) ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE)) +static bool pkt_sum_needed(struct sk_buff *skb) +{ + return skb->ip_summed == CHECKSUM_PARTIAL; +} + +static void pkt_set_sum_good(struct sk_buff *skb, bool x) +{ + skb->ip_summed = (x ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE); +} void brcmf_proto_dump(struct brcmf_pub *drvr, struct brcmu_strbuf *strbuf) { @@ -363,7 +367,7 @@ void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx, h = (struct brcmf_proto_bdc_header *)(pktbuf->data); h->flags = (BDC_PROTO_VER << BDC_FLAG_VER_SHIFT); - if (PKTSUMNEEDED(pktbuf)) + if (pkt_sum_needed(pktbuf)) h->flags |= BDC_FLAG_SUM_NEEDED; h->priority = (pktbuf->priority & BDC_PRIORITY_MASK); @@ -405,7 +409,7 @@ int brcmf_proto_hdrpull(struct brcmf_pub *drvr, int *ifidx, if (h->flags & BDC_FLAG_SUM_GOOD) { brcmf_dbg(INFO, "%s: BDC packet received with good rx-csum, flags 0x%x\n", brcmf_ifname(drvr, *ifidx), h->flags); - PKTSETSUMGOOD(pktbuf, true); + pkt_set_sum_good(pktbuf, true); } pktbuf->priority = h->priority & BDC_PRIORITY_MASK; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 1a5f7305ed6..ba7a982f4c6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -35,6 +35,10 @@ int brcmf_msg_level; #define MSGTRACE_VERSION 1 +#define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter, u) +#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \ + offsetof(struct brcmf_pkt_filter_pattern, mask_and_pattern) + #ifdef BCMDBG static const char brcmf_version[] = "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 8e4e0d00183..aadc5bb7762 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -322,29 +322,6 @@ struct rte_console { #define SDPCM_GLOMDESC(p) (((u8 *)p)[1] & 0x80) -/* For TEST_CHANNEL packets, define another 4-byte header */ -#define SDPCM_TEST_HDRLEN 4 /* - * Generally: Cmd(1), Ext(1), Len(2); - * Semantics of Ext byte depend on - * command. Len is current or requested - * frame length, not including test - * header; sent little-endian. - */ -#define SDPCM_TEST_DISCARD 0x01 /* Receiver discards. Ext:pattern id. */ -#define SDPCM_TEST_ECHOREQ 0x02 /* Echo request. Ext:pattern id. */ -#define SDPCM_TEST_ECHORSP 0x03 /* Echo response. Ext:pattern id. */ -#define SDPCM_TEST_BURST 0x04 /* - * Receiver to send a burst. - * Ext is a frame count - */ -#define SDPCM_TEST_SEND 0x05 /* - * Receiver sets send mode. - * Ext is boolean on/off - */ - -/* Handy macro for filling in datagen packets with a pattern */ -#define SDPCM_TEST_FILL(byteno, id) ((u8)(id + byteno)) - /* * Shared structure between dongle and the host. * The structure contains pointers to trap or assert information. @@ -355,7 +332,6 @@ struct rte_console { #define SDPCM_SHARED_ASSERT 0x0200 #define SDPCM_SHARED_TRAP 0x0400 - /* Space for header read, limit for data packets */ #define MAX_HDR_READ (1 << 6) #define MAX_RX_DATASZ 2048 @@ -425,9 +401,11 @@ struct rte_console { /* * Conversion of 802.1D priority to precedence level */ -#define PRIO2PREC(prio) \ - (((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? \ - ((prio^2)) : (prio)) +static uint prio2prec(u32 prio) +{ + return (prio == PRIO_8021D_NONE || prio == PRIO_8021D_BE) ? + (prio^2) : prio; +} /* * Core reg address translation. @@ -809,15 +787,15 @@ static bool forcealign; #define ALIGNMENT 4 -#define PKTALIGN(_p, _len, _align) \ - do { \ - uint datalign; \ - datalign = (unsigned long)((_p)->data); \ - datalign = roundup(datalign, (_align)) - datalign; \ - if (datalign) \ - skb_pull((_p), datalign); \ - __skb_trim((_p), (_len)); \ - } while (0) +static void pkt_align(struct sk_buff *p, int len, int align) +{ + uint datalign; + datalign = (unsigned long)(p->data); + datalign = roundup(datalign, (align)) - datalign; + if (datalign) + skb_pull(p, datalign); + __skb_trim(p, len); +} /* Limit on rounding up frames */ static const uint max_roundup = 512; @@ -826,9 +804,11 @@ static const uint max_roundup = 512; static bool brcmf_readahead; /* To check if there's window offered */ -#define DATAOK(bus) \ - (((u8)(bus->tx_max - bus->tx_seq) != 0) && \ - (((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0)) +static bool data_ok(struct brcmf_bus *bus) +{ + return (u8)(bus->tx_max - bus->tx_seq) != 0 && + ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0; +} /* * Reads a register in the SDIO hardware block. This block occupies a series of @@ -1232,11 +1212,11 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) return 0; } -#define BUS_WAKE(bus) \ - do { \ - if ((bus)->sleeping) \ - brcmf_sdbrcm_bussleep((bus), false); \ - } while (0); +static void bus_wake(struct brcmf_bus *bus) +{ + if (bus->sleeping) + brcmf_sdbrcm_bussleep(bus, false); +} /* Writes a HW/SW header into the packet and sends it. */ /* Assumes: (a) header space already there, (b) caller holds lock */ @@ -1275,7 +1255,7 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, goto done; } - PKTALIGN(new, pkt->len, BRCMF_SDALIGN); + pkt_align(new, pkt->len, BRCMF_SDALIGN); memcpy(new->data, pkt->data, pkt->len); if (free_pkt) brcmu_pkt_buf_free_skb(pkt); @@ -1401,12 +1381,12 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) skb_push(pkt, SDPCM_HDRLEN); /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ - prec = PRIO2PREC((pkt->priority & PRIOMASK)); + prec = prio2prec((pkt->priority & PRIOMASK)); /* Check for existing queue, current flow-control, pending event, or pending clock */ if (brcmf_deferred_tx || bus->fcstate || pktq_len(&bus->txq) - || bus->dpc_sched || (!DATAOK(bus)) + || bus->dpc_sched || (!data_ok(bus)) || (bus->flowcontrol & NBITVAL(prec)) || (bus->clkstate != CLK_AVAIL)) { brcmf_dbg(TRACE, "deferring pktq len %d\n", @@ -1444,7 +1424,7 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) brcmf_sdbrcm_sdlock(bus); /* Otherwise, send it now */ - BUS_WAKE(bus); + bus_wake(bus); /* Make sure back plane ht clk is on, no pending allowed */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); @@ -1484,7 +1464,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) tx_prec_map = ~bus->flowcontrol; /* Send frames until the limit or some other event */ - for (cnt = 0; (cnt < maxframes) && DATAOK(bus); cnt++) { + for (cnt = 0; (cnt < maxframes) && data_ok(bus); cnt++) { spin_lock_bh(&bus->txqlock); pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); if (pkt == NULL) { @@ -1573,7 +1553,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) /* Need to lock here to protect txseq and SDIO tx calls */ brcmf_sdbrcm_sdlock(bus); - BUS_WAKE(bus); + bus_wake(bus); /* Make sure backplane clock is on */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -1591,7 +1571,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); - if (!DATAOK(bus)) { + if (!data_ok(bus)) { brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", bus->tx_max, bus->tx_seq); bus->ctrl_frame_stat = true; @@ -2364,7 +2344,7 @@ static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, /* Request clock to allow SDIO accesses */ if (!bus->drvr->dongle_reset) { - BUS_WAKE(bus); + bus_wake(bus); brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); } @@ -2899,7 +2879,7 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, if (vi == NULL) { brcmf_sdbrcm_sdlock(bus); - BUS_WAKE(bus); + bus_wake(bus); /* Turn on clock in case SD command needs backplane */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -2956,7 +2936,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) if (enforce_mutex) brcmf_sdbrcm_sdlock(bus); - BUS_WAKE(bus); + bus_wake(bus); /* Enable clock for device interrupts */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -3358,7 +3338,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } /* Adhere to start alignment requirements */ - PKTALIGN(pnext, sublen, BRCMF_SDALIGN); + pkt_align(pnext, sublen, BRCMF_SDALIGN); } /* If all allocations succeeded, save packet chain @@ -3748,7 +3728,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) len, rdlen, rxseq); continue; } else { - PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); + pkt_align(pkt, rdlen, BRCMF_SDALIGN); rxbuf = (u8 *) (pkt->data); /* Read the entire frame */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, @@ -4052,7 +4032,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Leave room for what we already read, and align remainder */ skb_pull(pkt, firstread); - PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); + pkt_align(pkt, rdlen, BRCMF_SDALIGN); /* Read the remaining frame data */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, @@ -4287,7 +4267,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) } } - BUS_WAKE(bus); + bus_wake(bus); /* Make sure backplane clock is on */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); @@ -4377,7 +4357,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) bus->intstatus = intstatus; clkwait: - if (DATAOK(bus) && bus->ctrl_frame_stat && + if (data_ok(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) { int ret, i; @@ -4425,7 +4405,7 @@ clkwait: /* Send queued frames (limit 1 if rx may still be pending) */ else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit - && DATAOK(bus)) { + && data_ok(bus)) { framecnt = rxdone ? txlimit : min(txlimit, brcmf_txminmax); framecnt = brcmf_sdbrcm_sendfromq(bus, framecnt); txlimit -= framecnt; @@ -4446,7 +4426,7 @@ clkwait: resched = true; } else if (bus->intstatus || bus->ipend || (!bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) - && DATAOK(bus)) || PKT_AVAILABLE()) { + && data_ok(bus)) || PKT_AVAILABLE()) { resched = true; } @@ -4605,7 +4585,7 @@ static int brcmf_sdbrcm_bus_console_in(struct brcmf_pub *drvr, } /* Request clock to allow SDIO accesses */ - BUS_WAKE(bus); + bus_wake(bus); /* No pend allowed since txpkt is called later, ht clk has to be on */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 67368b93297..ddb6656dad0 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -202,9 +202,6 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, /* Async request (vs. sync request) */ #define SDIO_REQ_ASYNC 0x4 -/* Pending (non-error) return code */ -#define BCME_PENDING 1 - /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only). * rw: read or write (0/1) * addr: direct SDIO address diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index c8e47ff9117..dd56baac049 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -34,6 +34,9 @@ #include "dhd.h" #include "wl_cfg80211.h" +#define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ + (sizeof(struct brcmf_assoc_params) - sizeof(u16)) + static struct sdio_func *cfg80211_sdio_func; static struct brcmf_cfg80211_dev *cfg80211_dev; static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; @@ -309,25 +312,22 @@ static int brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv); static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv); -#define WL_PRIV_GET() \ - ({ \ - struct brcmf_cfg80211_iface *ci = brcmf_get_drvdata(cfg80211_dev); \ - if (unlikely(!ci)) { \ - WL_ERR("wl_cfg80211_dev is unavailable\n"); \ - BUG(); \ - } \ - ci->cfg_priv; \ -}) +static struct brcmf_cfg80211_priv *brcmf_priv_get(void) +{ + struct brcmf_cfg80211_iface *ci = brcmf_get_drvdata(cfg80211_dev); + return ci->cfg_priv; +} -#define CHECK_SYS_UP() \ -do { \ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); \ - if (unlikely(!test_bit(WL_STATUS_READY, &cfg_priv->status))) { \ - WL_INFO("device is not ready : status (%d)\n", \ - (int)cfg_priv->status); \ - return -EIO; \ - } \ -} while (0) +static bool check_sys_up(struct wiphy *wiphy) +{ + struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); + if (!test_bit(WL_STATUS_READY, &cfg_priv->status)) { + WL_INFO("device is not ready : status (%d)\n", + (int)cfg_priv->status); + return false; + } + return true; +} #define CHAN2G(_channel, _freq, _flags) { \ .band = IEEE80211_BAND_2GHZ, \ @@ -560,7 +560,8 @@ brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; switch (type) { case NL80211_IFTYPE_MONITOR: @@ -815,7 +816,8 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; err = __brcmf_cfg80211_scan(wiphy, ndev, request, NULL); if (unlikely(err)) @@ -910,7 +912,8 @@ static s32 brcmf_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; if (changed & WIPHY_PARAM_RTS_THRESHOLD && (cfg_priv->conf->rts_threshold != wiphy->rts_threshold)) { @@ -958,7 +961,8 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, s32 bcnprd; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; if (params->ssid) WL_CONN("SSID: %s\n", params->ssid); @@ -1099,7 +1103,8 @@ brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; brcmf_link_down(cfg_priv); @@ -1372,7 +1377,8 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; if (unlikely(!sme->ssid)) { WL_ERR("Invalid ssid\n"); @@ -1459,7 +1465,8 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, s32 err = 0; WL_TRACE("Enter. Reason code = %d\n", reason_code); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; clear_bit(WL_STATUS_CONNECTED, &cfg_priv->status); @@ -1489,7 +1496,8 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, s32 disable = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; switch (type) { case NL80211_TX_POWER_AUTOMATIC: @@ -1541,7 +1549,8 @@ static s32 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm) s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; err = brcmf_dev_intvar_get(ndev, "qtxpower", &txpwrdbm); if (unlikely(err)) { @@ -1567,7 +1576,8 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, WL_TRACE("Enter\n"); WL_CONN("key index (%d)\n", key_idx); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; err = brcmf_dev_ioctl(dev, BRCMF_C_GET_WSEC, &wsec, sizeof(wsec)); if (unlikely(err)) { @@ -1690,7 +1700,8 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, WL_TRACE("Enter\n"); WL_CONN("key index (%d)\n", key_idx); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; if (mac_addr) { WL_TRACE("Exit"); @@ -1781,7 +1792,9 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, s32 wsec; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; + memset(&key, 0, sizeof(key)); key.index = (u32) key_idx; @@ -1850,7 +1863,8 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, WL_TRACE("Enter\n"); WL_CONN("key index (%d)\n", key_idx); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; memset(&key, 0, sizeof(key)); key.index = key_idx; @@ -1904,7 +1918,6 @@ brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, { WL_INFO("Not supported\n"); - CHECK_SYS_UP(); return -EOPNOTSUPP; } @@ -1920,7 +1933,8 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, u8 *bssid = brcmf_read_prof(cfg_priv, WL_PROF_BSSID); WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; if (unlikely (memcmp(mac, bssid, ETH_ALEN))) { @@ -2017,7 +2031,8 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; /* addr param is always NULL. ignore it */ /* Get current rateset */ @@ -2171,7 +2186,8 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, int i; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; for (i = 0; i < pmkids->npmkid; i++) if (!memcmp(pmksa->bssid, pmkids->pmkid[i].BSSID, ETH_ALEN)) @@ -2205,7 +2221,9 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, int i; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; + memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN); memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); @@ -2250,7 +2268,8 @@ brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) s32 err = 0; WL_TRACE("Enter\n"); - CHECK_SYS_UP(); + if (!check_sys_up(wiphy)) + return -EIO; memset(cfg_priv->pmk_list, 0, sizeof(*cfg_priv->pmk_list)); err = brcmf_update_pmklist(dev, cfg_priv->pmk_list, err); @@ -2358,7 +2377,7 @@ wiphy_new_out: static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv) { - struct wireless_dev *wdev = cfg_to_wdev(cfg_priv); + struct wireless_dev *wdev = cfg_priv->wdev; if (unlikely(!wdev)) { WL_ERR("wdev is invalid\n"); @@ -2367,7 +2386,7 @@ static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv) wiphy_unregister(wdev->wiphy); wiphy_free(wdev->wiphy); kfree(wdev); - cfg_to_wdev(cfg_priv) = NULL; + cfg_priv->wdev = NULL; } static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) @@ -3460,7 +3479,7 @@ void brcmf_cfg80211_detach(void) { struct brcmf_cfg80211_priv *cfg_priv; - cfg_priv = WL_PRIV_GET(); + cfg_priv = brcmf_priv_get(); wl_deinit_priv(cfg_priv); brcmf_free_wdev(cfg_priv); @@ -3937,7 +3956,7 @@ s32 brcmf_cfg80211_up(void) struct brcmf_cfg80211_priv *cfg_priv; s32 err = 0; - cfg_priv = WL_PRIV_GET(); + cfg_priv = brcmf_priv_get(); mutex_lock(&cfg_priv->usr_sync); err = __brcmf_cfg80211_up(cfg_priv); mutex_unlock(&cfg_priv->usr_sync); @@ -3950,7 +3969,7 @@ s32 brcmf_cfg80211_down(void) struct brcmf_cfg80211_priv *cfg_priv; s32 err = 0; - cfg_priv = WL_PRIV_GET(); + cfg_priv = brcmf_priv_get(); mutex_lock(&cfg_priv->usr_sync); err = __brcmf_cfg80211_down(cfg_priv); mutex_unlock(&cfg_priv->usr_sync); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 98cd47da86b..cfbf50deb74 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -319,15 +319,39 @@ struct brcmf_cfg80211_priv { u8 ci[0] __aligned(NETDEV_ALIGN); }; -#define cfg_to_wiphy(w) (w->wdev->wiphy) -#define wiphy_to_cfg(w) ((struct brcmf_cfg80211_priv *)(wiphy_priv(w))) -#define cfg_to_wdev(w) (w->wdev) -#define wdev_to_cfg(w) ((struct brcmf_cfg80211_priv *)(wdev_priv(w))) -#define cfg_to_ndev(w) (w->wdev->netdev) -#define ndev_to_cfg(n) (wdev_to_cfg(n->ieee80211_ptr)) +static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_priv *w) +{ + return w->wdev->wiphy; +} + +static inline struct brcmf_cfg80211_priv *wiphy_to_cfg(struct wiphy *w) +{ + return (struct brcmf_cfg80211_priv *)(wiphy_priv(w)); +} + +static inline struct brcmf_cfg80211_priv *wdev_to_cfg(struct wireless_dev *wd) +{ + return (struct brcmf_cfg80211_priv *)(wdev_priv(wd)); +} + +static inline struct net_device *cfg_to_ndev(struct brcmf_cfg80211_priv *cfg) +{ + return cfg->wdev->netdev; +} + +static inline struct brcmf_cfg80211_priv *ndev_to_cfg(struct net_device *ndev) +{ + return wdev_to_cfg(ndev->ieee80211_ptr); +} + #define iscan_to_cfg(i) ((struct brcmf_cfg80211_priv *)(i->data)) #define cfg_to_iscan(w) (w->iscan) -#define cfg_to_conn(w) (&w->conn_info) + +static inline struct +brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg) +{ + return &cfg->conn_info; +} static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, struct brcmf_bss_info *bss) From b78f721be11ab2e7e0d0247ad045c2a16edb09d3 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:50 +0200 Subject: [PATCH 0977/1519] staging: brcm80211: removed fullmac BRCMF_IOCTL_MAGIC support Linux will never call brcmf_netdev_ioctl_entry() with the value BRCMF_IOCTL_MAGIC in a user space buffer. Thus, unused code could be removed. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 33 - .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 33 - drivers/staging/brcm80211/brcmfmac/dhd.h | 1 - drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 12 - drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 5 - .../staging/brcm80211/brcmfmac/dhd_common.c | 291 ------- .../staging/brcm80211/brcmfmac/dhd_linux.c | 9 - .../staging/brcm80211/brcmfmac/dhd_proto.h | 7 - drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 742 ------------------ .../staging/brcm80211/brcmfmac/sdio_host.h | 14 - 10 files changed, 1147 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 2490dde1c2b..4e8fe4dc24c 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -235,39 +235,6 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, fnc_num, addr, data); } -int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, u8 * cis, - uint length) -{ - int status; - - u8 *tmp_buf, *tmp_ptr; - u8 *ptr; - bool ascii = func & ~0xf; - func &= 0x7; - - status = brcmf_sdioh_cis_read(sdiodev, func, cis, length); - - if (ascii) { - /* Move binary bits to tmp and format them - into the provided buffer. */ - tmp_buf = kmalloc(length, GFP_ATOMIC); - if (tmp_buf == NULL) { - brcmf_dbg(ERROR, "out of memory\n"); - return -ENOMEM; - } - memcpy(tmp_buf, cis, length); - for (tmp_ptr = tmp_buf, ptr = cis; ptr < (cis + length - 4); - tmp_ptr++) { - ptr += sprintf((char *)ptr, "%.2x ", *tmp_ptr & 0xff); - if ((((tmp_ptr - tmp_buf) + 1) & 0xf) == 0) - ptr += sprintf((char *)ptr, "\n"); - } - kfree(tmp_buf); - } - - return status; -} - int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) { diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 6adf5c0e1a8..b38e698a074 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -423,39 +423,6 @@ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) return scratch; } -int brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, - u8 *cisd, u32 length) -{ - u32 count; - int offset; - u32 foo; - u8 *cis = cisd; - - brcmf_dbg(TRACE, "Func = %d\n", func); - - if (!sdiodev->func_cis_ptr[func]) { - memset(cis, 0, length); - brcmf_dbg(ERROR, "no func_cis_ptr[%d]\n", func); - return -ENOTSUPP; - } - - brcmf_dbg(ERROR, "func_cis_ptr[%d]=0x%04x\n", - func, sdiodev->func_cis_ptr[func]); - - for (count = 0; count < length; count++) { - offset = sdiodev->func_cis_ptr[func] + count; - if (brcmf_sdioh_card_regread(sdiodev, 0, offset, 1, &foo) < 0) { - brcmf_dbg(ERROR, "regread failed: Can't read CIS\n"); - return -EIO; - } - - *cis = (u8) (foo & 0xff); - cis++; - } - - return 0; -} - static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) { int err_ret; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index a1262a6341d..add29c32aff 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -789,7 +789,6 @@ struct brcmf_c_ioctl { #define BRCMF_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */ /* common ioctl definitions */ -#define BRCMF_GET_MAGIC 0 #define BRCMF_GET_VERSION 1 #define BRCMF_GET_VAR 2 #define BRCMF_SET_VAR 3 diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 24f578ab406..3361e015108 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -56,18 +56,6 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); extern int brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); -/* Check for and handle local prot-specific iovar commands */ -extern int brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, - void *params, int plen, void *arg, int len, - bool set); - -/* Add bus dump output to a buffer */ -extern void brcmf_sdbrcm_bus_dump(struct brcmf_pub *drvr, - struct brcmu_strbuf *strbuf); - -/* Clear any bus counters */ -extern void brcmf_bus_clearcounts(struct brcmf_pub *drvr); - extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); #endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index eacbe3133c7..f8731c8b9e6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -348,11 +348,6 @@ static void pkt_set_sum_good(struct sk_buff *skb, bool x) skb->ip_summed = (x ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE); } -void brcmf_proto_dump(struct brcmf_pub *drvr, struct brcmu_strbuf *strbuf) -{ - brcmu_bprintf(strbuf, "Protocol CDC: reqid %d\n", drvr->prot->reqid); -} - void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index ba7a982f4c6..fd39998526a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -48,41 +48,6 @@ static const char brcmf_version[] = "Dongle Host Driver, version " BRCMF_VERSION_STR; #endif -/* IOVar table */ -enum { - IOV_VERSION = 1, - IOV_MSGLEVEL, - IOV_BCMERRORSTR, - IOV_BCMERROR, - IOV_DUMP, - IOV_CLEARCOUNTS, - IOV_LOGDUMP, - IOV_LOGCAL, - IOV_LOGSTAMP, - IOV_GPIOOB, - IOV_LAST -}; - -static const struct brcmu_iovar brcmf_iovars[] = { - {"version", IOV_VERSION, 0, IOVT_BUFFER, sizeof(brcmf_version)} - , -#ifdef BCMDBG - {"msglevel", IOV_MSGLEVEL, 0, IOVT_UINT32, 0} - , -#endif /* BCMDBG */ - {"bcmerrorstr", IOV_BCMERRORSTR, 0, IOVT_BUFFER, BCME_STRLEN} - , - {"bcmerror", IOV_BCMERROR, 0, IOVT_INT8, 0} - , - {"dump", IOV_DUMP, 0, IOVT_BUFFER, BRCMF_IOCTL_MAXLEN} - , - {"clearcounts", IOV_CLEARCOUNTS, 0, IOVT_VOID, 0} - , - {"gpioob", IOV_GPIOOB, 0, IOVT_UINT32, 0} - , - {NULL, 0, 0, 0, 0} -}; - /* Message trace header */ struct msgtrace_hdr { u8 version; @@ -112,132 +77,6 @@ void brcmf_c_init(void) brcmf_msg_level = BRCMF_ERROR_VAL; } -static int brcmf_c_dump(struct brcmf_pub *drvr, char *buf, int buflen) -{ - struct brcmu_strbuf b; - struct brcmu_strbuf *strbuf = &b; - - brcmu_binit(strbuf, buf, buflen); - - /* Base info */ - brcmu_bprintf(strbuf, "%s\n", brcmf_version); - brcmu_bprintf(strbuf, "\n"); - brcmu_bprintf(strbuf, "pub.up %d pub.txoff %d pub.busstate %d\n", - drvr->up, drvr->txoff, drvr->busstate); - brcmu_bprintf(strbuf, "pub.hdrlen %d pub.maxctl %d pub.rxsz %d\n", - drvr->hdrlen, drvr->maxctl, drvr->rxsz); - brcmu_bprintf(strbuf, "pub.iswl %d pub.drv_version %ld pub.mac %pM\n", - drvr->iswl, drvr->drv_version, &drvr->mac); - brcmu_bprintf(strbuf, "pub.bcmerror %d tickcnt %d\n", drvr->bcmerror, - drvr->tickcnt); - - brcmu_bprintf(strbuf, "dongle stats:\n"); - brcmu_bprintf(strbuf, - "tx_packets %ld tx_bytes %ld tx_errors %ld tx_dropped %ld\n", - drvr->dstats.tx_packets, drvr->dstats.tx_bytes, - drvr->dstats.tx_errors, drvr->dstats.tx_dropped); - brcmu_bprintf(strbuf, - "rx_packets %ld rx_bytes %ld rx_errors %ld rx_dropped %ld\n", - drvr->dstats.rx_packets, drvr->dstats.rx_bytes, - drvr->dstats.rx_errors, drvr->dstats.rx_dropped); - brcmu_bprintf(strbuf, "multicast %ld\n", drvr->dstats.multicast); - - brcmu_bprintf(strbuf, "bus stats:\n"); - brcmu_bprintf(strbuf, "tx_packets %ld tx_multicast %ld tx_errors %ld\n", - drvr->tx_packets, drvr->tx_multicast, drvr->tx_errors); - brcmu_bprintf(strbuf, "tx_ctlpkts %ld tx_ctlerrs %ld\n", - drvr->tx_ctlpkts, drvr->tx_ctlerrs); - brcmu_bprintf(strbuf, "rx_packets %ld rx_multicast %ld rx_errors %ld\n", - drvr->rx_packets, drvr->rx_multicast, drvr->rx_errors); - brcmu_bprintf(strbuf, - "rx_ctlpkts %ld rx_ctlerrs %ld rx_dropped %ld rx_flushed %ld\n", - drvr->rx_ctlpkts, drvr->rx_ctlerrs, drvr->rx_dropped, - drvr->rx_flushed); - brcmu_bprintf(strbuf, - "rx_readahead_cnt %ld tx_realloc %ld fc_packets %ld\n", - drvr->rx_readahead_cnt, drvr->tx_realloc, drvr->fc_packets); - brcmu_bprintf(strbuf, "wd_dpc_sched %ld\n", drvr->wd_dpc_sched); - brcmu_bprintf(strbuf, "\n"); - - /* Add any prot info */ - brcmf_proto_dump(drvr, strbuf); - brcmu_bprintf(strbuf, "\n"); - - /* Add any bus info */ - brcmf_sdbrcm_bus_dump(drvr, strbuf); - - return !strbuf->size ? -EOVERFLOW : 0; -} - -static int -brcmf_c_doiovar(struct brcmf_pub *drvr, const struct brcmu_iovar *vi, - u32 actionid, const char *name, void *params, int plen, - void *arg, int len, int val_size) -{ - int bcmerror = 0; - s32 int_val = 0; - - brcmf_dbg(TRACE, "Enter\n"); - - bcmerror = brcmu_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid)); - if (bcmerror != 0) - goto exit; - - if (plen >= (int)sizeof(int_val)) - memcpy(&int_val, params, sizeof(int_val)); - - switch (actionid) { - case IOV_GVAL(IOV_VERSION): - /* Need to have checked buffer length */ - strncpy((char *)arg, brcmf_version, len); - break; - - case IOV_GVAL(IOV_MSGLEVEL): - int_val = (s32) brcmf_msg_level; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_MSGLEVEL): - brcmf_msg_level = int_val; - break; - - case IOV_GVAL(IOV_BCMERRORSTR): - strncpy((char *)arg, "bcm_error", - BCME_STRLEN); - ((char *)arg)[BCME_STRLEN - 1] = 0x00; - break; - - case IOV_GVAL(IOV_BCMERROR): - int_val = (s32) drvr->bcmerror; - memcpy(arg, &int_val, val_size); - break; - - case IOV_GVAL(IOV_DUMP): - bcmerror = brcmf_c_dump(drvr, arg, len); - break; - - case IOV_SVAL(IOV_CLEARCOUNTS): - drvr->tx_packets = drvr->rx_packets = 0; - drvr->tx_errors = drvr->rx_errors = 0; - drvr->tx_ctlpkts = drvr->rx_ctlpkts = 0; - drvr->tx_ctlerrs = drvr->rx_ctlerrs = 0; - drvr->rx_dropped = 0; - drvr->rx_readahead_cnt = 0; - drvr->tx_realloc = 0; - drvr->wd_dpc_sched = 0; - memset(&drvr->dstats, 0, sizeof(drvr->dstats)); - brcmf_bus_clearcounts(drvr); - break; - - default: - bcmerror = -ENOTSUPP; - break; - } - -exit: - return bcmerror; -} - bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, struct sk_buff *pkt, int prec) { @@ -286,136 +125,6 @@ bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, return p != NULL; } -static int -brcmf_c_iovar_op(struct brcmf_pub *drvr, const char *name, - void *params, int plen, void *arg, int len, bool set) -{ - int bcmerror = 0; - int val_size; - const struct brcmu_iovar *vi = NULL; - u32 actionid; - - brcmf_dbg(TRACE, "Enter\n"); - - if (name == NULL || len < 0) - return -EINVAL; - - /* Set does not take qualifiers */ - if (set && (params || plen)) - return -EINVAL; - - /* Get must have return space;*/ - if (!set && !(arg && len)) - return -EINVAL; - - vi = brcmu_iovar_lookup(brcmf_iovars, name); - if (vi == NULL) { - bcmerror = -ENOTSUPP; - goto exit; - } - - brcmf_dbg(CTL, "%s %s, len %d plen %d\n", - name, set ? "set" : "get", len, plen); - - /* set up 'params' pointer in case this is a set command so that - * the convenience int and bool code can be common to set and get - */ - if (params == NULL) { - params = arg; - plen = len; - } - - if (vi->type == IOVT_VOID) - val_size = 0; - else if (vi->type == IOVT_BUFFER) - val_size = len; - else - /* all other types are integer sized */ - val_size = sizeof(int); - - actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); - bcmerror = - brcmf_c_doiovar(drvr, vi, actionid, name, params, plen, arg, len, - val_size); - -exit: - return bcmerror; -} - -int brcmf_c_ioctl(struct brcmf_pub *drvr, struct brcmf_c_ioctl *ioc, void *buf, - uint buflen) -{ - int bcmerror = 0; - - brcmf_dbg(TRACE, "Enter\n"); - - if (!buf) - return -EINVAL; - - switch (ioc->cmd) { - case BRCMF_GET_MAGIC: - if (buflen < sizeof(int)) - bcmerror = -EOVERFLOW; - else - *(int *)buf = BRCMF_IOCTL_MAGIC; - break; - - case BRCMF_GET_VERSION: - if (buflen < sizeof(int)) - bcmerror = -EOVERFLOW; - else - *(int *)buf = BRCMF_IOCTL_VERSION; - break; - - case BRCMF_GET_VAR: - case BRCMF_SET_VAR:{ - char *arg; - uint arglen; - - /* scan past the name to any arguments */ - for (arg = buf, arglen = buflen; *arg && arglen; - arg++, arglen--) - ; - - if (*arg) { - bcmerror = -EOVERFLOW; - break; - } - - /* account for the NUL terminator */ - arg++, arglen--; - - /* call with the appropriate arguments */ - if (ioc->cmd == BRCMF_GET_VAR) - bcmerror = brcmf_c_iovar_op(drvr, buf, arg, - arglen, buf, buflen, IOV_GET); - else - bcmerror = - brcmf_c_iovar_op(drvr, buf, NULL, 0, arg, - arglen, IOV_SET); - if (bcmerror != -ENOTSUPP) - break; - - /* if still not found, try bus module */ - if (ioc->cmd == BRCMF_GET_VAR) - bcmerror = brcmf_sdbrcm_bus_iovar_op(drvr, - buf, arg, arglen, buf, buflen, - IOV_GET); - else - bcmerror = brcmf_sdbrcm_bus_iovar_op(drvr, - buf, NULL, 0, arg, arglen, - IOV_SET); - - break; - } - - default: - bcmerror = -ENOTSUPP; - } - - return bcmerror; -} - #ifdef BCMDBG static void brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index bb0f71866a6..539a24db428 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -1012,15 +1012,6 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, goto done; } - /* check for local brcmf ioctl and handle it */ - if (driver == BRCMF_IOCTL_MAGIC) { - bcmerror = brcmf_c_ioctl((void *)&drvr_priv->pub, &ioc, - buf, buflen); - if (bcmerror) - drvr_priv->pub.bcmerror = bcmerror; - goto done; - } - /* send to dongle (must be up, and wl) */ if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { brcmf_dbg(ERROR, "DONGLE_DOWN\n"); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h index 2ce5feabbef..6686f4c8350 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h @@ -52,16 +52,9 @@ extern int brcmf_proto_hdrpull(struct brcmf_pub *, int *ifidx, extern int brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, void *buf, int len); -/* Add prot dump output to a buffer */ -extern void brcmf_proto_dump(struct brcmf_pub *drvr, - struct brcmu_strbuf *strbuf); - /* Update local copy of dongle statistics */ extern void brcmf_proto_dstats(struct brcmf_pub *drvr); -extern int brcmf_c_ioctl(struct brcmf_pub *drvr, struct brcmf_c_ioctl *ioc, - void *buf, uint buflen); - extern int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr); extern int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index aadc5bb7762..34351249d3e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -855,8 +855,6 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) #define HOSTINTMASK (I_HMB_SW_MASK | I_CHIPACTIVE) #ifdef BCMDBG -static int brcmf_sdbrcm_bus_console_in(struct brcmf_pub *drvr, - unsigned char *msg, uint msglen); static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size); static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus); #endif /* BCMDBG */ @@ -1712,196 +1710,6 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) return rxlen ? (int)rxlen : -ETIMEDOUT; } -/* IOVar table */ -enum { - IOV_INTR = 1, - IOV_POLLRATE, - IOV_SDREG, - IOV_SBREG, - IOV_SDCIS, - IOV_MEMBYTES, - IOV_MEMSIZE, -#ifdef BCMDBG - IOV_CHECKDIED, - IOV_CONS, - IOV_DCONSOLE_POLL, -#endif - IOV_DOWNLOAD, - IOV_FORCEEVEN, - IOV_SDIOD_DRIVE, - IOV_READAHEAD, - IOV_SDRXCHAIN, - IOV_ALIGNCTL, - IOV_SDALIGN, - IOV_DEVRESET, - IOV_TXBOUND, - IOV_RXBOUND, - IOV_TXMINMAX, - IOV_IDLETIME, - IOV_IDLECLOCK, - IOV_SLEEP, - IOV_WDTICK, - IOV_IOCTLTIMEOUT, - IOV_VARS -}; - -static const struct brcmu_iovar brcmf_sdio_iovars[] = { - {"intr", IOV_INTR, 0, IOVT_BOOL, 0}, - {"sleep", IOV_SLEEP, 0, IOVT_BOOL, 0}, - {"pollrate", IOV_POLLRATE, 0, IOVT_UINT32, 0}, - {"idletime", IOV_IDLETIME, 0, IOVT_INT32, 0}, - {"idleclock", IOV_IDLECLOCK, 0, IOVT_INT32, 0}, - {"membytes", IOV_MEMBYTES, 0, IOVT_BUFFER, 2 * sizeof(int)}, - {"memsize", IOV_MEMSIZE, 0, IOVT_UINT32, 0}, - {"download", IOV_DOWNLOAD, 0, IOVT_BOOL, 0}, - {"vars", IOV_VARS, 0, IOVT_BUFFER, 0}, - {"sdiod_drive", IOV_SDIOD_DRIVE, 0, IOVT_UINT32, 0}, - {"readahead", IOV_READAHEAD, 0, IOVT_BOOL, 0}, - {"sdrxchain", IOV_SDRXCHAIN, 0, IOVT_BOOL, 0}, - {"alignctl", IOV_ALIGNCTL, 0, IOVT_BOOL, 0}, - {"sdalign", IOV_SDALIGN, 0, IOVT_BOOL, 0}, - {"devreset", IOV_DEVRESET, 0, IOVT_BOOL, 0}, - {"wdtick", IOV_WDTICK, 0, IOVT_UINT32, 0}, - {"ioctl_timeout", IOV_IOCTLTIMEOUT, 0, IOVT_UINT32, 0}, -#ifdef BCMDBG - {"cons", IOV_CONS, 0, IOVT_BUFFER, 0} - , - {"dconpoll", IOV_DCONSOLE_POLL, 0, IOVT_UINT32, 0} - , - {"sdreg", IOV_SDREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} - , - {"sbreg", IOV_SBREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} - , - {"sd_cis", IOV_SDCIS, 0, IOVT_BUFFER, BRCMF_IOCTL_MAXLEN} - , - {"forcealign", IOV_FORCEEVEN, 0, IOVT_BOOL, 0} - , - {"txbound", IOV_TXBOUND, 0, IOVT_UINT32, 0} - , - {"rxbound", IOV_RXBOUND, 0, IOVT_UINT32, 0} - , - {"txminmax", IOV_TXMINMAX, 0, IOVT_UINT32, 0} - , - {"checkdied", IOV_CHECKDIED, 0, IOVT_BUFFER, 0} - , -#endif /* BCMDBG */ - - {NULL, 0, 0, 0, 0} -}; - -static void -brcmf_dump_pct(struct brcmu_strbuf *strbuf, char *desc, uint num, uint div) -{ - uint q1, q2; - - if (!div) { - brcmu_bprintf(strbuf, "%s N/A", desc); - } else { - q1 = num / div; - q2 = (100 * (num - (q1 * div))) / div; - brcmu_bprintf(strbuf, "%s %d.%02d", desc, q1, q2); - } -} - -void brcmf_sdbrcm_bus_dump(struct brcmf_pub *drvr, struct brcmu_strbuf *strbuf) -{ - struct brcmf_bus *bus = drvr->bus; - - brcmu_bprintf(strbuf, "Bus SDIO structure:\n"); - brcmu_bprintf(strbuf, - "hostintmask 0x%08x intstatus 0x%08x sdpcm_ver %d\n", - bus->hostintmask, bus->intstatus, bus->sdpcm_ver); - brcmu_bprintf(strbuf, - "fcstate %d qlen %d tx_seq %d, max %d, rxskip %d rxlen %d rx_seq %d\n", - bus->fcstate, pktq_len(&bus->txq), bus->tx_seq, bus->tx_max, - bus->rxskip, bus->rxlen, bus->rx_seq); - brcmu_bprintf(strbuf, "intr %d intrcount %d lastintrs %d spurious %d\n", - bus->intr, bus->intrcount, bus->lastintrs, bus->spurious); - brcmu_bprintf(strbuf, "pollrate %d pollcnt %d regfails %d\n", - bus->pollrate, bus->pollcnt, bus->regfails); - - brcmu_bprintf(strbuf, "\nAdditional counters:\n"); - brcmu_bprintf(strbuf, - "tx_sderrs %d fcqueued %d rxrtx %d rx_toolong %d rxc_errors %d\n", - bus->tx_sderrs, bus->fcqueued, bus->rxrtx, bus->rx_toolong, - bus->rxc_errors); - brcmu_bprintf(strbuf, "rx_hdrfail %d badhdr %d badseq %d\n", - bus->rx_hdrfail, bus->rx_badhdr, bus->rx_badseq); - brcmu_bprintf(strbuf, "fc_rcvd %d, fc_xoff %d, fc_xon %d\n", - bus->fc_rcvd, bus->fc_xoff, bus->fc_xon); - brcmu_bprintf(strbuf, "rxglomfail %d, rxglomframes %d, rxglompkts %d\n", - bus->rxglomfail, bus->rxglomframes, bus->rxglompkts); - brcmu_bprintf(strbuf, "f2rx (hdrs/data) %d (%d/%d), f2tx %d f1regs" - " %d\n", - (bus->f2rxhdrs + bus->f2rxdata), bus->f2rxhdrs, - bus->f2rxdata, bus->f2txdata, bus->f1regdata); - { - brcmf_dump_pct(strbuf, "\nRx: pkts/f2rd", bus->drvr->rx_packets, - (bus->f2rxhdrs + bus->f2rxdata)); - brcmf_dump_pct(strbuf, ", pkts/f1sd", bus->drvr->rx_packets, - bus->f1regdata); - brcmf_dump_pct(strbuf, ", pkts/sd", bus->drvr->rx_packets, - (bus->f2rxhdrs + bus->f2rxdata + bus->f1regdata)); - brcmf_dump_pct(strbuf, ", pkts/int", bus->drvr->rx_packets, - bus->intrcount); - brcmu_bprintf(strbuf, "\n"); - - brcmf_dump_pct(strbuf, "Rx: glom pct", (100 * bus->rxglompkts), - bus->drvr->rx_packets); - brcmf_dump_pct(strbuf, ", pkts/glom", bus->rxglompkts, - bus->rxglomframes); - brcmu_bprintf(strbuf, "\n"); - - brcmf_dump_pct(strbuf, "Tx: pkts/f2wr", bus->drvr->tx_packets, - bus->f2txdata); - brcmf_dump_pct(strbuf, ", pkts/f1sd", bus->drvr->tx_packets, - bus->f1regdata); - brcmf_dump_pct(strbuf, ", pkts/sd", bus->drvr->tx_packets, - (bus->f2txdata + bus->f1regdata)); - brcmf_dump_pct(strbuf, ", pkts/int", bus->drvr->tx_packets, - bus->intrcount); - brcmu_bprintf(strbuf, "\n"); - - brcmf_dump_pct(strbuf, "Total: pkts/f2rw", - (bus->drvr->tx_packets + bus->drvr->rx_packets), - (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata)); - brcmf_dump_pct(strbuf, ", pkts/f1sd", - (bus->drvr->tx_packets + bus->drvr->rx_packets), - bus->f1regdata); - brcmf_dump_pct(strbuf, ", pkts/sd", - (bus->drvr->tx_packets + bus->drvr->rx_packets), - (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata + - bus->f1regdata)); - brcmf_dump_pct(strbuf, ", pkts/int", - (bus->drvr->tx_packets + bus->drvr->rx_packets), - bus->intrcount); - brcmu_bprintf(strbuf, "\n\n"); - } - -#ifdef BCMDBG - brcmu_bprintf(strbuf, "dpc_sched %d host interrupt%spending\n", - bus->dpc_sched, " not "); - brcmu_bprintf(strbuf, "blocksize %d roundup %d\n", bus->blocksize, - bus->roundup); -#endif /* BCMDBG */ - brcmu_bprintf(strbuf, - "clkstate %d activity %d idletime %d idlecount %d sleeping %d\n", - bus->clkstate, bus->activity, bus->idletime, bus->idlecount, - bus->sleeping); -} - -void brcmf_bus_clearcounts(struct brcmf_pub *drvr) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) drvr->bus; - - bus->intrcount = bus->lastintrs = bus->spurious = bus->regfails = 0; - bus->rxrtx = bus->rx_toolong = bus->rxc_errors = 0; - bus->rx_hdrfail = bus->rx_badhdr = bus->rx_badseq = 0; - bus->tx_sderrs = bus->fc_rcvd = bus->fc_xoff = bus->fc_xon = 0; - bus->rxglomfail = bus->rxglomframes = bus->rxglompkts = 0; - bus->f2rxhdrs = bus->f2rxdata = bus->f2txdata = bus->f1regdata = 0; -} - static int brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, uint size) @@ -2300,417 +2108,6 @@ err: return bcmerror; } -static int brcmf_sdbrcm_doiovar(struct brcmf_bus *bus, - const struct brcmu_iovar *vi, u32 actionid, - const char *name, void *params, int plen, - void *arg, int len, int val_size) -{ - int bcmerror = 0; - s32 int_val = 0; - bool bool_val = 0; - - brcmf_dbg(TRACE, "Enter, action %d name %s params %p plen %d arg %p len %d val_size %d\n", - actionid, name, params, plen, arg, len, val_size); - - bcmerror = brcmu_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid)); - if (bcmerror != 0) - goto exit; - - if (plen >= (int)sizeof(int_val)) - memcpy(&int_val, params, sizeof(int_val)); - - bool_val = (int_val != 0) ? true : false; - - /* Some ioctls use the bus */ - brcmf_sdbrcm_sdlock(bus); - - /* Check if dongle is in reset. If so, only allow DEVRESET iovars */ - if (bus->drvr->dongle_reset && !(actionid == IOV_SVAL(IOV_DEVRESET) || - actionid == IOV_GVAL(IOV_DEVRESET))) { - bcmerror = -EPERM; - goto exit; - } - - /* Handle sleep stuff before any clock mucking */ - if (vi->varid == IOV_SLEEP) { - if (IOV_ISSET(actionid)) { - bcmerror = brcmf_sdbrcm_bussleep(bus, bool_val); - } else { - int_val = (s32) bus->sleeping; - memcpy(arg, &int_val, val_size); - } - goto exit; - } - - /* Request clock to allow SDIO accesses */ - if (!bus->drvr->dongle_reset) { - bus_wake(bus); - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - } - - switch (actionid) { - case IOV_GVAL(IOV_INTR): - int_val = (s32) bus->intr; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_INTR): - bus->intr = bool_val; - break; - - case IOV_GVAL(IOV_POLLRATE): - int_val = (s32) bus->pollrate; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_POLLRATE): - bus->pollrate = (uint) int_val; - bus->poll = (bus->pollrate != 0); - break; - - case IOV_GVAL(IOV_IDLETIME): - int_val = bus->idletime; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_IDLETIME): - if ((int_val < 0) && (int_val != BRCMF_IDLE_IMMEDIATE)) - bcmerror = -EINVAL; - else - bus->idletime = int_val; - break; - - case IOV_GVAL(IOV_IDLECLOCK): - int_val = (s32) bus->idleclock; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_IDLECLOCK): - bus->idleclock = int_val; - break; - - case IOV_SVAL(IOV_MEMBYTES): - case IOV_GVAL(IOV_MEMBYTES): - { - u32 address; - uint size, dsize; - u8 *data; - - bool set = (actionid == IOV_SVAL(IOV_MEMBYTES)); - - address = (u32) int_val; - memcpy(&int_val, (char *)params + sizeof(int_val), - sizeof(int_val)); - size = (uint) int_val; - - /* Do some validation */ - dsize = set ? plen - (2 * sizeof(int)) : len; - if (dsize < size) { - brcmf_dbg(ERROR, "error on %s membytes, addr 0x%08x size %d dsize %d\n", - set ? "set" : "get", - address, size, dsize); - bcmerror = -EINVAL; - break; - } - - brcmf_dbg(INFO, "Request to %s %d bytes at address 0x%08x\n", - set ? "write" : "read", size, address); - - /* If we know about SOCRAM, check for a fit */ - if ((bus->orig_ramsize) && - ((address > bus->orig_ramsize) - || (address + size > bus->orig_ramsize))) { - brcmf_dbg(ERROR, "ramsize 0x%08x doesn't have %d bytes at 0x%08x\n", - bus->orig_ramsize, size, address); - bcmerror = -EINVAL; - break; - } - - /* Generate the actual data pointer */ - data = - set ? (u8 *) params + - 2 * sizeof(int) : (u8 *) arg; - - /* Call to do the transfer */ - bcmerror = brcmf_sdbrcm_membytes(bus, set, address, - data, size); - - break; - } - - case IOV_GVAL(IOV_MEMSIZE): - int_val = (s32) bus->ramsize; - memcpy(arg, &int_val, val_size); - break; - - case IOV_GVAL(IOV_SDIOD_DRIVE): - int_val = (s32) brcmf_sdiod_drive_strength; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_SDIOD_DRIVE): - brcmf_sdiod_drive_strength = int_val; - brcmf_sdbrcm_sdiod_drive_strength_init(bus, - brcmf_sdiod_drive_strength); - break; - - case IOV_SVAL(IOV_DOWNLOAD): - bcmerror = brcmf_sdbrcm_download_state(bus, bool_val); - break; - - case IOV_SVAL(IOV_VARS): - bcmerror = brcmf_sdbrcm_downloadvars(bus, arg, len); - break; - - case IOV_GVAL(IOV_READAHEAD): - int_val = (s32) brcmf_readahead; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_READAHEAD): - if (bool_val && !brcmf_readahead) - bus->nextlen = 0; - brcmf_readahead = bool_val; - break; - - case IOV_GVAL(IOV_SDRXCHAIN): - int_val = (s32) bus->use_rxchain; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_SDRXCHAIN): - if (bool_val && !bus->sd_rxchain) - bcmerror = -ENOTSUPP; - else - bus->use_rxchain = bool_val; - break; - case IOV_GVAL(IOV_ALIGNCTL): - int_val = (s32) brcmf_alignctl; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_ALIGNCTL): - brcmf_alignctl = bool_val; - break; - - case IOV_GVAL(IOV_SDALIGN): - int_val = BRCMF_SDALIGN; - memcpy(arg, &int_val, val_size); - break; - -#ifdef BCMDBG - case IOV_GVAL(IOV_VARS): - if (bus->varsz < (uint) len) - memcpy(arg, bus->vars, bus->varsz); - else - bcmerror = -EOVERFLOW; - break; -#endif /* BCMDBG */ - -#ifdef BCMDBG - case IOV_GVAL(IOV_DCONSOLE_POLL): - int_val = (s32) brcmf_console_ms; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_DCONSOLE_POLL): - brcmf_console_ms = (uint) int_val; - break; - - case IOV_SVAL(IOV_CONS): - if (len > 0) - bcmerror = brcmf_sdbrcm_bus_console_in(bus->drvr, - arg, len - 1); - break; - - case IOV_GVAL(IOV_SDREG): - { - struct brcmf_sdreg *sd_ptr; - u32 addr, size; - - sd_ptr = (struct brcmf_sdreg *) params; - - addr = bus->ci->buscorebase + sd_ptr->offset; - size = sd_ptr->func; - int_val = (s32) brcmf_sdcard_reg_read(bus->sdiodev, - addr, size); - if (brcmf_sdcard_regfail(bus->sdiodev)) - bcmerror = -EIO; - memcpy(arg, &int_val, sizeof(s32)); - break; - } - - case IOV_SVAL(IOV_SDREG): - { - struct brcmf_sdreg *sd_ptr; - u32 addr, size; - - sd_ptr = (struct brcmf_sdreg *) params; - - addr = bus->ci->buscorebase + sd_ptr->offset; - size = sd_ptr->func; - brcmf_sdcard_reg_write(bus->sdiodev, addr, size, - sd_ptr->value); - if (brcmf_sdcard_regfail(bus->sdiodev)) - bcmerror = -EIO; - break; - } - - /* Same as above, but offset is not backplane - (not SDIO core) */ - case IOV_GVAL(IOV_SBREG): - { - struct brcmf_sdreg sdreg; - u32 addr, size; - - memcpy(&sdreg, params, sizeof(sdreg)); - - addr = SI_ENUM_BASE + sdreg.offset; - size = sdreg.func; - int_val = (s32) brcmf_sdcard_reg_read(bus->sdiodev, - addr, size); - if (brcmf_sdcard_regfail(bus->sdiodev)) - bcmerror = -EIO; - memcpy(arg, &int_val, sizeof(s32)); - break; - } - - case IOV_SVAL(IOV_SBREG): - { - struct brcmf_sdreg sdreg; - u32 addr, size; - - memcpy(&sdreg, params, sizeof(sdreg)); - - addr = SI_ENUM_BASE + sdreg.offset; - size = sdreg.func; - brcmf_sdcard_reg_write(bus->sdiodev, addr, size, - sdreg.value); - if (brcmf_sdcard_regfail(bus->sdiodev)) - bcmerror = -EIO; - break; - } - - case IOV_GVAL(IOV_SDCIS): - { - *(char *)arg = 0; - - strcat(arg, "\nFunc 0\n"); - brcmf_sdcard_cis_read(bus->sdiodev, 0x10, - (u8 *) arg + strlen(arg), - SBSDIO_CIS_SIZE_LIMIT); - strcat(arg, "\nFunc 1\n"); - brcmf_sdcard_cis_read(bus->sdiodev, 0x11, - (u8 *) arg + strlen(arg), - SBSDIO_CIS_SIZE_LIMIT); - strcat(arg, "\nFunc 2\n"); - brcmf_sdcard_cis_read(bus->sdiodev, 0x12, - (u8 *) arg + strlen(arg), - SBSDIO_CIS_SIZE_LIMIT); - break; - } - - case IOV_GVAL(IOV_FORCEEVEN): - int_val = (s32) forcealign; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_FORCEEVEN): - forcealign = bool_val; - break; - - case IOV_GVAL(IOV_TXBOUND): - int_val = (s32) brcmf_txbound; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_TXBOUND): - brcmf_txbound = (uint) int_val; - break; - - case IOV_GVAL(IOV_RXBOUND): - int_val = (s32) brcmf_rxbound; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_RXBOUND): - brcmf_rxbound = (uint) int_val; - break; - - case IOV_GVAL(IOV_TXMINMAX): - int_val = (s32) brcmf_txminmax; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_TXMINMAX): - brcmf_txminmax = (uint) int_val; - break; -#endif /* BCMDBG */ - - case IOV_SVAL(IOV_DEVRESET): - brcmf_dbg(TRACE, "Called set IOV_DEVRESET=%d dongle_reset=%d busstate=%d\n", - bool_val, bus->drvr->dongle_reset, - bus->drvr->busstate); - - brcmf_bus_devreset(bus->drvr, (u8) bool_val); - - break; - - case IOV_GVAL(IOV_DEVRESET): - brcmf_dbg(TRACE, "Called get IOV_DEVRESET\n"); - - /* Get its status */ - int_val = (bool) bus->drvr->dongle_reset; - memcpy(arg, &int_val, val_size); - - break; - - case IOV_GVAL(IOV_WDTICK): - int_val = (s32) brcmf_watchdog_ms; - memcpy(arg, &int_val, val_size); - break; - - case IOV_SVAL(IOV_WDTICK): - if (!bus->drvr->up) { - bcmerror = -ENOLINK; - break; - } - brcmf_sdbrcm_wd_timer(bus, (uint) int_val); - break; - - case IOV_GVAL(IOV_IOCTLTIMEOUT):{ - int_val = brcmf_ioctl_timeout_msec; - memcpy(arg, &int_val, sizeof(int_val)); - break; - } - - case IOV_SVAL(IOV_IOCTLTIMEOUT):{ - if (int_val <= 0) - bcmerror = -EINVAL; - else - brcmf_ioctl_timeout_msec = int_val; - break; - } - - default: - bcmerror = -ENOTSUPP; - break; - } - -exit: - if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); - - if (actionid == IOV_SVAL(IOV_DEVRESET) && bool_val == false) - brcmf_c_preinit_ioctls(bus->drvr); - - return bcmerror; -} - static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) { int bcmerror = 0; @@ -2851,79 +2248,6 @@ fail: return bcmerror; } -int -brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *drvr, const char *name, - void *params, int plen, void *arg, int len, bool set) -{ - struct brcmf_bus *bus = drvr->bus; - const struct brcmu_iovar *vi = NULL; - int bcmerror = 0; - int val_size; - u32 actionid; - - brcmf_dbg(TRACE, "Enter\n"); - - if (name == NULL || len < 0) - return -EINVAL; - - /* Set does not take qualifiers */ - if (set && (params || plen)) - return -EINVAL; - - /* Get must have return space;*/ - if (!set && !(arg && len)) - return -EINVAL; - - /* Look up var locally; if not found pass to host driver */ - vi = brcmu_iovar_lookup(brcmf_sdio_iovars, name); - if (vi == NULL) { - brcmf_sdbrcm_sdlock(bus); - - bus_wake(bus); - - /* Turn on clock in case SD command needs backplane */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - bcmerror = brcmf_sdcard_iovar_op(bus->sdiodev, name, params, - plen, arg, len, set); - - if (bus->idletime == BRCMF_IDLE_IMMEDIATE && - !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); - goto exit; - } - - brcmf_dbg(CTL, "%s %s, len %d plen %d\n", - name, set ? "set" : "get", len, plen); - - /* set up 'params' pointer in case this is a set command so that - * the convenience int and bool code can be common to set and get - */ - if (params == NULL) { - params = arg; - plen = len; - } - - if (vi->type == IOVT_VOID) - val_size = 0; - else if (vi->type == IOVT_BUFFER) - val_size = len; - else - /* all other types are integer sized */ - val_size = sizeof(int); - - actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); - bcmerror = brcmf_sdbrcm_doiovar(bus, vi, actionid, name, params, plen, - arg, len, val_size); - -exit: - return bcmerror; -} - void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) { u32 local_hostintmask; @@ -4562,72 +3886,6 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) return bus->ipend; } -#ifdef BCMDBG -static int brcmf_sdbrcm_bus_console_in(struct brcmf_pub *drvr, - unsigned char *msg, uint msglen) -{ - struct brcmf_bus *bus = drvr->bus; - u32 addr, val; - int rv; - struct sk_buff *pkt; - - /* Address could be zero if CONSOLE := 0 in dongle Makefile */ - if (bus->console_addr == 0) - return -ENOTSUPP; - - /* Exclusive bus access */ - brcmf_sdbrcm_sdlock(bus); - - /* Don't allow input if dongle is in reset */ - if (bus->drvr->dongle_reset) { - brcmf_sdbrcm_sdunlock(bus); - return -EPERM; - } - - /* Request clock to allow SDIO accesses */ - bus_wake(bus); - /* No pend allowed since txpkt is called later, ht clk has to be on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Zero cbuf_index */ - addr = bus->console_addr + offsetof(struct rte_console, cbuf_idx); - val = cpu_to_le32(0); - rv = brcmf_sdbrcm_membytes(bus, true, addr, (u8 *)&val, sizeof(val)); - if (rv < 0) - goto done; - - /* Write message into cbuf */ - addr = bus->console_addr + offsetof(struct rte_console, cbuf); - rv = brcmf_sdbrcm_membytes(bus, true, addr, (u8 *)msg, msglen); - if (rv < 0) - goto done; - - /* Write length into vcons_in */ - addr = bus->console_addr + offsetof(struct rte_console, vcons_in); - val = cpu_to_le32(msglen); - rv = brcmf_sdbrcm_membytes(bus, true, addr, (u8 *)&val, sizeof(val)); - if (rv < 0) - goto done; - - /* Bump dongle by sending an empty event pkt. - * sdpcm_sendup (RX) checks for virtual console input. - */ - pkt = brcmu_pkt_buf_get_skb(4 + SDPCM_RESERVE); - if ((pkt != NULL) && bus->clkstate == CLK_AVAIL) - brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_EVENT_CHANNEL, true); - -done: - if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); - - return rv; -} -#endif /* BCMDBG */ - static bool brcmf_sdbrcm_chipmatch(u16 chipid) { if (chipid == BCM4329_CHIP_ID) diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index ddb6656dad0..aa177ed8727 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -149,16 +149,6 @@ extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func, extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func, u32 addr, u8 data, int *err); -/* Read CIS content for specified function. - * fn: function whose CIS is being requested (0 is common CIS) - * cis: pointer to memory location to place results - * length: number of bytes to read - * Internally, this routine uses the values from the cis base regs (0x9-0xB) - * to form an SDIO-space address to read the data from. - */ -extern int brcmf_sdcard_cis_read(struct brcmf_sdio_dev *sdiodev, uint func, - u8 *cis, uint length); - /* Synchronous access to device (client) core registers via CMD53 to F1. * addr: backplane address (i.e. >= regsva from attach) * size: register width in bytes (2 or 4) @@ -255,10 +245,6 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, u32 addr, uint regwidth, u32 buflen, u8 *buffer, struct sk_buff *pkt); -/* get cis data */ -extern int brcmf_sdioh_cis_read(struct brcmf_sdio_dev *sdiodev, uint fuc, - u8 *cis, u32 length); - /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable); From e99cab09d0ecf91f780075f371a8bc48465d25af Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:51 +0200 Subject: [PATCH 0978/1519] staging: brcm80211: removed fullmac function brcmf_sdcard_iovar_op() brcmf_sdcard_iovar_op was only called with iovar "sd_rxchain", and always returns 'false' as the queried value. Thus, the entire function, related iovar tables and related functions could be removed. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 115 ------------------ drivers/staging/brcm80211/brcmfmac/dhd.h | 6 - drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 14 +-- .../staging/brcm80211/brcmfmac/sdio_host.h | 5 - drivers/staging/brcm80211/brcmsmac/types.h | 10 +- drivers/staging/brcm80211/brcmutil/utils.c | 67 ---------- .../staging/brcm80211/include/brcmu_utils.h | 45 ------- 7 files changed, 12 insertions(+), 250 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 4e8fe4dc24c..26919f1d1f1 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -41,121 +41,6 @@ module_param(sd_f2_blocksize, int, 0); -/* IOVar table */ -enum { - IOV_MSGLEVEL = 1, - IOV_DEVREG, - IOV_HCIREGS, - IOV_RXCHAIN -}; - -static const struct brcmu_iovar sdioh_iovars[] = { - {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} - , - {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} - , - {NULL, 0, 0, 0, 0} -}; - -int -brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, - void *params, int plen, void *arg, int len, bool set) -{ - const struct brcmu_iovar *vi = NULL; - int bcmerror = 0; - int val_size; - s32 int_val = 0; - bool bool_val; - u32 actionid; - - if (name == NULL || len < 0) - return -EINVAL; - - /* Set does not take qualifiers */ - if (set && (params || plen)) - return -EINVAL; - - /* Get must have return space;*/ - if (!set && !(arg && len)) - return -EINVAL; - - brcmf_dbg(TRACE, "Enter (%s %s)\n", set ? "set" : "get", name); - - vi = brcmu_iovar_lookup(sdioh_iovars, name); - if (vi == NULL) { - bcmerror = -ENOTSUPP; - goto exit; - } - - bcmerror = brcmu_iovar_lencheck(vi, arg, len, set); - if (bcmerror != 0) - goto exit; - - /* Set up params so get and set can share the convenience variables */ - if (params == NULL) { - params = arg; - plen = len; - } - - if (vi->type == IOVT_VOID) - val_size = 0; - else if (vi->type == IOVT_BUFFER) - val_size = len; - else - val_size = sizeof(int); - - if (plen >= (int)sizeof(int_val)) - memcpy(&int_val, params, sizeof(int_val)); - - bool_val = (int_val != 0) ? true : false; - - actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); - switch (actionid) { - case IOV_GVAL(IOV_RXCHAIN): - int_val = false; - memcpy(arg, &int_val, val_size); - break; - - case IOV_GVAL(IOV_DEVREG): - { - struct brcmf_sdreg *sd_ptr = - (struct brcmf_sdreg *) params; - u8 data = 0; - - if (brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, - sd_ptr->func, sd_ptr->offset, &data)) { - bcmerror = -EIO; - break; - } - - int_val = (int)data; - memcpy(arg, &int_val, sizeof(int_val)); - break; - } - - case IOV_SVAL(IOV_DEVREG): - { - struct brcmf_sdreg *sd_ptr = - (struct brcmf_sdreg *) params; - u8 data = (u8) sd_ptr->value; - - if (brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, - sd_ptr->func, sd_ptr->offset, &data)) { - bcmerror = -EIO; - break; - } - break; - } - - default: - bcmerror = -ENOTSUPP; - break; - } -exit: - - return bcmerror; -} - static void brcmf_sdioh_irqhandler(struct sdio_func *func) { struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index add29c32aff..b0cfe514479 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -88,9 +88,6 @@ #define TOE_TX_CSUM_OL 0x00000001 #define TOE_RX_CSUM_OL 0x00000002 -/* maximum channels returned by the get valid channels iovar */ -#define WL_NUMCHANNELS 64 - #define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */ /* size of brcmf_scan_params not including variable length array */ @@ -810,9 +807,6 @@ struct brcmf_c_ioctl { /* Enter idle immediately (no timeout) */ #define BRCMF_IDLE_IMMEDIATE (-1) - -/* Values for idleclock iovar: other values are the sd_divisor to use - when idle */ #define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change when idle */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 34351249d3e..efff099f520 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -4196,17 +4196,9 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) bus->blocksize = bus->sdiodev->func[2]->cur_blksize; bus->roundup = min(max_roundup, bus->blocksize); - /* Query if bus module supports packet chaining, - default to use if supported */ - if (brcmf_sdcard_iovar_op(bus->sdiodev, "sd_rxchain", NULL, 0, - &bus->sd_rxchain, sizeof(s32), - false) != 0) - bus->sd_rxchain = false; - else - brcmf_dbg(INFO, "bus module (through sdiocard API) %s chaining\n", - bus->sd_rxchain ? "supports" : "does not support"); - - bus->use_rxchain = (bool) bus->sd_rxchain; + /* bus module does not support packet chaining */ + bus->use_rxchain = false; + bus->sd_rxchain = false; return true; } diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index aa177ed8727..c67e1c8558b 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -205,11 +205,6 @@ extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, /* Issue an abort to the specified function */ extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn); -/* Miscellaneous knob tweaker. */ -extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, - const char *name, void *params, int plen, - void *arg, int len, bool set); - /* platform specific/high level functions */ extern int brcmf_sdio_function_init(void); extern int brcmf_sdio_register(void); diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index a3af57c535a..ed2870be096 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -351,7 +351,6 @@ struct brcms_info; struct brcms_c_info; struct brcms_hardware; struct brcms_c_if; -struct brcmu_iovar; struct brcmu_strbuf; struct brcms_txq_info; struct brcms_band; @@ -362,6 +361,15 @@ struct d11rxhdr; struct brcms_d11rxhdr; struct txpwr_limits; +/* iovar structure */ +struct brcmu_iovar { + const char *name; /* name for lookup and display */ + u16 varid; /* id for switch */ + u16 flags; /* driver-specific flag bits */ + u16 type; /* base type of argument */ + u16 minlen; /* min length for buffer vars */ +}; + /* brcm_msg_level is a bit vector with defs in defs.h */ extern u32 brcm_msg_level; diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 6280ec15f34..1fe47fe66e3 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -364,73 +364,6 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) EXPORT_SYMBOL(brcmu_prpkt); #endif /* defined(BCMDBG) */ -/* iovar table lookup */ -const struct brcmu_iovar *brcmu_iovar_lookup(const struct brcmu_iovar *table, - const char *name) -{ - const struct brcmu_iovar *vi; - const char *lookup_name; - - /* skip any ':' delimited option prefixes */ - lookup_name = strrchr(name, ':'); - if (lookup_name != NULL) - lookup_name++; - else - lookup_name = name; - - for (vi = table; vi->name; vi++) { - if (!strcmp(vi->name, lookup_name)) - return vi; - } - /* ran to end of table */ - - return NULL; /* var name not found */ -} -EXPORT_SYMBOL(brcmu_iovar_lookup); - -int brcmu_iovar_lencheck(const struct brcmu_iovar *vi, void *arg, int len, - bool set) -{ - int bcmerror = 0; - - /* length check on io buf */ - switch (vi->type) { - case IOVT_BOOL: - case IOVT_INT8: - case IOVT_INT16: - case IOVT_INT32: - case IOVT_UINT8: - case IOVT_UINT16: - case IOVT_UINT32: - /* all integers are s32 sized args at the ioctl interface */ - if (len < (int)sizeof(int)) - bcmerror = -EOVERFLOW; - break; - - case IOVT_BUFFER: - /* buffer must meet minimum length requirement */ - if (len < vi->minlen) - bcmerror = -EOVERFLOW; - break; - - case IOVT_VOID: - if (!set) - /* Cannot return nil... */ - bcmerror = -ENOTSUPP; - else if (len) - /* Set is an action w/o parameters */ - bcmerror = -ENOBUFS; - break; - - default: - /* unknown type for length check in iovar info */ - bcmerror = -ENOTSUPP; - } - - return bcmerror; -} -EXPORT_SYMBOL(brcmu_iovar_lencheck); - /* * Traverse a string of 1-byte tag/1-byte length/variable-length value * triples, returning a pointer to the substring whose first element diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index 633972125eb..cf34bd3e252 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -198,51 +198,6 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); #define brcmu_prpkt(a, b) #endif /* BCMDBG */ -/* Support for sharing code across in-driver iovar implementations. - * The intent is that a driver use this structure to map iovar names - * to its (private) iovar identifiers, and the lookup function to - * find the entry. Macros are provided to map ids and get/set actions - * into a single number space for a switch statement. - */ - -/* iovar structure */ -struct brcmu_iovar { - const char *name; /* name for lookup and display */ - u16 varid; /* id for switch */ - u16 flags; /* driver-specific flag bits */ - u16 type; /* base type of argument */ - u16 minlen; /* min length for buffer vars */ -}; - -/* varid definitions are per-driver, may use these get/set bits */ - -/* IOVar action bits for id mapping */ -#define IOV_GET 0 /* Get an iovar */ -#define IOV_SET 1 /* Set an iovar */ - -/* Varid to actionid mapping */ -#define IOV_GVAL(id) ((id)*2) -#define IOV_SVAL(id) (((id)*2)+IOV_SET) -#define IOV_ISSET(actionid) ((actionid & IOV_SET) == IOV_SET) -#define IOV_ID(actionid) (actionid >> 1) - -extern const struct -brcmu_iovar *brcmu_iovar_lookup(const struct brcmu_iovar *table, - const char *name); -extern int brcmu_iovar_lencheck(const struct brcmu_iovar *table, void *arg, - int len, bool set); - -/* Base type definitions */ -#define IOVT_VOID 0 /* no value (implictly set only) */ -#define IOVT_BOOL 1 /* any value ok (zero/nonzero) */ -#define IOVT_INT8 2 /* integer values are range-checked */ -#define IOVT_UINT8 3 /* unsigned int 8 bits */ -#define IOVT_INT16 4 /* int 16 bits */ -#define IOVT_UINT16 5 /* unsigned int 16 bits */ -#define IOVT_INT32 6 /* int 32 bits */ -#define IOVT_UINT32 7 /* unsigned int 32 bits */ -#define IOVT_BUFFER 8 /* buffer is size-checked as per minlen */ - /* brcmu_format_flags() bit description structure */ struct brcmu_bit_desc { u32 bit; From 98ae8a0bf1d2670630023aefb02d75a329fd7271 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Sep 2011 12:14:52 +0200 Subject: [PATCH 0979/1519] staging: brcm80211: remove static function variable in brcmfmac The static local variable save_ms in brcmf_sdbrcm_wd_timer() has been removed and placed in the structure brcmf_bus definition. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index efff099f520..823567fc911 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -654,6 +654,7 @@ struct brcmf_bus { struct completion watchdog_wait; struct task_struct *watchdog_tsk; bool wd_timer_valid; + uint save_ms; struct tasklet_struct tasklet; struct task_struct *dpc_tsk; @@ -5031,8 +5032,6 @@ brcmf_sdbrcm_watchdog(unsigned long data) void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) { - static uint save_ms; - /* don't start the wd until fw is loaded */ if (bus->drvr->busstate == BRCMF_BUS_DOWN) return; @@ -5041,14 +5040,14 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) if (!wdtick && bus->wd_timer_valid == true) { del_timer_sync(&bus->timer); bus->wd_timer_valid = false; - save_ms = wdtick; + bus->save_ms = wdtick; return; } if (wdtick) { brcmf_watchdog_ms = (uint) wdtick; - if (save_ms != brcmf_watchdog_ms) { + if (bus->save_ms != brcmf_watchdog_ms) { if (bus->wd_timer_valid == true) /* Stop timer and restart at new value */ del_timer_sync(&bus->timer); @@ -5067,7 +5066,7 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) } bus->wd_timer_valid = true; - save_ms = wdtick; + bus->save_ms = wdtick; } } From 7b93a42f24caf3ac1c9ad440fb50b1aafd7d2969 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Sep 2011 12:14:53 +0200 Subject: [PATCH 0980/1519] staging: brcm80211: remove static variables from wl_cfg80211.c The source file contained two static variable which were used by the driver instance. This makes having multiple instances of the driver on one system impossible. This patch removes the use of these static variables allowing multiple driver instances. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 1 - drivers/staging/brcm80211/brcmfmac/dhd.h | 2 + drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 3 + .../staging/brcm80211/brcmfmac/dhd_linux.c | 20 +++-- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 5 ++ .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 77 +++++++------------ .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 15 ++-- 7 files changed, 59 insertions(+), 64 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index b38e698a074..0aff62d89a6 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -539,7 +539,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, return -ENODEV; sdiodev->func[2] = func; - brcmf_cfg80211_sdio_func(func); brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_probe...\n"); ret = brcmf_sdio_probe(sdiodev); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index b0cfe514479..9f84837cb54 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -540,6 +540,7 @@ struct brcmf_ioctl { struct brcmf_bus; /* device bus info */ struct brcmf_proto; /* device communication protocol info */ struct brcmf_info; /* device driver info */ +struct brcmf_cfg80211_dev; /* cfg80211 device info */ /* Common structure for module and instance linkage */ struct brcmf_pub { @@ -547,6 +548,7 @@ struct brcmf_pub { struct brcmf_bus *bus; struct brcmf_proto *prot; struct brcmf_info *info; + struct brcmf_cfg80211_dev *config; /* Internal brcmf items */ bool up; /* Driver up/down (to OS) */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 3361e015108..aa05b1c5fdc 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -38,6 +38,9 @@ extern uint brcmf_watchdog_ms; extern int brcmf_bus_register(void); extern void brcmf_bus_unregister(void); +/* obtain linux device object providing bus function */ +extern struct device *brcmf_bus_get_device(struct brcmf_bus *bus); + /* Stop bus module: clear pending frames, disable data flow */ extern void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 539a24db428..cfdd64590d9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -828,7 +828,7 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *net, sprintf(info->version, "%lu", drvr_priv->pub.drv_version); sprintf(info->fw_version, "%s", BCM4329_FW_NAME); sprintf(info->bus_info, "%s", - dev_name(&brcmf_cfg80211_get_sdio_func()->dev)); + dev_name(brcmf_bus_get_device(drvr_priv->pub.bus))); } static struct ethtool_ops brcmf_ethtool_ops = { @@ -1055,15 +1055,15 @@ done: static int brcmf_netdev_stop(struct net_device *net) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(net); brcmf_dbg(TRACE, "Enter\n"); - brcmf_cfg80211_down(); - if (drvr_priv->pub.up == 0) + brcmf_cfg80211_down(drvr->config); + if (drvr->up == 0) return 0; /* Set state and stop OS transmissions */ - drvr_priv->pub.up = 0; + drvr->up = 0; netif_stop_queue(net); return 0; @@ -1102,7 +1102,7 @@ static int brcmf_netdev_open(struct net_device *net) /* Allow transmit calls */ netif_start_queue(net); drvr_priv->pub.up = 1; - if (unlikely(brcmf_cfg80211_up())) { + if (unlikely(brcmf_cfg80211_up(drvr_priv->pub.config))) { brcmf_dbg(ERROR, "failed to bring up cfg80211\n"); return -1; } @@ -1220,7 +1220,11 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) } /* Attach and link in the cfg80211 */ - if (unlikely(brcmf_cfg80211_attach(net, &drvr_priv->pub))) { + drvr_priv->pub.config = + brcmf_cfg80211_attach(net, + brcmf_bus_get_device(bus), + &drvr_priv->pub); + if (unlikely(drvr_priv->pub.config == NULL)) { brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); goto fail; } @@ -1425,7 +1429,7 @@ void brcmf_detach(struct brcmf_pub *drvr) if (drvr->prot) brcmf_proto_detach(drvr); - brcmf_cfg80211_detach(); + brcmf_cfg80211_detach(drvr->config); free_netdev(ifp->net); kfree(ifp); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 823567fc911..0de4dc64b9e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -4317,6 +4317,11 @@ void brcmf_bus_unregister(void) brcmf_sdio_unregister(); } +struct device *brcmf_bus_get_device(struct brcmf_bus *bus) +{ + return &bus->sdiodev->func[2]->dev; +} + static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) { int offset = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index dd56baac049..d33d2cdd315 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -37,8 +36,6 @@ #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ (sizeof(struct brcmf_assoc_params) - sizeof(u16)) -static struct sdio_func *cfg80211_sdio_func; -static struct brcmf_cfg80211_dev *cfg80211_dev; static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; static u32 brcmf_dbg_level = WL_DBG_ERR; @@ -147,11 +144,6 @@ static s32 brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, const struct brcmf_event_msg *e, void *data); -/* -** register/deregister sdio function -*/ -static void brcmf_clear_sdio_func(void); - /* ** ioctl utilites */ @@ -312,9 +304,10 @@ static int brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv); static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv); -static struct brcmf_cfg80211_priv *brcmf_priv_get(void) +static +struct brcmf_cfg80211_priv *brcmf_priv_get(struct brcmf_cfg80211_dev *cfg_dev) { - struct brcmf_cfg80211_iface *ci = brcmf_get_drvdata(cfg80211_dev); + struct brcmf_cfg80211_iface *ci = brcmf_get_drvdata(cfg_dev); return ci->cfg_priv; } @@ -3430,27 +3423,31 @@ static void wl_deinit_priv(struct brcmf_cfg80211_priv *cfg_priv) brcmf_deinit_priv_mem(cfg_priv); } -s32 brcmf_cfg80211_attach(struct net_device *ndev, void *data) +struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, + struct device *busdev, + void *data) { struct wireless_dev *wdev; struct brcmf_cfg80211_priv *cfg_priv; struct brcmf_cfg80211_iface *ci; + struct brcmf_cfg80211_dev *cfg_dev; s32 err = 0; if (unlikely(!ndev)) { WL_ERR("ndev is invalid\n"); - return -ENODEV; + return NULL; } - cfg80211_dev = kzalloc(sizeof(struct brcmf_cfg80211_dev), GFP_KERNEL); - if (unlikely(!cfg80211_dev)) { + cfg_dev = kzalloc(sizeof(struct brcmf_cfg80211_dev), GFP_KERNEL); + if (unlikely(!cfg_dev)) { WL_ERR("wl_cfg80211_dev is invalid\n"); - return -ENOMEM; + return NULL; + } + + wdev = brcmf_alloc_wdev(sizeof(struct brcmf_cfg80211_iface), busdev); + if (IS_ERR(wdev)) { + kfree(cfg_dev); + return NULL; } - WL_INFO("func %p\n", brcmf_cfg80211_get_sdio_func()); - wdev = brcmf_alloc_wdev(sizeof(struct brcmf_cfg80211_iface), - &brcmf_cfg80211_get_sdio_func()->dev); - if (IS_ERR(wdev)) - return -ENOMEM; wdev->iftype = brcmf_mode_to_nl80211_iftype(WL_MODE_BSS); cfg_priv = wdev_to_cfg(wdev); @@ -3466,27 +3463,26 @@ s32 brcmf_cfg80211_attach(struct net_device *ndev, void *data) WL_ERR("Failed to init iwm_priv (%d)\n", err); goto cfg80211_attach_out; } - brcmf_set_drvdata(cfg80211_dev, ci); + brcmf_set_drvdata(cfg_dev, ci); - return err; + return cfg_dev; cfg80211_attach_out: brcmf_free_wdev(cfg_priv); - return err; + kfree(cfg_dev); + return NULL; } -void brcmf_cfg80211_detach(void) +void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg_dev) { struct brcmf_cfg80211_priv *cfg_priv; - cfg_priv = brcmf_priv_get(); + cfg_priv = brcmf_priv_get(cfg_dev); wl_deinit_priv(cfg_priv); brcmf_free_wdev(cfg_priv); - brcmf_set_drvdata(cfg80211_dev, NULL); - kfree(cfg80211_dev); - cfg80211_dev = NULL; - brcmf_clear_sdio_func(); + brcmf_set_drvdata(cfg_dev, NULL); + kfree(cfg_dev); } static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv) @@ -3620,21 +3616,6 @@ static void brcmf_put_event(struct brcmf_cfg80211_event_q *e) kfree(e); } -void brcmf_cfg80211_sdio_func(void *func) -{ - cfg80211_sdio_func = (struct sdio_func *)func; -} - -static void brcmf_clear_sdio_func(void) -{ - cfg80211_sdio_func = NULL; -} - -struct sdio_func *brcmf_cfg80211_get_sdio_func(void) -{ - return cfg80211_sdio_func; -} - static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) { s32 infra = 0; @@ -3951,12 +3932,12 @@ static s32 __brcmf_cfg80211_down(struct brcmf_cfg80211_priv *cfg_priv) return 0; } -s32 brcmf_cfg80211_up(void) +s32 brcmf_cfg80211_up(struct brcmf_cfg80211_dev *cfg_dev) { struct brcmf_cfg80211_priv *cfg_priv; s32 err = 0; - cfg_priv = brcmf_priv_get(); + cfg_priv = brcmf_priv_get(cfg_dev); mutex_lock(&cfg_priv->usr_sync); err = __brcmf_cfg80211_up(cfg_priv); mutex_unlock(&cfg_priv->usr_sync); @@ -3964,12 +3945,12 @@ s32 brcmf_cfg80211_up(void) return err; } -s32 brcmf_cfg80211_down(void) +s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev) { struct brcmf_cfg80211_priv *cfg_priv; s32 err = 0; - cfg_priv = brcmf_priv_get(); + cfg_priv = brcmf_priv_get(cfg_dev); mutex_lock(&cfg_priv->usr_sync); err = __brcmf_cfg80211_down(cfg_priv); mutex_unlock(&cfg_priv->usr_sync); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index cfbf50deb74..db71762f497 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -364,16 +364,17 @@ static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, #define for_each_bss(list, bss, __i) \ for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, \ - bss = next_bss(list, bss)) + bss = next_bss(list, bss)) + +extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, + struct device *busdev, + void *data); +extern void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg); -extern s32 brcmf_cfg80211_attach(struct net_device *ndev, void *data); -extern void brcmf_cfg80211_detach(void); /* event handler from dongle */ extern void brcmf_cfg80211_event(struct net_device *ndev, const struct brcmf_event_msg *e, void *data); -extern void brcmf_cfg80211_sdio_func(void *func); /* set sdio function info */ -extern struct sdio_func *brcmf_cfg80211_get_sdio_func(void); -extern s32 brcmf_cfg80211_up(void); /* dongle up */ -extern s32 brcmf_cfg80211_down(void); /* dongle down */ +extern s32 brcmf_cfg80211_up(struct brcmf_cfg80211_dev *cfg_dev); +extern s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev); #endif /* _wl_cfg80211_h_ */ From 7456ed2906ce81fbb211731c855005ab12419758 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:54 +0200 Subject: [PATCH 0981/1519] staging: brcm80211: removed unused encryption/security functionality Softmac relies on Mac80211 for this. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/alloc.c | 15 ---- drivers/staging/brcm80211/brcmsmac/main.c | 59 +------------ drivers/staging/brcm80211/brcmsmac/main.h | 97 ---------------------- drivers/staging/brcm80211/brcmsmac/pub.h | 12 --- 4 files changed, 3 insertions(+), 180 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 7a499ba1858..344c0ad9b22 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -210,20 +210,6 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) } brcms_c_bsscfg_ID_assign(wlc, wlc->cfg); - wlc->wsec_def_keys[0] = - kzalloc(sizeof(struct wsec_key) * BRCMS_DEFAULT_KEYS, - GFP_ATOMIC); - if (wlc->wsec_def_keys[0] == NULL) { - *err = 1015; - goto fail; - } else { - int i; - for (i = 1; i < BRCMS_DEFAULT_KEYS; i++) - wlc->wsec_def_keys[i] = (struct wsec_key *) - ((unsigned long)wlc->wsec_def_keys[0] + - (sizeof(struct wsec_key) * i)); - } - wlc->protection = kzalloc(sizeof(struct brcms_protection), GFP_ATOMIC); if (wlc->protection == NULL) { @@ -280,7 +266,6 @@ void brcms_c_detach_mfree(struct brcms_c_info *wlc) brcms_c_pub_mfree(wlc->pub); kfree(wlc->modulecb); kfree(wlc->default_bss); - kfree(wlc->wsec_def_keys[0]); kfree(wlc->protection); kfree(wlc->stf); kfree(wlc->bandstate[0]); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d755c185a5d..cc669d6f779 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -32,16 +32,6 @@ #include "ucode_loader.h" #include "main.h" - -/* - * WPA(2) definitions - */ -#define RSN_CAP_4_REPLAY_CNTRS 2 -#define RSN_CAP_16_REPLAY_CNTRS 3 - -#define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS -#define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS - /* * Indication for txflowcontrol that all priority bits in * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. @@ -181,9 +171,6 @@ /* stop txq enqueue for ampdu flow control */ #define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 -/* number of 802.11 default (non-paired, group keys) */ -#define WSEC_MAX_DEFAULT_KEYS 4 /* # of default keys */ - #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ #define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) @@ -376,18 +363,7 @@ #define BRCMS_TX_FIFO_ENAB(wlc, fifo) \ ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo]) -/* - * if wpa is in use then portopen is true when the - * group key is plumbed otherwise it is always true - */ -#define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED)) - -#define BRCMS_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \ - ((bsscfg)->wsec & WSEC_SWFLAG))) - -#define BRCMS_PORTOPEN(cfg) \ - (((cfg)->WPA_auth != WPA_AUTH_DISABLED && WSEC_ENABLED((cfg)->wsec)) ? \ - (cfg)->wsec_portopen : true) +#define BRCMS_PORTOPEN(cfg) true #define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) @@ -4325,8 +4301,6 @@ static void brcms_b_watchdog(void *arg) static void brcms_c_watchdog(void *arg) { struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - int i; - struct brcms_bss_cfg *cfg; BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); @@ -4372,14 +4346,6 @@ static void brcms_c_watchdog(void *arg) if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) brcms_c_statsupd(wlc); - /* Manage TKIP countermeasures timers */ - FOREACH_BSS(wlc, i, cfg) - if (cfg->tk_cm_dt) - cfg->tk_cm_dt--; - if (cfg->tk_cm_bt) - cfg->tk_cm_bt--; - END_FOREACH_BSS() - if (BRCMS_ISNPHY(wlc->band) && !wlc->pub->tempsense_disable && ((wlc->pub->now - wlc->tempsense_lasttime) >= BRCMS_TEMPSENSE_PERIOD)) { @@ -4469,15 +4435,6 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->SRL = RETRY_SHORT_DEF; wlc->LRL = RETRY_LONG_DEF; - /* Set flag to indicate that hw keys should be used when available. */ - wlc->wsec_swkeys = false; - - /* init the 4 static WEP default keys */ - for (i = 0; i < WSEC_MAX_DEFAULT_KEYS; i++) { - wlc->wsec_keys[i] = wlc->wsec_def_keys[i]; - wlc->wsec_keys[i]->idx = (u8) i; - } - /* WME QoS mode is Auto by default */ wlc->pub->_wme = AUTO; wlc->pub->_ampdu = AMPDU_AGG_HOST; @@ -7128,7 +7085,7 @@ static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct sk_buff *p, struct scb *scb, uint frag, uint nfrags, uint queue, uint next_frag_len, - struct wsec_key *key, u32 rspec_override) + u32 rspec_override) { struct ieee80211_hdr *h; struct d11txh *txh; @@ -7171,14 +7128,6 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, len = brcmu_pkttotlen(p); phylen = len + FCS_LEN; - /* If WEP enabled, add room in phylen for the additional bytes of - * ICV which MAC generates. We do NOT add the additional bytes to - * the packet itself, thus phylen = packet length + ICV_LEN + FCS_LEN - * in this case - */ - if (key) - phylen += key->icv_len; - /* Get tx_info */ tx_info = IEEE80211_SKB_CB(p); @@ -7796,9 +7745,7 @@ void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : MAXPRIO; fifo = prio2fifo[prio]; - if (unlikely - (brcms_c_d11hdrs_mac80211( - wlc, hw, sdu, scb, 0, 1, fifo, 0, NULL, 0))) + if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0, 0)) return; brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); brcms_c_send_q(wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index a0dcacc8ec4..674750bfdcc 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -237,44 +237,6 @@ struct brcms_stf { #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \ >> RXS_CHAN_ID_SHIFT) -/* Maximum # of keys that wl driver supports in S/W. - * Keys supported in H/W is less than or equal to WSEC_MAX_KEYS. - */ -#define WSEC_MAX_KEYS 54 /* Max # of keys (50 + 4 default keys) */ -#define BRCMS_DEFAULT_KEYS 4 /* Default # of keys */ - -/* -* Max # of keys currently supported: -* -* s/w keys if WSEC_SW(wlc->wsec). -* h/w keys otherwise. -*/ - -struct wsec_iv { - u32 hi; /* upper 32 bits of IV */ - u16 lo; /* lower 16 bits of IV */ -}; - -#define BRCMS_NUMRXIVS 16 /* # rx IVs (one per 802.11e TID) */ - -struct wsec_key { - u8 ea[ETH_ALEN]; /* per station */ - u8 idx; /* key index in wsec_keys array */ - u8 id; /* key ID [0-3] */ - u8 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ - u8 rcmta; /* rcmta entry index, same as idx by default */ - u16 flags; /* misc flags */ - u8 algo_hw; /* cache for hw register */ - u8 aes_mode; /* cache for hw register */ - s8 iv_len; /* IV length */ - s8 icv_len; /* ICV length */ - u32 len; /* key length..don't move this var */ - /* data is 4byte aligned */ - u8 data[WLAN_MAX_KEY_LEN]; /* key data */ - struct wsec_iv rxiv[BRCMS_NUMRXIVS]; /* Rx IV (one per TID) */ - struct wsec_iv txiv; /* Tx IV */ -}; - /* * core state (mac) */ @@ -575,10 +537,6 @@ struct brcms_txq_info { * bsscfg: set of BSS configurations, idx 0 is default and always valid. * cfg: the primary bsscfg (can be AP or STA). * tx_queues: common TX Queue list. - * wsec_keys[WSEC_MAX_KEYS]: dynamic key storage. - * wsec_def_keys[BRCMS_DEFAULT_KEYS]: default key storage. - * wsec_swkeys: indicates that all keys should be treated as - * sw keys (used for debugging). * modulecb: * mimoft: SIGN or 11N. * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode. @@ -718,10 +676,6 @@ struct brcms_c_info { /* tx queue */ struct brcms_txq_info *tx_queues; - /* security */ - struct wsec_key *wsec_keys[WSEC_MAX_KEYS]; - struct wsec_key *wsec_def_keys[BRCMS_DEFAULT_KEYS]; - bool wsec_swkeys; struct modulecb *modulecb; u8 mimoft; @@ -808,28 +762,6 @@ struct antsel_info { * nmac: # of entries on maclist array * macmode: allow/deny stations on maclist array * maclist: list of source MAC addrs to match - - * security - * -------- - * wsec: wireless security bitvec - * auth: 802.11 authentication: Open, Shared Key, WPA - * openshared: try Open auth first, then Shared Key - * wsec_restrict: drop unencrypted packets if wsec is enabled - * eap_restrict: restrict data until 802.1X auth succeeds - * WPA_auth: WPA authenticated key management - * wpa2_preauth: default is true, wpa_cap sets value - * wsec_portopen: indicates keys are plumbed - * wpa_none_txiv: global txiv for WPA_NONE, tkip and aes - * wsec_index: 0-3: default tx key, -1: not set - * bss_def_keys: default key storage - * - * TKIP countermeasures - * -------------------- - * tkip_countermeasures: flags TKIP no-assoc period - * tk_cm_dt: detect timer - * tk_cm_bt: blocking timer - * tk_cm_bt_tmstmp: Timestamp when TKIP BT is activated - * tk_cm_activate: activate countermeasures after EAPOL-Key sent * * BSSID: BSSID (associated) * cur_etheraddr: h/w address @@ -839,12 +771,7 @@ struct antsel_info { * bcn: AP beacon * bcn_len: AP beacon length * ar_disassoc: disassociated in associated recreation - * auth_atmptd: auth type (open/shared) attempted * - * pmkid_cand: PMKID candidate list - * npmkid_cand: num PMKID candidates - * pmkid: PMKID cache - * npmkid: num cached PMKIDs * current_bss: BSS parms in ASSOCIATED state * * PM states @@ -854,8 +781,6 @@ struct antsel_info { * priorPMstate: Detecting PM state transitions * PSpoll: flags there is an outstanding PS-Poll frame * - * rcmta: BSSID entry in RCMTA, use the wsec key to manage the RCMTA entries. - * * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation * * txrspecidx: index into tx rate circular buffer @@ -875,22 +800,6 @@ struct brcms_bss_cfg { uint nmac; int macmode; struct ether_addr *maclist; - u32 wsec; - s16 auth; - s16 openshared; - bool wsec_restrict; - bool eap_restrict; - u16 WPA_auth; - bool wpa2_preauth; - bool wsec_portopen; - struct wsec_iv wpa_none_txiv; - int wsec_index; - struct wsec_key *bss_def_keys[BRCMS_DEFAULT_KEYS]; - bool tkip_countermeasures; - u32 tk_cm_dt; - u32 tk_cm_bt; - u32 tk_cm_bt_tmstmp; - bool tk_cm_activate; u8 BSSID[ETH_ALEN]; u8 cur_etheraddr[ETH_ALEN]; u16 bcmc_fid; @@ -899,17 +808,11 @@ struct brcms_bss_cfg { u8 *bcn; uint bcn_len; bool ar_disassoc; - int auth_atmptd; - struct pmkid_cand pmkid_cand[MAXPMKID]; - uint npmkid_cand; - struct pmkid pmkid[MAXPMKID]; - uint npmkid; struct brcms_bss_info *current_bss; bool PMawakebcn; bool PMpending; bool priorPMstate; bool PSpoll; - struct wsec_key *rcmta; u16 ID; uint txrspecidx; u32 txrspec[NTXRATE][2]; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 20582f10059..9e767fbd922 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -128,16 +128,6 @@ struct brcms_c_rateset { u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */ }; -struct rsn_parms { - u8 flags; /* misc booleans (e.g., supported) */ - u8 multicast; /* multicast cipher */ - u8 ucount; /* count of unicast ciphers */ - u8 unicast[4]; /* unicast ciphers */ - u8 acount; /* count of auth modes */ - u8 auth[4]; /* Authentication modes */ - u8 PAD[4]; /* padding for future growth */ -}; - /* All the HT-specific default advertised capabilities (including AMPDU) * should be grouped here at one place */ @@ -160,8 +150,6 @@ struct brcms_bss_info { s8 phy_noise; /* noise right after tx (in dBm) */ u16 capability; /* Capability information */ u8 wme_qosinfo; /* QoS Info from WME IE; valid if BSS_WME flag set */ - struct rsn_parms wpa; - struct rsn_parms wpa2; u16 qbss_load_aac; /* qbss load available admission capacity */ /* qbss_load_chan_free <- (0xff - chan utilization of qbss_load_ie_t) */ u8 qbss_load_chan_free; /* indicates how free the channel is */ From e929821dee3ea88f5da20f889207bb0d8ad9bba9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:55 +0200 Subject: [PATCH 0982/1519] staging: brcm80211: removed softmac 'tunable' functionality Removed unused mechanism as part of code cleanup. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/alloc.c | 58 ---------------------- drivers/staging/brcm80211/brcmsmac/ampdu.c | 5 +- drivers/staging/brcm80211/brcmsmac/main.c | 41 +++++++++------ drivers/staging/brcm80211/brcmsmac/pub.h | 20 -------- drivers/staging/brcm80211/brcmsmac/types.h | 16 ------ 5 files changed, 31 insertions(+), 109 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 344c0ad9b22..52189dc9eea 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -20,61 +20,12 @@ #include "main.h" #include "alloc.h" -/* Max # of entries in Tx FIFO based on 4kb page size */ -#define NTXD 256 -/* Max # of entries in Rx FIFO based on 4kb page size */ -#define NRXD 256 -/* try to keep this # rbufs posted to the chip */ -#define NRXBUFPOST 32 -/* Maximum SCBs in cache for STA */ -#define MAXSCB 32 - -/* Count of packet callback structures. either of following - * 1. Set to the number of SCBs since a STA - * can queue up a rate callback for each IBSS STA it knows about, and an AP can - * queue up an "are you there?" Null Data callback for each associated STA - * 2. controlled by tunable config file - */ -#define MAXPKTCB MAXSCB /* Max number of packet callbacks */ - -/* Number of BSS handled in ucode bcn/prb */ -#define BRCMS_MAX_UCODE_BSS (16) -/* Number of BSS handled in sw bcn/prb */ -#define BRCMS_MAX_UCODE_BSS4 (4) - -/* data msg txq hiwat mark */ -#define BRCMS_DATAHIWAT 50 -#define BRCMS_AMPDUDATAHIWAT 255 - -/* bounded rx loops */ -#define RXBND 8 /* max # frames to process in brcms_c_recv() */ -#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ - -static void brcms_c_tunables_init(struct brcms_tunables *tunables, uint devid) -{ - tunables->ntxd = NTXD; - tunables->nrxd = NRXD; - tunables->rxbufsz = RXBUFSZ; - tunables->nrxbufpost = NRXBUFPOST; - tunables->maxscb = MAXSCB; - tunables->ampdunummpdu = AMPDU_NUM_MPDU; - tunables->maxpktcb = MAXPKTCB; - tunables->maxucodebss = BRCMS_MAX_UCODE_BSS; - tunables->maxucodebss4 = BRCMS_MAX_UCODE_BSS4; - tunables->maxbss = MAXBSS; - tunables->datahiwat = BRCMS_DATAHIWAT; - tunables->ampdudatahiwat = BRCMS_AMPDUDATAHIWAT; - tunables->rxbnd = RXBND; - tunables->txsbnd = TXSBND; -} - static void brcms_c_pub_mfree(struct brcms_pub *pub) { if (pub == NULL) return; kfree(pub->multicast); - kfree(pub->tunables); kfree(pub); } @@ -88,15 +39,6 @@ static struct brcms_pub *brcms_c_pub_malloc(uint unit, uint *err, uint devid) goto fail; } - pub->tunables = kzalloc(sizeof(struct brcms_tunables), GFP_ATOMIC); - if (pub->tunables == NULL) { - *err = 1028; - goto fail; - } - - /* need to init the tunables now */ - brcms_c_tunables_init(pub->tunables, devid); - pub->multicast = kzalloc(ETH_ALEN * MAXMULTILIST, GFP_ATOMIC); if (pub->multicast == NULL) { *err = 1003; diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index efae10f99c0..76f487183c5 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -62,6 +62,9 @@ #define AMPDU_DELIMITER_LEN 4 +/* max allowed number of mpdus in an ampdu (2 streams) */ +#define AMPDU_NUM_MPDU 16 + #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ @@ -287,7 +290,7 @@ static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, struct scb_ampdu *scb_ampdu = &scb->scb_ampdu; int i; - scb_ampdu->max_pdu = (u8) ampdu->wlc->pub->tunables->ampdunummpdu; + scb_ampdu->max_pdu = AMPDU_NUM_MPDU; /* go back to legacy size if some preloading is occurring */ for (i = 0; i < NUM_FFPLD_FIFO; i++) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index cc669d6f779..c5cecb48759 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -320,6 +320,21 @@ #define MAX_DMA_SEGS 4 +/* Max # of entries in Tx FIFO based on 4kb page size */ +#define NTXD 256 +/* Max # of entries in Rx FIFO based on 4kb page size */ +#define NRXD 256 + +/* try to keep this # rbufs posted to the chip */ +#define NRXBUFPOST 32 + +/* data msg txq hiwat mark */ +#define BRCMS_DATAHIWAT 50 + +/* bounded rx loops */ +#define RXBND 8 /* max # frames to process in brcms_c_recv() */ +#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ + /* * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. */ @@ -646,7 +661,7 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) struct sk_buff *head = NULL; struct sk_buff *tail = NULL; uint n = 0; - uint bound_limit = bound ? wlc_hw->wlc->pub->tunables->rxbnd : -1; + uint bound_limit = bound ? RXBND : -1; struct brcms_d11rxhdr *wlc_rxhdr = NULL; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -718,7 +733,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) * Param 'max_tx_num' indicates max. # tx status to process before * break out. */ - uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; + uint max_tx_num = bound ? TXSBND : -1; BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -925,7 +940,6 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) u16 pio_mhf2 = 0; struct brcms_hardware *wlc_hw = wlc->hw; uint unit = wlc_hw->unit; - struct brcms_tunables *tune = wlc->pub->tunables; struct wiphy *wiphy = wlc->wiphy; /* name and offsets for dma_attach */ @@ -942,8 +956,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, (wme ? DMAREG(wlc_hw, DMA_TX, 0) : NULL), DMAREG(wlc_hw, DMA_RX, 0), - (wme ? tune->ntxd : 0), tune->nrxd, - tune->rxbufsz, -1, tune->nrxbufpost, + (wme ? NTXD : 0), NRXD, + RXBUFSZ, -1, NRXBUFPOST, BRCMS_HWRXOFF, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[0]); @@ -955,7 +969,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) */ wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 1), NULL, - tune->ntxd, 0, 0, -1, 0, 0, + NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[1]); @@ -966,7 +980,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) */ wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 2), NULL, - tune->ntxd, 0, 0, -1, 0, 0, + NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[2]); /* @@ -976,7 +990,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) */ wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 3), - NULL, tune->ntxd, 0, 0, -1, + NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[3]); /* Cleaner to leave this as if with AP defined */ @@ -4963,7 +4977,7 @@ static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) * will remain the same */ brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT, - (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT + 2 * BRCMS_DATAHIWAT + PKTQ_LEN_DEFAULT + wlc->pub->psq_pkts_total); /* add this queue to the the global list */ @@ -6798,11 +6812,10 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, */ if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { - if (pktq_len(q) >= wlc->pub->tunables->datahiwat) + if (pktq_len(q) >= BRCMS_DATAHIWAT) brcms_c_txflowcontrol(wlc, qi, ON, ALLPRIO); } else if (wlc->pub->_priofc) { - if (pktq_plen(q, wlc_prio2prec_map[prio]) >= - wlc->pub->tunables->datahiwat) + if (pktq_plen(q, wlc_prio2prec_map[prio]) >= BRCMS_DATAHIWAT) brcms_c_txflowcontrol(wlc, qi, ON, prio); } } @@ -7806,14 +7819,14 @@ void brcms_c_send_q(struct brcms_c_info *wlc) if (!EDCF_ENAB(wlc->pub) || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) - && (pktq_len(q) < wlc->pub->tunables->datahiwat / 2)) + && (pktq_len(q) < BRCMS_DATAHIWAT / 2)) brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); } else if (wlc->pub->_priofc) { int prio; for (prio = MAXPRIO; prio >= 0; prio--) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && q->q[wlc_prio2prec_map[prio]].len < - wlc->pub->tunables->datahiwat / 2) + BRCMS_DATAHIWAT / 2) brcms_c_txflowcontrol(wlc, qi, OFF, prio); } } diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 9e767fbd922..acad21b33d1 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -102,24 +102,6 @@ #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ -struct brcms_tunables { - int ntxd; /* size of tx descriptor table */ - int nrxd; /* size of rx descriptor table */ - int rxbufsz; /* size of rx buffers to post */ - int nrxbufpost; /* # of rx buffers to post */ - int maxscb; /* # of SCBs supported */ - int ampdunummpdu; /* max number of mpdu in an ampdu */ - int maxpktcb; /* max # of packet callbacks */ - int maxucodebss;/* max # of BSS handled in ucode bcn/prb */ - int maxucodebss4; /* max # of BSS handled in sw bcn/prb */ - int maxbss; /* max # of bss info elements in scan list */ - int datahiwat; /* data msg txq hiwat mark */ - int ampdudatahiwat; /* AMPDU msg txq hiwat mark */ - int rxbnd; /* max # rx bufs to process before deferring to dpc */ - int txsbnd; /* max # tx status to process in wlc_txstatus() */ - int memreserved;/* memory reserved for BMAC's USB dma rx */ -}; - struct brcms_c_rateset { uint count; /* number of rates in rates[] */ /* rates in 500kbps units w/hi bit set if basic */ @@ -176,8 +158,6 @@ struct brcms_pub { char *vars; /* "environment" name=value */ bool up; /* interface up and running */ bool hw_off; /* HW is off */ - /* tunables: ntxd, nrxd, maxscb, etc. */ - struct brcms_tunables *tunables; bool hw_up; /* one time hw up/down */ bool _piomode; /* true if pio mode */ uint _nbands; /* # bands supported */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index ed2870be096..0ae3d8386b1 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -244,26 +244,10 @@ * ******************************************************************** */ -/************************************************* - * Defaults for tunables (e.g. sizing constants) - * - * For each new tunable, add a member to the end - * of struct brcms_tunables in brcms_c_pub.h to enable - * runtime checks of tunable values. (Directly - * using the macros in code invalidates ROM code) - * - * *********************************************** - */ - -/* max allowed number of mpdus in an ampdu (2 streams) */ -#define AMPDU_NUM_MPDU 16 - /* NetBSD also needs to keep track of this */ /* max # BSS configs */ #define BRCMS_MAXBSSCFG (1) -/* max # available networks */ -#define MAXBSS 64 #define BCMMSG(dev, fmt, args...) \ do { \ From db8cbbfd6d279b506813723e41d7f9c85891136e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:56 +0200 Subject: [PATCH 0983/1519] staging: brcm80211: cleaned up unused softmac struct members Struct members were unused or only written but never read. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/alloc.c | 45 +------------- drivers/staging/brcm80211/brcmsmac/main.c | 68 +++------------------- drivers/staging/brcm80211/brcmsmac/main.h | 11 ---- drivers/staging/brcm80211/brcmsmac/pub.h | 62 -------------------- 4 files changed, 9 insertions(+), 177 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c index 52189dc9eea..b99087d232d 100644 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/alloc.c @@ -20,44 +20,11 @@ #include "main.h" #include "alloc.h" -static void brcms_c_pub_mfree(struct brcms_pub *pub) -{ - if (pub == NULL) - return; - - kfree(pub->multicast); - kfree(pub); -} - -static struct brcms_pub *brcms_c_pub_malloc(uint unit, uint *err, uint devid) -{ - struct brcms_pub *pub; - - pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); - if (pub == NULL) { - *err = 1001; - goto fail; - } - - pub->multicast = kzalloc(ETH_ALEN * MAXMULTILIST, GFP_ATOMIC); - if (pub->multicast == NULL) { - *err = 1003; - goto fail; - } - - return pub; - - fail: - brcms_c_pub_mfree(pub); - return NULL; -} - static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) { if (cfg == NULL) return; - kfree(cfg->maclist); kfree(cfg->current_bss); kfree(cfg); } @@ -81,13 +48,6 @@ static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) return NULL; } -static void brcms_c_bsscfg_ID_assign(struct brcms_c_info *wlc, - struct brcms_bss_cfg *bsscfg) -{ - bsscfg->ID = wlc->next_bsscfg_ID; - wlc->next_bsscfg_ID++; -} - /* * The common driver entry routine. Error codes should be unique */ @@ -102,7 +62,7 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) } /* allocate struct brcms_c_pub state structure */ - wlc->pub = brcms_c_pub_malloc(unit, err, devid); + wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); if (wlc->pub == NULL) { *err = 1003; goto fail; @@ -150,7 +110,6 @@ struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) *err = 1011; goto fail; } - brcms_c_bsscfg_ID_assign(wlc, wlc->cfg); wlc->protection = kzalloc(sizeof(struct brcms_protection), GFP_ATOMIC); @@ -205,7 +164,7 @@ void brcms_c_detach_mfree(struct brcms_c_info *wlc) return; brcms_c_bsscfg_mfree(wlc->cfg); - brcms_c_pub_mfree(wlc->pub); + kfree(wlc->pub); kfree(wlc->modulecb); kfree(wlc->default_bss); kfree(wlc->protection); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index c5cecb48759..e330c021b9a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -70,11 +70,6 @@ #define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ -/* Software feature flag defines used by wlfeatureflag */ -#define WL_SWFL_NOHWRADIO 0x0004 -#define WL_SWFL_FLOWCONTROL 0x0008 /* Enable backpressure to OS stack */ -#define WL_SWFL_WLBSSSORT 0x0010 /* Per-port supports sorting of BSS */ - /* n-mode support capability */ /* 2x2 includes both 1x1 & 2x2 devices * reserved #define 2 for future when we want to separate 1x1 & 2x2 and @@ -2779,11 +2774,6 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw) /* turn off PHYPLL to save power */ brcms_b_core_phypll_ctl(wlc_hw, false); - /* No need to set wlc->pub->radio_active = OFF - * because this function needs down capability and - * radio_active is designed for BCMNODOWN. - */ - /* remove gpio controls */ if (wlc_hw->ucode_dbgsel) ai_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY); @@ -3744,9 +3734,6 @@ static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) */ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) { - int idx; - struct brcms_bss_cfg *cfg; - /* use the override if it is set */ if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); @@ -3756,17 +3743,6 @@ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) wlc->shortslot = shortslot; - /* update the capability based on current shortslot mode */ - FOREACH_BSS(wlc, idx, cfg) - if (!cfg->associated) - continue; - cfg->current_bss->capability &= - ~WLAN_CAPABILITY_SHORT_SLOT_TIME; - if (wlc->shortslot) - cfg->current_bss->capability |= - WLAN_CAPABILITY_SHORT_SLOT_TIME; - END_FOREACH_BSS() - brcms_b_set_shortslot(wlc->hw, shortslot); } @@ -4193,7 +4169,7 @@ static void brcms_c_down_led_upd(struct brcms_c_info *wlc) static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc) { /* Don't start the timer if HWRADIO feature is disabled */ - if (wlc->radio_monitor || (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO)) + if (wlc->radio_monitor) return true; wlc->radio_monitor = true; @@ -4238,7 +4214,7 @@ bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) /* read hwdisable state and propagate to wlc flag */ static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) { - if (wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO || wlc->pub->hw_off) + if (wlc->pub->hw_off) return; if (brcms_b_radio_read_hwdisabled(wlc->hw)) @@ -4360,7 +4336,7 @@ static void brcms_c_watchdog(void *arg) if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) brcms_c_statsupd(wlc); - if (BRCMS_ISNPHY(wlc->band) && !wlc->pub->tempsense_disable && + if (BRCMS_ISNPHY(wlc->band) && ((wlc->pub->now - wlc->tempsense_lasttime) >= BRCMS_TEMPSENSE_PERIOD)) { wlc->tempsense_lasttime = wlc->pub->now; @@ -4453,7 +4429,6 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->pub->_wme = AUTO; wlc->pub->_ampdu = AMPDU_AGG_HOST; wlc->pub->bcmerror = 0; - wlc->pub->_coex = ON; /* initialize mpc delay */ wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; @@ -4940,7 +4915,6 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) /* init default and target BSS with some sane initial values */ memset((char *)(bi), 0, sizeof(struct brcms_bss_info)); bi->beacon_period = BEACON_INTERVAL_DEFAULT; - bi->dtim_period = DTIM_INTERVAL_DEFAULT; /* fill the default channel as the first valid channel * starting from the 2G channels @@ -4977,8 +4951,7 @@ static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) * will remain the same */ brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT, - 2 * BRCMS_DATAHIWAT + PKTQ_LEN_DEFAULT - + wlc->pub->psq_pkts_total); + 2 * BRCMS_DATAHIWAT + PKTQ_LEN_DEFAULT); /* add this queue to the the global list */ p = wlc->tx_queues; @@ -5220,7 +5193,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->bsscfg[0] = wlc->cfg; wlc->cfg->_idx = 0; wlc->cfg->wlc = wlc; - pub->txmaxpkts = MAXTXPKTS; brcms_c_wme_initparams_sta(wlc, &wlc->wme_param_ie); @@ -5953,18 +5925,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) wlc->shortslot_override = shortslot; - if (preamble == BRCMS_PLCP_SHORT) - wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; - else - wlc->default_bss->capability &= ~WLAN_CAPABILITY_SHORT_PREAMBLE; - - /* Update shortslot capability bit for AP and IBSS */ - if (shortslot == BRCMS_SHORTSLOT_ON) - wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME; - else - wlc->default_bss->capability &= - ~WLAN_CAPABILITY_SHORT_SLOT_TIME; - /* Use the default 11g rateset */ if (!rs.count) brcms_c_rateset_copy(&cck_ofdm_rates, &rs); @@ -6792,8 +6752,7 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, prio = sdu->priority; if (!brcms_c_prec_enq(wlc, q, sdu, prec)) { - if (!EDCF_ENAB(wlc->pub) - || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) + if (!EDCF_ENAB(wlc->pub)) wiphy_err(wlc->wiphy, "wl%d: txq_enq: txq overflow" "\n", wlc->pub->unit); @@ -6810,13 +6769,9 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, * would make the decision on what to drop instead of relying on * stack to make the right decision */ - if (!EDCF_ENAB(wlc->pub) - || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { + if (!EDCF_ENAB(wlc->pub)) { if (pktq_len(q) >= BRCMS_DATAHIWAT) brcms_c_txflowcontrol(wlc, qi, ON, ALLPRIO); - } else if (wlc->pub->_priofc) { - if (pktq_plen(q, wlc_prio2prec_map[prio]) >= BRCMS_DATAHIWAT) - brcms_c_txflowcontrol(wlc, qi, ON, prio); } } @@ -7816,19 +7771,10 @@ void brcms_c_send_q(struct brcms_c_info *wlc) * Check if flow control needs to be turned off after * sending the packet */ - if (!EDCF_ENAB(wlc->pub) - || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL)) { + if (!EDCF_ENAB(wlc->pub)) { if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) && (pktq_len(q) < BRCMS_DATAHIWAT / 2)) brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); - } else if (wlc->pub->_priofc) { - int prio; - for (prio = MAXPRIO; prio >= 0; prio--) { - if (brcms_c_txflowcontrol_prio_isset(wlc, qi, prio) && - q->q[wlc_prio2prec_map[prio]].len < - BRCMS_DATAHIWAT / 2) - brcms_c_txflowcontrol(wlc, qi, OFF, prio); - } } in_send_q = false; } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 674750bfdcc..b31c20fd243 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -568,7 +568,6 @@ struct brcms_txq_info { * tempsense_lasttime; * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM. * tx_duty_cycle_cck: maximum allowed duty cycle for CCK. - * next_bsscfg_ID; * pkt_queue: txq for transmit packets. * mpc_dur: total time (ms) in mpc mode except for the portion since * radio is turned off last time. @@ -722,8 +721,6 @@ struct brcms_c_info { u16 tx_duty_cycle_ofdm; u16 tx_duty_cycle_cck; - u16 next_bsscfg_ID; - struct brcms_txq_info *pkt_queue; u32 mpc_dur; u32 mpc_laston_ts; @@ -757,11 +754,6 @@ struct antsel_info { * bcmc_scb: one bcmc_scb per band * _idx: the index of this bsscfg, assigned at wlc_bsscfg_alloc() * - * MAC filter - * ---------- - * nmac: # of entries on maclist array - * macmode: allow/deny stations on maclist array - * maclist: list of source MAC addrs to match * * BSSID: BSSID (associated) * cur_etheraddr: h/w address @@ -797,9 +789,6 @@ struct brcms_bss_cfg { u8 SSID[IEEE80211_MAX_SSID_LEN]; struct scb *bcmc_scb[MAXBANDS]; s8 _idx; - uint nmac; - int macmode; - struct ether_addr *maclist; u8 BSSID[ETH_ALEN]; u8 cur_etheraddr[ETH_ALEN]; u16 bcmc_fid; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index acad21b33d1..da633641478 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -22,7 +22,6 @@ #include "defs.h" #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ -#define MAXMULTILIST 32 /* max # multicast addresses */ #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ /* phy types */ @@ -124,19 +123,8 @@ struct brcms_bss_info { s16 RSSI; /* receive signal strength (in dBm) */ s16 SNR; /* receive signal SNR in dB */ u16 beacon_period; /* units are Kusec */ - u16 atim_window; /* units are Kusec */ u16 chanspec; /* Channel num, bw, ctrl_sb and band */ - s8 infra; /* 0=IBSS, 1=infrastructure, 2=unknown */ struct brcms_c_rateset rateset; /* supported rates */ - u8 dtim_period; /* DTIM period */ - s8 phy_noise; /* noise right after tx (in dBm) */ - u16 capability; /* Capability information */ - u8 wme_qosinfo; /* QoS Info from WME IE; valid if BSS_WME flag set */ - u16 qbss_load_aac; /* qbss load available admission capacity */ - /* qbss_load_chan_free <- (0xff - chan utilization of qbss_load_ie_t) */ - u8 qbss_load_chan_free; /* indicates how free the channel is */ - u8 mcipher; /* multicast cipher */ - u8 wpacfg; /* wpa config index */ }; #define MAC80211_PROMISC_BCNS (1 << 0) @@ -165,78 +153,28 @@ struct brcms_pub { bool promisc; /* promiscuous destination address */ bool delayed_down; /* down delayed */ - bool _ap; /* AP mode enabled */ - bool _apsta; /* simultaneous AP/STA mode enabled */ - bool _assoc_recreate; /* association recreation on up transitions */ int _wme; /* WME QoS mode */ - u8 _mbss; /* MBSS mode on */ - bool allmulti; /* enable all multicasts */ bool associated; /* true:part of [I]BSS, false: not */ /* (union of stas_associated, aps_associated) */ - bool phytest_on; /* whether a PHY test is running */ - bool bf_preempt_4306; /* True to enable 'darwin' mode */ bool _ampdu; /* ampdu enabled or not */ - bool _cac; /* 802.11e CAC enabled */ u8 _n_enab; /* bitmap of 11N + HT support */ - bool _n_reqd; /* N support required for clients */ - - s8 _coex; /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */ - bool _priofc; /* Priority-based flowcontrol */ u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */ - u8 *multicast; /* ptr to list of multicast addresses */ - uint nmulticast; /* # enabled multicast addresses */ - - u32 wlfeatureflag; /* Flags to control sw features from registry */ - int psq_pkts_total; /* total num of ps pkts */ - - u16 txmaxpkts; /* max number of large pkts allowed to be pending */ - - /* s/w decryption counters */ - u32 swdecrypt; /* s/w decrypt attempts */ - int bcmerror; /* last bcm error */ u32 radio_disabled; /* bit vector for radio disabled reasons */ - bool radio_active; /* radio on/off state */ - u16 roam_time_thresh; /* Max. # secs. of not hearing beacons - * before roaming. - */ - bool align_wd_tbtt; /* Align watchdog with tbtt indication - * handling. This flag is cleared by default - * and is set explicitly */ u16 boardrev; /* version # of particular board */ u8 sromrev; /* version # of the srom */ char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */ u32 boardflags; /* Board specific flags from srom */ u32 boardflags2; /* More board flags if sromrev >= 4 */ - bool tempsense_disable; /* disable periodic tempsense check */ bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */ - bool _ampdumac; /* mac assist ampdu enabled or not */ struct wl_cnt *_cnt; /* low-level counters in driver */ }; -/* wl_monitor rx status per packet */ -struct wl_rxsts { - uint pkterror; /* error flags per pkt */ - uint phytype; /* 802.11 A/B/G ... */ - uint channel; /* channel */ - uint datarate; /* rate in 500kbps */ - uint antenna; /* antenna pkts received on */ - uint pktlength; /* pkt length minus bcm phy hdr */ - u32 mactime; /* time stamp from mac, count per 1us */ - uint sq; /* signal quality */ - s32 signal; /* in dbm */ - s32 noise; /* in dbm */ - uint preamble; /* Unknown, short, long */ - uint encoding; /* Unknown, CCK, PBCC, OFDM */ - uint nfrmtype; /* special 802.11n frames(AMPDU, AMSDU) */ - struct brcms_if *wlif; /* wl interface */ -}; - enum wlc_par_id { IOV_MPC = 1, IOV_RTSTHRESH, From 72660455c3b3fb2a666e5d58e2ff3a07f8f06533 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:57 +0200 Subject: [PATCH 0984/1519] staging: brcm80211: removed softmac ratespec override functionality This was unused. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 17 +++-------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 -- drivers/staging/brcm80211/brcmsmac/stf.c | 12 ++++-------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index e330c021b9a..d30116d97b1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5913,12 +5913,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) */ if ((gmode == GMODE_LEGACY_B) && (band->gmode != GMODE_LEGACY_B)) { band->gmode = gmode; - if (band->rspec_override && !IS_CCK(band->rspec_override)) { - band->rspec_override = 0; - brcms_c_reprate_init(wlc); - } - if (band->mrspec_override && !IS_CCK(band->mrspec_override)) - band->mrspec_override = 0; } band->gmode = gmode; @@ -5988,12 +5982,8 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) for (i = 0; i < wlc->pub->_nbands; i++) { memset(wlc->bandstate[i]->hw_rateset.mcs, 0, MCSSET_LEN); - if (IS_MCS(wlc->band->rspec_override)) { - wlc->bandstate[i]->rspec_override = 0; + if (IS_MCS(0)) brcms_c_reprate_init(wlc); - } - if (IS_MCS(wlc->band->mrspec_override)) - wlc->bandstate[i]->mrspec_override = 0; } break; @@ -7052,8 +7042,7 @@ done: static u16 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct sk_buff *p, struct scb *scb, uint frag, - uint nfrags, uint queue, uint next_frag_len, - u32 rspec_override) + uint nfrags, uint queue, uint next_frag_len) { struct ieee80211_hdr *h; struct d11txh *txh; @@ -7713,7 +7702,7 @@ void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : MAXPRIO; fifo = prio2fifo[prio]; - if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0, 0)) + if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0)) return; brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); brcms_c_send_q(wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index b31c20fd243..4e576e5e572 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -271,8 +271,6 @@ struct brcms_band { /* band-specific copy of default_bss.rateset */ struct brcms_c_rateset defrateset; - u32 rspec_override; /* 802.11 rate override */ - u32 mrspec_override; /* multicast rate override */ u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */ s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */ /* rates supported by chip (phy-specific) */ diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 0a101a4ee62..71c5d237957 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -293,26 +293,22 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) if (txstreams == 1) { for (i = 0; i < wlc->pub->_nbands; i++) - if ((RSPEC_STF(wlc->bandstate[i]->rspec_override) != + if ((RSPEC_STF(0) != PHY_TXC1_MODE_SISO) - || (RSPEC_STF(wlc->bandstate[i]->mrspec_override) != + || (RSPEC_STF(0) != PHY_TXC1_MODE_SISO)) { if (!force) return -EBADE; /* over-write the override rspec */ - if (RSPEC_STF(wlc->bandstate[i]->rspec_override) + if (RSPEC_STF(0) != PHY_TXC1_MODE_SISO) { - wlc->bandstate[i]->rspec_override = 0; wiphy_err(wlc->wiphy, "%s(): temp " "sense override non-SISO " "rspec_override\n", __func__); } - if (RSPEC_STF - (wlc->bandstate[i]->mrspec_override) != - PHY_TXC1_MODE_SISO) { - wlc->bandstate[i]->mrspec_override = 0; + if (RSPEC_STF(0) != PHY_TXC1_MODE_SISO) { wiphy_err(wlc->wiphy, "%s(): temp " "sense override non-SISO " "mrspec_override\n", From e046da4fd91f203899261dcf6bc7c2d997398dec Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:58 +0200 Subject: [PATCH 0985/1519] staging: brcm80211: removed unused softmac code after macro cleanup Since the macro's IS_MCS(0), RSPEC_STF(0) and PHY_TXC1_MODE_SISO all expand to 0, inactive code could be removed. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 2 -- drivers/staging/brcm80211/brcmsmac/stf.c | 26 ----------------------- 2 files changed, 28 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d30116d97b1..7ebe0607a84 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5982,8 +5982,6 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) for (i = 0; i < wlc->pub->_nbands; i++) { memset(wlc->bandstate[i]->hw_rateset.mcs, 0, MCSSET_LEN); - if (IS_MCS(0)) - brcms_c_reprate_init(wlc); } break; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 71c5d237957..82805e0a826 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -291,32 +291,6 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) if (txstreams > MAX_STREAMS_SUPPORTED) return -EINVAL; - if (txstreams == 1) { - for (i = 0; i < wlc->pub->_nbands; i++) - if ((RSPEC_STF(0) != - PHY_TXC1_MODE_SISO) - || (RSPEC_STF(0) != - PHY_TXC1_MODE_SISO)) { - if (!force) - return -EBADE; - - /* over-write the override rspec */ - if (RSPEC_STF(0) - != PHY_TXC1_MODE_SISO) { - wiphy_err(wlc->wiphy, "%s(): temp " - "sense override non-SISO " - "rspec_override\n", - __func__); - } - if (RSPEC_STF(0) != PHY_TXC1_MODE_SISO) { - wiphy_err(wlc->wiphy, "%s(): temp " - "sense override non-SISO " - "mrspec_override\n", - __func__); - } - } - } - wlc->stf->txchain = txchain; wlc->stf->txstreams = txstreams; brcms_c_stf_stbc_tx_set(wlc, wlc->band->band_stf_stbc_tx); From 7be8a00e1c577f2be9376161d278a78425284225 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:14:59 +0200 Subject: [PATCH 0986/1519] staging: brcm80211: removed unused softmac struct brcms_c_if Nothing useful was done with this struct. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 4 ++-- drivers/staging/brcm80211/brcmsmac/main.c | 12 +++++----- drivers/staging/brcm80211/brcmsmac/main.h | 22 +------------------ drivers/staging/brcm80211/brcmsmac/pub.h | 3 +-- drivers/staging/brcm80211/brcmsmac/types.h | 1 - 5 files changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 23001c25247..d00378627a1 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -510,7 +510,7 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, /* retrieve the current rates */ LOCK(wl); error = brcms_c_ioctl(wl->wlc, BRCM_GET_CURR_RATESET, - &rs, sizeof(rs), NULL); + &rs, sizeof(rs)); UNLOCK(wl); if (error) { wiphy_err(wiphy, "%s: retrieve rateset failed: %d\n", @@ -530,7 +530,7 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, /* update the rate set */ LOCK(wl); - brcms_c_ioctl(wl->wlc, BRCM_SET_RATESET, &rs, sizeof(rs), NULL); + brcms_c_ioctl(wl->wlc, BRCM_SET_RATESET, &rs, sizeof(rs)); UNLOCK(wl); } if (changed & BSS_CHANGED_BEACON_INT) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 7ebe0607a84..13f6cd4abac 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6060,13 +6060,13 @@ brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs_arg) /* simplified integer set interface for common ioctl handler */ int brcms_c_set(struct brcms_c_info *wlc, int cmd, int arg) { - return brcms_c_ioctl(wlc, cmd, (void *)&arg, sizeof(arg), NULL); + return brcms_c_ioctl(wlc, cmd, (void *)&arg, sizeof(arg)); } /* simplified integer get interface for common ioctl handler */ int brcms_c_get(struct brcms_c_info *wlc, int cmd, int *arg) { - return brcms_c_ioctl(wlc, cmd, arg, sizeof(int), NULL); + return brcms_c_ioctl(wlc, cmd, arg, sizeof(int)); } static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) @@ -6086,8 +6086,7 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) /* common ioctl handler. return: 0=ok, -1=error, positive=particular error */ static int -_brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, - struct brcms_c_if *wlcif) +_brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len) { int val, *pval; bool bool_val; @@ -6335,10 +6334,9 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, } int -brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, - struct brcms_c_if *wlcif) +brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len) { - return _brcms_c_ioctl(wlc, cmd, arg, len, wlcif); + return _brcms_c_ioctl(wlc, cmd, arg, len); } /* diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 4e576e5e572..d418686fc7e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -320,8 +320,7 @@ struct modulecb { */ int (*iovar_fn)(void *handle, const struct brcmu_iovar *vi, u32 actionid, const char *name, void *params, - uint plen, void *arg, int alen, int vsize, - struct brcms_c_if *wlcif); + uint plen, void *arg, int alen, int vsize); int (*down_fn)(void *handle); /* down handler. Note: the int returned * by the down function is a count of the @@ -347,25 +346,6 @@ struct wme_param_ie { struct edcf_acparam acparam[AC_COUNT]; } __packed; -/* virtual interface */ -struct brcms_c_if { - struct brcms_c_if *next; - u8 type; /* BSS or WDS */ - u8 index; /* assigned in wl_add_if(), index of the wlif if any, - * not necessarily corresponding to bsscfg._idx or - * AID2PVBMAP(scb). - */ - u8 flags; /* flags for the interface */ - struct brcms_if *wlif; /* pointer to wlif */ - struct brcms_txq_info *qi; /* pointer to associated tx queue */ - union { - /* pointer to scb if WDS */ - struct scb *scb; - /* pointer to bsscfg if BSS */ - struct brcms_bss_cfg *bsscfg; - } u; -}; - struct brcms_hw_band { int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */ uint bandunit; /* bandstate[] index */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index da633641478..33e7ebe7b97 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -327,8 +327,7 @@ extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded); extern void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, struct ieee80211_hw *hw); -extern int brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len, - struct brcms_c_if *wlcif); +extern int brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len); extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid); /* helper functions */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 0ae3d8386b1..ace210c9762 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -334,7 +334,6 @@ struct ieee80211_tx_queue_params; struct brcms_info; struct brcms_c_info; struct brcms_hardware; -struct brcms_c_if; struct brcmu_strbuf; struct brcms_txq_info; struct brcms_band; From 4ea50d584aa4831367a4445c6fedc8c6f4350c00 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:15:00 +0200 Subject: [PATCH 0987/1519] staging: brcm80211: removed several unused softmac main.h struct members Members were always set to zero, or set but never read. Signed-off-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 13 +------------ drivers/staging/brcm80211/brcmsmac/main.h | 13 ------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 13f6cd4abac..9df2f8609ee 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -2384,9 +2384,7 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) null_ether_addr); } else { /* resume tx fifos */ - if (!wlc_hw->wlc->tx_suspended) - brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); - + brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); @@ -2774,10 +2772,6 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw) /* turn off PHYPLL to save power */ brcms_b_core_phypll_ctl(wlc_hw, false); - /* remove gpio controls */ - if (wlc_hw->ucode_dbgsel) - ai_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY); - wlc_hw->clk = false; ai_core_disable(wlc_hw->sih, 0); wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); @@ -3601,9 +3595,6 @@ void brcms_c_init(struct brcms_c_info *wlc) /* clear tx flow control */ brcms_c_txflowcontrol_reset(wlc); - /* clear tx data fifo suspends */ - wlc->tx_suspended = false; - /* enable the RF Disable Delay timer */ W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); @@ -4380,8 +4371,6 @@ bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) void brcms_c_info_init(struct brcms_c_info *wlc, int unit) { int i; - /* Assume the device is there until proven otherwise */ - wlc->device_present = true; /* Save our copy of the chanspec */ wlc->chanspec = ch20mhz_chspec(1); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index d418686fc7e..1ee283c5eb2 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -382,7 +382,6 @@ struct brcms_hardware { u32 boardflags2; /* More board flags if sromrev >= 4 */ u32 machwcap; /* MAC capabilities */ u32 machwcap_backup; /* backup of machwcap */ - u16 ucode_dbgsel; /* dbgsel for ucode debug(config gpio) */ struct si_pub *sih; /* SI handle (cookie for siutils calls) */ char *vars; /* "environment" name=value */ @@ -416,14 +415,11 @@ struct brcms_hardware { u32 wake_override; /* bit flags to force MAC to WAKE mode */ u32 mute_override; /* Prevent ucode from sending beacons */ u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */ - u32 led_gpio_mask; /* LED GPIO Mask */ bool noreset; /* true= do not reset hw, used by WLC_OUT */ bool forcefastclk; /* true if h/w is forcing to use fast clk */ bool clk; /* core is out of reset and has clock */ bool sbclk; /* sb has clock */ - struct bmac_pmq *bmac_pmq; /* bmac PM states derived from ucode PMQ */ bool phyclk; /* phy is out of reset and has clock */ - bool dma_lpbk; /* core is in DMA loopback */ bool ucode_loaded; /* true after ucode downloaded */ @@ -463,14 +459,12 @@ struct brcms_txq_info { * macintstatus: bit channel between isr and dpc. * macintmask: sw runtime master macintmask value. * defmacintmask: default "on" macintmask value. - * device_present: (removable) device is present. * clk: core is out of reset and has clock. * core: pointer to active io core. * band: pointer to active per-band state. * corestate: per-core state (one per hw core). * bandstate: per-band state (one per phy/radio). * war16165: PCI slow clock 16165 war flag. - * tx_suspended: data fifos need to remain suspended. * txpend16165war: PCI slow clock 16165 war flag. * qvalid: DirFrmQValid and BcMcFrmQValid. * txpwr_local_max: regulatory local txpwr max. @@ -559,7 +553,6 @@ struct brcms_c_info { struct brcms_hardware *hw; /* clock */ - int clkreq_override; u16 fastpwrup_dly; /* interrupt */ @@ -567,9 +560,6 @@ struct brcms_c_info { u32 macintmask; u32 defmacintmask; - /* up and down */ - bool device_present; - bool clk; /* multiband */ @@ -579,9 +569,6 @@ struct brcms_c_info { struct brcms_band *bandstate[MAXBANDS]; bool war16165; - - bool tx_suspended; - uint txpend16165war; /* packet queue */ From 91591c0fc8f35fc38c5c7ca6cf6f95e268333baf Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:15:01 +0200 Subject: [PATCH 0988/1519] staging: brcm80211: removed unused softmac transmit power variables Struct member variables were only set to '0'. As a result, function brcms_c_local_constraint_qdbm() always returned BRCMS_TXPWR_MAX and thus could be removed. Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 34 ++--------------------- drivers/staging/brcm80211/brcmsmac/main.h | 7 ----- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 9df2f8609ee..5199f6aa6ee 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3275,44 +3275,14 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); } -static u8 brcms_c_local_constraint_qdbm(struct brcms_c_info *wlc) -{ - u8 local; - s16 local_max; - - local = BRCMS_TXPWR_MAX; - if (wlc->pub->associated && - (brcmu_chspec_ctlchan(wlc->chanspec) == - brcmu_chspec_ctlchan(wlc->home_chanspec))) { - - /* get the local power constraint if we are on the AP's - * channel [802.11h, 7.3.2.13] - */ - /* Clamp the value between 0 and BRCMS_TXPWR_MAX w/o - * overflowing the target */ - local_max = - (wlc->txpwr_local_max - - wlc->txpwr_local_constraint) * BRCMS_TXPWR_DB_FACTOR; - if (local_max > 0 && local_max < BRCMS_TXPWR_MAX) - return (u8) local_max; - if (local_max < 0) - return 0; - } - - return local; -} - static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, u16 chanspec) { /* Save our copy of the chanspec */ wlc->chanspec = chanspec; - /* Set the chanspec and power limits for this locale after computing - * any 11h local tx power constraints. - */ - brcms_c_channel_set_chanspec(wlc->cmi, chanspec, - brcms_c_local_constraint_qdbm(wlc)); + /* Set the chanspec and power limits for this locale */ + brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); if (wlc->stf->ss_algosel_auto) brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 1ee283c5eb2..58d5c2ebcba 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -467,8 +467,6 @@ struct brcms_txq_info { * war16165: PCI slow clock 16165 war flag. * txpend16165war: PCI slow clock 16165 war flag. * qvalid: DirFrmQValid and BcMcFrmQValid. - * txpwr_local_max: regulatory local txpwr max. - * txpwr_local_constraint: local power contraint in dB. * ampdu: ampdu module handler. * asi: antsel module handler. * cmi: channel manager module handler. @@ -574,11 +572,6 @@ struct brcms_c_info { /* packet queue */ uint qvalid; - /* Regulatory power limits */ - s8 txpwr_local_max; - u8 txpwr_local_constraint; - - struct ampdu_info *ampdu; struct antsel_info *asi; struct brcms_cm_info *cmi; From ae7e3691a7a1168520d69a75b1859e955cbe3d2b Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:15:02 +0200 Subject: [PATCH 0989/1519] staging: brcm80211: removed more unused softmac main.h struct members Members were always set to zero, or set but never read. Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 21 ++-------- drivers/staging/brcm80211/brcmsmac/main.h | 47 ----------------------- 2 files changed, 3 insertions(+), 65 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 5199f6aa6ee..a1f5e24d726 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -168,8 +168,6 @@ #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ -#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) - /* * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s * OS timer(soft watchdog) it is not a wall clock and won't increment when @@ -3359,8 +3357,7 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) * inits to populate a bogus beacon. */ if (BRCMS_PHY_11N_CAP(wlc->band)) - brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, - wlc->band->bcntsfoff); + brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, 0); } } else { /* disable an active IBSS if we are not on the home channel */ @@ -3593,7 +3590,7 @@ void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) { - if (wlc->bcnmisc_ibss || wlc->bcnmisc_scan || wlc->bcnmisc_monitor) + if (wlc->bcnmisc_monitor) brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); else brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, 0); @@ -4275,7 +4272,6 @@ static void brcms_c_watchdog(void *arg) WL_RADIO_MPC_DISABLE); if (wlc->mpc && brcms_c_ismpc(wlc)) wlc->mpc_offcnt = 0; - wlc->mpc_laston_ts = OSL_SYSUPTIME(); } } @@ -5167,22 +5163,15 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, if (BRCMS_SGI_CAP_PHY(wlc)) { brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | BRCMS_N_SGI_40)); - wlc->sgi_tx = AUTO; } else if (BRCMS_ISSSLPNPHY(wlc->band)) { brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | BRCMS_N_SGI_40)); - wlc->sgi_tx = AUTO; } else { brcms_c_ht_update_sgi_rx(wlc, 0); - wlc->sgi_tx = OFF; } /* *******nvram 11n config overrides Start ********* */ - /* apply the sgi override from nvram conf */ - if (n_disabled & WLFEATURE_DISABLE_11N_SGI_TX) - wlc->sgi_tx = OFF; - if (n_disabled & WLFEATURE_DISABLE_11N_SGI_RX) brcms_c_ht_update_sgi_rx(wlc, 0); @@ -5402,7 +5391,6 @@ void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) wlc->mpc_dlycnt = BRCMS_MPC_MAX_DELAYCNT; else wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; - wlc->mpc_dur += OSL_SYSUPTIME() - wlc->mpc_laston_ts; } /* * Below logic is meant to capture the transition from mpc off @@ -5825,9 +5813,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) if (config == true) brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); - /* Clear supported rates filter */ - memset(&wlc->sup_rates_override, 0, sizeof(struct brcms_c_rateset)); - /* Clear rateset override */ memset(&rs, 0, sizeof(struct brcms_c_rateset)); @@ -6663,7 +6648,7 @@ brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, if (eprec >= 0) { bool discard_oldest; - discard_oldest = ac_bitmap_tst(wlc->wme_dp, eprec); + discard_oldest = ac_bitmap_tst(0, eprec); /* Refuse newer packet unless configured to discard oldest */ if (eprec == prec && !discard_oldest) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 58d5c2ebcba..ed8369fe219 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -281,47 +281,15 @@ struct brcms_band { u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */ u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */ - u16 bcntsfoff; /* beacon tsf offset */ -}; - -struct pkt_cb { - /* function to call when tx frame completes */ - /* tx completion callback takes 3 args */ - void (*fn)(struct brcms_c_info *wlc, uint txstatus, void *arg); - - void *arg; /* void arg for fn */ - u8 nextidx; /* index of next call back if threading */ - bool entered; /* recursion check */ }; /* module control blocks */ struct modulecb { /* module name : NULL indicates empty array member */ char name[32]; - /* iovar table */ - const struct brcmu_iovar *iovars; /* handle passed when handler 'doiovar' is called */ struct brcms_info *hdl; - /* IOVar handler - * - * handle - a pointer value registered with the function - * vi - iovar_info that was looked up - * actionid - action ID, calculated by IOV_GVAL() and IOV_SVAL() - * based on varid. - * name - the actual iovar name - * params/plen - parameters and length for a get, input only. - * arg/len - buffer and length for value to be set or retrieved, - * input or output. - * vsize - value size, valid for integer type only. - * wlcif - interface context (brcms_c_if pointer) - * - * All pointers may point into the same buffer. - */ - int (*iovar_fn)(void *handle, const struct brcmu_iovar *vi, - u32 actionid, const char *name, void *params, - uint plen, void *arg, int alen, int vsize); - int (*down_fn)(void *handle); /* down handler. Note: the int returned * by the down function is a count of the * number of timers that could not be @@ -488,16 +456,12 @@ struct brcms_txq_info { * wdtimer: timer for watchdog routine. * radio_timer: timer for hw radio button monitor routine. * monitor: monitor (MPDU sniffing) mode. - * bcnmisc_ibss: bcns promisc mode override for IBSS. - * bcnmisc_scan: bcns promisc mode override for scan. * bcnmisc_monitor: bcns promisc mode override for monitor. * _rifs: enable per-packet rifs. - * sgi_tx: sgi tx. * bcn_li_bcn: beacon listen interval in # beacons. * bcn_li_dtim: beacon listen interval in # dtims. * WDarmed: watchdog timer is armed. * WDlast: last time wlc_watchdog() was called. - * wme_dp: AC bitmap. Discard (oldest first) policy per AC. * edcf_txop[AC_COUNT]: current txop for each ac. * wme_param_ie: on STA contains parameters in use locally, and on AP * contains parameters advertised @@ -519,7 +483,6 @@ struct brcms_txq_info { * autocountry_default: initial country for 802.11d auto-country mode. * prb_resp_timeout: do not send prb resp if request older * than this, 0 = disable. - * sup_rates_override: use only these rates in 11g supported rates if specified. * home_chanspec: shared home chanspec. * chanspec: target operational channel. * usr_fragthresh: user configured fragmentation threshold. @@ -539,9 +502,6 @@ struct brcms_txq_info { * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM. * tx_duty_cycle_cck: maximum allowed duty cycle for CCK. * pkt_queue: txq for transmit packets. - * mpc_dur: total time (ms) in mpc mode except for the portion since - * radio is turned off last time. - * mpc_laston_ts: timestamp (ms) when radio is turned off last time. * wiphy: */ struct brcms_c_info { @@ -603,13 +563,10 @@ struct brcms_c_info { /* promiscuous */ bool monitor; - bool bcnmisc_ibss; - bool bcnmisc_scan; bool bcnmisc_monitor; /* driver feature */ bool _rifs; - s8 sgi_tx; /* AP-STA synchronization, power save */ u8 bcn_li_bcn; @@ -619,7 +576,6 @@ struct brcms_c_info { u32 WDlast; /* WME */ - u8 wme_dp; u16 edcf_txop[AC_COUNT]; struct wme_param_ie wme_param_ie; @@ -648,7 +604,6 @@ struct brcms_c_info { char country_default[BRCM_CNTRY_BUF_SZ]; char autocountry_default[BRCM_CNTRY_BUF_SZ]; u16 prb_resp_timeout; - struct brcms_c_rateset sup_rates_override; u16 home_chanspec; @@ -680,8 +635,6 @@ struct brcms_c_info { u16 tx_duty_cycle_cck; struct brcms_txq_info *pkt_queue; - u32 mpc_dur; - u32 mpc_laston_ts; struct wiphy *wiphy; }; From 6f42a9e59793bac56c200dd709994cc1ac6505d2 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Mon, 12 Sep 2011 12:15:03 +0200 Subject: [PATCH 0990/1519] staging: brcm80211: removed softmac files alloc.c/alloc.h Alloc.c does not contain enough functionality anymore to warrant its own file. Moved functionality into main.c Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/Makefile | 1 - drivers/staging/brcm80211/brcmsmac/alloc.c | 181 -------------------- drivers/staging/brcm80211/brcmsmac/alloc.h | 19 -- drivers/staging/brcm80211/brcmsmac/main.c | 159 ++++++++++++++++- 4 files changed, 158 insertions(+), 202 deletions(-) delete mode 100644 drivers/staging/brcm80211/brcmsmac/alloc.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/alloc.h diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile index eee2fe30ca7..8fdca2ef846 100644 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -23,7 +23,6 @@ ccflags-y := \ BRCMSMAC_OFILES := \ mac80211_if.o \ ucode_loader.o \ - alloc.o \ ampdu.o \ antsel.o \ channel.o \ diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.c b/drivers/staging/brcm80211/brcmsmac/alloc.c deleted file mode 100644 index b99087d232d..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/alloc.c +++ /dev/null @@ -1,181 +0,0 @@ -#/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include "types.h" -#include "pub.h" -#include "main.h" -#include "alloc.h" - -static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) -{ - if (cfg == NULL) - return; - - kfree(cfg->current_bss); - kfree(cfg); -} - -static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) -{ - struct brcms_bss_cfg *cfg; - - cfg = kzalloc(sizeof(struct brcms_bss_cfg), GFP_ATOMIC); - if (cfg == NULL) - goto fail; - - cfg->current_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); - if (cfg->current_bss == NULL) - goto fail; - - return cfg; - - fail: - brcms_c_bsscfg_mfree(cfg); - return NULL; -} - -/* - * The common driver entry routine. Error codes should be unique - */ -struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, uint devid) -{ - struct brcms_c_info *wlc; - - wlc = kzalloc(sizeof(struct brcms_c_info), GFP_ATOMIC); - if (wlc == NULL) { - *err = 1002; - goto fail; - } - - /* allocate struct brcms_c_pub state structure */ - wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); - if (wlc->pub == NULL) { - *err = 1003; - goto fail; - } - wlc->pub->wlc = wlc; - - /* allocate struct brcms_hardware state structure */ - - wlc->hw = kzalloc(sizeof(struct brcms_hardware), GFP_ATOMIC); - if (wlc->hw == NULL) { - *err = 1005; - goto fail; - } - wlc->hw->wlc = wlc; - - wlc->hw->bandstate[0] = - kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC); - if (wlc->hw->bandstate[0] == NULL) { - *err = 1006; - goto fail; - } else { - int i; - - for (i = 1; i < MAXBANDS; i++) - wlc->hw->bandstate[i] = (struct brcms_hw_band *) - ((unsigned long)wlc->hw->bandstate[0] + - (sizeof(struct brcms_hw_band) * i)); - } - - wlc->modulecb = - kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC); - if (wlc->modulecb == NULL) { - *err = 1009; - goto fail; - } - - wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); - if (wlc->default_bss == NULL) { - *err = 1010; - goto fail; - } - - wlc->cfg = brcms_c_bsscfg_malloc(unit); - if (wlc->cfg == NULL) { - *err = 1011; - goto fail; - } - - wlc->protection = kzalloc(sizeof(struct brcms_protection), - GFP_ATOMIC); - if (wlc->protection == NULL) { - *err = 1016; - goto fail; - } - - wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); - if (wlc->stf == NULL) { - *err = 1017; - goto fail; - } - - wlc->bandstate[0] = - kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC); - if (wlc->bandstate[0] == NULL) { - *err = 1025; - goto fail; - } else { - int i; - - for (i = 1; i < MAXBANDS; i++) - wlc->bandstate[i] = (struct brcms_band *) - ((unsigned long)wlc->bandstate[0] - + (sizeof(struct brcms_band)*i)); - } - - wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); - if (wlc->corestate == NULL) { - *err = 1026; - goto fail; - } - - wlc->corestate->macstat_snapshot = - kzalloc(sizeof(struct macstat), GFP_ATOMIC); - if (wlc->corestate->macstat_snapshot == NULL) { - *err = 1027; - goto fail; - } - - return wlc; - - fail: - brcms_c_detach_mfree(wlc); - return NULL; -} - -void brcms_c_detach_mfree(struct brcms_c_info *wlc) -{ - if (wlc == NULL) - return; - - brcms_c_bsscfg_mfree(wlc->cfg); - kfree(wlc->pub); - kfree(wlc->modulecb); - kfree(wlc->default_bss); - kfree(wlc->protection); - kfree(wlc->stf); - kfree(wlc->bandstate[0]); - kfree(wlc->corestate->macstat_snapshot); - kfree(wlc->corestate); - kfree(wlc->hw->bandstate[0]); - kfree(wlc->hw); - - /* free the wlc */ - kfree(wlc); - wlc = NULL; -} diff --git a/drivers/staging/brcm80211/brcmsmac/alloc.h b/drivers/staging/brcm80211/brcmsmac/alloc.h deleted file mode 100644 index f465d304303..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/alloc.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -extern struct brcms_c_info *brcms_c_attach_malloc(uint unit, uint *err, - uint devid); -extern void brcms_c_detach_mfree(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index a1f5e24d726..2b5d4de73c1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -27,7 +27,6 @@ #include "antsel.h" #include "stf.h" #include "ampdu.h" -#include "alloc.h" #include "mac80211_if.h" #include "ucode_loader.h" #include "main.h" @@ -503,6 +502,164 @@ static const char fifo_names[6][0]; static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); #endif +static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) +{ + if (cfg == NULL) + return; + + kfree(cfg->current_bss); + kfree(cfg); +} + +static void brcms_c_detach_mfree(struct brcms_c_info *wlc) +{ + if (wlc == NULL) + return; + + brcms_c_bsscfg_mfree(wlc->cfg); + kfree(wlc->pub); + kfree(wlc->modulecb); + kfree(wlc->default_bss); + kfree(wlc->protection); + kfree(wlc->stf); + kfree(wlc->bandstate[0]); + kfree(wlc->corestate->macstat_snapshot); + kfree(wlc->corestate); + kfree(wlc->hw->bandstate[0]); + kfree(wlc->hw); + + /* free the wlc */ + kfree(wlc); + wlc = NULL; +} + +static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) +{ + struct brcms_bss_cfg *cfg; + + cfg = kzalloc(sizeof(struct brcms_bss_cfg), GFP_ATOMIC); + if (cfg == NULL) + goto fail; + + cfg->current_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); + if (cfg->current_bss == NULL) + goto fail; + + return cfg; + + fail: + brcms_c_bsscfg_mfree(cfg); + return NULL; +} + +static struct brcms_c_info * +brcms_c_attach_malloc(uint unit, uint *err, uint devid) +{ + struct brcms_c_info *wlc; + + wlc = kzalloc(sizeof(struct brcms_c_info), GFP_ATOMIC); + if (wlc == NULL) { + *err = 1002; + goto fail; + } + + /* allocate struct brcms_c_pub state structure */ + wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); + if (wlc->pub == NULL) { + *err = 1003; + goto fail; + } + wlc->pub->wlc = wlc; + + /* allocate struct brcms_hardware state structure */ + + wlc->hw = kzalloc(sizeof(struct brcms_hardware), GFP_ATOMIC); + if (wlc->hw == NULL) { + *err = 1005; + goto fail; + } + wlc->hw->wlc = wlc; + + wlc->hw->bandstate[0] = + kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC); + if (wlc->hw->bandstate[0] == NULL) { + *err = 1006; + goto fail; + } else { + int i; + + for (i = 1; i < MAXBANDS; i++) + wlc->hw->bandstate[i] = (struct brcms_hw_band *) + ((unsigned long)wlc->hw->bandstate[0] + + (sizeof(struct brcms_hw_band) * i)); + } + + wlc->modulecb = + kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC); + if (wlc->modulecb == NULL) { + *err = 1009; + goto fail; + } + + wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); + if (wlc->default_bss == NULL) { + *err = 1010; + goto fail; + } + + wlc->cfg = brcms_c_bsscfg_malloc(unit); + if (wlc->cfg == NULL) { + *err = 1011; + goto fail; + } + + wlc->protection = kzalloc(sizeof(struct brcms_protection), + GFP_ATOMIC); + if (wlc->protection == NULL) { + *err = 1016; + goto fail; + } + + wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); + if (wlc->stf == NULL) { + *err = 1017; + goto fail; + } + + wlc->bandstate[0] = + kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC); + if (wlc->bandstate[0] == NULL) { + *err = 1025; + goto fail; + } else { + int i; + + for (i = 1; i < MAXBANDS; i++) + wlc->bandstate[i] = (struct brcms_band *) + ((unsigned long)wlc->bandstate[0] + + (sizeof(struct brcms_band)*i)); + } + + wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); + if (wlc->corestate == NULL) { + *err = 1026; + goto fail; + } + + wlc->corestate->macstat_snapshot = + kzalloc(sizeof(struct macstat), GFP_ATOMIC); + if (wlc->corestate->macstat_snapshot == NULL) { + *err = 1027; + goto fail; + } + + return wlc; + + fail: + brcms_c_detach_mfree(wlc); + return NULL; +} + /* * Update the slot timing for standard 11b/g (20us slots) * or shortslot 11g (9us slots) From ffd6e890411c177334993010f33cb041f3f1b4ab Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Mon, 12 Sep 2011 12:15:04 +0200 Subject: [PATCH 0991/1519] staging: brcm80211: remove static function declaration in wl_cfg80211 Reshuffle function order in wl_cfg80211 of fullmac to get rid of static function declaration Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 2148 ++++++++--------- 1 file changed, 941 insertions(+), 1207 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index d33d2cdd315..198f0cc1ebe 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -40,269 +40,19 @@ static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; static u32 brcmf_dbg_level = WL_DBG_ERR; -/* -** cfg80211_ops api/callback list -*/ -static s32 brcmf_cfg80211_change_iface(struct wiphy *wiphy, - struct net_device *ndev, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params); -static s32 __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_scan_request *request, - struct cfg80211_ssid *this_ssid); -static s32 brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_scan_request *request); -static s32 brcmf_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed); -static s32 brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_ibss_params *params); -static s32 brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, - struct net_device *dev); -static s32 brcmf_cfg80211_get_station(struct wiphy *wiphy, - struct net_device *dev, u8 *mac, - struct station_info *sinfo); -static s32 brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, - struct net_device *dev, bool enabled, - s32 timeout); -static s32 brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, - struct net_device *dev, - const u8 *addr, - const struct cfg80211_bitrate_mask - *mask); -static int brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_cfg80211_disconnect(struct wiphy *wiphy, - struct net_device *dev, - u16 reason_code); -static s32 brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, - enum nl80211_tx_power_setting type, - s32 dbm); -static s32 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm); -static s32 brcmf_cfg80211_config_default_key(struct wiphy *wiphy, - struct net_device *dev, u8 key_idx, - bool unicast, bool multicast); -static s32 brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, - u8 key_idx, bool pairwise, const u8 *mac_addr, - struct key_params *params); -static s32 brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, - u8 key_idx, bool pairwise, const u8 *mac_addr); -static s32 brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, - u8 key_idx, bool pairwise, const u8 *mac_addr, - void *cookie, void (*callback) (void *cookie, - struct - key_params * - params)); -static s32 brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, - struct net_device *dev, - u8 key_idx); -static s32 brcmf_cfg80211_resume(struct wiphy *wiphy); -static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, - struct cfg80211_wowlan *wow); -static s32 brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_pmksa *pmksa); -static s32 brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_pmksa *pmksa); -static s32 brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, - struct net_device *dev); -/* -** event & event Q handlers for cfg80211 interfaces -*/ -static s32 brcmf_create_event_handler(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_destroy_event_handler(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_event_handler(void *data); -static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_flush_eq(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_lock_eq(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_unlock_eq(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_init_eq_lock(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_init_eloop_handler(struct brcmf_cfg80211_event_loop *el); -static struct brcmf_cfg80211_event_q * -brcmf_deq_event(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 type, - const struct brcmf_event_msg *msg); -static void brcmf_put_event(struct brcmf_cfg80211_event_q *e); -static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, - void *data); -static s32 brcmf_notify_roaming_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, - void *data); -static s32 brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, - void *data); -static s32 brcmf_bss_connect_done(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, - bool completed); -static s32 brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e); -static s32 brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data); +static void brcmf_set_drvdata(struct brcmf_cfg80211_dev *dev, void *data) +{ + dev->driver_data = data; +} -/* -** ioctl utilites -*/ -static s32 brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, - s32 buf_len); -static __used s32 brcmf_dev_bufvar_set(struct net_device *dev, s8 *name, - s8 *buf, s32 len); -static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val); -static s32 brcmf_dev_intvar_get(struct net_device *dev, s8 *name, - s32 *retval); -static s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, - u32 len); +static void *brcmf_get_drvdata(struct brcmf_cfg80211_dev *dev) +{ + void *data = NULL; -/* -** cfg80211 set_wiphy_params utilities -*/ -static s32 brcmf_set_frag(struct net_device *dev, u32 frag_threshold); -static s32 brcmf_set_rts(struct net_device *dev, u32 frag_threshold); -static s32 brcmf_set_retry(struct net_device *dev, u32 retry, bool l); - -/* -** wl profile utilities -*/ -static s32 brcmf_update_prof(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e, - void *data, s32 item); -static void *brcmf_read_prof(struct brcmf_cfg80211_priv *cfg_priv, s32 item); -static void brcmf_init_prof(struct brcmf_cfg80211_profile *prof); - -/* -** cfg80211 connect utilites -*/ -static s32 brcmf_set_wpa_version(struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_set_auth_type(struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_set_set_cipher(struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_set_key_mgmt(struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_set_set_sharedkey(struct net_device *dev, - struct cfg80211_connect_params *sme); -static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_ch_to_chanspec(int ch, - struct brcmf_join_params *join_params, size_t *join_params_size); - -/* -** information element utilities -*/ -static __used s32 brcmf_add_ie(struct brcmf_cfg80211_priv *cfg_priv, - u8 t, u8 l, u8 *v); -static s32 brcmf_mode_to_nl80211_iftype(s32 mode); -static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, - struct device *dev); -static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, - struct brcmf_bss_info *bi); -static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, - u8 key_idx, const u8 *mac_addr, - struct key_params *params); - -/* -** key indianess swap utilities -*/ -static void convert_key_from_CPU(struct brcmf_wsec_key *key); -static void convert_key_to_CPU(struct brcmf_wsec_key *key); - -/* -** brcmf_cfg80211_priv memory init/deinit utilities -*/ -static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv); - -static void brcmf_delay(u32 ms); - -/* -** store/restore cfg80211 instance data -*/ -static void brcmf_set_drvdata(struct brcmf_cfg80211_dev *dev, void *data); -static void *brcmf_get_drvdata(struct brcmf_cfg80211_dev *dev); - -/* -** ibss mode utilities -*/ -static bool brcmf_is_ibssmode(struct brcmf_cfg80211_priv *cfg_priv); - -/* -** dongle up/down , default configuration utilities -*/ -static bool brcmf_is_linkdown(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e); -static bool brcmf_is_linkup(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e); -static bool brcmf_is_nonetwork(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e); -static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype); -static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv); -static s32 __brcmf_cfg80211_down(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_init_conf(struct brcmf_cfg80211_conf *conf); - -/* -** dongle configuration utilities -*/ -static s32 brcmf_dongle_eventmsg(struct net_device *ndev); -static s32 brcmf_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time, - s32 scan_unassoc_time, s32 scan_passive_time); -static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, - bool need_lock); -static s32 brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, - u32 bcn_timeout); - -/* -** iscan handler -*/ -static void brcmf_iscan_timer(unsigned long data); -static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_dev_iovar_setbuf(struct net_device *dev, s8 *iovar, - void *param, s32 paramlen, void *bufptr, - s32 buflen); -static s32 brcmf_dev_iovar_getbuf(struct net_device *dev, s8 *iovar, - void *param, s32 paramlen, void *bufptr, - s32 buflen); -static s32 brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, - struct brcmf_ssid *ssid, u16 action); -static s32 brcmf_do_iscan(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan); -static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, - u32 *status, - struct brcmf_scan_results **bss_list); -static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, - bool aborted); -static void brcmf_init_iscan_eloop(struct brcmf_cfg80211_iscan_eloop *el); -static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_iscan_pending(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv); -static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv); - -/* -* update pmklist to dongle -*/ -static __used s32 brcmf_update_pmklist(struct net_device *dev, - struct brcmf_cfg80211_pmk_list *pmk_list, - s32 err); - -static void brcmf_set_mpc(struct net_device *ndev, int mpc); - -/* -* debufs support -*/ -static int -brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv); -static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv); + if (dev) + data = dev->driver_data; + return data; +} static struct brcmf_cfg80211_priv *brcmf_priv_get(struct brcmf_cfg80211_dev *cfg_dev) @@ -594,6 +344,63 @@ done: return err; } +static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) +{ + s8 buf[BRCMF_C_IOCTL_SMLEN]; + u32 len; + s32 err = 0; + + val = cpu_to_le32(val); + len = brcmu_mkiovar(name, (char *)(&val), sizeof(val), buf, + sizeof(buf)); + BUG_ON(!len); + + err = brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, buf, len); + if (unlikely(err)) + WL_ERR("error (%d)\n", err); + + return err; +} + +static s32 +brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) +{ + union { + s8 buf[BRCMF_C_IOCTL_SMLEN]; + s32 val; + } var; + u32 len; + u32 data_null; + s32 err = 0; + + len = + brcmu_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), + sizeof(var.buf)); + BUG_ON(!len); + err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, &var, len); + if (unlikely(err)) + WL_ERR("error (%d)\n", err); + + *retval = le32_to_cpu(var.val); + + return err; +} + +static void brcmf_set_mpc(struct net_device *ndev, int mpc) +{ + s32 err = 0; + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); + + if (test_bit(WL_STATUS_READY, &cfg_priv->status)) { + err = brcmf_dev_intvar_set(ndev, "mpc", mpc); + if (unlikely(err)) { + WL_ERR("fail to set mpc\n"); + return; + } + WL_INFO("MPC : %d\n", mpc); + } +} + static void wl_iscan_prep(struct brcmf_scan_params *params, struct brcmf_ssid *ssid) { @@ -820,48 +627,6 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return err; } -static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) -{ - s8 buf[BRCMF_C_IOCTL_SMLEN]; - u32 len; - s32 err = 0; - - val = cpu_to_le32(val); - len = brcmu_mkiovar(name, (char *)(&val), sizeof(val), buf, - sizeof(buf)); - BUG_ON(!len); - - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, buf, len); - if (unlikely(err)) - WL_ERR("error (%d)\n", err); - - return err; -} - -static s32 -brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) -{ - union { - s8 buf[BRCMF_C_IOCTL_SMLEN]; - s32 val; - } var; - u32 len; - u32 data_null; - s32 err = 0; - - len = - brcmu_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), - sizeof(var.buf)); - BUG_ON(!len); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, &var, len); - if (unlikely(err)) - WL_ERR("error (%d)\n", err); - - *retval = le32_to_cpu(var.val); - - return err; -} - static s32 brcmf_set_rts(struct net_device *dev, u32 rts_threshold) { s32 err = 0; @@ -942,6 +707,118 @@ done: return err; } +static void *brcmf_read_prof(struct brcmf_cfg80211_priv *cfg_priv, s32 item) +{ + switch (item) { + case WL_PROF_SEC: + return &cfg_priv->profile->sec; + case WL_PROF_BSSID: + return &cfg_priv->profile->bssid; + case WL_PROF_SSID: + return &cfg_priv->profile->ssid; + } + WL_ERR("invalid item (%d)\n", item); + return NULL; +} + +static s32 +brcmf_update_prof(struct brcmf_cfg80211_priv *cfg_priv, + const struct brcmf_event_msg *e, void *data, s32 item) +{ + s32 err = 0; + struct brcmf_ssid *ssid; + + switch (item) { + case WL_PROF_SSID: + ssid = (struct brcmf_ssid *) data; + memset(cfg_priv->profile->ssid.SSID, 0, + sizeof(cfg_priv->profile->ssid.SSID)); + memcpy(cfg_priv->profile->ssid.SSID, + ssid->SSID, ssid->SSID_len); + cfg_priv->profile->ssid.SSID_len = ssid->SSID_len; + break; + case WL_PROF_BSSID: + if (data) + memcpy(cfg_priv->profile->bssid, data, ETH_ALEN); + else + memset(cfg_priv->profile->bssid, 0, ETH_ALEN); + break; + case WL_PROF_SEC: + memcpy(&cfg_priv->profile->sec, data, + sizeof(cfg_priv->profile->sec)); + break; + case WL_PROF_BEACONINT: + cfg_priv->profile->beacon_interval = *(u16 *)data; + break; + case WL_PROF_DTIMPERIOD: + cfg_priv->profile->dtim_period = *(u8 *)data; + break; + default: + WL_ERR("unsupported item (%d)\n", item); + err = -EOPNOTSUPP; + break; + } + + return err; +} + +static void brcmf_init_prof(struct brcmf_cfg80211_profile *prof) +{ + memset(prof, 0, sizeof(*prof)); +} + +static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, + size_t *join_params_size) +{ + u16 chanspec = 0; + + if (ch != 0) { + join_params->params.chanspec_num = 1; + join_params->params.chanspec_list[0] = ch; + + if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL) + chanspec |= WL_CHANSPEC_BAND_2G; + else + chanspec |= WL_CHANSPEC_BAND_5G; + + chanspec |= WL_CHANSPEC_BW_20; + chanspec |= WL_CHANSPEC_CTL_SB_NONE; + + *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + + join_params->params.chanspec_num * sizeof(u16); + + join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK; + join_params->params.chanspec_list[0] |= chanspec; + join_params->params.chanspec_list[0] = + cpu_to_le16(join_params->params.chanspec_list[0]); + + join_params->params.chanspec_num = + cpu_to_le32(join_params->params.chanspec_num); + + WL_CONN("join_params->params.chanspec_list[0]= %#X," + "channel %d, chanspec %#X\n", + join_params->params.chanspec_list[0], ch, chanspec); + } +} + +static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct net_device *dev = NULL; + s32 err = 0; + + WL_TRACE("Enter\n"); + + if (cfg_priv->link_up) { + dev = cfg_to_ndev(cfg_priv); + WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); + err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, NULL, 0); + if (unlikely(err)) + WL_ERR("WLC_DISASSOC failed (%d)\n", err); + cfg_priv->link_up = false; + } + WL_TRACE("Exit\n"); +} + static s32 brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ibss_params *params) @@ -2071,6 +1948,463 @@ done: return err; } +static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, + struct brcmf_bss_info *bi) +{ + struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); + struct ieee80211_channel *notify_channel; + struct cfg80211_bss *bss; + struct ieee80211_supported_band *band; + s32 err = 0; + u16 channel; + u32 freq; + u64 notify_timestamp; + u16 notify_capability; + u16 notify_interval; + u8 *notify_ie; + size_t notify_ielen; + s32 notify_signal; + + if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) { + WL_ERR("Bss info is larger than buffer. Discarding\n"); + return 0; + } + + channel = bi->ctl_ch ? bi->ctl_ch : + CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); + + if (channel <= CH_MAX_2G_CHANNEL) + band = wiphy->bands[IEEE80211_BAND_2GHZ]; + else + band = wiphy->bands[IEEE80211_BAND_5GHZ]; + + freq = ieee80211_channel_to_frequency(channel, band->band); + notify_channel = ieee80211_get_channel(wiphy, freq); + + notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ + notify_capability = le16_to_cpu(bi->capability); + notify_interval = le16_to_cpu(bi->beacon_period); + notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); + notify_ielen = le16_to_cpu(bi->ie_length); + notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; + + WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", + bi->BSSID[0], bi->BSSID[1], bi->BSSID[2], + bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]); + WL_CONN("Channel: %d(%d)\n", channel, freq); + WL_CONN("Capability: %X\n", notify_capability); + WL_CONN("Beacon interval: %d\n", notify_interval); + WL_CONN("Signal: %d\n", notify_signal); + WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); + + bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID, + notify_timestamp, notify_capability, notify_interval, notify_ie, + notify_ielen, notify_signal, GFP_KERNEL); + + if (unlikely(!bss)) { + WL_ERR("cfg80211_inform_bss_frame error\n"); + return -EINVAL; + } + + return err; +} + +static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_scan_results *bss_list; + struct brcmf_bss_info *bi = NULL; /* must be initialized */ + s32 err = 0; + int i; + + bss_list = cfg_priv->bss_list; + if (unlikely(bss_list->version != BRCMF_BSS_INFO_VERSION)) { + WL_ERR("Version %d != WL_BSS_INFO_VERSION\n", + bss_list->version); + return -EOPNOTSUPP; + } + WL_SCAN("scanned AP count (%d)\n", bss_list->count); + bi = next_bss(bss_list, bi); + for_each_bss(bss_list, bi, i) { + err = brcmf_inform_single_bss(cfg_priv, bi); + if (unlikely(err)) + break; + } + return err; +} + +static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, + struct net_device *dev, const u8 *bssid) +{ + struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); + struct ieee80211_channel *notify_channel; + struct brcmf_bss_info *bi = NULL; + struct ieee80211_supported_band *band; + u8 *buf = NULL; + s32 err = 0; + u16 channel; + u32 freq; + u64 notify_timestamp; + u16 notify_capability; + u16 notify_interval; + u8 *notify_ie; + size_t notify_ielen; + s32 notify_signal; + + WL_TRACE("Enter\n"); + + buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); + if (buf == NULL) { + WL_ERR("kzalloc() failed\n"); + err = -ENOMEM; + goto CleanUp; + } + + *(u32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); + + err = brcmf_dev_ioctl(dev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); + if (unlikely(err)) { + WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); + goto CleanUp; + } + + bi = (struct brcmf_bss_info *)(buf + 4); + + channel = bi->ctl_ch ? bi->ctl_ch : + CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); + + if (channel <= CH_MAX_2G_CHANNEL) + band = wiphy->bands[IEEE80211_BAND_2GHZ]; + else + band = wiphy->bands[IEEE80211_BAND_5GHZ]; + + freq = ieee80211_channel_to_frequency(channel, band->band); + notify_channel = ieee80211_get_channel(wiphy, freq); + + notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ + notify_capability = le16_to_cpu(bi->capability); + notify_interval = le16_to_cpu(bi->beacon_period); + notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); + notify_ielen = le16_to_cpu(bi->ie_length); + notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; + + WL_CONN("channel: %d(%d)\n", channel, freq); + WL_CONN("capability: %X\n", notify_capability); + WL_CONN("beacon interval: %d\n", notify_interval); + WL_CONN("signal: %d\n", notify_signal); + WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); + + cfg80211_inform_bss(wiphy, notify_channel, bssid, + notify_timestamp, notify_capability, notify_interval, + notify_ie, notify_ielen, notify_signal, GFP_KERNEL); + +CleanUp: + + kfree(buf); + + WL_TRACE("Exit\n"); + + return err; +} + +static bool brcmf_is_ibssmode(struct brcmf_cfg80211_priv *cfg_priv) +{ + return cfg_priv->conf->mode == WL_MODE_IBSS; +} + +static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_bss_info *bi; + struct brcmf_ssid *ssid; + struct brcmu_tlv *tim; + u16 beacon_interval; + u8 dtim_period; + size_t ie_len; + u8 *ie; + s32 err = 0; + + WL_TRACE("Enter\n"); + if (brcmf_is_ibssmode(cfg_priv)) + return err; + + ssid = (struct brcmf_ssid *)brcmf_read_prof(cfg_priv, WL_PROF_SSID); + + *(u32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); + err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, + cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); + if (unlikely(err)) { + WL_ERR("Could not get bss info %d\n", err); + goto update_bss_info_out; + } + + bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); + err = brcmf_inform_single_bss(cfg_priv, bi); + if (unlikely(err)) + goto update_bss_info_out; + + ie = ((u8 *)bi) + bi->ie_offset; + ie_len = bi->ie_length; + beacon_interval = cpu_to_le16(bi->beacon_period); + + tim = brcmu_parse_tlvs(ie, ie_len, WLAN_EID_TIM); + if (tim) + dtim_period = tim->data[1]; + else { + /* + * active scan was done so we could not get dtim + * information out of probe response. + * so we speficially query dtim information to dongle. + */ + u32 var; + err = brcmf_dev_intvar_get(cfg_to_ndev(cfg_priv), + "dtim_assoc", &var); + if (unlikely(err)) { + WL_ERR("wl dtim_assoc failed (%d)\n", err); + goto update_bss_info_out; + } + dtim_period = (u8)var; + } + + brcmf_update_prof(cfg_priv, NULL, &beacon_interval, WL_PROF_BEACONINT); + brcmf_update_prof(cfg_priv, NULL, &dtim_period, WL_PROF_DTIMPERIOD); + +update_bss_info_out: + WL_TRACE("Exit"); + return err; +} + +static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); + struct brcmf_ssid ssid; + + if (cfg_priv->iscan_on) { + iscan->state = WL_ISCAN_STATE_IDLE; + + if (iscan->timer_on) { + del_timer_sync(&iscan->timer); + iscan->timer_on = 0; + } + + cancel_work_sync(&iscan->work); + + /* Abort iscan running in FW */ + memset(&ssid, 0, sizeof(ssid)); + brcmf_run_iscan(iscan, &ssid, WL_SCAN_ACTION_ABORT); + } +} + +static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, + bool aborted) +{ + struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); + struct net_device *ndev = cfg_to_ndev(cfg_priv); + + if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, + &cfg_priv->status))) { + WL_ERR("Scan complete while device not scanning\n"); + return; + } + if (likely(cfg_priv->scan_request)) { + WL_SCAN("ISCAN Completed scan: %s\n", + aborted ? "Aborted" : "Done"); + cfg80211_scan_done(cfg_priv->scan_request, aborted); + brcmf_set_mpc(ndev, 1); + cfg_priv->scan_request = NULL; + } + cfg_priv->iscan_kickstart = false; +} + +static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) +{ + if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) { + WL_SCAN("wake up iscan\n"); + schedule_work(&iscan->work); + return 0; + } + + return -EIO; +} + +static s32 +brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, + struct brcmf_scan_results **bss_list) +{ + struct brcmf_iscan_results list; + struct brcmf_scan_results *results; + struct brcmf_iscan_results *list_buf; + s32 err = 0; + + memset(iscan->scan_buf, 0, WL_ISCAN_BUF_MAX); + list_buf = (struct brcmf_iscan_results *)iscan->scan_buf; + results = &list_buf->results; + results->buflen = BRCMF_ISCAN_RESULTS_FIXED_SIZE; + results->version = 0; + results->count = 0; + + memset(&list, 0, sizeof(list)); + list.results.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); + err = brcmf_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, + BRCMF_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, + WL_ISCAN_BUF_MAX); + if (unlikely(err)) { + WL_ERR("error (%d)\n", err); + return err; + } + results->buflen = le32_to_cpu(results->buflen); + results->version = le32_to_cpu(results->version); + results->count = le32_to_cpu(results->count); + WL_SCAN("results->count = %d\n", results->count); + WL_SCAN("results->buflen = %d\n", results->buflen); + *status = le32_to_cpu(list_buf->status); + WL_SCAN("status = %d\n", *status); + *bss_list = results; + + return err; +} + +static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; + s32 err = 0; + + iscan->state = WL_ISCAN_STATE_IDLE; + rtnl_lock(); + brcmf_inform_bss(cfg_priv); + brcmf_notify_iscan_complete(iscan, false); + rtnl_unlock(); + + return err; +} + +static s32 brcmf_iscan_pending(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; + s32 err = 0; + + /* Reschedule the timer */ + mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); + iscan->timer_on = 1; + + return err; +} + +static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; + s32 err = 0; + + rtnl_lock(); + brcmf_inform_bss(cfg_priv); + brcmf_run_iscan(iscan, NULL, BRCMF_SCAN_ACTION_CONTINUE); + rtnl_unlock(); + /* Reschedule the timer */ + mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); + iscan->timer_on = 1; + + return err; +} + +static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; + s32 err = 0; + + iscan->state = WL_ISCAN_STATE_IDLE; + rtnl_lock(); + brcmf_notify_iscan_complete(iscan, true); + rtnl_unlock(); + + return err; +} + +static void brcmf_cfg80211_iscan_handler(struct work_struct *work) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = + container_of(work, struct brcmf_cfg80211_iscan_ctrl, + work); + struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); + struct brcmf_cfg80211_iscan_eloop *el = &iscan->el; + u32 status = BRCMF_SCAN_RESULTS_PARTIAL; + + if (iscan->timer_on) { + del_timer_sync(&iscan->timer); + iscan->timer_on = 0; + } + + rtnl_lock(); + if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) { + status = BRCMF_SCAN_RESULTS_ABORTED; + WL_ERR("Abort iscan\n"); + } + rtnl_unlock(); + + el->handler[status](cfg_priv); +} + +static void brcmf_iscan_timer(unsigned long data) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = + (struct brcmf_cfg80211_iscan_ctrl *)data; + + if (iscan) { + iscan->timer_on = 0; + WL_SCAN("timer expired\n"); + brcmf_wakeup_iscan(iscan); + } +} + +static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); + + if (cfg_priv->iscan_on) { + iscan->state = WL_ISCAN_STATE_IDLE; + INIT_WORK(&iscan->work, brcmf_cfg80211_iscan_handler); + } + + return 0; +} + +static void brcmf_init_iscan_eloop(struct brcmf_cfg80211_iscan_eloop *el) +{ + memset(el, 0, sizeof(*el)); + el->handler[BRCMF_SCAN_RESULTS_SUCCESS] = brcmf_iscan_done; + el->handler[BRCMF_SCAN_RESULTS_PARTIAL] = brcmf_iscan_inprogress; + el->handler[BRCMF_SCAN_RESULTS_PENDING] = brcmf_iscan_pending; + el->handler[BRCMF_SCAN_RESULTS_ABORTED] = brcmf_iscan_aborted; + el->handler[BRCMF_SCAN_RESULTS_NO_MEM] = brcmf_iscan_aborted; +} + +static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); + int err = 0; + + if (cfg_priv->iscan_on) { + iscan->dev = cfg_to_ndev(cfg_priv); + brcmf_init_iscan_eloop(&iscan->el); + iscan->timer_ms = WL_ISCAN_TIMER_INTERVAL_MS; + init_timer(&iscan->timer); + iscan->timer.data = (unsigned long) iscan; + iscan->timer.function = brcmf_iscan_timer; + err = brcmf_invoke_iscan(cfg_priv); + if (!err) + iscan->data = cfg_priv; + } + + return err; +} + +static void brcmf_delay(u32 ms) +{ + if (ms < 1000 / HZ) { + cond_resched(); + mdelay(ms); + } else { + msleep(ms); + } +} + static s32 brcmf_cfg80211_resume(struct wiphy *wiphy) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -2148,6 +2482,42 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, return 0; } +static __used s32 +brcmf_dev_bufvar_set(struct net_device *dev, s8 *name, s8 *buf, s32 len) +{ + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + u32 buflen; + + buflen = brcmu_mkiovar(name, buf, len, cfg_priv->ioctl_buf, + WL_IOCTL_LEN_MAX); + BUG_ON(!buflen); + + return brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, cfg_priv->ioctl_buf, + buflen); +} + +static s32 +brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, + s32 buf_len) +{ + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + u32 len; + s32 err = 0; + + len = brcmu_mkiovar(name, NULL, 0, cfg_priv->ioctl_buf, + WL_IOCTL_LEN_MAX); + BUG_ON(!len); + err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, (void *)cfg_priv->ioctl_buf, + WL_IOCTL_LEN_MAX); + if (unlikely(err)) { + WL_ERR("error (%d)\n", err); + return err; + } + memcpy(buf, cfg_priv->ioctl_buf, buf_len); + + return err; +} + static __used s32 brcmf_update_pmklist(struct net_device *dev, struct brcmf_cfg80211_pmk_list *pmk_list, s32 err) @@ -2382,165 +2752,6 @@ static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv) cfg_priv->wdev = NULL; } -static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_scan_results *bss_list; - struct brcmf_bss_info *bi = NULL; /* must be initialized */ - s32 err = 0; - int i; - - bss_list = cfg_priv->bss_list; - if (unlikely(bss_list->version != BRCMF_BSS_INFO_VERSION)) { - WL_ERR("Version %d != WL_BSS_INFO_VERSION\n", - bss_list->version); - return -EOPNOTSUPP; - } - WL_SCAN("scanned AP count (%d)\n", bss_list->count); - bi = next_bss(bss_list, bi); - for_each_bss(bss_list, bi, i) { - err = brcmf_inform_single_bss(cfg_priv, bi); - if (unlikely(err)) - break; - } - return err; -} - - -static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, - struct brcmf_bss_info *bi) -{ - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct ieee80211_channel *notify_channel; - struct cfg80211_bss *bss; - struct ieee80211_supported_band *band; - s32 err = 0; - u16 channel; - u32 freq; - u64 notify_timestamp; - u16 notify_capability; - u16 notify_interval; - u8 *notify_ie; - size_t notify_ielen; - s32 notify_signal; - - if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) { - WL_ERR("Bss info is larger than buffer. Discarding\n"); - return 0; - } - - channel = bi->ctl_ch ? bi->ctl_ch : - CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); - - if (channel <= CH_MAX_2G_CHANNEL) - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - else - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - - freq = ieee80211_channel_to_frequency(channel, band->band); - notify_channel = ieee80211_get_channel(wiphy, freq); - - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ - notify_capability = le16_to_cpu(bi->capability); - notify_interval = le16_to_cpu(bi->beacon_period); - notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le16_to_cpu(bi->ie_length); - notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; - - WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - bi->BSSID[0], bi->BSSID[1], bi->BSSID[2], - bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]); - WL_CONN("Channel: %d(%d)\n", channel, freq); - WL_CONN("Capability: %X\n", notify_capability); - WL_CONN("Beacon interval: %d\n", notify_interval); - WL_CONN("Signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); - - bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID, - notify_timestamp, notify_capability, notify_interval, notify_ie, - notify_ielen, notify_signal, GFP_KERNEL); - - if (unlikely(!bss)) { - WL_ERR("cfg80211_inform_bss_frame error\n"); - return -EINVAL; - } - - return err; -} - -static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *dev, const u8 *bssid) -{ - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct ieee80211_channel *notify_channel; - struct brcmf_bss_info *bi = NULL; - struct ieee80211_supported_band *band; - u8 *buf = NULL; - s32 err = 0; - u16 channel; - u32 freq; - u64 notify_timestamp; - u16 notify_capability; - u16 notify_interval; - u8 *notify_ie; - size_t notify_ielen; - s32 notify_signal; - - WL_TRACE("Enter\n"); - - buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); - if (buf == NULL) { - WL_ERR("kzalloc() failed\n"); - err = -ENOMEM; - goto CleanUp; - } - - *(u32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); - - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); - if (unlikely(err)) { - WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); - goto CleanUp; - } - - bi = (struct brcmf_bss_info *)(buf + 4); - - channel = bi->ctl_ch ? bi->ctl_ch : - CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); - - if (channel <= CH_MAX_2G_CHANNEL) - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - else - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - - freq = ieee80211_channel_to_frequency(channel, band->band); - notify_channel = ieee80211_get_channel(wiphy, freq); - - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ - notify_capability = le16_to_cpu(bi->capability); - notify_interval = le16_to_cpu(bi->beacon_period); - notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le16_to_cpu(bi->ie_length); - notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; - - WL_CONN("channel: %d(%d)\n", channel, freq); - WL_CONN("capability: %X\n", notify_capability); - WL_CONN("beacon interval: %d\n", notify_interval); - WL_CONN("signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); - - cfg80211_inform_bss(wiphy, notify_channel, bssid, - notify_timestamp, notify_capability, notify_interval, - notify_ie, notify_ielen, notify_signal, GFP_KERNEL); - -CleanUp: - - kfree(buf); - - WL_TRACE("Exit\n"); - - return err; -} - static bool brcmf_is_linkup(struct brcmf_cfg80211_priv *cfg_priv, const struct brcmf_event_msg *e) { @@ -2590,104 +2801,16 @@ static bool brcmf_is_nonetwork(struct brcmf_cfg80211_priv *cfg_priv, return false; } -static s32 -brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) +static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) { - s32 err = 0; + struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - if (brcmf_is_linkup(cfg_priv, e)) { - WL_CONN("Linkup\n"); - if (brcmf_is_ibssmode(cfg_priv)) { - brcmf_update_prof(cfg_priv, NULL, (void *)e->addr, - WL_PROF_BSSID); - wl_inform_ibss(cfg_priv, ndev, e->addr); - cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL); - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - } else - brcmf_bss_connect_done(cfg_priv, ndev, e, true); - } else if (brcmf_is_linkdown(cfg_priv, e)) { - WL_CONN("Linkdown\n"); - if (brcmf_is_ibssmode(cfg_priv)) { - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - if (test_and_clear_bit(WL_STATUS_CONNECTED, - &cfg_priv->status)) - brcmf_link_down(cfg_priv); - } else { - brcmf_bss_connect_done(cfg_priv, ndev, e, false); - if (test_and_clear_bit(WL_STATUS_CONNECTED, - &cfg_priv->status)) { - cfg80211_disconnected(ndev, 0, NULL, 0, - GFP_KERNEL); - brcmf_link_down(cfg_priv); - } - } - brcmf_init_prof(cfg_priv->profile); - } else if (brcmf_is_nonetwork(cfg_priv, e)) { - if (brcmf_is_ibssmode(cfg_priv)) - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - else - brcmf_bss_connect_done(cfg_priv, ndev, e, false); - } - - return err; -} - -static s32 -brcmf_notify_roaming_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - s32 err = 0; - u32 event = be32_to_cpu(e->event_type); - u32 status = be32_to_cpu(e->status); - - if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { - if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) - brcmf_bss_roaming_done(cfg_priv, ndev, e); - else - brcmf_bss_connect_done(cfg_priv, ndev, e, true); - } - - return err; -} - -static __used s32 -brcmf_dev_bufvar_set(struct net_device *dev, s8 *name, s8 *buf, s32 len) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); - u32 buflen; - - buflen = brcmu_mkiovar(name, buf, len, cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); - BUG_ON(!buflen); - - return brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, cfg_priv->ioctl_buf, - buflen); -} - -static s32 -brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, - s32 buf_len) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); - u32 len; - s32 err = 0; - - len = brcmu_mkiovar(name, NULL, 0, cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); - BUG_ON(!len); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, (void *)cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); - if (unlikely(err)) { - WL_ERR("error (%d)\n", err); - return err; - } - memcpy(buf, cfg_priv->ioctl_buf, buf_len); - - return err; + kfree(conn_info->req_ie); + conn_info->req_ie = NULL; + conn_info->req_ie_len = 0; + kfree(conn_info->resp_ie); + conn_info->resp_ie = NULL; + conn_info->resp_ie_len = 0; } static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) @@ -2748,114 +2871,6 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) return err; } -static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - - kfree(conn_info->req_ie); - conn_info->req_ie = NULL; - conn_info->req_ie_len = 0; - kfree(conn_info->resp_ie); - conn_info->resp_ie = NULL; - conn_info->resp_ie_len = 0; -} - - -static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, - size_t *join_params_size) -{ - u16 chanspec = 0; - - if (ch != 0) { - join_params->params.chanspec_num = 1; - join_params->params.chanspec_list[0] = ch; - - if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL) - chanspec |= WL_CHANSPEC_BAND_2G; - else - chanspec |= WL_CHANSPEC_BAND_5G; - - chanspec |= WL_CHANSPEC_BW_20; - chanspec |= WL_CHANSPEC_CTL_SB_NONE; - - *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + - join_params->params.chanspec_num * sizeof(u16); - - join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK; - join_params->params.chanspec_list[0] |= chanspec; - join_params->params.chanspec_list[0] = - cpu_to_le16(join_params->params.chanspec_list[0]); - - join_params->params.chanspec_num = - cpu_to_le32(join_params->params.chanspec_num); - - WL_CONN("join_params->params.chanspec_list[0]= %#X," - "channel %d, chanspec %#X\n", - join_params->params.chanspec_list[0], ch, chanspec); - } -} - -static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_bss_info *bi; - struct brcmf_ssid *ssid; - struct brcmu_tlv *tim; - u16 beacon_interval; - u8 dtim_period; - size_t ie_len; - u8 *ie; - s32 err = 0; - - WL_TRACE("Enter\n"); - if (brcmf_is_ibssmode(cfg_priv)) - return err; - - ssid = (struct brcmf_ssid *)brcmf_read_prof(cfg_priv, WL_PROF_SSID); - - *(u32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); - err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, - cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); - if (unlikely(err)) { - WL_ERR("Could not get bss info %d\n", err); - goto update_bss_info_out; - } - - bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); - err = brcmf_inform_single_bss(cfg_priv, bi); - if (unlikely(err)) - goto update_bss_info_out; - - ie = ((u8 *)bi) + bi->ie_offset; - ie_len = bi->ie_length; - beacon_interval = cpu_to_le16(bi->beacon_period); - - tim = brcmu_parse_tlvs(ie, ie_len, WLAN_EID_TIM); - if (tim) - dtim_period = tim->data[1]; - else { - /* - * active scan was done so we could not get dtim - * information out of probe response. - * so we speficially query dtim information to dongle. - */ - u32 var; - err = brcmf_dev_intvar_get(cfg_to_ndev(cfg_priv), - "dtim_assoc", &var); - if (unlikely(err)) { - WL_ERR("wl dtim_assoc failed (%d)\n", err); - goto update_bss_info_out; - } - dtim_period = (u8)var; - } - - brcmf_update_prof(cfg_priv, NULL, &beacon_interval, WL_PROF_BEACONINT); - brcmf_update_prof(cfg_priv, NULL, &dtim_period, WL_PROF_DTIMPERIOD); - -update_bss_info_out: - WL_TRACE("Exit"); - return err; -} - static s32 brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, @@ -2936,6 +2951,70 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_priv *cfg_priv, return err; } +static s32 +brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, + struct net_device *ndev, + const struct brcmf_event_msg *e, void *data) +{ + s32 err = 0; + + if (brcmf_is_linkup(cfg_priv, e)) { + WL_CONN("Linkup\n"); + if (brcmf_is_ibssmode(cfg_priv)) { + brcmf_update_prof(cfg_priv, NULL, (void *)e->addr, + WL_PROF_BSSID); + wl_inform_ibss(cfg_priv, ndev, e->addr); + cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL); + clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); + set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); + } else + brcmf_bss_connect_done(cfg_priv, ndev, e, true); + } else if (brcmf_is_linkdown(cfg_priv, e)) { + WL_CONN("Linkdown\n"); + if (brcmf_is_ibssmode(cfg_priv)) { + clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); + if (test_and_clear_bit(WL_STATUS_CONNECTED, + &cfg_priv->status)) + brcmf_link_down(cfg_priv); + } else { + brcmf_bss_connect_done(cfg_priv, ndev, e, false); + if (test_and_clear_bit(WL_STATUS_CONNECTED, + &cfg_priv->status)) { + cfg80211_disconnected(ndev, 0, NULL, 0, + GFP_KERNEL); + brcmf_link_down(cfg_priv); + } + } + brcmf_init_prof(cfg_priv->profile); + } else if (brcmf_is_nonetwork(cfg_priv, e)) { + if (brcmf_is_ibssmode(cfg_priv)) + clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); + else + brcmf_bss_connect_done(cfg_priv, ndev, e, false); + } + + return err; +} + +static s32 +brcmf_notify_roaming_status(struct brcmf_cfg80211_priv *cfg_priv, + struct net_device *ndev, + const struct brcmf_event_msg *e, void *data) +{ + s32 err = 0; + u32 event = be32_to_cpu(e->event_type); + u32 status = be32_to_cpu(e->status); + + if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { + if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) + brcmf_bss_roaming_done(cfg_priv, ndev, e); + else + brcmf_bss_connect_done(cfg_priv, ndev, e, true); + } + + return err; +} + static s32 brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, @@ -3041,11 +3120,6 @@ static void brcmf_init_conf(struct brcmf_cfg80211_conf *conf) conf->tx_power = -1; } -static void brcmf_init_prof(struct brcmf_cfg80211_profile *prof) -{ - memset(prof, 0, sizeof(*prof)); -} - static void brcmf_init_eloop_handler(struct brcmf_cfg80211_event_loop *el) { memset(el, 0, sizeof(*el)); @@ -3056,6 +3130,28 @@ static void brcmf_init_eloop_handler(struct brcmf_cfg80211_event_loop *el) el->handler[BRCMF_E_SET_SSID] = brcmf_notify_connect_status; } +static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) +{ + kfree(cfg_priv->scan_results); + cfg_priv->scan_results = NULL; + kfree(cfg_priv->bss_info); + cfg_priv->bss_info = NULL; + kfree(cfg_priv->conf); + cfg_priv->conf = NULL; + kfree(cfg_priv->profile); + cfg_priv->profile = NULL; + kfree(cfg_priv->scan_req_int); + cfg_priv->scan_req_int = NULL; + kfree(cfg_priv->ioctl_buf); + cfg_priv->ioctl_buf = NULL; + kfree(cfg_priv->extra_buf); + cfg_priv->extra_buf = NULL; + kfree(cfg_priv->iscan); + cfg_priv->iscan = NULL; + kfree(cfg_priv->pmk_list); + cfg_priv->pmk_list = NULL; +} + static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) { cfg_priv->scan_results = kzalloc(WL_SCAN_BUF_MAX, GFP_KERNEL); @@ -3113,26 +3209,114 @@ init_priv_mem_out: return -ENOMEM; } -static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) +static void brcmf_lock_eq(struct brcmf_cfg80211_priv *cfg_priv) { - kfree(cfg_priv->scan_results); - cfg_priv->scan_results = NULL; - kfree(cfg_priv->bss_info); - cfg_priv->bss_info = NULL; - kfree(cfg_priv->conf); - cfg_priv->conf = NULL; - kfree(cfg_priv->profile); - cfg_priv->profile = NULL; - kfree(cfg_priv->scan_req_int); - cfg_priv->scan_req_int = NULL; - kfree(cfg_priv->ioctl_buf); - cfg_priv->ioctl_buf = NULL; - kfree(cfg_priv->extra_buf); - cfg_priv->extra_buf = NULL; - kfree(cfg_priv->iscan); - cfg_priv->iscan = NULL; - kfree(cfg_priv->pmk_list); - cfg_priv->pmk_list = NULL; + spin_lock_irq(&cfg_priv->eq_lock); +} + +static void brcmf_unlock_eq(struct brcmf_cfg80211_priv *cfg_priv) +{ + spin_unlock_irq(&cfg_priv->eq_lock); +} + +static void brcmf_init_eq_lock(struct brcmf_cfg80211_priv *cfg_priv) +{ + spin_lock_init(&cfg_priv->eq_lock); +} + +/* +* retrieve first queued event from head +*/ + +static struct brcmf_cfg80211_event_q *brcmf_deq_event( + struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_event_q *e = NULL; + + brcmf_lock_eq(cfg_priv); + if (likely(!list_empty(&cfg_priv->eq_list))) { + e = list_first_entry(&cfg_priv->eq_list, + struct brcmf_cfg80211_event_q, eq_list); + list_del(&e->eq_list); + } + brcmf_unlock_eq(cfg_priv); + + return e; +} + +/* +** push event to tail of the queue +*/ + +static s32 +brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, + const struct brcmf_event_msg *msg) +{ + struct brcmf_cfg80211_event_q *e; + s32 err = 0; + + e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); + if (unlikely(!e)) { + WL_ERR("event alloc failed\n"); + return -ENOMEM; + } + + e->etype = event; + memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); + + brcmf_lock_eq(cfg_priv); + list_add_tail(&e->eq_list, &cfg_priv->eq_list); + brcmf_unlock_eq(cfg_priv); + + return err; +} + +static void brcmf_put_event(struct brcmf_cfg80211_event_q *e) +{ + kfree(e); +} + +static s32 brcmf_event_handler(void *data) +{ + struct brcmf_cfg80211_priv *cfg_priv = + (struct brcmf_cfg80211_priv *)data; + struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; + struct brcmf_cfg80211_event_q *e; + DECLARE_WAITQUEUE(wait, current); + + sched_setscheduler(current, SCHED_FIFO, ¶m); + allow_signal(SIGTERM); + add_wait_queue(&cfg_priv->event_waitq, &wait); + while (1) { + prepare_to_wait(&cfg_priv->event_waitq, &wait, + TASK_INTERRUPTIBLE); + + schedule(); + + if (kthread_should_stop()) + break; + + e = brcmf_deq_event(cfg_priv); + if (unlikely(!e)) { + WL_ERR("event queue empty...\n"); + continue; + } + + do { + WL_INFO("event type (%d)\n", e->etype); + if (cfg_priv->el.handler[e->etype]) + cfg_priv->el.handler[e->etype](cfg_priv, + cfg_to_ndev(cfg_priv), + &e->emsg, e->edata); + else + WL_INFO("Unknown Event (%d): ignoring\n", + e->etype); + brcmf_put_event(e); + } while ((e = brcmf_deq_event(cfg_priv))); + } + finish_wait(&cfg_priv->event_waitq, &wait); + WL_INFO("was terminated\n"); + return 0; } static s32 brcmf_create_event_handler(struct brcmf_cfg80211_priv *cfg_priv) @@ -3157,227 +3341,24 @@ static void brcmf_destroy_event_handler(struct brcmf_cfg80211_priv *cfg_priv) } } -static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) +static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv) { - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - struct brcmf_ssid ssid; + brcmf_init_eq_lock(cfg_priv); + INIT_LIST_HEAD(&cfg_priv->eq_list); +} - if (cfg_priv->iscan_on) { - iscan->state = WL_ISCAN_STATE_IDLE; +static void brcmf_flush_eq(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct brcmf_cfg80211_event_q *e; - if (iscan->timer_on) { - del_timer_sync(&iscan->timer); - iscan->timer_on = 0; - } - - cancel_work_sync(&iscan->work); - - /* Abort iscan running in FW */ - memset(&ssid, 0, sizeof(ssid)); - brcmf_run_iscan(iscan, &ssid, WL_SCAN_ACTION_ABORT); + brcmf_lock_eq(cfg_priv); + while (!list_empty(&cfg_priv->eq_list)) { + e = list_first_entry(&cfg_priv->eq_list, + struct brcmf_cfg80211_event_q, eq_list); + list_del(&e->eq_list); + kfree(e); } -} - -static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, - bool aborted) -{ - struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - - if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, - &cfg_priv->status))) { - WL_ERR("Scan complete while device not scanning\n"); - return; - } - if (likely(cfg_priv->scan_request)) { - WL_SCAN("ISCAN Completed scan: %s\n", - aborted ? "Aborted" : "Done"); - cfg80211_scan_done(cfg_priv->scan_request, aborted); - brcmf_set_mpc(ndev, 1); - cfg_priv->scan_request = NULL; - } - cfg_priv->iscan_kickstart = false; -} - -static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) -{ - if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) { - WL_SCAN("wake up iscan\n"); - schedule_work(&iscan->work); - return 0; - } - - return -EIO; -} - -static s32 -brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, - struct brcmf_scan_results **bss_list) -{ - struct brcmf_iscan_results list; - struct brcmf_scan_results *results; - struct brcmf_iscan_results *list_buf; - s32 err = 0; - - memset(iscan->scan_buf, 0, WL_ISCAN_BUF_MAX); - list_buf = (struct brcmf_iscan_results *)iscan->scan_buf; - results = &list_buf->results; - results->buflen = BRCMF_ISCAN_RESULTS_FIXED_SIZE; - results->version = 0; - results->count = 0; - - memset(&list, 0, sizeof(list)); - list.results.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); - err = brcmf_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, - BRCMF_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, - WL_ISCAN_BUF_MAX); - if (unlikely(err)) { - WL_ERR("error (%d)\n", err); - return err; - } - results->buflen = le32_to_cpu(results->buflen); - results->version = le32_to_cpu(results->version); - results->count = le32_to_cpu(results->count); - WL_SCAN("results->count = %d\n", results->count); - WL_SCAN("results->buflen = %d\n", results->buflen); - *status = le32_to_cpu(list_buf->status); - WL_SCAN("status = %d\n", *status); - *bss_list = results; - - return err; -} - -static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - iscan->state = WL_ISCAN_STATE_IDLE; - rtnl_lock(); - brcmf_inform_bss(cfg_priv); - brcmf_notify_iscan_complete(iscan, false); - rtnl_unlock(); - - return err; -} - -static s32 brcmf_iscan_pending(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - /* Reschedule the timer */ - mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); - iscan->timer_on = 1; - - return err; -} - -static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - rtnl_lock(); - brcmf_inform_bss(cfg_priv); - brcmf_run_iscan(iscan, NULL, BRCMF_SCAN_ACTION_CONTINUE); - rtnl_unlock(); - /* Reschedule the timer */ - mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); - iscan->timer_on = 1; - - return err; -} - -static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - iscan->state = WL_ISCAN_STATE_IDLE; - rtnl_lock(); - brcmf_notify_iscan_complete(iscan, true); - rtnl_unlock(); - - return err; -} - -static void brcmf_cfg80211_iscan_handler(struct work_struct *work) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = - container_of(work, struct brcmf_cfg80211_iscan_ctrl, - work); - struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); - struct brcmf_cfg80211_iscan_eloop *el = &iscan->el; - u32 status = BRCMF_SCAN_RESULTS_PARTIAL; - - if (iscan->timer_on) { - del_timer_sync(&iscan->timer); - iscan->timer_on = 0; - } - - rtnl_lock(); - if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) { - status = BRCMF_SCAN_RESULTS_ABORTED; - WL_ERR("Abort iscan\n"); - } - rtnl_unlock(); - - el->handler[status](cfg_priv); -} - -static void brcmf_iscan_timer(unsigned long data) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = - (struct brcmf_cfg80211_iscan_ctrl *)data; - - if (iscan) { - iscan->timer_on = 0; - WL_SCAN("timer expired\n"); - brcmf_wakeup_iscan(iscan); - } -} - -static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - - if (cfg_priv->iscan_on) { - iscan->state = WL_ISCAN_STATE_IDLE; - INIT_WORK(&iscan->work, brcmf_cfg80211_iscan_handler); - } - - return 0; -} - -static void brcmf_init_iscan_eloop(struct brcmf_cfg80211_iscan_eloop *el) -{ - memset(el, 0, sizeof(*el)); - el->handler[BRCMF_SCAN_RESULTS_SUCCESS] = brcmf_iscan_done; - el->handler[BRCMF_SCAN_RESULTS_PARTIAL] = brcmf_iscan_inprogress; - el->handler[BRCMF_SCAN_RESULTS_PENDING] = brcmf_iscan_pending; - el->handler[BRCMF_SCAN_RESULTS_ABORTED] = brcmf_iscan_aborted; - el->handler[BRCMF_SCAN_RESULTS_NO_MEM] = brcmf_iscan_aborted; -} - -static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - int err = 0; - - if (cfg_priv->iscan_on) { - iscan->dev = cfg_to_ndev(cfg_priv); - brcmf_init_iscan_eloop(&iscan->el); - iscan->timer_ms = WL_ISCAN_TIMER_INTERVAL_MS; - init_timer(&iscan->timer); - iscan->timer.data = (unsigned long) iscan; - iscan->timer.function = brcmf_iscan_timer; - err = brcmf_invoke_iscan(cfg_priv); - if (!err) - iscan->data = cfg_priv; - } - - return err; + brcmf_unlock_eq(cfg_priv); } static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) @@ -3490,49 +3471,6 @@ static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv) wake_up(&cfg_priv->event_waitq); } -static s32 brcmf_event_handler(void *data) -{ - struct brcmf_cfg80211_priv *cfg_priv = - (struct brcmf_cfg80211_priv *)data; - struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; - struct brcmf_cfg80211_event_q *e; - DECLARE_WAITQUEUE(wait, current); - - sched_setscheduler(current, SCHED_FIFO, ¶m); - allow_signal(SIGTERM); - add_wait_queue(&cfg_priv->event_waitq, &wait); - while (1) { - prepare_to_wait(&cfg_priv->event_waitq, &wait, - TASK_INTERRUPTIBLE); - - schedule(); - - if (kthread_should_stop()) - break; - - e = brcmf_deq_event(cfg_priv); - if (unlikely(!e)) { - WL_ERR("event queue empty...\n"); - continue; - } - - do { - WL_INFO("event type (%d)\n", e->etype); - if (cfg_priv->el.handler[e->etype]) - cfg_priv->el.handler[e->etype](cfg_priv, - cfg_to_ndev(cfg_priv), - &e->emsg, e->edata); - else - WL_INFO("Unknown Event (%d): ignoring\n", - e->etype); - brcmf_put_event(e); - } while ((e = brcmf_deq_event(cfg_priv))); - } - finish_wait(&cfg_priv->event_waitq, &wait); - WL_INFO("was terminated\n"); - return 0; -} - void brcmf_cfg80211_event(struct net_device *ndev, const struct brcmf_event_msg *e, void *data) @@ -3544,78 +3482,6 @@ brcmf_cfg80211_event(struct net_device *ndev, brcmf_wakeup_event(cfg_priv); } -static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - brcmf_init_eq_lock(cfg_priv); - INIT_LIST_HEAD(&cfg_priv->eq_list); -} - -static void brcmf_flush_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_event_q *e; - - brcmf_lock_eq(cfg_priv); - while (!list_empty(&cfg_priv->eq_list)) { - e = list_first_entry(&cfg_priv->eq_list, - struct brcmf_cfg80211_event_q, eq_list); - list_del(&e->eq_list); - kfree(e); - } - brcmf_unlock_eq(cfg_priv); -} - -/* -* retrieve first queued event from head -*/ - -static struct brcmf_cfg80211_event_q *brcmf_deq_event( - struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_event_q *e = NULL; - - brcmf_lock_eq(cfg_priv); - if (likely(!list_empty(&cfg_priv->eq_list))) { - e = list_first_entry(&cfg_priv->eq_list, - struct brcmf_cfg80211_event_q, eq_list); - list_del(&e->eq_list); - } - brcmf_unlock_eq(cfg_priv); - - return e; -} - -/* -** push event to tail of the queue -*/ - -static s32 -brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, - const struct brcmf_event_msg *msg) -{ - struct brcmf_cfg80211_event_q *e; - s32 err = 0; - - e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); - if (unlikely(!e)) { - WL_ERR("event alloc failed\n"); - return -ENOMEM; - } - - e->etype = event; - memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); - - brcmf_lock_eq(cfg_priv); - list_add_tail(&e->eq_list, &cfg_priv->eq_list); - brcmf_unlock_eq(cfg_priv); - - return err; -} - -static void brcmf_put_event(struct brcmf_cfg80211_event_q *e) -{ - kfree(e); -} - static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) { s32 infra = 0; @@ -3798,6 +3664,35 @@ dongle_scantime_out: return err; } +static s32 wl_update_wiphybands(struct brcmf_cfg80211_priv *cfg_priv) +{ + struct wiphy *wiphy; + s32 phy_list; + s8 phy; + s32 err = 0; + + err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, + &phy_list, sizeof(phy_list)); + if (unlikely(err)) { + WL_ERR("error (%d)\n", err); + return err; + } + + phy = ((char *)&phy_list)[1]; + WL_INFO("%c phy\n", phy); + if (phy == 'n' || phy == 'a') { + wiphy = cfg_to_wiphy(cfg_priv); + wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n; + } + + return err; +} + +static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv) +{ + return wl_update_wiphybands(cfg_priv); +} + static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, bool need_lock) { @@ -3853,30 +3748,40 @@ default_conf_out: } -static s32 wl_update_wiphybands(struct brcmf_cfg80211_priv *cfg_priv) +static int brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv) { - struct wiphy *wiphy; - s32 phy_list; - s8 phy; + char buf[10+IFNAMSIZ]; + struct dentry *fd; s32 err = 0; - err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, - &phy_list, sizeof(phy_list)); - if (unlikely(err)) { - WL_ERR("error (%d)\n", err); - return err; + sprintf(buf, "netdev:%s", cfg_to_ndev(cfg_priv)->name); + cfg_priv->debugfsdir = debugfs_create_dir(buf, + cfg_to_wiphy(cfg_priv)->debugfsdir); + + fd = debugfs_create_u16("beacon_int", S_IRUGO, cfg_priv->debugfsdir, + (u16 *)&cfg_priv->profile->beacon_interval); + if (!fd) { + err = -ENOMEM; + goto err_out; } - phy = ((char *)&phy_list)[1]; - WL_INFO("%c phy\n", phy); - if (phy == 'n' || phy == 'a') { - wiphy = cfg_to_wiphy(cfg_priv); - wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n; + fd = debugfs_create_u8("dtim_period", S_IRUGO, cfg_priv->debugfsdir, + (u8 *)&cfg_priv->profile->dtim_period); + if (!fd) { + err = -ENOMEM; + goto err_out; } +err_out: return err; } +static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv) +{ + debugfs_remove_recursive(cfg_priv->debugfsdir); + cfg_priv->debugfsdir = NULL; +} + static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv) { s32 err = 0; @@ -3958,71 +3863,6 @@ s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev) return err; } -static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv) -{ - return wl_update_wiphybands(cfg_priv); -} - -static void *brcmf_read_prof(struct brcmf_cfg80211_priv *cfg_priv, s32 item) -{ - switch (item) { - case WL_PROF_SEC: - return &cfg_priv->profile->sec; - case WL_PROF_BSSID: - return &cfg_priv->profile->bssid; - case WL_PROF_SSID: - return &cfg_priv->profile->ssid; - } - WL_ERR("invalid item (%d)\n", item); - return NULL; -} - -static s32 -brcmf_update_prof(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e, void *data, s32 item) -{ - s32 err = 0; - struct brcmf_ssid *ssid; - - switch (item) { - case WL_PROF_SSID: - ssid = (struct brcmf_ssid *) data; - memset(cfg_priv->profile->ssid.SSID, 0, - sizeof(cfg_priv->profile->ssid.SSID)); - memcpy(cfg_priv->profile->ssid.SSID, - ssid->SSID, ssid->SSID_len); - cfg_priv->profile->ssid.SSID_len = ssid->SSID_len; - break; - case WL_PROF_BSSID: - if (data) - memcpy(cfg_priv->profile->bssid, data, ETH_ALEN); - else - memset(cfg_priv->profile->bssid, 0, ETH_ALEN); - break; - case WL_PROF_SEC: - memcpy(&cfg_priv->profile->sec, data, - sizeof(cfg_priv->profile->sec)); - break; - case WL_PROF_BEACONINT: - cfg_priv->profile->beacon_interval = *(u16 *)data; - break; - case WL_PROF_DTIMPERIOD: - cfg_priv->profile->dtim_period = *(u8 *)data; - break; - default: - WL_ERR("unsupported item (%d)\n", item); - err = -EOPNOTSUPP; - break; - } - - return err; -} - -static bool brcmf_is_ibssmode(struct brcmf_cfg80211_priv *cfg_priv) -{ - return cfg_priv->conf->mode == WL_MODE_IBSS; -} - static __used s32 brcmf_add_ie(struct brcmf_cfg80211_priv *cfg_priv, u8 t, u8 l, u8 *v) { @@ -4040,109 +3880,3 @@ static __used s32 brcmf_add_ie(struct brcmf_cfg80211_priv *cfg_priv, return err; } - -static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct net_device *dev = NULL; - s32 err = 0; - - WL_TRACE("Enter\n"); - - if (cfg_priv->link_up) { - dev = cfg_to_ndev(cfg_priv); - WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); - err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, NULL, 0); - if (unlikely(err)) - WL_ERR("WLC_DISASSOC failed (%d)\n", err); - cfg_priv->link_up = false; - } - WL_TRACE("Exit\n"); -} - -static void brcmf_lock_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_lock_irq(&cfg_priv->eq_lock); -} - -static void brcmf_unlock_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_unlock_irq(&cfg_priv->eq_lock); -} - -static void brcmf_init_eq_lock(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_lock_init(&cfg_priv->eq_lock); -} - -static void brcmf_delay(u32 ms) -{ - if (ms < 1000 / HZ) { - cond_resched(); - mdelay(ms); - } else { - msleep(ms); - } -} - -static void brcmf_set_drvdata(struct brcmf_cfg80211_dev *dev, void *data) -{ - dev->driver_data = data; -} - -static void *brcmf_get_drvdata(struct brcmf_cfg80211_dev *dev) -{ - void *data = NULL; - - if (dev) - data = dev->driver_data; - return data; -} - -static void brcmf_set_mpc(struct net_device *ndev, int mpc) -{ - s32 err = 0; - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) { - err = brcmf_dev_intvar_set(ndev, "mpc", mpc); - if (unlikely(err)) { - WL_ERR("fail to set mpc\n"); - return; - } - WL_INFO("MPC : %d\n", mpc); - } -} - -static int brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv) -{ - char buf[10+IFNAMSIZ]; - struct dentry *fd; - s32 err = 0; - - sprintf(buf, "netdev:%s", cfg_to_ndev(cfg_priv)->name); - cfg_priv->debugfsdir = debugfs_create_dir(buf, - cfg_to_wiphy(cfg_priv)->debugfsdir); - - fd = debugfs_create_u16("beacon_int", S_IRUGO, cfg_priv->debugfsdir, - (u16 *)&cfg_priv->profile->beacon_interval); - if (!fd) { - err = -ENOMEM; - goto err_out; - } - - fd = debugfs_create_u8("dtim_period", S_IRUGO, cfg_priv->debugfsdir, - (u8 *)&cfg_priv->profile->dtim_period); - if (!fd) { - err = -ENOMEM; - goto err_out; - } - -err_out: - return err; -} - -static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv) -{ - debugfs_remove_recursive(cfg_priv->debugfsdir); - cfg_priv->debugfsdir = NULL; -} From 25bb6c0a94ddd9eb486e41db87466615fad18036 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 8 Sep 2011 15:43:08 -0700 Subject: [PATCH 0992/1519] staging: intel_sst: fix comment typo Signed-off-by: Lu Guanqun Cc: Vinod Koul Acked-by: Vinod Koul Acked-by: Liam Girdwood Acked-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/intel_sst/intel_sst_dsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/intel_sst/intel_sst_dsp.c b/drivers/staging/intel_sst/intel_sst_dsp.c index a89e1ade847..426d2b92073 100644 --- a/drivers/staging/intel_sst/intel_sst_dsp.c +++ b/drivers/staging/intel_sst/intel_sst_dsp.c @@ -104,7 +104,7 @@ static int sst_start_mrst(void) /** * sst_start_medfield - Start the SST DSP processor * - * This starts the DSP in MRST platfroms + * This starts the DSP in Medfield platfroms */ static int sst_start_medfield(void) { From 3037a7b61fa63160f2bd76555aa9ae59c6f71faf Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:37 -0700 Subject: [PATCH 0993/1519] Staging: hv: vmbus: Introduce a utility function to match hv_vmbus_device_id Introduce a utility function to match hv_vmbus_device_id. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 375e45184d2..77f4373ab89 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -272,6 +272,22 @@ static inline bool is_null_guid(const __u8 *guid) return true; } +/* + * Return a matching hv_vmbus_device_id pointer. + * If there is no match, return NULL. + */ +static const struct hv_vmbus_device_id *hv_vmbus_get_id( + const struct hv_vmbus_device_id *id, + __u8 *guid) +{ + for (; !is_null_guid(id->guid); id++) + if (!memcmp(&id->guid, guid, sizeof(uuid_le))) + return id; + + return NULL; +} + + /* * vmbus_match - Attempt to match the specified device to the specified driver @@ -280,12 +296,9 @@ static int vmbus_match(struct device *device, struct device_driver *driver) { struct hv_driver *drv = drv_to_hv_drv(driver); struct hv_device *hv_dev = device_to_hv_device(device); - const struct hv_vmbus_device_id *id_array = drv->id_table; - for (; !is_null_guid(id_array->guid); id_array++) - if (!memcmp(&id_array->guid, &hv_dev->dev_type.b, - sizeof(uuid_le))) - return 1; + if (hv_vmbus_get_id(drv->id_table, hv_dev->dev_type.b)) + return 1; return 0; } From 84946899bd50035c50d88da9da809aa25de60471 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:38 -0700 Subject: [PATCH 0994/1519] Staging: hv: vmbus: Change the signature of struct hv_driver probe function In preparation to leveraging the driver_data field in struct hv_vmbus_device_id, change the signature of struct hv_driver probe function. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 3 ++- drivers/staging/hv/hv_util.c | 3 ++- drivers/staging/hv/hyperv.h | 2 +- drivers/staging/hv/netvsc_drv.c | 3 ++- drivers/staging/hv/storvsc_drv.c | 3 ++- drivers/staging/hv/vmbus_drv.c | 4 +++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index dbb04ee4e96..5ff8a035cd7 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -823,7 +823,8 @@ static int mousevsc_on_device_remove(struct hv_device *device) } -static int mousevsc_probe(struct hv_device *dev) +static int mousevsc_probe(struct hv_device *dev, + const struct hv_vmbus_device_id *dev_id) { int ret = 0; diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index 603921771b9..d9460fdd9e4 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -239,7 +239,8 @@ static void heartbeat_onchannelcallback(void *context) * The devices managed by the util driver don't need any additional * setup. */ -static int util_probe(struct hv_device *dev) +static int util_probe(struct hv_device *dev, + const struct hv_vmbus_device_id *dev_id) { return 0; } diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index c24981198b1..caa3a7ba837 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -810,7 +810,7 @@ struct hv_driver { struct device_driver driver; - int (*probe)(struct hv_device *); + int (*probe)(struct hv_device *, const struct hv_vmbus_device_id *); int (*remove)(struct hv_device *); void (*shutdown)(struct hv_device *); diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 30b9c80e200..d06cde29bef 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -329,7 +329,8 @@ static void netvsc_send_garp(struct work_struct *w) } -static int netvsc_probe(struct hv_device *dev) +static int netvsc_probe(struct hv_device *dev, + const struct hv_vmbus_device_id *dev_id) { struct net_device *net = NULL; struct net_device_context *net_device_ctx; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index b0c4e56304e..fff1e5b936f 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1380,7 +1380,8 @@ MODULE_DEVICE_TABLE(vmbus, id_table); * storvsc_probe - Add a new device for this driver */ -static int storvsc_probe(struct hv_device *device) +static int storvsc_probe(struct hv_device *device, + const struct hv_vmbus_device_id *dev_id) { int ret; struct Scsi_Host *host; diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 77f4373ab89..2fccb1f974c 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -312,9 +312,11 @@ static int vmbus_probe(struct device *child_device) struct hv_driver *drv = drv_to_hv_drv(child_device->driver); struct hv_device *dev = device_to_hv_device(child_device); + const struct hv_vmbus_device_id *dev_id; + dev_id = hv_vmbus_get_id(drv->id_table, dev->dev_type.b); if (drv->probe) { - ret = drv->probe(dev); + ret = drv->probe(dev, dev_id); if (ret != 0) pr_err("probe failed for device %s (%d)\n", dev_name(child_device), ret); From ef52a81bf5b229d74b76a25c5de22ae10e1fbb77 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:39 -0700 Subject: [PATCH 0995/1519] Staging: hv: storvsc: Use the driver_data to identify ide Use the driver_data to identify ide devices in storvsc_probe(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index fff1e5b936f..b996293640b 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1359,17 +1359,20 @@ static struct scsi_host_template scsi_driver = { .dma_boundary = PAGE_SIZE-1, }; -/* - * The storvsc_probe function assumes that the IDE guid - * is the second entry. - */ +enum { + SCSI_GUID, + IDE_GUID, +}; + static const struct hv_vmbus_device_id id_table[] = { /* SCSI guid */ { VMBUS_DEVICE(0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, - 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) }, + 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) + .driver_data = SCSI_GUID }, /* IDE guid */ { VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) }, + 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) + .driver_data = IDE_GUID }, { }, }; @@ -1387,15 +1390,10 @@ static int storvsc_probe(struct hv_device *device, struct Scsi_Host *host; struct hv_host_device *host_dev; struct storvsc_device_info device_info; - bool dev_is_ide; + bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false); int path = 0; int target = 0; - if (!memcmp(&device->dev_type.b, id_table[1].guid, sizeof(uuid_le))) - dev_is_ide = true; - else - dev_is_ide = false; - host = scsi_host_alloc(&scsi_driver, sizeof(struct hv_host_device)); if (!host) From ab101e86d0f2c00c11aec5b16e27246ccecb0870 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:40 -0700 Subject: [PATCH 0996/1519] Staging: hv: vmbus: Introduce functions for setting and getting driver data Introduce vmbus specific wrapper functions to set/get driver specific data. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index caa3a7ba837..91e557b2fd1 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -843,6 +843,15 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d) return container_of(d, struct hv_driver, driver); } +static inline void hv_set_drvdata(struct hv_device *dev, void *data) +{ + dev_set_drvdata(&dev->device, data); +} + +static inline void *hv_get_drvdata(struct hv_device *dev) +{ + return dev_get_drvdata(&dev->device); +} /* Vmbus interface */ #define vmbus_driver_register(driver) \ From d4372179c85b50cf0a468c1d573113056b0c46a0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:44 -0700 Subject: [PATCH 0997/1519] Staging: hv: vmbus: Cleanup vmbus_remove() vmbus_remove() cannot fail; clean it up accordingly. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 2fccb1f974c..466425a5ed3 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -334,22 +334,14 @@ static int vmbus_probe(struct device *child_device) */ static int vmbus_remove(struct device *child_device) { - int ret; - struct hv_driver *drv; - + struct hv_driver *drv = drv_to_hv_drv(child_device->driver); struct hv_device *dev = device_to_hv_device(child_device); - if (child_device->driver) { - drv = drv_to_hv_drv(child_device->driver); - - if (drv->remove) { - ret = drv->remove(dev); - } else { - pr_err("remove not set for driver %s\n", - dev_name(child_device)); - ret = -ENODEV; - } - } + if (drv->remove) + drv->remove(dev); + else + pr_err("remove not set for driver %s\n", + dev_name(child_device)); return 0; } From 6e4198ce18859953019d8f32f71e3a7aa309b72d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:45 -0700 Subject: [PATCH 0998/1519] Staging: hv: storvsc: Get rid of storvsc_dev_add() by inlining the code Get rid of storvsc_dev_add() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 60 ++++++++------------------------ 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index b996293640b..2210c8c8d68 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -651,41 +651,6 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) return ret; } -static int storvsc_dev_add(struct hv_device *device, - void *additional_info) -{ - struct storvsc_device *stor_device; - struct storvsc_device_info *device_info; - int ret = 0; - - device_info = (struct storvsc_device_info *)additional_info; - stor_device = alloc_stor_device(device); - if (!stor_device) - return -ENOMEM; - - /* Save the channel properties to our storvsc channel */ - - /* - * If we support more than 1 scsi channel, we need to set the - * port number here to the scsi channel but how do we get the - * scsi channel prior to the bus scan. - * - * The host does not support this. - */ - - stor_device->port_number = device_info->port_number; - /* Send it back up */ - ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size); - if (ret) { - kfree(stor_device); - return ret; - } - device_info->path_id = stor_device->path_id; - device_info->target_id = stor_device->target_id; - - return ret; -} - static int storvsc_dev_remove(struct hv_device *device) { struct storvsc_device *stor_device; @@ -1389,10 +1354,10 @@ static int storvsc_probe(struct hv_device *device, int ret; struct Scsi_Host *host; struct hv_host_device *host_dev; - struct storvsc_device_info device_info; bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false); int path = 0; int target = 0; + struct storvsc_device *stor_device; host = scsi_host_alloc(&scsi_driver, sizeof(struct hv_host_device)); @@ -1417,22 +1382,27 @@ static int storvsc_probe(struct hv_device *device, return -ENOMEM; } - device_info.port_number = host->host_no; - device_info.ring_buffer_size = storvsc_ringbuffer_size; - /* Call to the vsc driver to add the device */ - ret = storvsc_dev_add(device, (void *)&device_info); - - if (ret != 0) { + stor_device = alloc_stor_device(device); + if (!stor_device) { kmem_cache_destroy(host_dev->request_pool); scsi_host_put(host); - return -ENODEV; + return -ENOMEM; + } + + stor_device->port_number = host->host_no; + ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size); + if (ret) { + kmem_cache_destroy(host_dev->request_pool); + scsi_host_put(host); + kfree(stor_device); + return ret; } if (dev_is_ide) storvsc_get_ide_info(device, &target, &path); - host_dev->path = device_info.path_id; - host_dev->target = device_info.target_id; + host_dev->path = stor_device->path_id; + host_dev->target = stor_device->target_id; /* max # of devices per target */ host->max_lun = STORVSC_MAX_LUNS_PER_TARGET; From a13d35ab9fdcc8e40af570039120a35179426c08 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:46 -0700 Subject: [PATCH 0999/1519] Staging: hv: storvsc: Get rid of alloc_stor_device() by inlining the code Get rid of alloc_stor_device() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 2210c8c8d68..ce8652e3d74 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -332,23 +332,6 @@ static inline void storvsc_wait_to_drain(struct storvsc_device *dev) dev->drain_notify = false; } -static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) -{ - struct storvsc_device *stor_device; - - stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL); - if (!stor_device) - return NULL; - - stor_device->destroy = false; - init_waitqueue_head(&stor_device->waiting_to_drain); - stor_device->device = device; - device->ext = stor_device; - - return stor_device; -} - - static inline struct storvsc_device *get_in_stor_device( struct hv_device *device) { @@ -1382,13 +1365,18 @@ static int storvsc_probe(struct hv_device *device, return -ENOMEM; } - stor_device = alloc_stor_device(device); + stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL); if (!stor_device) { kmem_cache_destroy(host_dev->request_pool); scsi_host_put(host); return -ENOMEM; } + stor_device->destroy = false; + init_waitqueue_head(&stor_device->waiting_to_drain); + stor_device->device = device; + device->ext = stor_device; + stor_device->port_number = host->host_no; ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size); if (ret) { From f810d592a29314ade8cce29f8dac858c90a50409 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:47 -0700 Subject: [PATCH 1000/1519] Staging: hv: storvsc: Get rid of some unnecessary state and definitions Now, get rid of some unnecessary state and definitions. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index ce8652e3d74..5e306a5e567 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -245,7 +245,6 @@ enum storvsc_request_type { struct hv_storvsc_request { - struct hv_storvsc_request *request; struct hv_device *device; /* Synchronize the request/response if needed */ @@ -260,14 +259,6 @@ struct hv_storvsc_request { }; -struct storvsc_device_info { - u32 ring_buffer_size; - unsigned int port_number; - unsigned char path_id; - unsigned char target_id; -}; - - /* A storvsc device is a device object that contains a vmbus channel */ struct storvsc_device { struct hv_device *device; From cd654ea1cc72aed95e871971d87c4a988924fdda Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:48 -0700 Subject: [PATCH 1001/1519] Staging: hv: storvsc: Eliminate the usage of ext field in struct hv_device Now, eliminate the usage of ext field in struct hv_device for storvsc driver. We do this by registering pointer to struct storvsc_device as the driver specific data and eliminating the current usage of driver specific data to save and retrieve the pointer to struct Scsi_Host. Additionally, all access to the driver specific data is through the vmbus wrapper functions. Note that function to allocate the host gives us a reference on the host object. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 5e306a5e567..807c94d711c 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -266,6 +266,7 @@ struct storvsc_device { bool destroy; bool drain_notify; atomic_t num_outstanding_req; + struct Scsi_Host *host; wait_queue_head_t waiting_to_drain; @@ -306,7 +307,7 @@ static inline struct storvsc_device *get_out_stor_device( { struct storvsc_device *stor_device; - stor_device = (struct storvsc_device *)device->ext; + stor_device = hv_get_drvdata(device); if (stor_device && stor_device->destroy) stor_device = NULL; @@ -328,7 +329,7 @@ static inline struct storvsc_device *get_in_stor_device( { struct storvsc_device *stor_device; - stor_device = (struct storvsc_device *)device->ext; + stor_device = hv_get_drvdata(device); if (!stor_device) goto get_in_err; @@ -480,8 +481,7 @@ static void storvsc_on_io_completion(struct hv_device *device, struct storvsc_device *stor_device; struct vstor_packet *stor_pkt; - stor_device = (struct storvsc_device *)device->ext; - + stor_device = hv_get_drvdata(device); stor_pkt = &request->vstor_packet; /* @@ -630,7 +630,7 @@ static int storvsc_dev_remove(struct hv_device *device) struct storvsc_device *stor_device; unsigned long flags; - stor_device = (struct storvsc_device *)device->ext; + stor_device = hv_get_drvdata(device); spin_lock_irqsave(&device->channel->inbound_lock, flags); stor_device->destroy = true; @@ -652,7 +652,7 @@ static int storvsc_dev_remove(struct hv_device *device) * allow incoming packets. */ spin_lock_irqsave(&device->channel->inbound_lock, flags); - device->ext = NULL; + hv_set_drvdata(device, NULL); spin_unlock_irqrestore(&device->channel->inbound_lock, flags); /* Close the channel */ @@ -962,7 +962,8 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, static int storvsc_remove(struct hv_device *dev) { - struct Scsi_Host *host = dev_get_drvdata(&dev->device); + struct storvsc_device *stor_device = hv_get_drvdata(dev); + struct Scsi_Host *host = stor_device->host; struct hv_host_device *host_dev = (struct hv_host_device *)host->hostdata; @@ -1338,8 +1339,6 @@ static int storvsc_probe(struct hv_device *device, if (!host) return -ENOMEM; - dev_set_drvdata(&device->device, host); - host_dev = (struct hv_host_device *)host->hostdata; memset(host_dev, 0, sizeof(struct hv_host_device)); @@ -1366,7 +1365,8 @@ static int storvsc_probe(struct hv_device *device, stor_device->destroy = false; init_waitqueue_head(&stor_device->waiting_to_drain); stor_device->device = device; - device->ext = stor_device; + stor_device->host = host; + hv_set_drvdata(device, stor_device); stor_device->port_number = host->host_no; ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size); From 2ddd5e5fb342b9f014d61941a4f73c0bd9b50a60 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:49 -0700 Subject: [PATCH 1002/1519] Staging: hv: netvsc: Get rid of the usage of the ext field in struct hv_device Now, eliminate the usage of ext field in struct hv_device for netvsc driver. We do this by registering pointer to struct netvsc_device as the driver specific data and eliminating the current usage of driver specific data to save and retrieve the pointer to struct net_device. Additionally, all access to the driver specific data is through the vmbus wrapper functions. As part of this cleanup, we also get rid of some unnecessary debug print statements. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv_net.h | 2 + drivers/staging/hv/netvsc.c | 86 +++++++++++++++---------------- drivers/staging/hv/netvsc_drv.c | 24 +++++++-- drivers/staging/hv/rndis_filter.c | 28 ++++++---- 4 files changed, 83 insertions(+), 57 deletions(-) diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h index af8a37fb502..366dd2b32b1 100644 --- a/drivers/staging/hv/hyperv_net.h +++ b/drivers/staging/hv/hyperv_net.h @@ -392,6 +392,8 @@ struct netvsc_device { struct nvsp_message revoke_packet; /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */ + struct net_device *ndev; + /* Holds rndis device info */ void *extension; }; diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 115629f2d69..2bcc8b2b9b3 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -35,6 +35,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) { struct netvsc_device *net_device; + struct net_device *ndev = hv_get_drvdata(device); net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); if (!net_device) @@ -43,8 +44,9 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) net_device->destroy = false; net_device->dev = device; - device->ext = net_device; + net_device->ndev = ndev; + hv_set_drvdata(device, net_device); return net_device; } @@ -52,7 +54,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) { struct netvsc_device *net_device; - net_device = device->ext; + net_device = hv_get_drvdata(device); if (net_device && net_device->destroy) net_device = NULL; @@ -63,7 +65,7 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device) { struct netvsc_device *net_device; - net_device = device->ext; + net_device = hv_get_drvdata(device); if (!net_device) goto get_in_err; @@ -81,7 +83,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) { struct nvsp_message *revoke_packet; int ret = 0; - struct net_device *ndev = dev_get_drvdata(&net_device->dev->device); + struct net_device *ndev = net_device->ndev; /* * If we got a section count, it means we received a @@ -153,14 +155,12 @@ static int netvsc_init_recv_buf(struct hv_device *device) int t; struct netvsc_device *net_device; struct nvsp_message *init_packet; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; net_device = get_outbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "unable to get net device..." - "device being destroyed?\n"); + if (!net_device) return -ENODEV; - } + ndev = net_device->ndev; net_device->recv_buf = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, @@ -269,14 +269,12 @@ static int netvsc_connect_vsp(struct hv_device *device) struct netvsc_device *net_device; struct nvsp_message *init_packet; int ndis_version; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; net_device = get_outbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "unable to get net device..." - "device being destroyed?\n"); + if (!net_device) return -ENODEV; - } + ndev = net_device->ndev; init_packet = &net_device->channel_init_pkt; @@ -357,7 +355,7 @@ int netvsc_device_remove(struct hv_device *device) struct hv_netvsc_packet *netvsc_packet, *pos; unsigned long flags; - net_device = (struct netvsc_device *)device->ext; + net_device = hv_get_drvdata(device); spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device->destroy = true; spin_unlock_irqrestore(&device->channel->inbound_lock, flags); @@ -381,7 +379,7 @@ int netvsc_device_remove(struct hv_device *device) */ spin_lock_irqsave(&device->channel->inbound_lock, flags); - device->ext = NULL; + hv_set_drvdata(device, NULL); spin_unlock_irqrestore(&device->channel->inbound_lock, flags); /* At this point, no one should be accessing netDevice except in here */ @@ -407,14 +405,12 @@ static void netvsc_send_completion(struct hv_device *device, struct netvsc_device *net_device; struct nvsp_message *nvsp_packet; struct hv_netvsc_packet *nvsc_packet; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; net_device = get_inbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "unable to get net device..." - "device being destroyed?\n"); + if (!net_device) return; - } + ndev = net_device->ndev; nvsp_packet = (struct nvsp_message *)((unsigned long)packet + (packet->offset8 << 3)); @@ -452,14 +448,12 @@ int netvsc_send(struct hv_device *device, struct netvsc_device *net_device; int ret = 0; struct nvsp_message sendMessage; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; net_device = get_outbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "net device (%p) shutting down..." - "ignoring outbound packets\n", net_device); + if (!net_device) return -ENODEV; - } + ndev = net_device->ndev; sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT; if (packet->is_data_pkt) { @@ -506,7 +500,10 @@ static void netvsc_send_recv_completion(struct hv_device *device, struct nvsp_message recvcompMessage; int retries = 0; int ret; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; + struct netvsc_device *net_device = hv_get_drvdata(device); + + ndev = net_device->ndev; recvcompMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE; @@ -552,7 +549,7 @@ static void netvsc_receive_completion(void *context) u64 transaction_id = 0; bool fsend_receive_comp = false; unsigned long flags; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; /* * Even though it seems logical to do a GetOutboundNetDevice() here to @@ -560,11 +557,9 @@ static void netvsc_receive_completion(void *context) * since we may have disable outbound traffic already. */ net_device = get_inbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "unable to get net device..." - "device being destroyed?\n"); + if (!net_device) return; - } + ndev = net_device->ndev; /* Overloading use of the lock. */ spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags); @@ -607,16 +602,14 @@ static void netvsc_receive(struct hv_device *device, int i, j; int count = 0, bytes_remain = 0; unsigned long flags; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; LIST_HEAD(listHead); net_device = get_inbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "unable to get net device..." - "device being destroyed?\n"); + if (!net_device) return; - } + ndev = net_device->ndev; /* * All inbound packets other than send completion should be xfer page @@ -784,7 +777,7 @@ static void netvsc_channel_cb(void *context) struct vmpacket_descriptor *desc; unsigned char *buffer; int bufferlen = NETVSC_PACKET_SIZE; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), GFP_ATOMIC); @@ -793,11 +786,9 @@ static void netvsc_channel_cb(void *context) buffer = packet; net_device = get_inbound_net_device(device); - if (!net_device) { - netdev_err(ndev, "net device (%p) shutting down..." - "ignoring inbound packets\n", net_device); + if (!net_device) goto out; - } + ndev = net_device->ndev; do { ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, @@ -871,7 +862,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ((struct netvsc_device_info *)additional_info)->ring_size; struct netvsc_device *net_device; struct hv_netvsc_packet *packet, *pos; - struct net_device *ndev = dev_get_drvdata(&device->device); + struct net_device *ndev; net_device = alloc_net_device(device); if (!net_device) { @@ -879,6 +870,15 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) goto cleanup; } + /* + * Coming into this function, struct net_device * is + * registered as the driver private data. + * In alloc_net_device(), we register struct netvsc_device * + * as the driver private data and stash away struct net_device * + * in struct netvsc_device *. + */ + ndev = net_device->ndev; + /* Initialize the NetVSC channel extension */ net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; spin_lock_init(&net_device->recv_pkt_list_lock); diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index d06cde29bef..69c233e5fbe 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -203,8 +203,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) void netvsc_linkstatus_callback(struct hv_device *device_obj, unsigned int status) { - struct net_device *net = dev_get_drvdata(&device_obj->device); + struct net_device *net; struct net_device_context *ndev_ctx; + struct netvsc_device *net_device; + + net_device = hv_get_drvdata(device_obj); + net = net_device->ndev; if (!net) { netdev_err(net, "got link status but net device " @@ -236,6 +240,10 @@ int netvsc_recv_callback(struct hv_device *device_obj, void *data; int i; unsigned long flags; + struct netvsc_device *net_device; + + net_device = hv_get_drvdata(device_obj); + net = net_device->ndev; if (!net) { netdev_err(net, "got receive callback but net device" @@ -322,9 +330,11 @@ static void netvsc_send_garp(struct work_struct *w) { struct net_device_context *ndev_ctx; struct net_device *net; + struct netvsc_device *net_device; ndev_ctx = container_of(w, struct net_device_context, dwork.work); - net = dev_get_drvdata(&ndev_ctx->device_ctx->device); + net_device = hv_get_drvdata(ndev_ctx->device_ctx); + net = net_device->ndev; netif_notify_peers(net); } @@ -347,7 +357,7 @@ static int netvsc_probe(struct hv_device *dev, net_device_ctx = netdev_priv(net); net_device_ctx->device_ctx = dev; atomic_set(&net_device_ctx->avail, ring_size); - dev_set_drvdata(&dev->device, net); + hv_set_drvdata(dev, net); INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp); net->netdev_ops = &device_ops; @@ -373,7 +383,7 @@ static int netvsc_probe(struct hv_device *dev, netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); unregister_netdev(net); free_netdev(net); - dev_set_drvdata(&dev->device, NULL); + hv_set_drvdata(dev, NULL); return ret; } memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); @@ -386,8 +396,12 @@ out: static int netvsc_remove(struct hv_device *dev) { - struct net_device *net = dev_get_drvdata(&dev->device); + struct net_device *net; struct net_device_context *ndev_ctx; + struct netvsc_device *net_device; + + net_device = hv_get_drvdata(dev); + net = net_device->ndev; if (net == NULL) { dev_err(&dev->device, "No net device to remove\n"); diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index b32534507d4..b354b0b6236 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -141,7 +141,11 @@ static void put_rndis_request(struct rndis_device *dev, static void dump_rndis_message(struct hv_device *hv_dev, struct rndis_message *rndis_msg) { - struct net_device *netdev = dev_get_drvdata(&hv_dev->device); + struct net_device *netdev; + struct netvsc_device *net_device; + + net_device = hv_get_drvdata(hv_dev); + netdev = net_device->ndev; switch (rndis_msg->ndis_msg_type) { case REMOTE_NDIS_PACKET_MSG: @@ -249,7 +253,9 @@ static void rndis_filter_receive_response(struct rndis_device *dev, struct rndis_request *request = NULL; bool found = false; unsigned long flags; - struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device); + struct net_device *ndev; + + ndev = dev->net_dev->ndev; spin_lock_irqsave(&dev->request_lock, flags); list_for_each_entry(request, &dev->req_list, list_ent) { @@ -356,11 +362,13 @@ static void rndis_filter_receive_data(struct rndis_device *dev, int rndis_filter_receive(struct hv_device *dev, struct hv_netvsc_packet *pkt) { - struct netvsc_device *net_dev = dev->ext; + struct netvsc_device *net_dev = hv_get_drvdata(dev); struct rndis_device *rndis_dev; struct rndis_message rndis_msg; struct rndis_message *rndis_hdr; - struct net_device *ndev = dev_get_drvdata(&dev->device); + struct net_device *ndev; + + ndev = net_dev->ndev; if (!net_dev) return -EINVAL; @@ -517,7 +525,9 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, struct rndis_set_complete *set_complete; u32 status; int ret, t; - struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device); + struct net_device *ndev; + + ndev = dev->net_dev->ndev; request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG, RNDIS_MESSAGE_SIZE(struct rndis_set_request) + @@ -700,7 +710,7 @@ int rndis_filter_device_add(struct hv_device *dev, /* Initialize the rndis device */ - netDevice = dev->ext; + netDevice = hv_get_drvdata(dev); netDevice->extension = rndisDevice; rndisDevice->net_dev = netDevice; @@ -737,7 +747,7 @@ int rndis_filter_device_add(struct hv_device *dev, void rndis_filter_device_remove(struct hv_device *dev) { - struct netvsc_device *net_dev = dev->ext; + struct netvsc_device *net_dev = hv_get_drvdata(dev); struct rndis_device *rndis_dev = net_dev->extension; /* Halt and release the rndis device */ @@ -752,7 +762,7 @@ void rndis_filter_device_remove(struct hv_device *dev) int rndis_filter_open(struct hv_device *dev) { - struct netvsc_device *netDevice = dev->ext; + struct netvsc_device *netDevice = hv_get_drvdata(dev); if (!netDevice) return -EINVAL; @@ -762,7 +772,7 @@ int rndis_filter_open(struct hv_device *dev) int rndis_filter_close(struct hv_device *dev) { - struct netvsc_device *netDevice = dev->ext; + struct netvsc_device *netDevice = hv_get_drvdata(dev); if (!netDevice) return -EINVAL; From 80e623887ef6a86718ecab257c592e214ecad82d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:50 -0700 Subject: [PATCH 1003/1519] Staging: hv: mousevsc: Get rid of the usage of the ext field in struct hv_device Get rid of the usage of the ext field in struct hv_device for the mouse driver. We do this by using the newly introduced functions to set and and get driver specific data. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 5ff8a035cd7..fcb023af4b3 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -196,7 +196,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) atomic_cmpxchg(&input_dev->ref_count, 0, 2); input_dev->device = device; - device->ext = input_dev; + hv_set_drvdata(device, input_dev); return input_dev; } @@ -214,7 +214,7 @@ static struct mousevsc_dev *get_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; - input_dev = (struct mousevsc_dev *)device->ext; + input_dev = hv_get_drvdata(device); /* * FIXME @@ -240,7 +240,7 @@ static struct mousevsc_dev *must_get_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; - input_dev = (struct mousevsc_dev *)device->ext; + input_dev = hv_get_drvdata(device); if (input_dev && atomic_read(&input_dev->ref_count)) atomic_inc(&input_dev->ref_count); @@ -254,7 +254,7 @@ static void put_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; - input_dev = (struct mousevsc_dev *)device->ext; + input_dev = hv_get_drvdata(device); atomic_dec(&input_dev->ref_count); } @@ -266,7 +266,7 @@ static struct mousevsc_dev *release_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; - input_dev = (struct mousevsc_dev *)device->ext; + input_dev = hv_get_drvdata(device); /* Busy wait until the ref drop to 2, then set it to 1 */ while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2) @@ -282,13 +282,13 @@ static struct mousevsc_dev *final_release_input_device(struct hv_device *device) { struct mousevsc_dev *input_dev; - input_dev = (struct mousevsc_dev *)device->ext; + input_dev = hv_get_drvdata(device); /* Busy wait until the ref drop to 1, then set it to 0 */ while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1) udelay(100); - device->ext = NULL; + hv_set_drvdata(device, NULL); return input_dev; } @@ -790,7 +790,7 @@ static int mousevsc_on_device_remove(struct hv_device *device) int ret = 0; pr_info("disabling input device (%p)...", - device->ext); + hv_get_drvdata(device)); input_dev = release_input_device(device); @@ -808,7 +808,7 @@ static int mousevsc_on_device_remove(struct hv_device *device) udelay(100); } - pr_info("removing input device (%p)...", device->ext); + pr_info("removing input device (%p)...", hv_get_drvdata(device)); input_dev = final_release_input_device(device); From b0bb55175f846909e06952583e38982a77f7ecea Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:51 -0700 Subject: [PATCH 1004/1519] Staging: hv: vmbus: Get rid of the ext field in struct hv_device Now that we have eliminated all uses of the ext field in struct hv_device, get rid of the ext field. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hyperv.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 91e557b2fd1..76e2ddd437d 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -827,9 +827,6 @@ struct hv_device { struct device device; struct vmbus_channel *channel; - - /* Device extension; */ - void *ext; }; From 7bb52384b2678fcbcebfa97be8f98dfb3219edc1 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:52 -0700 Subject: [PATCH 1005/1519] Staging: hv: vmbus: Do not allocate struct hv_device_info on the stack struct hv_device_info is about 101 bytes in size. Do not allocate this structure on the stack. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 134 +++++++++++++++++---------------- 1 file changed, 69 insertions(+), 65 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 466425a5ed3..d2562afcce4 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -112,101 +112,105 @@ static ssize_t vmbus_show_device_attr(struct device *dev, char *buf) { struct hv_device *hv_dev = device_to_hv_device(dev); - struct hv_device_info device_info; + struct hv_device_info *device_info; char alias_name[VMBUS_ALIAS_LEN + 1]; + int ret = 0; - memset(&device_info, 0, sizeof(struct hv_device_info)); + device_info = kzalloc(sizeof(struct hv_device_info), GFP_KERNEL); + if (!device_info) + return ret; - get_channel_info(hv_dev, &device_info); + get_channel_info(hv_dev, device_info); if (!strcmp(dev_attr->attr.name, "class_id")) { - return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" + ret = sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_type.b[3], - device_info.chn_type.b[2], - device_info.chn_type.b[1], - device_info.chn_type.b[0], - device_info.chn_type.b[5], - device_info.chn_type.b[4], - device_info.chn_type.b[7], - device_info.chn_type.b[6], - device_info.chn_type.b[8], - device_info.chn_type.b[9], - device_info.chn_type.b[10], - device_info.chn_type.b[11], - device_info.chn_type.b[12], - device_info.chn_type.b[13], - device_info.chn_type.b[14], - device_info.chn_type.b[15]); + device_info->chn_type.b[3], + device_info->chn_type.b[2], + device_info->chn_type.b[1], + device_info->chn_type.b[0], + device_info->chn_type.b[5], + device_info->chn_type.b[4], + device_info->chn_type.b[7], + device_info->chn_type.b[6], + device_info->chn_type.b[8], + device_info->chn_type.b[9], + device_info->chn_type.b[10], + device_info->chn_type.b[11], + device_info->chn_type.b[12], + device_info->chn_type.b[13], + device_info->chn_type.b[14], + device_info->chn_type.b[15]); } else if (!strcmp(dev_attr->attr.name, "device_id")) { - return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" + ret = sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_instance.b[3], - device_info.chn_instance.b[2], - device_info.chn_instance.b[1], - device_info.chn_instance.b[0], - device_info.chn_instance.b[5], - device_info.chn_instance.b[4], - device_info.chn_instance.b[7], - device_info.chn_instance.b[6], - device_info.chn_instance.b[8], - device_info.chn_instance.b[9], - device_info.chn_instance.b[10], - device_info.chn_instance.b[11], - device_info.chn_instance.b[12], - device_info.chn_instance.b[13], - device_info.chn_instance.b[14], - device_info.chn_instance.b[15]); + device_info->chn_instance.b[3], + device_info->chn_instance.b[2], + device_info->chn_instance.b[1], + device_info->chn_instance.b[0], + device_info->chn_instance.b[5], + device_info->chn_instance.b[4], + device_info->chn_instance.b[7], + device_info->chn_instance.b[6], + device_info->chn_instance.b[8], + device_info->chn_instance.b[9], + device_info->chn_instance.b[10], + device_info->chn_instance.b[11], + device_info->chn_instance.b[12], + device_info->chn_instance.b[13], + device_info->chn_instance.b[14], + device_info->chn_instance.b[15]); } else if (!strcmp(dev_attr->attr.name, "modalias")) { print_alias_name(hv_dev, alias_name); - return sprintf(buf, "vmbus:%s\n", alias_name); + ret = sprintf(buf, "vmbus:%s\n", alias_name); } else if (!strcmp(dev_attr->attr.name, "state")) { - return sprintf(buf, "%d\n", device_info.chn_state); + ret = sprintf(buf, "%d\n", device_info->chn_state); } else if (!strcmp(dev_attr->attr.name, "id")) { - return sprintf(buf, "%d\n", device_info.chn_id); + ret = sprintf(buf, "%d\n", device_info->chn_id); } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) { - return sprintf(buf, "%d\n", device_info.outbound.int_mask); + ret = sprintf(buf, "%d\n", device_info->outbound.int_mask); } else if (!strcmp(dev_attr->attr.name, "out_read_index")) { - return sprintf(buf, "%d\n", device_info.outbound.read_idx); + ret = sprintf(buf, "%d\n", device_info->outbound.read_idx); } else if (!strcmp(dev_attr->attr.name, "out_write_index")) { - return sprintf(buf, "%d\n", device_info.outbound.write_idx); + ret = sprintf(buf, "%d\n", device_info->outbound.write_idx); } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.outbound.bytes_avail_toread); + ret = sprintf(buf, "%d\n", + device_info->outbound.bytes_avail_toread); } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.outbound.bytes_avail_towrite); + ret = sprintf(buf, "%d\n", + device_info->outbound.bytes_avail_towrite); } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) { - return sprintf(buf, "%d\n", device_info.inbound.int_mask); + ret = sprintf(buf, "%d\n", device_info->inbound.int_mask); } else if (!strcmp(dev_attr->attr.name, "in_read_index")) { - return sprintf(buf, "%d\n", device_info.inbound.read_idx); + ret = sprintf(buf, "%d\n", device_info->inbound.read_idx); } else if (!strcmp(dev_attr->attr.name, "in_write_index")) { - return sprintf(buf, "%d\n", device_info.inbound.write_idx); + ret = sprintf(buf, "%d\n", device_info->inbound.write_idx); } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.inbound.bytes_avail_toread); + ret = sprintf(buf, "%d\n", + device_info->inbound.bytes_avail_toread); } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.inbound.bytes_avail_towrite); + ret = sprintf(buf, "%d\n", + device_info->inbound.bytes_avail_towrite); } else if (!strcmp(dev_attr->attr.name, "monitor_id")) { - return sprintf(buf, "%d\n", device_info.monitor_id); + ret = sprintf(buf, "%d\n", device_info->monitor_id); } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) { - return sprintf(buf, "%d\n", device_info.server_monitor_pending); + ret = sprintf(buf, "%d\n", device_info->server_monitor_pending); } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) { - return sprintf(buf, "%d\n", device_info.server_monitor_latency); + ret = sprintf(buf, "%d\n", device_info->server_monitor_latency); } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) { - return sprintf(buf, "%d\n", - device_info.server_monitor_conn_id); + ret = sprintf(buf, "%d\n", + device_info->server_monitor_conn_id); } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) { - return sprintf(buf, "%d\n", device_info.client_monitor_pending); + ret = sprintf(buf, "%d\n", device_info->client_monitor_pending); } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) { - return sprintf(buf, "%d\n", device_info.client_monitor_latency); + ret = sprintf(buf, "%d\n", device_info->client_monitor_latency); } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) { - return sprintf(buf, "%d\n", - device_info.client_monitor_conn_id); - } else { - return 0; + ret = sprintf(buf, "%d\n", + device_info->client_monitor_conn_id); } + + kfree(device_info); + return ret; } /* Set up per device attributes in /sys/bus/vmbus/devices/ */ From d982042b9b62f3a966e7de5572fd30d131eb5357 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:53 -0700 Subject: [PATCH 1006/1519] Staging: hv: vmbus: Get rid of the module dependency Hyper-V modules can be built as part of the kernel (not just as modules). Get rid of the module dependency in Kconfig. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig index 26b5064bf63..815f8c2f7cd 100644 --- a/drivers/staging/hv/Kconfig +++ b/drivers/staging/hv/Kconfig @@ -1,6 +1,6 @@ config HYPERV tristate "Microsoft Hyper-V client drivers" - depends on X86 && ACPI && PCI && m + depends on X86 && ACPI && PCI default n help Select this option to run Linux as a Hyper-V client operating From 86c921af41f0d40ff9105a73fb20378440f0299f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:54 -0700 Subject: [PATCH 1007/1519] Staging: hv: netvsc: Rename netDevice as net_device Rename netDevice as net_device. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/netvsc.c | 5 ++++- drivers/staging/hv/rndis_filter.c | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 2bcc8b2b9b3..b902579c7fe 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -382,7 +382,10 @@ int netvsc_device_remove(struct hv_device *device) hv_set_drvdata(device, NULL); spin_unlock_irqrestore(&device->channel->inbound_lock, flags); - /* At this point, no one should be accessing netDevice except in here */ + /* + * At this point, no one should be accessing net_device + * except in here + */ dev_notice(&device->device, "net device safe to remove\n"); /* Now, we can close the channel safely */ diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index b354b0b6236..efa7df5b1f8 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -689,7 +689,7 @@ int rndis_filter_device_add(struct hv_device *dev, void *additional_info) { int ret; - struct netvsc_device *netDevice; + struct netvsc_device *net_device; struct rndis_device *rndisDevice; struct netvsc_device_info *deviceInfo = additional_info; @@ -710,10 +710,10 @@ int rndis_filter_device_add(struct hv_device *dev, /* Initialize the rndis device */ - netDevice = hv_get_drvdata(dev); + net_device = hv_get_drvdata(dev); - netDevice->extension = rndisDevice; - rndisDevice->net_dev = netDevice; + net_device->extension = rndisDevice; + rndisDevice->net_dev = net_device; /* Send the rndis initialization message */ ret = rndis_filter_init_device(rndisDevice); @@ -762,12 +762,12 @@ void rndis_filter_device_remove(struct hv_device *dev) int rndis_filter_open(struct hv_device *dev) { - struct netvsc_device *netDevice = hv_get_drvdata(dev); + struct netvsc_device *net_device = hv_get_drvdata(dev); - if (!netDevice) + if (!net_device) return -EINVAL; - return rndis_filter_open_device(netDevice->extension); + return rndis_filter_open_device(net_device->extension); } int rndis_filter_close(struct hv_device *dev) From b13cc345b6f7aae293050c33e86f585ea30b2e38 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:55 -0700 Subject: [PATCH 1008/1519] Staging: hv: netvsc: Rename rndisDevice to rndis_device Rename rndisDevice to rndis_device. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index efa7df5b1f8..bfe91292e9e 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -690,11 +690,11 @@ int rndis_filter_device_add(struct hv_device *dev, { int ret; struct netvsc_device *net_device; - struct rndis_device *rndisDevice; + struct rndis_device *rndis_device; struct netvsc_device_info *deviceInfo = additional_info; - rndisDevice = get_rndis_device(); - if (!rndisDevice) + rndis_device = get_rndis_device(); + if (!rndis_device) return -ENODEV; /* @@ -704,7 +704,7 @@ int rndis_filter_device_add(struct hv_device *dev, */ ret = netvsc_device_add(dev, additional_info); if (ret != 0) { - kfree(rndisDevice); + kfree(rndis_device); return ret; } @@ -712,11 +712,11 @@ int rndis_filter_device_add(struct hv_device *dev, /* Initialize the rndis device */ net_device = hv_get_drvdata(dev); - net_device->extension = rndisDevice; - rndisDevice->net_dev = net_device; + net_device->extension = rndis_device; + rndis_device->net_dev = net_device; /* Send the rndis initialization message */ - ret = rndis_filter_init_device(rndisDevice); + ret = rndis_filter_init_device(rndis_device); if (ret != 0) { /* * TODO: If rndis init failed, we will need to shut down the @@ -725,21 +725,21 @@ int rndis_filter_device_add(struct hv_device *dev, } /* Get the mac address */ - ret = rndis_filter_query_device_mac(rndisDevice); + ret = rndis_filter_query_device_mac(rndis_device); if (ret != 0) { /* * TODO: shutdown rndis device and the channel */ } - memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN); + memcpy(deviceInfo->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); - rndis_filter_query_device_link_status(rndisDevice); + rndis_filter_query_device_link_status(rndis_device); - deviceInfo->link_state = rndisDevice->link_stat; + deviceInfo->link_state = rndis_device->link_stat; dev_info(&dev->device, "Device MAC %pM link state %s", - rndisDevice->hw_mac_adr, + rndis_device->hw_mac_adr, ((deviceInfo->link_state) ? ("down\n") : ("up\n"))); return ret; From 3c4debad4290a31d3537bf89837f49d5e48b8271 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 10:59:56 -0700 Subject: [PATCH 1009/1519] Staging: hv: netvsc: Rename deviceInfo as device_info Rename deviceInfo as device_info. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index bfe91292e9e..963582acb6a 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -691,7 +691,7 @@ int rndis_filter_device_add(struct hv_device *dev, int ret; struct netvsc_device *net_device; struct rndis_device *rndis_device; - struct netvsc_device_info *deviceInfo = additional_info; + struct netvsc_device_info *device_info = additional_info; rndis_device = get_rndis_device(); if (!rndis_device) @@ -732,15 +732,15 @@ int rndis_filter_device_add(struct hv_device *dev, */ } - memcpy(deviceInfo->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); + memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); rndis_filter_query_device_link_status(rndis_device); - deviceInfo->link_state = rndis_device->link_stat; + device_info->link_state = rndis_device->link_stat; dev_info(&dev->device, "Device MAC %pM link state %s", rndis_device->hw_mac_adr, - ((deviceInfo->link_state) ? ("down\n") : ("up\n"))); + ((device_info->link_state) ? ("down\n") : ("up\n"))); return ret; } From 6f27457b50c0439388e34d528f0fc200ddedb9a4 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 13 Sep 2011 15:21:27 -0700 Subject: [PATCH 1010/1519] Staging: hv: netvsc: Cleanup the name and type of link_stat variable Consistently name the variable tracking the link status. Use a consistent type for this variable and get rid of some unnecessary parentheses as well. I would like to thank Joe Perches for suggesting these changes and patiently helping me get here! Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 963582acb6a..ef43f2e95f3 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -41,7 +41,7 @@ struct rndis_device { struct netvsc_device *net_dev; enum rndis_device_state state; - u32 link_stat; + bool link_state; atomic_t new_req_id; spinlock_t request_lock; @@ -511,10 +511,15 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev) static int rndis_filter_query_device_link_status(struct rndis_device *dev) { u32 size = sizeof(u32); + u32 link_status; + int ret; - return rndis_filter_query_device(dev, + ret = rndis_filter_query_device(dev, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, - &dev->link_stat, &size); + &link_status, &size); + dev->link_state = (link_status != 0) ? true : false; + + return ret; } static int rndis_filter_set_packet_filter(struct rndis_device *dev, @@ -736,11 +741,11 @@ int rndis_filter_device_add(struct hv_device *dev, rndis_filter_query_device_link_status(rndis_device); - device_info->link_state = rndis_device->link_stat; + device_info->link_state = rndis_device->link_state; - dev_info(&dev->device, "Device MAC %pM link state %s", + dev_info(&dev->device, "Device MAC %pM link state %s\n", rndis_device->hw_mac_adr, - ((device_info->link_state) ? ("down\n") : ("up\n"))); + device_info->link_state ? "down" : "up"); return ret; } From 18e9351e453fbcf445cb8ffdd2e106e0212166da Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Wed, 7 Sep 2011 16:10:22 +0800 Subject: [PATCH 1011/1519] staging: irq: Remove IRQF_DISABLED This flag is a NOOP and can be removed now. Signed-off-by: Yong Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-alsa.c | 2 +- drivers/staging/cx25821/cx25821-audio-upstream.c | 2 +- drivers/staging/cx25821/cx25821-core.c | 2 +- drivers/staging/cx25821/cx25821-video-upstream-ch2.c | 2 +- drivers/staging/cx25821/cx25821-video-upstream.c | 2 +- drivers/staging/cxt1e1/linux.c | 6 ------ drivers/staging/lirc/lirc_serial.c | 2 +- drivers/staging/lirc/lirc_sir.c | 2 +- 8 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c index ebdba7c65bc..09e99de5fd2 100644 --- a/drivers/staging/cx25821/cx25821-alsa.c +++ b/drivers/staging/cx25821/cx25821-alsa.c @@ -708,7 +708,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev) chip->irq = dev->pci->irq; err = request_irq(dev->pci->irq, cx25821_irq, - IRQF_SHARED | IRQF_DISABLED, chip->dev->name, chip); + IRQF_SHARED, chip->dev->name, chip); if (err < 0) { pr_err("ERROR %s: can't get IRQ %d for ALSA\n", diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c index 50e56a64112..c20d6dece15 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.c +++ b/drivers/staging/cx25821/cx25821-audio-upstream.c @@ -680,7 +680,7 @@ int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev, err = request_irq(dev->pci->irq, cx25821_upstream_irq_audio, - IRQF_SHARED | IRQF_DISABLED, dev->name, dev); + IRQF_SHARED, dev->name, dev); if (err < 0) { pr_err("%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c index 3ec58af0e26..a7fa38f9594 100644 --- a/drivers/staging/cx25821/cx25821-core.c +++ b/drivers/staging/cx25821/cx25821-core.c @@ -1428,7 +1428,7 @@ static int __devinit cx25821_initdev(struct pci_dev *pci_dev, } err = - request_irq(pci_dev->irq, cx25821_irq, IRQF_SHARED | IRQF_DISABLED, + request_irq(pci_dev->irq, cx25821_irq, IRQF_SHARED, dev->name, dev); if (err < 0) { diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index 08ac7c1a7bb..2a724ddfa53 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c @@ -693,7 +693,7 @@ int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, - IRQF_SHARED | IRQF_DISABLED, dev->name, dev); + IRQF_SHARED, dev->name, dev); if (err < 0) { pr_err("%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c index 14a6a6c0340..c0b80068f46 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream.c +++ b/drivers/staging/cx25821/cx25821-video-upstream.c @@ -749,7 +749,7 @@ int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, err = request_irq(dev->pci->irq, cx25821_upstream_irq, - IRQF_SHARED | IRQF_DISABLED, dev->name, dev); + IRQF_SHARED, dev->name, dev); if (err < 0) { pr_err("%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 9ced08f253b..24e009c0149 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -1017,13 +1017,7 @@ c4_add_dev (hdw_info_t * hi, int brdno, unsigned long f0, unsigned long f1, **************************************************************/ if (request_irq (irq0, &c4_linux_interrupt, -#if defined(SBE_ISR_TASKLET) - IRQF_DISABLED | IRQF_SHARED, -#elif defined(SBE_ISR_IMMEDIATE) - IRQF_DISABLED | IRQF_SHARED, -#elif defined(SBE_ISR_INLINE) IRQF_SHARED, -#endif ndev->name, ndev)) { pr_warning("%s: MUSYCC could not get irq: %d\n", ndev->name, irq0); diff --git a/drivers/staging/lirc/lirc_serial.c b/drivers/staging/lirc/lirc_serial.c index 805df913bb6..8a060a8a722 100644 --- a/drivers/staging/lirc/lirc_serial.c +++ b/drivers/staging/lirc/lirc_serial.c @@ -841,7 +841,7 @@ static int init_port(void) int i, nlow, nhigh, result; result = request_irq(irq, irq_handler, - IRQF_DISABLED | (share_irq ? IRQF_SHARED : 0), + (share_irq ? IRQF_SHARED : 0), LIRC_DRIVER_NAME, (void *)&hardware); switch (result) { diff --git a/drivers/staging/lirc/lirc_sir.c b/drivers/staging/lirc/lirc_sir.c index 0d3864594b1..6903d3992ec 100644 --- a/drivers/staging/lirc/lirc_sir.c +++ b/drivers/staging/lirc/lirc_sir.c @@ -967,7 +967,7 @@ static int init_port(void) return -EBUSY; } #endif - retval = request_irq(irq, sir_interrupt, IRQF_DISABLED, + retval = request_irq(irq, sir_interrupt, 0, LIRC_DRIVER_NAME, NULL); if (retval < 0) { # ifndef LIRC_ON_SA1100 From d15cce50161bbb46236f9c50ab044c795cbbecc0 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Mon, 12 Sep 2011 17:16:39 +0200 Subject: [PATCH 1012/1519] staging: crystalhd/bc_dts_types.h: typedef cleanup Not much left out of this header file. All these typedefs can be found in stdint.h Signed-off-by: Arvydas Sidorenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/bc_dts_types.h | 57 ------------------------ 1 file changed, 57 deletions(-) diff --git a/drivers/staging/crystalhd/bc_dts_types.h b/drivers/staging/crystalhd/bc_dts_types.h index d2131e7fe2f..1085a91221b 100644 --- a/drivers/staging/crystalhd/bc_dts_types.h +++ b/drivers/staging/crystalhd/bc_dts_types.h @@ -25,32 +25,7 @@ #ifndef _BC_DTS_TYPES_H_ #define _BC_DTS_TYPES_H_ -#ifdef __LINUX_USER__ /* Don't include these for KERNEL.. */ #include -#endif - -#ifndef PVOID -typedef void *PVOID; -#endif - -#ifndef BOOL -typedef int BOOL; -#endif - -#if defined(__KERNEL__) || defined(__LINUX_USER__) - -#ifdef __LINUX_USER__ /* Don't include these for KERNEL */ -typedef uint32_t ULONG; -typedef int32_t LONG; -typedef void *HANDLE; -#ifndef VOID -typedef void VOID; -#endif -typedef void *LPVOID; -typedef uint32_t DWORD; -typedef uint32_t UINT32; -typedef uint32_t *LPDWORD; -typedef unsigned char *PUCHAR; #ifndef TRUE #define TRUE 1 @@ -62,36 +37,4 @@ typedef unsigned char *PUCHAR; #define TEXT -#else - -/* For Kernel usage.. */ #endif - -#else - -#ifndef uint64_t -typedef struct _uint64_t { - uint32_t low_dw; - uint32_t hi_dw; -} uint64_t; -#endif - -#ifndef int32_t -typedef signed long int32_t; -#endif - -#ifndef uint32_t -typedef unsigned long uint32_t; -#endif - -#ifndef uint16_t -typedef unsigned short uint16_t; -#endif - -#ifndef uint8_t -typedef unsigned char uint8_t; -#endif -#endif - -#endif - From 863c02af581e0d1b0cf57e9f3b785572bcfcd980 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 13 Sep 2011 22:49:31 +0300 Subject: [PATCH 1013/1519] staging: xgifb: main: use readb()/readw() to access iomapped memory Use readb()/readw() instead of direct pointer access to read I/O mapped memory and also add __iomem annotation. The patch eliminates the following sparse warnings: drivers/staging/xgifb/XGI_main_26.c:2125:35: warning: incorrect type in assignment (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2125:35: expected char *[addressable] [toplevel] [assigned] mmio_vbase drivers/staging/xgifb/XGI_main_26.c:2125:35: got void [noderef] * drivers/staging/xgifb/XGI_main_26.c:2439:31: warning: incorrect type in argument 1 (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2439:31: expected void volatile [noderef] *addr drivers/staging/xgifb/XGI_main_26.c:2439:31: got char *[addressable] [toplevel] [assigned] mmio_vbase drivers/staging/xgifb/XGI_main_26.c:2463:31: warning: incorrect type in argument 1 (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2463:31: expected void volatile [noderef] *addr drivers/staging/xgifb/XGI_main_26.c:2463:31: got char *[addressable] [toplevel] [assigned] mmio_vbase Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 54 ++++++++++++----------------- drivers/staging/xgifb/XGIfb.h | 2 +- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 8c5a6e8a695..e6156f15f0b 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -498,48 +498,38 @@ invalid: static int XGIfb_GetXG21LVDSData(void) { u8 tmp; - unsigned char *pData; + void __iomem *data = xgi_video_info.mmio_vbase + 0x20000; int i, j, k; tmp = xgifb_reg_get(XGISR, 0x1e); xgifb_reg_set(XGISR, 0x1e, tmp | 4); - pData = xgi_video_info.mmio_vbase + 0x20000; - if ((pData[0x0] == 0x55) && - (pData[0x1] == 0xAA) && - (pData[0x65] & 0x1)) { - i = pData[0x316] | (pData[0x317] << 8); - j = pData[i - 1]; + if ((readb(data) == 0x55) && + (readb(data + 1) == 0xAA) && + (readb(data + 0x65) & 0x1)) { + i = readw(data + 0x316); + j = readb(data + i - 1); if (j == 0xff) j = 1; k = 0; do { - XGI21_LCDCapList[k].LVDS_Capability = pData[i] - | (pData[i + 1] << 8); - XGI21_LCDCapList[k].LVDSHT = pData[i + 2] | (pData[i - + 3] << 8); - XGI21_LCDCapList[k].LVDSVT = pData[i + 4] | (pData[i - + 5] << 8); - XGI21_LCDCapList[k].LVDSHDE = pData[i + 6] | (pData[i - + 7] << 8); - XGI21_LCDCapList[k].LVDSVDE = pData[i + 8] | (pData[i - + 9] << 8); - XGI21_LCDCapList[k].LVDSHFP = pData[i + 10] | (pData[i - + 11] << 8); - XGI21_LCDCapList[k].LVDSVFP = pData[i + 12] | (pData[i - + 13] << 8); - XGI21_LCDCapList[k].LVDSHSYNC = pData[i + 14] - | (pData[i + 15] << 8); - XGI21_LCDCapList[k].LVDSVSYNC = pData[i + 16] - | (pData[i + 17] << 8); - XGI21_LCDCapList[k].VCLKData1 = pData[i + 18]; - XGI21_LCDCapList[k].VCLKData2 = pData[i + 19]; - XGI21_LCDCapList[k].PSC_S1 = pData[i + 20]; - XGI21_LCDCapList[k].PSC_S2 = pData[i + 21]; - XGI21_LCDCapList[k].PSC_S3 = pData[i + 22]; - XGI21_LCDCapList[k].PSC_S4 = pData[i + 23]; - XGI21_LCDCapList[k].PSC_S5 = pData[i + 24]; + XGI21_LCDCapList[k].LVDS_Capability = readw(data + i); + XGI21_LCDCapList[k].LVDSHT = readw(data + i + 2); + XGI21_LCDCapList[k].LVDSVT = readw(data + i + 4); + XGI21_LCDCapList[k].LVDSHDE = readw(data + i + 6); + XGI21_LCDCapList[k].LVDSVDE = readw(data + i + 8); + XGI21_LCDCapList[k].LVDSHFP = readw(data + i + 10); + XGI21_LCDCapList[k].LVDSVFP = readw(data + i + 12); + XGI21_LCDCapList[k].LVDSHSYNC = readw(data + i + 14); + XGI21_LCDCapList[k].LVDSVSYNC = readw(data + i + 16); + XGI21_LCDCapList[k].VCLKData1 = readb(data + i + 18); + XGI21_LCDCapList[k].VCLKData2 = readb(data + i + 19); + XGI21_LCDCapList[k].PSC_S1 = readb(data + i + 20); + XGI21_LCDCapList[k].PSC_S2 = readb(data + i + 21); + XGI21_LCDCapList[k].PSC_S3 = readb(data + i + 22); + XGI21_LCDCapList[k].PSC_S4 = readb(data + i + 23); + XGI21_LCDCapList[k].PSC_S5 = readb(data + i + 24); i += 25; j--; k++; diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 5d81cb69e63..12e1a3e330b 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -59,7 +59,7 @@ struct video_info { char *video_vbase; unsigned long mmio_base; unsigned long mmio_size; - char *mmio_vbase; + void __iomem *mmio_vbase; unsigned long vga_base; unsigned long mtrr; From 4b4954621ff57e168ebd77b7d2682308d13b4e7f Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 13 Sep 2011 22:49:32 +0300 Subject: [PATCH 1014/1519] staging: xgifb: unify #include order Include Linux headers before driver's own headers. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 3 +-- drivers/staging/xgifb/vb_util.c | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 262992ee70e..c7fd406be1a 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -1,7 +1,6 @@ -#include "vgatypes.h" - #include #include /* udelay */ +#include "vgatypes.h" #include "XGIfb.h" #include "vb_def.h" diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c index ea2b795bfa5..b5c99891ead 100644 --- a/drivers/staging/xgifb/vb_util.c +++ b/drivers/staging/xgifb/vb_util.c @@ -1,10 +1,11 @@ +#include +#include + #include "vb_def.h" #include "vgatypes.h" #include "vb_struct.h" #include "XGIfb.h" -#include -#include #include "vb_util.h" From c44fa627c7b351cb359b7bd373756776b907ecd5 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 13 Sep 2011 22:49:33 +0300 Subject: [PATCH 1015/1519] staging: xgifb: vb_init: use readl()/writel() to access iomapped memory Use readl() and writel() in FB memory test instead of direct pointer access, and also add iomem annotations for the FB memory. The patch eliminates the following sparse warnings: drivers/staging/xgifb/XGI_main_26.c:2113:69: warning: incorrect type in assignment (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2113:69: expected unsigned char *static [addressable] [toplevel] [assigned] pjVideoMemoryAddress drivers/staging/xgifb/XGI_main_26.c:2113:69: got void [noderef] * drivers/staging/xgifb/XGI_main_26.c:2399:30: warning: incorrect type in assignment (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2399:30: expected char [noderef] *screen_base drivers/staging/xgifb/XGI_main_26.c:2399:30: got char *[addressable] [toplevel] [assigned] video_vbase drivers/staging/xgifb/XGI_main_26.c:2430:31: warning: incorrect type in argument 1 (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2430:31: expected void volatile [noderef] *addr drivers/staging/xgifb/XGI_main_26.c:2430:31: got char *[addressable] [toplevel] [assigned] video_vbase drivers/staging/xgifb/XGI_main_26.c:2454:31: warning: incorrect type in argument 1 (different address spaces) drivers/staging/xgifb/XGI_main_26.c:2454:31: expected void volatile [noderef] *addr drivers/staging/xgifb/XGI_main_26.c:2454:31: got char *[addressable] [toplev Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGIfb.h | 2 +- drivers/staging/xgifb/vb_init.c | 10 +++++----- drivers/staging/xgifb/vb_struct.h | 2 +- drivers/staging/xgifb/vgatypes.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 12e1a3e330b..f778293b553 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -56,7 +56,7 @@ struct video_info { int chip_id; unsigned int video_size; unsigned long video_base; - char *video_vbase; + void __iomem *video_vbase; unsigned long mmio_base; unsigned long mmio_size; void __iomem *mmio_vbase; diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index c7fd406be1a..ce5bf6839cf 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -678,12 +678,13 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr, { int i; unsigned long Position = 0; + void __iomem *fbaddr = pVBInfo->FBAddr; - *((unsigned long *) (pVBInfo->FBAddr + Position)) = Position; + writel(Position, fbaddr + Position); for (i = StartAddr; i <= StopAddr; i++) { Position = 1 << i; - *((unsigned long *) (pVBInfo->FBAddr + Position)) = Position; + writel(Position, fbaddr + Position); } udelay(500); /* [Vicent] 2004/04/16. @@ -691,13 +692,12 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr, Position = 0; - if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) != Position) + if (readl(fbaddr + Position) != Position) return 0; for (i = StartAddr; i <= StopAddr; i++) { Position = 1 << i; - if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) != - Position) + if (readl(fbaddr + Position) != Position) return 0; } return 1; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 6f13442bd6a..860c98649bf 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -300,7 +300,7 @@ struct vb_device_info { unsigned short SelectCRT2Rate; unsigned char *ROMAddr; - unsigned char *FBAddr; + void __iomem *FBAddr; unsigned long BaseAddr; unsigned long RelIO; diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h index 7f911f1ac32..76e2d81cbd5 100644 --- a/drivers/staging/xgifb/vgatypes.h +++ b/drivers/staging/xgifb/vgatypes.h @@ -53,7 +53,7 @@ struct xgi_hw_device_info { unsigned char *pjVirtualRomBase; /* ROM image */ - unsigned char *pjVideoMemoryAddress;/* base virtual memory address */ + void __iomem *pjVideoMemoryAddress;/* base virtual memory address */ /* of Linear VGA memory */ unsigned long ulVideoMemorySize; /* size, in bytes, of the From 09d1cad15df89df3a09e53d880de0e9a8e8324b5 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 13 Sep 2011 22:49:34 +0300 Subject: [PATCH 1016/1519] staging: xgifb: add missing #include Add a missing include to eliminate the following sparse warning: drivers/staging/xgifb/vb_table.h:2572:28: warning: symbol 'XGI21_LCDCapList' was not declared. Should it be static? Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index efdda2256b9..8f3a8127d09 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -8,6 +8,7 @@ #include "vb_def.h" #include "vgatypes.h" #include "vb_struct.h" +#include "vb_init.h" #include "vb_util.h" #include "vb_table.h" #include "vb_setmode.h" From 8775316e1ae147d90b77ba683e7455e89a74364a Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 13 Sep 2011 22:49:35 +0300 Subject: [PATCH 1017/1519] staging: xgifb: update TODO There are no build warnings at the moment. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/xgifb/TODO b/drivers/staging/xgifb/TODO index c85ff5e9e70..13d9bc25797 100644 --- a/drivers/staging/xgifb/TODO +++ b/drivers/staging/xgifb/TODO @@ -5,7 +5,6 @@ Arnaud TODO: - clean ups -- fix build warnings when module - sort out dup ids with SiS driver - remove useless/wrong/unused #ifdef/code/... - fix printk usages From 322c95636739420631e51f3d3f24132dc220762a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 14 Sep 2011 13:01:23 +0100 Subject: [PATCH 1018/1519] staging:iio:tree wide. abi fixup for in_ out_ prefix introduction. This patch set should bring all the attributes created outside of chan_spec registration inline with the new abi. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16204_core.c | 12 ++-- drivers/staging/iio/accel/adis16240_core.c | 4 +- drivers/staging/iio/accel/sca3000_core.c | 10 ++-- drivers/staging/iio/accel/sca3000_ring.c | 4 +- drivers/staging/iio/adc/ad7192.c | 9 +-- drivers/staging/iio/adc/ad7280a.c | 12 ++-- drivers/staging/iio/adc/ad7745.c | 36 +++++------ drivers/staging/iio/adc/ad799x_core.c | 60 +++++++++---------- drivers/staging/iio/dac/ad5446.c | 26 ++++---- drivers/staging/iio/dac/ad5504.c | 43 +++++++------ drivers/staging/iio/dac/ad5624r_spi.c | 30 +++++----- drivers/staging/iio/dac/ad5686.c | 30 +++++----- drivers/staging/iio/dac/dac.h | 2 +- drivers/staging/iio/dac/max517.c | 25 ++++---- .../staging/iio/impedance-analyzer/ad5933.c | 32 +++++----- drivers/staging/iio/magnetometer/hmc5843.c | 4 +- drivers/staging/iio/meter/ade7753.c | 10 ++-- drivers/staging/iio/meter/ade7754.c | 10 ++-- drivers/staging/iio/meter/ade7758_core.c | 10 ++-- drivers/staging/iio/meter/ade7759.c | 10 ++-- drivers/staging/iio/sysfs.h | 6 +- 21 files changed, 196 insertions(+), 189 deletions(-) diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index e0b87840133..b0d6a2e7257 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -301,15 +301,15 @@ err_ret: /* Unique to this driver currently */ #define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xy, S_IRUGO, _show, NULL, _addr) + IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr) #define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \ - IIO_DEVICE_ATTR(accel_xypeak, S_IRUGO, _show, NULL, _addr) + IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr) static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed, ADIS16204_XY_RSS_OUT); static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed, ADIS16204_XY_PEAK_OUT); -static IIO_CONST_ATTR(accel_xy_scale, "0.017125"); +static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125"); static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0); @@ -475,9 +475,9 @@ static struct iio_chan_spec adis16204_channels[] = { static struct attribute *adis16204_attributes[] = { &iio_dev_attr_reset.dev_attr.attr, - &iio_dev_attr_accel_xy.dev_attr.attr, - &iio_dev_attr_accel_xypeak.dev_attr.attr, - &iio_const_attr_accel_xy_scale.dev_attr.attr, + &iio_dev_attr_in_accel_xy.dev_attr.attr, + &iio_dev_attr_in_accel_xypeak.dev_attr.attr, + &iio_const_attr_in_accel_xy_scale.dev_attr.attr, NULL }; diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 0dd02a3ba15..282a746dc5d 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -325,7 +325,7 @@ err_ret: return ret; } -static IIO_DEVICE_ATTR(accel_xyz_squared_peak_raw, S_IRUGO, +static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO, adis16240_read_12bit_signed, NULL, ADIS16240_XYZPEAK_OUT); @@ -500,7 +500,7 @@ static struct iio_chan_spec adis16240_channels[] = { }; static struct attribute *adis16240_attributes[] = { - &iio_dev_attr_accel_xyz_squared_peak_raw.dev_attr.attr, + &iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, NULL diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index e0407e24faa..394b04eb1aa 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -771,9 +771,9 @@ static struct attribute *sca3000_attributes_with_temp[] = { &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, /* Only present if temp sensor is */ - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, + &iio_dev_attr_in_temp_raw.dev_attr.attr, + &iio_const_attr_in_temp_offset.dev_attr.attr, + &iio_const_attr_in_temp_scale.dev_attr.attr, NULL, }; @@ -1018,14 +1018,14 @@ exit_point: /* Free fall detector related event attribute */ static IIO_DEVICE_ATTR_NAMED(accel_xayaz_mag_falling_en, - accel_x&y&z_mag_falling_en, + in_accel_x&y&z_mag_falling_en, S_IRUGO | S_IWUSR, sca3000_query_free_fall_mode, sca3000_set_free_fall_mode, 0); static IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period, - accel_x&y&z_mag_falling_period, + in_accel_x&y&z_mag_falling_period, "0.226"); static struct attribute *sca3000_event_attributes[] = { diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 3d6dafa11e5..996b01ed97b 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -229,7 +229,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev, return sprintf(buf, "0.%06d\n", 4*st->info->scale); } -static IIO_DEVICE_ATTR(accel_scale, +static IIO_DEVICE_ATTR(in_accel_scale, S_IRUGO, sca3000_show_buffer_scale, NULL, @@ -247,7 +247,7 @@ static struct attribute *sca3000_ring_attributes[] = { &dev_attr_enable.attr, &iio_dev_attr_50_percent.dev_attr.attr, &iio_dev_attr_75_percent.dev_attr.attr, - &iio_dev_attr_accel_scale.dev_attr.attr, + &iio_dev_attr_in_accel_scale.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 5bc1051b24b..5a389b81cbc 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -747,10 +747,11 @@ static ssize_t ad7192_show_scale_available(struct device *dev, return len; } -static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available, in-in_scale_available, +static IIO_DEVICE_ATTR_NAMED(in_v_m_v_scale_available, + in_voltage-voltage_scale_available, S_IRUGO, ad7192_show_scale_available, NULL, 0); -static IIO_DEVICE_ATTR(in_scale_available, S_IRUGO, +static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO, ad7192_show_scale_available, NULL, 0); static ssize_t ad7192_show_ac_excitation(struct device *dev, @@ -830,8 +831,8 @@ static IIO_DEVICE_ATTR(ac_excitation_en, S_IRUGO | S_IWUSR, static struct attribute *ad7192_attributes[] = { &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_dev_attr_in_m_in_scale_available.dev_attr.attr, - &iio_dev_attr_in_scale_available.dev_attr.attr, + &iio_dev_attr_in_v_m_v_scale_available.dev_attr.attr, + &iio_dev_attr_in_voltage_scale_available.dev_attr.attr, &iio_dev_attr_bridge_switch_en.dev_attr.attr, &iio_dev_attr_ac_excitation_en.dev_attr.attr, NULL diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 2d8d650dc27..4c67cfea6ed 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -736,26 +736,26 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) } static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value, - in-in_thresh_low_value, + in_voltage-voltage_thresh_low_value, S_IRUGO | S_IWUSR, ad7280_read_channel_config, ad7280_write_channel_config, AD7280A_CELL_UNDERVOLTAGE); static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value, - in-in_thresh_high_value, + in_voltage-voltage_thresh_high_value, S_IRUGO | S_IWUSR, ad7280_read_channel_config, ad7280_write_channel_config, AD7280A_CELL_OVERVOLTAGE); -static IIO_DEVICE_ATTR(temp_thresh_low_value, +static IIO_DEVICE_ATTR(in_temp_thresh_low_value, S_IRUGO | S_IWUSR, ad7280_read_channel_config, ad7280_write_channel_config, AD7280A_AUX_ADC_UNDERVOLTAGE); -static IIO_DEVICE_ATTR(temp_thresh_high_value, +static IIO_DEVICE_ATTR(in_temp_thresh_high_value, S_IRUGO | S_IWUSR, ad7280_read_channel_config, ad7280_write_channel_config, @@ -765,8 +765,8 @@ static IIO_DEVICE_ATTR(temp_thresh_high_value, static struct attribute *ad7280_event_attributes[] = { &iio_dev_attr_in_thresh_low_value.dev_attr.attr, &iio_dev_attr_in_thresh_high_value.dev_attr.attr, - &iio_dev_attr_temp_thresh_low_value.dev_attr.attr, - &iio_dev_attr_temp_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_temp_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_temp_thresh_high_value.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index eea77f1603d..827344c2147 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -131,21 +131,21 @@ static int ad774x_i2c_write(struct ad774x_chip_info *chip, u8 reg, u8 data) #define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) #define IIO_DEV_ATTR_CAP_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(cap_setup, _mode, _show, _store, 0) + IIO_DEVICE_ATTR(in_capacitance_setup, _mode, _show, _store, 0) #define IIO_DEV_ATTR_VT_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in0_setup, _mode, _show, _store, 0) + IIO_DEVICE_ATTR(in_voltage0_setup, _mode, _show, _store, 0) #define IIO_DEV_ATTR_EXEC_SETUP(_mode, _show, _store) \ IIO_DEVICE_ATTR(exec_setup, _mode, _show, _store, 0) #define IIO_DEV_ATTR_VOLT_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in0_gain, _mode, _show, _store, 0) + IIO_DEVICE_ATTR(in_voltage0_gain, _mode, _show, _store, 0) #define IIO_DEV_ATTR_CAP_OFFS(_mode, _show, _store) \ - IIO_DEVICE_ATTR(cap_offs, _mode, _show, _store, 0) + IIO_DEVICE_ATTR(in_capacitance_offs, _mode, _show, _store, 0) #define IIO_DEV_ATTR_CAP_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(cap_gain, _mode, _show, _store, 0) + IIO_DEVICE_ATTR(in_capacitance_gain, _mode, _show, _store, 0) #define IIO_DEV_ATTR_CAP_DATA(_show) \ - IIO_DEVICE_ATTR(cap0_raw, S_IRUGO, _show, NULL, 0) + IIO_DEVICE_ATTR(in_capacitance0_raw, S_IRUGO, _show, NULL, 0) #define IIO_DEV_ATTR_VT_DATA(_show) \ - IIO_DEVICE_ATTR(in0_raw, S_IRUGO, _show, NULL, 0) + IIO_DEVICE_ATTR(in_voltage0_raw, S_IRUGO, _show, NULL, 0) static ssize_t ad774x_show_conversion_modes(struct device *dev, struct device_attribute *attr, @@ -241,12 +241,12 @@ static ssize_t ad774x_store_dac_value(struct device *dev, return -EINVAL; } -static IIO_DEVICE_ATTR(capdac0_raw, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_capacitance0_raw, S_IRUGO | S_IWUSR, ad774x_show_dac_value, ad774x_store_dac_value, AD774X_CAPDACA); -static IIO_DEVICE_ATTR(capdac1_raw, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_capacitance1_raw, S_IRUGO | S_IWUSR, ad774x_show_dac_value, ad774x_store_dac_value, AD774X_CAPDACB); @@ -501,16 +501,16 @@ static IIO_DEV_ATTR_CAP_GAIN(S_IRUGO | S_IWUSR, static struct attribute *ad774x_attributes[] = { &iio_dev_attr_available_conversion_modes.dev_attr.attr, &iio_dev_attr_conversion_mode.dev_attr.attr, - &iio_dev_attr_cap_setup.dev_attr.attr, - &iio_dev_attr_in0_setup.dev_attr.attr, + &iio_dev_attr_in_capacitance_setup.dev_attr.attr, + &iio_dev_attr_in_voltage0_setup.dev_attr.attr, &iio_dev_attr_exec_setup.dev_attr.attr, - &iio_dev_attr_cap_offs.dev_attr.attr, - &iio_dev_attr_cap_gain.dev_attr.attr, - &iio_dev_attr_in0_gain.dev_attr.attr, - &iio_dev_attr_in0_raw.dev_attr.attr, - &iio_dev_attr_cap0_raw.dev_attr.attr, - &iio_dev_attr_capdac0_raw.dev_attr.attr, - &iio_dev_attr_capdac1_raw.dev_attr.attr, + &iio_dev_attr_in_capacitance_offs.dev_attr.attr, + &iio_dev_attr_in_capacitance_gain.dev_attr.attr, + &iio_dev_attr_in_voltage0_gain.dev_attr.attr, + &iio_dev_attr_in_voltage0_raw.dev_attr.attr, + &iio_dev_attr_in_capacitance0_raw.dev_attr.attr, + &iio_dev_attr_out_capacitance0_raw.dev_attr.attr, + &iio_dev_attr_out_capacitance1_raw.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 75b8c37ca1e..ae64ee95cdd 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -350,73 +350,73 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) return IRQ_HANDLED; } -static IIO_DEVICE_ATTR(in0_thresh_low_value, +static IIO_DEVICE_ATTR(in_voltage0_thresh_low_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATALOW_CH1_REG); -static IIO_DEVICE_ATTR(in0_thresh_high_value, +static IIO_DEVICE_ATTR(in_voltage0_thresh_high_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATAHIGH_CH1_REG); -static IIO_DEVICE_ATTR(in0_thresh_both_hyst_raw, +static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH1_REG); -static IIO_DEVICE_ATTR(in1_thresh_low_value, +static IIO_DEVICE_ATTR(in_voltage1_thresh_low_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATALOW_CH2_REG); -static IIO_DEVICE_ATTR(in1_thresh_high_value, +static IIO_DEVICE_ATTR(in_voltage1_thresh_high_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATAHIGH_CH2_REG); -static IIO_DEVICE_ATTR(in1_thresh_both_hyst_raw, +static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH2_REG); -static IIO_DEVICE_ATTR(in2_thresh_low_value, +static IIO_DEVICE_ATTR(in_voltage2_thresh_low_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATALOW_CH3_REG); -static IIO_DEVICE_ATTR(in2_thresh_high_value, +static IIO_DEVICE_ATTR(in_voltage2_thresh_high_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATAHIGH_CH3_REG); -static IIO_DEVICE_ATTR(in2_thresh_both_hyst_raw, +static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH3_REG); -static IIO_DEVICE_ATTR(in3_thresh_low_value, +static IIO_DEVICE_ATTR(in_voltage3_thresh_low_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATALOW_CH4_REG); -static IIO_DEVICE_ATTR(in3_thresh_high_value, +static IIO_DEVICE_ATTR(in_voltage3_thresh_high_value, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_DATAHIGH_CH4_REG); -static IIO_DEVICE_ATTR(in3_thresh_both_hyst_raw, +static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, @@ -428,18 +428,18 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); static struct attribute *ad7993_4_7_8_event_attributes[] = { - &iio_dev_attr_in0_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in0_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in0_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in1_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in1_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in1_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in2_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in2_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in2_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in3_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in3_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in3_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage2_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage2_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage3_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage3_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL, @@ -451,12 +451,12 @@ static struct attribute_group ad7993_4_7_8_event_attrs_group = { }; static struct attribute *ad7992_event_attributes[] = { - &iio_dev_attr_in0_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in0_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in0_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in1_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in1_thresh_high_value.dev_attr.attr, - &iio_dev_attr_in1_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr, + &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL, diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index c670fb9de31..41a8872b37c 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -105,7 +105,7 @@ static ssize_t ad5446_show_scale(struct device *dev, return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000); } -static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5446_show_scale, NULL, 0); +static IIO_DEVICE_ATTR(out_voltage_scale, S_IRUGO, ad5446_show_scale, NULL, 0); static ssize_t ad5446_write_powerdown_mode(struct device *dev, struct device_attribute *attr, @@ -177,23 +177,23 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, return ret ? ret : len; } -static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, ad5446_read_powerdown_mode, ad5446_write_powerdown_mode, 0); -static IIO_CONST_ATTR(out_powerdown_mode_available, +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "1kohm_to_gnd 100kohm_to_gnd three_state"); -static IIO_DEVICE_ATTR(out0_powerdown, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_powerdown, S_IRUGO | S_IWUSR, ad5446_read_dac_powerdown, ad5446_write_dac_powerdown, 0); static struct attribute *ad5446_attributes[] = { - &iio_dev_attr_out0_raw.dev_attr.attr, - &iio_dev_attr_out_scale.dev_attr.attr, - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_raw.dev_attr.attr, + &iio_dev_attr_out_voltage_scale.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, NULL, }; @@ -207,10 +207,12 @@ static mode_t ad5446_attr_is_visible(struct kobject *kobj, mode_t mode = attr->mode; if (!st->chip_info->store_pwr_down && - (attr == &iio_dev_attr_out0_powerdown.dev_attr.attr || - attr == &iio_dev_attr_out_powerdown_mode.dev_attr.attr || + (attr == &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr || + attr == &iio_dev_attr_out_voltage_powerdown_mode. + dev_attr.attr || attr == - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr)) + &iio_const_attr_out_voltage_powerdown_mode_available. + dev_attr.attr)) mode = 0; return mode; diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index c528dff5b5b..a430874ee7c 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -169,10 +169,10 @@ static ssize_t ad5504_show_scale(struct device *dev, return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000); } -static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5504_show_scale, NULL, 0); +static IIO_DEVICE_ATTR(out_voltage_scale, S_IRUGO, ad5504_show_scale, NULL, 0); #define IIO_DEV_ATTR_OUT_RW_RAW(_num, _show, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_raw, \ + IIO_DEVICE_ATTR(out_voltage##_num##_raw, \ S_IRUGO | S_IWUSR, _show, _store, _addr) static IIO_DEV_ATTR_OUT_RW_RAW(0, ad5504_read_dac, @@ -184,17 +184,16 @@ static IIO_DEV_ATTR_OUT_RW_RAW(2, ad5504_read_dac, static IIO_DEV_ATTR_OUT_RW_RAW(3, ad5504_read_dac, ad5504_write_dac, AD5504_ADDR_DAC3); -static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO | +static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, ad5504_read_powerdown_mode, ad5504_write_powerdown_mode, 0); -static IIO_CONST_ATTR(out_powerdown_mode_available, +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "20kohm_to_gnd three_state"); #define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_powerdown, \ + IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \ S_IRUGO | S_IWUSR, _show, _store, _addr) - static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5504_read_dac_powerdown, ad5504_write_dac_powerdown, 0); static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5504_read_dac_powerdown, @@ -205,17 +204,17 @@ static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5504_read_dac_powerdown, ad5504_write_dac_powerdown, 3); static struct attribute *ad5504_attributes[] = { - &iio_dev_attr_out0_raw.dev_attr.attr, - &iio_dev_attr_out1_raw.dev_attr.attr, - &iio_dev_attr_out2_raw.dev_attr.attr, - &iio_dev_attr_out3_raw.dev_attr.attr, - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out1_powerdown.dev_attr.attr, - &iio_dev_attr_out2_powerdown.dev_attr.attr, - &iio_dev_attr_out3_powerdown.dev_attr.attr, - &iio_dev_attr_out_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, - &iio_dev_attr_out_scale.dev_attr.attr, + &iio_dev_attr_out_voltage0_raw.dev_attr.attr, + &iio_dev_attr_out_voltage1_raw.dev_attr.attr, + &iio_dev_attr_out_voltage2_raw.dev_attr.attr, + &iio_dev_attr_out_voltage3_raw.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage_scale.dev_attr.attr, NULL, }; @@ -224,11 +223,11 @@ static const struct attribute_group ad5504_attribute_group = { }; static struct attribute *ad5501_attributes[] = { - &iio_dev_attr_out0_raw.dev_attr.attr, - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, - &iio_dev_attr_out_scale.dev_attr.attr, + &iio_dev_attr_out_voltage0_raw.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage_scale.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index e5edf590f92..8e7fafb6cc4 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -173,22 +173,22 @@ static ssize_t ad5624r_show_scale(struct device *dev, return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000); } -static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5624r_show_scale, NULL, 0); +static IIO_DEVICE_ATTR(out_voltage_scale, S_IRUGO, ad5624r_show_scale, NULL, 0); static IIO_DEV_ATTR_OUT_RAW(0, ad5624r_write_dac, AD5624R_ADDR_DAC0); static IIO_DEV_ATTR_OUT_RAW(1, ad5624r_write_dac, AD5624R_ADDR_DAC1); static IIO_DEV_ATTR_OUT_RAW(2, ad5624r_write_dac, AD5624R_ADDR_DAC2); static IIO_DEV_ATTR_OUT_RAW(3, ad5624r_write_dac, AD5624R_ADDR_DAC3); -static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO | +static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, ad5624r_read_powerdown_mode, ad5624r_write_powerdown_mode, 0); -static IIO_CONST_ATTR(out_powerdown_mode_available, +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "1kohm_to_gnd 100kohm_to_gnd three_state"); #define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_powerdown, \ + IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \ S_IRUGO | S_IWUSR, _show, _store, _addr) static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5624r_read_dac_powerdown, @@ -201,17 +201,17 @@ static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5624r_read_dac_powerdown, ad5624r_write_dac_powerdown, 3); static struct attribute *ad5624r_attributes[] = { - &iio_dev_attr_out0_raw.dev_attr.attr, - &iio_dev_attr_out1_raw.dev_attr.attr, - &iio_dev_attr_out2_raw.dev_attr.attr, - &iio_dev_attr_out3_raw.dev_attr.attr, - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out1_powerdown.dev_attr.attr, - &iio_dev_attr_out2_powerdown.dev_attr.attr, - &iio_dev_attr_out3_powerdown.dev_attr.attr, - &iio_dev_attr_out_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, - &iio_dev_attr_out_scale.dev_attr.attr, + &iio_dev_attr_out_voltage0_raw.dev_attr.attr, + &iio_dev_attr_out_voltage1_raw.dev_attr.attr, + &iio_dev_attr_out_voltage2_raw.dev_attr.attr, + &iio_dev_attr_out_voltage3_raw.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage_scale.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index 6e768206a87..b55ef42a18b 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -247,11 +247,12 @@ static ssize_t ad5686_write_dac_powerdown(struct device *dev, return ret ? ret : len; } -static IIO_CONST_ATTR(out_powerdown_mode_available, +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "1kohm_to_gnd 100kohm_to_gnd three_state"); -#define IIO_DEV_ATTR_DAC_POWERDOWN_MODE(_num) \ - IIO_DEVICE_ATTR(out##_num##_powerdown_mode, S_IRUGO | S_IWUSR, \ +#define IIO_DEV_ATTR_DAC_POWERDOWN_MODE(_num) \ + IIO_DEVICE_ATTR(out_voltage##_num##_powerdown_mode, \ + S_IRUGO | S_IWUSR, \ ad5686_read_powerdown_mode, \ ad5686_write_powerdown_mode, _num) @@ -260,8 +261,9 @@ static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(1); static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(2); static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(3); -#define IIO_DEV_ATTR_DAC_POWERDOWN(_num) \ - IIO_DEVICE_ATTR(out##_num##_powerdown, S_IRUGO | S_IWUSR, \ +#define IIO_DEV_ATTR_DAC_POWERDOWN(_num) \ + IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \ + S_IRUGO | S_IWUSR, \ ad5686_read_dac_powerdown, \ ad5686_write_dac_powerdown, _num) @@ -271,15 +273,15 @@ static IIO_DEV_ATTR_DAC_POWERDOWN(2); static IIO_DEV_ATTR_DAC_POWERDOWN(3); static struct attribute *ad5686_attributes[] = { - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out1_powerdown.dev_attr.attr, - &iio_dev_attr_out2_powerdown.dev_attr.attr, - &iio_dev_attr_out3_powerdown.dev_attr.attr, - &iio_dev_attr_out0_powerdown_mode.dev_attr.attr, - &iio_dev_attr_out1_powerdown_mode.dev_attr.attr, - &iio_dev_attr_out2_powerdown_mode.dev_attr.attr, - &iio_dev_attr_out3_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, NULL, }; diff --git a/drivers/staging/iio/dac/dac.h b/drivers/staging/iio/dac/dac.h index 1d82f353241..0754d715cf9 100644 --- a/drivers/staging/iio/dac/dac.h +++ b/drivers/staging/iio/dac/dac.h @@ -3,4 +3,4 @@ */ #define IIO_DEV_ATTR_OUT_RAW(_num, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_raw, S_IWUSR, NULL, _store, _addr) + IIO_DEVICE_ATTR(out_voltage##_num##_raw, S_IWUSR, NULL, _store, _addr) diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c index d54262ff0cd..fb780d02cae 100644 --- a/drivers/staging/iio/dac/max517.c +++ b/drivers/staging/iio/dac/max517.c @@ -120,8 +120,9 @@ static ssize_t max517_set_value_both(struct device *dev, { return max517_set_value(dev, attr, buf, count, 3); } -static IIO_DEVICE_ATTR_NAMED(out1and2_raw, out1&2_raw, S_IWUSR, NULL, - max517_set_value_both, -1); +static IIO_DEVICE_ATTR_NAMED(out_voltage1and2_raw, + out_voltage1&2_raw, S_IWUSR, NULL, + max517_set_value_both, -1); static ssize_t max517_show_scale(struct device *dev, struct device_attribute *attr, @@ -141,7 +142,8 @@ static ssize_t max517_show_scale1(struct device *dev, { return max517_show_scale(dev, attr, buf, 1); } -static IIO_DEVICE_ATTR(out1_scale, S_IRUGO, max517_show_scale1, NULL, 0); +static IIO_DEVICE_ATTR(out_voltage1_scale, S_IRUGO, + max517_show_scale1, NULL, 0); static ssize_t max517_show_scale2(struct device *dev, struct device_attribute *attr, @@ -149,12 +151,13 @@ static ssize_t max517_show_scale2(struct device *dev, { return max517_show_scale(dev, attr, buf, 2); } -static IIO_DEVICE_ATTR(out2_scale, S_IRUGO, max517_show_scale2, NULL, 0); +static IIO_DEVICE_ATTR(out_voltage2_scale, S_IRUGO, + max517_show_scale2, NULL, 0); /* On MAX517 variant, we have one output */ static struct attribute *max517_attributes[] = { - &iio_dev_attr_out1_raw.dev_attr.attr, - &iio_dev_attr_out1_scale.dev_attr.attr, + &iio_dev_attr_out_voltage1_raw.dev_attr.attr, + &iio_dev_attr_out_voltage1_scale.dev_attr.attr, NULL }; @@ -164,11 +167,11 @@ static struct attribute_group max517_attribute_group = { /* On MAX518 and MAX519 variant, we have two outputs */ static struct attribute *max518_attributes[] = { - &iio_dev_attr_out1_raw.dev_attr.attr, - &iio_dev_attr_out1_scale.dev_attr.attr, - &iio_dev_attr_out2_raw.dev_attr.attr, - &iio_dev_attr_out2_scale.dev_attr.attr, - &iio_dev_attr_out1and2_raw.dev_attr.attr, + &iio_dev_attr_out_voltage1_raw.dev_attr.attr, + &iio_dev_attr_out_voltage1_scale.dev_attr.attr, + &iio_dev_attr_out_voltage2_raw.dev_attr.attr, + &iio_dev_attr_out_voltage2_scale.dev_attr.attr, + &iio_dev_attr_out_voltage1and2_raw.dev_attr.attr, NULL }; diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 65399d1467c..6d1086b2cd8 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -308,12 +308,12 @@ static ssize_t ad5933_store_frequency(struct device *dev, return ret ? ret : len; } -static IIO_DEVICE_ATTR(out0_freq_start, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_freq_start, S_IRUGO | S_IWUSR, ad5933_show_frequency, ad5933_store_frequency, AD5933_REG_FREQ_START); -static IIO_DEVICE_ATTR(out0_freq_increment, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_freq_increment, S_IRUGO | S_IWUSR, ad5933_show_frequency, ad5933_store_frequency, AD5933_REG_FREQ_INC); @@ -431,32 +431,32 @@ static ssize_t ad5933_store(struct device *dev, return ret ? ret : len; } -static IIO_DEVICE_ATTR(out0_scale, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_scale, S_IRUGO | S_IWUSR, ad5933_show, ad5933_store, AD5933_OUT_RANGE); -static IIO_DEVICE_ATTR(out0_scale_available, S_IRUGO, +static IIO_DEVICE_ATTR(out_voltage0_scale_available, S_IRUGO, ad5933_show, NULL, AD5933_OUT_RANGE_AVAIL); -static IIO_DEVICE_ATTR(in0_scale, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(in_voltage0_scale, S_IRUGO | S_IWUSR, ad5933_show, ad5933_store, AD5933_IN_PGA_GAIN); -static IIO_DEVICE_ATTR(in0_scale_available, S_IRUGO, +static IIO_DEVICE_ATTR(in_voltage0_scale_available, S_IRUGO, ad5933_show, NULL, AD5933_IN_PGA_GAIN_AVAIL); -static IIO_DEVICE_ATTR(out0_freq_points, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_freq_points, S_IRUGO | S_IWUSR, ad5933_show, ad5933_store, AD5933_FREQ_POINTS); -static IIO_DEVICE_ATTR(out0_settling_cycles, S_IRUGO | S_IWUSR, +static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, S_IRUGO | S_IWUSR, ad5933_show, ad5933_store, AD5933_OUT_SETTLING_CYCLES); @@ -467,14 +467,14 @@ static IIO_DEVICE_ATTR(out0_settling_cycles, S_IRUGO | S_IWUSR, * don't create dedicated sysfs channel attributes for out0 and in0. */ static struct attribute *ad5933_attributes[] = { - &iio_dev_attr_out0_scale.dev_attr.attr, - &iio_dev_attr_out0_scale_available.dev_attr.attr, - &iio_dev_attr_out0_freq_start.dev_attr.attr, - &iio_dev_attr_out0_freq_increment.dev_attr.attr, - &iio_dev_attr_out0_freq_points.dev_attr.attr, - &iio_dev_attr_out0_settling_cycles.dev_attr.attr, - &iio_dev_attr_in0_scale.dev_attr.attr, - &iio_dev_attr_in0_scale_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_scale.dev_attr.attr, + &iio_dev_attr_out_voltage0_scale_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_start.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_increment.dev_attr.attr, + &iio_dev_attr_out_voltage0_freq_points.dev_attr.attr, + &iio_dev_attr_out_voltage0_settling_cycles.dev_attr.attr, + &iio_dev_attr_in_voltage0_scale.dev_attr.attr, + &iio_dev_attr_in_voltage0_scale_available.dev_attr.attr, NULL }; diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 1bb71864d58..04c7ab015b8 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -445,7 +445,7 @@ exit: return count; } -static IIO_DEVICE_ATTR(magn_range, +static IIO_DEVICE_ATTR(in_magn_range, S_IWUSR | S_IRUGO, show_range, set_range, @@ -490,7 +490,7 @@ static struct attribute *hmc5843_attributes[] = { &iio_dev_attr_meas_conf.dev_attr.attr, &iio_dev_attr_operating_mode.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_dev_attr_magn_range.dev_attr.attr, + &iio_dev_attr_in_magn_range.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL }; diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 8cf7308874b..3d62bfdde97 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -454,8 +454,8 @@ out: } static IIO_DEV_ATTR_TEMP_RAW(ade7753_read_8bit); -static IIO_CONST_ATTR(temp_offset, "-25 C"); -static IIO_CONST_ATTR(temp_scale, "0.67 C"); +static IIO_CONST_ATTR(in_temp_offset, "-25 C"); +static IIO_CONST_ATTR(in_temp_scale, "0.67 C"); static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7753_read_frequency, @@ -466,9 +466,9 @@ static IIO_DEV_ATTR_RESET(ade7753_write_reset); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500"); static struct attribute *ade7753_attributes[] = { - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, + &iio_dev_attr_in_temp_raw.dev_attr.attr, + &iio_const_attr_in_temp_offset.dev_attr.attr, + &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 8adb2a98bb3..cdb62a40a42 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -473,8 +473,8 @@ out: return ret ? ret : len; } static IIO_DEV_ATTR_TEMP_RAW(ade7754_read_8bit); -static IIO_CONST_ATTR(temp_offset, "129 C"); -static IIO_CONST_ATTR(temp_scale, "4 C"); +static IIO_CONST_ATTR(in_temp_offset, "129 C"); +static IIO_CONST_ATTR(in_temp_scale, "4 C"); static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7754_read_frequency, @@ -485,9 +485,9 @@ static IIO_DEV_ATTR_RESET(ade7754_write_reset); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000"); static struct attribute *ade7754_attributes[] = { - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, + &iio_dev_attr_in_temp_raw.dev_attr.attr, + &iio_const_attr_in_temp_offset.dev_attr.attr, + &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 7cbf1cb198f..6507875f846 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -584,8 +584,8 @@ out: } static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit); -static IIO_CONST_ATTR(temp_offset, "129 C"); -static IIO_CONST_ATTR(temp_scale, "4 C"); +static IIO_CONST_ATTR(in_temp_offset, "129 C"); +static IIO_CONST_ATTR(in_temp_scale, "4 C"); static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit, ADE7758_AWATTHR); @@ -615,9 +615,9 @@ static IIO_DEV_ATTR_RESET(ade7758_write_reset); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255"); static struct attribute *ade7758_attributes[] = { - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, + &iio_dev_attr_in_temp_raw.dev_attr.attr, + &iio_const_attr_in_temp_offset.dev_attr.attr, + &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 8e44e46d82a..69b1f8bba3d 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -413,8 +413,8 @@ out: return ret ? ret : len; } static IIO_DEV_ATTR_TEMP_RAW(ade7759_read_8bit); -static IIO_CONST_ATTR(temp_offset, "70 C"); -static IIO_CONST_ATTR(temp_scale, "1 C"); +static IIO_CONST_ATTR(in_temp_offset, "70 C"); +static IIO_CONST_ATTR(in_temp_scale, "1 C"); static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7759_read_frequency, @@ -425,9 +425,9 @@ static IIO_DEV_ATTR_RESET(ade7759_write_reset); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500"); static struct attribute *ade7759_attributes[] = { - &iio_dev_attr_temp_raw.dev_attr.attr, - &iio_const_attr_temp_offset.dev_attr.attr, - &iio_const_attr_temp_scale.dev_attr.attr, + &iio_dev_attr_in_temp_raw.dev_attr.attr, + &iio_const_attr_in_temp_offset.dev_attr.attr, + &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h index 174f2c6bf3f..868952b5ba6 100644 --- a/drivers/staging/iio/sysfs.h +++ b/drivers/staging/iio/sysfs.h @@ -106,13 +106,13 @@ struct iio_const_attr { IIO_CONST_ATTR(sampling_frequency_available, _string) #define IIO_DEV_ATTR_TEMP_RAW(_show) \ - IIO_DEVICE_ATTR(temp_raw, S_IRUGO, _show, NULL, 0) + IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0) #define IIO_CONST_ATTR_TEMP_OFFSET(_string) \ - IIO_CONST_ATTR(temp_offset, _string) + IIO_CONST_ATTR(in_temp_offset, _string) #define IIO_CONST_ATTR_TEMP_SCALE(_string) \ - IIO_CONST_ATTR(temp_scale, _string) + IIO_CONST_ATTR(in_temp_scale, _string) enum iio_event_type { IIO_EV_TYPE_THRESH, From cedd1a16bbe00456fb9abda237e9b1c2bc763edd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 14 Sep 2011 13:01:24 +0100 Subject: [PATCH 1019/1519] staging:iio:adc:ad7606 add channel type specification to range attributes. Cleaner and more consistent naming + makes one abi element we don't need go away. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606_core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index bea663dc25d..f22f668c6bc 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -140,9 +140,9 @@ static ssize_t ad7606_store_range(struct device *dev, return count; } -static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, \ +static IIO_DEVICE_ATTR(in_voltage_range, S_IRUGO | S_IWUSR, \ ad7606_show_range, ad7606_store_range, 0); -static IIO_CONST_ATTR(range_available, "5000 10000"); +static IIO_CONST_ATTR(in_voltage_range_available, "5000 10000"); static ssize_t ad7606_show_oversampling_ratio(struct device *dev, struct device_attribute *attr, char *buf) @@ -198,8 +198,8 @@ static IIO_DEVICE_ATTR(oversampling_ratio, S_IRUGO | S_IWUSR, static IIO_CONST_ATTR(oversampling_ratio_available, "0 2 4 8 16 32 64"); static struct attribute *ad7606_attributes[] = { - &iio_dev_attr_range.dev_attr.attr, - &iio_const_attr_range_available.dev_attr.attr, + &iio_dev_attr_in_voltage_range.dev_attr.attr, + &iio_const_attr_in_voltage_range_available.dev_attr.attr, &iio_dev_attr_oversampling_ratio.dev_attr.attr, &iio_const_attr_oversampling_ratio_available.dev_attr.attr, NULL, @@ -220,9 +220,10 @@ static mode_t ad7606_attr_is_visible(struct kobject *kobj, &iio_const_attr_oversampling_ratio_available.dev_attr.attr)) mode = 0; else if (!st->have_range && - (attr == &iio_dev_attr_range.dev_attr.attr || - attr == &iio_const_attr_range_available.dev_attr.attr)) - mode = 0; + (attr == &iio_dev_attr_in_voltage_range.dev_attr.attr || + attr == + &iio_const_attr_in_voltage_range_available.dev_attr.attr)) + mode = 0; return mode; } From a9e39f9e80ac24367e375c8ea110dfaec837b020 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 14 Sep 2011 13:01:25 +0100 Subject: [PATCH 1020/1519] staging:iio: move id and device name setting to iio_device_allocate. The recent reorganization of the sysfs attribute registration had the side effect of moving iio_device_register after registration of triggers etc. The side effect of this is that the id hadn't been allocated by the time of trigger registration. Thus all triggers based on device got the name -dev0 instead of -devN where N is the iio device id. This should also fix the lack of device name for some error messages that we have been seeing (and I'd been meaning to track down) as that has now moved earlier as well. Reported-by: Manuel Stahl Signed-off-by: Jonathan Cameron Tested-by: Manuel Stahl Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-core.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index fd4aadaa06f..8eba592125d 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1033,6 +1033,15 @@ struct iio_dev *iio_allocate_device(int sizeof_priv) device_initialize(&dev->dev); dev_set_drvdata(&dev->dev, (void *)dev); mutex_init(&dev->mlock); + + dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); + if (dev->id < 0) { + /* cannot use a dev_err as the name isn't available */ + printk(KERN_ERR "Failed to get id\n"); + kfree(dev); + return NULL; + } + dev_set_name(&dev->dev, "iio:device%d", dev->id); } return dev; @@ -1041,8 +1050,10 @@ EXPORT_SYMBOL(iio_allocate_device); void iio_free_device(struct iio_dev *dev) { - if (dev) + if (dev) { + ida_simple_remove(&iio_ida, dev->id); kfree(dev); + } } EXPORT_SYMBOL(iio_free_device); @@ -1100,14 +1111,6 @@ int iio_device_register(struct iio_dev *dev_info) { int ret; - dev_info->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); - if (dev_info->id < 0) { - ret = dev_info->id; - dev_err(&dev_info->dev, "Failed to get id\n"); - goto error_ret; - } - dev_set_name(&dev_info->dev, "iio:device%d", dev_info->id); - /* configure elements for the chrdev */ dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id); @@ -1115,7 +1118,7 @@ int iio_device_register(struct iio_dev *dev_info) if (ret) { dev_err(dev_info->dev.parent, "Failed to register sysfs interfaces\n"); - goto error_free_ida; + goto error_ret; } ret = iio_device_register_eventset(dev_info); if (ret) { @@ -1142,8 +1145,6 @@ error_unreg_eventset: iio_device_unregister_eventset(dev_info); error_free_sysfs: iio_device_unregister_sysfs(dev_info); -error_free_ida: - ida_simple_remove(&iio_ida, dev_info->id); error_ret: return ret; } From ada4f4f804e81425e96f2a0b84a6f00745156988 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:45 +0100 Subject: [PATCH 1021/1519] staging: wlags49_h2: Remove non-linux configurations For now just remove from hcfcfg.h, we will slowly remove the unused configurations as we go Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcfcfg.h | 1524 --------------------------- 1 file changed, 1524 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcfcfg.h b/drivers/staging/wlags49_h2/hcfcfg.h index 83475b1060a..32db3817853 100644 --- a/drivers/staging/wlags49_h2/hcfcfg.h +++ b/drivers/staging/wlags49_h2/hcfcfg.h @@ -300,493 +300,6 @@ typedef unsigned long hcf_32; #define HCF_TALLIES_HCF 0x0002 // HCF Tallies accumulated in IFB #define HCF_TALLIES_RESET 0x8000 // Tallies in IFB are reset when reported via hcf_get_info - -/************************************************************************************************/ -/****************************** M I N I P O R T N D I S *************************************/ -/************************************************************************************************/ - -#if defined WVLAN_41 || defined WVLAN_48 || defined WVLAN_52 || defined _WIN32_WCE - -#ifndef WVLAN_46 -#define HCF_EXT (HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS ) -#else -#define HCF_EXT ( HCF_EXT_TX_CONT | HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS ) -#endif -#define HCF_DLV 1 //H-I legacy, superfluous for H-II - -#ifdef _WIN32_WCE -#define HCF_IO HCF_IO_MEM -#define HCF_DMA 0 // To enable DMA -#endif - -#if _VARIANT == 7 -#define HCF_SLEEP HCF_CDS -#endif // _VARIANT == 7 - -#if _VARIANT == 5 || _VARIANT == 6 -#define _WARP -#define _AES -#define HCF_SLEEP HCF_CDS -#if _VARIANT == 6 -//! #define _RSN -#endif // _VARIANT == 6 -#ifndef _WIN32_WCE -#define HCF_IO HCF_IO_32BITS -#define HCF_DMA 1 // To enable DMA -#endif -#endif // _VARIANT == 5 || _VARIANT == 6 - - -//HWi for migration purposes I defined a define which will be TRUE for ALL drivers -//Meaning that _CCX defined code which we think will get a all driver OK flag can be defined from _CCX to _CCX_OK -#if defined WVLAN_48 // && !defined _WIN32_WCE -#if _VARIANT == 4 || _VARIANT == 6 -#define _CCX_OK 1 -#endif // _VARIANT == 4 || _VARIANT == 6 -#endif // WVLAN_48 - -//#if !defined WVLAN_46 -#if defined WVLAN_48 -#if _VARIANT == 4 || _VARIANT == 6 -#define _CCX -#define HCF_MAX_MSG_CKIP_PADDING 86 //, use 86 for rx fragmentation. 28 is enuf for MIC+PPK encapsulation -#define HCF_MAX_MSG ( 1514 + HCF_MAX_MSG_CKIP_PADDING ) // need extra padding for CKIP (need to subtract 28 for NDIS) -#endif // _VARIANT == 4 || _VARIANT == 6 -#endif // WVLAN_48 -//#endif // WVLAN_46 - -#if !defined WVLAN_46 -#define _PEEK -#endif - -#ifndef _WIN32_WCE -// ASSERT already used by WinCE... -#ifdef ASSERT -#undef ASSERT -#define ASSERT(x) ASSERTDEBUGMSG((x), (TEXT("SIMULATE ASSERT:"))) -#endif -#endif - - -#if defined WVLAN_41 -#define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_31 -#endif // WVLAN_41 -#if defined WVLAN_48 && !defined _WIN32_WCE -#define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_50 -#endif // WVLAN_48 / _WIN32_WCE -#if defined WVLAN_52 && !defined _WIN32_WCE -#define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_40 -#endif // WVLAN_52 / _WIN32_WCE -#if defined WVLAN_46 -#define MSF_COMPONENT_ID COMP_ID_WIN_CE -#endif // _WIN32_WCE - -#define MSF_COMPONENT_VAR _VARIANT - -#define T1__HCF_TYPE (HCF_TYPE_NONE) - -#define T2__HCF_TYPE (T1__HCF_TYPE) - -#ifdef _WARP -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5 | HCF_TYPE_WARP ) -#else -#if _VARIANT == 7 -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5) -#else // _VARIANT == 7 -#define T3__HCF_TYPE (T2__HCF_TYPE) -#endif // _VARIANT == 7 -#endif // _WARP - -#ifdef _CCX_OK -#define T4__HCF_TYPE (T3__HCF_TYPE | HCF_TYPE_CCX) -#else -#define T4__HCF_TYPE (T3__HCF_TYPE) -#endif // _CCX_OK - -//not suitable for H-II #define HCF_CFG_STA_1_BOTTOM 16 - -// Default WPA in ON for all drivers except for WARP driver -#ifdef _WARP -#define T5__HCF_TYPE (T4__HCF_TYPE) -#else // _WARP -#define T5__HCF_TYPE (T4__HCF_TYPE | HCF_TYPE_WPA) -#endif // _WARP - -#define HCF_TYPE (T5__HCF_TYPE) - -// This is needed to get aux_ctrl() from the HCF for WlFreezeAndDump() -#if (defined DBG && DBG != 0) -#ifndef STATIC -#define STATIC -#endif -#endif - -#if !defined SOFTRONICS_CODE && !defined _APIDLL && !defined _WIN32_WCE -#include -#endif // SOFTRONICS_CODE / _APIDLL / _WIN32_WCE -#if defined _WIN32_WCE -#include -#include -#endif // _WIN32_WCE -#include "version.h" - -#define MSF_COMPONENT_MAJOR_VER TPI_MAJOR_VERSION -#define MSF_COMPONENT_MINOR_VER TPI_MINOR_VERSION - -#if !defined _APIDLL && !defined _WIN32_WCE - -__inline UCHAR NDIS_IN_BYTE( ULONG port ) -{ - UCHAR value; - NdisRawReadPortUchar(port , &value); - return (value); -} - -__inline ULONG NDIS_IN_LONG( ULONG port ) -{ - ULONG value; - NdisRawReadPortUlong(port , &value); - return (value); -} -__inline USHORT NDIS_IN_WORD( ULONG port ) -{ - USHORT value; - NdisRawReadPortUshort(port , &value); - return (value); -} - -#define IN_PORT_DWORD(port) NDIS_IN_LONG( (ULONG) (port) ) -#define IN_PORT_WORD(port) NDIS_IN_WORD( (ULONG) (port) ) -#define OUT_PORT_DWORD(port, value) NdisRawWritePortUlong((ULONG) (port) , value) -#define OUT_PORT_WORD(port, value) NdisRawWritePortUshort((ULONG) (port) , (USHORT) (value)) - -#define IN_PORT_STRING_8_16(port, addr, len) IN_PORT_STRING_16(port, addr, len) -#define OUT_PORT_STRING_8_16(port, addr, len) OUT_PORT_STRING_16(port, addr, len) - -#define IN_PORT_STRING_32(port, addr, len) { \ - NdisRawReadPortBufferUlong(port, addr, (len)); \ -} - -#define OUT_PORT_STRING_32(port, addr, len) { \ - NdisRawWritePortBufferUlong(port, addr, (len)); \ -} - -#define IN_PORT_STRING_16(port, addr, len) NdisRawReadPortBufferUshort(port, addr, (len)); -#define OUT_PORT_STRING_16(port, addr, len) NdisRawWritePortBufferUshort(port, addr, (len)); - -#endif // _APIDLL / _WIN32_WCE - -#if defined _WIN32_WCE - -#define HCF_ALIGN 2 -#define HCF_MEM_IO 1 // overrule standard Port I/O with Memory mapped I/O -#define HCF_PROT_TIME 49 - -#define IN_PORT_BYTE CE_IN_PORT_BYTE -#define OUT_PORT_BYTE CE_OUT_PORT_BYTE -#define IN_PORT_WORD CE_IN_PORT_WORD -#define OUT_PORT_WORD CE_OUT_PORT_WORD -#define IN_PORT_STRING_16 CE_IN_PORT_STRING -#define OUT_PORT_STRING_16 CE_OUT_PORT_STRING - -extern hcf_8 CE_IN_PORT_BYTE(hcf_32 port); -extern void CE_OUT_PORT_BYTE(hcf_32 port, hcf_8 value); -extern hcf_16 CE_IN_PORT_WORD(hcf_32 port); -extern void CE_OUT_PORT_WORD(hcf_32 port, hcf_16 value); -extern void CE_IN_PORT_STRING(hcf_32 port, void *addr, hcf_16 len); -extern void CE_OUT_PORT_STRING(hcf_32 port, void *addr, hcf_16 len); - - -#endif - -#if defined _DEBUG || (defined DBG && DBG != 0) -#define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF ) //0xC001 -//#define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF | HCF_ASSERT_MB ) //just to test -#endif // _DEBUG || DBG - -#if defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0) -#ifdef _WIN32_WCE -#define DBGA2W(DBGSTR) CeConvertAnsiToUnicodeLen((char*)DBGSTR) -#define OUTPUTDEBUGMSG(dprintf_exp) ((void)((! ZONE_DEBUG) ? 0:ce_debug_out dprintf_exp)) -#define ASSERTDEBUGMSG(cond, dprintf_exp) ((void)((cond) ? 0:ce_debug_out dprintf_exp)) - -#define ZONE_ERROR DEBUGZONE(0) -#define ZONE_WARN DEBUGZONE(1) -#define ZONE_FUNCTION DEBUGZONE(2) -#define ZONE_INIT DEBUGZONE(3) -#define ZONE_INTR DEBUGZONE(4) -#define ZONE_RCV DEBUGZONE(5) -#define ZONE_XMIT DEBUGZONE(6) -#define ZONE_ASSERT DEBUGZONE(7) -#define ZONE_DEBUG DEBUGZONE(8) -#define ZONE_OEM DEBUGZONE(9) -#define ZONE_HCF DEBUGZONE(10) -#define ZONE_PORTIO DEBUGZONE(11) -#define ZONE_LOGTOFILE DEBUGZONE(15) - -#else // !(_WIN32_WCE) - -#define OUTPUTDEBUGMSG(dprintf_exp) ((void) (DbgPrint dprintf_exp)) -// the assertdebugmsg macro will print filename, line followed by a caller-defined text, when cond == 0 -#define ASSERTDEBUGMSG(cond, print) ((void)((cond) ? 0: (DbgPrint("%s %s:%d - ", print, __FILE__, __LINE__)))) - -#define ZONE_ERROR 1 -#define ZONE_WARN 1 -#define ZONE_FUNCTION 1 -#define ZONE_INIT 1 -#define ZONE_INTR 1 -#define ZONE_RCV 1 -#define ZONE_XMIT 1 -#define ZONE_ASSERT 1 -#define ZONE_DEBUG 1 -#define ZONE_OEM 1 -#define ZONE_HCF 1 -#define ZONE_PORTIO 1 -#define ZONE_LOGTOFILE 1 - -#endif // _WIN32_WCE -#ifndef DBGA2W -#define DBGA2W -#endif // DBGA2W - -#else // !(defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0) ) -#define OUTPUTDEBUGMSG(dprintf_exp) -#define ASSERTDEBUGMSG(cond, dprintf_exp) -#endif // DEBUG / DBG - -#if !defined HCF_MAX_MSG_CKIP_PADDING -#define HCF_MAX_MSG_CKIP_PADDING 0 -#endif // HCF_MAX_MSG_CKIP_PADDING - -#if !defined HCF_MAX_MSG -#define HCF_MAX_MSG 1514 -#endif // HCF_MAX_MSG - -#define HCF_LEGACY 1 //;?nv je moet wat - -#endif //WVLAN_41 / WVLAN_48 / WVLAN_52 / _WIN32_WCE - - -/************************************************************************************************/ -/**************************** P A C K E T D R I V E R ***************************************/ -/********************************** D O S O D I *********************************************/ -/************************************************************************************************/ - -#if defined WVLAN_42 || defined WVLAN_43 - -#pragma warning ( disable: 4001 ) -#define FAR __far //segmented 16 bits mode -#define BASED __based(__segname("_CODE")) //force all the "const" structures in the CODE segment - -//#define HCF_IO 0 //no DMA, no 32 bits - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -#define HCF_EXT HCF_EXT_MB -#define HCF_PROT_TIME 49 //49*10240 microseconds H/W failure protection timer - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -/******************************** CONFIGURATION MANAGEMENT *****************************************/ -#ifdef WVLAN_42 -#define MSF_COMPONENT_ID COMP_ID_PACKET -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 6 -#define MSF_COMPONENT_MINOR_VER 12 -#endif // WVLAN_42 - -#ifdef WVLAN_43 -#define MSF_COMPONENT_ID COMP_ID_ODI_16 -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 6 -#define MSF_COMPONENT_MINOR_VER 10 -#endif // WVLAN_43 - -/************************************** INPUT / OUTPUT **********************************************/ -#ifndef H_2_INC -#include -#include -#if 1 //temorary use functions defined in hcf.c -#ifndef _DEBUG -#pragma intrinsic( _inp, _inpw, _outp, _outpw ) -#endif // _DEBUG - -#define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value )) - -#if 1 // C implementation which let the processor handle the word-at-byte-boundary problem -#define IN_PORT_STRING_8_16( port, addr, n) while (n--) \ - { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_8 FAR*)addr)+=2; } -#define OUT_PORT_STRING_8_16( port, addr, n) while (n--) \ - { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; ((hcf_8 FAR*)addr)+=2; } -#elif 0 // C implementation which handles the word-at-byte-boundary problem -#define IN_PORT_STRING_8_16( port, addr, n) while ( n-- ) \ - { hcf_16 i = IN_PORT_WORD(port); *((hcf_8 FAR*)addr)++ = (hcf_8)i; *((hcf_8 FAR*)addr)++ = (hcf_8)(i>>8);} -#define OUT_PORT_STRING_8_16( port, addr, n) while ( n-- ) \ - { OUT_PORT_WORD( port, *((hcf_8 FAR*)addr) | *(((hcf_8 FAR*)addr)+1)<<8 ); (hcf_8 FAR*)addr+=2; } -#else // Assembler implementation -#define IN_PORT_STRING_8_16( port, addr, n) __asm \ -{ \ - __asm push di \ - __asm push es \ - __asm mov cx,n \ - __asm les di,addr \ - __asm mov dx,port \ - __asm rep insw \ - __asm pop es \ - __asm pop di \ -} - -#define OUT_PORT_STRING_8_16( port, addr, n) __asm \ -{ \ - __asm push si \ - __asm push ds \ - __asm mov cx,n \ - __asm lds si,addr \ - __asm mov dx,port \ - __asm rep outsw \ - __asm pop ds \ - __asm pop si \ -} - -#endif // Asm or C implementation -#define IN_PORT_STRING_32( port, addr, n) { int n2 = 2*n; IN_PORT_STRING_8_16(port, addr, n2) } -#define OUT_PORT_STRING_32( port, addr, n) { int n2 = 2*n; OUT_PORT_STRING_8_16(port, addr, n2) } -#endif // 0 //temorary use functions defined in hcf.c -#endif // H_2_INC - -#endif // WVLAN_42 / WVLAN_43 - - - -/************************************************************************************************/ -/**************************** D O S H - I / II L O A D E R **********************************/ -/************************************************************************************************/ - -#if defined H0_LDR || defined H1_LDR || defined H2_LDR || defined H5_LDR - -#if defined H0_LDR //implies H-I -#define HCF_DLV 0 //H-I legacy, meaningless under H-II -#define HCF_DLNV 1 //H-I legacy, meaningless under H-II -#endif // H0_LDR - -#if defined H1_LDR //implies H-I -#define HCF_DLV 1 //H-I legacy, meaningless under H-II -#define HCF_DLNV 0 //H-I legacy, meaningless under H-II -#endif // H1_LDR / H2_LDR - -//#if defined H2_LDR : not needed, H-II defaults are O.K for H2_LDR - -#ifdef H5_LDR -#define HCF_TYPE (HCF_TYPE_HII5 | HCF_TYPE_WARP ) -//;? why does only this subset of the H_LDRs need HCF_TYPE to be defined here -#endif - -#define HCF_ASSERT HCF_ASSERT_LNK_MSF_RTN //support dynamic linking of msf_assert routine -#define HCF_ENCAP 0 -#define HCF_INT_ON 0 -#define HCF_TALLIES 0 - -#define MSF_COMPONENT_ID COMP_ID_ODI_16 //;?By lack of any better -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 0 -#define MSF_COMPONENT_MINOR_VER 0 - -#include -#include -#if defined NDEBUG -#pragma intrinsic( _inp, _inpw, _outp, _outpw ) -#endif // NDEBUG - -#if 0 //use 0 to replace I/O Macros with logging facility -#define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value )) -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; } -#endif //use 0 to replace I/O Macros with logging facility - -#endif // H0_LDR / H1_LDR / H2_LDR - - - -/************************************************************************************************/ -/**************************** H C F D E M O P R O G R A M ***********************************/ -/************************************************************************************************/ - -#if defined HCF_DEMO - -#define HCF_DLV 1 //;?should become the default !defaults to 1 anyway for H-II -//#define HCF_DLNV 0 //defaults to 0 anyway for H-II - -#define HCF_ASSERT HCF_ASSERT_LNK_MSF_RTN //support dynamic linking of msf_assert routine - -#define HCF_ENCAP 0 -#define HCF_INT_ON 0 -#define HCF_TALLIES ( HCF_TALLIES_NIC | HCF_TALLIES_HCF ) - -//#define MSF_COMPONENT_ID NO configuration management - -#include -#include -#if defined NDEBUG -#pragma intrinsic( _inp, _inpw, _outp, _outpw ) -#endif // NDEBUG - -#if 0 //use 0 to replace I/O Macros with logging facility -#define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value )) -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; } -#endif //use 0 to replace I/O Macros with logging facility - -#endif // HCF_DEMO - - - -/************************************************************************************************/ -/*********************************** M A C O S **********************************************/ -/************************************************************************************************/ - -#if defined WVLAN_45 - -#include "Version.h" - -#define MSF_COMPONENT_ID COMP_ID_MAC_OS -#define MSF_COMPONENT_VAR VARIANT -#define MSF_COMPONENT_MAJOR_VER VERSION_MAJOR -#define MSF_COMPONENT_MINOR_VER VERSION_MINOR - -#define MAC_OS 1 - -#define HCF_BIG_ENDIAN 1 // selects Big Endian (a.k.a. Motorola), most significant byte first - -#if defined DEBUG -#define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox -#endif // DEBUG - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus -extern volatile unsigned char *MacIOaddr; -extern hcf_16 IN_PORT_WORD(hcf_16 port); -extern void OUT_PORT_WORD(hcf_16 port, hcf_16 value); -extern void IN_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len); -extern void OUT_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len); - -#define SwapBytes(t) (((t) >> 8) + (((t) & 0xff) << 8)) - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // WVLAN_45 - - - /************************************************************************************************/ /****************************************** L I N U X *****************************************/ /************************************************************************************************/ @@ -951,1043 +464,6 @@ extern void OUT_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len); #define HCF_MAX_MSG 1600 //get going ;? #endif // WVLAN_49 - - -/************************************************************************************************/ -/********************************************* Q N X ******************************************/ -/************************************************************************************************/ - -#if defined __QNX__ || defined WVLAN_50 - -#define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ... -#define MSF_COMPONENT_VAR 0 //...compatibilty check to function -#define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more -#define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do - -#include - -#define IN_PORT_WORD(port) ((hcf_16)inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) (outpw( (hcf_io)(port), (hcf_16) (value) )) -/* -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; } -*/ - -#endif // QNX / WVLAN_50 - - - -/************************************************************************************************/ -/********************************************* B E O S ****************************************/ -/************************************************************************************************/ - -#if defined __BEOS__ - -#define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ... -#define MSF_COMPONENT_VAR 0 //...compatibilty check to function -#define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more -#define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do - -#include -#include - -uint8 read_io_8 (int); -void write_io_8 (int, uint8); -uint16 read_io_16 (int); -void write_io_16 (int, uint16); - -#define IN_PORT_WORD(port) ((hcf_16)read_io_16( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) (write_io_16( (hcf_io)(port), (hcf_16) (value) )) -/* -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; } -*/ -#endif // __BEOS__ - - - -/************************************************************************************************/ -/******************************** U S B D O N G L E *****************************************/ -/************************************************************************************************/ - -#if defined USB -#include "gpif.h" - -#define MSF_COMPONENT_MAJOR_VER 0 -#define MSF_COMPONENT_MINOR_VER 1 - -#define IN_PORT_WORD(port) (Hermes_IO_Read( (hcf_8)(port))) -#define OUT_PORT_WORD(port, value) (Hermes_IO_Write( (hcf_8)port, /*(hcf_16)*/(value) ) ) -/* !!!! NOTE USB supports only 16-bits I/O and no 8-bits I/O - * as a consequence the IN_/OUT_PORT_STRING_16 macros use hcf_16* rather than hcf_8 pointers - * to get more optimal code - * therefore the pointers are incremented by 1 (which means two "bytes") rather than by 2 - */ -//#define IN_PORT_STRING_16( port, addr, n) while ( n-- ) { *((hcf_16*)addr)++ = IN_PORT_WORD( port ); } -//#define OUT_PORT_STRING_16( port, addr, n) while ( n-- ) { OUT_PORT_WORD( port, *((hcf_16*)addr)++ ); } -#define IN_PORT_STRING_16( port, dst, n) while ( n-- ) { *dst++ = IN_PORT_WORD( port ); } -#define OUT_PORT_STRING_16( port, src, n) while ( n-- ) { OUT_PORT_WORD( port, *src++ ); } - -//#define HCF_TYPE ( HCF_TYPE_AP | HCF_TYPE_WPA ) -#define HCF_TYPE HCF_TYPE_WPA - -#endif // USB - - -/************************************************************************************************/ -/****************************************** FreeBSD *******************************************/ -/************************************************************************************************/ - -#if defined __FREE_BSD__ - -#define MSF_COMPONENT_ID COMP_ID_FreeBSD -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#include - -#define IN_PORT_WORD(port) ((hcf_16)inw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) (outw((hcf_io)(port), (hcf_16)(value))) - -/* -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; } -*/ -#endif // __FREE_BSD__ - - - -/************************************************************************************************/ -/********************************* W A V E P O I N T ******************************************/ -/************************************************************************************************/ - -#if defined WVLAN_81 /* BORLANDC */ - -#define EXTERN_C extern // needed because DHF uses this instead of 'extern' - -#define MSF_COMPONENT_ID COMP_ID_AP1 -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 4 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_PROT_TIME 49 //49*10240 microseconds H/W failure protection timer - -//#define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox /* debug build only */ - -#if !defined FAR -#define FAR far // segmented 16 bits mode -#endif // FAR - -#define IN_PORT_WORD(port) (inport( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) (outport( (hcf_io)(port), value )) - -#define IN_PORT_STRING_16(port, addr, len) \ - asm { push di; push es; mov cx,len; les di,addr; mov dx,port; rep insw; pop es; pop di } - -#define OUT_PORT_STRING_16(port, addr, len) \ - asm { push si; push ds; mov cx,len; lds si,addr; mov dx,port; rep outsw; pop ds; pop si } - -#endif // WVLAN_81 - - -/************************************************************************************************/ -/******************************** W A V E L A U N C H *****************************************/ -/************************************************************************************************/ - -#if defined WVLAUNCH - -#include "DriverX.h" -extern HWDEVICE* g_pDevice; - -//#define MSF_COMPONENT_ID 0 //;? to get around browser problem - -#define IN_PORT_WORD(port) HwInpw( g_pDevice, port ) -#define OUT_PORT_WORD(port, value) HwOutpw( g_pDevice, port, value ) - - -// C implementation which let the processor handle the word-at-byte-boundary problem -/* -#define IN_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; } -#define OUT_PORT_STRING_16( port, addr, n) \ - while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; } -*/ -#endif // WVLAUNCH - - - -/************************************************************************************************/ -/************************************* W C I T S T *********************************************/ -/************************************************************************************************/ - -#if defined WCITST -#define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ... -#define MSF_COMPONENT_VAR 0 //...compatibilty check to function -#define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more -#define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do - -//#define HCF_ENCAP HCF_ENC_NONE //to get going -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#define HCF_TYPE (HCF_TYPE_WPA | HCF_TYPE_PRELOADED) // Hermes-I for HCF6, II for HCF7 -#define HCF_DMA 1 -//#define LLB //!!!!MIC Debug Only -#if defined LLB && !((HCF_TYPE) & HCF_TYPE_WPA) -err: no LLB unless SSN; -#endif // LLB / HCF_TYPE_WPA -//#define HCF_ALIGN 2 -#define HCF_DLV 1 //just to change memory layout ????;? -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -#define HCF_ASSERT HCF_ASSERT_SW_SUP // logging via Hermes support registerr -//#define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox - -#if defined __GNUC__ -#include "stdio.h" -//#include "unistd.h" //ioperm libc5 -#include "sys/io.h" //ioperm glibc -#define extern //see IO Port Programming mini-HOWTO -//#include "asm/io.h" // -#define IN_PORT_WORD(port) inw( (hcf_io)(port) ) -#define IN_PORT_DWORD(port) inl( (hcf_io)(port) ) -#define OUT_PORT_WORD(port, value) outw( (hcf_io)(port), (hcf_16)(value) ) -#define OUT_PORT_DWORD(port, value) outl( (hcf_io)(port), (hcf_16)(value) ) -#else -#pragma warning ( disable: 4001 ) -#define FAR __far // segmented 16 bits mode - -#include -#include -#ifndef _DEBUG -#pragma intrinsic( _inp, _inpw, _outp, _outpw ) -#endif // _DEBUG - -#ifdef LOG -extern FILE* utm_logfile; -hcf_16 ipw( hcf_16 port ); -hcf_8 ipb( hcf_16 port ); -void opw( hcf_16 port, hcf_16 value ); -void opb( hcf_16 port, hcf_8 value ); - -#define IN_PORT_WORD(port) ipw( (hcf_io)(port) ) -#define OUT_PORT_WORD(port, value) opw( (hcf_io)(port), (hcf_16)(value) ) -#else // LOG -#define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value )) -#endif // LOG - -#if 1 //ASM example -#define IN_PORT_STRING_16( port, addr, len) __asm \ -{ \ - __asm push di \ - __asm push es \ - __asm mov cx,len \ - __asm les di,addr \ - __asm mov dx,port \ - __asm rep insw \ - __asm pop es \ - __asm pop di \ -} - -#define OUT_PORT_STRING_16( port, addr, len) __asm \ -{ \ - __asm push si \ - __asm push ds \ - __asm mov cx,len \ - __asm lds si,addr \ - __asm mov dx,port \ - __asm rep outsw \ - __asm pop ds \ - __asm pop si \ -} - -#endif // asm example - -#endif // __GCC__ - -#if ! defined IN_PORT_STRING_16 -#define IN_PORT_STRING_16( port, addr, n) while (n--) \ - { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_16 FAR*)addr)++; } -#define OUT_PORT_STRING_16( port, addr, n) while (n--) \ - { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ); ((hcf_16 FAR*)addr)++; } -#endif // IN_PORT_STRING_16 - -#endif // WCITST - - -/************************************************************************************************/ -/******************************* Motorola Power PC 800 family *********************************/ -/************************************************************************************************/ -/* known users: LH@I - */ - -#if defined I_MPC8XX - -#define MSF_COMPONENT_VAR 0 -#define MSF_COMPONENT_ID 0 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_HSI_VAR 1 - -#define HCF_BIG_ENDIAN 1 -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#include "o_portbl.h" -#include "ipcmcia.h" -typedef o_uint8_t hcf_8; -typedef o_uint16_t hcf_16; -typedef o_uint32_t hcf_32; - -/***************************************************************************/ - - -#ifdef _lint -#else -asm hcf_16 IN_PORT_WORD(int port) -{ -% reg port - lhbrx r3,r0,port - eieio -} -#endif // _lint - - -#ifdef _lint -#else -asm void OUT_PORT_WORD(int port, hcf_16 value) -{ -% reg port, value - sthbrx value,r0,port - eieio -} -#endif // _lint - -/***************************************************************************/ - -#define IN_PORT_STRING_16(port, addr, len) \ - { \ - unsigned l = (len); \ - hcf_16 *d = (volatile hcf_16 *)(addr); \ - while (l--) \ - { \ - *d++ = *(volatile hcf_16 *)(port); \ - EIEIO(); \ - } \ - } - -#define OUT_PORT_STRING_16(port, addr, len) \ - { \ - unsigned l = (len); \ - hcf_16 *s = (volatile hcf_16 *)(addr); \ - while (l--) \ - { \ - *(volatile hcf_16 *)(port) = *s++; \ - EIEIO(); \ - } \ - } - -#endif // I_MPC8XX - - - -/************************************************************************************************/ -/********************************** Diab or High C 29K **************************************/ -/************************************************************************************************/ -/* known users: GK@C - */ - -#if defined _AM29K - -#define MSF_COMPONENT_VAR 0 -#define MSF_COMPONENT_ID COMP_ID_AP1 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_BIG_ENDIAN 1 -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#define SwapBytes(t) /*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/ - -#if defined __ppc - #ifndef __GNUC__ - #define __asm__ asm - #endif - - #if ! defined _lint - #define EIEIO() __asm__(" eieio") - #else - #define EIEIO() - #endif - - static hcf_16 IN_PORT_WORD(int port) { - hcf_16 value = *(volatile hcf_16 *)(port); EIEIO(); - value = SwapBytes(value); - return value; - } - - #define OUT_PORT_WORD(port, value) \ - { *(volatile hcf_16 *)(port) = SwapBytes(value); EIEIO(); } -#else - #define IN_PORT_WORD(port) (*(volatile hcf_16 *)(port)) - #define OUT_PORT_WORD(port, value) (*(volatile hcf_16 *)(port) = (value)) -#endif // __ppc - -/***************************************************************************/ - -#define IN_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 t, *d = (volatile hcf_16 *)(addr); \ - while (l--) { \ - t = IN_PORT_WORD(port); \ - *d++ = SwapBytes(t); \ - } \ - } - -#define OUT_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 t, *s = (volatile hcf_16 *)(addr); \ - while (l--) { \ - t = *s++; \ - OUT_PORT_WORD(port, SwapBytes(t)); \ - } \ - } - -#if PRODUCT == 9150 - #define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox - #undef MSF_COMPONENT_ID -#endif // 9150 - -#endif // _AM29K - - - -/************************************************************************************************/ -/***************************************** MPC860 **********************************************/ -/************************************************************************************************/ -/* known users: RR - */ - -#if defined CPU -#if CPU == PPC860 - -#define MSF_COMPONENT_VAR 0 -#define MSF_COMPONENT_ID 0 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_BIG_ENDIAN 1 -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#define SwapBytes(t) /*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/ - -#ifndef __GNUC__ - #define __asm__ asm -#endif - -#if ! defined _lint - #define EIEIO() __asm__(" eieio") -#else - #define EIEIO() -#endif - -static hcf_16 IN_PORT_WORD(int port) { - hcf_16 value = *(volatile hcf_16 *)(port); EIEIO(); - value = SwapBytes(value); - return value; - #ifdef __GNUC__ - /* the following serves to avoid the compiler warnings that - * IN_PORT_WORD() is not used in some files */ - (void)IN_PORT_WORD; - #endif -} - -#define OUT_PORT_WORD(port, value) \ - { *(volatile hcf_16 *)(port) = SwapBytes(value); EIEIO(); } - -/***************************************************************************/ - -#define IN_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 t; \ - volatile hcf_16 *d = (volatile hcf_16 *)(addr); \ - while (l--) { \ - t = IN_PORT_WORD(port); \ - *d++ = SwapBytes(t); \ - } \ - } - -#define OUT_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 t; \ - volatile hcf_16 *s = (volatile hcf_16 *)(addr); \ - while (l--) { \ - t = *s++; \ - OUT_PORT_WORD(port, SwapBytes(t)); \ - } \ - } - -#if PRODUCT == 9150 - #define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox - #undef MSF_COMPONENT_ID -#endif - -#endif /* PPC860 */ -#endif /* CPU */ - - - -/************************************************************************************************/ -/**************************** Microtec Research 80X86 Compiler *********************************/ -/************************************************************************************************/ - -#if 0 - -//#undef HCF_TYPE // Hermes-I Station F/W without SSN support - -#define MSF_COMPONENT_VAR 0 -#define MSF_COMPONENT_ID 0 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -extern int far inp( int ); -extern void far outp( int, int ); -extern int far inpw( int ); -extern void far outpw( int, int ); - -#define IN_PORT_WORD(port) ((hcf_16)inpw( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) ((void)outpw( (hcf_io)(port), value )) - -#define IN_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 *d = (hcf_16 *)(addr); \ - while (l--) *d++ = IN_PORT_WORD(port); \ - } - -#define OUT_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 *s = (hcf_16 *)(addr); \ - while (l--) OUT_PORT_WORD(port, *s++); \ - } -#endif /* Microtec 80X86 C Compiler */ - - - -/************************************************************************************************/ -/****************************** W A V E L A N E C ********************************************/ -/************************************************************************************************/ -/* known users: KM - */ - -#ifdef mc68302 - -#define MSF_COMPONENT_ID COMP_ID_EC - -#include - -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER MAJOR_VERSION -#define MSF_COMPONENT_MINOR_VER MINOR_VERSION - -#define HCF_BIG_ENDIAN 1 -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#define SwapBytes(t) /*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/ - -#define PCMCIA_ADDRESS 0xc80000UL - -#define IN_PORT_2BYTES(port) (*(hcf_16 *)(port)) -#if 0 -static hcf_16 IN_PORT_WORD(hcf_32 port) // should be hcf_io, not hcf_32 -{ - hcf_16 word = IN_PORT_2BYTES(port); - return SwapBytes(word); -} -#else -static hcf_16 swap_var; -#define IN_PORT_WORD(port) \ - (((swap_var = IN_PORT_2BYTES(port)) >> 8) + (((swap_var) & 0xff) << 8)) -#endif -#define OUT_PORT_2BYTES(port, value) (*(hcf_16 *)(port) = (hcf_16)(value)) -#define OUT_PORT_WORD(port, value) OUT_PORT_2BYTES(port, SwapBytes(value)) - -/* -#define IN_PORT_STRING_16(port, addr, len) \ - while ((len)--) {*(hcf_16 *)(addr) = IN_PORT_2BYTES(port); ((cast)addr) += 2; } -#define OUT_PORT_STRING_16(port, addr, len) \ - while ((len)--) {OUT_PORT_2BYTES((port), *(hcf_16 *)(addr)) ; ((cast)addr) += 2; } -*/ - -#endif /* mc68302 */ - - - -/************************************************************************************************/ -/********************************* NGAP ***************************************/ -/************************************************************************************************/ - -#if defined __VX_WORKS__ /* VxWorks */ - -#if defined WLC_STATION -//#undef HCF_TYPE /* Hermes-I Station F/W without SSN support */ -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDSTA -#else -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDAP -#endif // WLC_STATION - -#define HCF_YIELD (taskDelay(0) == 0) - -#define MSF_COMPONENT_VAR 1 -#define MSF_COMPONENT_MAJOR_VER 1 -#define MSF_COMPONENT_MINOR_VER 0 - -// #define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox - -#if defined PC486BSP - -#define IN_PORT_WORD(port) (sysInWord ((hcf_io)(port))) -#define OUT_PORT_WORD(port, value) (sysOutWord ((hcf_io)(port), (hcf_16) (value))) -#define IN_PORT_STRING_16(port, addr, n) (sysInWordString ((hcf_io)(port), addr, n)) -#define OUT_PORT_STRING_16(port, addr, n) (sysOutWordString ((hcf_io)(port), addr, n)) - -#elif defined AS2000BSP - -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -/* Define PCI stuff here. */ -unsigned short sysRead16( unsigned short *port ); -void sysWrite16( unsigned short *port, unsigned short value ); - -#define PCI_IN_BYTE( port ) \ - *(unsigned char *)( port ) - -#define PCI_IN_WORD( port ) \ - sysRead16( (unsigned short *)( port ) ) - -#define PCI_OUT_BYTE( port, value ) \ - *(unsigned char *)( port ) = (unsigned char)( value ) - -#define PCI_OUT_WORD( port, value ) \ - sysWrite16( (unsigned short *)( port ), (unsigned short)( value ) ) - -#define IN_PORT_WORD( port ) \ - PCI_IN_WORD( port ) - -#define OUT_PORT_WORD( port, value ) \ - PCI_OUT_WORD( port, value ) - -#define IN_PORT_STRING_16( port, buf, len ) \ - do { \ - hcf_16 *p; \ - \ - for ( p = (hcf_16 *)(buf); p < &( (hcf_16 *)(buf) )[ (int)len ]; p++ ) { \ - *p = PCI_IN_WORD( port ); \ - } \ - } while ( 0 ) - -#define OUT_PORT_STRING_16( port, buf, len ) \ - do { \ - const hcf_16 *p; \ - \ - for ( p = (const hcf_16 *)( buf ); p < &( (const hcf_16 *)(buf) )[ (int)len ]; p++ ) { \ - PCI_OUT_WORD( port, *p ); \ - } \ - } while ( 0 ) - -#elif defined FADS860BSP /* elif defined AS2000BSP */ - -#define HCF_BIG_ENDIAN 1 - -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#ifndef __GNUC__ - #define __asm__ asm -#endif - -#if ! defined _lint - #define EIEIO() __asm__(" eieio") -#else - #define EIEIO() -#endif - -static hcf_16 IN_PORT_WORD(int port) { - hcf_16 value = *(volatile hcf_16 *)(port); EIEIO(); - value = ((value & 0xff00) >> 8) + ((value & 0x00ff) << 8); -/* value = CNV_LITTLE_TO_SHORT(value); */ - return value; - #ifdef __GNUC__ - /* the following serves to avoid the compiler warnings that - * IN_PORT_WORD() is not used in some files */ - (void)IN_PORT_WORD; - #endif -} - -#define OUT_PORT_WORD(port, value) \ - { *(volatile hcf_16 *)(port) = CNV_SHORT_TO_LITTLE(value); EIEIO(); } - -/***********************************************************************/ - -#define IN_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - volatile hcf_16 *d = (volatile hcf_16 *)(addr); \ - while (l--) { \ - *d++ = *(volatile hcf_16 *)(port); \ - EIEIO(); \ - } \ - } - -#define OUT_PORT_STRING_16( port, addr, len) { \ - unsigned l = (len); \ - volatile hcf_16 *s = (volatile hcf_16 *)(addr); \ - while (l--) { \ - *(volatile hcf_16 *)(port) = *s++; \ - EIEIO(); \ - } \ - } - -#elif defined DAYTONABSP - -#define HCF_BIG_ENDIAN 1 - -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#ifndef __GNUC__ - #define __asm__ asm -#endif - -#define IN_PORT_WORD(port) (sysOrinocoInWord((unsigned long)(port))) -#define OUT_PORT_WORD(port,value) (sysOrinocoOutWord((unsigned long)(port), (unsigned short)(value))) - -#define IN_PORT_STRING_16(port,addr,len) (sysOrinocoInString((port), (addr), (len))) -#define OUT_PORT_STRING_16(port,addr,len) (sysOrinocoOutString((port), (addr), (len))) - -extern unsigned char sysOrinocoInByte (unsigned long port); -extern unsigned short sysOrinocoInWord (unsigned long port); -extern void sysOrinocoInString (unsigned long port, void *addr, unsigned short len); - -extern void sysOrinocoOutByte (unsigned long port, unsigned char value); -extern void sysOrinocoOutWord (unsigned long port, unsigned short value); -extern void sysOrinocoOutString (unsigned long port, void *addr, unsigned short len); - -#elif defined ALPHA_BSP - -#define HCF_BIG_ENDIAN 1 - -#define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O - -#ifndef __GNUC__ - #define __asm__ asm -#endif - -#define IN_PORT_WORD(port) (sysOrinocoInWord((unsigned long)(port))) -#define OUT_PORT_WORD(port,value) (sysOrinocoOutWord((unsigned long)(port), (unsigned short)(value))) - -#define IN_PORT_STRING_16(port,addr,len) (sysOrinocoInString((port), (addr), (len))) -#define OUT_PORT_STRING_16(port,addr,len) (sysOrinocoOutString((port), (addr), (len))) - -extern unsigned char sysOrinocoInByte (unsigned long port); -extern unsigned short sysOrinocoInWord (unsigned long port); -extern void sysOrinocoInString (unsigned long port, void *addr, unsigned short len); - -extern void sysOrinocoOutByte (unsigned long port, unsigned char value); -extern void sysOrinocoOutWord (unsigned long port, unsigned short value); -extern void sysOrinocoOutString (unsigned long port, void *addr, unsigned short len); - -#else - -err: /* commented here */ /* "BSP is not defined..." */ - -#endif /* else PC486BSP */ - -#endif // __VX_WORKS__ - - - -/************************************************************************************************/ -/****************************** VXWORKS. Motorola Sandpoint PowerPC 824X ***********************/ -/************************************************************************************************/ -#ifdef __VX_WORKS_SANDPOINT_824X__ - -#include -#include -#include - -#ifdef WVLAN_53 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDSTA -#endif /* WVLAN_53 */ - -#ifdef WVLAN_54 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDAP -#endif /* WVLAN_54 */ - -#ifdef WVLAN_56 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_END -#endif /* WVLAN_56 */ - -#if !defined MSF_COMPONENT_ID -#error "you must define an MSF component ID: WVLAN_53, WVLAN_54, WVLAN_56" -#endif - -#define MSF_COMPONENT_VAR 1 - -#define HCF_EXT HCF_EXT_INFO_LOG -#define HCF_SLEEP ( HCF_CDS | HCF_DDS ) -//#define HCF_SLEEP ( HCF_DDS ) - -#ifndef HCF_ACT_WAKEUP -#define HCF_ACT_WAKEUP 0x1D -#endif // HCF_ACT_WAKEUP - -#if defined FATNIC | defined BEAGLE_H253 -#define T1__HCF_TYPE HCF_TYPE_STA -#else -#define T1__HCF_TYPE HCF_TYPE_AP | HCF_TYPE_STA -#endif - -#ifdef HERMES_USB -#define T2__HCF_TYPE (T1__HCF_TYPE | HCF_TYPE_USB) -#else // HERMES_USB -#define T2__HCF_TYPE (T1__HCF_TYPE) -#endif // HERMES_USB - -#ifdef _WARP -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5) -#else // _WARP -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_WPA | HCF_TYPE_HII) -#endif // WARP - -#ifdef _CCX -#define T4__HCF_TYPE (T3__HCF_TYPE | HCF_TYPE_CCX) -#else // _WARP -#define T4__HCF_TYPE (T3__HCF_TYPE) -#endif // _CCX - -#define T5__HCF_TYPE (T4__HCF_TYPE) - -// Default to TYPE_AP + SSN! -#define HCF_TYPE (T5__HCF_TYPE ) - - - -#define MSF_COMPONENT_MAJOR_VER 2 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_IO HCF_IO_MEM -#define HCF_DMA 0 -#define HCF_MEM_IO 1 -#define HCF_BIG_ENDIAN 1 - -//#define support_32bits 1 - -#define IN_PORT_WORD(port) (sysInWord( (hcf_io)(port) )) -#define OUT_PORT_WORD(port, value) (sysOutWord( (hcf_io)(port), (hcf_16)(value) )) -#define IN_PORT_DWORD(port) (sysInLong( (hcf_io)(port) )) -#define OUT_PORT_DWORD(port, value) (sysOutLong( (hcf_io)(port), (hcf_16)(value) )) -#define IN_PORT_STRING_16(port, dst, n) (sysInWordString((hcf_io)(port), (hcf_16 *)dst, n)) -#define OUT_PORT_STRING_16(port, src, n) (sysOutWordString((hcf_io)(port), (hcf_16 *)src, n)) - -#ifdef WVLAN_DEBUG -#define DBG 1 -#define _DEBUG 1 -#endif - -/* we'll need to add these prints someday */ -#define OUTPUTDEBUGMSG(dprintf_exp) -#define ASSERTDEBUGMSG(cond, dprintf_exp) - -#define HCF_INTERFACE_CONNECT(ifbp) -#define HCF_INTERFACE_DISCONNECT(ifbp) -#define HCF_ENTER_INTERFACE_FUNCT(ibfb) -#define HCF_LEAVE_INTERFACE_FUNCT(ifbp) - -#define CNV_END_INT(w) ( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 ) -#define CNV_LITTLE_TO_INT(w) CNV_END_INT(w) -#define CNV_INT_TO_LITTLE(w) CNV_LITTLE_TO_INT(w) - -#endif /* __VX_WORKS_SANDPOINT_824X__ */ - -/************************************************************************************************/ -/************************************* VXWORKS. ARM T8300 IPPhone *****************************/ -/************************************************************************************************/ -#if defined( IPT_T8300 ) || defined( IPT_T8307 ) - -#include -#include -#include - -#define HCF_ALIGN 4 /* default to 4 byte alignment */ - -#define BEAGLE_H253 /* Hermes 2.5.3 build, better to be in the project file */ -#define OOR_DDS /* Hermes 2.5.3 build, better to be in the project file */ -#define FATNIC - - -#ifdef WVLAN_53 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDSTA -#endif /* WVLAN_53 */ - -#ifdef WVLAN_54 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_ENDAP -#endif /* WVLAN_54 */ - -#ifdef WVLAN_56 -#define MSF_COMPONENT_ID COMP_ID_VX_WORKS_END -#endif /* WVLAN_56 */ - -#if !defined MSF_COMPONENT_ID -#error "you must define an MSF component ID: WVLAN_53, WVLAN_54, WVLAN_56" -#endif - -#define MSF_COMPONENT_VAR 1 - -#define HCF_EXT HCF_EXT_INFO_LOG -//#define HCF_EXT HCF_EXT_INFO_LOG | HCF_EXT_MB -#define HCF_SLEEP ( HCF_CDS | HCF_DDS ) -//#define HCF_SLEEP ( HCF_DDS ) - -#ifndef HCF_ACT_WAKEUP -#define HCF_ACT_WAKEUP 0x1D -#endif // HCF_ACT_WAKEUP - -#if defined FATNIC || defined BEAGLE_H253 -#define T1__HCF_TYPE HCF_TYPE_STA -#else -//#define T1__HCF_TYPE HCF_TYPE_AP | HCF_TYPE_STA -#define T1__HCF_TYPE HCF_TYPE_STA /* dz, Station code only */ -#endif - -#ifdef HERMES_USB -#define T2__HCF_TYPE (T1__HCF_TYPE | HCF_TYPE_USB) -#else // HERMES_USB -#define T2__HCF_TYPE (T1__HCF_TYPE) -#endif // HERMES_USB - -#ifdef _WARP -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5) -#else // _WARP -#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_WPA | HCF_TYPE_HII) -//#define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII) /* dz. no WPA support at this time, test code */ -#endif // WARP - -#ifdef _CCX -#define T4__HCF_TYPE (T3__HCF_TYPE | HCF_TYPE_CCX) -#else // _WARP -#define T4__HCF_TYPE (T3__HCF_TYPE) -#endif // _CCX - -#define T5__HCF_TYPE (T4__HCF_TYPE) - -// Default to TYPE_AP + SSN! -#define HCF_TYPE (T5__HCF_TYPE ) - - -#define MSF_COMPONENT_MAJOR_VER 2 -#define MSF_COMPONENT_MINOR_VER 0 - -#define HCF_IO HCF_IO_MEM -#define HCF_DMA 0 -#define HCF_MEM_IO 1 - - -/* Endian is determined by vxWorks project compile option */ -#if (_BYTE_ORDER == _BIG_ENDIAN) -#undef HCF_LITTLE_ENDIAN -#define HCF_BIG_ENDIAN 1 -#endif - - -#define CNV_END(w) ( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 ) -#if defined HCF_BIG_ENDIAN -//******************************************** B I G E N D I A N ******************************************* -#define CNV_LITTLE_TO_INT(w) CNV_END(w) // endianess conversion needed -#define CNV_BIG_TO_INT(w) (w) // no endianess conversion needed -#else -//****************************************** L I T T L E E N D I A N **************************************** -#define CNV_LITTLE_TO_INT(w) (w) // no endianess conversion needed -#define CNV_BIG_TO_INT(w) CNV_END(w) // endianess conversion needed -#endif // HCF_BIG_ENDIAN - -// conversion macros which can be expressed in other macros -#define CNV_INT_TO_LITTLE(w) CNV_LITTLE_TO_INT(w) -#define CNV_INT_TO_BIG(w) CNV_BIG_TO_INT(w) - - - -#define IN_PORT_WORD( port ) *((volatile hcf_16 *)( port )) -#define OUT_PORT_WORD( port, value ) *((volatile hcf_16 *)( port )) = ((hcf_16)( value )) -//#define IN_PORT_BYTE( port ) *((volatile hcf_8 *)( port )) - -#define IN_PORT_STRING( port, addr, len) { \ - unsigned l = len; \ - hcf_16 *d = (hcf_16 *)(addr); \ - hcf_16 t; \ - while (l--) { \ - t = IN_PORT_WORD(port); \ - *d++ = CNV_LITTLE_TO_INT(t); \ - } \ -} // IN_PORT_STRING - -#define OUT_PORT_STRING( port, addr, len) { \ - unsigned l = (len); \ - hcf_16 *s = (hcf_16 *)(addr); \ - hcf_16 t; \ - while (l--) { \ - t = *s++; \ - t = CNV_LITTLE_TO_INT(t); \ - OUT_PORT_WORD(port, t); \ - } \ -} // OUT_PORT_STRING - -#define IN_PORT_STRING_16(port, dst, n) { \ - unsigned l = (n); \ - hcf_16 *d = (hcf_16 *)(dst); \ - while (l--) { \ - *d++ = IN_PORT_WORD(port); \ - } \ -} // IN_PORT_STRING_16 - -#define OUT_PORT_STRING_16(port, src, n) { \ - hcf_16 t; \ - int l = (n); \ - hcf_16 *s = (hcf_16 *)(src); \ - while (l--) { \ - t = *s++; \ - OUT_PORT_WORD(port, t); \ - } \ -} // OUT_PORT_STRING_16 - -/* #define HCF_YIELD (taskDelay(0) == 0) */ - - - -#ifdef WVLAN_DEBUG -#define DBG 1 -#define _DEBUG 1 -#endif - -/* we'll need to add these prints someday */ -#define OUTPUTDEBUGMSG(dprintf_exp) -#define ASSERTDEBUGMSG(cond, dprintf_exp) - -#define HCF_INTERFACE_CONNECT(ifbp) -#define HCF_INTERFACE_DISCONNECT(ifbp) -#define HCF_ENTER_INTERFACE_FUNCT(ibfb) -#define HCF_LEAVE_INTERFACE_FUNCT(ifbp) - -#define sysInWord(offsetAddr) IN_PORT_WORD(offsetAddr) -#define sysInByte(offsetAddr) IN_PORT_BYTE(offsetAddr) -#define sysOutWord(addr, value) OUT_PORT_WORD(addr, value) - -#endif /*IPT_T8300 */ - /************************************************************************************************************/ /*********************************** **************************************/ /************************************************************************************************************/ From fe4d275594446d19254ebfefc2169b572a895a87 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:46 +0100 Subject: [PATCH 1022/1519] staging: wlags49_h2: Reindent hcfdef.h Untabified with tab-width set to 4. Reindented with linux style. Also remove BITN macros. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcfdef.h | 807 +++++++++++++--------------- 1 file changed, 385 insertions(+), 422 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcfdef.h b/drivers/staging/wlags49_h2/hcfdef.h index cb1966d8473..0261c7358c1 100644 --- a/drivers/staging/wlags49_h2/hcfdef.h +++ b/drivers/staging/wlags49_h2/hcfdef.h @@ -1,286 +1,249 @@ - -// vim:tw=110:ts=4: #ifndef HCFDEFC_H #define HCFDEFC_H 1 /************************************************************************************************* -* -* FILE : HCFDEF.H -* -* DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.8 $ -* Original: 2004/05/28 14:05:35 Revision: 1.59 Tag: hcf7_t20040602_01 -* Original: 2004/05/13 15:31:45 Revision: 1.53 Tag: hcf7_t7_20040513_01 -* Original: 2004/04/15 09:24:42 Revision: 1.44 Tag: hcf7_t7_20040415_01 -* Original: 2004/04/13 14:22:45 Revision: 1.43 Tag: t7_20040413_01 -* Original: 2004/04/01 15:32:55 Revision: 1.40 Tag: t7_20040401_01 -* Original: 2004/03/10 15:39:28 Revision: 1.36 Tag: t20040310_01 -* Original: 2004/03/03 14:10:12 Revision: 1.34 Tag: t20040304_01 -* Original: 2004/03/02 09:27:12 Revision: 1.32 Tag: t20040302_03 -* Original: 2004/02/24 13:00:29 Revision: 1.29 Tag: t20040224_01 -* Original: 2004/02/18 17:13:57 Revision: 1.26 Tag: t20040219_01 -* -* AUTHOR : Nico Valster -* -* SPECIFICATION: ........... -* -* DESC : Definitions and Prototypes for HCF only -* -************************************************************************************************** -* -* -* SOFTWARE LICENSE -* -* This software is provided subject to the following terms and conditions, -* which you should read carefully before using the software. Using this -* software indicates your acceptance of these terms and conditions. If you do -* not agree with these terms and conditions, do not use the software. -* -* COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved -* COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved -* COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved -* All rights reserved. -* -* Redistribution and use in source or binary forms, with or without -* modifications, are permitted provided that the following conditions are met: -* -* . Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following Disclaimer as comments in the code as -* well as in the documentation and/or other materials provided with the -* distribution. -* -* . Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following Disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* . Neither the name of Agere Systems Inc. nor the names of the contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* Disclaimer -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY -* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN -* RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -* -* -*************************************************************************************************/ + * + * FILE : HCFDEF.H + * + * DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.8 $ + * Original: 2004/05/28 14:05:35 Revision: 1.59 Tag: hcf7_t20040602_01 + * Original: 2004/05/13 15:31:45 Revision: 1.53 Tag: hcf7_t7_20040513_01 + * Original: 2004/04/15 09:24:42 Revision: 1.44 Tag: hcf7_t7_20040415_01 + * Original: 2004/04/13 14:22:45 Revision: 1.43 Tag: t7_20040413_01 + * Original: 2004/04/01 15:32:55 Revision: 1.40 Tag: t7_20040401_01 + * Original: 2004/03/10 15:39:28 Revision: 1.36 Tag: t20040310_01 + * Original: 2004/03/03 14:10:12 Revision: 1.34 Tag: t20040304_01 + * Original: 2004/03/02 09:27:12 Revision: 1.32 Tag: t20040302_03 + * Original: 2004/02/24 13:00:29 Revision: 1.29 Tag: t20040224_01 + * Original: 2004/02/18 17:13:57 Revision: 1.26 Tag: t20040219_01 + * + * AUTHOR : Nico Valster + * + * SPECIFICATION: ........... + * + * DESC : Definitions and Prototypes for HCF only + * + ************************************************************************************************** + * + * + * SOFTWARE LICENSE + * + * This software is provided subject to the following terms and conditions, + * which you should read carefully before using the software. Using this + * software indicates your acceptance of these terms and conditions. If you do + * not agree with these terms and conditions, do not use the software. + * + * COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved + * COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved + * COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved + * All rights reserved. + * + * Redistribution and use in source or binary forms, with or without + * modifications, are permitted provided that the following conditions are met: + * + * . Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following Disclaimer as comments in the code as + * well as in the documentation and/or other materials provided with the + * distribution. + * + * . Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following Disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * . Neither the name of Agere Systems Inc. nor the names of the contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Disclaimer + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY + * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN + * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + *************************************************************************************************/ /************************************************************************************************/ /********************************* P R E F I X E S ********************************************/ /************************************************************************************************/ -//IFB_ Interface Block -//HCMD_ Hermes Command -//HFS_ Hermes (Transmit/Receive) Frame Structure -//HREG_ Hermes Register +//IFB_ Interface Block +//HCMD_ Hermes Command +//HFS_ Hermes (Transmit/Receive) Frame Structure +//HREG_ Hermes Register /*************************************************************************************************/ -#if 0 // -#define BIT0 0x0001 -#define BIT1 0x0002 -#define BIT2 0x0004 -#define BIT3 0x0008 -#define BIT4 0x0010 -#define BIT5 0x0020 -#define BIT6 0x0040 -#define BIT7 0x0080 -#define BIT8 0x0100 -#define BIT9 0x0200 -#define BIT10 0x0400 -#define BIT11 0x0800 -#define BIT12 0x1000 -#define BIT13 0x2000 -#define BIT14 0x4000 -#define BIT15 0x8000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 -#endif // 0 - /************************************************************************************************/ /********************************* GENERAL EQUATES **********************************************/ /************************************************************************************************/ -#define HCF_MAGIC 0x7D37 // "}7" Handle validation +#define HCF_MAGIC 0x7D37 // "}7" Handle validation -#define PLUG_DATA_OFFSET 0x00000800 //needed by some test tool on top of H-II NDIS driver +#define PLUG_DATA_OFFSET 0x00000800 //needed by some test tool on top of H-II NDIS driver -#define INI_TICK_INI 0x00040000L +#define INI_TICK_INI 0x00040000L -#define IO_IN 0 //hcfio_in_string -#define IO_OUT 1 //hcfio_out_string +#define IO_IN 0 //hcfio_in_string +#define IO_OUT 1 //hcfio_out_string //DO_ASSERT, create an artificial FALSE to force an ASSERT without the nasty compiler warning -#define DO_ASSERT ( assert_ifbp->IFB_Magic != HCF_MAGIC && assert_ifbp->IFB_Magic == HCF_MAGIC ) -#define NT_ASSERT 0x0000 //, NEVER_TESTED -#define NEVER_TESTED MERGE_2( 0xEFFE, 0xFEEF ) -#define SE_ASSERT 0x5EFF /* Side Effect, HCFASSERT invokation which are only called for the - * side effect and which should never trigger */ -#define DHF_FILE_NAME_OFFSET 10000 //to distinguish DHF from HCF asserts by means of line number -#define MMD_FILE_NAME_OFFSET 20000 //to distinguish MMD from HCF asserts by means of line number +#define DO_ASSERT ( assert_ifbp->IFB_Magic != HCF_MAGIC && assert_ifbp->IFB_Magic == HCF_MAGIC ) +#define NT_ASSERT 0x0000 //, NEVER_TESTED +#define NEVER_TESTED MERGE_2( 0xEFFE, 0xFEEF ) +#define SE_ASSERT 0x5EFF /* Side Effect, HCFASSERT invokation which are only called for the + * side effect and which should never trigger */ +#define DHF_FILE_NAME_OFFSET 10000 //to distinguish DHF from HCF asserts by means of line number +#define MMD_FILE_NAME_OFFSET 20000 //to distinguish MMD from HCF asserts by means of line number // trace codes used to // 1: profile execution times via HCF_TRACE and HCF_TRACE_VALUE // 2: hierarchical flow information via HCFLOGENTRY / HCFLOGEXIT -//#define HCF_TRACE_CONNECT useless -//#define HCF_TRACE_DISCONNECT useless -#define HCF_TRACE_ACTION 0x0000 // 0x0001 -#define HCF_TRACE_CNTL 0x0001 // 0x0002 -#define HCF_TRACE_DMA_RX_GET 0x0002 // 0x0004 -#define HCF_TRACE_DMA_RX_PUT 0x0003 // 0x0008 -#define HCF_TRACE_DMA_TX_GET 0x0004 // 0x0010 -#define HCF_TRACE_DMA_TX_PUT 0x0005 // 0x0020 -#define HCF_TRACE_GET_INFO 0x0006 // 0x0040 -#define HCF_TRACE_PUT_INFO 0x0007 // 0x0080 -#define HCF_TRACE_RCV_MSG 0x0008 // 0x0100 -#define HCF_TRACE_SEND_MSG 0x0009 // 0x0200 -#define HCF_TRACE_SERVICE_NIC 0x000A // 0x0400 +//#define HCF_TRACE_CONNECT useless +//#define HCF_TRACE_DISCONNECT useless +#define HCF_TRACE_ACTION 0x0000 // 0x0001 +#define HCF_TRACE_CNTL 0x0001 // 0x0002 +#define HCF_TRACE_DMA_RX_GET 0x0002 // 0x0004 +#define HCF_TRACE_DMA_RX_PUT 0x0003 // 0x0008 +#define HCF_TRACE_DMA_TX_GET 0x0004 // 0x0010 +#define HCF_TRACE_DMA_TX_PUT 0x0005 // 0x0020 +#define HCF_TRACE_GET_INFO 0x0006 // 0x0040 +#define HCF_TRACE_PUT_INFO 0x0007 // 0x0080 +#define HCF_TRACE_RCV_MSG 0x0008 // 0x0100 +#define HCF_TRACE_SEND_MSG 0x0009 // 0x0200 +#define HCF_TRACE_SERVICE_NIC 0x000A // 0x0400 // #define HCF_TRACE_ 0x000C // 0x1000 // #define HCF_TRACE_ 0x000D // 0x2000 // #define HCF_TRACE_ 0x000E // 0x4000 // #define HCF_TRACE_ 0x000F // 0x8000 -// ============================================ HCF_TRACE_... codes below 0x0010 are asserted on re-entry -#define HCF_TRACE_ACTION_KLUDGE 0x0010 /* once you start introducing kludges there is no end to it - * this is an escape to do not assert on re-entrancy problem caused - * by HCF_ACT_INT_FORCE_ON used to get Microsofts NDIS drivers going - */ -#define HCF_TRACE_STRIO 0x0020 -#define HCF_TRACE_ALLOC 0X0021 -#define HCF_TRACE_DL 0X0023 -#define HCF_TRACE_ISR_INFO 0X0024 -#define HCF_TRACE_CALIBRATE 0x0026 +// ============================================ HCF_TRACE_... codes below 0x0010 are asserted on re-entry +#define HCF_TRACE_ACTION_KLUDGE 0x0010 /* once you start introducing kludges there is no end to it + * this is an escape to do not assert on re-entrancy problem caused + * by HCF_ACT_INT_FORCE_ON used to get Microsofts NDIS drivers going + */ +#define HCF_TRACE_STRIO 0x0020 +#define HCF_TRACE_ALLOC 0X0021 +#define HCF_TRACE_DL 0X0023 +#define HCF_TRACE_ISR_INFO 0X0024 +#define HCF_TRACE_CALIBRATE 0x0026 -#define HCF_TRACE_CMD_CPL 0x0040 -#define HCF_TRACE_CMD_EXE 0x0041 -#define HCF_TRACE_GET_FID 0x0042 -#define HCF_TRACE_GET_FRAG 0x0043 -#define HCF_TRACE_INIT 0x0044 -#define HCF_TRACE_PUT_FRAG 0x0045 -#define HCF_TRACE_SETUP_BAP 0x0046 +#define HCF_TRACE_CMD_CPL 0x0040 +#define HCF_TRACE_CMD_EXE 0x0041 +#define HCF_TRACE_GET_FID 0x0042 +#define HCF_TRACE_GET_FRAG 0x0043 +#define HCF_TRACE_INIT 0x0044 +#define HCF_TRACE_PUT_FRAG 0x0045 +#define HCF_TRACE_SETUP_BAP 0x0046 -#define HCF_TRACE_EXIT 0x8000 // Keil C warns "long constant truncated to int" +#define HCF_TRACE_EXIT 0x8000 // Keil C warns "long constant truncated to int" -//#define BAP_0 HREG_DATA_0 //Used by DMA controller to access NIC RAM -#define BAP_1 HREG_DATA_1 //Used by HCF to access NIC RAM +//#define BAP_0 HREG_DATA_0 //Used by DMA controller to access NIC RAM +#define BAP_1 HREG_DATA_1 //Used by HCF to access NIC RAM //************************* Hermes Receive/Transmit Frame Structures //HFS_STAT //see MMD.H for HFS_STAT_ERR -#define HFS_STAT_MSG_TYPE 0xE000 //Hermes reported Message Type -#define HFS_STAT_MIC_KEY_ID 0x1800 //MIC key used (if any) -#define HFS_STAT_1042 0x2000 //RFC1042 Encoded -#define HFS_STAT_TUNNEL 0x4000 //Bridge-Tunnel Encoded -#define HFS_STAT_WMP_MSG 0x6000 //WaveLAN-II Management Protocol Frame +#define HFS_STAT_MSG_TYPE 0xE000 //Hermes reported Message Type +#define HFS_STAT_MIC_KEY_ID 0x1800 //MIC key used (if any) +#define HFS_STAT_1042 0x2000 //RFC1042 Encoded +#define HFS_STAT_TUNNEL 0x4000 //Bridge-Tunnel Encoded +#define HFS_STAT_WMP_MSG 0x6000 //WaveLAN-II Management Protocol Frame #if (HCF_TYPE) & HCF_TYPE_WPA -#define HFS_STAT_MIC 0x0010 //Frame contains MIC //;? re-instate when F/W ready +#define HFS_STAT_MIC 0x0010 //Frame contains MIC //;? re-instate when F/W ready #endif //************************* Hermes Register Offsets and Command bits -#define HREG_IO_RANGE 0x80 //I/O Range used by Hermes +#define HREG_IO_RANGE 0x80 //I/O Range used by Hermes //************************* Command/Status -#define HREG_CMD 0x00 // -#define HCMD_CMD_CODE 0x3F -#define HREG_PARAM_0 0x02 // -#define HREG_PARAM_1 0x04 // -#define HREG_PARAM_2 0x06 // -#define HREG_STAT 0x08 // -#define HREG_STAT_CMD_CODE 0x003F // -#define HREG_STAT_DIAG_ERR 0x0100 -#define HREG_STAT_INQUIRE_ERR 0x0500 -#define HREG_STAT_CMD_RESULT 0x7F00 // -#define HREG_RESP_0 0x0A // -#define HREG_RESP_1 0x0C // -#define HREG_RESP_2 0x0E // +#define HREG_CMD 0x00 // +#define HCMD_CMD_CODE 0x3F +#define HREG_PARAM_0 0x02 // +#define HREG_PARAM_1 0x04 // +#define HREG_PARAM_2 0x06 // +#define HREG_STAT 0x08 // +#define HREG_STAT_CMD_CODE 0x003F // +#define HREG_STAT_DIAG_ERR 0x0100 +#define HREG_STAT_INQUIRE_ERR 0x0500 +#define HREG_STAT_CMD_RESULT 0x7F00 // +#define HREG_RESP_0 0x0A // +#define HREG_RESP_1 0x0C // +#define HREG_RESP_2 0x0E // //************************* FID Management -#define HREG_INFO_FID 0x10 // -#define HREG_RX_FID 0x20 // -#define HREG_ALLOC_FID 0x22 // -#define HREG_TX_COMPL_FID 0x24 // +#define HREG_INFO_FID 0x10 // +#define HREG_RX_FID 0x20 // +#define HREG_ALLOC_FID 0x22 // +#define HREG_TX_COMPL_FID 0x24 // //************************* BAP //20031030 HWi Inserted this again because the dongle code uses this (GPIF.C) -//#define HREG_SELECT_0 0x18 // -//#define HREG_OFFSET_0 0x1C // -//#define HREG_DATA_0 0x36 // +//#define HREG_SELECT_0 0x18 // +//#define HREG_OFFSET_0 0x1C // +//#define HREG_DATA_0 0x36 // -//#define HREG_OFFSET_BUSY 0x8000 // use HCMD_BUSY -#define HREG_OFFSET_ERR 0x4000 // -//rsrvd #define HREG_OFFSET_DATA_OFFSET 0x0FFF // +//#define HREG_OFFSET_BUSY 0x8000 // use HCMD_BUSY +#define HREG_OFFSET_ERR 0x4000 // +//rsrvd #define HREG_OFFSET_DATA_OFFSET 0x0FFF // -#define HREG_SELECT_1 0x1A // -#define HREG_OFFSET_1 0x1E // -#define HREG_DATA_1 0x38 // +#define HREG_SELECT_1 0x1A // +#define HREG_OFFSET_1 0x1E // +#define HREG_DATA_1 0x38 // //************************* Event -#define HREG_EV_STAT 0x30 // -#define HREG_INT_EN 0x32 // -#define HREG_EV_ACK 0x34 // +#define HREG_EV_STAT 0x30 // +#define HREG_INT_EN 0x32 // +#define HREG_EV_ACK 0x34 // -#define HREG_EV_TICK 0x8000 //Auxiliary Timer Tick -//#define HREG_EV_RES 0x4000 //H-I only: H/W error (Wait Time-out) -#define HREG_EV_INFO_DROP 0x2000 //WMAC did not have sufficient RAM to build Unsollicited Frame +#define HREG_EV_TICK 0x8000 //Auxiliary Timer Tick +//#define HREG_EV_RES 0x4000 //H-I only: H/W error (Wait Time-out) +#define HREG_EV_INFO_DROP 0x2000 //WMAC did not have sufficient RAM to build Unsollicited Frame #if (HCF_TYPE) & HCF_TYPE_HII5 -#define HREG_EV_ACK_REG_READY 0x0000 +#define HREG_EV_ACK_REG_READY 0x0000 #else -#define HREG_EV_ACK_REG_READY 0x1000 //Workaround Kludge bit for H-II (not H-II.5) +#define HREG_EV_ACK_REG_READY 0x1000 //Workaround Kludge bit for H-II (not H-II.5) #endif // HCF_TYPE_HII5 #if (HCF_SLEEP) & ( HCF_CDS | HCF_DDS ) -#define HREG_EV_SLEEP_REQ 0x0800 +#define HREG_EV_SLEEP_REQ 0x0800 #else -#define HREG_EV_SLEEP_REQ 0x0000 +#define HREG_EV_SLEEP_REQ 0x0000 #endif // HCF_CDS / HCF_DDS #if HCF_DMA -//#define HREG_EV_LPESC 0x0400 // firmware sets this bit and clears it, not for host usage. -#define HREG_EV_RDMAD 0x0200 // rx frame in host memory -#define HREG_EV_TDMAD 0x0100 // tx frame in host memory processed -//#define HREG_EV_RXDMA 0x0040 // firmware kicks off DMA engine (bit is not for host usage) -//#define HREG_EV_TXDMA 0x0020 // firmware kicks off DMA engine (bit is not for host usage) -#define HREG_EV_FW_DMA 0x0460 // firmware / DMA engine I/F (bits are not for host usage) +//#define HREG_EV_LPESC 0x0400 // firmware sets this bit and clears it, not for host usage. +#define HREG_EV_RDMAD 0x0200 // rx frame in host memory +#define HREG_EV_TDMAD 0x0100 // tx frame in host memory processed +//#define HREG_EV_RXDMA 0x0040 // firmware kicks off DMA engine (bit is not for host usage) +//#define HREG_EV_TXDMA 0x0020 // firmware kicks off DMA engine (bit is not for host usage) +#define HREG_EV_FW_DMA 0x0460 // firmware / DMA engine I/F (bits are not for host usage) #else -#define HREG_EV_FW_DMA 0x0000 +#define HREG_EV_FW_DMA 0x0000 #endif // HCF_DMA -#define HREG_EV_INFO 0x0080 // Asynchronous Information Frame -#define HREG_EV_CMD 0x0010 // Command completed, Status and Response available -#define HREG_EV_ALLOC 0x0008 // Asynchronous part of Allocation/Reclaim completed -#define HREG_EV_TX_EXC 0x0004 // Asynchronous Transmission unsuccessful completed -#define HREG_EV_TX 0x0002 // Asynchronous Transmission successful completed -#define HREG_EV_RX 0x0001 // Asynchronous Receive Frame +#define HREG_EV_INFO 0x0080 // Asynchronous Information Frame +#define HREG_EV_CMD 0x0010 // Command completed, Status and Response available +#define HREG_EV_ALLOC 0x0008 // Asynchronous part of Allocation/Reclaim completed +#define HREG_EV_TX_EXC 0x0004 // Asynchronous Transmission unsuccessful completed +#define HREG_EV_TX 0x0002 // Asynchronous Transmission successful completed +#define HREG_EV_RX 0x0001 // Asynchronous Receive Frame -#define HREG_EV_TX_EXT ( (HCF_EXT) & (HCF_EXT_INT_TX_EX | HCF_EXT_INT_TICK ) ) - /* HREG_EV_TX_EXT := 0x0000 or HREG_EV_TX_EXC and/or HREG_EV_TICK - * could be extended with HREG_EV_TX */ +#define HREG_EV_TX_EXT ( (HCF_EXT) & (HCF_EXT_INT_TX_EX | HCF_EXT_INT_TICK ) ) +/* HREG_EV_TX_EXT := 0x0000 or HREG_EV_TX_EXC and/or HREG_EV_TICK + * could be extended with HREG_EV_TX */ #if HCF_EXT_INT_TX_EX != HREG_EV_TX_EXC err: these values should match; #endif // HCF_EXT_INT_TX_EX / HREG_EV_TX_EXC @@ -290,97 +253,97 @@ err: these values should match; #endif // HCF_EXT_INT_TICK / HREG_EV_TICK //************************* Host Software -#define HREG_SW_0 0x28 // -#define HREG_SW_1 0x2A // -#define HREG_SW_2 0x2C // -//rsrvd #define HREG_SW_3 0x2E // +#define HREG_SW_0 0x28 // +#define HREG_SW_1 0x2A // +#define HREG_SW_2 0x2C // +//rsrvd #define HREG_SW_3 0x2E // //************************* Control and Auxiliary Port -#define HREG_IO 0x12 -#define HREG_IO_SRESET 0x0001 -#define HREG_IO_WAKEUP_ASYNC 0x0002 -#define HREG_IO_WOKEN_UP 0x0004 -#define HREG_CNTL 0x14 // -//#define HREG_CNTL_WAKEUP_SYNC 0x0001 -#define HREG_CNTL_AUX_ENA_STAT 0xC000 -#define HREG_CNTL_AUX_DIS_STAT 0x0000 -#define HREG_CNTL_AUX_ENA_CNTL 0x8000 -#define HREG_CNTL_AUX_DIS_CNTL 0x4000 -#define HREG_CNTL_AUX_DSD 0x2000 -#define HREG_CNTL_AUX_ENA (HREG_CNTL_AUX_ENA_CNTL | HREG_CNTL_AUX_DIS_CNTL ) -#define HREG_SPARE 0x16 // -#define HREG_AUX_PAGE 0x3A // -#define HREG_AUX_OFFSET 0x3C // -#define HREG_AUX_DATA 0x3E // +#define HREG_IO 0x12 +#define HREG_IO_SRESET 0x0001 +#define HREG_IO_WAKEUP_ASYNC 0x0002 +#define HREG_IO_WOKEN_UP 0x0004 +#define HREG_CNTL 0x14 // +//#define HREG_CNTL_WAKEUP_SYNC 0x0001 +#define HREG_CNTL_AUX_ENA_STAT 0xC000 +#define HREG_CNTL_AUX_DIS_STAT 0x0000 +#define HREG_CNTL_AUX_ENA_CNTL 0x8000 +#define HREG_CNTL_AUX_DIS_CNTL 0x4000 +#define HREG_CNTL_AUX_DSD 0x2000 +#define HREG_CNTL_AUX_ENA (HREG_CNTL_AUX_ENA_CNTL | HREG_CNTL_AUX_DIS_CNTL ) +#define HREG_SPARE 0x16 // +#define HREG_AUX_PAGE 0x3A // +#define HREG_AUX_OFFSET 0x3C // +#define HREG_AUX_DATA 0x3E // #if HCF_DMA //************************* DMA (bus mastering) - // Be careful to use these registers only at a genuine 32 bits NIC - // On 16 bits NICs, these addresses are mapped into the range 0x00 through 0x3F with all consequences - // thereof, e.g. HREG_DMA_CTRL register maps to HREG_CMD. -#define HREG_DMA_CTRL 0x0040 -#define HREG_TXDMA_PTR32 0x0044 -#define HREG_TXDMA_PRIO_PTR32 0x0048 -#define HREG_TXDMA_HIPRIO_PTR32 0x004C -#define HREG_RXDMA_PTR32 0x0050 -#define HREG_CARDDETECT_1 0x007C // contains 7D37 -#define HREG_CARDDETECT_2 0x007E // contains 7DE7 -#define HREG_FREETIMER 0x0058 -#define HREG_DMA_RX_CNT 0x0026 +// Be careful to use these registers only at a genuine 32 bits NIC +// On 16 bits NICs, these addresses are mapped into the range 0x00 through 0x3F with all consequences +// thereof, e.g. HREG_DMA_CTRL register maps to HREG_CMD. +#define HREG_DMA_CTRL 0x0040 +#define HREG_TXDMA_PTR32 0x0044 +#define HREG_TXDMA_PRIO_PTR32 0x0048 +#define HREG_TXDMA_HIPRIO_PTR32 0x004C +#define HREG_RXDMA_PTR32 0x0050 +#define HREG_CARDDETECT_1 0x007C // contains 7D37 +#define HREG_CARDDETECT_2 0x007E // contains 7DE7 +#define HREG_FREETIMER 0x0058 +#define HREG_DMA_RX_CNT 0x0026 /****************************************************************************** -* Defines for the bits in the DmaControl register (@40h) -******************************************************************************/ -#define HREG_DMA_CTRL_RXHWEN 0x80000000 // high word enable bit -#define HREG_DMA_CTRL_RXRESET 0x40000000 // tx dma init bit -#define HREG_DMA_CTRL_RXBAP1 BIT29 -#define HREG_DMA_CTRL_RX_STALLED BIT28 -#define HREG_DMA_CTRL_RXAUTOACK_DMADONE BIT27 // no host involvement req. for TDMADONE event -#define HREG_DMA_CTRL_RXAUTOACK_INFO BIT26 // no host involvement req. for alloc event -#define HREG_DMA_CTRL_RXAUTOACK_DMAEN 0x02000000 // no host involvement req. for TxDMAen event -#define HREG_DMA_CTRL_RXAUTOACK_RX 0x01000000 // no host involvement req. for tx event -#define HREG_DMA_CTRL_RX_BUSY BIT23 // read only bit -//#define HREG_DMA_CTRL_RX_RBUFCONT_PLAIN 0 // bits 21..20 -//#define HREG_DMA_CTRL_RX_MODE_PLAIN_DMA 0 // mode 0 -#define HREG_DMA_CTRL_RX_MODE_SINGLE_PACKET 0x00010000 // mode 1 -#define HREG_DMA_CTRL_RX_MODE_MULTI_PACKET 0x00020000 // mode 2 -//#define HREG_DMA_CTRL_RX_MODE_DISABLE (0x00020000|0x00010000) // disable tx dma engine -#define HREG_DMA_CTRL_TXHWEN 0x8000 // low word enable bit -#define HREG_DMA_CTRL_TXRESET 0x4000 // rx dma init bit -#define HREG_DMA_CTRL_TXBAP1 BIT13 -#define HREG_DMA_CTRL_TXAUTOACK_DMADONE BIT11 // no host involvement req. for RxDMADONE event -#define HREG_DMA_CTRL_TXAUTOACK_DMAEN 0x00000400 // no host involvement req. for RxDMAen event -#define HREG_DMA_CTRL_TXAUTOACK_DMAALLOC 0x00000200 // no host involvement req. for info event -#define HREG_DMA_CTRL_TXAUTOACK_TX 0x00000100 // no host involvement req. for rx event -#define HREG_DMA_CTRL_TX_BUSY BIT7 // read only bit -//#define HREG_DMA_CTRL_TX_TBUFCONT_PLAIN 0 // bits 6..5 -//#define HREG_DMA_CTRL_TX_MODE_PLAIN_DMA 0 // mode 0 -#define HREG_DMA_CTRL_TX_MODE_SINGLE_PACKET BIT0 // mode 1 -#define HREG_DMA_CTRL_TX_MODE_MULTI_PACKET 0x00000002 // mode 2 -//#define HREG_DMA_CTRL_TX_MODE_DISABLE (0x00000001|0x00000002) // disable tx dma engine + * Defines for the bits in the DmaControl register (@40h) + ******************************************************************************/ +#define HREG_DMA_CTRL_RXHWEN 0x80000000 // high word enable bit +#define HREG_DMA_CTRL_RXRESET 0x40000000 // tx dma init bit +#define HREG_DMA_CTRL_RXBAP1 BIT29 +#define HREG_DMA_CTRL_RX_STALLED BIT28 +#define HREG_DMA_CTRL_RXAUTOACK_DMADONE BIT27 // no host involvement req. for TDMADONE event +#define HREG_DMA_CTRL_RXAUTOACK_INFO BIT26 // no host involvement req. for alloc event +#define HREG_DMA_CTRL_RXAUTOACK_DMAEN 0x02000000 // no host involvement req. for TxDMAen event +#define HREG_DMA_CTRL_RXAUTOACK_RX 0x01000000 // no host involvement req. for tx event +#define HREG_DMA_CTRL_RX_BUSY BIT23 // read only bit +//#define HREG_DMA_CTRL_RX_RBUFCONT_PLAIN 0 // bits 21..20 +//#define HREG_DMA_CTRL_RX_MODE_PLAIN_DMA 0 // mode 0 +#define HREG_DMA_CTRL_RX_MODE_SINGLE_PACKET 0x00010000 // mode 1 +#define HREG_DMA_CTRL_RX_MODE_MULTI_PACKET 0x00020000 // mode 2 +//#define HREG_DMA_CTRL_RX_MODE_DISABLE (0x00020000|0x00010000) // disable tx dma engine +#define HREG_DMA_CTRL_TXHWEN 0x8000 // low word enable bit +#define HREG_DMA_CTRL_TXRESET 0x4000 // rx dma init bit +#define HREG_DMA_CTRL_TXBAP1 BIT13 +#define HREG_DMA_CTRL_TXAUTOACK_DMADONE BIT11 // no host involvement req. for RxDMADONE event +#define HREG_DMA_CTRL_TXAUTOACK_DMAEN 0x00000400 // no host involvement req. for RxDMAen event +#define HREG_DMA_CTRL_TXAUTOACK_DMAALLOC 0x00000200 // no host involvement req. for info event +#define HREG_DMA_CTRL_TXAUTOACK_TX 0x00000100 // no host involvement req. for rx event +#define HREG_DMA_CTRL_TX_BUSY BIT7 // read only bit +//#define HREG_DMA_CTRL_TX_TBUFCONT_PLAIN 0 // bits 6..5 +//#define HREG_DMA_CTRL_TX_MODE_PLAIN_DMA 0 // mode 0 +#define HREG_DMA_CTRL_TX_MODE_SINGLE_PACKET BIT0 // mode 1 +#define HREG_DMA_CTRL_TX_MODE_MULTI_PACKET 0x00000002 // mode 2 +//#define HREG_DMA_CTRL_TX_MODE_DISABLE (0x00000001|0x00000002) // disable tx dma engine //configuration DWORD to configure DMA for mode2 operation, using BAP0 as the DMA BAP. #define DMA_CTRLSTAT_GO (HREG_DMA_CTRL_RXHWEN | HREG_DMA_CTRL_RX_MODE_MULTI_PACKET | \ HREG_DMA_CTRL_RXAUTOACK_DMAEN | HREG_DMA_CTRL_RXAUTOACK_RX | \ HREG_DMA_CTRL_TXHWEN | /*;?HREG_DMA_CTRL_TX_TBUFCONT_PLAIN |*/ \ - HREG_DMA_CTRL_TX_MODE_MULTI_PACKET | HREG_DMA_CTRL_TXAUTOACK_DMAEN |\ + HREG_DMA_CTRL_TX_MODE_MULTI_PACKET | HREG_DMA_CTRL_TXAUTOACK_DMAEN | \ HREG_DMA_CTRL_TXAUTOACK_DMAALLOC) //configuration DWORD to reset both the Tx and Rx DMA engines #define DMA_CTRLSTAT_RESET (HREG_DMA_CTRL_RXHWEN | HREG_DMA_CTRL_RXRESET | HREG_DMA_CTRL_TXHWEN | HREG_DMA_CTRL_TXRESET) -//#define DESC_DMA_OWNED 0x80000000 // BIT31 -#define DESC_DMA_OWNED 0x8000 // BIT31 -#define DESC_SOP 0x8000 // BIT15 -#define DESC_EOP 0x4000 // BIT14 +//#define DESC_DMA_OWNED 0x80000000 // BIT31 +#define DESC_DMA_OWNED 0x8000 // BIT31 +#define DESC_SOP 0x8000 // BIT15 +#define DESC_EOP 0x4000 // BIT14 -#define DMA_RX 0 -#define DMA_TX 1 +#define DMA_RX 0 +#define DMA_TX 1 -// #define IFB_RxFirstDesc IFB_FirstDesc[DMA_RX] -// #define IFB_TxFirstDesc IFB_FirstDesc[DMA_TX] -// #define IFB_RxLastDesc IFB_LastDesc[DMA_RX] -// #define IFB_TxLastDesc IFB_LastDesc[DMA_TX] +// #define IFB_RxFirstDesc IFB_FirstDesc[DMA_RX] +// #define IFB_TxFirstDesc IFB_FirstDesc[DMA_TX] +// #define IFB_RxLastDesc IFB_LastDesc[DMA_RX] +// #define IFB_TxLastDesc IFB_LastDesc[DMA_TX] #endif // HCF_DMA // @@ -390,96 +353,96 @@ err: these values should match; // Hermes Command Codes and Qualifier bits -#define HCMD_BUSY 0x8000 // Busy bit, applicable for all commands -#define HCMD_INI 0x0000 // -#define HCMD_ENABLE HCF_CNTL_ENABLE // 0x0001 -#define HCMD_DISABLE HCF_CNTL_DISABLE // 0x0002 -#define HCMD_CONNECT HCF_CNTL_CONNECT // 0x0003 -#define HCMD_EXECUTE 0x0004 // -#define HCMD_DISCONNECT HCF_CNTL_DISCONNECT // 0x0005 -#define HCMD_SLEEP 0x0006 // -#define HCMD_CONTINUE HCF_CNTL_CONTINUE // 0x0007 -#define HCMD_RETRY 0x0100 // Retry bit -#define HCMD_ALLOC 0x000A // -#define HCMD_TX 0x000B // -#define HCMD_RECL 0x0100 // Reclaim bit, applicable for Tx and Inquire -#define HCMD_INQUIRE 0x0011 // -#define HCMD_ACCESS 0x0021 // -#define HCMD_ACCESS_WRITE 0x0100 // Write bit -#define HCMD_PROGRAM 0x0022 // -#define HCMD_READ_MIF 0x0030 -#define HCMD_WRITE_MIF 0x0031 -#define HCMD_THESEUS 0x0038 -#define HCMD_STARTPREAMBLE 0x0E00 // Start continuous preamble Tx -#define HCMD_STOP 0x0F00 // Stop Theseus test mode +#define HCMD_BUSY 0x8000 // Busy bit, applicable for all commands +#define HCMD_INI 0x0000 // +#define HCMD_ENABLE HCF_CNTL_ENABLE // 0x0001 +#define HCMD_DISABLE HCF_CNTL_DISABLE // 0x0002 +#define HCMD_CONNECT HCF_CNTL_CONNECT // 0x0003 +#define HCMD_EXECUTE 0x0004 // +#define HCMD_DISCONNECT HCF_CNTL_DISCONNECT // 0x0005 +#define HCMD_SLEEP 0x0006 // +#define HCMD_CONTINUE HCF_CNTL_CONTINUE // 0x0007 +#define HCMD_RETRY 0x0100 // Retry bit +#define HCMD_ALLOC 0x000A // +#define HCMD_TX 0x000B // +#define HCMD_RECL 0x0100 // Reclaim bit, applicable for Tx and Inquire +#define HCMD_INQUIRE 0x0011 // +#define HCMD_ACCESS 0x0021 // +#define HCMD_ACCESS_WRITE 0x0100 // Write bit +#define HCMD_PROGRAM 0x0022 // +#define HCMD_READ_MIF 0x0030 +#define HCMD_WRITE_MIF 0x0031 +#define HCMD_THESEUS 0x0038 +#define HCMD_STARTPREAMBLE 0x0E00 // Start continuous preamble Tx +#define HCMD_STOP 0x0F00 // Stop Theseus test mode //Configuration Management // -#define CFG_DRV_ACT_RANGES_PRI_3_BOTTOM 1 // Default Bottom Compatibility for Primary Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_PRI_3_TOP 1 // Default Top Compatibility for Primary Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_PRI_3_BOTTOM 1 // Default Bottom Compatibility for Primary Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_PRI_3_TOP 1 // Default Top Compatibility for Primary Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_HSI_4_BOTTOM 1 // Default Bottom Compatibility for H/W - driver I/F -#define CFG_DRV_ACT_RANGES_HSI_4_TOP 1 // Default Top Compatibility for H/W - driver I/F +#define CFG_DRV_ACT_RANGES_HSI_4_BOTTOM 1 // Default Bottom Compatibility for H/W - driver I/F +#define CFG_DRV_ACT_RANGES_HSI_4_TOP 1 // Default Top Compatibility for H/W - driver I/F -#define CFG_DRV_ACT_RANGES_HSI_5_BOTTOM 1 // Default Bottom Compatibility for H/W - driver I/F -#define CFG_DRV_ACT_RANGES_HSI_5_TOP 1 // Default Top Compatibility for H/W - driver I/F +#define CFG_DRV_ACT_RANGES_HSI_5_BOTTOM 1 // Default Bottom Compatibility for H/W - driver I/F +#define CFG_DRV_ACT_RANGES_HSI_5_TOP 1 // Default Top Compatibility for H/W - driver I/F #if (HCF_TYPE) & HCF_TYPE_WPA -#define CFG_DRV_ACT_RANGES_APF_1_BOTTOM 16 // Default Bottom Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_1_TOP 16 // Default Top Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_1_BOTTOM 16 // Default Bottom Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_1_TOP 16 // Default Top Compatibility for AP Firmware - driver I/F #else //;? is this REALLY O.K. -#define CFG_DRV_ACT_RANGES_APF_1_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_1_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_1_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_1_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F #endif // HCF_TYPE_WPA -#define CFG_DRV_ACT_RANGES_APF_2_BOTTOM 2 // Default Bottom Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_2_TOP 2 // Default Top Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_2_BOTTOM 2 // Default Bottom Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_2_TOP 2 // Default Top Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_3_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_3_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_3_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_3_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_4_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_APF_4_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_4_BOTTOM 1 // Default Bottom Compatibility for AP Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_APF_4_TOP 1 // Default Top Compatibility for AP Firmware - driver I/F #if (HCF_TYPE) & HCF_TYPE_HII5 -#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM 6 // Default Bottom Compatibility for Station Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_STA_2_TOP 6 // Default Top Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM 6 // Default Bottom Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_2_TOP 6 // Default Top Compatibility for Station Firmware - driver I/F #else // (HCF_TYPE) & HCF_TYPE_HII5 -#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_STA_2_TOP 2 // Default Top Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_2_TOP 2 // Default Top Compatibility for Station Firmware - driver I/F #endif // (HCF_TYPE) & HCF_TYPE_HII5 -#define CFG_DRV_ACT_RANGES_STA_3_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_STA_3_TOP 1 // Default Top Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_3_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_3_TOP 1 // Default Top Compatibility for Station Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_STA_4_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F -#define CFG_DRV_ACT_RANGES_STA_4_TOP 1 // Default Top Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_4_BOTTOM 1 // Default Bottom Compatibility for Station Firmware - driver I/F +#define CFG_DRV_ACT_RANGES_STA_4_TOP 1 // Default Top Compatibility for Station Firmware - driver I/F //--------------------------------------------------------------------------------------------------------------------- #if defined HCF_CFG_PRI_1_TOP || defined HCF_CFG_PRI_1_BOTTOM -err: PRI_1 not supported for H-I; // Compatibility for Primary Firmware - driver I/F +err: PRI_1 not supported for H-I; // Compatibility for Primary Firmware - driver I/F #endif // HCF_CFG_PRI_1_TOP / HCF_CFG_PRI_1_BOTTOM #if defined HCF_CFG_PRI_2_TOP || defined HCF_CFG_PRI_2_BOTTOM -err: PRI_2 not supported for H-I; // Compatibility for Primary Firmware - driver I/F +err: PRI_2 not supported for H-I; // Compatibility for Primary Firmware - driver I/F #endif // HCF_CFG_PRI_2_TOP / HCF_CFG_PRI_2_BOTTOM -#ifdef HCF_CFG_PRI_3_TOP // Top Compatibility for Primary Firmware - driver I/F -#if HCF_CFG_PRI_3_TOP == 0 || \ +#ifdef HCF_CFG_PRI_3_TOP // Top Compatibility for Primary Firmware - driver I/F +#if HCF_CFG_PRI_3_TOP == 0 || \ CFG_DRV_ACT_RANGES_PRI_3_BOTTOM <= HCF_CFG_PRI_3_TOP && HCF_CFG_PRI_3_TOP <= CFG_DRV_ACT_RANGES_PRI_3_TOP #undef CFG_DRV_ACT_RANGES_PRI_3_TOP -#define CFG_DRV_ACT_RANGES_PRI_3_TOP HCF_CFG_PRI_3_TOP +#define CFG_DRV_ACT_RANGES_PRI_3_TOP HCF_CFG_PRI_3_TOP #else err: ; #endif #endif // HCF_CFG_PRI_3_TOP -#ifdef HCF_CFG_PRI_3_BOTTOM // Bottom Compatibility for Primary Firmware - driver I/F +#ifdef HCF_CFG_PRI_3_BOTTOM // Bottom Compatibility for Primary Firmware - driver I/F #if CFG_DRV_ACT_RANGES_PRI_3_BOTTOM <= HCF_CFG_PRI_3_BOTTOM && HCF_CFG_PRI_3_BOTTOM <= CFG_DRV_ACT_RANGES_PRI_3_TOP #undef CFG_DRV_ACT_RANGES_PRI_3_BOTTOM -#define CFG_DRV_ACT_RANGES_PRI_3_BOTTOM HCF_CFG_PRI_3_BOTTOM +#define CFG_DRV_ACT_RANGES_PRI_3_BOTTOM HCF_CFG_PRI_3_BOTTOM #else err: ; #endif @@ -488,77 +451,77 @@ err: ; //--------------------------------------------------------------------------------------------------------------------- #if defined HCF_CFG_HSI_0_TOP || defined HCF_CFG_HSI_0_BOTTOM -err: HSI_0 not supported for H-I; // Compatibility for HSI I/F +err: HSI_0 not supported for H-I; // Compatibility for HSI I/F #endif // HCF_CFG_HSI_0_TOP / HCF_CFG_HSI_0_BOTTOM #if defined HCF_CFG_HSI_1_TOP || defined HCF_CFG_HSI_1_BOTTOM -err: HSI_1 not supported for H-I; // Compatibility for HSI I/F +err: HSI_1 not supported for H-I; // Compatibility for HSI I/F #endif // HCF_CFG_HSI_1_TOP / HCF_CFG_HSI_1_BOTTOM #if defined HCF_CFG_HSI_2_TOP || defined HCF_CFG_HSI_2_BOTTOM -err: HSI_2 not supported for H-I; // Compatibility for HSI I/F +err: HSI_2 not supported for H-I; // Compatibility for HSI I/F #endif // HCF_CFG_HSI_2_TOP / HCF_CFG_HSI_2_BOTTOM #if defined HCF_CFG_HSI_3_TOP || defined HCF_CFG_HSI_3_BOTTOM -err: HSI_3 not supported for H-I; // Compatibility for HSI I/F +err: HSI_3 not supported for H-I; // Compatibility for HSI I/F #endif // HCF_CFG_HSI_3_TOP / HCF_CFG_HSI_3_BOTTOM -#ifdef HCF_CFG_HSI_4_TOP // Top Compatibility for HSI I/F -#if HCF_CFG_HSI_4_TOP == 0 || \ +#ifdef HCF_CFG_HSI_4_TOP // Top Compatibility for HSI I/F +#if HCF_CFG_HSI_4_TOP == 0 || \ CFG_DRV_ACT_RANGES_HSI_4_BOTTOM <= CF_CFG_HSI_4_TOP && HCF_CFG_HSI_4_TOP <= CFG_DRV_ACT_RANGES_HSI_4_TOP #undef CFG_DRV_ACT_RANGES_HSI_4_TOP -#define CFG_DRV_ACT_RANGES_HSI_4_TOP HCF_CFG_HSI_4_TOP +#define CFG_DRV_ACT_RANGES_HSI_4_TOP HCF_CFG_HSI_4_TOP #else err: ; #endif #endif // HCF_CFG_HSI_4_TOP -#ifdef HCF_CFG_HSI_4_BOTTOM // Bottom Compatibility for HSI I/F +#ifdef HCF_CFG_HSI_4_BOTTOM // Bottom Compatibility for HSI I/F #if CFG_DRV_ACT_RANGES_HSI_4_BOTTOM <= HCF_CFG_HSI_4_BOTTOM && HCF_CFG_HSI_4_BOTTOM <= CFG_DRV_ACT_RANGES_HSI_4_TOP #undef CFG_DRV_ACT_RANGES_HSI_4_BOTTOM -#define CFG_DRV_ACT_RANGES_HSI_4_BOTTOM HCF_CFG_HSI_4_BOTTOM +#define CFG_DRV_ACT_RANGES_HSI_4_BOTTOM HCF_CFG_HSI_4_BOTTOM #else err: ; #endif #endif // HCF_CFG_HSI_4_BOTTOM -#ifdef HCF_CFG_HSI_5_TOP // Top Compatibility for HSI I/F -#if HCF_CFG_HSI_5_TOP == 0 || \ +#ifdef HCF_CFG_HSI_5_TOP // Top Compatibility for HSI I/F +#if HCF_CFG_HSI_5_TOP == 0 || \ CFG_DRV_ACT_RANGES_HSI_5_BOTTOM <= CF_CFG_HSI_5_TOP && HCF_CFG_HSI_5_TOP <= CFG_DRV_ACT_RANGES_HSI_5_TOP #undef CFG_DRV_ACT_RANGES_HSI_5_TOP -#define CFG_DRV_ACT_RANGES_HSI_5_TOP HCF_CFG_HSI_5_TOP +#define CFG_DRV_ACT_RANGES_HSI_5_TOP HCF_CFG_HSI_5_TOP #else err: ; #endif #endif // HCF_CFG_HSI_5_TOP -#ifdef HCF_CFG_HSI_5_BOTTOM // Bottom Compatibility for HSI I/F +#ifdef HCF_CFG_HSI_5_BOTTOM // Bottom Compatibility for HSI I/F #if CFG_DRV_ACT_RANGES_HSI_5_BOTTOM <= HCF_CFG_HSI_5_BOTTOM && HCF_CFG_HSI_5_BOTTOM <= CFG_DRV_ACT_RANGES_HSI_5_TOP #undef CFG_DRV_ACT_RANGES_HSI_5_BOTTOM -#define CFG_DRV_ACT_RANGES_HSI_5_BOTTOM HCF_CFG_HSI_5_BOTTOM +#define CFG_DRV_ACT_RANGES_HSI_5_BOTTOM HCF_CFG_HSI_5_BOTTOM #else err: ; #endif #endif // HCF_CFG_HSI_5_BOTTOM //--------------------------------------------------------------------------------------------------------------------- #if defined HCF_CFG_APF_1_TOP || defined HCF_CFG_APF_1_BOTTOM -err: APF_1 not supported for H-I; // Compatibility for AP Firmware - driver I/F +err: APF_1 not supported for H-I; // Compatibility for AP Firmware - driver I/F #endif // HCF_CFG_APF_1_TOP / HCF_CFG_APF_1_BOTTOM -#ifdef HCF_CFG_APF_2_TOP // Top Compatibility for AP Firmware - driver I/F -#if HCF_CFG_APF_2_TOP == 0 || \ +#ifdef HCF_CFG_APF_2_TOP // Top Compatibility for AP Firmware - driver I/F +#if HCF_CFG_APF_2_TOP == 0 || \ CFG_DRV_ACT_RANGES_APF_2_BOTTOM <= HCF_CFG_APF_2_TOP && HCF_CFG_APF_2_TOP <= CFG_DRV_ACT_RANGES_APF_2_TOP #undef CFG_DRV_ACT_RANGES_APF_2_TOP -#define CFG_DRV_ACT_RANGES_APF_2_TOP HCF_CFG_APF_2_TOP +#define CFG_DRV_ACT_RANGES_APF_2_TOP HCF_CFG_APF_2_TOP #else err: ; #endif #endif // HCF_CFG_APF_TOP -#ifdef HCF_CFG_APF_2_BOTTOM // Bottom Compatibility for AP Firmware - driver I/F +#ifdef HCF_CFG_APF_2_BOTTOM // Bottom Compatibility for AP Firmware - driver I/F #if CFG_DRV_ACT_RANGES_APF_2_BOTTOM <= HCF_CFG_APF_2_BOTTOM && HCF_CFG_APF_2_BOTTOM <= CFG_DRV_ACT_RANGES_APF_2_TOP #undef CFG_DRV_ACT_RANGES_APF_2_BOTTOM -#define CFG_DRV_ACT_RANGES_APF_2_BOTTOM HCF_CFG_APF_2_BOTTOM +#define CFG_DRV_ACT_RANGES_APF_2_BOTTOM HCF_CFG_APF_2_BOTTOM #else err: ; #endif @@ -566,23 +529,23 @@ err: ; //--------------------------------------------------------------------------------------------------------------------- #if defined HCF_CFG_STA_1_TOP || defined HCF_CFG_STA_1_BOTTOM -err: STA_1 not supported for H-I; // Compatibility for Station Firmware - driver I/F +err: STA_1 not supported for H-I; // Compatibility for Station Firmware - driver I/F #endif // HCF_CFG_STA_1_TOP / HCF_CFG_STA_1_BOTTOM -#ifdef HCF_CFG_STA_2_TOP // Top Compatibility for Station Firmware - driver I/F -#if HCF_CFG_STA_2_TOP == 0 || \ +#ifdef HCF_CFG_STA_2_TOP // Top Compatibility for Station Firmware - driver I/F +#if HCF_CFG_STA_2_TOP == 0 || \ CFG_DRV_ACT_RANGES_STA_2_BOTTOM <= HCF_CFG_STA_2_TOP && HCF_CFG_STA_2_TOP <= CFG_DRV_ACT_RANGES_STA_2_TOP #undef CFG_DRV_ACT_RANGES_STA_2_TOP -#define CFG_DRV_ACT_RANGES_STA_2_TOP HCF_CFG_STA_2_TOP +#define CFG_DRV_ACT_RANGES_STA_2_TOP HCF_CFG_STA_2_TOP #else err: ; #endif #endif // HCF_CFG_STA_TOP -#ifdef HCF_CFG_STA_2_BOTTOM // Bottom Compatibility for Station Firmware - driver I/F +#ifdef HCF_CFG_STA_2_BOTTOM // Bottom Compatibility for Station Firmware - driver I/F #if CFG_DRV_ACT_RANGES_STA_2_BOTTOM <= HCF_CFG_STA_2_BOTTOM && HCF_CFG_STA_2_BOTTOM <= CFG_DRV_ACT_RANGES_STA_2_TOP #undef CFG_DRV_ACT_RANGES_STA_2_BOTTOM -#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM HCF_CFG_STA_2_BOTTOM +#define CFG_DRV_ACT_RANGES_STA_2_BOTTOM HCF_CFG_STA_2_BOTTOM #else err: ; #endif @@ -597,32 +560,32 @@ err: ; #if defined MSF_WAIT err: MSF should no longer supply this macro; #else -#define MSF_WAIT(x) \ - { PROT_CNT_INI \ - HCF_WAIT_WHILE( ( IPW( HREG_IO ) & HREG_IO_WOKEN_UP ) == 0 ); \ - HCFASSERT( prot_cnt, IPW( HREG_IO ) ) \ - } +#define MSF_WAIT(x) \ + { PROT_CNT_INI \ + HCF_WAIT_WHILE( ( IPW( HREG_IO ) & HREG_IO_WOKEN_UP ) == 0 ); \ + HCFASSERT( prot_cnt, IPW( HREG_IO ) ) \ + } #endif // MSF_WAIT #else -#define MSF_WAIT(x) /*NOP*/ +#define MSF_WAIT(x) /*NOP*/ #endif // HCF_SLEEP -#define LOF(x) (sizeof(x)/sizeof(hcf_16)-1) +#define LOF(x) (sizeof(x)/sizeof(hcf_16)-1) -#define MUL_BY_2( x ) ( (x) << 1 ) //used to multiply by 2 -#define DIV_BY_2( x ) ( (x) >> 1 ) //used to divide by 2 +#define MUL_BY_2( x ) ( (x) << 1 ) //used to multiply by 2 +#define DIV_BY_2( x ) ( (x) >> 1 ) //used to divide by 2 //resolve problems on for some 16 bits compilers to create 32 bit values -#define MERGE_2( hw, lw ) ( ( ((hcf_32)(hw)) << 16 ) | ((hcf_16)(lw)) ) +#define MERGE_2( hw, lw ) ( ( ((hcf_32)(hw)) << 16 ) | ((hcf_16)(lw)) ) #if ! defined HCF_STATIC -#define HCF_STATIC static -#endif // HCF_STATIC +#define HCF_STATIC static +#endif // HCF_STATIC #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 -#define DAWA_ACK( mask) { \ - OPW( HREG_EV_ACK, mask | HREG_EV_ACK_REG_READY ); \ - OPW( HREG_EV_ACK, (mask & ~HREG_EV_ALLOC) | HREG_EV_ACK_REG_READY ); } +#define DAWA_ACK( mask) { \ + OPW( HREG_EV_ACK, mask | HREG_EV_ACK_REG_READY ); \ + OPW( HREG_EV_ACK, (mask & ~HREG_EV_ALLOC) | HREG_EV_ACK_REG_READY ); } #define DAWA_ZERO_FID(reg) OPW( reg, 0 ); #else #define DAWA_ACK( mask) OPW( HREG_EV_ACK, mask ); @@ -630,20 +593,20 @@ err: MSF should no longer supply this macro; #endif // HCF_TYPE_HII5 #if (HCF_TYPE) & HCF_TYPE_WPA -#define CALC_RX_MIC( p, len ) calc_mic_rx_frag( ifbp, p, len ) -#define CALC_TX_MIC( p, len ) calc_mic_tx_frag( ifbp, p, len ) +#define CALC_RX_MIC( p, len ) calc_mic_rx_frag( ifbp, p, len ) +#define CALC_TX_MIC( p, len ) calc_mic_tx_frag( ifbp, p, len ) #define IF_SSN(x) x #define IF_NOT_SSN(x) #else -#define CALC_RX_MIC( p, len ) -#define CALC_TX_MIC( p, len ) +#define CALC_RX_MIC( p, len ) +#define CALC_TX_MIC( p, len ) #define MIC_RX_RTN( mic, dw ) #define MIC_TX_RTN( mic, dw ) #define IF_SSN(x) #define IF_NOT_SSN(x) x #endif // HCF_TYPE_WPA -#if HCF_TALLIES & HCF_TALLIES_HCF //HCF tally support +#if HCF_TALLIES & HCF_TALLIES_HCF //HCF tally support #define IF_TALLY(x) x #else #define IF_TALLY(x) @@ -651,23 +614,23 @@ err: MSF should no longer supply this macro; #if HCF_DMA -#define IF_DMA(x) x +#define IF_DMA(x) x #define IF_NOT_DMA(x) -#define IF_USE_DMA(x) if ( ifbp->IFB_CntlOpt & USE_DMA ) x -#define IF_NOT_USE_DMA(x) if ( !(ifbp->IFB_CntlOpt & USE_DMA) ) x +#define IF_USE_DMA(x) if ( ifbp->IFB_CntlOpt & USE_DMA ) x +#define IF_NOT_USE_DMA(x) if ( !(ifbp->IFB_CntlOpt & USE_DMA) ) x #else #define IF_DMA(x) -#define IF_NOT_DMA(x) x +#define IF_NOT_DMA(x) x #define IF_USE_DMA(x) -#define IF_NOT_USE_DMA(x) x +#define IF_NOT_USE_DMA(x) x #endif // HCF_DMA #define IPW(x) ((hcf_16)IN_PORT_WORD( ifbp->IFB_IOBase + (x) ) ) #define OPW(x, y) OUT_PORT_WORD( ifbp->IFB_IOBase + (x), y ) - /* make sure the implementation of HCF_WAIT_WHILE is such that there may be multiple HCF_WAIT_WHILE calls - * in a row and that when one fails all subsequent fail immediately without reinitialization of prot_cnt - */ +/* make sure the implementation of HCF_WAIT_WHILE is such that there may be multiple HCF_WAIT_WHILE calls + * in a row and that when one fails all subsequent fail immediately without reinitialization of prot_cnt + */ #if HCF_PROT_TIME == 0 #define PROT_CNT_INI #define IF_PROT_TIME(x) @@ -677,8 +640,8 @@ err: MSF should no longer supply this macro; #define HCF_WAIT_WHILE( x ) while ( x ) /*NOP*/; #endif // HCF_YIELD #else -#define PROT_CNT_INI hcf_32 prot_cnt = ifbp->IFB_TickIni; -#define IF_PROT_TIME(x) x +#define PROT_CNT_INI hcf_32 prot_cnt = ifbp->IFB_TickIni; +#define IF_PROT_TIME(x) x #if defined HCF_YIELD #define HCF_WAIT_WHILE( x ) while ( prot_cnt && (x) && (HCF_YIELD) ) prot_cnt--; #else @@ -697,7 +660,7 @@ err: you used an invalid bitmask; #endif // HCF_EX_INT #if 0 //get compiler going -#if HCF_EX_INT_TICK != HREG_EV_TICK +#if HCF_EX_INT_TICK != HREG_EV_TICK ;? out dated checking err: someone redefined these macros while the implemenation assumes they are equal; #endif @@ -724,36 +687,36 @@ err: someone redefined these macros while the implemenation assumes they are equ #define HCFASSERT(x,q) {if (!(x)) {mdd_assert( ifbp, __LINE__ , q );}} #define MMDASSERT(x,q) {if (!(x)) {mdd_assert( assert_ifbp, __LINE__ + FILE_NAME_OFFSET, q );}} -#define HCFLOGENTRY( where, what ) \ -{if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ - HCF_ENTRY( ifbp ); \ - HCFASSERT( (ifbp->IFB_AssertTrace & 1<<((where)&0xF)) == 0, ifbp->IFB_AssertTrace ); \ - ifbp->IFB_AssertTrace |= 1<<((where)&0xF); \ - } \ -HCFTRACE(ifbp, where ) \ -HCFTRACEVALUE(ifbp, what ) \ -} +#define HCFLOGENTRY( where, what ) \ + {if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ + HCF_ENTRY( ifbp ); \ + HCFASSERT( (ifbp->IFB_AssertTrace & 1<<((where)&0xF)) == 0, ifbp->IFB_AssertTrace ); \ + ifbp->IFB_AssertTrace |= 1<<((where)&0xF); \ + } \ + HCFTRACE(ifbp, where ) \ + HCFTRACEVALUE(ifbp, what ) \ + } -#define HCFLOGEXIT( where ) \ -{if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ - HCF_EXIT( ifbp ); \ - ifbp->IFB_AssertTrace &= ~(1<<((where)&0xF)); \ - } \ -HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ -} +#define HCFLOGEXIT( where ) \ + {if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ + HCF_EXIT( ifbp ); \ + ifbp->IFB_AssertTrace &= ~(1<<((where)&0xF)); \ + } \ + HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ + } #else // HCF_ASSERT #define HCFASSERT( x, q ) #define MMDASSERT( x, q ) -#define HCFLOGENTRY( where, what ) {HCF_ENTRY( ifbp );} -#define HCFLOGEXIT( where ) {HCF_EXIT( ifbp );} +#define HCFLOGENTRY( where, what ) {HCF_ENTRY( ifbp );} +#define HCFLOGEXIT( where ) {HCF_EXIT( ifbp );} #endif // HCF_ASSERT #if HCF_INT_ON /* ;? HCFASSERT_INT * #if (HCF_SLEEP) & HCF_DDS * #define HCFASSERT_INT HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFF && ifbp->IFB_IntOffCnt != 0xFFFE, \ - * ifbp->IFB_IntOffCnt ) + * ifbp->IFB_IntOffCnt ) * #else */ #define HCFASSERT_INT HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFF, ifbp->IFB_IntOffCnt ) @@ -764,8 +727,8 @@ HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ #if defined HCF_TRACE -#define HCFTRACE(ifbp, where ) {OPW( HREG_SW_1, where );} -//#define HCFTRACE(ifbp, where ) {HCFASSERT( DO_ASSERT, where );} +#define HCFTRACE(ifbp, where ) {OPW( HREG_SW_1, where );} +//#define HCFTRACE(ifbp, where ) {HCFASSERT( DO_ASSERT, where );} #define HCFTRACEVALUE(ifbp, what ) {OPW( HREG_SW_2, what );} //#define HCFTRACEVALUE(ifbp, what ) {HCFASSERT( DO_ASSERT, what );} #else @@ -775,7 +738,7 @@ HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ #if HCF_BIG_ENDIAN -#define BE_PAR(x) ,x +#define BE_PAR(x) ,x #else #define BE_PAR(x) #endif // HCF_BIG_ENDIAN @@ -789,13 +752,13 @@ HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ /************************************************************************************************/ #if HCF_ASSERT -extern IFBP BASED assert_ifbp; //to make asserts easily work under MMD and DHF -EXTERN_C void mdd_assert (IFBP ifbp, unsigned int line_number, hcf_32 q ); +extern IFBP BASED assert_ifbp; //to make asserts easily work under MMD and DHF +EXTERN_C void mdd_assert (IFBP ifbp, unsigned int line_number, hcf_32 q ); #endif //HCF_ASSERT -#if ! ( (HCF_IO) & HCF_IO_32BITS ) // defined 16 bits only +#if ! ( (HCF_IO) & HCF_IO_32BITS ) // defined 16 bits only #undef OUT_PORT_STRING_32 #undef IN_PORT_STRING_32 #endif // HCF_IO -#endif //HCFDEFC_H +#endif //HCFDEFC_H From 788c2bce7e06f9fd682a7a2db9d6b823e1d18d44 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:47 +0100 Subject: [PATCH 1023/1519] staging: wlags49_h2: Fix macro termination Semi-colon terminate various macros (HCFASSERT, IF_PROT_TIME, IF_DMA, PROT_CNT_INI, HCFLOGENTRY, HCFLOGEXIT, DAWA_ACK, DAWA_ZERO_FID) so auto-indent will work correctly. Add appropriate do {} while protection to the macros. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 350 ++++++++++++++-------------- drivers/staging/wlags49_h2/hcfdef.h | 93 ++++---- 2 files changed, 220 insertions(+), 223 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index a73317ef935..85950d74f8f 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -703,19 +703,19 @@ hcf_action( IFBP ifbp, hcf_16 action ) { int rc = HCF_SUCCESS; - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); #if HCF_INT_ON - HCFLOGENTRY( action == HCF_ACT_INT_FORCE_ON ? HCF_TRACE_ACTION_KLUDGE : HCF_TRACE_ACTION, action ) /* 0 */ + HCFLOGENTRY( action == HCF_ACT_INT_FORCE_ON ? HCF_TRACE_ACTION_KLUDGE : HCF_TRACE_ACTION, action ); /* 0 */ #if (HCF_SLEEP) HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE || action == HCF_ACT_INT_OFF, - MERGE_2( action, ifbp->IFB_IntOffCnt ) ) + MERGE_2( action, ifbp->IFB_IntOffCnt ) ); #else - HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, action ) + HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, action ); #endif // HCF_SLEEP HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFF || - action == HCF_ACT_INT_OFF || action == HCF_ACT_INT_FORCE_ON, action ) + action == HCF_ACT_INT_OFF || action == HCF_ACT_INT_FORCE_ON, action ); HCFASSERT( ifbp->IFB_IntOffCnt <= 16 || ifbp->IFB_IntOffCnt >= 0xFFFE, - MERGE_2( action, ifbp->IFB_IntOffCnt ) ) //nesting more than 16 deep seems unreasonable + MERGE_2( action, ifbp->IFB_IntOffCnt ) ); //nesting more than 16 deep seems unreasonable #endif // HCF_INT_ON switch (action) { @@ -789,7 +789,7 @@ hcf_16 i; cmd_exe( ifbp, HCMD_SLEEP, 0 ); break; // case HCF_ACT_WAKEUP: // DDS Wakeup request -// HCFASSERT( ifbp->IFB_IntOffCnt == 0xFFFE, ifbp->IFB_IntOffCnt ) +// HCFASSERT( ifbp->IFB_IntOffCnt == 0xFFFE, ifbp->IFB_IntOffCnt ); // ifbp->IFB_IntOffCnt++; // restore conventional I/F // OPW( HREG_IO, HREG_IO_WAKEUP_ASYNC ); // MSF_WAIT(800); // MSF-defined function to wait n microseconds. @@ -828,11 +828,11 @@ hcf_16 i; break; default: - HCFASSERT( DO_ASSERT, action ) + HCFASSERT( DO_ASSERT, action ); break; } //! do not HCFASSERT( rc == HCF_SUCCESS, rc ) /* 30*/ - HCFLOGEXIT( HCF_TRACE_ACTION ) + HCFLOGEXIT( HCF_TRACE_ACTION ); return rc; } // hcf_action #endif // HCF_DL_ONLY @@ -959,13 +959,13 @@ int rc = HCF_ERR_INCOMP_FW; x &= ~HFS_TX_CNTL_PORT; } HCFASSERT( x==HCF_CNTL_ENABLE || x==HCF_CNTL_DISABLE || HCF_CNTL_CONTINUE || - x==HCF_CNTL_CONNECT || x==HCF_CNTL_DISCONNECT, cmd ) + x==HCF_CNTL_CONNECT || x==HCF_CNTL_DISCONNECT, cmd ); } #endif // HCF_ASSERT // #if (HCF_SLEEP) & HCF_DDS -// HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, cmd ) +// HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, cmd ); // #endif // HCF_DDS - HCFLOGENTRY( HCF_TRACE_CNTL, cmd ) + HCFLOGENTRY( HCF_TRACE_CNTL, cmd ); if ( ifbp->IFB_CardStat == 0 ) { /*2*/ /*6*/ rc = cmd_exe( ifbp, cmd, 0 ); #if (HCF_SLEEP) & HCF_DDS @@ -989,12 +989,12 @@ int rc = HCF_ERR_INCOMP_FW; * as additional beneficiary side effect, the SOP and EOP bits will also be cleared */ ifbp->IFB_CntlOpt |= DMA_ENABLED; - HCFASSERT( NT_ASSERT, NEVER_TESTED ) + HCFASSERT( NT_ASSERT, NEVER_TESTED ); // make the entire rx descriptor chain DMA-owned, so the DMA engine can (re-)use it. p = ifbp->IFB_FirstDesc[DMA_RX]; if (p != NULL) { //;? Think this over again in the light of the new chaining strategy if ( 1 ) { //begin alternative - HCFASSERT( NT_ASSERT, NEVER_TESTED ) + HCFASSERT( NT_ASSERT, NEVER_TESTED ); put_frame_lst( ifbp, ifbp->IFB_FirstDesc[DMA_RX], DMA_RX ); if ( ifbp->IFB_FirstDesc[DMA_RX] ) { put_frame_lst( ifbp, ifbp->IFB_FirstDesc[DMA_RX]->next_desc_addr, DMA_RX ); @@ -1013,8 +1013,8 @@ int rc = HCF_ERR_INCOMP_FW; } } #endif // HCF_DMA - HCFASSERT( rc == HCF_SUCCESS, rc ) - HCFLOGEXIT( HCF_TRACE_CNTL ) + HCFASSERT( rc == HCF_SUCCESS, rc ); + HCFLOGEXIT( HCF_TRACE_CNTL ); return rc; } // hcf_cntl @@ -1217,19 +1217,19 @@ LTV_STRCT x; ifbp->IFB_AssertStrct.frag_buf[0].frag_addr = &ifbp->IFB_AssertLine; #endif // HCF_ASSERT_MB #endif // HCF_ASSERT - IF_PROT_TIME( prot_cnt = ifbp->IFB_TickIni = INI_TICK_INI; ) + IF_PROT_TIME( prot_cnt = ifbp->IFB_TickIni = INI_TICK_INI ); #if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 //!! No asserts before Reset-bit in HREG_IO is cleared OPW( HREG_IO, 0x0000 ); //OPW useable /* 2b*/ HCF_WAIT_WHILE( (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); - IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ) - IF_PROT_TIME( if ( prot_cnt ) prot_cnt = ifbp->IFB_TickIni; ) + IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ); + IF_PROT_TIME( if ( prot_cnt ) prot_cnt = ifbp->IFB_TickIni ); #endif // HCF_TYPE_PRELOADED //!! No asserts before Reset-bit in HREG_IO is cleared - HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF0 ) ) //just to proof that the complete assert machinery is working - HCFASSERT( xa != CFG_FW_IDENTITY, 0 ) // assert if hcf_connect is called without intervening hcf_disconnect. - HCFASSERT( ((hcf_32)(void*)ifbp & (HCF_ALIGN-1) ) == 0, (hcf_32)(void*)ifbp ) - HCFASSERT( (io_addr & 0x003F) == 0, io_addr ) + HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF0 ) ); //just to proof that the complete assert machinery is working + HCFASSERT( xa != CFG_FW_IDENTITY, 0 ); // assert if hcf_connect is called without intervening hcf_disconnect. + HCFASSERT( ((hcf_32)(void*)ifbp & (HCF_ALIGN-1) ) == 0, (hcf_32)(void*)ifbp ); + HCFASSERT( (io_addr & 0x003F) == 0, io_addr ); //if Busy bit in Cmd register if (IPW( HREG_CMD ) & HCMD_BUSY ) { /* 8 */ //. Ack all to unblock a (possibly) blocked cmd pipe line @@ -1237,7 +1237,7 @@ LTV_STRCT x; //. Wait for Busy bit drop in Cmd register //. Wait for Cmd bit raise in Ev register HCF_WAIT_WHILE( ( IPW( HREG_CMD ) & HCMD_BUSY ) && (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); - IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ) /* if prot_cnt == 0, cmd_exe will fail, causing DEFUNCT */ + IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ); /* if prot_cnt == 0, cmd_exe will fail, causing DEFUNCT */ } OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); #if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 /*12*/ @@ -1307,7 +1307,7 @@ get_frame_lst( IFBP ifbp, int tx_rx_flag ) DESC_STRCT *head = ifbp->IFB_FirstDesc[tx_rx_flag]; DESC_STRCT *copy, *p, *prev; - HCFASSERT( tx_rx_flag == DMA_RX || tx_rx_flag == DMA_TX, tx_rx_flag ) + HCFASSERT( tx_rx_flag == DMA_RX || tx_rx_flag == DMA_TX, tx_rx_flag ); //if FrameList if ( head ) { //. search for last descriptor of first FrameList @@ -1407,27 +1407,27 @@ put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ) DESC_STRCT *p = descp; hcf_16 port; - HCFASSERT( ifbp->IFB_CntlOpt & USE_DMA, ifbp->IFB_CntlOpt) //only hcf_dma_tx_put must also be DMA_ENABLED - HCFASSERT( tx_rx_flag == DMA_RX || tx_rx_flag == DMA_TX, tx_rx_flag ) - HCFASSERT( p , 0 ) + HCFASSERT( ifbp->IFB_CntlOpt & USE_DMA, ifbp->IFB_CntlOpt); //only hcf_dma_tx_put must also be DMA_ENABLED + HCFASSERT( tx_rx_flag == DMA_RX || tx_rx_flag == DMA_TX, tx_rx_flag ); + HCFASSERT( p , 0 ); while ( p ) { - HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ) - HCFASSERT( (p->BUF_CNT & ~DESC_CNT_MASK) == 0, p->BUF_CNT ) - HCFASSERT( (p->BUF_SIZE & ~DESC_CNT_MASK) == 0, p->BUF_SIZE ) + HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); + HCFASSERT( (p->BUF_CNT & ~DESC_CNT_MASK) == 0, p->BUF_CNT ); + HCFASSERT( (p->BUF_SIZE & ~DESC_CNT_MASK) == 0, p->BUF_SIZE ); p->BUF_SIZE &= DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF p->BUF_CNT &= tx_rx_flag == DMA_RX ? 0 : DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF p->BUF_CNT |= DESC_DMA_OWNED; if ( p->next_desc_addr ) { -// HCFASSERT( p->buf_addr && p->buf_phys_addr && p->BUF_SIZE && +/- p->BUF_SIZE, ... ) - HCFASSERT( p->next_desc_addr->desc_phys_addr, (hcf_32)p->next_desc_addr ) +// HCFASSERT( p->buf_addr && p->buf_phys_addr && p->BUF_SIZE && +/- p->BUF_SIZE, ... ); + HCFASSERT( p->next_desc_addr->desc_phys_addr, (hcf_32)p->next_desc_addr ); p->next_desc_phys_addr = p->next_desc_addr->desc_phys_addr; } else { // p->next_desc_phys_addr = 0; if ( p->buf_addr == NULL ) { // DELWA Descriptor - HCFASSERT( descp == p, (hcf_32)descp ) //singleton DescriptorList - HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_FirstDesc[tx_rx_flag]) - HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]) + HCFASSERT( descp == p, (hcf_32)descp ); //singleton DescriptorList + HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_FirstDesc[tx_rx_flag]); + HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]); descp->BUF_CNT = 0; //&= ~DESC_DMA_OWNED; ifbp->IFB_FirstDesc[tx_rx_flag] = descp; // part of alternative ifbp->IFB_LastDesc[tx_rx_flag] = ifbp->IFB_FirstDesc[tx_rx_flag] = descp; @@ -1436,10 +1436,10 @@ put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ) // . prepare for activation DMA controller // part of alternative descp = descp->next_desc_addr; } else { //a "real" FrameList, hand it over to the DMA engine - HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag], (hcf_32)descp ) - HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag], (hcf_32)descp ) + HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag], (hcf_32)descp ); + HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag], (hcf_32)descp ); HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr == NULL, - (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr) + (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr); // p->buf_cntl.cntl_stat |= DESC_DMA_OWNED; ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr = descp; ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_phys_addr = descp->desc_phys_addr; @@ -1522,16 +1522,16 @@ DESC_STRCT *descp; // pointer to start of FrameList { int i; DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame - HCFASSERT(p, 0) + HCFASSERT(p, 0); // The 2nd descriptor contains (maybe) a SNAP header plus part or whole of the payload. //determine decapsulation sub-flag in RxFS i = *(wci_recordp)&descp->buf_addr[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); if ( i == HFS_STAT_TUNNEL || ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&p->buf_addr[HCF_DASA_SIZE] ) != ENC_TUNNEL )) { // The 2nd descriptor contains a SNAP header plus part or whole of the payload. - HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ) + HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ); // perform decapsulation - HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE) + HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE); // move SA[2:5] in the second buffer to replace part of the SNAP header for ( i=3; i >= 0; i--) p->buf_addr[i+8] = p->buf_addr[i]; // copy DA[0:5], SA[0:1] from first buffer to second buffer @@ -1542,7 +1542,7 @@ DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame } #endif // HCF_ENC if ( descp == NULL ) ifbp->IFB_DmaPackets &= (hcf_16)~HREG_EV_RDMAD; //;?could be integrated into get_frame_lst - HCFLOGEXIT( HCF_TRACE_DMA_RX_GET ) + HCFLOGEXIT( HCF_TRACE_DMA_RX_GET ); return descp; } // hcf_dma_rx_get @@ -1596,20 +1596,20 @@ void hcf_dma_rx_put( IFBP ifbp, DESC_STRCT *descp ) { - HCFLOGENTRY( HCF_TRACE_DMA_RX_PUT, 0xDA01 ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT + HCFLOGENTRY( HCF_TRACE_DMA_RX_PUT, 0xDA01 ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; put_frame_lst( ifbp, descp, DMA_RX ); #if HCF_ASSERT && (HCF_ENCAP) == HCF_ENC if ( descp->buf_addr ) { - HCFASSERT( descp->BUF_SIZE == HCF_DMA_RX_BUF1_SIZE, descp->BUF_SIZE ) - HCFASSERT( descp->next_desc_addr, 0 ) // first descriptor should be followed by another descriptor + HCFASSERT( descp->BUF_SIZE == HCF_DMA_RX_BUF1_SIZE, descp->BUF_SIZE ); + HCFASSERT( descp->next_desc_addr, 0 ); // first descriptor should be followed by another descriptor // The second DB is for SNAP and payload purposes. It should be a minimum of 12 bytes in size. - HCFASSERT( descp->next_desc_addr->BUF_SIZE >= 12, descp->next_desc_addr->BUF_SIZE ) + HCFASSERT( descp->next_desc_addr->BUF_SIZE >= 12, descp->next_desc_addr->BUF_SIZE ); } #endif // HCFASSERT / HCF_ENC - HCFLOGEXIT( HCF_TRACE_DMA_RX_PUT ) + HCFLOGEXIT( HCF_TRACE_DMA_RX_PUT ); } // hcf_dma_rx_put @@ -1660,7 +1660,7 @@ DESC_STRCT *descp; // pointer to start of FrameList if ( descp == NULL ) { //;?could be integrated into get_frame_lst ifbp->IFB_DmaPackets &= (hcf_16)~HREG_EV_TDMAD; } - HCFLOGEXIT( HCF_TRACE_DMA_TX_GET ) + HCFLOGEXIT( HCF_TRACE_DMA_TX_GET ); return descp; } // hcf_dma_tx_get @@ -1788,19 +1788,19 @@ int i; #if HCF_ASSERT int x = ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ? tx_cntl & ~HFS_TX_CNTL_PORT : tx_cntl; - HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ) + HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ); #endif // HCF_ASSERT - HCFLOGENTRY( HCF_TRACE_DMA_TX_PUT, 0xDA03 ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT - HCFASSERT( ( ifbp->IFB_CntlOpt & (USE_DMA|DMA_ENABLED) ) == (USE_DMA|DMA_ENABLED), ifbp->IFB_CntlOpt) + HCFLOGENTRY( HCF_TRACE_DMA_TX_PUT, 0xDA03 ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; + HCFASSERT( ( ifbp->IFB_CntlOpt & (USE_DMA|DMA_ENABLED) ) == (USE_DMA|DMA_ENABLED), ifbp->IFB_CntlOpt); if ( descp->buf_addr ) { *(hcf_16*)(descp->buf_addr + HFS_TX_CNTL) = tx_cntl; /*1*/ #if (HCF_ENCAP) == HCF_ENC - HCFASSERT( descp->next_desc_addr, 0 ) //at least 2 descripors - HCFASSERT( descp->BUF_CNT == HFS_ADDR_DEST, descp->BUF_CNT ) //exact length required for 1st buffer - HCFASSERT( descp->BUF_SIZE >= HCF_DMA_TX_BUF1_SIZE, descp->BUF_SIZE ) //minimal storage for encapsulation + HCFASSERT( descp->next_desc_addr, 0 ); //at least 2 descripors + HCFASSERT( descp->BUF_CNT == HFS_ADDR_DEST, descp->BUF_CNT ); //exact length required for 1st buffer + HCFASSERT( descp->BUF_SIZE >= HCF_DMA_TX_BUF1_SIZE, descp->BUF_SIZE ); //minimal storage for encapsulation HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); //at least DA, SA and 'type' in 2nd buffer #if (HCF_TYPE) & HCF_TYPE_CCX @@ -1850,7 +1850,7 @@ int i; #endif // HCF_ENC } put_frame_lst( ifbp, descp, DMA_TX ); - HCFLOGEXIT( HCF_TRACE_DMA_TX_PUT ) + HCFLOGEXIT( HCF_TRACE_DMA_TX_PUT ); } // hcf_dma_tx_put #endif // HCF_DMA @@ -2035,11 +2035,11 @@ hcf_16 *q = NULL; /* source word pointer Note!! DOS COM can't cope with FAR */ int i; - HCFLOGENTRY( HCF_TRACE_GET_INFO, ltvp->typ ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT - HCFASSERT( ltvp, 0 ) - HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, MERGE_2( ltvp->typ, ltvp->len ) ) + HCFLOGENTRY( HCF_TRACE_GET_INFO, ltvp->typ ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; + HCFASSERT( ltvp, 0 ); + HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, MERGE_2( ltvp->typ, ltvp->len ) ); ltvp->len = 0; //default to: No Info Available #if defined MSF_COMPONENT_ID || (HCF_EXT) & HCF_EXT_MB //filter out all specials @@ -2096,9 +2096,9 @@ wci_bufp pt; //pointer with the "right" type, just to help ease writing macr } } else if ( type == CFG_CMD_HCF ) { #define P ((CFG_CMD_HCF_STRCT FAR *)ltvp) - HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ) //only Hermes register access supported + HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported if ( P->cmd == CFG_CMD_HCF_REG_ACCESS ) { - HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ) //Check Register space + HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space ltvp->len = min( len, 4 ); //RESTORE ltv length P->add_info = IPW( P->mode ); } @@ -2117,7 +2117,7 @@ wci_bufp pt; //pointer with the "right" type, just to help ease writing macr get_frag( ifbp, (wci_bufp)<vp->len, 2*len+2 BE_PAR(2) ); if ( IPW( HREG_STAT ) == 0xFFFF ) { //NIC removal test ltvp->len = 0; - HCFASSERT( DO_ASSERT, type ) + HCFASSERT( DO_ASSERT, type ); } } /*12*/ } else HCFASSERT( DO_ASSERT, type ) /*NOP*/; //NOP in case HCFASSERT is dummy @@ -2129,8 +2129,8 @@ wci_bufp pt; //pointer with the "right" type, just to help ease writing macr } } HCFASSERT( rc == HCF_SUCCESS || ( rc == HCF_ERR_LEN && ifbp->IFB_AssertTrace & 1<typ ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT - HCFASSERT( ltvp, 0 ) - HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, ltvp->len ) + HCFLOGENTRY( HCF_TRACE_PUT_INFO, ltvp->typ ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; + HCFASSERT( ltvp, 0 ); + HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, ltvp->len ); //all codes between 0xFA00 and 0xFCFF are passed to Hermes #if (HCF_TYPE) & HCF_TYPE_WPA @@ -2256,7 +2256,7 @@ int rc = HCF_SUCCESS; #define P ((CFG_REG_ASSERT_RTNP_STRCT FAR *)ltvp) ifbp->IFB_AssertRtn = P->rtnp; // ifbp->IFB_AssertLvl = P->lvl; //TODO not yet supported so default is set in hcf_connect - HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF1 ) ) //just to proof that the complete assert machinery is working + HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF1 ) ); //just to proof that the complete assert machinery is working #undef P break; #endif // HCF_ASSERT_RT_MSF_RTN @@ -2266,22 +2266,22 @@ int rc = HCF_SUCCESS; break; #endif // HCF_EXT_INFO_LOG case CFG_CNTL_OPT: //overrule option - HCFASSERT( ( ltvp->val[0] & ~(USE_DMA | USE_16BIT) ) == 0, ltvp->val[0] ) + HCFASSERT( ( ltvp->val[0] & ~(USE_DMA | USE_16BIT) ) == 0, ltvp->val[0] ); if ( ( ltvp->val[0] & USE_DMA ) == 0 ) ifbp->IFB_CntlOpt &= ~USE_DMA; ifbp->IFB_CntlOpt |= ltvp->val[0] & USE_16BIT; break; #if (HCF_EXT) & HCF_EXT_MB case CFG_REG_MB: //Register MailBox #define P ((CFG_REG_MB_STRCT FAR *)ltvp) - HCFASSERT( ( (hcf_32)P->mb_addr & 0x0001 ) == 0, (hcf_32)P->mb_addr ) - HCFASSERT( (P)->mb_size >= 60, (P)->mb_size ) + HCFASSERT( ( (hcf_32)P->mb_addr & 0x0001 ) == 0, (hcf_32)P->mb_addr ); + HCFASSERT( (P)->mb_size >= 60, (P)->mb_size ); ifbp->IFB_MBp = P->mb_addr; /* if no MB present, size must be 0 for ;?the old;? put_info_mb to work correctly */ ifbp->IFB_MBSize = ifbp->IFB_MBp == NULL ? 0 : P->mb_size; ifbp->IFB_MBWp = ifbp->IFB_MBRp = 0; ifbp->IFB_MBp[0] = 0; //flag the MailBox as empty ifbp->IFB_MBInfoLen = 0; - HCFASSERT( ifbp->IFB_MBSize >= 60 || ifbp->IFB_MBp == NULL, ifbp->IFB_MBSize ) + HCFASSERT( ifbp->IFB_MBSize >= 60 || ifbp->IFB_MBp == NULL, ifbp->IFB_MBSize ); #undef P break; case CFG_MB_INFO: //store MailBoxInfoBlock @@ -2306,9 +2306,9 @@ int rc = HCF_SUCCESS; break; case CFG_CMD_HCF: #define P ((CFG_CMD_HCF_STRCT FAR *)ltvp) - HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ) //only Hermes register access supported + HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported if ( P->cmd == CFG_CMD_HCF_REG_ACCESS ) { - HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ) //Check Register space + HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space OPW( P->mode, P->add_info); } #undef P @@ -2325,7 +2325,7 @@ int rc = HCF_SUCCESS; rc = put_info( ifbp, ltvp ); } //DO NOT !!! HCFASSERT( rc == HCF_SUCCESS, rc ) /* 20 */ - HCFLOGEXIT( HCF_TRACE_PUT_INFO ) + HCFLOGEXIT( HCF_TRACE_PUT_INFO ); return rc; } // hcf_put_info @@ -2448,21 +2448,21 @@ wci_bufp lap = ifbp->IFB_lap + offset; //start address in LookAhead Buffer hcf_16 lal = ifbp->IFB_lal - offset; //available data within LookAhead Buffer hcf_16 j; - HCFLOGENTRY( HCF_TRACE_RCV_MSG, offset ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT - HCFASSERT( descp, HCF_TRACE_RCV_MSG ) - HCFASSERT( ifbp->IFB_RxLen, HCF_TRACE_RCV_MSG ) - HCFASSERT( ifbp->IFB_RxLen >= offset, MERGE_2( offset, ifbp->IFB_RxLen ) ) - HCFASSERT( ifbp->IFB_lal >= offset, offset ) - HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADA ) + HCFLOGENTRY( HCF_TRACE_RCV_MSG, offset ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; + HCFASSERT( descp, HCF_TRACE_RCV_MSG ); + HCFASSERT( ifbp->IFB_RxLen, HCF_TRACE_RCV_MSG ); + HCFASSERT( ifbp->IFB_RxLen >= offset, MERGE_2( offset, ifbp->IFB_RxLen ) ); + HCFASSERT( ifbp->IFB_lal >= offset, offset ); + HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADA ); if ( tot_len < 0 ) { lal = 0; tot_len = 0; //suppress all copying activity in the do--while loop } do { //loop over all available fragments // obnoxious hcf.c(1480) : warning C4769: conversion of near pointer to long integer - HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ) + HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ); cp = descp->buf_addr; j = min( (hcf_16)tot_len, descp->BUF_SIZE ); //minimum of "what's` available" and fragment size descp->BUF_CNT = j; @@ -2486,8 +2486,8 @@ hcf_16 j; } #endif // HCF_TYPE_WPA (void)hcf_action( ifbp, HCF_ACT_RX_ACK ); //only 1 shot to get the data, so free the resources in the NIC - HCFASSERT( rc == HCF_SUCCESS, rc ) - HCFLOGEXIT( HCF_TRACE_RCV_MSG ) + HCFASSERT( rc == HCF_SUCCESS, rc ); + HCFLOGEXIT( HCF_TRACE_RCV_MSG ); return rc; } // hcf_rcv_msg #endif // HCF_DL_ONLY @@ -2658,18 +2658,18 @@ hcf_16 i; hcf_16 fid = 0; - HCFASSERT( ifbp->IFB_RscInd || descp == NULL, ifbp->IFB_RscInd ) - HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADB ) + HCFASSERT( ifbp->IFB_RscInd || descp == NULL, ifbp->IFB_RscInd ); + HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADB ); - HCFLOGENTRY( HCF_TRACE_SEND_MSG, tx_cntl ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT + HCFLOGENTRY( HCF_TRACE_SEND_MSG, tx_cntl ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; /* obnoxious c:/hcf/hcf.c(1480) : warning C4769: conversion of near pointer to long integer, * so skip */ - HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ) + HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ); #if HCF_ASSERT { int x = ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ? tx_cntl & ~HFS_TX_CNTL_PORT : tx_cntl; - HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ) + HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ); } #endif // HCF_ASSERT @@ -2684,7 +2684,7 @@ hcf_16 fid = 0; //copy all the fragments in a transparent fashion for ( p = descp; p; p = p->next_desc_addr ) { /* obnoxious warning C4769: conversion of near pointer to long integer */ - HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ) + HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); put_frag( ifbp, p->buf_addr, p->BUF_CNT BE_PAR(0) ); } rc = cmd_exe( ifbp, HCMD_THESEUS | HCMD_BUSY | HCMD_STARTPREAMBLE, fid ); @@ -2693,7 +2693,7 @@ hcf_16 fid = 0; } } // een slecht voorbeeld doet goed volgen ;? - HCFLOGEXIT( HCF_TRACE_SEND_MSG ) + HCFLOGEXIT( HCF_TRACE_SEND_MSG ); return rc; } #endif // HCF_EXT_TX_CONT @@ -2716,10 +2716,10 @@ hcf_16 fid = 0; p = descp; do len += p->BUF_CNT; while ( ( p = p->next_desc_addr ) != NULL ); p = descp; -//;? HCFASSERT( len <= HCF_MAX_MSG, len ) +//;? HCFASSERT( len <= HCF_MAX_MSG, len ); /*7*/ (void)setup_bap( ifbp, fid, HFS_TX_CNTL, IO_OUT ); #if (HCF_TYPE) & HCF_TYPE_TX_DELAY - HCFASSERT( ( descp != NULL ) ^ ( tx_cntl & HFS_TX_CNTL_TX_DELAY ), tx_cntl ) + HCFASSERT( ( descp != NULL ) ^ ( tx_cntl & HFS_TX_CNTL_TX_DELAY ), tx_cntl ); if ( tx_cntl & HFS_TX_CNTL_TX_DELAY ) { tx_cntl &= ~HFS_TX_CNTL_TX_DELAY; //!!HFS_TX_CNTL_TX_DELAY no longer available ifbp->IFB_TxFID = fid; @@ -2729,7 +2729,7 @@ hcf_16 fid = 0; OPW( HREG_DATA_1, tx_cntl ) ; OPW( HREG_DATA_1, 0 ); #if ! ( (HCF_TYPE) & HCF_TYPE_CCX ) - HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ) + HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); /* assume DestAddr/SrcAddr/Len/Type ALWAYS contained in 1st fragment * otherwise life gets too cumbersome for MIC and Encapsulation !!!!!!!! if ( p->BUF_CNT >= 14 ) { alternatively: add a safety escape !!!!!!!!!!!! } */ @@ -2780,7 +2780,7 @@ hcf_16 fid = 0; while ( ( p = p->next_desc_addr ) != NULL ) { /* obnoxious c:/hcf/hcf.c(1480) : warning C4769: conversion of near pointer to long integer, * so skip */ - HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ) + HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); put_frag( ifbp, p->buf_addr, p->BUF_CNT BE_PAR(0) ); CALC_TX_MIC( p->buf_addr, p->BUF_CNT ); } @@ -2800,8 +2800,8 @@ hcf_16 fid = 0; } // #endif // ALLOC_15 } -// HCFASSERT( level::ifbp->IFB_RscInd, ifbp->IFB_RscInd ) - HCFLOGEXIT( HCF_TRACE_SEND_MSG ) +// HCFASSERT( level::ifbp->IFB_RscInd, ifbp->IFB_RscInd ); + HCFLOGEXIT( HCF_TRACE_SEND_MSG ); return rc; } // hcf_send_msg #endif // HCF_DL_ONLY @@ -3068,9 +3068,9 @@ hcf_16 stat; wci_bufp buf_addr; hcf_16 i; - HCFLOGENTRY( HCF_TRACE_SERVICE_NIC, ifbp->IFB_IntOffCnt ) - HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ) - HCFASSERT_INT + HCFLOGENTRY( HCF_TRACE_SERVICE_NIC, ifbp->IFB_IntOffCnt ); + HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); + HCFASSERT_INT; ifbp->IFB_LinkStat = 0; // ;? to be obsoleted ASAP /* 1*/ ifbp->IFB_DSLinkStat &= ~CFG_LINK_STAT_CHANGE; /* 1*/ @@ -3084,7 +3084,7 @@ hcf_16 i; if ( ifbp->IFB_RscInd == 0 && stat & HREG_EV_ALLOC ) { //Note: IFB_RscInd is ALWAYS 1 for DMA ifbp->IFB_RscInd = 1; } - IF_TALLY( if ( stat & HREG_EV_INFO_DROP ) ifbp->IFB_HCF_Tallies.NoBufInfo++; ) + IF_TALLY( if ( stat & HREG_EV_INFO_DROP ) { ifbp->IFB_HCF_Tallies.NoBufInfo++; } ); #if (HCF_EXT) & HCF_EXT_INT_TICK if ( stat & HREG_EV_TICK ) { ifbp->IFB_TickCnt++; @@ -3112,7 +3112,7 @@ CFG_DDS_TICK_TIME_STRCT ltv; } #if (HCF_EXT) & HCF_EXT_INT_TX_EX if ( stat & HREG_EV_TX_EXT && ( i = IPW( HREG_TX_COMPL_FID ) ) != 0 /*DAWA*/ ) { - DAWA_ZERO_FID( HREG_TX_COMPL_FID ) + DAWA_ZERO_FID( HREG_TX_COMPL_FID ); (void)setup_bap( ifbp, i, 0, IO_IN ); get_frag( ifbp, &ifbp->IFB_TxFsStat, HFS_SWSUP BE_PAR(1) ); } @@ -3122,10 +3122,10 @@ CFG_DDS_TICK_TIME_STRCT ltv; if ( !( ifbp->IFB_CntlOpt & USE_DMA ) ) //!! be aware of the logical indentations #endif // HCF_DMA /*16*/ if ( stat & HREG_EV_RX && ( ifbp->IFB_RxFID = IPW( HREG_RX_FID ) ) != 0 ) { //if 0 then DAWA_ACK - HCFASSERT( bufp, len ) - HCFASSERT( len >= HFS_DAT + 2, len ) - DAWA_ZERO_FID( HREG_RX_FID ) - HCFASSERT( ifbp->IFB_RxFID < CFG_PROD_DATA, ifbp->IFB_RxFID) + HCFASSERT( bufp, len ); + HCFASSERT( len >= HFS_DAT + 2, len ); + DAWA_ZERO_FID( HREG_RX_FID ); + HCFASSERT( ifbp->IFB_RxFID < CFG_PROD_DATA, ifbp->IFB_RxFID); (void)setup_bap( ifbp, ifbp->IFB_RxFID, 0, IO_IN ); get_frag( ifbp, bufp, HFS_ADDR_DEST BE_PAR(1) ); ifbp->IFB_lap = buf_addr = bufp + HFS_ADDR_DEST; @@ -3144,7 +3144,7 @@ CFG_DDS_TICK_TIME_STRCT ltv; #endif // HCF_TYPE_CCX { #if (HCF_ENCAP) == HCF_ENC - HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ) + HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ); /*34*/ i = *(wci_recordp)&bufp[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); if ( i == HFS_STAT_TUNNEL || ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&bufp[HFS_TYPE] ) != ENC_TUNNEL ) ) { @@ -3174,16 +3174,16 @@ CFG_DDS_TICK_TIME_STRCT ltv; } } // in case of DMA: signal availability of rx and/or tx packets to MSF - IF_USE_DMA( ifbp->IFB_DmaPackets |= stat & ( HREG_EV_RDMAD | HREG_EV_TDMAD ); ) + IF_USE_DMA( ifbp->IFB_DmaPackets |= stat & ( HREG_EV_RDMAD | HREG_EV_TDMAD ) ); // rlav : pending HREG_EV_RDMAD or HREG_EV_TDMAD events get acknowledged here. /*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); //a positive mask would be easier to understand /*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); - IF_USE_DMA( stat &= (hcf_16)~HREG_EV_RX; ) + IF_USE_DMA( stat &= (hcf_16)~HREG_EV_RX ); if ( stat ) { DAWA_ACK( stat ); /*DAWA*/ } } - HCFLOGEXIT( HCF_TRACE_SERVICE_NIC ) + HCFLOGEXIT( HCF_TRACE_SERVICE_NIC ); return rc; } // hcf_service_nic #endif // HCF_DL_ONLY @@ -3507,7 +3507,7 @@ hcf_32 prot_cnt; ifbp->IFB_TickIni = INI_TICK_INI; ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_TIMER; ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; - HCFASSERT( DO_ASSERT, prot_cnt ) + HCFASSERT( DO_ASSERT, prot_cnt ); } } ifbp->IFB_TickIni <<= HCF_PROT_TIME_SHFT; /*8*/ @@ -3617,19 +3617,19 @@ HCF_STATIC int cmd_cmpl( IFBP ifbp ) { -PROT_CNT_INI +PROT_CNT_INI; int rc = HCF_SUCCESS; hcf_16 stat; - HCFLOGENTRY( HCF_TRACE_CMD_CPL, ifbp->IFB_Cmd ) + HCFLOGENTRY( HCF_TRACE_CMD_CPL, ifbp->IFB_Cmd ); ifbp->IFB_Cmd &= ~HCMD_BUSY; /* 2 */ HCF_WAIT_WHILE( (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); /* 4 */ stat = IPW( HREG_STAT ); #if HCF_PROT_TIME if ( prot_cnt == 0 ) { - IF_TALLY( ifbp->IFB_HCF_Tallies.MiscErr++; ) + IF_TALLY( ifbp->IFB_HCF_Tallies.MiscErr++ ); rc = HCF_ERR_TIME_OUT; - HCFASSERT( DO_ASSERT, ifbp->IFB_Cmd ) + HCFASSERT( DO_ASSERT, ifbp->IFB_Cmd ); } else #endif // HCF_PROT_TIME { @@ -3639,15 +3639,15 @@ hcf_16 stat; rc = ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_CMD_SEQ; ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; } - IF_TALLY( ifbp->IFB_HCF_Tallies.MiscErr++; ) + IF_TALLY( ifbp->IFB_HCF_Tallies.MiscErr++ ); ifbp->IFB_ErrCmd = stat; ifbp->IFB_ErrQualifier = IPW( HREG_RESP_0 ); - HCFASSERT( DO_ASSERT, MERGE_2( IPW( HREG_PARAM_0 ), ifbp->IFB_Cmd ) ) - HCFASSERT( DO_ASSERT, MERGE_2( ifbp->IFB_ErrQualifier, ifbp->IFB_ErrCmd ) ) + HCFASSERT( DO_ASSERT, MERGE_2( IPW( HREG_PARAM_0 ), ifbp->IFB_Cmd ) ); + HCFASSERT( DO_ASSERT, MERGE_2( ifbp->IFB_ErrQualifier, ifbp->IFB_ErrCmd ) ); } } - HCFASSERT( rc == HCF_SUCCESS, rc) - HCFLOGEXIT( HCF_TRACE_CMD_CPL ) + HCFASSERT( rc == HCF_SUCCESS, rc); + HCFLOGEXIT( HCF_TRACE_CMD_CPL ); return rc; } // cmd_cmpl @@ -3706,8 +3706,8 @@ cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ) //if HCMD_BUSY of cmd_code s { int rc; - HCFLOGENTRY( HCF_TRACE_CMD_EXE, cmd_code ) - HCFASSERT( (cmd_code & HCMD_CMD_CODE) != HCMD_TX || cmd_code & HCMD_BUSY, cmd_code ) //Tx must have Busy bit set + HCFLOGENTRY( HCF_TRACE_CMD_EXE, cmd_code ); + HCFASSERT( (cmd_code & HCMD_CMD_CODE) != HCMD_TX || cmd_code & HCMD_BUSY, cmd_code ); //Tx must have Busy bit set OPW( HREG_SW_0, HCF_MAGIC ); if ( IPW( HREG_SW_0 ) == HCF_MAGIC ) { /* 1 */ rc = ifbp->IFB_DefunctStat; @@ -3725,8 +3725,8 @@ int rc; rc = cmd_cmpl( ifbp ); } } - HCFASSERT( rc == HCF_SUCCESS, MERGE_2( rc, cmd_code ) ) - HCFLOGEXIT( HCF_TRACE_CMD_EXE ) + HCFASSERT( rc == HCF_SUCCESS, MERGE_2( rc, cmd_code ) ); + HCFLOGEXIT( HCF_TRACE_CMD_EXE ); return rc; } // cmd_exe @@ -3764,9 +3764,9 @@ int rc = HCF_SUCCESS; wci_bufp cp; hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; - HCFLOGENTRY( HCF_TRACE_DL, ltvp->typ ) + HCFLOGENTRY( HCF_TRACE_DL, ltvp->typ ); #if (HCF_TYPE) & HCF_TYPE_PRELOADED - HCFASSERT( DO_ASSERT, ltvp->mode ) + HCFASSERT( DO_ASSERT, ltvp->mode ); #else //if initial "program" LTV if ( ifbp->IFB_DLMode == CFG_PROG_STOP && ltvp->mode == CFG_PROG_VOLATILE) { @@ -3818,7 +3818,7 @@ hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; } else #endif //;? as long as the above if contains a hard coded 0, might as well leave it out even more obvious { //. . get number of words to program - HCFASSERT( ltvp->segment_size, *ltvp->host_addr ) + HCFASSERT( ltvp->segment_size, *ltvp->host_addr ); i = ltvp->segment_size/2; //. . copy data (words) from LTV via AUX port to NIC cp = (wci_bufp)ltvp->host_addr; //OUT_PORT_STRING_8_16 macro may modify its parameters @@ -3833,8 +3833,8 @@ hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; } ifbp->IFB_DLMode = ltvp->mode; //save state in IFB_DLMode #endif // HCF_TYPE_PRELOADED - HCFASSERT( rc == HCF_SUCCESS, rc ) - HCFLOGEXIT( HCF_TRACE_DL ) + HCFASSERT( rc == HCF_SUCCESS, rc ); + HCFLOGEXIT( HCF_TRACE_DL ); return rc; } // download @@ -3916,18 +3916,18 @@ get_fid( IFBP ifbp ) hcf_16 fid = 0; #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 -PROT_CNT_INI +PROT_CNT_INI; #endif // HCF_TYPE_HII5 - IF_DMA( HCFASSERT(!(ifbp->IFB_CntlOpt & USE_DMA), ifbp->IFB_CntlOpt) ) + IF_DMA( HCFASSERT(!(ifbp->IFB_CntlOpt & USE_DMA), ifbp->IFB_CntlOpt) ); if ( IPW( HREG_EV_STAT) & HREG_EV_ALLOC) { fid = IPW( HREG_ALLOC_FID ); - HCFASSERT( fid, ifbp->IFB_RscInd ) - DAWA_ZERO_FID( HREG_ALLOC_FID ) + HCFASSERT( fid, ifbp->IFB_RscInd ); + DAWA_ZERO_FID( HREG_ALLOC_FID ); #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 HCF_WAIT_WHILE( ( IPW( HREG_EV_STAT ) & HREG_EV_ACK_REG_READY ) == 0 ); - HCFASSERT( prot_cnt, IPW( HREG_EV_STAT ) ) + HCFASSERT( prot_cnt, IPW( HREG_EV_STAT ) ); #endif // HCF_TYPE_HII5 DAWA_ACK( HREG_EV_ALLOC ); //!!note that HREG_EV_ALLOC is written only once // 180 degree error in logic ;? #if ALLOC_15 @@ -3989,7 +3989,7 @@ wci_bufp p = bufp; //working pointer int i; //prevent side effects from macro int j; - HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ) + HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ); /*1: here recovery logic for intervening BAP access between hcf_service_nic and hcf_rcv_msg COULD be added * if current access is RxInitial @@ -4045,9 +4045,9 @@ hcf_32 FAR *p4; //prevent side effects from macro } } #if HCF_BIG_ENDIAN - HCFASSERT( word_len == 0 || word_len == 2 || word_len == 4, word_len ) - HCFASSERT( word_len == 0 || ((hcf_32)bufp & 1 ) == 0, (hcf_32)bufp ) - HCFASSERT( word_len <= len, MERGE2( word_len, len ) ) + HCFASSERT( word_len == 0 || word_len == 2 || word_len == 4, word_len ); + HCFASSERT( word_len == 0 || ((hcf_32)bufp & 1 ) == 0, (hcf_32)bufp ); + HCFASSERT( word_len <= len, MERGE2( word_len, len ) ); //see put_frag for an alternative implementation, but be careful about what are int's and what are //hcf_16's if ( word_len ) { //. if there is anything to convert @@ -4158,11 +4158,11 @@ init( IFBP ifbp ) int rc = HCF_SUCCESS; - HCFLOGENTRY( HCF_TRACE_INIT, 0 ) + HCFLOGENTRY( HCF_TRACE_INIT, 0 ); ifbp->IFB_CardStat = 0; /* 2*/ OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); /* 4*/ - IF_PROT_TIME( calibrate( ifbp ); ) /*10*/ + IF_PROT_TIME( calibrate( ifbp ) ); /*10*/ #if 0 // OOR ifbp->IFB_FWIdentity.len = 2; //misuse the IFB space for a put ifbp->IFB_FWIdentity.typ = CFG_TICK_TIME; @@ -4234,7 +4234,7 @@ int i = sizeof( CFG_FW_IDENTITY_STRCT) + sizeof(CFG_SUP_RANGE_STRCT ); #endif // MSF_COMPONENT_ID #if (HCF_DL_ONLY) == 0 /* 28 */ if ( rc == HCF_SUCCESS && ifbp->IFB_FWIdentity.comp_id >= COMP_ID_FW_STA ) { -PROT_CNT_INI +PROT_CNT_INI; /************************************************************************************** * rlav: the DMA engine needs the host to cause a 'hanging alloc event' for it to consume. * not sure if this is the right spot in the HCF, thinking about hcf_enable... @@ -4245,22 +4245,22 @@ PROT_CNT_INI //#else if ( rc == HCF_SUCCESS ) { HCF_WAIT_WHILE( (IPW( HREG_EV_STAT ) & HREG_EV_ALLOC) == 0 ); - IF_PROT_TIME( HCFASSERT(prot_cnt, IPW( HREG_EV_STAT ) ) /*NOP*/;) + IF_PROT_TIME( HCFASSERT(prot_cnt, IPW( HREG_EV_STAT )) ); #if HCF_DMA if ( ! ( ifbp->IFB_CntlOpt & USE_DMA ) ) #endif // HCF_DMA { ifbp->IFB_RscInd = get_fid( ifbp ); - HCFASSERT( ifbp->IFB_RscInd, 0 ) + HCFASSERT( ifbp->IFB_RscInd, 0 ); cmd_exe( ifbp, HCMD_ALLOC, 0 ); - IF_PROT_TIME( if ( prot_cnt == 0 ) rc = HCF_ERR_TIME_OUT; ) + IF_PROT_TIME( if ( prot_cnt == 0 ) rc = HCF_ERR_TIME_OUT ); } } //#endif // ALLOC_15 } #endif // HCF_DL_ONLY - HCFASSERT( rc == HCF_SUCCESS, rc ) - HCFLOGEXIT( HCF_TRACE_INIT ) + HCFASSERT( rc == HCF_SUCCESS, rc ); + HCFLOGEXIT( HCF_TRACE_INIT ); return rc; } // init @@ -4307,11 +4307,11 @@ RID_LOGP ridp = ifbp->IFB_RIDLogp; //NULL or pointer to array of RID_LOG structu HCFTRACE( ifbp, HCF_TRACE_ISR_INFO ); /* 1 */ fid = IPW( HREG_INFO_FID ); - DAWA_ZERO_FID( HREG_INFO_FID ) + DAWA_ZERO_FID( HREG_INFO_FID ); if ( fid ) { (void)setup_bap( ifbp, fid, 0, IO_IN ); get_frag( ifbp, (wci_bufp)info, 4 BE_PAR(2) ); - HCFASSERT( info[0] <= HCF_MAX_LTV + 1, MERGE_2( info[1], info[0] ) ) //;? a smaller value makes more sense + HCFASSERT( info[0] <= HCF_MAX_LTV + 1, MERGE_2( info[1], info[0] ) ); //;? a smaller value makes more sense #if (HCF_TALLIES) & HCF_TALLIES_NIC //Hermes tally support if ( info[1] == CFG_TALLIES ) { hcf_32 *p; @@ -4331,7 +4331,7 @@ hcf_32 *p; /*6*/ while ( 1 ) { if ( ridp->typ == 0 || ridp->typ == info[1] ) { if ( ridp->bufp ) { - HCFASSERT( ridp->len >= 2, ridp->typ ) + HCFASSERT( ridp->len >= 2, ridp->typ ); ridp->bufp[0] = min((hcf_16)(ridp->len - 1), info[0] ); //save L ridp->bufp[1] = info[1]; //save T get_frag( ifbp, (wci_bufp)&ridp->bufp[2], (ridp->bufp[0] - 1)*2 BE_PAR(0) ); @@ -4366,7 +4366,7 @@ hcf_32 *p; // /*6*/ while ( 1 ) { // if ( ridp->typ == 0 || ridp->typ == info[1] ) { // if ( ridp->bufp ) { -// HCFASSERT( ridp->len >= 2, ridp->typ ) +// HCFASSERT( ridp->len >= 2, ridp->typ ); // (void)setup_bap( ifbp, fid, 2, IO_IN ); //restore BAP for tallies, linkstat and specific type followed by wild card // ridp->bufp[0] = min( ridp->len - 1, info[0] ); //save L // get_frag( ifbp, (wci_bufp)&ridp->bufp[1], ridp->bufp[0]*2 BE_PAR(0) ); @@ -4483,11 +4483,11 @@ put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) hcf_io io_port = ifbp->IFB_IOBase + HREG_DATA_1; //BAP data register int i; //prevent side effects from macro hcf_16 j; - HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ) + HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ); #if HCF_BIG_ENDIAN - HCFASSERT( word_len == 0 || word_len == 2 || word_len == 4, word_len ) - HCFASSERT( word_len == 0 || ((hcf_32)bufp & 1 ) == 0, (hcf_32)bufp ) - HCFASSERT( word_len <= len, MERGE_2( word_len, len ) ) + HCFASSERT( word_len == 0 || word_len == 2 || word_len == 4, word_len ); + HCFASSERT( word_len == 0 || ((hcf_32)bufp & 1 ) == 0, (hcf_32)bufp ); + HCFASSERT( word_len <= len, MERGE_2( word_len, len ) ); if ( word_len ) { //if there is anything to convert //. convert and write the 1st hcf_16 @@ -4635,8 +4635,8 @@ put_info( IFBP ifbp, LTVP ltvp ) int rc = HCF_SUCCESS; - HCFASSERT( ifbp->IFB_CardStat == 0, MERGE_2( ltvp->typ, ifbp->IFB_CardStat ) ) - HCFASSERT( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX, ltvp->typ ) + HCFASSERT( ifbp->IFB_CardStat == 0, MERGE_2( ltvp->typ, ifbp->IFB_CardStat ) ); + HCFASSERT( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX, ltvp->typ ); if ( ifbp->IFB_CardStat == 0 && /* 20*/ ( ( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX ) || @@ -4654,7 +4654,7 @@ int rc = HCF_SUCCESS; t != CFG_DEAUTHENTICATE_ADDR ) ) { - HCFASSERT( DO_ASSERT, ltvp->typ ) + HCFASSERT( DO_ASSERT, ltvp->typ ); } } #endif // HCF_ASSERT @@ -4738,8 +4738,8 @@ hcf_16 len; //total length to copy to MailBox hcf_16 tlen; //free length/working length/offset in WMP frame if ( ifbp->IFB_MBp == NULL ) return rc; //;?not sufficient - HCFASSERT( ifbp->IFB_MBp != NULL, 0 ) //!!!be careful, don't get into an endless recursion - HCFASSERT( ifbp->IFB_MBSize, 0 ) + HCFASSERT( ifbp->IFB_MBp != NULL, 0 ); //!!!be careful, don't get into an endless recursion + HCFASSERT( ifbp->IFB_MBSize, 0 ); len = 1; /* 1 */ for ( i = 0; i < ltvp->frag_cnt; i++ ) { @@ -4765,7 +4765,7 @@ hcf_16 tlen; //free length/working length/offset in WMP frame } if ( len + 2 >= tlen ){ /* 6 */ //Do Not ASSERT, this is a normal condition - IF_TALLY( ifbp->IFB_HCF_Tallies.NoBufMB++; ) /*NOP to cover against analomies with empty compound*/; + IF_TALLY( ifbp->IFB_HCF_Tallies.NoBufMB++ ); rc = HCF_ERR_LEN; } else { *dp++ = len; //write Len (= size of T+V in words to MB_Info block @@ -4861,7 +4861,7 @@ hcf_16 tlen; //free length/working length/offset in WMP frame HCF_STATIC int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ) { -PROT_CNT_INI +PROT_CNT_INI; int rc; HCFTRACE( ifbp, HCF_TRACE_STRIO ); @@ -4874,9 +4874,9 @@ int rc; } else ifbp->IFB_CarryOut = 0; HCF_WAIT_WHILE( IPW( HREG_OFFSET_1) & HCMD_BUSY ); - HCFASSERT( !( IPW( HREG_OFFSET_1) & HREG_OFFSET_ERR ), MERGE_2( fid, offset ) ) /*8*/ + HCFASSERT( !( IPW( HREG_OFFSET_1) & HREG_OFFSET_ERR ), MERGE_2( fid, offset ) ); /*8*/ if ( prot_cnt == 0 ) { - HCFASSERT( DO_ASSERT, MERGE_2( fid, offset ) ) + HCFASSERT( DO_ASSERT, MERGE_2( fid, offset ) ); rc = ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_TIME_OUT; ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; } diff --git a/drivers/staging/wlags49_h2/hcfdef.h b/drivers/staging/wlags49_h2/hcfdef.h index 0261c7358c1..8e08d7b16b9 100644 --- a/drivers/staging/wlags49_h2/hcfdef.h +++ b/drivers/staging/wlags49_h2/hcfdef.h @@ -557,17 +557,13 @@ err: ; /************************************************************************************************/ #ifdef HCF_SLEEP -#if defined MSF_WAIT -err: MSF should no longer supply this macro; +#define MSF_WAIT(x) do { \ + PROT_CNT_INI; \ + HCF_WAIT_WHILE((IPW(HREG_IO) & HREG_IO_WOKEN_UP) == 0); \ + HCFASSERT( prot_cnt, IPW( HREG_IO ) ); \ + } while (0) #else -#define MSF_WAIT(x) \ - { PROT_CNT_INI \ - HCF_WAIT_WHILE( ( IPW( HREG_IO ) & HREG_IO_WOKEN_UP ) == 0 ); \ - HCFASSERT( prot_cnt, IPW( HREG_IO ) ) \ - } -#endif // MSF_WAIT -#else -#define MSF_WAIT(x) /*NOP*/ +#define MSF_WAIT(x) do { } while (0) #endif // HCF_SLEEP #define LOF(x) (sizeof(x)/sizeof(hcf_16)-1) @@ -583,13 +579,14 @@ err: MSF should no longer supply this macro; #endif // HCF_STATIC #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 -#define DAWA_ACK( mask) { \ +#define DAWA_ACK( mask) do { \ OPW( HREG_EV_ACK, mask | HREG_EV_ACK_REG_READY ); \ - OPW( HREG_EV_ACK, (mask & ~HREG_EV_ALLOC) | HREG_EV_ACK_REG_READY ); } -#define DAWA_ZERO_FID(reg) OPW( reg, 0 ); + OPW( HREG_EV_ACK, (mask & ~HREG_EV_ALLOC) | HREG_EV_ACK_REG_READY ); \ + } while (0) +#define DAWA_ZERO_FID(reg) OPW( reg, 0 ) #else -#define DAWA_ACK( mask) OPW( HREG_EV_ACK, mask ); -#define DAWA_ZERO_FID(reg) +#define DAWA_ACK( mask) OPW( HREG_EV_ACK, mask ) +#define DAWA_ZERO_FID(reg) do { } while (0) #endif // HCF_TYPE_HII5 #if (HCF_TYPE) & HCF_TYPE_WPA @@ -607,22 +604,22 @@ err: MSF should no longer supply this macro; #endif // HCF_TYPE_WPA #if HCF_TALLIES & HCF_TALLIES_HCF //HCF tally support -#define IF_TALLY(x) x +#define IF_TALLY(x) do { x; } while (0) #else -#define IF_TALLY(x) +#define IF_TALLY(x) do { } while (0) #endif // HCF_TALLIES_HCF #if HCF_DMA -#define IF_DMA(x) x -#define IF_NOT_DMA(x) -#define IF_USE_DMA(x) if ( ifbp->IFB_CntlOpt & USE_DMA ) x -#define IF_NOT_USE_DMA(x) if ( !(ifbp->IFB_CntlOpt & USE_DMA) ) x +#define IF_DMA(x) do { x; } while(0) +#define IF_NOT_DMA(x) do { } while(0) +#define IF_USE_DMA(x) if ( ifbp->IFB_CntlOpt & USE_DMA ) { x; } +#define IF_NOT_USE_DMA(x) if ( !(ifbp->IFB_CntlOpt & USE_DMA) ) { x; } #else -#define IF_DMA(x) -#define IF_NOT_DMA(x) x -#define IF_USE_DMA(x) -#define IF_NOT_USE_DMA(x) x +#define IF_DMA(x) do { } while(0) +#define IF_NOT_DMA(x) do { x; } while(0) +#define IF_USE_DMA(x) do { } while(0) +#define IF_NOT_USE_DMA(x) do { x; } while(0) #endif // HCF_DMA @@ -632,16 +629,16 @@ err: MSF should no longer supply this macro; * in a row and that when one fails all subsequent fail immediately without reinitialization of prot_cnt */ #if HCF_PROT_TIME == 0 -#define PROT_CNT_INI -#define IF_PROT_TIME(x) +#define PROT_CNT_INI do { } while(0) +#define IF_PROT_TIME(x) do { } while(0) #if defined HCF_YIELD -#define HCF_WAIT_WHILE( x ) while ( (x) && (HCF_YIELD) ) /*NOP*/; +#define HCF_WAIT_WHILE( x ) do { } while( (x) && (HCF_YIELD) ) #else -#define HCF_WAIT_WHILE( x ) while ( x ) /*NOP*/; +#define HCF_WAIT_WHILE( x ) do { } while ( x ) #endif // HCF_YIELD #else -#define PROT_CNT_INI hcf_32 prot_cnt = ifbp->IFB_TickIni; -#define IF_PROT_TIME(x) x +#define PROT_CNT_INI hcf_32 prot_cnt = ifbp->IFB_TickIni +#define IF_PROT_TIME(x) do { x; } while(0) #if defined HCF_YIELD #define HCF_WAIT_WHILE( x ) while ( prot_cnt && (x) && (HCF_YIELD) ) prot_cnt--; #else @@ -684,32 +681,32 @@ err: someone redefined these macros while the implemenation assumes they are equ * on the if-statement */ #if HCF_ASSERT -#define HCFASSERT(x,q) {if (!(x)) {mdd_assert( ifbp, __LINE__ , q );}} +#define HCFASSERT(x,q) do { if (!(x)) {mdd_assert(ifbp, __LINE__, q );} } while(0) #define MMDASSERT(x,q) {if (!(x)) {mdd_assert( assert_ifbp, __LINE__ + FILE_NAME_OFFSET, q );}} -#define HCFLOGENTRY( where, what ) \ - {if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ +#define HCFLOGENTRY( where, what ) do { \ + if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ HCF_ENTRY( ifbp ); \ HCFASSERT( (ifbp->IFB_AssertTrace & 1<<((where)&0xF)) == 0, ifbp->IFB_AssertTrace ); \ ifbp->IFB_AssertTrace |= 1<<((where)&0xF); \ } \ - HCFTRACE(ifbp, where ) \ - HCFTRACEVALUE(ifbp, what ) \ - } + HCFTRACE(ifbp, where ); \ + HCFTRACEVALUE(ifbp, what ); \ + } while (0) -#define HCFLOGEXIT( where ) \ - {if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ +#define HCFLOGEXIT( where ) do { \ + if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ HCF_EXIT( ifbp ); \ ifbp->IFB_AssertTrace &= ~(1<<((where)&0xF)); \ } \ - HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ) \ - } + HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ); \ + } while (0) #else // HCF_ASSERT -#define HCFASSERT( x, q ) +#define HCFASSERT( x, q ) do { } while(0) #define MMDASSERT( x, q ) -#define HCFLOGENTRY( where, what ) {HCF_ENTRY( ifbp );} -#define HCFLOGEXIT( where ) {HCF_EXIT( ifbp );} +#define HCFLOGENTRY( where, what ) do {HCF_ENTRY( ifbp );} while (0) +#define HCFLOGEXIT( where ) do {HCF_EXIT( ifbp );} while(0) #endif // HCF_ASSERT #if HCF_INT_ON @@ -727,13 +724,13 @@ err: someone redefined these macros while the implemenation assumes they are equ #if defined HCF_TRACE -#define HCFTRACE(ifbp, where ) {OPW( HREG_SW_1, where );} +#define HCFTRACE(ifbp, where ) do {OPW( HREG_SW_1, where );} while(0) //#define HCFTRACE(ifbp, where ) {HCFASSERT( DO_ASSERT, where );} -#define HCFTRACEVALUE(ifbp, what ) {OPW( HREG_SW_2, what );} +#define HCFTRACEVALUE(ifbp, what ) do {OPW( HREG_SW_2, what );} while (0) //#define HCFTRACEVALUE(ifbp, what ) {HCFASSERT( DO_ASSERT, what );} #else -#define HCFTRACE(ifbp, where ) -#define HCFTRACEVALUE(ifbp, what ) +#define HCFTRACE(ifbp, where ) do { } while(0) +#define HCFTRACEVALUE(ifbp, what ) do { } while(0) #endif // HCF_TRACE From 543fd0a349dbb2f6ab896ec97cedbbd6fe4d1ee6 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:48 +0100 Subject: [PATCH 1024/1519] staging: wlags49_h2: Reindent hcf.c Untabify with tab-width set to 4 (to match VI header). Then reindent with tab-width reset to 8. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 6064 +++++++++++++++--------------- 1 file changed, 3032 insertions(+), 3032 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 85950d74f8f..304258e2025 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -1,97 +1,96 @@ -// vim:tw=110:ts=4: /************************************************************************************************************ -* -* FILE : HCF.C -* -* DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.10 $ -* Original: 2004/06/02 10:22:22 Revision: 1.85 Tag: hcf7_t20040602_01 -* Original: 2004/04/15 09:24:41 Revision: 1.63 Tag: hcf7_t7_20040415_01 -* Original: 2004/04/13 14:22:44 Revision: 1.62 Tag: t7_20040413_01 -* Original: 2004/04/01 15:32:55 Revision: 1.59 Tag: t7_20040401_01 -* Original: 2004/03/10 15:39:27 Revision: 1.55 Tag: t20040310_01 -* Original: 2004/03/04 11:03:37 Revision: 1.53 Tag: t20040304_01 -* Original: 2004/03/02 14:51:21 Revision: 1.50 Tag: t20040302_03 -* Original: 2004/02/24 13:00:27 Revision: 1.43 Tag: t20040224_01 -* Original: 2004/02/19 10:57:25 Revision: 1.39 Tag: t20040219_01 -* -* AUTHOR : Nico Valster -* -* SPECIFICATION: ........ -* -* DESCRIPTION : HCF Routines for Hermes-II (callable via the Wireless Connection I/F or WCI) -* Local Support Routines for above procedures -* -* Customizable via HCFCFG.H, which is included by HCF.H -* -************************************************************************************************************* -* -* -* SOFTWARE LICENSE -* -* This software is provided subject to the following terms and conditions, -* which you should read carefully before using the software. Using this -* software indicates your acceptance of these terms and conditions. If you do -* not agree with these terms and conditions, do not use the software. -* -* COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved -* COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved -* COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved -* All rights reserved. -* -* Redistribution and use in source or binary forms, with or without -* modifications, are permitted provided that the following conditions are met: -* -* . Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following Disclaimer as comments in the code as -* well as in the documentation and/or other materials provided with the -* distribution. -* -* . Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following Disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* . Neither the name of Agere Systems Inc. nor the names of the contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* Disclaimer -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY -* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN -* RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -* -* -************************************************************************************************************/ + * + * FILE : HCF.C + * + * DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.10 $ + * Original: 2004/06/02 10:22:22 Revision: 1.85 Tag: hcf7_t20040602_01 + * Original: 2004/04/15 09:24:41 Revision: 1.63 Tag: hcf7_t7_20040415_01 + * Original: 2004/04/13 14:22:44 Revision: 1.62 Tag: t7_20040413_01 + * Original: 2004/04/01 15:32:55 Revision: 1.59 Tag: t7_20040401_01 + * Original: 2004/03/10 15:39:27 Revision: 1.55 Tag: t20040310_01 + * Original: 2004/03/04 11:03:37 Revision: 1.53 Tag: t20040304_01 + * Original: 2004/03/02 14:51:21 Revision: 1.50 Tag: t20040302_03 + * Original: 2004/02/24 13:00:27 Revision: 1.43 Tag: t20040224_01 + * Original: 2004/02/19 10:57:25 Revision: 1.39 Tag: t20040219_01 + * + * AUTHOR : Nico Valster + * + * SPECIFICATION: ........ + * + * DESCRIPTION : HCF Routines for Hermes-II (callable via the Wireless Connection I/F or WCI) + * Local Support Routines for above procedures + * + * Customizable via HCFCFG.H, which is included by HCF.H + * + ************************************************************************************************************* + * + * + * SOFTWARE LICENSE + * + * This software is provided subject to the following terms and conditions, + * which you should read carefully before using the software. Using this + * software indicates your acceptance of these terms and conditions. If you do + * not agree with these terms and conditions, do not use the software. + * + * COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved + * COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved + * COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved + * All rights reserved. + * + * Redistribution and use in source or binary forms, with or without + * modifications, are permitted provided that the following conditions are met: + * + * . Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following Disclaimer as comments in the code as + * well as in the documentation and/or other materials provided with the + * distribution. + * + * . Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following Disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * . Neither the name of Agere Systems Inc. nor the names of the contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Disclaimer + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY + * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN + * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + ************************************************************************************************************/ /************************************************************************************************************ -** -** Implementation Notes -** -* - a leading marker of //! is used. The purpose of such a sequence is to help to understand the flow -* An example is: //!rc = HCF_SUCCESS; -* if this is superfluous because rc is already guaranteed to be 0 but it shows to the (maintenance) -* programmer it is an intentional omission at the place where someone could consider it most appropriate at -* first glance -* - using near pointers in a model where ss!=ds is an invitation for disaster, so be aware of how you specify -* your model and how you define variables which are used at interrupt time -* - remember that sign extension on 32 bit platforms may cause problems unless code is carefully constructed, -* e.g. use "(hcf_16)~foo" rather than "~foo" -* -************************************************************************************************************/ + ** + ** Implementation Notes + ** + * - a leading marker of //! is used. The purpose of such a sequence is to help to understand the flow + * An example is: //!rc = HCF_SUCCESS; + * if this is superfluous because rc is already guaranteed to be 0 but it shows to the (maintenance) + * programmer it is an intentional omission at the place where someone could consider it most appropriate at + * first glance + * - using near pointers in a model where ss!=ds is an invitation for disaster, so be aware of how you specify + * your model and how you define variables which are used at interrupt time + * - remember that sign extension on 32 bit platforms may cause problems unless code is carefully constructed, + * e.g. use "(hcf_16)~foo" rather than "~foo" + * + ************************************************************************************************************/ -#include "hcf.h" // HCF and MSF common include file -#include "hcfdef.h" // HCF specific include file -#include "mmd.h" // MoreModularDriver common include file +#include "hcf.h" // HCF and MSF common include file +#include "hcfdef.h" // HCF specific include file +#include "mmd.h" // MoreModularDriver common include file #include #if ! defined offsetof @@ -102,56 +101,56 @@ /***********************************************************************************************************/ /*************************************** PROTOTYPES ******************************************************/ /***********************************************************************************************************/ -HCF_STATIC int cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ); -HCF_STATIC int init( IFBP ifbp ); -HCF_STATIC int put_info( IFBP ifbp, LTVP ltvp ); +HCF_STATIC int cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ); +HCF_STATIC int init( IFBP ifbp ); +HCF_STATIC int put_info( IFBP ifbp, LTVP ltvp ); #if (HCF_EXT) & HCF_EXT_MB -HCF_STATIC int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ); +HCF_STATIC int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ); #endif // HCF_EXT_MB #if (HCF_TYPE) & HCF_TYPE_WPA -HCF_STATIC void calc_mic( hcf_32* p, hcf_32 M ); -void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ); -void calc_mic_tx_frag( IFBP ifbp, wci_bufp p, int len ); -HCF_STATIC int check_mic( IFBP ifbp ); +HCF_STATIC void calc_mic( hcf_32* p, hcf_32 M ); +void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ); +void calc_mic_tx_frag( IFBP ifbp, wci_bufp p, int len ); +HCF_STATIC int check_mic( IFBP ifbp ); #endif // HCF_TYPE_WPA -HCF_STATIC void calibrate( IFBP ifbp ); -HCF_STATIC int cmd_cmpl( IFBP ifbp ); -HCF_STATIC hcf_16 get_fid( IFBP ifbp ); -HCF_STATIC void isr_info( IFBP ifbp ); +HCF_STATIC void calibrate( IFBP ifbp ); +HCF_STATIC int cmd_cmpl( IFBP ifbp ); +HCF_STATIC hcf_16 get_fid( IFBP ifbp ); +HCF_STATIC void isr_info( IFBP ifbp ); #if HCF_DMA -HCF_STATIC DESC_STRCT* get_frame_lst(IFBP ifbp, int tx_rx_flag); +HCF_STATIC DESC_STRCT* get_frame_lst(IFBP ifbp, int tx_rx_flag); #endif // HCF_DMA -HCF_STATIC void get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ); //char*, byte count (usually even) +HCF_STATIC void get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ); //char*, byte count (usually even) #if HCF_DMA -HCF_STATIC void put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ); +HCF_STATIC void put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ); #endif // HCF_DMA -HCF_STATIC void put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ); -HCF_STATIC void put_frag_finalize( IFBP ifbp ); -HCF_STATIC int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ); +HCF_STATIC void put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ); +HCF_STATIC void put_frag_finalize( IFBP ifbp ); +HCF_STATIC int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ); #if (HCF_ASSERT) & HCF_ASSERT_PRINTF static int fw_printf(IFBP ifbp, CFG_FW_PRINTF_STRCT FAR *ltvp); #endif // HCF_ASSERT_PRINTF -HCF_STATIC int download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ); +HCF_STATIC int download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ); #if (HCF_ENCAP) & HCF_ENC -HCF_STATIC hcf_8 hcf_encap( wci_bufp type ); +HCF_STATIC hcf_8 hcf_encap( wci_bufp type ); #endif // HCF_ENCAP -HCF_STATIC hcf_8 null_addr[4] = { 0, 0, 0, 0 }; -#if ! defined IN_PORT_WORD //replace I/O Macros with logging facility +HCF_STATIC hcf_8 null_addr[4] = { 0, 0, 0, 0 }; +#if ! defined IN_PORT_WORD //replace I/O Macros with logging facility extern FILE *log_file; -#define IN_PORT_WORD(port) in_port_word( (hcf_io)(port) ) +#define IN_PORT_WORD(port) in_port_word( (hcf_io)(port) ) static hcf_16 in_port_word( hcf_io port ) { -hcf_16 i = (hcf_16)_inpw( port ); + hcf_16 i = (hcf_16)_inpw( port ); if ( log_file ) { fprintf( log_file, "\nR %2.2x %4.4x", (port)&0xFF, i); } return i; } // in_port_word -#define OUT_PORT_WORD(port, value) out_port_word( (hcf_io)(port), (hcf_16)(value) ) +#define OUT_PORT_WORD(port, value) out_port_word( (hcf_io)(port), (hcf_16)(value) ) static void out_port_word( hcf_io port, hcf_16 value ) { _outpw( port, value ); @@ -160,12 +159,12 @@ static void out_port_word( hcf_io port, hcf_16 value ) { } } -void IN_PORT_STRING_32( hcf_io prt, hcf_32 FAR * dst, int n) { +void IN_PORT_STRING_32( hcf_io prt, hcf_32 FAR * dst, int n) { int i = 0; hcf_16 FAR * p; if ( log_file ) { fprintf( log_file, "\nread string_32 length %04x (%04d) at port %02.2x to addr %lp", - (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF, dst); + (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF, dst); } while ( n-- ) { p = (hcf_16 FAR *)dst; @@ -178,12 +177,12 @@ void IN_PORT_STRING_32( hcf_io prt, hcf_32 FAR * dst, int n) { } } // IN_PORT_STRING_32 -void IN_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * dst, int n) { //also handles byte alignment problems - hcf_16 FAR * p = (hcf_16 FAR *)dst; //this needs more elaborate code in non-x86 platforms +void IN_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * dst, int n) { //also handles byte alignment problems + hcf_16 FAR * p = (hcf_16 FAR *)dst; //this needs more elaborate code in non-x86 platforms int i = 0; if ( log_file ) { fprintf( log_file, "\nread string_16 length %04x (%04d) at port %02.2x to addr %lp", - (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF, dst ); + (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF, dst ); } while ( n-- ) { *p =(hcf_16)_inpw( prt); @@ -198,12 +197,12 @@ void IN_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * dst, int n) { //also handles b } } // IN_PORT_STRING_8_16 -void OUT_PORT_STRING_32( hcf_io prt, hcf_32 FAR * src, int n) { +void OUT_PORT_STRING_32( hcf_io prt, hcf_32 FAR * src, int n) { int i = 0; hcf_16 FAR * p; if ( log_file ) { fprintf( log_file, "\nwrite string_32 length %04x (%04d) at port %02.2x", - (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF); + (hcf_16)n, (hcf_16)n, (hcf_16)(prt)&0xFF); } while ( n-- ) { p = (hcf_16 FAR *)src; @@ -216,8 +215,8 @@ void OUT_PORT_STRING_32( hcf_io prt, hcf_32 FAR * src, int n) { } } // OUT_PORT_STRING_32 -void OUT_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * src, int n) { //also handles byte alignment problems - hcf_16 FAR * p = (hcf_16 FAR *)src; //this needs more elaborate code in non-x86 platforms +void OUT_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * src, int n) { //also handles byte alignment problems + hcf_16 FAR * p = (hcf_16 FAR *)src; //this needs more elaborate code in non-x86 platforms int i = 0; if ( log_file ) { fprintf( log_file, "\nwrite string_16 length %04x (%04d) at port %04x", n, n, (hcf_16)prt); @@ -238,27 +237,27 @@ void OUT_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * src, int n) { //also handles #endif // IN_PORT_WORD /************************************************************************************************************ -******************************* D A T A D E F I N I T I O N S ******************************************** -************************************************************************************************************/ + ******************************* D A T A D E F I N I T I O N S ******************************************** + ************************************************************************************************************/ #if HCF_ASSERT -IFBP BASED assert_ifbp = NULL; //to make asserts easily work under MMD and DHF +IFBP BASED assert_ifbp = NULL; //to make asserts easily work under MMD and DHF #endif // HCF_ASSERT #if HCF_ENCAP /* SNAP header to be inserted in Ethernet-II frames */ -HCF_STATIC hcf_8 BASED snap_header[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, //5 bytes signature + - 0 }; //1 byte protocol identifier +HCF_STATIC hcf_8 BASED snap_header[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, //5 bytes signature + + 0 }; //1 byte protocol identifier #endif // HCF_ENCAP #if (HCF_TYPE) & HCF_TYPE_WPA -HCF_STATIC hcf_8 BASED mic_pad[8] = { 0x5A, 0, 0, 0, 0, 0, 0, 0 }; //MIC padding of message +HCF_STATIC hcf_8 BASED mic_pad[8] = { 0x5A, 0, 0, 0, 0, 0, 0, 0 }; //MIC padding of message #endif // HCF_TYPE_WPA #if defined MSF_COMPONENT_ID CFG_IDENTITY_STRCT BASED cfg_drv_identity = { - sizeof(cfg_drv_identity)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_IDENTITY, // (0x0826) + sizeof(cfg_drv_identity)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_IDENTITY, // (0x0826) MSF_COMPONENT_ID, MSF_COMPONENT_VAR, MSF_COMPONENT_MAJOR_VER, @@ -266,186 +265,186 @@ CFG_IDENTITY_STRCT BASED cfg_drv_identity = { } ; CFG_RANGES_STRCT BASED cfg_drv_sup_range = { - sizeof(cfg_drv_sup_range)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_SUP_RANGE, // (0x0827) + sizeof(cfg_drv_sup_range)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_SUP_RANGE, // (0x0827) COMP_ROLE_SUPL, COMP_ID_DUI, - {{ DUI_COMPAT_VAR, - DUI_COMPAT_BOT, - DUI_COMPAT_TOP + {{ DUI_COMPAT_VAR, + DUI_COMPAT_BOT, + DUI_COMPAT_TOP }} } ; struct CFG_RANGE3_STRCT BASED cfg_drv_act_ranges_pri = { - sizeof(cfg_drv_act_ranges_pri)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_ACT_RANGES_PRI, // (0x0828) + sizeof(cfg_drv_act_ranges_pri)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_ACT_RANGES_PRI, // (0x0828) COMP_ROLE_ACT, COMP_ID_PRI, { - { 0, 0, 0 }, // HCF_PRI_VAR_1 not supported by HCF 7 - { 0, 0, 0 }, // HCF_PRI_VAR_2 not supported by HCF 7 - { 3, //var_rec[2] - Variant number - CFG_DRV_ACT_RANGES_PRI_3_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_PRI_3_TOP // - Top Compatibility - } + { 0, 0, 0 }, // HCF_PRI_VAR_1 not supported by HCF 7 + { 0, 0, 0 }, // HCF_PRI_VAR_2 not supported by HCF 7 + { 3, //var_rec[2] - Variant number + CFG_DRV_ACT_RANGES_PRI_3_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_PRI_3_TOP // - Top Compatibility + } } } ; struct CFG_RANGE4_STRCT BASED cfg_drv_act_ranges_sta = { - sizeof(cfg_drv_act_ranges_sta)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_ACT_RANGES_STA, // (0x0829) + sizeof(cfg_drv_act_ranges_sta)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_ACT_RANGES_STA, // (0x0829) COMP_ROLE_ACT, COMP_ID_STA, { #if defined HCF_STA_VAR_1 - { 1, //var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_STA_1_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_STA_1_TOP // - Top Compatibility - }, + { 1, //var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_STA_1_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_STA_1_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_STA_VAR_1 #if defined HCF_STA_VAR_2 - { 2, //var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_STA_2_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_STA_2_TOP // - Top Compatibility - }, + { 2, //var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_STA_2_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_STA_2_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_STA_VAR_2 // For Native_USB (Not used!) #if defined HCF_STA_VAR_3 - { 3, //var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_STA_3_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_STA_3_TOP // - Top Compatibility - }, + { 3, //var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_STA_3_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_STA_3_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_STA_VAR_3 // Warp #if defined HCF_STA_VAR_4 - { 4, //var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_STA_4_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_STA_4_TOP // - Top Compatibility - } + { 4, //var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_STA_4_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_STA_4_TOP // - Top Compatibility + } #else - { 0, 0, 0 } + { 0, 0, 0 } #endif // HCF_STA_VAR_4 } } ; struct CFG_RANGE6_STRCT BASED cfg_drv_act_ranges_hsi = { - sizeof(cfg_drv_act_ranges_hsi)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_ACT_RANGES_HSI, // (0x082A) + sizeof(cfg_drv_act_ranges_hsi)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_ACT_RANGES_HSI, // (0x082A) COMP_ROLE_ACT, COMP_ID_HSI, { -#if defined HCF_HSI_VAR_0 // Controlled deployment - { 0, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_HSI_0_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_HSI_0_TOP // - Top Compatibility - }, +#if defined HCF_HSI_VAR_0 // Controlled deployment + { 0, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_HSI_0_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_HSI_0_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_HSI_VAR_0 - { 0, 0, 0 }, // HCF_HSI_VAR_1 not supported by HCF 7 - { 0, 0, 0 }, // HCF_HSI_VAR_2 not supported by HCF 7 - { 0, 0, 0 }, // HCF_HSI_VAR_3 not supported by HCF 7 -#if defined HCF_HSI_VAR_4 // Hermes-II all types - { 4, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_HSI_4_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_HSI_4_TOP // - Top Compatibility - }, + { 0, 0, 0 }, // HCF_HSI_VAR_1 not supported by HCF 7 + { 0, 0, 0 }, // HCF_HSI_VAR_2 not supported by HCF 7 + { 0, 0, 0 }, // HCF_HSI_VAR_3 not supported by HCF 7 +#if defined HCF_HSI_VAR_4 // Hermes-II all types + { 4, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_HSI_4_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_HSI_4_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_HSI_VAR_4 -#if defined HCF_HSI_VAR_5 // WARP Hermes-2.5 - { 5, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_HSI_5_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_HSI_5_TOP // - Top Compatibility - } +#if defined HCF_HSI_VAR_5 // WARP Hermes-2.5 + { 5, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_HSI_5_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_HSI_5_TOP // - Top Compatibility + } #else - { 0, 0, 0 } + { 0, 0, 0 } #endif // HCF_HSI_VAR_5 } } ; CFG_RANGE4_STRCT BASED cfg_drv_act_ranges_apf = { - sizeof(cfg_drv_act_ranges_apf)/sizeof(hcf_16) - 1, //length of RID - CFG_DRV_ACT_RANGES_APF, // (0x082B) + sizeof(cfg_drv_act_ranges_apf)/sizeof(hcf_16) - 1, //length of RID + CFG_DRV_ACT_RANGES_APF, // (0x082B) COMP_ROLE_ACT, COMP_ID_APF, { -#if defined HCF_APF_VAR_1 //(Fake) Hermes-I - { 1, //var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_APF_1_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_APF_1_TOP // - Top Compatibility - }, +#if defined HCF_APF_VAR_1 //(Fake) Hermes-I + { 1, //var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_APF_1_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_APF_1_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_APF_VAR_1 -#if defined HCF_APF_VAR_2 //Hermes-II - { 2, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_APF_2_BOTTOM, // - Bottom Compatibility - CFG_DRV_ACT_RANGES_APF_2_TOP // - Top Compatibility - }, +#if defined HCF_APF_VAR_2 //Hermes-II + { 2, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_APF_2_BOTTOM, // - Bottom Compatibility + CFG_DRV_ACT_RANGES_APF_2_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_APF_VAR_2 -#if defined HCF_APF_VAR_3 // Native_USB - { 3, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_APF_3_BOTTOM, // - Bottom Compatibility !!!!!see note below!!!!!!! - CFG_DRV_ACT_RANGES_APF_3_TOP // - Top Compatibility - }, +#if defined HCF_APF_VAR_3 // Native_USB + { 3, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_APF_3_BOTTOM, // - Bottom Compatibility !!!!!see note below!!!!!!! + CFG_DRV_ACT_RANGES_APF_3_TOP // - Top Compatibility + }, #else - { 0, 0, 0 }, + { 0, 0, 0 }, #endif // HCF_APF_VAR_3 -#if defined HCF_APF_VAR_4 // WARP Hermes 2.5 - { 4, // var_rec[1] - Variant number - CFG_DRV_ACT_RANGES_APF_4_BOTTOM, // - Bottom Compatibility !!!!!see note below!!!!!!! - CFG_DRV_ACT_RANGES_APF_4_TOP // - Top Compatibility - } +#if defined HCF_APF_VAR_4 // WARP Hermes 2.5 + { 4, // var_rec[1] - Variant number + CFG_DRV_ACT_RANGES_APF_4_BOTTOM, // - Bottom Compatibility !!!!!see note below!!!!!!! + CFG_DRV_ACT_RANGES_APF_4_TOP // - Top Compatibility + } #else - { 0, 0, 0 } + { 0, 0, 0 } #endif // HCF_APF_VAR_4 } } ; #define HCF_VERSION TEXT( "HCF$Revision: 1.10 $" ) static struct /*CFG_HCF_OPT_STRCT*/ { - hcf_16 len; //length of cfg_hcf_opt struct - hcf_16 typ; //type 0x082C - hcf_16 v0; //offset HCF_VERSION - hcf_16 v1; // MSF_COMPONENT_ID - hcf_16 v2; // HCF_ALIGN - hcf_16 v3; // HCF_ASSERT - hcf_16 v4; // HCF_BIG_ENDIAN - hcf_16 v5; // /* HCF_DLV | HCF_DLNV */ - hcf_16 v6; // HCF_DMA - hcf_16 v7; // HCF_ENCAP - hcf_16 v8; // HCF_EXT - hcf_16 v9; // HCF_INT_ON - hcf_16 v10; // HCF_IO - hcf_16 v11; // HCF_LEGACY - hcf_16 v12; // HCF_MAX_LTV - hcf_16 v13; // HCF_PROT_TIME - hcf_16 v14; // HCF_SLEEP - hcf_16 v15; // HCF_TALLIES - hcf_16 v16; // HCF_TYPE - hcf_16 v17; // HCF_NIC_TAL_CNT - hcf_16 v18; // HCF_HCF_TAL_CNT - hcf_16 v19; // offset tallies - TCHAR val[sizeof(HCF_VERSION)]; + hcf_16 len; //length of cfg_hcf_opt struct + hcf_16 typ; //type 0x082C + hcf_16 v0; //offset HCF_VERSION + hcf_16 v1; // MSF_COMPONENT_ID + hcf_16 v2; // HCF_ALIGN + hcf_16 v3; // HCF_ASSERT + hcf_16 v4; // HCF_BIG_ENDIAN + hcf_16 v5; // /* HCF_DLV | HCF_DLNV */ + hcf_16 v6; // HCF_DMA + hcf_16 v7; // HCF_ENCAP + hcf_16 v8; // HCF_EXT + hcf_16 v9; // HCF_INT_ON + hcf_16 v10; // HCF_IO + hcf_16 v11; // HCF_LEGACY + hcf_16 v12; // HCF_MAX_LTV + hcf_16 v13; // HCF_PROT_TIME + hcf_16 v14; // HCF_SLEEP + hcf_16 v15; // HCF_TALLIES + hcf_16 v16; // HCF_TYPE + hcf_16 v17; // HCF_NIC_TAL_CNT + hcf_16 v18; // HCF_HCF_TAL_CNT + hcf_16 v19; // offset tallies + TCHAR val[sizeof(HCF_VERSION)]; } BASED cfg_hcf_opt = { sizeof(cfg_hcf_opt)/sizeof(hcf_16) -1, - CFG_HCF_OPT, // (0x082C) + CFG_HCF_OPT, // (0x082C) ( sizeof(cfg_hcf_opt) - sizeof(HCF_VERSION) - 4 )/sizeof(hcf_16), #if defined MSF_COMPONENT_ID MSF_COMPONENT_ID, @@ -455,7 +454,7 @@ static struct /*CFG_HCF_OPT_STRCT*/ { HCF_ALIGN, HCF_ASSERT, HCF_BIG_ENDIAN, - 0, // /* HCF_DLV | HCF_DLNV*/, + 0, // /* HCF_DLV | HCF_DLNV*/, HCF_DMA, HCF_ENCAP, HCF_EXT, @@ -488,208 +487,208 @@ HCF_STATIC LTV_STRCT BASED cfg_null = { 1, CFG_NULL, {0} }; #endif // HCF_EXT_MB HCF_STATIC hcf_16* BASED xxxx[ ] = { #if (HCF_EXT) & HCF_EXT_MB - &cfg_null.len, //CFG_NULL 0x0820 + &cfg_null.len, //CFG_NULL 0x0820 #endif // HCF_EXT_MB #if defined MSF_COMPONENT_ID - &cfg_drv_identity.len, //CFG_DRV_IDENTITY 0x0826 - &cfg_drv_sup_range.len, //CFG_DRV_SUP_RANGE 0x0827 - &cfg_drv_act_ranges_pri.len, //CFG_DRV_ACT_RANGES_PRI 0x0828 - &cfg_drv_act_ranges_sta.len, //CFG_DRV_ACT_RANGES_STA 0x0829 - &cfg_drv_act_ranges_hsi.len, //CFG_DRV_ACT_RANGES_HSI 0x082A - &cfg_drv_act_ranges_apf.len, //CFG_DRV_ACT_RANGES_APF 0x082B - &cfg_hcf_opt.len, //CFG_HCF_OPT 0x082C - NULL, //IFB_PRIIdentity placeholder 0xFD02 - NULL, //IFB_PRISup placeholder 0xFD03 + &cfg_drv_identity.len, //CFG_DRV_IDENTITY 0x0826 + &cfg_drv_sup_range.len, //CFG_DRV_SUP_RANGE 0x0827 + &cfg_drv_act_ranges_pri.len, //CFG_DRV_ACT_RANGES_PRI 0x0828 + &cfg_drv_act_ranges_sta.len, //CFG_DRV_ACT_RANGES_STA 0x0829 + &cfg_drv_act_ranges_hsi.len, //CFG_DRV_ACT_RANGES_HSI 0x082A + &cfg_drv_act_ranges_apf.len, //CFG_DRV_ACT_RANGES_APF 0x082B + &cfg_hcf_opt.len, //CFG_HCF_OPT 0x082C + NULL, //IFB_PRIIdentity placeholder 0xFD02 + NULL, //IFB_PRISup placeholder 0xFD03 #endif // MSF_COMPONENT_ID - NULL //endsentinel - }; -#define xxxx_PRI_IDENTITY_OFFSET (ARRAY_SIZE(xxxx) - 3) + NULL //endsentinel +}; +#define xxxx_PRI_IDENTITY_OFFSET (ARRAY_SIZE(xxxx) - 3) #endif // MSF_COMPONENT_ID / HCF_EXT_MB /************************************************************************************************************ -************************** T O P L E V E L H C F R O U T I N E S ************************************** -************************************************************************************************************/ + ************************** T O P L E V E L H C F R O U T I N E S ************************************** + ************************************************************************************************************/ #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.MODULE int hcf_action( IFBP ifbp, hcf_16 action ) -*.PURPOSE Changes the run-time Card behavior. -* Performs Miscellanuous actions. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* action number identifying the type of change -* - HCF_ACT_CCX_OFF disable CKIP -* - HCF_ACT_CCX_ON enable CKIP -* - HCF_ACT_INT_FORCE_ON enable interrupt generation by WaveLAN NIC -* - HCF_ACT_INT_OFF disable interrupt generation by WaveLAN NIC -* - HCF_ACT_INT_ON compensate 1 HCF_ACT_INT_OFF, enable interrupt generation if balance reached -* - HCF_ACT_PRS_SCAN Hermes Probe Respons Scan (F102) command -* - HCF_ACT_RX_ACK acknowledge non-DMA receiver to Hermes -* - HCF_ACT_SCAN Hermes Inquire Scan (F101) command (non-WARP only) -* - HCF_ACT_SLEEP DDS Sleep request -* - HCF_ACT_TALLIES Hermes Inquire Tallies (F100) command -* -*.RETURNS -* HCF_SUCCESS all (including invalid) -* HCF_INT_PENDING HCF_ACT_INT_OFF, interrupt pending -* HCF_ERR_NO_NIC HCF_ACT_INT_OFF, NIC presence check fails -* -*.CONDITIONS -* Except for hcf_action with HCF_ACT_INT_FORCE_ON or HCF_ACT_INT_OFF as parameter or hcf_connect with an I/O -* address (i.e. not HCF_DISCONNECT), all hcf-function calls MUST be preceded by a call of hcf_action with -* HCF_ACT_INT_OFF as parameter. -* Note that hcf_connect defaults to NIC interrupt disabled mode, i.e. as if hcf_action( HCF_ACT_INT_OFF ) -* was called. -* -*.DESCRIPTION -* hcf_action supports the following mode changing action-code pairs that are antonyms -* - HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON -* - HCF_ACT_INT_[FORCE_]ON / HCF_ACT_INT_OFF -* -* Additionally hcf_action can start the following actions in the NIC: -* - HCF_ACT_PRS_SCAN -* - HCF_ACT_RX_ACK -* - HCF_ACT_SCAN -* - HCF_ACT_SLEEP -* - HCF_ACT_TALLIES -* -* o HCF_ACT_INT_OFF: Sets NIC Interrupts mode Disabled. -* This command, and the associated [Force] Enable NIC interrupts command, are only available if the HCF_INT_ON -* compile time option is not set at 0x0000. -* -* o HCF_ACT_INT_ON: Sets NIC Interrupts mode Enabled. -* Enable NIC Interrupts, depending on the number of preceding Disable NIC Interrupt calls. -* -* o HCF_ACT_INT_FORCE_ON: Force NIC Interrupts mode Enabled. -* Sets NIC Interrupts mode Enabled, regardless off the number of preceding Disable NIC Interrupt calls. -* -* The disabling and enabling of interrupts are antonyms. -* These actions must be balanced. -* For each "disable interrupts" there must be a matching "enable interrupts". -* The disable interrupts may be executed multiple times in a row without intervening enable interrupts, in -* other words, the disable interrupts may be nested. -* The interrupt generation mechanism is disabled at the first call with HCF_ACT_INT_OFF. -* The interrupt generation mechanism is re-enabled when the number of calls with HCF_ACT_INT_ON matches the -* number of calls with INT_OFF. -* -* It is not allowed to have more Enable NIC Interrupts calls than Disable NIC Interrupts calls. -* The interrupt generation mechanism is initially (i.e. after hcf_connect) disabled. -* An MSF based on a interrupt strategy must call hcf_action with INT_ON in its initialization logic. -* -*! The INT_OFF/INT_ON housekeeping is initialized at 0x0000 by hcf_connect, causing the interrupt generation -* mechanism to be disabled at first. This suits MSF implementation based on a polling strategy. -* -* o HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON -*!! This can use some more explanation;? -* Disables and Enables support in the HCF runtime code for the CCX feature. Each time one of these action -* codes is used, the effects of the preceding use cease. -* -* o HCF_ACT_SLEEP: Initiates the Disconnected DeepSleep process -* This command is only available if the HCF_DDS compile time option is set. It triggers the F/W to start the -* sleep handshaking. Regardless whether the Host initiates a Disconnected DeepSleep (DDS) or the F/W initiates -* a Connected DeepSleep (CDS), the Host-F/W sleep handshaking is completed when the NIC Interrupts mode is -* enabled (by means of the balancing HCF_ACT_INT_ON), i.e. at that moment the F/W really goes into sleep mode. -* The F/W is wokenup by the HCF when the NIC Interrupts mode are disabled, i.e. at the first HCF_ACT_INT_OFF -* after going into sleep. -* -* The following Miscellanuous actions are defined: -* -* o HCF_ACT_RX_ACK: Receiver Acknowledgement (non-DMA, non-USB mode only) -* Acking the receiver, frees the NIC memory used to hold the Rx frame and allows the F/W to -* report the existence of the next Rx frame. -* If the MSF does not need access (any longer) to the current frame, e.g. because it is rejected based on the -* look ahead or copied to another buffer, the receiver may be acked. Acking earlier is assumed to have the -* potential of improving the performance. -* If the MSF does not explitly ack te receiver, the acking is done implicitly if: -* - the received frame fits in the look ahead buffer, by the hcf_service_nic call that reported the Rx frame -* - if not in the above step, by hcf_rcv_msg (assuming hcf_rcv_msg is called) -* - if neither of the above implicit acks nor an explicit ack by the MSF, by the first hcf_service_nic after -* the hcf_service_nic that reported the Rx frame. -* Note: If an Rx frame is already acked, an explicit ACK by the MSF acts as a NoOperation. -* -* o HCF_ACT_TALLIES: Inquire Tallies command -* This command is only operational if the F/W is enabled. -* The Inquire Tallies command requests the F/W to provide its current set of tallies. -* See also hcf_get_info with CFG_TALLIES as parameter. -* -* o HCF_ACT_PRS_SCAN: Inquire Probe Respons Scan command -* This command is only operational if the F/W is enabled. -* The Probe Respons Scan command starts a scan sequence. -* The HCF puts the result of this action in an MSF defined buffer (see CFG_RID_LOG_STRCT). -* -* o HCF_ACT_SCAN: Inquire Scan command -* This command is only supported for HII F/W (i.e. pre-WARP) and it is operational if the F/W is enabled. -* The Inquire Scan command starts a scan sequence. -* The HCF puts the result of this action in an MSF defined buffer (see CFG_RID_LOG_STRCT). -* -* Assert fails if -* - ifbp has a recognizable out-of-range value. -* - NIC interrupts are not disabled while required by parameter action. -* - an invalid code is specified in parameter action. -* - HCF_ACT_INT_ON commands outnumber the HCF_ACT_INT_OFF commands. -* - reentrancy, may be caused by calling hcf_functions without adequate protection against NIC interrupts or -* multi-threading -* -* - Since the HCF does not maintain status information relative to the F/W enabled state, it is not asserted -* whether HCF_ACT_SCAN, HCF_ACT_PRS_SCAN or HCF_ACT_TALLIES are only used while F/W is enabled. -* -*.DIAGRAM -* 0: The assert embedded in HCFLOGENTRY checks against re-entrancy. Re-entrancy could be caused by a MSF logic -* at task-level calling hcf_functions without shielding with HCF_ACT_ON/_OFF. However the HCF_ACT_INT_OFF -* action itself can per definition not be protected this way. Based on code inspection, it can be concluded, -* that there is no re-entrancy PROBLEM in this particular flow. It does not seem worth the trouble to -* explicitly check for this condition (although there was a report of an MSF which ran into this assert. -* 2:IFB_IntOffCnt is used to balance the INT_OFF and INT_ON calls. Disabling of the interrupts is achieved by -* writing a zero to the Hermes IntEn register. In a shared interrupt environment (e.g. the mini-PCI NDIS -* driver) it is considered more correct to return the status HCF_INT_PENDING if and only if, the current -* invocation of hcf_service_nic is (apparently) called in the ISR when the ISR was activated as result of a -* change in HREG_EV_STAT matching a bit in HREG_INT_EN, i.e. not if invoked as result of another device -* generating an interrupt on the shared interrupt line. -* Note 1: it has been observed that under certain adverse conditions on certain platforms the writing of -* HREG_INT_EN can apparently fail, therefor it is paramount that HREG_INT_EN is written again with 0 for -* each and every call to HCF_ACT_INT_OFF. -* Note 2: it has been observed that under certain H/W & S/W architectures this logic is called when there is -* no NIC at all. To cater for this, the value of HREG_INT_EN is validated. If the unused bit 0x0100 is set, -* it is assumed there is no NIC. -* Note 3: During the download process, some versions of the F/W reset HREG_SW_0, hence checking this -* register for HCF_MAGIC (the classical NIC presence test) when HCF_ACT_INT_OFF is called due to another -* card interrupting via a shared IRQ during a download, fails. -*4: The construction "if ( ifbp->IFB_IntOffCnt-- == 0 )" is optimal (in the sense of shortest/quickest -* path in error free flows) but NOT fail safe in case of too many INT_ON invocations compared to INT_OFF). -* Enabling of the interrupts is achieved by writing the Hermes IntEn register. -* - If the HCF is in Defunct mode, the interrupts stay disabled. -* - Under "normal" conditions, the HCF is only interested in Info Events, Rx Events and Notify Events. -* - When the HCF is out of Tx/Notify resources, the HCF is also interested in Alloc Events. -* - via HCF_EXT, the MSF programmer can also request HREG_EV_TICK and/or HREG_EV_TX_EXC interrupts. -* For DMA operation, the DMA hardware handles the alloc events. The DMA engine will generate a 'TxDmaDone' -* event as soon as it has pumped a frame from host ram into NIC-RAM (note that the frame does not have to be -* transmitted then), and a 'RxDmaDone' event as soon as a received frame has been pumped from NIC-RAM into -* host ram. Note that the 'alloc' event has been removed from the event-mask, because the DMA engine will -* react to and acknowledge this event. -*6: ack the "old" Rx-event. See "Rx Buffer free strategy" in hcf_service_nic above for more explanation. -* IFB_RxFID and IFB_RxLen must be cleared to bring both the internal HCF house keeping and the information -* supplied to the MSF in the state "no frame received". -*8: The HCF_ACT_SCAN, HCF_ACT_PRS_SCAN and HCF_ACT_TALLIES activity are merged by "clever" algebraic -* manipulations of the RID-values and action codes, so foregoing robustness against migration problems for -* ease of implementation. The assumptions about numerical relationships between CFG_TALLIES etc and -* HCF_ACT_TALLIES etc are checked by the "#if" statements just prior to the body of this routine, resulting -* in: err "maintenance" during compilation if the assumptions are no longer met. The writing of HREG_PARAM_1 -* with 0x3FFF in case of an PRS scan, is a kludge to get around lack of specification, hence different -* implementation in F/W and Host. -* When there is no NIC RAM available, some versions of the Hermes F/W do report 0x7F00 as error in the -* Result field of the Status register and some F/W versions don't. To mask this difference to the MSF all -* return codes of the Hermes are ignored ("best" and "most simple" solution to these types of analomies with -* an acceptable loss due to ignoring all error situations as well). -* The "No inquire space" is reported via the Hermes tallies. -*30: do not HCFASSERT( rc, rc ) since rc == HCF_INT_PENDING is no error -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE int hcf_action( IFBP ifbp, hcf_16 action ) + *.PURPOSE Changes the run-time Card behavior. + * Performs Miscellanuous actions. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * action number identifying the type of change + * - HCF_ACT_CCX_OFF disable CKIP + * - HCF_ACT_CCX_ON enable CKIP + * - HCF_ACT_INT_FORCE_ON enable interrupt generation by WaveLAN NIC + * - HCF_ACT_INT_OFF disable interrupt generation by WaveLAN NIC + * - HCF_ACT_INT_ON compensate 1 HCF_ACT_INT_OFF, enable interrupt generation if balance reached + * - HCF_ACT_PRS_SCAN Hermes Probe Respons Scan (F102) command + * - HCF_ACT_RX_ACK acknowledge non-DMA receiver to Hermes + * - HCF_ACT_SCAN Hermes Inquire Scan (F101) command (non-WARP only) + * - HCF_ACT_SLEEP DDS Sleep request + * - HCF_ACT_TALLIES Hermes Inquire Tallies (F100) command + * + *.RETURNS + * HCF_SUCCESS all (including invalid) + * HCF_INT_PENDING HCF_ACT_INT_OFF, interrupt pending + * HCF_ERR_NO_NIC HCF_ACT_INT_OFF, NIC presence check fails + * + *.CONDITIONS + * Except for hcf_action with HCF_ACT_INT_FORCE_ON or HCF_ACT_INT_OFF as parameter or hcf_connect with an I/O + * address (i.e. not HCF_DISCONNECT), all hcf-function calls MUST be preceded by a call of hcf_action with + * HCF_ACT_INT_OFF as parameter. + * Note that hcf_connect defaults to NIC interrupt disabled mode, i.e. as if hcf_action( HCF_ACT_INT_OFF ) + * was called. + * + *.DESCRIPTION + * hcf_action supports the following mode changing action-code pairs that are antonyms + * - HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON + * - HCF_ACT_INT_[FORCE_]ON / HCF_ACT_INT_OFF + * + * Additionally hcf_action can start the following actions in the NIC: + * - HCF_ACT_PRS_SCAN + * - HCF_ACT_RX_ACK + * - HCF_ACT_SCAN + * - HCF_ACT_SLEEP + * - HCF_ACT_TALLIES + * + * o HCF_ACT_INT_OFF: Sets NIC Interrupts mode Disabled. + * This command, and the associated [Force] Enable NIC interrupts command, are only available if the HCF_INT_ON + * compile time option is not set at 0x0000. + * + * o HCF_ACT_INT_ON: Sets NIC Interrupts mode Enabled. + * Enable NIC Interrupts, depending on the number of preceding Disable NIC Interrupt calls. + * + * o HCF_ACT_INT_FORCE_ON: Force NIC Interrupts mode Enabled. + * Sets NIC Interrupts mode Enabled, regardless off the number of preceding Disable NIC Interrupt calls. + * + * The disabling and enabling of interrupts are antonyms. + * These actions must be balanced. + * For each "disable interrupts" there must be a matching "enable interrupts". + * The disable interrupts may be executed multiple times in a row without intervening enable interrupts, in + * other words, the disable interrupts may be nested. + * The interrupt generation mechanism is disabled at the first call with HCF_ACT_INT_OFF. + * The interrupt generation mechanism is re-enabled when the number of calls with HCF_ACT_INT_ON matches the + * number of calls with INT_OFF. + * + * It is not allowed to have more Enable NIC Interrupts calls than Disable NIC Interrupts calls. + * The interrupt generation mechanism is initially (i.e. after hcf_connect) disabled. + * An MSF based on a interrupt strategy must call hcf_action with INT_ON in its initialization logic. + * + *! The INT_OFF/INT_ON housekeeping is initialized at 0x0000 by hcf_connect, causing the interrupt generation + * mechanism to be disabled at first. This suits MSF implementation based on a polling strategy. + * + * o HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON + *!! This can use some more explanation;? + * Disables and Enables support in the HCF runtime code for the CCX feature. Each time one of these action + * codes is used, the effects of the preceding use cease. + * + * o HCF_ACT_SLEEP: Initiates the Disconnected DeepSleep process + * This command is only available if the HCF_DDS compile time option is set. It triggers the F/W to start the + * sleep handshaking. Regardless whether the Host initiates a Disconnected DeepSleep (DDS) or the F/W initiates + * a Connected DeepSleep (CDS), the Host-F/W sleep handshaking is completed when the NIC Interrupts mode is + * enabled (by means of the balancing HCF_ACT_INT_ON), i.e. at that moment the F/W really goes into sleep mode. + * The F/W is wokenup by the HCF when the NIC Interrupts mode are disabled, i.e. at the first HCF_ACT_INT_OFF + * after going into sleep. + * + * The following Miscellanuous actions are defined: + * + * o HCF_ACT_RX_ACK: Receiver Acknowledgement (non-DMA, non-USB mode only) + * Acking the receiver, frees the NIC memory used to hold the Rx frame and allows the F/W to + * report the existence of the next Rx frame. + * If the MSF does not need access (any longer) to the current frame, e.g. because it is rejected based on the + * look ahead or copied to another buffer, the receiver may be acked. Acking earlier is assumed to have the + * potential of improving the performance. + * If the MSF does not explitly ack te receiver, the acking is done implicitly if: + * - the received frame fits in the look ahead buffer, by the hcf_service_nic call that reported the Rx frame + * - if not in the above step, by hcf_rcv_msg (assuming hcf_rcv_msg is called) + * - if neither of the above implicit acks nor an explicit ack by the MSF, by the first hcf_service_nic after + * the hcf_service_nic that reported the Rx frame. + * Note: If an Rx frame is already acked, an explicit ACK by the MSF acts as a NoOperation. + * + * o HCF_ACT_TALLIES: Inquire Tallies command + * This command is only operational if the F/W is enabled. + * The Inquire Tallies command requests the F/W to provide its current set of tallies. + * See also hcf_get_info with CFG_TALLIES as parameter. + * + * o HCF_ACT_PRS_SCAN: Inquire Probe Respons Scan command + * This command is only operational if the F/W is enabled. + * The Probe Respons Scan command starts a scan sequence. + * The HCF puts the result of this action in an MSF defined buffer (see CFG_RID_LOG_STRCT). + * + * o HCF_ACT_SCAN: Inquire Scan command + * This command is only supported for HII F/W (i.e. pre-WARP) and it is operational if the F/W is enabled. + * The Inquire Scan command starts a scan sequence. + * The HCF puts the result of this action in an MSF defined buffer (see CFG_RID_LOG_STRCT). + * + * Assert fails if + * - ifbp has a recognizable out-of-range value. + * - NIC interrupts are not disabled while required by parameter action. + * - an invalid code is specified in parameter action. + * - HCF_ACT_INT_ON commands outnumber the HCF_ACT_INT_OFF commands. + * - reentrancy, may be caused by calling hcf_functions without adequate protection against NIC interrupts or + * multi-threading + * + * - Since the HCF does not maintain status information relative to the F/W enabled state, it is not asserted + * whether HCF_ACT_SCAN, HCF_ACT_PRS_SCAN or HCF_ACT_TALLIES are only used while F/W is enabled. + * + *.DIAGRAM + * 0: The assert embedded in HCFLOGENTRY checks against re-entrancy. Re-entrancy could be caused by a MSF logic + * at task-level calling hcf_functions without shielding with HCF_ACT_ON/_OFF. However the HCF_ACT_INT_OFF + * action itself can per definition not be protected this way. Based on code inspection, it can be concluded, + * that there is no re-entrancy PROBLEM in this particular flow. It does not seem worth the trouble to + * explicitly check for this condition (although there was a report of an MSF which ran into this assert. + * 2:IFB_IntOffCnt is used to balance the INT_OFF and INT_ON calls. Disabling of the interrupts is achieved by + * writing a zero to the Hermes IntEn register. In a shared interrupt environment (e.g. the mini-PCI NDIS + * driver) it is considered more correct to return the status HCF_INT_PENDING if and only if, the current + * invocation of hcf_service_nic is (apparently) called in the ISR when the ISR was activated as result of a + * change in HREG_EV_STAT matching a bit in HREG_INT_EN, i.e. not if invoked as result of another device + * generating an interrupt on the shared interrupt line. + * Note 1: it has been observed that under certain adverse conditions on certain platforms the writing of + * HREG_INT_EN can apparently fail, therefor it is paramount that HREG_INT_EN is written again with 0 for + * each and every call to HCF_ACT_INT_OFF. + * Note 2: it has been observed that under certain H/W & S/W architectures this logic is called when there is + * no NIC at all. To cater for this, the value of HREG_INT_EN is validated. If the unused bit 0x0100 is set, + * it is assumed there is no NIC. + * Note 3: During the download process, some versions of the F/W reset HREG_SW_0, hence checking this + * register for HCF_MAGIC (the classical NIC presence test) when HCF_ACT_INT_OFF is called due to another + * card interrupting via a shared IRQ during a download, fails. + *4: The construction "if ( ifbp->IFB_IntOffCnt-- == 0 )" is optimal (in the sense of shortest/quickest + * path in error free flows) but NOT fail safe in case of too many INT_ON invocations compared to INT_OFF). + * Enabling of the interrupts is achieved by writing the Hermes IntEn register. + * - If the HCF is in Defunct mode, the interrupts stay disabled. + * - Under "normal" conditions, the HCF is only interested in Info Events, Rx Events and Notify Events. + * - When the HCF is out of Tx/Notify resources, the HCF is also interested in Alloc Events. + * - via HCF_EXT, the MSF programmer can also request HREG_EV_TICK and/or HREG_EV_TX_EXC interrupts. + * For DMA operation, the DMA hardware handles the alloc events. The DMA engine will generate a 'TxDmaDone' + * event as soon as it has pumped a frame from host ram into NIC-RAM (note that the frame does not have to be + * transmitted then), and a 'RxDmaDone' event as soon as a received frame has been pumped from NIC-RAM into + * host ram. Note that the 'alloc' event has been removed from the event-mask, because the DMA engine will + * react to and acknowledge this event. + *6: ack the "old" Rx-event. See "Rx Buffer free strategy" in hcf_service_nic above for more explanation. + * IFB_RxFID and IFB_RxLen must be cleared to bring both the internal HCF house keeping and the information + * supplied to the MSF in the state "no frame received". + *8: The HCF_ACT_SCAN, HCF_ACT_PRS_SCAN and HCF_ACT_TALLIES activity are merged by "clever" algebraic + * manipulations of the RID-values and action codes, so foregoing robustness against migration problems for + * ease of implementation. The assumptions about numerical relationships between CFG_TALLIES etc and + * HCF_ACT_TALLIES etc are checked by the "#if" statements just prior to the body of this routine, resulting + * in: err "maintenance" during compilation if the assumptions are no longer met. The writing of HREG_PARAM_1 + * with 0x3FFF in case of an PRS scan, is a kludge to get around lack of specification, hence different + * implementation in F/W and Host. + * When there is no NIC RAM available, some versions of the Hermes F/W do report 0x7F00 as error in the + * Result field of the Status register and some F/W versions don't. To mask this difference to the MSF all + * return codes of the Hermes are ignored ("best" and "most simple" solution to these types of analomies with + * an acceptable loss due to ignoring all error situations as well). + * The "No inquire space" is reported via the Hermes tallies. + *30: do not HCFASSERT( rc, rc ) since rc == HCF_INT_PENDING is no error + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 #if CFG_SCAN != CFG_TALLIES - HCF_ACT_TALLIES + HCF_ACT_SCAN err: "maintenance" apparently inviolated the underlying assumption about the numerical values of these macros @@ -701,43 +700,43 @@ err: "maintenance" apparently inviolated the underlying assumption about the num int hcf_action( IFBP ifbp, hcf_16 action ) { -int rc = HCF_SUCCESS; + int rc = HCF_SUCCESS; HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); #if HCF_INT_ON - HCFLOGENTRY( action == HCF_ACT_INT_FORCE_ON ? HCF_TRACE_ACTION_KLUDGE : HCF_TRACE_ACTION, action ); /* 0 */ + HCFLOGENTRY( action == HCF_ACT_INT_FORCE_ON ? HCF_TRACE_ACTION_KLUDGE : HCF_TRACE_ACTION, action ); /* 0 */ #if (HCF_SLEEP) HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE || action == HCF_ACT_INT_OFF, - MERGE_2( action, ifbp->IFB_IntOffCnt ) ); + MERGE_2( action, ifbp->IFB_IntOffCnt ) ); #else HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, action ); #endif // HCF_SLEEP HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFF || - action == HCF_ACT_INT_OFF || action == HCF_ACT_INT_FORCE_ON, action ); + action == HCF_ACT_INT_OFF || action == HCF_ACT_INT_FORCE_ON, action ); HCFASSERT( ifbp->IFB_IntOffCnt <= 16 || ifbp->IFB_IntOffCnt >= 0xFFFE, - MERGE_2( action, ifbp->IFB_IntOffCnt ) ); //nesting more than 16 deep seems unreasonable + MERGE_2( action, ifbp->IFB_IntOffCnt ) ); //nesting more than 16 deep seems unreasonable #endif // HCF_INT_ON switch (action) { #if HCF_INT_ON -hcf_16 i; - case HCF_ACT_INT_OFF: // Disable Interrupt generation + hcf_16 i; + case HCF_ACT_INT_OFF: // Disable Interrupt generation #if HCF_SLEEP - if ( ifbp->IFB_IntOffCnt == 0xFFFE ) { // WakeUp test ;?tie this to the "new" super-LinkStat - ifbp->IFB_IntOffCnt++; // restore conventional I/F - OPW(HREG_IO, HREG_IO_WAKEUP_ASYNC ); // set wakeup bit - OPW(HREG_IO, HREG_IO_WAKEUP_ASYNC ); // set wakeup bit to counteract the clearing by F/W + if ( ifbp->IFB_IntOffCnt == 0xFFFE ) { // WakeUp test ;?tie this to the "new" super-LinkStat + ifbp->IFB_IntOffCnt++; // restore conventional I/F + OPW(HREG_IO, HREG_IO_WAKEUP_ASYNC ); // set wakeup bit + OPW(HREG_IO, HREG_IO_WAKEUP_ASYNC ); // set wakeup bit to counteract the clearing by F/W // 800 us latency before FW switches to high power - MSF_WAIT(800); // MSF-defined function to wait n microseconds. -//OOR if ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_DS_OOR ) { // OutOfRange -// printk( "<5>ACT_INT_OFF: Deepsleep phase terminated, enable and go to AwaitConnection\n" ); //;?remove me 1 day + MSF_WAIT(800); // MSF-defined function to wait n microseconds. +//OOR if ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_DS_OOR ) { // OutOfRange +// printk( "<5>ACT_INT_OFF: Deepsleep phase terminated, enable and go to AwaitConnection\n" ); //;?remove me 1 day // hcf_cntl( ifbp, HCF_CNTL_ENABLE ); // } -// ifbp->IFB_DSLinkStat &= ~( CFG_LINK_STAT_DS_IR | CFG_LINK_STAT_DS_OOR); //clear IR/OOR state +// ifbp->IFB_DSLinkStat &= ~( CFG_LINK_STAT_DS_IR | CFG_LINK_STAT_DS_OOR); //clear IR/OOR state } #endif // HCF_SLEEP -/*2*/ ifbp->IFB_IntOffCnt++; -//! rc = 0; + /*2*/ ifbp->IFB_IntOffCnt++; +//! rc = 0; i = IPW( HREG_INT_EN ); OPW( HREG_INT_EN, 0 ); if ( i & 0x1000 ) { @@ -749,89 +748,89 @@ hcf_16 i; } break; - case HCF_ACT_INT_FORCE_ON: // Enforce Enable Interrupt generation + case HCF_ACT_INT_FORCE_ON: // Enforce Enable Interrupt generation ifbp->IFB_IntOffCnt = 0; //Fall through in HCF_ACT_INT_ON - case HCF_ACT_INT_ON: // Enable Interrupt generation -/*4*/ if ( ifbp->IFB_IntOffCnt-- == 0 && ifbp->IFB_CardStat == 0 ) { - //determine Interrupt Event mask + case HCF_ACT_INT_ON: // Enable Interrupt generation + /*4*/ if ( ifbp->IFB_IntOffCnt-- == 0 && ifbp->IFB_CardStat == 0 ) { + //determine Interrupt Event mask #if HCF_DMA if ( ifbp->IFB_CntlOpt & USE_DMA ) { - i = HREG_EV_INFO | HREG_EV_RDMAD | HREG_EV_TDMAD | HREG_EV_TX_EXT; //mask when DMA active + i = HREG_EV_INFO | HREG_EV_RDMAD | HREG_EV_TDMAD | HREG_EV_TX_EXT; //mask when DMA active } else #endif // HCF_DMA { - i = HREG_EV_INFO | HREG_EV_RX | HREG_EV_TX_EXT; //mask when DMA not active + i = HREG_EV_INFO | HREG_EV_RX | HREG_EV_TX_EXT; //mask when DMA not active if ( ifbp->IFB_RscInd == 0 ) { - i |= HREG_EV_ALLOC; //mask when no TxFID available + i |= HREG_EV_ALLOC; //mask when no TxFID available } } #if HCF_SLEEP if ( ( IPW(HREG_EV_STAT) & ( i | HREG_EV_SLEEP_REQ ) ) == HREG_EV_SLEEP_REQ ) { // firmware indicates it would like to go into sleep modus // only acknowledge this request if no other events that can cause an interrupt are pending - ifbp->IFB_IntOffCnt--; //becomes 0xFFFE - OPW( HREG_INT_EN, i | HREG_EV_TICK ); + ifbp->IFB_IntOffCnt--; //becomes 0xFFFE + OPW( HREG_INT_EN, i | HREG_EV_TICK ); OPW( HREG_EV_ACK, HREG_EV_SLEEP_REQ | HREG_EV_TICK | HREG_EV_ACK_REG_READY ); } else #endif // HCF_SLEEP { - OPW( HREG_INT_EN, i | HREG_EV_SLEEP_REQ ); + OPW( HREG_INT_EN, i | HREG_EV_SLEEP_REQ ); } } break; #endif // HCF_INT_ON #if (HCF_SLEEP) & HCF_DDS - case HCF_ACT_SLEEP: // DDS Sleep request + case HCF_ACT_SLEEP: // DDS Sleep request hcf_cntl( ifbp, HCF_CNTL_DISABLE ); cmd_exe( ifbp, HCMD_SLEEP, 0 ); break; -// case HCF_ACT_WAKEUP: // DDS Wakeup request -// HCFASSERT( ifbp->IFB_IntOffCnt == 0xFFFE, ifbp->IFB_IntOffCnt ); -// ifbp->IFB_IntOffCnt++; // restore conventional I/F -// OPW( HREG_IO, HREG_IO_WAKEUP_ASYNC ); -// MSF_WAIT(800); // MSF-defined function to wait n microseconds. -// rc = hcf_action( ifbp, HCF_ACT_INT_OFF ); /*bogus, IFB_IntOffCnt == 0xFFFF, so if you carefully look -// *at the #if HCF_DDS statements, HCF_ACT_INT_OFF is empty -// *for DDS. "Much" better would be to merge the flows for -// *DDS and DEEP_SLEEP -// */ -// break; +// case HCF_ACT_WAKEUP: // DDS Wakeup request +// HCFASSERT( ifbp->IFB_IntOffCnt == 0xFFFE, ifbp->IFB_IntOffCnt ); +// ifbp->IFB_IntOffCnt++; // restore conventional I/F +// OPW( HREG_IO, HREG_IO_WAKEUP_ASYNC ); +// MSF_WAIT(800); // MSF-defined function to wait n microseconds. +// rc = hcf_action( ifbp, HCF_ACT_INT_OFF ); /*bogus, IFB_IntOffCnt == 0xFFFF, so if you carefully look +// *at the #if HCF_DDS statements, HCF_ACT_INT_OFF is empty +// *for DDS. "Much" better would be to merge the flows for +// *DDS and DEEP_SLEEP +// */ +// break; #endif // HCF_DDS #if (HCF_TYPE) & HCF_TYPE_CCX - case HCF_ACT_CCX_ON: // enable CKIP - case HCF_ACT_CCX_OFF: // disable CKIP + case HCF_ACT_CCX_ON: // enable CKIP + case HCF_ACT_CCX_OFF: // disable CKIP ifbp->IFB_CKIPStat = action; break; #endif // HCF_TYPE_CCX - case HCF_ACT_RX_ACK: //Receiver ACK -/*6*/ if ( ifbp->IFB_RxFID ) { + case HCF_ACT_RX_ACK: //Receiver ACK + /*6*/ if ( ifbp->IFB_RxFID ) { DAWA_ACK( HREG_EV_RX ); } ifbp->IFB_RxFID = ifbp->IFB_RxLen = 0; break; -/*8*/ case HCF_ACT_PRS_SCAN: // Hermes PRS Scan (F102) + /*8*/ case HCF_ACT_PRS_SCAN: // Hermes PRS Scan (F102) OPW( HREG_PARAM_1, 0x3FFF ); - //Fall through in HCF_ACT_TALLIES - case HCF_ACT_TALLIES: // Hermes Inquire Tallies (F100) + //Fall through in HCF_ACT_TALLIES + case HCF_ACT_TALLIES: // Hermes Inquire Tallies (F100) #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 - case HCF_ACT_SCAN: // Hermes Inquire Scan (F101) + case HCF_ACT_SCAN: // Hermes Inquire Scan (F101) #endif // HCF_TYPE_HII5 /*!! the assumptions about numerical relationships between CFG_TALLIES etc and HCF_ACT_TALLIES etc - * are checked by #if statements just prior to this routine resulting in: err "maintenance" */ + * are checked by #if statements just prior to this routine resulting in: err "maintenance" */ cmd_exe( ifbp, HCMD_INQUIRE, action - HCF_ACT_TALLIES + CFG_TALLIES ); break; - default: + default: HCFASSERT( DO_ASSERT, action ); break; } - //! do not HCFASSERT( rc == HCF_SUCCESS, rc ) /* 30*/ + //! do not HCFASSERT( rc == HCF_SUCCESS, rc ) /* 30*/ HCFLOGEXIT( HCF_TRACE_ACTION ); return rc; } // hcf_action @@ -839,137 +838,137 @@ hcf_16 i; /************************************************************************************************************ -* -*.MODULE int hcf_cntl( IFBP ifbp, hcf_16 cmd ) -*.PURPOSE Connect or disconnect a specific port to a specific network. -*!! ;???????????????? continue needs more explanation -* recovers by means of "continue" when the connect process in CCX mode fails -* Enables or disables data transmission and reception for the NIC. -* Activates static NIC configuration for a specific port at connect. -* Activates static configuration for all ports at enable. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* cmd 0x001F: Hermes command (disable, enable, connect, disconnect, continue) -* HCF_CNTL_ENABLE Enable -* HCF_CNTL_DISABLE Disable -* HCF_CNTL_CONTINUE Continue -* HCF_CNTL_CONNECT Connect -* HCF_CNTL_DISCONNECT Disconnect -* 0x0100: command qualifier (continue) -* HCMD_RETRY retry flag -* 0x0700: port number (connect/disconnect) -* HCF_PORT_0 MAC Port 0 -* HCF_PORT_1 MAC Port 1 -* HCF_PORT_2 MAC Port 2 -* HCF_PORT_3 MAC Port 3 -* HCF_PORT_4 MAC Port 4 -* HCF_PORT_5 MAC Port 5 -* HCF_PORT_6 MAC Port 6 -* -*.RETURNS -* HCF_SUCCESS -*!! via cmd_exe -* HCF_ERR_NO_NIC -* HCF_ERR_DEFUNCT_... -* HCF_ERR_TIME_OUT -* -*.DESCRIPTION -* The parameter cmd contains a number of subfields. -* The actual value for cmd is created by logical or-ing the appropriate mnemonics for the subfields. -* The field 0x001F contains the command code -* - HCF_CNTL_ENABLE -* - HCF_CNTL_DISABLE -* - HCF_CNTL_CONNECT -* - HCF_CNTL_DISCONNECT -* - HCF_CNTL_CONTINUE -* -* For HCF_CNTL_CONTINUE, the field 0x0100 contains the retry flag HCMD_RETRY. -* For HCF_CNTL_CONNECT and HCF_CNTL_DISCONNECT, the field 0x0700 contains the port number as HCF_PORT_#. -* For Station as well as AccessPoint F/W, MAC Port 0 is the "normal" communication channel. -* For AccessPoint F/W, MAC Port 1 through 6 control the WDS links. -* -* Note that despite the names HCF_CNTL_DISABLE and HCF_CNTL_ENABLE, hcf_cntl does not influence the NIC -* Interrupts mode. -* -* The Connect is used by the MSF to bring a particular port in an inactive state as far as data transmission -* and reception are concerned. -* When a particular port is disconnected: -* - the F/W disables the receiver for that port. -* - the F/W ignores send commands for that port. -* - all frames (Receive as well as pending Transmit) for that port on the NIC are discarded. -* -* When the NIC is disabled, above list applies to all ports, i.e. the result is like all ports are -* disconnected. -* -* When a particular port is connected: -* - the F/W effectuates the static configuration for that port. -* - enables the receiver for that port. -* - accepts send commands for that port. -* -* Enabling has the following effects: -* - the F/W effectuates the static configuration for all ports. -* The F/W only updates its static configuration at a transition from disabled to enabled or from -* disconnected to connected. -* In order to enforce the static configuration, the MSF must assure that such a transition takes place. -* Due to such a disable/enable or disconnect/connect sequence, Rx/Tx frames may be lost, in other words, -* configuration may impact communication. -* - The DMA Engine (if applicable) is enabled. -* Note that the Enable Function by itself only enables data transmission and reception, it -* does not enable the Interrupt Generation mechanism. This is done by hcf_action. -* -* Disabling has the following effects: -*!! ;?????is the following statement really true -* - it acts as a disconnect on all ports. -* - The DMA Engine (if applicable) is disabled. -* -* For impact of the disable command on the behavior of hcf_dma_tx/rx_get see the appropriate sections. -* -* Although the Enable/Disable and Connect/Disconnect are antonyms, there is no restriction on their sequencing, -* in other words, they may be called multiple times in arbitrary sequence without being paired or balanced. -* Each time one of these functions is called, the effects of the preceding calls cease. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value. -* - NIC interrupts are not disabled. -* - A command other than Continue, Enable, Disable, Connect or Disconnect is given. -* - An invalid combination of the subfields is given or a bit outside the subfields is given. -* - any return code besides HCF_SUCCESS. -* - reentrancy, may be caused by calling a hcf_function without adequate protection against NIC interrupts or -* multi-threading -* -*.DIAGRAM -* hcf_cntl takes successively the following actions: -*2: If the HCF is in Defunct mode or incompatible with the Primary or Station Supplier in the Hermes, -* hcf_cntl() returns immediately with HCF_ERR_NO_NIC;? as status. -*8: when the port is disabled, the DMA engine needs to be de-activated, so the host can safely reclaim tx -* packets from the tx descriptor chain. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE int hcf_cntl( IFBP ifbp, hcf_16 cmd ) + *.PURPOSE Connect or disconnect a specific port to a specific network. + *!! ;???????????????? continue needs more explanation + * recovers by means of "continue" when the connect process in CCX mode fails + * Enables or disables data transmission and reception for the NIC. + * Activates static NIC configuration for a specific port at connect. + * Activates static configuration for all ports at enable. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * cmd 0x001F: Hermes command (disable, enable, connect, disconnect, continue) + * HCF_CNTL_ENABLE Enable + * HCF_CNTL_DISABLE Disable + * HCF_CNTL_CONTINUE Continue + * HCF_CNTL_CONNECT Connect + * HCF_CNTL_DISCONNECT Disconnect + * 0x0100: command qualifier (continue) + * HCMD_RETRY retry flag + * 0x0700: port number (connect/disconnect) + * HCF_PORT_0 MAC Port 0 + * HCF_PORT_1 MAC Port 1 + * HCF_PORT_2 MAC Port 2 + * HCF_PORT_3 MAC Port 3 + * HCF_PORT_4 MAC Port 4 + * HCF_PORT_5 MAC Port 5 + * HCF_PORT_6 MAC Port 6 + * + *.RETURNS + * HCF_SUCCESS + *!! via cmd_exe + * HCF_ERR_NO_NIC + * HCF_ERR_DEFUNCT_... + * HCF_ERR_TIME_OUT + * + *.DESCRIPTION + * The parameter cmd contains a number of subfields. + * The actual value for cmd is created by logical or-ing the appropriate mnemonics for the subfields. + * The field 0x001F contains the command code + * - HCF_CNTL_ENABLE + * - HCF_CNTL_DISABLE + * - HCF_CNTL_CONNECT + * - HCF_CNTL_DISCONNECT + * - HCF_CNTL_CONTINUE + * + * For HCF_CNTL_CONTINUE, the field 0x0100 contains the retry flag HCMD_RETRY. + * For HCF_CNTL_CONNECT and HCF_CNTL_DISCONNECT, the field 0x0700 contains the port number as HCF_PORT_#. + * For Station as well as AccessPoint F/W, MAC Port 0 is the "normal" communication channel. + * For AccessPoint F/W, MAC Port 1 through 6 control the WDS links. + * + * Note that despite the names HCF_CNTL_DISABLE and HCF_CNTL_ENABLE, hcf_cntl does not influence the NIC + * Interrupts mode. + * + * The Connect is used by the MSF to bring a particular port in an inactive state as far as data transmission + * and reception are concerned. + * When a particular port is disconnected: + * - the F/W disables the receiver for that port. + * - the F/W ignores send commands for that port. + * - all frames (Receive as well as pending Transmit) for that port on the NIC are discarded. + * + * When the NIC is disabled, above list applies to all ports, i.e. the result is like all ports are + * disconnected. + * + * When a particular port is connected: + * - the F/W effectuates the static configuration for that port. + * - enables the receiver for that port. + * - accepts send commands for that port. + * + * Enabling has the following effects: + * - the F/W effectuates the static configuration for all ports. + * The F/W only updates its static configuration at a transition from disabled to enabled or from + * disconnected to connected. + * In order to enforce the static configuration, the MSF must assure that such a transition takes place. + * Due to such a disable/enable or disconnect/connect sequence, Rx/Tx frames may be lost, in other words, + * configuration may impact communication. + * - The DMA Engine (if applicable) is enabled. + * Note that the Enable Function by itself only enables data transmission and reception, it + * does not enable the Interrupt Generation mechanism. This is done by hcf_action. + * + * Disabling has the following effects: + *!! ;?????is the following statement really true + * - it acts as a disconnect on all ports. + * - The DMA Engine (if applicable) is disabled. + * + * For impact of the disable command on the behavior of hcf_dma_tx/rx_get see the appropriate sections. + * + * Although the Enable/Disable and Connect/Disconnect are antonyms, there is no restriction on their sequencing, + * in other words, they may be called multiple times in arbitrary sequence without being paired or balanced. + * Each time one of these functions is called, the effects of the preceding calls cease. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value. + * - NIC interrupts are not disabled. + * - A command other than Continue, Enable, Disable, Connect or Disconnect is given. + * - An invalid combination of the subfields is given or a bit outside the subfields is given. + * - any return code besides HCF_SUCCESS. + * - reentrancy, may be caused by calling a hcf_function without adequate protection against NIC interrupts or + * multi-threading + * + *.DIAGRAM + * hcf_cntl takes successively the following actions: + *2: If the HCF is in Defunct mode or incompatible with the Primary or Station Supplier in the Hermes, + * hcf_cntl() returns immediately with HCF_ERR_NO_NIC;? as status. + *8: when the port is disabled, the DMA engine needs to be de-activated, so the host can safely reclaim tx + * packets from the tx descriptor chain. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int hcf_cntl( IFBP ifbp, hcf_16 cmd ) { -int rc = HCF_ERR_INCOMP_FW; + int rc = HCF_ERR_INCOMP_FW; #if HCF_ASSERT -{ int x = cmd & HCMD_CMD_CODE; - if ( x == HCF_CNTL_CONTINUE ) x &= ~HCMD_RETRY; - else if ( (x == HCMD_DISABLE || x == HCMD_ENABLE) && ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ) { - x &= ~HFS_TX_CNTL_PORT; - } - HCFASSERT( x==HCF_CNTL_ENABLE || x==HCF_CNTL_DISABLE || HCF_CNTL_CONTINUE || + { int x = cmd & HCMD_CMD_CODE; + if ( x == HCF_CNTL_CONTINUE ) x &= ~HCMD_RETRY; + else if ( (x == HCMD_DISABLE || x == HCMD_ENABLE) && ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ) { + x &= ~HFS_TX_CNTL_PORT; + } + HCFASSERT( x==HCF_CNTL_ENABLE || x==HCF_CNTL_DISABLE || HCF_CNTL_CONTINUE || x==HCF_CNTL_CONNECT || x==HCF_CNTL_DISCONNECT, cmd ); -} + } #endif // HCF_ASSERT // #if (HCF_SLEEP) & HCF_DDS -// HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, cmd ); +// HCFASSERT( ifbp->IFB_IntOffCnt != 0xFFFE, cmd ); // #endif // HCF_DDS HCFLOGENTRY( HCF_TRACE_CNTL, cmd ); - if ( ifbp->IFB_CardStat == 0 ) { /*2*/ -/*6*/ rc = cmd_exe( ifbp, cmd, 0 ); + if ( ifbp->IFB_CardStat == 0 ) { /*2*/ + /*6*/ rc = cmd_exe( ifbp, cmd, 0 ); #if (HCF_SLEEP) & HCF_DDS - ifbp->IFB_TickCnt = 0; //start 2 second period (with 1 tick uncertanty) + ifbp->IFB_TickCnt = 0; //start 2 second period (with 1 tick uncertanty) #endif // HCF_DDS } #if HCF_DMA @@ -980,7 +979,7 @@ int rc = HCF_ERR_INCOMP_FW; hcf_io io_port = ifbp->IFB_IOBase; DESC_STRCT *p; if ( cmd == HCF_CNTL_DISABLE || cmd == HCF_CNTL_ENABLE ) { - OUT_PORT_DWORD( (io_port + HREG_DMA_CTRL), DMA_CTRLSTAT_RESET); /*8*/ + OUT_PORT_DWORD( (io_port + HREG_DMA_CTRL), DMA_CTRLSTAT_RESET); /*8*/ ifbp->IFB_CntlOpt &= ~DMA_ENABLED; } if ( cmd == HCF_CNTL_ENABLE ) { @@ -993,7 +992,7 @@ int rc = HCF_ERR_INCOMP_FW; // make the entire rx descriptor chain DMA-owned, so the DMA engine can (re-)use it. p = ifbp->IFB_FirstDesc[DMA_RX]; if (p != NULL) { //;? Think this over again in the light of the new chaining strategy - if ( 1 ) { //begin alternative + if ( 1 ) { //begin alternative HCFASSERT( NT_ASSERT, NEVER_TESTED ); put_frame_lst( ifbp, ifbp->IFB_FirstDesc[DMA_RX], DMA_RX ); if ( ifbp->IFB_FirstDesc[DMA_RX] ) { @@ -1020,140 +1019,140 @@ int rc = HCF_ERR_INCOMP_FW; /************************************************************************************************************ -* -*.MODULE int hcf_connect( IFBP ifbp, hcf_io io_base ) -*.PURPOSE Grants access right for the HCF to the IFB. -* Initializes Card and HCF housekeeping. -* -*.ARGUMENTS -* ifbp (near) address of the Interface Block -* io_base non-USB: I/O Base address of the NIC (connect) -* non-USB: HCF_DISCONNECT -* USB: HCF_CONNECT, HCF_DISCONNECT -* -*.RETURNS -* HCF_SUCCESS -* HCF_ERR_INCOMP_PRI -* HCF_ERR_INCOMP_FW -* HCF_ERR_DEFUNCT_CMD_SEQ -*!! HCF_ERR_NO_NIC really returned ;? -* HCF_ERR_NO_NIC -* HCF_ERR_TIME_OUT -* -* MSF-accessible fields of Result Block: -* IFB_IOBase entry parameter io_base -* IFB_IORange HREG_IO_RANGE (0x40/0x80) -* IFB_Version version of the IFB layout -* IFB_FWIdentity CFG_FW_IDENTITY_STRCT, specifies the identity of the -* "running" F/W, i.e. tertiary F/W under normal conditions -* IFB_FWSup CFG_SUP_RANGE_STRCT, specifies the supplier range of -* the "running" F/W, i.e. tertiary F/W under normal conditions -* IFB_HSISup CFG_SUP_RANGE_STRCT, specifies the HW/SW I/F range of the NIC -* IFB_PRIIdentity CFG_PRI_IDENTITY_STRCT, specifies the Identity of the Primary F/W -* IFB_PRISup CFG_SUP_RANGE_STRCT, specifies the supplier range of the Primary F/W -* all other all MSF accessible fields, which are not specified above, are zero-filled -* -*.CONDITIONS -* It is the responsibility of the MSF to assure the correctness of the I/O Base address. -* -* Note: hcf_connect defaults to NIC interrupt disabled mode, i.e. as if hcf_action( HCF_ACT_INT_OFF ) -* was called. -* -*.DESCRIPTION -* hcf_connect passes the MSF-defined location of the IFB to the HCF and grants or revokes access right for the -* HCF to the IFB. Revoking is done by specifying HCF_DISCONNECT rather than an I/O address for the parameter -* io_base. Every call of hcf_connect in "connect" mode, must eventually be followed by a call of hcf_connect -* in "disconnect" mode. Clalling hcf_connect in "connect"/"disconnect" mode can not be nested. -* The IFB address must be used as a handle with all subsequent HCF-function calls and the HCF uses the IFB -* address as a handle when it performs a call(back) of an MSF-function (i.e. msf_assert). -* -* Note that not only the MSF accessible fields are cleared, but also all internal housekeeping -* information is re-initialized. -* This implies that all settings which are done via hcf_action and hcf_put_info (e.g. CFG_MB_ASSERT, CFG_REG_MB, -* CFG_REG_INFO_LOG) must be done again. The only field which is not cleared, is IFB_MSFSup. -* -* If HCF_INT_ON is selected as compile option, NIC interrupts are disabled. -* -* Assert fails if -* - ifbp is not properly aligned ( ref chapter HCF_ALIGN in 4.1.1) -* - I/O Base Address is not a multiple of 0x40 (note: 0x0000 is explicitly allowed). -* -*.DIAGRAM -* -*0: Throughout hcf_connect you need to distinguish the connect from the disconnect case, which requires -* some attention about what to use as "I/O" address when for which purpose. -*2: -*2a: Reset H-II by toggling reset bit in IO-register on and off. -* The HCF_TYPE_PRELOADED caters for the DOS environment where H-II is loaded by a separate program to -* overcome the 64k size limit posed on DOS drivers. -* The macro OPW is not yet useable because the IFB_IOBase field is not set. -* Note 1: hopefully the clearing and initializing of the IFB (see below) acts as a delay which meets the -* specification for S/W reset -* Note 2: it turns out that on some H/W constellations, the clock to access the EEProm is not lowered -* to an appropriate frequency by HREG_IO_SRESET. By giving an HCMD_INI first, this problem is worked around. -*2b: Experimentally it is determined over a wide range of F/W versions that waiting for the for Cmd bit in -* Ev register gives a workable strategy. The available documentation does not give much clues. -*4: clear and initialize the IFB -* The HCF house keeping info is designed such that zero is the appropriate initial value for as much as -* feasible IFB-items. -* The readable fields mentioned in the description section and some HCF specific fields are given their -* actual value. -* IFB_TickIni is initialized at best guess before calibration -* Hcf_connect defaults to "no interrupt generation" (implicitly achieved by the zero-filling). -*6: Register compile-time linked MSF Routine and set default filter level -* cast needed to get around the "near" problem in DOS COM model -* er C2446: no conversion from void (__near __cdecl *)(unsigned char __far *,unsigned int,unsigned short,int) -* to void (__far __cdecl *)(unsigned char __far *,unsigned int,unsigned short,int) -*8: If a command is apparently still active (as indicated by the Busy bit in Cmd register) this may indicate a -* blocked cmd pipe line. To unblock the following actions are done: -* - Ack everything -* - Wait for Busy bit drop in Cmd register -* - Wait for Cmd bit raise in Ev register -* The two waits are combined in a single HCF_WAIT_WHILE to optimize memory size. If either of these waits -* fail (prot_cnt becomes 0), then something is serious wrong. Rather than PANICK, the assumption is that the -* next cmd_exe will fail, causing the HCF to go into DEFUNCT mode -*10: Ack everything to unblock a (possibly blocked) cmd pipe line -* Note 1: it is very likely that an Alloc event is pending and very well possible that a (Send) Cmd event is -* pending on non-initial calls -* Note 2: it is assumed that this strategy takes away the need to ack every conceivable event after an -* Hermes Initialize -*12: Only H-II NEEDS the Hermes Initialize command. Due to the different semantics for H-I and H-II -* Initialize command, init() does not (and can not, since it is called e.g. after a download) execute the -* Hermes Initialize command. Executing the Hermes Initialize command for H-I would not harm but not do -* anything useful either, so it is skipped. -* The return status of cmd_exe is ignored. It is assumed that if cmd_exe fails, init fails too -*14: use io_base as a flag to merge hcf_connect and hcf_disconnect into 1 routine -* the call to init and its subsequent call of cmd_exe will return HCF_ERR_NO_NIC if appropriate. This status -* is (badly) needed by some legacy combination of NT4 and card services which do not yield an I/O address in -* time. -* -*.NOTICE -* On platforms where the NULL-pointer is not a bit-pattern of all zeros, the zero-filling of the IFB results -* in an incorrect initialization of pointers. -* The implementation of the MailBox manipulation in put_mb_info protects against the absence of a MailBox -* based on IFB_MBSize, IFB_MBWp and ifbp->IFB_MBRp. This has ramifications on the initialization of the -* MailBox via hcf_put_info with the CFG_REG_MB type, but it prevents dependency on the "NULL-"ness of -* IFB_MBp. -* -*.NOTICE -* There are a number of problems when asserting and logging hcf_connect, e.g. -* - Asserting on re-entrancy of hcf_connect by means of -* "HCFASSERT( (ifbp->IFB_AssertTrace & HCF_ASSERT_CONNECT) == 0, 0 )" is not useful because IFB contents -* are undefined -* - Asserting before the IFB is cleared will cause mdd_assert() to interpret the garbage in IFB_AssertRtn -* as a routine address -* Therefore HCFTRACE nor HCFLOGENTRY is called by hcf_connect. -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE int hcf_connect( IFBP ifbp, hcf_io io_base ) + *.PURPOSE Grants access right for the HCF to the IFB. + * Initializes Card and HCF housekeeping. + * + *.ARGUMENTS + * ifbp (near) address of the Interface Block + * io_base non-USB: I/O Base address of the NIC (connect) + * non-USB: HCF_DISCONNECT + * USB: HCF_CONNECT, HCF_DISCONNECT + * + *.RETURNS + * HCF_SUCCESS + * HCF_ERR_INCOMP_PRI + * HCF_ERR_INCOMP_FW + * HCF_ERR_DEFUNCT_CMD_SEQ + *!! HCF_ERR_NO_NIC really returned ;? + * HCF_ERR_NO_NIC + * HCF_ERR_TIME_OUT + * + * MSF-accessible fields of Result Block: + * IFB_IOBase entry parameter io_base + * IFB_IORange HREG_IO_RANGE (0x40/0x80) + * IFB_Version version of the IFB layout + * IFB_FWIdentity CFG_FW_IDENTITY_STRCT, specifies the identity of the + * "running" F/W, i.e. tertiary F/W under normal conditions + * IFB_FWSup CFG_SUP_RANGE_STRCT, specifies the supplier range of + * the "running" F/W, i.e. tertiary F/W under normal conditions + * IFB_HSISup CFG_SUP_RANGE_STRCT, specifies the HW/SW I/F range of the NIC + * IFB_PRIIdentity CFG_PRI_IDENTITY_STRCT, specifies the Identity of the Primary F/W + * IFB_PRISup CFG_SUP_RANGE_STRCT, specifies the supplier range of the Primary F/W + * all other all MSF accessible fields, which are not specified above, are zero-filled + * + *.CONDITIONS + * It is the responsibility of the MSF to assure the correctness of the I/O Base address. + * + * Note: hcf_connect defaults to NIC interrupt disabled mode, i.e. as if hcf_action( HCF_ACT_INT_OFF ) + * was called. + * + *.DESCRIPTION + * hcf_connect passes the MSF-defined location of the IFB to the HCF and grants or revokes access right for the + * HCF to the IFB. Revoking is done by specifying HCF_DISCONNECT rather than an I/O address for the parameter + * io_base. Every call of hcf_connect in "connect" mode, must eventually be followed by a call of hcf_connect + * in "disconnect" mode. Clalling hcf_connect in "connect"/"disconnect" mode can not be nested. + * The IFB address must be used as a handle with all subsequent HCF-function calls and the HCF uses the IFB + * address as a handle when it performs a call(back) of an MSF-function (i.e. msf_assert). + * + * Note that not only the MSF accessible fields are cleared, but also all internal housekeeping + * information is re-initialized. + * This implies that all settings which are done via hcf_action and hcf_put_info (e.g. CFG_MB_ASSERT, CFG_REG_MB, + * CFG_REG_INFO_LOG) must be done again. The only field which is not cleared, is IFB_MSFSup. + * + * If HCF_INT_ON is selected as compile option, NIC interrupts are disabled. + * + * Assert fails if + * - ifbp is not properly aligned ( ref chapter HCF_ALIGN in 4.1.1) + * - I/O Base Address is not a multiple of 0x40 (note: 0x0000 is explicitly allowed). + * + *.DIAGRAM + * + *0: Throughout hcf_connect you need to distinguish the connect from the disconnect case, which requires + * some attention about what to use as "I/O" address when for which purpose. + *2: + *2a: Reset H-II by toggling reset bit in IO-register on and off. + * The HCF_TYPE_PRELOADED caters for the DOS environment where H-II is loaded by a separate program to + * overcome the 64k size limit posed on DOS drivers. + * The macro OPW is not yet useable because the IFB_IOBase field is not set. + * Note 1: hopefully the clearing and initializing of the IFB (see below) acts as a delay which meets the + * specification for S/W reset + * Note 2: it turns out that on some H/W constellations, the clock to access the EEProm is not lowered + * to an appropriate frequency by HREG_IO_SRESET. By giving an HCMD_INI first, this problem is worked around. + *2b: Experimentally it is determined over a wide range of F/W versions that waiting for the for Cmd bit in + * Ev register gives a workable strategy. The available documentation does not give much clues. + *4: clear and initialize the IFB + * The HCF house keeping info is designed such that zero is the appropriate initial value for as much as + * feasible IFB-items. + * The readable fields mentioned in the description section and some HCF specific fields are given their + * actual value. + * IFB_TickIni is initialized at best guess before calibration + * Hcf_connect defaults to "no interrupt generation" (implicitly achieved by the zero-filling). + *6: Register compile-time linked MSF Routine and set default filter level + * cast needed to get around the "near" problem in DOS COM model + * er C2446: no conversion from void (__near __cdecl *)(unsigned char __far *,unsigned int,unsigned short,int) + * to void (__far __cdecl *)(unsigned char __far *,unsigned int,unsigned short,int) + *8: If a command is apparently still active (as indicated by the Busy bit in Cmd register) this may indicate a + * blocked cmd pipe line. To unblock the following actions are done: + * - Ack everything + * - Wait for Busy bit drop in Cmd register + * - Wait for Cmd bit raise in Ev register + * The two waits are combined in a single HCF_WAIT_WHILE to optimize memory size. If either of these waits + * fail (prot_cnt becomes 0), then something is serious wrong. Rather than PANICK, the assumption is that the + * next cmd_exe will fail, causing the HCF to go into DEFUNCT mode + *10: Ack everything to unblock a (possibly blocked) cmd pipe line + * Note 1: it is very likely that an Alloc event is pending and very well possible that a (Send) Cmd event is + * pending on non-initial calls + * Note 2: it is assumed that this strategy takes away the need to ack every conceivable event after an + * Hermes Initialize + *12: Only H-II NEEDS the Hermes Initialize command. Due to the different semantics for H-I and H-II + * Initialize command, init() does not (and can not, since it is called e.g. after a download) execute the + * Hermes Initialize command. Executing the Hermes Initialize command for H-I would not harm but not do + * anything useful either, so it is skipped. + * The return status of cmd_exe is ignored. It is assumed that if cmd_exe fails, init fails too + *14: use io_base as a flag to merge hcf_connect and hcf_disconnect into 1 routine + * the call to init and its subsequent call of cmd_exe will return HCF_ERR_NO_NIC if appropriate. This status + * is (badly) needed by some legacy combination of NT4 and card services which do not yield an I/O address in + * time. + * + *.NOTICE + * On platforms where the NULL-pointer is not a bit-pattern of all zeros, the zero-filling of the IFB results + * in an incorrect initialization of pointers. + * The implementation of the MailBox manipulation in put_mb_info protects against the absence of a MailBox + * based on IFB_MBSize, IFB_MBWp and ifbp->IFB_MBRp. This has ramifications on the initialization of the + * MailBox via hcf_put_info with the CFG_REG_MB type, but it prevents dependency on the "NULL-"ness of + * IFB_MBp. + * + *.NOTICE + * There are a number of problems when asserting and logging hcf_connect, e.g. + * - Asserting on re-entrancy of hcf_connect by means of + * "HCFASSERT( (ifbp->IFB_AssertTrace & HCF_ASSERT_CONNECT) == 0, 0 )" is not useful because IFB contents + * are undefined + * - Asserting before the IFB is cleared will cause mdd_assert() to interpret the garbage in IFB_AssertRtn + * as a routine address + * Therefore HCFTRACE nor HCFLOGENTRY is called by hcf_connect. + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int hcf_connect( IFBP ifbp, hcf_io io_base ) { -int rc = HCF_SUCCESS; -hcf_io io_addr; -hcf_32 prot_cnt; -hcf_8 *q; -LTV_STRCT x; + int rc = HCF_SUCCESS; + hcf_io io_addr; + hcf_32 prot_cnt; + hcf_8 *q; + LTV_STRCT x; #if HCF_ASSERT hcf_16 xa = ifbp->IFB_FWIdentity.typ; /* is assumed to cause an assert later on if hcf_connect is called without intervening hcf_disconnect. @@ -1163,51 +1162,51 @@ LTV_STRCT x; */ #endif // HCF_ASSERT - if ( io_base == HCF_DISCONNECT ) { //disconnect + if ( io_base == HCF_DISCONNECT ) { //disconnect io_addr = ifbp->IFB_IOBase; - OPW( HREG_INT_EN, 0 ); //;?workaround against dying F/W on subsequent hcf_connect calls - } else { //connect /* 0 */ + OPW( HREG_INT_EN, 0 ); //;?workaround against dying F/W on subsequent hcf_connect calls + } else { //connect /* 0 */ io_addr = io_base; } #if 0 //;? if a subsequent hcf_connect is preceded by an hcf_disconnect the wakeup is not needed !! #if HCF_SLEEP - OUT_PORT_WORD( .....+HREG_IO, HREG_IO_WAKEUP_ASYNC ); //OPW not yet useable - MSF_WAIT(800); // MSF-defined function to wait n microseconds. + OUT_PORT_WORD( .....+HREG_IO, HREG_IO_WAKEUP_ASYNC ); //OPW not yet useable + MSF_WAIT(800); // MSF-defined function to wait n microseconds. note that MSF_WAIT uses not yet defined!!!! IFB_IOBase and IFB_TickIni (via PROT_CNT_INI) so be careful if this code is restored #endif // HCF_SLEEP #endif // 0 -#if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 //switch clock back for SEEPROM access !!! - OUT_PORT_WORD( io_addr + HREG_CMD, HCMD_INI ); //OPW not yet useable +#if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 //switch clock back for SEEPROM access !!! + OUT_PORT_WORD( io_addr + HREG_CMD, HCMD_INI ); //OPW not yet useable prot_cnt = INI_TICK_INI; HCF_WAIT_WHILE( (IN_PORT_WORD( io_addr + HREG_EV_STAT) & HREG_EV_CMD) == 0 ); - OUT_PORT_WORD( (io_addr + HREG_IO), HREG_IO_SRESET ); //OPW not yet useable /* 2a*/ + OUT_PORT_WORD( (io_addr + HREG_IO), HREG_IO_SRESET ); //OPW not yet useable /* 2a*/ #endif // HCF_TYPE_PRELOADED - for ( q = (hcf_8*)(&ifbp->IFB_Magic); q > (hcf_8*)ifbp; *--q = 0 ) /*NOP*/; /* 4 */ - ifbp->IFB_Magic = HCF_MAGIC; - ifbp->IFB_Version = IFB_VERSION; + for ( q = (hcf_8*)(&ifbp->IFB_Magic); q > (hcf_8*)ifbp; *--q = 0 ) /*NOP*/; /* 4 */ + ifbp->IFB_Magic = HCF_MAGIC; + ifbp->IFB_Version = IFB_VERSION; #if defined MSF_COMPONENT_ID //a new IFB demonstrates how dirty the solution is - xxxx[xxxx_PRI_IDENTITY_OFFSET] = NULL; //IFB_PRIIdentity placeholder 0xFD02 - xxxx[xxxx_PRI_IDENTITY_OFFSET+1] = NULL; //IFB_PRISup placeholder 0xFD03 + xxxx[xxxx_PRI_IDENTITY_OFFSET] = NULL; //IFB_PRIIdentity placeholder 0xFD02 + xxxx[xxxx_PRI_IDENTITY_OFFSET+1] = NULL; //IFB_PRISup placeholder 0xFD03 #endif // MSF_COMPONENT_ID #if (HCF_TALLIES) & ( HCF_TALLIES_NIC | HCF_TALLIES_HCF ) - ifbp->IFB_TallyLen = 1 + 2 * (HCF_NIC_TAL_CNT + HCF_HCF_TAL_CNT); //convert # of Tallies to L value for LTV - ifbp->IFB_TallyTyp = CFG_TALLIES; //IFB_TallyTyp: set T value + ifbp->IFB_TallyLen = 1 + 2 * (HCF_NIC_TAL_CNT + HCF_HCF_TAL_CNT); //convert # of Tallies to L value for LTV + ifbp->IFB_TallyTyp = CFG_TALLIES; //IFB_TallyTyp: set T value #endif // HCF_TALLIES_NIC / HCF_TALLIES_HCF - ifbp->IFB_IOBase = io_addr; //set IO_Base asap, so asserts via HREG_SW_2 don't harm - ifbp->IFB_IORange = HREG_IO_RANGE; - ifbp->IFB_CntlOpt = USE_16BIT; + ifbp->IFB_IOBase = io_addr; //set IO_Base asap, so asserts via HREG_SW_2 don't harm + ifbp->IFB_IORange = HREG_IO_RANGE; + ifbp->IFB_CntlOpt = USE_16BIT; #if HCF_ASSERT assert_ifbp = ifbp; ifbp->IFB_AssertLvl = 1; #if (HCF_ASSERT) & HCF_ASSERT_LNK_MSF_RTN if ( io_base != HCF_DISCONNECT ) { - ifbp->IFB_AssertRtn = (MSF_ASSERT_RTNP)msf_assert; /* 6 */ + ifbp->IFB_AssertRtn = (MSF_ASSERT_RTNP)msf_assert; /* 6 */ } #endif // HCF_ASSERT_LNK_MSF_RTN -#if (HCF_ASSERT) & HCF_ASSERT_MB //build the structure to pass the assert info to hcf_put_info +#if (HCF_ASSERT) & HCF_ASSERT_MB //build the structure to pass the assert info to hcf_put_info ifbp->IFB_AssertStrct.len = sizeof(ifbp->IFB_AssertStrct)/sizeof(hcf_16) - 1; ifbp->IFB_AssertStrct.typ = CFG_MB_INFO; ifbp->IFB_AssertStrct.base_typ = CFG_MB_ASSERT; @@ -1220,31 +1219,31 @@ LTV_STRCT x; IF_PROT_TIME( prot_cnt = ifbp->IFB_TickIni = INI_TICK_INI ); #if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 //!! No asserts before Reset-bit in HREG_IO is cleared - OPW( HREG_IO, 0x0000 ); //OPW useable /* 2b*/ + OPW( HREG_IO, 0x0000 ); //OPW useable /* 2b*/ HCF_WAIT_WHILE( (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ); IF_PROT_TIME( if ( prot_cnt ) prot_cnt = ifbp->IFB_TickIni ); #endif // HCF_TYPE_PRELOADED //!! No asserts before Reset-bit in HREG_IO is cleared - HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF0 ) ); //just to proof that the complete assert machinery is working - HCFASSERT( xa != CFG_FW_IDENTITY, 0 ); // assert if hcf_connect is called without intervening hcf_disconnect. + HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF0 ) ); //just to proof that the complete assert machinery is working + HCFASSERT( xa != CFG_FW_IDENTITY, 0 ); // assert if hcf_connect is called without intervening hcf_disconnect. HCFASSERT( ((hcf_32)(void*)ifbp & (HCF_ALIGN-1) ) == 0, (hcf_32)(void*)ifbp ); HCFASSERT( (io_addr & 0x003F) == 0, io_addr ); - //if Busy bit in Cmd register - if (IPW( HREG_CMD ) & HCMD_BUSY ) { /* 8 */ - //. Ack all to unblock a (possibly) blocked cmd pipe line + //if Busy bit in Cmd register + if (IPW( HREG_CMD ) & HCMD_BUSY ) { /* 8 */ + //. Ack all to unblock a (possibly) blocked cmd pipe line OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); - //. Wait for Busy bit drop in Cmd register - //. Wait for Cmd bit raise in Ev register + //. Wait for Busy bit drop in Cmd register + //. Wait for Cmd bit raise in Ev register HCF_WAIT_WHILE( ( IPW( HREG_CMD ) & HCMD_BUSY ) && (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); IF_PROT_TIME( HCFASSERT( prot_cnt, IPW( HREG_EV_STAT) ) ); /* if prot_cnt == 0, cmd_exe will fail, causing DEFUNCT */ } OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); -#if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 /*12*/ +#if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 /*12*/ (void)cmd_exe( ifbp, HCMD_INI, 0 ); #endif // HCF_TYPE_PRELOADED -if ( io_base != HCF_DISCONNECT ) { - rc = init( ifbp ); /*14*/ + if ( io_base != HCF_DISCONNECT ) { + rc = init( ifbp ); /*14*/ if ( rc == HCF_SUCCESS ) { x.len = 2; x.typ = CFG_NIC_BUS_TYPE; @@ -1253,10 +1252,10 @@ if ( io_base != HCF_DISCONNECT ) { //CFG_NIC_BUS_TYPE not supported -> default 32 bits/DMA, MSF has to overrule via CFG_CNTL_OPT if ( x.len == 0 || x.val[0] == 0x0002 || x.val[0] == 0x0003 ) { #if (HCF_IO) & HCF_IO_32BITS - ifbp->IFB_CntlOpt &= ~USE_16BIT; //reset USE_16BIT + ifbp->IFB_CntlOpt &= ~USE_16BIT; //reset USE_16BIT #endif // HCF_IO_32BITS #if HCF_DMA - ifbp->IFB_CntlOpt |= USE_DMA; //SET DMA + ifbp->IFB_CntlOpt |= USE_DMA; //SET DMA #else ifbp->IFB_IORange = 0x40 /*i.s.o. HREG_IO_RANGE*/; #endif // HCF_DMA @@ -1264,147 +1263,147 @@ if ( io_base != HCF_DISCONNECT ) { } } else HCFASSERT( ( ifbp->IFB_Magic ^= HCF_MAGIC ) == 0, ifbp->IFB_Magic ) /*NOP*/; /* of above HCFASSERT only the side effect is needed, NOP in case HCFASSERT is dummy */ - ifbp->IFB_IOBase = io_base; /* 0*/ + ifbp->IFB_IOBase = io_base; /* 0*/ return rc; } // hcf_connect #if HCF_DMA /************************************************************************************************************ -* Function get_frame_lst -* - resolve the "last host-owned descriptor" problems when a descriptor list is reclaimed by the MSF. -* -* The FrameList to be reclaimed as well as the DescriptorList always start in IFB_FirstDesc[tx_rx_flag] -* and this is always the "current" DELWA Descriptor. -* -* If a FrameList is available, the last descriptor of the FrameList to turned into a new DELWA Descriptor: -* - a copy is made from the information in the last descriptor of the FrameList into the current -* DELWA Descriptor -* - the remainder of the DescriptorList is detached from the copy by setting the next_desc_addr at NULL -* - the DMA control bits of the copy are cleared to do not confuse the MSF -* - the copy of the last descriptor (i.e. the "old" DELWA Descriptor) is chained to the prev Descriptor -* of the FrameList, thus replacing the original last Descriptor of the FrameList. -* - IFB_FirstDesc is changed to the address of that replaced (original) last descriptor of the FrameList, -* i.e. the "new" DELWA Descriptor. -* -* This function makes a copy of that last host-owned descriptor, so the MSF will get a copy of the descriptor. -* On top of that, it adjusts DMA related fields in the IFB structure. - // perform a copying-scheme to circumvent the 'last host owned descriptor cannot be reclaimed' limitation imposed by H2.5's DMA hardware design - // a 'reclaim descriptor' should be available in the HCF: -* -* Returns: address of the first descriptor of the FrameList -* + * Function get_frame_lst + * - resolve the "last host-owned descriptor" problems when a descriptor list is reclaimed by the MSF. + * + * The FrameList to be reclaimed as well as the DescriptorList always start in IFB_FirstDesc[tx_rx_flag] + * and this is always the "current" DELWA Descriptor. + * + * If a FrameList is available, the last descriptor of the FrameList to turned into a new DELWA Descriptor: + * - a copy is made from the information in the last descriptor of the FrameList into the current + * DELWA Descriptor + * - the remainder of the DescriptorList is detached from the copy by setting the next_desc_addr at NULL + * - the DMA control bits of the copy are cleared to do not confuse the MSF + * - the copy of the last descriptor (i.e. the "old" DELWA Descriptor) is chained to the prev Descriptor + * of the FrameList, thus replacing the original last Descriptor of the FrameList. + * - IFB_FirstDesc is changed to the address of that replaced (original) last descriptor of the FrameList, + * i.e. the "new" DELWA Descriptor. + * + * This function makes a copy of that last host-owned descriptor, so the MSF will get a copy of the descriptor. + * On top of that, it adjusts DMA related fields in the IFB structure. + // perform a copying-scheme to circumvent the 'last host owned descriptor cannot be reclaimed' limitation imposed by H2.5's DMA hardware design + // a 'reclaim descriptor' should be available in the HCF: + * + * Returns: address of the first descriptor of the FrameList + * 8: Be careful once you start re-ordering the steps in the copy process, that it still works for cases -* of FrameLists of 1, 2 and more than 2 descriptors -* -* Input parameters: -* tx_rx_flag : specifies 'transmit' or 'receive' descriptor. -* -************************************************************************************************************/ + * of FrameLists of 1, 2 and more than 2 descriptors + * + * Input parameters: + * tx_rx_flag : specifies 'transmit' or 'receive' descriptor. + * + ************************************************************************************************************/ HCF_STATIC DESC_STRCT* get_frame_lst( IFBP ifbp, int tx_rx_flag ) { -DESC_STRCT *head = ifbp->IFB_FirstDesc[tx_rx_flag]; -DESC_STRCT *copy, *p, *prev; + DESC_STRCT *head = ifbp->IFB_FirstDesc[tx_rx_flag]; + DESC_STRCT *copy, *p, *prev; HCFASSERT( tx_rx_flag == DMA_RX || tx_rx_flag == DMA_TX, tx_rx_flag ); - //if FrameList + //if FrameList if ( head ) { - //. search for last descriptor of first FrameList + //. search for last descriptor of first FrameList p = prev = head; while ( ( p->BUF_SIZE & DESC_EOP ) == 0 && p->next_desc_addr ) { - if ( ( ifbp->IFB_CntlOpt & DMA_ENABLED ) == 0 ) { //clear control bits when disabled + if ( ( ifbp->IFB_CntlOpt & DMA_ENABLED ) == 0 ) { //clear control bits when disabled p->BUF_CNT &= DESC_CNT_MASK; } prev = p; p = p->next_desc_addr; } - //. if DMA enabled + //. if DMA enabled if ( ifbp->IFB_CntlOpt & DMA_ENABLED ) { - //. . if last descriptor of FrameList is DMA owned - //. . or if FrameList is single (DELWA) Descriptor + //. . if last descriptor of FrameList is DMA owned + //. . or if FrameList is single (DELWA) Descriptor if ( p->BUF_CNT & DESC_DMA_OWNED || head->next_desc_addr == NULL ) { - //. . . refuse to return FrameList to caller + //. . . refuse to return FrameList to caller head = NULL; } } } - //if returnable FrameList found + //if returnable FrameList found if ( head ) { - //. if FrameList is single (DELWA) Descriptor (implies DMA disabled) - if ( head->next_desc_addr == NULL ) { - //. . clear DescriptorList + //. if FrameList is single (DELWA) Descriptor (implies DMA disabled) + if ( head->next_desc_addr == NULL ) { + //. . clear DescriptorList /*;?ifbp->IFB_LastDesc[tx_rx_flag] =*/ ifbp->IFB_FirstDesc[tx_rx_flag] = NULL; - //. else + //. else } else { - //. . strip hardware-related bits from last descriptor - //. . remove DELWA Descriptor from head of DescriptorList + //. . strip hardware-related bits from last descriptor + //. . remove DELWA Descriptor from head of DescriptorList copy = head; - head = head->next_desc_addr; - //. . exchange first (Confined) and last (possibly imprisoned) Descriptor + head = head->next_desc_addr; + //. . exchange first (Confined) and last (possibly imprisoned) Descriptor copy->buf_phys_addr = p->buf_phys_addr; copy->buf_addr = p->buf_addr; - copy->BUF_SIZE = p->BUF_SIZE &= DESC_CNT_MASK; //get rid of DESC_EOP and possibly DESC_SOP - copy->BUF_CNT = p->BUF_CNT &= DESC_CNT_MASK; //get rid of DESC_DMA_OWNED + copy->BUF_SIZE = p->BUF_SIZE &= DESC_CNT_MASK; //get rid of DESC_EOP and possibly DESC_SOP + copy->BUF_CNT = p->BUF_CNT &= DESC_CNT_MASK; //get rid of DESC_DMA_OWNED #if (HCF_EXT) & HCF_DESC_STRCT_EXT copy->DESC_MSFSup = p->DESC_MSFSup; #endif // HCF_DESC_STRCT_EXT - //. . turn into a DELWA Descriptor + //. . turn into a DELWA Descriptor p->buf_addr = NULL; - //. . chain copy to prev /* 8*/ + //. . chain copy to prev /* 8*/ prev->next_desc_addr = copy; - //. . detach remainder of the DescriptorList from FrameList + //. . detach remainder of the DescriptorList from FrameList copy->next_desc_addr = NULL; copy->next_desc_phys_addr = 0xDEAD0000; //! just to be nice, not really needed - //. . save the new start (i.e. DELWA Descriptor) in IFB_FirstDesc + //. . save the new start (i.e. DELWA Descriptor) in IFB_FirstDesc ifbp->IFB_FirstDesc[tx_rx_flag] = p; } - //. strip DESC_SOP from first descriptor + //. strip DESC_SOP from first descriptor head->BUF_SIZE &= DESC_CNT_MASK; //head->BUF_CNT &= DESC_CNT_MASK; get rid of DESC_DMA_OWNED head->next_desc_phys_addr = 0xDEAD0000; //! just to be nice, not really needed } - //return the just detached FrameList (if any) + //return the just detached FrameList (if any) return head; } // get_frame_lst /************************************************************************************************************ -* Function put_frame_lst -* -* This function -* -* Returns: address of the first descriptor of the FrameList -* -* Input parameters: -* tx_rx_flag : specifies 'transmit' or 'receive' descriptor. -* -* The following list should be kept in sync with hcf_dma_tx/rx_put, in order to get them in the WCI-spec !!!! -* Assert fails if -* - DMA is not enabled -* - descriptor list is NULL -* - a descriptor in the descriptor list is not double word aligned -* - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. -* - the DELWA descriptor is not a "singleton" DescriptorList. -* - the DELWA descriptor is not the first Descriptor supplied -* - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied -* - Possibly more checks could be added !!!!!!!!!!!!! + * Function put_frame_lst + * + * This function + * + * Returns: address of the first descriptor of the FrameList + * + * Input parameters: + * tx_rx_flag : specifies 'transmit' or 'receive' descriptor. + * + * The following list should be kept in sync with hcf_dma_tx/rx_put, in order to get them in the WCI-spec !!!! + * Assert fails if + * - DMA is not enabled + * - descriptor list is NULL + * - a descriptor in the descriptor list is not double word aligned + * - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. + * - the DELWA descriptor is not a "singleton" DescriptorList. + * - the DELWA descriptor is not the first Descriptor supplied + * - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied + * - Possibly more checks could be added !!!!!!!!!!!!! -*.NOTICE -* The asserts marked with *sc* are really sanity checks for the HCF, they can (supposedly) not be influenced -* by incorrect MSF behavior + *.NOTICE + * The asserts marked with *sc* are really sanity checks for the HCF, they can (supposedly) not be influenced + * by incorrect MSF behavior - // The MSF is required to supply the HCF with a single descriptor for MSF tx reclaim purposes. - // This 'reclaim descriptor' can be recognized by the fact that its buf_addr field is zero. - ********************************************************************************************* - * Although not required from a hardware perspective: - * - make each descriptor in this rx-chain DMA-owned. - * - Also set the count to zero. EOP and SOP bits are also cleared. - *********************************************************************************************/ + // The MSF is required to supply the HCF with a single descriptor for MSF tx reclaim purposes. + // This 'reclaim descriptor' can be recognized by the fact that its buf_addr field is zero. + ********************************************************************************************* + * Although not required from a hardware perspective: + * - make each descriptor in this rx-chain DMA-owned. + * - Also set the count to zero. EOP and SOP bits are also cleared. + *********************************************************************************************/ HCF_STATIC void put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ) { - DESC_STRCT *p = descp; + DESC_STRCT *p = descp; hcf_16 port; HCFASSERT( ifbp->IFB_CntlOpt & USE_DMA, ifbp->IFB_CntlOpt); //only hcf_dma_tx_put must also be DMA_ENABLED @@ -1415,37 +1414,37 @@ put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ) HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); HCFASSERT( (p->BUF_CNT & ~DESC_CNT_MASK) == 0, p->BUF_CNT ); HCFASSERT( (p->BUF_SIZE & ~DESC_CNT_MASK) == 0, p->BUF_SIZE ); - p->BUF_SIZE &= DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF - p->BUF_CNT &= tx_rx_flag == DMA_RX ? 0 : DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF + p->BUF_SIZE &= DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF + p->BUF_CNT &= tx_rx_flag == DMA_RX ? 0 : DESC_CNT_MASK; //!!this SHOULD be superfluous in case of correct MSF p->BUF_CNT |= DESC_DMA_OWNED; if ( p->next_desc_addr ) { // HCFASSERT( p->buf_addr && p->buf_phys_addr && p->BUF_SIZE && +/- p->BUF_SIZE, ... ); HCFASSERT( p->next_desc_addr->desc_phys_addr, (hcf_32)p->next_desc_addr ); p->next_desc_phys_addr = p->next_desc_addr->desc_phys_addr; - } else { // + } else { // p->next_desc_phys_addr = 0; - if ( p->buf_addr == NULL ) { // DELWA Descriptor - HCFASSERT( descp == p, (hcf_32)descp ); //singleton DescriptorList + if ( p->buf_addr == NULL ) { // DELWA Descriptor + HCFASSERT( descp == p, (hcf_32)descp ); //singleton DescriptorList HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_FirstDesc[tx_rx_flag]); HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag] == NULL, (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]); descp->BUF_CNT = 0; //&= ~DESC_DMA_OWNED; ifbp->IFB_FirstDesc[tx_rx_flag] = descp; // part of alternative ifbp->IFB_LastDesc[tx_rx_flag] = ifbp->IFB_FirstDesc[tx_rx_flag] = descp; - // if "recycling" a FrameList - // (e.g. called from hcf_cntl( HCF_CNTL_ENABLE ) - // . prepare for activation DMA controller + // if "recycling" a FrameList + // (e.g. called from hcf_cntl( HCF_CNTL_ENABLE ) + // . prepare for activation DMA controller // part of alternative descp = descp->next_desc_addr; - } else { //a "real" FrameList, hand it over to the DMA engine + } else { //a "real" FrameList, hand it over to the DMA engine HCFASSERT( ifbp->IFB_FirstDesc[tx_rx_flag], (hcf_32)descp ); HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag], (hcf_32)descp ); HCFASSERT( ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr == NULL, - (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr); + (hcf_32)ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr); // p->buf_cntl.cntl_stat |= DESC_DMA_OWNED; ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_addr = descp; ifbp->IFB_LastDesc[tx_rx_flag]->next_desc_phys_addr = descp->desc_phys_addr; port = HREG_RXDMA_PTR32; if ( tx_rx_flag ) { - p->BUF_SIZE |= DESC_EOP; // p points at the last descriptor in the caller-supplied descriptor chain + p->BUF_SIZE |= DESC_EOP; // p points at the last descriptor in the caller-supplied descriptor chain descp->BUF_SIZE |= DESC_SOP; port = HREG_TXDMA_PTR32; } @@ -1459,87 +1458,87 @@ put_frame_lst( IFBP ifbp, DESC_STRCT *descp, int tx_rx_flag ) /************************************************************************************************************ -* -*.MODULE DESC_STRCT* hcf_dma_rx_get( IFBP ifbp ) -*.PURPOSE decapsulate a message and provides that message to the MSF. -* reclaim all descriptors in the rx descriptor chain. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* pointer to a FrameList -* -*.DESCRIPTION -* hcf_dma_rx_get is intended to return a received frame when such a frame is deposited in Host memory by the -* DMA engine. In addition hcf_dma_rx_get can be used to reclaim all descriptors in the rx descriptor chain -* when the DMA Engine is disabled, e.g. as part of a driver unloading strategy. -* hcf_dma_rx_get must be called repeatedly by the MSF when hcf_service_nic signals availability of a rx frame -* through the HREG_EV_RDMAD flag of IFB_DmaPackets. The calling must stop when a NULL pointer is returned, at -* which time the HREG_EV_RDMAD flag is also cleared by the HCF to arm the mechanism for the next frame -* reception. -* Regardless whether the DMA Engine is currently enabled (as controlled via hcf_cntl), if the DMA controller -* deposited an Rx-frame in the Rx-DescriptorList, this frame is detached from the Rx-DescriptorList, -* transformed into a FrameList (i.e. updating the housekeeping fields in the descriptors) and returned to the -* caller. -* If no such Rx-frame is available in the Rx-DescriptorList, the behavior of hcf_dma_rx_get depends on the -* status of the DMA Engine. -* If the DMA Engine is enabled, a NULL pointer is returned. -* If the DMA Engine is disabled, the following strategy is used: -* - the complete Rx-DescriptorList is returned. The DELWA Descriptor is not part of the Rx-DescriptorList. -* - If there is no Rx-DescriptorList, the DELWA Descriptor is returned. -* - If there is no DELWA Descriptor, a NULL pointer is returned. -* -* If the MSF performs an disable/enable sequence without exhausting the Rx-DescriptorList as described above, -* the enable command will reset all house keeping information, i.e. already received but not yet by the MSF -* retrieved frames are lost and the next frame will be received starting with the oldest descriptor. -* -* The HCF can be used in 2 fashions: with and without decapsulation for data transfer. -* This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. -* If appropriate, decapsulation is done by moving some data inside the buffers and updating the descriptors -* accordingly. -*!! ;?????where did I describe why a simple manipulation with the count values does not suffice? -* -*.DIAGRAM -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE DESC_STRCT* hcf_dma_rx_get( IFBP ifbp ) + *.PURPOSE decapsulate a message and provides that message to the MSF. + * reclaim all descriptors in the rx descriptor chain. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * pointer to a FrameList + * + *.DESCRIPTION + * hcf_dma_rx_get is intended to return a received frame when such a frame is deposited in Host memory by the + * DMA engine. In addition hcf_dma_rx_get can be used to reclaim all descriptors in the rx descriptor chain + * when the DMA Engine is disabled, e.g. as part of a driver unloading strategy. + * hcf_dma_rx_get must be called repeatedly by the MSF when hcf_service_nic signals availability of a rx frame + * through the HREG_EV_RDMAD flag of IFB_DmaPackets. The calling must stop when a NULL pointer is returned, at + * which time the HREG_EV_RDMAD flag is also cleared by the HCF to arm the mechanism for the next frame + * reception. + * Regardless whether the DMA Engine is currently enabled (as controlled via hcf_cntl), if the DMA controller + * deposited an Rx-frame in the Rx-DescriptorList, this frame is detached from the Rx-DescriptorList, + * transformed into a FrameList (i.e. updating the housekeeping fields in the descriptors) and returned to the + * caller. + * If no such Rx-frame is available in the Rx-DescriptorList, the behavior of hcf_dma_rx_get depends on the + * status of the DMA Engine. + * If the DMA Engine is enabled, a NULL pointer is returned. + * If the DMA Engine is disabled, the following strategy is used: + * - the complete Rx-DescriptorList is returned. The DELWA Descriptor is not part of the Rx-DescriptorList. + * - If there is no Rx-DescriptorList, the DELWA Descriptor is returned. + * - If there is no DELWA Descriptor, a NULL pointer is returned. + * + * If the MSF performs an disable/enable sequence without exhausting the Rx-DescriptorList as described above, + * the enable command will reset all house keeping information, i.e. already received but not yet by the MSF + * retrieved frames are lost and the next frame will be received starting with the oldest descriptor. + * + * The HCF can be used in 2 fashions: with and without decapsulation for data transfer. + * This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. + * If appropriate, decapsulation is done by moving some data inside the buffers and updating the descriptors + * accordingly. + *!! ;?????where did I describe why a simple manipulation with the count values does not suffice? + * + *.DIAGRAM + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ DESC_STRCT* hcf_dma_rx_get (IFBP ifbp) { -DESC_STRCT *descp; // pointer to start of FrameList + DESC_STRCT *descp; // pointer to start of FrameList descp = get_frame_lst( ifbp, DMA_RX ); if ( descp && descp->buf_addr ) //!be aware of the missing curly bracket - //skip decapsulation at confined descriptor + //skip decapsulation at confined descriptor #if (HCF_ENCAP) == HCF_ENC #if (HCF_TYPE) & HCF_TYPE_CCX - if ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) + if ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) #endif // HCF_TYPE_CCX - { -int i; -DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame - HCFASSERT(p, 0); - // The 2nd descriptor contains (maybe) a SNAP header plus part or whole of the payload. - //determine decapsulation sub-flag in RxFS - i = *(wci_recordp)&descp->buf_addr[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); - if ( i == HFS_STAT_TUNNEL || - ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&p->buf_addr[HCF_DASA_SIZE] ) != ENC_TUNNEL )) { - // The 2nd descriptor contains a SNAP header plus part or whole of the payload. - HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ); - // perform decapsulation - HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE); - // move SA[2:5] in the second buffer to replace part of the SNAP header - for ( i=3; i >= 0; i--) p->buf_addr[i+8] = p->buf_addr[i]; - // copy DA[0:5], SA[0:1] from first buffer to second buffer - for ( i=0; i<8; i++) p->buf_addr[i] = descp->buf_addr[HFS_ADDR_DEST + i]; - // make first buffer shorter in count - descp->BUF_CNT = HFS_ADDR_DEST; + { + int i; + DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame + HCFASSERT(p, 0); + // The 2nd descriptor contains (maybe) a SNAP header plus part or whole of the payload. + //determine decapsulation sub-flag in RxFS + i = *(wci_recordp)&descp->buf_addr[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); + if ( i == HFS_STAT_TUNNEL || + ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&p->buf_addr[HCF_DASA_SIZE] ) != ENC_TUNNEL )) { + // The 2nd descriptor contains a SNAP header plus part or whole of the payload. + HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ); + // perform decapsulation + HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE); + // move SA[2:5] in the second buffer to replace part of the SNAP header + for ( i=3; i >= 0; i--) p->buf_addr[i+8] = p->buf_addr[i]; + // copy DA[0:5], SA[0:1] from first buffer to second buffer + for ( i=0; i<8; i++) p->buf_addr[i] = descp->buf_addr[HFS_ADDR_DEST + i]; + // make first buffer shorter in count + descp->BUF_CNT = HFS_ADDR_DEST; + } } - } #endif // HCF_ENC if ( descp == NULL ) ifbp->IFB_DmaPackets &= (hcf_16)~HREG_EV_RDMAD; //;?could be integrated into get_frame_lst HCFLOGEXIT( HCF_TRACE_DMA_RX_GET ); @@ -1548,50 +1547,50 @@ DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame /************************************************************************************************************ -* -*.MODULE void hcf_dma_rx_put( IFBP ifbp, DESC_STRCT *descp ) -*.PURPOSE supply buffers for receive purposes. -* supply the Rx-DELWA descriptor. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* descp address of a DescriptorList -* -*.RETURNS N.A. -* -*.DESCRIPTION -* This function is called by the MSF to supply the HCF with new/more buffers for receive purposes. -* The HCF can be used in 2 fashions: with and without encapsulation for data transfer. -* This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. -* As a consequence, some additional constraints apply to the number of descriptor and the buffers associated -* with the first 2 descriptors. Independent of the encapsulation feature, the COUNT fields are ignored. -* A special case is the supplying of the DELWA descriptor, which must be supplied as the first descriptor. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value. -* - NIC interrupts are not disabled while required by parameter action. -* - in case decapsulation by the HCF is selected: -* - The first databuffer does not have the exact size corresponding with the RxFS up to the 802.3 DestAddr -* field (== 29 words). -* - The FrameList does not consists of at least 2 Descriptors. -* - The second databuffer does not have the minimum size of 8 bytes. -*!! The 2nd part of the list of asserts should be kept in sync with put_frame_lst, in order to get -*!! them in the WCI-spec !!!! -* - DMA is not enabled -* - descriptor list is NULL -* - a descriptor in the descriptor list is not double word aligned -* - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. -* - the DELWA descriptor is not a "singleton" DescriptorList. -* - the DELWA descriptor is not the first Descriptor supplied -* - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied -*!! - Possibly more checks could be added !!!!!!!!!!!!! -* -*.DIAGRAM -* -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE void hcf_dma_rx_put( IFBP ifbp, DESC_STRCT *descp ) + *.PURPOSE supply buffers for receive purposes. + * supply the Rx-DELWA descriptor. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * descp address of a DescriptorList + * + *.RETURNS N.A. + * + *.DESCRIPTION + * This function is called by the MSF to supply the HCF with new/more buffers for receive purposes. + * The HCF can be used in 2 fashions: with and without encapsulation for data transfer. + * This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. + * As a consequence, some additional constraints apply to the number of descriptor and the buffers associated + * with the first 2 descriptors. Independent of the encapsulation feature, the COUNT fields are ignored. + * A special case is the supplying of the DELWA descriptor, which must be supplied as the first descriptor. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value. + * - NIC interrupts are not disabled while required by parameter action. + * - in case decapsulation by the HCF is selected: + * - The first databuffer does not have the exact size corresponding with the RxFS up to the 802.3 DestAddr + * field (== 29 words). + * - The FrameList does not consists of at least 2 Descriptors. + * - The second databuffer does not have the minimum size of 8 bytes. + *!! The 2nd part of the list of asserts should be kept in sync with put_frame_lst, in order to get + *!! them in the WCI-spec !!!! + * - DMA is not enabled + * - descriptor list is NULL + * - a descriptor in the descriptor list is not double word aligned + * - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. + * - the DELWA descriptor is not a "singleton" DescriptorList. + * - the DELWA descriptor is not the first Descriptor supplied + * - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied + *!! - Possibly more checks could be added !!!!!!!!!!!!! + * + *.DIAGRAM + * + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ void hcf_dma_rx_put( IFBP ifbp, DESC_STRCT *descp ) { @@ -1614,47 +1613,47 @@ hcf_dma_rx_put( IFBP ifbp, DESC_STRCT *descp ) /************************************************************************************************************ -* -*.MODULE DESC_STRCT* hcf_dma_tx_get( IFBP ifbp ) -*.PURPOSE DMA mode: reclaims and decapsulates packets in the tx descriptor chain if: -* - A Tx packet has been copied from host-RAM into NIC-RAM by the DMA engine -* - The Hermes/DMAengine have been disabled -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* pointer to a reclaimed Tx packet. -* -*.DESCRIPTION -* impact of the disable command: -* When a non-empty pool of Tx descriptors exists (created by means of hcf_dma_put_tx), the MSF -* is supposed to empty that pool by means of hcf_dma_tx_get calls after the disable in an -* disable/enable sequence. -* -*.DIAGRAM -* -*.NOTICE -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE DESC_STRCT* hcf_dma_tx_get( IFBP ifbp ) + *.PURPOSE DMA mode: reclaims and decapsulates packets in the tx descriptor chain if: + * - A Tx packet has been copied from host-RAM into NIC-RAM by the DMA engine + * - The Hermes/DMAengine have been disabled + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * pointer to a reclaimed Tx packet. + * + *.DESCRIPTION + * impact of the disable command: + * When a non-empty pool of Tx descriptors exists (created by means of hcf_dma_put_tx), the MSF + * is supposed to empty that pool by means of hcf_dma_tx_get calls after the disable in an + * disable/enable sequence. + * + *.DIAGRAM + * + *.NOTICE + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ DESC_STRCT* hcf_dma_tx_get( IFBP ifbp ) { -DESC_STRCT *descp; // pointer to start of FrameList + DESC_STRCT *descp; // pointer to start of FrameList descp = get_frame_lst( ifbp, DMA_TX ); if ( descp && descp->buf_addr ) //!be aware of the missing curly bracket - //skip decapsulation at confined descriptor + //skip decapsulation at confined descriptor #if (HCF_ENCAP) == HCF_ENC if ( ( descp->BUF_CNT == HFS_TYPE ) #if (HCF_TYPE) & HCF_TYPE_CCX - || ( descp->BUF_CNT == HFS_DAT ) + || ( descp->BUF_CNT == HFS_DAT ) #endif // HCF_TYPE_CCX - ) { // perform decapsulation if needed + ) { // perform decapsulation if needed descp->next_desc_addr->buf_phys_addr -= HCF_DASA_SIZE; - descp->next_desc_addr->BUF_CNT += HCF_DASA_SIZE; + descp->next_desc_addr->BUF_CNT += HCF_DASA_SIZE; } #endif // HCF_ENC if ( descp == NULL ) { //;?could be integrated into get_frame_lst @@ -1666,125 +1665,125 @@ DESC_STRCT *descp; // pointer to start of FrameList /************************************************************************************************************ -* -*.MODULE void hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) -*.PURPOSE puts a packet in the Tx DMA queue in host ram and kicks off the TxDma engine. -* supply the Tx-DELWA descriptor. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* descp address of Tx Descriptor Chain (i.e. a single Tx frame) -* tx_cntl indicates MAC-port and (Hermes) options -* -*.RETURNS N.A. -* -*.DESCRIPTION -* The HCF can be used in 2 fashions: with and without encapsulation for data transfer. -* This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. -* -* Regardless of the HCF_ENCAP system constant, the descriptor list created to describe the frame to be -* transmitted, must supply space to contain the 802.11 header, preceding the actual frame to be transmitted. -* Basically, this only supplies working storage to the HCF which passes this on to the DMA engine. -* As a consequence the contents of this space do not matter. -* Nevertheless BUF_CNT must take in account this storage. -* This working space to contain the 802.11 header may not be fragmented, the first buffer must be -* sufficiently large to contain at least the 802.11 header, i.e. HFS_ADDR_DEST (29 words or 0x3A bytes). -* This way, the HCF can simply, regardless whether or not the HCF encapsulates the frame, write the parameter -* tx_cntl at offset 0x36 (HFS_TX_CNTL) in the first buffer. -* Note that it is allowed to have part or all of the actual frame represented by the first descriptor as long -* as the requirement for storage for the 802.11 header is met, i.e. the 802.3 frame starts at offset -* HFS_ADDR_DEST. -* Except for the Assert on the 1st buffer in case of Encapsualtion, the SIZE fields are ignored. -* -* In case the encapsulation feature is compiled in, there are the following additional requirements. -* o The BUF_CNT of the first buffer changes from a minimum of 0x3A bytes to exactly 0x3A, i.e. the workspace -* to store the 802.11 header -* o The BUF_SIZE of the first buffer is at least the space needed to store the -* - 802.11 header (29 words) -* - 802.3 header, i.e. 12 bytes addressing information and 2 bytes length field -* - 6 bytes SNAP-header -* This results in 39 words or 0x4E bytes or HFS_TYPE. -* Note that if the BUF_SIZE is larger than 0x4E, this surplus is not used. -* o The actual frame begins in the 2nd descriptor (which is already implied by the BUF_CNT == 0x3A requirement) and the associated buffer contains at least the 802.3 header, i.e. the 14 bytes representing addressing information and length/type field -* -* When the HCF does not encapsulates (i.e. length/type field <= 1500), no changes are made to descriptors -* or buffers. -* -* When the HCF actually encapsulates (i.e. length/type field > 1500), it successively writes, starting at -* offset HFS_ADDR_DEST (0x3A) in the first buffer: -* - the 802.3 addressing information, copied from the begin of the second buffer -* - the frame length, derived from the total length of the individual fragments, corrected for the SNAP -* header length and Type field and ignoring the Destination Address, Source Address and Length field -* - the appropriate snap header (Tunnel or 1042, depending on the value of the type field). -* -* The information in the first two descriptors is adjusted accordingly: -* - the first descriptor count is changed from 0x3A to 0x4E (HFS_TYPE), which matches 0x3A + 12 + 2 + 6 -* - the second descriptor count is decreased by 12, being the moved addressing information -* - the second descriptor (physical) buffer address is increased by 12. -* -* When the descriptors are returned by hcf_dma_tx_get, the transformation of the first two descriptors is -* undone. -* -* Under any of the above scenarios, the assert BUF_CNT <= BUF_SIZE must be true for all descriptors -* In case of encapsulation, BUF_SIZE of the 1st descriptor is asserted to be at least HFS_TYPE (0x4E), so it is NOT tested. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value. -* - tx_cntl has a recognizable out-of-range value. -* - NIC interrupts are not disabled while required by parameter action. -* - in case encapsulation by the HCF is selected: -* - The FrameList does not consists of at least 2 Descriptors. -* - The first databuffer does not contain exactly the (space for) the 802.11 header (== 28 words) -* - The first databuffer does not have a size to additionally accommodate the 802.3 header and the -* SNAP header of the frame after encapsulation (== 39 words). -* - The second databuffer does not contain at least DA, SA and 'type/length' (==14 bytes or 7 words) -*!! The 2nd part of the list of asserts should be kept in sync with put_frame_lst, in order to get -*!! them in the WCI-spec !!!! -* - DMA is not enabled -* - descriptor list is NULL -* - a descriptor in the descriptor list is not double word aligned -* - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. -* - the DELWA descriptor is not a "singleton" DescriptorList. -* - the DELWA descriptor is not the first Descriptor supplied -* - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied -*!! - Possibly more checks could be added !!!!!!!!!!!!! -*.DIAGRAM -* -*.NOTICE -* -*.ENDDOC END DOCUMENTATION -* -* -*1: Write tx_cntl parameter to HFS_TX_CNTL field into the Hermes-specific header in buffer 1 -*4: determine whether encapsulation is needed and write the type (tunnel or 1042) already at the appropriate -* offset in the 1st buffer -*6: Build the encapsualtion enveloppe in the free space at the end of the 1st buffer -* - Copy DA/SA fields from the 2nd buffer -* - Calculate total length of the message (snap-header + type-field + the length of all buffer fragments -* associated with the 802.3 frame (i.e all descriptors except the first), but not the DestinationAddress, -* SourceAddress and length-field) -* Assert the message length -* Write length. Note that the message is in BE format, hence on LE platforms the length must be converted -* ;? THIS IS NOT WHAT CURRENTLY IS IMPLEMENTED -* - Write snap header. Note that the last byte of the snap header is NOT copied, that byte is already in -* place as result of the call to hcf_encap. -* Note that there are many ways to skin a cat. To express the offsets in the 1st buffer while writing -* the snap header, HFS_TYPE is chosen as a reference point to make it easier to grasp that the snap header -* and encapsualtion type are at least relative in the right. -*8: modify 1st descriptor to reflect moved part of the 802.3 header + Snap-header -* modify 2nd descriptor to skip the moved part of the 802.3 header (DA/SA -*10: set each descriptor to 'DMA owned', clear all other control bits. -* Set SOP bit on first descriptor. Set EOP bit on last descriptor. -*12: Either append the current frame to an existing descriptor list or -*14: create a list beginning with the current frame -*16: remember the new end of the list -*20: hand the frame over to the DMA engine -************************************************************************************************************/ + * + *.MODULE void hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) + *.PURPOSE puts a packet in the Tx DMA queue in host ram and kicks off the TxDma engine. + * supply the Tx-DELWA descriptor. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * descp address of Tx Descriptor Chain (i.e. a single Tx frame) + * tx_cntl indicates MAC-port and (Hermes) options + * + *.RETURNS N.A. + * + *.DESCRIPTION + * The HCF can be used in 2 fashions: with and without encapsulation for data transfer. + * This is controlled at compile time by the HCF_ENC bit of the HCF_ENCAP system constant. + * + * Regardless of the HCF_ENCAP system constant, the descriptor list created to describe the frame to be + * transmitted, must supply space to contain the 802.11 header, preceding the actual frame to be transmitted. + * Basically, this only supplies working storage to the HCF which passes this on to the DMA engine. + * As a consequence the contents of this space do not matter. + * Nevertheless BUF_CNT must take in account this storage. + * This working space to contain the 802.11 header may not be fragmented, the first buffer must be + * sufficiently large to contain at least the 802.11 header, i.e. HFS_ADDR_DEST (29 words or 0x3A bytes). + * This way, the HCF can simply, regardless whether or not the HCF encapsulates the frame, write the parameter + * tx_cntl at offset 0x36 (HFS_TX_CNTL) in the first buffer. + * Note that it is allowed to have part or all of the actual frame represented by the first descriptor as long + * as the requirement for storage for the 802.11 header is met, i.e. the 802.3 frame starts at offset + * HFS_ADDR_DEST. + * Except for the Assert on the 1st buffer in case of Encapsualtion, the SIZE fields are ignored. + * + * In case the encapsulation feature is compiled in, there are the following additional requirements. + * o The BUF_CNT of the first buffer changes from a minimum of 0x3A bytes to exactly 0x3A, i.e. the workspace + * to store the 802.11 header + * o The BUF_SIZE of the first buffer is at least the space needed to store the + * - 802.11 header (29 words) + * - 802.3 header, i.e. 12 bytes addressing information and 2 bytes length field + * - 6 bytes SNAP-header + * This results in 39 words or 0x4E bytes or HFS_TYPE. + * Note that if the BUF_SIZE is larger than 0x4E, this surplus is not used. + * o The actual frame begins in the 2nd descriptor (which is already implied by the BUF_CNT == 0x3A requirement) and the associated buffer contains at least the 802.3 header, i.e. the 14 bytes representing addressing information and length/type field + * + * When the HCF does not encapsulates (i.e. length/type field <= 1500), no changes are made to descriptors + * or buffers. + * + * When the HCF actually encapsulates (i.e. length/type field > 1500), it successively writes, starting at + * offset HFS_ADDR_DEST (0x3A) in the first buffer: + * - the 802.3 addressing information, copied from the begin of the second buffer + * - the frame length, derived from the total length of the individual fragments, corrected for the SNAP + * header length and Type field and ignoring the Destination Address, Source Address and Length field + * - the appropriate snap header (Tunnel or 1042, depending on the value of the type field). + * + * The information in the first two descriptors is adjusted accordingly: + * - the first descriptor count is changed from 0x3A to 0x4E (HFS_TYPE), which matches 0x3A + 12 + 2 + 6 + * - the second descriptor count is decreased by 12, being the moved addressing information + * - the second descriptor (physical) buffer address is increased by 12. + * + * When the descriptors are returned by hcf_dma_tx_get, the transformation of the first two descriptors is + * undone. + * + * Under any of the above scenarios, the assert BUF_CNT <= BUF_SIZE must be true for all descriptors + * In case of encapsulation, BUF_SIZE of the 1st descriptor is asserted to be at least HFS_TYPE (0x4E), so it is NOT tested. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value. + * - tx_cntl has a recognizable out-of-range value. + * - NIC interrupts are not disabled while required by parameter action. + * - in case encapsulation by the HCF is selected: + * - The FrameList does not consists of at least 2 Descriptors. + * - The first databuffer does not contain exactly the (space for) the 802.11 header (== 28 words) + * - The first databuffer does not have a size to additionally accommodate the 802.3 header and the + * SNAP header of the frame after encapsulation (== 39 words). + * - The second databuffer does not contain at least DA, SA and 'type/length' (==14 bytes or 7 words) + *!! The 2nd part of the list of asserts should be kept in sync with put_frame_lst, in order to get + *!! them in the WCI-spec !!!! + * - DMA is not enabled + * - descriptor list is NULL + * - a descriptor in the descriptor list is not double word aligned + * - a count of size field of a descriptor contains control bits, i.e. bits in the high order nibble. + * - the DELWA descriptor is not a "singleton" DescriptorList. + * - the DELWA descriptor is not the first Descriptor supplied + * - a non_DMA descriptor is supplied before the DELWA Descriptor is supplied + *!! - Possibly more checks could be added !!!!!!!!!!!!! + *.DIAGRAM + * + *.NOTICE + * + *.ENDDOC END DOCUMENTATION + * + * + *1: Write tx_cntl parameter to HFS_TX_CNTL field into the Hermes-specific header in buffer 1 + *4: determine whether encapsulation is needed and write the type (tunnel or 1042) already at the appropriate + * offset in the 1st buffer + *6: Build the encapsualtion enveloppe in the free space at the end of the 1st buffer + * - Copy DA/SA fields from the 2nd buffer + * - Calculate total length of the message (snap-header + type-field + the length of all buffer fragments + * associated with the 802.3 frame (i.e all descriptors except the first), but not the DestinationAddress, + * SourceAddress and length-field) + * Assert the message length + * Write length. Note that the message is in BE format, hence on LE platforms the length must be converted + * ;? THIS IS NOT WHAT CURRENTLY IS IMPLEMENTED + * - Write snap header. Note that the last byte of the snap header is NOT copied, that byte is already in + * place as result of the call to hcf_encap. + * Note that there are many ways to skin a cat. To express the offsets in the 1st buffer while writing + * the snap header, HFS_TYPE is chosen as a reference point to make it easier to grasp that the snap header + * and encapsualtion type are at least relative in the right. + *8: modify 1st descriptor to reflect moved part of the 802.3 header + Snap-header + * modify 2nd descriptor to skip the moved part of the 802.3 header (DA/SA + *10: set each descriptor to 'DMA owned', clear all other control bits. + * Set SOP bit on first descriptor. Set EOP bit on last descriptor. + *12: Either append the current frame to an existing descriptor list or + *14: create a list beginning with the current frame + *16: remember the new end of the list + *20: hand the frame over to the DMA engine + ************************************************************************************************************/ void hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) { -DESC_STRCT *p = descp->next_desc_addr; -int i; + DESC_STRCT *p = descp->next_desc_addr; + int i; #if HCF_ASSERT int x = ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ? tx_cntl & ~HFS_TX_CNTL_PORT : tx_cntl; @@ -1796,21 +1795,21 @@ int i; HCFASSERT( ( ifbp->IFB_CntlOpt & (USE_DMA|DMA_ENABLED) ) == (USE_DMA|DMA_ENABLED), ifbp->IFB_CntlOpt); if ( descp->buf_addr ) { - *(hcf_16*)(descp->buf_addr + HFS_TX_CNTL) = tx_cntl; /*1*/ + *(hcf_16*)(descp->buf_addr + HFS_TX_CNTL) = tx_cntl; /*1*/ #if (HCF_ENCAP) == HCF_ENC - HCFASSERT( descp->next_desc_addr, 0 ); //at least 2 descripors - HCFASSERT( descp->BUF_CNT == HFS_ADDR_DEST, descp->BUF_CNT ); //exact length required for 1st buffer - HCFASSERT( descp->BUF_SIZE >= HCF_DMA_TX_BUF1_SIZE, descp->BUF_SIZE ); //minimal storage for encapsulation - HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); //at least DA, SA and 'type' in 2nd buffer + HCFASSERT( descp->next_desc_addr, 0 ); //at least 2 descripors + HCFASSERT( descp->BUF_CNT == HFS_ADDR_DEST, descp->BUF_CNT ); //exact length required for 1st buffer + HCFASSERT( descp->BUF_SIZE >= HCF_DMA_TX_BUF1_SIZE, descp->BUF_SIZE ); //minimal storage for encapsulation + HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); //at least DA, SA and 'type' in 2nd buffer #if (HCF_TYPE) & HCF_TYPE_CCX /* if we are doing PPK +/- CMIC, or we are sending a DDP frame */ if ( ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_ON ) || - ( ( p->BUF_CNT >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && - ( p->buf_addr[12] == 0xAA ) && ( p->buf_addr[13] == 0xAA ) && - ( p->buf_addr[14] == 0x03 ) && ( p->buf_addr[15] == 0x00 ) && - ( p->buf_addr[16] == 0x40 ) && ( p->buf_addr[17] == 0x96 ) && - ( p->buf_addr[18] == 0x00 ) && ( p->buf_addr[19] == 0x00 ))) + ( ( p->BUF_CNT >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && + ( p->buf_addr[12] == 0xAA ) && ( p->buf_addr[13] == 0xAA ) && + ( p->buf_addr[14] == 0x03 ) && ( p->buf_addr[15] == 0x00 ) && + ( p->buf_addr[16] == 0x40 ) && ( p->buf_addr[17] == 0x96 ) && + ( p->buf_addr[18] == 0x00 ) && ( p->buf_addr[19] == 0x00 ))) { /* copy the DA/SA to the first buffer */ for ( i = 0; i < HCF_DASA_SIZE; i++ ) { @@ -1821,34 +1820,34 @@ int i; do { i += p->BUF_CNT; } while( p = p->next_desc_addr ); i -= HCF_DASA_SIZE ; /* convert the length field to big endian, using the endian friendly macros */ - i = CNV_SHORT_TO_BIG(i); //!! this converts ONLY on LE platforms, how does that relate to the non-CCX code + i = CNV_SHORT_TO_BIG(i); //!! this converts ONLY on LE platforms, how does that relate to the non-CCX code *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = (hcf_16)i; descp->BUF_CNT = HFS_DAT; // modify 2nd descriptor to skip the 'Da/Sa' fields descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; - descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; + descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; } else #endif // HCF_TYPE_CCX { - descp->buf_addr[HFS_TYPE-1] = hcf_encap(&descp->next_desc_addr->buf_addr[HCF_DASA_SIZE]); /*4*/ + descp->buf_addr[HFS_TYPE-1] = hcf_encap(&descp->next_desc_addr->buf_addr[HCF_DASA_SIZE]); /*4*/ if ( descp->buf_addr[HFS_TYPE-1] != ENC_NONE ) { - for ( i=0; i < HCF_DASA_SIZE; i++ ) { /*6*/ + for ( i=0; i < HCF_DASA_SIZE; i++ ) { /*6*/ descp->buf_addr[i + HFS_ADDR_DEST] = descp->next_desc_addr->buf_addr[i]; } i = sizeof(snap_header) + 2 - ( 2*6 + 2 ); do { i += p->BUF_CNT; } while ( ( p = p->next_desc_addr ) != NULL ); - *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = CNV_END_SHORT(i); //!! this converts on ALL platforms, how does that relate to the CCX code + *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = CNV_END_SHORT(i); //!! this converts on ALL platforms, how does that relate to the CCX code for ( i=0; i < sizeof(snap_header) - 1; i++) { descp->buf_addr[HFS_TYPE - sizeof(snap_header) + i] = snap_header[i]; } - descp->BUF_CNT = HFS_TYPE; /*8*/ - descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; - descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; + descp->BUF_CNT = HFS_TYPE; /*8*/ + descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; + descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; } } #endif // HCF_ENC - } + } put_frame_lst( ifbp, descp, DMA_TX ); HCFLOGEXIT( HCF_TRACE_DMA_TX_PUT ); } // hcf_dma_tx_put @@ -1857,44 +1856,44 @@ int i; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.MODULE hcf_8 hcf_encap( wci_bufp type ) -*.PURPOSE test whether RFC1042 or Bridge-Tunnel encapsulation is needed. -* -*.ARGUMENTS -* type (Far) pointer to the (Big Endian) Type/Length field in the message -* -*.RETURNS -* ENC_NONE len/type is "len" ( (BIG_ENDIAN)type <= 1500 ) -* ENC_TUNNEL len/type is "type" and 0x80F3 or 0x8137 -* ENC_1042 len/type is "type" but not 0x80F3 or 0x8137 -* -*.CONDITIONS -* NIC Interrupts d.c -* -*.DESCRIPTION -* Type must point to the Len/Type field of the message, this is the 2-byte field immediately after the 6 byte -* Destination Address and 6 byte Source Address. The 2 successive bytes addressed by type are interpreted as -* a Big Endian value. If that value is less than or equal to 1500, the message is assumed to be in 802.3 -* format. Otherwise the message is assumed to be in Ethernet-II format. Depending on the value of Len/Typ, -* Bridge Tunnel or RFC1042 encapsulation is needed. -* -*.DIAGRAM -* -* 1: presume 802.3, hence preset return value at ENC_NONE -* 2: convert type from "network" Endian format to native Endian -* 4: the litmus test to distinguish type and len. -* The hard code "magic" value of 1500 is intentional and should NOT be replaced by a mnemonic because it is -* not related at all to the maximum frame size supported by the Hermes. -* 6: check type against: -* 0x80F3 //AppleTalk Address Resolution Protocol (AARP) -* 0x8137 //IPX -* to determine the type of encapsulation -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ -#if HCF_ENCAP //i.e HCF_ENC or HCF_ENC_SUP + * + *.MODULE hcf_8 hcf_encap( wci_bufp type ) + *.PURPOSE test whether RFC1042 or Bridge-Tunnel encapsulation is needed. + * + *.ARGUMENTS + * type (Far) pointer to the (Big Endian) Type/Length field in the message + * + *.RETURNS + * ENC_NONE len/type is "len" ( (BIG_ENDIAN)type <= 1500 ) + * ENC_TUNNEL len/type is "type" and 0x80F3 or 0x8137 + * ENC_1042 len/type is "type" but not 0x80F3 or 0x8137 + * + *.CONDITIONS + * NIC Interrupts d.c + * + *.DESCRIPTION + * Type must point to the Len/Type field of the message, this is the 2-byte field immediately after the 6 byte + * Destination Address and 6 byte Source Address. The 2 successive bytes addressed by type are interpreted as + * a Big Endian value. If that value is less than or equal to 1500, the message is assumed to be in 802.3 + * format. Otherwise the message is assumed to be in Ethernet-II format. Depending on the value of Len/Typ, + * Bridge Tunnel or RFC1042 encapsulation is needed. + * + *.DIAGRAM + * + * 1: presume 802.3, hence preset return value at ENC_NONE + * 2: convert type from "network" Endian format to native Endian + * 4: the litmus test to distinguish type and len. + * The hard code "magic" value of 1500 is intentional and should NOT be replaced by a mnemonic because it is + * not related at all to the maximum frame size supported by the Hermes. + * 6: check type against: + * 0x80F3 //AppleTalk Address Resolution Protocol (AARP) + * 0x8137 //IPX + * to determine the type of encapsulation + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ +#if HCF_ENCAP //i.e HCF_ENC or HCF_ENC_SUP #if ! ( (HCF_ENCAP) & HCF_ENC_SUP ) HCF_STATIC #endif // HCF_ENCAP @@ -1902,12 +1901,12 @@ hcf_8 hcf_encap( wci_bufp type ) { -hcf_8 rc = ENC_NONE; /* 1 */ -hcf_16 t = (hcf_16)(*type<<8) + *(type+1); /* 2 */ + hcf_8 rc = ENC_NONE; /* 1 */ + hcf_16 t = (hcf_16)(*type<<8) + *(type+1); /* 2 */ - if ( t > 1500 ) { /* 4 */ + if ( t > 1500 ) { /* 4 */ if ( t == 0x8137 || t == 0x80F3 ) { - rc = ENC_TUNNEL; /* 6 */ + rc = ENC_TUNNEL; /* 6 */ } else { rc = ENC_1042; } @@ -1919,121 +1918,121 @@ hcf_16 t = (hcf_16)(*type<<8) + *(type+1); /* 2 */ /************************************************************************************************************ -* -*.MODULE int hcf_get_info( IFBP ifbp, LTVP ltvp ) -*.PURPOSE Obtains transient and persistent configuration information from the Card and from the HCF. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* ltvp address of LengthTypeValue structure specifying the "what" and the "how much" of the -* information to be collected from the HCF or from the Hermes -* -*.RETURNS -* HCF_ERR_LEN The provided buffer was too small -* HCF_SUCCESS Success -*!! via cmd_exe ( type >= CFG_RID_FW_MIN ) -* HCF_ERR_NO_NIC NIC removed during retrieval -* HCF_ERR_TIME_OUT Expected Hermes event did not occur in expected time -*!! via cmd_exe and setup_bap (type >= CFG_RID_FW_MIN ) -* HCF_ERR_DEFUNCT_... HCF is in defunct mode (bits 0x7F reflect cause) -* -*.DESCRIPTION -* The T-field of the LTV-record (provided by the MSF in parameter ltvp) specifies the RID wanted. The RID -* information identified by the T-field is copied into the V-field. -* On entry, the L-field specifies the size of the buffer, also called the "Initial DataLength". The L-value -* includes the size of the T-field, but not the size of the L-field itself. -* On return, the L-field indicates the number of words actually contained by the Type and Value fields. -* As the size of the Type field in the LTV-record is included in the "Initial DataLength" of the record, the -* V-field can contain at most "Initial DataLength" - 1 words of data. -* Copying stops if either the complete Information is copied or if the number of words indicated by the -* "Initial DataLength" were copied. The "Initial DataLength" acts as a safe guard against Configuration -* Information blocks that have different sizes for different F/W versions, e.g. when later versions support -* more tallies than earlier versions. -* If the size of Value field of the RID exceeds the size of the "Initial DataLength" -1, as much data -* as fits is copied, and an error status of HCF_ERR_LEN is returned. -* -* It is the responsibility of the MSF to detect card removal and re-insertion and not call the HCF when the -* NIC is absent. The MSF cannot, however, timely detect a Card removal if the Card is removed while -* hcf_get_info is in progress. Therefore, the HCF performs its own check on Card presence after the read -* operation of the NIC data. If the Card is not present or removed during the execution of hcf_get_info, -* HCF_ERR_NO_NIC is returned and the content of the Data Buffer is unpredictable. This check is not performed -* in case of the "HCF embedded" pseudo RIDs like CFG_TALLIES. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value. -* - reentrancy, may be caused by calling hcf_functions without adequate protection -* against NIC interrupts or multi-threading. -* - ltvp is a NULL pointer. -* - length field of the LTV-record at entry is 0 or 1 or has an excessive value (i.e. exceeds HCF_MAX_LTV). -* - type field of the LTV-record is invalid. -* -*.DIAGRAM -* Hcf_get_mb_info copies the contents of the oldest MailBox Info block in the MailBox to PC RAM. If len is -* less than the size of the MailBox Info block, only as much as fits in the PC RAM buffer is copied. After -* the copying the MailBox Read pointer is updated to point to the next MailBox Info block, hence the -* remainder of an "oversized" MailBox Info block is lost. The truncation of the MailBox Info block is NOT -* reflected in the return status. Note that hcf_get_info guarantees the length of the PC RAM buffer meets -* the minimum requirements of at least 2, so no PC RAM buffer overrun. -* -* Calling hcf_get_mb_info when their is no MailBox Info block available or when there is no MailBox at all, -* results in a "NULL" MailBox Info block. -* -*12: see NOTICE -*17: The return status of cmd_wait and the first hcfio_in_string can be ignored, because when one fails, the -* other fails via the IFB_DefunctStat mechanism -*20: "HCFASSERT( rc == HCF_SUCCESS, rc )" is not suitable because this will always trigger as side effect of -* the HCFASSERT in hcf_put_info which calls hcf_get_info to figure out whether the RID exists at all. + * + *.MODULE int hcf_get_info( IFBP ifbp, LTVP ltvp ) + *.PURPOSE Obtains transient and persistent configuration information from the Card and from the HCF. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * ltvp address of LengthTypeValue structure specifying the "what" and the "how much" of the + * information to be collected from the HCF or from the Hermes + * + *.RETURNS + * HCF_ERR_LEN The provided buffer was too small + * HCF_SUCCESS Success + *!! via cmd_exe ( type >= CFG_RID_FW_MIN ) + * HCF_ERR_NO_NIC NIC removed during retrieval + * HCF_ERR_TIME_OUT Expected Hermes event did not occur in expected time + *!! via cmd_exe and setup_bap (type >= CFG_RID_FW_MIN ) + * HCF_ERR_DEFUNCT_... HCF is in defunct mode (bits 0x7F reflect cause) + * + *.DESCRIPTION + * The T-field of the LTV-record (provided by the MSF in parameter ltvp) specifies the RID wanted. The RID + * information identified by the T-field is copied into the V-field. + * On entry, the L-field specifies the size of the buffer, also called the "Initial DataLength". The L-value + * includes the size of the T-field, but not the size of the L-field itself. + * On return, the L-field indicates the number of words actually contained by the Type and Value fields. + * As the size of the Type field in the LTV-record is included in the "Initial DataLength" of the record, the + * V-field can contain at most "Initial DataLength" - 1 words of data. + * Copying stops if either the complete Information is copied or if the number of words indicated by the + * "Initial DataLength" were copied. The "Initial DataLength" acts as a safe guard against Configuration + * Information blocks that have different sizes for different F/W versions, e.g. when later versions support + * more tallies than earlier versions. + * If the size of Value field of the RID exceeds the size of the "Initial DataLength" -1, as much data + * as fits is copied, and an error status of HCF_ERR_LEN is returned. + * + * It is the responsibility of the MSF to detect card removal and re-insertion and not call the HCF when the + * NIC is absent. The MSF cannot, however, timely detect a Card removal if the Card is removed while + * hcf_get_info is in progress. Therefore, the HCF performs its own check on Card presence after the read + * operation of the NIC data. If the Card is not present or removed during the execution of hcf_get_info, + * HCF_ERR_NO_NIC is returned and the content of the Data Buffer is unpredictable. This check is not performed + * in case of the "HCF embedded" pseudo RIDs like CFG_TALLIES. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value. + * - reentrancy, may be caused by calling hcf_functions without adequate protection + * against NIC interrupts or multi-threading. + * - ltvp is a NULL pointer. + * - length field of the LTV-record at entry is 0 or 1 or has an excessive value (i.e. exceeds HCF_MAX_LTV). + * - type field of the LTV-record is invalid. + * + *.DIAGRAM + * Hcf_get_mb_info copies the contents of the oldest MailBox Info block in the MailBox to PC RAM. If len is + * less than the size of the MailBox Info block, only as much as fits in the PC RAM buffer is copied. After + * the copying the MailBox Read pointer is updated to point to the next MailBox Info block, hence the + * remainder of an "oversized" MailBox Info block is lost. The truncation of the MailBox Info block is NOT + * reflected in the return status. Note that hcf_get_info guarantees the length of the PC RAM buffer meets + * the minimum requirements of at least 2, so no PC RAM buffer overrun. + * + * Calling hcf_get_mb_info when their is no MailBox Info block available or when there is no MailBox at all, + * results in a "NULL" MailBox Info block. + * + *12: see NOTICE + *17: The return status of cmd_wait and the first hcfio_in_string can be ignored, because when one fails, the + * other fails via the IFB_DefunctStat mechanism + *20: "HCFASSERT( rc == HCF_SUCCESS, rc )" is not suitable because this will always trigger as side effect of + * the HCFASSERT in hcf_put_info which calls hcf_get_info to figure out whether the RID exists at all. -*.NOTICE -* -* "HCF embedded" pseudo RIDs: -* CFG_MB_INFO, CFG_TALLIES, CFG_DRV_IDENTITY, CFG_DRV_SUP_RANGE, CFG_DRV_ACT_RANGES_PRI, -* CFG_DRV_ACT_RANGES_STA, CFG_DRV_ACT_RANGES_HSI -* Note the HCF_ERR_LEN is NOT adequately set, when L >= 2 but less than needed -* -* Remarks: Transfers operation information and transient and persistent configuration information from the -* Card and from the HCF to the MSF. -* The exact layout of the provided data structure depends on the action code. Copying stops if either the -* complete Configuration Information is copied or if the number of bytes indicated by len is copied. Len -* acts as a safe guard against Configuration Information blocks which have different sizes for different -* Hermes versions, e.g. when later versions support more tallies than earlier versions. It is a conscious -* decision that unused parts of the PC RAM buffer are not cleared. -* -* Remarks: The only error against which is protected is the "Read error" as result of Card removal. Only the -* last hcf_io_string need to be protected because if the first fails the second will fail as well. Checking -* for cmd_exe errors is supposed superfluous because problems in cmd_exe are already caught or will be -* caught by hcf_enable. -* -* CFG_MB_INFO: copy the oldest MailBox Info Block or the "null" block if none available. -* -* The mechanism to HCF_ASSERT on invalid typ-codes in the LTV record is based on the following strategy: -* - during the pseudo-asynchronous Hermes commands (diagnose, download) only CFG_MB_INFO is acceptable -* - some codes (e.g. CFG_TALLIES) are explicitly handled by the HCF which implies that these codes -* are valid -* - all other codes in the range 0xFC00 through 0xFFFF are passed to the Hermes. The Hermes returns an -* LTV record with a zero value in the L-field for all Typ-codes it does not recognize. This is -* defined and intended behavior, so HCF_ASSERT does not catch on this phenomena. -* - all remaining codes are invalid and cause an ASSERT. -* -*.CONDITIONS -* In case of USB, HCF_MAX_MSG ;?USED;? to limit the amount of data that can be retrieved via hcf_get_info. -* -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + *.NOTICE + * + * "HCF embedded" pseudo RIDs: + * CFG_MB_INFO, CFG_TALLIES, CFG_DRV_IDENTITY, CFG_DRV_SUP_RANGE, CFG_DRV_ACT_RANGES_PRI, + * CFG_DRV_ACT_RANGES_STA, CFG_DRV_ACT_RANGES_HSI + * Note the HCF_ERR_LEN is NOT adequately set, when L >= 2 but less than needed + * + * Remarks: Transfers operation information and transient and persistent configuration information from the + * Card and from the HCF to the MSF. + * The exact layout of the provided data structure depends on the action code. Copying stops if either the + * complete Configuration Information is copied or if the number of bytes indicated by len is copied. Len + * acts as a safe guard against Configuration Information blocks which have different sizes for different + * Hermes versions, e.g. when later versions support more tallies than earlier versions. It is a conscious + * decision that unused parts of the PC RAM buffer are not cleared. + * + * Remarks: The only error against which is protected is the "Read error" as result of Card removal. Only the + * last hcf_io_string need to be protected because if the first fails the second will fail as well. Checking + * for cmd_exe errors is supposed superfluous because problems in cmd_exe are already caught or will be + * caught by hcf_enable. + * + * CFG_MB_INFO: copy the oldest MailBox Info Block or the "null" block if none available. + * + * The mechanism to HCF_ASSERT on invalid typ-codes in the LTV record is based on the following strategy: + * - during the pseudo-asynchronous Hermes commands (diagnose, download) only CFG_MB_INFO is acceptable + * - some codes (e.g. CFG_TALLIES) are explicitly handled by the HCF which implies that these codes + * are valid + * - all other codes in the range 0xFC00 through 0xFFFF are passed to the Hermes. The Hermes returns an + * LTV record with a zero value in the L-field for all Typ-codes it does not recognize. This is + * defined and intended behavior, so HCF_ASSERT does not catch on this phenomena. + * - all remaining codes are invalid and cause an ASSERT. + * + *.CONDITIONS + * In case of USB, HCF_MAX_MSG ;?USED;? to limit the amount of data that can be retrieved via hcf_get_info. + * + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int hcf_get_info( IFBP ifbp, LTVP ltvp ) { -int rc = HCF_SUCCESS; -hcf_16 len = ltvp->len; -hcf_16 type = ltvp->typ; -wci_recordp p = <vp->len; //destination word pointer (in LTV record) -hcf_16 *q = NULL; /* source word pointer Note!! DOS COM can't cope with FAR - * as a consequence MailBox must be near which is usually true anyway - */ -int i; + int rc = HCF_SUCCESS; + hcf_16 len = ltvp->len; + hcf_16 type = ltvp->typ; + wci_recordp p = <vp->len; //destination word pointer (in LTV record) + hcf_16 *q = NULL; /* source word pointer Note!! DOS COM can't cope with FAR + * as a consequence MailBox must be near which is usually true anyway + */ + int i; HCFLOGENTRY( HCF_TRACE_GET_INFO, ltvp->typ ); HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); @@ -2041,12 +2040,12 @@ int i; HCFASSERT( ltvp, 0 ); HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, MERGE_2( ltvp->typ, ltvp->len ) ); - ltvp->len = 0; //default to: No Info Available + ltvp->len = 0; //default to: No Info Available #if defined MSF_COMPONENT_ID || (HCF_EXT) & HCF_EXT_MB //filter out all specials for ( i = 0; ( q = xxxx[i] ) != NULL && q[1] != type; i++ ) /*NOP*/; #endif // MSF_COMPONENT_ID / HCF_EXT_MB #if HCF_TALLIES - if ( type == CFG_TALLIES ) { /*3*/ + if ( type == CFG_TALLIES ) { /*3*/ (void)hcf_action( ifbp, HCF_ACT_TALLIES ); q = (hcf_16*)&ifbp->IFB_TallyLen; } @@ -2058,7 +2057,7 @@ int i; ifbp->IFB_MBRp = 0; //;?Probably superfluous } q = &ifbp->IFB_MBp[ifbp->IFB_MBRp]; - ifbp->IFB_MBRp += *q + 1; //update read pointer + ifbp->IFB_MBRp += *q + 1; //update read pointer if ( ifbp->IFB_MBp[ifbp->IFB_MBRp] == 0xFFFF ) { ifbp->IFB_MBRp = 0; } @@ -2066,8 +2065,8 @@ int i; } } #endif // HCF_EXT_MB - if ( q != NULL ) { //a special or CFG_TALLIES or CFG_MB_INFO - i = min( len, *q ) + 1; //total size of destination (including T-field) + if ( q != NULL ) { //a special or CFG_TALLIES or CFG_MB_INFO + i = min( len, *q ) + 1; //total size of destination (including T-field) while ( i-- ) { *p++ = *q; #if (HCF_TALLIES) & HCF_TALLIES_RESET @@ -2077,50 +2076,50 @@ int i; #endif // HCF_TALLIES_RESET q++; } - } else { // not a special nor CFG_TALLIES nor CFG_MB_INFO - if ( type == CFG_CNTL_OPT ) { //read back effective options + } else { // not a special nor CFG_TALLIES nor CFG_MB_INFO + if ( type == CFG_CNTL_OPT ) { //read back effective options ltvp->len = 2; ltvp->val[0] = ifbp->IFB_CntlOpt; #if (HCF_EXT) & HCF_EXT_NIC_ACCESS } else if ( type == CFG_PROD_DATA ) { //only needed for some test tool on top of H-II NDIS driver -hcf_io io_port; -wci_bufp pt; //pointer with the "right" type, just to help ease writing macros with embedded assembly + hcf_io io_port; + wci_bufp pt; //pointer with the "right" type, just to help ease writing macros with embedded assembly OPW( HREG_AUX_PAGE, (hcf_16)(PLUG_DATA_OFFSET >> 7) ); OPW( HREG_AUX_OFFSET, (hcf_16)(PLUG_DATA_OFFSET & 0x7E) ); - io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; //to prevent side effects of the MSF-defined macro - p = ltvp->val; //destination char pointer (in LTV record) + io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; //to prevent side effects of the MSF-defined macro + p = ltvp->val; //destination char pointer (in LTV record) i = len - 1; if (i > 0 ) { - pt = (wci_bufp)p; //just to help ease writing macros with embedded assembly + pt = (wci_bufp)p; //just to help ease writing macros with embedded assembly IN_PORT_STRING_8_16( io_port, pt, i ); //space used by T: -1 } } else if ( type == CFG_CMD_HCF ) { #define P ((CFG_CMD_HCF_STRCT FAR *)ltvp) - HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported + HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported if ( P->cmd == CFG_CMD_HCF_REG_ACCESS ) { - HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space - ltvp->len = min( len, 4 ); //RESTORE ltv length + HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space + ltvp->len = min( len, 4 ); //RESTORE ltv length P->add_info = IPW( P->mode ); } #undef P #endif // HCF_EXT_NIC_ACCESS #if (HCF_ASSERT) & HCF_ASSERT_PRINTF - } else if (type == CFG_FW_PRINTF) { - rc = fw_printf(ifbp, (CFG_FW_PRINTF_STRCT*)ltvp); + } else if (type == CFG_FW_PRINTF) { + rc = fw_printf(ifbp, (CFG_FW_PRINTF_STRCT*)ltvp); #endif // HCF_ASSERT_PRINTF } else if ( type >= CFG_RID_FW_MIN ) { //;? by using HCMD_BUSY option when calling cmd_exe, using a get_frag with length 0 just to set up the //;? BAP and calling cmd_cmpl, you could merge the 2 Busy waits. Whether this really helps (and what //;? would be the optimal sequence in cmd_exe and get_frag) would have to be MEASURED -/*17*/ if ( ( rc = cmd_exe( ifbp, HCMD_ACCESS, type ) ) == HCF_SUCCESS && + /*17*/ if ( ( rc = cmd_exe( ifbp, HCMD_ACCESS, type ) ) == HCF_SUCCESS && ( rc = setup_bap( ifbp, type, 0, IO_IN ) ) == HCF_SUCCESS ) { get_frag( ifbp, (wci_bufp)<vp->len, 2*len+2 BE_PAR(2) ); - if ( IPW( HREG_STAT ) == 0xFFFF ) { //NIC removal test + if ( IPW( HREG_STAT ) == 0xFFFF ) { //NIC removal test ltvp->len = 0; HCFASSERT( DO_ASSERT, type ); } } -/*12*/ } else HCFASSERT( DO_ASSERT, type ) /*NOP*/; //NOP in case HCFASSERT is dummy + /*12*/ } else HCFASSERT( DO_ASSERT, type ) /*NOP*/; //NOP in case HCFASSERT is dummy } if ( len < ltvp->len ) { ltvp->len = len; @@ -2129,86 +2128,86 @@ wci_bufp pt; //pointer with the "right" type, just to help ease writing macr } } HCFASSERT( rc == HCF_SUCCESS || ( rc == HCF_ERR_LEN && ifbp->IFB_AssertTrace & 1<typ ); HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); @@ -2216,115 +2215,116 @@ int rc = HCF_SUCCESS; HCFASSERT( ltvp, 0 ); HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, ltvp->len ); - //all codes between 0xFA00 and 0xFCFF are passed to Hermes + //all codes between 0xFA00 and 0xFCFF are passed to Hermes #if (HCF_TYPE) & HCF_TYPE_WPA - { hcf_16 i; - hcf_32 FAR * key_p; + { + hcf_16 i; + hcf_32 FAR * key_p; - if ( ltvp->typ == CFG_ADD_TKIP_DEFAULT_KEY || ltvp->typ == CFG_ADD_TKIP_MAPPED_KEY ) { - key_p = (hcf_32*)((CFG_ADD_TKIP_MAPPED_KEY_STRCT FAR *)ltvp)->tx_mic_key; - i = TX_KEY; //i.e. TxKeyIndicator == 1, KeyID == 0 - if ( ltvp->typ == CFG_ADD_TKIP_DEFAULT_KEY ) { - key_p = (hcf_32*)((CFG_ADD_TKIP_DEFAULT_KEY_STRCT FAR *)ltvp)->tx_mic_key; - i = CNV_LITTLE_TO_SHORT(((CFG_ADD_TKIP_DEFAULT_KEY_STRCT FAR *)ltvp)->tkip_key_id_info); + if ( ltvp->typ == CFG_ADD_TKIP_DEFAULT_KEY || ltvp->typ == CFG_ADD_TKIP_MAPPED_KEY ) { + key_p = (hcf_32*)((CFG_ADD_TKIP_MAPPED_KEY_STRCT FAR *)ltvp)->tx_mic_key; + i = TX_KEY; //i.e. TxKeyIndicator == 1, KeyID == 0 + if ( ltvp->typ == CFG_ADD_TKIP_DEFAULT_KEY ) { + key_p = (hcf_32*)((CFG_ADD_TKIP_DEFAULT_KEY_STRCT FAR *)ltvp)->tx_mic_key; + i = CNV_LITTLE_TO_SHORT(((CFG_ADD_TKIP_DEFAULT_KEY_STRCT FAR *)ltvp)->tkip_key_id_info); + } + if ( i & TX_KEY ) { /* TxKeyIndicator == 1 + (either really set by MSF in case of DEFAULT or faked by HCF in case of MAPPED ) */ + ifbp->IFB_MICTxCntl = (hcf_16)( HFS_TX_CNTL_MIC | (i & KEY_ID )<<8 ); + ifbp->IFB_MICTxKey[0] = CNV_LONGP_TO_LITTLE( key_p ); + ifbp->IFB_MICTxKey[1] = CNV_LONGP_TO_LITTLE( (key_p+1) ); + } + i = ( i & KEY_ID ) * 2; + ifbp->IFB_MICRxKey[i] = CNV_LONGP_TO_LITTLE( (key_p+2) ); + ifbp->IFB_MICRxKey[i+1] = CNV_LONGP_TO_LITTLE( (key_p+3) ); } - if ( i & TX_KEY ) { /* TxKeyIndicator == 1 - (either really set by MSF in case of DEFAULT or faked by HCF in case of MAPPED ) */ - ifbp->IFB_MICTxCntl = (hcf_16)( HFS_TX_CNTL_MIC | (i & KEY_ID )<<8 ); - ifbp->IFB_MICTxKey[0] = CNV_LONGP_TO_LITTLE( key_p ); - ifbp->IFB_MICTxKey[1] = CNV_LONGP_TO_LITTLE( (key_p+1) ); - } - i = ( i & KEY_ID ) * 2; - ifbp->IFB_MICRxKey[i] = CNV_LONGP_TO_LITTLE( (key_p+2) ); - ifbp->IFB_MICRxKey[i+1] = CNV_LONGP_TO_LITTLE( (key_p+3) ); - } #define P ((CFG_REMOVE_TKIP_DEFAULT_KEY_STRCT FAR *)ltvp) - if ( ( ltvp->typ == CFG_REMOVE_TKIP_MAPPED_KEY ) || - ( ltvp->typ == CFG_REMOVE_TKIP_DEFAULT_KEY && - ( (ifbp->IFB_MICTxCntl >> 8) & KEY_ID ) == CNV_SHORT_TO_LITTLE(P->tkip_key_id ) - ) - ) { ifbp->IFB_MICTxCntl = 0; } //disable MIC-engine + if ( ( ltvp->typ == CFG_REMOVE_TKIP_MAPPED_KEY ) || + ( ltvp->typ == CFG_REMOVE_TKIP_DEFAULT_KEY && + ( (ifbp->IFB_MICTxCntl >> 8) & KEY_ID ) == CNV_SHORT_TO_LITTLE(P->tkip_key_id ) + ) + ) { ifbp->IFB_MICTxCntl = 0; } //disable MIC-engine #undef P - } + } #endif // HCF_TYPE_WPA if ( ltvp->typ == CFG_PROG ) { rc = download( ifbp, (CFG_PROG_STRCT FAR *)ltvp ); } else switch (ltvp->typ) { #if (HCF_ASSERT) & HCF_ASSERT_RT_MSF_RTN - case CFG_REG_ASSERT_RTNP: //Register MSF Routines + case CFG_REG_ASSERT_RTNP: //Register MSF Routines #define P ((CFG_REG_ASSERT_RTNP_STRCT FAR *)ltvp) - ifbp->IFB_AssertRtn = P->rtnp; -// ifbp->IFB_AssertLvl = P->lvl; //TODO not yet supported so default is set in hcf_connect - HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF1 ) ); //just to proof that the complete assert machinery is working + ifbp->IFB_AssertRtn = P->rtnp; +// ifbp->IFB_AssertLvl = P->lvl; //TODO not yet supported so default is set in hcf_connect + HCFASSERT( DO_ASSERT, MERGE_2( HCF_ASSERT, 0xCAF1 ) ); //just to proof that the complete assert machinery is working #undef P - break; + break; #endif // HCF_ASSERT_RT_MSF_RTN #if (HCF_EXT) & HCF_EXT_INFO_LOG - case CFG_REG_INFO_LOG: //Register Log filter - ifbp->IFB_RIDLogp = ((CFG_RID_LOG_STRCT FAR*)ltvp)->recordp; - break; + case CFG_REG_INFO_LOG: //Register Log filter + ifbp->IFB_RIDLogp = ((CFG_RID_LOG_STRCT FAR*)ltvp)->recordp; + break; #endif // HCF_EXT_INFO_LOG - case CFG_CNTL_OPT: //overrule option - HCFASSERT( ( ltvp->val[0] & ~(USE_DMA | USE_16BIT) ) == 0, ltvp->val[0] ); - if ( ( ltvp->val[0] & USE_DMA ) == 0 ) ifbp->IFB_CntlOpt &= ~USE_DMA; - ifbp->IFB_CntlOpt |= ltvp->val[0] & USE_16BIT; - break; + case CFG_CNTL_OPT: //overrule option + HCFASSERT( ( ltvp->val[0] & ~(USE_DMA | USE_16BIT) ) == 0, ltvp->val[0] ); + if ( ( ltvp->val[0] & USE_DMA ) == 0 ) ifbp->IFB_CntlOpt &= ~USE_DMA; + ifbp->IFB_CntlOpt |= ltvp->val[0] & USE_16BIT; + break; #if (HCF_EXT) & HCF_EXT_MB - case CFG_REG_MB: //Register MailBox + case CFG_REG_MB: //Register MailBox #define P ((CFG_REG_MB_STRCT FAR *)ltvp) - HCFASSERT( ( (hcf_32)P->mb_addr & 0x0001 ) == 0, (hcf_32)P->mb_addr ); - HCFASSERT( (P)->mb_size >= 60, (P)->mb_size ); - ifbp->IFB_MBp = P->mb_addr; - /* if no MB present, size must be 0 for ;?the old;? put_info_mb to work correctly */ - ifbp->IFB_MBSize = ifbp->IFB_MBp == NULL ? 0 : P->mb_size; - ifbp->IFB_MBWp = ifbp->IFB_MBRp = 0; - ifbp->IFB_MBp[0] = 0; //flag the MailBox as empty - ifbp->IFB_MBInfoLen = 0; - HCFASSERT( ifbp->IFB_MBSize >= 60 || ifbp->IFB_MBp == NULL, ifbp->IFB_MBSize ); + HCFASSERT( ( (hcf_32)P->mb_addr & 0x0001 ) == 0, (hcf_32)P->mb_addr ); + HCFASSERT( (P)->mb_size >= 60, (P)->mb_size ); + ifbp->IFB_MBp = P->mb_addr; + /* if no MB present, size must be 0 for ;?the old;? put_info_mb to work correctly */ + ifbp->IFB_MBSize = ifbp->IFB_MBp == NULL ? 0 : P->mb_size; + ifbp->IFB_MBWp = ifbp->IFB_MBRp = 0; + ifbp->IFB_MBp[0] = 0; //flag the MailBox as empty + ifbp->IFB_MBInfoLen = 0; + HCFASSERT( ifbp->IFB_MBSize >= 60 || ifbp->IFB_MBp == NULL, ifbp->IFB_MBSize ); #undef P - break; - case CFG_MB_INFO: //store MailBoxInfoBlock - rc = put_info_mb( ifbp, (CFG_MB_INFO_STRCT FAR *)ltvp ); - break; + break; + case CFG_MB_INFO: //store MailBoxInfoBlock + rc = put_info_mb( ifbp, (CFG_MB_INFO_STRCT FAR *)ltvp ); + break; #endif // HCF_EXT_MB #if (HCF_EXT) & HCF_EXT_NIC_ACCESS - case CFG_CMD_NIC: + case CFG_CMD_NIC: #define P ((CFG_CMD_NIC_STRCT FAR *)ltvp) - OPW( HREG_PARAM_2, P->parm2 ); - OPW( HREG_PARAM_1, P->parm1 ); - rc = cmd_exe( ifbp, P->cmd, P->parm0 ); - P->hcf_stat = (hcf_16)rc; - P->stat = IPW( HREG_STAT ); - P->resp0 = IPW( HREG_RESP_0 ); - P->resp1 = IPW( HREG_RESP_1 ); - P->resp2 = IPW( HREG_RESP_2 ); - P->ifb_err_cmd = ifbp->IFB_ErrCmd; - P->ifb_err_qualifier = ifbp->IFB_ErrQualifier; + OPW( HREG_PARAM_2, P->parm2 ); + OPW( HREG_PARAM_1, P->parm1 ); + rc = cmd_exe( ifbp, P->cmd, P->parm0 ); + P->hcf_stat = (hcf_16)rc; + P->stat = IPW( HREG_STAT ); + P->resp0 = IPW( HREG_RESP_0 ); + P->resp1 = IPW( HREG_RESP_1 ); + P->resp2 = IPW( HREG_RESP_2 ); + P->ifb_err_cmd = ifbp->IFB_ErrCmd; + P->ifb_err_qualifier = ifbp->IFB_ErrQualifier; #undef P - break; - case CFG_CMD_HCF: + break; + case CFG_CMD_HCF: #define P ((CFG_CMD_HCF_STRCT FAR *)ltvp) - HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported - if ( P->cmd == CFG_CMD_HCF_REG_ACCESS ) { - HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space - OPW( P->mode, P->add_info); - } + HCFASSERT( P->cmd == CFG_CMD_HCF_REG_ACCESS, P->cmd ); //only Hermes register access supported + if ( P->cmd == CFG_CMD_HCF_REG_ACCESS ) { + HCFASSERT( P->mode < ifbp->IFB_IOBase, P->mode ); //Check Register space + OPW( P->mode, P->add_info); + } #undef P - break; + break; #endif // HCF_EXT_NIC_ACCESS #if (HCF_ASSERT) & HCF_ASSERT_PRINTF - case CFG_FW_PRINTF_BUFFER_LOCATION: - ifbp->IFB_FwPfBuff = *(CFG_FW_PRINTF_BUFFER_LOCATION_STRCT*)ltvp; - break; + case CFG_FW_PRINTF_BUFFER_LOCATION: + ifbp->IFB_FwPfBuff = *(CFG_FW_PRINTF_BUFFER_LOCATION_STRCT*)ltvp; + break; #endif // HCF_ASSERT_PRINTF - default: //pass everything unknown above the "FID" range to the Hermes or Dongle - rc = put_info( ifbp, ltvp ); - } - //DO NOT !!! HCFASSERT( rc == HCF_SUCCESS, rc ) /* 20 */ + default: //pass everything unknown above the "FID" range to the Hermes or Dongle + rc = put_info( ifbp, ltvp ); + } + //DO NOT !!! HCFASSERT( rc == HCF_SUCCESS, rc ) /* 20 */ HCFLOGEXIT( HCF_TRACE_PUT_INFO ); return rc; } // hcf_put_info @@ -2332,121 +2332,121 @@ int rc = HCF_SUCCESS; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.MODULE int hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) -*.PURPOSE All: decapsulate a message. -* pre-HermesII.5: verify MIC. -* non-USB, non-DMA mode: Transfer a message from the NIC to the Host and acknowledge reception. -* USB: Transform a message from proprietary USB format to 802.3 format -* -*.ARGUMENTS -* ifbp address of the Interface Block -* descp Pointer to the Descriptor List location. -* offset USB: not used -* non-USB: specifies the beginning of the data to be obtained (0 corresponds with DestAddr field -* of frame). -* -*.RETURNS -* HCF_SUCCESS No SSN error ( or HCF_ERR_MIC already reported by hcf_service_nic) -* HCF_ERR_MIC message contains an erroneous MIC ( HCF_SUCCESS is reported if HCF_ERR_MIC is already -* reported by hcf_service_nic) -* HCF_ERR_NO_NIC NIC removed during data retrieval -* HCF_ERR_DEFUNCT... -* -*.DESCRIPTION -* The Receive Message Function can be executed by the MSF to obtain the Data Info fields of the message that -* is reported to be available by the Service NIC Function. -* -* The Receive Message Function copies the message data available in the Card memory into a buffer structure -* provided by the MSF. -* Only data of the message indicated by the Service NIC Function can be obtained. -* Execution of the Service NIC function may result in the availability of a new message, but it definitely -* makes the message reported by the preceding Service NIC function, unavailable. -* -* in non-USB/non-DMA mode, hcf_rcv_msg starts the copy process at the (non-negative) offset requested by the -* parameter offset, relative to HFS_ADDR_DEST, e.g offset 0 starts copying from the Destination Address, the -* very begin of the 802.3 frame message. Offset must either lay within the part of the 802.3 frame as stored -* by hcf_service_nic in the lookahead buffer or be just behind it, i.e. the first byte not yet read. -* When offset is within lookahead, data is copied from lookahead. -* When offset is beyond lookahead, data is read directly from RxFS in NIC with disregard of the actual value -* of offset -* -*.NOTICE: -* o at entry: look ahead buffer as passed with hcf_service_nic is still accessible and unchanged -* o at exit: Receive Frame in NIC memory is released -* -* Description: -* Starting at the byte indicated by the Offset value, the bytes are copied from the Data Info -* Part of the current Receive Frame Structure to the Host memory data buffer structure -* identified by descp. -* The maximum value for Offset is the number of characters of the 802.3 frame read into the -* look ahead buffer by hcf_service_nic (i.e. the look ahead buffer size minus -* Control and 802.11 fields) -* If Offset is less than the maximum value, copying starts from the look ahead buffer till the -* end of that buffer is reached -* Then (or if the maximum value is specified for Offset), the -* message is directly copied from NIC memory to Host memory. -* If an invalid (i.e. too large) offset is specified, an assert catches but the buffer contents are -* undefined. -* Copying stops if either: -* o the end of the 802.3 frame is reached -* o the Descriptor with a NULL pointer in the next_desc_addr field is reached -* -* When the copying stops, the receiver is ack'ed, thus freeing the NIC memory where the frame is stored -* As a consequence, hcf_rcv_msg can only be called once for any particular Rx frame. -* -* For the time being (PCI Bus mastering not yet supported), only the following fields of each -* of the descriptors in the descriptor list must be set by the MSF: -* o buf_cntl.buf_dim[1] -* o *next_desc_addr -* o *buf_addr -* At return from hcf_rcv_msg, the field buf_cntl.buf_dim[0] of the used Descriptors reflects -* the number of bytes in the buffer corresponding with the Descriptor. -* On the last used Descriptor, buf_cntl.buf_dim[0] is less or equal to buf_cntl.buf_dim[1]. -* On all preceding Descriptors buf_cntl.buf_dim[0] is equal to buf_cntl.buf_dim[1]. -* On all succeeding (unused) Descriptors, buf_cntl.buf_dim[0] is zero. -* Note: this I/F is based on the assumptions how the I/F needed for PCI Bus mastering will -* be, so it may change. -* -* The most likely handling of HCF_ERR_NO_NIC by the MSF is to drop the already copied -* data as elegantly as possible under the constraints and requirements posed by the (N)OS. -* If no received Frame Structure is pending, "Success" rather than "Read error" is returned. -* This error constitutes a logic flaw in the MSF -* The HCF can only catch a minority of this -* type of errors -* Based on consistency ideas, the HCF catches none of these errors. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value -* - there is no unacknowledged Rx-message available -* - offset is out of range (outside look ahead buffer) -* - descp is a NULL pointer -* - any of the descriptors is not double word aligned -* - reentrancy, may be caused by calling hcf_functions without adequate protection -* against NIC interrupts or multi-threading. -* - Interrupts are enabled. -* -*.DIAGRAM -* -*.NOTICE -* - by using unsigned int as type for offset, no need to worry about negative offsets -* - Asserting on being enabled/present is superfluous, since a non-zero IFB_lal implies that hcf_service_nic -* was called and detected a Rx-message. A zero IFB_lal will set the BUF_CNT field of at least the first -* descriptor to zero. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE int hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) + *.PURPOSE All: decapsulate a message. + * pre-HermesII.5: verify MIC. + * non-USB, non-DMA mode: Transfer a message from the NIC to the Host and acknowledge reception. + * USB: Transform a message from proprietary USB format to 802.3 format + * + *.ARGUMENTS + * ifbp address of the Interface Block + * descp Pointer to the Descriptor List location. + * offset USB: not used + * non-USB: specifies the beginning of the data to be obtained (0 corresponds with DestAddr field + * of frame). + * + *.RETURNS + * HCF_SUCCESS No SSN error ( or HCF_ERR_MIC already reported by hcf_service_nic) + * HCF_ERR_MIC message contains an erroneous MIC ( HCF_SUCCESS is reported if HCF_ERR_MIC is already + * reported by hcf_service_nic) + * HCF_ERR_NO_NIC NIC removed during data retrieval + * HCF_ERR_DEFUNCT... + * + *.DESCRIPTION + * The Receive Message Function can be executed by the MSF to obtain the Data Info fields of the message that + * is reported to be available by the Service NIC Function. + * + * The Receive Message Function copies the message data available in the Card memory into a buffer structure + * provided by the MSF. + * Only data of the message indicated by the Service NIC Function can be obtained. + * Execution of the Service NIC function may result in the availability of a new message, but it definitely + * makes the message reported by the preceding Service NIC function, unavailable. + * + * in non-USB/non-DMA mode, hcf_rcv_msg starts the copy process at the (non-negative) offset requested by the + * parameter offset, relative to HFS_ADDR_DEST, e.g offset 0 starts copying from the Destination Address, the + * very begin of the 802.3 frame message. Offset must either lay within the part of the 802.3 frame as stored + * by hcf_service_nic in the lookahead buffer or be just behind it, i.e. the first byte not yet read. + * When offset is within lookahead, data is copied from lookahead. + * When offset is beyond lookahead, data is read directly from RxFS in NIC with disregard of the actual value + * of offset + * + *.NOTICE: + * o at entry: look ahead buffer as passed with hcf_service_nic is still accessible and unchanged + * o at exit: Receive Frame in NIC memory is released + * + * Description: + * Starting at the byte indicated by the Offset value, the bytes are copied from the Data Info + * Part of the current Receive Frame Structure to the Host memory data buffer structure + * identified by descp. + * The maximum value for Offset is the number of characters of the 802.3 frame read into the + * look ahead buffer by hcf_service_nic (i.e. the look ahead buffer size minus + * Control and 802.11 fields) + * If Offset is less than the maximum value, copying starts from the look ahead buffer till the + * end of that buffer is reached + * Then (or if the maximum value is specified for Offset), the + * message is directly copied from NIC memory to Host memory. + * If an invalid (i.e. too large) offset is specified, an assert catches but the buffer contents are + * undefined. + * Copying stops if either: + * o the end of the 802.3 frame is reached + * o the Descriptor with a NULL pointer in the next_desc_addr field is reached + * + * When the copying stops, the receiver is ack'ed, thus freeing the NIC memory where the frame is stored + * As a consequence, hcf_rcv_msg can only be called once for any particular Rx frame. + * + * For the time being (PCI Bus mastering not yet supported), only the following fields of each + * of the descriptors in the descriptor list must be set by the MSF: + * o buf_cntl.buf_dim[1] + * o *next_desc_addr + * o *buf_addr + * At return from hcf_rcv_msg, the field buf_cntl.buf_dim[0] of the used Descriptors reflects + * the number of bytes in the buffer corresponding with the Descriptor. + * On the last used Descriptor, buf_cntl.buf_dim[0] is less or equal to buf_cntl.buf_dim[1]. + * On all preceding Descriptors buf_cntl.buf_dim[0] is equal to buf_cntl.buf_dim[1]. + * On all succeeding (unused) Descriptors, buf_cntl.buf_dim[0] is zero. + * Note: this I/F is based on the assumptions how the I/F needed for PCI Bus mastering will + * be, so it may change. + * + * The most likely handling of HCF_ERR_NO_NIC by the MSF is to drop the already copied + * data as elegantly as possible under the constraints and requirements posed by the (N)OS. + * If no received Frame Structure is pending, "Success" rather than "Read error" is returned. + * This error constitutes a logic flaw in the MSF + * The HCF can only catch a minority of this + * type of errors + * Based on consistency ideas, the HCF catches none of these errors. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value + * - there is no unacknowledged Rx-message available + * - offset is out of range (outside look ahead buffer) + * - descp is a NULL pointer + * - any of the descriptors is not double word aligned + * - reentrancy, may be caused by calling hcf_functions without adequate protection + * against NIC interrupts or multi-threading. + * - Interrupts are enabled. + * + *.DIAGRAM + * + *.NOTICE + * - by using unsigned int as type for offset, no need to worry about negative offsets + * - Asserting on being enabled/present is superfluous, since a non-zero IFB_lal implies that hcf_service_nic + * was called and detected a Rx-message. A zero IFB_lal will set the BUF_CNT field of at least the first + * descriptor to zero. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) { -int rc = HCF_SUCCESS; -wci_bufp cp; //char oriented working pointer -hcf_16 i; -int tot_len = ifbp->IFB_RxLen - offset; //total length -wci_bufp lap = ifbp->IFB_lap + offset; //start address in LookAhead Buffer -hcf_16 lal = ifbp->IFB_lal - offset; //available data within LookAhead Buffer -hcf_16 j; + int rc = HCF_SUCCESS; + wci_bufp cp; //char oriented working pointer + hcf_16 i; + int tot_len = ifbp->IFB_RxLen - offset; //total length + wci_bufp lap = ifbp->IFB_lap + offset; //start address in LookAhead Buffer + hcf_16 lal = ifbp->IFB_lal - offset; //available data within LookAhead Buffer + hcf_16 j; HCFLOGENTRY( HCF_TRACE_RCV_MSG, offset ); HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); @@ -2458,34 +2458,34 @@ hcf_16 j; HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADA ); if ( tot_len < 0 ) { - lal = 0; tot_len = 0; //suppress all copying activity in the do--while loop + lal = 0; tot_len = 0; //suppress all copying activity in the do--while loop } - do { //loop over all available fragments + do { //loop over all available fragments // obnoxious hcf.c(1480) : warning C4769: conversion of near pointer to long integer HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ); cp = descp->buf_addr; - j = min( (hcf_16)tot_len, descp->BUF_SIZE ); //minimum of "what's` available" and fragment size + j = min( (hcf_16)tot_len, descp->BUF_SIZE ); //minimum of "what's` available" and fragment size descp->BUF_CNT = j; - tot_len -= j; //adjust length still to go - if ( lal ) { //if lookahead Buffer not yet completely copied - i = min( lal, j ); //minimum of "what's available" in LookAhead and fragment size - lal -= i; //adjust length still available in LookAhead - j -= i; //adjust length still available in current fragment + tot_len -= j; //adjust length still to go + if ( lal ) { //if lookahead Buffer not yet completely copied + i = min( lal, j ); //minimum of "what's available" in LookAhead and fragment size + lal -= i; //adjust length still available in LookAhead + j -= i; //adjust length still available in current fragment /*;? while loop could be improved by moving words but that is complicated on platforms with * alignment requirements*/ while ( i-- ) *cp++ = *lap++; } - if ( j ) { //if LookAhead Buffer exhausted but still space in fragment, copy directly from NIC RAM + if ( j ) { //if LookAhead Buffer exhausted but still space in fragment, copy directly from NIC RAM get_frag( ifbp, cp, j BE_PAR(0) ); CALC_RX_MIC( cp, j ); } } while ( ( descp = descp->next_desc_addr ) != NULL ); #if (HCF_TYPE) & HCF_TYPE_WPA if ( ifbp->IFB_RxFID ) { - rc = check_mic( ifbp ); //prevents MIC error report if hcf_service_nic already consumed all + rc = check_mic( ifbp ); //prevents MIC error report if hcf_service_nic already consumed all } #endif // HCF_TYPE_WPA - (void)hcf_action( ifbp, HCF_ACT_RX_ACK ); //only 1 shot to get the data, so free the resources in the NIC + (void)hcf_action( ifbp, HCF_ACT_RX_ACK ); //only 1 shot to get the data, so free the resources in the NIC HCFASSERT( rc == HCF_SUCCESS, rc ); HCFLOGEXIT( HCF_TRACE_RCV_MSG ); return rc; @@ -2495,168 +2495,168 @@ hcf_16 j; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.MODULE int hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) -*.PURPOSE Encapsulate a message and append padding and MIC. -* non-USB: Transfers the resulting message from Host to NIC and initiates transmission. -* USB: Transfer resulting message into a flat buffer. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* descp pointer to the DescriptorList or NULL -* tx_cntl indicates MAC-port and (Hermes) options -* HFS_TX_CNTL_SPECTRALINK -* HFS_TX_CNTL_PRIO -* HFS_TX_CNTL_TX_OK -* HFS_TX_CNTL_TX_EX -* HFS_TX_CNTL_TX_DELAY -* HFS_TX_CNTL_TX_CONT -* HCF_PORT_0 MAC Port 0 (default) -* HCF_PORT_1 (AP only) MAC Port 1 -* HCF_PORT_2 (AP only) MAC Port 2 -* HCF_PORT_3 (AP only) MAC Port 3 -* HCF_PORT_4 (AP only) MAC Port 4 -* HCF_PORT_5 (AP only) MAC Port 5 -* HCF_PORT_6 (AP only) MAC Port 6 -* -*.RETURNS -* HCF_SUCCESS -* HCF_ERR_DEFUNCT_.. -* HCF_ERR_TIME_OUT -* -*.DESCRIPTION: -* The Send Message Function embodies 2 functions: -* o transfers a message (including MAC header) from the provided buffer structure in Host memory to the Transmit -* Frame Structure (TxFS) in NIC memory. -* o Issue a send command to the F/W to actually transmit the contents of the TxFS. -* -* Control is based on the Resource Indicator IFB_RscInd. -* The Resource Indicator is maintained by the HCF and should only be interpreted but not changed by the MSF. -* The MSF must check IFB_RscInd to be non-zero before executing the call to the Send Message Function. -* When no resources are available, the MSF must handle the queuing of the Transmit frame and check the -* Resource Indicator periodically after calling hcf_service_nic. -* -* The Send Message Functions transfers a message to NIC memory when it is called with a non-NULL descp. -* Before the Send Message Function is invoked this way, the Resource Indicator (IFB_RscInd) must be checked. -* If the Resource is not available, Send Message Function execution must be postponed until after processing of -* a next hcf_service_nic it appears that the Resource has become available. -* The message is copied from the buffer structure identified by descp to the NIC. -* Copying stops if a NULL pointer in the next_desc_addr field is reached. -* Hcf_send_msg does not check for transmit buffer overflow, because the F/W does this protection. -* In case of a transmit buffer overflow, the surplus which does not fit in the buffer is simply dropped. -* -* The Send Message Function activates the F/W to actually send the message to the medium when the -* HFS_TX_CNTL_TX_DELAY bit of the tx_cntl parameter is not set. -* If the descp parameter of the current call is non-NULL, the message as represented by descp is send. -* If the descp parameter of the current call is NULL, and if the preceding call of the Send Message Function had -* a non-NULL descp and the preceding call had the HFS_TX_CNTL_TX_DELAY bit of tx_cntl set, then the message as -* represented by the descp of the preceding call is send. -* -* Hcf_send_msg supports encapsulation (see HCF_ENCAP) of Ethernet-II frames. -* An Ethernet-II frame is transferred to the Transmit Frame structure as an 802.3 frame. -* Hcf_send_msg distinguishes between an 802.3 and an Ethernet-II frame by looking at the data length/type field -* of the frame. If this field contains a value larger than 1514, the frame is considered to be an Ethernet-II -* frame, otherwise it is treated as an 802.3 frame. -* To ease implementation of the HCF, this type/type field must be located in the first descriptor structure, -* i.e. the 1st fragment must have a size of at least 14 (to contain DestAddr, SrcAddr and Len/Type field). -* An Ethernet-II frame is encapsulated by inserting a SNAP header between the addressing information and the -* type field. This insertion is transparent for the MSF. -* The HCF contains a fixed table that stores a number of types. If the value specified by the type/type field -* occurs in this table, Bridge Tunnel Encapsulation is used, otherwise RFC1042 encapsulation is used. -* Bridge Tunnel uses AA AA 03 00 00 F8 as SNAP header, -* RFC1042 uses AA AA 03 00 00 00 as SNAP header. -* The table currently contains: -* 0 0x80F3 AppleTalk Address Resolution Protocol (AARP) -* 0 0x8137 IPX -* -* The algorithm to distinguish between 802.3 and Ethernet-II frames limits the maximum length for frames of -* 802.3 frames to 1514 bytes. -* Encapsulation can be suppressed by means of the system constant HCF_ENCAP, e.g. to support proprietary -* protocols with 802.3 like frames with a size larger than 1514 bytes. -* -* In case the HCF encapsulates the frame, the number of bytes that is actually transmitted is determined by the -* cumulative value of the buf_cntl.buf_dim[0] fields. -* In case the HCF does not encapsulate the frame, the number of bytes that is actually transmitted is not -* determined by the cumulative value of the buf_cntl.buf_dim[DESC_CNTL_CNT] fields of the desc_strct's but by -* the Length field of the 802.3 frame. -* If there is a conflict between the cumulative value of the buf_cntl.buf_dim[0] fields and the -* 802.3 Length field the 802.3 Length field determines the number of bytes actually transmitted by the NIC while -* the cumulative value of the buf_cntl.buf_dim[0] fields determines the position of the MIC, hence a mismatch -* will result in MIC errors on the Receiving side. -* Currently this problem is flagged on the Transmit side by an Assert. -* The following fields of each of the descriptors in the descriptor list must be set by the MSF: -* o buf_cntl.buf_dim[0] -* o *next_desc_addr -* o *buf_addr -* -* All bits of the tx_cntl parameter except HFS_TX_CNTL_TX_DELAY and the HCF_PORT# bits are passed to the F/W via -* the HFS_TX_CNTL field of the TxFS. -* -* Note that hcf_send_msg does not detect NIC absence. The MSF is supposed to have its own -platform dependent- -* way to recognize card removal/insertion. -* The total system must be robust against card removal and there is no principal difference between card removal -* just after hcf_send_msg returns but before the actual transmission took place or sometime earlier. -* -* Assert fails if -* - ifbp has a recognizable out-of-range value -* - descp is a NULL pointer -* - no resources for PIF available. -* - Interrupts are enabled. -* - reentrancy, may be caused by calling hcf_functions without adequate protection -* against NIC interrupts or multi-threading. -* -*.DIAGRAM -*4: for the normal case (i.e. no HFS_TX_CNTL_TX_DELAY option active), a fid is acquired via the -* routine get_fid. If no FID is acquired, the remainder is skipped without an error notification. After -* all, the MSF is not supposed to call hcf_send_msg when no Resource is available. -*7: The ControlField of the TxFS is written. Since put_frag can only return the fatal Defunct or "No NIC", the -* return status can be ignored because when it fails, cmd_wait will fail as well. (see also the note on the -* need for a return code below). -* Note that HFS_TX_CNTL has different values for H-I, H-I/SSN and H-II and HFS_ADDR_DEST has different -* values for H-I (regardless of SSN) and H-II. -* By writing 17, 1 or 2 ( implying 16, 0 or 1 garbage word after HFS_TX_CNTL) the BAP just gets to -* HFS_ADDR_DEST for H-I, H-I/SSN and H-II respectively. -*10: if neither encapsulation nor MIC calculation is needed, splitting the first fragment in two does not -* really help but it makes the flow easier to follow to do not optimize on this difference -* -* hcf_send_msg checks whether the frame is an Ethernet-II rather than an "official" 802.3 frame. -* The E-II check is based on the length/type field in the MAC header. If this field has a value larger than -* 1500, E-II is assumed. The implementation of this test fails if the length/type field is not in the first -* descriptor. If E-II is recognized, a SNAP header is inserted. This SNAP header represents either RFC1042 -* or Bridge-Tunnel encapsulation, depending on the return status of the support routine hcf_encap. -* -*.NOTICE -* hcf_send_msg leaves the responsibility to only send messages on enabled ports at the MSF level. -* This is considered the strategy which is sufficiently adequate for all "robust" MSFs, have the least -* processor utilization and being still acceptable robust at the WCI !!!!! -* -* hcf_send_msg does not NEED a return value to report NIC absence or removal during the execution of -* hcf_send_msg(), because the MSF and higher layers must be able to cope anyway with the NIC being removed -* after a successful completion of hcf_send_msg() but before the actual transmission took place. -* To accommodate user expectations the current implementation does report NIC absence. -* Defunct blocks all NIC access and will (also) be reported on a number of other calls. -* -* hcf_send_msg does not check for transmit buffer overflow because the Hermes does this protection. -* In case of a transmit buffer overflow, the surplus which does not fit in the buffer is simply dropped. -* Note that this possibly results in the transmission of incomplete frames. -* -* After some deliberation with F/W team, it is decided that - being in the twilight zone of not knowing -* whether the problem at hand is an MSF bug, HCF buf, F/W bug, H/W malfunction or even something else - there -* is no "best thing to do" in case of a failing send, hence the HCF considers the TxFID ownership to be taken -* over by the F/W and hopes for an Allocate event in due time -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.MODULE int hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) + *.PURPOSE Encapsulate a message and append padding and MIC. + * non-USB: Transfers the resulting message from Host to NIC and initiates transmission. + * USB: Transfer resulting message into a flat buffer. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * descp pointer to the DescriptorList or NULL + * tx_cntl indicates MAC-port and (Hermes) options + * HFS_TX_CNTL_SPECTRALINK + * HFS_TX_CNTL_PRIO + * HFS_TX_CNTL_TX_OK + * HFS_TX_CNTL_TX_EX + * HFS_TX_CNTL_TX_DELAY + * HFS_TX_CNTL_TX_CONT + * HCF_PORT_0 MAC Port 0 (default) + * HCF_PORT_1 (AP only) MAC Port 1 + * HCF_PORT_2 (AP only) MAC Port 2 + * HCF_PORT_3 (AP only) MAC Port 3 + * HCF_PORT_4 (AP only) MAC Port 4 + * HCF_PORT_5 (AP only) MAC Port 5 + * HCF_PORT_6 (AP only) MAC Port 6 + * + *.RETURNS + * HCF_SUCCESS + * HCF_ERR_DEFUNCT_.. + * HCF_ERR_TIME_OUT + * + *.DESCRIPTION: + * The Send Message Function embodies 2 functions: + * o transfers a message (including MAC header) from the provided buffer structure in Host memory to the Transmit + * Frame Structure (TxFS) in NIC memory. + * o Issue a send command to the F/W to actually transmit the contents of the TxFS. + * + * Control is based on the Resource Indicator IFB_RscInd. + * The Resource Indicator is maintained by the HCF and should only be interpreted but not changed by the MSF. + * The MSF must check IFB_RscInd to be non-zero before executing the call to the Send Message Function. + * When no resources are available, the MSF must handle the queuing of the Transmit frame and check the + * Resource Indicator periodically after calling hcf_service_nic. + * + * The Send Message Functions transfers a message to NIC memory when it is called with a non-NULL descp. + * Before the Send Message Function is invoked this way, the Resource Indicator (IFB_RscInd) must be checked. + * If the Resource is not available, Send Message Function execution must be postponed until after processing of + * a next hcf_service_nic it appears that the Resource has become available. + * The message is copied from the buffer structure identified by descp to the NIC. + * Copying stops if a NULL pointer in the next_desc_addr field is reached. + * Hcf_send_msg does not check for transmit buffer overflow, because the F/W does this protection. + * In case of a transmit buffer overflow, the surplus which does not fit in the buffer is simply dropped. + * + * The Send Message Function activates the F/W to actually send the message to the medium when the + * HFS_TX_CNTL_TX_DELAY bit of the tx_cntl parameter is not set. + * If the descp parameter of the current call is non-NULL, the message as represented by descp is send. + * If the descp parameter of the current call is NULL, and if the preceding call of the Send Message Function had + * a non-NULL descp and the preceding call had the HFS_TX_CNTL_TX_DELAY bit of tx_cntl set, then the message as + * represented by the descp of the preceding call is send. + * + * Hcf_send_msg supports encapsulation (see HCF_ENCAP) of Ethernet-II frames. + * An Ethernet-II frame is transferred to the Transmit Frame structure as an 802.3 frame. + * Hcf_send_msg distinguishes between an 802.3 and an Ethernet-II frame by looking at the data length/type field + * of the frame. If this field contains a value larger than 1514, the frame is considered to be an Ethernet-II + * frame, otherwise it is treated as an 802.3 frame. + * To ease implementation of the HCF, this type/type field must be located in the first descriptor structure, + * i.e. the 1st fragment must have a size of at least 14 (to contain DestAddr, SrcAddr and Len/Type field). + * An Ethernet-II frame is encapsulated by inserting a SNAP header between the addressing information and the + * type field. This insertion is transparent for the MSF. + * The HCF contains a fixed table that stores a number of types. If the value specified by the type/type field + * occurs in this table, Bridge Tunnel Encapsulation is used, otherwise RFC1042 encapsulation is used. + * Bridge Tunnel uses AA AA 03 00 00 F8 as SNAP header, + * RFC1042 uses AA AA 03 00 00 00 as SNAP header. + * The table currently contains: + * 0 0x80F3 AppleTalk Address Resolution Protocol (AARP) + * 0 0x8137 IPX + * + * The algorithm to distinguish between 802.3 and Ethernet-II frames limits the maximum length for frames of + * 802.3 frames to 1514 bytes. + * Encapsulation can be suppressed by means of the system constant HCF_ENCAP, e.g. to support proprietary + * protocols with 802.3 like frames with a size larger than 1514 bytes. + * + * In case the HCF encapsulates the frame, the number of bytes that is actually transmitted is determined by the + * cumulative value of the buf_cntl.buf_dim[0] fields. + * In case the HCF does not encapsulate the frame, the number of bytes that is actually transmitted is not + * determined by the cumulative value of the buf_cntl.buf_dim[DESC_CNTL_CNT] fields of the desc_strct's but by + * the Length field of the 802.3 frame. + * If there is a conflict between the cumulative value of the buf_cntl.buf_dim[0] fields and the + * 802.3 Length field the 802.3 Length field determines the number of bytes actually transmitted by the NIC while + * the cumulative value of the buf_cntl.buf_dim[0] fields determines the position of the MIC, hence a mismatch + * will result in MIC errors on the Receiving side. + * Currently this problem is flagged on the Transmit side by an Assert. + * The following fields of each of the descriptors in the descriptor list must be set by the MSF: + * o buf_cntl.buf_dim[0] + * o *next_desc_addr + * o *buf_addr + * + * All bits of the tx_cntl parameter except HFS_TX_CNTL_TX_DELAY and the HCF_PORT# bits are passed to the F/W via + * the HFS_TX_CNTL field of the TxFS. + * + * Note that hcf_send_msg does not detect NIC absence. The MSF is supposed to have its own -platform dependent- + * way to recognize card removal/insertion. + * The total system must be robust against card removal and there is no principal difference between card removal + * just after hcf_send_msg returns but before the actual transmission took place or sometime earlier. + * + * Assert fails if + * - ifbp has a recognizable out-of-range value + * - descp is a NULL pointer + * - no resources for PIF available. + * - Interrupts are enabled. + * - reentrancy, may be caused by calling hcf_functions without adequate protection + * against NIC interrupts or multi-threading. + * + *.DIAGRAM + *4: for the normal case (i.e. no HFS_TX_CNTL_TX_DELAY option active), a fid is acquired via the + * routine get_fid. If no FID is acquired, the remainder is skipped without an error notification. After + * all, the MSF is not supposed to call hcf_send_msg when no Resource is available. + *7: The ControlField of the TxFS is written. Since put_frag can only return the fatal Defunct or "No NIC", the + * return status can be ignored because when it fails, cmd_wait will fail as well. (see also the note on the + * need for a return code below). + * Note that HFS_TX_CNTL has different values for H-I, H-I/SSN and H-II and HFS_ADDR_DEST has different + * values for H-I (regardless of SSN) and H-II. + * By writing 17, 1 or 2 ( implying 16, 0 or 1 garbage word after HFS_TX_CNTL) the BAP just gets to + * HFS_ADDR_DEST for H-I, H-I/SSN and H-II respectively. + *10: if neither encapsulation nor MIC calculation is needed, splitting the first fragment in two does not + * really help but it makes the flow easier to follow to do not optimize on this difference + * + * hcf_send_msg checks whether the frame is an Ethernet-II rather than an "official" 802.3 frame. + * The E-II check is based on the length/type field in the MAC header. If this field has a value larger than + * 1500, E-II is assumed. The implementation of this test fails if the length/type field is not in the first + * descriptor. If E-II is recognized, a SNAP header is inserted. This SNAP header represents either RFC1042 + * or Bridge-Tunnel encapsulation, depending on the return status of the support routine hcf_encap. + * + *.NOTICE + * hcf_send_msg leaves the responsibility to only send messages on enabled ports at the MSF level. + * This is considered the strategy which is sufficiently adequate for all "robust" MSFs, have the least + * processor utilization and being still acceptable robust at the WCI !!!!! + * + * hcf_send_msg does not NEED a return value to report NIC absence or removal during the execution of + * hcf_send_msg(), because the MSF and higher layers must be able to cope anyway with the NIC being removed + * after a successful completion of hcf_send_msg() but before the actual transmission took place. + * To accommodate user expectations the current implementation does report NIC absence. + * Defunct blocks all NIC access and will (also) be reported on a number of other calls. + * + * hcf_send_msg does not check for transmit buffer overflow because the Hermes does this protection. + * In case of a transmit buffer overflow, the surplus which does not fit in the buffer is simply dropped. + * Note that this possibly results in the transmission of incomplete frames. + * + * After some deliberation with F/W team, it is decided that - being in the twilight zone of not knowing + * whether the problem at hand is an MSF bug, HCF buf, F/W bug, H/W malfunction or even something else - there + * is no "best thing to do" in case of a failing send, hence the HCF considers the TxFID ownership to be taken + * over by the F/W and hopes for an Allocate event in due time + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) { -int rc = HCF_SUCCESS; -DESC_STRCT *p /* = descp*/; //working pointer -hcf_16 len; // total byte count -hcf_16 i; + int rc = HCF_SUCCESS; + DESC_STRCT *p /* = descp*/; //working pointer + hcf_16 len; // total byte count + hcf_16 i; -hcf_16 fid = 0; + hcf_16 fid = 0; HCFASSERT( ifbp->IFB_RscInd || descp == NULL, ifbp->IFB_RscInd ); HCFASSERT( (ifbp->IFB_CntlOpt & USE_DMA) == 0, 0xDADB ); @@ -2668,22 +2668,22 @@ hcf_16 fid = 0; * so skip */ HCFASSERT( ((hcf_32)descp & 3 ) == 0, (hcf_32)descp ); #if HCF_ASSERT -{ int x = ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ? tx_cntl & ~HFS_TX_CNTL_PORT : tx_cntl; - HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ); -} + { int x = ifbp->IFB_FWIdentity.comp_id == COMP_ID_FW_AP ? tx_cntl & ~HFS_TX_CNTL_PORT : tx_cntl; + HCFASSERT( (x & ~HCF_TX_CNTL_MASK ) == 0, tx_cntl ); + } #endif // HCF_ASSERT - if ( descp ) ifbp->IFB_TxFID = 0; //cancel a pre-put message + if ( descp ) ifbp->IFB_TxFID = 0; //cancel a pre-put message -#if (HCF_EXT) & HCF_EXT_TX_CONT // Continuous transmit test +#if (HCF_EXT) & HCF_EXT_TX_CONT // Continuous transmit test if ( tx_cntl == HFS_TX_CNTL_TX_CONT ) { - fid = get_fid(ifbp); - if (fid != 0 ) { - //setup BAP to begin of TxFS + fid = get_fid(ifbp); + if (fid != 0 ) { + //setup BAP to begin of TxFS (void)setup_bap( ifbp, fid, 0, IO_OUT ); - //copy all the fragments in a transparent fashion - for ( p = descp; p; p = p->next_desc_addr ) { - /* obnoxious warning C4769: conversion of near pointer to long integer */ + //copy all the fragments in a transparent fashion + for ( p = descp; p; p = p->next_desc_addr ) { + /* obnoxious warning C4769: conversion of near pointer to long integer */ HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); put_frag( ifbp, p->buf_addr, p->BUF_CNT BE_PAR(0) ); } @@ -2692,79 +2692,79 @@ hcf_16 fid = 0; ifbp->IFB_RscInd = get_fid( ifbp ); } } - // een slecht voorbeeld doet goed volgen ;? + // een slecht voorbeeld doet goed volgen ;? HCFLOGEXIT( HCF_TRACE_SEND_MSG ); return rc; } #endif // HCF_EXT_TX_CONT - /* the following initialization code is redundant for a pre-put message - * but moving it inside the "if fid" logic makes the merging with the - * USB flow awkward - */ + /* the following initialization code is redundant for a pre-put message + * but moving it inside the "if fid" logic makes the merging with the + * USB flow awkward + */ #if (HCF_TYPE) & HCF_TYPE_WPA tx_cntl |= ifbp->IFB_MICTxCntl; #endif // HCF_TYPE_WPA fid = ifbp->IFB_TxFID; - if (fid == 0 && ( fid = get_fid( ifbp ) ) != 0 ) /* 4 */ - /* skip the next compound statement if: - - pre-put message or - - no fid available (which should never occur if the MSF adheres to the WCI) - */ - { // to match the closing curly bracket of above "if" in case of HCF_TYPE_USB - //calculate total length ;? superfluous unless CCX or Encapsulation + if (fid == 0 && ( fid = get_fid( ifbp ) ) != 0 ) /* 4 */ + /* skip the next compound statement if: + - pre-put message or + - no fid available (which should never occur if the MSF adheres to the WCI) + */ + { // to match the closing curly bracket of above "if" in case of HCF_TYPE_USB + //calculate total length ;? superfluous unless CCX or Encapsulation len = 0; p = descp; do len += p->BUF_CNT; while ( ( p = p->next_desc_addr ) != NULL ); p = descp; -//;? HCFASSERT( len <= HCF_MAX_MSG, len ); -/*7*/ (void)setup_bap( ifbp, fid, HFS_TX_CNTL, IO_OUT ); +//;? HCFASSERT( len <= HCF_MAX_MSG, len ); + /*7*/ (void)setup_bap( ifbp, fid, HFS_TX_CNTL, IO_OUT ); #if (HCF_TYPE) & HCF_TYPE_TX_DELAY HCFASSERT( ( descp != NULL ) ^ ( tx_cntl & HFS_TX_CNTL_TX_DELAY ), tx_cntl ); if ( tx_cntl & HFS_TX_CNTL_TX_DELAY ) { - tx_cntl &= ~HFS_TX_CNTL_TX_DELAY; //!!HFS_TX_CNTL_TX_DELAY no longer available + tx_cntl &= ~HFS_TX_CNTL_TX_DELAY; //!!HFS_TX_CNTL_TX_DELAY no longer available ifbp->IFB_TxFID = fid; - fid = 0; //!!fid no longer available, be careful when modifying code + fid = 0; //!!fid no longer available, be careful when modifying code } #endif // HCF_TYPE_TX_DELAY OPW( HREG_DATA_1, tx_cntl ) ; OPW( HREG_DATA_1, 0 ); #if ! ( (HCF_TYPE) & HCF_TYPE_CCX ) HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); - /* assume DestAddr/SrcAddr/Len/Type ALWAYS contained in 1st fragment - * otherwise life gets too cumbersome for MIC and Encapsulation !!!!!!!! - if ( p->BUF_CNT >= 14 ) { alternatively: add a safety escape !!!!!!!!!!!! } */ + /* assume DestAddr/SrcAddr/Len/Type ALWAYS contained in 1st fragment + * otherwise life gets too cumbersome for MIC and Encapsulation !!!!!!!! + if ( p->BUF_CNT >= 14 ) { alternatively: add a safety escape !!!!!!!!!!!! } */ #endif // HCF_TYPE_CCX - CALC_TX_MIC( NULL, -1 ); //initialize MIC -/*10*/ put_frag( ifbp, p->buf_addr, HCF_DASA_SIZE BE_PAR(0) ); //write DA, SA with MIC calculation - CALC_TX_MIC( p->buf_addr, HCF_DASA_SIZE ); //MIC over DA, SA - CALC_TX_MIC( null_addr, 4 ); //MIC over (virtual) priority field + CALC_TX_MIC( NULL, -1 ); //initialize MIC + /*10*/ put_frag( ifbp, p->buf_addr, HCF_DASA_SIZE BE_PAR(0) ); //write DA, SA with MIC calculation + CALC_TX_MIC( p->buf_addr, HCF_DASA_SIZE ); //MIC over DA, SA + CALC_TX_MIC( null_addr, 4 ); //MIC over (virtual) priority field #if (HCF_TYPE) & HCF_TYPE_CCX //!!be careful do not use positive test on HCF_ACT_CCX_OFF, because IFB_CKIPStat is initially 0 if(( ifbp->IFB_CKIPStat == HCF_ACT_CCX_ON ) || - ((GET_BUF_CNT(p) >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && - (p->buf_addr[12] == 0xAA) && (p->buf_addr[13] == 0xAA) && - (p->buf_addr[14] == 0x03) && (p->buf_addr[15] == 0x00) && - (p->buf_addr[16] == 0x40) && (p->buf_addr[17] == 0x96) && - (p->buf_addr[18] == 0x00) && (p->buf_addr[19] == 0x00))) - { - i = HCF_DASA_SIZE; + ((GET_BUF_CNT(p) >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && + (p->buf_addr[12] == 0xAA) && (p->buf_addr[13] == 0xAA) && + (p->buf_addr[14] == 0x03) && (p->buf_addr[15] == 0x00) && + (p->buf_addr[16] == 0x40) && (p->buf_addr[17] == 0x96) && + (p->buf_addr[18] == 0x00) && (p->buf_addr[19] == 0x00))) + { + i = HCF_DASA_SIZE; - OPW( HREG_DATA_1, CNV_SHORT_TO_BIG( len - i )); + OPW( HREG_DATA_1, CNV_SHORT_TO_BIG( len - i )); - /* need to send out the remainder of the fragment */ + /* need to send out the remainder of the fragment */ put_frag( ifbp, &p->buf_addr[i], GET_BUF_CNT(p) - i BE_PAR(0) ); - } - else + } + else #endif // HCF_TYPE_CCX { - //if encapsulation needed + //if encapsulation needed #if (HCF_ENCAP) == HCF_ENC - //write length (with SNAP-header,Type, without //DA,SA,Length ) no MIC calc. + //write length (with SNAP-header,Type, without //DA,SA,Length ) no MIC calc. if ( ( snap_header[sizeof(snap_header)-1] = hcf_encap( &p->buf_addr[HCF_DASA_SIZE] ) ) != ENC_NONE ) { OPW( HREG_DATA_1, CNV_END_SHORT( len + (sizeof(snap_header) + 2) - ( 2*6 + 2 ) ) ); - //write splice with MIC calculation + //write splice with MIC calculation put_frag( ifbp, snap_header, sizeof(snap_header) BE_PAR(0) ); - CALC_TX_MIC( snap_header, sizeof(snap_header) ); //MIC over 6 byte SNAP + CALC_TX_MIC( snap_header, sizeof(snap_header) ); //MIC over 6 byte SNAP i = HCF_DASA_SIZE; } else #endif // HCF_ENC @@ -2772,11 +2772,11 @@ hcf_16 fid = 0; OPW( HREG_DATA_1, *(wci_recordp)&p->buf_addr[HCF_DASA_SIZE] ); i = 14; } - //complete 1st fragment starting with Type with MIC calculation + //complete 1st fragment starting with Type with MIC calculation put_frag( ifbp, &p->buf_addr[i], p->BUF_CNT - i BE_PAR(0) ); CALC_TX_MIC( &p->buf_addr[i], p->BUF_CNT - i ); } - //do the remaining fragments with MIC calculation + //do the remaining fragments with MIC calculation while ( ( p = p->next_desc_addr ) != NULL ) { /* obnoxious c:/hcf/hcf.c(1480) : warning C4769: conversion of near pointer to long integer, * so skip */ @@ -2784,18 +2784,18 @@ hcf_16 fid = 0; put_frag( ifbp, p->buf_addr, p->BUF_CNT BE_PAR(0) ); CALC_TX_MIC( p->buf_addr, p->BUF_CNT ); } - //pad message, finalize MIC calculation and write MIC to NIC + //pad message, finalize MIC calculation and write MIC to NIC put_frag_finalize( ifbp ); } if ( fid ) { -/*16*/ rc = cmd_exe( ifbp, HCMD_BUSY | HCMD_TX | HCMD_RECL, fid ); + /*16*/ rc = cmd_exe( ifbp, HCMD_BUSY | HCMD_TX | HCMD_RECL, fid ); ifbp->IFB_TxFID = 0; - /* probably this (i.e. no RscInd AND "HREG_EV_ALLOC") at this point in time occurs so infrequent, - * that it might just as well be acceptable to skip this - * "optimization" code and handle that additional interrupt once in a while - */ + /* probably this (i.e. no RscInd AND "HREG_EV_ALLOC") at this point in time occurs so infrequent, + * that it might just as well be acceptable to skip this + * "optimization" code and handle that additional interrupt once in a while + */ // 180 degree error in logic ;? #if ALLOC_15 -/*20*/ if ( ifbp->IFB_RscInd == 0 ) { + /*20*/ if ( ifbp->IFB_RscInd == 0 ) { ifbp->IFB_RscInd = get_fid( ifbp ); } // #endif // ALLOC_15 @@ -2809,41 +2809,41 @@ hcf_16 fid = 0; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.MODULE int hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) -*.PURPOSE Services (most) NIC events. -* Provides received message -* Provides status information. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* In non-DMA mode: -* bufp address of char buffer, sufficiently large to hold the first part of the RxFS up through HFS_TYPE -* len length in bytes of buffer specified by bufp -* value between HFS_TYPE + 2 and HFS_ADDR_DEST + HCF_MAX_MSG -* -*.RETURNS -* HCF_SUCCESS -* HCF_ERR_MIC message contains an erroneous MIC (only if frame fits completely in bufp) -* -*.DESCRIPTION -* -* MSF-accessible fields of Result Block -* - IFB_RxLen 0 or Frame size. -* - IFB_MBInfoLen 0 or the L-field of the oldest MBIB. -* - IFB_RscInd -* - IFB_HCF_Tallies updated if a corresponding event occurred. -* - IFB_NIC_Tallies updated if a Tally Info frame received from the NIC. -* - IFB_DmaPackets -* - IFB_TxFsStat -* - IFB_TxFsSwSup -* - IFB_LinkStat reflects new link status or 0x0000 if no change relative to previous hcf_service_nic call. + * + *.MODULE int hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) + *.PURPOSE Services (most) NIC events. + * Provides received message + * Provides status information. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * In non-DMA mode: + * bufp address of char buffer, sufficiently large to hold the first part of the RxFS up through HFS_TYPE + * len length in bytes of buffer specified by bufp + * value between HFS_TYPE + 2 and HFS_ADDR_DEST + HCF_MAX_MSG + * + *.RETURNS + * HCF_SUCCESS + * HCF_ERR_MIC message contains an erroneous MIC (only if frame fits completely in bufp) + * + *.DESCRIPTION + * + * MSF-accessible fields of Result Block + * - IFB_RxLen 0 or Frame size. + * - IFB_MBInfoLen 0 or the L-field of the oldest MBIB. + * - IFB_RscInd + * - IFB_HCF_Tallies updated if a corresponding event occurred. + * - IFB_NIC_Tallies updated if a Tally Info frame received from the NIC. + * - IFB_DmaPackets + * - IFB_TxFsStat + * - IFB_TxFsSwSup + * - IFB_LinkStat reflects new link status or 0x0000 if no change relative to previous hcf_service_nic call. or -* - IFB_LinkStat link status, 0x8000 reflects change relative to previous hcf_service_nic call. +* - IFB_LinkStat link status, 0x8000 reflects change relative to previous hcf_service_nic call. * * When IFB_MBInfoLen is non-zero, at least one MBIB is available. * -* IFB_RxLen reflects the number of received bytes in 802.3 view (Including DestAddr, SrcAddr and Length, +* IFB_RxLen reflects the number of received bytes in 802.3 view (Including DestAddr, SrcAddr and Length, * excluding MIC-padding, MIC and sum check) of active Rx Frame Structure. If no Rx Data s available, IFB_RxLen * equals 0x0000. * Repeated execution causes the Service NIC Function to provide information about subsequently received @@ -2891,150 +2891,150 @@ or * specific requirements of that environment to translate the interrupt strategy to a polled strategy. * * hcf_service_nic services the following Hermes events: -* - HREG_EV_INFO Asynchronous Information Frame -* - HREG_EV_INFO_DROP WMAC did not have sufficient RAM to build Unsolicited Information Frame -* - HREG_EV_TX_EXC (if applicable, i.e. selected via HCF_EXT_INT_TX_EX bit of HCF_EXT) -* - HREG_EV_SLEEP_REQ (if applicable, i.e. selected via HCF_DDS/HCF_CDS bit of HCF_SLEEP) +* - HREG_EV_INFO Asynchronous Information Frame +* - HREG_EV_INFO_DROP WMAC did not have sufficient RAM to build Unsolicited Information Frame +* - HREG_EV_TX_EXC (if applicable, i.e. selected via HCF_EXT_INT_TX_EX bit of HCF_EXT) +* - HREG_EV_SLEEP_REQ (if applicable, i.e. selected via HCF_DDS/HCF_CDS bit of HCF_SLEEP) * ** in non_DMA mode -* - HREG_EV_ALLOC Asynchronous part of Allocation/Reclaim completed while out of resources at -* completion of hcf_send_msg/notify -* - HREG_EV_RX the detection of the availability of received messages -* including WaveLAN Management Protocol (WMP) message processing +* - HREG_EV_ALLOC Asynchronous part of Allocation/Reclaim completed while out of resources at +* completion of hcf_send_msg/notify +* - HREG_EV_RX the detection of the availability of received messages +* including WaveLAN Management Protocol (WMP) message processing * ** in DMA mode * - HREG_EV_RDMAD * - HREG_EV_TDMAD *!! hcf_service_nic does not service the following Hermes events: -*!! HREG_EV_TX (the "OK" Tx Event) is no longer supported by the WCI, if it occurs it is unclear -*!! what the cause is, so no meaningful strategy is available. Not acking the bit is -*!! probably the best help that can be given to the debugger. -*!! HREG_EV_CMD handled in cmd_wait. -*!! HREG_EV_FW_DMA (i.e. HREG_EV_RXDMA, HREG_EV_TXDMA and_EV_LPESC) are either not used or used -*!! between the F/W and the DMA engine. -*!! HREG_EV_ACK_REG_READY is only applicable for H-II (i.e. not HII.5 and up, see DAWA) +*!! HREG_EV_TX (the "OK" Tx Event) is no longer supported by the WCI, if it occurs it is unclear +*!! what the cause is, so no meaningful strategy is available. Not acking the bit is +*!! probably the best help that can be given to the debugger. +*!! HREG_EV_CMD handled in cmd_wait. +*!! HREG_EV_FW_DMA (i.e. HREG_EV_RXDMA, HREG_EV_TXDMA and_EV_LPESC) are either not used or used +*!! between the F/W and the DMA engine. +*!! HREG_EV_ACK_REG_READY is only applicable for H-II (i.e. not HII.5 and up, see DAWA) * -* If, in non-DMA mode, a Rx message is available, its length is reflected by the IFB_RxLen field of the IFB. -* This length reflects the data itself and the Destination Address, Source Address and DataLength/Type field -* but not the SNAP-header in case of decapsulation by the HCF. If no message is available, IFB_RxLen is -* zero. Former versions of the HCF handled WMP messages and supported a "monitor" mode in hcf_service_nic, -* which deposited certain or all Rx messages in the MailBox. The responsibility to handle these frames is -* moved to the MSF. The HCF offers as supports hcf_put_info with CFG_MB_INFO as parameter to emulate the old -* implementation under control of the MSF. +* If, in non-DMA mode, a Rx message is available, its length is reflected by the IFB_RxLen field of the IFB. +* This length reflects the data itself and the Destination Address, Source Address and DataLength/Type field +* but not the SNAP-header in case of decapsulation by the HCF. If no message is available, IFB_RxLen is +* zero. Former versions of the HCF handled WMP messages and supported a "monitor" mode in hcf_service_nic, +* which deposited certain or all Rx messages in the MailBox. The responsibility to handle these frames is +* moved to the MSF. The HCF offers as supports hcf_put_info with CFG_MB_INFO as parameter to emulate the old +* implementation under control of the MSF. * * **Rx Buffer free strategy -* When hcf_service_nic reports the availability of a non-DMA message, the MSF can access that message by -* means of hcf_rcv_msg. It must be prevented that the LAN Controller writes new data in the NIC buffer -* before the MSF is finished with the current message. The NIC buffer is returned to the LAN Controller -* when: -* - the complete frame fits in the lookahead buffer or -* - hcf_rcv_msg is called or -* - hcf_action with HCF_ACT_RX is called or -* - hcf_service_nic is called again -* It can be reasoned that hcf_action( INT_ON ) should not be given before the MSF has completely processed -* a reported Rx-frame. The reason is that the INT_ON action is guaranteed to cause a (Rx-)interrupt (the -* MSF is processing a Rx-frame, hence the Rx-event bit in the Hermes register must be active). This -* interrupt will cause hcf_service_nic to be called, which will cause the ack-ing of the "last" Rx-event -* to the Hermes, causing the Hermes to discard the associated NIC RAM buffer. +* When hcf_service_nic reports the availability of a non-DMA message, the MSF can access that message by +* means of hcf_rcv_msg. It must be prevented that the LAN Controller writes new data in the NIC buffer +* before the MSF is finished with the current message. The NIC buffer is returned to the LAN Controller +* when: +* - the complete frame fits in the lookahead buffer or +* - hcf_rcv_msg is called or +* - hcf_action with HCF_ACT_RX is called or +* - hcf_service_nic is called again +* It can be reasoned that hcf_action( INT_ON ) should not be given before the MSF has completely processed +* a reported Rx-frame. The reason is that the INT_ON action is guaranteed to cause a (Rx-)interrupt (the +* MSF is processing a Rx-frame, hence the Rx-event bit in the Hermes register must be active). This +* interrupt will cause hcf_service_nic to be called, which will cause the ack-ing of the "last" Rx-event +* to the Hermes, causing the Hermes to discard the associated NIC RAM buffer. * Assert fails if * - ifbp is zero or other recognizable out-of-range value. * - hcf_service_nic is called without a prior call to hcf_connect. * - interrupts are enabled. * - reentrancy, may be caused by calling hcf_functions without adequate protection -* against NIC interrupts or multi-threading. +* against NIC interrupts or multi-threading. * * *.DIAGRAM -*1: IFB_LinkStat is cleared, if a LinkStatus frame is received, IFB_LinkStat will be updated accordingly -* by isr_info. +*1: IFB_LinkStat is cleared, if a LinkStatus frame is received, IFB_LinkStat will be updated accordingly +* by isr_info. or -*1: IFB_LinkStat change indication is cleared. If a LinkStatus frame is received, IFB_LinkStat will be updated -* accordingly by isr_info. +*1: IFB_LinkStat change indication is cleared. If a LinkStatus frame is received, IFB_LinkStat will be updated +* accordingly by isr_info. *2: IFB_RxLen must be cleared before the NIC presence check otherwise: -* - this value may stay non-zero if the NIC is pulled out at an inconvenient moment. -* - the RxAck on a zero-FID needs a zero-value for IFB_RxLen to work -* Note that as side-effect of the hcf_action call, the remainder of Rx related info is re-initialized as -* well. -*4: In case of Defunct mode, the information supplied by Hermes is unreliable, so the body of -* hcf_service_nic is skipped. Since hcf_cntl turns into a NOP if Primary or Station F/W is incompatible, -* hcf_service_nic is also skipped in those cases. -* To prevent that hcf_service_nic reports bogus information to the MSF with all - possibly difficult to -* debug - undesirable side effects, it is paramount to check the NIC presence. In former days the presence -* test was based on the Hermes register HREG_SW_0. Since in HCF_ACT_INT_OFF is chosen for strategy based on -* HREG_EV_STAT, this is now also used in hcf_service_nic. The motivation to change strategy is partly -* due to inconsistent F/W implementations with respect to HREG_SW_0 manipulation around reset and download. -* Note that in polled environments Card Removal is not detected by INT_OFF which makes the check in -* hcf_service_nic even more important. -*8: The event status register of the Hermes is sampled -* The assert checks for unexpected events ;?????????????????????????????????????. -* - HREG_EV_INFO_DROP is explicitly excluded from the acceptable HREG_EV_STAT bits because it indicates -* a too heavily loaded system. -* - HREG_EV_ACK_REG_READY is 0x0000 for H-I (and hopefully H-II.5) +* - this value may stay non-zero if the NIC is pulled out at an inconvenient moment. +* - the RxAck on a zero-FID needs a zero-value for IFB_RxLen to work +* Note that as side-effect of the hcf_action call, the remainder of Rx related info is re-initialized as +* well. +*4: In case of Defunct mode, the information supplied by Hermes is unreliable, so the body of +* hcf_service_nic is skipped. Since hcf_cntl turns into a NOP if Primary or Station F/W is incompatible, +* hcf_service_nic is also skipped in those cases. +* To prevent that hcf_service_nic reports bogus information to the MSF with all - possibly difficult to +* debug - undesirable side effects, it is paramount to check the NIC presence. In former days the presence +* test was based on the Hermes register HREG_SW_0. Since in HCF_ACT_INT_OFF is chosen for strategy based on +* HREG_EV_STAT, this is now also used in hcf_service_nic. The motivation to change strategy is partly +* due to inconsistent F/W implementations with respect to HREG_SW_0 manipulation around reset and download. +* Note that in polled environments Card Removal is not detected by INT_OFF which makes the check in +* hcf_service_nic even more important. +*8: The event status register of the Hermes is sampled +* The assert checks for unexpected events ;?????????????????????????????????????. +* - HREG_EV_INFO_DROP is explicitly excluded from the acceptable HREG_EV_STAT bits because it indicates +* a too heavily loaded system. +* - HREG_EV_ACK_REG_READY is 0x0000 for H-I (and hopefully H-II.5) * * -* HREG_EV_TX_EXC is accepted (via HREG_EV_TX_EXT) if and only if HCF_EXT_INT_TX_EX set in the HCF_EXT -* definition at compile time. -* The following activities are handled: -* - Alloc events are handled by hcf_send_msg (and notify). Only if there is no "spare" resource, the -* alloc event is superficially serviced by hcf_service_nic to create a pseudo-resource with value -* 0x001. This value is recognized by get_fid (called by hcf_send_msg and notify) where the real -* TxFid is retrieved and the Hermes is acked and - hopefully - the "normal" case with a spare TxFid -* in IFB_RscInd is restored. -* - Info drop events are handled by incrementing a tally -* - LinkEvent (including solicited and unsolicited tallies) are handled by procedure isr_info. -* - TxEx (if selected at compile time) is handled by copying the significant part of the TxFS -* into the IFB for further processing by the MSF. -* Note the complication of the zero-FID protection sub-scheme in DAWA. -* Note, the Ack of all of above events is handled at the end of hcf_service_nic +* HREG_EV_TX_EXC is accepted (via HREG_EV_TX_EXT) if and only if HCF_EXT_INT_TX_EX set in the HCF_EXT +* definition at compile time. +* The following activities are handled: +* - Alloc events are handled by hcf_send_msg (and notify). Only if there is no "spare" resource, the +* alloc event is superficially serviced by hcf_service_nic to create a pseudo-resource with value +* 0x001. This value is recognized by get_fid (called by hcf_send_msg and notify) where the real +* TxFid is retrieved and the Hermes is acked and - hopefully - the "normal" case with a spare TxFid +* in IFB_RscInd is restored. +* - Info drop events are handled by incrementing a tally +* - LinkEvent (including solicited and unsolicited tallies) are handled by procedure isr_info. +* - TxEx (if selected at compile time) is handled by copying the significant part of the TxFS +* into the IFB for further processing by the MSF. +* Note the complication of the zero-FID protection sub-scheme in DAWA. +* Note, the Ack of all of above events is handled at the end of hcf_service_nic *16: In case of non-DMA ( either not compiled in or due to a run-time choice): -* If an Rx-frame is available, first the FID of that frame is read, including the complication of the -* zero-FID protection sub-scheme in DAWA. Note that such a zero-FID is acknowledged at the end of -* hcf_service_nic and that this depends on the IFB_RxLen initialization in the begin of hcf_service_nic. -* The Assert validates the HCF assumption about Hermes implementation upon which the range of -* Pseudo-RIDs is based. -* Then the control fields up to the start of the 802.3 frame are read from the NIC into the lookahead buffer. -* The status field is converted to native Endianess. -* The length is, after implicit Endianess conversion if needed, and adjustment for the 14 bytes of the -* 802.3 MAC header, stored in IFB_RxLen. -* In MAC Monitor mode, 802.11 control frames with a TOTAL length of 14 are received, so without this -* length adjustment, IFB_RxLen could not be used to distinguish these frames from "no frame". -* No MIC calculation processes are associated with the reading of these Control fields. +* If an Rx-frame is available, first the FID of that frame is read, including the complication of the +* zero-FID protection sub-scheme in DAWA. Note that such a zero-FID is acknowledged at the end of +* hcf_service_nic and that this depends on the IFB_RxLen initialization in the begin of hcf_service_nic. +* The Assert validates the HCF assumption about Hermes implementation upon which the range of +* Pseudo-RIDs is based. +* Then the control fields up to the start of the 802.3 frame are read from the NIC into the lookahead buffer. +* The status field is converted to native Endianess. +* The length is, after implicit Endianess conversion if needed, and adjustment for the 14 bytes of the +* 802.3 MAC header, stored in IFB_RxLen. +* In MAC Monitor mode, 802.11 control frames with a TOTAL length of 14 are received, so without this +* length adjustment, IFB_RxLen could not be used to distinguish these frames from "no frame". +* No MIC calculation processes are associated with the reading of these Control fields. *26: This length test feels like superfluous robustness against malformed frames, but it turned out to be -* needed in the real (hostile) world. -* The decapsulation check needs sufficient data to represent DA, SA, L, SNAP and Type which amounts to -* 22 bytes. In MAC Monitor mode, 802.11 control frames with a smaller length are received. To prevent -* that the implementation goes haywire, a check on the length is needed. -* The actual decapsulation takes place on the fly in the copying process by overwriting the SNAP header. -* Note that in case of decapsulation the SNAP header is not passed to the MSF, hence IFB_RxLen must be -* compensated for the SNAP header length. -* The 22 bytes needed for decapsulation are (more than) sufficient for the exceptional handling of the -* MIC algorithm of the L-field (replacing the 2 byte L-field with 4 0x00 bytes). +* needed in the real (hostile) world. +* The decapsulation check needs sufficient data to represent DA, SA, L, SNAP and Type which amounts to +* 22 bytes. In MAC Monitor mode, 802.11 control frames with a smaller length are received. To prevent +* that the implementation goes haywire, a check on the length is needed. +* The actual decapsulation takes place on the fly in the copying process by overwriting the SNAP header. +* Note that in case of decapsulation the SNAP header is not passed to the MSF, hence IFB_RxLen must be +* compensated for the SNAP header length. +* The 22 bytes needed for decapsulation are (more than) sufficient for the exceptional handling of the +* MIC algorithm of the L-field (replacing the 2 byte L-field with 4 0x00 bytes). *30: The 12 in the no-SSN branch corresponds with the get_frag, the 2 with the IPW of the SSN branch *32: If Hermes reported MIC-presence, than the MIC engine is initialized with the non-dummy MIC calculation -* routine address and appropriate key. +* routine address and appropriate key. *34: The 8 bytes after the DA, SA, L are read and it is checked whether decapsulation is needed i.e.: -* - the Hermes reported Tunnel encapsulation or -* - the Hermes reported 1042 Encapsulation and hcf_encap reports that the HCF would not have used -* 1042 as the encapsulation mechanism -* Note that the first field of the RxFS in bufp has Native Endianess due to the conversion done by the -* BE_PAR in get_frag. +* - the Hermes reported Tunnel encapsulation or +* - the Hermes reported 1042 Encapsulation and hcf_encap reports that the HCF would not have used +* 1042 as the encapsulation mechanism +* Note that the first field of the RxFS in bufp has Native Endianess due to the conversion done by the +* BE_PAR in get_frag. *36: The Type field is the only word kept (after moving) of the just read 8 bytes, it is moved to the -* L-field. The original L-field and 6 byte SNAP header are discarded, so IFB_RxLen and buf_addr must -* be adjusted by 8. +* L-field. The original L-field and 6 byte SNAP header are discarded, so IFB_RxLen and buf_addr must +* be adjusted by 8. *40: Determine how much of the frame (starting with DA) fits in the Lookahead buffer, then read the not-yet -* read data into the lookahead buffer. -* If the lookahead buffer contains the complete message, check the MIC. The majority considered this -* I/F more appropriate then have the MSF call hcf_get_data only to check the MIC. +* read data into the lookahead buffer. +* If the lookahead buffer contains the complete message, check the MIC. The majority considered this +* I/F more appropriate then have the MSF call hcf_get_data only to check the MIC. *44: Since the complete message is copied from NIC RAM to PC RAM, the Rx can be acknowledged to the Hermes -* to optimize the flow ( a better chance to get new Rx data in the next pass through hcf_service_nic ). -* This acknowledgement can not be done via hcf_action( HCF_ACT_RX_ACK ) because this also clears -* IFB_RxLEN thus corrupting the I/F to the MSF. +* to optimize the flow ( a better chance to get new Rx data in the next pass through hcf_service_nic ). +* This acknowledgement can not be done via hcf_action( HCF_ACT_RX_ACK ) because this also clears +* IFB_RxLEN thus corrupting the I/F to the MSF. *;?: In case of DMA (compiled in and activated): *54: Limiting the number of places where the F/W is acked (e.g. the merging of the Rx-ACK with the other -* ACKs), is supposed to diminish the potential of race conditions in the F/W. -* Note 1: The CMD event is acknowledged in cmd_cmpl -* Note 2: HREG_EV_ACK_REG_READY is 0x0000 for H-I (and hopefully H-II.5) -* Note 3: The ALLOC event is acknowledged in get_fid (except for the initialization flow) +* ACKs), is supposed to diminish the potential of race conditions in the F/W. +* Note 1: The CMD event is acknowledged in cmd_cmpl +* Note 2: HREG_EV_ACK_REG_READY is 0x0000 for H-I (and hopefully H-II.5) +* Note 3: The ALLOC event is acknowledged in get_fid (except for the initialization flow) * *.NOTICE * The Non-DMA HREG_EV_RX is handled different compared with the other F/W events. @@ -3047,40 +3047,40 @@ or * *.NOTICE * The minimum size for Len must supply space for: -* - an F/W dependent number of bytes of Control Info field including the 802.11 Header field -* - Destination Address -* - Source Address -* - Length field -* - [ SNAP Header] -* - [ Ethernet-II Type] +* - an F/W dependent number of bytes of Control Info field including the 802.11 Header field +* - Destination Address +* - Source Address +* - Length field +* - [ SNAP Header] +* - [ Ethernet-II Type] * This results in 68 for Hermes-I and 80 for Hermes-II * This way the minimum amount of information is available needed by the HCF to determine whether the frame * must be decapsulated. -*.ENDDOC END DOCUMENTATION +*.ENDDOC END DOCUMENTATION * ************************************************************************************************************/ int hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) { -int rc = HCF_SUCCESS; -hcf_16 stat; -wci_bufp buf_addr; -hcf_16 i; + int rc = HCF_SUCCESS; + hcf_16 stat; + wci_bufp buf_addr; + hcf_16 i; HCFLOGENTRY( HCF_TRACE_SERVICE_NIC, ifbp->IFB_IntOffCnt ); HCFASSERT( ifbp->IFB_Magic == HCF_MAGIC, ifbp->IFB_Magic ); HCFASSERT_INT; - ifbp->IFB_LinkStat = 0; // ;? to be obsoleted ASAP /* 1*/ - ifbp->IFB_DSLinkStat &= ~CFG_LINK_STAT_CHANGE; /* 1*/ - (void)hcf_action( ifbp, HCF_ACT_RX_ACK ); /* 2*/ - if ( ifbp->IFB_CardStat == 0 && ( stat = IPW( HREG_EV_STAT ) ) != 0xFFFF ) { /* 4*/ + ifbp->IFB_LinkStat = 0; // ;? to be obsoleted ASAP /* 1*/ + ifbp->IFB_DSLinkStat &= ~CFG_LINK_STAT_CHANGE; /* 1*/ + (void)hcf_action( ifbp, HCF_ACT_RX_ACK ); /* 2*/ + if ( ifbp->IFB_CardStat == 0 && ( stat = IPW( HREG_EV_STAT ) ) != 0xFFFF ) { /* 4*/ /* IF_NOT_DMA( HCFASSERT( !( stat & ~HREG_EV_BASIC_MASK, stat ) ) * IF_NOT_USE_DMA( HCFASSERT( !( stat & ~HREG_EV_BASIC_MASK, stat ) ) * IF_USE_DMA( HCFASSERT( !( stat & ~( HREG_EV_BASIC_MASK ^ ( HREG_EV_...DMA.... ), stat ) ) */ - /* 8*/ + /* 8*/ if ( ifbp->IFB_RscInd == 0 && stat & HREG_EV_ALLOC ) { //Note: IFB_RscInd is ALWAYS 1 for DMA ifbp->IFB_RscInd = 1; } @@ -3091,7 +3091,7 @@ hcf_16 i; } #if 0 // (HCF_SLEEP) & HCF_DDS if ( ifbp->IFB_TickCnt == 3 && ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_CONNECTED ) == 0 ) { -CFG_DDS_TICK_TIME_STRCT ltv; + CFG_DDS_TICK_TIME_STRCT ltv; // 2 second period (with 1 tick uncertanty) in not-connected mode -->go into DS_OOR hcf_action( ifbp, HCF_ACT_SLEEP ); ifbp->IFB_DSLinkStat |= CFG_LINK_STAT_DS_OOR; //set OutOfRange @@ -3100,7 +3100,7 @@ CFG_DDS_TICK_TIME_STRCT ltv; ltv.tick_time = ( ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_TIMER ) + 0x10 ) *64; //78 is more right hcf_put_info( ifbp, (LTVP)<v ); printk( "<5>Preparing for sleep, link_status: %04X, timer : %d\n", - ifbp->IFB_DSLinkStat, ltv.tick_time );//;?remove me 1 day + ifbp->IFB_DSLinkStat, ltv.tick_time );//;?remove me 1 day ifbp->IFB_TickCnt++; //;?just to make sure we do not keep on printing above message if ( ltv.tick_time < 300 * 125 ) ifbp->IFB_DSLinkStat += 0x0010; @@ -3121,66 +3121,66 @@ CFG_DDS_TICK_TIME_STRCT ltv; #if HCF_DMA if ( !( ifbp->IFB_CntlOpt & USE_DMA ) ) //!! be aware of the logical indentations #endif // HCF_DMA -/*16*/ if ( stat & HREG_EV_RX && ( ifbp->IFB_RxFID = IPW( HREG_RX_FID ) ) != 0 ) { //if 0 then DAWA_ACK - HCFASSERT( bufp, len ); - HCFASSERT( len >= HFS_DAT + 2, len ); - DAWA_ZERO_FID( HREG_RX_FID ); - HCFASSERT( ifbp->IFB_RxFID < CFG_PROD_DATA, ifbp->IFB_RxFID); - (void)setup_bap( ifbp, ifbp->IFB_RxFID, 0, IO_IN ); - get_frag( ifbp, bufp, HFS_ADDR_DEST BE_PAR(1) ); - ifbp->IFB_lap = buf_addr = bufp + HFS_ADDR_DEST; - ifbp->IFB_RxLen = (hcf_16)(bufp[HFS_DAT_LEN] + (bufp[HFS_DAT_LEN+1]<<8) + 2*6 + 2); -/*26*/ if ( ifbp->IFB_RxLen >= 22 ) { // convenient for MIC calculation (5 DWs + 1 "skipped" W) - //. get DA,SA,Len/Type and (SNAP,Type or 8 data bytes) -/*30*/ get_frag( ifbp, buf_addr, 22 BE_PAR(0) ); -/*32*/ CALC_RX_MIC( bufp, -1 ); //. initialize MIC - CALC_RX_MIC( buf_addr, HCF_DASA_SIZE ); //. MIC over DA, SA - CALC_RX_MIC( null_addr, 4 ); //. MIC over (virtual) priority field - CALC_RX_MIC( buf_addr+14, 8 ); //. skip Len, MIC over SNAP,Type or 8 data bytes) - buf_addr += 22; + /*16*/ if ( stat & HREG_EV_RX && ( ifbp->IFB_RxFID = IPW( HREG_RX_FID ) ) != 0 ) { //if 0 then DAWA_ACK + HCFASSERT( bufp, len ); + HCFASSERT( len >= HFS_DAT + 2, len ); + DAWA_ZERO_FID( HREG_RX_FID ); + HCFASSERT( ifbp->IFB_RxFID < CFG_PROD_DATA, ifbp->IFB_RxFID); + (void)setup_bap( ifbp, ifbp->IFB_RxFID, 0, IO_IN ); + get_frag( ifbp, bufp, HFS_ADDR_DEST BE_PAR(1) ); + ifbp->IFB_lap = buf_addr = bufp + HFS_ADDR_DEST; + ifbp->IFB_RxLen = (hcf_16)(bufp[HFS_DAT_LEN] + (bufp[HFS_DAT_LEN+1]<<8) + 2*6 + 2); + /*26*/ if ( ifbp->IFB_RxLen >= 22 ) { // convenient for MIC calculation (5 DWs + 1 "skipped" W) + //. get DA,SA,Len/Type and (SNAP,Type or 8 data bytes) + /*30*/ get_frag( ifbp, buf_addr, 22 BE_PAR(0) ); + /*32*/ CALC_RX_MIC( bufp, -1 ); //. initialize MIC + CALC_RX_MIC( buf_addr, HCF_DASA_SIZE ); //. MIC over DA, SA + CALC_RX_MIC( null_addr, 4 ); //. MIC over (virtual) priority field + CALC_RX_MIC( buf_addr+14, 8 ); //. skip Len, MIC over SNAP,Type or 8 data bytes) + buf_addr += 22; #if (HCF_TYPE) & HCF_TYPE_CCX //!!be careful do not use positive test on HCF_ACT_CCX_OFF, because IFB_CKIPStat is initially 0 - if( ifbp->IFB_CKIPStat != HCF_ACT_CCX_ON ) + if( ifbp->IFB_CKIPStat != HCF_ACT_CCX_ON ) #endif // HCF_TYPE_CCX - { + { #if (HCF_ENCAP) == HCF_ENC - HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ); -/*34*/ i = *(wci_recordp)&bufp[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); - if ( i == HFS_STAT_TUNNEL || - ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&bufp[HFS_TYPE] ) != ENC_TUNNEL ) ) { - //. copy E-II Type to 802.3 LEN field -/*36*/ bufp[HFS_LEN ] = bufp[HFS_TYPE ]; - bufp[HFS_LEN+1] = bufp[HFS_TYPE+1]; - //. discard Snap by overwriting with data - ifbp->IFB_RxLen -= (HFS_TYPE - HFS_LEN); - buf_addr -= ( HFS_TYPE - HFS_LEN ); // this happens to bring us at a DW boundary of 36 - } + HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ); + /*34*/ i = *(wci_recordp)&bufp[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); + if ( i == HFS_STAT_TUNNEL || + ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&bufp[HFS_TYPE] ) != ENC_TUNNEL ) ) { + //. copy E-II Type to 802.3 LEN field + /*36*/ bufp[HFS_LEN ] = bufp[HFS_TYPE ]; + bufp[HFS_LEN+1] = bufp[HFS_TYPE+1]; + //. discard Snap by overwriting with data + ifbp->IFB_RxLen -= (HFS_TYPE - HFS_LEN); + buf_addr -= ( HFS_TYPE - HFS_LEN ); // this happens to bring us at a DW boundary of 36 + } #endif // HCF_ENC + } + } + /*40*/ ifbp->IFB_lal = min( (hcf_16)(len - HFS_ADDR_DEST), ifbp->IFB_RxLen ); + i = ifbp->IFB_lal - ( buf_addr - ( bufp + HFS_ADDR_DEST ) ); + get_frag( ifbp, buf_addr, i BE_PAR(0) ); + CALC_RX_MIC( buf_addr, i ); +#if (HCF_TYPE) & HCF_TYPE_WPA + if ( ifbp->IFB_lal == ifbp->IFB_RxLen ) { + rc = check_mic( ifbp ); + } +#endif // HCF_TYPE_WPA + /*44*/ if ( len - HFS_ADDR_DEST >= ifbp->IFB_RxLen ) { + ifbp->IFB_RxFID = 0; + } else { /* IFB_RxFID is cleared, so you do not get another Rx_Ack at next entry of hcf_service_nic */ + stat &= (hcf_16)~HREG_EV_RX; //don't ack Rx if processing not yet completed } } -/*40*/ ifbp->IFB_lal = min( (hcf_16)(len - HFS_ADDR_DEST), ifbp->IFB_RxLen ); - i = ifbp->IFB_lal - ( buf_addr - ( bufp + HFS_ADDR_DEST ) ); - get_frag( ifbp, buf_addr, i BE_PAR(0) ); - CALC_RX_MIC( buf_addr, i ); -#if (HCF_TYPE) & HCF_TYPE_WPA - if ( ifbp->IFB_lal == ifbp->IFB_RxLen ) { - rc = check_mic( ifbp ); - } -#endif // HCF_TYPE_WPA -/*44*/ if ( len - HFS_ADDR_DEST >= ifbp->IFB_RxLen ) { - ifbp->IFB_RxFID = 0; - } else { /* IFB_RxFID is cleared, so you do not get another Rx_Ack at next entry of hcf_service_nic */ - stat &= (hcf_16)~HREG_EV_RX; //don't ack Rx if processing not yet completed - } - } // in case of DMA: signal availability of rx and/or tx packets to MSF IF_USE_DMA( ifbp->IFB_DmaPackets |= stat & ( HREG_EV_RDMAD | HREG_EV_TDMAD ) ); // rlav : pending HREG_EV_RDMAD or HREG_EV_TDMAD events get acknowledged here. -/*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); -//a positive mask would be easier to understand /*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); + /*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); +//a positive mask would be easier to understand /*54*/ stat &= (hcf_16)~( HREG_EV_SLEEP_REQ | HREG_EV_CMD | HREG_EV_ACK_REG_READY | HREG_EV_ALLOC | HREG_EV_FW_DMA ); IF_USE_DMA( stat &= (hcf_16)~HREG_EV_RX ); if ( stat ) { - DAWA_ACK( stat ); /*DAWA*/ + DAWA_ACK( stat ); /*DAWA*/ } } HCFLOGEXIT( HCF_TRACE_SERVICE_NIC ); @@ -3190,41 +3190,41 @@ CFG_DDS_TICK_TIME_STRCT ltv; /************************************************************************************************************ -************************** H C F S U P P O R T R O U T I N E S ****************************************** -************************************************************************************************************/ + ************************** H C F S U P P O R T R O U T I N E S ****************************************** + ************************************************************************************************************/ /************************************************************************************************************ -* -*.SUBMODULE void calc_mic( hcf_32* p, hcf_32 m ) -*.PURPOSE calculate MIC on a quad byte. -* -*.ARGUMENTS -* p address of the MIC -* m 32 bit value to be processed by the MIC calculation engine -* -*.RETURNS N.A. -* -*.DESCRIPTION -* calc_mic is the implementation of the MIC algorithm. It is a monkey-see monkey-do copy of -* Michael::appendByte() -* of Appendix C of .......... -* -* -*.DIAGRAM -* -*.NOTICE -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void calc_mic( hcf_32* p, hcf_32 m ) + *.PURPOSE calculate MIC on a quad byte. + * + *.ARGUMENTS + * p address of the MIC + * m 32 bit value to be processed by the MIC calculation engine + * + *.RETURNS N.A. + * + *.DESCRIPTION + * calc_mic is the implementation of the MIC algorithm. It is a monkey-see monkey-do copy of + * Michael::appendByte() + * of Appendix C of .......... + * + * + *.DIAGRAM + * + *.NOTICE + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ #if (HCF_TYPE) & HCF_TYPE_WPA #define ROL32( A, n ) ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) #define ROR32( A, n ) ROL32( (A), 32-(n) ) -#define L *p -#define R *(p+1) +#define L *p +#define R *(p+1) void calc_mic( hcf_32* p, hcf_32 m ) @@ -3250,38 +3250,38 @@ calc_mic( hcf_32* p, hcf_32 m ) #if (HCF_TYPE) & HCF_TYPE_WPA /************************************************************************************************************ -* -*.SUBMODULE void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ) -*.PURPOSE calculate MIC on a single fragment. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* bufp (byte) address of buffer -* len length in bytes of buffer specified by bufp -* -*.RETURNS N.A. -* -*.DESCRIPTION -* calc_mic_rx_frag ........ -* -* The MIC is located in the IFB. -* The MIC is separate for Tx and Rx, thus allowing hcf_send_msg to occur between hcf_service_nic and -* hcf_rcv_msg. -* -* -*.DIAGRAM -* -*.NOTICE -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ) + *.PURPOSE calculate MIC on a single fragment. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * bufp (byte) address of buffer + * len length in bytes of buffer specified by bufp + * + *.RETURNS N.A. + * + *.DESCRIPTION + * calc_mic_rx_frag ........ + * + * The MIC is located in the IFB. + * The MIC is separate for Tx and Rx, thus allowing hcf_send_msg to occur between hcf_service_nic and + * hcf_rcv_msg. + * + * + *.DIAGRAM + * + *.NOTICE + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ) { -static union { hcf_32 x32; hcf_16 x16[2]; hcf_8 x8[4]; } x; //* area to accumulate 4 bytes input for MIC engine -int i; + static union { hcf_32 x32; hcf_16 x16[2]; hcf_8 x8[4]; } x; //* area to accumulate 4 bytes input for MIC engine + int i; - if ( len == -1 ) { //initialize MIC housekeeping + if ( len == -1 ) { //initialize MIC housekeeping i = *(wci_recordp)&p[HFS_STAT]; /* i = CNV_SHORTP_TO_LITTLE(&p[HFS_STAT]); should not be neede to prevent alignment poroblems * since len == -1 if and only if p is lookahaead buffer which MUST be word aligned @@ -3289,12 +3289,12 @@ int i; */ if ( ( i & HFS_STAT_MIC ) == 0 ) { - ifbp->IFB_MICRxCarry = 0xFFFF; //suppress MIC calculation + ifbp->IFB_MICRxCarry = 0xFFFF; //suppress MIC calculation } else { ifbp->IFB_MICRxCarry = 0; -//* Note that "coincidentally" the bit positions used in HFS_STAT -//* correspond with the offset of the key in IFB_MICKey - i = ( i & HFS_STAT_MIC_KEY_ID ) >> 10; /* coincidentally no shift needed for i itself */ +//* Note that "coincidentally" the bit positions used in HFS_STAT +//* correspond with the offset of the key in IFB_MICKey + i = ( i & HFS_STAT_MIC_KEY_ID ) >> 10; /* coincidentally no shift needed for i itself */ ifbp->IFB_MICRx[0] = CNV_LONG_TO_LITTLE(ifbp->IFB_MICRxKey[i ]); ifbp->IFB_MICRx[1] = CNV_LONG_TO_LITTLE(ifbp->IFB_MICRxKey[i+1]); } @@ -3308,11 +3308,11 @@ int i; ifbp->IFB_MICRxCarry = 4; len -= 4; } - } else while ( ifbp->IFB_MICRxCarry < 4 && len ) { //note for hcf_16 applies: 0xFFFF > 4 - x.x8[ifbp->IFB_MICRxCarry++] = *p++; - len--; - } - while ( ifbp->IFB_MICRxCarry == 4 ) { //contrived so we have only 1 call to calc_mic so we could bring it in-line + } else while ( ifbp->IFB_MICRxCarry < 4 && len ) { //note for hcf_16 applies: 0xFFFF > 4 + x.x8[ifbp->IFB_MICRxCarry++] = *p++; + len--; + } + while ( ifbp->IFB_MICRxCarry == 4 ) { //contrived so we have only 1 call to calc_mic so we could bring it in-line calc_mic( ifbp->IFB_MICRx, x.x32 ); x.x32 = CNV_LONGP_TO_LITTLE(p); p += 4; @@ -3328,92 +3328,92 @@ int i; #if (HCF_TYPE) & HCF_TYPE_WPA /************************************************************************************************************ -* -*.SUBMODULE void calc_mic_tx_frag( IFBP ifbp, wci_bufp p, int len ) -*.PURPOSE calculate MIC on a single fragment. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* bufp (byte) address of buffer -* len length in bytes of buffer specified by bufp -* -*.RETURNS N.A. -* -*.DESCRIPTION -* calc_mic_tx_frag ........ -* -* The MIC is located in the IFB. -* The MIC is separate for Tx and Rx, thus allowing hcf_send_msg to occur between hcf_service_nic and -* hcf_rcv_msg. -* -* -*.DIAGRAM -* -*.NOTICE -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void calc_mic_tx_frag( IFBP ifbp, wci_bufp p, int len ) + *.PURPOSE calculate MIC on a single fragment. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * bufp (byte) address of buffer + * len length in bytes of buffer specified by bufp + * + *.RETURNS N.A. + * + *.DESCRIPTION + * calc_mic_tx_frag ........ + * + * The MIC is located in the IFB. + * The MIC is separate for Tx and Rx, thus allowing hcf_send_msg to occur between hcf_service_nic and + * hcf_rcv_msg. + * + * + *.DIAGRAM + * + *.NOTICE + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ void calc_mic_tx_frag( IFBP ifbp, wci_bufp p, int len ) { -static union { hcf_32 x32; hcf_16 x16[2]; hcf_8 x8[4]; } x; //* area to accumulate 4 bytes input for MIC engine + static union { hcf_32 x32; hcf_16 x16[2]; hcf_8 x8[4]; } x; //* area to accumulate 4 bytes input for MIC engine - //if initialization request + //if initialization request if ( len == -1 ) { - //. presume MIC calculation disabled + //. presume MIC calculation disabled ifbp->IFB_MICTxCarry = 0xFFFF; - //. if MIC calculation enabled + //. if MIC calculation enabled if ( ifbp->IFB_MICTxCntl ) { - //. . clear MIC carry + //. . clear MIC carry ifbp->IFB_MICTxCarry = 0; - //. . initialize MIC-engine - ifbp->IFB_MICTx[0] = CNV_LONG_TO_LITTLE(ifbp->IFB_MICTxKey[0]); /*Tx always uses Key 0 */ + //. . initialize MIC-engine + ifbp->IFB_MICTx[0] = CNV_LONG_TO_LITTLE(ifbp->IFB_MICTxKey[0]); /*Tx always uses Key 0 */ ifbp->IFB_MICTx[1] = CNV_LONG_TO_LITTLE(ifbp->IFB_MICTxKey[1]); } - //else + //else } else { - //. if MIC enabled (Tx) / if MIC present (Rx) - //. and no carry from previous calc_mic_frag + //. if MIC enabled (Tx) / if MIC present (Rx) + //. and no carry from previous calc_mic_frag if ( ifbp->IFB_MICTxCarry == 0 ) { - //. . preset accu with 4 bytes from buffer + //. . preset accu with 4 bytes from buffer x.x32 = CNV_LONGP_TO_LITTLE(p); - //. . adjust pointer accordingly + //. . adjust pointer accordingly p += 4; - //. . if buffer contained less then 4 bytes + //. . if buffer contained less then 4 bytes if ( len < 4 ) { - //. . . promote valid bytes in accu to carry - //. . . flag accu to contain incomplete double word + //. . . promote valid bytes in accu to carry + //. . . flag accu to contain incomplete double word ifbp->IFB_MICTxCarry = (hcf_16)len; - //. . else + //. . else } else { - //. . . flag accu to contain complete double word + //. . . flag accu to contain complete double word ifbp->IFB_MICTxCarry = 4; - //. . adjust remaining buffer length + //. . adjust remaining buffer length len -= 4; } - //. else if MIC enabled - //. and if carry bytes from previous calc_mic_tx_frag - //. . move (1-3) bytes from carry into accu - } else while ( ifbp->IFB_MICTxCarry < 4 && len ) { /* note for hcf_16 applies: 0xFFFF > 4 */ - x.x8[ifbp->IFB_MICTxCarry++] = *p++; - len--; - } - //. while accu contains complete double word - //. and MIC enabled + //. else if MIC enabled + //. and if carry bytes from previous calc_mic_tx_frag + //. . move (1-3) bytes from carry into accu + } else while ( ifbp->IFB_MICTxCarry < 4 && len ) { /* note for hcf_16 applies: 0xFFFF > 4 */ + x.x8[ifbp->IFB_MICTxCarry++] = *p++; + len--; + } + //. while accu contains complete double word + //. and MIC enabled while ( ifbp->IFB_MICTxCarry == 4 ) { - //. . pass accu to MIC engine + //. . pass accu to MIC engine calc_mic( ifbp->IFB_MICTx, x.x32 ); - //. . copy next 4 bytes from buffer to accu + //. . copy next 4 bytes from buffer to accu x.x32 = CNV_LONGP_TO_LITTLE(p); - //. . adjust buffer pointer + //. . adjust buffer pointer p += 4; - //. . if buffer contained less then 4 bytes - //. . . promote valid bytes in accu to carry - //. . . flag accu to contain incomplete double word + //. . if buffer contained less then 4 bytes + //. . . promote valid bytes in accu to carry + //. . . flag accu to contain incomplete double word if ( len < 4 ) { ifbp->IFB_MICTxCarry = (hcf_16)len; } - //. . adjust remaining buffer length + //. . adjust remaining buffer length len -= 4; } } @@ -3423,94 +3423,94 @@ static union { hcf_32 x32; hcf_16 x16[2]; hcf_8 x8[4]; } x; //* area to accumula #if HCF_PROT_TIME /************************************************************************************************************ -* -*.SUBMODULE void calibrate( IFBP ifbp ) -*.PURPOSE calibrates the S/W protection counter against the Hermes Timer tick. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS N.A. -* -*.DESCRIPTION -* calibrates the S/W protection counter against the Hermes Timer tick -* IFB_TickIni is the value used to initialize the S/W protection counter such that the expiration period -* more or less independent of the processor speed. If IFB_TickIni is not yet calibrated, it is done now. -* This calibration is "reasonably" accurate because the Hermes is in a quiet state as a result of the -* Initialize command. -* -* -*.DIAGRAM -* -*1: IFB_TickIni is initialized at INI_TICK_INI by hcf_connect. If calibrate succeeds, IFB_TickIni is -* guaranteed to be changed. As a consequence there will be only 1 shot at calibration (regardless of the -* number of init calls) under normal circumstances. -*2: Calibration is done HCF_PROT_TIME_CNT times. This diminish the effects of jitter and interference, -* especially in a pre-emptive environment. HCF_PROT_TIME_CNT is in the range of 16 through 32 and derived -* from the HCF_PROT_TIME specified by the MSF programmer. The divisor needed to scale HCF_PROT_TIME into the -* 16-32 range, is used as a multiplicator after the calibration, to scale the found value back to the -* requested range. This way a compromise is achieved between accuracy and duration of the calibration -* process. -*3: Acknowledge the Timer Tick Event. -* Each cycle is limited to at most INI_TICK_INI samples of the TimerTick status of the Hermes. -* Since the start of calibrate is unrelated to the Hermes Internal Timer, the first interval may last from 0 -* to the normal interval, all subsequent intervals should be the full length of the Hermes Tick interval. -* The Hermes Timer Tick is not reprogrammed by the HCF, hence it is running at the default of 10 k -* microseconds. -*4: If the Timer Tick Event is continuously up (prot_cnt still has the value INI_TICK_INI) or no Timer Tick -* Event occurred before the protection counter expired, reset IFB_TickIni to INI_TICK_INI, -* set the defunct bit of IFB_CardStat (thus rendering the Hermes inoperable) and exit the calibrate routine. -*8: ifbp->IFB_TickIni is multiplied to scale the found value back to the requested range as explained under 2. -* -*.NOTICE -* o Although there are a number of viewpoints possible, calibrate() uses as error strategy that a single -* failure of the Hermes TimerTick is considered fatal. -* o There is no hard and concrete time-out value defined for Hermes activities. The default 1 seconds is -* believed to be sufficiently "relaxed" for real life and to be sufficiently short to be still useful in an -* environment with humans. -* o Note that via IFB_DefunctStat time outs in cmd_wait and in hcfio_string block all Hermes access till the -* next init so functions which call a mix of cmd_wait and hcfio_string only need to check the return status -* of the last call -* o The return code is preset at Time out. -* The additional complication that no calibrated value for the protection count can be assumed since -* calibrate() does not yet have determined a calibrated value (a catch 22), is handled by setting the -* initial value at INI_TICK_INI (by hcf_connect). This approach is considered safe, because: -* - the HCF does not use the pipeline mechanism of Hermes commands. -* - the likelihood of failure (the only time when protection count is relevant) is small. -* - the time will be sufficiently large on a fast machine (busy bit drops on good NIC before counter -* expires) -* - the time will be sufficiently small on a slow machine (counter expires on bad NIC before the end user -* switches the power off in despair -* The time needed to wrap a 32 bit counter around is longer than many humans want to wait, hence the more or -* less arbitrary value of 0x40000L is chosen, assuming it does not take too long on an XT and is not too -* short on a scream-machine. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void calibrate( IFBP ifbp ) + *.PURPOSE calibrates the S/W protection counter against the Hermes Timer tick. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS N.A. + * + *.DESCRIPTION + * calibrates the S/W protection counter against the Hermes Timer tick + * IFB_TickIni is the value used to initialize the S/W protection counter such that the expiration period + * more or less independent of the processor speed. If IFB_TickIni is not yet calibrated, it is done now. + * This calibration is "reasonably" accurate because the Hermes is in a quiet state as a result of the + * Initialize command. + * + * + *.DIAGRAM + * + *1: IFB_TickIni is initialized at INI_TICK_INI by hcf_connect. If calibrate succeeds, IFB_TickIni is + * guaranteed to be changed. As a consequence there will be only 1 shot at calibration (regardless of the + * number of init calls) under normal circumstances. + *2: Calibration is done HCF_PROT_TIME_CNT times. This diminish the effects of jitter and interference, + * especially in a pre-emptive environment. HCF_PROT_TIME_CNT is in the range of 16 through 32 and derived + * from the HCF_PROT_TIME specified by the MSF programmer. The divisor needed to scale HCF_PROT_TIME into the + * 16-32 range, is used as a multiplicator after the calibration, to scale the found value back to the + * requested range. This way a compromise is achieved between accuracy and duration of the calibration + * process. + *3: Acknowledge the Timer Tick Event. + * Each cycle is limited to at most INI_TICK_INI samples of the TimerTick status of the Hermes. + * Since the start of calibrate is unrelated to the Hermes Internal Timer, the first interval may last from 0 + * to the normal interval, all subsequent intervals should be the full length of the Hermes Tick interval. + * The Hermes Timer Tick is not reprogrammed by the HCF, hence it is running at the default of 10 k + * microseconds. + *4: If the Timer Tick Event is continuously up (prot_cnt still has the value INI_TICK_INI) or no Timer Tick + * Event occurred before the protection counter expired, reset IFB_TickIni to INI_TICK_INI, + * set the defunct bit of IFB_CardStat (thus rendering the Hermes inoperable) and exit the calibrate routine. + *8: ifbp->IFB_TickIni is multiplied to scale the found value back to the requested range as explained under 2. + * + *.NOTICE + * o Although there are a number of viewpoints possible, calibrate() uses as error strategy that a single + * failure of the Hermes TimerTick is considered fatal. + * o There is no hard and concrete time-out value defined for Hermes activities. The default 1 seconds is + * believed to be sufficiently "relaxed" for real life and to be sufficiently short to be still useful in an + * environment with humans. + * o Note that via IFB_DefunctStat time outs in cmd_wait and in hcfio_string block all Hermes access till the + * next init so functions which call a mix of cmd_wait and hcfio_string only need to check the return status + * of the last call + * o The return code is preset at Time out. + * The additional complication that no calibrated value for the protection count can be assumed since + * calibrate() does not yet have determined a calibrated value (a catch 22), is handled by setting the + * initial value at INI_TICK_INI (by hcf_connect). This approach is considered safe, because: + * - the HCF does not use the pipeline mechanism of Hermes commands. + * - the likelihood of failure (the only time when protection count is relevant) is small. + * - the time will be sufficiently large on a fast machine (busy bit drops on good NIC before counter + * expires) + * - the time will be sufficiently small on a slow machine (counter expires on bad NIC before the end user + * switches the power off in despair + * The time needed to wrap a 32 bit counter around is longer than many humans want to wait, hence the more or + * less arbitrary value of 0x40000L is chosen, assuming it does not take too long on an XT and is not too + * short on a scream-machine. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC void calibrate( IFBP ifbp ) { -int cnt = HCF_PROT_TIME_CNT; -hcf_32 prot_cnt; + int cnt = HCF_PROT_TIME_CNT; + hcf_32 prot_cnt; HCFTRACE( ifbp, HCF_TRACE_CALIBRATE ); - if ( ifbp->IFB_TickIni == INI_TICK_INI ) { /*1*/ - ifbp->IFB_TickIni = 0; /*2*/ - while ( cnt-- ) { - prot_cnt = INI_TICK_INI; - OPW( HREG_EV_ACK, HREG_EV_TICK ); /*3*/ - while ( (IPW( HREG_EV_STAT ) & HREG_EV_TICK) == 0 && --prot_cnt ) { - ifbp->IFB_TickIni++; - } - if ( prot_cnt == 0 || prot_cnt == INI_TICK_INI ) { /*4*/ - ifbp->IFB_TickIni = INI_TICK_INI; - ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_TIMER; - ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; - HCFASSERT( DO_ASSERT, prot_cnt ); - } + if ( ifbp->IFB_TickIni == INI_TICK_INI ) { /*1*/ + ifbp->IFB_TickIni = 0; /*2*/ + while ( cnt-- ) { + prot_cnt = INI_TICK_INI; + OPW( HREG_EV_ACK, HREG_EV_TICK ); /*3*/ + while ( (IPW( HREG_EV_STAT ) & HREG_EV_TICK) == 0 && --prot_cnt ) { + ifbp->IFB_TickIni++; } - ifbp->IFB_TickIni <<= HCF_PROT_TIME_SHFT; /*8*/ + if ( prot_cnt == 0 || prot_cnt == INI_TICK_INI ) { /*4*/ + ifbp->IFB_TickIni = INI_TICK_INI; + ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_TIMER; + ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; + HCFASSERT( DO_ASSERT, prot_cnt ); + } + } + ifbp->IFB_TickIni <<= HCF_PROT_TIME_SHFT; /*8*/ } HCFTRACE( ifbp, HCF_TRACE_CALIBRATE | HCF_TRACE_EXIT ); } // calibrate @@ -3520,48 +3520,48 @@ hcf_32 prot_cnt; #if (HCF_DL_ONLY) == 0 #if (HCF_TYPE) & HCF_TYPE_WPA /************************************************************************************************************ -* -*.SUBMODULE int check_mic( IFBP ifbp ) -*.PURPOSE verifies the MIC of a received non-USB frame. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* HCF_SUCCESS -* HCF_ERR_MIC -* -*.DESCRIPTION -* -* -*.DIAGRAM -* -*4: test whether or not a MIC is reported by the Hermes -*14: the calculated MIC and the received MIC are compared, the return status is set when there is a mismatch -* -*.NOTICE -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int check_mic( IFBP ifbp ) + *.PURPOSE verifies the MIC of a received non-USB frame. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * HCF_SUCCESS + * HCF_ERR_MIC + * + *.DESCRIPTION + * + * + *.DIAGRAM + * + *4: test whether or not a MIC is reported by the Hermes + *14: the calculated MIC and the received MIC are compared, the return status is set when there is a mismatch + * + *.NOTICE + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ int check_mic( IFBP ifbp ) { -int rc = HCF_SUCCESS; -hcf_32 x32[2]; //* area to save rcvd 8 bytes MIC + int rc = HCF_SUCCESS; + hcf_32 x32[2]; //* area to save rcvd 8 bytes MIC - //if MIC present in RxFS + //if MIC present in RxFS if ( *(wci_recordp)&ifbp->IFB_lap[-HFS_ADDR_DEST] & HFS_STAT_MIC ) { - //or if ( ifbp->IFB_MICRxCarry != 0xFFFF ) - CALC_RX_MIC( mic_pad, 8 ); //. process up to 3 remaining bytes of data and append 5 to 8 bytes of padding to MIC calculation + //or if ( ifbp->IFB_MICRxCarry != 0xFFFF ) + CALC_RX_MIC( mic_pad, 8 ); //. process up to 3 remaining bytes of data and append 5 to 8 bytes of padding to MIC calculation get_frag( ifbp, (wci_bufp)x32, 8 BE_PAR(0));//. get 8 byte MIC from NIC - //. if calculated and received MIC do not match - //. . set status at HCF_ERR_MIC -/*14*/ if ( x32[0] != CNV_LITTLE_TO_LONG(ifbp->IFB_MICRx[0]) || - x32[1] != CNV_LITTLE_TO_LONG(ifbp->IFB_MICRx[1]) ) { + //. if calculated and received MIC do not match + //. . set status at HCF_ERR_MIC + /*14*/ if ( x32[0] != CNV_LITTLE_TO_LONG(ifbp->IFB_MICRx[0]) || + x32[1] != CNV_LITTLE_TO_LONG(ifbp->IFB_MICRx[1]) ) { rc = HCF_ERR_MIC; } } - //return status + //return status return rc; } // check_mic #endif // HCF_TYPE_WPA @@ -3569,61 +3569,61 @@ hcf_32 x32[2]; //* area to save rcvd 8 bytes MIC /************************************************************************************************************ -* -*.SUBMODULE int cmd_cmpl( IFBP ifbp ) -*.PURPOSE waits for Hermes Command Completion. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* IFB_DefunctStat -* HCF_ERR_TIME_OUT -* HCF_ERR_DEFUNCT_CMD_SEQ -* HCF_SUCCESS -* -*.DESCRIPTION -* -* -*.DIAGRAM -* -*2: Once cmd_cmpl is called, the Busy option bit in IFB_Cmd must be cleared -*4: If Status register and command code don't match either: -* - the Hermes and Host are out of sync ( a fatal error) -* - error bits are reported via the Status Register. -* Out of sync is considered fatal and brings the HCF in Defunct mode -* Errors reported via the Status Register should be caused by sequence violations in Hermes command -* sequences and hence these bugs should have been found during engineering testing. Since there is no -* strategy to cope with this problem, it might as well be ignored at run time. Note that for any particular -* situation where a strategy is formulated to handle the consequences of a particular bug causing a -* particular Error situation reported via the Status Register, the bug should be removed rather than adding -* logic to cope with the consequences of the bug. -* There have been HCF versions where an error report via the Status Register even brought the HCF in defunct -* mode (although it was not yet named like that at that time). This is particular undesirable behavior for a -* general library. -* Simply reporting the error (as "interesting") is debatable. There also have been HCF versions with this -* strategy using the "vague" HCF_FAILURE code. -* The error is reported via: -* - MiscErr tally of the HCF Tally set -* - the (informative) fields IFB_ErrCmd and IFB_ErrQualifier -* - the assert mechanism -*8: Here the Defunct case and the Status error are separately treated -* -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int cmd_cmpl( IFBP ifbp ) + *.PURPOSE waits for Hermes Command Completion. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * IFB_DefunctStat + * HCF_ERR_TIME_OUT + * HCF_ERR_DEFUNCT_CMD_SEQ + * HCF_SUCCESS + * + *.DESCRIPTION + * + * + *.DIAGRAM + * + *2: Once cmd_cmpl is called, the Busy option bit in IFB_Cmd must be cleared + *4: If Status register and command code don't match either: + * - the Hermes and Host are out of sync ( a fatal error) + * - error bits are reported via the Status Register. + * Out of sync is considered fatal and brings the HCF in Defunct mode + * Errors reported via the Status Register should be caused by sequence violations in Hermes command + * sequences and hence these bugs should have been found during engineering testing. Since there is no + * strategy to cope with this problem, it might as well be ignored at run time. Note that for any particular + * situation where a strategy is formulated to handle the consequences of a particular bug causing a + * particular Error situation reported via the Status Register, the bug should be removed rather than adding + * logic to cope with the consequences of the bug. + * There have been HCF versions where an error report via the Status Register even brought the HCF in defunct + * mode (although it was not yet named like that at that time). This is particular undesirable behavior for a + * general library. + * Simply reporting the error (as "interesting") is debatable. There also have been HCF versions with this + * strategy using the "vague" HCF_FAILURE code. + * The error is reported via: + * - MiscErr tally of the HCF Tally set + * - the (informative) fields IFB_ErrCmd and IFB_ErrQualifier + * - the assert mechanism + *8: Here the Defunct case and the Status error are separately treated + * + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int cmd_cmpl( IFBP ifbp ) { -PROT_CNT_INI; -int rc = HCF_SUCCESS; -hcf_16 stat; + PROT_CNT_INI; + int rc = HCF_SUCCESS; + hcf_16 stat; HCFLOGENTRY( HCF_TRACE_CMD_CPL, ifbp->IFB_Cmd ); - ifbp->IFB_Cmd &= ~HCMD_BUSY; /* 2 */ - HCF_WAIT_WHILE( (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); /* 4 */ + ifbp->IFB_Cmd &= ~HCMD_BUSY; /* 2 */ + HCF_WAIT_WHILE( (IPW( HREG_EV_STAT) & HREG_EV_CMD) == 0 ); /* 4 */ stat = IPW( HREG_STAT ); #if HCF_PROT_TIME if ( prot_cnt == 0 ) { @@ -3634,8 +3634,8 @@ hcf_16 stat; #endif // HCF_PROT_TIME { DAWA_ACK( HREG_EV_CMD ); -/*4*/ if ( stat != (ifbp->IFB_Cmd & HCMD_CMD_CODE) ) { -/*8*/ if ( ( (stat ^ ifbp->IFB_Cmd ) & HCMD_CMD_CODE) != 0 ) { + /*4*/ if ( stat != (ifbp->IFB_Cmd & HCMD_CMD_CODE) ) { + /*8*/ if ( ( (stat ^ ifbp->IFB_Cmd ) & HCMD_CMD_CODE) != 0 ) { rc = ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_CMD_SEQ; ifbp->IFB_CardStat |= CARD_STAT_DEFUNCT; } @@ -3653,75 +3653,75 @@ hcf_16 stat; /************************************************************************************************************ -* -*.SUBMODULE int cmd_exe( IFBP ifbp, int cmd_code, int par_0 ) -*.PURPOSE Executes synchronous part of Hermes Command and - optionally - waits for Command Completion. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* cmd_code -* par_0 -* -*.RETURNS -* IFB_DefunctStat -* HCF_ERR_DEFUNCT_CMD_SEQ -* HCF_SUCCESS -* HCF_ERR_TO_BE_ADDED <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -* -*.DESCRIPTION -* Executes synchronous Hermes Command and waits for Command Completion -* -* The general HCF strategy is to wait for command completion. As a consequence: -* - the read of the busy bit before writing the command register is superfluous -* - the Hermes requirement that no Inquiry command may be executed if there is still an unacknowledged -* Inquiry command outstanding, is automatically met. -* The Tx command uses the "Busy" bit in the cmd_code parameter to deviate from this general HCF strategy. -* The idea is that by not busy-waiting on completion of this frequently used command the processor -* utilization is diminished while using the busy-wait on all other seldom used commands the flow is kept -* simple. -* -* -* -*.DIAGRAM -* -*1: skip the body of cmd_exe when in defunct mode or when - based on the S/W Support register write and -* read back test - there is apparently no NIC. -* Note: we gave up on the "old" strategy to write the S/W Support register at magic only when needed. Due to -* the intricateness of Hermes F/W varieties ( which behave differently as far as corruption of the S/W -* Support register is involved), the increasing number of Hermes commands which do an implicit initialize -* (thus modifying the S/W Support register) and the workarounds of some OS/Support S/W induced aspects (e.g. -* the System Soft library at WinNT which postpones the actual mapping of I/O space up to 30 seconds after -* giving the go-ahead), the "magic" strategy is now reduced to a simple write and read back. This means that -* problems like a bug tramping over the memory mapped Hermes registers will no longer be noticed as side -* effect of the S/W Support register check. -*2: check whether the preceding command skipped the busy wait and if so, check for command completion -* -*.NOTICE -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int cmd_exe( IFBP ifbp, int cmd_code, int par_0 ) + *.PURPOSE Executes synchronous part of Hermes Command and - optionally - waits for Command Completion. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * cmd_code + * par_0 + * + *.RETURNS + * IFB_DefunctStat + * HCF_ERR_DEFUNCT_CMD_SEQ + * HCF_SUCCESS + * HCF_ERR_TO_BE_ADDED <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + * + *.DESCRIPTION + * Executes synchronous Hermes Command and waits for Command Completion + * + * The general HCF strategy is to wait for command completion. As a consequence: + * - the read of the busy bit before writing the command register is superfluous + * - the Hermes requirement that no Inquiry command may be executed if there is still an unacknowledged + * Inquiry command outstanding, is automatically met. + * The Tx command uses the "Busy" bit in the cmd_code parameter to deviate from this general HCF strategy. + * The idea is that by not busy-waiting on completion of this frequently used command the processor + * utilization is diminished while using the busy-wait on all other seldom used commands the flow is kept + * simple. + * + * + * + *.DIAGRAM + * + *1: skip the body of cmd_exe when in defunct mode or when - based on the S/W Support register write and + * read back test - there is apparently no NIC. + * Note: we gave up on the "old" strategy to write the S/W Support register at magic only when needed. Due to + * the intricateness of Hermes F/W varieties ( which behave differently as far as corruption of the S/W + * Support register is involved), the increasing number of Hermes commands which do an implicit initialize + * (thus modifying the S/W Support register) and the workarounds of some OS/Support S/W induced aspects (e.g. + * the System Soft library at WinNT which postpones the actual mapping of I/O space up to 30 seconds after + * giving the go-ahead), the "magic" strategy is now reduced to a simple write and read back. This means that + * problems like a bug tramping over the memory mapped Hermes registers will no longer be noticed as side + * effect of the S/W Support register check. + *2: check whether the preceding command skipped the busy wait and if so, check for command completion + * + *.NOTICE + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int -cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ) //if HCMD_BUSY of cmd_code set, then do NOT wait for completion +cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ) //if HCMD_BUSY of cmd_code set, then do NOT wait for completion { -int rc; + int rc; HCFLOGENTRY( HCF_TRACE_CMD_EXE, cmd_code ); HCFASSERT( (cmd_code & HCMD_CMD_CODE) != HCMD_TX || cmd_code & HCMD_BUSY, cmd_code ); //Tx must have Busy bit set OPW( HREG_SW_0, HCF_MAGIC ); - if ( IPW( HREG_SW_0 ) == HCF_MAGIC ) { /* 1 */ + if ( IPW( HREG_SW_0 ) == HCF_MAGIC ) { /* 1 */ rc = ifbp->IFB_DefunctStat; } else rc = HCF_ERR_NO_NIC; if ( rc == HCF_SUCCESS ) { //;?is this a hot idea, better MEASURE performance impact -/*2*/ if ( ifbp->IFB_Cmd & HCMD_BUSY ) { + /*2*/ if ( ifbp->IFB_Cmd & HCMD_BUSY ) { rc = cmd_cmpl( ifbp ); } OPW( HREG_PARAM_0, par_0 ); OPW( HREG_CMD, cmd_code &~HCMD_BUSY ); ifbp->IFB_Cmd = cmd_code; - if ( (cmd_code & HCMD_BUSY) == 0 ) { //;?is this a hot idea, better MEASURE performance impact + if ( (cmd_code & HCMD_BUSY) == 0 ) { //;?is this a hot idea, better MEASURE performance impact rc = cmd_cmpl( ifbp ); } } @@ -3732,72 +3732,72 @@ int rc; /************************************************************************************************************ -* -*.SUBMODULE int download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ) -*.PURPOSE downloads F/W image into NIC and initiates execution of the downloaded F/W. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* ltvp specifies the pseudo-RID (as defined by WCI) -* -*.RETURNS -* -*.DESCRIPTION -* -* -*.DIAGRAM -*1: First, Ack everything to unblock a (possibly) blocked cmd pipe line -* Note 1: it is very likely that an Alloc event is pending and very well possible that a (Send) Cmd event is -* pending -* Note 2: it is assumed that this strategy takes away the need to ack every conceivable event after an -* Hermes Initialize -* -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ) + *.PURPOSE downloads F/W image into NIC and initiates execution of the downloaded F/W. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * ltvp specifies the pseudo-RID (as defined by WCI) + * + *.RETURNS + * + *.DESCRIPTION + * + * + *.DIAGRAM + *1: First, Ack everything to unblock a (possibly) blocked cmd pipe line + * Note 1: it is very likely that an Alloc event is pending and very well possible that a (Send) Cmd event is + * pending + * Note 2: it is assumed that this strategy takes away the need to ack every conceivable event after an + * Hermes Initialize + * + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int -download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ) //Hermes-II download (volatile only) +download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ) //Hermes-II download (volatile only) { -hcf_16 i; -int rc = HCF_SUCCESS; -wci_bufp cp; -hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; + hcf_16 i; + int rc = HCF_SUCCESS; + wci_bufp cp; + hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; HCFLOGENTRY( HCF_TRACE_DL, ltvp->typ ); #if (HCF_TYPE) & HCF_TYPE_PRELOADED HCFASSERT( DO_ASSERT, ltvp->mode ); #else - //if initial "program" LTV + //if initial "program" LTV if ( ifbp->IFB_DLMode == CFG_PROG_STOP && ltvp->mode == CFG_PROG_VOLATILE) { - //. switch Hermes to initial mode -/*1*/ OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); - rc = cmd_exe( ifbp, HCMD_INI, 0 ); /* HCMD_INI can not be part of init() because that is called on - * other occasions as well */ + //. switch Hermes to initial mode + /*1*/ OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); + rc = cmd_exe( ifbp, HCMD_INI, 0 ); /* HCMD_INI can not be part of init() because that is called on + * other occasions as well */ rc = init( ifbp ); } - //if final "program" LTV + //if final "program" LTV if ( ltvp->mode == CFG_PROG_STOP && ifbp->IFB_DLMode == CFG_PROG_VOLATILE) { - //. start tertiary (or secondary) + //. start tertiary (or secondary) OPW( HREG_PARAM_1, (hcf_16)(ltvp->nic_addr >> 16) ); rc = cmd_exe( ifbp, HCMD_EXECUTE, (hcf_16) ltvp->nic_addr ); if (rc == HCF_SUCCESS) { - rc = init( ifbp ); /*;? do we really want to skip init if cmd_exe failed, i.e. - * IFB_FW_Comp_Id is than possibly incorrect */ - } - //else (non-final) + rc = init( ifbp ); /*;? do we really want to skip init if cmd_exe failed, i.e. + * IFB_FW_Comp_Id is than possibly incorrect */ + } + //else (non-final) } else { - //. if mode == Readback SEEPROM -#if 0 //;? as long as the next if contains a hard coded 0, might as well leave it out even more obvious + //. if mode == Readback SEEPROM +#if 0 //;? as long as the next if contains a hard coded 0, might as well leave it out even more obvious if ( 0 /*len is definitely not want we want;?*/ && ltvp->mode == CFG_PROG_SEEPROM_READBACK ) { OPW( HREG_PARAM_1, (hcf_16)(ltvp->nic_addr >> 16) ); OPW( HREG_PARAM_2, MUL_BY_2(ltvp->len - 4)); - //. . perform Hermes prog cmd with appropriate mode bits + //. . perform Hermes prog cmd with appropriate mode bits rc = cmd_exe( ifbp, HCMD_PROGRAM | ltvp->mode, (hcf_16)ltvp->nic_addr ); - //. . set up NIC RAM addressability according Resp0-1 + //. . set up NIC RAM addressability according Resp0-1 OPW( HREG_AUX_PAGE, IPW( HREG_RESP_1) ); OPW( HREG_AUX_OFFSET, IPW( HREG_RESP_0) ); - //. . set up L-field of LTV according Resp2 + //. . set up L-field of LTV according Resp2 i = ( IPW( HREG_RESP_2 ) + 1 ) / 2; // i contains max buffer size in words, a probably not very useful piece of information ;? /*Nico's code based on i is the "real amount of data available" if ( ltvp->len - 4 < i ) rc = HCF_ERR_LEN; @@ -3810,28 +3810,28 @@ hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; ltvp->len = i + 4; } */ - //. . copy data from NIC via AUX port to LTV - cp = (wci_bufp)ltvp->host_addr; /*IN_PORT_STRING_8_16 macro may modify its parameters*/ + //. . copy data from NIC via AUX port to LTV + cp = (wci_bufp)ltvp->host_addr; /*IN_PORT_STRING_8_16 macro may modify its parameters*/ i = ltvp->len - 4; - IN_PORT_STRING_8_16( io_port, cp, i ); //!!!WORD length, cp MUST be a char pointer // $$ char - //. else (non-final programming) + IN_PORT_STRING_8_16( io_port, cp, i ); //!!!WORD length, cp MUST be a char pointer // $$ char + //. else (non-final programming) } else #endif //;? as long as the above if contains a hard coded 0, might as well leave it out even more obvious - { //. . get number of words to program + { //. . get number of words to program HCFASSERT( ltvp->segment_size, *ltvp->host_addr ); i = ltvp->segment_size/2; - //. . copy data (words) from LTV via AUX port to NIC - cp = (wci_bufp)ltvp->host_addr; //OUT_PORT_STRING_8_16 macro may modify its parameters - //. . if mode == volatile programming + //. . copy data (words) from LTV via AUX port to NIC + cp = (wci_bufp)ltvp->host_addr; //OUT_PORT_STRING_8_16 macro may modify its parameters + //. . if mode == volatile programming if ( ltvp->mode == CFG_PROG_VOLATILE ) { - //. . . set up NIC RAM addressability via AUX port + //. . . set up NIC RAM addressability via AUX port OPW( HREG_AUX_PAGE, (hcf_16)(ltvp->nic_addr >> 16 << 9 | (ltvp->nic_addr & 0xFFFF) >> 7 ) ); OPW( HREG_AUX_OFFSET, (hcf_16)(ltvp->nic_addr & 0x007E) ); - OUT_PORT_STRING_8_16( io_port, cp, i ); //!!!WORD length, cp MUST be a char pointer + OUT_PORT_STRING_8_16( io_port, cp, i ); //!!!WORD length, cp MUST be a char pointer } } } - ifbp->IFB_DLMode = ltvp->mode; //save state in IFB_DLMode + ifbp->IFB_DLMode = ltvp->mode; //save state in IFB_DLMode #endif // HCF_TYPE_PRELOADED HCFASSERT( rc == HCF_SUCCESS, rc ); HCFLOGEXIT( HCF_TRACE_DL ); @@ -3841,82 +3841,82 @@ hcf_io io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; #if (HCF_ASSERT) & HCF_ASSERT_PRINTF /************************************************** -* Certain Hermes-II firmware versions can generate -* debug information. This debug information is -* contained in a buffer in nic-RAM, and can be read -* via the aux port. -**************************************************/ + * Certain Hermes-II firmware versions can generate + * debug information. This debug information is + * contained in a buffer in nic-RAM, and can be read + * via the aux port. + **************************************************/ HCF_STATIC int fw_printf(IFBP ifbp, CFG_FW_PRINTF_STRCT FAR *ltvp) { - int rc = HCF_SUCCESS; - hcf_16 fw_cnt; -// hcf_32 DbMsgBuffer = 0x29D2, DbMsgCount= 0x000029D0; -// hcf_16 DbMsgSize=0x00000080; - hcf_32 DbMsgBuffer; - CFG_FW_PRINTF_BUFFER_LOCATION_STRCT *p = &ifbp->IFB_FwPfBuff; - ltvp->len = 1; - if ( p->DbMsgSize != 0 ) { - // first, check the counter in nic-RAM and compare it to the latest counter value of the HCF - OPW( HREG_AUX_PAGE, (hcf_16)(p->DbMsgCount >> 7) ); - OPW( HREG_AUX_OFFSET, (hcf_16)(p->DbMsgCount & 0x7E) ); - fw_cnt = ((IPW( HREG_AUX_DATA) >>1 ) & ((hcf_16)p->DbMsgSize - 1)); - if ( fw_cnt != ifbp->IFB_DbgPrintF_Cnt ) { -// DbgPrint("fw_cnt=%d IFB_DbgPrintF_Cnt=%d\n", fw_cnt, ifbp->IFB_DbgPrintF_Cnt); - DbMsgBuffer = p->DbMsgBuffer + ifbp->IFB_DbgPrintF_Cnt * 6; // each entry is 3 words - OPW( HREG_AUX_PAGE, (hcf_16)(DbMsgBuffer >> 7) ); - OPW( HREG_AUX_OFFSET, (hcf_16)(DbMsgBuffer & 0x7E) ); - ltvp->msg_id = IPW(HREG_AUX_DATA); - ltvp->msg_par = IPW(HREG_AUX_DATA); - ltvp->msg_tstamp = IPW(HREG_AUX_DATA); - ltvp->len = 4; - ifbp->IFB_DbgPrintF_Cnt++; - ifbp->IFB_DbgPrintF_Cnt &= (p->DbMsgSize - 1); - } - } - return rc; + int rc = HCF_SUCCESS; + hcf_16 fw_cnt; +// hcf_32 DbMsgBuffer = 0x29D2, DbMsgCount= 0x000029D0; +// hcf_16 DbMsgSize=0x00000080; + hcf_32 DbMsgBuffer; + CFG_FW_PRINTF_BUFFER_LOCATION_STRCT *p = &ifbp->IFB_FwPfBuff; + ltvp->len = 1; + if ( p->DbMsgSize != 0 ) { + // first, check the counter in nic-RAM and compare it to the latest counter value of the HCF + OPW( HREG_AUX_PAGE, (hcf_16)(p->DbMsgCount >> 7) ); + OPW( HREG_AUX_OFFSET, (hcf_16)(p->DbMsgCount & 0x7E) ); + fw_cnt = ((IPW( HREG_AUX_DATA) >>1 ) & ((hcf_16)p->DbMsgSize - 1)); + if ( fw_cnt != ifbp->IFB_DbgPrintF_Cnt ) { +// DbgPrint("fw_cnt=%d IFB_DbgPrintF_Cnt=%d\n", fw_cnt, ifbp->IFB_DbgPrintF_Cnt); + DbMsgBuffer = p->DbMsgBuffer + ifbp->IFB_DbgPrintF_Cnt * 6; // each entry is 3 words + OPW( HREG_AUX_PAGE, (hcf_16)(DbMsgBuffer >> 7) ); + OPW( HREG_AUX_OFFSET, (hcf_16)(DbMsgBuffer & 0x7E) ); + ltvp->msg_id = IPW(HREG_AUX_DATA); + ltvp->msg_par = IPW(HREG_AUX_DATA); + ltvp->msg_tstamp = IPW(HREG_AUX_DATA); + ltvp->len = 4; + ifbp->IFB_DbgPrintF_Cnt++; + ifbp->IFB_DbgPrintF_Cnt &= (p->DbMsgSize - 1); + } + } + return rc; }; #endif // HCF_ASSERT_PRINTF #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.SUBMODULE hcf_16 get_fid( IFBP ifbp ) -*.PURPOSE get allocated FID for either transmit or notify. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* 0 no FID available -* <>0 FID number -* -*.DESCRIPTION -* -* -*.DIAGRAM -* The preference is to use a "pending" alloc. If no alloc is pending, then - if available - the "spare" FID -* is used. -* If the spare FID is used, IFB_RscInd (representing the spare FID) must be cleared -* If the pending alloc is used, the alloc event must be acknowledged to the Hermes. -* In case the spare FID was depleted and the IFB_RscInd has been "faked" as pseudo resource with a 0x0001 -* value by hcf_service_nic, IFB_RscInd has to be "corrected" again to its 0x0000 value. -* -* Note that due to the Hermes-II H/W problems which are intended to be worked around by DAWA, the Alloc bit -* in the Event register is no longer a reliable indication of the presence/absence of a FID. The "Clear FID" -* part of the DAWA logic, together with the choice of the definition of the return information from get_fid, -* handle this automatically, i.e. without additional code in get_fid. -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE hcf_16 get_fid( IFBP ifbp ) + *.PURPOSE get allocated FID for either transmit or notify. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * 0 no FID available + * <>0 FID number + * + *.DESCRIPTION + * + * + *.DIAGRAM + * The preference is to use a "pending" alloc. If no alloc is pending, then - if available - the "spare" FID + * is used. + * If the spare FID is used, IFB_RscInd (representing the spare FID) must be cleared + * If the pending alloc is used, the alloc event must be acknowledged to the Hermes. + * In case the spare FID was depleted and the IFB_RscInd has been "faked" as pseudo resource with a 0x0001 + * value by hcf_service_nic, IFB_RscInd has to be "corrected" again to its 0x0000 value. + * + * Note that due to the Hermes-II H/W problems which are intended to be worked around by DAWA, the Alloc bit + * in the Event register is no longer a reliable indication of the presence/absence of a FID. The "Clear FID" + * part of the DAWA logic, together with the choice of the definition of the return information from get_fid, + * handle this automatically, i.e. without additional code in get_fid. + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC hcf_16 get_fid( IFBP ifbp ) { -hcf_16 fid = 0; + hcf_16 fid = 0; #if ( (HCF_TYPE) & HCF_TYPE_HII5 ) == 0 -PROT_CNT_INI; + PROT_CNT_INI; #endif // HCF_TYPE_HII5 IF_DMA( HCFASSERT(!(ifbp->IFB_CntlOpt & USE_DMA), ifbp->IFB_CntlOpt) ); @@ -3929,7 +3929,7 @@ PROT_CNT_INI; HCF_WAIT_WHILE( ( IPW( HREG_EV_STAT ) & HREG_EV_ACK_REG_READY ) == 0 ); HCFASSERT( prot_cnt, IPW( HREG_EV_STAT ) ); #endif // HCF_TYPE_HII5 - DAWA_ACK( HREG_EV_ALLOC ); //!!note that HREG_EV_ALLOC is written only once + DAWA_ACK( HREG_EV_ALLOC ); //!!note that HREG_EV_ALLOC is written only once // 180 degree error in logic ;? #if ALLOC_15 if ( ifbp->IFB_RscInd == 1 ) { ifbp->IFB_RscInd = 0; @@ -3947,100 +3947,100 @@ PROT_CNT_INI; /************************************************************************************************************ -* -*.SUBMODULE void get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) -*.PURPOSE reads with 16/32 bit I/O via BAP1 port from NIC RAM to Host memory. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* bufp (byte) address of buffer -* len length in bytes of buffer specified by bufp -* word_len Big Endian only: number of leading bytes to swap in pairs -* -*.RETURNS N.A. -* -*.DESCRIPTION -* process the single byte (if applicable) read by the previous get_frag and copy len (or len-1) bytes from -* NIC to bufp. -* On a Big Endian platform, the parameter word_len controls the number of leading bytes whose endianess is -* converted (i.e. byte swapped) -* -* -*.DIAGRAM -*10: The PCMCIA card can be removed in the middle of the transfer. By depositing a "magic number" in the -* HREG_SW_0 register of the Hermes at initialization time and by verifying this register, it can be -* determined whether the card is still present. The return status is set accordingly. -* Clearing the buffer is a (relative) cheap way to prevent that failing I/O results in run-away behavior -* because the garbage in the buffer is interpreted by the caller irrespective of the return status (e.g. -* hcf_service_nic has this behavior). -* -*.NOTICE -* It turns out DOS ODI uses zero length fragments. The HCF code can cope with it, but as a consequence, no -* Assert on len is possible -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) + *.PURPOSE reads with 16/32 bit I/O via BAP1 port from NIC RAM to Host memory. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * bufp (byte) address of buffer + * len length in bytes of buffer specified by bufp + * word_len Big Endian only: number of leading bytes to swap in pairs + * + *.RETURNS N.A. + * + *.DESCRIPTION + * process the single byte (if applicable) read by the previous get_frag and copy len (or len-1) bytes from + * NIC to bufp. + * On a Big Endian platform, the parameter word_len controls the number of leading bytes whose endianess is + * converted (i.e. byte swapped) + * + * + *.DIAGRAM + *10: The PCMCIA card can be removed in the middle of the transfer. By depositing a "magic number" in the + * HREG_SW_0 register of the Hermes at initialization time and by verifying this register, it can be + * determined whether the card is still present. The return status is set accordingly. + * Clearing the buffer is a (relative) cheap way to prevent that failing I/O results in run-away behavior + * because the garbage in the buffer is interpreted by the caller irrespective of the return status (e.g. + * hcf_service_nic has this behavior). + * + *.NOTICE + * It turns out DOS ODI uses zero length fragments. The HCF code can cope with it, but as a consequence, no + * Assert on len is possible + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC void get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) { -hcf_io io_port = ifbp->IFB_IOBase + HREG_DATA_1; //BAP data register -wci_bufp p = bufp; //working pointer -int i; //prevent side effects from macro -int j; + hcf_io io_port = ifbp->IFB_IOBase + HREG_DATA_1; //BAP data register + wci_bufp p = bufp; //working pointer + int i; //prevent side effects from macro + int j; HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ); -/*1: here recovery logic for intervening BAP access between hcf_service_nic and hcf_rcv_msg COULD be added - * if current access is RxInitial - * . persistent_offset += len +/*1: here recovery logic for intervening BAP access between hcf_service_nic and hcf_rcv_msg COULD be added + * if current access is RxInitial + * . persistent_offset += len */ i = len; - //if buffer length > 0 and carry from previous get_frag + //if buffer length > 0 and carry from previous get_frag if ( i && ifbp->IFB_CarryIn ) { - //. move carry to buffer - //. adjust buffer length and pointer accordingly + //. move carry to buffer + //. adjust buffer length and pointer accordingly *p++ = (hcf_8)(ifbp->IFB_CarryIn>>8); i--; - //. clear carry flag + //. clear carry flag ifbp->IFB_CarryIn = 0; } #if (HCF_IO) & HCF_IO_32BITS //skip zero-length I/O, single byte I/O and I/O not worthwhile (i.e. less than 6 bytes)for DW logic - //if buffer length >= 6 and 32 bits I/O support + //if buffer length >= 6 and 32 bits I/O support if ( !(ifbp->IFB_CntlOpt & USE_16BIT) && i >= 6 ) { -hcf_32 FAR *p4; //prevent side effects from macro - if ( ( (hcf_32)p & 0x1 ) == 0 ) { //. if buffer at least word aligned - if ( (hcf_32)p & 0x2 ) { //. . if buffer not double word aligned - //. . . read single word to get double word aligned + hcf_32 FAR *p4; //prevent side effects from macro + if ( ( (hcf_32)p & 0x1 ) == 0 ) { //. if buffer at least word aligned + if ( (hcf_32)p & 0x2 ) { //. . if buffer not double word aligned + //. . . read single word to get double word aligned *(wci_recordp)p = IN_PORT_WORD( io_port ); - //. . . adjust buffer length and pointer accordingly + //. . . adjust buffer length and pointer accordingly p += 2; i -= 2; } - //. . read as many double word as possible + //. . read as many double word as possible p4 = (hcf_32 FAR *)p; j = i/4; IN_PORT_STRING_32( io_port, p4, j ); - //. . adjust buffer length and pointer accordingly + //. . adjust buffer length and pointer accordingly p += i & ~0x0003; i &= 0x0003; } } #endif // HCF_IO_32BITS - //if no 32-bit support OR byte aligned OR 1-3 bytes left + //if no 32-bit support OR byte aligned OR 1-3 bytes left if ( i ) { - //. read as many word as possible in "alignment safe" way + //. read as many word as possible in "alignment safe" way j = i/2; IN_PORT_STRING_8_16( io_port, p, j ); - //. if 1 byte left + //. if 1 byte left if ( i & 0x0001 ) { - //. . read 1 word + //. . read 1 word ifbp->IFB_CarryIn = IN_PORT_WORD( io_port ); - //. . store LSB in last char of buffer + //. . store LSB in last char of buffer bufp[len-1] = (hcf_8)ifbp->IFB_CarryIn; - //. . save MSB in carry, set carry flag + //. . save MSB in carry, set carry flag ifbp->IFB_CarryIn |= 0x1; } } @@ -4050,13 +4050,13 @@ hcf_32 FAR *p4; //prevent side effects from macro HCFASSERT( word_len <= len, MERGE2( word_len, len ) ); //see put_frag for an alternative implementation, but be careful about what are int's and what are //hcf_16's - if ( word_len ) { //. if there is anything to convert -hcf_8 c; - c = bufp[1]; //. . convert the 1st hcf_16 + if ( word_len ) { //. if there is anything to convert + hcf_8 c; + c = bufp[1]; //. . convert the 1st hcf_16 bufp[1] = bufp[0]; bufp[0] = c; - if ( word_len > 1 ) { //. . if there is to convert more than 1 word ( i.e 2 ) - c = bufp[3]; //. . . convert the 2nd hcf_16 + if ( word_len > 1 ) { //. . if there is to convert more than 1 word ( i.e 2 ) + c = bufp[3]; //. . . convert the 2nd hcf_16 bufp[3] = bufp[2]; bufp[2] = c; } @@ -4065,108 +4065,108 @@ hcf_8 c; } // get_frag /************************************************************************************************************ -* -*.SUBMODULE int init( IFBP ifbp ) -*.PURPOSE Handles common initialization aspects (H-I init, calibration, config.mngmt, allocation). -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS -* HCF_ERR_INCOMP_PRI -* HCF_ERR_INCOMP_FW -* HCF_ERR_TIME_OUT -* >>hcf_get_info -* HCF_ERR_NO_NIC -* HCF_ERR_LEN -* -*.DESCRIPTION -* init will successively: -* - in case of a (non-preloaded) H-I, initialize the NIC -* - calibrate the S/W protection timer against the Hermes Timer -* - collect HSI, "active" F/W Configuration Management Information -* - in case active F/W is Primary F/W: collect Primary F/W Configuration Management Information -* - check HSI and Primary F/W compatibility with the HCF -* - in case active F/W is Station or AP F/W: check Station or AP F/W compatibility with the HCF -* - in case active F/W is not Primary F/W: allocate FIDs to be used in transmit/notify process -* -* -*.DIAGRAM -*2: drop all error status bits in IFB_CardStat since they are expected to be re-evaluated. -*4: Ack everything except HREG_EV_SLEEP_REQ. It is very likely that an Alloc event is pending and -* very well possible that a Send Cmd event is pending. Acking HREG_EV_SLEEP_REQ is handled by hcf_action( -* HCF_ACT_INT_ON ) !!! -*10: Calibrate the S/W time-out protection mechanism by calling calibrate(). Note that possible errors -* in the calibration process are nor reported by init but will show up via the defunct mechanism in -* subsequent hcf-calls. -*14: usb_check_comp() is called to have the minimal visual clutter for the legacy H-I USB dongle -* compatibility check. -*16: The following configuration management related information is retrieved from the NIC: -* - HSI supplier -* - F/W Identity -* - F/W supplier -* if appropriate: -* - PRI Identity -* - PRI supplier -* appropriate means on H-I: always -* and on H-II if F/W supplier reflects a primary (i.e. only after an Hermes Reset or Init -* command). -* QUESTION ;? !!!!!! should, For each of the above RIDs the Endianess is converted to native Endianess. -* Only the return code of the first hcf_get_info is used. All hcf_get_info calls are made, regardless of -* the success or failure of the 1st hcf_get_info. The assumptions are: -* - if any call fails, they all fail, so remembering the result of the 1st call is adequate -* - a failing call will overwrite the L-field with a 0x0000 value, which services both as an -* error indication for the values cached in the IFB as making mmd_check_comp fail. -* In case of H-I, when getting the F/W identity fails, the F/W is assumed to be H-I AP F/W pre-dating -* version 9.0 and the F/W Identity and Supplier are faked accordingly. -* In case of H-II, the Primary, Station and AP Identity are merged into a single F/W Identity. -* The same applies to the Supplier information. As a consequence the PRI information can no longer be -* retrieved when a Tertiary runs. To accommodate MSFs and Utilities who depend on PRI information being -* available at any time, this information is cached in the IFB. In this cache the generic "F/W" value of -* the typ-fields is overwritten with the specific (legacy) "PRI" values. To actually re-route the (legacy) -* PRI request via hcf_get_info, the xxxx-table must be set. In case of H-I, this caching, modifying and -* re-routing is not needed because PRI information is always available directly from the NIC. For -* consistency the caching fields in the IFB are filled with the PRI information anyway. -*18: mdd_check_comp() is called to check the Supplier Variant and Range of the Host-S/W I/F (HSI) and the -* Primary Firmware Variant and Range against the Top and Bottom level supported by this HCF. If either of -* these tests fails, the CARD_STAT_INCOMP_PRI bit of IFB_CardStat is set -* Note: There should always be a primary except during production, so this makes the HCF in its current form -* unsuitable for manufacturing test systems like the FTS. This can be remedied by an adding a test like -* ifbp->IFB_PRISup.id == COMP_ID_PRI -*20: In case there is Tertiary F/W and this F/W is Station F/W, the Supplier Variant and Range of the Station -* Firmware function as retrieved from the Hermes is checked against the Top and Bottom level supported by -* this HCF. -* Note: ;? the tertiary F/W compatibility checks could be moved to the DHF, which already has checked the -* CFI and MFI compatibility of the image with the NIC before the image was downloaded. -*28: In case of non-Primary F/W: allocates and acknowledge a (TX or Notify) FID and allocates without -* acknowledge another (TX or Notify) FID (the so-called 1.5 alloc scheme) with the following steps: -* - execute the allocate command by calling cmd_exe -* - wait till either the alloc event or a time-out occurs -* - regardless whether the alloc event occurs, call get_fid to -* - read the FID and save it in IFB_RscInd to be used as "spare FID" -* - acknowledge the alloc event -* - do another "half" allocate to complete the "1.5 Alloc scheme" -* Note that above 3 steps do not harm and thus give the "cheapest" acceptable strategy. -* If a time-out occurred, then report time out status (after all) -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int init( IFBP ifbp ) + *.PURPOSE Handles common initialization aspects (H-I init, calibration, config.mngmt, allocation). + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS + * HCF_ERR_INCOMP_PRI + * HCF_ERR_INCOMP_FW + * HCF_ERR_TIME_OUT + * >>hcf_get_info + * HCF_ERR_NO_NIC + * HCF_ERR_LEN + * + *.DESCRIPTION + * init will successively: + * - in case of a (non-preloaded) H-I, initialize the NIC + * - calibrate the S/W protection timer against the Hermes Timer + * - collect HSI, "active" F/W Configuration Management Information + * - in case active F/W is Primary F/W: collect Primary F/W Configuration Management Information + * - check HSI and Primary F/W compatibility with the HCF + * - in case active F/W is Station or AP F/W: check Station or AP F/W compatibility with the HCF + * - in case active F/W is not Primary F/W: allocate FIDs to be used in transmit/notify process + * + * + *.DIAGRAM + *2: drop all error status bits in IFB_CardStat since they are expected to be re-evaluated. + *4: Ack everything except HREG_EV_SLEEP_REQ. It is very likely that an Alloc event is pending and + * very well possible that a Send Cmd event is pending. Acking HREG_EV_SLEEP_REQ is handled by hcf_action( + * HCF_ACT_INT_ON ) !!! + *10: Calibrate the S/W time-out protection mechanism by calling calibrate(). Note that possible errors + * in the calibration process are nor reported by init but will show up via the defunct mechanism in + * subsequent hcf-calls. + *14: usb_check_comp() is called to have the minimal visual clutter for the legacy H-I USB dongle + * compatibility check. + *16: The following configuration management related information is retrieved from the NIC: + * - HSI supplier + * - F/W Identity + * - F/W supplier + * if appropriate: + * - PRI Identity + * - PRI supplier + * appropriate means on H-I: always + * and on H-II if F/W supplier reflects a primary (i.e. only after an Hermes Reset or Init + * command). + * QUESTION ;? !!!!!! should, For each of the above RIDs the Endianess is converted to native Endianess. + * Only the return code of the first hcf_get_info is used. All hcf_get_info calls are made, regardless of + * the success or failure of the 1st hcf_get_info. The assumptions are: + * - if any call fails, they all fail, so remembering the result of the 1st call is adequate + * - a failing call will overwrite the L-field with a 0x0000 value, which services both as an + * error indication for the values cached in the IFB as making mmd_check_comp fail. + * In case of H-I, when getting the F/W identity fails, the F/W is assumed to be H-I AP F/W pre-dating + * version 9.0 and the F/W Identity and Supplier are faked accordingly. + * In case of H-II, the Primary, Station and AP Identity are merged into a single F/W Identity. + * The same applies to the Supplier information. As a consequence the PRI information can no longer be + * retrieved when a Tertiary runs. To accommodate MSFs and Utilities who depend on PRI information being + * available at any time, this information is cached in the IFB. In this cache the generic "F/W" value of + * the typ-fields is overwritten with the specific (legacy) "PRI" values. To actually re-route the (legacy) + * PRI request via hcf_get_info, the xxxx-table must be set. In case of H-I, this caching, modifying and + * re-routing is not needed because PRI information is always available directly from the NIC. For + * consistency the caching fields in the IFB are filled with the PRI information anyway. + *18: mdd_check_comp() is called to check the Supplier Variant and Range of the Host-S/W I/F (HSI) and the + * Primary Firmware Variant and Range against the Top and Bottom level supported by this HCF. If either of + * these tests fails, the CARD_STAT_INCOMP_PRI bit of IFB_CardStat is set + * Note: There should always be a primary except during production, so this makes the HCF in its current form + * unsuitable for manufacturing test systems like the FTS. This can be remedied by an adding a test like + * ifbp->IFB_PRISup.id == COMP_ID_PRI + *20: In case there is Tertiary F/W and this F/W is Station F/W, the Supplier Variant and Range of the Station + * Firmware function as retrieved from the Hermes is checked against the Top and Bottom level supported by + * this HCF. + * Note: ;? the tertiary F/W compatibility checks could be moved to the DHF, which already has checked the + * CFI and MFI compatibility of the image with the NIC before the image was downloaded. + *28: In case of non-Primary F/W: allocates and acknowledge a (TX or Notify) FID and allocates without + * acknowledge another (TX or Notify) FID (the so-called 1.5 alloc scheme) with the following steps: + * - execute the allocate command by calling cmd_exe + * - wait till either the alloc event or a time-out occurs + * - regardless whether the alloc event occurs, call get_fid to + * - read the FID and save it in IFB_RscInd to be used as "spare FID" + * - acknowledge the alloc event + * - do another "half" allocate to complete the "1.5 Alloc scheme" + * Note that above 3 steps do not harm and thus give the "cheapest" acceptable strategy. + * If a time-out occurred, then report time out status (after all) + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int init( IFBP ifbp ) { -int rc = HCF_SUCCESS; + int rc = HCF_SUCCESS; HCFLOGENTRY( HCF_TRACE_INIT, 0 ); - ifbp->IFB_CardStat = 0; /* 2*/ - OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); /* 4*/ - IF_PROT_TIME( calibrate( ifbp ) ); /*10*/ + ifbp->IFB_CardStat = 0; /* 2*/ + OPW( HREG_EV_ACK, ~HREG_EV_SLEEP_REQ ); /* 4*/ + IF_PROT_TIME( calibrate( ifbp ) ); /*10*/ #if 0 // OOR - ifbp->IFB_FWIdentity.len = 2; //misuse the IFB space for a put + ifbp->IFB_FWIdentity.len = 2; //misuse the IFB space for a put ifbp->IFB_FWIdentity.typ = CFG_TICK_TIME; - ifbp->IFB_FWIdentity.comp_id = (1000*1000)/1024 + 1; //roughly 1 second + ifbp->IFB_FWIdentity.comp_id = (1000*1000)/1024 + 1; //roughly 1 second hcf_put_info( ifbp, (LTVP)&ifbp->IFB_FWIdentity.len ); #endif // OOR ifbp->IFB_FWIdentity.len = sizeof(CFG_FW_IDENTITY_STRCT)/sizeof(hcf_16) - 1; @@ -4179,8 +4179,8 @@ int rc = HCF_SUCCESS; ifbp->IFB_FWIdentity.version_major = CNV_LITTLE_TO_SHORT( ifbp->IFB_FWIdentity.version_major ); ifbp->IFB_FWIdentity.version_minor = CNV_LITTLE_TO_SHORT( ifbp->IFB_FWIdentity.version_minor ); #endif // HCF_BIG_ENDIAN -#if defined MSF_COMPONENT_ID /*14*/ - if ( rc == HCF_SUCCESS ) { /*16*/ +#if defined MSF_COMPONENT_ID /*14*/ + if ( rc == HCF_SUCCESS ) { /*16*/ ifbp->IFB_HSISup.len = sizeof(CFG_SUP_RANGE_STRCT)/sizeof(hcf_16) - 1; ifbp->IFB_HSISup.typ = CFG_NIC_HSI_SUP_RANGE; rc = hcf_get_info( ifbp, (LTVP)&ifbp->IFB_HSISup.len ); @@ -4207,41 +4207,41 @@ int rc = HCF_SUCCESS; ifbp->IFB_FWSup.top = CNV_LITTLE_TO_SHORT( ifbp->IFB_FWSup.top ); #endif // HCF_BIG_ENDIAN - if ( ifbp->IFB_FWSup.id == COMP_ID_PRI ) { /* 20*/ -int i = sizeof( CFG_FW_IDENTITY_STRCT) + sizeof(CFG_SUP_RANGE_STRCT ); + if ( ifbp->IFB_FWSup.id == COMP_ID_PRI ) { /* 20*/ + int i = sizeof( CFG_FW_IDENTITY_STRCT) + sizeof(CFG_SUP_RANGE_STRCT ); while ( i-- ) ((hcf_8*)(&ifbp->IFB_PRIIdentity))[i] = ((hcf_8*)(&ifbp->IFB_FWIdentity))[i]; ifbp->IFB_PRIIdentity.typ = CFG_PRI_IDENTITY; ifbp->IFB_PRISup.typ = CFG_PRI_SUP_RANGE; xxxx[xxxx_PRI_IDENTITY_OFFSET] = &ifbp->IFB_PRIIdentity.len; xxxx[xxxx_PRI_IDENTITY_OFFSET+1] = &ifbp->IFB_PRISup.len; } - if ( !mmd_check_comp( (void*)&cfg_drv_act_ranges_hsi, &ifbp->IFB_HSISup) /* 22*/ + if ( !mmd_check_comp( (void*)&cfg_drv_act_ranges_hsi, &ifbp->IFB_HSISup) /* 22*/ #if ( (HCF_TYPE) & HCF_TYPE_PRELOADED ) == 0 //;? the PRI compatibility check is only relevant for DHF - || !mmd_check_comp( (void*)&cfg_drv_act_ranges_pri, &ifbp->IFB_PRISup) + || !mmd_check_comp( (void*)&cfg_drv_act_ranges_pri, &ifbp->IFB_PRISup) #endif // HCF_TYPE_PRELOADED - ) { + ) { ifbp->IFB_CardStat = CARD_STAT_INCOMP_PRI; rc = HCF_ERR_INCOMP_PRI; } - if ( ( ifbp->IFB_FWSup.id == COMP_ID_STA && !mmd_check_comp( (void*)&cfg_drv_act_ranges_sta, &ifbp->IFB_FWSup) ) || - ( ifbp->IFB_FWSup.id == COMP_ID_APF && !mmd_check_comp( (void*)&cfg_drv_act_ranges_apf, &ifbp->IFB_FWSup) ) - ) { /* 24 */ + if ( ( ifbp->IFB_FWSup.id == COMP_ID_STA && !mmd_check_comp( (void*)&cfg_drv_act_ranges_sta, &ifbp->IFB_FWSup) ) || + ( ifbp->IFB_FWSup.id == COMP_ID_APF && !mmd_check_comp( (void*)&cfg_drv_act_ranges_apf, &ifbp->IFB_FWSup) ) + ) { /* 24 */ ifbp->IFB_CardStat |= CARD_STAT_INCOMP_FW; rc = HCF_ERR_INCOMP_FW; } } #endif // MSF_COMPONENT_ID -#if (HCF_DL_ONLY) == 0 /* 28 */ +#if (HCF_DL_ONLY) == 0 /* 28 */ if ( rc == HCF_SUCCESS && ifbp->IFB_FWIdentity.comp_id >= COMP_ID_FW_STA ) { -PROT_CNT_INI; + PROT_CNT_INI; /************************************************************************************** - * rlav: the DMA engine needs the host to cause a 'hanging alloc event' for it to consume. - * not sure if this is the right spot in the HCF, thinking about hcf_enable... - **************************************************************************************/ + * rlav: the DMA engine needs the host to cause a 'hanging alloc event' for it to consume. + * not sure if this is the right spot in the HCF, thinking about hcf_enable... + **************************************************************************************/ rc = cmd_exe( ifbp, HCMD_ALLOC, 0 ); // 180 degree error in logic ;? #if ALLOC_15 -// ifbp->IFB_RscInd = 1; //let's hope that by the time hcf_send_msg isa called, there will be a FID +// ifbp->IFB_RscInd = 1; //let's hope that by the time hcf_send_msg isa called, there will be a FID //#else if ( rc == HCF_SUCCESS ) { HCF_WAIT_WHILE( (IPW( HREG_EV_STAT ) & HREG_EV_ALLOC) == 0 ); @@ -4266,74 +4266,74 @@ PROT_CNT_INI; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.SUBMODULE void isr_info( IFBP ifbp ) -*.PURPOSE handles link events. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS N.A. -* -*.DESCRIPTION -* -* -*.DIAGRAM -*1: First the FID number corresponding with the InfoEvent is determined. -* Note the complication of the zero-FID protection sub-scheme in DAWA. -* Next the L-field and the T-field are fetched into scratch buffer info. -*2: In case of tallies, the 16 bits Hermes values are accumulated in the IFB into 32 bits values. Info[0] -* is (expected to be) HCF_NIC_TAL_CNT + 1. The contraption "while ( info[0]-- >1 )" rather than -* "while ( --info[0] )" is used because it is dangerous to determine the length of the Value field by -* decrementing info[0]. As a result of a bug in some version of the F/W, info[0] may be 0, resulting -* in a very long loop in the pre-decrement logic. -*4: In case of a link status frame, the information is copied to the IFB field IFB_linkStat -*6: All other than Tallies (including "unknown" ones) are checked against the selection set by the MSF -* via CFG_RID_LOG. If a match is found or the selection set has the wild-card type (i.e non-NULL buffer -* pointer at the terminating zero-type), the frame is copied to the (type-specific) log buffer. -* Note that to accumulate tallies into IFB AND to log them or to log a frame when a specific match occures -* AND based on the wild-card selection, you have to call setup_bap again after the 1st copy. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void isr_info( IFBP ifbp ) + *.PURPOSE handles link events. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS N.A. + * + *.DESCRIPTION + * + * + *.DIAGRAM + *1: First the FID number corresponding with the InfoEvent is determined. + * Note the complication of the zero-FID protection sub-scheme in DAWA. + * Next the L-field and the T-field are fetched into scratch buffer info. + *2: In case of tallies, the 16 bits Hermes values are accumulated in the IFB into 32 bits values. Info[0] + * is (expected to be) HCF_NIC_TAL_CNT + 1. The contraption "while ( info[0]-- >1 )" rather than + * "while ( --info[0] )" is used because it is dangerous to determine the length of the Value field by + * decrementing info[0]. As a result of a bug in some version of the F/W, info[0] may be 0, resulting + * in a very long loop in the pre-decrement logic. + *4: In case of a link status frame, the information is copied to the IFB field IFB_linkStat + *6: All other than Tallies (including "unknown" ones) are checked against the selection set by the MSF + * via CFG_RID_LOG. If a match is found or the selection set has the wild-card type (i.e non-NULL buffer + * pointer at the terminating zero-type), the frame is copied to the (type-specific) log buffer. + * Note that to accumulate tallies into IFB AND to log them or to log a frame when a specific match occures + * AND based on the wild-card selection, you have to call setup_bap again after the 1st copy. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC void isr_info( IFBP ifbp ) { -hcf_16 info[2], fid; + hcf_16 info[2], fid; #if (HCF_EXT) & HCF_EXT_INFO_LOG -RID_LOGP ridp = ifbp->IFB_RIDLogp; //NULL or pointer to array of RID_LOG structures (terminated by zero typ) + RID_LOGP ridp = ifbp->IFB_RIDLogp; //NULL or pointer to array of RID_LOG structures (terminated by zero typ) #endif // HCF_EXT_INFO_LOG - HCFTRACE( ifbp, HCF_TRACE_ISR_INFO ); /* 1 */ + HCFTRACE( ifbp, HCF_TRACE_ISR_INFO ); /* 1 */ fid = IPW( HREG_INFO_FID ); DAWA_ZERO_FID( HREG_INFO_FID ); if ( fid ) { (void)setup_bap( ifbp, fid, 0, IO_IN ); get_frag( ifbp, (wci_bufp)info, 4 BE_PAR(2) ); HCFASSERT( info[0] <= HCF_MAX_LTV + 1, MERGE_2( info[1], info[0] ) ); //;? a smaller value makes more sense -#if (HCF_TALLIES) & HCF_TALLIES_NIC //Hermes tally support +#if (HCF_TALLIES) & HCF_TALLIES_NIC //Hermes tally support if ( info[1] == CFG_TALLIES ) { -hcf_32 *p; -/*2*/ if ( info[0] > HCF_NIC_TAL_CNT ) { + hcf_32 *p; + /*2*/ if ( info[0] > HCF_NIC_TAL_CNT ) { info[0] = HCF_NIC_TAL_CNT + 1; } p = (hcf_32*)&ifbp->IFB_NIC_Tallies; - while ( info[0]-- >1 ) *p++ += IPW( HREG_DATA_1 ); //request may return zero length + while ( info[0]-- >1 ) *p++ += IPW( HREG_DATA_1 ); //request may return zero length } else #endif // HCF_TALLIES_NIC { -/*4*/ if ( info[1] == CFG_LINK_STAT ) { + /*4*/ if ( info[1] == CFG_LINK_STAT ) { ifbp->IFB_LinkStat = IPW( HREG_DATA_1 ); } #if (HCF_EXT) & HCF_EXT_INFO_LOG -/*6*/ while ( 1 ) { + /*6*/ while ( 1 ) { if ( ridp->typ == 0 || ridp->typ == info[1] ) { if ( ridp->bufp ) { HCFASSERT( ridp->len >= 2, ridp->typ ); - ridp->bufp[0] = min((hcf_16)(ridp->len - 1), info[0] ); //save L - ridp->bufp[1] = info[1]; //save T + ridp->bufp[0] = min((hcf_16)(ridp->len - 1), info[0] ); //save L + ridp->bufp[1] = info[1]; //save T get_frag( ifbp, (wci_bufp)&ridp->bufp[2], (ridp->bufp[0] - 1)*2 BE_PAR(0) ); } break; @@ -4351,79 +4351,79 @@ hcf_32 *p; // // // #endif // HCF_TALLIES_NIC -// /*4*/ if ( info[1] == CFG_LINK_STAT ) { -// ifbp->IFB_DSLinkStat = IPW( HREG_DATA_1 ) | CFG_LINK_STAT_CHANGE; //corrupts BAP !! ;? -// ifbp->IFB_LinkStat = ifbp->IFB_DSLinkStat & CFG_LINK_STAT_FW; //;? to be obsoleted -// printk( "<4>linkstatus: %04x\n", ifbp->IFB_DSLinkStat ); //;?remove me 1 day +// /*4*/ if ( info[1] == CFG_LINK_STAT ) { +// ifbp->IFB_DSLinkStat = IPW( HREG_DATA_1 ) | CFG_LINK_STAT_CHANGE; //corrupts BAP !! ;? +// ifbp->IFB_LinkStat = ifbp->IFB_DSLinkStat & CFG_LINK_STAT_FW; //;? to be obsoleted +// printk( "<4>linkstatus: %04x\n", ifbp->IFB_DSLinkStat ); //;?remove me 1 day // #if (HCF_SLEEP) & HCF_DDS -// if ( ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_CONNECTED ) == 0 ) { //even values are disconnected etc. -// ifbp->IFB_TickCnt = 0; //start 2 second period (with 1 tick uncertanty) -// printk( "<5>isr_info: AwaitConnection phase started, IFB_TickCnt = 0\n" ); //;?remove me 1 day -// } +// if ( ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_CONNECTED ) == 0 ) { //even values are disconnected etc. +// ifbp->IFB_TickCnt = 0; //start 2 second period (with 1 tick uncertanty) +// printk( "<5>isr_info: AwaitConnection phase started, IFB_TickCnt = 0\n" ); //;?remove me 1 day +// } // #endif // HCF_DDS -// } +// } // #if (HCF_EXT) & HCF_EXT_INFO_LOG -// /*6*/ while ( 1 ) { -// if ( ridp->typ == 0 || ridp->typ == info[1] ) { -// if ( ridp->bufp ) { -// HCFASSERT( ridp->len >= 2, ridp->typ ); -// (void)setup_bap( ifbp, fid, 2, IO_IN ); //restore BAP for tallies, linkstat and specific type followed by wild card -// ridp->bufp[0] = min( ridp->len - 1, info[0] ); //save L -// get_frag( ifbp, (wci_bufp)&ridp->bufp[1], ridp->bufp[0]*2 BE_PAR(0) ); -// } -// break; //;?this break is no longer needed due to setup_bap but lets concentrate on DDS first -// } -// ridp++; -// } +// /*6*/ while ( 1 ) { +// if ( ridp->typ == 0 || ridp->typ == info[1] ) { +// if ( ridp->bufp ) { +// HCFASSERT( ridp->len >= 2, ridp->typ ); +// (void)setup_bap( ifbp, fid, 2, IO_IN ); //restore BAP for tallies, linkstat and specific type followed by wild card +// ridp->bufp[0] = min( ridp->len - 1, info[0] ); //save L +// get_frag( ifbp, (wci_bufp)&ridp->bufp[1], ridp->bufp[0]*2 BE_PAR(0) ); +// } +// break; //;?this break is no longer needed due to setup_bap but lets concentrate on DDS first +// } +// ridp++; +// } // #endif // HCF_EXT_INFO_LOG -// } -// HCFTRACE( ifbp, HCF_TRACE_ISR_INFO | HCF_TRACE_EXIT ); +// } +// HCFTRACE( ifbp, HCF_TRACE_ISR_INFO | HCF_TRACE_EXIT ); // // // // -// return; +// return; //} // isr_info //#endif // HCF_DL_ONLY /************************************************************************************************************ -* -*.SUBMODULE void mdd_assert( IFBP ifbp, unsigned int line_number, hcf_32 q ) -*.PURPOSE filters assert on level and interfaces to the MSF supplied msf_assert routine. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* line_number line number of the line which caused the assert -* q qualifier, additional information which may give a clue about the problem -* -*.RETURNS N.A. -* -*.DESCRIPTION -* -* -*.DIAGRAM -* -*.NOTICE -* mdd_assert has been through a turmoil, renaming hcf_assert to assert and hcf_assert again and supporting off -* and on being called from the MSF level and other ( immature ) ModularDriverDevelopment modules like DHF and -* MMD. - * !!!! The assert routine is not an hcf_..... routine in the sense that it may be called by the MSF, - * however it is called from mmd.c and dhf.c, so it must be external. - * To prevent namespace pollution it needs a prefix, to prevent that MSF programmers think that - * they are allowed to call the assert logic, the prefix HCF can't be used, so MDD is selected!!!! * -* When called from the DHF module the line number is incremented by DHF_FILE_NAME_OFFSET and when called from -* the MMD module by MMD_FILE_NAME_OFFSET. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + *.SUBMODULE void mdd_assert( IFBP ifbp, unsigned int line_number, hcf_32 q ) + *.PURPOSE filters assert on level and interfaces to the MSF supplied msf_assert routine. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * line_number line number of the line which caused the assert + * q qualifier, additional information which may give a clue about the problem + * + *.RETURNS N.A. + * + *.DESCRIPTION + * + * + *.DIAGRAM + * + *.NOTICE + * mdd_assert has been through a turmoil, renaming hcf_assert to assert and hcf_assert again and supporting off + * and on being called from the MSF level and other ( immature ) ModularDriverDevelopment modules like DHF and + * MMD. + * !!!! The assert routine is not an hcf_..... routine in the sense that it may be called by the MSF, + * however it is called from mmd.c and dhf.c, so it must be external. + * To prevent namespace pollution it needs a prefix, to prevent that MSF programmers think that + * they are allowed to call the assert logic, the prefix HCF can't be used, so MDD is selected!!!! + * + * When called from the DHF module the line number is incremented by DHF_FILE_NAME_OFFSET and when called from + * the MMD module by MMD_FILE_NAME_OFFSET. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ #if HCF_ASSERT void mdd_assert( IFBP ifbp, unsigned int line_number, hcf_32 q ) { -hcf_16 run_time_flag = ifbp->IFB_AssertLvl; + hcf_16 run_time_flag = ifbp->IFB_AssertLvl; if ( run_time_flag /* > ;?????? */ ) { //prevent recursive behavior, later to be extended to level filtering ifbp->IFB_AssertQualifier = q; @@ -4441,9 +4441,9 @@ hcf_16 run_time_flag = ifbp->IFB_AssertLvl; #endif // HCF_ASSERT_SW_SUP #if (HCF_EXT) & HCF_EXT_MB && (HCF_ASSERT) & HCF_ASSERT_MB - ifbp->IFB_AssertLvl = 0; // prevent recursive behavior + ifbp->IFB_AssertLvl = 0; // prevent recursive behavior hcf_put_info( ifbp, (LTVP)&ifbp->IFB_AssertStrct ); - ifbp->IFB_AssertLvl = run_time_flag; // restore appropriate filter level + ifbp->IFB_AssertLvl = run_time_flag; // restore appropriate filter level #endif // HCF_EXT_MB / HCF_ASSERT_MB } } // mdd_assert @@ -4451,63 +4451,63 @@ hcf_16 run_time_flag = ifbp->IFB_AssertLvl; /************************************************************************************************************ -* -*.SUBMODULE void put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) -*.PURPOSE writes with 16/32 bit I/O via BAP1 port from Host memory to NIC RAM. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* bufp (byte) address of buffer -* len length in bytes of buffer specified by bufp -* word_len Big Endian only: number of leading bytes to swap in pairs -* -*.RETURNS N.A. -* -*.DESCRIPTION -* process the single byte (if applicable) not yet written by the previous put_frag and copy len -* (or len-1) bytes from bufp to NIC. -* -* -*.DIAGRAM -* -*.NOTICE -* It turns out DOS ODI uses zero length fragments. The HCF code can cope with it, but as a consequence, no -* Assert on len is possible -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) + *.PURPOSE writes with 16/32 bit I/O via BAP1 port from Host memory to NIC RAM. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * bufp (byte) address of buffer + * len length in bytes of buffer specified by bufp + * word_len Big Endian only: number of leading bytes to swap in pairs + * + *.RETURNS N.A. + * + *.DESCRIPTION + * process the single byte (if applicable) not yet written by the previous put_frag and copy len + * (or len-1) bytes from bufp to NIC. + * + * + *.DIAGRAM + * + *.NOTICE + * It turns out DOS ODI uses zero length fragments. The HCF code can cope with it, but as a consequence, no + * Assert on len is possible + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC void put_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) ) { -hcf_io io_port = ifbp->IFB_IOBase + HREG_DATA_1; //BAP data register -int i; //prevent side effects from macro -hcf_16 j; + hcf_io io_port = ifbp->IFB_IOBase + HREG_DATA_1; //BAP data register + int i; //prevent side effects from macro + hcf_16 j; HCFASSERT( ((hcf_32)bufp & (HCF_ALIGN-1) ) == 0, (hcf_32)bufp ); #if HCF_BIG_ENDIAN HCFASSERT( word_len == 0 || word_len == 2 || word_len == 4, word_len ); HCFASSERT( word_len == 0 || ((hcf_32)bufp & 1 ) == 0, (hcf_32)bufp ); HCFASSERT( word_len <= len, MERGE_2( word_len, len ) ); - if ( word_len ) { //if there is anything to convert - //. convert and write the 1st hcf_16 + if ( word_len ) { //if there is anything to convert + //. convert and write the 1st hcf_16 j = bufp[1] | bufp[0]<<8; OUT_PORT_WORD( io_port, j ); - //. update pointer and counter accordingly + //. update pointer and counter accordingly len -= 2; bufp += 2; - if ( word_len > 1 ) { //. if there is to convert more than 1 word ( i.e 2 ) - //. . convert and write the 2nd hcf_16 - j = bufp[1] | bufp[0]<<8; /*bufp is already incremented by 2*/ + if ( word_len > 1 ) { //. if there is to convert more than 1 word ( i.e 2 ) + //. . convert and write the 2nd hcf_16 + j = bufp[1] | bufp[0]<<8; /*bufp is already incremented by 2*/ OUT_PORT_WORD( io_port, j ); - //. . update pointer and counter accordingly + //. . update pointer and counter accordingly len -= 2; bufp += 2; } } #endif // HCF_BIG_ENDIAN i = len; - if ( i && ifbp->IFB_CarryOut ) { //skip zero-length + if ( i && ifbp->IFB_CarryOut ) { //skip zero-length j = ((*bufp)<<8) + ( ifbp->IFB_CarryOut & 0xFF ); OUT_PORT_WORD( io_port, j ); bufp++; i--; @@ -4515,35 +4515,35 @@ hcf_16 j; } #if (HCF_IO) & HCF_IO_32BITS //skip zero-length I/O, single byte I/O and I/O not worthwhile (i.e. less than 6 bytes)for DW logic - //if buffer length >= 6 and 32 bits I/O support + //if buffer length >= 6 and 32 bits I/O support if ( !(ifbp->IFB_CntlOpt & USE_16BIT) && i >= 6 ) { -hcf_32 FAR *p4; //prevent side effects from macro - if ( ( (hcf_32)bufp & 0x1 ) == 0 ) { //. if buffer at least word aligned - if ( (hcf_32)bufp & 0x2 ) { //. . if buffer not double word aligned - //. . . write a single word to get double word aligned - j = *(wci_recordp)bufp; //just to help ease writing macros with embedded assembly + hcf_32 FAR *p4; //prevent side effects from macro + if ( ( (hcf_32)bufp & 0x1 ) == 0 ) { //. if buffer at least word aligned + if ( (hcf_32)bufp & 0x2 ) { //. . if buffer not double word aligned + //. . . write a single word to get double word aligned + j = *(wci_recordp)bufp; //just to help ease writing macros with embedded assembly OUT_PORT_WORD( io_port, j ); - //. . . adjust buffer length and pointer accordingly + //. . . adjust buffer length and pointer accordingly bufp += 2; i -= 2; } - //. . write as many double word as possible + //. . write as many double word as possible p4 = (hcf_32 FAR *)bufp; j = (hcf_16)i/4; OUT_PORT_STRING_32( io_port, p4, j ); - //. . adjust buffer length and pointer accordingly + //. . adjust buffer length and pointer accordingly bufp += i & ~0x0003; i &= 0x0003; } } #endif // HCF_IO_32BITS - //if no 32-bit support OR byte aligned OR 1 word left + //if no 32-bit support OR byte aligned OR 1 word left if ( i ) { - //. if odd number of bytes left + //. if odd number of bytes left if ( i & 0x0001 ) { - //. . save left over byte (before bufp is corrupted) in carry, set carry flag - ifbp->IFB_CarryOut = (hcf_16)bufp[i-1] | 0x0100; //note that i and bufp are always simultaneously modified, &bufp[i-1] is invariant + //. . save left over byte (before bufp is corrupted) in carry, set carry flag + ifbp->IFB_CarryOut = (hcf_16)bufp[i-1] | 0x0100; //note that i and bufp are always simultaneously modified, &bufp[i-1] is invariant } - //. write as many word as possible in "alignment safe" way + //. write as many word as possible in "alignment safe" way j = (hcf_16)i/2; OUT_PORT_STRING_8_16( io_port, bufp, j ); } @@ -4551,117 +4551,117 @@ hcf_32 FAR *p4; //prevent side effects from macro /************************************************************************************************************ -* -*.SUBMODULE void put_frag_finalize( IFBP ifbp ) -*.PURPOSE cleanup after put_frag for trailing odd byte and MIC transfer to NIC. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* -*.RETURNS N.A. -* -*.DESCRIPTION -* finalize the MIC calculation with the padding pattern, output the last byte (if applicable) -* of the message and the MIC to the TxFS -* -* -*.DIAGRAM -*2: 1 byte of the last put_frag may be still in IFB_CarryOut ( the put_frag carry holder ), so ........ -* 1 - 3 bytes of the last put_frag may be still in IFB_tx_32 ( the MIC engine carry holder ), so ........ -* The call to the MIC calculation routine feeds these remaining bytes (if any) of put_frag and the -* just as many bytes of the padding as needed to the MIC calculation engine. Note that the "unneeded" pad -* bytes simply end up in the MIC engine carry holder and are never used. -*8: write the remainder of the MIC and possible some garbage to NIC RAM -* Note: i is always 4 (a loop-invariant of the while in point 2) -* -*.NOTICE -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE void put_frag_finalize( IFBP ifbp ) + *.PURPOSE cleanup after put_frag for trailing odd byte and MIC transfer to NIC. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * + *.RETURNS N.A. + * + *.DESCRIPTION + * finalize the MIC calculation with the padding pattern, output the last byte (if applicable) + * of the message and the MIC to the TxFS + * + * + *.DIAGRAM + *2: 1 byte of the last put_frag may be still in IFB_CarryOut ( the put_frag carry holder ), so ........ + * 1 - 3 bytes of the last put_frag may be still in IFB_tx_32 ( the MIC engine carry holder ), so ........ + * The call to the MIC calculation routine feeds these remaining bytes (if any) of put_frag and the + * just as many bytes of the padding as needed to the MIC calculation engine. Note that the "unneeded" pad + * bytes simply end up in the MIC engine carry holder and are never used. + *8: write the remainder of the MIC and possible some garbage to NIC RAM + * Note: i is always 4 (a loop-invariant of the while in point 2) + * + *.NOTICE + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC void put_frag_finalize( IFBP ifbp ) { #if (HCF_TYPE) & HCF_TYPE_WPA - if ( ifbp->IFB_MICTxCarry != 0xFFFF) { //if MIC calculation active - CALC_TX_MIC( mic_pad, 8); //. feed (up to 8 bytes of) virtual padding to MIC engine - //. write (possibly) trailing byte + (most of) MIC + if ( ifbp->IFB_MICTxCarry != 0xFFFF) { //if MIC calculation active + CALC_TX_MIC( mic_pad, 8); //. feed (up to 8 bytes of) virtual padding to MIC engine + //. write (possibly) trailing byte + (most of) MIC put_frag( ifbp, (wci_bufp)ifbp->IFB_MICTx, 8 BE_PAR(0) ); } #endif // HCF_TYPE_WPA - put_frag( ifbp, null_addr, 1 BE_PAR(0) ); //write (possibly) trailing data or MIC byte + put_frag( ifbp, null_addr, 1 BE_PAR(0) ); //write (possibly) trailing data or MIC byte } // put_frag_finalize /************************************************************************************************************ -* -*.SUBMODULE int put_info( IFBP ifbp, LTVP ltvp ) -*.PURPOSE support routine to handle the "basic" task of hcf_put_info to pass RIDs to the NIC. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* ltvp address in NIC RAM where LVT-records are located -* -*.RETURNS -* HCF_SUCCESS -* >>put_frag -* >>cmd_wait -* -*.DESCRIPTION -* -* -*.DIAGRAM -*20: do not write RIDs to NICs which have incompatible Firmware -*24: If the RID does not exist, the L-field is set to zero. -* Note that some RIDs can not be read, e.g. the pseudo RIDs for direct Hermes commands and CFG_DEFAULT_KEYS -*28: If the RID is written successful, pass it to the NIC by means of an Access Write command -* -*.NOTICE -* The mechanism to HCF_ASSERT on invalid typ-codes in the LTV record is based on the following strategy: -* - some codes (e.g. CFG_REG_MB) are explicitly handled by the HCF which implies that these codes -* are valid. These codes are already consumed by hcf_put_info. -* - all other codes are passed to the Hermes. Before the put action is executed, hcf_get_info is called -* with an LTV record with a value of 1 in the L-field and the intended put action type in the Typ-code -* field. If the put action type is valid, it is also valid as a get action type code - except -* for CFG_DEFAULT_KEYS and CFG_ADD_TKIP_DEFAULT_KEY - so the HCF_ASSERT logic of hcf_get_info should -* not catch. -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int put_info( IFBP ifbp, LTVP ltvp ) + *.PURPOSE support routine to handle the "basic" task of hcf_put_info to pass RIDs to the NIC. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * ltvp address in NIC RAM where LVT-records are located + * + *.RETURNS + * HCF_SUCCESS + * >>put_frag + * >>cmd_wait + * + *.DESCRIPTION + * + * + *.DIAGRAM + *20: do not write RIDs to NICs which have incompatible Firmware + *24: If the RID does not exist, the L-field is set to zero. + * Note that some RIDs can not be read, e.g. the pseudo RIDs for direct Hermes commands and CFG_DEFAULT_KEYS + *28: If the RID is written successful, pass it to the NIC by means of an Access Write command + * + *.NOTICE + * The mechanism to HCF_ASSERT on invalid typ-codes in the LTV record is based on the following strategy: + * - some codes (e.g. CFG_REG_MB) are explicitly handled by the HCF which implies that these codes + * are valid. These codes are already consumed by hcf_put_info. + * - all other codes are passed to the Hermes. Before the put action is executed, hcf_get_info is called + * with an LTV record with a value of 1 in the L-field and the intended put action type in the Typ-code + * field. If the put action type is valid, it is also valid as a get action type code - except + * for CFG_DEFAULT_KEYS and CFG_ADD_TKIP_DEFAULT_KEY - so the HCF_ASSERT logic of hcf_get_info should + * not catch. + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int -put_info( IFBP ifbp, LTVP ltvp ) +put_info( IFBP ifbp, LTVP ltvp ) { -int rc = HCF_SUCCESS; + int rc = HCF_SUCCESS; HCFASSERT( ifbp->IFB_CardStat == 0, MERGE_2( ltvp->typ, ifbp->IFB_CardStat ) ); HCFASSERT( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX, ltvp->typ ); - if ( ifbp->IFB_CardStat == 0 && /* 20*/ - ( ( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX ) || - ( CFG_RID_ENG_MIN <= ltvp->typ /* && ltvp->typ <= 0xFFFF */ ) ) ) { + if ( ifbp->IFB_CardStat == 0 && /* 20*/ + ( ( CFG_RID_CFG_MIN <= ltvp->typ && ltvp->typ <= CFG_RID_CFG_MAX ) || + ( CFG_RID_ENG_MIN <= ltvp->typ /* && ltvp->typ <= 0xFFFF */ ) ) ) { #if HCF_ASSERT //FCC8, FCB0, FCB4, FCB6, FCB7, FCB8, FCC0, FCC4, FCBC, FCBD, FCBE, FCBF - { - hcf_16 t = ltvp->typ; - LTV_STRCT x = { 2, t, {0} }; /*24*/ - hcf_get_info( ifbp, (LTVP)&x ); - if ( x.len == 0 && - ( t != CFG_DEFAULT_KEYS && t != CFG_ADD_TKIP_DEFAULT_KEY && t != CFG_REMOVE_TKIP_DEFAULT_KEY && - t != CFG_ADD_TKIP_MAPPED_KEY && t != CFG_REMOVE_TKIP_MAPPED_KEY && - t != CFG_HANDOVER_ADDR && t != CFG_DISASSOCIATE_ADDR && - t != CFG_FCBC && t != CFG_FCBD && t != CFG_FCBE && t != CFG_FCBF && - t != CFG_DEAUTHENTICATE_ADDR - ) - ) { - HCFASSERT( DO_ASSERT, ltvp->typ ); + { + hcf_16 t = ltvp->typ; + LTV_STRCT x = { 2, t, {0} }; /*24*/ + hcf_get_info( ifbp, (LTVP)&x ); + if ( x.len == 0 && + ( t != CFG_DEFAULT_KEYS && t != CFG_ADD_TKIP_DEFAULT_KEY && t != CFG_REMOVE_TKIP_DEFAULT_KEY && + t != CFG_ADD_TKIP_MAPPED_KEY && t != CFG_REMOVE_TKIP_MAPPED_KEY && + t != CFG_HANDOVER_ADDR && t != CFG_DISASSOCIATE_ADDR && + t != CFG_FCBC && t != CFG_FCBD && t != CFG_FCBE && t != CFG_FCBF && + t != CFG_DEAUTHENTICATE_ADDR + ) + ) { + HCFASSERT( DO_ASSERT, ltvp->typ ); + } } - } #endif // HCF_ASSERT rc = setup_bap( ifbp, ltvp->typ, 0, IO_OUT ); put_frag( ifbp, (wci_bufp)ltvp, 2*ltvp->len + 2 BE_PAR(2) ); -/*28*/ if ( rc == HCF_SUCCESS ) { + /*28*/ if ( rc == HCF_SUCCESS ) { rc = cmd_exe( ifbp, HCMD_ACCESS + HCMD_ACCESS_WRITE, ltvp->typ ); } } @@ -4671,113 +4671,113 @@ int rc = HCF_SUCCESS; #if (HCF_DL_ONLY) == 0 /************************************************************************************************************ -* -*.SUBMODULE int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) -*.PURPOSE accumulates a ( series of) buffers into a single Info block into the MailBox. -* -*.ARGUMENTS -* ifbp address of the Interface Block -* ltvp address of structure specifying the "type" and the fragments of the information to be synthesized -* as an LTV into the MailBox -* -*.RETURNS -* -*.DESCRIPTION -* If the data does not fit (including no MailBox is available), the IFB_MBTally is incremented and an -* error status is returned. -* HCF_ASSERT does not catch. -* Calling put_info_mb when their is no MailBox available, is considered a design error in the MSF. -* -* Note that there is always at least 1 word of unused space in the mail box. -* As a consequence: -* - no problem in pointer arithmetic (MB_RP == MB_WP means unambiguously mail box is completely empty -* - There is always free space to write an L field with a value of zero after each MB_Info block. This -* allows for an easy scan mechanism in the "get MB_Info block" logic. -* -* -*.DIAGRAM -*1: Calculate L field of the MBIB, i.e. 1 for the T-field + the cumulative length of the fragments. -*2: The free space in the MailBox is calculated (2a: free part from Write Ptr to Read Ptr, 2b: free part -* turns out to wrap around) . If this space suffices to store the number of words reflected by len (T-field -* + Value-field) plus the additional MailBox Info L-field + a trailing 0 to act as the L-field of a trailing -* dummy or empty LTV record, then a MailBox Info block is build in the MailBox consisting of -* - the value len in the first word -* - type in the second word -* - a copy of the contents of the fragments in the second and higher word -* -*4: Since put_info_mb() can more or less directly be called from the MSF level, the I/F must be robust -* against out-of-range variables. As failsafe coding, the MB update is skipped by changing tlen to 0 if -* len == 0; This will indirectly cause an assert as result of the violation of the next if clause. -*6: Check whether the free space in MailBox suffices (this covers the complete absence of the MailBox). -* Note that len is unsigned, so even MSF I/F violation works out O.K. -* The '2' in the expression "len+2" is used because 1 word is needed for L itself and 1 word is needed -* for the zero-sentinel -*8: update MailBox Info length report to MSF with "oldest" MB Info Block size. Be careful here, if you get -* here before the MailBox is registered, you can't read from the buffer addressed by IFB_MBp (it is the -* Null buffer) so don't move this code till the end of this routine but keep it where there is garuanteed -* a buffer. -* -*.NOTICE -* boundary testing depends on the fact that IFB_MBSize is guaranteed to be zero if no MailBox is present, -* and to a lesser degree, that IFB_MBWp = IFB_MBRp = 0 -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) + *.PURPOSE accumulates a ( series of) buffers into a single Info block into the MailBox. + * + *.ARGUMENTS + * ifbp address of the Interface Block + * ltvp address of structure specifying the "type" and the fragments of the information to be synthesized + * as an LTV into the MailBox + * + *.RETURNS + * + *.DESCRIPTION + * If the data does not fit (including no MailBox is available), the IFB_MBTally is incremented and an + * error status is returned. + * HCF_ASSERT does not catch. + * Calling put_info_mb when their is no MailBox available, is considered a design error in the MSF. + * + * Note that there is always at least 1 word of unused space in the mail box. + * As a consequence: + * - no problem in pointer arithmetic (MB_RP == MB_WP means unambiguously mail box is completely empty + * - There is always free space to write an L field with a value of zero after each MB_Info block. This + * allows for an easy scan mechanism in the "get MB_Info block" logic. + * + * + *.DIAGRAM + *1: Calculate L field of the MBIB, i.e. 1 for the T-field + the cumulative length of the fragments. + *2: The free space in the MailBox is calculated (2a: free part from Write Ptr to Read Ptr, 2b: free part + * turns out to wrap around) . If this space suffices to store the number of words reflected by len (T-field + * + Value-field) plus the additional MailBox Info L-field + a trailing 0 to act as the L-field of a trailing + * dummy or empty LTV record, then a MailBox Info block is build in the MailBox consisting of + * - the value len in the first word + * - type in the second word + * - a copy of the contents of the fragments in the second and higher word + * + *4: Since put_info_mb() can more or less directly be called from the MSF level, the I/F must be robust + * against out-of-range variables. As failsafe coding, the MB update is skipped by changing tlen to 0 if + * len == 0; This will indirectly cause an assert as result of the violation of the next if clause. + *6: Check whether the free space in MailBox suffices (this covers the complete absence of the MailBox). + * Note that len is unsigned, so even MSF I/F violation works out O.K. + * The '2' in the expression "len+2" is used because 1 word is needed for L itself and 1 word is needed + * for the zero-sentinel + *8: update MailBox Info length report to MSF with "oldest" MB Info Block size. Be careful here, if you get + * here before the MailBox is registered, you can't read from the buffer addressed by IFB_MBp (it is the + * Null buffer) so don't move this code till the end of this routine but keep it where there is garuanteed + * a buffer. + * + *.NOTICE + * boundary testing depends on the fact that IFB_MBSize is guaranteed to be zero if no MailBox is present, + * and to a lesser degree, that IFB_MBWp = IFB_MBRp = 0 + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ #if (HCF_EXT) & HCF_EXT_MB HCF_STATIC int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) { -int rc = HCF_SUCCESS; -hcf_16 i; //work counter -hcf_16 *dp; //destination pointer (in MailBox) -wci_recordp sp; //source pointer -hcf_16 len; //total length to copy to MailBox -hcf_16 tlen; //free length/working length/offset in WMP frame + int rc = HCF_SUCCESS; + hcf_16 i; //work counter + hcf_16 *dp; //destination pointer (in MailBox) + wci_recordp sp; //source pointer + hcf_16 len; //total length to copy to MailBox + hcf_16 tlen; //free length/working length/offset in WMP frame if ( ifbp->IFB_MBp == NULL ) return rc; //;?not sufficient - HCFASSERT( ifbp->IFB_MBp != NULL, 0 ); //!!!be careful, don't get into an endless recursion + HCFASSERT( ifbp->IFB_MBp != NULL, 0 ); //!!!be careful, don't get into an endless recursion HCFASSERT( ifbp->IFB_MBSize, 0 ); - len = 1; /* 1 */ + len = 1; /* 1 */ for ( i = 0; i < ltvp->frag_cnt; i++ ) { len += ltvp->frag_buf[i].frag_len; } if ( ifbp->IFB_MBRp > ifbp->IFB_MBWp ) { - tlen = ifbp->IFB_MBRp - ifbp->IFB_MBWp; /* 2a*/ + tlen = ifbp->IFB_MBRp - ifbp->IFB_MBWp; /* 2a*/ } else { if ( ifbp->IFB_MBRp == ifbp->IFB_MBWp ) { - ifbp->IFB_MBRp = ifbp->IFB_MBWp = 0; // optimize Wrapping + ifbp->IFB_MBRp = ifbp->IFB_MBWp = 0; // optimize Wrapping } - tlen = ifbp->IFB_MBSize - ifbp->IFB_MBWp; /* 2b*/ - if ( ( tlen <= len + 2 ) && ( len + 2 < ifbp->IFB_MBRp ) ) { //if trailing space is too small but - // leading space is sufficiently large - ifbp->IFB_MBp[ifbp->IFB_MBWp] = 0xFFFF; //flag dummy LTV to fill the trailing space - ifbp->IFB_MBWp = 0; //reset WritePointer to begin of MailBox - tlen = ifbp->IFB_MBRp; //get new available space size + tlen = ifbp->IFB_MBSize - ifbp->IFB_MBWp; /* 2b*/ + if ( ( tlen <= len + 2 ) && ( len + 2 < ifbp->IFB_MBRp ) ) { //if trailing space is too small but + // leading space is sufficiently large + ifbp->IFB_MBp[ifbp->IFB_MBWp] = 0xFFFF; //flag dummy LTV to fill the trailing space + ifbp->IFB_MBWp = 0; //reset WritePointer to begin of MailBox + tlen = ifbp->IFB_MBRp; //get new available space size } } dp = &ifbp->IFB_MBp[ifbp->IFB_MBWp]; if ( len == 0 ) { tlen = 0; //;? what is this good for } - if ( len + 2 >= tlen ){ /* 6 */ + if ( len + 2 >= tlen ){ /* 6 */ //Do Not ASSERT, this is a normal condition IF_TALLY( ifbp->IFB_HCF_Tallies.NoBufMB++ ); rc = HCF_ERR_LEN; } else { - *dp++ = len; //write Len (= size of T+V in words to MB_Info block - *dp++ = ltvp->base_typ; //write Type to MB_Info block - ifbp->IFB_MBWp += len + 1; //update WritePointer of MailBox - for ( i = 0; i < ltvp->frag_cnt; i++ ) { // process each of the fragments + *dp++ = len; //write Len (= size of T+V in words to MB_Info block + *dp++ = ltvp->base_typ; //write Type to MB_Info block + ifbp->IFB_MBWp += len + 1; //update WritePointer of MailBox + for ( i = 0; i < ltvp->frag_cnt; i++ ) { // process each of the fragments sp = ltvp->frag_buf[i].frag_addr; len = ltvp->frag_buf[i].frag_len; while ( len-- ) *dp++ = *sp++; } - ifbp->IFB_MBp[ifbp->IFB_MBWp] = 0; //to assure get_info for CFG_MB_INFO stops - ifbp->IFB_MBInfoLen = ifbp->IFB_MBp[ifbp->IFB_MBRp]; /* 8 */ + ifbp->IFB_MBp[ifbp->IFB_MBWp] = 0; //to assure get_info for CFG_MB_INFO stops + ifbp->IFB_MBInfoLen = ifbp->IFB_MBp[ifbp->IFB_MBRp]; /* 8 */ } return rc; } // put_info_mb @@ -4787,94 +4787,94 @@ hcf_16 tlen; //free length/working length/offset in WMP frame /************************************************************************************************************ -* -*.SUBMODULE int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ) -*.PURPOSE set up data access to NIC RAM via BAP_1. -* -*.ARGUMENTS -* ifbp address of I/F Block -* fid FID/RID -* offset !!even!! offset in FID/RID -* type IO_IN, IO_OUT -* -*.RETURNS -* HCF_SUCCESS O.K -* HCF_ERR_NO_NIC card is removed -* HCF_ERR_DEFUNCT_TIME_OUT Fatal malfunction detected -* HCF_ERR_DEFUNCT_..... if and only if IFB_DefunctStat <> 0 -* -*.DESCRIPTION -* -* A non-zero return status indicates: -* - the NIC is considered nonoperational, e.g. due to a time-out of some Hermes activity in the past -* - BAP_1 could not properly be initialized -* - the card is removed before completion of the data transfer -* In all other cases, a zero is returned. -* BAP Initialization failure indicates an H/W error which is very likely to signal complete H/W failure. -* Once a BAP Initialization failure has occurred all subsequent interactions with the Hermes will return a -* "defunct" status till the Hermes is re-initialized by means of an hcf_connect. -* -* A BAP is a set of registers (Offset, Select and Data) offering read/write access to a particular FID or -* RID. This access is based on a auto-increment feature. -* There are two BAPs but these days the HCF uses only BAP_1 and leaves BAP_0 to the PCI Busmastering H/W. -* -* The BAP-mechanism is based on the Busy bit in the Offset register (see the Hermes definition). The waiting -* for Busy must occur between writing the Offset register and accessing the Data register. The -* implementation to wait for the Busy bit drop after each write to the Offset register, implies that the -* requirement that the Busy bit is low before the Select register is written, is automatically met. -* BAP-setup may be time consuming (e.g. 380 usec for large offsets occurs frequently). The wait for Busy bit -* drop is protected by a loop counter, which is initialized with IFB_TickIni, which is calibrated in init. -* -* The NIC I/F is optimized for word transfer and can only handle word transfer at a word boundary in NIC -* RAM. The intended solution for transfer of a single byte has multiple H/W flaws. There have been different -* S/W Workaround strategies. RID access is hcf_16 based by "nature", so no byte access problems. For Tx/Rx -* FID access, the byte logic became obsolete by absorbing it in the double word oriented nature of the MIC -* feature. -* -* -*.DIAGRAM -* -*2: the test on rc checks whether the HCF went into "defunct" mode ( e.g. BAP initialization or a call to -* cmd_wait did ever fail). -*4: the select register and offset register are set -* the offset register is monitored till a successful condition (no busy bit) is detected or till the -* (calibrated) protection counter expires -* If the counter expires, this is reflected in IFB_DefunctStat, so all subsequent calls to setup_bap fail -* immediately ( see 2) -*6: initialization of the carry as used by pet/get_frag -*8: HREG_OFFSET_ERR is ignored as error because: -* a: the Hermes is robust against it -* b: it is not known what causes it (probably a bug), hence no strategy can be specified which level is -* to handle this error in which way. In the past, it could be induced by the MSF level, e.g. by calling -* hcf_rcv_msg while there was no Rx-FID available. Since this is an MSF-error which is caught by ASSERT, -* there is no run-time action required by the HCF. -* Lumping the Offset error in with the Busy bit error, as has been done in the past turns out to be a -* disaster or a life saver, just depending on what the cause of the error is. Since no prediction can be -* done about the future, it is "felt" to be the best strategy to ignore this error. One day the code was -* accompanied by the following comment: -* // ignore HREG_OFFSET_ERR, someone, supposedly the MSF programmer ;) made a bug. Since we don't know -* // what is going on, we might as well go on - under management pressure - by ignoring it -* -*.ENDDOC END DOCUMENTATION -* -************************************************************************************************************/ + * + *.SUBMODULE int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ) + *.PURPOSE set up data access to NIC RAM via BAP_1. + * + *.ARGUMENTS + * ifbp address of I/F Block + * fid FID/RID + * offset !!even!! offset in FID/RID + * type IO_IN, IO_OUT + * + *.RETURNS + * HCF_SUCCESS O.K + * HCF_ERR_NO_NIC card is removed + * HCF_ERR_DEFUNCT_TIME_OUT Fatal malfunction detected + * HCF_ERR_DEFUNCT_..... if and only if IFB_DefunctStat <> 0 + * + *.DESCRIPTION + * + * A non-zero return status indicates: + * - the NIC is considered nonoperational, e.g. due to a time-out of some Hermes activity in the past + * - BAP_1 could not properly be initialized + * - the card is removed before completion of the data transfer + * In all other cases, a zero is returned. + * BAP Initialization failure indicates an H/W error which is very likely to signal complete H/W failure. + * Once a BAP Initialization failure has occurred all subsequent interactions with the Hermes will return a + * "defunct" status till the Hermes is re-initialized by means of an hcf_connect. + * + * A BAP is a set of registers (Offset, Select and Data) offering read/write access to a particular FID or + * RID. This access is based on a auto-increment feature. + * There are two BAPs but these days the HCF uses only BAP_1 and leaves BAP_0 to the PCI Busmastering H/W. + * + * The BAP-mechanism is based on the Busy bit in the Offset register (see the Hermes definition). The waiting + * for Busy must occur between writing the Offset register and accessing the Data register. The + * implementation to wait for the Busy bit drop after each write to the Offset register, implies that the + * requirement that the Busy bit is low before the Select register is written, is automatically met. + * BAP-setup may be time consuming (e.g. 380 usec for large offsets occurs frequently). The wait for Busy bit + * drop is protected by a loop counter, which is initialized with IFB_TickIni, which is calibrated in init. + * + * The NIC I/F is optimized for word transfer and can only handle word transfer at a word boundary in NIC + * RAM. The intended solution for transfer of a single byte has multiple H/W flaws. There have been different + * S/W Workaround strategies. RID access is hcf_16 based by "nature", so no byte access problems. For Tx/Rx + * FID access, the byte logic became obsolete by absorbing it in the double word oriented nature of the MIC + * feature. + * + * + *.DIAGRAM + * + *2: the test on rc checks whether the HCF went into "defunct" mode ( e.g. BAP initialization or a call to + * cmd_wait did ever fail). + *4: the select register and offset register are set + * the offset register is monitored till a successful condition (no busy bit) is detected or till the + * (calibrated) protection counter expires + * If the counter expires, this is reflected in IFB_DefunctStat, so all subsequent calls to setup_bap fail + * immediately ( see 2) + *6: initialization of the carry as used by pet/get_frag + *8: HREG_OFFSET_ERR is ignored as error because: + * a: the Hermes is robust against it + * b: it is not known what causes it (probably a bug), hence no strategy can be specified which level is + * to handle this error in which way. In the past, it could be induced by the MSF level, e.g. by calling + * hcf_rcv_msg while there was no Rx-FID available. Since this is an MSF-error which is caught by ASSERT, + * there is no run-time action required by the HCF. + * Lumping the Offset error in with the Busy bit error, as has been done in the past turns out to be a + * disaster or a life saver, just depending on what the cause of the error is. Since no prediction can be + * done about the future, it is "felt" to be the best strategy to ignore this error. One day the code was + * accompanied by the following comment: + * // ignore HREG_OFFSET_ERR, someone, supposedly the MSF programmer ;) made a bug. Since we don't know + * // what is going on, we might as well go on - under management pressure - by ignoring it + * + *.ENDDOC END DOCUMENTATION + * + ************************************************************************************************************/ HCF_STATIC int setup_bap( IFBP ifbp, hcf_16 fid, int offset, int type ) { -PROT_CNT_INI; -int rc; + PROT_CNT_INI; + int rc; HCFTRACE( ifbp, HCF_TRACE_STRIO ); rc = ifbp->IFB_DefunctStat; - if (rc == HCF_SUCCESS) { /*2*/ - OPW( HREG_SELECT_1, fid ); /*4*/ + if (rc == HCF_SUCCESS) { /*2*/ + OPW( HREG_SELECT_1, fid ); /*4*/ OPW( HREG_OFFSET_1, offset ); if ( type == IO_IN ) { ifbp->IFB_CarryIn = 0; } else ifbp->IFB_CarryOut = 0; HCF_WAIT_WHILE( IPW( HREG_OFFSET_1) & HCMD_BUSY ); - HCFASSERT( !( IPW( HREG_OFFSET_1) & HREG_OFFSET_ERR ), MERGE_2( fid, offset ) ); /*8*/ + HCFASSERT( !( IPW( HREG_OFFSET_1) & HREG_OFFSET_ERR ), MERGE_2( fid, offset ) ); /*8*/ if ( prot_cnt == 0 ) { HCFASSERT( DO_ASSERT, MERGE_2( fid, offset ) ); rc = ifbp->IFB_DefunctStat = HCF_ERR_DEFUNCT_TIME_OUT; From 49e9563d4e80c42205b87e7ddfbdaf6ea5e6fb06 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:49 +0100 Subject: [PATCH 1025/1519] staging: wlags49_h2: Remove HCF_DL_ONLY This is supposed to profile the code so that you can build a driver that will only update the firmware. We don't need to support this configuration. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 23 ++--------------------- drivers/staging/wlags49_h2/hcfcfg.h | 13 ------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 304258e2025..b38fea5f2a8 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -511,7 +511,6 @@ HCF_STATIC hcf_16* BASED xxxx[ ] = { ************************** T O P L E V E L H C F R O U T I N E S ************************************** ************************************************************************************************************/ -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.MODULE int hcf_action( IFBP ifbp, hcf_16 action ) @@ -834,7 +833,6 @@ hcf_action( IFBP ifbp, hcf_16 action ) HCFLOGEXIT( HCF_TRACE_ACTION ); return rc; } // hcf_action -#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -1854,7 +1852,6 @@ hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) #endif // HCF_DMA -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.MODULE hcf_8 hcf_encap( wci_bufp type ) @@ -1914,7 +1911,6 @@ hcf_encap( wci_bufp type ) return rc; } // hcf_encap #endif // HCF_ENCAP -#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -2330,7 +2326,6 @@ hcf_put_info( IFBP ifbp, LTVP ltvp ) } // hcf_put_info -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.MODULE int hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) @@ -2490,10 +2485,8 @@ hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) HCFLOGEXIT( HCF_TRACE_RCV_MSG ); return rc; } // hcf_rcv_msg -#endif // HCF_DL_ONLY -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.MODULE int hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) @@ -2804,10 +2797,8 @@ hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) HCFLOGEXIT( HCF_TRACE_SEND_MSG ); return rc; } // hcf_send_msg -#endif // HCF_DL_ONLY -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.MODULE int hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) @@ -3186,7 +3177,6 @@ hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) HCFLOGEXIT( HCF_TRACE_SERVICE_NIC ); return rc; } // hcf_service_nic -#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -3517,7 +3507,6 @@ calibrate( IFBP ifbp ) #endif // HCF_PROT_TIME -#if (HCF_DL_ONLY) == 0 #if (HCF_TYPE) & HCF_TYPE_WPA /************************************************************************************************************ * @@ -3565,7 +3554,6 @@ check_mic( IFBP ifbp ) return rc; } // check_mic #endif // HCF_TYPE_WPA -#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -3879,7 +3867,6 @@ fw_printf(IFBP ifbp, CFG_FW_PRINTF_STRCT FAR *ltvp) #endif // HCF_ASSERT_PRINTF -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.SUBMODULE hcf_16 get_fid( IFBP ifbp ) @@ -3943,7 +3930,6 @@ get_fid( IFBP ifbp ) } return fid; } // get_fid -#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -4232,7 +4218,7 @@ init( IFBP ifbp ) } } #endif // MSF_COMPONENT_ID -#if (HCF_DL_ONLY) == 0 /* 28 */ + if ( rc == HCF_SUCCESS && ifbp->IFB_FWIdentity.comp_id >= COMP_ID_FW_STA ) { PROT_CNT_INI; /************************************************************************************** @@ -4258,13 +4244,12 @@ init( IFBP ifbp ) } //#endif // ALLOC_15 } -#endif // HCF_DL_ONLY + HCFASSERT( rc == HCF_SUCCESS, rc ); HCFLOGEXIT( HCF_TRACE_INIT ); return rc; } // init -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.SUBMODULE void isr_info( IFBP ifbp ) @@ -4346,7 +4331,6 @@ isr_info( IFBP ifbp ) } return; } // isr_info -#endif // HCF_DL_ONLY // // @@ -4384,7 +4368,6 @@ isr_info( IFBP ifbp ) // // return; //} // isr_info -//#endif // HCF_DL_ONLY /************************************************************************************************************ @@ -4669,7 +4652,6 @@ put_info( IFBP ifbp, LTVP ltvp ) } // put_info -#if (HCF_DL_ONLY) == 0 /************************************************************************************************************ * *.SUBMODULE int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) @@ -4783,7 +4765,6 @@ put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) } // put_info_mb #endif // HCF_EXT_MB -#endif // HCF_DL_ONLY /************************************************************************************************************ diff --git a/drivers/staging/wlags49_h2/hcfcfg.h b/drivers/staging/wlags49_h2/hcfcfg.h index 32db3817853..764ad9a116c 100644 --- a/drivers/staging/wlags49_h2/hcfcfg.h +++ b/drivers/staging/wlags49_h2/hcfcfg.h @@ -479,10 +479,6 @@ typedef unsigned long hcf_32; #define HCF_BIG_ENDIAN 0 #endif // HCF_BIG_ENDIAN -#if ! defined HCF_DL_ONLY -#define HCF_DL_ONLY 0 -#endif // HCF_DL_ONLY - #if ! defined HCF_DMA #define HCF_DMA 0 #endif // HCF_DMA @@ -540,11 +536,6 @@ typedef unsigned long hcf_32; #define HCF_BIG_ENDIAN 1 //just for convenience of generating cfg_hcf_opt #endif // HCF_BIG_ENDIAN -#if HCF_DL_ONLY -#undef HCF_DL_ONLY -#define HCF_DL_ONLY 1 //just for convenience of generating cfg_hcf_opt -#endif // HCF_DL_ONLY - #if HCF_DMA #undef HCF_DMA #define HCF_DMA 1 //just for convenience of generating cfg_hcf_opt @@ -752,10 +743,6 @@ err: these macros are not used consistently; err: invalid value for HCF_BIG_ENDIAN; #endif // HCF_BIG_ENDIAN -#if HCF_DL_ONLY != 0 && HCF_DL_ONLY != 1 -err: invalid value for HCF_DL_ONLY; -#endif // HCF_DL_ONLY - #if HCF_DMA != 0 && HCF_DMA != 1 err: invalid value for HCF_DMA; #endif // HCF_DMA From 47996398c449092ad882119d49022282bb2c94d4 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:50 +0100 Subject: [PATCH 1026/1519] staging: wlags49_h2: Simplify HCF_ENCAP usage Encapsulation should always be enabled. Support is either via firmware or in the driver, so we need to keep the macro. The driver can stop exporting hcf_encap Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 11 +---------- drivers/staging/wlags49_h2/hcf.h | 3 --- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index b38fea5f2a8..e1d391a7380 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -133,9 +133,7 @@ static int fw_printf(IFBP ifbp, CFG_FW_PRINTF_STRCT FAR *ltvp); #endif // HCF_ASSERT_PRINTF HCF_STATIC int download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ); -#if (HCF_ENCAP) & HCF_ENC HCF_STATIC hcf_8 hcf_encap( wci_bufp type ); -#endif // HCF_ENCAP HCF_STATIC hcf_8 null_addr[4] = { 0, 0, 0, 0 }; #if ! defined IN_PORT_WORD //replace I/O Macros with logging facility extern FILE *log_file; @@ -244,11 +242,9 @@ void OUT_PORT_STRING_8_16( hcf_io prt, hcf_8 FAR * src, int n) { //also handl IFBP BASED assert_ifbp = NULL; //to make asserts easily work under MMD and DHF #endif // HCF_ASSERT -#if HCF_ENCAP /* SNAP header to be inserted in Ethernet-II frames */ HCF_STATIC hcf_8 BASED snap_header[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, //5 bytes signature + 0 }; //1 byte protocol identifier -#endif // HCF_ENCAP #if (HCF_TYPE) & HCF_TYPE_WPA HCF_STATIC hcf_8 BASED mic_pad[8] = { 0x5A, 0, 0, 0, 0, 0, 0, 0 }; //MIC padding of message @@ -1890,11 +1886,7 @@ hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) *.ENDDOC END DOCUMENTATION * ************************************************************************************************************/ -#if HCF_ENCAP //i.e HCF_ENC or HCF_ENC_SUP -#if ! ( (HCF_ENCAP) & HCF_ENC_SUP ) -HCF_STATIC -#endif // HCF_ENCAP -hcf_8 +HCF_STATIC hcf_8 hcf_encap( wci_bufp type ) { @@ -1910,7 +1902,6 @@ hcf_encap( wci_bufp type ) } return rc; } // hcf_encap -#endif // HCF_ENCAP /************************************************************************************************************ diff --git a/drivers/staging/wlags49_h2/hcf.h b/drivers/staging/wlags49_h2/hcf.h index 2cd573944cd..4fd62cda9cf 100644 --- a/drivers/staging/wlags49_h2/hcf.h +++ b/drivers/staging/wlags49_h2/hcf.h @@ -382,9 +382,6 @@ typedef IFB_STRCT* IFBP; EXTERN_C int hcf_action (IFBP ifbp, hcf_16 cmd ); EXTERN_C int hcf_connect (IFBP ifbp, hcf_io io_base ); -#if (HCF_ENCAP) & HCF_ENC_SUP -EXTERN_C hcf_8 hcf_encap (wci_bufp type ); -#endif // HCF_ENC_SUP EXTERN_C int hcf_get_info (IFBP ifbp, LTVP ltvp ); EXTERN_C int hcf_service_nic (IFBP ifbp, wci_bufp bufp, unsigned int len ); EXTERN_C int hcf_cntl (IFBP ifbp, hcf_16 cmd ); From 7a9541c3246a6c8b1129f1668fe5e83f1f8b7354 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:51 +0100 Subject: [PATCH 1027/1519] staging: wlags49_h2: Remove some unused defines HCF_INT_OFF, _TCHAR_DEFINED, HCF_LITTLE_ENDIAN, HCF_TALLIES_EXTRA HCF_ENTRY, HCF_EXIT, OUTPUTDEBUGMSG, ASSERTDEBUGMSG Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 6 +----- drivers/staging/wlags49_h2/hcf.h | 2 -- drivers/staging/wlags49_h2/hcfcfg.h | 30 ----------------------------- drivers/staging/wlags49_h2/hcfdef.h | 6 ++---- 4 files changed, 3 insertions(+), 41 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index e1d391a7380..0ec0229fc2b 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -437,7 +437,7 @@ static struct /*CFG_HCF_OPT_STRCT*/ { hcf_16 v17; // HCF_NIC_TAL_CNT hcf_16 v18; // HCF_HCF_TAL_CNT hcf_16 v19; // offset tallies - TCHAR val[sizeof(HCF_VERSION)]; + char val[sizeof(HCF_VERSION)]; } BASED cfg_hcf_opt = { sizeof(cfg_hcf_opt)/sizeof(hcf_16) -1, CFG_HCF_OPT, // (0x082C) @@ -473,10 +473,6 @@ static struct /*CFG_HCF_OPT_STRCT*/ { }; // cfg_hcf_opt #endif // MSF_COMPONENT_ID -#if defined HCF_TALLIES_EXTRA - replaced by HCF_EXT_TALLIES_FW ; -#endif // HCF_TALLIES_EXTRA - #if defined MSF_COMPONENT_ID || (HCF_EXT) & HCF_EXT_MB #if (HCF_EXT) & HCF_EXT_MB HCF_STATIC LTV_STRCT BASED cfg_null = { 1, CFG_NULL, {0} }; diff --git a/drivers/staging/wlags49_h2/hcf.h b/drivers/staging/wlags49_h2/hcf.h index 4fd62cda9cf..fc8c3553b57 100644 --- a/drivers/staging/wlags49_h2/hcf.h +++ b/drivers/staging/wlags49_h2/hcf.h @@ -335,9 +335,7 @@ typedef struct { CFG_FW_PRINTF_BUFFER_LOCATION_STRCT IFB_FwPfBuff; #endif // HCF_ASSERT_PRINTF #endif // HCF_ASSERT -#if ! defined HCF_INT_OFF hcf_16 volatile IFB_IntOffCnt; // 0xFFFF based HCF_ACT_INT_OFF nesting counter, DeepSleep flag -#endif // HCF_INT_OFF #if (HCF_TYPE) & HCF_TYPE_CCX hcf_16 IFB_CKIPStat; // CKIP Status flag #endif // HCF_TYPE_CCX diff --git a/drivers/staging/wlags49_h2/hcfcfg.h b/drivers/staging/wlags49_h2/hcfcfg.h index 764ad9a116c..825550e1b9e 100644 --- a/drivers/staging/wlags49_h2/hcfcfg.h +++ b/drivers/staging/wlags49_h2/hcfcfg.h @@ -447,16 +447,6 @@ typedef unsigned long hcf_32; #define IN_PORT_STRING_8_16(port, addr, len) IN_PORT_STRING_16(port, addr, len) #define OUT_PORT_STRING_8_16(port, addr, len) OUT_PORT_STRING_16(port, addr, len) - -#ifndef OUTPUTDEBUGMSG -#define OUTPUTDEBUGMSG(dprintf_exp) -#endif - - -#ifndef ASSERTDEBUGMSG -#define ASSERTDEBUGMSG(cond, dprintf_exp) -#endif - #ifndef CFG_SCAN_CHANNELS_2GHZ #define CFG_SCAN_CHANNELS_2GHZ 0xFCC2 #endif /* CFG_SCAN_CHANNELS_2GHZ */ @@ -487,14 +477,6 @@ typedef unsigned long hcf_32; #define HCF_ENCAP HCF_ENC #endif // HCF_ENCAP -#if ! defined HCF_ENTRY -#define HCF_ENTRY( ifbp ) -#endif // HCF_ENTRY - -#if ! defined HCF_EXIT -#define HCF_EXIT( ifbp ) -#endif // HCF_EXIT - #if ! defined HCF_EXT #define HCF_EXT 0 #endif // HCF_EXT @@ -711,21 +693,9 @@ err: primary variants 1 and 2 correspond with H-I only; #define TEXT(x) x #endif // TEXT -#if !defined _TCHAR_DEFINED -#define TCHAR char -#endif // _TCHAR_DEFINED - /************************************************************************************************************/ /*********************** C O N F L I C T D E T E C T I O N & R E S O L U T I O N ************************/ /************************************************************************************************************/ -#if defined HCF_LITTLE_ENDIAN -err: HCF_LITTLE_ENDIAN is obsolete; -#endif // HCF_LITTLE_ENDIAN - -#if defined HCF_INT_OFF -err: HCF_INT_OFF is obsolete; -#endif //HCF_INT_OFF - #if HCF_ALIGN != 1 && HCF_ALIGN != 2 && HCF_ALIGN != 4 && HCF_ALIGN != 8 err: invalid value for HCF_ALIGN; #endif // HCF_ALIGN diff --git a/drivers/staging/wlags49_h2/hcfdef.h b/drivers/staging/wlags49_h2/hcfdef.h index 8e08d7b16b9..fe003ed8d66 100644 --- a/drivers/staging/wlags49_h2/hcfdef.h +++ b/drivers/staging/wlags49_h2/hcfdef.h @@ -686,7 +686,6 @@ err: someone redefined these macros while the implemenation assumes they are equ #define HCFLOGENTRY( where, what ) do { \ if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ - HCF_ENTRY( ifbp ); \ HCFASSERT( (ifbp->IFB_AssertTrace & 1<<((where)&0xF)) == 0, ifbp->IFB_AssertTrace ); \ ifbp->IFB_AssertTrace |= 1<<((where)&0xF); \ } \ @@ -696,7 +695,6 @@ err: someone redefined these macros while the implemenation assumes they are equ #define HCFLOGEXIT( where ) do { \ if ( (ifbp->IFB_AssertWhere = where) <= 15 ) { \ - HCF_EXIT( ifbp ); \ ifbp->IFB_AssertTrace &= ~(1<<((where)&0xF)); \ } \ HCFTRACE(ifbp, (where)|HCF_TRACE_EXIT ); \ @@ -705,8 +703,8 @@ err: someone redefined these macros while the implemenation assumes they are equ #else // HCF_ASSERT #define HCFASSERT( x, q ) do { } while(0) #define MMDASSERT( x, q ) -#define HCFLOGENTRY( where, what ) do {HCF_ENTRY( ifbp );} while (0) -#define HCFLOGEXIT( where ) do {HCF_EXIT( ifbp );} while(0) +#define HCFLOGENTRY( where, what ) do { } while(0) +#define HCFLOGEXIT( where ) do { } while(0) #endif // HCF_ASSERT #if HCF_INT_ON From 4b7ad42963dbc921c8e10f5b9527ecdaadda0602 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:52 +0100 Subject: [PATCH 1028/1519] staging: wlags49_h2: Remove references to SSN SSN seems to be an old abbreviation for WPA. Remove all references. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 10 +++++----- drivers/staging/wlags49_h2/hcfdef.h | 4 ---- drivers/staging/wlags49_h2/mdd.h | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 0ec0229fc2b..c46ad304961 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -2329,7 +2329,7 @@ hcf_put_info( IFBP ifbp, LTVP ltvp ) * of frame). * *.RETURNS - * HCF_SUCCESS No SSN error ( or HCF_ERR_MIC already reported by hcf_service_nic) + * HCF_SUCCESS No WPA error ( or HCF_ERR_MIC already reported by hcf_service_nic) * HCF_ERR_MIC message contains an erroneous MIC ( HCF_SUCCESS is reported if HCF_ERR_MIC is already * reported by hcf_service_nic) * HCF_ERR_NO_NIC NIC removed during data retrieval @@ -2592,10 +2592,10 @@ hcf_rcv_msg( IFBP ifbp, DESC_STRCT *descp, unsigned int offset ) *7: The ControlField of the TxFS is written. Since put_frag can only return the fatal Defunct or "No NIC", the * return status can be ignored because when it fails, cmd_wait will fail as well. (see also the note on the * need for a return code below). - * Note that HFS_TX_CNTL has different values for H-I, H-I/SSN and H-II and HFS_ADDR_DEST has different - * values for H-I (regardless of SSN) and H-II. + * Note that HFS_TX_CNTL has different values for H-I, H-I/WPA and H-II and HFS_ADDR_DEST has different + * values for H-I (regardless of WPA) and H-II. * By writing 17, 1 or 2 ( implying 16, 0 or 1 garbage word after HFS_TX_CNTL) the BAP just gets to - * HFS_ADDR_DEST for H-I, H-I/SSN and H-II respectively. + * HFS_ADDR_DEST for H-I, H-I/WPA and H-II respectively. *10: if neither encapsulation nor MIC calculation is needed, splitting the first fragment in two does not * really help but it makes the flow easier to follow to do not optimize on this difference * @@ -2985,7 +2985,7 @@ or * compensated for the SNAP header length. * The 22 bytes needed for decapsulation are (more than) sufficient for the exceptional handling of the * MIC algorithm of the L-field (replacing the 2 byte L-field with 4 0x00 bytes). -*30: The 12 in the no-SSN branch corresponds with the get_frag, the 2 with the IPW of the SSN branch +*30: The 12 in the no-WPA branch corresponds with the get_frag, the 2 with the IPW of the WPA branch *32: If Hermes reported MIC-presence, than the MIC engine is initialized with the non-dummy MIC calculation * routine address and appropriate key. *34: The 8 bytes after the DA, SA, L are read and it is checked whether decapsulation is needed i.e.: diff --git a/drivers/staging/wlags49_h2/hcfdef.h b/drivers/staging/wlags49_h2/hcfdef.h index fe003ed8d66..8fb870dcab7 100644 --- a/drivers/staging/wlags49_h2/hcfdef.h +++ b/drivers/staging/wlags49_h2/hcfdef.h @@ -592,15 +592,11 @@ err: ; #if (HCF_TYPE) & HCF_TYPE_WPA #define CALC_RX_MIC( p, len ) calc_mic_rx_frag( ifbp, p, len ) #define CALC_TX_MIC( p, len ) calc_mic_tx_frag( ifbp, p, len ) -#define IF_SSN(x) x -#define IF_NOT_SSN(x) #else #define CALC_RX_MIC( p, len ) #define CALC_TX_MIC( p, len ) #define MIC_RX_RTN( mic, dw ) #define MIC_TX_RTN( mic, dw ) -#define IF_SSN(x) -#define IF_NOT_SSN(x) x #endif // HCF_TYPE_WPA #if HCF_TALLIES & HCF_TALLIES_HCF //HCF tally support diff --git a/drivers/staging/wlags49_h2/mdd.h b/drivers/staging/wlags49_h2/mdd.h index 5aa9eb846de..acdeacd699d 100644 --- a/drivers/staging/wlags49_h2/mdd.h +++ b/drivers/staging/wlags49_h2/mdd.h @@ -444,7 +444,7 @@ XX1( CFG_DEFAULT_KEYS, KEY_STRCT, key[4] ) /*defines set of encryption keys tx_mic_key[4], rx_mic_key[4] ) /* */ X6( CFG_ADD_TKIP_MAPPED_KEY, bssid[3], tkip_key[8], \ tsc[4], rsc[4], tx_mic_key[4], rx_mic_key[4] ) /* */ - X1( CFG_SET_SSN_AUTHENTICATION_SUITE, \ + X1( CFG_SET_WPA_AUTHENTICATION_SUITE, \ ssn_authentication_suite ) /* */ X1( CFG_REMOVE_TKIP_DEFAULT_KEY,tkip_key_id ) /* */ X1( CFG_TICK_TIME, tick_time ) /*Auxiliary Timer tick interval */ @@ -525,7 +525,7 @@ X2( CFG_WOL_PATTERNS, nPatterns, buffer[WOL_BUF_SIZE] ) /*[STA] WakeOnLan pat X1( CFG_OWN_MAC_ADDR, mac_addr[3] ) /*[AP] Unique local node MAC Address */ X3( CFG_PCF_INFO, medium_occupancy_limit, \ cfp_period, cfp_max_duration ) /*[AP] Point Coordination Function capability info */ - X1( CFG_CUR_SSN_INFO_ELEMENT, ssn_info_element[1] ) /* */ + X1( CFG_CUR_WPA_INFO_ELEMENT, ssn_info_element[1] ) /* */ X4( CFG_CUR_TKIP_IV_INFO, \ tkip_seq_cnt0[4], tkip_seq_cnt1[4], \ tkip_seq_cnt2[4], tkip_seq_cnt3[4] ) /* */ @@ -802,7 +802,7 @@ XX1( CFG_SCAN, SCAN_RS_STRCT, scan_result[32] ) /*Scan results * #define CFG_PCF_INFO 0xFD87 //[AP] Point Coordination Function capability info //*RESERVED* #define CFG_HIGHEST_BASIC_RATE 0xFD88 // #define CFG_CUR_COUNTRY_INFO 0xFD89 // -#define CFG_CUR_SSN_INFO_ELEMENT 0xFD8A // +#define CFG_CUR_WPA_INFO_ELEMENT 0xFD8A // #define CFG_CUR_TKIP_IV_INFO 0xFD8B // #define CFG_CUR_ASSOC_REQ_INFO 0xFD8C // #define CFG_CUR_ASSOC_RESP_INFO 0xFD8D // From 85d5cb15b3a75ca029be34af76fda7d0e081af44 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:53 +0100 Subject: [PATCH 1029/1519] staging: wlags49_h2: Remove MUL/DIV_BY_2 Only used in one place, so just inline and get rid of the macro. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 2 +- drivers/staging/wlags49_h2/hcfdef.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index c46ad304961..0453b908b2f 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -3766,7 +3766,7 @@ download( IFBP ifbp, CFG_PROG_STRCT FAR *ltvp ) //Hermes-II #if 0 //;? as long as the next if contains a hard coded 0, might as well leave it out even more obvious if ( 0 /*len is definitely not want we want;?*/ && ltvp->mode == CFG_PROG_SEEPROM_READBACK ) { OPW( HREG_PARAM_1, (hcf_16)(ltvp->nic_addr >> 16) ); - OPW( HREG_PARAM_2, MUL_BY_2(ltvp->len - 4)); + OPW( HREG_PARAM_2, (hcf_16)((ltvp->len - 4) << 1) ); //. . perform Hermes prog cmd with appropriate mode bits rc = cmd_exe( ifbp, HCMD_PROGRAM | ltvp->mode, (hcf_16)ltvp->nic_addr ); //. . set up NIC RAM addressability according Resp0-1 diff --git a/drivers/staging/wlags49_h2/hcfdef.h b/drivers/staging/wlags49_h2/hcfdef.h index 8fb870dcab7..a62b53a2289 100644 --- a/drivers/staging/wlags49_h2/hcfdef.h +++ b/drivers/staging/wlags49_h2/hcfdef.h @@ -568,9 +568,6 @@ err: ; #define LOF(x) (sizeof(x)/sizeof(hcf_16)-1) -#define MUL_BY_2( x ) ( (x) << 1 ) //used to multiply by 2 -#define DIV_BY_2( x ) ( (x) >> 1 ) //used to divide by 2 - //resolve problems on for some 16 bits compilers to create 32 bit values #define MERGE_2( hw, lw ) ( ( ((hcf_32)(hw)) << 16 ) | ((hcf_16)(lw)) ) From 89c5be50e13f41e13d22f3462798ac729631f2c4 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:54 +0100 Subject: [PATCH 1030/1519] staging: wlags49_h2: Remove CKIP support from hcf CKIP is a Cisco proprietary alternative to TKIP. Support removed to simplify code - the defines to interact with the firmware are left in place. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 194 ++++++++++--------------------- drivers/staging/wlags49_h2/hcf.h | 3 - 2 files changed, 60 insertions(+), 137 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 0453b908b2f..5935b42c680 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -512,8 +512,6 @@ HCF_STATIC hcf_16* BASED xxxx[ ] = { *.ARGUMENTS * ifbp address of the Interface Block * action number identifying the type of change - * - HCF_ACT_CCX_OFF disable CKIP - * - HCF_ACT_CCX_ON enable CKIP * - HCF_ACT_INT_FORCE_ON enable interrupt generation by WaveLAN NIC * - HCF_ACT_INT_OFF disable interrupt generation by WaveLAN NIC * - HCF_ACT_INT_ON compensate 1 HCF_ACT_INT_OFF, enable interrupt generation if balance reached @@ -537,7 +535,6 @@ HCF_STATIC hcf_16* BASED xxxx[ ] = { * *.DESCRIPTION * hcf_action supports the following mode changing action-code pairs that are antonyms - * - HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON * - HCF_ACT_INT_[FORCE_]ON / HCF_ACT_INT_OFF * * Additionally hcf_action can start the following actions in the NIC: @@ -573,11 +570,6 @@ HCF_STATIC hcf_16* BASED xxxx[ ] = { *! The INT_OFF/INT_ON housekeeping is initialized at 0x0000 by hcf_connect, causing the interrupt generation * mechanism to be disabled at first. This suits MSF implementation based on a polling strategy. * - * o HCF_ACT_CCX_OFF / HCF_ACT_CCX_ON - *!! This can use some more explanation;? - * Disables and Enables support in the HCF runtime code for the CCX feature. Each time one of these action - * codes is used, the effects of the preceding use cease. - * * o HCF_ACT_SLEEP: Initiates the Disconnected DeepSleep process * This command is only available if the HCF_DDS compile time option is set. It triggers the F/W to start the * sleep handshaking. Regardless whether the Host initiates a Disconnected DeepSleep (DDS) or the F/W initiates @@ -791,13 +783,6 @@ hcf_action( IFBP ifbp, hcf_16 action ) // break; #endif // HCF_DDS -#if (HCF_TYPE) & HCF_TYPE_CCX - case HCF_ACT_CCX_ON: // enable CKIP - case HCF_ACT_CCX_OFF: // disable CKIP - ifbp->IFB_CKIPStat = action; - break; -#endif // HCF_TYPE_CCX - case HCF_ACT_RX_ACK: //Receiver ACK /*6*/ if ( ifbp->IFB_RxFID ) { DAWA_ACK( HREG_EV_RX ); @@ -1501,34 +1486,30 @@ hcf_dma_rx_get (IFBP ifbp) DESC_STRCT *descp; // pointer to start of FrameList descp = get_frame_lst( ifbp, DMA_RX ); - if ( descp && descp->buf_addr ) //!be aware of the missing curly bracket + if ( descp && descp->buf_addr ) { //skip decapsulation at confined descriptor #if (HCF_ENCAP) == HCF_ENC -#if (HCF_TYPE) & HCF_TYPE_CCX - if ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) -#endif // HCF_TYPE_CCX - { - int i; - DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame - HCFASSERT(p, 0); - // The 2nd descriptor contains (maybe) a SNAP header plus part or whole of the payload. - //determine decapsulation sub-flag in RxFS - i = *(wci_recordp)&descp->buf_addr[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); - if ( i == HFS_STAT_TUNNEL || - ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&p->buf_addr[HCF_DASA_SIZE] ) != ENC_TUNNEL )) { - // The 2nd descriptor contains a SNAP header plus part or whole of the payload. - HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ); - // perform decapsulation - HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE); - // move SA[2:5] in the second buffer to replace part of the SNAP header - for ( i=3; i >= 0; i--) p->buf_addr[i+8] = p->buf_addr[i]; - // copy DA[0:5], SA[0:1] from first buffer to second buffer - for ( i=0; i<8; i++) p->buf_addr[i] = descp->buf_addr[HFS_ADDR_DEST + i]; - // make first buffer shorter in count - descp->BUF_CNT = HFS_ADDR_DEST; - } + int i; + DESC_STRCT *p = descp->next_desc_addr; //pointer to 2nd descriptor of frame + HCFASSERT(p, 0); + // The 2nd descriptor contains (maybe) a SNAP header plus part or whole of the payload. + //determine decapsulation sub-flag in RxFS + i = *(wci_recordp)&descp->buf_addr[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); + if ( i == HFS_STAT_TUNNEL || + ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&p->buf_addr[HCF_DASA_SIZE] ) != ENC_TUNNEL )) { + // The 2nd descriptor contains a SNAP header plus part or whole of the payload. + HCFASSERT( p->BUF_CNT == (p->buf_addr[5] + (p->buf_addr[4]<<8) + 2*6 + 2 - 8), p->BUF_CNT ); + // perform decapsulation + HCFASSERT(p->BUF_SIZE >=8, p->BUF_SIZE); + // move SA[2:5] in the second buffer to replace part of the SNAP header + for ( i=3; i >= 0; i--) p->buf_addr[i+8] = p->buf_addr[i]; + // copy DA[0:5], SA[0:1] from first buffer to second buffer + for ( i=0; i<8; i++) p->buf_addr[i] = descp->buf_addr[HFS_ADDR_DEST + i]; + // make first buffer shorter in count + descp->BUF_CNT = HFS_ADDR_DEST; } + } #endif // HCF_ENC if ( descp == NULL ) ifbp->IFB_DmaPackets &= (hcf_16)~HREG_EV_RDMAD; //;?could be integrated into get_frame_lst HCFLOGEXIT( HCF_TRACE_DMA_RX_GET ); @@ -1634,18 +1615,16 @@ hcf_dma_tx_get( IFBP ifbp ) DESC_STRCT *descp; // pointer to start of FrameList descp = get_frame_lst( ifbp, DMA_TX ); - if ( descp && descp->buf_addr ) //!be aware of the missing curly bracket + if ( descp && descp->buf_addr ) { //skip decapsulation at confined descriptor #if (HCF_ENCAP) == HCF_ENC - if ( ( descp->BUF_CNT == HFS_TYPE ) -#if (HCF_TYPE) & HCF_TYPE_CCX - || ( descp->BUF_CNT == HFS_DAT ) -#endif // HCF_TYPE_CCX - ) { // perform decapsulation if needed + if ( ( descp->BUF_CNT == HFS_TYPE )) { + // perform decapsulation if needed descp->next_desc_addr->buf_phys_addr -= HCF_DASA_SIZE; descp->next_desc_addr->BUF_CNT += HCF_DASA_SIZE; } #endif // HCF_ENC + } if ( descp == NULL ) { //;?could be integrated into get_frame_lst ifbp->IFB_DmaPackets &= (hcf_16)~HREG_EV_TDMAD; } @@ -1792,49 +1771,20 @@ hcf_dma_tx_put( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) HCFASSERT( descp->BUF_SIZE >= HCF_DMA_TX_BUF1_SIZE, descp->BUF_SIZE ); //minimal storage for encapsulation HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); //at least DA, SA and 'type' in 2nd buffer -#if (HCF_TYPE) & HCF_TYPE_CCX - /* if we are doing PPK +/- CMIC, or we are sending a DDP frame */ - if ( ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_ON ) || - ( ( p->BUF_CNT >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && - ( p->buf_addr[12] == 0xAA ) && ( p->buf_addr[13] == 0xAA ) && - ( p->buf_addr[14] == 0x03 ) && ( p->buf_addr[15] == 0x00 ) && - ( p->buf_addr[16] == 0x40 ) && ( p->buf_addr[17] == 0x96 ) && - ( p->buf_addr[18] == 0x00 ) && ( p->buf_addr[19] == 0x00 ))) - { - /* copy the DA/SA to the first buffer */ - for ( i = 0; i < HCF_DASA_SIZE; i++ ) { - descp->buf_addr[i + HFS_ADDR_DEST] = p->buf_addr[i]; + descp->buf_addr[HFS_TYPE-1] = hcf_encap(&descp->next_desc_addr->buf_addr[HCF_DASA_SIZE]); /*4*/ + if ( descp->buf_addr[HFS_TYPE-1] != ENC_NONE ) { + for ( i=0; i < HCF_DASA_SIZE; i++ ) { /*6*/ + descp->buf_addr[i + HFS_ADDR_DEST] = descp->next_desc_addr->buf_addr[i]; } - /* calculate the length of the second fragment only */ - i = 0; - do { i += p->BUF_CNT; } while( p = p->next_desc_addr ); - i -= HCF_DASA_SIZE ; - /* convert the length field to big endian, using the endian friendly macros */ - i = CNV_SHORT_TO_BIG(i); //!! this converts ONLY on LE platforms, how does that relate to the non-CCX code - *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = (hcf_16)i; - descp->BUF_CNT = HFS_DAT; - // modify 2nd descriptor to skip the 'Da/Sa' fields - descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; - descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; - } - else -#endif // HCF_TYPE_CCX - { - descp->buf_addr[HFS_TYPE-1] = hcf_encap(&descp->next_desc_addr->buf_addr[HCF_DASA_SIZE]); /*4*/ - if ( descp->buf_addr[HFS_TYPE-1] != ENC_NONE ) { - for ( i=0; i < HCF_DASA_SIZE; i++ ) { /*6*/ - descp->buf_addr[i + HFS_ADDR_DEST] = descp->next_desc_addr->buf_addr[i]; - } - i = sizeof(snap_header) + 2 - ( 2*6 + 2 ); - do { i += p->BUF_CNT; } while ( ( p = p->next_desc_addr ) != NULL ); - *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = CNV_END_SHORT(i); //!! this converts on ALL platforms, how does that relate to the CCX code - for ( i=0; i < sizeof(snap_header) - 1; i++) { - descp->buf_addr[HFS_TYPE - sizeof(snap_header) + i] = snap_header[i]; - } - descp->BUF_CNT = HFS_TYPE; /*8*/ - descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; - descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; + i = sizeof(snap_header) + 2 - ( 2*6 + 2 ); + do { i += p->BUF_CNT; } while ( ( p = p->next_desc_addr ) != NULL ); + *(hcf_16*)(&descp->buf_addr[HFS_LEN]) = CNV_END_SHORT(i); //!! this converts on ALL platforms, how does that relate to the CCX code + for ( i=0; i < sizeof(snap_header) - 1; i++) { + descp->buf_addr[HFS_TYPE - sizeof(snap_header) + i] = snap_header[i]; } + descp->BUF_CNT = HFS_TYPE; /*8*/ + descp->next_desc_addr->buf_phys_addr += HCF_DASA_SIZE; + descp->next_desc_addr->BUF_CNT -= HCF_DASA_SIZE; } #endif // HCF_ENC } @@ -2708,54 +2658,36 @@ hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) #endif // HCF_TYPE_TX_DELAY OPW( HREG_DATA_1, tx_cntl ) ; OPW( HREG_DATA_1, 0 ); -#if ! ( (HCF_TYPE) & HCF_TYPE_CCX ) + HCFASSERT( p->BUF_CNT >= 14, p->BUF_CNT ); /* assume DestAddr/SrcAddr/Len/Type ALWAYS contained in 1st fragment * otherwise life gets too cumbersome for MIC and Encapsulation !!!!!!!! if ( p->BUF_CNT >= 14 ) { alternatively: add a safety escape !!!!!!!!!!!! } */ -#endif // HCF_TYPE_CCX + CALC_TX_MIC( NULL, -1 ); //initialize MIC /*10*/ put_frag( ifbp, p->buf_addr, HCF_DASA_SIZE BE_PAR(0) ); //write DA, SA with MIC calculation CALC_TX_MIC( p->buf_addr, HCF_DASA_SIZE ); //MIC over DA, SA CALC_TX_MIC( null_addr, 4 ); //MIC over (virtual) priority field -#if (HCF_TYPE) & HCF_TYPE_CCX - //!!be careful do not use positive test on HCF_ACT_CCX_OFF, because IFB_CKIPStat is initially 0 - if(( ifbp->IFB_CKIPStat == HCF_ACT_CCX_ON ) || - ((GET_BUF_CNT(p) >= 20 ) && ( ifbp->IFB_CKIPStat == HCF_ACT_CCX_OFF ) && - (p->buf_addr[12] == 0xAA) && (p->buf_addr[13] == 0xAA) && - (p->buf_addr[14] == 0x03) && (p->buf_addr[15] == 0x00) && - (p->buf_addr[16] == 0x40) && (p->buf_addr[17] == 0x96) && - (p->buf_addr[18] == 0x00) && (p->buf_addr[19] == 0x00))) - { - i = HCF_DASA_SIZE; - OPW( HREG_DATA_1, CNV_SHORT_TO_BIG( len - i )); - - /* need to send out the remainder of the fragment */ - put_frag( ifbp, &p->buf_addr[i], GET_BUF_CNT(p) - i BE_PAR(0) ); - } - else -#endif // HCF_TYPE_CCX - { //if encapsulation needed #if (HCF_ENCAP) == HCF_ENC //write length (with SNAP-header,Type, without //DA,SA,Length ) no MIC calc. - if ( ( snap_header[sizeof(snap_header)-1] = hcf_encap( &p->buf_addr[HCF_DASA_SIZE] ) ) != ENC_NONE ) { - OPW( HREG_DATA_1, CNV_END_SHORT( len + (sizeof(snap_header) + 2) - ( 2*6 + 2 ) ) ); + if ( ( snap_header[sizeof(snap_header)-1] = hcf_encap( &p->buf_addr[HCF_DASA_SIZE] ) ) != ENC_NONE ) { + OPW( HREG_DATA_1, CNV_END_SHORT( len + (sizeof(snap_header) + 2) - ( 2*6 + 2 ) ) ); //write splice with MIC calculation - put_frag( ifbp, snap_header, sizeof(snap_header) BE_PAR(0) ); - CALC_TX_MIC( snap_header, sizeof(snap_header) ); //MIC over 6 byte SNAP - i = HCF_DASA_SIZE; - } else + put_frag( ifbp, snap_header, sizeof(snap_header) BE_PAR(0) ); + CALC_TX_MIC( snap_header, sizeof(snap_header) ); //MIC over 6 byte SNAP + i = HCF_DASA_SIZE; + } else #endif // HCF_ENC - { - OPW( HREG_DATA_1, *(wci_recordp)&p->buf_addr[HCF_DASA_SIZE] ); - i = 14; - } - //complete 1st fragment starting with Type with MIC calculation - put_frag( ifbp, &p->buf_addr[i], p->BUF_CNT - i BE_PAR(0) ); - CALC_TX_MIC( &p->buf_addr[i], p->BUF_CNT - i ); + { + OPW( HREG_DATA_1, *(wci_recordp)&p->buf_addr[HCF_DASA_SIZE] ); + i = 14; } + //complete 1st fragment starting with Type with MIC calculation + put_frag( ifbp, &p->buf_addr[i], p->BUF_CNT - i BE_PAR(0) ); + CALC_TX_MIC( &p->buf_addr[i], p->BUF_CNT - i ); + //do the remaining fragments with MIC calculation while ( ( p = p->next_desc_addr ) != NULL ) { /* obnoxious c:/hcf/hcf.c(1480) : warning C4769: conversion of near pointer to long integer, @@ -3116,25 +3048,19 @@ hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len ) CALC_RX_MIC( null_addr, 4 ); //. MIC over (virtual) priority field CALC_RX_MIC( buf_addr+14, 8 ); //. skip Len, MIC over SNAP,Type or 8 data bytes) buf_addr += 22; -#if (HCF_TYPE) & HCF_TYPE_CCX -//!!be careful do not use positive test on HCF_ACT_CCX_OFF, because IFB_CKIPStat is initially 0 - if( ifbp->IFB_CKIPStat != HCF_ACT_CCX_ON ) -#endif // HCF_TYPE_CCX - { #if (HCF_ENCAP) == HCF_ENC - HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ); - /*34*/ i = *(wci_recordp)&bufp[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); - if ( i == HFS_STAT_TUNNEL || - ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&bufp[HFS_TYPE] ) != ENC_TUNNEL ) ) { + HCFASSERT( len >= HFS_DAT + 2 + sizeof(snap_header), len ); + /*34*/ i = *(wci_recordp)&bufp[HFS_STAT] & ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR ); + if ( i == HFS_STAT_TUNNEL || + ( i == HFS_STAT_1042 && hcf_encap( (wci_bufp)&bufp[HFS_TYPE] ) != ENC_TUNNEL ) ) { //. copy E-II Type to 802.3 LEN field - /*36*/ bufp[HFS_LEN ] = bufp[HFS_TYPE ]; - bufp[HFS_LEN+1] = bufp[HFS_TYPE+1]; + /*36*/ bufp[HFS_LEN ] = bufp[HFS_TYPE ]; + bufp[HFS_LEN+1] = bufp[HFS_TYPE+1]; //. discard Snap by overwriting with data - ifbp->IFB_RxLen -= (HFS_TYPE - HFS_LEN); - buf_addr -= ( HFS_TYPE - HFS_LEN ); // this happens to bring us at a DW boundary of 36 - } -#endif // HCF_ENC + ifbp->IFB_RxLen -= (HFS_TYPE - HFS_LEN); + buf_addr -= ( HFS_TYPE - HFS_LEN ); // this happens to bring us at a DW boundary of 36 } +#endif // HCF_ENC } /*40*/ ifbp->IFB_lal = min( (hcf_16)(len - HFS_ADDR_DEST), ifbp->IFB_RxLen ); i = ifbp->IFB_lal - ( buf_addr - ( bufp + HFS_ADDR_DEST ) ); diff --git a/drivers/staging/wlags49_h2/hcf.h b/drivers/staging/wlags49_h2/hcf.h index fc8c3553b57..cf55e8ea1d3 100644 --- a/drivers/staging/wlags49_h2/hcf.h +++ b/drivers/staging/wlags49_h2/hcf.h @@ -336,9 +336,6 @@ typedef struct { #endif // HCF_ASSERT_PRINTF #endif // HCF_ASSERT hcf_16 volatile IFB_IntOffCnt; // 0xFFFF based HCF_ACT_INT_OFF nesting counter, DeepSleep flag -#if (HCF_TYPE) & HCF_TYPE_CCX - hcf_16 IFB_CKIPStat; // CKIP Status flag -#endif // HCF_TYPE_CCX #if (HCF_TALLIES) & ( HCF_TALLIES_NIC | HCF_TALLIES_HCF ) //Hermes and/or HCF tally support hcf_32 IFB_Silly_you_should_align; //;? hcf_16 IFB_TallyLen; // Tally length (to build an LTV) From 7c22429923c393853687266cd9d99c13c688f0a1 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:55 +0100 Subject: [PATCH 1031/1519] staging: wlags49_h2: Remove HCF_EXT_MB from code. The HII and HII.5 configurations both use the mailboxes. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 28 ++++++++-------------------- drivers/staging/wlags49_h2/hcf.h | 2 -- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 5935b42c680..67c138d6ca0 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -104,9 +104,7 @@ HCF_STATIC int cmd_exe( IFBP ifbp, hcf_16 cmd_code, hcf_16 par_0 ); HCF_STATIC int init( IFBP ifbp ); HCF_STATIC int put_info( IFBP ifbp, LTVP ltvp ); -#if (HCF_EXT) & HCF_EXT_MB HCF_STATIC int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ); -#endif // HCF_EXT_MB #if (HCF_TYPE) & HCF_TYPE_WPA HCF_STATIC void calc_mic( hcf_32* p, hcf_32 M ); void calc_mic_rx_frag( IFBP ifbp, wci_bufp p, int len ); @@ -473,14 +471,10 @@ static struct /*CFG_HCF_OPT_STRCT*/ { }; // cfg_hcf_opt #endif // MSF_COMPONENT_ID -#if defined MSF_COMPONENT_ID || (HCF_EXT) & HCF_EXT_MB -#if (HCF_EXT) & HCF_EXT_MB HCF_STATIC LTV_STRCT BASED cfg_null = { 1, CFG_NULL, {0} }; -#endif // HCF_EXT_MB + HCF_STATIC hcf_16* BASED xxxx[ ] = { -#if (HCF_EXT) & HCF_EXT_MB &cfg_null.len, //CFG_NULL 0x0820 -#endif // HCF_EXT_MB #if defined MSF_COMPONENT_ID &cfg_drv_identity.len, //CFG_DRV_IDENTITY 0x0826 &cfg_drv_sup_range.len, //CFG_DRV_SUP_RANGE 0x0827 @@ -496,8 +490,6 @@ HCF_STATIC hcf_16* BASED xxxx[ ] = { }; #define xxxx_PRI_IDENTITY_OFFSET (ARRAY_SIZE(xxxx) - 3) -#endif // MSF_COMPONENT_ID / HCF_EXT_MB - /************************************************************************************************************ ************************** T O P L E V E L H C F R O U T I N E S ************************************** @@ -1974,16 +1966,16 @@ hcf_get_info( IFBP ifbp, LTVP ltvp ) HCFASSERT( 1 < ltvp->len && ltvp->len <= HCF_MAX_LTV + 1, MERGE_2( ltvp->typ, ltvp->len ) ); ltvp->len = 0; //default to: No Info Available -#if defined MSF_COMPONENT_ID || (HCF_EXT) & HCF_EXT_MB //filter out all specials + //filter out all specials for ( i = 0; ( q = xxxx[i] ) != NULL && q[1] != type; i++ ) /*NOP*/; -#endif // MSF_COMPONENT_ID / HCF_EXT_MB + #if HCF_TALLIES if ( type == CFG_TALLIES ) { /*3*/ (void)hcf_action( ifbp, HCF_ACT_TALLIES ); q = (hcf_16*)&ifbp->IFB_TallyLen; } #endif // HCF_TALLIES -#if (HCF_EXT) & HCF_EXT_MB + if ( type == CFG_MB_INFO ) { if ( ifbp->IFB_MBInfoLen ) { if ( ifbp->IFB_MBp[ifbp->IFB_MBRp] == 0xFFFF ) { @@ -1997,7 +1989,7 @@ hcf_get_info( IFBP ifbp, LTVP ltvp ) ifbp->IFB_MBInfoLen = ifbp->IFB_MBp[ifbp->IFB_MBRp]; } } -#endif // HCF_EXT_MB + if ( q != NULL ) { //a special or CFG_TALLIES or CFG_MB_INFO i = min( len, *q ) + 1; //total size of destination (including T-field) while ( i-- ) { @@ -2203,7 +2195,7 @@ hcf_put_info( IFBP ifbp, LTVP ltvp ) if ( ( ltvp->val[0] & USE_DMA ) == 0 ) ifbp->IFB_CntlOpt &= ~USE_DMA; ifbp->IFB_CntlOpt |= ltvp->val[0] & USE_16BIT; break; -#if (HCF_EXT) & HCF_EXT_MB + case CFG_REG_MB: //Register MailBox #define P ((CFG_REG_MB_STRCT FAR *)ltvp) HCFASSERT( ( (hcf_32)P->mb_addr & 0x0001 ) == 0, (hcf_32)P->mb_addr ); @@ -2220,7 +2212,6 @@ hcf_put_info( IFBP ifbp, LTVP ltvp ) case CFG_MB_INFO: //store MailBoxInfoBlock rc = put_info_mb( ifbp, (CFG_MB_INFO_STRCT FAR *)ltvp ); break; -#endif // HCF_EXT_MB #if (HCF_EXT) & HCF_EXT_NIC_ACCESS case CFG_CMD_NIC: @@ -4336,11 +4327,11 @@ mdd_assert( IFBP ifbp, unsigned int line_number, hcf_32 q ) OPW( HREG_SW_2, (hcf_16)(q >> 16 ) ); #endif // HCF_ASSERT_SW_SUP -#if (HCF_EXT) & HCF_EXT_MB && (HCF_ASSERT) & HCF_ASSERT_MB +#if (HCF_ASSERT) & HCF_ASSERT_MB ifbp->IFB_AssertLvl = 0; // prevent recursive behavior hcf_put_info( ifbp, (LTVP)&ifbp->IFB_AssertStrct ); ifbp->IFB_AssertLvl = run_time_flag; // restore appropriate filter level -#endif // HCF_EXT_MB / HCF_ASSERT_MB +#endif // HCF_ASSERT_MB } } // mdd_assert #endif // HCF_ASSERT @@ -4619,7 +4610,6 @@ put_info( IFBP ifbp, LTVP ltvp ) *.ENDDOC END DOCUMENTATION * ************************************************************************************************************/ -#if (HCF_EXT) & HCF_EXT_MB HCF_STATIC int put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) @@ -4677,8 +4667,6 @@ put_info_mb( IFBP ifbp, CFG_MB_INFO_STRCT FAR * ltvp ) return rc; } // put_info_mb -#endif // HCF_EXT_MB - /************************************************************************************************************ * diff --git a/drivers/staging/wlags49_h2/hcf.h b/drivers/staging/wlags49_h2/hcf.h index cf55e8ea1d3..00099473116 100644 --- a/drivers/staging/wlags49_h2/hcf.h +++ b/drivers/staging/wlags49_h2/hcf.h @@ -301,13 +301,11 @@ typedef struct { #if (HCF_EXT) & HCF_EXT_INT_TICK int IFB_TickCnt; // Hermes Timer Tick Counter #endif // HCF_EXT_INT_TICK -#if (HCF_EXT) & HCF_EXT_MB hcf_16 *IFB_MBp; // pointer to the MailBox hcf_16 IFB_MBSize; // size of the MailBox hcf_16 IFB_MBWp; // zero-based write index into the MailBox hcf_16 IFB_MBRp; // zero-based read index into the MailBox hcf_16 IFB_MBInfoLen; // contents of L-field of the oldest available MailBoxInfoBlock -#endif // HCF_EXT_MB #if (HCF_TYPE) & HCF_TYPE_WPA hcf_16 IFB_MICTxCntl; // MIC bit and Key index in TxControl field of TxFS hcf_32 IFB_MICTxKey[2]; // calculating key From 2a83cb015647be5ddd2522764e0672f593644718 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 16 Sep 2011 00:20:56 +0100 Subject: [PATCH 1032/1519] staging: wlags49_h2: Reformat TX_CNTL comment This tabular comment is useful, but the original tabbed layout is for a tab-wdth of 4. Reformat with spaces. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/mdd.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/wlags49_h2/mdd.h b/drivers/staging/wlags49_h2/mdd.h index acdeacd699d..b02e3ea9e47 100644 --- a/drivers/staging/wlags49_h2/mdd.h +++ b/drivers/staging/wlags49_h2/mdd.h @@ -893,20 +893,20 @@ XX1( CFG_SCAN, SCAN_RS_STRCT, scan_result[32] ) /*Scan results * //HFS_TX_CNTL /* Note that the HCF_.... System Constants influence the HFS_.... values below - * H-I H-I | H-II H-II H-II.5 - * WPA | WPA - * HFS_TX_CNTL_TX_OK 0002 0002 | 0002 0002 N/A <<<<<<< Date: Fri, 16 Sep 2011 00:20:57 +0100 Subject: [PATCH 1033/1519] staging: wlags49_h2: Remove continuous tx test Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/hcf.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 67c138d6ca0..7dc176a95aa 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -2596,28 +2596,6 @@ hcf_send_msg( IFBP ifbp, DESC_STRCT *descp, hcf_16 tx_cntl ) if ( descp ) ifbp->IFB_TxFID = 0; //cancel a pre-put message -#if (HCF_EXT) & HCF_EXT_TX_CONT // Continuous transmit test - if ( tx_cntl == HFS_TX_CNTL_TX_CONT ) { - fid = get_fid(ifbp); - if (fid != 0 ) { - //setup BAP to begin of TxFS - (void)setup_bap( ifbp, fid, 0, IO_OUT ); - //copy all the fragments in a transparent fashion - for ( p = descp; p; p = p->next_desc_addr ) { - /* obnoxious warning C4769: conversion of near pointer to long integer */ - HCFASSERT( ((hcf_32)p & 3 ) == 0, (hcf_32)p ); - put_frag( ifbp, p->buf_addr, p->BUF_CNT BE_PAR(0) ); - } - rc = cmd_exe( ifbp, HCMD_THESEUS | HCMD_BUSY | HCMD_STARTPREAMBLE, fid ); - if ( ifbp->IFB_RscInd == 0 ) { - ifbp->IFB_RscInd = get_fid( ifbp ); - } - } - // een slecht voorbeeld doet goed volgen ;? - HCFLOGEXIT( HCF_TRACE_SEND_MSG ); - return rc; - } -#endif // HCF_EXT_TX_CONT /* the following initialization code is redundant for a pre-put message * but moving it inside the "if fid" logic makes the merging with the * USB flow awkward From b2f37e7e0be3ad2db87b9b70ce21d463c9bf9d99 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 13 Sep 2011 09:49:41 +0200 Subject: [PATCH 1034/1519] staging: brcm80211: remove static function declaration in dhd_sdio Reshuffle function order in dhd_sdio of fullmac to get rid of static function declaration Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 4622 ++++++++--------- 1 file changed, 2284 insertions(+), 2338 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 0de4dc64b9e..680b23265f3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -855,58 +855,6 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) #define HOSTINTMASK (I_HMB_SW_MASK | I_CHIPACTIVE) -#ifdef BCMDBG -static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size); -static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus); -#endif /* BCMDBG */ -static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter); - -static void brcmf_sdbrcm_release(struct brcmf_bus *bus); -static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus); -static bool brcmf_sdbrcm_chipmatch(u16 chipid); -static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva); -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus); -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus); -static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus); - -static uint brcmf_process_nvram_vars(char *varbuf, uint len); - -static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size); -static int brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, - struct sk_buff *pkt); - -static bool brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus); -static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus); - -static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus); -static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus); - -static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase); - -static int brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs); - -static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase); - -static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, - u32 drivestrength); -static void brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus); -static void brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar); -static void brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus); -static void brcmf_sdbrcm_watchdog(unsigned long data); -static int brcmf_sdbrcm_watchdog_thread(void *data); -static int brcmf_sdbrcm_dpc_thread(void *data); -static void brcmf_sdbrcm_dpc_tasklet(unsigned long data); -static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus); -static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus); -static void brcmf_sdbrcm_sdunlock(struct brcmf_bus *bus); -static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus); -static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, - bool *pending); -static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus); - /* Packet free applicable unconditionally for sdio and sdspi. * Conditional if bufpool was present for gspi bus. */ @@ -927,6 +875,22 @@ static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size) bus->ramsize = brcmf_dongle_memsize; } +static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus) +{ + if (bus->threads_only) + down(&bus->sdsem); + else + spin_lock_bh(&bus->sdlock); +} + +static void brcmf_sdbrcm_sdunlock(struct brcmf_bus *bus) +{ + if (bus->threads_only) + up(&bus->sdsem); + else + spin_unlock_bh(&bus->sdlock); +} + /* Turn backplane clock on or off */ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) { @@ -1217,1225 +1181,80 @@ static void bus_wake(struct brcmf_bus *bus) brcmf_sdbrcm_bussleep(bus, false); } -/* Writes a HW/SW header into the packet and sends it. */ -/* Assumes: (a) header space already there, (b) caller holds lock */ -static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, - uint chan, bool free_pkt) +static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) { - int ret; - u8 *frame; - u16 len, pad = 0; - u32 swheader; - uint retries = 0; - struct sk_buff *new; - int i; - - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr->dongle_reset) { - ret = -EPERM; - goto done; - } - - frame = (u8 *) (pkt->data); - - /* Add alignment padding, allocate new packet if needed */ - pad = ((unsigned long)frame % BRCMF_SDALIGN); - if (pad) { - if (skb_headroom(pkt) < pad) { - brcmf_dbg(INFO, "insufficient headroom %d for %d pad\n", - skb_headroom(pkt), pad); - bus->drvr->tx_realloc++; - new = brcmu_pkt_buf_get_skb(pkt->len + BRCMF_SDALIGN); - if (!new) { - brcmf_dbg(ERROR, "couldn't allocate new %d-byte packet\n", - pkt->len + BRCMF_SDALIGN); - ret = -ENOMEM; - goto done; - } - - pkt_align(new, pkt->len, BRCMF_SDALIGN); - memcpy(new->data, pkt->data, pkt->len); - if (free_pkt) - brcmu_pkt_buf_free_skb(pkt); - /* free the pkt if canned one is not used */ - free_pkt = true; - pkt = new; - frame = (u8 *) (pkt->data); - /* precondition: (frame % BRCMF_SDALIGN) == 0) */ - pad = 0; - } else { - skb_push(pkt, pad); - frame = (u8 *) (pkt->data); - /* precondition: pad + SDPCM_HDRLEN <= pkt->len */ - memset(frame, 0, pad + SDPCM_HDRLEN); - } - } - /* precondition: pad < BRCMF_SDALIGN */ - - /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - len = (u16) (pkt->len); - *(u16 *) frame = cpu_to_le16(len); - *(((u16 *) frame) + 1) = cpu_to_le16(~len); - - /* Software tag: channel, sequence number, data offset */ - swheader = - ((chan << SDPCM_CHANNEL_SHIFT) & SDPCM_CHANNEL_MASK) | bus->tx_seq | - (((pad + - SDPCM_HDRLEN) << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); - - put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); - put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); - -#ifdef BCMDBG - tx_packets[pkt->priority]++; - if (BRCMF_BYTES_ON() && - (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || - (BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } -#endif - - /* Raise len to next SDIO block to eliminate tail command */ - if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { - u16 pad = bus->blocksize - (len % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize)) - len += pad; - } else if (len % BRCMF_SDALIGN) { - len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); - } - - /* Some controllers have trouble with odd bytes -- round to even */ - if (forcealign && (len & (ALIGNMENT - 1))) - len = roundup(len, ALIGNMENT); - - do { - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, - len, pkt); - bus->f2txdata++; - - if (ret < 0) { - /* On failure, abort the command - and terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, - NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } - - } - if (ret == 0) - bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - - } while ((ret < 0) && retrydata && retries++ < TXRETRIES); - -done: - /* restore pkt buffer pointer before calling tx complete routine */ - skb_pull(pkt, SDPCM_HDRLEN + pad); - brcmf_sdbrcm_sdunlock(bus); - brcmf_txcomplete(bus->drvr, pkt, ret != 0); - brcmf_sdbrcm_sdlock(bus); - - if (free_pkt) - brcmu_pkt_buf_free_skb(pkt); - - return ret; -} - -int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) -{ - int ret = -EBADE; - uint datalen, prec; - - brcmf_dbg(TRACE, "Enter\n"); - - datalen = pkt->len; - - /* Add space for the header */ - skb_push(pkt, SDPCM_HDRLEN); - /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ - - prec = prio2prec((pkt->priority & PRIOMASK)); - - /* Check for existing queue, current flow-control, - pending event, or pending clock */ - if (brcmf_deferred_tx || bus->fcstate || pktq_len(&bus->txq) - || bus->dpc_sched || (!data_ok(bus)) - || (bus->flowcontrol & NBITVAL(prec)) - || (bus->clkstate != CLK_AVAIL)) { - brcmf_dbg(TRACE, "deferring pktq len %d\n", - pktq_len(&bus->txq)); - bus->fcqueued++; - - /* Priority based enq */ - spin_lock_bh(&bus->txqlock); - if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == - false) { - skb_pull(pkt, SDPCM_HDRLEN); - brcmf_txcomplete(bus->drvr, pkt, false); - brcmu_pkt_buf_free_skb(pkt); - brcmf_dbg(ERROR, "out of bus->txq !!!\n"); - ret = -ENOSR; - } else { - ret = 0; - } - spin_unlock_bh(&bus->txqlock); - - if (pktq_len(&bus->txq) >= TXHI) - brcmf_txflowcontrol(bus->drvr, 0, ON); - -#ifdef BCMDBG - if (pktq_plen(&bus->txq, prec) > qcount[prec]) - qcount[prec] = pktq_plen(&bus->txq, prec); -#endif - /* Schedule DPC if needed to send queued packet(s) */ - if (brcmf_deferred_tx && !bus->dpc_sched) { - bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); - } - } else { - /* Lock: we're about to use shared data/code (and SDIO) */ - brcmf_sdbrcm_sdlock(bus); - - /* Otherwise, send it now */ - bus_wake(bus); - /* Make sure back plane ht clk is on, no pending allowed */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); - - brcmf_dbg(TRACE, "calling txpkt\n"); - ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); - if (ret) - bus->drvr->tx_errors++; - else - bus->drvr->dstats.tx_bytes += datalen; - - if (bus->idletime == BRCMF_IDLE_IMMEDIATE && - !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); - } - - return ret; -} - -static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) -{ - struct sk_buff *pkt; u32 intstatus = 0; + u32 hmb_data; + u8 fcbits; uint retries = 0; - int ret = 0, prec_out; - uint cnt = 0; - uint datalen; - u8 tx_prec_map; - - struct brcmf_pub *drvr = bus->drvr; brcmf_dbg(TRACE, "Enter\n"); - tx_prec_map = ~bus->flowcontrol; + /* Read mailbox data and ack that we did so */ + r_sdreg32(bus, &hmb_data, + offsetof(struct sdpcmd_regs, tohostmailboxdata), &retries); - /* Send frames until the limit or some other event */ - for (cnt = 0; (cnt < maxframes) && data_ok(bus); cnt++) { - spin_lock_bh(&bus->txqlock); - pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); - if (pkt == NULL) { - spin_unlock_bh(&bus->txqlock); - break; - } - spin_unlock_bh(&bus->txqlock); - datalen = pkt->len - SDPCM_HDRLEN; + if (retries <= retry_limit) + w_sdreg32(bus, SMB_INT_ACK, + offsetof(struct sdpcmd_regs, tosbmailbox), &retries); + bus->f1regdata += 2; - ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); - if (ret) - bus->drvr->tx_errors++; - else - bus->drvr->dstats.tx_bytes += datalen; + /* Dongle recomposed rx frames, accept them again */ + if (hmb_data & HMB_DATA_NAKHANDLED) { + brcmf_dbg(INFO, "Dongle reports NAK handled, expect rtx of %d\n", + bus->rx_seq); + if (!bus->rxskip) + brcmf_dbg(ERROR, "unexpected NAKHANDLED!\n"); - /* In poll mode, need to check for other events */ - if (!bus->intr && cnt) { - /* Check device status, signal pending interrupt */ - r_sdreg32(bus, &intstatus, - offsetof(struct sdpcmd_regs, intstatus), - &retries); - bus->f2txdata++; - if (brcmf_sdcard_regfail(bus->sdiodev)) - break; - if (intstatus & bus->hostintmask) - bus->ipend = true; - } + bus->rxskip = false; + intstatus |= I_HMB_FRAME_IND; } - /* Deflow-control stack if needed */ - if (drvr->up && (drvr->busstate == BRCMF_BUS_DATA) && - drvr->txoff && (pktq_len(&bus->txq) < TXLOW)) - brcmf_txflowcontrol(drvr, 0, OFF); - - return cnt; -} - -int -brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) -{ - u8 *frame; - u16 len; - u32 swheader; - uint retries = 0; - u8 doff = 0; - int ret = -1; - int i; - - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr->dongle_reset) - return -EIO; - - /* Back the pointer to make a room for bus header */ - frame = msg - SDPCM_HDRLEN; - len = (msglen += SDPCM_HDRLEN); - - /* Add alignment padding (optional for ctl frames) */ - if (brcmf_alignctl) { - doff = ((unsigned long)frame % BRCMF_SDALIGN); - if (doff) { - frame -= doff; - len += doff; - msglen += doff; - memset(frame, 0, doff + SDPCM_HDRLEN); - } - /* precondition: doff < BRCMF_SDALIGN */ - } - doff += SDPCM_HDRLEN; - - /* Round send length to next SDIO block */ - if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { - u16 pad = bus->blocksize - (len % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize)) - len += pad; - } else if (len % BRCMF_SDALIGN) { - len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); - } - - /* Satisfy length-alignment requirements */ - if (forcealign && (len & (ALIGNMENT - 1))) - len = roundup(len, ALIGNMENT); - - /* precondition: IS_ALIGNED((unsigned long)frame, 2) */ - - /* Need to lock here to protect txseq and SDIO tx calls */ - brcmf_sdbrcm_sdlock(bus); - - bus_wake(bus); - - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - *(u16 *) frame = cpu_to_le16((u16) msglen); - *(((u16 *) frame) + 1) = cpu_to_le16(~msglen); - - /* Software tag: channel, sequence number, data offset */ - swheader = - ((SDPCM_CONTROL_CHANNEL << SDPCM_CHANNEL_SHIFT) & - SDPCM_CHANNEL_MASK) - | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & - SDPCM_DOFFSET_MASK); - put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); - put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); - - if (!data_ok(bus)) { - brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", - bus->tx_max, bus->tx_seq); - bus->ctrl_frame_stat = true; - /* Send from dpc */ - bus->ctrl_frame_buf = frame; - bus->ctrl_frame_len = len; - - brcmf_sdbrcm_wait_for_event(bus, &bus->ctrl_frame_stat); - - if (bus->ctrl_frame_stat == false) { - brcmf_dbg(INFO, "ctrl_frame_stat == false\n"); - ret = 0; - } else { - brcmf_dbg(INFO, "ctrl_frame_stat == true\n"); - ret = -1; - } - } - - if (ret == -1) { -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } -#endif - - do { - bus->ctrl_frame_stat = false; - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, len, NULL); - - if (ret < 0) { - /* On failure, abort the command and - terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, - SFC_WF_TERM, NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } - - } - if (ret == 0) - bus->tx_seq = - (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - - } while ((ret < 0) && retries++ < TXRETRIES); - } - - if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); - - if (ret) - bus->drvr->tx_ctlerrs++; - else - bus->drvr->tx_ctlpkts++; - - return ret ? -EIO : 0; -} - -int -brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) -{ - int timeleft; - uint rxlen = 0; - bool pending; - - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr->dongle_reset) - return -EIO; - - /* Wait until control frame is available */ - timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); - - brcmf_sdbrcm_sdlock(bus); - rxlen = bus->rxlen; - memcpy(msg, bus->rxctl, min(msglen, rxlen)); - bus->rxlen = 0; - brcmf_sdbrcm_sdunlock(bus); - - if (rxlen) { - brcmf_dbg(CTL, "resumed on rxctl frame, got %d expected %d\n", - rxlen, msglen); - } else if (timeleft == 0) { - brcmf_dbg(ERROR, "resumed on timeout\n"); -#ifdef BCMDBG - brcmf_sdbrcm_sdlock(bus); - brcmf_sdbrcm_checkdied(bus, NULL, 0); - brcmf_sdbrcm_sdunlock(bus); -#endif /* BCMDBG */ - } else if (pending == true) { - brcmf_dbg(CTL, "cancelled\n"); - return -ERESTARTSYS; - } else { - brcmf_dbg(CTL, "resumed for unknown reason?\n"); -#ifdef BCMDBG - brcmf_sdbrcm_sdlock(bus); - brcmf_sdbrcm_checkdied(bus, NULL, 0); - brcmf_sdbrcm_sdunlock(bus); -#endif /* BCMDBG */ - } - - if (rxlen) - bus->drvr->rx_ctlpkts++; - else - bus->drvr->rx_ctlerrs++; - - return rxlen ? (int)rxlen : -ETIMEDOUT; -} - -static int -brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, - uint size) -{ - int bcmerror = 0; - u32 sdaddr; - uint dsize; - - /* Determine initial transfer parameters */ - sdaddr = address & SBSDIO_SB_OFT_ADDR_MASK; - if ((sdaddr + size) & SBSDIO_SBWINDOW_MASK) - dsize = (SBSDIO_SB_OFT_ADDR_LIMIT - sdaddr); - else - dsize = size; - - /* Set the backplane window to include the start address */ - bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, address); - if (bcmerror) { - brcmf_dbg(ERROR, "window change failed\n"); - goto xfer_done; - } - - /* Do the transfer(s) */ - while (size) { - brcmf_dbg(INFO, "%s %d bytes at offset 0x%08x in window 0x%08x\n", - write ? "write" : "read", dsize, - sdaddr, address & SBSDIO_SBWINDOW_MASK); - bcmerror = brcmf_sdcard_rwdata(bus->sdiodev, write, - sdaddr, data, dsize); - if (bcmerror) { - brcmf_dbg(ERROR, "membytes transfer failed\n"); - break; - } - - /* Adjust for next transfer (if any) */ - size -= dsize; - if (size) { - data += dsize; - address += dsize; - bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, - address); - if (bcmerror) { - brcmf_dbg(ERROR, "window change failed\n"); - break; - } - sdaddr = 0; - dsize = min_t(uint, SBSDIO_SB_OFT_ADDR_LIMIT, size); - } - } - -xfer_done: - /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, bus->sdiodev->sbwad)) - brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", - bus->sdiodev->sbwad); - - return bcmerror; -} - -#ifdef BCMDBG -static int -brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) -{ - u32 addr; - int rv; - - /* Read last word in memory to determine address of - sdpcm_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, bus->ramsize - 4, (u8 *)&addr, - 4); - if (rv < 0) - return rv; - - addr = le32_to_cpu(addr); - - brcmf_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr); - /* - * Check if addr is valid. - * NVRAM length at the end of memory should have been overwritten. + * DEVREADY does not occur with gSPI. */ - if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) { - brcmf_dbg(ERROR, "address (0x%08x) of sdpcm_shared invalid\n", - addr); - return -EBADE; - } - - /* Read rte_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *) sh, - sizeof(struct sdpcm_shared)); - if (rv < 0) - return rv; - - /* Endianness */ - sh->flags = le32_to_cpu(sh->flags); - sh->trap_addr = le32_to_cpu(sh->trap_addr); - sh->assert_exp_addr = le32_to_cpu(sh->assert_exp_addr); - sh->assert_file_addr = le32_to_cpu(sh->assert_file_addr); - sh->assert_line = le32_to_cpu(sh->assert_line); - sh->console_addr = le32_to_cpu(sh->console_addr); - sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr); - - if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { - brcmf_dbg(ERROR, "sdpcm_shared version %d in brcmf is different than sdpcm_shared version %d in dongle\n", - SDPCM_SHARED_VERSION, - sh->flags & SDPCM_SHARED_VERSION_MASK); - return -EBADE; - } - - return 0; -} - -static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) -{ - int bcmerror = 0; - uint msize = 512; - char *mbuffer = NULL; - uint maxstrlen = 256; - char *str = NULL; - struct brcmf_trap tr; - struct sdpcm_shared sdpcm_shared; - struct brcmu_strbuf strbuf; - - brcmf_dbg(TRACE, "Enter\n"); - - if (data == NULL) { - /* - * Called after a rx ctrl timeout. "data" is NULL. - * allocate memory to trace the trap or assert. - */ - size = msize; - mbuffer = data = kmalloc(msize, GFP_ATOMIC); - if (mbuffer == NULL) { - brcmf_dbg(ERROR, "kmalloc(%d) failed\n", msize); - bcmerror = -ENOMEM; - goto done; - } - } - - str = kmalloc(maxstrlen, GFP_ATOMIC); - if (str == NULL) { - brcmf_dbg(ERROR, "kmalloc(%d) failed\n", maxstrlen); - bcmerror = -ENOMEM; - goto done; - } - - bcmerror = brcmf_sdbrcm_readshared(bus, &sdpcm_shared); - if (bcmerror < 0) - goto done; - - brcmu_binit(&strbuf, data, size); - - brcmu_bprintf(&strbuf, - "msgtrace address : 0x%08X\nconsole address : 0x%08X\n", - sdpcm_shared.msgtrace_addr, sdpcm_shared.console_addr); - - if ((sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) == 0) - /* NOTE: Misspelled assert is intentional - DO NOT FIX. - * (Avoids conflict with real asserts for programmatic - * parsing of output.) - */ - brcmu_bprintf(&strbuf, "Assrt not built in dongle\n"); - - if ((sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) == - 0) { - /* NOTE: Misspelled assert is intentional - DO NOT FIX. - * (Avoids conflict with real asserts for programmatic - * parsing of output.) - */ - brcmu_bprintf(&strbuf, "No trap%s in dongle", - (sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) - ? "/assrt" : ""); - } else { - if (sdpcm_shared.flags & SDPCM_SHARED_ASSERT) { - /* Download assert */ - brcmu_bprintf(&strbuf, "Dongle assert"); - if (sdpcm_shared.assert_exp_addr != 0) { - str[0] = '\0'; - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.assert_exp_addr, - (u8 *) str, maxstrlen); - if (bcmerror < 0) - goto done; - - str[maxstrlen - 1] = '\0'; - brcmu_bprintf(&strbuf, " expr \"%s\"", str); - } - - if (sdpcm_shared.assert_file_addr != 0) { - str[0] = '\0'; - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.assert_file_addr, - (u8 *) str, maxstrlen); - if (bcmerror < 0) - goto done; - - str[maxstrlen - 1] = '\0'; - brcmu_bprintf(&strbuf, " file \"%s\"", str); - } - - brcmu_bprintf(&strbuf, " line %d ", - sdpcm_shared.assert_line); - } - - if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) { - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.trap_addr, (u8 *)&tr, - sizeof(struct brcmf_trap)); - if (bcmerror < 0) - goto done; - - brcmu_bprintf(&strbuf, - "Dongle trap type 0x%x @ epc 0x%x, cpsr 0x%x, spsr 0x%x, sp 0x%x," - "lp 0x%x, rpc 0x%x Trap offset 0x%x, " - "r0 0x%x, r1 0x%x, r2 0x%x, r3 0x%x, r4 0x%x, r5 0x%x, r6 0x%x, r7 0x%x\n", - tr.type, tr.epc, tr.cpsr, tr.spsr, tr.r13, - tr.r14, tr.pc, sdpcm_shared.trap_addr, - tr.r0, tr.r1, tr.r2, tr.r3, tr.r4, tr.r5, - tr.r6, tr.r7); - } - } - - if (sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) - brcmf_dbg(ERROR, "%s\n", strbuf.origbuf); - -#ifdef BCMDBG - if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) - /* Mem dump to a file on device */ - brcmf_sdbrcm_mem_dump(bus); - -#endif /* BCMDBG */ - -done: - kfree(mbuffer); - kfree(str); - - return bcmerror; -} - -static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) -{ - int ret = 0; - int size; /* Full mem size */ - int start = 0; /* Start address */ - int read_size = 0; /* Read size of each iteration */ - u8 *buf = NULL, *databuf = NULL; - - /* Get full mem size */ - size = bus->ramsize; - buf = kmalloc(size, GFP_ATOMIC); - if (!buf) { - brcmf_dbg(ERROR, "Out of memory (%d bytes)\n", size); - return -1; - } - - /* Read mem content */ - printk(KERN_DEBUG "Dump dongle memory"); - databuf = buf; - while (size) { - read_size = min(MEMBLOCK, size); - ret = brcmf_sdbrcm_membytes(bus, false, start, databuf, - read_size); - if (ret) { - brcmf_dbg(ERROR, "Error membytes %d\n", ret); - kfree(buf); - return -1; - } - printk("."); - - /* Decrement size and increment start address */ - size -= read_size; - start += read_size; - databuf += read_size; - } - printk(KERN_DEBUG "Done\n"); - - /* free buf before return !!! */ - if (brcmf_write_to_file(bus->drvr, buf, bus->ramsize)) { - brcmf_dbg(ERROR, "Error writing to files\n"); - return -1; - } - - /* buf free handled in brcmf_write_to_file, not here */ - return 0; -} - -#define CONSOLE_LINE_MAX 192 - -static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) -{ - struct brcmf_console *c = &bus->console; - u8 line[CONSOLE_LINE_MAX], ch; - u32 n, idx, addr; - int rv; - - /* Don't do anything until FWREADY updates console address */ - if (bus->console_addr == 0) - return 0; - - /* Read console log struct */ - addr = bus->console_addr + offsetof(struct rte_console, log); - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&c->log, - sizeof(c->log)); - if (rv < 0) - return rv; - - /* Allocate console buffer (one time only) */ - if (c->buf == NULL) { - c->bufsize = le32_to_cpu(c->log.buf_size); - c->buf = kmalloc(c->bufsize, GFP_ATOMIC); - if (c->buf == NULL) - return -ENOMEM; - } - - idx = le32_to_cpu(c->log.idx); - - /* Protect against corrupt value */ - if (idx > c->bufsize) - return -EBADE; - - /* Skip reading the console buffer if the index pointer - has not moved */ - if (idx == c->last) - return 0; - - /* Read the console buffer */ - addr = le32_to_cpu(c->log.buf); - rv = brcmf_sdbrcm_membytes(bus, false, addr, c->buf, c->bufsize); - if (rv < 0) - return rv; - - while (c->last != idx) { - for (n = 0; n < CONSOLE_LINE_MAX - 2; n++) { - if (c->last == idx) { - /* This would output a partial line. - * Instead, back up - * the buffer pointer and output this - * line next time around. - */ - if (c->last >= n) - c->last -= n; - else - c->last = c->bufsize - n; - goto break2; - } - ch = c->buf[c->last]; - c->last = (c->last + 1) % c->bufsize; - if (ch == '\n') - break; - line[n] = ch; - } - - if (n > 0) { - if (line[n - 1] == '\r') - n--; - line[n] = 0; - printk(KERN_DEBUG "CONSOLE: %s\n", line); - } - } -break2: - - return 0; -} -#endif /* BCMDBG */ - -static int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) -{ - int bcmerror = 0; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Basic sanity checks */ - if (bus->drvr->up) { - bcmerror = -EISCONN; - goto err; - } - if (!len) { - bcmerror = -EOVERFLOW; - goto err; - } - - /* Free the old ones and replace with passed variables */ - kfree(bus->vars); - - bus->vars = kmalloc(len, GFP_ATOMIC); - bus->varsz = bus->vars ? len : 0; - if (bus->vars == NULL) { - bcmerror = -ENOMEM; - goto err; - } - - /* Copy the passed variables, which should include the - terminating double-null */ - memcpy(bus->vars, arg, bus->varsz); -err: - return bcmerror; -} - -static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) -{ - int bcmerror = 0; - u32 varsize; - u32 varaddr; - u8 *vbuffer; - u32 varsizew; -#ifdef BCMDBG - char *nvram_ularray; -#endif /* BCMDBG */ - - /* Even if there are no vars are to be written, we still - need to set the ramsize. */ - varsize = bus->varsz ? roundup(bus->varsz, 4) : 0; - varaddr = (bus->ramsize - 4) - varsize; - - if (bus->vars) { - vbuffer = kzalloc(varsize, GFP_ATOMIC); - if (!vbuffer) - return -ENOMEM; - - memcpy(vbuffer, bus->vars, bus->varsz); - - /* Write the vars list */ - bcmerror = - brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); -#ifdef BCMDBG - /* Verify NVRAM bytes */ - brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); - nvram_ularray = kmalloc(varsize, GFP_ATOMIC); - if (!nvram_ularray) - return -ENOMEM; - - /* Upload image to verify downloaded contents. */ - memset(nvram_ularray, 0xaa, varsize); - - /* Read the vars list to temp buffer for comparison */ - bcmerror = - brcmf_sdbrcm_membytes(bus, false, varaddr, nvram_ularray, - varsize); - if (bcmerror) { - brcmf_dbg(ERROR, "error %d on reading %d nvram bytes at 0x%08x\n", - bcmerror, varsize, varaddr); - } - /* Compare the org NVRAM with the one read from RAM */ - if (memcmp(vbuffer, nvram_ularray, varsize)) - brcmf_dbg(ERROR, "Downloaded NVRAM image is corrupted\n"); + if (hmb_data & (HMB_DATA_DEVREADY | HMB_DATA_FWREADY)) { + bus->sdpcm_ver = + (hmb_data & HMB_DATA_VERSION_MASK) >> + HMB_DATA_VERSION_SHIFT; + if (bus->sdpcm_ver != SDPCM_PROT_VERSION) + brcmf_dbg(ERROR, "Version mismatch, dongle reports %d, " + "expecting %d\n", + bus->sdpcm_ver, SDPCM_PROT_VERSION); else - brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); - - kfree(nvram_ularray); -#endif /* BCMDBG */ - - kfree(vbuffer); + brcmf_dbg(INFO, "Dongle ready, protocol version %d\n", + bus->sdpcm_ver); } - /* adjust to the user specified RAM */ - brcmf_dbg(INFO, "Physical memory size: %d, usable memory size: %d\n", - bus->orig_ramsize, bus->ramsize); - brcmf_dbg(INFO, "Vars are at %d, orig varsize is %d\n", - varaddr, varsize); - varsize = ((bus->orig_ramsize - 4) - varaddr); - /* - * Determine the length token: - * Varsize, converted to words, in lower 16-bits, checksum - * in upper 16-bits. + * Flow Control has been moved into the RX headers and this out of band + * method isn't used any more. + * remaining backward compatible with older dongles. */ - if (bcmerror) { - varsizew = 0; - } else { - varsizew = varsize / 4; - varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF); - varsizew = cpu_to_le32(varsizew); + if (hmb_data & HMB_DATA_FC) { + fcbits = (hmb_data & HMB_DATA_FCDATA_MASK) >> + HMB_DATA_FCDATA_SHIFT; + + if (fcbits & ~bus->flowcontrol) + bus->fc_xoff++; + + if (bus->flowcontrol & ~fcbits) + bus->fc_xon++; + + bus->fc_rcvd++; + bus->flowcontrol = fcbits; } - brcmf_dbg(INFO, "New varsize is %d, length token=0x%08x\n", - varsize, varsizew); + /* Shouldn't be any others */ + if (hmb_data & ~(HMB_DATA_DEVREADY | + HMB_DATA_NAKHANDLED | + HMB_DATA_FC | + HMB_DATA_FWREADY | + HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) + brcmf_dbg(ERROR, "Unknown mailbox data content: 0x%02x\n", + hmb_data); - /* Write the length token to the last word */ - bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->orig_ramsize - 4), - (u8 *)&varsizew, 4); - - return bcmerror; -} - -static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) -{ - uint retries; - u32 regdata; - int bcmerror = 0; - - /* To enter download state, disable ARM and reset SOCRAM. - * To exit download state, simply reset ARM (default is RAM boot). - */ - if (enter) { - bus->alp_only = true; - - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, - bus->ci->armcorebase); - - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); - - /* Clear the top bit of memory */ - if (bus->ramsize) { - u32 zeros = 0; - brcmf_sdbrcm_membytes(bus, true, bus->ramsize - 4, - (u8 *)&zeros, 4); - } - } else { - regdata = brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); - regdata &= (SBTML_RESET | SBTML_REJ_MASK | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { - brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); - bcmerror = -EBADE; - goto fail; - } - - bcmerror = brcmf_sdbrcm_write_vars(bus); - if (bcmerror) { - brcmf_dbg(ERROR, "no vars written to RAM\n"); - bcmerror = 0; - } - - w_sdreg32(bus, 0xFFFFFFFF, - offsetof(struct sdpcmd_regs, intstatus), &retries); - - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); - - /* Allow HT Clock now that the ARM is running. */ - bus->alp_only = false; - - bus->drvr->busstate = BRCMF_BUS_LOAD; - } -fail: - return bcmerror; -} - -void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) -{ - u32 local_hostintmask; - u8 saveclk; - uint retries; - int err; - - brcmf_dbg(TRACE, "Enter\n"); - - if (enforce_mutex) - brcmf_sdbrcm_sdlock(bus); - - bus_wake(bus); - - /* Enable clock for device interrupts */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - if (bus->watchdog_tsk) { - send_sig(SIGTERM, bus->watchdog_tsk, 1); - kthread_stop(bus->watchdog_tsk); - bus->watchdog_tsk = NULL; - } - - if (bus->dpc_tsk) { - send_sig(SIGTERM, bus->dpc_tsk, 1); - kthread_stop(bus->dpc_tsk); - bus->dpc_tsk = NULL; - } else - tasklet_kill(&bus->tasklet); - - /* Disable and clear interrupts at the chip level also */ - w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries); - local_hostintmask = bus->hostintmask; - bus->hostintmask = 0; - - /* Change our idea of bus state */ - bus->drvr->busstate = BRCMF_BUS_DOWN; - - /* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (!err) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - (saveclk | SBSDIO_FORCE_HT), &err); - } - if (err) - brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); - - /* Turn off the bus (F2), free any pending packets */ - brcmf_dbg(INTR, "disable SDIO interrupts\n"); - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - /* Clear any pending interrupts now that F2 is disabled */ - w_sdreg32(bus, local_hostintmask, - offsetof(struct sdpcmd_regs, intstatus), &retries); - - /* Turn off the backplane clock (only) */ - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - - /* Clear the data packet queues */ - brcmu_pktq_flush(&bus->txq, true, NULL, NULL); - - /* Clear any held glomming stuff */ - if (bus->glomd) - brcmu_pkt_buf_free_skb(bus->glomd); - - if (bus->glom) - brcmu_pkt_buf_free_skb(bus->glom); - - bus->glom = bus->glomd = NULL; - - /* Clear rx control and wake any waiters */ - bus->rxlen = 0; - brcmf_sdbrcm_ioctl_resp_wake(bus); - - /* Reset some F2 state stuff */ - bus->rxskip = false; - bus->tx_seq = bus->rx_seq = 0; - - if (enforce_mutex) - brcmf_sdbrcm_sdunlock(bus); -} - -int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) -{ - struct brcmf_bus *bus = drvr->bus; - unsigned long timeout; - uint retries = 0; - u8 ready, enable; - int err, ret = 0; - u8 saveclk; - - brcmf_dbg(TRACE, "Enter\n"); - - /* try to download image and nvram to the dongle */ - if (drvr->busstate == BRCMF_BUS_DOWN) { - if (!(brcmf_sdbrcm_download_firmware(bus))) - return -1; - } - - if (!bus->drvr) - return 0; - - /* Start the watchdog timer */ - bus->drvr->tickcnt = 0; - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); - - if (enforce_mutex) - brcmf_sdbrcm_sdlock(bus); - - /* Make sure backplane clock is on, needed to generate F2 interrupt */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - if (bus->clkstate != CLK_AVAIL) - goto exit; - - /* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (!err) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - (saveclk | SBSDIO_FORCE_HT), &err); - } - if (err) { - brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); - goto exit; - } - - /* Enable function 2 (frame transfers) */ - w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, - offsetof(struct sdpcmd_regs, tosbmailboxdata), &retries); - enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - enable, NULL); - - timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); - ready = 0; - while (enable != ready) { - ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, - SDIO_CCCR_IORx, NULL); - if (time_after(jiffies, timeout)) - break; - else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50)) - /* prevent busy waiting if it takes too long */ - msleep_interruptible(20); - } - - brcmf_dbg(INFO, "enable 0x%02x, ready 0x%02x\n", enable, ready); - - /* If F2 successfully enabled, set core and enable interrupts */ - if (ready == enable) { - /* Set up the interrupt mask and enable interrupts */ - bus->hostintmask = HOSTINTMASK; - w_sdreg32(bus, bus->hostintmask, - offsetof(struct sdpcmd_regs, hostintmask), &retries); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_WATERMARK, 8, &err); - - /* Set bus state according to enable result */ - drvr->busstate = BRCMF_BUS_DATA; - } - - else { - /* Disable F2 again */ - enable = SDIO_FUNC_ENABLE_1; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, - SDIO_CCCR_IOEx, enable, NULL); - } - - /* Restore previous clock setting */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); - - /* If we didn't come up, turn off backplane clock */ - if (drvr->busstate != BRCMF_BUS_DATA) - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - -exit: - if (enforce_mutex) - brcmf_sdbrcm_sdunlock(bus); - - return ret; + return intstatus; } static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) @@ -2498,98 +1317,6 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) bus->drvr->busstate = BRCMF_BUS_DOWN; } -static void -brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) -{ - uint rdlen, pad; - - int sdret; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Set rxctl for frame (w/optional alignment) */ - bus->rxctl = bus->rxbuf; - if (brcmf_alignctl) { - bus->rxctl += firstread; - pad = ((unsigned long)bus->rxctl % BRCMF_SDALIGN); - if (pad) - bus->rxctl += (BRCMF_SDALIGN - pad); - bus->rxctl -= firstread; - } - - /* Copy the already-read portion over */ - memcpy(bus->rxctl, hdr, firstread); - if (len <= firstread) - goto gotpkt; - - /* Raise rdlen to next SDIO block to avoid tail command */ - rdlen = len - firstread; - if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { - pad = bus->blocksize - (rdlen % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize) && - ((len + pad) < bus->drvr->maxctl)) - rdlen += pad; - } else if (rdlen % BRCMF_SDALIGN) { - rdlen += BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); - } - - /* Satisfy length-alignment requirements */ - if (forcealign && (rdlen & (ALIGNMENT - 1))) - rdlen = roundup(rdlen, ALIGNMENT); - - /* Drop if the read is too big or it exceeds our maximum */ - if ((rdlen + firstread) > bus->drvr->maxctl) { - brcmf_dbg(ERROR, "%d-byte control read exceeds %d-byte buffer\n", - rdlen, bus->drvr->maxctl); - bus->drvr->rx_errors++; - brcmf_sdbrcm_rxfail(bus, false, false); - goto done; - } - - if ((len - doff) > bus->drvr->maxctl) { - brcmf_dbg(ERROR, "%d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n", - len, len - doff, bus->drvr->maxctl); - bus->drvr->rx_errors++; - bus->rx_toolong++; - brcmf_sdbrcm_rxfail(bus, false, false); - goto done; - } - - /* Read remainder of frame body into the rxctl buffer */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, (bus->rxctl + firstread), rdlen, - NULL); - bus->f2rxdata++; - - /* Control frame failures need retransmission */ - if (sdret < 0) { - brcmf_dbg(ERROR, "read %d control bytes failed: %d\n", - rdlen, sdret); - bus->rxc_errors++; - brcmf_sdbrcm_rxfail(bus, true, true); - goto done; - } - -gotpkt: - -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "RxCtrl:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len); - } -#endif - - /* Point to valid data and indicate its length */ - bus->rxctl += doff; - bus->rxlen = len - doff; - -done: - /* Awake any waiters */ - brcmf_sdbrcm_ioctl_resp_wake(bus); -} - static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) { u16 dlen, totlen; @@ -2970,6 +1697,127 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) return num; } +static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, + bool *pending) +{ + DECLARE_WAITQUEUE(wait, current); + int timeout = msecs_to_jiffies(brcmf_ioctl_timeout_msec); + + /* Wait until control frame is available */ + add_wait_queue(&bus->ioctl_resp_wait, &wait); + set_current_state(TASK_INTERRUPTIBLE); + + while (!(*condition) && (!signal_pending(current) && timeout)) + timeout = schedule_timeout(timeout); + + if (signal_pending(current)) + *pending = true; + + set_current_state(TASK_RUNNING); + remove_wait_queue(&bus->ioctl_resp_wait, &wait); + + return timeout; +} + +static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus) +{ + if (waitqueue_active(&bus->ioctl_resp_wait)) + wake_up_interruptible(&bus->ioctl_resp_wait); + + return 0; +} +static void +brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) +{ + uint rdlen, pad; + + int sdret; + + brcmf_dbg(TRACE, "Enter\n"); + + /* Set rxctl for frame (w/optional alignment) */ + bus->rxctl = bus->rxbuf; + if (brcmf_alignctl) { + bus->rxctl += firstread; + pad = ((unsigned long)bus->rxctl % BRCMF_SDALIGN); + if (pad) + bus->rxctl += (BRCMF_SDALIGN - pad); + bus->rxctl -= firstread; + } + + /* Copy the already-read portion over */ + memcpy(bus->rxctl, hdr, firstread); + if (len <= firstread) + goto gotpkt; + + /* Raise rdlen to next SDIO block to avoid tail command */ + rdlen = len - firstread; + if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { + pad = bus->blocksize - (rdlen % bus->blocksize); + if ((pad <= bus->roundup) && (pad < bus->blocksize) && + ((len + pad) < bus->drvr->maxctl)) + rdlen += pad; + } else if (rdlen % BRCMF_SDALIGN) { + rdlen += BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); + } + + /* Satisfy length-alignment requirements */ + if (forcealign && (rdlen & (ALIGNMENT - 1))) + rdlen = roundup(rdlen, ALIGNMENT); + + /* Drop if the read is too big or it exceeds our maximum */ + if ((rdlen + firstread) > bus->drvr->maxctl) { + brcmf_dbg(ERROR, "%d-byte control read exceeds %d-byte buffer\n", + rdlen, bus->drvr->maxctl); + bus->drvr->rx_errors++; + brcmf_sdbrcm_rxfail(bus, false, false); + goto done; + } + + if ((len - doff) > bus->drvr->maxctl) { + brcmf_dbg(ERROR, "%d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n", + len, len - doff, bus->drvr->maxctl); + bus->drvr->rx_errors++; + bus->rx_toolong++; + brcmf_sdbrcm_rxfail(bus, false, false); + goto done; + } + + /* Read remainder of frame body into the rxctl buffer */ + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, + bus->sdiodev->sbwad, + SDIO_FUNC_2, + F2SYNC, (bus->rxctl + firstread), rdlen, + NULL); + bus->f2rxdata++; + + /* Control frame failures need retransmission */ + if (sdret < 0) { + brcmf_dbg(ERROR, "read %d control bytes failed: %d\n", + rdlen, sdret); + bus->rxc_errors++; + brcmf_sdbrcm_rxfail(bus, true, true); + goto done; + } + +gotpkt: + +#ifdef BCMDBG + if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { + printk(KERN_DEBUG "RxCtrl:\n"); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len); + } +#endif + + /* Point to valid data and indicate its length */ + bus->rxctl += doff; + bus->rxlen = len - doff; + +done: + /* Awake any waiters */ + brcmf_sdbrcm_ioctl_resp_wake(bus); +} + /* Return true if there may be more frames to read */ static uint brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) @@ -3449,80 +2297,235 @@ deliver: return rxcount; } -static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) +static int +brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, + u8 *buf, uint nbytes, struct sk_buff *pkt) { - u32 intstatus = 0; - u32 hmb_data; - u8 fcbits; + return brcmf_sdcard_send_buf + (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt); +} + +static void +brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) +{ + brcmf_sdbrcm_sdunlock(bus); + wait_event_interruptible_timeout(bus->ctrl_wait, + (*lockvar == false), HZ * 2); + brcmf_sdbrcm_sdlock(bus); + return; +} + +static void +brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus) +{ + if (waitqueue_active(&bus->ctrl_wait)) + wake_up_interruptible(&bus->ctrl_wait); + return; +} + +/* Writes a HW/SW header into the packet and sends it. */ +/* Assumes: (a) header space already there, (b) caller holds lock */ +static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, + uint chan, bool free_pkt) +{ + int ret; + u8 *frame; + u16 len, pad = 0; + u32 swheader; uint retries = 0; + struct sk_buff *new; + int i; brcmf_dbg(TRACE, "Enter\n"); - /* Read mailbox data and ack that we did so */ - r_sdreg32(bus, &hmb_data, - offsetof(struct sdpcmd_regs, tohostmailboxdata), &retries); - - if (retries <= retry_limit) - w_sdreg32(bus, SMB_INT_ACK, - offsetof(struct sdpcmd_regs, tosbmailbox), &retries); - bus->f1regdata += 2; - - /* Dongle recomposed rx frames, accept them again */ - if (hmb_data & HMB_DATA_NAKHANDLED) { - brcmf_dbg(INFO, "Dongle reports NAK handled, expect rtx of %d\n", - bus->rx_seq); - if (!bus->rxskip) - brcmf_dbg(ERROR, "unexpected NAKHANDLED!\n"); - - bus->rxskip = false; - intstatus |= I_HMB_FRAME_IND; + if (bus->drvr->dongle_reset) { + ret = -EPERM; + goto done; } - /* - * DEVREADY does not occur with gSPI. - */ - if (hmb_data & (HMB_DATA_DEVREADY | HMB_DATA_FWREADY)) { - bus->sdpcm_ver = - (hmb_data & HMB_DATA_VERSION_MASK) >> - HMB_DATA_VERSION_SHIFT; - if (bus->sdpcm_ver != SDPCM_PROT_VERSION) - brcmf_dbg(ERROR, "Version mismatch, dongle reports %d, " - "expecting %d\n", - bus->sdpcm_ver, SDPCM_PROT_VERSION); + frame = (u8 *) (pkt->data); + + /* Add alignment padding, allocate new packet if needed */ + pad = ((unsigned long)frame % BRCMF_SDALIGN); + if (pad) { + if (skb_headroom(pkt) < pad) { + brcmf_dbg(INFO, "insufficient headroom %d for %d pad\n", + skb_headroom(pkt), pad); + bus->drvr->tx_realloc++; + new = brcmu_pkt_buf_get_skb(pkt->len + BRCMF_SDALIGN); + if (!new) { + brcmf_dbg(ERROR, "couldn't allocate new %d-byte packet\n", + pkt->len + BRCMF_SDALIGN); + ret = -ENOMEM; + goto done; + } + + pkt_align(new, pkt->len, BRCMF_SDALIGN); + memcpy(new->data, pkt->data, pkt->len); + if (free_pkt) + brcmu_pkt_buf_free_skb(pkt); + /* free the pkt if canned one is not used */ + free_pkt = true; + pkt = new; + frame = (u8 *) (pkt->data); + /* precondition: (frame % BRCMF_SDALIGN) == 0) */ + pad = 0; + } else { + skb_push(pkt, pad); + frame = (u8 *) (pkt->data); + /* precondition: pad + SDPCM_HDRLEN <= pkt->len */ + memset(frame, 0, pad + SDPCM_HDRLEN); + } + } + /* precondition: pad < BRCMF_SDALIGN */ + + /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ + len = (u16) (pkt->len); + *(u16 *) frame = cpu_to_le16(len); + *(((u16 *) frame) + 1) = cpu_to_le16(~len); + + /* Software tag: channel, sequence number, data offset */ + swheader = + ((chan << SDPCM_CHANNEL_SHIFT) & SDPCM_CHANNEL_MASK) | bus->tx_seq | + (((pad + + SDPCM_HDRLEN) << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); + + put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); + put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); + +#ifdef BCMDBG + tx_packets[pkt->priority]++; + if (BRCMF_BYTES_ON() && + (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || + (BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { + printk(KERN_DEBUG "Tx Frame:\n"); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len); + } else if (BRCMF_HDRS_ON()) { + printk(KERN_DEBUG "TxHdr:\n"); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, + frame, min_t(u16, len, 16)); + } +#endif + + /* Raise len to next SDIO block to eliminate tail command */ + if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { + u16 pad = bus->blocksize - (len % bus->blocksize); + if ((pad <= bus->roundup) && (pad < bus->blocksize)) + len += pad; + } else if (len % BRCMF_SDALIGN) { + len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); + } + + /* Some controllers have trouble with odd bytes -- round to even */ + if (forcealign && (len & (ALIGNMENT - 1))) + len = roundup(len, ALIGNMENT); + + do { + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, + len, pkt); + bus->f2txdata++; + + if (ret < 0) { + /* On failure, abort the command + and terminate the frame */ + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); + bus->tx_sderrs++; + + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, + NULL); + bus->f1regdata++; + + for (i = 0; i < 3; i++) { + u8 hi, lo; + hi = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCHI, + NULL); + lo = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCLO, + NULL); + bus->f1regdata += 2; + if ((hi == 0) && (lo == 0)) + break; + } + + } + if (ret == 0) + bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; + + } while ((ret < 0) && retrydata && retries++ < TXRETRIES); + +done: + /* restore pkt buffer pointer before calling tx complete routine */ + skb_pull(pkt, SDPCM_HDRLEN + pad); + brcmf_sdbrcm_sdunlock(bus); + brcmf_txcomplete(bus->drvr, pkt, ret != 0); + brcmf_sdbrcm_sdlock(bus); + + if (free_pkt) + brcmu_pkt_buf_free_skb(pkt); + + return ret; +} + +static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) +{ + struct sk_buff *pkt; + u32 intstatus = 0; + uint retries = 0; + int ret = 0, prec_out; + uint cnt = 0; + uint datalen; + u8 tx_prec_map; + + struct brcmf_pub *drvr = bus->drvr; + + brcmf_dbg(TRACE, "Enter\n"); + + tx_prec_map = ~bus->flowcontrol; + + /* Send frames until the limit or some other event */ + for (cnt = 0; (cnt < maxframes) && data_ok(bus); cnt++) { + spin_lock_bh(&bus->txqlock); + pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); + if (pkt == NULL) { + spin_unlock_bh(&bus->txqlock); + break; + } + spin_unlock_bh(&bus->txqlock); + datalen = pkt->len - SDPCM_HDRLEN; + + ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); + if (ret) + bus->drvr->tx_errors++; else - brcmf_dbg(INFO, "Dongle ready, protocol version %d\n", - bus->sdpcm_ver); + bus->drvr->dstats.tx_bytes += datalen; + + /* In poll mode, need to check for other events */ + if (!bus->intr && cnt) { + /* Check device status, signal pending interrupt */ + r_sdreg32(bus, &intstatus, + offsetof(struct sdpcmd_regs, intstatus), + &retries); + bus->f2txdata++; + if (brcmf_sdcard_regfail(bus->sdiodev)) + break; + if (intstatus & bus->hostintmask) + bus->ipend = true; + } } - /* - * Flow Control has been moved into the RX headers and this out of band - * method isn't used any more. - * remaining backward compatible with older dongles. - */ - if (hmb_data & HMB_DATA_FC) { - fcbits = (hmb_data & HMB_DATA_FCDATA_MASK) >> - HMB_DATA_FCDATA_SHIFT; + /* Deflow-control stack if needed */ + if (drvr->up && (drvr->busstate == BRCMF_BUS_DATA) && + drvr->txoff && (pktq_len(&bus->txq) < TXLOW)) + brcmf_txflowcontrol(drvr, 0, OFF); - if (fcbits & ~bus->flowcontrol) - bus->fc_xoff++; - - if (bus->flowcontrol & ~fcbits) - bus->fc_xon++; - - bus->fc_rcvd++; - bus->flowcontrol = fcbits; - } - - /* Shouldn't be any others */ - if (hmb_data & ~(HMB_DATA_DEVREADY | - HMB_DATA_NAKHANDLED | - HMB_DATA_FC | - HMB_DATA_FWREADY | - HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) - brcmf_dbg(ERROR, "Unknown mailbox data content: 0x%02x\n", - hmb_data); - - return intstatus; + return cnt; } static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) @@ -3769,559 +2772,1026 @@ clkwait: return resched; } -void brcmf_sdbrcm_isr(void *arg) +static int brcmf_sdbrcm_dpc_thread(void *data) { - struct brcmf_bus *bus = (struct brcmf_bus *) arg; + struct brcmf_bus *bus = (struct brcmf_bus *) data; - brcmf_dbg(TRACE, "Enter\n"); - - if (!bus) { - brcmf_dbg(ERROR, "bus is null pointer, exiting\n"); - return; + /* This thread doesn't need any user-level access, + * so get rid of all our resources + */ + if (brcmf_dpc_prio > 0) { + struct sched_param param; + param.sched_priority = (brcmf_dpc_prio < MAX_RT_PRIO) ? + brcmf_dpc_prio : (MAX_RT_PRIO - 1); + sched_setscheduler(current, SCHED_FIFO, ¶m); } - if (bus->drvr->busstate == BRCMF_BUS_DOWN) { - brcmf_dbg(ERROR, "bus is down. we have nothing to do\n"); - return; - } - /* Count the interrupt call */ - bus->intrcount++; - bus->ipend = true; - - /* Shouldn't get this interrupt if we're sleeping? */ - if (bus->sleeping) { - brcmf_dbg(ERROR, "INTERRUPT WHILE SLEEPING??\n"); - return; - } - - /* Disable additional interrupts (is this needed now)? */ - if (!bus->intr) - brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); - - bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); -} - -static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) -{ - struct brcmf_bus *bus; - - brcmf_dbg(TIMER, "Enter\n"); - - bus = drvr->bus; - - if (bus->drvr->dongle_reset) - return false; - - /* Ignore the timer if simulating bus down */ - if (bus->sleeping) - return false; - - brcmf_sdbrcm_sdlock(bus); - - /* Poll period: check device if appropriate. */ - if (bus->poll && (++bus->polltick >= bus->pollrate)) { - u32 intstatus = 0; - - /* Reset poll tick */ - bus->polltick = 0; - - /* Check device if no interrupts */ - if (!bus->intr || (bus->intrcount == bus->lastintrs)) { - - if (!bus->dpc_sched) { - u8 devpend; - devpend = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_0, SDIO_CCCR_INTx, - NULL); - intstatus = - devpend & (INTR_STATUS_FUNC1 | - INTR_STATUS_FUNC2); - } - - /* If there is something, make like the ISR and - schedule the DPC */ - if (intstatus) { - bus->pollcnt++; - bus->ipend = true; - - bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); - - } - } - - /* Update interrupt tracking */ - bus->lastintrs = bus->intrcount; - } -#ifdef BCMDBG - /* Poll for console output periodically */ - if (drvr->busstate == BRCMF_BUS_DATA && brcmf_console_ms != 0) { - bus->console.count += brcmf_watchdog_ms; - if (bus->console.count >= brcmf_console_ms) { - bus->console.count -= brcmf_console_ms; - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - if (brcmf_sdbrcm_readconsole(bus) < 0) - brcmf_console_ms = 0; /* On error, - stop trying */ - } - } -#endif /* BCMDBG */ - - /* On idle timeout clear activity flag and/or turn off clock */ - if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { - if (++bus->idlecount >= bus->idletime) { - bus->idlecount = 0; - if (bus->activity) { - bus->activity = false; - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + allow_signal(SIGTERM); + /* Run until signal received */ + while (1) { + if (kthread_should_stop()) + break; + if (!wait_for_completion_interruptible(&bus->dpc_wait)) { + /* Call bus dpc unless it indicated down + (then clean stop) */ + if (bus->drvr->busstate != BRCMF_BUS_DOWN) { + if (brcmf_sdbrcm_dpc(bus)) + complete(&bus->dpc_wait); } else { - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); + brcmf_sdbrcm_bus_stop(bus, true); } - } + } else + break; + } + return 0; +} + +static void brcmf_sdbrcm_dpc_tasklet(unsigned long data) +{ + struct brcmf_bus *bus = (struct brcmf_bus *) data; + + /* Call bus dpc unless it indicated down (then clean stop) */ + if (bus->drvr->busstate != BRCMF_BUS_DOWN) { + if (brcmf_sdbrcm_dpc(bus)) + tasklet_schedule(&bus->tasklet); + } else + brcmf_sdbrcm_bus_stop(bus, true); +} + +static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus) +{ + if (bus->dpc_tsk) { + complete(&bus->dpc_wait); + return; } - brcmf_sdbrcm_sdunlock(bus); - - return bus->ipend; + tasklet_schedule(&bus->tasklet); } -static bool brcmf_sdbrcm_chipmatch(u16 chipid) +int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) { - if (chipid == BCM4329_CHIP_ID) - return true; - return false; -} - -void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, struct brcmf_sdio_dev *sdiodev) -{ - int ret; - struct brcmf_bus *bus; - - /* Init global variables at run-time, not as part of the declaration. - * This is required to support init/de-init of the driver. - * Initialization - * of globals as part of the declaration results in non-deterministic - * behavior since the value of the globals may be different on the - * first time that the driver is initialized vs subsequent - * initializations. - */ - brcmf_txbound = BRCMF_TXBOUND; - brcmf_rxbound = BRCMF_RXBOUND; - brcmf_alignctl = true; - brcmf_readahead = true; - retrydata = false; - brcmf_dongle_memsize = 0; - brcmf_txminmax = BRCMF_TXMINMAX; - - forcealign = true; - - brcmf_c_init(); + int ret = -EBADE; + uint datalen, prec; brcmf_dbg(TRACE, "Enter\n"); - /* We make an assumption about address window mappings: - * regsva == SI_ENUM_BASE*/ + datalen = pkt->len; - /* Allocate private bus interface state */ - bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); - if (!bus) { - brcmf_dbg(ERROR, "kmalloc of struct dhd_bus failed\n"); - goto fail; - } - bus->sdiodev = sdiodev; - sdiodev->bus = bus; - bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; - bus->usebufpool = false; /* Use bufpool if allocated, - else use locally malloced rxbuf */ + /* Add space for the header */ + skb_push(pkt, SDPCM_HDRLEN); + /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ - /* attempt to attach to the dongle */ - if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_attach failed\n"); - goto fail; - } + prec = prio2prec((pkt->priority & PRIOMASK)); - spin_lock_init(&bus->txqlock); - init_waitqueue_head(&bus->ctrl_wait); - init_waitqueue_head(&bus->ioctl_resp_wait); + /* Check for existing queue, current flow-control, + pending event, or pending clock */ + if (brcmf_deferred_tx || bus->fcstate || pktq_len(&bus->txq) + || bus->dpc_sched || (!data_ok(bus)) + || (bus->flowcontrol & NBITVAL(prec)) + || (bus->clkstate != CLK_AVAIL)) { + brcmf_dbg(TRACE, "deferring pktq len %d\n", + pktq_len(&bus->txq)); + bus->fcqueued++; - /* Set up the watchdog timer */ - init_timer(&bus->timer); - bus->timer.data = (unsigned long)bus; - bus->timer.function = brcmf_sdbrcm_watchdog; - - /* Initialize thread based operation and lock */ - if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0)) { - bus->threads_only = true; - sema_init(&bus->sdsem, 1); - } else { - bus->threads_only = false; - spin_lock_init(&bus->sdlock); - } - - if (brcmf_dpc_prio >= 0) { - /* Initialize watchdog thread */ - init_completion(&bus->watchdog_wait); - bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, - bus, "brcmf_watchdog"); - if (IS_ERR(bus->watchdog_tsk)) { - printk(KERN_WARNING - "brcmf_watchdog thread failed to start\n"); - bus->watchdog_tsk = NULL; + /* Priority based enq */ + spin_lock_bh(&bus->txqlock); + if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == + false) { + skb_pull(pkt, SDPCM_HDRLEN); + brcmf_txcomplete(bus->drvr, pkt, false); + brcmu_pkt_buf_free_skb(pkt); + brcmf_dbg(ERROR, "out of bus->txq !!!\n"); + ret = -ENOSR; + } else { + ret = 0; } - } else - bus->watchdog_tsk = NULL; + spin_unlock_bh(&bus->txqlock); - /* Set up the bottom half handler */ - if (brcmf_dpc_prio >= 0) { - /* Initialize DPC thread */ - init_completion(&bus->dpc_wait); - bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, - bus, "brcmf_dpc"); - if (IS_ERR(bus->dpc_tsk)) { - printk(KERN_WARNING - "brcmf_dpc thread failed to start\n"); - bus->dpc_tsk = NULL; - } - } else { - tasklet_init(&bus->tasklet, brcmf_sdbrcm_dpc_tasklet, - (unsigned long)bus); - bus->dpc_tsk = NULL; - } - - /* Attach to the brcmf/OS/network interface */ - bus->drvr = brcmf_attach(bus, SDPCM_RESERVE); - if (!bus->drvr) { - brcmf_dbg(ERROR, "brcmf_attach failed\n"); - goto fail; - } - - /* Allocate buffers */ - if (!(brcmf_sdbrcm_probe_malloc(bus))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_malloc failed\n"); - goto fail; - } - - if (!(brcmf_sdbrcm_probe_init(bus))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_init failed\n"); - goto fail; - } - - /* Register interrupt callback, but mask it (not operational yet). */ - brcmf_dbg(INTR, "disable SDIO interrupts (not interested yet)\n"); - ret = brcmf_sdcard_intr_reg(bus->sdiodev); - if (ret != 0) { - brcmf_dbg(ERROR, "FAILED: sdcard_intr_reg returned %d\n", ret); - goto fail; - } - brcmf_dbg(INTR, "registered SDIO interrupt function ok\n"); - - brcmf_dbg(INFO, "completed!!\n"); - - /* if firmware path present try to download and bring up bus */ - ret = brcmf_bus_start(bus->drvr); - if (ret != 0) { - if (ret == -ENOLINK) { - brcmf_dbg(ERROR, "dongle is not responding\n"); - goto fail; - } - } - /* Ok, have the per-port tell the stack we're open for business */ - if (brcmf_net_attach(bus->drvr, 0) != 0) { - brcmf_dbg(ERROR, "Net attach failed!!\n"); - goto fail; - } - - return bus; - -fail: - brcmf_sdbrcm_release(bus); - return NULL; -} - -static bool -brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) -{ - u8 clkctl = 0; - int err = 0; - int reg_addr; - u32 reg_val; - - bus->alp_only = true; - - /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) - brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); + if (pktq_len(&bus->txq) >= TXHI) + brcmf_txflowcontrol(bus->drvr, 0, ON); #ifdef BCMDBG - printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", - brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); - -#endif /* BCMDBG */ - - /* - * Force PLL off until brcmf_sdbrcm_chip_attach() - * programs PLL control regs - */ - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - BRCMF_INIT_CLKCTL1, &err); - if (!err) - clkctl = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - - if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { - brcmf_dbg(ERROR, "ChipClkCSR access: err %d wrote 0x%02x read 0x%02x\n", - err, BRCMF_INIT_CLKCTL1, clkctl); - goto fail; - } - - if (brcmf_sdbrcm_chip_attach(bus, regsva)) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); - goto fail; - } - - if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) { - brcmf_dbg(ERROR, "unsupported chip: 0x%04x\n", bus->ci->chip); - goto fail; - } - - brcmf_sdbrcm_sdiod_drive_strength_init(bus, brcmf_sdiod_drive_strength); - - /* Get info on the ARM and SOCRAM cores... */ - brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->armcorebase, sbidhigh), 4); - bus->orig_ramsize = bus->ci->ramsize; - if (!(bus->orig_ramsize)) { - brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); - goto fail; - } - bus->ramsize = bus->orig_ramsize; - if (brcmf_dongle_memsize) - brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); - - brcmf_dbg(ERROR, "DHD: dongle ram size is set to %d(orig %d)\n", - bus->ramsize, bus->orig_ramsize); - - /* Set core control so an SDIO reset does a backplane reset */ - reg_addr = bus->ci->buscorebase + - offsetof(struct sdpcmd_regs, corecontrol); - reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); - brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), - reg_val | CC_BPRESEN); - - brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); - - /* Locate an appropriately-aligned portion of hdrbuf */ - bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], - BRCMF_SDALIGN); - - /* Set the poll and/or interrupt flags */ - bus->intr = (bool) brcmf_intr; - bus->poll = (bool) brcmf_poll; - if (bus->poll) - bus->pollrate = 1; - - return true; - -fail: - return false; -} - -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr->maxctl) { - bus->rxblen = - roundup((bus->drvr->maxctl + SDPCM_HDRLEN), - ALIGNMENT) + BRCMF_SDALIGN; - bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC); - if (!(bus->rxbuf)) { - brcmf_dbg(ERROR, "kmalloc of %d-byte rxbuf failed\n", - bus->rxblen); - goto fail; + if (pktq_plen(&bus->txq, prec) > qcount[prec]) + qcount[prec] = pktq_plen(&bus->txq, prec); +#endif + /* Schedule DPC if needed to send queued packet(s) */ + if (brcmf_deferred_tx && !bus->dpc_sched) { + bus->dpc_sched = true; + brcmf_sdbrcm_sched_dpc(bus); } + } else { + /* Lock: we're about to use shared data/code (and SDIO) */ + brcmf_sdbrcm_sdlock(bus); + + /* Otherwise, send it now */ + bus_wake(bus); + /* Make sure back plane ht clk is on, no pending allowed */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); + + brcmf_dbg(TRACE, "calling txpkt\n"); + ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); + if (ret) + bus->drvr->tx_errors++; + else + bus->drvr->dstats.tx_bytes += datalen; + + if (bus->idletime == BRCMF_IDLE_IMMEDIATE && + !bus->dpc_sched) { + bus->activity = false; + brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); + } + + brcmf_sdbrcm_sdunlock(bus); } - /* Allocate buffer to receive glomed packet */ - bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC); - if (!(bus->databuf)) { - brcmf_dbg(ERROR, "kmalloc of %d-byte databuf failed\n", - MAX_DATA_BUF); - /* release rxbuf which was already located as above */ - if (!bus->rxblen) - kfree(bus->rxbuf); - goto fail; - } - - /* Align the buffer */ - if ((unsigned long)bus->databuf % BRCMF_SDALIGN) - bus->dataptr = bus->databuf + (BRCMF_SDALIGN - - ((unsigned long)bus->databuf % BRCMF_SDALIGN)); - else - bus->dataptr = bus->databuf; - - return true; - -fail: - return false; -} - -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - bus->drvr->busstate = BRCMF_BUS_DOWN; - bus->sleeping = false; - bus->rxflow = false; - - /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - - /* ...and initialize clock/power states */ - bus->clkstate = CLK_SDONLY; - bus->idletime = (s32) brcmf_idletime; - bus->idleclock = BRCMF_IDLE_ACTIVE; - - /* Query the F2 block size, set roundup accordingly */ - bus->blocksize = bus->sdiodev->func[2]->cur_blksize; - bus->roundup = min(max_roundup, bus->blocksize); - - /* bus module does not support packet chaining */ - bus->use_rxchain = false; - bus->sd_rxchain = false; - - return true; -} - -static bool -brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) -{ - bool ret; - - /* Download the firmware */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - ret = _brcmf_sdbrcm_download_firmware(bus) == 0; - - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - return ret; } -/* Detach and free everything */ -static void brcmf_sdbrcm_release(struct brcmf_bus *bus) +static int +brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, + uint size) { - brcmf_dbg(TRACE, "Enter\n"); + int bcmerror = 0; + u32 sdaddr; + uint dsize; - if (bus) { - /* De-register interrupt handler */ - brcmf_sdcard_intr_dereg(bus->sdiodev); + /* Determine initial transfer parameters */ + sdaddr = address & SBSDIO_SB_OFT_ADDR_MASK; + if ((sdaddr + size) & SBSDIO_SBWINDOW_MASK) + dsize = (SBSDIO_SB_OFT_ADDR_LIMIT - sdaddr); + else + dsize = size; - if (bus->drvr) { - brcmf_detach(bus->drvr); - brcmf_sdbrcm_release_dongle(bus); - bus->drvr = NULL; + /* Set the backplane window to include the start address */ + bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, address); + if (bcmerror) { + brcmf_dbg(ERROR, "window change failed\n"); + goto xfer_done; + } + + /* Do the transfer(s) */ + while (size) { + brcmf_dbg(INFO, "%s %d bytes at offset 0x%08x in window 0x%08x\n", + write ? "write" : "read", dsize, + sdaddr, address & SBSDIO_SBWINDOW_MASK); + bcmerror = brcmf_sdcard_rwdata(bus->sdiodev, write, + sdaddr, data, dsize); + if (bcmerror) { + brcmf_dbg(ERROR, "membytes transfer failed\n"); + break; } - brcmf_sdbrcm_release_malloc(bus); - - kfree(bus); + /* Adjust for next transfer (if any) */ + size -= dsize; + if (size) { + data += dsize; + address += dsize; + bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, + address); + if (bcmerror) { + brcmf_dbg(ERROR, "window change failed\n"); + break; + } + sdaddr = 0; + dsize = min_t(uint, SBSDIO_SB_OFT_ADDR_LIMIT, size); + } } - brcmf_dbg(TRACE, "Disconnected\n"); +xfer_done: + /* Return the window to backplane enumeration space for core access */ + if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, bus->sdiodev->sbwad)) + brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", + bus->sdiodev->sbwad); + + return bcmerror; } -static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) +#ifdef BCMDBG +static int +brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) { + u32 addr; + int rv; + + /* Read last word in memory to determine address of + sdpcm_shared structure */ + rv = brcmf_sdbrcm_membytes(bus, false, bus->ramsize - 4, (u8 *)&addr, + 4); + if (rv < 0) + return rv; + + addr = le32_to_cpu(addr); + + brcmf_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr); + + /* + * Check if addr is valid. + * NVRAM length at the end of memory should have been overwritten. + */ + if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) { + brcmf_dbg(ERROR, "address (0x%08x) of sdpcm_shared invalid\n", + addr); + return -EBADE; + } + + /* Read rte_shared structure */ + rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *) sh, + sizeof(struct sdpcm_shared)); + if (rv < 0) + return rv; + + /* Endianness */ + sh->flags = le32_to_cpu(sh->flags); + sh->trap_addr = le32_to_cpu(sh->trap_addr); + sh->assert_exp_addr = le32_to_cpu(sh->assert_exp_addr); + sh->assert_file_addr = le32_to_cpu(sh->assert_file_addr); + sh->assert_line = le32_to_cpu(sh->assert_line); + sh->console_addr = le32_to_cpu(sh->console_addr); + sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr); + + if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { + brcmf_dbg(ERROR, "sdpcm_shared version %d in brcmf is different than sdpcm_shared version %d in dongle\n", + SDPCM_SHARED_VERSION, + sh->flags & SDPCM_SHARED_VERSION_MASK); + return -EBADE; + } + + return 0; +} + +static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) +{ + int ret = 0; + int size; /* Full mem size */ + int start = 0; /* Start address */ + int read_size = 0; /* Read size of each iteration */ + u8 *buf = NULL, *databuf = NULL; + + /* Get full mem size */ + size = bus->ramsize; + buf = kmalloc(size, GFP_ATOMIC); + if (!buf) { + brcmf_dbg(ERROR, "Out of memory (%d bytes)\n", size); + return -1; + } + + /* Read mem content */ + printk(KERN_DEBUG "Dump dongle memory"); + databuf = buf; + while (size) { + read_size = min(MEMBLOCK, size); + ret = brcmf_sdbrcm_membytes(bus, false, start, databuf, + read_size); + if (ret) { + brcmf_dbg(ERROR, "Error membytes %d\n", ret); + kfree(buf); + return -1; + } + printk("."); + + /* Decrement size and increment start address */ + size -= read_size; + start += read_size; + databuf += read_size; + } + printk(KERN_DEBUG "Done\n"); + + /* free buf before return !!! */ + if (brcmf_write_to_file(bus->drvr, buf, bus->ramsize)) { + brcmf_dbg(ERROR, "Error writing to files\n"); + return -1; + } + + /* buf free handled in brcmf_write_to_file, not here */ + return 0; +} + +static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) +{ + int bcmerror = 0; + uint msize = 512; + char *mbuffer = NULL; + uint maxstrlen = 256; + char *str = NULL; + struct brcmf_trap tr; + struct sdpcm_shared sdpcm_shared; + struct brcmu_strbuf strbuf; + brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr && bus->drvr->dongle_reset) - return; + if (data == NULL) { + /* + * Called after a rx ctrl timeout. "data" is NULL. + * allocate memory to trace the trap or assert. + */ + size = msize; + mbuffer = data = kmalloc(msize, GFP_ATOMIC); + if (mbuffer == NULL) { + brcmf_dbg(ERROR, "kmalloc(%d) failed\n", msize); + bcmerror = -ENOMEM; + goto done; + } + } - kfree(bus->rxbuf); - bus->rxctl = bus->rxbuf = NULL; + str = kmalloc(maxstrlen, GFP_ATOMIC); + if (str == NULL) { + brcmf_dbg(ERROR, "kmalloc(%d) failed\n", maxstrlen); + bcmerror = -ENOMEM; + goto done; + } + + bcmerror = brcmf_sdbrcm_readshared(bus, &sdpcm_shared); + if (bcmerror < 0) + goto done; + + brcmu_binit(&strbuf, data, size); + + brcmu_bprintf(&strbuf, + "msgtrace address : 0x%08X\nconsole address : 0x%08X\n", + sdpcm_shared.msgtrace_addr, sdpcm_shared.console_addr); + + if ((sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) == 0) + /* NOTE: Misspelled assert is intentional - DO NOT FIX. + * (Avoids conflict with real asserts for programmatic + * parsing of output.) + */ + brcmu_bprintf(&strbuf, "Assrt not built in dongle\n"); + + if ((sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) == + 0) { + /* NOTE: Misspelled assert is intentional - DO NOT FIX. + * (Avoids conflict with real asserts for programmatic + * parsing of output.) + */ + brcmu_bprintf(&strbuf, "No trap%s in dongle", + (sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) + ? "/assrt" : ""); + } else { + if (sdpcm_shared.flags & SDPCM_SHARED_ASSERT) { + /* Download assert */ + brcmu_bprintf(&strbuf, "Dongle assert"); + if (sdpcm_shared.assert_exp_addr != 0) { + str[0] = '\0'; + bcmerror = brcmf_sdbrcm_membytes(bus, false, + sdpcm_shared.assert_exp_addr, + (u8 *) str, maxstrlen); + if (bcmerror < 0) + goto done; + + str[maxstrlen - 1] = '\0'; + brcmu_bprintf(&strbuf, " expr \"%s\"", str); + } + + if (sdpcm_shared.assert_file_addr != 0) { + str[0] = '\0'; + bcmerror = brcmf_sdbrcm_membytes(bus, false, + sdpcm_shared.assert_file_addr, + (u8 *) str, maxstrlen); + if (bcmerror < 0) + goto done; + + str[maxstrlen - 1] = '\0'; + brcmu_bprintf(&strbuf, " file \"%s\"", str); + } + + brcmu_bprintf(&strbuf, " line %d ", + sdpcm_shared.assert_line); + } + + if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) { + bcmerror = brcmf_sdbrcm_membytes(bus, false, + sdpcm_shared.trap_addr, (u8 *)&tr, + sizeof(struct brcmf_trap)); + if (bcmerror < 0) + goto done; + + brcmu_bprintf(&strbuf, + "Dongle trap type 0x%x @ epc 0x%x, cpsr 0x%x, spsr 0x%x, sp 0x%x," + "lp 0x%x, rpc 0x%x Trap offset 0x%x, " + "r0 0x%x, r1 0x%x, r2 0x%x, r3 0x%x, r4 0x%x, r5 0x%x, r6 0x%x, r7 0x%x\n", + tr.type, tr.epc, tr.cpsr, tr.spsr, tr.r13, + tr.r14, tr.pc, sdpcm_shared.trap_addr, + tr.r0, tr.r1, tr.r2, tr.r3, tr.r4, tr.r5, + tr.r6, tr.r7); + } + } + + if (sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) + brcmf_dbg(ERROR, "%s\n", strbuf.origbuf); + +#ifdef BCMDBG + if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) + /* Mem dump to a file on device */ + brcmf_sdbrcm_mem_dump(bus); + +#endif /* BCMDBG */ + +done: + kfree(mbuffer); + kfree(str); + + return bcmerror; +} + +#define CONSOLE_LINE_MAX 192 + +static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) +{ + struct brcmf_console *c = &bus->console; + u8 line[CONSOLE_LINE_MAX], ch; + u32 n, idx, addr; + int rv; + + /* Don't do anything until FWREADY updates console address */ + if (bus->console_addr == 0) + return 0; + + /* Read console log struct */ + addr = bus->console_addr + offsetof(struct rte_console, log); + rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&c->log, + sizeof(c->log)); + if (rv < 0) + return rv; + + /* Allocate console buffer (one time only) */ + if (c->buf == NULL) { + c->bufsize = le32_to_cpu(c->log.buf_size); + c->buf = kmalloc(c->bufsize, GFP_ATOMIC); + if (c->buf == NULL) + return -ENOMEM; + } + + idx = le32_to_cpu(c->log.idx); + + /* Protect against corrupt value */ + if (idx > c->bufsize) + return -EBADE; + + /* Skip reading the console buffer if the index pointer + has not moved */ + if (idx == c->last) + return 0; + + /* Read the console buffer */ + addr = le32_to_cpu(c->log.buf); + rv = brcmf_sdbrcm_membytes(bus, false, addr, c->buf, c->bufsize); + if (rv < 0) + return rv; + + while (c->last != idx) { + for (n = 0; n < CONSOLE_LINE_MAX - 2; n++) { + if (c->last == idx) { + /* This would output a partial line. + * Instead, back up + * the buffer pointer and output this + * line next time around. + */ + if (c->last >= n) + c->last -= n; + else + c->last = c->bufsize - n; + goto break2; + } + ch = c->buf[c->last]; + c->last = (c->last + 1) % c->bufsize; + if (ch == '\n') + break; + line[n] = ch; + } + + if (n > 0) { + if (line[n - 1] == '\r') + n--; + line[n] = 0; + printk(KERN_DEBUG "CONSOLE: %s\n", line); + } + } +break2: + + return 0; +} +#endif /* BCMDBG */ + +int +brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) +{ + u8 *frame; + u16 len; + u32 swheader; + uint retries = 0; + u8 doff = 0; + int ret = -1; + int i; + + brcmf_dbg(TRACE, "Enter\n"); + + if (bus->drvr->dongle_reset) + return -EIO; + + /* Back the pointer to make a room for bus header */ + frame = msg - SDPCM_HDRLEN; + len = (msglen += SDPCM_HDRLEN); + + /* Add alignment padding (optional for ctl frames) */ + if (brcmf_alignctl) { + doff = ((unsigned long)frame % BRCMF_SDALIGN); + if (doff) { + frame -= doff; + len += doff; + msglen += doff; + memset(frame, 0, doff + SDPCM_HDRLEN); + } + /* precondition: doff < BRCMF_SDALIGN */ + } + doff += SDPCM_HDRLEN; + + /* Round send length to next SDIO block */ + if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { + u16 pad = bus->blocksize - (len % bus->blocksize); + if ((pad <= bus->roundup) && (pad < bus->blocksize)) + len += pad; + } else if (len % BRCMF_SDALIGN) { + len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); + } + + /* Satisfy length-alignment requirements */ + if (forcealign && (len & (ALIGNMENT - 1))) + len = roundup(len, ALIGNMENT); + + /* precondition: IS_ALIGNED((unsigned long)frame, 2) */ + + /* Need to lock here to protect txseq and SDIO tx calls */ + brcmf_sdbrcm_sdlock(bus); + + bus_wake(bus); + + /* Make sure backplane clock is on */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + + /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ + *(u16 *) frame = cpu_to_le16((u16) msglen); + *(((u16 *) frame) + 1) = cpu_to_le16(~msglen); + + /* Software tag: channel, sequence number, data offset */ + swheader = + ((SDPCM_CONTROL_CHANNEL << SDPCM_CHANNEL_SHIFT) & + SDPCM_CHANNEL_MASK) + | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & + SDPCM_DOFFSET_MASK); + put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); + put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); + + if (!data_ok(bus)) { + brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", + bus->tx_max, bus->tx_seq); + bus->ctrl_frame_stat = true; + /* Send from dpc */ + bus->ctrl_frame_buf = frame; + bus->ctrl_frame_len = len; + + brcmf_sdbrcm_wait_for_event(bus, &bus->ctrl_frame_stat); + + if (bus->ctrl_frame_stat == false) { + brcmf_dbg(INFO, "ctrl_frame_stat == false\n"); + ret = 0; + } else { + brcmf_dbg(INFO, "ctrl_frame_stat == true\n"); + ret = -1; + } + } + + if (ret == -1) { +#ifdef BCMDBG + if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { + printk(KERN_DEBUG "Tx Frame:\n"); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, + frame, len); + } else if (BRCMF_HDRS_ON()) { + printk(KERN_DEBUG "TxHdr:\n"); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, + frame, min_t(u16, len, 16)); + } +#endif + + do { + bus->ctrl_frame_stat = false; + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, len, NULL); + + if (ret < 0) { + /* On failure, abort the command and + terminate the frame */ + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); + bus->tx_sderrs++; + + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); + + brcmf_sdcard_cfg_write(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_FRAMECTRL, + SFC_WF_TERM, NULL); + bus->f1regdata++; + + for (i = 0; i < 3; i++) { + u8 hi, lo; + hi = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCHI, + NULL); + lo = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCLO, + NULL); + bus->f1regdata += 2; + if ((hi == 0) && (lo == 0)) + break; + } + + } + if (ret == 0) + bus->tx_seq = + (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; + + } while ((ret < 0) && retries++ < TXRETRIES); + } + + if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { + bus->activity = false; + brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); + } + + brcmf_sdbrcm_sdunlock(bus); + + if (ret) + bus->drvr->tx_ctlerrs++; + else + bus->drvr->tx_ctlpkts++; + + return ret ? -EIO : 0; +} + +int +brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) +{ + int timeleft; + uint rxlen = 0; + bool pending; + + brcmf_dbg(TRACE, "Enter\n"); + + if (bus->drvr->dongle_reset) + return -EIO; + + /* Wait until control frame is available */ + timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); + + brcmf_sdbrcm_sdlock(bus); + rxlen = bus->rxlen; + memcpy(msg, bus->rxctl, min(msglen, rxlen)); bus->rxlen = 0; + brcmf_sdbrcm_sdunlock(bus); - kfree(bus->databuf); - bus->databuf = NULL; -} - -static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr && bus->drvr->dongle_reset) - return; - - if (bus->ci) { - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - brcmf_sdbrcm_chip_detach(bus); - if (bus->vars && bus->varsz) - kfree(bus->vars); - bus->vars = NULL; + if (rxlen) { + brcmf_dbg(CTL, "resumed on rxctl frame, got %d expected %d\n", + rxlen, msglen); + } else if (timeleft == 0) { + brcmf_dbg(ERROR, "resumed on timeout\n"); +#ifdef BCMDBG + brcmf_sdbrcm_sdlock(bus); + brcmf_sdbrcm_checkdied(bus, NULL, 0); + brcmf_sdbrcm_sdunlock(bus); +#endif /* BCMDBG */ + } else if (pending == true) { + brcmf_dbg(CTL, "cancelled\n"); + return -ERESTARTSYS; + } else { + brcmf_dbg(CTL, "resumed for unknown reason?\n"); +#ifdef BCMDBG + brcmf_sdbrcm_sdlock(bus); + brcmf_sdbrcm_checkdied(bus, NULL, 0); + brcmf_sdbrcm_sdunlock(bus); +#endif /* BCMDBG */ } - brcmf_dbg(TRACE, "Disconnected\n"); + if (rxlen) + bus->drvr->rx_ctlpkts++; + else + bus->drvr->rx_ctlerrs++; + + return rxlen ? (int)rxlen : -ETIMEDOUT; } -void brcmf_sdbrcm_disconnect(void *ptr) +static int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) { - struct brcmf_bus *bus = (struct brcmf_bus *)ptr; + int bcmerror = 0; brcmf_dbg(TRACE, "Enter\n"); - if (bus) - brcmf_sdbrcm_release(bus); + /* Basic sanity checks */ + if (bus->drvr->up) { + bcmerror = -EISCONN; + goto err; + } + if (!len) { + bcmerror = -EOVERFLOW; + goto err; + } - brcmf_dbg(TRACE, "Disconnected\n"); + /* Free the old ones and replace with passed variables */ + kfree(bus->vars); + + bus->vars = kmalloc(len, GFP_ATOMIC); + bus->varsz = bus->vars ? len : 0; + if (bus->vars == NULL) { + bcmerror = -ENOMEM; + goto err; + } + + /* Copy the passed variables, which should include the + terminating double-null */ + memcpy(bus->vars, arg, bus->varsz); +err: + return bcmerror; } -int brcmf_bus_register(void) +static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) { - brcmf_dbg(TRACE, "Enter\n"); + int bcmerror = 0; + u32 varsize; + u32 varaddr; + u8 *vbuffer; + u32 varsizew; +#ifdef BCMDBG + char *nvram_ularray; +#endif /* BCMDBG */ - /* Sanity check on the module parameters */ - do { - /* Both watchdog and DPC as tasklets are ok */ - if ((brcmf_watchdog_prio < 0) && (brcmf_dpc_prio < 0)) - break; + /* Even if there are no vars are to be written, we still + need to set the ramsize. */ + varsize = bus->varsz ? roundup(bus->varsz, 4) : 0; + varaddr = (bus->ramsize - 4) - varsize; - /* If both watchdog and DPC are threads, TX must be deferred */ - if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0) - && brcmf_deferred_tx) - break; + if (bus->vars) { + vbuffer = kzalloc(varsize, GFP_ATOMIC); + if (!vbuffer) + return -ENOMEM; - brcmf_dbg(ERROR, "Invalid module parameters.\n"); - return -EINVAL; - } while (0); + memcpy(vbuffer, bus->vars, bus->varsz); - return brcmf_sdio_register(); + /* Write the vars list */ + bcmerror = + brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); +#ifdef BCMDBG + /* Verify NVRAM bytes */ + brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); + nvram_ularray = kmalloc(varsize, GFP_ATOMIC); + if (!nvram_ularray) + return -ENOMEM; + + /* Upload image to verify downloaded contents. */ + memset(nvram_ularray, 0xaa, varsize); + + /* Read the vars list to temp buffer for comparison */ + bcmerror = + brcmf_sdbrcm_membytes(bus, false, varaddr, nvram_ularray, + varsize); + if (bcmerror) { + brcmf_dbg(ERROR, "error %d on reading %d nvram bytes at 0x%08x\n", + bcmerror, varsize, varaddr); + } + /* Compare the org NVRAM with the one read from RAM */ + if (memcmp(vbuffer, nvram_ularray, varsize)) + brcmf_dbg(ERROR, "Downloaded NVRAM image is corrupted\n"); + else + brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); + + kfree(nvram_ularray); +#endif /* BCMDBG */ + + kfree(vbuffer); + } + + /* adjust to the user specified RAM */ + brcmf_dbg(INFO, "Physical memory size: %d, usable memory size: %d\n", + bus->orig_ramsize, bus->ramsize); + brcmf_dbg(INFO, "Vars are at %d, orig varsize is %d\n", + varaddr, varsize); + varsize = ((bus->orig_ramsize - 4) - varaddr); + + /* + * Determine the length token: + * Varsize, converted to words, in lower 16-bits, checksum + * in upper 16-bits. + */ + if (bcmerror) { + varsizew = 0; + } else { + varsizew = varsize / 4; + varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF); + varsizew = cpu_to_le32(varsizew); + } + + brcmf_dbg(INFO, "New varsize is %d, length token=0x%08x\n", + varsize, varsizew); + + /* Write the length token to the last word */ + bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->orig_ramsize - 4), + (u8 *)&varsizew, 4); + + return bcmerror; } -void brcmf_bus_unregister(void) +static void +brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) { - brcmf_dbg(TRACE, "Enter\n"); + u32 regdata; - brcmf_sdio_unregister(); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + if (regdata & SBTML_RESET) + return; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { + /* + * set target reject and spin until busy is clear + * (preserve core-specific bits) + */ + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), + 4, regdata | SBTML_REJ); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + udelay(1); + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4) & + SBTMH_BUSY), 100000); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4); + if (regdata & SBTMH_BUSY) + brcmf_dbg(ERROR, "ARM core still busy\n"); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbidlow), 4); + if (regdata & SBIDL_INIT) { + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) | + SBIM_RJ; + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbimstate), 4, + regdata); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4); + udelay(1); + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) & + SBIM_BY), 100000); + } + + /* set reset and reject while enabling the clocks */ + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4, + (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | + SBTML_REJ | SBTML_RESET)); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + udelay(10); + + /* clear the initiator reject bit */ + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbidlow), 4); + if (regdata & SBIDL_INIT) { + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) & + ~SBIM_RJ; + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbimstate), 4, + regdata); + } + } + + /* leave reset and reject asserted */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SBTML_REJ | SBTML_RESET)); + udelay(1); } -struct device *brcmf_bus_get_device(struct brcmf_bus *bus) +static void +brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) { - return &bus->sdiodev->func[2]->dev; + u32 regdata; + + /* + * Must do the disable sequence first to work for + * arbitrary current core state. + */ + brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); + + /* + * Now do the initialization sequence. + * set reset while enabling the clock and + * forcing them on throughout the core + */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | + SBTML_RESET); + udelay(1); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4); + if (regdata & SBTMH_SERR) + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4, 0); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4); + if (regdata & (SBIM_IBE | SBIM_TO)) + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, + regdata & ~(SBIM_IBE | SBIM_TO)); + + /* clear reset and allow it to propagate throughout the core */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SICF_FGC << SBTML_SICF_SHIFT) | + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + udelay(1); + + /* leave clock enabled */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + udelay(1); } +static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) +{ + uint retries; + u32 regdata; + int bcmerror = 0; + + /* To enter download state, disable ARM and reset SOCRAM. + * To exit download state, simply reset ARM (default is RAM boot). + */ + if (enter) { + bus->alp_only = true; + + brcmf_sdbrcm_chip_disablecore(bus->sdiodev, + bus->ci->armcorebase); + + brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); + + /* Clear the top bit of memory */ + if (bus->ramsize) { + u32 zeros = 0; + brcmf_sdbrcm_membytes(bus, true, bus->ramsize - 4, + (u8 *)&zeros, 4); + } + } else { + regdata = brcmf_sdcard_reg_read(bus->sdiodev, + CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); + regdata &= (SBTML_RESET | SBTML_REJ_MASK | + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { + brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); + bcmerror = -EBADE; + goto fail; + } + + bcmerror = brcmf_sdbrcm_write_vars(bus); + if (bcmerror) { + brcmf_dbg(ERROR, "no vars written to RAM\n"); + bcmerror = 0; + } + + w_sdreg32(bus, 0xFFFFFFFF, + offsetof(struct sdpcmd_regs, intstatus), &retries); + + brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); + + /* Allow HT Clock now that the ARM is running. */ + bus->alp_only = false; + + bus->drvr->busstate = BRCMF_BUS_LOAD; + } +fail: + return bcmerror; +} + +static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) +{ + if (bus->firmware->size < bus->fw_ptr + len) + len = bus->firmware->size - bus->fw_ptr; + + memcpy(buf, &bus->firmware->data[bus->fw_ptr], len); + bus->fw_ptr += len; + return len; +} + +MODULE_FIRMWARE(BCM4329_FW_NAME); +MODULE_FIRMWARE(BCM4329_NV_NAME); + static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) { int offset = 0; @@ -4506,347 +3976,388 @@ err: return bcmerror; } - -static int -brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt) +static bool +brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) { - return brcmf_sdcard_send_buf - (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt); + bool ret; + + /* Download the firmware */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + + ret = _brcmf_sdbrcm_download_firmware(bus) == 0; + + brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); + + return ret; } -int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) +void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) { - int bcmerror = 0; - struct brcmf_bus *bus; - - bus = drvr->bus; - - if (flag == true) { - brcmf_sdbrcm_wd_timer(bus, 0); - if (!bus->drvr->dongle_reset) { - /* Expect app to have torn down any - connection before calling */ - /* Stop the bus, disable F2 */ - brcmf_sdbrcm_bus_stop(bus, false); - - /* Clean tx/rx buffer pointers, - detach from the dongle */ - brcmf_sdbrcm_release_dongle(bus); - - bus->drvr->dongle_reset = true; - bus->drvr->up = false; - - brcmf_dbg(TRACE, "WLAN OFF DONE\n"); - /* App can now remove power from device */ - } else - bcmerror = -EIO; - } else { - /* App must have restored power to device before calling */ - - brcmf_dbg(TRACE, " == WLAN ON ==\n"); - - if (bus->drvr->dongle_reset) { - /* Turn on WLAN */ - - /* Attempt to re-attach & download */ - if (brcmf_sdbrcm_probe_attach(bus, SI_ENUM_BASE)) { - /* Attempt to download binary to the dongle */ - if (brcmf_sdbrcm_probe_init(bus)) { - /* Re-init bus, enable F2 transfer */ - brcmf_sdbrcm_bus_init(bus->drvr, false); - - bus->drvr->dongle_reset = false; - bus->drvr->up = true; - - brcmf_dbg(TRACE, "WLAN ON DONE\n"); - } else - bcmerror = -EIO; - } else - bcmerror = -EIO; - } else { - bcmerror = -EISCONN; - brcmf_dbg(ERROR, "Set DEVRESET=false invoked when device is on\n"); - bcmerror = -EIO; - } - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); - } - return bcmerror; -} - -static int -brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u32 regs) -{ - u32 regdata; - - /* - * Get CC core rev - * Chipid is assume to be at offset 0 from regs arg - * For different chiptypes or old sdio hosts w/o chipcommon, - * other ways of recognition should be added here. - */ - ci->cccorebase = regs; - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, chipid), 4); - ci->chip = regdata & CID_ID_MASK; - ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; - - brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); - - /* Address of cores for new chips should be added here */ - switch (ci->chip) { - case BCM4329_CHIP_ID: - ci->buscorebase = BCM4329_CORE_BUS_BASE; - ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; - ci->armcorebase = BCM4329_CORE_ARM_BASE; - ci->ramsize = BCM4329_RAMSIZE; - break; - default: - brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); - return -ENODEV; - } - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->cccorebase, sbidhigh), 4); - ci->ccrev = SBCOREREV(regdata); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); - ci->pmurev = regdata & PCAP_REV_MASK; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscorerev = SBCOREREV(regdata); - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; - - brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); - - /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, capabilities), 4); - - return 0; -} - -static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) -{ - u32 regdata; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if (regdata & SBTML_RESET) - return; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { - /* - * set target reject and spin until busy is clear - * (preserve core-specific bits) - */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), - 4, regdata | SBTML_REJ); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4) & - SBTMH_BUSY), 100000); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_BUSY) - brcmf_dbg(ERROR, "ARM core still busy\n"); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) | - SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - SBIM_BY), 100000); - } - - /* set reset and reject while enabling the clocks */ - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4, - (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_REJ | SBTML_RESET)); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(10); - - /* clear the initiator reject bit */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - ~SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - } - } - - /* leave reset and reject asserted */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SBTML_REJ | SBTML_RESET)); - udelay(1); -} - -static int -brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) -{ - struct chip_info *ci; + u32 local_hostintmask; + u8 saveclk; + uint retries; int err; - u8 clkval, clkset; brcmf_dbg(TRACE, "Enter\n"); - /* alloc chip_info_t */ - ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); - if (NULL == ci) { - brcmf_dbg(ERROR, "malloc failed!\n"); - return -ENOMEM; + if (enforce_mutex) + brcmf_sdbrcm_sdlock(bus); + + bus_wake(bus); + + /* Enable clock for device interrupts */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + + if (bus->watchdog_tsk) { + send_sig(SIGTERM, bus->watchdog_tsk, 1); + kthread_stop(bus->watchdog_tsk); + bus->watchdog_tsk = NULL; } - /* bus/core/clk setup for register access */ - /* Try forcing SDIO core to do ALPAvail request only */ - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); - if (err) { - brcmf_dbg(ERROR, "error writing for HT off\n"); - goto fail; - } + if (bus->dpc_tsk) { + send_sig(SIGTERM, bus->dpc_tsk, 1); + kthread_stop(bus->dpc_tsk); + bus->dpc_tsk = NULL; + } else + tasklet_kill(&bus->tasklet); - /* If register supported, wait for ALPAvail and then force ALP */ - /* This may take up to 15 milliseconds */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, NULL); - if ((clkval & ~SBSDIO_AVBITS) == clkset) { - SPINWAIT(((clkval = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - NULL)), - !SBSDIO_ALPAV(clkval)), - PMU_MAX_TRANSITION_DLY); - if (!SBSDIO_ALPAV(clkval)) { - brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", - clkval); - err = -EBUSY; - goto fail; - } - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | - SBSDIO_FORCE_ALP; + /* Disable and clear interrupts at the chip level also */ + w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries); + local_hostintmask = bus->hostintmask; + bus->hostintmask = 0; + + /* Change our idea of bus state */ + bus->drvr->busstate = BRCMF_BUS_DOWN; + + /* Force clocks on backplane to be sure F2 interrupt propagates */ + saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, &err); + if (!err) { brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - clkset, &err); - udelay(65); - } else { - brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", - clkset, clkval); - err = -EACCES; - goto fail; + SBSDIO_FUNC1_CHIPCLKCSR, + (saveclk | SBSDIO_FORCE_HT), &err); } - - /* Also, disable the extra SDIO pull-ups */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); - - err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); if (err) - goto fail; + brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); - /* - * Make sure any on-chip ARM is off (in case strapping is wrong), - * or downloaded code was already running. - */ - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); - - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); - - /* Disable F2 to clear any intermediate frame state on the dongle */ + /* Turn off the bus (F2), free any pending packets */ + brcmf_dbg(INTR, "disable SDIO interrupts\n"); brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); + SDIO_FUNC_ENABLE_1, NULL); - /* WAR: cmd52 backplane read so core HW will drop ALPReq */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - 0, NULL); + /* Clear any pending interrupts now that F2 is disabled */ + w_sdreg32(bus, local_hostintmask, + offsetof(struct sdpcmd_regs, intstatus), &retries); - /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); + /* Turn off the backplane clock (only) */ + brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - bus->ci = ci; - return 0; -fail: - bus->ci = NULL; - kfree(ci); - return err; + /* Clear the data packet queues */ + brcmu_pktq_flush(&bus->txq, true, NULL, NULL); + + /* Clear any held glomming stuff */ + if (bus->glomd) + brcmu_pkt_buf_free_skb(bus->glomd); + + if (bus->glom) + brcmu_pkt_buf_free_skb(bus->glom); + + bus->glom = bus->glomd = NULL; + + /* Clear rx control and wake any waiters */ + bus->rxlen = 0; + brcmf_sdbrcm_ioctl_resp_wake(bus); + + /* Reset some F2 state stuff */ + bus->rxskip = false; + bus->tx_seq = bus->rx_seq = 0; + + if (enforce_mutex) + brcmf_sdbrcm_sdunlock(bus); } -static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) +int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) { - u32 regdata; + struct brcmf_bus *bus = drvr->bus; + unsigned long timeout; + uint retries = 0; + u8 ready, enable; + int err, ret = 0; + u8 saveclk; - /* - * Must do the disable sequence first to work for - * arbitrary current core state. - */ - brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); + brcmf_dbg(TRACE, "Enter\n"); - /* - * Now do the initialization sequence. - * set reset while enabling the clock and - * forcing them on throughout the core - */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_RESET); - udelay(1); + /* try to download image and nvram to the dongle */ + if (drvr->busstate == BRCMF_BUS_DOWN) { + if (!(brcmf_sdbrcm_download_firmware(bus))) + return -1; + } - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_SERR) - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4, 0); + if (!bus->drvr) + return 0; - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - if (regdata & (SBIM_IBE | SBIM_TO)) - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, - regdata & ~(SBIM_IBE | SBIM_TO)); + /* Start the watchdog timer */ + bus->drvr->tickcnt = 0; + brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); - /* clear reset and allow it to propagate throughout the core */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_FGC << SBTML_SICF_SHIFT) | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); + if (enforce_mutex) + brcmf_sdbrcm_sdlock(bus); - /* leave clock enabled */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); + /* Make sure backplane clock is on, needed to generate F2 interrupt */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + if (bus->clkstate != CLK_AVAIL) + goto exit; + + /* Force clocks on backplane to be sure F2 interrupt propagates */ + saveclk = + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, &err); + if (!err) { + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + (saveclk | SBSDIO_FORCE_HT), &err); + } + if (err) { + brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); + goto exit; + } + + /* Enable function 2 (frame transfers) */ + w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, + offsetof(struct sdpcmd_regs, tosbmailboxdata), &retries); + enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2); + + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, + enable, NULL); + + timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); + ready = 0; + while (enable != ready) { + ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, + SDIO_CCCR_IORx, NULL); + if (time_after(jiffies, timeout)) + break; + else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50)) + /* prevent busy waiting if it takes too long */ + msleep_interruptible(20); + } + + brcmf_dbg(INFO, "enable 0x%02x, ready 0x%02x\n", enable, ready); + + /* If F2 successfully enabled, set core and enable interrupts */ + if (ready == enable) { + /* Set up the interrupt mask and enable interrupts */ + bus->hostintmask = HOSTINTMASK; + w_sdreg32(bus, bus->hostintmask, + offsetof(struct sdpcmd_regs, hostintmask), &retries); + + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_WATERMARK, 8, &err); + + /* Set bus state according to enable result */ + drvr->busstate = BRCMF_BUS_DATA; + } + + else { + /* Disable F2 again */ + enable = SDIO_FUNC_ENABLE_1; + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, + SDIO_CCCR_IOEx, enable, NULL); + } + + /* Restore previous clock setting */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); + + /* If we didn't come up, turn off backplane clock */ + if (drvr->busstate != BRCMF_BUS_DATA) + brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); + +exit: + if (enforce_mutex) + brcmf_sdbrcm_sdunlock(bus); + + return ret; +} + +void brcmf_sdbrcm_isr(void *arg) +{ + struct brcmf_bus *bus = (struct brcmf_bus *) arg; + + brcmf_dbg(TRACE, "Enter\n"); + + if (!bus) { + brcmf_dbg(ERROR, "bus is null pointer, exiting\n"); + return; + } + + if (bus->drvr->busstate == BRCMF_BUS_DOWN) { + brcmf_dbg(ERROR, "bus is down. we have nothing to do\n"); + return; + } + /* Count the interrupt call */ + bus->intrcount++; + bus->ipend = true; + + /* Shouldn't get this interrupt if we're sleeping? */ + if (bus->sleeping) { + brcmf_dbg(ERROR, "INTERRUPT WHILE SLEEPING??\n"); + return; + } + + /* Disable additional interrupts (is this needed now)? */ + if (!bus->intr) + brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); + + bus->dpc_sched = true; + brcmf_sdbrcm_sched_dpc(bus); +} + +static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) +{ + struct brcmf_bus *bus; + + brcmf_dbg(TIMER, "Enter\n"); + + bus = drvr->bus; + + if (bus->drvr->dongle_reset) + return false; + + /* Ignore the timer if simulating bus down */ + if (bus->sleeping) + return false; + + brcmf_sdbrcm_sdlock(bus); + + /* Poll period: check device if appropriate. */ + if (bus->poll && (++bus->polltick >= bus->pollrate)) { + u32 intstatus = 0; + + /* Reset poll tick */ + bus->polltick = 0; + + /* Check device if no interrupts */ + if (!bus->intr || (bus->intrcount == bus->lastintrs)) { + + if (!bus->dpc_sched) { + u8 devpend; + devpend = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_0, SDIO_CCCR_INTx, + NULL); + intstatus = + devpend & (INTR_STATUS_FUNC1 | + INTR_STATUS_FUNC2); + } + + /* If there is something, make like the ISR and + schedule the DPC */ + if (intstatus) { + bus->pollcnt++; + bus->ipend = true; + + bus->dpc_sched = true; + brcmf_sdbrcm_sched_dpc(bus); + + } + } + + /* Update interrupt tracking */ + bus->lastintrs = bus->intrcount; + } +#ifdef BCMDBG + /* Poll for console output periodically */ + if (drvr->busstate == BRCMF_BUS_DATA && brcmf_console_ms != 0) { + bus->console.count += brcmf_watchdog_ms; + if (bus->console.count >= brcmf_console_ms) { + bus->console.count -= brcmf_console_ms; + /* Make sure backplane clock is on */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + if (brcmf_sdbrcm_readconsole(bus) < 0) + brcmf_console_ms = 0; /* On error, + stop trying */ + } + } +#endif /* BCMDBG */ + + /* On idle timeout clear activity flag and/or turn off clock */ + if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { + if (++bus->idlecount >= bus->idletime) { + bus->idlecount = 0; + if (bus->activity) { + bus->activity = false; + brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + } else { + brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); + } + } + } + + brcmf_sdbrcm_sdunlock(bus); + + return bus->ipend; +} + +static bool brcmf_sdbrcm_chipmatch(u16 chipid) +{ + if (chipid == BCM4329_CHIP_ID) + return true; + return false; +} + +static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) +{ + brcmf_dbg(TRACE, "Enter\n"); + + if (bus->drvr && bus->drvr->dongle_reset) + return; + + kfree(bus->rxbuf); + bus->rxctl = bus->rxbuf = NULL; + bus->rxlen = 0; + + kfree(bus->databuf); + bus->databuf = NULL; +} + +static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) +{ + brcmf_dbg(TRACE, "Enter\n"); + + if (bus->drvr->maxctl) { + bus->rxblen = + roundup((bus->drvr->maxctl + SDPCM_HDRLEN), + ALIGNMENT) + BRCMF_SDALIGN; + bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC); + if (!(bus->rxbuf)) { + brcmf_dbg(ERROR, "kmalloc of %d-byte rxbuf failed\n", + bus->rxblen); + goto fail; + } + } + + /* Allocate buffer to receive glomed packet */ + bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC); + if (!(bus->databuf)) { + brcmf_dbg(ERROR, "kmalloc of %d-byte databuf failed\n", + MAX_DATA_BUF); + /* release rxbuf which was already located as above */ + if (!bus->rxblen) + kfree(bus->rxbuf); + goto fail; + } + + /* Align the buffer */ + if ((unsigned long)bus->databuf % BRCMF_SDALIGN) + bus->dataptr = bus->databuf + (BRCMF_SDALIGN - + ((unsigned long)bus->databuf % BRCMF_SDALIGN)); + else + bus->dataptr = bus->databuf; + + return true; + +fail: + return false; } /* SDIO Pad drive strength to select value mappings */ @@ -4954,31 +4465,278 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, } } -static void -brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) +static int +brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u32 regs) +{ + u32 regdata; + + /* + * Get CC core rev + * Chipid is assume to be at offset 0 from regs arg + * For different chiptypes or old sdio hosts w/o chipcommon, + * other ways of recognition should be added here. + */ + ci->cccorebase = regs; + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, chipid), 4); + ci->chip = regdata & CID_ID_MASK; + ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; + + brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); + + /* Address of cores for new chips should be added here */ + switch (ci->chip) { + case BCM4329_CHIP_ID: + ci->buscorebase = BCM4329_CORE_BUS_BASE; + ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; + ci->armcorebase = BCM4329_CORE_ARM_BASE; + ci->ramsize = BCM4329_RAMSIZE; + break; + default: + brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); + return -ENODEV; + } + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->cccorebase, sbidhigh), 4); + ci->ccrev = SBCOREREV(regdata); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); + ci->pmurev = regdata & PCAP_REV_MASK; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->buscorebase, sbidhigh), 4); + ci->buscorerev = SBCOREREV(regdata); + ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; + + brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", + ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); + + /* get chipcommon capabilites */ + ci->cccaps = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, capabilities), 4); + + return 0; +} + +static int +brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) +{ + struct chip_info *ci; + int err; + u8 clkval, clkset; + + brcmf_dbg(TRACE, "Enter\n"); + + /* alloc chip_info_t */ + ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); + if (NULL == ci) { + brcmf_dbg(ERROR, "malloc failed!\n"); + return -ENOMEM; + } + + /* bus/core/clk setup for register access */ + /* Try forcing SDIO core to do ALPAvail request only */ + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); + if (err) { + brcmf_dbg(ERROR, "error writing for HT off\n"); + goto fail; + } + + /* If register supported, wait for ALPAvail and then force ALP */ + /* This may take up to 15 milliseconds */ + clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, NULL); + if ((clkval & ~SBSDIO_AVBITS) == clkset) { + SPINWAIT(((clkval = + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + NULL)), + !SBSDIO_ALPAV(clkval)), + PMU_MAX_TRANSITION_DLY); + if (!SBSDIO_ALPAV(clkval)) { + brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", + clkval); + err = -EBUSY; + goto fail; + } + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | + SBSDIO_FORCE_ALP; + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + clkset, &err); + udelay(65); + } else { + brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", + clkset, clkval); + err = -EACCES; + goto fail; + } + + /* Also, disable the extra SDIO pull-ups */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); + + err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); + if (err) + goto fail; + + /* + * Make sure any on-chip ARM is off (in case strapping is wrong), + * or downloaded code was already running. + */ + brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); + + brcmf_sdcard_reg_write(bus->sdiodev, + CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); + brcmf_sdcard_reg_write(bus->sdiodev, + CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); + + /* Disable F2 to clear any intermediate frame state on the dongle */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, + SDIO_FUNC_ENABLE_1, NULL); + + /* WAR: cmd52 backplane read so core HW will drop ALPReq */ + clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + 0, NULL); + + /* Done with backplane-dependent accesses, can drop clock... */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); + + bus->ci = ci; + return 0; +fail: + bus->ci = NULL; + kfree(ci); + return err; +} + +static bool +brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) +{ + u8 clkctl = 0; + int err = 0; + int reg_addr; + u32 reg_val; + + bus->alp_only = true; + + /* Return the window to backplane enumeration space for core access */ + if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) + brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); + +#ifdef BCMDBG + printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", + brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); + +#endif /* BCMDBG */ + + /* + * Force PLL off until brcmf_sdbrcm_chip_attach() + * programs PLL control regs + */ + + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, + BRCMF_INIT_CLKCTL1, &err); + if (!err) + clkctl = + brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, &err); + + if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { + brcmf_dbg(ERROR, "ChipClkCSR access: err %d wrote 0x%02x read 0x%02x\n", + err, BRCMF_INIT_CLKCTL1, clkctl); + goto fail; + } + + if (brcmf_sdbrcm_chip_attach(bus, regsva)) { + brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); + goto fail; + } + + if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) { + brcmf_dbg(ERROR, "unsupported chip: 0x%04x\n", bus->ci->chip); + goto fail; + } + + brcmf_sdbrcm_sdiod_drive_strength_init(bus, brcmf_sdiod_drive_strength); + + /* Get info on the ARM and SOCRAM cores... */ + brcmf_sdcard_reg_read(bus->sdiodev, + CORE_SB(bus->ci->armcorebase, sbidhigh), 4); + bus->orig_ramsize = bus->ci->ramsize; + if (!(bus->orig_ramsize)) { + brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); + goto fail; + } + bus->ramsize = bus->orig_ramsize; + if (brcmf_dongle_memsize) + brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); + + brcmf_dbg(ERROR, "DHD: dongle ram size is set to %d(orig %d)\n", + bus->ramsize, bus->orig_ramsize); + + /* Set core control so an SDIO reset does a backplane reset */ + reg_addr = bus->ci->buscorebase + + offsetof(struct sdpcmd_regs, corecontrol); + reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); + brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), + reg_val | CC_BPRESEN); + + brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); + + /* Locate an appropriately-aligned portion of hdrbuf */ + bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], + BRCMF_SDALIGN); + + /* Set the poll and/or interrupt flags */ + bus->intr = (bool) brcmf_intr; + bus->poll = (bool) brcmf_poll; + if (bus->poll) + bus->pollrate = 1; + + return true; + +fail: + return false; +} + +static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) { brcmf_dbg(TRACE, "Enter\n"); - kfree(bus->ci); - bus->ci = NULL; -} + /* Disable F2 to clear any intermediate frame state on the dongle */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, + SDIO_FUNC_ENABLE_1, NULL); -static void -brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) -{ - brcmf_sdbrcm_sdunlock(bus); - wait_event_interruptible_timeout(bus->ctrl_wait, - (*lockvar == false), HZ * 2); - brcmf_sdbrcm_sdlock(bus); - return; -} + bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->sleeping = false; + bus->rxflow = false; -static void -brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus) -{ - if (waitqueue_active(&bus->ctrl_wait)) - wake_up_interruptible(&bus->ctrl_wait); - return; + /* Done with backplane-dependent accesses, can drop clock... */ + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); + + /* ...and initialize clock/power states */ + bus->clkstate = CLK_SDONLY; + bus->idletime = (s32) brcmf_idletime; + bus->idleclock = BRCMF_IDLE_ACTIVE; + + /* Query the F2 block size, set roundup accordingly */ + bus->blocksize = bus->sdiodev->func[2]->cur_blksize; + bus->roundup = min(max_roundup, bus->blocksize); + + /* bus module does not support packet chaining */ + bus->use_rxchain = false; + bus->sd_rxchain = false; + + return true; } static int @@ -5034,6 +4792,309 @@ brcmf_sdbrcm_watchdog(unsigned long data) mod_timer(&bus->timer, jiffies + brcmf_watchdog_ms * HZ / 1000); } +static void +brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) +{ + brcmf_dbg(TRACE, "Enter\n"); + + kfree(bus->ci); + bus->ci = NULL; +} + +static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) +{ + brcmf_dbg(TRACE, "Enter\n"); + + if (bus->drvr && bus->drvr->dongle_reset) + return; + + if (bus->ci) { + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); + brcmf_sdbrcm_chip_detach(bus); + if (bus->vars && bus->varsz) + kfree(bus->vars); + bus->vars = NULL; + } + + brcmf_dbg(TRACE, "Disconnected\n"); +} + +/* Detach and free everything */ +static void brcmf_sdbrcm_release(struct brcmf_bus *bus) +{ + brcmf_dbg(TRACE, "Enter\n"); + + if (bus) { + /* De-register interrupt handler */ + brcmf_sdcard_intr_dereg(bus->sdiodev); + + if (bus->drvr) { + brcmf_detach(bus->drvr); + brcmf_sdbrcm_release_dongle(bus); + bus->drvr = NULL; + } + + brcmf_sdbrcm_release_malloc(bus); + + kfree(bus); + } + + brcmf_dbg(TRACE, "Disconnected\n"); +} + +void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, + u32 regsva, struct brcmf_sdio_dev *sdiodev) +{ + int ret; + struct brcmf_bus *bus; + + /* Init global variables at run-time, not as part of the declaration. + * This is required to support init/de-init of the driver. + * Initialization + * of globals as part of the declaration results in non-deterministic + * behavior since the value of the globals may be different on the + * first time that the driver is initialized vs subsequent + * initializations. + */ + brcmf_txbound = BRCMF_TXBOUND; + brcmf_rxbound = BRCMF_RXBOUND; + brcmf_alignctl = true; + brcmf_readahead = true; + retrydata = false; + brcmf_dongle_memsize = 0; + brcmf_txminmax = BRCMF_TXMINMAX; + + forcealign = true; + + brcmf_c_init(); + + brcmf_dbg(TRACE, "Enter\n"); + + /* We make an assumption about address window mappings: + * regsva == SI_ENUM_BASE*/ + + /* Allocate private bus interface state */ + bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); + if (!bus) { + brcmf_dbg(ERROR, "kmalloc of struct dhd_bus failed\n"); + goto fail; + } + bus->sdiodev = sdiodev; + sdiodev->bus = bus; + bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; + bus->usebufpool = false; /* Use bufpool if allocated, + else use locally malloced rxbuf */ + + /* attempt to attach to the dongle */ + if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_attach failed\n"); + goto fail; + } + + spin_lock_init(&bus->txqlock); + init_waitqueue_head(&bus->ctrl_wait); + init_waitqueue_head(&bus->ioctl_resp_wait); + + /* Set up the watchdog timer */ + init_timer(&bus->timer); + bus->timer.data = (unsigned long)bus; + bus->timer.function = brcmf_sdbrcm_watchdog; + + /* Initialize thread based operation and lock */ + if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0)) { + bus->threads_only = true; + sema_init(&bus->sdsem, 1); + } else { + bus->threads_only = false; + spin_lock_init(&bus->sdlock); + } + + if (brcmf_dpc_prio >= 0) { + /* Initialize watchdog thread */ + init_completion(&bus->watchdog_wait); + bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, + bus, "brcmf_watchdog"); + if (IS_ERR(bus->watchdog_tsk)) { + printk(KERN_WARNING + "brcmf_watchdog thread failed to start\n"); + bus->watchdog_tsk = NULL; + } + } else + bus->watchdog_tsk = NULL; + + /* Set up the bottom half handler */ + if (brcmf_dpc_prio >= 0) { + /* Initialize DPC thread */ + init_completion(&bus->dpc_wait); + bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, + bus, "brcmf_dpc"); + if (IS_ERR(bus->dpc_tsk)) { + printk(KERN_WARNING + "brcmf_dpc thread failed to start\n"); + bus->dpc_tsk = NULL; + } + } else { + tasklet_init(&bus->tasklet, brcmf_sdbrcm_dpc_tasklet, + (unsigned long)bus); + bus->dpc_tsk = NULL; + } + + /* Attach to the brcmf/OS/network interface */ + bus->drvr = brcmf_attach(bus, SDPCM_RESERVE); + if (!bus->drvr) { + brcmf_dbg(ERROR, "brcmf_attach failed\n"); + goto fail; + } + + /* Allocate buffers */ + if (!(brcmf_sdbrcm_probe_malloc(bus))) { + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_malloc failed\n"); + goto fail; + } + + if (!(brcmf_sdbrcm_probe_init(bus))) { + brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_init failed\n"); + goto fail; + } + + /* Register interrupt callback, but mask it (not operational yet). */ + brcmf_dbg(INTR, "disable SDIO interrupts (not interested yet)\n"); + ret = brcmf_sdcard_intr_reg(bus->sdiodev); + if (ret != 0) { + brcmf_dbg(ERROR, "FAILED: sdcard_intr_reg returned %d\n", ret); + goto fail; + } + brcmf_dbg(INTR, "registered SDIO interrupt function ok\n"); + + brcmf_dbg(INFO, "completed!!\n"); + + /* if firmware path present try to download and bring up bus */ + ret = brcmf_bus_start(bus->drvr); + if (ret != 0) { + if (ret == -ENOLINK) { + brcmf_dbg(ERROR, "dongle is not responding\n"); + goto fail; + } + } + /* Ok, have the per-port tell the stack we're open for business */ + if (brcmf_net_attach(bus->drvr, 0) != 0) { + brcmf_dbg(ERROR, "Net attach failed!!\n"); + goto fail; + } + + return bus; + +fail: + brcmf_sdbrcm_release(bus); + return NULL; +} + +void brcmf_sdbrcm_disconnect(void *ptr) +{ + struct brcmf_bus *bus = (struct brcmf_bus *)ptr; + + brcmf_dbg(TRACE, "Enter\n"); + + if (bus) + brcmf_sdbrcm_release(bus); + + brcmf_dbg(TRACE, "Disconnected\n"); +} + +int brcmf_bus_register(void) +{ + brcmf_dbg(TRACE, "Enter\n"); + + /* Sanity check on the module parameters */ + do { + /* Both watchdog and DPC as tasklets are ok */ + if ((brcmf_watchdog_prio < 0) && (brcmf_dpc_prio < 0)) + break; + + /* If both watchdog and DPC are threads, TX must be deferred */ + if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0) + && brcmf_deferred_tx) + break; + + brcmf_dbg(ERROR, "Invalid module parameters.\n"); + return -EINVAL; + } while (0); + + return brcmf_sdio_register(); +} + +void brcmf_bus_unregister(void) +{ + brcmf_dbg(TRACE, "Enter\n"); + + brcmf_sdio_unregister(); +} + +struct device *brcmf_bus_get_device(struct brcmf_bus *bus) +{ + return &bus->sdiodev->func[2]->dev; +} + +int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) +{ + int bcmerror = 0; + struct brcmf_bus *bus; + + bus = drvr->bus; + + if (flag == true) { + brcmf_sdbrcm_wd_timer(bus, 0); + if (!bus->drvr->dongle_reset) { + /* Expect app to have torn down any + connection before calling */ + /* Stop the bus, disable F2 */ + brcmf_sdbrcm_bus_stop(bus, false); + + /* Clean tx/rx buffer pointers, + detach from the dongle */ + brcmf_sdbrcm_release_dongle(bus); + + bus->drvr->dongle_reset = true; + bus->drvr->up = false; + + brcmf_dbg(TRACE, "WLAN OFF DONE\n"); + /* App can now remove power from device */ + } else + bcmerror = -EIO; + } else { + /* App must have restored power to device before calling */ + + brcmf_dbg(TRACE, " == WLAN ON ==\n"); + + if (bus->drvr->dongle_reset) { + /* Turn on WLAN */ + + /* Attempt to re-attach & download */ + if (brcmf_sdbrcm_probe_attach(bus, SI_ENUM_BASE)) { + /* Attempt to download binary to the dongle */ + if (brcmf_sdbrcm_probe_init(bus)) { + /* Re-init bus, enable F2 transfer */ + brcmf_sdbrcm_bus_init(bus->drvr, false); + + bus->drvr->dongle_reset = false; + bus->drvr->up = true; + + brcmf_dbg(TRACE, "WLAN ON DONE\n"); + } else + bcmerror = -EIO; + } else + bcmerror = -EIO; + } else { + bcmerror = -EISCONN; + brcmf_dbg(ERROR, "Set DEVRESET=false invoked when device is on\n"); + bcmerror = -EIO; + } + brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + } + return bcmerror; +} + void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) { @@ -5074,118 +5135,3 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) bus->save_ms = wdtick; } } - -static int brcmf_sdbrcm_dpc_thread(void *data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) data; - - /* This thread doesn't need any user-level access, - * so get rid of all our resources - */ - if (brcmf_dpc_prio > 0) { - struct sched_param param; - param.sched_priority = (brcmf_dpc_prio < MAX_RT_PRIO) ? - brcmf_dpc_prio : (MAX_RT_PRIO - 1); - sched_setscheduler(current, SCHED_FIFO, ¶m); - } - - allow_signal(SIGTERM); - /* Run until signal received */ - while (1) { - if (kthread_should_stop()) - break; - if (!wait_for_completion_interruptible(&bus->dpc_wait)) { - /* Call bus dpc unless it indicated down - (then clean stop) */ - if (bus->drvr->busstate != BRCMF_BUS_DOWN) { - if (brcmf_sdbrcm_dpc(bus)) - complete(&bus->dpc_wait); - } else { - brcmf_sdbrcm_bus_stop(bus, true); - } - } else - break; - } - return 0; -} - -static void brcmf_sdbrcm_dpc_tasklet(unsigned long data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) data; - - /* Call bus dpc unless it indicated down (then clean stop) */ - if (bus->drvr->busstate != BRCMF_BUS_DOWN) { - if (brcmf_sdbrcm_dpc(bus)) - tasklet_schedule(&bus->tasklet); - } else - brcmf_sdbrcm_bus_stop(bus, true); -} - -static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus) -{ - if (bus->dpc_tsk) { - complete(&bus->dpc_wait); - return; - } - - tasklet_schedule(&bus->tasklet); -} - -static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus) -{ - if (bus->threads_only) - down(&bus->sdsem); - else - spin_lock_bh(&bus->sdlock); -} - -static void brcmf_sdbrcm_sdunlock(struct brcmf_bus *bus) -{ - if (bus->threads_only) - up(&bus->sdsem); - else - spin_unlock_bh(&bus->sdlock); -} - -static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) -{ - if (bus->firmware->size < bus->fw_ptr + len) - len = bus->firmware->size - bus->fw_ptr; - - memcpy(buf, &bus->firmware->data[bus->fw_ptr], len); - bus->fw_ptr += len; - return len; -} - -MODULE_FIRMWARE(BCM4329_FW_NAME); -MODULE_FIRMWARE(BCM4329_NV_NAME); - -static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, - bool *pending) -{ - DECLARE_WAITQUEUE(wait, current); - int timeout = msecs_to_jiffies(brcmf_ioctl_timeout_msec); - - /* Wait until control frame is available */ - add_wait_queue(&bus->ioctl_resp_wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); - - while (!(*condition) && (!signal_pending(current) && timeout)) - timeout = schedule_timeout(timeout); - - if (signal_pending(current)) - *pending = true; - - set_current_state(TASK_RUNNING); - remove_wait_queue(&bus->ioctl_resp_wait, &wait); - - return timeout; -} - -static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus) -{ - if (waitqueue_active(&bus->ioctl_resp_wait)) - wake_up_interruptible(&bus->ioctl_resp_wait); - - return 0; -} From 648f3b75b4688a1107fbfcc5c42005eabff2a3f8 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 15 Sep 2011 10:06:21 +0200 Subject: [PATCH 1035/1519] staging: brcm80211: remove ioctl layer from brcmsmac The ioctl layer in brcmsmac only provided an interface layer that was internal to the driver. This is considered pointless and has been removed. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 65 ++- drivers/staging/brcm80211/brcmsmac/main.c | 391 ++++++------------ drivers/staging/brcm80211/brcmsmac/pub.h | 12 +- drivers/staging/brcm80211/include/defs.h | 13 +- 4 files changed, 177 insertions(+), 304 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index d00378627a1..11ad5d05c7e 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -371,23 +371,23 @@ ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, enum nl80211_channel_type type) { struct brcms_info *wl = hw->priv; - int err = 0; + int err; switch (type) { case NL80211_CHAN_HT20: case NL80211_CHAN_NO_HT: - err = brcms_c_set(wl->wlc, BRCM_SET_CHANNEL, chan->hw_value); + err = brcms_c_set_channel(wl->wlc, chan->hw_value); break; case NL80211_CHAN_HT40MINUS: case NL80211_CHAN_HT40PLUS: wiphy_err(hw->wiphy, "%s: Need to implement 40 Mhz Channels!\n", __func__); - err = 1; + err = -ENOTSUPP; break; + default: + err = -EINVAL; } - if (err) - return -EIO; return err; } @@ -436,21 +436,10 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) if (changed & IEEE80211_CONF_CHANGE_CHANNEL) err = ieee_set_channel(hw, conf->channel, conf->channel_type); - if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { - if (brcms_c_set - (wl->wlc, BRCM_SET_SRL, - conf->short_frame_max_tx_count) < 0) { - wiphy_err(wiphy, "%s: Error setting srl\n", __func__); - err = -EIO; - goto config_out; - } - if (brcms_c_set(wl->wlc, BRCM_SET_LRL, - conf->long_frame_max_tx_count) < 0) { - wiphy_err(wiphy, "%s: Error setting lrl\n", __func__); - err = -EIO; - goto config_out; - } - } + if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) + err = brcms_c_set_rate_limit(wl->wlc, + conf->short_frame_max_tx_count, + conf->long_frame_max_tx_count); config_out: UNLOCK(wl); @@ -464,7 +453,6 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, { struct brcms_info *wl = hw->priv; struct wiphy *wiphy = hw->wiphy; - int val; if (changed & BSS_CHANGED_ASSOC) { /* association status changed (associated/disassociated) @@ -477,13 +465,15 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, UNLOCK(wl); } if (changed & BSS_CHANGED_ERP_SLOT) { + s8 val; + /* slot timing changed */ if (info->use_short_slot) val = 1; else val = 0; LOCK(wl); - brcms_c_set(wl->wlc, BRCMS_SET_SHORTSLOT_OVERRIDE, val); + brcms_c_set_shortslot_override(wl->wlc, val); UNLOCK(wl); } @@ -509,14 +499,9 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, /* retrieve the current rates */ LOCK(wl); - error = brcms_c_ioctl(wl->wlc, BRCM_GET_CURR_RATESET, - &rs, sizeof(rs)); + brcms_c_get_current_rateset(wl->wlc, &rs); UNLOCK(wl); - if (error) { - wiphy_err(wiphy, "%s: retrieve rateset failed: %d\n", - __func__, error); - return; - } + br_mask = info->basic_rates; bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)]; for (i = 0; i < bi->n_bitrates; i++) { @@ -530,20 +515,22 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, /* update the rate set */ LOCK(wl); - brcms_c_ioctl(wl->wlc, BRCM_SET_RATESET, &rs, sizeof(rs)); + error = brcms_c_set_rateset(wl->wlc, &rs); UNLOCK(wl); + if (error) + wiphy_err(wiphy, "changing basic rates failed: %d\n", + error); } if (changed & BSS_CHANGED_BEACON_INT) { /* Beacon interval changed */ LOCK(wl); - brcms_c_set(wl->wlc, BRCM_SET_BCNPRD, info->beacon_int); + brcms_c_set_beacon_period(wl->wlc, info->beacon_int); UNLOCK(wl); } if (changed & BSS_CHANGED_BSSID) { /* BSSID changed, for whatever reason (IBSS and managed mode) */ LOCK(wl); - brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, - info->bssid); + brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid); UNLOCK(wl); } if (changed & BSS_CHANGED_BEACON) @@ -1086,18 +1073,16 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; int has_5g; - char phy_list[4]; + u16 phy_type; has_5g = 0; hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; - if (brcms_c_get(wl->wlc, BRCM_GET_PHYLIST, (int *)&phy_list) < 0) - wiphy_err(hw->wiphy, "Phy list failed\n"); - - if (phy_list[0] == 'n' || phy_list[0] == 'c') { - if (phy_list[0] == 'c') { + phy_type = brcms_c_get_phy_type(wl->wlc, 0); + if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) { + if (phy_type == PHY_TYPE_LCN) { /* Single stream */ brcms_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; brcms_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; @@ -1110,7 +1095,7 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) /* Assume all bands use the same phy. True for 11n devices. */ if (wl->pub->_nbands > 1) { has_5g++; - if (phy_list[0] == 'n' || phy_list[0] == 'c') + if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &brcms_band_5GHz_nphy; else diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 2b5d4de73c1..705f0ebb84b 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5252,7 +5252,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, /* init per-band default rateset, depend on band->gmode */ brcms_default_rateset(wlc, &wlc->band->defrateset); - /* fill in hw_rateset (used early by BRCM_SET_RATESET) */ + /* fill in hw_rateset */ brcms_c_rateset_filter(&wlc->band->defrateset, &wlc->band->hw_rateset, false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, @@ -6116,7 +6116,8 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) } static int -brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs_arg) +brcms_c_set_internal_rateset(struct brcms_c_info *wlc, + struct brcms_c_rateset *rs_arg) { struct brcms_c_rateset rs, new; uint bandunit; @@ -6158,18 +6159,6 @@ brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs_arg) return 0; } -/* simplified integer set interface for common ioctl handler */ -int brcms_c_set(struct brcms_c_info *wlc, int cmd, int arg) -{ - return brcms_c_ioctl(wlc, cmd, (void *)&arg, sizeof(arg)); -} - -/* simplified integer get interface for common ioctl handler */ -int brcms_c_get(struct brcms_c_info *wlc, int cmd, int *arg) -{ - return brcms_c_ioctl(wlc, cmd, arg, sizeof(int)); -} - static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) { u8 r; @@ -6185,259 +6174,153 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) return; } -/* common ioctl handler. return: 0=ok, -1=error, positive=particular error */ -static int -_brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len) +int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) { - int val, *pval; - bool bool_val; - int bcmerror; - struct scb *nextscb; - bool ta_ok; - uint band; - struct brcms_bss_cfg *bsscfg; - struct brcms_bss_info *current_bss; + u16 chspec = ch20mhz_chspec(channel); - /* update bsscfg pointer */ - bsscfg = wlc->cfg; - current_bss = bsscfg->current_bss; + if (channel < 0 || channel > MAXCHANNEL) + return -EINVAL; - /* initialize the following to get rid of compiler warning */ - nextscb = NULL; - ta_ok = false; - band = 0; + if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) + return -EINVAL; - /* If the device is turned off, then it's not "removed" */ - if (!wlc->pub->hw_off && DEVICEREMOVED(wlc)) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, - __func__); - brcms_down(wlc->wl); - return -EBADE; - } - /* default argument is generic integer */ - pval = arg ? (int *)arg : NULL; - - /* - * This will prevent misaligned access. The (void *) cast prevents a - * memcpy alignment issue on e.g. Sparc64 platforms. - */ - if (pval && (u32) len >= sizeof(val)) - memcpy((void *)&val, (void *)pval, sizeof(val)); - else - val = 0; - - /* bool conversion to avoid duplication below */ - bool_val = val != 0; - bcmerror = 0; - - if ((arg == NULL) || (len <= 0)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Command %d needs arguments\n", - wlc->pub->unit, __func__, cmd); - bcmerror = -EINVAL; - goto done; - } - - switch (cmd) { - - case BRCM_SET_CHANNEL:{ - u16 chspec = ch20mhz_chspec(val); - - if (val < 0 || val > MAXCHANNEL) { - bcmerror = -EINVAL; - break; - } - - if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) { - bcmerror = -EINVAL; - break; - } - - if (!wlc->pub->up && IS_MBAND_UNLOCKED(wlc)) { - if (wlc->band->bandunit != - chspec_bandunit(chspec)) - wlc->bandinit_pending = true; - else - wlc->bandinit_pending = false; - } - - wlc->default_bss->chanspec = chspec; - /* brcms_c_BSSinit() will sanitize the rateset before - * using it.. */ - if (wlc->pub->up && - (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { - brcms_c_set_home_chanspec(wlc, chspec); - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_set_chanspec(wlc, chspec); - brcms_c_enable_mac(wlc); - } - break; - } - - case BRCM_SET_SRL: - if (val >= 1 && val <= RETRY_SHORT_MAX) { - int ac; - wlc->SRL = (u16) val; - - brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - - for (ac = 0; ac < AC_COUNT; ac++) - BRCMS_WME_RETRY_SHORT_SET(wlc, ac, wlc->SRL); - - brcms_c_wme_retries_write(wlc); - } else - bcmerror = -EINVAL; - break; - - case BRCM_SET_LRL: - if (val >= 1 && val <= 255) { - int ac; - wlc->LRL = (u16) val; - - brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - - for (ac = 0; ac < AC_COUNT; ac++) - BRCMS_WME_RETRY_LONG_SET(wlc, ac, wlc->LRL); - - brcms_c_wme_retries_write(wlc); - } else - bcmerror = -EINVAL; - break; - - case BRCM_GET_CURR_RATESET:{ - struct brcm_rateset *ret_rs = - (struct brcm_rateset *) arg; - struct brcms_c_rateset *rs; - - if (wlc->pub->associated) - rs = ¤t_bss->rateset; - else - rs = &wlc->default_bss->rateset; - - if (len < (int)(rs->count + sizeof(rs->count))) { - bcmerror = -EOVERFLOW; - break; - } - - /* Copy only legacy rateset section */ - ret_rs->count = rs->count; - memcpy(&ret_rs->rates, &rs->rates, rs->count); - break; - } - - case BRCM_SET_RATESET:{ - struct brcms_c_rateset rs; - struct brcm_rateset *in_rs = - (struct brcm_rateset *) arg; - - if (len < (int)(in_rs->count + sizeof(in_rs->count))) { - bcmerror = -EOVERFLOW; - break; - } - - if (in_rs->count > BRCMS_NUMRATES) { - bcmerror = -ENOBUFS; - break; - } - - memset(&rs, 0, sizeof(struct brcms_c_rateset)); - - /* Copy only legacy rateset section */ - rs.count = in_rs->count; - memcpy(&rs.rates, &in_rs->rates, rs.count); - - /* merge rateset coming in with the current mcsset */ - if (wlc->pub->_n_enab & SUPPORT_11N) { - struct brcms_bss_info *mcsset_bss; - if (bsscfg->associated) - mcsset_bss = current_bss; - else - mcsset_bss = wlc->default_bss; - memcpy(rs.mcs, &mcsset_bss->rateset.mcs[0], - MCSSET_LEN); - } - - bcmerror = brcms_c_set_rateset(wlc, &rs); - - if (!bcmerror) - brcms_c_ofdm_rateset_war(wlc); - - break; - } - - case BRCM_SET_BCNPRD: - /* range [1, 0xffff] */ - if (val >= DOT11_MIN_BEACON_PERIOD - && val <= DOT11_MAX_BEACON_PERIOD) - wlc->default_bss->beacon_period = (u16) val; + if (!wlc->pub->up && IS_MBAND_UNLOCKED(wlc)) { + if (wlc->band->bandunit != chspec_bandunit(chspec)) + wlc->bandinit_pending = true; else - bcmerror = -EINVAL; - break; - - case BRCM_GET_PHYLIST: - { - unsigned char *cp = arg; - if (len < 3) { - bcmerror = -EOVERFLOW; - break; - } - - if (BRCMS_ISNPHY(wlc->band)) - *cp++ = 'n'; - else if (BRCMS_ISLCNPHY(wlc->band)) - *cp++ = 'c'; - else if (BRCMS_ISSSLPNPHY(wlc->band)) - *cp++ = 's'; - *cp = '\0'; - break; - } - - case BRCMS_SET_SHORTSLOT_OVERRIDE: - if (val != BRCMS_SHORTSLOT_AUTO && val != BRCMS_SHORTSLOT_OFF && - val != BRCMS_SHORTSLOT_ON) { - bcmerror = -EINVAL; - break; - } - - wlc->shortslot_override = (s8) val; - - /* shortslot is an 11g feature, so no more work if we are - * currently on the 5G band - */ - if (wlc->band->bandtype == BRCM_BAND_5G) - break; - - if (wlc->pub->up && wlc->pub->associated) { - /* let watchdog or beacon processing update shortslot */ - } else if (wlc->pub->up) { - /* unassociated shortslot is off */ - brcms_c_switch_shortslot(wlc, false); - } else { - /* driver is down, so just update the brcms_c_info - * value */ - if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) - wlc->shortslot = false; - else - wlc->shortslot = - (wlc->shortslot_override == - BRCMS_SHORTSLOT_ON); - } - - break; - + wlc->bandinit_pending = false; } - done: - if (bcmerror) - wlc->pub->bcmerror = bcmerror; + wlc->default_bss->chanspec = chspec; + /* brcms_c_BSSinit() will sanitize the rateset before + * using it.. */ + if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { + brcms_c_set_home_chanspec(wlc, chspec); + brcms_c_suspend_mac_and_wait(wlc); + brcms_c_set_chanspec(wlc, chspec); + brcms_c_enable_mac(wlc); + } + return 0; +} + +int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) +{ + int ac; + + if (srl < 1 || srl > RETRY_SHORT_MAX || + lrl < 1 || lrl > RETRY_SHORT_MAX) + return -EINVAL; + + wlc->SRL = srl; + wlc->LRL = lrl; + + brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); + + for (ac = 0; ac < AC_COUNT; ac++) { + BRCMS_WME_RETRY_SHORT_SET(wlc, ac, srl); + BRCMS_WME_RETRY_LONG_SET(wlc, ac, lrl); + } + brcms_c_wme_retries_write(wlc); + + return 0; +} + +void brcms_c_get_current_rateset(struct brcms_c_info *wlc, + struct brcm_rateset *currs) +{ + struct brcms_c_rateset *rs; + + if (wlc->pub->associated) + rs = &wlc->cfg->current_bss->rateset; + else + rs = &wlc->default_bss->rateset; + + /* Copy only legacy rateset section */ + currs->count = rs->count; + memcpy(&currs->rates, &rs->rates, rs->count); +} + +int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) +{ + struct brcms_c_rateset internal_rs; + int bcmerror; + + if (rs->count > BRCMS_NUMRATES) + return -ENOBUFS; + + memset(&internal_rs, 0, sizeof(struct brcms_c_rateset)); + + /* Copy only legacy rateset section */ + internal_rs.count = rs->count; + memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); + + /* merge rateset coming in with the current mcsset */ + if (wlc->pub->_n_enab & SUPPORT_11N) { + struct brcms_bss_info *mcsset_bss; + if (wlc->cfg->associated) + mcsset_bss = wlc->cfg->current_bss; + else + mcsset_bss = wlc->default_bss; + memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], + MCSSET_LEN); + } + + bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs); + if (!bcmerror) + brcms_c_ofdm_rateset_war(wlc); return bcmerror; } -int -brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len) +int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period) { - return _brcms_c_ioctl(wlc, cmd, arg, len); + if (period < DOT11_MIN_BEACON_PERIOD || + period > DOT11_MAX_BEACON_PERIOD) + return -EINVAL; + + wlc->default_bss->beacon_period = period; + return 0; +} + +u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) +{ + return wlc->band->phytype; +} + +int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) +{ + if (sslot_override != BRCMS_SHORTSLOT_AUTO && + sslot_override != BRCMS_SHORTSLOT_OFF && + sslot_override != BRCMS_SHORTSLOT_ON) { + return -EINVAL; + } + + wlc->shortslot_override = sslot_override; + + /* + * shortslot is an 11g feature, so no more work if we are + * currently on the 5G band + */ + if (wlc->band->bandtype == BRCM_BAND_5G) + return 0; + + if (wlc->pub->up && wlc->pub->associated) { + /* let watchdog or beacon processing update shortslot */ + } else if (wlc->pub->up) { + /* unassociated shortslot is off */ + brcms_c_switch_shortslot(wlc, false); + } else { + /* driver is down, so just update the brcms_c_info + * value */ + if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) + wlc->shortslot = false; + else + wlc->shortslot = + (wlc->shortslot_override == + BRCMS_SHORTSLOT_ON); + } + return 0; } /* diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 33e7ebe7b97..3655ac6ff6d 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -312,8 +312,6 @@ extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); -extern int brcms_c_set(struct brcms_c_info *wlc, int cmd, int arg); -extern int brcms_c_get(struct brcms_c_info *wlc, int cmd, int *arg); extern bool brcms_c_chipmatch(u16 vendor, u16 device); extern void brcms_c_init(struct brcms_c_info *wlc); extern void brcms_c_reset(struct brcms_c_info *wlc); @@ -327,7 +325,6 @@ extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded); extern void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, struct ieee80211_hw *hw); -extern int brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len); extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid); /* helper functions */ @@ -382,6 +379,15 @@ extern int brcms_c_get_curband(struct brcms_c_info *wlc); extern void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop); +int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel); +int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl); +void brcms_c_get_current_rateset(struct brcms_c_info *wlc, + struct brcm_rateset *currs); +int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs); +int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period); +u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx); +int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override); + /* helper functions */ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); extern bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h index c745b7e5922..3438c544eb1 100644 --- a/drivers/staging/brcm80211/include/defs.h +++ b/drivers/staging/brcm80211/include/defs.h @@ -57,14 +57,13 @@ struct brcm_rateset { #define BRCM_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NUL */ -#define BRCM_SET_CHANNEL 30 -#define BRCM_SET_SRL 32 -#define BRCM_SET_LRL 34 +#define BRCM_SET_CHANNEL 30 +#define BRCM_SET_SRL 32 +#define BRCM_SET_LRL 34 +#define BRCM_SET_BCNPRD 76 -#define BRCM_SET_RATESET 72 -#define BRCM_SET_BCNPRD 76 -#define BRCM_GET_CURR_RATESET 114 /* current rateset */ -#define BRCM_GET_PHYLIST 180 +#define BRCM_GET_CURR_RATESET 114 /* current rateset */ +#define BRCM_GET_PHYLIST 180 /* Bit masks for radio disabled status - returned by WL_GET_RADIO */ From b87987b1f4524f9abca525c5d2a346ea0079d295 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 13 Sep 2011 09:49:43 +0200 Subject: [PATCH 1036/1519] staging: brcm80211: remove function ieee_set_channel() The function ieee_set_channel() provides very little functionality so it has been removed. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 39 ++++--------------- drivers/staging/brcm80211/brcmsmac/main.c | 11 +----- drivers/staging/brcm80211/brcmsmac/pub.h | 3 +- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 11ad5d05c7e..3ec72f1a38f 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -363,34 +363,6 @@ brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) UNLOCK(wl); } -/* - * precondition: perimeter lock has been acquired - */ -static int -ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, - enum nl80211_channel_type type) -{ - struct brcms_info *wl = hw->priv; - int err; - - switch (type) { - case NL80211_CHAN_HT20: - case NL80211_CHAN_NO_HT: - err = brcms_c_set_channel(wl->wlc, chan->hw_value); - break; - case NL80211_CHAN_HT40MINUS: - case NL80211_CHAN_HT40PLUS: - wiphy_err(hw->wiphy, - "%s: Need to implement 40 Mhz Channels!\n", __func__); - err = -ENOTSUPP; - break; - default: - err = -EINVAL; - } - - return err; -} - static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) { struct ieee80211_conf *conf = &hw->conf; @@ -433,9 +405,14 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) "\n", __func__, conf->power_level * 4, new_int); } - if (changed & IEEE80211_CONF_CHANGE_CHANNEL) - err = ieee_set_channel(hw, conf->channel, conf->channel_type); - + if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { + if (conf->channel_type == NL80211_CHAN_HT20 || + conf->channel_type == NL80211_CHAN_NO_HT) + err = brcms_c_set_channel(wl->wlc, + conf->channel->hw_value); + else + err = -ENOTSUPP; + } if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) err = brcms_c_set_rate_limit(wl->wlc, conf->short_frame_max_tx_count, diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 705f0ebb84b..bf3634e288e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -6288,14 +6288,8 @@ u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) return wlc->band->phytype; } -int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) +void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) { - if (sslot_override != BRCMS_SHORTSLOT_AUTO && - sslot_override != BRCMS_SHORTSLOT_OFF && - sslot_override != BRCMS_SHORTSLOT_ON) { - return -EINVAL; - } - wlc->shortslot_override = sslot_override; /* @@ -6303,7 +6297,7 @@ int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) * currently on the 5G band */ if (wlc->band->bandtype == BRCM_BAND_5G) - return 0; + return; if (wlc->pub->up && wlc->pub->associated) { /* let watchdog or beacon processing update shortslot */ @@ -6320,7 +6314,6 @@ int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); } - return 0; } /* diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 3655ac6ff6d..2069d16147d 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -386,7 +386,8 @@ void brcms_c_get_current_rateset(struct brcms_c_info *wlc, int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs); int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period); u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx); -int brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override); +void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, + s8 sslot_override); /* helper functions */ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); From 7d16c0ffff8cf8fbe915aa7cafbeadcff70a81bf Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:44 +0200 Subject: [PATCH 1037/1519] staging: brcm80211: fix for fullmac build problem Fullmac had a build error for CONFIG_PM_SLEEP=n Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 0aff62d89a6..7cb8f3f5a96 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -49,12 +49,10 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = { }; MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); -#ifdef CONFIG_PM_SLEEP static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); -#endif /* CONFIG_PM_SLEEP */ static bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) From 11de5b72cab5e14bef71ab2dde75d7278a90e38f Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:45 +0200 Subject: [PATCH 1038/1519] staging: brcm80211: macro cleanup in softmac dma Substituted macro's by functions. Renamed several struct members in dma.c to get rid of a set of macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 139 +++++++++++++---------- 1 file changed, 80 insertions(+), 59 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 63e5e0e8cfb..6c9b1fe29e9 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -155,9 +155,6 @@ #define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1 */ #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /* core-dependent data type */ -#define DMA64_DD_PARITY(dd) \ - parity32((dd)->addrlow ^ (dd)->addrhigh ^ (dd)->ctrl1 ^ (dd)->ctrl2) - /* * packet headroom necessary to accommodate the largest header * in the system, (i.e TXOFF). By doing, we avoid the need to @@ -192,27 +189,8 @@ #define DMA_NONE(args) -#define d64txregs dregs.d64_u.txregs_64 -#define d64rxregs dregs.d64_u.rxregs_64 -#define txd64 dregs.d64_u.txd_64 -#define rxd64 dregs.d64_u.rxd_64 - #define MAXNAMEL 8 /* 8 char names */ -/* descriptor bumping macros */ -/* faster than %, but n must be power of 2 */ -#define XXD(x, n) ((x) & ((n) - 1)) - -#define TXD(x) XXD((x), di->ntxd) -#define RXD(x) XXD((x), di->nrxd) -#define NEXTTXD(i) TXD((i) + 1) -#define PREVTXD(i) TXD((i) - 1) -#define NEXTRXD(i) RXD((i) + 1) -#define PREVRXD(i) RXD((i) - 1) - -#define NTXDACTIVE(h, t) TXD((t) - (h)) -#define NRXDACTIVE(h, t) RXD((t) - (h)) - /* macros to convert between byte offsets and indexes */ #define B2I(bytes, type) ((bytes) / sizeof(type)) #define I2B(index, type) ((index) * sizeof(type)) @@ -245,18 +223,14 @@ struct dma_info { bool dma64; /* this dma engine is operating in 64-bit mode */ bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ - union { - struct { - /* 64-bit dma tx engine registers */ - struct dma64regs *txregs_64; - /* 64-bit dma rx engine registers */ - struct dma64regs *rxregs_64; - /* pointer to dma64 tx descriptor ring */ - struct dma64desc *txd_64; - /* pointer to dma64 rx descriptor ring */ - struct dma64desc *rxd_64; - } d64_u; - } dregs; + /* 64-bit dma tx engine registers */ + struct dma64regs *d64txregs; + /* 64-bit dma rx engine registers */ + struct dma64regs *d64rxregs; + /* pointer to dma64 tx descriptor ring */ + struct dma64desc *txd64; + /* pointer to dma64 rx descriptor ring */ + struct dma64desc *rxd64; u16 dmadesc_align; /* alignment requirement for dma descriptors */ @@ -320,6 +294,65 @@ struct dma_info { */ static uint dma_msg_level; +/* Check for odd number of 1's */ +static u32 parity32(u32 data) +{ + data ^= data >> 16; + data ^= data >> 8; + data ^= data >> 4; + data ^= data >> 2; + data ^= data >> 1; + + return data & 1; +} + +static bool dma64_dd_parity(struct dma64desc *dd) +{ + return parity32(dd->addrlow ^ dd->addrhigh ^ dd->ctrl1 ^ dd->ctrl2); +} + +/* descriptor bumping functions */ + +static uint xxd(uint x, uint n) +{ + return x & (n - 1); /* faster than %, but n must be power of 2 */ +} + +static uint txd(struct dma_info *di, uint x) +{ + return xxd(x, di->ntxd); +} + +static uint rxd(struct dma_info *di, uint x) +{ + return xxd(x, di->nrxd); +} + +static uint nexttxd(struct dma_info *di, uint i) +{ + return txd(di, i + 1); +} + +static uint prevtxd(struct dma_info *di, uint i) +{ + return txd(di, i - 1); +} + +static uint nextrxd(struct dma_info *di, uint i) +{ + return txd(di, i + 1); +} + +static uint ntxdactive(struct dma_info *di, uint h, uint t) +{ + return txd(di, t-h); +} + +static uint nrxdactive(struct dma_info *di, uint h, uint t) +{ + return rxd(di, t-h); +} + static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) { uint dmactrlflags = di->dma.dmactrlflags; @@ -675,18 +708,6 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, return NULL; } -/* Check for odd number of 1's */ -static inline u32 parity32(u32 data) -{ - data ^= data >> 16; - data ^= data >> 8; - data ^= data >> 4; - data ^= data >> 2; - data ^= data >> 1; - - return data & 1; -} - static inline void dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, dma_addr_t pa, uint outidx, u32 *flags, u32 bufcount) @@ -713,7 +734,7 @@ dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, ddring[outidx].ctrl2 = cpu_to_le32(ctrl2); } if (di->dma.dmactrlflags & DMA_CTRL_PEN) { - if (DMA64_DD_PARITY(&ddring[outidx])) + if (dma64_dd_parity(&ddring[outidx])) ddring[outidx].ctrl2 = cpu_to_le32(ctrl2 | D64_CTRL2_PARITY); } @@ -866,7 +887,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) di->rxd64[i].addrlow = 0xdeadbeef; di->rxd64[i].addrhigh = 0xdeadbeef; - di->rxin = NEXTRXD(i); + di->rxin = nextrxd(di, i); return rxp; } @@ -988,7 +1009,7 @@ bool dma_rxfill(struct dma_pub *pub) rxin = di->rxin; rxout = di->rxout; - n = di->nrxpost - NRXDACTIVE(rxin, rxout); + n = di->nrxpost - nrxdactive(di, rxin, rxout); DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n)); @@ -1035,7 +1056,7 @@ bool dma_rxfill(struct dma_pub *pub) dma64_dd_upd(di, di->rxd64, pa, rxout, &flags, di->rxbufsize); - rxout = NEXTRXD(rxout); + rxout = nextrxd(di, rxout); } di->rxout = rxout; @@ -1237,7 +1258,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) next = p->next; /* return nonzero if out of tx descriptors */ - if (NEXTTXD(txout) == di->txin) + if (nexttxd(di, txout) == di->txin) goto outoftxd; if (len == 0) @@ -1262,16 +1283,16 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - txout = NEXTTXD(txout); + txout = nexttxd(di, txout); } /* if last txd eof not set, fix it */ if (!(flags & D64_CTRL1_EOF)) - di->txd64[PREVTXD(txout)].ctrl1 = + di->txd64[prevtxd(di, txout)].ctrl1 = cpu_to_le32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); /* save the packet */ - di->txp[PREVTXD(txout)] = p0; + di->txp[prevtxd(di, txout)] = p0; /* bump the tx descriptor index */ di->txout = txout; @@ -1282,7 +1303,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) di->xmtptrbase + I2B(txout, struct dma64desc)); /* tx flow control */ - di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; + di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; return 0; @@ -1341,14 +1362,14 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) (active_desc - di->xmtptrbase) & D64_XS0_CD_MASK; active_desc = B2I(active_desc, struct dma64desc); if (end != active_desc) - end = PREVTXD(active_desc); + end = prevtxd(di, active_desc); } } if ((start == 0) && (end > di->txout)) goto bogus; - for (i = start; i != end && !txp; i = NEXTTXD(i)) { + for (i = start; i != end && !txp; i = nexttxd(di, i)) { dma_addr_t pa; uint size; @@ -1370,7 +1391,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) di->txin = i; /* tx flow control */ - di->dma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; + di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; return txp; @@ -1401,6 +1422,6 @@ void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) tx_info = (struct ieee80211_tx_info *)skb->cb; (callback_fnc)(tx_info, arg_a); } - i = NEXTTXD(i); + i = nexttxd(di, i); } } From 00cf25ae119cb623583c33d61050bc7537335ac6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:46 +0200 Subject: [PATCH 1039/1519] staging: brcm80211: cleanup of softmac macro EDCF_ENAB() Since structure member pub->_wme is set to AUTO early in init, macro EDCF_ENAB is always 'true' after that. All code that uses ECDF_ENAB() appears in the code flow after the init. Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 53 +++-------------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 - drivers/staging/brcm80211/brcmsmac/pub.h | 4 -- drivers/staging/brcm80211/brcmsmac/scb.h | 2 +- 4 files changed, 8 insertions(+), 53 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index bf3634e288e..9921af29bb8 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3579,19 +3579,10 @@ static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc) wlc->tx_prec_map = BRCMS_PREC_BMP_ALL; memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16)); - /* - * For non-WME, both fifos have overlapping MAXPRIO. So just - * disable all precedences if either is full. - */ - if (!EDCF_ENAB(wlc->pub)) { - wlc->fifo2prec_map[TX_DATA_FIFO] = BRCMS_PREC_BMP_ALL; - wlc->fifo2prec_map[TX_CTL_FIFO] = BRCMS_PREC_BMP_ALL; - } else { - wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK; - wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE; - wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI; - wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO; - } + wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK; + wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE; + wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI; + wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO; } static void @@ -3698,10 +3689,8 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_bsinit(wlc); /* Enable EDCF mode (while the MAC is suspended) */ - if (EDCF_ENAB(wlc->pub)) { - OR_REG(®s->ifs_ctl, IFS_USEEDCF); - brcms_c_edcf_setparams(wlc, false); - } + OR_REG(®s->ifs_ctl, IFS_USEEDCF); + brcms_c_edcf_setparams(wlc, false); /* Init precedence maps for empty FIFOs */ brcms_c_tx_prec_map_init(wlc); @@ -4538,7 +4527,6 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->LRL = RETRY_LONG_DEF; /* WME QoS mode is Auto by default */ - wlc->pub->_wme = AUTO; wlc->pub->_ampdu = AMPDU_AGG_HOST; wlc->pub->bcmerror = 0; @@ -5745,10 +5733,7 @@ int brcms_c_up(struct brcms_c_info *wlc) brcms_c_radio_monitor_stop(wlc); /* Set EDCF hostflags */ - if (EDCF_ENAB(wlc->pub)) - brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); - else - brcms_c_mhf(wlc, MHF1, MHF1_EDCF, 0, BRCM_BAND_ALL); + brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); if (BRCMS_WAR16165(wlc)) brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR, @@ -6715,27 +6700,12 @@ void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, prio = sdu->priority; if (!brcms_c_prec_enq(wlc, q, sdu, prec)) { - if (!EDCF_ENAB(wlc->pub)) - wiphy_err(wlc->wiphy, "wl%d: txq_enq: txq overflow" - "\n", wlc->pub->unit); - /* * we might hit this condtion in case * packet flooding from mac80211 stack */ brcmu_pkt_buf_free_skb(sdu); } - - /* - * Check if flow control needs to be turned on after enqueuing the - * packet. Don't turn on flow control if EDCF is enabled. Driver - * would make the decision on what to drop instead of relying on - * stack to make the right decision - */ - if (!EDCF_ENAB(wlc->pub)) { - if (pktq_len(q) >= BRCMS_DATAHIWAT) - brcms_c_txflowcontrol(wlc, qi, ON, ALLPRIO); - } } /* @@ -7729,15 +7699,6 @@ void brcms_c_send_q(struct brcms_c_info *wlc) } } - /* - * Check if flow control needs to be turned off after - * sending the packet - */ - if (!EDCF_ENAB(wlc->pub)) { - if (brcms_c_txflowcontrol_prio_isset(wlc, qi, ALLPRIO) - && (pktq_len(q) < BRCMS_DATAHIWAT / 2)) - brcms_c_txflowcontrol(wlc, qi, OFF, ALLPRIO); - } in_send_q = false; } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index ed8369fe219..046225061c1 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -849,8 +849,6 @@ extern void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec); extern bool brcms_c_ps_allowed(struct brcms_c_info *wlc); extern bool brcms_c_stay_awake(struct brcms_c_info *wlc); -extern void brcms_c_wme_initparams_sta(struct brcms_c_info *wlc, - struct wme_param_ie *pe); extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type); diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 2069d16147d..62303509f8a 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -153,7 +153,6 @@ struct brcms_pub { bool promisc; /* promiscuous destination address */ bool delayed_down; /* down delayed */ - int _wme; /* WME QoS mode */ bool associated; /* true:part of [I]BSS, false: not */ /* (union of stas_associated, aps_associated) */ bool _ampdu; /* ampdu enabled or not */ @@ -197,9 +196,6 @@ enum wlc_par_id { /* WL11N Support */ #define AMPDU_AGG_HOST 1 -#define EDCF_ENAB(pub) ((pub)->_wme != OFF) -#define QOS_ENAB(pub) ((pub)->_wme != OFF || (pub)->_n_enab & SUPPORT_11N) - /* pri is priority encoded in the packet. This maps the Packet priority to * enqueue precedence as defined in wlc_prec_map */ diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index b2aacf3bf3f..122d3c36f0c 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -27,7 +27,7 @@ #define AMPDU_MAX_SCB_TID NUMPRIO /* scb flags */ -#define SCB_WMECAP 0x0040 /* may ONLY be set if pub->_wme!=OFF */ +#define SCB_WMECAP 0x0040 #define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */ #define SCB_IS40 0x80000 /* 40MHz capable */ #define SCB_STBCCAP 0x40000000 /* STBC Capable */ From be6d2b32e2e75e0225a63715e33a473e812cc64c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:47 +0200 Subject: [PATCH 1040/1519] staging: brcm80211: removed function brcms_c_wme_initparams_sta() since its variable assignment can be done in a more straightforward manner. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 57 +++++++---------------- drivers/staging/brcm80211/brcmsmac/main.h | 19 -------- 2 files changed, 17 insertions(+), 59 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 9921af29bb8..7067a02504e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -431,6 +431,12 @@ struct brcms_b_state { u32 preamble_ovr; /* preamble override */ }; +struct edcf_acparam { + u8 ACI; + u8 ECW; + u16 TXOP; +} __packed; + const u8 prio2fifo[NUMPRIO] = { TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ TX_AC_BK_FIFO, /* 1 BK AC_BK Background */ @@ -4124,34 +4130,6 @@ static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) } } -/* - * Initialize a WME Parameter Info Element with default - * STA parameters from WMM Spec, Table 12 - */ -void -brcms_c_wme_initparams_sta(struct brcms_c_info *wlc, struct wme_param_ie *pe) -{ - static const struct wme_param_ie stadef = { - WME_OUI, - WME_TYPE, - WME_SUBTYPE_PARAM_IE, - WME_VER, - 0, - 0, - { - {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, - cpu_to_le16(EDCF_AC_BE_TXOP_STA)}, - {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, - cpu_to_le16(EDCF_AC_BK_TXOP_STA)}, - {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, - cpu_to_le16(EDCF_AC_VI_TXOP_STA)}, - {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, - cpu_to_le16(EDCF_AC_VO_TXOP_STA)} - } - }; - memcpy(pe, &stadef, sizeof(*pe)); -} - void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, const struct ieee80211_tx_queue_params *params, bool suspend) @@ -4222,18 +4200,19 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) { u16 aci; int i_ac; - struct edcf_acparam *edcf_acp; - struct ieee80211_tx_queue_params txq_pars; struct ieee80211_tx_queue_params *params = &txq_pars; - - /* - * AP uses AC params from wme_param_ie_ap. - * AP advertises AC params from wme_param_ie. - * STA uses AC params from wme_param_ie. - */ - - edcf_acp = (struct edcf_acparam *) &wlc->wme_param_ie.acparam[0]; + static struct edcf_acparam default_edcf_acparams[] = { + {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, + cpu_to_le16(EDCF_AC_BE_TXOP_STA)}, + {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, + cpu_to_le16(EDCF_AC_BK_TXOP_STA)}, + {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, + cpu_to_le16(EDCF_AC_VI_TXOP_STA)}, + {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, + cpu_to_le16(EDCF_AC_VO_TXOP_STA)} + }; /* ucode needs these parameters during its initialization */ + struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { /* find out which ac this set of params applies to */ @@ -5294,8 +5273,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->cfg->_idx = 0; wlc->cfg->wlc = wlc; - brcms_c_wme_initparams_sta(wlc, &wlc->wme_param_ie); - wlc->mimoft = FT_HT; wlc->ht_cap.cap_info = HT_CAP; diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 046225061c1..aa0bf03825e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -298,22 +298,6 @@ struct modulecb { }; -struct edcf_acparam { - u8 ACI; - u8 ECW; - u16 TXOP; -} __packed; - -struct wme_param_ie { - u8 oui[3]; - u8 type; - u8 subtype; - u8 version; - u8 qosinfo; - u8 rsvd; - struct edcf_acparam acparam[AC_COUNT]; -} __packed; - struct brcms_hw_band { int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */ uint bandunit; /* bandstate[] index */ @@ -463,8 +447,6 @@ struct brcms_txq_info { * WDarmed: watchdog timer is armed. * WDlast: last time wlc_watchdog() was called. * edcf_txop[AC_COUNT]: current txop for each ac. - * wme_param_ie: on STA contains parameters in use locally, and on AP - * contains parameters advertised * wme_retries: per-AC retry limits. * tx_prec_map: Precedence map based on HW FIFO space. * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. @@ -578,7 +560,6 @@ struct brcms_c_info { /* WME */ u16 edcf_txop[AC_COUNT]; - struct wme_param_ie wme_param_ie; u16 wme_retries[AC_COUNT]; u16 tx_prec_map; u16 fifo2prec_map[NFIFO]; From 7d9e0b9a7f47844f3147db90d2149caf32dbf5e9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:48 +0200 Subject: [PATCH 1041/1519] staging: brcm80211: macro cleanup in softmac main.c Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 249 ++++++++++------------ 1 file changed, 115 insertions(+), 134 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 7067a02504e..a40fcba3815 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -167,23 +167,21 @@ #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ -/* - * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s - * OS timer(soft watchdog) it is not a wall clock and won't increment when - * driver is in "down" state this low resolution driver tick can be used - * for maintenance tasks such as phy calibration and scb update - */ - -#define BRCMS_WAR16165(wlc) (wlc->war16165) - /* Find basic rate for a given rate */ -#define BRCMS_BASIC_RATE(wlc, rspec) \ - (IS_MCS(rspec) \ - ? (wlc)->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK].leg_ofdm] \ - : (wlc)->band->basic_rate[rspec & RSPEC_RATE_MASK]) +static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) +{ + if (IS_MCS(rspec)) + return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] + .leg_ofdm]; + return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; +} -#define FRAMETYPE(r, mimoframe) \ - (IS_MCS(r) ? mimoframe : (IS_CCK(r) ? FT_CCK : FT_OFDM)) +static u16 frametype(u32 rspec, u8 mimoframe) +{ + if (IS_MCS(rspec)) + return mimoframe; + return IS_CCK(rspec) ? FT_CCK : FT_OFDM; +} /* rfdisable delay timer 500 ms, runs of ALP clock */ #define RFDISABLE_DEFAULT 10000000 @@ -240,11 +238,6 @@ #define FRAGNUM_MASK 0xF -#define DMAREG(wlc_hw, direction, fifonum) \ - ((direction == DMA_TX) ? \ - &(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ - &(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) - #define APHY_SLOT_TIME 9 #define BPHY_SLOT_TIME 20 @@ -359,21 +352,11 @@ #define END_FOREACH_BSS() } /* currently the best mechanism for determining SIFS is the band in use */ -#define SIFS(band) ((band)->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : \ - BPHY_SIFS_TIME); - -/* A fifo is full. Clear precedences related to that FIFO */ -#define BRCMS_TX_FIFO_CLEAR(wlc, fifo) \ - ((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo]) - -/* Fifo is NOT full. Enable precedences for that FIFO */ -#define BRCMS_TX_FIFO_ENAB(wlc, fifo) \ - ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo]) - -#define BRCMS_PORTOPEN(cfg) true - -#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \ - brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) +static u16 get_sifs(struct brcms_band *band) +{ + return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : + BPHY_SIFS_TIME; +} /* * Detect Card removed. @@ -384,45 +367,35 @@ * If clocks are present, call the sb routine which will figure out if the * device is removed. */ -#define DEVICEREMOVED(wlc) \ - ((wlc->hw->clk) ? \ - ((R_REG(&wlc->hw->regs->maccontrol) & \ - (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \ - (ai_deviceremoved(wlc->hw->sih))) - -#define BRCMS_WME_RETRY_SHORT_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_SHORT) -#define BRCMS_WME_RETRY_SFB_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_SFB) -#define BRCMS_WME_RETRY_LONG_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_LONG) -#define BRCMS_WME_RETRY_LFB_GET(wlc, ac) \ - GFIELD(wlc->wme_retries[ac], EDCF_LFB) - -#define BRCMS_WME_RETRY_SHORT_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val)) -#define BRCMS_WME_RETRY_SFB_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val)) -#define BRCMS_WME_RETRY_LONG_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val)) -#define BRCMS_WME_RETRY_LFB_SET(wlc, ac, val) \ - (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val)) +static bool brcms_deviceremoved(struct brcms_c_info *wlc) +{ + if (!wlc->hw->clk) + return ai_deviceremoved(wlc->hw->sih); + return (R_REG(&wlc->hw->regs->maccontrol) & + (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; +} /* sum the individual fifo tx pending packet counts */ -#define TXPKTPENDTOT(wlc) \ - ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ - (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) -#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) -#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) -#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val)) -#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) +static s16 brcms_txpktpendtot(struct brcms_c_info *wlc) +{ + return wlc->core->txpktpend[0] + wlc->core->txpktpend[1] + + wlc->core->txpktpend[2] + wlc->core->txpktpend[3]; +} -#define IS_MBAND_UNLOCKED(wlc) \ - ((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) +static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc) +{ + return wlc->pub->_nbands > 1 && !wlc->bandlocked; +} -#define CHSPEC_WLC_BW(chanspec) (CHSPEC_IS40(chanspec) ? BRCMS_40_MHZ : \ - CHSPEC_IS20(chanspec) ? BRCMS_20_MHZ : \ - BRCMS_10_MHZ) +static int brcms_chspec_bw(u16 chanspec) +{ + if (CHSPEC_IS40(chanspec)) + return BRCMS_40_MHZ; + if (CHSPEC_IS20(chanspec)) + return BRCMS_20_MHZ; + + return BRCMS_10_MHZ; +} /* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) driver */ @@ -973,7 +946,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) bool fatal = false; struct wiphy *wiphy = wlc->wiphy; - if (DEVICEREMOVED(wlc)) { + if (brcms_deviceremoved(wlc)) { wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, __func__); brcms_down(wlc->wl); @@ -1086,6 +1059,14 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) } } +static struct dma64regs * +dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) +{ + if (direction == DMA_TX) + return &(hw->regs->fifo64regs[fifonum].dmaxmt); + return &(hw->regs->fifo64regs[fifonum].dmarcv); +} + static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) { uint i; @@ -1110,8 +1091,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: RX_FIFO (RX data packets) */ wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, - (wme ? DMAREG(wlc_hw, DMA_TX, 0) : - NULL), DMAREG(wlc_hw, DMA_RX, 0), + (wme ? dmareg(wlc_hw, DMA_TX, 0) : + NULL), dmareg(wlc_hw, DMA_RX, 0), (wme ? NTXD : 0), NRXD, RXBUFSZ, -1, NRXBUFPOST, BRCMS_HWRXOFF, &brcm_msg_level); @@ -1124,7 +1105,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: UNUSED */ wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 1), NULL, + dmareg(wlc_hw, DMA_TX, 1), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[1]); @@ -1135,7 +1116,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: UNUSED */ wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 2), NULL, + dmareg(wlc_hw, DMA_TX, 2), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[2]); @@ -1145,7 +1126,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * (legacy) TX_CTL_FIFO (TX control & mgmt packets) */ wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 3), + dmareg(wlc_hw, DMA_TX, 3), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[3]); @@ -2567,7 +2548,7 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) * Read and clear macintmask and macintstatus and intstatus registers. * This routine should be called with interrupts off * Return: - * -1 if DEVICEREMOVED(wlc) evaluates to true; + * -1 if brcms_deviceremoved(wlc) evaluates to true; * 0 if the interrupt is not for us, or we are in some special cases; * device interrupt status bits otherwise. */ @@ -2584,10 +2565,10 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) macintstatus); /* detect cardbus removed, in power down(suspend) and in reset */ - if (DEVICEREMOVED(wlc)) + if (brcms_deviceremoved(wlc)) return -1; - /* DEVICEREMOVED succeeds even when the core is still resetting, + /* brcms_deviceremoved() succeeds even when the core is still resetting, * handle that case here. */ if (macintstatus == 0xffffffff) @@ -2916,7 +2897,7 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw) BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - dev_gone = DEVICEREMOVED(wlc_hw->wlc); + dev_gone = brcms_deviceremoved(wlc_hw->wlc); if (dev_gone) return; @@ -2949,7 +2930,7 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) for (i = 0; i < NFIFO; i++) if (wlc_hw->di[i]) { dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); - TXPKTPENDCLR(wlc, i); + wlc->core->txpktpend[i] = 0; BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); } @@ -3131,7 +3112,7 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) * disallow PS when one of the following * bsscfg specific conditions meets */ - if (!cfg->BSS || !BRCMS_PORTOPEN(cfg)) + if (!cfg->BSS) return false; if (!cfg->dtim_programmed) @@ -3147,7 +3128,7 @@ static void brcms_b_reset(struct brcms_hardware *wlc_hw) BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); /* reset the core */ - if (!DEVICEREMOVED(wlc_hw->wlc)) + if (!brcms_deviceremoved(wlc_hw->wlc)) brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); /* purge the dma rings */ @@ -3724,7 +3705,7 @@ void brcms_c_init(struct brcms_c_info *wlc) * Initialize WME parameters; if they haven't been set by some other * mechanism (IOVar, etc) then read them from the hardware. */ - if (BRCMS_WME_RETRY_SHORT_GET(wlc, 0) == 0) { + if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { /* Uninitialized; read from HW */ int ac; @@ -3987,16 +3968,14 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) brcms_c_set_phy_chanspec(wlc, chanspec); /* init antenna selection */ - if (CHSPEC_WLC_BW(old_chanspec) != CHSPEC_WLC_BW(chanspec)) { + if (brcms_chspec_bw(old_chanspec) != brcms_chspec_bw(chanspec)) { brcms_c_antsel_init(wlc->asi); /* Fix the hardware rateset based on bw. * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz */ brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, - wlc->band-> - mimo_cap_40 ? CHSPEC_WLC_BW(chanspec) - : 0); + wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); } /* update some mac configuration since chanspec changed */ @@ -4278,7 +4257,7 @@ static void brcms_c_radio_enable(struct brcms_c_info *wlc) if (wlc->pub->up) return; - if (DEVICEREMOVED(wlc)) + if (brcms_deviceremoved(wlc)) return; brcms_up(wlc->wl); @@ -4332,7 +4311,7 @@ static void brcms_c_radio_timer(void *arg) { struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - if (DEVICEREMOVED(wlc)) { + if (brcms_deviceremoved(wlc)) { wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, __func__); brcms_down(wlc->wl); @@ -4380,7 +4359,7 @@ static void brcms_c_watchdog(void *arg) if (!wlc->pub->up) return; - if (DEVICEREMOVED(wlc)) { + if (brcms_deviceremoved(wlc)) { wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, __func__); brcms_down(wlc->wl); @@ -4564,8 +4543,6 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) return wlc->pub; } -#define CHIP_SUPPORTS_11N(wlc) 1 - /* low level attach * run backplane attach, init nvram * run phy attach @@ -5011,7 +4988,7 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, band->bandtype, false, BRCMS_RATE_MASK_FULL, (bool) (wlc->pub->_n_enab & SUPPORT_11N), - CHSPEC_WLC_BW(chanspec), wlc->stf->txstreams); + brcms_chspec_bw(chanspec), wlc->stf->txstreams); if (wlc->pub->_n_enab & SUPPORT_11N) bi->flags |= BRCMS_BSS_HT; @@ -5202,7 +5179,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, } /* init _n_enab supported mode */ - if (BRCMS_PHY_11N_CAP(wlc->band) && CHIP_SUPPORTS_11N(wlc)) { + if (BRCMS_PHY_11N_CAP(wlc->band)) { if (n_disabled & WLFEATURE_DISABLE_11N) { pub->_n_enab = OFF; brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, @@ -5649,7 +5626,7 @@ int brcms_c_up(struct brcms_c_info *wlc) BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); /* HW is turned off so don't try to access it */ - if (wlc->pub->hw_off || DEVICEREMOVED(wlc)) + if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) return -ENOMEDIUM; if (!wlc->pub->hw_up) { @@ -5712,7 +5689,7 @@ int brcms_c_up(struct brcms_c_info *wlc) /* Set EDCF hostflags */ brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); - if (BRCMS_WAR16165(wlc)) + if (wlc->war16165) brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR, BRCM_BAND_ALL); @@ -5760,7 +5737,7 @@ static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) if (!wlc_hw->up) return callbacks; - dev_gone = DEVICEREMOVED(wlc_hw->wlc); + dev_gone = brcms_deviceremoved(wlc_hw->wlc); /* disable interrupts */ if (dev_gone) @@ -5791,7 +5768,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) wlc_hw->up = false; wlc_phy_hw_state_upd(wlc_hw->band->pi, false); - dev_gone = DEVICEREMOVED(wlc_hw->wlc); + dev_gone = brcms_deviceremoved(wlc_hw->wlc); if (dev_gone) { wlc_hw->sbclk = false; @@ -5850,7 +5827,7 @@ uint brcms_c_down(struct brcms_c_info *wlc) callbacks += brcms_b_bmac_down_prep(wlc->hw); - dev_gone = DEVICEREMOVED(wlc); + dev_gone = brcms_deviceremoved(wlc); /* Call any registered down handlers */ for (i = 0; i < BRCMS_MAXMODULES; i++) { @@ -6099,7 +6076,7 @@ brcms_c_set_internal_rateset(struct brcms_c_info *wlc, goto good; /* try the other band */ - if (IS_MBAND_UNLOCKED(wlc)) { + if (brcms_is_mband_unlocked(wlc)) { bandunit = OTHERBANDUNIT(wlc); memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); if (brcms_c_rate_hwrs_filter_sort_validate(&new, @@ -6147,7 +6124,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) return -EINVAL; - if (!wlc->pub->up && IS_MBAND_UNLOCKED(wlc)) { + if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { if (wlc->band->bandunit != chspec_bandunit(chspec)) wlc->bandinit_pending = true; else @@ -6180,8 +6157,10 @@ int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); for (ac = 0; ac < AC_COUNT; ac++) { - BRCMS_WME_RETRY_SHORT_SET(wlc, ac, srl); - BRCMS_WME_RETRY_LONG_SET(wlc, ac, lrl); + wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], + EDCF_SHORT, wlc->SRL); + wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], + EDCF_LONG, wlc->LRL); } brcms_c_wme_retries_write(wlc); @@ -6400,8 +6379,8 @@ void brcms_c_statsupd(struct brcms_c_info *wlc) #endif /* BCMDBG */ /* Read mac stats from contiguous shared memory */ - brcms_b_copyfrom_shm(wlc->hw, M_UCODE_MACSTAT, - &macstats, sizeof(struct macstat)); + brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats, + sizeof(struct macstat), OBJADDR_SHM_SEL); #ifdef BCMDBG /* check for rx fifo 0 overflow */ @@ -6719,7 +6698,7 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, * is less than or equal to the rate of the immediately previous * frame in the FES */ - rspec = BRCMS_BASIC_RATE(wlc, rspec); + rspec = brcms_basic_rate(wlc, rspec); /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ dur = brcms_c_calc_frame_time(wlc, rspec, preamble_type, @@ -6747,7 +6726,7 @@ brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, * is less than or equal to the rate of the immediately previous * frame in the FES */ - rspec = BRCMS_BASIC_RATE(wlc, rspec); + rspec = brcms_basic_rate(wlc, rspec); /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ return brcms_c_calc_frame_time(wlc, rspec, preamble_type, (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + @@ -6770,7 +6749,7 @@ brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, { u16 dur, sifs; - sifs = SIFS(wlc->band); + sifs = get_sifs(wlc->band); dur = sifs; dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); @@ -7140,7 +7119,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * Is the phy configured to use 40MHZ frames? If * so then pick the desired txbw */ - if (CHSPEC_WLC_BW(wlc->chanspec) == BRCMS_40_MHZ) { + if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { /* default txbw is 20in40 SB */ mimo_ctlchbw = mimo_txbw = CHSPEC_SB_UPPER(wlc_phy_chanspec_get( @@ -7458,15 +7437,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, txh->MainRates = cpu_to_le16(mainrates); /* XtraFrameTypes */ - xfts = FRAMETYPE(rspec[1], wlc->mimoft); - xfts |= (FRAMETYPE(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); - xfts |= (FRAMETYPE(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); + xfts = frametype(rspec[1], wlc->mimoft); + xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); + xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << XFTS_CHANNEL_SHIFT; txh->XtraFrameTypes = cpu_to_le16(xfts); /* PhyTxControlWord */ - phyctl = FRAMETYPE(rspec[0], wlc->mimoft); + phyctl = frametype(rspec[0], wlc->mimoft); if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) || (preamble_type[0] == BRCMS_GF_PREAMBLE)) { if (RSPEC2RATE(rspec[0]) != BRCM_RATE_1M) @@ -7707,7 +7686,7 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, if (fifo == TX_BCMC_FIFO) frameid = le16_to_cpu(txh->TxFrameID); - if (BRCMS_WAR16165(wlc)) + if (wlc->war16165) brcms_c_war16165(wlc, true); @@ -7716,9 +7695,9 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, * used, this will be handled in brcms_b_txfifo() */ if (commit) { - TXPKTPENDINC(wlc, fifo, txpktpend); + wlc->core->txpktpend[fifo] += txpktpend; BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n", - txpktpend, TXPKTPENDGET(wlc, fifo)); + txpktpend, wlc->core->txpktpend[fifo]); } /* Commit BCMC sequence number in the SHM frame ID location */ @@ -7867,7 +7846,7 @@ brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, { u16 dur, sifs; - sifs = SIFS(wlc->band); + sifs = get_sifs(wlc->band); if (!cts_only) { /* RTS/CTS */ @@ -7955,19 +7934,19 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, rts_rspec = rspec; else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) /* Use 11Mbps as the g protection RTS target rate and fallback. - * Use the BRCMS_BASIC_RATE() lookup to find the best basic rate + * Use the brcms_basic_rate() lookup to find the best basic rate * under the target in case 11 Mbps is not Basic. * 6 and 9 Mbps are not usually selected by rate selection, but * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 * is more robust. */ - rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); + rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M); else /* calculate RTS rate and fallback rate based on the frame rate * RTS must be sent at a basic rate since it is a * control frame, sec 9.6 of 802.11 spec */ - rts_rspec = BRCMS_BASIC_RATE(wlc, rspec); + rts_rspec = brcms_basic_rate(wlc, rspec); if (BRCMS_PHY_11N_CAP(wlc->band)) { /* set rts txbw to correct side band */ @@ -8043,7 +8022,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) } p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); - if (BRCMS_WAR16165(wlc)) + if (wlc->war16165) brcms_c_war16165(wlc, false); if (p == NULL) goto fatal; @@ -8103,8 +8082,10 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) fbl; if (queue < AC_COUNT) { - sfbl = BRCMS_WME_RETRY_SFB_GET(wlc, wme_fifo2ac[queue]); - lfbl = BRCMS_WME_RETRY_LFB_GET(wlc, wme_fifo2ac[queue]); + sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], + EDCF_SFB); + lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], + EDCF_LFB); } else { sfbl = wlc->SFBL; lfbl = wlc->LFBL; @@ -8179,12 +8160,12 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) { - TXPKTPENDDEC(wlc, fifo, txpktpend); + wlc->core->txpktpend[fifo] -= txpktpend; BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend, - TXPKTPENDGET(wlc, fifo)); + wlc->core->txpktpend[fifo]); /* There is more room; mark precedences related to this FIFO sendable */ - BRCMS_TX_FIFO_ENAB(wlc, fifo); + wlc->tx_prec_map |= wlc->fifo2prec_map[fifo]; /* figure out which bsscfg is being worked on... */ } @@ -8774,10 +8755,10 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc) for (i = 0; i < rs.count; i++) { rate = rs.rates[i] & BRCMS_RATE_MASK; - /* for a given rate BRCMS_BASIC_RATE returns the rate at + /* for a given rate brcms_basic_rate returns the rate at * which a response ACK/CTS should be sent. */ - basic_rate = BRCMS_BASIC_RATE(wlc, rate); + basic_rate = brcms_basic_rate(wlc, rate); if (basic_rate == 0) /* This should only happen if we are using a * restricted rateset. @@ -8835,7 +8816,7 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) u16 dur, sifs; uint i; - sifs = SIFS(wlc->band); + sifs = get_sifs(wlc->band); rs_dflt = brcms_c_rateset_get_hwrs(wlc); @@ -9124,7 +9105,8 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) /* return if insufficient dma resources */ if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) { /* Mark precedences related to this FIFO, unsendable */ - BRCMS_TX_FIFO_CLEAR(wlc, fifo); + /* A fifo is full. Clear precedences related to that FIFO */ + wlc->tx_prec_map &= ~(wlc->fifo2prec_map[fifo]); return -EBUSY; } return 0; @@ -9153,7 +9135,7 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) brcms_c_rateset_default(rs, NULL, wlc->band->phytype, wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, (bool) (wlc->pub->_n_enab & SUPPORT_11N), - CHSPEC_WLC_BW(wlc->default_bss->chanspec), + brcms_chspec_bw(wlc->default_bss->chanspec), wlc->stf->txstreams); } @@ -9389,8 +9371,7 @@ void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL); /* wait for queue and DMA fifos to run dry */ - while (!pktq_empty(&wlc->pkt_queue->q) || - TXPKTPENDTOT(wlc) > 0) + while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) brcms_msleep(wlc->wl, 1); } From 5b876618c0ce69151571f6f197e7c54fd5b80081 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:49 +0200 Subject: [PATCH 1042/1519] staging: brcm80211: added clarification on softmac dma alignment Descriptor ring can only start at 8KB alignment, this requirement is dictated by DMA hardware. Reported-by: Johannes Berg Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 6c9b1fe29e9..06990b3d6cd 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -24,8 +24,8 @@ #include "dma.h" /* - * Each descriptor ring must be 8kB aligned, and fit within a - * contiguous 8kB physical address. + * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within + * a contiguous 8kB physical address. */ #define D64RINGALIGN_BITS 13 #define D64MAXRINGSZ (1 << D64RINGALIGN_BITS) @@ -440,6 +440,10 @@ static bool _dma_descriptor_align(struct dma_info *di) return true; } +/* + * Descriptor table must start at the DMA hardware dictated alignment, so + * allocated memory must be large enough to support this requirement. + */ static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, uint *alloced, dma_addr_t *pap) From 2e08396da0d185d81101e96de3ac4bc65b96d2fa Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 13 Sep 2011 09:49:50 +0200 Subject: [PATCH 1043/1519] staging: brcm80211: remove devpath related nvram variable lookup The lookup function used for the devpath related functions did not provide a variable table so the lookup would always fail. As this makes the functions pretty useless these have been removed. Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 62 +------------------- drivers/staging/brcm80211/brcmsmac/aiutils.h | 5 -- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 9510d838009..b7b0bdf1982 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1018,17 +1018,9 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) /* do a pci config read to get subsystem id and subvendor id */ pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w); - /* Let nvram variables override subsystem Vend/ID */ - sii->pub.boardvendor = (u16)ai_getdevpathintvar(&sii->pub, - "boardvendor"); - if (sii->pub.boardvendor == 0) - sii->pub.boardvendor = w & 0xffff; - - sii->pub.boardtype = (u16)ai_getdevpathintvar(&sii->pub, - "boardtype"); - if (sii->pub.boardtype == 0) - sii->pub.boardtype = (w >> 16) & 0xffff; + sii->pub.boardvendor = w & 0xffff; + sii->pub.boardtype = (w >> 16) & 0xffff; sii->pub.boardflags = getintvar(pvars, "boardflags"); } @@ -1864,56 +1856,6 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return 0; } -/* Concatenate the dev path with a varname into the given 'var' buffer - * and return the 'var' pointer. Nothing is done to the arguments if - * len == 0 or var is NULL, var is still returned. On overflow, the - * first char will be set to '\0'. - */ -static char *ai_devpathvar(struct si_pub *sih, char *var, int len, - const char *name) -{ - uint path_len; - - if (!var || len <= 0) - return var; - - if (ai_devpath(sih, var, len) == 0) { - path_len = strlen(var); - - if (strlen(name) + 1 > (uint) (len - path_len)) - var[0] = '\0'; - else - strncpy(var + path_len, name, len - path_len - 1); - } - - return var; -} - -/* Get a variable, but only if it has a devpath prefix */ -char *ai_getdevpathvar(struct si_pub *sih, const char *name) -{ - char varname[SI_DEVPATH_BUFSZ + 32]; - - ai_devpathvar(sih, varname, sizeof(varname), name); - - return getvar(NULL, varname); -} - -/* Get a variable, but only if it has a devpath prefix */ -int ai_getdevpathintvar(struct si_pub *sih, const char *name) -{ - char varname[SI_DEVPATH_BUFSZ + 32]; - - ai_devpathvar(sih, varname, sizeof(varname), name); - - return getintvar(NULL, varname); -} - -char *ai_getnvramflvar(struct si_pub *sih, const char *name) -{ - return getvar(NULL, name); -} - bool ai_pci_war16165(struct si_pub *sih) { struct si_info *sii; diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 0d4fa85f9be..a7769451cff 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -369,9 +369,6 @@ extern bool ai_is_sprom_available(struct si_pub *sih); * Return 0 on success, nonzero otherwise. */ extern int ai_devpath(struct si_pub *sih, char *path, int size); -/* Read variable with prepending the devpath to the name */ -extern char *ai_getdevpathvar(struct si_pub *sih, const char *name); -extern int ai_getdevpathintvar(struct si_pub *sih, const char *name); extern void ai_pci_sleep(struct si_pub *sih); extern void ai_pci_down(struct si_pub *sih); @@ -382,6 +379,4 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on); /* Enable Ex-PA for 4313 */ extern void ai_epa_4313war(struct si_pub *sih); -char *ai_getnvramflvar(struct si_pub *sih, const char *name); - #endif /* _BRCM_AIUTILS_H_ */ From 2fc6af5b8c9bcb39ae1ffa0f4e72dcb011332ae8 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 13 Sep 2011 09:49:51 +0200 Subject: [PATCH 1044/1519] staging: brcm80211: remove brcms_c_get_par and set_par functions The source main.c provided an interface function that handled several things demultiplexing on given identifier. This interface has been replaced by separate functions to make it more straightforward. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 26 ++---- drivers/staging/brcm80211/brcmsmac/main.c | 85 ++++++------------- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- drivers/staging/brcm80211/brcmsmac/pub.h | 8 +- 4 files changed, 38 insertions(+), 83 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 3ec72f1a38f..65d30b58469 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -373,14 +373,8 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) LOCK(wl); if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { - if (brcms_c_set_par(wl->wlc, IOV_BCN_LI_BCN, - conf->listen_interval) < 0) { - wiphy_err(wiphy, "%s: Error setting listen_interval\n", - __func__); - err = -EIO; - goto config_out; - } - brcms_c_get_par(wl->wlc, IOV_BCN_LI_BCN, &new_int); + brcms_c_set_beacon_listen_interval(wl->wlc, + conf->listen_interval); } if (changed & IEEE80211_CONF_CHANGE_MONITOR) wiphy_err(wiphy, "%s: change monitor mode: %s (implement)\n", @@ -392,17 +386,16 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) "true" : "false"); if (changed & IEEE80211_CONF_CHANGE_POWER) { - if (brcms_c_set_par(wl->wlc, IOV_QTXPOWER, - conf->power_level * 4) < 0) { + err = brcms_c_set_tx_power(wl->wlc, conf->power_level); + if (err < 0) { wiphy_err(wiphy, "%s: Error setting power_level\n", __func__); - err = -EIO; goto config_out; } - brcms_c_get_par(wl->wlc, IOV_QTXPOWER, &new_int); - if (new_int != (conf->power_level * 4)) + new_int = brcms_c_get_tx_power(wl->wlc); + if (new_int != conf->power_level) wiphy_err(wiphy, "%s: Power level req != actual, %d %d" - "\n", __func__, conf->power_level * 4, + "\n", __func__, conf->power_level, new_int); } if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { @@ -1177,9 +1170,8 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; - if (brcms_c_set_par(wl->wlc, IOV_MPC, 0) < 0) - wiphy_err(wl->wiphy, "wl%d: Error setting MPC variable to 0\n", - unit); + /* disable mpc */ + brcms_c_set_radio_mpc(wl->wlc, false); /* register our interrupt handler */ if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index a40fcba3815..ec7de38069e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -9375,74 +9375,37 @@ void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) brcms_msleep(wlc->wl, 1); } -int brcms_c_set_par(struct brcms_c_info *wlc, enum wlc_par_id par_id, - int int_val) +void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) { - int err = 0; - - switch (par_id) { - case IOV_BCN_LI_BCN: - wlc->bcn_li_bcn = (u8) int_val; - if (wlc->pub->up) - brcms_c_bcn_li_upd(wlc); - break; - /* As long as override is false, this only sets the *user* - targets. User can twiddle this all he wants with no harm. - wlc_phy_txpower_set() explicitly sets override to false if - not internal or test. - */ - case IOV_QTXPOWER:{ - u8 qdbm; - bool override; - - /* Remove override bit and clip to max qdbm value */ - qdbm = (u8)min_t(u32, (int_val & ~WL_TXPWR_OVERRIDE), 0xff); - /* Extract override setting */ - override = (int_val & WL_TXPWR_OVERRIDE) ? true : false; - err = - wlc_phy_txpower_set(wlc->band->pi, qdbm, override); - break; - } - case IOV_MPC: - wlc->mpc = (bool)int_val; - brcms_c_radio_mpc_upd(wlc); - break; - default: - err = -ENOTSUPP; - } - return err; + wlc->bcn_li_bcn = interval; + if (wlc->pub->up) + brcms_c_bcn_li_upd(wlc); } -int brcms_c_get_par(struct brcms_c_info *wlc, enum wlc_par_id par_id, - int *ret_int_ptr) +int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr) { - int err = 0; + uint qdbm; - switch (par_id) { - case IOV_BCN_LI_BCN: - *ret_int_ptr = wlc->bcn_li_bcn; - break; - case IOV_QTXPOWER: { - uint qdbm; - bool override; + /* Remove override bit and clip to max qdbm value */ + qdbm = min_t(uint, txpwr * BRCMS_TXPWR_DB_FACTOR, 0xff); + return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); +} - err = wlc_phy_txpower_get(wlc->band->pi, &qdbm, - &override); - if (err != 0) - return err; +int brcms_c_get_tx_power(struct brcms_c_info *wlc) +{ + uint qdbm; + bool override; - /* Return qdbm units */ - *ret_int_ptr = - qdbm | (override ? WL_TXPWR_OVERRIDE : 0); - break; - } - case IOV_MPC: - *ret_int_ptr = (s32) wlc->mpc; - break; - default: - err = -ENOTSUPP; - } - return err; + wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); + + /* Return qdbm units */ + return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); +} + +void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) +{ + wlc->mpc = mpc; + brcms_c_radio_mpc_upd(wlc); } /* diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index eb171f0269c..196a595f73e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -1463,7 +1463,7 @@ int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override) int i; if (qdbm > 127) - return 5; + return -EINVAL; for (i = 0; i < TXP_NUM_RATES; i++) pi->tx_user_target[i] = (u8) qdbm; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 62303509f8a..c72f7b581b9 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -350,10 +350,6 @@ extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta, u16 tid); extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, u8 ba_wsize, uint max_rx_ampdu_bytes); -extern int brcms_c_set_par(struct brcms_c_info *wlc, enum wlc_par_id par_id, - int val); -extern int brcms_c_get_par(struct brcms_c_info *wlc, enum wlc_par_id par_id, - int *ret_int_ptr); extern char *getvar(char *vars, const char *name); extern int getintvar(char *vars, const char *name); @@ -384,6 +380,10 @@ int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period); u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx); void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override); +void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval); +int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); +int brcms_c_get_tx_power(struct brcms_c_info *wlc); +void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc); /* helper functions */ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); From 7a447be316f99bf8a15a52612f25ee53632908dc Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:52 +0200 Subject: [PATCH 1045/1519] staging: brcm80211: macro cleanup in softmac rate.h Substituted/moved/deleted macro's. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 25 ++- drivers/staging/brcm80211/brcmsmac/main.c | 173 ++++++++++----------- drivers/staging/brcm80211/brcmsmac/rate.c | 16 +- drivers/staging/brcm80211/brcmsmac/rate.h | 156 ++++++++++++------- drivers/staging/brcm80211/brcmsmac/stf.c | 2 +- 5 files changed, 204 insertions(+), 168 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 76f487183c5..47dc27acf35 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -158,16 +158,16 @@ static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) { /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */ /* 20MHz, No SGI */ - rate = MCS_RATE(mcs, false, false); + rate = mcs_2_rate(mcs, false, false); ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3; /* 40 MHz, No SGI */ - rate = MCS_RATE(mcs, true, false); + rate = mcs_2_rate(mcs, true, false); ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3; /* 20MHz, SGI */ - rate = MCS_RATE(mcs, false, true); + rate = mcs_2_rate(mcs, false, true); ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3; /* 40 MHz, SGI */ - rate = MCS_RATE(mcs, true, true); + rate = mcs_2_rate(mcs, true, true); ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3; } } @@ -330,7 +330,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) /* note : we divide/multiply by 100 to avoid integer overflows */ max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], AMPDU_NUM_MPDU_LEGACY); - phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); + phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false); dma_rate = (((phy_rate / 100) * (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) @@ -341,7 +341,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) dma_rate = dma_rate >> 7; for (i = 0; i < FFPLD_MAX_MCS; i++) { /* shifting to keep it within integer range */ - phy_rate = MCS_RATE(i, true, false) >> 7; + phy_rate = mcs_2_rate(i, true, false) >> 7; if (phy_rate > dma_rate) { tmp = ((fifo->ampdu_pld_size * phy_rate) / ((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1; @@ -360,7 +360,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) { struct ampdu_info *ampdu = wlc->ampdu; - u32 phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); + u32 phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false); u32 txunfl_ratio; u8 max_mpdu; u32 current_ampdu_cnt = 0; @@ -678,7 +678,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, } is40 = (plcp0 & MIMO_PLCP_40MHZ) ? 1 : 0; - sgi = PLCP3_ISSGI(plcp3) ? 1 : 0; + sgi = plcp3_issgi(plcp3) ? 1 : 0; mcs = plcp0 & ~MIMO_PLCP_40MHZ; max_ampdu_bytes = min(scb_ampdu->max_rx_ampdu_bytes, @@ -697,9 +697,8 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT); if (fbr_iscck) /* CCK */ - rspec_fallback = - CCK_RSPEC(CCK_PHY2MAC_RATE - (txh->FragPLCPFallback[0])); + rspec_fallback = cck_rspec(cck_phy2mac_rate + (txh->FragPLCPFallback[0])); else { /* MIMO */ rspec_fallback = RSPEC_MIMORATE; rspec_fallback |= @@ -722,7 +721,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, /* if (first mpdu for host agg) */ /* test whether to add more */ - if ((MCS_RATE(mcs, true, false) >= f->dmaxferrate) && + if ((mcs_2_rate(mcs, true, false) >= f->dmaxferrate) && (count == f->mcs2ampdu_table[mcs])) { BCMMSG(wlc->wiphy, "wl%d: PR 37644: stopping" " ampdu at %d for mcs %d\n", @@ -816,7 +815,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, } /* set the preload length */ - if (MCS_RATE(mcs, true, false) >= f->dmaxferrate) { + if (mcs_2_rate(mcs, true, false) >= f->dmaxferrate) { dma_len = min(dma_len, f->ampdu_pld_size); txh->PreloadSize = cpu_to_le16(dma_len); } else diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index ec7de38069e..2c9ac6db4ff 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -170,7 +170,7 @@ /* Find basic rate for a given rate */ static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) { - if (IS_MCS(rspec)) + if (is_mcs_rate(rspec)) return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] .leg_ofdm]; return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; @@ -178,9 +178,9 @@ static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) static u16 frametype(u32 rspec, u8 mimoframe) { - if (IS_MCS(rspec)) + if (is_mcs_rate(rspec)) return mimoframe; - return IS_CCK(rspec) ? FT_CCK : FT_OFDM; + return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; } /* rfdisable delay timer 500 ms, runs of ALP clock */ @@ -4001,7 +4001,7 @@ u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, * pick siso/cdd as default for OFDM (note no basic * rate MCSs are supported yet) */ - if (IS_OFDM(lowest_basic_rspec)) + if (is_ofdm_rate(lowest_basic_rspec)) lowest_basic_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); return lowest_basic_rspec; @@ -6560,7 +6560,7 @@ u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) u8 phy_rate, index; /* get the phy specific rate encoding for the PLCP SIGNAL field */ - if (IS_OFDM(rate)) + if (is_ofdm_rate(rate)) table_ptr = M_RT_DIRMAP_A; else table_ptr = M_RT_DIRMAP_B; @@ -6772,27 +6772,26 @@ brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, u8 preamble_type, uint dur) { uint nsyms, mac_len, Ndps, kNdps; - uint rate = RSPEC2RATE(ratespec); + uint rate = rspec2rate(ratespec); BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n", wlc->pub->unit, ratespec, preamble_type, dur); - if (IS_MCS(ratespec)) { + if (is_mcs_rate(ratespec)) { uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec); + int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); /* payload calculation matches that of regular ofdm */ if (wlc->band->bandtype == BRCM_BAND_2G) dur -= DOT11_OFDM_SIGNAL_EXTENSION; /* kNdbps = kbps * 4 */ - kNdps = - MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), - RSPEC_ISSGI(ratespec)) * 4; + kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), + rspec_issgi(ratespec)) * 4; nsyms = dur / APHY_SYMBOL_TIME; mac_len = ((nsyms * kNdps) - ((APHY_SERVICE_NBITS + APHY_TAIL_NBITS) * 1000)) / 8000; - } else if (IS_OFDM(ratespec)) { + } else if (is_ofdm_rate(ratespec)) { dur -= APHY_PREAMBLE_TIME; dur -= APHY_SIGNAL_TIME; /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ @@ -6872,14 +6871,14 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, goto done; } } - } else if (IS_OFDM(rate)) { + } else if (is_ofdm_rate(rate)) { if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", wlc->pub->unit, __func__); bcmerror = -EINVAL; goto done; } - } else if (IS_CCK(rate)) { + } else if (is_cck_rate(rate)) { if ((cur_band->bandtype != BRCM_BAND_2G) || (stf != PHY_TXC1_MODE_SISO)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", @@ -7074,7 +7073,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * determine and validate primary rate * and fallback rates */ - if (!RSPEC_ACTIVE(rspec[k])) { + if (!rspec_active(rspec[k])) { rspec[k] = BRCM_RATE_1M; } else { if (!is_multicast_ether_addr(h->addr1)) { @@ -7093,15 +7092,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * apply siso/cdd to single stream mcs's or ofdm * if rspec is auto selected */ - if (((IS_MCS(rspec[k]) && - IS_SINGLE_STREAM(rspec[k] & RSPEC_RATE_MASK)) || - IS_OFDM(rspec[k])) + if (((is_mcs_rate(rspec[k]) && + is_single_stream(rspec[k] & RSPEC_RATE_MASK)) || + is_ofdm_rate(rspec[k])) && ((rspec[k] & RSPEC_OVERRIDE_MCS_ONLY) || !(rspec[k] & RSPEC_OVERRIDE))) { rspec[k] &= ~(RSPEC_STF_MASK | RSPEC_STC_MASK); /* For SISO MCS use STBC if possible */ - if (IS_MCS(rspec[k]) + if (is_mcs_rate(rspec[k]) && BRCMS_STF_SS_STBC_TX(wlc, scb)) { u8 stc; @@ -7126,7 +7125,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, wlc->band->pi)) ? PHY_TXC1_BW_20MHZ_UP : PHY_TXC1_BW_20MHZ; - if (IS_MCS(rspec[k])) { + if (is_mcs_rate(rspec[k])) { /* mcs 32 must be 40b/w DUP */ if ((rspec[k] & RSPEC_RATE_MASK) == 32) { @@ -7138,7 +7137,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* else check if dst is using 40 Mhz */ else if (scb->flags & SCB_IS40) mimo_txbw = PHY_TXC1_BW_40MHZ; - } else if (IS_OFDM(rspec[k])) { + } else if (is_ofdm_rate(rspec[k])) { if (wlc->ofdm_40txbw != AUTO) mimo_txbw = wlc->ofdm_40txbw; } else if (wlc->cck_40txbw != AUTO) { @@ -7159,7 +7158,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* Set channel width */ rspec[k] &= ~RSPEC_BW_MASK; - if ((k == 0) || ((k > 0) && IS_MCS(rspec[k]))) + if ((k == 0) || ((k > 0) && is_mcs_rate(rspec[k]))) rspec[k] |= (mimo_txbw << RSPEC_BW_SHIFT); else rspec[k] |= (mimo_ctlchbw << RSPEC_BW_SHIFT); @@ -7172,13 +7171,13 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, mimo_preamble_type = BRCMS_GF_PREAMBLE; if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) - && (!IS_MCS(rspec[k]))) { + && (!is_mcs_rate(rspec[k]))) { wiphy_err(wlc->wiphy, "wl%d: %s: IEEE80211_TX_" - "RC_MCS != IS_MCS(rspec)\n", + "RC_MCS != is_mcs_rate(rspec)\n", wlc->pub->unit, __func__); } - if (IS_MCS(rspec[k])) { + if (is_mcs_rate(rspec[k])) { preamble_type[k] = mimo_preamble_type; /* @@ -7186,13 +7185,13 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * for single stream */ if ((rspec[k] & RSPEC_SHORT_GI) - && IS_SINGLE_STREAM(rspec[k] & + && is_single_stream(rspec[k] & RSPEC_RATE_MASK)) preamble_type[k] = BRCMS_MM_PREAMBLE; } /* should be better conditionalized */ - if (!IS_MCS(rspec[0]) + if (!is_mcs_rate(rspec[0]) && (tx_info->control.rates[0]. flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)) preamble_type[k] = BRCMS_SHORT_PREAMBLE; @@ -7204,7 +7203,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, rspec[k] |= (PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT); /* for nphy, stf of ofdm frames must follow policies */ - if (BRCMS_ISNPHY(wlc->band) && IS_OFDM(rspec[k])) { + if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { rspec[k] &= ~RSPEC_STF_MASK; rspec[k] |= phyctl1_stf << RSPEC_STF_SHIFT; } @@ -7229,13 +7228,13 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, plcp_fallback, sizeof(txh->FragPLCPFallback)); /* Length field now put in CCK FBR CRC field */ - if (IS_CCK(rspec[1])) { + if (is_cck_rate(rspec[1])) { txh->FragPLCPFallback[4] = phylen & 0xff; txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; } /* MIMO-RATE: need validation ?? */ - mainrates = IS_OFDM(rspec[0]) ? + mainrates = is_ofdm_rate(rspec[0]) ? D11A_PHY_HDR_GRATE((struct ofdm_phy_hdr *) plcp) : plcp[0]; @@ -7292,7 +7291,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, /* Set fallback rate preamble type */ if ((preamble_type[1] == BRCMS_SHORT_PREAMBLE) || (preamble_type[1] == BRCMS_GF_PREAMBLE)) { - if (RSPEC2RATE(rspec[1]) != BRCM_RATE_1M) + if (rspec2rate(rspec[1]) != BRCM_RATE_1M) mch |= TXC_PREAMBLE_DATA_FB_SHORT; } @@ -7336,15 +7335,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, mimo_ctlchbw); } - if (!IS_OFDM(rts_rspec[0]) && - !((RSPEC2RATE(rts_rspec[0]) == BRCM_RATE_1M) || + if (!is_ofdm_rate(rts_rspec[0]) && + !((rspec2rate(rts_rspec[0]) == BRCM_RATE_1M) || (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { rts_preamble_type[0] = BRCMS_SHORT_PREAMBLE; mch |= TXC_PREAMBLE_RTS_MAIN_SHORT; } - if (!IS_OFDM(rts_rspec[1]) && - !((RSPEC2RATE(rts_rspec[1]) == BRCM_RATE_1M) || + if (!is_ofdm_rate(rts_rspec[1]) && + !((rspec2rate(rts_rspec[1]) == BRCM_RATE_1M) || (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { rts_preamble_type[1] = BRCMS_SHORT_PREAMBLE; mch |= TXC_PREAMBLE_RTS_FB_SHORT; @@ -7403,7 +7402,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * low 8 bits: main frag rate/mcs, * high 8 bits: rts/cts rate/mcs */ - mainrates |= (IS_OFDM(rts_rspec[0]) ? + mainrates |= (is_ofdm_rate(rts_rspec[0]) ? D11A_PHY_HDR_GRATE( (struct ofdm_phy_hdr *) rts_plcp) : rts_plcp[0]) << 8; @@ -7418,7 +7417,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, #ifdef SUPPORT_40MHZ /* add null delimiter count */ - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && IS_MCS(rspec)) + if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); @@ -7448,7 +7447,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, phyctl = frametype(rspec[0], wlc->mimoft); if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) || (preamble_type[0] == BRCMS_GF_PREAMBLE)) { - if (RSPEC2RATE(rspec[0]) != BRCM_RATE_1M) + if (rspec2rate(rspec[0]) != BRCM_RATE_1M) phyctl |= PHY_TXC_SHORT_HDR; } @@ -7477,14 +7476,14 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, * is going to be set, fill in non-zero MModeLen and/or * MModeFbrLen it will be unnecessary if they are separated */ - if (IS_MCS(rspec[0]) && + if (is_mcs_rate(rspec[0]) && (preamble_type[0] == BRCMS_MM_PREAMBLE)) { u16 mmodelen = brcms_c_calc_lsig_len(wlc, rspec[0], phylen); txh->MModeLen = cpu_to_le16(mmodelen); } - if (IS_MCS(rspec[1]) && + if (is_mcs_rate(rspec[1]) && (preamble_type[1] == BRCMS_MM_PREAMBLE)) { u16 mmodefbrlen = brcms_c_calc_lsig_len(wlc, rspec[1], phylen); @@ -7570,7 +7569,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, wiphy_err(wlc->wiphy, "wl%d: %s txop invalid " "for rate %d\n", wlc->pub->unit, fifo_names[queue], - RSPEC2RATE(rspec[0])); + rspec2rate(rspec[0])); } if (dur > wlc->edcf_txop[ac]) @@ -7772,10 +7771,10 @@ static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) { u8 mcs = (u8) (rspec & RSPEC_RATE_MASK); plcp[0] = mcs; - if (RSPEC_IS40MHZ(rspec) || (mcs == 32)) + if (rspec_is40mhz(rspec) || (mcs == 32)) plcp[0] |= MIMO_PLCP_40MHZ; BRCMS_SET_MIMO_PLCP_LEN(plcp, length); - plcp[3] = RSPEC_MIMOPLCP3(rspec); /* rspec already holds this byte */ + plcp[3] = rspec_mimoplcp3(rspec); /* rspec already holds this byte */ plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ plcp[5] = 0; @@ -7787,7 +7786,7 @@ brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) { u8 rate_signal; u32 tmp = 0; - int rate = RSPEC2RATE(rspec); + int rate = rspec2rate(rspec); /* * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb @@ -7809,7 +7808,7 @@ brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, uint length, u8 *plcp) { - int rate = RSPEC2RATE(rspec); + int rate = rspec2rate(rspec); brcms_c_cck_plcp_set(wlc, rate, length, plcp); } @@ -7818,9 +7817,9 @@ void brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, uint length, u8 *plcp) { - if (IS_MCS(rspec)) + if (is_mcs_rate(rspec)) brcms_c_compute_mimo_plcp(rspec, length, plcp); - else if (IS_OFDM(rspec)) + else if (is_ofdm_rate(rspec)) brcms_c_compute_ofdm_plcp(rspec, length, plcp); else brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); @@ -7881,7 +7880,7 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) if (BRCMS_ISLCNPHY(wlc->band)) { bw = PHY_TXC1_BW_20MHZ; } else { - bw = RSPEC_GET_BW(rspec); + bw = rspec_get_bw(rspec); /* 10Mhz is not supported yet */ if (bw < PHY_TXC1_BW_20MHZ) { wiphy_err(wlc->wiphy, "phytxctl1_calc: bw %d is " @@ -7890,14 +7889,14 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) } } - if (IS_MCS(rspec)) { + if (is_mcs_rate(rspec)) { uint mcs = rspec & RSPEC_RATE_MASK; - /* bw, stf, coding-type is part of RSPEC_PHYTXBYTE2 returns */ - phyctl1 = RSPEC_PHYTXBYTE2(rspec); + /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ + phyctl1 = rspec_phytxbyte2(rspec); /* set the upper byte of phyctl1 */ phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 << 8); - } else if (IS_CCK(rspec) && !BRCMS_ISLCNPHY(wlc->band) + } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) && !BRCMS_ISSSLPNPHY(wlc->band)) { /* * In CCK mode LPPHY overloads OFDM Modulation bits with CCK @@ -7905,11 +7904,11 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) * this format */ /* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ - phyctl1 = (bw | (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); + phyctl1 = (bw | (rspec_stf(rspec) << PHY_TXC1_MODE_SHIFT)); } else { /* legacy OFDM/CCK */ s16 phycfg; /* get the phyctl byte from rate phycfg table */ - phycfg = brcms_c_rate_legacy_phyctl(RSPEC2RATE(rspec)); + phycfg = brcms_c_rate_legacy_phyctl(rspec2rate(rspec)); if (phycfg == -1) { wiphy_err(wlc->wiphy, "phytxctl1_calc: wrong " "legacy OFDM/CCK rate\n"); @@ -7918,7 +7917,7 @@ u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) /* set the upper byte of phyctl1 */ phyctl1 = (bw | (phycfg << 8) | - (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT)); + (rspec_stf(rspec) << PHY_TXC1_MODE_SHIFT)); } return phyctl1; } @@ -7932,7 +7931,7 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, if (use_rspec) /* use frame rate as rts rate */ rts_rspec = rspec; - else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) + else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) /* Use 11Mbps as the g protection RTS target rate and fallback. * Use the brcms_basic_rate() lookup to find the best basic rate * under the target in case 11 Mbps is not Basic. @@ -7956,13 +7955,13 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, * if rspec/rspec_fallback is 40MHz, then send RTS on both * 20MHz channel (DUP), otherwise send RTS on control channel */ - if (RSPEC_IS40MHZ(rspec) && !IS_CCK(rts_rspec)) + if (rspec_is40mhz(rspec) && !is_cck_rate(rts_rspec)) rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT); else rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT); /* pick siso/cdd as default for ofdm */ - if (IS_OFDM(rts_rspec)) { + if (is_ofdm_rate(rts_rspec)) { rts_rspec &= ~RSPEC_STF_MASK; rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); } @@ -8269,13 +8268,13 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, plcp = p->data; rspec = brcms_c_compute_rspec(rxh, plcp); - if (IS_MCS(rspec)) { + if (is_mcs_rate(rspec)) { rx_status->rate_idx = rspec & RSPEC_RATE_MASK; rx_status->flag |= RX_FLAG_HT; - if (RSPEC_IS40MHZ(rspec)) + if (rspec_is40mhz(rspec)) rx_status->flag |= RX_FLAG_40MHZ; } else { - switch (RSPEC2RATE(rspec)) { + switch (rspec2rate(rspec)) { case BRCM_RATE_1M: rx_status->rate_idx = 0; break; @@ -8326,10 +8325,10 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, /* Determine short preamble and rate_idx */ preamble = 0; - if (IS_CCK(rspec)) { + if (is_cck_rate(rspec)) { if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) rx_status->flag |= RX_FLAG_SHORTPRE; - } else if (IS_OFDM(rspec)) { + } else if (is_ofdm_rate(rspec)) { rx_status->flag |= RX_FLAG_SHORTPRE; } else { wiphy_err(wlc->wiphy, "%s: Unknown modulation\n", @@ -8337,7 +8336,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, } } - if (PLCP3_ISSGI(plcp[3])) + if (plcp3_issgi(plcp[3])) rx_status->flag |= RX_FLAG_SHORT_GI; if (rxh->RxStatus1 & RXS_DECERR) { @@ -8479,23 +8478,22 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint nsyms, len = 0, kNdps; BCMMSG(wlc->wiphy, "wl%d: rate %d, len%d\n", - wlc->pub->unit, RSPEC2RATE(ratespec), mac_len); + wlc->pub->unit, rspec2rate(ratespec), mac_len); - if (IS_MCS(ratespec)) { + if (is_mcs_rate(ratespec)) { uint mcs = ratespec & RSPEC_RATE_MASK; - /* MCS_TXS(mcs) returns num tx streams - 1 */ - int tot_streams = (MCS_TXS(mcs) + 1) + RSPEC_STC(ratespec); + int tot_streams = (mcs_2_txstreams(mcs) + 1) + + rspec_stc(ratespec); /* * the payload duration calculation matches that * of regular ofdm */ /* 1000Ndbps = kbps * 4 */ - kNdps = - MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), - RSPEC_ISSGI(ratespec)) * 4; + kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), + rspec_issgi(ratespec)) * 4; - if (RSPEC_STC(ratespec) == 0) + if (rspec_stc(ratespec) == 0) nsyms = CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS) * 1000, kNdps); @@ -8527,7 +8525,7 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, u8 preamble_type, uint mac_len) { uint nsyms, dur = 0, Ndps, kNdps; - uint rate = RSPEC2RATE(ratespec); + uint rate = rspec2rate(ratespec); if (rate == 0) { wiphy_err(wlc->wiphy, "wl%d: WAR: using rate of 1 mbps\n", @@ -8538,19 +8536,18 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, len%d\n", wlc->pub->unit, ratespec, preamble_type, mac_len); - if (IS_MCS(ratespec)) { + if (is_mcs_rate(ratespec)) { uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec); + int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); dur = PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); if (preamble_type == BRCMS_MM_PREAMBLE) dur += PREN_MM_EXT; /* 1000Ndbps = kbps * 4 */ - kNdps = - MCS_RATE(mcs, RSPEC_IS40MHZ(ratespec), - RSPEC_ISSGI(ratespec)) * 4; + kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), + rspec_issgi(ratespec)) * 4; - if (RSPEC_STC(ratespec) == 0) + if (rspec_stc(ratespec) == 0) nsyms = CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS) * 1000, kNdps); @@ -8564,7 +8561,7 @@ brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, dur += APHY_SYMBOL_TIME * nsyms; if (wlc->band->bandtype == BRCM_BAND_2G) dur += DOT11_OFDM_SIGNAL_EXTENSION; - } else if (IS_OFDM(rate)) { + } else if (is_ofdm_rate(rate)) { dur = APHY_PREAMBLE_TIME; dur += APHY_SIGNAL_TIME; /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ @@ -8649,7 +8646,7 @@ void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, * Keep track of the best basic rate so far by * modulation type. */ - if (IS_OFDM(rate)) + if (is_ofdm_rate(rate)) ofdm_basic = rate; else cck_basic = rate; @@ -8662,12 +8659,12 @@ void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, * the hole in the table */ - br[rate] = IS_OFDM(rate) ? ofdm_basic : cck_basic; + br[rate] = is_ofdm_rate(rate) ? ofdm_basic : cck_basic; if (br[rate] != 0) continue; - if (IS_OFDM(rate)) { + if (is_ofdm_rate(rate)) { /* * In 11g and 11a, the OFDM mandatory rates * are 6, 12, and 24 Mbps @@ -8696,10 +8693,10 @@ static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, u16 basic_ptr; /* Shared memory address for the table we are reading */ - dir_table = IS_OFDM(basic_rate) ? M_RT_DIRMAP_A : M_RT_DIRMAP_B; + dir_table = is_ofdm_rate(basic_rate) ? M_RT_DIRMAP_A : M_RT_DIRMAP_B; /* Shared memory address for the table we are writing */ - basic_table = IS_OFDM(rate) ? M_RT_BBRSMAP_A : M_RT_BBRSMAP_B; + basic_table = is_ofdm_rate(rate) ? M_RT_BBRSMAP_A : M_RT_BBRSMAP_B; /* * for a given rate, the LS-nibble of the PLCP SIGNAL field is @@ -8788,15 +8785,15 @@ bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, return false; /* check if this is a mimo rate */ - if (IS_MCS(rspec)) { - if (!VALID_MCS((rspec & RSPEC_RATE_MASK))) + if (is_mcs_rate(rspec)) { + if ((rspec & RSPEC_RATE_MASK) >= MCS_TABLE_SIZE) goto error; return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); } for (i = 0; i < hw_rateset->count; i++) - if (hw_rateset->rates[i] == RSPEC2RATE(rspec)) + if (hw_rateset->rates[i] == rspec2rate(rspec)) return true; error: if (verbose) diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c index 1241dc9e1ae..0a0c0ad4f96 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ b/drivers/staging/brcm80211/brcmsmac/rate.c @@ -353,12 +353,12 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) { case PRXS0_CCK: rspec = - CCK_PHY2MAC_RATE( + cck_phy2mac_rate( ((struct cck_phy_hdr *) plcp)->signal); break; case PRXS0_OFDM: rspec = - OFDM_PHY2MAC_RATE( + ofdm_phy2mac_rate( ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); break; case PRXS0_PREN: @@ -375,14 +375,14 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) /* not supported, error condition */ break; } - if (PLCP3_ISSGI(plcp[3])) + if (plcp3_issgi(plcp[3])) rspec |= RSPEC_SHORT_GI; } else if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM)) - rspec = OFDM_PHY2MAC_RATE( + rspec = ofdm_phy2mac_rate( ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); else - rspec = CCK_PHY2MAC_RATE( + rspec = cck_phy2mac_rate( ((struct cck_phy_hdr *) plcp)->signal); return rspec; @@ -417,9 +417,11 @@ brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, r = src->rates[i]; if (basic_only && !(r & BRCMS_RATE_FLAG)) continue; - if (rates == BRCMS_RATES_CCK && IS_OFDM((r & BRCMS_RATE_MASK))) + if (rates == BRCMS_RATES_CCK && + is_ofdm_rate((r & BRCMS_RATE_MASK))) continue; - if (rates == BRCMS_RATES_OFDM && IS_CCK((r & BRCMS_RATE_MASK))) + if (rates == BRCMS_RATES_OFDM && + is_cck_rate((r & BRCMS_RATE_MASK))) continue; dst->rates[count++] = r & xmask; } diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index ae5479b4609..2cc66e04c0d 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -18,6 +18,7 @@ #define _BRCM_RATE_H_ #include "types.h" +#include "d11.h" extern const u8 rate_info[]; extern const struct brcms_c_rateset cck_ofdm_mimo_rates; @@ -48,33 +49,31 @@ struct brcms_mcs_info { #define MCS_TABLE_SIZE 33 /* Number of mcs entries in the table */ extern const struct brcms_mcs_info mcs_table[]; -#define MCS_INVALID 0xFF -#define MCS_CR_MASK 0x07 /* Code Rate bit mask */ -#define MCS_MOD_MASK 0x38 /* Modulation bit shift */ -#define MCS_MOD_SHIFT 3 /* MOdulation bit shift */ #define MCS_TXS_MASK 0xc0 /* num tx streams - 1 bit mask */ #define MCS_TXS_SHIFT 6 /* num tx streams - 1 bit shift */ -#define MCS_CR(_mcs) (mcs_table[_mcs].tx_phy_ctl3 & MCS_CR_MASK) -#define MCS_MOD(_mcs) \ - ((mcs_table[_mcs].tx_phy_ctl3 & MCS_MOD_MASK) >> MCS_MOD_SHIFT) +/* returns num tx streams - 1 */ +static inline u8 mcs_2_txstreams(u8 mcs) +{ + return (mcs_table[mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT; +} -#define MCS_TXS(_mcs) \ - ((mcs_table[_mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT) +static inline uint mcs_2_rate(u8 mcs, bool is40, bool sgi) +{ + if (sgi) { + if (is40) + return mcs_table[mcs].phy_rate_40_sgi; + return mcs_table[mcs].phy_rate_20_sgi; + } + if (is40) + return mcs_table[mcs].phy_rate_40; -#define MCS_RATE(_mcs, _is40, _sgi) (_sgi ? \ - (_is40 ? mcs_table[_mcs].phy_rate_40_sgi : \ - mcs_table[_mcs].phy_rate_20_sgi) : \ - (_is40 ? mcs_table[_mcs].phy_rate_40 : mcs_table[_mcs].phy_rate_20)) - -#define VALID_MCS(_mcs) ((_mcs < MCS_TABLE_SIZE)) + return mcs_table[mcs].phy_rate_20; +} /* Macro to use the rate_info table */ #define BRCMS_RATE_MASK_FULL 0xff /* Rate value mask with basic rate flag */ -/* convert 500kbps to bps */ -#define BRCMS_RATE_500K_TO_BPS(rate) ((rate) * 500000) - /* * rate spec : holds rate and mode specific information required to generate a * tx frame. Legacy CCK and OFDM information is held in the same manner as was @@ -113,65 +112,104 @@ extern const struct brcms_mcs_info mcs_table[]; /* bit indicates override rate only */ #define RSPEC_OVERRIDE_MCS_ONLY 0x40000000 -#define BRCMS_HTPHY 127 /* HT PHY Membership */ +static inline bool rspec_active(u32 rspec) +{ + return rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE); +} -#define RSPEC_ACTIVE(rspec) (rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE)) +static inline u8 rspec_phytxbyte2(u32 rspec) +{ + return (rspec & 0xff00) >> 8; +} -#define RSPEC2RATE(rspec) \ - ((rspec & RSPEC_MIMORATE) ? \ - MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), \ - RSPEC_ISSGI(rspec)) : \ - (rspec & RSPEC_RATE_MASK)) +static inline u32 rspec_get_bw(u32 rspec) +{ + return (rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT; +} -#define RSPEC_PHYTXBYTE2(rspec) ((rspec & 0xff00) >> 8) +static inline bool rspec_issgi(u32 rspec) +{ + return (rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI; +} -#define RSPEC_GET_BW(rspec) ((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) +static inline bool rspec_is40mhz(u32 rspec) +{ + u32 bw = rspec_get_bw(rspec); -#define RSPEC_IS40MHZ(rspec) \ - ((((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ) || \ - (((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ_DUP)) + return bw == PHY_TXC1_BW_40MHZ || bw == PHY_TXC1_BW_40MHZ_DUP; +} -#define RSPEC_ISSGI(rspec) ((rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI) -#define RSPEC_MIMOPLCP3(rspec) ((rspec & 0xf00000) >> 16) -#define PLCP3_ISSGI(plcp) (plcp & (RSPEC_SHORT_GI >> 16)) -#define RSPEC_STC(rspec) ((rspec & RSPEC_STC_MASK) >> RSPEC_STC_SHIFT) -#define RSPEC_STF(rspec) ((rspec & RSPEC_STF_MASK) >> RSPEC_STF_SHIFT) -#define PLCP3_ISSTBC(plcp) ((plcp & (RSPEC_STC_MASK) >> 16) == 0x10) -#define PLCP3_STC_MASK 0x30 -#define PLCP3_STC_SHIFT 4 +static inline uint rspec2rate(u32 rspec) +{ + if (rspec & RSPEC_MIMORATE) + return mcs_2_rate(rspec & RSPEC_RATE_MASK, rspec_is40mhz(rspec), + rspec_issgi(rspec)); + return rspec & RSPEC_RATE_MASK; +} -/* Rate info table; takes a legacy rate or u32 */ -#define IS_MCS(r) (r & RSPEC_MIMORATE) +static inline u8 rspec_mimoplcp3(u32 rspec) +{ + return (rspec & 0xf00000) >> 16; +} -#define IS_OFDM(r) (!IS_MCS(r) && (rate_info[(r) & RSPEC_RATE_MASK] & \ - BRCMS_RATE_FLAG)) +static inline bool plcp3_issgi(u8 plcp) +{ + return (plcp & (RSPEC_SHORT_GI >> 16)) != 0; +} -#define IS_CCK(r) (!IS_MCS(r) && ( \ - ((r) & BRCMS_RATE_MASK) == BRCM_RATE_1M || \ - ((r) & BRCMS_RATE_MASK) == BRCM_RATE_2M || \ - ((r) & BRCMS_RATE_MASK) == BRCM_RATE_5M5 || \ - ((r) & BRCMS_RATE_MASK) == BRCM_RATE_11M)) +static inline uint rspec_stc(u32 rspec) +{ + return (rspec & RSPEC_STC_MASK) >> RSPEC_STC_SHIFT; +} -#define IS_SINGLE_STREAM(mcs) \ - (((mcs) <= HIGHEST_SINGLE_STREAM_MCS) || ((mcs) == 32)) +static inline uint rspec_stf(u32 rspec) +{ + return (rspec & RSPEC_STF_MASK) >> RSPEC_STF_SHIFT; +} -#define CCK_RSPEC(cck) ((cck) & RSPEC_RATE_MASK) +static inline bool is_mcs_rate(u32 ratespec) +{ + return (ratespec & RSPEC_MIMORATE) != 0; +} -#define OFDM_RSPEC(ofdm) (((ofdm) & RSPEC_RATE_MASK) |\ - (PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT)) +static inline bool is_ofdm_rate(u32 ratespec) +{ + return !is_mcs_rate(ratespec) && + (rate_info[ratespec & RSPEC_RATE_MASK] & BRCMS_RATE_FLAG); +} -#define LEGACY_RSPEC(rate) \ - (IS_CCK(rate) ? CCK_RSPEC(rate) : OFDM_RSPEC(rate)) +static inline bool is_cck_rate(u32 ratespec) +{ + u32 rate = (ratespec & BRCMS_RATE_MASK); -#define MCS_RSPEC(mcs) (((mcs) & RSPEC_RATE_MASK) | RSPEC_MIMORATE | \ - (IS_SINGLE_STREAM(mcs) ? (PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT) : \ - (PHY_TXC1_MODE_SDM << RSPEC_STF_SHIFT))) + return !is_mcs_rate(ratespec) && ( + rate == BRCM_RATE_1M || rate == BRCM_RATE_2M || + rate == BRCM_RATE_5M5 || rate == BRCM_RATE_11M); +} + +static inline bool is_single_stream(u8 mcs) +{ + return mcs <= HIGHEST_SINGLE_STREAM_MCS || mcs == 32; +} + +static inline u8 cck_rspec(u8 cck) +{ + return cck & RSPEC_RATE_MASK; +} /* Convert encoded rate value in plcp header to numerical rates in 500 KHz * increments */ extern const u8 ofdm_rate_lookup[]; -#define OFDM_PHY2MAC_RATE(rlpt) (ofdm_rate_lookup[rlpt & 0x7]) -#define CCK_PHY2MAC_RATE(signal) (signal/5) + +static inline u8 ofdm_phy2mac_rate(u8 rlpt) +{ + return ofdm_rate_lookup[rlpt & 0x7]; +} + +static inline u8 cck_phy2mac_rate(u8 signal) +{ + return signal/5; +} /* Rates specified in brcms_c_rateset_filter() */ #define BRCMS_RATES_CCK_OFDM 0 diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 82805e0a826..91b53a5a261 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -421,7 +421,7 @@ static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, { u16 phytxant = wlc->stf->phytxant; - if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) + if (rspec_stf(rspec) != PHY_TXC1_MODE_SISO) phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; else if (wlc->stf->txant == ANT_TX_DEF) phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; From 9dd8eff3da331b795ab6879a6b3a8b88d5adf658 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:53 +0200 Subject: [PATCH 1046/1519] staging: brcm80211: separated public from private ioctl functions net_device ioctl handler was called both by the OS as by the driver itself. Split the ioctl handler into two functions to make code paths more clear. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 2 ++ .../staging/brcm80211/brcmfmac/dhd_linux.c | 24 ++++++++++++------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 9f84837cb54..93a1bfc85c3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -715,6 +715,8 @@ extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *dev); +extern int brcmf_netdev_ioctl_priv(struct net_device *net, struct ifreq *ifr); + /* Indication from bus module regarding removal/absence of dongle */ extern void brcmf_detach(struct brcmf_pub *drvr); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index cfdd64590d9..4bc231e5e5d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -950,13 +950,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd) { struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); - struct brcmf_c_ioctl ioc; - int bcmerror = 0; - int buflen = 0; - void *buf = NULL; - uint driver = 0; int ifidx; - bool is_set_key_cmd; ifidx = brcmf_net2idx(drvr_priv, net); brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); @@ -967,8 +961,22 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, if (cmd == SIOCETHTOOL) return brcmf_ethtool(drvr_priv, ifr->ifr_data); - if (cmd != SIOCDEVPRIVATE) - return -EOPNOTSUPP; + return -EOPNOTSUPP; +} + +/* called only from within this driver, handles cmd == SIOCDEVPRIVATE */ +int brcmf_netdev_ioctl_priv(struct net_device *net, struct ifreq *ifr) +{ + struct brcmf_c_ioctl ioc; + int bcmerror = 0; + int buflen = 0; + void *buf = NULL; + uint driver = 0; + bool is_set_key_cmd; + struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + int ifidx; + + ifidx = brcmf_net2idx(drvr_priv, net); memset(&ioc, 0, sizeof(ioc)); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 198f0cc1ebe..3fa0c1b8990 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -286,7 +286,7 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) fs = get_fs(); set_fs(get_ds()); - err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE); + err = brcmf_netdev_ioctl_priv(dev, &ifr); set_fs(fs); return err; From 9af07ef1febb8538d35d7613ae621e4ea5fa9631 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 15 Sep 2011 10:06:34 +0200 Subject: [PATCH 1047/1519] staging: brcm80211: simplification of brcmf_netdev_ioctl_priv() This function is only called from within the driver. Because of that certain simplifications (not required to lock down user mem pages, not required to check user permissions) could be performed. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 14 +--- .../staging/brcm80211/brcmfmac/dhd_linux.c | 69 +++---------------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 5 +- 3 files changed, 13 insertions(+), 75 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 93a1bfc85c3..a92a28e7af8 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -715,7 +715,8 @@ extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *dev); -extern int brcmf_netdev_ioctl_priv(struct net_device *net, struct ifreq *ifr); +extern int brcmf_netdev_ioctl_priv(struct net_device *net, + struct brcmf_ioctl *ioc); /* Indication from bus module regarding removal/absence of dongle */ extern void brcmf_detach(struct brcmf_pub *drvr); @@ -771,17 +772,6 @@ extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg); extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, int master_mode); -/* Linux network driver ioctl encoding */ -struct brcmf_c_ioctl { - uint cmd; /* common ioctl definition */ - void __user *buf; /* pointer to user buffer */ - uint len; /* length of user buffer */ - bool set; /* get or set request (optional) */ - uint used; /* bytes read or written (optional) */ - uint needed; /* bytes needed (optional) */ - uint driver; /* to identify target driver */ -}; - /* per-driver magic numbers */ #define BRCMF_IOCTL_MAGIC 0x00444944 diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 4bc231e5e5d..26a39ee894f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -964,61 +964,19 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, return -EOPNOTSUPP; } -/* called only from within this driver, handles cmd == SIOCDEVPRIVATE */ -int brcmf_netdev_ioctl_priv(struct net_device *net, struct ifreq *ifr) +/* called only from within this driver */ +int brcmf_netdev_ioctl_priv(struct net_device *net, struct brcmf_ioctl *ioc) { - struct brcmf_c_ioctl ioc; int bcmerror = 0; int buflen = 0; - void *buf = NULL; - uint driver = 0; bool is_set_key_cmd; struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); int ifidx; ifidx = brcmf_net2idx(drvr_priv, net); - memset(&ioc, 0, sizeof(ioc)); - - /* Copy the ioc control structure part of ioctl request */ - if (copy_from_user(&ioc, ifr->ifr_data, sizeof(struct brcmf_ioctl))) { - bcmerror = -EINVAL; - goto done; - } - - /* Copy out any buffer passed */ - if (ioc.buf) { - buflen = min_t(int, ioc.len, BRCMF_IOCTL_MAXLEN); - /* optimization for direct ioctl calls from kernel */ - /* - if (segment_eq(get_fs(), KERNEL_DS)) { - buf = ioc.buf; - } else { - */ - { - buf = kmalloc(buflen, GFP_ATOMIC); - if (!buf) { - bcmerror = -ENOMEM; - goto done; - } - if (copy_from_user(buf, ioc.buf, buflen)) { - bcmerror = -EINVAL; - goto done; - } - } - } - - /* To differentiate read 4 more byes */ - if ((copy_from_user(&driver, (char __user *)ifr->ifr_data + - sizeof(struct brcmf_ioctl), sizeof(uint)) != 0)) { - bcmerror = -EINVAL; - goto done; - } - - if (!capable(CAP_NET_ADMIN)) { - bcmerror = -EPERM; - goto done; - } + if (ioc->buf != NULL) + buflen = min_t(uint, ioc->len, BRCMF_IOCTL_MAXLEN); /* send to dongle (must be up, and wl) */ if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { @@ -1036,25 +994,18 @@ int brcmf_netdev_ioctl_priv(struct net_device *net, struct ifreq *ifr) * Intercept BRCMF_C_SET_KEY IOCTL - serialize M4 send and * set key IOCTL to prevent M4 encryption. */ - is_set_key_cmd = ((ioc.cmd == BRCMF_C_SET_KEY) || - ((ioc.cmd == BRCMF_C_SET_VAR) && - !(strncmp("wsec_key", ioc.buf, 9))) || - ((ioc.cmd == BRCMF_C_SET_VAR) && - !(strncmp("bsscfg:wsec_key", ioc.buf, 15)))); + is_set_key_cmd = ((ioc->cmd == BRCMF_C_SET_KEY) || + ((ioc->cmd == BRCMF_C_SET_VAR) && + !(strncmp("wsec_key", ioc->buf, 9))) || + ((ioc->cmd == BRCMF_C_SET_VAR) && + !(strncmp("bsscfg:wsec_key", ioc->buf, 15)))); if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(net); bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, - (struct brcmf_ioctl *)&ioc, buf, buflen); + ioc, ioc->buf, buflen); done: - if (!bcmerror && buf && ioc.buf) { - if (copy_to_user(ioc.buf, buf, buflen)) - bcmerror = -EFAULT; - } - - kfree(buf); - if (bcmerror > 0) bcmerror = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 3fa0c1b8990..b001e405c94 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -272,7 +272,6 @@ static void convert_key_to_CPU(struct brcmf_wsec_key *key) static s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) { - struct ifreq ifr; struct brcmf_ioctl ioc; mm_segment_t fs; s32 err = 0; @@ -281,12 +280,10 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) ioc.cmd = cmd; ioc.buf = arg; ioc.len = len; - strcpy(ifr.ifr_name, dev->name); - ifr.ifr_data = (char __user *)&ioc; fs = get_fs(); set_fs(get_ds()); - err = brcmf_netdev_ioctl_priv(dev, &ifr); + err = brcmf_netdev_ioctl_priv(dev, &ioc); set_fs(fs); return err; From a8a4d920c31c296d15a9189d32b6c84578788fbe Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:55 +0200 Subject: [PATCH 1048/1519] staging: brcm80211: cleaned up function brcmf_cfg80211_get_key() Unnecessary endianess conversion and struct member setting was deleted. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index b001e405c94..926b0192d4c 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -258,17 +258,6 @@ static void convert_key_from_CPU(struct brcmf_wsec_key *key) key->iv_initialized = cpu_to_le32(key->iv_initialized); } -static void convert_key_to_CPU(struct brcmf_wsec_key *key) -{ - key->index = le32_to_cpu(key->index); - key->len = le32_to_cpu(key->len); - key->algo = le32_to_cpu(key->algo); - key->flags = le32_to_cpu(key->flags); - key->rxiv.hi = le32_to_cpu(key->rxiv.hi); - key->rxiv.lo = le16_to_cpu(key->rxiv.lo); - key->iv_initialized = le32_to_cpu(key->iv_initialized); -} - static s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) { @@ -1722,7 +1711,6 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, void (*callback) (void *cookie, struct key_params * params)) { struct key_params params; - struct brcmf_wsec_key key; struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); struct brcmf_cfg80211_security *sec; s32 wsec; @@ -1733,12 +1721,7 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, if (!check_sys_up(wiphy)) return -EIO; - memset(&key, 0, sizeof(key)); - key.index = key_idx; - convert_key_to_CPU(&key); memset(¶ms, 0, sizeof(params)); - params.key_len = (u8) min_t(u8, WLAN_MAX_KEY_LEN, key.len); - memcpy(params.key, key.data, params.key_len); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_WSEC, &wsec, sizeof(wsec)); if (unlikely(err)) { From 4b8b9c8ff6d5081f871cbd4c06e5d63260f90676 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:56 +0200 Subject: [PATCH 1049/1519] staging: brcm80211: fullmac sparse endianness encryption keys check Added support by making a distinction between a struct and its little endian relative. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 36 +++++++-- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 78 ++++++++++--------- 2 files changed, 73 insertions(+), 41 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index a92a28e7af8..88983705444 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -405,6 +405,11 @@ struct brcmf_ssid { unsigned char SSID[32]; }; +struct brcmf_ssid_le { + __le32 SSID_len; + unsigned char SSID[32]; +}; + struct brcmf_scan_params { struct brcmf_ssid ssid; /* default: {0, ""} */ u8 bssid[ETH_ALEN]; /* default: bcast */ @@ -500,16 +505,37 @@ struct brcmf_wsec_key { u32 pad_1[18]; u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ u32 flags; /* misc flags */ - u32 pad_2[2]; - int pad_3; - int iv_initialized; /* has IV been initialized already? */ - int pad_4; + u32 pad_2[3]; + u32 iv_initialized; /* has IV been initialized already? */ + u32 pad_3; /* Rx IV */ struct { u32 hi; /* upper 32 bits of IV */ u16 lo; /* lower 16 bits of IV */ } rxiv; - u32 pad_5[2]; + u32 pad_4[2]; + u8 ea[ETH_ALEN]; /* per station */ +}; + +/* + * dongle requires same struct as above but with fields in little endian order + */ +struct brcmf_wsec_key_le { + __le32 index; /* key index */ + __le32 len; /* key length */ + u8 data[WLAN_MAX_KEY_LEN]; /* key data */ + __le32 pad_1[18]; + __le32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ + __le32 flags; /* misc flags */ + __le32 pad_2[3]; + __le32 iv_initialized; /* has IV been initialized already? */ + __le32 pad_3; + /* Rx IV */ + struct { + __le32 hi; /* upper 32 bits of IV */ + __le16 lo; /* lower 16 bits of IV */ + } rxiv; + __le32 pad_4[2]; u8 ea[ETH_ALEN]; /* per station */ }; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 926b0192d4c..ce393ac4d62 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -247,17 +247,6 @@ static const u32 __wl_cipher_suites[] = { WLAN_CIPHER_SUITE_AES_CMAC, }; -static void convert_key_from_CPU(struct brcmf_wsec_key *key) -{ - key->index = cpu_to_le32(key->index); - key->len = cpu_to_le32(key->len); - key->algo = cpu_to_le32(key->algo); - key->flags = cpu_to_le32(key->flags); - key->rxiv.hi = cpu_to_le32(key->rxiv.hi); - key->rxiv.lo = cpu_to_le16(key->rxiv.lo); - key->iv_initialized = cpu_to_le32(key->iv_initialized); -} - static s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) { @@ -278,6 +267,33 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) return err; } +static void convert_key_from_CPU(struct brcmf_wsec_key *key, + struct brcmf_wsec_key_le *key_le) +{ + key_le->index = cpu_to_le32(key->index); + key_le->len = cpu_to_le32(key->len); + key_le->algo = cpu_to_le32(key->algo); + key_le->flags = cpu_to_le32(key->flags); + key_le->rxiv.hi = cpu_to_le32(key->rxiv.hi); + key_le->rxiv.lo = cpu_to_le16(key->rxiv.lo); + key_le->iv_initialized = cpu_to_le32(key->iv_initialized); + memcpy(key_le->data, key->data, sizeof(key->data)); + memcpy(key_le->ea, key->ea, sizeof(key->ea)); +} + +static int send_key_to_dongle(struct net_device *dev, + struct brcmf_wsec_key *key) +{ + int err; + struct brcmf_wsec_key_le key_le; + + convert_key_from_CPU(key, &key_le); + err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); + if (err) + WL_ERR("WLC_SET_KEY error (%d)\n", err); + return err; +} + static s32 brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, enum nl80211_iftype type, u32 *flags, @@ -1200,13 +1216,10 @@ brcmf_set_set_sharedkey(struct net_device *dev, WL_CONN("key length (%d) key index (%d) algo (%d)\n", key.len, key.index, key.algo); WL_CONN("key \"%s\"\n", key.data); - convert_key_from_CPU(&key); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, - sizeof(key)); - if (unlikely(err)) { - WL_ERR("WLC_SET_KEY error (%d)\n", err); + err = send_key_to_dongle(dev, &key); + if (err) return err; - } + if (sec->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) { WL_CONN("set auth_type to shared key\n"); val = 1; /* shared key */ @@ -1461,6 +1474,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, u8 key_idx, const u8 *mac_addr, struct key_params *params) { struct brcmf_wsec_key key; + struct brcmf_wsec_key_le key_le; s32 err = 0; memset(&key, 0, sizeof(key)); @@ -1473,12 +1487,9 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, /* check for key index change */ if (key.len == 0) { /* key delete */ - convert_key_from_CPU(&key); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); - if (unlikely(err)) { - WL_ERR("key delete error (%d)\n", err); + err = send_key_to_dongle(dev, &key); + if (err) return err; - } } else { if (key.len > sizeof(key.data)) { WL_ERR("Invalid key length (%d)\n", key.len); @@ -1531,10 +1542,11 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, WL_ERR("Invalid cipher (0x%x)\n", params->cipher); return -EINVAL; } - convert_key_from_CPU(&key); + convert_key_from_CPU(&key, &key_le); brcmf_netdev_wait_pend8021x(dev); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); + err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key_le, + sizeof(key_le)); if (unlikely(err)) { WL_ERR("WLC_SET_KEY error (%d)\n", err); return err; @@ -1606,13 +1618,9 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, goto done; } - /* Set the new key/index */ - convert_key_from_CPU(&key); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); - if (unlikely(err)) { - WL_ERR("WLC_SET_KEY error (%d)\n", err); + err = send_key_to_dongle(dev, &key); /* Set the new key/index */ + if (err) goto done; - } val = WEP_ENABLED; err = brcmf_dev_intvar_get(dev, "wsec", &wsec); @@ -1658,17 +1666,15 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, key.algo = CRYPTO_ALGO_OFF; WL_CONN("key index (%d)\n", key_idx); + /* Set the new key/index */ - convert_key_from_CPU(&key); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key)); - if (unlikely(err)) { + err = send_key_to_dongle(dev, &key); + if (err) { if (err == -EINVAL) { if (key.index >= DOT11_MAX_DEFAULT_KEYS) /* we ignore this key index in this case */ WL_ERR("invalid key index (%d)\n", key_idx); - } else - WL_ERR("WLC_SET_KEY error (%d)\n", err); - + } /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; goto done; From 6562382a6d862090f3fb956ef05425ec2283dfbd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 13 Sep 2011 09:49:57 +0200 Subject: [PATCH 1050/1519] staging: brcm80211: introduced fullmac function get/set u32 to/from dongle Code cleanup. Avoids repetition of same code fragment. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Roland Vossen Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index ce393ac4d62..1f736ead1bd 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -267,6 +267,19 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) return err; } +/* function for reading/writing a single u32 from/to the dongle */ +static int +brcmf_dev_ioctl_u32(struct net_device *dev, u32 cmd, u32 *par) +{ + int err; + __le32 par_le = cpu_to_le32(*par); + + err = brcmf_dev_ioctl(dev, cmd, &par_le, sizeof(__le32)); + *par = le32_to_cpu(par_le); + + return err; +} + static void convert_key_from_CPU(struct brcmf_wsec_key *key, struct brcmf_wsec_key_le *key_le) { @@ -327,8 +340,7 @@ brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, goto done; } - infra = cpu_to_le32(infra); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_INFRA, &infra, sizeof(infra)); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); if (unlikely(err)) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); err = -EAGAIN; @@ -656,8 +668,7 @@ static s32 brcmf_set_retry(struct net_device *dev, u32 retry, bool l) s32 err = 0; u32 cmd = (l ? BRCM_SET_LRL : BRCM_SET_SRL); - retry = cpu_to_le32(retry); - err = brcmf_dev_ioctl(dev, cmd, &retry, sizeof(retry)); + err = brcmf_dev_ioctl_u32(dev, cmd, &retry); if (unlikely(err)) { WL_ERR("cmd (%d) , error (%d)\n", cmd, err); return err; @@ -941,9 +952,9 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, } /* set channel for starter */ - target_channel = cpu_to_le32(cfg_priv->channel); - err = brcmf_dev_ioctl(dev, BRCM_SET_CHANNEL, - &target_channel, sizeof(target_channel)); + target_channel = cfg_priv->channel; + err = brcmf_dev_ioctl_u32(dev, BRCM_SET_CHANNEL, + &target_channel); if (unlikely(err)) { WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err); goto done; @@ -1388,9 +1399,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, } /* Make sure radio is off or on as far as software is concerned */ disable = WL_RADIO_SW_DISABLE << 16; - disable = cpu_to_le32(disable); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_RADIO, &disable, - sizeof(disable)); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_RADIO, &disable); if (unlikely(err)) WL_ERR("WLC_SET_RADIO error (%d)\n", err); @@ -1440,7 +1449,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, u8 key_idx, bool unicast, bool multicast) { u32 index; - s32 wsec; + u32 wsec; s32 err = 0; WL_TRACE("Enter\n"); @@ -1448,19 +1457,16 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, if (!check_sys_up(wiphy)) return -EIO; - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_WSEC, &wsec, sizeof(wsec)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); if (unlikely(err)) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); goto done; } - wsec = le32_to_cpu(wsec); if (wsec & WEP_ENABLED) { /* Just select a new current key */ - index = (u32) key_idx; - index = cpu_to_le32(index); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY_PRIMARY, &index, - sizeof(index)); + index = key_idx; + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_KEY_PRIMARY, &index); if (unlikely(err)) WL_ERR("error (%d)\n", err); } @@ -1637,8 +1643,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, } val = 1; /* assume shared key. otherwise 0 */ - val = cpu_to_le32(val); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_AUTH, &val, sizeof(val)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); if (unlikely(err)) WL_ERR("WLC_SET_AUTH error (%d)\n", err); done: @@ -1699,8 +1704,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, } val = 0; /* assume open key. otherwise 1 */ - val = cpu_to_le32(val); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_AUTH, &val, sizeof(val)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); if (unlikely(err)) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1729,14 +1733,13 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, memset(¶ms, 0, sizeof(params)); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_WSEC, &wsec, sizeof(wsec)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); if (unlikely(err)) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; goto done; } - wsec = le32_to_cpu(wsec); switch (wsec) { case WEP_ENABLED: sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); @@ -1804,11 +1807,10 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, } /* Report the current tx rate */ - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_RATE, &rate, sizeof(rate)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_RATE, &rate); if (err) { WL_ERR("Could not get rate (%d)\n", err); } else { - rate = le32_to_cpu(rate); sinfo->filled |= STATION_INFO_TX_BITRATE; sinfo->txrate.legacy = rate * 5; WL_CONN("Rate %d Mbps\n", rate / 2); @@ -1858,10 +1860,9 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, } pm = enabled ? PM_FAST : PM_OFF; - pm = cpu_to_le32(pm); WL_INFO("power save %s\n", (pm ? "enabled" : "disabled")); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_PM, &pm, sizeof(pm)); + err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_PM, &pm); if (unlikely(err)) { if (err == -ENODEV) WL_ERR("net_device is not ready yet\n"); @@ -3491,8 +3492,7 @@ static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) WL_ERR("invalid type (%d)\n", iftype); return err; } - infra = cpu_to_le32(infra); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_INFRA, &infra, sizeof(infra)); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); if (unlikely(err)) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); return err; @@ -3703,9 +3703,7 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, goto default_conf_out; power_mode = cfg_priv->pwr_save ? PM_FAST : PM_OFF; - power_mode = cpu_to_le32(power_mode); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_PM, - &power_mode, sizeof(power_mode)); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_PM, &power_mode); if (err) goto default_conf_out; WL_INFO("power save set to %s\n", From 2748f26b6a948308278ea43d343a6ec12aa18195 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:34 +0800 Subject: [PATCH 1051/1519] Staging: cx25821: Fix labels' placement in cx25821-video.c Delete whitespace before labels. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 7a0304a8573..8bdd1e8584c 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -679,7 +679,7 @@ int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, return 0; - fail: +fail: cx25821_free_buffer(q, buf); return rc; } From c1e6e24175475a5a03176958623fb06d1644f38e Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:35 +0800 Subject: [PATCH 1052/1519] Staging: cx25821: Fix function signatures Fix long function signatures (over 80 characters) and indent them properly. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 49 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 8bdd1e8584c..4a365bb34c2 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -110,7 +110,8 @@ struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc) return NULL; } -void cx25821_dump_video_queue(struct cx25821_dev *dev, struct cx25821_dmaqueue *q) +void cx25821_dump_video_queue(struct cx25821_dev *dev, + struct cx25821_dmaqueue *q) { struct cx25821_buffer *buf; struct list_head *item; @@ -220,7 +221,8 @@ static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) */ /* resource management */ -int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bit) +int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, + unsigned int bit) { dprintk(1, "%s()\n", __func__); if (fh->resources & bit) @@ -252,7 +254,8 @@ int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit) return fh->dev->channels[fh->channel_id].resources & bit; } -void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bits) +void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, + unsigned int bits) { BUG_ON((fh->resources & bits) != bits); dprintk(1, "%s()\n", __func__); @@ -684,7 +687,8 @@ fail: return rc; } -void cx25821_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) +void cx25821_buffer_release(struct videobuf_queue *q, + struct videobuf_buffer *vb) { struct cx25821_buffer *buf = container_of(vb, struct cx25821_buffer, vb); @@ -992,7 +996,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) } static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct cx25821_fh *fh = priv; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; @@ -1101,8 +1105,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv, return cx25821_set_control(dev, ctl, fh->channel_id); } -/* VIDEO IOCTLS */ -int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) +/* VIDEO IOCTLS */ +int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) { struct cx25821_fh *fh = priv; @@ -1116,7 +1121,8 @@ int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_form return 0; } -int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) +int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) { struct cx25821_fmt *fmt; enum v4l2_field field; @@ -1162,7 +1168,8 @@ int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fo return 0; } -int cx25821_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) +int cx25821_vidioc_querycap(struct file *file, void *priv, + struct v4l2_capability *cap) { struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; @@ -1189,13 +1196,15 @@ int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, return 0; } -int cx25821_vidioc_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) +int cx25821_vidioc_reqbufs(struct file *file, void *priv, + struct v4l2_requestbuffers *p) { struct cx25821_fh *fh = priv; return videobuf_reqbufs(get_queue(fh), p); } -int cx25821_vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) +int cx25821_vidioc_querybuf(struct file *file, void *priv, + struct v4l2_buffer *p) { struct cx25821_fh *fh = priv; return videobuf_querybuf(get_queue(fh), p); @@ -1217,7 +1226,8 @@ int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p) return 0; } -int cx25821_vidioc_s_priority(struct file *file, void *f, enum v4l2_priority prio) +int cx25821_vidioc_s_priority(struct file *file, void *f, + enum v4l2_priority prio) { struct cx25821_fh *fh = f; struct cx25821_dev *dev = ((struct cx25821_fh *)f)->dev; @@ -1280,7 +1290,8 @@ int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i) return 0; } -int cx25821_vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i) +int cx25821_vidioc_enum_input(struct file *file, void *priv, + struct v4l2_input *i) { struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; dprintk(1, "%s()\n", __func__); @@ -1323,7 +1334,8 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i) } #ifdef TUNER_FLAG -int cx25821_vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) +int cx25821_vidioc_g_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) { struct cx25821_fh *fh = priv; struct cx25821_dev *dev = fh->dev; @@ -1350,7 +1362,8 @@ int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f) return 0; } -int cx25821_vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) +int cx25821_vidioc_s_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) { struct cx25821_fh *fh = priv; struct cx25821_dev *dev; @@ -1522,7 +1535,8 @@ static const struct v4l2_queryctrl *ctrl_by_id(unsigned int id) return NULL; } -int cx25821_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctl) +int cx25821_vidioc_g_ctrl(struct file *file, void *priv, + struct v4l2_control *ctl) { struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_fh *fh = priv; @@ -1612,7 +1626,8 @@ static void cx25821_init_controls(struct cx25821_dev *dev, int chan_num) } } -int cx25821_vidioc_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cropcap) +int cx25821_vidioc_cropcap(struct file *file, void *priv, + struct v4l2_cropcap *cropcap) { struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; From 692cfb9beca7bd8d7bf69727a25b162fd39f555e Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:36 +0800 Subject: [PATCH 1053/1519] Staging: cx25821: Fix obscure line endings Fix obscure line endings to less obscure ones. Rationale: readability. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 4a365bb34c2..1aebc99ae24 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -162,8 +162,7 @@ void cx25821_video_wakeup(struct cx25821_dev *dev, struct cx25821_dmaqueue *q, else mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); if (bc != 1) - pr_err("%s: %d buffers handled (should be 1)\n", - __func__, bc); + pr_err("%s: %d buffers handled (should be 1)\n", __func__, bc); } #ifdef TUNER_FLAG From c2c311fd3b95d47c2b69db259bfd6726c134318e Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:37 +0800 Subject: [PATCH 1054/1519] Staging: cx25821: Fix indent in comment Change indent in comment to use tabs instead of spaces. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 1aebc99ae24..116727a84bc 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -203,19 +203,19 @@ struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, /* static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) { - int i; + int i; - if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1) - return -EINVAL; - for (i = 0; i < CX25821_CTLS; i++) - if (cx25821_ctls[i].v.id == qctrl->id) - break; - if (i == CX25821_CTLS) { - *qctrl = no_ctl; + if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1) + return -EINVAL; + for (i = 0; i < CX25821_CTLS; i++) + if (cx25821_ctls[i].v.id == qctrl->id) + break; + if (i == CX25821_CTLS) { + *qctrl = no_ctl; + return 0; + } + *qctrl = cx25821_ctls[i].v; return 0; - } - *qctrl = cx25821_ctls[i].v; - return 0; } */ From 69dfe45f7bae456fdee207be49eb1826172a5b16 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:38 +0800 Subject: [PATCH 1055/1519] Staging: cx25821: Change indent with spaces to tabs 1 Changed indent with spaces to use tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 116727a84bc..a952ca1bb32 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -230,14 +230,14 @@ int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, /* is it free? */ mutex_lock(&dev->lock); - if (dev->channels[fh->channel_id].resources & bit) { + if (dev->channels[fh->channel_id].resources & bit) { /* no, someone else uses it */ mutex_unlock(&dev->lock); return 0; } /* it's free, grab it */ fh->resources |= bit; - dev->channels[fh->channel_id].resources |= bit; + dev->channels[fh->channel_id].resources |= bit; dprintk(1, "res: get %d\n", bit); mutex_unlock(&dev->lock); return 1; @@ -250,7 +250,7 @@ int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit) int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit) { - return fh->dev->channels[fh->channel_id].resources & bit; + return fh->dev->channels[fh->channel_id].resources & bit; } void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, @@ -261,7 +261,7 @@ void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, mutex_lock(&dev->lock); fh->resources &= ~bits; - dev->channels[fh->channel_id].resources &= ~bits; + dev->channels[fh->channel_id].resources &= ~bits; dprintk(1, "res: put %d\n", bits); mutex_unlock(&dev->lock); } @@ -355,7 +355,7 @@ int cx25821_restart_video_queue(struct cx25821_dev *dev, buf->vb.state = VIDEOBUF_ACTIVE; buf->count = q->count++; prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); - prev->risc.jmp[2] = cpu_to_le32(0); /* Bits 63 - 32 */ + prev->risc.jmp[2] = cpu_to_le32(0); /* Bits 63 - 32 */ } else { return 0; } @@ -368,11 +368,11 @@ void cx25821_vid_timeout(unsigned long data) struct cx25821_data *timeout_data = (struct cx25821_data *)data; struct cx25821_dev *dev = timeout_data->dev; struct sram_channel *channel = timeout_data->channel; - struct cx25821_dmaqueue *q = &dev->channels[channel->i].vidq; + struct cx25821_dmaqueue *q = &dev->channels[channel->i].vidq; struct cx25821_buffer *buf; unsigned long flags; - /* cx25821_sram_channel_dump(dev, channel); */ + /* cx25821_sram_channel_dump(dev, channel); */ cx_clear(channel->dma_ctl, 0x11); spin_lock_irqsave(&dev->slock, flags); @@ -394,7 +394,7 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) u32 count = 0; int handled = 0; u32 mask; - struct sram_channel *channel = dev->channels[chan_num].sram_channels; + struct sram_channel *channel = dev->channels[chan_num].sram_channels; mask = cx_read(channel->int_msk); if (0 == (status & mask)) @@ -414,8 +414,8 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) if (status & FLD_VID_DST_RISC1) { spin_lock(&dev->slock); count = cx_read(channel->gpcnt); - cx25821_video_wakeup(dev, - &dev->channels[channel->i].vidq, count); + cx25821_video_wakeup(dev, &dev->channels[channel->i].vidq, + count); spin_unlock(&dev->slock); handled++; } From 788d0f33b990d10ad2542ee1dce8a0ebf2fcc335 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:39 +0800 Subject: [PATCH 1056/1519] Staging: cx25821: Change indent with spaces to tabs 2 Change indent with spaces to use tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index a952ca1bb32..206990ec2ea 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -424,9 +424,8 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) if (status & 0x10) { dprintk(2, "stopper video\n"); spin_lock(&dev->slock); - cx25821_restart_video_queue(dev, - &dev->channels[channel->i].vidq, - channel); + cx25821_restart_video_queue(dev, + &dev->channels[channel->i].vidq, channel); spin_unlock(&dev->slock); handled++; } @@ -449,18 +448,18 @@ void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num) { cx_clear(PCI_INT_MSK, 1); - if (dev->channels[chan_num].video_dev) { - if (video_is_registered(dev->channels[chan_num].video_dev)) - video_unregister_device( - dev->channels[chan_num].video_dev); + if (dev->channels[chan_num].video_dev) { + if (video_is_registered(dev->channels[chan_num].video_dev)) + video_unregister_device( + dev->channels[chan_num].video_dev); else - video_device_release( - dev->channels[chan_num].video_dev); + video_device_release( + dev->channels[chan_num].video_dev); - dev->channels[chan_num].video_dev = NULL; + dev->channels[chan_num].video_dev = NULL; - btcx_riscmem_free(dev->pci, - &dev->channels[chan_num].vidq.stopper); + btcx_riscmem_free(dev->pci, + &dev->channels[chan_num].vidq.stopper); pr_warn("device %d released!\n", chan_num); } From 48eb80ba3d0912f48f07ad95ef18ce50db7d7da8 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:40 +0800 Subject: [PATCH 1057/1519] Staging: cx25821: Change indent with spaces to tabs 3 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 35 ++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 206990ec2ea..e1909b2e3c2 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -469,30 +469,29 @@ void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num) int cx25821_video_register(struct cx25821_dev *dev) { int err; - int i; + int i; - struct video_device cx25821_video_device = { - .name = "cx25821-video", - .fops = &video_fops, - .minor = -1, - .ioctl_ops = &video_ioctl_ops, - .tvnorms = CX25821_NORMS, - .current_norm = V4L2_STD_NTSC_M, - }; + struct video_device cx25821_video_device = { + .name = "cx25821-video", + .fops = &video_fops, + .minor = -1, + .ioctl_ops = &video_ioctl_ops, + .tvnorms = CX25821_NORMS, + .current_norm = V4L2_STD_NTSC_M, + }; spin_lock_init(&dev->slock); - for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; ++i) { - cx25821_init_controls(dev, i); + for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; ++i) { + cx25821_init_controls(dev, i); - cx25821_risc_stopper(dev->pci, - &dev->channels[i].vidq.stopper, - dev->channels[i].sram_channels->dma_ctl, - 0x11, 0); + cx25821_risc_stopper(dev->pci, &dev->channels[i].vidq.stopper, + dev->channels[i].sram_channels->dma_ctl, + 0x11, 0); - dev->channels[i].sram_channels = &cx25821_sram_channels[i]; - dev->channels[i].video_dev = NULL; - dev->channels[i].resources = 0; + dev->channels[i].sram_channels = &cx25821_sram_channels[i]; + dev->channels[i].video_dev = NULL; + dev->channels[i].resources = 0; cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff); From 84cd410e11fb641a19b29c855b7a4b5b5ec9bd7b Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:41 +0800 Subject: [PATCH 1058/1519] Staging: cx25821: Change indent with spaces to tabs 4 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index e1909b2e3c2..6f5ee370e31 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -493,20 +493,19 @@ int cx25821_video_register(struct cx25821_dev *dev) dev->channels[i].video_dev = NULL; dev->channels[i].resources = 0; - cx_write(dev->channels[i].sram_channels->int_stat, - 0xffffffff); + cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff); - INIT_LIST_HEAD(&dev->channels[i].vidq.active); - INIT_LIST_HEAD(&dev->channels[i].vidq.queued); + INIT_LIST_HEAD(&dev->channels[i].vidq.active); + INIT_LIST_HEAD(&dev->channels[i].vidq.queued); - dev->channels[i].timeout_data.dev = dev; - dev->channels[i].timeout_data.channel = - &cx25821_sram_channels[i]; - dev->channels[i].vidq.timeout.function = - cx25821_vid_timeout; - dev->channels[i].vidq.timeout.data = - (unsigned long)&dev->channels[i].timeout_data; - init_timer(&dev->channels[i].vidq.timeout); + dev->channels[i].timeout_data.dev = dev; + dev->channels[i].timeout_data.channel = + &cx25821_sram_channels[i]; + dev->channels[i].vidq.timeout.function = + cx25821_vid_timeout; + dev->channels[i].vidq.timeout.data = + (unsigned long)&dev->channels[i].timeout_data; + init_timer(&dev->channels[i].vidq.timeout); /* register v4l devices */ dev->channels[i].video_dev = cx25821_vdev_init(dev, From 2ba5149861341dd35e823346de8d70b87b74a00c Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:42 +0800 Subject: [PATCH 1059/1519] Staging: cx25821: Change indent with spaces to tabs 5 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 6f5ee370e31..81450067081 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -507,31 +507,31 @@ int cx25821_video_register(struct cx25821_dev *dev) (unsigned long)&dev->channels[i].timeout_data; init_timer(&dev->channels[i].vidq.timeout); - /* register v4l devices */ - dev->channels[i].video_dev = cx25821_vdev_init(dev, - dev->pci, &cx25821_video_device, "video"); + /* register v4l devices */ + dev->channels[i].video_dev = cx25821_vdev_init(dev, + dev->pci, &cx25821_video_device, "video"); - err = video_register_device(dev->channels[i].video_dev, - VFL_TYPE_GRABBER, video_nr[dev->nr]); + err = video_register_device(dev->channels[i].video_dev, + VFL_TYPE_GRABBER, video_nr[dev->nr]); - if (err < 0) - goto fail_unreg; + if (err < 0) + goto fail_unreg; } - /* set PCI interrupt */ + /* set PCI interrupt */ cx_set(PCI_INT_MSK, 0xff); /* initial device configuration */ mutex_lock(&dev->lock); #ifdef TUNER_FLAG - dev->tvnorm = cx25821_video_device.current_norm; + dev->tvnorm = cx25821_video_device.current_norm; cx25821_set_tvnorm(dev, dev->tvnorm); #endif mutex_unlock(&dev->lock); - return 0; + return 0; fail_unreg: cx25821_video_unregister(dev, i); From 8e4ac0741f38bd28a118edbceefd2c7070d805c1 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:43 +0800 Subject: [PATCH 1060/1519] Staging: cx25821: Change indent with spaces to tabs 6 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 81450067081..d422d45df78 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -534,7 +534,7 @@ int cx25821_video_register(struct cx25821_dev *dev) return 0; fail_unreg: - cx25821_video_unregister(dev, i); + cx25821_video_unregister(dev, i); return err; } @@ -565,7 +565,7 @@ int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, u32 line0_offset, line1_offset; struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb); int bpl_local = LINE_SIZE_D1; - int channel_opened = fh->channel_id; + int channel_opened = fh->channel_id; BUG_ON(NULL == fh->fmt); if (fh->width < 48 || fh->width > 720 || @@ -604,21 +604,21 @@ int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, channel_opened = (channel_opened < 0 || channel_opened > 7) ? 7 : channel_opened; - if (dev->channels[channel_opened] - .pixel_formats == PIXEL_FRMT_411) + if (dev->channels[channel_opened].pixel_formats == + PIXEL_FRMT_411) buf->bpl = (buf->fmt->depth * buf->vb.width) >> 3; else buf->bpl = (buf->fmt->depth >> 3) * (buf->vb.width); - if (dev->channels[channel_opened] - .pixel_formats == PIXEL_FRMT_411) { + if (dev->channels[channel_opened].pixel_formats == + PIXEL_FRMT_411) { bpl_local = buf->bpl; } else { - bpl_local = buf->bpl; /* Default */ + bpl_local = buf->bpl; /* Default */ if (channel_opened >= 0 && channel_opened <= 7) { - if (dev->channels[channel_opened] - .use_cif_resolution) { + if (dev->channels[channel_opened] + .use_cif_resolution) { if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) bpl_local = 352 << 1; @@ -724,7 +724,7 @@ int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma) static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) { - struct cx25821_buffer *buf = + struct cx25821_buffer *buf = container_of(vb, struct cx25821_buffer, vb); struct cx25821_buffer *prev; struct cx25821_fh *fh = vq->priv_data; From e6cf66c1c067b89c7247aa1cd23b86d8a0ddcf50 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:44 +0800 Subject: [PATCH 1061/1519] Staging: cx25821: Change indent with spaces to tabs 7 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 57 ++++++++++++------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index d422d45df78..e4243895ed5 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -726,40 +726,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) { struct cx25821_buffer *buf = container_of(vb, struct cx25821_buffer, vb); - struct cx25821_buffer *prev; - struct cx25821_fh *fh = vq->priv_data; - struct cx25821_dev *dev = fh->dev; - struct cx25821_dmaqueue *q = &dev->channels[fh->channel_id].vidq; + struct cx25821_buffer *prev; + struct cx25821_fh *fh = vq->priv_data; + struct cx25821_dev *dev = fh->dev; + struct cx25821_dmaqueue *q = &dev->channels[fh->channel_id].vidq; - /* add jump to stopper */ - buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); - buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); - buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ + /* add jump to stopper */ + buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); + buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); + buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ - dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); + dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); - if (!list_empty(&q->queued)) { - list_add_tail(&buf->vb.queue, &q->queued); - buf->vb.state = VIDEOBUF_QUEUED; - dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, - buf->vb.i); + if (!list_empty(&q->queued)) { + list_add_tail(&buf->vb.queue, &q->queued); + buf->vb.state = VIDEOBUF_QUEUED; + dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, + buf->vb.i); - } else if (list_empty(&q->active)) { - list_add_tail(&buf->vb.queue, &q->active); - cx25821_start_video_dma(dev, q, buf, - dev->channels[fh->channel_id]. - sram_channels); - buf->vb.state = VIDEOBUF_ACTIVE; - buf->count = q->count++; - mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); - dprintk(2, - "[%p/%d] buffer_queue - first active, buf cnt = %d, \ - q->count = %d\n", - buf, buf->vb.i, buf->count, q->count); - } else { - prev = - list_entry(q->active.prev, struct cx25821_buffer, vb.queue); - if (prev->vb.width == buf->vb.width + } else if (list_empty(&q->active)) { + list_add_tail(&buf->vb.queue, &q->active); + cx25821_start_video_dma(dev, q, buf, + dev->channels[fh->channel_id].sram_channels); + buf->vb.state = VIDEOBUF_ACTIVE; + buf->count = q->count++; + mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); + dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", + buf, buf->vb.i, buf->count, q->count); + } else { + prev = list_entry(q->active.prev, struct cx25821_buffer, + vb.queue); + if (prev->vb.width == buf->vb.width && prev->vb.height == buf->vb.height && prev->fmt == buf->fmt) { list_add_tail(&buf->vb.queue, &q->active); From 8ebbda49b70b1137a3f30f6065876f8f871ffcde Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:45 +0800 Subject: [PATCH 1062/1519] Staging: cx25821: Change indent with spaces to tabs 8 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 36 ++++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index e4243895ed5..fbf741d7fa5 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -759,28 +759,26 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) if (prev->vb.width == buf->vb.width && prev->vb.height == buf->vb.height && prev->fmt == buf->fmt) { - list_add_tail(&buf->vb.queue, &q->active); - buf->vb.state = VIDEOBUF_ACTIVE; - buf->count = q->count++; - prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); + list_add_tail(&buf->vb.queue, &q->active); + buf->vb.state = VIDEOBUF_ACTIVE; + buf->count = q->count++; + prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); - /* 64 bit bits 63-32 */ - prev->risc.jmp[2] = cpu_to_le32(0); - dprintk(2, - "[%p/%d] buffer_queue - append to active, \ - buf->count=%d\n", - buf, buf->vb.i, buf->count); + /* 64 bit bits 63-32 */ + prev->risc.jmp[2] = cpu_to_le32(0); + dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", + buf, buf->vb.i, buf->count); - } else { - list_add_tail(&buf->vb.queue, &q->queued); - buf->vb.state = VIDEOBUF_QUEUED; - dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, - buf->vb.i); - } - } + } else { + list_add_tail(&buf->vb.queue, &q->queued); + buf->vb.state = VIDEOBUF_QUEUED; + dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, + buf->vb.i); + } + } - if (list_empty(&q->active)) - dprintk(2, "active queue empty!\n"); + if (list_empty(&q->active)) + dprintk(2, "active queue empty!\n"); } static struct videobuf_queue_ops cx25821_video_qops = { From fb5f2c8010b5cd81e8114dc8a3f853cee5fc4c1c Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:46 +0800 Subject: [PATCH 1063/1519] Staging: cx25821: Change indent with spaces to tabs 9 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index fbf741d7fa5..268f51b93ec 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -782,32 +782,31 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) } static struct videobuf_queue_ops cx25821_video_qops = { - .buf_setup = cx25821_buffer_setup, - .buf_prepare = cx25821_buffer_prepare, - .buf_queue = buffer_queue, - .buf_release = cx25821_buffer_release, + .buf_setup = cx25821_buffer_setup, + .buf_prepare = cx25821_buffer_prepare, + .buf_queue = buffer_queue, + .buf_release = cx25821_buffer_release, }; static int video_open(struct file *file) { - struct video_device *vdev = video_devdata(file); - struct cx25821_dev *h, *dev = video_drvdata(file); - struct cx25821_fh *fh; - struct list_head *list; - int minor = video_devdata(file)->minor; - enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - u32 pix_format; - int ch_id = 0; - int i; + struct video_device *vdev = video_devdata(file); + struct cx25821_dev *h, *dev = video_drvdata(file); + struct cx25821_fh *fh; + struct list_head *list; + int minor = video_devdata(file)->minor; + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + u32 pix_format; + int ch_id = 0; + int i; - dprintk(1, "open dev=%s type=%s\n", - video_device_node_name(vdev), - v4l2_type_names[type]); + dprintk(1, "open dev=%s type=%s\n", video_device_node_name(vdev), + v4l2_type_names[type]); - /* allocate + initialize per filehandle data */ - fh = kzalloc(sizeof(*fh), GFP_KERNEL); - if (NULL == fh) - return -ENOMEM; + /* allocate + initialize per filehandle data */ + fh = kzalloc(sizeof(*fh), GFP_KERNEL); + if (NULL == fh) + return -ENOMEM; mutex_lock(&cx25821_devlist_mutex); From 9eadb1711cd76710efd89b4b801e2180b2938d5f Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:47 +0800 Subject: [PATCH 1064/1519] Staging: cx25821: Change indent with spaces to tabs 10 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 268f51b93ec..61fa7aff80d 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -810,25 +810,25 @@ static int video_open(struct file *file) mutex_lock(&cx25821_devlist_mutex); - list_for_each(list, &cx25821_devlist) - { - h = list_entry(list, struct cx25821_dev, devlist); + list_for_each(list, &cx25821_devlist) + { + h = list_entry(list, struct cx25821_dev, devlist); - for (i = 0; i < MAX_VID_CHANNEL_NUM; i++) { - if (h->channels[i].video_dev && + for (i = 0; i < MAX_VID_CHANNEL_NUM; i++) { + if (h->channels[i].video_dev && h->channels[i].video_dev->minor == minor) { - dev = h; - ch_id = i; - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - } - } - } + dev = h; + ch_id = i; + type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + } + } + } - if (NULL == dev) { + if (NULL == dev) { mutex_unlock(&cx25821_devlist_mutex); kfree(fh); return -ENODEV; - } + } file->private_data = fh; fh->dev = dev; From 0bf42c9e4f45b8ec8699d903d3509343de6fe1ca Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:48 +0800 Subject: [PATCH 1065/1519] Staging: cx25821: Change indent with spaces to tabs 11 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 31 ++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 61fa7aff80d..db9b765bf1e 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -830,26 +830,25 @@ static int video_open(struct file *file) return -ENODEV; } - file->private_data = fh; - fh->dev = dev; - fh->type = type; - fh->width = 720; - fh->channel_id = ch_id; + file->private_data = fh; + fh->dev = dev; + fh->type = type; + fh->width = 720; + fh->channel_id = ch_id; - if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) - fh->height = 576; - else - fh->height = 480; + if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) + fh->height = 576; + else + fh->height = 480; - dev->channel_opened = fh->channel_id; - pix_format = - (dev->channels[ch_id].pixel_formats == - PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; - fh->fmt = cx25821_format_by_fourcc(pix_format); + dev->channel_opened = fh->channel_id; + pix_format = (dev->channels[ch_id].pixel_formats == PIXEL_FRMT_411) ? + V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; + fh->fmt = cx25821_format_by_fourcc(pix_format); - v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio); + v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio); - videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, + videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, &dev->pci->dev, &dev->slock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_INTERLACED, From 20e8a366c0a04ff4c12465e9eb0d38b7a0e4efb4 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:49 +0800 Subject: [PATCH 1066/1519] Staging: cx25821: Change indent with spaces to tabs 12 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index db9b765bf1e..3af5f2bfaa8 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -854,29 +854,29 @@ static int video_open(struct file *file) V4L2_FIELD_INTERLACED, sizeof(struct cx25821_buffer), fh, NULL); - dprintk(1, "post videobuf_queue_init()\n"); + dprintk(1, "post videobuf_queue_init()\n"); mutex_unlock(&cx25821_devlist_mutex); - return 0; + return 0; } static ssize_t video_read(struct file *file, char __user * data, size_t count, loff_t *ppos) { - struct cx25821_fh *fh = file->private_data; + struct cx25821_fh *fh = file->private_data; - switch (fh->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (cx25821_res_locked(fh, RESOURCE_VIDEO0)) - return -EBUSY; + switch (fh->type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + if (cx25821_res_locked(fh, RESOURCE_VIDEO0)) + return -EBUSY; - return videobuf_read_one(&fh->vidq, data, count, ppos, + return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); - default: - BUG(); - return 0; - } + default: + BUG(); + return 0; + } } static unsigned int video_poll(struct file *file, From 55c37c0d6c9f447b2d42d0505471e8edcf283d5f Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:50 +0800 Subject: [PATCH 1067/1519] Staging: cx25821: Change indent with spaces to tabs 13 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 3af5f2bfaa8..958940f7074 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -882,41 +882,41 @@ static ssize_t video_read(struct file *file, char __user * data, size_t count, static unsigned int video_poll(struct file *file, struct poll_table_struct *wait) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_buffer *buf; + struct cx25821_fh *fh = file->private_data; + struct cx25821_buffer *buf; - if (cx25821_res_check(fh, RESOURCE_VIDEO0)) { - /* streaming capture */ - if (list_empty(&fh->vidq.stream)) - return POLLERR; - buf = list_entry(fh->vidq.stream.next, + if (cx25821_res_check(fh, RESOURCE_VIDEO0)) { + /* streaming capture */ + if (list_empty(&fh->vidq.stream)) + return POLLERR; + buf = list_entry(fh->vidq.stream.next, struct cx25821_buffer, vb.stream); - } else { - /* read() capture */ - buf = (struct cx25821_buffer *)fh->vidq.read_buf; - if (NULL == buf) - return POLLERR; - } + } else { + /* read() capture */ + buf = (struct cx25821_buffer *)fh->vidq.read_buf; + if (NULL == buf) + return POLLERR; + } - poll_wait(file, &buf->vb.done, wait); - if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) { - if (buf->vb.state == VIDEOBUF_DONE) { - struct cx25821_dev *dev = fh->dev; + poll_wait(file, &buf->vb.done, wait); + if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) { + if (buf->vb.state == VIDEOBUF_DONE) { + struct cx25821_dev *dev = fh->dev; - if (dev && dev->channels[fh->channel_id] - .use_cif_resolution) { - u8 cam_id = *((char *)buf->vb.baddr + 3); - memcpy((char *)buf->vb.baddr, + if (dev && dev->channels[fh->channel_id] + .use_cif_resolution) { + u8 cam_id = *((char *)buf->vb.baddr + 3); + memcpy((char *)buf->vb.baddr, (char *)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); - *((char *)buf->vb.baddr + 3) = cam_id; - } - } + *((char *)buf->vb.baddr + 3) = cam_id; + } + } - return POLLIN | POLLRDNORM; - } + return POLLIN | POLLRDNORM; + } - return 0; + return 0; } static int video_release(struct file *file) From 21377cdd5e34b135d62bda5d974f052adf873341 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:51 +0800 Subject: [PATCH 1068/1519] Staging: cx25821: Change indent with spaces to tabs 14 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 958940f7074..75bc44e2548 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -921,30 +921,30 @@ static unsigned int video_poll(struct file *file, static int video_release(struct file *file) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_dev *dev = fh->dev; + struct cx25821_fh *fh = file->private_data; + struct cx25821_dev *dev = fh->dev; - /* stop the risc engine and fifo */ - cx_write(channel0->dma_ctl, 0); /* FIFO and RISC disable */ + /* stop the risc engine and fifo */ + cx_write(channel0->dma_ctl, 0); /* FIFO and RISC disable */ - /* stop video capture */ - if (cx25821_res_check(fh, RESOURCE_VIDEO0)) { - videobuf_queue_cancel(&fh->vidq); - cx25821_res_free(dev, fh, RESOURCE_VIDEO0); - } + /* stop video capture */ + if (cx25821_res_check(fh, RESOURCE_VIDEO0)) { + videobuf_queue_cancel(&fh->vidq); + cx25821_res_free(dev, fh, RESOURCE_VIDEO0); + } - if (fh->vidq.read_buf) { - cx25821_buffer_release(&fh->vidq, fh->vidq.read_buf); - kfree(fh->vidq.read_buf); - } + if (fh->vidq.read_buf) { + cx25821_buffer_release(&fh->vidq, fh->vidq.read_buf); + kfree(fh->vidq.read_buf); + } - videobuf_mmap_free(&fh->vidq); + videobuf_mmap_free(&fh->vidq); - v4l2_prio_close(&dev->channels[fh->channel_id].prio, fh->prio); - file->private_data = NULL; - kfree(fh); + v4l2_prio_close(&dev->channels[fh->channel_id].prio, fh->prio); + file->private_data = NULL; + kfree(fh); - return 0; + return 0; } static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) From 3f3d9e4a54d09f2d7f36c274b5e84e15756815a0 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:52 +0800 Subject: [PATCH 1069/1519] Staging: cx25821: Change indent with spaces to tabs 15 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 75bc44e2548..83872c801c7 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -949,20 +949,20 @@ static int video_release(struct file *file) static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) { - struct cx25821_fh *fh = priv; - struct cx25821_dev *dev = fh->dev; + struct cx25821_fh *fh = priv; + struct cx25821_dev *dev = fh->dev; - if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) - return -EINVAL; + if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) + return -EINVAL; - if (unlikely(i != fh->type)) - return -EINVAL; + if (unlikely(i != fh->type)) + return -EINVAL; - if (unlikely(!cx25821_res_get(dev, fh, - cx25821_get_resource(fh, RESOURCE_VIDEO0)))) - return -EBUSY; + if (unlikely(!cx25821_res_get(dev, fh, cx25821_get_resource(fh, + RESOURCE_VIDEO0)))) + return -EBUSY; - return videobuf_streamon(get_queue(fh)); + return videobuf_streamon(get_queue(fh)); } static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) From eda59eb189a387caa64514f4dcfa71af46d8870a Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:53 +0800 Subject: [PATCH 1070/1519] Staging: cx25821: Change indent with spaces to tabs 16 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 83872c801c7..e27b224db9e 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -967,21 +967,21 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) { - struct cx25821_fh *fh = priv; - struct cx25821_dev *dev = fh->dev; - int err, res; + struct cx25821_fh *fh = priv; + struct cx25821_dev *dev = fh->dev; + int err, res; - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (i != fh->type) - return -EINVAL; + if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + if (i != fh->type) + return -EINVAL; - res = cx25821_get_resource(fh, RESOURCE_VIDEO0); - err = videobuf_streamoff(get_queue(fh)); - if (err < 0) - return err; - cx25821_res_free(dev, fh, res); - return 0; + res = cx25821_get_resource(fh, RESOURCE_VIDEO0); + err = videobuf_streamoff(get_queue(fh)); + if (err < 0) + return err; + cx25821_res_free(dev, fh, res); + return 0; } static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, From a39bea3a4e2c8de6904c9e288d8994e703f51819 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:54 +0800 Subject: [PATCH 1071/1519] Staging: cx25821: Change indent with spaces to tabs 17 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index e27b224db9e..1815c30c4e4 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -987,18 +987,18 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct cx25821_fh *fh = priv; - struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; + struct cx25821_fh *fh = priv; + struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct v4l2_mbus_framefmt mbus_fmt; - int err; - int pix_format = PIXEL_FRMT_422; + int err; + int pix_format = PIXEL_FRMT_422; - if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); - if (0 != err) - return err; - } + if (fh) { + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); + if (0 != err) + return err; + } dprintk(2, "%s()\n", __func__); err = cx25821_vidioc_try_fmt_vid_cap(file, priv, f); From 255c040a4273a46939facbae8833c11e983a1e47 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:55 +0800 Subject: [PATCH 1072/1519] Staging: cx25821: Change indent with spaces to tabs 18 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 1815c30c4e4..5713656880d 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1000,21 +1000,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, return err; } - dprintk(2, "%s()\n", __func__); - err = cx25821_vidioc_try_fmt_vid_cap(file, priv, f); + dprintk(2, "%s()\n", __func__); + err = cx25821_vidioc_try_fmt_vid_cap(file, priv, f); - if (0 != err) - return err; + if (0 != err) + return err; - fh->fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat); - fh->vidq.field = f->fmt.pix.field; + fh->fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat); + fh->vidq.field = f->fmt.pix.field; - /* check if width and height is valid based on set standard */ - if (cx25821_is_valid_width(f->fmt.pix.width, dev->tvnorm)) - fh->width = f->fmt.pix.width; + /* check if width and height is valid based on set standard */ + if (cx25821_is_valid_width(f->fmt.pix.width, dev->tvnorm)) + fh->width = f->fmt.pix.width; - if (cx25821_is_valid_height(f->fmt.pix.height, dev->tvnorm)) - fh->height = f->fmt.pix.height; + if (cx25821_is_valid_height(f->fmt.pix.height, dev->tvnorm)) + fh->height = f->fmt.pix.height; if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) pix_format = PIXEL_FRMT_411; From 6678762aa289a4bfd6ce779e40680b70e9a3258d Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:56 +0800 Subject: [PATCH 1073/1519] Staging: cx25821: Change indent with spaces to tabs 19 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 5713656880d..bbf1ad98a8a 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1016,30 +1016,30 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, if (cx25821_is_valid_height(f->fmt.pix.height, dev->tvnorm)) fh->height = f->fmt.pix.height; - if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) - pix_format = PIXEL_FRMT_411; - else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) - pix_format = PIXEL_FRMT_422; - else - return -EINVAL; + if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) + pix_format = PIXEL_FRMT_411; + else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) + pix_format = PIXEL_FRMT_422; + else + return -EINVAL; - cx25821_set_pixel_format(dev, SRAM_CH00, pix_format); + cx25821_set_pixel_format(dev, SRAM_CH00, pix_format); - /* check if cif resolution */ - if (fh->width == 320 || fh->width == 352) - dev->channels[fh->channel_id].use_cif_resolution = 1; - else - dev->channels[fh->channel_id].use_cif_resolution = 0; + /* check if cif resolution */ + if (fh->width == 320 || fh->width == 352) + dev->channels[fh->channel_id].use_cif_resolution = 1; + else + dev->channels[fh->channel_id].use_cif_resolution = 0; - dev->channels[fh->channel_id].cif_width = fh->width; - medusa_set_resolution(dev, fh->width, SRAM_CH00); + dev->channels[fh->channel_id].cif_width = fh->width; + medusa_set_resolution(dev, fh->width, SRAM_CH00); dprintk(2, "%s(): width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); cx25821_call_all(dev, video, s_mbus_fmt, &mbus_fmt); - return 0; + return 0; } static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) From 02859b61cc0ec4bba2dca638268afb3c4d73d3a7 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:57 +0800 Subject: [PATCH 1074/1519] Staging: cx25821: Change indent with spaces to tabs 20 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index bbf1ad98a8a..c77e9d5df65 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1044,37 +1044,37 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) { - int ret_val = 0; - struct cx25821_fh *fh = priv; - struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; + int ret_val = 0; + struct cx25821_fh *fh = priv; + struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; - ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); + ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); - p->sequence = dev->channels[fh->channel_id].vidq.count; + p->sequence = dev->channels[fh->channel_id].vidq.count; - return ret_val; + return ret_val; } static int vidioc_log_status(struct file *file, void *priv) { - struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; - struct cx25821_fh *fh = priv; - char name[32 + 2]; + struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; + struct cx25821_fh *fh = priv; + char name[32 + 2]; - struct sram_channel *sram_ch = dev->channels[fh->channel_id] - .sram_channels; - u32 tmp = 0; + struct sram_channel *sram_ch = dev->channels[fh->channel_id] + .sram_channels; + u32 tmp = 0; - snprintf(name, sizeof(name), "%s/2", dev->name); + snprintf(name, sizeof(name), "%s/2", dev->name); pr_info("%s/2: ============ START LOG STATUS ============\n", dev->name); - cx25821_call_all(dev, core, log_status); - tmp = cx_read(sram_ch->dma_ctl); + cx25821_call_all(dev, core, log_status); + tmp = cx_read(sram_ch->dma_ctl); pr_info("Video input 0 is %s\n", (tmp & 0x11) ? "streaming" : "stopped"); pr_info("%s/2: ============= END LOG STATUS =============\n", dev->name); - return 0; + return 0; } static int vidioc_s_ctrl(struct file *file, void *priv, From f9a8150c924c9793ee6cd52cce663756bae27314 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:58 +0800 Subject: [PATCH 1075/1519] Staging: cx25821: Change indent with spaces to tabs 21 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index c77e9d5df65..709fe3d98bc 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1080,18 +1080,18 @@ static int vidioc_log_status(struct file *file, void *priv) static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctl) { - struct cx25821_fh *fh = priv; - struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; - int err; + struct cx25821_fh *fh = priv; + struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; + int err; - if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); - if (0 != err) - return err; - } + if (fh) { + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); + if (0 != err) + return err; + } - return cx25821_set_control(dev, ctl, fh->channel_id); + return cx25821_set_control(dev, ctl, fh->channel_id); } /* VIDEO IOCTLS */ From 70e7f145e416dfe0ce8c38e77d8a5280f08eda7f Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:14:59 +0800 Subject: [PATCH 1076/1519] Staging: cx25821: Change indent with spaces to tabs 22 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 709fe3d98bc..4cea79156cf 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1208,9 +1208,9 @@ int cx25821_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p) { struct cx25821_dev *dev = ((struct cx25821_fh *)f)->dev; - struct cx25821_fh *fh = f; + struct cx25821_fh *fh = f; - *p = v4l2_prio_max(&dev->channels[fh->channel_id].prio); + *p = v4l2_prio_max(&dev->channels[fh->channel_id].prio); return 0; } @@ -1221,8 +1221,8 @@ int cx25821_vidioc_s_priority(struct file *file, void *f, struct cx25821_fh *fh = f; struct cx25821_dev *dev = ((struct cx25821_fh *)f)->dev; - return v4l2_prio_change(&dev->channels[fh->channel_id] - .prio, &fh->prio, prio); + return v4l2_prio_change(&dev->channels[fh->channel_id].prio, &fh->prio, + prio); } #ifdef TUNER_FLAG @@ -1235,15 +1235,14 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms) dprintk(1, "%s()\n", __func__); if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); if (0 != err) return err; } - if (dev->tvnorm == *tvnorms) { + if (dev->tvnorm == *tvnorms) return 0; - } mutex_lock(&dev->lock); cx25821_set_tvnorm(dev, *tvnorms); @@ -1257,7 +1256,7 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms) int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i) { - static const char *iname[] = { + static const char * const iname[] = { [CX25821_VMUX_COMPOSITE] = "Composite", [CX25821_VMUX_SVIDEO] = "S-Video", [CX25821_VMUX_DEBUG] = "for debug only", @@ -1305,8 +1304,8 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i) dprintk(1, "%s(%d)\n", __func__, i); if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); if (0 != err) return err; } From e0b871bd2c8f6760c75cc72d960533b1928f16ab Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:00 +0800 Subject: [PATCH 1077/1519] Staging: cx25821: Change indent with spaces to tabs 23 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 4cea79156cf..8cda0f9380e 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1358,14 +1358,14 @@ int cx25821_vidioc_s_frequency(struct file *file, void *priv, int err; if (fh) { - dev = fh->dev; - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); + dev = fh->dev; + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); if (0 != err) return err; - } else { - pr_err("Invalid fh pointer!\n"); - return -EINVAL; + } else { + pr_err("Invalid fh pointer!\n"); + return -EINVAL; } return cx25821_set_freq(dev, f); @@ -1427,8 +1427,8 @@ int cx25821_vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) int err; if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id] - .prio, fh->prio); + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); if (0 != err) return err; } @@ -1527,7 +1527,7 @@ int cx25821_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctl) { struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; - struct cx25821_fh *fh = priv; + struct cx25821_fh *fh = priv; const struct v4l2_queryctrl *ctrl; @@ -1537,16 +1537,16 @@ int cx25821_vidioc_g_ctrl(struct file *file, void *priv, return -EINVAL; switch (ctl->id) { case V4L2_CID_BRIGHTNESS: - ctl->value = dev->channels[fh->channel_id].ctl_bright; + ctl->value = dev->channels[fh->channel_id].ctl_bright; break; case V4L2_CID_HUE: - ctl->value = dev->channels[fh->channel_id].ctl_hue; + ctl->value = dev->channels[fh->channel_id].ctl_hue; break; case V4L2_CID_CONTRAST: - ctl->value = dev->channels[fh->channel_id].ctl_contrast; + ctl->value = dev->channels[fh->channel_id].ctl_contrast; break; case V4L2_CID_SATURATION: - ctl->value = dev->channels[fh->channel_id].ctl_saturation; + ctl->value = dev->channels[fh->channel_id].ctl_saturation; break; } return 0; From 8a911ed9c0eb73530b823a55756cd39763824867 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:01 +0800 Subject: [PATCH 1078/1519] Staging: cx25821: Change indent with spaces to tabs 24 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 8cda0f9380e..d3c387015d7 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1580,19 +1580,19 @@ int cx25821_set_control(struct cx25821_dev *dev, switch (ctl->id) { case V4L2_CID_BRIGHTNESS: - dev->channels[chan_num].ctl_bright = ctl->value; + dev->channels[chan_num].ctl_bright = ctl->value; medusa_set_brightness(dev, ctl->value, chan_num); break; case V4L2_CID_HUE: - dev->channels[chan_num].ctl_hue = ctl->value; + dev->channels[chan_num].ctl_hue = ctl->value; medusa_set_hue(dev, ctl->value, chan_num); break; case V4L2_CID_CONTRAST: - dev->channels[chan_num].ctl_contrast = ctl->value; + dev->channels[chan_num].ctl_contrast = ctl->value; medusa_set_contrast(dev, ctl->value, chan_num); break; case V4L2_CID_SATURATION: - dev->channels[chan_num].ctl_saturation = ctl->value; + dev->channels[chan_num].ctl_saturation = ctl->value; medusa_set_saturation(dev, ctl->value, chan_num); break; } @@ -1625,9 +1625,9 @@ int cx25821_vidioc_cropcap(struct file *file, void *priv, cropcap->bounds.width = 720; cropcap->bounds.height = dev->tvnorm == V4L2_STD_PAL_BG ? 576 : 480; cropcap->pixelaspect.numerator = - dev->tvnorm == V4L2_STD_PAL_BG ? 59 : 10; + dev->tvnorm == V4L2_STD_PAL_BG ? 59 : 10; cropcap->pixelaspect.denominator = - dev->tvnorm == V4L2_STD_PAL_BG ? 54 : 11; + dev->tvnorm == V4L2_STD_PAL_BG ? 54 : 11; cropcap->defrect = cropcap->bounds; return 0; } @@ -1639,24 +1639,24 @@ int cx25821_vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop) int err; if (fh) { - err = v4l2_prio_check(&dev->channels[fh->channel_id]. - prio, fh->prio); + err = v4l2_prio_check(&dev->channels[fh->channel_id].prio, + fh->prio); if (0 != err) return err; } - /* cx25821_vidioc_s_crop not supported */ + /* cx25821_vidioc_s_crop not supported */ return -EINVAL; } int cx25821_vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop) { - /* cx25821_vidioc_g_crop not supported */ + /* cx25821_vidioc_g_crop not supported */ return -EINVAL; } int cx25821_vidioc_querystd(struct file *file, void *priv, v4l2_std_id * norm) { - /* medusa does not support video standard sensing of current input */ + /* medusa does not support video standard sensing of current input */ *norm = CX25821_NORMS; return 0; From 75965b8f6fcb3f41b256c365d34ba1eca3cdbe93 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:02 +0800 Subject: [PATCH 1079/1519] Staging: cx25821: Change indent with spaces to tabs 25 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index d3c387015d7..fb89c2785b1 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1702,30 +1702,29 @@ int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm) static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned long arg) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_dev *dev = fh->dev; - int command = 0; - struct upstream_user_struct *data_from_user; + struct cx25821_fh *fh = file->private_data; + struct cx25821_dev *dev = fh->dev; + int command = 0; + struct upstream_user_struct *data_from_user; - data_from_user = (struct upstream_user_struct *)arg; + data_from_user = (struct upstream_user_struct *)arg; if (!data_from_user) { pr_err("%s(): Upstream data is INVALID. Returning\n", __func__); return 0; } - command = data_from_user->command; + command = data_from_user->command; - if (command != UPSTREAM_START_VIDEO && - command != UPSTREAM_STOP_VIDEO) - return 0; + if (command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO) + return 0; - dev->input_filename = data_from_user->input_filename; - dev->input_audiofilename = data_from_user->input_filename; - dev->vid_stdname = data_from_user->vid_stdname; - dev->pixel_format = data_from_user->pixel_format; - dev->channel_select = data_from_user->channel_select; - dev->command = data_from_user->command; + dev->input_filename = data_from_user->input_filename; + dev->input_audiofilename = data_from_user->input_filename; + dev->vid_stdname = data_from_user->vid_stdname; + dev->pixel_format = data_from_user->pixel_format; + dev->channel_select = data_from_user->channel_select; + dev->command = data_from_user->command; switch (command) { case UPSTREAM_START_VIDEO: From 6f87cc6cd91a077cc9b6946cc1cb63032d15ecb4 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:03 +0800 Subject: [PATCH 1080/1519] Staging: cx25821: Change indent with spaces to tabs 26 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index fb89c2785b1..4d3d4f25edc 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1726,17 +1726,17 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd, dev->channel_select = data_from_user->channel_select; dev->command = data_from_user->command; - switch (command) { - case UPSTREAM_START_VIDEO: - cx25821_start_upstream_video_ch1(dev, data_from_user); - break; + switch (command) { + case UPSTREAM_START_VIDEO: + cx25821_start_upstream_video_ch1(dev, data_from_user); + break; - case UPSTREAM_STOP_VIDEO: - cx25821_stop_upstream_video_ch1(dev); - break; - } + case UPSTREAM_STOP_VIDEO: + cx25821_stop_upstream_video_ch1(dev); + break; + } - return 0; + return 0; } static long video_ioctl_upstream10(struct file *file, unsigned int cmd, From 43be3824d967c7aee557f3a3e6ade665b161c1b8 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:04 +0800 Subject: [PATCH 1081/1519] Staging: cx25821: Change indent with spaces to tabs 27 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 4d3d4f25edc..5c890c9077c 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1742,30 +1742,29 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd, static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned long arg) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_dev *dev = fh->dev; - int command = 0; - struct upstream_user_struct *data_from_user; + struct cx25821_fh *fh = file->private_data; + struct cx25821_dev *dev = fh->dev; + int command = 0; + struct upstream_user_struct *data_from_user; - data_from_user = (struct upstream_user_struct *)arg; + data_from_user = (struct upstream_user_struct *)arg; if (!data_from_user) { pr_err("%s(): Upstream data is INVALID. Returning\n", __func__); return 0; } - command = data_from_user->command; + command = data_from_user->command; - if (command != UPSTREAM_START_VIDEO && - command != UPSTREAM_STOP_VIDEO) - return 0; + if (command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO) + return 0; - dev->input_filename_ch2 = data_from_user->input_filename; - dev->input_audiofilename = data_from_user->input_filename; - dev->vid_stdname_ch2 = data_from_user->vid_stdname; - dev->pixel_format_ch2 = data_from_user->pixel_format; - dev->channel_select_ch2 = data_from_user->channel_select; - dev->command_ch2 = data_from_user->command; + dev->input_filename_ch2 = data_from_user->input_filename; + dev->input_audiofilename = data_from_user->input_filename; + dev->vid_stdname_ch2 = data_from_user->vid_stdname; + dev->pixel_format_ch2 = data_from_user->pixel_format; + dev->channel_select_ch2 = data_from_user->channel_select; + dev->command_ch2 = data_from_user->command; switch (command) { case UPSTREAM_START_VIDEO: From f9ef6be38960bde3e33b89544b1a2894580724d2 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:05 +0800 Subject: [PATCH 1082/1519] Staging: cx25821: Change indent with spaces to tabs 28 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 5c890c9077c..f6a9a5c889e 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1766,17 +1766,17 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd, dev->channel_select_ch2 = data_from_user->channel_select; dev->command_ch2 = data_from_user->command; - switch (command) { - case UPSTREAM_START_VIDEO: - cx25821_start_upstream_video_ch2(dev, data_from_user); - break; + switch (command) { + case UPSTREAM_START_VIDEO: + cx25821_start_upstream_video_ch2(dev, data_from_user); + break; - case UPSTREAM_STOP_VIDEO: - cx25821_stop_upstream_video_ch2(dev); - break; - } + case UPSTREAM_STOP_VIDEO: + cx25821_stop_upstream_video_ch2(dev); + break; + } - return 0; + return 0; } static long video_ioctl_upstream11(struct file *file, unsigned int cmd, From 5e6440141e7673624dc8e2e754b7661c80d47d05 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:06 +0800 Subject: [PATCH 1083/1519] Staging: cx25821: Change indent with spaces to tabs 29 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 47 ++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index f6a9a5c889e..57f1a55fa62 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1782,42 +1782,41 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd, static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_dev *dev = fh->dev; - int command = 0; - struct upstream_user_struct *data_from_user; + struct cx25821_fh *fh = file->private_data; + struct cx25821_dev *dev = fh->dev; + int command = 0; + struct upstream_user_struct *data_from_user; - data_from_user = (struct upstream_user_struct *)arg; + data_from_user = (struct upstream_user_struct *)arg; if (!data_from_user) { pr_err("%s(): Upstream data is INVALID. Returning\n", __func__); return 0; } - command = data_from_user->command; + command = data_from_user->command; - if (command != UPSTREAM_START_AUDIO && - command != UPSTREAM_STOP_AUDIO) - return 0; + if (command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO) + return 0; - dev->input_filename = data_from_user->input_filename; - dev->input_audiofilename = data_from_user->input_filename; - dev->vid_stdname = data_from_user->vid_stdname; - dev->pixel_format = data_from_user->pixel_format; - dev->channel_select = data_from_user->channel_select; - dev->command = data_from_user->command; + dev->input_filename = data_from_user->input_filename; + dev->input_audiofilename = data_from_user->input_filename; + dev->vid_stdname = data_from_user->vid_stdname; + dev->pixel_format = data_from_user->pixel_format; + dev->channel_select = data_from_user->channel_select; + dev->command = data_from_user->command; - switch (command) { - case UPSTREAM_START_AUDIO: - cx25821_start_upstream_audio(dev, data_from_user); - break; + switch (command) { + case UPSTREAM_START_AUDIO: + cx25821_start_upstream_audio(dev, data_from_user); + break; - case UPSTREAM_STOP_AUDIO: - cx25821_stop_upstream_audio(dev); - break; - } + case UPSTREAM_STOP_AUDIO: + cx25821_stop_upstream_audio(dev); + break; + } - return 0; + return 0; } static long video_ioctl_set(struct file *file, unsigned int cmd, From 16a81efe8819af8d99d68185cca904e1d6d9d864 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:07 +0800 Subject: [PATCH 1084/1519] Staging: cx25821: Change indent with spaces to tabs 30 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 57f1a55fa62..fbdb79f0c75 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1822,25 +1822,25 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long arg) { - struct cx25821_fh *fh = file->private_data; - struct cx25821_dev *dev = fh->dev; - struct downstream_user_struct *data_from_user; - int command; - int width = 720; - int selected_channel = 0, pix_format = 0, i = 0; - int cif_enable = 0, cif_width = 0; - u32 value = 0; + struct cx25821_fh *fh = file->private_data; + struct cx25821_dev *dev = fh->dev; + struct downstream_user_struct *data_from_user; + int command; + int width = 720; + int selected_channel = 0, pix_format = 0, i = 0; + int cif_enable = 0, cif_width = 0; + u32 value = 0; - data_from_user = (struct downstream_user_struct *)arg; + data_from_user = (struct downstream_user_struct *)arg; if (!data_from_user) { pr_err("%s(): User data is INVALID. Returning\n", __func__); return 0; } - command = data_from_user->command; + command = data_from_user->command; - if (command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT + if (command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION && command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE) { From 12fe746fa96db3c14879222e977191eab1be8629 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:08 +0800 Subject: [PATCH 1085/1519] Staging: cx25821: Change indent with spaces to tabs 31 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 35 ++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index fbdb79f0c75..2383feb9782 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1844,28 +1844,27 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, && command != ENABLE_CIF_RESOLUTION && command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE) { - return 0; - } + return 0; + } - switch (command) { - case SET_VIDEO_STD: - dev->tvnorm = - !strcmp(data_from_user->vid_stdname, - "PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; - medusa_set_videostandard(dev); - break; + switch (command) { + case SET_VIDEO_STD: + dev->tvnorm = !strcmp(data_from_user->vid_stdname, "PAL") ? + V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; + medusa_set_videostandard(dev); + break; - case SET_PIXEL_FORMAT: - selected_channel = data_from_user->decoder_select; - pix_format = data_from_user->pixel_format; + case SET_PIXEL_FORMAT: + selected_channel = data_from_user->decoder_select; + pix_format = data_from_user->pixel_format; - if (!(selected_channel <= 7 && selected_channel >= 0)) { - selected_channel -= 4; - selected_channel = selected_channel % 8; - } + if (!(selected_channel <= 7 && selected_channel >= 0)) { + selected_channel -= 4; + selected_channel = selected_channel % 8; + } - if (selected_channel >= 0) - cx25821_set_pixel_format(dev, selected_channel, + if (selected_channel >= 0) + cx25821_set_pixel_format(dev, selected_channel, pix_format); break; From 2a51749fd57722db115e78399870d314dcb849bf Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:09 +0800 Subject: [PATCH 1086/1519] Staging: cx25821: Change indent with spaces to tabs 32 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 103 ++++++++++++------------ 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 2383feb9782..aa57b40c58c 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1867,69 +1867,68 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, cx25821_set_pixel_format(dev, selected_channel, pix_format); - break; + break; - case ENABLE_CIF_RESOLUTION: - selected_channel = data_from_user->decoder_select; - cif_enable = data_from_user->cif_resolution_enable; - cif_width = data_from_user->cif_width; + case ENABLE_CIF_RESOLUTION: + selected_channel = data_from_user->decoder_select; + cif_enable = data_from_user->cif_resolution_enable; + cif_width = data_from_user->cif_width; - if (cif_enable) { - if (dev->tvnorm & V4L2_STD_PAL_BG - || dev->tvnorm & V4L2_STD_PAL_DK) - width = 352; - else - width = (cif_width == 320 - || cif_width == 352) ? cif_width : 320; - } + if (cif_enable) { + if (dev->tvnorm & V4L2_STD_PAL_BG + || dev->tvnorm & V4L2_STD_PAL_DK) + width = 352; + else + width = (cif_width == 320 || cif_width == 352) ? + cif_width : 320; + } - if (!(selected_channel <= 7 && selected_channel >= 0)) { - selected_channel -= 4; - selected_channel = selected_channel % 8; - } + if (!(selected_channel <= 7 && selected_channel >= 0)) { + selected_channel -= 4; + selected_channel = selected_channel % 8; + } - if (selected_channel <= 7 && selected_channel >= 0) { - dev->channels[selected_channel]. - use_cif_resolution = cif_enable; - dev->channels[selected_channel].cif_width = width; - } else { - for (i = 0; i < VID_CHANNEL_NUM; i++) { - dev->channels[i].use_cif_resolution = - cif_enable; - dev->channels[i].cif_width = width; - } - } + if (selected_channel <= 7 && selected_channel >= 0) { + dev->channels[selected_channel]. + use_cif_resolution = cif_enable; + dev->channels[selected_channel].cif_width = width; + } else { + for (i = 0; i < VID_CHANNEL_NUM; i++) { + dev->channels[i].use_cif_resolution = + cif_enable; + dev->channels[i].cif_width = width; + } + } - medusa_set_resolution(dev, width, selected_channel); - break; - case REG_READ: - data_from_user->reg_data = cx_read(data_from_user->reg_address); - break; - case REG_WRITE: - cx_write(data_from_user->reg_address, data_from_user->reg_data); - break; - case MEDUSA_READ: - value = - cx25821_i2c_read(&dev->i2c_bus[0], - (u16) data_from_user->reg_address, - &data_from_user->reg_data); - break; - case MEDUSA_WRITE: - cx25821_i2c_write(&dev->i2c_bus[0], - (u16) data_from_user->reg_address, - data_from_user->reg_data); - break; - } + medusa_set_resolution(dev, width, selected_channel); + break; + case REG_READ: + data_from_user->reg_data = cx_read(data_from_user->reg_address); + break; + case REG_WRITE: + cx_write(data_from_user->reg_address, data_from_user->reg_data); + break; + case MEDUSA_READ: + value = cx25821_i2c_read(&dev->i2c_bus[0], + (u16) data_from_user->reg_address, + &data_from_user->reg_data); + break; + case MEDUSA_WRITE: + cx25821_i2c_write(&dev->i2c_bus[0], + (u16) data_from_user->reg_address, + data_from_user->reg_data); + break; + } - return 0; + return 0; } static long cx25821_video_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - int ret = 0; + int ret = 0; - struct cx25821_fh *fh = file->private_data; + struct cx25821_fh *fh = file->private_data; /* check to see if it's the video upstream */ if (fh->channel_id == SRAM_CH09) { From d2a167c8fc1c964d062de3b4ab6200acc3c0e404 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:10 +0800 Subject: [PATCH 1087/1519] Staging: cx25821: Change indent with spaces to tabs 33 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index aa57b40c58c..1b57d4917af 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1930,20 +1930,20 @@ static long cx25821_video_ioctl(struct file *file, struct cx25821_fh *fh = file->private_data; - /* check to see if it's the video upstream */ - if (fh->channel_id == SRAM_CH09) { - ret = video_ioctl_upstream9(file, cmd, arg); - return ret; - } else if (fh->channel_id == SRAM_CH10) { - ret = video_ioctl_upstream10(file, cmd, arg); - return ret; - } else if (fh->channel_id == SRAM_CH11) { - ret = video_ioctl_upstream11(file, cmd, arg); - ret = video_ioctl_set(file, cmd, arg); - return ret; - } + /* check to see if it's the video upstream */ + if (fh->channel_id == SRAM_CH09) { + ret = video_ioctl_upstream9(file, cmd, arg); + return ret; + } else if (fh->channel_id == SRAM_CH10) { + ret = video_ioctl_upstream10(file, cmd, arg); + return ret; + } else if (fh->channel_id == SRAM_CH11) { + ret = video_ioctl_upstream11(file, cmd, arg); + ret = video_ioctl_set(file, cmd, arg); + return ret; + } - return video_ioctl2(file, cmd, arg); + return video_ioctl2(file, cmd, arg); } /* exported stuff */ From fa7ce1f41d139f1eda7ca69ef848af933605a8cc Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:11 +0800 Subject: [PATCH 1088/1519] Staging: cx25821: Change indent with spaces to tabs 34 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 1b57d4917af..14661b92424 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1948,52 +1948,52 @@ static long cx25821_video_ioctl(struct file *file, /* exported stuff */ static const struct v4l2_file_operations video_fops = { - .owner = THIS_MODULE, - .open = video_open, - .release = video_release, - .read = video_read, - .poll = video_poll, - .mmap = cx25821_video_mmap, - .ioctl = cx25821_video_ioctl, + .owner = THIS_MODULE, + .open = video_open, + .release = video_release, + .read = video_read, + .poll = video_poll, + .mmap = cx25821_video_mmap, + .ioctl = cx25821_video_ioctl, }; static const struct v4l2_ioctl_ops video_ioctl_ops = { - .vidioc_querycap = cx25821_vidioc_querycap, - .vidioc_enum_fmt_vid_cap = cx25821_vidioc_enum_fmt_vid_cap, - .vidioc_g_fmt_vid_cap = cx25821_vidioc_g_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = cx25821_vidioc_try_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_reqbufs = cx25821_vidioc_reqbufs, - .vidioc_querybuf = cx25821_vidioc_querybuf, - .vidioc_qbuf = cx25821_vidioc_qbuf, - .vidioc_dqbuf = vidioc_dqbuf, + .vidioc_querycap = cx25821_vidioc_querycap, + .vidioc_enum_fmt_vid_cap = cx25821_vidioc_enum_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = cx25821_vidioc_g_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = cx25821_vidioc_try_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, + .vidioc_reqbufs = cx25821_vidioc_reqbufs, + .vidioc_querybuf = cx25821_vidioc_querybuf, + .vidioc_qbuf = cx25821_vidioc_qbuf, + .vidioc_dqbuf = vidioc_dqbuf, #ifdef TUNER_FLAG - .vidioc_s_std = cx25821_vidioc_s_std, - .vidioc_querystd = cx25821_vidioc_querystd, + .vidioc_s_std = cx25821_vidioc_s_std, + .vidioc_querystd = cx25821_vidioc_querystd, #endif - .vidioc_cropcap = cx25821_vidioc_cropcap, - .vidioc_s_crop = cx25821_vidioc_s_crop, - .vidioc_g_crop = cx25821_vidioc_g_crop, - .vidioc_enum_input = cx25821_vidioc_enum_input, - .vidioc_g_input = cx25821_vidioc_g_input, - .vidioc_s_input = cx25821_vidioc_s_input, - .vidioc_g_ctrl = cx25821_vidioc_g_ctrl, - .vidioc_s_ctrl = vidioc_s_ctrl, - .vidioc_queryctrl = cx25821_vidioc_queryctrl, - .vidioc_streamon = vidioc_streamon, - .vidioc_streamoff = vidioc_streamoff, - .vidioc_log_status = vidioc_log_status, - .vidioc_g_priority = cx25821_vidioc_g_priority, - .vidioc_s_priority = cx25821_vidioc_s_priority, + .vidioc_cropcap = cx25821_vidioc_cropcap, + .vidioc_s_crop = cx25821_vidioc_s_crop, + .vidioc_g_crop = cx25821_vidioc_g_crop, + .vidioc_enum_input = cx25821_vidioc_enum_input, + .vidioc_g_input = cx25821_vidioc_g_input, + .vidioc_s_input = cx25821_vidioc_s_input, + .vidioc_g_ctrl = cx25821_vidioc_g_ctrl, + .vidioc_s_ctrl = vidioc_s_ctrl, + .vidioc_queryctrl = cx25821_vidioc_queryctrl, + .vidioc_streamon = vidioc_streamon, + .vidioc_streamoff = vidioc_streamoff, + .vidioc_log_status = vidioc_log_status, + .vidioc_g_priority = cx25821_vidioc_g_priority, + .vidioc_s_priority = cx25821_vidioc_s_priority, #ifdef TUNER_FLAG - .vidioc_g_tuner = cx25821_vidioc_g_tuner, - .vidioc_s_tuner = cx25821_vidioc_s_tuner, - .vidioc_g_frequency = cx25821_vidioc_g_frequency, - .vidioc_s_frequency = cx25821_vidioc_s_frequency, + .vidioc_g_tuner = cx25821_vidioc_g_tuner, + .vidioc_s_tuner = cx25821_vidioc_s_tuner, + .vidioc_g_frequency = cx25821_vidioc_g_frequency, + .vidioc_s_frequency = cx25821_vidioc_s_frequency, #endif #ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = cx25821_vidioc_g_register, - .vidioc_s_register = cx25821_vidioc_s_register, + .vidioc_g_register = cx25821_vidioc_g_register, + .vidioc_s_register = cx25821_vidioc_s_register, #endif }; From 527db49d91763b5c0f8fe800c13f2f6a738b8249 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:12 +0800 Subject: [PATCH 1089/1519] Staging: cx25821: Change indent with spaces to tabs 35 Change indent with spaces to tabs. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 14661b92424..020db63838d 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -1998,9 +1998,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { }; struct video_device cx25821_videoioctl_template = { - .name = "cx25821-videoioctl", - .fops = &video_fops, - .ioctl_ops = &video_ioctl_ops, - .tvnorms = CX25821_NORMS, - .current_norm = V4L2_STD_NTSC_M, + .name = "cx25821-videoioctl", + .fops = &video_fops, + .ioctl_ops = &video_ioctl_ops, + .tvnorms = CX25821_NORMS, + .current_norm = V4L2_STD_NTSC_M, }; From e313e1f9832c442e7981e0f01b6778b1fa8f07f5 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:13 +0800 Subject: [PATCH 1090/1519] Staging: cx25821: Fix braces around statements in cx25821-video.c Delete braces around single statements. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 020db63838d..c54d309e11a 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -98,9 +98,8 @@ struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc) { unsigned int i; - if (fourcc == V4L2_PIX_FMT_Y41P || fourcc == V4L2_PIX_FMT_YUV411P) { + if (fourcc == V4L2_PIX_FMT_Y41P || fourcc == V4L2_PIX_FMT_YUV411P) return formats + 1; - } for (i = 0; i < ARRAY_SIZE(formats); i++) if (formats[i].fourcc == fourcc) @@ -147,9 +146,8 @@ void cx25821_video_wakeup(struct cx25821_dev *dev, struct cx25821_dmaqueue *q, /* count comes from the hw and it is 16bit wide -- * this trick handles wrap-arounds correctly for * up to 32767 buffers in flight... */ - if ((s16) (count - buf->count) < 0) { + if ((s16) (count - buf->count) < 0) break; - } do_gettimeofday(&buf->vb.ts); buf->vb.state = VIDEOBUF_DONE; From 3038f638ac27a1cb712a1021506d7ea4ab47e8f9 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:14 +0800 Subject: [PATCH 1091/1519] Staging: cx25821: Replace :? by if-else in cx25821-video.c Replace :? operator by equivalent if-else statement where in improves readability. Don't add else branch if it is not needed. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.c | 32 +++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index c54d309e11a..084fc0899e1 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c @@ -599,8 +599,8 @@ int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, if (init_buffer) { channel_opened = dev->channel_opened; - channel_opened = (channel_opened < 0 - || channel_opened > 7) ? 7 : channel_opened; + if (channel_opened < 0 || channel_opened > 7) + channel_opened = 7; if (dev->channels[channel_opened].pixel_formats == PIXEL_FRMT_411) @@ -840,8 +840,10 @@ static int video_open(struct file *file) fh->height = 480; dev->channel_opened = fh->channel_id; - pix_format = (dev->channels[ch_id].pixel_formats == PIXEL_FRMT_411) ? - V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; + if (dev->channels[ch_id].pixel_formats == PIXEL_FRMT_411) + pix_format = V4L2_PIX_FMT_Y41P; + else + pix_format = V4L2_PIX_FMT_YUYV; fh->fmt = cx25821_format_by_fourcc(pix_format); v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio); @@ -1124,8 +1126,10 @@ int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, maxh = 576; if (V4L2_FIELD_ANY == field) { - field = (f->fmt.pix.height > maxh / 2) - ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; + if (f->fmt.pix.height > maxh / 2) + field = V4L2_FIELD_INTERLACED; + else + field = V4L2_FIELD_TOP; } switch (field) { @@ -1847,8 +1851,10 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, switch (command) { case SET_VIDEO_STD: - dev->tvnorm = !strcmp(data_from_user->vid_stdname, "PAL") ? - V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; + if (!strcmp(data_from_user->vid_stdname, "PAL")) + dev->tvnorm = V4L2_STD_PAL_BG; + else + dev->tvnorm = V4L2_STD_NTSC_M; medusa_set_videostandard(dev); break; @@ -1874,11 +1880,13 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, if (cif_enable) { if (dev->tvnorm & V4L2_STD_PAL_BG - || dev->tvnorm & V4L2_STD_PAL_DK) + || dev->tvnorm & V4L2_STD_PAL_DK) { width = 352; - else - width = (cif_width == 320 || cif_width == 352) ? - cif_width : 320; + } else { + width = cif_width; + if (cif_width != 320 && cif_width != 352) + width = 320; + } } if (!(selected_channel <= 7 && selected_channel >= 0)) { From 9ad6902d2217245ec3dacc7b3e1a91ab3332d7f5 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:15 +0800 Subject: [PATCH 1092/1519] Staging: cx25821: cx25821-video.h: Line up constant Line up integer constant with others. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cx25821/cx25821-video.h b/drivers/staging/cx25821/cx25821-video.h index f4ee8051b8b..42477884fbc 100644 --- a/drivers/staging/cx25821/cx25821-video.h +++ b/drivers/staging/cx25821/cx25821-video.h @@ -63,7 +63,7 @@ do { \ #define REG_READ 900 #define REG_WRITE 901 #define MEDUSA_READ 910 -#define MEDUSA_WRITE 911 +#define MEDUSA_WRITE 911 extern struct sram_channel *channel0; extern struct sram_channel *channel1; From 64eb324424071441d047270a9cc04e9ac723d6e1 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:16 +0800 Subject: [PATCH 1093/1519] Staging: cx25821: cx25821-video.h: Fix indent Fix indent of function arguments. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.h | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.h b/drivers/staging/cx25821/cx25821-video.h index 42477884fbc..e4aa4df0d30 100644 --- a/drivers/staging/cx25821/cx25821-video.h +++ b/drivers/staging/cx25821/cx25821-video.h @@ -87,7 +87,7 @@ extern struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc); extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM]; extern void cx25821_dump_video_queue(struct cx25821_dev *dev, - struct cx25821_dmaqueue *q); + struct cx25821_dmaqueue *q); extern void cx25821_video_wakeup(struct cx25821_dev *dev, struct cx25821_dmaqueue *q, u32 count); @@ -96,11 +96,11 @@ extern int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm); #endif extern int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, - unsigned int bit); + unsigned int bit); extern int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit); extern int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit); extern void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, - unsigned int bits); + unsigned int bits); extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input); extern int cx25821_start_video_dma(struct cx25821_dev *dev, struct cx25821_dmaqueue *q, @@ -119,18 +119,18 @@ extern int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count, extern int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, enum v4l2_field field); extern void cx25821_buffer_release(struct videobuf_queue *q, - struct videobuf_buffer *vb); + struct videobuf_buffer *vb); extern struct videobuf_queue *get_queue(struct cx25821_fh *fh); extern int cx25821_get_resource(struct cx25821_fh *fh, int resource); extern int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma); extern int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f); + struct v4l2_format *f); extern int cx25821_vidioc_querycap(struct file *file, void *priv, - struct v4l2_capability *cap); + struct v4l2_capability *cap); extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_fmtdesc *f); + struct v4l2_fmtdesc *f); extern int cx25821_vidioc_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *p); + struct v4l2_requestbuffers *p); extern int cx25821_vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p); extern int cx25821_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p); @@ -141,16 +141,16 @@ extern int cx25821_vidioc_enum_input(struct file *file, void *priv, extern int cx25821_vidioc_g_input(struct file *file, void *priv, unsigned int *i); extern int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i); extern int cx25821_vidioc_g_ctrl(struct file *file, void *priv, - struct v4l2_control *ctl); + struct v4l2_control *ctl); extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f); + struct v4l2_format *f); extern int cx25821_vidioc_g_frequency(struct file *file, void *priv, - struct v4l2_frequency *f); + struct v4l2_frequency *f); extern int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f); extern int cx25821_vidioc_s_frequency(struct file *file, void *priv, - struct v4l2_frequency *f); + struct v4l2_frequency *f); extern int cx25821_vidioc_g_register(struct file *file, void *fh, - struct v4l2_dbg_register *reg); + struct v4l2_dbg_register *reg); extern int cx25821_vidioc_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg); extern int cx25821_vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t); @@ -161,10 +161,10 @@ extern int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm); extern int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p); extern int cx25821_vidioc_s_priority(struct file *file, void *f, - enum v4l2_priority prio); + enum v4l2_priority prio); extern int cx25821_vidioc_queryctrl(struct file *file, void *priv, - struct v4l2_queryctrl *qctrl); + struct v4l2_queryctrl *qctrl); extern int cx25821_set_control(struct cx25821_dev *dev, struct v4l2_control *ctrl, int chan_num); From 661d3bf652c0b8eca6f40f2e308b5a719307dd56 Mon Sep 17 00:00:00 2001 From: "Leonid V. Fedorenchik" Date: Fri, 16 Sep 2011 14:15:17 +0800 Subject: [PATCH 1094/1519] Staging: cx25821: cx25821-video.h: Fix long lines Fix long function prototypes and line up arguments nicely. Signed-off-by: Leonid V. Fedorenchik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-video.h | 45 +++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-video.h b/drivers/staging/cx25821/cx25821-video.h index e4aa4df0d30..d0d9538ca5b 100644 --- a/drivers/staging/cx25821/cx25821-video.h +++ b/drivers/staging/cx25821/cx25821-video.h @@ -115,9 +115,10 @@ extern int cx25821_video_register(struct cx25821_dev *dev); extern int cx25821_get_format_size(void); extern int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count, - unsigned int *size); -extern int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, - enum v4l2_field field); + unsigned int *size); +extern int cx25821_buffer_prepare(struct videobuf_queue *q, + struct videobuf_buffer *vb, + enum v4l2_field field); extern void cx25821_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb); extern struct videobuf_queue *get_queue(struct cx25821_fh *fh); @@ -132,14 +133,18 @@ extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, extern int cx25821_vidioc_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p); extern int cx25821_vidioc_querybuf(struct file *file, void *priv, - struct v4l2_buffer *p); -extern int cx25821_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p); -extern int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms); + struct v4l2_buffer *p); +extern int cx25821_vidioc_qbuf(struct file *file, void *priv, + struct v4l2_buffer *p); +extern int cx25821_vidioc_s_std(struct file *file, void *priv, + v4l2_std_id *tvnorms); extern int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i); extern int cx25821_vidioc_enum_input(struct file *file, void *priv, - struct v4l2_input *i); -extern int cx25821_vidioc_g_input(struct file *file, void *priv, unsigned int *i); -extern int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i); + struct v4l2_input *i); +extern int cx25821_vidioc_g_input(struct file *file, void *priv, + unsigned int *i); +extern int cx25821_vidioc_s_input(struct file *file, void *priv, + unsigned int i); extern int cx25821_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctl); extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv, @@ -152,14 +157,17 @@ extern int cx25821_vidioc_s_frequency(struct file *file, void *priv, extern int cx25821_vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg); extern int cx25821_vidioc_s_register(struct file *file, void *fh, - struct v4l2_dbg_register *reg); -extern int cx25821_vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t); -extern int cx25821_vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t); + struct v4l2_dbg_register *reg); +extern int cx25821_vidioc_g_tuner(struct file *file, void *priv, + struct v4l2_tuner *t); +extern int cx25821_vidioc_s_tuner(struct file *file, void *priv, + struct v4l2_tuner *t); extern int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm); extern int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm); -extern int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p); +extern int cx25821_vidioc_g_priority(struct file *file, void *f, + enum v4l2_priority *p); extern int cx25821_vidioc_s_priority(struct file *file, void *f, enum v4l2_priority prio); @@ -169,9 +177,12 @@ extern int cx25821_set_control(struct cx25821_dev *dev, struct v4l2_control *ctrl, int chan_num); extern int cx25821_vidioc_cropcap(struct file *file, void *fh, - struct v4l2_cropcap *cropcap); -extern int cx25821_vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop); -extern int cx25821_vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop); + struct v4l2_cropcap *cropcap); +extern int cx25821_vidioc_s_crop(struct file *file, void *priv, + struct v4l2_crop *crop); +extern int cx25821_vidioc_g_crop(struct file *file, void *priv, + struct v4l2_crop *crop); -extern int cx25821_vidioc_querystd(struct file *file, void *priv, v4l2_std_id * norm); +extern int cx25821_vidioc_querystd(struct file *file, void *priv, + v4l2_std_id *norm); #endif From c0569981b343a8cb848852a3ebd68bc07b64d873 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 16 Sep 2011 08:57:33 +0200 Subject: [PATCH 1095/1519] drivers/staging/mei/interface.c: take size of pointed value, not pointer Sizeof a pointer-typed expression returns the size of the pointer, not that of the pointed data. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression *e; type T; identifier f; @@ f(...,(T)e,..., -sizeof(e) +sizeof(*e) ,...) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mei/interface.c b/drivers/staging/mei/interface.c index cfec92dfc1c..a65dacf0021 100644 --- a/drivers/staging/mei/interface.c +++ b/drivers/staging/mei/interface.c @@ -332,7 +332,7 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) mei_hdr->reserved = 0; mei_flow_control = (struct hbm_flow_control *) &dev->wr_msg_buf[1]; - memset(mei_flow_control, 0, sizeof(mei_flow_control)); + memset(mei_flow_control, 0, sizeof(*mei_flow_control)); mei_flow_control->host_addr = cl->host_client_id; mei_flow_control->me_addr = cl->me_client_id; mei_flow_control->cmd.cmd = MEI_FLOW_CONTROL_CMD; @@ -396,7 +396,7 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) mei_cli_disconnect = (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1]; - memset(mei_cli_disconnect, 0, sizeof(mei_cli_disconnect)); + memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect)); mei_cli_disconnect->host_addr = cl->host_client_id; mei_cli_disconnect->me_addr = cl->me_client_id; mei_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD; From e61a8fd54f458118b908774817a6ba609f1bdd70 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:50 -0700 Subject: [PATCH 1096/1519] staging: brcm80211: remove SOFTAP code from fullmac Dead code removal. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 12 ----------- .../staging/brcm80211/brcmfmac/dhd_linux.c | 21 ------------------- 2 files changed, 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 88983705444..c35134904ad 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -707,18 +707,6 @@ static inline void MUTEX_UNLOCK(struct brcmf_pub *drvr) { } -static inline void MUTEX_LOCK_SOFTAP_SET_INIT(struct brcmf_pub *drvr) -{ -} - -static inline void MUTEX_LOCK_SOFTAP_SET(struct brcmf_pub *drvr) -{ -} - -static inline void MUTEX_UNLOCK_SOFTAP_SET(struct brcmf_pub *drvr) -{ -} - static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void) { } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 26a39ee894f..82868855c7f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -314,10 +314,6 @@ _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) return ret; } -#ifdef SOFTAP -static struct net_device *ap_net_dev; -#endif - /* Virtual interfaces only ((ifp && ifp->info && ifp->idx == true) */ static void brcmf_op_if(struct brcmf_if *ifp) { @@ -357,18 +353,6 @@ static void brcmf_op_if(struct brcmf_if *ifp) err); ret = -EOPNOTSUPP; } else { -#ifdef SOFTAP - /* semaphore that the soft AP CODE - waits on */ - struct semaphore ap_eth_sema; - - /* save ptr to wl0.1 netdev for use - in wl_iw.c */ - ap_net_dev = ifp->net; - /* signal to the SOFTAP 'sleeper' thread, - wl0.1 is ready */ - up(&ap_eth_sema); -#endif brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", current->pid, ifp->net->name); ifp->state = 0; @@ -395,11 +379,6 @@ static void brcmf_op_if(struct brcmf_if *ifp) drvr_priv->iflist[ifp->idx] = NULL; kfree(ifp); -#ifdef SOFTAP - if (ifp->net == ap_net_dev) - ap_net_dev = NULL; /* NULL SOFTAP global - wl0.1 as well */ -#endif /* SOFTAP */ } } From 6760e1ba63a1844560fb91e1d55260caf3fac264 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:51 -0700 Subject: [PATCH 1097/1519] staging: brcm80211: remove fullmac module_param sd_f2_blocksize Replaced the global variable with macro. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 4 ---- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 10 +++++----- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 2 -- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 26919f1d1f1..d9d1592c446 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -37,10 +37,6 @@ #define SDIOH_API_ACCESS_RETRY_LIMIT 2 -/* Module parameters specific to each host-controller driver */ - -module_param(sd_f2_blocksize, int, 0); - static void brcmf_sdioh_irqhandler(struct sdio_func *func) { struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 7cb8f3f5a96..65cd5d71bc1 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -40,7 +40,8 @@ #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 -uint sd_f2_blocksize = 512; /* Default blocksize */ +#define SDIO_FUNC1_BLOCKSIZE 64 +#define SDIO_FUNC2_BLOCKSIZE 512 /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { @@ -466,7 +467,7 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) sdiodev->num_funcs = 2; sdio_claim_host(sdiodev->func[1]); - err_ret = sdio_set_block_size(sdiodev->func[1], 64); + err_ret = sdio_set_block_size(sdiodev->func[1], SDIO_FUNC1_BLOCKSIZE); sdio_release_host(sdiodev->func[1]); if (err_ret) { brcmf_dbg(ERROR, "Failed to set F1 blocksize\n"); @@ -474,11 +475,10 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) } sdio_claim_host(sdiodev->func[2]); - err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize); + err_ret = sdio_set_block_size(sdiodev->func[2], SDIO_FUNC2_BLOCKSIZE); sdio_release_host(sdiodev->func[2]); if (err_ret) { - brcmf_dbg(ERROR, "Failed to set F2 blocksize to %d\n", - sd_f2_blocksize); + brcmf_dbg(ERROR, "Failed to set F2 blocksize\n"); goto out; } diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index c67e1c8558b..fb5f6b5402b 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -244,8 +244,6 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable); -extern uint sd_f2_blocksize; - extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, u32 regsva, struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdbrcm_disconnect(void *ptr); From 818cf60e4d90f934fb12ab4ce718a99481559696 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:52 -0700 Subject: [PATCH 1098/1519] staging: brcm80211: remove fullmac module_param brcmf_deferred_tx Remove brcmf_deferred_tx as it should be always 1 Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 81 ++++++------------- 1 file changed, 23 insertions(+), 58 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 680b23265f3..dade3ec8dd6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -721,10 +721,6 @@ static int qcount[NUMPRIO]; static int tx_packets[NUMPRIO]; #endif /* BCMDBG */ -/* Deferred transmit */ -uint brcmf_deferred_tx = 1; -module_param(brcmf_deferred_tx, uint, 0); - /* Watchdog thread priority, -1 to use kernel timer */ int brcmf_watchdog_prio = 97; module_param(brcmf_watchdog_prio, int, 0); @@ -2845,63 +2841,33 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) /* Check for existing queue, current flow-control, pending event, or pending clock */ - if (brcmf_deferred_tx || bus->fcstate || pktq_len(&bus->txq) - || bus->dpc_sched || (!data_ok(bus)) - || (bus->flowcontrol & NBITVAL(prec)) - || (bus->clkstate != CLK_AVAIL)) { - brcmf_dbg(TRACE, "deferring pktq len %d\n", - pktq_len(&bus->txq)); - bus->fcqueued++; + brcmf_dbg(TRACE, "deferring pktq len %d\n", pktq_len(&bus->txq)); + bus->fcqueued++; - /* Priority based enq */ - spin_lock_bh(&bus->txqlock); - if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == - false) { - skb_pull(pkt, SDPCM_HDRLEN); - brcmf_txcomplete(bus->drvr, pkt, false); - brcmu_pkt_buf_free_skb(pkt); - brcmf_dbg(ERROR, "out of bus->txq !!!\n"); - ret = -ENOSR; - } else { - ret = 0; - } - spin_unlock_bh(&bus->txqlock); + /* Priority based enq */ + spin_lock_bh(&bus->txqlock); + if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == false) { + skb_pull(pkt, SDPCM_HDRLEN); + brcmf_txcomplete(bus->drvr, pkt, false); + brcmu_pkt_buf_free_skb(pkt); + brcmf_dbg(ERROR, "out of bus->txq !!!\n"); + ret = -ENOSR; + } else { + ret = 0; + } + spin_unlock_bh(&bus->txqlock); - if (pktq_len(&bus->txq) >= TXHI) - brcmf_txflowcontrol(bus->drvr, 0, ON); + if (pktq_len(&bus->txq) >= TXHI) + brcmf_txflowcontrol(bus->drvr, 0, ON); #ifdef BCMDBG - if (pktq_plen(&bus->txq, prec) > qcount[prec]) - qcount[prec] = pktq_plen(&bus->txq, prec); + if (pktq_plen(&bus->txq, prec) > qcount[prec]) + qcount[prec] = pktq_plen(&bus->txq, prec); #endif - /* Schedule DPC if needed to send queued packet(s) */ - if (brcmf_deferred_tx && !bus->dpc_sched) { - bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); - } - } else { - /* Lock: we're about to use shared data/code (and SDIO) */ - brcmf_sdbrcm_sdlock(bus); - - /* Otherwise, send it now */ - bus_wake(bus); - /* Make sure back plane ht clk is on, no pending allowed */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); - - brcmf_dbg(TRACE, "calling txpkt\n"); - ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); - if (ret) - bus->drvr->tx_errors++; - else - bus->drvr->dstats.tx_bytes += datalen; - - if (bus->idletime == BRCMF_IDLE_IMMEDIATE && - !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - brcmf_sdbrcm_sdunlock(bus); + /* Schedule DPC if needed to send queued packet(s) */ + if (!bus->dpc_sched) { + bus->dpc_sched = true; + brcmf_sdbrcm_sched_dpc(bus); } return ret; @@ -5013,8 +4979,7 @@ int brcmf_bus_register(void) break; /* If both watchdog and DPC are threads, TX must be deferred */ - if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0) - && brcmf_deferred_tx) + if (brcmf_watchdog_prio >= 0 && brcmf_dpc_prio >= 0) break; brcmf_dbg(ERROR, "Invalid module parameters.\n"); From 82553d9ba35a592e3217d8e657d2e6032375fdea Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:53 -0700 Subject: [PATCH 1099/1519] staging: brcm80211: remove fullmac module_param for packet filter feature Use constant values for packet filter configuration Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 9 --------- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 13 ++++--------- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 12 ------------ 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index c35134904ad..329851ca43b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -673,15 +673,6 @@ extern uint brcmf_arp_mode; /* ARP offload enable */ extern uint brcmf_arp_enable; -/* Pkt filte enable control */ -extern uint brcmf_pkt_filter_enable; - -/* Pkt filter init setup */ -extern uint brcmf_pkt_filter_init; - -/* Pkt filter mode control */ -extern uint brcmf_master_mode; - /* Roaming mode control */ extern uint brcmf_roam; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index fd39998526a..5ae4a408f75 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -865,15 +865,10 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) brcmf_c_arp_offload_enable(drvr, brcmf_arp_enable); /* Set up pkt filter */ - if (brcmf_pkt_filter_enable) { - for (i = 0; i < drvr->pktfilter_count; i++) { - brcmf_c_pktfilter_offload_set(drvr, - drvr->pktfilter[i]); - brcmf_c_pktfilter_offload_enable(drvr, - drvr->pktfilter[i], - brcmf_pkt_filter_init, - brcmf_master_mode); - } + for (i = 0; i < drvr->pktfilter_count; i++) { + brcmf_c_pktfilter_offload_set(drvr, drvr->pktfilter[i]); + brcmf_c_pktfilter_offload_enable(drvr, drvr->pktfilter[i], + 0, true); } brcmf_os_proto_unblock(drvr); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 82868855c7f..8e729d82e16 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -98,18 +98,6 @@ module_param(brcmf_arp_mode, uint, 0); uint brcmf_arp_enable = true; module_param(brcmf_arp_enable, uint, 0); -/* Global Pkt filter enable control */ -uint brcmf_pkt_filter_enable = true; -module_param(brcmf_pkt_filter_enable, uint, 0); - -/* Pkt filter init setup */ -uint brcmf_pkt_filter_init; -module_param(brcmf_pkt_filter_init, uint, 0); - -/* Pkt filter mode control */ -uint brcmf_master_mode = true; -module_param(brcmf_master_mode, uint, 0); - /* Contorl fw roaming */ uint brcmf_roam = 1; From 24d7d5e8a8c54ddf0085cc69237e8b083f908ce2 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:54 -0700 Subject: [PATCH 1100/1519] staging: brcm80211: remove global variable brcmf_roam from fullmac Remove unnecessary global variable Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 3 --- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 3 ++- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 329851ca43b..5316df9a24b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -673,9 +673,6 @@ extern uint brcmf_arp_mode; /* ARP offload enable */ extern uint brcmf_arp_enable; -/* Roaming mode control */ -extern uint brcmf_roam; - /* Roaming mode control */ extern uint brcmf_radio_up; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 5ae4a408f75..c02c8cd4672 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -794,6 +794,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) char buf[128], *ptr; u32 dongle_align = BRCMF_SDALIGN; u32 glom = 0; + u32 roaming = 1; uint bcn_timeout = 3; int scan_assoc_time = 40; int scan_unassoc_time = 40; @@ -838,7 +839,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* Enable/Disable build-in roaming to allowed ext supplicant to take of romaing */ - brcmu_mkiovar("roam_off", (char *)&brcmf_roam, 4, + brcmu_mkiovar("roam_off", (char *)&roaming, 4, iovbuf, sizeof(iovbuf)); brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 8e729d82e16..f462a5f1a43 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -98,9 +98,6 @@ module_param(brcmf_arp_mode, uint, 0); uint brcmf_arp_enable = true; module_param(brcmf_arp_enable, uint, 0); -/* Contorl fw roaming */ -uint brcmf_roam = 1; - /* Control radio state */ uint brcmf_radio_up = 1; From bb450766c367d364b4729f39ce08cece253d7385 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:27:55 -0700 Subject: [PATCH 1101/1519] staging: brcm80211: remove global variable brcmf_radio_up from fullmac Remove unnecessary global variable Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 3 --- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 4 +--- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 3 --- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 5316df9a24b..2967ada0cb6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -673,9 +673,6 @@ extern uint brcmf_arp_mode; /* ARP offload enable */ extern uint brcmf_arp_enable; -/* Roaming mode control */ -extern uint brcmf_radio_up; - /* Override to force tx queueing all the time */ extern uint brcmf_force_tx_queueing; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index c02c8cd4672..2e8db625650 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -845,9 +845,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) sizeof(iovbuf)); /* Force STA UP */ - if (brcmf_radio_up) - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_UP, (char *)&up, - sizeof(up)); + brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up)); /* Setup event_msgs */ brcmu_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index f462a5f1a43..16f7216098f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -98,9 +98,6 @@ module_param(brcmf_arp_mode, uint, 0); uint brcmf_arp_enable = true; module_param(brcmf_arp_enable, uint, 0); -/* Control radio state */ -uint brcmf_radio_up = 1; - /* Network inteface name */ char iface_name[IFNAMSIZ] = "wlan"; module_param_string(iface_name, iface_name, IFNAMSIZ, 0); From 862c307fc1ccee9b8f67e1efe9d9b2be9fa2b42e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:27:56 -0700 Subject: [PATCH 1102/1519] staging: brcm80211: simplified brcmf_proto_ioctl() Removed a function parameter since it was redundant. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 12 ++++++------ drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 17 ++++++++--------- drivers/staging/brcm80211/brcmfmac/dhd_proto.h | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index f8731c8b9e6..0d8389eaf60 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -271,7 +271,7 @@ done: int brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, - void *buf, int len) + int len) { struct brcmf_proto *prot = drvr->prot; int ret = -1; @@ -293,7 +293,7 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, (unsigned long)prot->lastcmd); if ((ioc->cmd == BRCMF_C_SET_VAR) || (ioc->cmd == BRCMF_C_GET_VAR)) - brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)buf); + brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)ioc->buf); goto done; } @@ -302,10 +302,10 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, prot->lastcmd = ioc->cmd; if (ioc->set) ret = brcmf_proto_cdc_set_ioctl(drvr, ifidx, ioc->cmd, - buf, len); + ioc->buf, len); else { ret = brcmf_proto_cdc_query_ioctl(drvr, ifidx, ioc->cmd, - buf, len); + ioc->buf, len); if (ret > 0) ioc->used = ret - sizeof(struct brcmf_proto_cdc_ioctl); } @@ -321,12 +321,12 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, /* Intercept the wme_dp ioctl here */ if (!ret && ioc->cmd == BRCMF_C_SET_VAR && - !strcmp(buf, "wme_dp")) { + !strcmp(ioc->buf, "wme_dp")) { int slen, val = 0; slen = strlen("wme_dp") + 1; if (len >= (int)(slen + sizeof(int))) - memcpy(&val, (char *)buf + slen, sizeof(int)); + memcpy(&val, (char *)ioc->buf + slen, sizeof(int)); drvr->wme_dp = (u8) le32_to_cpu(val); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 16f7216098f..ca42883387a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -200,7 +200,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = buflen; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n", brcmf_ifname(&drvr_priv->pub, ifidx), cnt); @@ -238,7 +238,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = buflen; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", brcmf_ifname(&drvr_priv->pub, ifidx), @@ -259,7 +259,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = sizeof(allmulti); ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set promisc %d failed\n", brcmf_ifname(&drvr_priv->pub, ifidx), @@ -286,7 +286,7 @@ _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) ioc.len = 32; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", brcmf_ifname(&drvr_priv->pub, ifidx)); @@ -718,7 +718,7 @@ static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol) ioc.set = false; strcpy(buf, "toe_ol"); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { /* Check for older dongle image that doesn't support toe_ol */ if (ret == -EIO) { @@ -756,7 +756,7 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) strcpy(buf, "toe_ol"); memcpy(&buf[sizeof("toe_ol")], &toe_ol, sizeof(u32)); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n", brcmf_ifname(&drvr_priv->pub, ifidx), ret); @@ -770,7 +770,7 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) strcpy(buf, "toe"); memcpy(&buf[sizeof("toe")], &toe, sizeof(u32)); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: could not set toe: ret=%d\n", brcmf_ifname(&drvr_priv->pub, ifidx), ret); @@ -963,8 +963,7 @@ int brcmf_netdev_ioctl_priv(struct net_device *net, struct brcmf_ioctl *ioc) if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(net); - bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, - ioc, ioc->buf, buflen); + bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, ioc, buflen); done: if (bcmerror > 0) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h index 6686f4c8350..24b0f99e466 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h @@ -50,7 +50,7 @@ extern int brcmf_proto_hdrpull(struct brcmf_pub *, int *ifidx, /* Use protocol to issue ioctl to dongle */ extern int brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, - struct brcmf_ioctl *ioc, void *buf, int len); + struct brcmf_ioctl *ioc, int len); /* Update local copy of dongle statistics */ extern void brcmf_proto_dstats(struct brcmf_pub *drvr); From 90b3b115e5ace1d414390526bb06b3109cfe8963 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:27:57 -0700 Subject: [PATCH 1103/1519] staging: brcm80211: removed set_fs/get_fs/get_ds calls from brcmf_dev_ioctl() brcmf_dev_ioctl() does not provide a user space buffer to brcmf_netdev_ioctl_priv. Hence these calls are not necessary. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 1f736ead1bd..c4a8117a557 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -251,7 +251,6 @@ static s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) { struct brcmf_ioctl ioc; - mm_segment_t fs; s32 err = 0; memset(&ioc, 0, sizeof(ioc)); @@ -259,10 +258,7 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) ioc.buf = arg; ioc.len = len; - fs = get_fs(); - set_fs(get_ds()); err = brcmf_netdev_ioctl_priv(dev, &ioc); - set_fs(fs); return err; } From 66af0d7e80fb55c6811ee289e777c8a8d69ce494 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:27:58 -0700 Subject: [PATCH 1104/1519] staging: brcm80211: fixed sparse endianness warnings on fullmac scan pars Three structures that are sent to the dongle have been annotated for correct endianness: struct brcmf_iscan_params, brcmf_scan_params, brcmf_cfg80211_scan_req. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 33 +++++------ .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 59 +++++++++---------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 2967ada0cb6..e1d7c57482b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -410,24 +410,24 @@ struct brcmf_ssid_le { unsigned char SSID[32]; }; -struct brcmf_scan_params { - struct brcmf_ssid ssid; /* default: {0, ""} */ +struct brcmf_scan_params_le { + struct brcmf_ssid_le ssid_le; /* default: {0, ""} */ u8 bssid[ETH_ALEN]; /* default: bcast */ s8 bss_type; /* default: any, * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */ u8 scan_type; /* flags, 0 use default */ - s32 nprobes; /* -1 use default, number of probes per channel */ - s32 active_time; /* -1 use default, dwell time per channel for + __le32 nprobes; /* -1 use default, number of probes per channel */ + __le32 active_time; /* -1 use default, dwell time per channel for * active scanning */ - s32 passive_time; /* -1 use default, dwell time per channel + __le32 passive_time; /* -1 use default, dwell time per channel * for passive scanning */ - s32 home_time; /* -1 use default, dwell time for the home channel - * between channel scans + __le32 home_time; /* -1 use default, dwell time for the + * home channel between channel scans */ - s32 channel_num; /* count of channels and ssids that follow + __le32 channel_num; /* count of channels and ssids that follow * * low half is count of channels in * channel_list, 0 means default (use all @@ -443,22 +443,17 @@ struct brcmf_scan_params { * fixed parameter portion is assumed, otherwise * ssid in the fixed portion is ignored */ - u16 channel_list[1]; /* list of chanspecs */ + __le16 channel_list[1]; /* list of chanspecs */ }; /* incremental scan struct */ -struct brcmf_iscan_params { - u32 version; - u16 action; - u16 scan_duration; - struct brcmf_scan_params params; +struct brcmf_iscan_params_le { + __le32 version; + __le16 action; + __le16 scan_duration; + struct brcmf_scan_params_le params_le; }; -/* 3 fields + size of brcmf_scan_params, not including variable length array */ -#define BRCMF_ISCAN_PARAMS_FIXED_SIZE \ - (offsetof(struct brcmf_iscan_params, params) + \ - sizeof(struct brcmf_ssid)) - struct brcmf_scan_results { u32 buflen; u32 version; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index c4a8117a557..2dced70ac2f 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -359,9 +359,10 @@ static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) s8 buf[BRCMF_C_IOCTL_SMLEN]; u32 len; s32 err = 0; + __le32 val_le; - val = cpu_to_le32(val); - len = brcmu_mkiovar(name, (char *)(&val), sizeof(val), buf, + val_le = cpu_to_le32(val); + len = brcmu_mkiovar(name, (char *)(&val_le), sizeof(val_le), buf, sizeof(buf)); BUG_ON(!len); @@ -411,25 +412,19 @@ static void brcmf_set_mpc(struct net_device *ndev, int mpc) } } -static void wl_iscan_prep(struct brcmf_scan_params *params, +static void wl_iscan_prep(struct brcmf_scan_params_le *params_le, struct brcmf_ssid *ssid) { - memcpy(params->bssid, ether_bcast, ETH_ALEN); - params->bss_type = DOT11_BSSTYPE_ANY; - params->scan_type = 0; - params->nprobes = -1; - params->active_time = -1; - params->passive_time = -1; - params->home_time = -1; - params->channel_num = 0; - - params->nprobes = cpu_to_le32(params->nprobes); - params->active_time = cpu_to_le32(params->active_time); - params->passive_time = cpu_to_le32(params->passive_time); - params->home_time = cpu_to_le32(params->home_time); + memcpy(params_le->bssid, ether_bcast, ETH_ALEN); + params_le->bss_type = DOT11_BSSTYPE_ANY; + params_le->scan_type = 0; + params_le->channel_num = 0; + params_le->nprobes = cpu_to_le32(-1); + params_le->active_time = cpu_to_le32(-1); + params_le->passive_time = cpu_to_le32(-1); + params_le->home_time = cpu_to_le32(-1); if (ssid && ssid->SSID_len) - memcpy(¶ms->ssid, ssid, sizeof(struct brcmf_ssid)); - + memcpy(¶ms_le->ssid_le, ssid, sizeof(struct brcmf_ssid)); } static s32 @@ -460,9 +455,9 @@ static s32 brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, struct brcmf_ssid *ssid, u16 action) { - s32 params_size = (BRCMF_SCAN_PARAMS_FIXED_SIZE + - offsetof(struct brcmf_iscan_params, params)); - struct brcmf_iscan_params *params; + s32 params_size = BRCMF_SCAN_PARAMS_FIXED_SIZE + + offsetof(struct brcmf_iscan_params_le, params_le); + struct brcmf_iscan_params_le *params; s32 err = 0; if (ssid && ssid->SSID_len) @@ -472,13 +467,12 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, return -ENOMEM; BUG_ON(params_size >= BRCMF_C_IOCTL_SMLEN); - wl_iscan_prep(¶ms->params, ssid); + wl_iscan_prep(¶ms->params_le, ssid); params->version = cpu_to_le32(BRCMF_ISCAN_REQ_VERSION); params->action = cpu_to_le16(action); params->scan_duration = cpu_to_le16(0); - /* params_size += offsetof(struct brcmf_iscan_params, params); */ err = brcmf_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size, iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); if (unlikely(err)) { @@ -537,6 +531,7 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, bool iscan_req; bool spec_scan; s32 err = 0; + u32 SSID_len; if (unlikely(test_bit(WL_STATUS_SCANNING, &cfg_priv->status))) { WL_ERR("Scanning already : status (%lu)\n", cfg_priv->status); @@ -577,12 +572,12 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, } else { WL_SCAN("ssid \"%s\", ssid_len (%d)\n", ssids->ssid, ssids->ssid_len); - memset(&sr->ssid, 0, sizeof(sr->ssid)); - sr->ssid.SSID_len = - min_t(u8, sizeof(sr->ssid.SSID), ssids->ssid_len); - if (sr->ssid.SSID_len) { - memcpy(sr->ssid.SSID, ssids->ssid, sr->ssid.SSID_len); - sr->ssid.SSID_len = cpu_to_le32(sr->ssid.SSID_len); + memset(&sr->ssid_le, 0, sizeof(sr->ssid_le)); + SSID_len = min_t(u8, sizeof(sr->ssid_le.SSID), ssids->ssid_len); + sr->ssid_le.SSID_len = cpu_to_le32(0); + if (SSID_len) { + memcpy(sr->ssid_le.SSID, ssids->ssid, SSID_len); + sr->ssid_le.SSID_len = cpu_to_le32(SSID_len); spec_scan = true; } else { WL_SCAN("Broadcast scan\n"); @@ -596,12 +591,12 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, goto scan_out; } brcmf_set_mpc(ndev, 0); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN, &sr->ssid, - sizeof(sr->ssid)); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN, &sr->ssid_le, + sizeof(sr->ssid_le)); if (err) { if (err == -EBUSY) WL_INFO("system busy : scan for \"%s\" " - "canceled\n", sr->ssid.SSID); + "canceled\n", sr->ssid_le.SSID); else WL_ERR("WLC_SCAN error (%d)\n", err); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index db71762f497..7a8c671cb9b 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -188,7 +188,7 @@ struct brcmf_cfg80211_dev { /* basic structure of scan request */ struct brcmf_cfg80211_scan_req { - struct brcmf_ssid ssid; + struct brcmf_ssid_le ssid_le; }; /* basic structure of information element */ From c57d25025ddbcd41eb37044f82446dbda538e23b Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:27:59 -0700 Subject: [PATCH 1105/1519] staging: brcm80211: fixed sparse endianness warnings on fullmac assoc pars Structures that are sent to the dongle have been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 10 +-- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 63 +++++++++---------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index e1d7c57482b..c34cc7b315a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -462,20 +462,20 @@ struct brcmf_scan_results { }; /* used for association with a specific BSSID and chanspec list */ -struct brcmf_assoc_params { +struct brcmf_assoc_params_le { /* 00:00:00:00:00:00: broadcast scan */ u8 bssid[ETH_ALEN]; /* 0: all available channels, otherwise count of chanspecs in * chanspec_list */ - s32 chanspec_num; + __le32 chanspec_num; /* list of chanspecs */ - u16 chanspec_list[1]; + __le16 chanspec_list[1]; }; /* used for join with or without a specific bssid and channel list */ struct brcmf_join_params { - struct brcmf_ssid ssid; - struct brcmf_assoc_params params; + struct brcmf_ssid_le ssid_le; + struct brcmf_assoc_params_le params_le; }; /* size of brcmf_scan_results not including variable length array */ diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 2dced70ac2f..67955d3d59d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -34,7 +34,7 @@ #include "wl_cfg80211.h" #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ - (sizeof(struct brcmf_assoc_params) - sizeof(u16)) + (sizeof(struct brcmf_assoc_params_le) - sizeof(u16)) static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; @@ -777,10 +777,7 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, u16 chanspec = 0; if (ch != 0) { - join_params->params.chanspec_num = 1; - join_params->params.chanspec_list[0] = ch; - - if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL) + if (ch <= CH_MAX_2G_CHANNEL) chanspec |= WL_CHANSPEC_BAND_2G; else chanspec |= WL_CHANSPEC_BAND_5G; @@ -789,19 +786,15 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, chanspec |= WL_CHANSPEC_CTL_SB_NONE; *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + - join_params->params.chanspec_num * sizeof(u16); + sizeof(u16); - join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK; - join_params->params.chanspec_list[0] |= chanspec; - join_params->params.chanspec_list[0] = - cpu_to_le16(join_params->params.chanspec_list[0]); - - join_params->params.chanspec_num = - cpu_to_le32(join_params->params.chanspec_num); + chanspec |= (ch & WL_CHANSPEC_CHAN_MASK); + join_params->params_le.chanspec_list[0] = cpu_to_le16(chanspec); + join_params->params_le.chanspec_num = cpu_to_le32(1); WL_CONN("join_params->params.chanspec_list[0]= %#X," "channel %d, chanspec %#X\n", - join_params->params.chanspec_list[0], ch, chanspec); + chanspec, ch, chanspec); } } @@ -833,6 +826,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, s32 err = 0; s32 wsec = 0; s32 bcnprd; + struct brcmf_ssid ssid; WL_TRACE("Enter\n"); if (!check_sys_up(wiphy)) @@ -910,24 +904,24 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, memset(&join_params, 0, sizeof(struct brcmf_join_params)); /* SSID */ - join_params.ssid.SSID_len = - (params->ssid_len > 32) ? 32 : params->ssid_len; - memcpy(join_params.ssid.SSID, params->ssid, join_params.ssid.SSID_len); - join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); - join_params_size = sizeof(join_params.ssid); - brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); + ssid.SSID_len = min_t(u32, params->ssid_len, 32); + memcpy(ssid.SSID, params->ssid, ssid.SSID_len); + memcpy(join_params.ssid_le.SSID, params->ssid, ssid.SSID_len); + join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); + join_params_size = sizeof(join_params.ssid_le); + brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); /* BSSID */ if (params->bssid) { - memcpy(join_params.params.bssid, params->bssid, ETH_ALEN); - join_params_size = sizeof(join_params.ssid) + - BRCMF_ASSOC_PARAMS_FIXED_SIZE; + memcpy(join_params.params_le.bssid, params->bssid, ETH_ALEN); + join_params_size = sizeof(join_params.ssid_le) + + BRCMF_ASSOC_PARAMS_FIXED_SIZE; } else { - memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); + memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); } brcmf_update_prof(cfg_priv, NULL, - &join_params.params.bssid, WL_PROF_BSSID); + &join_params.params_le.bssid, WL_PROF_BSSID); /* Channel */ if (params->channel) { @@ -1244,6 +1238,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan = sme->channel; struct brcmf_join_params join_params; size_t join_params_size; + struct brcmf_ssid ssid; s32 err = 0; @@ -1299,19 +1294,19 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } memset(&join_params, 0, sizeof(join_params)); - join_params_size = sizeof(join_params.ssid); + join_params_size = sizeof(join_params.ssid_le); - join_params.ssid.SSID_len = - min(sizeof(join_params.ssid.SSID), sme->ssid_len); - memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len); - join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); - brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); + ssid.SSID_len = min_t(u32, sizeof(ssid.SSID), sme->ssid_len); + memcpy(&join_params.ssid_le.SSID, sme->ssid, ssid.SSID_len); + memcpy(&ssid.SSID, sme->ssid, ssid.SSID_len); + join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); + brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); - memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); + memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); - if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) + if (ssid.SSID_len < IEEE80211_MAX_SSID_LEN) WL_CONN("ssid \"%s\", len (%d)\n", - join_params.ssid.SSID, join_params.ssid.SSID_len); + ssid.SSID, ssid.SSID_len); brcmf_ch_to_chanspec(cfg_priv->channel, &join_params, &join_params_size); From 7d852d16deab9757cbb7b78617dd879e46c7547e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:28:00 -0700 Subject: [PATCH 1106/1519] staging: brcm80211: fixed sparse endianness warnings on fullmac scb pars Structure that is sent to the dongle has been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 4 ++-- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index c34cc7b315a..af0ad1fba36 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -535,8 +535,8 @@ struct brcmf_wsec_key_le { }; /* Used to get specific STA parameters */ -struct brcmf_scb_val { - u32 val; +struct brcmf_scb_val_le { + __le32 val; u8 ea[ETH_ALEN]; }; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 67955d3d59d..3b0c1a38192 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1327,7 +1327,7 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_scb_val scbval; + struct brcmf_scb_val_le scbval; s32 err = 0; WL_TRACE("Enter. Reason code = %d\n", reason_code); @@ -1336,11 +1336,10 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, clear_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - scbval.val = reason_code; memcpy(&scbval.ea, brcmf_read_prof(cfg_priv, WL_PROF_BSSID), ETH_ALEN); - scbval.val = cpu_to_le32(scbval.val); + scbval.val = cpu_to_le32(reason_code); err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, &scbval, - sizeof(struct brcmf_scb_val)); + sizeof(struct brcmf_scb_val_le)); if (unlikely(err)) WL_ERR("error (%d)\n", err); @@ -1771,7 +1770,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, u8 *mac, struct station_info *sinfo) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_scb_val scb_val; + struct brcmf_scb_val_le scb_val; int rssi; s32 rate; s32 err = 0; @@ -1803,9 +1802,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, } if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { - scb_val.val = 0; + scb_val.val = cpu_to_le32(0); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_RSSI, &scb_val, - sizeof(struct brcmf_scb_val)); + sizeof(struct brcmf_scb_val_le)); if (unlikely(err)) WL_ERR("Could not get rssi (%d)\n", err); From c17f70da1af199f5b0fe49439f8f8020239a2733 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:28:01 -0700 Subject: [PATCH 1107/1519] staging: brcm80211: fixed sparse endianness warnings on fullmac ratespec Structure that is sent to the dongle has been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 7 +++++++ drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 12 +++++------- drivers/staging/brcm80211/brcmsmac/pub.h | 7 +++++++ drivers/staging/brcm80211/include/defs.h | 7 ------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index af0ad1fba36..e543640f962 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -400,6 +400,13 @@ struct brcmf_bss_info { /* variable length Information Elements */ }; +struct brcm_rateset_le { + /* # rates in this set */ + __le32 count; + /* rates in 500kbps units w/hi bit set if basic */ + u8 rates[WL_NUMRATES]; +}; + struct brcmf_ssid { u32 SSID_len; unsigned char SSID[32]; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 3b0c1a38192..6ac4cc71828 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1864,7 +1864,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, const u8 *addr, const struct cfg80211_bitrate_mask *mask) { - struct brcm_rateset rateset; + struct brcm_rateset_le rateset_le; s32 rate; s32 val; s32 err_bg; @@ -1878,15 +1878,13 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, /* addr param is always NULL. ignore it */ /* Get current rateset */ - err = brcmf_dev_ioctl(dev, BRCM_GET_CURR_RATESET, &rateset, - sizeof(rateset)); + err = brcmf_dev_ioctl(dev, BRCM_GET_CURR_RATESET, &rateset_le, + sizeof(rateset_le)); if (unlikely(err)) { WL_ERR("could not get current rateset (%d)\n", err); goto done; } - rateset.count = le32_to_cpu(rateset.count); - legacy = ffs(mask->control[IEEE80211_BAND_2GHZ].legacy & 0xFFFF); if (!legacy) legacy = ffs(mask->control[IEEE80211_BAND_5GHZ].legacy & @@ -1894,9 +1892,9 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, val = wl_g_rates[legacy - 1].bitrate * 100000; - if (val < rateset.count) + if (val < le32_to_cpu(rateset_le.count)) /* Select rate by rateset index */ - rate = rateset.rates[val] & 0x7f; + rate = rateset_le.rates[val] & 0x7f; else /* Specified rate in bps */ rate = val / 500000; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index c72f7b581b9..96703099ef9 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -101,6 +101,13 @@ #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ +struct brcm_rateset { + /* # rates in this set */ + u32 count; + /* rates in 500kbps units w/hi bit set if basic */ + u8 rates[WL_NUMRATES]; +}; + struct brcms_c_rateset { uint count; /* number of rates in rates[] */ /* rates in 500kbps units w/hi bit set if basic */ diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h index 3438c544eb1..1e5f310af1e 100644 --- a/drivers/staging/brcm80211/include/defs.h +++ b/drivers/staging/brcm80211/include/defs.h @@ -48,13 +48,6 @@ #define WL_NUMRATES 16 /* max # of rates in a rateset */ -struct brcm_rateset { - /* # rates in this set */ - u32 count; - /* rates in 500kbps units w/hi bit set if basic */ - u8 rates[WL_NUMRATES]; -}; - #define BRCM_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NUL */ #define BRCM_SET_CHANNEL 30 From 8e118503b74da4fdabd3999614df5fbef7c99b71 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:28:02 -0700 Subject: [PATCH 1108/1519] staging: brcm80211: remove _brcmf_sysioc_thread in fullmac _brcmf_sysioc_thread is handling deferred jobs from 4 callers. Use work queue to handle set_mac_address/set_multicast_list requests. brcmf_add_if/brcmf_del_if never run in atomic context and can call brcmf_op_if directly. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 159 +++++------------- 1 file changed, 39 insertions(+), 120 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index ca42883387a..3b2d500ced8 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -73,11 +73,8 @@ struct brcmf_info { struct mutex proto_block; - /* Thread to issue ioctl for multicast */ - struct task_struct *sysioc_tsk; - wait_queue_head_t sysioc_waitq; - bool set_multicast; - bool set_macaddress; + struct work_struct setmacaddr_work; + struct work_struct multicast_work; u8 macvalue[ETH_ALEN]; atomic_t pend_8021x_cnt; }; @@ -85,10 +82,6 @@ struct brcmf_info { /* Error bits */ module_param(brcmf_msg_level, int, 0); -/* Spawn a thread for system ioctls (set mac, set mcast) */ -uint brcmf_sysioc = true; -module_param(brcmf_sysioc, uint, 0); - /* ARP offload agent mode : Enable ARP Host Auto-Reply and ARP Peer Auto-Reply */ uint brcmf_arp_mode = 0xb; @@ -152,7 +145,7 @@ char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx) return ""; } -static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) +static void _brcmf_set_multicast_list(struct work_struct *work) { struct net_device *dev; struct netdev_hw_addr *ha; @@ -163,7 +156,10 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) uint buflen; int ret; - dev = drvr_priv->iflist[ifidx]->net; + struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, + multicast_work); + + dev = drvr_priv->iflist[0]->net; cnt = netdev_mc_count(dev); /* Determine initial value of allmulti flag */ @@ -175,7 +171,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) bufp = buf = kmalloc(buflen, GFP_ATOMIC); if (!bufp) { brcmf_dbg(ERROR, "%s: out of memory for mcast_list, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), cnt); + brcmf_ifname(&drvr_priv->pub, 0), cnt); return; } @@ -200,10 +196,10 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = buflen; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), cnt); + brcmf_ifname(&drvr_priv->pub, 0), cnt); allmulti = cnt ? true : allmulti; } @@ -218,7 +214,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) buf = kmalloc(buflen, GFP_ATOMIC); if (!buf) { brcmf_dbg(ERROR, "%s: out of memory for allmulti\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); + brcmf_ifname(&drvr_priv->pub, 0)); return; } allmulti = cpu_to_le32(allmulti); @@ -226,7 +222,7 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) if (!brcmu_mkiovar ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) { brcmf_dbg(ERROR, "%s: mkiovar failed for allmulti, datalen %d buflen %u\n", - brcmf_ifname(&drvr_priv->pub, ifidx), + brcmf_ifname(&drvr_priv->pub, 0), (int)sizeof(allmulti), buflen); kfree(buf); return; @@ -238,10 +234,10 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = buflen; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx), + brcmf_ifname(&drvr_priv->pub, 0), le32_to_cpu(allmulti)); } @@ -259,26 +255,30 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx) ioc.len = sizeof(allmulti); ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set promisc %d failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx), + brcmf_ifname(&drvr_priv->pub, 0), le32_to_cpu(allmulti)); } } -static int -_brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) +static void +_brcmf_set_mac_address(struct work_struct *work) { char buf[32]; struct brcmf_ioctl ioc; int ret; + struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, + setmacaddr_work); + brcmf_dbg(TRACE, "enter\n"); - if (!brcmu_mkiovar("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) { + if (!brcmu_mkiovar("cur_etheraddr", (char *)drvr_priv->macvalue, + ETH_ALEN, buf, 32)) { brcmf_dbg(ERROR, "%s: mkiovar failed for cur_etheraddr\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); - return -1; + brcmf_ifname(&drvr_priv->pub, 0)); + return; } memset(&ioc, 0, sizeof(ioc)); ioc.cmd = BRCMF_C_SET_VAR; @@ -286,14 +286,15 @@ _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *addr) ioc.len = 32; ioc.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); if (ret < 0) brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); + brcmf_ifname(&drvr_priv->pub, 0)); else - memcpy(drvr_priv->iflist[ifidx]->net->dev_addr, addr, ETH_ALEN); + memcpy(drvr_priv->iflist[0]->net->dev_addr, + drvr_priv->macvalue, ETH_ALEN); - return ret; + return; } /* Virtual interfaces only ((ifp && ifp->info && ifp->idx == true) */ @@ -364,76 +365,8 @@ static void brcmf_op_if(struct brcmf_if *ifp) } } -static int _brcmf_sysioc_thread(void *data) -{ - struct brcmf_info *drvr_priv = (struct brcmf_info *) data; - int i; -#ifdef SOFTAP - bool in_ap = false; -#endif - DECLARE_WAITQUEUE(wait, current); - allow_signal(SIGTERM); - - add_wait_queue(&drvr_priv->sysioc_waitq, &wait); - while (1) { - prepare_to_wait(&drvr_priv->sysioc_waitq, &wait, - TASK_INTERRUPTIBLE); - - /* wait for event */ - schedule(); - - if (kthread_should_stop()) - break; - - for (i = 0; i < BRCMF_MAX_IFS; i++) { - struct brcmf_if *ifentry = drvr_priv->iflist[i]; - if (ifentry) { -#ifdef SOFTAP - in_ap = (ap_net_dev != NULL); -#endif /* SOFTAP */ - if (ifentry->state) - brcmf_op_if(ifentry); -#ifdef SOFTAP - if (drvr_priv->iflist[i] == NULL) { - brcmf_dbg(TRACE, "interface %d removed!\n", - i); - continue; - } - - if (in_ap && drvr_priv->set_macaddress) { - brcmf_dbg(TRACE, "attempt to set MAC for %s in AP Mode, blocked.\n", - ifentry->net->name); - drvr_priv->set_macaddress = false; - continue; - } - - if (in_ap && drvr_priv->set_multicast) { - brcmf_dbg(TRACE, "attempt to set MULTICAST list for %s in AP Mode, blocked.\n", - ifentry->net->name); - drvr_priv->set_multicast = false; - continue; - } -#endif /* SOFTAP */ - if (drvr_priv->set_multicast) { - drvr_priv->set_multicast = false; - _brcmf_set_multicast_list(drvr_priv, i); - } - if (drvr_priv->set_macaddress) { - drvr_priv->set_macaddress = false; - _brcmf_set_mac_address(drvr_priv, i, - drvr_priv->macvalue); - } - } - } - } - finish_wait(&drvr_priv->sysioc_waitq, &wait); - return 0; -} - static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) { - int ret = 0; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(dev); struct sockaddr *sa = (struct sockaddr *)addr; int ifidx; @@ -443,9 +376,8 @@ static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) return -1; memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); - drvr_priv->set_macaddress = true; - wake_up(&drvr_priv->sysioc_waitq); - return ret; + schedule_work(&drvr_priv->setmacaddr_work); + return 0; } static void brcmf_netdev_set_multicast_list(struct net_device *dev) @@ -457,8 +389,7 @@ static void brcmf_netdev_set_multicast_list(struct net_device *dev) if (ifidx == BRCMF_BAD_IF) return; - drvr_priv->set_multicast = true; - wake_up(&drvr_priv->sysioc_waitq); + schedule_work(&drvr_priv->multicast_work); } int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) @@ -1056,7 +987,7 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, if (net == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; - wake_up(&drvr_priv->sysioc_waitq); + brcmf_op_if(ifp); } else ifp->net = net; @@ -1077,7 +1008,7 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) ifp->state = BRCMF_E_IF_DEL; ifp->idx = ifidx; - wake_up(&drvr_priv->sysioc_waitq); + brcmf_op_if(ifp); } struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) @@ -1148,17 +1079,8 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) goto fail; } - if (brcmf_sysioc) { - init_waitqueue_head(&drvr_priv->sysioc_waitq); - drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, - drvr_priv, "_brcmf_sysioc"); - if (IS_ERR(drvr_priv->sysioc_tsk)) { - printk(KERN_WARNING - "_brcmf_sysioc thread failed to start\n"); - drvr_priv->sysioc_tsk = NULL; - } - } else - drvr_priv->sysioc_tsk = NULL; + INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); + INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); /* * Save the brcmf_info into the priv @@ -1337,11 +1259,8 @@ void brcmf_detach(struct brcmf_pub *drvr) unregister_netdev(ifp->net); } - if (drvr_priv->sysioc_tsk) { - send_sig(SIGTERM, drvr_priv->sysioc_tsk, 1); - kthread_stop(drvr_priv->sysioc_tsk); - drvr_priv->sysioc_tsk = NULL; - } + cancel_work_sync(&drvr_priv->setmacaddr_work); + cancel_work_sync(&drvr_priv->multicast_work); brcmf_bus_detach(drvr); From 5a8dc2ef78b790854bf67fb688a84e293f70deba Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 16 Sep 2011 12:28:03 -0700 Subject: [PATCH 1109/1519] staging: brcm80211: remove fullmac module_param for ARP offload feature Use macro to replace global variable for ARP offload configuration Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 10 ---------- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 6 +++--- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 9 --------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index e543640f962..de3f914d7a4 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -665,16 +665,6 @@ struct bcmevent_name { const char *name; }; -/* - * Insmod parameters for debug/test - */ - -/* ARP offload agent mode */ -extern uint brcmf_arp_mode; - -/* ARP offload enable */ -extern uint brcmf_arp_enable; - /* Override to force tx queueing all the time */ extern uint brcmf_force_tx_queueing; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 2e8db625650..02c022ab9ff 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -30,6 +30,7 @@ #define DOT11_OUI_LEN 3 #define BCMILCP_BCM_SUBTYPE_EVENT 1 #define PKTFILTER_BUF_SIZE 2048 +#define BRCMF_ARPOL_MODE 0xb /* agent|snoop|peer_autoreply */ int brcmf_msg_level; @@ -859,9 +860,8 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); /* Set and enable ARP offload feature */ - if (brcmf_arp_enable) - brcmf_c_arp_offload_set(drvr, brcmf_arp_mode); - brcmf_c_arp_offload_enable(drvr, brcmf_arp_enable); + brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE); + brcmf_c_arp_offload_enable(drvr, true); /* Set up pkt filter */ for (i = 0; i < drvr->pktfilter_count; i++) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 3b2d500ced8..643c9c20ea9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -82,15 +82,6 @@ struct brcmf_info { /* Error bits */ module_param(brcmf_msg_level, int, 0); -/* ARP offload agent mode : Enable ARP Host Auto-Reply -and ARP Peer Auto-Reply */ -uint brcmf_arp_mode = 0xb; -module_param(brcmf_arp_mode, uint, 0); - -/* ARP offload enable */ -uint brcmf_arp_enable = true; -module_param(brcmf_arp_enable, uint, 0); - /* Network inteface name */ char iface_name[IFNAMSIZ] = "wlan"; module_param_string(iface_name, iface_name, IFNAMSIZ, 0); From 66b9aa024583d31684f184d804d6d55b00392f31 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 16 Sep 2011 12:28:04 -0700 Subject: [PATCH 1110/1519] staging: brcm80211: remove brcmfmac interface name override The brcmfmac had a module parameter which could be used to override the name of the wireless net device name and it defaults to 'wlan'. This is considered rather useless, because what is in a name. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 643c9c20ea9..9919fa5861a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -82,9 +82,6 @@ struct brcmf_info { /* Error bits */ module_param(brcmf_msg_level, int, 0); -/* Network inteface name */ -char iface_name[IFNAMSIZ] = "wlan"; -module_param_string(iface_name, iface_name, IFNAMSIZ, 0); static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net) { @@ -311,10 +308,11 @@ static void brcmf_op_if(struct brcmf_if *ifp) unregister_netdev(ifp->net); free_netdev(ifp->net); } - /* Allocate etherdev, including space for private structure */ - ifp->net = alloc_etherdev(sizeof(drvr_priv)); + /* Allocate netdev, including space for private structure */ + ifp->net = alloc_netdev(sizeof(drvr_priv), "wlan%d", + ether_setup); if (!ifp->net) { - brcmf_dbg(ERROR, "OOM - alloc_etherdev\n"); + brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); ret = -ENOMEM; } if (ret == 0) { @@ -1009,10 +1007,10 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) brcmf_dbg(TRACE, "Enter\n"); - /* Allocate etherdev, including space for private structure */ - net = alloc_etherdev(sizeof(drvr_priv)); + /* Allocate netdev, including space for private structure */ + net = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); if (!net) { - brcmf_dbg(ERROR, "OOM - alloc_etherdev\n"); + brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); goto fail; } @@ -1028,18 +1026,6 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) */ memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv)); - /* Set network interface name if it was provided as module parameter */ - if (iface_name[0]) { - int len; - char ch; - strncpy(net->name, iface_name, IFNAMSIZ); - net->name[IFNAMSIZ - 1] = 0; - len = strlen(net->name); - ch = net->name[len - 1]; - if ((ch > '9' || ch < '0') && (len < IFNAMSIZ - 2)) - strcat(net->name, "%d"); - } - if (brcmf_add_if(drvr_priv, 0, net, net->name, NULL, 0, 0) == BRCMF_BAD_IF) goto fail; From 0569c8e2d6f545b05cbb7a6193ab977a6f9bbc19 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 16 Sep 2011 12:28:05 -0700 Subject: [PATCH 1111/1519] staging: brcm80211: remove for_each_bss() macro from brcmfmac driver The macro was only used once in the code and has been removed for clarity reading the code. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 4 ++-- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 6ac4cc71828..4f3e8b8d589 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1993,8 +1993,8 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) return -EOPNOTSUPP; } WL_SCAN("scanned AP count (%d)\n", bss_list->count); - bi = next_bss(bss_list, bi); - for_each_bss(bss_list, bi, i) { + for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { + bi = next_bss(bss_list, bi); err = brcmf_inform_single_bss(cfg_priv, bi); if (unlikely(err)) break; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 7a8c671cb9b..d27d4e6f943 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -362,10 +362,6 @@ static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, list->bss_info; } -#define for_each_bss(list, bss, __i) \ - for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, \ - bss = next_bss(list, bss)) - extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, struct device *busdev, void *data); From 22a911976ff0ba4a52b7491af2bc5c7f7b8c7a0e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 16 Sep 2011 12:28:06 -0700 Subject: [PATCH 1112/1519] staging: brcm80211: remove global variable from bcmsdh_sdmmc.c The source file contained some static global variables that were needed per device handled by the driver. They have moved to the struct brcmf_sdio_dev for that reason. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 21 +++++++++---------- .../staging/brcm80211/brcmfmac/sdio_host.h | 5 +++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 65cd5d71bc1..443e3a8ce2e 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -50,11 +50,6 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = { }; MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); -static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait); -static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait); -static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait); -static DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait); - static bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) { @@ -66,12 +61,12 @@ brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) } static void -brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t wq) +brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t *wq) { #ifdef CONFIG_PM_SLEEP int retry = 0; while (atomic_read(&sdiodev->suspend) && retry++ != 30) - wait_event_timeout(wq, false, HZ/100); + wait_event_timeout(*wq, false, HZ/100); #endif } @@ -82,7 +77,7 @@ int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); - brcmf_pm_resume_wait(sdiodev, sdioh_request_byte_wait); + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_byte_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; if (rw) { /* CMD52 Write */ @@ -185,7 +180,7 @@ int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", rw, func, addr, nbytes); - brcmf_pm_resume_wait(sdiodev, sdioh_request_word_wait); + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_word_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; /* Claim host controller */ @@ -235,7 +230,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, brcmf_dbg(TRACE, "Enter\n"); - brcmf_pm_resume_wait(sdiodev, sdioh_request_packet_wait); + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_packet_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; @@ -312,7 +307,7 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, brcmf_dbg(TRACE, "Enter\n"); - brcmf_pm_resume_wait(sdiodev, sdioh_request_buffer_wait); + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; /* Case 1: we don't have a packet. */ @@ -529,6 +524,10 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, dev_set_drvdata(&func->card->dev, sdiodev); atomic_set(&sdiodev->suspend, false); + init_waitqueue_head(&sdiodev->request_byte_wait); + init_waitqueue_head(&sdiodev->request_word_wait); + init_waitqueue_head(&sdiodev->request_packet_wait); + init_waitqueue_head(&sdiodev->request_buffer_wait); } if (func->num == 2) { diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index fb5f6b5402b..397ad48803d 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -130,6 +130,11 @@ struct brcmf_sdio_dev { bool regfail; /* status of last reg_r/w call */ void *bus; atomic_t suspend; /* suspend flag */ + wait_queue_head_t request_byte_wait; + wait_queue_head_t request_word_wait; + wait_queue_head_t request_packet_wait; + wait_queue_head_t request_buffer_wait; + }; /* Register/deregister device interrupt handler. */ From 7dae3a638c9cc2b03161454fd0fda3acbf2462e0 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 16 Sep 2011 12:28:07 -0700 Subject: [PATCH 1113/1519] staging: brcm80211: remove static global variables from dhd_sdio.c Several global variables that were set but never initialized have been removed. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 161 ++++++++---------- 1 file changed, 67 insertions(+), 94 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index dade3ec8dd6..720f567bf6c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -761,26 +761,18 @@ module_param(brcmf_poll, uint, 0); uint brcmf_intr = true; module_param(brcmf_intr, uint, 0); -/* IOCTL response timeout */ -static int brcmf_ioctl_timeout_msec = IOCTL_RESP_TIMEOUT; - /* override the RAM size if possible */ #define DONGLE_MIN_MEMSIZE (128 * 1024) int brcmf_dongle_memsize; module_param(brcmf_dongle_memsize, int, 0); -static bool brcmf_alignctl; - -static bool retrydata; -#define RETRYCHAN(chan) (((chan) == SDPCM_EVENT_CHANNEL) || retrydata) - -static const uint firstread = BRCMF_FIRSTREAD; +#define RETRYCHAN(chan) ((chan) == SDPCM_EVENT_CHANNEL) /* Retry count for register access failures */ static const uint retry_limit = 2; -/* Force even SD lengths (some host controllers mess up on odd bytes) */ -static bool forcealign; +/* Limit on rounding up frames */ +static const uint max_roundup = 512; #define ALIGNMENT 4 @@ -794,12 +786,6 @@ static void pkt_align(struct sk_buff *p, int len, int align) __skb_trim(p, len); } -/* Limit on rounding up frames */ -static const uint max_roundup = 512; - -/* Try doing readahead */ -static bool brcmf_readahead; - /* To check if there's window offered */ static bool data_ok(struct brcmf_bus *bus) { @@ -1697,7 +1683,7 @@ static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, bool *pending) { DECLARE_WAITQUEUE(wait, current); - int timeout = msecs_to_jiffies(brcmf_ioctl_timeout_msec); + int timeout = msecs_to_jiffies(IOCTL_RESP_TIMEOUT); /* Wait until control frame is available */ add_wait_queue(&bus->ioctl_resp_wait, &wait); @@ -1733,21 +1719,19 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) /* Set rxctl for frame (w/optional alignment) */ bus->rxctl = bus->rxbuf; - if (brcmf_alignctl) { - bus->rxctl += firstread; - pad = ((unsigned long)bus->rxctl % BRCMF_SDALIGN); - if (pad) - bus->rxctl += (BRCMF_SDALIGN - pad); - bus->rxctl -= firstread; - } + bus->rxctl += BRCMF_FIRSTREAD; + pad = ((unsigned long)bus->rxctl % BRCMF_SDALIGN); + if (pad) + bus->rxctl += (BRCMF_SDALIGN - pad); + bus->rxctl -= BRCMF_FIRSTREAD; /* Copy the already-read portion over */ - memcpy(bus->rxctl, hdr, firstread); - if (len <= firstread) + memcpy(bus->rxctl, hdr, BRCMF_FIRSTREAD); + if (len <= BRCMF_FIRSTREAD) goto gotpkt; /* Raise rdlen to next SDIO block to avoid tail command */ - rdlen = len - firstread; + rdlen = len - BRCMF_FIRSTREAD; if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { pad = bus->blocksize - (rdlen % bus->blocksize); if ((pad <= bus->roundup) && (pad < bus->blocksize) && @@ -1758,11 +1742,11 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) } /* Satisfy length-alignment requirements */ - if (forcealign && (rdlen & (ALIGNMENT - 1))) + if (rdlen & (ALIGNMENT - 1)) rdlen = roundup(rdlen, ALIGNMENT); /* Drop if the read is too big or it exceeds our maximum */ - if ((rdlen + firstread) > bus->drvr->maxctl) { + if ((rdlen + BRCMF_FIRSTREAD) > bus->drvr->maxctl) { brcmf_dbg(ERROR, "%d-byte control read exceeds %d-byte buffer\n", rdlen, bus->drvr->maxctl); bus->drvr->rx_errors++; @@ -1783,7 +1767,7 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, - F2SYNC, (bus->rxctl + firstread), rdlen, + F2SYNC, (bus->rxctl + BRCMF_FIRSTREAD), rdlen, NULL); bus->f2rxdata++; @@ -1857,7 +1841,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) } /* Try doing single read if we can */ - if (brcmf_readahead && bus->nextlen) { + if (bus->nextlen) { u16 nextlen = bus->nextlen; bus->nextlen = 0; @@ -1871,7 +1855,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) (rdlen % bus->blocksize); if ((pad <= bus->roundup) && (pad < bus->blocksize) - && ((rdlen + pad + firstread) < + && ((rdlen + pad + BRCMF_FIRSTREAD) < MAX_RX_DATASZ)) rdlen += pad; } else if (rdlen % BRCMF_SDALIGN) { @@ -2055,8 +2039,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Read frame header (hardware and software) */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread, - NULL); + SDIO_FUNC_2, F2SYNC, bus->rxhdr, + BRCMF_FIRSTREAD, NULL); bus->f2rxhdrs++; if (sdret < 0) { @@ -2162,24 +2146,24 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) SDPCM_GLOM_CHANNEL */ /* Length to read */ - rdlen = (len > firstread) ? (len - firstread) : 0; + rdlen = (len > BRCMF_FIRSTREAD) ? (len - BRCMF_FIRSTREAD) : 0; /* May pad read to blocksize for efficiency */ if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { pad = bus->blocksize - (rdlen % bus->blocksize); if ((pad <= bus->roundup) && (pad < bus->blocksize) && - ((rdlen + pad + firstread) < MAX_RX_DATASZ)) + ((rdlen + pad + BRCMF_FIRSTREAD) < MAX_RX_DATASZ)) rdlen += pad; } else if (rdlen % BRCMF_SDALIGN) { rdlen += BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); } /* Satisfy length-alignment requirements */ - if (forcealign && (rdlen & (ALIGNMENT - 1))) + if (rdlen & (ALIGNMENT - 1)) rdlen = roundup(rdlen, ALIGNMENT); - if ((rdlen + firstread) > MAX_RX_DATASZ) { + if ((rdlen + BRCMF_FIRSTREAD) > MAX_RX_DATASZ) { /* Too long -- skip this frame */ brcmf_dbg(ERROR, "too long: len %d rdlen %d\n", len, rdlen); @@ -2189,7 +2173,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) continue; } - pkt = brcmu_pkt_buf_get_skb(rdlen + firstread + BRCMF_SDALIGN); + pkt = brcmu_pkt_buf_get_skb(rdlen + + BRCMF_FIRSTREAD + BRCMF_SDALIGN); if (!pkt) { /* Give up on data, request rtx of events */ brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: rdlen %d chan %d\n", @@ -2200,7 +2185,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) } /* Leave room for what we already read, and align remainder */ - skb_pull(pkt, firstread); + skb_pull(pkt, BRCMF_FIRSTREAD); pkt_align(pkt, rdlen, BRCMF_SDALIGN); /* Read the remaining frame data */ @@ -2221,8 +2206,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) } /* Copy the already-read portion */ - skb_push(pkt, firstread); - memcpy(pkt->data, bus->rxhdr, firstread); + skb_push(pkt, BRCMF_FIRSTREAD); + memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); #ifdef BCMDBG if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { @@ -2328,7 +2313,6 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, u8 *frame; u16 len, pad = 0; u32 swheader; - uint retries = 0; struct sk_buff *new; int i; @@ -2413,48 +2397,44 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, } /* Some controllers have trouble with odd bytes -- round to even */ - if (forcealign && (len & (ALIGNMENT - 1))) + if (len & (ALIGNMENT - 1)) len = roundup(len, ALIGNMENT); - do { - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, - len, pkt); - bus->f2txdata++; + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, + len, pkt); + bus->f2txdata++; - if (ret < 0) { - /* On failure, abort the command - and terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; + if (ret < 0) { + /* On failure, abort the command and terminate the frame */ + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); + bus->tx_sderrs++; - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, - NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, + NULL); + bus->f1regdata++; + for (i = 0; i < 3; i++) { + u8 hi, lo; + hi = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCHI, + NULL); + lo = brcmf_sdcard_cfg_read(bus->sdiodev, + SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCLO, + NULL); + bus->f1regdata += 2; + if ((hi == 0) && (lo == 0)) + break; } - if (ret == 0) - bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - } while ((ret < 0) && retrydata && retries++ < TXRETRIES); + } + if (ret == 0) + bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; done: /* restore pkt buffer pointer before calling tx complete routine */ @@ -3259,16 +3239,14 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) len = (msglen += SDPCM_HDRLEN); /* Add alignment padding (optional for ctl frames) */ - if (brcmf_alignctl) { - doff = ((unsigned long)frame % BRCMF_SDALIGN); - if (doff) { - frame -= doff; - len += doff; - msglen += doff; - memset(frame, 0, doff + SDPCM_HDRLEN); - } - /* precondition: doff < BRCMF_SDALIGN */ + doff = ((unsigned long)frame % BRCMF_SDALIGN); + if (doff) { + frame -= doff; + len += doff; + msglen += doff; + memset(frame, 0, doff + SDPCM_HDRLEN); } + /* precondition: doff < BRCMF_SDALIGN */ doff += SDPCM_HDRLEN; /* Round send length to next SDIO block */ @@ -3281,7 +3259,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) } /* Satisfy length-alignment requirements */ - if (forcealign && (len & (ALIGNMENT - 1))) + if (len & (ALIGNMENT - 1)) len = roundup(len, ALIGNMENT); /* precondition: IS_ALIGNED((unsigned long)frame, 2) */ @@ -4825,14 +4803,9 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, */ brcmf_txbound = BRCMF_TXBOUND; brcmf_rxbound = BRCMF_RXBOUND; - brcmf_alignctl = true; - brcmf_readahead = true; - retrydata = false; brcmf_dongle_memsize = 0; brcmf_txminmax = BRCMF_TXMINMAX; - forcealign = true; - brcmf_c_init(); brcmf_dbg(TRACE, "Enter\n"); From 14739feed0af86c1e7d20c22a46252889bfd887a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 16 Sep 2011 12:28:08 -0700 Subject: [PATCH 1114/1519] staging: brcm80211: sparse endianness warnings on fullmac bss info Structure that is received from dongle has been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 27 ++++++++++--------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 10 +++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index de3f914d7a4..da53dd02c33 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -366,36 +366,37 @@ struct brcmf_pkt_filter_enable { * next bss_info structure in a vector (in struct brcmf_scan_results) */ struct brcmf_bss_info { - u32 version; /* version field */ - u32 length; /* byte length of data in this record, + __le32 version; /* version field */ + __le32 length; /* byte length of data in this record, * starting at version and including IEs */ u8 BSSID[ETH_ALEN]; - u16 beacon_period; /* units are Kusec */ - u16 capability; /* Capability information */ + __le16 beacon_period; /* units are Kusec */ + __le16 capability; /* Capability information */ u8 SSID_len; u8 SSID[32]; struct { - uint count; /* # rates in this set */ + __le32 count; /* # rates in this set */ u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */ } rateset; /* supported rates */ - u16 chanspec; /* chanspec for bss */ - u16 atim_window; /* units are Kusec */ + __le16 chanspec; /* chanspec for bss */ + __le16 atim_window; /* units are Kusec */ u8 dtim_period; /* DTIM period */ - s16 RSSI; /* receive signal strength (in dBm) */ + __le16 RSSI; /* receive signal strength (in dBm) */ s8 phy_noise; /* noise (in dBm) */ u8 n_cap; /* BSS is 802.11N Capable */ - u32 nbss_cap; /* 802.11N BSS Capabilities (based on HT_CAP_*) */ + /* 802.11N BSS Capabilities (based on HT_CAP_*): */ + __le32 nbss_cap; u8 ctl_ch; /* 802.11N BSS control channel number */ - u32 reserved32[1]; /* Reserved for expansion of BSS properties */ + __le32 reserved32[1]; /* Reserved for expansion of BSS properties */ u8 flags; /* flags */ u8 reserved[3]; /* Reserved for expansion of BSS properties */ u8 basic_mcs[MCSSET_LEN]; /* 802.11N BSS required MCS set */ - u16 ie_offset; /* offset at which IEs start, from beginning */ - u32 ie_length; /* byte length of Information Elements */ - s16 SNR; /* average SNR of during frame reception */ + __le16 ie_offset; /* offset at which IEs start, from beginning */ + __le32 ie_length; /* byte length of Information Elements */ + __le16 SNR; /* average SNR of during frame reception */ /* Add new fields here */ /* variable length Information Elements */ }; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 4f3e8b8d589..9e07f777558 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -1955,7 +1955,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, notify_capability = le16_to_cpu(bi->capability); notify_interval = le16_to_cpu(bi->beacon_period); notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le16_to_cpu(bi->ie_length); + notify_ielen = le32_to_cpu(bi->ie_length); notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", @@ -2054,7 +2054,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, notify_capability = le16_to_cpu(bi->capability); notify_interval = le16_to_cpu(bi->beacon_period); notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le16_to_cpu(bi->ie_length); + notify_ielen = le32_to_cpu(bi->ie_length); notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; WL_CONN("channel: %d(%d)\n", channel, freq); @@ -2111,9 +2111,9 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) if (unlikely(err)) goto update_bss_info_out; - ie = ((u8 *)bi) + bi->ie_offset; - ie_len = bi->ie_length; - beacon_interval = cpu_to_le16(bi->beacon_period); + ie = ((u8 *)bi) + le16_to_cpu(bi->ie_offset); + ie_len = le32_to_cpu(bi->ie_length); + beacon_interval = le16_to_cpu(bi->beacon_period); tim = brcmu_parse_tlvs(ie, ie_len, WLAN_EID_TIM); if (tim) From 7518b9b8fc72a6c0ba67f33bdd4689c7dd28686a Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Mon, 19 Sep 2011 16:56:51 +0200 Subject: [PATCH 1115/1519] staging: usbip: fix up api changes that broke windows clients Revert changes in definitions that were submitted on May 11 2011 and committed on June 7 2011. No reason for the change in these values was given in the patch comment, it broke compatibility with older versions, and was difficult to detect by the simultaneous move of the lines of code. Signed-off-by: Alexander Thomas Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/usbip_common.h | 8 ++++---- drivers/staging/usbip/usbip_protocol.txt | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 074ac4267d3..be216175ae8 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -126,12 +126,12 @@ extern struct device_attribute dev_attr_usbip_debug; * */ #define USBIP_CMD_SUBMIT 0x0001 -#define USBIP_RET_SUBMIT 0x0002 -#define USBIP_CMD_UNLINK 0x0003 +#define USBIP_CMD_UNLINK 0x0002 +#define USBIP_RET_SUBMIT 0x0003 #define USBIP_RET_UNLINK 0x0004 -#define USBIP_DIR_IN 0x00 -#define USBIP_DIR_OUT 0x01 +#define USBIP_DIR_OUT 0x00 +#define USBIP_DIR_IN 0x01 /** * struct usbip_header_basic - data pertinent to every request diff --git a/drivers/staging/usbip/usbip_protocol.txt b/drivers/staging/usbip/usbip_protocol.txt index 84e353b714b..0f102081e86 100644 --- a/drivers/staging/usbip/usbip_protocol.txt +++ b/drivers/staging/usbip/usbip_protocol.txt @@ -243,8 +243,8 @@ USBIP_CMD_SUBMIT: Submit an URB -----------+--------+------------+--------------------------------------------------- 8 | 4 | | devid -----------+--------+------------+--------------------------------------------------- - 0xC | 4 | | direction: 0: USBIP_DIR_IN - | | | 1: USBIP_DIR_OUT + 0xC | 4 | | direction: 0: USBIP_DIR_OUT + | | | 1: USBIP_DIR_IN -----------+--------+------------+--------------------------------------------------- 0x10 | 4 | | ep: endpoint number, possible values are: 0...15 -----------+--------+------------+--------------------------------------------------- @@ -285,14 +285,14 @@ USBIP_RET_SUBMIT: Reply for submitting an URB Offset | Length | Value | Description -----------+--------+------------+--------------------------------------------------- - 0 | 4 | 0x00000002 | command + 0 | 4 | 0x00000003 | command -----------+--------+------------+--------------------------------------------------- 4 | 4 | | seqnum: URB sequence number -----------+--------+------------+--------------------------------------------------- 8 | 4 | | devid -----------+--------+------------+--------------------------------------------------- - 0xC | 4 | | direction: 0: USBIP_DIR_IN - | | | 1: USBIP_DIR_OUT + 0xC | 4 | | direction: 0: USBIP_DIR_OUT + | | | 1: USBIP_DIR_IN -----------+--------+------------+--------------------------------------------------- 0x10 | 4 | | ep: endpoint number -----------+--------+------------+--------------------------------------------------- @@ -318,14 +318,14 @@ USBIP_CMD_UNLINK: Unlink an URB Offset | Length | Value | Description -----------+--------+------------+--------------------------------------------------- - 0 | 4 | 0x00000003 | command: URB unlink command + 0 | 4 | 0x00000002 | command: URB unlink command -----------+--------+------------+--------------------------------------------------- 4 | 4 | | seqnum: URB sequence number to unlink: FIXME: is this so? -----------+--------+------------+--------------------------------------------------- 8 | 4 | | devid -----------+--------+------------+--------------------------------------------------- - 0xC | 4 | | direction: 0: USBIP_DIR_IN - | | | 1: USBIP_DIR_OUT + 0xC | 4 | | direction: 0: USBIP_DIR_OUT + | | | 1: USBIP_DIR_IN -----------+--------+------------+--------------------------------------------------- 0x10 | 4 | | ep: endpoint number: zero -----------+--------+------------+--------------------------------------------------- @@ -345,8 +345,8 @@ USBIP_RET_UNLINK: Reply for URB unlink -----------+--------+------------+--------------------------------------------------- 8 | 4 | | devid -----------+--------+------------+--------------------------------------------------- - 0xC | 4 | | direction: 0: USBIP_DIR_IN - | | | 1: USBIP_DIR_OUT + 0xC | 4 | | direction: 0: USBIP_DIR_OUT + | | | 1: USBIP_DIR_IN -----------+--------+------------+--------------------------------------------------- 0x10 | 4 | | ep: endpoint number -----------+--------+------------+--------------------------------------------------- From 5ac5bd8754b3dabcf4aea7b5f4a28a1d8494a1b0 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Sun, 18 Sep 2011 18:34:46 -0400 Subject: [PATCH 1116/1519] Staging: bcm: Add size minimum size restrictions for IOCTL_IDLE_REQ If IoBuffer.InputLength is zero then this will cause an Oops when we dereference the ZERO_SIZE_PTR. Or if it's smaller than sizeof(struct link_request) then we would get memory corruption when we set ->PLength in CopyBufferToControlPacket(). Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 6f8a75dc1ef..1905a83b338 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -687,7 +687,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - /* FIXME: don't accept any length from user */ + if (IoBuffer.InputLength < sizeof(struct link_request)) + return -EINVAL; + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); if (!pvBuffer) return -ENOMEM; From e228b7426e65df0f2e93c783c2c89baabe318b9b Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Sun, 18 Sep 2011 18:34:47 -0400 Subject: [PATCH 1117/1519] Staging: bcm: Add size maximum size restrictions for IOCTL_IDLE_REQ In the first alteration, the MAX_CNTL_PKT_SIZE is the maximum size of the control packet in ->Adapter->txctlpacket[] which is defined in InitAdapter(). This caps the size of kmalloc memory allocation. In the second change, this max cap fixes a potential memory corruption bug when subsequent memset and memcpy calls are invoked. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 3 +++ drivers/staging/bcm/Misc.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 1905a83b338..4c433538397 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -690,6 +690,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if (IoBuffer.InputLength < sizeof(struct link_request)) return -EINVAL; + if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) + return -EINVAL; + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); if (!pvBuffer) return -ENOMEM; diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index c5b3a3666bc..9da94086987 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -421,6 +421,10 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**PLength = pktlen; } } + + if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE) + return -EINVAL; + memset(ctrl_buff, 0, pktlen+LEADER_SIZE); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); *(PLEADER)ctrl_buff=*pLeader; From e8df1674d383d2ecc6efa8d7dba74c03aafdfdd7 Mon Sep 17 00:00:00 2001 From: Kautuk Consul Date: Wed, 14 Sep 2011 08:56:21 +0530 Subject: [PATCH 1118/1519] staging: quatech_usb2: Potential lost wakeup scenario in TIOCMIWAIT If the usermode app does an ioctl over this serial device by using TIOCMIWAIT, then the code will wait by setting the current task state to TASK_INTERRUPTIBLE and then calling schedule(). This will be woken up by the qt2_process_modem_status on URB completion when the port_extra->shadowMSR is set to the new modem status. However, this could result in a lost wakeup scenario due to a race in the logic in the qt2_ioctl(TIOCMIWAIT) loop and the URB completion for new modem status in qt2_process_modem_status. Due to this, the usermode app's task will continue to sleep despite a change in the modem status. Signed-off-by: Kautuk Consul Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/quatech_usb2/quatech_usb2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c index ca098cabc2b..02fafecd477 100644 --- a/drivers/staging/quatech_usb2/quatech_usb2.c +++ b/drivers/staging/quatech_usb2/quatech_usb2.c @@ -916,9 +916,10 @@ static int qt2_ioctl(struct tty_struct *tty, dbg("%s() port %d, cmd == TIOCMIWAIT enter", __func__, port->number); prev_msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK; + barrier(); + __set_current_state(TASK_INTERRUPTIBLE); while (1) { add_wait_queue(&port_extra->wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); schedule(); dbg("%s(): port %d, cmd == TIOCMIWAIT here\n", __func__, port->number); @@ -926,9 +927,12 @@ static int qt2_ioctl(struct tty_struct *tty, /* see if a signal woke us up */ if (signal_pending(current)) return -ERESTARTSYS; + set_current_state(TASK_INTERRUPTIBLE); msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK; - if (msr_value == prev_msr_value) + if (msr_value == prev_msr_value) { + __set_current_state(TASK_RUNNING); return -EIO; /* no change - error */ + } if ((arg & TIOCM_RNG && ((prev_msr_value & QT2_SERIAL_MSR_RI) == (msr_value & QT2_SERIAL_MSR_RI))) || @@ -941,6 +945,7 @@ static int qt2_ioctl(struct tty_struct *tty, (arg & TIOCM_CTS && ((prev_msr_value & QT2_SERIAL_MSR_CTS) == (msr_value & QT2_SERIAL_MSR_CTS)))) { + __set_current_state(TASK_RUNNING); return 0; } } /* end inifinite while */ From f49334a00e115103fb5a9df3fb904a4daf156512 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Mon, 19 Sep 2011 21:08:14 +0100 Subject: [PATCH 1119/1519] staging: wlags49_h2: Remove old WIRELESS_EXT support Since the driver is now in-kernel remove support for building against ancient WIRELESS_EXT versions. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_internal.h | 7 -- drivers/staging/wlags49_h2/wl_version.h | 3 - drivers/staging/wlags49_h2/wl_wext.c | 96 ------------------------ drivers/staging/wlags49_h2/wl_wext.h | 8 -- 4 files changed, 114 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_internal.h b/drivers/staging/wlags49_h2/wl_internal.h index b61c9eb75ad..6351bb8b680 100644 --- a/drivers/staging/wlags49_h2/wl_internal.h +++ b/drivers/staging/wlags49_h2/wl_internal.h @@ -74,15 +74,8 @@ #include #endif // BUS_PCMCIA -#ifdef HAS_WIRELESS_EXTENSIONS #include -#if WIRELESS_EXT > 13 #include -#endif // WIRELESS_EXT > 13 -#define USE_DBM -#define RETURN_CURRENT_NETWORKNAME -#define USE_FREQUENCY -#endif // HAS_WIRELESS_EXTENSIONS/ #include diff --git a/drivers/staging/wlags49_h2/wl_version.h b/drivers/staging/wlags49_h2/wl_version.h index a5faada136d..55e93cdc1f1 100644 --- a/drivers/staging/wlags49_h2/wl_version.h +++ b/drivers/staging/wlags49_h2/wl_version.h @@ -157,9 +157,6 @@ err: define bus type; * There doesn't seem to be a difference for PCMCIA and PCI anymore, at least * for PCMCIA the same defines are needed now as previously only used for PCI */ -#if USE_WEXT -#define HAS_WIRELESS_EXTENSIONS -#endif // USE_WEXT #define NEW_MULTICAST #define ALLOC_SKB(len) dev_alloc_skb(len+2) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 522a31090c5..fc453a8dac0 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -77,11 +77,6 @@ -/* If WIRELESS_EXT is not defined (as a result of HAS_WIRELESS_EXTENSIONS - #including linux/wireless.h), then these functions do not need to be included - in the build. */ -#ifdef WIRELESS_EXT - #define IWE_STREAM_ADD_EVENT(info, buf, end, iwe, len) \ iwe_stream_add_event(info, buf, end, iwe, len) #define IWE_STREAM_ADD_POINT(info, buf, end, iwe, msg) \ @@ -324,16 +319,8 @@ static int wireless_get_frequency(struct net_device *dev, struct iw_request_info if( ret == HCF_SUCCESS ) { hcf_16 channel = CNV_LITTLE_TO_INT( lp->ltvRecord.u.u16[0] ); -#ifdef USE_FREQUENCY - freq->m = wl_get_freq_from_chan( channel ) * 100000; freq->e = 1; -#else - - freq->m = channel; - freq->e = 0; - -#endif /* USE_FREQUENCY */ } wl_act_int_on( lp ); @@ -460,8 +447,6 @@ retry: /* Link quality */ -#ifdef USE_DBM - range->max_qual.qual = (u_char)HCF_MAX_COMM_QUALITY; /* If the value returned in /proc/net/wireless is greater than the maximum range, @@ -470,13 +455,6 @@ retry: range->max_qual.level = (u_char)( dbm( HCF_MIN_SIGNAL_LEVEL ) - 1 ); range->max_qual.noise = (u_char)( dbm( HCF_MIN_NOISE_LEVEL ) - 1 ); -#else - - range->max_qual.qual = 100; - range->max_qual.level = 100; - range->max_qual.noise = 100; - -#endif /* USE_DBM */ /* Set available rates */ @@ -508,8 +486,6 @@ retry: /* Encryption */ -#if WIRELESS_EXT > 8 - /* Holding the lock too long, make a gap to allow other processes */ wl_unlock(lp, &flags); wl_lock( lp, &flags ); @@ -526,26 +502,17 @@ retry: range->max_encoding_tokens = MAX_KEYS; } -#endif /* WIRELESS_EXT > 8 */ - /* Tx Power Info */ range->txpower_capa = IW_TXPOW_MWATT; range->num_txpower = 1; range->txpower[0] = RADIO_TX_POWER_MWATT; -#if WIRELESS_EXT > 10 - /* Wireless Extension Info */ range->we_version_compiled = WIRELESS_EXT; range->we_version_source = WIRELESS_SUPPORT; // Retry Limits and Lifetime - NOT SUPPORTED -#endif - - -#if WIRELESS_EXT > 11 - /* Holding the lock too long, make a gap to allow other processes */ wl_unlock(lp, &flags); wl_lock( lp, &flags ); @@ -555,8 +522,6 @@ retry: range->avg_qual = lp->wstats.qual; DBG_TRACE( DbgInfo, "wl_wireless_stats done\n" ); -#endif - /* Event capability (kernel + driver) */ range->event_capa[0] = (IW_EVENT_CAPA_K_0 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | @@ -1087,7 +1052,6 @@ static int wireless_get_essid(struct net_device *dev, struct iw_request_info *in #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode -#ifdef RETURN_CURRENT_NETWORKNAME /* if desired is null ("any"), return current or "any" */ if( pName->name[0] == '\0' ) { @@ -1116,7 +1080,6 @@ static int wireless_get_essid(struct net_device *dev, struct iw_request_info *in } } -#endif // RETURN_CURRENT_NETWORKNAME #endif // HCF_STA data->length--; @@ -1170,10 +1133,7 @@ static int wireless_set_encode(struct net_device *dev, struct iw_request_info *i struct wl_private *lp = wl_priv(dev); unsigned long flags; int ret = 0; - -#if 1 //;? #if WIRELESS_EXT > 8 - used unconditionally in the rest of the code... hcf_8 encryption_state; -#endif // WIRELESS_EXT > 8 /*------------------------------------------------------------------------*/ @@ -2023,11 +1983,9 @@ static int wireless_set_rts_threshold (struct net_device *dev, struct iw_request goto out; } -#if WIRELESS_EXT > 8 if( rts->disabled ) { rthr = 2347; } -#endif /* WIRELESS_EXT > 8 */ if(( rthr < 256 ) || ( rthr > 2347 )) { ret = -EINVAL; @@ -2095,12 +2053,8 @@ static int wireless_get_rts_threshold (struct net_device *dev, struct iw_request rts->value = lp->RTSThreshold; -#if WIRELESS_EXT > 8 - rts->disabled = ( rts->value == 2347 ); -#endif /* WIRELESS_EXT > 8 */ - rts->fixed = 1; wl_act_int_on( lp ); @@ -2527,8 +2481,6 @@ out: -#if WIRELESS_EXT > 13 - /******************************************************************************* * wireless_set_scan() ******************************************************************************* @@ -2810,7 +2762,6 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf buf = IWE_STREAM_ADD_EVENT(info, buf, buf_end, &iwe, IW_EV_FREQ_LEN); -#if WIRELESS_EXT > 14 /* Custom info (Beacon Interval) */ memset( &iwe, 0, sizeof( iwe )); memset( msg, 0, sizeof( msg )); @@ -2839,7 +2790,6 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf } /* Add other custom info in formatted string format as needed... */ -#endif } data->length = buf - extra; @@ -2856,11 +2806,8 @@ out: } // wireless_get_scan /*============================================================================*/ -#endif // WIRELESS_EXT > 13 -#if WIRELESS_EXT > 17 - static int wireless_set_auth(struct net_device *dev, struct iw_request_info *info, struct iw_param *data, char *extra) @@ -3261,8 +3208,6 @@ out: /*============================================================================*/ -#endif // WIRELESS_EXT > 17 - /******************************************************************************* * wl_wireless_stats() ******************************************************************************* @@ -3316,7 +3261,6 @@ struct iw_statistics * wl_wireless_stats( struct net_device *dev ) if( status == HCF_SUCCESS ) { pQual = (CFG_COMMS_QUALITY_STRCT *)&( lp->ltvRecord ); -#ifdef USE_DBM pStats->qual.qual = (u_char) CNV_LITTLE_TO_INT( pQual->coms_qual ); pStats->qual.level = (u_char) dbm( CNV_LITTLE_TO_INT( pQual->signal_lvl )); pStats->qual.noise = (u_char) dbm( CNV_LITTLE_TO_INT( pQual->noise_lvl )); @@ -3325,23 +3269,6 @@ struct iw_statistics * wl_wireless_stats( struct net_device *dev ) IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED | IW_QUAL_DBM); -#else - pStats->qual.qual = percent( CNV_LITTLE_TO_INT( pQual->coms_qual ), - HCF_MIN_COMM_QUALITY, - HCF_MAX_COMM_QUALITY ); - - pStats->qual.level = percent( CNV_LITTLE_TO_INT( pQual->signal_lvl ), - HCF_MIN_SIGNAL_LEVEL, - HCF_MAX_SIGNAL_LEVEL ); - - pStats->qual.noise = percent( CNV_LITTLE_TO_INT( pQual->noise_lvl ), - HCF_MIN_NOISE_LEVEL, - HCF_MAX_NOISE_LEVEL ); - - pStats->qual.updated |= (IW_QUAL_QUAL_UPDATED | - IW_QUAL_LEVEL_UPDATED | - IW_QUAL_NOISE_UPDATED); -#endif /* USE_DBM */ } else { memset( &( pStats->qual ), 0, sizeof( pStats->qual )); } @@ -3512,7 +3439,6 @@ inline void wl_spy_gather( struct net_device *dev, u_char *mac ) ******************************************************************************/ void wl_wext_event_freq( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ @@ -3524,7 +3450,6 @@ void wl_wext_event_freq( struct net_device *dev ) wrqu.freq.e = 0; wireless_send_event( dev, SIOCSIWFREQ, &wrqu, NULL ); -#endif /* WIRELESS_EXT > 13 */ return; } // wl_wext_event_freq @@ -3554,7 +3479,6 @@ void wl_wext_event_freq( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_mode( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ @@ -3569,7 +3493,6 @@ void wl_wext_event_mode( struct net_device *dev ) } wireless_send_event( dev, SIOCSIWMODE, &wrqu, NULL ); -#endif /* WIRELESS_EXT > 13 */ return; } // wl_wext_event_mode @@ -3599,7 +3522,6 @@ void wl_wext_event_mode( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_essid( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); /*------------------------------------------------------------------------*/ @@ -3616,7 +3538,6 @@ void wl_wext_event_essid( struct net_device *dev ) wrqu.essid.flags = 1; wireless_send_event( dev, SIOCSIWESSID, &wrqu, lp->NetworkName ); -#endif /* WIRELESS_EXT > 13 */ return; } // wl_wext_event_essid @@ -3646,7 +3567,6 @@ void wl_wext_event_essid( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_encode( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); int index = 0; @@ -3688,7 +3608,6 @@ void wl_wext_event_encode( struct net_device *dev ) wireless_send_event( dev, SIOCSIWENCODE, &wrqu, lp->DefaultKeys.key[index].key ); -#endif /* WIRELESS_EXT > 13 */ return; } // wl_wext_event_encode @@ -3718,7 +3637,6 @@ void wl_wext_event_encode( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_ap( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); int status; @@ -3747,8 +3665,6 @@ void wl_wext_event_ap( struct net_device *dev ) wireless_send_event( dev, SIOCGIWAP, &wrqu, NULL ); } -#endif /* WIRELESS_EXT > 13 */ - return; } // wl_wext_event_ap /*============================================================================*/ @@ -3776,7 +3692,6 @@ void wl_wext_event_ap( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_scan_complete( struct net_device *dev ) { -#if WIRELESS_EXT > 13 union iwreq_data wrqu; /*------------------------------------------------------------------------*/ @@ -3785,7 +3700,6 @@ void wl_wext_event_scan_complete( struct net_device *dev ) wrqu.addr.sa_family = ARPHRD_ETHER; wireless_send_event( dev, SIOCGIWSCAN, &wrqu, NULL ); -#endif /* WIRELESS_EXT > 13 */ return; } // wl_wext_event_scan_complete @@ -3815,7 +3729,6 @@ void wl_wext_event_scan_complete( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_new_sta( struct net_device *dev ) { -#if WIRELESS_EXT > 14 union iwreq_data wrqu; /*------------------------------------------------------------------------*/ @@ -3826,7 +3739,6 @@ void wl_wext_event_new_sta( struct net_device *dev ) memcpy( wrqu.addr.sa_data, dev->dev_addr, ETH_ALEN ); wrqu.addr.sa_family = ARPHRD_ETHER; wireless_send_event( dev, IWEVREGISTERED, &wrqu, NULL ); -#endif /* WIRELESS_EXT > 14 */ return; } // wl_wext_event_new_sta @@ -3856,7 +3768,6 @@ void wl_wext_event_new_sta( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_expired_sta( struct net_device *dev ) { -#if WIRELESS_EXT > 14 union iwreq_data wrqu; /*------------------------------------------------------------------------*/ @@ -3866,7 +3777,6 @@ void wl_wext_event_expired_sta( struct net_device *dev ) memcpy( wrqu.addr.sa_data, dev->dev_addr, ETH_ALEN ); wrqu.addr.sa_family = ARPHRD_ETHER; wireless_send_event( dev, IWEVEXPIRED, &wrqu, NULL ); -#endif /* WIRELESS_EXT > 14 */ return; } // wl_wext_event_expired_sta @@ -3895,7 +3805,6 @@ void wl_wext_event_expired_sta( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_mic_failed( struct net_device *dev ) { -#if WIRELESS_EXT > 14 char msg[512]; union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); @@ -3944,7 +3853,6 @@ void wl_wext_event_mic_failed( struct net_device *dev ) #endif wrqu.data.length = strlen( msg ); wireless_send_event( dev, IWEVCUSTOM, &wrqu, msg ); -#endif /* WIRELESS_EXT > 14 */ return; } // wl_wext_event_mic_failed @@ -3974,7 +3882,6 @@ void wl_wext_event_mic_failed( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_assoc_ie( struct net_device *dev ) { -#if WIRELESS_EXT > 14 char msg[512]; union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); @@ -4016,7 +3923,6 @@ void wl_wext_event_assoc_ie( struct net_device *dev ) wireless_send_event( dev, IWEVCUSTOM, &wrqu, msg ); } } -#endif /* WIRELESS_EXT > 14 */ return; } // wl_wext_event_assoc_ie @@ -4120,5 +4026,3 @@ const struct iw_handler_def wl_iw_handler_def = .standard = (iw_handler *) wl_handler, .get_wireless_stats = wl_get_wireless_stats, }; - -#endif // WIRELESS_EXT diff --git a/drivers/staging/wlags49_h2/wl_wext.h b/drivers/staging/wlags49_h2/wl_wext.h index 39d39a47b05..a713058c802 100644 --- a/drivers/staging/wlags49_h2/wl_wext.h +++ b/drivers/staging/wlags49_h2/wl_wext.h @@ -62,9 +62,6 @@ #define __WL_WEXT_H__ -#ifdef WIRELESS_EXT - - /******************************************************************************* * function protoypes ******************************************************************************/ @@ -88,9 +85,4 @@ void wl_wext_event_assoc_ie( struct net_device *dev ); extern const struct iw_handler_def wl_iw_handler_def; -#else -#error WIRELESS_EXT -#endif // WIRELESS_EXT - - #endif // __WL_WEXT_H__ From a4f7b2e823d05e500ccb2c35a68e454e8e672224 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Mon, 19 Sep 2011 21:08:15 +0100 Subject: [PATCH 1120/1519] staging: wlags49_h2: Support standard WEXT events ... instead of using IWEVCUSTOM. Use the defined events for michael mic failure, association request info and association response info. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 56 +++++++++------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index fc453a8dac0..917c949fe59 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -3805,9 +3805,9 @@ void wl_wext_event_expired_sta( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_mic_failed( struct net_device *dev ) { - char msg[512]; union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); + struct iw_michaelmicfailure wxmic; int key_idx; char *addr1; char *addr2; @@ -3829,30 +3829,17 @@ void wl_wext_event_mic_failed( struct net_device *dev ) DBG_PRINT( "MIC FAIL - KEY USED : %d, STATUS : 0x%04x\n", key_idx, hdr->status ); - memset( &wrqu, 0, sizeof( wrqu )); - memset( msg, 0, sizeof( msg )); + memset(&wrqu, 0, sizeof(wrqu)); + memset(&wxmic, 0, sizeof(wxmic)); + wxmic.flags = key_idx & IW_MICFAILURE_KEY_ID; + wxmic.flags |= (addr1[0] & 1) ? + IW_MICFAILURE_GROUP : IW_MICFAILURE_PAIRWISE; + wxmic.src_addr.sa_family = ARPHRD_ETHER; + memcpy(wxmic.src_addr.sa_data, addr2, ETH_ALEN); - /* Because MIC failures are not part of the Wireless Extensions yet, they - must be passed as a string using an IWEVCUSTOM event. In order for the - event to be effective, the string format must be known by both the - driver and the supplicant. The following is the string format used by the - hostap project's WPA supplicant, and will be used here until the Wireless - Extensions interface adds this support: - - MLME-MICHAELMICFAILURE.indication(keyid=# broadcast/unicast addr=addr2) - */ - - /* NOTE: Format of MAC address (using colons to separate bytes) may cause - a problem in future versions of the supplicant, if they ever - actually parse these parameters */ -#if DBG - sprintf(msg, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast " - "addr=%pM)", key_idx, addr1[0] & 0x01 ? "broad" : "uni", - addr2); -#endif - wrqu.data.length = strlen( msg ); - wireless_send_event( dev, IWEVCUSTOM, &wrqu, msg ); + wrqu.data.length = sizeof(wxmic); + wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&wxmic); return; } // wl_wext_event_mic_failed @@ -3882,7 +3869,6 @@ void wl_wext_event_mic_failed( struct net_device *dev ) ******************************************************************************/ void wl_wext_event_assoc_ie( struct net_device *dev ) { - char msg[512]; union iwreq_data wrqu; struct wl_private *lp = wl_priv(dev); int status; @@ -3893,7 +3879,6 @@ void wl_wext_event_assoc_ie( struct net_device *dev ) memset( &wrqu, 0, sizeof( wrqu )); - memset( msg, 0, sizeof( msg )); /* Retrieve the Association Request IE */ lp->ltvRecord.len = 45; @@ -3906,21 +3891,16 @@ void wl_wext_event_assoc_ie( struct net_device *dev ) memcpy( &data.rawData, &( lp->ltvRecord.u.u8[1] ), 88 ); wpa_ie = wl_parse_wpa_ie( &data, &length ); - /* Because this event (Association WPA-IE) is not part of the Wireless - Extensions yet, it must be passed as a string using an IWEVCUSTOM event. - In order for the event to be effective, the string format must be known - by both the driver and the supplicant. The following is the string format - used by the hostap project's WPA supplicant, and will be used here until - the Wireless Extensions interface adds this support: - - ASSOCINFO(ReqIEs=WPA-IE RespIEs=WPA-IE) - */ - if( length != 0 ) { - sprintf( msg, "ASSOCINFO(ReqIEs=%s)", wl_print_wpa_ie( wpa_ie, length )); - wrqu.data.length = strlen( msg ); - wireless_send_event( dev, IWEVCUSTOM, &wrqu, msg ); + wrqu.data.length = wpa_ie[1] + 2; + wireless_send_event(dev, IWEVASSOCREQIE, + &wrqu, wpa_ie); + + /* This bit is a hack. We send the respie + * event at the same time */ + wireless_send_event(dev, IWEVASSOCRESPIE, + &wrqu, wpa_ie); } } From a29b643c5767558956450b86d79eb66334704ac2 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sun, 18 Sep 2011 10:31:33 -0700 Subject: [PATCH 1121/1519] Staging: hv: util: Perform some service specific init/deinit in probe/remove In preparation for modifying the util driver to fully conform to the Linux Driver Model, perform some service specific init and de-init operations in util_probe()/util_remove() as opposed to in init_hyperv_utils()/exit_hyperv_utils() as is currently done. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_kvp.c | 7 +-- drivers/staging/hv/hv_kvp.h | 2 +- drivers/staging/hv/hv_util.c | 91 ++++++++++++++++++++++-------------- drivers/staging/hv/hyperv.h | 13 ++++++ 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c index 13b0ecf7d5d..ff0d9ab2e4a 100644 --- a/drivers/staging/hv/hv_kvp.c +++ b/drivers/staging/hv/hv_kvp.c @@ -312,16 +312,14 @@ callback_done: } int -hv_kvp_init(void) +hv_kvp_init(struct hv_util_service *srv) { int err; err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback); if (err) return err; - recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); - if (!recv_buffer) - return -ENOMEM; + recv_buffer = srv->recv_buffer; return 0; } @@ -330,5 +328,4 @@ void hv_kvp_deinit(void) { cn_del_callback(&kvp_id); cancel_delayed_work_sync(&kvp_work); - kfree(recv_buffer); } diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/staging/hv/hv_kvp.h index 8c402f357d3..9b765d7df83 100644 --- a/drivers/staging/hv/hv_kvp.h +++ b/drivers/staging/hv/hv_kvp.h @@ -175,7 +175,7 @@ struct hv_kvp_msg { struct hv_kvp_msg_enumerate kvp_data; }; -int hv_kvp_init(void); +int hv_kvp_init(struct hv_util_service *); void hv_kvp_deinit(void); void hv_kvp_onchannelcallback(void *); diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index d9460fdd9e4..a1539a7814d 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -30,9 +30,27 @@ #include "hyperv.h" #include "hv_kvp.h" -static u8 *shut_txf_buf; -static u8 *time_txf_buf; -static u8 *hbeat_txf_buf; + +static void shutdown_onchannelcallback(void *context); +static struct hv_util_service util_shutdown = { + .util_cb = shutdown_onchannelcallback, +}; + +static void timesync_onchannelcallback(void *context); +static struct hv_util_service util_timesynch = { + .util_cb = timesync_onchannelcallback, +}; + +static void heartbeat_onchannelcallback(void *context); +static struct hv_util_service util_heartbeat = { + .util_cb = heartbeat_onchannelcallback, +}; + +static struct hv_util_service util_kvp = { + .util_cb = hv_kvp_onchannelcallback, + .util_init = hv_kvp_init, + .util_deinit = hv_kvp_deinit, +}; static void shutdown_onchannelcallback(void *context) { @@ -40,6 +58,7 @@ static void shutdown_onchannelcallback(void *context) u32 recvlen; u64 requestid; u8 execute_shutdown = false; + u8 *shut_txf_buf = util_shutdown.recv_buffer; struct shutdown_msg_data *shutdown_msg; @@ -169,6 +188,7 @@ static void timesync_onchannelcallback(void *context) u64 requestid; struct icmsg_hdr *icmsghdrp; struct ictimesync_data *timedatap; + u8 *time_txf_buf = util_timesynch.recv_buffer; vmbus_recvpacket(channel, time_txf_buf, PAGE_SIZE, &recvlen, &requestid); @@ -207,6 +227,7 @@ static void heartbeat_onchannelcallback(void *context) u64 requestid; struct icmsg_hdr *icmsghdrp; struct heartbeat_msg_data *heartbeat_msg; + u8 *hbeat_txf_buf = util_heartbeat.recv_buffer; vmbus_recvpacket(channel, hbeat_txf_buf, PAGE_SIZE, &recvlen, &requestid); @@ -235,34 +256,56 @@ static void heartbeat_onchannelcallback(void *context) } } -/* - * The devices managed by the util driver don't need any additional - * setup. - */ static int util_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { + struct hv_util_service *srv = + (struct hv_util_service *)dev_id->driver_data; + int ret; + + srv->recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!srv->recv_buffer) + return -ENOMEM; + if (srv->util_init) { + ret = srv->util_init(srv); + if (ret) { + kfree(srv->recv_buffer); + return -ENODEV; + } + } + + hv_set_drvdata(dev, srv); return 0; } static int util_remove(struct hv_device *dev) { + struct hv_util_service *srv = hv_get_drvdata(dev); + + if (srv->util_deinit) + srv->util_deinit(); + kfree(srv->recv_buffer); + return 0; } static const struct hv_vmbus_device_id id_table[] = { /* Shutdown guid */ { VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) }, + 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) + .driver_data = (unsigned long)&util_shutdown }, /* Time synch guid */ { VMBUS_DEVICE(0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, - 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) }, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) + .driver_data = (unsigned long)&util_timesynch }, /* Heartbeat guid */ { VMBUS_DEVICE(0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, - 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) }, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) + .driver_data = (unsigned long)&util_heartbeat }, /* KVP guid */ { VMBUS_DEVICE(0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, - 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6) }, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6) + .driver_data = (unsigned long)&util_kvp }, { }, }; @@ -281,24 +324,11 @@ static int __init init_hyperv_utils(void) int ret; pr_info("Registering HyperV Utility Driver\n"); - if (hv_kvp_init()) - return -ENODEV; - - - shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); - time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); - hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); - - if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) { - pr_info("Unable to allocate memory for receive buffer\n"); - ret = -ENOMEM; - goto err; - } ret = vmbus_driver_register(&util_drv); if (ret != 0) - goto err; + return ret; hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; @@ -310,12 +340,6 @@ static int __init init_hyperv_utils(void) return 0; -err: - kfree(shut_txf_buf); - kfree(time_txf_buf); - kfree(hbeat_txf_buf); - - return ret; } static void exit_hyperv_utils(void) @@ -342,11 +366,6 @@ static void exit_hyperv_utils(void) &chn_cb_negotiate; hv_cb_utils[HV_KVP_MSG].callback = NULL; - hv_kvp_deinit(); - - kfree(shut_txf_buf); - kfree(time_txf_buf); - kfree(hbeat_txf_buf); vmbus_driver_unregister(&util_drv); } diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 76e2ddd437d..5c3e297e11b 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -889,6 +889,19 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); #define HV_ERROR_NOT_SUPPORTED 0x80070032 #define HV_ERROR_MACHINE_LOCKED 0x800704F7 +/* + * While we want to handle util services as regular devices, + * there is only one instance of each of these services; so + * we statically allocate the service specific state. + */ + +struct hv_util_service { + u8 *recv_buffer; + void (*util_cb)(void *); + int (*util_init)(struct hv_util_service *); + void (*util_deinit)(void); +}; + struct vmbuspipe_hdr { u32 flags; u32 msgsize; From 4e65f6e80593c316c5a65a71191fa480360f165d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sun, 18 Sep 2011 10:31:34 -0700 Subject: [PATCH 1122/1519] Staging: hv: util: Properly handle util services in the util driver Now, properly handle util services in the util driver and eliminate code that will not be necessary. In the current code, util services were all handled not as other vmbus devices (net, block) but rather through special handling (channel setup etc.). In this patch we handle all services using the standard Linux Driver Model. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 36 -------------------- drivers/staging/hv/hv_kvp.c | 7 ++++ drivers/staging/hv/hv_util.c | 55 +++++++++---------------------- 3 files changed, 23 insertions(+), 75 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index c68e5fad0f9..99cc334b794 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -181,24 +181,6 @@ void chn_cb_negotiate(void *context) struct icmsg_hdr *icmsghdrp; struct icmsg_negotiate *negop = NULL; - if (channel->util_index >= 0) { - /* - * This is a properly initialized util channel. - * Route this callback appropriately and setup state - * so that we don't need to reroute again. - */ - if (hv_cb_utils[channel->util_index].callback != NULL) { - /* - * The util driver has established a handler for - * this service; do the magic. - */ - channel->onchannel_callback = - hv_cb_utils[channel->util_index].callback; - (hv_cb_utils[channel->util_index].callback)(channel); - return; - } - } - buflen = PAGE_SIZE; buf = kmalloc(buflen, GFP_ATOMIC); @@ -348,7 +330,6 @@ static void vmbus_process_offer(struct work_struct *work) struct vmbus_channel *channel; bool fnew = true; int ret; - int cnt; unsigned long flags; /* The next possible work is rescind handling */ @@ -410,23 +391,6 @@ static void vmbus_process_offer(struct work_struct *work) * can cleanup properly */ newchannel->state = CHANNEL_OPEN_STATE; - newchannel->util_index = -1; /* Invalid index */ - - /* Open IC channels */ - for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) { - if (!uuid_le_cmp(newchannel->offermsg.offer.if_type, - hv_cb_utils[cnt].data) && - vmbus_open(newchannel, 2 * PAGE_SIZE, - 2 * PAGE_SIZE, NULL, 0, - chn_cb_negotiate, - newchannel) == 0) { - hv_cb_utils[cnt].channel = newchannel; - newchannel->util_index = cnt; - - pr_info("%s\n", hv_cb_utils[cnt].log_msg); - - } - } } } diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c index ff0d9ab2e4a..9aa9ede0ee8 100644 --- a/drivers/staging/hv/hv_kvp.c +++ b/drivers/staging/hv/hv_kvp.c @@ -177,6 +177,13 @@ kvp_respond_to_host(char *key, char *value, int error) channel = kvp_transaction.recv_channel; req_id = kvp_transaction.recv_req_id; + if (channel->onchannel_callback == NULL) + /* + * We have raced with util driver being unloaded; + * silently return. + */ + return; + icmsghdrp = (struct icmsg_hdr *) &recv_buffer[sizeof(struct vmbuspipe_hdr)]; kvp_msg = (struct hv_kvp_msg *) diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index a1539a7814d..faa66074cc2 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -269,19 +269,32 @@ static int util_probe(struct hv_device *dev, if (srv->util_init) { ret = srv->util_init(srv); if (ret) { - kfree(srv->recv_buffer); - return -ENODEV; + ret = -ENODEV; + goto error1; } } + ret = vmbus_open(dev->channel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0, + srv->util_cb, dev->channel); + if (ret) + goto error; + hv_set_drvdata(dev, srv); return 0; + +error: + if (srv->util_deinit) + srv->util_deinit(); +error1: + kfree(srv->recv_buffer); + return ret; } static int util_remove(struct hv_device *dev) { struct hv_util_service *srv = hv_get_drvdata(dev); + vmbus_close(dev->channel); if (srv->util_deinit) srv->util_deinit(); kfree(srv->recv_buffer); @@ -321,51 +334,15 @@ static struct hv_driver util_drv = { static int __init init_hyperv_utils(void) { - int ret; pr_info("Registering HyperV Utility Driver\n"); - - ret = vmbus_driver_register(&util_drv); - - if (ret != 0) - return ret; - - hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; - - hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; - - hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback; - - hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; - - return 0; - + return vmbus_driver_register(&util_drv); } static void exit_hyperv_utils(void) { pr_info("De-Registered HyperV Utility Driver\n"); - if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL) - hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL; - - if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL) - hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL; - - if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL) - hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL; - - if (hv_cb_utils[HV_KVP_MSG].channel != NULL) - hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_KVP_MSG].callback = NULL; - vmbus_driver_unregister(&util_drv); } From e0f4c6742bdbb2792bd67b147af9c1fd9176b94a Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sun, 18 Sep 2011 10:31:35 -0700 Subject: [PATCH 1123/1519] Staging: hv: vmbus: Get rid of hv_cb_utils[] and other unneeded code Now that the transformation of the util driver is complete, get rid of hv_cb_utils[] and other unneeded code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/channel_mgmt.c | 94 ------------------------------- drivers/staging/hv/hyperv.h | 13 ----- 2 files changed, 107 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 99cc334b794..9f007522a9d 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -158,100 +158,6 @@ void prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, } EXPORT_SYMBOL(prep_negotiate_resp); -/** - * chn_cb_negotiate() - Default handler for non IDE/SCSI/NETWORK - * Hyper-V requests - * @context: Pointer to argument structure. - * - * Set up the default handler for non device driver specific requests - * from Hyper-V. This stub responds to the default negotiate messages - * that come in for every non IDE/SCSI/Network request. - * This behavior is normally overwritten in the hv_utils driver. That - * driver handles requests like graceful shutdown, heartbeats etc. - * - * Mainly used by Hyper-V drivers. - */ -void chn_cb_negotiate(void *context) -{ - struct vmbus_channel *channel = context; - u8 *buf; - u32 buflen, recvlen; - u64 requestid; - - struct icmsg_hdr *icmsghdrp; - struct icmsg_negotiate *negop = NULL; - - buflen = PAGE_SIZE; - buf = kmalloc(buflen, GFP_ATOMIC); - - vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid); - - if (recvlen > 0) { - icmsghdrp = (struct icmsg_hdr *)&buf[ - sizeof(struct vmbuspipe_hdr)]; - - prep_negotiate_resp(icmsghdrp, negop, buf); - - icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION - | ICMSGHDRFLAG_RESPONSE; - - vmbus_sendpacket(channel, buf, - recvlen, requestid, - VM_PKT_DATA_INBAND, 0); - } - - kfree(buf); -} -EXPORT_SYMBOL(chn_cb_negotiate); - -/* - * Function table used for message responses for non IDE/SCSI/Network type - * messages. (Such as KVP/Shutdown etc) - */ -struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { - /* 0E0B6031-5213-4934-818B-38D90CED39DB */ - /* Shutdown */ - { - .msg_type = HV_SHUTDOWN_MSG, - .data.b = { - 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB - }, - .log_msg = "Shutdown channel functionality initialized" - }, - - /* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */ - /* TimeSync */ - { - .msg_type = HV_TIMESYNC_MSG, - .data.b = { - 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, - 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf - }, - .log_msg = "Timesync channel functionality initialized" - }, - /* {57164f39-9115-4e78-ab55-382f3bd5422d} */ - /* Heartbeat */ - { - .msg_type = HV_HEARTBEAT_MSG, - .data.b = { - 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, - 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d - }, - .log_msg = "Heartbeat channel functionality initialized" - }, - /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */ - /* KVP */ - { - .data.b = { - 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, - 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 - }, - .log_msg = "KVP channel functionality initialized" - }, -}; -EXPORT_SYMBOL(hv_cb_utils); - /* * alloc_channel - Allocate and initialize a vmbus channel object */ diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 5c3e297e11b..edaa9e2f58e 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -581,11 +581,6 @@ struct vmbus_channel { struct work_struct work; enum vmbus_channel_state state; - /* - * For util channels, stash the - * the service index for easy access. - */ - s8 util_index; struct vmbus_channel_offer_channel offermsg; /* @@ -960,12 +955,6 @@ struct ictimesync_data { u8 flags; } __packed; -/* Index for each IC struct in array hv_cb_utils[] */ -#define HV_SHUTDOWN_MSG 0 -#define HV_TIMESYNC_MSG 1 -#define HV_HEARTBEAT_MSG 2 -#define HV_KVP_MSG 3 - struct hyperv_service_callback { u8 msg_type; char *log_msg; @@ -976,7 +965,5 @@ struct hyperv_service_callback { extern void prep_negotiate_resp(struct icmsg_hdr *, struct icmsg_negotiate *, u8 *); -extern void chn_cb_negotiate(void *); -extern struct hyperv_service_callback hv_cb_utils[]; #endif /* _HYPERV_H */ From 40fbb290119a94434a7fa952d0492f2325663f94 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:38 -0700 Subject: [PATCH 1124/1519] staging: brcm80211: sparse endianness warnings on dongle events Structures received from dongle have been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 14 +++++------ drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 3 ++- .../staging/brcm80211/brcmfmac/dhd_common.c | 21 ++++++++-------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 24 +++++++++---------- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index da53dd02c33..c368f71cbbc 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -134,13 +134,13 @@ #define BRCMF_EVENT_MSG_GROUP 0x04 struct brcmf_event_msg { - u16 version; - u16 flags; - u32 event_type; - u32 status; - u32 reason; - u32 auth_type; - u32 datalen; + __be16 version; + __be16 flags; + __be32 event_type; + __be32 status; + __be32 reason; + __be32 auth_type; + __be32 datalen; u8 addr[ETH_ALEN]; char ifname[IFNAMSIZ]; } __packed; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 0d8389eaf60..6f65683b040 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -322,7 +322,8 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, /* Intercept the wme_dp ioctl here */ if (!ret && ioc->cmd == BRCMF_C_SET_VAR && !strcmp(ioc->buf, "wme_dp")) { - int slen, val = 0; + int slen; + __le32 val = 0; slen = strlen("wme_dp") + 1; if (len >= (int)(slen + sizeof(int))) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 02c022ab9ff..c9bf92a680b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -53,15 +53,15 @@ static const char brcmf_version[] = struct msgtrace_hdr { u8 version; u8 spare; - u16 len; /* Len of the trace */ - u32 seqnum; /* Sequence number of message. Useful + __be16 len; /* Len of the trace */ + __be32 seqnum; /* Sequence number of message. Useful * if the messsage has been lost * because of DMA error or a bus reset * (ex: SDIO Func2) */ - u32 discarded_bytes; /* Number of discarded bytes because of + __be32 discarded_bytes; /* Number of discarded bytes because of trace overflow */ - u32 discarded_printf; /* Number of discarded printf + __be32 discarded_printf; /* Number of discarded printf because of trace overflow */ } __packed; @@ -401,7 +401,7 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) case BRCMF_E_RSSI: brcmf_dbg(EVENT, "MACEVENT: %s %d\n", - event_name, be32_to_cpu(*((int *)event_data))); + event_name, be32_to_cpu(*((__be32 *)event_data))); break; default: @@ -498,14 +498,15 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, /* put it back to BRCMF_E_NDIS_LINK */ if (type == BRCMF_E_NDIS_LINK) { - u32 temp; + u32 temp1; + __be32 temp2; - temp = get_unaligned_be32(&event->event_type); + temp1 = get_unaligned_be32(&event->event_type); brcmf_dbg(TRACE, "Converted to WLC_E_LINK type %d\n", - temp); + temp1); - temp = be32_to_cpu(BRCMF_E_NDIS_LINK); - memcpy((void *)(&pvt_data->msg.event_type), &temp, + temp2 = cpu_to_be32(BRCMF_E_NDIS_LINK); + memcpy((void *)(&pvt_data->msg.event_type), &temp2, sizeof(pvt_data->msg.event_type)); } break; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 720f567bf6c..fb9b35105f5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -63,10 +63,10 @@ struct brcmf_trap { #define CBUF_LEN (128) -struct rte_log { - u32 buf; /* Can't be pointer on (64-bit) hosts */ - uint buf_size; - uint idx; +struct rte_log_le { + __le32 buf; /* Can't be pointer on (64-bit) hosts */ + __le32 buf_size; + __le32 idx; char *_buf_compat; /* Redundant pointer for backward compat. */ }; @@ -89,7 +89,7 @@ struct rte_console { * Output will be lost if the output wraps around faster than the host * polls. */ - struct rte_log log; + struct rte_log_le log_le; /* Console input line buffer * Characters are read one at a time into cbuf @@ -512,7 +512,7 @@ struct sdpcmd_regs { struct brcmf_console { uint count; /* Poll interval msec counter */ uint log_addr; /* Log struct address (fixed) */ - struct rte_log log; /* Log struct (host copy) */ + struct rte_log_le log_le; /* Log struct (host copy) */ uint bufsize; /* Size of log buffer */ u8 *buf; /* Log buffer (host copy) */ uint last; /* Last buffer read index */ @@ -3153,21 +3153,21 @@ static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) return 0; /* Read console log struct */ - addr = bus->console_addr + offsetof(struct rte_console, log); - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&c->log, - sizeof(c->log)); + addr = bus->console_addr + offsetof(struct rte_console, log_le); + rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&c->log_le, + sizeof(c->log_le)); if (rv < 0) return rv; /* Allocate console buffer (one time only) */ if (c->buf == NULL) { - c->bufsize = le32_to_cpu(c->log.buf_size); + c->bufsize = le32_to_cpu(c->log_le.buf_size); c->buf = kmalloc(c->bufsize, GFP_ATOMIC); if (c->buf == NULL) return -ENOMEM; } - idx = le32_to_cpu(c->log.idx); + idx = le32_to_cpu(c->log_le.idx); /* Protect against corrupt value */ if (idx > c->bufsize) @@ -3179,7 +3179,7 @@ static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) return 0; /* Read the console buffer */ - addr = le32_to_cpu(c->log.buf); + addr = le32_to_cpu(c->log_le.buf); rv = brcmf_sdbrcm_membytes(bus, false, addr, c->buf, c->bufsize); if (rv < 0) return rv; From 33db085d1e243f6009b3a0220ad8826bebf90bfd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:39 -0700 Subject: [PATCH 1125/1519] staging: brcm80211: various fulmac sparse endianness fixes Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 6 +++-- .../staging/brcm80211/brcmfmac/dhd_linux.c | 23 +++++++++++-------- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 19 ++++++++------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 12 +++++----- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 443e3a8ce2e..1cbdb80c023 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -401,7 +401,9 @@ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) /* read 24 bits and return valid 17 bit addr */ int i; u32 scratch, regdata; - u8 *ptr = (u8 *)&scratch; + __le32 scratch_le; + u8 *ptr = (u8 *)&scratch_le; + for (i = 0; i < 3; i++) { if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, ®data)) != SUCCESS) @@ -412,7 +414,7 @@ static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) } /* Only the lower 17-bits are valid */ - scratch = le32_to_cpu(scratch); + scratch = le32_to_cpu(scratch_le); scratch &= 0x0001FFFF; return scratch; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 9919fa5861a..e1d745640a3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -138,6 +138,8 @@ static void _brcmf_set_multicast_list(struct work_struct *work) struct net_device *dev; struct netdev_hw_addr *ha; u32 allmulti, cnt; + __le32 cnt_le; + __le32 allmulti_le; struct brcmf_ioctl ioc; char *buf, *bufp; @@ -166,9 +168,9 @@ static void _brcmf_set_multicast_list(struct work_struct *work) strcpy(bufp, "mcast_list"); bufp += strlen("mcast_list") + 1; - cnt = cpu_to_le32(cnt); - memcpy(bufp, &cnt, sizeof(cnt)); - bufp += sizeof(cnt); + cnt_le = cpu_to_le32(cnt); + memcpy(bufp, &cnt_le, sizeof(cnt)); + bufp += sizeof(cnt_le); netdev_for_each_mc_addr(ha, dev) { if (!cnt) @@ -205,10 +207,11 @@ static void _brcmf_set_multicast_list(struct work_struct *work) brcmf_ifname(&drvr_priv->pub, 0)); return; } - allmulti = cpu_to_le32(allmulti); + allmulti_le = cpu_to_le32(allmulti); if (!brcmu_mkiovar - ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) { + ("allmulti", (void *)&allmulti_le, + sizeof(allmulti_le), buf, buflen)) { brcmf_dbg(ERROR, "%s: mkiovar failed for allmulti, datalen %d buflen %u\n", brcmf_ifname(&drvr_priv->pub, 0), (int)sizeof(allmulti), buflen); @@ -226,7 +229,7 @@ static void _brcmf_set_multicast_list(struct work_struct *work) if (ret < 0) { brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", brcmf_ifname(&drvr_priv->pub, 0), - le32_to_cpu(allmulti)); + le32_to_cpu(allmulti_le)); } kfree(buf); @@ -235,19 +238,19 @@ static void _brcmf_set_multicast_list(struct work_struct *work) driver does */ allmulti = (dev->flags & IFF_PROMISC) ? true : false; - allmulti = cpu_to_le32(allmulti); + allmulti_le = cpu_to_le32(allmulti); memset(&ioc, 0, sizeof(ioc)); ioc.cmd = BRCMF_C_SET_PROMISC; - ioc.buf = &allmulti; - ioc.len = sizeof(allmulti); + ioc.buf = &allmulti_le; + ioc.len = sizeof(allmulti_le); ioc.set = true; ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set promisc %d failed\n", brcmf_ifname(&drvr_priv->pub, 0), - le32_to_cpu(allmulti)); + le32_to_cpu(allmulti_le)); } } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index fb9b35105f5..57001d4e73a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2361,8 +2361,8 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ len = (u16) (pkt->len); - *(u16 *) frame = cpu_to_le16(len); - *(((u16 *) frame) + 1) = cpu_to_le16(~len); + *(__le16 *) frame = cpu_to_le16(len); + *(((__le16 *) frame) + 1) = cpu_to_le16(~len); /* Software tag: channel, sequence number, data offset */ swheader = @@ -2917,16 +2917,17 @@ static int brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) { u32 addr; + __le32 addr_le; int rv; /* Read last word in memory to determine address of sdpcm_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, bus->ramsize - 4, (u8 *)&addr, + rv = brcmf_sdbrcm_membytes(bus, false, bus->ramsize - 4, (u8 *)&addr_le, 4); if (rv < 0) return rv; - addr = le32_to_cpu(addr); + addr = le32_to_cpu(addr_le); brcmf_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr); @@ -3273,8 +3274,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - *(u16 *) frame = cpu_to_le16((u16) msglen); - *(((u16 *) frame) + 1) = cpu_to_le16(~msglen); + *(__le16 *) frame = cpu_to_le16((u16) msglen); + *(((__le16 *) frame) + 1) = cpu_to_le16(~msglen); /* Software tag: channel, sequence number, data offset */ swheader = @@ -3466,6 +3467,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) u32 varaddr; u8 *vbuffer; u32 varsizew; + __le32 varsizew_le; #ifdef BCMDBG char *nvram_ularray; #endif /* BCMDBG */ @@ -3529,10 +3531,11 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) */ if (bcmerror) { varsizew = 0; + varsizew_le = cpu_to_le32(0); } else { varsizew = varsize / 4; varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF); - varsizew = cpu_to_le32(varsizew); + varsizew_le = cpu_to_le32(varsizew); } brcmf_dbg(INFO, "New varsize is %d, length token=0x%08x\n", @@ -3540,7 +3543,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) /* Write the length token to the last word */ bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->orig_ramsize - 4), - (u8 *)&varsizew, 4); + (u8 *)&varsizew_le, 4); return bcmerror; } diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 9e07f777558..b4befec704b 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -378,7 +378,7 @@ brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) { union { s8 buf[BRCMF_C_IOCTL_SMLEN]; - s32 val; + __le32 val; } var; u32 len; u32 data_null; @@ -890,11 +890,11 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, /* Configure Beacon Interval for starter */ if (params->beacon_interval) - bcnprd = cpu_to_le32(params->beacon_interval); + bcnprd = params->beacon_interval; else - bcnprd = cpu_to_le32(100); + bcnprd = 100; - err = brcmf_dev_ioctl(dev, BRCM_SET_BCNPRD, &bcnprd, sizeof(bcnprd)); + err = brcmf_dev_ioctl_u32(dev, BRCM_SET_BCNPRD, &bcnprd); if (unlikely(err)) { WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err); goto done; @@ -2029,7 +2029,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, goto CleanUp; } - *(u32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); + *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); if (unlikely(err)) { @@ -2098,7 +2098,7 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) ssid = (struct brcmf_ssid *)brcmf_read_prof(cfg_priv, WL_PROF_SSID); - *(u32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); + *(__le32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); if (unlikely(err)) { From 6e8e1264eef6a1907d75ea49cd5498bdf328d61c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:40 -0700 Subject: [PATCH 1126/1519] staging: brcm80211: sparse endianness warnings for struct brcmf_proto_cdc_ioctl Structure that is send/received to/from dongle has been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 6f65683b040..28bdf9e300a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -28,11 +28,11 @@ #include "dhd_dbg.h" struct brcmf_proto_cdc_ioctl { - u32 cmd; /* ioctl command value */ - u32 len; /* lower 16: output buflen; + __le32 cmd; /* ioctl command value */ + __le32 len; /* lower 16: output buflen; * upper 16: input buflen (excludes header) */ - u32 flags; /* flag defns given below */ - u32 status; /* status code returned from the device */ + __le32 flags; /* flag defns given below */ + __le32 status; /* status code returned from the device */ }; /* Max valid buffer size that can be sent to the dongle */ @@ -47,9 +47,6 @@ struct brcmf_proto_cdc_ioctl { #define CDCF_IOC_ID_SHIFT 16 /* ID Mask shift bits */ #define CDC_IOC_ID(flags) \ (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT) -#define CDC_SET_IF_IDX(hdr, idx) \ - ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | \ - ((idx) << CDCF_IOC_IF_SHIFT))) /* * BDC header - Broadcom specific extension of CDC. @@ -144,7 +141,7 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, struct brcmf_proto_cdc_ioctl *msg = &prot->msg; void *info; int ret = 0, retries = 0; - u32 id, flags = 0; + u32 id, flags; brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); @@ -165,9 +162,9 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, msg->cmd = cpu_to_le32(cmd); msg->len = cpu_to_le32(len); - msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT); - CDC_SET_IF_IDX(msg, ifidx); - msg->flags = cpu_to_le32(msg->flags); + flags = (++prot->reqid << CDCF_IOC_ID_SHIFT); + flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT); + msg->flags = cpu_to_le32(flags); if (buf) memcpy(prot->buf, buf, len); @@ -233,9 +230,9 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, msg->cmd = cpu_to_le32(cmd); msg->len = cpu_to_le32(len); - msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET; - CDC_SET_IF_IDX(msg, ifidx); - msg->flags = cpu_to_le32(msg->flags); + flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET; + flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT); + msg->flags = cpu_to_le32(flags); if (buf) memcpy(prot->buf, buf, len); From bd370bd7319469bd1a4317361b92b7adb37a1f2a Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:41 -0700 Subject: [PATCH 1127/1519] staging: brcm80211: sparse endianness warnings for struct sdpcm_shared Structure that is received from dongle has been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 57001d4e73a..9d4850d32d6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -530,6 +530,17 @@ struct sdpcm_shared { u8 tag[32]; }; +struct sdpcm_shared_le { + __le32 flags; + __le32 trap_addr; + __le32 assert_exp_addr; + __le32 assert_file_addr; + __le32 assert_line; + __le32 console_addr; /* Address of struct rte_console */ + __le32 msgtrace_addr; + u8 tag[32]; +}; + /* misc chip info needed by some of the routines */ struct chip_info { @@ -2919,6 +2930,7 @@ brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) u32 addr; __le32 addr_le; int rv; + struct sdpcm_shared_le sh_le; /* Read last word in memory to determine address of sdpcm_shared structure */ @@ -2942,19 +2954,20 @@ brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) } /* Read rte_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *) sh, - sizeof(struct sdpcm_shared)); + rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *) &sh_le, + sizeof(struct sdpcm_shared_le)); if (rv < 0) return rv; /* Endianness */ - sh->flags = le32_to_cpu(sh->flags); - sh->trap_addr = le32_to_cpu(sh->trap_addr); - sh->assert_exp_addr = le32_to_cpu(sh->assert_exp_addr); - sh->assert_file_addr = le32_to_cpu(sh->assert_file_addr); - sh->assert_line = le32_to_cpu(sh->assert_line); - sh->console_addr = le32_to_cpu(sh->console_addr); - sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr); + sh->flags = le32_to_cpu(sh_le.flags); + sh->trap_addr = le32_to_cpu(sh_le.trap_addr); + sh->assert_exp_addr = le32_to_cpu(sh_le.assert_exp_addr); + sh->assert_file_addr = le32_to_cpu(sh_le.assert_file_addr); + sh->assert_line = le32_to_cpu(sh_le.assert_line); + sh->console_addr = le32_to_cpu(sh_le.console_addr); + sh->msgtrace_addr = le32_to_cpu(sh_le.msgtrace_addr); + memcpy(sh->tag, sh_le.tag, sizeof(sh->tag)); if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { brcmf_dbg(ERROR, "sdpcm_shared version %d in brcmf is different than sdpcm_shared version %d in dongle\n", From d6a66afcf06b9b6d500e38ea8d53fe9fde47f81b Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:42 -0700 Subject: [PATCH 1128/1519] staging: brcm80211: more fullmac sparse endianness scan related changes Annotated endianness on structures send/received to/from dongle. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 25 ++++++-- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 64 ++++++++++--------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index c368f71cbbc..1e18ad0521d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -469,6 +469,13 @@ struct brcmf_scan_results { struct brcmf_bss_info bss_info[1]; }; +struct brcmf_scan_results_le { + __le32 buflen; + __le32 version; + __le32 count; + struct brcmf_bss_info bss_info[1]; +}; + /* used for association with a specific BSSID and chanspec list */ struct brcmf_assoc_params_le { /* 00:00:00:00:00:00: broadcast scan */ @@ -492,8 +499,14 @@ struct brcmf_join_params { /* incremental scan results struct */ struct brcmf_iscan_results { - u32 status; - struct brcmf_scan_results results; + union { + u32 status; + __le32 status_le; + }; + union { + struct brcmf_scan_results results; + struct brcmf_scan_results_le results_le; + }; }; /* size of brcmf_iscan_results not including variable length array */ @@ -549,10 +562,10 @@ struct brcmf_scb_val_le { }; /* channel encoding */ -struct brcmf_channel_info { - int hw_channel; - int target_channel; - int scan_channel; +struct brcmf_channel_info_le { + __le32 hw_channel; + __le32 target_channel; + __le32 scan_channel; }; /* Linux network driver ioctl encoding */ diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index b4befec704b..5e86e21adca 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2201,18 +2201,20 @@ brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, { struct brcmf_iscan_results list; struct brcmf_scan_results *results; + struct brcmf_scan_results_le *results_le; struct brcmf_iscan_results *list_buf; s32 err = 0; memset(iscan->scan_buf, 0, WL_ISCAN_BUF_MAX); list_buf = (struct brcmf_iscan_results *)iscan->scan_buf; results = &list_buf->results; + results_le = &list_buf->results_le; results->buflen = BRCMF_ISCAN_RESULTS_FIXED_SIZE; results->version = 0; results->count = 0; memset(&list, 0, sizeof(list)); - list.results.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); + list.results_le.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); err = brcmf_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, BRCMF_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, WL_ISCAN_BUF_MAX); @@ -2220,12 +2222,12 @@ brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, WL_ERR("error (%d)\n", err); return err; } - results->buflen = le32_to_cpu(results->buflen); - results->version = le32_to_cpu(results->version); - results->count = le32_to_cpu(results->count); - WL_SCAN("results->count = %d\n", results->count); - WL_SCAN("results->buflen = %d\n", results->buflen); - *status = le32_to_cpu(list_buf->status); + results->buflen = le32_to_cpu(results_le->buflen); + results->version = le32_to_cpu(results_le->version); + results->count = le32_to_cpu(results_le->count); + WL_SCAN("results->count = %d\n", results_le->count); + WL_SCAN("results->buflen = %d\n", results_le->buflen); + *status = le32_to_cpu(list_buf->status_le); WL_SCAN("status = %d\n", *status); *bss_list = results; @@ -2848,11 +2850,12 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, { struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct brcmf_channel_info channel; + struct brcmf_channel_info_le channel_le; struct ieee80211_channel *notify_channel; struct ieee80211_supported_band *band; u32 freq; s32 err = 0; + u32 target_channel; WL_TRACE("Enter\n"); @@ -2860,18 +2863,18 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, brcmf_update_prof(cfg_priv, NULL, &e->addr, WL_PROF_BSSID); brcmf_update_bss_info(cfg_priv); - brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel, sizeof(channel)); + brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_le, + sizeof(channel_le)); - channel.target_channel = le32_to_cpu(channel.target_channel); - WL_CONN("Roamed to channel %d\n", channel.target_channel); + target_channel = le32_to_cpu(channel_le.target_channel); + WL_CONN("Roamed to channel %d\n", target_channel); - if (channel.target_channel <= CH_MAX_2G_CHANNEL) + if (target_channel <= CH_MAX_2G_CHANNEL) band = wiphy->bands[IEEE80211_BAND_2GHZ]; else band = wiphy->bands[IEEE80211_BAND_5GHZ]; - freq = ieee80211_channel_to_frequency(channel.target_channel, - band->band); + freq = ieee80211_channel_to_frequency(target_channel, band->band); notify_channel = ieee80211_get_channel(wiphy, freq); cfg80211_roamed(ndev, notify_channel, @@ -3011,11 +3014,12 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, struct net_device *ndev, const struct brcmf_event_msg *e, void *data) { - struct brcmf_channel_info channel_inform; - struct brcmf_scan_results *bss_list; + struct brcmf_channel_info_le channel_inform_le; + struct brcmf_scan_results_le *bss_list_le; u32 len = WL_SCAN_BUF_MAX; s32 err = 0; bool scan_abort = false; + u32 scan_channel; WL_TRACE("Enter\n"); @@ -3032,34 +3036,32 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, goto scan_done_out; } - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_inform, - sizeof(channel_inform)); + err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_inform_le, + sizeof(channel_inform_le)); if (unlikely(err)) { WL_ERR("scan busy (%d)\n", err); scan_abort = true; goto scan_done_out; } - channel_inform.scan_channel = le32_to_cpu(channel_inform.scan_channel); - if (unlikely(channel_inform.scan_channel)) { - - WL_CONN("channel_inform.scan_channel (%d)\n", - channel_inform.scan_channel); - } + scan_channel = le32_to_cpu(channel_inform_le.scan_channel); + if (unlikely(scan_channel)) + WL_CONN("channel_inform.scan_channel (%d)\n", scan_channel); cfg_priv->bss_list = cfg_priv->scan_results; - bss_list = cfg_priv->bss_list; - memset(bss_list, 0, len); - bss_list->buflen = cpu_to_le32(len); + bss_list_le = (struct brcmf_scan_results_le *) cfg_priv->bss_list; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN_RESULTS, bss_list, len); + memset(cfg_priv->scan_results, 0, len); + bss_list_le->buflen = cpu_to_le32(len); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN_RESULTS, + cfg_priv->scan_results, len); if (unlikely(err)) { WL_ERR("%s Scan_results error (%d)\n", ndev->name, err); err = -EINVAL; scan_abort = true; goto scan_done_out; } - bss_list->buflen = le32_to_cpu(bss_list->buflen); - bss_list->version = le32_to_cpu(bss_list->version); - bss_list->count = le32_to_cpu(bss_list->count); + cfg_priv->scan_results->buflen = le32_to_cpu(bss_list_le->buflen); + cfg_priv->scan_results->version = le32_to_cpu(bss_list_le->version); + cfg_priv->scan_results->count = le32_to_cpu(bss_list_le->count); err = brcmf_inform_bss(cfg_priv); if (err) { From 6fc1fbc00419ebcef0fac1ed6ece8a5939541b7a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 22 Sep 2011 17:07:43 -0700 Subject: [PATCH 1129/1519] staging: brcm80211: remove unconditional code blocks from brcmfmac Using a block statement to scope function variables is not common in linux kernel development. Browsed through the brcmfmac to remove those. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_common.c | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index c9bf92a680b..0c41c1c26c1 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -198,6 +198,11 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) BRCMF_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"} }; uint event_type, flags, auth_type, datalen; + static u32 seqnum_prev; + struct msgtrace_hdr hdr; + u32 nblost; + char *s, *p; + event_type = be32_to_cpu(event->event_type); flags = be16_to_cpu(event->flags); status = be32_to_cpu(event->status); @@ -348,55 +353,52 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) break; case BRCMF_E_TRACE: - { - static u32 seqnum_prev; - struct msgtrace_hdr hdr; - u32 nblost; - char *s, *p; - - buf = (unsigned char *) event_data; - memcpy(&hdr, buf, sizeof(struct msgtrace_hdr)); - - if (hdr.version != MSGTRACE_VERSION) { - brcmf_dbg(ERROR, "MACEVENT: %s [unsupported version --> brcmf version:%d dongle version:%d]\n", - event_name, - MSGTRACE_VERSION, hdr.version); - /* Reset datalen to avoid display below */ - datalen = 0; - break; - } - - /* There are 2 bytes available at the end of data */ - *(buf + sizeof(struct msgtrace_hdr) - + be16_to_cpu(hdr.len)) = '\0'; - - if (be32_to_cpu(hdr.discarded_bytes) - || be32_to_cpu(hdr.discarded_printf)) - brcmf_dbg(ERROR, "WLC_E_TRACE: [Discarded traces in dongle --> discarded_bytes %d discarded_printf %d]\n", - be32_to_cpu(hdr.discarded_bytes), - be32_to_cpu(hdr.discarded_printf)); - - nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; - if (nblost > 0) - brcmf_dbg(ERROR, "WLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n", - be32_to_cpu(hdr.seqnum), nblost); - seqnum_prev = be32_to_cpu(hdr.seqnum); - - /* Display the trace buffer. Advance from \n to \n to - * avoid display big - * printf (issue with Linux printk ) - */ - p = (char *)&buf[sizeof(struct msgtrace_hdr)]; - while ((s = strstr(p, "\n")) != NULL) { - *s = '\0'; - printk(KERN_DEBUG"%s\n", p); - p = s + 1; - } - printk(KERN_DEBUG "%s\n", p); + buf = (unsigned char *) event_data; + memcpy(&hdr, buf, sizeof(struct msgtrace_hdr)); + if (hdr.version != MSGTRACE_VERSION) { + brcmf_dbg(ERROR, + "MACEVENT: %s [unsupported version --> brcmf" + " version:%d dongle version:%d]\n", + event_name, MSGTRACE_VERSION, hdr.version); /* Reset datalen to avoid display below */ datalen = 0; + break; } + + /* There are 2 bytes available at the end of data */ + *(buf + sizeof(struct msgtrace_hdr) + + be16_to_cpu(hdr.len)) = '\0'; + + if (be32_to_cpu(hdr.discarded_bytes) + || be32_to_cpu(hdr.discarded_printf)) + brcmf_dbg(ERROR, + "WLC_E_TRACE: [Discarded traces in dongle -->" + " discarded_bytes %d discarded_printf %d]\n", + be32_to_cpu(hdr.discarded_bytes), + be32_to_cpu(hdr.discarded_printf)); + + nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; + if (nblost > 0) + brcmf_dbg(ERROR, "WLC_E_TRACE: [Event lost --> seqnum " + " %d nblost %d\n", be32_to_cpu(hdr.seqnum), + nblost); + seqnum_prev = be32_to_cpu(hdr.seqnum); + + /* Display the trace buffer. Advance from \n to \n to + * avoid display big + * printf (issue with Linux printk ) + */ + p = (char *)&buf[sizeof(struct msgtrace_hdr)]; + while ((s = strstr(p, "\n")) != NULL) { + *s = '\0'; + printk(KERN_DEBUG"%s\n", p); + p = s + 1; + } + printk(KERN_DEBUG "%s\n", p); + + /* Reset datalen to avoid display below */ + datalen = 0; break; case BRCMF_E_RSSI: @@ -405,8 +407,9 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) break; default: - brcmf_dbg(EVENT, "MACEVENT: %s %d, MAC %s, status %d, reason %d, auth %d\n", - event_name, event_type, eabuf, + brcmf_dbg(EVENT, + "MACEVENT: %s %d, MAC %s, status %d, reason %d, " + "auth %d\n", event_name, event_type, eabuf, (int)status, (int)reason, (int)auth_type); break; } @@ -428,6 +431,7 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, { /* check whether packet is a BRCM event pkt */ struct brcmf_event *pvt_data = (struct brcmf_event *) pktdata; + struct brcmf_if_event *ifevent; char *event_data; u32 type, status; u16 flags; @@ -459,26 +463,22 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, switch (type) { case BRCMF_E_IF: - { - struct brcmf_if_event *ifevent = - (struct brcmf_if_event *) event_data; - brcmf_dbg(TRACE, "if event\n"); + ifevent = (struct brcmf_if_event *) event_data; + brcmf_dbg(TRACE, "if event\n"); - if (ifevent->ifidx > 0 && - ifevent->ifidx < BRCMF_MAX_IFS) { - if (ifevent->action == BRCMF_E_IF_ADD) - brcmf_add_if(drvr_priv, ifevent->ifidx, - NULL, event->ifname, - pvt_data->eth.h_dest, - ifevent->flags, - ifevent->bssidx); - else - brcmf_del_if(drvr_priv, ifevent->ifidx); - } else { - brcmf_dbg(ERROR, "Invalid ifidx %d for %s\n", - ifevent->ifidx, event->ifname); - } + if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { + if (ifevent->action == BRCMF_E_IF_ADD) + brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, + event->ifname, + pvt_data->eth.h_dest, + ifevent->flags, ifevent->bssidx); + else + brcmf_del_if(drvr_priv, ifevent->ifidx); + } else { + brcmf_dbg(ERROR, "Invalid ifidx %d for %s\n", + ifevent->ifidx, event->ifname); } + /* send up the if event: btamp user needs it */ *ifidx = brcmf_ifname2idx(drvr_priv, event->ifname); break; From 6a5e1e00bad78c567626a24c57f66314ec6a3a92 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:44 -0700 Subject: [PATCH 1130/1519] staging: brcm80211: remove event handler thread from fullmac Use work queue to defer cfg80211 event handle jobs Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 85 +++++-------------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 3 +- 2 files changed, 21 insertions(+), 67 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 5e86e21adca..2dd28a240bd 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3248,69 +3248,30 @@ static void brcmf_put_event(struct brcmf_cfg80211_event_q *e) kfree(e); } -static s32 brcmf_event_handler(void *data) +static void brcmf_cfg80211_event_handler(struct work_struct *work) { struct brcmf_cfg80211_priv *cfg_priv = - (struct brcmf_cfg80211_priv *)data; - struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; + container_of(work, struct brcmf_cfg80211_priv, + event_work); struct brcmf_cfg80211_event_q *e; - DECLARE_WAITQUEUE(wait, current); - sched_setscheduler(current, SCHED_FIFO, ¶m); - allow_signal(SIGTERM); - add_wait_queue(&cfg_priv->event_waitq, &wait); - while (1) { - prepare_to_wait(&cfg_priv->event_waitq, &wait, - TASK_INTERRUPTIBLE); - - schedule(); - - if (kthread_should_stop()) - break; - - e = brcmf_deq_event(cfg_priv); - if (unlikely(!e)) { - WL_ERR("event queue empty...\n"); - continue; - } - - do { - WL_INFO("event type (%d)\n", e->etype); - if (cfg_priv->el.handler[e->etype]) - cfg_priv->el.handler[e->etype](cfg_priv, - cfg_to_ndev(cfg_priv), - &e->emsg, e->edata); - else - WL_INFO("Unknown Event (%d): ignoring\n", - e->etype); - brcmf_put_event(e); - } while ((e = brcmf_deq_event(cfg_priv))); + e = brcmf_deq_event(cfg_priv); + if (unlikely(!e)) { + WL_ERR("event queue empty...\n"); + return; } - finish_wait(&cfg_priv->event_waitq, &wait); - WL_INFO("was terminated\n"); - return 0; -} -static s32 brcmf_create_event_handler(struct brcmf_cfg80211_priv *cfg_priv) -{ - init_waitqueue_head(&cfg_priv->event_waitq); - cfg_priv->event_tsk = kthread_run(brcmf_event_handler, cfg_priv, - "wl_event_handler"); - if (IS_ERR(cfg_priv->event_tsk)) { - cfg_priv->event_tsk = NULL; - WL_ERR("failed to create event thread\n"); - return -ENOMEM; - } - return 0; -} + do { + WL_INFO("event type (%d)\n", e->etype); + if (cfg_priv->el.handler[e->etype]) + cfg_priv->el.handler[e->etype](cfg_priv, + cfg_to_ndev(cfg_priv), + &e->emsg, e->edata); + else + WL_INFO("Unknown Event (%d): ignoring\n", e->etype); + brcmf_put_event(e); + } while ((e = brcmf_deq_event(cfg_priv))); -static void brcmf_destroy_event_handler(struct brcmf_cfg80211_priv *cfg_priv) -{ - if (cfg_priv->event_tsk) { - send_sig(SIGTERM, cfg_priv->event_tsk, 1); - kthread_stop(cfg_priv->event_tsk); - cfg_priv->event_tsk = NULL; - } } static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv) @@ -3352,8 +3313,7 @@ static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) err = brcmf_init_priv_mem(cfg_priv); if (unlikely(err)) return err; - if (unlikely(brcmf_create_event_handler(cfg_priv))) - return -ENOMEM; + INIT_WORK(&cfg_priv->event_work, brcmf_cfg80211_event_handler); brcmf_init_eloop_handler(&cfg_priv->el); mutex_init(&cfg_priv->usr_sync); err = brcmf_init_iscan(cfg_priv); @@ -3368,7 +3328,7 @@ static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) static void wl_deinit_priv(struct brcmf_cfg80211_priv *cfg_priv) { - brcmf_destroy_event_handler(cfg_priv); + cancel_work_sync(&cfg_priv->event_work); cfg_priv->dongle_up = false; /* dongle down */ brcmf_flush_eq(cfg_priv); brcmf_link_down(cfg_priv); @@ -3438,11 +3398,6 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg_dev) kfree(cfg_dev); } -static void brcmf_wakeup_event(struct brcmf_cfg80211_priv *cfg_priv) -{ - wake_up(&cfg_priv->event_waitq); -} - void brcmf_cfg80211_event(struct net_device *ndev, const struct brcmf_event_msg *e, void *data) @@ -3451,7 +3406,7 @@ brcmf_cfg80211_event(struct net_device *ndev, struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); if (likely(!brcmf_enq_event(cfg_priv, event_type, e))) - brcmf_wakeup_event(cfg_priv); + schedule_work(&cfg_priv->event_work); } static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index d27d4e6f943..79806c0bb9e 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -298,8 +298,7 @@ struct brcmf_cfg80211_priv { struct brcmf_cfg80211_iscan_ctrl *iscan; /* iscan controller */ struct brcmf_cfg80211_connect_info conn_info; /* association info */ struct brcmf_cfg80211_pmk_list *pmk_list; /* wpa2 pmk list */ - struct task_struct *event_tsk; /* task of main event handler thread */ - wait_queue_head_t event_waitq; /* wait queue for main event handling */ + struct work_struct event_work; /* event handler work struct */ unsigned long status; /* current dongle status */ void *pub; u32 channel; /* current channel */ From 9ca59c6f70b77b07085e8b9785b24f76aa87634c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:45 -0700 Subject: [PATCH 1131/1519] staging: brcm80211: remove fullmac module_param brcmf_dongle_memsize remove unused module parameter brcmf_dongle_memsize and related code Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 3 -- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 35 +++---------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index aa05b1c5fdc..d02cb10657c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -24,9 +24,6 @@ * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) */ -/* dongle ram module parameter */ -extern int brcmf_dongle_memsize; - /* Tx/Rx bounds module parameters */ extern uint brcmf_txbound; extern uint brcmf_rxbound; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 9d4850d32d6..7090a3670a6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -568,7 +568,6 @@ struct brcmf_bus { uint varsz; /* Size of variables buffer */ u32 ramsize; /* Size of RAM in SOCRAM (bytes) */ - u32 orig_ramsize; /* Size of RAM in SOCRAM (bytes) */ u32 hostintmask; /* Copy of Host Interrupt Mask */ u32 intstatus; /* Intstatus bits (events) pending */ @@ -772,11 +771,6 @@ module_param(brcmf_poll, uint, 0); uint brcmf_intr = true; module_param(brcmf_intr, uint, 0); -/* override the RAM size if possible */ -#define DONGLE_MIN_MEMSIZE (128 * 1024) -int brcmf_dongle_memsize; -module_param(brcmf_dongle_memsize, int, 0); - #define RETRYCHAN(chan) ((chan) == SDPCM_EVENT_CHANNEL) /* Retry count for register access failures */ @@ -857,17 +851,6 @@ static void brcmf_sdbrcm_pktfree2(struct brcmf_bus *bus, struct sk_buff *pkt) brcmu_pkt_buf_free_skb(pkt); } -static void brcmf_sdbrcm_setmemsize(struct brcmf_bus *bus, int mem_size) -{ - s32 min_size = DONGLE_MIN_MEMSIZE; - /* Restrict the memsize to user specified limit */ - brcmf_dbg(ERROR, "user: Restrict the dongle ram size to %d, min %d\n", - brcmf_dongle_memsize, min_size); - if ((brcmf_dongle_memsize > min_size) && - (brcmf_dongle_memsize < (s32) bus->orig_ramsize)) - bus->ramsize = brcmf_dongle_memsize; -} - static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus) { if (bus->threads_only) @@ -3531,11 +3514,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) } /* adjust to the user specified RAM */ - brcmf_dbg(INFO, "Physical memory size: %d, usable memory size: %d\n", - bus->orig_ramsize, bus->ramsize); + brcmf_dbg(INFO, "Physical memory size: %d\n", bus->ramsize); brcmf_dbg(INFO, "Vars are at %d, orig varsize is %d\n", varaddr, varsize); - varsize = ((bus->orig_ramsize - 4) - varaddr); + varsize = ((bus->ramsize - 4) - varaddr); /* * Determine the length token: @@ -3555,7 +3537,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) varsize, varsizew); /* Write the length token to the last word */ - bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->orig_ramsize - 4), + bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->ramsize - 4), (u8 *)&varsizew_le, 4); return bcmerror; @@ -4630,17 +4612,11 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) /* Get info on the ARM and SOCRAM cores... */ brcmf_sdcard_reg_read(bus->sdiodev, CORE_SB(bus->ci->armcorebase, sbidhigh), 4); - bus->orig_ramsize = bus->ci->ramsize; - if (!(bus->orig_ramsize)) { + bus->ramsize = bus->ci->ramsize; + if (!(bus->ramsize)) { brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); goto fail; } - bus->ramsize = bus->orig_ramsize; - if (brcmf_dongle_memsize) - brcmf_sdbrcm_setmemsize(bus, brcmf_dongle_memsize); - - brcmf_dbg(ERROR, "DHD: dongle ram size is set to %d(orig %d)\n", - bus->ramsize, bus->orig_ramsize); /* Set core control so an SDIO reset does a backplane reset */ reg_addr = bus->ci->buscorebase + @@ -4819,7 +4795,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, */ brcmf_txbound = BRCMF_TXBOUND; brcmf_rxbound = BRCMF_RXBOUND; - brcmf_dongle_memsize = 0; brcmf_txminmax = BRCMF_TXMINMAX; brcmf_c_init(); From ab8c7bf5456d4334e6f78566d0d09fb547903dac Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:46 -0700 Subject: [PATCH 1132/1519] staging: brcm80211: remove fullmac module_param brcmf_sdiod_drive_strength Replaced the global variable with constant Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 7090a3670a6..53de5a7bda0 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -759,9 +759,7 @@ static uint brcmf_txminmax; int brcmf_idletime = 1; module_param(brcmf_idletime, int, 0); -/* SDIO Drive Strength (in milliamps) */ -uint brcmf_sdiod_drive_strength = 6; -module_param(brcmf_sdiod_drive_strength, uint, 0); +#define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ /* Use polling */ uint brcmf_poll; @@ -4607,7 +4605,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) goto fail; } - brcmf_sdbrcm_sdiod_drive_strength_init(bus, brcmf_sdiod_drive_strength); + brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); /* Get info on the ARM and SOCRAM cores... */ brcmf_sdcard_reg_read(bus->sdiodev, From 823a937e36ab4318d6783374d121b75fb6c54b61 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:47 -0700 Subject: [PATCH 1133/1519] staging: brcm80211: remove fullmac module_param for watchdog Use constant to replace global variable used for watchdog polling Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 6 +-- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 45 +++++++------------ 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index d9d1592c446..5906337780b 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -375,7 +375,7 @@ void brcmf_sdio_unregister(void) void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable) { if (enable) - brcmf_sdbrcm_wd_timer(sdiodev->bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS); else brcmf_sdbrcm_wd_timer(sdiodev->bus, 0); } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index d02cb10657c..104c0e739be 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -20,6 +20,9 @@ /* Packet alignment for most efficient SDIO (can change based on platform) */ #define BRCMF_SDALIGN (1 << 6) +/* watchdog polling interval in ms */ +#define BRCMF_WD_POLL_MS 10 + /* * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) */ @@ -28,9 +31,6 @@ extern uint brcmf_txbound; extern uint brcmf_rxbound; -/* Watchdog timer interval */ -extern uint brcmf_watchdog_ms; - /* Indicate (dis)interest in finding dongles. */ extern int brcmf_bus_register(void); extern void brcmf_bus_unregister(void); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 53de5a7bda0..4033e734d35 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -612,6 +612,7 @@ struct brcmf_bus { uint pollcnt; /* Count of active polls */ #ifdef BCMDBG + uint console_interval; struct brcmf_console console; /* Console output polling support */ uint console_addr; /* Console address from shared struct */ #endif /* BCMDBG */ @@ -735,20 +736,10 @@ static int tx_packets[NUMPRIO]; int brcmf_watchdog_prio = 97; module_param(brcmf_watchdog_prio, int, 0); -/* Watchdog interval */ -uint brcmf_watchdog_ms = 10; -module_param(brcmf_watchdog_ms, uint, 0); - /* DPC thread priority, -1 to use tasklet */ int brcmf_dpc_prio = 98; module_param(brcmf_dpc_prio, int, 0); -#ifdef BCMDBG -/* Console poll interval */ -uint brcmf_console_ms; -module_param(brcmf_console_ms, uint, 0); -#endif /* BCMDBG */ - /* Tx/Rx bounds */ uint brcmf_txbound; uint brcmf_rxbound; @@ -1023,7 +1014,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) /* Early exit if we're already there */ if (bus->clkstate == target) { if (target == CLK_AVAIL) { - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); bus->activity = true; } return 0; @@ -1036,7 +1027,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) brcmf_sdbrcm_sdclk(bus, true); /* Now request HT Avail on the backplane */ brcmf_sdbrcm_htclk(bus, true, pendok); - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); bus->activity = true; break; @@ -1049,7 +1040,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) else brcmf_dbg(ERROR, "request for %d -> %d\n", bus->clkstate, target); - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); break; case CLK_NONE: @@ -4038,7 +4029,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) /* Start the watchdog timer */ bus->drvr->tickcnt = 0; - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); if (enforce_mutex) brcmf_sdbrcm_sdlock(bus); @@ -4207,15 +4198,15 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) } #ifdef BCMDBG /* Poll for console output periodically */ - if (drvr->busstate == BRCMF_BUS_DATA && brcmf_console_ms != 0) { - bus->console.count += brcmf_watchdog_ms; - if (bus->console.count >= brcmf_console_ms) { - bus->console.count -= brcmf_console_ms; + if (drvr->busstate == BRCMF_BUS_DATA && bus->console_interval != 0) { + bus->console.count += BRCMF_WD_POLL_MS; + if (bus->console.count >= bus->console_interval) { + bus->console.count -= bus->console_interval; /* Make sure backplane clock is on */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); if (brcmf_sdbrcm_readconsole(bus) < 0) - brcmf_console_ms = 0; /* On error, - stop trying */ + /* stop on error */ + bus->console_interval = 0; } } #endif /* BCMDBG */ @@ -4226,7 +4217,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) bus->idlecount = 0; if (bus->activity) { bus->activity = false; - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); } else { brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); } @@ -4723,7 +4714,7 @@ brcmf_sdbrcm_watchdog(unsigned long data) /* Reschedule the watchdog */ if (bus->wd_timer_valid) - mod_timer(&bus->timer, jiffies + brcmf_watchdog_ms * HZ / 1000); + mod_timer(&bus->timer, jiffies + BRCMF_WD_POLL_MS * HZ / 1000); } static void @@ -5017,7 +5008,7 @@ int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) brcmf_dbg(ERROR, "Set DEVRESET=false invoked when device is on\n"); bcmerror = -EIO; } - brcmf_sdbrcm_wd_timer(bus, brcmf_watchdog_ms); + brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); } return bcmerror; } @@ -5038,9 +5029,7 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) } if (wdtick) { - brcmf_watchdog_ms = (uint) wdtick; - - if (bus->save_ms != brcmf_watchdog_ms) { + if (bus->save_ms != BRCMF_WD_POLL_MS) { if (bus->wd_timer_valid == true) /* Stop timer and restart at new value */ del_timer_sync(&bus->timer); @@ -5049,13 +5038,13 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) dynamically changed or in the first instance */ bus->timer.expires = - jiffies + brcmf_watchdog_ms * HZ / 1000; + jiffies + BRCMF_WD_POLL_MS * HZ / 1000; add_timer(&bus->timer); } else { /* Re arm the timer, at last watchdog period */ mod_timer(&bus->timer, - jiffies + brcmf_watchdog_ms * HZ / 1000); + jiffies + BRCMF_WD_POLL_MS * HZ / 1000); } bus->wd_timer_valid = true; From c5d3cc0288cfecab34ed37623c37c72a679a167c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:48 -0700 Subject: [PATCH 1134/1519] staging: brcm80211: remove fullmac module_param brcmf_idletime Use constant for idle time setting. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 1 + drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 1e18ad0521d..7ca917203a9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -808,5 +808,6 @@ extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, #define BRCMF_IDLE_IMMEDIATE (-1) #define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change when idle */ +#define BRCMF_IDLE_INTERVAL 1 #endif /* _BRCMF_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 4033e734d35..57049eceb14 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -747,9 +747,6 @@ module_param(brcmf_txbound, uint, 0); module_param(brcmf_rxbound, uint, 0); static uint brcmf_txminmax; -int brcmf_idletime = 1; -module_param(brcmf_idletime, int, 0); - #define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ /* Use polling */ @@ -4650,7 +4647,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) /* ...and initialize clock/power states */ bus->clkstate = CLK_SDONLY; - bus->idletime = (s32) brcmf_idletime; + bus->idletime = BRCMF_IDLE_INTERVAL; bus->idleclock = BRCMF_IDLE_ACTIVE; /* Query the F2 block size, set roundup accordingly */ From 191e2becd08aad769da307c03a65f154053ea2b9 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 22 Sep 2011 17:07:49 -0700 Subject: [PATCH 1135/1519] staging: brcm80211: remove global variables for data frame boundary Put boundary settings in brcmf_bus structure Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 4 ---- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 24 ++++++++----------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index 104c0e739be..a5064f562e4 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -27,10 +27,6 @@ * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) */ -/* Tx/Rx bounds module parameters */ -extern uint brcmf_txbound; -extern uint brcmf_rxbound; - /* Indicate (dis)interest in finding dongles. */ extern int brcmf_bus_register(void); extern void brcmf_bus_unregister(void); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 57049eceb14..66ab752a65c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -588,6 +588,10 @@ struct brcmf_bus { u8 rx_seq; /* Receive sequence number (expected) */ bool rxskip; /* Skip receive (awaiting NAK ACK) */ + uint rxbound; /* Rx frames to read before resched */ + uint txbound; /* Tx frames to send before resched */ + uint txminmax; + struct sk_buff *glomd; /* Packet containing glomming descriptor */ struct sk_buff *glom; /* Packet chain for glommed superframe */ uint glomerr; /* Glom packet read errors */ @@ -740,13 +744,6 @@ module_param(brcmf_watchdog_prio, int, 0); int brcmf_dpc_prio = 98; module_param(brcmf_dpc_prio, int, 0); -/* Tx/Rx bounds */ -uint brcmf_txbound; -uint brcmf_rxbound; -module_param(brcmf_txbound, uint, 0); -module_param(brcmf_rxbound, uint, 0); -static uint brcmf_txminmax; - #define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ /* Use polling */ @@ -2488,8 +2485,8 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) { u32 intstatus, newstatus = 0; uint retries = 0; - uint rxlimit = brcmf_rxbound; /* Rx frames to read before resched */ - uint txlimit = brcmf_txbound; /* Tx frames to send before resched */ + uint rxlimit = bus->rxbound; /* Rx frames to read before resched */ + uint txlimit = bus->txbound; /* Tx frames to send before resched */ uint framecnt = 0; /* Temporary counter of tx/rx frames */ bool rxdone = true; /* Flag for no more read data */ bool resched = false; /* Flag indicating resched wanted */ @@ -2690,7 +2687,7 @@ clkwait: else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit && data_ok(bus)) { - framecnt = rxdone ? txlimit : min(txlimit, brcmf_txminmax); + framecnt = rxdone ? txlimit : min(txlimit, bus->txminmax); framecnt = brcmf_sdbrcm_sendfromq(bus, framecnt); txlimit -= framecnt; } @@ -4779,10 +4776,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, * first time that the driver is initialized vs subsequent * initializations. */ - brcmf_txbound = BRCMF_TXBOUND; - brcmf_rxbound = BRCMF_RXBOUND; - brcmf_txminmax = BRCMF_TXMINMAX; - brcmf_c_init(); brcmf_dbg(TRACE, "Enter\n"); @@ -4798,6 +4791,9 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, } bus->sdiodev = sdiodev; sdiodev->bus = bus; + bus->txbound = BRCMF_TXBOUND; + bus->rxbound = BRCMF_RXBOUND; + bus->txminmax = BRCMF_TXMINMAX; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ From 201d7a38e6a7bf449d088a9eb4a34cfa4cbd42b6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:50 -0700 Subject: [PATCH 1136/1519] staging: brcm80211: removed two fullmac sparse spinlock warnings By deleting three redundant functions. The spinlock was related to event queue operation. Event queue data members were also renamed to make their function more clear. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 49 +++++++------------ .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 6 +-- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 2dd28a240bd..0bda00c07e2 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -3181,21 +3181,6 @@ init_priv_mem_out: return -ENOMEM; } -static void brcmf_lock_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_lock_irq(&cfg_priv->eq_lock); -} - -static void brcmf_unlock_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_unlock_irq(&cfg_priv->eq_lock); -} - -static void brcmf_init_eq_lock(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_lock_init(&cfg_priv->eq_lock); -} - /* * retrieve first queued event from head */ @@ -3205,13 +3190,13 @@ static struct brcmf_cfg80211_event_q *brcmf_deq_event( { struct brcmf_cfg80211_event_q *e = NULL; - brcmf_lock_eq(cfg_priv); - if (likely(!list_empty(&cfg_priv->eq_list))) { - e = list_first_entry(&cfg_priv->eq_list, - struct brcmf_cfg80211_event_q, eq_list); - list_del(&e->eq_list); + spin_lock_irq(&cfg_priv->evt_q_lock); + if (likely(!list_empty(&cfg_priv->evt_q_list))) { + e = list_first_entry(&cfg_priv->evt_q_list, + struct brcmf_cfg80211_event_q, evt_q_list); + list_del(&e->evt_q_list); } - brcmf_unlock_eq(cfg_priv); + spin_unlock_irq(&cfg_priv->evt_q_lock); return e; } @@ -3236,9 +3221,9 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, e->etype = event; memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); - brcmf_lock_eq(cfg_priv); - list_add_tail(&e->eq_list, &cfg_priv->eq_list); - brcmf_unlock_eq(cfg_priv); + spin_lock_irq(&cfg_priv->evt_q_lock); + list_add_tail(&e->evt_q_list, &cfg_priv->evt_q_list); + spin_unlock_irq(&cfg_priv->evt_q_lock); return err; } @@ -3276,22 +3261,22 @@ static void brcmf_cfg80211_event_handler(struct work_struct *work) static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv) { - brcmf_init_eq_lock(cfg_priv); - INIT_LIST_HEAD(&cfg_priv->eq_list); + spin_lock_init(&cfg_priv->evt_q_lock); + INIT_LIST_HEAD(&cfg_priv->evt_q_list); } static void brcmf_flush_eq(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_cfg80211_event_q *e; - brcmf_lock_eq(cfg_priv); - while (!list_empty(&cfg_priv->eq_list)) { - e = list_first_entry(&cfg_priv->eq_list, - struct brcmf_cfg80211_event_q, eq_list); - list_del(&e->eq_list); + spin_lock_irq(&cfg_priv->evt_q_lock); + while (!list_empty(&cfg_priv->evt_q_list)) { + e = list_first_entry(&cfg_priv->evt_q_list, + struct brcmf_cfg80211_event_q, evt_q_list); + list_del(&e->evt_q_list); kfree(e); } - brcmf_unlock_eq(cfg_priv); + spin_unlock_irq(&cfg_priv->evt_q_lock); } static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 79806c0bb9e..14a32e18e6b 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -199,7 +199,7 @@ struct brcmf_cfg80211_ie { /* event queue for cfg80211 main event */ struct brcmf_cfg80211_event_q { - struct list_head eq_list; + struct list_head evt_q_list; u32 etype; struct brcmf_event_msg emsg; s8 edata[1]; @@ -282,8 +282,8 @@ struct brcmf_cfg80211_priv { struct cfg80211_scan_request *scan_request; /* scan request object */ struct brcmf_cfg80211_event_loop el; /* main event loop */ - struct list_head eq_list; /* used for event queue */ - spinlock_t eq_lock; /* for event queue synchronization */ + struct list_head evt_q_list; /* used for event queue */ + spinlock_t evt_q_lock; /* for event queue synchronization */ struct mutex usr_sync; /* maily for dongle up/down synchronization */ struct brcmf_scan_results *bss_list; /* bss_list holding scanned ap information */ From 12e139ff6bb4cc2ead9c5a677f92cdd1f0930867 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:51 -0700 Subject: [PATCH 1137/1519] staging: brcm80211: added endianness check flag to fullmac Makefile Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/brcm80211/brcmfmac/Makefile b/drivers/staging/brcm80211/brcmfmac/Makefile index 3d0878fac7d..a1b7637dce3 100644 --- a/drivers/staging/brcm80211/brcmfmac/Makefile +++ b/drivers/staging/brcm80211/brcmfmac/Makefile @@ -30,3 +30,4 @@ DHDOFILES = \ obj-$(CONFIG_BRCMFMAC) += brcmfmac.o brcmfmac-objs += $(DHDOFILES) +ccflags-y += -D__CHECK_ENDIAN__ From bb7410b2fd325d889f674d2456ce953c519fb774 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:52 -0700 Subject: [PATCH 1138/1519] staging: brcm80211: removed likely/unlikely calls There was no performance rationale to use these guys. Reported-by: Dan Carpenter Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 4 +- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 211 +++++++++--------- drivers/staging/brcm80211/brcmsmac/ampdu.c | 2 +- 3 files changed, 107 insertions(+), 110 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index e1d745640a3..cc8564a1622 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -944,7 +944,7 @@ static int brcmf_netdev_open(struct net_device *net) /* Allow transmit calls */ netif_start_queue(net); drvr_priv->pub.up = 1; - if (unlikely(brcmf_cfg80211_up(drvr_priv->pub.config))) { + if (brcmf_cfg80211_up(drvr_priv->pub.config)) { brcmf_dbg(ERROR, "failed to bring up cfg80211\n"); return -1; } @@ -1054,7 +1054,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) brcmf_cfg80211_attach(net, brcmf_bus_get_device(bus), &drvr_priv->pub); - if (unlikely(drvr_priv->pub.config == NULL)) { + if (drvr_priv->pub.config == NULL) { brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); goto fail; } diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 0bda00c07e2..6acaaaec37e 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -337,7 +337,7 @@ brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, } err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); err = -EAGAIN; } else { @@ -367,7 +367,7 @@ static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) BUG_ON(!len); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, buf, len); - if (unlikely(err)) + if (err) WL_ERR("error (%d)\n", err); return err; @@ -389,7 +389,7 @@ brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) sizeof(var.buf)); BUG_ON(!len); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, &var, len); - if (unlikely(err)) + if (err) WL_ERR("error (%d)\n", err); *retval = le32_to_cpu(var.val); @@ -404,7 +404,7 @@ static void brcmf_set_mpc(struct net_device *ndev, int mpc) if (test_bit(WL_STATUS_READY, &cfg_priv->status)) { err = brcmf_dev_intvar_set(ndev, "mpc", mpc); - if (unlikely(err)) { + if (err) { WL_ERR("fail to set mpc\n"); return; } @@ -463,7 +463,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, if (ssid && ssid->SSID_len) params_size += sizeof(struct brcmf_ssid); params = kzalloc(params_size, GFP_KERNEL); - if (unlikely(!params)) + if (!params) return -ENOMEM; BUG_ON(params_size >= BRCMF_C_IOCTL_SMLEN); @@ -475,7 +475,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, err = brcmf_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size, iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); - if (unlikely(err)) { + if (err) { if (err == -EBUSY) WL_INFO("system busy : iscan canceled\n"); else @@ -502,7 +502,7 @@ static s32 brcmf_do_iscan(struct brcmf_cfg80211_priv *cfg_priv) passive_scan = cfg_priv->active_scan ? 0 : 1; err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_SET_PASSIVE_SCAN, &passive_scan, sizeof(passive_scan)); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); return err; } @@ -533,11 +533,11 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, s32 err = 0; u32 SSID_len; - if (unlikely(test_bit(WL_STATUS_SCANNING, &cfg_priv->status))) { + if (test_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { WL_ERR("Scanning already : status (%lu)\n", cfg_priv->status); return -EAGAIN; } - if (unlikely(test_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status))) { + if (test_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status)) { WL_ERR("Scanning being aborted : status (%lu)\n", cfg_priv->status); return -EAGAIN; @@ -565,7 +565,7 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, set_bit(WL_STATUS_SCANNING, &cfg_priv->status); if (iscan_req) { err = brcmf_do_iscan(cfg_priv); - if (likely(!err)) + if (!err) return err; else goto scan_out; @@ -586,7 +586,7 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, passive_scan = cfg_priv->active_scan ? 0 : 1; err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_PASSIVE_SCAN, &passive_scan, sizeof(passive_scan)); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_PASSIVE_SCAN error (%d)\n", err); goto scan_out; } @@ -625,7 +625,7 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return -EIO; err = __brcmf_cfg80211_scan(wiphy, ndev, request, NULL); - if (unlikely(err)) + if (err) WL_ERR("scan error (%d)\n", err); WL_TRACE("Exit\n"); @@ -637,7 +637,7 @@ static s32 brcmf_set_rts(struct net_device *dev, u32 rts_threshold) s32 err = 0; err = brcmf_dev_intvar_set(dev, "rtsthresh", rts_threshold); - if (unlikely(err)) + if (err) WL_ERR("Error (%d)\n", err); return err; @@ -648,7 +648,7 @@ static s32 brcmf_set_frag(struct net_device *dev, u32 frag_threshold) s32 err = 0; err = brcmf_dev_intvar_set(dev, "fragthresh", frag_threshold); - if (unlikely(err)) + if (err) WL_ERR("Error (%d)\n", err); return err; @@ -660,7 +660,7 @@ static s32 brcmf_set_retry(struct net_device *dev, u32 retry, bool l) u32 cmd = (l ? BRCM_SET_LRL : BRCM_SET_SRL); err = brcmf_dev_ioctl_u32(dev, cmd, &retry); - if (unlikely(err)) { + if (err) { WL_ERR("cmd (%d) , error (%d)\n", cmd, err); return err; } @@ -809,7 +809,7 @@ static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) dev = cfg_to_ndev(cfg_priv); WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, NULL, 0); - if (unlikely(err)) + if (err) WL_ERR("WLC_DISASSOC failed (%d)\n", err); cfg_priv->link_up = false; } @@ -883,7 +883,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, wsec |= WEP_ENABLED; err = brcmf_dev_intvar_set(dev, "wsec", wsec); - if (unlikely(err)) { + if (err) { WL_ERR("wsec failed (%d)\n", err); goto done; } @@ -895,7 +895,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, bcnprd = 100; err = brcmf_dev_ioctl_u32(dev, BRCM_SET_BCNPRD, &bcnprd); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err); goto done; } @@ -940,7 +940,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, target_channel = cfg_priv->channel; err = brcmf_dev_ioctl_u32(dev, BRCM_SET_CHANNEL, &target_channel); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err); goto done; } @@ -952,7 +952,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, err = brcmf_dev_ioctl(dev, BRCMF_C_SET_SSID, &join_params, join_params_size); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_SSID failed (%d)\n", err); goto done; } @@ -997,7 +997,7 @@ static s32 brcmf_set_wpa_version(struct net_device *dev, val = WPA_AUTH_DISABLED; WL_CONN("setting wpa_auth to 0x%0x\n", val); err = brcmf_dev_intvar_set(dev, "wpa_auth", val); - if (unlikely(err)) { + if (err) { WL_ERR("set wpa_auth failed (%d)\n", err); return err; } @@ -1036,7 +1036,7 @@ brcmf_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) } err = brcmf_dev_intvar_set(dev, "auth", val); - if (unlikely(err)) { + if (err) { WL_ERR("set auth failed (%d)\n", err); return err; } @@ -1100,7 +1100,7 @@ brcmf_set_set_cipher(struct net_device *dev, WL_CONN("pval (%d) gval (%d)\n", pval, gval); err = brcmf_dev_intvar_set(dev, "wsec", pval | gval); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); return err; } @@ -1122,7 +1122,7 @@ brcmf_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme) if (sme->crypto.n_akm_suites) { err = brcmf_dev_intvar_get(dev, "wpa_auth", &val); - if (unlikely(err)) { + if (err) { WL_ERR("could not get wpa_auth (%d)\n", err); return err; } @@ -1156,7 +1156,7 @@ brcmf_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme) WL_CONN("setting wpa_auth to %d\n", val); err = brcmf_dev_intvar_set(dev, "wpa_auth", val); - if (unlikely(err)) { + if (err) { WL_ERR("could not set wpa_auth (%d)\n", err); return err; } @@ -1190,7 +1190,7 @@ brcmf_set_set_sharedkey(struct net_device *dev, memset(&key, 0, sizeof(key)); key.len = (u32) sme->key_len; key.index = (u32) sme->key_idx; - if (unlikely(key.len > sizeof(key.data))) { + if (key.len > sizeof(key.data)) { WL_ERR("Too long key length (%u)\n", key.len); return -EINVAL; } @@ -1220,7 +1220,7 @@ brcmf_set_set_sharedkey(struct net_device *dev, WL_CONN("set auth_type to shared key\n"); val = 1; /* shared key */ err = brcmf_dev_intvar_set(dev, "auth", val); - if (unlikely(err)) { + if (err) { WL_ERR("set auth failed (%d)\n", err); return err; } @@ -1246,7 +1246,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (!check_sys_up(wiphy)) return -EIO; - if (unlikely(!sme->ssid)) { + if (!sme->ssid) { WL_ERR("Invalid ssid\n"); return -EOPNOTSUPP; } @@ -1340,7 +1340,7 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, scbval.val = cpu_to_le32(reason_code); err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, &scbval, sizeof(struct brcmf_scb_val_le)); - if (unlikely(err)) + if (err) WL_ERR("error (%d)\n", err); cfg_priv->link_up = false; @@ -1385,7 +1385,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, /* Make sure radio is off or on as far as software is concerned */ disable = WL_RADIO_SW_DISABLE << 16; err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_RADIO, &disable); - if (unlikely(err)) + if (err) WL_ERR("WLC_SET_RADIO error (%d)\n", err); if (dbm > 0xffff) @@ -1394,7 +1394,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, txpwrmw = (u16) dbm; err = brcmf_dev_intvar_set(ndev, "qtxpower", (s32) (brcmu_mw_to_qdbm(txpwrmw))); - if (unlikely(err)) + if (err) WL_ERR("qtxpower error (%d)\n", err); cfg_priv->conf->tx_power = dbm; @@ -1416,7 +1416,7 @@ static s32 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm) return -EIO; err = brcmf_dev_intvar_get(ndev, "qtxpower", &txpwrdbm); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); goto done; } @@ -1443,7 +1443,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, return -EIO; err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); goto done; } @@ -1452,7 +1452,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, /* Just select a new current key */ index = key_idx; err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_KEY_PRIMARY, &index); - if (unlikely(err)) + if (err) WL_ERR("error (%d)\n", err); } done: @@ -1538,7 +1538,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, brcmf_netdev_wait_pend8021x(dev); err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_KEY error (%d)\n", err); return err; } @@ -1571,7 +1571,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, key.len = (u32) params->key_len; key.index = (u32) key_idx; - if (unlikely(key.len > sizeof(key.data))) { + if (key.len > sizeof(key.data)) { WL_ERR("Too long key length (%u)\n", key.len); err = -EINVAL; goto done; @@ -1615,21 +1615,21 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, val = WEP_ENABLED; err = brcmf_dev_intvar_get(dev, "wsec", &wsec); - if (unlikely(err)) { + if (err) { WL_ERR("get wsec error (%d)\n", err); goto done; } wsec &= ~(WEP_ENABLED); wsec |= val; err = brcmf_dev_intvar_set(dev, "wsec", wsec); - if (unlikely(err)) { + if (err) { WL_ERR("set wsec error (%d)\n", err); goto done; } val = 1; /* assume shared key. otherwise 0 */ err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); - if (unlikely(err)) + if (err) WL_ERR("WLC_SET_AUTH error (%d)\n", err); done: WL_TRACE("Exit\n"); @@ -1672,7 +1672,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, val = 0; err = brcmf_dev_intvar_get(dev, "wsec", &wsec); - if (unlikely(err)) { + if (err) { WL_ERR("get wsec error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; @@ -1681,7 +1681,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, wsec &= ~(WEP_ENABLED); wsec |= val; err = brcmf_dev_intvar_set(dev, "wsec", wsec); - if (unlikely(err)) { + if (err) { WL_ERR("set wsec error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; @@ -1690,7 +1690,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, val = 0; /* assume open key. otherwise 1 */ err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; @@ -1719,7 +1719,7 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, memset(¶ms, 0, sizeof(params)); err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ err = -EAGAIN; @@ -1780,8 +1780,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, if (!check_sys_up(wiphy)) return -EIO; - if (unlikely - (memcmp(mac, bssid, ETH_ALEN))) { + if (memcmp(mac, bssid, ETH_ALEN)) { WL_ERR("Wrong Mac address cfg_mac-%X:%X:%X:%X:%X:%X" "wl_bssid-%X:%X:%X:%X:%X:%X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], @@ -1805,7 +1804,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, scb_val.val = cpu_to_le32(0); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_RSSI, &scb_val, sizeof(struct brcmf_scb_val_le)); - if (unlikely(err)) + if (err) WL_ERR("Could not get rssi (%d)\n", err); rssi = le32_to_cpu(scb_val.val); @@ -1848,7 +1847,7 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, WL_INFO("power save %s\n", (pm ? "enabled" : "disabled")); err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_PM, &pm); - if (unlikely(err)) { + if (err) { if (err == -ENODEV) WL_ERR("net_device is not ready yet\n"); else @@ -1880,7 +1879,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, /* Get current rateset */ err = brcmf_dev_ioctl(dev, BRCM_GET_CURR_RATESET, &rateset_le, sizeof(rateset_le)); - if (unlikely(err)) { + if (err) { WL_ERR("could not get current rateset (%d)\n", err); goto done; } @@ -1908,7 +1907,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, */ err_bg = brcmf_dev_intvar_set(dev, "bg_rate", rate); err_a = brcmf_dev_intvar_set(dev, "a_rate", rate); - if (unlikely(err_bg && err_a)) { + if (err_bg && err_a) { WL_ERR("could not set fixed rate (%d) (%d)\n", err_bg, err_a); err = err_bg | err_a; } @@ -1935,7 +1934,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, size_t notify_ielen; s32 notify_signal; - if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) { + if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) { WL_ERR("Bss info is larger than buffer. Discarding\n"); return 0; } @@ -1971,7 +1970,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, notify_timestamp, notify_capability, notify_interval, notify_ie, notify_ielen, notify_signal, GFP_KERNEL); - if (unlikely(!bss)) { + if (!bss) { WL_ERR("cfg80211_inform_bss_frame error\n"); return -EINVAL; } @@ -1987,7 +1986,7 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) int i; bss_list = cfg_priv->bss_list; - if (unlikely(bss_list->version != BRCMF_BSS_INFO_VERSION)) { + if (bss_list->version != BRCMF_BSS_INFO_VERSION) { WL_ERR("Version %d != WL_BSS_INFO_VERSION\n", bss_list->version); return -EOPNOTSUPP; @@ -1996,7 +1995,7 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { bi = next_bss(bss_list, bi); err = brcmf_inform_single_bss(cfg_priv, bi); - if (unlikely(err)) + if (err) break; } return err; @@ -2032,7 +2031,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); goto CleanUp; } @@ -2101,14 +2100,14 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) *(__le32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("Could not get bss info %d\n", err); goto update_bss_info_out; } bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); err = brcmf_inform_single_bss(cfg_priv, bi); - if (unlikely(err)) + if (err) goto update_bss_info_out; ie = ((u8 *)bi) + le16_to_cpu(bi->ie_offset); @@ -2127,7 +2126,7 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) u32 var; err = brcmf_dev_intvar_get(cfg_to_ndev(cfg_priv), "dtim_assoc", &var); - if (unlikely(err)) { + if (err) { WL_ERR("wl dtim_assoc failed (%d)\n", err); goto update_bss_info_out; } @@ -2169,12 +2168,11 @@ static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); struct net_device *ndev = cfg_to_ndev(cfg_priv); - if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, - &cfg_priv->status))) { + if (!test_and_clear_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { WL_ERR("Scan complete while device not scanning\n"); return; } - if (likely(cfg_priv->scan_request)) { + if (cfg_priv->scan_request) { WL_SCAN("ISCAN Completed scan: %s\n", aborted ? "Aborted" : "Done"); cfg80211_scan_done(cfg_priv->scan_request, aborted); @@ -2186,7 +2184,7 @@ static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) { - if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) { + if (iscan->state != WL_ISCAN_STATE_IDLE) { WL_SCAN("wake up iscan\n"); schedule_work(&iscan->work); return 0; @@ -2218,7 +2216,7 @@ brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, err = brcmf_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, BRCMF_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, WL_ISCAN_BUF_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); return err; } @@ -2481,7 +2479,7 @@ brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, BUG_ON(!len); err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, (void *)cfg_priv->ioctl_buf, WL_IOCTL_LEN_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); return err; } @@ -2504,7 +2502,7 @@ brcmf_update_pmklist(struct net_device *dev, WL_CONN("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]); } - if (likely(!err)) + if (!err) brcmf_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list, sizeof(*pmk_list)); @@ -2662,14 +2660,14 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, s32 err = 0; wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); - if (unlikely(!wdev)) { + if (!wdev) { WL_ERR("Could not allocate wireless device\n"); return ERR_PTR(-ENOMEM); } wdev->wiphy = wiphy_new(&wl_cfg80211_ops, sizeof(struct brcmf_cfg80211_priv) + sizeof_iface); - if (unlikely(!wdev->wiphy)) { + if (!wdev->wiphy) { WL_ERR("Couldn not allocate wiphy device\n"); err = -ENOMEM; goto wiphy_new_out; @@ -2695,7 +2693,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, * by default */ err = wiphy_register(wdev->wiphy); - if (unlikely(err < 0)) { + if (err < 0) { WL_ERR("Couldn not register wiphy device (%d)\n", err); goto wiphy_register_out; } @@ -2714,7 +2712,7 @@ static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv) { struct wireless_dev *wdev = cfg_priv->wdev; - if (unlikely(!wdev)) { + if (!wdev) { WL_ERR("wdev is invalid\n"); return; } @@ -2798,7 +2796,7 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) err = brcmf_dev_bufvar_get(ndev, "assoc_info", cfg_priv->extra_buf, WL_ASSOC_INFO_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("could not get assoc info (%d)\n", err); return err; } @@ -2809,7 +2807,7 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) err = brcmf_dev_bufvar_get(ndev, "assoc_req_ies", cfg_priv->extra_buf, WL_ASSOC_INFO_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("could not get assoc req (%d)\n", err); return err; } @@ -2825,7 +2823,7 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) err = brcmf_dev_bufvar_get(ndev, "assoc_resp_ies", cfg_priv->extra_buf, WL_ASSOC_INFO_MAX); - if (unlikely(err)) { + if (err) { WL_ERR("could not get assoc resp (%d)\n", err); return err; } @@ -3028,8 +3026,7 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, return brcmf_wakeup_iscan(cfg_to_iscan(cfg_priv)); } - if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, - &cfg_priv->status))) { + if (!test_and_clear_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { WL_ERR("Scan complete while device not scanning\n"); scan_abort = true; err = -EINVAL; @@ -3038,13 +3035,13 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_inform_le, sizeof(channel_inform_le)); - if (unlikely(err)) { + if (err) { WL_ERR("scan busy (%d)\n", err); scan_abort = true; goto scan_done_out; } scan_channel = le32_to_cpu(channel_inform_le.scan_channel); - if (unlikely(scan_channel)) + if (scan_channel) WL_CONN("channel_inform.scan_channel (%d)\n", scan_channel); cfg_priv->bss_list = cfg_priv->scan_results; bss_list_le = (struct brcmf_scan_results_le *) cfg_priv->bss_list; @@ -3053,7 +3050,7 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, bss_list_le->buflen = cpu_to_le32(len); err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN_RESULTS, cfg_priv->scan_results, len); - if (unlikely(err)) { + if (err) { WL_ERR("%s Scan_results error (%d)\n", ndev->name, err); err = -EINVAL; scan_abort = true; @@ -3127,48 +3124,48 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) { cfg_priv->scan_results = kzalloc(WL_SCAN_BUF_MAX, GFP_KERNEL); - if (unlikely(!cfg_priv->scan_results)) { + if (!cfg_priv->scan_results) { WL_ERR("Scan results alloc failed\n"); goto init_priv_mem_out; } cfg_priv->conf = kzalloc(sizeof(*cfg_priv->conf), GFP_KERNEL); - if (unlikely(!cfg_priv->conf)) { + if (!cfg_priv->conf) { WL_ERR("wl_conf alloc failed\n"); goto init_priv_mem_out; } cfg_priv->profile = kzalloc(sizeof(*cfg_priv->profile), GFP_KERNEL); - if (unlikely(!cfg_priv->profile)) { + if (!cfg_priv->profile) { WL_ERR("wl_profile alloc failed\n"); goto init_priv_mem_out; } cfg_priv->bss_info = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); - if (unlikely(!cfg_priv->bss_info)) { + if (!cfg_priv->bss_info) { WL_ERR("Bss information alloc failed\n"); goto init_priv_mem_out; } cfg_priv->scan_req_int = kzalloc(sizeof(*cfg_priv->scan_req_int), GFP_KERNEL); - if (unlikely(!cfg_priv->scan_req_int)) { + if (!cfg_priv->scan_req_int) { WL_ERR("Scan req alloc failed\n"); goto init_priv_mem_out; } cfg_priv->ioctl_buf = kzalloc(WL_IOCTL_LEN_MAX, GFP_KERNEL); - if (unlikely(!cfg_priv->ioctl_buf)) { + if (!cfg_priv->ioctl_buf) { WL_ERR("Ioctl buf alloc failed\n"); goto init_priv_mem_out; } cfg_priv->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); - if (unlikely(!cfg_priv->extra_buf)) { + if (!cfg_priv->extra_buf) { WL_ERR("Extra buf alloc failed\n"); goto init_priv_mem_out; } cfg_priv->iscan = kzalloc(sizeof(*cfg_priv->iscan), GFP_KERNEL); - if (unlikely(!cfg_priv->iscan)) { + if (!cfg_priv->iscan) { WL_ERR("Iscan buf alloc failed\n"); goto init_priv_mem_out; } cfg_priv->pmk_list = kzalloc(sizeof(*cfg_priv->pmk_list), GFP_KERNEL); - if (unlikely(!cfg_priv->pmk_list)) { + if (!cfg_priv->pmk_list) { WL_ERR("pmk list alloc failed\n"); goto init_priv_mem_out; } @@ -3191,7 +3188,7 @@ static struct brcmf_cfg80211_event_q *brcmf_deq_event( struct brcmf_cfg80211_event_q *e = NULL; spin_lock_irq(&cfg_priv->evt_q_lock); - if (likely(!list_empty(&cfg_priv->evt_q_list))) { + if (!list_empty(&cfg_priv->evt_q_list)) { e = list_first_entry(&cfg_priv->evt_q_list, struct brcmf_cfg80211_event_q, evt_q_list); list_del(&e->evt_q_list); @@ -3213,7 +3210,7 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, s32 err = 0; e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); - if (unlikely(!e)) { + if (!e) { WL_ERR("event alloc failed\n"); return -ENOMEM; } @@ -3296,13 +3293,13 @@ static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) cfg_priv->dongle_up = false; /* dongle is not up yet */ brcmf_init_eq(cfg_priv); err = brcmf_init_priv_mem(cfg_priv); - if (unlikely(err)) + if (err) return err; INIT_WORK(&cfg_priv->event_work, brcmf_cfg80211_event_handler); brcmf_init_eloop_handler(&cfg_priv->el); mutex_init(&cfg_priv->usr_sync); err = brcmf_init_iscan(cfg_priv); - if (unlikely(err)) + if (err) return err; brcmf_init_conf(cfg_priv->conf); brcmf_init_prof(cfg_priv->profile); @@ -3331,12 +3328,12 @@ struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, struct brcmf_cfg80211_dev *cfg_dev; s32 err = 0; - if (unlikely(!ndev)) { + if (!ndev) { WL_ERR("ndev is invalid\n"); return NULL; } cfg_dev = kzalloc(sizeof(struct brcmf_cfg80211_dev), GFP_KERNEL); - if (unlikely(!cfg_dev)) { + if (!cfg_dev) { WL_ERR("wl_cfg80211_dev is invalid\n"); return NULL; } @@ -3357,7 +3354,7 @@ struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); wdev->netdev = ndev; err = wl_init_priv(cfg_priv); - if (unlikely(err)) { + if (err) { WL_ERR("Failed to init iwm_priv (%d)\n", err); goto cfg80211_attach_out; } @@ -3390,7 +3387,7 @@ brcmf_cfg80211_event(struct net_device *ndev, u32 event_type = be32_to_cpu(e->event_type); struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - if (likely(!brcmf_enq_event(cfg_priv, event_type, e))) + if (!brcmf_enq_event(cfg_priv, event_type, e)) schedule_work(&cfg_priv->event_work); } @@ -3418,7 +3415,7 @@ static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) return err; } err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); return err; } @@ -3439,7 +3436,7 @@ static s32 brcmf_dongle_eventmsg(struct net_device *ndev) brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, iovbuf, sizeof(iovbuf)); - if (unlikely(err)) { + if (err) { WL_ERR("Get event_msgs error (%d)\n", err); goto dongle_eventmsg_out; } @@ -3468,7 +3465,7 @@ static s32 brcmf_dongle_eventmsg(struct net_device *ndev) brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - if (unlikely(err)) { + if (err) { WL_ERR("Set event_msgs error (%d)\n", err); goto dongle_eventmsg_out; } @@ -3495,7 +3492,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) sizeof(bcn_timeout), iovbuf, sizeof(iovbuf)); err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - if (unlikely(err)) { + if (err) { WL_ERR("bcn_timeout error (%d)\n", err); goto dongle_rom_out; } @@ -3509,7 +3506,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) brcmu_mkiovar("roam_off", (char *)&roamvar, sizeof(roamvar), iovbuf, sizeof(iovbuf)); err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - if (unlikely(err)) { + if (err) { WL_ERR("roam_off error (%d)\n", err); goto dongle_rom_out; } @@ -3518,7 +3515,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) roamtrigger[1] = BRCM_BAND_ALL; err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_ROAM_TRIGGER, (void *)roamtrigger, sizeof(roamtrigger)); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_ROAM_TRIGGER error (%d)\n", err); goto dongle_rom_out; } @@ -3527,7 +3524,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) roam_delta[1] = BRCM_BAND_ALL; err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_ROAM_DELTA, (void *)roam_delta, sizeof(roam_delta)); - if (unlikely(err)) { + if (err) { WL_ERR("WLC_SET_ROAM_DELTA error (%d)\n", err); goto dongle_rom_out; } @@ -3584,7 +3581,7 @@ static s32 wl_update_wiphybands(struct brcmf_cfg80211_priv *cfg_priv) err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, &phy_list, sizeof(phy_list)); - if (unlikely(err)) { + if (err) { WL_ERR("error (%d)\n", err); return err; } @@ -3624,7 +3621,7 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME); err = brcmf_dongle_eventmsg(ndev); - if (unlikely(err)) + if (err) goto default_conf_out; power_mode = cfg_priv->pwr_save ? PM_FAST : PM_OFF; @@ -3636,13 +3633,13 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, err = brcmf_dongle_roam(ndev, (cfg_priv->roam_on ? 0 : 1), WL_BEACON_TIMEOUT); - if (unlikely(err)) + if (err) goto default_conf_out; err = brcmf_dongle_mode(ndev, wdev->iftype); - if (unlikely(err && err != -EINPROGRESS)) + if (err && err != -EINPROGRESS) goto default_conf_out; err = brcmf_dongle_probecap(cfg_priv); - if (unlikely(err)) + if (err) goto default_conf_out; /* -EINPROGRESS: Call commit handler */ @@ -3700,7 +3697,7 @@ static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv) brcmf_debugfs_add_netdev_params(cfg_priv); err = brcmf_config_dongle(cfg_priv, false); - if (unlikely(err)) + if (err) return err; brcmf_invoke_iscan(cfg_priv); @@ -3778,7 +3775,7 @@ static __used s32 brcmf_add_ie(struct brcmf_cfg80211_priv *cfg_priv, struct brcmf_cfg80211_ie *ie = &cfg_priv->ie; s32 err = 0; - if (unlikely(ie->offset + l + 2 > WL_TLV_INFO_MAX)) { + if (ie->offset + l + 2 > WL_TLV_INFO_MAX) { WL_ERR("ei crosses buffer boundary\n"); return -ENOSPC; } diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 47dc27acf35..d221a3a30d1 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -1132,7 +1132,7 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, s2 = R_REG(&wlc->regs->frmtxstatus2); } - if (likely(scb)) { + if (scb) { scb_ampdu = &scb->scb_ampdu; ini = &scb_ampdu->ini[p->priority]; brcms_c_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); From 3428fc49229231eb8ac6940fc1ad30c572e1c96e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:53 -0700 Subject: [PATCH 1139/1519] staging: brcm80211: removed log after kzalloc()/kmalloc() failure kzalloc/kmalloc already reports an allocation failure themselves. Reported-by: Dan Carpenter Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 4 +- .../staging/brcm80211/brcmfmac/dhd_common.c | 13 ++--- .../staging/brcm80211/brcmfmac/dhd_linux.c | 19 ++----- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 26 ++-------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 50 +++++-------------- drivers/staging/brcm80211/brcmsmac/ampdu.c | 6 +-- drivers/staging/brcm80211/brcmsmac/antsel.c | 5 +- drivers/staging/brcm80211/brcmsmac/channel.c | 5 +- drivers/staging/brcm80211/brcmsmac/dma.c | 16 ++---- .../staging/brcm80211/brcmsmac/mac80211_if.c | 11 ++-- drivers/staging/brcm80211/brcmsmac/nicpci.c | 3 +- drivers/staging/brcm80211/brcmsmac/phy_shim.c | 7 +-- 12 files changed, 41 insertions(+), 124 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 28bdf9e300a..91b4d3cd319 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -417,10 +417,8 @@ int brcmf_proto_attach(struct brcmf_pub *drvr) struct brcmf_proto *cdc; cdc = kzalloc(sizeof(struct brcmf_proto), GFP_ATOMIC); - if (!cdc) { - brcmf_dbg(ERROR, "kmalloc failed\n"); + if (!cdc) goto fail; - } /* ensure that the msg buf directly follows the cdc msg struct */ if ((unsigned long)(&cdc->msg + 1) != (unsigned long)cdc->buf) { diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 0c41c1c26c1..963d1a9f7c5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -562,10 +562,9 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, struct brcmf_pkt_filter_enable *pkt_filterp; arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC); - if (!arg_save) { - brcmf_dbg(ERROR, "kmalloc failed\n"); + if (!arg_save) goto fail; - } + arg_org = arg_save; memcpy(arg_save, arg, strlen(arg) + 1); @@ -635,18 +634,14 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) char *arg_save = NULL, *arg_org = NULL; arg_save = kstrdup(arg, GFP_ATOMIC); - if (!arg_save) { - brcmf_dbg(ERROR, "kmalloc failed\n"); + if (!arg_save) goto fail; - } arg_org = arg_save; buf = kmalloc(PKTFILTER_BUF_SIZE, GFP_ATOMIC); - if (!buf) { - brcmf_dbg(ERROR, "kmalloc failed\n"); + if (!buf) goto fail; - } argv[i] = strsep(&arg_save, " "); while (argv[i++]) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index cc8564a1622..659a9c2d2e1 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -159,11 +159,8 @@ static void _brcmf_set_multicast_list(struct work_struct *work) buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN); bufp = buf = kmalloc(buflen, GFP_ATOMIC); - if (!bufp) { - brcmf_dbg(ERROR, "%s: out of memory for mcast_list, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, 0), cnt); + if (!bufp) return; - } strcpy(bufp, "mcast_list"); bufp += strlen("mcast_list") + 1; @@ -202,11 +199,9 @@ static void _brcmf_set_multicast_list(struct work_struct *work) buflen = sizeof("allmulti") + sizeof(allmulti); buf = kmalloc(buflen, GFP_ATOMIC); - if (!buf) { - brcmf_dbg(ERROR, "%s: out of memory for allmulti\n", - brcmf_ifname(&drvr_priv->pub, 0)); + if (!buf) return; - } + allmulti_le = cpu_to_le32(allmulti); if (!brcmu_mkiovar @@ -963,10 +958,8 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, ifp = drvr_priv->iflist[ifidx]; if (!ifp) { ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); - if (!ifp) { - brcmf_dbg(ERROR, "OOM - struct brcmf_if\n"); + if (!ifp) return -ENOMEM; - } } memset(ifp, 0, sizeof(struct brcmf_if)); @@ -1019,10 +1012,8 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) /* Allocate primary brcmf_info */ drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); - if (!drvr_priv) { - brcmf_dbg(ERROR, "OOM - alloc brcmf_info\n"); + if (!drvr_priv) goto fail; - } /* * Save the brcmf_info into the priv diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 66ab752a65c..9f8bcb32dd6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2956,10 +2956,8 @@ static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) /* Get full mem size */ size = bus->ramsize; buf = kmalloc(size, GFP_ATOMIC); - if (!buf) { - brcmf_dbg(ERROR, "Out of memory (%d bytes)\n", size); + if (!buf) return -1; - } /* Read mem content */ printk(KERN_DEBUG "Dump dongle memory"); @@ -3013,7 +3011,6 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) size = msize; mbuffer = data = kmalloc(msize, GFP_ATOMIC); if (mbuffer == NULL) { - brcmf_dbg(ERROR, "kmalloc(%d) failed\n", msize); bcmerror = -ENOMEM; goto done; } @@ -3021,7 +3018,6 @@ static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) str = kmalloc(maxstrlen, GFP_ATOMIC); if (str == NULL) { - brcmf_dbg(ERROR, "kmalloc(%d) failed\n", maxstrlen); bcmerror = -ENOMEM; goto done; } @@ -3737,8 +3733,6 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) memptr = memblock = kmalloc(MEMBLOCK + BRCMF_SDALIGN, GFP_ATOMIC); if (memblock == NULL) { - brcmf_dbg(ERROR, "Failed to allocate memory %d bytes\n", - MEMBLOCK); ret = -ENOMEM; goto err; } @@ -3837,8 +3831,6 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) memblock = kmalloc(MEMBLOCK, GFP_ATOMIC); if (memblock == NULL) { - brcmf_dbg(ERROR, "Failed to allocate memory %d bytes\n", - MEMBLOCK); ret = -ENOMEM; goto err; } @@ -4254,18 +4246,13 @@ static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) roundup((bus->drvr->maxctl + SDPCM_HDRLEN), ALIGNMENT) + BRCMF_SDALIGN; bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC); - if (!(bus->rxbuf)) { - brcmf_dbg(ERROR, "kmalloc of %d-byte rxbuf failed\n", - bus->rxblen); + if (!(bus->rxbuf)) goto fail; - } } /* Allocate buffer to receive glomed packet */ bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC); if (!(bus->databuf)) { - brcmf_dbg(ERROR, "kmalloc of %d-byte databuf failed\n", - MAX_DATA_BUF); /* release rxbuf which was already located as above */ if (!bus->rxblen) kfree(bus->rxbuf); @@ -4457,10 +4444,8 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) /* alloc chip_info_t */ ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); - if (NULL == ci) { - brcmf_dbg(ERROR, "malloc failed!\n"); + if (NULL == ci) return -ENOMEM; - } /* bus/core/clk setup for register access */ /* Try forcing SDIO core to do ALPAvail request only */ @@ -4785,10 +4770,9 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, /* Allocate private bus interface state */ bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); - if (!bus) { - brcmf_dbg(ERROR, "kmalloc of struct dhd_bus failed\n"); + if (!bus) goto fail; - } + bus->sdiodev = sdiodev; sdiodev->bus = bus; bus->txbound = BRCMF_TXBOUND; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 6acaaaec37e..d0ae2b6d3e9 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -2023,7 +2023,6 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); if (buf == NULL) { - WL_ERR("kzalloc() failed\n"); err = -ENOMEM; goto CleanUp; } @@ -2660,10 +2659,9 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, s32 err = 0; wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); - if (!wdev) { - WL_ERR("Could not allocate wireless device\n"); + if (!wdev) return ERR_PTR(-ENOMEM); - } + wdev->wiphy = wiphy_new(&wl_cfg80211_ops, sizeof(struct brcmf_cfg80211_priv) + sizeof_iface); @@ -3124,51 +3122,33 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) { cfg_priv->scan_results = kzalloc(WL_SCAN_BUF_MAX, GFP_KERNEL); - if (!cfg_priv->scan_results) { - WL_ERR("Scan results alloc failed\n"); + if (!cfg_priv->scan_results) goto init_priv_mem_out; - } cfg_priv->conf = kzalloc(sizeof(*cfg_priv->conf), GFP_KERNEL); - if (!cfg_priv->conf) { - WL_ERR("wl_conf alloc failed\n"); + if (!cfg_priv->conf) goto init_priv_mem_out; - } cfg_priv->profile = kzalloc(sizeof(*cfg_priv->profile), GFP_KERNEL); - if (!cfg_priv->profile) { - WL_ERR("wl_profile alloc failed\n"); + if (!cfg_priv->profile) goto init_priv_mem_out; - } cfg_priv->bss_info = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); - if (!cfg_priv->bss_info) { - WL_ERR("Bss information alloc failed\n"); + if (!cfg_priv->bss_info) goto init_priv_mem_out; - } cfg_priv->scan_req_int = kzalloc(sizeof(*cfg_priv->scan_req_int), GFP_KERNEL); - if (!cfg_priv->scan_req_int) { - WL_ERR("Scan req alloc failed\n"); + if (!cfg_priv->scan_req_int) goto init_priv_mem_out; - } cfg_priv->ioctl_buf = kzalloc(WL_IOCTL_LEN_MAX, GFP_KERNEL); - if (!cfg_priv->ioctl_buf) { - WL_ERR("Ioctl buf alloc failed\n"); + if (!cfg_priv->ioctl_buf) goto init_priv_mem_out; - } cfg_priv->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); - if (!cfg_priv->extra_buf) { - WL_ERR("Extra buf alloc failed\n"); + if (!cfg_priv->extra_buf) goto init_priv_mem_out; - } cfg_priv->iscan = kzalloc(sizeof(*cfg_priv->iscan), GFP_KERNEL); - if (!cfg_priv->iscan) { - WL_ERR("Iscan buf alloc failed\n"); + if (!cfg_priv->iscan) goto init_priv_mem_out; - } cfg_priv->pmk_list = kzalloc(sizeof(*cfg_priv->pmk_list), GFP_KERNEL); - if (!cfg_priv->pmk_list) { - WL_ERR("pmk list alloc failed\n"); + if (!cfg_priv->pmk_list) goto init_priv_mem_out; - } return 0; @@ -3210,10 +3190,8 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, s32 err = 0; e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); - if (!e) { - WL_ERR("event alloc failed\n"); + if (!e) return -ENOMEM; - } e->etype = event; memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); @@ -3333,10 +3311,8 @@ struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, return NULL; } cfg_dev = kzalloc(sizeof(struct brcmf_cfg80211_dev), GFP_KERNEL); - if (!cfg_dev) { - WL_ERR("wl_cfg80211_dev is invalid\n"); + if (!cfg_dev) return NULL; - } wdev = brcmf_alloc_wdev(sizeof(struct brcmf_cfg80211_iface), busdev); if (IS_ERR(wdev)) { diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index d221a3a30d1..b94d60c2238 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -227,11 +227,9 @@ struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc) int i; ampdu = kzalloc(sizeof(struct ampdu_info), GFP_ATOMIC); - if (!ampdu) { - wiphy_err(wlc->wiphy, "wl%d: brcms_c_ampdu_attach: out of mem" - "\n", wlc->pub->unit); + if (!ampdu) return NULL; - } + ampdu->wlc = wlc; for (i = 0; i < AMPDU_MAX_SCB_TID; i++) diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index 29b51a13d29..c61c5202446 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -110,11 +110,8 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) struct antsel_info *asi; asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC); - if (!asi) { - wiphy_err(wlc->wiphy, "wl%d: brcms_c_antsel_attach: out of " - "mem\n", wlc->pub->unit); + if (!asi) return NULL; - } asi->wlc = wlc; asi->pub = wlc->pub; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index af01c9d5ec3..a9defe21b7d 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1090,11 +1090,8 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); wlc_cm = kzalloc(sizeof(struct brcms_cm_info), GFP_ATOMIC); - if (wlc_cm == NULL) { - wiphy_err(wlc->wiphy, "wl%d: %s: out of memory", pub->unit, - __func__); + if (wlc_cm == NULL) return NULL; - } wlc_cm->pub = pub; wlc_cm->wlc = wlc; wlc->cmi = wlc_cm; diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 06990b3d6cd..714c74c78f5 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -559,12 +559,8 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, /* allocate private info structure */ di = kzalloc(sizeof(struct dma_info), GFP_ATOMIC); - if (di == NULL) { -#ifdef BCMDBG - printk(KERN_ERR "dma_attach: out of memory\n"); -#endif + if (di == NULL) return NULL; - } di->msg_level = msg_level ? msg_level : &dma_msg_level; @@ -651,22 +647,16 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, if (ntxd) { size = ntxd * sizeof(void *); di->txp = kzalloc(size, GFP_ATOMIC); - if (di->txp == NULL) { - DMA_ERROR(("%s: dma_attach: out of tx memory\n", - di->name)); + if (di->txp == NULL) goto fail; - } } /* allocate rx packet pointer vector */ if (nrxd) { size = nrxd * sizeof(void *); di->rxp = kzalloc(size, GFP_ATOMIC); - if (di->rxp == NULL) { - DMA_ERROR(("%s: dma_attach: out of rx memory\n", - di->name)); + if (di->rxp == NULL) goto fail; - } } /* diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 65d30b58469..32d7abf2b08 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -1541,11 +1541,8 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl, struct brcms_timer *t; t = kzalloc(sizeof(struct brcms_timer), GFP_ATOMIC); - if (!t) { - wiphy_err(wl->wiphy, "wl%d: brcms_init_timer: out of memory\n", - wl->pub->unit); + if (!t) return NULL; - } init_timer(&t->timer); t->timer.data = (unsigned long) t; @@ -1659,11 +1656,9 @@ int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx) pdata = wl->fw.fw_bin[i]->data + le32_to_cpu(hdr->offset); *pbuf = kmalloc(len, GFP_ATOMIC); - if (*pbuf == NULL) { - wiphy_err(wl->wiphy, "fail to alloc %d" - " bytes\n", len); + if (*pbuf == NULL) goto fail; - } + memcpy(*pbuf, pdata, len); return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index a2cab5c312e..f5a2695ac0d 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -245,9 +245,8 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, /* alloc struct pcicore_info */ pi = kzalloc(sizeof(struct pcicore_info), GFP_ATOMIC); - if (pi == NULL) { + if (pi == NULL) return NULL; - } pi->sih = sih; pi->dev = pdev; diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index 31c93742f0f..e0c19b62b19 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -41,12 +41,9 @@ struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, struct phy_shim_info *physhim = NULL; physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC); - if (!physhim) { - wiphy_err(wlc_hw->wlc->wiphy, - "wl%d: wlc_phy_shim_attach: out of mem\n", - wlc_hw->unit); + if (!physhim) return NULL; - } + physhim->wlc_hw = wlc_hw; physhim->wlc = wlc; physhim->wl = wl; From 3229827ec323f8e7effc50b6e7712d13169f0dfb Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:54 -0700 Subject: [PATCH 1140/1519] staging: brcm80211: clarified fullmac io and event codes Added comments to make code more readable. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 4 ++++ drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 5 +++++ drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 7ca917203a9..7ab45d90c03 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -27,6 +27,9 @@ #define BRCMF_C_IOCTL_MEDLEN 1536 /* "med" ioctl buffer required */ #define BRCMF_C_IOCTL_MAXLEN 8192 +/******************************************************************************* + * IO codes that are interpreted by dongle firmware + ******************************************************************************/ #define BRCMF_C_UP 2 #define BRCMF_C_SET_PROMISC 10 #define BRCMF_C_GET_RATE 12 @@ -171,6 +174,7 @@ struct dngl_stats { unsigned long multicast; /* multicast packets received */ }; +/* event codes sent by the dongle to this driver */ #define BRCMF_E_SET_SSID 0 #define BRCMF_E_JOIN 1 #define BRCMF_E_START 2 diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 91b4d3cd319..4c171a30628 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -14,6 +14,11 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/******************************************************************************* + * Communicates with the dongle by using Broadcom specific ioctl codes. + * For certain ioctl codes, the dongle interprets string data from the host. + ******************************************************************************/ + #include #include #include diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index d0ae2b6d3e9..45c9e781953 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* Toplevel file. Relies on dhd_linux.c to send ioctls to the dongle. */ + #include #include #include From 4fa819becadd4181db837071b10e6aa2c35355a9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:55 -0700 Subject: [PATCH 1141/1519] staging: brcm80211: consistent naming of struct net_device *ndev Code cleanup. Various names (ndev, net, dev) were used for the same structure. Settled for 'ndev'. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 6 +- .../staging/brcm80211/brcmfmac/dhd_linux.c | 214 +++++++++-------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 219 +++++++++--------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- 4 files changed, 225 insertions(+), 216 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 7ab45d90c03..a16f7317177 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -722,9 +722,9 @@ static inline void MUTEX_UNLOCK_WL_SCAN_SET(void) extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen); extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); -extern int brcmf_netdev_wait_pend8021x(struct net_device *dev); +extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); -extern int brcmf_netdev_ioctl_priv(struct net_device *net, +extern int brcmf_netdev_ioctl_priv(struct net_device *ndev, struct brcmf_ioctl *ioc); /* Indication from bus module regarding removal/absence of dongle */ @@ -766,7 +766,7 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, extern void brcmf_c_init(void); extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, - struct net_device *net, char *name, u8 *mac_addr, + struct net_device *ndev, char *name, u8 *mac_addr, u32 flags, u8 bssidx); extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 659a9c2d2e1..827022edf45 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -53,7 +53,7 @@ MODULE_LICENSE("Dual BSD/GPL"); struct brcmf_if { struct brcmf_info *info; /* back pointer to brcmf_info */ /* OS/stack specifics */ - struct net_device *net; + struct net_device *ndev; struct net_device_stats stats; int idx; /* iface idx in dongle */ int state; /* interface state */ @@ -83,12 +83,12 @@ struct brcmf_info { module_param(brcmf_msg_level, int, 0); -static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net) +static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) { int i = 0; while (i < BRCMF_MAX_IFS) { - if (drvr_priv->iflist[i] && (drvr_priv->iflist[i]->net == net)) + if (drvr_priv->iflist[i] && drvr_priv->iflist[i]->ndev == ndev) return i; i++; } @@ -127,15 +127,15 @@ char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx) return ""; } - if (drvr_priv->iflist[ifidx]->net) - return drvr_priv->iflist[ifidx]->net->name; + if (drvr_priv->iflist[ifidx]->ndev) + return drvr_priv->iflist[ifidx]->ndev->name; return ""; } static void _brcmf_set_multicast_list(struct work_struct *work) { - struct net_device *dev; + struct net_device *ndev; struct netdev_hw_addr *ha; u32 allmulti, cnt; __le32 cnt_le; @@ -149,11 +149,11 @@ static void _brcmf_set_multicast_list(struct work_struct *work) struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, multicast_work); - dev = drvr_priv->iflist[0]->net; - cnt = netdev_mc_count(dev); + ndev = drvr_priv->iflist[0]->ndev; + cnt = netdev_mc_count(ndev); /* Determine initial value of allmulti flag */ - allmulti = (dev->flags & IFF_ALLMULTI) ? true : false; + allmulti = (ndev->flags & IFF_ALLMULTI) ? true : false; /* Send down the multicast list first. */ @@ -169,7 +169,7 @@ static void _brcmf_set_multicast_list(struct work_struct *work) memcpy(bufp, &cnt_le, sizeof(cnt)); bufp += sizeof(cnt_le); - netdev_for_each_mc_addr(ha, dev) { + netdev_for_each_mc_addr(ha, ndev) { if (!cnt) break; memcpy(bufp, ha->addr, ETH_ALEN); @@ -232,7 +232,7 @@ static void _brcmf_set_multicast_list(struct work_struct *work) /* Finally, pick up the PROMISC flag as well, like the NIC driver does */ - allmulti = (dev->flags & IFF_PROMISC) ? true : false; + allmulti = (ndev->flags & IFF_PROMISC) ? true : false; allmulti_le = cpu_to_le32(allmulti); memset(&ioc, 0, sizeof(ioc)); @@ -277,7 +277,7 @@ _brcmf_set_mac_address(struct work_struct *work) brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", brcmf_ifname(&drvr_priv->pub, 0)); else - memcpy(drvr_priv->iflist[0]->net->dev_addr, + memcpy(drvr_priv->iflist[0]->ndev->dev_addr, drvr_priv->macvalue, ETH_ALEN); return; @@ -299,23 +299,23 @@ static void brcmf_op_if(struct brcmf_if *ifp) * Delete the existing interface before overwriting it * in case we missed the BRCMF_E_IF_DEL event. */ - if (ifp->net != NULL) { + if (ifp->ndev != NULL) { brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", - ifp->net->name); - netif_stop_queue(ifp->net); - unregister_netdev(ifp->net); - free_netdev(ifp->net); + ifp->ndev->name); + netif_stop_queue(ifp->ndev); + unregister_netdev(ifp->ndev); + free_netdev(ifp->ndev); } /* Allocate netdev, including space for private structure */ - ifp->net = alloc_netdev(sizeof(drvr_priv), "wlan%d", - ether_setup); - if (!ifp->net) { + ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", + ether_setup); + if (!ifp->ndev) { brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); ret = -ENOMEM; } if (ret == 0) { - strcpy(ifp->net->name, ifp->name); - memcpy(netdev_priv(ifp->net), &drvr_priv, + strcpy(ifp->ndev->name, ifp->name); + memcpy(netdev_priv(ifp->ndev), &drvr_priv, sizeof(drvr_priv)); err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); if (err != 0) { @@ -324,16 +324,16 @@ static void brcmf_op_if(struct brcmf_if *ifp) ret = -EOPNOTSUPP; } else { brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", - current->pid, ifp->net->name); + current->pid, ifp->ndev->name); ifp->state = 0; } } break; case BRCMF_E_IF_DEL: - if (ifp->net != NULL) { + if (ifp->ndev != NULL) { brcmf_dbg(TRACE, "got 'WLC_E_IF_DEL' state\n"); - netif_stop_queue(ifp->net); - unregister_netdev(ifp->net); + netif_stop_queue(ifp->ndev); + unregister_netdev(ifp->ndev); ret = BRCMF_DEL_IF; /* Make sure the free_netdev() is called */ } @@ -344,21 +344,22 @@ static void brcmf_op_if(struct brcmf_if *ifp) } if (ret < 0) { - if (ifp->net) - free_netdev(ifp->net); + if (ifp->ndev) + free_netdev(ifp->ndev); drvr_priv->iflist[ifp->idx] = NULL; kfree(ifp); } } -static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) +static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(dev); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); struct sockaddr *sa = (struct sockaddr *)addr; int ifidx; - ifidx = brcmf_net2idx(drvr_priv, dev); + ifidx = brcmf_net2idx(drvr_priv, ndev); if (ifidx == BRCMF_BAD_IF) return -1; @@ -367,12 +368,13 @@ static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) return 0; } -static void brcmf_netdev_set_multicast_list(struct net_device *dev) +static void brcmf_netdev_set_multicast_list(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(dev); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); int ifidx; - ifidx = brcmf_net2idx(drvr_priv, dev); + ifidx = brcmf_net2idx(drvr_priv, ndev); if (ifidx == BRCMF_BAD_IF) return; @@ -405,10 +407,11 @@ int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) return brcmf_sdbrcm_bus_txdata(drvr->bus, pktbuf); } -static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net) +static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) { int ret; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); int ifidx; brcmf_dbg(TRACE, "Enter\n"); @@ -417,14 +420,14 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net) if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == BRCMF_BUS_DOWN)) { brcmf_dbg(ERROR, "xmit rejected pub.up=%d busstate=%d\n", drvr_priv->pub.up, drvr_priv->pub.busstate); - netif_stop_queue(net); + netif_stop_queue(ndev); return -ENODEV; } - ifidx = brcmf_net2idx(drvr_priv, net); + ifidx = brcmf_net2idx(drvr_priv, ndev); if (ifidx == BRCMF_BAD_IF) { brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); - netif_stop_queue(net); + netif_stop_queue(ndev); return -ENODEV; } @@ -460,17 +463,17 @@ done: void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool state) { - struct net_device *net; + struct net_device *ndev; struct brcmf_info *drvr_priv = drvr->info; brcmf_dbg(TRACE, "Enter\n"); drvr->txoff = state; - net = drvr_priv->iflist[ifidx]->net; + ndev = drvr_priv->iflist[ifidx]->ndev; if (state == ON) - netif_stop_queue(net); + netif_stop_queue(ndev); else - netif_wake_queue(net); + netif_wake_queue(ndev); } static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, @@ -483,8 +486,8 @@ static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, if (bcmerror != 0) return bcmerror; - if (drvr_priv->iflist[*ifidx]->net) - brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->net, + if (drvr_priv->iflist[*ifidx]->ndev) + brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->ndev, event, *data); return bcmerror; @@ -530,7 +533,7 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, if (ifp == NULL) ifp = drvr_priv->iflist[0]; - skb->dev = ifp->net; + skb->dev = ifp->ndev; skb->protocol = eth_type_trans(skb, skb->dev); if (skb->pkt_type == PACKET_MULTICAST) @@ -552,8 +555,8 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, !drvr_priv->iflist[ifidx]->state) ifp = drvr_priv->iflist[ifidx]; - if (ifp->net) - ifp->net->last_rx = jiffies; + if (ifp->ndev) + ifp->ndev->last_rx = jiffies; drvr->dstats.rx_bytes += skb->len; drvr->rx_packets++; /* Local count */ @@ -588,15 +591,16 @@ void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success) } -static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *net) +static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); struct brcmf_if *ifp; int ifidx; brcmf_dbg(TRACE, "Enter\n"); - ifidx = brcmf_net2idx(drvr_priv, net); + ifidx = brcmf_net2idx(drvr_priv, ndev); if (ifidx == BRCMF_BAD_IF) return NULL; @@ -698,10 +702,11 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) return 0; } -static void brcmf_ethtool_get_drvinfo(struct net_device *net, +static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); sprintf(info->driver, KBUILD_MODNAME); sprintf(info->version, "%lu", drvr_priv->pub.drv_version); @@ -809,10 +814,10 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) /* If setting TX checksum mode, tell Linux the new mode */ if (cmd == ETHTOOL_STXCSUM) { if (edata.data) - drvr_priv->iflist[0]->net->features |= + drvr_priv->iflist[0]->ndev->features |= NETIF_F_IP_CSUM; else - drvr_priv->iflist[0]->net->features &= + drvr_priv->iflist[0]->ndev->features &= ~NETIF_F_IP_CSUM; } @@ -825,13 +830,14 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) return 0; } -static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, +static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, int cmd) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); int ifidx; - ifidx = brcmf_net2idx(drvr_priv, net); + ifidx = brcmf_net2idx(drvr_priv, ndev); brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); if (ifidx == BRCMF_BAD_IF) @@ -844,15 +850,16 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr, } /* called only from within this driver */ -int brcmf_netdev_ioctl_priv(struct net_device *net, struct brcmf_ioctl *ioc) +int brcmf_netdev_ioctl_priv(struct net_device *ndev, struct brcmf_ioctl *ioc) { int bcmerror = 0; int buflen = 0; bool is_set_key_cmd; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); int ifidx; - ifidx = brcmf_net2idx(drvr_priv, net); + ifidx = brcmf_net2idx(drvr_priv, ndev); if (ioc->buf != NULL) buflen = min_t(uint, ioc->len, BRCMF_IOCTL_MAXLEN); @@ -879,7 +886,7 @@ int brcmf_netdev_ioctl_priv(struct net_device *net, struct brcmf_ioctl *ioc) ((ioc->cmd == BRCMF_C_SET_VAR) && !(strncmp("bsscfg:wsec_key", ioc->buf, 15)))); if (is_set_key_cmd) - brcmf_netdev_wait_pend8021x(net); + brcmf_netdev_wait_pend8021x(ndev); bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, ioc, buflen); @@ -890,9 +897,9 @@ done: return bcmerror; } -static int brcmf_netdev_stop(struct net_device *net) +static int brcmf_netdev_stop(struct net_device *ndev) { - struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(net); + struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(ndev); brcmf_dbg(TRACE, "Enter\n"); brcmf_cfg80211_down(drvr->config); @@ -901,16 +908,17 @@ static int brcmf_netdev_stop(struct net_device *net) /* Set state and stop OS transmissions */ drvr->up = 0; - netif_stop_queue(net); + netif_stop_queue(ndev); return 0; } -static int brcmf_netdev_open(struct net_device *net) +static int brcmf_netdev_open(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net); + struct brcmf_info *drvr_priv = *(struct brcmf_info **) + netdev_priv(ndev); u32 toe_ol; - int ifidx = brcmf_net2idx(drvr_priv, net); + int ifidx = brcmf_net2idx(drvr_priv, ndev); s32 ret = 0; brcmf_dbg(TRACE, "ifidx %d\n", ifidx); @@ -925,19 +933,19 @@ static int brcmf_netdev_open(struct net_device *net) } atomic_set(&drvr_priv->pend_8021x_cnt, 0); - memcpy(net->dev_addr, drvr_priv->pub.mac, ETH_ALEN); + memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); /* Get current TOE mode from dongle */ if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0 && (toe_ol & TOE_TX_CSUM_OL) != 0) - drvr_priv->iflist[ifidx]->net->features |= + drvr_priv->iflist[ifidx]->ndev->features |= NETIF_F_IP_CSUM; else - drvr_priv->iflist[ifidx]->net->features &= + drvr_priv->iflist[ifidx]->ndev->features &= ~NETIF_F_IP_CSUM; } /* Allow transmit calls */ - netif_start_queue(net); + netif_start_queue(ndev); drvr_priv->pub.up = 1; if (brcmf_cfg80211_up(drvr_priv->pub.config)) { brcmf_dbg(ERROR, "failed to bring up cfg80211\n"); @@ -948,12 +956,12 @@ static int brcmf_netdev_open(struct net_device *net) } int -brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, +brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, char *name, u8 *mac_addr, u32 flags, u8 bssidx) { struct brcmf_if *ifp; - brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, net); + brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); ifp = drvr_priv->iflist[ifidx]; if (!ifp) { @@ -969,12 +977,12 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *net, if (mac_addr != NULL) memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - if (net == NULL) { + if (ndev == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; brcmf_op_if(ifp); } else - ifp->net = net; + ifp->ndev = ndev; return 0; } @@ -999,13 +1007,13 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) { struct brcmf_info *drvr_priv = NULL; - struct net_device *net; + struct net_device *ndev; brcmf_dbg(TRACE, "Enter\n"); /* Allocate netdev, including space for private structure */ - net = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); - if (!net) { + ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); + if (!ndev) { brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); goto fail; } @@ -1018,13 +1026,13 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) /* * Save the brcmf_info into the priv */ - memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv)); + memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); - if (brcmf_add_if(drvr_priv, 0, net, net->name, NULL, 0, 0) == + if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == BRCMF_BAD_IF) goto fail; - net->netdev_ops = NULL; + ndev->netdev_ops = NULL; mutex_init(&drvr_priv->proto_block); /* Link to info module */ @@ -1042,7 +1050,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) /* Attach and link in the cfg80211 */ drvr_priv->pub.config = - brcmf_cfg80211_attach(net, + brcmf_cfg80211_attach(ndev, brcmf_bus_get_device(bus), &drvr_priv->pub); if (drvr_priv->pub.config == NULL) { @@ -1056,13 +1064,13 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) /* * Save the brcmf_info into the priv */ - memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv)); + memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); return &drvr_priv->pub; fail: - if (net) - free_netdev(net); + if (ndev) + free_netdev(ndev); if (drvr_priv) brcmf_detach(&drvr_priv->pub); @@ -1143,14 +1151,14 @@ static struct net_device_ops brcmf_netdev_ops_pri = { int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) { struct brcmf_info *drvr_priv = drvr->info; - struct net_device *net; + struct net_device *ndev; u8 temp_addr[ETH_ALEN] = { 0x00, 0x90, 0x4c, 0x11, 0x22, 0x33}; brcmf_dbg(TRACE, "ifidx %d\n", ifidx); - net = drvr_priv->iflist[ifidx]->net; - net->netdev_ops = &brcmf_netdev_ops_pri; + ndev = drvr_priv->iflist[ifidx]->ndev; + ndev->netdev_ops = &brcmf_netdev_ops_pri; /* * We have to use the primary MAC for virtual interfaces @@ -1168,25 +1176,25 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) - Locally Administered address */ } - net->hard_header_len = ETH_HLEN + drvr_priv->pub.hdrlen; - net->ethtool_ops = &brcmf_ethtool_ops; + ndev->hard_header_len = ETH_HLEN + drvr_priv->pub.hdrlen; + ndev->ethtool_ops = &brcmf_ethtool_ops; - drvr_priv->pub.rxsz = net->mtu + net->hard_header_len + - drvr_priv->pub.hdrlen; + drvr_priv->pub.rxsz = ndev->mtu + ndev->hard_header_len + + drvr_priv->pub.hdrlen; - memcpy(net->dev_addr, temp_addr, ETH_ALEN); + memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); - if (register_netdev(net) != 0) { + if (register_netdev(ndev) != 0) { brcmf_dbg(ERROR, "couldn't register the net device\n"); goto fail; } - brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", net->name); + brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", ndev->name); return 0; fail: - net->netdev_ops = NULL; + ndev->netdev_ops = NULL; return -EBADE; } @@ -1225,9 +1233,9 @@ void brcmf_detach(struct brcmf_pub *drvr) brcmf_del_if(drvr_priv, i); ifp = drvr_priv->iflist[0]; - if (ifp->net->netdev_ops == &brcmf_netdev_ops_pri) { - brcmf_netdev_stop(ifp->net); - unregister_netdev(ifp->net); + if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { + brcmf_netdev_stop(ifp->ndev); + unregister_netdev(ifp->ndev); } cancel_work_sync(&drvr_priv->setmacaddr_work); @@ -1240,7 +1248,7 @@ void brcmf_detach(struct brcmf_pub *drvr) brcmf_cfg80211_detach(drvr->config); - free_netdev(ifp->net); + free_netdev(ifp->ndev); kfree(ifp); kfree(drvr_priv); } @@ -1305,9 +1313,9 @@ static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv) #define MAX_WAIT_FOR_8021X_TX 10 -int brcmf_netdev_wait_pend8021x(struct net_device *dev) +int brcmf_netdev_wait_pend8021x(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev); + struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(ndev); int timeout = 10 * HZ / 1000; int ntimes = MAX_WAIT_FOR_8021X_TX; int pend = brcmf_get_pend_8021x_cnt(drvr_priv); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 45c9e781953..b707bc0ddcb 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -267,12 +267,12 @@ brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) /* function for reading/writing a single u32 from/to the dongle */ static int -brcmf_dev_ioctl_u32(struct net_device *dev, u32 cmd, u32 *par) +brcmf_dev_ioctl_u32(struct net_device *ndev, u32 cmd, u32 *par) { int err; __le32 par_le = cpu_to_le32(*par); - err = brcmf_dev_ioctl(dev, cmd, &par_le, sizeof(__le32)); + err = brcmf_dev_ioctl(ndev, cmd, &par_le, sizeof(__le32)); *par = le32_to_cpu(par_le); return err; @@ -292,14 +292,14 @@ static void convert_key_from_CPU(struct brcmf_wsec_key *key, memcpy(key_le->ea, key->ea, sizeof(key->ea)); } -static int send_key_to_dongle(struct net_device *dev, +static int send_key_to_dongle(struct net_device *ndev, struct brcmf_wsec_key *key) { int err; struct brcmf_wsec_key_le key_le; convert_key_from_CPU(key, &key_le); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); if (err) WL_ERR("WLC_SET_KEY error (%d)\n", err); return err; @@ -356,7 +356,7 @@ done: return err; } -static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) +static s32 brcmf_dev_intvar_set(struct net_device *ndev, s8 *name, s32 val) { s8 buf[BRCMF_C_IOCTL_SMLEN]; u32 len; @@ -368,7 +368,7 @@ static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) sizeof(buf)); BUG_ON(!len); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, buf, len); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, buf, len); if (err) WL_ERR("error (%d)\n", err); @@ -376,7 +376,7 @@ static s32 brcmf_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) } static s32 -brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) +brcmf_dev_intvar_get(struct net_device *ndev, s8 *name, s32 *retval) { union { s8 buf[BRCMF_C_IOCTL_SMLEN]; @@ -390,7 +390,7 @@ brcmf_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) brcmu_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf)); BUG_ON(!len); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, &var, len); + err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, &var, len); if (err) WL_ERR("error (%d)\n", err); @@ -430,7 +430,7 @@ static void wl_iscan_prep(struct brcmf_scan_params_le *params_le, } static s32 -brcmf_dev_iovar_setbuf(struct net_device *dev, s8 * iovar, void *param, +brcmf_dev_iovar_setbuf(struct net_device *ndev, s8 * iovar, void *param, s32 paramlen, void *bufptr, s32 buflen) { s32 iolen; @@ -438,11 +438,11 @@ brcmf_dev_iovar_setbuf(struct net_device *dev, s8 * iovar, void *param, iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); BUG_ON(!iolen); - return brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, bufptr, iolen); + return brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, bufptr, iolen); } static s32 -brcmf_dev_iovar_getbuf(struct net_device *dev, s8 * iovar, void *param, +brcmf_dev_iovar_getbuf(struct net_device *ndev, s8 * iovar, void *param, s32 paramlen, void *bufptr, s32 buflen) { s32 iolen; @@ -450,7 +450,7 @@ brcmf_dev_iovar_getbuf(struct net_device *dev, s8 * iovar, void *param, iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); BUG_ON(!iolen); - return brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, bufptr, buflen); + return brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, bufptr, buflen); } static s32 @@ -475,8 +475,8 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, params->action = cpu_to_le16(action); params->scan_duration = cpu_to_le16(0); - err = brcmf_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size, - iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); + err = brcmf_dev_iovar_setbuf(iscan->ndev, "iscan", params, params_size, + iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); if (err) { if (err == -EBUSY) WL_INFO("system busy : iscan canceled\n"); @@ -634,34 +634,34 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return err; } -static s32 brcmf_set_rts(struct net_device *dev, u32 rts_threshold) +static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold) { s32 err = 0; - err = brcmf_dev_intvar_set(dev, "rtsthresh", rts_threshold); + err = brcmf_dev_intvar_set(ndev, "rtsthresh", rts_threshold); if (err) WL_ERR("Error (%d)\n", err); return err; } -static s32 brcmf_set_frag(struct net_device *dev, u32 frag_threshold) +static s32 brcmf_set_frag(struct net_device *ndev, u32 frag_threshold) { s32 err = 0; - err = brcmf_dev_intvar_set(dev, "fragthresh", frag_threshold); + err = brcmf_dev_intvar_set(ndev, "fragthresh", frag_threshold); if (err) WL_ERR("Error (%d)\n", err); return err; } -static s32 brcmf_set_retry(struct net_device *dev, u32 retry, bool l) +static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l) { s32 err = 0; u32 cmd = (l ? BRCM_SET_LRL : BRCM_SET_SRL); - err = brcmf_dev_ioctl_u32(dev, cmd, &retry); + err = brcmf_dev_ioctl_u32(ndev, cmd, &retry); if (err) { WL_ERR("cmd (%d) , error (%d)\n", cmd, err); return err; @@ -802,15 +802,15 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) { - struct net_device *dev = NULL; + struct net_device *ndev = NULL; s32 err = 0; WL_TRACE("Enter\n"); if (cfg_priv->link_up) { - dev = cfg_to_ndev(cfg_priv); + ndev = cfg_to_ndev(cfg_priv); WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); - err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, NULL, 0); + err = brcmf_dev_ioctl(ndev, BRCMF_C_DISASSOC, NULL, 0); if (err) WL_ERR("WLC_DISASSOC failed (%d)\n", err); cfg_priv->link_up = false; @@ -819,7 +819,7 @@ static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) } static s32 -brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ibss_params *params) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -884,7 +884,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, if (params->privacy) wsec |= WEP_ENABLED; - err = brcmf_dev_intvar_set(dev, "wsec", wsec); + err = brcmf_dev_intvar_set(ndev, "wsec", wsec); if (err) { WL_ERR("wsec failed (%d)\n", err); goto done; @@ -896,7 +896,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, else bcnprd = 100; - err = brcmf_dev_ioctl_u32(dev, BRCM_SET_BCNPRD, &bcnprd); + err = brcmf_dev_ioctl_u32(ndev, BRCM_SET_BCNPRD, &bcnprd); if (err) { WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err); goto done; @@ -940,7 +940,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, /* set channel for starter */ target_channel = cfg_priv->channel; - err = brcmf_dev_ioctl_u32(dev, BRCM_SET_CHANNEL, + err = brcmf_dev_ioctl_u32(ndev, BRCM_SET_CHANNEL, &target_channel); if (err) { WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err); @@ -952,7 +952,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, cfg_priv->ibss_starter = false; - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_SSID, + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SSID, &join_params, join_params_size); if (err) { WL_ERR("WLC_SET_SSID failed (%d)\n", err); @@ -967,7 +967,7 @@ done: } static s32 -brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) +brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); s32 err = 0; @@ -983,10 +983,10 @@ brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) return err; } -static s32 brcmf_set_wpa_version(struct net_device *dev, +static s32 brcmf_set_wpa_version(struct net_device *ndev, struct cfg80211_connect_params *sme) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); struct brcmf_cfg80211_security *sec; s32 val = 0; s32 err = 0; @@ -998,7 +998,7 @@ static s32 brcmf_set_wpa_version(struct net_device *dev, else val = WPA_AUTH_DISABLED; WL_CONN("setting wpa_auth to 0x%0x\n", val); - err = brcmf_dev_intvar_set(dev, "wpa_auth", val); + err = brcmf_dev_intvar_set(ndev, "wpa_auth", val); if (err) { WL_ERR("set wpa_auth failed (%d)\n", err); return err; @@ -1008,10 +1008,10 @@ static s32 brcmf_set_wpa_version(struct net_device *dev, return err; } -static s32 -brcmf_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) +static s32 brcmf_set_auth_type(struct net_device *ndev, + struct cfg80211_connect_params *sme) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); struct brcmf_cfg80211_security *sec; s32 val = 0; s32 err = 0; @@ -1037,7 +1037,7 @@ brcmf_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) break; } - err = brcmf_dev_intvar_set(dev, "auth", val); + err = brcmf_dev_intvar_set(ndev, "auth", val); if (err) { WL_ERR("set auth failed (%d)\n", err); return err; @@ -1048,10 +1048,10 @@ brcmf_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) } static s32 -brcmf_set_set_cipher(struct net_device *dev, +brcmf_set_set_cipher(struct net_device *ndev, struct cfg80211_connect_params *sme) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); struct brcmf_cfg80211_security *sec; s32 pval = 0; s32 gval = 0; @@ -1101,7 +1101,7 @@ brcmf_set_set_cipher(struct net_device *dev, } WL_CONN("pval (%d) gval (%d)\n", pval, gval); - err = brcmf_dev_intvar_set(dev, "wsec", pval | gval); + err = brcmf_dev_intvar_set(ndev, "wsec", pval | gval); if (err) { WL_ERR("error (%d)\n", err); return err; @@ -1115,15 +1115,15 @@ brcmf_set_set_cipher(struct net_device *dev, } static s32 -brcmf_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme) +brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); struct brcmf_cfg80211_security *sec; s32 val = 0; s32 err = 0; if (sme->crypto.n_akm_suites) { - err = brcmf_dev_intvar_get(dev, "wpa_auth", &val); + err = brcmf_dev_intvar_get(ndev, "wpa_auth", &val); if (err) { WL_ERR("could not get wpa_auth (%d)\n", err); return err; @@ -1157,7 +1157,7 @@ brcmf_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme) } WL_CONN("setting wpa_auth to %d\n", val); - err = brcmf_dev_intvar_set(dev, "wpa_auth", val); + err = brcmf_dev_intvar_set(ndev, "wpa_auth", val); if (err) { WL_ERR("could not set wpa_auth (%d)\n", err); return err; @@ -1170,10 +1170,10 @@ brcmf_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme) } static s32 -brcmf_set_set_sharedkey(struct net_device *dev, +brcmf_set_set_sharedkey(struct net_device *ndev, struct cfg80211_connect_params *sme) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); struct brcmf_cfg80211_security *sec; struct brcmf_wsec_key key; s32 val; @@ -1214,14 +1214,14 @@ brcmf_set_set_sharedkey(struct net_device *dev, WL_CONN("key length (%d) key index (%d) algo (%d)\n", key.len, key.index, key.algo); WL_CONN("key \"%s\"\n", key.data); - err = send_key_to_dongle(dev, &key); + err = send_key_to_dongle(ndev, &key); if (err) return err; if (sec->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) { WL_CONN("set auth_type to shared key\n"); val = 1; /* shared key */ - err = brcmf_dev_intvar_set(dev, "auth", val); + err = brcmf_dev_intvar_set(ndev, "auth", val); if (err) { WL_ERR("set auth failed (%d)\n", err); return err; @@ -1233,7 +1233,7 @@ brcmf_set_set_sharedkey(struct net_device *dev, } static s32 -brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_connect_params *sme) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -1265,31 +1265,31 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, WL_INFO("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len); - err = brcmf_set_wpa_version(dev, sme); + err = brcmf_set_wpa_version(ndev, sme); if (err) { WL_ERR("wl_set_wpa_version failed (%d)\n", err); goto done; } - err = brcmf_set_auth_type(dev, sme); + err = brcmf_set_auth_type(ndev, sme); if (err) { WL_ERR("wl_set_auth_type failed (%d)\n", err); goto done; } - err = brcmf_set_set_cipher(dev, sme); + err = brcmf_set_set_cipher(ndev, sme); if (err) { WL_ERR("wl_set_set_cipher failed (%d)\n", err); goto done; } - err = brcmf_set_key_mgmt(dev, sme); + err = brcmf_set_key_mgmt(ndev, sme); if (err) { WL_ERR("wl_set_key_mgmt failed (%d)\n", err); goto done; } - err = brcmf_set_set_sharedkey(dev, sme); + err = brcmf_set_set_sharedkey(ndev, sme); if (err) { WL_ERR("wl_set_set_sharedkey failed (%d)\n", err); goto done; @@ -1312,7 +1312,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, brcmf_ch_to_chanspec(cfg_priv->channel, &join_params, &join_params_size); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_SSID, + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SSID, &join_params, join_params_size); if (err) WL_ERR("WLC_SET_SSID failed (%d)\n", err); @@ -1325,7 +1325,7 @@ done: } static s32 -brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev, u16 reason_code) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -1340,7 +1340,7 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, memcpy(&scbval.ea, brcmf_read_prof(cfg_priv, WL_PROF_BSSID), ETH_ALEN); scbval.val = cpu_to_le32(reason_code); - err = brcmf_dev_ioctl(dev, BRCMF_C_DISASSOC, &scbval, + err = brcmf_dev_ioctl(ndev, BRCMF_C_DISASSOC, &scbval, sizeof(struct brcmf_scb_val_le)); if (err) WL_ERR("error (%d)\n", err); @@ -1432,7 +1432,7 @@ done: } static s32 -brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx, bool unicast, bool multicast) { u32 index; @@ -1444,7 +1444,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, if (!check_sys_up(wiphy)) return -EIO; - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_WSEC, &wsec); if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); goto done; @@ -1453,7 +1453,8 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, if (wsec & WEP_ENABLED) { /* Just select a new current key */ index = key_idx; - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_KEY_PRIMARY, &index); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_KEY_PRIMARY, + &index); if (err) WL_ERR("error (%d)\n", err); } @@ -1463,7 +1464,7 @@ done: } static s32 -brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, +brcmf_add_keyext(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx, const u8 *mac_addr, struct key_params *params) { struct brcmf_wsec_key key; @@ -1480,7 +1481,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, /* check for key index change */ if (key.len == 0) { /* key delete */ - err = send_key_to_dongle(dev, &key); + err = send_key_to_dongle(ndev, &key); if (err) return err; } else { @@ -1537,8 +1538,8 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, } convert_key_from_CPU(&key, &key_le); - brcmf_netdev_wait_pend8021x(dev); - err = brcmf_dev_ioctl(dev, BRCMF_C_SET_KEY, &key_le, + brcmf_netdev_wait_pend8021x(ndev); + err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); if (err) { WL_ERR("WLC_SET_KEY error (%d)\n", err); @@ -1549,7 +1550,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *dev, } static s32 -brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params) { @@ -1566,7 +1567,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, if (mac_addr) { WL_TRACE("Exit"); - return brcmf_add_keyext(wiphy, dev, key_idx, mac_addr, params); + return brcmf_add_keyext(wiphy, ndev, key_idx, mac_addr, params); } memset(&key, 0, sizeof(key)); @@ -1611,26 +1612,26 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, goto done; } - err = send_key_to_dongle(dev, &key); /* Set the new key/index */ + err = send_key_to_dongle(ndev, &key); /* Set the new key/index */ if (err) goto done; val = WEP_ENABLED; - err = brcmf_dev_intvar_get(dev, "wsec", &wsec); + err = brcmf_dev_intvar_get(ndev, "wsec", &wsec); if (err) { WL_ERR("get wsec error (%d)\n", err); goto done; } wsec &= ~(WEP_ENABLED); wsec |= val; - err = brcmf_dev_intvar_set(dev, "wsec", wsec); + err = brcmf_dev_intvar_set(ndev, "wsec", wsec); if (err) { WL_ERR("set wsec error (%d)\n", err); goto done; } val = 1; /* assume shared key. otherwise 0 */ - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_AUTH, &val); if (err) WL_ERR("WLC_SET_AUTH error (%d)\n", err); done: @@ -1639,7 +1640,7 @@ done: } static s32 -brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx, bool pairwise, const u8 *mac_addr) { struct brcmf_wsec_key key; @@ -1660,7 +1661,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, WL_CONN("key index (%d)\n", key_idx); /* Set the new key/index */ - err = send_key_to_dongle(dev, &key); + err = send_key_to_dongle(ndev, &key); if (err) { if (err == -EINVAL) { if (key.index >= DOT11_MAX_DEFAULT_KEYS) @@ -1673,7 +1674,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, } val = 0; - err = brcmf_dev_intvar_get(dev, "wsec", &wsec); + err = brcmf_dev_intvar_get(ndev, "wsec", &wsec); if (err) { WL_ERR("get wsec error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1682,7 +1683,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, } wsec &= ~(WEP_ENABLED); wsec |= val; - err = brcmf_dev_intvar_set(dev, "wsec", wsec); + err = brcmf_dev_intvar_set(ndev, "wsec", wsec); if (err) { WL_ERR("set wsec error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1691,7 +1692,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, } val = 0; /* assume open key. otherwise 1 */ - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_AUTH, &val); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_AUTH, &val); if (err) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1703,7 +1704,7 @@ done: } static s32 -brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie, void (*callback) (void *cookie, struct key_params * params)) { @@ -1720,7 +1721,7 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, memset(¶ms, 0, sizeof(params)); - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_WSEC, &wsec); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_WSEC, &wsec); if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1760,7 +1761,7 @@ done: static s32 brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, - struct net_device *dev, u8 key_idx) + struct net_device *ndev, u8 key_idx) { WL_INFO("Not supported\n"); @@ -1768,7 +1769,7 @@ brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, } static s32 -brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, u8 *mac, struct station_info *sinfo) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -1793,7 +1794,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, } /* Report the current tx rate */ - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_GET_RATE, &rate); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_RATE, &rate); if (err) { WL_ERR("Could not get rate (%d)\n", err); } else { @@ -1804,7 +1805,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { scb_val.val = cpu_to_le32(0); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_RSSI, &scb_val, + err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_RSSI, &scb_val, sizeof(struct brcmf_scb_val_le)); if (err) WL_ERR("Could not get rssi (%d)\n", err); @@ -1821,7 +1822,7 @@ done: } static s32 -brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, bool enabled, s32 timeout) { s32 pm; @@ -1848,7 +1849,7 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, pm = enabled ? PM_FAST : PM_OFF; WL_INFO("power save %s\n", (pm ? "enabled" : "disabled")); - err = brcmf_dev_ioctl_u32(dev, BRCMF_C_SET_PM, &pm); + err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_PM, &pm); if (err) { if (err == -ENODEV) WL_ERR("net_device is not ready yet\n"); @@ -1861,7 +1862,7 @@ done: } static s32 -brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *ndev, const u8 *addr, const struct cfg80211_bitrate_mask *mask) { @@ -1879,7 +1880,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, /* addr param is always NULL. ignore it */ /* Get current rateset */ - err = brcmf_dev_ioctl(dev, BRCM_GET_CURR_RATESET, &rateset_le, + err = brcmf_dev_ioctl(ndev, BRCM_GET_CURR_RATESET, &rateset_le, sizeof(rateset_le)); if (err) { WL_ERR("could not get current rateset (%d)\n", err); @@ -1907,8 +1908,8 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, * Set rate override, * Since the is a/b/g-blind, both a/bg_rate are enforced. */ - err_bg = brcmf_dev_intvar_set(dev, "bg_rate", rate); - err_a = brcmf_dev_intvar_set(dev, "a_rate", rate); + err_bg = brcmf_dev_intvar_set(ndev, "bg_rate", rate); + err_a = brcmf_dev_intvar_set(ndev, "a_rate", rate); if (err_bg && err_a) { WL_ERR("could not set fixed rate (%d) (%d)\n", err_bg, err_a); err = err_bg | err_a; @@ -2004,7 +2005,7 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) } static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *dev, const u8 *bssid) + struct net_device *ndev, const u8 *bssid) { struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); struct ieee80211_channel *notify_channel; @@ -2031,7 +2032,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); + err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); if (err) { WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); goto CleanUp; @@ -2214,9 +2215,9 @@ brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, memset(&list, 0, sizeof(list)); list.results_le.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); - err = brcmf_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, - BRCMF_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, - WL_ISCAN_BUF_MAX); + err = brcmf_dev_iovar_getbuf(iscan->ndev, "iscanresults", &list, + BRCMF_ISCAN_RESULTS_FIXED_SIZE, + iscan->scan_buf, WL_ISCAN_BUF_MAX); if (err) { WL_ERR("error (%d)\n", err); return err; @@ -2352,7 +2353,7 @@ static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) int err = 0; if (cfg_priv->iscan_on) { - iscan->dev = cfg_to_ndev(cfg_priv); + iscan->ndev = cfg_to_ndev(cfg_priv); brcmf_init_iscan_eloop(&iscan->el); iscan->timer_ms = WL_ISCAN_TIMER_INTERVAL_MS; init_timer(&iscan->timer); @@ -2454,32 +2455,32 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, } static __used s32 -brcmf_dev_bufvar_set(struct net_device *dev, s8 *name, s8 *buf, s32 len) +brcmf_dev_bufvar_set(struct net_device *ndev, s8 *name, s8 *buf, s32 len) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); u32 buflen; buflen = brcmu_mkiovar(name, buf, len, cfg_priv->ioctl_buf, WL_IOCTL_LEN_MAX); BUG_ON(!buflen); - return brcmf_dev_ioctl(dev, BRCMF_C_SET_VAR, cfg_priv->ioctl_buf, + return brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, cfg_priv->ioctl_buf, buflen); } static s32 -brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, +brcmf_dev_bufvar_get(struct net_device *ndev, s8 *name, s8 *buf, s32 buf_len) { - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(dev); + struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); u32 len; s32 err = 0; len = brcmu_mkiovar(name, NULL, 0, cfg_priv->ioctl_buf, WL_IOCTL_LEN_MAX); BUG_ON(!len); - err = brcmf_dev_ioctl(dev, BRCMF_C_GET_VAR, (void *)cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); + err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, cfg_priv->ioctl_buf, + WL_IOCTL_LEN_MAX); if (err) { WL_ERR("error (%d)\n", err); return err; @@ -2490,7 +2491,7 @@ brcmf_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, } static __used s32 -brcmf_update_pmklist(struct net_device *dev, +brcmf_update_pmklist(struct net_device *ndev, struct brcmf_cfg80211_pmk_list *pmk_list, s32 err) { int i, j; @@ -2504,14 +2505,14 @@ brcmf_update_pmklist(struct net_device *dev, } if (!err) - brcmf_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list, + brcmf_dev_bufvar_set(ndev, "pmkid_info", (char *)pmk_list, sizeof(*pmk_list)); return err; } static s32 -brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_pmksa *pmksa) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -2539,14 +2540,14 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, for (i = 0; i < WLAN_PMKID_LEN; i++) WL_CONN("%02x\n", pmkids->pmkid[pmkids->npmkid].PMKID[i]); - err = brcmf_update_pmklist(dev, cfg_priv->pmk_list, err); + err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); WL_TRACE("Exit\n"); return err; } static s32 -brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, +brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_pmksa *pmksa) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -2588,7 +2589,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, } else err = -EINVAL; - err = brcmf_update_pmklist(dev, cfg_priv->pmk_list, err); + err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); WL_TRACE("Exit\n"); return err; @@ -2596,7 +2597,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, } static s32 -brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) +brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); s32 err = 0; @@ -2606,7 +2607,7 @@ brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) return -EIO; memset(cfg_priv->pmk_list, 0, sizeof(*cfg_priv->pmk_list)); - err = brcmf_update_pmklist(dev, cfg_priv->pmk_list, err); + err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); WL_TRACE("Exit\n"); return err; @@ -2655,7 +2656,7 @@ static s32 brcmf_mode_to_nl80211_iftype(s32 mode) } static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, - struct device *dev) + struct device *ndev) { struct wireless_dev *wdev; s32 err = 0; @@ -2672,7 +2673,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, err = -ENOMEM; goto wiphy_new_out; } - set_wiphy_dev(wdev->wiphy, dev); + set_wiphy_dev(wdev->wiphy, ndev); wdev->wiphy->max_scan_ssids = WL_NUM_SCAN_MAX; wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX; wdev->wiphy->interface_modes = diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 14a32e18e6b..afc60d9c967 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -243,7 +243,7 @@ struct brcmf_cfg80211_iscan_eloop { /* dongle iscan controller */ struct brcmf_cfg80211_iscan_ctrl { - struct net_device *dev; + struct net_device *ndev; struct timer_list timer; u32 timer_ms; u32 timer_on; From 06bc69691bbdcc9a61c1fefceba081636b80435c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 22 Sep 2011 17:07:56 -0700 Subject: [PATCH 1142/1519] staging: brcm80211: simplified internal ioctl function once more Code cleanup. Merged two functions. Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 3 +- .../staging/brcm80211/brcmfmac/dhd_linux.c | 40 +++++++++++-------- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 16 -------- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index a16f7317177..514f779c63c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -724,8 +724,7 @@ extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); -extern int brcmf_netdev_ioctl_priv(struct net_device *ndev, - struct brcmf_ioctl *ioc); +extern s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len); /* Indication from bus module regarding removal/absence of dongle */ extern void brcmf_detach(struct brcmf_pub *drvr); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 827022edf45..3ae0d437166 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -849,30 +849,36 @@ static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, return -EOPNOTSUPP; } -/* called only from within this driver */ -int brcmf_netdev_ioctl_priv(struct net_device *ndev, struct brcmf_ioctl *ioc) +/* called only from within this driver. Sends an ioctl to the dongle. */ +s32 brcmf_dev_ioctl(struct net_device *ndev, u32 cmd, void *arg, u32 len) { - int bcmerror = 0; + struct brcmf_ioctl ioc; + s32 err = 0; int buflen = 0; bool is_set_key_cmd; struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); + netdev_priv(ndev); int ifidx; + memset(&ioc, 0, sizeof(ioc)); + ioc.cmd = cmd; + ioc.buf = arg; + ioc.len = len; + ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ioc->buf != NULL) - buflen = min_t(uint, ioc->len, BRCMF_IOCTL_MAXLEN); + if (ioc.buf != NULL) + buflen = min_t(uint, ioc.len, BRCMF_IOCTL_MAXLEN); /* send to dongle (must be up, and wl) */ if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { brcmf_dbg(ERROR, "DONGLE_DOWN\n"); - bcmerror = -EIO; + err = -EIO; goto done; } if (!drvr_priv->pub.iswl) { - bcmerror = -EIO; + err = -EIO; goto done; } @@ -880,21 +886,21 @@ int brcmf_netdev_ioctl_priv(struct net_device *ndev, struct brcmf_ioctl *ioc) * Intercept BRCMF_C_SET_KEY IOCTL - serialize M4 send and * set key IOCTL to prevent M4 encryption. */ - is_set_key_cmd = ((ioc->cmd == BRCMF_C_SET_KEY) || - ((ioc->cmd == BRCMF_C_SET_VAR) && - !(strncmp("wsec_key", ioc->buf, 9))) || - ((ioc->cmd == BRCMF_C_SET_VAR) && - !(strncmp("bsscfg:wsec_key", ioc->buf, 15)))); + is_set_key_cmd = ((ioc.cmd == BRCMF_C_SET_KEY) || + ((ioc.cmd == BRCMF_C_SET_VAR) && + !(strncmp("wsec_key", ioc.buf, 9))) || + ((ioc.cmd == BRCMF_C_SET_VAR) && + !(strncmp("bsscfg:wsec_key", ioc.buf, 15)))); if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(ndev); - bcmerror = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, ioc, buflen); + err = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, buflen); done: - if (bcmerror > 0) - bcmerror = 0; + if (err > 0) + err = 0; - return bcmerror; + return err; } static int brcmf_netdev_stop(struct net_device *ndev) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index b707bc0ddcb..b956c9060a4 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -249,22 +249,6 @@ static const u32 __wl_cipher_suites[] = { WLAN_CIPHER_SUITE_AES_CMAC, }; -static s32 -brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len) -{ - struct brcmf_ioctl ioc; - s32 err = 0; - - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = cmd; - ioc.buf = arg; - ioc.len = len; - - err = brcmf_netdev_ioctl_priv(dev, &ioc); - - return err; -} - /* function for reading/writing a single u32 from/to the dongle */ static int brcmf_dev_ioctl_u32(struct net_device *ndev, u32 cmd, u32 *par) From 8f019bfe0a23167d49aa5c364d229ae416f7e675 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Sep 2011 10:17:04 +0300 Subject: [PATCH 1143/1519] Staging: rtl8192e: off by one in rtl8192_get_channel_map() COUNTRY_CODE_MAX is not a valid country code. We're off by one here. This gets passed to Dot11d_Channelmap() where it's used as an offset into the ChannelPlan[] array. Signed-off-by: Dan Carpenter Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 4c5d7abd9be..5ad96649f40 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -1283,7 +1283,7 @@ static short rtl8192_get_channel_map(struct net_device *dev) return -1; } - if (priv->ChannelPlan > COUNTRY_CODE_MAX) { + if (priv->ChannelPlan >= COUNTRY_CODE_MAX) { printk(KERN_INFO "rtl819x_init:Error channel plan! Set to " "default.\n"); priv->ChannelPlan = COUNTRY_CODE_FCC; From abc51b6de532b1071d8335918970c5d9154da73f Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Wed, 21 Sep 2011 16:45:30 +0300 Subject: [PATCH 1144/1519] staging: mei: Organize the initialization state machine. moving the final state, clearing of the client maps and updating of mei state out from mei_host_client_properties function. Acked-by: Tomas Winkler Signed-off-by: Oren Weil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/init.c | 30 ++++++++--------------------- drivers/staging/mei/interrupt.c | 34 ++++++++++++++++++++++++++++++++- drivers/staging/mei/mei_dev.h | 2 +- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c index cb0ebbedf67..8bf34794489 100644 --- a/drivers/staging/mei/init.c +++ b/drivers/staging/mei/init.c @@ -470,9 +470,12 @@ void mei_allocate_me_clients_storage(struct mei_device *dev) * * @dev: the device structure * - * returns none. + * returns: + * < 0 - Error. + * = 0 - no more clients. + * = 1 - still have clients to send properties request. */ -void mei_host_client_properties(struct mei_device *dev) +int mei_host_client_properties(struct mei_device *dev) { struct mei_msg_hdr *mei_header; struct hbm_props_request *host_cli_req; @@ -504,32 +507,15 @@ void mei_host_client_properties(struct mei_device *dev) dev->mei_state = MEI_RESETING; dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); mei_reset(dev, 1); - return; + return -EIO; } dev->init_clients_timer = INIT_CLIENTS_TIMEOUT; dev->me_client_index = b; - return; + return 1; } - - /* - * Clear Map for indicating now ME clients - * with associated host client - */ - bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX); - dev->open_handle_count = 0; - bitmap_set(dev->host_clients_map, 0, 3); - dev->mei_state = MEI_ENABLED; - - /* if wd initialization fails, initialization the AMTHI client, - * otherwise the AMTHI client will be initialized after the WD client connect response - * will be received - */ - if (mei_wd_host_init(dev)) - mei_host_init_iamthif(dev); - - return; + return 0; } /** diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index d1da3aa1cd5..882d106d54e 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -653,6 +653,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, struct hbm_host_enum_response *enum_res; struct hbm_client_disconnect_request *disconnect_req; struct hbm_host_stop_request *host_stop_req; + int res; unsigned char *buffer; @@ -746,7 +747,38 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, MEI_CLIENT_PROPERTIES_MESSAGE) { dev->me_client_index++; dev->me_client_presentation_num++; - mei_host_client_properties(dev); + + /** Send Client Propeties request **/ + res = mei_host_client_properties(dev); + if (res < 0) { + dev_dbg(&dev->pdev->dev, "mei_host_client_properties() failed"); + return; + } else if (!res) { + /* + * No more clients to send to. + * Clear Map for indicating now ME clients + * with associated host client + */ + bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX); + dev->open_handle_count = 0; + + /* + * Reserving the first three client IDs + * Client Id 0 - Reserved for MEI Bus Message communications + * Client Id 1 - Reserved for Watchdog + * Client ID 2 - Reserved for AMTHI + */ + bitmap_set(dev->host_clients_map, 0, 3); + dev->mei_state = MEI_ENABLED; + + /* if wd initialization fails, initialization the AMTHI client, + * otherwise the AMTHI client will be initialized after the WD client connect response + * will be received + */ + if (mei_wd_host_init(dev)) + mei_host_init_iamthif(dev); + } + } else { dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message"); mei_reset(dev, 1); diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h index 6487be1a4bf..af4b1af9eea 100644 --- a/drivers/staging/mei/mei_dev.h +++ b/drivers/staging/mei/mei_dev.h @@ -329,7 +329,7 @@ static inline bool mei_cl_cmp_id(const struct mei_cl *cl1, */ void mei_host_start_message(struct mei_device *dev); void mei_host_enum_clients_message(struct mei_device *dev); -void mei_host_client_properties(struct mei_device *dev); +int mei_host_client_properties(struct mei_device *dev); /* * MEI interrupt functions prototype From 5bf8ebc5c67b808ca0d2e90d898df46405caa8f0 Mon Sep 17 00:00:00 2001 From: Jaap Crezee Date: Wed, 21 Sep 2011 22:48:44 +0200 Subject: [PATCH 1145/1519] Staging: intel_sst: instel_sst: fixed some coding style issues. Fixed a coding style issue. Signed-off-by: Jaap Crezee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/intel_sst/intel_sst.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/intel_sst/intel_sst.c b/drivers/staging/intel_sst/intel_sst.c index d892861346f..c303d85011b 100644 --- a/drivers/staging/intel_sst/intel_sst.c +++ b/drivers/staging/intel_sst/intel_sst.c @@ -321,7 +321,7 @@ static int __devinit intel_sst_probe(struct pci_dev *pci, if (ret) { pr_err("couldn't register LPE device\n"); goto do_free_misc; - } + } } else if (sst_drv_ctx->pci_id == SST_MFLD_PCI_ID) { u32 csr; @@ -524,9 +524,11 @@ int intel_sst_resume(struct pci_dev *pci) return 0; } -/* The runtime_suspend/resume is pretty much similar to the legacy suspend/resume with the noted exception below: - * The PCI core takes care of taking the system through D3hot and restoring it back to D0 and so there is - * no need to duplicate that here. +/* The runtime_suspend/resume is pretty much similar to the legacy + * suspend/resume with the noted exception below: + * The PCI core takes care of taking the system through D3hot and + * restoring it back to D0 and so there is no need to duplicate + * that here. */ static int intel_sst_runtime_suspend(struct device *dev) { From 83e416f458d532f173f822be823354ba7e68dc50 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 21 Sep 2011 11:15:49 +0100 Subject: [PATCH 1146/1519] staging: iio: adc: Replace, rewrite ad7745 from scratch. The existing ad7745 driver didn't conform with the IIO spec for such devices. It was way simpler to rewrite the existing driver, than actually fixing it. Signed-off-by: Michael Hennerich Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/Kconfig | 2 +- drivers/staging/iio/adc/Makefile | 2 +- drivers/staging/iio/adc/ad7745.c | 673 -------------------------- drivers/staging/iio/adc/ad7746.c | 804 +++++++++++++++++++++++++++++++ drivers/staging/iio/adc/ad7746.h | 29 ++ 5 files changed, 835 insertions(+), 675 deletions(-) delete mode 100644 drivers/staging/iio/adc/ad7745.c create mode 100644 drivers/staging/iio/adc/ad7746.c create mode 100644 drivers/staging/iio/adc/ad7746.h diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 7867ab18913..0482073744f 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -144,7 +144,7 @@ config AD7793 To compile this driver as a module, choose M here: the module will be called AD7793. -config AD7745 +config AD7746 tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver" depends on I2C help diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 990d3fada30..5ba3cdb631c 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_AD7150) += ad7150.o obj-$(CONFIG_AD7152) += ad7152.o obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7314) += ad7314.o -obj-$(CONFIG_AD7745) += ad7745.o +obj-$(CONFIG_AD7746) += ad7746.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7816) += ad7816.o diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c deleted file mode 100644 index 827344c2147..00000000000 --- a/drivers/staging/iio/adc/ad7745.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * AD774X capacitive sensor driver supporting AD7745/6/7 - * - * Copyright 2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../iio.h" -#include "../sysfs.h" - -/* - * AD774X registers definition - */ - -#define AD774X_STATUS 0 -#define AD774X_STATUS_RDY (1 << 2) -#define AD774X_STATUS_RDYVT (1 << 1) -#define AD774X_STATUS_RDYCAP (1 << 0) -#define AD774X_CAP_DATA_HIGH 1 -#define AD774X_CAP_DATA_MID 2 -#define AD774X_CAP_DATA_LOW 3 -#define AD774X_VT_DATA_HIGH 4 -#define AD774X_VT_DATA_MID 5 -#define AD774X_VT_DATA_LOW 6 -#define AD774X_CAP_SETUP 7 -#define AD774X_VT_SETUP 8 -#define AD774X_EXEC_SETUP 9 -#define AD774X_CFG 10 -#define AD774X_CAPDACA 11 -#define AD774X_CAPDACB 12 -#define AD774X_CAPDAC_EN (1 << 7) -#define AD774X_CAP_OFFH 13 -#define AD774X_CAP_OFFL 14 -#define AD774X_CAP_GAINH 15 -#define AD774X_CAP_GAINL 16 -#define AD774X_VOLT_GAINH 17 -#define AD774X_VOLT_GAINL 18 - -#define AD774X_MAX_CONV_MODE 6 - -/* - * struct ad774x_chip_info - chip specifc information - */ - -struct ad774x_chip_info { - struct i2c_client *client; - bool inter; - u16 cap_offs; /* Capacitive offset */ - u16 cap_gain; /* Capacitive gain calibration */ - u16 volt_gain; /* Voltage gain calibration */ - u8 cap_setup; - u8 vt_setup; - u8 exec_setup; - - char *conversion_mode; -}; - -struct ad774x_conversion_mode { - char *name; - u8 reg_cfg; -}; - -static struct ad774x_conversion_mode -ad774x_conv_mode_table[AD774X_MAX_CONV_MODE] = { - { "idle", 0 }, - { "continuous-conversion", 1 }, - { "single-conversion", 2 }, - { "power-down", 3 }, - { "offset-calibration", 5 }, - { "gain-calibration", 6 }, -}; - -/* - * ad774x register access by I2C - */ - -static int ad774x_i2c_read(struct ad774x_chip_info *chip, u8 reg, u8 *data, int len) -{ - struct i2c_client *client = chip->client; - int ret; - - ret = i2c_master_send(client, ®, 1); - if (ret < 0) { - dev_err(&client->dev, "I2C write error\n"); - return ret; - } - - ret = i2c_master_recv(client, data, len); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - return ret; -} - -static int ad774x_i2c_write(struct ad774x_chip_info *chip, u8 reg, u8 data) -{ - struct i2c_client *client = chip->client; - int ret; - - u8 tx[2] = { - reg, - data, - }; - - ret = i2c_master_send(client, tx, 2); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -/* - * sysfs nodes - */ - -#define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show) \ - IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store) \ - IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CAP_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in_capacitance_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_VT_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in_voltage0_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_EXEC_SETUP(_mode, _show, _store) \ - IIO_DEVICE_ATTR(exec_setup, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_VOLT_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in_voltage0_gain, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CAP_OFFS(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in_capacitance_offs, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CAP_GAIN(_mode, _show, _store) \ - IIO_DEVICE_ATTR(in_capacitance_gain, _mode, _show, _store, 0) -#define IIO_DEV_ATTR_CAP_DATA(_show) \ - IIO_DEVICE_ATTR(in_capacitance0_raw, S_IRUGO, _show, NULL, 0) -#define IIO_DEV_ATTR_VT_DATA(_show) \ - IIO_DEVICE_ATTR(in_voltage0_raw, S_IRUGO, _show, NULL, 0) - -static ssize_t ad774x_show_conversion_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int i; - int len = 0; - - for (i = 0; i < AD774X_MAX_CONV_MODE; i++) - len += sprintf(buf + len, "%s ", ad774x_conv_mode_table[i].name); - - len += sprintf(buf + len, "\n"); - - return len; -} - -static IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(ad774x_show_conversion_modes); - -static ssize_t ad774x_show_conversion_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%s\n", chip->conversion_mode); -} - -static ssize_t ad774x_store_conversion_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - u8 cfg; - int i; - - ad774x_i2c_read(chip, AD774X_CFG, &cfg, 1); - - for (i = 0; i < AD774X_MAX_CONV_MODE; i++) { - if (strncmp(buf, ad774x_conv_mode_table[i].name, - strlen(ad774x_conv_mode_table[i].name) - 1) == 0) { - chip->conversion_mode = ad774x_conv_mode_table[i].name; - cfg |= 0x18 | ad774x_conv_mode_table[i].reg_cfg; - ad774x_i2c_write(chip, AD774X_CFG, cfg); - return len; - } - } - - dev_err(dev, "not supported conversion mode\n"); - - return -EINVAL; -} - -static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR, - ad774x_show_conversion_mode, - ad774x_store_conversion_mode); - -static ssize_t ad774x_show_dac_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - u8 data; - - ad774x_i2c_read(chip, this_attr->address, &data, 1); - - return sprintf(buf, "%02x\n", data & 0x7F); -} - -static ssize_t ad774x_store_dac_value(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if (!ret) { - ad774x_i2c_write(chip, this_attr->address, - (data ? AD774X_CAPDAC_EN : 0) | (data & 0x7F)); - return len; - } - - return -EINVAL; -} - -static IIO_DEVICE_ATTR(out_capacitance0_raw, S_IRUGO | S_IWUSR, - ad774x_show_dac_value, - ad774x_store_dac_value, - AD774X_CAPDACA); - -static IIO_DEVICE_ATTR(out_capacitance1_raw, S_IRUGO | S_IWUSR, - ad774x_show_dac_value, - ad774x_store_dac_value, - AD774X_CAPDACB); - -static ssize_t ad774x_show_cap_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->cap_setup); -} - -static ssize_t ad774x_store_cap_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad774x_i2c_write(chip, AD774X_CAP_SETUP, data); - chip->cap_setup = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CAP_SETUP(S_IRUGO | S_IWUSR, - ad774x_show_cap_setup, - ad774x_store_cap_setup); - -static ssize_t ad774x_show_vt_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->vt_setup); -} - -static ssize_t ad774x_store_vt_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad774x_i2c_write(chip, AD774X_VT_SETUP, data); - chip->vt_setup = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_VT_SETUP(S_IRUGO | S_IWUSR, - ad774x_show_vt_setup, - ad774x_store_vt_setup); - -static ssize_t ad774x_show_exec_setup(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "0x%02x\n", chip->exec_setup); -} - -static ssize_t ad774x_store_exec_setup(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x100)) { - ad774x_i2c_write(chip, AD774X_EXEC_SETUP, data); - chip->exec_setup = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_EXEC_SETUP(S_IRUGO | S_IWUSR, - ad774x_show_exec_setup, - ad774x_store_exec_setup); - -static ssize_t ad774x_show_volt_gain(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->volt_gain); -} - -static ssize_t ad774x_store_volt_gain(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad774x_i2c_write(chip, AD774X_VOLT_GAINH, data >> 8); - ad774x_i2c_write(chip, AD774X_VOLT_GAINL, data); - chip->volt_gain = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_VOLT_GAIN(S_IRUGO | S_IWUSR, - ad774x_show_volt_gain, - ad774x_store_volt_gain); - -static ssize_t ad774x_show_cap_data(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - char tmp[3]; - - ad774x_i2c_read(chip, AD774X_CAP_DATA_HIGH, tmp, 3); - data = ((int)tmp[0] << 16) | ((int)tmp[1] << 8) | (int)tmp[2]; - - return sprintf(buf, "%ld\n", data); -} - -static IIO_DEV_ATTR_CAP_DATA(ad774x_show_cap_data); - -static ssize_t ad774x_show_vt_data(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - char tmp[3]; - - ad774x_i2c_read(chip, AD774X_VT_DATA_HIGH, tmp, 3); - data = ((int)tmp[0] << 16) | ((int)tmp[1] << 8) | (int)tmp[2]; - - return sprintf(buf, "%ld\n", data); -} - -static IIO_DEV_ATTR_VT_DATA(ad774x_show_vt_data); - -static ssize_t ad774x_show_cap_offs(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->cap_offs); -} - -static ssize_t ad774x_store_cap_offs(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad774x_i2c_write(chip, AD774X_CAP_OFFH, data >> 8); - ad774x_i2c_write(chip, AD774X_CAP_OFFL, data); - chip->cap_offs = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CAP_OFFS(S_IRUGO | S_IWUSR, - ad774x_show_cap_offs, - ad774x_store_cap_offs); - -static ssize_t ad774x_show_cap_gain(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - - return sprintf(buf, "%d\n", chip->cap_gain); -} - -static ssize_t ad774x_store_cap_gain(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad774x_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - - ret = strict_strtoul(buf, 10, &data); - - if ((!ret) && (data < 0x10000)) { - ad774x_i2c_write(chip, AD774X_CAP_GAINH, data >> 8); - ad774x_i2c_write(chip, AD774X_CAP_GAINL, data); - chip->cap_gain = data; - return len; - } - - return -EINVAL; -} - -static IIO_DEV_ATTR_CAP_GAIN(S_IRUGO | S_IWUSR, - ad774x_show_cap_gain, - ad774x_store_cap_gain); - -static struct attribute *ad774x_attributes[] = { - &iio_dev_attr_available_conversion_modes.dev_attr.attr, - &iio_dev_attr_conversion_mode.dev_attr.attr, - &iio_dev_attr_in_capacitance_setup.dev_attr.attr, - &iio_dev_attr_in_voltage0_setup.dev_attr.attr, - &iio_dev_attr_exec_setup.dev_attr.attr, - &iio_dev_attr_in_capacitance_offs.dev_attr.attr, - &iio_dev_attr_in_capacitance_gain.dev_attr.attr, - &iio_dev_attr_in_voltage0_gain.dev_attr.attr, - &iio_dev_attr_in_voltage0_raw.dev_attr.attr, - &iio_dev_attr_in_capacitance0_raw.dev_attr.attr, - &iio_dev_attr_out_capacitance0_raw.dev_attr.attr, - &iio_dev_attr_out_capacitance1_raw.dev_attr.attr, - NULL, -}; - -static const struct attribute_group ad774x_attribute_group = { - .attrs = ad774x_attributes, -}; - -/* - * data ready events - */ - -#define IIO_EVENT_CODE_CAP_RDY 0 -#define IIO_EVENT_CODE_VT_RDY 1 - -#define IIO_EVENT_ATTR_CAP_RDY_SH(_evlist, _show, _store, _mask) \ - IIO_EVENT_ATTR_SH(cap_rdy, _evlist, _show, _store, _mask) - -#define IIO_EVENT_ATTR_VT_RDY_SH(_evlist, _show, _store, _mask) \ - IIO_EVENT_ATTR_SH(vt_rdy, _evlist, _show, _store, _mask) - -static irqreturn_t ad774x_event_handler(int irq, void *private) -{ - struct iio_dev *indio_dev = private; - struct ad774x_chip_info *chip = iio_priv(indio_dev); - u8 int_status; - - ad774x_i2c_read(chip, AD774X_STATUS, &int_status, 1); - - if (int_status & AD774X_STATUS_RDYCAP) - iio_push_event(indio_dev, - IIO_EVENT_CODE_CAP_RDY, - iio_get_time_ns()); - - if (int_status & AD774X_STATUS_RDYVT) - iio_push_event(indio_dev, - IIO_EVENT_CODE_VT_RDY, - iio_get_time_ns()); - - return IRQ_HANDLED; -} - -static IIO_CONST_ATTR(cap_rdy_en, "1"); -static IIO_CONST_ATTR(vt_rdy_en, "1"); - -static struct attribute *ad774x_event_attributes[] = { - &iio_const_attr_cap_rdy_en.dev_attr.attr, - &iio_const_attr_vt_rdy_en.dev_attr.attr, - NULL, -}; - -static struct attribute_group ad774x_event_attribute_group = { - .attrs = ad774x_event_attributes, - .name = "events", -}; - -static const struct iio_info ad774x_info = { - .attrs = &ad774x_event_attribute_group, - .event_attrs = &ad774x_event_attribute_group, - .driver_module = THIS_MODULE, -}; -/* - * device probe and remove - */ - -static int __devinit ad774x_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct ad774x_chip_info *chip; - struct iio_dev *indio_dev; - - indio_dev = iio_allocate_device(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - chip = iio_priv(indio_dev); - /* this is only used for device removal purposes */ - i2c_set_clientdata(client, indio_dev); - - chip->client = client; - - /* Establish that the iio_dev is a child of the i2c device */ - indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; - indio_dev->info = &ad774x_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - if (client->irq) { - ret = request_threaded_irq(client->irq, - NULL, - &ad774x_event_handler, - IRQF_TRIGGER_FALLING, - "ad774x", - indio_dev); - if (ret) - goto error_free_dev; - } - - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_irq; - - dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq); - - return 0; - -error_free_irq: - free_irq(client->irq, indio_dev); -error_free_dev: - iio_free_device(indio_dev); -error_ret: - return ret; -} - -static int __devexit ad774x_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - if (client->irq) - free_irq(client->irq, indio_dev); - iio_device_unregister(indio_dev); - - return 0; -} - -static const struct i2c_device_id ad774x_id[] = { - { "ad7745", 0 }, - { "ad7746", 0 }, - { "ad7747", 0 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, ad774x_id); - -static struct i2c_driver ad774x_driver = { - .driver = { - .name = "ad774x", - }, - .probe = ad774x_probe, - .remove = __devexit_p(ad774x_remove), - .id_table = ad774x_id, -}; - -static __init int ad774x_init(void) -{ - return i2c_add_driver(&ad774x_driver); -} - -static __exit void ad774x_exit(void) -{ - i2c_del_driver(&ad774x_driver); -} - -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ad7745/6/7 capacitive sensor driver"); -MODULE_LICENSE("GPL v2"); - -module_init(ad774x_init); -module_exit(ad774x_exit); diff --git a/drivers/staging/iio/adc/ad7746.c b/drivers/staging/iio/adc/ad7746.c new file mode 100644 index 00000000000..0b251ad1780 --- /dev/null +++ b/drivers/staging/iio/adc/ad7746.c @@ -0,0 +1,804 @@ +/* + * AD7746 capacitive sensor driver supporting AD7745, AD7746 and AD7747 + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" + +#include "ad7746.h" + +/* + * AD7746 Register Definition + */ + +#define AD7746_REG_STATUS 0 +#define AD7746_REG_CAP_DATA_HIGH 1 +#define AD7746_REG_CAP_DATA_MID 2 +#define AD7746_REG_CAP_DATA_LOW 3 +#define AD7746_REG_VT_DATA_HIGH 4 +#define AD7746_REG_VT_DATA_MID 5 +#define AD7746_REG_VT_DATA_LOW 6 +#define AD7746_REG_CAP_SETUP 7 +#define AD7746_REG_VT_SETUP 8 +#define AD7746_REG_EXC_SETUP 9 +#define AD7746_REG_CFG 10 +#define AD7746_REG_CAPDACA 11 +#define AD7746_REG_CAPDACB 12 +#define AD7746_REG_CAP_OFFH 13 +#define AD7746_REG_CAP_OFFL 14 +#define AD7746_REG_CAP_GAINH 15 +#define AD7746_REG_CAP_GAINL 16 +#define AD7746_REG_VOLT_GAINH 17 +#define AD7746_REG_VOLT_GAINL 18 + +/* Status Register Bit Designations (AD7746_REG_STATUS) */ +#define AD7746_STATUS_EXCERR (1 << 3) +#define AD7746_STATUS_RDY (1 << 2) +#define AD7746_STATUS_RDYVT (1 << 1) +#define AD7746_STATUS_RDYCAP (1 << 0) + +/* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */ +#define AD7746_CAPSETUP_CAPEN (1 << 7) +#define AD7746_CAPSETUP_CIN2 (1 << 6) /* AD7746 only */ +#define AD7746_CAPSETUP_CAPDIFF (1 << 5) +#define AD7746_CAPSETUP_CACHOP (1 << 0) + +/* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */ +#define AD7746_VTSETUP_VTEN (1 << 7) +#define AD7746_VTSETUP_VTMD_INT_TEMP (0 << 5) +#define AD7746_VTSETUP_VTMD_EXT_TEMP (1 << 5) +#define AD7746_VTSETUP_VTMD_VDD_MON (2 << 5) +#define AD7746_VTSETUP_VTMD_EXT_VIN (3 << 5) +#define AD7746_VTSETUP_EXTREF (1 << 4) +#define AD7746_VTSETUP_VTSHORT (1 << 1) +#define AD7746_VTSETUP_VTCHOP (1 << 0) + +/* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */ +#define AD7746_EXCSETUP_CLKCTRL (1 << 7) +#define AD7746_EXCSETUP_EXCON (1 << 6) +#define AD7746_EXCSETUP_EXCB (1 << 5) +#define AD7746_EXCSETUP_NEXCB (1 << 4) +#define AD7746_EXCSETUP_EXCA (1 << 3) +#define AD7746_EXCSETUP_NEXCA (1 << 2) +#define AD7746_EXCSETUP_EXCLVL(x) (((x) & 0x3) << 0) + +/* Config Register Bit Designations (AD7746_REG_CFG) */ +#define AD7746_CONF_VTFS(x) ((x) << 6) +#define AD7746_CONF_CAPFS(x) ((x) << 3) +#define AD7746_CONF_MODE_IDLE (0 << 0) +#define AD7746_CONF_MODE_CONT_CONV (1 << 0) +#define AD7746_CONF_MODE_SINGLE_CONV (2 << 0) +#define AD7746_CONF_MODE_PWRDN (3 << 0) +#define AD7746_CONF_MODE_OFFS_CAL (5 << 0) +#define AD7746_CONF_MODE_GAIN_CAL (6 << 0) + +/* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */ +#define AD7746_CAPDAC_DACEN (1 << 7) +#define AD7746_CAPDAC_DACP(x) ((x) & 0x7F) + +/* + * struct ad7746_chip_info - chip specifc information + */ + +struct ad7746_chip_info { + struct i2c_client *client; + /* + * Capacitive channel digital filter setup; + * conversion time/update rate setup per channel + */ + u8 config; + u8 cap_setup; + u8 vt_setup; + u8 capdac[2][2]; + s8 capdac_set; +}; + +enum ad7746_chan { + VIN, + VIN_VDD, + TEMP_INT, + TEMP_EXT, + CIN1, + CIN1_DIFF, + CIN2, + CIN2_DIFF, +}; + +static const struct iio_chan_spec ad7746_channels[] = { + [VIN] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_VT_DATA_HIGH << 8 | + AD7746_VTSETUP_VTMD_EXT_VIN, + }, + [VIN_VDD] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .extend_name = "supply", + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_VT_DATA_HIGH << 8 | + AD7746_VTSETUP_VTMD_VDD_MON, + }, + [TEMP_INT] = { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .processed_val = IIO_PROCESSED, + .address = AD7746_REG_VT_DATA_HIGH << 8 | + AD7746_VTSETUP_VTMD_INT_TEMP, + }, + [TEMP_EXT] = { + .type = IIO_TEMP, + .indexed = 1, + .channel = 1, + .processed_val = IIO_PROCESSED, + .address = AD7746_REG_VT_DATA_HIGH << 8 | + AD7746_VTSETUP_VTMD_EXT_TEMP, + }, + [CIN1] = { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED) | + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_CAP_DATA_HIGH << 8, + }, + [CIN1_DIFF] = { + .type = IIO_CAPACITANCE, + .differential = 1, + .indexed = 1, + .channel = 0, + .channel2 = 2, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED) | + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_CAP_DATA_HIGH << 8 | + AD7746_CAPSETUP_CAPDIFF + }, + [CIN2] = { + .type = IIO_CAPACITANCE, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED) | + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_CAP_DATA_HIGH << 8 | + AD7746_CAPSETUP_CIN2, + }, + [CIN2_DIFF] = { + .type = IIO_CAPACITANCE, + .differential = 1, + .indexed = 1, + .channel = 1, + .channel2 = 3, + .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | + (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED) | + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = AD7746_REG_CAP_DATA_HIGH << 8 | + AD7746_CAPSETUP_CAPDIFF | AD7746_CAPSETUP_CIN2, + } +}; + +/* Values are Update Rate (Hz), Conversion Time (ms) + 1*/ +static const unsigned char ad7746_vt_filter_rate_table[][2] = { + {50, 20 + 1}, {31, 32 + 1}, {16, 62 + 1}, {8, 122 + 1}, +}; + +static const unsigned char ad7746_cap_filter_rate_table[][2] = { + {91, 11 + 1}, {84, 12 + 1}, {50, 20 + 1}, {26, 38 + 1}, + {16, 62 + 1}, {13, 77 + 1}, {11, 92 + 1}, {9, 110 + 1}, +}; + +static int ad7746_select_channel(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan) +{ + struct ad7746_chip_info *chip = iio_priv(indio_dev); + int ret, delay; + u8 vt_setup, cap_setup; + + switch (chan->type) { + case IIO_CAPACITANCE: + cap_setup = (chan->address & 0xFF) | AD7746_CAPSETUP_CAPEN; + vt_setup = chip->vt_setup & ~AD7746_VTSETUP_VTEN; + delay = ad7746_cap_filter_rate_table[(chip->config >> 3) & + 0x7][1]; + + if (chip->capdac_set != chan->channel) { + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACA, + chip->capdac[chan->channel][0]); + if (ret < 0) + return ret; + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACB, + chip->capdac[chan->channel][1]); + if (ret < 0) + return ret; + + chip->capdac_set = chan->channel; + } + break; + case IIO_VOLTAGE: + case IIO_TEMP: + vt_setup = (chan->address & 0xFF) | AD7746_VTSETUP_VTEN; + cap_setup = chip->cap_setup & ~AD7746_CAPSETUP_CAPEN; + delay = ad7746_cap_filter_rate_table[(chip->config >> 6) & + 0x3][1]; + break; + default: + return -EINVAL; + } + + if (chip->cap_setup != cap_setup) { + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAP_SETUP, + cap_setup); + if (ret < 0) + return ret; + + chip->cap_setup = cap_setup; + } + + if (chip->vt_setup != vt_setup) { + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_VT_SETUP, + vt_setup); + if (ret < 0) + return ret; + + chip->vt_setup = vt_setup; + } + + return delay; +} + +static inline ssize_t ad7746_start_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len, + u8 regval) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + bool doit; + int ret, timeout = 10; + + ret = strtobool(buf, &doit); + if (ret < 0) + return ret; + + if (!doit) + return 0; + + mutex_lock(&indio_dev->mlock); + regval |= chip->config; + ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval); + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); + return ret; + } + + do { + msleep(20); + ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG); + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); + return ret; + } + } while ((ret == regval) && timeout--); + + mutex_unlock(&indio_dev->mlock); + + return len; +} + +static ssize_t ad7746_start_offset_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + int ret = ad7746_select_channel(indio_dev, + &ad7746_channels[to_iio_dev_attr(attr)->address]); + if (ret < 0) + return ret; + + return ad7746_start_calib(dev, attr, buf, len, + AD7746_CONF_MODE_OFFS_CAL); +} + +static ssize_t ad7746_start_gain_calib(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + int ret = ad7746_select_channel(indio_dev, + &ad7746_channels[to_iio_dev_attr(attr)->address]); + if (ret < 0) + return ret; + + return ad7746_start_calib(dev, attr, buf, len, + AD7746_CONF_MODE_GAIN_CAL); +} + +static IIO_DEVICE_ATTR(in_capacitance0_calibbias_calibration, + S_IWUSR, NULL, ad7746_start_offset_calib, CIN1); +static IIO_DEVICE_ATTR(in_capacitance1_calibbias_calibration, + S_IWUSR, NULL, ad7746_start_offset_calib, CIN2); +static IIO_DEVICE_ATTR(in_capacitance0_calibscale_calibration, + S_IWUSR, NULL, ad7746_start_gain_calib, CIN1); +static IIO_DEVICE_ATTR(in_capacitance1_calibscale_calibration, + S_IWUSR, NULL, ad7746_start_gain_calib, CIN2); +static IIO_DEVICE_ATTR(in_voltage0_calibscale_calibration, + S_IWUSR, NULL, ad7746_start_gain_calib, VIN); + +static ssize_t ad7746_show_cap_filter_rate_setup(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", ad7746_cap_filter_rate_table[ + (chip->config >> 3) & 0x7][0]); +} + +static ssize_t ad7746_store_cap_filter_rate_setup(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + u8 data; + int ret, i; + + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; + + for (i = 0; i < ARRAY_SIZE(ad7746_cap_filter_rate_table); i++) + if (data >= ad7746_cap_filter_rate_table[i][0]) + break; + + if (i >= ARRAY_SIZE(ad7746_cap_filter_rate_table)) + i = ARRAY_SIZE(ad7746_cap_filter_rate_table) - 1; + + mutex_lock(&indio_dev->mlock); + chip->config &= ~AD7746_CONF_CAPFS(0x7); + chip->config |= AD7746_CONF_CAPFS(i); + mutex_unlock(&indio_dev->mlock); + + return len; +} + +static ssize_t ad7746_show_vt_filter_rate_setup(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", ad7746_vt_filter_rate_table[ + (chip->config >> 6) & 0x3][0]); +} + +static ssize_t ad7746_store_vt_filter_rate_setup(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + u8 data; + int ret, i; + + ret = kstrtou8(buf, 10, &data); + if (ret < 0) + return ret; + + for (i = 0; i < ARRAY_SIZE(ad7746_vt_filter_rate_table); i++) + if (data >= ad7746_vt_filter_rate_table[i][0]) + break; + + if (i >= ARRAY_SIZE(ad7746_vt_filter_rate_table)) + i = ARRAY_SIZE(ad7746_vt_filter_rate_table) - 1; + + mutex_lock(&indio_dev->mlock); + chip->config &= ~AD7746_CONF_VTFS(0x3); + chip->config |= AD7746_CONF_VTFS(i); + mutex_unlock(&indio_dev->mlock); + + return len; +} + +static IIO_DEVICE_ATTR(in_capacitance_sampling_frequency, + S_IRUGO | S_IWUSR, ad7746_show_cap_filter_rate_setup, + ad7746_store_cap_filter_rate_setup, 0); + +static IIO_DEVICE_ATTR(in_voltage_sampling_frequency, + S_IRUGO | S_IWUSR, ad7746_show_vt_filter_rate_setup, + ad7746_store_vt_filter_rate_setup, 0); + +static IIO_CONST_ATTR(in_voltage_sampling_frequency_available, "50 31 16 8"); +static IIO_CONST_ATTR(in_capacitance_sampling_frequency_available, + "91 84 50 26 16 13 11 9"); + +static struct attribute *ad7746_attributes[] = { + &iio_dev_attr_in_capacitance_sampling_frequency.dev_attr.attr, + &iio_dev_attr_in_voltage_sampling_frequency.dev_attr.attr, + &iio_dev_attr_in_capacitance0_calibbias_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance0_calibscale_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance1_calibscale_calibration.dev_attr.attr, + &iio_dev_attr_in_capacitance1_calibbias_calibration.dev_attr.attr, + &iio_dev_attr_in_voltage0_calibscale_calibration.dev_attr.attr, + &iio_const_attr_in_voltage_sampling_frequency_available.dev_attr.attr, + &iio_const_attr_in_capacitance_sampling_frequency_available. + dev_attr.attr, + NULL, +}; + +static const struct attribute_group ad7746_attribute_group = { + .attrs = ad7746_attributes, +}; + +static int ad7746_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct ad7746_chip_info *chip = iio_priv(indio_dev); + int ret, reg; + + mutex_lock(&indio_dev->mlock); + + switch (mask) { + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + if (val != 1) { + ret = -EINVAL; + goto out; + } + + val = (val2 * 1024) / 15625; + + switch (chan->type) { + case IIO_CAPACITANCE: + reg = AD7746_REG_CAP_GAINH; + break; + case IIO_VOLTAGE: + reg = AD7746_REG_VOLT_GAINH; + break; + default: + ret = -EINVAL; + goto out; + } + + ret = i2c_smbus_write_word_data(chip->client, reg, swab16(val)); + if (ret < 0) + goto out; + + ret = 0; + break; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED): + if ((val < 0) | (val > 0xFFFF)) { + ret = -EINVAL; + goto out; + } + ret = i2c_smbus_write_word_data(chip->client, + AD7746_REG_CAP_OFFH, swab16(val)); + if (ret < 0) + goto out; + + ret = 0; + break; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + if ((val < 0) | (val > 43008000)) { /* 21pF */ + ret = -EINVAL; + goto out; + } + + /* CAPDAC Scale = 21pF_typ / 127 + * CIN Scale = 8.192pF / 2^24 + * Offset Scale = CAPDAC Scale / CIN Scale = 338646 + * */ + + val /= 338646; + + chip->capdac[chan->channel][chan->differential] = (val > 0 ? + AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0); + + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACA, + chip->capdac[chan->channel][0]); + if (ret < 0) + goto out; + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACB, + chip->capdac[chan->channel][1]); + if (ret < 0) + goto out; + + chip->capdac_set = chan->channel; + + ret = 0; + break; + default: + ret = -EINVAL; + } + +out: + mutex_unlock(&indio_dev->mlock); + return ret; +} + +static int ad7746_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + struct ad7746_chip_info *chip = iio_priv(indio_dev); + int ret, delay; + u8 regval, reg; + + union { + u32 d32; + u8 d8[4]; + } data; + + mutex_lock(&indio_dev->mlock); + + switch (mask) { + case 0: + ret = ad7746_select_channel(indio_dev, chan); + if (ret < 0) + goto out; + delay = ret; + + regval = chip->config | AD7746_CONF_MODE_SINGLE_CONV; + ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, + regval); + if (ret < 0) + goto out; + + msleep(delay); + /* Now read the actual register */ + + ret = i2c_smbus_read_i2c_block_data(chip->client, + chan->address >> 8, 3, &data.d8[1]); + + if (ret < 0) + goto out; + + *val = (be32_to_cpu(data.d32) & 0xFFFFFF) - 0x800000; + + switch (chan->type) { + case IIO_TEMP: + /* temperature in milli degrees Celsius + * T = ((*val / 2048) - 4096) * 1000 + */ + *val = (*val * 125) / 256; + break; + case IIO_VOLTAGE: + if (chan->channel == 1) /* supply_raw*/ + *val = *val * 6; + break; + default: + break; + } + + ret = IIO_VAL_INT; + break; + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + switch (chan->type) { + case IIO_CAPACITANCE: + reg = AD7746_REG_CAP_GAINH; + break; + case IIO_VOLTAGE: + reg = AD7746_REG_VOLT_GAINH; + break; + default: + ret = -EINVAL; + goto out; + } + + ret = i2c_smbus_read_word_data(chip->client, reg); + if (ret < 0) + goto out; + /* 1 + gain_val / 2^16 */ + *val = 1; + *val2 = (15625 * swab16(ret)) / 1024; + + ret = IIO_VAL_INT_PLUS_MICRO; + break; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED): + ret = i2c_smbus_read_word_data(chip->client, + AD7746_REG_CAP_OFFH); + if (ret < 0) + goto out; + *val = swab16(ret); + + ret = IIO_VAL_INT; + break; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + *val = AD7746_CAPDAC_DACP(chip->capdac[chan->channel] + [chan->differential]) * 338646; + + ret = IIO_VAL_INT; + break; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + switch (chan->type) { + case IIO_CAPACITANCE: + /* 8.192pf / 2^24 */ + *val2 = 488; + *val = 0; + break; + case IIO_VOLTAGE: + /* 1170mV / 2^23 */ + *val2 = 139475; + *val = 0; + break; + default: + ret = -EINVAL; + goto out; + } + + ret = IIO_VAL_INT_PLUS_NANO; + break; + default: + ret = -EINVAL; + }; +out: + mutex_unlock(&indio_dev->mlock); + return ret; +} + +static const struct iio_info ad7746_info = { + .attrs = &ad7746_attribute_group, + .read_raw = &ad7746_read_raw, + .write_raw = &ad7746_write_raw, + .driver_module = THIS_MODULE, +}; + +/* + * device probe and remove + */ + +static int __devinit ad7746_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct ad7746_platform_data *pdata = client->dev.platform_data; + struct ad7746_chip_info *chip; + struct iio_dev *indio_dev; + int ret = 0; + unsigned char regval = 0; + + indio_dev = iio_allocate_device(sizeof(*chip)); + if (indio_dev == NULL) { + ret = -ENOMEM; + goto error_ret; + } + chip = iio_priv(indio_dev); + /* this is only used for device removal purposes */ + i2c_set_clientdata(client, indio_dev); + + chip->client = client; + chip->capdac_set = -1; + + /* Establish that the iio_dev is a child of the i2c device */ + indio_dev->name = id->name; + indio_dev->dev.parent = &client->dev; + indio_dev->info = &ad7746_info; + indio_dev->channels = ad7746_channels; + if (id->driver_data == 7746) + indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); + else + indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2; + indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + if (pdata) { + if (pdata->exca_en) { + if (pdata->exca_inv_en) + regval |= AD7746_EXCSETUP_NEXCA; + else + regval |= AD7746_EXCSETUP_EXCA; + } + + if (pdata->excb_en) { + if (pdata->excb_inv_en) + regval |= AD7746_EXCSETUP_NEXCB; + else + regval |= AD7746_EXCSETUP_EXCB; + } + + regval |= AD7746_EXCSETUP_EXCLVL(pdata->exclvl); + } else { + dev_warn(&client->dev, "No platform data? using default\n"); + regval = AD7746_EXCSETUP_EXCA | AD7746_EXCSETUP_EXCB | + AD7746_EXCSETUP_EXCLVL(3); + } + + ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_EXC_SETUP, regval); + if (ret < 0) + goto error_free_dev; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_dev; + + dev_info(&client->dev, "%s capacitive sensor registered\n", id->name); + + return 0; + +error_free_dev: + iio_free_device(indio_dev); +error_ret: + return ret; +} + +static int __devexit ad7746_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + + return 0; +} + +static const struct i2c_device_id ad7746_id[] = { + { "ad7745", 7745 }, + { "ad7746", 7746 }, + { "ad7747", 7747 }, + {} +}; + +MODULE_DEVICE_TABLE(i2c, ad7746_id); + +static struct i2c_driver ad7746_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .probe = ad7746_probe, + .remove = __devexit_p(ad7746_remove), + .id_table = ad7746_id, +}; + +static __init int ad7746_init(void) +{ + return i2c_add_driver(&ad7746_driver); +} + +static __exit void ad7746_exit(void) +{ + i2c_del_driver(&ad7746_driver); +} + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD7746/5/7 capacitive sensor driver"); +MODULE_LICENSE("GPL v2"); + +module_init(ad7746_init); +module_exit(ad7746_exit); diff --git a/drivers/staging/iio/adc/ad7746.h b/drivers/staging/iio/adc/ad7746.h new file mode 100644 index 00000000000..ea8572d1df0 --- /dev/null +++ b/drivers/staging/iio/adc/ad7746.h @@ -0,0 +1,29 @@ +/* + * AD7746 capacitive sensor driver supporting AD7745, AD7746 and AD7747 + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#ifndef IIO_CDC_AD7746_H_ +#define IIO_CDC_AD7746_H_ + +/* + * TODO: struct ad7746_platform_data needs to go into include/linux/iio + */ + +#define AD7466_EXCLVL_0 0 /* +-VDD/8 */ +#define AD7466_EXCLVL_1 1 /* +-VDD/4 */ +#define AD7466_EXCLVL_2 2 /* +-VDD * 3/8 */ +#define AD7466_EXCLVL_3 3 /* +-VDD/2 */ + +struct ad7746_platform_data { + unsigned char exclvl; /*Excitation Voltage Level */ + bool exca_en; /* enables EXCA pin as the excitation output */ + bool exca_inv_en; /* enables /EXCA pin as the excitation output */ + bool excb_en; /* enables EXCB pin as the excitation output */ + bool excb_inv_en; /* enables /EXCB pin as the excitation output */ +}; + +#endif /* IIO_CDC_AD7746_H_ */ From 0aeac51d1b8908ee3987ecba67f9c81a510d35d9 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Wed, 21 Sep 2011 11:15:50 +0100 Subject: [PATCH 1147/1519] staging: iio: Move sensor drivers to sub menus We have a lot of drivers now, so the iio sub menu becomes quite large. This patch creates sub menus for the different sensors. Signed-off-by: Manuel Stahl Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/Kconfig | 4 +++- drivers/staging/iio/adc/Kconfig | 4 +++- drivers/staging/iio/addac/Kconfig | 4 +++- drivers/staging/iio/dac/Kconfig | 4 +++- drivers/staging/iio/dds/Kconfig | 4 +++- drivers/staging/iio/gyro/Kconfig | 4 +++- drivers/staging/iio/impedance-analyzer/Kconfig | 4 +++- drivers/staging/iio/imu/Kconfig | 4 +++- drivers/staging/iio/light/Kconfig | 4 +++- drivers/staging/iio/magnetometer/Kconfig | 3 ++- drivers/staging/iio/meter/Kconfig | 4 +++- drivers/staging/iio/resolver/Kconfig | 3 ++- 12 files changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index 81a33b60512..bf38114233b 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -1,7 +1,7 @@ # # Accelerometer drivers # -comment "Accelerometers" +menu "Accelerometers" config ADIS16201 tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer" @@ -100,3 +100,5 @@ config SCA3000 help Say yes here to build support for the VTI SCA3000 series of SPI accelerometers. These devices use a hardware ring buffer. + +endmenu diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 0482073744f..27dda13770b 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -1,7 +1,7 @@ # # ADC drivers # -comment "Analog to digital convertors" +menu "Analog to digital convertors" config AD7150 tristate "Analog Devices ad7150/1/6 capacitive sensor driver" @@ -229,3 +229,5 @@ config MAX1363_RING_BUFFER help Say yes here to include ring buffer support in the MAX1363 ADC driver. + +endmenu diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig index 9847baf0270..869540e6af8 100644 --- a/drivers/staging/iio/addac/Kconfig +++ b/drivers/staging/iio/addac/Kconfig @@ -1,7 +1,7 @@ # # ADDAC drivers # -comment "Analog digital bi-direction convertors" +menu "Analog digital bi-direction convertors" config ADT7316 tristate "Analog Devices ADT7316/7/8 ADT7516/7/9 temperature sensor, ADC and DAC driver" @@ -23,3 +23,5 @@ config ADT7316_I2C help Say yes here to build I2C bus support for Analog Devices ADT7316/7/8 and ADT7516/7/9. + +endmenu diff --git a/drivers/staging/iio/dac/Kconfig b/drivers/staging/iio/dac/Kconfig index 7ddae357f20..30001567ef0 100644 --- a/drivers/staging/iio/dac/Kconfig +++ b/drivers/staging/iio/dac/Kconfig @@ -1,7 +1,7 @@ # # DAC drivers # -comment "Digital to analog convertors" +menu "Digital to analog convertors" config AD5624R_SPI tristate "Analog Devices AD5624/44/64R DAC spi driver" @@ -62,3 +62,5 @@ config MAX517 This driver can also be built as a module. If so, the module will be called max517. + +endmenu diff --git a/drivers/staging/iio/dds/Kconfig b/drivers/staging/iio/dds/Kconfig index e07431d8009..93b7141b2c1 100644 --- a/drivers/staging/iio/dds/Kconfig +++ b/drivers/staging/iio/dds/Kconfig @@ -1,7 +1,7 @@ # # Direct Digital Synthesis drivers # -comment "Direct Digital Synthesis" +menu "Direct Digital Synthesis" config AD5930 tristate "Analog Devices ad5930/5932 driver" @@ -57,3 +57,5 @@ config AD9951 help Say yes here to build support for Analog Devices DDS chip ad9951, provides direct access via sysfs. + +endmenu diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index ae2e7d3095a..86774e3c97c 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -1,7 +1,7 @@ # # IIO Digital Gyroscope Sensor drivers configuration # -comment "Digital gyroscope sensors" +menu "Digital gyroscope sensors" config ADIS16060 tristate "Analog Devices ADIS16060 Yaw Rate Gyroscope with SPI driver" @@ -45,3 +45,5 @@ config ADXRS450 This driver can also be built as a module. If so, the module will be called adxrs450. + +endmenu diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig index 9e91a9bc8bf..cce1ce3b5d9 100644 --- a/drivers/staging/iio/impedance-analyzer/Kconfig +++ b/drivers/staging/iio/impedance-analyzer/Kconfig @@ -1,7 +1,7 @@ # # Impedance Converter, Network Analyzer drivers # -comment "Network Analyzer, Impedance Converters" +menu "Network Analyzer, Impedance Converters" config AD5933 tristate "Analog Devices AD5933, AD5934 driver" @@ -14,3 +14,5 @@ config AD5933 To compile this driver as a module, choose M here: the module will be called ad5933. + +endmenu diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig index e0e01446117..233c76a313e 100644 --- a/drivers/staging/iio/imu/Kconfig +++ b/drivers/staging/iio/imu/Kconfig @@ -1,7 +1,7 @@ # # IIO imu drivers configuration # -comment "Inertial measurement units" +menu "Inertial measurement units" config ADIS16400 tristate "Analog Devices ADIS16400 and similar IMU SPI driver" @@ -13,3 +13,5 @@ config ADIS16400 adis16354, adis16355, adis16360, adis16362, adis16364, adis16365, adis16400 and adis16405 triaxial inertial sensors (adis16400 series also have magnetometers). + +endmenu diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig index 1ad2d56c8ba..e7e9159d989 100644 --- a/drivers/staging/iio/light/Kconfig +++ b/drivers/staging/iio/light/Kconfig @@ -1,7 +1,7 @@ # # Light sensors # -comment "Light sensors" +menu "Light sensors" config SENSORS_ISL29018 tristate "ISL 29018 light and proximity sensor" @@ -30,3 +30,5 @@ config TSL2583 help Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices. Access ALS data via iio, sysfs. + +endmenu diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig index 81b579d371d..b8c149db293 100644 --- a/drivers/staging/iio/magnetometer/Kconfig +++ b/drivers/staging/iio/magnetometer/Kconfig @@ -1,7 +1,7 @@ # # Magnetometer sensors # -comment "Magnetometer sensors" +menu "Magnetometer sensors" config SENSORS_AK8975 tristate "Asahi Kasei AK8975 3-Axis Magnetometer" @@ -23,3 +23,4 @@ config SENSORS_HMC5843 To compile this driver as a module, choose M here: the module will be called hmc5843 +endmenu diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig index 12e36e46069..a8deab27831 100644 --- a/drivers/staging/iio/meter/Kconfig +++ b/drivers/staging/iio/meter/Kconfig @@ -1,7 +1,7 @@ # # IIO meter drivers configuration # -comment "Active energy metering IC" +menu "Active energy metering IC" config ADE7753 tristate "Analog Devices ADE7753/6 Single-Phase Multifunction Metering IC Driver" @@ -59,3 +59,5 @@ config ADE7854_SPI To compile this driver as a module, choose M here: the module will be called ade7854-spi. + +endmenu diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index 6ecd79e3003..07c309bba57 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -1,7 +1,7 @@ # # Resolver/Synchro drivers # -comment "Resolver to digital converters" +menu "Resolver to digital converters" config AD2S90 tristate "Analog Devices ad2s90 driver" @@ -25,3 +25,4 @@ config AD2S1210 Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s1210, provides direct access via sysfs. +endmenu From 15739cd2d605e60faf76c1a850bdfc04f8c5a1a6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:51 +0100 Subject: [PATCH 1148/1519] staging:iio:documentation general refresh of abi docs. Numerous small fixes and additions of missing elements. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 183 +++++++++--------- 1 file changed, 91 insertions(+), 92 deletions(-) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index 1d52c963cb3..f7bc59a57a7 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -6,12 +6,6 @@ Description: Corresponds to a grouping of sensor channels. X is the IIO index of the device. -What: /sys/bus/iio/devices/iio:deviceX/power_state -KernelVersion: 2.6.37 -Contact: linux-iio@vger.kernel.org -Description: - This property gets/sets the device power state. - What: /sys/bus/iio/devices/triggerX KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org @@ -39,6 +33,8 @@ Description: Typically a part number. What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency +What: /sys/bus/iio/devices/iio:deviceX/buffer/sampling_frequency +What: /sys/bus/iio/devices/triggerX/sampling_frequency KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -49,27 +45,17 @@ Description: effects datardy triggers, hardware buffers and the sysfs direct access interfaces, it may be found in any of the relevant directories. If it effects all of the above - then it is to be found in the base device directory as here. + then it is to be found in the base device directory. What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency_available +What: /sys/.../iio:deviceX/buffer/sampling_frequency_available +What: /sys/bus/iio/devices/triggerX/sampling_frequency_available KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: When the internal sampling clock can only take a small discrete set of values, this file lists those available. -What: /sys/bus/iio/devices/iio:deviceX/range -KernelVersion: 2.6.38 -Contact: linux-iio@vger.kernel.org -Description: - Hardware dependent ADC Full Scale Range in mVolt. - -What: /sys/bus/iio/devices/iio:deviceX/range_available -KernelVersion: 2.6.38 -Contact: linux-iio@vger.kernel.org -Description: - Hardware dependent supported vales for ADC Full Scale Range. - What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org @@ -92,7 +78,8 @@ Description: channel Y. In special cases where the channel does not correspond to externally available input one of the named versions may be used. The number must always be specified and - unique to allow association with event codes. + unique to allow association with event codes. Units after + application of scale and offset are microvolts. What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw KernelVersion: 2.6.35 @@ -102,9 +89,11 @@ Description: channel Y - channel Z where these channel numbers apply to the physically equivalent inputs when non differential readings are separately available. In differential only parts, then all that - is required is a consistent labeling. + is required is a consistent labeling. Units after application + of scale and offset are microvolts. What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw +What: /sys/bus/iio/devices/iio:deviceX/in_tempX_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_y_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_z_raw @@ -114,7 +103,8 @@ Description: Raw (unscaled no bias removal etc) temperature measurement. It an axis is specified it generally means that the temperature sensor is associated with one part of a compound device (e.g. - a gyroscope axis). + a gyroscope axis). Units after application of scale and offset + are milli degrees Celsuis. What: /sys/bus/iio/devices/iio:deviceX/in_tempX_input KernelVersion: 2.6.38 @@ -129,10 +119,9 @@ KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Acceleration in direction x, y or z (may be arbitrarily assigned - but should match other such assignments on device) - channel m (not present if only one accelerometer channel at - this orientation). Has all of the equivalent parameters as per - voltageY. Units after application of scale and offset are m/s^2. + but should match other such assignments on device). + Has all of the equivalent parameters as per voltageY. Units + after application of scale and offset are m/s^2. What: /sys/bus/iio/devices/iio:deviceX/in_gyro_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_gyro_y_raw @@ -143,7 +132,8 @@ Description: Angular velocity about axis x, y or z (may be arbitrarily assigned) Data converted by application of offset then scale to radians per second. Has all the equivalent parameters as - per voltageY. + per voltageY. Units after application of scale and offset are + radians per second. What: /sys/bus/iio/devices/iio:deviceX/in_incli_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_incli_y_raw @@ -162,10 +152,8 @@ KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Magnetic field along axis x, y or z (may be arbitrarily - assigned) channel m (not present if only one magnetometer - at this orientation). Data converted by application of - offset then scale to Gauss. Has all the equivalent modifiers - as per voltageY. + assigned). Data converted by application of offset + then scale to Gauss. What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_peak_raw What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_peak_raw @@ -173,10 +161,9 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_peak_raw KernelVersion: 2.6.36 Contact: linux-iio@vger.kernel.org Description: - Some devices provide a store of the highest value seen since - some reset condition. These attributes allow access to this - and are otherwise the direct equivalent of the - Y[_name]_raw attributes. + Highest value since some reset condition. These + attributes allow access to this and are otherwise + the direct equivalent of the Y[_name]_raw attributes. What: /sys/bus/iio/devices/iio:deviceX/in_accel_xyz_squared_peak_raw KernelVersion: 2.6.36 @@ -186,6 +173,12 @@ Description: the underlying value in the specified directions. What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset +What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset +What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset +What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset +What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org @@ -193,13 +186,16 @@ Description: If known for a device, offset to be added to [Y]_raw prior to scaling by [Y]_scale in order to obtain value in the units as specified in [y]_raw documentation. - Not present if the offset is always 0 or unknown. If Y is not - present, then the offset applies to all in channels of . + Not present if the offset is always 0 or unknown. If Y or + axis is not present, then the offset applies to all + in channels of . May be writable if a variable offset can be applied on the device. Note that this is different to calibbias which is for devices (or drivers) that apply offsets to compensate for variation between different instances of the part, typically adjusted by using some hardware supported calibration procedure. + Calibbias is applied internally, offset is applied in userspace + to the _raw output. What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale @@ -219,9 +215,9 @@ Description: post addition of [Y][_name]_offset in order to obtain the measured value in units as specified in [Y][_name]_raw documentation.. If shared across all in - channels then Y is not present and the value is called - [Y][_name]_scale. The peak modifier means this value - is applied to Y[_name]_peak_raw values. + channels then Y and are not present and the value is + called [Y][_name]_scale. The peak modifier means this + value is applied to Y[_name]_peak_raw values. What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibbias @@ -233,8 +229,7 @@ KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Hardware applied calibration offset. (assumed to fix production - inaccuracies). If shared across all channels, _calibbias - is used. + inaccuracies). What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale What /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_calibscale @@ -253,13 +248,16 @@ Description: _calibscale is used. What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available +What: /sys/.../iio:deviceX/in_voltageX_scale_available +What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available +What: /sys/.../iio:deviceX/out_voltageX_scale_available KernelVersion: 2.635 Contact: linux-iio@vger.kernel.org Description: If a discrete set of scale values are available, they are listed in this attribute. -What: /sys/bus/iio/devices/iio:deviceX/out_votlageY_raw +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_raw KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -333,22 +331,22 @@ What: /sys/.../iio:deviceX/events/in_magn_y_thresh_rising_en What: /sys/.../iio:deviceX/events/in_magn_y_thresh_falling_en What: /sys/.../iio:deviceX/events/in_magn_z_thresh_rising_en What: /sys/.../iio:deviceX/events/in_magn_z_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_voltageZ_supply_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_voltageZ_supply_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_voltageZ_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_voltageZ_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_temp_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_temp_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_voltageY_supply_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_voltageY_supply_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_voltageY_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_voltageY_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_tempY_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_tempY_thresh_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Event generated when channel passes a threshold in the specified (_rising|_falling) direction. If the direction is not specified, then either the device will report an event which ever direction - a single threshold value is called in (e.g. - [Z][_name]__thresh_value) or - [Z][_name]__thresh_rising_value and - [Z][_name]__thresh_falling_value may take + a single threshold value is passed in (e.g. + [Y][_name]__thresh_value) or + [Y][_name]__thresh_rising_value and + [Y][_name]__thresh_falling_value may take different values, but the device can only enable both thresholds or neither. Note the driver will assume the last p events requested are @@ -378,12 +376,12 @@ What: /sys/.../iio:deviceX/events/in_magn_y_roc_rising_en What: /sys/.../iio:deviceX/events/in_magn_y_roc_falling_en What: /sys/.../iio:deviceX/events/in_magn_z_roc_rising_en What: /sys/.../iio:deviceX/events/in_magn_z_roc_falling_en -What: /sys/.../iio:deviceX/events/in_voltageZ_supply_roc_rising_en -What: /sys/.../iio:deviceX/events/in_voltageZ_supply_roc_falling_en -What: /sys/.../iio:deviceX/events/in_voltageZ_roc_rising_en -What: /sys/.../iio:deviceX/events/in_voltageZ_roc_falling_en -What: /sys/.../iio:deviceX/events/in_temp_roc_rising_en -What: /sys/.../iio:deviceX/events/in_temp_roc_falling_en +What: /sys/.../iio:deviceX/events/in_voltageY_supply_roc_rising_en +What: /sys/.../iio:deviceX/events/in_voltageY_supply_roc_falling_en +What: /sys/.../iio:deviceX/events/in_voltageY_roc_rising_en +What: /sys/.../iio:deviceX/events/in_voltageY_roc_falling_en +What: /sys/.../iio:deviceX/events/in_tempY_roc_rising_en +What: /sys/.../iio:deviceX/events/in_tempY_roc_falling_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -391,10 +389,10 @@ Description: change (1st differential) in the specified (_rising|_falling) direction. If the direction is not specified, then either the device will report an event which ever direction a single - threshold value is called in (e.g. - [Z][_name]__roc_value) or - [Z][_name]__roc_rising_value and - [Z][_name]__roc_falling_value may take + threshold value is passed in (e.g. + [Y][_name]__roc_value) or + [Y][_name]__roc_rising_value and + [Y][_name]__roc_falling_value may take different values, but the device can only enable both rate of change thresholds or neither. Note the driver will assume the last p events requested are @@ -424,19 +422,19 @@ What: /sys/.../events/in_magn_y_raw_thresh_rising_value What: /sys/.../events/in_magn_y_raw_thresh_falling_value What: /sys/.../events/in_magn_z_raw_thresh_rising_value What: /sys/.../events/in_magn_z_raw_thresh_falling_value -What: /sys/.../events/in_voltageZ_supply_raw_thresh_rising_value -What: /sys/.../events/in_voltageZ_supply_raw_thresh_falling_value -What: /sys/.../events/in_voltageZ_raw_thresh_falling_value -What: /sys/.../events/in_voltageZ_raw_thresh_falling_value -What: /sys/.../events/in_temp_raw_thresh_falling_value -What: /sys/.../events/in_temp_raw_thresh_falling_value +What: /sys/.../events/in_voltageY_supply_raw_thresh_rising_value +What: /sys/.../events/in_voltageY_supply_raw_thresh_falling_value +What: /sys/.../events/in_voltageY_raw_thresh_falling_value +What: /sys/.../events/in_voltageY_raw_thresh_falling_value +What: /sys/.../events/in_tempY_raw_thresh_falling_value +What: /sys/.../events/in_tempY_raw_thresh_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Specifies the value of threshold that the device is comparing against for the events enabled by - Z[_name]_thresh[_rising|falling]_en. - If separate attributes exist for the two directions, but + Y[_name]_thresh[_rising|falling]_en. + If separate attributes exist for the two directions, but direction is not specified for this attribute, then a single threshold value applies to both directions. The raw or input element of the name indicates whether the @@ -461,18 +459,18 @@ What: /sys/.../events/in_magn_y_raw_roc_rising_value What: /sys/.../events/in_magn_y_raw_roc_falling_value What: /sys/.../events/in_magn_z_raw_roc_rising_value What: /sys/.../events/in_magn_z_raw_roc_falling_value -What: /sys/.../events/in_voltageZ_supply_raw_roc_rising_value -What: /sys/.../events/in_voltageZ_supply_raw_roc_falling_value -What: /sys/.../events/in_voltageZ_raw_roc_falling_value -What: /sys/.../events/in_voltageZ_raw_roc_falling_value -What: /sys/.../events/in_temp_raw_roc_falling_value -What: /sys/.../events/in_temp_raw_roc_falling_value +What: /sys/.../events/in_voltageY_supply_raw_roc_rising_value +What: /sys/.../events/in_voltageY_supply_raw_roc_falling_value +What: /sys/.../events/in_voltageY_raw_roc_falling_value +What: /sys/.../events/in_voltageY_raw_roc_falling_value +What: /sys/.../events/in_tempY_raw_roc_falling_value +What: /sys/.../events/in_tempY_raw_roc_falling_value KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: Specifies the value of rate of change threshold that the device is comparing against for the events enabled by - [Z][_name]_roc[_rising|falling]_en. + [Y][_name]_roc[_rising|falling]_en. If separate attributes exist for the two directions, but direction is not specified for this attribute, then a single threshold value applies to both directions. @@ -516,18 +514,18 @@ What: /sys/.../events/in_magn_z_thresh_rising_period What: /sys/.../events/in_magn_z_thresh_falling_period What: /sys/.../events/in_magn_z_roc_rising_period What: /sys/.../events/in_magn_z_roc_falling_period -What: /sys/.../events/in_voltageZ_supply_thresh_rising_period -What: /sys/.../events/in_voltageZ_supply_thresh_falling_period -What: /sys/.../events/in_voltagez_supply_roc_rising_period -What: /sys/.../events/in_voltageZ_supply_roc_falling_period -What: /sys/.../events/in_voltageZ_thresh_rising_period -What: /sys/.../events/in_voltageZ_thresh_falling_period -What: /sys/.../events/in_voltageZ_roc_rising_period -What: /sys/.../events/in_voltageZ_roc_falling_period -What: /sys/.../events/in_temp_thresh_rising_period -What: /sys/.../events/in_temp_thresh_falling_period -What: /sys/.../events/in_temp_roc_rising_period -What: /sys/.../events/in_temp_roc_falling_period +What: /sys/.../events/in_voltageY_supply_thresh_rising_period +What: /sys/.../events/in_voltageY_supply_thresh_falling_period +What: /sys/.../events/in_voltageY_supply_roc_rising_period +What: /sys/.../events/in_voltageY_supply_roc_falling_period +What: /sys/.../events/in_voltageY_thresh_rising_period +What: /sys/.../events/in_voltageY_thresh_falling_period +What: /sys/.../events/in_voltageY_roc_rising_period +What: /sys/.../events/in_voltageY_roc_falling_period +What: /sys/.../events/in_tempY_thresh_rising_period +What: /sys/.../events/in_tempY_thresh_falling_period +What: /sys/.../events/in_tempY_roc_rising_period +What: /sys/.../events/in_tempY_roc_falling_period What: /sys/.../events/in_accel_x&y&z_mag_falling_period KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org @@ -635,7 +633,8 @@ Contact: linux-iio@vger.kernel.org Description: Description of the scan element data storage within the buffer and hence the form in which it is read from user-space. - Form is [s|u]bits/storagebits[>>shift]. s or u specifies if + Form is [be|le]:[s|u]bits/storagebits[>>shift]. + be or le specifies big or little endian. s or u specifies if signed (2's complement) or unsigned. bits is the number of bits of data and storagebits is the space (after padding) that it occupies in the buffer. shift if specified, is the shift that @@ -672,7 +671,7 @@ What: /sys/.../buffer/scan_elements/in_magn_y_index What: /sys/.../buffer/scan_elements/in_magn_z_index What: /sys/.../buffer/scan_elements/in_incli_x_index What: /sys/.../buffer/scan_elements/in_incli_y_index -What: /sys/.../buffer/scan_elements/in_voltage_timestamp_index +What: /sys/.../buffer/scan_elements/in_timestamp_index KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: From 0baf29d658c71e39f5d7f83249af2fe6a8cd1dcb Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:52 +0100 Subject: [PATCH 1149/1519] staging:iio:documentation Add abi docs for capacitance adcs. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index f7bc59a57a7..fb6c3812016 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -92,6 +92,24 @@ Description: is required is a consistent labeling. Units after application of scale and offset are microvolts. +What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw +KernelVersion: 3.2 +Contact: linux-iio@vger.kernel.org +Description: + Raw capacitance measurement from channel Y. Units after + application of scale and offset are nanofarads. + +What: /sys/.../iio:deviceX/in_capacitanceY-in_capacitanceZ_raw +KernelVersion: 3.2 +Contact: linux-iio@vger.kernel.org +Description: + Raw differential capacitance measurement equivalent to + channel Y - channel Z where these channel numbers apply to the + physically equivalent inputs when non differential readings are + separately available. In differential only parts, then all that + is required is a consistent labeling. Units after application + of scale and offset are nanofarads.. + What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw What: /sys/bus/iio/devices/iio:deviceX/in_tempX_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_x_raw @@ -251,6 +269,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available What: /sys/.../iio:deviceX/in_voltageX_scale_available What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available What: /sys/.../iio:deviceX/out_voltageX_scale_available +What: /sys/.../iio:deviceX/in_capacitance_scale_available KernelVersion: 2.635 Contact: linux-iio@vger.kernel.org Description: From 3b99fb7656a73d483b00fd4777646c00db16b040 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:53 +0100 Subject: [PATCH 1150/1519] staging:iio: treewide rename iio_triggered_ring_* to iio_triggered_buffer_* Not always a ring so naming is missleading. Also, kfifo_buf is probably first buffer to take out of staging and it definitely isn't a ring. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 4 ++-- drivers/staging/iio/accel/adis16203_ring.c | 4 ++-- drivers/staging/iio/accel/adis16204_ring.c | 4 ++-- drivers/staging/iio/accel/adis16209_ring.c | 4 ++-- drivers/staging/iio/accel/adis16240_ring.c | 4 ++-- drivers/staging/iio/accel/lis3l02dq_ring.c | 4 ++-- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7298_ring.c | 4 ++-- drivers/staging/iio/adc/ad7476_ring.c | 4 ++-- drivers/staging/iio/adc/ad7606_ring.c | 4 ++-- drivers/staging/iio/adc/ad7793.c | 4 ++-- drivers/staging/iio/adc/ad7887_ring.c | 4 ++-- drivers/staging/iio/adc/ad799x_ring.c | 4 ++-- drivers/staging/iio/adc/max1363_ring.c | 4 ++-- drivers/staging/iio/gyro/adis16260_ring.c | 4 ++-- drivers/staging/iio/imu/adis16400_ring.c | 4 ++-- drivers/staging/iio/industrialio-trigger.c | 8 ++++---- drivers/staging/iio/meter/ade7758_ring.c | 4 ++-- drivers/staging/iio/trigger_consumer.h | 4 ++-- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 1c1f35d77c3..47be20afbeb 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -99,8 +99,8 @@ void adis16201_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16201_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16201_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index d7d692c17b4..d86f86dc8fd 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -101,8 +101,8 @@ void adis16203_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16203_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16203_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 273293aa200..8cc14990531 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -96,8 +96,8 @@ void adis16204_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16204_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16204_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index bc654e2e477..941fc5acbfd 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -96,8 +96,8 @@ void adis16209_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16209_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16209_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index b41e24f02a9..e52ad2e3655 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -93,8 +93,8 @@ void adis16240_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16240_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16240_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index c8169338b27..eaecda4d658 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -386,7 +386,7 @@ static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev) if (ret) goto error_ret; - return iio_triggered_ring_postenable(indio_dev); + return iio_triggered_buffer_postenable(indio_dev); error_ret: return ret; } @@ -397,7 +397,7 @@ static int lis3l02dq_ring_predisable(struct iio_dev *indio_dev) u8 t; int ret; - ret = iio_triggered_ring_predisable(indio_dev); + ret = iio_triggered_buffer_predisable(indio_dev); if (ret) goto error_ret; diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 5a389b81cbc..3f4e911c458 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -564,8 +564,8 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p) static const struct iio_ring_setup_ops ad7192_ring_setup_ops = { .preenable = &ad7192_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, .postdisable = &ad7192_ring_postdisable, }; diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 246b2e724d3..9c5ac9dd5ef 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -145,8 +145,8 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) static const struct iio_ring_setup_ops ad7298_ring_setup_ops = { .preenable = &ad7298_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index b109afb8984..3cc673c9e5c 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -107,8 +107,8 @@ done: static const struct iio_ring_setup_ops ad7476_ring_setup_ops = { .preenable = &ad7476_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index e6424300c8e..320ec68a4a3 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -149,8 +149,8 @@ done: static const struct iio_ring_setup_ops ad7606_ring_setup_ops = { .preenable = &ad7606_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 7044ed2932a..565199d0a93 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -430,8 +430,8 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p) static const struct iio_ring_setup_ops ad7793_ring_setup_ops = { .preenable = &ad7793_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, .postdisable = &ad7793_ring_postdisable, }; diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 36e118cf32e..159aeb17eed 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -149,8 +149,8 @@ done: static const struct iio_ring_setup_ops ad7887_ring_setup_ops = { .preenable = &ad7887_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, .postdisable = &ad7887_ring_postdisable, }; diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 438e81d190c..7b6488dce7f 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -155,8 +155,8 @@ out: static const struct iio_ring_setup_ops ad799x_buf_setup_ops = { .preenable = &ad799x_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index abe9e03f36e..ef1c95f5eb9 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -150,9 +150,9 @@ done: } static const struct iio_ring_setup_ops max1363_ring_setup_ops = { - .postenable = &iio_triggered_ring_postenable, + .postenable = &iio_triggered_buffer_postenable, .preenable = &max1363_ring_preenable, - .predisable = &iio_triggered_ring_predisable, + .predisable = &iio_triggered_buffer_predisable, }; int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 40226f72d86..2b1c65a322b 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -98,8 +98,8 @@ void adis16260_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16260_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16260_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index af25697dab9..421a9fab52e 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -168,8 +168,8 @@ void adis16400_unconfigure_ring(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops adis16400_ring_setup_ops = { .preenable = &iio_sw_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int adis16400_configure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index a66dcf7ad62..00d0e0c6fe1 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -488,20 +488,20 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) iio_put_trigger(dev_info->trig); } -int iio_triggered_ring_postenable(struct iio_dev *indio_dev) +int iio_triggered_buffer_postenable(struct iio_dev *indio_dev) { return indio_dev->trig ? iio_trigger_attach_poll_func(indio_dev->trig, indio_dev->pollfunc) : 0; } -EXPORT_SYMBOL(iio_triggered_ring_postenable); +EXPORT_SYMBOL(iio_triggered_buffer_postenable); -int iio_triggered_ring_predisable(struct iio_dev *indio_dev) +int iio_triggered_buffer_predisable(struct iio_dev *indio_dev) { return indio_dev->trig ? iio_trigger_dettach_poll_func(indio_dev->trig, indio_dev->pollfunc) : 0; } -EXPORT_SYMBOL(iio_triggered_ring_predisable); +EXPORT_SYMBOL(iio_triggered_buffer_predisable); diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 9934f508ded..ece2a4076ee 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -121,8 +121,8 @@ static int ade7758_ring_preenable(struct iio_dev *indio_dev) static const struct iio_ring_setup_ops ade7758_ring_setup_ops = { .preenable = &ade7758_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; void ade7758_unconfigure_ring(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/trigger_consumer.h b/drivers/staging/iio/trigger_consumer.h index 418e0bd5f4c..60d64b35694 100644 --- a/drivers/staging/iio/trigger_consumer.h +++ b/drivers/staging/iio/trigger_consumer.h @@ -48,5 +48,5 @@ void iio_trigger_notify_done(struct iio_trigger *trig); * Two functions for common case where all that happens is a pollfunc * is attached and detached from a trigger */ -int iio_triggered_ring_postenable(struct iio_dev *indio_dev); -int iio_triggered_ring_predisable(struct iio_dev *indio_dev); +int iio_triggered_buffer_postenable(struct iio_dev *indio_dev); +int iio_triggered_buffer_predisable(struct iio_dev *indio_dev); From ec3afa40c648ed17eb2a83a4b7249deab3631f61 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:54 +0100 Subject: [PATCH 1151/1519] staging:iio: tree wide IIO_RING_TRIGGERED -> IIO_BUFFER_TRIGGERED also, IIO_RING_HARDWARE_BUFFER -> IIO_BUFFER_HARDWARE These aren't always rings so the naming should not imply that. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_ring.c | 2 +- drivers/staging/iio/accel/adis16203_ring.c | 2 +- drivers/staging/iio/accel/adis16204_ring.c | 2 +- drivers/staging/iio/accel/adis16209_ring.c | 2 +- drivers/staging/iio/accel/adis16240_ring.c | 2 +- drivers/staging/iio/accel/lis3l02dq_core.c | 4 ++-- drivers/staging/iio/accel/lis3l02dq_ring.c | 2 +- drivers/staging/iio/accel/sca3000_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7298_ring.c | 2 +- drivers/staging/iio/adc/ad7476_ring.c | 2 +- drivers/staging/iio/adc/ad7606_ring.c | 2 +- drivers/staging/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7887_ring.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 2 +- drivers/staging/iio/adc/max1363_ring.c | 2 +- drivers/staging/iio/gyro/adis16260_ring.c | 2 +- drivers/staging/iio/iio.h | 10 +++++----- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- drivers/staging/iio/imu/adis16400_core.c | 2 +- drivers/staging/iio/imu/adis16400_ring.c | 2 +- drivers/staging/iio/industrialio-core.c | 4 ++-- drivers/staging/iio/industrialio-ring.c | 16 ++++++++-------- drivers/staging/iio/industrialio-trigger.c | 2 +- drivers/staging/iio/meter/ade7758_core.c | 2 +- drivers/staging/iio/meter/ade7758_ring.c | 2 +- 26 files changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 47be20afbeb..52679b9e248 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -132,7 +132,7 @@ int adis16201_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index d86f86dc8fd..c694e87cd69 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -134,7 +134,7 @@ int adis16203_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 8cc14990531..8e2a976c02f 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -130,7 +130,7 @@ int adis16204_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 941fc5acbfd..ca2c2814e06 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -130,7 +130,7 @@ int adis16209_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index e52ad2e3655..6119f4b0ade 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -127,7 +127,7 @@ int adis16240_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index ee91cc719bc..52b3a129776 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -259,7 +259,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, case 0: /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_RING_TRIGGERED) + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) ret = lis3l02dq_read_accel_from_ring(indio_dev->ring, chan->scan_index, val); @@ -725,7 +725,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) return 0; error_remove_trigger: - if (indio_dev->modes & INDIO_RING_TRIGGERED) + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) lis3l02dq_remove_trigger(indio_dev); error_free_interrupt: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index eaecda4d658..1f35fdc988e 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -455,7 +455,7 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 996b01ed97b..2a83e8aa815 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -290,7 +290,7 @@ int sca3000_configure_ring(struct iio_dev *indio_dev) indio_dev->ring = sca3000_rb_allocate(indio_dev); if (indio_dev->ring == NULL) return -ENOMEM; - indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; + indio_dev->modes |= INDIO_BUFFER_HARDWARE; indio_dev->ring->access = &sca3000_ring_access_funcs; diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 3f4e911c458..4b5649085a2 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -595,7 +595,7 @@ static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->setup_ops = &ad7192_ring_setup_ops; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 9c5ac9dd5ef..2315ee98913 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -178,7 +178,7 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->scan_timestamp = true; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index 3cc673c9e5c..e48181a56ad 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -141,7 +141,7 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->scan_timestamp = true; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 320ec68a4a3..15bdec68317 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -186,7 +186,7 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring); /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 565199d0a93..e21593d097a 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -461,7 +461,7 @@ static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->setup_ops = &ad7793_ring_setup_ops; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 159aeb17eed..678c877eba8 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -179,7 +179,7 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->setup_ops = &ad7887_ring_setup_ops; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 7b6488dce7f..8177de5277e 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -187,7 +187,7 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->scan_timestamp = true; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index ef1c95f5eb9..570c68650c8 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -182,7 +182,7 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) indio_dev->ring->setup_ops = &max1363_ring_setup_ops; /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 2b1c65a322b..7169d924919 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -131,7 +131,7 @@ int adis16260_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 8ef04f83336..0f657c773d7 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -189,10 +189,11 @@ static inline s64 iio_get_time_ns(void) /* Device operating modes */ #define INDIO_DIRECT_MODE 0x01 -#define INDIO_RING_TRIGGERED 0x02 -#define INDIO_RING_HARDWARE_BUFFER 0x08 +#define INDIO_BUFFER_TRIGGERED 0x02 +#define INDIO_BUFFER_HARDWARE 0x08 -#define INDIO_ALL_RING_MODES (INDIO_RING_TRIGGERED | INDIO_RING_HARDWARE_BUFFER) +#define INDIO_ALL_BUFFER_MODES \ + (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE) /* Vast majority of this is set by the industrialio subsystem on a * call to iio_device_register. */ @@ -388,8 +389,7 @@ void iio_free_device(struct iio_dev *dev); static inline bool iio_ring_enabled(struct iio_dev *dev_info) { return dev_info->currentmode - & (INDIO_RING_TRIGGERED - | INDIO_RING_HARDWARE_BUFFER); + & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE); }; #endif /* _INDUSTRIAL_IO_H_ */ diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 6d1086b2cd8..25223d8baf5 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -612,7 +612,7 @@ static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) /* Ring buffer functions - here trigger setup related */ indio_dev->ring->setup_ops = &ad5933_ring_setup_ops; - indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; + indio_dev->modes |= INDIO_BUFFER_HARDWARE; return 0; } diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index b6d824f5dbf..19dacfb6e17 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -1070,7 +1070,7 @@ static int __devinit adis16400_probe(struct spi_device *spi) return 0; error_remove_trigger: - if (indio_dev->modes & INDIO_RING_TRIGGERED) + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) adis16400_remove_trigger(indio_dev); error_uninitialize_ring: iio_ring_buffer_unregister(indio_dev); diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 421a9fab52e..a97e1e3b02b 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -203,7 +203,7 @@ int adis16400_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 8eba592125d..bfbfcdd6748 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -998,7 +998,7 @@ static void iio_dev_release(struct device *device) { struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); cdev_del(&dev_info->chrdev); - if (dev_info->modes & INDIO_RING_TRIGGERED) + if (dev_info->modes & INDIO_BUFFER_TRIGGERED) iio_device_unregister_trigger_consumer(dev_info); iio_device_unregister_eventset(dev_info); iio_device_unregister_sysfs(dev_info); @@ -1126,7 +1126,7 @@ int iio_device_register(struct iio_dev *dev_info) "Failed to register event set\n"); goto error_free_sysfs; } - if (dev_info->modes & INDIO_RING_TRIGGERED) + if (dev_info->modes & INDIO_BUFFER_TRIGGERED) iio_device_register_trigger_consumer(dev_info); ret = device_add(&dev_info->dev); diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 7a95fbe0eed..e048d348bbd 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -150,7 +150,7 @@ static ssize_t iio_scan_el_store(struct device *dev, state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_RING_TRIGGERED) { + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { ret = -EBUSY; goto error_ret; } @@ -193,7 +193,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_RING_TRIGGERED) { + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { ret = -EBUSY; goto error_ret; } @@ -430,7 +430,7 @@ ssize_t iio_store_ring_enable(struct device *dev, mutex_lock(&dev_info->mlock); previous_mode = dev_info->currentmode; requested_state = !(buf[0] == '0'); - current_state = !!(previous_mode & INDIO_ALL_RING_MODES); + current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES); if (current_state == requested_state) { printk(KERN_INFO "iio-ring, current state requested again\n"); goto done; @@ -457,7 +457,7 @@ ssize_t iio_store_ring_enable(struct device *dev, if (ring->access->mark_in_use) ring->access->mark_in_use(ring); /* Definitely possible for devices to support both of these.*/ - if (dev_info->modes & INDIO_RING_TRIGGERED) { + if (dev_info->modes & INDIO_BUFFER_TRIGGERED) { if (!dev_info->trig) { printk(KERN_INFO "Buffer not started: no trigger\n"); @@ -466,9 +466,9 @@ ssize_t iio_store_ring_enable(struct device *dev, ring->access->unmark_in_use(ring); goto error_ret; } - dev_info->currentmode = INDIO_RING_TRIGGERED; - } else if (dev_info->modes & INDIO_RING_HARDWARE_BUFFER) - dev_info->currentmode = INDIO_RING_HARDWARE_BUFFER; + dev_info->currentmode = INDIO_BUFFER_TRIGGERED; + } else if (dev_info->modes & INDIO_BUFFER_HARDWARE) + dev_info->currentmode = INDIO_BUFFER_HARDWARE; else { /* should never be reached */ ret = -EINVAL; goto error_ret; @@ -519,7 +519,7 @@ ssize_t iio_show_ring_enable(struct device *dev, { struct iio_dev *dev_info = dev_get_drvdata(dev); return sprintf(buf, "%d\n", !!(dev_info->currentmode - & INDIO_ALL_RING_MODES)); + & INDIO_ALL_BUFFER_MODES)); } EXPORT_SYMBOL(iio_show_ring_enable); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 00d0e0c6fe1..392664962b4 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -329,7 +329,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, int ret; mutex_lock(&dev_info->mlock); - if (dev_info->currentmode == INDIO_RING_TRIGGERED) { + if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) { mutex_unlock(&dev_info->mlock); return -EBUSY; } diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 6507875f846..1661f31184b 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -801,7 +801,7 @@ static int __devinit ade7758_probe(struct spi_device *spi) return 0; error_remove_trigger: - if (indio_dev->modes & INDIO_RING_TRIGGERED) + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) ade7758_remove_trigger(indio_dev); error_uninitialize_ring: ade7758_uninitialize_ring(indio_dev); diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index ece2a4076ee..8c7541ec321 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -158,7 +158,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) goto error_iio_sw_rb_free; } - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; st->tx_buf[0] = ADE7758_READ_REG(ADE7758_RSTATUS); st->tx_buf[1] = 0; From f2a96245baccc07f770d5993f6a523e84e44336f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:55 +0100 Subject: [PATCH 1152/1519] staging:iio: tree wide IIO_RING_BUFFER config symbol to IIO_BUFFER Functionality is generic, so name is missleading. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Kconfig | 6 ++-- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/accel/Kconfig | 28 +++++++++---------- drivers/staging/iio/accel/Makefile | 12 ++++---- drivers/staging/iio/accel/adis16201.h | 6 ++-- drivers/staging/iio/accel/adis16203.h | 6 ++-- drivers/staging/iio/accel/adis16204.h | 6 ++-- drivers/staging/iio/accel/adis16209.h | 6 ++-- drivers/staging/iio/accel/adis16240.h | 6 ++-- drivers/staging/iio/accel/lis3l02dq.h | 6 ++-- drivers/staging/iio/accel/lis3l02dq_core.c | 2 +- drivers/staging/iio/accel/sca3000.h | 2 +- drivers/staging/iio/adc/Kconfig | 18 ++++++------ drivers/staging/iio/adc/Makefile | 8 +++--- drivers/staging/iio/adc/ad7298.h | 6 ++-- drivers/staging/iio/adc/ad7476.h | 6 ++-- drivers/staging/iio/adc/ad7887.h | 6 ++-- drivers/staging/iio/gyro/Kconfig | 4 +-- drivers/staging/iio/gyro/Makefile | 2 +- drivers/staging/iio/gyro/adis16260.h | 6 ++-- drivers/staging/iio/iio_core.h | 2 +- .../staging/iio/impedance-analyzer/Kconfig | 2 +- drivers/staging/iio/imu/Kconfig | 4 +-- drivers/staging/iio/imu/Makefile | 2 +- drivers/staging/iio/imu/adis16400.h | 6 ++-- drivers/staging/iio/meter/Kconfig | 4 +-- drivers/staging/iio/meter/Makefile | 2 +- drivers/staging/iio/meter/ade7758.h | 6 ++-- drivers/staging/iio/ring_generic.h | 6 ++-- 29 files changed, 89 insertions(+), 89 deletions(-) diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index 75265678348..db4a79ff2ec 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -12,13 +12,13 @@ menuconfig IIO drivers/staging/iio/Documentation for more information. if IIO -config IIO_RING_BUFFER +config IIO_BUFFER bool "Enable buffer support within IIO" help Provide core support for various buffer based data acquisition methods. -if IIO_RING_BUFFER +if IIO_BUFFER config IIO_SW_RING select IIO_TRIGGER @@ -38,7 +38,7 @@ config IIO_KFIFO_BUF no buffer events so it is up to userspace to work out how often to read from the buffer. -endif # IIO_RINGBUFFER +endif # IIO_BUFFER config IIO_TRIGGER boolean "Enable triggered sampling support" diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index eaff649faf9..67a1d9cc345 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_IIO) += industrialio.o industrialio-y := industrialio-core.o -industrialio-$(CONFIG_IIO_RING_BUFFER) += industrialio-ring.o +industrialio-$(CONFIG_IIO_BUFFER) += industrialio-ring.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_SW_RING) += ring_sw.o diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index bf38114233b..71f873997b0 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -6,8 +6,8 @@ menu "Accelerometers" config ADIS16201 tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices adis16201 dual-axis digital inclinometer and accelerometer. @@ -15,8 +15,8 @@ config ADIS16201 config ADIS16203 tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices adis16203 Programmable 360 Degrees Inclinometer. @@ -24,8 +24,8 @@ config ADIS16203 config ADIS16204 tristate "Analog Devices ADIS16204 Programmable High-g Digital Impact Sensor and Recorder" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices adis16204 Programmable High-g Digital Impact Sensor and Recorder. @@ -33,8 +33,8 @@ config ADIS16204 config ADIS16209 tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer and accelerometer. @@ -49,8 +49,8 @@ config ADIS16220 config ADIS16240 tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices adis16240 programmable impact Sensor and recorder. @@ -65,8 +65,8 @@ config KXSD9 config LIS3L02DQ tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - depends on !IIO_RING_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING + select IIO_TRIGGER if IIO_BUFFER + depends on !IIO_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING help Say yes here to build SPI support for the ST microelectronics accelerometer. The driver supplies direct access via sysfs files @@ -74,7 +74,7 @@ config LIS3L02DQ choice prompt "Buffer type" - depends on LIS3L02DQ && IIO_RING_BUFFER + depends on LIS3L02DQ && IIO_BUFFER config LIS3L02DQ_BUF_KFIFO depends on IIO_KFIFO_BUF @@ -94,7 +94,7 @@ config LIS3L02DQ_BUF_RING_SW endchoice config SCA3000 - depends on IIO_RING_BUFFER + depends on IIO_BUFFER depends on SPI tristate "VTI SCA3000 series accelerometers" help diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile index 1b2a6d3ddaf..95c66661e70 100644 --- a/drivers/staging/iio/accel/Makefile +++ b/drivers/staging/iio/accel/Makefile @@ -3,32 +3,32 @@ # adis16201-y := adis16201_core.o -adis16201-$(CONFIG_IIO_RING_BUFFER) += adis16201_ring.o adis16201_trigger.o +adis16201-$(CONFIG_IIO_BUFFER) += adis16201_ring.o adis16201_trigger.o obj-$(CONFIG_ADIS16201) += adis16201.o adis16203-y := adis16203_core.o -adis16203-$(CONFIG_IIO_RING_BUFFER) += adis16203_ring.o adis16203_trigger.o +adis16203-$(CONFIG_IIO_BUFFER) += adis16203_ring.o adis16203_trigger.o obj-$(CONFIG_ADIS16203) += adis16203.o adis16204-y := adis16204_core.o -adis16204-$(CONFIG_IIO_RING_BUFFER) += adis16204_ring.o adis16204_trigger.o +adis16204-$(CONFIG_IIO_BUFFER) += adis16204_ring.o adis16204_trigger.o obj-$(CONFIG_ADIS16204) += adis16204.o adis16209-y := adis16209_core.o -adis16209-$(CONFIG_IIO_RING_BUFFER) += adis16209_ring.o adis16209_trigger.o +adis16209-$(CONFIG_IIO_BUFFER) += adis16209_ring.o adis16209_trigger.o obj-$(CONFIG_ADIS16209) += adis16209.o adis16220-y := adis16220_core.o obj-$(CONFIG_ADIS16220) += adis16220.o adis16240-y := adis16240_core.o -adis16240-$(CONFIG_IIO_RING_BUFFER) += adis16240_ring.o adis16240_trigger.o +adis16240-$(CONFIG_IIO_BUFFER) += adis16240_ring.o adis16240_trigger.o obj-$(CONFIG_ADIS16240) += adis16240.o obj-$(CONFIG_KXSD9) += kxsd9.o lis3l02dq-y := lis3l02dq_core.o -lis3l02dq-$(CONFIG_IIO_RING_BUFFER) += lis3l02dq_ring.o +lis3l02dq-$(CONFIG_IIO_BUFFER) += lis3l02dq_ring.o obj-$(CONFIG_LIS3L02DQ) += lis3l02dq.o sca3000-y := sca3000_core.o sca3000_ring.o diff --git a/drivers/staging/iio/accel/adis16201.h b/drivers/staging/iio/accel/adis16201.h index dac5540b5a8..72750f7f3a8 100644 --- a/drivers/staging/iio/accel/adis16201.h +++ b/drivers/staging/iio/accel/adis16201.h @@ -89,7 +89,7 @@ enum adis16201_scan { ADIS16201_SCAN_INCLI_Y, }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16201_remove_trigger(struct iio_dev *indio_dev); int adis16201_probe_trigger(struct iio_dev *indio_dev); @@ -100,7 +100,7 @@ ssize_t adis16201_read_data_from_ring(struct device *dev, int adis16201_configure_ring(struct iio_dev *indio_dev); void adis16201_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16201_remove_trigger(struct iio_dev *indio_dev) { @@ -137,5 +137,5 @@ static inline void adis16201_uninitialize_ring(struct iio_ring_buffer *ring) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16201_H_ */ diff --git a/drivers/staging/iio/accel/adis16203.h b/drivers/staging/iio/accel/adis16203.h index 4071bc0d69a..3f96ad3bbd6 100644 --- a/drivers/staging/iio/accel/adis16203.h +++ b/drivers/staging/iio/accel/adis16203.h @@ -82,7 +82,7 @@ enum adis16203_scan { ADIS16203_SCAN_INCLI_Y, }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16203_remove_trigger(struct iio_dev *indio_dev); int adis16203_probe_trigger(struct iio_dev *indio_dev); @@ -93,7 +93,7 @@ ssize_t adis16203_read_data_from_ring(struct device *dev, int adis16203_configure_ring(struct iio_dev *indio_dev); void adis16203_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16203_remove_trigger(struct iio_dev *indio_dev) { @@ -121,5 +121,5 @@ static inline void adis16203_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16203_H_ */ diff --git a/drivers/staging/iio/accel/adis16204.h b/drivers/staging/iio/accel/adis16204.h index 3bb0490465f..7cf4e91f83a 100644 --- a/drivers/staging/iio/accel/adis16204.h +++ b/drivers/staging/iio/accel/adis16204.h @@ -90,7 +90,7 @@ enum adis16204_scan { ADIS16204_SCAN_TEMP, }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16204_remove_trigger(struct iio_dev *indio_dev); int adis16204_probe_trigger(struct iio_dev *indio_dev); @@ -101,7 +101,7 @@ ssize_t adis16204_read_data_from_ring(struct device *dev, int adis16204_configure_ring(struct iio_dev *indio_dev); void adis16204_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16204_remove_trigger(struct iio_dev *indio_dev) { @@ -129,5 +129,5 @@ static inline void adis16204_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16204_H_ */ diff --git a/drivers/staging/iio/accel/adis16209.h b/drivers/staging/iio/accel/adis16209.h index c8b7b00d417..3c88b86e7b8 100644 --- a/drivers/staging/iio/accel/adis16209.h +++ b/drivers/staging/iio/accel/adis16209.h @@ -128,7 +128,7 @@ int adis16209_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16209_SCAN_INCLI_Y 6 #define ADIS16209_SCAN_ROT 7 -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16209_remove_trigger(struct iio_dev *indio_dev); int adis16209_probe_trigger(struct iio_dev *indio_dev); @@ -140,7 +140,7 @@ ssize_t adis16209_read_data_from_ring(struct device *dev, int adis16209_configure_ring(struct iio_dev *indio_dev); void adis16209_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16209_remove_trigger(struct iio_dev *indio_dev) { @@ -168,5 +168,5 @@ static inline void adis16209_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16209_H_ */ diff --git a/drivers/staging/iio/accel/adis16240.h b/drivers/staging/iio/accel/adis16240.h index f1dd047aa5e..3fabcc0b347 100644 --- a/drivers/staging/iio/accel/adis16240.h +++ b/drivers/staging/iio/accel/adis16240.h @@ -152,7 +152,7 @@ int adis16240_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16240_SCAN_AUX_ADC 4 #define ADIS16240_SCAN_TEMP 5 -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16240_remove_trigger(struct iio_dev *indio_dev); int adis16240_probe_trigger(struct iio_dev *indio_dev); @@ -164,7 +164,7 @@ ssize_t adis16240_read_data_from_ring(struct device *dev, int adis16240_configure_ring(struct iio_dev *indio_dev); void adis16240_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16240_remove_trigger(struct iio_dev *indio_dev) { @@ -192,5 +192,5 @@ static inline void adis16240_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16240_H_ */ diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h index 18b23acfb6f..5a18f50a4e8 100644 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ b/drivers/staging/iio/accel/lis3l02dq.h @@ -174,7 +174,7 @@ int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev, int lis3l02dq_disable_all_events(struct iio_dev *indio_dev); -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! */ @@ -202,7 +202,7 @@ void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev); irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private); #define lis3l02dq_th lis3l02dq_data_rdy_trig_poll -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ #define lis3l02dq_th lis3l02dq_noring static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) @@ -227,5 +227,5 @@ static int lis3l02dq_configure_ring(struct iio_dev *indio_dev) static inline void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_LIS3L02DQ_H_ */ diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 52b3a129776..6d600f68c1d 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -34,7 +34,7 @@ * This means that use cannot be made of spi_write etc. */ /* direct copy of the irq_default_primary_handler */ -#ifndef CONFIG_IIO_RING_BUFFER +#ifndef CONFIG_IIO_BUFFER static irqreturn_t lis3l02dq_noring(int irq, void *private) { return IRQ_WAKE_THREAD; diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h index 1e396cefdf6..0dabfadde68 100644 --- a/drivers/staging/iio/accel/sca3000.h +++ b/drivers/staging/iio/accel/sca3000.h @@ -221,7 +221,7 @@ int sca3000_read_data_short(struct sca3000_state *st, **/ int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val); -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER /** * sca3000_register_ring_funcs() setup the ring state change functions **/ diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 27dda13770b..070efd329a1 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -44,7 +44,7 @@ config AD7314 config AD7606 tristate "Analog Devices AD7606 ADC driver" depends on GPIOLIB - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_TRIGGER select IIO_SW_RING help @@ -72,7 +72,7 @@ config AD7606_IFACE_SPI config AD799X tristate "Analog Devices AD799x ADC driver" depends on I2C - select IIO_TRIGGER if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER select AD799X_RING_BUFFER help Say yes here to build support for Analog Devices: @@ -83,7 +83,7 @@ config AD799X config AD799X_RING_BUFFER bool "Analog Devices AD799x: use ring buffer" depends on AD799X - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING help Say yes here to include ring buffer support in the AD799X @@ -92,7 +92,7 @@ config AD799X_RING_BUFFER config AD7476 tristate "Analog Devices AD7475/6/7/8 AD7466/7/8 and AD7495 ADC driver" depends on SPI - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING select IIO_TRIGGER help @@ -107,7 +107,7 @@ config AD7476 config AD7887 tristate "Analog Devices AD7887 ADC driver" depends on SPI - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING select IIO_TRIGGER help @@ -133,7 +133,7 @@ config AD7780 config AD7793 tristate "Analog Devices AD7792 AD7793 ADC driver" depends on SPI - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING select IIO_TRIGGER help @@ -164,7 +164,7 @@ config AD7816 config AD7192 tristate "Analog Devices AD7190 AD7192 AD7195 ADC driver" depends on SPI - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING select IIO_TRIGGER help @@ -209,7 +209,7 @@ config AD7280 config MAX1363 tristate "Maxim max1363 ADC driver" depends on I2C - select IIO_TRIGGER if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER select MAX1363_RING_BUFFER help Say yes here to build support for many Maxim i2c analog to digital @@ -224,7 +224,7 @@ config MAX1363 config MAX1363_RING_BUFFER bool "Maxim max1363: use ring buffer" depends on MAX1363 - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING help Say yes here to include ring buffer support in the MAX1363 diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 5ba3cdb631c..8adf096e6b8 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -8,7 +8,7 @@ max1363-y += max1363_ring.o obj-$(CONFIG_MAX1363) += max1363.o ad7606-y := ad7606_core.o -ad7606-$(CONFIG_IIO_RING_BUFFER) += ad7606_ring.o +ad7606-$(CONFIG_IIO_BUFFER) += ad7606_ring.o ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o @@ -18,15 +18,15 @@ ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o obj-$(CONFIG_AD799X) += ad799x.o ad7476-y := ad7476_core.o -ad7476-$(CONFIG_IIO_RING_BUFFER) += ad7476_ring.o +ad7476-$(CONFIG_IIO_BUFFER) += ad7476_ring.o obj-$(CONFIG_AD7476) += ad7476.o ad7887-y := ad7887_core.o -ad7887-$(CONFIG_IIO_RING_BUFFER) += ad7887_ring.o +ad7887-$(CONFIG_IIO_BUFFER) += ad7887_ring.o obj-$(CONFIG_AD7887) += ad7887.o ad7298-y := ad7298_core.o -ad7298-$(CONFIG_IIO_RING_BUFFER) += ad7298_ring.o +ad7298-$(CONFIG_IIO_BUFFER) += ad7298_ring.o obj-$(CONFIG_AD7298) += ad7298.o obj-$(CONFIG_AD7150) += ad7150.o diff --git a/drivers/staging/iio/adc/ad7298.h b/drivers/staging/iio/adc/ad7298.h index 628f5adcf0c..9ddf5cf0e51 100644 --- a/drivers/staging/iio/adc/ad7298.h +++ b/drivers/staging/iio/adc/ad7298.h @@ -53,11 +53,11 @@ struct ad7298_state { unsigned short tx_buf[2]; }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER int ad7298_scan_from_ring(struct iio_dev *indio_dev, long ch); int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad7298_ring_cleanup(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline int ad7298_scan_from_ring(struct iio_dev *indio_dev, long ch) { return 0; @@ -72,5 +72,5 @@ ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev) static inline void ad7298_ring_cleanup(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* IIO_ADC_AD7298_H_ */ diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h index 0d44976e846..60142926565 100644 --- a/drivers/staging/iio/adc/ad7476.h +++ b/drivers/staging/iio/adc/ad7476.h @@ -49,11 +49,11 @@ enum ad7476_supported_device_ids { ID_AD7495 }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER int ad7476_scan_from_ring(struct iio_dev *indio_dev); int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad7476_ring_cleanup(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline int ad7476_scan_from_ring(struct iio_dev *indio_dev) { return 0; @@ -68,5 +68,5 @@ ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev) static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* IIO_ADC_AD7476_H_ */ diff --git a/drivers/staging/iio/adc/ad7887.h b/drivers/staging/iio/adc/ad7887.h index 1b7a772934c..3452d181907 100644 --- a/drivers/staging/iio/adc/ad7887.h +++ b/drivers/staging/iio/adc/ad7887.h @@ -82,11 +82,11 @@ enum ad7887_supported_device_ids { ID_AD7887 }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER int ad7887_scan_from_ring(struct ad7887_state *st, int channum); int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad7887_ring_cleanup(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline int ad7887_scan_from_ring(struct ad7887_state *st, int channum) { return 0; @@ -101,5 +101,5 @@ ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev) static inline void ad7887_ring_cleanup(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* IIO_ADC_AD7887_H_ */ diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index 86774e3c97c..22aea5b4e61 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -27,8 +27,8 @@ config ADIS16130 config ADIS16260 tristate "Analog Devices ADIS16260 Digital Gyroscope Sensor SPI driver" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices ADIS16260 ADIS16265 ADIS16250 ADIS16255 and ADIS16251 programmable digital gyroscope sensors. diff --git a/drivers/staging/iio/gyro/Makefile b/drivers/staging/iio/gyro/Makefile index 2212240f7de..9ba5ec15170 100644 --- a/drivers/staging/iio/gyro/Makefile +++ b/drivers/staging/iio/gyro/Makefile @@ -12,7 +12,7 @@ adis16130-y := adis16130_core.o obj-$(CONFIG_ADIS16130) += adis16130.o adis16260-y := adis16260_core.o -adis16260-$(CONFIG_IIO_RING_BUFFER) += adis16260_ring.o adis16260_trigger.o +adis16260-$(CONFIG_IIO_BUFFER) += adis16260_ring.o adis16260_trigger.o obj-$(CONFIG_ADIS16260) += adis16260.o adis16251-y := adis16251_core.o diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h index 969b624be6d..4c4b25129c6 100644 --- a/drivers/staging/iio/gyro/adis16260.h +++ b/drivers/staging/iio/gyro/adis16260.h @@ -112,7 +112,7 @@ int adis16260_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16260_SCAN_TEMP 3 #define ADIS16260_SCAN_ANGL 4 -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16260_remove_trigger(struct iio_dev *indio_dev); int adis16260_probe_trigger(struct iio_dev *indio_dev); @@ -124,7 +124,7 @@ ssize_t adis16260_read_data_from_ring(struct device *dev, int adis16260_configure_ring(struct iio_dev *indio_dev); void adis16260_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16260_remove_trigger(struct iio_dev *indio_dev) { @@ -152,5 +152,5 @@ static inline void adis16260_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16260_H_ */ diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index 803bdd8a20e..a173321a993 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -30,7 +30,7 @@ int __iio_add_chan_devattr(const char *postfix, /* Event interface flags */ #define IIO_BUSY_BIT_POS 1 -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER struct poll_table_struct; void iio_chrdev_ring_open(struct iio_dev *indio_dev); diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig index cce1ce3b5d9..ad0ff765e4b 100644 --- a/drivers/staging/iio/impedance-analyzer/Kconfig +++ b/drivers/staging/iio/impedance-analyzer/Kconfig @@ -6,7 +6,7 @@ menu "Network Analyzer, Impedance Converters" config AD5933 tristate "Analog Devices AD5933, AD5934 driver" depends on I2C - select IIO_RING_BUFFER + select IIO_BUFFER select IIO_SW_RING help Say yes here to build support for Analog Devices Impedance Converter, diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig index 233c76a313e..2e2fa8c9191 100644 --- a/drivers/staging/iio/imu/Kconfig +++ b/drivers/staging/iio/imu/Kconfig @@ -6,8 +6,8 @@ menu "Inertial measurement units" config ADIS16400 tristate "Analog Devices ADIS16400 and similar IMU SPI driver" depends on SPI - select IIO_SW_RING if IIO_RING_BUFFER - select IIO_TRIGGER if IIO_RING_BUFFER + select IIO_SW_RING if IIO_BUFFER + select IIO_TRIGGER if IIO_BUFFER help Say yes here to build support for Analog Devices adis16300, adis16350, adis16354, adis16355, adis16360, adis16362, adis16364, adis16365, diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile index d46a691912e..3400a13d152 100644 --- a/drivers/staging/iio/imu/Makefile +++ b/drivers/staging/iio/imu/Makefile @@ -3,5 +3,5 @@ # adis16400-y := adis16400_core.o -adis16400-$(CONFIG_IIO_RING_BUFFER) += adis16400_ring.o adis16400_trigger.o +adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o adis16400_trigger.o obj-$(CONFIG_ADIS16400) += adis16400.o diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h index 1f8f0c60c2c..f3546ee910a 100644 --- a/drivers/staging/iio/imu/adis16400.h +++ b/drivers/staging/iio/imu/adis16400.h @@ -184,7 +184,7 @@ int adis16400_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16300_SCAN_INCLI_X 12 #define ADIS16300_SCAN_INCLI_Y 13 -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER void adis16400_remove_trigger(struct iio_dev *indio_dev); int adis16400_probe_trigger(struct iio_dev *indio_dev); @@ -196,7 +196,7 @@ ssize_t adis16400_read_data_from_ring(struct device *dev, int adis16400_configure_ring(struct iio_dev *indio_dev); void adis16400_unconfigure_ring(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void adis16400_remove_trigger(struct iio_dev *indio_dev) { @@ -224,5 +224,5 @@ static inline void adis16400_unconfigure_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* SPI_ADIS16400_H_ */ diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig index a8deab27831..d290d273841 100644 --- a/drivers/staging/iio/meter/Kconfig +++ b/drivers/staging/iio/meter/Kconfig @@ -20,8 +20,8 @@ config ADE7754 config ADE7758 tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver" depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER + select IIO_TRIGGER if IIO_BUFFER + select IIO_SW_RING if IIO_BUFFER help Say yes here to build support for Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC with Per Phase Information Driver. diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile index 0cc7d5140df..de3863d6b07 100644 --- a/drivers/staging/iio/meter/Makefile +++ b/drivers/staging/iio/meter/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_ADE7753) += ade7753.o obj-$(CONFIG_ADE7754) += ade7754.o ade7758-y := ade7758_core.o -ade7758-$(CONFIG_IIO_RING_BUFFER) += ade7758_ring.o ade7758_trigger.o +ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o obj-$(CONFIG_ADE7758) += ade7758.o obj-$(CONFIG_ADE7759) += ade7759.o diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h index 20a2bcace7f..bdd1b05bf7a 100644 --- a/drivers/staging/iio/meter/ade7758.h +++ b/drivers/staging/iio/meter/ade7758.h @@ -134,7 +134,7 @@ struct ade7758_state { unsigned char tx_buf[8]; }; -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! */ @@ -158,7 +158,7 @@ int ade7758_spi_write_reg_8(struct device *dev, int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline void ade7758_remove_trigger(struct iio_dev *indio_dev) { @@ -182,6 +182,6 @@ static inline int ade7758_initialize_ring(struct iio_ring_buffer *ring) static inline void ade7758_uninitialize_ring(struct iio_dev *indio_dev) { } -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 8f6ecde1061..6a89ec00bff 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -13,7 +13,7 @@ #include "iio.h" #include "chrdev.h" -#ifdef CONFIG_IIO_RING_BUFFER +#ifdef CONFIG_IIO_BUFFER struct iio_ring_buffer; @@ -209,7 +209,7 @@ ssize_t iio_show_ring_enable(struct device *dev, int iio_sw_ring_preenable(struct iio_dev *indio_dev); -#else /* CONFIG_IIO_RING_BUFFER */ +#else /* CONFIG_IIO_BUFFER */ static inline int iio_ring_buffer_register(struct iio_dev *indio_dev, struct iio_chan_spec *channels, @@ -221,6 +221,6 @@ static inline int iio_ring_buffer_register(struct iio_dev *indio_dev, static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev) {}; -#endif /* CONFIG_IIO_RING_BUFFER */ +#endif /* CONFIG_IIO_BUFFER */ #endif /* _IIO_RING_GENERIC_H_ */ From 3811cd6291bb5a11c8d830831149d6369e7d3b68 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:56 +0100 Subject: [PATCH 1153/1519] staging:iio: rename ring_generic.h -> buffer_generic.h Nothing in this file is specific to RING buffers so rename it. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 2 +- drivers/staging/iio/accel/adis16203_core.c | 2 +- drivers/staging/iio/accel/adis16204_core.c | 2 +- drivers/staging/iio/accel/adis16209_core.c | 2 +- drivers/staging/iio/accel/adis16240_core.c | 2 +- drivers/staging/iio/accel/lis3l02dq_core.c | 2 +- drivers/staging/iio/accel/sca3000_core.c | 2 +- drivers/staging/iio/accel/sca3000_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7298_core.c | 2 +- drivers/staging/iio/adc/ad7298_ring.c | 2 +- drivers/staging/iio/adc/ad7476_core.c | 2 +- drivers/staging/iio/adc/ad7476_ring.c | 2 +- drivers/staging/iio/adc/ad7606_core.c | 2 +- drivers/staging/iio/adc/ad7606_ring.c | 2 +- drivers/staging/iio/adc/ad7780.c | 1 - drivers/staging/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7887_core.c | 2 +- drivers/staging/iio/adc/ad7887_ring.c | 2 +- drivers/staging/iio/adc/ad799x_core.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 2 +- drivers/staging/iio/adc/max1363_core.c | 2 +- drivers/staging/iio/adc/max1363_ring.c | 2 +- drivers/staging/iio/{ring_generic.h => buffer_generic.h} | 6 +++--- drivers/staging/iio/gyro/adis16260_core.c | 2 +- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- drivers/staging/iio/imu/adis16400_core.c | 2 +- drivers/staging/iio/industrialio-ring.c | 2 +- drivers/staging/iio/kfifo_buf.h | 2 +- drivers/staging/iio/meter/ade7758_core.c | 2 +- drivers/staging/iio/ring_sw.h | 2 +- 31 files changed, 32 insertions(+), 33 deletions(-) rename drivers/staging/iio/{ring_generic.h => buffer_generic.h} (98%) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 2785460b385..eb6a1a8b082 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16201.h" diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 27079a95d4b..561e7a9f7d4 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16203.h" diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index b0d6a2e7257..507f282ac30 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -21,7 +21,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16204.h" diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 97dca8866df..2dd24c3e5cd 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -18,7 +18,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16209.h" diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 282a746dc5d..10e02498861 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -21,7 +21,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16240.h" diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 6d600f68c1d..fd53fd51ebf 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -25,7 +25,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "lis3l02dq.h" diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 394b04eb1aa..2fe35788da4 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -21,7 +21,7 @@ #include #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "sca3000.h" diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 2a83e8aa815..f5198578c6a 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -20,7 +20,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_hw.h" #include "sca3000.h" diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 4b5649085a2..8d080ab68a3 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -19,7 +19,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index a627bfe208a..cf91ccd8543 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -18,7 +18,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "ad7298.h" diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 2315ee98913..1cd5f61ed7d 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -12,7 +12,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index edf25ce8970..d574a2ee9ad 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "ad7476.h" diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index e48181a56ad..854d94971fc 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -14,7 +14,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index f22f668c6bc..f8eba678334 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -20,7 +20,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "ad7606.h" diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 15bdec68317..20afb3e24ab 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -12,7 +12,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 46d1f8f3fe8..4b6f8c6640e 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -20,7 +20,6 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" #include "ad7780.h" diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index e21593d097a..11ba79e476e 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -19,7 +19,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index cdd7c130aa1..4a8ffb5735b 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -17,7 +17,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "ad7887.h" diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 678c877eba8..96274d6057d 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -13,7 +13,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index ae64ee95cdd..d5fbda7857c 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -35,7 +35,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "ad799x.h" diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 8177de5277e..c1d38c589ec 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -17,7 +17,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index b7c46aeceb5..e0f87917051 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -34,7 +34,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "max1363.h" diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 570c68650c8..91e29c5abc6 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -15,7 +15,7 @@ #include #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "../trigger_consumer.h" diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/buffer_generic.h similarity index 98% rename from drivers/staging/iio/ring_generic.h rename to drivers/staging/iio/buffer_generic.h index 6a89ec00bff..a1256c152cf 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/buffer_generic.h @@ -7,8 +7,8 @@ * the Free Software Foundation. */ -#ifndef _IIO_RING_GENERIC_H_ -#define _IIO_RING_GENERIC_H_ +#ifndef _IIO_BUFFER_GENERIC_H_ +#define _IIO_BUFFER_GENERIC_H_ #include #include "iio.h" #include "chrdev.h" @@ -223,4 +223,4 @@ static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev) #endif /* CONFIG_IIO_BUFFER */ -#endif /* _IIO_RING_GENERIC_H_ */ +#endif /* _IIO_BUFFER_GENERIC_H_ */ diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 73157b21252..8058d669984 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -21,7 +21,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16260.h" diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 25223d8baf5..fb831618277 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -20,7 +20,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" #include "ad5933.h" diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 19dacfb6e17..b041b46539d 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -28,7 +28,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "adis16400.h" enum adis16400_chip_variant { diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index e048d348bbd..6f9d9e7858c 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -23,7 +23,7 @@ #include "iio.h" #include "iio_core.h" #include "sysfs.h" -#include "ring_generic.h" +#include "buffer_generic.h" static const char * const iio_endian_prefix[] = { [IIO_BE] = "be", diff --git a/drivers/staging/iio/kfifo_buf.h b/drivers/staging/iio/kfifo_buf.h index fb48523748e..66a80c65840 100644 --- a/drivers/staging/iio/kfifo_buf.h +++ b/drivers/staging/iio/kfifo_buf.h @@ -1,7 +1,7 @@ #include #include "iio.h" -#include "ring_generic.h" +#include "buffer_generic.h" extern const struct iio_ring_access_funcs kfifo_access_funcs; diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 1661f31184b..9a0dc1ea80e 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -21,7 +21,7 @@ #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "meter.h" #include "ade7758.h" diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h index 15271639534..2835c9940ed 100644 --- a/drivers/staging/iio/ring_sw.h +++ b/drivers/staging/iio/ring_sw.h @@ -23,7 +23,7 @@ #ifndef _IIO_RING_SW_H_ #define _IIO_RING_SW_H_ -#include "ring_generic.h" +#include "buffer_generic.h" /** * ring_sw_access_funcs - access functions for a software ring buffer From 14555b14455f9acbdf0e500ae96140828a970796 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:57 +0100 Subject: [PATCH 1154/1519] staging:iio: replacing term ring with buffer in the IIO core. They aren't always ring buffers, so just use buffer for all naming. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/accel/adis16201_core.c | 10 +- drivers/staging/iio/accel/adis16201_ring.c | 14 +- drivers/staging/iio/accel/adis16203_core.c | 10 +- drivers/staging/iio/accel/adis16203_ring.c | 14 +- drivers/staging/iio/accel/adis16204_core.c | 10 +- drivers/staging/iio/accel/adis16204_ring.c | 14 +- drivers/staging/iio/accel/adis16209_core.c | 10 +- drivers/staging/iio/accel/adis16209_ring.c | 14 +- drivers/staging/iio/accel/adis16240_core.c | 10 +- drivers/staging/iio/accel/adis16240_ring.c | 14 +- drivers/staging/iio/accel/lis3l02dq.h | 4 +- drivers/staging/iio/accel/lis3l02dq_core.c | 12 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 30 +- drivers/staging/iio/accel/sca3000.h | 2 +- drivers/staging/iio/accel/sca3000_core.c | 20 +- drivers/staging/iio/accel/sca3000_ring.c | 48 +-- drivers/staging/iio/adc/ad7192.c | 44 +-- drivers/staging/iio/adc/ad7298_core.c | 12 +- drivers/staging/iio/adc/ad7298_ring.c | 24 +- drivers/staging/iio/adc/ad7476_core.c | 12 +- drivers/staging/iio/adc/ad7476_ring.c | 30 +- drivers/staging/iio/adc/ad7606_core.c | 14 +- drivers/staging/iio/adc/ad7606_ring.c | 24 +- drivers/staging/iio/adc/ad7793.c | 42 +-- drivers/staging/iio/adc/ad7887_core.c | 12 +- drivers/staging/iio/adc/ad7887_ring.c | 28 +- drivers/staging/iio/adc/ad799x_core.c | 10 +- drivers/staging/iio/adc/ad799x_ring.c | 30 +- drivers/staging/iio/adc/max1363_core.c | 12 +- drivers/staging/iio/adc/max1363_ring.c | 20 +- drivers/staging/iio/buffer_generic.h | 192 +++++------ drivers/staging/iio/gyro/adis16260_core.c | 22 +- drivers/staging/iio/gyro/adis16260_ring.c | 14 +- drivers/staging/iio/iio.h | 10 +- drivers/staging/iio/iio_core.h | 24 +- .../staging/iio/impedance-analyzer/ad5933.c | 36 +- drivers/staging/iio/imu/adis16400_core.c | 10 +- drivers/staging/iio/imu/adis16400_ring.c | 25 +- ...ustrialio-ring.c => industrialio-buffer.c} | 311 +++++++++--------- drivers/staging/iio/industrialio-core.c | 16 +- drivers/staging/iio/kfifo_buf.c | 48 +-- drivers/staging/iio/kfifo_buf.h | 6 +- drivers/staging/iio/meter/ade7758_core.c | 6 +- drivers/staging/iio/meter/ade7758_ring.c | 28 +- drivers/staging/iio/ring_hw.h | 6 +- drivers/staging/iio/ring_sw.c | 44 +-- drivers/staging/iio/ring_sw.h | 6 +- 48 files changed, 679 insertions(+), 677 deletions(-) rename drivers/staging/iio/{industrialio-ring.c => industrialio-buffer.c} (57%) diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index 67a1d9cc345..788397d1a4b 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_IIO) += industrialio.o industrialio-y := industrialio-core.o -industrialio-$(CONFIG_IIO_BUFFER) += industrialio-ring.o +industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_SW_RING) += ring_sw.o diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index eb6a1a8b082..e5364b74ac4 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -492,9 +492,9 @@ static int __devinit adis16201_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - adis16201_channels, - ARRAY_SIZE(adis16201_channels)); + ret = iio_buffer_register(indio_dev, + adis16201_channels, + ARRAY_SIZE(adis16201_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -519,7 +519,7 @@ static int __devinit adis16201_probe(struct spi_device *spi) error_remove_trigger: adis16201_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16201_unconfigure_ring(indio_dev); error_free_dev: @@ -533,7 +533,7 @@ static int adis16201_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16201_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16201_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c index 52679b9e248..dbd883294d6 100644 --- a/drivers/staging/iio/accel/adis16201_ring.c +++ b/drivers/staging/iio/accel/adis16201_ring.c @@ -61,7 +61,7 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16201_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; @@ -94,11 +94,11 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p) void adis16201_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16201_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16201_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -106,14 +106,14 @@ static const struct iio_ring_setup_ops adis16201_ring_setup_ops = { int adis16201_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->bpe = 2; ring->scan_timestamp = true; @@ -135,6 +135,6 @@ int adis16201_configure_ring(struct iio_dev *indio_dev) indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 561e7a9f7d4..34975dc16e4 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -446,9 +446,9 @@ static int __devinit adis16203_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - adis16203_channels, - ARRAY_SIZE(adis16203_channels)); + ret = iio_buffer_register(indio_dev, + adis16203_channels, + ARRAY_SIZE(adis16203_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -474,7 +474,7 @@ static int __devinit adis16203_probe(struct spi_device *spi) error_remove_trigger: adis16203_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16203_unconfigure_ring(indio_dev); error_free_dev: @@ -488,7 +488,7 @@ static int adis16203_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16203_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16203_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c index c694e87cd69..838d3012c87 100644 --- a/drivers/staging/iio/accel/adis16203_ring.c +++ b/drivers/staging/iio/accel/adis16203_ring.c @@ -61,7 +61,7 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16203_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; @@ -96,11 +96,11 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p) void adis16203_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16203_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16203_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -108,14 +108,14 @@ static const struct iio_ring_setup_ops adis16203_ring_setup_ops = { int adis16203_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->bpe = 2; ring->scan_timestamp = true; @@ -138,6 +138,6 @@ int adis16203_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 507f282ac30..7a4c680722d 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -521,9 +521,9 @@ static int __devinit adis16204_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - adis16204_channels, - ARRAY_SIZE(adis16204_channels)); + ret = iio_buffer_register(indio_dev, + adis16204_channels, + ARRAY_SIZE(adis16204_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -548,7 +548,7 @@ static int __devinit adis16204_probe(struct spi_device *spi) error_remove_trigger: adis16204_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16204_unconfigure_ring(indio_dev); error_free_dev: @@ -562,7 +562,7 @@ static int adis16204_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); adis16204_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16204_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c index 8e2a976c02f..08551bb48f1 100644 --- a/drivers/staging/iio/accel/adis16204_ring.c +++ b/drivers/staging/iio/accel/adis16204_ring.c @@ -59,7 +59,7 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16204_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); @@ -91,11 +91,11 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p) void adis16204_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16204_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16204_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -103,14 +103,14 @@ static const struct iio_ring_setup_ops adis16204_ring_setup_ops = { int adis16204_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; @@ -134,6 +134,6 @@ int adis16204_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 2dd24c3e5cd..1824e729153 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -494,9 +494,9 @@ static int __devinit adis16209_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - adis16209_channels, - ARRAY_SIZE(adis16209_channels)); + ret = iio_buffer_register(indio_dev, + adis16209_channels, + ARRAY_SIZE(adis16209_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -521,7 +521,7 @@ static int __devinit adis16209_probe(struct spi_device *spi) error_remove_trigger: adis16209_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16209_unconfigure_ring(indio_dev); error_free_dev: @@ -537,7 +537,7 @@ static int adis16209_remove(struct spi_device *spi) flush_scheduled_work(); adis16209_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16209_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index ca2c2814e06..bb66364bef0 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -59,7 +59,7 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16209_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; @@ -91,11 +91,11 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p) void adis16209_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16209_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16209_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -103,14 +103,14 @@ static const struct iio_ring_setup_ops adis16209_ring_setup_ops = { int adis16209_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; @@ -134,6 +134,6 @@ int adis16209_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 10e02498861..6d3194f2a52 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -547,9 +547,9 @@ static int __devinit adis16240_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - adis16240_channels, - ARRAY_SIZE(adis16240_channels)); + ret = iio_buffer_register(indio_dev, + adis16240_channels, + ARRAY_SIZE(adis16240_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -573,7 +573,7 @@ static int __devinit adis16240_probe(struct spi_device *spi) error_remove_trigger: adis16240_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16240_unconfigure_ring(indio_dev); error_free_dev: @@ -590,7 +590,7 @@ static int adis16240_remove(struct spi_device *spi) flush_scheduled_work(); adis16240_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16240_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 6119f4b0ade..34f1e7e6a56 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -56,7 +56,7 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16240_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; @@ -88,11 +88,11 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p) void adis16240_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16240_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16240_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -100,14 +100,14 @@ static const struct iio_ring_setup_ops adis16240_ring_setup_ops = { int adis16240_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; @@ -131,6 +131,6 @@ int adis16240_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h index 5a18f50a4e8..6633091d018 100644 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ b/drivers/staging/iio/accel/lis3l02dq.h @@ -181,7 +181,7 @@ int lis3l02dq_disable_all_events(struct iio_dev *indio_dev); void lis3l02dq_remove_trigger(struct iio_dev *indio_dev); int lis3l02dq_probe_trigger(struct iio_dev *indio_dev); -ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, +ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, int index, int *val); @@ -213,7 +213,7 @@ static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) return 0; } static inline ssize_t -lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, +lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, int index, int *val) { diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index fd53fd51ebf..c59ca1c2a19 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -260,7 +260,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) - ret = lis3l02dq_read_accel_from_ring(indio_dev->ring, + ret = lis3l02dq_read_accel_from_ring(indio_dev->buffer, chan->scan_index, val); else { @@ -690,9 +690,9 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - lis3l02dq_channels, - ARRAY_SIZE(lis3l02dq_channels)); + ret = iio_buffer_register(indio_dev, + lis3l02dq_channels, + ARRAY_SIZE(lis3l02dq_channels)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -731,7 +731,7 @@ error_free_interrupt: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(st->us->irq, indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: lis3l02dq_unconfigure_ring(indio_dev); error_free_dev: @@ -785,7 +785,7 @@ static int lis3l02dq_remove(struct spi_device *spi) free_irq(st->us->irq, indio_dev); lis3l02dq_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); lis3l02dq_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 1f35fdc988e..1ccfba9ff13 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -40,7 +40,7 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private) /** * lis3l02dq_read_accel_from_ring() individual acceleration read from ring **/ -ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, +ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, int index, int *val) { @@ -86,7 +86,7 @@ static const u8 read_all_tx_array[] = { **/ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; struct lis3l02dq_state *st = iio_priv(indio_dev); struct spi_transfer *xfers; struct spi_message msg; @@ -145,13 +145,13 @@ static int lis3l02dq_get_ring_element(struct iio_dev *indio_dev, u8 *rx_array ; s16 *data = (s16 *)buf; - rx_array = kzalloc(4 * (indio_dev->ring->scan_count), GFP_KERNEL); + rx_array = kzalloc(4 * (indio_dev->buffer->scan_count), GFP_KERNEL); if (rx_array == NULL) return -ENOMEM; ret = lis3l02dq_read_all(indio_dev, rx_array); if (ret < 0) return ret; - for (i = 0; i < indio_dev->ring->scan_count; i++) + for (i = 0; i < indio_dev->buffer->scan_count; i++) data[i] = combine_8_to_16(rx_array[i*4+1], rx_array[i*4+3]); kfree(rx_array); @@ -163,7 +163,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int len = 0; size_t datasize = ring->access->get_bytes_per_datum(ring); char *data = kmalloc(datasize, GFP_KERNEL); @@ -346,7 +346,7 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - lis3l02dq_free_buf(indio_dev->ring); + lis3l02dq_free_buf(indio_dev->buffer); } static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev) @@ -362,17 +362,17 @@ static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev) if (ret) goto error_ret; - if (iio_scan_mask_query(indio_dev->ring, 0)) { + if (iio_scan_mask_query(indio_dev->buffer, 0)) { t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE; oneenabled = true; } else t &= ~LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE; - if (iio_scan_mask_query(indio_dev->ring, 1)) { + if (iio_scan_mask_query(indio_dev->buffer, 1)) { t |= LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE; oneenabled = true; } else t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE; - if (iio_scan_mask_query(indio_dev->ring, 2)) { + if (iio_scan_mask_query(indio_dev->buffer, 2)) { t |= LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE; oneenabled = true; } else @@ -418,8 +418,8 @@ error_ret: return ret; } -static const struct iio_ring_setup_ops lis3l02dq_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops lis3l02dq_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &lis3l02dq_ring_postenable, .predisable = &lis3l02dq_ring_predisable, }; @@ -427,15 +427,15 @@ static const struct iio_ring_setup_ops lis3l02dq_ring_setup_ops = { int lis3l02dq_configure_ring(struct iio_dev *indio_dev) { int ret; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = lis3l02dq_alloc_buf(indio_dev); if (!ring) return -ENOMEM; - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &lis3l02dq_access_funcs; + indio_dev->buffer->access = &lis3l02dq_access_funcs; ring->bpe = 2; ring->scan_timestamp = true; @@ -459,6 +459,6 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - lis3l02dq_free_buf(indio_dev->ring); + lis3l02dq_free_buf(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h index 0dabfadde68..ad38dd955cd 100644 --- a/drivers/staging/iio/accel/sca3000.h +++ b/drivers/staging/iio/accel/sca3000.h @@ -248,7 +248,7 @@ void sca3000_unconfigure_ring(struct iio_dev *indio_dev); * sca3000_ring_int_process() handles ring related event pushing and escalation * @val: the event code **/ -void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring); +void sca3000_ring_int_process(u8 val, struct iio_buffer *ring); #else static inline void sca3000_register_ring_funcs(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 2fe35788da4..5592b240ebf 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -812,7 +812,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) if (ret) goto done; - sca3000_ring_int_process(val, indio_dev->ring); + sca3000_ring_int_process(val, indio_dev->buffer); if (val & SCA3000_INT_STATUS_FREE_FALL) iio_push_event(indio_dev, @@ -1156,15 +1156,15 @@ static int __devinit sca3000_probe(struct spi_device *spi) if (ret < 0) goto error_free_dev; regdone = 1; - ret = iio_ring_buffer_register(indio_dev, - sca3000_channels, - ARRAY_SIZE(sca3000_channels)); + ret = iio_buffer_register(indio_dev, + sca3000_channels, + ARRAY_SIZE(sca3000_channels)); if (ret < 0) goto error_unregister_dev; - if (indio_dev->ring) { - iio_scan_mask_set(indio_dev->ring, 0); - iio_scan_mask_set(indio_dev->ring, 1); - iio_scan_mask_set(indio_dev->ring, 2); + if (indio_dev->buffer) { + iio_scan_mask_set(indio_dev->buffer, 0); + iio_scan_mask_set(indio_dev->buffer, 1); + iio_scan_mask_set(indio_dev->buffer, 2); } if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { @@ -1187,7 +1187,7 @@ error_free_irq: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(spi->irq, indio_dev); error_unregister_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unregister_dev: error_free_dev: if (regdone) @@ -1228,7 +1228,7 @@ static int sca3000_remove(struct spi_device *spi) return ret; if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(spi->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index f5198578c6a..4a9a01dccd0 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -81,10 +81,10 @@ error_ret: * can only be inferred approximately from ring buffer events such as 50% full * and knowledge of when buffer was last emptied. This is left to userspace. **/ -static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r, +static int sca3000_read_first_n_hw_rb(struct iio_buffer *r, size_t count, char __user *buf) { - struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r); + struct iio_hw_buffer *hw_ring = iio_to_hw_buf(r); struct iio_dev *indio_dev = hw_ring->private; struct sca3000_state *st = iio_priv(indio_dev); u8 *rx; @@ -134,20 +134,20 @@ error_ret: } /* This is only valid with all 3 elements enabled */ -static int sca3000_ring_get_length(struct iio_ring_buffer *r) +static int sca3000_ring_get_length(struct iio_buffer *r) { return 64; } /* only valid if resolution is kept at 11bits */ -static int sca3000_ring_get_bytes_per_datum(struct iio_ring_buffer *r) +static int sca3000_ring_get_bytes_per_datum(struct iio_buffer *r) { return 6; } -static IIO_RING_ENABLE_ATTR; -static IIO_RING_BYTES_PER_DATUM_ATTR; -static IIO_RING_LENGTH_ATTR; +static IIO_BUFFER_ENABLE_ATTR; +static IIO_BUFFER_BYTES_PER_DATUM_ATTR; +static IIO_BUFFER_LENGTH_ATTR; /** * sca3000_query_ring_int() is the hardware ring status interrupt enabled @@ -158,7 +158,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev, { struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret, val; - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_buffer *ring = dev_get_drvdata(dev); struct iio_dev *indio_dev = ring->indio_dev; struct sca3000_state *st = iio_priv(indio_dev); @@ -180,7 +180,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev, const char *buf, size_t len) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_buffer *ring = dev_get_drvdata(dev); struct iio_dev *indio_dev = ring->indio_dev; struct sca3000_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); @@ -222,7 +222,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_buffer *ring = dev_get_drvdata(dev); struct iio_dev *indio_dev = ring->indio_dev; struct sca3000_state *st = iio_priv(indio_dev); @@ -256,10 +256,10 @@ static struct attribute_group sca3000_ring_attr = { .name = "buffer", }; -static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) +static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) { - struct iio_ring_buffer *buf; - struct iio_hw_ring_buffer *ring; + struct iio_buffer *buf; + struct iio_hw_buffer *ring; ring = kzalloc(sizeof *ring, GFP_KERNEL); if (!ring) @@ -269,17 +269,17 @@ static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) buf = &ring->buf; buf->stufftoread = 0; buf->attrs = &sca3000_ring_attr; - iio_ring_buffer_init(buf, indio_dev); + iio_buffer_init(buf, indio_dev); return buf; } -static inline void sca3000_rb_free(struct iio_ring_buffer *r) +static inline void sca3000_rb_free(struct iio_buffer *r) { - kfree(iio_to_hw_ring_buf(r)); + kfree(iio_to_hw_buf(r)); } -static const struct iio_ring_access_funcs sca3000_ring_access_funcs = { +static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = { .read_first_n = &sca3000_read_first_n_hw_rb, .get_length = &sca3000_ring_get_length, .get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum, @@ -287,19 +287,19 @@ static const struct iio_ring_access_funcs sca3000_ring_access_funcs = { int sca3000_configure_ring(struct iio_dev *indio_dev) { - indio_dev->ring = sca3000_rb_allocate(indio_dev); - if (indio_dev->ring == NULL) + indio_dev->buffer = sca3000_rb_allocate(indio_dev); + if (indio_dev->buffer == NULL) return -ENOMEM; indio_dev->modes |= INDIO_BUFFER_HARDWARE; - indio_dev->ring->access = &sca3000_ring_access_funcs; + indio_dev->buffer->access = &sca3000_ring_access_funcs; return 0; } void sca3000_unconfigure_ring(struct iio_dev *indio_dev) { - sca3000_rb_free(indio_dev->ring); + sca3000_rb_free(indio_dev->buffer); } static inline @@ -343,14 +343,14 @@ static int sca3000_hw_ring_postdisable(struct iio_dev *indio_dev) return __sca3000_hw_ring_state_set(indio_dev, 0); } -static const struct iio_ring_setup_ops sca3000_ring_setup_ops = { +static const struct iio_buffer_setup_ops sca3000_ring_setup_ops = { .preenable = &sca3000_hw_ring_preenable, .postdisable = &sca3000_hw_ring_postdisable, }; void sca3000_register_ring_funcs(struct iio_dev *indio_dev) { - indio_dev->ring->setup_ops = &sca3000_ring_setup_ops; + indio_dev->buffer->setup_ops = &sca3000_ring_setup_ops; } /** @@ -359,7 +359,7 @@ void sca3000_register_ring_funcs(struct iio_dev *indio_dev) * This is only split from the main interrupt handler so as to * reduce the amount of code if the ring buffer is not enabled. **/ -void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring) +void sca3000_ring_int_process(u8 val, struct iio_buffer *ring) { if (val & (SCA3000_INT_STATUS_THREE_QUARTERS | SCA3000_INT_STATUS_HALF)) { diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 8d080ab68a3..67d731b4064 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -455,7 +455,7 @@ out: static int ad7192_scan_from_ring(struct ad7192_state *st, unsigned ch, int *val) { - struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; int ret; s64 dat64[2]; u32 *dat32 = (u32 *)dat64; @@ -475,7 +475,7 @@ static int ad7192_scan_from_ring(struct ad7192_state *st, unsigned ch, int *val) static int ad7192_ring_preenable(struct iio_dev *indio_dev) { struct ad7192_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; unsigned channel; @@ -494,9 +494,9 @@ static int ad7192_ring_preenable(struct iio_dev *indio_dev) d_size += sizeof(s64) - (d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, d_size); st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | AD7192_MODE_SEL(AD7192_MODE_CONT); @@ -539,7 +539,7 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; struct ad7192_state *st = iio_priv(indio_dev); s64 dat64[2]; s32 *dat32 = (s32 *)dat64; @@ -562,7 +562,7 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p) return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad7192_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7192_ring_setup_ops = { .preenable = &ad7192_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -573,13 +573,13 @@ static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev) { int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &ad7192_trigger_handler, IRQF_ONESHOT, @@ -592,14 +592,14 @@ static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev) } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7192_ring_setup_ops; + indio_dev->buffer->setup_ops = &ad7192_ring_setup_ops; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -607,7 +607,7 @@ error_ret: static void ad7192_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } /** @@ -705,7 +705,7 @@ static ssize_t ad7192_write_frequency(struct device *dev, return ret; mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mutex_unlock(&indio_dev->mlock); return -EBUSY; } @@ -790,7 +790,7 @@ static ssize_t ad7192_set(struct device *dev, return ret; mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mutex_unlock(&indio_dev->mlock); return -EBUSY; } @@ -872,7 +872,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, switch (m) { case 0: mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) + if (iio_buffer_enabled(indio_dev)) ret = ad7192_scan_from_ring(st, chan->scan_index, &smpl); else @@ -929,7 +929,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, unsigned int tmp; mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mutex_unlock(&indio_dev->mlock); return -EBUSY; } @@ -1099,9 +1099,9 @@ static int __devinit ad7192_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_remove_trigger; @@ -1112,7 +1112,7 @@ static int __devinit ad7192_probe(struct spi_device *spi) return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_remove_trigger: ad7192_remove_trigger(indio_dev); error_unreg_ring: @@ -1137,7 +1137,7 @@ static int ad7192_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7192_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7192_remove_trigger(indio_dev); ad7192_ring_cleanup(indio_dev); diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index cf91ccd8543..7f08ffaa3d8 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -122,7 +122,7 @@ static int ad7298_read_raw(struct iio_dev *dev_info, switch (m) { case 0: mutex_lock(&dev_info->mlock); - if (iio_ring_enabled(dev_info)) { + if (iio_buffer_enabled(dev_info)) { if (chan->address == AD7298_CH_TEMP) ret = -ENODEV; else @@ -218,9 +218,9 @@ static int __devinit ad7298_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, - &ad7298_channels[1], /* skip temp0 */ - ARRAY_SIZE(ad7298_channels) - 1); + ret = iio_buffer_register(indio_dev, + &ad7298_channels[1], /* skip temp0 */ + ARRAY_SIZE(ad7298_channels) - 1); if (ret) goto error_cleanup_ring; ret = iio_device_register(indio_dev); @@ -230,7 +230,7 @@ static int __devinit ad7298_probe(struct spi_device *spi) return 0; error_unregister_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_cleanup_ring: ad7298_ring_cleanup(indio_dev); error_disable_reg: @@ -249,7 +249,7 @@ static int __devexit ad7298_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7298_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7298_ring_cleanup(indio_dev); iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index 1cd5f61ed7d..d90b6f495f9 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -20,7 +20,7 @@ int ad7298_scan_from_ring(struct iio_dev *dev_info, long ch) { - struct iio_ring_buffer *ring = dev_info->ring; + struct iio_buffer *ring = dev_info->buffer; int ret; u16 *ring_data; @@ -57,7 +57,7 @@ error_ret: static int ad7298_ring_preenable(struct iio_dev *indio_dev) { struct ad7298_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; int i, m; unsigned short command; @@ -119,7 +119,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ad7298_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; s64 time_ns; __u16 buf[16]; int b_sent, i; @@ -137,13 +137,13 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) for (i = 0; i < ring->scan_count; i++) buf[i] = be16_to_cpu(st->rx_buf[i]); - indio_dev->ring->access->store_to(ring, (u8 *)buf, time_ns); + indio_dev->buffer->access->store_to(ring, (u8 *)buf, time_ns); iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad7298_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7298_ring_setup_ops = { .preenable = &ad7298_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -153,13 +153,13 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev) { int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(NULL, &ad7298_trigger_handler, @@ -174,15 +174,15 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev) } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7298_ring_setup_ops; - indio_dev->ring->scan_timestamp = true; + indio_dev->buffer->setup_ops = &ad7298_ring_setup_ops; + indio_dev->buffer->scan_timestamp = true; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -190,5 +190,5 @@ error_ret: void ad7298_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index d574a2ee9ad..ec75332e16c 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -45,7 +45,7 @@ static int ad7476_read_raw(struct iio_dev *dev_info, switch (m) { case 0: mutex_lock(&dev_info->mlock); - if (iio_ring_enabled(dev_info)) + if (iio_buffer_enabled(dev_info)) ret = ad7476_scan_from_ring(dev_info); else ret = ad7476_scan_direct(st); @@ -179,9 +179,9 @@ static int __devinit ad7476_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, - st->chip_info->channel, - ARRAY_SIZE(st->chip_info->channel)); + ret = iio_buffer_register(indio_dev, + st->chip_info->channel, + ARRAY_SIZE(st->chip_info->channel)); if (ret) goto error_cleanup_ring; @@ -191,7 +191,7 @@ static int __devinit ad7476_probe(struct spi_device *spi) return 0; error_ring_unregister: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_cleanup_ring: ad7476_ring_cleanup(indio_dev); error_disable_reg: @@ -211,7 +211,7 @@ static int ad7476_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7476_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7476_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c index 854d94971fc..e82c1a433f4 100644 --- a/drivers/staging/iio/adc/ad7476_ring.c +++ b/drivers/staging/iio/adc/ad7476_ring.c @@ -22,7 +22,7 @@ int ad7476_scan_from_ring(struct iio_dev *indio_dev) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int ret; u8 *ring_data; @@ -54,7 +54,7 @@ error_ret: static int ad7476_ring_preenable(struct iio_dev *indio_dev) { struct ad7476_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; st->d_size = ring->scan_count * st->chip_info->channel[0].scan_type.storagebits / 8; @@ -66,9 +66,9 @@ static int ad7476_ring_preenable(struct iio_dev *indio_dev) st->d_size += sizeof(s64) - (st->d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - st->d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, st->d_size); return 0; } @@ -93,11 +93,11 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) time_ns = iio_get_time_ns(); - if (indio_dev->ring->scan_timestamp) + if (indio_dev->buffer->scan_timestamp) memcpy(rxbuf + st->d_size - sizeof(s64), &time_ns, sizeof(time_ns)); - indio_dev->ring->access->store_to(indio_dev->ring, rxbuf, time_ns); + indio_dev->buffer->access->store_to(indio_dev->buffer, rxbuf, time_ns); done: iio_trigger_notify_done(indio_dev->trig); kfree(rxbuf); @@ -105,7 +105,7 @@ done: return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad7476_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7476_ring_setup_ops = { .preenable = &ad7476_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -116,13 +116,13 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev) struct ad7476_state *st = iio_priv(indio_dev); int ret = 0; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(NULL, &ad7476_trigger_handler, @@ -137,15 +137,15 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev) } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7476_ring_setup_ops; - indio_dev->ring->scan_timestamp = true; + indio_dev->buffer->setup_ops = &ad7476_ring_setup_ops; + indio_dev->buffer->scan_timestamp = true; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -153,5 +153,5 @@ error_ret: void ad7476_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index f8eba678334..c3ce74ccc18 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -90,7 +90,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, switch (m) { case 0: mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) + if (iio_buffer_enabled(indio_dev)) ret = ad7606_scan_from_ring(indio_dev, chan->address); else ret = ad7606_scan_direct(indio_dev, chan->address); @@ -416,7 +416,7 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id) struct iio_dev *indio_dev = dev_id; struct ad7606_state *st = iio_priv(indio_dev); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { if (!work_pending(&st->poll_work)) schedule_work(&st->poll_work); } else { @@ -502,9 +502,9 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, if (ret) goto error_free_irq; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; ret = iio_device_register(indio_dev); @@ -513,7 +513,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, return indio_dev; error_unregister_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_cleanup_ring: ad7606_ring_cleanup(indio_dev); @@ -539,7 +539,7 @@ int ad7606_remove(struct iio_dev *indio_dev) { struct ad7606_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7606_ring_cleanup(indio_dev); free_irq(st->irq, indio_dev); diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 20afb3e24ab..0b60a6e4d66 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -20,7 +20,7 @@ int ad7606_scan_from_ring(struct iio_dev *indio_dev, unsigned ch) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int ret; u16 *ring_data; @@ -52,7 +52,7 @@ error_ret: static int ad7606_ring_preenable(struct iio_dev *indio_dev) { struct ad7606_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; d_size = st->chip_info->num_channels * @@ -101,7 +101,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) struct ad7606_state *st = container_of(work_s, struct ad7606_state, poll_work); struct iio_dev *indio_dev = iio_priv_to_dev(st); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; s64 time_ns; __u8 *buf; int ret; @@ -140,14 +140,14 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) memcpy(buf + st->d_size - sizeof(s64), &time_ns, sizeof(time_ns)); - ring->access->store_to(indio_dev->ring, buf, time_ns); + ring->access->store_to(indio_dev->buffer, buf, time_ns); done: gpio_set_value(st->pdata->gpio_convst, 0); iio_trigger_notify_done(indio_dev->trig); kfree(buf); } -static const struct iio_ring_setup_ops ad7606_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7606_ring_setup_ops = { .preenable = &ad7606_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -158,14 +158,14 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) struct ad7606_state *st = iio_priv(indio_dev); int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh, &ad7606_trigger_handler_th_bh, 0, @@ -180,8 +180,8 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7606_ring_setup_ops; - indio_dev->ring->scan_timestamp = true ; + indio_dev->buffer->setup_ops = &ad7606_ring_setup_ops; + indio_dev->buffer->scan_timestamp = true ; INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring); @@ -190,7 +190,7 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -198,5 +198,5 @@ error_ret: void ad7606_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 11ba79e476e..788ee086a4c 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -317,7 +317,7 @@ out: static int ad7793_scan_from_ring(struct ad7793_state *st, unsigned ch, int *val) { - struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; int ret; s64 dat64[2]; u32 *dat32 = (u32 *)dat64; @@ -337,7 +337,7 @@ static int ad7793_scan_from_ring(struct ad7793_state *st, unsigned ch, int *val) static int ad7793_ring_preenable(struct iio_dev *indio_dev) { struct ad7793_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; unsigned channel; @@ -357,9 +357,9 @@ static int ad7793_ring_preenable(struct iio_dev *indio_dev) d_size += sizeof(s64) - (d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, d_size); st->mode = (st->mode & ~AD7793_MODE_SEL(-1)) | AD7793_MODE_SEL(AD7793_MODE_CONT); @@ -405,7 +405,7 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; struct ad7793_state *st = iio_priv(indio_dev); s64 dat64[2]; s32 *dat32 = (s32 *)dat64; @@ -428,7 +428,7 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p) return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad7793_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7793_ring_setup_ops = { .preenable = &ad7793_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -439,13 +439,13 @@ static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev) { int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &ad7793_trigger_handler, IRQF_ONESHOT, @@ -458,14 +458,14 @@ static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev) } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7793_ring_setup_ops; + indio_dev->buffer->setup_ops = &ad7793_ring_setup_ops; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -473,7 +473,7 @@ error_ret: static void ad7793_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } /** @@ -570,7 +570,7 @@ static ssize_t ad7793_write_frequency(struct device *dev, int i, ret; mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mutex_unlock(&indio_dev->mlock); return -EBUSY; } @@ -647,7 +647,7 @@ static int ad7793_read_raw(struct iio_dev *indio_dev, switch (m) { case 0: mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) + if (iio_buffer_enabled(indio_dev)) ret = ad7793_scan_from_ring(st, chan->scan_index, &smpl); else @@ -709,7 +709,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev, unsigned int tmp; mutex_lock(&indio_dev->mlock); - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mutex_unlock(&indio_dev->mlock); return -EBUSY; } @@ -974,9 +974,9 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_unreg_ring; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_remove_trigger; @@ -991,7 +991,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_remove_trigger: ad7793_remove_trigger(indio_dev); error_unreg_ring: @@ -1013,7 +1013,7 @@ static int ad7793_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7793_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7793_remove_trigger(indio_dev); ad7793_ring_cleanup(indio_dev); diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 4a8ffb5735b..465d7155379 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -44,7 +44,7 @@ static int ad7887_read_raw(struct iio_dev *dev_info, switch (m) { case 0: mutex_lock(&dev_info->mlock); - if (iio_ring_enabled(dev_info)) + if (iio_buffer_enabled(dev_info)) ret = ad7887_scan_from_ring(st, 1 << chan->address); else ret = ad7887_scan_direct(st, chan->address); @@ -189,9 +189,9 @@ static int __devinit ad7887_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; @@ -201,7 +201,7 @@ static int __devinit ad7887_probe(struct spi_device *spi) return 0; error_unregister_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_cleanup_ring: ad7887_ring_cleanup(indio_dev); error_disable_reg: @@ -220,7 +220,7 @@ static int ad7887_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7887_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad7887_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c index 96274d6057d..cb74cada561 100644 --- a/drivers/staging/iio/adc/ad7887_ring.c +++ b/drivers/staging/iio/adc/ad7887_ring.c @@ -21,7 +21,7 @@ int ad7887_scan_from_ring(struct ad7887_state *st, int channum) { - struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; int count = 0, ret; u16 *ring_data; @@ -63,7 +63,7 @@ error_ret: static int ad7887_ring_preenable(struct iio_dev *indio_dev) { struct ad7887_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; st->d_size = ring->scan_count * st->chip_info->channel[0].scan_type.storagebits / 8; @@ -75,9 +75,9 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev) st->d_size += sizeof(s64) - (st->d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - st->d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, st->d_size); /* We know this is a single long so can 'cheat' */ switch (*ring->scan_mask) { @@ -116,7 +116,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ad7887_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; s64 time_ns; __u8 *buf; int b_sent; @@ -139,7 +139,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p) memcpy(buf + st->d_size - sizeof(s64), &time_ns, sizeof(time_ns)); - indio_dev->ring->access->store_to(indio_dev->ring, buf, time_ns); + indio_dev->buffer->access->store_to(indio_dev->buffer, buf, time_ns); done: kfree(buf); iio_trigger_notify_done(indio_dev->trig); @@ -147,7 +147,7 @@ done: return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad7887_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad7887_ring_setup_ops = { .preenable = &ad7887_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -158,13 +158,13 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev) { int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &ad7887_trigger_handler, IRQF_ONESHOT, @@ -176,14 +176,14 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev) goto error_deallocate_sw_rb; } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7887_ring_setup_ops; + indio_dev->buffer->setup_ops = &ad7887_ring_setup_ops; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -191,5 +191,5 @@ error_ret: void ad7887_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index d5fbda7857c..b8efd593018 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -149,7 +149,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info, switch (m) { case 0: mutex_lock(&dev_info->mlock); - if (iio_ring_enabled(dev_info)) + if (iio_buffer_enabled(dev_info)) ret = ad799x_single_channel_from_ring(st, chan->address); else @@ -701,9 +701,9 @@ static int __devinit ad799x_probe(struct i2c_client *client, if (ret) goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - indio_dev->num_channels); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + indio_dev->num_channels); if (ret) goto error_cleanup_ring; @@ -747,7 +747,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) if (client->irq > 0) free_irq(client->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); ad799x_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index c1d38c589ec..1bcc168fa76 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -25,7 +25,7 @@ int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum) { - struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; int count = 0, ret; u16 *ring_data; @@ -62,7 +62,7 @@ error_ret: **/ static int ad799x_ring_preenable(struct iio_dev *indio_dev) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; struct ad799x_state *st = iio_priv(indio_dev); /* @@ -82,9 +82,9 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev) st->d_size += sizeof(s64) - (st->d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - st->d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, st->d_size); return 0; } @@ -101,7 +101,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ad799x_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; s64 time_ns; __u8 *rxbuf; int b_sent; @@ -142,7 +142,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) memcpy(rxbuf + st->d_size - sizeof(s64), &time_ns, sizeof(time_ns)); - ring->access->store_to(indio_dev->ring, rxbuf, time_ns); + ring->access->store_to(indio_dev->buffer, rxbuf, time_ns); done: kfree(rxbuf); if (b_sent < 0) @@ -153,7 +153,7 @@ out: return IRQ_HANDLED; } -static const struct iio_ring_setup_ops ad799x_buf_setup_ops = { +static const struct iio_buffer_setup_ops ad799x_buf_setup_ops = { .preenable = &ad799x_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -163,13 +163,13 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) { int ret = 0; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; indio_dev->pollfunc = iio_alloc_pollfunc(NULL, &ad799x_trigger_handler, IRQF_ONESHOT, @@ -183,15 +183,15 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) } /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad799x_buf_setup_ops; - indio_dev->ring->scan_timestamp = true; + indio_dev->buffer->setup_ops = &ad799x_buf_setup_ops; + indio_dev->buffer->scan_timestamp = true; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -199,5 +199,5 @@ error_ret: void ad799x_ring_cleanup(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index e0f87917051..2abcc32c378 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -205,7 +205,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, } /* If ring buffer capture is occurring, query the buffer */ - if (iio_ring_enabled(indio_dev)) { + if (iio_buffer_enabled(indio_dev)) { mask = max1363_mode_table[chan->address].modemask; data = max1363_single_channel_from_ring(mask, st); if (data < 0) { @@ -1292,9 +1292,9 @@ static int __devinit max1363_probe(struct i2c_client *client, if (ret) goto error_free_available_scan_masks; - ret = iio_ring_buffer_register(indio_dev, - st->chip_info->channels, - st->chip_info->num_channels); + ret = iio_buffer_register(indio_dev, + st->chip_info->channels, + st->chip_info->num_channels); if (ret) goto error_cleanup_ring; @@ -1318,7 +1318,7 @@ static int __devinit max1363_probe(struct i2c_client *client, error_free_irq: free_irq(st->client->irq, indio_dev); error_uninit_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_cleanup_ring: max1363_ring_cleanup(indio_dev); error_free_available_scan_masks: @@ -1341,7 +1341,7 @@ static int max1363_remove(struct i2c_client *client) if (client->irq) free_irq(st->client->irq, indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); max1363_ring_cleanup(indio_dev); kfree(indio_dev->available_scan_masks); if (!IS_ERR(reg)) { diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 91e29c5abc6..df6893e058c 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -23,7 +23,7 @@ int max1363_single_channel_from_ring(const long *mask, struct max1363_state *st) { - struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring; + struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; int count = 0, ret, index; u8 *ring_data; index = find_first_bit(mask, MAX1363_MAX_CHANNELS); @@ -68,7 +68,7 @@ error_ret: static int max1363_ring_preenable(struct iio_dev *indio_dev) { struct max1363_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size = 0; unsigned long numvals; @@ -141,7 +141,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns)); - indio_dev->ring->access->store_to(indio_dev->ring, rxbuf, time_ns); + indio_dev->buffer->access->store_to(indio_dev->buffer, rxbuf, time_ns); done: iio_trigger_notify_done(indio_dev->trig); kfree(rxbuf); @@ -149,7 +149,7 @@ done: return IRQ_HANDLED; } -static const struct iio_ring_setup_ops max1363_ring_setup_ops = { +static const struct iio_buffer_setup_ops max1363_ring_setup_ops = { .postenable = &iio_triggered_buffer_postenable, .preenable = &max1363_ring_preenable, .predisable = &iio_triggered_buffer_predisable, @@ -160,8 +160,8 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) struct max1363_state *st = iio_priv(indio_dev); int ret = 0; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } @@ -177,9 +177,9 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) goto error_deallocate_sw_rb; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &max1363_ring_setup_ops; + indio_dev->buffer->setup_ops = &max1363_ring_setup_ops; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; @@ -187,7 +187,7 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } @@ -196,5 +196,5 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev) { /* ensure that the trigger has been detached */ iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } diff --git a/drivers/staging/iio/buffer_generic.h b/drivers/staging/iio/buffer_generic.h index a1256c152cf..548bb748191 100644 --- a/drivers/staging/iio/buffer_generic.h +++ b/drivers/staging/iio/buffer_generic.h @@ -1,4 +1,4 @@ -/* The industrial I/O core - generic ring buffer interfaces. +/* The industrial I/O core - generic buffer interfaces. * * Copyright (c) 2008 Jonathan Cameron * @@ -15,65 +15,66 @@ #ifdef CONFIG_IIO_BUFFER -struct iio_ring_buffer; +struct iio_buffer; /** - * struct iio_ring_access_funcs - access functions for ring buffers. + * struct iio_buffer_access_funcs - access functions for buffers. * @mark_in_use: reference counting, typically to prevent module removal - * @unmark_in_use: reduce reference count when no longer using ring buffer - * @store_to: actually store stuff to the ring buffer + * @unmark_in_use: reduce reference count when no longer using buffer + * @store_to: actually store stuff to the buffer * @read_last: get the last element stored * @read_first_n: try to get a specified number of elements (must exist) - * @mark_param_change: notify ring that some relevant parameter has changed + * @mark_param_change: notify buffer that some relevant parameter has changed * Often this means the underlying storage may need to * change. * @request_update: if a parameter change has been marked, update underlying * storage. * @get_bytes_per_datum:get current bytes per datum * @set_bytes_per_datum:set number of bytes per datum - * @get_length: get number of datums in ring - * @set_length: set number of datums in ring - * @is_enabled: query if ring is currently being used - * @enable: enable the ring + * @get_length: get number of datums in buffer + * @set_length: set number of datums in buffer + * @is_enabled: query if buffer is currently being used + * @enable: enable the buffer * - * The purpose of this structure is to make the ring buffer element + * The purpose of this structure is to make the buffer element * modular as event for a given driver, different usecases may require - * different ring designs (space efficiency vs speed for example). + * different buffer designs (space efficiency vs speed for example). * - * It is worth noting that a given ring implementation may only support a small - * proportion of these functions. The core code 'should' cope fine with any of - * them not existing. + * It is worth noting that a given buffer implementation may only support a + * small proportion of these functions. The core code 'should' cope fine with + * any of them not existing. **/ -struct iio_ring_access_funcs { - void (*mark_in_use)(struct iio_ring_buffer *ring); - void (*unmark_in_use)(struct iio_ring_buffer *ring); +struct iio_buffer_access_funcs { + void (*mark_in_use)(struct iio_buffer *buffer); + void (*unmark_in_use)(struct iio_buffer *buffer); - int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp); - int (*read_last)(struct iio_ring_buffer *ring, u8 *data); - int (*read_first_n)(struct iio_ring_buffer *ring, + int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp); + int (*read_last)(struct iio_buffer *buffer, u8 *data); + int (*read_first_n)(struct iio_buffer *buffer, size_t n, char __user *buf); - int (*mark_param_change)(struct iio_ring_buffer *ring); - int (*request_update)(struct iio_ring_buffer *ring); + int (*mark_param_change)(struct iio_buffer *buffer); + int (*request_update)(struct iio_buffer *buffer); - int (*get_bytes_per_datum)(struct iio_ring_buffer *ring); - int (*set_bytes_per_datum)(struct iio_ring_buffer *ring, size_t bpd); - int (*get_length)(struct iio_ring_buffer *ring); - int (*set_length)(struct iio_ring_buffer *ring, int length); + int (*get_bytes_per_datum)(struct iio_buffer *buffer); + int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); + int (*get_length)(struct iio_buffer *buffer); + int (*set_length)(struct iio_buffer *buffer, int length); - int (*is_enabled)(struct iio_ring_buffer *ring); - int (*enable)(struct iio_ring_buffer *ring); + int (*is_enabled)(struct iio_buffer *buffer); + int (*enable)(struct iio_buffer *buffer); }; /** - * struct iio_ring_setup_ops - buffer setup related callbacks - * @preenable: [DRIVER] function to run prior to marking ring enabled - * @postenable: [DRIVER] function to run after marking ring enabled - * @predisable: [DRIVER] function to run prior to marking ring disabled - * @postdisable: [DRIVER] function to run after marking ring disabled + * struct iio_buffer_setup_ops - buffer setup related callbacks + * @preenable: [DRIVER] function to run prior to marking buffer enabled + * @postenable: [DRIVER] function to run after marking buffer enabled + * @predisable: [DRIVER] function to run prior to marking buffer + * disabled + * @postdisable: [DRIVER] function to run after marking buffer disabled */ -struct iio_ring_setup_ops { +struct iio_buffer_setup_ops { int (*preenable)(struct iio_dev *); int (*postenable)(struct iio_dev *); int (*predisable)(struct iio_dev *); @@ -81,11 +82,10 @@ struct iio_ring_setup_ops { }; /** - * struct iio_ring_buffer - general ring buffer structure - * @dev: ring buffer device struct + * struct iio_buffer - general buffer structure * @indio_dev: industrial I/O device structure - * @owner: module that owns the ring buffer (for ref counting) - * @length: [DEVICE] number of datums in ring + * @owner: module that owns the buffer (for ref counting) + * @length: [DEVICE] number of datums in buffer * @bytes_per_datum: [DEVICE] size of individual datum including timestamp * @bpe: [DEVICE] size of individual channel value * @scan_el_attrs: [DRIVER] control of scan elements if that scan mode @@ -93,11 +93,11 @@ struct iio_ring_setup_ops { * @scan_count: [INTERN] the number of elements in the current scan mode * @scan_mask: [INTERN] bitmask used in masking scan mode elements * @scan_timestamp: [INTERN] does the scan mode include a timestamp - * @access: [DRIVER] ring access functions associated with the + * @access: [DRIVER] buffer access functions associated with the * implementation. * @flags: [INTERN] file ops related flags including busy flag. **/ -struct iio_ring_buffer { +struct iio_buffer { struct iio_dev *indio_dev; struct module *owner; int length; @@ -107,8 +107,8 @@ struct iio_ring_buffer { int scan_count; long *scan_mask; bool scan_timestamp; - const struct iio_ring_access_funcs *access; - const struct iio_ring_setup_ops *setup_ops; + const struct iio_buffer_access_funcs *access; + const struct iio_buffer_setup_ops *setup_ops; struct list_head scan_el_dev_attr_list; struct attribute_group scan_el_group; wait_queue_head_t pollq; @@ -118,107 +118,109 @@ struct iio_ring_buffer { }; /** - * iio_ring_buffer_init() - Initialize the buffer structure - * @ring: buffer to be initialized + * iio_buffer_init() - Initialize the buffer structure + * @buffer: buffer to be initialized * @dev_info: the iio device the buffer is assocated with **/ -void iio_ring_buffer_init(struct iio_ring_buffer *ring, +void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info); -void iio_ring_buffer_deinit(struct iio_ring_buffer *ring); +void iio_buffer_deinit(struct iio_buffer *buffer); /** - * __iio_update_ring_buffer() - update common elements of ring buffers - * @ring: ring buffer that is the event source + * __iio_update_buffer() - update common elements of buffers + * @buffer: buffer that is the event source * @bytes_per_datum: size of individual datum including timestamp - * @length: number of datums in ring + * @length: number of datums in buffer **/ -static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring, - int bytes_per_datum, int length) +static inline void __iio_update_buffer(struct iio_buffer *buffer, + int bytes_per_datum, int length) { - ring->bytes_per_datum = bytes_per_datum; - ring->length = length; + buffer->bytes_per_datum = bytes_per_datum; + buffer->length = length; } -int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit); +int iio_scan_mask_query(struct iio_buffer *buffer, int bit); /** * iio_scan_mask_set() - set particular bit in the scan mask - * @ring: the ring buffer whose scan mask we are interested in + * @buffer: the buffer whose scan mask we are interested in * @bit: the bit to be set. **/ -int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit); +int iio_scan_mask_set(struct iio_buffer *buffer, int bit); -#define to_iio_ring_buffer(d) \ - container_of(d, struct iio_ring_buffer, dev) +#define to_iio_buffer(d) \ + container_of(d, struct iio_buffer, dev) /** - * iio_ring_buffer_register() - register the buffer with IIO core + * iio_buffer_register() - register the buffer with IIO core * @indio_dev: device with the buffer to be registered **/ -int iio_ring_buffer_register(struct iio_dev *indio_dev, - const struct iio_chan_spec *channels, - int num_channels); +int iio_buffer_register(struct iio_dev *indio_dev, + const struct iio_chan_spec *channels, + int num_channels); /** - * iio_ring_buffer_unregister() - unregister the buffer from IIO core + * iio_buffer_unregister() - unregister the buffer from IIO core * @indio_dev: the device with the buffer to be unregistered **/ -void iio_ring_buffer_unregister(struct iio_dev *indio_dev); +void iio_buffer_unregister(struct iio_dev *indio_dev); /** - * iio_read_ring_length() - attr func to get number of datums in the buffer + * iio_buffer_read_length() - attr func to get number of datums in the buffer **/ -ssize_t iio_read_ring_length(struct device *dev, - struct device_attribute *attr, - char *buf); +ssize_t iio_buffer_read_length(struct device *dev, + struct device_attribute *attr, + char *buf); /** - * iio_write_ring_length() - attr func to set number of datums in the buffer + * iio_buffer_write_length() - attr func to set number of datums in the buffer **/ -ssize_t iio_write_ring_length(struct device *dev, +ssize_t iio_buffer_write_length(struct device *dev, struct device_attribute *attr, const char *buf, size_t len); /** - * iio_read_ring_bytes_per_datum() - attr for number of bytes in whole datum + * iio_buffer_read_bytes_per_datum() - attr for number of bytes in whole datum **/ -ssize_t iio_read_ring_bytes_per_datum(struct device *dev, - struct device_attribute *attr, - char *buf); +ssize_t iio_buffer_read_bytes_per_datum(struct device *dev, + struct device_attribute *attr, + char *buf); /** - * iio_store_ring_enable() - attr to turn the buffer on + * iio_buffer_store_enable() - attr to turn the buffer on **/ -ssize_t iio_store_ring_enable(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len); +ssize_t iio_buffer_store_enable(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len); /** - * iio_show_ring_enable() - attr to see if the buffer is on + * iio_buffer_show_enable() - attr to see if the buffer is on **/ -ssize_t iio_show_ring_enable(struct device *dev, - struct device_attribute *attr, - char *buf); -#define IIO_RING_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR, \ - iio_read_ring_length, \ - iio_write_ring_length) -#define IIO_RING_BYTES_PER_DATUM_ATTR DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR, \ - iio_read_ring_bytes_per_datum, NULL) -#define IIO_RING_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \ - iio_show_ring_enable, \ - iio_store_ring_enable) +ssize_t iio_buffer_show_enable(struct device *dev, + struct device_attribute *attr, + char *buf); +#define IIO_BUFFER_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR, \ + iio_buffer_read_length, \ + iio_buffer_write_length) +#define IIO_BUFFER_BYTES_PER_DATUM_ATTR \ + DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR, \ + iio_buffer_read_bytes_per_datum, NULL) -int iio_sw_ring_preenable(struct iio_dev *indio_dev); +#define IIO_BUFFER_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \ + iio_buffer_show_enable, \ + iio_buffer_store_enable) + +int iio_sw_buffer_preenable(struct iio_dev *indio_dev); #else /* CONFIG_IIO_BUFFER */ -static inline int iio_ring_buffer_register(struct iio_dev *indio_dev, +static inline int iio_buffer_register(struct iio_dev *indio_dev, struct iio_chan_spec *channels, int num_channels) { return 0; } -static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev) +static inline void iio_buffer_unregister(struct iio_dev *indio_dev) {}; #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 8058d669984..2ad43a871b0 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -625,20 +625,20 @@ static int __devinit adis16260_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - indio_dev->channels, - ARRAY_SIZE(adis16260_channels_x)); + ret = iio_buffer_register(indio_dev, + indio_dev->channels, + ARRAY_SIZE(adis16260_channels_x)); if (ret) { printk(KERN_ERR "failed to initialize the ring\n"); goto error_unreg_ring_funcs; } - if (indio_dev->ring) { + if (indio_dev->buffer) { /* Set default scan mode */ - iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_SUPPLY); - iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_GYRO); - iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_AUX_ADC); - iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_TEMP); - iio_scan_mask_set(indio_dev->ring, ADIS16260_SCAN_ANGL); + iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_SUPPLY); + iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_GYRO); + iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_AUX_ADC); + iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_TEMP); + iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_ANGL); } if (spi->irq) { ret = adis16260_probe_trigger(indio_dev); @@ -659,7 +659,7 @@ static int __devinit adis16260_probe(struct spi_device *spi) error_remove_trigger: adis16260_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16260_unconfigure_ring(indio_dev); error_free_dev: @@ -680,7 +680,7 @@ static int adis16260_remove(struct spi_device *spi) flush_scheduled_work(); adis16260_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16260_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 7169d924919..679c1515571 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -62,7 +62,7 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16260_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); @@ -93,11 +93,11 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p) void adis16260_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16260_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16260_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -105,14 +105,14 @@ static const struct iio_ring_setup_ops adis16260_ring_setup_ops = { int adis16260_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; @@ -135,6 +135,6 @@ int adis16260_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 0f657c773d7..4851d6fb9eb 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -276,13 +276,13 @@ struct iio_info { * @dev: [DRIVER] device structure, should be assigned a parent * and owner * @event_interface: [INTERN] event chrdevs associated with interrupt lines - * @ring: [DRIVER] any ring buffer present + * @buffer: [DRIVER] any buffer present * @mlock: [INTERN] lock used to prevent simultaneous device state * changes * @available_scan_masks: [DRIVER] optional array of allowed bitmasks * @masklength: [INTERN] the length of the mask established from * channels - * @trig: [INTERN] current device trigger (ring buffer modes) + * @trig: [INTERN] current device trigger (buffer modes) * @pollfunc: [DRIVER] function run on trigger being received * @channels: [DRIVER] channel specification structure table * @num_channels: [DRIVER] number of chanels specified in @channels. @@ -304,7 +304,7 @@ struct iio_dev { struct iio_event_interface *event_interface; - struct iio_ring_buffer *ring; + struct iio_buffer *buffer; struct mutex mlock; unsigned long *available_scan_masks; @@ -383,10 +383,10 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) void iio_free_device(struct iio_dev *dev); /** - * iio_ring_enabled() - helper function to test if any form of ring is enabled + * iio_buffer_enabled() - helper function to test if the buffer is enabled * @dev_info: IIO device info structure for device **/ -static inline bool iio_ring_enabled(struct iio_dev *dev_info) +static inline bool iio_buffer_enabled(struct iio_dev *dev_info) { return dev_info->currentmode & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE); diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index a173321a993..dde9e3e4278 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -33,27 +33,27 @@ int __iio_add_chan_devattr(const char *postfix, #ifdef CONFIG_IIO_BUFFER struct poll_table_struct; -void iio_chrdev_ring_open(struct iio_dev *indio_dev); -void iio_chrdev_ring_release(struct iio_dev *indio_dev); +void iio_chrdev_buffer_open(struct iio_dev *indio_dev); +void iio_chrdev_buffer_release(struct iio_dev *indio_dev); -unsigned int iio_ring_poll(struct file *filp, - struct poll_table_struct *wait); -ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, - size_t n, loff_t *f_ps); +unsigned int iio_buffer_poll(struct file *filp, + struct poll_table_struct *wait); +ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, + size_t n, loff_t *f_ps); -#define iio_ring_poll_addr (&iio_ring_poll) -#define iio_ring_read_first_n_outer_addr (&iio_ring_read_first_n_outer) +#define iio_buffer_poll_addr (&iio_buffer_poll) +#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer) #else -static inline void iio_chrdev_ring_open(struct iio_dev *indio_dev) +static inline void iio_chrdev_buffer_open(struct iio_dev *indio_dev) {} -static inline void iio_chrdev_ring_release(struct iio_dev *indio_dev) +static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev) {} -#define iio_ring_poll_addr NULL -#define iio_ring_read_first_n_outer_addr NULL +#define iio_buffer_poll_addr NULL +#define iio_buffer_read_first_n_outer_addr NULL #endif diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index fb831618277..929da9b794c 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -495,7 +495,7 @@ static int ad5933_read_raw(struct iio_dev *dev_info, mutex_lock(&dev_info->mlock); switch (m) { case 0: - if (iio_ring_enabled(dev_info)) { + if (iio_buffer_enabled(dev_info)) { ret = -EBUSY; goto out; } @@ -536,7 +536,7 @@ static const struct iio_info ad5933_info = { static int ad5933_ring_preenable(struct iio_dev *indio_dev) { struct ad5933_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; int ret; @@ -546,9 +546,9 @@ static int ad5933_ring_preenable(struct iio_dev *indio_dev) d_size = ring->scan_count * ad5933_channels[1].scan_type.storagebits / 8; - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, d_size); ret = ad5933_reset(st); if (ret < 0) @@ -594,7 +594,7 @@ static int ad5933_ring_postdisable(struct iio_dev *indio_dev) return ad5933_cmd(st, AD5933_CTRL_POWER_DOWN); } -static const struct iio_ring_setup_ops ad5933_ring_setup_ops = { +static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { .preenable = &ad5933_ring_preenable, .postenable = &ad5933_ring_postenable, .postdisable = &ad5933_ring_postdisable, @@ -602,15 +602,15 @@ static const struct iio_ring_setup_ops ad5933_ring_setup_ops = { static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) { - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) return -ENOMEM; /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad5933_ring_setup_ops; + indio_dev->buffer->setup_ops = &ad5933_ring_setup_ops; indio_dev->modes |= INDIO_BUFFER_HARDWARE; @@ -622,7 +622,7 @@ static void ad5933_work(struct work_struct *work) struct ad5933_state *st = container_of(work, struct ad5933_state, work.work); struct iio_dev *indio_dev = i2c_get_clientdata(st->client); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; signed short buf[2]; unsigned char status; @@ -728,13 +728,13 @@ static int __devinit ad5933_probe(struct i2c_client *client, goto error_disable_reg; /* skip temp0_input, register in0_(real|imag)_raw */ - ret = iio_ring_buffer_register(indio_dev, &ad5933_channels[1], 2); + ret = iio_buffer_register(indio_dev, &ad5933_channels[1], 2); if (ret) goto error_unreg_ring; /* enable both REAL and IMAG channels by default */ - iio_scan_mask_set(indio_dev->ring, 0); - iio_scan_mask_set(indio_dev->ring, 1); + iio_scan_mask_set(indio_dev->buffer, 0); + iio_scan_mask_set(indio_dev->buffer, 1); ret = ad5933_setup(st); if (ret) @@ -747,9 +747,9 @@ static int __devinit ad5933_probe(struct i2c_client *client, return 0; error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); @@ -767,8 +767,8 @@ static __devexit int ad5933_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad5933_state *st = iio_priv(indio_dev); - iio_ring_buffer_unregister(indio_dev); - iio_sw_rb_free(indio_dev->ring); + iio_buffer_unregister(indio_dev); + iio_sw_rb_free(indio_dev->buffer); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index b041b46539d..d99c56a6971 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -1045,9 +1045,9 @@ static int __devinit adis16400_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_ring_buffer_register(indio_dev, - st->variant->channels, - st->variant->num_channels); + ret = iio_buffer_register(indio_dev, + st->variant->channels, + st->variant->num_channels); if (ret) { dev_err(&spi->dev, "failed to initialize the ring\n"); goto error_unreg_ring_funcs; @@ -1073,7 +1073,7 @@ error_remove_trigger: if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) adis16400_remove_trigger(indio_dev); error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); error_unreg_ring_funcs: adis16400_unconfigure_ring(indio_dev); error_free_dev: @@ -1093,7 +1093,7 @@ static int adis16400_remove(struct spi_device *spi) goto err_ret; adis16400_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); adis16400_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index a97e1e3b02b..c3682458d78 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -79,13 +79,13 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) int i, j = 0, ret; struct spi_transfer *xfers; - xfers = kzalloc(sizeof(*xfers)*indio_dev->ring->scan_count + 1, + xfers = kzalloc(sizeof(*xfers)*indio_dev->buffer->scan_count + 1, GFP_KERNEL); if (xfers == NULL) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++) - if (test_bit(i, indio_dev->ring->scan_mask)) { + if (test_bit(i, indio_dev->buffer->scan_mask)) { xfers[j].tx_buf = &read_all_tx_array[i]; xfers[j].bits_per_word = 16; xfers[j].len = 2; @@ -96,7 +96,7 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) xfers[j].len = 2; spi_message_init(&msg); - for (j = 0; j < indio_dev->ring->scan_count + 1; j++) + for (j = 0; j < indio_dev->buffer->scan_count + 1; j++) spi_message_add_tail(&xfers[j], &msg); ret = spi_sync(st->us, &msg); @@ -113,7 +113,7 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16400_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int i = 0, j, ret = 0; s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); @@ -137,7 +137,7 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx); if (ret < 0) goto err; - for (; i < indio_dev->ring->scan_count; i++) { + for (; i < indio_dev->buffer->scan_count; i++) { j = __ffs(mask); mask &= ~(1 << j); data[i] = be16_to_cpup( @@ -148,7 +148,7 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) /* Guaranteed to be aligned with 8 byte boundary */ if (ring->scan_timestamp) *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp; - ring->access->store_to(indio_dev->ring, (u8 *) data, pf->timestamp); + ring->access->store_to(indio_dev->buffer, (u8 *) data, pf->timestamp); iio_trigger_notify_done(indio_dev->trig); @@ -163,11 +163,11 @@ err: void adis16400_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } -static const struct iio_ring_setup_ops adis16400_ring_setup_ops = { - .preenable = &iio_sw_ring_preenable, +static const struct iio_buffer_setup_ops adis16400_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -175,15 +175,14 @@ static const struct iio_ring_setup_ops adis16400_ring_setup_ops = { int adis16400_configure_ring(struct iio_dev *indio_dev) { int ret = 0; - struct adis16400_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring; + struct iio_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } - indio_dev->ring = ring; + indio_dev->buffer = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; @@ -206,6 +205,6 @@ int adis16400_configure_ring(struct iio_dev *indio_dev) indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-buffer.c similarity index 57% rename from drivers/staging/iio/industrialio-ring.c rename to drivers/staging/iio/industrialio-buffer.c index 6f9d9e7858c..c3f57e7e808 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -6,7 +6,7 @@ * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * - * Handling of ring allocation / resizing. + * Handling of buffer allocation / resizing. * * * Things to look at here. @@ -31,16 +31,16 @@ static const char * const iio_endian_prefix[] = { }; /** - * iio_ring_read_first_n_outer() - chrdev read for ring buffer access + * iio_buffer_read_first_n_outer() - chrdev read for buffer access * - * This function relies on all ring buffer implementations having an - * iio_ring _bufer as their first element. + * This function relies on all buffer implementations having an + * iio_buffer as their first element. **/ -ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, - size_t n, loff_t *f_ps) +ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, + size_t n, loff_t *f_ps) { struct iio_dev *indio_dev = filp->private_data; - struct iio_ring_buffer *rb = indio_dev->ring; + struct iio_buffer *rb = indio_dev->buffer; if (!rb->access->read_first_n) return -EINVAL; @@ -48,13 +48,13 @@ ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, } /** - * iio_ring_poll() - poll the ring to find out if it has data + * iio_buffer_poll() - poll the buffer to find out if it has data */ -unsigned int iio_ring_poll(struct file *filp, - struct poll_table_struct *wait) +unsigned int iio_buffer_poll(struct file *filp, + struct poll_table_struct *wait) { struct iio_dev *indio_dev = filp->private_data; - struct iio_ring_buffer *rb = indio_dev->ring; + struct iio_buffer *rb = indio_dev->buffer; poll_wait(filp, &rb->pollq, wait); if (rb->stufftoread) @@ -63,16 +63,16 @@ unsigned int iio_ring_poll(struct file *filp, return 0; } -void iio_chrdev_ring_open(struct iio_dev *indio_dev) +void iio_chrdev_buffer_open(struct iio_dev *indio_dev) { - struct iio_ring_buffer *rb = indio_dev->ring; + struct iio_buffer *rb = indio_dev->buffer; if (rb && rb->access->mark_in_use) rb->access->mark_in_use(rb); } -void iio_chrdev_ring_release(struct iio_dev *indio_dev) +void iio_chrdev_buffer_release(struct iio_dev *indio_dev) { - struct iio_ring_buffer *rb = indio_dev->ring; + struct iio_buffer *rb = indio_dev->buffer; clear_bit(IIO_BUSY_BIT_POS, &rb->flags); if (rb->access->unmark_in_use) @@ -80,13 +80,12 @@ void iio_chrdev_ring_release(struct iio_dev *indio_dev) } -void iio_ring_buffer_init(struct iio_ring_buffer *ring, - struct iio_dev *dev_info) +void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info) { - ring->indio_dev = dev_info; - init_waitqueue_head(&ring->pollq); + buffer->indio_dev = dev_info; + init_waitqueue_head(&buffer->pollq); } -EXPORT_SYMBOL(iio_ring_buffer_init); +EXPORT_SYMBOL(iio_buffer_init); static ssize_t iio_show_scan_index(struct device *dev, struct device_attribute *attr, @@ -123,17 +122,17 @@ static ssize_t iio_scan_el_show(struct device *dev, int ret; struct iio_dev *dev_info = dev_get_drvdata(dev); - ret = iio_scan_mask_query(dev_info->ring, + ret = iio_scan_mask_query(dev_info->buffer, to_iio_dev_attr(attr)->address); if (ret < 0) return ret; return sprintf(buf, "%d\n", ret); } -static int iio_scan_mask_clear(struct iio_ring_buffer *ring, int bit) +static int iio_scan_mask_clear(struct iio_buffer *buffer, int bit) { - clear_bit(bit, ring->scan_mask); - ring->scan_count--; + clear_bit(bit, buffer->scan_mask); + buffer->scan_count--; return 0; } @@ -145,7 +144,7 @@ static ssize_t iio_scan_el_store(struct device *dev, int ret = 0; bool state; struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); state = !(buf[0] == '0'); @@ -154,15 +153,15 @@ static ssize_t iio_scan_el_store(struct device *dev, ret = -EBUSY; goto error_ret; } - ret = iio_scan_mask_query(ring, this_attr->address); + ret = iio_scan_mask_query(buffer, this_attr->address); if (ret < 0) goto error_ret; if (!state && ret) { - ret = iio_scan_mask_clear(ring, this_attr->address); + ret = iio_scan_mask_clear(buffer, this_attr->address); if (ret) goto error_ret; } else if (state && !ret) { - ret = iio_scan_mask_set(ring, this_attr->address); + ret = iio_scan_mask_set(buffer, this_attr->address); if (ret) goto error_ret; } @@ -179,7 +178,7 @@ static ssize_t iio_scan_el_ts_show(struct device *dev, char *buf) { struct iio_dev *dev_info = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", dev_info->ring->scan_timestamp); + return sprintf(buf, "%d\n", dev_info->buffer->scan_timestamp); } static ssize_t iio_scan_el_ts_store(struct device *dev, @@ -197,18 +196,18 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, ret = -EBUSY; goto error_ret; } - indio_dev->ring->scan_timestamp = state; + indio_dev->buffer->scan_timestamp = state; error_ret: mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } -static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan) +static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) { int ret, attrcount = 0; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; ret = __iio_add_chan_devattr("index", chan, @@ -217,7 +216,7 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, 0, 0, &indio_dev->dev, - &ring->scan_el_dev_attr_list); + &buffer->scan_el_dev_attr_list); if (ret) goto error_ret; attrcount++; @@ -228,7 +227,7 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, 0, 0, &indio_dev->dev, - &ring->scan_el_dev_attr_list); + &buffer->scan_el_dev_attr_list); if (ret) goto error_ret; attrcount++; @@ -240,7 +239,7 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, chan->scan_index, 0, &indio_dev->dev, - &ring->scan_el_dev_attr_list); + &buffer->scan_el_dev_attr_list); else ret = __iio_add_chan_devattr("en", chan, @@ -249,51 +248,51 @@ static int iio_ring_add_channel_sysfs(struct iio_dev *indio_dev, chan->scan_index, 0, &indio_dev->dev, - &ring->scan_el_dev_attr_list); + &buffer->scan_el_dev_attr_list); attrcount++; ret = attrcount; error_ret: return ret; } -static void iio_ring_remove_and_free_scan_dev_attr(struct iio_dev *indio_dev, - struct iio_dev_attr *p) +static void iio_buffer_remove_and_free_scan_dev_attr(struct iio_dev *indio_dev, + struct iio_dev_attr *p) { kfree(p->dev_attr.attr.name); kfree(p); } -static void __iio_ring_attr_cleanup(struct iio_dev *indio_dev) +static void __iio_buffer_attr_cleanup(struct iio_dev *indio_dev) { struct iio_dev_attr *p, *n; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; list_for_each_entry_safe(p, n, - &ring->scan_el_dev_attr_list, l) - iio_ring_remove_and_free_scan_dev_attr(indio_dev, p); + &buffer->scan_el_dev_attr_list, l) + iio_buffer_remove_and_free_scan_dev_attr(indio_dev, p); } static const char * const iio_scan_elements_group_name = "scan_elements"; -int iio_ring_buffer_register(struct iio_dev *indio_dev, - const struct iio_chan_spec *channels, - int num_channels) +int iio_buffer_register(struct iio_dev *indio_dev, + const struct iio_chan_spec *channels, + int num_channels) { struct iio_dev_attr *p; struct attribute **attr; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; int ret, i, attrn, attrcount, attrcount_orig = 0; - if (ring->attrs) - indio_dev->groups[indio_dev->groupcounter++] = ring->attrs; + if (buffer->attrs) + indio_dev->groups[indio_dev->groupcounter++] = buffer->attrs; - if (ring->scan_el_attrs != NULL) { - attr = ring->scan_el_attrs->attrs; + if (buffer->scan_el_attrs != NULL) { + attr = buffer->scan_el_attrs->attrs; while (*attr++ != NULL) attrcount_orig++; } attrcount = attrcount_orig; - INIT_LIST_HEAD(&ring->scan_el_dev_attr_list); + INIT_LIST_HEAD(&buffer->scan_el_dev_attr_list); if (channels) { /* new magic */ for (i = 0; i < num_channels; i++) { @@ -303,167 +302,168 @@ int iio_ring_buffer_register(struct iio_dev *indio_dev, indio_dev->masklength = indio_dev->channels[i].scan_index + 1; - ret = iio_ring_add_channel_sysfs(indio_dev, + ret = iio_buffer_add_channel_sysfs(indio_dev, &channels[i]); if (ret < 0) goto error_cleanup_dynamic; attrcount += ret; } - if (indio_dev->masklength && ring->scan_mask == NULL) { - ring->scan_mask - = kzalloc(sizeof(*ring->scan_mask)* + if (indio_dev->masklength && buffer->scan_mask == NULL) { + buffer->scan_mask + = kzalloc(sizeof(*buffer->scan_mask)* BITS_TO_LONGS(indio_dev->masklength), GFP_KERNEL); - if (ring->scan_mask == NULL) { + if (buffer->scan_mask == NULL) { ret = -ENOMEM; goto error_cleanup_dynamic; } } } - ring->scan_el_group.name = iio_scan_elements_group_name; + buffer->scan_el_group.name = iio_scan_elements_group_name; - ring->scan_el_group.attrs - = kzalloc(sizeof(ring->scan_el_group.attrs[0])*(attrcount + 1), + buffer->scan_el_group.attrs + = kzalloc(sizeof(buffer->scan_el_group.attrs[0])* + (attrcount + 1), GFP_KERNEL); - if (ring->scan_el_group.attrs == NULL) { + if (buffer->scan_el_group.attrs == NULL) { ret = -ENOMEM; goto error_free_scan_mask; } - if (ring->scan_el_attrs) - memcpy(ring->scan_el_group.attrs, ring->scan_el_attrs, - sizeof(ring->scan_el_group.attrs[0])*attrcount_orig); + if (buffer->scan_el_attrs) + memcpy(buffer->scan_el_group.attrs, buffer->scan_el_attrs, + sizeof(buffer->scan_el_group.attrs[0])*attrcount_orig); attrn = attrcount_orig; - list_for_each_entry(p, &ring->scan_el_dev_attr_list, l) - ring->scan_el_group.attrs[attrn++] = &p->dev_attr.attr; - indio_dev->groups[indio_dev->groupcounter++] = &ring->scan_el_group; + list_for_each_entry(p, &buffer->scan_el_dev_attr_list, l) + buffer->scan_el_group.attrs[attrn++] = &p->dev_attr.attr; + indio_dev->groups[indio_dev->groupcounter++] = &buffer->scan_el_group; return 0; error_free_scan_mask: - kfree(ring->scan_mask); + kfree(buffer->scan_mask); error_cleanup_dynamic: - __iio_ring_attr_cleanup(indio_dev); + __iio_buffer_attr_cleanup(indio_dev); return ret; } -EXPORT_SYMBOL(iio_ring_buffer_register); +EXPORT_SYMBOL(iio_buffer_register); -void iio_ring_buffer_unregister(struct iio_dev *indio_dev) +void iio_buffer_unregister(struct iio_dev *indio_dev) { - kfree(indio_dev->ring->scan_mask); - kfree(indio_dev->ring->scan_el_group.attrs); - __iio_ring_attr_cleanup(indio_dev); + kfree(indio_dev->buffer->scan_mask); + kfree(indio_dev->buffer->scan_el_group.attrs); + __iio_buffer_attr_cleanup(indio_dev); } -EXPORT_SYMBOL(iio_ring_buffer_unregister); +EXPORT_SYMBOL(iio_buffer_unregister); -ssize_t iio_read_ring_length(struct device *dev, - struct device_attribute *attr, - char *buf) +ssize_t iio_buffer_read_length(struct device *dev, + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; - if (ring->access->get_length) + if (buffer->access->get_length) return sprintf(buf, "%d\n", - ring->access->get_length(ring)); + buffer->access->get_length(buffer)); return 0; } -EXPORT_SYMBOL(iio_read_ring_length); +EXPORT_SYMBOL(iio_buffer_read_length); -ssize_t iio_write_ring_length(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) +ssize_t iio_buffer_write_length(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) { int ret; ulong val; struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; ret = strict_strtoul(buf, 10, &val); if (ret) return ret; - if (ring->access->get_length) - if (val == ring->access->get_length(ring)) + if (buffer->access->get_length) + if (val == buffer->access->get_length(buffer)) return len; - if (ring->access->set_length) { - ring->access->set_length(ring, val); - if (ring->access->mark_param_change) - ring->access->mark_param_change(ring); + if (buffer->access->set_length) { + buffer->access->set_length(buffer, val); + if (buffer->access->mark_param_change) + buffer->access->mark_param_change(buffer); } return len; } -EXPORT_SYMBOL(iio_write_ring_length); +EXPORT_SYMBOL(iio_buffer_write_length); -ssize_t iio_read_ring_bytes_per_datum(struct device *dev, - struct device_attribute *attr, - char *buf) +ssize_t iio_buffer_read_bytes_per_datum(struct device *dev, + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; - if (ring->access->get_bytes_per_datum) + if (buffer->access->get_bytes_per_datum) return sprintf(buf, "%d\n", - ring->access->get_bytes_per_datum(ring)); + buffer->access->get_bytes_per_datum(buffer)); return 0; } -EXPORT_SYMBOL(iio_read_ring_bytes_per_datum); +EXPORT_SYMBOL(iio_buffer_read_bytes_per_datum); -ssize_t iio_store_ring_enable(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) +ssize_t iio_buffer_store_enable(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) { int ret; bool requested_state, current_state; int previous_mode; struct iio_dev *dev_info = dev_get_drvdata(dev); - struct iio_ring_buffer *ring = dev_info->ring; + struct iio_buffer *buffer = dev_info->buffer; mutex_lock(&dev_info->mlock); previous_mode = dev_info->currentmode; requested_state = !(buf[0] == '0'); current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES); if (current_state == requested_state) { - printk(KERN_INFO "iio-ring, current state requested again\n"); + printk(KERN_INFO "iio-buffer, current state requested again\n"); goto done; } if (requested_state) { - if (ring->setup_ops->preenable) { - ret = ring->setup_ops->preenable(dev_info); + if (buffer->setup_ops->preenable) { + ret = buffer->setup_ops->preenable(dev_info); if (ret) { printk(KERN_ERR "Buffer not started:" - "ring preenable failed\n"); + "buffer preenable failed\n"); goto error_ret; } } - if (ring->access->request_update) { - ret = ring->access->request_update(ring); + if (buffer->access->request_update) { + ret = buffer->access->request_update(buffer); if (ret) { printk(KERN_INFO "Buffer not started:" - "ring parameter update failed\n"); + "buffer parameter update failed\n"); goto error_ret; } } - if (ring->access->mark_in_use) - ring->access->mark_in_use(ring); + if (buffer->access->mark_in_use) + buffer->access->mark_in_use(buffer); /* Definitely possible for devices to support both of these.*/ if (dev_info->modes & INDIO_BUFFER_TRIGGERED) { if (!dev_info->trig) { printk(KERN_INFO "Buffer not started: no trigger\n"); ret = -EINVAL; - if (ring->access->unmark_in_use) - ring->access->unmark_in_use(ring); + if (buffer->access->unmark_in_use) + buffer->access->unmark_in_use(buffer); goto error_ret; } dev_info->currentmode = INDIO_BUFFER_TRIGGERED; @@ -474,31 +474,32 @@ ssize_t iio_store_ring_enable(struct device *dev, goto error_ret; } - if (ring->setup_ops->postenable) { - ret = ring->setup_ops->postenable(dev_info); + if (buffer->setup_ops->postenable) { + ret = buffer->setup_ops->postenable(dev_info); if (ret) { printk(KERN_INFO "Buffer not started:" "postenable failed\n"); - if (ring->access->unmark_in_use) - ring->access->unmark_in_use(ring); + if (buffer->access->unmark_in_use) + buffer->access->unmark_in_use(buffer); dev_info->currentmode = previous_mode; - if (ring->setup_ops->postdisable) - ring->setup_ops->postdisable(dev_info); + if (buffer->setup_ops->postdisable) + buffer->setup_ops-> + postdisable(dev_info); goto error_ret; } } } else { - if (ring->setup_ops->predisable) { - ret = ring->setup_ops->predisable(dev_info); + if (buffer->setup_ops->predisable) { + ret = buffer->setup_ops->predisable(dev_info); if (ret) goto error_ret; } - if (ring->access->unmark_in_use) - ring->access->unmark_in_use(ring); + if (buffer->access->unmark_in_use) + buffer->access->unmark_in_use(buffer); dev_info->currentmode = INDIO_DIRECT_MODE; - if (ring->setup_ops->postdisable) { - ret = ring->setup_ops->postdisable(dev_info); + if (buffer->setup_ops->postdisable) { + ret = buffer->setup_ops->postdisable(dev_info); if (ret) goto error_ret; } @@ -511,42 +512,42 @@ error_ret: mutex_unlock(&dev_info->mlock); return ret; } -EXPORT_SYMBOL(iio_store_ring_enable); +EXPORT_SYMBOL(iio_buffer_store_enable); -ssize_t iio_show_ring_enable(struct device *dev, - struct device_attribute *attr, - char *buf) +ssize_t iio_buffer_show_enable(struct device *dev, + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_get_drvdata(dev); return sprintf(buf, "%d\n", !!(dev_info->currentmode & INDIO_ALL_BUFFER_MODES)); } -EXPORT_SYMBOL(iio_show_ring_enable); +EXPORT_SYMBOL(iio_buffer_show_enable); -int iio_sw_ring_preenable(struct iio_dev *indio_dev) +int iio_sw_buffer_preenable(struct iio_dev *indio_dev) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *buffer = indio_dev->buffer; size_t size; dev_dbg(&indio_dev->dev, "%s\n", __func__); /* Check if there are any scan elements enabled, if not fail*/ - if (!(ring->scan_count || ring->scan_timestamp)) + if (!(buffer->scan_count || buffer->scan_timestamp)) return -EINVAL; - if (ring->scan_timestamp) - if (ring->scan_count) + if (buffer->scan_timestamp) + if (buffer->scan_count) /* Timestamp (aligned to s64) and data */ - size = (((ring->scan_count * ring->bpe) + size = (((buffer->scan_count * buffer->bpe) + sizeof(s64) - 1) & ~(sizeof(s64) - 1)) + sizeof(s64); else /* Timestamp only */ size = sizeof(s64); else /* Data only */ - size = ring->scan_count * ring->bpe; - ring->access->set_bytes_per_datum(ring, size); + size = buffer->scan_count * buffer->bpe; + buffer->access->set_bytes_per_datum(buffer, size); return 0; } -EXPORT_SYMBOL(iio_sw_ring_preenable); +EXPORT_SYMBOL(iio_sw_buffer_preenable); /* note NULL used as error indicator as it doesn't make sense. */ @@ -566,12 +567,12 @@ static unsigned long *iio_scan_mask_match(unsigned long *av_masks, /** * iio_scan_mask_set() - set particular bit in the scan mask - * @ring: the ring buffer whose scan mask we are interested in + * @buffer: the buffer whose scan mask we are interested in * @bit: the bit to be set. **/ -int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) +int iio_scan_mask_set(struct iio_buffer *buffer, int bit) { - struct iio_dev *dev_info = ring->indio_dev; + struct iio_dev *dev_info = buffer->indio_dev; unsigned long *mask; unsigned long *trialmask; @@ -582,11 +583,11 @@ int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) if (trialmask == NULL) return -ENOMEM; if (!dev_info->masklength) { - WARN_ON("trying to set scan mask prior to registering ring\n"); + WARN_ON("trying to set scanmask prior to registering buffer\n"); kfree(trialmask); return -EINVAL; } - bitmap_copy(trialmask, ring->scan_mask, dev_info->masklength); + bitmap_copy(trialmask, buffer->scan_mask, dev_info->masklength); set_bit(bit, trialmask); if (dev_info->available_scan_masks) { @@ -598,8 +599,8 @@ int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) return -EINVAL; } } - bitmap_copy(ring->scan_mask, trialmask, dev_info->masklength); - ring->scan_count++; + bitmap_copy(buffer->scan_mask, trialmask, dev_info->masklength); + buffer->scan_count++; kfree(trialmask); @@ -607,22 +608,22 @@ int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit) }; EXPORT_SYMBOL_GPL(iio_scan_mask_set); -int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit) +int iio_scan_mask_query(struct iio_buffer *buffer, int bit) { - struct iio_dev *dev_info = ring->indio_dev; + struct iio_dev *dev_info = buffer->indio_dev; long *mask; if (bit > dev_info->masklength) return -EINVAL; - if (!ring->scan_mask) + if (!buffer->scan_mask) return 0; if (dev_info->available_scan_masks) mask = iio_scan_mask_match(dev_info->available_scan_masks, dev_info->masklength, - ring->scan_mask); + buffer->scan_mask); else - mask = ring->scan_mask; + mask = buffer->scan_mask; if (!mask) return 0; diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index bfbfcdd6748..b11c7f303ac 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1058,23 +1058,23 @@ void iio_free_device(struct iio_dev *dev) EXPORT_SYMBOL(iio_free_device); /** - * iio_chrdev_open() - chrdev file open for ring buffer access and ioctls + * iio_chrdev_open() - chrdev file open for buffer access and ioctls **/ static int iio_chrdev_open(struct inode *inode, struct file *filp) { struct iio_dev *dev_info = container_of(inode->i_cdev, struct iio_dev, chrdev); filp->private_data = dev_info; - iio_chrdev_ring_open(dev_info); + iio_chrdev_buffer_open(dev_info); return 0; } /** - * iio_chrdev_release() - chrdev file close ring buffer access and ioctls + * iio_chrdev_release() - chrdev file close buffer access and ioctls **/ static int iio_chrdev_release(struct inode *inode, struct file *filp) { - iio_chrdev_ring_release(container_of(inode->i_cdev, + iio_chrdev_buffer_release(container_of(inode->i_cdev, struct iio_dev, chrdev)); return 0; } @@ -1096,11 +1096,11 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EINVAL; } -static const struct file_operations iio_ring_fileops = { - .read = iio_ring_read_first_n_outer_addr, +static const struct file_operations iio_buffer_fileops = { + .read = iio_buffer_read_first_n_outer_addr, .release = iio_chrdev_release, .open = iio_chrdev_open, - .poll = iio_ring_poll_addr, + .poll = iio_buffer_poll_addr, .owner = THIS_MODULE, .llseek = noop_llseek, .unlocked_ioctl = iio_ioctl, @@ -1132,7 +1132,7 @@ int iio_device_register(struct iio_dev *dev_info) ret = device_add(&dev_info->dev); if (ret < 0) goto error_unreg_eventset; - cdev_init(&dev_info->chrdev, &iio_ring_fileops); + cdev_init(&dev_info->chrdev, &iio_buffer_fileops); dev_info->chrdev.owner = dev_info->info->driver_module; ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1); if (ret < 0) diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c index 39b058557f6..e8c234bb18f 100644 --- a/drivers/staging/iio/kfifo_buf.c +++ b/drivers/staging/iio/kfifo_buf.c @@ -9,14 +9,14 @@ #include "kfifo_buf.h" struct iio_kfifo { - struct iio_ring_buffer ring; + struct iio_buffer buffer; struct kfifo kf; int use_count; int update_needed; struct mutex use_lock; }; -#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring) +#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer) static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, int bytes_per_datum, int length) @@ -24,11 +24,11 @@ static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, if ((length == 0) || (bytes_per_datum == 0)) return -EINVAL; - __iio_update_ring_buffer(&buf->ring, bytes_per_datum, length); + __iio_update_buffer(&buf->buffer, bytes_per_datum, length); return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL); } -static int iio_request_update_kfifo(struct iio_ring_buffer *r) +static int iio_request_update_kfifo(struct iio_buffer *r) { int ret = 0; struct iio_kfifo *buf = iio_to_kfifo(r); @@ -41,14 +41,14 @@ static int iio_request_update_kfifo(struct iio_ring_buffer *r) goto error_ret; } kfifo_free(&buf->kf); - ret = __iio_allocate_kfifo(buf, buf->ring.bytes_per_datum, - buf->ring.length); + ret = __iio_allocate_kfifo(buf, buf->buffer.bytes_per_datum, + buf->buffer.length); error_ret: mutex_unlock(&buf->use_lock); return ret; } -static void iio_mark_kfifo_in_use(struct iio_ring_buffer *r) +static void iio_mark_kfifo_in_use(struct iio_buffer *r) { struct iio_kfifo *buf = iio_to_kfifo(r); mutex_lock(&buf->use_lock); @@ -56,7 +56,7 @@ static void iio_mark_kfifo_in_use(struct iio_ring_buffer *r) mutex_unlock(&buf->use_lock); } -static void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r) +static void iio_unmark_kfifo_in_use(struct iio_buffer *r) { struct iio_kfifo *buf = iio_to_kfifo(r); mutex_lock(&buf->use_lock); @@ -64,7 +64,7 @@ static void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r) mutex_unlock(&buf->use_lock); } -static int iio_get_length_kfifo(struct iio_ring_buffer *r) +static int iio_get_length_kfifo(struct iio_buffer *r) { return r->length; } @@ -74,9 +74,9 @@ static inline void __iio_init_kfifo(struct iio_kfifo *kf) mutex_init(&kf->use_lock); } -static IIO_RING_ENABLE_ATTR; -static IIO_RING_BYTES_PER_DATUM_ATTR; -static IIO_RING_LENGTH_ATTR; +static IIO_BUFFER_ENABLE_ATTR; +static IIO_BUFFER_BYTES_PER_DATUM_ATTR; +static IIO_BUFFER_LENGTH_ATTR; static struct attribute *iio_kfifo_attributes[] = { &dev_attr_length.attr, @@ -90,7 +90,7 @@ static struct attribute_group iio_kfifo_attribute_group = { .name = "buffer", }; -struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) +struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) { struct iio_kfifo *kf; @@ -98,20 +98,20 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) if (!kf) return NULL; kf->update_needed = true; - iio_ring_buffer_init(&kf->ring, indio_dev); - kf->ring.attrs = &iio_kfifo_attribute_group; + iio_buffer_init(&kf->buffer, indio_dev); + kf->buffer.attrs = &iio_kfifo_attribute_group; __iio_init_kfifo(kf); - return &kf->ring; + return &kf->buffer; } EXPORT_SYMBOL(iio_kfifo_allocate); -static int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r) +static int iio_get_bytes_per_datum_kfifo(struct iio_buffer *r) { return r->bytes_per_datum; } -static int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd) +static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd) { if (r->bytes_per_datum != bpd) { r->bytes_per_datum = bpd; @@ -121,14 +121,14 @@ static int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd) return 0; } -static int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r) +static int iio_mark_update_needed_kfifo(struct iio_buffer *r) { struct iio_kfifo *kf = iio_to_kfifo(r); kf->update_needed = true; return 0; } -static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length) +static int iio_set_length_kfifo(struct iio_buffer *r, int length) { if (r->length != length) { r->length = length; @@ -138,13 +138,13 @@ static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length) return 0; } -void iio_kfifo_free(struct iio_ring_buffer *r) +void iio_kfifo_free(struct iio_buffer *r) { kfree(iio_to_kfifo(r)); } EXPORT_SYMBOL(iio_kfifo_free); -static int iio_store_to_kfifo(struct iio_ring_buffer *r, +static int iio_store_to_kfifo(struct iio_buffer *r, u8 *data, s64 timestamp) { @@ -163,7 +163,7 @@ static int iio_store_to_kfifo(struct iio_ring_buffer *r, return 0; } -static int iio_read_first_n_kfifo(struct iio_ring_buffer *r, +static int iio_read_first_n_kfifo(struct iio_buffer *r, size_t n, char __user *buf) { int ret, copied; @@ -174,7 +174,7 @@ static int iio_read_first_n_kfifo(struct iio_ring_buffer *r, return copied; } -const struct iio_ring_access_funcs kfifo_access_funcs = { +const struct iio_buffer_access_funcs kfifo_access_funcs = { .mark_in_use = &iio_mark_kfifo_in_use, .unmark_in_use = &iio_unmark_kfifo_in_use, .store_to = &iio_store_to_kfifo, diff --git a/drivers/staging/iio/kfifo_buf.h b/drivers/staging/iio/kfifo_buf.h index 66a80c65840..a15598bb9fd 100644 --- a/drivers/staging/iio/kfifo_buf.h +++ b/drivers/staging/iio/kfifo_buf.h @@ -3,8 +3,8 @@ #include "iio.h" #include "buffer_generic.h" -extern const struct iio_ring_access_funcs kfifo_access_funcs; +extern const struct iio_buffer_access_funcs kfifo_access_funcs; -struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev); -void iio_kfifo_free(struct iio_ring_buffer *r); +struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev); +void iio_kfifo_free(struct iio_buffer *r); diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 9a0dc1ea80e..bedd3783fc3 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -775,9 +775,9 @@ static int __devinit ade7758_probe(struct spi_device *spi) if (ret) goto error_free_tx; - ret = iio_ring_buffer_register(indio_dev, - &ade7758_channels[0], - ARRAY_SIZE(ade7758_channels)); + ret = iio_buffer_register(indio_dev, + &ade7758_channels[0], + ARRAY_SIZE(ade7758_channels)); if (ret) { dev_err(&spi->dev, "failed to initialize the ring\n"); goto error_unreg_ring_funcs; diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 8c7541ec321..99ade658a2d 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -61,7 +61,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; struct ade7758_state *st = iio_priv(indio_dev); s64 dat64[2]; u32 *dat32 = (u32 *)dat64; @@ -91,7 +91,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p) static int ade7758_ring_preenable(struct iio_dev *indio_dev) { struct ade7758_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; size_t d_size; unsigned channel; @@ -109,9 +109,9 @@ static int ade7758_ring_preenable(struct iio_dev *indio_dev) d_size += sizeof(s64) - (d_size % sizeof(s64)); } - if (indio_dev->ring->access->set_bytes_per_datum) - indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring, - d_size); + if (indio_dev->buffer->access->set_bytes_per_datum) + indio_dev->buffer->access-> + set_bytes_per_datum(indio_dev->buffer, d_size); ade7758_write_waveform_type(&indio_dev->dev, st->ade7758_ring_channels[channel].address); @@ -119,7 +119,7 @@ static int ade7758_ring_preenable(struct iio_dev *indio_dev) return 0; } -static const struct iio_ring_setup_ops ade7758_ring_setup_ops = { +static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = { .preenable = &ade7758_ring_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, @@ -128,7 +128,7 @@ static const struct iio_ring_setup_ops ade7758_ring_setup_ops = { void ade7758_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } int ade7758_configure_ring(struct iio_dev *indio_dev) @@ -136,16 +136,16 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) struct ade7758_state *st = iio_priv(indio_dev); int ret = 0; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; return ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; - indio_dev->ring->setup_ops = &ade7758_ring_setup_ops; - indio_dev->ring->owner = THIS_MODULE; + indio_dev->buffer->access = &ring_sw_access_funcs; + indio_dev->buffer->setup_ops = &ade7758_ring_setup_ops; + indio_dev->buffer->owner = THIS_MODULE; indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &ade7758_trigger_handler, @@ -196,11 +196,11 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); return ret; } void ade7758_uninitialize_ring(struct iio_dev *indio_dev) { - iio_ring_buffer_unregister(indio_dev); + iio_buffer_unregister(indio_dev); } diff --git a/drivers/staging/iio/ring_hw.h b/drivers/staging/iio/ring_hw.h index bb8cfd28d45..cad8a2ed9b6 100644 --- a/drivers/staging/iio/ring_hw.h +++ b/drivers/staging/iio/ring_hw.h @@ -14,9 +14,9 @@ * @buf: generic ring buffer elements * @private: device specific data */ -struct iio_hw_ring_buffer { - struct iio_ring_buffer buf; +struct iio_hw_buffer { + struct iio_buffer buf; void *private; }; -#define iio_to_hw_ring_buf(r) container_of(r, struct iio_hw_ring_buffer, buf) +#define iio_to_hw_buf(r) container_of(r, struct iio_hw_buffer, buf) diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c index 1905e033c41..66a34addb75 100644 --- a/drivers/staging/iio/ring_sw.c +++ b/drivers/staging/iio/ring_sw.c @@ -30,10 +30,10 @@ * @use_lock: lock to prevent change in size when in use * * Note that the first element of all ring buffers must be a - * struct iio_ring_buffer. + * struct iio_buffer. **/ struct iio_sw_ring_buffer { - struct iio_ring_buffer buf; + struct iio_buffer buf; unsigned char *data; unsigned char *read_p; unsigned char *write_p; @@ -52,7 +52,7 @@ static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring, { if ((length == 0) || (bytes_per_datum == 0)) return -EINVAL; - __iio_update_ring_buffer(&ring->buf, bytes_per_datum, length); + __iio_update_buffer(&ring->buf, bytes_per_datum, length); ring->data = kmalloc(length*ring->buf.bytes_per_datum, GFP_ATOMIC); ring->read_p = NULL; ring->write_p = NULL; @@ -71,7 +71,7 @@ static inline void __iio_free_sw_ring_buffer(struct iio_sw_ring_buffer *ring) kfree(ring->data); } -static void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r) +static void iio_mark_sw_rb_in_use(struct iio_buffer *r) { struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); spin_lock(&ring->use_lock); @@ -79,7 +79,7 @@ static void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r) spin_unlock(&ring->use_lock); } -static void iio_unmark_sw_rb_in_use(struct iio_ring_buffer *r) +static void iio_unmark_sw_rb_in_use(struct iio_buffer *r) { struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); spin_lock(&ring->use_lock); @@ -166,7 +166,7 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring, return ret; } -static int iio_read_first_n_sw_rb(struct iio_ring_buffer *r, +static int iio_read_first_n_sw_rb(struct iio_buffer *r, size_t n, char __user *buf) { struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); @@ -297,7 +297,7 @@ error_ret: return ret; } -static int iio_store_to_sw_rb(struct iio_ring_buffer *r, +static int iio_store_to_sw_rb(struct iio_buffer *r, u8 *data, s64 timestamp) { @@ -327,13 +327,13 @@ again: return 0; } -static int iio_read_last_from_sw_rb(struct iio_ring_buffer *r, +static int iio_read_last_from_sw_rb(struct iio_buffer *r, unsigned char *data) { return iio_read_last_from_sw_ring(iio_to_sw_ring(r), data); } -static int iio_request_update_sw_rb(struct iio_ring_buffer *r) +static int iio_request_update_sw_rb(struct iio_buffer *r) { int ret = 0; struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); @@ -354,13 +354,13 @@ error_ret: return ret; } -static int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r) +static int iio_get_bytes_per_datum_sw_rb(struct iio_buffer *r) { struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); return ring->buf.bytes_per_datum; } -static int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd) +static int iio_set_bytes_per_datum_sw_rb(struct iio_buffer *r, size_t bpd) { if (r->bytes_per_datum != bpd) { r->bytes_per_datum = bpd; @@ -370,12 +370,12 @@ static int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd) return 0; } -static int iio_get_length_sw_rb(struct iio_ring_buffer *r) +static int iio_get_length_sw_rb(struct iio_buffer *r) { return r->length; } -static int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length) +static int iio_set_length_sw_rb(struct iio_buffer *r, int length) { if (r->length != length) { r->length = length; @@ -385,16 +385,16 @@ static int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length) return 0; } -static int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r) +static int iio_mark_update_needed_sw_rb(struct iio_buffer *r) { struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); ring->update_needed = true; return 0; } -static IIO_RING_ENABLE_ATTR; -static IIO_RING_BYTES_PER_DATUM_ATTR; -static IIO_RING_LENGTH_ATTR; +static IIO_BUFFER_ENABLE_ATTR; +static IIO_BUFFER_BYTES_PER_DATUM_ATTR; +static IIO_BUFFER_LENGTH_ATTR; /* Standard set of ring buffer attributes */ static struct attribute *iio_ring_attributes[] = { @@ -409,9 +409,9 @@ static struct attribute_group iio_ring_attribute_group = { .name = "buffer", }; -struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) +struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) { - struct iio_ring_buffer *buf; + struct iio_buffer *buf; struct iio_sw_ring_buffer *ring; ring = kzalloc(sizeof *ring, GFP_KERNEL); @@ -419,7 +419,7 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) return NULL; ring->update_needed = true; buf = &ring->buf; - iio_ring_buffer_init(buf, indio_dev); + iio_buffer_init(buf, indio_dev); __iio_init_sw_ring_buffer(ring); buf->attrs = &iio_ring_attribute_group; @@ -427,13 +427,13 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) } EXPORT_SYMBOL(iio_sw_rb_allocate); -void iio_sw_rb_free(struct iio_ring_buffer *r) +void iio_sw_rb_free(struct iio_buffer *r) { kfree(iio_to_sw_ring(r)); } EXPORT_SYMBOL(iio_sw_rb_free); -const struct iio_ring_access_funcs ring_sw_access_funcs = { +const struct iio_buffer_access_funcs ring_sw_access_funcs = { .mark_in_use = &iio_mark_sw_rb_in_use, .unmark_in_use = &iio_unmark_sw_rb_in_use, .store_to = &iio_store_to_sw_rb, diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h index 2835c9940ed..a3e15784c22 100644 --- a/drivers/staging/iio/ring_sw.h +++ b/drivers/staging/iio/ring_sw.h @@ -28,8 +28,8 @@ /** * ring_sw_access_funcs - access functions for a software ring buffer **/ -extern const struct iio_ring_access_funcs ring_sw_access_funcs; +extern const struct iio_buffer_access_funcs ring_sw_access_funcs; -struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev); -void iio_sw_rb_free(struct iio_ring_buffer *ring); +struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev); +void iio_sw_rb_free(struct iio_buffer *ring); #endif /* _IIO_RING_SW_H_ */ From 6ddbb08af050948a7dda0fb5db6bf6bc01d54528 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:58 +0100 Subject: [PATCH 1155/1519] staging:iio:accel:lis3l02dq ring->buffer renames. This driver already supports kfifo usage, so the term ring is misleading and hence replaced. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq.h | 20 +++--- drivers/staging/iio/accel/lis3l02dq_core.c | 25 +++---- drivers/staging/iio/accel/lis3l02dq_ring.c | 76 +++++++++++----------- 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h index 6633091d018..7237a9ab61a 100644 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ b/drivers/staging/iio/accel/lis3l02dq.h @@ -175,19 +175,19 @@ int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev, int lis3l02dq_disable_all_events(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER -/* At the moment triggers are only used for ring buffer +/* At the moment triggers are only used for buffer * filling. This may change! */ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev); int lis3l02dq_probe_trigger(struct iio_dev *indio_dev); -ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, +ssize_t lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer, int index, int *val); -int lis3l02dq_configure_ring(struct iio_dev *indio_dev); -void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev); +int lis3l02dq_configure_buffer(struct iio_dev *indio_dev); +void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev); #ifdef CONFIG_LIS3L02DQ_BUF_RING_SW #define lis3l02dq_free_buf iio_sw_rb_free @@ -203,7 +203,7 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private); #define lis3l02dq_th lis3l02dq_data_rdy_trig_poll #else /* CONFIG_IIO_BUFFER */ -#define lis3l02dq_th lis3l02dq_noring +#define lis3l02dq_th lis3l02dq_nobuffer static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) { @@ -213,18 +213,18 @@ static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) return 0; } static inline ssize_t -lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, - int index, - int *val) +lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer, + int index, + int *val) { return 0; } -static int lis3l02dq_configure_ring(struct iio_dev *indio_dev) +static int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) { return 0; } -static inline void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) +static inline void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev) { } #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index c59ca1c2a19..737dd97f44a 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -35,7 +35,7 @@ */ /* direct copy of the irq_default_primary_handler */ #ifndef CONFIG_IIO_BUFFER -static irqreturn_t lis3l02dq_noring(int irq, void *private) +static irqreturn_t lis3l02dq_nobuffer(int irq, void *private) { return IRQ_WAKE_THREAD; } @@ -260,9 +260,10 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) - ret = lis3l02dq_read_accel_from_ring(indio_dev->buffer, - chan->scan_index, - val); + ret = lis3l02dq_read_accel_from_buffer(indio_dev-> + buffer, + chan->scan_index, + val); else { reg = lis3l02dq_axis_map [LIS3L02DQ_ACCEL][chan->address]; @@ -686,7 +687,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; - ret = lis3l02dq_configure_ring(indio_dev); + ret = lis3l02dq_configure_buffer(indio_dev); if (ret) goto error_free_dev; @@ -694,8 +695,8 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) lis3l02dq_channels, ARRAY_SIZE(lis3l02dq_channels)); if (ret) { - printk(KERN_ERR "failed to initialize the ring\n"); - goto error_unreg_ring_funcs; + printk(KERN_ERR "failed to initialize the buffer\n"); + goto error_unreg_buffer_funcs; } if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { @@ -706,7 +707,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) "lis3l02dq", indio_dev); if (ret) - goto error_uninitialize_ring; + goto error_uninitialize_buffer; ret = lis3l02dq_probe_trigger(indio_dev); if (ret) @@ -730,10 +731,10 @@ error_remove_trigger: error_free_interrupt: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(st->us->irq, indio_dev); -error_uninitialize_ring: +error_uninitialize_buffer: iio_buffer_unregister(indio_dev); -error_unreg_ring_funcs: - lis3l02dq_unconfigure_ring(indio_dev); +error_unreg_buffer_funcs: + lis3l02dq_unconfigure_buffer(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: @@ -786,7 +787,7 @@ static int lis3l02dq_remove(struct spi_device *spi) lis3l02dq_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); - lis3l02dq_unconfigure_ring(indio_dev); + lis3l02dq_unconfigure_buffer(indio_dev); iio_device_unregister(indio_dev); diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 1ccfba9ff13..5c542dd0461 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -38,30 +38,30 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private) } /** - * lis3l02dq_read_accel_from_ring() individual acceleration read from ring + * lis3l02dq_read_accel_from_buffer() individual acceleration read from buffer **/ -ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, - int index, - int *val) +ssize_t lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer, + int index, + int *val) { int ret; s16 *data; - if (!iio_scan_mask_query(ring, index)) + if (!iio_scan_mask_query(buffer, index)) return -EINVAL; - if (!ring->access->read_last) + if (!buffer->access->read_last) return -EBUSY; - data = kmalloc(ring->access->get_bytes_per_datum(ring), + data = kmalloc(buffer->access->get_bytes_per_datum(buffer), GFP_KERNEL); if (data == NULL) return -ENOMEM; - ret = ring->access->read_last(ring, (u8 *)data); + ret = buffer->access->read_last(buffer, (u8 *)data); if (ret) goto error_free_data; - *val = data[bitmap_weight(ring->scan_mask, index)]; + *val = data[bitmap_weight(buffer->scan_mask, index)]; error_free_data: kfree(data); @@ -86,13 +86,13 @@ static const u8 read_all_tx_array[] = { **/ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) { - struct iio_buffer *ring = indio_dev->buffer; + struct iio_buffer *buffer = indio_dev->buffer; struct lis3l02dq_state *st = iio_priv(indio_dev); struct spi_transfer *xfers; struct spi_message msg; int ret, i, j = 0; - xfers = kzalloc((ring->scan_count) * 2 + xfers = kzalloc((buffer->scan_count) * 2 * sizeof(*xfers), GFP_KERNEL); if (!xfers) return -ENOMEM; @@ -100,7 +100,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) mutex_lock(&st->buf_lock); for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) - if (test_bit(i, ring->scan_mask)) { + if (test_bit(i, buffer->scan_mask)) { /* lower byte */ xfers[j].tx_buf = st->tx + 2*j; st->tx[2*j] = read_all_tx_array[i*4]; @@ -128,7 +128,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) * values in alternate bytes */ spi_message_init(&msg); - for (j = 0; j < ring->scan_count * 2; j++) + for (j = 0; j < buffer->scan_count * 2; j++) spi_message_add_tail(&xfers[j], &msg); ret = spi_sync(st->us, &msg); @@ -138,7 +138,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) return ret; } -static int lis3l02dq_get_ring_element(struct iio_dev *indio_dev, +static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) { int ret, i; @@ -163,26 +163,26 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - struct iio_buffer *ring = indio_dev->buffer; + struct iio_buffer *buffer = indio_dev->buffer; int len = 0; - size_t datasize = ring->access->get_bytes_per_datum(ring); + size_t datasize = buffer->access->get_bytes_per_datum(buffer); char *data = kmalloc(datasize, GFP_KERNEL); if (data == NULL) { dev_err(indio_dev->dev.parent, - "memory alloc failed in ring bh"); + "memory alloc failed in buffer bh"); return -ENOMEM; } - if (ring->scan_count) - len = lis3l02dq_get_ring_element(indio_dev, data); + if (buffer->scan_count) + len = lis3l02dq_get_buffer_element(indio_dev, data); /* Guaranteed to be aligned with 8 byte boundary */ - if (ring->scan_timestamp) + if (buffer->scan_timestamp) *(s64 *)(((phys_addr_t)data + len + sizeof(s64) - 1) & ~(sizeof(s64) - 1)) = pf->timestamp; - ring->access->store_to(ring, (u8 *)data, pf->timestamp); + buffer->access->store_to(buffer, (u8 *)data, pf->timestamp); iio_trigger_notify_done(indio_dev->trig); kfree(data); @@ -255,7 +255,7 @@ error_ret: * * If disabling the interrupt also does a final read to ensure it is clear. * This is only important in some cases where the scan enable elements are - * switched before the ring is reenabled. + * switched before the buffer is reenabled. **/ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state) @@ -343,13 +343,13 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) iio_free_trigger(st->trig); } -void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) +void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); lis3l02dq_free_buf(indio_dev->buffer); } -static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev) +static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev) { /* Disable unwanted channels otherwise the interrupt will not clear */ u8 t; @@ -392,7 +392,7 @@ error_ret: } /* Turn all channels on again */ -static int lis3l02dq_ring_predisable(struct iio_dev *indio_dev) +static int lis3l02dq_buffer_predisable(struct iio_dev *indio_dev) { u8 t; int ret; @@ -418,29 +418,29 @@ error_ret: return ret; } -static const struct iio_buffer_setup_ops lis3l02dq_ring_setup_ops = { +static const struct iio_buffer_setup_ops lis3l02dq_buffer_setup_ops = { .preenable = &iio_sw_buffer_preenable, - .postenable = &lis3l02dq_ring_postenable, - .predisable = &lis3l02dq_ring_predisable, + .postenable = &lis3l02dq_buffer_postenable, + .predisable = &lis3l02dq_buffer_predisable, }; -int lis3l02dq_configure_ring(struct iio_dev *indio_dev) +int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) { int ret; - struct iio_buffer *ring; + struct iio_buffer *buffer; - ring = lis3l02dq_alloc_buf(indio_dev); - if (!ring) + buffer = lis3l02dq_alloc_buf(indio_dev); + if (!buffer) return -ENOMEM; - indio_dev->buffer = ring; - /* Effectively select the ring buffer implementation */ + indio_dev->buffer = buffer; + /* Effectively select the buffer implementation */ indio_dev->buffer->access = &lis3l02dq_access_funcs; - ring->bpe = 2; + buffer->bpe = 2; - ring->scan_timestamp = true; - ring->setup_ops = &lis3l02dq_ring_setup_ops; - ring->owner = THIS_MODULE; + buffer->scan_timestamp = true; + buffer->setup_ops = &lis3l02dq_buffer_setup_ops; + buffer->owner = THIS_MODULE; /* Functions are NULL as we set handler below */ indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, From f6d838d7fecfd4e59a4ce7bdfb16165add36d26e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:59 +0100 Subject: [PATCH 1156/1519] staging:iio:magnetometer:ak8975 use platform_data to pass the gpio number. Tegra doesn't have irq_to_gpio() any more, and ak8975 is included in tegra_defconfig. This causes a build failure. Instead, pass the GPIO name through platform data. [swarren: Rewrote commit description when I squashed this with my patch to remove the irq_to_gpio() call] Signed-off-by: Jonathan Cameron Signed-off-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/ak8975.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 0697ab3c422..0e66d3f080b 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -477,7 +477,10 @@ static int ak8975_probe(struct i2c_client *client, int err; /* Grab and set up the supplied GPIO. */ - eoc_gpio = irq_to_gpio(client->irq); + if (client->dev.platform_data == NULL) + eoc_gpio = -1; + else + eoc_gpio = *(int *)(client->dev.platform_data); /* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */ From 7c6c936832a46e86b0fac654923ce5015bdc80ee Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 21 Sep 2011 11:16:00 +0100 Subject: [PATCH 1157/1519] staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO gpio_is_valid() is the defined mechanism to determine whether a GPIO is valid. Use this instead of assuming that 0 is an invalid GPIO. Signed-off-by: Stephen Warren Acked-by: Andrew Chew Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/ak8975.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 0e66d3f080b..9c5338396d7 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -373,7 +373,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) } /* Wait for the conversion to complete. */ - if (data->eoc_gpio) + if (gpio_is_valid(data->eoc_gpio)) ret = wait_conversion_complete_gpio(data); else ret = wait_conversion_complete_polled(data); @@ -484,7 +484,7 @@ static int ak8975_probe(struct i2c_client *client, /* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */ - if (eoc_gpio > 0) { + if (gpio_is_valid(eoc_gpio)) { err = gpio_request(eoc_gpio, "ak_8975"); if (err < 0) { dev_err(&client->dev, @@ -500,8 +500,7 @@ static int ak8975_probe(struct i2c_client *client, eoc_gpio, err); goto exit_gpio; } - } else - eoc_gpio = 0; /* No GPIO available */ + } /* Register with IIO */ indio_dev = iio_allocate_device(sizeof(*data)); @@ -537,7 +536,7 @@ static int ak8975_probe(struct i2c_client *client, exit_free_iio: iio_free_device(indio_dev); exit_gpio: - if (eoc_gpio) + if (gpio_is_valid(eoc_gpio)) gpio_free(eoc_gpio); exit: return err; @@ -551,7 +550,7 @@ static int ak8975_remove(struct i2c_client *client) iio_device_unregister(indio_dev); - if (eoc_gpio) + if (gpio_is_valid(eoc_gpio)) gpio_free(eoc_gpio); return 0; From ad31d250bf60c8e4c990e8b0daeedbaa2d6884a9 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 21 Sep 2011 11:16:01 +0100 Subject: [PATCH 1158/1519] staging:iio:magnetometer:ak8975: Fix probe() error-handling Fix ak8975_probe() to jump to the appropriate exit labels when an error occurs. With the previous code, some cleanup actions were being skipped for some error conditions. Signed-off-by: Stephen Warren Acked-by: Andrew Chew Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/magnetometer/ak8975.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 9c5338396d7..ab0e26cbdba 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -513,7 +513,7 @@ static int ak8975_probe(struct i2c_client *client, err = ak8975_setup(client); if (err < 0) { dev_err(&client->dev, "AK8975 initialization fails\n"); - goto exit_gpio; + goto exit_free_iio; } i2c_set_clientdata(client, indio_dev); From 30eb82f05dd1f12b18a0ad054401a0b5690fb3c3 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:16:02 +0100 Subject: [PATCH 1159/1519] staging:iio: Prevent reading from buffer chrdev when device has no buffer. Silly bug introduced during the chrdev merge series. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_core.h | 9 ++++++--- drivers/staging/iio/industrialio-buffer.c | 8 +++++--- drivers/staging/iio/industrialio-core.c | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h index dde9e3e4278..36159e0dbfc 100644 --- a/drivers/staging/iio/iio_core.h +++ b/drivers/staging/iio/iio_core.h @@ -33,7 +33,7 @@ int __iio_add_chan_devattr(const char *postfix, #ifdef CONFIG_IIO_BUFFER struct poll_table_struct; -void iio_chrdev_buffer_open(struct iio_dev *indio_dev); +int iio_chrdev_buffer_open(struct iio_dev *indio_dev); void iio_chrdev_buffer_release(struct iio_dev *indio_dev); unsigned int iio_buffer_poll(struct file *filp, @@ -47,8 +47,11 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, #else -static inline void iio_chrdev_buffer_open(struct iio_dev *indio_dev) -{} +static inline int iio_chrdev_buffer_open(struct iio_dev *indio_dev) +{ + return -EINVAL; +} + static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev) {} diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index c3f57e7e808..4ce101af9a9 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -63,11 +63,14 @@ unsigned int iio_buffer_poll(struct file *filp, return 0; } -void iio_chrdev_buffer_open(struct iio_dev *indio_dev) +int iio_chrdev_buffer_open(struct iio_dev *indio_dev) { struct iio_buffer *rb = indio_dev->buffer; - if (rb && rb->access->mark_in_use) + if (!rb) + return -EINVAL; + if (rb->access->mark_in_use) rb->access->mark_in_use(rb); + return 0; } void iio_chrdev_buffer_release(struct iio_dev *indio_dev) @@ -77,7 +80,6 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev) clear_bit(IIO_BUSY_BIT_POS, &rb->flags); if (rb->access->unmark_in_use) rb->access->unmark_in_use(rb); - } void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info) diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index b11c7f303ac..647a4052a8c 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -1065,8 +1065,8 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp) struct iio_dev *dev_info = container_of(inode->i_cdev, struct iio_dev, chrdev); filp->private_data = dev_info; - iio_chrdev_buffer_open(dev_info); - return 0; + + return iio_chrdev_buffer_open(dev_info); } /** From c7e285bedb20cc0cfe999e1b285ab31a19e1902c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 22 Sep 2011 13:20:57 +0100 Subject: [PATCH 1160/1519] staging: gma500: frame buffer locking If we are the console then a printk can hit us with a spin lock held (and in fact the kernel will do its best to take printing lock). In that case we cannot politely sleep when synching after an accelerated op but must behave obnixously to be sure of getting the bits out. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/accel_2d.c | 10 ++++++---- drivers/staging/gma500/psb_drv.c | 2 +- drivers/staging/gma500/psb_drv.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gma500/accel_2d.c b/drivers/staging/gma500/accel_2d.c index be9237184ab..114b99a1ce1 100644 --- a/drivers/staging/gma500/accel_2d.c +++ b/drivers/staging/gma500/accel_2d.c @@ -111,8 +111,9 @@ static int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf, int ret = 0; int i; unsigned submit_size; + unsigned long flags; - mutex_lock(&dev_priv->mutex_2d); + spin_lock_irqsave(&dev_priv->lock_2d, flags); while (size > 0) { submit_size = (size < 0x60) ? size : 0x60; size -= submit_size; @@ -127,7 +128,7 @@ static int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf, (void)PSB_RSGX32(PSB_SGX_2D_SLAVE_PORT + i - 4); } - mutex_unlock(&dev_priv->mutex_2d); + spin_unlock_irqrestore(&dev_priv->lock_2d, flags); return ret; } @@ -327,8 +328,9 @@ int psbfb_sync(struct fb_info *info) struct drm_psb_private *dev_priv = dev->dev_private; unsigned long _end = jiffies + DRM_HZ; int busy = 0; + unsigned long flags; - mutex_lock(&dev_priv->mutex_2d); + spin_lock_irqsave(&dev_priv->lock_2d, flags); /* * First idle the 2D engine. */ @@ -357,7 +359,7 @@ int psbfb_sync(struct fb_info *info) _PSB_C2B_STATUS_BUSY) != 0); out: - mutex_unlock(&dev_priv->mutex_2d); + spin_unlock_irqrestore(&dev_priv->lock_2d, flags); return (busy) ? -EBUSY : 0; } diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index 297b05a391d..dc676c2ce81 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -228,7 +228,7 @@ static int psb_do_init(struct drm_device *dev) spin_lock_init(&dev_priv->irqmask_lock); - mutex_init(&dev_priv->mutex_2d); + spin_lock_init(&dev_priv->lock_2d); PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0); PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK1); diff --git a/drivers/staging/gma500/psb_drv.h b/drivers/staging/gma500/psb_drv.h index 9cbb494ed3d..11d963a055b 100644 --- a/drivers/staging/gma500/psb_drv.h +++ b/drivers/staging/gma500/psb_drv.h @@ -612,7 +612,7 @@ struct drm_psb_private { void (*exit_idle)(struct drm_device *dev, u32 update_src); /* 2D acceleration */ - struct mutex mutex_2d; + spinlock_t lock_2d; /* FIXME: Arrays anyone ? */ struct mdfld_dsi_encoder *encoder0; From ef86de5832a2eee01c5dc4199cee0c48e9c14c3e Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 22 Sep 2011 19:43:47 +0100 Subject: [PATCH 1161/1519] staging: gma500: gtt based hardware scrolling console Add support for GTT based scrolling. Instead of pushing bits around we simply use the GTT to change the mappings. This provides us with a very fast way to scroll the display providing we have enough memory to allocate on 4K line boundaries. In practice this seems to be the case except for very big displays such as HDMI. It works out nicely on the usual configurations are netbooks and tablets. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gma500/framebuffer.c | 85 +++++++++++++++++++++++----- drivers/staging/gma500/gtt.c | 51 ++++++++++++++++- drivers/staging/gma500/gtt.h | 3 + 3 files changed, 123 insertions(+), 16 deletions(-) diff --git a/drivers/staging/gma500/framebuffer.c b/drivers/staging/gma500/framebuffer.c index 7748331d269..3f39a37456f 100644 --- a/drivers/staging/gma500/framebuffer.c +++ b/drivers/staging/gma500/framebuffer.c @@ -37,6 +37,7 @@ #include "psb_intel_reg.h" #include "psb_intel_drv.h" #include "framebuffer.h" +#include "gtt.h" #include "mdfld_output.h" @@ -91,6 +92,21 @@ static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green, return 0; } +static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info) +{ + struct psb_fbdev *fbdev = info->par; + struct psb_framebuffer *psbfb = &fbdev->pfb; + struct drm_device *dev = psbfb->base.dev; + + /* + * We have to poke our nose in here. The core fb code assumes + * panning is part of the hardware that can be invoked before + * the actual fb is mapped. In our case that isn't quite true. + */ + if (psbfb->gtt->npage) + psb_gtt_roll(dev, psbfb->gtt, var->yoffset); + return 0; +} void psbfb_suspend(struct drm_device *dev) { @@ -217,6 +233,21 @@ static struct fb_ops psbfb_ops = { .fb_ioctl = psbfb_ioctl, }; +static struct fb_ops psbfb_roll_ops = { + .owner = THIS_MODULE, + .fb_check_var = drm_fb_helper_check_var, + .fb_set_par = drm_fb_helper_set_par, + .fb_blank = drm_fb_helper_blank, + .fb_setcolreg = psbfb_setcolreg, + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, + .fb_pan_display = psbfb_pan, + .fb_mmap = psbfb_mmap, + .fb_sync = psbfb_sync, + .fb_ioctl = psbfb_ioctl, +}; + static struct fb_ops psbfb_unaccel_ops = { .owner = THIS_MODULE, .fb_check_var = drm_fb_helper_check_var, @@ -304,6 +335,7 @@ static struct drm_framebuffer *psb_framebuffer_create * psbfb_alloc - allocate frame buffer memory * @dev: the DRM device * @aligned_size: space needed + * @force: fall back to GEM buffers if need be * * Allocate the frame buffer. In the usual case we get a GTT range that * is stolen memory backed and life is simple. If there isn't sufficient @@ -311,11 +343,9 @@ static struct drm_framebuffer *psb_framebuffer_create * and back it with a GEM object. * * In this case the GEM object has no handle. - * - * FIXME: console speed up - allocate twice the space if room and use - * hardware scrolling for acceleration. */ -static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size) +static struct gtt_range *psbfb_alloc(struct drm_device *dev, + int aligned_size, int force) { struct gtt_range *backing; /* Begin by trying to use stolen memory backing */ @@ -326,6 +356,9 @@ static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size) return backing; psb_gtt_free_range(dev, backing); } + if (!force) + return NULL; + /* Next try using GEM host memory */ backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0); if (backing == NULL) @@ -359,6 +392,7 @@ static int psbfb_create(struct psb_fbdev *fbdev, int size; int ret; struct gtt_range *backing; + int gtt_roll = 1; mode_cmd.width = sizes->surface_width; mode_cmd.height = sizes->surface_height; @@ -368,17 +402,37 @@ static int psbfb_create(struct psb_fbdev *fbdev, if (mode_cmd.bpp == 24) mode_cmd.bpp = 32; - /* HW requires pitch to be 64 byte aligned */ - mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64); + /* Acceleration via the GTT requires pitch to be 4096 byte aligned + (ie 1024 or 2048 pixels in normal use) */ + mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 4096); mode_cmd.depth = sizes->surface_depth; size = mode_cmd.pitch * mode_cmd.height; size = ALIGN(size, PAGE_SIZE); /* Allocate the framebuffer in the GTT with stolen page backing */ - backing = psbfb_alloc(dev, size); - if (backing == NULL) - return -ENOMEM; + backing = psbfb_alloc(dev, size, 0); + if (backing == NULL) { + /* + * We couldn't get the space we wanted, fall back to the + * display engine requirement instead. The HW requires + * the pitch to be 64 byte aligned + */ + + gtt_roll = 0; /* Don't use GTT accelerated scrolling */ + + mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64); + mode_cmd.depth = sizes->surface_depth; + + size = mode_cmd.pitch * mode_cmd.height; + size = ALIGN(size, PAGE_SIZE); + + /* Allocate the framebuffer in the GTT with stolen page + backing when there is room */ + backing = psbfb_alloc(dev, size, 1); + if (backing == NULL) + return -ENOMEM; + } mutex_lock(&dev->struct_mutex); @@ -402,11 +456,14 @@ static int psbfb_create(struct psb_fbdev *fbdev, strcpy(info->fix.id, "psbfb"); info->flags = FBINFO_DEFAULT; - /* No 2D engine */ - if (!dev_priv->ops->accel_2d) - info->fbops = &psbfb_unaccel_ops; - else + if (gtt_roll) { /* GTT rolling seems best */ + info->fbops = &psbfb_roll_ops; + info->flags |= FBINFO_HWACCEL_YPAN; + } + else if (dev_priv->ops->accel_2d) /* 2D engine */ info->fbops = &psbfb_ops; + else /* Software */ + info->fbops = &psbfb_unaccel_ops; ret = fb_alloc_cmap(&info->cmap, 256, 0); if (ret) { @@ -416,6 +473,8 @@ static int psbfb_create(struct psb_fbdev *fbdev, info->fix.smem_start = dev->mode_config.fb_base; info->fix.smem_len = size; + info->fix.ywrapstep = gtt_roll; + info->fix.ypanstep = gtt_roll; if (backing->stolen) { /* Accessed stolen memory directly */ diff --git a/drivers/staging/gma500/gtt.c b/drivers/staging/gma500/gtt.c index a24623997e5..e770bd190a5 100644 --- a/drivers/staging/gma500/gtt.c +++ b/drivers/staging/gma500/gtt.c @@ -95,12 +95,17 @@ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r) set_pages_array_uc(pages, r->npage); /* Write our page entries into the GTT itself */ - for (i = 0; i < r->npage; i++) { - pte = psb_gtt_mask_pte(page_to_pfn(*pages++), 0/*type*/); + for (i = r->roll; i < r->npage; i++) { + pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0); + iowrite32(pte, gtt_slot++); + } + for (i = 0; i < r->roll; i++) { + pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0); iowrite32(pte, gtt_slot++); } /* Make sure all the entries are set before we return */ ioread32(gtt_slot - 1); + return 0; } @@ -113,7 +118,6 @@ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r) * page table entries with the dummy page. This is protected via the gtt * mutex which the caller must hold. */ - static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r) { struct drm_psb_private *dev_priv = dev->dev_private; @@ -131,6 +135,46 @@ static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r) set_pages_array_wb(r->pages, r->npage); } +/** + * psb_gtt_roll - set scrolling position + * @dev: our DRM device + * @r: the gtt mapping we are using + * @roll: roll offset + * + * Roll an existing pinned mapping by moving the pages through the GTT. + * This allows us to implement hardware scrolling on the consoles without + * a 2D engine + */ +void psb_gtt_roll(struct drm_device *dev, struct gtt_range *r, int roll) +{ + u32 *gtt_slot, pte; + int i; + + if (roll >= r->npage) { + WARN_ON(1); + return; + } + + r->roll = roll; + + /* Not currently in the GTT - no worry we will write the mapping at + the right position when it gets pinned */ + if (!r->stolen && !r->in_gart) + return; + + gtt_slot = psb_gtt_entry(dev, r); + + for (i = r->roll; i < r->npage; i++) { + pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0); + iowrite32(pte, gtt_slot++); + } + for (i = 0; i < r->roll; i++) { + pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0); + iowrite32(pte, gtt_slot++); + } + ioread32(gtt_slot - 1); +} + /** * psb_gtt_attach_pages - attach and pin GEM pages * @gt: the gtt range @@ -302,6 +346,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, gt->resource.name = name; gt->stolen = backed; gt->in_gart = backed; + gt->roll = 0; /* Ensure this is set for non GEM objects */ gt->gem.dev = dev; ret = allocate_resource(dev_priv->gtt_mem, >->resource, diff --git a/drivers/staging/gma500/gtt.h b/drivers/staging/gma500/gtt.h index e0e1cb6f9bd..aa1742387f5 100644 --- a/drivers/staging/gma500/gtt.h +++ b/drivers/staging/gma500/gtt.h @@ -49,6 +49,7 @@ struct gtt_range { bool mmapping; /* Is mmappable */ struct page **pages; /* Backing pages if present */ int npage; /* Number of backing pages */ + int roll; /* Roll applied to the GTT entries */ }; extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, @@ -57,5 +58,7 @@ extern void psb_gtt_kref_put(struct gtt_range *gt); extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt); extern int psb_gtt_pin(struct gtt_range *gt); extern void psb_gtt_unpin(struct gtt_range *gt); +extern void psb_gtt_roll(struct drm_device *dev, + struct gtt_range *gt, int roll); #endif From 8e0ae3d55a1daebc97ef2631b0cdf2cdef5572db Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:52 +0100 Subject: [PATCH 1162/1519] staging: et131x: support register dump in ethtool ops Not an exhaustive dump of the et131x registers, used while debugging a specific problem - seems a shame not to keep it around. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_ethtool.c | 138 +++++++++++++++++++++++- 1 file changed, 135 insertions(+), 3 deletions(-) diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c index b92633fa6d4..c4555b91a50 100644 --- a/drivers/staging/et131x/et131x_ethtool.c +++ b/drivers/staging/et131x/et131x_ethtool.c @@ -28,6 +28,7 @@ #include #include "et131x_adapter.h" +#include "et1310_phy.h" #include "et131x.h" static int et131x_get_settings(struct net_device *netdev, @@ -46,6 +47,135 @@ static int et131x_set_settings(struct net_device *netdev, return phy_ethtool_sset(adapter->phydev, cmd); } +static int et131x_get_regs_len(struct net_device *netdev) +{ +#define ET131X_REGS_LEN 256 + return ET131X_REGS_LEN * sizeof(u32); +} + +static void et131x_get_regs(struct net_device *netdev, + struct ethtool_regs *regs, void *regs_data) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct address_map __iomem *aregs = adapter->regs; + u32 *regs_buff = regs_data; + u32 num = 0; + + memset(regs_data, 0, et131x_get_regs_len(netdev)); + + regs->version = (1 << 24) | (adapter->pdev->revision << 16) | + adapter->pdev->device; + + /* PHY regs */ + et131x_mii_read(adapter, MII_BMCR, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_BMSR, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_PHYSID1, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_PHYSID2, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_ADVERTISE, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_LPA, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_EXPANSION, (u16 *)®s_buff[num++]); + /* Autoneg next page transmit reg */ + et131x_mii_read(adapter, 0x07, (u16 *)®s_buff[num++]); + /* Link partner next page reg */ + et131x_mii_read(adapter, 0x08, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_CTRL1000, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_STAT1000, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_ESTATUS, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_CONFIG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_PHY_CONTROL, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INTERRUPT_MASK, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_PHY_STATUS, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LED_1, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LED_2, (u16 *)®s_buff[num++]); + + /* Global regs */ + regs_buff[num++] = readl(&aregs->global.txq_start_addr); + regs_buff[num++] = readl(&aregs->global.txq_end_addr); + regs_buff[num++] = readl(&aregs->global.rxq_start_addr); + regs_buff[num++] = readl(&aregs->global.rxq_end_addr); + regs_buff[num++] = readl(&aregs->global.pm_csr); + regs_buff[num++] = adapter->stats.interrupt_status; + regs_buff[num++] = readl(&aregs->global.int_mask); + regs_buff[num++] = readl(&aregs->global.int_alias_clr_en); + regs_buff[num++] = readl(&aregs->global.int_status_alias); + regs_buff[num++] = readl(&aregs->global.sw_reset); + regs_buff[num++] = readl(&aregs->global.slv_timer); + regs_buff[num++] = readl(&aregs->global.msi_config); + regs_buff[num++] = readl(&aregs->global.loopback); + regs_buff[num++] = readl(&aregs->global.watchdog_timer); + + /* TXDMA regs */ + regs_buff[num++] = readl(&aregs->txdma.csr); + regs_buff[num++] = readl(&aregs->txdma.pr_base_hi); + regs_buff[num++] = readl(&aregs->txdma.pr_base_lo); + regs_buff[num++] = readl(&aregs->txdma.pr_num_des); + regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr); + regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr_ext); + regs_buff[num++] = readl(&aregs->txdma.txq_rd_addr); + regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_hi); + regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_lo); + regs_buff[num++] = readl(&aregs->txdma.service_request); + regs_buff[num++] = readl(&aregs->txdma.service_complete); + regs_buff[num++] = readl(&aregs->txdma.cache_rd_index); + regs_buff[num++] = readl(&aregs->txdma.cache_wr_index); + regs_buff[num++] = readl(&aregs->txdma.tx_dma_error); + regs_buff[num++] = readl(&aregs->txdma.desc_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.desc_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.desc_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.dropped_tlp_cnt); + regs_buff[num++] = readl(&aregs->txdma.new_service_complete); + regs_buff[num++] = readl(&aregs->txdma.ethernet_packet_cnt); + + /* RXDMA regs */ + regs_buff[num++] = readl(&aregs->rxdma.csr); + regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.num_pkt_done); + regs_buff[num++] = readl(&aregs->rxdma.max_pkt_time); + regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr); + regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr_ext); + regs_buff[num++] = readl(&aregs->rxdma.rxq_wr_addr); + regs_buff[num++] = readl(&aregs->rxdma.psr_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.psr_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.psr_num_des); + regs_buff[num++] = readl(&aregs->rxdma.psr_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.psr_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.psr_access_index); + regs_buff[num++] = readl(&aregs->rxdma.psr_min_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_num_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_rd_index); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_min_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_num_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_rd_index); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_min_des); +} + #define ET131X_DRVINFO_LEN 32 /* value from ethtool.h */ static void et131x_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) @@ -58,9 +188,11 @@ static void et131x_get_drvinfo(struct net_device *netdev, } static struct ethtool_ops et131x_ethtool_ops = { - .get_settings = et131x_get_settings, - .set_settings = et131x_set_settings, - .get_drvinfo = et131x_get_drvinfo, + .get_settings = et131x_get_settings, + .set_settings = et131x_set_settings, + .get_drvinfo = et131x_get_drvinfo, + .get_regs_len = et131x_get_regs_len, + .get_regs = et131x_get_regs, .get_link = ethtool_op_get_link, }; From 66a0cc1a02054a53ae8e6d1af0870d4ab799416d Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:53 +0100 Subject: [PATCH 1163/1519] staging: et131x: Add link status to adapter struct This will be used to determine if the link state has changed when the phydev informs the et131x that a change has occurred (in et131x_adjust_link) Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_adapter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 78f2894d76e..fabc2c593b3 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -147,6 +147,9 @@ struct et131x_adapter { /* Flags that indicate current state of the adapter */ u32 flags; + /* local link state, to determine if a state change has occurred */ + int link; + /* Configuration */ u8 rom_addr[ETH_ALEN]; u8 addr[ETH_ALEN]; From 268420aa840ce6d5c18035ce6d7ebc4244b2cb1f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:54 +0100 Subject: [PATCH 1164/1519] staging: et131x: Remove et131x_check_mii() and move functionality into et131x_adjust_link() et131x_check_mii() is now only being called from et131x_adjust_link. Removed this call and associated subroutines, putting the functionality directly into et131x_adjust_link(), in preparation for further simplification. Changed register checks from bare BMSR checks to use phydev/netif versions, also now uses adapter->link to track link state changes. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 167 ------------------------ drivers/staging/et131x/et131x_initpci.c | 115 +++++++++++++--- 2 files changed, 98 insertions(+), 184 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index c4bc41dd185..fc37b185737 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -298,68 +298,6 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) et131x_mii_write(adapter, MII_BMCR, data); } -/** - * et1310_phy_link_status - read link state - * @adapter: device to read - * @link_status: reported link state - * @autoneg: reported autonegotiation state (complete/incomplete/disabled) - * @linkspeed: returnedlink speed in use - * @duplex_mode: reported half/full duplex state - * @mdi_mdix: not yet working - * @masterslave: report whether we are master or slave - * @polarity: link polarity - * - * I can read your lan like a magazine - * I see if your up - * I know your link speed - * I see all the setting that you'd rather keep - */ -static void et1310_phy_link_status(struct et131x_adapter *adapter, - u8 *link_status, - u32 *autoneg, - u32 *linkspeed, - u32 *duplex_mode, - u32 *mdi_mdix, - u32 *masterslave, u32 *polarity) -{ - u16 mistatus = 0; - u16 is1000BaseT = 0; - u16 vmi_phystatus = 0; - u16 control = 0; - - et131x_mii_read(adapter, MII_BMSR, &mistatus); - et131x_mii_read(adapter, MII_STAT1000, &is1000BaseT); - et131x_mii_read(adapter, PHY_PHY_STATUS, &vmi_phystatus); - et131x_mii_read(adapter, MII_BMCR, &control); - - *link_status = (vmi_phystatus & ET_PHY_LSTATUS) ? 1 : 0; - *autoneg = (control & ET_PHY_AUTONEG_STATUS) ? - ((vmi_phystatus & ET_PHY_AUTONEG_ENABLE) ? - TRUEPHY_ANEG_COMPLETE : - TRUEPHY_ANEG_NOT_COMPLETE) : - TRUEPHY_ANEG_DISABLED; - *linkspeed = (vmi_phystatus & ET_PHY_SPEED_STATUS) >> 8; - *duplex_mode = (vmi_phystatus & ET_PHY_DUPLEX_STATUS) >> 7; - /* NOTE: Need to complete this */ - *mdi_mdix = 0; - - *masterslave = (is1000BaseT & ET_1000BT_MSTR_SLV) ? - TRUEPHY_CFG_MASTER : TRUEPHY_CFG_SLAVE; - *polarity = (vmi_phystatus & ET_PHY_POLARITY_STATUS) ? - TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL; -} - -static void et1310_phy_and_or_reg(struct et131x_adapter *adapter, - u16 regnum, u16 and_mask, u16 or_mask) -{ - u16 reg; - - et131x_mii_read(adapter, regnum, ®); - reg &= and_mask; - reg |= or_mask; - et131x_mii_write(adapter, regnum, reg); -} - /* Still used from _mac for BIT_READ */ void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, u16 regnum, u16 bitnum, u8 *value) @@ -437,108 +375,3 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) } } -void et131x_mii_check(struct et131x_adapter *adapter, - u16 bmsr, u16 bmsr_ints) -{ - struct phy_device *phydev = adapter->phydev; - u8 link_status; - u32 autoneg_status; - u32 speed; - u32 duplex; - u32 mdi_mdix; - u32 masterslave; - u32 polarity; - - if (bmsr_ints & BMSR_LSTATUS) { - if (bmsr & BMSR_LSTATUS) { - adapter->boot_coma = 20; - } else { - dev_warn(&adapter->pdev->dev, - "Link down - cable problem ?\n"); - - if (phydev && phydev->speed == SPEED_10) { - /* NOTE - Is there a way to query this without - * TruePHY? - * && TRU_QueryCoreType(adapter->hTruePhy, 0) == - * EMI_TRUEPHY_A13O) { - */ - u16 register18; - - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - ®ister18); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18 | 0x4); - et131x_mii_write(adapter, PHY_INDEX_REG, - register18 | 0x8402); - et131x_mii_write(adapter, PHY_DATA_REG, - register18 | 511); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18); - } - - /* Free the packets being actively sent & stopped */ - et131x_free_busy_send_packets(adapter); - - /* Re-initialize the send structures */ - et131x_init_send(adapter); - - /* Reset the RFD list and re-start RU */ - et131x_reset_recv(adapter); - - /* - * Bring the device back to the state it was during - * init prior to autonegotiation being complete. This - * way, when we get the auto-neg complete interrupt, - * we can complete init by calling config_mac_regs2. - */ - et131x_soft_reset(adapter); - - /* Setup ET1310 as per the documentation */ - et131x_adapter_setup(adapter); - } - } - - if (bmsr_ints & BMSR_ANEGCOMPLETE) { - if (bmsr & BMSR_ANEGCOMPLETE) { - et1310_phy_link_status(adapter, - &link_status, &autoneg_status, - &speed, &duplex, &mdi_mdix, - &masterslave, &polarity); - - adapter->boot_coma = 20; - - if (phydev && phydev->speed == SPEED_10) { - /* - * NOTE - Is there a way to query this without - * TruePHY? - * && TRU_QueryCoreType(adapter->hTruePhy, 0)== - * EMI_TRUEPHY_A13O) { - */ - u16 register18; - - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - ®ister18); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18 | 0x4); - et131x_mii_write(adapter, PHY_INDEX_REG, - register18 | 0x8402); - et131x_mii_write(adapter, PHY_DATA_REG, - register18 | 511); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18); - } - - et1310_config_flow_control(adapter); - - if (phydev && phydev->speed == SPEED_1000 && - adapter->registry_jumbo_packet > 2048) - et1310_phy_and_or_reg(adapter, PHY_CONFIG, - ~ET_PHY_CONFIG_TX_FIFO_DEPTH, - ET_PHY_CONFIG_FIFO_DEPTH_32); - - et131x_set_rx_dma_timer(adapter); - et1310_config_mac_regs2(adapter); - } - } -} - diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 799aad68547..618f84428a0 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -446,29 +446,110 @@ static void et131x_adjust_link(struct net_device *netdev) struct address_map __iomem *iomem = adapter->regs; u32 pm_csr; - u16 bmsr_ints; - u16 bmsr_data; - /* If we are in coma mode, we need to disable it. */ - pm_csr = readl(&iomem->global.pm_csr); - if (pm_csr & ET_PM_PHY_SW_COMA) { - /* - * Check to see if we are in coma mode and if - * so, disable it because we will not be able - * to read PHY values until we are out. - */ - et1310_disable_phy_coma(adapter); + if (netif_carrier_ok(netdev)) { + adapter->boot_coma = 20; + + if (phydev && phydev->speed == SPEED_10) { + /* + * NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(adapter->hTruePhy, 0)== + * EMI_TRUEPHY_A13O) { + */ + u16 register18; + + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18 | 0x4); + et131x_mii_write(adapter, PHY_INDEX_REG, + register18 | 0x8402); + et131x_mii_write(adapter, PHY_DATA_REG, + register18 | 511); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); + } + + et1310_config_flow_control(adapter); + + if (phydev && phydev->speed == SPEED_1000 && + adapter->registry_jumbo_packet > 2048) { + u16 reg; + + et131x_mii_read(adapter, PHY_CONFIG, ®); + reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; + reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; + et131x_mii_write(adapter, PHY_CONFIG, reg); + } + + et131x_set_rx_dma_timer(adapter); + et1310_config_mac_regs2(adapter); } - et131x_phy_mii_read(adapter, phydev->addr, MII_BMSR, &bmsr_data); + if (phydev->link != adapter->link) { + /* If we are in coma mode, we need to disable it. */ + pm_csr = readl(&iomem->global.pm_csr); + if (pm_csr & ET_PM_PHY_SW_COMA) { + /* + * Check to see if we are in coma mode and if + * so, disable it because we will not be able + * to read PHY values until we are out. + */ + et1310_disable_phy_coma(adapter); + } - bmsr_ints = adapter->bmsr ^ bmsr_data; - adapter->bmsr = bmsr_data; + if (phydev->link) { + adapter->boot_coma = 20; + } else { + dev_warn(&adapter->pdev->dev, + "Link down - cable problem ?\n"); - /* Do all the cable in / cable out stuff */ - et131x_mii_check(adapter, bmsr_data, bmsr_ints); + if (phydev && phydev->speed == SPEED_10) { + /* NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(adapter->hTruePhy, 0) == + * EMI_TRUEPHY_A13O) + */ + u16 register18; - phy_print_status(phydev); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18 | 0x4); + et131x_mii_write(adapter, PHY_INDEX_REG, + register18 | 0x8402); + et131x_mii_write(adapter, PHY_DATA_REG, + register18 | 511); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); + } + + /* Free the packets being actively sent & stopped */ + et131x_free_busy_send_packets(adapter); + + /* Re-initialize the send structures */ + et131x_init_send(adapter); + + /* Reset the RFD list and re-start RU */ + et131x_reset_recv(adapter); + + /* + * Bring the device back to the state it was during + * init prior to autonegotiation being complete. This + * way, when we get the auto-neg complete interrupt, + * we can complete init by calling config_mac_regs2. + */ + et131x_soft_reset(adapter); + + /* Setup ET1310 as per the documentation */ + et131x_adapter_setup(adapter); + } + + adapter->link = phydev->link; + + phy_print_status(phydev); + } } int et131x_mii_probe(struct net_device *netdev) From 7fabca4d9183a449676648b93307e29299595866 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:55 +0100 Subject: [PATCH 1165/1519] staging: et131x: Create et131x_[dis|en]able_txrx() calls In et131x_netdev.c, a series of calls to enable and diasble the rx/tx engine and queue are being used in several different places. Create two functions to encapsulate these calls, and replace many calls with just the one. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.h | 2 + drivers/staging/et131x/et131x_netdev.c | 126 ++++++++++--------------- 2 files changed, 50 insertions(+), 78 deletions(-) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index f52fa182987..6f8fef61244 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -83,6 +83,8 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ struct net_device *et131x_device_alloc(void); +void et131x_enable_txrx(struct net_device *netdev); +void et131x_disable_txrx(struct net_device *netdev); /* et1310_pm.c */ void et1310_enable_phy_coma(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 5fb40560c15..6ec4a0f2919 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -136,6 +136,45 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev) return stats; } +/** + * et131x_enable_txrx - Enable tx/rx queues + * @netdev: device to be enabled + */ +void et131x_enable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Enable the Tx and Rx DMA engines (if not already enabled) */ + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + + /* Enable device interrupts */ + if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) + et131x_enable_interrupts(adapter); + + /* We're ready to move some data, so start the queue */ + netif_start_queue(netdev); +} + +/** + * et131x_disable_txrx - Disable tx/rx queues + * @netdev: device to be disabled + */ +void et131x_disable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* First thing is to stop the queue */ + netif_stop_queue(netdev); + + /* Stop the Tx and Rx DMA engines */ + et131x_rx_dma_disable(adapter); + et131x_tx_dma_disable(adapter); + + /* Disable device interrupts */ + et131x_disable_interrupts(adapter); +} + /** * et131x_open - Open the device for use. * @netdev: device to be opened @@ -159,19 +198,10 @@ int et131x_open(struct net_device *netdev) return result; } - /* Enable the Tx and Rx DMA engines (if not already enabled) */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - et131x_enable_interrupts(adapter); - adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; - + et131x_enable_txrx(netdev); phy_start(adapter->phydev); - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); return result; } @@ -188,15 +218,7 @@ int et131x_close(struct net_device *netdev) /* Save the timestamp for the TX watchdog, prevent a timeout */ netdev->trans_start = jiffies; - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); /* Deregistering ISR */ adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; @@ -442,29 +464,9 @@ void et131x_tx_timeout(struct net_device *netdev) adapter->net_stats.tx_errors++; - /* perform reset */ - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); - - /* - * Enable the Tx and Rx DMA engines - * (if not already enabled) - */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - et131x_enable_interrupts(adapter); - - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); + /* perform reset of tx/rx */ + et131x_disable_txrx(netdev); + et131x_enable_txrx(netdev); return; } } @@ -488,15 +490,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) if (new_mtu < 64 || new_mtu > 9216) return -EINVAL; - /* Stop the netif queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); et131x_handle_send_interrupt(adapter); et131x_handle_recv_interrupt(adapter); @@ -526,16 +520,8 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) /* Init the device with the new settings */ et131x_adapter_setup(adapter); - /* Enable interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); + et131x_enable_txrx(netdev); - /* Restart the Tx and Rx DMA engines */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Restart the netif queue */ - netif_wake_queue(netdev); return result; } @@ -563,15 +549,7 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) if (!is_valid_ether_addr(address->sa_data)) return -EINVAL; - /* Stop the netif queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); et131x_handle_send_interrupt(adapter); et131x_handle_recv_interrupt(adapter); @@ -603,16 +581,8 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) /* Init the device with the new settings */ et131x_adapter_setup(adapter); - /* Enable interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); + et131x_enable_txrx(netdev); - /* Restart the Tx and Rx DMA engines */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Restart the netif queue */ - netif_wake_queue(netdev); return result; } From 2c2815aee78fc992872617eaeb283e6f164d126a Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:56 +0100 Subject: [PATCH 1166/1519] staging: et131x: Remove header declaration of et131x_check_mii() et131x_check_mii no longer exists, remove its declaration from the header file Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 6f8fef61244..c047e6e2850 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -107,8 +107,6 @@ int32_t et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value); int32_t et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value); -void et131x_mii_check(struct et131x_adapter *adapter, - u16 bmsr, u16 bmsr_ints); int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg); int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value); From c28a613316c8b02d4ae4ac1a2548a363b019ae77 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 25 Sep 2011 19:17:57 +0100 Subject: [PATCH 1167/1519] staging: et131x: Bugfix - driver doesn't autoreneg after cable unplug/plug events This driver has a long standing bug where removing and inserting the ethernet cable results in no packets being trnasmitted / received and hence no autonegotiation occurring. Fixed by resetting the rx/tx engines and queue on detecting a cable being removed. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_initpci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 618f84428a0..e9daa733bea 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -544,6 +544,10 @@ static void et131x_adjust_link(struct net_device *netdev) /* Setup ET1310 as per the documentation */ et131x_adapter_setup(adapter); + + /* perform reset of tx/rx */ + et131x_disable_txrx(netdev); + et131x_enable_txrx(netdev); } adapter->link = phydev->link; From 43664e14a029ab458cba8af43c65853b079b282f Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Fri, 23 Sep 2011 00:20:09 -0300 Subject: [PATCH 1168/1519] drivers/staging/bcm/InterfaceDld.c: Fix checkpatch warnings In the source file there are a lot of warnings. I will send it in parts to be more easy to review. All the changes in this file its just alignment, and things like that. Signed-off-by: Marcos Paulo de Souza Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceDld.c | 93 +++++++++++++++--------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index df64acb0612..bf6cc6a414b 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -1,62 +1,61 @@ #include "headers.h" - -int InterfaceFileDownload( PVOID arg, - struct file *flp, - unsigned int on_chip_loc) +int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) { - // unsigned int reg=0; - mm_segment_t oldfs={0}; - int errno=0, len=0 /*,is_config_file = 0*/; - loff_t pos=0; + /*unsigned int reg = 0;*/ + mm_segment_t oldfs = {0}; + int errno = 0, len = 0; /*,is_config_file = 0*/ + loff_t pos = 0; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; - //PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; - char *buff=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); + /*PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;*/ + char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - if(!buff) - { - return -ENOMEM; - } - while(1) - { - oldfs=get_fs(); set_fs(get_ds()); - len=vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); - set_fs(oldfs); - if(len<=0) - { - if(len<0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); - errno=len; - } - else - { - errno = 0; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); - } - break; - } - //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, buff, MAX_TRANSFER_CTRL_BYTE_USB); - errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len) ; - if(errno) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed! status: %d", errno); + if (!buff) + return -ENOMEM; + + while (1) { + oldfs = get_fs(); + set_fs(get_ds()); + len = vfs_read(flp, (void __force __user *)buff, + MAX_TRANSFER_CTRL_BYTE_USB, &pos); + set_fs(oldfs); + if (len <= 0) { + if (len < 0) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, MP_INIT, + DBG_LVL_ALL, "len < 0"); + errno = len; + } else { + errno = 0; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, MP_INIT, + DBG_LVL_ALL, + "Got end of file!"); + } break; - } - on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; - }/* End of for(;;)*/ + /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, + DBG_LVL_ALL, buff, + MAX_TRANSFER_CTRL_BYTE_USB);*/ + errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len); + if (errno) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_PRINTK, 0, 0, + "WRM Failed! status: %d", errno); + break; + } + on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB; + } kfree(buff); - return errno; + return errno; } -int InterfaceFileReadbackFromChip( PVOID arg, - struct file *flp, - unsigned int on_chip_loc) +int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, + unsigned int on_chip_loc) { - char *buff, *buff_readback; - unsigned int reg=0; + char *buff, *buff_readback; + unsigned int reg = 0; mm_segment_t oldfs={0}; int errno=0, len=0, is_config_file = 0; loff_t pos=0; From de0920b1fedb4d694fe4732cfc3cccfcd4743f84 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 23 Sep 2011 09:23:22 +0300 Subject: [PATCH 1169/1519] Staging: vt6655-6: potential info leak in private_ioctl() Smatch has a new check for Rosenberg type information leaks where structs are copied to the user with uninitialized stack data in them. In this path, the .uLinkRate member doesn't get initialized so I've set it to zero. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 1 + drivers/staging/vt6656/ioctl.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 8cf88c3b68d..43964a5e72a 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -296,6 +296,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { } else { sLinkStatus.bLink = false; + sLinkStatus.uLinkRate = 0; } if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { result = -EFAULT; diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c index cfe9c95d780..1cb9a7d0d88 100644 --- a/drivers/staging/vt6656/ioctl.c +++ b/drivers/staging/vt6656/ioctl.c @@ -291,6 +291,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { } else { sLinkStatus.bLink = FALSE; + sLinkStatus.uLinkRate = 0; } if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { result = -EFAULT; From bcd9a1e91fbc293bbbbddd98df687ad2e8027c89 Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn Date: Sun, 25 Sep 2011 06:49:12 +0200 Subject: [PATCH 1170/1519] staging: comedi: Added log subjects to printk()s in pcmmio Added log subject to printk()s in drivers/staging/comedi/drivers/pcmmio.c. Signed-off-by: Johannes Thumshirn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index f2e88e57d55..3ad04aaa1e3 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -371,7 +371,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) iobase = it->options[0]; irq[0] = it->options[1]; - printk("comedi%d: %s: io: %lx ", dev->minor, driver.driver_name, + printk(KERN_INFO "comedi%d: %s: io: %lx ", dev->minor, driver.driver_name, iobase); dev->iobase = iobase; @@ -379,7 +379,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!iobase || !request_region(iobase, thisboard->total_iosize, driver.driver_name)) { - printk("I/O port conflict\n"); + printk(KERN_ERR "I/O port conflict\n"); return -EIO; } @@ -394,7 +394,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) * convenient macro defined in comedidev.h. */ if (alloc_private(dev, sizeof(struct pcmmio_private)) < 0) { - printk("cannot allocate private data structure\n"); + printk(KERN_ERR "cannot allocate private data structure\n"); return -ENOMEM; } @@ -417,7 +417,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) kcalloc(n_subdevs, sizeof(struct pcmmio_subdev_private), GFP_KERNEL); if (!devpriv->sprivs) { - printk("cannot allocate subdevice private data structures\n"); + printk(KERN_ERR "cannot allocate subdevice private data structures\n"); return -ENOMEM; } /* @@ -427,7 +427,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) * Allocate 1 AI + 1 AO + 2 DIO subdevs (24 lines per DIO) */ if (alloc_subdevices(dev, n_subdevs) < 0) { - printk("cannot allocate subdevice data structures\n"); + printk(KERN_ERR "cannot allocate subdevice data structures\n"); return -ENOMEM; } @@ -557,14 +557,14 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) */ if (irq[0]) { - printk("irq: %u ", irq[0]); + printk(KERN_DEBUG "irq: %u ", irq[0]); if (thisboard->dio_num_asics == 2 && irq[1]) - printk("second ASIC irq: %u ", irq[1]); + printk(KERN_DEBUG "second ASIC irq: %u ", irq[1]); } else { - printk("(IRQ mode disabled) "); + printk(KERN_INFO "(IRQ mode disabled) "); } - printk("attached\n"); + printk(KERN_INFO "attached\n"); return 1; } @@ -581,7 +581,7 @@ static int pcmmio_detach(struct comedi_device *dev) { int i; - printk("comedi%d: %s: remove\n", dev->minor, driver.driver_name); + printk(KERN_INFO "comedi%d: %s: remove\n", dev->minor, driver.driver_name); if (dev->iobase) release_region(dev->iobase, thisboard->total_iosize); @@ -622,7 +622,7 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, #ifdef DAMMIT_ITS_BROKEN /* DEBUG */ - printk("write mask: %08x data: %08x\n", data[0], data[1]); + printk(KERN_DEBUG "write mask: %08x data: %08x\n", data[0], data[1]); #endif s->state = 0; @@ -644,9 +644,9 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, #ifdef DAMMIT_ITS_BROKEN /* DEBUG */ printk - ("byte %d wmb %02x db %02x offset %02d io %04x, data_in %02x ", - byte_no, (unsigned)write_mask_byte, (unsigned)data_byte, - offset, ioaddr, (unsigned)byte); + (KERN_DEBUG "byte %d wmb %02x db %02x offset %02d io %04x," + " data_in %02x ", byte_no, (unsigned)write_mask_byte, + (unsigned)data_byte, offset, ioaddr, (unsigned)byte); #endif if (write_mask_byte) { @@ -663,7 +663,7 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, } #ifdef DAMMIT_ITS_BROKEN /* DEBUG */ - printk("data_out_byte %02x\n", (unsigned)byte); + printk(KERN_DEBUG "data_out_byte %02x\n", (unsigned)byte); #endif /* save the digital input lines for this byte.. */ s->state |= ((unsigned int)byte) << offset; @@ -674,7 +674,7 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, #ifdef DAMMIT_ITS_BROKEN /* DEBUG */ - printk("s->state %08x data_out %08x\n", s->state, data[1]); + printk(KERN_DEBUG "s->state %08x data_out %08x\n", s->state, data[1]); #endif return 2; @@ -886,7 +886,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d) * with commands.. */ printk - ("PCMMIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n", + (KERN_DEBUG "got edge detect interrupt %d asic %d which_chans: %06x\n", irq, asic, triggered); for (s = dev->subdevices + 2; s < dev->subdevices + dev->n_subdevices; From 589cabe1b13576b85419d73ba87e50f7f80463fb Mon Sep 17 00:00:00 2001 From: Christopher Rice Date: Fri, 23 Sep 2011 16:53:09 -0700 Subject: [PATCH 1171/1519] drivers:staging:comedi:drivers:cb_das_cs.c codeing style issue drivers: staging: comedi: cb_das16_cs.c fixed over 80 line issue, and removed a space before tab issue. Signed-off-by: Christopher Rice Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_das16_cs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 8a1b8a7fa15..e171c56112d 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -370,7 +370,8 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* step 2: make sure trigger sources are unique and + * mutually compatible */ /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && @@ -508,7 +509,7 @@ static int das16cs_ao_winsn(struct comedi_device *dev, else status1 |= 0x0008; -/* printk("0x%04x\n",status1);*/ +/* printk("0x%04x\n",status1);*/ outw(status1, dev->iobase + 4); udelay(1); From 870634604e23e6ba011d17e9b10ab8f8ccc4f768 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 25 Sep 2011 08:30:18 +0100 Subject: [PATCH 1172/1519] staging: wlags49_h2: Fixup WEXT capabilities Add recently added events to the capabilities reported in iw_range. Use capability macros instead of assuming the array offsets. Explicitly list scan capabilities. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 917c949fe59..80bd938bfc0 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -523,15 +523,17 @@ retry: DBG_TRACE( DbgInfo, "wl_wireless_stats done\n" ); /* Event capability (kernel + driver) */ - range->event_capa[0] = (IW_EVENT_CAPA_K_0 | - IW_EVENT_CAPA_MASK(SIOCGIWAP) | - IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); - range->event_capa[1] = IW_EVENT_CAPA_K_1; - range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVREGISTERED) | - IW_EVENT_CAPA_MASK(IWEVCUSTOM) | - IW_EVENT_CAPA_MASK(IWEVEXPIRED)); + IW_EVENT_CAPA_SET_KERNEL(range->event_capa); + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); + IW_EVENT_CAPA_SET(range->event_capa, IWEVREGISTERED); + IW_EVENT_CAPA_SET(range->event_capa, IWEVEXPIRED); + IW_EVENT_CAPA_SET(range->event_capa, IWEVMICHAELMICFAILURE); + IW_EVENT_CAPA_SET(range->event_capa, IWEVASSOCREQIE); + IW_EVENT_CAPA_SET(range->event_capa, IWEVASSOCRESPIE); range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP; + range->scan_capa = IW_SCAN_CAPA_NONE; out_unlock: wl_act_int_on( lp ); From 145a401fc43fa82cf1aad55bc35a7f6c5bbd1ecb Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 25 Sep 2011 08:30:20 +0100 Subject: [PATCH 1173/1519] staging: wlags49_h2: Declare support for WEXT 21 WEXT changes between versions 15 and 21 have been taken care of, so update the declared support. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_version.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlags49_h2/wl_version.h b/drivers/staging/wlags49_h2/wl_version.h index 55e93cdc1f1..fd37040afd0 100644 --- a/drivers/staging/wlags49_h2/wl_version.h +++ b/drivers/staging/wlags49_h2/wl_version.h @@ -143,7 +143,8 @@ err: define bus type; " for " BUS_TYPE ", " \ MODULE_DATE " by " VENDOR_NAME -#define WIRELESS_SUPPORT 15 // The version of wireless extensions we support +/* The version of wireless extensions we support */ +#define WIRELESS_SUPPORT 21 //#define DBG_MOD_NAME DRIVER_NAME ":" BUS_TYPE ":" HW_TYPE ":" FW_TYPE #define DBG_MOD_NAME MODULE_NAME From e7751b6384596cc9a2646f037a03ad57f6201f6d Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 25 Sep 2011 08:30:19 +0100 Subject: [PATCH 1174/1519] staging: wlags49_h2: Stop playing with length in GIWESSID handler WE21 clarified that ESSID should not be NULL terminated. The existing code didn't NULL terminate, but did play with length and then reset it again. Just stop it. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 80bd938bfc0..1f6b4dce438 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -1042,9 +1042,6 @@ static int wireless_get_essid(struct net_device *dev, struct iw_request_info *in /* Copy the information into the user buffer */ data->length = pName->length; - /* NOTE: Null terminating is necessary for proper display of the SSID in - the wireless tools */ - data->length = pName->length + 1; if( pName->length < HCF_MAX_NAME_LEN ) { pName->name[pName->length] = '\0'; } @@ -1070,11 +1067,7 @@ static int wireless_get_essid(struct net_device *dev, struct iw_request_info *in pName->length = CNV_LITTLE_TO_INT( pName->length ); /* Copy the information into the user buffer */ - data->length = pName->length + 1; - if( pName->length < HCF_MAX_NAME_LEN ) { - pName->name[pName->length] = '\0'; - } - + data->length = pName->length; data->flags = 1; } else { ret = -EFAULT; @@ -1084,8 +1077,6 @@ static int wireless_get_essid(struct net_device *dev, struct iw_request_info *in #endif // HCF_STA - data->length--; - if (pName->length > IW_ESSID_MAX_SIZE) { ret = -EFAULT; goto out_unlock; From bc79be9b384a8189a3b0f9ec9bba7193ede32f43 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 25 Sep 2011 08:30:21 +0100 Subject: [PATCH 1175/1519] staging: wlags49_h2: Use IW_HANDLER macro to declare wireless handlers. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 89 ++++++++++------------------ 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 1f6b4dce438..764a3208afd 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -3904,66 +3904,39 @@ void wl_wext_event_assoc_ie( struct net_device *dev ) static const iw_handler wl_handler[] = { - (iw_handler) wireless_commit, /* SIOCSIWCOMMIT */ - (iw_handler) wireless_get_protocol, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) wireless_set_frequency, /* SIOCSIWFREQ */ - (iw_handler) wireless_get_frequency, /* SIOCGIWFREQ */ - (iw_handler) wireless_set_porttype, /* SIOCSIWMODE */ - (iw_handler) wireless_get_porttype, /* SIOCGIWMODE */ - (iw_handler) wireless_set_sensitivity, /* SIOCSIWSENS */ - (iw_handler) wireless_get_sensitivity, /* SIOCGIWSENS */ - (iw_handler) NULL , /* SIOCSIWRANGE */ - (iw_handler) wireless_get_range, /* SIOCGIWRANGE */ - (iw_handler) NULL , /* SIOCSIWPRIV */ - (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ - (iw_handler) NULL , /* SIOCSIWSTATS */ - (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */ - iw_handler_set_spy, /* SIOCSIWSPY */ - iw_handler_get_spy, /* SIOCGIWSPY */ - NULL, /* SIOCSIWTHRSPY */ - NULL, /* SIOCGIWTHRSPY */ - (iw_handler) NULL, /* SIOCSIWAP */ + IW_HANDLER(SIOCSIWCOMMIT, (iw_handler) wireless_commit), + IW_HANDLER(SIOCGIWNAME, (iw_handler) wireless_get_protocol), + IW_HANDLER(SIOCSIWFREQ, (iw_handler) wireless_set_frequency), + IW_HANDLER(SIOCGIWFREQ, (iw_handler) wireless_get_frequency), + IW_HANDLER(SIOCSIWMODE, (iw_handler) wireless_set_porttype), + IW_HANDLER(SIOCGIWMODE, (iw_handler) wireless_get_porttype), + IW_HANDLER(SIOCSIWSENS, (iw_handler) wireless_set_sensitivity), + IW_HANDLER(SIOCGIWSENS, (iw_handler) wireless_get_sensitivity), + IW_HANDLER(SIOCGIWRANGE, (iw_handler) wireless_get_range), + IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), + IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA - (iw_handler) wireless_get_bssid, /* SIOCGIWAP */ -#else - (iw_handler) NULL, /* SIOCGIWAP */ + IW_HANDLER(SIOCGIWAP, (iw_handler) wireless_get_bssid), #endif - (iw_handler) NULL, /* SIOCSIWMLME */ - (iw_handler) wireless_get_ap_list, /* SIOCGIWAPLIST */ - (iw_handler) wireless_set_scan, /* SIOCSIWSCAN */ - (iw_handler) wireless_get_scan, /* SIOCGIWSCAN */ - (iw_handler) wireless_set_essid, /* SIOCSIWESSID */ - (iw_handler) wireless_get_essid, /* SIOCGIWESSID */ - (iw_handler) wireless_set_nickname, /* SIOCSIWNICKN */ - (iw_handler) wireless_get_nickname, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) wireless_set_rate, /* SIOCSIWRATE */ - (iw_handler) wireless_get_rate, /* SIOCGIWRATE */ - (iw_handler) wireless_set_rts_threshold,/* SIOCSIWRTS */ - (iw_handler) wireless_get_rts_threshold,/* SIOCGIWRTS */ - (iw_handler) NULL, /* SIOCSIWFRAG */ - (iw_handler) NULL, /* SIOCGIWFRAG */ - (iw_handler) NULL, /* SIOCSIWTXPOW */ - (iw_handler) wireless_get_tx_power, /* SIOCGIWTXPOW */ - (iw_handler) NULL, /* SIOCSIWRETRY */ - (iw_handler) NULL, /* SIOCGIWRETRY */ - (iw_handler) wireless_set_encode, /* SIOCSIWENCODE */ - (iw_handler) wireless_get_encode, /* SIOCGIWENCODE */ - (iw_handler) wireless_set_power, /* SIOCSIWPOWER */ - (iw_handler) wireless_get_power, /* SIOCGIWPOWER */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) wireless_get_genie, /* SIOCSIWGENIE */ - (iw_handler) NULL, /* SIOCGIWGENIE */ - (iw_handler) wireless_set_auth, /* SIOCSIWAUTH */ - (iw_handler) NULL, /* SIOCGIWAUTH */ - (iw_handler) wireless_set_encodeext, /* SIOCSIWENCODEEXT */ - (iw_handler) NULL, /* SIOCGIWENCODEEXT */ - (iw_handler) NULL, /* SIOCSIWPMKSA */ - (iw_handler) NULL, /* -- hole -- */ + IW_HANDLER(SIOCGIWAPLIST, (iw_handler) wireless_get_ap_list), + IW_HANDLER(SIOCSIWSCAN, (iw_handler) wireless_set_scan), + IW_HANDLER(SIOCGIWSCAN, (iw_handler) wireless_get_scan), + IW_HANDLER(SIOCSIWESSID, (iw_handler) wireless_set_essid), + IW_HANDLER(SIOCGIWESSID, (iw_handler) wireless_get_essid), + IW_HANDLER(SIOCSIWNICKN, (iw_handler) wireless_set_nickname), + IW_HANDLER(SIOCGIWNICKN, (iw_handler) wireless_get_nickname), + IW_HANDLER(SIOCSIWRATE, (iw_handler) wireless_set_rate), + IW_HANDLER(SIOCGIWRATE, (iw_handler) wireless_get_rate), + IW_HANDLER(SIOCSIWRTS, (iw_handler) wireless_set_rts_threshold), + IW_HANDLER(SIOCGIWRTS, (iw_handler) wireless_get_rts_threshold), + IW_HANDLER(SIOCGIWTXPOW, (iw_handler) wireless_get_tx_power), + IW_HANDLER(SIOCSIWENCODE, (iw_handler) wireless_set_encode), + IW_HANDLER(SIOCGIWENCODE, (iw_handler) wireless_get_encode), + IW_HANDLER(SIOCSIWPOWER, (iw_handler) wireless_set_power), + IW_HANDLER(SIOCGIWPOWER, (iw_handler) wireless_get_power), + IW_HANDLER(SIOCSIWGENIE, (iw_handler) wireless_get_genie), + IW_HANDLER(SIOCSIWAUTH, (iw_handler) wireless_set_auth), + IW_HANDLER(SIOCSIWENCODEEXT, (iw_handler) wireless_set_encodeext), }; static const iw_handler wl_private_handler[] = From 6519ad6e6f92a4310fbaab50f074d5bbad27b329 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 22 Sep 2011 12:40:50 -0700 Subject: [PATCH 1176/1519] Staging: hv: Update the TODO file Now that all vmbus audit related comments have been addressed, update the TODO file to reflect this. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/TODO | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO index 7c9a93fd30e..fcc57c24580 100644 --- a/drivers/staging/hv/TODO +++ b/drivers/staging/hv/TODO @@ -1,6 +1,4 @@ TODO: - - audit the vmbus to verify it is working properly with the - driver model - audit the network driver - checking for carrier inside open is wrong, network device API confusion?? From 6835cb6b438b77ba82ad5a23944bbfb12128f5db Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 27 Sep 2011 09:56:41 +0100 Subject: [PATCH 1177/1519] staging:iio: unwind the IIO_IN -> IIO_VOLTAGE define This was originally there to avoid churn during a complex change. Now everything is stable lets get rid of this as it is missleading and confusing. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 6 +- drivers/staging/iio/accel/adis16203_core.c | 6 +- drivers/staging/iio/accel/adis16204_core.c | 6 +- drivers/staging/iio/accel/adis16209_core.c | 6 +- drivers/staging/iio/accel/adis16220_core.c | 8 +- drivers/staging/iio/accel/adis16240_core.c | 6 +- drivers/staging/iio/accel/kxsd9.c | 2 +- drivers/staging/iio/adc/ad7150.c | 8 +- drivers/staging/iio/adc/ad7291.c | 4 +- drivers/staging/iio/adc/ad7298_core.c | 16 ++-- drivers/staging/iio/adc/ad7476_core.c | 16 ++-- drivers/staging/iio/adc/ad7606_core.c | 36 ++++----- drivers/staging/iio/adc/ad7780.c | 4 +- drivers/staging/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7887_core.c | 4 +- drivers/staging/iio/adc/ad799x_core.c | 80 +++++++++---------- drivers/staging/iio/adc/max1363_core.c | 24 ++++-- drivers/staging/iio/addac/adt7316.c | 8 +- drivers/staging/iio/gyro/adis16060_core.c | 4 +- drivers/staging/iio/gyro/adis16080_core.c | 4 +- drivers/staging/iio/gyro/adis16260_core.c | 6 +- drivers/staging/iio/iio.h | 4 - .../staging/iio/impedance-analyzer/ad5933.c | 4 +- drivers/staging/iio/imu/adis16400_core.c | 8 +- drivers/staging/iio/meter/ade7758_core.c | 6 +- 25 files changed, 141 insertions(+), 137 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index e5364b74ac4..d7ec5052905 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -325,7 +325,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case (1 << IIO_CHAN_INFO_SCALE_SHARED): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 1220; @@ -407,7 +407,7 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16201_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_supply, ADIS16201_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0), @@ -426,7 +426,7 @@ static struct iio_chan_spec adis16201_channels[] = { (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), accel_y, ADIS16201_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_aux, ADIS16201_SCAN_AUX_ADC, IIO_ST('u', 12, 16, 0), 0), diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 34975dc16e4..2ffcf4ed3dd 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -332,7 +332,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case (1 << IIO_CHAN_INFO_SCALE_SHARED): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 1220; @@ -373,11 +373,11 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16203_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_supply, ADIS16203_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_aux, ADIS16203_SCAN_AUX_ADC, IIO_ST('u', 12, 16, 0), 0), diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 7a4c680722d..2ca617d31bd 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -369,7 +369,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 1220; @@ -445,11 +445,11 @@ static int adis16204_write_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16204_channels[] = { - IIO_CHAN(IIO_IN, 0, 0, 0, "supply", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 0, 0, "supply", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_supply, ADIS16204_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_aux, ADIS16204_SCAN_AUX_ADC, IIO_ST('u', 12, 16, 0), 0), diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 1824e729153..d03ac01c8d5 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -358,7 +358,7 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case (1 << IIO_CHAN_INFO_SCALE_SHARED): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 305180; @@ -409,7 +409,7 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16209_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_supply, ADIS16209_SCAN_SUPPLY, IIO_ST('u', 14, 16, 0), 0), @@ -428,7 +428,7 @@ static struct iio_chan_spec adis16209_channels[] = { (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), accel_y, ADIS16209_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_aux, ADIS16209_SCAN_AUX_ADC, IIO_ST('u', 12, 16, 0), 0), diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 18b0830b82f..15f5f301068 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -529,7 +529,7 @@ static int adis16220_read_raw(struct iio_dev *indio_dev, case IIO_ACCEL: *val2 = 1887042; return IIO_VAL_INT_PLUS_MICRO; - case IIO_IN: + case IIO_VOLTAGE: if (chan->channel == 0) *val2 = 0012221; else /* Should really be dependent on VDD */ @@ -571,7 +571,7 @@ static int adis16220_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec adis16220_channels[] = { { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, .extend_name = "supply", @@ -591,14 +591,14 @@ static const struct iio_chan_spec adis16220_channels[] = { (1 << IIO_CHAN_INFO_SCALE_SEPARATE), .address = temp, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | (1 << IIO_CHAN_INFO_SCALE_SEPARATE), .address = in_1, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, .address = in_2, diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 6d3194f2a52..ee1e873f177 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -392,7 +392,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case (1 << IIO_CHAN_INFO_SCALE_SHARED): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 4880; @@ -469,11 +469,11 @@ static int adis16240_write_raw(struct iio_dev *indio_dev, } static struct iio_chan_spec adis16240_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), in_supply, ADIS16240_SCAN_SUPPLY, IIO_ST('u', 10, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, 0, in_aux, ADIS16240_SCAN_AUX_ADC, IIO_ST('u', 10, 16, 0), 0), diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index 2a0565181d4..eeee808f7f0 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c @@ -188,7 +188,7 @@ error_ret: static struct iio_chan_spec kxsd9_channels[] = { KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z), { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .address = KXSD9_REG_AUX, } diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index d5102e5efda..89434205b6f 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -473,7 +473,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -481,7 +481,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), @@ -490,7 +490,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -498,7 +498,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index c486d72167b..ba3f19fb418 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -192,14 +192,14 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) { if (v_status & (1 << i)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i/2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (v_status & (1 << (i + 1))) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i/2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 7f08ffaa3d8..9ef310241bc 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -26,28 +26,28 @@ static struct iio_chan_spec ad7298_channels[] = { IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), 9, AD7298_CH_TEMP, IIO_ST('s', 32, 32, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 4, 4, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 5, 5, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 6, 6, IIO_ST('u', 12, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 7, 7, IIO_ST('u', 12, 16, 0), 0), IIO_CHAN_SOFT_TIMESTAMP(8), diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index ec75332e16c..9b050cefa44 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -68,49 +68,49 @@ static int ad7476_read_raw(struct iio_dev *dev_info, static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { [ID_AD7466] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7467] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 2), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7468] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1 , 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1 , 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 8, 16, 4), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7475] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7476] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7477] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 2), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7478] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 8, 16, 4), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, [ID_AD7495] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index c3ce74ccc18..17cdafbdc37 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -234,66 +234,66 @@ static const struct attribute_group ad7606_attribute_group = { }; static struct iio_chan_spec ad7606_8_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 4, 4, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 5, 5, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 6, 6, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 7, 7, IIO_ST('s', 16, 16, 0), 0), IIO_CHAN_SOFT_TIMESTAMP(8), }; static struct iio_chan_spec ad7606_6_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 4, 4, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 5, 5, IIO_ST('s', 16, 16, 0), 0), IIO_CHAN_SOFT_TIMESTAMP(6), }; static struct iio_chan_spec ad7606_4_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('s', 16, 16, 0), 0), IIO_CHAN_SOFT_TIMESTAMP(4), diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 4b6f8c6640e..a8103c06e74 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -126,12 +126,12 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { [ID_AD7780] = { - .channel = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('s', 24, 32, 8), 0), }, [ID_AD7781] = { - .channel = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('s', 20, 32, 12), 0), }, diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 788ee086a4c..0a536c5ff36 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -674,7 +674,7 @@ static int ad7793_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): switch (chan->type) { - case IIO_IN: + case IIO_VOLTAGE: /* 1170mV / 2^23 * 6 */ scale_uv = (1170ULL * 100000000ULL * 6ULL) >> (chan->scan_type.realbits - diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 465d7155379..71af6cba763 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -71,11 +71,11 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { * More devices added in future */ [ID_AD7887] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index b8efd593018..b6662dbfbd9 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -336,11 +336,11 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) if (status & (1 << i)) iio_push_event(indio_dev, i & 0x1 ? - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, (i >> 1), IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) : - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, (i >> 1), IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), @@ -486,16 +486,16 @@ static const struct iio_info ad7993_4_7_8_info = { static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7991] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 12, 16, 0), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), @@ -504,16 +504,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7991_info, }, [ad7995] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 10, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 10, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 10, 16, 0), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), @@ -522,16 +522,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7991_info, }, [ad7999] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 10, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 10, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 10, 16, 0), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), @@ -540,10 +540,10 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7991_info, }, [ad7992] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), @@ -553,16 +553,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7992_info, }, [ad7993] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 10, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 10, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 10, 16, 0), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), @@ -572,16 +572,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7993_4_7_8_info, }, [ad7994] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 12, 16, 0), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), @@ -591,28 +591,28 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7993_4_7_8_info, }, [ad7997] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 10, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 10, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 10, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 10, 16, 0), 0), - .channel[4] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0, + .channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 4, 4, IIO_ST('u', 10, 16, 0), 0), - .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0, + .channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 5, 5, IIO_ST('u', 10, 16, 0), 0), - .channel[6] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0, + .channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 6, 6, IIO_ST('u', 10, 16, 0), 0), - .channel[7] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0, + .channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 7, 7, IIO_ST('u', 10, 16, 0), 0), .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), @@ -622,28 +622,28 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .info = &ad7993_4_7_8_info, }, [ad7998] = { - .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, + .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, + .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, + .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, + .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 3, 3, IIO_ST('u', 12, 16, 0), 0), - .channel[4] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0, + .channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 4, 4, IIO_ST('u', 12, 16, 0), 0), - .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0, + .channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 5, 5, IIO_ST('u', 12, 16, 0), 0), - .channel[6] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0, + .channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 6, 6, IIO_ST('u', 12, 16, 0), 0), - .channel[7] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0, + .channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), 7, 7, IIO_ST('u', 12, 16, 0), 0), .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 2abcc32c378..e962f8412d3 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -574,14 +574,22 @@ static int max1363_write_thresh(struct iio_dev *indio_dev, } static const u64 max1363_event_codes[] = { - IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, + IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), }; static irqreturn_t max1363_event_handler(int irq, void *private) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 17b6c1332ae..d37726e5bde 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1802,19 +1802,19 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) time); if (stat1 & (1 << 5)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, 1, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); if (stat1 & (1 << 6)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, 2, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); if (stat1 & (1 << 7)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, 3, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); @@ -1823,7 +1823,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) if (!ret) { if (stat2 & ADT7316_INT_MASK2_VDD) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_IN, + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 481080588b1..f8129916071 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -122,12 +122,12 @@ static const struct iio_chan_spec adis16060_channels[] = { .channel2 = IIO_MOD_Z, .address = ADIS16060_GYRO, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, .address = ADIS16060_AIN1, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .address = ADIS16060_AIN2, diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index 826f8f1db0d..a2ee9beda80 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -113,12 +113,12 @@ static const struct iio_chan_spec adis16080_channels[] = { .channel2 = IIO_MOD_Z, .address = ADIS16080_DIN_GYRO, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, .address = ADIS16080_DIN_AIN1, }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .address = ADIS16080_DIN_AIN2, diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 2ad43a871b0..efbee279384 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -405,11 +405,11 @@ enum adis16260_channel { (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ temp, ADIS16260_SCAN_TEMP, \ IIO_ST('u', 12, 16, 0), 0), \ - IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0, \ + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0, \ (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ in_supply, ADIS16260_SCAN_SUPPLY, \ IIO_ST('u', 12, 16, 0), 0), \ - IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, \ + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, \ (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ in_aux, ADIS16260_SCAN_AUX_ADC, \ IIO_ST('u', 12, 16, 0), 0), \ @@ -475,7 +475,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, else *val2 = 1278; return IIO_VAL_INT_PLUS_MICRO; - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 18315; diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 4851d6fb9eb..2a6c6731b3c 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -44,10 +44,6 @@ enum iio_chan_type { IIO_CAPACITANCE, }; -/* Nasty hack to avoid massive churn */ -#define IIO_IN IIO_VOLTAGE -#define IIO_IN_DIFF IIO_VOLTAGE_DIFF - enum iio_modifier { IIO_NO_MOD, IIO_MOD_X, diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 929da9b794c..eab288e5f43 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -111,10 +111,10 @@ static struct iio_chan_spec ad5933_channels[] = { IIO_CHAN(IIO_TEMP, 0, 1, 1, NULL, 0, 0, 0, 0, AD5933_REG_TEMP_DATA, IIO_ST('s', 14, 16, 0), 0), /* Ring Channels */ - IIO_CHAN(IIO_IN, 0, 1, 0, "real_raw", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "real_raw", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), AD5933_REG_REAL_DATA, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, "imag_raw", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "imag_raw", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SEPARATE), AD5933_REG_IMAG_DATA, 1, IIO_ST('s', 16, 16, 0), 0), }; diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index d99c56a6971..0e62d5e81e5 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -511,7 +511,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, *val = 0; *val2 = st->variant->gyro_scale_micro; return IIO_VAL_INT_PLUS_MICRO; - case IIO_IN: + case IIO_VOLTAGE: *val = 0; if (chan->channel == 0) *val2 = 2418; @@ -652,7 +652,7 @@ static struct iio_chan_spec adis16400_channels[] = { .scan_index = ADIS16400_SCAN_TEMP, .scan_type = IIO_ST('s', 12, 16, 0), }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), @@ -758,7 +758,7 @@ static struct iio_chan_spec adis16350_channels[] = { .scan_index = ADIS16350_SCAN_TEMP_Z, .scan_type = IIO_ST('s', 12, 16, 0), }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), @@ -825,7 +825,7 @@ static struct iio_chan_spec adis16300_channels[] = { .scan_index = ADIS16400_SCAN_TEMP, .scan_type = IIO_ST('s', 12, 16, 0), }, { - .type = IIO_IN, + .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index bedd3783fc3..3f31368e3d8 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -663,7 +663,7 @@ static const struct attribute_group ade7758_attribute_group = { }; static struct iio_chan_spec ade7758_channels[] = { - IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 0, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE), 0, IIO_ST('s', 24, 32, 0), 0), @@ -683,7 +683,7 @@ static struct iio_chan_spec ade7758_channels[] = { (1 << IIO_CHAN_INFO_SCALE_SHARED), AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR), 4, IIO_ST('s', 24, 32, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 1, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE), 5, IIO_ST('s', 24, 32, 0), 0), @@ -703,7 +703,7 @@ static struct iio_chan_spec ade7758_channels[] = { (1 << IIO_CHAN_INFO_SCALE_SHARED), AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR), 9, IIO_ST('s', 24, 32, 0), 0), - IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 2, 0, + IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE), 10, IIO_ST('s', 24, 32, 0), 0), From 657d1b0dfc97e2256257320f0818e21cf360d0ce Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 29 Sep 2011 09:13:18 +0300 Subject: [PATCH 1178/1519] Staging: vt6656: potential memory corruption param->u.wpa_key.key_len comes from the user. If it's too large we would write past the end of the array. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/wpactl.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index 9216df01829..2fa4f845a75 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -229,6 +229,9 @@ int wpa_set_wpadev(PSDevice pDevice, int val) return ret; } + if (param->u.wpa_key.key && param->u.wpa_key.key_len > sizeof(abyKey)) + return -EINVAL; + spin_unlock_irq(&pDevice->lock); if(param->u.wpa_key.key && fcpfkernel) { memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); @@ -269,6 +272,10 @@ int wpa_set_wpadev(PSDevice pDevice, int val) return ret; } + + if (param->u.wpa_key.seq && param->u.wpa_key.seq_len > sizeof(abySeq)) + return -EINVAL; + spin_unlock_irq(&pDevice->lock); if(param->u.wpa_key.seq && fcpfkernel) { memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); @@ -772,9 +779,14 @@ static int wpa_set_associate(PSDevice pDevice, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming dBm = %d\n", param->u.wpa_associate.roam_dbm); //Davidwang - if (param->u.wpa_associate.wpa_ie && - copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len)) - return -EINVAL; + if (param->u.wpa_associate.wpa_ie) { + if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE)) + return -EINVAL; + + if (copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, + param->u.wpa_associate.wpa_ie_len)) + return -EFAULT; + } if (param->u.wpa_associate.mode == 1) pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; From d515d0ff36a7afd528f32e3511780ad8385d957e Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Wed, 28 Sep 2011 13:24:15 -0700 Subject: [PATCH 1179/1519] staging: hv: remove the carrier status check from netvsc_open() Checking carrier status in netvsc_open() is not necessary. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/TODO | 2 -- drivers/staging/hv/netvsc_drv.c | 19 +++++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO index fcc57c24580..ed4d63619df 100644 --- a/drivers/staging/hv/TODO +++ b/drivers/staging/hv/TODO @@ -1,7 +1,5 @@ TODO: - audit the network driver - - checking for carrier inside open is wrong, network device API - confusion?? - audit the scsi driver Please send patches for this code to Greg Kroah-Hartman , diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 69c233e5fbe..561ba58f0e1 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -69,20 +69,15 @@ static int netvsc_open(struct net_device *net) struct hv_device *device_obj = net_device_ctx->device_ctx; int ret = 0; - if (netif_carrier_ok(net)) { - /* Open up the device */ - ret = rndis_filter_open(device_obj); - if (ret != 0) { - netdev_err(net, "unable to open device (ret %d).\n", - ret); - return ret; - } - - netif_start_queue(net); - } else { - netdev_err(net, "unable to open device...link is down.\n"); + /* Open up the device */ + ret = rndis_filter_open(device_obj); + if (ret != 0) { + netdev_err(net, "unable to open device (ret %d).\n", ret); + return ret; } + netif_start_queue(net); + return ret; } From 0a2cc4977ffd551b58ae20c646bd7083ba5a89d2 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 26 Sep 2011 22:03:59 -0400 Subject: [PATCH 1180/1519] Staging: bcm: Add min/max restrictions for IOCTL_BCM_REGISTER_READ_PRIVATE This patch fixes two issues within bcm/Bcmchar.c. The first condition in the or statement checks if variable IoBuffer.OutputLength, defined from user space, is greater than the maximum value allowed for an unsigned short. IoBuffer.OutputLength is then used in a kmalloc call to return a pointer to memory. If this size is greater than an unsigned short, it becomes useless. The second condition in the or statement checks if the same variable, IoBuffer.OutputLength is equal to zero before invoking the kmalloc call. In this case, if a zero size is sent to kmalloc, a valid pointer to memory is returned instead of the expected NULL. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 4c433538397..867c65c4375 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -216,7 +216,11 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) return -EFAULT; - /* FIXME: need to restrict BuffLen */ + if (IoBuffer.OutputLength > USHRT_MAX || + IoBuffer.OutputLength == 0) { + return -EINVAL; + } + Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; temp_buff = kmalloc(Bufflen, GFP_KERNEL); if (!temp_buff) From 2505aa6ce42a686b2d3db95ccdcc7bc100e7b8c0 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Tue, 27 Sep 2011 21:28:11 -0400 Subject: [PATCH 1181/1519] Staging: bcm: Alter LOC for readability/understandability purposes This patch alters a line of code to make it more readable and easier to understand. The purpose of the original line of code was to compute the amount of memory to request from kmalloc. This mulit-step algorithm was being done in one line of code, thus making it more difficult to understand. Therefore, I split this algorithm into three logical steps. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 867c65c4375..2fa658eb74d 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -205,6 +205,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) RDM_BUFFER sRdmBuffer = {0}; PCHAR temp_buff; UINT Bufflen; + u16 temp_value; /* Copy Ioctl Buffer structure */ if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) @@ -221,7 +222,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return -EINVAL; } - Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; + Bufflen = IoBuffer.OutputLength; + temp_value = 4 - (Bufflen % 4); + Bufflen += temp_value % 4; + temp_buff = kmalloc(Bufflen, GFP_KERNEL); if (!temp_buff) return -ENOMEM; From 7974035c008d98ec23ec76d9f10bff2dfd866ecf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:39 +0200 Subject: [PATCH 1182/1519] staging: nvec: Include missing headers Those headers were apparently included by other headers previously, but are not anymore. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.h | 1 + drivers/staging/nvec/nvec_kbd.c | 1 + drivers/staging/nvec/nvec_ps2.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index d9ff721d1d8..7cf9b01f898 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -1,6 +1,7 @@ #ifndef __LINUX_MFD_NVEC #define __LINUX_MFD_NVEC +#include #include typedef enum { diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 347a38c4687..87f0378c74f 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 0d3149b3e85..9eec075bed8 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -1,3 +1,4 @@ +#include #include #include #include From 162c7d8c4be2d599583c42c2a8fe99bed6d87f67 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:40 +0200 Subject: [PATCH 1183/1519] staging: nvec: coding style fixes / add copyright notice This patch fixes coding style and adds copyright notices. Signed-off-by: Marc Dietrich [jak@jak-linux.org: Merge later cleanup into that patch] Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/TODO | 5 +- drivers/staging/nvec/nvec-keytable.h | 209 +++++++++------- drivers/staging/nvec/nvec.c | 189 ++++++++------- drivers/staging/nvec/nvec.h | 38 ++- drivers/staging/nvec/nvec_kbd.c | 36 ++- drivers/staging/nvec/nvec_power.c | 348 ++++++++++++++------------- drivers/staging/nvec/nvec_ps2.c | 90 ++++--- 7 files changed, 508 insertions(+), 407 deletions(-) diff --git a/drivers/staging/nvec/TODO b/drivers/staging/nvec/TODO index 649d6b70dea..623e9bb0b40 100644 --- a/drivers/staging/nvec/TODO +++ b/drivers/staging/nvec/TODO @@ -1,10 +1,7 @@ ToDo list (incomplete, unordered) - - convert mouse, keyboard, and power to platform devices - - add copyright / driver author / license - add compile as module support - - move nvec devices to mfd cells? - - adjust to kernel style - fix clk usage should not be using clk_get_sys(), but clk_get(&pdev->dev, conn) where conn is either NULL if the device only has one clock, or the device specific name if it has multiple clocks. + - move half of the nvec init stuff to i2c-tegra.c diff --git a/drivers/staging/nvec/nvec-keytable.h b/drivers/staging/nvec/nvec-keytable.h index 6a1c4f7f460..1dc22cb8812 100644 --- a/drivers/staging/nvec/nvec-keytable.h +++ b/drivers/staging/nvec/nvec-keytable.h @@ -22,7 +22,8 @@ */ static unsigned short code_tab_102us[] = { - KEY_GRAVE, // 0x00 + /* 0x00 */ + KEY_GRAVE, KEY_ESC, KEY_1, KEY_2, @@ -38,7 +39,8 @@ static unsigned short code_tab_102us[] = { KEY_EQUAL, KEY_BACKSPACE, KEY_TAB, - KEY_Q, // 0x10 + /* 0x10 */ + KEY_Q, KEY_W, KEY_E, KEY_R, @@ -54,7 +56,8 @@ static unsigned short code_tab_102us[] = { KEY_LEFTCTRL, KEY_A, KEY_S, - KEY_D, // 0x20 + /* 0x20 */ + KEY_D, KEY_F, KEY_G, KEY_H, @@ -70,7 +73,8 @@ static unsigned short code_tab_102us[] = { KEY_X, KEY_C, KEY_V, - KEY_B, // 0x30 + /* 0x30 */ + KEY_B, KEY_N, KEY_M, KEY_COMMA, @@ -86,13 +90,15 @@ static unsigned short code_tab_102us[] = { KEY_F3, KEY_F4, KEY_F5, - KEY_F6, // 0x40 + /* 0x40 */ + KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_FN, - 0, //VK_SCROLL + /* VK_SCROLL */ + 0, KEY_KP7, KEY_KP8, KEY_KP9, @@ -102,52 +108,57 @@ static unsigned short code_tab_102us[] = { KEY_KP6, KEY_KPPLUS, KEY_KP1, - KEY_KP2, // 0x50 + /* 0x50 */ + KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT, - KEY_MENU, //VK_SNAPSHOT + /* VK_SNAPSHOT */ + KEY_MENU, KEY_POWER, - KEY_102ND, //VK_OEM_102 henry+ 0x2B (43) BACKSLASH have been used,change to use 0X56 (86) - KEY_F11, //VK_F11 - KEY_F12, //VK_F12 - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 60 + /* VK_OEM_102 */ + KEY_102ND, + KEY_F11, + KEY_F12, 0, 0, - KEY_SEARCH, // add search key map - 0, 0, 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 70 0, 0, - KEY_KP5, //73 for JP keyboard '\' key, report 0x4c - 0, + 0, + /* 0x60 */ 0, 0, - 0, - 0, - 0, - 0, - 0, - 0, - KEY_KP9, //7d for JP keyboard '|' key, report 0x49 + 0, + KEY_SEARCH, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + /* 0x70 */ + 0, + 0, + 0, + KEY_KP5, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + KEY_KP9, }; static unsigned short extcode_tab_us102[] = { @@ -167,7 +178,7 @@ static unsigned short extcode_tab_us102[] = { 0, 0, 0, - 0, // 0xE0 0x10 + /* 0x10 */ 0, 0, 0, @@ -176,18 +187,24 @@ static unsigned short extcode_tab_us102[] = { 0, 0, 0, - 0, //VK_MEDIA_NEXT_TRACK, + 0, + /* VK_MEDIA_NEXT_TRACK */ 0, 0, - 0, //VK_RETURN, - KEY_RIGHTCTRL, //VK_RCONTROL, + 0, + /* VK_RETURN */ + 0, + KEY_RIGHTCTRL, 0, 0, - KEY_MUTE, // 0xE0 0x20 - 0, //VK_LAUNCH_APP1 - 0, //VK_MEDIA_PLAY_PAUSE + /* 0x20 */ + KEY_MUTE, + /* VK_LAUNCH_APP1 */ 0, - 0, //VK_MEDIA_STOP + /* VK_MEDIA_PLAY_PAUSE */ + 0, + 0, + /* VK_MEDIA_STOP */ 0, 0, 0, @@ -199,40 +216,55 @@ static unsigned short extcode_tab_us102[] = { 0, 0, 0, - KEY_VOLUMEUP, // 0xE0 0x30 0, - 0, //VK_BROWSER_HOME + /* 0x30 */ + KEY_VOLUMEUP, + 0, + /* VK_BROWSER_HOME */ + 0, + 0, + 0, + /* VK_DIVIDE */ + KEY_KPSLASH, + 0, + /* VK_SNAPSHOT */ + KEY_SYSRQ, + /* VK_RMENU */ + KEY_RIGHTALT, + /* VK_OEM_NV_BACKLIGHT_UP */ + 0, + /* VK_OEM_NV_BACKLIGHT_DN */ + 0, + /* VK_OEM_NV_BACKLIGHT_AUTOTOGGLE */ + 0, + /* VK_OEM_NV_POWER_INFO */ + 0, + /* VK_OEM_NV_WIFI_TOGGLE */ + 0, + /* VK_OEM_NV_DISPLAY_SELECT */ + 0, + /* VK_OEM_NV_AIRPLANE_TOGGLE */ + 0, + /* 0x40 */ + 0, + KEY_LEFT, + 0, 0, 0, - KEY_KPSLASH, //VK_DIVIDE 0, - KEY_SYSRQ, //VK_SNAPSHOT - KEY_RIGHTALT, //VK_RMENU - 0, //VK_OEM_NV_BACKLIGHT_UP - 0, //VK_OEM_NV_BACKLIGHT_DN - 0, //VK_OEM_NV_BACKLIGHT_AUTOTOGGLE - 0, //VK_OEM_NV_POWER_INFO - 0, //VK_OEM_NV_WIFI_TOGGLE - 0, //VK_OEM_NV_DISPLAY_SELECT - 0, //VK_OEM_NV_AIRPLANE_TOGGLE - 0, //0xE0 0x40 - KEY_LEFT, //VK_OEM_NV_RESERVED henry+ for JP keyboard - 0, //VK_OEM_NV_RESERVED - 0, //VK_OEM_NV_RESERVED - 0, //VK_OEM_NV_RESERVED - 0, //VK_OEM_NV_RESERVED KEY_CANCEL, KEY_HOME, KEY_UP, - KEY_PAGEUP, //VK_PRIOR + KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, - KEY_DOWN, // 0xE0 0x50 - KEY_PAGEDOWN, //VK_NEXT + /* 0x50 */ + KEY_DOWN, + KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, @@ -242,25 +274,34 @@ static unsigned short extcode_tab_us102[] = { 0, 0, 0, - KEY_LEFTMETA, //VK_LWIN - 0, //VK_RWIN - KEY_ESC, //VK_APPS - KEY_KPMINUS, //for power button workaround - 0, + KEY_LEFTMETA, + 0, + KEY_ESC, + KEY_KPMINUS, 0, 0, 0, 0, 0, - 0, //VK_BROWSER_SEARCH - 0, //VK_BROWSER_FAVORITES - 0, //VK_BROWSER_REFRESH - 0, //VK_BROWSER_STOP - 0, //VK_BROWSER_FORWARD - 0, //VK_BROWSER_BACK - 0, //VK_LAUNCH_APP2 - 0, //VK_LAUNCH_MAIL - 0, //VK_LAUNCH_MEDIA_SELECT + 0, + /* VK_BROWSER_SEARCH */ + 0, + /* VK_BROWSER_FAVORITES */ + 0, + /* VK_BROWSER_REFRESH */ + 0, + /* VK_BROWSER_STOP */ + 0, + /* VK_BROWSER_FORWARD */ + 0, + /* VK_BROWSER_BACK */ + 0, + /* VK_LAUNCH_APP2 */ + 0, + /* VK_LAUNCH_MAIL */ + 0, + /* VK_LAUNCH_MEDIA_SELECT */ + 0, }; -static unsigned short* code_tabs[] = {code_tab_102us, extcode_tab_us102 }; +static unsigned short *code_tabs[] = { code_tab_102us, extcode_tab_us102 }; diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index efdc8dbbac6..d8609abcbd2 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -1,13 +1,25 @@ -// #define DEBUG +/* + * NVEC: NVIDIA compliant embedded controller interface + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Pierre-Hugues Husson + * Ilya Petrov + * Marc Dietrich + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ -/* ToDo list (incomplete, unorderd) - - convert mouse, keyboard, and power to platform devices -*/ +/* #define DEBUG */ -#include #include + #include #include +#include #include #include #include @@ -16,57 +28,60 @@ #include #include #include -#include -#include + #include #include #include #include #include + +#include +#include + #include "nvec.h" -static unsigned char EC_DISABLE_EVENT_REPORTING[] = {'\x04','\x00','\x00'}; -static unsigned char EC_ENABLE_EVENT_REPORTING[] = {'\x04','\x00','\x01'}; -static unsigned char EC_GET_FIRMWARE_VERSION[] = {'\x07','\x15'}; +static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00"; +static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01"; +static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15"; static struct nvec_chip *nvec_power_handle; static struct mfd_cell nvec_devices[] = { { - .name = "nvec-kbd", - .id = 1, + .name = "nvec-kbd", + .id = 1, }, { - .name = "nvec-mouse", - .id = 1, + .name = "nvec-mouse", + .id = 1, }, { - .name = "nvec-power", - .id = 1, + .name = "nvec-power", + .id = 1, }, { - .name = "nvec-power", - .id = 2, + .name = "nvec-power", + .id = 2, }, }; int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, - unsigned int events) + unsigned int events) { return atomic_notifier_chain_register(&nvec->notifier_list, nb); } EXPORT_SYMBOL_GPL(nvec_register_notifier); -static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type, - void *data) +static int nvec_status_notifier(struct notifier_block *nb, + unsigned long event_type, void *data) { unsigned char *msg = (unsigned char *)data; int i; - if(event_type != NVEC_CNTL) + if (event_type != NVEC_CNTL) return NOTIFY_DONE; - printk("unhandled msg type %ld, payload: ", event_type); + printk(KERN_WARNING "unhandled msg type %ld, payload: ", event_type); for (i = 0; i < msg[1]; i++) printk("%0x ", msg[i+2]); printk("\n"); @@ -74,7 +89,8 @@ static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_t return NOTIFY_OK; } -void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size) +void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, + short size) { struct nvec_msg *msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); @@ -95,42 +111,43 @@ static void nvec_request_master(struct work_struct *work) { struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work); - if(!list_empty(&nvec->tx_data)) { + if (!list_empty(&nvec->tx_data)) gpio_set_value(nvec->gpio, 0); - } } static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) { int i; - if((msg->data[0] & 1<<7) == 0 && msg->data[3]) { - dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", msg->data[0], - msg->data[1], msg->data[2], msg->data[3]); + if ((msg->data[0] & 1 << 7) == 0 && msg->data[3]) { + dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", + msg->data[0], msg->data[1], msg->data[2], msg->data[3]); return -EINVAL; } - if ((msg->data[0] >> 7 ) == 1 && (msg->data[0] & 0x0f) == 5) - { + if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) { dev_warn(nvec->dev, "ec system event "); - for (i=0; i < msg->data[1]; i++) + for (i = 0; i < msg->data[1]; i++) dev_warn(nvec->dev, "%02x ", msg->data[2+i]); dev_warn(nvec->dev, "\n"); } - atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data); + atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, + msg->data); return 0; } -static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, unsigned char *data, short size) +static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, + const unsigned char *data, short size) { down(&nvec->sync_write_mutex); nvec->sync_write_pending = (data[1] << 8) + data[0]; nvec_write_async(nvec, data, size); - dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", nvec->sync_write_pending); + dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", + nvec->sync_write_pending); wait_for_completion(&nvec->sync_write); dev_dbg(nvec->dev, "nvec_sync_write: pong!\n"); @@ -145,21 +162,21 @@ static void nvec_dispatch(struct work_struct *work) struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work); struct nvec_msg *msg; - while(!list_empty(&nvec->rx_data)) - { + while (!list_empty(&nvec->rx_data)) { msg = list_first_entry(&nvec->rx_data, struct nvec_msg, node); list_del_init(&msg->node); - if(nvec->sync_write_pending == (msg->data[2] << 8) + msg->data[0]) - { + if (nvec->sync_write_pending == + (msg->data[2] << 8) + msg->data[0]) { dev_dbg(nvec->dev, "sync write completed!\n"); nvec->sync_write_pending = 0; nvec->last_sync_msg = msg; complete(&nvec->sync_write); } else { parse_msg(nvec, msg); - if((!msg) || (!msg->data)) - dev_warn(nvec->dev, "attempt access zero pointer\n"); + if ((!msg) || (!msg->data)) + dev_warn(nvec->dev, + "attempt access zero pointer\n"); else { kfree(msg->data); kfree(msg); @@ -179,20 +196,13 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) status = readl(base + I2C_SL_STATUS); - if(!(status & I2C_SL_IRQ)) - { + if (!(status & I2C_SL_IRQ)) { dev_warn(nvec->dev, "nvec Spurious IRQ\n"); - //Yup, handled. ahum. goto handled; } - if(status & END_TRANS && !(status & RCVD)) - { - //Reenable IRQ only when even has been sent - //printk("Write sequence ended !\n"); - //parse_msg(nvec); + if (status & END_TRANS && !(status & RCVD)) { nvec->state = NVEC_WAIT; - if(nvec->rx->size > 1) - { + if (nvec->rx->size > 1) { list_add_tail(&nvec->rx->node, &nvec->rx_data); schedule_work(&nvec->rx_work); } else { @@ -200,41 +210,31 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) kfree(nvec->rx); } return IRQ_HANDLED; - } else if(status & RNW) - { - // Work around for AP20 New Slave Hw Bug. Give 1us extra. - // nvec/smbus/nvec_i2c_transport.c in NV`s crap for reference - if(status & RCVD) + } else if (status & RNW) { + if (status & RCVD) udelay(3); - if(status & RCVD) - { + if (status & RCVD) nvec->state = NVEC_WRITE; - //Master wants something from us. New communication -// dev_dbg(nvec->dev, "New read comm!\n"); - } else { - //Master wants something from us from a communication we've already started -// dev_dbg(nvec->dev, "Read comm cont !\n"); - } - //if(msg_postx_data)) - { + + if (list_empty(&nvec->tx_data)) { dev_err(nvec->dev, "nvec empty tx - sending no-op\n"); to_send = 0x8a; nvec_write_async(nvec, "\x07\x02", 2); -// to_send = 0x01; } else { - msg = list_first_entry(&nvec->tx_data, struct nvec_msg, node); - if(msg->pos < msg->size) { + msg = + list_first_entry(&nvec->tx_data, struct nvec_msg, + node); + if (msg->pos < msg->size) { to_send = msg->data[msg->pos]; msg->pos++; } else { - dev_err(nvec->dev, "nvec crap! %d\n", msg->size); + dev_err(nvec->dev, "nvec crap! %d\n", + msg->size); to_send = 0x01; } - if(msg->pos >= msg->size) - { + if (msg->pos >= msg->size) { list_del_init(&msg->node); kfree(msg->data); kfree(msg); @@ -251,14 +251,13 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) goto handled; } else { received = readl(base + I2C_SL_RCVD); - //Workaround? - if(status & RCVD) { + + if (status & RCVD) { writel(0, base + I2C_SL_RCVD); goto handled; } - if (nvec->state == NVEC_WAIT) - { + if (nvec->state == NVEC_WAIT) { nvec->state = NVEC_READ; msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); msg->data = kzalloc(32, GFP_NOWAIT); @@ -272,7 +271,8 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) msg->data[msg->pos] = received; msg->pos++; msg->size = msg->pos; - dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", received, msg->pos); + dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", + received, msg->pos); } handled: return IRQ_HANDLED; @@ -318,7 +318,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) void __iomem *base; nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL); - if(nvec == NULL) { + if (nvec == NULL) { dev_err(&pdev->dev, "failed to reserve memory\n"); return -ENOMEM; } @@ -367,7 +367,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) /* Set the gpio to low when we've got something to say */ err = gpio_request(nvec->gpio, "nvec gpio"); - if(err < 0) + if (err < 0) dev_err(nvec->dev, "couldn't request gpio\n"); ATOMIC_INIT_NOTIFIER_HEAD(&nvec->notifier_list); @@ -392,7 +392,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) /* enable event reporting */ nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, - sizeof(EC_ENABLE_EVENT_REPORTING)); + sizeof(EC_ENABLE_EVENT_REPORTING)); nvec->nvec_status_notifier.notifier_call = nvec_status_notifier; nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0); @@ -402,17 +402,17 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) /* Get Firmware Version */ msg = nvec_write_sync(nvec, EC_GET_FIRMWARE_VERSION, - sizeof(EC_GET_FIRMWARE_VERSION)); + sizeof(EC_GET_FIRMWARE_VERSION)); dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", - msg->data[4], msg->data[5], msg->data[6], msg->data[7]); + msg->data[4], msg->data[5], msg->data[6], msg->data[7]); kfree(msg->data); kfree(msg); ret = mfd_add_devices(nvec->dev, -1, nvec_devices, - ARRAY_SIZE(nvec_devices), base, 0); - if(ret) + ARRAY_SIZE(nvec_devices), base, 0); + if (ret) dev_err(nvec->dev, "error adding subdevices\n"); /* unmute speakers? */ @@ -460,8 +460,8 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state) return 0; } -static int tegra_nvec_resume(struct platform_device *pdev) { - +static int tegra_nvec_resume(struct platform_device *pdev) +{ struct nvec_chip *nvec = platform_get_drvdata(pdev); dev_dbg(nvec->dev, "resuming\n"); @@ -476,13 +476,12 @@ static int tegra_nvec_resume(struct platform_device *pdev) { #define tegra_nvec_resume NULL #endif -static struct platform_driver nvec_device_driver = -{ - .probe = tegra_nvec_probe, - .remove = __devexit_p(tegra_nvec_remove), +static struct platform_driver nvec_device_driver = { + .probe = tegra_nvec_probe, + .remove = __devexit_p(tegra_nvec_remove), .suspend = tegra_nvec_suspend, - .resume = tegra_nvec_resume, - .driver = { + .resume = tegra_nvec_resume, + .driver = { .name = "nvec", .owner = THIS_MODULE, } @@ -494,4 +493,8 @@ static int __init tegra_nvec_init(void) } module_init(tegra_nvec_init); + MODULE_ALIAS("platform:nvec"); +MODULE_DESCRIPTION("NVIDIA compliant embedded controller interface"); +MODULE_AUTHOR("Marc Dietrich "); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index 7cf9b01f898..fe11225bcec 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -1,3 +1,18 @@ +/* + * NVEC: NVIDIA compliant embedded controller interface + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Pierre-Hugues Husson + * Ilya Petrov + * Marc Dietrich + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ + #ifndef __LINUX_MFD_NVEC #define __LINUX_MFD_NVEC @@ -17,7 +32,7 @@ typedef enum { } how_care; typedef enum { - NVEC_SYS=1, + NVEC_SYS = 1, NVEC_BAT, NVEC_KBD = 5, NVEC_PS2, @@ -27,9 +42,9 @@ typedef enum { } nvec_event; typedef enum { - NVEC_WAIT, - NVEC_READ, - NVEC_WRITE + NVEC_WAIT, + NVEC_READ, + NVEC_WRITE } nvec_state; struct nvec_msg { @@ -64,22 +79,27 @@ struct nvec_chip { struct work_struct rx_work, tx_work; struct nvec_msg *rx, *tx; -/* sync write stuff */ + /* sync write stuff */ struct semaphore sync_write_mutex; struct completion sync_write; u16 sync_write_pending; struct nvec_msg *last_sync_msg; }; -extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size); +extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, + short size); extern int nvec_register_notifier(struct nvec_chip *nvec, - struct notifier_block *nb, unsigned int events); + struct notifier_block *nb, + unsigned int events); extern int nvec_unregister_notifier(struct device *dev, - struct notifier_block *nb, unsigned int events); + struct notifier_block *nb, + unsigned int events); -const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data)); +const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, + how_care care_resp, + void (*rt_handler) (unsigned char *data)); #define I2C_CNFG 0x00 #define I2C_CNFG_PACKET_MODE_EN (1<<10) diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 87f0378c74f..06e877cf151 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -1,15 +1,30 @@ +/* + * nvec_kbd: keyboard driver for a NVIDIA compliant embedded controller + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Pierre-Hugues Husson + * Marc Dietrich + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ + #include #include #include #include #include + #include "nvec-keytable.h" #include "nvec.h" #define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) - + ARRAY_SIZE(extcode_tab_us102)]; + + ARRAY_SIZE(extcode_tab_us102)]; struct nvec_keys { struct input_dev *input; @@ -20,7 +35,7 @@ struct nvec_keys { static struct nvec_keys keys_dev; static int nvec_keys_notifier(struct notifier_block *nb, - unsigned long event_type, void *data) + unsigned long event_type, void *data) { int code, state; unsigned char *msg = (unsigned char *)data; @@ -38,7 +53,8 @@ static int nvec_keys_notifier(struct notifier_block *nb, code = msg[1] & 0x7f; state = msg[1] & 0x80; - input_report_key(keys_dev.input, code_tabs[_size][code], !state); + input_report_key(keys_dev.input, code_tabs[_size][code], + !state); input_sync(keys_dev.input); return NOTIFY_STOP; @@ -48,7 +64,7 @@ static int nvec_keys_notifier(struct notifier_block *nb, } static int nvec_kbd_event(struct input_dev *dev, unsigned int type, - unsigned int code, int value) + unsigned int code, int value) { unsigned char buf[] = ACK_KBD_EVENT; struct nvec_chip *nvec = keys_dev.nvec; @@ -125,10 +141,10 @@ fail: } static struct platform_driver nvec_kbd_driver = { - .probe = nvec_kbd_probe, - .driver = { - .name = "nvec-kbd", - .owner = THIS_MODULE, + .probe = nvec_kbd_probe, + .driver = { + .name = "nvec-kbd", + .owner = THIS_MODULE, }, }; @@ -138,3 +154,7 @@ static int __init nvec_kbd_init(void) } module_init(nvec_kbd_init); + +MODULE_AUTHOR("Marc Dietrich "); +MODULE_DESCRIPTION("NVEC keyboard driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c index df164add837..dfa966f6189 100644 --- a/drivers/staging/nvec/nvec_power.c +++ b/drivers/staging/nvec/nvec_power.c @@ -1,3 +1,17 @@ +/* + * nvec_power: power supply driver for a NVIDIA compliant embedded controller + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Ilya Petrov + * Marc Dietrich + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ + #include #include #include @@ -5,10 +19,10 @@ #include #include #include + #include "nvec.h" -struct nvec_power -{ +struct nvec_power { struct notifier_block notifier; struct delayed_work poller; struct nvec_chip *nvec; @@ -58,7 +72,8 @@ struct bat_response { u8 length; u8 sub_type; u8 status; - union { /* payload */ + /* payload */ + union { char plc[30]; u16 plu; s16 pls; @@ -69,18 +84,17 @@ static struct power_supply nvec_bat_psy; static struct power_supply nvec_psy; static int nvec_power_notifier(struct notifier_block *nb, - unsigned long event_type, void *data) + unsigned long event_type, void *data) { - struct nvec_power *power = container_of(nb, struct nvec_power, notifier); + struct nvec_power *power = + container_of(nb, struct nvec_power, notifier); struct bat_response *res = (struct bat_response *)data; if (event_type != NVEC_SYS) return NOTIFY_DONE; - if(res->sub_type == 0) - { - if (power->on != res->plu) - { + if (res->sub_type == 0) { + if (power->on != res->plu) { power->on = res->plu; power_supply_changed(&nvec_psy); } @@ -89,8 +103,7 @@ static int nvec_power_notifier(struct notifier_block *nb, return NOTIFY_OK; } -static const int bat_init[] = -{ +static const int bat_init[] = { LAST_FULL_CHARGE_CAPACITY, DESIGN_CAPACITY, CRITICAL_CAPACITY, MANUFACTURER, MODEL, TYPE, }; @@ -100,116 +113,115 @@ static void get_bat_mfg_data(struct nvec_power *power) int i; char buf[] = { '\x02', '\x00' }; - for (i = 0; i < ARRAY_SIZE(bat_init); i++) - { + for (i = 0; i < ARRAY_SIZE(bat_init); i++) { buf[1] = bat_init[i]; nvec_write_async(power->nvec, buf, 2); } } static int nvec_power_bat_notifier(struct notifier_block *nb, - unsigned long event_type, void *data) + unsigned long event_type, void *data) { - struct nvec_power *power = container_of(nb, struct nvec_power, notifier); + struct nvec_power *power = + container_of(nb, struct nvec_power, notifier); struct bat_response *res = (struct bat_response *)data; int status_changed = 0; if (event_type != NVEC_BAT) return NOTIFY_DONE; - switch(res->sub_type) - { - case SLOT_STATUS: - if (res->plc[0] & 1) - { - if (power->bat_present == 0) - { - status_changed = 1; - get_bat_mfg_data(power); - } + switch (res->sub_type) { + case SLOT_STATUS: + if (res->plc[0] & 1) { + if (power->bat_present == 0) { + status_changed = 1; + get_bat_mfg_data(power); + } - power->bat_present = 1; + power->bat_present = 1; - switch ((res->plc[0] >> 1) & 3) - { - case 0: - power->bat_status = POWER_SUPPLY_STATUS_NOT_CHARGING; - break; - case 1: - power->bat_status = POWER_SUPPLY_STATUS_CHARGING; - break; - case 2: - power->bat_status = POWER_SUPPLY_STATUS_DISCHARGING; - break; - default: - power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; - } - } else { - if (power->bat_present == 1) - status_changed = 1; - - power->bat_present = 0; + switch ((res->plc[0] >> 1) & 3) { + case 0: + power->bat_status = + POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + case 1: + power->bat_status = + POWER_SUPPLY_STATUS_CHARGING; + break; + case 2: + power->bat_status = + POWER_SUPPLY_STATUS_DISCHARGING; + break; + default: power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; } - power->bat_cap = res->plc[1]; - if (status_changed) - power_supply_changed(&nvec_bat_psy); - break; - case VOLTAGE: - power->bat_voltage_now = res->plu * 1000; - break; - case TIME_REMAINING: - power->time_remain = res->plu * 3600; - break; - case CURRENT: - power->bat_current_now = res->pls * 1000; - break; - case AVERAGE_CURRENT: - power->bat_current_avg = res->pls * 1000; - break; - case CAPACITY_REMAINING: - power->capacity_remain = res->plu * 1000; - break; - case LAST_FULL_CHARGE_CAPACITY: - power->charge_last_full = res->plu * 1000; - break; - case DESIGN_CAPACITY: - power->charge_full_design = res->plu * 1000; - break; - case CRITICAL_CAPACITY: - power->critical_capacity = res->plu * 1000; - break; - case TEMPERATURE: - power->bat_temperature = res->plu - 2732; - break; - case MANUFACTURER: - memcpy(power->bat_manu, &res->plc, res->length-2); - power->bat_model[res->length-2] = '\0'; - break; - case MODEL: - memcpy(power->bat_model, &res->plc, res->length-2); - power->bat_model[res->length-2] = '\0'; - break; - case TYPE: - memcpy(power->bat_type, &res->plc, res->length-2); - power->bat_type[res->length-2] = '\0'; - /* this differs a little from the spec - fill in more if you find some */ - if (!strncmp(power->bat_type, "Li", 30)) - power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION; - else - power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; - break; - default: - return NOTIFY_STOP; + } else { + if (power->bat_present == 1) + status_changed = 1; + + power->bat_present = 0; + power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; + } + power->bat_cap = res->plc[1]; + if (status_changed) + power_supply_changed(&nvec_bat_psy); + break; + case VOLTAGE: + power->bat_voltage_now = res->plu * 1000; + break; + case TIME_REMAINING: + power->time_remain = res->plu * 3600; + break; + case CURRENT: + power->bat_current_now = res->pls * 1000; + break; + case AVERAGE_CURRENT: + power->bat_current_avg = res->pls * 1000; + break; + case CAPACITY_REMAINING: + power->capacity_remain = res->plu * 1000; + break; + case LAST_FULL_CHARGE_CAPACITY: + power->charge_last_full = res->plu * 1000; + break; + case DESIGN_CAPACITY: + power->charge_full_design = res->plu * 1000; + break; + case CRITICAL_CAPACITY: + power->critical_capacity = res->plu * 1000; + break; + case TEMPERATURE: + power->bat_temperature = res->plu - 2732; + break; + case MANUFACTURER: + memcpy(power->bat_manu, &res->plc, res->length - 2); + power->bat_model[res->length - 2] = '\0'; + break; + case MODEL: + memcpy(power->bat_model, &res->plc, res->length - 2); + power->bat_model[res->length - 2] = '\0'; + break; + case TYPE: + memcpy(power->bat_type, &res->plc, res->length - 2); + power->bat_type[res->length - 2] = '\0'; + /* this differs a little from the spec + fill in more if you find some */ + if (!strncmp(power->bat_type, "Li", 30)) + power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION; + else + power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; + break; + default: + return NOTIFY_STOP; } return NOTIFY_STOP; } static int nvec_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) + enum power_supply_property psp, + union power_supply_propval *val) { struct nvec_power *power = dev_get_drvdata(psy->dev->parent); switch (psp) { @@ -223,61 +235,60 @@ static int nvec_power_get_property(struct power_supply *psy, } static int nvec_battery_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) + enum power_supply_property psp, + union power_supply_propval *val) { struct nvec_power *power = dev_get_drvdata(psy->dev->parent); - switch(psp) - { - case POWER_SUPPLY_PROP_STATUS: - val->intval = power->bat_status; - break; - case POWER_SUPPLY_PROP_CAPACITY: - val->intval = power->bat_cap; - break; - case POWER_SUPPLY_PROP_PRESENT: - val->intval = power->bat_present; - break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = power->bat_voltage_now; - break; - case POWER_SUPPLY_PROP_CURRENT_NOW: - val->intval = power->bat_current_now; - break; - case POWER_SUPPLY_PROP_CURRENT_AVG: - val->intval = power->bat_current_avg; - break; - case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: - val->intval = power->time_remain; - break; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: - val->intval = power->charge_full_design; - break; - case POWER_SUPPLY_PROP_CHARGE_FULL: - val->intval = power->charge_last_full; - break; - case POWER_SUPPLY_PROP_CHARGE_EMPTY: - val->intval = power->critical_capacity; - break; - case POWER_SUPPLY_PROP_CHARGE_NOW: - val->intval = power->capacity_remain; - break; - case POWER_SUPPLY_PROP_TEMP: - val->intval = power->bat_temperature; - break; - case POWER_SUPPLY_PROP_MANUFACTURER: - val->strval = power->bat_manu; - break; - case POWER_SUPPLY_PROP_MODEL_NAME: - val->strval = power->bat_model; - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = power->bat_type_enum; - break; - default: - return -EINVAL; - } + switch (psp) { + case POWER_SUPPLY_PROP_STATUS: + val->intval = power->bat_status; + break; + case POWER_SUPPLY_PROP_CAPACITY: + val->intval = power->bat_cap; + break; + case POWER_SUPPLY_PROP_PRESENT: + val->intval = power->bat_present; + break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + val->intval = power->bat_voltage_now; + break; + case POWER_SUPPLY_PROP_CURRENT_NOW: + val->intval = power->bat_current_now; + break; + case POWER_SUPPLY_PROP_CURRENT_AVG: + val->intval = power->bat_current_avg; + break; + case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: + val->intval = power->time_remain; + break; + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: + val->intval = power->charge_full_design; + break; + case POWER_SUPPLY_PROP_CHARGE_FULL: + val->intval = power->charge_last_full; + break; + case POWER_SUPPLY_PROP_CHARGE_EMPTY: + val->intval = power->critical_capacity; + break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + val->intval = power->capacity_remain; + break; + case POWER_SUPPLY_PROP_TEMP: + val->intval = power->bat_temperature; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = power->bat_manu; + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = power->bat_model; + break; + case POWER_SUPPLY_PROP_TECHNOLOGY: + val->intval = power->bat_type_enum; + break; + default: + return -EINVAL; + } return 0; } @@ -310,11 +321,11 @@ static char *nvec_power_supplied_to[] = { }; static struct power_supply nvec_bat_psy = { - .name = "battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = nvec_battery_props, - .num_properties = ARRAY_SIZE(nvec_battery_props), - .get_property = nvec_battery_get_property, + .name = "battery", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = nvec_battery_props, + .num_properties = ARRAY_SIZE(nvec_battery_props), + .get_property = nvec_battery_get_property, }; static struct power_supply nvec_psy = { @@ -327,9 +338,8 @@ static struct power_supply nvec_psy = { .get_property = nvec_power_get_property, }; -static int counter = 0; -static int const bat_iter[] = -{ +static int counter; +static int const bat_iter[] = { SLOT_STATUS, VOLTAGE, CURRENT, CAPACITY_REMAINING, #ifdef EC_FULL_DIAG AVERAGE_CURRENT, TEMPERATURE, TIME_REMAINING, @@ -340,7 +350,7 @@ static void nvec_power_poll(struct work_struct *work) { char buf[] = { '\x01', '\x00' }; struct nvec_power *power = container_of(work, struct nvec_power, - poller.work); + poller.work); if (counter >= ARRAY_SIZE(bat_iter)) counter = 0; @@ -351,19 +361,18 @@ static void nvec_power_poll(struct work_struct *work) /* select a battery request function via round robin doing it all at once seems to overload the power supply */ - buf[0] = '\x02'; /* battery */ - buf[1] = bat_iter[counter++]; + buf[0] = '\x02'; /* battery */ + buf[1] = bat_iter[counter++]; nvec_write_async(power->nvec, buf, 2); -// printk("%02x %02x\n", buf[0], buf[1]); - schedule_delayed_work(to_delayed_work(work), msecs_to_jiffies(5000)); }; static int __devinit nvec_power_probe(struct platform_device *pdev) { struct power_supply *psy; - struct nvec_power *power = kzalloc(sizeof(struct nvec_power), GFP_NOWAIT); + struct nvec_power *power = + kzalloc(sizeof(struct nvec_power), GFP_NOWAIT); struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); dev_set_drvdata(&pdev->dev, power); @@ -381,7 +390,7 @@ static int __devinit nvec_power_probe(struct platform_device *pdev) case BAT: psy = &nvec_bat_psy; - power->notifier.notifier_call = nvec_power_bat_notifier; + power->notifier.notifier_call = nvec_power_bat_notifier; break; default: kfree(power); @@ -398,14 +407,13 @@ static int __devinit nvec_power_probe(struct platform_device *pdev) static struct platform_driver nvec_power_driver = { .probe = nvec_power_probe, -// .remove = __devexit_p(nvec_power_remove), .driver = { - .name = "nvec-power", - .owner = THIS_MODULE, - } + .name = "nvec-power", + .owner = THIS_MODULE, + } }; -static int __init nvec_power_init(void) +static int __init nvec_power_init(void) { return platform_driver_register(&nvec_power_driver); } diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 9eec075bed8..67c77551494 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -1,16 +1,33 @@ +/* + * nvec_ps2: mouse driver for a NVIDIA compliant embedded controller + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Pierre-Hugues Husson + * Ilya Petrov + * Marc Dietrich + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ + #include #include #include #include #include + #include "nvec.h" -#define START_STREAMING {'\x06','\x03','\x01'} -#define STOP_STREAMING {'\x06','\x04'} -#define SEND_COMMAND {'\x06','\x01','\xf4','\x01'} +#define START_STREAMING {'\x06', '\x03', '\x01'} +#define STOP_STREAMING {'\x06', '\x04'} +#define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'} -struct nvec_ps2 -{ +static const unsigned char MOUSE_RESET[] = {'\x06', '\x01', '\xff', '\x03'}; + +struct nvec_ps2 { struct serio *ser_dev; struct notifier_block notifier; struct nvec_chip *nvec; @@ -31,12 +48,6 @@ static void ps2_stopstreaming(struct serio *ser_dev) nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } -/* is this really needed? -static void nvec_resp_handler(unsigned char *data) { - serio_interrupt(ser_dev, data[4], 0); -} -*/ - static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) { unsigned char buf[] = SEND_COMMAND; @@ -50,47 +61,44 @@ static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) } static int nvec_ps2_notifier(struct notifier_block *nb, - unsigned long event_type, void *data) + unsigned long event_type, void *data) { int i; unsigned char *msg = (unsigned char *)data; switch (event_type) { - case NVEC_PS2_EVT: - serio_interrupt(ps2_dev.ser_dev, msg[2], 0); - return NOTIFY_STOP; + case NVEC_PS2_EVT: + serio_interrupt(ps2_dev.ser_dev, msg[2], 0); + return NOTIFY_STOP; - case NVEC_PS2: - if (msg[2] == 1) - for(i = 0; i < (msg[1] - 2); i++) - serio_interrupt(ps2_dev.ser_dev, msg[i+4], 0); - else if (msg[1] != 2) /* !ack */ - { - printk("nvec_ps2: unhandled mouse event "); - for(i = 0; i <= (msg[1]+1); i++) - printk("%02x ", msg[i]); - printk(".\n"); - } + case NVEC_PS2: + if (msg[2] == 1) + for (i = 0; i < (msg[1] - 2); i++) + serio_interrupt(ps2_dev.ser_dev, msg[i + 4], 0); + else if (msg[1] != 2) { /* !ack */ + print_hex_dump(KERN_WARNING, "unhandled mouse event: ", + DUMP_PREFIX_NONE, 16, 1, + msg, msg[1] + 2, true); + } - return NOTIFY_STOP; + return NOTIFY_STOP; } return NOTIFY_DONE; } - static int __devinit nvec_mouse_probe(struct platform_device *pdev) { struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL); - ser_dev->id.type=SERIO_8042; - ser_dev->write=ps2_sendcommand; - ser_dev->open=ps2_startstreaming; - ser_dev->close=ps2_stopstreaming; + ser_dev->id.type = SERIO_8042; + ser_dev->write = ps2_sendcommand; + ser_dev->open = ps2_startstreaming; + ser_dev->close = ps2_stopstreaming; - strlcpy(ser_dev->name, "NVEC PS2", sizeof(ser_dev->name)); - strlcpy(ser_dev->phys, "NVEC I2C slave", sizeof(ser_dev->phys)); + strlcpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name)); + strlcpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys)); ps2_dev.ser_dev = ser_dev; ps2_dev.notifier.notifier_call = nvec_ps2_notifier; @@ -100,16 +108,16 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev) serio_register_port(ser_dev); /* mouse reset */ - nvec_write_async(nvec, "\x06\x01\xff\x03", 4); + nvec_write_async(nvec, MOUSE_RESET, 4); return 0; } static struct platform_driver nvec_mouse_driver = { - .probe = nvec_mouse_probe, - .driver = { - .name = "nvec-mouse", - .owner = THIS_MODULE, + .probe = nvec_mouse_probe, + .driver = { + .name = "nvec-mouse", + .owner = THIS_MODULE, }, }; @@ -119,3 +127,7 @@ static int __init nvec_mouse_init(void) } module_init(nvec_mouse_init); + +MODULE_DESCRIPTION("NVEC mouse driver"); +MODULE_AUTHOR("Marc Dietrich "); +MODULE_LICENSE("GPL"); From a3a9aa1a41429b17aa1af20995850ea1b68d5ba2 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:41 +0200 Subject: [PATCH 1184/1519] staging: nvec: Use print_hex_dump() where appropriate Split of the previous patch and the next by Marc, as that patch is not strictly a coding style fix only. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index d8609abcbd2..d43fba25c22 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -76,15 +76,13 @@ static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type, void *data) { unsigned char *msg = (unsigned char *)data; - int i; if (event_type != NVEC_CNTL) return NOTIFY_DONE; - printk(KERN_WARNING "unhandled msg type %ld, payload: ", event_type); - for (i = 0; i < msg[1]; i++) - printk("%0x ", msg[i+2]); - printk("\n"); + printk(KERN_WARNING "unhandled msg type %ld\n", event_type); + print_hex_dump(KERN_WARNING, "payload: ", DUMP_PREFIX_NONE, 16, 1, + msg, msg[1] + 2, true); return NOTIFY_OK; } @@ -117,20 +115,16 @@ static void nvec_request_master(struct work_struct *work) static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) { - int i; - if ((msg->data[0] & 1 << 7) == 0 && msg->data[3]) { dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", msg->data[0], msg->data[1], msg->data[2], msg->data[3]); return -EINVAL; } - if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) { - dev_warn(nvec->dev, "ec system event "); - for (i = 0; i < msg->data[1]; i++) - dev_warn(nvec->dev, "%02x ", msg->data[2+i]); - dev_warn(nvec->dev, "\n"); - } + if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) + print_hex_dump(KERN_WARNING, "ec system event ", + DUMP_PREFIX_NONE, 16, 1, msg->data, + msg->data[1] + 2, true); atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data); From ac8107599e47b0f4638f4f3fb0141bbcf0cb142b Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:42 +0200 Subject: [PATCH 1185/1519] staging: nvec: rework the nvec slave init Rework the tegra slave controller init to look more like in tegra-i2c.c. This makes the nvec init reliable. Also add de-init of the slave to be used during suspend. Signed-off-by: Marc Dietrich Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index d43fba25c22..6c6e39447a5 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -282,18 +282,30 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec) udelay(2); tegra_periph_reset_deassert(nvec->i2c_clk); + val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN | + (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT); + writel(val, nvec->base + I2C_CNFG); + + clk_set_rate(nvec->i2c_clk, 8 * 80000); + + writel(I2C_SL_NEWL, nvec->base + I2C_SL_CNFG); + writel(0x1E, nvec->base + I2C_SL_DELAY_COUNT); + writel(nvec->i2c_addr>>1, nvec->base + I2C_SL_ADDR1); writel(0, nvec->base + I2C_SL_ADDR2); - writel(0x1E, nvec->base + I2C_SL_DELAY_COUNT); - val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN | - (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT); - writel(val, nvec->base + I2C_CNFG); - writel(I2C_SL_NEWL, nvec->base + I2C_SL_CNFG); + enable_irq(nvec->irq); clk_disable(nvec->i2c_clk); } +static void nvec_disable_i2c_slave(struct nvec_chip *nvec) +{ + disable_irq(nvec->irq); + writel(I2C_SL_NEWL | I2C_SL_NACK, nvec->base + I2C_SL_CNFG); + clk_disable(nvec->i2c_clk); +} + static void nvec_power_off(void) { nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3); @@ -352,9 +364,6 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) goto err_iounmap; } - clk_enable(i2c_clk); - clk_set_rate(i2c_clk, 8*80000); - nvec->base = base; nvec->irq = res->start; nvec->i2c_clk = i2c_clk; @@ -378,9 +387,12 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) dev_err(nvec->dev, "couldn't request irq\n"); goto failed; } + disable_irq(nvec->irq); tegra_init_i2c_slave(nvec); + clk_enable(i2c_clk); + gpio_direction_output(nvec->gpio, 1); gpio_set_value(nvec->gpio, 1); @@ -450,6 +462,7 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state) dev_dbg(nvec->dev, "suspending\n"); nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3); nvec_write_async(nvec, "\x04\x02", 2); + nvec_disable_i2c_slave(nvec); return 0; } From 6dca320c8f16b464bb762494b509b2b02897054e Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:43 +0200 Subject: [PATCH 1186/1519] staging: nvec: fix unmute of speakers The ec command used was for muting, not unmuting. Signed-off-by: Marc Dietrich Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 6c6e39447a5..69130189798 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -422,7 +422,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) dev_err(nvec->dev, "error adding subdevices\n"); /* unmute speakers? */ - nvec_write_async(nvec, "\x0d\x10\x59\x94", 4); + nvec_write_async(nvec, "\x0d\x10\x59\x95", 4); /* enable lid switch event */ nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x02\x00", 7); From 97cc26576fa2b0eb1aad1b29515bb0a32f86c45c Mon Sep 17 00:00:00 2001 From: Ilya Petrov Date: Tue, 27 Sep 2011 19:00:44 +0200 Subject: [PATCH 1187/1519] staging: nvec: add LED support This patch adds support for LEDs connect to a nvec. A single brightness property is exported to sysfs. LEDs are selected via bitfields in the brightness value. Also the blinking behavior is selected through this method. Vendors may use different values for different HW designs. Signed-off-by: Ilya Petrov Signed-off-by: Marc Dietrich [jak@jak-linux.org: Fixed checkpatch warnings] Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/Kconfig | 6 ++ drivers/staging/nvec/Makefile | 1 + drivers/staging/nvec/nvec.c | 4 ++ drivers/staging/nvec/nvec_kbd.c | 4 +- drivers/staging/nvec/nvec_leds.c | 114 +++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/nvec/nvec_leds.c diff --git a/drivers/staging/nvec/Kconfig b/drivers/staging/nvec/Kconfig index 987ad48ff93..a86cf27ae24 100644 --- a/drivers/staging/nvec/Kconfig +++ b/drivers/staging/nvec/Kconfig @@ -25,3 +25,9 @@ config NVEC_POWER help Say Y to enable support for battery and charger interface for nVidia compliant embedded controllers. + +config NVEC_LEDS + bool "NVEC leds" + depends on MFD_NVEC && LEDS_CLASS + help + Say Y to enable yellow side leds on AC100 or other nVidia tegra nvec leds diff --git a/drivers/staging/nvec/Makefile b/drivers/staging/nvec/Makefile index 4b5fcec1a10..b844d604e3a 100644 --- a/drivers/staging/nvec/Makefile +++ b/drivers/staging/nvec/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_SERIO_NVEC_PS2) += nvec_ps2.o obj-$(CONFIG_MFD_NVEC) += nvec.o obj-$(CONFIG_NVEC_POWER) += nvec_power.o obj-$(CONFIG_KEYBOARD_NVEC) += nvec_kbd.o +obj-$(CONFIG_NVEC_LEDS) += nvec_leds.o diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 69130189798..43a83a953d4 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -63,6 +63,10 @@ static struct mfd_cell nvec_devices[] = { .name = "nvec-power", .id = 2, }, + { + .name = "nvec-leds", + .id = 1, + }, }; int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 06e877cf151..eaaafac6806 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -99,8 +99,8 @@ static int __devinit nvec_kbd_probe(struct platform_device *pdev) keycodes[j++] = extcode_tab_us102[i]; idev = input_allocate_device(); - idev->name = "Tegra nvec keyboard"; - idev->phys = "i2c3_slave/nvec"; + idev->name = "nvec keyboard"; + idev->phys = "nvec"; idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_LED); idev->ledbit[0] = BIT_MASK(LED_CAPSL); idev->event = nvec_kbd_event; diff --git a/drivers/staging/nvec/nvec_leds.c b/drivers/staging/nvec/nvec_leds.c new file mode 100644 index 00000000000..f4cbcd62500 --- /dev/null +++ b/drivers/staging/nvec/nvec_leds.c @@ -0,0 +1,114 @@ +/* + * nvec_leds: LED driver for a NVIDIA compliant embedded controller + * + * Copyright (C) 2011 The AC100 Kernel Team + * + * Authors: Ilya Petrov + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ + +#include +#include +#include +#include +#include +#include "nvec.h" + +#define to_nvec_led(led_cdev) \ + container_of(led_cdev, struct nvec_led, cdev) + +#define NVEC_LED_REQ {'\x0d', '\x10', '\x45', '\x10', '\x00'} + +#define NVEC_LED_MAX 8 + +struct nvec_led { + struct led_classdev cdev; + struct nvec_chip *nvec; +}; + +static void nvec_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct nvec_led *led = to_nvec_led(led_cdev); + unsigned char buf[] = NVEC_LED_REQ; + buf[4] = value; + + nvec_write_async(led->nvec, buf, sizeof(buf)); + + led->cdev.brightness = value; + +} + +static int __devinit nvec_led_probe(struct platform_device *pdev) +{ + struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); + struct nvec_led *led; + int ret = 0; + + led = kzalloc(sizeof(*led), GFP_KERNEL); + if (led == NULL) + return -ENOMEM; + + led->cdev.max_brightness = NVEC_LED_MAX; + + led->cdev.brightness_set = nvec_led_brightness_set; + led->cdev.name = "nvec-led"; + led->cdev.flags |= LED_CORE_SUSPENDRESUME; + led->nvec = nvec; + + platform_set_drvdata(pdev, led); + + ret = led_classdev_register(&pdev->dev, &led->cdev); + if (ret < 0) + goto err_led; + + /* to expose the default value to userspace */ + led->cdev.brightness = 0; + + return 0; + +err_led: + kfree(led); + return ret; +} + +static int __devexit nvec_led_remove(struct platform_device *pdev) +{ + struct nvec_led *led = platform_get_drvdata(pdev); + + led_classdev_unregister(&led->cdev); + kfree(led); + return 0; +} + +static struct platform_driver nvec_led_driver = { + .probe = nvec_led_probe, + .remove = __devexit_p(nvec_led_remove), + .driver = { + .name = "nvec-leds", + .owner = THIS_MODULE, + }, +}; + +static int __init nvec_led_init(void) +{ + return platform_driver_register(&nvec_led_driver); +} + +module_init(nvec_led_init); + +static void __exit nvec_led_exit(void) +{ + platform_driver_unregister(&nvec_led_driver); +} + +module_exit(nvec_led_exit); + +MODULE_AUTHOR("Ilya Petrov "); +MODULE_DESCRIPTION("Tegra NVEC LED driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:nvec-leds"); From 8cdeff497a5279c0dc754c639cad83b8120810b6 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:45 +0200 Subject: [PATCH 1188/1519] staging: nvec: update ToDo list Mostly small stuff only. Hopefully completed during the next release cycle. Signed-off-by: Marc Dietrich [jak@jak-linux.org: Removed some items no longer valid] Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/TODO | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/nvec/TODO b/drivers/staging/nvec/TODO index 623e9bb0b40..f950ab890e2 100644 --- a/drivers/staging/nvec/TODO +++ b/drivers/staging/nvec/TODO @@ -5,3 +5,8 @@ ToDo list (incomplete, unordered) where conn is either NULL if the device only has one clock, or the device specific name if it has multiple clocks. - move half of the nvec init stuff to i2c-tegra.c + - move event handling to nvec_events + - finish suspend/resume support + - modifiy the sync_write method to return the received + message in a variable (and return the error code). + - add support for more device implementations From 7c6b6c7110a2b51d579f791aaaf4878ebf066962 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:46 +0200 Subject: [PATCH 1189/1519] staging: nvec: add MAINTAINERS info This adds the relevant info to the MAINTAINERS file so people can find the right person to blame. Signed-off-by: Marc Dietrich Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4f00a54ba34..fe393cd79f0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6205,6 +6205,12 @@ W: http://www.lirc.org/ S: Odd Fixes F: drivers/staging/lirc/ +STAGING - NVIDIA COMPLIANT EMBEDDED CONTROLLER INTERFACE (nvec) +M: Marc Dietrich +L: ac100@lists.launchpad.net (moderated for non-subscribers) +S: Maintained +F: drivers/staging/nvec/ + STAGING - OLPC SECONDARY DISPLAY CONTROLLER (DCON) M: Andres Salomon M: Chris Ball From b414e2eb3a487c901c6e0c515753fc0905784eac Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:00:47 +0200 Subject: [PATCH 1190/1519] staging: nvec: fix Kconfig dependencies This patch adds config dependencies for the NVEC keyboard, mouse, and power drivers. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/nvec/Kconfig b/drivers/staging/nvec/Kconfig index a86cf27ae24..86a8b8c418c 100644 --- a/drivers/staging/nvec/Kconfig +++ b/drivers/staging/nvec/Kconfig @@ -7,21 +7,21 @@ config MFD_NVEC config KEYBOARD_NVEC bool "Keyboard on nVidia compliant EC" - depends on MFD_NVEC + depends on MFD_NVEC && INPUT=y help Say Y here to enable support for a keyboard connected to a nVidia compliant embedded controller. config SERIO_NVEC_PS2 bool "PS2 on nVidia EC" - depends on MFD_NVEC + depends on MFD_NVEC && MOUSE_PS2 help Say Y here to enable support for a Touchpad / Mouse connected to a nVidia compliant embedded controller. config NVEC_POWER bool "NVEC charger and battery" - depends on MFD_NVEC + depends on MFD_NVEC && POWER_SUPPLY=y help Say Y to enable support for battery and charger interface for nVidia compliant embedded controllers. From 0b1076c4b2a06e517fafbb2b4704f23e69b05386 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:48 +0200 Subject: [PATCH 1191/1519] staging: nvec: Introduce new internal API for msg alloc/free Introduce two new functions nvec_msg_alloc() and nvec_msg_free() that allocate and free message buffers from the internal pool of messages. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 23 +++++++++++++++++++++++ drivers/staging/nvec/nvec.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 43a83a953d4..fb0f51a2b0b 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -91,6 +92,28 @@ static int nvec_status_notifier(struct notifier_block *nb, return NOTIFY_OK; } +static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) +{ + int i; + + for (i = 0; i < NVEC_POOL_SIZE; i++) { + if (atomic_xchg(&nvec->msg_pool[i].used, 1) == 0) { + dev_vdbg(nvec->dev, "INFO: Allocate %i\n", i); + return &nvec->msg_pool[i]; + } + } + + dev_err(nvec->dev, "could not allocate buffer\n"); + + return NULL; +} + +static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) +{ + dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool); + atomic_set(&msg->used, 0); +} + void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size) { diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index fe11225bcec..544080259e2 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -16,9 +16,13 @@ #ifndef __LINUX_MFD_NVEC #define __LINUX_MFD_NVEC +#include #include #include +/* NVEC_POOL_SIZE - Size of the pool in &struct nvec_msg */ +#define NVEC_POOL_SIZE 64 + typedef enum { NVEC_2BYTES, NVEC_3BYTES, @@ -52,6 +56,7 @@ struct nvec_msg { unsigned short size; unsigned short pos; struct list_head node; + atomic_t used; }; struct nvec_subdev { @@ -78,6 +83,7 @@ struct nvec_chip { struct notifier_block nvec_status_notifier; struct work_struct rx_work, tx_work; struct nvec_msg *rx, *tx; + struct nvec_msg msg_pool[NVEC_POOL_SIZE]; /* sync write stuff */ struct semaphore sync_write_mutex; From e7c40851fd7989dad297988b6343f4e3cb687292 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:49 +0200 Subject: [PATCH 1192/1519] staging: nvec: Introduce nvec_gpio_set_value() Introduce nvec_gpio_set_value(), which works like gpio_set_value(), but also creates a debugging message, if that's enabled. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index fb0f51a2b0b..17f5abfcb78 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -114,6 +114,13 @@ static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) atomic_set(&msg->used, 0); } +static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) +{ + dev_dbg(nvec->dev, "GPIO changed from %u to %u\n", + gpio_get_value(nvec->gpio), value); + gpio_set_value(nvec->gpio, value); +} + void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size) { From 8517e879e0d11a277275616b9e1c749afe2fceff Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:50 +0200 Subject: [PATCH 1193/1519] staging: nvec: Add is_event() and size() functions for nvec_msg Add functions nvec_msg_is_event() and nvec_msg_size() which do just what the say: tell whether the message is an event, and getting the size of the message. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 17f5abfcb78..8e97e2d7ac3 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -114,6 +114,37 @@ static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) atomic_set(&msg->used, 0); } +/** + * nvec_msg_is_event - Return %true if @msg is an event + * @msg: A message + */ +static bool nvec_msg_is_event(struct nvec_msg *msg) +{ + return msg->data[0] >> 7; +} + +/** + * nvec_msg_size - Get the size of a message + * @msg: The message to get the size for + * + * This only works for received messages, not for outgoing messages. + */ +static size_t nvec_msg_size(struct nvec_msg *msg) +{ + bool is_event = nvec_msg_is_event(msg); + int event_length = (msg->data[0] & 0x60) >> 5; + + /* for variable size, payload size in byte 1 + count (1) + cmd (1) */ + if (!is_event || event_length == NVEC_VAR_SIZE) + return (msg->pos || msg->size) ? (msg->data[1] + 2) : 0; + else if (event_length == NVEC_2BYTES) + return 2; + else if (event_length == NVEC_3BYTES) + return 3; + else + return 0; +} + static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) { dev_dbg(nvec->dev, "GPIO changed from %u to %u\n", From 0cab4cb8526d7367c912c9a871d3ad1a9ac1fbf0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:51 +0200 Subject: [PATCH 1194/1519] staging: nvec: Rewrite the interrupt handler Rewrite the interrupt handler to use a state machine similar to that found in the various kernels for the Advent Vega. This also changes the code to use the new functions introduced in the previous commits. This also merges the rewrite sent in August 2011 by Marc Dietrich, and thus also includes code by him. His original patch can be found on the mailing list. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 407 ++++++++++++++++++++++---------- drivers/staging/nvec/nvec.h | 58 ++--- drivers/staging/nvec/nvec_kbd.c | 2 +- 3 files changed, 316 insertions(+), 151 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 8e97e2d7ac3..1a120c1418e 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -155,27 +155,81 @@ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size) { - struct nvec_msg *msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); + struct nvec_msg *msg; + unsigned long flags; - msg->data = kzalloc(size, GFP_NOWAIT); + msg = nvec_msg_alloc(nvec); msg->data[0] = size; memcpy(msg->data + 1, data, size); msg->size = size + 1; - msg->pos = 0; - INIT_LIST_HEAD(&msg->node); + spin_lock_irqsave(&nvec->tx_lock, flags); list_add_tail(&msg->node, &nvec->tx_data); + spin_unlock_irqrestore(&nvec->tx_lock, flags); - gpio_set_value(nvec->gpio, 0); + queue_work(nvec->wq, &nvec->tx_work); } EXPORT_SYMBOL(nvec_write_async); +struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, + const unsigned char *data, short size) +{ + struct nvec_msg *msg; + + mutex_lock(&nvec->sync_write_mutex); + + nvec->sync_write_pending = (data[1] << 8) + data[0]; + nvec_write_async(nvec, data, size); + + dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", + nvec->sync_write_pending); + if (!(wait_for_completion_timeout(&nvec->sync_write, + msecs_to_jiffies(2000)))) { + dev_warn(nvec->dev, "timeout waiting for sync write to complete\n"); + mutex_unlock(&nvec->sync_write_mutex); + return NULL; + } + + dev_dbg(nvec->dev, "nvec_sync_write: pong!\n"); + + msg = nvec->last_sync_msg; + + mutex_unlock(&nvec->sync_write_mutex); + + return msg; +} +EXPORT_SYMBOL(nvec_write_sync); + +/* TX worker */ static void nvec_request_master(struct work_struct *work) { struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work); + unsigned long flags; + long err; + struct nvec_msg *msg; - if (!list_empty(&nvec->tx_data)) - gpio_set_value(nvec->gpio, 0); + spin_lock_irqsave(&nvec->tx_lock, flags); + while (!list_empty(&nvec->tx_data)) { + msg = list_first_entry(&nvec->tx_data, struct nvec_msg, node); + spin_unlock_irqrestore(&nvec->tx_lock, flags); + nvec_gpio_set_value(nvec, 0); + err = wait_for_completion_interruptible_timeout( + &nvec->ec_transfer, msecs_to_jiffies(5000)); + + if (err == 0) { + dev_warn(nvec->dev, "timeout waiting for ec transfer\n"); + nvec_gpio_set_value(nvec, 1); + msg->pos = 0; + } + + spin_lock_irqsave(&nvec->tx_lock, flags); + + if (err > 0) { + list_del_init(&msg->node); + nvec_msg_free(nvec, msg); + } + } + spin_unlock_irqrestore(&nvec->tx_lock, flags); } static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) @@ -197,143 +251,243 @@ static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) return 0; } -static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, - const unsigned char *data, short size) -{ - down(&nvec->sync_write_mutex); - - nvec->sync_write_pending = (data[1] << 8) + data[0]; - nvec_write_async(nvec, data, size); - - dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", - nvec->sync_write_pending); - wait_for_completion(&nvec->sync_write); - dev_dbg(nvec->dev, "nvec_sync_write: pong!\n"); - - up(&nvec->sync_write_mutex); - - return nvec->last_sync_msg; -} - /* RX worker */ static void nvec_dispatch(struct work_struct *work) { struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work); + unsigned long flags; struct nvec_msg *msg; + spin_lock_irqsave(&nvec->rx_lock, flags); while (!list_empty(&nvec->rx_data)) { msg = list_first_entry(&nvec->rx_data, struct nvec_msg, node); list_del_init(&msg->node); + spin_unlock_irqrestore(&nvec->rx_lock, flags); if (nvec->sync_write_pending == - (msg->data[2] << 8) + msg->data[0]) { + (msg->data[2] << 8) + msg->data[0]) { dev_dbg(nvec->dev, "sync write completed!\n"); nvec->sync_write_pending = 0; nvec->last_sync_msg = msg; complete(&nvec->sync_write); } else { parse_msg(nvec, msg); - if ((!msg) || (!msg->data)) - dev_warn(nvec->dev, - "attempt access zero pointer\n"); - else { - kfree(msg->data); - kfree(msg); - } + nvec_msg_free(nvec, msg); } + spin_lock_irqsave(&nvec->rx_lock, flags); + } + spin_unlock_irqrestore(&nvec->rx_lock, flags); +} + +static void nvec_tx_completed(struct nvec_chip *nvec) +{ + /* We got an END_TRANS, let's skip this, maybe there's an event */ + if (nvec->tx->pos != nvec->tx->size) { + dev_err(nvec->dev, "premature END_TRANS, resending\n"); + nvec->tx->pos = 0; + nvec_gpio_set_value(nvec, 0); + } else { + nvec->state = 0; } } +static void nvec_rx_completed(struct nvec_chip *nvec) +{ + if (nvec->rx->pos != nvec_msg_size(nvec->rx)) + dev_err(nvec->dev, "RX incomplete: Expected %u bytes, got %u\n", + (uint) nvec_msg_size(nvec->rx), + (uint) nvec->rx->pos); + + spin_lock(&nvec->rx_lock); + + /* add the received data to the work list + and move the ring buffer pointer to the next entry */ + list_add_tail(&nvec->rx->node, &nvec->rx_data); + + spin_unlock(&nvec->rx_lock); + + nvec->state = 0; + + if (!nvec_msg_is_event(nvec->rx)) + complete(&nvec->ec_transfer); + + queue_work(nvec->wq, &nvec->rx_work); +} + +/** + * nvec_invalid_flags - Send an error message about invalid flags and jump + * @nvec: The nvec device + * @status: The status flags + * @reset: Whether we shall jump to state 0. + */ +static void nvec_invalid_flags(struct nvec_chip *nvec, unsigned int status, + bool reset) +{ + dev_err(nvec->dev, "unexpected status flags 0x%02x during state %i\n", + status, nvec->state); + if (reset) + nvec->state = 0; +} + +/** + * nvec_tx_set - Set the message to transfer (nvec->tx) + */ +static void nvec_tx_set(struct nvec_chip *nvec) +{ + spin_lock(&nvec->tx_lock); + if (list_empty(&nvec->tx_data)) { + dev_err(nvec->dev, "empty tx - sending no-op\n"); + memcpy(nvec->tx_scratch.data, "\x02\x07\x02", 3); + nvec->tx_scratch.size = 3; + nvec->tx_scratch.pos = 0; + nvec->tx = &nvec->tx_scratch; + list_add_tail(&nvec->tx->node, &nvec->tx_data); + } else { + nvec->tx = list_first_entry(&nvec->tx_data, struct nvec_msg, + node); + nvec->tx->pos = 0; + } + spin_unlock(&nvec->tx_lock); + + dev_dbg(nvec->dev, "Sending message of length %u, command 0x%x\n", + (uint)nvec->tx->size, nvec->tx->data[1]); +} + +/** + * nvec_interrupt - Interrupt handler + * @irq: The IRQ + * @dev: The nvec device + */ static irqreturn_t nvec_interrupt(int irq, void *dev) { unsigned long status; - unsigned long received; - unsigned char to_send; - struct nvec_msg *msg; - struct nvec_chip *nvec = (struct nvec_chip *)dev; - void __iomem *base = nvec->base; + unsigned int received = 0; + unsigned char to_send = 0xff; + const unsigned long irq_mask = I2C_SL_IRQ | END_TRANS | RCVD | RNW; + struct nvec_chip *nvec = dev; + unsigned int state = nvec->state; - status = readl(base + I2C_SL_STATUS); + status = readl(nvec->base + I2C_SL_STATUS); - if (!(status & I2C_SL_IRQ)) { - dev_warn(nvec->dev, "nvec Spurious IRQ\n"); - goto handled; - } - if (status & END_TRANS && !(status & RCVD)) { - nvec->state = NVEC_WAIT; - if (nvec->rx->size > 1) { - list_add_tail(&nvec->rx->node, &nvec->rx_data); - schedule_work(&nvec->rx_work); - } else { - kfree(nvec->rx->data); - kfree(nvec->rx); - } + /* Filter out some errors */ + if ((status & irq_mask) == 0 && (status & ~irq_mask) != 0) { + dev_err(nvec->dev, "unexpected irq mask %lx\n", status); return IRQ_HANDLED; - } else if (status & RNW) { - if (status & RCVD) - udelay(3); - - if (status & RCVD) - nvec->state = NVEC_WRITE; - - if (list_empty(&nvec->tx_data)) { - dev_err(nvec->dev, "nvec empty tx - sending no-op\n"); - to_send = 0x8a; - nvec_write_async(nvec, "\x07\x02", 2); - } else { - msg = - list_first_entry(&nvec->tx_data, struct nvec_msg, - node); - if (msg->pos < msg->size) { - to_send = msg->data[msg->pos]; - msg->pos++; - } else { - dev_err(nvec->dev, "nvec crap! %d\n", - msg->size); - to_send = 0x01; - } - - if (msg->pos >= msg->size) { - list_del_init(&msg->node); - kfree(msg->data); - kfree(msg); - schedule_work(&nvec->tx_work); - nvec->state = NVEC_WAIT; - } - } - writel(to_send, base + I2C_SL_RCVD); - - gpio_set_value(nvec->gpio, 1); - - dev_dbg(nvec->dev, "nvec sent %x\n", to_send); - - goto handled; - } else { - received = readl(base + I2C_SL_RCVD); - - if (status & RCVD) { - writel(0, base + I2C_SL_RCVD); - goto handled; - } - - if (nvec->state == NVEC_WAIT) { - nvec->state = NVEC_READ; - msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); - msg->data = kzalloc(32, GFP_NOWAIT); - INIT_LIST_HEAD(&msg->node); - nvec->rx = msg; - } else - msg = nvec->rx; - - BUG_ON(msg->pos > 32); - - msg->data[msg->pos] = received; - msg->pos++; - msg->size = msg->pos; - dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", - received, msg->pos); } -handled: + if ((status & I2C_SL_IRQ) == 0) { + dev_err(nvec->dev, "Spurious IRQ\n"); + return IRQ_HANDLED; + } + + /* The EC did not request a read, so it send us something, read it */ + if ((status & RNW) == 0) { + received = readl(nvec->base + I2C_SL_RCVD); + if (status & RCVD) + writel(0, nvec->base + I2C_SL_RCVD); + } + + if (status == (I2C_SL_IRQ | RCVD)) + nvec->state = 0; + + switch (nvec->state) { + case 0: /* Verify that its a transfer start, the rest later */ + if (status != (I2C_SL_IRQ | RCVD)) + nvec_invalid_flags(nvec, status, false); + break; + case 1: /* command byte */ + if (status != I2C_SL_IRQ) { + nvec_invalid_flags(nvec, status, true); + } else { + nvec->rx = nvec_msg_alloc(nvec); + nvec->rx->data[0] = received; + nvec->rx->pos = 1; + nvec->state = 2; + } + break; + case 2: /* first byte after command */ + if (status == (I2C_SL_IRQ | RNW | RCVD)) { + udelay(33); + if (nvec->rx->data[0] != 0x01) { + dev_err(nvec->dev, + "Read without prior read command\n"); + nvec->state = 0; + break; + } + nvec_msg_free(nvec, nvec->rx); + nvec->state = 3; + nvec_tx_set(nvec); + BUG_ON(nvec->tx->size < 1); + to_send = nvec->tx->data[0]; + nvec->tx->pos = 1; + } else if (status == (I2C_SL_IRQ)) { + BUG_ON(nvec->rx == NULL); + nvec->rx->data[1] = received; + nvec->rx->pos = 2; + nvec->state = 4; + } else { + nvec_invalid_flags(nvec, status, true); + } + break; + case 3: /* EC does a block read, we transmit data */ + if (status & END_TRANS) { + nvec_tx_completed(nvec); + } else if ((status & RNW) == 0 || (status & RCVD)) { + nvec_invalid_flags(nvec, status, true); + } else if (nvec->tx && nvec->tx->pos < nvec->tx->size) { + to_send = nvec->tx->data[nvec->tx->pos++]; + } else { + dev_err(nvec->dev, "tx buffer underflow on %p (%u > %u)\n", + nvec->tx, + (uint) (nvec->tx ? nvec->tx->pos : 0), + (uint) (nvec->tx ? nvec->tx->size : 0)); + nvec->state = 0; + } + break; + case 4: /* EC does some write, we read the data */ + if ((status & (END_TRANS | RNW)) == END_TRANS) + nvec_rx_completed(nvec); + else if (status & (RNW | RCVD)) + nvec_invalid_flags(nvec, status, true); + else if (nvec->rx && nvec->rx->pos < NVEC_MSG_SIZE) + nvec->rx->data[nvec->rx->pos++] = received; + else + dev_err(nvec->dev, + "RX buffer overflow on %p: " + "Trying to write byte %u of %u\n", + nvec->rx, nvec->rx->pos, NVEC_MSG_SIZE); + break; + default: + nvec->state = 0; + } + + /* If we are told that a new transfer starts, verify it */ + if ((status & (RCVD | RNW)) == RCVD) { + if (received != nvec->i2c_addr) + dev_err(nvec->dev, + "received address 0x%02x, expected 0x%02x\n", + received, nvec->i2c_addr); + nvec->state = 1; + } + + /* Send data if requested, but not on end of transmission */ + if ((status & (RNW | END_TRANS)) == RNW) + writel(to_send, nvec->base + I2C_SL_RCVD); + + /* If we have send the first byte */ + if (status == (I2C_SL_IRQ | RNW | RCVD)) + nvec_gpio_set_value(nvec, 1); + + dev_dbg(nvec->dev, + "Handled: %s 0x%02x, %s 0x%02x in state %u [%s%s%s]\n", + (status & RNW) == 0 ? "received" : "R=", + received, + (status & (RNW | END_TRANS)) ? "sent" : "S=", + to_send, + state, + status & END_TRANS ? " END_TRANS" : "", + status & RCVD ? " RCVD" : "", + status & RNW ? " RNW" : ""); + return IRQ_HANDLED; } @@ -432,6 +586,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) nvec->base = base; nvec->irq = res->start; nvec->i2c_clk = i2c_clk; + nvec->rx = &nvec->msg_pool[0]; /* Set the gpio to low when we've got something to say */ err = gpio_request(nvec->gpio, "nvec gpio"); @@ -441,11 +596,15 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) ATOMIC_INIT_NOTIFIER_HEAD(&nvec->notifier_list); init_completion(&nvec->sync_write); - sema_init(&nvec->sync_write_mutex, 1); - INIT_LIST_HEAD(&nvec->tx_data); + init_completion(&nvec->ec_transfer); + mutex_init(&nvec->sync_write_mutex); + spin_lock_init(&nvec->tx_lock); + spin_lock_init(&nvec->rx_lock); INIT_LIST_HEAD(&nvec->rx_data); + INIT_LIST_HEAD(&nvec->tx_data); INIT_WORK(&nvec->rx_work, nvec_dispatch); INIT_WORK(&nvec->tx_work, nvec_request_master); + nvec->wq = alloc_workqueue("nvec", WQ_NON_REENTRANT, 2); err = request_irq(nvec->irq, nvec_interrupt, 0, "nvec", nvec); if (err) { @@ -473,13 +632,14 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) /* Get Firmware Version */ msg = nvec_write_sync(nvec, EC_GET_FIRMWARE_VERSION, - sizeof(EC_GET_FIRMWARE_VERSION)); + sizeof(EC_GET_FIRMWARE_VERSION)); - dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", - msg->data[4], msg->data[5], msg->data[6], msg->data[7]); + if (msg) { + dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", + msg->data[4], msg->data[5], msg->data[6], msg->data[7]); - kfree(msg->data); - kfree(msg); + nvec_msg_free(nvec, msg); + } ret = mfd_add_devices(nvec->dev, -1, nvec_devices, ARRAY_SIZE(nvec_devices), base, 0); @@ -513,6 +673,7 @@ static int __devexit tegra_nvec_remove(struct platform_device *pdev) free_irq(nvec->irq, &nvec_interrupt); iounmap(nvec->base); gpio_free(nvec->gpio); + destroy_workqueue(nvec->wq); kfree(nvec); return 0; diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index 544080259e2..851d7831a11 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -23,39 +23,36 @@ /* NVEC_POOL_SIZE - Size of the pool in &struct nvec_msg */ #define NVEC_POOL_SIZE 64 -typedef enum { +/* + * NVEC_MSG_SIZE - Maximum size of the data field of &struct nvec_msg. + * + * A message must store up to a SMBus block operation which consists of + * one command byte, one count byte, and up to 32 payload bytes = 34 + * byte. + */ +#define NVEC_MSG_SIZE 34 + +enum { NVEC_2BYTES, NVEC_3BYTES, - NVEC_VAR_SIZE -} nvec_size; + NVEC_VAR_SIZE, +}; -typedef enum { - NOT_REALLY, - YES, - NOT_AT_ALL, -} how_care; - -typedef enum { +enum { NVEC_SYS = 1, NVEC_BAT, NVEC_KBD = 5, NVEC_PS2, NVEC_CNTL, NVEC_KB_EVT = 0x80, - NVEC_PS2_EVT -} nvec_event; - -typedef enum { - NVEC_WAIT, - NVEC_READ, - NVEC_WRITE -} nvec_state; + NVEC_PS2_EVT, +}; struct nvec_msg { - unsigned char *data; + struct list_head node; + unsigned char data[NVEC_MSG_SIZE]; unsigned short size; unsigned short pos; - struct list_head node; atomic_t used; }; @@ -77,24 +74,35 @@ struct nvec_chip { int i2c_addr; void __iomem *base; struct clk *i2c_clk; - nvec_state state; struct atomic_notifier_head notifier_list; struct list_head rx_data, tx_data; struct notifier_block nvec_status_notifier; struct work_struct rx_work, tx_work; - struct nvec_msg *rx, *tx; + struct workqueue_struct *wq; struct nvec_msg msg_pool[NVEC_POOL_SIZE]; + struct nvec_msg *rx; + + struct nvec_msg *tx; + struct nvec_msg tx_scratch; + struct completion ec_transfer; + + spinlock_t tx_lock, rx_lock; /* sync write stuff */ - struct semaphore sync_write_mutex; + struct mutex sync_write_mutex; struct completion sync_write; u16 sync_write_pending; struct nvec_msg *last_sync_msg; + + int state; }; extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size); +extern struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, + const unsigned char *data, short size); + extern int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, unsigned int events); @@ -103,10 +111,6 @@ extern int nvec_unregister_notifier(struct device *dev, struct notifier_block *nb, unsigned int events); -const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, - how_care care_resp, - void (*rt_handler) (unsigned char *data)); - #define I2C_CNFG 0x00 #define I2C_CNFG_PACKET_MODE_EN (1<<10) #define I2C_CNFG_NEW_MASTER_SFM (1<<11) diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index eaaafac6806..167eac09809 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -41,7 +41,7 @@ static int nvec_keys_notifier(struct notifier_block *nb, unsigned char *msg = (unsigned char *)data; if (event_type == NVEC_KB_EVT) { - nvec_size _size = (msg[0] & (3 << 5)) >> 5; + int _size = (msg[0] & (3 << 5)) >> 5; /* power on/off button */ if (_size == NVEC_VAR_SIZE) From 7b77065793b8de101c7be3829b4ff8a4618a7172 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:52 +0200 Subject: [PATCH 1195/1519] staging: nvec: Do not print free message for tx_scratch The scratch area is not part of the pool and thus gets no allocation message. Printing a free message would be confusing, and the pointer subtraction would be undefined behavior. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 1a120c1418e..c3643844a6f 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -110,7 +110,8 @@ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) { - dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool); + if (msg != &nvec->tx_scratch) + dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool); atomic_set(&msg->used, 0); } From 791c4a642721552204d8defdbd6a3e93cd411f79 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:53 +0200 Subject: [PATCH 1196/1519] staging: nvec: Add myself to copyright and authors list Forgotten in the last commit(s) which contained the copyrightable material, so let's add it now. I believe that only my nvec.c contributions are copyrightable, nvec.h is just interface naming, so does not deserve that yet. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index c3643844a6f..fee4ee0b4b6 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -6,6 +6,7 @@ * Authors: Pierre-Hugues Husson * Ilya Petrov * Marc Dietrich + * Julian Andres Klode * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive From ff169c1487381aa522b92b9f0c87bd92577bfc80 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:54 +0200 Subject: [PATCH 1197/1519] staging: nvec: Enable the capslock LED in the keyboard driver When the caps lock key is pressed, toggle the associated LED. According to Nvidia code, we should send 0x01 where we sent 0x07, but this does not appear to work correctly on the AC100. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec_kbd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 167eac09809..a4ce5a740e2 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -23,6 +23,8 @@ #define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} +static const char led_on[3] = "\x05\xed\x07"; +static const char led_off[3] = "\x05\xed\x00"; static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) + ARRAY_SIZE(extcode_tab_us102)]; @@ -30,10 +32,21 @@ struct nvec_keys { struct input_dev *input; struct notifier_block notifier; struct nvec_chip *nvec; + bool caps_lock; }; static struct nvec_keys keys_dev; +static void nvec_kbd_toggle_led(void) +{ + keys_dev.caps_lock = !keys_dev.caps_lock; + + if (keys_dev.caps_lock) + nvec_write_async(keys_dev.nvec, led_on, sizeof(led_on)); + else + nvec_write_async(keys_dev.nvec, led_off, sizeof(led_off)); +} + static int nvec_keys_notifier(struct notifier_block *nb, unsigned long event_type, void *data) { @@ -53,6 +66,9 @@ static int nvec_keys_notifier(struct notifier_block *nb, code = msg[1] & 0x7f; state = msg[1] & 0x80; + if (code_tabs[_size][code] == KEY_CAPSLOCK && state) + nvec_kbd_toggle_led(); + input_report_key(keys_dev.input, code_tabs[_size][code], !state); input_sync(keys_dev.input); @@ -133,6 +149,9 @@ static int __devinit nvec_kbd_probe(struct platform_device *pdev) or until we have a sync write */ mdelay(1000); + /* Disable caps lock LED */ + nvec_write_async(nvec, led_off, sizeof(led_off)); + return 0; fail: From 1b9bf629ea42fdacd951b9190f86b028557bbe19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:55 +0200 Subject: [PATCH 1198/1519] staging: nvec: Have nvec_write_async() return -ENOMEM on OOM Change nvec_write_async() to return an integer, 0 by default, a negative error on failure. Change nvec_write_sync() to check the return value and abort if it is negative. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 11 +++++++++-- drivers/staging/nvec/nvec.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index fee4ee0b4b6..dc3c0c64ed8 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -154,13 +154,16 @@ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) gpio_set_value(nvec->gpio, value); } -void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, +int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size) { struct nvec_msg *msg; unsigned long flags; msg = nvec_msg_alloc(nvec); + if (msg == NULL) + return -ENOMEM; + msg->data[0] = size; memcpy(msg->data + 1, data, size); msg->size = size + 1; @@ -170,6 +173,8 @@ void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, spin_unlock_irqrestore(&nvec->tx_lock, flags); queue_work(nvec->wq, &nvec->tx_work); + + return 0; } EXPORT_SYMBOL(nvec_write_async); @@ -181,7 +186,9 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, mutex_lock(&nvec->sync_write_mutex); nvec->sync_write_pending = (data[1] << 8) + data[0]; - nvec_write_async(nvec, data, size); + + if (nvec_write_async(nvec, data, size) < 0) + return NULL; dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", nvec->sync_write_pending); diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index 851d7831a11..a39cfc15b4c 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -97,7 +97,7 @@ struct nvec_chip { int state; }; -extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, +extern int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size); extern struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, From bdf034d98676d143cb88f7b999a71fff5775fcd4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:56 +0200 Subject: [PATCH 1199/1519] staging: nvec: Document public and private API Add kernel-doc comments describing the functions and structs we currently have. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 109 +++++++++++++++++++++++++++++++++++- drivers/staging/nvec/nvec.h | 86 +++++++++++++++++++++++++++- 2 files changed, 191 insertions(+), 4 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index dc3c0c64ed8..057c8889ff0 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -71,6 +71,15 @@ static struct mfd_cell nvec_devices[] = { }, }; +/** + * nvec_register_notifier - Register a notifier with nvec + * @nvec: A &struct nvec_chip + * @nb: The notifier block to register + * + * Registers a notifier with @nvec. The notifier will be added to an atomic + * notifier chain that is called for all received messages except those that + * correspond to a request initiated by nvec_write_sync(). + */ int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, unsigned int events) { @@ -78,6 +87,12 @@ int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, } EXPORT_SYMBOL_GPL(nvec_register_notifier); +/** + * nvec_status_notifier - The final notifier + * + * Prints a message about control events not handled in the notifier + * chain. + */ static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type, void *data) { @@ -93,6 +108,14 @@ static int nvec_status_notifier(struct notifier_block *nb, return NOTIFY_OK; } +/** + * nvec_msg_alloc: + * @nvec: A &struct nvec_chip + * + * Allocate a single &struct nvec_msg object from the message pool of + * @nvec. The result shall be passed to nvec_msg_free() if no longer + * used. + */ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) { int i; @@ -109,6 +132,13 @@ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) return NULL; } +/** + * nvec_msg_free: + * @nvec: A &struct nvec_chip + * @msg: A message (must be allocated by nvec_msg_alloc() and belong to @nvec) + * + * Free the given message + */ static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) { if (msg != &nvec->tx_scratch) @@ -147,6 +177,13 @@ static size_t nvec_msg_size(struct nvec_msg *msg) return 0; } +/** + * nvec_gpio_set_value - Set the GPIO value + * @nvec: A &struct nvec_chip + * @value: The value to write (0 or 1) + * + * Like gpio_set_value(), but generating debugging information + */ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) { dev_dbg(nvec->dev, "GPIO changed from %u to %u\n", @@ -154,6 +191,18 @@ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) gpio_set_value(nvec->gpio, value); } +/** + * nvec_write_async - Asynchronously write a message to NVEC + * @nvec: An nvec_chip instance + * @data: The message data, starting with the request type + * @size: The size of @data + * + * Queue a single message to be transferred to the embedded controller + * and return immediately. + * + * Returns: 0 on success, a negative error code on failure. If a failure + * occured, the nvec driver may print an error. + */ int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, short size) { @@ -178,6 +227,20 @@ int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, } EXPORT_SYMBOL(nvec_write_async); +/** + * nvec_write_sync - Write a message to nvec and read the response + * @nvec: An &struct nvec_chip + * @data: The data to write + * @size: The size of @data + * + * This is similar to nvec_write_async(), but waits for the + * request to be answered before returning. This function + * uses a mutex and can thus not be called from e.g. + * interrupt handlers. + * + * Returns: A pointer to the response message on success, + * %NULL on failure. + */ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, const unsigned char *data, short size) { @@ -209,7 +272,14 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, } EXPORT_SYMBOL(nvec_write_sync); -/* TX worker */ +/** + * nvec_request_master - Process outgoing messages + * @work: A &struct work_struct (the tx_worker member of &struct nvec_chip) + * + * Processes all outgoing requests by sending the request and awaiting the + * response, then continuing with the next request. Once a request has a + * matching response, it will be freed and removed from the list. + */ static void nvec_request_master(struct work_struct *work) { struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work); @@ -241,6 +311,14 @@ static void nvec_request_master(struct work_struct *work) spin_unlock_irqrestore(&nvec->tx_lock, flags); } +/** + * parse_msg - Print some information and call the notifiers on an RX message + * @nvec: A &struct nvec_chip + * @msg: A message received by @nvec + * + * Paarse some pieces of the message and then call the chain of notifiers + * registered via nvec_register_notifier. + */ static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) { if ((msg->data[0] & 1 << 7) == 0 && msg->data[3]) { @@ -260,7 +338,13 @@ static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) return 0; } -/* RX worker */ +/** + * nvec_dispatch - Process messages received from the EC + * @work: A &struct work_struct (the tx_worker member of &struct nvec_chip) + * + * Process messages previously received from the EC and put into the RX + * queue of the &struct nvec_chip instance associated with @work. + */ static void nvec_dispatch(struct work_struct *work) { struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work); @@ -288,6 +372,12 @@ static void nvec_dispatch(struct work_struct *work) spin_unlock_irqrestore(&nvec->rx_lock, flags); } +/** + * nvec_tx_completed - Complete the current transfer + * @nvec: A &struct nvec_chip + * + * This is called when we have received an END_TRANS on a TX transfer. + */ static void nvec_tx_completed(struct nvec_chip *nvec) { /* We got an END_TRANS, let's skip this, maybe there's an event */ @@ -300,6 +390,12 @@ static void nvec_tx_completed(struct nvec_chip *nvec) } } +/** + * nvec_rx_completed - Complete the current transfer + * @nvec: A &struct nvec_chip + * + * This is called when we have received an END_TRANS on a RX transfer. + */ static void nvec_rx_completed(struct nvec_chip *nvec) { if (nvec->rx->pos != nvec_msg_size(nvec->rx)) @@ -340,6 +436,11 @@ static void nvec_invalid_flags(struct nvec_chip *nvec, unsigned int status, /** * nvec_tx_set - Set the message to transfer (nvec->tx) + * @nvec: A &struct nvec_chip + * + * Gets the first entry from the tx_data list of @nvec and sets the + * tx member to it. If the tx_data list is empty, this uses the + * tx_scratch message to send a no operation message. */ static void nvec_tx_set(struct nvec_chip *nvec) { @@ -366,6 +467,10 @@ static void nvec_tx_set(struct nvec_chip *nvec) * nvec_interrupt - Interrupt handler * @irq: The IRQ * @dev: The nvec device + * + * Interrupt handler that fills our RX buffers and empties our TX + * buffers. This uses a finite state machine with ridiculous amounts + * of error checking, in order to be fairly reliable. */ static irqreturn_t nvec_interrupt(int irq, void *dev) { diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index a39cfc15b4c..d1e4f57f851 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -6,6 +6,7 @@ * Authors: Pierre-Hugues Husson * Ilya Petrov * Marc Dietrich + * Julian Andres Klode * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive @@ -32,13 +33,37 @@ */ #define NVEC_MSG_SIZE 34 -enum { +/** + * enum nvec_event_size - The size of an event message + * @NVEC_2BYTES: The message has one command byte and one data byte + * @NVEC_3BYTES: The message has one command byte and two data bytes + * @NVEC_VAR_SIZE: The message has one command byte, one count byte, and as + * up to as many bytes as the number in the count byte. The + * maximum is 32 + * + * Events can be fixed or variable sized. This is useless on other message + * types, which are always variable sized. + */ +enum nvec_event_size { NVEC_2BYTES, NVEC_3BYTES, NVEC_VAR_SIZE, }; -enum { +/** + * enum nvec_msg_type - The type of a message + * @NVEC_SYS: A system request/response + * @NVEC_BAT: A battery request/response + * @NVEC_KBD: A keyboard request/response + * @NVEC_PS2: A mouse request/response + * @NVEC_CNTL: A EC control request/response + * @NVEC_KB_EVT: An event from the keyboard + * @NVEC_PS2_EVT: An event from the mouse + * + * Events can be fixed or variable sized. This is useless on other message + * types, which are always variable sized. + */ +enum nvec_msg_type { NVEC_SYS = 1, NVEC_BAT, NVEC_KBD = 5, @@ -48,6 +73,19 @@ enum { NVEC_PS2_EVT, }; +/** + * struct nvec_msg - A buffer for a single message + * @node: Messages are part of various lists in a &struct nvec_chip + * @data: The data of the message + * @size: For TX messages, the number of bytes used in @data + * @pos: For RX messages, the current position to write to. For TX messages, + * the position to read from. + * @used: Used for the message pool to mark a message as free/allocated. + * + * This structure is used to hold outgoing and incoming messages. Outgoing + * messages have a different format than incoming messages, and that is not + * documented yet. + */ struct nvec_msg { struct list_head node; unsigned char data[NVEC_MSG_SIZE]; @@ -56,17 +94,61 @@ struct nvec_msg { atomic_t used; }; +/** + * struct nvec_subdev - A subdevice of nvec, such as nvec_kbd + * @name: The name of the sub device + * @platform_data: Platform data + * @id: Identifier of the sub device + */ struct nvec_subdev { const char *name; void *platform_data; int id; }; +/** + * struct nvec_platform_data - platform data for a tegra slave controller + * @i2c_addr: number of i2c slave adapter the ec is connected to + * @gpio: gpio number for the ec request line + * + * Platform data, to be used in board definitions. For an example, take a + * look at the paz00 board in arch/arm/mach-tegra/board-paz00.c + */ struct nvec_platform_data { int i2c_addr; int gpio; }; +/** + * struct nvec_chip - A single connection to an NVIDIA Embedded controller + * @dev: The device + * @gpio: The same as for &struct nvec_platform_data + * @irq: The IRQ of the I2C device + * @i2c_addr: The address of the I2C slave + * @base: The base of the memory mapped region of the I2C device + * @clk: The clock of the I2C device + * @notifier_list: Notifiers to be called on received messages, see + * nvec_register_notifier() + * @rx_data: Received messages that have to be processed + * @tx_data: Messages waiting to be sent to the controller + * @nvec_status_notifier: Internal notifier (see nvec_status_notifier()) + * @rx_work: A work structure for the RX worker nvec_dispatch() + * @tx_work: A work structure for the TX worker nvec_request_master() + * @wq: The work queue in which @rx_work and @tx_work are executed + * @rx: The message currently being retrieved or %NULL + * @msg_pool: A pool of messages for allocation + * @tx: The message currently being transferred + * @tx_scratch: Used for building pseudo messages + * @ec_transfer: A completion that will be completed once a message has been + * received (see nvec_rx_completed()) + * @tx_lock: Spinlock for modifications on @tx_data + * @rx_lock: Spinlock for modifications on @rx_data + * @sync_write_mutex: A mutex for nvec_write_sync() + * @sync_write: A completion to signal that a synchronous message is complete + * @sync_write_pending: The first two bytes of the request (type and subtype) + * @last_sync_msg: The last synchronous message. + * @state: State of our finite state machine used in nvec_interrupt() + */ struct nvec_chip { struct device *dev; int gpio; From 391d2fa95c8e5e5ad3b06af235ce4aeae6514966 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:57 +0200 Subject: [PATCH 1200/1519] staging: nvec: Move implementation-only macros out of the header Those macros are needed only for implementation purposes and do not have any use for other code wishing to use nvec. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 20 ++++++++++++++++++++ drivers/staging/nvec/nvec.h | 21 --------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 057c8889ff0..3fa1c75bda8 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -42,6 +42,26 @@ #include "nvec.h" +#define I2C_CNFG 0x00 +#define I2C_CNFG_PACKET_MODE_EN (1<<10) +#define I2C_CNFG_NEW_MASTER_SFM (1<<11) +#define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12 + +#define I2C_SL_CNFG 0x20 +#define I2C_SL_NEWL (1<<2) +#define I2C_SL_NACK (1<<1) +#define I2C_SL_RESP (1<<0) +#define I2C_SL_IRQ (1<<3) +#define END_TRANS (1<<4) +#define RCVD (1<<2) +#define RNW (1<<1) + +#define I2C_SL_RCVD 0x24 +#define I2C_SL_STATUS 0x28 +#define I2C_SL_ADDR1 0x2c +#define I2C_SL_ADDR2 0x30 +#define I2C_SL_DELAY_COUNT 0x3c + static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00"; static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01"; static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15"; diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index d1e4f57f851..44787535c0e 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -192,25 +192,4 @@ extern int nvec_register_notifier(struct nvec_chip *nvec, extern int nvec_unregister_notifier(struct device *dev, struct notifier_block *nb, unsigned int events); - -#define I2C_CNFG 0x00 -#define I2C_CNFG_PACKET_MODE_EN (1<<10) -#define I2C_CNFG_NEW_MASTER_SFM (1<<11) -#define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12 - -#define I2C_SL_CNFG 0x20 -#define I2C_SL_NEWL (1<<2) -#define I2C_SL_NACK (1<<1) -#define I2C_SL_RESP (1<<0) -#define I2C_SL_IRQ (1<<3) -#define END_TRANS (1<<4) -#define RCVD (1<<2) -#define RNW (1<<1) - -#define I2C_SL_RCVD 0x24 -#define I2C_SL_STATUS 0x28 -#define I2C_SL_ADDR1 0x2c -#define I2C_SL_ADDR2 0x30 -#define I2C_SL_DELAY_COUNT 0x3c - #endif From 198dd26714ba4a60ccc5ce70bc4506613b4f0c2d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:58 +0200 Subject: [PATCH 1201/1519] staging: nvec: Export nvec_msg_free() to clients Client code wishing to make use of nvec_write_sync() must have a way to free the returned pointer, otherwise we run out of poool memory fairly soon. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 6 ++++-- drivers/staging/nvec/nvec.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 3fa1c75bda8..488d7dd78a2 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -159,12 +159,13 @@ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) * * Free the given message */ -static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) +inline void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) { if (msg != &nvec->tx_scratch) dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool); atomic_set(&msg->used, 0); } +EXPORT_SYMBOL_GPL(nvec_msg_free); /** * nvec_msg_is_event - Return %true if @msg is an event @@ -259,7 +260,8 @@ EXPORT_SYMBOL(nvec_write_async); * interrupt handlers. * * Returns: A pointer to the response message on success, - * %NULL on failure. + * %NULL on failure. Free with nvec_msg_free() once no longer + * used. */ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, const unsigned char *data, short size) diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index 44787535c0e..f8ffe0002d1 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -192,4 +192,7 @@ extern int nvec_register_notifier(struct nvec_chip *nvec, extern int nvec_unregister_notifier(struct device *dev, struct notifier_block *nb, unsigned int events); + +extern void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg); + #endif From bb0590e2723eed53b524d61cf011d53fc7280949 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:00:59 +0200 Subject: [PATCH 1202/1519] staging: nvec: Allow TX buffers only in the upper 75% of the pool Allow TX buffers to be allocated only in the upper 75% of the pool to avoid a completely filled buffer preventing the driver from processing responses. This also improves performance, as RX allocations do not require checking buffers allocated for TX unless there are more than 16 incoming messages -- which is highly unlikely. An earlier version used the lower 75% for TX messages, but that was considered to be not that effective due to the overlaps of RX and TX buffers mentioned above. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 488d7dd78a2..c05adcd7fbf 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -62,6 +62,16 @@ #define I2C_SL_ADDR2 0x30 #define I2C_SL_DELAY_COUNT 0x3c +/** + * enum nvec_msg_category - Message categories for nvec_msg_alloc() + * @NVEC_MSG_RX: The message is an incoming message (from EC) + * @NVEC_MSG_TX: The message is an outgoing message (to EC) + */ +enum nvec_msg_category { + NVEC_MSG_RX, + NVEC_MSG_TX, +}; + static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00"; static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01"; static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15"; @@ -131,23 +141,31 @@ static int nvec_status_notifier(struct notifier_block *nb, /** * nvec_msg_alloc: * @nvec: A &struct nvec_chip + * @category: Pool category, see &enum nvec_msg_category * * Allocate a single &struct nvec_msg object from the message pool of * @nvec. The result shall be passed to nvec_msg_free() if no longer * used. + * + * Outgoing messages are placed in the upper 75% of the pool, keeping the + * lower 25% available for RX buffers only. The reason is to prevent a + * situation where all buffers are full and a message is thus endlessly + * retried because the response could never be processed. */ -static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) +static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec, + enum nvec_msg_category category) { - int i; + int i = (category == NVEC_MSG_TX) ? (NVEC_POOL_SIZE / 4) : 0; - for (i = 0; i < NVEC_POOL_SIZE; i++) { + for (; i < NVEC_POOL_SIZE; i++) { if (atomic_xchg(&nvec->msg_pool[i].used, 1) == 0) { dev_vdbg(nvec->dev, "INFO: Allocate %i\n", i); return &nvec->msg_pool[i]; } } - dev_err(nvec->dev, "could not allocate buffer\n"); + dev_err(nvec->dev, "could not allocate %s buffer\n", + (category == NVEC_MSG_TX) ? "TX" : "RX"); return NULL; } @@ -230,7 +248,8 @@ int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, struct nvec_msg *msg; unsigned long flags; - msg = nvec_msg_alloc(nvec); + msg = nvec_msg_alloc(nvec, NVEC_MSG_TX); + if (msg == NULL) return -ENOMEM; @@ -534,7 +553,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) if (status != I2C_SL_IRQ) { nvec_invalid_flags(nvec, status, true); } else { - nvec->rx = nvec_msg_alloc(nvec); + nvec->rx = nvec_msg_alloc(nvec, NVEC_MSG_RX); nvec->rx->data[0] = received; nvec->rx->pos = 1; nvec->state = 2; From 8da798634343de8dbb8c1593923f8368db69f838 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:00 +0200 Subject: [PATCH 1203/1519] staging: nvec: Handle filled up RX buffers If no RX buffer is available in state 1, jump to state 0 again. This will produce an incredible amount of warnings, but it is not supposed to happen anyway. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index c05adcd7fbf..e845f58a8d7 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -554,6 +554,11 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) nvec_invalid_flags(nvec, status, true); } else { nvec->rx = nvec_msg_alloc(nvec, NVEC_MSG_RX); + /* Should not happen in a normal world */ + if (unlikely(nvec->rx == NULL)) { + nvec->state = 0; + break; + } nvec->rx->data[0] = received; nvec->rx->pos = 1; nvec->state = 2; From 210ceb4f68dcc7bede2e3af547abd6f661a7bfda Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:01 +0200 Subject: [PATCH 1204/1519] staging: nvec: Reject incomplete messages Reject incomplete messages, causing the request to be transmitted again. This should fix various problems out there. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index e845f58a8d7..8c01723d681 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -439,11 +439,16 @@ static void nvec_tx_completed(struct nvec_chip *nvec) */ static void nvec_rx_completed(struct nvec_chip *nvec) { - if (nvec->rx->pos != nvec_msg_size(nvec->rx)) + if (nvec->rx->pos != nvec_msg_size(nvec->rx)) { dev_err(nvec->dev, "RX incomplete: Expected %u bytes, got %u\n", (uint) nvec_msg_size(nvec->rx), (uint) nvec->rx->pos); + nvec_msg_free(nvec, nvec->rx); + nvec->state = 0; + return; + } + spin_lock(&nvec->rx_lock); /* add the received data to the work list From ff006d12667153a5ee187c834ac328dfd5afb0a2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:02 +0200 Subject: [PATCH 1205/1519] staging: nvec: Return error in PS2 driver if write fails Return the return value of nvec_write_async() in the methods returning an int. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec_ps2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 67c77551494..c3ba12c7cf8 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -38,8 +38,7 @@ static struct nvec_ps2 ps2_dev; static int ps2_startstreaming(struct serio *ser_dev) { unsigned char buf[] = START_STREAMING; - nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); - return 0; + return nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static void ps2_stopstreaming(struct serio *ser_dev) @@ -55,9 +54,7 @@ static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) buf[2] = cmd & 0xff; dev_dbg(&ser_dev->dev, "Sending ps2 cmd %02x\n", cmd); - nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); - - return 0; + return nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static int nvec_ps2_notifier(struct notifier_block *nb, From 1e46e6273bc62d87c1eb984d2a2b16efa6b19641 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:03 +0200 Subject: [PATCH 1206/1519] staging: nvec: ps2: Always sample 4 bytes instead of just 1 Get 4 bytes of data from nvec at once instead of just a single byte. This makes the driver more similar to nvidias and might improve reliability. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec_ps2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index c3ba12c7cf8..742f5ccfe76 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -21,7 +21,7 @@ #include "nvec.h" -#define START_STREAMING {'\x06', '\x03', '\x01'} +#define START_STREAMING {'\x06', '\x03', '\x04'} #define STOP_STREAMING {'\x06', '\x04'} #define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'} @@ -65,7 +65,8 @@ static int nvec_ps2_notifier(struct notifier_block *nb, switch (event_type) { case NVEC_PS2_EVT: - serio_interrupt(ps2_dev.ser_dev, msg[2], 0); + for (i = 0; i < msg[1]; i++) + serio_interrupt(ps2_dev.ser_dev, msg[2 + i], 0); return NOTIFY_STOP; case NVEC_PS2: From d6bdcf2e1019351cbc176e963b7756766bdd8721 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:04 +0200 Subject: [PATCH 1207/1519] staging: nvec: Add battery quirk to ignore incomplete responses The nvec_power system polls nvec for battery information. In some cases, that part seems to be overloaded and unable to respond fast in which case it sends an incomplete response. We need to mark the transfer as completed, though, in order to prevent endless retries which can kill nvec. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 8c01723d681..a80f9935a3e 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -446,6 +446,11 @@ static void nvec_rx_completed(struct nvec_chip *nvec) nvec_msg_free(nvec, nvec->rx); nvec->state = 0; + + /* Battery quirk - Often incomplete, and likes to crash */ + if (nvec->rx->data[0] == NVEC_BAT) + complete(&nvec->ec_transfer); + return; } From b812538234397adf170ba4e218d35c8e5d0604fd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:05 +0200 Subject: [PATCH 1208/1519] staging: nvec: Add myself to MAINTAINERS I intent to support this code, especially the parts I wrote; and will thus enter as co-maintainer. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index fe393cd79f0..ed3795a15ab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6206,6 +6206,7 @@ S: Odd Fixes F: drivers/staging/lirc/ STAGING - NVIDIA COMPLIANT EMBEDDED CONTROLLER INTERFACE (nvec) +M: Julian Andres Klode M: Marc Dietrich L: ac100@lists.launchpad.net (moderated for non-subscribers) S: Maintained From 12b5a55d725579d0978da67f26577224a1c40640 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:06 +0200 Subject: [PATCH 1209/1519] staging: nvec: Add missing includes and reorder them Add the includes that are currently missing in nvec.h and nvec.c and reorder them alphabetically. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 24 +++++++++++------------- drivers/staging/nvec/nvec.h | 7 ++++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index a80f9935a3e..89153446b37 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -16,29 +16,27 @@ /* #define DEBUG */ -#include - +#include #include +#include #include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include - -#include #include +#include +#include #include #include -#include +#include +#include +#include -#include #include +#include #include "nvec.h" diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index f8ffe0002d1..a4c17b0e10c 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -18,8 +18,13 @@ #define __LINUX_MFD_NVEC #include +#include +#include +#include +#include #include -#include +#include +#include /* NVEC_POOL_SIZE - Size of the pool in &struct nvec_msg */ #define NVEC_POOL_SIZE 64 From de839b8f06bc5dd3f5037c4409a720cbb9bf21c3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Sep 2011 19:01:07 +0200 Subject: [PATCH 1210/1519] staging: nvec: Add a udelay(100) to nvec_interrupt As the comment indicates, adding that udelay seems to improve the stability of the communication, although it is not known why this is the case. Signed-off-by: Julian Andres Klode Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 89153446b37..07c8e0952a2 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -656,6 +656,15 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) status & RCVD ? " RCVD" : "", status & RNW ? " RNW" : ""); + + /* + * TODO: A correct fix needs to be found for this. + * + * We experience less incomplete messages with this delay than without + * it, but we don't know why. Help is appreciated. + */ + udelay(100); + return IRQ_HANDLED; } From 9feeb0147fe6ae3158db5f319faded5e763744f9 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Tue, 27 Sep 2011 19:01:08 +0200 Subject: [PATCH 1211/1519] staging: nvec: send suspend messages synchronously The suspend commands need to be sent using the synchronous method, otherwise the power gets disabled before the messages are transferred. Signed-off-by: Marc Dietrich [jak@jak-linux.org: Rewrote commit message] Signed-off-by: Julian Andres Klode Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 07c8e0952a2..fb0f0959eaf 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -861,10 +861,16 @@ static int __devexit tegra_nvec_remove(struct platform_device *pdev) static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state) { struct nvec_chip *nvec = platform_get_drvdata(pdev); + struct nvec_msg *msg; dev_dbg(nvec->dev, "suspending\n"); - nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3); - nvec_write_async(nvec, "\x04\x02", 2); + + /* keep these sync or you'll break suspend */ + msg = nvec_write_sync(nvec, EC_DISABLE_EVENT_REPORTING, 3); + nvec_msg_free(nvec, msg); + msg = nvec_write_sync(nvec, "\x04\x02", 2); + nvec_msg_free(nvec, msg); + nvec_disable_i2c_slave(nvec); return 0; From 630081fdc94fb71394fc21d6c60772cbb52d04ea Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 Oct 2011 16:02:41 -0700 Subject: [PATCH 1212/1519] MAINTAINERS: the staging tree dropped the "-2.6" suffix Now that we are in the 3.x days, "2.6" doesn't make sense. Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ed3795a15ab..6ae6c53913a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6125,7 +6125,7 @@ S: Maintained STAGING SUBSYSTEM M: Greg Kroah-Hartman -T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6.git +T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git L: devel@driverdev.osuosl.org S: Maintained F: drivers/staging/ From dcacccc54f96aa0863640c90d554f913e438911a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:30 +0100 Subject: [PATCH 1213/1519] staging:iio:adc:ad799x fix incorrect scan_type descriptions. A few of these had the wrong shifts, which would lead to userspace hacking off the top couple of bits. Also, one part had the wrong accuracy. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index b6662dbfbd9..58f70aa6ca1 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -506,16 +506,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7995] = { .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 0), 0), + 0, 0, IIO_ST('u', 10, 16, 2), 0), .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 0), 0), + 1, 1, IIO_ST('u', 10, 16, 2), 0), .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 0), 0), + 2, 2, IIO_ST('u', 10, 16, 2), 0), .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 0), 0), + 3, 3, IIO_ST('u', 10, 16, 2), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), .num_channels = 5, .int_vref_mv = 1024, @@ -524,16 +524,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7999] = { .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 0), 0), + 0, 0, IIO_ST('u', 8, 16, 4), 0), .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 0), 0), + 1, 1, IIO_ST('u', 8, 16, 4), 0), .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 0), 0), + 2, 2, IIO_ST('u', 8, 16, 4), 0), .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 0), 0), + 3, 3, IIO_ST('u', 8, 16, 4), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), .num_channels = 5, .int_vref_mv = 1024, @@ -555,16 +555,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7993] = { .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 0), 0), + 0, 0, IIO_ST('u', 10, 16, 2), 0), .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 0), 0), + 1, 1, IIO_ST('u', 10, 16, 2), 0), .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 0), 0), + 2, 2, IIO_ST('u', 10, 16, 2), 0), .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 0), 0), + 3, 3, IIO_ST('u', 10, 16, 2), 0), .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), .num_channels = 5, .int_vref_mv = 1024, @@ -593,28 +593,28 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7997] = { .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 0), 0), + 0, 0, IIO_ST('u', 10, 16, 2), 0), .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 0), 0), + 1, 1, IIO_ST('u', 10, 16, 2), 0), .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 0), 0), + 2, 2, IIO_ST('u', 10, 16, 2), 0), .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 0), 0), + 3, 3, IIO_ST('u', 10, 16, 2), 0), .channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 4, 4, IIO_ST('u', 10, 16, 0), 0), + 4, 4, IIO_ST('u', 10, 16, 2), 0), .channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 5, 5, IIO_ST('u', 10, 16, 0), 0), + 5, 5, IIO_ST('u', 10, 16, 2), 0), .channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 6, 6, IIO_ST('u', 10, 16, 0), 0), + 6, 6, IIO_ST('u', 10, 16, 2), 0), .channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, (1 << IIO_CHAN_INFO_SCALE_SHARED), - 7, 7, IIO_ST('u', 10, 16, 0), 0), + 7, 7, IIO_ST('u', 10, 16, 2), 0), .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), .num_channels = 9, .int_vref_mv = 1024, From 7c626f58ab0095d7614636cc81f6081426903a37 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:31 +0100 Subject: [PATCH 1214/1519] staging:iio:adc:ad799x stop using IIO_CHAN macro. Preparation for moving driver out of staging. That macro is a nightmare to maintain so it is going away. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 452 +++++++++++++++++++------- 1 file changed, 329 insertions(+), 123 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 58f70aa6ca1..975a3f7122c 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -151,7 +151,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info, mutex_lock(&dev_info->mlock); if (iio_buffer_enabled(dev_info)) ret = ad799x_single_channel_from_ring(st, - chan->address); + chan->scan_index); else ret = ad799x_scan_direct(st, chan->address); mutex_unlock(&dev_info->mlock); @@ -486,167 +486,373 @@ static const struct iio_info ad7993_4_7_8_info = { static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7991] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 12, 16, 0), 0), - .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + }, .num_channels = 5, .int_vref_mv = 4096, .info = &ad7991_info, }, [ad7995] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 2), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 2), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 2), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 2), 0), - .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + }, .num_channels = 5, .int_vref_mv = 1024, .info = &ad7991_info, }, [ad7999] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 8, 16, 4), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 8, 16, 4), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 8, 16, 4), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 8, 16, 4), 0), - .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 8, 16, 4), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 8, 16, 4), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 8, 16, 4), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 8, 16, 4), + }, + [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + }, .num_channels = 5, .int_vref_mv = 1024, .info = &ad7991_info, }, [ad7992] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [2] = IIO_CHAN_SOFT_TIMESTAMP(2), + }, .num_channels = 3, .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, .info = &ad7992_info, }, [ad7993] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 2), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 2), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 2), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 2), 0), - .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + }, .num_channels = 5, .int_vref_mv = 1024, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, [ad7994] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 12, 16, 0), 0), - .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + }, .num_channels = 5, .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, [ad7997] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 10, 16, 2), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 10, 16, 2), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 10, 16, 2), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 10, 16, 2), 0), - .channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 4, 4, IIO_ST('u', 10, 16, 2), 0), - .channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 5, 5, IIO_ST('u', 10, 16, 2), 0), - .channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 6, 6, IIO_ST('u', 10, 16, 2), 0), - .channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 7, 7, IIO_ST('u', 10, 16, 2), 0), - .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [4] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 4, + .address = 4, + .scan_index = 4, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [5] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 5, + .address = 5, + .scan_index = 5, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [6] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 6, + .address = 6, + .scan_index = 6, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [7] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 7, + .address = 7, + .scan_index = 7, + .scan_type = IIO_ST('u', 10, 16, 2), + }, + [8] = IIO_CHAN_SOFT_TIMESTAMP(8), + }, .num_channels = 9, .int_vref_mv = 1024, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, [ad7998] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 12, 16, 0), 0), - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 12, 16, 0), 0), - .channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('u', 12, 16, 0), 0), - .channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('u', 12, 16, 0), 0), - .channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 4, 4, IIO_ST('u', 12, 16, 0), 0), - .channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 5, 5, IIO_ST('u', 12, 16, 0), 0), - .channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 6, 6, IIO_ST('u', 12, 16, 0), 0), - .channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 7, 7, IIO_ST('u', 12, 16, 0), 0), - .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), + .channel = { + [0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [2] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 2, + .address = 2, + .scan_index = 2, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [3] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 3, + .address = 3, + .scan_index = 3, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [4] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 4, + .address = 4, + .scan_index = 4, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [5] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 5, + .address = 5, + .scan_index = 5, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [6] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 6, + .address = 6, + .scan_index = 6, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [7] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 7, + .address = 7, + .scan_index = 7, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + [8] = IIO_CHAN_SOFT_TIMESTAMP(8), + }, .num_channels = 9, .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, From 5357ba3df4af9da111fb351292c9a410b1f7ab0a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:32 +0100 Subject: [PATCH 1215/1519] staging:iio:adc:ad799x trivial: use the convenient chan struct. This is much cleaner than bouncing through the various structures to get to the same thing. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 975a3f7122c..8a7dce05477 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -158,12 +158,11 @@ static int ad799x_read_raw(struct iio_dev *dev_info, if (ret < 0) return ret; - *val = (ret >> st->chip_info->channel[0].scan_type.shift) & - RES_MASK(st->chip_info->channel[0].scan_type.realbits); + *val = (ret >> chan->scan_type.shift) & + RES_MASK(chan->scan_type.realbits); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): - scale_uv = (st->int_vref_mv * 1000) - >> st->chip_info->channel[0].scan_type.realbits; + scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits; *val = scale_uv / 1000; *val2 = (scale_uv % 1000) * 1000; return IIO_VAL_INT_PLUS_MICRO; From 24cba40615aff04a4654db90545d07d41ffa7ba5 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:33 +0100 Subject: [PATCH 1216/1519] staging:iio:adc:ad799x use a table for frequency values rather than big switch. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 74 ++++++--------------------- 1 file changed, 17 insertions(+), 57 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 8a7dce05477..ff902ea6dbb 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -169,7 +169,15 @@ static int ad799x_read_raw(struct iio_dev *dev_info, } return -EINVAL; } - +static const unsigned int ad7998_frequencies[] = { + [AD7998_CYC_DIS] = 0, + [AD7998_CYC_TCONF_32] = 15625, + [AD7998_CYC_TCONF_64] = 7812, + [AD7998_CYC_TCONF_128] = 3906, + [AD7998_CYC_TCONF_512] = 976, + [AD7998_CYC_TCONF_1024] = 488, + [AD7998_CYC_TCONF_2048] = 244, +}; static ssize_t ad799x_read_frequency(struct device *dev, struct device_attribute *attr, char *buf) @@ -177,7 +185,7 @@ static ssize_t ad799x_read_frequency(struct device *dev, struct iio_dev *dev_info = dev_get_drvdata(dev); struct ad799x_state *st = iio_priv(dev_info); - int ret, len = 0; + int ret; u8 val; ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); if (ret) @@ -185,33 +193,7 @@ static ssize_t ad799x_read_frequency(struct device *dev, val &= AD7998_CYC_MASK; - switch (val) { - case AD7998_CYC_DIS: - len = sprintf(buf, "0\n"); - break; - case AD7998_CYC_TCONF_32: - len = sprintf(buf, "15625\n"); - break; - case AD7998_CYC_TCONF_64: - len = sprintf(buf, "7812\n"); - break; - case AD7998_CYC_TCONF_128: - len = sprintf(buf, "3906\n"); - break; - case AD7998_CYC_TCONF_256: - len = sprintf(buf, "1953\n"); - break; - case AD7998_CYC_TCONF_512: - len = sprintf(buf, "976\n"); - break; - case AD7998_CYC_TCONF_1024: - len = sprintf(buf, "488\n"); - break; - case AD7998_CYC_TCONF_2048: - len = sprintf(buf, "244\n"); - break; - } - return len; + return sprintf(buf, "%u\n", ad7998_frequencies[val]); } static ssize_t ad799x_write_frequency(struct device *dev, @@ -223,7 +205,7 @@ static ssize_t ad799x_write_frequency(struct device *dev, struct ad799x_state *st = iio_priv(dev_info); long val; - int ret; + int ret, i; u8 t; ret = strict_strtol(buf, 10, &val); @@ -237,36 +219,14 @@ static ssize_t ad799x_write_frequency(struct device *dev, /* Wipe the bits clean */ t &= ~AD7998_CYC_MASK; - switch (val) { - case 15625: - t |= AD7998_CYC_TCONF_32; - break; - case 7812: - t |= AD7998_CYC_TCONF_64; - break; - case 3906: - t |= AD7998_CYC_TCONF_128; - break; - case 1953: - t |= AD7998_CYC_TCONF_256; - break; - case 976: - t |= AD7998_CYC_TCONF_512; - break; - case 488: - t |= AD7998_CYC_TCONF_1024; - break; - case 244: - t |= AD7998_CYC_TCONF_2048; - break; - case 0: - t |= AD7998_CYC_DIS; - break; - default: + for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) + if (val == ad7998_frequencies[i]) + break; + if (i == ARRAY_SIZE(ad7998_frequencies)) { ret = -EINVAL; goto error_ret_mutex; } - + t |= i; ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); error_ret_mutex: From f2a634291e87bd7b8afa78d018ef9c51647682d8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:34 +0100 Subject: [PATCH 1217/1519] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x.h | 4 ++-- drivers/staging/iio/adc/ad799x_core.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index 98f06f682b8..eda01d5bab7 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h @@ -124,11 +124,11 @@ struct ad799x_platform_data { int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask); #ifdef CONFIG_AD799X_RING_BUFFER -int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum); +int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum); int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad799x_ring_cleanup(struct iio_dev *indio_dev); #else /* CONFIG_AD799X_RING_BUFFER */ -int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum) +int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum) { return -EINVAL; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index ff902ea6dbb..dd279ced6c7 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -150,7 +150,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info, case 0: mutex_lock(&dev_info->mlock); if (iio_buffer_enabled(dev_info)) - ret = ad799x_single_channel_from_ring(st, + ret = ad799x_single_channel_from_ring(dev_info, chan->scan_index); else ret = ad799x_scan_direct(st, chan->address); diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 1bcc168fa76..e3f4698d781 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -23,9 +23,9 @@ #include "ad799x.h" -int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum) +int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum) { - struct iio_buffer *ring = iio_priv_to_dev(st)->buffer; + struct iio_buffer *ring = indio_dev->buffer; int count = 0, ret; u16 *ring_data; From 231c5c3b8b7124f8e399f8ac3651904ec8fa63b8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:35 +0100 Subject: [PATCH 1218/1519] staging:iio:adc:ad799x use the core handling for as much of the events as possible. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 142 +++++++++++++++----------- 1 file changed, 82 insertions(+), 60 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index dd279ced6c7..c56181f9d53 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -235,6 +235,61 @@ error_ret_mutex: return ret ? ret : len; } +static int ad799x_read_event_config(struct iio_dev *dev_info, + u64 event_code) +{ + return 1; +} + +static const u8 ad799x_threshold_addresses[][2] = { + { AD7998_DATALOW_CH1_REG, AD7998_DATAHIGH_CH1_REG }, + { AD7998_DATALOW_CH2_REG, AD7998_DATAHIGH_CH2_REG }, + { AD7998_DATALOW_CH3_REG, AD7998_DATAHIGH_CH3_REG }, + { AD7998_DATALOW_CH4_REG, AD7998_DATAHIGH_CH4_REG }, +}; + +static int ad799x_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_FALLING); + int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_write16(st, + ad799x_threshold_addresses[number][direction], + val); + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static int ad799x_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_FALLING); + int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); + u16 valin; + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_read16(st, + ad799x_threshold_addresses[number][direction], + &valin); + mutex_unlock(&indio_dev->mlock); + if (ret < 0) + return ret; + *val = valin; + + return 0; +} + static ssize_t ad799x_read_channel_config(struct device *dev, struct device_attribute *attr, char *buf) @@ -309,72 +364,24 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) return IRQ_HANDLED; } -static IIO_DEVICE_ATTR(in_voltage0_thresh_low_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATALOW_CH1_REG); - -static IIO_DEVICE_ATTR(in_voltage0_thresh_high_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATAHIGH_CH1_REG); - static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH1_REG); -static IIO_DEVICE_ATTR(in_voltage1_thresh_low_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATALOW_CH2_REG); - -static IIO_DEVICE_ATTR(in_voltage1_thresh_high_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATAHIGH_CH2_REG); - static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH2_REG); -static IIO_DEVICE_ATTR(in_voltage2_thresh_low_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATALOW_CH3_REG); - -static IIO_DEVICE_ATTR(in_voltage2_thresh_high_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATAHIGH_CH3_REG); - static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, ad799x_write_channel_config, AD7998_HYST_CH3_REG); -static IIO_DEVICE_ATTR(in_voltage3_thresh_low_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATALOW_CH4_REG); - -static IIO_DEVICE_ATTR(in_voltage3_thresh_high_value, - S_IRUGO | S_IWUSR, - ad799x_read_channel_config, - ad799x_write_channel_config, - AD7998_DATAHIGH_CH4_REG); - static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw, S_IRUGO | S_IWUSR, ad799x_read_channel_config, @@ -387,17 +394,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); static struct attribute *ad7993_4_7_8_event_attributes[] = { - &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in_voltage2_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage2_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in_voltage3_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage3_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, @@ -410,11 +409,7 @@ static struct attribute_group ad7993_4_7_8_event_attrs_group = { }; static struct attribute *ad7992_event_attributes[] = { - &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, - &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr, - &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr, &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, @@ -434,15 +429,24 @@ static const struct iio_info ad7991_info = { static const struct iio_info ad7992_info = { .read_raw = &ad799x_read_raw, .event_attrs = &ad7992_event_attrs_group, + .read_event_config = &ad799x_read_event_config, + .read_event_value = &ad799x_read_event_value, + .write_event_value = &ad799x_write_event_value, .driver_module = THIS_MODULE, }; static const struct iio_info ad7993_4_7_8_info = { .read_raw = &ad799x_read_raw, .event_attrs = &ad7993_4_7_8_event_attrs_group, + .read_event_config = &ad799x_read_event_config, + .read_event_value = &ad799x_read_event_value, + .write_event_value = &ad799x_write_event_value, .driver_module = THIS_MODULE, }; +#define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) + static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7991] = { .channel = { @@ -573,6 +577,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [1] = { .type = IIO_VOLTAGE, @@ -581,6 +586,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [2] = IIO_CHAN_SOFT_TIMESTAMP(2), }, @@ -598,6 +604,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [1] = { .type = IIO_VOLTAGE, @@ -606,6 +613,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [2] = { .type = IIO_VOLTAGE, @@ -614,6 +622,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [3] = { .type = IIO_VOLTAGE, @@ -622,6 +631,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, @@ -639,6 +649,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [1] = { .type = IIO_VOLTAGE, @@ -647,6 +658,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [2] = { .type = IIO_VOLTAGE, @@ -655,6 +667,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [3] = { .type = IIO_VOLTAGE, @@ -663,6 +676,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, @@ -680,6 +694,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [1] = { .type = IIO_VOLTAGE, @@ -688,6 +703,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [2] = { .type = IIO_VOLTAGE, @@ -696,6 +712,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [3] = { .type = IIO_VOLTAGE, @@ -704,6 +721,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 10, 16, 2), + .event_mask = AD799X_EV_MASK, }, [4] = { .type = IIO_VOLTAGE, @@ -753,6 +771,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [1] = { .type = IIO_VOLTAGE, @@ -761,6 +780,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [2] = { .type = IIO_VOLTAGE, @@ -769,6 +789,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [3] = { .type = IIO_VOLTAGE, @@ -777,6 +798,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 12, 16, 0), + .event_mask = AD799X_EV_MASK, }, [4] = { .type = IIO_VOLTAGE, From b79c9a3c1e9868873d7c60afeeec4bccf0f2deb7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:36 +0100 Subject: [PATCH 1219/1519] staging:iio:adc:ad799x set the device name only once. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index c56181f9d53..19ddd69de93 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -878,7 +878,6 @@ static int __devinit ad799x_probe(struct i2c_client *client, indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = st->chip_info->info; - indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channel; From 58dffaeddd2d59fc78eb2f218fda7cce81c66690 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:37 +0100 Subject: [PATCH 1220/1519] staging:iio:adc:ad799x address and scan_index always match so stop using address Saves on setting the value of address for the simple situation seen in this device. They are already used interchangably to get data from the buffer. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad799x_core.c | 40 +-------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 19ddd69de93..7c42c12d8ee 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -153,7 +153,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info, ret = ad799x_single_channel_from_ring(dev_info, chan->scan_index); else - ret = ad799x_scan_direct(st, chan->address); + ret = ad799x_scan_direct(st, chan->scan_index); mutex_unlock(&dev_info->mlock); if (ret < 0) @@ -454,7 +454,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -462,7 +461,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -470,7 +468,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -478,7 +475,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -494,7 +490,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -502,7 +497,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -510,7 +504,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -518,7 +511,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -534,7 +526,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 8, 16, 4), }, @@ -542,7 +533,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 8, 16, 4), }, @@ -550,7 +540,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 8, 16, 4), }, @@ -558,7 +547,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 8, 16, 4), }, @@ -574,7 +562,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -583,7 +570,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -601,7 +587,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -610,7 +595,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -619,7 +603,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -628,7 +611,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -646,7 +628,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -655,7 +636,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -664,7 +644,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -673,7 +652,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -691,7 +669,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -700,7 +677,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -709,7 +685,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -718,7 +693,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 10, 16, 2), .event_mask = AD799X_EV_MASK, @@ -727,7 +701,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 4, - .address = 4, .scan_index = 4, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -735,7 +708,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 5, - .address = 5, .scan_index = 5, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -743,7 +715,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 6, - .address = 6, .scan_index = 6, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -751,7 +722,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 7, - .address = 7, .scan_index = 7, .scan_type = IIO_ST('u', 10, 16, 2), }, @@ -768,7 +738,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .address = 0, .scan_index = 0, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -777,7 +746,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .address = 1, .scan_index = 1, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -786,7 +754,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .address = 2, .scan_index = 2, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -795,7 +762,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 3, - .address = 3, .scan_index = 3, .scan_type = IIO_ST('u', 12, 16, 0), .event_mask = AD799X_EV_MASK, @@ -804,7 +770,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 4, - .address = 4, .scan_index = 4, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -812,7 +777,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 5, - .address = 5, .scan_index = 5, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -820,7 +784,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 6, - .address = 6, .scan_index = 6, .scan_type = IIO_ST('u', 12, 16, 0), }, @@ -828,7 +791,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { .type = IIO_VOLTAGE, .indexed = 1, .channel = 7, - .address = 7, .scan_index = 7, .scan_type = IIO_ST('u', 12, 16, 0), }, From 50ac23be392c7bc88193247e85baddbcd08150ee Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:38 +0100 Subject: [PATCH 1221/1519] staging:iio:adc:ad7606 add local define for chan_spec structures. IIO_CHAN is being phased out and in this case things are so simple it makes sense to have a local one parameter equivalent. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606_core.c | 82 +++++++++------------------ 1 file changed, 28 insertions(+), 54 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 17cdafbdc37..7ea5232c7ce 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -233,69 +233,43 @@ static const struct attribute_group ad7606_attribute_group = { .is_visible = ad7606_attr_is_visible, }; +#define AD7606_CHANNEL(num) \ + { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = num, \ + .address = num, \ + .scan_index = num, \ + .scan_type = IIO_ST('s', 16, 16, 0), \ + } + static struct iio_chan_spec ad7606_8_channels[] = { - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 4, 4, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 5, 5, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 6, 6, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 7, 7, IIO_ST('s', 16, 16, 0), 0), + AD7606_CHANNEL(0), + AD7606_CHANNEL(1), + AD7606_CHANNEL(2), + AD7606_CHANNEL(3), + AD7606_CHANNEL(4), + AD7606_CHANNEL(5), + AD7606_CHANNEL(6), + AD7606_CHANNEL(7), IIO_CHAN_SOFT_TIMESTAMP(8), }; static struct iio_chan_spec ad7606_6_channels[] = { - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 4, 4, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 5, 5, IIO_ST('s', 16, 16, 0), 0), + AD7606_CHANNEL(0), + AD7606_CHANNEL(1), + AD7606_CHANNEL(2), + AD7606_CHANNEL(3), + AD7606_CHANNEL(4), + AD7606_CHANNEL(5), IIO_CHAN_SOFT_TIMESTAMP(6), }; static struct iio_chan_spec ad7606_4_channels[] = { - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 2, 2, IIO_ST('s', 16, 16, 0), 0), - IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 3, 3, IIO_ST('s', 16, 16, 0), 0), + AD7606_CHANNEL(0), + AD7606_CHANNEL(1), + AD7606_CHANNEL(2), + AD7606_CHANNEL(3), IIO_CHAN_SOFT_TIMESTAMP(4), }; From 0b89525dfcb8b90b5992d6de1433aa04b0a04b3a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:39 +0100 Subject: [PATCH 1222/1519] staging:iio:adc:ad7606 trivial code style fix. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 7ea5232c7ce..02b0a5b1e12 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -329,9 +329,8 @@ static int ad7606_request_gpios(struct ad7606_state *st) } ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array)); - if (!ret) { + if (!ret) st->have_os = true; - } ret = gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW, "AD7606_RESET"); From 68b41aefa30d9b8713d1c255080863e611a5a226 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:40 +0100 Subject: [PATCH 1223/1519] staging:iio:adc:ad7606 make gpio request failures more consistent To my mind, if a gpio is specified in the board file, yet fails to be successfully requested, that is an error condidtion and the driver should not muddle on regardless. This does mean unwinding the gpios on error. Also the free_gpios function is reordered so that it is consistent with the request one (reverse order obviously). This patch is the category of not technically fixing anything, just making the driver be more in line with what a reviewer will expect. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606.h | 5 - drivers/staging/iio/adc/ad7606_core.c | 139 ++++++++++++++++---------- drivers/staging/iio/adc/ad7606_ring.c | 2 +- 3 files changed, 88 insertions(+), 58 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index b8b3d8ef1ff..8fc259f4b3d 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -75,11 +75,6 @@ struct ad7606_state { unsigned range; unsigned oversampling; bool done; - bool have_frstdata; - bool have_os; - bool have_stby; - bool have_reset; - bool have_range; void __iomem *base_address; /* diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 02b0a5b1e12..e762acb8fc2 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -26,7 +26,7 @@ int ad7606_reset(struct ad7606_state *st) { - if (st->have_reset) { + if (gpio_is_valid(st->pdata->gpio_reset)) { gpio_set_value(st->pdata->gpio_reset, 1); ndelay(100); /* t_reset >= 100ns */ gpio_set_value(st->pdata->gpio_reset, 0); @@ -48,7 +48,7 @@ static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned ch) if (ret) goto error_ret; - if (st->have_frstdata) { + if (gpio_is_valid(st->pdata->gpio_frstdata)) { ret = st->bops->read_block(st->dev, 1, st->data); if (ret) goto error_ret; @@ -214,12 +214,14 @@ static mode_t ad7606_attr_is_visible(struct kobject *kobj, mode_t mode = attr->mode; - if (!st->have_os && - (attr == &iio_dev_attr_oversampling_ratio.dev_attr.attr || - attr == - &iio_const_attr_oversampling_ratio_available.dev_attr.attr)) + if (!(gpio_is_valid(st->pdata->gpio_os0) && + gpio_is_valid(st->pdata->gpio_os1) && + gpio_is_valid(st->pdata->gpio_os2)) && + (attr == &iio_dev_attr_oversampling_ratio.dev_attr.attr || + attr == + &iio_const_attr_oversampling_ratio_available.dev_attr.attr)) mode = 0; - else if (!st->have_range && + else if (!gpio_is_valid(st->pdata->gpio_range) && (attr == &iio_dev_attr_in_voltage_range.dev_attr.attr || attr == &iio_const_attr_in_voltage_range_available.dev_attr.attr)) @@ -321,63 +323,96 @@ static int ad7606_request_gpios(struct ad7606_state *st) }; int ret; - ret = gpio_request_one(st->pdata->gpio_convst, GPIOF_OUT_INIT_LOW, - "AD7606_CONVST"); - if (ret) { - dev_err(st->dev, "failed to request GPIO CONVST\n"); - return ret; + if (gpio_is_valid(st->pdata->gpio_convst)) { + ret = gpio_request_one(st->pdata->gpio_convst, + GPIOF_OUT_INIT_LOW, + "AD7606_CONVST"); + if (ret) { + dev_err(st->dev, "failed to request GPIO CONVST\n"); + goto error_ret; + } + } else { + ret = -EIO; + goto error_ret; } - ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array)); - if (!ret) - st->have_os = true; + if (gpio_is_valid(st->pdata->gpio_os0) && + gpio_is_valid(st->pdata->gpio_os1) && + gpio_is_valid(st->pdata->gpio_os2)) { + ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array)); + if (ret < 0) + goto error_free_convst; + } - ret = gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW, - "AD7606_RESET"); - if (!ret) - st->have_reset = true; + if (gpio_is_valid(st->pdata->gpio_reset)) { + ret = gpio_request_one(st->pdata->gpio_reset, + GPIOF_OUT_INIT_LOW, + "AD7606_RESET"); + if (ret < 0) + goto error_free_os; + } - ret = gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT | - ((st->range == 10000) ? GPIOF_INIT_HIGH : - GPIOF_INIT_LOW), "AD7606_RANGE"); - if (!ret) - st->have_range = true; - - ret = gpio_request_one(st->pdata->gpio_stby, GPIOF_OUT_INIT_HIGH, - "AD7606_STBY"); - if (!ret) - st->have_stby = true; + if (gpio_is_valid(st->pdata->gpio_range)) { + ret = gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT | + ((st->range == 10000) ? GPIOF_INIT_HIGH : + GPIOF_INIT_LOW), "AD7606_RANGE"); + if (ret < 0) + goto error_free_reset; + } + if (gpio_is_valid(st->pdata->gpio_stby)) { + ret = gpio_request_one(st->pdata->gpio_stby, + GPIOF_OUT_INIT_HIGH, + "AD7606_STBY"); + if (ret < 0) + goto error_free_range; + } if (gpio_is_valid(st->pdata->gpio_frstdata)) { ret = gpio_request_one(st->pdata->gpio_frstdata, GPIOF_IN, "AD7606_FRSTDATA"); - if (!ret) - st->have_frstdata = true; + if (ret < 0) + goto error_free_stby; } return 0; + +error_free_stby: + if (gpio_is_valid(st->pdata->gpio_stby)) + gpio_free(st->pdata->gpio_stby); +error_free_range: + if (gpio_is_valid(st->pdata->gpio_range)) + gpio_free(st->pdata->gpio_range); +error_free_reset: + if (gpio_is_valid(st->pdata->gpio_reset)) + gpio_free(st->pdata->gpio_reset); +error_free_os: + if (gpio_is_valid(st->pdata->gpio_os0) && + gpio_is_valid(st->pdata->gpio_os1) && + gpio_is_valid(st->pdata->gpio_os2)) + gpio_free_array(gpio_array, ARRAY_SIZE(gpio_array)); +error_free_convst: + gpio_free(st->pdata->gpio_convst); +error_ret: + return ret; } static void ad7606_free_gpios(struct ad7606_state *st) { - if (st->have_range) - gpio_free(st->pdata->gpio_range); - - if (st->have_stby) - gpio_free(st->pdata->gpio_stby); - - if (st->have_os) { - gpio_free(st->pdata->gpio_os0); - gpio_free(st->pdata->gpio_os1); - gpio_free(st->pdata->gpio_os2); - } - - if (st->have_reset) - gpio_free(st->pdata->gpio_reset); - - if (st->have_frstdata) + if (gpio_is_valid(st->pdata->gpio_frstdata)) gpio_free(st->pdata->gpio_frstdata); - + if (gpio_is_valid(st->pdata->gpio_stby)) + gpio_free(st->pdata->gpio_stby); + if (gpio_is_valid(st->pdata->gpio_range)) + gpio_free(st->pdata->gpio_range); + if (gpio_is_valid(st->pdata->gpio_reset)) + gpio_free(st->pdata->gpio_reset); + if (gpio_is_valid(st->pdata->gpio_os0) && + gpio_is_valid(st->pdata->gpio_os1) && + gpio_is_valid(st->pdata->gpio_os2)) { + gpio_free(st->pdata->gpio_os2); + gpio_free(st->pdata->gpio_os1); + gpio_free(st->pdata->gpio_os0); + } gpio_free(st->pdata->gpio_convst); } @@ -531,8 +566,8 @@ void ad7606_suspend(struct iio_dev *indio_dev) { struct ad7606_state *st = iio_priv(indio_dev); - if (st->have_stby) { - if (st->have_range) + if (gpio_is_valid(st->pdata->gpio_stby)) { + if (gpio_is_valid(st->pdata->gpio_range)) gpio_set_value(st->pdata->gpio_range, 1); gpio_set_value(st->pdata->gpio_stby, 0); } @@ -542,8 +577,8 @@ void ad7606_resume(struct iio_dev *indio_dev) { struct ad7606_state *st = iio_priv(indio_dev); - if (st->have_stby) { - if (st->have_range) + if (gpio_is_valid(st->pdata->gpio_stby)) { + if (gpio_is_valid(st->pdata->gpio_range)) gpio_set_value(st->pdata->gpio_range, st->range == 10000); diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index 0b60a6e4d66..f0742d6134f 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -110,7 +110,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) if (buf == NULL) return; - if (st->have_frstdata) { + if (gpio_is_valid(st->pdata->gpio_frstdata)) { ret = st->bops->read_block(st->dev, 1, buf); if (ret) goto done; From 4f5495d0a5c3a4a0174ad8e7eca2ad579d03deff Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:41 +0100 Subject: [PATCH 1224/1519] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv Other than a few slight refactorings the local version was pretty standard so replace it and rework to get rid of st->d_size which it setup. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606.h | 1 - drivers/staging/iio/adc/ad7606_ring.c | 42 +++++---------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index 8fc259f4b3d..bc95f09327a 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -68,7 +68,6 @@ struct ad7606_state { struct regulator *reg; struct work_struct poll_work; wait_queue_head_t wq_data_avail; - size_t d_size; const struct ad7606_bus_ops *bops; int irq; unsigned id; diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index f0742d6134f..20927fd5372 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -42,37 +42,6 @@ error_ret: return ret; } -/** - * ad7606_ring_preenable() setup the parameters of the ring before enabling - * - * The complex nature of the setting of the nuber of bytes per datum is due - * to this driver currently ensuring that the timestamp is stored at an 8 - * byte boundary. - **/ -static int ad7606_ring_preenable(struct iio_dev *indio_dev) -{ - struct ad7606_state *st = iio_priv(indio_dev); - struct iio_buffer *ring = indio_dev->buffer; - size_t d_size; - - d_size = st->chip_info->num_channels * - st->chip_info->channels[0].scan_type.storagebits / 8; - - if (ring->scan_timestamp) { - d_size += sizeof(s64); - - if (d_size % sizeof(s64)) - d_size += sizeof(s64) - (d_size % sizeof(s64)); - } - - if (ring->access->set_bytes_per_datum) - ring->access->set_bytes_per_datum(ring, d_size); - - st->d_size = d_size; - - return 0; -} - /** * ad7606_trigger_handler_th() th/bh of trigger launched polling to ring buffer * @@ -106,7 +75,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) __u8 *buf; int ret; - buf = kzalloc(st->d_size, GFP_KERNEL); + buf = kzalloc(ring->access->get_bytes_per_datum(ring), + GFP_KERNEL); if (buf == NULL) return; @@ -137,8 +107,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) time_ns = iio_get_time_ns(); if (ring->scan_timestamp) - memcpy(buf + st->d_size - sizeof(s64), - &time_ns, sizeof(time_ns)); + *((s64 *)(buf + ring->access->get_bytes_per_datum(ring) - + sizeof(s64))) = time_ns; ring->access->store_to(indio_dev->buffer, buf, time_ns); done: @@ -148,7 +118,7 @@ done: } static const struct iio_buffer_setup_ops ad7606_ring_setup_ops = { - .preenable = &ad7606_ring_preenable, + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; @@ -166,6 +136,8 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) /* Effectively select the ring buffer implementation */ indio_dev->buffer->access = &ring_sw_access_funcs; + indio_dev->buffer->bpe = + st->chip_info->channels[0].scan_type.storagebits / 8; indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh, &ad7606_trigger_handler_th_bh, 0, From 8cbb36a0236954527a8f7b66145f786d09b55ab9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:42 +0100 Subject: [PATCH 1225/1519] staging:iio:adc:ad7606 refactor to remove st->irq and st->id. id wasn't used anywhere and st->irq can be removed by simply passing it into the core remove function (trivially available in the two bus implementations). Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606.h | 4 +--- drivers/staging/iio/adc/ad7606_core.c | 10 ++++------ drivers/staging/iio/adc/ad7606_par.c | 2 +- drivers/staging/iio/adc/ad7606_spi.c | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index bc95f09327a..0d1bb261c79 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -69,8 +69,6 @@ struct ad7606_state { struct work_struct poll_work; wait_queue_head_t wq_data_avail; const struct ad7606_bus_ops *bops; - int irq; - unsigned id; unsigned range; unsigned oversampling; bool done; @@ -94,7 +92,7 @@ void ad7606_resume(struct iio_dev *indio_dev); struct iio_dev *ad7606_probe(struct device *dev, int irq, void __iomem *base_address, unsigned id, const struct ad7606_bus_ops *bops); -int ad7606_remove(struct iio_dev *indio_dev); +int ad7606_remove(struct iio_dev *indio_dev, int irq); int ad7606_reset(struct ad7606_state *st); enum ad7606_supported_device_ids { diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index e762acb8fc2..3c0fb729891 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -459,8 +459,6 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, st = iio_priv(indio_dev); st->dev = dev; - st->id = id; - st->irq = irq; st->bops = bops; st->base_address = base_address; st->range = pdata->default_range == 10000 ? 10000 : 5000; @@ -501,7 +499,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, if (ret) dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n"); - ret = request_irq(st->irq, ad7606_interrupt, + ret = request_irq(irq, ad7606_interrupt, IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev); if (ret) goto error_free_gpios; @@ -527,7 +525,7 @@ error_cleanup_ring: ad7606_ring_cleanup(indio_dev); error_free_irq: - free_irq(st->irq, indio_dev); + free_irq(irq, indio_dev); error_free_gpios: ad7606_free_gpios(st); @@ -543,14 +541,14 @@ error_ret: return ERR_PTR(ret); } -int ad7606_remove(struct iio_dev *indio_dev) +int ad7606_remove(struct iio_dev *indio_dev, int irq) { struct ad7606_state *st = iio_priv(indio_dev); iio_buffer_unregister(indio_dev); ad7606_ring_cleanup(indio_dev); - free_irq(st->irq, indio_dev); + free_irq(irq, indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c index d21218da923..688632edd3d 100644 --- a/drivers/staging/iio/adc/ad7606_par.c +++ b/drivers/staging/iio/adc/ad7606_par.c @@ -106,7 +106,7 @@ static int __devexit ad7606_par_remove(struct platform_device *pdev) struct resource *res; struct ad7606_state *st = iio_priv(indio_dev); - ad7606_remove(indio_dev); + ad7606_remove(indio_dev, platform_get_irq(pdev, 0)); iounmap(st->base_address); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c index 0769c807d95..aede1ba5e04 100644 --- a/drivers/staging/iio/adc/ad7606_spi.c +++ b/drivers/staging/iio/adc/ad7606_spi.c @@ -59,7 +59,7 @@ static int __devexit ad7606_spi_remove(struct spi_device *spi) { struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev); - return ad7606_remove(indio_dev); + return ad7606_remove(indio_dev, spi->irq); } #ifdef CONFIG_PM From 3f0676a874df0585f8b06d09d0e0f0ff55078992 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:43 +0100 Subject: [PATCH 1226/1519] staging:iio:adc:ad7606 remove unused chip info elements. These are now handled through the chan_spec arrays and no one is using them anymore. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index 0d1bb261c79..35018c3f518 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -50,8 +50,6 @@ struct ad7606_platform_data { struct ad7606_chip_info { const char *name; - u8 bits; - char sign; u16 int_vref_mv; struct iio_chan_spec *channels; unsigned num_channels; From 31bf47d518b27291b23728279a695a1f9fd56ce1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:44 +0100 Subject: [PATCH 1227/1519] staging:iio:adc:ad7887 stop using IIO_CHAN macro. It's going away. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7887_core.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 71af6cba763..37e6cc9e5cb 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -71,14 +71,24 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { * More devices added in future */ [ID_AD7887] = { - .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 1, 1, IIO_ST('u', 12, 16, 0), 0), - - .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0, - (1 << IIO_CHAN_INFO_SCALE_SHARED), - 0, 0, IIO_ST('u', 12, 16, 0), 0), - + .channel[0] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 1, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = 1, + .scan_index = 1, + .scan_type = IIO_ST('u', 12, 16, 0), + }, + .channel[1] = { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), + .address = 0, + .scan_index = 0, + .scan_type = IIO_ST('u', 12, 16, 0), + }, .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), .int_vref_mv = 2500, }, From 85da50596db89356524974d78bec0e32952521a8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 30 Sep 2011 10:05:45 +0100 Subject: [PATCH 1228/1519] staging:iio:imu:adis16400 rename adis16344 -> adis16334. Part never existed under that name. Ooops Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/Kconfig | 8 ++++---- drivers/staging/iio/imu/adis16400_core.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig index 2e2fa8c9191..2c2f47de263 100644 --- a/drivers/staging/iio/imu/Kconfig +++ b/drivers/staging/iio/imu/Kconfig @@ -9,9 +9,9 @@ config ADIS16400 select IIO_SW_RING if IIO_BUFFER select IIO_TRIGGER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16300, adis16350, - adis16354, adis16355, adis16360, adis16362, adis16364, adis16365, - adis16400 and adis16405 triaxial inertial sensors (adis16400 series - also have magnetometers). + Say yes here to build support for Analog Devices adis16300, adis16344, + adis16350, adis16354, adis16355, adis16360, adis16362, adis16364, + adis16365, adis16400 and adis16405 triaxial inertial sensors + (adis16400 series also have magnetometers). endmenu diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 0e62d5e81e5..07d5a61eaa7 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -33,7 +33,7 @@ enum adis16400_chip_variant { ADIS16300, - ADIS16344, + ADIS16334, ADIS16350, ADIS16360, ADIS16362, @@ -852,7 +852,7 @@ static struct iio_chan_spec adis16300_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(14) }; -static const struct iio_chan_spec adis16344_channels[] = { +static const struct iio_chan_spec adis16334_channels[] = { { .type = IIO_GYRO, .modified = 1, @@ -944,9 +944,9 @@ static struct adis16400_chip_info adis16400_chips[] = { (1 << ADIS16300_SCAN_INCLI_X) | (1 << ADIS16300_SCAN_INCLI_Y) | (1 << 14), }, - [ADIS16344] = { - .channels = adis16344_channels, - .num_channels = ARRAY_SIZE(adis16344_channels), + [ADIS16334] = { + .channels = adis16334_channels, + .num_channels = ARRAY_SIZE(adis16334_channels), .gyro_scale_micro = 873, .accel_scale_micro = 981, .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) | @@ -1105,7 +1105,7 @@ err_ret: static const struct spi_device_id adis16400_id[] = { {"adis16300", ADIS16300}, - {"adis16344", ADIS16344}, + {"adis16334", ADIS16334}, {"adis16350", ADIS16350}, {"adis16354", ADIS16350}, {"adis16355", ADIS16350}, From eeca83a74fcec80a616e0a71f3c961263084a494 Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Fri, 30 Sep 2011 10:35:35 +0800 Subject: [PATCH 1229/1519] staging: intel_sst: fix compile error include module.h to fix the following compile errors: drivers/staging/intel_sst/intelmid.c:52: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:52: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:52: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR' drivers/staging/intel_sst/intelmid.c:52: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:53: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:53: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:53: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR' drivers/staging/intel_sst/intelmid.c:53: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:54: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:54: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:54: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR' drivers/staging/intel_sst/intelmid.c:54: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:55: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:55: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:55: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR' drivers/staging/intel_sst/intelmid.c:55: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:56: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:56: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:56: warning: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION' drivers/staging/intel_sst/intelmid.c:56: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:57: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:57: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:57: warning: type defaults to 'int' in declaration of 'MODULE_LICENSE' drivers/staging/intel_sst/intelmid.c:57: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:58: error: expected declaration specifiers or '...' before string constant drivers/staging/intel_sst/intelmid.c:58: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:58: warning: type defaults to 'int' in declaration of 'MODULE_SUPPORTED_DEVICE' drivers/staging/intel_sst/intelmid.c:58: warning: function declaration isn't a prototype drivers/staging/intel_sst/intelmid.c:64: error: expected ')' before 'int' drivers/staging/intel_sst/intelmid.c:65: error: expected ')' before string constant drivers/staging/intel_sst/intelmid.c:66: error: expected ')' before numeric constant drivers/staging/intel_sst/intelmid.c:67: error: expected ')' before string constant drivers/staging/intel_sst/intelmid.c:461: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:461: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL' drivers/staging/intel_sst/intelmid.c:461: warning: parameter names (without types) in function declaration drivers/staging/intel_sst/intelmid.c:475: warning: data definition has no type or storage class drivers/staging/intel_sst/intelmid.c:475: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL' drivers/staging/intel_sst/intelmid.c:475: warning: parameter names (without types) in function declaration drivers/staging/intel_sst/intelmid.c: In function 'snd_intelmad_probe': drivers/staging/intel_sst/intelmid.c:859: error: 'THIS_MODULE' undeclared (first use in this function) drivers/staging/intel_sst/intelmid.c:859: error: (Each undeclared identifier is reported only once drivers/staging/intel_sst/intelmid.c:859: error: for each function it appears in.) drivers/staging/intel_sst/intelmid.c: At top level: drivers/staging/intel_sst/intelmid.c:989: error: 'THIS_MODULE' undeclared here (not in a function) Reported-by: Stephen Rothwell Signed-off-by: Lu Guanqun Acked-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/staging/intel_sst/intelmid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/intel_sst/intelmid.c b/drivers/staging/intel_sst/intelmid.c index 25656ad2802..492b660246b 100644 --- a/drivers/staging/intel_sst/intelmid.c +++ b/drivers/staging/intel_sst/intelmid.c @@ -27,6 +27,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include From 748b636c4020286f84362f4a3cfa65a96d5387a5 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 30 Sep 2011 18:06:58 -0400 Subject: [PATCH 1230/1519] staging: add module.h to various iio drivers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since they are assuming it is there implicitly and will fail otherwise with things like: drivers/staging/iio/impedance-analyzer/ad5933.c:816: warning: type defaults to ‘int’ in declaration of ‘MODULE_AUTHOR’ drivers/staging/iio/adc/ad7280a.c:990: warning: type defaults to ‘int’ in declaration of ‘MODULE_AUTHOR’ Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7280a.c | 1 + drivers/staging/iio/impedance-analyzer/ad5933.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 4c67cfea6ed..59581feecd4 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index eab288e5f43..dc0f9835e73 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "../iio.h" From 64fa3ddc34b4f3c9ea11643e5259e8106af9862d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:12 -0700 Subject: [PATCH 1231/1519] staging: brcm80211: remove uncoditional code blocks from brcmsmac Using a block statement to scope function variables is not common in linux kernel development. Browsed through the brcmsmac to remove those. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 9 +- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 31 ++---- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 104 ++++++++---------- 3 files changed, 62 insertions(+), 82 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 2c9ac6db4ff..d6b43ff12d3 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5076,7 +5076,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, { struct brcms_c_info *wlc; uint err = 0; - uint j; + uint i, j; struct brcms_pub *pub; uint n_disabled; @@ -5149,11 +5149,8 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->stf->hw_rxchain); /* pull up some info resulting from the low attach */ - { - int i; - for (i = 0; i < NFIFO; i++) - wlc->core->txavail[i] = wlc->hw->txavail[i]; - } + for (i = 0; i < NFIFO; i++) + wlc->core->txavail[i] = wlc->hw->txavail[i]; brcms_b_hw_etheraddr(wlc->hw, wlc->perm_etheraddr); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 196a595f73e..a26c682abc2 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -1199,12 +1199,7 @@ static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi) void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on) { struct brcms_phy *pi = (struct brcms_phy *) pih; - - { - uint mc; - - mc = R_REG(&pi->regs->maccontrol); - } + (void)R_REG(&pi->regs->maccontrol); if (ISNPHY(pi)) { wlc_phy_switch_radio_nphy(pi, on); @@ -1696,26 +1691,22 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) band, rate); - { + wlc_phy_txpower_sromlimit((struct brcms_phy_pub *) pi, + target_chan, + &mintxpwr, &maxtxpwr, rate); - wlc_phy_txpower_sromlimit((struct brcms_phy_pub *) pi, - target_chan, - &mintxpwr, &maxtxpwr, rate); + maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); - maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); + maxtxpwr = (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; - maxtxpwr = - (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; + maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0; - maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0; + maxtxpwr = min(maxtxpwr, tx_pwr_target[rate]); - maxtxpwr = min(maxtxpwr, tx_pwr_target[rate]); + if (pi->txpwr_percent <= 100) + maxtxpwr = (maxtxpwr * pi->txpwr_percent) / 100; - if (pi->txpwr_percent <= 100) - maxtxpwr = (maxtxpwr * pi->txpwr_percent) / 100; - - tx_pwr_target[rate] = max(maxtxpwr, mintxpwr); - } + tx_pwr_target[rate] = max(maxtxpwr, mintxpwr); tx_pwr_target[rate] = min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 46661b833b8..fdcea56552c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -69,6 +69,14 @@ #define LCN_TEMPSENSE_OFFSET 80812 #define LCN_TEMPSENSE_DEN 2647 +#define LCN_BW_LMT 200 +#define LCN_CUR_LMT 1250 +#define LCN_MULT 1 +#define LCN_VCO_DIV 30 +#define LCN_OFFSET 680 +#define LCN_FACT 490 +#define LCN_CUR_DIV 2640 + #define LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT \ (0 + 8) #define LCNPHY_txgainctrlovrval1_pagain_ovr_val1_MASK \ @@ -1054,21 +1062,17 @@ static int wlc_lcnphy_calc_floor(s16 coeff_x, int type) static void wlc_lcnphy_get_tx_gain(struct brcms_phy *pi, struct lcnphy_txgains *gains) { - u16 dac_gain; + u16 dac_gain, rfgain0, rfgain1; dac_gain = read_phy_reg(pi, 0x439) >> 0; gains->dac_gain = (dac_gain & 0x380) >> 7; - { - u16 rfgain0, rfgain1; + rfgain0 = (read_phy_reg(pi, 0x4b5) & (0xffff << 0)) >> 0; + rfgain1 = (read_phy_reg(pi, 0x4fb) & (0x7fff << 0)) >> 0; - rfgain0 = (read_phy_reg(pi, 0x4b5) & (0xffff << 0)) >> 0; - rfgain1 = (read_phy_reg(pi, 0x4fb) & (0x7fff << 0)) >> 0; - - gains->gm_gain = rfgain0 & 0xff; - gains->pga_gain = (rfgain0 >> 8) & 0xff; - gains->pad_gain = rfgain1 & 0xff; - } + gains->gm_gain = rfgain0 & 0xff; + gains->pga_gain = (rfgain0 >> 8) & 0xff; + gains->pad_gain = rfgain1 & 0xff; } @@ -1634,6 +1638,9 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; u16 loop_bw, d30, setCount; + u8 h29, h28_ten, e30, h30_ten, cp_current; + u16 g30, d28; + ci = &chan_info_2064_lcnphy[0]; rfpll_doubler = 1; @@ -1746,27 +1753,18 @@ wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) write_radio_reg(pi, RADIO_2064_REG042, 0xA3); write_radio_reg(pi, RADIO_2064_REG043, 0x0C); - { - u8 h29, h23, c28, d29, h28_ten, e30, h30_ten, cp_current; - u16 c29, c38, c30, g30, d28; - c29 = loop_bw; - d29 = 200; - c38 = 1250; - h29 = d29 / c29; - h23 = 1; - c28 = 30; - d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * - (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / - (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) - + PLL_2064_LOW_END_KVCO; - h28_ten = (d28 * 10) / c28; - c30 = 2640; - e30 = (d30 - 680) / 490; - g30 = 680 + (e30 * 490); - h30_ten = (g30 * 10) / c30; - cp_current = ((c38 * h29 * h23 * 100) / h28_ten) / h30_ten; - mod_radio_reg(pi, RADIO_2064_REG03C, 0x3f, cp_current); - } + h29 = LCN_BW_LMT / loop_bw; + d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * + (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / + (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) + + PLL_2064_LOW_END_KVCO; + h28_ten = (d28 * 10) / LCN_VCO_DIV; + e30 = (d30 - LCN_OFFSET) / LCN_FACT; + g30 = LCN_OFFSET + (e30 * LCN_FACT); + h30_ten = (g30 * 10) / LCN_CUR_DIV; + cp_current = ((LCN_CUR_LMT * h29 * LCN_MULT * 100) / h28_ten) / h30_ten; + mod_radio_reg(pi, RADIO_2064_REG03C, 0x3f, cp_current); + if (channel >= 1 && channel <= 5) write_radio_reg(pi, RADIO_2064_REG03C, 0x8); else @@ -4838,18 +4836,13 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi_lcn->lcnphy_rssi_vc = (u8) PHY_GETINTVAR(pi, "rssismc2g"); pi_lcn->lcnphy_rssi_gs = (u8) PHY_GETINTVAR(pi, "rssisav2g"); - { - pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; - pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; - pi_lcn->lcnphy_rssi_gs_lowtemp = pi_lcn->lcnphy_rssi_gs; + pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; + pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; + pi_lcn->lcnphy_rssi_gs_lowtemp = pi_lcn->lcnphy_rssi_gs; - pi_lcn->lcnphy_rssi_vf_hightemp = - pi_lcn->lcnphy_rssi_vf; - pi_lcn->lcnphy_rssi_vc_hightemp = - pi_lcn->lcnphy_rssi_vc; - pi_lcn->lcnphy_rssi_gs_hightemp = - pi_lcn->lcnphy_rssi_gs; - } + pi_lcn->lcnphy_rssi_vf_hightemp = pi_lcn->lcnphy_rssi_vf; + pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc; + pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs; txpwr = (s8) PHY_GETINTVAR(pi, "maxp2ga0"); pi->tx_srom_max_2g = txpwr; @@ -5098,6 +5091,8 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) s32 log_val, gain_mismatch, desired_gain, input_power_offset_db, input_power_db; s32 received_power, temperature; + u32 power; + u32 msb1, msb2, val1, val2, diff1, diff2; uint freq; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; @@ -5107,20 +5102,17 @@ s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) nominal_power_db = read_phy_reg(pi, 0x425) >> 8; - { - u32 power = (received_power * 16); - u32 msb1, msb2, val1, val2, diff1, diff2; - msb1 = ffs(power) - 1; - msb2 = msb1 + 1; - val1 = 1 << msb1; - val2 = 1 << msb2; - diff1 = (power - val1); - diff2 = (val2 - power); - if (diff1 < diff2) - log_val = msb1; - else - log_val = msb2; - } + power = (received_power * 16); + msb1 = ffs(power) - 1; + msb2 = msb1 + 1; + val1 = 1 << msb1; + val2 = 1 << msb2; + diff1 = (power - val1); + diff2 = (val2 - power); + if (diff1 < diff2) + log_val = msb1; + else + log_val = msb2; log_val = log_val * 3; From b65e0fdb103122b932fad95207c03c2cc407b20d Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:13 -0700 Subject: [PATCH 1232/1519] staging: brcm80211: removed unused argument from softmac functions Parameter 's2' was unused. Affected function was only used internally to main.c and has been made static and moved above its callers. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 380 +++++++++++----------- drivers/staging/brcm80211/brcmsmac/main.h | 2 - 2 files changed, 188 insertions(+), 194 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d6b43ff12d3..d160212581a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -830,9 +830,193 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) return n >= bound_limit; } +static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) +{ + if (tx) { + /* the post-increment is used in STAY_AWAKE macro */ + if (wlc->txpend16165war++ == 0) + brcms_c_set_ps_ctrl(wlc); + } else { + wlc->txpend16165war--; + if (wlc->txpend16165war == 0) + brcms_c_set_ps_ctrl(wlc); + } +} + +/* process an individual struct tx_status */ static bool -brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, - u32 s2) +brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) +{ + struct sk_buff *p; + uint queue; + struct d11txh *txh; + struct scb *scb = NULL; + bool free_pdu; + int tx_rts, tx_frame_count, tx_rts_count; + uint totlen, supr_status; + bool lastframe; + struct ieee80211_hdr *h; + u16 mcl; + struct ieee80211_tx_info *tx_info; + struct ieee80211_tx_rate *txrate; + int i; + + /* discard intermediate indications for ucode with one legitimate case: + * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, + * but the subsequent tx of DATA failed. so it will start rts/cts + * from the beginning (resetting the rts transmission count) + */ + if (!(txs->status & TX_STATUS_AMPDU) + && (txs->status & TX_STATUS_INTERMEDIATE)) { + wiphy_err(wlc->wiphy, "%s: INTERMEDIATE but not AMPDU\n", + __func__); + return false; + } + + queue = txs->frameid & TXFID_QUEUE_MASK; + if (queue >= NFIFO) { + p = NULL; + goto fatal; + } + + p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); + if (wlc->war16165) + brcms_c_war16165(wlc, false); + if (p == NULL) + goto fatal; + + txh = (struct d11txh *) (p->data); + mcl = le16_to_cpu(txh->MacTxControlLow); + + if (txs->phyerr) { + if (brcm_msg_level & LOG_ERROR_VAL) { + wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n", + txs->phyerr, txh->MainRates); + brcms_c_print_txdesc(txh); + } + brcms_c_print_txstatus(txs); + } + + if (txs->frameid != cpu_to_le16(txh->TxFrameID)) + goto fatal; + tx_info = IEEE80211_SKB_CB(p); + h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); + + if (tx_info->control.sta) + scb = (struct scb *)tx_info->control.sta->drv_priv; + + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { + brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); + return false; + } + + supr_status = txs->status & TX_STATUS_SUPR_MASK; + if (supr_status == TX_STATUS_SUPR_BADCH) + BCMMSG(wlc->wiphy, + "%s: Pkt tx suppressed, possibly channel %d\n", + __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); + + tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS; + tx_frame_count = + (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; + tx_rts_count = + (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT; + + lastframe = !ieee80211_has_morefrags(h->frame_control); + + if (!lastframe) { + wiphy_err(wlc->wiphy, "Not last frame!\n"); + } else { + /* + * Set information to be consumed by Minstrel ht. + * + * The "fallback limit" is the number of tx attempts a given + * MPDU is sent at the "primary" rate. Tx attempts beyond that + * limit are sent at the "secondary" rate. + * A 'short frame' does not exceed RTS treshold. + */ + u16 sfbl, /* Short Frame Rate Fallback Limit */ + lfbl, /* Long Frame Rate Fallback Limit */ + fbl; + + if (queue < AC_COUNT) { + sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], + EDCF_SFB); + lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], + EDCF_LFB); + } else { + sfbl = wlc->SFBL; + lfbl = wlc->LFBL; + } + + txrate = tx_info->status.rates; + if (txrate[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) + fbl = lfbl; + else + fbl = sfbl; + + ieee80211_tx_info_clear_status(tx_info); + + if ((tx_frame_count > fbl) && (txrate[1].idx >= 0)) { + /* + * rate selection requested a fallback rate + * and we used it + */ + txrate[0].count = fbl; + txrate[1].count = tx_frame_count - fbl; + } else { + /* + * rate selection did not request fallback rate, or + * we didn't need it + */ + txrate[0].count = tx_frame_count; + /* + * rc80211_minstrel.c:minstrel_tx_status() expects + * unused rates to be marked with idx = -1 + */ + txrate[1].idx = -1; + txrate[1].count = 0; + } + + /* clear the rest of the rates */ + for (i = 2; i < IEEE80211_TX_MAX_RATES; i++) { + txrate[i].idx = -1; + txrate[i].count = 0; + } + + if (txs->status & TX_STATUS_ACK_RCV) + tx_info->flags |= IEEE80211_TX_STAT_ACK; + } + + totlen = brcmu_pkttotlen(p); + free_pdu = true; + + brcms_c_txfifo_complete(wlc, queue, 1); + + if (lastframe) { + p->next = NULL; + p->prev = NULL; + /* remove PLCP & Broadcom tx descriptor header */ + skb_pull(p, D11_PHY_HDR_LEN); + skb_pull(p, D11_TXH_LEN); + ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); + } else { + wiphy_err(wlc->wiphy, "%s: Not last frame => not calling " + "tx_status\n", __func__); + } + + return false; + + fatal: + if (p) + brcmu_pkt_buf_free_skb(p); + + return true; + +} + +static bool +brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs) { /* discard intermediate indications for ucode with one legitimate case: * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, @@ -843,7 +1027,7 @@ brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs, && (txs->status & TX_STATUS_INTERMEDIATE)) return false; - return brcms_c_dotxstatus(wlc_hw->wlc, txs, s2); + return brcms_c_dotxstatus(wlc_hw->wlc, txs); } /* process tx completion events in BMAC @@ -885,7 +1069,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; txs->lasttxtime = 0; - *fatal = brcms_b_dotxstatus(wlc_hw, txs, s2); + *fatal = brcms_b_dotxstatus(wlc_hw, txs); /* !give others some time to run! */ if (++n >= max_tx_num) @@ -7654,19 +7838,6 @@ void brcms_c_send_q(struct brcms_c_info *wlc) in_send_q = false; } -static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) -{ - if (tx) { - /* the post-increment is used in STAY_AWAKE macro */ - if (wlc->txpend16165war++ == 0) - brcms_c_set_ps_ctrl(wlc); - } else { - wlc->txpend16165war--; - if (wlc->txpend16165war == 0) - brcms_c_set_ps_ctrl(wlc); - } -} - void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, bool commit, s8 txpktpend) @@ -7978,181 +8149,6 @@ void brcms_c_tbtt(struct brcms_c_info *wlc) wlc->qvalid |= MCMD_DIRFRMQVAL; } -/* process an individual struct tx_status */ -bool -brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) -{ - struct sk_buff *p; - uint queue; - struct d11txh *txh; - struct scb *scb = NULL; - bool free_pdu; - int tx_rts, tx_frame_count, tx_rts_count; - uint totlen, supr_status; - bool lastframe; - struct ieee80211_hdr *h; - u16 mcl; - struct ieee80211_tx_info *tx_info; - struct ieee80211_tx_rate *txrate; - int i; - - /* Compiler reference to avoid unused variable warning */ - (void)(frm_tx2); - - /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, - * but the subsequent tx of DATA failed. so it will start rts/cts - * from the beginning (resetting the rts transmission count) - */ - if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) { - wiphy_err(wlc->wiphy, "%s: INTERMEDIATE but not AMPDU\n", - __func__); - return false; - } - - queue = txs->frameid & TXFID_QUEUE_MASK; - if (queue >= NFIFO) { - p = NULL; - goto fatal; - } - - p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); - if (wlc->war16165) - brcms_c_war16165(wlc, false); - if (p == NULL) - goto fatal; - - txh = (struct d11txh *) (p->data); - mcl = le16_to_cpu(txh->MacTxControlLow); - - if (txs->phyerr) { - if (brcm_msg_level & LOG_ERROR_VAL) { - wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n", - txs->phyerr, txh->MainRates); - brcms_c_print_txdesc(txh); - } - brcms_c_print_txstatus(txs); - } - - if (txs->frameid != cpu_to_le16(txh->TxFrameID)) - goto fatal; - tx_info = IEEE80211_SKB_CB(p); - h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - - if (tx_info->control.sta) - scb = (struct scb *)tx_info->control.sta->drv_priv; - - if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { - brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); - return false; - } - - supr_status = txs->status & TX_STATUS_SUPR_MASK; - if (supr_status == TX_STATUS_SUPR_BADCH) - BCMMSG(wlc->wiphy, - "%s: Pkt tx suppressed, possibly channel %d\n", - __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); - - tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS; - tx_frame_count = - (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; - tx_rts_count = - (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT; - - lastframe = !ieee80211_has_morefrags(h->frame_control); - - if (!lastframe) { - wiphy_err(wlc->wiphy, "Not last frame!\n"); - } else { - /* - * Set information to be consumed by Minstrel ht. - * - * The "fallback limit" is the number of tx attempts a given - * MPDU is sent at the "primary" rate. Tx attempts beyond that - * limit are sent at the "secondary" rate. - * A 'short frame' does not exceed RTS treshold. - */ - u16 sfbl, /* Short Frame Rate Fallback Limit */ - lfbl, /* Long Frame Rate Fallback Limit */ - fbl; - - if (queue < AC_COUNT) { - sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], - EDCF_SFB); - lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], - EDCF_LFB); - } else { - sfbl = wlc->SFBL; - lfbl = wlc->LFBL; - } - - txrate = tx_info->status.rates; - if (txrate[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) - fbl = lfbl; - else - fbl = sfbl; - - ieee80211_tx_info_clear_status(tx_info); - - if ((tx_frame_count > fbl) && (txrate[1].idx >= 0)) { - /* - * rate selection requested a fallback rate - * and we used it - */ - txrate[0].count = fbl; - txrate[1].count = tx_frame_count - fbl; - } else { - /* - * rate selection did not request fallback rate, or - * we didn't need it - */ - txrate[0].count = tx_frame_count; - /* - * rc80211_minstrel.c:minstrel_tx_status() expects - * unused rates to be marked with idx = -1 - */ - txrate[1].idx = -1; - txrate[1].count = 0; - } - - /* clear the rest of the rates */ - for (i = 2; i < IEEE80211_TX_MAX_RATES; i++) { - txrate[i].idx = -1; - txrate[i].count = 0; - } - - if (txs->status & TX_STATUS_ACK_RCV) - tx_info->flags |= IEEE80211_TX_STAT_ACK; - } - - totlen = brcmu_pkttotlen(p); - free_pdu = true; - - brcms_c_txfifo_complete(wlc, queue, 1); - - if (lastframe) { - p->next = NULL; - p->prev = NULL; - /* remove PLCP & Broadcom tx descriptor header */ - skb_pull(p, D11_PHY_HDR_LEN); - skb_pull(p, D11_TXH_LEN); - ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); - } else { - wiphy_err(wlc->wiphy, "%s: Not last frame => not calling " - "tx_status\n", __func__); - } - - return false; - - fatal: - if (p) - brcmu_pkt_buf_free_skb(p); - - return true; - -} - void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index aa0bf03825e..1572e469b28 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -702,8 +702,6 @@ struct brcms_bss_cfg { extern void brcms_c_fatal_error(struct brcms_c_info *wlc); extern void brcms_b_rpc_watchdog(struct brcms_c_info *wlc); extern void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p); -extern bool brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, - u32 frm_tx2); extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, bool commit, s8 txpktpend); From 33f08bd814d924e33582c8b5eb2d177a634a3520 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:14 -0700 Subject: [PATCH 1233/1519] staging: brcm80211: deleted unused array of bss configurations in softmac List always had one element. Converted the array to a scalar. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 139 +++++++-------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 +- drivers/staging/brcm80211/brcmsmac/types.h | 5 - 3 files changed, 43 insertions(+), 103 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d160212581a..138f63b5c61 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -342,15 +342,6 @@ static u16 frametype(u32 rspec, u8 mimoframe) /* Starting corerev for the fifo size table */ #define XMTFIFOTBL_STARTREV 20 -/* iterate through all valid bsscfg entries */ -#define FOREACH_BSS(wlc, idx, cfg) \ - for (idx = 0; (int) idx < BRCMS_MAXBSSCFG; idx++) { \ - cfg = (wlc)->bsscfg[idx]; \ - if (!cfg) \ - continue; -/* close marker for iterator code block */ -#define END_FOREACH_BSS() } - /* currently the best mechanism for determining SIFS is the band in use */ static u16 get_sifs(struct brcms_band *band) { @@ -3278,8 +3269,7 @@ static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) */ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) { - int idx; - struct brcms_bss_cfg *cfg; + struct brcms_bss_cfg *cfg = wlc->bsscfg; /* disallow PS when one of the following global conditions meets */ if (!wlc->pub->associated) @@ -3289,19 +3279,16 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) if (wlc->monitor) return false; - for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { - cfg = wlc->bsscfg[idx]; - if (cfg && cfg->associated) { - /* - * disallow PS when one of the following - * bsscfg specific conditions meets - */ - if (!cfg->BSS) - return false; + if (cfg->associated) { + /* + * disallow PS when one of the following + * bsscfg specific conditions meets + */ + if (!cfg->BSS) + return false; - if (!cfg->dtim_programmed) - return false; - } + if (!cfg->dtim_programmed) + return false; } return true; @@ -3779,8 +3766,6 @@ void brcms_c_init(struct brcms_c_info *wlc) { struct d11regs *regs; u16 chanspec; - int i; - struct brcms_bss_cfg *bsscfg; bool mute = false; BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); @@ -3806,32 +3791,24 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_reprate_init(wlc); /* write ethernet address to core */ - FOREACH_BSS(wlc, i, bsscfg) - brcms_c_set_mac(bsscfg); - brcms_c_set_bssid(bsscfg); - END_FOREACH_BSS() + brcms_c_set_mac(wlc->bsscfg); + brcms_c_set_bssid(wlc->bsscfg); /* Update tsf_cfprep if associated and up */ - if (wlc->pub->associated) { - FOREACH_BSS(wlc, i, bsscfg) - if (bsscfg->up) { - u32 bi; + if (wlc->pub->associated && wlc->bsscfg->up) { + u32 bi; - /* get beacon period and convert to uS */ - bi = bsscfg->current_bss->beacon_period << 10; - /* - * update since init path would reset - * to default value - */ - W_REG(®s->tsf_cfprep, - (bi << CFPREP_CBI_SHIFT)); + /* get beacon period and convert to uS */ + bi = wlc->bsscfg->current_bss->beacon_period << 10; + /* + * update since init path would reset + * to default value + */ + W_REG(®s->tsf_cfprep, + (bi << CFPREP_CBI_SHIFT)); - /* Update maccontrol PM related bits */ - brcms_c_set_ps_ctrl(wlc); - - break; - } - END_FOREACH_BSS() + /* Update maccontrol PM related bits */ + brcms_c_set_ps_ctrl(wlc); } brcms_c_bandinit_ordered(wlc, chanspec); @@ -4021,26 +3998,13 @@ void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) brcms_b_set_shortslot(wlc->hw, shortslot); } -/* - * propagate home chanspec to all bsscfgs in - * case bsscfg->current_bss->chanspec is referenced - */ void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) { if (wlc->home_chanspec != chanspec) { - int idx; - struct brcms_bss_cfg *cfg; - wlc->home_chanspec = chanspec; - FOREACH_BSS(wlc, idx, cfg) - if (!cfg->associated) - continue; - - cfg->current_bss->chanspec = chanspec; - END_FOREACH_BSS() - - + if (wlc->bsscfg->associated) + wlc->bsscfg->current_bss->chanspec = chanspec; } } @@ -4092,8 +4056,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, static void brcms_c_setband(struct brcms_c_info *wlc, uint bandunit) { - int idx; - struct brcms_bss_cfg *cfg; + struct brcms_bss_cfg *cfg = wlc->bsscfg; wlc->band = wlc->bandstate[bandunit]; @@ -4101,11 +4064,9 @@ static void brcms_c_setband(struct brcms_c_info *wlc, return; /* wait for at least one beacon before entering sleeping state */ - for (idx = 0; idx < BRCMS_MAXBSSCFG; idx++) { - cfg = wlc->bsscfg[idx]; - if (cfg && cfg->associated) - cfg->PMawakebcn = true; - } + if (cfg->associated) + cfg->PMawakebcn = true; + brcms_c_set_ps_ctrl(wlc); /* band-specific initializations */ @@ -5427,7 +5388,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, goto fail; } - wlc->bsscfg[0] = wlc->cfg; + wlc->bsscfg = wlc->cfg; wlc->cfg->_idx = 0; wlc->cfg->wlc = wlc; @@ -5840,19 +5801,15 @@ int brcms_c_up(struct brcms_c_info *wlc) if (status == -ENOMEDIUM) { if (!mboolisset (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { - int idx; - struct brcms_bss_cfg *bsscfg; + struct brcms_bss_cfg *bsscfg = wlc->bsscfg; mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - FOREACH_BSS(wlc, idx, bsscfg) - if (!bsscfg->enable || !bsscfg->BSS) - continue; - wiphy_err(wlc->wiphy, "wl%d.%d: up" + if (bsscfg->enable && bsscfg->BSS) + wiphy_err(wlc->wiphy, "wl%d: up" ": rfdisable -> " "bsscfg_disable()\n", - wlc->pub->unit, idx); - END_FOREACH_BSS() + wlc->pub->unit); } } } @@ -8993,14 +8950,10 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, */ void brcms_c_update_beacon(struct brcms_c_info *wlc) { - int idx; - struct brcms_bss_cfg *bsscfg; + struct brcms_bss_cfg *bsscfg = wlc->bsscfg; - /* update AP or IBSS beacons */ - FOREACH_BSS(wlc, idx, bsscfg) - if (bsscfg->up && !bsscfg->BSS) - brcms_c_bss_update_beacon(wlc, bsscfg); - END_FOREACH_BSS() + if (bsscfg->up && !bsscfg->BSS) + brcms_c_bss_update_beacon(wlc, bsscfg); } /* Write ssid into shared memory */ @@ -9020,14 +8973,11 @@ void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) { - int idx; - struct brcms_bss_cfg *bsscfg; + struct brcms_bss_cfg *bsscfg = wlc->bsscfg; /* update AP or IBSS probe responses */ - FOREACH_BSS(wlc, idx, bsscfg) - if (bsscfg->up && !bsscfg->BSS) - brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); - END_FOREACH_BSS() + if (bsscfg->up && !bsscfg->BSS) + brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); } void @@ -9105,12 +9055,7 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) /* init tx reported rate mechanism */ void brcms_c_reprate_init(struct brcms_c_info *wlc) { - int i; - struct brcms_bss_cfg *bsscfg; - - FOREACH_BSS(wlc, i, bsscfg) - brcms_c_bsscfg_reprate_init(bsscfg); - END_FOREACH_BSS() + brcms_c_bsscfg_reprate_init(wlc->bsscfg); } /* per bsscfg init tx reported rate mechanism */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 1572e469b28..ede4aef1c99 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -564,7 +564,7 @@ struct brcms_c_info { u16 tx_prec_map; u16 fifo2prec_map[NFIFO]; - struct brcms_bss_cfg *bsscfg[BRCMS_MAXBSSCFG]; + struct brcms_bss_cfg *bsscfg; struct brcms_bss_cfg *cfg; /* tx queue */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index ace210c9762..415ab8bbe95 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -244,11 +244,6 @@ * ******************************************************************** */ -/* NetBSD also needs to keep track of this */ - -/* max # BSS configs */ -#define BRCMS_MAXBSSCFG (1) - #define BCMMSG(dev, fmt, args...) \ do { \ if (brcm_msg_level & LOG_TRACE_VAL) \ From 52d63c393bf8f1e0262c6c0847064ff7e8098cb8 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:15 -0700 Subject: [PATCH 1234/1519] staging: brcm80211: removed redundant wlc->cfg struct member After initialization ('attach'), this struct member always pointed at the same memory as wlc->bsscfg. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 47 ++++++++++------------- drivers/staging/brcm80211/brcmsmac/main.h | 1 - 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 138f63b5c61..ee9c3225487 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -486,7 +486,7 @@ static void brcms_c_detach_mfree(struct brcms_c_info *wlc) if (wlc == NULL) return; - brcms_c_bsscfg_mfree(wlc->cfg); + brcms_c_bsscfg_mfree(wlc->bsscfg); kfree(wlc->pub); kfree(wlc->modulecb); kfree(wlc->default_bss); @@ -577,8 +577,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) goto fail; } - wlc->cfg = brcms_c_bsscfg_malloc(unit); - if (wlc->cfg == NULL) { + wlc->bsscfg = brcms_c_bsscfg_malloc(unit); + if (wlc->bsscfg == NULL) { *err = 1011; goto fail; } @@ -3943,14 +3943,13 @@ void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) * Write this BSS config's MAC address to core. * Updates RXE match engine. */ -int brcms_c_set_mac(struct brcms_bss_cfg *cfg) +int brcms_c_set_mac(struct brcms_bss_cfg *bsscfg) { int err = 0; - struct brcms_c_info *wlc = cfg->wlc; + struct brcms_c_info *wlc = bsscfg->wlc; - if (cfg == wlc->cfg) - /* enter the MAC addr into the RXE match registers */ - brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, cfg->cur_etheraddr); + /* enter the MAC addr into the RXE match registers */ + brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, bsscfg->cur_etheraddr); brcms_c_ampdu_macaddr_upd(wlc); @@ -3960,13 +3959,10 @@ int brcms_c_set_mac(struct brcms_bss_cfg *cfg) /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl). * Updates RXE match engine. */ -void brcms_c_set_bssid(struct brcms_bss_cfg *cfg) +void brcms_c_set_bssid(struct brcms_bss_cfg *bsscfg) { - struct brcms_c_info *wlc = cfg->wlc; - - /* if primary config, we need to update BSSID in RXE match registers */ - if (cfg == wlc->cfg) - brcms_c_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID); + /* we need to update BSSID in RXE match registers */ + brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); } static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) @@ -5388,9 +5384,8 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, goto fail; } - wlc->bsscfg = wlc->cfg; - wlc->cfg->_idx = 0; - wlc->cfg->wlc = wlc; + wlc->bsscfg->_idx = 0; + wlc->bsscfg->wlc = wlc; wlc->mimoft = FT_HT; wlc->ht_cap.cap_info = HT_CAP; @@ -6241,8 +6236,8 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) u8 r; bool war = false; - if (wlc->cfg->associated) - r = wlc->cfg->current_bss->rateset.rates[0]; + if (wlc->bsscfg->associated) + r = wlc->bsscfg->current_bss->rateset.rates[0]; else r = wlc->default_bss->rateset.rates[0]; @@ -6311,7 +6306,7 @@ void brcms_c_get_current_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs; if (wlc->pub->associated) - rs = &wlc->cfg->current_bss->rateset; + rs = &wlc->bsscfg->current_bss->rateset; else rs = &wlc->default_bss->rateset; @@ -6337,8 +6332,8 @@ int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) /* merge rateset coming in with the current mcsset */ if (wlc->pub->_n_enab & SUPPORT_11N) { struct brcms_bss_info *mcsset_bss; - if (wlc->cfg->associated) - mcsset_bss = wlc->cfg->current_bss; + if (wlc->bsscfg->associated) + mcsset_bss = wlc->bsscfg->current_bss; else mcsset_bss = wlc->default_bss; memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], @@ -8096,9 +8091,7 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, void brcms_c_tbtt(struct brcms_c_info *wlc) { - struct brcms_bss_cfg *cfg = wlc->cfg; - - if (!cfg->BSS) + if (!wlc->bsscfg->BSS) /* * DirFrmQ is now valid...defer setting until end * of ATIM window @@ -9144,7 +9137,7 @@ brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, { brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); if (match_reg_offset == RCM_BSSID_OFFSET) - memcpy(wlc->cfg->BSSID, addr, ETH_ALEN); + memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); } void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit) @@ -9273,7 +9266,7 @@ void brcms_c_scan_stop(struct brcms_c_info *wlc) void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state) { wlc->pub->associated = state; - wlc->cfg->associated = state; + wlc->bsscfg->associated = state; } /* diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index ede4aef1c99..d6de9c35398 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -565,7 +565,6 @@ struct brcms_c_info { u16 fifo2prec_map[NFIFO]; struct brcms_bss_cfg *bsscfg; - struct brcms_bss_cfg *cfg; /* tx queue */ struct brcms_txq_info *tx_queues; From 0805095d6b9031fd61d3907659f7a9abd709cb48 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:16 -0700 Subject: [PATCH 1235/1519] staging: brcm80211: removed global var from aiutils.c Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index b7b0bdf1982..d05c4baf7e1 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -477,9 +477,6 @@ struct aidmp { u32 componentid3; /* 0xffc */ }; -/* global kernel resource */ -static struct si_info ksii; - /* EROM parsing */ static u32 @@ -1216,8 +1213,7 @@ void ai_detach(struct si_pub *sih) pcicore_deinit(sii->pch); sii->pch = NULL; - if (sii != &ksii) - kfree(sii); + kfree(sii); } /* register driver interrupt disabling and restoring callback functions */ From bce42cf3fa4c91d62613a2fa822254823efc5280 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:17 -0700 Subject: [PATCH 1236/1519] staging: brcm80211: removed global vars in softmac ucode handling Moved global vars into a per-device structure. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 4 +- .../staging/brcm80211/brcmsmac/mac80211_if.h | 3 +- drivers/staging/brcm80211/brcmsmac/main.c | 27 ++-- .../staging/brcm80211/brcmsmac/ucode_loader.c | 121 +++++++++--------- .../staging/brcm80211/brcmsmac/ucode_loader.h | 44 ++++--- 5 files changed, 105 insertions(+), 94 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 32d7abf2b08..9bd4b83fcfe 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -894,7 +894,7 @@ static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev) wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr)); } wl->fw.fw_cnt = i; - return brcms_ucode_data_init(wl); + return brcms_ucode_data_init(wl, &wl->ucode); } /* @@ -925,7 +925,7 @@ static void brcms_free(struct brcms_info *wl) /* free ucode data */ if (wl->fw.fw_cnt) - brcms_ucode_data_free(); + brcms_ucode_data_free(&wl->ucode); if (wl->irq) free_irq(wl->irq, wl); diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 1eb36eda89d..2bdcd4c16f8 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -19,7 +19,7 @@ #include #include - +#include "ucode_loader.h" /* * Starting index for 5G rates in the * legacy rate table. @@ -77,6 +77,7 @@ struct brcms_info { bool resched; /* dpc needs to be and is rescheduled */ struct brcms_firmware fw; struct wiphy *wiphy; + struct brcms_ucode ucode; }; /* misc callbacks */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index ee9c3225487..4d5c8428e95 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -342,6 +342,12 @@ static u16 frametype(u32 rspec, u8 mimoframe) /* Starting corerev for the fifo size table */ #define XMTFIFOTBL_STARTREV 20 +struct d11init { + u16 addr; + u16 size; + u32 value; +}; + /* currently the best mechanism for determining SIFS is the band in use */ static u16 get_sifs(struct brcms_band *band) { @@ -349,6 +355,7 @@ static u16 get_sifs(struct brcms_band *band) BPHY_SIFS_TIME; } + /* * Detect Card removed. * Even checking an sbconfig register read will not false trigger when the core @@ -694,6 +701,7 @@ static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) { struct wiphy *wiphy = wlc_hw->wlc->wiphy; + struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; /* init microcode host flags */ brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); @@ -701,7 +709,7 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) /* do band-specific ucode IHR, SHM, and SCR inits */ if (D11REV_IS(wlc_hw->corerev, 23)) { if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, d11n0bsinitvals16); + brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); else wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" " %d\n", __func__, wlc_hw->unit, @@ -710,7 +718,7 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) if (D11REV_IS(wlc_hw->corerev, 24)) { if (BRCMS_ISLCNPHY(wlc_hw->band)) brcms_c_write_inits(wlc_hw, - d11lcn0bsinitvals24); + ucode->d11lcn0bsinitvals24); else wiphy_err(wiphy, "%s: wl%d: unsupported phy in" " core rev %d\n", __func__, @@ -2457,6 +2465,8 @@ static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], static void brcms_ucode_download(struct brcms_hardware *wlc_hw) { struct brcms_c_info *wlc; + struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; + wlc = wlc_hw->wlc; if (wlc_hw->ucode_loaded) @@ -2464,8 +2474,8 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw) if (D11REV_IS(wlc_hw->corerev, 23)) { if (BRCMS_ISNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, bcm43xx_16_mimo, - bcm43xx_16_mimosz); + brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, + ucode->bcm43xx_16_mimosz); wlc_hw->ucode_loaded = true; } else wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " @@ -2473,8 +2483,8 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw) __func__, wlc_hw->unit, wlc_hw->corerev); } else if (D11REV_IS(wlc_hw->corerev, 24)) { if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, bcm43xx_24_lcn, - bcm43xx_24_lcnsz); + brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, + ucode->bcm43xx_24_lcnsz); wlc_hw->ucode_loaded = true; } else { wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " @@ -3372,6 +3382,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) int err = 0; u16 buf[NFIFO]; struct wiphy *wiphy = wlc->wiphy; + struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; regs = wlc_hw->regs; @@ -3404,14 +3415,14 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) if (D11REV_IS(wlc_hw->corerev, 23)) { if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, d11n0initvals16); + brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); else wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" " %d\n", __func__, wlc_hw->unit, wlc_hw->corerev); } else if (D11REV_IS(wlc_hw->corerev, 24)) { if (BRCMS_ISLCNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, d11lcn0initvals24); + brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); else wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" " %d\n", __func__, wlc_hw->unit, diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c b/drivers/staging/brcm80211/brcmsmac/ucode_loader.c index c14bce87358..80e3ccf865e 100644 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c +++ b/drivers/staging/brcm80211/brcmsmac/ucode_loader.c @@ -37,80 +37,73 @@ enum { D11UCODE_OVERSIGHT_BOMMINOR }; -struct d11init *d11lcn0bsinitvals24; -struct d11init *d11lcn0initvals24; -struct d11init *d11lcn1bsinitvals24; -struct d11init *d11lcn1initvals24; -struct d11init *d11lcn2bsinitvals24; -struct d11init *d11lcn2initvals24; -struct d11init *d11n0absinitvals16; -struct d11init *d11n0bsinitvals16; -struct d11init *d11n0initvals16; -u32 *bcm43xx_16_mimo; -u32 bcm43xx_16_mimosz; -u32 *bcm43xx_24_lcn; -u32 bcm43xx_24_lcnsz; - -static u32 *bcm43xx_bommajor; -static u32 *bcm43xx_bomminor; - -int brcms_ucode_data_init(struct brcms_info *wl) +int brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode) { int rc; + rc = brcms_check_firmwares(wl); rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&d11lcn0bsinitvals24, + brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn0bsinitvals24, D11LCN0BSINITVALS24); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&d11lcn0initvals24, - D11LCN0INITVALS24); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn0initvals24, + D11LCN0INITVALS24); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn1bsinitvals24, + D11LCN1BSINITVALS24); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn1initvals24, + D11LCN1INITVALS24); rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&d11lcn1bsinitvals24, - D11LCN1BSINITVALS24); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&d11lcn1initvals24, - D11LCN1INITVALS24); - rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&d11lcn2bsinitvals24, + brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn2bsinitvals24, D11LCN2BSINITVALS24); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&d11lcn2initvals24, - D11LCN2INITVALS24); - rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&d11n0absinitvals16, - D11N0ABSINITVALS16); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&d11n0bsinitvals16, - D11N0BSINITVALS16); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&d11n0initvals16, - D11N0INITVALS16); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&bcm43xx_16_mimo, - D11UCODE_OVERSIGHT16_MIMO); - rc = rc < 0 ? rc : brcms_ucode_init_uint(wl, &bcm43xx_16_mimosz, - D11UCODE_OVERSIGHT16_MIMOSZ); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&bcm43xx_24_lcn, - D11UCODE_OVERSIGHT24_LCN); - rc = rc < 0 ? rc : brcms_ucode_init_uint(wl, &bcm43xx_24_lcnsz, - D11UCODE_OVERSIGHT24_LCNSZ); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&bcm43xx_bommajor, - D11UCODE_OVERSIGHT_BOMMAJOR); - rc = rc < 0 ? rc : brcms_ucode_init_buf(wl, (void **)&bcm43xx_bomminor, - D11UCODE_OVERSIGHT_BOMMINOR); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn2initvals24, + D11LCN2INITVALS24); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0absinitvals16, + D11N0ABSINITVALS16); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0bsinitvals16, + D11N0BSINITVALS16); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0initvals16, + D11N0INITVALS16); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_16_mimo, + D11UCODE_OVERSIGHT16_MIMO); + rc = rc < 0 ? + rc : brcms_ucode_init_uint(wl, &ucode->bcm43xx_16_mimosz, + D11UCODE_OVERSIGHT16_MIMOSZ); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_24_lcn, + D11UCODE_OVERSIGHT24_LCN); + rc = rc < 0 ? + rc : brcms_ucode_init_uint(wl, &ucode->bcm43xx_24_lcnsz, + D11UCODE_OVERSIGHT24_LCNSZ); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_bommajor, + D11UCODE_OVERSIGHT_BOMMAJOR); + rc = rc < 0 ? + rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_bomminor, + D11UCODE_OVERSIGHT_BOMMINOR); return rc; } -void brcms_ucode_data_free(void) +void brcms_ucode_data_free(struct brcms_ucode *ucode) { - brcms_ucode_free_buf((void *)d11lcn0bsinitvals24); - brcms_ucode_free_buf((void *)d11lcn0initvals24); - brcms_ucode_free_buf((void *)d11lcn1bsinitvals24); - brcms_ucode_free_buf((void *)d11lcn1initvals24); - brcms_ucode_free_buf((void *)d11lcn2bsinitvals24); - brcms_ucode_free_buf((void *)d11lcn2initvals24); - brcms_ucode_free_buf((void *)d11n0absinitvals16); - brcms_ucode_free_buf((void *)d11n0bsinitvals16); - brcms_ucode_free_buf((void *)d11n0initvals16); - brcms_ucode_free_buf((void *)bcm43xx_16_mimo); - brcms_ucode_free_buf((void *)bcm43xx_24_lcn); - brcms_ucode_free_buf((void *)bcm43xx_bommajor); - brcms_ucode_free_buf((void *)bcm43xx_bomminor); - - return; + brcms_ucode_free_buf((void *)ucode->d11lcn0bsinitvals24); + brcms_ucode_free_buf((void *)ucode->d11lcn0initvals24); + brcms_ucode_free_buf((void *)ucode->d11lcn1bsinitvals24); + brcms_ucode_free_buf((void *)ucode->d11lcn1initvals24); + brcms_ucode_free_buf((void *)ucode->d11lcn2bsinitvals24); + brcms_ucode_free_buf((void *)ucode->d11lcn2initvals24); + brcms_ucode_free_buf((void *)ucode->d11n0absinitvals16); + brcms_ucode_free_buf((void *)ucode->d11n0bsinitvals16); + brcms_ucode_free_buf((void *)ucode->d11n0initvals16); + brcms_ucode_free_buf((void *)ucode->bcm43xx_16_mimo); + brcms_ucode_free_buf((void *)ucode->bcm43xx_24_lcn); + brcms_ucode_free_buf((void *)ucode->bcm43xx_bommajor); + brcms_ucode_free_buf((void *)ucode->bcm43xx_bomminor); } diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h index ca53deced7b..438675ae441 100644 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h +++ b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h @@ -13,6 +13,8 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _BRCM_UCODE_H_ +#define _BRCM_UCODE_H_ #include "types.h" /* forward structure declarations */ @@ -21,28 +23,30 @@ #define UCODE_LOADER_API_VER 0 -struct d11init { - u16 addr; - u16 size; - u32 value; +struct d11init; + +struct brcms_ucode { + struct d11init *d11lcn0bsinitvals24; + struct d11init *d11lcn0initvals24; + struct d11init *d11lcn1bsinitvals24; + struct d11init *d11lcn1initvals24; + struct d11init *d11lcn2bsinitvals24; + struct d11init *d11lcn2initvals24; + struct d11init *d11n0absinitvals16; + struct d11init *d11n0bsinitvals16; + struct d11init *d11n0initvals16; + u32 *bcm43xx_16_mimo; + u32 bcm43xx_16_mimosz; + u32 *bcm43xx_24_lcn; + u32 bcm43xx_24_lcnsz; + u32 *bcm43xx_bommajor; + u32 *bcm43xx_bomminor; }; -extern struct d11init *d11lcn0bsinitvals24; -extern struct d11init *d11lcn0initvals24; -extern struct d11init *d11lcn1bsinitvals24; -extern struct d11init *d11lcn1initvals24; -extern struct d11init *d11lcn2bsinitvals24; -extern struct d11init *d11lcn2initvals24; -extern struct d11init *d11n0absinitvals16; -extern struct d11init *d11n0bsinitvals16; -extern struct d11init *d11n0initvals16; -extern u32 *bcm43xx_16_mimo; -extern u32 bcm43xx_16_mimosz; -extern u32 *bcm43xx_24_lcn; -extern u32 bcm43xx_24_lcnsz; +extern int +brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode); -extern int brcms_ucode_data_init(struct brcms_info *wl); -extern void brcms_ucode_data_free(void); +extern void brcms_ucode_data_free(struct brcms_ucode *ucode); extern int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, unsigned int idx); @@ -50,3 +54,5 @@ extern int brcms_ucode_init_uint(struct brcms_info *wl, unsigned *data, unsigned int idx); extern void brcms_ucode_free_buf(void *); extern int brcms_check_firmwares(struct brcms_info *wl); + +#endif /* _BRCM_UCODE_H_ */ From 261f992bce8e5bc363a25f5a9db86404aadb847d Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:18 -0700 Subject: [PATCH 1237/1519] staging: brcm80211: removed unused softmac workaround WAR16165 is only used on older PCI chips, the driver does not support these chips. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 9 ------ drivers/staging/brcm80211/brcmsmac/aiutils.h | 2 -- drivers/staging/brcm80211/brcmsmac/d11.h | 3 +- drivers/staging/brcm80211/brcmsmac/main.c | 31 -------------------- drivers/staging/brcm80211/brcmsmac/main.h | 5 ---- 5 files changed, 1 insertion(+), 49 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index d05c4baf7e1..790fdce60ed 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1852,15 +1852,6 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return 0; } -bool ai_pci_war16165(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - return PCI(sii) && (sih->buscorerev <= 10); -} - void ai_pci_up(struct si_pub *sih) { struct si_info *sii; diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index a7769451cff..39171927c1b 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -322,8 +322,6 @@ extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); extern struct si_pub *ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz); extern void ai_detach(struct si_pub *sih); -extern bool ai_pci_war16165(struct si_pub *sih); - extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); extern uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index 14e60a5d130..cbb574ab228 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -1330,8 +1330,7 @@ struct shm_acparams { #define MHF1_FORCEFASTCLK 0x0400 /* Flags in M_HOST_FLAGS2 */ -/* PR16165WAR : Enable ucode PCI slow clock WAR */ -#define MHF2_PCISLOWCLKWAR 0x0008 + /* Flush BCMC FIFO immediately */ #define MHF2_TXBCMC_NOW 0x0040 /* Enable ucode/hw power control */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 4d5c8428e95..3ec952cd957 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -829,19 +829,6 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) return n >= bound_limit; } -static void brcms_c_war16165(struct brcms_c_info *wlc, bool tx) -{ - if (tx) { - /* the post-increment is used in STAY_AWAKE macro */ - if (wlc->txpend16165war++ == 0) - brcms_c_set_ps_ctrl(wlc); - } else { - wlc->txpend16165war--; - if (wlc->txpend16165war == 0) - brcms_c_set_ps_ctrl(wlc); - } -} - /* process an individual struct tx_status */ static bool brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) @@ -879,8 +866,6 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) } p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); - if (wlc->war16165) - brcms_c_war16165(wlc, false); if (p == NULL) goto fatal; @@ -3109,8 +3094,6 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) struct brcms_hardware *wlc_hw = wlc->hw; uint i; - wlc->txpend16165war = 0; - /* free any posted tx packets */ for (i = 0; i < NFIFO; i++) if (wlc_hw->di[i]) { @@ -3532,9 +3515,6 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) AND_REG(®s->ifs_ctl, 0x0FFF); W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); - /* dma initializations */ - wlc->txpend16165war = 0; - /* init the tx dma engines */ for (i = 0; i < NFIFO; i++) { if (wlc_hw->di[i]) @@ -4832,9 +4812,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, if (wlc_hw->boardflags & BFL_NOPLLDOWN) brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); - if (ai_pci_war16165(wlc_hw->sih)) - wlc->war16165 = true; - /* check device id(srom, nvram etc.) to set bands */ if (wlc_hw->deviceid == BCM43224_D11N_ID || wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) @@ -5833,10 +5810,6 @@ int brcms_c_up(struct brcms_c_info *wlc) /* Set EDCF hostflags */ brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); - if (wlc->war16165) - brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR, - BRCM_BAND_ALL); - brcms_init(wlc->wl); wlc->pub->up = true; @@ -7816,10 +7789,6 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, if (fifo == TX_BCMC_FIFO) frameid = le16_to_cpu(txh->TxFrameID); - if (wlc->war16165) - brcms_c_war16165(wlc, true); - - /* * Bump up pending count for if not using rpc. If rpc is * used, this will be handled in brcms_b_txfifo() diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index d6de9c35398..717843a231f 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -416,8 +416,6 @@ struct brcms_txq_info { * band: pointer to active per-band state. * corestate: per-core state (one per hw core). * bandstate: per-band state (one per phy/radio). - * war16165: PCI slow clock 16165 war flag. - * txpend16165war: PCI slow clock 16165 war flag. * qvalid: DirFrmQValid and BcMcFrmQValid. * ampdu: ampdu module handler. * asi: antsel module handler. @@ -508,9 +506,6 @@ struct brcms_c_info { struct brcms_core *corestate; struct brcms_band *bandstate[MAXBANDS]; - bool war16165; - uint txpend16165war; - /* packet queue */ uint qvalid; From 3215b494150864d551a9d0fe0351f3f412ac00da Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:19 -0700 Subject: [PATCH 1238/1519] staging: brcm80211: remove ht_cap field from brcms_c_info structure The field ht_cap was typed ieee80211_ht_cap from ieee80211.h. This contained little endian annotated field cap_info resulting in sparse endian warnings. It turned out the driver was setting the field, but it was actually never used. Therefore it has been removed. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 23 ----------------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 -- drivers/staging/brcm80211/brcmsmac/stf.c | 9 --------- 3 files changed, 34 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 3ec952cd957..074e16fbaae 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -325,11 +325,6 @@ static u16 frametype(u32 rspec, u8 mimoframe) */ #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) -/* defaults for the HT (MIMO) bss */ -#define HT_CAP (IEEE80211_HT_CAP_SM_PS |\ - IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |\ - IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40) - /* * The following table lists the buffer memory allocated to xmt fifos in HW. * the size is in units of 256bytes(one block), total size is HW dependent @@ -4213,13 +4208,6 @@ void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val) { - wlc->ht_cap.cap_info &= ~(IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40); - wlc->ht_cap.cap_info |= (val & BRCMS_N_SGI_20) ? - IEEE80211_HT_CAP_SGI_20 : 0; - wlc->ht_cap.cap_info |= (val & BRCMS_N_SGI_40) ? - IEEE80211_HT_CAP_SGI_40 : 0; - if (wlc->pub->up) { brcms_c_update_beacon(wlc); brcms_c_update_probe_resp(wlc, true); @@ -4230,10 +4218,6 @@ static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) { wlc->stf->ldpc = val; - wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_LDPC_CODING; - if (wlc->stf->ldpc != OFF) - wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_LDPC_CODING; - if (wlc->pub->up) { brcms_c_update_beacon(wlc); brcms_c_update_probe_resp(wlc, true); @@ -5376,8 +5360,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, wlc->bsscfg->wlc = wlc; wlc->mimoft = FT_HT; - wlc->ht_cap.cap_info = HT_CAP; - wlc->mimo_40txbw = AUTO; wlc->ofdm_40txbw = AUTO; wlc->cck_40txbw = AUTO; @@ -5403,15 +5385,10 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, if (n_disabled & WLFEATURE_DISABLE_11N_STBC_TX) { wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF; wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF; - wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC; } if (n_disabled & WLFEATURE_DISABLE_11N_STBC_RX) brcms_c_stf_stbc_rx_set(wlc, HT_CAP_RX_STBC_NO); - /* apply the GF override from nvram conf */ - if (n_disabled & WLFEATURE_DISABLE_11N_GF) - wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_GRN_FLD; - /* initialize radio_mpc_disable according to wlc->mpc */ brcms_c_radio_mpc_upd(wlc); brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 717843a231f..8760d7ec063 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -456,7 +456,6 @@ struct brcms_txq_info { * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode. * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode. * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode. - * ht_cap: HT CAP IE being advertised by this node. * default_bss: configured BSS parameters. * mc_fid_counter: BC/MC FIFO frame ID counter. * country_default: saved country for leaving 802.11d auto-country mode. @@ -570,7 +569,6 @@ struct brcms_c_info { s8 cck_40txbw; s8 ofdm_40txbw; s8 mimo_40txbw; - struct ieee80211_ht_cap ht_cap; struct brcms_bss_info *default_bss; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 91b53a5a261..c77bab2be87 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -53,9 +53,6 @@ static void brcms_c_stf_stbc_rx_ht_update(struct brcms_c_info *wlc, int val) return; } - wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_RX_STBC; - wlc->ht_cap.cap_info |= (val << IEEE80211_HT_CAP_RX_STBC_SHIFT); - if (wlc->pub->up) { brcms_c_update_beacon(wlc); brcms_c_update_probe_resp(wlc, true); @@ -140,12 +137,6 @@ static bool brcms_c_stf_stbc_tx_set(struct brcms_c_info *wlc, s32 int_val) if ((int_val == ON) && (wlc->stf->txstreams == 1)) return false; - if ((int_val == OFF) || (wlc->stf->txstreams == 1) - || !BRCMS_STBC_CAP_PHY(wlc)) - wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC; - else - wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_TX_STBC; - wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = (s8) int_val; wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = (s8) int_val; From 2f74156c9d6208ac5961fc08dc91b8b1732ce04b Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:20 -0700 Subject: [PATCH 1239/1519] staging: brcm80211: use fragment number provided in transmit frame In the transmit path the field seq_ctrl is filled in, but the fragment number was not properly determined. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 074e16fbaae..dfd67de4f8c 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -7100,7 +7100,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, scb->seqnum[p->priority]++; /* extract fragment number from frame first */ - seq = le16_to_cpu(seq) & FRAGNUM_MASK; + seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); h->seq_ctrl = cpu_to_le16(seq); From 25d3f4bc66ae77cf72202777332350ab893a3d65 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:21 -0700 Subject: [PATCH 1240/1519] staging: brcm80211: remove unused function si_pmu_ilp_clock() The function is not used in the driver and has been removed. Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/pmu.c | 22 ---------------------- drivers/staging/brcm80211/brcmsmac/pmu.h | 1 - 2 files changed, 23 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index 61ba3735a4f..6d4cd9fcefb 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -202,28 +202,6 @@ si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs *cc, W_REG(&cc->pmucontrol, tmp); } -u32 si_pmu_ilp_clock(struct si_pub *sih) -{ - static u32 ilpcycles_per_sec; - - if (!(sih->cccaps & CC_CAP_PMU)) - return ILP_CLOCK; - - if (ilpcycles_per_sec == 0) { - u32 start, end, delta; - u32 origidx = ai_coreidx(sih); - struct chipcregs *cc = ai_setcoreidx(sih, SI_CC_IDX); - start = R_REG(&cc->pmutimer); - mdelay(ILP_CALC_DUR); - end = R_REG(&cc->pmutimer); - delta = end - start; - ilpcycles_per_sec = delta * (1000 / ILP_CALC_DUR); - ai_setcoreidx(sih, origidx); - } - - return ilpcycles_per_sec; -} - u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) { uint delay = PMU_MAX_TRANSITION_DLY; diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.h b/drivers/staging/brcm80211/brcmsmac/pmu.h index 2917e6ff862..3a08c620640 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.h +++ b/drivers/staging/brcm80211/brcmsmac/pmu.h @@ -24,7 +24,6 @@ extern u16 si_pmu_fast_pwrup_delay(struct si_pub *sih); extern void si_pmu_sprom_enable(struct si_pub *sih, bool enable); extern u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); extern u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); -extern u32 si_pmu_ilp_clock(struct si_pub *sih); extern u32 si_pmu_alp_clock(struct si_pub *sih); extern void si_pmu_pllupd(struct si_pub *sih); extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid); From 4c5af8e260a7a35760fe68fe5278a717f33d1be4 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:22 -0700 Subject: [PATCH 1241/1519] staging: brcm80211: make device initializer table for wme constant For chip initialisation of the wme parameters a table is used, but it was not marked as constant. Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index dfd67de4f8c..a3c0157df47 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4297,7 +4297,7 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) int i_ac; struct ieee80211_tx_queue_params txq_pars; struct ieee80211_tx_queue_params *params = &txq_pars; - static struct edcf_acparam default_edcf_acparams[] = { + static const struct edcf_acparam default_edcf_acparams[] = { {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, cpu_to_le16(EDCF_AC_BE_TXOP_STA)}, {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, @@ -4307,7 +4307,7 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, cpu_to_le16(EDCF_AC_VO_TXOP_STA)} }; /* ucode needs these parameters during its initialization */ - struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; + const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { /* find out which ac this set of params applies to */ From 3e02a77a52e70b1c54a667b84a5bee05949b7e8e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:23 -0700 Subject: [PATCH 1242/1519] staging: brcm80211: remove dongle firmware related debug code When the device dies the driver could extract cpu registers on the device to analyze the trap handling on the dongle. As the firmware with this driver is stable this code does not belong in the brcmfmac driver. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 259 +----------------- 1 file changed, 1 insertion(+), 258 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 9f8bcb32dd6..4992d4df27e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -37,29 +37,7 @@ #ifdef BCMDBG -/* ARM trap handling */ -struct brcmf_trap { - u32 type; - u32 epc; - u32 cpsr; - u32 spsr; - u32 r0; - u32 r1; - u32 r2; - u32 r3; - u32 r4; - u32 r5; - u32 r6; - u32 r7; - u32 r8; - u32 r9; - u32 r10; - u32 r11; - u32 r12; - u32 r13; - u32 r14; - u32 pc; -}; +#define BRCMF_TRAP_INFO_SIZE 80 #define CBUF_LEN (128) @@ -2890,231 +2868,6 @@ xfer_done: } #ifdef BCMDBG -static int -brcmf_sdbrcm_readshared(struct brcmf_bus *bus, struct sdpcm_shared *sh) -{ - u32 addr; - __le32 addr_le; - int rv; - struct sdpcm_shared_le sh_le; - - /* Read last word in memory to determine address of - sdpcm_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, bus->ramsize - 4, (u8 *)&addr_le, - 4); - if (rv < 0) - return rv; - - addr = le32_to_cpu(addr_le); - - brcmf_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr); - - /* - * Check if addr is valid. - * NVRAM length at the end of memory should have been overwritten. - */ - if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) { - brcmf_dbg(ERROR, "address (0x%08x) of sdpcm_shared invalid\n", - addr); - return -EBADE; - } - - /* Read rte_shared structure */ - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *) &sh_le, - sizeof(struct sdpcm_shared_le)); - if (rv < 0) - return rv; - - /* Endianness */ - sh->flags = le32_to_cpu(sh_le.flags); - sh->trap_addr = le32_to_cpu(sh_le.trap_addr); - sh->assert_exp_addr = le32_to_cpu(sh_le.assert_exp_addr); - sh->assert_file_addr = le32_to_cpu(sh_le.assert_file_addr); - sh->assert_line = le32_to_cpu(sh_le.assert_line); - sh->console_addr = le32_to_cpu(sh_le.console_addr); - sh->msgtrace_addr = le32_to_cpu(sh_le.msgtrace_addr); - memcpy(sh->tag, sh_le.tag, sizeof(sh->tag)); - - if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { - brcmf_dbg(ERROR, "sdpcm_shared version %d in brcmf is different than sdpcm_shared version %d in dongle\n", - SDPCM_SHARED_VERSION, - sh->flags & SDPCM_SHARED_VERSION_MASK); - return -EBADE; - } - - return 0; -} - -static int brcmf_sdbrcm_mem_dump(struct brcmf_bus *bus) -{ - int ret = 0; - int size; /* Full mem size */ - int start = 0; /* Start address */ - int read_size = 0; /* Read size of each iteration */ - u8 *buf = NULL, *databuf = NULL; - - /* Get full mem size */ - size = bus->ramsize; - buf = kmalloc(size, GFP_ATOMIC); - if (!buf) - return -1; - - /* Read mem content */ - printk(KERN_DEBUG "Dump dongle memory"); - databuf = buf; - while (size) { - read_size = min(MEMBLOCK, size); - ret = brcmf_sdbrcm_membytes(bus, false, start, databuf, - read_size); - if (ret) { - brcmf_dbg(ERROR, "Error membytes %d\n", ret); - kfree(buf); - return -1; - } - printk("."); - - /* Decrement size and increment start address */ - size -= read_size; - start += read_size; - databuf += read_size; - } - printk(KERN_DEBUG "Done\n"); - - /* free buf before return !!! */ - if (brcmf_write_to_file(bus->drvr, buf, bus->ramsize)) { - brcmf_dbg(ERROR, "Error writing to files\n"); - return -1; - } - - /* buf free handled in brcmf_write_to_file, not here */ - return 0; -} - -static int brcmf_sdbrcm_checkdied(struct brcmf_bus *bus, u8 *data, uint size) -{ - int bcmerror = 0; - uint msize = 512; - char *mbuffer = NULL; - uint maxstrlen = 256; - char *str = NULL; - struct brcmf_trap tr; - struct sdpcm_shared sdpcm_shared; - struct brcmu_strbuf strbuf; - - brcmf_dbg(TRACE, "Enter\n"); - - if (data == NULL) { - /* - * Called after a rx ctrl timeout. "data" is NULL. - * allocate memory to trace the trap or assert. - */ - size = msize; - mbuffer = data = kmalloc(msize, GFP_ATOMIC); - if (mbuffer == NULL) { - bcmerror = -ENOMEM; - goto done; - } - } - - str = kmalloc(maxstrlen, GFP_ATOMIC); - if (str == NULL) { - bcmerror = -ENOMEM; - goto done; - } - - bcmerror = brcmf_sdbrcm_readshared(bus, &sdpcm_shared); - if (bcmerror < 0) - goto done; - - brcmu_binit(&strbuf, data, size); - - brcmu_bprintf(&strbuf, - "msgtrace address : 0x%08X\nconsole address : 0x%08X\n", - sdpcm_shared.msgtrace_addr, sdpcm_shared.console_addr); - - if ((sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) == 0) - /* NOTE: Misspelled assert is intentional - DO NOT FIX. - * (Avoids conflict with real asserts for programmatic - * parsing of output.) - */ - brcmu_bprintf(&strbuf, "Assrt not built in dongle\n"); - - if ((sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) == - 0) { - /* NOTE: Misspelled assert is intentional - DO NOT FIX. - * (Avoids conflict with real asserts for programmatic - * parsing of output.) - */ - brcmu_bprintf(&strbuf, "No trap%s in dongle", - (sdpcm_shared.flags & SDPCM_SHARED_ASSERT_BUILT) - ? "/assrt" : ""); - } else { - if (sdpcm_shared.flags & SDPCM_SHARED_ASSERT) { - /* Download assert */ - brcmu_bprintf(&strbuf, "Dongle assert"); - if (sdpcm_shared.assert_exp_addr != 0) { - str[0] = '\0'; - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.assert_exp_addr, - (u8 *) str, maxstrlen); - if (bcmerror < 0) - goto done; - - str[maxstrlen - 1] = '\0'; - brcmu_bprintf(&strbuf, " expr \"%s\"", str); - } - - if (sdpcm_shared.assert_file_addr != 0) { - str[0] = '\0'; - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.assert_file_addr, - (u8 *) str, maxstrlen); - if (bcmerror < 0) - goto done; - - str[maxstrlen - 1] = '\0'; - brcmu_bprintf(&strbuf, " file \"%s\"", str); - } - - brcmu_bprintf(&strbuf, " line %d ", - sdpcm_shared.assert_line); - } - - if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) { - bcmerror = brcmf_sdbrcm_membytes(bus, false, - sdpcm_shared.trap_addr, (u8 *)&tr, - sizeof(struct brcmf_trap)); - if (bcmerror < 0) - goto done; - - brcmu_bprintf(&strbuf, - "Dongle trap type 0x%x @ epc 0x%x, cpsr 0x%x, spsr 0x%x, sp 0x%x," - "lp 0x%x, rpc 0x%x Trap offset 0x%x, " - "r0 0x%x, r1 0x%x, r2 0x%x, r3 0x%x, r4 0x%x, r5 0x%x, r6 0x%x, r7 0x%x\n", - tr.type, tr.epc, tr.cpsr, tr.spsr, tr.r13, - tr.r14, tr.pc, sdpcm_shared.trap_addr, - tr.r0, tr.r1, tr.r2, tr.r3, tr.r4, tr.r5, - tr.r6, tr.r7); - } - } - - if (sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP)) - brcmf_dbg(ERROR, "%s\n", strbuf.origbuf); - -#ifdef BCMDBG - if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) - /* Mem dump to a file on device */ - brcmf_sdbrcm_mem_dump(bus); - -#endif /* BCMDBG */ - -done: - kfree(mbuffer); - kfree(str); - - return bcmerror; -} - #define CONSOLE_LINE_MAX 192 static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) @@ -3377,21 +3130,11 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) rxlen, msglen); } else if (timeleft == 0) { brcmf_dbg(ERROR, "resumed on timeout\n"); -#ifdef BCMDBG - brcmf_sdbrcm_sdlock(bus); - brcmf_sdbrcm_checkdied(bus, NULL, 0); - brcmf_sdbrcm_sdunlock(bus); -#endif /* BCMDBG */ } else if (pending == true) { brcmf_dbg(CTL, "cancelled\n"); return -ERESTARTSYS; } else { brcmf_dbg(CTL, "resumed for unknown reason?\n"); -#ifdef BCMDBG - brcmf_sdbrcm_sdlock(bus); - brcmf_sdbrcm_checkdied(bus, NULL, 0); - brcmf_sdbrcm_sdunlock(bus); -#endif /* BCMDBG */ } if (rxlen) From 8298f41150c3e063eb6b3dec58349f652c564fbf Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:24 -0700 Subject: [PATCH 1243/1519] staging: brcm80211: remove unnecessary mac80211 callbacks Several callback were implemented without executing any further function calls into the driver. Review feedback indicated that these could be removed. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 9bd4b83fcfe..11ba061ca86 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -580,12 +580,6 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw, return; } -static int -brcms_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) -{ - return 0; -} - static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; @@ -604,42 +598,6 @@ static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw) return; } -static void brcms_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf) -{ - wiphy_err(hw->wiphy, "%s: Enter\n", __func__); - return; -} - -static int -brcms_ops_get_stats(struct ieee80211_hw *hw, - struct ieee80211_low_level_stats *stats) -{ - struct brcms_info *wl = hw->priv; - struct wl_cnt *cnt; - - LOCK(wl); - cnt = wl->pub->_cnt; - stats->dot11ACKFailureCount = 0; - stats->dot11RTSFailureCount = 0; - stats->dot11FCSErrorCount = 0; - stats->dot11RTSSuccessCount = 0; - UNLOCK(wl); - return 0; -} - -static void -brcms_ops_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - enum sta_notify_cmd cmd, struct ieee80211_sta *sta) -{ - switch (cmd) { - default: - wiphy_err(hw->wiphy, "%s: Unknown cmd = %d\n", __func__, - cmd); - break; - } - return; -} - static int brcms_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, const struct ieee80211_tx_queue_params *params) @@ -653,12 +611,6 @@ brcms_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, return 0; } -static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw) -{ - wiphy_err(hw->wiphy, "%s: Enter\n", __func__); - return 0; -} - static int brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) @@ -697,13 +649,6 @@ brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return 0; } -static int -brcms_ops_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - return 0; -} - static int brcms_ops_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, @@ -800,16 +745,10 @@ static const struct ieee80211_ops brcms_ops = { .config = brcms_ops_config, .bss_info_changed = brcms_ops_bss_info_changed, .configure_filter = brcms_ops_configure_filter, - .set_tim = brcms_ops_set_tim, .sw_scan_start = brcms_ops_sw_scan_start, .sw_scan_complete = brcms_ops_sw_scan_complete, - .set_tsf = brcms_ops_set_tsf, - .get_stats = brcms_ops_get_stats, - .sta_notify = brcms_ops_sta_notify, .conf_tx = brcms_ops_conf_tx, - .get_tsf = brcms_ops_get_tsf, .sta_add = brcms_ops_sta_add, - .sta_remove = brcms_ops_sta_remove, .ampdu_action = brcms_ops_ampdu_action, .rfkill_poll = brcms_ops_rfkill_poll, .flush = brcms_ops_flush, From f9be7492782a584e61724c6f84d5ca2c71f7bed0 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:25 -0700 Subject: [PATCH 1244/1519] staging: brcm80211: removed band related global vars from softmac Global variables are undesirable unless they are read only. Variables are now maintained in a device specific structure. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 29 +++++++++++-------- drivers/staging/brcm80211/brcmsmac/main.h | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 11ba061ca86..d5d0d9e668f 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -31,6 +31,7 @@ #include "pub.h" #include "ucode_loader.h" #include "mac80211_if.h" +#include "main.h" #define N_TX_QUEUES 4 /* #tx queues on mac80211<->driver interface */ @@ -225,7 +226,7 @@ static struct ieee80211_rate legacy_ratetable[] = { RATE(540, 0), }; -static struct ieee80211_supported_band brcms_band_2GHz_nphy = { +static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { .band = IEEE80211_BAND_2GHZ, .channels = brcms_2ghz_chantable, .n_channels = ARRAY_SIZE(brcms_2ghz_chantable), @@ -247,7 +248,7 @@ static struct ieee80211_supported_band brcms_band_2GHz_nphy = { } }; -static struct ieee80211_supported_band brcms_band_5GHz_nphy = { +static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { .band = IEEE80211_BAND_5GHZ, .channels = brcms_5ghz_nphy_chantable, .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), @@ -981,22 +982,24 @@ static irqreturn_t brcms_isr(int irq, void *dev_id) static int ieee_hw_rate_init(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; - int has_5g; + struct brcms_c_info *wlc = wl->wlc; + struct ieee80211_supported_band *band; + int has_5g = 0; u16 phy_type; - has_5g = 0; - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; phy_type = brcms_c_get_phy_type(wl->wlc, 0); if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) { + band = &wlc->bandstate[BAND_2G_INDEX]->band; + *band = brcms_band_2GHz_nphy_template; if (phy_type == PHY_TYPE_LCN) { /* Single stream */ - brcms_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; - brcms_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; + band->ht_cap.mcs.rx_mask[1] = 0; + band->ht_cap.mcs.rx_highest = 72; } - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &brcms_band_2GHz_nphy; + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = band; } else { return -EPERM; } @@ -1004,11 +1007,13 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) /* Assume all bands use the same phy. True for 11n devices. */ if (wl->pub->_nbands > 1) { has_5g++; - if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) - hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &brcms_band_5GHz_nphy; - else + if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) { + band = &wlc->bandstate[BAND_5G_INDEX]->band; + *band = brcms_band_5GHz_nphy_template; + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = band; + } else { return -EPERM; + } } return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 8760d7ec063..9e12a1444d8 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -281,6 +281,7 @@ struct brcms_band { u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */ u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */ + struct ieee80211_supported_band band; }; /* module control blocks */ From 3568a0a0e7881cdb955c6c6c90b0fb43ccaa3e98 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:26 -0700 Subject: [PATCH 1245/1519] staging: brcm80211: removed global var global_scb from softmac Global variables are undesirable unless they are read only. Removed by instead using an already defined Station Control Block variable in a per-device structure. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 6 +++--- .../staging/brcm80211/brcmsmac/mac80211_if.c | 19 ++++------------- drivers/staging/brcm80211/brcmsmac/main.c | 21 ++++++++++++------- drivers/staging/brcm80211/brcmsmac/main.h | 4 ++++ drivers/staging/brcm80211/brcmsmac/pub.h | 1 - 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index b94d60c2238..e29c62efeb1 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -314,7 +314,7 @@ static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, static void brcms_c_scb_ampdu_update_config_all(struct ampdu_info *ampdu) { - brcms_c_scb_ampdu_update_config(ampdu, ampdu->wlc->pub->global_scb); + brcms_c_scb_ampdu_update_config(ampdu, &du->wlc->pri_scb); } static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) @@ -482,7 +482,7 @@ brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, struct scb_ampdu *scb_ampdu; struct scb_ampdu_tid_ini *ini; struct ampdu_info *ampdu = wlc->ampdu; - struct scb *scb = wlc->pub->global_scb; + struct scb *scb = &wlc->pri_scb; scb_ampdu = &scb->scb_ampdu; if (!ampdu->ini_enable[tid]) { @@ -542,7 +542,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, f = ampdu->fifo_tb + prio2fifo[tid]; - scb = wlc->pub->global_scb; + scb = &wlc->pri_scb; scb_ampdu = &scb->scb_ampdu; ini = &scb_ampdu->ini[tid]; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index d5d0d9e668f..1c4568741e8 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -616,25 +616,14 @@ static int brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct scb *scb; - - int i; struct brcms_info *wl = hw->priv; + struct scb *scb = &wl->wlc->pri_scb; - /* Init the scb */ - scb = (struct scb *)sta->drv_priv; - memset(scb, 0, sizeof(struct scb)); - for (i = 0; i < NUMPRIO; i++) - scb->seqctl[i] = 0xFFFF; - scb->seqctl_nonqos = 0xFFFF; - scb->magic = SCB_MAGIC; + brcms_c_init_scb(scb); - wl->pub->global_scb = scb; wl->pub->global_ampdu = &(scb->scb_ampdu); wl->pub->global_ampdu->scb = scb; wl->pub->global_ampdu->max_pdu = 16; - brcmu_pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID, - AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); sta->ht_cap.ht_supported = true; sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; @@ -657,8 +646,8 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct scb *scb = (struct scb *)sta->drv_priv; struct brcms_info *wl = hw->priv; + struct scb *scb = &wl->wlc->pri_scb; int status; if (WARN_ON(scb->magic != SCB_MAGIC)) @@ -1038,7 +1027,7 @@ static int ieee_hw_init(struct ieee80211_hw *hw) hw->rate_control_algorithm = "minstrel_ht"; - hw->sta_data_size = sizeof(struct scb); + hw->sta_data_size = 0; return ieee_hw_rate_init(hw); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index a3c0157df47..7a14ab9b273 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -882,7 +882,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); if (tx_info->control.sta) - scb = (struct scb *)tx_info->control.sta->drv_priv; + scb = &wlc->pri_scb; if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); @@ -3331,14 +3331,21 @@ static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc) return chanspec; } -static struct scb global_scb; - -static void brcms_c_init_scb(struct brcms_c_info *wlc, struct scb *scb) +void brcms_c_init_scb(struct scb *scb) { int i; + + memset(scb, 0, sizeof(struct scb)); scb->flags = SCB_WMECAP | SCB_HTCAP; - for (i = 0; i < NUMPRIO; i++) + for (i = 0; i < NUMPRIO; i++) { scb->seqnum[i] = 0; + scb->seqctl[i] = 0xFFFF; + } + + scb->seqctl_nonqos = 0xFFFF; + scb->magic = SCB_MAGIC; + brcmu_pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID, + AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); } /* d11 core init @@ -3799,8 +3806,6 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_bandinit_ordered(wlc, chanspec); - brcms_c_init_scb(wlc, &global_scb); - /* init probe response timeout */ brcms_c_write_shm(wlc, M_PRS_MAXTIME, wlc->prb_resp_timeout); @@ -7684,7 +7689,7 @@ void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, { u8 prio; uint fifo; - struct scb *scb = &global_scb; + struct scb *scb = &wlc->pri_scb; struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); /* diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 9e12a1444d8..47665da8b54 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -22,6 +22,7 @@ #include #include "types.h" #include "d11.h" +#include "scb.h" #define INVCHANNEL 255 /* invalid channel */ @@ -483,6 +484,7 @@ struct brcms_txq_info { * tx_duty_cycle_cck: maximum allowed duty cycle for CCK. * pkt_queue: txq for transmit packets. * wiphy: + * pri_scb: primary Station Control Block */ struct brcms_c_info { struct brcms_pub *pub; @@ -610,6 +612,7 @@ struct brcms_c_info { struct brcms_txq_info *pkt_queue; struct wiphy *wiphy; + struct scb pri_scb; }; /* antsel module specific state */ @@ -864,5 +867,6 @@ extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on); extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant); extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode); +extern void brcms_c_init_scb(struct scb *scb); #endif /* _BRCM_MAIN_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 96703099ef9..b69833eb461 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -144,7 +144,6 @@ struct brcms_bss_info { struct brcms_pub { struct brcms_c_info *wlc; struct ieee80211_hw *ieee_hw; - struct scb *global_scb; struct scb_ampdu *global_ampdu; uint mac80211_state; uint unit; /* device instance number */ From 3cfbbacd8179e47d39e21cd2acaf5574d3847dee Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:27 -0700 Subject: [PATCH 1246/1519] staging: brcm80211: various global var related changes in softmac Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 11 +---------- drivers/staging/brcm80211/brcmsmac/main.h | 2 +- drivers/staging/brcm80211/brcmsmac/otp.c | 4 ++-- drivers/staging/brcm80211/brcmsmac/rate.h | 1 - drivers/staging/brcm80211/brcmsmac/srom.c | 15 +++++++++------ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 7a14ab9b273..e34b5119a63 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -428,8 +428,6 @@ const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; /* WME/802.1E Access Category to TX FIFO number */ static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; -static bool in_send_q; - /* 802.1D Priority to precedence queue mapping */ const u8 wlc_prio2prec_map[] = { _BRCMS_PREC_BE, /* 0 BE - Best-effort */ @@ -442,7 +440,7 @@ const u8 wlc_prio2prec_map[] = { _BRCMS_PREC_NC, /* 7 NC - Network Control */ }; -static u16 xmtfifo_sz[][NFIFO] = { +static const u16 xmtfifo_sz[][NFIFO] = { /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ {20, 192, 192, 21, 17, 5}, /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ @@ -7716,11 +7714,6 @@ void brcms_c_send_q(struct brcms_c_info *wlc) struct pktq *q = &qi->q; struct ieee80211_tx_info *tx_info; - if (in_send_q) - return; - else - in_send_q = true; - prec_map = wlc->tx_prec_map; /* Send all the enq'd pkts that we can. @@ -7752,8 +7745,6 @@ void brcms_c_send_q(struct brcms_c_info *wlc) prec_map = wlc->tx_prec_map; } } - - in_send_q = false; } void diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 47665da8b54..c938add2c45 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -359,7 +359,7 @@ struct brcms_hardware { u16 chanspec; /* bmac chanspec shadow */ uint *txavail[NFIFO]; /* # tx descriptors available */ - u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */ + const u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */ u32 pllreq; /* pll requests to keep PLL on */ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 05c78c7f33c..06cb5754323 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -80,7 +80,7 @@ struct otp_fn_s { struct otpinfo { uint ccrev; /* chipc revision */ - struct otp_fn_s *fn; /* OTP functions */ + const struct otp_fn_s *fn; /* OTP functions */ struct si_pub *sih; /* Saved sb handle */ /* IPX OTP section */ @@ -442,7 +442,7 @@ static int ipxotp_nvread(struct otpinfo *oi, char *data, uint *len) return -ENOTSUPP; } -static struct otp_fn_s ipxotp_fn = { +static const struct otp_fn_s ipxotp_fn = { (int (*)(struct otpinfo *)) ipxotp_size, (u16 (*)(struct otpinfo *, struct chipcregs *, uint)) ipxotp_read_bit, diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h index 2cc66e04c0d..e7b9dc2f273 100644 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ b/drivers/staging/brcm80211/brcmsmac/rate.h @@ -27,7 +27,6 @@ extern const struct brcms_c_rateset cck_ofdm_rates; extern const struct brcms_c_rateset ofdm_rates; extern const struct brcms_c_rateset cck_rates; extern const struct brcms_c_rateset gphy_legacy_rates; -extern const struct brcms_c_rateset wlc_lrs_rates; extern const struct brcms_c_rateset rate_limit_1_2; struct brcms_mcs_info { diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 5bf07328cea..ce319593a17 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -778,7 +778,9 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { {NULL, 0, 0, 0, 0} }; -static u8 srom_crc8_table[CRC8_TABLE_SIZE]; +/* crc table has the same contents for every device instance, so it can be + * shared between devices. */ +static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; static u16 *srom_window_address(struct si_pub *sih, u8 *curmap) { @@ -1052,8 +1054,9 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, /* fixup the endianness so crc8 will pass */ htol16_buf(buf, nwords * 2); - if (crc8(srom_crc8_table, (u8 *) buf, nwords * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) + if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, + CRC8_INIT_VALUE) != + CRC8_GOOD_VALUE(brcms_srom_crc8_table)) /* DBG only pci always read srom4 first, then srom8/9 */ err = -EIO; @@ -1089,8 +1092,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) /* fixup the endianness so crc8 will pass */ htol16_buf(buf, bufsz); - if (crc8(srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(srom_crc8_table)) + if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) err = -EIO; /* now correct the endianness of the byte array */ @@ -1147,7 +1150,7 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, sromwindow = srom_window_address(sih, curmap); - crc8_populate_lsb(srom_crc8_table, SROM_CRC8_POLY); + crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); if (ai_is_sprom_available(sih)) { err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, true); From e429e0b7f4f378333b752cd83a1bd5b7b2e22f63 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:28 -0700 Subject: [PATCH 1247/1519] staging: brcm80211: removed global variable in softmac otp Placed variable on the stack instead and deleted unused functions. Softmac was tested to function properly with multiple adapters in one system. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/otp.c | 143 +++-------------------- drivers/staging/brcm80211/brcmsmac/otp.h | 8 -- 2 files changed, 18 insertions(+), 133 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index 06cb5754323..f15e8beb4bc 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -67,15 +67,13 @@ /* Fixed size subregions sizes in words */ #define OTPGU_CI_SZ 2 +struct otpinfo; + /* OTP function struct */ struct otp_fn_s { - int (*size)(struct otpinfo *oi); - u16 (*read_bit)(struct otpinfo *oi, struct chipcregs *cc, uint off); - struct otpinfo *(*init)(struct si_pub *sih); + int (*init)(struct si_pub *sih, struct otpinfo *oi); int (*read_region)(struct otpinfo *oi, int region, u16 *data, uint *wlen); - int (*nvread)(struct otpinfo *oi, char *data, uint *len); - int (*status)(struct otpinfo *oi); }; struct otpinfo { @@ -99,21 +97,6 @@ struct otpinfo { int otpgu_base; /* offset to General Use Region */ }; -static struct otpinfo otpinfo; - -/* - * IPX OTP Code - * - * Exported functions: - * ipxotp_status() - * ipxotp_size() - * ipxotp_init() - * ipxotp_read_bit() - * ipxotp_read_region() - * ipxotp_nvread() - * - */ - /* OTP layout */ /* CC revs 21, 24 and 27 OTP General Use Region word offset */ #define REVA4_OTPGU_BASE 12 @@ -149,51 +132,11 @@ static struct otpinfo otpinfo; #define OTP4315_SWREG_SZ 178 /* 178 bytes */ #define OTP_SZ_FU_144 (144/8) /* 144 bits */ -static int ipxotp_status(struct otpinfo *oi) -{ - return (int)(oi->status); -} - -/* Return size in bytes */ -static int ipxotp_size(struct otpinfo *oi) -{ - return (int)oi->wsize * 2; -} - static u16 ipxotp_otpr(struct otpinfo *oi, struct chipcregs *cc, uint wn) { return R_REG(&cc->sromotp[wn]); } -static u16 ipxotp_read_bit(struct otpinfo *oi, struct chipcregs *cc, uint off) -{ - uint k, row, col; - u32 otpp, st; - - row = off / oi->cols; - col = off % oi->cols; - - otpp = OTPP_START_BUSY | - ((OTPPOC_READ << OTPP_OC_SHIFT) & OTPP_OC_MASK) | - ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) | - ((col << OTPP_COL_SHIFT) & OTPP_COL_MASK); - W_REG(&cc->otpprog, otpp); - - for (k = 0; - ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) - && (k < OTPP_TRIES); k++) - ; - if (k >= OTPP_TRIES) - return 0xffff; - - if (st & OTPP_READERR) - return 0xffff; - - st = (st & OTPP_VALUE_MASK) >> OTPP_VALUE_SHIFT; - - return (int)st; -} - /* * Calculate max HW/SW region byte size by subtracting fuse region * and checksum size, osizew is oi->wsize (OTP size - GU size) in words @@ -294,28 +237,24 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) oi->flim = oi->wsize; } -static struct otpinfo *ipxotp_init(struct si_pub *sih) +static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) { uint idx; struct chipcregs *cc; - struct otpinfo *oi; /* Make sure we're running IPX OTP */ if (!OTPTYPE_IPX(sih->ccrev)) - return NULL; + return -EBADE; /* Make sure OTP is not disabled */ if (ai_is_otp_disabled(sih)) - return NULL; - - /* OTP is always powered */ - oi = &otpinfo; + return -EBADE; /* Check for otp size */ switch ((sih->cccaps & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) { case 0: /* Nothing there */ - return NULL; + return -EBADE; case 1: /* 32x64 */ oi->rows = 32; oi->cols = 64; @@ -338,7 +277,7 @@ static struct otpinfo *ipxotp_init(struct si_pub *sih) break; default: /* Don't know the geometry */ - return NULL; + return -EBADE; } /* Retrieve OTP region info */ @@ -349,7 +288,7 @@ static struct otpinfo *ipxotp_init(struct si_pub *sih) ai_setcoreidx(sih, idx); - return oi; + return 0; } static int @@ -437,56 +376,16 @@ ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) return 0; } -static int ipxotp_nvread(struct otpinfo *oi, char *data, uint *len) -{ - return -ENOTSUPP; -} - static const struct otp_fn_s ipxotp_fn = { - (int (*)(struct otpinfo *)) ipxotp_size, - (u16 (*)(struct otpinfo *, struct chipcregs *, uint)) ipxotp_read_bit, - - (struct otpinfo *(*)(struct si_pub *)) ipxotp_init, + (int (*)(struct si_pub *, struct otpinfo *)) ipxotp_init, (int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region, - (int (*)(struct otpinfo *, char *, uint *)) ipxotp_nvread, - - (int (*)(struct otpinfo *)) ipxotp_status }; -/* - * otp_status() - * otp_size() - * otp_read_bit() - * otp_init() - * otp_read_region() - * otp_nvread() - */ - -int otp_status(struct otpinfo *oi) +static int otp_init(struct si_pub *sih, struct otpinfo *oi) { - return oi->fn->status(oi); -} -int otp_size(struct otpinfo *oi) -{ - return oi->fn->size(oi); -} + int ret; -u16 otp_read_bit(struct otpinfo *oi, uint offset) -{ - uint idx = ai_coreidx(oi->sih); - struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX); - u16 readBit = (u16) oi->fn->read_bit(oi, cc, offset); - ai_setcoreidx(oi->sih, idx); - return readBit; -} - -struct otpinfo *otp_init(struct si_pub *sih) -{ - struct otpinfo *oi; - struct otpinfo *ret = NULL; - - oi = &otpinfo; memset(oi, 0, sizeof(struct otpinfo)); oi->ccrev = sih->ccrev; @@ -495,18 +394,19 @@ struct otpinfo *otp_init(struct si_pub *sih) oi->fn = &ipxotp_fn; if (oi->fn == NULL) - return NULL; + return -EBADE; oi->sih = sih; - ret = (oi->fn->init) (sih); + ret = (oi->fn->init) (sih, oi); return ret; } int otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) { - struct otpinfo *oi; + struct otpinfo otpinfo; + struct otpinfo *oi = &otpinfo; int err = 0; if (ai_is_otp_disabled(sih)) { @@ -514,19 +414,12 @@ otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) { goto out; } - oi = otp_init(sih); - if (oi == NULL) { - err = -EBADE; + err = otp_init(sih, oi); + if (err) goto out; - } err = ((oi)->fn->read_region)(oi, region, data, wlen); out: return err; } - -int otp_nvread(struct otpinfo *oi, char *data, uint *len) -{ - return oi->fn->nvread(oi, data, len); -} diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h index bf2f76f96ac..6b6d31cf956 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.h +++ b/drivers/staging/brcm80211/brcmsmac/otp.h @@ -30,15 +30,7 @@ /* OTP Size */ #define OTP_SZ_MAX (6144/8) /* maximum bytes in one CIS */ -struct otpinfo; - -/* Exported functions */ -extern int otp_status(struct otpinfo *oi); -extern int otp_size(struct otpinfo *oi); -extern u16 otp_read_bit(struct otpinfo *oi, uint offset); -extern struct otpinfo *otp_init(struct si_pub *sih); extern int otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen); -extern int otp_nvread(struct otpinfo *oi, char *data, uint *len); #endif /* _BRCM_OTP_H_ */ From d6cf28b310b497b001af755d88394df005dc7b5a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:29 -0700 Subject: [PATCH 1248/1519] staging: brcm80211: changing interface to n-phy rssi compute function The function wlc_phy_rssi_compute_nphy() was called with pointer to brcms_d11rxhdr structure in which it filled in the received power per antenna. However, these are not used further in the driver so it only needs the d11rxhdr structure as input for rssi calculation. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- drivers/staging/brcm80211/brcmsmac/phy/phy_int.h | 2 +- drivers/staging/brcm80211/brcmsmac/phy/phy_n.c | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index a26c682abc2..80252478c5f 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -2646,7 +2646,7 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, rssi -= 256; } else if (radioid == BCM2055_ID || radioid == BCM2056_ID || radioid == BCM2057_ID) { - rssi = wlc_phy_rssi_compute_nphy(pi, wlc_rxhdr); + rssi = wlc_phy_rssi_compute_nphy(pi, rxh); } end: diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index b94117b006e..8ce01596b90 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -1183,7 +1183,7 @@ extern void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, extern void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi); extern int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, - struct brcms_d11rxhdr *wlc_rxh); + struct d11rxhdr *rxh); #define NPHY_TESTPATTERN_BPHY_EVM 0 #define NPHY_TESTPATTERN_BPHY_RFCS 1 diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 58645d2b79d..ff8b1d861f3 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -23109,9 +23109,8 @@ void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi) } int -wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct brcms_d11rxhdr *wlc_rxh) +wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh) { - struct d11rxhdr *rxh = &wlc_rxh->rxhdr; s16 rxpwr, rxpwr0, rxpwr1; s16 phyRx0_l, phyRx2_l; @@ -23134,10 +23133,6 @@ wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct brcms_d11rxhdr *wlc_rxh) rxpwr1 = phyRx2_l; } - wlc_rxh->rxpwr[0] = (s8) rxpwr0; - wlc_rxh->rxpwr[1] = (s8) rxpwr1; - wlc_rxh->do_rssi_ma = 0; - if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MAX) rxpwr = (rxpwr0 > rxpwr1) ? rxpwr0 : rxpwr1; else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MIN) From e053edb69abd8b8ac0501b21f3bc7e61c9a532ad Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:30 -0700 Subject: [PATCH 1249/1519] staging: brcm80211: change interface for common rssi compute function The function wlc_phy_rssi_compute() now uses d11rxhdr struct as purely input parameter and returns the computed rssi value. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 4 +++- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 7 +++---- drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index e34b5119a63..ef96358ed99 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -806,15 +806,17 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) /* process each frame */ while ((p = head) != NULL) { + struct d11rxhdr *rxh; head = head->prev; p->prev = NULL; wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; + rxh = (struct d11rxhdr *)p->data; /* * compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ - wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr); + wlc_rxhdr->rssi = wlc_phy_rssi_compute(wlc_hw->band->pi, rxh); brcms_c_recv(wlc_hw->wlc, p); } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 80252478c5f..c359a10ca12 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -2610,10 +2610,9 @@ void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) } } -void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, - struct brcms_d11rxhdr *wlc_rxhdr) +int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, + struct d11rxhdr *rxh) { - struct d11rxhdr *rxh = &wlc_rxhdr->rxhdr; int rssi = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_JSSI_MASK; uint radioid = pih->radioid; struct brcms_phy *pi = (struct brcms_phy *) pih; @@ -2650,7 +2649,7 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, } end: - wlc_rxhdr->rssi = (s8) rssi; + return rssi; } void wlc_phy_freqtrack_start(struct brcms_phy_pub *pih) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index 1dbfaa3522b..39c3c2248e0 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -212,8 +212,8 @@ extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi); extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw); -extern void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, - struct brcms_d11rxhdr *wlc_rxhdr); +extern int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, + struct d11rxhdr *rxh); extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi); extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi); extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi); From f32f116bdae1b6f8913b333694d4014aa9b6f7e6 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:31 -0700 Subject: [PATCH 1250/1519] staging: brcm80211: convert endianess before handling the frame The received frame from the device is in little-endian order and converted in the receive path. However, the phy code was doing the rssi calculation with packet in LE order. This has been changed to do the le_to_cpu conversion before doing the rssi computation and further receive processing. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 27 +++++++++---------- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 6 ++--- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 8 +++--- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index ef96358ed99..1a7d005fdc6 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -813,11 +813,23 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; rxh = (struct d11rxhdr *)p->data; + /* fixup rx header endianness */ + rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize); + rxh->PhyRxStatus_0 = le16_to_cpu(rxh->PhyRxStatus_0); + rxh->PhyRxStatus_1 = le16_to_cpu(rxh->PhyRxStatus_1); + rxh->PhyRxStatus_2 = le16_to_cpu(rxh->PhyRxStatus_2); + rxh->PhyRxStatus_3 = le16_to_cpu(rxh->PhyRxStatus_3); + rxh->PhyRxStatus_4 = le16_to_cpu(rxh->PhyRxStatus_4); + rxh->PhyRxStatus_5 = le16_to_cpu(rxh->PhyRxStatus_5); + rxh->RxStatus1 = le16_to_cpu(rxh->RxStatus1); + rxh->RxStatus2 = le16_to_cpu(rxh->RxStatus2); + rxh->RxTSFTime = le16_to_cpu(rxh->RxTSFTime); + rxh->RxChan = le16_to_cpu(rxh->RxChan); + /* * compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ wlc_rxhdr->rssi = wlc_phy_rssi_compute(wlc_hw->band->pi, rxh); - brcms_c_recv(wlc_hw->wlc, p); } @@ -8289,19 +8301,6 @@ void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) /* strip off rxhdr */ skb_pull(p, BRCMS_HWRXOFF); - /* fixup rx header endianness */ - rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize); - rxh->PhyRxStatus_0 = le16_to_cpu(rxh->PhyRxStatus_0); - rxh->PhyRxStatus_1 = le16_to_cpu(rxh->PhyRxStatus_1); - rxh->PhyRxStatus_2 = le16_to_cpu(rxh->PhyRxStatus_2); - rxh->PhyRxStatus_3 = le16_to_cpu(rxh->PhyRxStatus_3); - rxh->PhyRxStatus_4 = le16_to_cpu(rxh->PhyRxStatus_4); - rxh->PhyRxStatus_5 = le16_to_cpu(rxh->PhyRxStatus_5); - rxh->RxStatus1 = le16_to_cpu(rxh->RxStatus1); - rxh->RxStatus2 = le16_to_cpu(rxh->RxStatus2); - rxh->RxTSFTime = le16_to_cpu(rxh->RxTSFTime); - rxh->RxChan = le16_to_cpu(rxh->RxChan); - /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ if (rxh->RxStatus1 & RXS_PBPRES) { if (p->len < 2) { diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index c359a10ca12..f9702c0fa85 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -2613,18 +2613,18 @@ void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, struct d11rxhdr *rxh) { - int rssi = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_JSSI_MASK; + int rssi = rxh->PhyRxStatus_1 & PRXS1_JSSI_MASK; uint radioid = pih->radioid; struct brcms_phy *pi = (struct brcms_phy *) pih; if ((pi->sh->corerev >= 11) - && !(le16_to_cpu(rxh->RxStatus2) & RXS_PHYRXST_VALID)) { + && !(rxh->RxStatus2 & RXS_PHYRXST_VALID)) { rssi = BRCMS_RSSI_INVALID; goto end; } if (ISLCNPHY(pi)) { - u8 gidx = (le16_to_cpu(rxh->PhyRxStatus_2) & 0xFC00) >> 10; + u8 gidx = (rxh->PhyRxStatus_2 & 0xFC00) >> 10; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; if (rssi > 127) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index ff8b1d861f3..a34d292bd61 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -23115,16 +23115,16 @@ wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh) s16 phyRx0_l, phyRx2_l; rxpwr = 0; - rxpwr0 = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR0_MASK; - rxpwr1 = (le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR1_MASK) >> 8; + rxpwr0 = rxh->PhyRxStatus_1 & PRXS1_nphy_PWR0_MASK; + rxpwr1 = (rxh->PhyRxStatus_1 & PRXS1_nphy_PWR1_MASK) >> 8; if (rxpwr0 > 127) rxpwr0 -= 256; if (rxpwr1 > 127) rxpwr1 -= 256; - phyRx0_l = le16_to_cpu(rxh->PhyRxStatus_0) & 0x00ff; - phyRx2_l = le16_to_cpu(rxh->PhyRxStatus_2) & 0x00ff; + phyRx0_l = rxh->PhyRxStatus_0 & 0x00ff; + phyRx2_l = rxh->PhyRxStatus_2 & 0x00ff; if (phyRx2_l > 127) phyRx2_l -= 256; From 776dddc52d67e67c74d7cc9a60e915a4dab73a3d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:32 -0700 Subject: [PATCH 1251/1519] staging: brcm80211: use endian annotated structures in brcmsmac Structures interfacing with the device have a specific endianess and structures exchanged between host and device have been annotated so sparse checking can be done. The Makefile has been modified to add the __CHECK_ENDIAN__ flag. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/Makefile | 3 +- drivers/staging/brcm80211/brcmsmac/d11.h | 77 ++++++++++------- drivers/staging/brcm80211/brcmsmac/dma.c | 41 +++++---- .../staging/brcm80211/brcmsmac/mac80211_if.c | 12 +-- drivers/staging/brcm80211/brcmsmac/main.c | 86 ++++++++++--------- drivers/staging/brcm80211/brcmsmac/srom.c | 4 +- .../staging/brcm80211/brcmsmac/ucode_loader.h | 8 +- 7 files changed, 126 insertions(+), 105 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile index 8fdca2ef846..e44859ddc98 100644 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -15,7 +15,8 @@ # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -ccflags-y := \ +ccflags-y := \ + -D__CHECK_ENDIAN__ \ -Idrivers/staging/brcm80211/brcmsmac \ -Idrivers/staging/brcm80211/brcmsmac/phy \ -Idrivers/staging/brcm80211/include diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index cbb574ab228..1f05e8aafe2 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -745,37 +745,37 @@ struct cck_phy_hdr { /* TX DMA buffer header */ struct d11txh { - u16 MacTxControlLow; /* 0x0 */ - u16 MacTxControlHigh; /* 0x1 */ - u16 MacFrameControl; /* 0x2 */ - u16 TxFesTimeNormal; /* 0x3 */ - u16 PhyTxControlWord; /* 0x4 */ - u16 PhyTxControlWord_1; /* 0x5 */ - u16 PhyTxControlWord_1_Fbr; /* 0x6 */ - u16 PhyTxControlWord_1_Rts; /* 0x7 */ - u16 PhyTxControlWord_1_FbrRts; /* 0x8 */ - u16 MainRates; /* 0x9 */ - u16 XtraFrameTypes; /* 0xa */ + __le16 MacTxControlLow; /* 0x0 */ + __le16 MacTxControlHigh; /* 0x1 */ + __le16 MacFrameControl; /* 0x2 */ + __le16 TxFesTimeNormal; /* 0x3 */ + __le16 PhyTxControlWord; /* 0x4 */ + __le16 PhyTxControlWord_1; /* 0x5 */ + __le16 PhyTxControlWord_1_Fbr; /* 0x6 */ + __le16 PhyTxControlWord_1_Rts; /* 0x7 */ + __le16 PhyTxControlWord_1_FbrRts; /* 0x8 */ + __le16 MainRates; /* 0x9 */ + __le16 XtraFrameTypes; /* 0xa */ u8 IV[16]; /* 0x0b - 0x12 */ u8 TxFrameRA[6]; /* 0x13 - 0x15 */ - u16 TxFesTimeFallback; /* 0x16 */ + __le16 TxFesTimeFallback; /* 0x16 */ u8 RTSPLCPFallback[6]; /* 0x17 - 0x19 */ - u16 RTSDurFallback; /* 0x1a */ + __le16 RTSDurFallback; /* 0x1a */ u8 FragPLCPFallback[6]; /* 0x1b - 1d */ - u16 FragDurFallback; /* 0x1e */ - u16 MModeLen; /* 0x1f */ - u16 MModeFbrLen; /* 0x20 */ - u16 TstampLow; /* 0x21 */ - u16 TstampHigh; /* 0x22 */ - u16 ABI_MimoAntSel; /* 0x23 */ - u16 PreloadSize; /* 0x24 */ - u16 AmpduSeqCtl; /* 0x25 */ - u16 TxFrameID; /* 0x26 */ - u16 TxStatus; /* 0x27 */ - u16 MaxNMpdus; /* 0x28 */ - u16 MaxABytes_MRT; /* 0x29 */ - u16 MaxABytes_FBR; /* 0x2a */ - u16 MinMBytes; /* 0x2b */ + __le16 FragDurFallback; /* 0x1e */ + __le16 MModeLen; /* 0x1f */ + __le16 MModeFbrLen; /* 0x20 */ + __le16 TstampLow; /* 0x21 */ + __le16 TstampHigh; /* 0x22 */ + __le16 ABI_MimoAntSel; /* 0x23 */ + __le16 PreloadSize; /* 0x24 */ + __le16 AmpduSeqCtl; /* 0x25 */ + __le16 TxFrameID; /* 0x26 */ + __le16 TxStatus; /* 0x27 */ + __le16 MaxNMpdus; /* 0x28 */ + __le16 MaxABytes_MRT; /* 0x29 */ + __le16 MaxABytes_FBR; /* 0x2a */ + __le16 MinMBytes; /* 0x2b */ u8 RTSPhyHeader[D11_PHY_HDR_LEN]; /* 0x2c - 0x2e */ struct ieee80211_rts rts_frame; /* 0x2f - 0x36 */ u16 PAD; /* 0x37 */ @@ -1379,6 +1379,21 @@ struct shm_acparams { * RxTSFTime: RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY * RxChan: gain code, channel radio code, and phy type */ +struct d11rxhdr_le { + __le16 RxFrameSize; + u16 PAD; + __le16 PhyRxStatus_0; + __le16 PhyRxStatus_1; + __le16 PhyRxStatus_2; + __le16 PhyRxStatus_3; + __le16 PhyRxStatus_4; + __le16 PhyRxStatus_5; + __le16 RxStatus1; + __le16 RxStatus2; + __le16 RxTSFTime; + __le16 RxChan; +} __packed; + struct d11rxhdr { u16 RxFrameSize; u16 PAD; @@ -1392,20 +1407,18 @@ struct d11rxhdr { u16 RxStatus2; u16 RxTSFTime; u16 RxChan; -} __packed; +}; /* * rxhdr: received frame header data - * tsf_l: TSF_L reading - * rssi: computed instanteneous rssi in BMAC + * rssi: rssi computed by PHY * rxpwr0: obsoleted, place holder for legacy ROM code. use rxpwr[] * rxpwr1: obsoleted, place holder for legacy ROM code. use rxpwr[] * do_rssi_ma: do per-pkt sampling for per-antenna ma in HIGH * rxpwr: rssi for supported antennas */ struct brcms_d11rxhdr { - struct d11rxhdr rxhdr; - u32 tsf_l; + struct d11rxhdr rxh_cpu; s8 rssi; s8 rxpwr0; s8 rxpwr1; diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index 714c74c78f5..ef856ce635b 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -206,10 +206,10 @@ * Descriptors are only read by the hardware, never written back. */ struct dma64desc { - u32 ctrl1; /* misc control bits & bufcount */ - u32 ctrl2; /* buffer count and address extension */ - u32 addrlow; /* memory address of the date buffer, bits 31:0 */ - u32 addrhigh; /* memory address of the date buffer, bits 63:32 */ + __le32 ctrl1; /* misc control bits & bufcount */ + __le32 ctrl2; /* buffer count and address extension */ + __le32 addrlow; /* memory address of the date buffer, bits 31:0 */ + __le32 addrhigh; /* memory address of the date buffer, bits 63:32 */ }; /* dma engine software state */ @@ -295,15 +295,18 @@ struct dma_info { static uint dma_msg_level; /* Check for odd number of 1's */ -static u32 parity32(u32 data) +static u32 parity32(__le32 data) { - data ^= data >> 16; - data ^= data >> 8; - data ^= data >> 4; - data ^= data >> 2; - data ^= data >> 1; + /* no swap needed for counting 1's */ + u32 par_data = *(u32 *)&data; - return data & 1; + par_data ^= par_data >> 16; + par_data ^= par_data >> 8; + par_data ^= par_data >> 4; + par_data ^= par_data >> 2; + par_data ^= par_data >> 1; + + return par_data & 1; } static bool dma64_dd_parity(struct dma64desc *dd) @@ -873,13 +876,13 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) rxp = di->rxp[i]; di->rxp[i] = NULL; - pa = cpu_to_le32(di->rxd64[i].addrlow) - di->dataoffsetlow; + pa = le32_to_cpu(di->rxd64[i].addrlow) - di->dataoffsetlow; /* clear this packet from the descriptor ring */ pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); - di->rxd64[i].addrlow = 0xdeadbeef; - di->rxd64[i].addrhigh = 0xdeadbeef; + di->rxd64[i].addrlow = cpu_to_le32(0xdeadbeef); + di->rxd64[i].addrhigh = cpu_to_le32(0xdeadbeef); di->rxin = nextrxd(di, i); @@ -917,7 +920,7 @@ struct sk_buff *dma_rx(struct dma_pub *pub) if (head == NULL) return NULL; - len = le16_to_cpu(*(u16 *) (head->data)); + len = le16_to_cpu(*(__le16 *) (head->data)); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); dma_spin_for_len(len, head); @@ -1367,14 +1370,14 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) dma_addr_t pa; uint size; - pa = cpu_to_le32(di->txd64[i].addrlow) - di->dataoffsetlow; + pa = le32_to_cpu(di->txd64[i].addrlow) - di->dataoffsetlow; size = - (cpu_to_le32(di->txd64[i].ctrl2) & + (le32_to_cpu(di->txd64[i].ctrl2) & D64_CTRL2_BC_MASK); - di->txd64[i].addrlow = 0xdeadbeef; - di->txd64[i].addrhigh = 0xdeadbeef; + di->txd64[i].addrlow = cpu_to_le32(0xdeadbeef); + di->txd64[i].addrhigh = cpu_to_le32(0xdeadbeef); txp = di->txp[i]; di->txp[i] = NULL; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 1c4568741e8..1fa95d71973 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -89,9 +89,9 @@ } struct firmware_hdr { - u32 offset; - u32 len; - u32 idx; + __le32 offset; + __le32 len; + __le32 idx; }; static const char * const brcms_firmwares[MAX_FW_IMAGES] = { @@ -243,7 +243,7 @@ static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { .mcs = { /* placeholders for now */ .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = 500, + .rx_highest = cpu_to_le16(500), .tx_params = IEEE80211_HT_MCS_TX_DEFINED} } }; @@ -265,7 +265,7 @@ static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { .mcs = { /* placeholders for now */ .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = 500, + .rx_highest = cpu_to_le16(500), .tx_params = IEEE80211_HT_MCS_TX_DEFINED} } }; @@ -1625,7 +1625,7 @@ int brcms_ucode_init_uint(struct brcms_info *wl, u32 *data, u32 idx) "ERROR: fw hdr len\n"); return -ENOMSG; } - *data = le32_to_cpu(*((u32 *) pdata)); + *data = le32_to_cpu(*((__le32 *) pdata)); return 0; } } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 1a7d005fdc6..3e39407c692 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -338,9 +338,9 @@ static u16 frametype(u32 rspec, u8 mimoframe) #define XMTFIFOTBL_STARTREV 20 struct d11init { - u16 addr; - u16 size; - u32 value; + __le16 addr; + __le16 size; + __le32 value; }; /* currently the best mechanism for determining SIFS is the band in use */ @@ -666,7 +666,7 @@ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, base = (u8 *)wlc_hw->regs; - for (i = 0; inits[i].addr != 0xffff; i++) { + for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { size = le16_to_cpu(inits[i].size); addr = base + le16_to_cpu(inits[i].addr); value = le32_to_cpu(inits[i].value); @@ -806,30 +806,33 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) /* process each frame */ while ((p = head) != NULL) { + struct d11rxhdr_le *rxh_le; struct d11rxhdr *rxh; head = head->prev; p->prev = NULL; - wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; + rxh_le = (struct d11rxhdr_le *)p->data; rxh = (struct d11rxhdr *)p->data; + wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; /* fixup rx header endianness */ - rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize); - rxh->PhyRxStatus_0 = le16_to_cpu(rxh->PhyRxStatus_0); - rxh->PhyRxStatus_1 = le16_to_cpu(rxh->PhyRxStatus_1); - rxh->PhyRxStatus_2 = le16_to_cpu(rxh->PhyRxStatus_2); - rxh->PhyRxStatus_3 = le16_to_cpu(rxh->PhyRxStatus_3); - rxh->PhyRxStatus_4 = le16_to_cpu(rxh->PhyRxStatus_4); - rxh->PhyRxStatus_5 = le16_to_cpu(rxh->PhyRxStatus_5); - rxh->RxStatus1 = le16_to_cpu(rxh->RxStatus1); - rxh->RxStatus2 = le16_to_cpu(rxh->RxStatus2); - rxh->RxTSFTime = le16_to_cpu(rxh->RxTSFTime); - rxh->RxChan = le16_to_cpu(rxh->RxChan); + rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); + rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); + rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); + rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); + rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); + rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); + rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); + rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); + rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); + rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); + rxh->RxChan = le16_to_cpu(rxh_le->RxChan); /* * compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ - wlc_rxhdr->rssi = wlc_phy_rssi_compute(wlc_hw->band->pi, rxh); + wlc_rxhdr->rssi = (s8)wlc_phy_rssi_compute(wlc_hw->band->pi, + rxh); brcms_c_recv(wlc_hw->wlc, p); } @@ -888,7 +891,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) brcms_c_print_txstatus(txs); } - if (txs->frameid != cpu_to_le16(txh->TxFrameID)) + if (txs->frameid != le16_to_cpu(txh->TxFrameID)) goto fatal; tx_info = IEEE80211_SKB_CB(p); h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); @@ -907,7 +910,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) "%s: Pkt tx suppressed, possibly channel %d\n", __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); - tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS; + tx_rts = le16_to_cpu(txh->MacTxControlLow) & TXC_SENDRTS; tx_frame_count = (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; tx_rts_count = @@ -1676,6 +1679,8 @@ brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, { struct d11regs *regs; u32 word; + __le32 word_le; + __be32 word_be; bool be_bit; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -1691,10 +1696,13 @@ brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, while (len > 0) { memcpy(&word, buf, sizeof(u32)); - if (be_bit) - word = cpu_to_be32(word); - else - word = cpu_to_le32(word); + if (be_bit) { + word_be = cpu_to_be32(word); + word = *(u32 *)&word_be; + } else { + word_le = cpu_to_le32(word); + word = *(u32 *)&word_le; + } W_REG(®s->tplatewrdata, word); @@ -2437,8 +2445,9 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY); } -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const u32 ucode[], - const uint nbytes) { +static void brcms_ucode_write(struct brcms_hardware *wlc_hw, + const __le32 ucode[], const size_t nbytes) +{ struct d11regs *regs = wlc_hw->regs; uint i; uint count; @@ -4260,7 +4269,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, do { memset((char *)&acp_shm, 0, sizeof(struct shm_acparams)); /* fill in shm ac params struct */ - acp_shm.txop = le16_to_cpu(params->txop); + acp_shm.txop = params->txop; /* convert from units of 32us to us for ucode */ wlc->edcf_txop[aci & 0x3] = acp_shm.txop = EDCF_TXOP2USEC(acp_shm.txop); @@ -4313,16 +4322,11 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) u16 aci; int i_ac; struct ieee80211_tx_queue_params txq_pars; - struct ieee80211_tx_queue_params *params = &txq_pars; static const struct edcf_acparam default_edcf_acparams[] = { - {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, - cpu_to_le16(EDCF_AC_BE_TXOP_STA)}, - {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, - cpu_to_le16(EDCF_AC_BK_TXOP_STA)}, - {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, - cpu_to_le16(EDCF_AC_VI_TXOP_STA)}, - {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, - cpu_to_le16(EDCF_AC_VO_TXOP_STA)} + {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, EDCF_AC_BE_TXOP_STA}, + {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, EDCF_AC_BK_TXOP_STA}, + {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, EDCF_AC_VI_TXOP_STA}, + {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, EDCF_AC_VO_TXOP_STA} }; /* ucode needs these parameters during its initialization */ const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; @@ -4331,15 +4335,15 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; /* fill in shm ac params struct */ - params->txop = edcf_acp->TXOP; - params->aifs = edcf_acp->ACI; + txq_pars.txop = edcf_acp->TXOP; + txq_pars.aifs = edcf_acp->ACI; /* CWmin = 2^(ECWmin) - 1 */ - params->cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); + txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); /* CWmax = 2^(ECWmax) - 1 */ - params->cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) + txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) >> EDCF_ECWMAX_SHIFT); - brcms_c_wme_setparams(wlc, aci, params, suspend); + brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); } if (suspend) @@ -8126,7 +8130,7 @@ static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); rx_tsf_16_31 = (u16)(tsf_l >> 16); - rx_tsf_0_15 = rxh->rxhdr.RxTSFTime; + rx_tsf_0_15 = rxh->rxh_cpu.RxTSFTime; /* * a greater tsf time indicates the low 16 bits of diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index ce319593a17..01053065e36 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -822,14 +822,14 @@ static inline void ltoh16_buf(u16 *buf, unsigned int size) { size /= 2; while (size--) - *(buf + size) = le16_to_cpu(*(buf + size)); + *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); } static inline void htol16_buf(u16 *buf, unsigned int size) { size /= 2; while (size--) - *(buf + size) = cpu_to_le16(*(buf + size)); + *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); } /* Initialization of varbuf structure */ diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h index 438675ae441..49d5b7e9a4e 100644 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h +++ b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h @@ -35,10 +35,10 @@ struct brcms_ucode { struct d11init *d11n0absinitvals16; struct d11init *d11n0bsinitvals16; struct d11init *d11n0initvals16; - u32 *bcm43xx_16_mimo; - u32 bcm43xx_16_mimosz; - u32 *bcm43xx_24_lcn; - u32 bcm43xx_24_lcnsz; + __le32 *bcm43xx_16_mimo; + size_t bcm43xx_16_mimosz; + __le32 *bcm43xx_24_lcn; + size_t bcm43xx_24_lcnsz; u32 *bcm43xx_bommajor; u32 *bcm43xx_bomminor; }; From 28bb0f60ce2ae66831735c650804942fa9da0b70 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:33 -0700 Subject: [PATCH 1252/1519] staging: brcm80211: move rssi computation to place we need it The rssi computation was done upon getting the frame from the queue, but the value is needed when filling in the receive status data for mac80211. The call to wlc_phy_rssi_compute() has been deferred. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 3e39407c692..bdc0611bb27 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -828,11 +828,6 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); rxh->RxChan = le16_to_cpu(rxh_le->RxChan); - /* - * compute the RSSI from d11rxhdr and record it in wlc_rxd11hr - */ - wlc_rxhdr->rssi = (s8)wlc_phy_rssi_compute(wlc_hw->band->pi, - rxh); brcms_c_recv(wlc_hw->wlc, p); } @@ -8172,7 +8167,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, rx_status->freq = ieee80211_dsss_chan_to_freq(channel); } - rx_status->signal = wlc_rxh->rssi; + rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); /* noise */ /* qual */ From e4e2f462aea3308891855a078b655675e7cc3c94 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 29 Sep 2011 15:34:34 -0700 Subject: [PATCH 1253/1519] staging: brcm80211: use d11rxhdr structure in brcms_c_recover_tsf64() All information needed for this function is available in the d11rxhdr structure. This is the last place where the brcms_d11rxhdr structure so it can be removed. Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/d11.h | 17 ----------------- drivers/staging/brcm80211/brcmsmac/main.c | 9 +++------ drivers/staging/brcm80211/brcmsmac/types.h | 1 - 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index 1f05e8aafe2..ed51616abc8 100644 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -1407,23 +1407,6 @@ struct d11rxhdr { u16 RxStatus2; u16 RxTSFTime; u16 RxChan; -}; - -/* - * rxhdr: received frame header data - * rssi: rssi computed by PHY - * rxpwr0: obsoleted, place holder for legacy ROM code. use rxpwr[] - * rxpwr1: obsoleted, place holder for legacy ROM code. use rxpwr[] - * do_rssi_ma: do per-pkt sampling for per-antenna ma in HIGH - * rxpwr: rssi for supported antennas - */ -struct brcms_d11rxhdr { - struct d11rxhdr rxh_cpu; - s8 rssi; - s8 rxpwr0; - s8 rxpwr1; - s8 do_rssi_ma; - s8 rxpwr[WL_RSSI_ANT_MAX]; } __packed; /* PhyRxStatus_0: */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index bdc0611bb27..4f79a42604e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -783,7 +783,6 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) struct sk_buff *tail = NULL; uint n = 0; uint bound_limit = bound ? RXBND : -1; - struct brcms_d11rxhdr *wlc_rxhdr = NULL; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); /* gather received frames */ @@ -813,7 +812,6 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) rxh_le = (struct d11rxhdr_le *)p->data; rxh = (struct d11rxhdr *)p->data; - wlc_rxhdr = (struct brcms_d11rxhdr *) p->data; /* fixup rx header endianness */ rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); @@ -8117,7 +8115,7 @@ brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, * are used. Finally, the tsf_h is read from the tsf register. */ static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, - struct brcms_d11rxhdr *rxh) + struct d11rxhdr *rxh) { u32 tsf_h, tsf_l; u16 rx_tsf_0_15, rx_tsf_16_31; @@ -8125,7 +8123,7 @@ static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); rx_tsf_16_31 = (u16)(tsf_l >> 16); - rx_tsf_0_15 = rxh->rxh_cpu.RxTSFTime; + rx_tsf_0_15 = rxh->RxTSFTime; /* * a greater tsf time indicates the low 16 bits of @@ -8145,14 +8143,13 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, struct sk_buff *p, struct ieee80211_rx_status *rx_status) { - struct brcms_d11rxhdr *wlc_rxh = (struct brcms_d11rxhdr *) rxh; int preamble; int channel; u32 rspec; unsigned char *plcp; /* fill in TSF and flag its presence */ - rx_status->mactime = brcms_c_recover_tsf64(wlc, wlc_rxh); + rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); rx_status->flag |= RX_FLAG_MACTIME_MPDU; channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 415ab8bbe95..23969fe9006 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -336,7 +336,6 @@ struct dma_pub; struct si_pub; struct tx_status; struct d11rxhdr; -struct brcms_d11rxhdr; struct txpwr_limits; /* iovar structure */ From 5c0fd595e2a69d3d1c32251a4cb5e6cfc15387c3 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:35 -0700 Subject: [PATCH 1254/1519] staging: brcm80211: simple changes to softmac phy variables Code cleanup resulting in less sparse warnings. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 14 ----------- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 23 ------------------- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 2 +- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index f9702c0fa85..f31ebe2ac77 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -111,20 +111,6 @@ static struct chan_info_basic chan_info_all[] = { {216, 50800} }; -u16 ltrn_list[PHY_LTRN_LIST_LEN] = { - 0x18f9, 0x0d01, 0x00e4, 0xdef4, 0x06f1, 0x0ffc, - 0xfa27, 0x1dff, 0x10f0, 0x0918, 0xf20a, 0xe010, - 0x1417, 0x1104, 0xf114, 0xf2fa, 0xf7db, 0xe2fc, - 0xe1fb, 0x13ee, 0xff0d, 0xe91c, 0x171a, 0x0318, - 0xda00, 0x03e8, 0x17e6, 0xe9e4, 0xfff3, 0x1312, - 0xe105, 0xe204, 0xf725, 0xf206, 0xf1ec, 0x11fc, - 0x14e9, 0xe0f0, 0xf2f6, 0x09e8, 0x1010, 0x1d01, - 0xfad9, 0x0f04, 0x060f, 0xde0c, 0x001c, 0x0dff, - 0x1807, 0xf61a, 0xe40e, 0x0f16, 0x05f9, 0x18ec, - 0x0a1b, 0xff1e, 0x2600, 0xffe2, 0x0ae5, 0x1814, - 0x0507, 0x0fea, 0xe4f2, 0xf6e6 -}; - const u8 ofdm_rate_lookup[] = { BRCM_RATE_48M, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 8ce01596b90..16115212226 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -247,9 +247,6 @@ enum phy_cal_mode { #define PUB_NOT_ASSOC(pi) \ (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC)) -#define PHY_LTRN_LIST_LEN 64 -extern u16 ltrn_list[PHY_LTRN_LIST_LEN]; - struct phy_table_info { uint table; int q; @@ -922,26 +919,6 @@ struct lcnphy_radio_regs { u8 do_init_g; }; -extern struct lcnphy_radio_regs lcnphy_radio_regs_2064[]; -extern struct lcnphy_radio_regs lcnphy_radio_regs_2066[]; - -extern struct radio_regs regs_2055[], regs_SYN_2056[], regs_TX_2056[], - regs_RX_2056[]; -extern struct radio_regs regs_SYN_2056_A1[], regs_TX_2056_A1[], - regs_RX_2056_A1[]; -extern struct radio_regs regs_SYN_2056_rev5[], regs_TX_2056_rev5[], - regs_RX_2056_rev5[]; -extern struct radio_regs regs_SYN_2056_rev6[], regs_TX_2056_rev6[], - regs_RX_2056_rev6[]; -extern struct radio_regs regs_SYN_2056_rev7[], regs_TX_2056_rev7[], - regs_RX_2056_rev7[]; -extern struct radio_regs regs_SYN_2056_rev8[], regs_TX_2056_rev8[], - regs_RX_2056_rev8[]; - -extern struct radio_20xx_regs regs_2057_rev4[], regs_2057_rev5[], - regs_2057_rev5v1[]; -extern struct radio_20xx_regs regs_2057_rev7[], regs_2057_rev8[]; - extern char *phy_getvar(struct brcms_phy *pi, const char *name); extern int phy_getintvar(struct brcms_phy *pi, const char *name); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index fdcea56552c..bada9288555 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -575,7 +575,7 @@ static struct chan_info_2064_lcnphy chan_info_2064_lcnphy[] = { {14, 2484, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, }; -struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { +static struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { {0x00, 0, 0, 0, 0}, {0x01, 0x64, 0x64, 0, 0}, {0x02, 0x20, 0x20, 0, 0}, From c4aa147ac3d0824b37ecdd3d8f7ddba18762c352 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Thu, 29 Sep 2011 15:34:36 -0700 Subject: [PATCH 1255/1519] staging: brcm80211: declared global vars in softmac phy as const Global variables are undesirable unless they are read only. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 6 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 60 ++++++++++--------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index f31ebe2ac77..5b814805f45 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -52,7 +52,7 @@ struct chan_info_basic { u16 freq; }; -static struct chan_info_basic chan_info_all[] = { +static const struct chan_info_basic chan_info_all[] = { {1, 2412}, {2, 2417}, {3, 2422}, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index bada9288555..a87e3921b5d 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -558,7 +558,7 @@ struct chan_info_2064_lcnphy { u8 rxrf_rxrf_spare1; }; -static struct chan_info_2064_lcnphy chan_info_2064_lcnphy[] = { +static const struct chan_info_2064_lcnphy chan_info_2064_lcnphy[] = { {1, 2412, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, {2, 2417, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, {3, 2422, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, @@ -575,7 +575,7 @@ static struct chan_info_2064_lcnphy chan_info_2064_lcnphy[] = { {14, 2484, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, }; -static struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { +static const struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { {0x00, 0, 0, 0, 0}, {0x01, 0x64, 0x64, 0, 0}, {0x02, 0x20, 0x20, 0, 0}, @@ -4489,7 +4489,7 @@ static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) static void wlc_radio_2064_init(struct brcms_phy *pi) { u32 i; - struct lcnphy_radio_regs *lcnphyregs = NULL; + const struct lcnphy_radio_regs *lcnphyregs = NULL; lcnphyregs = lcnphy_radio_regs_2064; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index a34d292bd61..93ac12fc81c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -443,7 +443,7 @@ struct nphy_sfo_cfg { u16 PHY_BW6; }; -static struct chan_info_nphy_2055 chan_info_nphy_2055[] = { +static const struct chan_info_nphy_2055 chan_info_nphy_2055[] = { { 184, 4920, 3280, 0x71, 0x01, 0xEC, 0x0F, 0xFF, 0x01, 0x04, 0x0A, 0x00, 0x8F, 0xFF, 0xFF, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, @@ -942,7 +942,7 @@ static struct chan_info_nphy_2055 chan_info_nphy_2055[] = { 0x01, 0x80, 0x3E6, 0x3E2, 0x3DE, 0x41B, 0x41F, 0x424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev3_2056[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev3_2056[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, @@ -1565,7 +1565,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev3_2056[] = { 0x0f, 0x00, 0x0d, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev4_2056_A1[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev4_2056_A1[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, @@ -2188,7 +2188,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev4_2056_A1[] = { 0x0f, 0x00, 0x0e, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev5_2056v5[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev5_2056v5[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, @@ -2811,7 +2811,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev5_2056v5[] = { 0x0d, 0x00, 0x08, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v6[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v6[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, @@ -3434,7 +3434,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v6[] = { 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev5n6_2056v7[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev5n6_2056v7[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, @@ -4057,7 +4057,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev5n6_2056v7[] = { 0x0d, 0x00, 0x08, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v8[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v8[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, @@ -4680,7 +4680,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v8[] = { 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v11[] = { +static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v11[] = { { 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x02, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, @@ -5303,7 +5303,7 @@ static struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v11[] = { 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio2057 chan_info_nphyrev7_2057_rev4[] = { +static const struct chan_info_nphy_radio2057 chan_info_nphyrev7_2057_rev4[] = { { 184, 4920, 0x68, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xec, 0x01, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, @@ -6166,7 +6166,8 @@ static struct chan_info_nphy_radio2057 chan_info_nphyrev7_2057_rev4[] = { 0x0424} }; -static struct chan_info_nphy_radio2057_rev5 chan_info_nphyrev8_2057_rev5[] = { +static const struct chan_info_nphy_radio2057_rev5 +chan_info_nphyrev8_2057_rev5[] = { { 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0d, 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03c9, 0x03c5, 0x03c1, @@ -6225,7 +6226,8 @@ static struct chan_info_nphy_radio2057_rev5 chan_info_nphyrev8_2057_rev5[] = { 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio2057_rev5 chan_info_nphyrev9_2057_rev5v1[] = { +static const struct chan_info_nphy_radio2057_rev5 +chan_info_nphyrev9_2057_rev5v1[] = { { 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0d, 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03c9, 0x03c5, 0x03c1, @@ -6284,7 +6286,7 @@ static struct chan_info_nphy_radio2057_rev5 chan_info_nphyrev9_2057_rev5v1[] = { 0x041b, 0x041f, 0x0424} }; -static struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev7[] = { +static const struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev7[] = { { 184, 4920, 0x68, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xec, 0x01, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, @@ -7025,7 +7027,7 @@ static struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev7[] = { 0x0424} }; -static struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev8[] = { +static const struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev8[] = { { 186, 4930, 0x6b, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xed, 0x01, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, @@ -20387,15 +20389,15 @@ void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on) static bool wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, - struct chan_info_nphy_radio2057 **t0, - struct chan_info_nphy_radio205x **t1, - struct chan_info_nphy_radio2057_rev5 **t2, - struct chan_info_nphy_2055 **t3) + const struct chan_info_nphy_radio2057 **t0, + const struct chan_info_nphy_radio205x **t1, + const struct chan_info_nphy_radio2057_rev5 **t2, + const struct chan_info_nphy_2055 **t3) { uint i; - struct chan_info_nphy_radio2057 *chan_info_tbl_p_0 = NULL; - struct chan_info_nphy_radio205x *chan_info_tbl_p_1 = NULL; - struct chan_info_nphy_radio2057_rev5 *chan_info_tbl_p_2 = NULL; + const struct chan_info_nphy_radio2057 *chan_info_tbl_p_0 = NULL; + const struct chan_info_nphy_radio205x *chan_info_tbl_p_1 = NULL; + const struct chan_info_nphy_radio2057_rev5 *chan_info_tbl_p_2 = NULL; u32 tbl_len = 0; int freq = 0; @@ -20550,10 +20552,10 @@ fail: u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint channel) { int freq; - struct chan_info_nphy_radio2057 *t0 = NULL; - struct chan_info_nphy_radio205x *t1 = NULL; - struct chan_info_nphy_radio2057_rev5 *t2 = NULL; - struct chan_info_nphy_2055 *t3 = NULL; + const struct chan_info_nphy_radio2057 *t0 = NULL; + const struct chan_info_nphy_radio205x *t1 = NULL; + const struct chan_info_nphy_radio2057_rev5 *t2 = NULL; + const struct chan_info_nphy_2055 *t3 = NULL; if (channel == 0) channel = CHSPEC_CHANNEL(pi->radio_chanspec); @@ -20573,7 +20575,7 @@ u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint channel) static void wlc_phy_chanspec_radio2055_setup(struct brcms_phy *pi, - struct chan_info_nphy_2055 *ci) + const struct chan_info_nphy_2055 *ci) { write_radio_reg(pi, RADIO_2055_PLL_REF, ci->RF_pll_ref); @@ -21294,10 +21296,10 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) { int freq; - struct chan_info_nphy_radio2057 *t0 = NULL; - struct chan_info_nphy_radio205x *t1 = NULL; - struct chan_info_nphy_radio2057_rev5 *t2 = NULL; - struct chan_info_nphy_2055 *t3 = NULL; + const struct chan_info_nphy_radio2057 *t0 = NULL; + const struct chan_info_nphy_radio205x *t1 = NULL; + const struct chan_info_nphy_radio2057_rev5 *t2 = NULL; + const struct chan_info_nphy_2055 *t3 = NULL; if (!wlc_phy_chan2freq_nphy (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) From 3e8eda4447d2c89bcc197f708dd09c18dce4b8ae Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:26 -0700 Subject: [PATCH 1256/1519] staging: brcm80211: removed some unused fmac variable declarations Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 29 ------------------------ 1 file changed, 29 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 514f779c63c..be6c620a712 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -683,36 +683,7 @@ struct bcmevent_name { const char *name; }; -/* Override to force tx queueing all the time */ -extern uint brcmf_force_tx_queueing; - extern const struct bcmevent_name bcmevent_names[]; -extern const int bcmevent_names_size; - - -static inline void MUTEX_LOCK_INIT(struct brcmf_pub *drvr) -{ -} - -static inline void MUTEX_LOCK(struct brcmf_pub *drvr) -{ -} - -static inline void MUTEX_UNLOCK(struct brcmf_pub *drvr) -{ -} - -static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void) -{ -} - -static inline void MUTEX_LOCK_WL_SCAN_SET(void) -{ -} - -static inline void MUTEX_UNLOCK_WL_SCAN_SET(void) -{ -} /* Indication from bus module regarding presence/insertion of dongle. * Return struct brcmf_pub pointer, used as handle to OS module in later calls. From 7983a5a7ff1a529a0317b8cdd9c6fab825554a7d Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:27 -0700 Subject: [PATCH 1257/1519] staging: brcm80211: removed unused smac tx ampdu packet queue A remnant of the past. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 2 -- drivers/staging/brcm80211/brcmsmac/scb.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 4f79a42604e..e6bd3cf3cd3 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3358,8 +3358,6 @@ void brcms_c_init_scb(struct scb *scb) scb->seqctl_nonqos = 0xFFFF; scb->magic = SCB_MAGIC; - brcmu_pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID, - AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); } /* d11 core init diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h index 122d3c36f0c..51c79c7239b 100644 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ b/drivers/staging/brcm80211/brcmsmac/scb.h @@ -51,7 +51,6 @@ struct scb_ampdu { u8 release; /* # of mpdus released at a time */ u16 min_len; /* min mpdu len to support the density */ u32 max_rx_ampdu_bytes; /* max ampdu rcv length; 8k, 16k, 32k, 64k */ - struct pktq txq; /* sdu transmit queue pending aggregation */ /* * This could easily be a ini[] pointer and we keep this info in wl From 24cca4aafb600e142c31a4deeddcea75374eb19f Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:28 -0700 Subject: [PATCH 1258/1519] staging: brcm80211: cleaning up tx rate control code in softmac Code cleanup. Code was unnecessarily complex. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index e6bd3cf3cd3..10f1de20555 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -7066,7 +7066,6 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct ieee80211_rts *rts = NULL; bool qos; uint ac; - u32 rate_val[2]; bool hwtkmic = false; u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; #define ANTCFG_NONE 0xFF @@ -7077,7 +7076,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, struct ieee80211_tx_rate *txrate[2]; int k; struct ieee80211_tx_info *tx_info; - bool is_mcs[2]; + bool is_mcs; u16 mimo_txbw; u8 mimo_preamble_type; @@ -7137,13 +7136,12 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, txrate[1] = txrate[0]; for (k = 0; k < hw->max_rates; k++) { - is_mcs[k] = - txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; - if (!is_mcs[k]) { + is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; + if (!is_mcs) { if ((txrate[k]->idx >= 0) && (txrate[k]->idx < hw->wiphy->bands[tx_info->band]->n_bitrates)) { - rate_val[k] = + rspec[k] = hw->wiphy->bands[tx_info->band]-> bitrates[txrate[k]->idx].hw_value; short_preamble[k] = @@ -7151,10 +7149,11 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ? true : false; } else { - rate_val[k] = BRCM_RATE_1M; + rspec[k] = BRCM_RATE_1M; } } else { - rate_val[k] = txrate[k]->idx; + rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, + NRATE_MCS_INUSE | txrate[k]->idx); } /* @@ -7169,10 +7168,6 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, txrate[k]-> flags & IEEE80211_TX_RC_USE_CTS_PROTECT ? true : false; - if (is_mcs[k]) - rate_val[k] |= NRATE_MCS_INUSE; - - rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, rate_val[k]); /* * (1) RATE: From 9d1b113e2b2c98c7bb1223d24b740c5674677811 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:29 -0700 Subject: [PATCH 1259/1519] staging: brcm80211: various __iomem additions to softmac. So it is clear to the reader what memory is IO mapped Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 107 ++++++++++--------- drivers/staging/brcm80211/brcmsmac/aiutils.h | 16 +-- drivers/staging/brcm80211/brcmsmac/main.c | 2 +- drivers/staging/brcm80211/brcmsmac/nicpci.c | 45 ++++---- drivers/staging/brcm80211/brcmsmac/nicpci.h | 9 +- drivers/staging/brcm80211/brcmsmac/otp.c | 9 +- drivers/staging/brcm80211/brcmsmac/pmu.c | 16 +-- drivers/staging/brcm80211/brcmsmac/srom.c | 20 ++-- drivers/staging/brcm80211/brcmsmac/srom.h | 2 +- 9 files changed, 123 insertions(+), 103 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 790fdce60ed..0b3ba6a7474 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -323,7 +323,8 @@ (((si)->pub.buscoretype == PCI_CORE_ID) && \ (si)->pub.buscorerev >= 13)) -#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET)) +#define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \ + PCI_16KB0_CCREGS_OFFSET)) #define IS_SIM(chippkg) \ ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) @@ -357,7 +358,8 @@ (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ IS_ALIGNED((x), SI_CORE_SIZE)) -#define PCIEREGS(si) (((char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET)) +#define PCIEREGS(si) ((__iomem char *)((si)->curmap) + \ + PCI_16KB0_PCIREGS_OFFSET) struct aidmp { u32 oobselina30; /* 0x000 */ @@ -480,7 +482,7 @@ struct aidmp { /* EROM parsing */ static u32 -get_erom_ent(struct si_pub *sih, u32 **eromptr, u32 mask, u32 match) +get_erom_ent(struct si_pub *sih, u32 __iomem **eromptr, u32 mask, u32 match) { u32 ent; uint inv = 0, nom = 0; @@ -510,7 +512,7 @@ get_erom_ent(struct si_pub *sih, u32 **eromptr, u32 mask, u32 match) } static u32 -get_asd(struct si_pub *sih, u32 **eromptr, uint sp, uint ad, uint st, +get_asd(struct si_pub *sih, u32 __iomem **eromptr, uint sp, uint ad, uint st, u32 *addrl, u32 *addrh, u32 *sizel, u32 *sizeh) { u32 asd, sz, szd; @@ -546,12 +548,13 @@ static void ai_hwfixup(struct si_info *sii) } /* parse the enumeration rom to identify all cores */ -static void ai_scan(struct si_pub *sih, struct chipcregs *cc) +static void ai_scan(struct si_pub *sih, struct chipcregs __iomem *cc) { struct si_info *sii = (struct si_info *)sih; - u32 erombase, *eromptr, *eromlim; - void *regs = cc; + u32 erombase; + u32 __iomem *eromptr, *eromlim; + void __iomem *regs = cc; erombase = R_REG(&cc->eromptr); @@ -566,7 +569,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) while (eromptr < eromlim) { u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp; u32 mpd, asd, addrl, addrh, sizel, sizeh; - u32 *base; + u32 __iomem *base; uint i, j, idx; bool br; @@ -726,7 +729,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs *cc) * contains the first register of this 'common' register block (not to be * confused with 'common core'). */ -void *ai_setcoreidx(struct si_pub *sih, uint coreidx) +void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) { struct si_info *sii = (struct si_info *)sih; u32 addr = sii->coresba[coreidx]; @@ -914,7 +917,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) bool pci, pcie; uint i; uint pciidx, pcieidx, pcirev, pcierev; - struct chipcregs *cc; + struct chipcregs __iomem *cc; cc = ai_setcoreidx(&sii->pub, SI_CC_IDX); @@ -990,7 +993,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) if (SI_FAST(sii)) { if (!sii->pch) { sii->pch = pcicore_init(&sii->pub, sii->pbus, - (void *)PCIEREGS(sii)); + (__iomem void *)PCIEREGS(sii)); if (sii->pch == NULL) return false; } @@ -1022,12 +1025,12 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) } static struct si_info *ai_doattach(struct si_info *sii, - void *regs, struct pci_dev *pbus, + void __iomem *regs, struct pci_dev *pbus, char **vars, uint *varsz) { struct si_pub *sih = &sii->pub; u32 w, savewin; - struct chipcregs *cc; + struct chipcregs __iomem *cc; char *pvars = NULL; uint socitype; uint origidx; @@ -1048,7 +1051,7 @@ static struct si_info *ai_doattach(struct si_info *sii, pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, SI_ENUM_BASE); - cc = (struct chipcregs *) regs; + cc = (struct chipcregs __iomem *) regs; /* bus/core/clk setup for register access */ if (!ai_buscore_prep(sii)) { @@ -1098,7 +1101,7 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_nvram_process(sii, pvars); /* === NVRAM, clock is ready === */ - cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); W_REG(&cc->gpiopullup, 0); W_REG(&cc->gpiopulldown, 0); ai_setcoreidx(sih, origidx); @@ -1177,7 +1180,7 @@ static struct si_info *ai_doattach(struct si_info *sii, * varsz - pointer to int to return the size of the vars */ struct si_pub * -ai_attach(void *regs, struct pci_dev *sdh, char **vars, uint *varsz) +ai_attach(void __iomem *regs, struct pci_dev *sdh, char **vars, uint *varsz) { struct si_info *sii; @@ -1291,7 +1294,7 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) * Moreover, callers should keep interrupts off during switching * out of and back to d11 core. */ -void *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) +void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) { uint idx; @@ -1303,10 +1306,10 @@ void *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) } /* Turn off interrupt as required by ai_setcore, before switch core */ -void *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, - uint *intr_val) +void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, + uint *intr_val) { - void *cc; + void __iomem *cc; struct si_info *sii; sii = (struct si_info *)sih; @@ -1364,7 +1367,7 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, uint val) { uint origidx = 0; - u32 *r = NULL; + u32 __iomem *r = NULL; uint w; uint intr_val = 0; bool fast = false; @@ -1382,8 +1385,8 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { /* Chipc registers are mapped at 12KB */ fast = true; - r = (u32 *)((char *)sii->curmap + - PCI_16KB0_CCREGS_OFFSET + regoff); + r = (u32 __iomem *)((__iomem char *)sii->curmap + + PCI_16KB0_CCREGS_OFFSET + regoff); } else if (sii->pub.buscoreidx == coreidx) { /* * pci registers are at either in the last 2KB of @@ -1391,10 +1394,10 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, */ fast = true; if (SI_FAST(sii)) - r = (u32 *)((char *)sii->curmap + + r = (u32 __iomem *)((__iomem char *)sii->curmap + PCI_16KB0_PCIREGS_OFFSET + regoff); else - r = (u32 *)((char *)sii->curmap + + r = (u32 __iomem *)((__iomem char *)sii->curmap + ((regoff >= SBCONFIGOFF) ? PCI_BAR0_PCISBR_OFFSET : PCI_BAR0_PCIREGS_OFFSET) + regoff); @@ -1407,8 +1410,8 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, origidx = ai_coreidx(&sii->pub); /* switch core */ - r = (u32 *) ((unsigned char *) ai_setcoreidx(&sii->pub, coreidx) - + regoff); + r = (u32 __iomem *) ((unsigned char __iomem *) + ai_setcoreidx(&sii->pub, coreidx) + regoff); } /* mask and set */ @@ -1489,7 +1492,7 @@ void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits) /* return the slow clock source - LPO, XTAL, or PCI */ static uint ai_slowclk_src(struct si_info *sii) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; u32 val; if (sii->pub.ccrev < 6) { @@ -1499,7 +1502,8 @@ static uint ai_slowclk_src(struct si_info *sii) return SCC_SS_PCI; return SCC_SS_XTAL; } else if (sii->pub.ccrev < 10) { - cc = (struct chipcregs *) ai_setcoreidx(&sii->pub, sii->curidx); + cc = (struct chipcregs __iomem *) + ai_setcoreidx(&sii->pub, sii->curidx); return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; } else /* Insta-clock */ return SCC_SS_XTAL; @@ -1509,8 +1513,8 @@ static uint ai_slowclk_src(struct si_info *sii) * return the ILP (slowclock) min or max frequency * precondition: we've established the chip has dynamic clk control */ -static uint -ai_slowclk_freq(struct si_info *sii, bool max_freq, struct chipcregs *cc) +static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, + struct chipcregs __iomem *cc) { u32 slowclk; uint div; @@ -1544,7 +1548,8 @@ ai_slowclk_freq(struct si_info *sii, bool max_freq, struct chipcregs *cc) return 0; } -static void ai_clkctl_setdelay(struct si_info *sii, struct chipcregs *cc) +static void +ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) { uint slowmaxfreq, pll_delay, slowclk; uint pll_on_delay, fref_sel_delay; @@ -1577,7 +1582,7 @@ void ai_clkctl_init(struct si_pub *sih) { struct si_info *sii; uint origidx = 0; - struct chipcregs *cc; + struct chipcregs __iomem *cc; bool fast; if (!(sih->cccaps & CC_CAP_PWR_CTL)) @@ -1587,11 +1592,12 @@ void ai_clkctl_init(struct si_pub *sih) fast = SI_FAST(sii); if (!fast) { origidx = sii->curidx; - cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs __iomem *) + ai_setcore(sih, CC_CORE_ID, 0); if (cc == NULL) return; } else { - cc = (struct chipcregs *) CCREGS_FAST(sii); + cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); if (cc == NULL) return; } @@ -1615,7 +1621,7 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) { struct si_info *sii; uint origidx = 0; - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint slowminfreq; u16 fpdelay; uint intr_val = 0; @@ -1637,11 +1643,12 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) if (!fast) { origidx = sii->curidx; INTR_OFF(sii, intr_val); - cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs __iomem *) + ai_setcore(sih, CC_CORE_ID, 0); if (cc == NULL) goto done; } else { - cc = (struct chipcregs *) CCREGS_FAST(sii); + cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); if (cc == NULL) goto done; } @@ -1725,7 +1732,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) static bool _ai_clkctl_cc(struct si_info *sii, uint mode) { uint origidx = 0; - struct chipcregs *cc; + struct chipcregs __iomem *cc; u32 scc; uint intr_val = 0; bool fast = SI_FAST(sii); @@ -1737,9 +1744,10 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) if (!fast) { INTR_OFF(sii, intr_val); origidx = sii->curidx; - cc = (struct chipcregs *) ai_setcore(&sii->pub, CC_CORE_ID, 0); + cc = (struct chipcregs __iomem *) + ai_setcore(&sii->pub, CC_CORE_ID, 0); } else { - cc = (struct chipcregs *) CCREGS_FAST(sii); + cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); if (cc == NULL) goto done; } @@ -1897,7 +1905,7 @@ void ai_pci_down(struct si_pub *sih) void ai_pci_setup(struct si_pub *sih, uint coremask) { struct si_info *sii; - struct sbpciregs *regs = NULL; + struct sbpciregs __iomem *regs = NULL; u32 siflag = 0, w; uint idx = 0; @@ -1943,7 +1951,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) int ai_pci_fixcfg(struct si_pub *sih) { uint origidx; - void *regs = NULL; + void __iomem *regs = NULL; struct si_info *sii = (struct si_info *)sih; /* Fixup PI in SROM shadow area to enable the correct PCI core access */ @@ -1953,9 +1961,10 @@ int ai_pci_fixcfg(struct si_pub *sih) /* check 'pi' is correct and fix it if not */ regs = ai_setcore(&sii->pub, sii->pub.buscoretype, 0); if (sii->pub.buscoretype == PCIE_CORE_ID) - pcicore_fixcfg_pcie(sii->pch, (struct sbpcieregs *)regs); + pcicore_fixcfg_pcie(sii->pch, + (struct sbpcieregs __iomem *)regs); else if (sii->pub.buscoretype == PCI_CORE_ID) - pcicore_fixcfg_pci(sii->pch, (struct sbpciregs *)regs); + pcicore_fixcfg_pci(sii->pch, (struct sbpciregs __iomem *)regs); /* restore the original index */ ai_setcoreidx(&sii->pub, origidx); @@ -1976,14 +1985,14 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) { struct si_info *sii; - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; u32 val; sii = (struct si_info *)sih; origidx = ai_coreidx(sih); - cc = (struct chipcregs *) ai_setcore(sih, CC_CORE_ID, 0); + cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); val = R_REG(&cc->chipcontrol); @@ -2009,7 +2018,7 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) void ai_epa_4313war(struct si_pub *sih) { struct si_info *sii; - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; sii = (struct si_info *)sih; @@ -2044,7 +2053,7 @@ bool ai_is_sprom_available(struct si_pub *sih) if (sih->ccrev >= 31) { struct si_info *sii; uint origidx; - struct chipcregs *cc; + struct chipcregs __iomem *cc; u32 sromctrl; if ((sih->cccaps & CC_CAP_SROM) == 0) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 39171927c1b..4a3f98efc9c 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -269,8 +269,8 @@ struct si_info { char *vars; uint varsz; - void *curmap; /* current regs va */ - void *regs[SI_MAXCORES]; /* other regs va */ + void __iomem *curmap; /* current regs va */ + void __iomem *regs[SI_MAXCORES]; /* other regs va */ uint curidx; /* current core index */ uint numcores; /* # discovered cores */ @@ -319,8 +319,8 @@ extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ -extern struct si_pub *ai_attach(void *regs, struct pci_dev *sdh, char **vars, - uint *varsz); +extern struct si_pub *ai_attach(void __iomem *regs, struct pci_dev *sdh, + char **vars, uint *varsz); extern void ai_detach(struct si_pub *sih); extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); @@ -331,10 +331,10 @@ extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); extern bool ai_iscoreup(struct si_pub *sih); extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit); -extern void *ai_setcoreidx(struct si_pub *sih, uint coreidx); -extern void *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); -extern void *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, - uint *intr_val); +extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx); +extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); +extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, + uint *origidx, uint *intr_val); extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val); extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); extern void ai_core_disable(struct si_pub *sih, u32 bits); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 10f1de20555..f8bc42f34a5 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4678,7 +4678,7 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) * put the whole chip in reset(driver down state), no clock */ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void *regsva, + uint unit, bool piomode, void __iomem *regsva, struct pci_dev *btparam) { struct brcms_hardware *wlc_hw; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index f5a2695ac0d..e3cce296220 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -206,8 +206,8 @@ struct sbpcieregs { struct pcicore_info { union { - struct sbpcieregs *pcieregs; - struct sbpciregs *pciregs; + struct sbpcieregs __iomem *pcieregs; + struct sbpciregs __iomem *pciregs; } regs; /* Memory mapped register to the core */ struct si_pub *sih; /* System interconnect handle */ @@ -239,7 +239,7 @@ static void pr28829_delay(void) * It's caller's responsibility to make sure that this is done only once */ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, - void *regs) + void __iomem *regs) { struct pcicore_info *pi; @@ -334,7 +334,7 @@ end: /* ***** Register Access API */ static uint -pcie_readreg(struct sbpcieregs *pcieregs, uint addrtype, uint offset) +pcie_readreg(struct sbpcieregs __iomem *pcieregs, uint addrtype, uint offset) { uint retval = 0xFFFFFFFF; @@ -354,8 +354,8 @@ pcie_readreg(struct sbpcieregs *pcieregs, uint addrtype, uint offset) return retval; } -static uint -pcie_writereg(struct sbpcieregs *pcieregs, uint addrtype, uint offset, uint val) +static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype, + uint offset, uint val) { switch (addrtype) { case PCIE_CONFIGREGS: @@ -374,7 +374,7 @@ pcie_writereg(struct sbpcieregs *pcieregs, uint addrtype, uint offset, uint val) static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) { - struct sbpcieregs *pcieregs = pi->regs.pcieregs; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; uint mdiodata, i = 0; uint pcie_serdes_spinwait = 200; @@ -405,7 +405,7 @@ static int pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, uint *val) { - struct sbpcieregs *pcieregs = pi->regs.pcieregs; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; uint mdiodata; uint i = 0; uint pcie_serdes_spinwait = 10; @@ -503,7 +503,7 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend) { u32 w; struct si_pub *sih = pi->sih; - struct sbpcieregs *pcieregs = pi->regs.pcieregs; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; if (sih->buscoretype != PCIE_CORE_ID || sih->buscorerev < 7) return; @@ -582,9 +582,10 @@ static void pcie_war_polarity(struct pcicore_info *pi) */ static void pcie_war_aspm_clkreq(struct pcicore_info *pi) { - struct sbpcieregs *pcieregs = pi->regs.pcieregs; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; struct si_pub *sih = pi->sih; - u16 val16, *reg16; + u16 val16; + u16 __iomem *reg16; u32 w; if (!PCIE_ASPM(sih)) @@ -642,8 +643,9 @@ static void pcie_war_serdes(struct pcicore_info *pi) /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_misc_config_fixup(struct pcicore_info *pi) { - struct sbpcieregs *pcieregs = pi->regs.pcieregs; - u16 val16, *reg16; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; + u16 val16; + u16 __iomem *reg16; reg16 = &pcieregs->sprom[SRSH_PCIE_MISC_CONFIG]; val16 = R_REG(reg16); @@ -658,8 +660,8 @@ static void pcie_misc_config_fixup(struct pcicore_info *pi) /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_war_noplldown(struct pcicore_info *pi) { - struct sbpcieregs *pcieregs = pi->regs.pcieregs; - u16 *reg16; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; + u16 __iomem *reg16; /* turn off serdes PLL down */ ai_corereg(pi->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), @@ -674,7 +676,7 @@ static void pcie_war_noplldown(struct pcicore_info *pi) static void pcie_war_pci_setup(struct pcicore_info *pi) { struct si_pub *sih = pi->sih; - struct sbpcieregs *pcieregs = pi->regs.pcieregs; + struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; u32 w; if (sih->buscorerev == 0 || sih->buscorerev == 1) { @@ -789,7 +791,7 @@ void pcicore_down(struct pcicore_info *pi, int state) } /* precondition: current core is sii->buscoretype */ -static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16) +static void pcicore_fixcfg(struct pcicore_info *pi, u16 __iomem *reg16) { struct si_info *sii = (struct si_info *)(pi->sih); u16 val16; @@ -804,18 +806,21 @@ static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16) } } -void pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs *pciregs) +void +pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) { pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]); } -void pcicore_fixcfg_pcie(struct pcicore_info *pi, struct sbpcieregs *pcieregs) +void pcicore_fixcfg_pcie(struct pcicore_info *pi, + struct sbpcieregs __iomem *pcieregs) { pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); } /* precondition: current core is pci core */ -void pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs *pciregs) +void +pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) { u32 w; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.h b/drivers/staging/brcm80211/brcmsmac/nicpci.h index 49952039841..2d41aab8ad5 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.h +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.h @@ -62,7 +62,8 @@ struct sbpciregs; struct sbpcieregs; extern struct pcicore_info *pcicore_init(struct si_pub *sih, - struct pci_dev *pdev, void *regs); + struct pci_dev *pdev, + void __iomem *regs); extern void pcicore_deinit(struct pcicore_info *pch); extern void pcicore_attach(struct pcicore_info *pch, char *pvars, int state); extern void pcicore_hwup(struct pcicore_info *pch); @@ -72,10 +73,10 @@ extern void pcicore_down(struct pcicore_info *pch, int state); extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen); extern void pcicore_fixcfg_pci(struct pcicore_info *pch, - struct sbpciregs *pciregs); + struct sbpciregs __iomem *pciregs); extern void pcicore_fixcfg_pcie(struct pcicore_info *pch, - struct sbpcieregs *pciregs); + struct sbpcieregs __iomem *pciregs); extern void pcicore_pci_setup(struct pcicore_info *pch, - struct sbpciregs *pciregs); + struct sbpciregs __iomem *pciregs); #endif /* _BRCM_NICPCI_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c index f15e8beb4bc..edf551561fd 100644 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ b/drivers/staging/brcm80211/brcmsmac/otp.c @@ -132,7 +132,8 @@ struct otpinfo { #define OTP4315_SWREG_SZ 178 /* 178 bytes */ #define OTP_SZ_FU_144 (144/8) /* 144 bits */ -static u16 ipxotp_otpr(struct otpinfo *oi, struct chipcregs *cc, uint wn) +static u16 +ipxotp_otpr(struct otpinfo *oi, struct chipcregs __iomem *cc, uint wn) { return R_REG(&cc->sromotp[wn]); } @@ -160,7 +161,7 @@ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) return ret; } -static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) +static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) { uint k; u32 otpp, st; @@ -240,7 +241,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) { uint idx; - struct chipcregs *cc; + struct chipcregs __iomem *cc; /* Make sure we're running IPX OTP */ if (!OTPTYPE_IPX(sih->ccrev)) @@ -295,7 +296,7 @@ static int ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) { uint idx; - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint base, i, sz; /* Validate region selection */ diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c index 6d4cd9fcefb..3b36e3acfd7 100644 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ b/drivers/staging/brcm80211/brcmsmac/pmu.c @@ -139,7 +139,7 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) } static void -si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs *cc, +si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, u8 spuravoid) { u32 tmp = 0; @@ -221,7 +221,7 @@ u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) void si_pmu_sprom_enable(struct si_pub *sih, bool enable) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -294,11 +294,11 @@ u32 si_pmu_alp_clock(struct si_pub *sih) void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx, intr_val; /* Remember original core before switch to chipc */ - cc = (struct chipcregs *) + cc = (struct chipcregs __iomem *) ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); /* update the pll changes */ @@ -311,7 +311,7 @@ void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) /* initialize PMU */ void si_pmu_init(struct si_pub *sih) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -350,7 +350,7 @@ void si_pmu_swreg_init(struct si_pub *sih) /* initialize PLL */ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; /* Remember original core before switch to chipc */ @@ -374,7 +374,7 @@ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) /* initialize PMU resources */ void si_pmu_res_init(struct si_pub *sih) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; u32 min_mask = 0, max_mask = 0; @@ -406,7 +406,7 @@ void si_pmu_res_init(struct si_pub *sih) u32 si_pmu_measure_alpclk(struct si_pub *sih) { - struct chipcregs *cc; + struct chipcregs __iomem *cc; uint origidx; u32 alp_khz; diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 01053065e36..6f3b12c0e0f 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -782,12 +782,14 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { * shared between devices. */ static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; -static u16 *srom_window_address(struct si_pub *sih, u8 *curmap) +static u16 __iomem * +srom_window_address(struct si_pub *sih, u8 __iomem *curmap) { if (sih->ccrev < 32) - return (u16 *)(curmap + PCI_BAR0_SPROM_OFFSET); + return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); if (sih->cccaps & CC_CAP_SROM) - return (u16 *)(curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); + return (u16 __iomem *) + (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); return NULL; } @@ -1032,7 +1034,7 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) * Return 0 on success, nonzero on error. */ static int -sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, +sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc) { int err = 0; @@ -1131,10 +1133,11 @@ static int initvars_table(char *start, char *end, * Initialize nonvolatile variable table from sprom. * Return 0 on success, nonzero on error. */ -static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, - uint *count) +static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, + char **vars, uint *count) { - u16 *srom, *sromwindow; + u16 *srom; + u16 __iomem *sromwindow; u8 sromrev = 0; u32 sr; struct brcms_varbuf b; @@ -1222,7 +1225,8 @@ errout: * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. */ -int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) +int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, + uint *count) { uint len; diff --git a/drivers/staging/brcm80211/brcmsmac/srom.h b/drivers/staging/brcm80211/brcmsmac/srom.h index dd51156fb12..826c2cd91af 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.h +++ b/drivers/staging/brcm80211/brcmsmac/srom.h @@ -20,7 +20,7 @@ #include "types.h" /* Prototypes */ -extern int srom_var_init(struct si_pub *sih, void *curmap, char **vars, +extern int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, uint *count); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, From f2ac3b297d170a431b2bac48a35b48f6ca223a64 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:30 -0700 Subject: [PATCH 1260/1519] staging: brcm80211: reduced softmac sparse warnings By declaring certain variables static. One unused array induced a warning, array was deleted. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 4 +- drivers/staging/brcm80211/brcmsmac/main.c | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 48 +++++++++---------- .../brcm80211/brcmsmac/phy/phytbl_lcn.c | 4 -- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index a9defe21b7d..02bb7955d6f 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -197,7 +197,7 @@ static const struct brcms_chanvec chanvec_none = { }; /* All 2.4 GHz HW channels */ -const struct brcms_chanvec chanvec_all_2G = { +static const struct brcms_chanvec chanvec_all_2G = { {0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -205,7 +205,7 @@ const struct brcms_chanvec chanvec_all_2G = { }; /* All 5 GHz HW channels */ -const struct brcms_chanvec chanvec_all_5G = { +static const struct brcms_chanvec chanvec_all_5G = { {0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x11, 0x11, 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x20, 0x22, 0x22, 0x00, 0x00, 0x11, diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index f8bc42f34a5..ac5a52a0e78 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -423,7 +423,7 @@ uint brcm_msg_level = #endif /* BCMDBG */ /* TX FIFO number to WME/802.1E Access Category */ -const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; +static const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; /* WME/802.1E Access Category to TX FIFO number */ static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 93ac12fc81c..4023af13812 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -7762,7 +7762,7 @@ static const struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev8[] = { 0x0424} }; -struct radio_regs regs_2055[] = { +static struct radio_regs regs_2055[] = { {0x02, 0x80, 0x80, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0x27, 0x27, 0, 0}, @@ -7991,7 +7991,7 @@ struct radio_regs regs_2055[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_SYN_2056[] = { +static struct radio_regs regs_SYN_2056[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8176,7 +8176,7 @@ struct radio_regs regs_SYN_2056[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_TX_2056[] = { +static struct radio_regs regs_TX_2056[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8325,7 +8325,7 @@ struct radio_regs regs_TX_2056[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_RX_2056[] = { +static struct radio_regs regs_RX_2056[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8476,7 +8476,7 @@ struct radio_regs regs_RX_2056[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_SYN_2056_A1[] = { +static struct radio_regs regs_SYN_2056_A1[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8661,7 +8661,7 @@ struct radio_regs regs_SYN_2056_A1[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_TX_2056_A1[] = { +static struct radio_regs regs_TX_2056_A1[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8810,7 +8810,7 @@ struct radio_regs regs_TX_2056_A1[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_RX_2056_A1[] = { +static struct radio_regs regs_RX_2056_A1[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -8961,7 +8961,7 @@ struct radio_regs regs_RX_2056_A1[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_SYN_2056_rev5[] = { +static struct radio_regs regs_SYN_2056_rev5[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9146,7 +9146,7 @@ struct radio_regs regs_SYN_2056_rev5[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_TX_2056_rev5[] = { +static struct radio_regs regs_TX_2056_rev5[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9303,7 +9303,7 @@ struct radio_regs regs_TX_2056_rev5[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_RX_2056_rev5[] = { +static struct radio_regs regs_RX_2056_rev5[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9454,7 +9454,7 @@ struct radio_regs regs_RX_2056_rev5[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_SYN_2056_rev6[] = { +static struct radio_regs regs_SYN_2056_rev6[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9639,7 +9639,7 @@ struct radio_regs regs_SYN_2056_rev6[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_TX_2056_rev6[] = { +static struct radio_regs regs_TX_2056_rev6[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9796,7 +9796,7 @@ struct radio_regs regs_TX_2056_rev6[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_RX_2056_rev6[] = { +static struct radio_regs regs_RX_2056_rev6[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -9947,7 +9947,7 @@ struct radio_regs regs_RX_2056_rev6[] = { {0xFFFF, 0, 0, 0, 0} }; -struct radio_regs regs_SYN_2056_rev7[] = { +static struct radio_regs regs_SYN_2056_rev7[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -10132,7 +10132,7 @@ struct radio_regs regs_SYN_2056_rev7[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_TX_2056_rev7[] = { +static struct radio_regs regs_TX_2056_rev7[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -10289,7 +10289,7 @@ struct radio_regs regs_TX_2056_rev7[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_RX_2056_rev7[] = { +static struct radio_regs regs_RX_2056_rev7[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -10440,7 +10440,7 @@ struct radio_regs regs_RX_2056_rev7[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_SYN_2056_rev8[] = { +static struct radio_regs regs_SYN_2056_rev8[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -10625,7 +10625,7 @@ struct radio_regs regs_SYN_2056_rev8[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_TX_2056_rev8[] = { +static struct radio_regs regs_TX_2056_rev8[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -10782,7 +10782,7 @@ struct radio_regs regs_TX_2056_rev8[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_regs regs_RX_2056_rev8[] = { +static struct radio_regs regs_RX_2056_rev8[] = { {0x02, 0, 0, 0, 0}, {0x03, 0, 0, 0, 0}, {0x04, 0, 0, 0, 0}, @@ -11426,7 +11426,7 @@ static const struct radio_regs regs_RX_2056_rev11[] = { {0xFFFF, 0, 0, 0, 0}, }; -struct radio_20xx_regs regs_2057_rev4[] = { +static struct radio_20xx_regs regs_2057_rev4[] = { {0x00, 0x84, 0}, {0x01, 0, 0}, {0x02, 0x60, 0}, @@ -11816,7 +11816,7 @@ struct radio_20xx_regs regs_2057_rev4[] = { {0xFFFF, 0, 0}, }; -struct radio_20xx_regs regs_2057_rev5[] = { +static struct radio_20xx_regs regs_2057_rev5[] = { {0x00, 0, 1}, {0x01, 0x57, 1}, {0x02, 0x20, 1}, @@ -12148,7 +12148,7 @@ struct radio_20xx_regs regs_2057_rev5[] = { {0xFFFF, 0, 0} }; -struct radio_20xx_regs regs_2057_rev5v1[] = { +static struct radio_20xx_regs regs_2057_rev5v1[] = { {0x00, 0x15, 1}, {0x01, 0x57, 1}, {0x02, 0x20, 1}, @@ -12480,7 +12480,7 @@ struct radio_20xx_regs regs_2057_rev5v1[] = { {0xFFFF, 0, 0} }; -struct radio_20xx_regs regs_2057_rev7[] = { +static struct radio_20xx_regs regs_2057_rev7[] = { {0x00, 0, 1}, {0x01, 0x57, 1}, {0x02, 0x20, 1}, @@ -12896,7 +12896,7 @@ struct radio_20xx_regs regs_2057_rev7[] = { {0xFFFF, 0, 0} }; -struct radio_20xx_regs regs_2057_rev8[] = { +static struct radio_20xx_regs regs_2057_rev8[] = { {0x00, 0x8, 1}, {0x01, 0x57, 1}, {0x02, 0x20, 1}, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c index 15c5ffcc30a..622c01ca72c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c @@ -1611,10 +1611,6 @@ const u32 dot11lcnphytbl_rx_gain_info_sz_rev0 = sizeof(dot11lcnphytbl_rx_gain_info_rev0) / sizeof(dot11lcnphytbl_rx_gain_info_rev0[0]); -static const u32 dot11lcnphytbl_rx_gain_info_sz_rev1 = - sizeof(dot11lcnphytbl_rx_gain_info_rev1) / - sizeof(dot11lcnphytbl_rx_gain_info_rev1[0]); - const u32 dot11lcnphytbl_rx_gain_info_2G_rev2_sz = sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2) / sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2[0]); From d892735338e81af7c66ebf9ae84d0b7477e891fb Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:31 -0700 Subject: [PATCH 1261/1519] staging: brcm80211: added __iomem qualifier to softmac main.c Code cleanup. Makes it clear when an address is mapped IO space. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 81 +++++++++++------------ drivers/staging/brcm80211/brcmsmac/main.h | 4 +- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index ac5a52a0e78..e4dd2d486dc 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -638,7 +638,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, bool shortslot) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = wlc_hw->regs; @@ -657,23 +657,23 @@ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, const struct d11init *inits) { int i; - u8 *base; - u8 *addr; + u8 __iomem *base; + u8 __iomem *addr; u16 size; u32 value; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - base = (u8 *)wlc_hw->regs; + base = (u8 __iomem *)wlc_hw->regs; for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { size = le16_to_cpu(inits[i].size); addr = base + le16_to_cpu(inits[i].addr); value = le32_to_cpu(inits[i].value); if (size == 2) - W_REG((u16 *)addr, value); + W_REG((u16 __iomem *)addr, value); else if (size == 4) - W_REG((u32 *)addr, value); + W_REG((u32 __iomem *)addr, value); else break; } @@ -1025,7 +1025,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) { bool morepending = false; struct brcms_c_info *wlc = wlc_hw->wlc; - struct d11regs *regs; + struct d11regs __iomem *regs; struct tx_status txstatus, *txs; u32 s1, s2; uint n = 0; @@ -1113,7 +1113,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) { u32 macintstatus; struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; bool fatal = false; struct wiphy *wiphy = wlc->wiphy; @@ -1230,7 +1230,7 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) } } -static struct dma64regs * +static struct dma64regs __iomem * dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) { if (direction == DMA_TX) @@ -1645,7 +1645,7 @@ static void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, const u8 *addr) { - struct d11regs *regs; + struct d11regs __iomem *regs; u16 mac_l; u16 mac_m; u16 mac_h; @@ -1670,7 +1670,7 @@ void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, void *buf) { - struct d11regs *regs; + struct d11regs __iomem *regs; u32 word; __le32 word_le; __be32 word_be; @@ -1745,7 +1745,7 @@ static void brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, u16 bcn[], int len) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3, bcn); @@ -1759,7 +1759,7 @@ static void brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, u16 bcn[], int len) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3, bcn); @@ -2168,7 +2168,7 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs *) + wlc_hw->regs = (struct d11regs __iomem *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); ai_core_reset(wlc_hw->sih, flags, resetbits); brcms_c_mctrl_reset(wlc_hw); @@ -2202,7 +2202,7 @@ static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) */ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) { - struct d11regs *regs; + struct d11regs __iomem *regs; uint i; bool fastclk; u32 resetbits = 0; @@ -2286,7 +2286,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) */ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; u16 fifo_nu; u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; u16 txfifo_def, txfifo_def1; @@ -2346,8 +2346,7 @@ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) { - struct d11regs *regs; - regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { @@ -2376,7 +2375,7 @@ void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) static void brcms_c_gpio_init(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs; + struct d11regs __iomem *regs; u32 gc, gm; regs = wlc_hw->regs; @@ -2441,7 +2440,7 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const __le32 ucode[], const size_t nbytes) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; uint i; uint count; @@ -2518,7 +2517,7 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) bool fatal = false; uint unit; uint intstatus, idx; - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; struct wiphy *wiphy = wlc_hw->wlc->wiphy; unit = wlc_hw->unit; @@ -2734,7 +2733,7 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; u32 macintstatus; /* macintstatus includes a DMA interrupt summary bit */ @@ -2843,7 +2842,7 @@ bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; u32 mc, mi; struct wiphy *wiphy = wlc->wiphy; @@ -2912,7 +2911,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) void brcms_c_enable_mac(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; u32 mc, mi; BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, @@ -2955,7 +2954,7 @@ void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) { - struct d11regs *regs; + struct d11regs __iomem *regs; u32 w, val; struct wiphy *wiphy = wlc_hw->wlc->wiphy; @@ -3020,7 +3019,7 @@ static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) { - struct d11regs *regs; + struct d11regs __iomem *regs; u32 tmp; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); @@ -3118,9 +3117,9 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) { - struct d11regs *regs = wlc_hw->regs; - u16 *objdata_lo = (u16 *)®s->objdata; - u16 *objdata_hi = objdata_lo + 1; + struct d11regs __iomem *regs = wlc_hw->regs; + u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; + u16 __iomem *objdata_hi = objdata_lo + 1; u16 v; W_REG(®s->objaddr, sel | (offset >> 2)); @@ -3137,9 +3136,9 @@ static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, u32 sel) { - struct d11regs *regs = wlc_hw->regs; - u16 *objdata_lo = (u16 *)®s->objdata; - u16 *objdata_hi = objdata_lo + 1; + struct d11regs __iomem *regs = wlc_hw->regs; + u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; + u16 __iomem *objdata_hi = objdata_lo + 1; W_REG(®s->objaddr, sel | (offset >> 2)); (void)R_REG(®s->objaddr); @@ -3371,7 +3370,7 @@ void brcms_c_init_scb(struct scb *scb) static void brcms_b_coreinit(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs *regs; + struct d11regs __iomem *regs; u32 sflags; uint bcnint_us; uint i = 0; @@ -3769,7 +3768,7 @@ static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc) void brcms_c_init(struct brcms_c_info *wlc) { - struct d11regs *regs; + struct d11regs __iomem *regs; u16 chanspec; bool mute = false; @@ -4682,7 +4681,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, struct pci_dev *btparam) { struct brcms_hardware *wlc_hw; - struct d11regs *regs; + struct d11regs __iomem *regs; char *macaddr = NULL; char *vars; uint err = 0; @@ -4755,8 +4754,8 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, wlc_hw->deviceid = device; /* set bar0 window to point at D11 core */ - wlc_hw->regs = (struct d11regs *) ai_setcore(wlc_hw->sih, D11_CORE_ID, - 0); + wlc_hw->regs = (struct d11regs __iomem *) + ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); wlc_hw->corerev = ai_corerev(wlc_hw->sih); regs = wlc_hw->regs; @@ -5641,7 +5640,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs *) + wlc_hw->regs = (struct d11regs __iomem *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); /* @@ -8084,7 +8083,7 @@ static void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, u32 *tsf_h_ptr) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; /* read the tsf timer low, then high to get an atomic read */ *tsf_l_ptr = R_REG(®s->tsf_timerlow); @@ -8810,7 +8809,7 @@ static void brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], int len, bool both) { - struct d11regs *regs = wlc_hw->regs; + struct d11regs __iomem *regs = wlc_hw->regs; if (both) { brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); @@ -8855,7 +8854,7 @@ void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, /* Hardware beaconing for this config */ u16 bcn[BCN_TMPL_LEN / 2]; u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD; - struct d11regs *regs = wlc->regs; + struct d11regs __iomem *regs = wlc->regs; /* Check if both templates are in use, if so sched. an interrupt * that will call back into this routine diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index c938add2c45..045356aaefd 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -340,7 +340,7 @@ struct brcms_hardware { struct si_pub *sih; /* SI handle (cookie for siutils calls) */ char *vars; /* "environment" name=value */ uint vars_size; /* size of vars, free vars on detach */ - struct d11regs *regs; /* pointer to device registers */ + struct d11regs __iomem *regs; /* pointer to device registers */ struct phy_shim_info *physhim; /* phy shim layer handler */ struct shared_phy *phy_sh; /* pointer to shared phy state */ struct brcms_hw_band *band;/* pointer to active per-band state */ @@ -489,7 +489,7 @@ struct brcms_txq_info { struct brcms_c_info { struct brcms_pub *pub; struct brcms_info *wl; - struct d11regs *regs; + struct d11regs __iomem *regs; struct brcms_hardware *hw; /* clock */ From ffa1350e509d85699c9c8d902a5cbc57094e2f12 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:32 -0700 Subject: [PATCH 1262/1519] staging: brcm80211: added __iomem qualifier to softmac dma.c Code cleanup. Makes it clear when an address is mapped IO space. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/dma.c | 17 +++++++++-------- drivers/staging/brcm80211/brcmsmac/dma.h | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c index ef856ce635b..b56a30297c2 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ b/drivers/staging/brcm80211/brcmsmac/dma.c @@ -224,9 +224,9 @@ struct dma_info { bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ /* 64-bit dma tx engine registers */ - struct dma64regs *d64txregs; + struct dma64regs __iomem *d64txregs; /* 64-bit dma rx engine registers */ - struct dma64regs *d64rxregs; + struct dma64regs __iomem *d64rxregs; /* pointer to dma64 tx descriptor ring */ struct dma64desc *txd64; /* pointer to dma64 rx descriptor ring */ @@ -391,7 +391,7 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) return dmactrlflags; } -static bool _dma64_addrext(struct dma64regs *dma64regs) +static bool _dma64_addrext(struct dma64regs __iomem *dma64regs) { u32 w; OR_REG(&dma64regs->control, D64_XC_AE); @@ -553,8 +553,9 @@ static bool _dma_alloc(struct dma_info *di, uint direction) } struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void *dmaregstx, void *dmaregsrx, uint ntxd, - uint nrxd, uint rxbufsize, int rxextheadroom, + void __iomem *dmaregstx, void __iomem *dmaregsrx, + uint ntxd, uint nrxd, + uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level) { struct dma_info *di; @@ -571,8 +572,8 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); /* init dma reg pointer */ - di->d64txregs = (struct dma64regs *) dmaregstx; - di->d64rxregs = (struct dma64regs *) dmaregsrx; + di->d64txregs = (struct dma64regs __iomem *) dmaregstx; + di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; /* * Default flags (which can be changed by the driver calling @@ -1344,7 +1345,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) if (range == DMA_RANGE_ALL) end = di->txout; else { - struct dma64regs *dregs = di->d64txregs; + struct dma64regs __iomem *dregs = di->d64txregs; end = (u16) (B2I(((R_REG(&dregs->status0) & D64_XS0_CD_MASK) - diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h index 4075dc9c74b..ebc5bc546f3 100644 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ b/drivers/staging/brcm80211/brcmsmac/dma.h @@ -74,8 +74,9 @@ struct dma_pub { }; extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void *dmaregstx, void *dmaregsrx, uint ntxd, - uint nrxd, uint rxbufsize, int rxextheadroom, + void __iomem *dmaregstx, void __iomem *dmaregsrx, + uint ntxd, uint nrxd, + uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level); void dma_rxinit(struct dma_pub *pub); From 71e233a2abc11a8b4263e4883e90f9fbe01fd806 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:33 -0700 Subject: [PATCH 1263/1519] staging: brcm80211: added __iomem qualifier to softmac phy Code cleanup. Makes it clear when an address is mapped IO space. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 19 +++++++++---------- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 9 +++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 5b814805f45..45e3b4b294f 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -323,7 +323,7 @@ void write_phy_channel_reg(struct brcms_phy *pi, uint val) u16 read_phy_reg(struct brcms_phy *pi, u16 addr) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = pi->regs; @@ -335,7 +335,7 @@ u16 read_phy_reg(struct brcms_phy *pi, u16 addr) void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = pi->regs; @@ -345,8 +345,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) if (addr == 0x72) (void)R_REG(®s->phyregdata); #else - W_REG((u32 *)(®s->phyregaddr), - addr | (val << 16)); + W_REG((u32 __iomem *)(®s->phyregaddr), addr | (val << 16)); if (++pi->phy_wreg >= pi->phy_wreg_limit) { pi->phy_wreg = 0; (void)R_REG(®s->phyversion); @@ -356,7 +355,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = pi->regs; @@ -368,7 +367,7 @@ void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = pi->regs; @@ -380,7 +379,7 @@ void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) { - struct d11regs *regs; + struct d11regs __iomem *regs; regs = pi->regs; @@ -494,8 +493,8 @@ static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) } struct brcms_phy_pub * -wlc_phy_attach(struct shared_phy *sh, struct d11regs *regs, int bandtype, - char *vars, struct wiphy *wiphy) +wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, + int bandtype, char *vars, struct wiphy *wiphy) { struct brcms_phy *pi; u32 sflags = 0; @@ -1065,7 +1064,7 @@ wlc_phy_init_radio_regs(struct brcms_phy *pi, void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) { #define DUMMY_PKT_LEN 20 - struct d11regs *regs = pi->regs; + struct d11regs __iomem *regs = pi->regs; int i, count; u8 ofdmpkt[DUMMY_PKT_LEN] = { 0xcc, 0x01, 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index 39c3c2248e0..44818af3047 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -184,7 +184,7 @@ struct shared_phy_params { extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, - struct d11regs *regs, + struct d11regs __iomem *regs, int bandtype, char *vars, struct wiphy *wiphy); extern void wlc_phy_detach(struct brcms_phy_pub *ppi); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 16115212226..446809047cf 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -559,7 +559,7 @@ struct brcms_phy { } u; bool user_txpwr_at_rfport; - struct d11regs *regs; + struct d11regs __iomem *regs; struct brcms_phy *next; char *vars; struct brcms_phy_pub pubpi; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 4023af13812..67cfcdd8aab 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -19363,7 +19363,7 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) bool do_nphy_cal = false; uint core; uint origidx, intr_val; - struct d11regs *regs; + struct d11regs __iomem *regs; u32 d11_clk_ctl_st; bool do_rssi_cal = false; @@ -19385,9 +19385,10 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && CHSPEC_IS40(pi->radio_chanspec)) { - regs = (struct d11regs *) ai_switch_core(pi->sh->sih, - D11_CORE_ID, &origidx, - &intr_val); + regs = (struct d11regs __iomem *) + ai_switch_core(pi->sh->sih, + D11_CORE_ID, &origidx, + &intr_val); d11_clk_ctl_st = R_REG(®s->clk_ctl_st); AND_REG(®s->clk_ctl_st, ~(CCS_FORCEHT | CCS_HTAREQ)); From 683fbb42396106974c315897d8d379f9e7b8ee40 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Sun, 2 Oct 2011 10:14:34 -0700 Subject: [PATCH 1264/1519] staging: brcm80211: only allow one call to add_interface callback The driver only supports one network interface to be associated with it. Only for the first call it does actually something. For subsequent calls it does return -ENODEV error code. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 1fa95d71973..6787498cb04 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -341,7 +341,10 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) wl = hw->priv; LOCK(wl); - err = brcms_up(wl); + if (!wl->pub->up) + err = brcms_up(wl); + else + err = -ENODEV; UNLOCK(wl); if (err != 0) From 875176bb0b92d454b7a906c7ebea2c3f09ca3abf Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:35 -0700 Subject: [PATCH 1265/1519] staging: brcm80211: reduce indentation level in dhd_sdio.c #1 By introducing two new functions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 4992d4df27e..169c6b2f285 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1335,11 +1335,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) if (pnext) { brcmf_dbg(GLOM, "allocated %d-byte packet chain for %d subframes\n", totlen, num); - if (BRCMF_GLOM_ON() && bus->nextlen) { - if (totlen != bus->nextlen) { - brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", - bus->nextlen, totlen, rxseq); - } + if (BRCMF_GLOM_ON() && bus->nextlen && + totlen != bus->nextlen) { + brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", + bus->nextlen, totlen, rxseq); } bus->glom = pfirst; pfirst = pnext = NULL; @@ -1753,6 +1752,51 @@ done: brcmf_sdbrcm_ioctl_resp_wake(bus); } +/* Pad read to blocksize for efficiency */ +static void brcmf_pad(struct brcmf_bus *bus, u16 *pad, u16 *rdlen) +{ + if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) { + *pad = bus->blocksize - (*rdlen % bus->blocksize); + if (*pad <= bus->roundup && *pad < bus->blocksize && + *rdlen + *pad + BRCMF_FIRSTREAD < MAX_RX_DATASZ) + *rdlen += *pad; + } else if (*rdlen % BRCMF_SDALIGN) { + *rdlen += BRCMF_SDALIGN - (*rdlen % BRCMF_SDALIGN); + } +} + +static void +brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, + struct sk_buff **pkt, u8 **rxbuf) +{ + int sdret; /* Return code from calls */ + + *pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN); + if (*pkt == NULL) + return; + + pkt_align(*pkt, rdlen, BRCMF_SDALIGN); + *rxbuf = (u8 *) ((*pkt)->data); + /* Read the entire frame */ + sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, + *rxbuf, rdlen, *pkt); + bus->f2rxdata++; + + if (sdret < 0) { + brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n", + rdlen, sdret); + brcmu_pkt_buf_free_skb(*pkt); + bus->drvr->rx_errors++; + /* Force retry w/normal header read. + * Don't attempt NAK for + * gSPI + */ + brcmf_sdbrcm_rxfail(bus, true, true); + *pkt = NULL; + } +} + /* Return true if there may be more frames to read */ static uint brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) @@ -1801,63 +1845,19 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) bus->nextlen = 0; rdlen = len = nextlen << 4; + brcmf_pad(bus, &pad, &rdlen); - /* Pad read to blocksize for efficiency */ - if (bus->roundup && bus->blocksize - && (rdlen > bus->blocksize)) { - pad = - bus->blocksize - - (rdlen % bus->blocksize); - if ((pad <= bus->roundup) - && (pad < bus->blocksize) - && ((rdlen + pad + BRCMF_FIRSTREAD) < - MAX_RX_DATASZ)) - rdlen += pad; - } else if (rdlen % BRCMF_SDALIGN) { - rdlen += BRCMF_SDALIGN - - (rdlen % BRCMF_SDALIGN); - } - - /* We use bus->rxctl buffer in WinXP for initial - * control pkt receives. - * Later we use buffer-poll for data as well - * as control packets. - * This is required because dhd receives full - * frame in gSPI unlike SDIO. + /* * After the frame is received we have to * distinguish whether it is data * or non-data frame. */ - /* Allocate a packet buffer */ - pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN); - if (!pkt) { + brcmf_alloc_pkt_and_read(bus, rdlen, &pkt, &rxbuf); + if (pkt == NULL) { /* Give up on data, request rtx of events */ - brcmf_dbg(ERROR, "(nextlen): brcmu_pkt_buf_get_skb failed: len %d rdlen %d expected rxseq %d\n", + brcmf_dbg(ERROR, "(nextlen): brcmf_alloc_pkt_and_read failed: len %d rdlen %d expected rxseq %d\n", len, rdlen, rxseq); continue; - } else { - pkt_align(pkt, rdlen, BRCMF_SDALIGN); - rxbuf = (u8 *) (pkt->data); - /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, - rxbuf, rdlen, - pkt); - bus->f2rxdata++; - - if (sdret < 0) { - brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n", - rdlen, sdret); - brcmu_pkt_buf_free_skb(pkt); - bus->drvr->rx_errors++; - /* Force retry w/normal header read. - * Don't attempt NAK for - * gSPI - */ - brcmf_sdbrcm_rxfail(bus, true, true); - continue; - } } /* Now check the header */ From 800c2b675099813fcc0d210aa5ccb7ae8bab50a0 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:36 -0700 Subject: [PATCH 1266/1519] staging: brcm80211: reduce indentation level in dhd_sdio.c #2 By introducing 1 new function. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 103 ++++++++++-------- 1 file changed, 58 insertions(+), 45 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 169c6b2f285..cabf9129d0b 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1797,6 +1797,62 @@ brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, } } +/* Checks the header */ +static int +brcmf_check_rxbuf(struct brcmf_bus *bus, struct sk_buff *pkt, u8 *rxbuf, + u8 rxseq, u16 nextlen, u16 *len) +{ + u16 check; + bool len_consistent; /* Result of comparing readahead len and + len from hw-hdr */ + + memcpy(bus->rxhdr, rxbuf, SDPCM_HDRLEN); + + /* Extract hardware header fields */ + *len = get_unaligned_le16(bus->rxhdr); + check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); + + /* All zeros means readahead info was bad */ + if (!(*len | check)) { + brcmf_dbg(INFO, "(nextlen): read zeros in HW header???\n"); + goto fail; + } + + /* Validate check bytes */ + if ((u16)~(*len ^ check)) { + brcmf_dbg(ERROR, "(nextlen): HW hdr error: nextlen/len/check 0x%04x/0x%04x/0x%04x\n", + nextlen, *len, check); + bus->rx_badhdr++; + brcmf_sdbrcm_rxfail(bus, false, false); + goto fail; + } + + /* Validate frame length */ + if (*len < SDPCM_HDRLEN) { + brcmf_dbg(ERROR, "(nextlen): HW hdr length invalid: %d\n", + *len); + goto fail; + } + + /* Check for consistency with readahead info */ + len_consistent = (nextlen != (roundup(*len, 16) >> 4)); + if (len_consistent) { + /* Mismatch, force retry w/normal + header (may be >4K) */ + brcmf_dbg(ERROR, "(nextlen): mismatch, nextlen %d len %d rnd %d; expected rxseq %d\n", + nextlen, *len, roundup(*len, 16), + rxseq); + brcmf_sdbrcm_rxfail(bus, true, true); + goto fail; + } + + return 0; + +fail: + brcmf_sdbrcm_pktfree2(bus, pkt); + return -EINVAL; +} + /* Return true if there may be more frames to read */ static uint brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) @@ -1812,8 +1868,6 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) uint rxleft = 0; /* Remaining number of frames allowed */ int sdret; /* Return code from calls */ u8 txmax; /* Maximum tx sequence offered */ - bool len_consistent; /* Result of comparing readahead len and - len from hw-hdr */ u8 *rxbuf; int ifidx = 0; uint rxcount = 0; /* Total frames read */ @@ -1860,50 +1914,9 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) continue; } - /* Now check the header */ - memcpy(bus->rxhdr, rxbuf, SDPCM_HDRLEN); - - /* Extract hardware header fields */ - len = get_unaligned_le16(bus->rxhdr); - check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); - - /* All zeros means readahead info was bad */ - if (!(len | check)) { - brcmf_dbg(INFO, "(nextlen): read zeros in HW header???\n"); - brcmf_sdbrcm_pktfree2(bus, pkt); + if (brcmf_check_rxbuf(bus, pkt, rxbuf, rxseq, nextlen, + &len) < 0) continue; - } - - /* Validate check bytes */ - if ((u16)~(len ^ check)) { - brcmf_dbg(ERROR, "(nextlen): HW hdr error: nextlen/len/check 0x%04x/0x%04x/0x%04x\n", - nextlen, len, check); - bus->rx_badhdr++; - brcmf_sdbrcm_rxfail(bus, false, false); - brcmf_sdbrcm_pktfree2(bus, pkt); - continue; - } - - /* Validate frame length */ - if (len < SDPCM_HDRLEN) { - brcmf_dbg(ERROR, "(nextlen): HW hdr length invalid: %d\n", - len); - brcmf_sdbrcm_pktfree2(bus, pkt); - continue; - } - - /* Check for consistency withreadahead info */ - len_consistent = (nextlen != (roundup(len, 16) >> 4)); - if (len_consistent) { - /* Mismatch, force retry w/normal - header (may be >4K) */ - brcmf_dbg(ERROR, "(nextlen): mismatch, nextlen %d len %d rnd %d; expected rxseq %d\n", - nextlen, len, roundup(len, 16), - rxseq); - brcmf_sdbrcm_rxfail(bus, true, true); - brcmf_sdbrcm_pktfree2(bus, pkt); - continue; - } /* Extract software header fields */ chan = SDPCM_PACKET_CHANNEL( From 9f3697f950a85028ade4b67d475c08a899722cba Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:37 -0700 Subject: [PATCH 1267/1519] staging: brcm80211: reduce indentation level in dhd_sdio.c #3 By introducing 1 new function. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 85 ++++++++++--------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index cabf9129d0b..0def6e3ad01 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2960,6 +2960,48 @@ break2: } #endif /* BCMDBG */ +static int brcmf_tx_frame(struct brcmf_bus *bus, u8 *frame, u16 len) +{ + int i; + int ret; + + bus->ctrl_frame_stat = false; + ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, len, NULL); + + if (ret < 0) { + /* On failure, abort the command and terminate the frame */ + brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", + ret); + bus->tx_sderrs++; + + brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); + + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_FRAMECTRL, + SFC_WF_TERM, NULL); + bus->f1regdata++; + + for (i = 0; i < 3; i++) { + u8 hi, lo; + hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCHI, + NULL); + lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_WFRAMEBCLO, + NULL); + bus->f1regdata += 2; + if (hi == 0 && lo == 0) + break; + } + return ret; + } + + bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; + + return ret; +} + int brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) { @@ -2969,7 +3011,6 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) uint retries = 0; u8 doff = 0; int ret = -1; - int i; brcmf_dbg(TRACE, "Enter\n"); @@ -3060,46 +3101,8 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) #endif do { - bus->ctrl_frame_stat = false; - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, len, NULL); - - if (ret < 0) { - /* On failure, abort the command and - terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, - SFC_WF_TERM, NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } - - } - if (ret == 0) - bus->tx_seq = - (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - - } while ((ret < 0) && retries++ < TXRETRIES); + ret = brcmf_tx_frame(bus, frame, len); + } while (ret < 0 && retries++ < TXRETRIES); } if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { From 8b36ac445ad5af861d05846029230b8c6b434efb Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Sun, 2 Oct 2011 10:14:38 -0700 Subject: [PATCH 1268/1519] staging: brcm80211: reducing indentation levels in bcmsdh_sdmmc.c Some functions in the source file had a lot of indentation levels forcing statements to be spread over multiple lines impairing the readability of the code. Reported-by: Joe Perches Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 140 ++++++++---------- 1 file changed, 63 insertions(+), 77 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 1cbdb80c023..fc95bb24846 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -70,6 +70,54 @@ brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t *wq) #endif } +static inline int brcmf_sdioh_f0_write_byte(struct brcmf_sdio_dev *sdiodev, + uint regaddr, u8 *byte) +{ + struct sdio_func *sdfunc = sdiodev->func[0]; + int err_ret; + + /* + * Can only directly write to some F0 registers. + * Handle F2 enable/disable and Abort command + * as a special case. + */ + if (regaddr == SDIO_CCCR_IOEx) { + sdfunc = sdiodev->func[2]; + if (sdfunc) { + sdio_claim_host(sdfunc); + if (*byte & SDIO_FUNC_ENABLE_2) { + /* Enable Function 2 */ + err_ret = sdio_enable_func(sdfunc); + if (err_ret) + brcmf_dbg(ERROR, + "enable F2 failed:%d\n", + err_ret); + } else { + /* Disable Function 2 */ + err_ret = sdio_disable_func(sdfunc); + if (err_ret) + brcmf_dbg(ERROR, + "Disable F2 failed:%d\n", + err_ret); + } + sdio_release_host(sdfunc); + } + } else if (regaddr == SDIO_CCCR_ABORT) { + sdio_claim_host(sdfunc); + sdio_writeb(sdfunc, *byte, regaddr, &err_ret); + sdio_release_host(sdfunc); + } else if (regaddr < 0xF0) { + brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", regaddr); + err_ret = -EPERM; + } else { + sdio_claim_host(sdfunc); + sdio_f0_writeb(sdfunc, *byte, regaddr, &err_ret); + sdio_release_host(sdfunc); + } + + return err_ret; +} + int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint regaddr, u8 *byte) { @@ -80,82 +128,22 @@ int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, brcmf_pm_resume_wait(sdiodev, &sdiodev->request_byte_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; - if (rw) { /* CMD52 Write */ - if (func == 0) { - /* Can only directly write to some F0 registers. - * Handle F2 enable - * as a special case. - */ - if (regaddr == SDIO_CCCR_IOEx) { - if (sdiodev->func[2]) { - sdio_claim_host(sdiodev->func[2]); - if (*byte & SDIO_FUNC_ENABLE_2) { - /* Enable Function 2 */ - err_ret = - sdio_enable_func - (sdiodev->func[2]); - if (err_ret) - brcmf_dbg(ERROR, - "enable F2 failed:%d\n", - err_ret); - } else { - /* Disable Function 2 */ - err_ret = - sdio_disable_func - (sdiodev->func[2]); - if (err_ret) - brcmf_dbg(ERROR, - "Disable F2 failed:%d\n", - err_ret); - } - sdio_release_host(sdiodev->func[2]); - } - } - /* to allow abort command through F1 */ - else if (regaddr == SDIO_CCCR_ABORT) { - sdio_claim_host(sdiodev->func[func]); - /* - * this sdio_f0_writeb() can be replaced - * with another api - * depending upon MMC driver change. - * As of this time, this is temporaray one - */ - sdio_writeb(sdiodev->func[func], *byte, - regaddr, &err_ret); - sdio_release_host(sdiodev->func[func]); - } else if (regaddr < 0xF0) { - brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", - regaddr); - } else { - /* Claim host controller, perform F0 write, - and release */ - sdio_claim_host(sdiodev->func[func]); - sdio_f0_writeb(sdiodev->func[func], *byte, - regaddr, &err_ret); - sdio_release_host(sdiodev->func[func]); - } - } else { - /* Claim host controller, perform Fn write, - and release */ - sdio_claim_host(sdiodev->func[func]); + + if (rw && func == 0) { + /* handle F0 separately */ + err_ret = brcmf_sdioh_f0_write_byte(sdiodev, regaddr, byte); + } else { + sdio_claim_host(sdiodev->func[func]); + if (rw) /* CMD52 Write */ sdio_writeb(sdiodev->func[func], *byte, regaddr, &err_ret); - sdio_release_host(sdiodev->func[func]); - } - } else { /* CMD52 Read */ - /* Claim host controller, perform Fn read, and release */ - sdio_claim_host(sdiodev->func[func]); - - if (func == 0) { - *byte = - sdio_f0_readb(sdiodev->func[func], regaddr, - &err_ret); + else if (func == 0) { + *byte = sdio_f0_readb(sdiodev->func[func], regaddr, + &err_ret); } else { - *byte = - sdio_readb(sdiodev->func[func], regaddr, - &err_ret); + *byte = sdio_readb(sdiodev->func[func], regaddr, + &err_ret); } - sdio_release_host(sdiodev->func[func]); } @@ -197,12 +185,10 @@ int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } else { /* CMD52 Read */ if (nbytes == 4) - *word = - sdio_readl(sdiodev->func[func], addr, &err_ret); + *word = sdio_readl(sdiodev->func[func], addr, &err_ret); else if (nbytes == 2) - *word = - sdio_readw(sdiodev->func[func], addr, - &err_ret) & 0xFFFF; + *word = sdio_readw(sdiodev->func[func], addr, + &err_ret) & 0xFFFF; else brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } From 93a03c62ed26db436559dcd14f18fc65d77b3cd9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:39 -0700 Subject: [PATCH 1269/1519] staging: brcm80211: removed unused fullmac spinlock Usage of spinlock depended on module parameters that are going to be removed in a subsequent patch. Parameter wlc->threads_only is always 'true'. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 58 +++++++------------ 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 0def6e3ad01..198d544ffb7 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -655,7 +655,6 @@ struct brcmf_bus { bool threads_only; struct semaphore sdsem; - spinlock_t sdlock; const char *fw_name; const struct firmware *firmware; @@ -812,22 +811,6 @@ static void brcmf_sdbrcm_pktfree2(struct brcmf_bus *bus, struct sk_buff *pkt) brcmu_pkt_buf_free_skb(pkt); } -static void brcmf_sdbrcm_sdlock(struct brcmf_bus *bus) -{ - if (bus->threads_only) - down(&bus->sdsem); - else - spin_lock_bh(&bus->sdlock); -} - -static void brcmf_sdbrcm_sdunlock(struct brcmf_bus *bus) -{ - if (bus->threads_only) - up(&bus->sdsem); - else - spin_unlock_bh(&bus->sdlock); -} - /* Turn backplane clock on or off */ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) { @@ -1622,9 +1605,9 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) #endif /* BCMDBG */ } if (num) { - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); brcmf_rx_frame(bus->drvr, ifidx, save_pfirst, num); - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); } bus->rxglomframes++; @@ -2225,9 +2208,9 @@ deliver: } /* Unlock during rx call */ - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); brcmf_rx_frame(bus->drvr, ifidx, pkt, 1); - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); } rxcount = maxframes - rxleft; #ifdef BCMDBG @@ -2257,10 +2240,10 @@ brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, static void brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) { - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); wait_event_interruptible_timeout(bus->ctrl_wait, (*lockvar == false), HZ * 2); - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); return; } @@ -2407,9 +2390,9 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, done: /* restore pkt buffer pointer before calling tx complete routine */ skb_pull(pkt, SDPCM_HDRLEN + pad); - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); brcmf_txcomplete(bus->drvr, pkt, ret != 0); - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); if (free_pkt) brcmu_pkt_buf_free_skb(pkt); @@ -2487,7 +2470,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) /* Start with leftover status bits */ intstatus = bus->intstatus; - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); /* If waiting for HTAVAIL, check status */ if (bus->clkstate == CLK_PENDING) { @@ -2711,7 +2694,7 @@ clkwait: brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); } - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); return resched; } @@ -3048,7 +3031,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) /* precondition: IS_ALIGNED((unsigned long)frame, 2) */ /* Need to lock here to protect txseq and SDIO tx calls */ - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); bus_wake(bus); @@ -3110,7 +3093,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); } - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); if (ret) bus->drvr->tx_ctlerrs++; @@ -3135,11 +3118,11 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) /* Wait until control frame is available */ timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); rxlen = bus->rxlen; memcpy(msg, bus->rxctl, min(msglen, rxlen)); bus->rxlen = 0; - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); if (rxlen) { brcmf_dbg(CTL, "resumed on rxctl frame, got %d expected %d\n", @@ -3677,7 +3660,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) brcmf_dbg(TRACE, "Enter\n"); if (enforce_mutex) - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); bus_wake(bus); @@ -3749,7 +3732,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) bus->tx_seq = bus->rx_seq = 0; if (enforce_mutex) - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); } int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) @@ -3777,7 +3760,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); if (enforce_mutex) - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); /* Make sure backplane clock is on, needed to generate F2 interrupt */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -3851,7 +3834,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) exit: if (enforce_mutex) - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); return ret; } @@ -3904,7 +3887,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) if (bus->sleeping) return false; - brcmf_sdbrcm_sdlock(bus); + down(&bus->sdsem); /* Poll period: check device if appropriate. */ if (bus->poll && (++bus->polltick >= bus->pollrate)) { @@ -3969,7 +3952,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) } } - brcmf_sdbrcm_sdunlock(bus); + up(&bus->sdsem); return bus->ipend; } @@ -4562,7 +4545,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, sema_init(&bus->sdsem, 1); } else { bus->threads_only = false; - spin_lock_init(&bus->sdlock); } if (brcmf_dpc_prio >= 0) { From 4be9393fb8f11f5eb0aeabd1e5564d6930f36bbf Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:40 -0700 Subject: [PATCH 1270/1519] staging: brcm80211: removed unused softmac mimo disable code No element in array locale_bn[] has the 'no mimo' flag bit set. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 15 +++------------ drivers/staging/brcm80211/brcmsmac/main.h | 2 -- drivers/staging/brcm80211/brcmsmac/stf.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 02bb7955d6f..7fe005aabd8 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -987,7 +987,6 @@ brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, const char *ccode, uint regrev, const struct country_info *country) { - const struct locale_mimo_info *li_mimo; const struct locale_info *locale; struct brcms_c_info *wlc = wlc_cm->wlc; char prev_country_abbrev[BRCM_CNTRY_BUF_SZ]; @@ -1003,17 +1002,9 @@ brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, strncpy(wlc_cm->ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); wlc_cm->regrev = regrev; - /* disable/restore nmode based on country regulations */ - li_mimo = brcms_c_get_mimo_2g(country->locale_mimo_2G); - if (li_mimo && (li_mimo->flags & BRCMS_NO_MIMO)) { - brcms_c_set_nmode(wlc, OFF); - wlc->stf->no_cddstbc = true; - } else { - wlc->stf->no_cddstbc = false; - if ((wlc->pub->_n_enab & SUPPORT_11N) != - wlc->protection->nmode_user) - brcms_c_set_nmode(wlc, wlc->protection->nmode_user); - } + if ((wlc->pub->_n_enab & SUPPORT_11N) != + wlc->protection->nmode_user) + brcms_c_set_nmode(wlc, wlc->protection->nmode_user); brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 045356aaefd..8815042e448 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -194,7 +194,6 @@ struct brcms_protection { * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel; * else use wlc->band->stf->ss_mode_band. * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC. - * no_cddstbc: stf override, 1: no CDD (or STBC) allowed. * rxchain_restore_delay: delay time to restore default rxchain. * ldpc: AUTO/ON/OFF ldpc cap supported. * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts. @@ -213,7 +212,6 @@ struct brcms_stf { u8 ss_opmode; bool ss_algosel_auto; u16 ss_algo_channel; - u8 no_cddstbc; u8 rxchain_restore_delay; s8 ldpc; u8 txcore[MAX_STREAMS_SUPPORTED + 1]; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index c77bab2be87..ba3c3eff5f8 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -319,17 +319,15 @@ int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band) if (BRCMS_STBC_CAP_PHY(wlc) && wlc->stf->ss_algosel_auto && (wlc->stf->ss_algo_channel != (u16) -1)) { - upd_stf_ss = (wlc->stf->no_cddstbc || (wlc->stf->txstreams == 1) - || isset(&wlc->stf->ss_algo_channel, - PHY_TXC1_MODE_SISO)) ? PHY_TXC1_MODE_SISO - : PHY_TXC1_MODE_CDD; + upd_stf_ss = (wlc->stf->txstreams == 1 || + isset(&wlc->stf->ss_algo_channel, + PHY_TXC1_MODE_SISO)) ? + PHY_TXC1_MODE_SISO : PHY_TXC1_MODE_CDD; } else { if (wlc->band != band) return ret_code; - upd_stf_ss = (wlc->stf->no_cddstbc - || (wlc->stf->txstreams == - 1)) ? PHY_TXC1_MODE_SISO : band-> - band_stf_ss_mode; + upd_stf_ss = (wlc->stf->txstreams == 1) ? + PHY_TXC1_MODE_SISO : band->band_stf_ss_mode; } if (prev_stf_ss != upd_stf_ss) { wlc->stf->ss_opmode = upd_stf_ss; From 9ee777a558b16b1e115e0db972c1786dd8221e59 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:41 -0700 Subject: [PATCH 1271/1519] staging: brcm80211: removed fullmac function brcmf_bus_devreset() Function is not called anymore. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 2 - drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 82 +------------------ 2 files changed, 1 insertion(+), 83 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index be6c620a712..d79bd797a2a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -599,7 +599,6 @@ struct brcmf_pub { /* Internal brcmf items */ bool up; /* Driver up/down (to OS) */ bool txoff; /* Transmit flow-controlled */ - bool dongle_reset; /* true = DEVRESET put dongle into reset */ enum brcmf_bus_state busstate; uint hdrlen; /* Total BRCMF header length (proto + bus) */ uint maxctl; /* Max size rxctl request from proto to bus */ @@ -744,7 +743,6 @@ extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); extern int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx,\ struct sk_buff *pkt); -extern int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag); extern int brcmf_bus_start(struct brcmf_pub *drvr); extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 198d544ffb7..655209d187f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2269,11 +2269,6 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr->dongle_reset) { - ret = -EPERM; - goto done; - } - frame = (u8 *) (pkt->data); /* Add alignment padding, allocate new packet if needed */ @@ -2997,9 +2992,6 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr->dongle_reset) - return -EIO; - /* Back the pointer to make a room for bus header */ frame = msg - SDPCM_HDRLEN; len = (msglen += SDPCM_HDRLEN); @@ -3112,9 +3104,6 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr->dongle_reset) - return -EIO; - /* Wait until control frame is available */ timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); @@ -3880,9 +3869,6 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) bus = drvr->bus; - if (bus->drvr->dongle_reset) - return false; - /* Ignore the timer if simulating bus down */ if (bus->sleeping) return false; @@ -3968,9 +3954,6 @@ static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) { brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr && bus->drvr->dongle_reset) - return; - kfree(bus->rxbuf); bus->rxctl = bus->rxbuf = NULL; bus->rxlen = 0; @@ -4406,8 +4389,7 @@ brcmf_sdbrcm_watchdog_thread(void *data) if (kthread_should_stop()) break; if (!wait_for_completion_interruptible(&bus->watchdog_wait)) { - if (bus->drvr->dongle_reset == false) - brcmf_sdbrcm_bus_watchdog(bus->drvr); + brcmf_sdbrcm_bus_watchdog(bus->drvr); /* Count the tick for reference */ bus->drvr->tickcnt++; } else @@ -4451,9 +4433,6 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) { brcmf_dbg(TRACE, "Enter\n"); - if (bus->drvr && bus->drvr->dongle_reset) - return; - if (bus->ci) { brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); @@ -4672,65 +4651,6 @@ struct device *brcmf_bus_get_device(struct brcmf_bus *bus) return &bus->sdiodev->func[2]->dev; } -int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag) -{ - int bcmerror = 0; - struct brcmf_bus *bus; - - bus = drvr->bus; - - if (flag == true) { - brcmf_sdbrcm_wd_timer(bus, 0); - if (!bus->drvr->dongle_reset) { - /* Expect app to have torn down any - connection before calling */ - /* Stop the bus, disable F2 */ - brcmf_sdbrcm_bus_stop(bus, false); - - /* Clean tx/rx buffer pointers, - detach from the dongle */ - brcmf_sdbrcm_release_dongle(bus); - - bus->drvr->dongle_reset = true; - bus->drvr->up = false; - - brcmf_dbg(TRACE, "WLAN OFF DONE\n"); - /* App can now remove power from device */ - } else - bcmerror = -EIO; - } else { - /* App must have restored power to device before calling */ - - brcmf_dbg(TRACE, " == WLAN ON ==\n"); - - if (bus->drvr->dongle_reset) { - /* Turn on WLAN */ - - /* Attempt to re-attach & download */ - if (brcmf_sdbrcm_probe_attach(bus, SI_ENUM_BASE)) { - /* Attempt to download binary to the dongle */ - if (brcmf_sdbrcm_probe_init(bus)) { - /* Re-init bus, enable F2 transfer */ - brcmf_sdbrcm_bus_init(bus->drvr, false); - - bus->drvr->dongle_reset = false; - bus->drvr->up = true; - - brcmf_dbg(TRACE, "WLAN ON DONE\n"); - } else - bcmerror = -EIO; - } else - bcmerror = -EIO; - } else { - bcmerror = -EISCONN; - brcmf_dbg(ERROR, "Set DEVRESET=false invoked when device is on\n"); - bcmerror = -EIO; - } - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - } - return bcmerror; -} - void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) { From 8ff3a896843aa11358f57819cc4ac001120d1331 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:42 -0700 Subject: [PATCH 1272/1519] staging: brcm80211: removed 'enforce_mutex' parameter in fullmac Parameter was always called with the value 'true'. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 4 ++-- .../staging/brcm80211/brcmfmac/dhd_linux.c | 4 ++-- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 23 ++++++++----------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index a5064f562e4..a249407c9a1 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -35,10 +35,10 @@ extern void brcmf_bus_unregister(void); extern struct device *brcmf_bus_get_device(struct brcmf_bus *bus); /* Stop bus module: clear pending frames, disable data flow */ -extern void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex); +extern void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus); /* Initialize bus module: prepare for communication w/dongle */ -extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex); +extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr); /* Send a data frame to the dongle. Callee disposes of txp. */ extern int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *txp); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 3ae0d437166..a31b8a3bff8 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -1093,7 +1093,7 @@ int brcmf_bus_start(struct brcmf_pub *drvr) brcmf_dbg(TRACE, "\n"); /* Bring up the bus */ - ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub, true); + ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub); if (ret != 0) { brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret); return ret; @@ -1217,7 +1217,7 @@ static void brcmf_bus_detach(struct brcmf_pub *drvr) brcmf_proto_stop(&drvr_priv->pub); /* Stop the bus module */ - brcmf_sdbrcm_bus_stop(drvr_priv->pub.bus, true); + brcmf_sdbrcm_bus_stop(drvr_priv->pub.bus); } } } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 655209d187f..aa05cc0ed10 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2720,7 +2720,7 @@ static int brcmf_sdbrcm_dpc_thread(void *data) if (brcmf_sdbrcm_dpc(bus)) complete(&bus->dpc_wait); } else { - brcmf_sdbrcm_bus_stop(bus, true); + brcmf_sdbrcm_bus_stop(bus); } } else break; @@ -2736,8 +2736,9 @@ static void brcmf_sdbrcm_dpc_tasklet(unsigned long data) if (bus->drvr->busstate != BRCMF_BUS_DOWN) { if (brcmf_sdbrcm_dpc(bus)) tasklet_schedule(&bus->tasklet); - } else - brcmf_sdbrcm_bus_stop(bus, true); + } else { + brcmf_sdbrcm_bus_stop(bus); + } } static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus) @@ -3639,7 +3640,7 @@ brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) return ret; } -void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) +void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) { u32 local_hostintmask; u8 saveclk; @@ -3648,8 +3649,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) brcmf_dbg(TRACE, "Enter\n"); - if (enforce_mutex) - down(&bus->sdsem); + down(&bus->sdsem); bus_wake(bus); @@ -3720,11 +3720,10 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex) bus->rxskip = false; bus->tx_seq = bus->rx_seq = 0; - if (enforce_mutex) - up(&bus->sdsem); + up(&bus->sdsem); } -int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) +int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) { struct brcmf_bus *bus = drvr->bus; unsigned long timeout; @@ -3748,8 +3747,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) bus->drvr->tickcnt = 0; brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - if (enforce_mutex) - down(&bus->sdsem); + down(&bus->sdsem); /* Make sure backplane clock is on, needed to generate F2 interrupt */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); @@ -3822,8 +3820,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex) brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); exit: - if (enforce_mutex) - up(&bus->sdsem); + up(&bus->sdsem); return ret; } From 2228b27da6b11d748e5072f4413d512b4480d7ee Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:43 -0700 Subject: [PATCH 1273/1519] staging: brcm80211: renamed ioctl functions/structs to dcmd The fullmac dongle communicates with the driver using certain codes. These codes were named 'ioctls' in the code, but this term is confusing since it is used in kernel<->driver context. The term 'ioctl' has been replaced with 'dcmd' for 'dongle command'. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 32 ++--- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 118 ++++++++-------- .../staging/brcm80211/brcmfmac/dhd_common.c | 32 ++--- .../staging/brcm80211/brcmfmac/dhd_linux.c | 118 ++++++++-------- .../staging/brcm80211/brcmfmac/dhd_proto.h | 13 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 26 ++-- .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 126 +++++++++--------- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 10 +- 8 files changed, 233 insertions(+), 242 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index d79bd797a2a..501faed8705 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -23,9 +23,9 @@ #define BRCMF_VERSION_STR "4.218.248.5" -#define BRCMF_C_IOCTL_SMLEN 256 /* "small" ioctl buffer required */ -#define BRCMF_C_IOCTL_MEDLEN 1536 /* "med" ioctl buffer required */ -#define BRCMF_C_IOCTL_MAXLEN 8192 +#define BRCMF_C_DCMD_SMLEN 256 /* "small" cmd buffer required */ +#define BRCMF_C_DCMD_MEDLEN 1536 /* "med" cmd buffer required */ +#define BRCMF_C_DCMD_MAXLEN 8192 /******************************************************************************* * IO codes that are interpreted by dongle firmware @@ -572,12 +572,12 @@ struct brcmf_channel_info_le { __le32 scan_channel; }; -/* Linux network driver ioctl encoding */ -struct brcmf_ioctl { - uint cmd; /* common ioctl definition */ +/* Bus independent dongle command */ +struct brcmf_dcmd { + uint cmd; /* common dongle cmd definition */ void *buf; /* pointer to user buffer */ uint len; /* length of user buffer */ - u8 set; /* get or set request (optional) */ + u8 set; /* get or set request (optional) */ uint used; /* bytes read or written (optional) */ uint needed; /* bytes needed (optional) */ }; @@ -694,7 +694,7 @@ extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); -extern s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len); +extern s32 brcmf_exec_dcmd(struct net_device *dev, u32 cmd, void *arg, u32 len); /* Indication from bus module regarding removal/absence of dongle */ extern void brcmf_detach(struct brcmf_pub *drvr); @@ -716,8 +716,8 @@ extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx); extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success); -/* Query ioctl */ -extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, +/* Query dongle */ +extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, uint len); /* OS independent layer functions */ @@ -749,17 +749,7 @@ extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg); extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, int master_mode); -/* per-driver magic numbers */ -#define BRCMF_IOCTL_MAGIC 0x00444944 - -/* bump this number if you change the ioctl interface */ -#define BRCMF_IOCTL_VERSION 1 -#define BRCMF_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */ - -/* common ioctl definitions */ -#define BRCMF_GET_VERSION 1 -#define BRCMF_GET_VAR 2 -#define BRCMF_SET_VAR 3 +#define BRCMF_DCMD_MAXLEN 8192 /* max length cmd buffer required */ /* message levels */ #define BRCMF_ERROR_VAL 0x0001 diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 4c171a30628..ec0a0574566 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -15,8 +15,8 @@ */ /******************************************************************************* - * Communicates with the dongle by using Broadcom specific ioctl codes. - * For certain ioctl codes, the dongle interprets string data from the host. + * Communicates with the dongle by using dcmd codes. + * For certain dcmd codes, the dongle interprets string data from the host. ******************************************************************************/ #include @@ -32,8 +32,8 @@ #include "dhd_bus.h" #include "dhd_dbg.h" -struct brcmf_proto_cdc_ioctl { - __le32 cmd; /* ioctl command value */ +struct brcmf_proto_cdc_dcmd { + __le32 cmd; /* dongle command value */ __le32 len; /* lower 16: output buflen; * upper 16: input buflen (excludes header) */ __le32 flags; /* flag defns given below */ @@ -44,14 +44,14 @@ struct brcmf_proto_cdc_ioctl { #define CDC_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN) /* CDC flag definitions */ -#define CDCF_IOC_ERROR 0x01 /* 1=ioctl cmd failed */ -#define CDCF_IOC_SET 0x02 /* 0=get, 1=set cmd */ -#define CDCF_IOC_IF_MASK 0xF000 /* I/F index */ -#define CDCF_IOC_IF_SHIFT 12 -#define CDCF_IOC_ID_MASK 0xFFFF0000 /* id an ioctl pairing */ -#define CDCF_IOC_ID_SHIFT 16 /* ID Mask shift bits */ -#define CDC_IOC_ID(flags) \ - (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT) +#define CDC_DCMD_ERROR 0x01 /* 1=cmd failed */ +#define CDC_DCMD_SET 0x02 /* 0=get, 1=set cmd */ +#define CDC_DCMD_IF_MASK 0xF000 /* I/F index */ +#define CDC_DCMD_IF_SHIFT 12 +#define CDC_DCMD_ID_MASK 0xFFFF0000 /* id an cmd pairing */ +#define CDC_DCMD_ID_SHIFT 16 /* ID Mask shift bits */ +#define CDC_DCMD_ID(flags) \ + (((flags) & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT) /* * BDC header - Broadcom specific extension of CDC. @@ -81,7 +81,7 @@ struct brcmf_proto_bdc_header { }; -#define RETRIES 2 /* # of retries to retrieve matching ioctl response */ +#define RETRIES 2 /* # of retries to retrieve matching dcmd response */ #define BUS_HEADER_LEN (16+BRCMF_SDALIGN) /* Must be atleast SDPCM_RESERVE * (amount of header tha might be added) * plus any space that might be needed @@ -96,15 +96,15 @@ struct brcmf_proto { u8 pending; u32 lastcmd; u8 bus_header[BUS_HEADER_LEN]; - struct brcmf_proto_cdc_ioctl msg; - unsigned char buf[BRCMF_C_IOCTL_MAXLEN + ROUND_UP_MARGIN]; + struct brcmf_proto_cdc_dcmd msg; + unsigned char buf[BRCMF_C_DCMD_MAXLEN + ROUND_UP_MARGIN]; }; static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr) { struct brcmf_proto *prot = drvr->prot; int len = le32_to_cpu(prot->msg.len) + - sizeof(struct brcmf_proto_cdc_ioctl); + sizeof(struct brcmf_proto_cdc_dcmd); brcmf_dbg(TRACE, "Enter\n"); @@ -130,20 +130,20 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len) do { ret = brcmf_sdbrcm_bus_rxctl(drvr->bus, (unsigned char *)&prot->msg, - len + sizeof(struct brcmf_proto_cdc_ioctl)); + len + sizeof(struct brcmf_proto_cdc_dcmd)); if (ret < 0) break; - } while (CDC_IOC_ID(le32_to_cpu(prot->msg.flags)) != id); + } while (CDC_DCMD_ID(le32_to_cpu(prot->msg.flags)) != id); return ret; } int -brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, - void *buf, uint len) +brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, + void *buf, uint len) { struct brcmf_proto *prot = drvr->prot; - struct brcmf_proto_cdc_ioctl *msg = &prot->msg; + struct brcmf_proto_cdc_dcmd *msg = &prot->msg; void *info; int ret = 0, retries = 0; u32 id, flags; @@ -163,12 +163,13 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, } } - memset(msg, 0, sizeof(struct brcmf_proto_cdc_ioctl)); + memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd)); msg->cmd = cpu_to_le32(cmd); msg->len = cpu_to_le32(len); - flags = (++prot->reqid << CDCF_IOC_ID_SHIFT); - flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT); + flags = (++prot->reqid << CDC_DCMD_ID_SHIFT); + flags = (flags & ~CDC_DCMD_IF_MASK) | + (ifidx << CDC_DCMD_IF_SHIFT); msg->flags = cpu_to_le32(flags); if (buf) @@ -188,7 +189,7 @@ retry: goto done; flags = le32_to_cpu(msg->flags); - id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; + id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT; if ((id < prot->reqid) && (++retries < RETRIES)) goto retry; @@ -210,7 +211,7 @@ retry: } /* Check the ERROR flag */ - if (flags & CDCF_IOC_ERROR) { + if (flags & CDC_DCMD_ERROR) { ret = le32_to_cpu(msg->status); /* Cache error from dongle */ drvr->dongle_error = ret; @@ -220,23 +221,24 @@ done: return ret; } -int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, - void *buf, uint len) +int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, + void *buf, uint len) { struct brcmf_proto *prot = drvr->prot; - struct brcmf_proto_cdc_ioctl *msg = &prot->msg; + struct brcmf_proto_cdc_dcmd *msg = &prot->msg; int ret = 0; u32 flags, id; brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); - memset(msg, 0, sizeof(struct brcmf_proto_cdc_ioctl)); + memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd)); msg->cmd = cpu_to_le32(cmd); msg->len = cpu_to_le32(len); - flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET; - flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT); + flags = (++prot->reqid << CDC_DCMD_ID_SHIFT) | CDC_DCMD_SET; + flags = (flags & ~CDC_DCMD_IF_MASK) | + (ifidx << CDC_DCMD_IF_SHIFT); msg->flags = cpu_to_le32(flags); if (buf) @@ -251,7 +253,7 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, goto done; flags = le32_to_cpu(msg->flags); - id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; + id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT; if (id != prot->reqid) { brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n", @@ -261,7 +263,7 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd, } /* Check the ERROR flag */ - if (flags & CDCF_IOC_ERROR) { + if (flags & CDC_DCMD_ERROR) { ret = le32_to_cpu(msg->status); /* Cache error from dongle */ drvr->dongle_error = ret; @@ -272,7 +274,7 @@ done: } int -brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, +brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd, int len) { struct brcmf_proto *prot = drvr->prot; @@ -286,50 +288,50 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc, brcmf_dbg(TRACE, "Enter\n"); - if (len > BRCMF_C_IOCTL_MAXLEN) + if (len > BRCMF_C_DCMD_MAXLEN) goto done; if (prot->pending == true) { brcmf_dbg(TRACE, "CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n", - ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd, + dcmd->cmd, (unsigned long)dcmd->cmd, prot->lastcmd, (unsigned long)prot->lastcmd); - if ((ioc->cmd == BRCMF_C_SET_VAR) || - (ioc->cmd == BRCMF_C_GET_VAR)) - brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)ioc->buf); + if (dcmd->cmd == BRCMF_C_SET_VAR || + dcmd->cmd == BRCMF_C_GET_VAR) + brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)dcmd->buf); goto done; } prot->pending = true; - prot->lastcmd = ioc->cmd; - if (ioc->set) - ret = brcmf_proto_cdc_set_ioctl(drvr, ifidx, ioc->cmd, - ioc->buf, len); + prot->lastcmd = dcmd->cmd; + if (dcmd->set) + ret = brcmf_proto_cdc_set_dcmd(drvr, ifidx, dcmd->cmd, + dcmd->buf, len); else { - ret = brcmf_proto_cdc_query_ioctl(drvr, ifidx, ioc->cmd, - ioc->buf, len); + ret = brcmf_proto_cdc_query_dcmd(drvr, ifidx, dcmd->cmd, + dcmd->buf, len); if (ret > 0) - ioc->used = ret - sizeof(struct brcmf_proto_cdc_ioctl); + dcmd->used = ret - + sizeof(struct brcmf_proto_cdc_dcmd); } - /* Too many programs assume ioctl() returns 0 on success */ if (ret >= 0) ret = 0; else { - struct brcmf_proto_cdc_ioctl *msg = &prot->msg; + struct brcmf_proto_cdc_dcmd *msg = &prot->msg; /* len == needed when set/query fails from dongle */ - ioc->needed = le32_to_cpu(msg->len); + dcmd->needed = le32_to_cpu(msg->len); } - /* Intercept the wme_dp ioctl here */ - if (!ret && ioc->cmd == BRCMF_C_SET_VAR && - !strcmp(ioc->buf, "wme_dp")) { + /* Intercept the wme_dp dongle cmd here */ + if (!ret && dcmd->cmd == BRCMF_C_SET_VAR && + !strcmp(dcmd->buf, "wme_dp")) { int slen; __le32 val = 0; slen = strlen("wme_dp") + 1; if (len >= (int)(slen + sizeof(int))) - memcpy(&val, (char *)ioc->buf + slen, sizeof(int)); + memcpy(&val, (char *)dcmd->buf + slen, sizeof(int)); drvr->wme_dp = (u8) le32_to_cpu(val); } @@ -433,8 +435,8 @@ int brcmf_proto_attach(struct brcmf_pub *drvr) drvr->prot = cdc; drvr->hdrlen += BDC_HEADER_LEN; - drvr->maxctl = BRCMF_C_IOCTL_MAXLEN + - sizeof(struct brcmf_proto_cdc_ioctl) + ROUND_UP_MARGIN; + drvr->maxctl = BRCMF_C_DCMD_MAXLEN + + sizeof(struct brcmf_proto_cdc_dcmd) + ROUND_UP_MARGIN; return 0; fail: @@ -472,7 +474,7 @@ int brcmf_proto_init(struct brcmf_pub *drvr) /* Get the device MAC address */ strcpy(buf, "cur_etheraddr"); - ret = brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR, + ret = brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); if (ret < 0) { brcmf_os_proto_unblock(drvr); @@ -482,7 +484,7 @@ int brcmf_proto_init(struct brcmf_pub *drvr) brcmf_os_proto_unblock(drvr); - ret = brcmf_c_preinit_ioctls(drvr); + ret = brcmf_c_preinit_dcmds(drvr); /* Always assumes wl for now */ drvr->iswl = true; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 963d1a9f7c5..4075fd74dd9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -596,7 +596,7 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm)); /* Enable/disable the specified filter. */ - rc = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); + rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", @@ -607,7 +607,7 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, /* Contorl the master mode */ brcmu_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf, sizeof(buf)); - rc = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, buf, + rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, sizeof(buf)); rc = rc >= 0 ? 0 : rc; if (rc) @@ -734,7 +734,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) &pkt_filter, BRCMF_PKT_FILTER_FIXED_LEN + BRCMF_PKT_FILTER_PATTERN_FIXED_LEN); - rc = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); + rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) @@ -755,7 +755,7 @@ static void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) int retcode; brcmu_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); - retcode = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, + retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) @@ -772,7 +772,7 @@ static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) int retcode; brcmu_mkiovar("arpoe", (char *)&arp_enable, 4, iovbuf, sizeof(iovbuf)); - retcode = brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, + retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) @@ -783,7 +783,7 @@ static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) arp_enable); } -int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) +int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr) { char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for "event_msgs" + '\0' + bitvec */ @@ -801,7 +801,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* Set Country code */ if (drvr->country_code[0] != 0) { - if (brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_COUNTRY, + if (brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_COUNTRY, drvr->country_code, sizeof(drvr->country_code)) < 0) brcmf_dbg(ERROR, "country code setting failed\n"); @@ -811,7 +811,7 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) memset(buf, 0, sizeof(buf)); ptr = buf; brcmu_mkiovar("ver", NULL, 0, buf, sizeof(buf)); - brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); + brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); strsep(&ptr, "\n"); /* Print fw version info */ brcmf_dbg(ERROR, "Firmware version = %s\n", buf); @@ -819,40 +819,40 @@ int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr) /* Match Host and Dongle rx alignment */ brcmu_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); /* disable glom option per default */ brcmu_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); /* Setup timeout if Beacons are lost and roam is off to report link down */ brcmu_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable/Disable build-in roaming to allowed ext supplicant to take of romaing */ brcmu_mkiovar("roam_off", (char *)&roaming, 4, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); /* Force STA UP */ - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up)); + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up)); /* Setup event_msgs */ brcmu_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR, iovbuf, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time, sizeof(scan_assoc_time)); - brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME, + brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); /* Set and enable ARP offload feature */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index a31b8a3bff8..641cd9c7f04 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -141,7 +141,7 @@ static void _brcmf_set_multicast_list(struct work_struct *work) __le32 cnt_le; __le32 allmulti_le; - struct brcmf_ioctl ioc; + struct brcmf_dcmd dcmd; char *buf, *bufp; uint buflen; int ret; @@ -177,13 +177,13 @@ static void _brcmf_set_multicast_list(struct work_struct *work) cnt--; } - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = BRCMF_C_SET_VAR; - ioc.buf = buf; - ioc.len = buflen; - ioc.set = true; + memset(&dcmd, 0, sizeof(dcmd)); + dcmd.cmd = BRCMF_C_SET_VAR; + dcmd.buf = buf; + dcmd.len = buflen; + dcmd.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n", brcmf_ifname(&drvr_priv->pub, 0), cnt); @@ -214,13 +214,13 @@ static void _brcmf_set_multicast_list(struct work_struct *work) return; } - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = BRCMF_C_SET_VAR; - ioc.buf = buf; - ioc.len = buflen; - ioc.set = true; + memset(&dcmd, 0, sizeof(dcmd)); + dcmd.cmd = BRCMF_C_SET_VAR; + dcmd.buf = buf; + dcmd.len = buflen; + dcmd.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", brcmf_ifname(&drvr_priv->pub, 0), @@ -235,13 +235,13 @@ static void _brcmf_set_multicast_list(struct work_struct *work) allmulti = (ndev->flags & IFF_PROMISC) ? true : false; allmulti_le = cpu_to_le32(allmulti); - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = BRCMF_C_SET_PROMISC; - ioc.buf = &allmulti_le; - ioc.len = sizeof(allmulti_le); - ioc.set = true; + memset(&dcmd, 0, sizeof(dcmd)); + dcmd.cmd = BRCMF_C_SET_PROMISC; + dcmd.buf = &allmulti_le; + dcmd.len = sizeof(allmulti_le); + dcmd.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: set promisc %d failed\n", brcmf_ifname(&drvr_priv->pub, 0), @@ -253,7 +253,7 @@ static void _brcmf_set_mac_address(struct work_struct *work) { char buf[32]; - struct brcmf_ioctl ioc; + struct brcmf_dcmd dcmd; int ret; struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, @@ -266,13 +266,13 @@ _brcmf_set_mac_address(struct work_struct *work) brcmf_ifname(&drvr_priv->pub, 0)); return; } - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = BRCMF_C_SET_VAR; - ioc.buf = buf; - ioc.len = 32; - ioc.set = true; + memset(&dcmd, 0, sizeof(dcmd)); + dcmd.cmd = BRCMF_C_SET_VAR; + dcmd.buf = buf; + dcmd.len = 32; + dcmd.set = true; - ret = brcmf_proto_ioctl(&drvr_priv->pub, 0, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); if (ret < 0) brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", brcmf_ifname(&drvr_priv->pub, 0)); @@ -628,19 +628,19 @@ static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) as a bitmap in toe_ol iovar */ static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol) { - struct brcmf_ioctl ioc; + struct brcmf_dcmd dcmd; char buf[32]; int ret; - memset(&ioc, 0, sizeof(ioc)); + memset(&dcmd, 0, sizeof(dcmd)); - ioc.cmd = BRCMF_C_GET_VAR; - ioc.buf = buf; - ioc.len = (uint) sizeof(buf); - ioc.set = false; + dcmd.cmd = BRCMF_C_GET_VAR; + dcmd.buf = buf; + dcmd.len = (uint) sizeof(buf); + dcmd.set = false; strcpy(buf, "toe_ol"); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); if (ret < 0) { /* Check for older dongle image that doesn't support toe_ol */ if (ret == -EIO) { @@ -662,23 +662,23 @@ static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol) and set toe global enable iovar */ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) { - struct brcmf_ioctl ioc; + struct brcmf_dcmd dcmd; char buf[32]; int toe, ret; - memset(&ioc, 0, sizeof(ioc)); + memset(&dcmd, 0, sizeof(dcmd)); - ioc.cmd = BRCMF_C_SET_VAR; - ioc.buf = buf; - ioc.len = (uint) sizeof(buf); - ioc.set = true; + dcmd.cmd = BRCMF_C_SET_VAR; + dcmd.buf = buf; + dcmd.len = (uint) sizeof(buf); + dcmd.set = true; /* Set toe_ol as requested */ strcpy(buf, "toe_ol"); memcpy(&buf[sizeof("toe_ol")], &toe_ol, sizeof(u32)); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n", brcmf_ifname(&drvr_priv->pub, ifidx), ret); @@ -692,7 +692,7 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) strcpy(buf, "toe"); memcpy(&buf[sizeof("toe")], &toe, sizeof(u32)); - ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.len); + ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); if (ret < 0) { brcmf_dbg(ERROR, "%s: could not set toe: ret=%d\n", brcmf_ifname(&drvr_priv->pub, ifidx), ret); @@ -849,10 +849,10 @@ static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, return -EOPNOTSUPP; } -/* called only from within this driver. Sends an ioctl to the dongle. */ -s32 brcmf_dev_ioctl(struct net_device *ndev, u32 cmd, void *arg, u32 len) +/* called only from within this driver. Sends a command to the dongle. */ +s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) { - struct brcmf_ioctl ioc; + struct brcmf_dcmd dcmd; s32 err = 0; int buflen = 0; bool is_set_key_cmd; @@ -860,15 +860,15 @@ s32 brcmf_dev_ioctl(struct net_device *ndev, u32 cmd, void *arg, u32 len) netdev_priv(ndev); int ifidx; - memset(&ioc, 0, sizeof(ioc)); - ioc.cmd = cmd; - ioc.buf = arg; - ioc.len = len; + memset(&dcmd, 0, sizeof(dcmd)); + dcmd.cmd = cmd; + dcmd.buf = arg; + dcmd.len = len; ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ioc.buf != NULL) - buflen = min_t(uint, ioc.len, BRCMF_IOCTL_MAXLEN); + if (dcmd.buf != NULL) + buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); /* send to dongle (must be up, and wl) */ if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { @@ -883,18 +883,18 @@ s32 brcmf_dev_ioctl(struct net_device *ndev, u32 cmd, void *arg, u32 len) } /* - * Intercept BRCMF_C_SET_KEY IOCTL - serialize M4 send and - * set key IOCTL to prevent M4 encryption. + * Intercept BRCMF_C_SET_KEY CMD - serialize M4 send and + * set key CMD to prevent M4 encryption. */ - is_set_key_cmd = ((ioc.cmd == BRCMF_C_SET_KEY) || - ((ioc.cmd == BRCMF_C_SET_VAR) && - !(strncmp("wsec_key", ioc.buf, 9))) || - ((ioc.cmd == BRCMF_C_SET_VAR) && - !(strncmp("bsscfg:wsec_key", ioc.buf, 15)))); + is_set_key_cmd = ((dcmd.cmd == BRCMF_C_SET_KEY) || + ((dcmd.cmd == BRCMF_C_SET_VAR) && + !(strncmp("wsec_key", dcmd.buf, 9))) || + ((dcmd.cmd == BRCMF_C_SET_VAR) && + !(strncmp("bsscfg:wsec_key", dcmd.buf, 15)))); if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(ndev); - err = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, buflen); + err = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, buflen); done: if (err > 0) @@ -1107,7 +1107,7 @@ int brcmf_bus_start(struct brcmf_pub *drvr) brcmu_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR, iovbuf, + brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, iovbuf, sizeof(iovbuf)); memcpy(drvr->eventmask, iovbuf, BRCMF_EVENTING_MASK_LEN); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h index 24b0f99e466..4ee1ea846f6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h @@ -17,9 +17,6 @@ #ifndef _BRCMF_PROTO_H_ #define _BRCMF_PROTO_H_ -#define IOCTL_RESP_TIMEOUT 2000 /* In milli second */ -#define IOCTL_CHIP_ACTIVE_TIMEOUT 10 /* In milli second */ - /* * Exported from the brcmf protocol module (brcmf_cdc) */ @@ -48,16 +45,16 @@ extern void brcmf_proto_hdrpush(struct brcmf_pub *, int ifidx, extern int brcmf_proto_hdrpull(struct brcmf_pub *, int *ifidx, struct sk_buff *rxp); -/* Use protocol to issue ioctl to dongle */ -extern int brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, - struct brcmf_ioctl *ioc, int len); +/* Use protocol to issue command to dongle */ +extern int brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, + struct brcmf_dcmd *dcmd, int len); /* Update local copy of dongle statistics */ extern void brcmf_proto_dstats(struct brcmf_pub *drvr); -extern int brcmf_c_preinit_ioctls(struct brcmf_pub *drvr); +extern int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr); -extern int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, +extern int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, uint len); #endif /* _BRCMF_PROTO_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index aa05cc0ed10..5423280ba74 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -35,6 +35,8 @@ #include #include "sdio_host.h" +#define DCMD_RESP_TIMEOUT 2000 /* In milli second */ + #ifdef BCMDBG #define BRCMF_TRAP_INFO_SIZE 80 @@ -641,7 +643,7 @@ struct brcmf_bus { spinlock_t txqlock; wait_queue_head_t ctrl_wait; - wait_queue_head_t ioctl_resp_wait; + wait_queue_head_t dcmd_resp_wait; struct timer_list timer; struct completion watchdog_wait; @@ -1616,14 +1618,14 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) return num; } -static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, +static int brcmf_sdbrcm_dcmd_resp_wait(struct brcmf_bus *bus, uint *condition, bool *pending) { DECLARE_WAITQUEUE(wait, current); - int timeout = msecs_to_jiffies(IOCTL_RESP_TIMEOUT); + int timeout = msecs_to_jiffies(DCMD_RESP_TIMEOUT); /* Wait until control frame is available */ - add_wait_queue(&bus->ioctl_resp_wait, &wait); + add_wait_queue(&bus->dcmd_resp_wait, &wait); set_current_state(TASK_INTERRUPTIBLE); while (!(*condition) && (!signal_pending(current) && timeout)) @@ -1633,15 +1635,15 @@ static int brcmf_sdbrcm_ioctl_resp_wait(struct brcmf_bus *bus, uint *condition, *pending = true; set_current_state(TASK_RUNNING); - remove_wait_queue(&bus->ioctl_resp_wait, &wait); + remove_wait_queue(&bus->dcmd_resp_wait, &wait); return timeout; } -static int brcmf_sdbrcm_ioctl_resp_wake(struct brcmf_bus *bus) +static int brcmf_sdbrcm_dcmd_resp_wake(struct brcmf_bus *bus) { - if (waitqueue_active(&bus->ioctl_resp_wait)) - wake_up_interruptible(&bus->ioctl_resp_wait); + if (waitqueue_active(&bus->dcmd_resp_wait)) + wake_up_interruptible(&bus->dcmd_resp_wait); return 0; } @@ -1732,7 +1734,7 @@ gotpkt: done: /* Awake any waiters */ - brcmf_sdbrcm_ioctl_resp_wake(bus); + brcmf_sdbrcm_dcmd_resp_wake(bus); } /* Pad read to blocksize for efficiency */ @@ -3106,7 +3108,7 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) brcmf_dbg(TRACE, "Enter\n"); /* Wait until control frame is available */ - timeleft = brcmf_sdbrcm_ioctl_resp_wait(bus, &bus->rxlen, &pending); + timeleft = brcmf_sdbrcm_dcmd_resp_wait(bus, &bus->rxlen, &pending); down(&bus->sdsem); rxlen = bus->rxlen; @@ -3714,7 +3716,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) /* Clear rx control and wake any waiters */ bus->rxlen = 0; - brcmf_sdbrcm_ioctl_resp_wake(bus); + brcmf_sdbrcm_dcmd_resp_wake(bus); /* Reset some F2 state stuff */ bus->rxskip = false; @@ -4508,7 +4510,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, spin_lock_init(&bus->txqlock); init_waitqueue_head(&bus->ctrl_wait); - init_waitqueue_head(&bus->ioctl_resp_wait); + init_waitqueue_head(&bus->dcmd_resp_wait); /* Set up the watchdog timer */ init_timer(&bus->timer); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index b956c9060a4..42e7642126f 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* Toplevel file. Relies on dhd_linux.c to send ioctls to the dongle. */ +/* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */ #include #include @@ -251,12 +251,12 @@ static const u32 __wl_cipher_suites[] = { /* function for reading/writing a single u32 from/to the dongle */ static int -brcmf_dev_ioctl_u32(struct net_device *ndev, u32 cmd, u32 *par) +brcmf_exec_dcmd_u32(struct net_device *ndev, u32 cmd, u32 *par) { int err; __le32 par_le = cpu_to_le32(*par); - err = brcmf_dev_ioctl(ndev, cmd, &par_le, sizeof(__le32)); + err = brcmf_exec_dcmd(ndev, cmd, &par_le, sizeof(__le32)); *par = le32_to_cpu(par_le); return err; @@ -283,7 +283,7 @@ static int send_key_to_dongle(struct net_device *ndev, struct brcmf_wsec_key_le key_le; convert_key_from_CPU(key, &key_le); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); if (err) WL_ERR("WLC_SET_KEY error (%d)\n", err); return err; @@ -322,7 +322,7 @@ brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, goto done; } - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_INFRA, &infra); if (err) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); err = -EAGAIN; @@ -342,7 +342,7 @@ done: static s32 brcmf_dev_intvar_set(struct net_device *ndev, s8 *name, s32 val) { - s8 buf[BRCMF_C_IOCTL_SMLEN]; + s8 buf[BRCMF_C_DCMD_SMLEN]; u32 len; s32 err = 0; __le32 val_le; @@ -352,7 +352,7 @@ static s32 brcmf_dev_intvar_set(struct net_device *ndev, s8 *name, s32 val) sizeof(buf)); BUG_ON(!len); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, buf, len); + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, buf, len); if (err) WL_ERR("error (%d)\n", err); @@ -363,7 +363,7 @@ static s32 brcmf_dev_intvar_get(struct net_device *ndev, s8 *name, s32 *retval) { union { - s8 buf[BRCMF_C_IOCTL_SMLEN]; + s8 buf[BRCMF_C_DCMD_SMLEN]; __le32 val; } var; u32 len; @@ -374,7 +374,7 @@ brcmf_dev_intvar_get(struct net_device *ndev, s8 *name, s32 *retval) brcmu_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf)); BUG_ON(!len); - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, &var, len); + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, &var, len); if (err) WL_ERR("error (%d)\n", err); @@ -422,7 +422,7 @@ brcmf_dev_iovar_setbuf(struct net_device *ndev, s8 * iovar, void *param, iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); BUG_ON(!iolen); - return brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, bufptr, iolen); + return brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, bufptr, iolen); } static s32 @@ -434,7 +434,7 @@ brcmf_dev_iovar_getbuf(struct net_device *ndev, s8 * iovar, void *param, iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); BUG_ON(!iolen); - return brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, bufptr, buflen); + return brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, bufptr, buflen); } static s32 @@ -451,7 +451,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, params = kzalloc(params_size, GFP_KERNEL); if (!params) return -ENOMEM; - BUG_ON(params_size >= BRCMF_C_IOCTL_SMLEN); + BUG_ON(params_size >= BRCMF_C_DCMD_SMLEN); wl_iscan_prep(¶ms->params_le, ssid); @@ -460,7 +460,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, params->scan_duration = cpu_to_le16(0); err = brcmf_dev_iovar_setbuf(iscan->ndev, "iscan", params, params_size, - iscan->ioctl_buf, BRCMF_C_IOCTL_SMLEN); + iscan->dcmd_buf, BRCMF_C_DCMD_SMLEN); if (err) { if (err == -EBUSY) WL_INFO("system busy : iscan canceled\n"); @@ -486,7 +486,7 @@ static s32 brcmf_do_iscan(struct brcmf_cfg80211_priv *cfg_priv) iscan->state = WL_ISCAN_STATE_SCANING; passive_scan = cfg_priv->active_scan ? 0 : 1; - err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_SET_PASSIVE_SCAN, + err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCMF_C_SET_PASSIVE_SCAN, &passive_scan, sizeof(passive_scan)); if (err) { WL_ERR("error (%d)\n", err); @@ -570,14 +570,14 @@ __brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, } passive_scan = cfg_priv->active_scan ? 0 : 1; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_PASSIVE_SCAN, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_PASSIVE_SCAN, &passive_scan, sizeof(passive_scan)); if (err) { WL_ERR("WLC_SET_PASSIVE_SCAN error (%d)\n", err); goto scan_out; } brcmf_set_mpc(ndev, 0); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN, &sr->ssid_le, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SCAN, &sr->ssid_le, sizeof(sr->ssid_le)); if (err) { if (err == -EBUSY) @@ -645,7 +645,7 @@ static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l) s32 err = 0; u32 cmd = (l ? BRCM_SET_LRL : BRCM_SET_SRL); - err = brcmf_dev_ioctl_u32(ndev, cmd, &retry); + err = brcmf_exec_dcmd_u32(ndev, cmd, &retry); if (err) { WL_ERR("cmd (%d) , error (%d)\n", cmd, err); return err; @@ -794,7 +794,7 @@ static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) if (cfg_priv->link_up) { ndev = cfg_to_ndev(cfg_priv); WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); - err = brcmf_dev_ioctl(ndev, BRCMF_C_DISASSOC, NULL, 0); + err = brcmf_exec_dcmd(ndev, BRCMF_C_DISASSOC, NULL, 0); if (err) WL_ERR("WLC_DISASSOC failed (%d)\n", err); cfg_priv->link_up = false; @@ -880,7 +880,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, else bcnprd = 100; - err = brcmf_dev_ioctl_u32(ndev, BRCM_SET_BCNPRD, &bcnprd); + err = brcmf_exec_dcmd_u32(ndev, BRCM_SET_BCNPRD, &bcnprd); if (err) { WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err); goto done; @@ -924,7 +924,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, /* set channel for starter */ target_channel = cfg_priv->channel; - err = brcmf_dev_ioctl_u32(ndev, BRCM_SET_CHANNEL, + err = brcmf_exec_dcmd_u32(ndev, BRCM_SET_CHANNEL, &target_channel); if (err) { WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err); @@ -936,7 +936,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, cfg_priv->ibss_starter = false; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SSID, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SSID, &join_params, join_params_size); if (err) { WL_ERR("WLC_SET_SSID failed (%d)\n", err); @@ -1296,7 +1296,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, brcmf_ch_to_chanspec(cfg_priv->channel, &join_params, &join_params_size); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SSID, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SSID, &join_params, join_params_size); if (err) WL_ERR("WLC_SET_SSID failed (%d)\n", err); @@ -1324,7 +1324,7 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev, memcpy(&scbval.ea, brcmf_read_prof(cfg_priv, WL_PROF_BSSID), ETH_ALEN); scbval.val = cpu_to_le32(reason_code); - err = brcmf_dev_ioctl(ndev, BRCMF_C_DISASSOC, &scbval, + err = brcmf_exec_dcmd(ndev, BRCMF_C_DISASSOC, &scbval, sizeof(struct brcmf_scb_val_le)); if (err) WL_ERR("error (%d)\n", err); @@ -1370,7 +1370,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, } /* Make sure radio is off or on as far as software is concerned */ disable = WL_RADIO_SW_DISABLE << 16; - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_RADIO, &disable); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_RADIO, &disable); if (err) WL_ERR("WLC_SET_RADIO error (%d)\n", err); @@ -1428,7 +1428,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev, if (!check_sys_up(wiphy)) return -EIO; - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_WSEC, &wsec); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_WSEC, &wsec); if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); goto done; @@ -1437,7 +1437,7 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev, if (wsec & WEP_ENABLED) { /* Just select a new current key */ index = key_idx; - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_KEY_PRIMARY, + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_KEY_PRIMARY, &index); if (err) WL_ERR("error (%d)\n", err); @@ -1523,7 +1523,7 @@ brcmf_add_keyext(struct wiphy *wiphy, struct net_device *ndev, convert_key_from_CPU(&key, &key_le); brcmf_netdev_wait_pend8021x(ndev); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_KEY, &key_le, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); if (err) { WL_ERR("WLC_SET_KEY error (%d)\n", err); @@ -1615,7 +1615,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, } val = 1; /* assume shared key. otherwise 0 */ - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_AUTH, &val); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_AUTH, &val); if (err) WL_ERR("WLC_SET_AUTH error (%d)\n", err); done: @@ -1676,7 +1676,7 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, } val = 0; /* assume open key. otherwise 1 */ - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_AUTH, &val); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_AUTH, &val); if (err) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1705,7 +1705,7 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, memset(¶ms, 0, sizeof(params)); - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_WSEC, &wsec); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_WSEC, &wsec); if (err) { WL_ERR("WLC_GET_WSEC error (%d)\n", err); /* Ignore this error, may happen during DISASSOC */ @@ -1778,7 +1778,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, } /* Report the current tx rate */ - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_GET_RATE, &rate); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_RATE, &rate); if (err) { WL_ERR("Could not get rate (%d)\n", err); } else { @@ -1789,7 +1789,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { scb_val.val = cpu_to_le32(0); - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_RSSI, &scb_val, + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_RSSI, &scb_val, sizeof(struct brcmf_scb_val_le)); if (err) WL_ERR("Could not get rssi (%d)\n", err); @@ -1833,7 +1833,7 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, pm = enabled ? PM_FAST : PM_OFF; WL_INFO("power save %s\n", (pm ? "enabled" : "disabled")); - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_PM, &pm); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_PM, &pm); if (err) { if (err == -ENODEV) WL_ERR("net_device is not ready yet\n"); @@ -1864,7 +1864,7 @@ brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *ndev, /* addr param is always NULL. ignore it */ /* Get current rateset */ - err = brcmf_dev_ioctl(ndev, BRCM_GET_CURR_RATESET, &rateset_le, + err = brcmf_exec_dcmd(ndev, BRCM_GET_CURR_RATESET, &rateset_le, sizeof(rateset_le)); if (err) { WL_ERR("could not get current rateset (%d)\n", err); @@ -2016,7 +2016,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); if (err) { WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); goto CleanUp; @@ -2084,7 +2084,7 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) ssid = (struct brcmf_ssid *)brcmf_read_prof(cfg_priv, WL_PROF_SSID); *(__le32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); - err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, + err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); if (err) { WL_ERR("Could not get bss info %d\n", err); @@ -2444,11 +2444,11 @@ brcmf_dev_bufvar_set(struct net_device *ndev, s8 *name, s8 *buf, s32 len) struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); u32 buflen; - buflen = brcmu_mkiovar(name, buf, len, cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); + buflen = brcmu_mkiovar(name, buf, len, cfg_priv->dcmd_buf, + WL_DCMD_LEN_MAX); BUG_ON(!buflen); - return brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, cfg_priv->ioctl_buf, + return brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, cfg_priv->dcmd_buf, buflen); } @@ -2460,16 +2460,16 @@ brcmf_dev_bufvar_get(struct net_device *ndev, s8 *name, s8 *buf, u32 len; s32 err = 0; - len = brcmu_mkiovar(name, NULL, 0, cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); + len = brcmu_mkiovar(name, NULL, 0, cfg_priv->dcmd_buf, + WL_DCMD_LEN_MAX); BUG_ON(!len); - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, cfg_priv->ioctl_buf, - WL_IOCTL_LEN_MAX); + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, cfg_priv->dcmd_buf, + WL_DCMD_LEN_MAX); if (err) { WL_ERR("error (%d)\n", err); return err; } - memcpy(buf, cfg_priv->ioctl_buf, buf_len); + memcpy(buf, cfg_priv->dcmd_buf, buf_len); return err; } @@ -2846,7 +2846,7 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, brcmf_update_prof(cfg_priv, NULL, &e->addr, WL_PROF_BSSID); brcmf_update_bss_info(cfg_priv); - brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_le, + brcmf_exec_dcmd(ndev, BRCMF_C_GET_CHANNEL, &channel_le, sizeof(channel_le)); target_channel = le32_to_cpu(channel_le.target_channel); @@ -3018,7 +3018,7 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, goto scan_done_out; } - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_CHANNEL, &channel_inform_le, + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_CHANNEL, &channel_inform_le, sizeof(channel_inform_le)); if (err) { WL_ERR("scan busy (%d)\n", err); @@ -3033,7 +3033,7 @@ brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, memset(cfg_priv->scan_results, 0, len); bss_list_le->buflen = cpu_to_le32(len); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SCAN_RESULTS, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SCAN_RESULTS, cfg_priv->scan_results, len); if (err) { WL_ERR("%s Scan_results error (%d)\n", ndev->name, err); @@ -3096,8 +3096,8 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) cfg_priv->profile = NULL; kfree(cfg_priv->scan_req_int); cfg_priv->scan_req_int = NULL; - kfree(cfg_priv->ioctl_buf); - cfg_priv->ioctl_buf = NULL; + kfree(cfg_priv->dcmd_buf); + cfg_priv->dcmd_buf = NULL; kfree(cfg_priv->extra_buf); cfg_priv->extra_buf = NULL; kfree(cfg_priv->iscan); @@ -3124,8 +3124,8 @@ static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) GFP_KERNEL); if (!cfg_priv->scan_req_int) goto init_priv_mem_out; - cfg_priv->ioctl_buf = kzalloc(WL_IOCTL_LEN_MAX, GFP_KERNEL); - if (!cfg_priv->ioctl_buf) + cfg_priv->dcmd_buf = kzalloc(WL_DCMD_LEN_MAX, GFP_KERNEL); + if (!cfg_priv->dcmd_buf) goto init_priv_mem_out; cfg_priv->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); if (!cfg_priv->extra_buf) @@ -3377,7 +3377,7 @@ static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) WL_ERR("invalid type (%d)\n", iftype); return err; } - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_INFRA, &infra); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_INFRA, &infra); if (err) { WL_ERR("WLC_SET_INFRA error (%d)\n", err); return err; @@ -3398,7 +3398,7 @@ static s32 brcmf_dongle_eventmsg(struct net_device *ndev) /* Setup event_msgs */ brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); - err = brcmf_dev_ioctl(ndev, BRCMF_C_GET_VAR, iovbuf, sizeof(iovbuf)); + err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, iovbuf, sizeof(iovbuf)); if (err) { WL_ERR("Get event_msgs error (%d)\n", err); goto dongle_eventmsg_out; @@ -3427,7 +3427,7 @@ static s32 brcmf_dongle_eventmsg(struct net_device *ndev) brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); if (err) { WL_ERR("Set event_msgs error (%d)\n", err); goto dongle_eventmsg_out; @@ -3453,7 +3453,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) if (roamvar) { brcmu_mkiovar("bcn_timeout", (char *)&bcn_timeout, sizeof(bcn_timeout), iovbuf, sizeof(iovbuf)); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); if (err) { WL_ERR("bcn_timeout error (%d)\n", err); @@ -3468,7 +3468,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) WL_INFO("Internal Roaming = %s\n", roamvar ? "Off" : "On"); brcmu_mkiovar("roam_off", (char *)&roamvar, sizeof(roamvar), iovbuf, sizeof(iovbuf)); - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); if (err) { WL_ERR("roam_off error (%d)\n", err); goto dongle_rom_out; @@ -3476,7 +3476,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) roamtrigger[0] = WL_ROAM_TRIGGER_LEVEL; roamtrigger[1] = BRCM_BAND_ALL; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_ROAM_TRIGGER, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_ROAM_TRIGGER, (void *)roamtrigger, sizeof(roamtrigger)); if (err) { WL_ERR("WLC_SET_ROAM_TRIGGER error (%d)\n", err); @@ -3485,7 +3485,7 @@ brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) roam_delta[0] = WL_ROAM_DELTA; roam_delta[1] = BRCM_BAND_ALL; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_ROAM_DELTA, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_ROAM_DELTA, (void *)roam_delta, sizeof(roam_delta)); if (err) { WL_ERR("WLC_SET_ROAM_DELTA error (%d)\n", err); @@ -3502,7 +3502,7 @@ brcmf_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time, { s32 err = 0; - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SCAN_CHANNEL_TIME, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_CHANNEL_TIME, &scan_assoc_time, sizeof(scan_assoc_time)); if (err) { if (err == -EOPNOTSUPP) @@ -3511,7 +3511,7 @@ brcmf_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time, WL_ERR("Scan assoc time error (%d)\n", err); goto dongle_scantime_out; } - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SCAN_UNASSOC_TIME, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_UNASSOC_TIME, &scan_unassoc_time, sizeof(scan_unassoc_time)); if (err) { if (err == -EOPNOTSUPP) @@ -3521,7 +3521,7 @@ brcmf_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time, goto dongle_scantime_out; } - err = brcmf_dev_ioctl(ndev, BRCMF_C_SET_SCAN_PASSIVE_TIME, + err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_PASSIVE_TIME, &scan_passive_time, sizeof(scan_passive_time)); if (err) { if (err == -EOPNOTSUPP) @@ -3542,7 +3542,7 @@ static s32 wl_update_wiphybands(struct brcmf_cfg80211_priv *cfg_priv) s8 phy; s32 err = 0; - err = brcmf_dev_ioctl(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, + err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, &phy_list, sizeof(phy_list)); if (err) { WL_ERR("error (%d)\n", err); @@ -3588,7 +3588,7 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, goto default_conf_out; power_mode = cfg_priv->pwr_save ? PM_FAST : PM_OFF; - err = brcmf_dev_ioctl_u32(ndev, BRCMF_C_SET_PM, &power_mode); + err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_PM, &power_mode); if (err) goto default_conf_out; WL_INFO("power save set to %s\n", diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index afc60d9c967..21c8f8e636c 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -103,10 +103,10 @@ do { \ * report it to cfg80211 through "connect" * event */ -#define WL_IOCTL_LEN_MAX 1024 +#define WL_DCMD_LEN_MAX 1024 #define WL_EXTRA_BUF_MAX 2048 #define WL_ISCAN_BUF_MAX 2048 /* - * the buf length can be BRCMF_C_IOCTL_MAXLEN + * the buf length can be BRCMF_C_DCMD_MAXLEN * to reduce iteration */ #define WL_ISCAN_TIMER_INTERVAL_MS 3000 @@ -251,7 +251,7 @@ struct brcmf_cfg80211_iscan_ctrl { struct work_struct work; struct brcmf_cfg80211_iscan_eloop el; void *data; - s8 ioctl_buf[BRCMF_C_IOCTL_SMLEN]; + s8 dcmd_buf[BRCMF_C_DCMD_SMLEN]; s8 scan_buf[WL_ISCAN_BUF_MAX]; }; @@ -312,8 +312,8 @@ struct brcmf_cfg80211_priv { bool dongle_up; /* indicate whether dongle up or not */ bool roam_on; /* on/off switch for dongle self-roaming */ bool scan_tried; /* indicates if first scan attempted */ - u8 *ioctl_buf; /* ioctl buffer */ - u8 *extra_buf; /* maily to grab assoc information */ + u8 *dcmd_buf; /* dcmd buffer */ + u8 *extra_buf; /* maily to grab assoc information */ struct dentry *debugfsdir; u8 ci[0] __aligned(NETDEV_ALIGN); }; From 44a94f62f1e3a2024b43de7705cd990359fcbafa Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:44 -0700 Subject: [PATCH 1274/1519] staging: brcm80211: cleaned up buffer len defines in fullmac Code cleanup. Replaced identical definition BRCMF_C_DCMD_MAXLEN by BRCMF_DCMD_MAXLEN. Renamed related buffer len definitions. Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd.h | 6 ++---- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 6 +++--- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 8 ++++---- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 501faed8705..3ec74778b2e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -23,10 +23,6 @@ #define BRCMF_VERSION_STR "4.218.248.5" -#define BRCMF_C_DCMD_SMLEN 256 /* "small" cmd buffer required */ -#define BRCMF_C_DCMD_MEDLEN 1536 /* "med" cmd buffer required */ -#define BRCMF_C_DCMD_MAXLEN 8192 - /******************************************************************************* * IO codes that are interpreted by dongle firmware ******************************************************************************/ @@ -749,6 +745,8 @@ extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg); extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, int master_mode); +#define BRCMF_DCMD_SMLEN 256 /* "small" cmd buffer required */ +#define BRCMF_DCMD_MEDLEN 1536 /* "med" cmd buffer required */ #define BRCMF_DCMD_MAXLEN 8192 /* max length cmd buffer required */ /* message levels */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index ec0a0574566..e34c5c3d1d5 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -97,7 +97,7 @@ struct brcmf_proto { u32 lastcmd; u8 bus_header[BUS_HEADER_LEN]; struct brcmf_proto_cdc_dcmd msg; - unsigned char buf[BRCMF_C_DCMD_MAXLEN + ROUND_UP_MARGIN]; + unsigned char buf[BRCMF_DCMD_MAXLEN + ROUND_UP_MARGIN]; }; static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr) @@ -288,7 +288,7 @@ brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd, brcmf_dbg(TRACE, "Enter\n"); - if (len > BRCMF_C_DCMD_MAXLEN) + if (len > BRCMF_DCMD_MAXLEN) goto done; if (prot->pending == true) { @@ -435,7 +435,7 @@ int brcmf_proto_attach(struct brcmf_pub *drvr) drvr->prot = cdc; drvr->hdrlen += BDC_HEADER_LEN; - drvr->maxctl = BRCMF_C_DCMD_MAXLEN + + drvr->maxctl = BRCMF_DCMD_MAXLEN + sizeof(struct brcmf_proto_cdc_dcmd) + ROUND_UP_MARGIN; return 0; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 42e7642126f..d12aa75c46d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -342,7 +342,7 @@ done: static s32 brcmf_dev_intvar_set(struct net_device *ndev, s8 *name, s32 val) { - s8 buf[BRCMF_C_DCMD_SMLEN]; + s8 buf[BRCMF_DCMD_SMLEN]; u32 len; s32 err = 0; __le32 val_le; @@ -363,7 +363,7 @@ static s32 brcmf_dev_intvar_get(struct net_device *ndev, s8 *name, s32 *retval) { union { - s8 buf[BRCMF_C_DCMD_SMLEN]; + s8 buf[BRCMF_DCMD_SMLEN]; __le32 val; } var; u32 len; @@ -451,7 +451,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, params = kzalloc(params_size, GFP_KERNEL); if (!params) return -ENOMEM; - BUG_ON(params_size >= BRCMF_C_DCMD_SMLEN); + BUG_ON(params_size >= BRCMF_DCMD_SMLEN); wl_iscan_prep(¶ms->params_le, ssid); @@ -460,7 +460,7 @@ brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, params->scan_duration = cpu_to_le16(0); err = brcmf_dev_iovar_setbuf(iscan->ndev, "iscan", params, params_size, - iscan->dcmd_buf, BRCMF_C_DCMD_SMLEN); + iscan->dcmd_buf, BRCMF_DCMD_SMLEN); if (err) { if (err == -EBUSY) WL_INFO("system busy : iscan canceled\n"); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 21c8f8e636c..e69f4f6bf94 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -106,7 +106,7 @@ do { \ #define WL_DCMD_LEN_MAX 1024 #define WL_EXTRA_BUF_MAX 2048 #define WL_ISCAN_BUF_MAX 2048 /* - * the buf length can be BRCMF_C_DCMD_MAXLEN + * the buf length can be BRCMF_DCMD_MAXLEN * to reduce iteration */ #define WL_ISCAN_TIMER_INTERVAL_MS 3000 @@ -251,7 +251,7 @@ struct brcmf_cfg80211_iscan_ctrl { struct work_struct work; struct brcmf_cfg80211_iscan_eloop el; void *data; - s8 dcmd_buf[BRCMF_C_DCMD_SMLEN]; + s8 dcmd_buf[BRCMF_DCMD_SMLEN]; s8 scan_buf[WL_ISCAN_BUF_MAX]; }; From 358830e372001fb0b89e3a4b889137247bd62bc9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Sun, 2 Oct 2011 10:14:45 -0700 Subject: [PATCH 1275/1519] staging: brcm80211: removed functionality to disable N mode NVRAM contains a parameter that can disable N mode. This functionality is not needed. As a consequence, brcms_c_protection_upd() could be simplified. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/channel.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.c | 85 +++++--------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 +- 3 files changed, 24 insertions(+), 65 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 7fe005aabd8..2127c2791a3 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1004,7 +1004,7 @@ brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, if ((wlc->pub->_n_enab & SUPPORT_11N) != wlc->protection->nmode_user) - brcms_c_set_nmode(wlc, wlc->protection->nmode_user); + brcms_c_set_nmode(wlc); brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index e4dd2d486dc..de5f5c03499 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5202,7 +5202,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, uint err = 0; uint i, j; struct brcms_pub *pub; - uint n_disabled; /* allocate struct brcms_c_info state and its substructures */ wlc = (struct brcms_c_info *) brcms_c_attach_malloc(unit, &err, device); @@ -5228,9 +5227,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, /* update sta/ap related parameters */ brcms_c_ap_upd(wlc); - /* 11n_disable nvram */ - n_disabled = getintvar(pub->vars, "11n_disable"); - /* * low level attach steps(all hw accesses go * inside, no more in rest of the attach) @@ -5301,17 +5297,11 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, /* init _n_enab supported mode */ if (BRCMS_PHY_11N_CAP(wlc->band)) { - if (n_disabled & WLFEATURE_DISABLE_11N) { - pub->_n_enab = OFF; - brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, - OFF); - } else { - pub->_n_enab = SUPPORT_11N; - brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, + pub->_n_enab = SUPPORT_11N; + brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, ((pub->_n_enab == SUPPORT_11N) ? WL_11N_2x2 : WL_11N_3x3)); - } } /* init per-band default rateset, depend on band->gmode */ @@ -5387,19 +5377,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, brcms_c_ht_update_sgi_rx(wlc, 0); } - /* *******nvram 11n config overrides Start ********* */ - - if (n_disabled & WLFEATURE_DISABLE_11N_SGI_RX) - brcms_c_ht_update_sgi_rx(wlc, 0); - - /* apply the stbc override from nvram conf */ - if (n_disabled & WLFEATURE_DISABLE_11N_STBC_TX) { - wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF; - wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF; - } - if (n_disabled & WLFEATURE_DISABLE_11N_STBC_RX) - brcms_c_stf_stbc_rx_set(wlc, HT_CAP_RX_STBC_NO); - /* initialize radio_mpc_disable according to wlc->mpc */ brcms_c_radio_mpc_upd(wlc); brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); @@ -6109,54 +6086,36 @@ static int brcms_c_nmode_validate(struct brcms_c_info *wlc, s32 nmode) return err; } -int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode) +int brcms_c_set_nmode(struct brcms_c_info *wlc) { uint i; int err; + s32 nmode = AUTO; err = brcms_c_nmode_validate(wlc, nmode); if (err) return err; - switch (nmode) { - case OFF: - wlc->pub->_n_enab = OFF; - wlc->default_bss->flags &= ~BRCMS_BSS_HT; - /* delete the mcs rates from the default and hw ratesets */ - brcms_c_rateset_mcs_clear(&wlc->default_bss->rateset); - for (i = 0; i < wlc->pub->_nbands; i++) { - memset(wlc->bandstate[i]->hw_rateset.mcs, 0, - MCSSET_LEN); - } - break; + if (wlc->stf->txstreams == WL_11N_3x3) + nmode = WL_11N_3x3; + else + nmode = WL_11N_2x2; - case AUTO: - if (wlc->stf->txstreams == WL_11N_3x3) - nmode = WL_11N_3x3; - else - nmode = WL_11N_2x2; - case WL_11N_2x2: - case WL_11N_3x3: - /* force GMODE_AUTO if NMODE is ON */ - brcms_c_set_gmode(wlc, GMODE_AUTO, true); - if (nmode == WL_11N_3x3) - wlc->pub->_n_enab = SUPPORT_HT; - else - wlc->pub->_n_enab = SUPPORT_11N; - wlc->default_bss->flags |= BRCMS_BSS_HT; - /* add the mcs rates to the default and hw ratesets */ - brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, - wlc->stf->txstreams); - for (i = 0; i < wlc->pub->_nbands; i++) - memcpy(wlc->bandstate[i]->hw_rateset.mcs, - wlc->default_bss->rateset.mcs, MCSSET_LEN); - break; + /* force GMODE_AUTO if NMODE is ON */ + brcms_c_set_gmode(wlc, GMODE_AUTO, true); + if (nmode == WL_11N_3x3) + wlc->pub->_n_enab = SUPPORT_HT; + else + wlc->pub->_n_enab = SUPPORT_11N; + wlc->default_bss->flags |= BRCMS_BSS_HT; + /* add the mcs rates to the default and hw ratesets */ + brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, + wlc->stf->txstreams); + for (i = 0; i < wlc->pub->_nbands; i++) + memcpy(wlc->bandstate[i]->hw_rateset.mcs, + wlc->default_bss->rateset.mcs, MCSSET_LEN); - default: - break; - } - - return err; + return 0; } static int diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 8815042e448..e4589167f6d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -799,7 +799,7 @@ extern void brcms_c_set_chanspec(struct brcms_c_info *wlc, extern bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit); -extern int brcms_c_set_nmode(struct brcms_c_info *wlc, s32 nmode); +extern int brcms_c_set_nmode(struct brcms_c_info *wlc); extern void brcms_c_mimops_action_ht_send(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, u8 mimops_mode); From 6a37b041d210c259482cdeb0000aa66e5fa2477d Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 4 Oct 2011 18:21:11 +1100 Subject: [PATCH 1276/1519] staging: iio: adc: add includes of module.h and stat.h fixes these build problems: drivers/staging/iio/adc/ad7746.c:345:8: error: 'S_IWUSR' undeclared here (not in a function) drivers/staging/iio/adc/ad7746.c:436:8: error: 'S_IRUGO' undeclared here (not in a function) drivers/staging/iio/adc/ad7746.c:681:19: error: 'THIS_MODULE' undeclared here (not in a function) drivers/staging/iio/adc/ad7746.c:778:1: warning: data definition has no type or storage class [enabled by default] drivers/staging/iio/adc/ad7746.c:778:1: warning: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' [-Wimplicit-int] drivers/staging/iio/adc/ad7746.c:778:1: warning: parameter names (without types) in function declaration [enabled by default] drivers/staging/iio/adc/ad7746.c:799:15: error: expected declaration specifiers or '...' before string constant drivers/staging/iio/adc/ad7746.c:800:20: error: expected declaration specifiers or '...' before string constant drivers/staging/iio/adc/ad7746.c:801:16: error: expected declaration specifiers or '...' before string constant Signed-off-by: Stephen Rothwell Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7746.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/adc/ad7746.c b/drivers/staging/iio/adc/ad7746.c index 0b251ad1780..3fe0c1715dc 100644 --- a/drivers/staging/iio/adc/ad7746.c +++ b/drivers/staging/iio/adc/ad7746.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "../iio.h" #include "../sysfs.h" From 81e07c06e62a48ec36a65728a0c3c3cafdfaee17 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 4 Oct 2011 18:32:57 +1100 Subject: [PATCH 1277/1519] staging: r8712u: include module.h where needed Signed-off-by: Stephen Rothwell Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 1 + drivers/staging/rtl8712/usb_intf.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 1bd9c374a5f..d0029aa4cd3 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "osdep_service.h" #include "drv_types.h" diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 0a2f2743165..fb2e89c3056 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -29,6 +29,7 @@ #define _HCI_INTF_C_ #include +#include #include "osdep_service.h" #include "drv_types.h" From 9d5d11539afba275ff2fec16a180e14b66cb4f1b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 4 Oct 2011 16:02:08 +0100 Subject: [PATCH 1278/1519] staging: iio: if(__LITTLE_ENDIAN) -> #ifdef __LITTLE_ENDIAN Unsuprisingly this symbol isn't defined on big endian systems. Signed-off-by: Jonathan Cameron Reported-by: Stephen Rothwell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index 4ce101af9a9..60929ff633e 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -104,10 +104,11 @@ static ssize_t iio_show_fixed_type(struct device *dev, u8 type = this_attr->c->scan_type.endianness; if (type == IIO_CPU) { - if (__LITTLE_ENDIAN) - type = IIO_LE; - else - type = IIO_BE; +#ifdef __LITTLE_ENDIAN + type = IIO_LE; +#else + type = IIO_BE; +#endif } return sprintf(buf, "%s:%c%d/%d>>%u\n", iio_endian_prefix[type], From 870e53adbd372cbeea15ed00e1d4423725f3cea0 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:41 -0700 Subject: [PATCH 1279/1519] Staging: hv: mousevsc: Fixup struct hv_input_dev_info This structure is protocol defined structure and must match the definition on the host side. Make appropriate adjustments. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index fcb023af4b3..44a2b23cc53 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -30,10 +30,11 @@ * Data types */ struct hv_input_dev_info { + unsigned int size; unsigned short vendor; unsigned short product; unsigned short version; - char name[128]; + unsigned short reserved[11]; }; /* The maximum size of a synthetic input message. */ @@ -686,7 +687,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) hid_dev->dev = dev->device; sprintf(hid_dev->name, "%s", - input_device_ctx->device_info.name); + "Microsoft Vmbus HID-compliant Mouse"); /* * HJ Do we want to call it with a 0 @@ -763,7 +764,6 @@ static int mousevsc_on_device_add(struct hv_device *device, dev_info.vendor = input_dev->hid_dev_info.vendor; dev_info.product = input_dev->hid_dev_info.product; dev_info.version = input_dev->hid_dev_info.version; - strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse"); /* Send the device info back up */ input_device_ctx = dev_get_drvdata(&device->device); From 28e0d06655ddc6598155e2f71945f1abb00b398a Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:42 -0700 Subject: [PATCH 1280/1519] Staging: hv: mousevsc: Get rid of the struct input_device_context The state maintained in struct input_device_context can easily be included in the struct mousevsc_dev structure. Simplify the code by consolidating the state. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 51 +++++++++-------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 44a2b23cc53..69eb00e45f8 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -172,14 +172,10 @@ struct mousevsc_dev { unsigned char *report_desc; u32 report_desc_size; struct hv_input_dev_info hid_dev_info; + int connected; + struct hid_device *hid_device; }; -struct input_device_context { - struct hv_device *device_ctx; - struct hid_device *hid_device; - struct hv_input_dev_info device_info; - int connected; -}; static struct mousevsc_dev *alloc_input_device(struct hv_device *device) { @@ -402,7 +398,6 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, struct synthhid_input_report *input_report) { struct hv_driver *input_drv; - struct input_device_context *input_dev_ctx; if (!input_device->init_complete) { pr_info("Initialization incomplete...ignoring input_report msg"); @@ -411,9 +406,8 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, input_drv = drv_to_hv_drv(input_device->device->device.driver); - input_dev_ctx = dev_get_drvdata(&input_device->device->device); - hid_input_report(input_dev_ctx->hid_device, + hid_input_report(input_device->hid_device, HID_INPUT_REPORT, input_report->buffer, input_report->header.size, 1); } @@ -662,9 +656,8 @@ static void mousevsc_hid_close(struct hid_device *hid) static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) { - struct input_device_context *input_device_ctx = - dev_get_drvdata(&dev->device); struct hid_device *hid_dev; + struct mousevsc_dev *input_device = hv_get_drvdata(dev); /* hid_debug = -1; */ hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL); @@ -681,9 +674,9 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) hid_dev->ll_driver->close = mousevsc_hid_close; hid_dev->bus = BUS_VIRTUAL; - hid_dev->vendor = input_device_ctx->device_info.vendor; - hid_dev->product = input_device_ctx->device_info.product; - hid_dev->version = input_device_ctx->device_info.version; + hid_dev->vendor = input_device->hid_dev_info.vendor; + hid_dev->product = input_device->hid_dev_info.product; + hid_dev->version = input_device->hid_dev_info.version; hid_dev->dev = dev->device; sprintf(hid_dev->name, "%s", @@ -695,7 +688,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) if (!hidinput_connect(hid_dev, 0)) { hid_dev->claimed |= HID_CLAIMED_INPUT; - input_device_ctx->connected = 1; + input_device->connected = 1; DPRINT_INFO(INPUTVSC_DRV, "HID device claimed by input\n"); @@ -707,7 +700,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) "input or hiddev\n"); } - input_device_ctx->hid_device = hid_dev; + input_device->hid_device = hid_dev; } kfree(hid_dev); @@ -719,8 +712,6 @@ static int mousevsc_on_device_add(struct hv_device *device, int ret = 0; struct mousevsc_dev *input_dev; struct hv_driver *input_drv; - struct hv_input_dev_info dev_info; - struct input_device_context *input_device_ctx; input_dev = alloc_input_device(device); @@ -761,14 +752,7 @@ static int mousevsc_on_device_add(struct hv_device *device, input_drv = drv_to_hv_drv(input_dev->device->device.driver); - dev_info.vendor = input_dev->hid_dev_info.vendor; - dev_info.product = input_dev->hid_dev_info.product; - dev_info.version = input_dev->hid_dev_info.version; - /* Send the device info back up */ - input_device_ctx = dev_get_drvdata(&device->device); - memcpy(&input_device_ctx->device_info, &dev_info, - sizeof(struct hv_input_dev_info)); /* Send the report desc back up */ /* workaround SA-167 */ @@ -828,12 +812,6 @@ static int mousevsc_probe(struct hv_device *dev, { int ret = 0; - struct input_device_context *input_dev_ctx; - - input_dev_ctx = kmalloc(sizeof(struct input_device_context), - GFP_KERNEL); - - dev_set_drvdata(&dev->device, input_dev_ctx); /* Call to the vsc driver to add the device */ ret = mousevsc_on_device_add(dev, NULL); @@ -849,13 +827,12 @@ static int mousevsc_probe(struct hv_device *dev, static int mousevsc_remove(struct hv_device *dev) { - struct input_device_context *input_dev_ctx; + struct mousevsc_dev *input_dev = hv_get_drvdata(dev); int ret; - input_dev_ctx = dev_get_drvdata(&dev->device); - if (input_dev_ctx->connected) { - hidinput_disconnect(input_dev_ctx->hid_device); - input_dev_ctx->connected = 0; + if (input_dev->connected) { + hidinput_disconnect(input_dev->hid_device); + input_dev->connected = 0; } /* @@ -868,8 +845,6 @@ static int mousevsc_remove(struct hv_device *dev) "unable to remove vsc device (ret %d)", ret); } - kfree(input_dev_ctx); - return ret; } From 7f2bad4bd0d22f4cdd876152f1eeb9a8cfdc8d9d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:43 -0700 Subject: [PATCH 1281/1519] Staging: hv: mousevsc: Fixup some bogus WARN_ON() calls Fix the bogus WARN_ON() calls. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 69eb00e45f8..016d7e570d1 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -200,7 +200,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) static void free_input_device(struct mousevsc_dev *device) { - WARN_ON(atomic_read(&device->ref_count) == 0); + WARN_ON(atomic_read(&device->ref_count) != 0); kfree(device); } @@ -327,7 +327,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, /* Save the hid desc */ desc = &device_info->hid_descriptor; - WARN_ON(desc->bLength > 0); + WARN_ON(desc->bLength == 0); input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL); @@ -447,7 +447,7 @@ static void mousevsc_on_receive(struct hv_device *device, break; case SynthHidInitialDeviceInfo: - WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info)); + WARN_ON(pipe_msg->size < sizeof(struct hv_input_dev_info)); /* * Parse out the device info into device attr, From 01584892dbf915a3921c5fc2607363e07023ef5c Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:44 -0700 Subject: [PATCH 1282/1519] Staging: hv: mousevsc: Change the allocation flags to reflect interrupt context Change the allocation flags to reflect interrupt context. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 016d7e570d1..b7cc16471ec 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -329,7 +329,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, desc = &device_info->hid_descriptor; WARN_ON(desc->bLength == 0); - input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL); + input_device->hid_desc = kzalloc(desc->bLength, GFP_ATOMIC); if (!input_device->hid_desc) { pr_err("unable to allocate hid descriptor - size %d", @@ -342,7 +342,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, /* Save the report desc */ input_device->report_desc_size = desc->desc[0].wDescriptorLength; input_device->report_desc = kzalloc(input_device->report_desc_size, - GFP_KERNEL); + GFP_ATOMIC); if (!input_device->report_desc) { pr_err("unable to allocate report descriptor - size %d", @@ -541,7 +541,7 @@ static void mousevsc_on_channel_callback(void *context) } else if (ret == -ENOBUFS) { /* Handle large packet */ bufferlen = bytes_recvd; - buffer = kzalloc(bytes_recvd, GFP_KERNEL); + buffer = kzalloc(bytes_recvd, GFP_ATOMIC); if (buffer == NULL) { buffer = packet; From 60e8615ad6e09f47b15c4d023f728c112b8f7294 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:45 -0700 Subject: [PATCH 1283/1519] Staging: hv: mousevsc: Handle the case where we may get bogus report desc size Handle the case where we may get bogus report desc size from the host. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index b7cc16471ec..19cfc231ab9 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -341,6 +341,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, /* Save the report desc */ input_device->report_desc_size = desc->desc[0].wDescriptorLength; + if (input_device->report_desc_size == 0) + goto cleanup; input_device->report_desc = kzalloc(input_device->report_desc_size, GFP_ATOMIC); From 1738067e5d7009c9ce9ee11c7fe9f9156b191aa9 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:46 -0700 Subject: [PATCH 1284/1519] Staging: hv: mousevsc: Correctly initialize the header size Correctly initialize the header size. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 19cfc231ab9..74faa267848 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -590,7 +590,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) request->size = sizeof(struct synthhid_protocol_request); request->request.header.type = SynthHidProtocolRequest; - request->request.header.size = sizeof(unsigned long); + request->request.header.size = sizeof(unsigned int); request->request.version_requested.version = SYNTHHID_INPUT_VERSION; pr_info("synthhid protocol request..."); From 622a50dce08bd817d2f10c1bcf806ccb35643653 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:47 -0700 Subject: [PATCH 1285/1519] Staging: hv: mousevsc: Use completion primitive to synchronize Use completion primitive to synchronize. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 74faa267848..ea9e1f30c14 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -162,10 +162,7 @@ struct mousevsc_dev { struct mousevsc_prt_msg protocol_req; struct mousevsc_prt_msg protocol_resp; /* Synchronize the request/response if needed */ - wait_queue_head_t protocol_wait_event; - wait_queue_head_t dev_info_wait_event; - int protocol_wait_condition; - int device_wait_condition; + struct completion wait_event; int dev_info_status; struct hid_descriptor *hid_desc; @@ -194,6 +191,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) input_dev->device = device; hv_set_drvdata(device, input_dev); + init_completion(&input_dev->wait_event); return input_dev; } @@ -379,8 +377,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, goto cleanup; } - input_device->device_wait_condition = 1; - wake_up(&input_device->dev_info_wait_event); + complete(&input_device->wait_event); return; @@ -392,8 +389,7 @@ cleanup: input_device->report_desc = NULL; input_device->dev_info_status = -1; - input_device->device_wait_condition = 1; - wake_up(&input_device->dev_info_wait_event); + complete(&input_device->wait_event); } static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, @@ -444,8 +440,7 @@ static void mousevsc_on_receive(struct hv_device *device, memcpy(&input_dev->protocol_resp, pipe_msg, pipe_msg->size + sizeof(struct pipe_prt_msg) - sizeof(unsigned char)); - input_dev->protocol_wait_condition = 1; - wake_up(&input_dev->protocol_wait_event); + complete(&input_dev->wait_event); break; case SynthHidInitialDeviceInfo: @@ -565,6 +560,7 @@ static void mousevsc_on_channel_callback(void *context) static int mousevsc_connect_to_vsp(struct hv_device *device) { int ret = 0; + int t; struct mousevsc_dev *input_dev; struct mousevsc_prt_msg *request; struct mousevsc_prt_msg *response; @@ -576,8 +572,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) return -1; } - init_waitqueue_head(&input_dev->protocol_wait_event); - init_waitqueue_head(&input_dev->dev_info_wait_event); request = &input_dev->protocol_req; @@ -607,10 +601,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) goto cleanup; } - input_dev->protocol_wait_condition = 0; - wait_event_timeout(input_dev->protocol_wait_event, - input_dev->protocol_wait_condition, msecs_to_jiffies(1000)); - if (input_dev->protocol_wait_condition == 0) { + t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } @@ -624,10 +616,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) goto cleanup; } - input_dev->device_wait_condition = 0; - wait_event_timeout(input_dev->dev_info_wait_event, - input_dev->device_wait_condition, msecs_to_jiffies(1000)); - if (input_dev->device_wait_condition == 0) { + t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } From da5969e4cce5cbb44ca4597c7ff60bf6517ba00b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:48 -0700 Subject: [PATCH 1286/1519] Staging: hv: mousevsc: Cleanup and properly implement reportdesc_callback() Cleanup and properly implement reportdesc_callback(); properly allocate the hid_device and properly initialize the hid device structure. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 56 ++++++++++++++--------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index ea9e1f30c14..8d94aef9010 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -646,56 +646,45 @@ static void mousevsc_hid_close(struct hid_device *hid) { } +static struct hid_ll_driver mousevsc_ll_driver = { + .open = mousevsc_hid_open, + .close = mousevsc_hid_close, +}; + +static struct hid_driver mousevsc_hid_driver; + static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) { struct hid_device *hid_dev; struct mousevsc_dev *input_device = hv_get_drvdata(dev); - /* hid_debug = -1; */ - hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL); + hid_dev = hid_allocate_device(); + if (IS_ERR(hid_dev)) + return; + + hid_dev->ll_driver = &mousevsc_ll_driver; + hid_dev->driver = &mousevsc_hid_driver; if (hid_parse_report(hid_dev, packet, len)) { DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report"); return; } - if (hid_dev) { - DPRINT_INFO(INPUTVSC_DRV, "hid_device created"); + hid_dev->bus = BUS_VIRTUAL; + hid_dev->vendor = input_device->hid_dev_info.vendor; + hid_dev->product = input_device->hid_dev_info.product; + hid_dev->version = input_device->hid_dev_info.version; - hid_dev->ll_driver->open = mousevsc_hid_open; - hid_dev->ll_driver->close = mousevsc_hid_close; + sprintf(hid_dev->name, "%s", "Microsoft Vmbus HID-compliant Mouse"); - hid_dev->bus = BUS_VIRTUAL; - hid_dev->vendor = input_device->hid_dev_info.vendor; - hid_dev->product = input_device->hid_dev_info.product; - hid_dev->version = input_device->hid_dev_info.version; - hid_dev->dev = dev->device; + if (!hidinput_connect(hid_dev, 0)) { + hid_dev->claimed |= HID_CLAIMED_INPUT; - sprintf(hid_dev->name, "%s", - "Microsoft Vmbus HID-compliant Mouse"); + input_device->connected = 1; - /* - * HJ Do we want to call it with a 0 - */ - if (!hidinput_connect(hid_dev, 0)) { - hid_dev->claimed |= HID_CLAIMED_INPUT; - - input_device->connected = 1; - - DPRINT_INFO(INPUTVSC_DRV, - "HID device claimed by input\n"); - } - - if (!hid_dev->claimed) { - DPRINT_ERR(INPUTVSC_DRV, - "HID device not claimed by " - "input or hiddev\n"); - } - - input_device->hid_device = hid_dev; } - kfree(hid_dev); + input_device->hid_device = hid_dev; } static int mousevsc_on_device_add(struct hv_device *device, @@ -825,6 +814,7 @@ static int mousevsc_remove(struct hv_device *dev) if (input_dev->connected) { hidinput_disconnect(input_dev->hid_device); input_dev->connected = 0; + hid_destroy_device(input_dev->hid_device); } /* From 0b1f0da005928c1cc761c320e6919b719a090a07 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:49 -0700 Subject: [PATCH 1287/1519] Staging: hv: mousevsc: Get rid of unnecessary DPRINT calls Get rid of unnecessary DPRINT calls. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 8d94aef9010..8dd902a901b 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -665,10 +665,8 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) hid_dev->ll_driver = &mousevsc_ll_driver; hid_dev->driver = &mousevsc_hid_driver; - if (hid_parse_report(hid_dev, packet, len)) { - DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report"); + if (hid_parse_report(hid_dev, packet, len)) return; - } hid_dev->bus = BUS_VIRTUAL; hid_dev->vendor = input_device->hid_dev_info.vendor; @@ -797,11 +795,8 @@ static int mousevsc_probe(struct hv_device *dev, /* Call to the vsc driver to add the device */ ret = mousevsc_on_device_add(dev, NULL); - if (ret != 0) { - DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device"); - + if (ret != 0) return -1; - } return 0; } @@ -809,7 +804,6 @@ static int mousevsc_probe(struct hv_device *dev, static int mousevsc_remove(struct hv_device *dev) { struct mousevsc_dev *input_dev = hv_get_drvdata(dev); - int ret; if (input_dev->connected) { hidinput_disconnect(input_dev->hid_device); @@ -821,13 +815,7 @@ static int mousevsc_remove(struct hv_device *dev) * Call to the vsc driver to let it know that the device * is being removed */ - ret = mousevsc_on_device_remove(dev); - if (ret != 0) { - DPRINT_ERR(INPUTVSC_DRV, - "unable to remove vsc device (ret %d)", ret); - } - - return ret; + return mousevsc_on_device_remove(dev); } static const struct hv_vmbus_device_id id_table[] = { From 5cd4d0302cc3a53b4fb48006d448f44f666f1569 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:50 -0700 Subject: [PATCH 1288/1519] Staging: hv: mousevsc: Cleanup error handling Cleanup error handling in this driver; use standard Linux error codes. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 8dd902a901b..fc1f3e60d0f 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -569,7 +569,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) if (!input_dev) { pr_err("unable to get input device...device being destroyed?"); - return -1; + return -ENODEV; } @@ -612,7 +612,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) if (!response->response.approved) { pr_err("synthhid protocol request failed (version %d)", SYNTHHID_INPUT_VERSION); - ret = -1; + ret = -ENODEV; goto cleanup; } @@ -629,7 +629,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) if (!input_dev->dev_info_status) pr_info("**** input channel up and running!! ****"); else - ret = -1; + ret = -ENOMEM; cleanup: put_input_device(device); @@ -694,10 +694,8 @@ static int mousevsc_on_device_add(struct hv_device *device, input_dev = alloc_input_device(device); - if (!input_dev) { - ret = -1; - goto cleanup; - } + if (!input_dev) + return -ENOMEM; input_dev->init_complete = false; @@ -714,7 +712,7 @@ static int mousevsc_on_device_add(struct hv_device *device, if (ret != 0) { pr_err("unable to open channel: %d", ret); free_input_device(input_dev); - return -1; + return ret; } pr_info("InputVsc channel open: %d", ret); @@ -743,7 +741,6 @@ static int mousevsc_on_device_add(struct hv_device *device, input_dev->init_complete = true; -cleanup: return ret; } @@ -789,16 +786,10 @@ static int mousevsc_on_device_remove(struct hv_device *device) static int mousevsc_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { - int ret = 0; - /* Call to the vsc driver to add the device */ - ret = mousevsc_on_device_add(dev, NULL); + return mousevsc_on_device_add(dev, NULL); - if (ret != 0) - return -1; - - return 0; } static int mousevsc_remove(struct hv_device *dev) From 61c4fb47cffa5cd6ff52fa1d3fca25547bcd76ad Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:51 -0700 Subject: [PATCH 1289/1519] Staging: hv: mousevsc: Get rid of unnecessary pr_* calls Get rid of unnecessary pr_* calls. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 64 ++++++----------------------------- 1 file changed, 11 insertions(+), 53 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index fc1f3e60d0f..57bc4a3d1fd 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -294,10 +294,8 @@ static void mousevsc_on_send_completion(struct hv_device *device, void *request; input_dev = must_get_input_device(device); - if (!input_dev) { - pr_err("unable to get input device...device being destroyed?"); + if (!input_dev) return; - } request = (void *)(unsigned long)packet->trans_id; @@ -329,11 +327,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, input_device->hid_desc = kzalloc(desc->bLength, GFP_ATOMIC); - if (!input_device->hid_desc) { - pr_err("unable to allocate hid descriptor - size %d", - desc->bLength); + if (!input_device->hid_desc) goto cleanup; - } memcpy(input_device->hid_desc, desc, desc->bLength); @@ -344,11 +339,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, input_device->report_desc = kzalloc(input_device->report_desc_size, GFP_ATOMIC); - if (!input_device->report_desc) { - pr_err("unable to allocate report descriptor - size %d", - input_device->report_desc_size); + if (!input_device->report_desc) goto cleanup; - } memcpy(input_device->report_desc, ((unsigned char *)desc) + desc->bLength, @@ -371,11 +363,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, (unsigned long)&ack, VM_PKT_DATA_INBAND, VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - if (ret != 0) { - pr_err("unable to send synthhid device info ack - ret %d", - ret); + if (ret != 0) goto cleanup; - } complete(&input_device->wait_event); @@ -397,10 +386,8 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, { struct hv_driver *input_drv; - if (!input_device->init_complete) { - pr_info("Initialization incomplete...ignoring input_report msg"); + if (!input_device->init_complete) return; - } input_drv = drv_to_hv_drv(input_device->device->device.driver); @@ -418,17 +405,13 @@ static void mousevsc_on_receive(struct hv_device *device, struct mousevsc_dev *input_dev; input_dev = must_get_input_device(device); - if (!input_dev) { - pr_err("unable to get input device...device being destroyed?"); + if (!input_dev) return; - } pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + (packet->offset8 << 3)); if (pipe_msg->type != PipeMessageData) { - pr_err("unknown pipe msg type - type %d len %d", - pipe_msg->type, pipe_msg->size); put_input_device(device); return ; } @@ -483,10 +466,8 @@ static void mousevsc_on_channel_callback(void *context) input_dev = must_get_input_device(device); - if (!input_dev) { - pr_err("unable to get input device...device being destroyed?"); + if (!input_dev) return; - } do { ret = vmbus_recvpacket_raw(device->channel, buffer, @@ -545,8 +526,6 @@ static void mousevsc_on_channel_callback(void *context) bufferlen = packetSize; /* Try again next time around */ - pr_err("unable to allocate buffer of size %d!", - bytes_recvd); break; } } @@ -567,10 +546,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) input_dev = get_input_device(device); - if (!input_dev) { - pr_err("unable to get input device...device being destroyed?"); + if (!input_dev) return -ENODEV; - } request = &input_dev->protocol_req; @@ -587,7 +564,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) request->request.header.size = sizeof(unsigned int); request->request.version_requested.version = SYNTHHID_INPUT_VERSION; - pr_info("synthhid protocol request..."); ret = vmbus_sendpacket(device->channel, request, sizeof(struct pipe_prt_msg) - @@ -596,10 +572,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) (unsigned long)request, VM_PKT_DATA_INBAND, VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); - if (ret != 0) { - pr_err("unable to send synthhid protocol request."); + if (ret != 0) goto cleanup; - } t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ); if (t == 0) { @@ -626,9 +600,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) * We should have gotten the device attr, hid desc and report * desc at this point */ - if (!input_dev->dev_info_status) - pr_info("**** input channel up and running!! ****"); - else + if (input_dev->dev_info_status) ret = -ENOMEM; cleanup: @@ -710,18 +682,14 @@ static int mousevsc_on_device_add(struct hv_device *device, ); if (ret != 0) { - pr_err("unable to open channel: %d", ret); free_input_device(input_dev); return ret; } - pr_info("InputVsc channel open: %d", ret); ret = mousevsc_connect_to_vsp(device); if (ret != 0) { - pr_err("unable to connect channel: %d", ret); - vmbus_close(device->channel); free_input_device(input_dev); return ret; @@ -749,8 +717,6 @@ static int mousevsc_on_device_remove(struct hv_device *device) struct mousevsc_dev *input_dev; int ret = 0; - pr_info("disabling input device (%p)...", - hv_get_drvdata(device)); input_dev = release_input_device(device); @@ -761,19 +727,11 @@ static int mousevsc_on_device_remove(struct hv_device *device) * * so that outstanding requests can be completed. */ - while (input_dev->num_outstanding_req) { - pr_info("waiting for %d requests to complete...", - input_dev->num_outstanding_req); - + while (input_dev->num_outstanding_req) udelay(100); - } - - pr_info("removing input device (%p)...", hv_get_drvdata(device)); input_dev = final_release_input_device(device); - pr_info("input device (%p) safe to remove", input_dev); - /* Close the channel */ vmbus_close(device->channel); From ea8646b92feea6de86dae44a879364758b6a4dcb Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:52 -0700 Subject: [PATCH 1290/1519] Staging: hv: mousevsc: Free allocated memory in free_input_device() Free all allocated memory in free_input_device(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 57bc4a3d1fd..326d9723946 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -199,6 +199,8 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) static void free_input_device(struct mousevsc_dev *device) { WARN_ON(atomic_read(&device->ref_count) != 0); + kfree(device->hid_desc); + kfree(device->report_desc); kfree(device); } From c5b71fc71fc7cdee68614d37826ed46db9be2006 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:53 -0700 Subject: [PATCH 1291/1519] Staging: hv: mousevsc: Get rid of the unused state: num_outstanding_req Get rid of the unused state: num_outstanding_req in struct mousevsc_dev. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 326d9723946..092c0ff0f0f 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -157,7 +157,6 @@ struct mousevsc_dev { struct hv_device *device; /* 0 indicates the device is being destroyed */ atomic_t ref_count; - int num_outstanding_req; unsigned char init_complete; struct mousevsc_prt_msg protocol_req; struct mousevsc_prt_msg protocol_resp; @@ -729,8 +728,6 @@ static int mousevsc_on_device_remove(struct hv_device *device) * * so that outstanding requests can be completed. */ - while (input_dev->num_outstanding_req) - udelay(100); input_dev = final_release_input_device(device); From bdbbdb2d63fe340935ec6521da62fe9e73d8dc15 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:54 -0700 Subject: [PATCH 1292/1519] Staging: hv: mousevsc: Cleanup alloc_input_device() Cleanup alloc_input_device(); you can directly set the reference count. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 092c0ff0f0f..38e31ae73a1 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -186,7 +186,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) * Set to 2 to allow both inbound and outbound traffics * (ie get_input_device() and must_get_input_device()) to proceed. */ - atomic_cmpxchg(&input_dev->ref_count, 0, 2); + atomic_set(&input_dev->ref_count, 2); input_dev->device = device; hv_set_drvdata(device, input_dev); From 1486dd0d0a95de1aaedd17ece19d9263ce7e5192 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:55 -0700 Subject: [PATCH 1293/1519] Staging: hv: mousevsc: Get rid of mousevsc_on_send_completion() We don't need to handle the "send complete" callback - nothing needs to be done here; get rid of the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 38e31ae73a1..fc0ba6879cf 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -288,25 +288,6 @@ static struct mousevsc_dev *final_release_input_device(struct hv_device *device) return input_dev; } -static void mousevsc_on_send_completion(struct hv_device *device, - struct vmpacket_descriptor *packet) -{ - struct mousevsc_dev *input_dev; - void *request; - - input_dev = must_get_input_device(device); - if (!input_dev) - return; - - request = (void *)(unsigned long)packet->trans_id; - - if (request == &input_dev->protocol_req) { - /* FIXME */ - /* Shouldn't we be doing something here? */ - } - - put_input_device(device); -} static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, struct synthhid_device_info *device_info) @@ -480,8 +461,6 @@ static void mousevsc_on_channel_callback(void *context) switch (desc->type) { case VM_PKT_COMP: - mousevsc_on_send_completion( - device, desc); break; case VM_PKT_DATA_INBAND: From 8660e38fab8b8a39ac828fb8a8579a9ad1b5d59d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:56 -0700 Subject: [PATCH 1294/1519] Staging: hv: mousevsc: Cleanup mousevsc_connect_to_vsp() Cleanup mousevsc_connect_to_vsp(). There is no need to take reference on the mousevsc device object when we are setting up the device. As part of this cleanup get rid of get_input_device() as this function is only used here. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index fc0ba6879cf..75ea2db1a75 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -203,32 +203,6 @@ static void free_input_device(struct mousevsc_dev *device) kfree(device); } -/* - * Get the inputdevice object if exists and its refcount > 1 - */ -static struct mousevsc_dev *get_input_device(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - - input_dev = hv_get_drvdata(device); - -/* - * FIXME - * This sure isn't a valid thing to print for debugging, no matter - * what the intention is... - * - * printk(KERN_ERR "-------------------------> REFCOUNT = %d", - * input_dev->ref_count); - */ - - if (input_dev && atomic_read(&input_dev->ref_count) > 1) - atomic_inc(&input_dev->ref_count); - else - input_dev = NULL; - - return input_dev; -} - /* * Get the inputdevice object iff exists and its refcount > 0 */ @@ -520,15 +494,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) { int ret = 0; int t; - struct mousevsc_dev *input_dev; + struct mousevsc_dev *input_dev = hv_get_drvdata(device); struct mousevsc_prt_msg *request; struct mousevsc_prt_msg *response; - input_dev = get_input_device(device); - - if (!input_dev) - return -ENODEV; - request = &input_dev->protocol_req; @@ -584,7 +553,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) ret = -ENOMEM; cleanup: - put_input_device(device); return ret; } From 8ec31f9385fdcd7c71fa0078deb0e84840f3cb49 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:57 -0700 Subject: [PATCH 1295/1519] Staging: hv: mousevsc: Get rid of mousevsc_on_device_remove() by inlining code Get rid of mousevsc_on_device_remove() by inlining code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 47 +++++++++++++---------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 75ea2db1a75..53244293a25 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -660,33 +660,6 @@ static int mousevsc_on_device_add(struct hv_device *device, return ret; } -static int mousevsc_on_device_remove(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - int ret = 0; - - - input_dev = release_input_device(device); - - - /* - * At this point, all outbound traffic should be disable. We only - * allow inbound traffic (responses) to proceed - * - * so that outstanding requests can be completed. - */ - - input_dev = final_release_input_device(device); - - /* Close the channel */ - vmbus_close(device->channel); - - free_input_device(input_dev); - - return ret; -} - - static int mousevsc_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { @@ -706,11 +679,25 @@ static int mousevsc_remove(struct hv_device *dev) hid_destroy_device(input_dev->hid_device); } + + release_input_device(dev); + + /* - * Call to the vsc driver to let it know that the device - * is being removed + * At this point, all outbound traffic should be disable. We only + * allow inbound traffic (responses) to proceed + * + * so that outstanding requests can be completed. */ - return mousevsc_on_device_remove(dev); + + input_dev = final_release_input_device(dev); + + /* Close the channel */ + vmbus_close(dev->channel); + + free_input_device(input_dev); + + return 0; } static const struct hv_vmbus_device_id id_table[] = { From c411f17daf0942509f6db47b4a237e953f35611b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:58 -0700 Subject: [PATCH 1296/1519] Staging: hv: mousevsc: Now cleanup mousevsc_remove() Now, cleanup mousevsc_remove(). The mouse driver once initialized only receives data from the host. So, by closing the channel first in the unload path, we can properly deal with inflight packets. So, we don't need the machinery for managing the life-cycle of the mousevsc_dev object. Get rid of the unnecessary code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 53 ++--------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 53244293a25..317d2bebc55 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -197,9 +197,9 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) static void free_input_device(struct mousevsc_dev *device) { - WARN_ON(atomic_read(&device->ref_count) != 0); kfree(device->hid_desc); kfree(device->report_desc); + hv_set_drvdata(device->device, NULL); kfree(device); } @@ -229,39 +229,6 @@ static void put_input_device(struct hv_device *device) atomic_dec(&input_dev->ref_count); } -/* - * Drop ref count to 1 to effectively disable get_input_device() - */ -static struct mousevsc_dev *release_input_device(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - - input_dev = hv_get_drvdata(device); - - /* Busy wait until the ref drop to 2, then set it to 1 */ - while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2) - udelay(100); - - return input_dev; -} - -/* - * Drop ref count to 0. No one can use input_device object. - */ -static struct mousevsc_dev *final_release_input_device(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - - input_dev = hv_get_drvdata(device); - - /* Busy wait until the ref drop to 1, then set it to 0 */ - while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1) - udelay(100); - - hv_set_drvdata(device, NULL); - return input_dev; -} - static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, struct synthhid_device_info *device_info) @@ -673,28 +640,14 @@ static int mousevsc_remove(struct hv_device *dev) { struct mousevsc_dev *input_dev = hv_get_drvdata(dev); + vmbus_close(dev->channel); + if (input_dev->connected) { hidinput_disconnect(input_dev->hid_device); input_dev->connected = 0; hid_destroy_device(input_dev->hid_device); } - - release_input_device(dev); - - - /* - * At this point, all outbound traffic should be disable. We only - * allow inbound traffic (responses) to proceed - * - * so that outstanding requests can be completed. - */ - - input_dev = final_release_input_device(dev); - - /* Close the channel */ - vmbus_close(dev->channel); - free_input_device(input_dev); return 0; From ee2baa299ae11fec073c2b2aad7f6c571f71189e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:54:59 -0700 Subject: [PATCH 1297/1519] Staging: hv: mousevsc: Get rid of ref_count state in struct mousevsc_dev Now get rid of the machinery for managing the life-cycle of the mousevsc_dev as this is not needed. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 54 ++--------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 317d2bebc55..e57e0b4b15c 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -155,8 +155,6 @@ struct mousevsc_prt_msg { */ struct mousevsc_dev { struct hv_device *device; - /* 0 indicates the device is being destroyed */ - atomic_t ref_count; unsigned char init_complete; struct mousevsc_prt_msg protocol_req; struct mousevsc_prt_msg protocol_resp; @@ -182,12 +180,6 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device) if (!input_dev) return NULL; - /* - * Set to 2 to allow both inbound and outbound traffics - * (ie get_input_device() and must_get_input_device()) to proceed. - */ - atomic_set(&input_dev->ref_count, 2); - input_dev->device = device; hv_set_drvdata(device, input_dev); init_completion(&input_dev->wait_event); @@ -203,32 +195,6 @@ static void free_input_device(struct mousevsc_dev *device) kfree(device); } -/* - * Get the inputdevice object iff exists and its refcount > 0 - */ -static struct mousevsc_dev *must_get_input_device(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - - input_dev = hv_get_drvdata(device); - - if (input_dev && atomic_read(&input_dev->ref_count)) - atomic_inc(&input_dev->ref_count); - else - input_dev = NULL; - - return input_dev; -} - -static void put_input_device(struct hv_device *device) -{ - struct mousevsc_dev *input_dev; - - input_dev = hv_get_drvdata(device); - - atomic_dec(&input_dev->ref_count); -} - static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, struct synthhid_device_info *device_info) @@ -325,19 +291,13 @@ static void mousevsc_on_receive(struct hv_device *device, { struct pipe_prt_msg *pipe_msg; struct synthhid_msg *hid_msg; - struct mousevsc_dev *input_dev; - - input_dev = must_get_input_device(device); - if (!input_dev) - return; + struct mousevsc_dev *input_dev = hv_get_drvdata(device); pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + (packet->offset8 << 3)); - if (pipe_msg->type != PipeMessageData) { - put_input_device(device); - return ; - } + if (pipe_msg->type != PipeMessageData) + return; hid_msg = (struct synthhid_msg *)&pipe_msg->data[0]; @@ -370,7 +330,6 @@ static void mousevsc_on_receive(struct hv_device *device, break; } - put_input_device(device); } static void mousevsc_on_channel_callback(void *context) @@ -378,7 +337,6 @@ static void mousevsc_on_channel_callback(void *context) const int packetSize = 0x100; int ret = 0; struct hv_device *device = (struct hv_device *)context; - struct mousevsc_dev *input_dev; u32 bytes_recvd; u64 req_id; @@ -387,10 +345,6 @@ static void mousevsc_on_channel_callback(void *context) unsigned char *buffer = packet; int bufferlen = packetSize; - input_dev = must_get_input_device(device); - - if (!input_dev) - return; do { ret = vmbus_recvpacket_raw(device->channel, buffer, @@ -452,8 +406,6 @@ static void mousevsc_on_channel_callback(void *context) } } while (1); - put_input_device(device); - return; } From 517812b448e56d71185028445f8feb722bcd17a2 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:55:00 -0700 Subject: [PATCH 1298/1519] Staging: hv: mousevsc: Cleanup camel cased enums Cleanup all camel cased names. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index e57e0b4b15c..662132606bc 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -58,12 +58,12 @@ struct hv_input_dev_info { * Message types in the synthetic input protocol */ enum synthhid_msg_type { - SynthHidProtocolRequest, - SynthHidProtocolResponse, - SynthHidInitialDeviceInfo, - SynthHidInitialDeviceInfoAck, - SynthHidInputReport, - SynthHidMax + SYNTH_HID_PROTOCOL_REQUEST, + SYNTH_HID_PROTOCOL_RESPONSE, + SYNTH_HID_INITIAL_DEVICE_INFO, + SYNTH_HID_INITIAL_DEVICE_INFO_ACK, + SYNTH_HID_INPUT_REPORT, + SYNTH_HID_MAX }; /* @@ -125,9 +125,9 @@ struct synthhid_input_report { #define NBITS(x) (((x)/BITS_PER_LONG)+1) enum pipe_prot_msg_type { - PipeMessageInvalid = 0, - PipeMessageData, - PipeMessageMaximum + PIPE_MESSAGE_INVALID, + PIPE_MESSAGE_DATA, + PIPE_MESSAGE_MAXIMUM }; @@ -238,10 +238,10 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, /* Send the ack */ memset(&ack, 0, sizeof(struct mousevsc_prt_msg)); - ack.type = PipeMessageData; + ack.type = PIPE_MESSAGE_DATA; ack.size = sizeof(struct synthhid_device_info_ack); - ack.ack.header.type = SynthHidInitialDeviceInfoAck; + ack.ack.header.type = SYNTH_HID_INITIAL_DEVICE_INFO_ACK; ack.ack.header.size = 1; ack.ack.reserved = 0; @@ -296,20 +296,20 @@ static void mousevsc_on_receive(struct hv_device *device, pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + (packet->offset8 << 3)); - if (pipe_msg->type != PipeMessageData) + if (pipe_msg->type != PIPE_MESSAGE_DATA) return; hid_msg = (struct synthhid_msg *)&pipe_msg->data[0]; switch (hid_msg->header.type) { - case SynthHidProtocolResponse: + case SYNTH_HID_PROTOCOL_RESPONSE: memcpy(&input_dev->protocol_resp, pipe_msg, pipe_msg->size + sizeof(struct pipe_prt_msg) - sizeof(unsigned char)); complete(&input_dev->wait_event); break; - case SynthHidInitialDeviceInfo: + case SYNTH_HID_INITIAL_DEVICE_INFO: WARN_ON(pipe_msg->size < sizeof(struct hv_input_dev_info)); /* @@ -319,7 +319,7 @@ static void mousevsc_on_receive(struct hv_device *device, mousevsc_on_receive_device_info(input_dev, (struct synthhid_device_info *)&pipe_msg->data[0]); break; - case SynthHidInputReport: + case SYNTH_HID_INPUT_REPORT: mousevsc_on_receive_input_report(input_dev, (struct synthhid_input_report *)&pipe_msg->data[0]); @@ -425,10 +425,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) */ memset(request, 0, sizeof(struct mousevsc_prt_msg)); - request->type = PipeMessageData; + request->type = PIPE_MESSAGE_DATA; request->size = sizeof(struct synthhid_protocol_request); - request->request.header.type = SynthHidProtocolRequest; + request->request.header.type = SYNTH_HID_PROTOCOL_REQUEST; request->request.header.size = sizeof(unsigned int); request->request.version_requested.version = SYNTHHID_INPUT_VERSION; From 6e56f27c09ec695fd0091476772e38fe9ccaa5a9 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:55:01 -0700 Subject: [PATCH 1299/1519] Staging: hv: mousevsc: Get rid of mousevsc_on_receive_input_report() by inlining Get rid of mousevsc_on_receive_input_report() by inlining the code. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 662132606bc..a526ba5ced3 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -270,28 +270,13 @@ cleanup: complete(&input_device->wait_event); } -static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device, - struct synthhid_input_report *input_report) -{ - struct hv_driver *input_drv; - - if (!input_device->init_complete) - return; - - input_drv = drv_to_hv_drv(input_device->device->device.driver); - - - hid_input_report(input_device->hid_device, - HID_INPUT_REPORT, input_report->buffer, input_report->header.size, 1); - -} - static void mousevsc_on_receive(struct hv_device *device, struct vmpacket_descriptor *packet) { struct pipe_prt_msg *pipe_msg; struct synthhid_msg *hid_msg; struct mousevsc_dev *input_dev = hv_get_drvdata(device); + struct synthhid_input_report *input_report; pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + (packet->offset8 << 3)); @@ -320,9 +305,13 @@ static void mousevsc_on_receive(struct hv_device *device, (struct synthhid_device_info *)&pipe_msg->data[0]); break; case SYNTH_HID_INPUT_REPORT: - mousevsc_on_receive_input_report(input_dev, - (struct synthhid_input_report *)&pipe_msg->data[0]); - + input_report = + (struct synthhid_input_report *)&pipe_msg->data[0]; + if (!input_dev->init_complete) + break; + hid_input_report(input_dev->hid_device, + HID_INPUT_REPORT, input_report->buffer, + input_report->header.size, 1); break; default: pr_err("unsupported hid msg type - type %d len %d", From 929ad795f0a8d3419ea19c76d7c13ebb96c49286 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:55:02 -0700 Subject: [PATCH 1300/1519] Staging: hv: mousevsc: Cleanup mousevsc_on_device_add() Cleanup mousevsc_on_device_add(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index a526ba5ced3..98ae0621c00 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -513,12 +513,10 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) input_device->hid_device = hid_dev; } -static int mousevsc_on_device_add(struct hv_device *device, - void *additional_info) +static int mousevsc_on_device_add(struct hv_device *device) { int ret = 0; struct mousevsc_dev *input_dev; - struct hv_driver *input_drv; input_dev = alloc_input_device(device); @@ -551,9 +549,6 @@ static int mousevsc_on_device_add(struct hv_device *device, return ret; } - input_drv = drv_to_hv_drv(input_dev->device->device.driver); - - /* Send the report desc back up */ /* workaround SA-167 */ @@ -573,7 +568,7 @@ static int mousevsc_probe(struct hv_device *dev, { /* Call to the vsc driver to add the device */ - return mousevsc_on_device_add(dev, NULL); + return mousevsc_on_device_add(dev); } From 1eadd8c286824ab50298bc6c828d4984bd297e9f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:55:03 -0700 Subject: [PATCH 1301/1519] Staging: hv: mousevsc: Enable autoloading of the mouse driver Now that the mouse driver is functional, enable the auto-loading of the driver. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 98ae0621c00..71b460b855f 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -596,10 +596,7 @@ static const struct hv_vmbus_device_id id_table[] = { { }, }; -/* - * The mouse driver is not functional; do not auto-load it. - */ -/* MODULE_DEVICE_TABLE(vmbus, id_table); */ +MODULE_DEVICE_TABLE(vmbus, id_table); static struct hv_driver mousevsc_drv = { .name = "mousevsc", From 41598a0b718d31db6782a87ac5049ccfb56121db Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 29 Sep 2011 11:55:04 -0700 Subject: [PATCH 1302/1519] Staging: hv: mousevsc: Get rid of unnecessary comments Get rid of unnecessary comments. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 71b460b855f..edbb4797db7 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -26,9 +26,6 @@ #include "hyperv.h" -/* - * Data types - */ struct hv_input_dev_info { unsigned int size; unsigned short vendor; @@ -137,9 +134,6 @@ struct pipe_prt_msg { char data[1]; }; -/* - * Data types - */ struct mousevsc_prt_msg { enum pipe_prot_msg_type type; u32 size; @@ -206,11 +200,9 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, /* Assume success for now */ input_device->dev_info_status = 0; - /* Save the device attr */ memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info, sizeof(struct hv_input_dev_info)); - /* Save the hid desc */ desc = &device_info->hid_descriptor; WARN_ON(desc->bLength == 0); @@ -221,7 +213,6 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device, memcpy(input_device->hid_desc, desc, desc->bLength); - /* Save the report desc */ input_device->report_desc_size = desc->desc[0].wDescriptorLength; if (input_device->report_desc_size == 0) goto cleanup; @@ -368,10 +359,6 @@ static void mousevsc_on_channel_callback(void *context) bufferlen = packetSize; } } else { - /* - * pr_debug("nothing else to read..."); - * reset - */ if (bufferlen > packetSize) { kfree(buffer); @@ -388,8 +375,6 @@ static void mousevsc_on_channel_callback(void *context) if (buffer == NULL) { buffer = packet; bufferlen = packetSize; - - /* Try again next time around */ break; } } @@ -409,9 +394,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device) request = &input_dev->protocol_req; - /* - * Now, initiate the vsc/vsp initialization protocol on the open channel - */ memset(request, 0, sizeof(struct mousevsc_prt_msg)); request->type = PIPE_MESSAGE_DATA; @@ -525,7 +507,6 @@ static int mousevsc_on_device_add(struct hv_device *device) input_dev->init_complete = false; - /* Open the channel */ ret = vmbus_open(device->channel, INPUTVSC_SEND_RING_BUFFER_SIZE, INPUTVSC_RECV_RING_BUFFER_SIZE, @@ -550,7 +531,6 @@ static int mousevsc_on_device_add(struct hv_device *device) } - /* Send the report desc back up */ /* workaround SA-167 */ if (input_dev->report_desc[14] == 0x25) input_dev->report_desc[14] = 0x29; @@ -567,7 +547,6 @@ static int mousevsc_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { - /* Call to the vsc driver to add the device */ return mousevsc_on_device_add(dev); } From 8bf90539d672090f725b6a5456f3898a602be193 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sat, 1 Oct 2011 09:43:48 +0100 Subject: [PATCH 1303/1519] staging: wlags49_h2: Use C99 __func__ in DBG machinery so you don't have to declare DBG_FUNC at the start of all functions. This just makes it easy to add DBG conforming to existing code. The patch reformats the changed #defines to satisfy checkstyle.pl Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/debug.h | 61 ++++++++++++++------------ drivers/staging/wlags49_h2/wl_netdev.c | 2 +- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/drivers/staging/wlags49_h2/debug.h b/drivers/staging/wlags49_h2/debug.h index 2c3dd140a35..8d5dddf0805 100644 --- a/drivers/staging/wlags49_h2/debug.h +++ b/drivers/staging/wlags49_h2/debug.h @@ -129,11 +129,15 @@ #define _LEAVE_STR "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" -#define _DBG_ENTER(A) DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A), _ENTER_STR, __FUNC__) -#define _DBG_LEAVE(A) DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--, _LEAVE_STR, __FUNC__) +#define _DBG_ENTER(A) \ + DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A), \ + _ENTER_STR, __func__) +#define _DBG_LEAVE(A) \ + DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--, \ + _LEAVE_STR, __func__) -#define DBG_FUNC(F) static const char *__FUNC__ = F; +#define DBG_FUNC(F) #define DBG_ENTER(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ _DBG_ENTER(A); } @@ -145,29 +149,33 @@ DBG_PRINT(" %s -- "F"\n", N, S); } -#define DBG_ERROR(A, S...) {if (DBG_FLAGS(A) & DBG_ERROR_ON) {\ - DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __FUNC__);\ - DBG_PRINTC(S); \ - DBG_TRAP; \ - } \ - } +#define DBG_ERROR(A, S...) do { \ + if (DBG_FLAGS(A) & DBG_ERROR_ON) { \ + DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __func__); \ + DBG_PRINTC(S); \ + DBG_TRAP; \ + } } while (0) -#define DBG_WARNING(A, S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) {\ - DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __FUNC__);\ - DBG_PRINTC(S); } } +#define DBG_WARNING(A, S...) do { \ + if (DBG_FLAGS(A) & DBG_WARNING_ON) { \ + DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __func__); \ + DBG_PRINTC(S); \ + } } while (0) -#define DBG_NOTICE(A, S...) {if (DBG_FLAGS(A) & DBG_NOTICE_ON) {\ - DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __FUNC__);\ - DBG_PRINTC(S); \ - } \ - } +#define DBG_NOTICE(A, S...) do { \ + if (DBG_FLAGS(A) & DBG_NOTICE_ON) { \ + DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __func__); \ + DBG_PRINTC(S); \ + } } while (0) -#define DBG_TRACE(A, S...) do {if (DBG_FLAGS(A) & DBG_TRACE_ON) {\ - DBG_PRINT("%s:%s ", DBG_NAME(A), __FUNC__);\ - DBG_PRINTC(S); } } while (0) +#define DBG_TRACE(A, S...) do { \ + if (DBG_FLAGS(A) & DBG_TRACE_ON) { \ + DBG_PRINT("%s:%s ", DBG_NAME(A), __func__); \ + DBG_PRINTC(S); \ + } } while (0) #define DBG_RX(A, S...) {if (DBG_FLAGS(A) & DBG_RX_ON) {\ @@ -181,13 +189,12 @@ DBG_PRINT(S); } } -#define DBG_ASSERT(C) { \ - if (!(C)) {\ - DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \ - #C, __FILE__, __LINE__, __FUNC__); \ - DBG_TRAP; \ - } \ - } +#define DBG_ASSERT(C) do { \ + if (!(C)) { \ + DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \ + #C, __FILE__, __LINE__, __func__); \ + DBG_TRAP; \ + } } while (0) typedef struct { char *dbgName; diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c index cf917e613f2..1c9d4d0626f 100644 --- a/drivers/staging/wlags49_h2/wl_netdev.c +++ b/drivers/staging/wlags49_h2/wl_netdev.c @@ -217,7 +217,7 @@ int wl_config( struct net_device *dev, struct ifmap *map ) /* The only thing we care about here is a port change. Since this not needed, ignore the request. */ - DBG_TRACE( DbgInfo, "%s: %s called.\n", dev->name, __FUNC__ ); + DBG_TRACE(DbgInfo, "%s: %s called.\n", dev->name, __func__); DBG_LEAVE( DbgInfo ); return 0; From 268b06ac8b3b16516cf926872d822836caf785cc Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sat, 1 Oct 2011 09:43:49 +0100 Subject: [PATCH 1304/1519] staging: wlags49_h2: Remove unused debug function The function no longer compiles, so we just remove it. Reported-by: Henk de Groot Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_cs.c | 114 ----------------------------- 1 file changed, 114 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c index a3a727c3b40..321580267fe 100644 --- a/drivers/staging/wlags49_h2/wl_cs.c +++ b/drivers/staging/wlags49_h2/wl_cs.c @@ -501,117 +501,3 @@ int wl_adapter_is_open(struct net_device *dev) return link->open; } /* wl_adapter_is_open */ /*============================================================================*/ - - -#if DBG - -/******************************************************************************* - * DbgEvent() - ******************************************************************************* - * - * DESCRIPTION: - * - * Converts the card serivces events to text for debugging. - * - * PARAMETERS: - * - * mask - a integer representing the error(s) being reported by Card - * Services. - * - * RETURNS: - * - * a pointer to a string describing the error(s) - * - ******************************************************************************/ -const char *DbgEvent(int mask) -{ - static char DbgBuffer[256]; - char *pBuf; - /*--------------------------------------------------------------------*/ - - pBuf = DbgBuffer; - *pBuf = '\0'; - - - if (mask & CS_EVENT_WRITE_PROTECT) - strcat(pBuf, "WRITE_PROTECT "); - - if (mask & CS_EVENT_CARD_LOCK) - strcat(pBuf, "CARD_LOCK "); - - if (mask & CS_EVENT_CARD_INSERTION) - strcat(pBuf, "CARD_INSERTION "); - - if (mask & CS_EVENT_CARD_REMOVAL) - strcat(pBuf, "CARD_REMOVAL "); - - if (mask & CS_EVENT_BATTERY_DEAD) - strcat(pBuf, "BATTERY_DEAD "); - - if (mask & CS_EVENT_BATTERY_LOW) - strcat(pBuf, "BATTERY_LOW "); - - if (mask & CS_EVENT_READY_CHANGE) - strcat(pBuf, "READY_CHANGE "); - - if (mask & CS_EVENT_CARD_DETECT) - strcat(pBuf, "CARD_DETECT "); - - if (mask & CS_EVENT_RESET_REQUEST) - strcat(pBuf, "RESET_REQUEST "); - - if (mask & CS_EVENT_RESET_PHYSICAL) - strcat(pBuf, "RESET_PHYSICAL "); - - if (mask & CS_EVENT_CARD_RESET) - strcat(pBuf, "CARD_RESET "); - - if (mask & CS_EVENT_REGISTRATION_COMPLETE) - strcat(pBuf, "REGISTRATION_COMPLETE "); - - /* if (mask & CS_EVENT_RESET_COMPLETE) - strcat(pBuf, "RESET_COMPLETE "); */ - - if (mask & CS_EVENT_PM_SUSPEND) - strcat(pBuf, "PM_SUSPEND "); - - if (mask & CS_EVENT_PM_RESUME) - strcat(pBuf, "PM_RESUME "); - - if (mask & CS_EVENT_INSERTION_REQUEST) - strcat(pBuf, "INSERTION_REQUEST "); - - if (mask & CS_EVENT_EJECTION_REQUEST) - strcat(pBuf, "EJECTION_REQUEST "); - - if (mask & CS_EVENT_MTD_REQUEST) - strcat(pBuf, "MTD_REQUEST "); - - if (mask & CS_EVENT_ERASE_COMPLETE) - strcat(pBuf, "ERASE_COMPLETE "); - - if (mask & CS_EVENT_REQUEST_ATTENTION) - strcat(pBuf, "REQUEST_ATTENTION "); - - if (mask & CS_EVENT_CB_DETECT) - strcat(pBuf, "CB_DETECT "); - - if (mask & CS_EVENT_3VCARD) - strcat(pBuf, "3VCARD "); - - if (mask & CS_EVENT_XVCARD) - strcat(pBuf, "XVCARD "); - - - if (*pBuf) { - pBuf[strlen(pBuf) - 1] = '\0'; - } else { - if (mask != 0x0) - sprintf(pBuf, "<<0x%08x>>", mask); - } - - return pBuf; -} /* DbgEvent */ -/*============================================================================*/ - -#endif /* DBG */ From c6a241745943aba2b86b9dae3258e60f4c6635a8 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sat, 1 Oct 2011 09:43:50 +0100 Subject: [PATCH 1305/1519] staging: wlags49_h2: Remove bad debug message The message is in the wrong place. We definitely don't want to return at this point, as we may need to turn off encryption. Reported-by: Henk de Groot Signed-off-by: David Kiroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 764a3208afd..89563dadddc 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -1214,7 +1214,6 @@ static int wireless_set_encode(struct net_device *dev, struct iw_request_info *i lp->EnableEncryption = 1; } else { DBG_WARNING( DbgInfo, "Problem setting the current TxKey\n" ); - DBG_LEAVE( DbgInfo ); ret = -EINVAL; } } From 53c3ee0db36db31d095f4e902bc42a4dea18fd8c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:10 +0100 Subject: [PATCH 1306/1519] staging: et131x: Remove TODO entry 'alloc_etherdev initilising memory with zero' Removing this as I'm pretty sure its not true, and alloc_etherdev isn't provided by this driver anyway. Alternatively, its a badly written comment and I don't understand it. This drivers use of alloc_etherdev() is within keeping with other net devices, so I'm happy. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 7e846b2c26d..d24ef84dcd8 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - alloc_etherdev is initializing memory with zero?!? - add_timer call in et131x_netdev.c is correct? - Add power saving functionality (suspend, sleep, resume) - Implement a few more kernel Parameter (set mac ) From a3bf5fa772963ef0310d982077784ef6839f2fa7 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:11 +0100 Subject: [PATCH 1307/1519] staging: et131x: Introduce et1310_in_phy_coma() call In several places in the code, the pm_csr register is read and the PHY_SW_COMA bit checked. Move this check into its own small function to make the code more readable. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 4 ++-- drivers/staging/et131x/et1310_pm.c | 15 +++++++++++++ drivers/staging/et131x/et131x.h | 1 + drivers/staging/et131x/et131x_initpci.c | 28 ++++++++----------------- drivers/staging/et131x/et131x_isr.c | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 08d7691ce19..157462feeb6 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -612,7 +612,7 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) /* Write out the new hash to the device */ pm_csr = readl(&adapter->regs->global.pm_csr); - if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { + if (!et1310_in_phy_coma(adapter)) { writel(hash1, &rxmac->multi_hash1); writel(hash2, &rxmac->multi_hash2); writel(hash3, &rxmac->multi_hash3); @@ -653,7 +653,7 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) adapter->addr[5]; pm_csr = readl(&adapter->regs->global.pm_csr); - if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { + if (!et1310_in_phy_coma(adapter)) { writel(uni_pf1, &rxmac->uni_pf_addr1); writel(uni_pf2, &rxmac->uni_pf_addr2); writel(uni_pf3, &rxmac->uni_pf_addr3); diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index b20d5d627ef..55f2d3672b1 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -86,6 +86,21 @@ #include "et131x_adapter.h" #include "et131x.h" +/** + * et1310_in_phy_coma - check if the device is in phy coma + * @adapter: pointer to our adapter structure + * + * Returns 0 if the device is not in phy coma, 1 if it is in phy coma + */ +int et1310_in_phy_coma(struct et131x_adapter *adapter) +{ + u32 pmcsr; + + pmcsr = readl(&adapter->regs->global.pm_csr); + + return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; +} + /** * et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index c047e6e2850..d967c5a1fe7 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -87,6 +87,7 @@ void et131x_enable_txrx(struct net_device *netdev); void et131x_disable_txrx(struct net_device *netdev); /* et1310_pm.c */ +int et1310_in_phy_coma(struct et131x_adapter *adapter); void et1310_enable_phy_coma(struct et131x_adapter *adapter); void et1310_disable_phy_coma(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index e9daa733bea..667ab80fe6f 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -239,15 +239,11 @@ static int et131x_pci_init(struct et131x_adapter *adapter, void et131x_error_timer_handler(unsigned long data) { struct et131x_adapter *adapter = (struct et131x_adapter *) data; - u32 pm_csr; - pm_csr = readl(&adapter->regs->global.pm_csr); - - if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) + if (!et1310_in_phy_coma(adapter)) et1310_update_macstat_host_counters(adapter); else - dev_err(&adapter->pdev->dev, - "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr); + dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma\n"); if (!(adapter->bmsr & BMSR_LSTATUS) && adapter->boot_coma < 11) { @@ -256,7 +252,7 @@ void et131x_error_timer_handler(unsigned long data) if (adapter->boot_coma == 10) { if (!(adapter->bmsr & BMSR_LSTATUS)) { - if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { + if (!et1310_in_phy_coma(adapter)) { /* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux? */ @@ -443,9 +439,6 @@ static void et131x_adjust_link(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); struct phy_device *phydev = adapter->phydev; - struct address_map __iomem *iomem = adapter->regs; - - u32 pm_csr; if (netif_carrier_ok(netdev)) { adapter->boot_coma = 20; @@ -488,16 +481,13 @@ static void et131x_adjust_link(struct net_device *netdev) } if (phydev->link != adapter->link) { - /* If we are in coma mode, we need to disable it. */ - pm_csr = readl(&iomem->global.pm_csr); - if (pm_csr & ET_PM_PHY_SW_COMA) { - /* - * Check to see if we are in coma mode and if - * so, disable it because we will not be able - * to read PHY values until we are out. - */ + /* + * Check to see if we are in coma mode and if + * so, disable it because we will not be able + * to read PHY values until we are out. + */ + if (et1310_in_phy_coma(adapter)) et1310_disable_phy_coma(adapter); - } if (phydev->link) { adapter->boot_coma = 20; diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index 0747935fb3c..fb108d202d3 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -304,7 +304,7 @@ void et131x_isr_handler(struct work_struct *work) * bp xon/xoff) */ pm_csr = readl(&iomem->global.pm_csr); - if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) + if (!et1310_in_phy_coma(adapter)) writel(3, &iomem->txmac.bp_ctrl); } } From 1ce664dc0144eb8e01647f753e319ef53a85423e Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:12 +0100 Subject: [PATCH 1308/1519] staging: et131x: Remove adapter->bmsr, replace with phydev equivalents adapter->bmsr is no longer being updated, but is also used to check the link state in places. Remove bmsr from adapter, and replace link state checks with phydev->link check. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 3 --- drivers/staging/et131x/et131x_adapter.h | 3 --- drivers/staging/et131x/et131x_initpci.c | 7 +++---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index fc37b185737..a72046ba0ac 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -337,9 +337,6 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) u16 isr; u16 lcr2; - /* Zero out the adapter structure variable representing BMSR */ - adapter->bmsr = 0; - et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &isr); et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &imr); diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index fabc2c593b3..b5195ef4f40 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -201,9 +201,6 @@ struct et131x_adapter { u16 pdown_speed; u8 pdown_duplex; - /* Xcvr status at last poll */ - u16 bmsr; - /* Tx Memory Variables */ struct tx_ring tx_ring; diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 667ab80fe6f..10283a397c9 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -239,19 +239,18 @@ static int et131x_pci_init(struct et131x_adapter *adapter, void et131x_error_timer_handler(unsigned long data) { struct et131x_adapter *adapter = (struct et131x_adapter *) data; + struct phy_device *phydev = adapter->phydev; if (!et1310_in_phy_coma(adapter)) et1310_update_macstat_host_counters(adapter); else dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma\n"); - if (!(adapter->bmsr & BMSR_LSTATUS) && - adapter->boot_coma < 11) { + if (!phydev->link && adapter->boot_coma < 11) adapter->boot_coma++; - } if (adapter->boot_coma == 10) { - if (!(adapter->bmsr & BMSR_LSTATUS)) { + if (!phydev->link) { if (!et1310_in_phy_coma(adapter)) { /* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux? From 25e1c2780c2cef0456c850237abd895781d34e44 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:13 +0100 Subject: [PATCH 1309/1519] staging: et131x: Add pci suspend & resume functions Added basic suspend & resume functionality. Tested on an et1310 device, and putting Fedora15 host in and out of hibernation successfully. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.h | 2 ++ drivers/staging/et131x/et131x_initpci.c | 45 +++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index d24ef84dcd8..42c388d2098 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -10,7 +10,6 @@ driver as they did not build properly at the time. TODO: - add_timer call in et131x_netdev.c is correct? - - Add power saving functionality (suspend, sleep, resume) - Implement a few more kernel Parameter (set mac ) Please send patches to: diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index d967c5a1fe7..15486d11f95 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -82,6 +82,8 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ +int et131x_open(struct net_device *netdev); +int et131x_close(struct net_device *netdev); struct net_device *et131x_device_alloc(void); void et131x_enable_txrx(struct net_device *netdev); void et131x_disable_txrx(struct net_device *netdev); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 10283a397c9..e166fde8997 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -869,6 +869,45 @@ static void __devexit et131x_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + + if (!netif_running(netdev)) + return 0; + + et131x_close(netdev); + netif_device_detach(netdev); + + pci_save_state(pdev); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); + + return 0; +} + +static int et131x_pci_resume(struct pci_dev *pdev) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + int err = 0; + + if (!netif_running(netdev)) + return 0; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + err = et131x_open(netdev); + if (err) { + dev_err(&pdev->dev, "Can't resume interface!\n"); + goto out; + } + + netif_device_attach(netdev); + +out: + return err; +} + static struct pci_device_id et131x_pci_table[] __devinitdata = { {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL}, @@ -884,8 +923,10 @@ static struct pci_driver et131x_driver = { .id_table = et131x_pci_table, .probe = et131x_pci_setup, .remove = __devexit_p(et131x_pci_remove), - .suspend = NULL, /* et131x_pci_suspend */ - .resume = NULL, /* et131x_pci_resume */ +#ifdef CONFIG_PM + .suspend = et131x_pci_suspend, + .resume = et131x_pci_resume, +#endif }; /** From d84b7e29d8ea049c352af89db69cff7e791a9418 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:14 +0100 Subject: [PATCH 1310/1519] staging: et131x: Fix add_timer() from et131x_open The error_timer was only getting initialised and an initial jiffies value set following a probe. This could result in the timer needlessly expiring immediately after et131x_open is called. Now this is all done from the open call instead. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.h | 1 + drivers/staging/et131x/et131x_initpci.c | 7 ------- drivers/staging/et131x/et131x_netdev.c | 4 ++++ 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 42c388d2098..a0ebaa0de53 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - add_timer call in et131x_netdev.c is correct? - Implement a few more kernel Parameter (set mac ) Please send patches to: diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 15486d11f95..c8f5ab14b6f 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -52,6 +52,7 @@ int et131x_init_eeprom(struct et131x_adapter *adapter); /* et131x_initpci.c */ +void et131x_error_timer_handler(unsigned long data); void et131x_configure_global_regs(struct et131x_adapter *adapter); void et131x_enable_interrupts(struct et131x_adapter *adapter); void et131x_disable_interrupts(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index e166fde8997..8bff4a08fa7 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -750,10 +750,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Copy address into the net_device struct */ memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); - adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; - adapter->error_timer.function = et131x_error_timer_handler; - adapter->error_timer.data = (unsigned long)adapter; - /* Init variable for counting how long we do not have link status */ adapter->boot_coma = 0; et1310_disable_phy_coma(adapter); @@ -795,9 +791,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, /* Setup et1310 as per the documentation */ et131x_adapter_setup(adapter); - /* Create a timer to count errors received by the NIC */ - init_timer(&adapter->error_timer); - /* We can enable interrupts now * * NOTE - Because registration of interrupt handler is done in the diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 6ec4a0f2919..21846827e6c 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -187,6 +187,10 @@ int et131x_open(struct net_device *netdev) struct et131x_adapter *adapter = netdev_priv(netdev); /* Start the timer to track NIC errors */ + init_timer(&adapter->error_timer); + adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; + adapter->error_timer.function = et131x_error_timer_handler; + adapter->error_timer.data = (unsigned long)adapter; add_timer(&adapter->error_timer); /* Register our IRQ */ From 92c31a43e15a9ae1535ac234ab444a265fd0775c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:15 +0100 Subject: [PATCH 1311/1519] staging: et131x: Update TODO file for kernel parameters set_mac is implemented, and there have been lots of new ethtool_ops added, so removing the TODO to add more kernel parameters. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index a0ebaa0de53..b262ec7df1d 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - Implement a few more kernel Parameter (set mac ) Please send patches to: Greg Kroah-Hartman From 86d734fd1e8edcab411c80ae4447c97317f8d8b5 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:16 +0100 Subject: [PATCH 1312/1519] staging: et131x: Updating copyright statements and module authors Adding copyright notices and adding myself as a module author. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_address_map.h | 2 ++ drivers/staging/et131x/et1310_eeprom.c | 2 ++ drivers/staging/et131x/et1310_mac.c | 2 ++ drivers/staging/et131x/et1310_phy.c | 2 ++ drivers/staging/et131x/et1310_phy.h | 2 ++ drivers/staging/et131x/et1310_pm.c | 2 ++ drivers/staging/et131x/et1310_rx.c | 2 ++ drivers/staging/et131x/et1310_rx.h | 2 ++ drivers/staging/et131x/et1310_tx.c | 2 ++ drivers/staging/et131x/et131x_adapter.h | 2 ++ drivers/staging/et131x/et131x_defs.h | 2 ++ drivers/staging/et131x/et131x_ethtool.c | 4 +--- drivers/staging/et131x/et131x_initpci.c | 3 +++ drivers/staging/et131x/et131x_isr.c | 2 ++ drivers/staging/et131x/et131x_netdev.c | 2 ++ drivers/staging/et131x/et131x_version.h | 1 + 16 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h index 38ec56c1298..b502ce38cc2 100644 --- a/drivers/staging/et131x/et1310_address_map.h +++ b/drivers/staging/et131x/et1310_address_map.h @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_address_map.h - Contains the register mapping for the ET1310 diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c index e8102547e13..747b1dc803b 100644 --- a/drivers/staging/et131x/et1310_eeprom.c +++ b/drivers/staging/et131x/et1310_eeprom.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_eeprom.c - Code used to access the device's EEPROM diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 157462feeb6..b4c9df195a2 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_mac.c - All code and routines pertaining to the MAC diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index a72046ba0ac..145ec765bea 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_phy.c - Routines for configuring and accessing the PHY diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 82037ac7d93..2803bdf8c68 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_phy.h - Defines, structs, enums, prototypes, etc. pertaining to the diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index 55f2d3672b1..fd1eb6f3296 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_pm.c - All power management related code (not completely implemented) diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index c402c5e61e4..600a8f10da8 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_rx.c - Routines used to perform data reception diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h index 1448aa90996..a19fab997bc 100644 --- a/drivers/staging/et131x/et1310_rx.h +++ b/drivers/staging/et131x/et1310_rx.h @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_rx.h - Defines, structs, enums, prototypes, etc. pertaining to data diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index 1f806511f6c..2ecb934a55b 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et1310_tx.c - Routines used to perform data transmission. diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index b5195ef4f40..b062e6dc585 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et131x_adapter.h - Header which includes the private adapter structure, along diff --git a/drivers/staging/et131x/et131x_defs.h b/drivers/staging/et131x/et131x_defs.h index 3d5193fdb00..872a5afc357 100644 --- a/drivers/staging/et131x/et131x_defs.h +++ b/drivers/staging/et131x/et131x_defs.h @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et131x_defs.h - Defines, structs, enums, prototypes, etc. to assist with OS diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c index c4555b91a50..903b5a0ad85 100644 --- a/drivers/staging/et131x/et131x_ethtool.c +++ b/drivers/staging/et131x/et131x_ethtool.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Mark Einon + * Copyright (c) 2011 Mark Einon * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,8 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Mark Einon */ #include "et131x_version.h" #include "et131x_defs.h" diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 8bff4a08fa7..ed2261548d3 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et131x_initpci.c - Routines and data used to register the driver with the @@ -945,5 +947,6 @@ module_exit(et131x_cleanup_module); /* Modinfo parameters (filled out using defines from et131x_version.h) */ MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_AUTHOR(DRIVER_AUTHOR2); MODULE_DESCRIPTION(DRIVER_INFO); MODULE_LICENSE(DRIVER_LICENSE); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index fb108d202d3..bccd0e53323 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et131x_isr.c - File which contains the ISR, ISR handler, and related routines diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 21846827e6c..79127deebfc 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -6,6 +6,8 @@ * All rights reserved. * http://www.agere.com * + * Copyright (c) 2011 Mark Einon + * *------------------------------------------------------------------------------ * * et131x_netdev.c - Routines and data required by all Linux network devices. diff --git a/drivers/staging/et131x/et131x_version.h b/drivers/staging/et131x/et131x_version.h index 2aa9bda44ac..c08b5e588d2 100644 --- a/drivers/staging/et131x/et131x_version.h +++ b/drivers/staging/et131x/et131x_version.h @@ -59,6 +59,7 @@ #define __ET131X_VERSION_H__ #define DRIVER_AUTHOR "Victor Soriano (vjsoriano@agere.com)" +#define DRIVER_AUTHOR2 "Mark Einon (mark.einon@gmail.com)" #define DRIVER_LICENSE "Dual BSD/GPL" #define DRIVER_DEVICE_STRING "ET1310" #define DRIVER_NAME "et131x" From 8481085a83af02397ed0bf29c2bce517c9287f32 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 1 Oct 2011 11:14:17 +0100 Subject: [PATCH 1313/1519] staging: et131x: Fix indefinite low power sleep The mechanism by which the device is put into low power sleep is broken in that the device can never come back out of low power mode afterwards. Temorary fix to bring the device back out of sleep almost immediately, until a suitable wake trigger can be found. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_pm.c | 5 +++-- drivers/staging/et131x/et131x_initpci.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index fd1eb6f3296..a1b72bf8467 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -147,6 +147,8 @@ void et1310_enable_phy_coma(struct et131x_adapter *adapter) /* Wait for outstanding Receive packets */ + et131x_disable_txrx(adapter->netdev); + /* Gate off JAGCore 3 clock domains */ pmcsr &= ~ET_PMCSR_INIT; writel(pmcsr, &adapter->regs->global.pm_csr); @@ -198,7 +200,6 @@ void et1310_disable_phy_coma(struct et131x_adapter *adapter) /* Allow Tx to restart */ adapter->flags &= ~fMP_ADAPTER_LOWER_POWER; - /* Need to re-enable Rx. */ - et131x_rx_dma_enable(adapter); + et131x_enable_txrx(adapter->netdev); } diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index ed2261548d3..9795310fa71 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -243,10 +243,15 @@ void et131x_error_timer_handler(unsigned long data) struct et131x_adapter *adapter = (struct et131x_adapter *) data; struct phy_device *phydev = adapter->phydev; - if (!et1310_in_phy_coma(adapter)) + if (et1310_in_phy_coma(adapter)) { + /* Bring the device immediately out of coma, to + * prevent it from sleeping indefinitely, this + * mechanism could be improved! */ + et1310_disable_phy_coma(adapter); + adapter->boot_coma = 20; + } else { et1310_update_macstat_host_counters(adapter); - else - dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma\n"); + } if (!phydev->link && adapter->boot_coma < 11) adapter->boot_coma++; @@ -495,6 +500,7 @@ static void et131x_adjust_link(struct net_device *netdev) } else { dev_warn(&adapter->pdev->dev, "Link down - cable problem ?\n"); + adapter->boot_coma = 0; if (phydev && phydev->speed == SPEED_10) { /* NOTE - Is there a way to query this without From 4d8daa6b77d0697ea19b9c4f704be9b26d76fb36 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 4 Oct 2011 23:18:47 +0200 Subject: [PATCH 1314/1519] staging: brcm80211: cleaned up struct brcms_bss_cfg Several fields were unused or were only set once. They have been removed. Uncalled functions that relied on these constants have been removed as well. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 132 +--------------------- drivers/staging/brcm80211/brcmsmac/main.h | 38 ------- 2 files changed, 3 insertions(+), 167 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index de5f5c03499..efc6682fcbe 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1741,34 +1741,6 @@ void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); } -static void -brcms_c_write_hw_bcntemplate0(struct brcms_hardware *wlc_hw, u16 bcn[], - int len) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - - brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3, - bcn); - /* write beacon length to SCR */ - brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len); - /* mark beacon0 valid */ - OR_REG(®s->maccommand, MCMD_BCN0VLD); -} - -static void -brcms_c_write_hw_bcntemplate1(struct brcms_hardware *wlc_hw, u16 bcn[], - int len) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - - brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3, - bcn); - /* write beacon length to SCR */ - brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len); - /* mark beacon1 valid */ - OR_REG(®s->maccommand, MCMD_BCN1VLD); -} - static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) { u16 v; @@ -3288,8 +3260,7 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) if (!cfg->BSS) return false; - if (!cfg->dtim_programmed) - return false; + return false; } return true; @@ -3791,9 +3762,6 @@ void brcms_c_init(struct brcms_c_info *wlc) /* update beacon listen interval */ brcms_c_bcn_li_upd(wlc); - /* the world is new again, so is our reported rate */ - brcms_c_reprate_init(wlc); - /* write ethernet address to core */ brcms_c_set_mac(wlc->bsscfg); brcms_c_set_bssid(wlc->bsscfg); @@ -4054,17 +4022,12 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, static void brcms_c_setband(struct brcms_c_info *wlc, uint bandunit) { - struct brcms_bss_cfg *cfg = wlc->bsscfg; - wlc->band = wlc->bandstate[bandunit]; if (!wlc->pub->up) return; /* wait for at least one beacon before entering sleeping state */ - if (cfg->associated) - cfg->PMawakebcn = true; - brcms_c_set_ps_ctrl(wlc); /* band-specific initializations */ @@ -5357,7 +5320,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, goto fail; } - wlc->bsscfg->_idx = 0; wlc->bsscfg->wlc = wlc; wlc->mimoft = FT_HT; @@ -8763,82 +8725,6 @@ int brcms_c_get_header_len(void) return TXOFF; } -/* mac is assumed to be suspended at this point */ -static void -brcms_b_write_hw_bcntemplates(struct brcms_hardware *wlc_hw, u16 bcn[], - int len, bool both) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - - if (both) { - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } else { - /* bcn 0 */ - if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) - brcms_c_write_hw_bcntemplate0(wlc_hw, bcn, len); - /* bcn 1 */ - else if (! - (R_REG(®s->maccommand) & MCMD_BCN1VLD)) - brcms_c_write_hw_bcntemplate1(wlc_hw, bcn, len); - } -} - -static void brcms_c_write_hw_bcntemplates(struct brcms_c_info *wlc, u16 bcn[], - int len, bool both) -{ - brcms_b_write_hw_bcntemplates(wlc->hw, bcn, len, both); -} - -/* - * Update a beacon for a particular BSS - * For MBSS, this updates the software template and sets "latest" to - * the index of the template updated. Otherwise, it updates the hardware - * template. - */ -void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, - struct brcms_bss_cfg *cfg) -{ - int len = BCN_TMPL_LEN; - - /* Clear the soft intmask */ - wlc->defmacintmask &= ~MI_BCNTPL; - - if (!cfg->up) - /* Only allow updates on an UP bss */ - return; - - /* Optimize: Some of if/else could be combined */ - if ((cfg->flags & BRCMS_BSSCFG_HW_BCN) != 0) { - /* Hardware beaconing for this config */ - u16 bcn[BCN_TMPL_LEN / 2]; - u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD; - struct d11regs __iomem *regs = wlc->regs; - - /* Check if both templates are in use, if so sched. an interrupt - * that will call back into this routine - */ - if ((R_REG(®s->maccommand) & both_valid) == both_valid) - /* clear any previous status */ - W_REG(®s->macintstatus, MI_BCNTPL); - - /* Check that after scheduling the interrupt both of the - * templates are still busy. if not clear the int. & remask - */ - if ((R_REG(®s->maccommand) & both_valid) == both_valid) { - wlc->defmacintmask |= MI_BCNTPL; - return; - } - - wlc->bcn_rspec = - brcms_c_lowest_basic_rspec(wlc, &cfg->current_bss->rateset); - /* update the template and ucode shm */ - brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_BEACON, - wlc->bcn_rspec, cfg, bcn, &len); - brcms_c_write_hw_bcntemplates(wlc, bcn, len, false); - } -} - /* * Update all beacons for the system. */ @@ -8847,7 +8733,8 @@ void brcms_c_update_beacon(struct brcms_c_info *wlc) struct brcms_bss_cfg *bsscfg = wlc->bsscfg; if (bsscfg->up && !bsscfg->BSS) - brcms_c_bss_update_beacon(wlc, bsscfg); + /* Clear the soft intmask */ + wlc->defmacintmask &= ~MI_BCNTPL; } /* Write ssid into shared memory */ @@ -8946,19 +8833,6 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) return 0; } -/* init tx reported rate mechanism */ -void brcms_c_reprate_init(struct brcms_c_info *wlc) -{ - brcms_c_bsscfg_reprate_init(wlc->bsscfg); -} - -/* per bsscfg init tx reported rate mechanism */ -void brcms_c_bsscfg_reprate_init(struct brcms_bss_cfg *bsscfg) -{ - bsscfg->txrspecidx = 0; - memset((char *)bsscfg->txrspec, 0, sizeof(bsscfg->txrspec)); -} - void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) { brcms_c_rateset_default(rs, NULL, wlc->band->phytype, diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index e4589167f6d..9e1575c99b9 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -634,35 +634,18 @@ struct antsel_info { * enable: is this configuration enabled * associated: is BSS in ASSOCIATED state * BSS: infraustructure or adhoc - * dtim_programmed: * SSID_len: the length of SSID * SSID: SSID string - * bcmc_scb: one bcmc_scb per band - * _idx: the index of this bsscfg, assigned at wlc_bsscfg_alloc() * * * BSSID: BSSID (associated) * cur_etheraddr: h/w address - * bcmc_fid: the last BCMC FID queued to TX_BCMC_FIFO - * bcmc_fid_shm: the last BCMC FID written to shared mem * flags: BSSCFG flags; see below - * bcn: AP beacon - * bcn_len: AP beacon length - * ar_disassoc: disassociated in associated recreation * * current_bss: BSS parms in ASSOCIATED state * - * PM states - * --------- - * PMawakebcn: bcn recvd during current waking state - * PMpending: waiting for tx status with PM indicated set - * priorPMstate: Detecting PM state transitions - * PSpoll: flags there is an outstanding PS-Poll frame * * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation - * - * txrspecidx: index into tx rate circular buffer - * txrspec: circular buffer of prev MPDUs tx rates */ struct brcms_bss_cfg { struct brcms_c_info *wlc; @@ -670,27 +653,11 @@ struct brcms_bss_cfg { bool enable; bool associated; bool BSS; - bool dtim_programmed; u8 SSID_len; u8 SSID[IEEE80211_MAX_SSID_LEN]; - struct scb *bcmc_scb[MAXBANDS]; - s8 _idx; u8 BSSID[ETH_ALEN]; u8 cur_etheraddr[ETH_ALEN]; - u16 bcmc_fid; - u16 bcmc_fid_shm; - u32 flags; - u8 *bcn; - uint bcn_len; - bool ar_disassoc; struct brcms_bss_info *current_bss; - bool PMawakebcn; - bool PMpending; - bool priorPMstate; - bool PSpoll; - u16 ID; - uint txrspecidx; - u32 txrspec[NTXRATE][2]; }; extern void brcms_c_fatal_error(struct brcms_c_info *wlc); @@ -765,9 +732,6 @@ extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw, struct ieee80211_sta *sta, void (*dma_callback_fn)); -extern void brcms_c_reprate_init(struct brcms_c_info *wlc); -extern void brcms_c_bsscfg_reprate_init(struct brcms_bss_cfg *bsscfg); - /* Shared memory access */ extern void brcms_c_write_shm(struct brcms_c_info *wlc, uint offset, u16 v); extern u16 brcms_c_read_shm(struct brcms_c_info *wlc, uint offset); @@ -775,8 +739,6 @@ extern void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, const void *buf, int len); extern void brcms_c_update_beacon(struct brcms_c_info *wlc); -extern void brcms_c_bss_update_beacon(struct brcms_c_info *wlc, - struct brcms_bss_cfg *bsscfg); extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend); extern void brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, From 215f311b5b08a50765fc1a510e08a701498cd474 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 4 Oct 2011 23:18:48 +0200 Subject: [PATCH 1315/1519] staging: brcm80211: remove setting ssn to zero upon AMPDU_TX_START The ssn should be given a valid value by the driver or it should not override the value. Removed override to zero from the driver. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index 6787498cb04..c5afeaf69d9 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -669,11 +669,6 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, tid); return -EINVAL; } - /* - * Future improvement: - * Use the starting sequence number provided ... - */ - *ssn = 0; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); break; From 67064f27ab1b13152dc0d21423a14499fd5c34e2 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 4 Oct 2011 23:18:49 +0200 Subject: [PATCH 1316/1519] staging: brcm80211: remove filtering of received frames In the receive path of the brcmsmac driver probe request frames and frames with invalid mac address fields are dropped. This is only fine for STA mode. Anticipating coming AP and monitor mode functionality this is unwanted behavior. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index efc6682fcbe..39b91d6b763 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -8238,29 +8238,8 @@ void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) goto toss; + /* not supporting A-MSDU */ is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; - - /* explicitly test bad src address to avoid sending bad deauth */ - if (!is_amsdu) { - /* CTS and ACK CTL frames are w/o a2 */ - - if (ieee80211_is_data(h->frame_control) || - ieee80211_is_mgmt(h->frame_control)) { - if ((is_zero_ether_addr(h->addr2) || - is_multicast_ether_addr(h->addr2))) { - wiphy_err(wlc->wiphy, "wl%d: %s: dropping a " - "frame with invalid src mac address," - " a2: %pM\n", - wlc->pub->unit, __func__, h->addr2); - goto toss; - } - } - } - - /* due to sheer numbers, toss out probe reqs for now */ - if (ieee80211_is_probe_req(h->frame_control)) - goto toss; - if (is_amsdu) goto toss; From 412e4fdf124a6747d789035fa641c06243afaabf Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 4 Oct 2011 23:18:50 +0200 Subject: [PATCH 1317/1519] staging: brcm80211: remove brcmu_bprintf and related functions The functions brcmu_bprintf and brcmu_binit could be replaced by snprintf kernel function. These are no longer used in both brcm80211 drivers so they have been removed. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/types.h | 1 - drivers/staging/brcm80211/brcmutil/utils.c | 34 ------------------- .../staging/brcm80211/include/brcmu_utils.h | 15 -------- 3 files changed, 50 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h index 23969fe9006..27a814b0746 100644 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ b/drivers/staging/brcm80211/brcmsmac/types.h @@ -329,7 +329,6 @@ struct ieee80211_tx_queue_params; struct brcms_info; struct brcms_c_info; struct brcms_hardware; -struct brcmu_strbuf; struct brcms_txq_info; struct brcms_band; struct dma_pub; diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c index 1fe47fe66e3..62bcc71eadf 100644 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ b/drivers/staging/brcm80211/brcmutil/utils.c @@ -598,37 +598,3 @@ uint brcmu_bitcount(u8 *bitmap, uint length) return bitcount; } EXPORT_SYMBOL(brcmu_bitcount); - -/* Initialization of brcmu_strbuf structure */ -void brcmu_binit(struct brcmu_strbuf *b, char *buf, uint size) -{ - b->origsize = b->size = size; - b->origbuf = b->buf = buf; -} -EXPORT_SYMBOL(brcmu_binit); - -/* Buffer sprintf wrapper to guard against buffer overflow */ -int brcmu_bprintf(struct brcmu_strbuf *b, const char *fmt, ...) -{ - va_list ap; - int r; - - va_start(ap, fmt); - r = vsnprintf(b->buf, b->size, fmt, ap); - - /* Non Ansi C99 compliant returns -1, - * Ansi compliant return r >= b->size, - * stdlib returns 0, handle all - */ - if ((r == -1) || (r >= (int)b->size) || (r == 0)) { - b->size = 0; - } else { - b->size -= r; - b->buf += r; - } - - va_end(ap); - - return r; -} -EXPORT_SYMBOL(brcmu_bprintf); diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h index cf34bd3e252..a7d3df23661 100644 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ b/drivers/staging/brcm80211/include/brcmu_utils.h @@ -19,18 +19,6 @@ #include -/* Buffer structure for collecting string-formatted data -* using brcmu_bprintf() API. -* Use brcmu_binit() to initialize before use -*/ - -struct brcmu_strbuf { - char *buf; /* pointer to current position in origbuf */ - unsigned int size; /* current (residual) size in bytes */ - char *origbuf; /* unmodified pointer to orignal buffer */ - unsigned int origsize; /* unmodified orignal buffer size in bytes */ -}; - /* * Spin at most 'us' microseconds while 'exp' is true. * Caller should explicitly test 'exp' when this completes @@ -228,9 +216,6 @@ extern struct brcmu_tlv *brcmu_parse_tlvs(void *buf, int buflen, extern u16 brcmu_qdbm_to_mw(u8 qdbm); extern u8 brcmu_mw_to_qdbm(u16 mw); -extern void brcmu_binit(struct brcmu_strbuf *b, char *buf, uint size); -extern int brcmu_bprintf(struct brcmu_strbuf *b, const char *fmt, ...); - extern uint brcmu_mkiovar(char *name, char *data, uint datalen, char *buf, uint len); extern uint brcmu_bitcount(u8 *bitmap, uint bytelength); From e6cfdf6850ac5557ef6b660d30a5809822cb8bfb Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 4 Oct 2011 23:18:51 +0200 Subject: [PATCH 1318/1519] staging: brcm80211: replace brcmu_bitcount with hweight8 The kernel provides bit operations to replace brcmu_bitcount so using those instead. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 7 +++---- drivers/staging/brcm80211/brcmsmac/stf.c | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 45e3b4b294f..0d3c9d87c5e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -15,6 +15,7 @@ */ #include #include +#include #include #include @@ -2879,8 +2880,7 @@ void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) pi->sh->hw_phyrxchain = rxchain; pi->sh->phytxchain = txchain; pi->sh->phyrxchain = rxchain; - pi->pubpi.phy_corenum = (u8) brcmu_bitcount((u8 *)&pi->sh->phyrxchain, - sizeof(u8)); + pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); } void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) @@ -2892,8 +2892,7 @@ void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) if (ISNPHY(pi)) wlc_phy_rxcore_setstate_nphy(pih, rxchain); - pi->pubpi.phy_corenum = (u8) brcmu_bitcount((u8 *)&pi->sh->phyrxchain, - sizeof(u8)); + pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); } void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain) diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index ba3c3eff5f8..9460cd157f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -165,10 +165,10 @@ static int brcms_c_stf_txcore_set(struct brcms_c_info *wlc, u8 Nsts, BCMMSG(wlc->wiphy, "wl%d: Nsts %d core_mask %x\n", wlc->pub->unit, Nsts, core_mask); - if (BRCMS_BITSCNT(core_mask) > wlc->stf->txstreams) + if (hweight8(core_mask) > wlc->stf->txstreams) core_mask = 0; - if ((BRCMS_BITSCNT(core_mask) == wlc->stf->txstreams) && + if ((hweight8(core_mask) == wlc->stf->txstreams) && ((core_mask & ~wlc->stf->txchain) || !(core_mask & wlc->stf->txchain))) core_mask = wlc->stf->txchain; @@ -278,7 +278,7 @@ int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) * if nrate override is configured to be non-SISO STF mode, reject * reducing txchain to 1 */ - txstreams = (u8) BRCMS_BITSCNT(txchain); + txstreams = (u8) hweight8(txchain); if (txstreams > MAX_STREAMS_SUPPORTED) return -EINVAL; @@ -385,7 +385,7 @@ void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) } wlc->stf->txchain = wlc->stf->hw_txchain; - wlc->stf->txstreams = (u8) BRCMS_BITSCNT(wlc->stf->hw_txchain); + wlc->stf->txstreams = (u8) hweight8(wlc->stf->hw_txchain); if (wlc->stf->hw_rxchain == 0 || wlc->stf->hw_rxchain == 0xf) { if (BRCMS_ISNPHY(wlc->band)) @@ -395,7 +395,7 @@ void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) } wlc->stf->rxchain = wlc->stf->hw_rxchain; - wlc->stf->rxstreams = (u8) BRCMS_BITSCNT(wlc->stf->hw_rxchain); + wlc->stf->rxstreams = (u8) hweight8(wlc->stf->hw_rxchain); /* initialize the txcore table */ memcpy(wlc->stf->txcore, txcore_default, sizeof(wlc->stf->txcore)); From c18692e701647e6b204dcec42eb66f325048f537 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 4 Oct 2011 23:18:52 +0200 Subject: [PATCH 1319/1519] staging: brcm80211: fullmac: fixed double #include Fix double include as detected by checkincludes script. Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index d12aa75c46d..f7b3077aec9 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include From 019f45f27464e91cd1936a22600a05779bbe5573 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 4 Oct 2011 23:18:53 +0200 Subject: [PATCH 1320/1519] staging: brcm80211: clean up rtnl_lock in fullmac rtnl lock is used improperly in fullmac. This patch intends to clean them up. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Sukesh Srikakula Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 3 +++ .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 24 ++----------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 641cd9c7f04..804b2bc64b1 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1240,7 +1241,9 @@ void brcmf_detach(struct brcmf_pub *drvr) ifp = drvr_priv->iflist[0]; if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { + rtnl_lock(); brcmf_netdev_stop(ifp->ndev); + rtnl_unlock(); unregister_netdev(ifp->ndev); } diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index f7b3077aec9..fc643c1eb59 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -2223,10 +2222,8 @@ static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv) s32 err = 0; iscan->state = WL_ISCAN_STATE_IDLE; - rtnl_lock(); brcmf_inform_bss(cfg_priv); brcmf_notify_iscan_complete(iscan, false); - rtnl_unlock(); return err; } @@ -2248,10 +2245,8 @@ static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv) struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; s32 err = 0; - rtnl_lock(); brcmf_inform_bss(cfg_priv); brcmf_run_iscan(iscan, NULL, BRCMF_SCAN_ACTION_CONTINUE); - rtnl_unlock(); /* Reschedule the timer */ mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); iscan->timer_on = 1; @@ -2265,9 +2260,7 @@ static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv) s32 err = 0; iscan->state = WL_ISCAN_STATE_IDLE; - rtnl_lock(); brcmf_notify_iscan_complete(iscan, true); - rtnl_unlock(); return err; } @@ -2286,12 +2279,10 @@ static void brcmf_cfg80211_iscan_handler(struct work_struct *work) iscan->timer_on = 0; } - rtnl_lock(); if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) { status = BRCMF_SCAN_RESULTS_ABORTED; WL_ERR("Abort iscan\n"); } - rtnl_unlock(); el->handler[status](cfg_priv); } @@ -2408,9 +2399,7 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, * generated due to DISASSOC call to the fw to keep * the state fw and WPA_Supplicant state consistent */ - rtnl_unlock(); brcmf_delay(500); - rtnl_lock(); } set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); @@ -2978,7 +2967,6 @@ brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, u16 flags = be16_to_cpu(e->flags); enum nl80211_key_type key_type; - rtnl_lock(); if (flags & BRCMF_EVENT_MSG_GROUP) key_type = NL80211_KEYTYPE_GROUP; else @@ -2986,7 +2974,6 @@ brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, cfg80211_michael_mic_failure(ndev, (u8 *)&e->addr, key_type, -1, NULL, GFP_KERNEL); - rtnl_unlock(); return 0; } @@ -3563,8 +3550,7 @@ static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv) return wl_update_wiphybands(cfg_priv); } -static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, - bool need_lock) +static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv) { struct net_device *ndev; struct wireless_dev *wdev; @@ -3576,8 +3562,6 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, ndev = cfg_to_ndev(cfg_priv); wdev = ndev->ieee80211_ptr; - if (need_lock) - rtnl_lock(); brcmf_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME, WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME); @@ -3607,8 +3591,6 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv, /* -EINPROGRESS: Call commit handler */ default_conf_out: - if (need_lock) - rtnl_unlock(); cfg_priv->dongle_up = true; @@ -3658,7 +3640,7 @@ static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv) brcmf_debugfs_add_netdev_params(cfg_priv); - err = brcmf_config_dongle(cfg_priv, false); + err = brcmf_config_dongle(cfg_priv); if (err) return err; @@ -3683,9 +3665,7 @@ static s32 __brcmf_cfg80211_down(struct brcmf_cfg80211_priv *cfg_priv) generated due to DISASSOC call to the fw to keep the state fw and WPA_Supplicant state consistent */ - rtnl_unlock(); brcmf_delay(500); - rtnl_lock(); } set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); From a3b0b566cd1d0759d26d8357366bb80f08aa069a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 4 Oct 2011 23:18:54 +0200 Subject: [PATCH 1321/1519] staging: brcm80211: remove fullmac module_param for intr/poll mode Use constant for interrupt/polling mode configuration. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 5423280ba74..6c2391b9907 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -725,14 +725,6 @@ module_param(brcmf_dpc_prio, int, 0); #define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ -/* Use polling */ -uint brcmf_poll; -module_param(brcmf_poll, uint, 0); - -/* Use interrupts */ -uint brcmf_intr = true; -module_param(brcmf_intr, uint, 0); - #define RETRYCHAN(chan) ((chan) == SDPCM_EVENT_CHANNEL) /* Retry count for register access failures */ @@ -4324,8 +4316,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) BRCMF_SDALIGN); /* Set the poll and/or interrupt flags */ - bus->intr = (bool) brcmf_intr; - bus->poll = (bool) brcmf_poll; + bus->intr = true; + bus->poll = false; if (bus->poll) bus->pollrate = 1; From ef8299ddee722c32e6e7f30dc34bb108f7fc017b Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 4 Oct 2011 23:18:55 +0200 Subject: [PATCH 1322/1519] staging: brcm80211: stop using assigned thread priority in fullmac Stop assigning priority to watchdog and dpc threads. Remove related code. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 60 ++----------------- 1 file changed, 5 insertions(+), 55 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 6c2391b9907..f3e6249589e 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -715,14 +715,6 @@ static int qcount[NUMPRIO]; static int tx_packets[NUMPRIO]; #endif /* BCMDBG */ -/* Watchdog thread priority, -1 to use kernel timer */ -int brcmf_watchdog_prio = 97; -module_param(brcmf_watchdog_prio, int, 0); - -/* DPC thread priority, -1 to use tasklet */ -int brcmf_dpc_prio = 98; -module_param(brcmf_dpc_prio, int, 0); - #define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ #define RETRYCHAN(chan) ((chan) == SDPCM_EVENT_CHANNEL) @@ -2692,16 +2684,6 @@ static int brcmf_sdbrcm_dpc_thread(void *data) { struct brcmf_bus *bus = (struct brcmf_bus *) data; - /* This thread doesn't need any user-level access, - * so get rid of all our resources - */ - if (brcmf_dpc_prio > 0) { - struct sched_param param; - param.sched_priority = (brcmf_dpc_prio < MAX_RT_PRIO) ? - brcmf_dpc_prio : (MAX_RT_PRIO - 1); - sched_setscheduler(current, SCHED_FIFO, ¶m); - } - allow_signal(SIGTERM); /* Run until signal received */ while (1) { @@ -4364,16 +4346,6 @@ brcmf_sdbrcm_watchdog_thread(void *data) { struct brcmf_bus *bus = (struct brcmf_bus *)data; - /* This thread doesn't need any user-level access, - * so get rid of all our resources - */ - if (brcmf_watchdog_prio > 0) { - struct sched_param param; - param.sched_priority = (brcmf_watchdog_prio < MAX_RT_PRIO) ? - brcmf_watchdog_prio : (MAX_RT_PRIO - 1); - sched_setscheduler(current, SCHED_FIFO, ¶m); - } - allow_signal(SIGTERM); /* Run until signal received */ while (1) { @@ -4394,7 +4366,7 @@ brcmf_sdbrcm_watchdog(unsigned long data) { struct brcmf_bus *bus = (struct brcmf_bus *)data; - if (brcmf_watchdog_prio >= 0) { + if (bus->threads_only) { if (bus->watchdog_tsk) complete(&bus->watchdog_wait); else @@ -4493,6 +4465,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ + bus->threads_only = true; /* attempt to attach to the dongle */ if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { @@ -4510,14 +4483,9 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->timer.function = brcmf_sdbrcm_watchdog; /* Initialize thread based operation and lock */ - if ((brcmf_watchdog_prio >= 0) && (brcmf_dpc_prio >= 0)) { - bus->threads_only = true; + if (bus->threads_only) { sema_init(&bus->sdsem, 1); - } else { - bus->threads_only = false; - } - if (brcmf_dpc_prio >= 0) { /* Initialize watchdog thread */ init_completion(&bus->watchdog_wait); bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, @@ -4527,11 +4495,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, "brcmf_watchdog thread failed to start\n"); bus->watchdog_tsk = NULL; } - } else - bus->watchdog_tsk = NULL; - - /* Set up the bottom half handler */ - if (brcmf_dpc_prio >= 0) { /* Initialize DPC thread */ init_completion(&bus->dpc_wait); bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, @@ -4542,9 +4505,10 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->dpc_tsk = NULL; } } else { + bus->watchdog_tsk = NULL; + bus->dpc_tsk = NULL; tasklet_init(&bus->tasklet, brcmf_sdbrcm_dpc_tasklet, (unsigned long)bus); - bus->dpc_tsk = NULL; } /* Attach to the brcmf/OS/network interface */ @@ -4613,20 +4577,6 @@ int brcmf_bus_register(void) { brcmf_dbg(TRACE, "Enter\n"); - /* Sanity check on the module parameters */ - do { - /* Both watchdog and DPC as tasklets are ok */ - if ((brcmf_watchdog_prio < 0) && (brcmf_dpc_prio < 0)) - break; - - /* If both watchdog and DPC are threads, TX must be deferred */ - if (brcmf_watchdog_prio >= 0 && brcmf_dpc_prio >= 0) - break; - - brcmf_dbg(ERROR, "Invalid module parameters.\n"); - return -EINVAL; - } while (0); - return brcmf_sdio_register(); } From 406f8d656c6331e27f31713473c840c0d26d5c60 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:18:56 +0200 Subject: [PATCH 1323/1519] staging: brcm80211: fixed checkpatch warnings Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 14 ++++++-------- drivers/staging/brcm80211/brcmsmac/main.c | 3 +-- drivers/staging/brcm80211/brcmsmac/nicpci.c | 3 +-- drivers/staging/brcm80211/brcmsmac/srom.c | 3 +-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 0b3ba6a7474..8d4024e5080 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1054,9 +1054,8 @@ static struct si_info *ai_doattach(struct si_info *sii, cc = (struct chipcregs __iomem *) regs; /* bus/core/clk setup for register access */ - if (!ai_buscore_prep(sii)) { + if (!ai_buscore_prep(sii)) return NULL; - } /* * ChipID recognition. @@ -1084,19 +1083,18 @@ static struct si_info *ai_doattach(struct si_info *sii, return NULL; } /* no cores found, bail out */ - if (sii->numcores == 0) { + if (sii->numcores == 0) return NULL; - } + /* bus/core/clk setup */ origidx = SI_CC_IDX; - if (!ai_buscore_setup(sii, savewin, &origidx)) { + if (!ai_buscore_setup(sii, savewin, &origidx)) goto exit; - } /* Init nvram from sprom/otp if they exist */ - if (srom_var_init(&sii->pub, cc, vars, varsz)) { + if (srom_var_init(&sii->pub, cc, vars, varsz)) goto exit; - } + pvars = vars ? *vars : NULL; ai_nvram_process(sii, pvars); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 39b91d6b763..db05521a7ad 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5995,9 +5995,8 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) * If we are switching to gmode == GMODE_LEGACY_B, * clean up rate info that may refer to OFDM rates. */ - if ((gmode == GMODE_LEGACY_B) && (band->gmode != GMODE_LEGACY_B)) { + if ((gmode == GMODE_LEGACY_B) && (band->gmode != GMODE_LEGACY_B)) band->gmode = gmode; - } band->gmode = gmode; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index e3cce296220..460b1054695 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -394,9 +394,8 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) i++; } - if (i >= pcie_serdes_spinwait) { + if (i >= pcie_serdes_spinwait) return false; - } return true; } diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 6f3b12c0e0f..13d17ebe6df 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -1175,8 +1175,7 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, if (sromrev == 0x10) sromrev = 1; } - } - else { + } else { /* Use OTP if SPROM not available */ err = otp_read_pci(sih, srom, SROM_MAX); if (err == 0) From e9d3adbef45d8197cb597101624a43d180ac218c Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:18:57 +0200 Subject: [PATCH 1324/1519] staging: brcm80211: removed accessor functions for band type and etheraddress. Functions were trivial so not really adding value. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index db05521a7ad..b6c43619b9e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1369,16 +1369,6 @@ static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); } -static void brcms_b_hw_etheraddr(struct brcms_hardware *wlc_hw, u8 *ea) -{ - memcpy(ea, wlc_hw->etheraddr, ETH_ALEN); -} - -static int brcms_b_bandtype(struct brcms_hardware *wlc_hw) -{ - return wlc_hw->band->bandtype; -} - /* control chip clock to save power, enable dynamic clock or force fast clock */ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) { @@ -3939,7 +3929,7 @@ static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) { wlc_hw->shortslot = shortslot; - if (brcms_b_bandtype(wlc_hw) == BRCM_BAND_2G && wlc_hw->up) { + if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { brcms_c_suspend_mac_and_wait(wlc_hw->wlc); brcms_b_update_slot_timing(wlc_hw, shortslot); brcms_c_enable_mac(wlc_hw->wlc); @@ -4854,8 +4844,8 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, /* Get a phy for this band */ wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, regs, - brcms_b_bandtype(wlc_hw), vars, - wlc->wiphy); + wlc_hw->band->bandtype, vars, + wlc->wiphy); if (wlc_hw->band->pi == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" "attach failed\n", unit); @@ -5235,9 +5225,8 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, for (i = 0; i < NFIFO; i++) wlc->core->txavail[i] = wlc->hw->txavail[i]; - brcms_b_hw_etheraddr(wlc->hw, wlc->perm_etheraddr); - - memcpy(&pub->cur_etheraddr, &wlc->perm_etheraddr, ETH_ALEN); + memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); + memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); for (j = 0; j < wlc->pub->_nbands; j++) { wlc->band = wlc->bandstate[j]; From d64bc7c2866a6a4ee8f5bf4594ecf7a22ea3ebdf Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:18:58 +0200 Subject: [PATCH 1325/1519] staging: brcm80211: fixed function returns - removed unneeded return statements at end of functions. - changed return value of brcms_c_radio_monitor_start to void. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index b6c43619b9e..dc95ba0828a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1572,8 +1572,6 @@ void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, brcms_c_mctrl_write(wlc_hw); brcms_b_wait_for_wake(wlc_hw); - - return; } void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, @@ -1585,8 +1583,6 @@ void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, return; brcms_c_mctrl_write(wlc_hw); - - return; } /* When driver needs ucode to stop beaconing, it has to make sure that @@ -1607,8 +1603,6 @@ static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw) return; brcms_c_mctrl_write(wlc_hw); - - return; } /* Clear the override on AP and INFRA bits */ @@ -3217,8 +3211,6 @@ static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) brcms_b_xtal(wlc_hw, OFF); } } - - return; } static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) @@ -4308,17 +4300,16 @@ static void brcms_c_down_led_upd(struct brcms_c_info *wlc) brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); } -static bool brcms_c_radio_monitor_start(struct brcms_c_info *wlc) +static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) { /* Don't start the timer if HWRADIO feature is disabled */ if (wlc->radio_monitor) - return true; + return; wlc->radio_monitor = true; brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_RADIO_MON); brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); - return true; } void brcms_c_radio_disable(struct brcms_c_info *wlc) @@ -6123,8 +6114,6 @@ static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) r = wlc->default_bss->rateset.rates[0]; wlc_phy_ofdm_rateset_war(wlc->band->pi, war); - - return; } int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) @@ -7785,8 +7774,6 @@ brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) plcp[2] |= (tmp >> 16) & 0xff; plcp[1] |= (tmp >> 8) & 0xff; plcp[0] |= tmp & 0xff; - - return; } /* Rate: 802.11 rate code, length: PSDU length in octets */ @@ -7808,7 +7795,6 @@ brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, brcms_c_compute_ofdm_plcp(rspec, length, plcp); else brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); - return; } /* brcms_c_compute_rtscts_dur() @@ -7997,8 +7983,6 @@ brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, /* read the tsf timer low, then high to get an atomic read */ *tsf_l_ptr = R_REG(®s->tsf_timerlow); *tsf_h_ptr = R_REG(®s->tsf_timerhigh); - - return; } /* @@ -8175,7 +8159,6 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); - return; } /* Process received frames */ @@ -8683,8 +8666,6 @@ brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN); /* SEQ filled in by MAC */ - - return; } int brcms_c_get_header_len(void) From 23ed011ea97d9df57aeb8762dc690496c33b0a8f Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:18:59 +0200 Subject: [PATCH 1326/1519] staging: brcm80211: made NULL ethernet address const Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index dc95ba0828a..6a0a5d0c746 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -2646,7 +2646,7 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) { - u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; if (on) { /* suspend tx fifos */ From dd5be5ea7ed42f41cafa1ce7b1e824f46affda0e Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:00 +0200 Subject: [PATCH 1327/1519] staging: brcm80211: removed empty brcms_c_reset_bmac_done callback function Empty functions are good candidates for removal. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 6 ------ drivers/staging/brcm80211/brcmsmac/main.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 6a0a5d0c746..d75756d8989 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3258,8 +3258,6 @@ static void brcms_b_reset(struct brcms_hardware *wlc_hw) /* purge the dma rings */ brcms_c_flushqueues(wlc_hw->wlc); - - brcms_c_reset_bmac_done(wlc_hw->wlc); } void brcms_c_reset(struct brcms_c_info *wlc) @@ -8868,10 +8866,6 @@ void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit) brcms_b_pllreq(wlc->hw, set, req_bit); } -void brcms_c_reset_bmac_done(struct brcms_c_info *wlc) -{ -} - /* check for the particular priority flow control bit being set */ bool brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc, diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 9e1575c99b9..5a2ec539602 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -677,7 +677,6 @@ extern int brcms_c_xmtfifo_sz_get(struct brcms_c_info *wlc, uint fifo, extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, void *buf); extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit); -extern void brcms_c_reset_bmac_done(struct brcms_c_info *wlc); #if defined(BCMDBG) extern void brcms_c_print_rxh(struct d11rxhdr *rxh); From 96b74847813ace67a7778c9f0c86958b17b36d3c Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:01 +0200 Subject: [PATCH 1328/1519] staging: brcm80211: decreased indentation level of brcms_c_wme_setparams function Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 36 ++++++++++------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index d75756d8989..33497164ac6 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4199,26 +4199,23 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, return; } - do { - memset((char *)&acp_shm, 0, sizeof(struct shm_acparams)); - /* fill in shm ac params struct */ - acp_shm.txop = params->txop; - /* convert from units of 32us to us for ucode */ - wlc->edcf_txop[aci & 0x3] = acp_shm.txop = - EDCF_TXOP2USEC(acp_shm.txop); - acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); + memset((char *)&acp_shm, 0, sizeof(struct shm_acparams)); + /* fill in shm ac params struct */ + acp_shm.txop = params->txop; + /* convert from units of 32us to us for ucode */ + wlc->edcf_txop[aci & 0x3] = acp_shm.txop = + EDCF_TXOP2USEC(acp_shm.txop); + acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); - if (aci == AC_VI && acp_shm.txop == 0 - && acp_shm.aifs < EDCF_AIFSN_MAX) - acp_shm.aifs++; - - if (acp_shm.aifs < EDCF_AIFSN_MIN - || acp_shm.aifs > EDCF_AIFSN_MAX) { - wiphy_err(wlc->wiphy, "wl%d: edcf_setparams: bad " - "aifs %d\n", wlc->pub->unit, acp_shm.aifs); - continue; - } + if (aci == AC_VI && acp_shm.txop == 0 + && acp_shm.aifs < EDCF_AIFSN_MAX) + acp_shm.aifs++; + if (acp_shm.aifs < EDCF_AIFSN_MIN + || acp_shm.aifs > EDCF_AIFSN_MAX) { + wiphy_err(wlc->wiphy, "wl%d: edcf_setparams: bad " + "aifs %d\n", wlc->pub->unit, acp_shm.aifs); + } else { acp_shm.cwmin = params->cw_min; acp_shm.cwmax = params->cw_max; acp_shm.cwcur = acp_shm.cwmin; @@ -4239,8 +4236,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, M_EDCF_QINFO + wme_ac2fifo[aci] * M_EDCF_QLEN + i, *shm_entry++); - - } while (0); + } if (suspend) brcms_c_suspend_mac_and_wait(wlc); From b2d62733e6ea427921e201269c1b55bca3a87936 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:02 +0200 Subject: [PATCH 1329/1519] staging: brcm80211: removed redundant code from brcms_c_set_gmode The comment says the rateset is being cleared when switching to GMODE_LEGACY_B, but the code that follows it does not do so. Besides, the rateset is already valid at this point. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 33497164ac6..9988e03b7cf 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5965,13 +5965,6 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) return -ENOTSUPP; } - /* - * If we are switching to gmode == GMODE_LEGACY_B, - * clean up rate info that may refer to OFDM rates. - */ - if ((gmode == GMODE_LEGACY_B) && (band->gmode != GMODE_LEGACY_B)) - band->gmode = gmode; - band->gmode = gmode; wlc->shortslot_override = shortslot; From 702e1430bdab6a184d9f34881ab6da832c7fbae5 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:03 +0200 Subject: [PATCH 1330/1519] staging: brcm80211: cleanup of shared memory related wrapper functions - removed brcms_c_read_shm and brcms_c_write_shm functions. - removed redundant argument check from brcms_c_copyto_shm function. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 10 +-- drivers/staging/brcm80211/brcmsmac/antsel.c | 4 +- drivers/staging/brcm80211/brcmsmac/main.c | 78 +++++++++------------ drivers/staging/brcm80211/brcmsmac/main.h | 2 - 4 files changed, 41 insertions(+), 53 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index e29c62efeb1..506c392e8cd 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -369,7 +369,7 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) u16 cur_txunfl; /* return if we got here for a different reason than underflows */ - cur_txunfl = brcms_c_read_shm(wlc, + cur_txunfl = brcms_b_read_shm(wlc->hw, M_UCODE_MACSTAT + offsetof(struct macstat, txfunfl[fid])); new_txunfl = (u16) (cur_txunfl - fifo->prev_txfunfl); @@ -1182,11 +1182,11 @@ void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu) */ if ((ampdu->rx_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) == IEEE80211_HT_MAX_AMPDU_64K) { - brcms_c_write_shm(wlc, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX); - brcms_c_write_shm(wlc, M_WATCHDOG_8TU, WATCHDOG_8TU_MAX); + brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX); + brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_MAX); } else { - brcms_c_write_shm(wlc, M_MIMO_MAXSYM, MIMO_MAXSYM_DEF); - brcms_c_write_shm(wlc, M_WATCHDOG_8TU, WATCHDOG_8TU_DEF); + brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_DEF); + brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_DEF); } } diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index c61c5202446..c2aa47bc1dc 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -206,7 +206,7 @@ static int brcms_c_antsel_cfgupd(struct antsel_info *asi, */ ant_cfg = antsel->ant_config[ANT_SELCFG_TX_DEF]; mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); - brcms_c_write_shm(wlc, M_MIMO_ANTSEL_TXDFLT, mimo_antsel); + brcms_b_write_shm(wlc->hw, M_MIMO_ANTSEL_TXDFLT, mimo_antsel); /* * Update driver stats for currently selected * default tx/rx antenna config @@ -218,7 +218,7 @@ static int brcms_c_antsel_cfgupd(struct antsel_info *asi, */ ant_cfg = antsel->ant_config[ANT_SELCFG_RX_DEF]; mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); - brcms_c_write_shm(wlc, M_MIMO_ANTSEL_RXDFLT, mimo_antsel); + brcms_b_write_shm(wlc->hw, M_MIMO_ANTSEL_RXDFLT, mimo_antsel); /* * Update driver stats for currently selected * default tx/rx antenna config diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 9988e03b7cf..5d3bfda9a72 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3104,17 +3104,26 @@ brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, W_REG(objdata_lo, v); } +/* + * Read a single u16 from shared memory. + * SHM 'offset' needs to be an even address + */ u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) { return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); } +/* + * Write a single u16 to shared memory. + * SHM 'offset' needs to be an even address + */ void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) { brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); } -/* Copy a buffer to shared memory of specified type . +/* + * Copy a buffer to shared memory of specified type . * SHM 'offset' needs to be an even address and * Buffer length 'len' must be an even number of bytes * 'sel' selects the type of memory @@ -3136,7 +3145,8 @@ brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset, } } -/* Copy a piece of shared memory of specified type to a buffer . +/* + * Copy a piece of shared memory of specified type to a buffer . * SHM 'offset' needs to be an even address and * Buffer length 'len' must be an even number of bytes * 'sel' selects the type of memory @@ -3627,7 +3637,8 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) * inits to populate a bogus beacon. */ if (BRCMS_PHY_11N_CAP(wlc->band)) - brcms_c_write_shm(wlc, M_BCN_TXTSF_OFFSET, 0); + brcms_b_write_shm(wlc->hw, + M_BCN_TXTSF_OFFSET, 0); } } else { /* disable an active IBSS if we are not on the home channel */ @@ -3673,7 +3684,7 @@ brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; /* Only write to shared memory when wl is up */ if (writeToShm) - brcms_c_write_shm(wlc, offset, (u16) idle_busy_ratio_x_16); + brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); if (isOFDM) wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; @@ -3766,10 +3777,10 @@ void brcms_c_init(struct brcms_c_info *wlc) brcms_c_bandinit_ordered(wlc, chanspec); /* init probe response timeout */ - brcms_c_write_shm(wlc, M_PRS_MAXTIME, wlc->prb_resp_timeout); + brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); /* init max burst txop (framebursting) */ - brcms_c_write_shm(wlc, M_MBURST_TXOP, + brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, (wlc-> _rifs ? (EDCF_AC_VO_TXOP_AP << 5) : MAXFRAMEBURST_TXOP)); @@ -3796,8 +3807,8 @@ void brcms_c_init(struct brcms_c_info *wlc) /* read the ucode version if we have not yet done so */ if (wlc->ucode_rev == 0) { wlc->ucode_rev = - brcms_c_read_shm(wlc, M_BOM_REV_MAJOR) << NBITS(u16); - wlc->ucode_rev |= brcms_c_read_shm(wlc, M_BOM_REV_MINOR); + brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR) << NBITS(u16); + wlc->ucode_rev |= brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); } /* ..now really unleash hell (allow the MAC out of suspend) */ @@ -3822,7 +3833,7 @@ void brcms_c_init(struct brcms_c_info *wlc) for (ac = 0; ac < AC_COUNT; ac++) wlc->wme_retries[ac] = - brcms_c_read_shm(wlc, M_AC_TXLMT_ADDR(ac)); + brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); } } @@ -4110,9 +4121,9 @@ void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, if (BRCMS_PHY_11N_CAP(wlc->band)) phytxant = brcms_c_stf_phytxchain_sel(wlc, bcn_rspec); - phyctl = brcms_c_read_shm(wlc, M_BCN_PCTLWD); + phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); phyctl = (phyctl & ~mask) | phytxant; - brcms_c_write_shm(wlc, M_BCN_PCTLWD, phyctl); + brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); } /* @@ -4223,7 +4234,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; /* Indicate the new params to the ucode */ - acp_shm.status = brcms_c_read_shm(wlc, (M_EDCF_QINFO + + acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + wme_ac2fifo[aci] * M_EDCF_QLEN + M_EDCF_STATUS_OFF)); @@ -4232,7 +4243,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, /* Fill in shm acparam table */ shm_entry = (u16 *) &acp_shm; for (i = 0; i < (int)sizeof(struct shm_acparams); i += 2) - brcms_c_write_shm(wlc, + brcms_b_write_shm(wlc->hw, M_EDCF_QINFO + wme_ac2fifo[aci] * M_EDCF_QLEN + i, *shm_entry++); @@ -5642,7 +5653,7 @@ static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) return; for (ac = 0; ac < AC_COUNT; ac++) - brcms_c_write_shm(wlc, M_AC_TXLMT_ADDR(ac), + brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), wlc->wme_retries[ac]); } @@ -7955,9 +7966,9 @@ void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) { /* wake up every DTIM is the default */ if (wlc->bcn_li_dtim == 1) - brcms_c_write_shm(wlc, M_BCN_LI, 0); + brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); else - brcms_c_write_shm(wlc, M_BCN_LI, + brcms_b_write_shm(wlc->hw, M_BCN_LI, (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); } @@ -8453,12 +8464,12 @@ static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, /* Find the SHM pointer to the ACK rate entry by looking in the * Direct-map Table */ - basic_ptr = brcms_c_read_shm(wlc, (dir_table + basic_index * 2)); + basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); /* Update the SHM BSS-basic-rate-set mapping table with the pointer * to the correct basic rate for the given incoming rate */ - brcms_c_write_shm(wlc, (basic_table + index * 2), basic_ptr); + brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); } static const struct brcms_c_rateset * @@ -8584,11 +8595,11 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) dur += sifs; /* Update the SHM Rate Table entry Probe Response values */ - brcms_c_write_shm(wlc, entry_ptr + M_RT_PRS_PLCP_POS, + brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, (u16) (plcp[0] + (plcp[1] << 8))); - brcms_c_write_shm(wlc, entry_ptr + M_RT_PRS_PLCP_POS + 2, + brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, (u16) (plcp[2] + (plcp[3] << 8))); - brcms_c_write_shm(wlc, entry_ptr + M_RT_PRS_DUR_POS, dur); + brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); } } @@ -8684,7 +8695,7 @@ void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) memcpy(ssidbuf, ssidptr, cfg->SSID_len); brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); - brcms_c_write_shm(wlc, M_SSIDLEN, (u16) cfg->SSID_len); + brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); } void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) @@ -8721,7 +8732,7 @@ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, (len + 3) & ~3, prb_resp); /* write the length of the probe response frame (+PLCP/-FCS) */ - brcms_c_write_shm(wlc, M_PRB_RESP_FRM_LEN, (u16) len); + brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); /* write the SSID and SSID length */ brcms_c_shm_ssid_upd(wlc, cfg); @@ -8777,22 +8788,6 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) wlc->stf->txstreams); } -/* Read a single u16 from shared memory. - * SHM 'offset' needs to be an even address - */ -u16 brcms_c_read_shm(struct brcms_c_info *wlc, uint offset) -{ - return brcms_b_read_shm(wlc->hw, offset); -} - -/* Write a single u16 to shared memory. - * SHM 'offset' needs to be an even address - */ -void brcms_c_write_shm(struct brcms_c_info *wlc, uint offset, u16 v) -{ - brcms_b_write_shm(wlc->hw, offset, v); -} - /* Copy a buffer to shared memory. * SHM 'offset' needs to be an even address and * Buffer length 'len' must be an even number of bytes @@ -8800,12 +8795,7 @@ void brcms_c_write_shm(struct brcms_c_info *wlc, uint offset, u16 v) void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, const void *buf, int len) { - /* offset and len need to be even */ - if (len <= 0 || (offset & 1) || (len & 1)) - return; - brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); - } /* wrapper BMAC functions to for HIGH driver access */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 5a2ec539602..6512e7a7817 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -732,8 +732,6 @@ extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw, void (*dma_callback_fn)); /* Shared memory access */ -extern void brcms_c_write_shm(struct brcms_c_info *wlc, uint offset, u16 v); -extern u16 brcms_c_read_shm(struct brcms_c_info *wlc, uint offset); extern void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, const void *buf, int len); From 62b54fca4bbeeed007fdef6ac57508685ec2c239 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:04 +0200 Subject: [PATCH 1331/1519] staging: brcm80211: cleanup of transmit buffer size related wrapper function Removed brcms_c_xmtfifo_sz_get function. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.c | 7 +------ drivers/staging/brcm80211/brcmsmac/main.h | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index 506c392e8cd..fc499008fe7 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -383,7 +383,7 @@ static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) return 1; /* check if fifo is big enough */ - if (brcms_c_xmtfifo_sz_get(wlc, fid, &xmtfifo_sz)) + if (brcms_b_xmtfifo_sz_get(wlc->hw, fid, &xmtfifo_sz)) return -1; if ((TXFIFO_SIZE_UNIT * (u32) xmtfifo_sz) <= ampdu->ffpld_rsvd) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 5d3bfda9a72..cbed10cbb46 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -8809,7 +8809,7 @@ void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, int bands) brcms_b_mhf(wlc->hw, idx, mask, val, bands); } -static int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, +int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, uint *blocks) { if (fifo >= NFIFO) @@ -8820,11 +8820,6 @@ static int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, return 0; } -int brcms_c_xmtfifo_sz_get(struct brcms_c_info *wlc, uint fifo, uint *blocks) -{ - return brcms_b_xmtfifo_sz_get(wlc->hw, fifo, blocks); -} - void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, void *buf) { diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 6512e7a7817..a71c5099109 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -672,8 +672,8 @@ extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, struct sk_buff *sdu, uint prec); extern void brcms_c_info_init(struct brcms_c_info *wlc, int unit); extern void brcms_c_print_txstatus(struct tx_status *txs); -extern int brcms_c_xmtfifo_sz_get(struct brcms_c_info *wlc, uint fifo, - uint *blocks); +extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, + uint *blocks); extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, void *buf); extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit); From eda075b546ec6beb8bc12f4fbad47688636122ff Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:05 +0200 Subject: [PATCH 1332/1519] staging: brcm80211: cleanup of several wrapper functions - removed brcms_c_write_template_ram function. - removed brcms_c_mctrl function. - removed brcms_c_pllreq function. - removed brcms_c_mhf function. - removed brcms_c_rate_shm_offset function. - removed brcms_c_write_hw_bcntemplates function. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/ampdu.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.c | 51 +++++----------------- drivers/staging/brcm80211/brcmsmac/main.h | 3 -- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c index fc499008fe7..7f27dbdb6b6 100644 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/ampdu.c @@ -1162,7 +1162,7 @@ void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc) /* driver needs to write the ta in the template; ta is at offset 16 */ memset(template, 0, sizeof(template)); memcpy(template, wlc->pub->cur_etheraddr, ETH_ALEN); - brcms_c_write_template_ram(wlc, (T_BA_TPL_BASE + 16), + brcms_b_write_template_ram(wlc->hw, (T_BA_TPL_BASE + 16), (T_RAM_ACCESS_SZ * 2), template); } diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index cbed10cbb46..bd38f33b13e 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3846,9 +3846,9 @@ void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) { if (wlc->bcnmisc_monitor) - brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); + brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); else - brcms_c_mctrl(wlc, MCTL_BCNS_PROMISC, 0); + brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, 0); } /* set or clear maccontrol bits MCTL_PROMISC and MCTL_KEEPCONTROL */ @@ -3872,7 +3872,7 @@ void brcms_c_mac_promisc(struct brcms_c_info *wlc) if (wlc->monitor) promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; - brcms_c_mctrl(wlc, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); + brcms_b_mctrl(wlc->hw, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); } /* push sw hps and wake state through hardware */ @@ -3891,7 +3891,7 @@ void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) if (hps) v2 |= MCTL_HPS; - brcms_c_mctrl(wlc, MCTL_WAKE | MCTL_HPS, v2); + brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); awake_before = ((v1 & MCTL_WAKE) || ((v1 & MCTL_HPS) == 0)); @@ -4301,8 +4301,8 @@ static void brcms_c_down_led_upd(struct brcms_c_info *wlc) * maintain LEDs while in down state, turn on sbclk if * not available yet. Turn on sbclk if necessary */ - brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_FLIP); - brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_FLIP); + brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_FLIP); + brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_FLIP); } static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) @@ -4312,7 +4312,7 @@ static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) return; wlc->radio_monitor = true; - brcms_c_pllreq(wlc, true, BRCMS_PLLREQ_RADIO_MON); + brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); } @@ -4345,7 +4345,7 @@ bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) return true; wlc->radio_monitor = false; - brcms_c_pllreq(wlc, false, BRCMS_PLLREQ_RADIO_MON); + brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); return brcms_del_timer(wlc->wl, wlc->radio_timer); } @@ -5675,10 +5675,10 @@ int brcms_c_up(struct brcms_c_info *wlc) && (wlc->pub->sih->chip == BCM4313_CHIP_ID)) { if (wlc->pub->boardrev >= 0x1250 && (wlc->pub->boardflags & BFL_FEM_BT)) - brcms_c_mhf(wlc, MHF5, MHF5_4313_GPIOCTRL, + brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, MHF5_4313_GPIOCTRL, BRCM_BAND_ALL); else - brcms_c_mhf(wlc, MHF4, MHF4_EXTPA_ENABLE, + brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, MHF4_EXTPA_ENABLE, BRCM_BAND_ALL); } @@ -5720,7 +5720,7 @@ int brcms_c_up(struct brcms_c_info *wlc) brcms_c_radio_monitor_stop(wlc); /* Set EDCF hostflags */ - brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); + brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); brcms_init(wlc->wl); wlc->pub->up = true; @@ -6578,11 +6578,6 @@ u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); } -static u16 brcms_c_rate_shm_offset(struct brcms_c_info *wlc, u8 rate) -{ - return brcms_b_rate_shm_offset(wlc->hw, rate); -} - /* Callback for device removed */ /* @@ -8581,7 +8576,7 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) for (i = 0; i < rs.count; i++) { rate = rs.rates[i] & BRCMS_RATE_MASK; - entry_ptr = brcms_c_rate_shm_offset(wlc, rate); + entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); /* Calculate the Probe Response PLCP for the given rate */ brcms_c_compute_plcp(wlc, rate, frame_len, plcp); @@ -8798,17 +8793,6 @@ void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, const void *buf, brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); } -/* wrapper BMAC functions to for HIGH driver access */ -void brcms_c_mctrl(struct brcms_c_info *wlc, u32 mask, u32 val) -{ - brcms_b_mctrl(wlc->hw, mask, val); -} - -void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, int bands) -{ - brcms_b_mhf(wlc->hw, idx, mask, val, bands); -} - int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, uint *blocks) { @@ -8820,12 +8804,6 @@ int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, return 0; } -void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, int len, - void *buf) -{ - brcms_b_write_template_ram(wlc->hw, offset, len, buf); -} - void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, const u8 *addr) @@ -8835,11 +8813,6 @@ brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); } -void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit) -{ - brcms_b_pllreq(wlc->hw, set, req_bit); -} - /* check for the particular priority flow control bit being set */ bool brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc, diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index a71c5099109..99d5c60467c 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -674,9 +674,6 @@ extern void brcms_c_info_init(struct brcms_c_info *wlc, int unit); extern void brcms_c_print_txstatus(struct tx_status *txs); extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, uint *blocks); -extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset, - int len, void *buf); -extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit); #if defined(BCMDBG) extern void brcms_c_print_rxh(struct d11rxhdr *rxh); From d75c7be5e8341edf332739f5f115b9f0df833ca6 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:06 +0200 Subject: [PATCH 1333/1519] staging: brcm80211: removed unneeded call to brcms_b_tx_fifo_suspended - removed call to brcms_b_tx_fifo_suspended on receipt of TX FIFO suspend/flush completion signal. - removed brcms_b_tx_fifo_suspended function as it is not being used elsewhere. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 34 ----------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index bd38f33b13e..175d85ea429 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1075,36 +1075,6 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) return morepending; } -/* brcms_b_tx_fifo_suspended: - * Check the MAC's tx suspend status for a tx fifo. - * - * When the MAC acknowledges a tx suspend, it indicates that no more - * packets will be transmitted out the radio. This is independent of - * DMA channel suspension---the DMA may have finished suspending, or may still - * be pulling data into a tx fifo, by the time the MAC acks the suspend - * request. - */ -static bool brcms_b_tx_fifo_suspended(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* check that a suspend has been requested and is no longer pending */ - - /* - * for DMA mode, the suspend request is set in xmtcontrol of the DMA - * engine, and the tx fifo suspend at the lower end of the MAC is - * acknowledged in the chnstatus register. - * - * The tx fifo suspend completion is independent of the DMA suspend - * completion and may be acked before or after the DMA is suspended. - */ - if (dma_txsuspended(wlc_hw->di[tx_fifo]) && - (R_REG(&wlc_hw->regs->chnstatus) & - (1 << tx_fifo)) == 0) - return true; - - return false; -} - /* second-level interrupt processing * Return true if another dpc needs to be re-scheduled. false otherwise. * Param 'bounded' indicates if applicable loops should be bounded. @@ -1161,10 +1131,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) wlc->macintstatus |= MI_DMAINT; - /* TX FIFO suspend/flush completion */ - if (macintstatus & MI_TXSTOP) - brcms_b_tx_fifo_suspended(wlc_hw, TX_DATA_FIFO); - /* noise sample collected */ if (macintstatus & MI_BG_NOISE) wlc_phy_noise_sample_intr(wlc_hw->band->pi); From 1689e9b11874143caa52ec3e66711c6a75e8caf9 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:07 +0200 Subject: [PATCH 1334/1519] staging: brcm80211: removed synchronisation of wlc->machwcap field - removed copying field wlc->machwcap from brcms_hardware to brcms_c_info during module attach. - field wlc->machwcap was written but never read. Therefore it was removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 39 +---------------------- drivers/staging/brcm80211/brcmsmac/main.h | 2 -- 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 175d85ea429..0656d9956fc 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -390,13 +390,6 @@ static int brcms_chspec_bw(u16 chanspec) return BRCMS_10_MHZ; } -/* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) - driver */ -struct brcms_b_state { - u32 machwcap; /* mac hw capibility */ - u32 preamble_ovr; /* preamble override */ -}; - struct edcf_acparam { u8 ACI; u8 ECW; @@ -1168,14 +1161,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) return wlc->macintstatus != 0; } -static int brcms_b_state_get(struct brcms_hardware *wlc_hw, - struct brcms_b_state *state) -{ - state->machwcap = wlc_hw->machwcap; - - return 0; -} - /* set initial host flags value */ static void brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) @@ -4534,20 +4519,6 @@ void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; } -static bool brcms_c_state_bmac_sync(struct brcms_c_info *wlc) -{ - struct brcms_b_state state_bmac = {0}; - - if (brcms_b_state_get(wlc->hw, &state_bmac) != 0) - return false; - - wlc->machwcap = state_bmac.machwcap; - brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, - (s8) state_bmac.preamble_ovr); - - return true; -} - static uint brcms_c_attach_module(struct brcms_c_info *wlc) { uint err = 0; @@ -5151,15 +5122,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, if (err) goto fail; - /* - * for some states, due to different info pointer(e,g, wlc, wlc_hw) or - * master/slave split, HIGH driver(both monolithic and HIGH_ONLY) needs - * to sync states FROM BMAC portion driver - */ - if (!brcms_c_state_bmac_sync(wlc)) { - err = 20; - goto fail; - } + brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, OFF); pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 99d5c60467c..441292a2418 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -519,8 +519,6 @@ struct brcms_c_info { u16 deviceid; uint ucode_rev; - u32 machwcap; - u8 perm_etheraddr[ETH_ALEN]; bool bandlocked; From fa1b6ab7a5cea3ae0c0eed0704c47e7bfd6ac20c Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:08 +0200 Subject: [PATCH 1335/1519] staging: brcm80211: remove brcms_b_dotxstatus wrapper function - removed brcms_b_dotxstatus - changed 'fatal' argument of brcms_b_txstatus from INOUT to OUT. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 0656d9956fc..4e2226e937a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -995,21 +995,6 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) } -static bool -brcms_b_dotxstatus(struct brcms_hardware *wlc_hw, struct tx_status *txs) -{ - /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, - * but the subsequent tx of DATA failed. so it will start rts/cts from - * the beginning (resetting the rts transmission count) - */ - if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) - return false; - - return brcms_c_dotxstatus(wlc_hw->wlc, txs); -} - /* process tx completion events in BMAC * Return true if more tx status need to be processed. false otherwise. */ @@ -1032,6 +1017,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) txs = &txstatus; regs = wlc_hw->regs; + *fatal = false; while (!(*fatal) && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { @@ -1041,7 +1027,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) return morepending; } - s2 = R_REG(®s->frmtxstatus2); + s2 = R_REG(®s->frmtxstatus2); txs->status = s1 & TXS_STATUS_MASK; txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; @@ -1049,7 +1035,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; txs->lasttxtime = 0; - *fatal = brcms_b_dotxstatus(wlc_hw, txs); + *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); /* !give others some time to run! */ if (++n >= max_tx_num) @@ -1077,7 +1063,6 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) u32 macintstatus; struct brcms_hardware *wlc_hw = wlc->hw; struct d11regs __iomem *regs = wlc_hw->regs; - bool fatal = false; struct wiphy *wiphy = wlc->wiphy; if (brcms_deviceremoved(wlc)) { @@ -1098,6 +1083,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) /* tx status */ if (macintstatus & MI_TFS) { + bool fatal; if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) wlc->macintstatus |= MI_TFS; if (fatal) { From 0f90d23cf4124616f9a42036b50ba5cc3724868c Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:09 +0200 Subject: [PATCH 1336/1519] staging: brcm80211: combined if statements Combined if statements in brcms_c_edcf_setparams and brcms_c_wme_setparams functions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 4e2226e937a..30c5573e886 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4186,12 +4186,10 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, *shm_entry++); } - if (suspend) + if (suspend) { brcms_c_suspend_mac_and_wait(wlc); - - if (suspend) brcms_c_enable_mac(wlc); - + } } void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) @@ -4223,12 +4221,10 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); } - if (suspend) + if (suspend) { brcms_c_suspend_mac_and_wait(wlc); - - if (suspend) brcms_c_enable_mac(wlc); - + } } /* maintain LED behavior in down state */ From 68327a1910f4b32226de47f9443068ce511ae2de Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 4 Oct 2011 23:19:10 +0200 Subject: [PATCH 1337/1519] staging: brcm80211: remove N mode validation function Removed the brcms_c_nmode_validate function as it only checks N-mode capability, which should always be true. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 29 ----------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 30c5573e886..9fa84858a8c 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -5912,40 +5912,11 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) return ret; } -static int brcms_c_nmode_validate(struct brcms_c_info *wlc, s32 nmode) -{ - int err = 0; - - switch (nmode) { - - case OFF: - break; - - case AUTO: - case WL_11N_2x2: - case WL_11N_3x3: - if (!(BRCMS_PHY_11N_CAP(wlc->band))) - err = -EINVAL; - break; - - default: - err = -EINVAL; - break; - } - - return err; -} - int brcms_c_set_nmode(struct brcms_c_info *wlc) { uint i; - int err; s32 nmode = AUTO; - err = brcms_c_nmode_validate(wlc, nmode); - if (err) - return err; - if (wlc->stf->txstreams == WL_11N_3x3) nmode = WL_11N_3x3; else From 8be00d98f167b95fac8886d60f9942ef0c744445 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 4 Oct 2011 23:19:11 +0200 Subject: [PATCH 1338/1519] staging: brcm80211: softmac: added event tracing Dpc and timer events can now be traced. Combined with Mac80211 driver callback tracing, all entry points into the driver can now be traced. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/Makefile | 3 +- .../brcm80211/brcmsmac/brcms_trace_events.c | 23 +++++ .../brcm80211/brcmsmac/brcms_trace_events.h | 92 +++++++++++++++++++ .../staging/brcm80211/brcmsmac/mac80211_if.c | 10 +- .../staging/brcm80211/brcmsmac/mac80211_if.h | 2 + 5 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c create mode 100644 drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile index e44859ddc98..a8a152b7e01 100644 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -42,7 +42,8 @@ BRCMSMAC_OFILES := \ otp.o \ srom.o \ dma.o \ - nicpci.o + nicpci.o \ + brcms_trace_events.o MODULEPFX := brcmsmac diff --git a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c new file mode 100644 index 00000000000..52fc9eeb5fa --- /dev/null +++ b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include /* bug in tracepoint.h, it should include this */ + +#ifndef __CHECKER__ +#include "mac80211_if.h" +#define CREATE_TRACE_POINTS +#include "brcms_trace_events.h" +#endif diff --git a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h new file mode 100644 index 00000000000..27dd73eef56 --- /dev/null +++ b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM brcmsmac + +#if !defined(__TRACE_BRCMSMAC_H) || defined(TRACE_HEADER_MULTI_READ) + +#define __TRACE_BRCMSMAC_H + +#include +#include "mac80211_if.h" + +#ifndef CONFIG_BRCMDBG +#undef TRACE_EVENT +#define TRACE_EVENT(name, proto, ...) \ +static inline void trace_ ## name(proto) {} +#endif + +/* + * We define a tracepoint, its arguments, its printk format and its + * 'fast binary record' layout. + */ +TRACE_EVENT(brcms_timer, + /* TPPROTO is the prototype of the function called by this tracepoint */ + TP_PROTO(struct brcms_timer *t), + /* + * TPARGS(firstarg, p) are the parameters names, same as found in the + * prototype. + */ + TP_ARGS(t), + /* + * Fast binary tracing: define the trace record via TP_STRUCT__entry(). + * You can think about it like a regular C structure local variable + * definition. + */ + TP_STRUCT__entry( + __field(uint, ms) + __field(uint, set) + __field(uint, periodic) + ), + TP_fast_assign( + __entry->ms = t->ms; + __entry->set = t->set; + __entry->periodic = t->periodic; + ), + TP_printk( + "ms=%u set=%u periodic=%u", + __entry->ms, __entry->set, __entry->periodic + ) +); + +TRACE_EVENT(brcms_dpc, + TP_PROTO(unsigned long data), + TP_ARGS(data), + TP_STRUCT__entry( + __field(unsigned long, data) + ), + TP_fast_assign( + __entry->data = data; + ), + TP_printk( + "data=%p", + (void *)__entry->data + ) +); + +#endif /* __TRACE_BRCMSMAC_H */ + +#ifdef CONFIG_BRCMDBG + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE brcms_trace_events + +#include + +#endif /* CONFIG_BRCMDBG */ diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index c5afeaf69d9..fa00ab31fab 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -750,7 +750,7 @@ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); } -static void brcms_dpc(unsigned long data) +void brcms_dpc(unsigned long data) { struct brcms_info *wl; @@ -1430,7 +1430,7 @@ void brcms_down(struct brcms_info *wl) /* * precondition: perimeter lock is not acquired */ -static void _brcms_timer(struct brcms_timer *t) +void brcms_timer(struct brcms_timer *t) { LOCK(t->wl); @@ -1454,9 +1454,9 @@ static void _brcms_timer(struct brcms_timer *t) /* * is called by the kernel from software irq context */ -static void brcms_timer(unsigned long data) +static void _brcms_timer(unsigned long data) { - _brcms_timer((struct brcms_timer *) data); + brcms_timer((struct brcms_timer *) data); } /* @@ -1477,7 +1477,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl, init_timer(&t->timer); t->timer.data = (unsigned long) t; - t->timer.function = brcms_timer; + t->timer.function = _brcms_timer; t->wl = wl; t->fn = fn; t->arg = arg; diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h index 2bdcd4c16f8..92256d0318f 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h @@ -101,5 +101,7 @@ extern void brcms_add_timer(struct brcms_info *wl, struct brcms_timer *timer, uint ms, int periodic); extern bool brcms_del_timer(struct brcms_info *wl, struct brcms_timer *timer); extern void brcms_msleep(struct brcms_info *wl, uint ms); +extern void brcms_dpc(unsigned long data); +extern void brcms_timer(struct brcms_timer *t); #endif /* _BRCM_MAC80211_IF_H_ */ From d0f5527d3949db767425dc84f0e8547824b74708 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 4 Oct 2011 23:19:12 +0200 Subject: [PATCH 1339/1519] staging: brcm80211: smac: fix for 64 bit systems A bug was introduced by the following commit (Sep 13): staging: brcm80211: use endian annotated structures in brcmsmac Result was that 64 bits systems will not be able to acquire an IP address. Also the rmmod crashed. This has been fixed and retested on a Sparc64. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 4 ++-- drivers/staging/brcm80211/brcmsmac/ucode_loader.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index fa00ab31fab..ac78052b495 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -1606,7 +1606,7 @@ fail: * Precondition: Since this function is called in brcms_pci_probe() context, * no locking is required. */ -int brcms_ucode_init_uint(struct brcms_info *wl, u32 *data, u32 idx) +int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx) { int i, entry; const u8 *pdata; @@ -1623,7 +1623,7 @@ int brcms_ucode_init_uint(struct brcms_info *wl, u32 *data, u32 idx) "ERROR: fw hdr len\n"); return -ENOMSG; } - *data = le32_to_cpu(*((__le32 *) pdata)); + *n_bytes = le32_to_cpu(*((__le32 *) pdata)); return 0; } } diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h index 49d5b7e9a4e..18750a814b4 100644 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h +++ b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h @@ -50,8 +50,8 @@ extern void brcms_ucode_data_free(struct brcms_ucode *ucode); extern int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, unsigned int idx); -extern int brcms_ucode_init_uint(struct brcms_info *wl, unsigned *data, - unsigned int idx); +extern int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, + unsigned int idx); extern void brcms_ucode_free_buf(void *); extern int brcms_check_firmwares(struct brcms_info *wl); From 03c74dada5bf59393d59a3e4bfc44db198f556c6 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:30:44 +0200 Subject: [PATCH 1340/1519] staging: brcm80211: move driver variable functions to srom.c The driver uses variables which are stored in string format. Using strings as variable identifiers is disliked by the community. The driver has been cleaned up and the only module providing these variables is srom.c. The variable retrieval functions have been moved to srom.c in preparation of a more likable way to store and lookup these driver variables. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/main.c | 44 ----------------------- drivers/staging/brcm80211/brcmsmac/srom.c | 44 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 9fa84858a8c..100e6ec425d 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -8881,47 +8881,3 @@ void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) wlc->mpc = mpc; brcms_c_radio_mpc_upd(wlc); } - -/* - * Search the name=value vars for a specific one and return its value. - * Returns NULL if not found. - */ -char *getvar(char *vars, const char *name) -{ - char *s; - int len; - - if (!name) - return NULL; - - len = strlen(name); - if (len == 0) - return NULL; - - /* first look in vars[] */ - for (s = vars; s && *s;) { - if ((memcmp(s, name, len) == 0) && (s[len] == '=')) - return &s[len + 1]; - - while (*s++) - ; - } - /* nothing found */ - return NULL; -} - -/* - * Search the vars for a specific one and return its value as - * an integer. Returns 0 if not found. - */ -int getintvar(char *vars, const char *name) -{ - char *val; - unsigned long res; - - val = getvar(vars, name); - if (val && !kstrtoul(val, 0, &res)) - return res; - - return 0; -} diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 13d17ebe6df..02dbd982cd6 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -1242,3 +1242,47 @@ int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, return -EINVAL; } + +/* + * Search the name=value vars for a specific one and return its value. + * Returns NULL if not found. + */ +char *getvar(char *vars, const char *name) +{ + char *s; + int len; + + if (!name) + return NULL; + + len = strlen(name); + if (len == 0) + return NULL; + + /* first look in vars[] */ + for (s = vars; s && *s;) { + if ((memcmp(s, name, len) == 0) && (s[len] == '=')) + return &s[len + 1]; + + while (*s++) + ; + } + /* nothing found */ + return NULL; +} + +/* + * Search the vars for a specific one and return its value as + * an integer. Returns 0 if not found. + */ +int getintvar(char *vars, const char *name) +{ + char *val; + unsigned long res; + + val = getvar(vars, name); + if (val && !kstrtoul(val, 0, &res)) + return res; + + return 0; +} From bd42e67bbece0088c3bc2ffb675ddd32eb3bf57d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Wed, 5 Oct 2011 15:20:01 +0200 Subject: [PATCH 1341/1519] staging: brcm80211: remove threads_only code from fullmac threads_only is always true as we never use the tasklet implementation. So related code is removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 98 ++++++------------- 1 file changed, 29 insertions(+), 69 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index f3e6249589e..0ae8dc03c8a 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -651,11 +651,9 @@ struct brcmf_bus { bool wd_timer_valid; uint save_ms; - struct tasklet_struct tasklet; struct task_struct *dpc_tsk; struct completion dpc_wait; - bool threads_only; struct semaphore sdsem; const char *fw_name; @@ -2704,29 +2702,6 @@ static int brcmf_sdbrcm_dpc_thread(void *data) return 0; } -static void brcmf_sdbrcm_dpc_tasklet(unsigned long data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) data; - - /* Call bus dpc unless it indicated down (then clean stop) */ - if (bus->drvr->busstate != BRCMF_BUS_DOWN) { - if (brcmf_sdbrcm_dpc(bus)) - tasklet_schedule(&bus->tasklet); - } else { - brcmf_sdbrcm_bus_stop(bus); - } -} - -static void brcmf_sdbrcm_sched_dpc(struct brcmf_bus *bus) -{ - if (bus->dpc_tsk) { - complete(&bus->dpc_wait); - return; - } - - tasklet_schedule(&bus->tasklet); -} - int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) { int ret = -EBADE; @@ -2770,7 +2745,8 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) /* Schedule DPC if needed to send queued packet(s) */ if (!bus->dpc_sched) { bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); + if (bus->dpc_tsk) + complete(&bus->dpc_wait); } return ret; @@ -3642,8 +3618,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) send_sig(SIGTERM, bus->dpc_tsk, 1); kthread_stop(bus->dpc_tsk); bus->dpc_tsk = NULL; - } else - tasklet_kill(&bus->tasklet); + } /* Disable and clear interrupts at the chip level also */ w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries); @@ -3831,7 +3806,8 @@ void brcmf_sdbrcm_isr(void *arg) brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); + if (bus->dpc_tsk) + complete(&bus->dpc_wait); } static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) @@ -3875,8 +3851,8 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) bus->ipend = true; bus->dpc_sched = true; - brcmf_sdbrcm_sched_dpc(bus); - + if (bus->dpc_tsk) + complete(&bus->dpc_wait); } } @@ -4366,21 +4342,13 @@ brcmf_sdbrcm_watchdog(unsigned long data) { struct brcmf_bus *bus = (struct brcmf_bus *)data; - if (bus->threads_only) { - if (bus->watchdog_tsk) - complete(&bus->watchdog_wait); - else - return; - } else { - brcmf_sdbrcm_bus_watchdog(bus->drvr); - - /* Count the tick for reference */ - bus->drvr->tickcnt++; + if (bus->watchdog_tsk) { + complete(&bus->watchdog_wait); + /* Reschedule the watchdog */ + if (bus->wd_timer_valid) + mod_timer(&bus->timer, + jiffies + BRCMF_WD_POLL_MS * HZ / 1000); } - - /* Reschedule the watchdog */ - if (bus->wd_timer_valid) - mod_timer(&bus->timer, jiffies + BRCMF_WD_POLL_MS * HZ / 1000); } static void @@ -4465,7 +4433,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->usebufpool = false; /* Use bufpool if allocated, else use locally malloced rxbuf */ - bus->threads_only = true; /* attempt to attach to the dongle */ if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { @@ -4483,32 +4450,25 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->timer.function = brcmf_sdbrcm_watchdog; /* Initialize thread based operation and lock */ - if (bus->threads_only) { - sema_init(&bus->sdsem, 1); + sema_init(&bus->sdsem, 1); - /* Initialize watchdog thread */ - init_completion(&bus->watchdog_wait); - bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, - bus, "brcmf_watchdog"); - if (IS_ERR(bus->watchdog_tsk)) { - printk(KERN_WARNING - "brcmf_watchdog thread failed to start\n"); - bus->watchdog_tsk = NULL; - } - /* Initialize DPC thread */ - init_completion(&bus->dpc_wait); - bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, - bus, "brcmf_dpc"); - if (IS_ERR(bus->dpc_tsk)) { - printk(KERN_WARNING - "brcmf_dpc thread failed to start\n"); - bus->dpc_tsk = NULL; - } - } else { + /* Initialize watchdog thread */ + init_completion(&bus->watchdog_wait); + bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, + bus, "brcmf_watchdog"); + if (IS_ERR(bus->watchdog_tsk)) { + printk(KERN_WARNING + "brcmf_watchdog thread failed to start\n"); bus->watchdog_tsk = NULL; + } + /* Initialize DPC thread */ + init_completion(&bus->dpc_wait); + bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, + bus, "brcmf_dpc"); + if (IS_ERR(bus->dpc_tsk)) { + printk(KERN_WARNING + "brcmf_dpc thread failed to start\n"); bus->dpc_tsk = NULL; - tasklet_init(&bus->tasklet, brcmf_sdbrcm_dpc_tasklet, - (unsigned long)bus); } /* Attach to the brcmf/OS/network interface */ From 43e45c3e89478694dd12619ff15a2ec12d80a36c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Wed, 5 Oct 2011 15:20:02 +0200 Subject: [PATCH 1342/1519] staging: brcm80211: remove redundant bus register layer from fullmac Remove some single line functions for bus register/unregister interface Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 10 ---------- .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 16 ++++------------ drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 14 -------------- drivers/staging/brcm80211/brcmfmac/sdio_host.h | 4 ---- 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index 5906337780b..bff9dcd6fad 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -362,16 +362,6 @@ int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) } EXPORT_SYMBOL(brcmf_sdio_remove); -int brcmf_sdio_register(void) -{ - return brcmf_sdio_function_init(); -} - -void brcmf_sdio_unregister(void) -{ - brcmf_sdio_function_cleanup(); -} - void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable) { if (enable) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index fc95bb24846..e919de210f7 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -609,23 +609,15 @@ static struct sdio_driver brcmf_sdmmc_driver = { #endif /* CONFIG_PM_SLEEP */ }; -/* - * module init -*/ -int brcmf_sdio_function_init(void) +/* bus register interface */ +int brcmf_bus_register(void) { - int error = 0; brcmf_dbg(TRACE, "Enter\n"); - error = sdio_register_driver(&brcmf_sdmmc_driver); - - return error; + return sdio_register_driver(&brcmf_sdmmc_driver); } -/* - * module cleanup -*/ -void brcmf_sdio_function_cleanup(void) +void brcmf_bus_unregister(void) { brcmf_dbg(TRACE, "Enter\n"); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 0ae8dc03c8a..0f7b80da41d 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -4533,20 +4533,6 @@ void brcmf_sdbrcm_disconnect(void *ptr) brcmf_dbg(TRACE, "Disconnected\n"); } -int brcmf_bus_register(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - return brcmf_sdio_register(); -} - -void brcmf_bus_unregister(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_sdio_unregister(); -} - struct device *brcmf_bus_get_device(struct brcmf_bus *bus) { return &bus->sdiodev->func[2]->dev; diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h index 397ad48803d..726fa898111 100644 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/staging/brcm80211/brcmfmac/sdio_host.h @@ -211,10 +211,6 @@ extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn); /* platform specific/high level functions */ -extern int brcmf_sdio_function_init(void); -extern int brcmf_sdio_register(void); -extern void brcmf_sdio_unregister(void); -extern void brcmf_sdio_function_cleanup(void); extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); From f4e5c544d17cb2d4d9d2935024c4e629f4b2f619 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:03 +0200 Subject: [PATCH 1343/1519] staging: brcm80211: remove code duplication for driver variable lookup The phy code used its own driver variable lookup functions which were duplicates of those in the brcmsmac driver (in srom.c). The phy code now uses the functions in srom.c through the phy_shim interface. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 36 --- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 6 - .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 56 +++-- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 235 ++++++++++-------- drivers/staging/brcm80211/brcmsmac/phy_shim.c | 9 + drivers/staging/brcm80211/brcmsmac/phy_shim.h | 3 + 6 files changed, 174 insertions(+), 171 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 0d3c9d87c5e..59767e36735 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -126,42 +126,6 @@ const u8 ofdm_rate_lookup[] = { #define PHY_WREG_LIMIT 24 -char *phy_getvar(struct brcms_phy *pi, const char *name) -{ - char *vars = pi->vars; - char *s; - int len; - - if (!name) - return NULL; - - len = strlen(name); - if (len == 0) - return NULL; - - for (s = vars; s && *s;) { - if ((memcmp(s, name, len) == 0) && (s[len] == '=')) - return &s[len + 1]; - - while (*s++) - ; - } - - return NULL; -} - -int phy_getintvar(struct brcms_phy *pi, const char *name) -{ - char *val; - unsigned long res; - - val = PHY_GETVAR(pi, name); - if (val && !kstrtoul(val, 0, &res)) - return res; - - return 0; -} - void wlc_phyreg_enter(struct brcms_phy_pub *pih) { struct brcms_phy *pi = (struct brcms_phy *) pih; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 446809047cf..4330e3846d9 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -919,12 +919,6 @@ struct lcnphy_radio_regs { u8 do_init_g; }; -extern char *phy_getvar(struct brcms_phy *pi, const char *name); -extern int phy_getintvar(struct brcms_phy *pi, const char *name); - -#define PHY_GETVAR(pi, name) phy_getvar(pi, name) -#define PHY_GETINTVAR(pi, name) phy_getintvar(pi, name) - extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr); extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index a87e3921b5d..dbeeeba755f 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -4823,18 +4823,21 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) u32 offset_ofdm, offset_mcs; pi_lcn->lcnphy_tr_isolation_mid = - (u8) PHY_GETINTVAR(pi, "triso2g"); + (u8) wlapi_getintvar(pi->vars, "triso2g"); pi_lcn->lcnphy_rx_power_offset = - (u8) PHY_GETINTVAR(pi, "rxpo2g"); + (u8) wlapi_getintvar(pi->vars, "rxpo2g"); - pi->txpa_2g[0] = (s16) PHY_GETINTVAR(pi, "pa0b0"); - pi->txpa_2g[1] = (s16) PHY_GETINTVAR(pi, "pa0b1"); - pi->txpa_2g[2] = (s16) PHY_GETINTVAR(pi, "pa0b2"); + pi->txpa_2g[0] = (s16) wlapi_getintvar(pi->vars, "pa0b0"); + pi->txpa_2g[1] = (s16) wlapi_getintvar(pi->vars, "pa0b1"); + pi->txpa_2g[2] = (s16) wlapi_getintvar(pi->vars, "pa0b2"); - pi_lcn->lcnphy_rssi_vf = (u8) PHY_GETINTVAR(pi, "rssismf2g"); - pi_lcn->lcnphy_rssi_vc = (u8) PHY_GETINTVAR(pi, "rssismc2g"); - pi_lcn->lcnphy_rssi_gs = (u8) PHY_GETINTVAR(pi, "rssisav2g"); + pi_lcn->lcnphy_rssi_vf = + (u8) wlapi_getintvar(pi->vars, "rssismf2g"); + pi_lcn->lcnphy_rssi_vc = + (u8) wlapi_getintvar(pi->vars, "rssismc2g"); + pi_lcn->lcnphy_rssi_gs = + (u8) wlapi_getintvar(pi->vars, "rssisav2g"); pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; @@ -4844,7 +4847,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc; pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs; - txpwr = (s8) PHY_GETINTVAR(pi, "maxp2ga0"); + txpwr = (s8) wlapi_getintvar(pi->vars, "maxp2ga0"); pi->tx_srom_max_2g = txpwr; for (i = 0; i < PWRTBL_NUM_COEFF; i++) { @@ -4852,7 +4855,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi->txpa_2g_high_temp[i] = pi->txpa_2g[i]; } - cckpo = (u16) PHY_GETINTVAR(pi, "cck2gpo"); + cckpo = (u16) wlapi_getintvar(pi->vars, "cck2gpo"); if (cckpo) { uint max_pwr_chan = txpwr; @@ -4862,7 +4865,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) cckpo >>= 4; } - offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); + offset_ofdm = + (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = max_pwr_chan - @@ -4872,12 +4876,13 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } else { u8 opo = 0; - opo = (u8) PHY_GETINTVAR(pi, "opo"); + opo = (u8) wlapi_getintvar(pi->vars, "opo"); for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) pi->tx_srom_max_rate_2g[i] = txpwr; - offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); + offset_ofdm = + (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = txpwr - @@ -4885,8 +4890,9 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) offset_ofdm >>= 4; } offset_mcs = - ((u16) PHY_GETINTVAR(pi, "mcs2gpo1") << 16) | - (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); + wlapi_getintvar(pi->vars, "mcs2gpo1") << 16; + offset_mcs |= + (u16) wlapi_getintvar(pi->vars, "mcs2gpo0"); pi_lcn->lcnphy_mcs20_po = offset_mcs; for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { @@ -4897,30 +4903,30 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } pi_lcn->lcnphy_rawtempsense = - (u16) PHY_GETINTVAR(pi, "rawtempsense"); + (u16) wlapi_getintvar(pi->vars, "rawtempsense"); pi_lcn->lcnphy_measPower = - (u8) PHY_GETINTVAR(pi, "measpower"); + (u8) wlapi_getintvar(pi->vars, "measpower"); pi_lcn->lcnphy_tempsense_slope = - (u8) PHY_GETINTVAR(pi, "tempsense_slope"); + (u8) wlapi_getintvar(pi->vars, "tempsense_slope"); pi_lcn->lcnphy_hw_iqcal_en = - (bool) PHY_GETINTVAR(pi, "hw_iqcal_en"); + (bool) wlapi_getintvar(pi->vars, "hw_iqcal_en"); pi_lcn->lcnphy_iqcal_swp_dis = - (bool) PHY_GETINTVAR(pi, "iqcal_swp_dis"); + (bool) wlapi_getintvar(pi->vars, "iqcal_swp_dis"); pi_lcn->lcnphy_tempcorrx = - (u8) PHY_GETINTVAR(pi, "tempcorrx"); + (u8) wlapi_getintvar(pi->vars, "tempcorrx"); pi_lcn->lcnphy_tempsense_option = - (u8) PHY_GETINTVAR(pi, "tempsense_option"); + (u8) wlapi_getintvar(pi->vars, "tempsense_option"); pi_lcn->lcnphy_freqoffset_corr = - (u8) PHY_GETINTVAR(pi, "freqoffset_corr"); + (u8) wlapi_getintvar(pi->vars, "freqoffset_corr"); if ((u8) getintvar(pi->vars, "aa2g") > 1) wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, (u8) getintvar(pi->vars, "aa2g")); } pi_lcn->lcnphy_cck_dig_filt_type = -1; - if (PHY_GETVAR(pi, "cckdigfilttype")) { + if (wlapi_getvar(pi->vars, "cckdigfilttype")) { s16 temp; - temp = (s16) PHY_GETINTVAR(pi, "cckdigfilttype"); + temp = (s16) wlapi_getintvar(pi->vars, "cckdigfilttype"); if (temp >= 0) pi_lcn->lcnphy_cck_dig_filt_type = temp; } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index 67cfcdd8aab..c410bf04c26 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14387,25 +14387,25 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) if (pi->sh->sromrev >= 9) return; - bw40po = (u16) PHY_GETINTVAR(pi, "bw40po"); + bw40po = (u16) wlapi_getintvar(pi->vars, "bw40po"); pi->bw402gpo = bw40po & 0xf; pi->bw405gpo = (bw40po & 0xf0) >> 4; pi->bw405glpo = (bw40po & 0xf00) >> 8; pi->bw405ghpo = (bw40po & 0xf000) >> 12; - cddpo = (u16) PHY_GETINTVAR(pi, "cddpo"); + cddpo = (u16) wlapi_getintvar(pi->vars, "cddpo"); pi->cdd2gpo = cddpo & 0xf; pi->cdd5gpo = (cddpo & 0xf0) >> 4; pi->cdd5glpo = (cddpo & 0xf00) >> 8; pi->cdd5ghpo = (cddpo & 0xf000) >> 12; - stbcpo = (u16) PHY_GETINTVAR(pi, "stbcpo"); + stbcpo = (u16) wlapi_getintvar(pi->vars, "stbcpo"); pi->stbc2gpo = stbcpo & 0xf; pi->stbc5gpo = (stbcpo & 0xf0) >> 4; pi->stbc5glpo = (stbcpo & 0xf00) >> 8; pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; - bwduppo = (u16) PHY_GETINTVAR(pi, "bwduppo"); + bwduppo = (u16) wlapi_getintvar(pi->vars, "bwduppo"); pi->bwdup2gpo = bwduppo & 0xf; pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; @@ -14417,168 +14417,188 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) case 0: pi->nphy_txpid2g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid2ga0"); + (u8) wlapi_getintvar(pi->vars, "txpid2ga0"); pi->nphy_txpid2g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid2ga1"); + (u8) wlapi_getintvar(pi->vars, "txpid2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga0"); + (s8) wlapi_getintvar(pi->vars, "maxp2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) PHY_GETINTVAR(pi, "maxp2ga1"); + (s8) wlapi_getintvar(pi->vars, "maxp2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a0"); + (s16) wlapi_getintvar(pi->vars, "pa2gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) PHY_GETINTVAR(pi, "pa2gw0a1"); + (s16) wlapi_getintvar(pi->vars, "pa2gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a0"); + (s16) wlapi_getintvar(pi->vars, "pa2gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) PHY_GETINTVAR(pi, "pa2gw1a1"); + (s16) wlapi_getintvar(pi->vars, "pa2gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a0"); + (s16) wlapi_getintvar(pi->vars, "pa2gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) PHY_GETINTVAR(pi, "pa2gw2a1"); + (s16) wlapi_getintvar(pi->vars, "pa2gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga0"); + (s8) wlapi_getintvar(pi->vars, "itt2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) PHY_GETINTVAR(pi, "itt2ga1"); + (s8) wlapi_getintvar(pi->vars, "itt2ga1"); - pi->cck2gpo = (u16) PHY_GETINTVAR(pi, "cck2gpo"); + pi->cck2gpo = + (u16) wlapi_getintvar(pi->vars, "cck2gpo"); + pi->ofdm2gpo = + (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); - pi->ofdm2gpo = (u32) PHY_GETINTVAR(pi, "ofdm2gpo"); - - pi->mcs2gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs2gpo0"); - pi->mcs2gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs2gpo1"); - pi->mcs2gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs2gpo2"); - pi->mcs2gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs2gpo3"); - pi->mcs2gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs2gpo4"); - pi->mcs2gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs2gpo5"); - pi->mcs2gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs2gpo6"); - pi->mcs2gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs2gpo7"); + pi->mcs2gpo[0] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo0"); + pi->mcs2gpo[1] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo1"); + pi->mcs2gpo[2] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo2"); + pi->mcs2gpo[3] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo3"); + pi->mcs2gpo[4] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo4"); + pi->mcs2gpo[5] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo5"); + pi->mcs2gpo[6] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo6"); + pi->mcs2gpo[7] = + (u16) wlapi_getintvar(pi->vars, "mcs2gpo7"); break; case 1: pi->nphy_txpid5g[PHY_CORE_0] = - (u8) PHY_GETINTVAR(pi, "txpid5ga0"); + (u8) wlapi_getintvar(pi->vars, "txpid5ga0"); pi->nphy_txpid5g[PHY_CORE_1] = - (u8) PHY_GETINTVAR(pi, "txpid5ga1"); + (u8) wlapi_getintvar(pi->vars, "txpid5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga0"); + (s8) wlapi_getintvar(pi->vars, "maxp5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) PHY_GETINTVAR(pi, "maxp5ga1"); + (s8) wlapi_getintvar(pi->vars, "maxp5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a0"); + (s16) wlapi_getintvar(pi->vars, "pa5gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) PHY_GETINTVAR(pi, "pa5gw0a1"); + (s16) wlapi_getintvar(pi->vars, "pa5gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a0"); + (s16) wlapi_getintvar(pi->vars, "pa5gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) PHY_GETINTVAR(pi, "pa5gw1a1"); + (s16) wlapi_getintvar(pi->vars, "pa5gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a0"); + (s16) wlapi_getintvar(pi->vars, "pa5gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) PHY_GETINTVAR(pi, "pa5gw2a1"); + (s16) wlapi_getintvar(pi->vars, "pa5gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga0"); + (s8) wlapi_getintvar(pi->vars, "itt5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) PHY_GETINTVAR(pi, "itt5ga1"); + (s8) wlapi_getintvar(pi->vars, "itt5ga1"); - pi->ofdm5gpo = (u32) PHY_GETINTVAR(pi, "ofdm5gpo"); + pi->ofdm5gpo = + (u32) wlapi_getintvar(pi->vars, "ofdm5gpo"); - pi->mcs5gpo[0] = (u16) PHY_GETINTVAR(pi, "mcs5gpo0"); - pi->mcs5gpo[1] = (u16) PHY_GETINTVAR(pi, "mcs5gpo1"); - pi->mcs5gpo[2] = (u16) PHY_GETINTVAR(pi, "mcs5gpo2"); - pi->mcs5gpo[3] = (u16) PHY_GETINTVAR(pi, "mcs5gpo3"); - pi->mcs5gpo[4] = (u16) PHY_GETINTVAR(pi, "mcs5gpo4"); - pi->mcs5gpo[5] = (u16) PHY_GETINTVAR(pi, "mcs5gpo5"); - pi->mcs5gpo[6] = (u16) PHY_GETINTVAR(pi, "mcs5gpo6"); - pi->mcs5gpo[7] = (u16) PHY_GETINTVAR(pi, "mcs5gpo7"); + pi->mcs5gpo[0] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo0"); + pi->mcs5gpo[1] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo1"); + pi->mcs5gpo[2] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo2"); + pi->mcs5gpo[3] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo3"); + pi->mcs5gpo[4] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo4"); + pi->mcs5gpo[5] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo5"); + pi->mcs5gpo[6] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo6"); + pi->mcs5gpo[7] = + (u16) wlapi_getintvar(pi->vars, "mcs5gpo7"); break; case 2: pi->nphy_txpid5gl[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gla0"); + (u8) wlapi_getintvar(pi->vars, "txpid5gla0"); pi->nphy_txpid5gl[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gla1"); + (u8) wlapi_getintvar(pi->vars, "txpid5gla1"); pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla0"); + (s8) wlapi_getintvar(pi->vars, "maxp5gla0"); pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) PHY_GETINTVAR(pi, "maxp5gla1"); + (s8) wlapi_getintvar(pi->vars, "maxp5gla1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a0"); + (s16) wlapi_getintvar(pi->vars, "pa5glw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) PHY_GETINTVAR(pi, "pa5glw0a1"); + (s16) wlapi_getintvar(pi->vars, "pa5glw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a0"); + (s16) wlapi_getintvar(pi->vars, "pa5glw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) PHY_GETINTVAR(pi, "pa5glw1a1"); + (s16) wlapi_getintvar(pi->vars, "pa5glw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a0"); + (s16) wlapi_getintvar(pi->vars, "pa5glw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) PHY_GETINTVAR(pi, "pa5glw2a1"); + (s16) wlapi_getintvar(pi->vars, "pa5glw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; - pi->ofdm5glpo = (u32) PHY_GETINTVAR(pi, "ofdm5glpo"); + pi->ofdm5glpo = + (u32) wlapi_getintvar(pi->vars, "ofdm5glpo"); pi->mcs5glpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo0"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo0"); pi->mcs5glpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo1"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo1"); pi->mcs5glpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo2"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo2"); pi->mcs5glpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo3"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo3"); pi->mcs5glpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo4"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo4"); pi->mcs5glpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo5"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo5"); pi->mcs5glpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo6"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo6"); pi->mcs5glpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5glpo7"); + (u16) wlapi_getintvar(pi->vars, "mcs5glpo7"); break; case 3: pi->nphy_txpid5gh[0] = - (u8) PHY_GETINTVAR(pi, "txpid5gha0"); + (u8) wlapi_getintvar(pi->vars, "txpid5gha0"); pi->nphy_txpid5gh[1] = - (u8) PHY_GETINTVAR(pi, "txpid5gha1"); + (u8) wlapi_getintvar(pi->vars, "txpid5gha1"); pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha0"); + (s8) wlapi_getintvar(pi->vars, "maxp5gha0"); pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) PHY_GETINTVAR(pi, "maxp5gha1"); + (s8) wlapi_getintvar(pi->vars, "maxp5gha1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a0"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw0a1"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a0"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) PHY_GETINTVAR(pi, "pa5ghw1a1"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a0"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) PHY_GETINTVAR(pi, "pa5ghw2a1"); + (s16) wlapi_getintvar(pi->vars, "pa5ghw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; - pi->ofdm5ghpo = (u32) PHY_GETINTVAR(pi, "ofdm5ghpo"); + pi->ofdm5ghpo = + (u32) wlapi_getintvar(pi->vars, "ofdm5ghpo"); pi->mcs5ghpo[0] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo0"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo0"); pi->mcs5ghpo[1] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo1"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo1"); pi->mcs5ghpo[2] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo2"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo2"); pi->mcs5ghpo[3] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo3"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo3"); pi->mcs5ghpo[4] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo4"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo4"); pi->mcs5ghpo[5] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo5"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo5"); pi->mcs5ghpo[6] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo6"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo6"); pi->mcs5ghpo[7] = - (u16) PHY_GETINTVAR(pi, "mcs5ghpo7"); + (u16) wlapi_getintvar(pi->vars, "mcs5ghpo7"); break; } } @@ -14589,34 +14609,40 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) { - pi->antswitch = (u8) PHY_GETINTVAR(pi, "antswitch"); - pi->aa2g = (u8) PHY_GETINTVAR(pi, "aa2g"); - pi->aa5g = (u8) PHY_GETINTVAR(pi, "aa5g"); + pi->antswitch = (u8) wlapi_getintvar(pi->vars, "antswitch"); + pi->aa2g = (u8) wlapi_getintvar(pi->vars, "aa2g"); + pi->aa5g = (u8) wlapi_getintvar(pi->vars, "aa5g"); - pi->srom_fem2g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos2g"); - pi->srom_fem2g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain2g"); - pi->srom_fem2g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange2g"); - pi->srom_fem2g.triso = (u8) PHY_GETINTVAR(pi, "triso2g"); - pi->srom_fem2g.antswctrllut = (u8) PHY_GETINTVAR(pi, "antswctl2g"); + pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(pi->vars, "tssipos2g"); + pi->srom_fem2g.extpagain = + (u8) wlapi_getintvar(pi->vars, "extpagain2g"); + pi->srom_fem2g.pdetrange = + (u8) wlapi_getintvar(pi->vars, "pdetrange2g"); + pi->srom_fem2g.triso = (u8) wlapi_getintvar(pi->vars, "triso2g"); + pi->srom_fem2g.antswctrllut = + (u8) wlapi_getintvar(pi->vars, "antswctl2g"); - pi->srom_fem5g.tssipos = (u8) PHY_GETINTVAR(pi, "tssipos5g"); - pi->srom_fem5g.extpagain = (u8) PHY_GETINTVAR(pi, "extpagain5g"); - pi->srom_fem5g.pdetrange = (u8) PHY_GETINTVAR(pi, "pdetrange5g"); - pi->srom_fem5g.triso = (u8) PHY_GETINTVAR(pi, "triso5g"); - if (PHY_GETVAR(pi, "antswctl5g")) + pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(pi->vars, "tssipos5g"); + pi->srom_fem5g.extpagain = + (u8) wlapi_getintvar(pi->vars, "extpagain5g"); + pi->srom_fem5g.pdetrange = + (u8) wlapi_getintvar(pi->vars, "pdetrange5g"); + pi->srom_fem5g.triso = (u8) wlapi_getintvar(pi->vars, "triso5g"); + if (wlapi_getvar(pi->vars, "antswctl5g")) pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl5g"); + (u8) wlapi_getintvar(pi->vars, "antswctl5g"); else pi->srom_fem5g.antswctrllut = - (u8) PHY_GETINTVAR(pi, "antswctl2g"); + (u8) wlapi_getintvar(pi->vars, "antswctl2g"); wlc_phy_txpower_ipa_upd(pi); - pi->phy_txcore_disable_temp = (s16) PHY_GETINTVAR(pi, "tempthresh"); + pi->phy_txcore_disable_temp = + (s16) wlapi_getintvar(pi->vars, "tempthresh"); if (pi->phy_txcore_disable_temp == 0) pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - pi->phy_tempsense_offset = (s8) PHY_GETINTVAR(pi, "tempoffset"); + pi->phy_tempsense_offset = (s8) wlapi_getintvar(pi->vars, "tempoffset"); if (pi->phy_tempsense_offset != 0) { if (pi->phy_tempsense_offset > (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) @@ -14631,7 +14657,8 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) pi->phy_txcore_enable_temp = pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; - pi->phycal_tempdelta = (u8) PHY_GETINTVAR(pi, "phycal_tempdelta"); + pi->phycal_tempdelta = + (u8) wlapi_getintvar(pi->vars, "phycal_tempdelta"); if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) pi->phycal_tempdelta = 0; diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index e0c19b62b19..0be07ed3bd1 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -215,3 +215,12 @@ wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf, { brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel); } + +char *wlapi_getvar(char *vars, const char *name) +{ + return getvar(vars, name); +} +int wlapi_getintvar(char *vars, const char *name) +{ + return getintvar(vars, name); +} diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index d88c8202c97..35fe993b74b 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -178,4 +178,7 @@ extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode); extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim); +extern char *wlapi_getvar(char *vars, const char *name); +extern int wlapi_getintvar(char *vars, const char *name); + #endif /* _BRCM_PHY_SHIM_H_ */ From 7ddaad7eb407f9ee90a8db2673a63541ec820285 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:04 +0200 Subject: [PATCH 1344/1519] staging: brcm80211: change parameter in driver variable lookup The functions getvar() and getintvar() had to pass the buffer containing the driver variables. Now they pass the structure containing this buffer hiding what type of buffer/container is used for storing the driver variables. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 18 +- drivers/staging/brcm80211/brcmsmac/antsel.c | 15 +- drivers/staging/brcm80211/brcmsmac/channel.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.c | 29 +-- drivers/staging/brcm80211/brcmsmac/nicpci.c | 4 +- drivers/staging/brcm80211/brcmsmac/nicpci.h | 2 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 62 +++-- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 217 +++++++++--------- drivers/staging/brcm80211/brcmsmac/phy_shim.c | 8 +- drivers/staging/brcm80211/brcmsmac/phy_shim.h | 4 +- drivers/staging/brcm80211/brcmsmac/pub.h | 4 +- drivers/staging/brcm80211/brcmsmac/srom.c | 11 +- drivers/staging/brcm80211/brcmsmac/stf.c | 4 +- 13 files changed, 187 insertions(+), 193 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 8d4024e5080..d44f619005f 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1012,7 +1012,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* * get boardtype and boardrev */ -static __used void ai_nvram_process(struct si_info *sii, char *pvars) +static __used void ai_nvram_process(struct si_info *sii) { uint w = 0; @@ -1021,7 +1021,7 @@ static __used void ai_nvram_process(struct si_info *sii, char *pvars) sii->pub.boardvendor = w & 0xffff; sii->pub.boardtype = (w >> 16) & 0xffff; - sii->pub.boardflags = getintvar(pvars, "boardflags"); + sii->pub.boardflags = getintvar(&sii->pub, "boardflags"); } static struct si_info *ai_doattach(struct si_info *sii, @@ -1031,7 +1031,6 @@ static struct si_info *ai_doattach(struct si_info *sii, struct si_pub *sih = &sii->pub; u32 w, savewin; struct chipcregs __iomem *cc; - char *pvars = NULL; uint socitype; uint origidx; @@ -1095,8 +1094,9 @@ static struct si_info *ai_doattach(struct si_info *sii, if (srom_var_init(&sii->pub, cc, vars, varsz)) goto exit; - pvars = vars ? *vars : NULL; - ai_nvram_process(sii, pvars); + sii->vars = vars ? *vars : NULL; + sii->varsz = varsz ? *varsz : 0; + ai_nvram_process(sii); /* === NVRAM, clock is ready === */ cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); @@ -1109,7 +1109,7 @@ static struct si_info *ai_doattach(struct si_info *sii, u32 xtalfreq; si_pmu_init(sih); si_pmu_chip_init(sih); - xtalfreq = getintvar(pvars, "xtalfreq"); + xtalfreq = getintvar(sih, "xtalfreq"); /* If xtalfreq var not available, try to measure it */ if (xtalfreq == 0) xtalfreq = si_pmu_measure_alpclk(sih); @@ -1119,14 +1119,14 @@ static struct si_info *ai_doattach(struct si_info *sii, } /* setup the GPIO based LED powersave register */ - w = getintvar(pvars, "leddc"); + w = getintvar(sih, "leddc"); if (w == 0) w = DEFAULT_GPIOTIMERVAL; ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), ~0, w); if (PCIE(sii)) - pcicore_attach(sii->pch, pvars, SI_DOATTACH); + pcicore_attach(sii->pch, SI_DOATTACH); if (sih->chip == BCM43224_CHIP_ID) { /* @@ -1191,8 +1191,6 @@ ai_attach(void __iomem *regs, struct pci_dev *sdh, char **vars, uint *varsz) kfree(sii); return NULL; } - sii->vars = vars ? *vars : NULL; - sii->varsz = varsz ? *varsz : 0; return (struct si_pub *) sii; } diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index c2aa47bc1dc..eedcdb68294 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -108,6 +108,7 @@ brcms_c_antsel_init_cfg(struct antsel_info *asi, struct brcms_antselcfg *antsel, struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) { struct antsel_info *asi; + struct si_pub *sih = wlc->hw->sih; asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC); if (!asi) @@ -117,7 +118,7 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) asi->pub = wlc->pub; asi->antsel_type = ANTSEL_NA; asi->antsel_avail = false; - asi->antsel_antswitch = (u8) getintvar(asi->pub->vars, "antswitch"); + asi->antsel_antswitch = (u8) getintvar(sih, "antswitch"); if ((asi->pub->sromrev >= 4) && (asi->antsel_antswitch != 0)) { switch (asi->antsel_antswitch) { @@ -127,12 +128,12 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) /* 4321/2 board with 2x3 switch logic */ asi->antsel_type = ANTSEL_2x3; /* Antenna selection availability */ - if (((u16) getintvar(asi->pub->vars, "aa2g") == 7) || - ((u16) getintvar(asi->pub->vars, "aa5g") == 7)) { + if (((u16) getintvar(sih, "aa2g") == 7) || + ((u16) getintvar(sih, "aa5g") == 7)) { asi->antsel_avail = true; } else if ( - (u16) getintvar(asi->pub->vars, "aa2g") == 3 || - (u16) getintvar(asi->pub->vars, "aa5g") == 3) { + (u16) getintvar(sih, "aa2g") == 3 || + (u16) getintvar(sih, "aa5g") == 3) { asi->antsel_avail = false; } else { asi->antsel_avail = false; @@ -145,8 +146,8 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) break; } } else if ((asi->pub->sromrev == 4) && - ((u16) getintvar(asi->pub->vars, "aa2g") == 7) && - ((u16) getintvar(asi->pub->vars, "aa5g") == 0)) { + ((u16) getintvar(sih, "aa2g") == 7) && + ((u16) getintvar(sih, "aa5g") == 0)) { /* hack to match old 4321CB2 cards with 2of3 antenna switch */ asi->antsel_type = ANTSEL_2x3; asi->antsel_avail = true; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 2127c2791a3..53066fb8af8 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1088,7 +1088,7 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) wlc->cmi = wlc_cm; /* store the country code for passing up as a regulatory hint */ - ccode = getvar(wlc->pub->vars, "ccode"); + ccode = getvar(wlc->hw->sih, "ccode"); if (ccode) strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 100e6ec425d..f2339a5f8dd 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1990,7 +1990,7 @@ static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) char *macaddr; /* If macaddr exists, use it (Sromrev4, CIS, ...). */ - macaddr = getvar(wlc_hw->vars, varname); + macaddr = getvar(wlc_hw->sih, varname); if (macaddr != NULL) return macaddr; @@ -1999,7 +1999,7 @@ static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) else varname = "il0macaddr"; - macaddr = getvar(wlc_hw->vars, varname); + macaddr = getvar(wlc_hw->sih, varname); if (macaddr == NULL) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " "getvar(%s) not found\n", wlc_hw->unit, varname); @@ -4593,13 +4593,13 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, * than those the BIOS recognizes for devices on PCMCIA_BUS, * SDIO_BUS, and SROMless devices on PCI_BUS. */ - var = getvar(vars, "vendid"); + var = getvar(wlc_hw->sih, "vendid"); if (var && !kstrtoul(var, 0, &res)) { vendor = (u16)res; wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", vendor); } - var = getvar(vars, "devid"); + var = getvar(wlc_hw->sih, "devid"); if (var && !kstrtoul(var, 0, &res)) { u16 devid = (u16)res; if (devid != 0xffff) { @@ -4656,7 +4656,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, } /* get the board rev, used just below */ - j = getintvar(vars, "boardrev"); + j = getintvar(wlc_hw->sih, "boardrev"); /* promote srom boardrev of 0xFF to 1 */ if (j == BOARDREV_PROMOTABLE) j = BOARDREV_PROMOTED; @@ -4668,9 +4668,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, err = 15; goto fail; } - wlc_hw->sromrev = (u8) getintvar(vars, "sromrev"); - wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); - wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); + wlc_hw->sromrev = (u8) getintvar(wlc_hw->sih, "sromrev"); + wlc_hw->boardflags = (u32) getintvar(wlc_hw->sih, "boardflags"); + wlc_hw->boardflags2 = (u32) getintvar(wlc_hw->sih, "boardflags2"); if (wlc_hw->boardflags & BFL_NOPLLDOWN) brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); @@ -4920,15 +4920,16 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) uint unit; char *vars; int bandtype; + struct si_pub *sih = wlc->hw->sih; unit = wlc->pub->unit; vars = wlc->pub->vars; bandtype = wlc->band->bandtype; /* get antennas available */ - aa = (s8) getintvar(vars, bandtype == BRCM_BAND_5G ? "aa5g" : "aa2g"); + aa = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? "aa5g" : "aa2g"); if (aa == 0) - aa = (s8) getintvar(vars, + aa = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? "aa1" : "aa0"); if ((aa < 1) || (aa > 15)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" @@ -4947,8 +4948,8 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) } /* Compute Antenna Gain */ - wlc->band->antgain = - (s8) getintvar(vars, bandtype == BRCM_BAND_5G ? "ag1" : "ag0"); + wlc->band->antgain = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? + "ag1" : "ag0"); brcms_c_attach_antgain_init(wlc); return true; @@ -5114,9 +5115,9 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, /* set maximum allowed duty cycle */ wlc->tx_duty_cycle_ofdm = - (u16) getintvar(pub->vars, "tx_duty_cycle_ofdm"); + (u16) getintvar(wlc->hw->sih, "tx_duty_cycle_ofdm"); wlc->tx_duty_cycle_cck = - (u16) getintvar(pub->vars, "tx_duty_cycle_cck"); + (u16) getintvar(wlc->hw->sih, "tx_duty_cycle_cck"); brcms_c_stf_phy_chain_calc(wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 460b1054695..57721a0c32b 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -719,13 +719,13 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) } /* ***** Functions called during driver state changes ***** */ -void pcicore_attach(struct pcicore_info *pi, char *pvars, int state) +void pcicore_attach(struct pcicore_info *pi, int state) { struct si_pub *sih = pi->sih; /* Determine if this board needs override */ if (PCIE_ASPM(sih)) { - if ((u32)getintvar(pvars, "boardflags2") & BFL2_PCIEWAR_OVR) + if ((u32)getintvar(sih, "boardflags2") & BFL2_PCIEWAR_OVR) pi->pcie_war_aspm_ovr = PCIE_ASPM_DISAB; else pi->pcie_war_aspm_ovr = PCIE_ASPM_ENAB; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.h b/drivers/staging/brcm80211/brcmsmac/nicpci.h index 2d41aab8ad5..58aa80dc332 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.h +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.h @@ -65,7 +65,7 @@ extern struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, void __iomem *regs); extern void pcicore_deinit(struct pcicore_info *pch); -extern void pcicore_attach(struct pcicore_info *pch, char *pvars, int state); +extern void pcicore_attach(struct pcicore_info *pch, int state); extern void pcicore_hwup(struct pcicore_info *pch); extern void pcicore_up(struct pcicore_info *pch, int state); extern void pcicore_sleep(struct pcicore_info *pch); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index dbeeeba755f..d84e1cf5dc5 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -4817,27 +4817,25 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) s8 txpwr = 0; int i; struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; + struct phy_shim_info *shim = pi->sh->physhim; if (CHSPEC_IS2G(pi->radio_chanspec)) { u16 cckpo = 0; u32 offset_ofdm, offset_mcs; pi_lcn->lcnphy_tr_isolation_mid = - (u8) wlapi_getintvar(pi->vars, "triso2g"); + (u8)wlapi_getintvar(shim, "triso2g"); pi_lcn->lcnphy_rx_power_offset = - (u8) wlapi_getintvar(pi->vars, "rxpo2g"); + (u8)wlapi_getintvar(shim, "rxpo2g"); - pi->txpa_2g[0] = (s16) wlapi_getintvar(pi->vars, "pa0b0"); - pi->txpa_2g[1] = (s16) wlapi_getintvar(pi->vars, "pa0b1"); - pi->txpa_2g[2] = (s16) wlapi_getintvar(pi->vars, "pa0b2"); + pi->txpa_2g[0] = (s16)wlapi_getintvar(shim, "pa0b0"); + pi->txpa_2g[1] = (s16)wlapi_getintvar(shim, "pa0b1"); + pi->txpa_2g[2] = (s16)wlapi_getintvar(shim, "pa0b2"); - pi_lcn->lcnphy_rssi_vf = - (u8) wlapi_getintvar(pi->vars, "rssismf2g"); - pi_lcn->lcnphy_rssi_vc = - (u8) wlapi_getintvar(pi->vars, "rssismc2g"); - pi_lcn->lcnphy_rssi_gs = - (u8) wlapi_getintvar(pi->vars, "rssisav2g"); + pi_lcn->lcnphy_rssi_vf = (u8)wlapi_getintvar(shim, "rssismf2g"); + pi_lcn->lcnphy_rssi_vc = (u8)wlapi_getintvar(shim, "rssismc2g"); + pi_lcn->lcnphy_rssi_gs = (u8)wlapi_getintvar(shim, "rssisav2g"); pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; @@ -4847,7 +4845,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc; pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs; - txpwr = (s8) wlapi_getintvar(pi->vars, "maxp2ga0"); + txpwr = (s8)wlapi_getintvar(shim, "maxp2ga0"); pi->tx_srom_max_2g = txpwr; for (i = 0; i < PWRTBL_NUM_COEFF; i++) { @@ -4855,7 +4853,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi->txpa_2g_high_temp[i] = pi->txpa_2g[i]; } - cckpo = (u16) wlapi_getintvar(pi->vars, "cck2gpo"); + cckpo = (u16)wlapi_getintvar(shim, "cck2gpo"); if (cckpo) { uint max_pwr_chan = txpwr; @@ -4865,8 +4863,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) cckpo >>= 4; } - offset_ofdm = - (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); + offset_ofdm = (u32)wlapi_getintvar(shim, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = max_pwr_chan - @@ -4876,13 +4873,12 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } else { u8 opo = 0; - opo = (u8) wlapi_getintvar(pi->vars, "opo"); + opo = (u8)wlapi_getintvar(shim, "opo"); for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) pi->tx_srom_max_rate_2g[i] = txpwr; - offset_ofdm = - (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); + offset_ofdm = (u32)wlapi_getintvar(shim, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = txpwr - @@ -4890,9 +4886,9 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) offset_ofdm >>= 4; } offset_mcs = - wlapi_getintvar(pi->vars, "mcs2gpo1") << 16; + wlapi_getintvar(shim, "mcs2gpo1") << 16; offset_mcs |= - (u16) wlapi_getintvar(pi->vars, "mcs2gpo0"); + (u16) wlapi_getintvar(shim, "mcs2gpo0"); pi_lcn->lcnphy_mcs20_po = offset_mcs; for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { @@ -4903,30 +4899,30 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } pi_lcn->lcnphy_rawtempsense = - (u16) wlapi_getintvar(pi->vars, "rawtempsense"); + (u16)wlapi_getintvar(shim, "rawtempsense"); pi_lcn->lcnphy_measPower = - (u8) wlapi_getintvar(pi->vars, "measpower"); + (u8)wlapi_getintvar(shim, "measpower"); pi_lcn->lcnphy_tempsense_slope = - (u8) wlapi_getintvar(pi->vars, "tempsense_slope"); + (u8)wlapi_getintvar(shim, "tempsense_slope"); pi_lcn->lcnphy_hw_iqcal_en = - (bool) wlapi_getintvar(pi->vars, "hw_iqcal_en"); + (bool)wlapi_getintvar(shim, "hw_iqcal_en"); pi_lcn->lcnphy_iqcal_swp_dis = - (bool) wlapi_getintvar(pi->vars, "iqcal_swp_dis"); + (bool)wlapi_getintvar(shim, "iqcal_swp_dis"); pi_lcn->lcnphy_tempcorrx = - (u8) wlapi_getintvar(pi->vars, "tempcorrx"); + (u8)wlapi_getintvar(shim, "tempcorrx"); pi_lcn->lcnphy_tempsense_option = - (u8) wlapi_getintvar(pi->vars, "tempsense_option"); + (u8)wlapi_getintvar(shim, "tempsense_option"); pi_lcn->lcnphy_freqoffset_corr = - (u8) wlapi_getintvar(pi->vars, "freqoffset_corr"); - if ((u8) getintvar(pi->vars, "aa2g") > 1) + (u8)wlapi_getintvar(shim, "freqoffset_corr"); + if ((u8)wlapi_getintvar(shim, "aa2g") > 1) wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, - (u8) getintvar(pi->vars, - "aa2g")); + (u8) wlapi_getintvar(shim, + "aa2g")); } pi_lcn->lcnphy_cck_dig_filt_type = -1; - if (wlapi_getvar(pi->vars, "cckdigfilttype")) { + if (wlapi_getvar(shim, "cckdigfilttype")) { s16 temp; - temp = (s16) wlapi_getintvar(pi->vars, "cckdigfilttype"); + temp = (s16)wlapi_getintvar(shim, "cckdigfilttype"); if (temp >= 0) pi_lcn->lcnphy_cck_dig_filt_type = temp; } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index c410bf04c26..a4417e9ab90 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14383,29 +14383,30 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) { u16 bw40po, cddpo, stbcpo, bwduppo; uint band_num; + struct phy_shim_info *shim = pi->sh->physhim; if (pi->sh->sromrev >= 9) return; - bw40po = (u16) wlapi_getintvar(pi->vars, "bw40po"); + bw40po = (u16) wlapi_getintvar(shim, "bw40po"); pi->bw402gpo = bw40po & 0xf; pi->bw405gpo = (bw40po & 0xf0) >> 4; pi->bw405glpo = (bw40po & 0xf00) >> 8; pi->bw405ghpo = (bw40po & 0xf000) >> 12; - cddpo = (u16) wlapi_getintvar(pi->vars, "cddpo"); + cddpo = (u16) wlapi_getintvar(shim, "cddpo"); pi->cdd2gpo = cddpo & 0xf; pi->cdd5gpo = (cddpo & 0xf0) >> 4; pi->cdd5glpo = (cddpo & 0xf00) >> 8; pi->cdd5ghpo = (cddpo & 0xf000) >> 12; - stbcpo = (u16) wlapi_getintvar(pi->vars, "stbcpo"); + stbcpo = (u16) wlapi_getintvar(shim, "stbcpo"); pi->stbc2gpo = stbcpo & 0xf; pi->stbc5gpo = (stbcpo & 0xf0) >> 4; pi->stbc5glpo = (stbcpo & 0xf00) >> 8; pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; - bwduppo = (u16) wlapi_getintvar(pi->vars, "bwduppo"); + bwduppo = (u16) wlapi_getintvar(shim, "bwduppo"); pi->bwdup2gpo = bwduppo & 0xf; pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; @@ -14417,188 +14418,186 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) case 0: pi->nphy_txpid2g[PHY_CORE_0] = - (u8) wlapi_getintvar(pi->vars, "txpid2ga0"); + (u8) wlapi_getintvar(shim, "txpid2ga0"); pi->nphy_txpid2g[PHY_CORE_1] = - (u8) wlapi_getintvar(pi->vars, "txpid2ga1"); + (u8) wlapi_getintvar(shim, "txpid2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) wlapi_getintvar(pi->vars, "maxp2ga0"); + (s8) wlapi_getintvar(shim, "maxp2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) wlapi_getintvar(pi->vars, "maxp2ga1"); + (s8) wlapi_getintvar(shim, "maxp2ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) wlapi_getintvar(pi->vars, "pa2gw0a0"); + (s16) wlapi_getintvar(shim, "pa2gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) wlapi_getintvar(pi->vars, "pa2gw0a1"); + (s16) wlapi_getintvar(shim, "pa2gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) wlapi_getintvar(pi->vars, "pa2gw1a0"); + (s16) wlapi_getintvar(shim, "pa2gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) wlapi_getintvar(pi->vars, "pa2gw1a1"); + (s16) wlapi_getintvar(shim, "pa2gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) wlapi_getintvar(pi->vars, "pa2gw2a0"); + (s16) wlapi_getintvar(shim, "pa2gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) wlapi_getintvar(pi->vars, "pa2gw2a1"); + (s16) wlapi_getintvar(shim, "pa2gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) wlapi_getintvar(pi->vars, "itt2ga0"); + (s8) wlapi_getintvar(shim, "itt2ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) wlapi_getintvar(pi->vars, "itt2ga1"); + (s8) wlapi_getintvar(shim, "itt2ga1"); - pi->cck2gpo = - (u16) wlapi_getintvar(pi->vars, "cck2gpo"); - pi->ofdm2gpo = - (u32) wlapi_getintvar(pi->vars, "ofdm2gpo"); + pi->cck2gpo = (u16) wlapi_getintvar(shim, "cck2gpo"); + + pi->ofdm2gpo = (u32) wlapi_getintvar(shim, "ofdm2gpo"); pi->mcs2gpo[0] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo0"); + (u16) wlapi_getintvar(shim, "mcs2gpo0"); pi->mcs2gpo[1] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo1"); + (u16) wlapi_getintvar(shim, "mcs2gpo1"); pi->mcs2gpo[2] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo2"); + (u16) wlapi_getintvar(shim, "mcs2gpo2"); pi->mcs2gpo[3] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo3"); + (u16) wlapi_getintvar(shim, "mcs2gpo3"); pi->mcs2gpo[4] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo4"); + (u16) wlapi_getintvar(shim, "mcs2gpo4"); pi->mcs2gpo[5] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo5"); + (u16) wlapi_getintvar(shim, "mcs2gpo5"); pi->mcs2gpo[6] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo6"); + (u16) wlapi_getintvar(shim, "mcs2gpo6"); pi->mcs2gpo[7] = - (u16) wlapi_getintvar(pi->vars, "mcs2gpo7"); + (u16) wlapi_getintvar(shim, "mcs2gpo7"); break; case 1: pi->nphy_txpid5g[PHY_CORE_0] = - (u8) wlapi_getintvar(pi->vars, "txpid5ga0"); + (u8) wlapi_getintvar(shim, "txpid5ga0"); pi->nphy_txpid5g[PHY_CORE_1] = - (u8) wlapi_getintvar(pi->vars, "txpid5ga1"); + (u8) wlapi_getintvar(shim, "txpid5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) wlapi_getintvar(pi->vars, "maxp5ga0"); + (s8) wlapi_getintvar(shim, "maxp5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) wlapi_getintvar(pi->vars, "maxp5ga1"); + (s8) wlapi_getintvar(shim, "maxp5ga1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5gw0a0"); + (s16) wlapi_getintvar(shim, "pa5gw0a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5gw0a1"); + (s16) wlapi_getintvar(shim, "pa5gw0a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5gw1a0"); + (s16) wlapi_getintvar(shim, "pa5gw1a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5gw1a1"); + (s16) wlapi_getintvar(shim, "pa5gw1a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5gw2a0"); + (s16) wlapi_getintvar(shim, "pa5gw2a0"); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5gw2a1"); + (s16) wlapi_getintvar(shim, "pa5gw2a1"); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) wlapi_getintvar(pi->vars, "itt5ga0"); + (s8) wlapi_getintvar(shim, "itt5ga0"); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) wlapi_getintvar(pi->vars, "itt5ga1"); + (s8) wlapi_getintvar(shim, "itt5ga1"); - pi->ofdm5gpo = - (u32) wlapi_getintvar(pi->vars, "ofdm5gpo"); + pi->ofdm5gpo = (u32) wlapi_getintvar(shim, "ofdm5gpo"); pi->mcs5gpo[0] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo0"); + (u16) wlapi_getintvar(shim, "mcs5gpo0"); pi->mcs5gpo[1] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo1"); + (u16) wlapi_getintvar(shim, "mcs5gpo1"); pi->mcs5gpo[2] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo2"); + (u16) wlapi_getintvar(shim, "mcs5gpo2"); pi->mcs5gpo[3] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo3"); + (u16) wlapi_getintvar(shim, "mcs5gpo3"); pi->mcs5gpo[4] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo4"); + (u16) wlapi_getintvar(shim, "mcs5gpo4"); pi->mcs5gpo[5] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo5"); + (u16) wlapi_getintvar(shim, "mcs5gpo5"); pi->mcs5gpo[6] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo6"); + (u16) wlapi_getintvar(shim, "mcs5gpo6"); pi->mcs5gpo[7] = - (u16) wlapi_getintvar(pi->vars, "mcs5gpo7"); + (u16) wlapi_getintvar(shim, "mcs5gpo7"); break; case 2: pi->nphy_txpid5gl[0] = - (u8) wlapi_getintvar(pi->vars, "txpid5gla0"); + (u8) wlapi_getintvar(shim, "txpid5gla0"); pi->nphy_txpid5gl[1] = - (u8) wlapi_getintvar(pi->vars, "txpid5gla1"); + (u8) wlapi_getintvar(shim, "txpid5gla1"); pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) wlapi_getintvar(pi->vars, "maxp5gla0"); + (s8) wlapi_getintvar(shim, "maxp5gla0"); pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) wlapi_getintvar(pi->vars, "maxp5gla1"); + (s8) wlapi_getintvar(shim, "maxp5gla1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5glw0a0"); + (s16) wlapi_getintvar(shim, "pa5glw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5glw0a1"); + (s16) wlapi_getintvar(shim, "pa5glw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5glw1a0"); + (s16) wlapi_getintvar(shim, "pa5glw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5glw1a1"); + (s16) wlapi_getintvar(shim, "pa5glw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5glw2a0"); + (s16) wlapi_getintvar(shim, "pa5glw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5glw2a1"); + (s16) wlapi_getintvar(shim, "pa5glw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; pi->ofdm5glpo = - (u32) wlapi_getintvar(pi->vars, "ofdm5glpo"); + (u32) wlapi_getintvar(shim, "ofdm5glpo"); pi->mcs5glpo[0] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo0"); + (u16) wlapi_getintvar(shim, "mcs5glpo0"); pi->mcs5glpo[1] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo1"); + (u16) wlapi_getintvar(shim, "mcs5glpo1"); pi->mcs5glpo[2] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo2"); + (u16) wlapi_getintvar(shim, "mcs5glpo2"); pi->mcs5glpo[3] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo3"); + (u16) wlapi_getintvar(shim, "mcs5glpo3"); pi->mcs5glpo[4] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo4"); + (u16) wlapi_getintvar(shim, "mcs5glpo4"); pi->mcs5glpo[5] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo5"); + (u16) wlapi_getintvar(shim, "mcs5glpo5"); pi->mcs5glpo[6] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo6"); + (u16) wlapi_getintvar(shim, "mcs5glpo6"); pi->mcs5glpo[7] = - (u16) wlapi_getintvar(pi->vars, "mcs5glpo7"); + (u16) wlapi_getintvar(shim, "mcs5glpo7"); break; case 3: pi->nphy_txpid5gh[0] = - (u8) wlapi_getintvar(pi->vars, "txpid5gha0"); + (u8) wlapi_getintvar(shim, "txpid5gha0"); pi->nphy_txpid5gh[1] = - (u8) wlapi_getintvar(pi->vars, "txpid5gha1"); + (u8) wlapi_getintvar(shim, "txpid5gha1"); pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) wlapi_getintvar(pi->vars, "maxp5gha0"); + (s8) wlapi_getintvar(shim, "maxp5gha0"); pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) wlapi_getintvar(pi->vars, "maxp5gha1"); + (s8) wlapi_getintvar(shim, "maxp5gha1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw0a0"); + (s16) wlapi_getintvar(shim, "pa5ghw0a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw0a1"); + (s16) wlapi_getintvar(shim, "pa5ghw0a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw1a0"); + (s16) wlapi_getintvar(shim, "pa5ghw1a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw1a1"); + (s16) wlapi_getintvar(shim, "pa5ghw1a1"); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw2a0"); + (s16) wlapi_getintvar(shim, "pa5ghw2a0"); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(pi->vars, "pa5ghw2a1"); + (s16) wlapi_getintvar(shim, "pa5ghw2a1"); pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; pi->ofdm5ghpo = - (u32) wlapi_getintvar(pi->vars, "ofdm5ghpo"); + (u32) wlapi_getintvar(shim, "ofdm5ghpo"); pi->mcs5ghpo[0] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo0"); + (u16) wlapi_getintvar(shim, "mcs5ghpo0"); pi->mcs5ghpo[1] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo1"); + (u16) wlapi_getintvar(shim, "mcs5ghpo1"); pi->mcs5ghpo[2] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo2"); + (u16) wlapi_getintvar(shim, "mcs5ghpo2"); pi->mcs5ghpo[3] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo3"); + (u16) wlapi_getintvar(shim, "mcs5ghpo3"); pi->mcs5ghpo[4] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo4"); + (u16) wlapi_getintvar(shim, "mcs5ghpo4"); pi->mcs5ghpo[5] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo5"); + (u16) wlapi_getintvar(shim, "mcs5ghpo5"); pi->mcs5ghpo[6] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo6"); + (u16) wlapi_getintvar(shim, "mcs5ghpo6"); pi->mcs5ghpo[7] = - (u16) wlapi_getintvar(pi->vars, "mcs5ghpo7"); + (u16) wlapi_getintvar(shim, "mcs5ghpo7"); break; } } @@ -14608,41 +14607,37 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) { + struct phy_shim_info *shim = pi->sh->physhim; - pi->antswitch = (u8) wlapi_getintvar(pi->vars, "antswitch"); - pi->aa2g = (u8) wlapi_getintvar(pi->vars, "aa2g"); - pi->aa5g = (u8) wlapi_getintvar(pi->vars, "aa5g"); + pi->antswitch = (u8) wlapi_getintvar(shim, "antswitch"); + pi->aa2g = (u8) wlapi_getintvar(shim, "aa2g"); + pi->aa5g = (u8) wlapi_getintvar(shim, "aa5g"); - pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(pi->vars, "tssipos2g"); - pi->srom_fem2g.extpagain = - (u8) wlapi_getintvar(pi->vars, "extpagain2g"); - pi->srom_fem2g.pdetrange = - (u8) wlapi_getintvar(pi->vars, "pdetrange2g"); - pi->srom_fem2g.triso = (u8) wlapi_getintvar(pi->vars, "triso2g"); - pi->srom_fem2g.antswctrllut = - (u8) wlapi_getintvar(pi->vars, "antswctl2g"); + pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(shim, "tssipos2g"); + pi->srom_fem2g.extpagain = (u8) wlapi_getintvar(shim, "extpagain2g"); + pi->srom_fem2g.pdetrange = (u8) wlapi_getintvar(shim, "pdetrange2g"); + pi->srom_fem2g.triso = (u8) wlapi_getintvar(shim, "triso2g"); + pi->srom_fem2g.antswctrllut = (u8) wlapi_getintvar(shim, "antswctl2g"); - pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(pi->vars, "tssipos5g"); - pi->srom_fem5g.extpagain = - (u8) wlapi_getintvar(pi->vars, "extpagain5g"); - pi->srom_fem5g.pdetrange = - (u8) wlapi_getintvar(pi->vars, "pdetrange5g"); - pi->srom_fem5g.triso = (u8) wlapi_getintvar(pi->vars, "triso5g"); - if (wlapi_getvar(pi->vars, "antswctl5g")) + pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(shim, "tssipos5g"); + pi->srom_fem5g.extpagain = (u8) wlapi_getintvar(shim, "extpagain5g"); + pi->srom_fem5g.pdetrange = (u8) wlapi_getintvar(shim, "pdetrange5g"); + pi->srom_fem5g.triso = (u8) wlapi_getintvar(shim, "triso5g"); + if (wlapi_getvar(shim, "antswctl5g")) pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(pi->vars, "antswctl5g"); + (u8) wlapi_getintvar(shim, "antswctl5g"); else pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(pi->vars, "antswctl2g"); + (u8) wlapi_getintvar(shim, "antswctl2g"); wlc_phy_txpower_ipa_upd(pi); pi->phy_txcore_disable_temp = - (s16) wlapi_getintvar(pi->vars, "tempthresh"); + (s16) wlapi_getintvar(shim, "tempthresh"); if (pi->phy_txcore_disable_temp == 0) pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - pi->phy_tempsense_offset = (s8) wlapi_getintvar(pi->vars, "tempoffset"); + pi->phy_tempsense_offset = (s8) wlapi_getintvar(shim, "tempoffset"); if (pi->phy_tempsense_offset != 0) { if (pi->phy_tempsense_offset > (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) @@ -14658,7 +14653,7 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; pi->phycal_tempdelta = - (u8) wlapi_getintvar(pi->vars, "phycal_tempdelta"); + (u8) wlapi_getintvar(shim, "phycal_tempdelta"); if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) pi->phycal_tempdelta = 0; diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index 0be07ed3bd1..57122fc4c78 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -216,11 +216,11 @@ wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf, brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel); } -char *wlapi_getvar(char *vars, const char *name) +char *wlapi_getvar(struct phy_shim_info *physhim, const char *name) { - return getvar(vars, name); + return getvar(physhim->wlc_hw->sih, name); } -int wlapi_getintvar(char *vars, const char *name) +int wlapi_getintvar(struct phy_shim_info *physhim, const char *name) { - return getintvar(vars, name); + return getintvar(physhim->wlc_hw->sih, name); } diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index 35fe993b74b..ca76153f79c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -178,7 +178,7 @@ extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode); extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim); -extern char *wlapi_getvar(char *vars, const char *name); -extern int wlapi_getintvar(char *vars, const char *name); +extern char *wlapi_getvar(struct phy_shim_info *physhim, const char *name); +extern int wlapi_getintvar(struct phy_shim_info *physhim, const char *name); #endif /* _BRCM_PHY_SHIM_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index b69833eb461..d1639b44bd7 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -356,8 +356,8 @@ extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta, u16 tid); extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, u8 ba_wsize, uint max_rx_ampdu_bytes); -extern char *getvar(char *vars, const char *name); -extern int getintvar(char *vars, const char *name); +extern char *getvar(struct si_pub *sih, const char *name); +extern int getintvar(struct si_pub *sih, const char *name); /* wlc_phy.c helper functions */ extern void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 02dbd982cd6..524f1cc4877 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -1247,10 +1247,13 @@ int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, * Search the name=value vars for a specific one and return its value. * Returns NULL if not found. */ -char *getvar(char *vars, const char *name) +char *getvar(struct si_pub *sih, const char *name) { char *s; int len; + struct si_info *sii; + + sii = (struct si_info *)sih; if (!name) return NULL; @@ -1260,7 +1263,7 @@ char *getvar(char *vars, const char *name) return NULL; /* first look in vars[] */ - for (s = vars; s && *s;) { + for (s = sii->vars; s && *s;) { if ((memcmp(s, name, len) == 0) && (s[len] == '=')) return &s[len + 1]; @@ -1275,12 +1278,12 @@ char *getvar(char *vars, const char *name) * Search the vars for a specific one and return its value as * an integer. Returns 0 if not found. */ -int getintvar(char *vars, const char *name) +int getintvar(struct si_pub *sih, const char *name) { char *val; unsigned long res; - val = getvar(vars, name); + val = getvar(sih, name); if (val && !kstrtoul(val, 0, &res)) return res; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 9460cd157f6..3ce90494aca 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -373,8 +373,8 @@ void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) { /* get available rx/tx chains */ - wlc->stf->hw_txchain = (u8) getintvar(wlc->pub->vars, "txchain"); - wlc->stf->hw_rxchain = (u8) getintvar(wlc->pub->vars, "rxchain"); + wlc->stf->hw_txchain = (u8) getintvar(wlc->hw->sih, "txchain"); + wlc->stf->hw_rxchain = (u8) getintvar(wlc->hw->sih, "rxchain"); /* these parameter are intended to be used for all PHY types */ if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) { From 3956b4a2ddb04524aa4a1c59fb1c2db8ac60f9ea Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:05 +0200 Subject: [PATCH 1345/1519] staging: brcm80211: remove locking macro definitions The driver contained locking macros which map directly to the lock function provided by the kernel. It does not provide any additional value so these have been removed. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmsmac/mac80211_if.c | 157 ++++++++---------- 1 file changed, 68 insertions(+), 89 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c index ac78052b495..185a098dd13 100644 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c @@ -35,26 +35,6 @@ #define N_TX_QUEUES 4 /* #tx queues on mac80211<->driver interface */ -#define LOCK(wl) spin_lock_bh(&(wl)->lock) -#define UNLOCK(wl) spin_unlock_bh(&(wl)->lock) - -/* locking from inside brcms_isr */ -#define ISR_LOCK(wl, flags)\ - do {\ - spin_lock(&(wl)->isr_lock);\ - (void)(flags); } \ - while (0) - -#define ISR_UNLOCK(wl, flags)\ - do {\ - spin_unlock(&(wl)->isr_lock);\ - (void)(flags); } \ - while (0) - -/* locking under LOCK() to synchronize with brcms_isr */ -#define INT_LOCK(wl, flags) spin_lock_irqsave(&(wl)->isr_lock, flags) -#define INT_UNLOCK(wl, flags) spin_unlock_irqrestore(&(wl)->isr_lock, flags) - /* Flags we support */ #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | \ @@ -291,7 +271,7 @@ static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct brcms_info *wl = hw->priv; - LOCK(wl); + spin_lock_bh(&wl->lock); if (!wl->pub->up) { wiphy_err(wl->wiphy, "ops->tx called while down\n"); kfree_skb(skb); @@ -299,7 +279,7 @@ static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) } brcms_c_sendpkt_mac80211(wl->wlc, skb, hw); done: - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } static int brcms_ops_start(struct ieee80211_hw *hw) @@ -308,9 +288,9 @@ static int brcms_ops_start(struct ieee80211_hw *hw) bool blocked; ieee80211_wake_queues(hw); - LOCK(wl); + spin_lock_bh(&wl->lock); blocked = brcms_rfkill_set_hw_state(wl); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); if (!blocked) wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); @@ -340,12 +320,12 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) } wl = hw->priv; - LOCK(wl); + spin_lock_bh(&wl->lock); if (!wl->pub->up) err = brcms_up(wl); else err = -ENODEV; - UNLOCK(wl); + spin_unlock_bh(&wl->lock); if (err != 0) wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, @@ -362,9 +342,9 @@ brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) wl = hw->priv; /* put driver in down state */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_down(wl); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) @@ -375,7 +355,7 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) int new_int; struct wiphy *wiphy = hw->wiphy; - LOCK(wl); + spin_lock_bh(&wl->lock); if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { brcms_c_set_beacon_listen_interval(wl->wlc, conf->listen_interval); @@ -416,7 +396,7 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) conf->long_frame_max_tx_count); config_out: - UNLOCK(wl); + spin_unlock_bh(&wl->lock); return err; } @@ -434,9 +414,9 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, */ wiphy_err(wiphy, "%s: %s: %sassociated\n", KBUILD_MODNAME, __func__, info->assoc ? "" : "dis"); - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_associate_upd(wl->wlc, info->assoc); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } if (changed & BSS_CHANGED_ERP_SLOT) { s8 val; @@ -446,23 +426,23 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, val = 1; else val = 0; - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_set_shortslot_override(wl->wlc, val); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } if (changed & BSS_CHANGED_HT) { /* 802.11n parameters changed */ u16 mode = info->ht_operation_mode; - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG, mode & IEEE80211_HT_OP_MODE_PROTECTION); brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF, mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS, mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } if (changed & BSS_CHANGED_BASIC_RATES) { struct ieee80211_supported_band *bi; @@ -472,9 +452,9 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, int error; /* retrieve the current rates */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_get_current_rateset(wl->wlc, &rs); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); br_mask = info->basic_rates; bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)]; @@ -488,24 +468,24 @@ brcms_ops_bss_info_changed(struct ieee80211_hw *hw, } /* update the rate set */ - LOCK(wl); + spin_lock_bh(&wl->lock); error = brcms_c_set_rateset(wl->wlc, &rs); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); if (error) wiphy_err(wiphy, "changing basic rates failed: %d\n", error); } if (changed & BSS_CHANGED_BEACON_INT) { /* Beacon interval changed */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_set_beacon_period(wl->wlc, info->beacon_int); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } if (changed & BSS_CHANGED_BSSID) { /* BSSID changed, for whatever reason (IBSS and managed mode) */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } if (changed & BSS_CHANGED_BEACON) /* Beacon data changed, retrieve new beacon (beaconing modes) */ @@ -571,7 +551,7 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw, if (changed_flags & FIF_OTHER_BSS) wiphy_err(wiphy, "FIF_OTHER_BSS\n"); if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { - LOCK(wl); + spin_lock_bh(&wl->lock); if (*total_flags & FIF_BCN_PRBRESP_PROMISC) { wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS; brcms_c_mac_bcn_promisc_change(wl->wlc, 1); @@ -579,7 +559,7 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw, brcms_c_mac_bcn_promisc_change(wl->wlc, 0); wl->pub->mac80211_state &= ~MAC80211_PROMISC_BCNS; } - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } return; } @@ -587,18 +567,18 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw, static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_scan_start(wl->wlc); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); return; } static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_scan_stop(wl->wlc); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); return; } @@ -608,9 +588,9 @@ brcms_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, { struct brcms_info *wl = hw->priv; - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_wme_setparams(wl->wlc, queue, params, true); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); return 0; } @@ -661,9 +641,9 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_RX_STOP: break; case IEEE80211_AMPDU_TX_START: - LOCK(wl); + spin_lock_bh(&wl->lock); status = brcms_c_aggregatable(wl->wlc, tid); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); if (!status) { wiphy_err(wl->wiphy, "START: tid %d is not agg\'able\n", tid); @@ -673,9 +653,9 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, break; case IEEE80211_AMPDU_TX_STOP: - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_ampdu_flush(wl->wlc, sta, tid); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); break; case IEEE80211_AMPDU_TX_OPERATIONAL: @@ -685,11 +665,11 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw, * recipient and traffic class. 'ampdu_factor' gives maximum * AMPDU size. */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size, (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + sta->ht_cap.ampdu_factor)) - 1); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); /* Power save wakeup */ break; default: @@ -705,9 +685,9 @@ static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw) struct brcms_info *wl = hw->priv; bool blocked; - LOCK(wl); + spin_lock_bh(&wl->lock); blocked = brcms_c_check_radio_disabled(wl->wlc); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); } @@ -719,9 +699,9 @@ static void brcms_ops_flush(struct ieee80211_hw *hw, bool drop) no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false"); /* wait for packet queue and dma fifos to run empty */ - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_c_wait_for_tx_completion(wl->wlc, drop); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } static const struct ieee80211_ops brcms_ops = { @@ -756,16 +736,16 @@ void brcms_dpc(unsigned long data) wl = (struct brcms_info *) data; - LOCK(wl); + spin_lock_bh(&wl->lock); /* call the common second level interrupt handler */ if (wl->pub->up) { if (wl->resched) { unsigned long flags; - INT_LOCK(wl, flags); + spin_lock_irqsave(&wl->isr_lock, flags); brcms_c_intrsupd(wl->wlc); - INT_UNLOCK(wl, flags); + spin_unlock_irqrestore(&wl->isr_lock, flags); } wl->resched = brcms_c_dpc(wl->wlc, true); @@ -783,7 +763,7 @@ void brcms_dpc(unsigned long data) brcms_intrson(wl); done: - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } /* @@ -912,9 +892,9 @@ static void brcms_remove(struct pci_dev *pdev) return; } - LOCK(wl); + spin_lock_bh(&wl->lock); status = brcms_c_chipmatch(pdev->vendor, pdev->device); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); if (!status) { wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " "failed\n"); @@ -924,9 +904,9 @@ static void brcms_remove(struct pci_dev *pdev) wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); ieee80211_unregister_hw(hw); - LOCK(wl); + spin_lock_bh(&wl->lock); brcms_down(wl); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); } pci_disable_device(pdev); @@ -940,11 +920,10 @@ static irqreturn_t brcms_isr(int irq, void *dev_id) { struct brcms_info *wl; bool ours, wantdpc; - unsigned long flags; wl = (struct brcms_info *) dev_id; - ISR_LOCK(wl, flags); + spin_lock(&wl->isr_lock); /* call common first level interrupt handler */ ours = brcms_c_isr(wl->wlc, &wantdpc); @@ -958,7 +937,7 @@ static irqreturn_t brcms_isr(int irq, void *dev_id) } } - ISR_UNLOCK(wl, flags); + spin_unlock(&wl->isr_lock); return IRQ_RETVAL(ours); } @@ -1226,9 +1205,9 @@ static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) } /* only need to flag hw is down for proper resume */ - LOCK(wl); + spin_lock_bh(&wl->lock); wl->pub->hw_up = false; - UNLOCK(wl); + spin_unlock_bh(&wl->lock); pci_save_state(pdev); pci_disable_device(pdev); @@ -1365,9 +1344,9 @@ void brcms_intrson(struct brcms_info *wl) { unsigned long flags; - INT_LOCK(wl, flags); + spin_lock_irqsave(&wl->isr_lock, flags); brcms_c_intrson(wl->wlc); - INT_UNLOCK(wl, flags); + spin_unlock_irqrestore(&wl->isr_lock, flags); } u32 brcms_intrsoff(struct brcms_info *wl) @@ -1375,9 +1354,9 @@ u32 brcms_intrsoff(struct brcms_info *wl) unsigned long flags; u32 status; - INT_LOCK(wl, flags); + spin_lock_irqsave(&wl->isr_lock, flags); status = brcms_c_intrsoff(wl->wlc); - INT_UNLOCK(wl, flags); + spin_unlock_irqrestore(&wl->isr_lock, flags); return status; } @@ -1385,9 +1364,9 @@ void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask) { unsigned long flags; - INT_LOCK(wl, flags); + spin_lock_irqsave(&wl->isr_lock, flags); brcms_c_intrsrestore(wl->wlc, macintmask); - INT_UNLOCK(wl, flags); + spin_unlock_irqrestore(&wl->isr_lock, flags); } /* @@ -1417,14 +1396,14 @@ void brcms_down(struct brcms_info *wl) callbacks = atomic_read(&wl->callbacks) - ret_val; /* wait for down callbacks to complete */ - UNLOCK(wl); + spin_unlock_bh(&wl->lock); /* For HIGH_only driver, it's important to actually schedule other work, * not just spin wait since everything runs at schedule level */ SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000); - LOCK(wl); + spin_lock_bh(&wl->lock); } /* @@ -1432,7 +1411,7 @@ void brcms_down(struct brcms_info *wl) */ void brcms_timer(struct brcms_timer *t) { - LOCK(t->wl); + spin_lock_bh(&t->wl->lock); if (t->set) { if (t->periodic) { @@ -1448,7 +1427,7 @@ void brcms_timer(struct brcms_timer *t) atomic_dec(&t->wl->callbacks); - UNLOCK(t->wl); + spin_unlock_bh(&t->wl->lock); } /* @@ -1703,11 +1682,11 @@ bool brcms_rfkill_set_hw_state(struct brcms_info *wl) { bool blocked = brcms_c_check_radio_disabled(wl->wlc); - UNLOCK(wl); + spin_unlock_bh(&wl->lock); wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); if (blocked) wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy); - LOCK(wl); + spin_lock_bh(&wl->lock); return blocked; } @@ -1716,7 +1695,7 @@ bool brcms_rfkill_set_hw_state(struct brcms_info *wl) */ void brcms_msleep(struct brcms_info *wl, uint ms) { - UNLOCK(wl); + spin_unlock_bh(&wl->lock); msleep(ms); - LOCK(wl); + spin_lock_bh(&wl->lock); } From bbbf4f42f59e9e1412239102d055bcc1c5f54eaf Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:06 +0200 Subject: [PATCH 1346/1519] staging: brcm80211: fix thread blocking issue in brcmf_sdbrcm_bus_stop() The function brcmf_sdbrcm_bus_stop() terminates the watchdog and dpc thread, but this function can be called from the dpc thread itself. Stopping the dpc thread is only done when it is not the 'current' thread. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 0f7b80da41d..6885755f4ec 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -2694,7 +2694,10 @@ static int brcmf_sdbrcm_dpc_thread(void *data) if (brcmf_sdbrcm_dpc(bus)) complete(&bus->dpc_wait); } else { + /* after stopping the bus, exit thread */ brcmf_sdbrcm_bus_stop(bus); + bus->dpc_tsk = NULL; + break; } } else break; @@ -3601,25 +3604,25 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) brcmf_dbg(TRACE, "Enter\n"); - down(&bus->sdsem); - - bus_wake(bus); - - /* Enable clock for device interrupts */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - if (bus->watchdog_tsk) { send_sig(SIGTERM, bus->watchdog_tsk, 1); kthread_stop(bus->watchdog_tsk); bus->watchdog_tsk = NULL; } - if (bus->dpc_tsk) { + if (bus->dpc_tsk && bus->dpc_tsk != current) { send_sig(SIGTERM, bus->dpc_tsk, 1); kthread_stop(bus->dpc_tsk); bus->dpc_tsk = NULL; } + down(&bus->sdsem); + + bus_wake(bus); + + /* Enable clock for device interrupts */ + brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); + /* Disable and clear interrupts at the chip level also */ w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries); local_hostintmask = bus->hostintmask; From 83773bcede6f0a4c31119dff6a0eb70dc74e4110 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:07 +0200 Subject: [PATCH 1347/1519] staging: brcm80211: remove invalid variable lookup from srom In the driver several driver variables were looked up that are not supported by the srom code. These have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Reviewed-by: Brett Rudley Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 6 ++-- drivers/staging/brcm80211/brcmsmac/main.c | 34 ++----------------- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 6 ---- 3 files changed, 5 insertions(+), 41 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index d44f619005f..2bc4bb36611 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1109,10 +1109,8 @@ static struct si_info *ai_doattach(struct si_info *sii, u32 xtalfreq; si_pmu_init(sih); si_pmu_chip_init(sih); - xtalfreq = getintvar(sih, "xtalfreq"); - /* If xtalfreq var not available, try to measure it */ - if (xtalfreq == 0) - xtalfreq = si_pmu_measure_alpclk(sih); + + xtalfreq = si_pmu_measure_alpclk(sih); si_pmu_pll_init(sih, xtalfreq); si_pmu_res_init(sih); si_pmu_swreg_init(sih); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index f2339a5f8dd..cfa918d36f6 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -4557,8 +4557,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, bool wme = false; struct shared_phy_params sha_params; struct wiphy *wiphy = wlc->wiphy; - char *var; - unsigned long res; BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, device); @@ -4588,27 +4586,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, } vars = wlc_hw->vars; - /* - * Get vendid/devid nvram overwrites, which could be different - * than those the BIOS recognizes for devices on PCMCIA_BUS, - * SDIO_BUS, and SROMless devices on PCI_BUS. - */ - var = getvar(wlc_hw->sih, "vendid"); - if (var && !kstrtoul(var, 0, &res)) { - vendor = (u16)res; - wiphy_err(wiphy, "Overriding vendor id = 0x%x\n", - vendor); - } - var = getvar(wlc_hw->sih, "devid"); - if (var && !kstrtoul(var, 0, &res)) { - u16 devid = (u16)res; - if (devid != 0xffff) { - device = devid; - wiphy_err(wiphy, "Overriding device id = 0x%x" - "\n", device); - } - } - /* verify again the device is supported */ if (!brcms_c_chipmatch(vendor, device)) { wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " @@ -4928,9 +4905,6 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) /* get antennas available */ aa = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? "aa5g" : "aa2g"); - if (aa == 0) - aa = (s8) getintvar(sih, - bandtype == BRCM_BAND_5G ? "aa1" : "aa0"); if ((aa < 1) || (aa > 15)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" " srom (0x%x), using 3\n", unit, __func__, aa); @@ -5113,11 +5087,9 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, brcms_b_copyfrom_vars(wlc->hw, &pub->vars, &wlc->vars_size); - /* set maximum allowed duty cycle */ - wlc->tx_duty_cycle_ofdm = - (u16) getintvar(wlc->hw->sih, "tx_duty_cycle_ofdm"); - wlc->tx_duty_cycle_cck = - (u16) getintvar(wlc->hw->sih, "tx_duty_cycle_cck"); + /* disable allowed duty cycle */ + wlc->tx_duty_cycle_ofdm = 0; + wlc->tx_duty_cycle_cck = 0; brcms_c_stf_phy_chain_calc(wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index d84e1cf5dc5..4bcf30543b3 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -4920,12 +4920,6 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) "aa2g")); } pi_lcn->lcnphy_cck_dig_filt_type = -1; - if (wlapi_getvar(shim, "cckdigfilttype")) { - s16 temp; - temp = (s16)wlapi_getintvar(shim, "cckdigfilttype"); - if (temp >= 0) - pi_lcn->lcnphy_cck_dig_filt_type = temp; - } return true; } From fe19e50ed9c78dc52902259d1457b122bd10bf12 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:08 +0200 Subject: [PATCH 1348/1519] staging: brcm80211: use identifiers instead of string for srom lookup The driver variables from srom are stored in memory with string identifiers and the caller needed to use this string identifier to retrieve a driver variable. The commit changes the calling code replacing strings with enumerated identifiers. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 4 +- drivers/staging/brcm80211/brcmsmac/antsel.c | 14 +- drivers/staging/brcm80211/brcmsmac/channel.c | 2 +- drivers/staging/brcm80211/brcmsmac/main.c | 35 ++- drivers/staging/brcm80211/brcmsmac/nicpci.c | 3 +- .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 56 ++-- .../staging/brcm80211/brcmsmac/phy/phy_n.c | 292 ++++++++++++------ drivers/staging/brcm80211/brcmsmac/phy_shim.c | 8 +- drivers/staging/brcm80211/brcmsmac/phy_shim.h | 5 +- drivers/staging/brcm80211/brcmsmac/pub.h | 262 +++++++++++++++- drivers/staging/brcm80211/brcmsmac/srom.c | 284 ++++++++++++++++- drivers/staging/brcm80211/brcmsmac/stf.c | 4 +- 12 files changed, 800 insertions(+), 169 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 2bc4bb36611..6086c264b17 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1021,7 +1021,7 @@ static __used void ai_nvram_process(struct si_info *sii) sii->pub.boardvendor = w & 0xffff; sii->pub.boardtype = (w >> 16) & 0xffff; - sii->pub.boardflags = getintvar(&sii->pub, "boardflags"); + sii->pub.boardflags = getintvar(&sii->pub, BRCMS_SROM_BOARDFLAGS); } static struct si_info *ai_doattach(struct si_info *sii, @@ -1117,7 +1117,7 @@ static struct si_info *ai_doattach(struct si_info *sii, } /* setup the GPIO based LED powersave register */ - w = getintvar(sih, "leddc"); + w = getintvar(sih, BRCMS_SROM_LEDDC); if (w == 0) w = DEFAULT_GPIOTIMERVAL; ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c index eedcdb68294..edc4016fd9a 100644 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/antsel.c @@ -118,7 +118,7 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) asi->pub = wlc->pub; asi->antsel_type = ANTSEL_NA; asi->antsel_avail = false; - asi->antsel_antswitch = (u8) getintvar(sih, "antswitch"); + asi->antsel_antswitch = (u8) getintvar(sih, BRCMS_SROM_ANTSWITCH); if ((asi->pub->sromrev >= 4) && (asi->antsel_antswitch != 0)) { switch (asi->antsel_antswitch) { @@ -128,12 +128,12 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) /* 4321/2 board with 2x3 switch logic */ asi->antsel_type = ANTSEL_2x3; /* Antenna selection availability */ - if (((u16) getintvar(sih, "aa2g") == 7) || - ((u16) getintvar(sih, "aa5g") == 7)) { + if (((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) || + ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 7)) { asi->antsel_avail = true; } else if ( - (u16) getintvar(sih, "aa2g") == 3 || - (u16) getintvar(sih, "aa5g") == 3) { + (u16) getintvar(sih, BRCMS_SROM_AA2G) == 3 || + (u16) getintvar(sih, BRCMS_SROM_AA5G) == 3) { asi->antsel_avail = false; } else { asi->antsel_avail = false; @@ -146,8 +146,8 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) break; } } else if ((asi->pub->sromrev == 4) && - ((u16) getintvar(sih, "aa2g") == 7) && - ((u16) getintvar(sih, "aa5g") == 0)) { + ((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) && + ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 0)) { /* hack to match old 4321CB2 cards with 2of3 antenna switch */ asi->antsel_type = ANTSEL_2x3; asi->antsel_avail = true; diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c index 53066fb8af8..a1b415da6c3 100644 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ b/drivers/staging/brcm80211/brcmsmac/channel.c @@ -1088,7 +1088,7 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) wlc->cmi = wlc_cm; /* store the country code for passing up as a regulatory hint */ - ccode = getvar(wlc->hw->sih, "ccode"); + ccode = getvar(wlc->hw->sih, BRCMS_SROM_CCODE); if (ccode) strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index cfa918d36f6..5ec25e89eef 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -1986,23 +1986,23 @@ static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) { - const char *varname = "macaddr"; + enum brcms_srom_id var_id = BRCMS_SROM_MACADDR; char *macaddr; /* If macaddr exists, use it (Sromrev4, CIS, ...). */ - macaddr = getvar(wlc_hw->sih, varname); + macaddr = getvar(wlc_hw->sih, var_id); if (macaddr != NULL) return macaddr; if (wlc_hw->_nbands > 1) - varname = "et1macaddr"; + var_id = BRCMS_SROM_ET1MACADDR; else - varname = "il0macaddr"; + var_id = BRCMS_SROM_IL0MACADDR; - macaddr = getvar(wlc_hw->sih, varname); + macaddr = getvar(wlc_hw->sih, var_id); if (macaddr == NULL) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " - "getvar(%s) not found\n", wlc_hw->unit, varname); + "getvar(%d) not found\n", wlc_hw->unit, var_id); return macaddr; } @@ -4633,7 +4633,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, } /* get the board rev, used just below */ - j = getintvar(wlc_hw->sih, "boardrev"); + j = getintvar(wlc_hw->sih, BRCMS_SROM_BOARDREV); /* promote srom boardrev of 0xFF to 1 */ if (j == BOARDREV_PROMOTABLE) j = BOARDREV_PROMOTED; @@ -4645,9 +4645,11 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, err = 15; goto fail; } - wlc_hw->sromrev = (u8) getintvar(wlc_hw->sih, "sromrev"); - wlc_hw->boardflags = (u32) getintvar(wlc_hw->sih, "boardflags"); - wlc_hw->boardflags2 = (u32) getintvar(wlc_hw->sih, "boardflags2"); + wlc_hw->sromrev = (u8) getintvar(wlc_hw->sih, BRCMS_SROM_REV); + wlc_hw->boardflags = (u32) getintvar(wlc_hw->sih, + BRCMS_SROM_BOARDFLAGS); + wlc_hw->boardflags2 = (u32) getintvar(wlc_hw->sih, + BRCMS_SROM_BOARDFLAGS2); if (wlc_hw->boardflags & BFL_NOPLLDOWN) brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); @@ -4904,7 +4906,11 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) bandtype = wlc->band->bandtype; /* get antennas available */ - aa = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? "aa5g" : "aa2g"); + if (bandtype == BRCM_BAND_5G) + aa = (s8) getintvar(sih, BRCMS_SROM_AA5G); + else + aa = (s8) getintvar(sih, BRCMS_SROM_AA2G); + if ((aa < 1) || (aa > 15)) { wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" " srom (0x%x), using 3\n", unit, __func__, aa); @@ -4922,8 +4928,11 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) } /* Compute Antenna Gain */ - wlc->band->antgain = (s8) getintvar(sih, bandtype == BRCM_BAND_5G ? - "ag1" : "ag0"); + if (bandtype == BRCM_BAND_5G) + wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG1); + else + wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG0); + brcms_c_attach_antgain_init(wlc); return true; diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 57721a0c32b..0bcb2679204 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -722,10 +722,11 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) void pcicore_attach(struct pcicore_info *pi, int state) { struct si_pub *sih = pi->sih; + u32 bfl2 = (u32)getintvar(sih, BRCMS_SROM_BOARDFLAGS2); /* Determine if this board needs override */ if (PCIE_ASPM(sih)) { - if ((u32)getintvar(sih, "boardflags2") & BFL2_PCIEWAR_OVR) + if (bfl2 & BFL2_PCIEWAR_OVR) pi->pcie_war_aspm_ovr = PCIE_ASPM_DISAB; else pi->pcie_war_aspm_ovr = PCIE_ASPM_ENAB; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c index 4bcf30543b3..a63aa99d981 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c @@ -4824,18 +4824,21 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) u32 offset_ofdm, offset_mcs; pi_lcn->lcnphy_tr_isolation_mid = - (u8)wlapi_getintvar(shim, "triso2g"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_TRISO2G); pi_lcn->lcnphy_rx_power_offset = - (u8)wlapi_getintvar(shim, "rxpo2g"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_RXPO2G); - pi->txpa_2g[0] = (s16)wlapi_getintvar(shim, "pa0b0"); - pi->txpa_2g[1] = (s16)wlapi_getintvar(shim, "pa0b1"); - pi->txpa_2g[2] = (s16)wlapi_getintvar(shim, "pa0b2"); + pi->txpa_2g[0] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B0); + pi->txpa_2g[1] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B1); + pi->txpa_2g[2] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B2); - pi_lcn->lcnphy_rssi_vf = (u8)wlapi_getintvar(shim, "rssismf2g"); - pi_lcn->lcnphy_rssi_vc = (u8)wlapi_getintvar(shim, "rssismc2g"); - pi_lcn->lcnphy_rssi_gs = (u8)wlapi_getintvar(shim, "rssisav2g"); + pi_lcn->lcnphy_rssi_vf = + (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMF2G); + pi_lcn->lcnphy_rssi_vc = + (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMC2G); + pi_lcn->lcnphy_rssi_gs = + (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISAV2G); pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; @@ -4845,7 +4848,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc; pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs; - txpwr = (s8)wlapi_getintvar(shim, "maxp2ga0"); + txpwr = (s8)wlapi_getintvar(shim, BRCMS_SROM_MAXP2GA0); pi->tx_srom_max_2g = txpwr; for (i = 0; i < PWRTBL_NUM_COEFF; i++) { @@ -4853,7 +4856,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) pi->txpa_2g_high_temp[i] = pi->txpa_2g[i]; } - cckpo = (u16)wlapi_getintvar(shim, "cck2gpo"); + cckpo = (u16)wlapi_getintvar(shim, BRCMS_SROM_CCK2GPO); + offset_ofdm = (u32)wlapi_getintvar(shim, BRCMS_SROM_OFDM2GPO); if (cckpo) { uint max_pwr_chan = txpwr; @@ -4863,7 +4867,6 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) cckpo >>= 4; } - offset_ofdm = (u32)wlapi_getintvar(shim, "ofdm2gpo"); for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = max_pwr_chan - @@ -4873,22 +4876,22 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } else { u8 opo = 0; - opo = (u8)wlapi_getintvar(shim, "opo"); + opo = (u8)wlapi_getintvar(shim, BRCMS_SROM_OPO); for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) pi->tx_srom_max_rate_2g[i] = txpwr; - offset_ofdm = (u32)wlapi_getintvar(shim, "ofdm2gpo"); - for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { pi->tx_srom_max_rate_2g[i] = txpwr - ((offset_ofdm & 0xf) * 2); offset_ofdm >>= 4; } offset_mcs = - wlapi_getintvar(shim, "mcs2gpo1") << 16; + wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO1) << 16; offset_mcs |= - (u16) wlapi_getintvar(shim, "mcs2gpo0"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO0); pi_lcn->lcnphy_mcs20_po = offset_mcs; for (i = TXP_FIRST_SISO_MCS_20; i <= TXP_LAST_SISO_MCS_20; i++) { @@ -4899,25 +4902,24 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) } pi_lcn->lcnphy_rawtempsense = - (u16)wlapi_getintvar(shim, "rawtempsense"); + (u16)wlapi_getintvar(shim, BRCMS_SROM_RAWTEMPSENSE); pi_lcn->lcnphy_measPower = - (u8)wlapi_getintvar(shim, "measpower"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_MEASPOWER); pi_lcn->lcnphy_tempsense_slope = - (u8)wlapi_getintvar(shim, "tempsense_slope"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_SLOPE); pi_lcn->lcnphy_hw_iqcal_en = - (bool)wlapi_getintvar(shim, "hw_iqcal_en"); + (bool)wlapi_getintvar(shim, BRCMS_SROM_HW_IQCAL_EN); pi_lcn->lcnphy_iqcal_swp_dis = - (bool)wlapi_getintvar(shim, "iqcal_swp_dis"); + (bool)wlapi_getintvar(shim, BRCMS_SROM_IQCAL_SWP_DIS); pi_lcn->lcnphy_tempcorrx = - (u8)wlapi_getintvar(shim, "tempcorrx"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPCORRX); pi_lcn->lcnphy_tempsense_option = - (u8)wlapi_getintvar(shim, "tempsense_option"); + (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_OPTION); pi_lcn->lcnphy_freqoffset_corr = - (u8)wlapi_getintvar(shim, "freqoffset_corr"); - if ((u8)wlapi_getintvar(shim, "aa2g") > 1) + (u8)wlapi_getintvar(shim, BRCMS_SROM_FREQOFFSET_CORR); + if ((u8)wlapi_getintvar(shim, BRCMS_SROM_AA2G) > 1) wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, - (u8) wlapi_getintvar(shim, - "aa2g")); + (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G)); } pi_lcn->lcnphy_cck_dig_filt_type = -1; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c index a4417e9ab90..cd19c2f7a34 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c @@ -14388,25 +14388,25 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) if (pi->sh->sromrev >= 9) return; - bw40po = (u16) wlapi_getintvar(shim, "bw40po"); + bw40po = (u16) wlapi_getintvar(shim, BRCMS_SROM_BW40PO); pi->bw402gpo = bw40po & 0xf; pi->bw405gpo = (bw40po & 0xf0) >> 4; pi->bw405glpo = (bw40po & 0xf00) >> 8; pi->bw405ghpo = (bw40po & 0xf000) >> 12; - cddpo = (u16) wlapi_getintvar(shim, "cddpo"); + cddpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_CDDPO); pi->cdd2gpo = cddpo & 0xf; pi->cdd5gpo = (cddpo & 0xf0) >> 4; pi->cdd5glpo = (cddpo & 0xf00) >> 8; pi->cdd5ghpo = (cddpo & 0xf000) >> 12; - stbcpo = (u16) wlapi_getintvar(shim, "stbcpo"); + stbcpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_STBCPO); pi->stbc2gpo = stbcpo & 0xf; pi->stbc5gpo = (stbcpo & 0xf0) >> 4; pi->stbc5glpo = (stbcpo & 0xf00) >> 8; pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; - bwduppo = (u16) wlapi_getintvar(shim, "bwduppo"); + bwduppo = (u16) wlapi_getintvar(shim, BRCMS_SROM_BWDUPPO); pi->bwdup2gpo = bwduppo & 0xf; pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; @@ -14418,186 +14418,264 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) case 0: pi->nphy_txpid2g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, "txpid2ga0"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID2GA0); pi->nphy_txpid2g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, "txpid2ga1"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID2GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) wlapi_getintvar(shim, "maxp2ga0"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP2GA0); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) wlapi_getintvar(shim, "maxp2ga1"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP2GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) wlapi_getintvar(shim, "pa2gw0a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW0A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) wlapi_getintvar(shim, "pa2gw0a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW0A1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) wlapi_getintvar(shim, "pa2gw1a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW1A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) wlapi_getintvar(shim, "pa2gw1a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW1A1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) wlapi_getintvar(shim, "pa2gw2a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW2A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) wlapi_getintvar(shim, "pa2gw2a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA2GW2A1); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) wlapi_getintvar(shim, "itt2ga0"); + (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA0); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) wlapi_getintvar(shim, "itt2ga1"); + (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA1); - pi->cck2gpo = (u16) wlapi_getintvar(shim, "cck2gpo"); + pi->cck2gpo = (u16) wlapi_getintvar(shim, + BRCMS_SROM_CCK2GPO); - pi->ofdm2gpo = (u32) wlapi_getintvar(shim, "ofdm2gpo"); + pi->ofdm2gpo = + (u32) wlapi_getintvar(shim, + BRCMS_SROM_OFDM2GPO); pi->mcs2gpo[0] = - (u16) wlapi_getintvar(shim, "mcs2gpo0"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO0); pi->mcs2gpo[1] = - (u16) wlapi_getintvar(shim, "mcs2gpo1"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO1); pi->mcs2gpo[2] = - (u16) wlapi_getintvar(shim, "mcs2gpo2"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO2); pi->mcs2gpo[3] = - (u16) wlapi_getintvar(shim, "mcs2gpo3"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO3); pi->mcs2gpo[4] = - (u16) wlapi_getintvar(shim, "mcs2gpo4"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO4); pi->mcs2gpo[5] = - (u16) wlapi_getintvar(shim, "mcs2gpo5"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO5); pi->mcs2gpo[6] = - (u16) wlapi_getintvar(shim, "mcs2gpo6"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO6); pi->mcs2gpo[7] = - (u16) wlapi_getintvar(shim, "mcs2gpo7"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS2GPO7); break; case 1: pi->nphy_txpid5g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, "txpid5ga0"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GA0); pi->nphy_txpid5g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, "txpid5ga1"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) wlapi_getintvar(shim, "maxp5ga0"); + (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) wlapi_getintvar(shim, "maxp5ga1"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP5GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(shim, "pa5gw0a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW0A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(shim, "pa5gw0a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW0A1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(shim, "pa5gw1a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW1A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(shim, "pa5gw1a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW1A1); pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(shim, "pa5gw2a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW2A0); pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(shim, "pa5gw2a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GW2A1); pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) wlapi_getintvar(shim, "itt5ga0"); + (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA0); pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) wlapi_getintvar(shim, "itt5ga1"); + (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA1); - pi->ofdm5gpo = (u32) wlapi_getintvar(shim, "ofdm5gpo"); + pi->ofdm5gpo = + (u32) wlapi_getintvar(shim, + BRCMS_SROM_OFDM5GPO); pi->mcs5gpo[0] = - (u16) wlapi_getintvar(shim, "mcs5gpo0"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO0); pi->mcs5gpo[1] = - (u16) wlapi_getintvar(shim, "mcs5gpo1"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO1); pi->mcs5gpo[2] = - (u16) wlapi_getintvar(shim, "mcs5gpo2"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO2); pi->mcs5gpo[3] = - (u16) wlapi_getintvar(shim, "mcs5gpo3"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO3); pi->mcs5gpo[4] = - (u16) wlapi_getintvar(shim, "mcs5gpo4"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO4); pi->mcs5gpo[5] = - (u16) wlapi_getintvar(shim, "mcs5gpo5"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO5); pi->mcs5gpo[6] = - (u16) wlapi_getintvar(shim, "mcs5gpo6"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO6); pi->mcs5gpo[7] = - (u16) wlapi_getintvar(shim, "mcs5gpo7"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GPO7); break; case 2: pi->nphy_txpid5gl[0] = - (u8) wlapi_getintvar(shim, "txpid5gla0"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GLA0); pi->nphy_txpid5gl[1] = - (u8) wlapi_getintvar(shim, "txpid5gla1"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GLA1); pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) wlapi_getintvar(shim, "maxp5gla0"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP5GLA0); pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) wlapi_getintvar(shim, "maxp5gla1"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP5GLA1); pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(shim, "pa5glw0a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW0A0); pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(shim, "pa5glw0a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW0A1); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(shim, "pa5glw1a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW1A0); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(shim, "pa5glw1a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW1A1); pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(shim, "pa5glw2a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW2A0); pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(shim, "pa5glw2a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GLW2A1); pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; pi->ofdm5glpo = - (u32) wlapi_getintvar(shim, "ofdm5glpo"); + (u32) wlapi_getintvar(shim, + BRCMS_SROM_OFDM5GLPO); pi->mcs5glpo[0] = - (u16) wlapi_getintvar(shim, "mcs5glpo0"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO0); pi->mcs5glpo[1] = - (u16) wlapi_getintvar(shim, "mcs5glpo1"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO1); pi->mcs5glpo[2] = - (u16) wlapi_getintvar(shim, "mcs5glpo2"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO2); pi->mcs5glpo[3] = - (u16) wlapi_getintvar(shim, "mcs5glpo3"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO3); pi->mcs5glpo[4] = - (u16) wlapi_getintvar(shim, "mcs5glpo4"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO4); pi->mcs5glpo[5] = - (u16) wlapi_getintvar(shim, "mcs5glpo5"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO5); pi->mcs5glpo[6] = - (u16) wlapi_getintvar(shim, "mcs5glpo6"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO6); pi->mcs5glpo[7] = - (u16) wlapi_getintvar(shim, "mcs5glpo7"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GLPO7); break; case 3: pi->nphy_txpid5gh[0] = - (u8) wlapi_getintvar(shim, "txpid5gha0"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GHA0); pi->nphy_txpid5gh[1] = - (u8) wlapi_getintvar(shim, "txpid5gha1"); + (u8) wlapi_getintvar(shim, + BRCMS_SROM_TXPID5GHA1); pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) wlapi_getintvar(shim, "maxp5gha0"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP5GHA0); pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) wlapi_getintvar(shim, "maxp5gha1"); + (s8) wlapi_getintvar(shim, + BRCMS_SROM_MAXP5GHA1); pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(shim, "pa5ghw0a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW0A0); pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(shim, "pa5ghw0a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW0A1); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(shim, "pa5ghw1a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW1A0); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(shim, "pa5ghw1a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW1A1); pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(shim, "pa5ghw2a0"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW2A0); pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(shim, "pa5ghw2a1"); + (s16) wlapi_getintvar(shim, + BRCMS_SROM_PA5GHW2A1); pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; pi->ofdm5ghpo = - (u32) wlapi_getintvar(shim, "ofdm5ghpo"); + (u32) wlapi_getintvar(shim, + BRCMS_SROM_OFDM5GHPO); pi->mcs5ghpo[0] = - (u16) wlapi_getintvar(shim, "mcs5ghpo0"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO0); pi->mcs5ghpo[1] = - (u16) wlapi_getintvar(shim, "mcs5ghpo1"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO1); pi->mcs5ghpo[2] = - (u16) wlapi_getintvar(shim, "mcs5ghpo2"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO2); pi->mcs5ghpo[3] = - (u16) wlapi_getintvar(shim, "mcs5ghpo3"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO3); pi->mcs5ghpo[4] = - (u16) wlapi_getintvar(shim, "mcs5ghpo4"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO4); pi->mcs5ghpo[5] = - (u16) wlapi_getintvar(shim, "mcs5ghpo5"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO5); pi->mcs5ghpo[6] = - (u16) wlapi_getintvar(shim, "mcs5ghpo6"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO6); pi->mcs5ghpo[7] = - (u16) wlapi_getintvar(shim, "mcs5ghpo7"); + (u16) wlapi_getintvar(shim, + BRCMS_SROM_MCS5GHPO7); break; } } @@ -14609,35 +14687,43 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) { struct phy_shim_info *shim = pi->sh->physhim; - pi->antswitch = (u8) wlapi_getintvar(shim, "antswitch"); - pi->aa2g = (u8) wlapi_getintvar(shim, "aa2g"); - pi->aa5g = (u8) wlapi_getintvar(shim, "aa5g"); + pi->antswitch = (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWITCH); + pi->aa2g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G); + pi->aa5g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA5G); - pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(shim, "tssipos2g"); - pi->srom_fem2g.extpagain = (u8) wlapi_getintvar(shim, "extpagain2g"); - pi->srom_fem2g.pdetrange = (u8) wlapi_getintvar(shim, "pdetrange2g"); - pi->srom_fem2g.triso = (u8) wlapi_getintvar(shim, "triso2g"); - pi->srom_fem2g.antswctrllut = (u8) wlapi_getintvar(shim, "antswctl2g"); + pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(shim, + BRCMS_SROM_TSSIPOS2G); + pi->srom_fem2g.extpagain = (u8) wlapi_getintvar(shim, + BRCMS_SROM_EXTPAGAIN2G); + pi->srom_fem2g.pdetrange = (u8) wlapi_getintvar(shim, + BRCMS_SROM_PDETRANGE2G); + pi->srom_fem2g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO2G); + pi->srom_fem2g.antswctrllut = + (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G); - pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(shim, "tssipos5g"); - pi->srom_fem5g.extpagain = (u8) wlapi_getintvar(shim, "extpagain5g"); - pi->srom_fem5g.pdetrange = (u8) wlapi_getintvar(shim, "pdetrange5g"); - pi->srom_fem5g.triso = (u8) wlapi_getintvar(shim, "triso5g"); - if (wlapi_getvar(shim, "antswctl5g")) + pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(shim, + BRCMS_SROM_TSSIPOS5G); + pi->srom_fem5g.extpagain = (u8) wlapi_getintvar(shim, + BRCMS_SROM_EXTPAGAIN5G); + pi->srom_fem5g.pdetrange = (u8) wlapi_getintvar(shim, + BRCMS_SROM_PDETRANGE5G); + pi->srom_fem5g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO5G); + if (wlapi_getvar(shim, BRCMS_SROM_ANTSWCTL5G)) pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(shim, "antswctl5g"); + (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL5G); else pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(shim, "antswctl2g"); + (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G); wlc_phy_txpower_ipa_upd(pi); pi->phy_txcore_disable_temp = - (s16) wlapi_getintvar(shim, "tempthresh"); + (s16) wlapi_getintvar(shim, BRCMS_SROM_TEMPTHRESH); if (pi->phy_txcore_disable_temp == 0) pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - pi->phy_tempsense_offset = (s8) wlapi_getintvar(shim, "tempoffset"); + pi->phy_tempsense_offset = (s8) wlapi_getintvar(shim, + BRCMS_SROM_TEMPOFFSET); if (pi->phy_tempsense_offset != 0) { if (pi->phy_tempsense_offset > (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) @@ -14653,7 +14739,7 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; pi->phycal_tempdelta = - (u8) wlapi_getintvar(shim, "phycal_tempdelta"); + (u8) wlapi_getintvar(shim, BRCMS_SROM_PHYCAL_TEMPDELTA); if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) pi->phycal_tempdelta = 0; diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c index 57122fc4c78..676222ec2b8 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.c @@ -216,11 +216,11 @@ wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf, brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel); } -char *wlapi_getvar(struct phy_shim_info *physhim, const char *name) +char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id) { - return getvar(physhim->wlc_hw->sih, name); + return getvar(physhim->wlc_hw->sih, id); } -int wlapi_getintvar(struct phy_shim_info *physhim, const char *name) +int wlapi_getintvar(struct phy_shim_info *physhim, enum brcms_srom_id id) { - return getintvar(physhim->wlc_hw->sih, name); + return getintvar(physhim->wlc_hw->sih, id); } diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h index ca76153f79c..8de549dfb1c 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/phy_shim.h @@ -178,7 +178,8 @@ extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode); extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim); -extern char *wlapi_getvar(struct phy_shim_info *physhim, const char *name); -extern int wlapi_getintvar(struct phy_shim_info *physhim, const char *name); +extern char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id); +extern int wlapi_getintvar(struct phy_shim_info *physhim, + enum brcms_srom_id id); #endif /* _BRCM_PHY_SHIM_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index d1639b44bd7..8c9ac8f4ee0 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -21,6 +21,264 @@ #include "types.h" #include "defs.h" +enum brcms_srom_id { + BRCMS_SROM_NULL, + BRCMS_SROM_CONT, + BRCMS_SROM_AA2G, + BRCMS_SROM_AA5G, + BRCMS_SROM_AG0, + BRCMS_SROM_AG1, + BRCMS_SROM_AG2, + BRCMS_SROM_AG3, + BRCMS_SROM_ANTSWCTL2G, + BRCMS_SROM_ANTSWCTL5G, + BRCMS_SROM_ANTSWITCH, + BRCMS_SROM_BOARDFLAGS2, + BRCMS_SROM_BOARDFLAGS, + BRCMS_SROM_BOARDNUM, + BRCMS_SROM_BOARDREV, + BRCMS_SROM_BOARDTYPE, + BRCMS_SROM_BW40PO, + BRCMS_SROM_BWDUPPO, + BRCMS_SROM_BXA2G, + BRCMS_SROM_BXA5G, + BRCMS_SROM_CC, + BRCMS_SROM_CCK2GPO, + BRCMS_SROM_CCKBW202GPO, + BRCMS_SROM_CCKBW20UL2GPO, + BRCMS_SROM_CCODE, + BRCMS_SROM_CDDPO, + BRCMS_SROM_DEVID, + BRCMS_SROM_ET1MACADDR, + BRCMS_SROM_EXTPAGAIN2G, + BRCMS_SROM_EXTPAGAIN5G, + BRCMS_SROM_FREQOFFSET_CORR, + BRCMS_SROM_HW_IQCAL_EN, + BRCMS_SROM_IL0MACADDR, + BRCMS_SROM_IQCAL_SWP_DIS, + BRCMS_SROM_LEDBH0, + BRCMS_SROM_LEDBH1, + BRCMS_SROM_LEDBH2, + BRCMS_SROM_LEDBH3, + BRCMS_SROM_LEDDC, + BRCMS_SROM_LEGOFDM40DUPPO, + BRCMS_SROM_LEGOFDMBW202GPO, + BRCMS_SROM_LEGOFDMBW205GHPO, + BRCMS_SROM_LEGOFDMBW205GLPO, + BRCMS_SROM_LEGOFDMBW205GMPO, + BRCMS_SROM_LEGOFDMBW20UL2GPO, + BRCMS_SROM_LEGOFDMBW20UL5GHPO, + BRCMS_SROM_LEGOFDMBW20UL5GLPO, + BRCMS_SROM_LEGOFDMBW20UL5GMPO, + BRCMS_SROM_MACADDR, + BRCMS_SROM_MCS2GPO0, + BRCMS_SROM_MCS2GPO1, + BRCMS_SROM_MCS2GPO2, + BRCMS_SROM_MCS2GPO3, + BRCMS_SROM_MCS2GPO4, + BRCMS_SROM_MCS2GPO5, + BRCMS_SROM_MCS2GPO6, + BRCMS_SROM_MCS2GPO7, + BRCMS_SROM_MCS32PO, + BRCMS_SROM_MCS5GHPO0, + BRCMS_SROM_MCS5GHPO1, + BRCMS_SROM_MCS5GHPO2, + BRCMS_SROM_MCS5GHPO3, + BRCMS_SROM_MCS5GHPO4, + BRCMS_SROM_MCS5GHPO5, + BRCMS_SROM_MCS5GHPO6, + BRCMS_SROM_MCS5GHPO7, + BRCMS_SROM_MCS5GLPO0, + BRCMS_SROM_MCS5GLPO1, + BRCMS_SROM_MCS5GLPO2, + BRCMS_SROM_MCS5GLPO3, + BRCMS_SROM_MCS5GLPO4, + BRCMS_SROM_MCS5GLPO5, + BRCMS_SROM_MCS5GLPO6, + BRCMS_SROM_MCS5GLPO7, + BRCMS_SROM_MCS5GPO0, + BRCMS_SROM_MCS5GPO1, + BRCMS_SROM_MCS5GPO2, + BRCMS_SROM_MCS5GPO3, + BRCMS_SROM_MCS5GPO4, + BRCMS_SROM_MCS5GPO5, + BRCMS_SROM_MCS5GPO6, + BRCMS_SROM_MCS5GPO7, + BRCMS_SROM_MCSBW202GPO, + BRCMS_SROM_MCSBW205GHPO, + BRCMS_SROM_MCSBW205GLPO, + BRCMS_SROM_MCSBW205GMPO, + BRCMS_SROM_MCSBW20UL2GPO, + BRCMS_SROM_MCSBW20UL5GHPO, + BRCMS_SROM_MCSBW20UL5GLPO, + BRCMS_SROM_MCSBW20UL5GMPO, + BRCMS_SROM_MCSBW402GPO, + BRCMS_SROM_MCSBW405GHPO, + BRCMS_SROM_MCSBW405GLPO, + BRCMS_SROM_MCSBW405GMPO, + BRCMS_SROM_MEASPOWER, + BRCMS_SROM_OFDM2GPO, + BRCMS_SROM_OFDM5GHPO, + BRCMS_SROM_OFDM5GLPO, + BRCMS_SROM_OFDM5GPO, + BRCMS_SROM_OPO, + BRCMS_SROM_PA0B0, + BRCMS_SROM_PA0B1, + BRCMS_SROM_PA0B2, + BRCMS_SROM_PA0ITSSIT, + BRCMS_SROM_PA0MAXPWR, + BRCMS_SROM_PA1B0, + BRCMS_SROM_PA1B1, + BRCMS_SROM_PA1B2, + BRCMS_SROM_PA1HIB0, + BRCMS_SROM_PA1HIB1, + BRCMS_SROM_PA1HIB2, + BRCMS_SROM_PA1HIMAXPWR, + BRCMS_SROM_PA1ITSSIT, + BRCMS_SROM_PA1LOB0, + BRCMS_SROM_PA1LOB1, + BRCMS_SROM_PA1LOB2, + BRCMS_SROM_PA1LOMAXPWR, + BRCMS_SROM_PA1MAXPWR, + BRCMS_SROM_PDETRANGE2G, + BRCMS_SROM_PDETRANGE5G, + BRCMS_SROM_PHYCAL_TEMPDELTA, + BRCMS_SROM_RAWTEMPSENSE, + BRCMS_SROM_REGREV, + BRCMS_SROM_REV, + BRCMS_SROM_RSSISAV2G, + BRCMS_SROM_RSSISAV5G, + BRCMS_SROM_RSSISMC2G, + BRCMS_SROM_RSSISMC5G, + BRCMS_SROM_RSSISMF2G, + BRCMS_SROM_RSSISMF5G, + BRCMS_SROM_RXCHAIN, + BRCMS_SROM_RXPO2G, + BRCMS_SROM_RXPO5G, + BRCMS_SROM_STBCPO, + BRCMS_SROM_TEMPCORRX, + BRCMS_SROM_TEMPOFFSET, + BRCMS_SROM_TEMPSENSE_OPTION, + BRCMS_SROM_TEMPSENSE_SLOPE, + BRCMS_SROM_TEMPTHRESH, + BRCMS_SROM_TRI2G, + BRCMS_SROM_TRI5GH, + BRCMS_SROM_TRI5GL, + BRCMS_SROM_TRI5G, + BRCMS_SROM_TRISO2G, + BRCMS_SROM_TRISO5G, + BRCMS_SROM_TSSIPOS2G, + BRCMS_SROM_TSSIPOS5G, + BRCMS_SROM_TXCHAIN, + BRCMS_SROM_TXPID2GA0, + BRCMS_SROM_TXPID2GA1, + BRCMS_SROM_TXPID2GA2, + BRCMS_SROM_TXPID2GA3, + BRCMS_SROM_TXPID5GA0, + BRCMS_SROM_TXPID5GA1, + BRCMS_SROM_TXPID5GA2, + BRCMS_SROM_TXPID5GA3, + BRCMS_SROM_TXPID5GHA0, + BRCMS_SROM_TXPID5GHA1, + BRCMS_SROM_TXPID5GHA2, + BRCMS_SROM_TXPID5GHA3, + BRCMS_SROM_TXPID5GLA0, + BRCMS_SROM_TXPID5GLA1, + BRCMS_SROM_TXPID5GLA2, + BRCMS_SROM_TXPID5GLA3, + /* + * per-path identifiers (see srom.c) + */ + BRCMS_SROM_ITT2GA0, + BRCMS_SROM_ITT2GA1, + BRCMS_SROM_ITT2GA2, + BRCMS_SROM_ITT2GA3, + BRCMS_SROM_ITT5GA0, + BRCMS_SROM_ITT5GA1, + BRCMS_SROM_ITT5GA2, + BRCMS_SROM_ITT5GA3, + BRCMS_SROM_MAXP2GA0, + BRCMS_SROM_MAXP2GA1, + BRCMS_SROM_MAXP2GA2, + BRCMS_SROM_MAXP2GA3, + BRCMS_SROM_MAXP5GA0, + BRCMS_SROM_MAXP5GA1, + BRCMS_SROM_MAXP5GA2, + BRCMS_SROM_MAXP5GA3, + BRCMS_SROM_MAXP5GHA0, + BRCMS_SROM_MAXP5GHA1, + BRCMS_SROM_MAXP5GHA2, + BRCMS_SROM_MAXP5GHA3, + BRCMS_SROM_MAXP5GLA0, + BRCMS_SROM_MAXP5GLA1, + BRCMS_SROM_MAXP5GLA2, + BRCMS_SROM_MAXP5GLA3, + BRCMS_SROM_PA2GW0A0, + BRCMS_SROM_PA2GW0A1, + BRCMS_SROM_PA2GW0A2, + BRCMS_SROM_PA2GW0A3, + BRCMS_SROM_PA2GW1A0, + BRCMS_SROM_PA2GW1A1, + BRCMS_SROM_PA2GW1A2, + BRCMS_SROM_PA2GW1A3, + BRCMS_SROM_PA2GW2A0, + BRCMS_SROM_PA2GW2A1, + BRCMS_SROM_PA2GW2A2, + BRCMS_SROM_PA2GW2A3, + BRCMS_SROM_PA2GW3A0, + BRCMS_SROM_PA2GW3A1, + BRCMS_SROM_PA2GW3A2, + BRCMS_SROM_PA2GW3A3, + BRCMS_SROM_PA5GHW0A0, + BRCMS_SROM_PA5GHW0A1, + BRCMS_SROM_PA5GHW0A2, + BRCMS_SROM_PA5GHW0A3, + BRCMS_SROM_PA5GHW1A0, + BRCMS_SROM_PA5GHW1A1, + BRCMS_SROM_PA5GHW1A2, + BRCMS_SROM_PA5GHW1A3, + BRCMS_SROM_PA5GHW2A0, + BRCMS_SROM_PA5GHW2A1, + BRCMS_SROM_PA5GHW2A2, + BRCMS_SROM_PA5GHW2A3, + BRCMS_SROM_PA5GHW3A0, + BRCMS_SROM_PA5GHW3A1, + BRCMS_SROM_PA5GHW3A2, + BRCMS_SROM_PA5GHW3A3, + BRCMS_SROM_PA5GLW0A0, + BRCMS_SROM_PA5GLW0A1, + BRCMS_SROM_PA5GLW0A2, + BRCMS_SROM_PA5GLW0A3, + BRCMS_SROM_PA5GLW1A0, + BRCMS_SROM_PA5GLW1A1, + BRCMS_SROM_PA5GLW1A2, + BRCMS_SROM_PA5GLW1A3, + BRCMS_SROM_PA5GLW2A0, + BRCMS_SROM_PA5GLW2A1, + BRCMS_SROM_PA5GLW2A2, + BRCMS_SROM_PA5GLW2A3, + BRCMS_SROM_PA5GLW3A0, + BRCMS_SROM_PA5GLW3A1, + BRCMS_SROM_PA5GLW3A2, + BRCMS_SROM_PA5GLW3A3, + BRCMS_SROM_PA5GW0A0, + BRCMS_SROM_PA5GW0A1, + BRCMS_SROM_PA5GW0A2, + BRCMS_SROM_PA5GW0A3, + BRCMS_SROM_PA5GW1A0, + BRCMS_SROM_PA5GW1A1, + BRCMS_SROM_PA5GW1A2, + BRCMS_SROM_PA5GW1A3, + BRCMS_SROM_PA5GW2A0, + BRCMS_SROM_PA5GW2A1, + BRCMS_SROM_PA5GW2A2, + BRCMS_SROM_PA5GW2A3, + BRCMS_SROM_PA5GW3A0, + BRCMS_SROM_PA5GW3A1, + BRCMS_SROM_PA5GW3A2, + BRCMS_SROM_PA5GW3A3, +}; + #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ @@ -356,8 +614,8 @@ extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta, u16 tid); extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, u8 ba_wsize, uint max_rx_ampdu_bytes); -extern char *getvar(struct si_pub *sih, const char *name); -extern int getintvar(struct si_pub *sih, const char *name); +extern char *getvar(struct si_pub *sih, enum brcms_srom_id id); +extern int getintvar(struct si_pub *sih, enum brcms_srom_id id); /* wlc_phy.c helper functions */ extern void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc); diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 524f1cc4877..c7a6e654704 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -23,6 +23,7 @@ #include #include +#include "pub.h" #include "nicpci.h" #include "aiutils.h" #include "otp.h" @@ -1243,18 +1244,289 @@ int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, return -EINVAL; } +struct srom_id_name { + enum brcms_srom_id id; + const char *name; +}; + +static const struct srom_id_name srom_id_map[] = { + { BRCMS_SROM_AA2G, "aa2g" }, + { BRCMS_SROM_AA5G, "aa5g" }, + { BRCMS_SROM_AG0, "ag0" }, + { BRCMS_SROM_AG1, "ag1" }, + { BRCMS_SROM_AG2, "ag2" }, + { BRCMS_SROM_AG3, "ag3" }, + { BRCMS_SROM_ANTSWCTL2G, "antswctl2g" }, + { BRCMS_SROM_ANTSWCTL5G, "antswctl5g" }, + { BRCMS_SROM_ANTSWITCH, "antswitch" }, + { BRCMS_SROM_BOARDFLAGS2, "boardflags2" }, + { BRCMS_SROM_BOARDFLAGS, "boardflags" }, + { BRCMS_SROM_BOARDNUM, "boardnum" }, + { BRCMS_SROM_BOARDREV, "boardrev" }, + { BRCMS_SROM_BOARDTYPE, "boardtype" }, + { BRCMS_SROM_BW40PO, "bw40po" }, + { BRCMS_SROM_BWDUPPO, "bwduppo" }, + { BRCMS_SROM_BXA2G, "bxa2g" }, + { BRCMS_SROM_BXA5G, "bxa5g" }, + { BRCMS_SROM_CC, "cc" }, + { BRCMS_SROM_CCK2GPO, "cck2gpo" }, + { BRCMS_SROM_CCKBW202GPO, "cckbw202gpo" }, + { BRCMS_SROM_CCKBW20UL2GPO, "cckbw20ul2gpo" }, + { BRCMS_SROM_CCODE, "ccode" }, + { BRCMS_SROM_CDDPO, "cddpo" }, + { BRCMS_SROM_DEVID, "devid" }, + { BRCMS_SROM_ET1MACADDR, "et1macaddr" }, + { BRCMS_SROM_EXTPAGAIN2G, "extpagain2g" }, + { BRCMS_SROM_EXTPAGAIN5G, "extpagain5g" }, + { BRCMS_SROM_FREQOFFSET_CORR, "freqoffset_corr" }, + { BRCMS_SROM_HW_IQCAL_EN, "hw_iqcal_en" }, + { BRCMS_SROM_IL0MACADDR, "il0macaddr" }, + { BRCMS_SROM_IQCAL_SWP_DIS, "iqcal_swp_dis" }, + { BRCMS_SROM_LEDBH0, "ledbh0" }, + { BRCMS_SROM_LEDBH1, "ledbh1" }, + { BRCMS_SROM_LEDBH2, "ledbh2" }, + { BRCMS_SROM_LEDBH3, "ledbh3" }, + { BRCMS_SROM_LEDDC, "leddc" }, + { BRCMS_SROM_LEGOFDM40DUPPO, "legofdm40duppo" }, + { BRCMS_SROM_LEGOFDMBW202GPO, "legofdmbw202gpo" }, + { BRCMS_SROM_LEGOFDMBW205GHPO, "legofdmbw205ghpo" }, + { BRCMS_SROM_LEGOFDMBW205GLPO, "legofdmbw205glpo" }, + { BRCMS_SROM_LEGOFDMBW205GMPO, "legofdmbw205gmpo" }, + { BRCMS_SROM_LEGOFDMBW20UL2GPO, "legofdmbw20ul2gpo" }, + { BRCMS_SROM_LEGOFDMBW20UL5GHPO, "legofdmbw20ul5ghpo" }, + { BRCMS_SROM_LEGOFDMBW20UL5GLPO, "legofdmbw20ul5glpo" }, + { BRCMS_SROM_LEGOFDMBW20UL5GMPO, "legofdmbw20ul5gmpo" }, + { BRCMS_SROM_MACADDR, "macaddr" }, + { BRCMS_SROM_MCS2GPO0, "mcs2gpo0" }, + { BRCMS_SROM_MCS2GPO1, "mcs2gpo1" }, + { BRCMS_SROM_MCS2GPO2, "mcs2gpo2" }, + { BRCMS_SROM_MCS2GPO3, "mcs2gpo3" }, + { BRCMS_SROM_MCS2GPO4, "mcs2gpo4" }, + { BRCMS_SROM_MCS2GPO5, "mcs2gpo5" }, + { BRCMS_SROM_MCS2GPO6, "mcs2gpo6" }, + { BRCMS_SROM_MCS2GPO7, "mcs2gpo7" }, + { BRCMS_SROM_MCS32PO, "mcs32po" }, + { BRCMS_SROM_MCS5GHPO0, "mcs5ghpo0" }, + { BRCMS_SROM_MCS5GHPO1, "mcs5ghpo1" }, + { BRCMS_SROM_MCS5GHPO2, "mcs5ghpo2" }, + { BRCMS_SROM_MCS5GHPO3, "mcs5ghpo3" }, + { BRCMS_SROM_MCS5GHPO4, "mcs5ghpo4" }, + { BRCMS_SROM_MCS5GHPO5, "mcs5ghpo5" }, + { BRCMS_SROM_MCS5GHPO6, "mcs5ghpo6" }, + { BRCMS_SROM_MCS5GHPO7, "mcs5ghpo7" }, + { BRCMS_SROM_MCS5GLPO0, "mcs5glpo0" }, + { BRCMS_SROM_MCS5GLPO1, "mcs5glpo1" }, + { BRCMS_SROM_MCS5GLPO2, "mcs5glpo2" }, + { BRCMS_SROM_MCS5GLPO3, "mcs5glpo3" }, + { BRCMS_SROM_MCS5GLPO4, "mcs5glpo4" }, + { BRCMS_SROM_MCS5GLPO5, "mcs5glpo5" }, + { BRCMS_SROM_MCS5GLPO6, "mcs5glpo6" }, + { BRCMS_SROM_MCS5GLPO7, "mcs5glpo7" }, + { BRCMS_SROM_MCS5GPO0, "mcs5gpo0" }, + { BRCMS_SROM_MCS5GPO1, "mcs5gpo1" }, + { BRCMS_SROM_MCS5GPO2, "mcs5gpo2" }, + { BRCMS_SROM_MCS5GPO3, "mcs5gpo3" }, + { BRCMS_SROM_MCS5GPO4, "mcs5gpo4" }, + { BRCMS_SROM_MCS5GPO5, "mcs5gpo5" }, + { BRCMS_SROM_MCS5GPO6, "mcs5gpo6" }, + { BRCMS_SROM_MCS5GPO7, "mcs5gpo7" }, + { BRCMS_SROM_MCSBW202GPO, "mcsbw202gpo" }, + { BRCMS_SROM_MCSBW205GHPO, "mcsbw205ghpo" }, + { BRCMS_SROM_MCSBW205GLPO, "mcsbw205glpo" }, + { BRCMS_SROM_MCSBW205GMPO, "mcsbw205gmpo" }, + { BRCMS_SROM_MCSBW20UL2GPO, "mcsbw20ul2gpo" }, + { BRCMS_SROM_MCSBW20UL5GHPO, "mcsbw20ul5ghpo" }, + { BRCMS_SROM_MCSBW20UL5GLPO, "mcsbw20ul5glpo" }, + { BRCMS_SROM_MCSBW20UL5GMPO, "mcsbw20ul5gmpo" }, + { BRCMS_SROM_MCSBW402GPO, "mcsbw402gpo" }, + { BRCMS_SROM_MCSBW405GHPO, "mcsbw405ghpo" }, + { BRCMS_SROM_MCSBW405GLPO, "mcsbw405glpo" }, + { BRCMS_SROM_MCSBW405GMPO, "mcsbw405gmpo" }, + { BRCMS_SROM_MEASPOWER, "measpower" }, + { BRCMS_SROM_OFDM2GPO, "ofdm2gpo" }, + { BRCMS_SROM_OFDM5GHPO, "ofdm5ghpo" }, + { BRCMS_SROM_OFDM5GLPO, "ofdm5glpo" }, + { BRCMS_SROM_OFDM5GPO, "ofdm5gpo" }, + { BRCMS_SROM_OPO, "opo" }, + { BRCMS_SROM_PA0B0, "pa0b0" }, + { BRCMS_SROM_PA0B1, "pa0b1" }, + { BRCMS_SROM_PA0B2, "pa0b2" }, + { BRCMS_SROM_PA0ITSSIT, "pa0itssit" }, + { BRCMS_SROM_PA0MAXPWR, "pa0maxpwr" }, + { BRCMS_SROM_PA1B0, "pa1b0" }, + { BRCMS_SROM_PA1B1, "pa1b1" }, + { BRCMS_SROM_PA1B2, "pa1b2" }, + { BRCMS_SROM_PA1HIB0, "pa1hib0" }, + { BRCMS_SROM_PA1HIB1, "pa1hib1" }, + { BRCMS_SROM_PA1HIB2, "pa1hib2" }, + { BRCMS_SROM_PA1HIMAXPWR, "pa1himaxpwr" }, + { BRCMS_SROM_PA1ITSSIT, "pa1itssit" }, + { BRCMS_SROM_PA1LOB0, "pa1lob0" }, + { BRCMS_SROM_PA1LOB1, "pa1lob1" }, + { BRCMS_SROM_PA1LOB2, "pa1lob2" }, + { BRCMS_SROM_PA1LOMAXPWR, "pa1lomaxpwr" }, + { BRCMS_SROM_PA1MAXPWR, "pa1maxpwr" }, + { BRCMS_SROM_PDETRANGE2G, "pdetrange2g" }, + { BRCMS_SROM_PDETRANGE5G, "pdetrange5g" }, + { BRCMS_SROM_PHYCAL_TEMPDELTA, "phycal_tempdelta" }, + { BRCMS_SROM_RAWTEMPSENSE, "rawtempsense" }, + { BRCMS_SROM_REV, "sromrev" }, + { BRCMS_SROM_REGREV, "regrev" }, + { BRCMS_SROM_RSSISAV2G, "rssisav2g" }, + { BRCMS_SROM_RSSISAV5G, "rssisav5g" }, + { BRCMS_SROM_RSSISMC2G, "rssismc2g" }, + { BRCMS_SROM_RSSISMC5G, "rssismc5g" }, + { BRCMS_SROM_RSSISMF2G, "rssismf2g" }, + { BRCMS_SROM_RSSISMF5G, "rssismf5g" }, + { BRCMS_SROM_RXCHAIN, "rxchain" }, + { BRCMS_SROM_RXPO2G, "rxpo2g" }, + { BRCMS_SROM_RXPO5G, "rxpo5g" }, + { BRCMS_SROM_STBCPO, "stbcpo" }, + { BRCMS_SROM_TEMPCORRX, "tempcorrx" }, + { BRCMS_SROM_TEMPOFFSET, "tempoffset" }, + { BRCMS_SROM_TEMPSENSE_OPTION, "tempsense_option" }, + { BRCMS_SROM_TEMPSENSE_SLOPE, "tempsense_slope" }, + { BRCMS_SROM_TEMPTHRESH, "tempthresh" }, + { BRCMS_SROM_TRI2G, "tri2g" }, + { BRCMS_SROM_TRI5GH, "tri5gh" }, + { BRCMS_SROM_TRI5GL, "tri5gl" }, + { BRCMS_SROM_TRI5G, "tri5g" }, + { BRCMS_SROM_TRISO2G, "triso2g" }, + { BRCMS_SROM_TRISO5G, "triso5g" }, + { BRCMS_SROM_TSSIPOS2G, "tssipos2g" }, + { BRCMS_SROM_TSSIPOS5G, "tssipos5g" }, + { BRCMS_SROM_TXCHAIN, "txchain" }, + { BRCMS_SROM_TXPID2GA0, "txpid2ga0" }, + { BRCMS_SROM_TXPID2GA1, "txpid2ga1" }, + { BRCMS_SROM_TXPID2GA2, "txpid2ga2" }, + { BRCMS_SROM_TXPID2GA3, "txpid2ga3" }, + { BRCMS_SROM_TXPID5GA0, "txpid5ga0" }, + { BRCMS_SROM_TXPID5GA1, "txpid5ga1" }, + { BRCMS_SROM_TXPID5GA2, "txpid5ga2" }, + { BRCMS_SROM_TXPID5GA3, "txpid5ga3" }, + { BRCMS_SROM_TXPID5GHA0, "txpid5gha0" }, + { BRCMS_SROM_TXPID5GHA1, "txpid5gha1" }, + { BRCMS_SROM_TXPID5GHA2, "txpid5gha2" }, + { BRCMS_SROM_TXPID5GHA3, "txpid5gha3" }, + { BRCMS_SROM_TXPID5GLA0, "txpid5gla0" }, + { BRCMS_SROM_TXPID5GLA1, "txpid5gla1" }, + { BRCMS_SROM_TXPID5GLA2, "txpid5gla2" }, + { BRCMS_SROM_TXPID5GLA3, "txpid5gla3" }, + { BRCMS_SROM_ITT2GA0, "itt2ga0" }, + { BRCMS_SROM_ITT2GA1, "itt2ga1" }, + { BRCMS_SROM_ITT2GA2, "itt2ga2" }, + { BRCMS_SROM_ITT2GA3, "itt2ga3" }, + { BRCMS_SROM_ITT5GA0, "itt5ga0" }, + { BRCMS_SROM_ITT5GA1, "itt5ga1" }, + { BRCMS_SROM_ITT5GA2, "itt5ga2" }, + { BRCMS_SROM_ITT5GA3, "itt5ga3" }, + { BRCMS_SROM_MAXP2GA0, "maxp2ga0" }, + { BRCMS_SROM_MAXP2GA1, "maxp2ga1" }, + { BRCMS_SROM_MAXP2GA2, "maxp2ga2" }, + { BRCMS_SROM_MAXP2GA3, "maxp2ga3" }, + { BRCMS_SROM_MAXP5GA0, "maxp5ga0" }, + { BRCMS_SROM_MAXP5GA1, "maxp5ga1" }, + { BRCMS_SROM_MAXP5GA2, "maxp5ga2" }, + { BRCMS_SROM_MAXP5GA3, "maxp5ga3" }, + { BRCMS_SROM_MAXP5GHA0, "maxp5gha0" }, + { BRCMS_SROM_MAXP5GHA1, "maxp5gha1" }, + { BRCMS_SROM_MAXP5GHA2, "maxp5gha2" }, + { BRCMS_SROM_MAXP5GHA3, "maxp5gha3" }, + { BRCMS_SROM_MAXP5GLA0, "maxp5gla0" }, + { BRCMS_SROM_MAXP5GLA1, "maxp5gla1" }, + { BRCMS_SROM_MAXP5GLA2, "maxp5gla2" }, + { BRCMS_SROM_MAXP5GLA3, "maxp5gla3" }, + { BRCMS_SROM_PA2GW0A0, "pa2gw0a0" }, + { BRCMS_SROM_PA2GW0A1, "pa2gw0a1" }, + { BRCMS_SROM_PA2GW0A2, "pa2gw0a2" }, + { BRCMS_SROM_PA2GW0A3, "pa2gw0a3" }, + { BRCMS_SROM_PA2GW1A0, "pa2gw1a0" }, + { BRCMS_SROM_PA2GW1A1, "pa2gw1a1" }, + { BRCMS_SROM_PA2GW1A2, "pa2gw1a2" }, + { BRCMS_SROM_PA2GW1A3, "pa2gw1a3" }, + { BRCMS_SROM_PA2GW2A0, "pa2gw2a0" }, + { BRCMS_SROM_PA2GW2A1, "pa2gw2a1" }, + { BRCMS_SROM_PA2GW2A2, "pa2gw2a2" }, + { BRCMS_SROM_PA2GW2A3, "pa2gw2a3" }, + { BRCMS_SROM_PA2GW3A0, "pa2gw3a0" }, + { BRCMS_SROM_PA2GW3A1, "pa2gw3a1" }, + { BRCMS_SROM_PA2GW3A2, "pa2gw3a2" }, + { BRCMS_SROM_PA2GW3A3, "pa2gw3a3" }, + { BRCMS_SROM_PA5GHW0A0, "pa5ghw0a0" }, + { BRCMS_SROM_PA5GHW0A1, "pa5ghw0a1" }, + { BRCMS_SROM_PA5GHW0A2, "pa5ghw0a2" }, + { BRCMS_SROM_PA5GHW0A3, "pa5ghw0a3" }, + { BRCMS_SROM_PA5GHW1A0, "pa5ghw1a0" }, + { BRCMS_SROM_PA5GHW1A1, "pa5ghw1a1" }, + { BRCMS_SROM_PA5GHW1A2, "pa5ghw1a2" }, + { BRCMS_SROM_PA5GHW1A3, "pa5ghw1a3" }, + { BRCMS_SROM_PA5GHW2A0, "pa5ghw2a0" }, + { BRCMS_SROM_PA5GHW2A1, "pa5ghw2a1" }, + { BRCMS_SROM_PA5GHW2A2, "pa5ghw2a2" }, + { BRCMS_SROM_PA5GHW2A3, "pa5ghw2a3" }, + { BRCMS_SROM_PA5GHW3A0, "pa5ghw3a0" }, + { BRCMS_SROM_PA5GHW3A1, "pa5ghw3a1" }, + { BRCMS_SROM_PA5GHW3A2, "pa5ghw3a2" }, + { BRCMS_SROM_PA5GHW3A3, "pa5ghw3a3" }, + { BRCMS_SROM_PA5GLW0A0, "pa5glw0a0" }, + { BRCMS_SROM_PA5GLW0A1, "pa5glw0a1" }, + { BRCMS_SROM_PA5GLW0A2, "pa5glw0a2" }, + { BRCMS_SROM_PA5GLW0A3, "pa5glw0a3" }, + { BRCMS_SROM_PA5GLW1A0, "pa5glw1a0" }, + { BRCMS_SROM_PA5GLW1A1, "pa5glw1a1" }, + { BRCMS_SROM_PA5GLW1A2, "pa5glw1a2" }, + { BRCMS_SROM_PA5GLW1A3, "pa5glw1a3" }, + { BRCMS_SROM_PA5GLW2A0, "pa5glw2a0" }, + { BRCMS_SROM_PA5GLW2A1, "pa5glw2a1" }, + { BRCMS_SROM_PA5GLW2A2, "pa5glw2a2" }, + { BRCMS_SROM_PA5GLW2A3, "pa5glw2a3" }, + { BRCMS_SROM_PA5GLW3A0, "pa5glw3a0" }, + { BRCMS_SROM_PA5GLW3A1, "pa5glw3a1" }, + { BRCMS_SROM_PA5GLW3A2, "pa5glw3a2" }, + { BRCMS_SROM_PA5GLW3A3, "pa5glw3a3" }, + { BRCMS_SROM_PA5GW0A0, "pa5gw0a0" }, + { BRCMS_SROM_PA5GW0A1, "pa5gw0a1" }, + { BRCMS_SROM_PA5GW0A2, "pa5gw0a2" }, + { BRCMS_SROM_PA5GW0A3, "pa5gw0a3" }, + { BRCMS_SROM_PA5GW1A0, "pa5gw1a0" }, + { BRCMS_SROM_PA5GW1A1, "pa5gw1a1" }, + { BRCMS_SROM_PA5GW1A2, "pa5gw1a2" }, + { BRCMS_SROM_PA5GW1A3, "pa5gw1a3" }, + { BRCMS_SROM_PA5GW2A0, "pa5gw2a0" }, + { BRCMS_SROM_PA5GW2A1, "pa5gw2a1" }, + { BRCMS_SROM_PA5GW2A2, "pa5gw2a2" }, + { BRCMS_SROM_PA5GW2A3, "pa5gw2a3" }, + { BRCMS_SROM_PA5GW3A0, "pa5gw3a0" }, + { BRCMS_SROM_PA5GW3A1, "pa5gw3a1" }, + { BRCMS_SROM_PA5GW3A2, "pa5gw3a2" }, + { BRCMS_SROM_PA5GW3A3, "pa5gw3a3" }, +}; + +static const char *get_varname(enum brcms_srom_id id) +{ + const struct srom_id_name *entry; + int i; + + entry = &srom_id_map[0]; + for (i = 0; i < ARRAY_SIZE(srom_id_map); i++) { + if (entry->id == id) + return entry->name; + entry++; + } + return NULL; +} + /* * Search the name=value vars for a specific one and return its value. * Returns NULL if not found. */ -char *getvar(struct si_pub *sih, const char *name) +char *getvar(struct si_pub *sih, enum brcms_srom_id id) { + const char *name = get_varname(id); char *s; int len; struct si_info *sii; - sii = (struct si_info *)sih; - if (!name) return NULL; @@ -1262,6 +1534,8 @@ char *getvar(struct si_pub *sih, const char *name) if (len == 0) return NULL; + sii = (struct si_info *)sih; + /* first look in vars[] */ for (s = sii->vars; s && *s;) { if ((memcmp(s, name, len) == 0) && (s[len] == '=')) @@ -1278,12 +1552,12 @@ char *getvar(struct si_pub *sih, const char *name) * Search the vars for a specific one and return its value as * an integer. Returns 0 if not found. */ -int getintvar(struct si_pub *sih, const char *name) +int getintvar(struct si_pub *sih, enum brcms_srom_id id) { char *val; unsigned long res; - val = getvar(sih, name); + val = getvar(sih, id); if (val && !kstrtoul(val, 0, &res)) return res; diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c index 3ce90494aca..f1bd1bf5485 100644 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ b/drivers/staging/brcm80211/brcmsmac/stf.c @@ -373,8 +373,8 @@ void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) { /* get available rx/tx chains */ - wlc->stf->hw_txchain = (u8) getintvar(wlc->hw->sih, "txchain"); - wlc->stf->hw_rxchain = (u8) getintvar(wlc->hw->sih, "rxchain"); + wlc->stf->hw_txchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_TXCHAIN); + wlc->stf->hw_rxchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_RXCHAIN); /* these parameter are intended to be used for all PHY types */ if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) { From 36bd40db3c6355d11aeee6e8761dfd0a1fd2ffc7 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:09 +0200 Subject: [PATCH 1349/1519] staging: brcm80211: use enum identifiers in srom variable tables In the srom variable tables fields were identified using string identifiers. This has been replaced by enumeration identifiers. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/srom.c | 1723 +++++++++++---------- 1 file changed, 890 insertions(+), 833 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index c7a6e654704..f014044b699 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -365,7 +365,7 @@ #define MAXSZ_NVRAM_VARS 4096 struct brcms_sromvar { - const char *name; + enum brcms_srom_id varid; u32 revmask; u32 flags; u16 off; @@ -392,858 +392,448 @@ struct brcms_varbuf { * Other entries must have non-NULL name. */ static const struct brcms_sromvar pci_sromvars[] = { - {"devid", 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, 0xffff}, - {"boardrev", 0x0000000e, SRFL_PRHEX, SROM_AABREV, SROM_BR_MASK}, - {"boardrev", 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, - {"boardrev", 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, - {"boardflags", 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, - {"boardflags", 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, 0xffff}, - {"", 0, 0, SROM_BFL2, 0xffff}, - {"boardflags", 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, 0xffff}, - {"", 0, 0, SROM3_BFL2, 0xffff}, - {"boardflags", 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, 0xffff}, - {"", 0, 0, SROM4_BFL1, 0xffff}, - {"boardflags", 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, 0xffff}, - {"", 0, 0, SROM5_BFL1, 0xffff}, - {"boardflags", 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, 0xffff}, - {"", 0, 0, SROM8_BFL1, 0xffff}, - {"boardflags2", 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, 0xffff}, - {"", 0, 0, SROM4_BFL3, 0xffff}, - {"boardflags2", 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, 0xffff}, - {"", 0, 0, SROM5_BFL3, 0xffff}, - {"boardflags2", 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, 0xffff}, - {"", 0, 0, SROM8_BFL3, 0xffff}, - {"boardtype", 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, - {"boardnum", 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, - {"boardnum", 0x00000008, 0, SROM3_MACLO, 0xffff}, - {"boardnum", 0x00000010, 0, SROM4_MACLO, 0xffff}, - {"boardnum", 0x000000e0, 0, SROM5_MACLO, 0xffff}, - {"boardnum", 0xffffff00, 0, SROM8_MACLO, 0xffff}, - {"cc", 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, - {"regrev", 0x00000008, 0, SROM_OPO, 0xff00}, - {"regrev", 0x00000010, 0, SROM4_REGREV, 0x00ff}, - {"regrev", 0x000000e0, 0, SROM5_REGREV, 0x00ff}, - {"regrev", 0xffffff00, 0, SROM8_REGREV, 0x00ff}, - {"ledbh0", 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, - {"ledbh1", 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, - {"ledbh2", 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, - {"ledbh3", 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, - {"ledbh0", 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, - {"ledbh1", 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, - {"ledbh2", 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, - {"ledbh3", 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, - {"ledbh0", 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, - {"ledbh1", 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, - {"ledbh2", 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, - {"ledbh3", 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, - {"ledbh0", 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, - {"ledbh1", 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, - {"ledbh2", 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, - {"ledbh3", 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, - {"pa0b0", 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, - {"pa0b1", 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, - {"pa0b2", 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, - {"pa0itssit", 0x0000000e, 0, SROM_ITT, 0x00ff}, - {"pa0maxpwr", 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, - {"pa0b0", 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, - {"pa0b1", 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, - {"pa0b2", 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, - {"pa0itssit", 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, - {"pa0maxpwr", 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, - {"opo", 0x0000000c, 0, SROM_OPO, 0x00ff}, - {"opo", 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, - {"aa2g", 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, - {"aa2g", 0x000000f0, 0, SROM4_AA, 0x00ff}, - {"aa2g", 0xffffff00, 0, SROM8_AA, 0x00ff}, - {"aa5g", 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, - {"aa5g", 0x000000f0, 0, SROM4_AA, 0xff00}, - {"aa5g", 0xffffff00, 0, SROM8_AA, 0xff00}, - {"ag0", 0x0000000e, 0, SROM_AG10, 0x00ff}, - {"ag1", 0x0000000e, 0, SROM_AG10, 0xff00}, - {"ag0", 0x000000f0, 0, SROM4_AG10, 0x00ff}, - {"ag1", 0x000000f0, 0, SROM4_AG10, 0xff00}, - {"ag2", 0x000000f0, 0, SROM4_AG32, 0x00ff}, - {"ag3", 0x000000f0, 0, SROM4_AG32, 0xff00}, - {"ag0", 0xffffff00, 0, SROM8_AG10, 0x00ff}, - {"ag1", 0xffffff00, 0, SROM8_AG10, 0xff00}, - {"ag2", 0xffffff00, 0, SROM8_AG32, 0x00ff}, - {"ag3", 0xffffff00, 0, SROM8_AG32, 0xff00}, - {"pa1b0", 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, - {"pa1b1", 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, - {"pa1b2", 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, - {"pa1lob0", 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, - {"pa1lob1", 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, - {"pa1lob2", 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, - {"pa1hib0", 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, - {"pa1hib1", 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, - {"pa1hib2", 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, - {"pa1itssit", 0x0000000e, 0, SROM_ITT, 0xff00}, - {"pa1maxpwr", 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, - {"pa1lomaxpwr", 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, - {"pa1himaxpwr", 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, - {"pa1b0", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, - {"pa1b1", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, - {"pa1b2", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, - {"pa1lob0", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_LC, 0xffff}, - {"pa1lob1", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_LC, 0xffff}, - {"pa1lob2", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_LC, 0xffff}, - {"pa1hib0", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_HC, 0xffff}, - {"pa1hib1", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_HC, 0xffff}, - {"pa1hib2", 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_HC, 0xffff}, - {"pa1itssit", 0xffffff00, 0, SROM8_W1_ITTMAXP, 0xff00}, - {"pa1maxpwr", 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, - {"pa1lomaxpwr", 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, - {"pa1himaxpwr", 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, - {"bxa2g", 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, - {"rssisav2g", 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, - {"rssismc2g", 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, - {"rssismf2g", 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, - {"bxa2g", 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, - {"rssisav2g", 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, - {"rssismc2g", 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, - {"rssismf2g", 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, - {"bxa5g", 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, - {"rssisav5g", 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, - {"rssismc5g", 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, - {"rssismf5g", 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, - {"bxa5g", 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, - {"rssisav5g", 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, - {"rssismc5g", 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, - {"rssismf5g", 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, - {"tri2g", 0x00000008, 0, SROM_TRI52G, 0x00ff}, - {"tri5g", 0x00000008, 0, SROM_TRI52G, 0xff00}, - {"tri5gl", 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, - {"tri5gh", 0x00000008, 0, SROM_TRI5GHL, 0xff00}, - {"tri2g", 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, - {"tri5g", 0xffffff00, 0, SROM8_TRI52G, 0xff00}, - {"tri5gl", 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, - {"tri5gh", 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, - {"rxpo2g", 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, - {"rxpo5g", 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, - {"rxpo2g", 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, - {"rxpo5g", 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, - {"txchain", 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, SROM4_TXCHAIN_MASK}, - {"rxchain", 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, SROM4_RXCHAIN_MASK}, - {"antswitch", 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, SROM4_SWITCH_MASK}, - {"txchain", 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, SROM4_TXCHAIN_MASK}, - {"rxchain", 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, SROM4_RXCHAIN_MASK}, - {"antswitch", 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, SROM4_SWITCH_MASK}, - {"tssipos2g", 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_TSSIPOS_MASK}, - {"extpagain2g", 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_EXTPA_GAIN_MASK}, - {"pdetrange2g", 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_PDET_RANGE_MASK}, - {"triso2g", 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_TR_ISO_MASK}, - {"antswctl2g", 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_ANTSWLUT_MASK}, - {"tssipos5g", 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_TSSIPOS_MASK}, - {"extpagain5g", 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_EXTPA_GAIN_MASK}, - {"pdetrange5g", 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_PDET_RANGE_MASK}, - {"triso5g", 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_TR_ISO_MASK}, - {"antswctl5g", 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_ANTSWLUT_MASK}, - {"tempthresh", 0xffffff00, 0, SROM8_THERMAL, 0xff00}, - {"tempoffset", 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, - {"txpid2ga0", 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, - {"txpid2ga1", 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, - {"txpid2ga2", 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, - {"txpid2ga3", 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, - {"txpid5ga0", 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, - {"txpid5ga1", 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, - {"txpid5ga2", 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, - {"txpid5ga3", 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, - {"txpid5gla0", 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, - {"txpid5gla1", 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, - {"txpid5gla2", 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, - {"txpid5gla3", 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, - {"txpid5gha0", 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, - {"txpid5gha1", 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, - {"txpid5gha2", 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, - {"txpid5gha3", 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, + {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, + 0xffff}, + {BRCMS_SROM_BOARDREV, 0x0000000e, SRFL_PRHEX, SROM_AABREV, + SROM_BR_MASK}, + {BRCMS_SROM_BOARDREV, 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, + {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM_BFL2, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM3_BFL2, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_BFL1, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM5_BFL1, 0xffff}, + {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, + {BRCMS_SROM_BOARDFLAGS2, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_BFL3, 0xffff}, + {BRCMS_SROM_BOARDFLAGS2, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM5_BFL3, 0xffff}, + {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, + 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, + {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, + {BRCMS_SROM_BOARDNUM, 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, + {BRCMS_SROM_BOARDNUM, 0x00000008, 0, SROM3_MACLO, 0xffff}, + {BRCMS_SROM_BOARDNUM, 0x00000010, 0, SROM4_MACLO, 0xffff}, + {BRCMS_SROM_BOARDNUM, 0x000000e0, 0, SROM5_MACLO, 0xffff}, + {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, + {BRCMS_SROM_CC, 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, + {BRCMS_SROM_REGREV, 0x00000008, 0, SROM_OPO, 0xff00}, + {BRCMS_SROM_REGREV, 0x00000010, 0, SROM4_REGREV, 0x00ff}, + {BRCMS_SROM_REGREV, 0x000000e0, 0, SROM5_REGREV, 0x00ff}, + {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, + {BRCMS_SROM_LEDBH0, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, + {BRCMS_SROM_LEDBH1, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, + {BRCMS_SROM_LEDBH2, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, + {BRCMS_SROM_LEDBH3, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, + {BRCMS_SROM_LEDBH0, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, + {BRCMS_SROM_LEDBH1, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, + {BRCMS_SROM_LEDBH2, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, + {BRCMS_SROM_LEDBH3, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, + {BRCMS_SROM_LEDBH0, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, + {BRCMS_SROM_LEDBH1, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, + {BRCMS_SROM_LEDBH2, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, + {BRCMS_SROM_LEDBH3, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, + {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, + {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, + {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, + {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, + {BRCMS_SROM_PA0B0, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, + {BRCMS_SROM_PA0B1, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, + {BRCMS_SROM_PA0B2, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, + {BRCMS_SROM_PA0ITSSIT, 0x0000000e, 0, SROM_ITT, 0x00ff}, + {BRCMS_SROM_PA0MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, + {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, + {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, + {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, + {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, + {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, + {BRCMS_SROM_OPO, 0x0000000c, 0, SROM_OPO, 0x00ff}, + {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, + {BRCMS_SROM_AA2G, 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, + {BRCMS_SROM_AA2G, 0x000000f0, 0, SROM4_AA, 0x00ff}, + {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, + {BRCMS_SROM_AA5G, 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, + {BRCMS_SROM_AA5G, 0x000000f0, 0, SROM4_AA, 0xff00}, + {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, + {BRCMS_SROM_AG0, 0x0000000e, 0, SROM_AG10, 0x00ff}, + {BRCMS_SROM_AG1, 0x0000000e, 0, SROM_AG10, 0xff00}, + {BRCMS_SROM_AG0, 0x000000f0, 0, SROM4_AG10, 0x00ff}, + {BRCMS_SROM_AG1, 0x000000f0, 0, SROM4_AG10, 0xff00}, + {BRCMS_SROM_AG2, 0x000000f0, 0, SROM4_AG32, 0x00ff}, + {BRCMS_SROM_AG3, 0x000000f0, 0, SROM4_AG32, 0xff00}, + {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, + {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, + {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, + {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, + {BRCMS_SROM_PA1B0, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, + {BRCMS_SROM_PA1B1, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, + {BRCMS_SROM_PA1B2, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, + {BRCMS_SROM_PA1LOB0, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, + {BRCMS_SROM_PA1LOB1, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, + {BRCMS_SROM_PA1LOB2, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, + {BRCMS_SROM_PA1HIB0, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, + {BRCMS_SROM_PA1HIB1, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, + {BRCMS_SROM_PA1HIB2, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, + {BRCMS_SROM_PA1ITSSIT, 0x0000000e, 0, SROM_ITT, 0xff00}, + {BRCMS_SROM_PA1MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, + {BRCMS_SROM_PA1LOMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, + {BRCMS_SROM_PA1HIMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, + {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, + {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, + {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, + {BRCMS_SROM_PA1LOB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_LC, 0xffff}, + {BRCMS_SROM_PA1LOB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_LC, 0xffff}, + {BRCMS_SROM_PA1LOB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_LC, 0xffff}, + {BRCMS_SROM_PA1HIB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_HC, 0xffff}, + {BRCMS_SROM_PA1HIB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_HC, 0xffff}, + {BRCMS_SROM_PA1HIB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_HC, 0xffff}, + {BRCMS_SROM_PA1ITSSIT, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0xff00}, + {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, + {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, + {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, + {BRCMS_SROM_BXA2G, 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, + {BRCMS_SROM_RSSISAV2G, 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, + {BRCMS_SROM_RSSISMC2G, 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, + {BRCMS_SROM_RSSISMF2G, 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, + {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, + {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, + {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, + {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, + {BRCMS_SROM_BXA5G, 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, + {BRCMS_SROM_RSSISAV5G, 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, + {BRCMS_SROM_RSSISMC5G, 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, + {BRCMS_SROM_RSSISMF5G, 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, + {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, + {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, + {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, + {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, + {BRCMS_SROM_TRI2G, 0x00000008, 0, SROM_TRI52G, 0x00ff}, + {BRCMS_SROM_TRI5G, 0x00000008, 0, SROM_TRI52G, 0xff00}, + {BRCMS_SROM_TRI5GL, 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, + {BRCMS_SROM_TRI5GH, 0x00000008, 0, SROM_TRI5GHL, 0xff00}, + {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, + {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, + {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, + {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, + {BRCMS_SROM_RXPO2G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, + {BRCMS_SROM_RXPO5G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, + {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, + {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, + {BRCMS_SROM_TXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, + SROM4_TXCHAIN_MASK}, + {BRCMS_SROM_RXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, + SROM4_RXCHAIN_MASK}, + {BRCMS_SROM_ANTSWITCH, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, + SROM4_SWITCH_MASK}, + {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, + SROM4_TXCHAIN_MASK}, + {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, + SROM4_RXCHAIN_MASK}, + {BRCMS_SROM_ANTSWITCH, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, + SROM4_SWITCH_MASK}, + {BRCMS_SROM_TSSIPOS2G, 0xffffff00, 0, SROM8_FEM2G, + SROM8_FEM_TSSIPOS_MASK}, + {BRCMS_SROM_EXTPAGAIN2G, 0xffffff00, 0, SROM8_FEM2G, + SROM8_FEM_EXTPA_GAIN_MASK}, + {BRCMS_SROM_PDETRANGE2G, 0xffffff00, 0, SROM8_FEM2G, + SROM8_FEM_PDET_RANGE_MASK}, + {BRCMS_SROM_TRISO2G, 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_TR_ISO_MASK}, + {BRCMS_SROM_ANTSWCTL2G, 0xffffff00, 0, SROM8_FEM2G, + SROM8_FEM_ANTSWLUT_MASK}, + {BRCMS_SROM_TSSIPOS5G, 0xffffff00, 0, SROM8_FEM5G, + SROM8_FEM_TSSIPOS_MASK}, + {BRCMS_SROM_EXTPAGAIN5G, 0xffffff00, 0, SROM8_FEM5G, + SROM8_FEM_EXTPA_GAIN_MASK}, + {BRCMS_SROM_PDETRANGE5G, 0xffffff00, 0, SROM8_FEM5G, + SROM8_FEM_PDET_RANGE_MASK}, + {BRCMS_SROM_TRISO5G, 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_TR_ISO_MASK}, + {BRCMS_SROM_ANTSWCTL5G, 0xffffff00, 0, SROM8_FEM5G, + SROM8_FEM_ANTSWLUT_MASK}, + {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, + {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, + {BRCMS_SROM_TXPID2GA0, 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, + {BRCMS_SROM_TXPID2GA1, 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, + {BRCMS_SROM_TXPID2GA2, 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, + {BRCMS_SROM_TXPID2GA3, 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, + {BRCMS_SROM_TXPID5GA0, 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, + {BRCMS_SROM_TXPID5GA1, 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, + {BRCMS_SROM_TXPID5GA2, 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, + {BRCMS_SROM_TXPID5GA3, 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, + {BRCMS_SROM_TXPID5GLA0, 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, + {BRCMS_SROM_TXPID5GLA1, 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, + {BRCMS_SROM_TXPID5GLA2, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, + {BRCMS_SROM_TXPID5GLA3, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, + {BRCMS_SROM_TXPID5GHA0, 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, + {BRCMS_SROM_TXPID5GHA1, 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, + {BRCMS_SROM_TXPID5GHA2, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, + {BRCMS_SROM_TXPID5GHA3, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, - {"ccode", 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, - {"ccode", 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, - {"ccode", 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, - {"ccode", 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, - {"macaddr", 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, - {"macaddr", 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, - {"macaddr", 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, - {"macaddr", 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, - {"il0macaddr", 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, 0xffff}, - {"et1macaddr", 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, 0xffff}, - {"leddc", 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, 0xffff}, - {"leddc", 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, 0xffff}, - {"leddc", 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, 0xffff}, - {"leddc", 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, 0xffff}, - {"rawtempsense", 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, 0x01ff}, - {"measpower", 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, 0xfe00}, - {"tempsense_slope", 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX, + {BRCMS_SROM_CCODE, 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, + {BRCMS_SROM_CCODE, 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, + {BRCMS_SROM_CCODE, 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, + {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, + {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, + {BRCMS_SROM_MACADDR, 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, + {BRCMS_SROM_MACADDR, 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, + {BRCMS_SROM_MACADDR, 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, + {BRCMS_SROM_IL0MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, + 0xffff}, + {BRCMS_SROM_ET1MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, + 0xffff}, + {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, + 0xffff}, + {BRCMS_SROM_LEDDC, 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, + 0xffff}, + {BRCMS_SROM_LEDDC, 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, + 0xffff}, + {BRCMS_SROM_LEDDC, 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, + 0xffff}, + {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, + 0x01ff}, + {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, + 0xfe00}, + {BRCMS_SROM_TEMPSENSE_SLOPE, 0xffffff00, SRFL_PRHEX, + SROM8_TS_SLP_OPT_CORRX, 0x00ff}, + {BRCMS_SROM_TEMPCORRX, 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX, + 0xfc00}, + {BRCMS_SROM_TEMPSENSE_OPTION, 0xffffff00, SRFL_PRHEX, + SROM8_TS_SLP_OPT_CORRX, 0x0300}, + {BRCMS_SROM_FREQOFFSET_CORR, 0xffffff00, SRFL_PRHEX, + SROM8_FOC_HWIQ_IQSWP, 0x000f}, + {BRCMS_SROM_IQCAL_SWP_DIS, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, + 0x0010}, + {BRCMS_SROM_HW_IQCAL_EN, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, + 0x0020}, + {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, 0x00ff}, - {"tempcorrx", 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX, 0xfc00}, - {"tempsense_option", 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX, - 0x0300}, - {"freqoffset_corr", 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, - 0x000f}, - {"iqcal_swp_dis", 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, 0x0010}, - {"hw_iqcal_en", 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, 0x0020}, - {"phycal_tempdelta", 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, 0x00ff}, - {"cck2gpo", 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, - {"cck2gpo", 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, - {"ofdm2gpo", 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, - {"", 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, - {"ofdm5gpo", 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, - {"", 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, - {"ofdm5glpo", 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, - {"", 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, - {"ofdm5ghpo", 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, - {"", 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, - {"ofdm2gpo", 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, - {"", 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, - {"ofdm5gpo", 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, - {"", 0, 0, SROM8_5G_OFDMPO + 1, 0xffff}, - {"ofdm5glpo", 0x00000100, SRFL_MORE, SROM8_5GL_OFDMPO, 0xffff}, - {"", 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, - {"ofdm5ghpo", 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, - {"", 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, - {"mcs2gpo0", 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, - {"mcs2gpo1", 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, - {"mcs2gpo2", 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, - {"mcs2gpo3", 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, - {"mcs2gpo4", 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, - {"mcs2gpo5", 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, - {"mcs2gpo6", 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, - {"mcs2gpo7", 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, - {"mcs5gpo0", 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, - {"mcs5gpo1", 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, - {"mcs5gpo2", 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, - {"mcs5gpo3", 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, - {"mcs5gpo4", 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, - {"mcs5gpo5", 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, - {"mcs5gpo6", 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, - {"mcs5gpo7", 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, - {"mcs5glpo0", 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, - {"mcs5glpo1", 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, - {"mcs5glpo2", 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, - {"mcs5glpo3", 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, - {"mcs5glpo4", 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, - {"mcs5glpo5", 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, - {"mcs5glpo6", 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, - {"mcs5glpo7", 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, - {"mcs5ghpo0", 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, - {"mcs5ghpo1", 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, - {"mcs5ghpo2", 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, - {"mcs5ghpo3", 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, - {"mcs5ghpo4", 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, - {"mcs5ghpo5", 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, - {"mcs5ghpo6", 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, - {"mcs5ghpo7", 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, - {"mcs2gpo0", 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, - {"mcs2gpo1", 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, - {"mcs2gpo2", 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, - {"mcs2gpo3", 0x00000100, 0, SROM8_2G_MCSPO + 3, 0xffff}, - {"mcs2gpo4", 0x00000100, 0, SROM8_2G_MCSPO + 4, 0xffff}, - {"mcs2gpo5", 0x00000100, 0, SROM8_2G_MCSPO + 5, 0xffff}, - {"mcs2gpo6", 0x00000100, 0, SROM8_2G_MCSPO + 6, 0xffff}, - {"mcs2gpo7", 0x00000100, 0, SROM8_2G_MCSPO + 7, 0xffff}, - {"mcs5gpo0", 0x00000100, 0, SROM8_5G_MCSPO, 0xffff}, - {"mcs5gpo1", 0x00000100, 0, SROM8_5G_MCSPO + 1, 0xffff}, - {"mcs5gpo2", 0x00000100, 0, SROM8_5G_MCSPO + 2, 0xffff}, - {"mcs5gpo3", 0x00000100, 0, SROM8_5G_MCSPO + 3, 0xffff}, - {"mcs5gpo4", 0x00000100, 0, SROM8_5G_MCSPO + 4, 0xffff}, - {"mcs5gpo5", 0x00000100, 0, SROM8_5G_MCSPO + 5, 0xffff}, - {"mcs5gpo6", 0x00000100, 0, SROM8_5G_MCSPO + 6, 0xffff}, - {"mcs5gpo7", 0x00000100, 0, SROM8_5G_MCSPO + 7, 0xffff}, - {"mcs5glpo0", 0x00000100, 0, SROM8_5GL_MCSPO, 0xffff}, - {"mcs5glpo1", 0x00000100, 0, SROM8_5GL_MCSPO + 1, 0xffff}, - {"mcs5glpo2", 0x00000100, 0, SROM8_5GL_MCSPO + 2, 0xffff}, - {"mcs5glpo3", 0x00000100, 0, SROM8_5GL_MCSPO + 3, 0xffff}, - {"mcs5glpo4", 0x00000100, 0, SROM8_5GL_MCSPO + 4, 0xffff}, - {"mcs5glpo5", 0x00000100, 0, SROM8_5GL_MCSPO + 5, 0xffff}, - {"mcs5glpo6", 0x00000100, 0, SROM8_5GL_MCSPO + 6, 0xffff}, - {"mcs5glpo7", 0x00000100, 0, SROM8_5GL_MCSPO + 7, 0xffff}, - {"mcs5ghpo0", 0x00000100, 0, SROM8_5GH_MCSPO, 0xffff}, - {"mcs5ghpo1", 0x00000100, 0, SROM8_5GH_MCSPO + 1, 0xffff}, - {"mcs5ghpo2", 0x00000100, 0, SROM8_5GH_MCSPO + 2, 0xffff}, - {"mcs5ghpo3", 0x00000100, 0, SROM8_5GH_MCSPO + 3, 0xffff}, - {"mcs5ghpo4", 0x00000100, 0, SROM8_5GH_MCSPO + 4, 0xffff}, - {"mcs5ghpo5", 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, - {"mcs5ghpo6", 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, - {"mcs5ghpo7", 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, - {"cddpo", 0x000000f0, 0, SROM4_CDDPO, 0xffff}, - {"stbcpo", 0x000000f0, 0, SROM4_STBCPO, 0xffff}, - {"bw40po", 0x000000f0, 0, SROM4_BW40PO, 0xffff}, - {"bwduppo", 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, - {"cddpo", 0x00000100, 0, SROM8_CDDPO, 0xffff}, - {"stbcpo", 0x00000100, 0, SROM8_STBCPO, 0xffff}, - {"bw40po", 0x00000100, 0, SROM8_BW40PO, 0xffff}, - {"bwduppo", 0x00000100, 0, SROM8_BWDUPPO, 0xffff}, + {BRCMS_SROM_CCK2GPO, 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, + {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, + {BRCMS_SROM_OFDM2GPO, 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GPO, 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GLPO, 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GHPO, 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_5G_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GLPO, 0x00000100, SRFL_MORE, SROM8_5GL_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, + {BRCMS_SROM_MCS2GPO0, 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, + {BRCMS_SROM_MCS2GPO1, 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS2GPO2, 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS2GPO3, 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS2GPO4, 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS2GPO5, 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS2GPO6, 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS2GPO7, 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GPO0, 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GPO1, 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GPO2, 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GPO3, 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GPO4, 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GPO5, 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GPO6, 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GPO7, 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GLPO0, 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GLPO1, 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GLPO2, 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GLPO3, 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GLPO4, 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GLPO5, 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GLPO6, 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GLPO7, 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GHPO0, 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GHPO1, 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GHPO2, 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GHPO3, 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GHPO4, 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GHPO5, 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GHPO6, 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GHPO7, 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, + {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS2GPO3, 0x00000100, 0, SROM8_2G_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS2GPO4, 0x00000100, 0, SROM8_2G_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS2GPO5, 0x00000100, 0, SROM8_2G_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS2GPO6, 0x00000100, 0, SROM8_2G_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS2GPO7, 0x00000100, 0, SROM8_2G_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GPO0, 0x00000100, 0, SROM8_5G_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GPO1, 0x00000100, 0, SROM8_5G_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GPO2, 0x00000100, 0, SROM8_5G_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GPO3, 0x00000100, 0, SROM8_5G_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GPO4, 0x00000100, 0, SROM8_5G_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GPO5, 0x00000100, 0, SROM8_5G_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GPO6, 0x00000100, 0, SROM8_5G_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GPO7, 0x00000100, 0, SROM8_5G_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GLPO0, 0x00000100, 0, SROM8_5GL_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GLPO1, 0x00000100, 0, SROM8_5GL_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GLPO2, 0x00000100, 0, SROM8_5GL_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GLPO3, 0x00000100, 0, SROM8_5GL_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GLPO4, 0x00000100, 0, SROM8_5GL_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GLPO5, 0x00000100, 0, SROM8_5GL_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GLPO6, 0x00000100, 0, SROM8_5GL_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GLPO7, 0x00000100, 0, SROM8_5GL_MCSPO + 7, 0xffff}, + {BRCMS_SROM_MCS5GHPO0, 0x00000100, 0, SROM8_5GH_MCSPO, 0xffff}, + {BRCMS_SROM_MCS5GHPO1, 0x00000100, 0, SROM8_5GH_MCSPO + 1, 0xffff}, + {BRCMS_SROM_MCS5GHPO2, 0x00000100, 0, SROM8_5GH_MCSPO + 2, 0xffff}, + {BRCMS_SROM_MCS5GHPO3, 0x00000100, 0, SROM8_5GH_MCSPO + 3, 0xffff}, + {BRCMS_SROM_MCS5GHPO4, 0x00000100, 0, SROM8_5GH_MCSPO + 4, 0xffff}, + {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, + {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, + {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, + {BRCMS_SROM_CDDPO, 0x000000f0, 0, SROM4_CDDPO, 0xffff}, + {BRCMS_SROM_STBCPO, 0x000000f0, 0, SROM4_STBCPO, 0xffff}, + {BRCMS_SROM_BW40PO, 0x000000f0, 0, SROM4_BW40PO, 0xffff}, + {BRCMS_SROM_BWDUPPO, 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, + {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, + {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, + {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, + {BRCMS_SROM_BWDUPPO, 0x00000100, 0, SROM8_BWDUPPO, 0xffff}, /* power per rate from sromrev 9 */ - {"cckbw202gpo", 0xfffffe00, 0, SROM9_2GPO_CCKBW20, 0xffff}, - {"cckbw20ul2gpo", 0xfffffe00, 0, SROM9_2GPO_CCKBW20UL, 0xffff}, - {"legofdmbw202gpo", 0xfffffe00, SRFL_MORE, SROM9_2GPO_LOFDMBW20, + {BRCMS_SROM_CCKBW202GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20, 0xffff}, + {BRCMS_SROM_CCKBW20UL2GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20UL, 0xffff}, + {BRCMS_SROM_LEGOFDMBW202GPO, 0xfffffe00, SRFL_MORE, + SROM9_2GPO_LOFDMBW20, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20 + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW20UL2GPO, 0xfffffe00, SRFL_MORE, + SROM9_2GPO_LOFDMBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20UL + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW205GLPO, 0xfffffe00, SRFL_MORE, + SROM9_5GLPO_LOFDMBW20, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20 + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW20UL5GLPO, 0xfffffe00, SRFL_MORE, + SROM9_5GLPO_LOFDMBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20UL + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW205GMPO, 0xfffffe00, SRFL_MORE, + SROM9_5GMPO_LOFDMBW20, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20 + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW20UL5GMPO, 0xfffffe00, SRFL_MORE, + SROM9_5GMPO_LOFDMBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20UL + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW205GHPO, 0xfffffe00, SRFL_MORE, + SROM9_5GHPO_LOFDMBW20, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20 + 1, 0xffff}, + {BRCMS_SROM_LEGOFDMBW20UL5GHPO, 0xfffffe00, SRFL_MORE, + SROM9_5GHPO_LOFDMBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20UL + 1, 0xffff}, + {BRCMS_SROM_MCSBW202GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_2GPO_LOFDMBW20 + 1, 0xffff}, - {"legofdmbw20ul2gpo", 0xfffffe00, SRFL_MORE, SROM9_2GPO_LOFDMBW20UL, + {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20 + 1, 0xffff}, + {BRCMS_SROM_MCSBW20UL2GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20UL, 0xffff}, - {"", 0, 0, SROM9_2GPO_LOFDMBW20UL + 1, 0xffff}, - {"legofdmbw205glpo", 0xfffffe00, SRFL_MORE, SROM9_5GLPO_LOFDMBW20, + {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20UL + 1, 0xffff}, + {BRCMS_SROM_MCSBW402GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GLPO_LOFDMBW20 + 1, 0xffff}, - {"legofdmbw20ul5glpo", 0xfffffe00, SRFL_MORE, SROM9_5GLPO_LOFDMBW20UL, + {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW40 + 1, 0xffff}, + {BRCMS_SROM_MCSBW205GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GLPO_LOFDMBW20UL + 1, 0xffff}, - {"legofdmbw205gmpo", 0xfffffe00, SRFL_MORE, SROM9_5GMPO_LOFDMBW20, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20 + 1, 0xffff}, + {BRCMS_SROM_MCSBW20UL5GLPO, 0xfffffe00, SRFL_MORE, + SROM9_5GLPO_MCSBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20UL + 1, 0xffff}, + {BRCMS_SROM_MCSBW405GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GMPO_LOFDMBW20 + 1, 0xffff}, - {"legofdmbw20ul5gmpo", 0xfffffe00, SRFL_MORE, SROM9_5GMPO_LOFDMBW20UL, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW40 + 1, 0xffff}, + {BRCMS_SROM_MCSBW205GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GMPO_LOFDMBW20UL + 1, 0xffff}, - {"legofdmbw205ghpo", 0xfffffe00, SRFL_MORE, SROM9_5GHPO_LOFDMBW20, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20 + 1, 0xffff}, + {BRCMS_SROM_MCSBW20UL5GMPO, 0xfffffe00, SRFL_MORE, + SROM9_5GMPO_MCSBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20UL + 1, 0xffff}, + {BRCMS_SROM_MCSBW405GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GHPO_LOFDMBW20 + 1, 0xffff}, - {"legofdmbw20ul5ghpo", 0xfffffe00, SRFL_MORE, SROM9_5GHPO_LOFDMBW20UL, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW40 + 1, 0xffff}, + {BRCMS_SROM_MCSBW205GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GHPO_LOFDMBW20UL + 1, 0xffff}, - {"mcsbw202gpo", 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_2GPO_MCSBW20 + 1, 0xffff}, - {"mcsbw20ul2gpo", 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20UL, 0xffff}, - {"", 0, 0, SROM9_2GPO_MCSBW20UL + 1, 0xffff}, - {"mcsbw402gpo", 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_2GPO_MCSBW40 + 1, 0xffff}, - {"mcsbw205glpo", 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GLPO_MCSBW20 + 1, 0xffff}, - {"mcsbw20ul5glpo", 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW20UL, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20 + 1, 0xffff}, + {BRCMS_SROM_MCSBW20UL5GHPO, 0xfffffe00, SRFL_MORE, + SROM9_5GHPO_MCSBW20UL, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20UL + 1, 0xffff}, + {BRCMS_SROM_MCSBW405GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GLPO_MCSBW20UL + 1, 0xffff}, - {"mcsbw405glpo", 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GLPO_MCSBW40 + 1, 0xffff}, - {"mcsbw205gmpo", 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GMPO_MCSBW20 + 1, 0xffff}, - {"mcsbw20ul5gmpo", 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW20UL, - 0xffff}, - {"", 0, 0, SROM9_5GMPO_MCSBW20UL + 1, 0xffff}, - {"mcsbw405gmpo", 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GMPO_MCSBW40 + 1, 0xffff}, - {"mcsbw205ghpo", 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW20, 0xffff}, - {"", 0, 0, SROM9_5GHPO_MCSBW20 + 1, 0xffff}, - {"mcsbw20ul5ghpo", 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW20UL, - 0xffff}, - {"", 0, 0, SROM9_5GHPO_MCSBW20UL + 1, 0xffff}, - {"mcsbw405ghpo", 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW40, 0xffff}, - {"", 0, 0, SROM9_5GHPO_MCSBW40 + 1, 0xffff}, - {"mcs32po", 0xfffffe00, 0, SROM9_PO_MCS32, 0xffff}, - {"legofdm40duppo", 0xfffffe00, 0, SROM9_PO_LOFDM40DUP, 0xffff}, + {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW40 + 1, 0xffff}, + {BRCMS_SROM_MCS32PO, 0xfffffe00, 0, SROM9_PO_MCS32, 0xffff}, + {BRCMS_SROM_LEGOFDM40DUPPO, 0xfffffe00, 0, SROM9_PO_LOFDM40DUP, 0xffff}, - {NULL, 0, 0, 0, 0} + {BRCMS_SROM_NULL, 0, 0, 0, 0} }; static const struct brcms_sromvar perpath_pci_sromvars[] = { - {"maxp2ga", 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, - {"itt2ga", 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, - {"itt5ga", 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, - {"pa2gw0a", 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, - {"pa2gw1a", 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, - {"pa2gw2a", 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, - {"pa2gw3a", 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, - {"maxp5ga", 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, - {"maxp5gha", 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, - {"maxp5gla", 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, - {"pa5gw0a", 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, - {"pa5gw1a", 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, - {"pa5gw2a", 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, - {"pa5gw3a", 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, - {"pa5glw0a", 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, - {"pa5glw1a", 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, 0xffff}, - {"pa5glw2a", 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, 0xffff}, - {"pa5glw3a", 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, 0xffff}, - {"pa5ghw0a", 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, - {"pa5ghw1a", 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, 0xffff}, - {"pa5ghw2a", 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, 0xffff}, - {"pa5ghw3a", 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, 0xffff}, - {"maxp2ga", 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, - {"itt2ga", 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, - {"itt5ga", 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, - {"pa2gw0a", 0xffffff00, SRFL_PRHEX, SROM8_2G_PA, 0xffff}, - {"pa2gw1a", 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 1, 0xffff}, - {"pa2gw2a", 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 2, 0xffff}, - {"maxp5ga", 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0x00ff}, - {"maxp5gha", 0xffffff00, 0, SROM8_5GLH_MAXP, 0x00ff}, - {"maxp5gla", 0xffffff00, 0, SROM8_5GLH_MAXP, 0xff00}, - {"pa5gw0a", 0xffffff00, SRFL_PRHEX, SROM8_5G_PA, 0xffff}, - {"pa5gw1a", 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 1, 0xffff}, - {"pa5gw2a", 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 2, 0xffff}, - {"pa5glw0a", 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA, 0xffff}, - {"pa5glw1a", 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 1, 0xffff}, - {"pa5glw2a", 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 2, 0xffff}, - {"pa5ghw0a", 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA, 0xffff}, - {"pa5ghw1a", 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 1, 0xffff}, - {"pa5ghw2a", 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 2, 0xffff}, - {NULL, 0, 0, 0, 0} + {BRCMS_SROM_MAXP2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, + {BRCMS_SROM_ITT2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, + {BRCMS_SROM_ITT5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, + {BRCMS_SROM_PA2GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, + {BRCMS_SROM_PA2GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, + {BRCMS_SROM_PA2GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, + {BRCMS_SROM_PA2GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, + {BRCMS_SROM_MAXP5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, + {BRCMS_SROM_MAXP5GHA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, + {BRCMS_SROM_MAXP5GLA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, + {BRCMS_SROM_PA5GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, + {BRCMS_SROM_PA5GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, + {BRCMS_SROM_PA5GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, + {BRCMS_SROM_PA5GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, + {BRCMS_SROM_PA5GLW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, + {BRCMS_SROM_PA5GLW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, + 0xffff}, + {BRCMS_SROM_PA5GLW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, + 0xffff}, + {BRCMS_SROM_PA5GLW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, + 0xffff}, + {BRCMS_SROM_PA5GHW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, + {BRCMS_SROM_PA5GHW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, + 0xffff}, + {BRCMS_SROM_PA5GHW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, + 0xffff}, + {BRCMS_SROM_PA5GHW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, + 0xffff}, + {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, + {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, + {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, + {BRCMS_SROM_PA2GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA, 0xffff}, + {BRCMS_SROM_PA2GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 1, 0xffff}, + {BRCMS_SROM_PA2GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 2, 0xffff}, + {BRCMS_SROM_MAXP5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0x00ff}, + {BRCMS_SROM_MAXP5GHA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0x00ff}, + {BRCMS_SROM_MAXP5GLA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0xff00}, + {BRCMS_SROM_PA5GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA, 0xffff}, + {BRCMS_SROM_PA5GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 1, 0xffff}, + {BRCMS_SROM_PA5GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 2, 0xffff}, + {BRCMS_SROM_PA5GLW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA, 0xffff}, + {BRCMS_SROM_PA5GLW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 1, + 0xffff}, + {BRCMS_SROM_PA5GLW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 2, + 0xffff}, + {BRCMS_SROM_PA5GHW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA, 0xffff}, + {BRCMS_SROM_PA5GHW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 1, + 0xffff}, + {BRCMS_SROM_PA5GHW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 2, + 0xffff}, + {BRCMS_SROM_NULL, 0, 0, 0, 0} }; -/* crc table has the same contents for every device instance, so it can be - * shared between devices. */ -static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; - -static u16 __iomem * -srom_window_address(struct si_pub *sih, u8 __iomem *curmap) -{ - if (sih->ccrev < 32) - return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); - if (sih->cccaps & CC_CAP_SROM) - return (u16 __iomem *) - (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); - - return NULL; -} - -/* Parse SROM and create name=value pairs. 'srom' points to - * the SROM word array. 'off' specifies the offset of the - * first word 'srom' points to, which should be either 0 or - * SROM3_SWRG_OFF (full SROM or software region). - */ - -static uint mask_shift(u16 mask) -{ - uint i; - for (i = 0; i < (sizeof(mask) << 3); i++) { - if (mask & (1 << i)) - return i; - } - return 0; -} - -static uint mask_width(u16 mask) -{ - int i; - for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) { - if (mask & (1 << i)) - return (uint) (i - mask_shift(mask) + 1); - } - return 0; -} - -static inline void ltoh16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); -} - -static inline void htol16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); -} - -/* Initialization of varbuf structure */ -static void varbuf_init(struct brcms_varbuf *b, char *buf, uint size) -{ - b->size = size; - b->base = b->buf = buf; -} - -/* append a null terminated var=value string */ -static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) -{ - va_list ap; - int r; - size_t len; - char *s; - - if (b->size < 2) - return 0; - - va_start(ap, fmt); - r = vsnprintf(b->buf, b->size, fmt, ap); - va_end(ap); - - /* - * C99 snprintf behavior returns r >= size on overflow, - * others return -1 on overflow. All return -1 on format error. - * We need to leave room for 2 null terminations, one for the current - * var string, and one for final null of the var table. So check that - * the strlen written, r, leaves room for 2 chars. - */ - if ((r == -1) || (r > (int)(b->size - 2))) { - b->size = 0; - return 0; - } - - /* Remove any earlier occurrence of the same variable */ - s = strchr(b->buf, '='); - if (s != NULL) { - len = (size_t) (s - b->buf); - for (s = b->base; s < b->buf;) { - if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') { - len = strlen(s) + 1; - memmove(s, (s + len), - ((b->buf + r + 1) - (s + len))); - b->buf -= len; - b->size += (unsigned int)len; - break; - } - - while (*s++) - ; - } - } - - /* skip over this string's null termination */ - r++; - b->size -= r; - b->buf += r; - - return r; -} - -static void -_initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) -{ - u16 w; - u32 val; - const struct brcms_sromvar *srv; - uint width; - uint flags; - u32 sr = (1 << sromrev); - - varbuf_append(b, "sromrev=%d", sromrev); - - for (srv = pci_sromvars; srv->name != NULL; srv++) { - const char *name; - - if ((srv->revmask & sr) == 0) - continue; - - if (srv->off < off) - continue; - - flags = srv->flags; - name = srv->name; - - /* This entry is for mfgc only. Don't generate param for it, */ - if (flags & SRFL_NOVAR) - continue; - - if (flags & SRFL_ETHADDR) { - u8 ea[ETH_ALEN]; - - ea[0] = (srom[srv->off - off] >> 8) & 0xff; - ea[1] = srom[srv->off - off] & 0xff; - ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; - ea[3] = srom[srv->off + 1 - off] & 0xff; - ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; - ea[5] = srom[srv->off + 2 - off] & 0xff; - - varbuf_append(b, "%s=%pM", name, ea); - } else { - w = srom[srv->off - off]; - val = (w & srv->mask) >> mask_shift(srv->mask); - width = mask_width(srv->mask); - - while (srv->flags & SRFL_MORE) { - srv++; - if (srv->off == 0 || srv->off < off) - continue; - - w = srom[srv->off - off]; - val += - ((w & srv->mask) >> mask_shift(srv-> - mask)) << - width; - width += mask_width(srv->mask); - } - - if ((flags & SRFL_NOFFS) - && ((int)val == (1 << width) - 1)) - continue; - - if (flags & SRFL_CCODE) { - if (val == 0) - varbuf_append(b, "ccode="); - else - varbuf_append(b, "ccode=%c%c", - (val >> 8), (val & 0xff)); - } - /* LED Powersave duty cycle has to be scaled: - *(oncount >> 24) (offcount >> 8) - */ - else if (flags & SRFL_LEDDC) { - u32 w32 = /* oncount */ - (((val >> 8) & 0xff) << 24) | - /* offcount */ - (((val & 0xff)) << 8); - varbuf_append(b, "leddc=%d", w32); - } else if (flags & SRFL_PRHEX) - varbuf_append(b, "%s=0x%x", name, val); - else if ((flags & SRFL_PRSIGN) - && (val & (1 << (width - 1)))) - varbuf_append(b, "%s=%d", name, - (int)(val | (~0 << width))); - else - varbuf_append(b, "%s=%u", name, val); - } - } - - if (sromrev >= 4) { - /* Do per-path variables */ - uint p, pb, psz; - - if (sromrev >= 8) { - pb = SROM8_PATH0; - psz = SROM8_PATH1 - SROM8_PATH0; - } else { - pb = SROM4_PATH0; - psz = SROM4_PATH1 - SROM4_PATH0; - } - - for (p = 0; p < MAX_PATH_SROM; p++) { - for (srv = perpath_pci_sromvars; srv->name != NULL; - srv++) { - if ((srv->revmask & sr) == 0) - continue; - - if (pb + srv->off < off) - continue; - - if (srv->flags & SRFL_NOVAR) - continue; - - w = srom[pb + srv->off - off]; - val = (w & srv->mask) >> mask_shift(srv->mask); - width = mask_width(srv->mask); - - /* Cheating: no per-path var is more than - * 1 word */ - if ((srv->flags & SRFL_NOFFS) - && ((int)val == (1 << width) - 1)) - continue; - - if (srv->flags & SRFL_PRHEX) - varbuf_append(b, "%s%d=0x%x", srv->name, - p, val); - else - varbuf_append(b, "%s%d=%d", srv->name, - p, val); - } - pb += psz; - } - } -} - -/* - * Read in and validate sprom. - * Return 0 on success, nonzero on error. - */ -static int -sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, - u16 *buf, uint nwords, bool check_crc) -{ - int err = 0; - uint i; - - /* read the sprom */ - for (i = 0; i < nwords; i++) - buf[i] = R_REG(&sprom[wordoff + i]); - - if (check_crc) { - - if (buf[0] == 0xffff) - /* - * The hardware thinks that an srom that starts with - * 0xffff is blank, regardless of the rest of the - * content, so declare it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, nwords * 2); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, - CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE(brcms_srom_crc8_table)) - /* DBG only pci always read srom4 first, then srom8/9 */ - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, nwords * 2); - } - return err; -} - -static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) -{ - u8 *otp; - uint sz = OTP_SZ_MAX / 2; /* size in words */ - int err = 0; - - otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); - if (otp == NULL) - return -ENOMEM; - - err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); - - memcpy(buf, otp, bufsz); - - kfree(otp); - - /* Check CRC */ - if (buf[0] == 0xffff) - /* The hardware thinks that an srom that starts with 0xffff - * is blank, regardless of the rest of the content, so declare - * it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, bufsz); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, bufsz); - - return err; -} - -/* -* Create variable table from memory. -* Return 0 on success, nonzero on error. -*/ -static int initvars_table(char *start, char *end, - char **vars, uint *count) -{ - int c = (int)(end - start); - - /* do it only when there is more than just the null string */ - if (c > 1) { - char *vp = kmalloc(c, GFP_ATOMIC); - if (!vp) - return -ENOMEM; - memcpy(vp, start, c); - *vars = vp; - *count = c; - } else { - *vars = NULL; - *count = 0; - } - - return 0; -} - -/* - * Initialize nonvolatile variable table from sprom. - * Return 0 on success, nonzero on error. - */ -static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, - char **vars, uint *count) -{ - u16 *srom; - u16 __iomem *sromwindow; - u8 sromrev = 0; - u32 sr; - struct brcms_varbuf b; - char *vp, *base = NULL; - int err = 0; - - /* - * Apply CRC over SROM content regardless SROM is present or not. - */ - srom = kmalloc(SROM_MAX, GFP_ATOMIC); - if (!srom) - return -ENOMEM; - - sromwindow = srom_window_address(sih, curmap); - - crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); - if (ai_is_sprom_available(sih)) { - err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, - true); - - if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || - (((sih->buscoretype == PCIE_CORE_ID) - && (sih->buscorerev >= 6)) - || ((sih->buscoretype == PCI_CORE_ID) - && (sih->buscorerev >= 0xe)))) { - /* sromrev >= 4, read more */ - err = sprom_read_pci(sih, sromwindow, 0, srom, - SROM4_WORDS, true); - sromrev = srom[SROM4_CRCREV] & 0xff; - } else if (err == 0) { - /* srom is good and is rev < 4 */ - /* top word of sprom contains version and crc8 */ - sromrev = srom[SROM_CRCREV] & 0xff; - /* bcm4401 sroms misprogrammed */ - if (sromrev == 0x10) - sromrev = 1; - } - } else { - /* Use OTP if SPROM not available */ - err = otp_read_pci(sih, srom, SROM_MAX); - if (err == 0) - /* OTP only contain SROM rev8/rev9 for now */ - sromrev = srom[SROM4_CRCREV] & 0xff; - } - - if (!err) { - /* Bitmask for the sromrev */ - sr = 1 << sromrev; - - /* - * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, - * 9 - */ - if ((sr & 0x33e) == 0) { - err = -EINVAL; - goto errout; - } - - base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC); - if (!base) { - err = -ENOMEM; - goto errout; - } - - varbuf_init(&b, base, MAXSZ_NVRAM_VARS); - - /* parse SROM into name=value pairs. */ - _initvars_srom_pci(sromrev, srom, 0, &b); - - /* final nullbyte terminator */ - vp = b.buf; - *vp++ = '\0'; - - err = initvars_table(base, vp, vars, count); - kfree(base); - } - -errout: - kfree(srom); - return err; -} - -/* - * Initialize local vars from the right source for this platform. - * Return 0 on success, nonzero on error. - */ -int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, - uint *count) -{ - uint len; - - len = 0; - - if (vars == NULL || count == NULL) - return 0; - - *vars = NULL; - *count = 0; - - if (curmap != NULL) - return initvars_srom_pci(sih, curmap, vars, count); - - return -EINVAL; -} - struct srom_id_name { enum brcms_srom_id id; const char *name; @@ -1516,6 +1106,473 @@ static const char *get_varname(enum brcms_srom_id id) return NULL; } +/* crc table has the same contents for every device instance, so it can be + * shared between devices. */ +static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; + +static u16 __iomem * +srom_window_address(struct si_pub *sih, u8 __iomem *curmap) +{ + if (sih->ccrev < 32) + return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); + if (sih->cccaps & CC_CAP_SROM) + return (u16 __iomem *) + (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); + + return NULL; +} + +/* Parse SROM and create name=value pairs. 'srom' points to + * the SROM word array. 'off' specifies the offset of the + * first word 'srom' points to, which should be either 0 or + * SROM3_SWRG_OFF (full SROM or software region). + */ + +static uint mask_shift(u16 mask) +{ + uint i; + for (i = 0; i < (sizeof(mask) << 3); i++) { + if (mask & (1 << i)) + return i; + } + return 0; +} + +static uint mask_width(u16 mask) +{ + int i; + for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) { + if (mask & (1 << i)) + return (uint) (i - mask_shift(mask) + 1); + } + return 0; +} + +static inline void ltoh16_buf(u16 *buf, unsigned int size) +{ + size /= 2; + while (size--) + *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); +} + +static inline void htol16_buf(u16 *buf, unsigned int size) +{ + size /= 2; + while (size--) + *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); +} + +/* Initialization of varbuf structure */ +static void varbuf_init(struct brcms_varbuf *b, char *buf, uint size) +{ + b->size = size; + b->base = b->buf = buf; +} + +/* append a null terminated var=value string */ +static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) +{ + va_list ap; + int r; + size_t len; + char *s; + + if (b->size < 2) + return 0; + + va_start(ap, fmt); + r = vsnprintf(b->buf, b->size, fmt, ap); + va_end(ap); + + /* + * C99 snprintf behavior returns r >= size on overflow, + * others return -1 on overflow. All return -1 on format error. + * We need to leave room for 2 null terminations, one for the current + * var string, and one for final null of the var table. So check that + * the strlen written, r, leaves room for 2 chars. + */ + if ((r == -1) || (r > (int)(b->size - 2))) { + b->size = 0; + return 0; + } + + /* Remove any earlier occurrence of the same variable */ + s = strchr(b->buf, '='); + if (s != NULL) { + len = (size_t) (s - b->buf); + for (s = b->base; s < b->buf;) { + if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') { + len = strlen(s) + 1; + memmove(s, (s + len), + ((b->buf + r + 1) - (s + len))); + b->buf -= len; + b->size += (unsigned int)len; + break; + } + + while (*s++) + ; + } + } + + /* skip over this string's null termination */ + r++; + b->size -= r; + b->buf += r; + + return r; +} + +static void +_initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) +{ + u16 w; + u32 val; + const struct brcms_sromvar *srv; + uint width; + uint flags; + u32 sr = (1 << sromrev); + + varbuf_append(b, "sromrev=%d", sromrev); + + for (srv = pci_sromvars; srv->varid != BRCMS_SROM_NULL; srv++) { + const char *name; + + if ((srv->revmask & sr) == 0) + continue; + + if (srv->off < off) + continue; + + flags = srv->flags; + name = get_varname(srv->varid); + + /* This entry is for mfgc only. Don't generate param for it, */ + if (flags & SRFL_NOVAR) + continue; + + if (flags & SRFL_ETHADDR) { + u8 ea[ETH_ALEN]; + + ea[0] = (srom[srv->off - off] >> 8) & 0xff; + ea[1] = srom[srv->off - off] & 0xff; + ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; + ea[3] = srom[srv->off + 1 - off] & 0xff; + ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; + ea[5] = srom[srv->off + 2 - off] & 0xff; + + varbuf_append(b, "%s=%pM", name, ea); + } else { + w = srom[srv->off - off]; + val = (w & srv->mask) >> mask_shift(srv->mask); + width = mask_width(srv->mask); + + while (srv->flags & SRFL_MORE) { + srv++; + if (srv->off == 0 || srv->off < off) + continue; + + w = srom[srv->off - off]; + val += + ((w & srv->mask) >> mask_shift(srv-> + mask)) << + width; + width += mask_width(srv->mask); + } + + if ((flags & SRFL_NOFFS) + && ((int)val == (1 << width) - 1)) + continue; + + if (flags & SRFL_CCODE) { + if (val == 0) + varbuf_append(b, "ccode="); + else + varbuf_append(b, "ccode=%c%c", + (val >> 8), (val & 0xff)); + } + /* LED Powersave duty cycle has to be scaled: + *(oncount >> 24) (offcount >> 8) + */ + else if (flags & SRFL_LEDDC) { + u32 w32 = /* oncount */ + (((val >> 8) & 0xff) << 24) | + /* offcount */ + (((val & 0xff)) << 8); + varbuf_append(b, "leddc=%d", w32); + } else if (flags & SRFL_PRHEX) + varbuf_append(b, "%s=0x%x", name, val); + else if ((flags & SRFL_PRSIGN) + && (val & (1 << (width - 1)))) + varbuf_append(b, "%s=%d", name, + (int)(val | (~0 << width))); + else + varbuf_append(b, "%s=%u", name, val); + } + } + + if (sromrev >= 4) { + /* Do per-path variables */ + uint p, pb, psz; + + if (sromrev >= 8) { + pb = SROM8_PATH0; + psz = SROM8_PATH1 - SROM8_PATH0; + } else { + pb = SROM4_PATH0; + psz = SROM4_PATH1 - SROM4_PATH0; + } + + for (p = 0; p < MAX_PATH_SROM; p++) { + for (srv = perpath_pci_sromvars; + srv->varid != BRCMS_SROM_NULL; srv++) { + if ((srv->revmask & sr) == 0) + continue; + + if (pb + srv->off < off) + continue; + + if (srv->flags & SRFL_NOVAR) + continue; + + w = srom[pb + srv->off - off]; + val = (w & srv->mask) >> mask_shift(srv->mask); + width = mask_width(srv->mask); + + /* Cheating: no per-path var is more than + * 1 word */ + if ((srv->flags & SRFL_NOFFS) + && ((int)val == (1 << width) - 1)) + continue; + + if (srv->flags & SRFL_PRHEX) + varbuf_append(b, "%s%d=0x%x", + get_varname(srv->varid), + p, val); + else + varbuf_append(b, "%s%d=%d", + get_varname(srv->varid), + p, val); + } + pb += psz; + } + } +} + +/* + * Read in and validate sprom. + * Return 0 on success, nonzero on error. + */ +static int +sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, + u16 *buf, uint nwords, bool check_crc) +{ + int err = 0; + uint i; + + /* read the sprom */ + for (i = 0; i < nwords; i++) + buf[i] = R_REG(&sprom[wordoff + i]); + + if (check_crc) { + + if (buf[0] == 0xffff) + /* + * The hardware thinks that an srom that starts with + * 0xffff is blank, regardless of the rest of the + * content, so declare it bad. + */ + return -ENODATA; + + /* fixup the endianness so crc8 will pass */ + htol16_buf(buf, nwords * 2); + if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, + CRC8_INIT_VALUE) != + CRC8_GOOD_VALUE(brcms_srom_crc8_table)) + /* DBG only pci always read srom4 first, then srom8/9 */ + err = -EIO; + + /* now correct the endianness of the byte array */ + ltoh16_buf(buf, nwords * 2); + } + return err; +} + +static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) +{ + u8 *otp; + uint sz = OTP_SZ_MAX / 2; /* size in words */ + int err = 0; + + otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); + if (otp == NULL) + return -ENOMEM; + + err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); + + memcpy(buf, otp, bufsz); + + kfree(otp); + + /* Check CRC */ + if (buf[0] == 0xffff) + /* The hardware thinks that an srom that starts with 0xffff + * is blank, regardless of the rest of the content, so declare + * it bad. + */ + return -ENODATA; + + /* fixup the endianness so crc8 will pass */ + htol16_buf(buf, bufsz); + if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, + CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) + err = -EIO; + + /* now correct the endianness of the byte array */ + ltoh16_buf(buf, bufsz); + + return err; +} + +/* +* Create variable table from memory. +* Return 0 on success, nonzero on error. +*/ +static int initvars_table(char *start, char *end, + char **vars, uint *count) +{ + int c = (int)(end - start); + + /* do it only when there is more than just the null string */ + if (c > 1) { + char *vp = kmalloc(c, GFP_ATOMIC); + if (!vp) + return -ENOMEM; + memcpy(vp, start, c); + *vars = vp; + *count = c; + } else { + *vars = NULL; + *count = 0; + } + + return 0; +} + +/* + * Initialize nonvolatile variable table from sprom. + * Return 0 on success, nonzero on error. + */ +static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, + char **vars, uint *count) +{ + u16 *srom; + u16 __iomem *sromwindow; + u8 sromrev = 0; + u32 sr; + struct brcms_varbuf b; + char *vp, *base = NULL; + int err = 0; + + /* + * Apply CRC over SROM content regardless SROM is present or not. + */ + srom = kmalloc(SROM_MAX, GFP_ATOMIC); + if (!srom) + return -ENOMEM; + + sromwindow = srom_window_address(sih, curmap); + + crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); + if (ai_is_sprom_available(sih)) { + err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, + true); + + if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || + (((sih->buscoretype == PCIE_CORE_ID) + && (sih->buscorerev >= 6)) + || ((sih->buscoretype == PCI_CORE_ID) + && (sih->buscorerev >= 0xe)))) { + /* sromrev >= 4, read more */ + err = sprom_read_pci(sih, sromwindow, 0, srom, + SROM4_WORDS, true); + sromrev = srom[SROM4_CRCREV] & 0xff; + } else if (err == 0) { + /* srom is good and is rev < 4 */ + /* top word of sprom contains version and crc8 */ + sromrev = srom[SROM_CRCREV] & 0xff; + /* bcm4401 sroms misprogrammed */ + if (sromrev == 0x10) + sromrev = 1; + } + } else { + /* Use OTP if SPROM not available */ + err = otp_read_pci(sih, srom, SROM_MAX); + if (err == 0) + /* OTP only contain SROM rev8/rev9 for now */ + sromrev = srom[SROM4_CRCREV] & 0xff; + } + + if (!err) { + /* Bitmask for the sromrev */ + sr = 1 << sromrev; + + /* + * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, + * 9 + */ + if ((sr & 0x33e) == 0) { + err = -EINVAL; + goto errout; + } + + base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC); + if (!base) { + err = -ENOMEM; + goto errout; + } + + varbuf_init(&b, base, MAXSZ_NVRAM_VARS); + + /* parse SROM into name=value pairs. */ + _initvars_srom_pci(sromrev, srom, 0, &b); + + /* final nullbyte terminator */ + vp = b.buf; + *vp++ = '\0'; + + err = initvars_table(base, vp, vars, count); + kfree(base); + } + +errout: + kfree(srom); + return err; +} + +/* + * Initialize local vars from the right source for this platform. + * Return 0 on success, nonzero on error. + */ +int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, + uint *count) +{ + uint len; + + len = 0; + + if (vars == NULL || count == NULL) + return 0; + + *vars = NULL; + *count = 0; + + if (curmap != NULL) + return initvars_srom_pci(sih, curmap, vars, count); + + return -EINVAL; +} + /* * Search the name=value vars for a specific one and return its value. * Returns NULL if not found. From 2a9b065c3de94c1c4d7416fce53183228594b5f3 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:10 +0200 Subject: [PATCH 1350/1519] staging: brcm80211: replace string based variable storage by linked list The storage of variables obtained from srom are now stored in a linked list and lookup is done based on the enumerated identifier. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 1 + drivers/staging/brcm80211/brcmsmac/aiutils.h | 1 + drivers/staging/brcm80211/brcmsmac/srom.c | 554 ++++--------------- drivers/staging/brcm80211/brcmsmac/srom.h | 1 + 4 files changed, 125 insertions(+), 432 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index 6086c264b17..afba8b12070 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1210,6 +1210,7 @@ void ai_detach(struct si_pub *sih) pcicore_deinit(sii->pch); sii->pch = NULL; + srom_free_vars(sih); kfree(sii); } diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index 4a3f98efc9c..dce55513374 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -266,6 +266,7 @@ struct si_info { struct pcicore_info *pch; /* PCI/E core handle */ + struct list_head var_list; /* list of srom variables */ char *vars; uint varsz; diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index f014044b699..75de8d11a15 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -364,6 +364,36 @@ /* Max. nvram variable table size */ #define MAXSZ_NVRAM_VARS 4096 +/* + * indicates type of value. + */ +enum brcms_srom_var_type { + BRCMS_SROM_STRING, + BRCMS_SROM_SNUMBER, + BRCMS_SROM_UNUMBER +}; + +/* + * storage type for srom variable. + * + * var_list: for linked list operations. + * varid: identifier of the variable. + * var_type: type of variable. + * buf: variable value when var_type == BRCMS_SROM_STRING. + * uval: unsigned variable value when var_type == BRCMS_SROM_UNUMBER. + * sval: signed variable value when var_type == BRCMS_SROM_SNUMBER. + */ +struct brcms_srom_list_head { + struct list_head var_list; + enum brcms_srom_id varid; + enum brcms_srom_var_type var_type; + union { + char buf[0]; + u32 uval; + s32 sval; + }; +}; + struct brcms_sromvar { enum brcms_srom_id varid; u32 revmask; @@ -834,278 +864,6 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { {BRCMS_SROM_NULL, 0, 0, 0, 0} }; -struct srom_id_name { - enum brcms_srom_id id; - const char *name; -}; - -static const struct srom_id_name srom_id_map[] = { - { BRCMS_SROM_AA2G, "aa2g" }, - { BRCMS_SROM_AA5G, "aa5g" }, - { BRCMS_SROM_AG0, "ag0" }, - { BRCMS_SROM_AG1, "ag1" }, - { BRCMS_SROM_AG2, "ag2" }, - { BRCMS_SROM_AG3, "ag3" }, - { BRCMS_SROM_ANTSWCTL2G, "antswctl2g" }, - { BRCMS_SROM_ANTSWCTL5G, "antswctl5g" }, - { BRCMS_SROM_ANTSWITCH, "antswitch" }, - { BRCMS_SROM_BOARDFLAGS2, "boardflags2" }, - { BRCMS_SROM_BOARDFLAGS, "boardflags" }, - { BRCMS_SROM_BOARDNUM, "boardnum" }, - { BRCMS_SROM_BOARDREV, "boardrev" }, - { BRCMS_SROM_BOARDTYPE, "boardtype" }, - { BRCMS_SROM_BW40PO, "bw40po" }, - { BRCMS_SROM_BWDUPPO, "bwduppo" }, - { BRCMS_SROM_BXA2G, "bxa2g" }, - { BRCMS_SROM_BXA5G, "bxa5g" }, - { BRCMS_SROM_CC, "cc" }, - { BRCMS_SROM_CCK2GPO, "cck2gpo" }, - { BRCMS_SROM_CCKBW202GPO, "cckbw202gpo" }, - { BRCMS_SROM_CCKBW20UL2GPO, "cckbw20ul2gpo" }, - { BRCMS_SROM_CCODE, "ccode" }, - { BRCMS_SROM_CDDPO, "cddpo" }, - { BRCMS_SROM_DEVID, "devid" }, - { BRCMS_SROM_ET1MACADDR, "et1macaddr" }, - { BRCMS_SROM_EXTPAGAIN2G, "extpagain2g" }, - { BRCMS_SROM_EXTPAGAIN5G, "extpagain5g" }, - { BRCMS_SROM_FREQOFFSET_CORR, "freqoffset_corr" }, - { BRCMS_SROM_HW_IQCAL_EN, "hw_iqcal_en" }, - { BRCMS_SROM_IL0MACADDR, "il0macaddr" }, - { BRCMS_SROM_IQCAL_SWP_DIS, "iqcal_swp_dis" }, - { BRCMS_SROM_LEDBH0, "ledbh0" }, - { BRCMS_SROM_LEDBH1, "ledbh1" }, - { BRCMS_SROM_LEDBH2, "ledbh2" }, - { BRCMS_SROM_LEDBH3, "ledbh3" }, - { BRCMS_SROM_LEDDC, "leddc" }, - { BRCMS_SROM_LEGOFDM40DUPPO, "legofdm40duppo" }, - { BRCMS_SROM_LEGOFDMBW202GPO, "legofdmbw202gpo" }, - { BRCMS_SROM_LEGOFDMBW205GHPO, "legofdmbw205ghpo" }, - { BRCMS_SROM_LEGOFDMBW205GLPO, "legofdmbw205glpo" }, - { BRCMS_SROM_LEGOFDMBW205GMPO, "legofdmbw205gmpo" }, - { BRCMS_SROM_LEGOFDMBW20UL2GPO, "legofdmbw20ul2gpo" }, - { BRCMS_SROM_LEGOFDMBW20UL5GHPO, "legofdmbw20ul5ghpo" }, - { BRCMS_SROM_LEGOFDMBW20UL5GLPO, "legofdmbw20ul5glpo" }, - { BRCMS_SROM_LEGOFDMBW20UL5GMPO, "legofdmbw20ul5gmpo" }, - { BRCMS_SROM_MACADDR, "macaddr" }, - { BRCMS_SROM_MCS2GPO0, "mcs2gpo0" }, - { BRCMS_SROM_MCS2GPO1, "mcs2gpo1" }, - { BRCMS_SROM_MCS2GPO2, "mcs2gpo2" }, - { BRCMS_SROM_MCS2GPO3, "mcs2gpo3" }, - { BRCMS_SROM_MCS2GPO4, "mcs2gpo4" }, - { BRCMS_SROM_MCS2GPO5, "mcs2gpo5" }, - { BRCMS_SROM_MCS2GPO6, "mcs2gpo6" }, - { BRCMS_SROM_MCS2GPO7, "mcs2gpo7" }, - { BRCMS_SROM_MCS32PO, "mcs32po" }, - { BRCMS_SROM_MCS5GHPO0, "mcs5ghpo0" }, - { BRCMS_SROM_MCS5GHPO1, "mcs5ghpo1" }, - { BRCMS_SROM_MCS5GHPO2, "mcs5ghpo2" }, - { BRCMS_SROM_MCS5GHPO3, "mcs5ghpo3" }, - { BRCMS_SROM_MCS5GHPO4, "mcs5ghpo4" }, - { BRCMS_SROM_MCS5GHPO5, "mcs5ghpo5" }, - { BRCMS_SROM_MCS5GHPO6, "mcs5ghpo6" }, - { BRCMS_SROM_MCS5GHPO7, "mcs5ghpo7" }, - { BRCMS_SROM_MCS5GLPO0, "mcs5glpo0" }, - { BRCMS_SROM_MCS5GLPO1, "mcs5glpo1" }, - { BRCMS_SROM_MCS5GLPO2, "mcs5glpo2" }, - { BRCMS_SROM_MCS5GLPO3, "mcs5glpo3" }, - { BRCMS_SROM_MCS5GLPO4, "mcs5glpo4" }, - { BRCMS_SROM_MCS5GLPO5, "mcs5glpo5" }, - { BRCMS_SROM_MCS5GLPO6, "mcs5glpo6" }, - { BRCMS_SROM_MCS5GLPO7, "mcs5glpo7" }, - { BRCMS_SROM_MCS5GPO0, "mcs5gpo0" }, - { BRCMS_SROM_MCS5GPO1, "mcs5gpo1" }, - { BRCMS_SROM_MCS5GPO2, "mcs5gpo2" }, - { BRCMS_SROM_MCS5GPO3, "mcs5gpo3" }, - { BRCMS_SROM_MCS5GPO4, "mcs5gpo4" }, - { BRCMS_SROM_MCS5GPO5, "mcs5gpo5" }, - { BRCMS_SROM_MCS5GPO6, "mcs5gpo6" }, - { BRCMS_SROM_MCS5GPO7, "mcs5gpo7" }, - { BRCMS_SROM_MCSBW202GPO, "mcsbw202gpo" }, - { BRCMS_SROM_MCSBW205GHPO, "mcsbw205ghpo" }, - { BRCMS_SROM_MCSBW205GLPO, "mcsbw205glpo" }, - { BRCMS_SROM_MCSBW205GMPO, "mcsbw205gmpo" }, - { BRCMS_SROM_MCSBW20UL2GPO, "mcsbw20ul2gpo" }, - { BRCMS_SROM_MCSBW20UL5GHPO, "mcsbw20ul5ghpo" }, - { BRCMS_SROM_MCSBW20UL5GLPO, "mcsbw20ul5glpo" }, - { BRCMS_SROM_MCSBW20UL5GMPO, "mcsbw20ul5gmpo" }, - { BRCMS_SROM_MCSBW402GPO, "mcsbw402gpo" }, - { BRCMS_SROM_MCSBW405GHPO, "mcsbw405ghpo" }, - { BRCMS_SROM_MCSBW405GLPO, "mcsbw405glpo" }, - { BRCMS_SROM_MCSBW405GMPO, "mcsbw405gmpo" }, - { BRCMS_SROM_MEASPOWER, "measpower" }, - { BRCMS_SROM_OFDM2GPO, "ofdm2gpo" }, - { BRCMS_SROM_OFDM5GHPO, "ofdm5ghpo" }, - { BRCMS_SROM_OFDM5GLPO, "ofdm5glpo" }, - { BRCMS_SROM_OFDM5GPO, "ofdm5gpo" }, - { BRCMS_SROM_OPO, "opo" }, - { BRCMS_SROM_PA0B0, "pa0b0" }, - { BRCMS_SROM_PA0B1, "pa0b1" }, - { BRCMS_SROM_PA0B2, "pa0b2" }, - { BRCMS_SROM_PA0ITSSIT, "pa0itssit" }, - { BRCMS_SROM_PA0MAXPWR, "pa0maxpwr" }, - { BRCMS_SROM_PA1B0, "pa1b0" }, - { BRCMS_SROM_PA1B1, "pa1b1" }, - { BRCMS_SROM_PA1B2, "pa1b2" }, - { BRCMS_SROM_PA1HIB0, "pa1hib0" }, - { BRCMS_SROM_PA1HIB1, "pa1hib1" }, - { BRCMS_SROM_PA1HIB2, "pa1hib2" }, - { BRCMS_SROM_PA1HIMAXPWR, "pa1himaxpwr" }, - { BRCMS_SROM_PA1ITSSIT, "pa1itssit" }, - { BRCMS_SROM_PA1LOB0, "pa1lob0" }, - { BRCMS_SROM_PA1LOB1, "pa1lob1" }, - { BRCMS_SROM_PA1LOB2, "pa1lob2" }, - { BRCMS_SROM_PA1LOMAXPWR, "pa1lomaxpwr" }, - { BRCMS_SROM_PA1MAXPWR, "pa1maxpwr" }, - { BRCMS_SROM_PDETRANGE2G, "pdetrange2g" }, - { BRCMS_SROM_PDETRANGE5G, "pdetrange5g" }, - { BRCMS_SROM_PHYCAL_TEMPDELTA, "phycal_tempdelta" }, - { BRCMS_SROM_RAWTEMPSENSE, "rawtempsense" }, - { BRCMS_SROM_REV, "sromrev" }, - { BRCMS_SROM_REGREV, "regrev" }, - { BRCMS_SROM_RSSISAV2G, "rssisav2g" }, - { BRCMS_SROM_RSSISAV5G, "rssisav5g" }, - { BRCMS_SROM_RSSISMC2G, "rssismc2g" }, - { BRCMS_SROM_RSSISMC5G, "rssismc5g" }, - { BRCMS_SROM_RSSISMF2G, "rssismf2g" }, - { BRCMS_SROM_RSSISMF5G, "rssismf5g" }, - { BRCMS_SROM_RXCHAIN, "rxchain" }, - { BRCMS_SROM_RXPO2G, "rxpo2g" }, - { BRCMS_SROM_RXPO5G, "rxpo5g" }, - { BRCMS_SROM_STBCPO, "stbcpo" }, - { BRCMS_SROM_TEMPCORRX, "tempcorrx" }, - { BRCMS_SROM_TEMPOFFSET, "tempoffset" }, - { BRCMS_SROM_TEMPSENSE_OPTION, "tempsense_option" }, - { BRCMS_SROM_TEMPSENSE_SLOPE, "tempsense_slope" }, - { BRCMS_SROM_TEMPTHRESH, "tempthresh" }, - { BRCMS_SROM_TRI2G, "tri2g" }, - { BRCMS_SROM_TRI5GH, "tri5gh" }, - { BRCMS_SROM_TRI5GL, "tri5gl" }, - { BRCMS_SROM_TRI5G, "tri5g" }, - { BRCMS_SROM_TRISO2G, "triso2g" }, - { BRCMS_SROM_TRISO5G, "triso5g" }, - { BRCMS_SROM_TSSIPOS2G, "tssipos2g" }, - { BRCMS_SROM_TSSIPOS5G, "tssipos5g" }, - { BRCMS_SROM_TXCHAIN, "txchain" }, - { BRCMS_SROM_TXPID2GA0, "txpid2ga0" }, - { BRCMS_SROM_TXPID2GA1, "txpid2ga1" }, - { BRCMS_SROM_TXPID2GA2, "txpid2ga2" }, - { BRCMS_SROM_TXPID2GA3, "txpid2ga3" }, - { BRCMS_SROM_TXPID5GA0, "txpid5ga0" }, - { BRCMS_SROM_TXPID5GA1, "txpid5ga1" }, - { BRCMS_SROM_TXPID5GA2, "txpid5ga2" }, - { BRCMS_SROM_TXPID5GA3, "txpid5ga3" }, - { BRCMS_SROM_TXPID5GHA0, "txpid5gha0" }, - { BRCMS_SROM_TXPID5GHA1, "txpid5gha1" }, - { BRCMS_SROM_TXPID5GHA2, "txpid5gha2" }, - { BRCMS_SROM_TXPID5GHA3, "txpid5gha3" }, - { BRCMS_SROM_TXPID5GLA0, "txpid5gla0" }, - { BRCMS_SROM_TXPID5GLA1, "txpid5gla1" }, - { BRCMS_SROM_TXPID5GLA2, "txpid5gla2" }, - { BRCMS_SROM_TXPID5GLA3, "txpid5gla3" }, - { BRCMS_SROM_ITT2GA0, "itt2ga0" }, - { BRCMS_SROM_ITT2GA1, "itt2ga1" }, - { BRCMS_SROM_ITT2GA2, "itt2ga2" }, - { BRCMS_SROM_ITT2GA3, "itt2ga3" }, - { BRCMS_SROM_ITT5GA0, "itt5ga0" }, - { BRCMS_SROM_ITT5GA1, "itt5ga1" }, - { BRCMS_SROM_ITT5GA2, "itt5ga2" }, - { BRCMS_SROM_ITT5GA3, "itt5ga3" }, - { BRCMS_SROM_MAXP2GA0, "maxp2ga0" }, - { BRCMS_SROM_MAXP2GA1, "maxp2ga1" }, - { BRCMS_SROM_MAXP2GA2, "maxp2ga2" }, - { BRCMS_SROM_MAXP2GA3, "maxp2ga3" }, - { BRCMS_SROM_MAXP5GA0, "maxp5ga0" }, - { BRCMS_SROM_MAXP5GA1, "maxp5ga1" }, - { BRCMS_SROM_MAXP5GA2, "maxp5ga2" }, - { BRCMS_SROM_MAXP5GA3, "maxp5ga3" }, - { BRCMS_SROM_MAXP5GHA0, "maxp5gha0" }, - { BRCMS_SROM_MAXP5GHA1, "maxp5gha1" }, - { BRCMS_SROM_MAXP5GHA2, "maxp5gha2" }, - { BRCMS_SROM_MAXP5GHA3, "maxp5gha3" }, - { BRCMS_SROM_MAXP5GLA0, "maxp5gla0" }, - { BRCMS_SROM_MAXP5GLA1, "maxp5gla1" }, - { BRCMS_SROM_MAXP5GLA2, "maxp5gla2" }, - { BRCMS_SROM_MAXP5GLA3, "maxp5gla3" }, - { BRCMS_SROM_PA2GW0A0, "pa2gw0a0" }, - { BRCMS_SROM_PA2GW0A1, "pa2gw0a1" }, - { BRCMS_SROM_PA2GW0A2, "pa2gw0a2" }, - { BRCMS_SROM_PA2GW0A3, "pa2gw0a3" }, - { BRCMS_SROM_PA2GW1A0, "pa2gw1a0" }, - { BRCMS_SROM_PA2GW1A1, "pa2gw1a1" }, - { BRCMS_SROM_PA2GW1A2, "pa2gw1a2" }, - { BRCMS_SROM_PA2GW1A3, "pa2gw1a3" }, - { BRCMS_SROM_PA2GW2A0, "pa2gw2a0" }, - { BRCMS_SROM_PA2GW2A1, "pa2gw2a1" }, - { BRCMS_SROM_PA2GW2A2, "pa2gw2a2" }, - { BRCMS_SROM_PA2GW2A3, "pa2gw2a3" }, - { BRCMS_SROM_PA2GW3A0, "pa2gw3a0" }, - { BRCMS_SROM_PA2GW3A1, "pa2gw3a1" }, - { BRCMS_SROM_PA2GW3A2, "pa2gw3a2" }, - { BRCMS_SROM_PA2GW3A3, "pa2gw3a3" }, - { BRCMS_SROM_PA5GHW0A0, "pa5ghw0a0" }, - { BRCMS_SROM_PA5GHW0A1, "pa5ghw0a1" }, - { BRCMS_SROM_PA5GHW0A2, "pa5ghw0a2" }, - { BRCMS_SROM_PA5GHW0A3, "pa5ghw0a3" }, - { BRCMS_SROM_PA5GHW1A0, "pa5ghw1a0" }, - { BRCMS_SROM_PA5GHW1A1, "pa5ghw1a1" }, - { BRCMS_SROM_PA5GHW1A2, "pa5ghw1a2" }, - { BRCMS_SROM_PA5GHW1A3, "pa5ghw1a3" }, - { BRCMS_SROM_PA5GHW2A0, "pa5ghw2a0" }, - { BRCMS_SROM_PA5GHW2A1, "pa5ghw2a1" }, - { BRCMS_SROM_PA5GHW2A2, "pa5ghw2a2" }, - { BRCMS_SROM_PA5GHW2A3, "pa5ghw2a3" }, - { BRCMS_SROM_PA5GHW3A0, "pa5ghw3a0" }, - { BRCMS_SROM_PA5GHW3A1, "pa5ghw3a1" }, - { BRCMS_SROM_PA5GHW3A2, "pa5ghw3a2" }, - { BRCMS_SROM_PA5GHW3A3, "pa5ghw3a3" }, - { BRCMS_SROM_PA5GLW0A0, "pa5glw0a0" }, - { BRCMS_SROM_PA5GLW0A1, "pa5glw0a1" }, - { BRCMS_SROM_PA5GLW0A2, "pa5glw0a2" }, - { BRCMS_SROM_PA5GLW0A3, "pa5glw0a3" }, - { BRCMS_SROM_PA5GLW1A0, "pa5glw1a0" }, - { BRCMS_SROM_PA5GLW1A1, "pa5glw1a1" }, - { BRCMS_SROM_PA5GLW1A2, "pa5glw1a2" }, - { BRCMS_SROM_PA5GLW1A3, "pa5glw1a3" }, - { BRCMS_SROM_PA5GLW2A0, "pa5glw2a0" }, - { BRCMS_SROM_PA5GLW2A1, "pa5glw2a1" }, - { BRCMS_SROM_PA5GLW2A2, "pa5glw2a2" }, - { BRCMS_SROM_PA5GLW2A3, "pa5glw2a3" }, - { BRCMS_SROM_PA5GLW3A0, "pa5glw3a0" }, - { BRCMS_SROM_PA5GLW3A1, "pa5glw3a1" }, - { BRCMS_SROM_PA5GLW3A2, "pa5glw3a2" }, - { BRCMS_SROM_PA5GLW3A3, "pa5glw3a3" }, - { BRCMS_SROM_PA5GW0A0, "pa5gw0a0" }, - { BRCMS_SROM_PA5GW0A1, "pa5gw0a1" }, - { BRCMS_SROM_PA5GW0A2, "pa5gw0a2" }, - { BRCMS_SROM_PA5GW0A3, "pa5gw0a3" }, - { BRCMS_SROM_PA5GW1A0, "pa5gw1a0" }, - { BRCMS_SROM_PA5GW1A1, "pa5gw1a1" }, - { BRCMS_SROM_PA5GW1A2, "pa5gw1a2" }, - { BRCMS_SROM_PA5GW1A3, "pa5gw1a3" }, - { BRCMS_SROM_PA5GW2A0, "pa5gw2a0" }, - { BRCMS_SROM_PA5GW2A1, "pa5gw2a1" }, - { BRCMS_SROM_PA5GW2A2, "pa5gw2a2" }, - { BRCMS_SROM_PA5GW2A3, "pa5gw2a3" }, - { BRCMS_SROM_PA5GW3A0, "pa5gw3a0" }, - { BRCMS_SROM_PA5GW3A1, "pa5gw3a1" }, - { BRCMS_SROM_PA5GW3A2, "pa5gw3a2" }, - { BRCMS_SROM_PA5GW3A3, "pa5gw3a3" }, -}; - -static const char *get_varname(enum brcms_srom_id id) -{ - const struct srom_id_name *entry; - int i; - - entry = &srom_id_map[0]; - for (i = 0; i < ARRAY_SIZE(srom_id_map); i++) { - if (entry->id == id) - return entry->name; - entry++; - } - return NULL; -} - /* crc table has the same contents for every device instance, so it can be * shared between devices. */ static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; @@ -1162,70 +920,14 @@ static inline void htol16_buf(u16 *buf, unsigned int size) *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); } -/* Initialization of varbuf structure */ -static void varbuf_init(struct brcms_varbuf *b, char *buf, uint size) -{ - b->size = size; - b->base = b->buf = buf; -} - -/* append a null terminated var=value string */ -static int varbuf_append(struct brcms_varbuf *b, const char *fmt, ...) -{ - va_list ap; - int r; - size_t len; - char *s; - - if (b->size < 2) - return 0; - - va_start(ap, fmt); - r = vsnprintf(b->buf, b->size, fmt, ap); - va_end(ap); - - /* - * C99 snprintf behavior returns r >= size on overflow, - * others return -1 on overflow. All return -1 on format error. - * We need to leave room for 2 null terminations, one for the current - * var string, and one for final null of the var table. So check that - * the strlen written, r, leaves room for 2 chars. - */ - if ((r == -1) || (r > (int)(b->size - 2))) { - b->size = 0; - return 0; - } - - /* Remove any earlier occurrence of the same variable */ - s = strchr(b->buf, '='); - if (s != NULL) { - len = (size_t) (s - b->buf); - for (s = b->base; s < b->buf;) { - if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') { - len = strlen(s) + 1; - memmove(s, (s + len), - ((b->buf + r + 1) - (s + len))); - b->buf -= len; - b->size += (unsigned int)len; - break; - } - - while (*s++) - ; - } - } - - /* skip over this string's null termination */ - r++; - b->size -= r; - b->buf += r; - - return r; -} - +/* + * convert binary srom data into linked list of srom variable items. + */ static void -_initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) +_initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct list_head *var_list) { + struct brcms_srom_list_head *entry; + enum brcms_srom_id id; u16 w; u32 val; const struct brcms_sromvar *srv; @@ -1233,10 +935,17 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) uint flags; u32 sr = (1 << sromrev); - varbuf_append(b, "sromrev=%d", sromrev); + /* first store the srom revision */ + entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); + entry->varid = BRCMS_SROM_REV; + entry->var_type = BRCMS_SROM_UNUMBER; + entry->uval = sromrev; + list_add(&entry->var_list, var_list); for (srv = pci_sromvars; srv->varid != BRCMS_SROM_NULL; srv++) { - const char *name; + enum brcms_srom_var_type type; + u8 ea[ETH_ALEN]; + u8 extra_space = 0; if ((srv->revmask & sr) == 0) continue; @@ -1245,23 +954,25 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) continue; flags = srv->flags; - name = get_varname(srv->varid); + id = srv->varid; /* This entry is for mfgc only. Don't generate param for it, */ if (flags & SRFL_NOVAR) continue; if (flags & SRFL_ETHADDR) { - u8 ea[ETH_ALEN]; - + /* + * stored in string format XX:XX:XX:XX:XX:XX (17 chars) + */ ea[0] = (srom[srv->off - off] >> 8) & 0xff; ea[1] = srom[srv->off - off] & 0xff; ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; ea[3] = srom[srv->off + 1 - off] & 0xff; ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; ea[5] = srom[srv->off + 2 - off] & 0xff; - - varbuf_append(b, "%s=%pM", name, ea); + /* 17 characters + string terminator - union size */ + extra_space = 18 - sizeof(s32); + type = BRCMS_SROM_STRING; } else { w = srom[srv->off - off]; val = (w & srv->mask) >> mask_shift(srv->mask); @@ -1285,30 +996,42 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) continue; if (flags & SRFL_CCODE) { - if (val == 0) - varbuf_append(b, "ccode="); - else - varbuf_append(b, "ccode=%c%c", - (val >> 8), (val & 0xff)); - } - /* LED Powersave duty cycle has to be scaled: - *(oncount >> 24) (offcount >> 8) - */ - else if (flags & SRFL_LEDDC) { + type = BRCMS_SROM_STRING; + } else if (flags & SRFL_LEDDC) { + /* LED Powersave duty cycle has to be scaled: + *(oncount >> 24) (offcount >> 8) + */ u32 w32 = /* oncount */ (((val >> 8) & 0xff) << 24) | /* offcount */ (((val & 0xff)) << 8); - varbuf_append(b, "leddc=%d", w32); - } else if (flags & SRFL_PRHEX) - varbuf_append(b, "%s=0x%x", name, val); - else if ((flags & SRFL_PRSIGN) - && (val & (1 << (width - 1)))) - varbuf_append(b, "%s=%d", name, - (int)(val | (~0 << width))); - else - varbuf_append(b, "%s=%u", name, val); + type = BRCMS_SROM_UNUMBER; + val = w32; + } else if ((flags & SRFL_PRSIGN) + && (val & (1 << (width - 1)))) { + type = BRCMS_SROM_SNUMBER; + val |= ~0 << width; + } else + type = BRCMS_SROM_UNUMBER; } + + entry = kzalloc(sizeof(struct brcms_srom_list_head) + + extra_space, GFP_KERNEL); + entry->varid = id; + entry->var_type = type; + if (flags & SRFL_ETHADDR) { + snprintf(entry->buf, 18, "%pM", ea); + } else if (flags & SRFL_CCODE) { + if (val == 0) + entry->buf[0] = '\0'; + else + snprintf(entry->buf, 3, "%c%c", + (val >> 8), (val & 0xff)); + } else { + entry->uval = val; + } + + list_add(&entry->var_list, var_list); } if (sromrev >= 4) { @@ -1345,14 +1068,13 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct brcms_varbuf *b) && ((int)val == (1 << width) - 1)) continue; - if (srv->flags & SRFL_PRHEX) - varbuf_append(b, "%s%d=0x%x", - get_varname(srv->varid), - p, val); - else - varbuf_append(b, "%s%d=%d", - get_varname(srv->varid), - p, val); + entry = + kzalloc(sizeof(struct brcms_srom_list_head), + GFP_KERNEL); + entry->varid = srv->varid+p; + entry->var_type = BRCMS_SROM_UNUMBER; + entry->uval = val; + list_add(&entry->var_list, var_list); } pb += psz; } @@ -1434,31 +1156,6 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) return err; } -/* -* Create variable table from memory. -* Return 0 on success, nonzero on error. -*/ -static int initvars_table(char *start, char *end, - char **vars, uint *count) -{ - int c = (int)(end - start); - - /* do it only when there is more than just the null string */ - if (c > 1) { - char *vp = kmalloc(c, GFP_ATOMIC); - if (!vp) - return -ENOMEM; - memcpy(vp, start, c); - *vars = vp; - *count = c; - } else { - *vars = NULL; - *count = 0; - } - - return 0; -} - /* * Initialize nonvolatile variable table from sprom. * Return 0 on success, nonzero on error. @@ -1470,8 +1167,6 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, u16 __iomem *sromwindow; u8 sromrev = 0; u32 sr; - struct brcms_varbuf b; - char *vp, *base = NULL; int err = 0; /* @@ -1514,6 +1209,8 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, } if (!err) { + struct si_info *sii = (struct si_info *)sih; + /* Bitmask for the sromrev */ sr = 1 << sromrev; @@ -1526,23 +1223,10 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, goto errout; } - base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC); - if (!base) { - err = -ENOMEM; - goto errout; - } - - varbuf_init(&b, base, MAXSZ_NVRAM_VARS); + INIT_LIST_HEAD(&sii->var_list); /* parse SROM into name=value pairs. */ - _initvars_srom_pci(sromrev, srom, 0, &b); - - /* final nullbyte terminator */ - vp = b.buf; - *vp++ = '\0'; - - err = initvars_table(base, vp, vars, count); - kfree(base); + _initvars_srom_pci(sromrev, srom, 0, &sii->var_list); } errout: @@ -1550,6 +1234,17 @@ errout: return err; } +void srom_free_vars(struct si_pub *sih) +{ + struct si_info *sii; + struct brcms_srom_list_head *entry, *next; + + sii = (struct si_info *)sih; + list_for_each_entry_safe(entry, next, &sii->var_list, var_list) { + list_del(&entry->var_list); + kfree(entry); + } +} /* * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. @@ -1579,44 +1274,39 @@ int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, */ char *getvar(struct si_pub *sih, enum brcms_srom_id id) { - const char *name = get_varname(id); - char *s; - int len; struct si_info *sii; - - if (!name) - return NULL; - - len = strlen(name); - if (len == 0) - return NULL; + struct brcms_srom_list_head *entry; sii = (struct si_info *)sih; - /* first look in vars[] */ - for (s = sii->vars; s && *s;) { - if ((memcmp(s, name, len) == 0) && (s[len] == '=')) - return &s[len + 1]; + list_for_each_entry(entry, &sii->var_list, var_list) + if (entry->varid == id) + return &entry->buf[0]; - while (*s++) - ; - } /* nothing found */ return NULL; } /* * Search the vars for a specific one and return its value as - * an integer. Returns 0 if not found. + * an integer. Returns 0 if not found.- */ int getintvar(struct si_pub *sih, enum brcms_srom_id id) { - char *val; + struct si_info *sii; + struct brcms_srom_list_head *entry; unsigned long res; - val = getvar(sih, id); - if (val && !kstrtoul(val, 0, &res)) - return res; + sii = (struct si_info *)sih; + + list_for_each_entry(entry, &sii->var_list, var_list) + if (entry->varid == id) { + if (entry->var_type == BRCMS_SROM_SNUMBER || + entry->var_type == BRCMS_SROM_UNUMBER) + return (int)entry->sval; + else if (!kstrtoul(&entry->buf[0], 0, &res)) + return (int)res; + } return 0; } diff --git a/drivers/staging/brcm80211/brcmsmac/srom.h b/drivers/staging/brcm80211/brcmsmac/srom.h index 826c2cd91af..395ab7ffb52 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.h +++ b/drivers/staging/brcm80211/brcmsmac/srom.h @@ -22,6 +22,7 @@ /* Prototypes */ extern int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, uint *count); +extern void srom_free_vars(struct si_pub *sih); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, uint byteoff, uint nbytes, u16 *buf, bool check_crc); From 4d648c8b329db8198d6196468ff4d5326739e507 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:11 +0200 Subject: [PATCH 1351/1519] staging: brcm80211: remove parameter 'off' from _initvars_srom_pci() The function is called once with parameter 'off' fixed to zero. This parameter has been removed. Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/srom.c | 30 +++++++++-------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 75de8d11a15..8400cf41e9a 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -924,7 +924,7 @@ static inline void htol16_buf(u16 *buf, unsigned int size) * convert binary srom data into linked list of srom variable items. */ static void -_initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct list_head *var_list) +_initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) { struct brcms_srom_list_head *entry; enum brcms_srom_id id; @@ -950,9 +950,6 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct list_head *var_list) if ((srv->revmask & sr) == 0) continue; - if (srv->off < off) - continue; - flags = srv->flags; id = srv->varid; @@ -964,26 +961,26 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct list_head *var_list) /* * stored in string format XX:XX:XX:XX:XX:XX (17 chars) */ - ea[0] = (srom[srv->off - off] >> 8) & 0xff; - ea[1] = srom[srv->off - off] & 0xff; - ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; - ea[3] = srom[srv->off + 1 - off] & 0xff; - ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; - ea[5] = srom[srv->off + 2 - off] & 0xff; + ea[0] = (srom[srv->off] >> 8) & 0xff; + ea[1] = srom[srv->off] & 0xff; + ea[2] = (srom[srv->off + 1] >> 8) & 0xff; + ea[3] = srom[srv->off + 1] & 0xff; + ea[4] = (srom[srv->off + 2] >> 8) & 0xff; + ea[5] = srom[srv->off + 2] & 0xff; /* 17 characters + string terminator - union size */ extra_space = 18 - sizeof(s32); type = BRCMS_SROM_STRING; } else { - w = srom[srv->off - off]; + w = srom[srv->off]; val = (w & srv->mask) >> mask_shift(srv->mask); width = mask_width(srv->mask); while (srv->flags & SRFL_MORE) { srv++; - if (srv->off == 0 || srv->off < off) + if (srv->off == 0) continue; - w = srom[srv->off - off]; + w = srom[srv->off]; val += ((w & srv->mask) >> mask_shift(srv-> mask)) << @@ -1052,13 +1049,10 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, struct list_head *var_list) if ((srv->revmask & sr) == 0) continue; - if (pb + srv->off < off) - continue; - if (srv->flags & SRFL_NOVAR) continue; - w = srom[pb + srv->off - off]; + w = srom[pb + srv->off]; val = (w & srv->mask) >> mask_shift(srv->mask); width = mask_width(srv->mask); @@ -1226,7 +1220,7 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, INIT_LIST_HEAD(&sii->var_list); /* parse SROM into name=value pairs. */ - _initvars_srom_pci(sromrev, srom, 0, &sii->var_list); + _initvars_srom_pci(sromrev, srom, &sii->var_list); } errout: From 5d3e78eeebb4143a0b5bd53547eb16968f43b5bc Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 5 Oct 2011 15:20:12 +0200 Subject: [PATCH 1352/1519] staging: brcm80211: cleanup driver variable references Throughout the data structures within the driver several references to the driver variables were stored. As the storage and access functions are now consolidated into srom.c those references are no longer needed and have been removed. Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmsmac/aiutils.c | 13 +++----- drivers/staging/brcm80211/brcmsmac/aiutils.h | 5 +--- drivers/staging/brcm80211/brcmsmac/main.c | 30 ++----------------- drivers/staging/brcm80211/brcmsmac/main.h | 5 ---- .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 6 +--- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 4 +-- .../staging/brcm80211/brcmsmac/phy/phy_int.h | 1 - drivers/staging/brcm80211/brcmsmac/pub.h | 1 - drivers/staging/brcm80211/brcmsmac/srom.c | 14 ++------- drivers/staging/brcm80211/brcmsmac/srom.h | 3 +- 10 files changed, 14 insertions(+), 68 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c index afba8b12070..025fa0eb6f4 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.c @@ -1025,8 +1025,7 @@ static __used void ai_nvram_process(struct si_info *sii) } static struct si_info *ai_doattach(struct si_info *sii, - void __iomem *regs, struct pci_dev *pbus, - char **vars, uint *varsz) + void __iomem *regs, struct pci_dev *pbus) { struct si_pub *sih = &sii->pub; u32 w, savewin; @@ -1091,11 +1090,9 @@ static struct si_info *ai_doattach(struct si_info *sii, goto exit; /* Init nvram from sprom/otp if they exist */ - if (srom_var_init(&sii->pub, cc, vars, varsz)) + if (srom_var_init(&sii->pub, cc)) goto exit; - sii->vars = vars ? *vars : NULL; - sii->varsz = varsz ? *varsz : 0; ai_nvram_process(sii); /* === NVRAM, clock is ready === */ @@ -1172,11 +1169,9 @@ static struct si_info *ai_doattach(struct si_info *sii, * devid - pci device id (used to determine chip#) * osh - opaque OS handle * regs - virtual address of initial core registers - * vars - pointer to a pointer area for "environment" variables - * varsz - pointer to int to return the size of the vars */ struct si_pub * -ai_attach(void __iomem *regs, struct pci_dev *sdh, char **vars, uint *varsz) +ai_attach(void __iomem *regs, struct pci_dev *sdh) { struct si_info *sii; @@ -1185,7 +1180,7 @@ ai_attach(void __iomem *regs, struct pci_dev *sdh, char **vars, uint *varsz) if (sii == NULL) return NULL; - if (ai_doattach(sii, regs, sdh, vars, varsz) == NULL) { + if (ai_doattach(sii, regs, sdh) == NULL) { kfree(sii); return NULL; } diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h index dce55513374..106a7424a7c 100644 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ b/drivers/staging/brcm80211/brcmsmac/aiutils.h @@ -267,8 +267,6 @@ struct si_info { struct pcicore_info *pch; /* PCI/E core handle */ struct list_head var_list; /* list of srom variables */ - char *vars; - uint varsz; void __iomem *curmap; /* current regs va */ void __iomem *regs[SI_MAXCORES]; /* other regs va */ @@ -320,8 +318,7 @@ extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ -extern struct si_pub *ai_attach(void __iomem *regs, struct pci_dev *sdh, - char **vars, uint *varsz); +extern struct si_pub *ai_attach(void __iomem *regs, struct pci_dev *sdh); extern void ai_detach(struct si_pub *sih); extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c index 5ec25e89eef..1e35be95262 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ b/drivers/staging/brcm80211/brcmsmac/main.c @@ -3106,16 +3106,6 @@ brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, } } -static void brcms_b_copyfrom_vars(struct brcms_hardware *wlc_hw, char **buf, - uint *len) -{ - BCMMSG(wlc_hw->wlc->wiphy, "nvram vars totlen=%d\n", - wlc_hw->vars_size); - - *buf = wlc_hw->vars; - *len = wlc_hw->vars_size; -} - static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, u16 SRL, u16 LRL) { @@ -4551,7 +4541,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, struct brcms_hardware *wlc_hw; struct d11regs __iomem *regs; char *macaddr = NULL; - char *vars; uint err = 0; uint j; bool wme = false; @@ -4576,15 +4565,13 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, * Do the hardware portion of the attach. Also initialize software * state that depends on the particular hardware we are running. */ - wlc_hw->sih = ai_attach(regsva, btparam, - &wlc_hw->vars, &wlc_hw->vars_size); + wlc_hw->sih = ai_attach(regsva, btparam); if (wlc_hw->sih == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", unit); err = 11; goto fail; } - vars = wlc_hw->vars; /* verify again the device is supported */ if (!brcms_c_chipmatch(vendor, device)) { @@ -4692,7 +4679,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, sha_params.physhim = wlc_hw->physhim; sha_params.unit = unit; sha_params.corerev = wlc_hw->corerev; - sha_params.vars = vars; sha_params.vid = wlc_hw->vendorid; sha_params.did = wlc_hw->deviceid; sha_params.chip = wlc_hw->sih->chip; @@ -4738,8 +4724,8 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, /* Get a phy for this band */ wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, regs, - wlc_hw->band->bandtype, vars, - wlc->wiphy); + wlc_hw->band->bandtype, + wlc->wiphy); if (wlc_hw->band->pi == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" "attach failed\n", unit); @@ -4897,12 +4883,10 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) { int aa; uint unit; - char *vars; int bandtype; struct si_pub *sih = wlc->hw->sih; unit = wlc->pub->unit; - vars = wlc->pub->vars; bandtype = wlc->band->bandtype; /* get antennas available */ @@ -5092,10 +5076,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); - /* propagate *vars* from BMAC driver to high driver */ - brcms_b_copyfrom_vars(wlc->hw, &pub->vars, &wlc->vars_size); - - /* disable allowed duty cycle */ wlc->tx_duty_cycle_ofdm = 0; wlc->tx_duty_cycle_cck = 0; @@ -5304,10 +5284,6 @@ static int brcms_b_detach(struct brcms_c_info *wlc) wlc_phy_shim_detach(wlc_hw->physhim); - /* free vars */ - kfree(wlc_hw->vars); - wlc_hw->vars = NULL; - if (wlc_hw->sih) { ai_detach(wlc_hw->sih); wlc_hw->sih = NULL; diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h index 441292a2418..7a2554f611a 100644 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ b/drivers/staging/brcm80211/brcmsmac/main.h @@ -336,8 +336,6 @@ struct brcms_hardware { u32 machwcap_backup; /* backup of machwcap */ struct si_pub *sih; /* SI handle (cookie for siutils calls) */ - char *vars; /* "environment" name=value */ - uint vars_size; /* size of vars, free vars on detach */ struct d11regs __iomem *regs; /* pointer to device registers */ struct phy_shim_info *physhim; /* phy shim layer handler */ struct shared_phy *phy_sh; /* pointer to shared phy state */ @@ -420,7 +418,6 @@ struct brcms_txq_info { * ampdu: ampdu module handler. * asi: antsel module handler. * cmi: channel manager module handler. - * vars_size: size of vars, free vars on detach. * vendorid: PCI vendor id. * deviceid: PCI device id. * ucode_rev: microcode revision. @@ -513,8 +510,6 @@ struct brcms_c_info { struct antsel_info *asi; struct brcms_cm_info *cmi; - uint vars_size; - u16 vendorid; u16 deviceid; uint ucode_rev; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c index 59767e36735..d54cfdb0a8e 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c @@ -459,7 +459,7 @@ static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) struct brcms_phy_pub * wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, - int bandtype, char *vars, struct wiphy *wiphy) + int bandtype, struct wiphy *wiphy) { struct brcms_phy *pi; u32 sflags = 0; @@ -493,8 +493,6 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, pi->phy_init_por = true; pi->phy_wreg_limit = PHY_WREG_LIMIT; - pi->vars = vars; - pi->txpwr_percent = 100; pi->do_initcal = true; @@ -609,8 +607,6 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, pi->next = pi->sh->phy_head; sh->phy_head = pi; - pi->vars = (char *)&pi->vars; - memcpy(&pi->pubpi_ro, &pi->pubpi, sizeof(struct brcms_phy_pub)); return &pi->pubpi_ro; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h index 44818af3047..96e15163222 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h @@ -167,7 +167,6 @@ struct shared_phy_params { uint unit; uint corerev; uint buscorerev; - char *vars; u16 vid; u16 did; uint chip; @@ -185,8 +184,7 @@ struct shared_phy_params { extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, - int bandtype, char *vars, - struct wiphy *wiphy); + int bandtype, struct wiphy *wiphy); extern void wlc_phy_detach(struct brcms_phy_pub *ppi); extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h index 4330e3846d9..bea85241a24 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h @@ -561,7 +561,6 @@ struct brcms_phy { struct d11regs __iomem *regs; struct brcms_phy *next; - char *vars; struct brcms_phy_pub pubpi; bool do_initcal; diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h index 8c9ac8f4ee0..3942f47b15c 100644 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ b/drivers/staging/brcm80211/brcmsmac/pub.h @@ -407,7 +407,6 @@ struct brcms_pub { uint unit; /* device instance number */ uint corerev; /* core revision */ struct si_pub *sih; /* SI handle (cookie for siutils calls) */ - char *vars; /* "environment" name=value */ bool up; /* interface up and running */ bool hw_off; /* HW is off */ bool hw_up; /* one time hw up/down */ diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 8400cf41e9a..99f791048e8 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -1154,8 +1154,7 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) * Initialize nonvolatile variable table from sprom. * Return 0 on success, nonzero on error. */ -static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap, - char **vars, uint *count) +static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) { u16 *srom; u16 __iomem *sromwindow; @@ -1243,21 +1242,14 @@ void srom_free_vars(struct si_pub *sih) * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. */ -int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, - uint *count) +int srom_var_init(struct si_pub *sih, void __iomem *curmap) { uint len; len = 0; - if (vars == NULL || count == NULL) - return 0; - - *vars = NULL; - *count = 0; - if (curmap != NULL) - return initvars_srom_pci(sih, curmap, vars, count); + return initvars_srom_pci(sih, curmap); return -EINVAL; } diff --git a/drivers/staging/brcm80211/brcmsmac/srom.h b/drivers/staging/brcm80211/brcmsmac/srom.h index 395ab7ffb52..708c43ff51c 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.h +++ b/drivers/staging/brcm80211/brcmsmac/srom.h @@ -20,8 +20,7 @@ #include "types.h" /* Prototypes */ -extern int srom_var_init(struct si_pub *sih, void __iomem *curmap, char **vars, - uint *count); +extern int srom_var_init(struct si_pub *sih, void __iomem *curmap); extern void srom_free_vars(struct si_pub *sih); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, From f461a2941233a5524ff5327862879f91f2fa5997 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Wed, 5 Oct 2011 15:20:13 +0200 Subject: [PATCH 1353/1519] staging: brcm80211: clean up struct brcmf_if in fullmac Some elements in structure brcmf_if are unused at all or redundant. This patch cleans it up. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 804b2bc64b1..b0202b7dd09 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -58,11 +58,7 @@ struct brcmf_if { struct net_device_stats stats; int idx; /* iface idx in dongle */ int state; /* interface state */ - uint subunit; /* subunit */ u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ - bool attached; /* Delayed attachment when unset */ - bool txflowcontrol; /* Per interface flow control indicator */ - char name[IFNAMSIZ]; /* linux interface name */ }; /* Local private structure (extension of pub) */ @@ -100,14 +96,16 @@ static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) { int i = BRCMF_MAX_IFS; + struct brcmf_if *ifp; if (name == NULL || *name == '\0') return 0; - while (--i > 0) - if (drvr_priv->iflist[i] - && !strncmp(drvr_priv->iflist[i]->name, name, IFNAMSIZ)) + while (--i > 0) { + ifp = drvr_priv->iflist[i]; + if (ifp && !strncmp(ifp->ndev->name, name, IFNAMSIZ)) break; + } brcmf_dbg(TRACE, "return idx %d for \"%s\"\n", i, name); @@ -315,7 +313,6 @@ static void brcmf_op_if(struct brcmf_if *ifp) ret = -ENOMEM; } if (ret == 0) { - strcpy(ifp->ndev->name, ifp->name); memcpy(netdev_priv(ifp->ndev), &drvr_priv, sizeof(drvr_priv)); err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); @@ -980,7 +977,6 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, memset(ifp, 0, sizeof(struct brcmf_if)); ifp->info = drvr_priv; drvr_priv->iflist[ifidx] = ifp; - strlcpy(ifp->name, name, IFNAMSIZ); if (mac_addr != NULL) memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); From 5df06b16d50af7cc98ddf65ad6602ab07b62925a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Wed, 5 Oct 2011 15:20:14 +0200 Subject: [PATCH 1354/1519] staging: brcm80211: remove brcmf_op_if from fullmac Absorb related code into brcmf_add_if/brcmf_del_if. This is part of the net device interface clean up. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- .../staging/brcm80211/brcmfmac/dhd_linux.c | 120 ++++++++---------- 1 file changed, 50 insertions(+), 70 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index b0202b7dd09..99ba5e3e45f 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -282,74 +282,6 @@ _brcmf_set_mac_address(struct work_struct *work) return; } -/* Virtual interfaces only ((ifp && ifp->info && ifp->idx == true) */ -static void brcmf_op_if(struct brcmf_if *ifp) -{ - struct brcmf_info *drvr_priv; - int ret = 0, err = 0; - - drvr_priv = ifp->info; - - brcmf_dbg(TRACE, "idx %d, state %d\n", ifp->idx, ifp->state); - - switch (ifp->state) { - case BRCMF_E_IF_ADD: - /* - * Delete the existing interface before overwriting it - * in case we missed the BRCMF_E_IF_DEL event. - */ - if (ifp->ndev != NULL) { - brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", - ifp->ndev->name); - netif_stop_queue(ifp->ndev); - unregister_netdev(ifp->ndev); - free_netdev(ifp->ndev); - } - /* Allocate netdev, including space for private structure */ - ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", - ether_setup); - if (!ifp->ndev) { - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - ret = -ENOMEM; - } - if (ret == 0) { - memcpy(netdev_priv(ifp->ndev), &drvr_priv, - sizeof(drvr_priv)); - err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); - if (err != 0) { - brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", - err); - ret = -EOPNOTSUPP; - } else { - brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", - current->pid, ifp->ndev->name); - ifp->state = 0; - } - } - break; - case BRCMF_E_IF_DEL: - if (ifp->ndev != NULL) { - brcmf_dbg(TRACE, "got 'WLC_E_IF_DEL' state\n"); - netif_stop_queue(ifp->ndev); - unregister_netdev(ifp->ndev); - ret = BRCMF_DEL_IF; /* Make sure the free_netdev() - is called */ - } - break; - default: - brcmf_dbg(ERROR, "bad op %d\n", ifp->state); - break; - } - - if (ret < 0) { - if (ifp->ndev) - free_netdev(ifp->ndev); - - drvr_priv->iflist[ifp->idx] = NULL; - kfree(ifp); - } -} - static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) { struct brcmf_info *drvr_priv = *(struct brcmf_info **) @@ -964,6 +896,7 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, char *name, u8 *mac_addr, u32 flags, u8 bssidx) { struct brcmf_if *ifp; + int ret = 0, err = 0; brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); @@ -983,7 +916,48 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, if (ndev == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; - brcmf_op_if(ifp); + /* + * Delete the existing interface before overwriting it + * in case we missed the BRCMF_E_IF_DEL event. + */ + if (ifp->ndev != NULL) { + brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", + ifp->ndev->name); + netif_stop_queue(ifp->ndev); + unregister_netdev(ifp->ndev); + free_netdev(ifp->ndev); + } + + /* Allocate netdev, including space for private structure */ + ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", + ether_setup); + if (!ifp->ndev) { + brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); + ret = -ENOMEM; + } + + if (ret == 0) { + memcpy(netdev_priv(ifp->ndev), &drvr_priv, + sizeof(drvr_priv)); + err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); + if (err != 0) { + brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", + err); + ret = -EOPNOTSUPP; + } else { + brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", + current->pid, ifp->ndev->name); + ifp->state = 0; + } + } + + if (ret < 0) { + if (ifp->ndev) + free_netdev(ifp->ndev); + + drvr_priv->iflist[ifp->idx] = NULL; + kfree(ifp); + } } else ifp->ndev = ndev; @@ -1004,7 +978,13 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) ifp->state = BRCMF_E_IF_DEL; ifp->idx = ifidx; - brcmf_op_if(ifp); + if (ifp->ndev != NULL) { + netif_stop_queue(ifp->ndev); + unregister_netdev(ifp->ndev); + free_netdev(ifp->ndev); + drvr_priv->iflist[ifidx] = NULL; + kfree(ifp); + } } struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) From 48a2c3799b7141c271a771d3249142a104faeefc Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:54 +0100 Subject: [PATCH 1355/1519] staging:iio:adc:ad7314 removal. Supported via hwmon. Driver ported over to hwmon where it fits much better. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/Kconfig | 7 - drivers/staging/iio/adc/Makefile | 1 - drivers/staging/iio/adc/ad7314.c | 281 ------------------------------- 3 files changed, 289 deletions(-) delete mode 100644 drivers/staging/iio/adc/ad7314.c diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 070efd329a1..2c1b7ded701 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -34,13 +34,6 @@ config AD7298 To compile this driver as a module, choose M here: the module will be called ad7298. -config AD7314 - tristate "Analog Devices AD7314 temperature sensor driver" - depends on SPI - help - Say yes here to build support for Analog Devices AD7314 - temperature sensors. - config AD7606 tristate "Analog Devices AD7606 ADC driver" depends on GPIOLIB diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 8adf096e6b8..93dc84bee26 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -32,7 +32,6 @@ obj-$(CONFIG_AD7298) += ad7298.o obj-$(CONFIG_AD7150) += ad7150.o obj-$(CONFIG_AD7152) += ad7152.o obj-$(CONFIG_AD7291) += ad7291.o -obj-$(CONFIG_AD7314) += ad7314.o obj-$(CONFIG_AD7746) += ad7746.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7793) += ad7793.o diff --git a/drivers/staging/iio/adc/ad7314.c b/drivers/staging/iio/adc/ad7314.c deleted file mode 100644 index 094a4ee971c..00000000000 --- a/drivers/staging/iio/adc/ad7314.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * AD7314 digital temperature sensor driver for AD7314, ADT7301 and ADT7302 - * - * Copyright 2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include - -#include "../iio.h" -#include "../sysfs.h" - -/* - * AD7314 power mode - */ -#define AD7314_PD 0x2000 - -/* - * AD7314 temperature masks - */ -#define AD7314_TEMP_SIGN 0x200 -#define AD7314_TEMP_MASK 0x7FE0 -#define AD7314_TEMP_OFFSET 5 -#define AD7314_TEMP_FLOAT_OFFSET 2 -#define AD7314_TEMP_FLOAT_MASK 0x3 - -/* - * ADT7301 and ADT7302 temperature masks - */ -#define ADT7301_TEMP_SIGN 0x2000 -#define ADT7301_TEMP_MASK 0x2FFF -#define ADT7301_TEMP_FLOAT_OFFSET 5 -#define ADT7301_TEMP_FLOAT_MASK 0x1F - -/* - * struct ad7314_chip_info - chip specifc information - */ - -struct ad7314_chip_info { - struct spi_device *spi_dev; - s64 last_timestamp; - u8 mode; -}; - -/* - * ad7314 register access by SPI - */ - -static int ad7314_spi_read(struct ad7314_chip_info *chip, u16 *data) -{ - struct spi_device *spi_dev = chip->spi_dev; - int ret = 0; - u16 value; - - ret = spi_read(spi_dev, (u8 *)&value, sizeof(value)); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI read error\n"); - return ret; - } - - *data = be16_to_cpu((u16)value); - - return ret; -} - -static int ad7314_spi_write(struct ad7314_chip_info *chip, u16 data) -{ - struct spi_device *spi_dev = chip->spi_dev; - int ret = 0; - u16 value = cpu_to_be16(data); - - ret = spi_write(spi_dev, (u8 *)&value, sizeof(value)); - if (ret < 0) - dev_err(&spi_dev->dev, "SPI write error\n"); - - return ret; -} - -static ssize_t ad7314_show_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7314_chip_info *chip = iio_priv(dev_info); - - if (chip->mode) - return sprintf(buf, "power-save\n"); - else - return sprintf(buf, "full\n"); -} - -static ssize_t ad7314_store_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7314_chip_info *chip = iio_priv(dev_info); - u16 mode = 0; - int ret; - - if (!strcmp(buf, "full")) - mode = AD7314_PD; - - ret = ad7314_spi_write(chip, mode); - if (ret) - return -EIO; - - chip->mode = mode; - - return len; -} - -static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, - ad7314_show_mode, - ad7314_store_mode, - 0); - -static ssize_t ad7314_show_available_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "full\npower-save\n"); -} - -static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7314_show_available_modes, NULL, 0); - -static ssize_t ad7314_show_temperature(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7314_chip_info *chip = iio_priv(dev_info); - u16 data; - char sign = ' '; - int ret; - - if (chip->mode) { - ret = ad7314_spi_write(chip, 0); - if (ret) - return -EIO; - } - - ret = ad7314_spi_read(chip, &data); - if (ret) - return -EIO; - - if (chip->mode) - ad7314_spi_write(chip, chip->mode); - - if (strcmp(dev_info->name, "ad7314")) { - data = (data & AD7314_TEMP_MASK) >> - AD7314_TEMP_OFFSET; - if (data & AD7314_TEMP_SIGN) { - data = (AD7314_TEMP_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.2d\n", sign, - data >> AD7314_TEMP_FLOAT_OFFSET, - (data & AD7314_TEMP_FLOAT_MASK) * 25); - } else { - data &= ADT7301_TEMP_MASK; - if (data & ADT7301_TEMP_SIGN) { - data = (ADT7301_TEMP_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.5d\n", sign, - data >> ADT7301_TEMP_FLOAT_OFFSET, - (data & ADT7301_TEMP_FLOAT_MASK) * 3125); - } -} - -static IIO_DEVICE_ATTR(temperature, S_IRUGO, ad7314_show_temperature, NULL, 0); - -static struct attribute *ad7314_attributes[] = { - &iio_dev_attr_available_modes.dev_attr.attr, - &iio_dev_attr_mode.dev_attr.attr, - &iio_dev_attr_temperature.dev_attr.attr, - NULL, -}; - -static const struct attribute_group ad7314_attribute_group = { - .attrs = ad7314_attributes, -}; - -static const struct iio_info ad7314_info = { - .attrs = &ad7314_attribute_group, - .driver_module = THIS_MODULE, -}; -/* - * device probe and remove - */ - -static int __devinit ad7314_probe(struct spi_device *spi_dev) -{ - struct ad7314_chip_info *chip; - struct iio_dev *indio_dev; - int ret = 0; - - indio_dev = iio_allocate_device(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - chip = iio_priv(indio_dev); - /* this is only used for device removal purposes */ - dev_set_drvdata(&spi_dev->dev, chip); - - chip->spi_dev = spi_dev; - - indio_dev->name = spi_get_device_id(spi_dev)->name; - indio_dev->dev.parent = &spi_dev->dev; - indio_dev->info = &ad7314_info; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - - dev_info(&spi_dev->dev, "%s temperature sensor registered.\n", - indio_dev->name); - - return 0; -error_free_dev: - iio_free_device(indio_dev); -error_ret: - return ret; -} - -static int __devexit ad7314_remove(struct spi_device *spi_dev) -{ - struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); - - dev_set_drvdata(&spi_dev->dev, NULL); - iio_device_unregister(indio_dev); - - return 0; -} - -static const struct spi_device_id ad7314_id[] = { - { "adt7301", 0 }, - { "adt7302", 0 }, - { "ad7314", 0 }, - {} -}; - -static struct spi_driver ad7314_driver = { - .driver = { - .name = "ad7314", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = ad7314_probe, - .remove = __devexit_p(ad7314_remove), - .id_table = ad7314_id, -}; - -static __init int ad7314_init(void) -{ - return spi_register_driver(&ad7314_driver); -} - -static __exit void ad7314_exit(void) -{ - spi_unregister_driver(&ad7314_driver); -} - -MODULE_AUTHOR("Sonic Zhang "); -MODULE_DESCRIPTION("Analog Devices AD7314, ADT7301 and ADT7302 digital" - " temperature sensor driver"); -MODULE_LICENSE("GPL v2"); - -module_init(ad7314_init); -module_exit(ad7314_exit); From 4a70513074091e814fd5444c75f572691b7ba588 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:55 +0100 Subject: [PATCH 1356/1519] staging:iio:lisght:isl29018 use IIO_PROCESSED enum value. No functional change, just a trivial tidy up so all drivers do the same thing. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/isl29018.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 3e9a06c2050..6958aa5809a 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -420,7 +420,7 @@ static const struct iio_chan_spec isl29018_channels[] = { .type = IIO_LIGHT, .indexed = 1, .channel = 0, - .processed_val = 1, + .processed_val = IIO_PROCESSED, .info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), }, { .type = IIO_INTENSITY, From 72a86ccd3a4b60dacddc97095e13f32ee6117314 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:56 +0100 Subject: [PATCH 1357/1519] staging:iio:resolver:ad2s90 fix registration of null pointer When the new allocation code was introduced a stray pointer to iio_dev structure was left in the chip state structure. This was never set but was then registered with the core. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s90.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 3739bd24951..161442ee7d3 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -23,7 +23,6 @@ struct ad2s90_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; u8 rx[2] ____cacheline_aligned; }; @@ -87,7 +86,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi) indio_dev->info = &ad2s90_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(st->idev); + ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; @@ -99,7 +98,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi) return 0; error_free_dev: - iio_free_device(st->idev); + iio_free_device(indio_dev); error_ret: return ret; } From 19147f5bc636a44eade7e9af5a27cd000e5cd070 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:57 +0100 Subject: [PATCH 1358/1519] staging:iio:resolver:ad2s90 ensure name is passed to iio_core. Scraps the pointless name define and adds an id table. It's not technically required in drivers with only one supported part but it does make the probe code more consistent. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s90.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 161442ee7d3..4b936d61bc0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -19,8 +19,6 @@ #include "../iio.h" #include "../sysfs.h" -#define DRV_NAME "ad2s90" - struct ad2s90_state { struct mutex lock; struct spi_device *sdev; @@ -85,6 +83,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s90_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->name = spi_get_device_id(spi)->name; ret = iio_device_register(indio_dev); if (ret) @@ -110,13 +109,19 @@ static int __devexit ad2s90_remove(struct spi_device *spi) return 0; } +static const struct spi_device_id ad2s90_id[] = { + { "ad2s90" }, + {} +}; + static struct spi_driver ad2s90_driver = { .driver = { - .name = DRV_NAME, + .name = "ad2s90", .owner = THIS_MODULE, }, .probe = ad2s90_probe, .remove = __devexit_p(ad2s90_remove), + .id_table = ad2s90_id, }; static __init int ad2s90_spi_init(void) From 199d847a2d89e5ccfca991092c1fb1cae3743f58 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:58 +0100 Subject: [PATCH 1359/1519] staging:iio:resolver:ad2s90 chan spec conversion Trivial conversion. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s90.c | 41 ++++++++++++--------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 4b936d61bc0..8b3d34dbe23 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -25,45 +25,38 @@ struct ad2s90_state { u8 rx[2] ____cacheline_aligned; }; -static ssize_t ad2s90_show_angular(struct device *dev, - struct device_attribute *attr, char *buf) +static int ad2s90_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) { int ret; - ssize_t len = 0; - u16 val; - struct ad2s90_state *st = iio_priv(dev_get_drvdata(dev)); + struct ad2s90_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); ret = spi_read(st->sdev, st->rx, 2); if (ret) goto error_ret; - val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - len = sprintf(buf, "%d\n", val); + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + error_ret: mutex_unlock(&st->lock); - return ret ? ret : len; + return IIO_VAL_INT; } -#define IIO_DEV_ATTR_SIMPLE_RESOLVER(_show) \ - IIO_DEVICE_ATTR(angular, S_IRUGO, _show, NULL, 0) - -static IIO_DEV_ATTR_SIMPLE_RESOLVER(ad2s90_show_angular); - -static struct attribute *ad2s90_attributes[] = { - &iio_dev_attr_angular.dev_attr.attr, - NULL, -}; - -static const struct attribute_group ad2s90_attribute_group = { - .attrs = ad2s90_attributes, -}; - static const struct iio_info ad2s90_info = { - .attrs = &ad2s90_attribute_group, + .read_raw = &ad2s90_read_raw, .driver_module = THIS_MODULE, }; +static const struct iio_chan_spec ad2s90_chan = { + .type = IIO_ANGL, + .indexed = 1, + .channel = 0, +}; + static int __devinit ad2s90_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -83,6 +76,8 @@ static int __devinit ad2s90_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s90_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = &ad2s90_chan; + indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; ret = iio_device_register(indio_dev); From 41ea040c7b6daf05d4884097b0168e7b74c6c0d0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:27:59 +0100 Subject: [PATCH 1360/1519] staging:iio: rename gyro channels to anglvel Ensure naming reflects what is measured, not how it is done. Resolvers can measure the same thing for starters. IIO_GYRO->IIO_ANGL_VEL to ensure consistent naming. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/adis16060_core.c | 2 +- drivers/staging/iio/gyro/adis16080_core.c | 2 +- drivers/staging/iio/gyro/adis16130_core.c | 2 +- drivers/staging/iio/gyro/adis16260_core.c | 8 ++++---- drivers/staging/iio/gyro/adxrs450_core.c | 4 ++-- drivers/staging/iio/iio.h | 2 +- drivers/staging/iio/imu/adis16400_core.c | 22 +++++++++++----------- drivers/staging/iio/industrialio-core.c | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index f8129916071..abb6f05ce3d 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -117,7 +117,7 @@ static const struct iio_info adis16060_info = { static const struct iio_chan_spec adis16060_channels[] = { { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .address = ADIS16060_GYRO, diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index a2ee9beda80..07b013a1159 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -108,7 +108,7 @@ static int adis16080_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec adis16080_channels[] = { { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .address = ADIS16080_DIN_GYRO, diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index a9f270e5eb9..87670c01f88 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -97,7 +97,7 @@ static int adis16130_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec adis16130_channels[] = { { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .address = ADIS16130_RATEDATA, diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index efbee279384..dc440d15f86 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -390,7 +390,7 @@ enum adis16260_channel { }; #define ADIS16260_GYRO_CHANNEL_SET(axis, mod) \ struct iio_chan_spec adis16260_channels_##axis[] = { \ - IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, mod, \ + IIO_CHAN(IIO_ANGL_VEL, 1, 0, 0, NULL, 0, mod, \ (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | \ (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | \ (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ @@ -468,7 +468,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case (1 << IIO_CHAN_INFO_SCALE_SHARED): switch (chan->type) { - case IIO_GYRO: + case IIO_ANGL_VEL: *val = 0; if (spi_get_device_id(st->us)->driver_data) *val2 = 320; @@ -495,7 +495,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): switch (chan->type) { - case IIO_GYRO: + case IIO_ANGL_VEL: bits = 12; break; default: @@ -515,7 +515,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): switch (chan->type) { - case IIO_GYRO: + case IIO_ANGL_VEL: bits = 12; break; default: diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 670b615839f..1fda3db1739 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -268,7 +268,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, switch (mask) { case 0: switch (chan->type) { - case IIO_GYRO: + case IIO_ANGL_VEL: ret = adxrs450_spi_sensor_data(indio_dev, &t); if (ret) break; @@ -305,7 +305,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec adxrs450_channels[] = { { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 2a6c6731b3c..e7c286581a3 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -31,7 +31,7 @@ enum iio_chan_type { IIO_CURRENT, IIO_POWER, IIO_ACCEL, - IIO_GYRO, + IIO_ANGL_VEL, IIO_MAGN, IIO_LIGHT, IIO_INTENSITY, diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 07d5a61eaa7..365f99ae86e 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -507,7 +507,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, case (1 << IIO_CHAN_INFO_SCALE_SHARED): case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): switch (chan->type) { - case IIO_GYRO: + case IIO_ANGL_VEL: *val = 0; *val2 = st->variant->gyro_scale_micro; return IIO_VAL_INT_PLUS_MICRO; @@ -565,7 +565,7 @@ static struct iio_chan_spec adis16400_channels[] = { .scan_index = ADIS16400_SCAN_SUPPLY, .scan_type = IIO_ST('u', 14, 16, 0) }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_X, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -574,7 +574,7 @@ static struct iio_chan_spec adis16400_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_X, .scan_type = IIO_ST('s', 14, 16, 0) }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Y, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -583,7 +583,7 @@ static struct iio_chan_spec adis16400_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_Y, .scan_type = IIO_ST('s', 14, 16, 0), }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -674,7 +674,7 @@ static struct iio_chan_spec adis16350_channels[] = { .scan_index = ADIS16400_SCAN_SUPPLY, .scan_type = IIO_ST('u', 12, 16, 0) }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_X, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -683,7 +683,7 @@ static struct iio_chan_spec adis16350_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_X, .scan_type = IIO_ST('s', 14, 16, 0) }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Y, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -692,7 +692,7 @@ static struct iio_chan_spec adis16350_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_Y, .scan_type = IIO_ST('s', 14, 16, 0), }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -780,7 +780,7 @@ static struct iio_chan_spec adis16300_channels[] = { .scan_index = ADIS16400_SCAN_SUPPLY, .scan_type = IIO_ST('u', 12, 16, 0) }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_X, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -854,7 +854,7 @@ static struct iio_chan_spec adis16300_channels[] = { static const struct iio_chan_spec adis16334_channels[] = { { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_X, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -863,7 +863,7 @@ static const struct iio_chan_spec adis16334_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_X, .scan_type = IIO_ST('s', 14, 16, 0), }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Y, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | @@ -872,7 +872,7 @@ static const struct iio_chan_spec adis16334_channels[] = { .scan_index = ADIS16400_SCAN_GYRO_Y, .scan_type = IIO_ST('s', 14, 16, 0), }, { - .type = IIO_GYRO, + .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, .info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) | diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 647a4052a8c..5a6dde85ec8 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -54,7 +54,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CURRENT] = "current", [IIO_POWER] = "power", [IIO_ACCEL] = "accel", - [IIO_GYRO] = "gyro", + [IIO_ANGL_VEL] = "anglvel", [IIO_MAGN] = "magn", [IIO_LIGHT] = "illuminance", [IIO_INTENSITY] = "intensity", From d4c926f2ba57718c15378933f975c8c3cbc264ae Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:00 +0100 Subject: [PATCH 1361/1519] staging:iio:Documentation gyro -> anglvel updates in attribute names Follows directly from change made in previous patch. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/sysfs-bus-iio | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio index fb6c3812016..0d6823d19b6 100644 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio +++ b/drivers/staging/iio/Documentation/sysfs-bus-iio @@ -141,9 +141,9 @@ Description: Has all of the equivalent parameters as per voltageY. Units after application of scale and offset are m/s^2. -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_x_raw -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_y_raw -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -221,7 +221,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_scale +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_scale @@ -240,9 +240,9 @@ Description: What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibbias What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibbias -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibbias -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibbias -What: /sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibbias +What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibbias KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -255,9 +255,9 @@ What /sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale What /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale What /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale What /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale -What /sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibscale -What /sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibscale -What /sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibscale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -338,12 +338,12 @@ What: /sys/.../iio:deviceX/events/in_accel_y_thresh_rising_en What: /sys/.../iio:deviceX/events/in_accel_y_thresh_falling_en What: /sys/.../iio:deviceX/events/in_accel_z_thresh_rising_en What: /sys/.../iio:deviceX/events/in_accel_z_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_x_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_x_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_y_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_y_thresh_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_z_thresh_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_z_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_x_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_x_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_y_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_y_thresh_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_z_thresh_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_z_thresh_falling_en What: /sys/.../iio:deviceX/events/in_magn_x_thresh_rising_en What: /sys/.../iio:deviceX/events/in_magn_x_thresh_falling_en What: /sys/.../iio:deviceX/events/in_magn_y_thresh_rising_en @@ -383,12 +383,12 @@ What: /sys/.../iio:deviceX/events/in_accel_y_roc_rising_en What: /sys/.../iio:deviceX/events/in_accel_y_roc_falling_en What: /sys/.../iio:deviceX/events/in_accel_z_roc_rising_en What: /sys/.../iio:deviceX/events/in_accel_z_roc_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_x_roc_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_x_roc_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_y_roc_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_y_roc_falling_en -What: /sys/.../iio:deviceX/events/in_gyro_z_roc_rising_en -What: /sys/.../iio:deviceX/events/in_gyro_z_roc_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_x_roc_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_x_roc_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_y_roc_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_y_roc_falling_en +What: /sys/.../iio:deviceX/events/in_anglvel_z_roc_rising_en +What: /sys/.../iio:deviceX/events/in_anglvel_z_roc_falling_en What: /sys/.../iio:deviceX/events/in_magn_x_roc_rising_en What: /sys/.../iio:deviceX/events/in_magn_x_roc_falling_en What: /sys/.../iio:deviceX/events/in_magn_y_roc_rising_en @@ -429,12 +429,12 @@ What: /sys/.../events/in_accel_y_raw_thresh_rising_value What: /sys/.../events/in_accel_y_raw_thresh_falling_value What: /sys/.../events/in_accel_z_raw_thresh_rising_value What: /sys/.../events/in_accel_z_raw_thresh_falling_value -What: /sys/.../events/in_gyro_x_raw_thresh_rising_value -What: /sys/.../events/in_gyro_x_raw_thresh_falling_value -What: /sys/.../events/in_gyro_y_raw_thresh_rising_value -What: /sys/.../events/in_gyro_y_raw_thresh_falling_value -What: /sys/.../events/in_gyro_z_raw_thresh_rising_value -What: /sys/.../events/in_gyro_z_raw_thresh_falling_value +What: /sys/.../events/in_anglvel_x_raw_thresh_rising_value +What: /sys/.../events/in_anglvel_x_raw_thresh_falling_value +What: /sys/.../events/in_anglvel_y_raw_thresh_rising_value +What: /sys/.../events/in_anglvel_y_raw_thresh_falling_value +What: /sys/.../events/in_anglvel_z_raw_thresh_rising_value +What: /sys/.../events/in_anglvel_z_raw_thresh_falling_value What: /sys/.../events/in_magn_x_raw_thresh_rising_value What: /sys/.../events/in_magn_x_raw_thresh_falling_value What: /sys/.../events/in_magn_y_raw_thresh_rising_value @@ -466,12 +466,12 @@ What: /sys/.../events/in_accel_y_raw_roc_rising_value What: /sys/.../events/in_accel_y_raw_roc_falling_value What: /sys/.../events/in_accel_z_raw_roc_rising_value What: /sys/.../events/in_accel_z_raw_roc_falling_value -What: /sys/.../events/in_gyro_x_raw_roc_rising_value -What: /sys/.../events/in_gyro_x_raw_roc_falling_value -What: /sys/.../events/in_gyro_y_raw_roc_rising_value -What: /sys/.../events/in_gyro_y_raw_roc_falling_value -What: /sys/.../events/in_gyro_z_raw_roc_rising_value -What: /sys/.../events/in_gyro_z_raw_roc_falling_value +What: /sys/.../events/in_anglvel_x_raw_roc_rising_value +What: /sys/.../events/in_anglvel_x_raw_roc_falling_value +What: /sys/.../events/in_anglvel_y_raw_roc_rising_value +What: /sys/.../events/in_anglvel_y_raw_roc_falling_value +What: /sys/.../events/in_anglvel_z_raw_roc_rising_value +What: /sys/.../events/in_anglvel_z_raw_roc_falling_value What: /sys/.../events/in_magn_x_raw_roc_rising_value What: /sys/.../events/in_magn_x_raw_roc_falling_value What: /sys/.../events/in_magn_y_raw_roc_rising_value @@ -509,18 +509,18 @@ What: /sys/.../events/in_accel_z_thresh_rising_period What: /sys/.../events/in_accel_z_thresh_falling_period What: /sys/.../events/in_accel_z_roc_rising_period What: /sys/.../events/in_accel_z_roc_falling_period -What: /sys/.../events/in_gyro_x_thresh_rising_period -What: /sys/.../events/in_gyro_x_thresh_falling_period -What: /sys/.../events/in_gyro_x_roc_rising_period -What: /sys/.../events/in_gyro_x_roc_falling_period -What: /sys/.../events/in_gyro_y_thresh_rising_period -What: /sys/.../events/in_gyro_y_thresh_falling_period -What: /sys/.../events/in_gyro_y_roc_rising_period -What: /sys/.../events/in_gyro_y_roc_falling_period -What: /sys/.../events/in_gyro_z_thresh_rising_period -What: /sys/.../events/in_gyro_z_thresh_falling_period -What: /sys/.../events/in_gyro_z_roc_rising_period -What: /sys/.../events/in_gyro_z_roc_falling_period +What: /sys/.../events/in_anglvel_x_thresh_rising_period +What: /sys/.../events/in_anglvel_x_thresh_falling_period +What: /sys/.../events/in_anglvel_x_roc_rising_period +What: /sys/.../events/in_anglvel_x_roc_falling_period +What: /sys/.../events/in_anglvel_y_thresh_rising_period +What: /sys/.../events/in_anglvel_y_thresh_falling_period +What: /sys/.../events/in_anglvel_y_roc_rising_period +What: /sys/.../events/in_anglvel_y_roc_falling_period +What: /sys/.../events/in_anglvel_z_thresh_rising_period +What: /sys/.../events/in_anglvel_z_thresh_falling_period +What: /sys/.../events/in_anglvel_z_roc_rising_period +What: /sys/.../events/in_anglvel_z_roc_falling_period What: /sys/.../events/in_magn_x_thresh_rising_period What: /sys/.../events/in_magn_x_thresh_falling_period What: /sys/.../events/in_magn_x_roc_rising_period @@ -622,9 +622,9 @@ Description: What: /sys/.../buffer/scan_elements/in_accel_x_en What: /sys/.../buffer/scan_elements/in_accel_y_en What: /sys/.../buffer/scan_elements/in_accel_z_en -What: /sys/.../buffer/scan_elements/in_gyro_x_en -What: /sys/.../buffer/scan_elements/in_gyro_y_en -What: /sys/.../buffer/scan_elements/in_gyro_z_en +What: /sys/.../buffer/scan_elements/in_anglvel_x_en +What: /sys/.../buffer/scan_elements/in_anglvel_y_en +What: /sys/.../buffer/scan_elements/in_anglvel_z_en What: /sys/.../buffer/scan_elements/in_magn_x_en What: /sys/.../buffer/scan_elements/in_magn_y_en What: /sys/.../buffer/scan_elements/in_magn_z_en @@ -640,7 +640,7 @@ Description: Scan element control for triggered data capture. What: /sys/.../buffer/scan_elements/in_accel_type -What: /sys/.../buffer/scan_elements/in_gyro_type +What: /sys/.../buffer/scan_elements/in_anglvel_type What: /sys/.../buffer/scan_elements/in_magn_type What: /sys/.../buffer/scan_elements/in_incli_type What: /sys/.../buffer/scan_elements/in_voltageY_type @@ -682,9 +682,9 @@ What: /sys/.../buffer/scan_elements/in_voltageY_supply_index What: /sys/.../buffer/scan_elements/in_accel_x_index What: /sys/.../buffer/scan_elements/in_accel_y_index What: /sys/.../buffer/scan_elements/in_accel_z_index -What: /sys/.../buffer/scan_elements/in_gyro_x_index -What: /sys/.../buffer/scan_elements/in_gyro_y_index -What: /sys/.../buffer/scan_elements/in_gyro_z_index +What: /sys/.../buffer/scan_elements/in_anglvel_x_index +What: /sys/.../buffer/scan_elements/in_anglvel_y_index +What: /sys/.../buffer/scan_elements/in_anglvel_z_index What: /sys/.../buffer/scan_elements/in_magn_x_index What: /sys/.../buffer/scan_elements/in_magn_y_index What: /sys/.../buffer/scan_elements/in_magn_z_index @@ -702,7 +702,7 @@ Description: and the relevant _type attributes to establish the data storage format. -What: /sys/.../iio:deviceX/in_gyro_z_quadrature_correction_raw +What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: linux-iio@vger.kernel.org Description: From 9c5ed829424e05a469715abc87994e6dbf11ba70 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:01 +0100 Subject: [PATCH 1362/1519] staging:iio:resolver:ad2s120x chan spec conversion Straight forward conversion. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s120x.c | 74 ++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s120x.c index fdaf0a8fcf9..7dadcd0e32b 100644 --- a/drivers/staging/iio/resolver/ad2s120x.c +++ b/drivers/staging/iio/resolver/ad2s120x.c @@ -39,62 +39,60 @@ struct ad2s120x_state { u8 rx[2] ____cacheline_aligned; }; -static ssize_t ad2s120x_show_val(struct device *dev, - struct device_attribute *attr, char *buf) +static int ad2s1200_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) { int ret = 0; - ssize_t len = 0; - u16 pos; s16 vel; - u8 status; - struct ad2s120x_state *st = iio_priv(dev_get_drvdata(dev)); - struct iio_dev_attr *iattr = to_iio_dev_attr(attr); + struct ad2s120x_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); - gpio_set_value(st->sample, 0); /* delay (6 * AD2S120X_TSCLK + 20) nano seconds */ udelay(1); gpio_set_value(st->sample, 1); - gpio_set_value(st->rdvel, iattr->address); + gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); ret = spi_read(st->sdev, st->rx, 2); - if (ret < 0) - goto error_ret; - status = st->rx[1]; - if (iattr->address) - pos = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - else { - vel = (st->rx[0] & 0x80) ? 0xf000 : 0; - vel |= (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + + switch (chan->type) { + case IIO_ANGL: + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + break; + case IIO_ANGL_VEL: + vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + vel = (vel << 4) >> 4; + *val = vel; + default: + mutex_unlock(&st->lock); + return -EINVAL; } - len = sprintf(buf, "%d %c%c%c%c ", iattr->address ? pos : vel, - (status & 0x8) ? 'P' : 'V', - (status & 0x4) ? 'd' : '_', - (status & 0x2) ? 'l' : '_', - (status & 0x1) ? '1' : '0'); -error_ret: /* delay (2 * AD2S120X_TSCLK + 20) ns for sample pulse */ udelay(1); mutex_unlock(&st->lock); - - return ret ? ret : len; + return IIO_VAL_INT; } -static IIO_DEVICE_ATTR(pos, S_IRUGO, ad2s120x_show_val, NULL, 1); -static IIO_DEVICE_ATTR(vel, S_IRUGO, ad2s120x_show_val, NULL, 0); - -static struct attribute *ad2s120x_attributes[] = { - &iio_dev_attr_pos.dev_attr.attr, - &iio_dev_attr_vel.dev_attr.attr, - NULL, -}; - -static const struct attribute_group ad2s120x_attribute_group = { - .attrs = ad2s120x_attributes, +static const struct iio_chan_spec ad2s1200_channels[] = { + { + .type = IIO_ANGL, + .indexed = 1, + .channel = 0, + }, { + .type = IIO_ANGL_VEL, + .indexed = 1, + .channel = 0, + } }; static const struct iio_info ad2s120x_info = { - .attrs = &ad2s120x_attribute_group, + .read_raw = &ad2s1200_read_raw, .driver_module = THIS_MODULE, }; @@ -126,6 +124,8 @@ static int __devinit ad2s120x_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s120x_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ad2s1200_channels; + indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels); ret = iio_device_register(indio_dev); if (ret) From 10e4a52b6e471cea2e87e71f8708a8c8c6b75266 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:02 +0100 Subject: [PATCH 1363/1519] staging:iio:resolver rename ad2s120x ->ad2s1200 There are far too many possible part numbers that are not covered in here to have such a generic name. So move to naming after one of the supported parts. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/Kconfig | 4 +- drivers/staging/iio/resolver/Makefile | 2 +- .../iio/resolver/{ad2s120x.c => ad2s1200.c} | 59 +++++++++++-------- 3 files changed, 37 insertions(+), 28 deletions(-) rename drivers/staging/iio/resolver/{ad2s120x.c => ad2s1200.c} (71%) diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index 07c309bba57..90b3bbcd875 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -10,8 +10,8 @@ config AD2S90 Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s90, provides direct access via sysfs. -config AD2S120X - tristate "Analog Devices ad2s120x driver" +config AD2S1200 + tristate "Analog Devices ad2s1200/ad2s1205 driver" depends on SPI help Say yes here to build support for Analog Devices spi resolver diff --git a/drivers/staging/iio/resolver/Makefile b/drivers/staging/iio/resolver/Makefile index 0b84a89e6ca..14375e444eb 100644 --- a/drivers/staging/iio/resolver/Makefile +++ b/drivers/staging/iio/resolver/Makefile @@ -3,5 +3,5 @@ # obj-$(CONFIG_AD2S90) += ad2s90.o -obj-$(CONFIG_AD2S120X) += ad2s120x.o +obj-$(CONFIG_AD2S1200) += ad2s1200.o obj-$(CONFIG_AD2S1210) += ad2s1210.o diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s1200.c similarity index 71% rename from drivers/staging/iio/resolver/ad2s120x.c rename to drivers/staging/iio/resolver/ad2s1200.c index 7dadcd0e32b..26268bfccff 100644 --- a/drivers/staging/iio/resolver/ad2s120x.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -1,5 +1,6 @@ /* - * ad2s120x.c simple support for the ADI Resolver to Digital Converters: AD2S1200/1205 + * ad2s1200.c simple support for the ADI Resolver to Digital Converters: + * AD2S1200/1205 * * Copyright (c) 2010-2010 Analog Devices Inc. * @@ -21,17 +22,17 @@ #include "../iio.h" #include "../sysfs.h" -#define DRV_NAME "ad2s120x" +#define DRV_NAME "ad2s1200" /* input pin sample and rdvel is controlled by driver */ -#define AD2S120X_PN 2 +#define AD2S1200_PN 2 /* input clock on serial interface */ -#define AD2S120X_HZ 8192000 +#define AD2S1200_HZ 8192000 /* clock period in nano second */ -#define AD2S120X_TSCLK (1000000000/AD2S120X_HZ) +#define AD2S1200_TSCLK (1000000000/AD2S1200_HZ) -struct ad2s120x_state { +struct ad2s1200_state { struct mutex lock; struct spi_device *sdev; int sample; @@ -47,11 +48,11 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, { int ret = 0; s16 vel; - struct ad2s120x_state *st = iio_priv(indio_dev); + struct ad2s1200_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); gpio_set_value(st->sample, 0); - /* delay (6 * AD2S120X_TSCLK + 20) nano seconds */ + /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ udelay(1); gpio_set_value(st->sample, 1); gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); @@ -73,7 +74,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, mutex_unlock(&st->lock); return -EINVAL; } - /* delay (2 * AD2S120X_TSCLK + 20) ns for sample pulse */ + /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */ udelay(1); mutex_unlock(&st->lock); return IIO_VAL_INT; @@ -91,19 +92,19 @@ static const struct iio_chan_spec ad2s1200_channels[] = { } }; -static const struct iio_info ad2s120x_info = { +static const struct iio_info ad2s1200_info = { .read_raw = &ad2s1200_read_raw, .driver_module = THIS_MODULE, }; -static int __devinit ad2s120x_probe(struct spi_device *spi) +static int __devinit ad2s1200_probe(struct spi_device *spi) { - struct ad2s120x_state *st; + struct ad2s1200_state *st; struct iio_dev *indio_dev; int pn, ret = 0; unsigned short *pins = spi->dev.platform_data; - for (pn = 0; pn < AD2S120X_PN; pn++) + for (pn = 0; pn < AD2S1200_PN; pn++) if (gpio_request_one(pins[pn], GPIOF_DIR_OUT, DRV_NAME)) { pr_err("%s: request gpio pin %d failed\n", DRV_NAME, pins[pn]); @@ -122,16 +123,17 @@ static int __devinit ad2s120x_probe(struct spi_device *spi) st->rdvel = pins[1]; indio_dev->dev.parent = &spi->dev; - indio_dev->info = &ad2s120x_info; + indio_dev->info = &ad2s1200_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad2s1200_channels; indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels); + indio_dev->name = spi_get_device_id(spi)->name; ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - spi->max_speed_hz = AD2S120X_HZ; + spi->max_speed_hz = AD2S1200_HZ; spi->mode = SPI_MODE_3; spi_setup(spi); @@ -145,33 +147,40 @@ error_ret: return ret; } -static int __devexit ad2s120x_remove(struct spi_device *spi) +static int __devexit ad2s1200_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); return 0; } -static struct spi_driver ad2s120x_driver = { +static const struct spi_device_id ad2s1200_id[] = { + { "ad2s1200" }, + { "ad2s1205" }, + {} +}; + +static struct spi_driver ad2s1200_driver = { .driver = { .name = DRV_NAME, .owner = THIS_MODULE, }, - .probe = ad2s120x_probe, - .remove = __devexit_p(ad2s120x_remove), + .probe = ad2s1200_probe, + .remove = __devexit_p(ad2s1200_remove), + .id_table = ad2s1200_id, }; -static __init int ad2s120x_spi_init(void) +static __init int ad2s1200_spi_init(void) { - return spi_register_driver(&ad2s120x_driver); + return spi_register_driver(&ad2s1200_driver); } -module_init(ad2s120x_spi_init); +module_init(ad2s1200_spi_init); -static __exit void ad2s120x_spi_exit(void) +static __exit void ad2s1200_spi_exit(void) { - spi_unregister_driver(&ad2s120x_driver); + spi_unregister_driver(&ad2s1200_driver); } -module_exit(ad2s120x_spi_exit); +module_exit(ad2s1200_spi_exit); MODULE_AUTHOR("Graff Yang "); MODULE_DESCRIPTION("Analog Devices AD2S1200/1205 Resolver to Digital SPI driver"); From bf52f0591f85eaa339a4707a4636bb62cba7ffff Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:03 +0100 Subject: [PATCH 1364/1519] staging:iio:resolver:ad2s1210 ensure iio_dev->name is set This is needed to ensure the required name attribute is created. Using an id table is the route most consistent with other drivers. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s1210.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 5c9c409ec7c..9a88563a7fe 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -760,6 +760,7 @@ static int __devinit ad2s1210_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1210_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->name = spi_get_device_id(spi)->name; ret = iio_device_register(indio_dev); if (ret) @@ -791,6 +792,11 @@ static int __devexit ad2s1210_remove(struct spi_device *spi) return 0; } +static const struct spi_device_id ad2s1210_id[] = { + { "ad2s1210" }, + {} +}; + static struct spi_driver ad2s1210_driver = { .driver = { .name = DRV_NAME, @@ -798,6 +804,7 @@ static struct spi_driver ad2s1210_driver = { }, .probe = ad2s1210_probe, .remove = __devexit_p(ad2s1210_remove), + .id_table = ad2s1210_id, }; static __init int ad2s1210_spi_init(void) From 29148543c52146bbbb3f918c5312f6fb7eef21af Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:04 +0100 Subject: [PATCH 1365/1519] staging:iio:resolver:ad2s1210 minimal chan spec conversion. Just convert the raw reads in this patch. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s1210.c | 118 +++++++++++++----------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 9a88563a7fe..697db80df9c 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -514,71 +514,70 @@ error_ret: return ret < 0 ? ret : len; } -static ssize_t ad2s1210_show_pos(struct device *dev, - struct device_attribute *attr, - char *buf) +static int ad2s1210_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) { + struct ad2s1210_state *st = iio_priv(indio_dev); + bool negative; int ret = 0; - ssize_t len = 0; u16 pos; - struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev)); - - mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); - /* delay (6 * tck + 20) nano seconds */ - udelay(1); - - ad2s1210_set_mode(MOD_POS, st); - ret = spi_read(st->sdev, st->rx, 2); - if (ret) - goto error_ret; - pos = be16_to_cpup((u16 *)st->rx); - if (st->hysteresis) - pos >>= 16 - st->resolution; - len = sprintf(buf, "%d\n", pos); -error_ret: - gpio_set_value(st->pdata->sample, 1); - /* delay (2 * tck + 20) nano seconds */ - udelay(1); - mutex_unlock(&st->lock); - - return ret < 0 ? ret : len; -} - -static ssize_t ad2s1210_show_vel(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - unsigned short negative; - int ret = 0; - ssize_t len = 0; s16 vel; - struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev)); mutex_lock(&st->lock); gpio_set_value(st->pdata->sample, 0); /* delay (6 * tck + 20) nano seconds */ udelay(1); - ad2s1210_set_mode(MOD_VEL, st); - ret = spi_read(st->sdev, st->rx, 2); - if (ret) - goto error_ret; - negative = st->rx[0] & 0x80; - vel = be16_to_cpup((s16 *)st->rx); - vel >>= 16 - st->resolution; - if (vel & 0x8000) { - negative = (0xffff >> st->resolution) << st->resolution; - vel |= negative; + switch (chan->type) { + case IIO_ANGL: + ad2s1210_set_mode(MOD_POS, st); + break; + case IIO_ANGL_VEL: + ad2s1210_set_mode(MOD_VEL, st); + break; + default: + ret = -EINVAL; + break; } - len = sprintf(buf, "%d\n", vel); + if (ret < 0) + goto error_ret; + ret = spi_read(st->sdev, st->rx, 2); + if (ret < 0) + goto error_ret; + + switch (chan->type) { + case IIO_ANGL: + pos = be16_to_cpup((u16 *)st->rx); + if (st->hysteresis) + pos >>= 16 - st->resolution; + *val = pos; + ret = IIO_VAL_INT; + break; + case IIO_ANGL_VEL: + negative = st->rx[0] & 0x80; + vel = be16_to_cpup((s16 *)st->rx); + vel >>= 16 - st->resolution; + if (vel & 0x8000) { + negative = (0xffff >> st->resolution) << st->resolution; + vel |= negative; + } + *val = vel; + ret = IIO_VAL_INT; + break; + default: + mutex_unlock(&st->lock); + return -EINVAL; + } + error_ret: gpio_set_value(st->pdata->sample, 1); /* delay (2 * tck + 20) nano seconds */ udelay(1); mutex_unlock(&st->lock); - - return ret < 0 ? ret : len; + return ret; } static IIO_DEVICE_ATTR(raw_io, S_IRUGO | S_IWUSR, @@ -595,8 +594,7 @@ static IIO_DEVICE_ATTR(bits, S_IRUGO | S_IWUSR, ad2s1210_show_resolution, ad2s1210_store_resolution, 0); static IIO_DEVICE_ATTR(fault, S_IRUGO | S_IWUSR, ad2s1210_show_fault, ad2s1210_clear_fault, 0); -static IIO_DEVICE_ATTR(pos, S_IRUGO, ad2s1210_show_pos, NULL, 0); -static IIO_DEVICE_ATTR(vel, S_IRUGO, ad2s1210_show_vel, NULL, 0); + static IIO_DEVICE_ATTR(los_thrd, S_IRUGO | S_IWUSR, ad2s1210_show_reg, ad2s1210_store_reg, AD2S1210_REG_LOS_THRD); @@ -619,6 +617,19 @@ static IIO_DEVICE_ATTR(lot_low_thrd, S_IRUGO | S_IWUSR, ad2s1210_show_reg, ad2s1210_store_reg, AD2S1210_REG_LOT_LOW_THRD); + +static struct iio_chan_spec ad2s1210_channels[] = { + { + .type = IIO_ANGL, + .indexed = 1, + .channel = 0, + }, { + .type = IIO_ANGL_VEL, + .indexed = 1, + .channel = 0, + } +}; + static struct attribute *ad2s1210_attributes[] = { &iio_dev_attr_raw_io.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, @@ -627,8 +638,6 @@ static struct attribute *ad2s1210_attributes[] = { &iio_dev_attr_control.dev_attr.attr, &iio_dev_attr_bits.dev_attr.attr, &iio_dev_attr_fault.dev_attr.attr, - &iio_dev_attr_pos.dev_attr.attr, - &iio_dev_attr_vel.dev_attr.attr, &iio_dev_attr_los_thrd.dev_attr.attr, &iio_dev_attr_dos_ovr_thrd.dev_attr.attr, &iio_dev_attr_dos_mis_thrd.dev_attr.attr, @@ -681,6 +690,7 @@ error_ret: } static const struct iio_info ad2s1210_info = { + .read_raw = &ad2s1210_read_raw, .attrs = &ad2s1210_attribute_group, .driver_module = THIS_MODULE, }; @@ -760,6 +770,8 @@ static int __devinit ad2s1210_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1210_info; indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ad2s1210_channels; + indio_dev->num_channels = ARRAY_SIZE(ad2s1210_channels); indio_dev->name = spi_get_device_id(spi)->name; ret = iio_device_register(indio_dev); From f97beb535b14b07e89744c58d40d51646dceca75 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:05 +0100 Subject: [PATCH 1366/1519] staging:iio:resolver:ad2s1210 drop raw config register access This should never have been exposed to userspace Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s1210.c | 44 ------------------------- 1 file changed, 44 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 697db80df9c..4f248de156e 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -195,47 +195,6 @@ static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) return ad2s1210_config_write(st, 0x0); } - -/* return the OLD DATA since last spi bus write */ -static ssize_t ad2s1210_show_raw(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev)); - int ret = 0; - - mutex_lock(&st->lock); - if (st->old_data) { - ret = sprintf(buf, "0x%x\n", st->rx[0]); - st->old_data = false; - } - mutex_unlock(&st->lock); - - return ret; -} - -static ssize_t ad2s1210_store_raw(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev)); - unsigned long udata; - unsigned char data; - int ret; - - ret = strict_strtoul(buf, 16, &udata); - if (ret) - return -EINVAL; - - data = udata & 0xff; - mutex_lock(&st->lock); - ret = ad2s1210_config_write(st, data); - mutex_unlock(&st->lock); - - return ret < 0 ? ret : len; -} - static ssize_t ad2s1210_store_softreset(struct device *dev, struct device_attribute *attr, const char *buf, @@ -580,8 +539,6 @@ error_ret: return ret; } -static IIO_DEVICE_ATTR(raw_io, S_IRUGO | S_IWUSR, - ad2s1210_show_raw, ad2s1210_store_raw, 0); static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, ad2s1210_store_softreset, 0); static IIO_DEVICE_ATTR(fclkin, S_IRUGO | S_IWUSR, @@ -631,7 +588,6 @@ static struct iio_chan_spec ad2s1210_channels[] = { }; static struct attribute *ad2s1210_attributes[] = { - &iio_dev_attr_raw_io.dev_attr.attr, &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_fclkin.dev_attr.attr, &iio_dev_attr_fexcit.dev_attr.attr, From 93decf3661bf1c7c05bbc217d4e69222b557512a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 5 Oct 2011 15:28:06 +0100 Subject: [PATCH 1367/1519] staging:iio:resolver:ad2s1210 cleanup gpio handling. Basically make use of the gpio array functions. Technically the free doesn't need as much info as given here, but this keeps it clean and easy to follow. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/resolver/ad2s1210.c | 51 +++++++++---------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 4f248de156e..8a6fcb66977 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -653,45 +653,30 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - int ret; unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; + struct gpio ad2s1210_gpios[] = { + { st->pdata->sample, GPIOF_DIR_IN, "sample" }, + { st->pdata->a[0], flags, "a0" }, + { st->pdata->a[1], flags, "a1" }, + { st->pdata->res[0], flags, "res0" }, + { st->pdata->res[0], flags, "res1" }, + }; - ret = gpio_request_one(st->pdata->sample, GPIOF_DIR_IN, "sample"); - if (ret < 0) - goto error_ret; - ret = gpio_request_one(st->pdata->a[0], flags, "a0"); - if (ret < 0) - goto error_free_sample; - ret = gpio_request_one(st->pdata->a[1], flags, "a1"); - if (ret < 0) - goto error_free_a0; - ret = gpio_request_one(st->pdata->res[1], flags, "res0"); - if (ret < 0) - goto error_free_a1; - ret = gpio_request_one(st->pdata->res[1], flags, "res1"); - if (ret < 0) - goto error_free_res0; - - return 0; -error_free_res0: - gpio_free(st->pdata->res[0]); -error_free_a1: - gpio_free(st->pdata->a[1]); -error_free_a0: - gpio_free(st->pdata->a[0]); -error_free_sample: - gpio_free(st->pdata->sample); -error_ret: - return ret; + return gpio_request_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); } static void ad2s1210_free_gpios(struct ad2s1210_state *st) { - gpio_free(st->pdata->res[1]); - gpio_free(st->pdata->res[0]); - gpio_free(st->pdata->a[1]); - gpio_free(st->pdata->a[0]); - gpio_free(st->pdata->sample); + unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; + struct gpio ad2s1210_gpios[] = { + { st->pdata->sample, GPIOF_DIR_IN, "sample" }, + { st->pdata->a[0], flags, "a0" }, + { st->pdata->a[1], flags, "a1" }, + { st->pdata->res[0], flags, "res0" }, + { st->pdata->res[0], flags, "res1" }, + }; + + gpio_free_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); } static int __devinit ad2s1210_probe(struct spi_device *spi) From 76e5f8135d63eb784ef44438e46e82cf0329e179 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 4 Oct 2011 14:00:02 -0700 Subject: [PATCH 1368/1519] Staging: hv: util: Fix a bug in kvp implementation The host gurantees that there can be only one kvp transaction active against the guest. So, the transaction active state is needed only to protect against spurious user level calls. The current code had a race condition where the guest could prematurely return because the previous transaction state was not cleared - this state was being cleared after sending the response to the host and there was a window where the host could notify the guest of a new transaction before the transaction active state was properly set. Also deal with the case when the user mode component does not respond in a timely fashion correctly. I would like to thank Long Li for identifying the problem. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Diagnosed-by: Long Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_kvp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c index 9aa9ede0ee8..307aedc08a3 100644 --- a/drivers/staging/hv/hv_kvp.c +++ b/drivers/staging/hv/hv_kvp.c @@ -50,6 +50,8 @@ static struct { static int kvp_send_key(int index); +#define TIMEOUT_FIRED 1 + static void kvp_respond_to_host(char *key, char *value, int error); static void kvp_work_func(struct work_struct *dummy); static void kvp_register(void); @@ -58,7 +60,6 @@ static DECLARE_DELAYED_WORK(kvp_work, kvp_work_func); static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL }; static const char kvp_name[] = "kvp_kernel_module"; -static int timeout_fired; static u8 *recv_buffer; /* * Register the kernel component with the user-level daemon. @@ -90,8 +91,7 @@ kvp_work_func(struct work_struct *dummy) * If the timer fires, the user-mode component has not responded; * process the pending transaction. */ - kvp_respond_to_host("Unknown key", "Guest timed out", timeout_fired); - timeout_fired = 1; + kvp_respond_to_host("Unknown key", "Guest timed out", TIMEOUT_FIRED); } /* @@ -177,6 +177,8 @@ kvp_respond_to_host(char *key, char *value, int error) channel = kvp_transaction.recv_channel; req_id = kvp_transaction.recv_req_id; + kvp_transaction.active = false; + if (channel->onchannel_callback == NULL) /* * We have raced with util driver being unloaded; @@ -224,7 +226,6 @@ response_done: vmbus_sendpacket(channel, recv_buffer, buf_len, req_id, VM_PKT_DATA_INBAND, 0); - kvp_transaction.active = false; } /* @@ -250,10 +251,6 @@ void hv_kvp_onchannelcallback(void *context) struct icmsg_negotiate *negop = NULL; - if (kvp_transaction.active) - return; - - vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE, &recvlen, &requestid); if (recvlen > 0) { From e2bb65378385a10e21612845e33cd5936e0cbadb Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Sun, 9 Oct 2011 19:42:28 -0700 Subject: [PATCH 1369/1519] Staging: hv: util: Invoke cn_netlink_send() in a work context Invoke cn_netlink_send() in a work context as opposed being called in the context of channel callback. On entry into the channel callback code the channel inbound spin lock is held and deferring to a work context avoids having to invoke cn_netlink_send() while holding the inbound lock. As part of this adjustment, also increase the timeout value for waiting for the user level component of KVP. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_kvp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c index 307aedc08a3..1e9515cc609 100644 --- a/drivers/staging/hv/hv_kvp.c +++ b/drivers/staging/hv/hv_kvp.c @@ -44,11 +44,12 @@ static struct { bool active; /* transaction status - active or not */ int recv_len; /* number of bytes received. */ + int index; /* current index */ struct vmbus_channel *recv_channel; /* chn we got the request */ u64 recv_req_id; /* request ID. */ } kvp_transaction; -static int kvp_send_key(int index); +static void kvp_send_key(struct work_struct *dummy); #define TIMEOUT_FIRED 1 @@ -57,6 +58,7 @@ static void kvp_work_func(struct work_struct *dummy); static void kvp_register(void); static DECLARE_DELAYED_WORK(kvp_work, kvp_work_func); +static DECLARE_WORK(kvp_sendkey_work, kvp_send_key); static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL }; static const char kvp_name[] = "kvp_kernel_module"; @@ -121,10 +123,11 @@ kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) } } -static int -kvp_send_key(int index) +static void +kvp_send_key(struct work_struct *dummy) { struct cn_msg *msg; + int index = kvp_transaction.index; msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC); @@ -136,9 +139,8 @@ kvp_send_key(int index) msg->len = sizeof(struct hv_ku_msg); cn_netlink_send(msg, 0, GFP_ATOMIC); kfree(msg); - return 0; } - return 1; + return; } /* @@ -286,6 +288,7 @@ void hv_kvp_onchannelcallback(void *context) kvp_transaction.recv_channel = channel; kvp_transaction.recv_req_id = requestid; kvp_transaction.active = true; + kvp_transaction.index = kvp_data->index; /* * Get the information from the @@ -296,8 +299,8 @@ void hv_kvp_onchannelcallback(void *context) * Set a timeout to deal with * user-mode not responding. */ - kvp_send_key(kvp_data->index); - schedule_delayed_work(&kvp_work, 100); + schedule_work(&kvp_sendkey_work); + schedule_delayed_work(&kvp_work, 5*HZ); return; @@ -332,4 +335,5 @@ void hv_kvp_deinit(void) { cn_del_callback(&kvp_id); cancel_delayed_work_sync(&kvp_work); + cancel_work_sync(&kvp_sendkey_work); } From 92ae4ebdaa6d6d083a53421715e5cdc70ab5823e Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Mon, 10 Oct 2011 09:37:39 +0200 Subject: [PATCH 1370/1519] staging: hv: storvsc: ignore SET_WINDOW scsi command Some commands sent by smartd will offline the device. With this change applied, smartd sill not monitor the device anymore. Signed-off-by: Olaf Hering Acked-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 807c94d711c..e4127163260 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -1122,6 +1122,22 @@ static void storvsc_command_completion(struct hv_storvsc_request *request) kmem_cache_free(host_dev->request_pool, cmd_request); } +static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd) +{ + bool allowed = true; + u8 scsi_op = scmnd->cmnd[0]; + + switch (scsi_op) { + /* smartd sends this command, which will offline the device */ + case SET_WINDOW: + scmnd->result = DID_ERROR << 16; + allowed = false; + break; + default: + break; + } + return allowed; +} /* * storvsc_queuecommand - Initiate command processing @@ -1141,6 +1157,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, unsigned int sg_count = 0; struct vmscsi_request *vm_srb; + if (storvsc_check_scsi_cmd(scmnd) == false) { + done(scmnd); + return 0; + } /* If retrying, no need to prep the cmd */ if (scmnd->host_scribble) { From 715a4801e734ea9c8e528265ce3ff6aead85bce1 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 6 Oct 2011 10:10:56 -0700 Subject: [PATCH 1371/1519] Staging: hv: netvsc: Fix a dereferencing issue net_dev is being de-referenced without proper checking; fix it. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Reported-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/rndis_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index ef43f2e95f3..bafccb36004 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -368,11 +368,11 @@ int rndis_filter_receive(struct hv_device *dev, struct rndis_message *rndis_hdr; struct net_device *ndev; - ndev = net_dev->ndev; - if (!net_dev) return -EINVAL; + ndev = net_dev->ndev; + /* Make sure the rndis device state is initialized */ if (!net_dev->extension) { netdev_err(ndev, "got rndis message but no rndis device - " From 46a971913611a23478283931460a95be962ce329 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 4 Oct 2011 12:29:52 -0700 Subject: [PATCH 1372/1519] Staging: hv: move hyperv code out of staging directory After many years wandering the desert, it is finally time for the Microsoft HyperV code to move out of the staging directory. Or at least the core hyperv bus code, and the utility driver, the rest still have some review to get through by the various subsystem maintainers. Signed-off-by: Greg Kroah-Hartman Signed-off-by: K. Y. Srinivasan --- drivers/Kconfig | 2 ++ drivers/Makefile | 2 ++ drivers/hv/Kconfig | 14 ++++++++++ drivers/hv/Makefile | 7 +++++ drivers/{staging => }/hv/channel.c | 2 +- drivers/{staging => }/hv/channel_mgmt.c | 2 +- drivers/{staging => }/hv/connection.c | 2 +- drivers/{staging => }/hv/hv.c | 2 +- drivers/{staging => }/hv/hv_kvp.c | 2 +- drivers/{staging => }/hv/hv_kvp.h | 0 drivers/{staging => }/hv/hv_util.c | 2 +- drivers/{staging => }/hv/hyperv_vmbus.h | 3 +- drivers/{staging => }/hv/ring_buffer.c | 2 +- drivers/{staging => }/hv/vmbus_drv.c | 2 +- drivers/staging/hv/Kconfig | 28 ++----------------- drivers/staging/hv/Makefile | 7 +---- drivers/staging/hv/hv_mouse.c | 3 +- drivers/staging/hv/hyperv_net.h | 2 +- drivers/staging/hv/storvsc_drv.c | 2 +- .../staging/hv => include/linux}/hyperv.h | 0 .../hv/tools => tools/hv}/hv_kvp_daemon.c | 0 21 files changed, 41 insertions(+), 45 deletions(-) create mode 100644 drivers/hv/Kconfig create mode 100644 drivers/hv/Makefile rename drivers/{staging => }/hv/channel.c (99%) rename drivers/{staging => }/hv/channel_mgmt.c (99%) rename drivers/{staging => }/hv/connection.c (99%) rename drivers/{staging => }/hv/hv.c (99%) rename drivers/{staging => }/hv/hv_kvp.c (99%) rename drivers/{staging => }/hv/hv_kvp.h (100%) rename drivers/{staging => }/hv/hv_util.c (99%) rename drivers/{staging => }/hv/hyperv_vmbus.h (99%) rename drivers/{staging => }/hv/ring_buffer.c (99%) rename drivers/{staging => }/hv/vmbus_drv.c (99%) rename {drivers/staging/hv => include/linux}/hyperv.h (100%) rename {drivers/staging/hv/tools => tools/hv}/hv_kvp_daemon.c (100%) diff --git a/drivers/Kconfig b/drivers/Kconfig index 95b9e7eefad..ce3c35f4041 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -130,4 +130,6 @@ source "drivers/iommu/Kconfig" source "drivers/virt/Kconfig" +source "drivers/hv/Kconfig" + endmenu diff --git a/drivers/Makefile b/drivers/Makefile index 7fa433a7030..ef693cfb481 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -127,3 +127,5 @@ obj-$(CONFIG_IOMMU_SUPPORT) += iommu/ # Virtualization drivers obj-$(CONFIG_VIRT_DRIVERS) += virt/ +obj-$(CONFIG_HYPERV) += hv/ + diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig new file mode 100644 index 00000000000..9fa09ac000a --- /dev/null +++ b/drivers/hv/Kconfig @@ -0,0 +1,14 @@ +config HYPERV + tristate "Microsoft Hyper-V client drivers" + depends on X86 && ACPI && PCI + help + Select this option to run Linux as a Hyper-V client operating + system. + +config HYPERV_UTILS + tristate "Microsoft Hyper-V Utilities driver" + depends on HYPERV && CONNECTOR && NLS + help + Select this option to enable the Hyper-V Utilities. + + diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile new file mode 100644 index 00000000000..a23938b991c --- /dev/null +++ b/drivers/hv/Makefile @@ -0,0 +1,7 @@ +obj-$(CONFIG_HYPERV) += hv_vmbus.o +obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o + +hv_vmbus-y := vmbus_drv.o \ + hv.o connection.o channel.o \ + channel_mgmt.o ring_buffer.o +hv_utils-y := hv_util.o hv_kvp.o diff --git a/drivers/staging/hv/channel.c b/drivers/hv/channel.c similarity index 99% rename from drivers/staging/hv/channel.c rename to drivers/hv/channel.c index b6f3d38a6db..406537420ff 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/hv/channel.c @@ -26,8 +26,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" #define NUM_PAGES_SPANNED(addr, len) \ diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c similarity index 99% rename from drivers/staging/hv/channel_mgmt.c rename to drivers/hv/channel_mgmt.c index 9f007522a9d..41bf287baa1 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -28,8 +28,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" struct vmbus_channel_message_table_entry { diff --git a/drivers/staging/hv/connection.c b/drivers/hv/connection.c similarity index 99% rename from drivers/staging/hv/connection.c rename to drivers/hv/connection.c index 649b91bcd8c..5f438b65006 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/hv/connection.c @@ -29,8 +29,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" diff --git a/drivers/staging/hv/hv.c b/drivers/hv/hv.c similarity index 99% rename from drivers/staging/hv/hv.c rename to drivers/hv/hv.c index 06f1e158c27..931b7b03078 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/hv/hv.c @@ -25,8 +25,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" /* The one and only */ diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/hv/hv_kvp.c similarity index 99% rename from drivers/staging/hv/hv_kvp.c rename to drivers/hv/hv_kvp.c index 1e9515cc609..69c4c985dae 100644 --- a/drivers/staging/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -26,8 +26,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hv_kvp.h" diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/hv/hv_kvp.h similarity index 100% rename from drivers/staging/hv/hv_kvp.h rename to drivers/hv/hv_kvp.h diff --git a/drivers/staging/hv/hv_util.c b/drivers/hv/hv_util.c similarity index 99% rename from drivers/staging/hv/hv_util.c rename to drivers/hv/hv_util.c index faa66074cc2..e0e3a6d0244 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -26,8 +26,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hv_kvp.h" diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h similarity index 99% rename from drivers/staging/hv/hyperv_vmbus.h rename to drivers/hv/hyperv_vmbus.h index 3d2d836c3cc..8261cb64931 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -28,8 +28,7 @@ #include #include #include - -#include "hyperv.h" +#include /* * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/hv/ring_buffer.c similarity index 99% rename from drivers/staging/hv/ring_buffer.c rename to drivers/hv/ring_buffer.c index 70e2e66fec7..f594ed09d7e 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -25,8 +25,8 @@ #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c similarity index 99% rename from drivers/staging/hv/vmbus_drv.c rename to drivers/hv/vmbus_drv.c index d2562afcce4..b0d08f980de 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -32,8 +32,8 @@ #include #include #include +#include -#include "hyperv.h" #include "hyperv_vmbus.h" diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig index 815f8c2f7cd..072185ebe95 100644 --- a/drivers/staging/hv/Kconfig +++ b/drivers/staging/hv/Kconfig @@ -1,39 +1,17 @@ -config HYPERV - tristate "Microsoft Hyper-V client drivers" - depends on X86 && ACPI && PCI - default n - help - Select this option to run Linux as a Hyper-V client operating - system. - -if HYPERV - config HYPERV_STORAGE tristate "Microsoft Hyper-V virtual storage driver" - depends on SCSI - default HYPERV + depends on HYPERV && SCSI help Select this option to enable the Hyper-V virtual storage driver. config HYPERV_NET tristate "Microsoft Hyper-V virtual network driver" - depends on NET - default HYPERV + depends on HYPERV && NET help Select this option to enable the Hyper-V virtual network driver. -config HYPERV_UTILS - tristate "Microsoft Hyper-V Utilities driver" - depends on CONNECTOR && NLS - default HYPERV - help - Select this option to enable the Hyper-V Utilities. - config HYPERV_MOUSE tristate "Microsoft Hyper-V mouse driver" - depends on HID - default HYPERV + depends on HYPERV && HID help Select this option to enable the Hyper-V mouse driver. - -endif diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile index bd176b1f231..e071c12c8f6 100644 --- a/drivers/staging/hv/Makefile +++ b/drivers/staging/hv/Makefile @@ -1,12 +1,7 @@ -obj-$(CONFIG_HYPERV) += hv_vmbus.o hv_timesource.o +obj-$(CONFIG_HYPERV) += hv_timesource.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o -obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o obj-$(CONFIG_HYPERV_MOUSE) += hv_mouse.o -hv_vmbus-y := vmbus_drv.o \ - hv.o connection.o channel.o \ - channel_mgmt.o ring_buffer.o hv_storvsc-y := storvsc_drv.o hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o -hv_utils-y := hv_util.o hv_kvp.o diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index edbb4797db7..c354ade76ef 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -22,8 +22,7 @@ #include #include #include - -#include "hyperv.h" +#include struct hv_input_dev_info { diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h index 366dd2b32b1..ac1ec840512 100644 --- a/drivers/staging/hv/hyperv_net.h +++ b/drivers/staging/hv/hyperv_net.h @@ -26,7 +26,7 @@ #define _HYPERV_NET_H #include -#include "hyperv.h" +#include /* Fwd declaration */ struct hv_netvsc_packet; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e4127163260..af185abbaa7 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include #include -#include "hyperv.h" #define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE; diff --git a/drivers/staging/hv/hyperv.h b/include/linux/hyperv.h similarity index 100% rename from drivers/staging/hv/hyperv.h rename to include/linux/hyperv.h diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c similarity index 100% rename from drivers/staging/hv/tools/hv_kvp_daemon.c rename to tools/hv/hv_kvp_daemon.c From 407dd1644302ea78fa5d740e67a1c09677aa18a4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 08:36:44 -0600 Subject: [PATCH 1373/1519] Staging: hv: remove unneeded asm include file in hyperv.h No one outside of the hyperv core needs to include the asm/hyperv.h file, so don't put it in the "global" include/linux/hyperv.h file. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/connection.c | 2 +- drivers/hv/hv.c | 2 +- drivers/hv/vmbus_drv.c | 2 +- include/linux/hyperv.h | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 5f438b65006..650c9f0b664 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -30,7 +30,7 @@ #include #include #include - +#include #include "hyperv_vmbus.h" diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 931b7b03078..0fb100ed91a 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -26,7 +26,7 @@ #include #include #include - +#include #include "hyperv_vmbus.h" /* The one and only */ diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index b0d08f980de..bb9f20507d7 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -33,7 +33,7 @@ #include #include #include - +#include #include "hyperv_vmbus.h" diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index edaa9e2f58e..4c8414a8b07 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -35,9 +35,6 @@ #include -#include - - #define MAX_PAGE_BUFFER_COUNT 16 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ From da0e96315ca703ab6540cc7665549622f71c155f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 08:42:28 -0600 Subject: [PATCH 1374/1519] hv: rename prep_negotiate_resp() to vmbus_prep_negotiate_resp() It's a global symbol, so properly prefix it and use the proper EXPORT value as well. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/channel_mgmt.c | 9 ++++----- drivers/hv/hv_kvp.c | 2 +- drivers/hv/hv_util.c | 6 +++--- include/linux/hyperv.h | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 41bf287baa1..a2fc487d142 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -114,7 +114,7 @@ static const uuid_le /** - * prep_negotiate_resp() - Create default response for Hyper-V Negotiate message + * vmbus_prep_negotiate_resp() - Create default response for Hyper-V Negotiate message * @icmsghdrp: Pointer to msg header structure * @icmsg_negotiate: Pointer to negotiate message structure * @buf: Raw buffer channel data @@ -128,9 +128,8 @@ static const uuid_le * * Mainly used by Hyper-V drivers. */ -void prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, - struct icmsg_negotiate *negop, - u8 *buf) +void vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, + struct icmsg_negotiate *negop, u8 *buf) { if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { icmsghdrp->icmsgsize = 0x10; @@ -156,7 +155,7 @@ void prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, negop->icmsg_vercnt = 1; } } -EXPORT_SYMBOL(prep_negotiate_resp); +EXPORT_SYMBOL_GPL(vmbus_prep_negotiate_resp); /* * alloc_channel - Allocate and initialize a vmbus channel object diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index 69c4c985dae..89f52440fcf 100644 --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -260,7 +260,7 @@ void hv_kvp_onchannelcallback(void *context) sizeof(struct vmbuspipe_hdr)]; if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { - prep_negotiate_resp(icmsghdrp, negop, recv_buffer); + vmbus_prep_negotiate_resp(icmsghdrp, negop, recv_buffer); } else { kvp_msg = (struct hv_kvp_msg *)&recv_buffer[ sizeof(struct vmbuspipe_hdr) + diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index e0e3a6d0244..55d58f21e6d 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -73,7 +73,7 @@ static void shutdown_onchannelcallback(void *context) sizeof(struct vmbuspipe_hdr)]; if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { - prep_negotiate_resp(icmsghdrp, negop, shut_txf_buf); + vmbus_prep_negotiate_resp(icmsghdrp, negop, shut_txf_buf); } else { shutdown_msg = (struct shutdown_msg_data *)&shut_txf_buf[ @@ -198,7 +198,7 @@ static void timesync_onchannelcallback(void *context) sizeof(struct vmbuspipe_hdr)]; if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { - prep_negotiate_resp(icmsghdrp, NULL, time_txf_buf); + vmbus_prep_negotiate_resp(icmsghdrp, NULL, time_txf_buf); } else { timedatap = (struct ictimesync_data *)&time_txf_buf[ sizeof(struct vmbuspipe_hdr) + @@ -237,7 +237,7 @@ static void heartbeat_onchannelcallback(void *context) sizeof(struct vmbuspipe_hdr)]; if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { - prep_negotiate_resp(icmsghdrp, NULL, hbeat_txf_buf); + vmbus_prep_negotiate_resp(icmsghdrp, NULL, hbeat_txf_buf); } else { heartbeat_msg = (struct heartbeat_msg_data *)&hbeat_txf_buf[ diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 4c8414a8b07..98a57a51acf 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -960,7 +960,7 @@ struct hyperv_service_callback { void (*callback) (void *context); }; -extern void prep_negotiate_resp(struct icmsg_hdr *, - struct icmsg_negotiate *, u8 *); +extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, + struct icmsg_negotiate *, u8 *); #endif /* _HYPERV_H */ From a832a1eba94096513bc42c96f33957cc46c5f2bf Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 08:47:32 -0600 Subject: [PATCH 1375/1519] hv: remove a bunch of unused debug macros from hyperv.h These aren't used by anyone anymore, so remove them before someone tries to use them again. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- include/linux/hyperv.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 98a57a51acf..2229073874b 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -721,11 +721,8 @@ extern void vmbus_ontimer(unsigned long data); BLKVSC_DRV) /* Logging Level */ -#define ERROR_LVL 3 #define WARNING_LVL 4 #define INFO_LVL 6 -#define DEBUG_LVL 7 -#define DEBUG_LVL_ENTEREXIT 8 #define DEBUG_RING_LVL 9 extern unsigned int vmbus_loglevel; @@ -736,33 +733,12 @@ extern unsigned int vmbus_loglevel; printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ } while (0) -#define DPRINT_DBG(mod, fmt, args...) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (DEBUG_LVL <= LOWORD(vmbus_loglevel))) \ - printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ - } while (0) - -#define DPRINT_INFO(mod, fmt, args...) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (INFO_LVL <= LOWORD(vmbus_loglevel))) \ - printk(KERN_INFO #mod": " fmt "\n", ## args);\ - } while (0) - #define DPRINT_WARN(mod, fmt, args...) do {\ if ((mod & (HIWORD(vmbus_loglevel))) && \ (WARNING_LVL <= LOWORD(vmbus_loglevel))) \ printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\ } while (0) -#define DPRINT_ERR(mod, fmt, args...) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (ERROR_LVL <= LOWORD(vmbus_loglevel))) \ - printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \ - __func__, ## args);\ - } while (0) - - - struct hv_driver; struct hv_device; From d181daa06dd72fa88652b1d8bf723570a9fc55ea Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:20:31 -0600 Subject: [PATCH 1376/1519] Staging: hv: storvsc: remove last usage of DPRINT_WARN Used the correct dev_warn() call instead. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 16 ++++++++-------- include/linux/hyperv.h | 6 ------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index af185abbaa7..1f9d23e48b2 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -510,20 +510,20 @@ static void storvsc_on_io_completion(struct hv_device *device, if (vstor_packet->vm_srb.scsi_status != 0 || vstor_packet->vm_srb.srb_status != 1){ - DPRINT_WARN(STORVSC, - "cmd 0x%x scsi status 0x%x srb status 0x%x\n", - stor_pkt->vm_srb.cdb[0], - vstor_packet->vm_srb.scsi_status, - vstor_packet->vm_srb.srb_status); + dev_warn(&device->device, + "cmd 0x%x scsi status 0x%x srb status 0x%x\n", + stor_pkt->vm_srb.cdb[0], + vstor_packet->vm_srb.scsi_status, + vstor_packet->vm_srb.srb_status); } if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { /* CHECK_CONDITION */ if (vstor_packet->vm_srb.srb_status & 0x80) { /* autosense data available */ - DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data " - "valid - len %d\n", request, - vstor_packet->vm_srb.sense_info_length); + dev_warn(&device->device, + "storvsc pkt %p autosense data valid - len %d\n", + request, vstor_packet->vm_srb.sense_info_length); memcpy(request->sense_buffer, vstor_packet->vm_srb.sense_data, diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 2229073874b..097d6dbe685 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -721,7 +721,6 @@ extern void vmbus_ontimer(unsigned long data); BLKVSC_DRV) /* Logging Level */ -#define WARNING_LVL 4 #define INFO_LVL 6 #define DEBUG_RING_LVL 9 @@ -733,11 +732,6 @@ extern unsigned int vmbus_loglevel; printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ } while (0) -#define DPRINT_WARN(mod, fmt, args...) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (WARNING_LVL <= LOWORD(vmbus_loglevel))) \ - printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\ - } while (0) struct hv_driver; struct hv_device; From 1a2643012fa2262e823b7f11d9732b7fea4c25ce Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:25:14 -0600 Subject: [PATCH 1377/1519] Staging: hv: remove last user of DPRINT() macro This also removed the unused function hv_dump_ring_info(). Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hyperv_vmbus.h | 2 -- drivers/hv/ring_buffer.c | 31 ------------------------------- include/linux/hyperv.h | 8 -------- 3 files changed, 41 deletions(-) diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 8261cb64931..0aee1122734 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -529,8 +529,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info, u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info); -void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix); - void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info, struct hv_ring_buffer_debug_info *debug_info); diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index f594ed09d7e..8af25a097d7 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -172,37 +172,6 @@ hv_get_ring_bufferindices(struct hv_ring_buffer_info *ring_info) return (u64)ring_info->ring_buffer->write_index << 32; } - -/* - * - * hv_dump_ring_info() - * - * Dump out to console the ring buffer info - * - */ -void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix) -{ - u32 bytes_avail_towrite; - u32 bytes_avail_toread; - - hv_get_ringbuffer_availbytes(ring_info, - &bytes_avail_toread, - &bytes_avail_towrite); - - DPRINT(VMBUS, - DEBUG_RING_LVL, - "%s <>", - prefix, - ring_info, - ring_info->ring_buffer->buffer, - bytes_avail_towrite, - bytes_avail_toread, - ring_info->ring_buffer->read_index, - ring_info->ring_buffer->write_index); -} - - /* * * hv_copyfrom_ringbuffer() diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 097d6dbe685..4fa32ec43aa 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -722,17 +722,9 @@ extern void vmbus_ontimer(unsigned long data); /* Logging Level */ #define INFO_LVL 6 -#define DEBUG_RING_LVL 9 extern unsigned int vmbus_loglevel; -#define DPRINT(mod, lvl, fmt, args...) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (lvl <= LOWORD(vmbus_loglevel))) \ - printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ - } while (0) - - struct hv_driver; struct hv_device; From 815166b95df1acb4890e9dbdb26660e9c00a7505 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:27:48 -0600 Subject: [PATCH 1378/1519] Staging: hv: remove vmbus_loglevel as it is not used at all anymore As there is no user of this variable, it's time to delete it. For dynamic debugging of the hyperv code, use the standard dynamic debug kernel interface. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/vmbus_drv.c | 5 ----- include/linux/hyperv.h | 5 ----- 2 files changed, 10 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index bb9f20507d7..e648571a5b0 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -41,10 +41,6 @@ static struct acpi_device *hv_acpi_dev; static struct tasklet_struct msg_dpc; static struct tasklet_struct event_dpc; - -unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL); -EXPORT_SYMBOL(vmbus_loglevel); - static struct completion probe_event; static int irq; @@ -767,6 +763,5 @@ cleanup: MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); -module_param(vmbus_loglevel, int, S_IRUGO|S_IWUSR); module_init(hv_acpi_init); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 4fa32ec43aa..7211e2ce24f 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -720,11 +720,6 @@ extern void vmbus_ontimer(unsigned long data); INPUTVSC_DRV|\ BLKVSC_DRV) -/* Logging Level */ -#define INFO_LVL 6 - -extern unsigned int vmbus_loglevel; - struct hv_driver; struct hv_device; From 5557e8a60570d0c2f3a06d6e9e6a0f5074c313f2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:30:22 -0600 Subject: [PATCH 1379/1519] hv: remove unused LOWORD and HIWORD macros from hyperv.h They aren't used anywhere anymore now that the debugging macros are gone, so remove it from hyperv.h as well. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- include/linux/hyperv.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 7211e2ce24f..6d9a53fc8a3 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -694,10 +694,6 @@ extern void vmbus_get_debug_info(struct vmbus_channel *channel, extern void vmbus_ontimer(unsigned long data); -#define LOWORD(dw) ((unsigned short)(dw)) -#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF)) - - #define VMBUS 0x0001 #define STORVSC 0x0002 #define NETVSC 0x0004 From 7a4ba88cc11eb4ba72778f491d8241385cb0475d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:33:29 -0600 Subject: [PATCH 1380/1519] hv: hyperv.h: remove unused module macros I have no idea what these were ever for, but they aren't used, so delete them. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- include/linux/hyperv.h | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 6d9a53fc8a3..f2bf0a51914 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -693,29 +693,6 @@ extern void vmbus_get_debug_info(struct vmbus_channel *channel, extern void vmbus_ontimer(unsigned long data); - -#define VMBUS 0x0001 -#define STORVSC 0x0002 -#define NETVSC 0x0004 -#define INPUTVSC 0x0008 -#define BLKVSC 0x0010 -#define VMBUS_DRV 0x0100 -#define STORVSC_DRV 0x0200 -#define NETVSC_DRV 0x0400 -#define INPUTVSC_DRV 0x0800 -#define BLKVSC_DRV 0x1000 - -#define ALL_MODULES (VMBUS |\ - STORVSC |\ - NETVSC |\ - INPUTVSC |\ - BLKVSC |\ - VMBUS_DRV |\ - STORVSC_DRV |\ - NETVSC_DRV |\ - INPUTVSC_DRV|\ - BLKVSC_DRV) - struct hv_driver; struct hv_device; From 2726f95e0b6c850b6162f287f2f83d9db37decd7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:37:27 -0600 Subject: [PATCH 1381/1519] hv: hyperv.h: remove unneeded forward declarations of structures This file was created by mushing different .h files together and it shows. This change removes some unneeded forward declarations. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- include/linux/hyperv.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index f2bf0a51914..ae865a11ad4 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -693,9 +693,6 @@ extern void vmbus_get_debug_info(struct vmbus_channel *channel, extern void vmbus_ontimer(unsigned long data); -struct hv_driver; -struct hv_device; - struct hv_dev_port_info { u32 int_mask; u32 read_idx; From 9f3e28e375a8d509a27efe89f3c8ea2a15aeb524 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:40:01 -0600 Subject: [PATCH 1382/1519] hv: remove free_channel() from hyperv.h This function is only used in the file it is declared in (channel_mgmt.c) so make it static and remove it from the hyperv.h file. Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/channel_mgmt.c | 2 +- include/linux/hyperv.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index a2fc487d142..12b85ff957f 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -196,7 +196,7 @@ static void release_channel(struct work_struct *work) /* * free_channel - Release the resources used by the vmbus channel object */ -void free_channel(struct vmbus_channel *channel) +static void free_channel(struct vmbus_channel *channel) { /* diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ae865a11ad4..240e1141cbb 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -606,8 +606,6 @@ struct vmbus_channel { void *channel_callback_context; }; -void free_channel(struct vmbus_channel *channel); - void vmbus_onmessage(void *context); int vmbus_request_offers(void); From 15b80d641793968605254c2bbb2aa9a10accb415 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Oct 2011 09:43:14 -0600 Subject: [PATCH 1383/1519] hv: remove struct hv_device_info from hyperv.h This is only used/needed by the vmbus core code, so move it out of the hyperv.h file and into the .c file that uses it. Signed-off-by: Greg Kroah-Hartman --- drivers/hv/vmbus_drv.c | 19 +++++++++++++++++++ include/linux/hyperv.h | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index e648571a5b0..0c048dd8013 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -44,6 +44,25 @@ static struct tasklet_struct event_dpc; static struct completion probe_event; static int irq; +struct hv_device_info { + u32 chn_id; + u32 chn_state; + uuid_le chn_type; + uuid_le chn_instance; + + u32 monitor_id; + u32 server_monitor_pending; + u32 server_monitor_latency; + u32 server_monitor_conn_id; + u32 client_monitor_pending; + u32 client_monitor_latency; + u32 client_monitor_conn_id; + + struct hv_dev_port_info inbound; + struct hv_dev_port_info outbound; +}; + + static void get_channel_info(struct hv_device *device, struct hv_device_info *info) { diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 240e1141cbb..12ec328481d 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -699,24 +699,6 @@ struct hv_dev_port_info { u32 bytes_avail_towrite; }; -struct hv_device_info { - u32 chn_id; - u32 chn_state; - uuid_le chn_type; - uuid_le chn_instance; - - u32 monitor_id; - u32 server_monitor_pending; - u32 server_monitor_latency; - u32 server_monitor_conn_id; - u32 client_monitor_pending; - u32 client_monitor_latency; - u32 client_monitor_conn_id; - - struct hv_dev_port_info inbound; - struct hv_dev_port_info outbound; -}; - /* Base driver object */ struct hv_driver { const char *name; From 97d35f281e6c9a60968c202d0386834e332677ce Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 6 Oct 2011 09:15:03 +0300 Subject: [PATCH 1384/1519] Staging: iio/light/tsl2563: unlock on an error path We need to unlock here before returning. Signed-off-by: Dan Carpenter Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2563.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 370777245f8..8977f5894da 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -518,7 +518,8 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ret = IIO_VAL_INT; break; default: - return -EINVAL; + ret = -EINVAL; + goto error_ret; } error_ret: From 15fbc198e635733aefbb4bc8182c02b85ec11a30 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 6 Oct 2011 09:15:36 +0300 Subject: [PATCH 1385/1519] Staging: iio/light/tsl2563: fix compile warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a compile warning: drivers/staging/iio/light/tsl2563.c:696:2: warning: initialization from incompatible pointer type [enabled by default] drivers/staging/iio/light/tsl2563.c:696:2: warning: (near initialization for ‘tsl2563_info.write_event_value’) [enabled by default] The tsl2563_write_thresh() function returns zero on success and error codes on failure, so nothing is lost by making the return type int instead of ssize_t. Signed-off-by: Dan Carpenter Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2563.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 8977f5894da..a5e08b32e42 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -569,7 +569,7 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev, return 0; } -static ssize_t tsl2563_write_thresh(struct iio_dev *indio_dev, +static int tsl2563_write_thresh(struct iio_dev *indio_dev, u64 event_code, int val) { From ee760ab2a95a1c52c7c68dc30c181425c667a507 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 6 Oct 2011 09:17:00 +0300 Subject: [PATCH 1386/1519] Staging: iio/adc/ad7150: release lock on error The error_ret label should have been before the mutex_unlock(). It's a typo. Signed-off-by: Dan Carpenter Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 89434205b6f..d1767d8f8bd 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -332,8 +332,8 @@ static int ad7150_write_event_value(struct iio_dev *indio_dev, /* write back if active */ ret = ad7150_write_event_params(indio_dev, event_code); - mutex_unlock(&chip->state_lock); error_ret: + mutex_unlock(&chip->state_lock); return ret; } From f8c6f4e9a40d47ce86a641eb20fb7c5a59f06ff0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 6 Oct 2011 17:14:35 +0100 Subject: [PATCH 1387/1519] staging:iio:core:naming: dev_info to indio_dev for consistency We had a random missmatch of these two. Lets pick the most common and get rid of the other. This patch covers the core. Others will clean up the drivers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/buffer_generic.h | 4 +- drivers/staging/iio/iio.h | 30 +-- drivers/staging/iio/iio_core_trigger.h | 17 +- drivers/staging/iio/industrialio-buffer.c | 78 ++++---- drivers/staging/iio/industrialio-core.c | 218 ++++++++++----------- drivers/staging/iio/industrialio-trigger.c | 42 ++-- 6 files changed, 195 insertions(+), 194 deletions(-) diff --git a/drivers/staging/iio/buffer_generic.h b/drivers/staging/iio/buffer_generic.h index 548bb748191..9e8f0100997 100644 --- a/drivers/staging/iio/buffer_generic.h +++ b/drivers/staging/iio/buffer_generic.h @@ -120,10 +120,10 @@ struct iio_buffer { /** * iio_buffer_init() - Initialize the buffer structure * @buffer: buffer to be initialized - * @dev_info: the iio device the buffer is assocated with + * @indio_dev: the iio device the buffer is assocated with **/ void iio_buffer_init(struct iio_buffer *buffer, - struct iio_dev *dev_info); + struct iio_dev *indio_dev); void iio_buffer_deinit(struct iio_buffer *buffer); diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index e7c286581a3..f3d88cd7e8a 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -323,23 +323,23 @@ struct iio_dev { /** * iio_device_register() - register a device with the IIO subsystem - * @dev_info: Device structure filled by the device driver + * @indio_dev: Device structure filled by the device driver **/ -int iio_device_register(struct iio_dev *dev_info); +int iio_device_register(struct iio_dev *indio_dev); /** * iio_device_unregister() - unregister a device from the IIO subsystem - * @dev_info: Device structure representing the device. + * @indio_dev: Device structure representing the device. **/ -void iio_device_unregister(struct iio_dev *dev_info); +void iio_device_unregister(struct iio_dev *indio_dev); /** * iio_push_event() - try to add event to the list for userspace reading - * @dev_info: IIO device structure + * @indio_dev: IIO device structure * @ev_code: What event * @timestamp: When the event occurred **/ -int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp); +int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); extern struct bus_type iio_bus_type; @@ -347,10 +347,10 @@ extern struct bus_type iio_bus_type; * iio_put_device() - reference counted deallocation of struct device * @dev: the iio_device containing the device **/ -static inline void iio_put_device(struct iio_dev *dev) +static inline void iio_put_device(struct iio_dev *indio_dev) { - if (dev) - put_device(&dev->dev); + if (indio_dev) + put_device(&indio_dev->dev); }; /* Can we make this smaller? */ @@ -361,9 +361,9 @@ static inline void iio_put_device(struct iio_dev *dev) **/ struct iio_dev *iio_allocate_device(int sizeof_priv); -static inline void *iio_priv(const struct iio_dev *dev) +static inline void *iio_priv(const struct iio_dev *indio_dev) { - return (char *)dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN); + return (char *)indio_dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN); } static inline struct iio_dev *iio_priv_to_dev(void *priv) @@ -376,15 +376,15 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) * iio_free_device() - free an iio_dev from a driver * @dev: the iio_dev associated with the device **/ -void iio_free_device(struct iio_dev *dev); +void iio_free_device(struct iio_dev *indio_dev); /** * iio_buffer_enabled() - helper function to test if the buffer is enabled - * @dev_info: IIO device info structure for device + * @indio_dev: IIO device info structure for device **/ -static inline bool iio_buffer_enabled(struct iio_dev *dev_info) +static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) { - return dev_info->currentmode + return indio_dev->currentmode & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE); }; diff --git a/drivers/staging/iio/iio_core_trigger.h b/drivers/staging/iio/iio_core_trigger.h index 3e5195a82bc..523c288b776 100644 --- a/drivers/staging/iio/iio_core_trigger.h +++ b/drivers/staging/iio/iio_core_trigger.h @@ -11,32 +11,33 @@ #ifdef CONFIG_IIO_TRIGGER /** * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers - * @dev_info: iio_dev associated with the device that will consume the trigger + * @indio_dev: iio_dev associated with the device that will consume the trigger **/ -int iio_device_register_trigger_consumer(struct iio_dev *dev_info); + +int iio_device_register_trigger_consumer(struct iio_dev *indio_dev); /** * iio_device_unregister_trigger_consumer() - reverse the registration process - * @dev_info: iio_dev associated with the device that consumed the trigger + * @indio_dev: iio_dev associated with the device that consumed the trigger **/ -void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info); +void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev); #else /** * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers - * @dev_info: iio_dev associated with the device that will consume the trigger + * @indio_dev: iio_dev associated with the device that will consume the trigger **/ -static int iio_device_register_trigger_consumer(struct iio_dev *dev_info) +static int iio_device_register_trigger_consumer(struct iio_dev *indio_dev) { return 0; }; /** * iio_device_unregister_trigger_consumer() - reverse the registration process - * @dev_info: iio_dev associated with the device that consumed the trigger + * @indio_dev: iio_dev associated with the device that consumed the trigger **/ -static void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +static void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev) { }; diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index 60929ff633e..6dd5d7d629a 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -82,9 +82,9 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev) rb->access->unmark_in_use(rb); } -void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info) +void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *indio_dev) { - buffer->indio_dev = dev_info; + buffer->indio_dev = indio_dev; init_waitqueue_head(&buffer->pollq); } EXPORT_SYMBOL(iio_buffer_init); @@ -123,9 +123,9 @@ static ssize_t iio_scan_el_show(struct device *dev, char *buf) { int ret; - struct iio_dev *dev_info = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); - ret = iio_scan_mask_query(dev_info->buffer, + ret = iio_scan_mask_query(indio_dev->buffer, to_iio_dev_attr(attr)->address); if (ret < 0) return ret; @@ -180,8 +180,8 @@ static ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", dev_info->buffer->scan_timestamp); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp); } static ssize_t iio_scan_el_ts_store(struct device *dev, @@ -427,11 +427,11 @@ ssize_t iio_buffer_store_enable(struct device *dev, int ret; bool requested_state, current_state; int previous_mode; - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct iio_buffer *buffer = dev_info->buffer; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_buffer *buffer = indio_dev->buffer; - mutex_lock(&dev_info->mlock); - previous_mode = dev_info->currentmode; + mutex_lock(&indio_dev->mlock); + previous_mode = indio_dev->currentmode; requested_state = !(buf[0] == '0'); current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES); if (current_state == requested_state) { @@ -440,7 +440,7 @@ ssize_t iio_buffer_store_enable(struct device *dev, } if (requested_state) { if (buffer->setup_ops->preenable) { - ret = buffer->setup_ops->preenable(dev_info); + ret = buffer->setup_ops->preenable(indio_dev); if (ret) { printk(KERN_ERR "Buffer not started:" @@ -460,8 +460,8 @@ ssize_t iio_buffer_store_enable(struct device *dev, if (buffer->access->mark_in_use) buffer->access->mark_in_use(buffer); /* Definitely possible for devices to support both of these.*/ - if (dev_info->modes & INDIO_BUFFER_TRIGGERED) { - if (!dev_info->trig) { + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) { + if (!indio_dev->trig) { printk(KERN_INFO "Buffer not started: no trigger\n"); ret = -EINVAL; @@ -469,50 +469,50 @@ ssize_t iio_buffer_store_enable(struct device *dev, buffer->access->unmark_in_use(buffer); goto error_ret; } - dev_info->currentmode = INDIO_BUFFER_TRIGGERED; - } else if (dev_info->modes & INDIO_BUFFER_HARDWARE) - dev_info->currentmode = INDIO_BUFFER_HARDWARE; + indio_dev->currentmode = INDIO_BUFFER_TRIGGERED; + } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) + indio_dev->currentmode = INDIO_BUFFER_HARDWARE; else { /* should never be reached */ ret = -EINVAL; goto error_ret; } if (buffer->setup_ops->postenable) { - ret = buffer->setup_ops->postenable(dev_info); + ret = buffer->setup_ops->postenable(indio_dev); if (ret) { printk(KERN_INFO "Buffer not started:" "postenable failed\n"); if (buffer->access->unmark_in_use) buffer->access->unmark_in_use(buffer); - dev_info->currentmode = previous_mode; + indio_dev->currentmode = previous_mode; if (buffer->setup_ops->postdisable) buffer->setup_ops-> - postdisable(dev_info); + postdisable(indio_dev); goto error_ret; } } } else { if (buffer->setup_ops->predisable) { - ret = buffer->setup_ops->predisable(dev_info); + ret = buffer->setup_ops->predisable(indio_dev); if (ret) goto error_ret; } if (buffer->access->unmark_in_use) buffer->access->unmark_in_use(buffer); - dev_info->currentmode = INDIO_DIRECT_MODE; + indio_dev->currentmode = INDIO_DIRECT_MODE; if (buffer->setup_ops->postdisable) { - ret = buffer->setup_ops->postdisable(dev_info); + ret = buffer->setup_ops->postdisable(indio_dev); if (ret) goto error_ret; } } done: - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return len; error_ret: - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret; } EXPORT_SYMBOL(iio_buffer_store_enable); @@ -521,8 +521,8 @@ ssize_t iio_buffer_show_enable(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", !!(dev_info->currentmode + struct iio_dev *indio_dev = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", !!(indio_dev->currentmode & INDIO_ALL_BUFFER_MODES)); } EXPORT_SYMBOL(iio_buffer_show_enable); @@ -575,34 +575,34 @@ static unsigned long *iio_scan_mask_match(unsigned long *av_masks, **/ int iio_scan_mask_set(struct iio_buffer *buffer, int bit) { - struct iio_dev *dev_info = buffer->indio_dev; + struct iio_dev *indio_dev = buffer->indio_dev; unsigned long *mask; unsigned long *trialmask; trialmask = kmalloc(sizeof(*trialmask)* - BITS_TO_LONGS(dev_info->masklength), + BITS_TO_LONGS(indio_dev->masklength), GFP_KERNEL); if (trialmask == NULL) return -ENOMEM; - if (!dev_info->masklength) { + if (!indio_dev->masklength) { WARN_ON("trying to set scanmask prior to registering buffer\n"); kfree(trialmask); return -EINVAL; } - bitmap_copy(trialmask, buffer->scan_mask, dev_info->masklength); + bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength); set_bit(bit, trialmask); - if (dev_info->available_scan_masks) { - mask = iio_scan_mask_match(dev_info->available_scan_masks, - dev_info->masklength, + if (indio_dev->available_scan_masks) { + mask = iio_scan_mask_match(indio_dev->available_scan_masks, + indio_dev->masklength, trialmask); if (!mask) { kfree(trialmask); return -EINVAL; } } - bitmap_copy(buffer->scan_mask, trialmask, dev_info->masklength); + bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength); buffer->scan_count++; kfree(trialmask); @@ -613,17 +613,17 @@ EXPORT_SYMBOL_GPL(iio_scan_mask_set); int iio_scan_mask_query(struct iio_buffer *buffer, int bit) { - struct iio_dev *dev_info = buffer->indio_dev; + struct iio_dev *indio_dev = buffer->indio_dev; long *mask; - if (bit > dev_info->masklength) + if (bit > indio_dev->masklength) return -EINVAL; if (!buffer->scan_mask) return 0; - if (dev_info->available_scan_masks) - mask = iio_scan_mask_match(dev_info->available_scan_masks, - dev_info->masklength, + if (indio_dev->available_scan_masks) + mask = iio_scan_mask_match(indio_dev->available_scan_masks, + indio_dev->masklength, buffer->scan_mask); else mask = buffer->scan_mask; diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 5a6dde85ec8..f52fa3a3887 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -119,9 +119,9 @@ struct iio_event_interface { struct attribute_group group; }; -int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp) +int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) { - struct iio_event_interface *ev_int = dev_info->event_interface; + struct iio_event_interface *ev_int = indio_dev->event_interface; struct iio_detected_event_list *ev; int ret = 0; @@ -567,7 +567,7 @@ error_ret: return ret; } -static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, +static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev, struct iio_chan_spec const *chan) { int ret, i, attrcount = 0; @@ -582,8 +582,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, &iio_write_channel_info : NULL), 0, 0, - &dev_info->dev, - &dev_info->channel_attr_list); + &indio_dev->dev, + &indio_dev->channel_attr_list); if (ret) goto error_ret; attrcount++; @@ -595,8 +595,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info, &iio_write_channel_info, (1 << i), !(i%2), - &dev_info->dev, - &dev_info->channel_attr_list); + &indio_dev->dev, + &indio_dev->channel_attr_list); if (ret == -EBUSY && (i%2 == 0)) { ret = 0; continue; @@ -610,7 +610,7 @@ error_ret: return ret; } -static void iio_device_remove_and_free_read_attr(struct iio_dev *dev_info, +static void iio_device_remove_and_free_read_attr(struct iio_dev *indio_dev, struct iio_dev_attr *p) { kfree(p->dev_attr.attr.name); @@ -627,15 +627,15 @@ static ssize_t iio_show_dev_name(struct device *dev, static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); -static int iio_device_register_sysfs(struct iio_dev *dev_info) +static int iio_device_register_sysfs(struct iio_dev *indio_dev) { int i, ret = 0, attrcount, attrn, attrcount_orig = 0; struct iio_dev_attr *p, *n; struct attribute **attr; /* First count elements in any existing group */ - if (dev_info->info->attrs) { - attr = dev_info->info->attrs->attrs; + if (indio_dev->info->attrs) { + attr = indio_dev->info->attrs->attrs; while (*attr++ != NULL) attrcount_orig++; } @@ -644,66 +644,66 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) * New channel registration method - relies on the fact a group does * not need to be initialized if it is name is NULL. */ - INIT_LIST_HEAD(&dev_info->channel_attr_list); - if (dev_info->channels) - for (i = 0; i < dev_info->num_channels; i++) { - ret = iio_device_add_channel_sysfs(dev_info, - &dev_info + INIT_LIST_HEAD(&indio_dev->channel_attr_list); + if (indio_dev->channels) + for (i = 0; i < indio_dev->num_channels; i++) { + ret = iio_device_add_channel_sysfs(indio_dev, + &indio_dev ->channels[i]); if (ret < 0) goto error_clear_attrs; attrcount += ret; } - if (dev_info->name) + if (indio_dev->name) attrcount++; - dev_info->chan_attr_group.attrs - = kzalloc(sizeof(dev_info->chan_attr_group.attrs[0])* + indio_dev->chan_attr_group.attrs + = kzalloc(sizeof(indio_dev->chan_attr_group.attrs[0])* (attrcount + 1), GFP_KERNEL); - if (dev_info->chan_attr_group.attrs == NULL) { + if (indio_dev->chan_attr_group.attrs == NULL) { ret = -ENOMEM; goto error_clear_attrs; } /* Copy across original attributes */ - if (dev_info->info->attrs) - memcpy(dev_info->chan_attr_group.attrs, - dev_info->info->attrs->attrs, - sizeof(dev_info->chan_attr_group.attrs[0]) + if (indio_dev->info->attrs) + memcpy(indio_dev->chan_attr_group.attrs, + indio_dev->info->attrs->attrs, + sizeof(indio_dev->chan_attr_group.attrs[0]) *attrcount_orig); attrn = attrcount_orig; /* Add all elements from the list. */ - list_for_each_entry(p, &dev_info->channel_attr_list, l) - dev_info->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr; - if (dev_info->name) - dev_info->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr; + list_for_each_entry(p, &indio_dev->channel_attr_list, l) + indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr; + if (indio_dev->name) + indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr; - dev_info->groups[dev_info->groupcounter++] = - &dev_info->chan_attr_group; + indio_dev->groups[indio_dev->groupcounter++] = + &indio_dev->chan_attr_group; return 0; error_clear_attrs: list_for_each_entry_safe(p, n, - &dev_info->channel_attr_list, l) { + &indio_dev->channel_attr_list, l) { list_del(&p->l); - iio_device_remove_and_free_read_attr(dev_info, p); + iio_device_remove_and_free_read_attr(indio_dev, p); } return ret; } -static void iio_device_unregister_sysfs(struct iio_dev *dev_info) +static void iio_device_unregister_sysfs(struct iio_dev *indio_dev) { struct iio_dev_attr *p, *n; - list_for_each_entry_safe(p, n, &dev_info->channel_attr_list, l) { + list_for_each_entry_safe(p, n, &indio_dev->channel_attr_list, l) { list_del(&p->l); - iio_device_remove_and_free_read_attr(dev_info, p); + iio_device_remove_and_free_read_attr(indio_dev, p); } - kfree(dev_info->chan_attr_group.attrs); + kfree(indio_dev->chan_attr_group.attrs); } static const char * const iio_ev_type_text[] = { @@ -793,7 +793,7 @@ static ssize_t iio_ev_value_store(struct device *dev, return len; } -static int iio_device_add_event_sysfs(struct iio_dev *dev_info, +static int iio_device_add_event_sysfs(struct iio_dev *indio_dev, struct iio_chan_spec const *chan) { int ret = 0, i, attrcount = 0; @@ -834,8 +834,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, iio_ev_state_store, mask, 0, - &dev_info->dev, - &dev_info->event_interface-> + &indio_dev->dev, + &indio_dev->event_interface-> dev_attr_list); kfree(postfix); if (ret) @@ -853,8 +853,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, iio_ev_value_store, mask, 0, - &dev_info->dev, - &dev_info->event_interface-> + &indio_dev->dev, + &indio_dev->event_interface-> dev_attr_list); kfree(postfix); if (ret) @@ -866,26 +866,26 @@ error_ret: return ret; } -static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info) +static inline void __iio_remove_event_config_attrs(struct iio_dev *indio_dev) { struct iio_dev_attr *p, *n; list_for_each_entry_safe(p, n, - &dev_info->event_interface-> + &indio_dev->event_interface-> dev_attr_list, l) { kfree(p->dev_attr.attr.name); kfree(p); } } -static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info) +static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev) { int j, ret, attrcount = 0; - INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list); + INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); /* Dynically created from the channels array */ - for (j = 0; j < dev_info->num_channels; j++) { - ret = iio_device_add_event_sysfs(dev_info, - &dev_info->channels[j]); + for (j = 0; j < indio_dev->num_channels; j++) { + ret = iio_device_add_event_sysfs(indio_dev, + &indio_dev->channels[j]); if (ret < 0) goto error_clear_attrs; attrcount += ret; @@ -893,17 +893,17 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info) return attrcount; error_clear_attrs: - __iio_remove_event_config_attrs(dev_info); + __iio_remove_event_config_attrs(indio_dev); return ret; } -static bool iio_check_for_dynamic_events(struct iio_dev *dev_info) +static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev) { int j; - for (j = 0; j < dev_info->num_channels; j++) - if (dev_info->channels[j].event_mask != 0) + for (j = 0; j < indio_dev->num_channels; j++) + if (indio_dev->channels[j].event_mask != 0) return true; return false; } @@ -919,91 +919,91 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int) } static const char *iio_event_group_name = "events"; -static int iio_device_register_eventset(struct iio_dev *dev_info) +static int iio_device_register_eventset(struct iio_dev *indio_dev) { struct iio_dev_attr *p; int ret = 0, attrcount_orig = 0, attrcount, attrn; struct attribute **attr; - if (!(dev_info->info->event_attrs || - iio_check_for_dynamic_events(dev_info))) + if (!(indio_dev->info->event_attrs || + iio_check_for_dynamic_events(indio_dev))) return 0; - dev_info->event_interface = + indio_dev->event_interface = kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL); - if (dev_info->event_interface == NULL) { + if (indio_dev->event_interface == NULL) { ret = -ENOMEM; goto error_ret; } - iio_setup_ev_int(dev_info->event_interface); - if (dev_info->info->event_attrs != NULL) { - attr = dev_info->info->event_attrs->attrs; + iio_setup_ev_int(indio_dev->event_interface); + if (indio_dev->info->event_attrs != NULL) { + attr = indio_dev->info->event_attrs->attrs; while (*attr++ != NULL) attrcount_orig++; } attrcount = attrcount_orig; - if (dev_info->channels) { - ret = __iio_add_event_config_attrs(dev_info); + if (indio_dev->channels) { + ret = __iio_add_event_config_attrs(indio_dev); if (ret < 0) goto error_free_setup_event_lines; attrcount += ret; } - dev_info->event_interface->group.name = iio_event_group_name; - dev_info->event_interface->group.attrs = - kzalloc(sizeof(dev_info->event_interface->group.attrs[0]) + indio_dev->event_interface->group.name = iio_event_group_name; + indio_dev->event_interface->group.attrs = + kzalloc(sizeof(indio_dev->event_interface->group.attrs[0]) *(attrcount + 1), GFP_KERNEL); - if (dev_info->event_interface->group.attrs == NULL) { + if (indio_dev->event_interface->group.attrs == NULL) { ret = -ENOMEM; goto error_free_setup_event_lines; } - if (dev_info->info->event_attrs) - memcpy(dev_info->event_interface->group.attrs, - dev_info->info->event_attrs->attrs, - sizeof(dev_info->event_interface->group.attrs[0]) + if (indio_dev->info->event_attrs) + memcpy(indio_dev->event_interface->group.attrs, + indio_dev->info->event_attrs->attrs, + sizeof(indio_dev->event_interface->group.attrs[0]) *attrcount_orig); attrn = attrcount_orig; /* Add all elements from the list. */ list_for_each_entry(p, - &dev_info->event_interface->dev_attr_list, + &indio_dev->event_interface->dev_attr_list, l) - dev_info->event_interface->group.attrs[attrn++] = + indio_dev->event_interface->group.attrs[attrn++] = &p->dev_attr.attr; - dev_info->groups[dev_info->groupcounter++] = - &dev_info->event_interface->group; + indio_dev->groups[indio_dev->groupcounter++] = + &indio_dev->event_interface->group; return 0; error_free_setup_event_lines: - __iio_remove_event_config_attrs(dev_info); - kfree(dev_info->event_interface); + __iio_remove_event_config_attrs(indio_dev); + kfree(indio_dev->event_interface); error_ret: return ret; } -static void iio_device_unregister_eventset(struct iio_dev *dev_info) +static void iio_device_unregister_eventset(struct iio_dev *indio_dev) { - if (dev_info->event_interface == NULL) + if (indio_dev->event_interface == NULL) return; - __iio_remove_event_config_attrs(dev_info); - kfree(dev_info->event_interface->group.attrs); - kfree(dev_info->event_interface); + __iio_remove_event_config_attrs(indio_dev); + kfree(indio_dev->event_interface->group.attrs); + kfree(indio_dev->event_interface); } static void iio_dev_release(struct device *device) { - struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); - cdev_del(&dev_info->chrdev); - if (dev_info->modes & INDIO_BUFFER_TRIGGERED) - iio_device_unregister_trigger_consumer(dev_info); - iio_device_unregister_eventset(dev_info); - iio_device_unregister_sysfs(dev_info); - ida_simple_remove(&iio_ida, dev_info->id); - kfree(dev_info); + struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev); + cdev_del(&indio_dev->chrdev); + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) + iio_device_unregister_trigger_consumer(indio_dev); + iio_device_unregister_eventset(indio_dev); + iio_device_unregister_sysfs(indio_dev); + ida_simple_remove(&iio_ida, indio_dev->id); + kfree(indio_dev); } static struct device_type iio_dev_type = { @@ -1062,11 +1062,11 @@ EXPORT_SYMBOL(iio_free_device); **/ static int iio_chrdev_open(struct inode *inode, struct file *filp) { - struct iio_dev *dev_info = container_of(inode->i_cdev, + struct iio_dev *indio_dev = container_of(inode->i_cdev, struct iio_dev, chrdev); - filp->private_data = dev_info; + filp->private_data = indio_dev; - return iio_chrdev_buffer_open(dev_info); + return iio_chrdev_buffer_open(indio_dev); } /** @@ -1107,52 +1107,52 @@ static const struct file_operations iio_buffer_fileops = { .compat_ioctl = iio_ioctl, }; -int iio_device_register(struct iio_dev *dev_info) +int iio_device_register(struct iio_dev *indio_dev) { int ret; /* configure elements for the chrdev */ - dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id); + indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); - ret = iio_device_register_sysfs(dev_info); + ret = iio_device_register_sysfs(indio_dev); if (ret) { - dev_err(dev_info->dev.parent, + dev_err(indio_dev->dev.parent, "Failed to register sysfs interfaces\n"); goto error_ret; } - ret = iio_device_register_eventset(dev_info); + ret = iio_device_register_eventset(indio_dev); if (ret) { - dev_err(dev_info->dev.parent, + dev_err(indio_dev->dev.parent, "Failed to register event set\n"); goto error_free_sysfs; } - if (dev_info->modes & INDIO_BUFFER_TRIGGERED) - iio_device_register_trigger_consumer(dev_info); + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) + iio_device_register_trigger_consumer(indio_dev); - ret = device_add(&dev_info->dev); + ret = device_add(&indio_dev->dev); if (ret < 0) goto error_unreg_eventset; - cdev_init(&dev_info->chrdev, &iio_buffer_fileops); - dev_info->chrdev.owner = dev_info->info->driver_module; - ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1); + cdev_init(&indio_dev->chrdev, &iio_buffer_fileops); + indio_dev->chrdev.owner = indio_dev->info->driver_module; + ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1); if (ret < 0) goto error_del_device; return 0; error_del_device: - device_del(&dev_info->dev); + device_del(&indio_dev->dev); error_unreg_eventset: - iio_device_unregister_eventset(dev_info); + iio_device_unregister_eventset(indio_dev); error_free_sysfs: - iio_device_unregister_sysfs(dev_info); + iio_device_unregister_sysfs(indio_dev); error_ret: return ret; } EXPORT_SYMBOL(iio_device_register); -void iio_device_unregister(struct iio_dev *dev_info) +void iio_device_unregister(struct iio_dev *indio_dev) { - device_unregister(&dev_info->dev); + device_unregister(&indio_dev->dev); } EXPORT_SYMBOL(iio_device_unregister); subsys_initcall(iio_init); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 392664962b4..2c626e0cb29 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -304,10 +304,10 @@ static ssize_t iio_trigger_read_current(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); - if (dev_info->trig) - return sprintf(buf, "%s\n", dev_info->trig->name); + if (indio_dev->trig) + return sprintf(buf, "%s\n", indio_dev->trig->name); return 0; } @@ -323,38 +323,38 @@ static ssize_t iio_trigger_write_current(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct iio_trigger *oldtrig = dev_info->trig; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_trigger *oldtrig = indio_dev->trig; struct iio_trigger *trig; int ret; - mutex_lock(&dev_info->mlock); - if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) { - mutex_unlock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { + mutex_unlock(&indio_dev->mlock); return -EBUSY; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); trig = iio_trigger_find_by_name(buf, len); - if (trig && dev_info->info->validate_trigger) { - ret = dev_info->info->validate_trigger(dev_info, trig); + if (trig && indio_dev->info->validate_trigger) { + ret = indio_dev->info->validate_trigger(indio_dev, trig); if (ret) return ret; } if (trig && trig->ops && trig->ops->validate_device) { - ret = trig->ops->validate_device(trig, dev_info); + ret = trig->ops->validate_device(trig, indio_dev); if (ret) return ret; } - dev_info->trig = trig; + indio_dev->trig = trig; - if (oldtrig && dev_info->trig != oldtrig) + if (oldtrig && indio_dev->trig != oldtrig) iio_put_trigger(oldtrig); - if (dev_info->trig) - iio_get_trigger(dev_info->trig); + if (indio_dev->trig) + iio_get_trigger(indio_dev->trig); return len; } @@ -473,19 +473,19 @@ void iio_free_trigger(struct iio_trigger *trig) } EXPORT_SYMBOL(iio_free_trigger); -int iio_device_register_trigger_consumer(struct iio_dev *dev_info) +int iio_device_register_trigger_consumer(struct iio_dev *indio_dev) { - dev_info->groups[dev_info->groupcounter++] = + indio_dev->groups[indio_dev->groupcounter++] = &iio_trigger_consumer_attr_group; return 0; } -void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev) { /* Clean up and associated but not attached triggers references */ - if (dev_info->trig) - iio_put_trigger(dev_info->trig); + if (indio_dev->trig) + iio_put_trigger(indio_dev->trig); } int iio_triggered_buffer_postenable(struct iio_dev *indio_dev) From 2579a0df14b07042f8803a841affdc8bd37132ac Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 6 Oct 2011 17:14:36 +0100 Subject: [PATCH 1388/1519] staging:iio:accel:sca3000 dev_info to indio_dev renaming. Again, there is a mix of the two names for the struct iio_dev. Lets pick one and run with it. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/sca3000_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 5592b240ebf..f2cdb1f3857 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -268,8 +268,8 @@ static ssize_t sca3000_show_rev(struct device *dev, char *buf) { int len = 0, ret; - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct sca3000_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct sca3000_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_REVID, 1); @@ -296,8 +296,8 @@ sca3000_show_available_measurement_modes(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct sca3000_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct sca3000_state *st = iio_priv(indio_dev); int len = 0; len += sprintf(buf + len, "0 - normal mode"); @@ -328,8 +328,8 @@ sca3000_show_measurement_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct sca3000_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct sca3000_state *st = iio_priv(indio_dev); int len = 0, ret; mutex_lock(&st->lock); @@ -379,8 +379,8 @@ sca3000_store_measurement_mode(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct sca3000_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct sca3000_state *st = iio_priv(indio_dev); int ret; int mask = 0x03; long val; From 84f79ecb0c1f39393b96e1401d4e8a1d498f3613 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 6 Oct 2011 17:14:37 +0100 Subject: [PATCH 1389/1519] staging:iio:adc:naming: dev_info to indio_dev for consistency We had a random missmatch of these two. Lets pick the most common and get rid of the other. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7150.c | 4 +- drivers/staging/iio/adc/ad7192.c | 4 +- drivers/staging/iio/adc/ad7280a.c | 60 +++++++++++++-------------- drivers/staging/iio/adc/ad7291.c | 12 +++--- drivers/staging/iio/adc/ad7298_core.c | 12 +++--- drivers/staging/iio/adc/ad7298_ring.c | 4 +- drivers/staging/iio/adc/ad7476_core.c | 12 +++--- drivers/staging/iio/adc/ad7816.c | 34 +++++++-------- drivers/staging/iio/adc/ad7887_core.c | 10 ++--- drivers/staging/iio/adc/ad799x_core.c | 38 ++++++++--------- 10 files changed, 95 insertions(+), 95 deletions(-) diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index d1767d8f8bd..7d0509682fb 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -341,8 +341,8 @@ static ssize_t ad7150_show_timeout(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7150_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7150_chip_info *chip = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); u8 value; diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 67d731b4064..29258f4a095 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -842,8 +842,8 @@ static mode_t ad7192_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7192_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7192_state *st = iio_priv(indio_dev); mode_t mode = attr->mode; diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 59581feecd4..386834a9b69 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -383,8 +383,8 @@ static ssize_t ad7280_show_balance_sw(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); return sprintf(buf, "%d\n", @@ -397,8 +397,8 @@ static ssize_t ad7280_store_balance_sw(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); bool readin; int ret; @@ -411,7 +411,7 @@ static ssize_t ad7280_store_balance_sw(struct device *dev, devaddr = this_attr->address >> 8; ch = this_attr->address & 0xFF; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); if (readin) st->cb_mask[devaddr] |= 1 << (ch + 2); else @@ -419,7 +419,7 @@ static ssize_t ad7280_store_balance_sw(struct device *dev, ret = ad7280_write(st, devaddr, AD7280A_CELL_BALANCE, 0, st->cb_mask[devaddr]); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -428,16 +428,16 @@ static ssize_t ad7280_show_balance_timer(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; unsigned msecs; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad7280_read(st, this_attr->address >> 8, this_attr->address & 0xFF); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; @@ -452,8 +452,8 @@ static ssize_t ad7280_store_balance_timer(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); long val; int ret; @@ -467,11 +467,11 @@ static ssize_t ad7280_store_balance_timer(struct device *dev, if (val > 31) return -EINVAL; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad7280_write(st, this_attr->address >> 8, this_attr->address & 0xFF, 0, (val & 0x1F) << 3); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -595,8 +595,8 @@ static ssize_t ad7280_read_channel_config(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); unsigned val; @@ -625,8 +625,8 @@ static ssize_t ad7280_write_channel_config(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); long val; @@ -651,7 +651,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev, val = clamp(val, 0L, 0xFFL); - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: st->cell_threshhigh = val; @@ -670,15 +670,15 @@ static ssize_t ad7280_write_channel_config(struct device *dev, ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, this_attr->address, 1, val); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } static irqreturn_t ad7280_event_handler(int irq, void *private) { - struct iio_dev *dev_info = private; - struct ad7280_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = private; + struct ad7280_state *st = iio_priv(indio_dev); unsigned *channels; int i, ret; @@ -694,7 +694,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) { if (((channels[i] >> 11) & 0xFFF) >= st->cell_threshhigh) - iio_push_event(dev_info, + iio_push_event(indio_dev, IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, @@ -704,7 +704,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->cell_threshlow) - iio_push_event(dev_info, + iio_push_event(indio_dev, IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, @@ -714,7 +714,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); } else { if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) - iio_push_event(dev_info, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -722,7 +722,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->aux_threshlow) - iio_push_event(dev_info, + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, @@ -775,25 +775,25 @@ static struct attribute_group ad7280_event_attrs_group = { .attrs = ad7280_event_attributes, }; -static int ad7280_read_raw(struct iio_dev *dev_info, +static int ad7280_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { - struct ad7280_state *st = iio_priv(dev_info); + struct ad7280_state *st = iio_priv(indio_dev); unsigned int scale_uv; int ret; switch (m) { case 0: - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); if (chan->address == AD7280A_ALL_CELLS) ret = ad7280_read_all_channels(st, st->scan_cnt, NULL); else ret = ad7280_read_channel(st, chan->address >> 8, chan->address & 0xFF); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index ba3f19fb418..acdce8c5092 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -131,8 +131,8 @@ static ssize_t ad7291_store_reset(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7291_chip_info *chip = iio_priv(indio_dev); return ad7291_i2c_write(chip, AD7291_COMMAND, chip->command | AD7291_RESET); @@ -213,8 +213,8 @@ static inline ssize_t ad7291_show_hyst(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7291_chip_info *chip = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); u16 data; int ret; @@ -231,8 +231,8 @@ static inline ssize_t ad7291_set_hyst(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7291_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7291_chip_info *chip = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); u16 data; int ret; diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 9ef310241bc..b77272722f5 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -109,24 +109,24 @@ static int ad7298_scan_temp(struct ad7298_state *st, int *val) return 0; } -static int ad7298_read_raw(struct iio_dev *dev_info, +static int ad7298_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { int ret; - struct ad7298_state *st = iio_priv(dev_info); + struct ad7298_state *st = iio_priv(indio_dev); unsigned int scale_uv; switch (m) { case 0: - mutex_lock(&dev_info->mlock); - if (iio_buffer_enabled(dev_info)) { + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) { if (chan->address == AD7298_CH_TEMP) ret = -ENODEV; else - ret = ad7298_scan_from_ring(dev_info, + ret = ad7298_scan_from_ring(indio_dev, chan->address); } else { if (chan->address == AD7298_CH_TEMP) @@ -134,7 +134,7 @@ static int ad7298_read_raw(struct iio_dev *dev_info, else ret = ad7298_scan_direct(st, chan->address); } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c index d90b6f495f9..47630d506a6 100644 --- a/drivers/staging/iio/adc/ad7298_ring.c +++ b/drivers/staging/iio/adc/ad7298_ring.c @@ -18,9 +18,9 @@ #include "ad7298.h" -int ad7298_scan_from_ring(struct iio_dev *dev_info, long ch) +int ad7298_scan_from_ring(struct iio_dev *indio_dev, long ch) { - struct iio_buffer *ring = dev_info->buffer; + struct iio_buffer *ring = indio_dev->buffer; int ret; u16 *ring_data; diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 9b050cefa44..1953dbf2cbd 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -32,24 +32,24 @@ static int ad7476_scan_direct(struct ad7476_state *st) return (st->data[0] << 8) | st->data[1]; } -static int ad7476_read_raw(struct iio_dev *dev_info, +static int ad7476_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { int ret; - struct ad7476_state *st = iio_priv(dev_info); + struct ad7476_state *st = iio_priv(indio_dev); unsigned int scale_uv; switch (m) { case 0: - mutex_lock(&dev_info->mlock); - if (iio_buffer_enabled(dev_info)) - ret = ad7476_scan_from_ring(dev_info); + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) + ret = ad7476_scan_from_ring(indio_dev); else ret = ad7476_scan_direct(st); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index deec8f245f9..1440619d74e 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -112,8 +112,8 @@ static ssize_t ad7816_show_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); if (chip->mode) return sprintf(buf, "power-save\n"); @@ -126,8 +126,8 @@ static ssize_t ad7816_store_mode(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); if (strcmp(buf, "full")) { gpio_set_value(chip->rdwr_pin, 1); @@ -158,8 +158,8 @@ static ssize_t ad7816_show_channel(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); return sprintf(buf, "%d\n", chip->channel_id); } @@ -169,8 +169,8 @@ static ssize_t ad7816_store_channel(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); unsigned long data; int ret; @@ -180,13 +180,13 @@ static ssize_t ad7816_store_channel(struct device *dev, if (data > AD7816_CS_MAX && data != AD7816_CS_MASK) { dev_err(&chip->spi_dev->dev, "Invalid channel id %lu for %s.\n", - data, dev_info->name); + data, indio_dev->name); return -EINVAL; - } else if (strcmp(dev_info->name, "ad7818") == 0 && data > 1) { + } else if (strcmp(indio_dev->name, "ad7818") == 0 && data > 1) { dev_err(&chip->spi_dev->dev, "Invalid channel id %lu for ad7818.\n", data); return -EINVAL; - } else if (strcmp(dev_info->name, "ad7816") == 0 && data > 0) { + } else if (strcmp(indio_dev->name, "ad7816") == 0 && data > 0) { dev_err(&chip->spi_dev->dev, "Invalid channel id %lu for ad7816.\n", data); return -EINVAL; @@ -207,8 +207,8 @@ static ssize_t ad7816_show_value(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); u16 data; s8 value; int ret; @@ -262,8 +262,8 @@ static ssize_t ad7816_show_oti(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); int value; if (chip->channel_id > AD7816_CS_MAX) { @@ -283,8 +283,8 @@ static inline ssize_t ad7816_set_oti(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad7816_chip_info *chip = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad7816_chip_info *chip = iio_priv(indio_dev); long value; u8 data; int ret; diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 37e6cc9e5cb..9456c032c05 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -31,24 +31,24 @@ static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1]; } -static int ad7887_read_raw(struct iio_dev *dev_info, +static int ad7887_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { int ret; - struct ad7887_state *st = iio_priv(dev_info); + struct ad7887_state *st = iio_priv(indio_dev); unsigned int scale_uv; switch (m) { case 0: - mutex_lock(&dev_info->mlock); - if (iio_buffer_enabled(dev_info)) + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) ret = ad7887_scan_from_ring(st, 1 << chan->address); else ret = ad7887_scan_direct(st, chan->address); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 7c42c12d8ee..2d60539b4e4 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -136,25 +136,25 @@ static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) return rxbuf; } -static int ad799x_read_raw(struct iio_dev *dev_info, +static int ad799x_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { int ret; - struct ad799x_state *st = iio_priv(dev_info); + struct ad799x_state *st = iio_priv(indio_dev); unsigned int scale_uv; switch (m) { case 0: - mutex_lock(&dev_info->mlock); - if (iio_buffer_enabled(dev_info)) - ret = ad799x_single_channel_from_ring(dev_info, + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) + ret = ad799x_single_channel_from_ring(indio_dev, chan->scan_index); else ret = ad799x_scan_direct(st, chan->scan_index); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; @@ -182,8 +182,8 @@ static ssize_t ad799x_read_frequency(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad799x_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad799x_state *st = iio_priv(indio_dev); int ret; u8 val; @@ -201,8 +201,8 @@ static ssize_t ad799x_write_frequency(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad799x_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad799x_state *st = iio_priv(indio_dev); long val; int ret, i; @@ -212,7 +212,7 @@ static ssize_t ad799x_write_frequency(struct device *dev, if (ret) return ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); if (ret) goto error_ret_mutex; @@ -230,12 +230,12 @@ static ssize_t ad799x_write_frequency(struct device *dev, ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); error_ret_mutex: - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } -static int ad799x_read_event_config(struct iio_dev *dev_info, +static int ad799x_read_event_config(struct iio_dev *indio_dev, u64 event_code) { return 1; @@ -294,8 +294,8 @@ static ssize_t ad799x_read_channel_config(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad799x_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad799x_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; @@ -312,8 +312,8 @@ static ssize_t ad799x_write_channel_config(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad799x_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad799x_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); long val; @@ -323,9 +323,9 @@ static ssize_t ad799x_write_channel_config(struct device *dev, if (ret) return ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad799x_i2c_write16(st, this_attr->address, val); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } From 638e59fc8c867b44dfbe20c235df00384814cb5e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 6 Oct 2011 17:14:38 +0100 Subject: [PATCH 1390/1519] staging:iio:dac/dds/impedance dev_info to indio_dev for consistency We had a random missmatch of these two. Lets pick the most common and get rid of the other. Signed-off-by: Jonathan Cameron For adxxxx parts Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5446.c | 36 +++++++-------- drivers/staging/iio/dac/max517.c | 8 ++-- drivers/staging/iio/dds/ad9832.c | 8 ++-- drivers/staging/iio/dds/ad9834.c | 28 ++++++------ .../staging/iio/impedance-analyzer/ad5933.c | 44 +++++++++---------- 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index 41a8872b37c..dc98867a160 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -68,8 +68,8 @@ static ssize_t ad5446_write(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); int ret; long val; @@ -82,11 +82,11 @@ static ssize_t ad5446_write(struct device *dev, goto error_ret; } - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); st->cached_val = val; st->chip_info->store_sample(st, val); ret = spi_sync(st->spi, &st->msg); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); error_ret: return ret ? ret : len; @@ -98,8 +98,8 @@ static ssize_t ad5446_show_scale(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); /* Corresponds to Vref / 2^(bits) */ unsigned int scale_uv = (st->vref_mv * 1000) >> st->chip_info->bits; @@ -111,8 +111,8 @@ static ssize_t ad5446_write_powerdown_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); if (sysfs_streq(buf, "1kohm_to_gnd")) st->pwr_down_mode = MODE_PWRDWN_1k; @@ -129,8 +129,8 @@ static ssize_t ad5446_write_powerdown_mode(struct device *dev, static ssize_t ad5446_read_powerdown_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"}; @@ -141,8 +141,8 @@ static ssize_t ad5446_read_dac_powerdown(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); return sprintf(buf, "%d\n", st->pwr_down); } @@ -151,8 +151,8 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); unsigned long readin; int ret; @@ -163,7 +163,7 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, if (readin > 1) ret = -EINVAL; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); st->pwr_down = readin; if (st->pwr_down) @@ -172,7 +172,7 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, st->chip_info->store_sample(st, st->cached_val); ret = spi_sync(st->spi, &st->msg); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -201,8 +201,8 @@ static mode_t ad5446_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5446_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5446_state *st = iio_priv(indio_dev); mode_t mode = attr->mode; diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c index fb780d02cae..adfbd20f898 100644 --- a/drivers/staging/iio/dac/max517.c +++ b/drivers/staging/iio/dac/max517.c @@ -59,8 +59,8 @@ static ssize_t max517_set_value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, int channel) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct max517_data *data = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct max517_data *data = iio_priv(indio_dev); struct i2c_client *client = data->client; u8 outbuf[4]; /* 1x or 2x command + value */ int outbuf_size = 0; @@ -128,8 +128,8 @@ static ssize_t max517_show_scale(struct device *dev, struct device_attribute *attr, char *buf, int channel) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct max517_data *data = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct max517_data *data = iio_priv(indio_dev); /* Corresponds to Vref / 2^(bits) */ unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8; diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index e6cfa649e8c..aefcab1c3fe 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c @@ -77,8 +77,8 @@ static ssize_t ad9832_write(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9832_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9832_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; long val; @@ -87,7 +87,7 @@ static ssize_t ad9832_write(struct device *dev, if (ret) goto error_ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD9832_FREQ0HM: case AD9832_FREQ1HM: @@ -148,7 +148,7 @@ static ssize_t ad9832_write(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); error_ret: return ret ? ret : len; diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index a5b5aedd769..fe461199801 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -66,8 +66,8 @@ static ssize_t ad9834_write(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; long val; @@ -76,7 +76,7 @@ static ssize_t ad9834_write(struct device *dev, if (ret) goto error_ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD9834_REG_FREQ0: case AD9834_REG_FREQ1: @@ -134,7 +134,7 @@ static ssize_t ad9834_write(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); error_ret: return ret ? ret : len; @@ -145,13 +145,13 @@ static ssize_t ad9834_store_wavetype(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret = 0; bool is_ad9833_7 = (st->devid == ID_AD9833) || (st->devid == ID_AD9837); - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case 0: @@ -194,7 +194,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev, st->data = cpu_to_be16(AD9834_REG_CMD | st->control); ret = spi_sync(st->spi, &st->msg); } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -203,8 +203,8 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); char *str; if ((st->devid == ID_AD9833) || (st->devid == ID_AD9837)) @@ -225,8 +225,8 @@ static ssize_t ad9834_show_out1_wavetype_available(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); char *str; if (st->control & AD9834_MODE) @@ -285,8 +285,8 @@ static mode_t ad9834_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); mode_t mode = attr->mode; diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index dc0f9835e73..e7ef3b27388 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -260,8 +260,8 @@ static ssize_t ad5933_show_frequency(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; unsigned long long freqreg; @@ -270,9 +270,9 @@ static ssize_t ad5933_show_frequency(struct device *dev, u8 d8[4]; } dat; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad5933_i2c_read(st->client, this_attr->address, 3, &dat.d8[1]); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; @@ -289,8 +289,8 @@ static ssize_t ad5933_store_frequency(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); long val; int ret; @@ -302,9 +302,9 @@ static ssize_t ad5933_store_frequency(struct device *dev, if (val > AD5933_MAX_OUTPUT_FREQ_Hz) return -EINVAL; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); ret = ad5933_set_freq(st, this_attr->address, val); - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -323,12 +323,12 @@ static ssize_t ad5933_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret = 0, len = 0; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD5933_OUT_RANGE: len = sprintf(buf, "%d\n", @@ -357,7 +357,7 @@ static ssize_t ad5933_show(struct device *dev, ret = -EINVAL; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -366,8 +366,8 @@ static ssize_t ad5933_store(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad5933_state *st = iio_priv(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5933_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); long val; int i, ret = 0; @@ -379,7 +379,7 @@ static ssize_t ad5933_store(struct device *dev, return ret; } - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD5933_OUT_RANGE: for (i = 0; i < 4; i++) @@ -428,7 +428,7 @@ static ssize_t ad5933_store(struct device *dev, ret = -EINVAL; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -483,20 +483,20 @@ static const struct attribute_group ad5933_attribute_group = { .attrs = ad5933_attributes, }; -static int ad5933_read_raw(struct iio_dev *dev_info, +static int ad5933_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { - struct ad5933_state *st = iio_priv(dev_info); + struct ad5933_state *st = iio_priv(indio_dev); unsigned short dat; int ret = -EINVAL; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (m) { case 0: - if (iio_buffer_enabled(dev_info)) { + if (iio_buffer_enabled(indio_dev)) { ret = -EBUSY; goto out; } @@ -512,7 +512,7 @@ static int ad5933_read_raw(struct iio_dev *dev_info, (u8 *)&dat); if (ret < 0) goto out; - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); ret = be16_to_cpu(dat); /* Temp in Milli degrees Celsius */ if (ret < 8192) @@ -524,7 +524,7 @@ static int ad5933_read_raw(struct iio_dev *dev_info, } out: - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret; } From a45186c0cdd35e6b79aeeff6e535c5d5c20ac93d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 7 Oct 2011 10:31:42 +0200 Subject: [PATCH 1391/1519] staging:iio:dac:ad5638: Fix channel address Commit c6fc806247 ("staging:iio: ABI rework - add in_ or out_ prefix to channnels") added the AD5868_CHANNEL macro to simplify channel initialization. Unfortunately the macro hardcodes the channel's address to AD5686_ADDR_DAC0. As a result writing to any of the channels will change the value of the first channel. This patch fixes the issue by calculating the channel address based on the channel number. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5686.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index b55ef42a18b..adf898f2492 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -26,10 +26,7 @@ #define AD5686_ADDR(x) ((x) << 16) #define AD5686_CMD(x) ((x) << 20) -#define AD5686_ADDR_DAC0 0x1 -#define AD5686_ADDR_DAC1 0x2 -#define AD5686_ADDR_DAC2 0x4 -#define AD5686_ADDR_DAC3 0x8 +#define AD5686_ADDR_DAC(chan) (0x1 << (chan)) #define AD5686_ADDR_ALL_DAC 0xF #define AD5686_CMD_NOOP 0x0 @@ -103,7 +100,7 @@ enum ad5686_supported_device_ids { .output = 1, \ .channel = chan, \ .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ - .address = AD5686_ADDR_DAC0, \ + .address = AD5686_ADDR_DAC(chan), \ .scan_type = IIO_ST('u', bits, 16, shift) \ } static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { From aa3e842d2c27acd3e73167eef5a347601639f2cb Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Thu, 6 Oct 2011 14:04:14 +0200 Subject: [PATCH 1392/1519] easycap: fix ntsc module parameter description Cc: Mike Thomas Signed-off-by: Thomas Petazzoni Acked-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/easycap_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 3ea51c37391..17444a72ec9 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -58,7 +58,7 @@ MODULE_PARM_DESC(gain, "Audio gain: 0,...,16(default),...31"); static bool easycap_ntsc; module_param_named(ntsc, easycap_ntsc, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(ntsc, "NTCS default encoding (default PAL)"); +MODULE_PARM_DESC(ntsc, "NTSC default encoding (default PAL)"); From 5ba321cf175192259ea0b3cc2322986cf1194fee Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 6 Oct 2011 09:17:38 +0300 Subject: [PATCH 1393/1519] Staging: dt3155v4l: silence a compiler warning The '!' is dead code that was left over from a previous version. It causes a compiler warning: drivers/staging/dt3155v4l/dt3155v4l.c:335:3: warning: value computed is not used Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155v4l/dt3155v4l.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c index 05b6a2a31ac..5b212dc725e 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -331,7 +331,7 @@ dt3155_irq_handler_even(int irq, void *dev_id) return IRQ_HANDLED; /* start of field irq */ } if ((tmp & FLD_START) && (tmp & FLD_END_ODD)) - !ipd->stats.start_before_end++; + ipd->stats.start_before_end++; /* check for corrupted fields */ /* write_i2c_reg(ipd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); */ /* write_i2c_reg(ipd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); */ From 8550be08cbed164a8357491cc2c27cb99282b7ff Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Thu, 6 Oct 2011 14:28:26 -0500 Subject: [PATCH 1394/1519] staging: zcache: fix crash on cpu remove In the case that a cpu is taken offline before zcache_do_preload() is ever called on the cpu, the per-cpu zcache_preloads structure will be uninitialized. In the CPU_DEAD case for zcache_cpu_notifier(), kp->obj is not checked before calling kmem_cache_free() on it. If it is NULL, a crash results. This patch ensures that both kp->obj and kp->page are not NULL before calling the respective free functions. In practice, just checking one or the other should be sufficient since they are assigned together in zcache_do_preload(), but I check both for safety. Signed-off-by: Seth Jennings Acked-by: Dave Hansen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/zcache-main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index fbb400193e9..dae2f4ee06a 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -1357,8 +1357,14 @@ static int zcache_cpu_notifier(struct notifier_block *nb, kp->objnodes[kp->nr - 1] = NULL; kp->nr--; } - kmem_cache_free(zcache_obj_cache, kp->obj); - free_page((unsigned long)kp->page); + if (kp->obj) { + kmem_cache_free(zcache_obj_cache, kp->obj); + kp->obj = NULL; + } + if (kp->page) { + free_page((unsigned long)kp->page); + kp->page = NULL; + } break; default: break; From 447ff8865209e48e231de804c47eb4677f2318be Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 8 Oct 2011 14:01:06 -0500 Subject: [PATCH 1395/1519] staging: r8712u: Fix possible out-of-bounds index with TKIP and AES keys Array XGrpKey has only 2 elements and uses (keyid - 1) as the index, which allows the possibility of memory corruption from an out-of-bounds index. This problem was reported by a new version of smatch. Reported-by: Dan Carpenter Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index c475b961308..ef8eb6c7ee4 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1281,12 +1281,16 @@ sint r8712_set_key(struct _adapter *adapter, psecuritypriv->DefKey[keyid].skey, keylen); break; case _TKIP_: + if (keyid < 1 || keyid > 2) + return _FAIL; keylen = 16; memcpy(psetkeyparm->key, &psecuritypriv->XGrpKey[keyid - 1], keylen); psetkeyparm->grpkey = 1; break; case _AES_: + if (keyid < 1 || keyid > 2) + return _FAIL; keylen = 16; memcpy(psetkeyparm->key, &psecuritypriv->XGrpKey[keyid - 1], keylen); From a9bd8ddad637f957d3b5f0bde31417e0c97c9c2f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Fri, 7 Oct 2011 22:51:27 +0100 Subject: [PATCH 1396/1519] staging: et131x: Removing Olaf Hartmann's email as it bounces On 3 October 2011 18:51, Uwe Ranft wrote: > Hello, > olaf is not more longer owner of this e-mailadress. he has left our > company. > Please remove olaf fron the mailing list! > Best Regards > Uwe Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index b262ec7df1d..d383e80fe8a 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -2,7 +2,7 @@ This is a driver for the ET1310 network device. Based on the driver found at https://sourceforge.net/projects/et131x/ -Cleaned up immensely by Olaf Hartman and Christoph +Cleaned up immensely by Olaf Hartman and Christoph Hellwig Note, the powermanagement options were removed from the vendor provided @@ -14,6 +14,3 @@ Please send patches to: Greg Kroah-Hartman Mark Einon -And Cc: Olaf Hartmann as he has this device and can -test any changes. - From a75fc17aaa52d4fa7a6bc619a094e542beafac3e Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Fri, 7 Oct 2011 22:52:50 +0100 Subject: [PATCH 1397/1519] staging: et131x: Remove error path from suspend/resume code Removing an error path from et131x suspend/resume functions. Also added a call to phy_stop() to complement the phy_start() call during device start/stop routine. Thanks to Francois Romieu for pointing this out. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.h | 2 ++ drivers/staging/et131x/et131x_initpci.c | 35 ++++++++-------------- drivers/staging/et131x/et131x_netdev.c | 40 +++++++++++++++++++------ 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index c8f5ab14b6f..e83223468f7 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -85,6 +85,8 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ int et131x_open(struct net_device *netdev); int et131x_close(struct net_device *netdev); +void et131x_up(struct net_device *netdev); +void et131x_down(struct net_device *netdev); struct net_device *et131x_device_alloc(void); void et131x_enable_txrx(struct net_device *netdev); void et131x_disable_txrx(struct net_device *netdev); diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 9795310fa71..95a1aff3332 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -874,14 +874,12 @@ static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *netdev = pci_get_drvdata(pdev); - if (!netif_running(netdev)) - return 0; - - et131x_close(netdev); - netif_device_detach(netdev); - - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + if (netif_running(netdev)) { + netif_device_detach(netdev); + et131x_down(netdev); + pci_save_state(pdev); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); + } return 0; } @@ -889,24 +887,15 @@ static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state) static int et131x_pci_resume(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); - int err = 0; - if (!netif_running(netdev)) - return 0; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - err = et131x_open(netdev); - if (err) { - dev_err(&pdev->dev, "Can't resume interface!\n"); - goto out; + if (netif_running(netdev)) { + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + et131x_up(netdev); + netif_device_attach(netdev); } - netif_device_attach(netdev); - -out: - return err; + return 0; } static struct pci_device_id et131x_pci_table[] __devinitdata = { diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 79127deebfc..16373bb9f88 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -177,6 +177,18 @@ void et131x_disable_txrx(struct net_device *netdev) et131x_disable_interrupts(adapter); } +/** + * et131x_up - Bring up a device for use. + * @netdev: device to be opened + */ +void et131x_up(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + et131x_enable_txrx(netdev); + phy_start(adapter->phydev); +} + /** * et131x_open - Open the device for use. * @netdev: device to be opened @@ -205,12 +217,27 @@ int et131x_open(struct net_device *netdev) } adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; - et131x_enable_txrx(netdev); - phy_start(adapter->phydev); + + et131x_up(netdev); return result; } +/** + * et131x_down - Bring down the device + * @netdev: device to be broght down + */ +void et131x_down(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Save the timestamp for the TX watchdog, prevent a timeout */ + netdev->trans_start = jiffies; + + phy_stop(adapter->phydev); + et131x_disable_txrx(netdev); +} + /** * et131x_close - Close the device * @netdev: device to be closed @@ -221,18 +248,13 @@ int et131x_close(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); - /* Save the timestamp for the TX watchdog, prevent a timeout */ - netdev->trans_start = jiffies; + et131x_down(netdev); - et131x_disable_txrx(netdev); - - /* Deregistering ISR */ adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; free_irq(netdev->irq, netdev); /* Stop the error timer */ - del_timer_sync(&adapter->error_timer); - return 0; + return del_timer_sync(&adapter->error_timer); } /** From f247be5d6b5bf5378a9cfec2e315b1ae913f8f0d Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Fri, 7 Oct 2011 22:52:51 +0100 Subject: [PATCH 1398/1519] staging: et131x: Move pm calls from pci device to driver device Move the pci driver suspend/resume calls up to the driver.pm ops structure, as they are not pci device specific. Thanks to Francois Romieu for pointing this out. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_initpci.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 95a1aff3332..2f03ba0437e 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -870,26 +870,27 @@ static void __devexit et131x_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } -static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int et131x_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct net_device *netdev = pci_get_drvdata(pdev); if (netif_running(netdev)) { netif_device_detach(netdev); et131x_down(netdev); pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); } return 0; } -static int et131x_pci_resume(struct pci_dev *pdev) +static int et131x_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct net_device *netdev = pci_get_drvdata(pdev); if (netif_running(netdev)) { - pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); et131x_up(netdev); netif_device_attach(netdev); @@ -898,6 +899,12 @@ static int et131x_pci_resume(struct pci_dev *pdev) return 0; } +static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); +#define ET131X_PM_OPS (&et131x_pm_ops) +#else +#define ET131X_PM_OPS NULL +#endif + static struct pci_device_id et131x_pci_table[] __devinitdata = { {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL}, @@ -913,10 +920,7 @@ static struct pci_driver et131x_driver = { .id_table = et131x_pci_table, .probe = et131x_pci_setup, .remove = __devexit_p(et131x_pci_remove), -#ifdef CONFIG_PM - .suspend = et131x_pci_suspend, - .resume = et131x_pci_resume, -#endif + .driver.pm = ET131X_PM_OPS, }; /** From b6f4160c4e5a1565fbb06976233e6482c16a489c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Fri, 7 Oct 2011 22:53:56 +0100 Subject: [PATCH 1399/1519] staging: et131x: Remove file et131x_version.h Removed defines in et131x_version.h and replaced them by actual strings where convinient, or moved them to et131x.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_eeprom.c | 1 - drivers/staging/et131x/et1310_mac.c | 1 - drivers/staging/et131x/et1310_phy.c | 1 - drivers/staging/et131x/et1310_pm.c | 1 - drivers/staging/et131x/et1310_rx.c | 1 - drivers/staging/et131x/et1310_tx.c | 1 - drivers/staging/et131x/et131x.h | 3 + drivers/staging/et131x/et131x_ethtool.c | 4 +- drivers/staging/et131x/et131x_initpci.c | 11 ++-- drivers/staging/et131x/et131x_isr.c | 1 - drivers/staging/et131x/et131x_netdev.c | 1 - drivers/staging/et131x/et131x_version.h | 75 ------------------------- 12 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 drivers/staging/et131x/et131x_version.h diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c index 747b1dc803b..20b96605e4c 100644 --- a/drivers/staging/et131x/et1310_eeprom.c +++ b/drivers/staging/et131x/et1310_eeprom.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index b4c9df195a2..017ece7e24c 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 145ec765bea..b809dd4e527 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c index a1b72bf8467..91d47dc2ccd 100644 --- a/drivers/staging/et131x/et1310_pm.c +++ b/drivers/staging/et131x/et1310_pm.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 600a8f10da8..814922bbff0 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index 2ecb934a55b..cd12500a265 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index e83223468f7..24570ca8039 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -48,6 +48,9 @@ * */ +#define DRIVER_NAME "et131x" +#define DRIVER_VERSION "v2.0" + /* et131x_eeprom.c */ int et131x_init_eeprom(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c index 903b5a0ad85..ff95a3e8cb0 100644 --- a/drivers/staging/et131x/et131x_ethtool.c +++ b/drivers/staging/et131x/et131x_ethtool.c @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "et131x_version.h" + #include "et131x_defs.h" #include @@ -181,7 +181,7 @@ static void et131x_get_drvinfo(struct net_device *netdev, struct et131x_adapter *adapter = netdev_priv(netdev); strncpy(info->driver, DRIVER_NAME, ET131X_DRVINFO_LEN); - strncpy(info->version, DRIVER_VERSION_STRING, ET131X_DRVINFO_LEN); + strncpy(info->version, DRIVER_VERSION, ET131X_DRVINFO_LEN); strncpy(info->bus_info, pci_name(adapter->pdev), ET131X_DRVINFO_LEN); } diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 2f03ba0437e..33e50e90b10 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -59,7 +59,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include @@ -944,8 +943,8 @@ static void __exit et131x_cleanup_module(void) module_init(et131x_init_module); module_exit(et131x_cleanup_module); -/* Modinfo parameters (filled out using defines from et131x_version.h) */ -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_AUTHOR(DRIVER_AUTHOR2); -MODULE_DESCRIPTION(DRIVER_INFO); -MODULE_LICENSE(DRIVER_LICENSE); +MODULE_AUTHOR("Victor Soriano "); +MODULE_AUTHOR("Mark Einon "); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " + "for the ET1310 by Agere Systems"); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index bccd0e53323..cf8665b1291 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -58,7 +58,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 16373bb9f88..bcb4756c75d 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -57,7 +57,6 @@ * */ -#include "et131x_version.h" #include "et131x_defs.h" #include diff --git a/drivers/staging/et131x/et131x_version.h b/drivers/staging/et131x/et131x_version.h deleted file mode 100644 index c08b5e588d2..00000000000 --- a/drivers/staging/et131x/et131x_version.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - *------------------------------------------------------------------------------ - * - * et131x_version.h - This file provides system and device version information. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef __ET131X_VERSION_H__ -#define __ET131X_VERSION_H__ - -#define DRIVER_AUTHOR "Victor Soriano (vjsoriano@agere.com)" -#define DRIVER_AUTHOR2 "Mark Einon (mark.einon@gmail.com)" -#define DRIVER_LICENSE "Dual BSD/GPL" -#define DRIVER_DEVICE_STRING "ET1310" -#define DRIVER_NAME "et131x" -#define DRIVER_VERSION_STRING "1.2.3-lk" -#define DRIVER_VENDOR "Agere Systems, http://www.agere.com" -#define DRIVER_DESC "10/100/1000 Base-T Ethernet Driver" - -#define DRIVER_INFO DRIVER_DESC " for the "\ - DRIVER_DEVICE_STRING ", v" \ - DRIVER_VERSION_STRING " by " \ - DRIVER_VENDOR - -#endif /* __ET131X_VERSION_H__ */ From 6617c3698778ae896deb89804f7ba8efb4d2252d Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 10 Oct 2011 16:21:11 +0100 Subject: [PATCH 1400/1519] staging: et131x: Fix et131x sparse warnings This fixes the following warnings: et1310_mac.c:375:44: warning: incorrect type in initializer (different address spaces) et1310_mac.c:382:28: warning: incorrect type in argument 2 (different address spaces) et1310_mac.c:384:31: warning: incorrect type in argument 2 (different address spaces) et131x_initpci.c:555:5: warning: symbol 'et131x_mii_probe' was not declared. Should it be static? et131x_netdev.c:267:5: warning: symbol 'et131x_ioctl' was not declared. Should it be static? et131x_netdev.c:285:5: warning: symbol 'et131x_set_packet_filter' was not declared. Should it be static? et131x_netdev.c:347:6: warning: symbol 'et131x_multicast' was not declared. Should it be static? et131x_netdev.c:420:5: warning: symbol 'et131x_tx' was not declared. Should it be static? et131x_netdev.c:453:6: warning: symbol 'et131x_tx_timeout' was not declared. Should it be static? et131x_netdev.c:511:5: warning: symbol 'et131x_change_mtu' was not declared. Should it be static? et131x_netdev.c:564:5: warning: symbol 'et131x_set_mac_addr' was not declared. Should it be static? Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 2 +- drivers/staging/et131x/et131x_initpci.c | 2 +- drivers/staging/et131x/et131x_netdev.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 017ece7e24c..042bc44f9ff 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -372,7 +372,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter) void et1310_config_txmac_regs(struct et131x_adapter *adapter) { - struct txmac_regs *txmac = &adapter->regs->txmac; + struct txmac_regs __iomem *txmac = &adapter->regs->txmac; /* We need to update the Control Frame Parameters * cfpt - control frame pause timer set to 64 (0x40) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 33e50e90b10..9b2dc55ecbe 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -552,7 +552,7 @@ static void et131x_adjust_link(struct net_device *netdev) } } -int et131x_mii_probe(struct net_device *netdev) +static int et131x_mii_probe(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); struct phy_device *phydev = NULL; diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index bcb4756c75d..62070cff76f 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -264,7 +264,7 @@ int et131x_close(struct net_device *netdev) * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) +static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) { struct et131x_adapter *adapter = netdev_priv(netdev); @@ -282,7 +282,7 @@ int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) * * Returns 0 on success, errno on failure */ -int et131x_set_packet_filter(struct et131x_adapter *adapter) +static int et131x_set_packet_filter(struct et131x_adapter *adapter) { int status = 0; uint32_t filter = adapter->packet_filter; @@ -344,7 +344,7 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter) * et131x_multicast - The handler to configure multicasting on the interface * @netdev: a pointer to a net_device struct representing the device */ -void et131x_multicast(struct net_device *netdev) +static void et131x_multicast(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); uint32_t packet_filter = 0; @@ -417,7 +417,7 @@ void et131x_multicast(struct net_device *netdev) * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_tx(struct sk_buff *skb, struct net_device *netdev) +static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) { int status = 0; @@ -450,7 +450,7 @@ int et131x_tx(struct sk_buff *skb, struct net_device *netdev) * specified by the 'tx_timeo" element in the net_device structure (see * et131x_alloc_device() to see how this value is set). */ -void et131x_tx_timeout(struct net_device *netdev) +static void et131x_tx_timeout(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); struct tcb *tcb; @@ -508,7 +508,7 @@ void et131x_tx_timeout(struct net_device *netdev) * * Returns 0 on success, errno on failure (as defined in errno.h) */ -int et131x_change_mtu(struct net_device *netdev, int new_mtu) +static int et131x_change_mtu(struct net_device *netdev, int new_mtu) { int result = 0; struct et131x_adapter *adapter = netdev_priv(netdev); @@ -561,7 +561,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) * * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14 */ -int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) +static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) { int result = 0; struct et131x_adapter *adapter = netdev_priv(netdev); From 33fd472ee7b98ac187f0fcee33d97a187bdbaa08 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 10 Oct 2011 16:21:12 +0100 Subject: [PATCH 1401/1519] staging: et131x: Fix et131x smatch issues This fixes the following issues: et131x_initpci.c +488 et131x_adjust_link(45) error: we previously assumed 'phydev' could be null. et131x_initpci.c +504 et131x_adjust_link(61) warn: variable dereferenced before check 'phydev' Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x_initpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 9b2dc55ecbe..45ce8321f31 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -485,7 +485,7 @@ static void et131x_adjust_link(struct net_device *netdev) et1310_config_mac_regs2(adapter); } - if (phydev->link != adapter->link) { + if (phydev && phydev->link != adapter->link) { /* * Check to see if we are in coma mode and if * so, disable it because we will not be able @@ -501,7 +501,7 @@ static void et131x_adjust_link(struct net_device *netdev) "Link down - cable problem ?\n"); adapter->boot_coma = 0; - if (phydev && phydev->speed == SPEED_10) { + if (phydev->speed == SPEED_10) { /* NOTE - Is there a way to query this without * TruePHY? * && TRU_QueryCoreType(adapter->hTruePhy, 0) == From a7203d58cb3b7c1e7dcee08ff70b97fe07ca5d54 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 10 Oct 2011 16:22:09 +0100 Subject: [PATCH 1402/1519] staging: et131x: Remove unused mac defines Remove some unused defines from et1310_mac.c. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_mac.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 042bc44f9ff..65179a364b7 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c @@ -89,17 +89,9 @@ #include "et131x_adapter.h" #include "et131x.h" - -#define COUNTER_WRAP_28_BIT 0x10000000 -#define COUNTER_WRAP_22_BIT 0x400000 #define COUNTER_WRAP_16_BIT 0x10000 #define COUNTER_WRAP_12_BIT 0x1000 -#define COUNTER_MASK_28_BIT (COUNTER_WRAP_28_BIT - 1) -#define COUNTER_MASK_22_BIT (COUNTER_WRAP_22_BIT - 1) -#define COUNTER_MASK_16_BIT (COUNTER_WRAP_16_BIT - 1) -#define COUNTER_MASK_12_BIT (COUNTER_WRAP_12_BIT - 1) - /** * et1310_config_mac_regs1 - Initialize the first part of MAC regs * @adapter: pointer to our adapter structure From a0985821014a01db77d4401d3a965ad85cefb4c0 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Mon, 10 Oct 2011 16:22:32 +0100 Subject: [PATCH 1403/1519] staging: et131x: Update TODO list Added some more tasks to the TODO list, as highlighted by Francois Romieu . Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index d383e80fe8a..c67f83ebfc0 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -2,13 +2,18 @@ This is a driver for the ET1310 network device. Based on the driver found at https://sourceforge.net/projects/et131x/ -Cleaned up immensely by Olaf Hartman and Christoph -Hellwig +Cleaned up immensely by Olaf Hartman and Christoph Hellwig Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: + - Put the driver into a single file, with a .h for the registers layout. + - rx_ring.fbr{0, 1} can probably share a common structure + - Use of kmem_cache seems a bit unusual + - Use dma_alloc_... in place of pci_alloc_... + - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet. + - PCI_VDEVICE ? Please send patches to: Greg Kroah-Hartman From 6a4ef5f9b39cc84550d2f031d3546d67c6584d90 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Fri, 7 Oct 2011 18:50:09 -0400 Subject: [PATCH 1404/1519] Staging: bcm: Fix coding style issues reported by checkpatch.pl This patch cleans up several hundred code style issues found in Misc.c reported by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Misc.c | 1803 ++++++++++++++++-------------------- 1 file changed, 776 insertions(+), 1027 deletions(-) diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 9da94086987..2bf942458e0 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -1,113 +1,94 @@ #include "headers.h" -static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, - unsigned int loc); +static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc); static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter); -static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer); +static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer); static int bcm_parse_target_params(PMINI_ADAPTER Adapter); -static void beceem_protocol_reset (PMINI_ADAPTER Adapter); +static void beceem_protocol_reset(PMINI_ADAPTER Adapter); static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter) { + UINT uiLoopIndex; - UINT uiLoopIndex; + for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) { + Adapter->PackInfo[uiLoopIndex].uiThreshold = TX_PACKET_THRESHOLD; + Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate = MAX_ALLOWED_RATE; + Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize = 20*1024*1024; + } - for(uiLoopIndex=0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) - { - Adapter->PackInfo[uiLoopIndex].uiThreshold=TX_PACKET_THRESHOLD; - Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate=MAX_ALLOWED_RATE; - Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize=20*1024*1024; - } - - Adapter->BEBucketSize=BE_BUCKET_SIZE; - Adapter->rtPSBucketSize=rtPS_BUCKET_SIZE; - Adapter->LinkStatus=SYNC_UP_REQUEST; - Adapter->TransferMode=IP_PACKET_ONLY_MODE; - Adapter->usBestEffortQueueIndex=-1; - return; + Adapter->BEBucketSize = BE_BUCKET_SIZE; + Adapter->rtPSBucketSize = rtPS_BUCKET_SIZE; + Adapter->LinkStatus = SYNC_UP_REQUEST; + Adapter->TransferMode = IP_PACKET_ONLY_MODE; + Adapter->usBestEffortQueueIndex = -1; + return; } - -INT -InitAdapter(PMINI_ADAPTER psAdapter) +INT InitAdapter(PMINI_ADAPTER psAdapter) { - int i = 0; - INT Status = STATUS_SUCCESS ; - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter); + int i = 0; + INT Status = STATUS_SUCCESS; + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter); - if(psAdapter == NULL) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL"); + if (psAdapter == NULL) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL"); return -EINVAL; } - sema_init(&psAdapter->NVMRdmWrmLock,1); -// psAdapter->ulFlashCalStart = FLASH_AUTO_INIT_BASE_ADDR; - + sema_init(&psAdapter->NVMRdmWrmLock, 1); sema_init(&psAdapter->rdmwrmsync, 1); spin_lock_init(&psAdapter->control_queue_lock); spin_lock_init(&psAdapter->txtransmitlock); - sema_init(&psAdapter->RxAppControlQueuelock, 1); -// sema_init(&psAdapter->data_packet_queue_lock, 1); - sema_init(&psAdapter->fw_download_sema, 1); - sema_init(&psAdapter->LowPowerModeSync,1); + sema_init(&psAdapter->RxAppControlQueuelock, 1); + sema_init(&psAdapter->fw_download_sema, 1); + sema_init(&psAdapter->LowPowerModeSync, 1); - // spin_lock_init(&psAdapter->sleeper_lock); + for (i = 0; i < NO_OF_QUEUES; i++) + spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock); + i = 0; - for(i=0;iPackInfo[i].SFQueueLock); - i=0; - - init_waitqueue_head(&psAdapter->process_rx_cntrlpkt); - init_waitqueue_head(&psAdapter->tx_packet_wait_queue); - init_waitqueue_head(&psAdapter->process_read_wait_queue); - init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); - init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); + init_waitqueue_head(&psAdapter->process_rx_cntrlpkt); + init_waitqueue_head(&psAdapter->tx_packet_wait_queue); + init_waitqueue_head(&psAdapter->process_read_wait_queue); + init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); + init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); psAdapter->waiting_to_fw_download_done = TRUE; - //init_waitqueue_head(&psAdapter->device_wake_queue); - psAdapter->fw_download_done=FALSE; - + psAdapter->fw_download_done = FALSE; default_wimax_protocol_initialize(psAdapter); - for (i=0;itxctlpacket[i] = kmalloc(MAX_CNTL_PKT_SIZE, GFP_KERNEL); - if(!psAdapter->txctlpacket[i]) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); + if (!psAdapter->txctlpacket[i]) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); return -ENOMEM; } } - if(AllocAdapterDsxBuffer(psAdapter)) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers"); + + if (AllocAdapterDsxBuffer(psAdapter)) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers"); return -EINVAL; } - //Initialize PHS interface - if(phs_init(&psAdapter->stBCMPhsContext,psAdapter)!=0) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__); + /* Initialize PHS interface */ + if (phs_init(&psAdapter->stBCMPhsContext, psAdapter) != 0) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__); return -ENOMEM; } Status = BcmAllocFlashCSStructure(psAdapter); - if(Status) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Memory Allocation for Flash structure failed"); - return Status ; + if (Status) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Memory Allocation for Flash structure failed"); + return Status; } Status = vendorextnInit(psAdapter); - if(STATUS_SUCCESS != Status) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Vendor Init Failed"); - return Status ; + if (STATUS_SUCCESS != Status) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Vendor Init Failed"); + return Status; } - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised"); - + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised"); return STATUS_SUCCESS; } @@ -115,42 +96,37 @@ InitAdapter(PMINI_ADAPTER psAdapter) VOID AdapterFree(PMINI_ADAPTER Adapter) { int count; - beceem_protocol_reset(Adapter); - vendorextnExit(Adapter); - if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) - kthread_stop (Adapter->control_packet_handler); + if (Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) + kthread_stop(Adapter->control_packet_handler); - if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) - kthread_stop (Adapter->transmit_packet_thread); + if (Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) + kthread_stop(Adapter->transmit_packet_thread); wake_up(&Adapter->process_read_wait_queue); - if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) - kthread_stop (Adapter->LEDInfo.led_cntrl_threadid); + if (Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) + kthread_stop(Adapter->LEDInfo.led_cntrl_threadid); unregister_networkdev(Adapter); /* FIXME: use proper wait_event and refcounting */ - while(atomic_read(&Adapter->ApplicationRunning)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning)); + while (atomic_read(&Adapter->ApplicationRunning)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n", atomic_read(&Adapter->ApplicationRunning)); msleep(100); } unregister_control_device_interface(Adapter); - kfree(Adapter->pstargetparams); - for (count =0;count < MAX_CNTRL_PKTS;count++) + for (count = 0; count < MAX_CNTRL_PKTS; count++) kfree(Adapter->txctlpacket[count]); FreeAdapterDsxBuffer(Adapter); - kfree(Adapter->pvInterfaceAdapter); - //Free the PHS Interface + /* Free the PHS Interface */ PhsCleanup(&Adapter->stBCMPhsContext); BcmDeAllocFlashCSStructure(Adapter); @@ -160,20 +136,18 @@ VOID AdapterFree(PMINI_ADAPTER Adapter) static int create_worker_threads(PMINI_ADAPTER psAdapter) { - // Rx Control Packets Processing + /* Rx Control Packets Processing */ psAdapter->control_packet_handler = kthread_run((int (*)(void *)) control_packet_handler, psAdapter, "%s-rx", DRV_NAME); - if(IS_ERR(psAdapter->control_packet_handler)) - { + if (IS_ERR(psAdapter->control_packet_handler)) { pr_notice(DRV_NAME ": could not create control thread\n"); return PTR_ERR(psAdapter->control_packet_handler); } - // Tx Thread + /* Tx Thread */ psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) tx_pkt_handler, psAdapter, "%s-tx", DRV_NAME); - if(IS_ERR (psAdapter->transmit_packet_thread)) - { + if (IS_ERR(psAdapter->transmit_packet_thread)) { pr_notice(DRV_NAME ": could not creat transmit thread\n"); kthread_stop(psAdapter->control_packet_handler); return PTR_ERR(psAdapter->transmit_packet_thread); @@ -183,241 +157,213 @@ static int create_worker_threads(PMINI_ADAPTER psAdapter) static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path) { - struct file *flp=NULL; - mm_segment_t oldfs; - oldfs=get_fs(); + struct file *flp = NULL; + mm_segment_t oldfs; + oldfs = get_fs(); set_fs(get_ds()); - flp=filp_open(path, O_RDONLY, S_IRWXU); - set_fs(oldfs); - if(IS_ERR(flp)) - { - pr_err(DRV_NAME "Unable To Open File %s, err %ld", - path, PTR_ERR(flp)); - flp = NULL; - } + flp = filp_open(path, O_RDONLY, S_IRWXU); + set_fs(oldfs); + if (IS_ERR(flp)) { + pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp)); + flp = NULL; + } - if(Adapter->device_removed) - flp = NULL; + if (Adapter->device_removed) + flp = NULL; - return flp; + return flp; } - -static int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ - const char *path, /**< path to image file */ - unsigned int loc /**< Download Address on the chip*/ - ) +/* Arguments: + * Logical Adapter + * Path to image file + * Download Address on the chip + */ +static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc) { - int errorno=0; - struct file *flp=NULL; - mm_segment_t oldfs; - struct timeval tv={0}; + int errorno = 0; + struct file *flp = NULL; + mm_segment_t oldfs; + struct timeval tv = {0}; - flp=open_firmware_file(Adapter, path); - if(!flp) - { - errorno = -ENOENT; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); - goto exit_download; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path,(unsigned long)flp->f_dentry->d_inode->i_size, loc); - do_gettimeofday(&tv); + flp = open_firmware_file(Adapter, path); + if (!flp) { + errorno = -ENOENT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); + goto exit_download; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)flp->f_dentry->d_inode->i_size, loc); + do_gettimeofday(&tv); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + - (tv.tv_usec/1000))); - if(Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error\ - %x!!!", -EIO); - errorno=-EIO; - goto exit_download; - } - oldfs=get_fs();set_fs(get_ds()); - vfs_llseek(flp, 0, 0); - set_fs(oldfs); - if(Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, - flp, loc)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); - errorno=-EIO; - goto exit_download; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + (tv.tv_usec / 1000))); + if (Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error %x!!!", -EIO); + errorno = -EIO; + goto exit_download; + } + oldfs = get_fs(); + set_fs(get_ds()); + vfs_llseek(flp, 0, 0); + set_fs(oldfs); + if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); + errorno = -EIO; + goto exit_download; + } exit_download: - oldfs=get_fs();set_fs(get_ds()); - if(flp && !(IS_ERR(flp))) - filp_close(flp, current->files); - set_fs(oldfs); + oldfs = get_fs(); + set_fs(get_ds()); + if (flp && !(IS_ERR(flp))) + filp_close(flp, current->files); + set_fs(oldfs); - return errorno; + return errorno; } /** -@ingroup ctrl_pkt_functions -This function copies the contents of given buffer -to the control packet and queues it for transmission. -@note Do not acquire the spinock, as it it already acquired. -@return SUCCESS/FAILURE. -*/ -INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**"); - if(!ioBuffer) - { - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Got Null Buffer\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>"); + if (!ioBuffer) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got Null Buffer\n"); return -EINVAL; } pLinkReq = (PLINK_REQUEST)ioBuffer; - pLeader=(PLEADER)ioBuffer; //ioBuffer Contains sw_Status and Payload + pLeader = (PLEADER)ioBuffer; /* ioBuffer Contains sw_Status and Payload */ - if(Adapter->bShutStatus == TRUE && + if (Adapter->bShutStatus == TRUE && pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD && - pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) - { - //Got sync down in SHUTDOWN..we could not process this. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n"); + pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) { + + /* Got sync down in SHUTDOWN..we could not process this. */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n"); return STATUS_FAILURE; } - if((pLeader->Status == LINK_UP_CONTROL_REQ) && + if ((pLeader->Status == LINK_UP_CONTROL_REQ) && ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD && - (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) ||//Sync Up Command - pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) //Net Entry Command - { - if(Adapter->LinkStatus > PHY_SYNC_ACHIVED) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"LinkStatus is Greater than PHY_SYN_ACHIEVED"); + (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) || /* Sync Up Command */ + pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) /* Net Entry Command */ { + + if (Adapter->LinkStatus > PHY_SYNC_ACHIVED) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "LinkStatus is Greater than PHY_SYN_ACHIEVED"); return STATUS_FAILURE; } - if(TRUE == Adapter->bShutStatus) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); - if(Adapter->bTriedToWakeUpFromlowPowerMode == FALSE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Waking up for the First Time..\n"); - Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; // change it to 1 for current support. + + if (TRUE == Adapter->bShutStatus) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); + if (Adapter->bTriedToWakeUpFromlowPowerMode == FALSE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Waking up for the First Time..\n"); + Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; /* change it to 1 for current support. */ Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); + Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->bShutStatus, (5 * HZ)); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->bShutStatus, (5 * HZ)); - - if(Status == -ERESTARTSYS) + if (Status == -ERESTARTSYS) return Status; - if(Adapter->bShutStatus) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n"); + if (Adapter->bShutStatus) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n"); return STATUS_FAILURE; } - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Wakeup has been tried already...\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Wakeup has been tried already...\n"); } } - } - if(TRUE == Adapter->IdleMode) - { - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n"); - if(pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || - pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ ) - { - if((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0]==LINK_DOWN_REQ_PAYLOAD)) - { - if((pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Link Down Sent in Idle Mode\n"); - Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN;//LINK DOWN sent in Idle Mode - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n"); + if (TRUE == Adapter->IdleMode) { + /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */ + if (pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || + pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ) { + + if ((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD)) { + if ((pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Link Down Sent in Idle Mode\n"); + Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN; /* LINK DOWN sent in Idle Mode */ + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); Adapter->usIdleModePattern = ABORT_IDLE_REG; } - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n"); - Adapter->usIdleModePattern = ABORT_IDLE_MODE; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); + Adapter->usIdleModePattern = ABORT_IDLE_MODE; } /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent - the wake up from idlemode is from host*/ - //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; + * the wake up from idlemode is from host + */ + /* Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; */ Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); - - - if(LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0]) - { - // We should not send DREG message down while in idlemode. + /* We should not send DREG message down while in idlemode. */ + if (LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0]) return STATUS_SUCCESS; - } - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->IdleMode, (5 * HZ)); + Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->IdleMode, (5 * HZ)); - if(Status == -ERESTARTSYS) + if (Status == -ERESTARTSYS) return Status; - if(Adapter->IdleMode) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n"); + if (Adapter->IdleMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n"); return STATUS_FAILURE; } - } - else + } else { return STATUS_SUCCESS; + } } - //The Driver has to send control messages with a particular VCID - pLeader->Vcid = VCID_CONTROL_PACKET;//VCID for control packet. + + /* The Driver has to send control messages with a particular VCID */ + pLeader->Vcid = VCID_CONTROL_PACKET; /* VCID for control packet. */ /* Allocate skb for Control Packet */ pktlen = pLeader->PLength; ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS]; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", - atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); - if(ctrl_buff) - { - if(pLeader) - { - if((pLeader->Status == 0x80) || - (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", + atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); + if (ctrl_buff) { + if (pLeader) { + if ((pLeader->Status == 0x80) || + (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) { /* - //Restructure the DSX message to handle Multiple classifier Support - // Write the Service Flow param Structures directly to the target - //and embed the pointers in the DSX messages sent to target. - */ - //Lets store the current length of the control packet we are transmitting + * Restructure the DSX message to handle Multiple classifier Support + * Write the Service Flow param Structures directly to the target + * and embed the pointers in the DSX messages sent to target. + */ + /* Lets store the current length of the control packet we are transmitting */ pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; pktlen = pLeader->PLength; - Status = StoreCmControlResponseMessage(Adapter,pucAddIndication, &pktlen); - if(Status != 1) - { - ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); + Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen); + if (Status != 1) { + ClearTargetDSXBuffer(Adapter, ((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); return STATUS_FAILURE; } /* - //update the leader to use the new length - //The length of the control packet is length of message being sent + Leader length - */ + * update the leader to use the new length + * The length of the control packet is length of message being sent + Leader length + */ pLeader->PLength = pktlen; } } @@ -426,36 +372,33 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**PLength); - *(PLEADER)ctrl_buff=*pLeader; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); + *(PLEADER)ctrl_buff = *pLeader; memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); - /*Update the statistics counters */ + /* Update the statistics counters */ spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost+=pLeader->PLength; + Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength; Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; atomic_inc(&Adapter->TotalPacketCount); spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].bValid = TRUE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, - Adapter->PackInfo[HiPriority].bValid); - Status=STATUS_SUCCESS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", + Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, + Adapter->PackInfo[HiPriority].bValid); + Status = STATUS_SUCCESS; /*Queue the packet for transmission */ atomic_inc(&Adapter->index_wr_txcntrlpkt); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets"); atomic_set(&Adapter->TxPktAvail, 1); wake_up(&Adapter->tx_packet_wait_queue); + } else { + Status = -ENOMEM; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); } - else - { - Status=-ENOMEM; - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); - } - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); return Status; } @@ -464,33 +407,30 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>"); pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS; - pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG);//minimum 4 bytes + pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG); /* minimum 4 bytes */ pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ; - - CopyBufferToControlPacket(Adapter,pstStatisticsPtrRequest); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<====="); + CopyBufferToControlPacket(Adapter, pstStatisticsPtrRequest); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<====="); return; } #endif - /****************************************************************** * Function - LinkMessage() * * Description - This function builds the Sync-up and Link-up request -* packet messages depending on the device Link status. +* packet messages depending on the device Link status. * * Parameters - Adapter: Pointer to the Adapter structure. * @@ -498,102 +438,90 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, *******************************************************************/ VOID LinkMessage(PMINI_ADAPTER Adapter) { - PLINK_REQUEST pstLinkRequest=NULL; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); - if(Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) - { + PLINK_REQUEST pstLinkRequest = NULL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); + if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) { pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC); - if(!pstLinkRequest) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); + if (!pstLinkRequest) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); return; } - //sync up request... - Adapter->LinkStatus = WAIT_FOR_SYNC;// current link status - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp..."); - pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD; - pstLinkRequest->szData[1]=LINK_SYNC_UP_SUBTYPE; - pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ; - pstLinkRequest->Leader.PLength=sizeof(ULONG); + /* sync up request... */ + Adapter->LinkStatus = WAIT_FOR_SYNC; /* current link status */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp..."); + pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; + pstLinkRequest->szData[1] = LINK_SYNC_UP_SUBTYPE; + pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; + pstLinkRequest->Leader.PLength = sizeof(ULONG); Adapter->bSyncUpRequestSent = TRUE; - } - else if(Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) - { + + } else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) { pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC); - if(!pstLinkRequest) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); + if (!pstLinkRequest) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); return; } - //LINK_UP_REQUEST - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp..."); - pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD; - pstLinkRequest->szData[1]=LINK_NET_ENTRY; - pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ; - pstLinkRequest->Leader.PLength=sizeof(ULONG); + /* LINK_UP_REQUEST */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp..."); + pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; + pstLinkRequest->szData[1] = LINK_NET_ENTRY; + pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; + pstLinkRequest->Leader.PLength = sizeof(ULONG); } - if(pstLinkRequest) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); + if (pstLinkRequest) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); CopyBufferToControlPacket(Adapter, pstLinkRequest); kfree(pstLinkRequest); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); return; } - /********************************************************************** * Function - StatisticsResponse() * * Description - This function handles the Statistics response packet. * * Parameters - Adapter : Pointer to the Adapter structure. -* - pvBuffer: Starting address of Statistic response data. +* - pvBuffer: Starting address of Statistic response data. * * Returns - None. ************************************************************************/ -VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer) +VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __FUNCTION__); Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (UINT)Adapter->StatisticsPointer); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (UINT)Adapter->StatisticsPointer); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __FUNCTION__); return; } - /********************************************************************** * Function - LinkControlResponseMessage() * * Description - This function handles the Link response packets. * * Parameters - Adapter : Pointer to the Adapter structure. -* - pucBuffer: Starting address of Link response data. +* - pucBuffer: Starting address of Link response data. * * Returns - None. ***********************************************************************/ -VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) +VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); - if(*pucBuffer==LINK_UP_ACK) - { - switch(*(pucBuffer+1)) - { - case PHY_SYNC_ACHIVED: //SYNCed UP - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED"); + if (*pucBuffer == LINK_UP_ACK) { + switch (*(pucBuffer+1)) { + case PHY_SYNC_ACHIVED: /* SYNCed UP */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED"); - if(Adapter->LinkStatus == LINKUP_DONE) - { + if (Adapter->LinkStatus == LINKUP_DONE) beceem_protocol_reset(Adapter); - } - Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ; - Adapter->LinkStatus=PHY_SYNC_ACHIVED; + Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; + Adapter->LinkStatus = PHY_SYNC_ACHIVED; - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->DriverState = NO_NETWORK_ENTRY; wake_up(&Adapter->LEDInfo.notify_led_event); } @@ -601,161 +529,145 @@ VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) LinkMessage(Adapter); break; - case LINKUP_DONE: - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE"); - Adapter->LinkStatus=LINKUP_DONE; - Adapter->bPHSEnabled = *(pucBuffer+3); - Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x \n",Adapter->bPHSEnabled); - if((FALSE == Adapter->bShutStatus)&& - (FALSE == Adapter->IdleMode)) - { - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { - Adapter->DriverState = NORMAL_OPERATION; - wake_up(&Adapter->LEDInfo.notify_led_event); - } + case LINKUP_DONE: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE"); + Adapter->LinkStatus = LINKUP_DONE; + Adapter->bPHSEnabled = *(pucBuffer+3); + Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x\n", Adapter->bPHSEnabled); + + if ((FALSE == Adapter->bShutStatus) && (FALSE == Adapter->IdleMode)) { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = NORMAL_OPERATION; + wake_up(&Adapter->LEDInfo.notify_led_event); } - LinkMessage(Adapter); - break; - case WAIT_FOR_SYNC: - - /* - * Driver to ignore the DREG_RECEIVED - * WiMAX Application should handle this Message - */ - //Adapter->liTimeSinceLastNetEntry = 0; - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ; - Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; - Adapter->IdleMode = FALSE; - beceem_protocol_reset(Adapter); - - break; - case LINK_SHUTDOWN_REQ_FROM_FIRMWARE: - case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW: - { - HandleShutDownModeRequest(Adapter, pucBuffer); } - break; - default: - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x",*(pucBuffer+1)); - break; + LinkMessage(Adapter); + break; + + case WAIT_FOR_SYNC: + /* + * Driver to ignore the DREG_RECEIVED + * WiMAX Application should handle this Message + */ + /* Adapter->liTimeSinceLastNetEntry = 0; */ + Adapter->LinkUpStatus = 0; + Adapter->LinkStatus = 0; + Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; + Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; + Adapter->IdleMode = FALSE; + beceem_protocol_reset(Adapter); + + break; + case LINK_SHUTDOWN_REQ_FROM_FIRMWARE: + case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW: + { + HandleShutDownModeRequest(Adapter, pucBuffer); } - } - else if(SET_MAC_ADDRESS_RESPONSE==*pucBuffer) - { + break; + default: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x", *(pucBuffer + 1)); + break; + } + } else if (SET_MAC_ADDRESS_RESPONSE == *pucBuffer) { PUCHAR puMacAddr = (pucBuffer + 1); - Adapter->LinkStatus=SYNC_UP_REQUEST; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP"); + Adapter->LinkStatus = SYNC_UP_REQUEST; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP"); LinkMessage(Adapter); memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====",__FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __FUNCTION__); return; } void SendIdleModeResponse(PMINI_ADAPTER Adapter) { - INT status = 0, NVMAccess = 0,lowPwrAbortMsg = 0; + INT status = 0, NVMAccess = 0, lowPwrAbortMsg = 0; struct timeval tv; - CONTROL_MESSAGE stIdleResponse = {{0}}; + CONTROL_MESSAGE stIdleResponse = {{0} }; memset(&tv, 0, sizeof(tv)); - stIdleResponse.Leader.Status = IDLE_MESSAGE; + stIdleResponse.Leader.Status = IDLE_MESSAGE; stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH; stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL," ============>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, " ============>"); /********************************* - **down_trylock - - ** if [ semaphore is available ] - ** acquire semaphone and return value 0 ; - ** else - ** return non-zero value ; - ** - ***********************************/ + *down_trylock - + * if [ semaphore is available ] + * acquire semaphone and return value 0 ; + * else + * return non-zero value ; + * + ***********************************/ NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - - lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync); + lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); - if((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) && - (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) ) - { - if(!NVMAccess) + if ((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) && + (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) { + + if (!NVMAccess) up(&Adapter->NVMRdmWrmLock); - if(!lowPwrAbortMsg) + if (!lowPwrAbortMsg) up(&Adapter->LowPowerModeSync); - stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); + stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); Adapter->bPreparingForLowPowerMode = FALSE; - } - else - { - stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; //2;//Idle ACK + } else { + stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; /* 2; Idle ACK */ Adapter->StatisticsPointer = 0; /* Wait for the LED to TURN OFF before sending ACK response */ - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { INT iRetVal = 0; /* Wake the LED Thread with IDLEMODE_ENTER State */ Adapter->DriverState = LOWPOWER_MODE_ENTER; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld",jiffies); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld", jiffies); wake_up(&Adapter->LEDInfo.notify_led_event); /* Wait for 1 SEC for LED to OFF */ - iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, \ - Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); - + iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ - if(iRetVal <= 0) - { - stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on. + if (iRetVal <= 0) { + stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ Adapter->DriverState = NORMAL_OPERATION; wake_up(&Adapter->LEDInfo.notify_led_event); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!"); } } - if(stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"ACKING IDLE MODE !!!!!!!!!"); + + if (stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "ACKING IDLE MODE !!!!!!!!!"); down(&Adapter->rdmwrmsync); Adapter->bPreparingForLowPowerMode = TRUE; up(&Adapter->rdmwrmsync); - //Killing all URBS. - if(Adapter->bDoSuspend == TRUE) + /* Killing all URBS. */ + if (Adapter->bDoSuspend == TRUE) Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); - - } - else - { + } else { Adapter->bPreparingForLowPowerMode = FALSE; } - if(!NVMAccess) + if (!NVMAccess) up(&Adapter->NVMRdmWrmLock); - if(!lowPwrAbortMsg) + if (!lowPwrAbortMsg) up(&Adapter->LowPowerModeSync); - } - status = CopyBufferToControlPacket(Adapter,&stIdleResponse); - if((status != STATUS_SUCCESS)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n"); + + status = CopyBufferToControlPacket(Adapter, &stIdleResponse); + if ((status != STATUS_SUCCESS)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "fail to send the Idle mode Request\n"); Adapter->bPreparingForLowPowerMode = FALSE; StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); } do_gettimeofday(&tv); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); - + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec * 1000 + tv.tv_usec / 1000); } /****************************************************************** @@ -769,307 +681,264 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) *******************************************************************/ VOID DumpPackInfo(PMINI_ADAPTER Adapter) { - - UINT uiLoopIndex = 0; + UINT uiLoopIndex = 0; UINT uiIndex = 0; UINT uiClsfrIndex = 0; S_CLASSIFIER_RULE *pstClassifierEntry = NULL; - for(uiLoopIndex=0;uiLoopIndexPackInfo[uiLoopIndex].bValid) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid is FALSE for %X index\n",uiLoopIndex); + for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex); + if (FALSE == Adapter->PackInfo[uiLoopIndex].bValid) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is FALSE for %X index\n", uiLoopIndex); continue; } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," Dumping SF Rule Entry For SFID %lX \n",Adapter->PackInfo[uiLoopIndex].ulSFID); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," ucDirection %X \n",Adapter->PackInfo[uiLoopIndex].ucDirection); - if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv6 Service Flow \n"); - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " Dumping SF Rule Entry For SFID %lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " ucDirection %X\n", Adapter->PackInfo[uiLoopIndex].ucDirection); + + if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv6 Service Flow\n"); else - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv4 Service Flow \n"); - } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," SF Traffic Priority %X \n",Adapter->PackInfo[uiLoopIndex].u8TrafficPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv4 Service Flow\n"); - for(uiClsfrIndex=0;uiClsfrIndexPackInfo[uiLoopIndex].u8TrafficPriority); + + for (uiClsfrIndex = 0; uiClsfrIndex < MAX_CLASSIFIERS; uiClsfrIndex++) { pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex]; - if(!pstClassifierEntry->bUsed) + if (!pstClassifierEntry->bUsed) continue; - if(pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID) + if (pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID) continue; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n",uiClsfrIndex,pstClassifierEntry->uiClassifierRuleIndex); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n",uiClsfrIndex,pstClassifierEntry->usVCID_Value); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n",uiClsfrIndex,pstClassifierEntry->bProtocolValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n",uiClsfrIndex,pstClassifierEntry->bTOSValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bDestIpValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bSrcIpValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n", uiClsfrIndex, pstClassifierEntry->uiClassifierRuleIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n", uiClsfrIndex, pstClassifierEntry->usVCID_Value); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n", uiClsfrIndex, pstClassifierEntry->bProtocolValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n", uiClsfrIndex, pstClassifierEntry->bTOSValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bDestIpValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bSrcIpValid); - - for(uiIndex=0;uiIndexusSrcPortRangeLo[uiIndex]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry->usSrcPortRangeHi[uiIndex]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeLo:%X\n",pstClassifierEntry->usDestPortRangeLo[uiIndex]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeHi:%X\n",pstClassifierEntry->usDestPortRangeHi[uiIndex]); + for (uiIndex = 0; uiIndex < MAX_PORT_RANGE; uiIndex++) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeLo:%X\n", pstClassifierEntry->usSrcPortRangeLo[uiIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeHi:%X\n", pstClassifierEntry->usSrcPortRangeHi[uiIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeLo:%X\n", pstClassifierEntry->usDestPortRangeLo[uiIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeHi:%X\n", pstClassifierEntry->usDestPortRangeHi[uiIndex]); } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry->ucIPSourceAddressLength); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry->ucIPDestinationAddressLength); - for(uiIndex=0;uiIndexucIPSourceAddressLength;uiIndex++) - { - if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpAddr :\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPSourceAddressLength : 0x%x\n", pstClassifierEntry->ucIPSourceAddressLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPDestinationAddressLength : 0x%x\n", pstClassifierEntry->ucIPDestinationAddressLength); + for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPSourceAddressLength; uiIndex++) { + if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpAddr :\n"); DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpMask :\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpMask :\n"); DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask); - } - else - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpAddr:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpMask:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpAddr:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpMask:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]); } } - for(uiIndex=0;uiIndexucIPDestinationAddressLength;uiIndex++) - { - if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpAddr :\n"); + + for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPDestinationAddressLength; uiIndex++) { + if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpAddr :\n"); DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpMask :\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpMask :\n"); DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask); - - } - else - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpAddr:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpMask:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpAddr:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpMask:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]); } } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucProtocol:0x%X\n",pstClassifierEntry->ucProtocol[0]); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry->u8ClassifierRulePriority); - - + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucProtocol:0x%X\n", pstClassifierEntry->ucProtocol[0]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tu8ClassifierRulePriority:%X\n", pstClassifierEntry->u8ClassifierRulePriority); } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ulSFID:%lX\n",Adapter->PackInfo[uiLoopIndex].ulSFID); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"usVCID_Value:%X\n",Adapter->PackInfo[uiLoopIndex].usVCID_Value); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"PhsEnabled: 0x%X\n",Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThreshold:%X\n",Adapter->PackInfo[uiLoopIndex].uiThreshold); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ulSFID:%lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "usVCID_Value:%X\n", Adapter->PackInfo[uiLoopIndex].usVCID_Value); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "PhsEnabled: 0x%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThreshold:%X\n", Adapter->PackInfo[uiLoopIndex].uiThreshold); - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid:%X\n",Adapter->PackInfo[uiLoopIndex].bValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bActive:%X\n",Adapter->PackInfo[uiLoopIndex].bActive); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"u8QueueType:%X\n",Adapter->PackInfo[uiLoopIndex].u8QueueType); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxBucketSize:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount)); - //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentBytesOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentPacketsOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentBytes); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentPackets); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentDrainRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThisPeriodSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liDrainCalculated:%llX\n",Adapter->PackInfo[uiLoopIndex].liDrainCalculated); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentTokenCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liLastUpdateTokenAt:%llX\n",Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxAllowedRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPendedLast:%X\n",Adapter->PackInfo[uiLoopIndex].uiPendedLast); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"NumOfPacketsSent:%X\n",Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n",Adapter->PackInfo[uiLoopIndex].uiMaxLatency); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ServiceClassName: %x %x %x %x\n",Adapter->PackInfo[uiLoopIndex].ucServiceClassName[0],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[1],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[2],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[3]); -// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); -// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes); -// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes); -// DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid:%X\n", Adapter->PackInfo[uiLoopIndex].bValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bActive:%X\n", Adapter->PackInfo[uiLoopIndex].bActive); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "u8QueueType:%X\n", Adapter->PackInfo[uiLoopIndex].u8QueueType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxBucketSize:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPerSFTxResourceCount:%X\n", atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount)); + /* DumpDebug(DUMP_INFO,("bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentBytesOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentPacketsOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentPackets); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentDrainRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThisPeriodSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liDrainCalculated:%llX\n", Adapter->PackInfo[uiLoopIndex].liDrainCalculated); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentTokenCount:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liLastUpdateTokenAt:%llX\n", Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxAllowedRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPendedLast:%X\n", Adapter->PackInfo[uiLoopIndex].uiPendedLast); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "NumOfPacketsSent:%X\n", Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n", Adapter->PackInfo[uiLoopIndex].uiMaxLatency); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ServiceClassName: %x %x %x %x\n", Adapter->PackInfo[uiLoopIndex].ucServiceClassName[0], Adapter->PackInfo[uiLoopIndex].ucServiceClassName[1], Adapter->PackInfo[uiLoopIndex].ucServiceClassName[2], Adapter->PackInfo[uiLoopIndex].ucServiceClassName[3]); +/* BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); + * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes); + * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes); + * DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount)); + */ } - for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++) - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aRxPktSizeHist[uiLoopIndex]); - - for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++) - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aTxPktSizeHist[uiLoopIndex]); - + for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aRxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aRxPktSizeHist[uiLoopIndex]); + for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aTxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aTxPktSizeHist[uiLoopIndex]); return; - - } int reset_card_proc(PMINI_ADAPTER ps_adapter) { int retval = STATUS_SUCCESS; - - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PS_INTERFACE_ADAPTER psIntfAdapter = NULL; unsigned int value = 0, uiResetValue = 0; - psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)) ; - + psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)); ps_adapter->bDDRInitDone = FALSE; - if(ps_adapter->chip_id >= T3LPB) - { - //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before - rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value)); - rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value)); + if (ps_adapter->chip_id >= T3LPB) { + /* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */ + rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); + rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); - //making bit[6...5] same as was before f/w download. this setting force the h/w to - //re-populated the SP RAM area with the string descriptor . - value = value | (ps_adapter->syscfgBefFwDld & 0x00000060) ; + /* making bit[6...5] same as was before f/w download. this setting force the h/w to */ + /* re-populated the SP RAM area with the string descriptor. */ + value = value | (ps_adapter->syscfgBefFwDld & 0x00000060); wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); } - //killing all submitted URBs. - psIntfAdapter->psAdapter->StopAllXaction = TRUE ; + /* killing all submitted URBs. */ + psIntfAdapter->psAdapter->StopAllXaction = TRUE; Bcm_kill_all_URBs(psIntfAdapter); /* Reset the UMA-B Device */ - if(ps_adapter->chip_id >= T3LPB) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B \n"); + if (ps_adapter->chip_id >= T3LPB) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B\n"); retval = usb_reset_device(psIntfAdapter->udev); + psIntfAdapter->psAdapter->StopAllXaction = FALSE; - psIntfAdapter->psAdapter->StopAllXaction = FALSE ; - - if(retval != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); + if (retval != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); goto err_exit; } + if (ps_adapter->chip_id == BCS220_2 || ps_adapter->chip_id == BCS220_2BC || ps_adapter->chip_id == BCS250_BC || - ps_adapter->chip_id == BCS220_3) - { - retval = rdmalt(ps_adapter,HPM_CONFIG_LDO145, &value, sizeof(value)); - if( retval < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval); + ps_adapter->chip_id == BCS220_3) { + + retval = rdmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); goto err_exit; } - //setting 0th bit + /* setting 0th bit */ value |= (1<<0); retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); - if( retval < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); goto err_exit; } } - - } - else - { - retval = rdmalt(ps_adapter,0x0f007018, &value, sizeof(value)); - if( retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval); + } else { + retval = rdmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); goto err_exit; } - value&=(~(1<<16)); - retval= wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)) ; - if( retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); + value &= (~(1<<16)); + retval = wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); goto err_exit; } - // Toggling the GPIO 8, 9 + /* Toggling the GPIO 8, 9 */ value = 0; retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); goto err_exit; } value = 0x300; - retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)) ; - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); + retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); goto err_exit; } mdelay(50); } - //ps_adapter->downloadDDR = false; - - if(ps_adapter->bFlashBoot) - { - //In flash boot mode MIPS state register has reverse polarity. - // So just or with setting bit 30. - //Make the MIPS in Reset state. + /* ps_adapter->downloadDDR = false; */ + if (ps_adapter->bFlashBoot) { + /* In flash boot mode MIPS state register has reverse polarity. + * So just or with setting bit 30. + * Make the MIPS in Reset state. + */ rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); - - uiResetValue |=(1<<30); + uiResetValue |= (1<<30); wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); } - if(ps_adapter->chip_id >= T3LPB) - { + if (ps_adapter->chip_id >= T3LPB) { uiResetValue = 0; - // - // WA for SYSConfig Issue. - // Read SYSCFG Twice to make it writable. - // + /* + * WA for SYSConfig Issue. + * Read SYSCFG Twice to make it writable. + */ rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); - if(uiResetValue & (1<<4)) - { + if (uiResetValue & (1<<4)) { uiResetValue = 0; - rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));//2nd read to make it writable. + rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); /* 2nd read to make it writable. */ uiResetValue &= (~(1<<4)); - wrmalt(ps_adapter,SYS_CFG, &uiResetValue, sizeof(uiResetValue)); + wrmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); } - } uiResetValue = 0; wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue)); -err_exit : - psIntfAdapter->psAdapter->StopAllXaction = FALSE ; +err_exit: + psIntfAdapter->psAdapter->StopAllXaction = FALSE; return retval; } -int run_card_proc(PMINI_ADAPTER ps_adapter ) +int run_card_proc(PMINI_ADAPTER ps_adapter) { - unsigned int value=0; + unsigned int value = 0; { - - if(rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__); + if (rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __FUNCTION__, __LINE__); return STATUS_FAILURE; } - if(ps_adapter->bFlashBoot) - { - - value&=(~(1<<30)); - } + if (ps_adapter->bFlashBoot) + value &= (~(1<<30)); else - { - value |=(1<<30); - } + value |= (1<<30); - if(wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__); + if (wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __FUNCTION__, __LINE__); return STATUS_FAILURE; } } @@ -1078,104 +947,87 @@ int run_card_proc(PMINI_ADAPTER ps_adapter ) int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) { - int status; UINT value = 0; /* - * Create the threads first and then download the - * Firm/DDR Settings.. - */ - + * Create the threads first and then download the + * Firm/DDR Settings.. + */ status = create_worker_threads(ps_adapter); - if (status<0) + if (status < 0) return status; - /* - * For Downloading the Firm, parse the cfg file first. - */ - status = bcm_parse_target_params (ps_adapter); - if(status){ + status = bcm_parse_target_params(ps_adapter); + if (status) return status; - } - if(ps_adapter->chip_id >= T3LPB) - { - rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value)); - ps_adapter->syscfgBefFwDld = value ; - if((value & 0x60)== 0) - { + if (ps_adapter->chip_id >= T3LPB) { + rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); + ps_adapter->syscfgBefFwDld = value; + + if ((value & 0x60) == 0) ps_adapter->bFlashBoot = TRUE; - } } reset_card_proc(ps_adapter); - //Initializing the NVM. + /* Initializing the NVM. */ BcmInitNVM(ps_adapter); status = ddr_init(ps_adapter); - if(status) - { + if (status) { pr_err(DRV_NAME "ddr_init Failed\n"); return status; } /* Download cfg file */ status = buffDnldVerify(ps_adapter, - (PUCHAR)ps_adapter->pstargetparams, - sizeof(STARGETPARAMS), - CONFIG_BEGIN_ADDR); - if(status) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); + (PUCHAR)ps_adapter->pstargetparams, + sizeof(STARGETPARAMS), + CONFIG_BEGIN_ADDR); + if (status) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); goto OUT; } - if(register_networkdev(ps_adapter)) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); + if (register_networkdev(ps_adapter)) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); return -EIO; } - if(FALSE == ps_adapter->AutoFirmDld) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); - //If Auto f/w download is disable, register the control interface, - //register the control interface after the mailbox. - if(register_control_device_interface(ps_adapter) < 0) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); + if (FALSE == ps_adapter->AutoFirmDld) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); + /* If Auto f/w download is disable, register the control interface, */ + /* register the control interface after the mailbox. */ + if (register_control_device_interface(ps_adapter) < 0) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); return -EIO; } - return STATUS_SUCCESS; } /* - * Do the LED Settings here. It will be used by the Firmware Download - * Thread. - */ + * Do the LED Settings here. It will be used by the Firmware Download + * Thread. + */ /* - * 1. If the LED Settings fails, do not stop and do the Firmware download. - * 2. This init would happened only if the cfg file is present, else - * call from the ioctl context. - */ + * 1. If the LED Settings fails, do not stop and do the Firmware download. + * 2. This init would happened only if the cfg file is present, else + * call from the ioctl context. + */ - status = InitLedSettings (ps_adapter); - - if(status) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n"); + status = InitLedSettings(ps_adapter); + if (status) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "INIT LED FAILED\n"); return status; } - if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + + if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { ps_adapter->DriverState = DRIVER_INIT; wake_up(&ps_adapter->LEDInfo.notify_led_event); } - if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { ps_adapter->DriverState = FW_DOWNLOAD; wake_up(&ps_adapter->LEDInfo.notify_led_event); } @@ -1184,37 +1036,31 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - if(ps_adapter->eNVMType == NVM_FLASH) - { + if (ps_adapter->eNVMType == NVM_FLASH) { status = PropagateCalParamsFromFlashToMemory(ps_adapter); - if(status) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL," Propagation of Cal param failed .." ); + if (status) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Propagation of Cal param failed .."); goto OUT; } } /* Download Firmare */ - if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present... \n"); + if ((status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present...\n"); goto OUT; } status = run_card_proc(ps_adapter); - if(status) - { - BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n"); + if (status) { + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n"); goto OUT; } - ps_adapter->fw_download_done = TRUE; mdelay(10); OUT: - if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { ps_adapter->DriverState = FW_DOWNLOAD_DONE; wake_up(&ps_adapter->LEDInfo.notify_led_event); } @@ -1222,41 +1068,38 @@ OUT: return status; } - static int bcm_parse_target_params(PMINI_ADAPTER Adapter) { - struct file *flp=NULL; - mm_segment_t oldfs={0}; + struct file *flp = NULL; + mm_segment_t oldfs = {0}; char *buff; int len = 0; - loff_t pos = 0; + loff_t pos = 0; - buff=kmalloc(BUFFER_1K, GFP_KERNEL); - if(!buff) - { + buff = kmalloc(BUFFER_1K, GFP_KERNEL); + if (!buff) return -ENOMEM; - } - if((Adapter->pstargetparams = - kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) - { + + if ((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) { kfree(buff); return -ENOMEM; } - flp=open_firmware_file(Adapter, CFG_FILE); - if(!flp) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE); + + flp = open_firmware_file(Adapter, CFG_FILE); + if (!flp) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE\n", CFG_FILE); kfree(buff); kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; return -ENOENT; } - oldfs=get_fs(); set_fs(get_ds()); - len=vfs_read(flp, (void __user __force *)buff, BUFFER_1K, &pos); + oldfs = get_fs(); + set_fs(get_ds()); + len = vfs_read(flp, (void __user __force *)buff, BUFFER_1K, &pos); set_fs(oldfs); - if(len != sizeof(STARGETPARAMS)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n"); + if (len != sizeof(STARGETPARAMS)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); kfree(buff); kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; @@ -1270,122 +1113,97 @@ static int bcm_parse_target_params(PMINI_ADAPTER Adapter) * Values in Adapter->pstargetparams are in network byte order */ memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); - kfree (buff); + kfree(buff); beceem_parse_target_struct(Adapter); return STATUS_SUCCESS; } void beceem_parse_target_struct(PMINI_ADAPTER Adapter) { - UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0; + UINT uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0; - if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) - { + if (ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) { pr_info(DRV_NAME ": AutoSyncup is Disabled\n"); Adapter->AutoSyncup = FALSE; - } - else - { + } else { pr_info(DRV_NAME ": AutoSyncup is Enabled\n"); - Adapter->AutoSyncup = TRUE; + Adapter->AutoSyncup = TRUE; } - if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) - { + if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) { pr_info(DRV_NAME ": Enabling autolink up"); Adapter->AutoLinkUp = TRUE; - } - else - { + } else { pr_info(DRV_NAME ": Disabling autolink up"); Adapter->AutoLinkUp = FALSE; } - // Setting the DDR Setting.. - Adapter->DDRSetting = - (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >>8)&0x0F; - Adapter->ulPowerSaveMode = - (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; - + /* Setting the DDR Setting.. */ + Adapter->DDRSetting = (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >> 8)&0x0F; + Adapter->ulPowerSaveMode = (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting); pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode); - if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) - { - pr_info(DRV_NAME ": Enabling Auto Firmware Download\n"); - Adapter->AutoFirmDld = TRUE; - } - else - { - pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); - Adapter->AutoFirmDld = FALSE; - } + if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) { + pr_info(DRV_NAME ": Enabling Auto Firmware Download\n"); + Adapter->AutoFirmDld = TRUE; + } else { + pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); + Adapter->AutoFirmDld = FALSE; + } uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; - pr_info(DRV_NAME ": MIPSConfig : 0x%X\n",Adapter->bMipsConfig); - //used for backward compatibility. + pr_info(DRV_NAME ": MIPSConfig : 0x%X\n", Adapter->bMipsConfig); + /* used for backward compatibility. */ Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; - - Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03; + Adapter->PmuMode = (uiHostDrvrCfg6 >> 24) & 0x03; pr_info(DRV_NAME ": PMU MODE: %x", Adapter->PmuMode); - if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01)) - { - Adapter->bDoSuspend = TRUE; - pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile"); - } + if ((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT) & (0x01)) { + Adapter->bDoSuspend = TRUE; + pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile"); + } uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); - pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n",uiEEPROMFlag); + pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n", uiEEPROMFlag); Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3); - Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; - Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); + Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; - Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; - - if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01) + if (ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x01) Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; - if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) + if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) doPowerAutoCorrection(Adapter); - } static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) { UINT reporting_mode; - reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ; + reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02; psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); - if(reporting_mode == TRUE) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"can't do suspen/resume as reporting mode is enable"); + if (reporting_mode == TRUE) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable"); psAdapter->bDoSuspend = FALSE; } - if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) - { - //If reporting mode is enable, switch PMU to PMC + if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) { + /* If reporting mode is enable, switch PMU to PMC */ { psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; - psAdapter->bDoSuspend =FALSE; - + psAdapter->bDoSuspend = FALSE; } - //clearing space bit[15..12] + /* clearing space bit[15..12] */ psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12))); - //placing the power save mode option + /* placing the power save mode option */ psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12)); - - } - else if (psAdapter->bIsAutoCorrectEnabled == FALSE) - { - - // remove the autocorrect disable bit set before dumping. + } else if (psAdapter->bIsAutoCorrectEnabled == FALSE) { + /* remove the autocorrect disable bit set before dumping. */ psAdapter->ulPowerSaveMode &= ~(1 << 3); psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15)); - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode); } } @@ -1396,63 +1214,56 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) unsigned int temp = 0; unsigned char *pucmacaddr = kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL); - if(!pucmacaddr) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n"); + if (!pucmacaddr) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n"); return NULL; } dwAddress |= 0x5b000000; - status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, - (PUINT)&dwAddress, sizeof(UINT)); - if(status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); + status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, (PUINT)&dwAddress, sizeof(UINT)); + if (status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); kfree(pucmacaddr); pucmacaddr = NULL; goto OUT; } - for(i=0;iinterface_rdm(Adapter->pvInterfaceAdapter, - uiAddress, pucBuff, sSize); + uiAddress, pucBuff, sSize); } int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) @@ -1460,112 +1271,103 @@ int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) int iRetVal; iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, - uiAddress, pucBuff, sSize); - - + uiAddress, pucBuff, sSize); return iRetVal; } -int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int wrmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) { convertEndian(RWM_WRITE, pucBuff, size); return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size); } -int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int rdmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) { - INT uiRetVal =0; + INT uiRetVal = 0; - uiRetVal = rdm(Adapter,uiAddress,(PUCHAR)pucBuff,size); + uiRetVal = rdm(Adapter, uiAddress, (PUCHAR)pucBuff, size); convertEndian(RWM_READ, (PUINT)pucBuff, size); return uiRetVal; } - int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) { - INT status = STATUS_SUCCESS ; + INT status = STATUS_SUCCESS; down(&Adapter->rdmwrmsync); - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + status = -EACCES; goto exit; } - status =wrm(Adapter, uiAddress, pucBuff, sSize); - + status = wrm(Adapter, uiAddress, pucBuff, sSize); exit: up(&Adapter->rdmwrmsync); - return status ; + return status; } -int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int wrmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) { int iRetVal = STATUS_SUCCESS; down(&Adapter->rdmwrmsync); - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + iRetVal = -EACCES; goto exit; } - iRetVal = wrmalt(Adapter,uiAddress,pucBuff,size); - + iRetVal = wrmalt(Adapter, uiAddress, pucBuff, size); exit: up(&Adapter->rdmwrmsync); return iRetVal; } -int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int rdmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) { - INT uiRetVal =STATUS_SUCCESS; + INT uiRetVal = STATUS_SUCCESS; down(&Adapter->rdmwrmsync); + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { uiRetVal = -EACCES; goto exit; } - uiRetVal = rdmalt(Adapter,uiAddress, pucBuff, size); - + uiRetVal = rdmalt(Adapter, uiAddress, pucBuff, size); exit: up(&Adapter->rdmwrmsync); return uiRetVal; } - static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter) { - int clear_abort_pattern = 0,Status = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); - //target has woken up From Shut Down - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); - Status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); + int clear_abort_pattern = 0, Status = 0; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); + /* target has woken up From Shut Down */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); + Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); return; } - if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) - { + + if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { msleep(100); InterfaceHandleShutdownModeWakeup(Adapter); msleep(100); } - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->DriverState = NO_NETWORK_ENTRY; wake_up(&Adapter->LEDInfo.notify_led_event); } @@ -1573,55 +1375,49 @@ static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter) Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; Adapter->bShutStatus = FALSE; wake_up(&Adapter->lowpower_mode_wait_queue); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); } static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) { - CONTROL_MESSAGE stShutdownResponse; - UINT NVMAccess = 0,lowPwrAbortMsg = 0; + CONTROL_MESSAGE stShutdownResponse; + UINT NVMAccess = 0, lowPwrAbortMsg = 0; UINT Status = 0; - memset (&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE)); + memset(&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE)); stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ; - stShutdownResponse.Leader.PLength = 8;//8 bytes; + stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */ stShutdownResponse.szData[0] = LINK_UP_ACK; stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE; /********************************* - **down_trylock - - ** if [ semaphore is available ] - ** acquire semaphone and return value 0 ; - ** else - ** return non-zero value ; - ** - ***********************************/ + * down_trylock - + * if [ semaphore is available ] + * acquire semaphone and return value 0 ; + * else + * return non-zero value ; + * + ***********************************/ NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); - lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync); - - - if(NVMAccess || lowPwrAbortMsg|| atomic_read(&Adapter->TotalPacketCount)) - { - if(!NVMAccess) + if (NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) { + if (!NVMAccess) up(&Adapter->NVMRdmWrmLock); - if(!lowPwrAbortMsg) + if (!lowPwrAbortMsg) up(&Adapter->LowPowerModeSync); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); - stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on. + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); + stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ Adapter->bPreparingForLowPowerMode = FALSE; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); - stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER;//ShutDown ACK + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); + stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER; /* ShutDown ACK */ /* Wait for the LED to TURN OFF before sending ACK response */ - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { INT iRetVal = 0; /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */ @@ -1629,237 +1425,200 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) wake_up(&Adapter->LEDInfo.notify_led_event); /* Wait for 1 SEC for LED to OFF */ - iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent,\ - Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); + iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ - if(iRetVal <= 0) - { - stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on. - + if (iRetVal <= 0) { + stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ Adapter->DriverState = NO_NETWORK_ENTRY; wake_up(&Adapter->LEDInfo.notify_led_event); } } - if(stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ACKING SHUTDOWN MODE !!!!!!!!!"); + if (stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ACKING SHUTDOWN MODE !!!!!!!!!"); down(&Adapter->rdmwrmsync); Adapter->bPreparingForLowPowerMode = TRUE; up(&Adapter->rdmwrmsync); - //Killing all URBS. - if(Adapter->bDoSuspend == TRUE) + /* Killing all URBS. */ + if (Adapter->bDoSuspend == TRUE) Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); - } - else - { + } else { Adapter->bPreparingForLowPowerMode = FALSE; } - if(!NVMAccess) + if (!NVMAccess) up(&Adapter->NVMRdmWrmLock); - if(!lowPwrAbortMsg) + if (!lowPwrAbortMsg) up(&Adapter->LowPowerModeSync); } - Status = CopyBufferToControlPacket(Adapter,&stShutdownResponse); - if((Status != STATUS_SUCCESS)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n"); - Adapter->bPreparingForLowPowerMode = FALSE; + Status = CopyBufferToControlPacket(Adapter, &stShutdownResponse); + if ((Status != STATUS_SUCCESS)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "fail to send the Idle mode Request\n"); + Adapter->bPreparingForLowPowerMode = FALSE; StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); } } - -static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) +static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer) { B_UINT32 uiResetValue = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); - if(*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) - { + if (*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) { HandleShutDownModeWakeup(Adapter); - } - else if(*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) - { - //Target wants to go to Shut Down Mode - //InterfacePrepareForShutdown(Adapter); - if(Adapter->chip_id == BCS220_2 || - Adapter->chip_id == BCS220_2BC || - Adapter->chip_id == BCS250_BC || - Adapter->chip_id == BCS220_3) - { - rdmalt(Adapter,HPM_CONFIG_MSW, &uiResetValue, 4); + } else if (*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) { + /* Target wants to go to Shut Down Mode */ + /* InterfacePrepareForShutdown(Adapter); */ + if (Adapter->chip_id == BCS220_2 || + Adapter->chip_id == BCS220_2BC || + Adapter->chip_id == BCS250_BC || + Adapter->chip_id == BCS220_3) { + + rdmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); uiResetValue |= (1<<17); wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); } SendShutModeResponse(Adapter); - BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); return; - } VOID ResetCounters(PMINI_ADAPTER Adapter) { - - beceem_protocol_reset(Adapter); - + beceem_protocol_reset(Adapter); Adapter->CurrNumRecvDescs = 0; - Adapter->PrevNumRecvDescs = 0; - Adapter->LinkUpStatus = 0; + Adapter->PrevNumRecvDescs = 0; + Adapter->LinkUpStatus = 0; Adapter->LinkStatus = 0; - atomic_set(&Adapter->cntrlpktCnt,0); - atomic_set (&Adapter->TotalPacketCount,0); - Adapter->fw_download_done=FALSE; + atomic_set(&Adapter->cntrlpktCnt, 0); + atomic_set(&Adapter->TotalPacketCount, 0); + Adapter->fw_download_done = FALSE; Adapter->LinkStatus = 0; - Adapter->AutoLinkUp = FALSE; + Adapter->AutoLinkUp = FALSE; Adapter->IdleMode = FALSE; Adapter->bShutStatus = FALSE; - } -S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP) + +S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIP) { - UINT uiIndex=0; - for(uiIndex=0;uiIndexastFragmentedPktClassifierTable[uiIndex].bUsed)&& - (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&& - (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIP)&& + UINT uiIndex = 0; + for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { + if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && + (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && + (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIP) && !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment) + return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry; } return NULL; } -void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo) +void AddFragIPClsEntry(PMINI_ADAPTER Adapter, PS_FRAGMENTED_PACKET_INFO psFragPktInfo) { - UINT uiIndex=0; - for(uiIndex=0;uiIndexastFragmentedPktClassifierTable[uiIndex].bUsed) - { - memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex],psFragPktInfo,sizeof(S_FRAGMENTED_PACKET_INFO)); + UINT uiIndex = 0; + for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { + if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) { + memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(S_FRAGMENTED_PACKET_INFO)); break; } } - } -void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp) +void DelFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIp) { - UINT uiIndex=0; - for(uiIndex=0;uiIndexastFragmentedPktClassifierTable[uiIndex].bUsed)&& - (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&& - (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIp)) - memset(&Adapter->astFragmentedPktClassifierTable[uiIndex],0,sizeof(S_FRAGMENTED_PACKET_INFO)); + UINT uiIndex = 0; + for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { + if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && + (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && + (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp)) + + memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(S_FRAGMENTED_PACKET_INFO)); } } -void update_per_cid_rx (PMINI_ADAPTER Adapter) +void update_per_cid_rx(PMINI_ADAPTER Adapter) { - UINT qindex = 0; + UINT qindex = 0; - if((jiffies - Adapter->liDrainCalculated) < XSECONDS) + if ((jiffies - Adapter->liDrainCalculated) < XSECONDS) return; - for(qindex = 0; qindex < HiPriority; qindex++) - { - if(Adapter->PackInfo[qindex].ucDirection == 0) - { + for (qindex = 0; qindex < HiPriority; qindex++) { + if (Adapter->PackInfo[qindex].ucDirection == 0) { Adapter->PackInfo[qindex].uiCurrentRxRate = (Adapter->PackInfo[qindex].uiCurrentRxRate + - Adapter->PackInfo[qindex].uiThisPeriodRxBytes)/2; + Adapter->PackInfo[qindex].uiThisPeriodRxBytes) / 2; Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0; - } - else - { + } else { Adapter->PackInfo[qindex].uiCurrentDrainRate = (Adapter->PackInfo[qindex].uiCurrentDrainRate + - Adapter->PackInfo[qindex].uiThisPeriodSentBytes)/2; - - Adapter->PackInfo[qindex].uiThisPeriodSentBytes=0; + Adapter->PackInfo[qindex].uiThisPeriodSentBytes) / 2; + Adapter->PackInfo[qindex].uiThisPeriodSentBytes = 0; } } - Adapter->liDrainCalculated=jiffies; + Adapter->liDrainCalculated = jiffies; } -void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) + +void update_per_sf_desc_cnts(PMINI_ADAPTER Adapter) { INT iIndex = 0; u32 uibuff[MAX_TARGET_DSX_BUFFERS]; - if(!atomic_read (&Adapter->uiMBupdate)) + if (!atomic_read(&Adapter->uiMBupdate)) return; - if(rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); + if (rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS) < 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); return; } - for(iIndex = 0;iIndex < HiPriority; iIndex++) - { - if(Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) - { - if(Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS) - { + + for (iIndex = 0; iIndex < HiPriority; iIndex++) { + if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) { + if (Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS) atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]); - } else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x \n", - Adapter->PackInfo[iIndex].usVCID_Value); - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x\n", Adapter->PackInfo[iIndex].usVCID_Value); } } - atomic_set (&Adapter->uiMBupdate, FALSE); + atomic_set(&Adapter->uiMBupdate, FALSE); } void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) { - struct sk_buff* PacketToDrop=NULL; - struct net_device_stats* netstats = &Adapter->dev->stats; - + struct sk_buff *PacketToDrop = NULL; + struct net_device_stats *netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - while(Adapter->PackInfo[iQIndex].FirstTxQueue && - atomic_read(&Adapter->TotalPacketCount)) - { + while (Adapter->PackInfo[iQIndex].FirstTxQueue && atomic_read(&Adapter->TotalPacketCount)) { PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if(PacketToDrop && PacketToDrop->len) - { + if (PacketToDrop && PacketToDrop->len) { netstats->tx_dropped++; - DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, \ - Adapter->PackInfo[iQIndex].LastTxQueue); - + DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, Adapter->PackInfo[iQIndex].LastTxQueue); Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--; Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len; - //Adding dropped statistics + /* Adding dropped statistics */ Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; - dev_kfree_skb(PacketToDrop); atomic_dec(&Adapter->TotalPacketCount); } } spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - } -static void beceem_protocol_reset (PMINI_ADAPTER Adapter) +static void beceem_protocol_reset(PMINI_ADAPTER Adapter) { int i; - if (netif_msg_link(Adapter)) pr_notice(PFX "%s: protocol reset\n", Adapter->dev->name); @@ -1868,32 +1627,22 @@ static void beceem_protocol_reset (PMINI_ADAPTER Adapter) Adapter->IdleMode = FALSE; Adapter->LinkUpStatus = FALSE; - ClearTargetDSXBuffer(Adapter,0, TRUE); - //Delete All Classifier Rules + ClearTargetDSXBuffer(Adapter, 0, TRUE); + /* Delete All Classifier Rules */ - for(i = 0;iTimerActive == TRUE) + if (Adapter->TimerActive == TRUE) Adapter->TimerActive = FALSE; - memset(Adapter->astFragmentedPktClassifierTable, 0, - sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); + memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); - for(i = 0;iPackInfo[i].stMibsExtServiceFlowTable, - 0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS)); + for (i = 0; i < HiPriority; i++) { + /* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */ + /* It is same between MIBs and SF. */ + memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS)); } } - - - - - From a8a1cdd6d4daeeb7a8016fbaa2cb79f37b14ea9a Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Fri, 7 Oct 2011 18:50:10 -0400 Subject: [PATCH 1405/1519] Staging: bcm: Replace dated variable __FUNCTION__ reported by checkpatch.pl This patch replaces the obsolete variable, __FUNCTION__, that holds the name of the current function with variable, __func__. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Misc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 2bf942458e0..4e900bb6608 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -71,7 +71,7 @@ INT InitAdapter(PMINI_ADAPTER psAdapter) /* Initialize PHS interface */ if (phs_init(&psAdapter->stBCMPhsContext, psAdapter) != 0) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __func__, __LINE__); return -ENOMEM; } @@ -489,10 +489,10 @@ VOID LinkMessage(PMINI_ADAPTER Adapter) ************************************************************************/ VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__); Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (UINT)Adapter->StatisticsPointer); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __func__); return; } @@ -576,7 +576,7 @@ VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer) LinkMessage(Adapter); memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __func__); return; } @@ -928,7 +928,7 @@ int run_card_proc(PMINI_ADAPTER ps_adapter) unsigned int value = 0; { if (rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); return STATUS_FAILURE; } @@ -938,7 +938,7 @@ int run_card_proc(PMINI_ADAPTER ps_adapter) value |= (1<<30); if (wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); return STATUS_FAILURE; } } From 9d4f1d0c9d1cf2fc4a73b6fff30aa129b9d1586e Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Fri, 7 Oct 2011 18:50:11 -0400 Subject: [PATCH 1406/1519] Staging: bcm: Remove assignment in if condition reported by checkpatch.pl There is a case where an assignment was being done in an if condition. This patch removes the assignment from the if condition and places the assignment above the if statement; thereby improving the readability of the code. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 4e900bb6608..0882e04963a 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -1080,7 +1080,8 @@ static int bcm_parse_target_params(PMINI_ADAPTER Adapter) if (!buff) return -ENOMEM; - if ((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) { + Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + if (Adapter->pstargetparams == NULL) { kfree(buff); return -ENOMEM; } From d491061b98bf3d2d036b9896f884403cdc2c0327 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Fri, 7 Oct 2011 18:50:12 -0400 Subject: [PATCH 1407/1519] Staging: bcm: Fix assignment issue in if statement reported by checkpatch.pl. This patch fixes an error where an assignment "=" was being used in an if statement to determine if Firmware was downloaded. This patch removes that assignment, and places it above the if statement. The if statement then evaluates the status to verify if "0" successful, or != 0 failure. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 0882e04963a..e9f29d59751 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -1045,7 +1045,8 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) } /* Download Firmare */ - if ((status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) { + status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR); + if (status != 0) { BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present...\n"); goto OUT; } From f969f84ed92e55040dbf51398ba2d8f5d23bf498 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 10 Oct 2011 21:01:48 -0400 Subject: [PATCH 1408/1519] Staging: bcm: Fix coding style issues reported by checkpatch.pl This patch cleans up several code style issues found in InterfaceInit.c reported by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceInit.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index d78d5ef1f29..36991f7cbf3 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -139,8 +139,7 @@ static void ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C2, 4, TRUE); } -static int -usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) +static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); int retval; @@ -389,32 +388,32 @@ static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descripto static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd)); + return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd); } static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd)); + return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd); } static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd)); + return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd); } static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd)); + return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd); } static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd)); + return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd); } static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) { - return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd)); + return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd); } static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) @@ -462,7 +461,7 @@ static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) if (bBcm16 == TRUE) { /* selecting alternate setting one as a default setting for High Speed modem. */ if (psIntfAdapter->bHighSpeedDevice) - retval= usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1); + retval = usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1); BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is applicable on this dongle\n"); if (retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) { @@ -497,7 +496,7 @@ static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) if ((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) { /* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */ UINT _uiData = ntohl(EP2_CFG_INT); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Reverting Bulk to INT as it is in Full Speed mode.\n"); BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter, (PUCHAR)&_uiData, 0x136, 4, TRUE); } @@ -579,7 +578,7 @@ static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) psIntfAdapter->sIntrOut.int_out_size = buffer_size; psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; - psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, GFP_KERNEL); + psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!psIntfAdapter->sIntrOut.int_out_buffer) { dev_err(&psIntfAdapter->udev->dev, "could not allocate interrupt_out_buffer\n"); @@ -641,8 +640,8 @@ static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) static int InterfaceResume(struct usb_interface *intf) { PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); - mdelay(100); + mdelay(100); psIntfAdapter->bSuspended = FALSE; StartInterruptUrb(psIntfAdapter); From ca45e70029b3d96923953992c05a2515dd3d9f24 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 10 Oct 2011 21:01:49 -0400 Subject: [PATCH 1409/1519] Staging: bcm: Remove assignment from if conditions reported by checkpatch.pl This patch removes an assignment from three if conditions. In all three cases, the line of code was attempting to allocate memory, and check if the memory was allocated in the if statement. This issue was reported by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceInit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index 36991f7cbf3..a09d35108f0 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -280,8 +280,9 @@ static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) int i = 0; for (i = 0; i < MAXIMUM_USB_TCB; i++) { - if ((psIntfAdapter->asUsbTcb[i].urb = - usb_alloc_urb(0, GFP_KERNEL)) == NULL) { + psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); + + if (psIntfAdapter->asUsbTcb[i].urb == NULL) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate Tx urb for index %d\n", i); return -ENOMEM; @@ -289,14 +290,17 @@ static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) } for (i = 0; i < MAXIMUM_USB_RCB; i++) { - if ((psIntfAdapter->asUsbRcb[i].urb = - usb_alloc_urb(0, GFP_KERNEL)) == NULL) { + psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); + + if (psIntfAdapter->asUsbRcb[i].urb == NULL) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate Rx urb for index %d\n", i); return -ENOMEM; } - if ((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = - kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL) { + + psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL); + + if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate Rx buffer for index %d\n", i); return -ENOMEM; From 54ced00639aa90c92e0ce399cc84ca6fc6a2eebb Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Mon, 10 Oct 2011 21:01:50 -0400 Subject: [PATCH 1410/1519] Staging: bcm: Fix coding style issues in InterfaceMisc.c This patch cleans up several code style issues found in InterfaceMisc.c reported by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceMisc.c | 342 +++++++++++++--------------- 1 file changed, 157 insertions(+), 185 deletions(-) diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c index a51185b522c..61f878b4f56 100644 --- a/drivers/staging/bcm/InterfaceMisc.c +++ b/drivers/staging/bcm/InterfaceMisc.c @@ -1,246 +1,219 @@ #include "headers.h" -INT -InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, - UINT addr, - PVOID buff, - INT len) +INT InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, + UINT addr, + PVOID buff, + INT len) { int retval = 0; - USHORT usRetries = 0 ; - if(psIntfAdapter == NULL ) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Interface Adapter is NULL"); - return -EINVAL ; - } + USHORT usRetries = 0; - if(psIntfAdapter->psAdapter->device_removed == TRUE) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed"); - return -ENODEV; - } - - if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus"); - return -EACCES; - } - - if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed.."); - return -EACCES; - } - psIntfAdapter->psAdapter->DeviceAccess = TRUE ; - do { - retval = usb_control_msg(psIntfAdapter->udev, - usb_rcvctrlpipe(psIntfAdapter->udev,0), - 0x02, - 0xC2, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); - - usRetries++ ; - if(-ENODEV == retval) - { - psIntfAdapter->psAdapter->device_removed =TRUE; - break; - } - - }while((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES ) ); - - if(retval < 0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d, retires :%d", retval,usRetries); - psIntfAdapter->psAdapter->DeviceAccess = FALSE ; - return retval; - } - else - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM sent %d", retval); - psIntfAdapter->psAdapter->DeviceAccess = FALSE ; - return STATUS_SUCCESS; - } -} - -INT -InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, - UINT addr, - PVOID buff, - INT len) -{ - int retval = 0; - USHORT usRetries = 0 ; - - if(psIntfAdapter == NULL ) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); + if (psIntfAdapter == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); return -EINVAL; } - if(psIntfAdapter->psAdapter->device_removed == TRUE) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed"); + if (psIntfAdapter->psAdapter->device_removed == TRUE) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Device got removed"); return -ENODEV; } - if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus..."); + if ((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "Currently Xaction is not allowed on the bus"); return -EACCES; } - if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed.."); + if (psIntfAdapter->bSuspended == TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "Bus is in suspended states hence RDM not allowed.."); return -EACCES; } - psIntfAdapter->psAdapter->DeviceAccess = TRUE ; - do{ + psIntfAdapter->psAdapter->DeviceAccess = TRUE; + + do { retval = usb_control_msg(psIntfAdapter->udev, - usb_sndctrlpipe(psIntfAdapter->udev,0), - 0x01, - 0x42, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); + usb_rcvctrlpipe(psIntfAdapter->udev, 0), + 0x02, + 0xC2, + (addr & 0xFFFF), + ((addr >> 16) & 0xFFFF), + buff, + len, + 5000); - usRetries++ ; - if(-ENODEV == retval) - { - psIntfAdapter->psAdapter->device_removed = TRUE ; + usRetries++; + if (-ENODEV == retval) { + psIntfAdapter->psAdapter->device_removed = TRUE; break; } - }while((retval < 0) && ( usRetries < MAX_RDM_WRM_RETIRES)); + } while ((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES)); - if(retval < 0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries); - psIntfAdapter->psAdapter->DeviceAccess = FALSE ; + if (retval < 0) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d, retires :%d", retval, usRetries); + psIntfAdapter->psAdapter->DeviceAccess = FALSE; return retval; - } - else - { - psIntfAdapter->psAdapter->DeviceAccess = FALSE ; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval); + } else { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM sent %d", retval); + psIntfAdapter->psAdapter->DeviceAccess = FALSE; return STATUS_SUCCESS; - } - } -INT -BcmRDM(PVOID arg, - UINT addr, - PVOID buff, - INT len) +INT InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, + UINT addr, + PVOID buff, + INT len) +{ + int retval = 0; + USHORT usRetries = 0; + + if (psIntfAdapter == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); + return -EINVAL; + } + + if (psIntfAdapter->psAdapter->device_removed == TRUE) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Device got removed"); + return -ENODEV; + } + + if ((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "Currently Xaction is not allowed on the bus..."); + return -EACCES; + } + + if (psIntfAdapter->bSuspended == TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "Bus is in suspended states hence RDM not allowed.."); + return -EACCES; + } + + psIntfAdapter->psAdapter->DeviceAccess = TRUE; + + do { + retval = usb_control_msg(psIntfAdapter->udev, + usb_sndctrlpipe(psIntfAdapter->udev, 0), + 0x01, + 0x42, + (addr & 0xFFFF), + ((addr >> 16) & 0xFFFF), + buff, + len, + 5000); + + usRetries++; + if (-ENODEV == retval) { + psIntfAdapter->psAdapter->device_removed = TRUE; + break; + } + + } while ((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES)); + + if (retval < 0) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries); + psIntfAdapter->psAdapter->DeviceAccess = FALSE; + return retval; + } else { + psIntfAdapter->psAdapter->DeviceAccess = FALSE; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval); + return STATUS_SUCCESS; + } +} + +INT BcmRDM(PVOID arg, + UINT addr, + PVOID buff, + INT len) { return InterfaceRDM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); } -INT -BcmWRM(PVOID arg, - UINT addr, - PVOID buff, - INT len) +INT BcmWRM(PVOID arg, + UINT addr, + PVOID buff, + INT len) { return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); } - - INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter) { PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter); - INT status = STATUS_SUCCESS ; + INT status = STATUS_SUCCESS; /* - usb_clear_halt - tells device to clear endpoint halt/stall condition - @dev: device whose endpoint is halted - @pipe: endpoint "pipe" being cleared - @ Context: !in_interrupt () + * usb_clear_halt - tells device to clear endpoint halt/stall condition + * @dev: device whose endpoint is halted + * @pipe: endpoint "pipe" being cleared + * @ Context: !in_interrupt () + * + * usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code. + * This is used to clear halt conditions for bulk and interrupt endpoints only. + * Control and isochronous endpoints never halts. + * + * Any URBs queued for such an endpoint should normally be unlinked by the driver + * before clearing the halt condition. + * + */ - usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code. - This is used to clear halt conditions for bulk and interrupt endpoints only. - Control and isochronous endpoints never halts. - - Any URBs queued for such an endpoint should normally be unlinked by the driver - before clearing the halt condition. - - */ - - //Killing all the submitted urbs to different end points. + /* Killing all the submitted urbs to different end points. */ Bcm_kill_all_URBs(psIntfAdapter); + /* clear the halted/stalled state for every end point */ + status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sIntrIn.int_in_pipe); + if (status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status); - //clear the halted/stalled state for every end point - status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sIntrIn.int_in_pipe); - if(status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status); + status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_pipe); + if (status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status); - status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkIn.bulk_in_pipe); - if(status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status); + status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sBulkOut.bulk_out_pipe); + if (status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status); - status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkOut.bulk_out_pipe); - if(status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status); - - return status ; + return status; } - VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) { struct urb *tempUrb = NULL; UINT i; - /** - * usb_kill_urb - cancel a transfer request and wait for it to finish - * @urb: pointer to URB describing a previously submitted request, - * returns nothing as it is void returned API. - * - * This routine cancels an in-progress request. It is guaranteed that - * upon return all completion handlers will have finished and the URB - * will be totally idle and available for reuse - - * This routine may not be used in an interrupt context (such as a bottom - * half or a completion handler), or when holding a spinlock, or in other - * situations where the caller can't schedule(). - * - **/ + /* + * usb_kill_urb - cancel a transfer request and wait for it to finish + * @urb: pointer to URB describing a previously submitted request, + * returns nothing as it is void returned API. + * + * This routine cancels an in-progress request. It is guaranteed that + * upon return all completion handlers will have finished and the URB + * will be totally idle and available for reuse + * + * This routine may not be used in an interrupt context (such as a bottom + * half or a completion handler), or when holding a spinlock, or in other + * situations where the caller can't schedule(). + * + */ /* Cancel submitted Interrupt-URB's */ - if(psIntfAdapter->psInterruptUrb != NULL) - { - if(psIntfAdapter->psInterruptUrb->status == -EINPROGRESS) - usb_kill_urb(psIntfAdapter->psInterruptUrb); + if (psIntfAdapter->psInterruptUrb != NULL) { + if (psIntfAdapter->psInterruptUrb->status == -EINPROGRESS) + usb_kill_urb(psIntfAdapter->psInterruptUrb); } /* Cancel All submitted TX URB's */ - for(i = 0; i < MAXIMUM_USB_TCB; i++) - { + for (i = 0; i < MAXIMUM_USB_TCB; i++) { tempUrb = psIntfAdapter->asUsbTcb[i].urb; - if(tempUrb) - { - if(tempUrb->status == -EINPROGRESS) + if (tempUrb) { + if (tempUrb->status == -EINPROGRESS) usb_kill_urb(tempUrb); } } - for(i = 0; i < MAXIMUM_USB_RCB; i++) - { + for (i = 0; i < MAXIMUM_USB_RCB; i++) { tempUrb = psIntfAdapter->asUsbRcb[i].urb; - if(tempUrb) - { - if(tempUrb->status == -EINPROGRESS) - usb_kill_urb(tempUrb); + if (tempUrb) { + if (tempUrb->status == -EINPROGRESS) + usb_kill_urb(tempUrb); } } @@ -253,13 +226,12 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) VOID putUsbSuspend(struct work_struct *work) { - PS_INTERFACE_ADAPTER psIntfAdapter = NULL ; - struct usb_interface *intf = NULL ; - psIntfAdapter = container_of(work, S_INTERFACE_ADAPTER,usbSuspendWork); - intf=psIntfAdapter->interface ; + PS_INTERFACE_ADAPTER psIntfAdapter = NULL; + struct usb_interface *intf = NULL; + psIntfAdapter = container_of(work, S_INTERFACE_ADAPTER, usbSuspendWork); + intf = psIntfAdapter->interface; - if(psIntfAdapter->bSuspended == FALSE) + if (psIntfAdapter->bSuspended == FALSE) usb_autopm_put_interface(intf); - } From fc2d6e573be68ac7b5a0730981fe9444ea2e2eaf Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 7 Oct 2011 16:24:40 +0200 Subject: [PATCH 1411/1519] staging: brcm80211: remove brcm80211 driver from the staging tree With the mainline patch being applied to the wireless-next repository by John Linville this driver is no longer needed under the staging directory. This patch ends its life under the staging tree. Cc: John W. Linville Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 2 - drivers/staging/brcm80211/Kconfig | 35 - drivers/staging/brcm80211/Makefile | 23 - drivers/staging/brcm80211/README | 1 - drivers/staging/brcm80211/TODO | 9 - drivers/staging/brcm80211/brcmfmac/Makefile | 33 - drivers/staging/brcm80211/brcmfmac/bcmchip.h | 32 - drivers/staging/brcm80211/brcmfmac/bcmsdh.c | 371 - .../staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 625 - drivers/staging/brcm80211/brcmfmac/dhd.h | 773 - drivers/staging/brcm80211/brcmfmac/dhd_bus.h | 57 - drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 498 - .../staging/brcm80211/brcmfmac/dhd_common.c | 872 - drivers/staging/brcm80211/brcmfmac/dhd_dbg.h | 58 - .../staging/brcm80211/brcmfmac/dhd_linux.c | 1354 - .../staging/brcm80211/brcmfmac/dhd_proto.h | 60 - drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 4581 --- .../staging/brcm80211/brcmfmac/sdio_host.h | 252 - .../staging/brcm80211/brcmfmac/wl_cfg80211.c | 3730 -- .../staging/brcm80211/brcmfmac/wl_cfg80211.h | 375 - drivers/staging/brcm80211/brcmsmac/Makefile | 51 - drivers/staging/brcm80211/brcmsmac/aiutils.c | 2079 -- drivers/staging/brcm80211/brcmsmac/aiutils.h | 378 - drivers/staging/brcm80211/brcmsmac/ampdu.c | 1241 - drivers/staging/brcm80211/brcmsmac/ampdu.h | 30 - drivers/staging/brcm80211/brcmsmac/antsel.c | 308 - drivers/staging/brcm80211/brcmsmac/antsel.h | 29 - .../brcm80211/brcmsmac/brcms_trace_events.c | 23 - .../brcm80211/brcmsmac/brcms_trace_events.h | 92 - drivers/staging/brcm80211/brcmsmac/channel.c | 1565 - drivers/staging/brcm80211/brcmsmac/channel.h | 53 - drivers/staging/brcm80211/brcmsmac/d11.h | 1898 - drivers/staging/brcm80211/brcmsmac/dma.c | 1425 - drivers/staging/brcm80211/brcmsmac/dma.h | 120 - .../staging/brcm80211/brcmsmac/mac80211_if.c | 1701 - .../staging/brcm80211/brcmsmac/mac80211_if.h | 107 - drivers/staging/brcm80211/brcmsmac/main.c | 8841 ----- drivers/staging/brcm80211/brcmsmac/main.h | 819 - drivers/staging/brcm80211/brcmsmac/nicpci.c | 835 - drivers/staging/brcm80211/brcmsmac/nicpci.h | 82 - drivers/staging/brcm80211/brcmsmac/otp.c | 426 - drivers/staging/brcm80211/brcmsmac/otp.h | 36 - .../staging/brcm80211/brcmsmac/phy/phy_cmn.c | 2988 -- .../staging/brcm80211/brcmsmac/phy/phy_hal.h | 301 - .../staging/brcm80211/brcmsmac/phy/phy_int.h | 1169 - .../staging/brcm80211/brcmsmac/phy/phy_lcn.c | 5154 --- .../staging/brcm80211/brcmsmac/phy/phy_lcn.h | 121 - .../staging/brcm80211/brcmsmac/phy/phy_n.c | 28876 ---------------- .../brcm80211/brcmsmac/phy/phy_qmath.c | 308 - .../brcm80211/brcmsmac/phy/phy_qmath.h | 42 - .../brcm80211/brcmsmac/phy/phy_radio.h | 1533 - .../staging/brcm80211/brcmsmac/phy/phyreg_n.h | 167 - .../brcm80211/brcmsmac/phy/phytbl_lcn.c | 3250 -- .../brcm80211/brcmsmac/phy/phytbl_lcn.h | 54 - .../staging/brcm80211/brcmsmac/phy/phytbl_n.c | 10630 ------ .../staging/brcm80211/brcmsmac/phy/phytbl_n.h | 50 - drivers/staging/brcm80211/brcmsmac/phy_shim.c | 226 - drivers/staging/brcm80211/brcmsmac/phy_shim.h | 185 - drivers/staging/brcm80211/brcmsmac/pmu.c | 458 - drivers/staging/brcm80211/brcmsmac/pmu.h | 38 - drivers/staging/brcm80211/brcmsmac/pub.h | 655 - drivers/staging/brcm80211/brcmsmac/rate.c | 514 - drivers/staging/brcm80211/brcmsmac/rate.h | 250 - drivers/staging/brcm80211/brcmsmac/scb.h | 82 - drivers/staging/brcm80211/brcmsmac/srom.c | 1298 - drivers/staging/brcm80211/brcmsmac/srom.h | 34 - drivers/staging/brcm80211/brcmsmac/stf.c | 438 - drivers/staging/brcm80211/brcmsmac/stf.h | 42 - drivers/staging/brcm80211/brcmsmac/types.h | 352 - .../staging/brcm80211/brcmsmac/ucode_loader.c | 109 - .../staging/brcm80211/brcmsmac/ucode_loader.h | 58 - drivers/staging/brcm80211/brcmutil/Makefile | 29 - drivers/staging/brcm80211/brcmutil/utils.c | 600 - drivers/staging/brcm80211/brcmutil/wifi.c | 136 - .../staging/brcm80211/include/brcm_hw_ids.h | 59 - .../staging/brcm80211/include/brcmu_utils.h | 223 - .../staging/brcm80211/include/brcmu_wifi.h | 275 - .../staging/brcm80211/include/chipcommon.h | 284 - drivers/staging/brcm80211/include/defs.h | 104 - drivers/staging/brcm80211/include/soc.h | 90 - 81 files changed, 97064 deletions(-) delete mode 100644 drivers/staging/brcm80211/Kconfig delete mode 100644 drivers/staging/brcm80211/Makefile delete mode 100644 drivers/staging/brcm80211/README delete mode 100644 drivers/staging/brcm80211/TODO delete mode 100644 drivers/staging/brcm80211/brcmfmac/Makefile delete mode 100644 drivers/staging/brcm80211/brcmfmac/bcmchip.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/bcmsdh.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_bus.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_common.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_dbg.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_linux.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_proto.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/sdio_host.h delete mode 100644 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c delete mode 100644 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/Makefile delete mode 100644 drivers/staging/brcm80211/brcmsmac/aiutils.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/aiutils.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/ampdu.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/ampdu.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/antsel.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/antsel.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/channel.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/channel.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/d11.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/dma.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/dma.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/mac80211_if.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/mac80211_if.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/main.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/main.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/nicpci.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/nicpci.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/otp.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/otp.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_int.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_n.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phy_radio.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phyreg_n.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy_shim.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/phy_shim.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/pmu.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/pmu.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/pub.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/rate.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/rate.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/scb.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/srom.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/srom.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/stf.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/stf.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/types.h delete mode 100644 drivers/staging/brcm80211/brcmsmac/ucode_loader.c delete mode 100644 drivers/staging/brcm80211/brcmsmac/ucode_loader.h delete mode 100644 drivers/staging/brcm80211/brcmutil/Makefile delete mode 100644 drivers/staging/brcm80211/brcmutil/utils.c delete mode 100644 drivers/staging/brcm80211/brcmutil/wifi.c delete mode 100644 drivers/staging/brcm80211/include/brcm_hw_ids.h delete mode 100644 drivers/staging/brcm80211/include/brcmu_utils.h delete mode 100644 drivers/staging/brcm80211/include/brcmu_wifi.h delete mode 100644 drivers/staging/brcm80211/include/chipcommon.h delete mode 100644 drivers/staging/brcm80211/include/defs.h delete mode 100644 drivers/staging/brcm80211/include/soc.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index eac0a7fd8ef..ece5033b135 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -44,8 +44,6 @@ source "drivers/staging/wlan-ng/Kconfig" source "drivers/staging/echo/Kconfig" -source "drivers/staging/brcm80211/Kconfig" - source "drivers/staging/comedi/Kconfig" source "drivers/staging/olpc_dcon/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 20be1129424..bd8267411a6 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -14,8 +14,6 @@ obj-$(CONFIG_USBIP_CORE) += usbip/ obj-$(CONFIG_W35UND) += winbond/ obj-$(CONFIG_PRISM2_USB) += wlan-ng/ obj-$(CONFIG_ECHO) += echo/ -obj-$(CONFIG_BRCMSMAC) += brcm80211/ -obj-$(CONFIG_BRCMFMAC) += brcm80211/ obj-$(CONFIG_COMEDI) += comedi/ obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ obj-$(CONFIG_ASUS_OLED) += asus_oled/ diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig deleted file mode 100644 index f51e0f17d70..00000000000 --- a/drivers/staging/brcm80211/Kconfig +++ /dev/null @@ -1,35 +0,0 @@ -config BRCMUTIL - tristate - -config BRCMSMAC - tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - depends on PCI - depends on WLAN && MAC80211 - depends on BCMA=n - select BRCMUTIL - select FW_LOADER - select CRC_CCITT - select CRC8 - select CORDIC - ---help--- - This module adds support for PCIe wireless adapters based on Broadcom - IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll - be called brcmsmac.ko. - -config BRCMFMAC - tristate "Broadcom IEEE802.11n embedded FullMAC WLAN driver" - depends on MMC - depends on WLAN && CFG80211 - select BRCMUTIL - select FW_LOADER - ---help--- - This module adds support for embedded wireless adapters based on - Broadcom IEEE802.11n FullMAC chipsets. This driver uses the kernel's - wireless extensions subsystem. If you choose to build a module, - it'll be called brcmfmac.ko. - -config BRCMDBG - bool "Broadcom driver debug functions" - depends on BRCMSMAC || BRCMFMAC - ---help--- - Selecting this enables additional code for debug purposes. diff --git a/drivers/staging/brcm80211/Makefile b/drivers/staging/brcm80211/Makefile deleted file mode 100644 index f41c047eca8..00000000000 --- a/drivers/staging/brcm80211/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# -# Makefile fragment for Broadcom 802.11n Networking Device Driver -# -# Copyright (c) 2010 Broadcom Corporation -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -# common flags -subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG - -obj-$(CONFIG_BRCMUTIL) += brcmutil/ -obj-$(CONFIG_BRCMFMAC) += brcmfmac/ -obj-$(CONFIG_BRCMSMAC) += brcmsmac/ diff --git a/drivers/staging/brcm80211/README b/drivers/staging/brcm80211/README deleted file mode 100644 index bb86b1b3e58..00000000000 --- a/drivers/staging/brcm80211/README +++ /dev/null @@ -1 +0,0 @@ -refer to: http://linuxwireless.org/en/users/Drivers/brcm80211 diff --git a/drivers/staging/brcm80211/TODO b/drivers/staging/brcm80211/TODO deleted file mode 100644 index 7f68762b1c3..00000000000 --- a/drivers/staging/brcm80211/TODO +++ /dev/null @@ -1,9 +0,0 @@ -To Do List for Broadcom Mac80211 driver before getting in mainline - -Bugs -==== -- none known at this moment - -brcm80211 info page -===================== -http://linuxwireless.org/en/users/Drivers/brcm80211 diff --git a/drivers/staging/brcm80211/brcmfmac/Makefile b/drivers/staging/brcm80211/brcmfmac/Makefile deleted file mode 100644 index a1b7637dce3..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# Makefile fragment for Broadcom 802.11n Networking Device Driver -# -# Copyright (c) 2010 Broadcom Corporation -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -ccflags-y += \ - -Idrivers/staging/brcm80211/brcmfmac \ - -Idrivers/staging/brcm80211/include - -DHDOFILES = \ - wl_cfg80211.o \ - dhd_cdc.o \ - dhd_common.o \ - dhd_sdio.o \ - dhd_linux.o \ - bcmsdh.o \ - bcmsdh_sdmmc.o - -obj-$(CONFIG_BRCMFMAC) += brcmfmac.o -brcmfmac-objs += $(DHDOFILES) -ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/staging/brcm80211/brcmfmac/bcmchip.h b/drivers/staging/brcm80211/brcmfmac/bcmchip.h deleted file mode 100644 index d7d3afd5a10..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/bcmchip.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _bcmchip_h_ -#define _bcmchip_h_ - -/* bcm4329 */ -/* SDIO device core, ID 0x829 */ -#define BCM4329_CORE_BUS_BASE 0x18011000 -/* internal memory core, ID 0x80e */ -#define BCM4329_CORE_SOCRAM_BASE 0x18003000 -/* ARM Cortex M3 core, ID 0x82a */ -#define BCM4329_CORE_ARM_BASE 0x18002000 -#define BCM4329_RAMSIZE 0x48000 -/* firmware name */ -#define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" -#define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt" - -#endif /* _bcmchip_h_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c deleted file mode 100644 index bff9dcd6fad..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/* ****************** SDIO CARD Interface Functions **************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include "dhd.h" -#include "dhd_bus.h" -#include "dhd_dbg.h" -#include "sdio_host.h" - -#define SDIOH_API_ACCESS_RETRY_LIMIT 2 - -static void brcmf_sdioh_irqhandler(struct sdio_func *func) -{ - struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); - - brcmf_dbg(TRACE, "***IRQHandler\n"); - - sdio_release_host(func); - - brcmf_sdbrcm_isr(sdiodev->bus); - - sdio_claim_host(func); -} - -int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) -{ - brcmf_dbg(TRACE, "Entering\n"); - - sdio_claim_host(sdiodev->func[1]); - sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler); - sdio_release_host(sdiodev->func[1]); - - return 0; -} - -int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) -{ - brcmf_dbg(TRACE, "Entering\n"); - - sdio_claim_host(sdiodev->func[1]); - sdio_release_irq(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - - return 0; -} - -u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, - int *err) -{ - int status; - s32 retry = 0; - u8 data = 0; - - do { - if (retry) /* wait for 1 ms till bus get settled down */ - udelay(1000); - status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num, - addr, (u8 *) &data); - } while (status != 0 - && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); - if (err) - *err = status; - - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n", - fnc_num, addr, data); - - return data; -} - -void -brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, - u8 data, int *err) -{ - int status; - s32 retry = 0; - - do { - if (retry) /* wait for 1 ms till bus get settled down */ - udelay(1000); - status = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, fnc_num, - addr, (u8 *) &data); - } while (status != 0 - && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT)); - if (err) - *err = status; - - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n", - fnc_num, addr, data); -} - -int -brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) -{ - int err = 0; - brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, - (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); - if (!err) - brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SBADDRMID, - (address >> 16) & SBSDIO_SBADDRMID_MASK, - &err); - if (!err) - brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SBADDRHIGH, - (address >> 24) & SBSDIO_SBADDRHIGH_MASK, - &err); - - return err; -} - -u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size) -{ - int status; - u32 word = 0; - uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - - brcmf_dbg(INFO, "fun = 1, addr = 0x%x\n", addr); - - if (bar0 != sdiodev->sbwad) { - if (brcmf_sdcard_set_sbaddr_window(sdiodev, bar0)) - return 0xFFFFFFFF; - - sdiodev->sbwad = bar0; - } - - addr &= SBSDIO_SB_OFT_ADDR_MASK; - if (size == 4) - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - - status = brcmf_sdioh_request_word(sdiodev, SDIOH_READ, SDIO_FUNC_1, - addr, &word, size); - - sdiodev->regfail = (status != 0); - - brcmf_dbg(INFO, "u32data = 0x%x\n", word); - - /* if ok, return appropriately masked word */ - if (status == 0) { - switch (size) { - case sizeof(u8): - return word & 0xff; - case sizeof(u16): - return word & 0xffff; - case sizeof(u32): - return word; - default: - sdiodev->regfail = true; - - } - } - - /* otherwise, bad sdio access or invalid size */ - brcmf_dbg(ERROR, "error reading addr 0x%04x size %d\n", addr, size); - return 0xFFFFFFFF; -} - -u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, - u32 data) -{ - int status; - uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - int err = 0; - - brcmf_dbg(INFO, "fun = 1, addr = 0x%x, uint%ddata = 0x%x\n", - addr, size * 8, data); - - if (bar0 != sdiodev->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); - if (err) - return err; - - sdiodev->sbwad = bar0; - } - - addr &= SBSDIO_SB_OFT_ADDR_MASK; - if (size == 4) - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - status = - brcmf_sdioh_request_word(sdiodev, SDIOH_WRITE, SDIO_FUNC_1, - addr, &data, size); - sdiodev->regfail = (status != 0); - - if (status == 0) - return 0; - - brcmf_dbg(ERROR, "error writing 0x%08x to addr 0x%04x size %d\n", - data, addr, size); - return 0xFFFFFFFF; -} - -bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev) -{ - return sdiodev->regfail; -} - -int -brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt) -{ - int status; - uint incr_fix; - uint width; - uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - int err = 0; - - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); - - /* Async not implemented yet */ - if (flags & SDIO_REQ_ASYNC) - return -ENOTSUPP; - - if (bar0 != sdiodev->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); - if (err) - return err; - - sdiodev->sbwad = bar0; - } - - addr &= SBSDIO_SB_OFT_ADDR_MASK; - - incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; - width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; - if (width == 4) - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - - status = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, - fn, addr, width, nbytes, buf, pkt); - - return status; -} - -int -brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt) -{ - uint incr_fix; - uint width; - uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; - int err = 0; - - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); - - /* Async not implemented yet */ - if (flags & SDIO_REQ_ASYNC) - return -ENOTSUPP; - - if (bar0 != sdiodev->sbwad) { - err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); - if (err) - return err; - - sdiodev->sbwad = bar0; - } - - addr &= SBSDIO_SB_OFT_ADDR_MASK; - - incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; - width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; - if (width == 4) - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - - return brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_WRITE, fn, - addr, width, nbytes, buf, pkt); -} - -int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, - u8 *buf, uint nbytes) -{ - addr &= SBSDIO_SB_OFT_ADDR_MASK; - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - - return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_INC, - (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, - addr, 4, nbytes, buf, NULL); -} - -int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) -{ - char t_func = (char)fn; - brcmf_dbg(TRACE, "Enter\n"); - - /* issue abort cmd52 command through F0 */ - brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, SDIO_FUNC_0, - SDIO_CCCR_ABORT, &t_func); - - brcmf_dbg(TRACE, "Exit\n"); - return 0; -} - -int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) -{ - u32 regs = 0; - int ret = 0; - - ret = brcmf_sdioh_attach(sdiodev); - if (ret) - goto out; - - regs = SI_ENUM_BASE; - - /* Report the BAR, to fix if needed */ - sdiodev->sbwad = SI_ENUM_BASE; - - /* try to attach to the target device */ - sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev); - if (!sdiodev->bus) { - brcmf_dbg(ERROR, "device attach failed\n"); - ret = -ENODEV; - goto out; - } - -out: - if (ret) - brcmf_sdio_remove(sdiodev); - - return ret; -} -EXPORT_SYMBOL(brcmf_sdio_probe); - -int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev) -{ - if (sdiodev->bus) { - brcmf_sdbrcm_disconnect(sdiodev->bus); - sdiodev->bus = NULL; - } - - brcmf_sdioh_detach(sdiodev); - - sdiodev->sbwad = 0; - - return 0; -} -EXPORT_SYMBOL(brcmf_sdio_remove); - -void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable) -{ - if (enable) - brcmf_sdbrcm_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS); - else - brcmf_sdbrcm_wd_timer(sdiodev->bus, 0); -} diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c deleted file mode 100644 index e919de210f7..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ /dev/null @@ -1,625 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* request_irq() */ -#include - -#include -#include -#include -#include -#include "sdio_host.h" -#include "dhd.h" -#include "dhd_dbg.h" -#include "wl_cfg80211.h" - -#define SDIO_VENDOR_ID_BROADCOM 0x02d0 - -#define DMA_ALIGN_MASK 0x03 - -#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 - -#define SDIO_FUNC1_BLOCKSIZE 64 -#define SDIO_FUNC2_BLOCKSIZE 512 - -/* devices we support, null terminated */ -static const struct sdio_device_id brcmf_sdmmc_ids[] = { - {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, - { /* end: all zeroes */ }, -}; -MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); - -static bool -brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev) -{ - bool is_err = false; -#ifdef CONFIG_PM_SLEEP - is_err = atomic_read(&sdiodev->suspend); -#endif - return is_err; -} - -static void -brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t *wq) -{ -#ifdef CONFIG_PM_SLEEP - int retry = 0; - while (atomic_read(&sdiodev->suspend) && retry++ != 30) - wait_event_timeout(*wq, false, HZ/100); -#endif -} - -static inline int brcmf_sdioh_f0_write_byte(struct brcmf_sdio_dev *sdiodev, - uint regaddr, u8 *byte) -{ - struct sdio_func *sdfunc = sdiodev->func[0]; - int err_ret; - - /* - * Can only directly write to some F0 registers. - * Handle F2 enable/disable and Abort command - * as a special case. - */ - if (regaddr == SDIO_CCCR_IOEx) { - sdfunc = sdiodev->func[2]; - if (sdfunc) { - sdio_claim_host(sdfunc); - if (*byte & SDIO_FUNC_ENABLE_2) { - /* Enable Function 2 */ - err_ret = sdio_enable_func(sdfunc); - if (err_ret) - brcmf_dbg(ERROR, - "enable F2 failed:%d\n", - err_ret); - } else { - /* Disable Function 2 */ - err_ret = sdio_disable_func(sdfunc); - if (err_ret) - brcmf_dbg(ERROR, - "Disable F2 failed:%d\n", - err_ret); - } - sdio_release_host(sdfunc); - } - } else if (regaddr == SDIO_CCCR_ABORT) { - sdio_claim_host(sdfunc); - sdio_writeb(sdfunc, *byte, regaddr, &err_ret); - sdio_release_host(sdfunc); - } else if (regaddr < 0xF0) { - brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", regaddr); - err_ret = -EPERM; - } else { - sdio_claim_host(sdfunc); - sdio_f0_writeb(sdfunc, *byte, regaddr, &err_ret); - sdio_release_host(sdfunc); - } - - return err_ret; -} - -int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, - uint regaddr, u8 *byte) -{ - int err_ret; - - brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); - - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_byte_wait); - if (brcmf_pm_resume_error(sdiodev)) - return -EIO; - - if (rw && func == 0) { - /* handle F0 separately */ - err_ret = brcmf_sdioh_f0_write_byte(sdiodev, regaddr, byte); - } else { - sdio_claim_host(sdiodev->func[func]); - if (rw) /* CMD52 Write */ - sdio_writeb(sdiodev->func[func], *byte, regaddr, - &err_ret); - else if (func == 0) { - *byte = sdio_f0_readb(sdiodev->func[func], regaddr, - &err_ret); - } else { - *byte = sdio_readb(sdiodev->func[func], regaddr, - &err_ret); - } - sdio_release_host(sdiodev->func[func]); - } - - if (err_ret) - brcmf_dbg(ERROR, "Failed to %s byte F%d:@0x%05x=%02x, Err: %d\n", - rw ? "write" : "read", func, regaddr, *byte, err_ret); - - return err_ret; -} - -int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, - uint rw, uint func, uint addr, u32 *word, - uint nbytes) -{ - int err_ret = -EIO; - - if (func == 0) { - brcmf_dbg(ERROR, "Only CMD52 allowed to F0\n"); - return -EINVAL; - } - - brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", - rw, func, addr, nbytes); - - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_word_wait); - if (brcmf_pm_resume_error(sdiodev)) - return -EIO; - /* Claim host controller */ - sdio_claim_host(sdiodev->func[func]); - - if (rw) { /* CMD52 Write */ - if (nbytes == 4) - sdio_writel(sdiodev->func[func], *word, addr, - &err_ret); - else if (nbytes == 2) - sdio_writew(sdiodev->func[func], (*word & 0xFFFF), - addr, &err_ret); - else - brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); - } else { /* CMD52 Read */ - if (nbytes == 4) - *word = sdio_readl(sdiodev->func[func], addr, &err_ret); - else if (nbytes == 2) - *word = sdio_readw(sdiodev->func[func], addr, - &err_ret) & 0xFFFF; - else - brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); - } - - /* Release host controller */ - sdio_release_host(sdiodev->func[func]); - - if (err_ret) - brcmf_dbg(ERROR, "Failed to %s word, Err: 0x%08x\n", - rw ? "write" : "read", err_ret); - - return err_ret; -} - -static int -brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, - uint write, uint func, uint addr, - struct sk_buff *pkt) -{ - bool fifo = (fix_inc == SDIOH_DATA_FIX); - u32 SGCount = 0; - int err_ret = 0; - - struct sk_buff *pnext; - - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_packet_wait); - if (brcmf_pm_resume_error(sdiodev)) - return -EIO; - - /* Claim host controller */ - sdio_claim_host(sdiodev->func[func]); - for (pnext = pkt; pnext; pnext = pnext->next) { - uint pkt_len = pnext->len; - pkt_len += 3; - pkt_len &= 0xFFFFFFFC; - - if ((write) && (!fifo)) { - err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, - ((u8 *) (pnext->data)), - pkt_len); - } else if (write) { - err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, - ((u8 *) (pnext->data)), - pkt_len); - } else if (fifo) { - err_ret = sdio_readsb(sdiodev->func[func], - ((u8 *) (pnext->data)), - addr, pkt_len); - } else { - err_ret = sdio_memcpy_fromio(sdiodev->func[func], - ((u8 *) (pnext->data)), - addr, pkt_len); - } - - if (err_ret) { - brcmf_dbg(ERROR, "%s FAILED %p[%d], addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", - write ? "TX" : "RX", pnext, SGCount, addr, - pkt_len, err_ret); - } else { - brcmf_dbg(TRACE, "%s xfr'd %p[%d], addr=0x%05x, len=%d\n", - write ? "TX" : "RX", pnext, SGCount, addr, - pkt_len); - } - - if (!fifo) - addr += pkt_len; - SGCount++; - - } - - /* Release host controller */ - sdio_release_host(sdiodev->func[func]); - - brcmf_dbg(TRACE, "Exit\n"); - return err_ret; -} - -/* - * This function takes a buffer or packet, and fixes everything up - * so that in the end, a DMA-able packet is created. - * - * A buffer does not have an associated packet pointer, - * and may or may not be aligned. - * A packet may consist of a single packet, or a packet chain. - * If it is a packet chain, then all the packets in the chain - * must be properly aligned. - * - * If the packet data is not aligned, then there may only be - * one packet, and in this case, it is copied to a new - * aligned packet. - * - */ -int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, - uint fix_inc, uint write, uint func, uint addr, - uint reg_width, uint buflen_u, u8 *buffer, - struct sk_buff *pkt) -{ - int Status; - struct sk_buff *mypkt = NULL; - - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait); - if (brcmf_pm_resume_error(sdiodev)) - return -EIO; - /* Case 1: we don't have a packet. */ - if (pkt == NULL) { - brcmf_dbg(DATA, "Creating new %s Packet, len=%d\n", - write ? "TX" : "RX", buflen_u); - mypkt = brcmu_pkt_buf_get_skb(buflen_u); - if (!mypkt) { - brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", - buflen_u); - return -EIO; - } - - /* For a write, copy the buffer data into the packet. */ - if (write) - memcpy(mypkt->data, buffer, buflen_u); - - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, mypkt); - - /* For a read, copy the packet data back to the buffer. */ - if (!write) - memcpy(buffer, mypkt->data, buflen_u); - - brcmu_pkt_buf_free_skb(mypkt); - } else if (((ulong) (pkt->data) & DMA_ALIGN_MASK) != 0) { - /* - * Case 2: We have a packet, but it is unaligned. - * In this case, we cannot have a chain (pkt->next == NULL) - */ - brcmf_dbg(DATA, "Creating aligned %s Packet, len=%d\n", - write ? "TX" : "RX", pkt->len); - mypkt = brcmu_pkt_buf_get_skb(pkt->len); - if (!mypkt) { - brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", - pkt->len); - return -EIO; - } - - /* For a write, copy the buffer data into the packet. */ - if (write) - memcpy(mypkt->data, pkt->data, pkt->len); - - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, mypkt); - - /* For a read, copy the packet data back to the buffer. */ - if (!write) - memcpy(pkt->data, mypkt->data, mypkt->len); - - brcmu_pkt_buf_free_skb(mypkt); - } else { /* case 3: We have a packet and - it is aligned. */ - brcmf_dbg(DATA, "Aligned %s Packet, direct DMA\n", - write ? "Tx" : "Rx"); - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, pkt); - } - - return Status; -} - -/* Read client card reg */ -static int -brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr, - int regsize, u32 *data) -{ - - if ((func == 0) || (regsize == 1)) { - u8 temp = 0; - - brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, func, regaddr, - &temp); - *data = temp; - *data &= 0xff; - brcmf_dbg(DATA, "byte read data=0x%02x\n", *data); - } else { - brcmf_sdioh_request_word(sdiodev, SDIOH_READ, func, regaddr, - data, regsize); - if (regsize == 2) - *data &= 0xffff; - - brcmf_dbg(DATA, "word read data=0x%08x\n", *data); - } - - return SUCCESS; -} - -static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr) -{ - /* read 24 bits and return valid 17 bit addr */ - int i; - u32 scratch, regdata; - __le32 scratch_le; - u8 *ptr = (u8 *)&scratch_le; - - for (i = 0; i < 3; i++) { - if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1, - ®data)) != SUCCESS) - brcmf_dbg(ERROR, "Can't read!\n"); - - *ptr++ = (u8) regdata; - regaddr++; - } - - /* Only the lower 17-bits are valid */ - scratch = le32_to_cpu(scratch_le); - scratch &= 0x0001FFFF; - return scratch; -} - -static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) -{ - int err_ret; - u32 fbraddr; - u8 func; - - brcmf_dbg(TRACE, "\n"); - - /* Get the Card's common CIS address */ - sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev, - SDIO_CCCR_CIS); - brcmf_dbg(INFO, "Card's Common CIS Ptr = 0x%x\n", - sdiodev->func_cis_ptr[0]); - - /* Get the Card's function CIS (for each function) */ - for (fbraddr = SDIO_FBR_BASE(1), func = 1; - func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { - sdiodev->func_cis_ptr[func] = - brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr); - brcmf_dbg(INFO, "Function %d CIS Ptr = 0x%x\n", - func, sdiodev->func_cis_ptr[func]); - } - - /* Enable Function 1 */ - sdio_claim_host(sdiodev->func[1]); - err_ret = sdio_enable_func(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - if (err_ret) - brcmf_dbg(ERROR, "Failed to enable F1 Err: 0x%08x\n", err_ret); - - return false; -} - -/* - * Public entry points & extern's - */ -int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) -{ - int err_ret = 0; - - brcmf_dbg(TRACE, "\n"); - - sdiodev->num_funcs = 2; - - sdio_claim_host(sdiodev->func[1]); - err_ret = sdio_set_block_size(sdiodev->func[1], SDIO_FUNC1_BLOCKSIZE); - sdio_release_host(sdiodev->func[1]); - if (err_ret) { - brcmf_dbg(ERROR, "Failed to set F1 blocksize\n"); - goto out; - } - - sdio_claim_host(sdiodev->func[2]); - err_ret = sdio_set_block_size(sdiodev->func[2], SDIO_FUNC2_BLOCKSIZE); - sdio_release_host(sdiodev->func[2]); - if (err_ret) { - brcmf_dbg(ERROR, "Failed to set F2 blocksize\n"); - goto out; - } - - brcmf_sdioh_enablefuncs(sdiodev); - -out: - brcmf_dbg(TRACE, "Done\n"); - return err_ret; -} - -void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) -{ - brcmf_dbg(TRACE, "\n"); - - /* Disable Function 2 */ - sdio_claim_host(sdiodev->func[2]); - sdio_disable_func(sdiodev->func[2]); - sdio_release_host(sdiodev->func[2]); - - /* Disable Function 1 */ - sdio_claim_host(sdiodev->func[1]); - sdio_disable_func(sdiodev->func[1]); - sdio_release_host(sdiodev->func[1]); - -} - -static int brcmf_ops_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - int ret = 0; - struct brcmf_sdio_dev *sdiodev; - brcmf_dbg(TRACE, "Enter\n"); - brcmf_dbg(TRACE, "func->class=%x\n", func->class); - brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor); - brcmf_dbg(TRACE, "sdio_device: 0x%04x\n", func->device); - brcmf_dbg(TRACE, "Function#: 0x%04x\n", func->num); - - if (func->num == 1) { - if (dev_get_drvdata(&func->card->dev)) { - brcmf_dbg(ERROR, "card private drvdata occupied\n"); - return -ENXIO; - } - sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); - if (!sdiodev) - return -ENOMEM; - sdiodev->func[0] = func->card->sdio_func[0]; - sdiodev->func[1] = func; - dev_set_drvdata(&func->card->dev, sdiodev); - - atomic_set(&sdiodev->suspend, false); - init_waitqueue_head(&sdiodev->request_byte_wait); - init_waitqueue_head(&sdiodev->request_word_wait); - init_waitqueue_head(&sdiodev->request_packet_wait); - init_waitqueue_head(&sdiodev->request_buffer_wait); - } - - if (func->num == 2) { - sdiodev = dev_get_drvdata(&func->card->dev); - if ((!sdiodev) || (sdiodev->func[1]->card != func->card)) - return -ENODEV; - sdiodev->func[2] = func; - - brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_probe...\n"); - ret = brcmf_sdio_probe(sdiodev); - } - - return ret; -} - -static void brcmf_ops_sdio_remove(struct sdio_func *func) -{ - struct brcmf_sdio_dev *sdiodev; - brcmf_dbg(TRACE, "Enter\n"); - brcmf_dbg(INFO, "func->class=%x\n", func->class); - brcmf_dbg(INFO, "sdio_vendor: 0x%04x\n", func->vendor); - brcmf_dbg(INFO, "sdio_device: 0x%04x\n", func->device); - brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num); - - if (func->num == 2) { - sdiodev = dev_get_drvdata(&func->card->dev); - brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); - brcmf_sdio_remove(sdiodev); - dev_set_drvdata(&func->card->dev, NULL); - kfree(sdiodev); - } -} - -#ifdef CONFIG_PM_SLEEP -static int brcmf_sdio_suspend(struct device *dev) -{ - mmc_pm_flag_t sdio_flags; - struct brcmf_sdio_dev *sdiodev; - struct sdio_func *func = dev_to_sdio_func(dev); - int ret = 0; - - brcmf_dbg(TRACE, "\n"); - - sdiodev = dev_get_drvdata(&func->card->dev); - - atomic_set(&sdiodev->suspend, true); - - sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]); - if (!(sdio_flags & MMC_PM_KEEP_POWER)) { - brcmf_dbg(ERROR, "Host can't keep power while suspended\n"); - return -EINVAL; - } - - ret = sdio_set_host_pm_flags(sdiodev->func[1], MMC_PM_KEEP_POWER); - if (ret) { - brcmf_dbg(ERROR, "Failed to set pm_flags\n"); - return ret; - } - - brcmf_sdio_wdtmr_enable(sdiodev, false); - - return ret; -} - -static int brcmf_sdio_resume(struct device *dev) -{ - struct brcmf_sdio_dev *sdiodev; - struct sdio_func *func = dev_to_sdio_func(dev); - - sdiodev = dev_get_drvdata(&func->card->dev); - brcmf_sdio_wdtmr_enable(sdiodev, true); - atomic_set(&sdiodev->suspend, false); - return 0; -} - -static const struct dev_pm_ops brcmf_sdio_pm_ops = { - .suspend = brcmf_sdio_suspend, - .resume = brcmf_sdio_resume, -}; -#endif /* CONFIG_PM_SLEEP */ - -static struct sdio_driver brcmf_sdmmc_driver = { - .probe = brcmf_ops_sdio_probe, - .remove = brcmf_ops_sdio_remove, - .name = "brcmfmac", - .id_table = brcmf_sdmmc_ids, -#ifdef CONFIG_PM_SLEEP - .drv = { - .pm = &brcmf_sdio_pm_ops, - }, -#endif /* CONFIG_PM_SLEEP */ -}; - -/* bus register interface */ -int brcmf_bus_register(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - return sdio_register_driver(&brcmf_sdmmc_driver); -} - -void brcmf_bus_unregister(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - sdio_unregister_driver(&brcmf_sdmmc_driver); -} diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h deleted file mode 100644 index 3ec74778b2e..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ /dev/null @@ -1,773 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/**************** - * Common types * - */ - -#ifndef _BRCMF_H_ -#define _BRCMF_H_ - -#define BRCMF_VERSION_STR "4.218.248.5" - -/******************************************************************************* - * IO codes that are interpreted by dongle firmware - ******************************************************************************/ -#define BRCMF_C_UP 2 -#define BRCMF_C_SET_PROMISC 10 -#define BRCMF_C_GET_RATE 12 -#define BRCMF_C_GET_INFRA 19 -#define BRCMF_C_SET_INFRA 20 -#define BRCMF_C_GET_AUTH 21 -#define BRCMF_C_SET_AUTH 22 -#define BRCMF_C_GET_BSSID 23 -#define BRCMF_C_GET_SSID 25 -#define BRCMF_C_SET_SSID 26 -#define BRCMF_C_GET_CHANNEL 29 -#define BRCMF_C_GET_SRL 31 -#define BRCMF_C_GET_LRL 33 -#define BRCMF_C_GET_RADIO 37 -#define BRCMF_C_SET_RADIO 38 -#define BRCMF_C_GET_PHYTYPE 39 -#define BRCMF_C_SET_KEY 45 -#define BRCMF_C_SET_PASSIVE_SCAN 49 -#define BRCMF_C_SCAN 50 -#define BRCMF_C_SCAN_RESULTS 51 -#define BRCMF_C_DISASSOC 52 -#define BRCMF_C_REASSOC 53 -#define BRCMF_C_SET_ROAM_TRIGGER 55 -#define BRCMF_C_SET_ROAM_DELTA 57 -#define BRCMF_C_GET_DTIMPRD 77 -#define BRCMF_C_SET_COUNTRY 84 -#define BRCMF_C_GET_PM 85 -#define BRCMF_C_SET_PM 86 -#define BRCMF_C_GET_AP 117 -#define BRCMF_C_SET_AP 118 -#define BRCMF_C_GET_RSSI 127 -#define BRCMF_C_GET_WSEC 133 -#define BRCMF_C_SET_WSEC 134 -#define BRCMF_C_GET_PHY_NOISE 135 -#define BRCMF_C_GET_BSS_INFO 136 -#define BRCMF_C_SET_SCAN_CHANNEL_TIME 185 -#define BRCMF_C_SET_SCAN_UNASSOC_TIME 187 -#define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON 201 -#define BRCMF_C_GET_VALID_CHANNELS 217 -#define BRCMF_C_GET_KEY_PRIMARY 235 -#define BRCMF_C_SET_KEY_PRIMARY 236 -#define BRCMF_C_SET_SCAN_PASSIVE_TIME 258 -#define BRCMF_C_GET_VAR 262 -#define BRCMF_C_SET_VAR 263 - -/* phy types (returned by WLC_GET_PHYTPE) */ -#define WLC_PHY_TYPE_A 0 -#define WLC_PHY_TYPE_B 1 -#define WLC_PHY_TYPE_G 2 -#define WLC_PHY_TYPE_N 4 -#define WLC_PHY_TYPE_LP 5 -#define WLC_PHY_TYPE_SSN 6 -#define WLC_PHY_TYPE_HT 7 -#define WLC_PHY_TYPE_LCN 8 -#define WLC_PHY_TYPE_NULL 0xf - -#define BRCMF_EVENTING_MASK_LEN 16 - -#define TOE_TX_CSUM_OL 0x00000001 -#define TOE_RX_CSUM_OL 0x00000002 - -#define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */ - -/* size of brcmf_scan_params not including variable length array */ -#define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 - -/* masks for channel and ssid count */ -#define BRCMF_SCAN_PARAMS_COUNT_MASK 0x0000ffff -#define BRCMF_SCAN_PARAMS_NSSID_SHIFT 16 - -#define BRCMF_SCAN_ACTION_START 1 -#define BRCMF_SCAN_ACTION_CONTINUE 2 -#define WL_SCAN_ACTION_ABORT 3 - -#define BRCMF_ISCAN_REQ_VERSION 1 - -/* brcmf_iscan_results status values */ -#define BRCMF_SCAN_RESULTS_SUCCESS 0 -#define BRCMF_SCAN_RESULTS_PARTIAL 1 -#define BRCMF_SCAN_RESULTS_PENDING 2 -#define BRCMF_SCAN_RESULTS_ABORTED 3 -#define BRCMF_SCAN_RESULTS_NO_MEM 4 - -/* Indicates this key is using soft encrypt */ -#define WL_SOFT_KEY (1 << 0) -/* primary (ie tx) key */ -#define BRCMF_PRIMARY_KEY (1 << 1) -/* Reserved for backward compat */ -#define WL_KF_RES_4 (1 << 4) -/* Reserved for backward compat */ -#define WL_KF_RES_5 (1 << 5) -/* Indicates a group key for a IBSS PEER */ -#define WL_IBSS_PEER_GROUP_KEY (1 << 6) - -/* For supporting multiple interfaces */ -#define BRCMF_MAX_IFS 16 -#define BRCMF_DEL_IF -0xe -#define BRCMF_BAD_IF -0xf - -#define DOT11_BSSTYPE_ANY 2 -#define DOT11_MAX_DEFAULT_KEYS 4 - -#define BRCMF_EVENT_MSG_LINK 0x01 -#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02 -#define BRCMF_EVENT_MSG_GROUP 0x04 - -struct brcmf_event_msg { - __be16 version; - __be16 flags; - __be32 event_type; - __be32 status; - __be32 reason; - __be32 auth_type; - __be32 datalen; - u8 addr[ETH_ALEN]; - char ifname[IFNAMSIZ]; -} __packed; - -struct brcm_ethhdr { - u16 subtype; - u16 length; - u8 version; - u8 oui[3]; - u16 usr_subtype; -} __packed; - -struct brcmf_event { - struct ethhdr eth; - struct brcm_ethhdr hdr; - struct brcmf_event_msg msg; -} __packed; - -struct dngl_stats { - unsigned long rx_packets; /* total packets received */ - unsigned long tx_packets; /* total packets transmitted */ - unsigned long rx_bytes; /* total bytes received */ - unsigned long tx_bytes; /* total bytes transmitted */ - unsigned long rx_errors; /* bad packets received */ - unsigned long tx_errors; /* packet transmit problems */ - unsigned long rx_dropped; /* packets dropped by dongle */ - unsigned long tx_dropped; /* packets dropped by dongle */ - unsigned long multicast; /* multicast packets received */ -}; - -/* event codes sent by the dongle to this driver */ -#define BRCMF_E_SET_SSID 0 -#define BRCMF_E_JOIN 1 -#define BRCMF_E_START 2 -#define BRCMF_E_AUTH 3 -#define BRCMF_E_AUTH_IND 4 -#define BRCMF_E_DEAUTH 5 -#define BRCMF_E_DEAUTH_IND 6 -#define BRCMF_E_ASSOC 7 -#define BRCMF_E_ASSOC_IND 8 -#define BRCMF_E_REASSOC 9 -#define BRCMF_E_REASSOC_IND 10 -#define BRCMF_E_DISASSOC 11 -#define BRCMF_E_DISASSOC_IND 12 -#define BRCMF_E_QUIET_START 13 -#define BRCMF_E_QUIET_END 14 -#define BRCMF_E_BEACON_RX 15 -#define BRCMF_E_LINK 16 -#define BRCMF_E_MIC_ERROR 17 -#define BRCMF_E_NDIS_LINK 18 -#define BRCMF_E_ROAM 19 -#define BRCMF_E_TXFAIL 20 -#define BRCMF_E_PMKID_CACHE 21 -#define BRCMF_E_RETROGRADE_TSF 22 -#define BRCMF_E_PRUNE 23 -#define BRCMF_E_AUTOAUTH 24 -#define BRCMF_E_EAPOL_MSG 25 -#define BRCMF_E_SCAN_COMPLETE 26 -#define BRCMF_E_ADDTS_IND 27 -#define BRCMF_E_DELTS_IND 28 -#define BRCMF_E_BCNSENT_IND 29 -#define BRCMF_E_BCNRX_MSG 30 -#define BRCMF_E_BCNLOST_MSG 31 -#define BRCMF_E_ROAM_PREP 32 -#define BRCMF_E_PFN_NET_FOUND 33 -#define BRCMF_E_PFN_NET_LOST 34 -#define BRCMF_E_RESET_COMPLETE 35 -#define BRCMF_E_JOIN_START 36 -#define BRCMF_E_ROAM_START 37 -#define BRCMF_E_ASSOC_START 38 -#define BRCMF_E_IBSS_ASSOC 39 -#define BRCMF_E_RADIO 40 -#define BRCMF_E_PSM_WATCHDOG 41 -#define BRCMF_E_PROBREQ_MSG 44 -#define BRCMF_E_SCAN_CONFIRM_IND 45 -#define BRCMF_E_PSK_SUP 46 -#define BRCMF_E_COUNTRY_CODE_CHANGED 47 -#define BRCMF_E_EXCEEDED_MEDIUM_TIME 48 -#define BRCMF_E_ICV_ERROR 49 -#define BRCMF_E_UNICAST_DECODE_ERROR 50 -#define BRCMF_E_MULTICAST_DECODE_ERROR 51 -#define BRCMF_E_TRACE 52 -#define BRCMF_E_IF 54 -#define BRCMF_E_RSSI 56 -#define BRCMF_E_PFN_SCAN_COMPLETE 57 -#define BRCMF_E_EXTLOG_MSG 58 -#define BRCMF_E_ACTION_FRAME 59 -#define BRCMF_E_ACTION_FRAME_COMPLETE 60 -#define BRCMF_E_PRE_ASSOC_IND 61 -#define BRCMF_E_PRE_REASSOC_IND 62 -#define BRCMF_E_CHANNEL_ADOPTED 63 -#define BRCMF_E_AP_STARTED 64 -#define BRCMF_E_DFS_AP_STOP 65 -#define BRCMF_E_DFS_AP_RESUME 66 -#define BRCMF_E_RESERVED1 67 -#define BRCMF_E_RESERVED2 68 -#define BRCMF_E_ESCAN_RESULT 69 -#define BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE 70 -#define BRCMF_E_DCS_REQUEST 73 - -#define BRCMF_E_FIFO_CREDIT_MAP 74 - -#define BRCMF_E_LAST 75 - -#define BRCMF_E_STATUS_SUCCESS 0 -#define BRCMF_E_STATUS_FAIL 1 -#define BRCMF_E_STATUS_TIMEOUT 2 -#define BRCMF_E_STATUS_NO_NETWORKS 3 -#define BRCMF_E_STATUS_ABORT 4 -#define BRCMF_E_STATUS_NO_ACK 5 -#define BRCMF_E_STATUS_UNSOLICITED 6 -#define BRCMF_E_STATUS_ATTEMPT 7 -#define BRCMF_E_STATUS_PARTIAL 8 -#define BRCMF_E_STATUS_NEWSCAN 9 -#define BRCMF_E_STATUS_NEWASSOC 10 -#define BRCMF_E_STATUS_11HQUIET 11 -#define BRCMF_E_STATUS_SUPPRESS 12 -#define BRCMF_E_STATUS_NOCHANS 13 -#define BRCMF_E_STATUS_CS_ABORT 15 -#define BRCMF_E_STATUS_ERROR 16 - -#define BRCMF_E_REASON_INITIAL_ASSOC 0 -#define BRCMF_E_REASON_LOW_RSSI 1 -#define BRCMF_E_REASON_DEAUTH 2 -#define BRCMF_E_REASON_DISASSOC 3 -#define BRCMF_E_REASON_BCNS_LOST 4 -#define BRCMF_E_REASON_MINTXRATE 9 -#define BRCMF_E_REASON_TXFAIL 10 - -#define BRCMF_E_REASON_FAST_ROAM_FAILED 5 -#define BRCMF_E_REASON_DIRECTED_ROAM 6 -#define BRCMF_E_REASON_TSPEC_REJECTED 7 -#define BRCMF_E_REASON_BETTER_AP 8 - -#define BRCMF_E_PRUNE_ENCR_MISMATCH 1 -#define BRCMF_E_PRUNE_BCAST_BSSID 2 -#define BRCMF_E_PRUNE_MAC_DENY 3 -#define BRCMF_E_PRUNE_MAC_NA 4 -#define BRCMF_E_PRUNE_REG_PASSV 5 -#define BRCMF_E_PRUNE_SPCT_MGMT 6 -#define BRCMF_E_PRUNE_RADAR 7 -#define BRCMF_E_RSN_MISMATCH 8 -#define BRCMF_E_PRUNE_NO_COMMON_RATES 9 -#define BRCMF_E_PRUNE_BASIC_RATES 10 -#define BRCMF_E_PRUNE_CIPHER_NA 12 -#define BRCMF_E_PRUNE_KNOWN_STA 13 -#define BRCMF_E_PRUNE_WDS_PEER 15 -#define BRCMF_E_PRUNE_QBSS_LOAD 16 -#define BRCMF_E_PRUNE_HOME_AP 17 - -#define BRCMF_E_SUP_OTHER 0 -#define BRCMF_E_SUP_DECRYPT_KEY_DATA 1 -#define BRCMF_E_SUP_BAD_UCAST_WEP128 2 -#define BRCMF_E_SUP_BAD_UCAST_WEP40 3 -#define BRCMF_E_SUP_UNSUP_KEY_LEN 4 -#define BRCMF_E_SUP_PW_KEY_CIPHER 5 -#define BRCMF_E_SUP_MSG3_TOO_MANY_IE 6 -#define BRCMF_E_SUP_MSG3_IE_MISMATCH 7 -#define BRCMF_E_SUP_NO_INSTALL_FLAG 8 -#define BRCMF_E_SUP_MSG3_NO_GTK 9 -#define BRCMF_E_SUP_GRP_KEY_CIPHER 10 -#define BRCMF_E_SUP_GRP_MSG1_NO_GTK 11 -#define BRCMF_E_SUP_GTK_DECRYPT_FAIL 12 -#define BRCMF_E_SUP_SEND_FAIL 13 -#define BRCMF_E_SUP_DEAUTH 14 - -#define BRCMF_E_IF_ADD 1 -#define BRCMF_E_IF_DEL 2 -#define BRCMF_E_IF_CHANGE 3 - -#define BRCMF_E_IF_ROLE_STA 0 -#define BRCMF_E_IF_ROLE_AP 1 -#define BRCMF_E_IF_ROLE_WDS 2 - -#define BRCMF_E_LINK_BCN_LOSS 1 -#define BRCMF_E_LINK_DISASSOC 2 -#define BRCMF_E_LINK_ASSOC_REC 3 -#define BRCMF_E_LINK_BSSCFG_DIS 4 - -/* The level of bus communication with the dongle */ -enum brcmf_bus_state { - BRCMF_BUS_DOWN, /* Not ready for frame transfers */ - BRCMF_BUS_LOAD, /* Download access only (CPU reset) */ - BRCMF_BUS_DATA /* Ready for frame transfers */ -}; - -/* Pattern matching filter. Specifies an offset within received packets to - * start matching, the pattern to match, the size of the pattern, and a bitmask - * that indicates which bits within the pattern should be matched. - */ -struct brcmf_pkt_filter_pattern { - /* - * Offset within received packet to start pattern matching. - * Offset '0' is the first byte of the ethernet header. - */ - u32 offset; - /* Size of the pattern. Bitmask must be the same size.*/ - u32 size_bytes; - /* - * Variable length mask and pattern data. mask starts at offset 0. - * Pattern immediately follows mask. - */ - u8 mask_and_pattern[1]; -}; - -/* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */ -struct brcmf_pkt_filter { - u32 id; /* Unique filter id, specified by app. */ - u32 type; /* Filter type (WL_PKT_FILTER_TYPE_xxx). */ - u32 negate_match; /* Negate the result of filter matches */ - union { /* Filter definitions */ - struct brcmf_pkt_filter_pattern pattern; /* Filter pattern */ - } u; -}; - -/* IOVAR "pkt_filter_enable" parameter. */ -struct brcmf_pkt_filter_enable { - u32 id; /* Unique filter id */ - u32 enable; /* Enable/disable bool */ -}; - -/* BSS info structure - * Applications MUST CHECK ie_offset field and length field to access IEs and - * next bss_info structure in a vector (in struct brcmf_scan_results) - */ -struct brcmf_bss_info { - __le32 version; /* version field */ - __le32 length; /* byte length of data in this record, - * starting at version and including IEs - */ - u8 BSSID[ETH_ALEN]; - __le16 beacon_period; /* units are Kusec */ - __le16 capability; /* Capability information */ - u8 SSID_len; - u8 SSID[32]; - struct { - __le32 count; /* # rates in this set */ - u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */ - } rateset; /* supported rates */ - __le16 chanspec; /* chanspec for bss */ - __le16 atim_window; /* units are Kusec */ - u8 dtim_period; /* DTIM period */ - __le16 RSSI; /* receive signal strength (in dBm) */ - s8 phy_noise; /* noise (in dBm) */ - - u8 n_cap; /* BSS is 802.11N Capable */ - /* 802.11N BSS Capabilities (based on HT_CAP_*): */ - __le32 nbss_cap; - u8 ctl_ch; /* 802.11N BSS control channel number */ - __le32 reserved32[1]; /* Reserved for expansion of BSS properties */ - u8 flags; /* flags */ - u8 reserved[3]; /* Reserved for expansion of BSS properties */ - u8 basic_mcs[MCSSET_LEN]; /* 802.11N BSS required MCS set */ - - __le16 ie_offset; /* offset at which IEs start, from beginning */ - __le32 ie_length; /* byte length of Information Elements */ - __le16 SNR; /* average SNR of during frame reception */ - /* Add new fields here */ - /* variable length Information Elements */ -}; - -struct brcm_rateset_le { - /* # rates in this set */ - __le32 count; - /* rates in 500kbps units w/hi bit set if basic */ - u8 rates[WL_NUMRATES]; -}; - -struct brcmf_ssid { - u32 SSID_len; - unsigned char SSID[32]; -}; - -struct brcmf_ssid_le { - __le32 SSID_len; - unsigned char SSID[32]; -}; - -struct brcmf_scan_params_le { - struct brcmf_ssid_le ssid_le; /* default: {0, ""} */ - u8 bssid[ETH_ALEN]; /* default: bcast */ - s8 bss_type; /* default: any, - * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT - */ - u8 scan_type; /* flags, 0 use default */ - __le32 nprobes; /* -1 use default, number of probes per channel */ - __le32 active_time; /* -1 use default, dwell time per channel for - * active scanning - */ - __le32 passive_time; /* -1 use default, dwell time per channel - * for passive scanning - */ - __le32 home_time; /* -1 use default, dwell time for the - * home channel between channel scans - */ - __le32 channel_num; /* count of channels and ssids that follow - * - * low half is count of channels in - * channel_list, 0 means default (use all - * available channels) - * - * high half is entries in struct brcmf_ssid - * array that follows channel_list, aligned for - * s32 (4 bytes) meaning an odd channel count - * implies a 2-byte pad between end of - * channel_list and first ssid - * - * if ssid count is zero, single ssid in the - * fixed parameter portion is assumed, otherwise - * ssid in the fixed portion is ignored - */ - __le16 channel_list[1]; /* list of chanspecs */ -}; - -/* incremental scan struct */ -struct brcmf_iscan_params_le { - __le32 version; - __le16 action; - __le16 scan_duration; - struct brcmf_scan_params_le params_le; -}; - -struct brcmf_scan_results { - u32 buflen; - u32 version; - u32 count; - struct brcmf_bss_info bss_info[1]; -}; - -struct brcmf_scan_results_le { - __le32 buflen; - __le32 version; - __le32 count; - struct brcmf_bss_info bss_info[1]; -}; - -/* used for association with a specific BSSID and chanspec list */ -struct brcmf_assoc_params_le { - /* 00:00:00:00:00:00: broadcast scan */ - u8 bssid[ETH_ALEN]; - /* 0: all available channels, otherwise count of chanspecs in - * chanspec_list */ - __le32 chanspec_num; - /* list of chanspecs */ - __le16 chanspec_list[1]; -}; - -/* used for join with or without a specific bssid and channel list */ -struct brcmf_join_params { - struct brcmf_ssid_le ssid_le; - struct brcmf_assoc_params_le params_le; -}; - -/* size of brcmf_scan_results not including variable length array */ -#define BRCMF_SCAN_RESULTS_FIXED_SIZE \ - (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info)) - -/* incremental scan results struct */ -struct brcmf_iscan_results { - union { - u32 status; - __le32 status_le; - }; - union { - struct brcmf_scan_results results; - struct brcmf_scan_results_le results_le; - }; -}; - -/* size of brcmf_iscan_results not including variable length array */ -#define BRCMF_ISCAN_RESULTS_FIXED_SIZE \ - (BRCMF_SCAN_RESULTS_FIXED_SIZE + \ - offsetof(struct brcmf_iscan_results, results)) - -struct brcmf_wsec_key { - u32 index; /* key index */ - u32 len; /* key length */ - u8 data[WLAN_MAX_KEY_LEN]; /* key data */ - u32 pad_1[18]; - u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ - u32 flags; /* misc flags */ - u32 pad_2[3]; - u32 iv_initialized; /* has IV been initialized already? */ - u32 pad_3; - /* Rx IV */ - struct { - u32 hi; /* upper 32 bits of IV */ - u16 lo; /* lower 16 bits of IV */ - } rxiv; - u32 pad_4[2]; - u8 ea[ETH_ALEN]; /* per station */ -}; - -/* - * dongle requires same struct as above but with fields in little endian order - */ -struct brcmf_wsec_key_le { - __le32 index; /* key index */ - __le32 len; /* key length */ - u8 data[WLAN_MAX_KEY_LEN]; /* key data */ - __le32 pad_1[18]; - __le32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ - __le32 flags; /* misc flags */ - __le32 pad_2[3]; - __le32 iv_initialized; /* has IV been initialized already? */ - __le32 pad_3; - /* Rx IV */ - struct { - __le32 hi; /* upper 32 bits of IV */ - __le16 lo; /* lower 16 bits of IV */ - } rxiv; - __le32 pad_4[2]; - u8 ea[ETH_ALEN]; /* per station */ -}; - -/* Used to get specific STA parameters */ -struct brcmf_scb_val_le { - __le32 val; - u8 ea[ETH_ALEN]; -}; - -/* channel encoding */ -struct brcmf_channel_info_le { - __le32 hw_channel; - __le32 target_channel; - __le32 scan_channel; -}; - -/* Bus independent dongle command */ -struct brcmf_dcmd { - uint cmd; /* common dongle cmd definition */ - void *buf; /* pointer to user buffer */ - uint len; /* length of user buffer */ - u8 set; /* get or set request (optional) */ - uint used; /* bytes read or written (optional) */ - uint needed; /* bytes needed (optional) */ -}; - -/* Forward decls for struct brcmf_pub (see below) */ -struct brcmf_bus; /* device bus info */ -struct brcmf_proto; /* device communication protocol info */ -struct brcmf_info; /* device driver info */ -struct brcmf_cfg80211_dev; /* cfg80211 device info */ - -/* Common structure for module and instance linkage */ -struct brcmf_pub { - /* Linkage ponters */ - struct brcmf_bus *bus; - struct brcmf_proto *prot; - struct brcmf_info *info; - struct brcmf_cfg80211_dev *config; - - /* Internal brcmf items */ - bool up; /* Driver up/down (to OS) */ - bool txoff; /* Transmit flow-controlled */ - enum brcmf_bus_state busstate; - uint hdrlen; /* Total BRCMF header length (proto + bus) */ - uint maxctl; /* Max size rxctl request from proto to bus */ - uint rxsz; /* Rx buffer size bus module should use */ - u8 wme_dp; /* wme discard priority */ - - /* Dongle media info */ - bool iswl; /* Dongle-resident driver is wl */ - unsigned long drv_version; /* Version of dongle-resident driver */ - u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */ - struct dngl_stats dstats; /* Stats for dongle-based data */ - - /* Additional stats for the bus level */ - - /* Data packets sent to dongle */ - unsigned long tx_packets; - /* Multicast data packets sent to dongle */ - unsigned long tx_multicast; - /* Errors in sending data to dongle */ - unsigned long tx_errors; - /* Control packets sent to dongle */ - unsigned long tx_ctlpkts; - /* Errors sending control frames to dongle */ - unsigned long tx_ctlerrs; - /* Packets sent up the network interface */ - unsigned long rx_packets; - /* Multicast packets sent up the network interface */ - unsigned long rx_multicast; - /* Errors processing rx data packets */ - unsigned long rx_errors; - /* Control frames processed from dongle */ - unsigned long rx_ctlpkts; - - /* Errors in processing rx control frames */ - unsigned long rx_ctlerrs; - /* Packets dropped locally (no memory) */ - unsigned long rx_dropped; - /* Packets flushed due to unscheduled sendup thread */ - unsigned long rx_flushed; - /* Number of times dpc scheduled by watchdog timer */ - unsigned long wd_dpc_sched; - - /* Number of packets where header read-ahead was used. */ - unsigned long rx_readahead_cnt; - /* Number of tx packets we had to realloc for headroom */ - unsigned long tx_realloc; - /* Number of flow control pkts recvd */ - unsigned long fc_packets; - - /* Last error return */ - int bcmerror; - uint tickcnt; - - /* Last error from dongle */ - int dongle_error; - - /* Suspend disable flag flag */ - int suspend_disable_flag; /* "1" to disable all extra powersaving - during suspend */ - int in_suspend; /* flag set to 1 when early suspend called */ - int dtim_skip; /* dtim skip , default 0 means wake each dtim */ - - /* Pkt filter defination */ - char *pktfilter[100]; - int pktfilter_count; - - u8 country_code[BRCM_CNTRY_BUF_SZ]; - char eventmask[BRCMF_EVENTING_MASK_LEN]; - -}; - -struct brcmf_if_event { - u8 ifidx; - u8 action; - u8 flags; - u8 bssidx; -}; - -struct bcmevent_name { - uint event; - const char *name; -}; - -extern const struct bcmevent_name bcmevent_names[]; - -/* Indication from bus module regarding presence/insertion of dongle. - * Return struct brcmf_pub pointer, used as handle to OS module in later calls. - * Returned structure should have bus and prot pointers filled in. - * bus_hdrlen specifies required headroom for bus module header. - */ -extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, - uint bus_hdrlen); -extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); -extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); - -extern s32 brcmf_exec_dcmd(struct net_device *dev, u32 cmd, void *arg, u32 len); - -/* Indication from bus module regarding removal/absence of dongle */ -extern void brcmf_detach(struct brcmf_pub *drvr); - -/* Indication from bus module to change flow-control state */ -extern void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool on); - -extern bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, - struct sk_buff *pkt, int prec); - -/* Receive frame for delivery to OS. Callee disposes of rxp. */ -extern void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, - struct sk_buff *rxp, int numpkt); - -/* Return pointer to interface name */ -extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx); - -/* Notify tx completion */ -extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, - bool success); - -/* Query dongle */ -extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, - uint cmd, void *buf, uint len); - -/* OS independent layer functions */ -extern int brcmf_os_proto_block(struct brcmf_pub *drvr); -extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr); -#ifdef BCMDBG -extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size); -#endif /* BCMDBG */ - -extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name); -extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, - void *pktdata, struct brcmf_event_msg *, - void **data_ptr); - -extern void brcmf_c_init(void); - -extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, - struct net_device *ndev, char *name, u8 *mac_addr, - u32 flags, u8 bssidx); -extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); - -/* Send packet to dongle via data channel */ -extern int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx,\ - struct sk_buff *pkt); - -extern int brcmf_bus_start(struct brcmf_pub *drvr); - -extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg); -extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, - int enable, int master_mode); - -#define BRCMF_DCMD_SMLEN 256 /* "small" cmd buffer required */ -#define BRCMF_DCMD_MEDLEN 1536 /* "med" cmd buffer required */ -#define BRCMF_DCMD_MAXLEN 8192 /* max length cmd buffer required */ - -/* message levels */ -#define BRCMF_ERROR_VAL 0x0001 -#define BRCMF_TRACE_VAL 0x0002 -#define BRCMF_INFO_VAL 0x0004 -#define BRCMF_DATA_VAL 0x0008 -#define BRCMF_CTL_VAL 0x0010 -#define BRCMF_TIMER_VAL 0x0020 -#define BRCMF_HDRS_VAL 0x0040 -#define BRCMF_BYTES_VAL 0x0080 -#define BRCMF_INTR_VAL 0x0100 -#define BRCMF_GLOM_VAL 0x0400 -#define BRCMF_EVENT_VAL 0x0800 -#define BRCMF_BTA_VAL 0x1000 -#define BRCMF_ISCAN_VAL 0x2000 - -/* Enter idle immediately (no timeout) */ -#define BRCMF_IDLE_IMMEDIATE (-1) -#define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change - when idle */ -#define BRCMF_IDLE_INTERVAL 1 - -#endif /* _BRCMF_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h deleted file mode 100644 index a249407c9a1..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCMF_BUS_H_ -#define _BRCMF_BUS_H_ - -/* Packet alignment for most efficient SDIO (can change based on platform) */ -#define BRCMF_SDALIGN (1 << 6) - -/* watchdog polling interval in ms */ -#define BRCMF_WD_POLL_MS 10 - -/* - * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) - */ - -/* Indicate (dis)interest in finding dongles. */ -extern int brcmf_bus_register(void); -extern void brcmf_bus_unregister(void); - -/* obtain linux device object providing bus function */ -extern struct device *brcmf_bus_get_device(struct brcmf_bus *bus); - -/* Stop bus module: clear pending frames, disable data flow */ -extern void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus); - -/* Initialize bus module: prepare for communication w/dongle */ -extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr); - -/* Send a data frame to the dongle. Callee disposes of txp. */ -extern int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *txp); - -/* Send/receive a control message to/from the dongle. - * Expects caller to enforce a single outstanding transaction. - */ -extern int -brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); - -extern int -brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); - -extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); - -#endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c deleted file mode 100644 index e34c5c3d1d5..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/******************************************************************************* - * Communicates with the dongle by using dcmd codes. - * For certain dcmd codes, the dongle interprets string data from the host. - ******************************************************************************/ - -#include -#include -#include -#include - -#include -#include - -#include "dhd.h" -#include "dhd_proto.h" -#include "dhd_bus.h" -#include "dhd_dbg.h" - -struct brcmf_proto_cdc_dcmd { - __le32 cmd; /* dongle command value */ - __le32 len; /* lower 16: output buflen; - * upper 16: input buflen (excludes header) */ - __le32 flags; /* flag defns given below */ - __le32 status; /* status code returned from the device */ -}; - -/* Max valid buffer size that can be sent to the dongle */ -#define CDC_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN) - -/* CDC flag definitions */ -#define CDC_DCMD_ERROR 0x01 /* 1=cmd failed */ -#define CDC_DCMD_SET 0x02 /* 0=get, 1=set cmd */ -#define CDC_DCMD_IF_MASK 0xF000 /* I/F index */ -#define CDC_DCMD_IF_SHIFT 12 -#define CDC_DCMD_ID_MASK 0xFFFF0000 /* id an cmd pairing */ -#define CDC_DCMD_ID_SHIFT 16 /* ID Mask shift bits */ -#define CDC_DCMD_ID(flags) \ - (((flags) & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT) - -/* - * BDC header - Broadcom specific extension of CDC. - * Used on data packets to convey priority across USB. - */ -#define BDC_HEADER_LEN 4 -#define BDC_PROTO_VER 1 /* Protocol version */ -#define BDC_FLAG_VER_MASK 0xf0 /* Protocol version mask */ -#define BDC_FLAG_VER_SHIFT 4 /* Protocol version shift */ -#define BDC_FLAG_SUM_GOOD 0x04 /* Good RX checksums */ -#define BDC_FLAG_SUM_NEEDED 0x08 /* Dongle needs to do TX checksums */ -#define BDC_PRIORITY_MASK 0x7 -#define BDC_FLAG2_IF_MASK 0x0f /* packet rx interface in APSTA */ -#define BDC_FLAG2_IF_SHIFT 0 - -#define BDC_GET_IF_IDX(hdr) \ - ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT)) -#define BDC_SET_IF_IDX(hdr, idx) \ - ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | \ - ((idx) << BDC_FLAG2_IF_SHIFT))) - -struct brcmf_proto_bdc_header { - u8 flags; - u8 priority; /* 802.1d Priority, 4:7 flow control info for usb */ - u8 flags2; - u8 rssi; -}; - - -#define RETRIES 2 /* # of retries to retrieve matching dcmd response */ -#define BUS_HEADER_LEN (16+BRCMF_SDALIGN) /* Must be atleast SDPCM_RESERVE - * (amount of header tha might be added) - * plus any space that might be needed - * for alignment padding. - */ -#define ROUND_UP_MARGIN 2048 /* Biggest SDIO block size possible for - * round off at the end of buffer - */ - -struct brcmf_proto { - u16 reqid; - u8 pending; - u32 lastcmd; - u8 bus_header[BUS_HEADER_LEN]; - struct brcmf_proto_cdc_dcmd msg; - unsigned char buf[BRCMF_DCMD_MAXLEN + ROUND_UP_MARGIN]; -}; - -static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr) -{ - struct brcmf_proto *prot = drvr->prot; - int len = le32_to_cpu(prot->msg.len) + - sizeof(struct brcmf_proto_cdc_dcmd); - - brcmf_dbg(TRACE, "Enter\n"); - - /* NOTE : cdc->msg.len holds the desired length of the buffer to be - * returned. Only up to CDC_MAX_MSG_SIZE of this buffer area - * is actually sent to the dongle - */ - if (len > CDC_MAX_MSG_SIZE) - len = CDC_MAX_MSG_SIZE; - - /* Send request */ - return brcmf_sdbrcm_bus_txctl(drvr->bus, (unsigned char *)&prot->msg, - len); -} - -static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len) -{ - int ret; - struct brcmf_proto *prot = drvr->prot; - - brcmf_dbg(TRACE, "Enter\n"); - - do { - ret = brcmf_sdbrcm_bus_rxctl(drvr->bus, - (unsigned char *)&prot->msg, - len + sizeof(struct brcmf_proto_cdc_dcmd)); - if (ret < 0) - break; - } while (CDC_DCMD_ID(le32_to_cpu(prot->msg.flags)) != id); - - return ret; -} - -int -brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, - void *buf, uint len) -{ - struct brcmf_proto *prot = drvr->prot; - struct brcmf_proto_cdc_dcmd *msg = &prot->msg; - void *info; - int ret = 0, retries = 0; - u32 id, flags; - - brcmf_dbg(TRACE, "Enter\n"); - brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); - - /* Respond "bcmerror" and "bcmerrorstr" with local cache */ - if (cmd == BRCMF_C_GET_VAR && buf) { - if (!strcmp((char *)buf, "bcmerrorstr")) { - strncpy((char *)buf, "bcm_error", - BCME_STRLEN); - goto done; - } else if (!strcmp((char *)buf, "bcmerror")) { - *(int *)buf = drvr->dongle_error; - goto done; - } - } - - memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd)); - - msg->cmd = cpu_to_le32(cmd); - msg->len = cpu_to_le32(len); - flags = (++prot->reqid << CDC_DCMD_ID_SHIFT); - flags = (flags & ~CDC_DCMD_IF_MASK) | - (ifidx << CDC_DCMD_IF_SHIFT); - msg->flags = cpu_to_le32(flags); - - if (buf) - memcpy(prot->buf, buf, len); - - ret = brcmf_proto_cdc_msg(drvr); - if (ret < 0) { - brcmf_dbg(ERROR, "brcmf_proto_cdc_msg failed w/status %d\n", - ret); - goto done; - } - -retry: - /* wait for interrupt and get first fragment */ - ret = brcmf_proto_cdc_cmplt(drvr, prot->reqid, len); - if (ret < 0) - goto done; - - flags = le32_to_cpu(msg->flags); - id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT; - - if ((id < prot->reqid) && (++retries < RETRIES)) - goto retry; - if (id != prot->reqid) { - brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n", - brcmf_ifname(drvr, ifidx), id, prot->reqid); - ret = -EINVAL; - goto done; - } - - /* Check info buffer */ - info = (void *)&msg[1]; - - /* Copy info buffer */ - if (buf) { - if (ret < (int)len) - len = ret; - memcpy(buf, info, len); - } - - /* Check the ERROR flag */ - if (flags & CDC_DCMD_ERROR) { - ret = le32_to_cpu(msg->status); - /* Cache error from dongle */ - drvr->dongle_error = ret; - } - -done: - return ret; -} - -int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, - void *buf, uint len) -{ - struct brcmf_proto *prot = drvr->prot; - struct brcmf_proto_cdc_dcmd *msg = &prot->msg; - int ret = 0; - u32 flags, id; - - brcmf_dbg(TRACE, "Enter\n"); - brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len); - - memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd)); - - msg->cmd = cpu_to_le32(cmd); - msg->len = cpu_to_le32(len); - flags = (++prot->reqid << CDC_DCMD_ID_SHIFT) | CDC_DCMD_SET; - flags = (flags & ~CDC_DCMD_IF_MASK) | - (ifidx << CDC_DCMD_IF_SHIFT); - msg->flags = cpu_to_le32(flags); - - if (buf) - memcpy(prot->buf, buf, len); - - ret = brcmf_proto_cdc_msg(drvr); - if (ret < 0) - goto done; - - ret = brcmf_proto_cdc_cmplt(drvr, prot->reqid, len); - if (ret < 0) - goto done; - - flags = le32_to_cpu(msg->flags); - id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT; - - if (id != prot->reqid) { - brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n", - brcmf_ifname(drvr, ifidx), id, prot->reqid); - ret = -EINVAL; - goto done; - } - - /* Check the ERROR flag */ - if (flags & CDC_DCMD_ERROR) { - ret = le32_to_cpu(msg->status); - /* Cache error from dongle */ - drvr->dongle_error = ret; - } - -done: - return ret; -} - -int -brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd, - int len) -{ - struct brcmf_proto *prot = drvr->prot; - int ret = -1; - - if (drvr->busstate == BRCMF_BUS_DOWN) { - brcmf_dbg(ERROR, "bus is down. we have nothing to do.\n"); - return ret; - } - brcmf_os_proto_block(drvr); - - brcmf_dbg(TRACE, "Enter\n"); - - if (len > BRCMF_DCMD_MAXLEN) - goto done; - - if (prot->pending == true) { - brcmf_dbg(TRACE, "CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n", - dcmd->cmd, (unsigned long)dcmd->cmd, prot->lastcmd, - (unsigned long)prot->lastcmd); - if (dcmd->cmd == BRCMF_C_SET_VAR || - dcmd->cmd == BRCMF_C_GET_VAR) - brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)dcmd->buf); - - goto done; - } - - prot->pending = true; - prot->lastcmd = dcmd->cmd; - if (dcmd->set) - ret = brcmf_proto_cdc_set_dcmd(drvr, ifidx, dcmd->cmd, - dcmd->buf, len); - else { - ret = brcmf_proto_cdc_query_dcmd(drvr, ifidx, dcmd->cmd, - dcmd->buf, len); - if (ret > 0) - dcmd->used = ret - - sizeof(struct brcmf_proto_cdc_dcmd); - } - - if (ret >= 0) - ret = 0; - else { - struct brcmf_proto_cdc_dcmd *msg = &prot->msg; - /* len == needed when set/query fails from dongle */ - dcmd->needed = le32_to_cpu(msg->len); - } - - /* Intercept the wme_dp dongle cmd here */ - if (!ret && dcmd->cmd == BRCMF_C_SET_VAR && - !strcmp(dcmd->buf, "wme_dp")) { - int slen; - __le32 val = 0; - - slen = strlen("wme_dp") + 1; - if (len >= (int)(slen + sizeof(int))) - memcpy(&val, (char *)dcmd->buf + slen, sizeof(int)); - drvr->wme_dp = (u8) le32_to_cpu(val); - } - - prot->pending = false; - -done: - brcmf_os_proto_unblock(drvr); - - return ret; -} - -static bool pkt_sum_needed(struct sk_buff *skb) -{ - return skb->ip_summed == CHECKSUM_PARTIAL; -} - -static void pkt_set_sum_good(struct sk_buff *skb, bool x) -{ - skb->ip_summed = (x ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE); -} - -void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx, - struct sk_buff *pktbuf) -{ - struct brcmf_proto_bdc_header *h; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Push BDC header used to convey priority for buses that don't */ - - skb_push(pktbuf, BDC_HEADER_LEN); - - h = (struct brcmf_proto_bdc_header *)(pktbuf->data); - - h->flags = (BDC_PROTO_VER << BDC_FLAG_VER_SHIFT); - if (pkt_sum_needed(pktbuf)) - h->flags |= BDC_FLAG_SUM_NEEDED; - - h->priority = (pktbuf->priority & BDC_PRIORITY_MASK); - h->flags2 = 0; - h->rssi = 0; - BDC_SET_IF_IDX(h, ifidx); -} - -int brcmf_proto_hdrpull(struct brcmf_pub *drvr, int *ifidx, - struct sk_buff *pktbuf) -{ - struct brcmf_proto_bdc_header *h; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Pop BDC header used to convey priority for buses that don't */ - - if (pktbuf->len < BDC_HEADER_LEN) { - brcmf_dbg(ERROR, "rx data too short (%d < %d)\n", - pktbuf->len, BDC_HEADER_LEN); - return -EBADE; - } - - h = (struct brcmf_proto_bdc_header *)(pktbuf->data); - - *ifidx = BDC_GET_IF_IDX(h); - if (*ifidx >= BRCMF_MAX_IFS) { - brcmf_dbg(ERROR, "rx data ifnum out of range (%d)\n", *ifidx); - return -EBADE; - } - - if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) != - BDC_PROTO_VER) { - brcmf_dbg(ERROR, "%s: non-BDC packet received, flags 0x%x\n", - brcmf_ifname(drvr, *ifidx), h->flags); - return -EBADE; - } - - if (h->flags & BDC_FLAG_SUM_GOOD) { - brcmf_dbg(INFO, "%s: BDC packet received with good rx-csum, flags 0x%x\n", - brcmf_ifname(drvr, *ifidx), h->flags); - pkt_set_sum_good(pktbuf, true); - } - - pktbuf->priority = h->priority & BDC_PRIORITY_MASK; - - skb_pull(pktbuf, BDC_HEADER_LEN); - - return 0; -} - -int brcmf_proto_attach(struct brcmf_pub *drvr) -{ - struct brcmf_proto *cdc; - - cdc = kzalloc(sizeof(struct brcmf_proto), GFP_ATOMIC); - if (!cdc) - goto fail; - - /* ensure that the msg buf directly follows the cdc msg struct */ - if ((unsigned long)(&cdc->msg + 1) != (unsigned long)cdc->buf) { - brcmf_dbg(ERROR, "struct brcmf_proto is not correctly defined\n"); - goto fail; - } - - drvr->prot = cdc; - drvr->hdrlen += BDC_HEADER_LEN; - drvr->maxctl = BRCMF_DCMD_MAXLEN + - sizeof(struct brcmf_proto_cdc_dcmd) + ROUND_UP_MARGIN; - return 0; - -fail: - kfree(cdc); - return -ENOMEM; -} - -/* ~NOTE~ What if another thread is waiting on the semaphore? Holding it? */ -void brcmf_proto_detach(struct brcmf_pub *drvr) -{ - kfree(drvr->prot); - drvr->prot = NULL; -} - -void brcmf_proto_dstats(struct brcmf_pub *drvr) -{ - /* No stats from dongle added yet, copy bus stats */ - drvr->dstats.tx_packets = drvr->tx_packets; - drvr->dstats.tx_errors = drvr->tx_errors; - drvr->dstats.rx_packets = drvr->rx_packets; - drvr->dstats.rx_errors = drvr->rx_errors; - drvr->dstats.rx_dropped = drvr->rx_dropped; - drvr->dstats.multicast = drvr->rx_multicast; - return; -} - -int brcmf_proto_init(struct brcmf_pub *drvr) -{ - int ret = 0; - char buf[128]; - - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_os_proto_block(drvr); - - /* Get the device MAC address */ - strcpy(buf, "cur_etheraddr"); - ret = brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, - buf, sizeof(buf)); - if (ret < 0) { - brcmf_os_proto_unblock(drvr); - return ret; - } - memcpy(drvr->mac, buf, ETH_ALEN); - - brcmf_os_proto_unblock(drvr); - - ret = brcmf_c_preinit_dcmds(drvr); - - /* Always assumes wl for now */ - drvr->iswl = true; - - return ret; -} - -void brcmf_proto_stop(struct brcmf_pub *drvr) -{ - /* Nothing to do for CDC */ -} diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c deleted file mode 100644 index 4075fd74dd9..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ /dev/null @@ -1,872 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "dhd.h" -#include "dhd_bus.h" -#include "dhd_proto.h" -#include "dhd_dbg.h" - -#define BRCM_OUI "\x00\x10\x18" -#define DOT11_OUI_LEN 3 -#define BCMILCP_BCM_SUBTYPE_EVENT 1 -#define PKTFILTER_BUF_SIZE 2048 -#define BRCMF_ARPOL_MODE 0xb /* agent|snoop|peer_autoreply */ - -int brcmf_msg_level; - -#define MSGTRACE_VERSION 1 - -#define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter, u) -#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \ - offsetof(struct brcmf_pkt_filter_pattern, mask_and_pattern) - -#ifdef BCMDBG -static const char brcmf_version[] = - "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " - __DATE__ " at " __TIME__; -#else -static const char brcmf_version[] = - "Dongle Host Driver, version " BRCMF_VERSION_STR; -#endif - -/* Message trace header */ -struct msgtrace_hdr { - u8 version; - u8 spare; - __be16 len; /* Len of the trace */ - __be32 seqnum; /* Sequence number of message. Useful - * if the messsage has been lost - * because of DMA error or a bus reset - * (ex: SDIO Func2) - */ - __be32 discarded_bytes; /* Number of discarded bytes because of - trace overflow */ - __be32 discarded_printf; /* Number of discarded printf - because of trace overflow */ -} __packed; - -void brcmf_c_init(void) -{ - /* Init global variables at run-time, not as part of the declaration. - * This is required to support init/de-init of the driver. - * Initialization - * of globals as part of the declaration results in non-deterministic - * behaviour since the value of the globals may be different on the - * first time that the driver is initialized vs subsequent - * initializations. - */ - brcmf_msg_level = BRCMF_ERROR_VAL; -} - -bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, - struct sk_buff *pkt, int prec) -{ - struct sk_buff *p; - int eprec = -1; /* precedence to evict from */ - bool discard_oldest; - - /* Fast case, precedence queue is not full and we are also not - * exceeding total queue length - */ - if (!pktq_pfull(q, prec) && !pktq_full(q)) { - brcmu_pktq_penq(q, prec, pkt); - return true; - } - - /* Determine precedence from which to evict packet, if any */ - if (pktq_pfull(q, prec)) - eprec = prec; - else if (pktq_full(q)) { - p = brcmu_pktq_peek_tail(q, &eprec); - if (eprec > prec) - return false; - } - - /* Evict if needed */ - if (eprec >= 0) { - /* Detect queueing to unconfigured precedence */ - discard_oldest = ac_bitmap_tst(drvr->wme_dp, eprec); - if (eprec == prec && !discard_oldest) - return false; /* refuse newer (incoming) packet */ - /* Evict packet according to discard policy */ - p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) : - brcmu_pktq_pdeq_tail(q, eprec); - if (p == NULL) - brcmf_dbg(ERROR, "brcmu_pktq_penq() failed, oldest %d\n", - discard_oldest); - - brcmu_pkt_buf_free_skb(p); - } - - /* Enqueue */ - p = brcmu_pktq_penq(q, prec, pkt); - if (p == NULL) - brcmf_dbg(ERROR, "brcmu_pktq_penq() failed\n"); - - return p != NULL; -} - -#ifdef BCMDBG -static void -brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) -{ - uint i, status, reason; - bool group = false, flush_txq = false, link = false; - char *auth_str, *event_name; - unsigned char *buf; - char err_msg[256], eabuf[ETHER_ADDR_STR_LEN]; - static struct { - uint event; - char *event_name; - } event_names[] = { - { - BRCMF_E_SET_SSID, "SET_SSID"}, { - BRCMF_E_JOIN, "JOIN"}, { - BRCMF_E_START, "START"}, { - BRCMF_E_AUTH, "AUTH"}, { - BRCMF_E_AUTH_IND, "AUTH_IND"}, { - BRCMF_E_DEAUTH, "DEAUTH"}, { - BRCMF_E_DEAUTH_IND, "DEAUTH_IND"}, { - BRCMF_E_ASSOC, "ASSOC"}, { - BRCMF_E_ASSOC_IND, "ASSOC_IND"}, { - BRCMF_E_REASSOC, "REASSOC"}, { - BRCMF_E_REASSOC_IND, "REASSOC_IND"}, { - BRCMF_E_DISASSOC, "DISASSOC"}, { - BRCMF_E_DISASSOC_IND, "DISASSOC_IND"}, { - BRCMF_E_QUIET_START, "START_QUIET"}, { - BRCMF_E_QUIET_END, "END_QUIET"}, { - BRCMF_E_BEACON_RX, "BEACON_RX"}, { - BRCMF_E_LINK, "LINK"}, { - BRCMF_E_MIC_ERROR, "MIC_ERROR"}, { - BRCMF_E_NDIS_LINK, "NDIS_LINK"}, { - BRCMF_E_ROAM, "ROAM"}, { - BRCMF_E_TXFAIL, "TXFAIL"}, { - BRCMF_E_PMKID_CACHE, "PMKID_CACHE"}, { - BRCMF_E_RETROGRADE_TSF, "RETROGRADE_TSF"}, { - BRCMF_E_PRUNE, "PRUNE"}, { - BRCMF_E_AUTOAUTH, "AUTOAUTH"}, { - BRCMF_E_EAPOL_MSG, "EAPOL_MSG"}, { - BRCMF_E_SCAN_COMPLETE, "SCAN_COMPLETE"}, { - BRCMF_E_ADDTS_IND, "ADDTS_IND"}, { - BRCMF_E_DELTS_IND, "DELTS_IND"}, { - BRCMF_E_BCNSENT_IND, "BCNSENT_IND"}, { - BRCMF_E_BCNRX_MSG, "BCNRX_MSG"}, { - BRCMF_E_BCNLOST_MSG, "BCNLOST_MSG"}, { - BRCMF_E_ROAM_PREP, "ROAM_PREP"}, { - BRCMF_E_PFN_NET_FOUND, "PNO_NET_FOUND"}, { - BRCMF_E_PFN_NET_LOST, "PNO_NET_LOST"}, { - BRCMF_E_RESET_COMPLETE, "RESET_COMPLETE"}, { - BRCMF_E_JOIN_START, "JOIN_START"}, { - BRCMF_E_ROAM_START, "ROAM_START"}, { - BRCMF_E_ASSOC_START, "ASSOC_START"}, { - BRCMF_E_IBSS_ASSOC, "IBSS_ASSOC"}, { - BRCMF_E_RADIO, "RADIO"}, { - BRCMF_E_PSM_WATCHDOG, "PSM_WATCHDOG"}, { - BRCMF_E_PROBREQ_MSG, "PROBREQ_MSG"}, { - BRCMF_E_SCAN_CONFIRM_IND, "SCAN_CONFIRM_IND"}, { - BRCMF_E_PSK_SUP, "PSK_SUP"}, { - BRCMF_E_COUNTRY_CODE_CHANGED, "COUNTRY_CODE_CHANGED"}, { - BRCMF_E_EXCEEDED_MEDIUM_TIME, "EXCEEDED_MEDIUM_TIME"}, { - BRCMF_E_ICV_ERROR, "ICV_ERROR"}, { - BRCMF_E_UNICAST_DECODE_ERROR, "UNICAST_DECODE_ERROR"}, { - BRCMF_E_MULTICAST_DECODE_ERROR, "MULTICAST_DECODE_ERROR"}, { - BRCMF_E_TRACE, "TRACE"}, { - BRCMF_E_ACTION_FRAME, "ACTION FRAME"}, { - BRCMF_E_ACTION_FRAME_COMPLETE, "ACTION FRAME TX COMPLETE"}, { - BRCMF_E_IF, "IF"}, { - BRCMF_E_RSSI, "RSSI"}, { - BRCMF_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"} - }; - uint event_type, flags, auth_type, datalen; - static u32 seqnum_prev; - struct msgtrace_hdr hdr; - u32 nblost; - char *s, *p; - - event_type = be32_to_cpu(event->event_type); - flags = be16_to_cpu(event->flags); - status = be32_to_cpu(event->status); - reason = be32_to_cpu(event->reason); - auth_type = be32_to_cpu(event->auth_type); - datalen = be32_to_cpu(event->datalen); - /* debug dump of event messages */ - sprintf(eabuf, "%pM", event->addr); - - event_name = "UNKNOWN"; - for (i = 0; i < ARRAY_SIZE(event_names); i++) { - if (event_names[i].event == event_type) - event_name = event_names[i].event_name; - } - - brcmf_dbg(EVENT, "EVENT: %s, event ID = %d\n", event_name, event_type); - brcmf_dbg(EVENT, "flags 0x%04x, status %d, reason %d, auth_type %d MAC %s\n", - flags, status, reason, auth_type, eabuf); - - if (flags & BRCMF_EVENT_MSG_LINK) - link = true; - if (flags & BRCMF_EVENT_MSG_GROUP) - group = true; - if (flags & BRCMF_EVENT_MSG_FLUSHTXQ) - flush_txq = true; - - switch (event_type) { - case BRCMF_E_START: - case BRCMF_E_DEAUTH: - case BRCMF_E_DISASSOC: - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); - break; - - case BRCMF_E_ASSOC_IND: - case BRCMF_E_REASSOC_IND: - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); - break; - - case BRCMF_E_ASSOC: - case BRCMF_E_REASSOC: - if (status == BRCMF_E_STATUS_SUCCESS) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, SUCCESS\n", - event_name, eabuf); - else if (status == BRCMF_E_STATUS_TIMEOUT) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, TIMEOUT\n", - event_name, eabuf); - else if (status == BRCMF_E_STATUS_FAIL) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, FAILURE, reason %d\n", - event_name, eabuf, (int)reason); - else - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, unexpected status %d\n", - event_name, eabuf, (int)status); - break; - - case BRCMF_E_DEAUTH_IND: - case BRCMF_E_DISASSOC_IND: - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, reason %d\n", - event_name, eabuf, (int)reason); - break; - - case BRCMF_E_AUTH: - case BRCMF_E_AUTH_IND: - if (auth_type == WLAN_AUTH_OPEN) - auth_str = "Open System"; - else if (auth_type == WLAN_AUTH_SHARED_KEY) - auth_str = "Shared Key"; - else { - sprintf(err_msg, "AUTH unknown: %d", (int)auth_type); - auth_str = err_msg; - } - if (event_type == BRCMF_E_AUTH_IND) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s\n", - event_name, eabuf, auth_str); - else if (status == BRCMF_E_STATUS_SUCCESS) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, SUCCESS\n", - event_name, eabuf, auth_str); - else if (status == BRCMF_E_STATUS_TIMEOUT) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, TIMEOUT\n", - event_name, eabuf, auth_str); - else if (status == BRCMF_E_STATUS_FAIL) { - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, FAILURE, reason %d\n", - event_name, eabuf, auth_str, (int)reason); - } - - break; - - case BRCMF_E_JOIN: - case BRCMF_E_ROAM: - case BRCMF_E_SET_SSID: - if (status == BRCMF_E_STATUS_SUCCESS) - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", - event_name, eabuf); - else if (status == BRCMF_E_STATUS_FAIL) - brcmf_dbg(EVENT, "MACEVENT: %s, failed\n", event_name); - else if (status == BRCMF_E_STATUS_NO_NETWORKS) - brcmf_dbg(EVENT, "MACEVENT: %s, no networks found\n", - event_name); - else - brcmf_dbg(EVENT, "MACEVENT: %s, unexpected status %d\n", - event_name, (int)status); - break; - - case BRCMF_E_BEACON_RX: - if (status == BRCMF_E_STATUS_SUCCESS) - brcmf_dbg(EVENT, "MACEVENT: %s, SUCCESS\n", event_name); - else if (status == BRCMF_E_STATUS_FAIL) - brcmf_dbg(EVENT, "MACEVENT: %s, FAIL\n", event_name); - else - brcmf_dbg(EVENT, "MACEVENT: %s, status %d\n", - event_name, status); - break; - - case BRCMF_E_LINK: - brcmf_dbg(EVENT, "MACEVENT: %s %s\n", - event_name, link ? "UP" : "DOWN"); - break; - - case BRCMF_E_MIC_ERROR: - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s, Group %d, Flush %d\n", - event_name, eabuf, group, flush_txq); - break; - - case BRCMF_E_ICV_ERROR: - case BRCMF_E_UNICAST_DECODE_ERROR: - case BRCMF_E_MULTICAST_DECODE_ERROR: - brcmf_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf); - break; - - case BRCMF_E_TXFAIL: - brcmf_dbg(EVENT, "MACEVENT: %s, RA %s\n", event_name, eabuf); - break; - - case BRCMF_E_SCAN_COMPLETE: - case BRCMF_E_PMKID_CACHE: - brcmf_dbg(EVENT, "MACEVENT: %s\n", event_name); - break; - - case BRCMF_E_PFN_NET_FOUND: - case BRCMF_E_PFN_NET_LOST: - case BRCMF_E_PFN_SCAN_COMPLETE: - brcmf_dbg(EVENT, "PNOEVENT: %s\n", event_name); - break; - - case BRCMF_E_PSK_SUP: - case BRCMF_E_PRUNE: - brcmf_dbg(EVENT, "MACEVENT: %s, status %d, reason %d\n", - event_name, (int)status, (int)reason); - break; - - case BRCMF_E_TRACE: - buf = (unsigned char *) event_data; - memcpy(&hdr, buf, sizeof(struct msgtrace_hdr)); - - if (hdr.version != MSGTRACE_VERSION) { - brcmf_dbg(ERROR, - "MACEVENT: %s [unsupported version --> brcmf" - " version:%d dongle version:%d]\n", - event_name, MSGTRACE_VERSION, hdr.version); - /* Reset datalen to avoid display below */ - datalen = 0; - break; - } - - /* There are 2 bytes available at the end of data */ - *(buf + sizeof(struct msgtrace_hdr) - + be16_to_cpu(hdr.len)) = '\0'; - - if (be32_to_cpu(hdr.discarded_bytes) - || be32_to_cpu(hdr.discarded_printf)) - brcmf_dbg(ERROR, - "WLC_E_TRACE: [Discarded traces in dongle -->" - " discarded_bytes %d discarded_printf %d]\n", - be32_to_cpu(hdr.discarded_bytes), - be32_to_cpu(hdr.discarded_printf)); - - nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; - if (nblost > 0) - brcmf_dbg(ERROR, "WLC_E_TRACE: [Event lost --> seqnum " - " %d nblost %d\n", be32_to_cpu(hdr.seqnum), - nblost); - seqnum_prev = be32_to_cpu(hdr.seqnum); - - /* Display the trace buffer. Advance from \n to \n to - * avoid display big - * printf (issue with Linux printk ) - */ - p = (char *)&buf[sizeof(struct msgtrace_hdr)]; - while ((s = strstr(p, "\n")) != NULL) { - *s = '\0'; - printk(KERN_DEBUG"%s\n", p); - p = s + 1; - } - printk(KERN_DEBUG "%s\n", p); - - /* Reset datalen to avoid display below */ - datalen = 0; - break; - - case BRCMF_E_RSSI: - brcmf_dbg(EVENT, "MACEVENT: %s %d\n", - event_name, be32_to_cpu(*((__be32 *)event_data))); - break; - - default: - brcmf_dbg(EVENT, - "MACEVENT: %s %d, MAC %s, status %d, reason %d, " - "auth %d\n", event_name, event_type, eabuf, - (int)status, (int)reason, (int)auth_type); - break; - } - - /* show any appended data */ - if (datalen) { - buf = (unsigned char *) event_data; - brcmf_dbg(EVENT, " data (%d) : ", datalen); - for (i = 0; i < datalen; i++) - brcmf_dbg(EVENT, " 0x%02x ", *buf++); - brcmf_dbg(EVENT, "\n"); - } -} -#endif /* BCMDBG */ - -int -brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, - struct brcmf_event_msg *event, void **data_ptr) -{ - /* check whether packet is a BRCM event pkt */ - struct brcmf_event *pvt_data = (struct brcmf_event *) pktdata; - struct brcmf_if_event *ifevent; - char *event_data; - u32 type, status; - u16 flags; - int evlen; - - if (memcmp(BRCM_OUI, &pvt_data->hdr.oui[0], DOT11_OUI_LEN)) { - brcmf_dbg(ERROR, "mismatched OUI, bailing\n"); - return -EBADE; - } - - /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */ - if (get_unaligned_be16(&pvt_data->hdr.usr_subtype) != - BCMILCP_BCM_SUBTYPE_EVENT) { - brcmf_dbg(ERROR, "mismatched subtype, bailing\n"); - return -EBADE; - } - - *data_ptr = &pvt_data[1]; - event_data = *data_ptr; - - /* memcpy since BRCM event pkt may be unaligned. */ - memcpy(event, &pvt_data->msg, sizeof(struct brcmf_event_msg)); - - type = get_unaligned_be32(&event->event_type); - flags = get_unaligned_be16(&event->flags); - status = get_unaligned_be32(&event->status); - evlen = get_unaligned_be32(&event->datalen) + - sizeof(struct brcmf_event); - - switch (type) { - case BRCMF_E_IF: - ifevent = (struct brcmf_if_event *) event_data; - brcmf_dbg(TRACE, "if event\n"); - - if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { - if (ifevent->action == BRCMF_E_IF_ADD) - brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, - event->ifname, - pvt_data->eth.h_dest, - ifevent->flags, ifevent->bssidx); - else - brcmf_del_if(drvr_priv, ifevent->ifidx); - } else { - brcmf_dbg(ERROR, "Invalid ifidx %d for %s\n", - ifevent->ifidx, event->ifname); - } - - /* send up the if event: btamp user needs it */ - *ifidx = brcmf_ifname2idx(drvr_priv, event->ifname); - break; - - /* These are what external supplicant/authenticator wants */ - case BRCMF_E_LINK: - case BRCMF_E_ASSOC_IND: - case BRCMF_E_REASSOC_IND: - case BRCMF_E_DISASSOC_IND: - case BRCMF_E_MIC_ERROR: - default: - /* Fall through: this should get _everything_ */ - - *ifidx = brcmf_ifname2idx(drvr_priv, event->ifname); - brcmf_dbg(TRACE, "MAC event %d, flags %x, status %x\n", - type, flags, status); - - /* put it back to BRCMF_E_NDIS_LINK */ - if (type == BRCMF_E_NDIS_LINK) { - u32 temp1; - __be32 temp2; - - temp1 = get_unaligned_be32(&event->event_type); - brcmf_dbg(TRACE, "Converted to WLC_E_LINK type %d\n", - temp1); - - temp2 = cpu_to_be32(BRCMF_E_NDIS_LINK); - memcpy((void *)(&pvt_data->msg.event_type), &temp2, - sizeof(pvt_data->msg.event_type)); - } - break; - } - -#ifdef BCMDBG - brcmf_c_show_host_event(event, event_data); -#endif /* BCMDBG */ - - return 0; -} - -/* Convert user's input in hex pattern to byte-size mask */ -static int brcmf_c_pattern_atoh(char *src, char *dst) -{ - int i; - if (strncmp(src, "0x", 2) != 0 && strncmp(src, "0X", 2) != 0) { - brcmf_dbg(ERROR, "Mask invalid format. Needs to start with 0x\n"); - return -EINVAL; - } - src = src + 2; /* Skip past 0x */ - if (strlen(src) % 2 != 0) { - brcmf_dbg(ERROR, "Mask invalid format. Length must be even.\n"); - return -EINVAL; - } - for (i = 0; *src != '\0'; i++) { - unsigned long res; - char num[3]; - strncpy(num, src, 2); - num[2] = '\0'; - if (kstrtoul(num, 16, &res)) - return -EINVAL; - dst[i] = (u8)res; - src += 2; - } - return i; -} - -void -brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable, - int master_mode) -{ - unsigned long res; - char *argv[8]; - int i = 0; - const char *str; - int buf_len; - int str_len; - char *arg_save = NULL, *arg_org = NULL; - int rc; - char buf[128]; - struct brcmf_pkt_filter_enable enable_parm; - struct brcmf_pkt_filter_enable *pkt_filterp; - - arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC); - if (!arg_save) - goto fail; - - arg_org = arg_save; - memcpy(arg_save, arg, strlen(arg) + 1); - - argv[i] = strsep(&arg_save, " "); - - i = 0; - if (NULL == argv[i]) { - brcmf_dbg(ERROR, "No args provided\n"); - goto fail; - } - - str = "pkt_filter_enable"; - str_len = strlen(str); - strncpy(buf, str, str_len); - buf[str_len] = '\0'; - buf_len = str_len + 1; - - pkt_filterp = (struct brcmf_pkt_filter_enable *) (buf + str_len + 1); - - /* Parse packet filter id. */ - enable_parm.id = 0; - if (!kstrtoul(argv[i], 0, &res)) - enable_parm.id = (u32)res; - - /* Parse enable/disable value. */ - enable_parm.enable = enable; - - buf_len += sizeof(enable_parm); - memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm)); - - /* Enable/disable the specified filter. */ - rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); - rc = rc >= 0 ? 0 : rc; - if (rc) - brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", - arg, rc); - else - brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg); - - /* Contorl the master mode */ - brcmu_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf, - sizeof(buf)); - rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, - sizeof(buf)); - rc = rc >= 0 ? 0 : rc; - if (rc) - brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", - arg, rc); - -fail: - kfree(arg_org); -} - -void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg) -{ - const char *str; - struct brcmf_pkt_filter pkt_filter; - struct brcmf_pkt_filter *pkt_filterp; - unsigned long res; - int buf_len; - int str_len; - int rc; - u32 mask_size; - u32 pattern_size; - char *argv[8], *buf = NULL; - int i = 0; - char *arg_save = NULL, *arg_org = NULL; - - arg_save = kstrdup(arg, GFP_ATOMIC); - if (!arg_save) - goto fail; - - arg_org = arg_save; - - buf = kmalloc(PKTFILTER_BUF_SIZE, GFP_ATOMIC); - if (!buf) - goto fail; - - argv[i] = strsep(&arg_save, " "); - while (argv[i++]) - argv[i] = strsep(&arg_save, " "); - - i = 0; - if (NULL == argv[i]) { - brcmf_dbg(ERROR, "No args provided\n"); - goto fail; - } - - str = "pkt_filter_add"; - strcpy(buf, str); - str_len = strlen(str); - buf_len = str_len + 1; - - pkt_filterp = (struct brcmf_pkt_filter *) (buf + str_len + 1); - - /* Parse packet filter id. */ - pkt_filter.id = 0; - if (!kstrtoul(argv[i], 0, &res)) - pkt_filter.id = (u32)res; - - if (NULL == argv[++i]) { - brcmf_dbg(ERROR, "Polarity not provided\n"); - goto fail; - } - - /* Parse filter polarity. */ - pkt_filter.negate_match = 0; - if (!kstrtoul(argv[i], 0, &res)) - pkt_filter.negate_match = (u32)res; - - if (NULL == argv[++i]) { - brcmf_dbg(ERROR, "Filter type not provided\n"); - goto fail; - } - - /* Parse filter type. */ - pkt_filter.type = 0; - if (!kstrtoul(argv[i], 0, &res)) - pkt_filter.type = (u32)res; - - if (NULL == argv[++i]) { - brcmf_dbg(ERROR, "Offset not provided\n"); - goto fail; - } - - /* Parse pattern filter offset. */ - pkt_filter.u.pattern.offset = 0; - if (!kstrtoul(argv[i], 0, &res)) - pkt_filter.u.pattern.offset = (u32)res; - - if (NULL == argv[++i]) { - brcmf_dbg(ERROR, "Bitmask not provided\n"); - goto fail; - } - - /* Parse pattern filter mask. */ - mask_size = - brcmf_c_pattern_atoh - (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern); - - if (NULL == argv[++i]) { - brcmf_dbg(ERROR, "Pattern not provided\n"); - goto fail; - } - - /* Parse pattern filter pattern. */ - pattern_size = - brcmf_c_pattern_atoh(argv[i], - (char *)&pkt_filterp->u.pattern. - mask_and_pattern[mask_size]); - - if (mask_size != pattern_size) { - brcmf_dbg(ERROR, "Mask and pattern not the same size\n"); - goto fail; - } - - pkt_filter.u.pattern.size_bytes = mask_size; - buf_len += BRCMF_PKT_FILTER_FIXED_LEN; - buf_len += (BRCMF_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size); - - /* Keep-alive attributes are set in local - * variable (keep_alive_pkt), and - ** then memcpy'ed into buffer (keep_alive_pktp) since there is no - ** guarantee that the buffer is properly aligned. - */ - memcpy((char *)pkt_filterp, - &pkt_filter, - BRCMF_PKT_FILTER_FIXED_LEN + BRCMF_PKT_FILTER_PATTERN_FIXED_LEN); - - rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf, buf_len); - rc = rc >= 0 ? 0 : rc; - - if (rc) - brcmf_dbg(TRACE, "failed to add pktfilter %s, retcode = %d\n", - arg, rc); - else - brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg); - -fail: - kfree(arg_org); - - kfree(buf); -} - -static void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode) -{ - char iovbuf[32]; - int retcode; - - brcmu_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); - retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, - iovbuf, sizeof(iovbuf)); - retcode = retcode >= 0 ? 0 : retcode; - if (retcode) - brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, retcode = %d\n", - arp_mode, retcode); - else - brcmf_dbg(TRACE, "successfully set ARP offload mode to 0x%x\n", - arp_mode); -} - -static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable) -{ - char iovbuf[32]; - int retcode; - - brcmu_mkiovar("arpoe", (char *)&arp_enable, 4, iovbuf, sizeof(iovbuf)); - retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, - iovbuf, sizeof(iovbuf)); - retcode = retcode >= 0 ? 0 : retcode; - if (retcode) - brcmf_dbg(TRACE, "failed to enable ARP offload to %d, retcode = %d\n", - arp_enable, retcode); - else - brcmf_dbg(TRACE, "successfully enabled ARP offload to %d\n", - arp_enable); -} - -int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr) -{ - char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for - "event_msgs" + '\0' + bitvec */ - uint up = 0; - char buf[128], *ptr; - u32 dongle_align = BRCMF_SDALIGN; - u32 glom = 0; - u32 roaming = 1; - uint bcn_timeout = 3; - int scan_assoc_time = 40; - int scan_unassoc_time = 40; - int i; - - brcmf_os_proto_block(drvr); - - /* Set Country code */ - if (drvr->country_code[0] != 0) { - if (brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_COUNTRY, - drvr->country_code, - sizeof(drvr->country_code)) < 0) - brcmf_dbg(ERROR, "country code setting failed\n"); - } - - /* query for 'ver' to get version info from firmware */ - memset(buf, 0, sizeof(buf)); - ptr = buf; - brcmu_mkiovar("ver", NULL, 0, buf, sizeof(buf)); - brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf)); - strsep(&ptr, "\n"); - /* Print fw version info */ - brcmf_dbg(ERROR, "Firmware version = %s\n", buf); - - /* Match Host and Dongle rx alignment */ - brcmu_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, - sizeof(iovbuf)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, - sizeof(iovbuf)); - - /* disable glom option per default */ - brcmu_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, - sizeof(iovbuf)); - - /* Setup timeout if Beacons are lost and roam is off to report - link down */ - brcmu_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, - sizeof(iovbuf)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, - sizeof(iovbuf)); - - /* Enable/Disable build-in roaming to allowed ext supplicant to take - of romaing */ - brcmu_mkiovar("roam_off", (char *)&roaming, 4, - iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, - sizeof(iovbuf)); - - /* Force STA UP */ - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up)); - - /* Setup event_msgs */ - brcmu_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, - iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, - sizeof(iovbuf)); - - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME, - (char *)&scan_assoc_time, sizeof(scan_assoc_time)); - brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME, - (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); - - /* Set and enable ARP offload feature */ - brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE); - brcmf_c_arp_offload_enable(drvr, true); - - /* Set up pkt filter */ - for (i = 0; i < drvr->pktfilter_count; i++) { - brcmf_c_pktfilter_offload_set(drvr, drvr->pktfilter[i]); - brcmf_c_pktfilter_offload_enable(drvr, drvr->pktfilter[i], - 0, true); - } - - brcmf_os_proto_unblock(drvr); - - return 0; -} diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h deleted file mode 100644 index 7467922f053..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCMF_DBG_H_ -#define _BRCMF_DBG_H_ - -#if defined(BCMDBG) - -#define brcmf_dbg(level, fmt, ...) \ -do { \ - if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \ - if (brcmf_msg_level & BRCMF_##level##_VAL) { \ - if (net_ratelimit()) \ - printk(KERN_DEBUG "%s: " fmt, \ - __func__, ##__VA_ARGS__); \ - } \ - } else { \ - if (brcmf_msg_level & BRCMF_##level##_VAL) { \ - printk(KERN_DEBUG "%s: " fmt, \ - __func__, ##__VA_ARGS__); \ - } \ - } \ -} while (0) - -#define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL) -#define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL) -#define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL) -#define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL) -#define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL) - -#else /* (defined BCMDBG) || (defined BCMDBG) */ - -#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) - -#define BRCMF_DATA_ON() 0 -#define BRCMF_CTL_ON() 0 -#define BRCMF_HDRS_ON() 0 -#define BRCMF_BYTES_ON() 0 -#define BRCMF_GLOM_ON() 0 - -#endif /* defined(BCMDBG) */ - -extern int brcmf_msg_level; - -#endif /* _BRCMF_DBG_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c deleted file mode 100644 index 99ba5e3e45f..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ /dev/null @@ -1,1354 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dhd.h" -#include "dhd_bus.h" -#include "dhd_proto.h" -#include "dhd_dbg.h" -#include "wl_cfg80211.h" -#include "bcmchip.h" - -MODULE_AUTHOR("Broadcom Corporation"); -MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver."); -MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards"); -MODULE_LICENSE("Dual BSD/GPL"); - - -/* Interface control information */ -struct brcmf_if { - struct brcmf_info *info; /* back pointer to brcmf_info */ - /* OS/stack specifics */ - struct net_device *ndev; - struct net_device_stats stats; - int idx; /* iface idx in dongle */ - int state; /* interface state */ - u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ -}; - -/* Local private structure (extension of pub) */ -struct brcmf_info { - struct brcmf_pub pub; - - /* OS/stack specifics */ - struct brcmf_if *iflist[BRCMF_MAX_IFS]; - - struct mutex proto_block; - - struct work_struct setmacaddr_work; - struct work_struct multicast_work; - u8 macvalue[ETH_ALEN]; - atomic_t pend_8021x_cnt; -}; - -/* Error bits */ -module_param(brcmf_msg_level, int, 0); - - -static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) -{ - int i = 0; - - while (i < BRCMF_MAX_IFS) { - if (drvr_priv->iflist[i] && drvr_priv->iflist[i]->ndev == ndev) - return i; - i++; - } - - return BRCMF_BAD_IF; -} - -int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) -{ - int i = BRCMF_MAX_IFS; - struct brcmf_if *ifp; - - if (name == NULL || *name == '\0') - return 0; - - while (--i > 0) { - ifp = drvr_priv->iflist[i]; - if (ifp && !strncmp(ifp->ndev->name, name, IFNAMSIZ)) - break; - } - - brcmf_dbg(TRACE, "return idx %d for \"%s\"\n", i, name); - - return i; /* default - the primary interface */ -} - -char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx) -{ - struct brcmf_info *drvr_priv = drvr->info; - - if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) { - brcmf_dbg(ERROR, "ifidx %d out of range\n", ifidx); - return ""; - } - - if (drvr_priv->iflist[ifidx] == NULL) { - brcmf_dbg(ERROR, "null i/f %d\n", ifidx); - return ""; - } - - if (drvr_priv->iflist[ifidx]->ndev) - return drvr_priv->iflist[ifidx]->ndev->name; - - return ""; -} - -static void _brcmf_set_multicast_list(struct work_struct *work) -{ - struct net_device *ndev; - struct netdev_hw_addr *ha; - u32 allmulti, cnt; - __le32 cnt_le; - __le32 allmulti_le; - - struct brcmf_dcmd dcmd; - char *buf, *bufp; - uint buflen; - int ret; - - struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, - multicast_work); - - ndev = drvr_priv->iflist[0]->ndev; - cnt = netdev_mc_count(ndev); - - /* Determine initial value of allmulti flag */ - allmulti = (ndev->flags & IFF_ALLMULTI) ? true : false; - - /* Send down the multicast list first. */ - - buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN); - bufp = buf = kmalloc(buflen, GFP_ATOMIC); - if (!bufp) - return; - - strcpy(bufp, "mcast_list"); - bufp += strlen("mcast_list") + 1; - - cnt_le = cpu_to_le32(cnt); - memcpy(bufp, &cnt_le, sizeof(cnt)); - bufp += sizeof(cnt_le); - - netdev_for_each_mc_addr(ha, ndev) { - if (!cnt) - break; - memcpy(bufp, ha->addr, ETH_ALEN); - bufp += ETH_ALEN; - cnt--; - } - - memset(&dcmd, 0, sizeof(dcmd)); - dcmd.cmd = BRCMF_C_SET_VAR; - dcmd.buf = buf; - dcmd.len = buflen; - dcmd.set = true; - - ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); - if (ret < 0) { - brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n", - brcmf_ifname(&drvr_priv->pub, 0), cnt); - allmulti = cnt ? true : allmulti; - } - - kfree(buf); - - /* Now send the allmulti setting. This is based on the setting in the - * net_device flags, but might be modified above to be turned on if we - * were trying to set some addresses and dongle rejected it... - */ - - buflen = sizeof("allmulti") + sizeof(allmulti); - buf = kmalloc(buflen, GFP_ATOMIC); - if (!buf) - return; - - allmulti_le = cpu_to_le32(allmulti); - - if (!brcmu_mkiovar - ("allmulti", (void *)&allmulti_le, - sizeof(allmulti_le), buf, buflen)) { - brcmf_dbg(ERROR, "%s: mkiovar failed for allmulti, datalen %d buflen %u\n", - brcmf_ifname(&drvr_priv->pub, 0), - (int)sizeof(allmulti), buflen); - kfree(buf); - return; - } - - memset(&dcmd, 0, sizeof(dcmd)); - dcmd.cmd = BRCMF_C_SET_VAR; - dcmd.buf = buf; - dcmd.len = buflen; - dcmd.set = true; - - ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); - if (ret < 0) { - brcmf_dbg(ERROR, "%s: set allmulti %d failed\n", - brcmf_ifname(&drvr_priv->pub, 0), - le32_to_cpu(allmulti_le)); - } - - kfree(buf); - - /* Finally, pick up the PROMISC flag as well, like the NIC - driver does */ - - allmulti = (ndev->flags & IFF_PROMISC) ? true : false; - allmulti_le = cpu_to_le32(allmulti); - - memset(&dcmd, 0, sizeof(dcmd)); - dcmd.cmd = BRCMF_C_SET_PROMISC; - dcmd.buf = &allmulti_le; - dcmd.len = sizeof(allmulti_le); - dcmd.set = true; - - ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); - if (ret < 0) { - brcmf_dbg(ERROR, "%s: set promisc %d failed\n", - brcmf_ifname(&drvr_priv->pub, 0), - le32_to_cpu(allmulti_le)); - } -} - -static void -_brcmf_set_mac_address(struct work_struct *work) -{ - char buf[32]; - struct brcmf_dcmd dcmd; - int ret; - - struct brcmf_info *drvr_priv = container_of(work, struct brcmf_info, - setmacaddr_work); - - brcmf_dbg(TRACE, "enter\n"); - if (!brcmu_mkiovar("cur_etheraddr", (char *)drvr_priv->macvalue, - ETH_ALEN, buf, 32)) { - brcmf_dbg(ERROR, "%s: mkiovar failed for cur_etheraddr\n", - brcmf_ifname(&drvr_priv->pub, 0)); - return; - } - memset(&dcmd, 0, sizeof(dcmd)); - dcmd.cmd = BRCMF_C_SET_VAR; - dcmd.buf = buf; - dcmd.len = 32; - dcmd.set = true; - - ret = brcmf_proto_dcmd(&drvr_priv->pub, 0, &dcmd, dcmd.len); - if (ret < 0) - brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n", - brcmf_ifname(&drvr_priv->pub, 0)); - else - memcpy(drvr_priv->iflist[0]->ndev->dev_addr, - drvr_priv->macvalue, ETH_ALEN); - - return; -} - -static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - struct sockaddr *sa = (struct sockaddr *)addr; - int ifidx; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return -1; - - memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); - schedule_work(&drvr_priv->setmacaddr_work); - return 0; -} - -static void brcmf_netdev_set_multicast_list(struct net_device *ndev) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return; - - schedule_work(&drvr_priv->multicast_work); -} - -int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) -{ - struct brcmf_info *drvr_priv = drvr->info; - - /* Reject if down */ - if (!drvr->up || (drvr->busstate == BRCMF_BUS_DOWN)) - return -ENODEV; - - /* Update multicast statistic */ - if (pktbuf->len >= ETH_ALEN) { - u8 *pktdata = (u8 *) (pktbuf->data); - struct ethhdr *eh = (struct ethhdr *)pktdata; - - if (is_multicast_ether_addr(eh->h_dest)) - drvr->tx_multicast++; - if (ntohs(eh->h_proto) == ETH_P_PAE) - atomic_inc(&drvr_priv->pend_8021x_cnt); - } - - /* If the protocol uses a data header, apply it */ - brcmf_proto_hdrpush(drvr, ifidx, pktbuf); - - /* Use bus module to send data frame */ - return brcmf_sdbrcm_bus_txdata(drvr->bus, pktbuf); -} - -static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) -{ - int ret; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Reject if down */ - if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == BRCMF_BUS_DOWN)) { - brcmf_dbg(ERROR, "xmit rejected pub.up=%d busstate=%d\n", - drvr_priv->pub.up, drvr_priv->pub.busstate); - netif_stop_queue(ndev); - return -ENODEV; - } - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) { - brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); - netif_stop_queue(ndev); - return -ENODEV; - } - - /* Make sure there's enough room for any header */ - if (skb_headroom(skb) < drvr_priv->pub.hdrlen) { - struct sk_buff *skb2; - - brcmf_dbg(INFO, "%s: insufficient headroom\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); - drvr_priv->pub.tx_realloc++; - skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); - dev_kfree_skb(skb); - skb = skb2; - if (skb == NULL) { - brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); - ret = -ENOMEM; - goto done; - } - } - - ret = brcmf_sendpkt(&drvr_priv->pub, ifidx, skb); - -done: - if (ret) - drvr_priv->pub.dstats.tx_dropped++; - else - drvr_priv->pub.tx_packets++; - - /* Return ok: we always eat the packet */ - return 0; -} - -void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool state) -{ - struct net_device *ndev; - struct brcmf_info *drvr_priv = drvr->info; - - brcmf_dbg(TRACE, "Enter\n"); - - drvr->txoff = state; - ndev = drvr_priv->iflist[ifidx]->ndev; - if (state == ON) - netif_stop_queue(ndev); - else - netif_wake_queue(ndev); -} - -static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, - void *pktdata, struct brcmf_event_msg *event, - void **data) -{ - int bcmerror = 0; - - bcmerror = brcmf_c_host_event(drvr_priv, ifidx, pktdata, event, data); - if (bcmerror != 0) - return bcmerror; - - if (drvr_priv->iflist[*ifidx]->ndev) - brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->ndev, - event, *data); - - return bcmerror; -} - -void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, - int numpkt) -{ - struct brcmf_info *drvr_priv = drvr->info; - unsigned char *eth; - uint len; - void *data; - struct sk_buff *pnext, *save_pktbuf; - int i; - struct brcmf_if *ifp; - struct brcmf_event_msg event; - - brcmf_dbg(TRACE, "Enter\n"); - - save_pktbuf = skb; - - for (i = 0; skb && i < numpkt; i++, skb = pnext) { - - pnext = skb->next; - skb->next = NULL; - - /* Get the protocol, maintain skb around eth_type_trans() - * The main reason for this hack is for the limitation of - * Linux 2.4 where 'eth_type_trans' uses the - * 'net->hard_header_len' - * to perform skb_pull inside vs ETH_HLEN. Since to avoid - * coping of the packet coming from the network stack to add - * BDC, Hardware header etc, during network interface - * registration - * we set the 'net->hard_header_len' to ETH_HLEN + extra space - * required - * for BDC, Hardware header etc. and not just the ETH_HLEN - */ - eth = skb->data; - len = skb->len; - - ifp = drvr_priv->iflist[ifidx]; - if (ifp == NULL) - ifp = drvr_priv->iflist[0]; - - skb->dev = ifp->ndev; - skb->protocol = eth_type_trans(skb, skb->dev); - - if (skb->pkt_type == PACKET_MULTICAST) - drvr_priv->pub.rx_multicast++; - - skb->data = eth; - skb->len = len; - - /* Strip header, count, deliver upward */ - skb_pull(skb, ETH_HLEN); - - /* Process special event packets and then discard them */ - if (ntohs(skb->protocol) == ETH_P_LINK_CTL) - brcmf_host_event(drvr_priv, &ifidx, - skb_mac_header(skb), - &event, &data); - - if (drvr_priv->iflist[ifidx] && - !drvr_priv->iflist[ifidx]->state) - ifp = drvr_priv->iflist[ifidx]; - - if (ifp->ndev) - ifp->ndev->last_rx = jiffies; - - drvr->dstats.rx_bytes += skb->len; - drvr->rx_packets++; /* Local count */ - - if (in_interrupt()) - netif_rx(skb); - else - /* If the receive is not processed inside an ISR, - * the softirqd must be woken explicitly to service - * the NET_RX_SOFTIRQ. In 2.6 kernels, this is handled - * by netif_rx_ni(), but in earlier kernels, we need - * to do it manually. - */ - netif_rx_ni(skb); - } -} - -void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success) -{ - uint ifidx; - struct brcmf_info *drvr_priv = drvr->info; - struct ethhdr *eh; - u16 type; - - brcmf_proto_hdrpull(drvr, &ifidx, txp); - - eh = (struct ethhdr *)(txp->data); - type = ntohs(eh->h_proto); - - if (type == ETH_P_PAE) - atomic_dec(&drvr_priv->pend_8021x_cnt); - -} - -static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - struct brcmf_if *ifp; - int ifidx; - - brcmf_dbg(TRACE, "Enter\n"); - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return NULL; - - ifp = drvr_priv->iflist[ifidx]; - - if (drvr_priv->pub.up) - /* Use the protocol to get dongle stats */ - brcmf_proto_dstats(&drvr_priv->pub); - - /* Copy dongle stats to net device stats */ - ifp->stats.rx_packets = drvr_priv->pub.dstats.rx_packets; - ifp->stats.tx_packets = drvr_priv->pub.dstats.tx_packets; - ifp->stats.rx_bytes = drvr_priv->pub.dstats.rx_bytes; - ifp->stats.tx_bytes = drvr_priv->pub.dstats.tx_bytes; - ifp->stats.rx_errors = drvr_priv->pub.dstats.rx_errors; - ifp->stats.tx_errors = drvr_priv->pub.dstats.tx_errors; - ifp->stats.rx_dropped = drvr_priv->pub.dstats.rx_dropped; - ifp->stats.tx_dropped = drvr_priv->pub.dstats.tx_dropped; - ifp->stats.multicast = drvr_priv->pub.dstats.multicast; - - return &ifp->stats; -} - -/* Retrieve current toe component enables, which are kept - as a bitmap in toe_ol iovar */ -static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol) -{ - struct brcmf_dcmd dcmd; - char buf[32]; - int ret; - - memset(&dcmd, 0, sizeof(dcmd)); - - dcmd.cmd = BRCMF_C_GET_VAR; - dcmd.buf = buf; - dcmd.len = (uint) sizeof(buf); - dcmd.set = false; - - strcpy(buf, "toe_ol"); - ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); - if (ret < 0) { - /* Check for older dongle image that doesn't support toe_ol */ - if (ret == -EIO) { - brcmf_dbg(ERROR, "%s: toe not supported by device\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); - return -EOPNOTSUPP; - } - - brcmf_dbg(INFO, "%s: could not get toe_ol: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret); - return ret; - } - - memcpy(toe_ol, buf, sizeof(u32)); - return 0; -} - -/* Set current toe component enables in toe_ol iovar, - and set toe global enable iovar */ -static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) -{ - struct brcmf_dcmd dcmd; - char buf[32]; - int toe, ret; - - memset(&dcmd, 0, sizeof(dcmd)); - - dcmd.cmd = BRCMF_C_SET_VAR; - dcmd.buf = buf; - dcmd.len = (uint) sizeof(buf); - dcmd.set = true; - - /* Set toe_ol as requested */ - - strcpy(buf, "toe_ol"); - memcpy(&buf[sizeof("toe_ol")], &toe_ol, sizeof(u32)); - - ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); - if (ret < 0) { - brcmf_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret); - return ret; - } - - /* Enable toe globally only if any components are enabled. */ - - toe = (toe_ol != 0); - - strcpy(buf, "toe"); - memcpy(&buf[sizeof("toe")], &toe, sizeof(u32)); - - ret = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, dcmd.len); - if (ret < 0) { - brcmf_dbg(ERROR, "%s: could not set toe: ret=%d\n", - brcmf_ifname(&drvr_priv->pub, ifidx), ret); - return ret; - } - - return 0; -} - -static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, - struct ethtool_drvinfo *info) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - - sprintf(info->driver, KBUILD_MODNAME); - sprintf(info->version, "%lu", drvr_priv->pub.drv_version); - sprintf(info->fw_version, "%s", BCM4329_FW_NAME); - sprintf(info->bus_info, "%s", - dev_name(brcmf_bus_get_device(drvr_priv->pub.bus))); -} - -static struct ethtool_ops brcmf_ethtool_ops = { - .get_drvinfo = brcmf_ethtool_get_drvinfo -}; - -static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) -{ - struct ethtool_drvinfo info; - char drvname[sizeof(info.driver)]; - u32 cmd; - struct ethtool_value edata; - u32 toe_cmpnt, csum_dir; - int ret; - - brcmf_dbg(TRACE, "Enter\n"); - - /* all ethtool calls start with a cmd word */ - if (copy_from_user(&cmd, uaddr, sizeof(u32))) - return -EFAULT; - - switch (cmd) { - case ETHTOOL_GDRVINFO: - /* Copy out any request driver name */ - if (copy_from_user(&info, uaddr, sizeof(info))) - return -EFAULT; - strncpy(drvname, info.driver, sizeof(info.driver)); - drvname[sizeof(info.driver) - 1] = '\0'; - - /* clear struct for return */ - memset(&info, 0, sizeof(info)); - info.cmd = cmd; - - /* if requested, identify ourselves */ - if (strcmp(drvname, "?dhd") == 0) { - sprintf(info.driver, "dhd"); - strcpy(info.version, BRCMF_VERSION_STR); - } - - /* otherwise, require dongle to be up */ - else if (!drvr_priv->pub.up) { - brcmf_dbg(ERROR, "dongle is not up\n"); - return -ENODEV; - } - - /* finally, report dongle driver type */ - else if (drvr_priv->pub.iswl) - sprintf(info.driver, "wl"); - else - sprintf(info.driver, "xx"); - - sprintf(info.version, "%lu", drvr_priv->pub.drv_version); - if (copy_to_user(uaddr, &info, sizeof(info))) - return -EFAULT; - brcmf_dbg(CTL, "given %*s, returning %s\n", - (int)sizeof(drvname), drvname, info.driver); - break; - - /* Get toe offload components from dongle */ - case ETHTOOL_GRXCSUM: - case ETHTOOL_GTXCSUM: - ret = brcmf_toe_get(drvr_priv, 0, &toe_cmpnt); - if (ret < 0) - return ret; - - csum_dir = - (cmd == ETHTOOL_GTXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL; - - edata.cmd = cmd; - edata.data = (toe_cmpnt & csum_dir) ? 1 : 0; - - if (copy_to_user(uaddr, &edata, sizeof(edata))) - return -EFAULT; - break; - - /* Set toe offload components in dongle */ - case ETHTOOL_SRXCSUM: - case ETHTOOL_STXCSUM: - if (copy_from_user(&edata, uaddr, sizeof(edata))) - return -EFAULT; - - /* Read the current settings, update and write back */ - ret = brcmf_toe_get(drvr_priv, 0, &toe_cmpnt); - if (ret < 0) - return ret; - - csum_dir = - (cmd == ETHTOOL_STXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL; - - if (edata.data != 0) - toe_cmpnt |= csum_dir; - else - toe_cmpnt &= ~csum_dir; - - ret = brcmf_toe_set(drvr_priv, 0, toe_cmpnt); - if (ret < 0) - return ret; - - /* If setting TX checksum mode, tell Linux the new mode */ - if (cmd == ETHTOOL_STXCSUM) { - if (edata.data) - drvr_priv->iflist[0]->ndev->features |= - NETIF_F_IP_CSUM; - else - drvr_priv->iflist[0]->ndev->features &= - ~NETIF_F_IP_CSUM; - } - - break; - - default: - return -EOPNOTSUPP; - } - - return 0; -} - -static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, - int cmd) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); - - if (ifidx == BRCMF_BAD_IF) - return -1; - - if (cmd == SIOCETHTOOL) - return brcmf_ethtool(drvr_priv, ifr->ifr_data); - - return -EOPNOTSUPP; -} - -/* called only from within this driver. Sends a command to the dongle. */ -s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) -{ - struct brcmf_dcmd dcmd; - s32 err = 0; - int buflen = 0; - bool is_set_key_cmd; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; - - memset(&dcmd, 0, sizeof(dcmd)); - dcmd.cmd = cmd; - dcmd.buf = arg; - dcmd.len = len; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - - if (dcmd.buf != NULL) - buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); - - /* send to dongle (must be up, and wl) */ - if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { - brcmf_dbg(ERROR, "DONGLE_DOWN\n"); - err = -EIO; - goto done; - } - - if (!drvr_priv->pub.iswl) { - err = -EIO; - goto done; - } - - /* - * Intercept BRCMF_C_SET_KEY CMD - serialize M4 send and - * set key CMD to prevent M4 encryption. - */ - is_set_key_cmd = ((dcmd.cmd == BRCMF_C_SET_KEY) || - ((dcmd.cmd == BRCMF_C_SET_VAR) && - !(strncmp("wsec_key", dcmd.buf, 9))) || - ((dcmd.cmd == BRCMF_C_SET_VAR) && - !(strncmp("bsscfg:wsec_key", dcmd.buf, 15)))); - if (is_set_key_cmd) - brcmf_netdev_wait_pend8021x(ndev); - - err = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, buflen); - -done: - if (err > 0) - err = 0; - - return err; -} - -static int brcmf_netdev_stop(struct net_device *ndev) -{ - struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(ndev); - - brcmf_dbg(TRACE, "Enter\n"); - brcmf_cfg80211_down(drvr->config); - if (drvr->up == 0) - return 0; - - /* Set state and stop OS transmissions */ - drvr->up = 0; - netif_stop_queue(ndev); - - return 0; -} - -static int brcmf_netdev_open(struct net_device *ndev) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - u32 toe_ol; - int ifidx = brcmf_net2idx(drvr_priv, ndev); - s32 ret = 0; - - brcmf_dbg(TRACE, "ifidx %d\n", ifidx); - - if (ifidx == 0) { /* do it only for primary eth0 */ - - /* try to bring up bus */ - ret = brcmf_bus_start(&drvr_priv->pub); - if (ret != 0) { - brcmf_dbg(ERROR, "failed with code %d\n", ret); - return -1; - } - atomic_set(&drvr_priv->pend_8021x_cnt, 0); - - memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); - - /* Get current TOE mode from dongle */ - if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0 - && (toe_ol & TOE_TX_CSUM_OL) != 0) - drvr_priv->iflist[ifidx]->ndev->features |= - NETIF_F_IP_CSUM; - else - drvr_priv->iflist[ifidx]->ndev->features &= - ~NETIF_F_IP_CSUM; - } - /* Allow transmit calls */ - netif_start_queue(ndev); - drvr_priv->pub.up = 1; - if (brcmf_cfg80211_up(drvr_priv->pub.config)) { - brcmf_dbg(ERROR, "failed to bring up cfg80211\n"); - return -1; - } - - return ret; -} - -int -brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, - char *name, u8 *mac_addr, u32 flags, u8 bssidx) -{ - struct brcmf_if *ifp; - int ret = 0, err = 0; - - brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); - - ifp = drvr_priv->iflist[ifidx]; - if (!ifp) { - ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); - if (!ifp) - return -ENOMEM; - } - - memset(ifp, 0, sizeof(struct brcmf_if)); - ifp->info = drvr_priv; - drvr_priv->iflist[ifidx] = ifp; - if (mac_addr != NULL) - memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - - if (ndev == NULL) { - ifp->state = BRCMF_E_IF_ADD; - ifp->idx = ifidx; - /* - * Delete the existing interface before overwriting it - * in case we missed the BRCMF_E_IF_DEL event. - */ - if (ifp->ndev != NULL) { - brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", - ifp->ndev->name); - netif_stop_queue(ifp->ndev); - unregister_netdev(ifp->ndev); - free_netdev(ifp->ndev); - } - - /* Allocate netdev, including space for private structure */ - ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", - ether_setup); - if (!ifp->ndev) { - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - ret = -ENOMEM; - } - - if (ret == 0) { - memcpy(netdev_priv(ifp->ndev), &drvr_priv, - sizeof(drvr_priv)); - err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); - if (err != 0) { - brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", - err); - ret = -EOPNOTSUPP; - } else { - brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", - current->pid, ifp->ndev->name); - ifp->state = 0; - } - } - - if (ret < 0) { - if (ifp->ndev) - free_netdev(ifp->ndev); - - drvr_priv->iflist[ifp->idx] = NULL; - kfree(ifp); - } - } else - ifp->ndev = ndev; - - return 0; -} - -void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) -{ - struct brcmf_if *ifp; - - brcmf_dbg(TRACE, "idx %d\n", ifidx); - - ifp = drvr_priv->iflist[ifidx]; - if (!ifp) { - brcmf_dbg(ERROR, "Null interface\n"); - return; - } - - ifp->state = BRCMF_E_IF_DEL; - ifp->idx = ifidx; - if (ifp->ndev != NULL) { - netif_stop_queue(ifp->ndev); - unregister_netdev(ifp->ndev); - free_netdev(ifp->ndev); - drvr_priv->iflist[ifidx] = NULL; - kfree(ifp); - } -} - -struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) -{ - struct brcmf_info *drvr_priv = NULL; - struct net_device *ndev; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Allocate netdev, including space for private structure */ - ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); - if (!ndev) { - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - goto fail; - } - - /* Allocate primary brcmf_info */ - drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); - if (!drvr_priv) - goto fail; - - /* - * Save the brcmf_info into the priv - */ - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); - - if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == - BRCMF_BAD_IF) - goto fail; - - ndev->netdev_ops = NULL; - mutex_init(&drvr_priv->proto_block); - - /* Link to info module */ - drvr_priv->pub.info = drvr_priv; - - /* Link to bus module */ - drvr_priv->pub.bus = bus; - drvr_priv->pub.hdrlen = bus_hdrlen; - - /* Attach and link in the protocol */ - if (brcmf_proto_attach(&drvr_priv->pub) != 0) { - brcmf_dbg(ERROR, "brcmf_prot_attach failed\n"); - goto fail; - } - - /* Attach and link in the cfg80211 */ - drvr_priv->pub.config = - brcmf_cfg80211_attach(ndev, - brcmf_bus_get_device(bus), - &drvr_priv->pub); - if (drvr_priv->pub.config == NULL) { - brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); - goto fail; - } - - INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); - INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); - - /* - * Save the brcmf_info into the priv - */ - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); - - return &drvr_priv->pub; - -fail: - if (ndev) - free_netdev(ndev); - if (drvr_priv) - brcmf_detach(&drvr_priv->pub); - - return NULL; -} - -int brcmf_bus_start(struct brcmf_pub *drvr) -{ - int ret = -1; - struct brcmf_info *drvr_priv = drvr->info; - /* Room for "event_msgs" + '\0' + bitvec */ - char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; - - brcmf_dbg(TRACE, "\n"); - - /* Bring up the bus */ - ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub); - if (ret != 0) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret); - return ret; - } - - /* If bus is not ready, can't come up */ - if (drvr_priv->pub.busstate != BRCMF_BUS_DATA) { - brcmf_dbg(ERROR, "failed bus is not ready\n"); - return -ENODEV; - } - - brcmu_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, - iovbuf, sizeof(iovbuf)); - brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, iovbuf, - sizeof(iovbuf)); - memcpy(drvr->eventmask, iovbuf, BRCMF_EVENTING_MASK_LEN); - - setbit(drvr->eventmask, BRCMF_E_SET_SSID); - setbit(drvr->eventmask, BRCMF_E_PRUNE); - setbit(drvr->eventmask, BRCMF_E_AUTH); - setbit(drvr->eventmask, BRCMF_E_REASSOC); - setbit(drvr->eventmask, BRCMF_E_REASSOC_IND); - setbit(drvr->eventmask, BRCMF_E_DEAUTH_IND); - setbit(drvr->eventmask, BRCMF_E_DISASSOC_IND); - setbit(drvr->eventmask, BRCMF_E_DISASSOC); - setbit(drvr->eventmask, BRCMF_E_JOIN); - setbit(drvr->eventmask, BRCMF_E_ASSOC_IND); - setbit(drvr->eventmask, BRCMF_E_PSK_SUP); - setbit(drvr->eventmask, BRCMF_E_LINK); - setbit(drvr->eventmask, BRCMF_E_NDIS_LINK); - setbit(drvr->eventmask, BRCMF_E_MIC_ERROR); - setbit(drvr->eventmask, BRCMF_E_PMKID_CACHE); - setbit(drvr->eventmask, BRCMF_E_TXFAIL); - setbit(drvr->eventmask, BRCMF_E_JOIN_START); - setbit(drvr->eventmask, BRCMF_E_SCAN_COMPLETE); - -/* enable dongle roaming event */ - - drvr->pktfilter_count = 1; - /* Setup filter to allow only unicast */ - drvr->pktfilter[0] = "100 0 0 0 0x01 0x00"; - - /* Bus is ready, do any protocol initialization */ - ret = brcmf_proto_init(&drvr_priv->pub); - if (ret < 0) - return ret; - - return 0; -} - -static struct net_device_ops brcmf_netdev_ops_pri = { - .ndo_open = brcmf_netdev_open, - .ndo_stop = brcmf_netdev_stop, - .ndo_get_stats = brcmf_netdev_get_stats, - .ndo_do_ioctl = brcmf_netdev_ioctl_entry, - .ndo_start_xmit = brcmf_netdev_start_xmit, - .ndo_set_mac_address = brcmf_netdev_set_mac_address, - .ndo_set_multicast_list = brcmf_netdev_set_multicast_list -}; - -int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) -{ - struct brcmf_info *drvr_priv = drvr->info; - struct net_device *ndev; - u8 temp_addr[ETH_ALEN] = { - 0x00, 0x90, 0x4c, 0x11, 0x22, 0x33}; - - brcmf_dbg(TRACE, "ifidx %d\n", ifidx); - - ndev = drvr_priv->iflist[ifidx]->ndev; - ndev->netdev_ops = &brcmf_netdev_ops_pri; - - /* - * We have to use the primary MAC for virtual interfaces - */ - if (ifidx != 0) { - /* for virtual interfaces use the primary MAC */ - memcpy(temp_addr, drvr_priv->pub.mac, ETH_ALEN); - - } - - if (ifidx == 1) { - brcmf_dbg(TRACE, "ACCESS POINT MAC:\n"); - /* ACCESSPOINT INTERFACE CASE */ - temp_addr[0] |= 0X02; /* set bit 2 , - - Locally Administered address */ - - } - ndev->hard_header_len = ETH_HLEN + drvr_priv->pub.hdrlen; - ndev->ethtool_ops = &brcmf_ethtool_ops; - - drvr_priv->pub.rxsz = ndev->mtu + ndev->hard_header_len + - drvr_priv->pub.hdrlen; - - memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); - - if (register_netdev(ndev) != 0) { - brcmf_dbg(ERROR, "couldn't register the net device\n"); - goto fail; - } - - brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", ndev->name); - - return 0; - -fail: - ndev->netdev_ops = NULL; - return -EBADE; -} - -static void brcmf_bus_detach(struct brcmf_pub *drvr) -{ - struct brcmf_info *drvr_priv; - - brcmf_dbg(TRACE, "Enter\n"); - - if (drvr) { - drvr_priv = drvr->info; - if (drvr_priv) { - /* Stop the protocol module */ - brcmf_proto_stop(&drvr_priv->pub); - - /* Stop the bus module */ - brcmf_sdbrcm_bus_stop(drvr_priv->pub.bus); - } - } -} - -void brcmf_detach(struct brcmf_pub *drvr) -{ - struct brcmf_info *drvr_priv; - - brcmf_dbg(TRACE, "Enter\n"); - - if (drvr) { - drvr_priv = drvr->info; - if (drvr_priv) { - struct brcmf_if *ifp; - int i; - - for (i = 1; i < BRCMF_MAX_IFS; i++) - if (drvr_priv->iflist[i]) - brcmf_del_if(drvr_priv, i); - - ifp = drvr_priv->iflist[0]; - if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { - rtnl_lock(); - brcmf_netdev_stop(ifp->ndev); - rtnl_unlock(); - unregister_netdev(ifp->ndev); - } - - cancel_work_sync(&drvr_priv->setmacaddr_work); - cancel_work_sync(&drvr_priv->multicast_work); - - brcmf_bus_detach(drvr); - - if (drvr->prot) - brcmf_proto_detach(drvr); - - brcmf_cfg80211_detach(drvr->config); - - free_netdev(ifp->ndev); - kfree(ifp); - kfree(drvr_priv); - } - } -} - -static void __exit brcmf_module_cleanup(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_bus_unregister(); -} - -static int __init brcmf_module_init(void) -{ - int error; - - brcmf_dbg(TRACE, "Enter\n"); - - error = brcmf_bus_register(); - - if (error) { - brcmf_dbg(ERROR, "brcmf_bus_register failed\n"); - goto failed; - } - return 0; - -failed: - return -EINVAL; -} - -module_init(brcmf_module_init); -module_exit(brcmf_module_cleanup); - -int brcmf_os_proto_block(struct brcmf_pub *drvr) -{ - struct brcmf_info *drvr_priv = drvr->info; - - if (drvr_priv) { - mutex_lock(&drvr_priv->proto_block); - return 1; - } - return 0; -} - -int brcmf_os_proto_unblock(struct brcmf_pub *drvr) -{ - struct brcmf_info *drvr_priv = drvr->info; - - if (drvr_priv) { - mutex_unlock(&drvr_priv->proto_block); - return 1; - } - - return 0; -} - -static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv) -{ - return atomic_read(&drvr_priv->pend_8021x_cnt); -} - -#define MAX_WAIT_FOR_8021X_TX 10 - -int brcmf_netdev_wait_pend8021x(struct net_device *ndev) -{ - struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(ndev); - int timeout = 10 * HZ / 1000; - int ntimes = MAX_WAIT_FOR_8021X_TX; - int pend = brcmf_get_pend_8021x_cnt(drvr_priv); - - while (ntimes && pend) { - if (pend) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(timeout); - set_current_state(TASK_RUNNING); - ntimes--; - } - pend = brcmf_get_pend_8021x_cnt(drvr_priv); - } - return pend; -} - -#ifdef BCMDBG -int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size) -{ - int ret = 0; - struct file *fp; - mm_segment_t old_fs; - loff_t pos = 0; - - /* change to KERNEL_DS address limit */ - old_fs = get_fs(); - set_fs(KERNEL_DS); - - /* open file to write */ - fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640); - if (!fp) { - brcmf_dbg(ERROR, "open file error\n"); - ret = -1; - goto exit; - } - - /* Write buf to file */ - fp->f_op->write(fp, buf, size, &pos); - -exit: - /* free buf before return */ - kfree(buf); - /* close file before return */ - if (fp) - filp_close(fp, current->files); - /* restore previous address limit */ - set_fs(old_fs); - - return ret; -} -#endif /* BCMDBG */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h deleted file mode 100644 index 4ee1ea846f6..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCMF_PROTO_H_ -#define _BRCMF_PROTO_H_ - -/* - * Exported from the brcmf protocol module (brcmf_cdc) - */ - -/* Linkage, sets prot link and updates hdrlen in pub */ -extern int brcmf_proto_attach(struct brcmf_pub *drvr); - -/* Unlink, frees allocated protocol memory (including brcmf_proto) */ -extern void brcmf_proto_detach(struct brcmf_pub *drvr); - -/* Initialize protocol: sync w/dongle state. - * Sets dongle media info (iswl, drv_version, mac address). - */ -extern int brcmf_proto_init(struct brcmf_pub *drvr); - -/* Stop protocol: sync w/dongle state. */ -extern void brcmf_proto_stop(struct brcmf_pub *drvr); - -/* Add any protocol-specific data header. - * Caller must reserve prot_hdrlen prepend space. - */ -extern void brcmf_proto_hdrpush(struct brcmf_pub *, int ifidx, - struct sk_buff *txp); - -/* Remove any protocol-specific data header. */ -extern int brcmf_proto_hdrpull(struct brcmf_pub *, int *ifidx, - struct sk_buff *rxp); - -/* Use protocol to issue command to dongle */ -extern int brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, - struct brcmf_dcmd *dcmd, int len); - -/* Update local copy of dongle statistics */ -extern void brcmf_proto_dstats(struct brcmf_pub *drvr); - -extern int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr); - -extern int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, - uint cmd, void *buf, uint len); - -#endif /* _BRCMF_PROTO_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c deleted file mode 100644 index 6885755f4ec..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ /dev/null @@ -1,4581 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sdio_host.h" - -#define DCMD_RESP_TIMEOUT 2000 /* In milli second */ - -#ifdef BCMDBG - -#define BRCMF_TRAP_INFO_SIZE 80 - -#define CBUF_LEN (128) - -struct rte_log_le { - __le32 buf; /* Can't be pointer on (64-bit) hosts */ - __le32 buf_size; - __le32 idx; - char *_buf_compat; /* Redundant pointer for backward compat. */ -}; - -struct rte_console { - /* Virtual UART - * When there is no UART (e.g. Quickturn), - * the host should write a complete - * input line directly into cbuf and then write - * the length into vcons_in. - * This may also be used when there is a real UART - * (at risk of conflicting with - * the real UART). vcons_out is currently unused. - */ - uint vcons_in; - uint vcons_out; - - /* Output (logging) buffer - * Console output is written to a ring buffer log_buf at index log_idx. - * The host may read the output when it sees log_idx advance. - * Output will be lost if the output wraps around faster than the host - * polls. - */ - struct rte_log_le log_le; - - /* Console input line buffer - * Characters are read one at a time into cbuf - * until is received, then - * the buffer is processed as a command line. - * Also used for virtual UART. - */ - uint cbuf_idx; - char cbuf[CBUF_LEN]; -}; - -#endif /* BCMDBG */ -#include - -#include "dhd.h" -#include "dhd_bus.h" -#include "dhd_proto.h" -#include "dhd_dbg.h" -#include - -#define TXQLEN 2048 /* bulk tx queue length */ -#define TXHI (TXQLEN - 256) /* turn on flow control above TXHI */ -#define TXLOW (TXHI - 256) /* turn off flow control below TXLOW */ -#define PRIOMASK 7 - -#define TXRETRIES 2 /* # of retries for tx frames */ - -#define BRCMF_RXBOUND 50 /* Default for max rx frames in - one scheduling */ - -#define BRCMF_TXBOUND 20 /* Default for max tx frames in - one scheduling */ - -#define BRCMF_TXMINMAX 1 /* Max tx frames if rx still pending */ - -#define MEMBLOCK 2048 /* Block size used for downloading - of dongle image */ -#define MAX_DATA_BUF (32 * 1024) /* Must be large enough to hold - biggest possible glom */ - -#define BRCMF_FIRSTREAD (1 << 6) - - -/* SBSDIO_DEVICE_CTL */ - -/* 1: device will assert busy signal when receiving CMD53 */ -#define SBSDIO_DEVCTL_SETBUSY 0x01 -/* 1: assertion of sdio interrupt is synchronous to the sdio clock */ -#define SBSDIO_DEVCTL_SPI_INTR_SYNC 0x02 -/* 1: mask all interrupts to host except the chipActive (rev 8) */ -#define SBSDIO_DEVCTL_CA_INT_ONLY 0x04 -/* 1: isolate internal sdio signals, put external pads in tri-state; requires - * sdio bus power cycle to clear (rev 9) */ -#define SBSDIO_DEVCTL_PADS_ISO 0x08 -/* Force SD->SB reset mapping (rev 11) */ -#define SBSDIO_DEVCTL_SB_RST_CTL 0x30 -/* Determined by CoreControl bit */ -#define SBSDIO_DEVCTL_RST_CORECTL 0x00 -/* Force backplane reset */ -#define SBSDIO_DEVCTL_RST_BPRESET 0x10 -/* Force no backplane reset */ -#define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 - -/* SBSDIO_FUNC1_CHIPCLKCSR */ - -/* Force ALP request to backplane */ -#define SBSDIO_FORCE_ALP 0x01 -/* Force HT request to backplane */ -#define SBSDIO_FORCE_HT 0x02 -/* Force ILP request to backplane */ -#define SBSDIO_FORCE_ILP 0x04 -/* Make ALP ready (power up xtal) */ -#define SBSDIO_ALP_AVAIL_REQ 0x08 -/* Make HT ready (power up PLL) */ -#define SBSDIO_HT_AVAIL_REQ 0x10 -/* Squelch clock requests from HW */ -#define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 -/* Status: ALP is ready */ -#define SBSDIO_ALP_AVAIL 0x40 -/* Status: HT is ready */ -#define SBSDIO_HT_AVAIL 0x80 - -#define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) -#define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) -#define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) -#define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) - -#define SBSDIO_CLKAV(regval, alponly) \ - (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) - -/* direct(mapped) cis space */ - -/* MAPPED common CIS address */ -#define SBSDIO_CIS_BASE_COMMON 0x1000 -/* maximum bytes in one CIS */ -#define SBSDIO_CIS_SIZE_LIMIT 0x200 -/* cis offset addr is < 17 bits */ -#define SBSDIO_CIS_OFT_ADDR_MASK 0x1FFFF - -/* manfid tuple length, include tuple, link bytes */ -#define SBSDIO_CIS_MANFID_TUPLE_LEN 6 - -/* intstatus */ -#define I_SMB_SW0 (1 << 0) /* To SB Mail S/W interrupt 0 */ -#define I_SMB_SW1 (1 << 1) /* To SB Mail S/W interrupt 1 */ -#define I_SMB_SW2 (1 << 2) /* To SB Mail S/W interrupt 2 */ -#define I_SMB_SW3 (1 << 3) /* To SB Mail S/W interrupt 3 */ -#define I_SMB_SW_MASK 0x0000000f /* To SB Mail S/W interrupts mask */ -#define I_SMB_SW_SHIFT 0 /* To SB Mail S/W interrupts shift */ -#define I_HMB_SW0 (1 << 4) /* To Host Mail S/W interrupt 0 */ -#define I_HMB_SW1 (1 << 5) /* To Host Mail S/W interrupt 1 */ -#define I_HMB_SW2 (1 << 6) /* To Host Mail S/W interrupt 2 */ -#define I_HMB_SW3 (1 << 7) /* To Host Mail S/W interrupt 3 */ -#define I_HMB_SW_MASK 0x000000f0 /* To Host Mail S/W interrupts mask */ -#define I_HMB_SW_SHIFT 4 /* To Host Mail S/W interrupts shift */ -#define I_WR_OOSYNC (1 << 8) /* Write Frame Out Of Sync */ -#define I_RD_OOSYNC (1 << 9) /* Read Frame Out Of Sync */ -#define I_PC (1 << 10) /* descriptor error */ -#define I_PD (1 << 11) /* data error */ -#define I_DE (1 << 12) /* Descriptor protocol Error */ -#define I_RU (1 << 13) /* Receive descriptor Underflow */ -#define I_RO (1 << 14) /* Receive fifo Overflow */ -#define I_XU (1 << 15) /* Transmit fifo Underflow */ -#define I_RI (1 << 16) /* Receive Interrupt */ -#define I_BUSPWR (1 << 17) /* SDIO Bus Power Change (rev 9) */ -#define I_XMTDATA_AVAIL (1 << 23) /* bits in fifo */ -#define I_XI (1 << 24) /* Transmit Interrupt */ -#define I_RF_TERM (1 << 25) /* Read Frame Terminate */ -#define I_WF_TERM (1 << 26) /* Write Frame Terminate */ -#define I_PCMCIA_XU (1 << 27) /* PCMCIA Transmit FIFO Underflow */ -#define I_SBINT (1 << 28) /* sbintstatus Interrupt */ -#define I_CHIPACTIVE (1 << 29) /* chip from doze to active state */ -#define I_SRESET (1 << 30) /* CCCR RES interrupt */ -#define I_IOE2 (1U << 31) /* CCCR IOE2 Bit Changed */ -#define I_ERRORS (I_PC | I_PD | I_DE | I_RU | I_RO | I_XU) -#define I_DMA (I_RI | I_XI | I_ERRORS) - -/* corecontrol */ -#define CC_CISRDY (1 << 0) /* CIS Ready */ -#define CC_BPRESEN (1 << 1) /* CCCR RES signal */ -#define CC_F2RDY (1 << 2) /* set CCCR IOR2 bit */ -#define CC_CLRPADSISO (1 << 3) /* clear SDIO pads isolation */ -#define CC_XMTDATAAVAIL_MODE (1 << 4) -#define CC_XMTDATAAVAIL_CTRL (1 << 5) - -/* SDA_FRAMECTRL */ -#define SFC_RF_TERM (1 << 0) /* Read Frame Terminate */ -#define SFC_WF_TERM (1 << 1) /* Write Frame Terminate */ -#define SFC_CRC4WOOS (1 << 2) /* CRC error for write out of sync */ -#define SFC_ABORTALL (1 << 3) /* Abort all in-progress frames */ - -/* HW frame tag */ -#define SDPCM_FRAMETAG_LEN 4 /* 2 bytes len, 2 bytes check val */ - -/* Total length of frame header for dongle protocol */ -#define SDPCM_HDRLEN (SDPCM_FRAMETAG_LEN + SDPCM_SWHEADER_LEN) -#define SDPCM_RESERVE (SDPCM_HDRLEN + BRCMF_SDALIGN) - -/* - * Software allocation of To SB Mailbox resources - */ - -/* tosbmailbox bits corresponding to intstatus bits */ -#define SMB_NAK (1 << 0) /* Frame NAK */ -#define SMB_INT_ACK (1 << 1) /* Host Interrupt ACK */ -#define SMB_USE_OOB (1 << 2) /* Use OOB Wakeup */ -#define SMB_DEV_INT (1 << 3) /* Miscellaneous Interrupt */ - -/* tosbmailboxdata */ -#define SMB_DATA_VERSION_SHIFT 16 /* host protocol version */ - -/* - * Software allocation of To Host Mailbox resources - */ - -/* intstatus bits */ -#define I_HMB_FC_STATE I_HMB_SW0 /* Flow Control State */ -#define I_HMB_FC_CHANGE I_HMB_SW1 /* Flow Control State Changed */ -#define I_HMB_FRAME_IND I_HMB_SW2 /* Frame Indication */ -#define I_HMB_HOST_INT I_HMB_SW3 /* Miscellaneous Interrupt */ - -/* tohostmailboxdata */ -#define HMB_DATA_NAKHANDLED 1 /* retransmit NAK'd frame */ -#define HMB_DATA_DEVREADY 2 /* talk to host after enable */ -#define HMB_DATA_FC 4 /* per prio flowcontrol update flag */ -#define HMB_DATA_FWREADY 8 /* fw ready for protocol activity */ - -#define HMB_DATA_FCDATA_MASK 0xff000000 -#define HMB_DATA_FCDATA_SHIFT 24 - -#define HMB_DATA_VERSION_MASK 0x00ff0000 -#define HMB_DATA_VERSION_SHIFT 16 - -/* - * Software-defined protocol header - */ - -/* Current protocol version */ -#define SDPCM_PROT_VERSION 4 - -/* SW frame header */ -#define SDPCM_PACKET_SEQUENCE(p) (((u8 *)p)[0] & 0xff) - -#define SDPCM_CHANNEL_MASK 0x00000f00 -#define SDPCM_CHANNEL_SHIFT 8 -#define SDPCM_PACKET_CHANNEL(p) (((u8 *)p)[1] & 0x0f) - -#define SDPCM_NEXTLEN_OFFSET 2 - -/* Data Offset from SOF (HW Tag, SW Tag, Pad) */ -#define SDPCM_DOFFSET_OFFSET 3 /* Data Offset */ -#define SDPCM_DOFFSET_VALUE(p) (((u8 *)p)[SDPCM_DOFFSET_OFFSET] & 0xff) -#define SDPCM_DOFFSET_MASK 0xff000000 -#define SDPCM_DOFFSET_SHIFT 24 -#define SDPCM_FCMASK_OFFSET 4 /* Flow control */ -#define SDPCM_FCMASK_VALUE(p) (((u8 *)p)[SDPCM_FCMASK_OFFSET] & 0xff) -#define SDPCM_WINDOW_OFFSET 5 /* Credit based fc */ -#define SDPCM_WINDOW_VALUE(p) (((u8 *)p)[SDPCM_WINDOW_OFFSET] & 0xff) - -#define SDPCM_SWHEADER_LEN 8 /* SW header is 64 bits */ - -/* logical channel numbers */ -#define SDPCM_CONTROL_CHANNEL 0 /* Control channel Id */ -#define SDPCM_EVENT_CHANNEL 1 /* Asyc Event Indication Channel Id */ -#define SDPCM_DATA_CHANNEL 2 /* Data Xmit/Recv Channel Id */ -#define SDPCM_GLOM_CHANNEL 3 /* For coalesced packets */ -#define SDPCM_TEST_CHANNEL 15 /* Reserved for test/debug packets */ - -#define SDPCM_SEQUENCE_WRAP 256 /* wrap-around val for 8bit frame seq */ - -#define SDPCM_GLOMDESC(p) (((u8 *)p)[1] & 0x80) - -/* - * Shared structure between dongle and the host. - * The structure contains pointers to trap or assert information. - */ -#define SDPCM_SHARED_VERSION 0x0002 -#define SDPCM_SHARED_VERSION_MASK 0x00FF -#define SDPCM_SHARED_ASSERT_BUILT 0x0100 -#define SDPCM_SHARED_ASSERT 0x0200 -#define SDPCM_SHARED_TRAP 0x0400 - -/* Space for header read, limit for data packets */ -#define MAX_HDR_READ (1 << 6) -#define MAX_RX_DATASZ 2048 - -/* Maximum milliseconds to wait for F2 to come up */ -#define BRCMF_WAIT_F2RDY 3000 - -/* Bump up limit on waiting for HT to account for first startup; - * if the image is doing a CRC calculation before programming the PMU - * for HT availability, it could take a couple hundred ms more, so - * max out at a 1 second (1000000us). - */ -#undef PMU_MAX_TRANSITION_DLY -#define PMU_MAX_TRANSITION_DLY 1000000 - -/* Value for ChipClockCSR during initial setup */ -#define BRCMF_INIT_CLKCTL1 (SBSDIO_FORCE_HW_CLKREQ_OFF | \ - SBSDIO_ALP_AVAIL_REQ) - -/* Flags for SDH calls */ -#define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) - -/* sbimstate */ -#define SBIM_IBE 0x20000 /* inbanderror */ -#define SBIM_TO 0x40000 /* timeout */ -#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ -#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ - -/* sbtmstatelow */ - -/* reset */ -#define SBTML_RESET 0x0001 -/* reject field */ -#define SBTML_REJ_MASK 0x0006 -/* reject */ -#define SBTML_REJ 0x0002 -/* temporary reject, for error recovery */ -#define SBTML_TMPREJ 0x0004 - -/* Shift to locate the SI control flags in sbtml */ -#define SBTML_SICF_SHIFT 16 - -/* sbtmstatehigh */ -#define SBTMH_SERR 0x0001 /* serror */ -#define SBTMH_INT 0x0002 /* interrupt */ -#define SBTMH_BUSY 0x0004 /* busy */ -#define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ - -/* Shift to locate the SI status flags in sbtmh */ -#define SBTMH_SISF_SHIFT 16 - -/* sbidlow */ -#define SBIDL_INIT 0x80 /* initiator */ - -/* sbidhigh */ -#define SBIDH_RC_MASK 0x000f /* revision code */ -#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ -#define SBIDH_RCE_SHIFT 8 -#define SBCOREREV(sbidh) \ - ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ - ((sbidh) & SBIDH_RC_MASK)) -#define SBIDH_CC_MASK 0x8ff0 /* core code */ -#define SBIDH_CC_SHIFT 4 -#define SBIDH_VC_MASK 0xffff0000 /* vendor code */ -#define SBIDH_VC_SHIFT 16 - -/* - * Conversion of 802.1D priority to precedence level - */ -static uint prio2prec(u32 prio) -{ - return (prio == PRIO_8021D_NONE || prio == PRIO_8021D_BE) ? - (prio^2) : prio; -} - -/* - * Core reg address translation. - * Both macro's returns a 32 bits byte address on the backplane bus. - */ -#define CORE_CC_REG(base, field) \ - (base + offsetof(struct chipcregs, field)) -#define CORE_BUS_REG(base, field) \ - (base + offsetof(struct sdpcmd_regs, field)) -#define CORE_SB(base, field) \ - (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) - -/* core registers */ -struct sdpcmd_regs { - u32 corecontrol; /* 0x00, rev8 */ - u32 corestatus; /* rev8 */ - u32 PAD[1]; - u32 biststatus; /* rev8 */ - - /* PCMCIA access */ - u16 pcmciamesportaladdr; /* 0x010, rev8 */ - u16 PAD[1]; - u16 pcmciamesportalmask; /* rev8 */ - u16 PAD[1]; - u16 pcmciawrframebc; /* rev8 */ - u16 PAD[1]; - u16 pcmciaunderflowtimer; /* rev8 */ - u16 PAD[1]; - - /* interrupt */ - u32 intstatus; /* 0x020, rev8 */ - u32 hostintmask; /* rev8 */ - u32 intmask; /* rev8 */ - u32 sbintstatus; /* rev8 */ - u32 sbintmask; /* rev8 */ - u32 funcintmask; /* rev4 */ - u32 PAD[2]; - u32 tosbmailbox; /* 0x040, rev8 */ - u32 tohostmailbox; /* rev8 */ - u32 tosbmailboxdata; /* rev8 */ - u32 tohostmailboxdata; /* rev8 */ - - /* synchronized access to registers in SDIO clock domain */ - u32 sdioaccess; /* 0x050, rev8 */ - u32 PAD[3]; - - /* PCMCIA frame control */ - u8 pcmciaframectrl; /* 0x060, rev8 */ - u8 PAD[3]; - u8 pcmciawatermark; /* rev8 */ - u8 PAD[155]; - - /* interrupt batching control */ - u32 intrcvlazy; /* 0x100, rev8 */ - u32 PAD[3]; - - /* counters */ - u32 cmd52rd; /* 0x110, rev8 */ - u32 cmd52wr; /* rev8 */ - u32 cmd53rd; /* rev8 */ - u32 cmd53wr; /* rev8 */ - u32 abort; /* rev8 */ - u32 datacrcerror; /* rev8 */ - u32 rdoutofsync; /* rev8 */ - u32 wroutofsync; /* rev8 */ - u32 writebusy; /* rev8 */ - u32 readwait; /* rev8 */ - u32 readterm; /* rev8 */ - u32 writeterm; /* rev8 */ - u32 PAD[40]; - u32 clockctlstatus; /* rev8 */ - u32 PAD[7]; - - u32 PAD[128]; /* DMA engines */ - - /* SDIO/PCMCIA CIS region */ - char cis[512]; /* 0x400-0x5ff, rev6 */ - - /* PCMCIA function control registers */ - char pcmciafcr[256]; /* 0x600-6ff, rev6 */ - u16 PAD[55]; - - /* PCMCIA backplane access */ - u16 backplanecsr; /* 0x76E, rev6 */ - u16 backplaneaddr0; /* rev6 */ - u16 backplaneaddr1; /* rev6 */ - u16 backplaneaddr2; /* rev6 */ - u16 backplaneaddr3; /* rev6 */ - u16 backplanedata0; /* rev6 */ - u16 backplanedata1; /* rev6 */ - u16 backplanedata2; /* rev6 */ - u16 backplanedata3; /* rev6 */ - u16 PAD[31]; - - /* sprom "size" & "blank" info */ - u16 spromstatus; /* 0x7BE, rev2 */ - u32 PAD[464]; - - u16 PAD[0x80]; -}; - -#ifdef BCMDBG -/* Device console log buffer state */ -struct brcmf_console { - uint count; /* Poll interval msec counter */ - uint log_addr; /* Log struct address (fixed) */ - struct rte_log_le log_le; /* Log struct (host copy) */ - uint bufsize; /* Size of log buffer */ - u8 *buf; /* Log buffer (host copy) */ - uint last; /* Last buffer read index */ -}; -#endif /* BCMDBG */ - -struct sdpcm_shared { - u32 flags; - u32 trap_addr; - u32 assert_exp_addr; - u32 assert_file_addr; - u32 assert_line; - u32 console_addr; /* Address of struct rte_console */ - u32 msgtrace_addr; - u8 tag[32]; -}; - -struct sdpcm_shared_le { - __le32 flags; - __le32 trap_addr; - __le32 assert_exp_addr; - __le32 assert_file_addr; - __le32 assert_line; - __le32 console_addr; /* Address of struct rte_console */ - __le32 msgtrace_addr; - u8 tag[32]; -}; - - -/* misc chip info needed by some of the routines */ -struct chip_info { - u32 chip; - u32 chiprev; - u32 cccorebase; - u32 ccrev; - u32 cccaps; - u32 buscorebase; /* 32 bits backplane bus address */ - u32 buscorerev; - u32 buscoretype; - u32 ramcorebase; - u32 armcorebase; - u32 pmurev; - u32 ramsize; -}; - -/* Private data for SDIO bus interaction */ -struct brcmf_bus { - struct brcmf_pub *drvr; - - struct brcmf_sdio_dev *sdiodev; /* sdio device handler */ - struct chip_info *ci; /* Chip info struct */ - char *vars; /* Variables (from CIS and/or other) */ - uint varsz; /* Size of variables buffer */ - - u32 ramsize; /* Size of RAM in SOCRAM (bytes) */ - - u32 hostintmask; /* Copy of Host Interrupt Mask */ - u32 intstatus; /* Intstatus bits (events) pending */ - bool dpc_sched; /* Indicates DPC schedule (intrpt rcvd) */ - bool fcstate; /* State of dongle flow-control */ - - uint blocksize; /* Block size of SDIO transfers */ - uint roundup; /* Max roundup limit */ - - struct pktq txq; /* Queue length used for flow-control */ - u8 flowcontrol; /* per prio flow control bitmask */ - u8 tx_seq; /* Transmit sequence number (next) */ - u8 tx_max; /* Maximum transmit sequence allowed */ - - u8 hdrbuf[MAX_HDR_READ + BRCMF_SDALIGN]; - u8 *rxhdr; /* Header of current rx frame (in hdrbuf) */ - u16 nextlen; /* Next Read Len from last header */ - u8 rx_seq; /* Receive sequence number (expected) */ - bool rxskip; /* Skip receive (awaiting NAK ACK) */ - - uint rxbound; /* Rx frames to read before resched */ - uint txbound; /* Tx frames to send before resched */ - uint txminmax; - - struct sk_buff *glomd; /* Packet containing glomming descriptor */ - struct sk_buff *glom; /* Packet chain for glommed superframe */ - uint glomerr; /* Glom packet read errors */ - - u8 *rxbuf; /* Buffer for receiving control packets */ - uint rxblen; /* Allocated length of rxbuf */ - u8 *rxctl; /* Aligned pointer into rxbuf */ - u8 *databuf; /* Buffer for receiving big glom packet */ - u8 *dataptr; /* Aligned pointer into databuf */ - uint rxlen; /* Length of valid data in buffer */ - - u8 sdpcm_ver; /* Bus protocol reported by dongle */ - - bool intr; /* Use interrupts */ - bool poll; /* Use polling */ - bool ipend; /* Device interrupt is pending */ - uint intrcount; /* Count of device interrupt callbacks */ - uint lastintrs; /* Count as of last watchdog timer */ - uint spurious; /* Count of spurious interrupts */ - uint pollrate; /* Ticks between device polls */ - uint polltick; /* Tick counter */ - uint pollcnt; /* Count of active polls */ - -#ifdef BCMDBG - uint console_interval; - struct brcmf_console console; /* Console output polling support */ - uint console_addr; /* Console address from shared struct */ -#endif /* BCMDBG */ - - uint regfails; /* Count of R_REG failures */ - - uint clkstate; /* State of sd and backplane clock(s) */ - bool activity; /* Activity flag for clock down */ - s32 idletime; /* Control for activity timeout */ - s32 idlecount; /* Activity timeout counter */ - s32 idleclock; /* How to set bus driver when idle */ - s32 sd_rxchain; - bool use_rxchain; /* If brcmf should use PKT chains */ - bool sleeping; /* Is SDIO bus sleeping? */ - bool rxflow_mode; /* Rx flow control mode */ - bool rxflow; /* Is rx flow control on */ - bool alp_only; /* Don't use HT clock (ALP only) */ -/* Field to decide if rx of control frames happen in rxbuf or lb-pool */ - bool usebufpool; - - /* Some additional counters */ - uint tx_sderrs; /* Count of tx attempts with sd errors */ - uint fcqueued; /* Tx packets that got queued */ - uint rxrtx; /* Count of rtx requests (NAK to dongle) */ - uint rx_toolong; /* Receive frames too long to receive */ - uint rxc_errors; /* SDIO errors when reading control frames */ - uint rx_hdrfail; /* SDIO errors on header reads */ - uint rx_badhdr; /* Bad received headers (roosync?) */ - uint rx_badseq; /* Mismatched rx sequence number */ - uint fc_rcvd; /* Number of flow-control events received */ - uint fc_xoff; /* Number which turned on flow-control */ - uint fc_xon; /* Number which turned off flow-control */ - uint rxglomfail; /* Failed deglom attempts */ - uint rxglomframes; /* Number of glom frames (superframes) */ - uint rxglompkts; /* Number of packets from glom frames */ - uint f2rxhdrs; /* Number of header reads */ - uint f2rxdata; /* Number of frame data reads */ - uint f2txdata; /* Number of f2 frame writes */ - uint f1regdata; /* Number of f1 register accesses */ - - u8 *ctrl_frame_buf; - u32 ctrl_frame_len; - bool ctrl_frame_stat; - - spinlock_t txqlock; - wait_queue_head_t ctrl_wait; - wait_queue_head_t dcmd_resp_wait; - - struct timer_list timer; - struct completion watchdog_wait; - struct task_struct *watchdog_tsk; - bool wd_timer_valid; - uint save_ms; - - struct task_struct *dpc_tsk; - struct completion dpc_wait; - - struct semaphore sdsem; - - const char *fw_name; - const struct firmware *firmware; - const char *nv_name; - u32 fw_ptr; -}; - -struct sbconfig { - u32 PAD[2]; - u32 sbipsflag; /* initiator port ocp slave flag */ - u32 PAD[3]; - u32 sbtpsflag; /* target port ocp slave flag */ - u32 PAD[11]; - u32 sbtmerrloga; /* (sonics >= 2.3) */ - u32 PAD; - u32 sbtmerrlog; /* (sonics >= 2.3) */ - u32 PAD[3]; - u32 sbadmatch3; /* address match3 */ - u32 PAD; - u32 sbadmatch2; /* address match2 */ - u32 PAD; - u32 sbadmatch1; /* address match1 */ - u32 PAD[7]; - u32 sbimstate; /* initiator agent state */ - u32 sbintvec; /* interrupt mask */ - u32 sbtmstatelow; /* target state */ - u32 sbtmstatehigh; /* target state */ - u32 sbbwa0; /* bandwidth allocation table0 */ - u32 PAD; - u32 sbimconfiglow; /* initiator configuration */ - u32 sbimconfighigh; /* initiator configuration */ - u32 sbadmatch0; /* address match0 */ - u32 PAD; - u32 sbtmconfiglow; /* target configuration */ - u32 sbtmconfighigh; /* target configuration */ - u32 sbbconfig; /* broadcast configuration */ - u32 PAD; - u32 sbbstate; /* broadcast state */ - u32 PAD[3]; - u32 sbactcnfg; /* activate configuration */ - u32 PAD[3]; - u32 sbflagst; /* current sbflags */ - u32 PAD[3]; - u32 sbidlow; /* identification */ - u32 sbidhigh; /* identification */ -}; - -/* clkstate */ -#define CLK_NONE 0 -#define CLK_SDONLY 1 -#define CLK_PENDING 2 /* Not used yet */ -#define CLK_AVAIL 3 - -#ifdef BCMDBG -static int qcount[NUMPRIO]; -static int tx_packets[NUMPRIO]; -#endif /* BCMDBG */ - -#define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ - -#define RETRYCHAN(chan) ((chan) == SDPCM_EVENT_CHANNEL) - -/* Retry count for register access failures */ -static const uint retry_limit = 2; - -/* Limit on rounding up frames */ -static const uint max_roundup = 512; - -#define ALIGNMENT 4 - -static void pkt_align(struct sk_buff *p, int len, int align) -{ - uint datalign; - datalign = (unsigned long)(p->data); - datalign = roundup(datalign, (align)) - datalign; - if (datalign) - skb_pull(p, datalign); - __skb_trim(p, len); -} - -/* To check if there's window offered */ -static bool data_ok(struct brcmf_bus *bus) -{ - return (u8)(bus->tx_max - bus->tx_seq) != 0 && - ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0; -} - -/* - * Reads a register in the SDIO hardware block. This block occupies a series of - * adresses on the 32 bit backplane bus. - */ -static void -r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) -{ - *retryvar = 0; - do { - *regvar = brcmf_sdcard_reg_read(bus->sdiodev, - bus->ci->buscorebase + reg_offset, sizeof(u32)); - } while (brcmf_sdcard_regfail(bus->sdiodev) && - (++(*retryvar) <= retry_limit)); - if (*retryvar) { - bus->regfails += (*retryvar-1); - if (*retryvar > retry_limit) { - brcmf_dbg(ERROR, "FAILED READ %Xh\n", reg_offset); - *regvar = 0; - } - } -} - -static void -w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) -{ - *retryvar = 0; - do { - brcmf_sdcard_reg_write(bus->sdiodev, - bus->ci->buscorebase + reg_offset, - sizeof(u32), regval); - } while (brcmf_sdcard_regfail(bus->sdiodev) && - (++(*retryvar) <= retry_limit)); - if (*retryvar) { - bus->regfails += (*retryvar-1); - if (*retryvar > retry_limit) - brcmf_dbg(ERROR, "FAILED REGISTER WRITE %Xh\n", - reg_offset); - } -} - -#define PKT_AVAILABLE() (intstatus & I_HMB_FRAME_IND) - -#define HOSTINTMASK (I_HMB_SW_MASK | I_CHIPACTIVE) - -/* Packet free applicable unconditionally for sdio and sdspi. - * Conditional if bufpool was present for gspi bus. - */ -static void brcmf_sdbrcm_pktfree2(struct brcmf_bus *bus, struct sk_buff *pkt) -{ - if (bus->usebufpool) - brcmu_pkt_buf_free_skb(pkt); -} - -/* Turn backplane clock on or off */ -static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) -{ - int err; - u8 clkctl, clkreq, devctl; - unsigned long timeout; - - brcmf_dbg(TRACE, "Enter\n"); - - clkctl = 0; - - if (on) { - /* Request HT Avail */ - clkreq = - bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; - - if ((bus->ci->chip == BCM4329_CHIP_ID) - && (bus->ci->chiprev == 0)) - clkreq |= SBSDIO_FORCE_ALP; - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); - if (err) { - brcmf_dbg(ERROR, "HT Avail request error: %d\n", err); - return -EBADE; - } - - if (pendok && ((bus->ci->buscoretype == PCMCIA_CORE_ID) - && (bus->ci->buscorerev == 9))) { - u32 dummy, retries; - r_sdreg32(bus, &dummy, - offsetof(struct sdpcmd_regs, clockctlstatus), - &retries); - } - - /* Check current status */ - clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (err) { - brcmf_dbg(ERROR, "HT Avail read error: %d\n", err); - return -EBADE; - } - - /* Go to pending and await interrupt if appropriate */ - if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { - /* Allow only clock-available interrupt */ - devctl = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, &err); - if (err) { - brcmf_dbg(ERROR, "Devctl error setting CA: %d\n", - err); - return -EBADE; - } - - devctl |= SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, devctl, &err); - brcmf_dbg(INFO, "CLKCTL: set PENDING\n"); - bus->clkstate = CLK_PENDING; - - return 0; - } else if (bus->clkstate == CLK_PENDING) { - /* Cancel CA-only interrupt filter */ - devctl = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, &err); - devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, devctl, &err); - } - - /* Otherwise, wait here (polling) for HT Avail */ - timeout = jiffies + - msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000); - while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { - clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - &err); - if (time_after(jiffies, timeout)) - break; - else - usleep_range(5000, 10000); - } - if (err) { - brcmf_dbg(ERROR, "HT Avail request error: %d\n", err); - return -EBADE; - } - if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { - brcmf_dbg(ERROR, "HT Avail timeout (%d): clkctl 0x%02x\n", - PMU_MAX_TRANSITION_DLY, clkctl); - return -EBADE; - } - - /* Mark clock available */ - bus->clkstate = CLK_AVAIL; - brcmf_dbg(INFO, "CLKCTL: turned ON\n"); - -#if defined(BCMDBG) - if (bus->alp_only != true) { - if (SBSDIO_ALPONLY(clkctl)) - brcmf_dbg(ERROR, "HT Clock should be on\n"); - } -#endif /* defined (BCMDBG) */ - - bus->activity = true; - } else { - clkreq = 0; - - if (bus->clkstate == CLK_PENDING) { - /* Cancel CA-only interrupt filter */ - devctl = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, &err); - devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, devctl, &err); - } - - bus->clkstate = CLK_SDONLY; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); - brcmf_dbg(INFO, "CLKCTL: turned OFF\n"); - if (err) { - brcmf_dbg(ERROR, "Failed access turning clock off: %d\n", - err); - return -EBADE; - } - } - return 0; -} - -/* Change idle/active SD state */ -static int brcmf_sdbrcm_sdclk(struct brcmf_bus *bus, bool on) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (on) - bus->clkstate = CLK_SDONLY; - else - bus->clkstate = CLK_NONE; - - return 0; -} - -/* Transition SD and backplane clock readiness */ -static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) -{ -#ifdef BCMDBG - uint oldstate = bus->clkstate; -#endif /* BCMDBG */ - - brcmf_dbg(TRACE, "Enter\n"); - - /* Early exit if we're already there */ - if (bus->clkstate == target) { - if (target == CLK_AVAIL) { - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - bus->activity = true; - } - return 0; - } - - switch (target) { - case CLK_AVAIL: - /* Make sure SD clock is available */ - if (bus->clkstate == CLK_NONE) - brcmf_sdbrcm_sdclk(bus, true); - /* Now request HT Avail on the backplane */ - brcmf_sdbrcm_htclk(bus, true, pendok); - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - bus->activity = true; - break; - - case CLK_SDONLY: - /* Remove HT request, or bring up SD clock */ - if (bus->clkstate == CLK_NONE) - brcmf_sdbrcm_sdclk(bus, true); - else if (bus->clkstate == CLK_AVAIL) - brcmf_sdbrcm_htclk(bus, false, false); - else - brcmf_dbg(ERROR, "request for %d -> %d\n", - bus->clkstate, target); - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - break; - - case CLK_NONE: - /* Make sure to remove HT request */ - if (bus->clkstate == CLK_AVAIL) - brcmf_sdbrcm_htclk(bus, false, false); - /* Now remove the SD clock */ - brcmf_sdbrcm_sdclk(bus, false); - brcmf_sdbrcm_wd_timer(bus, 0); - break; - } -#ifdef BCMDBG - brcmf_dbg(INFO, "%d -> %d\n", oldstate, bus->clkstate); -#endif /* BCMDBG */ - - return 0; -} - -static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) -{ - uint retries = 0; - - brcmf_dbg(INFO, "request %s (currently %s)\n", - sleep ? "SLEEP" : "WAKE", - bus->sleeping ? "SLEEP" : "WAKE"); - - /* Done if we're already in the requested state */ - if (sleep == bus->sleeping) - return 0; - - /* Going to sleep: set the alarm and turn off the lights... */ - if (sleep) { - /* Don't sleep if something is pending */ - if (bus->dpc_sched || bus->rxskip || pktq_len(&bus->txq)) - return -EBUSY; - - /* Make sure the controller has the bus up */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Tell device to start using OOB wakeup */ - w_sdreg32(bus, SMB_USE_OOB, - offsetof(struct sdpcmd_regs, tosbmailbox), &retries); - if (retries > retry_limit) - brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n"); - - /* Turn off our contribution to the HT clock request */ - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); - - /* Isolate the bus */ - if (bus->ci->chip != BCM4329_CHIP_ID) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, - SBSDIO_DEVCTL_PADS_ISO, NULL); - } - - /* Change state */ - bus->sleeping = true; - - } else { - /* Waking up: bus power up is ok, set local state */ - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - - /* Force pad isolation off if possible - (in case power never toggled) */ - if ((bus->ci->buscoretype == PCMCIA_CORE_ID) - && (bus->ci->buscorerev >= 10)) - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, 0, NULL); - - /* Make sure the controller has the bus up */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Send misc interrupt to indicate OOB not needed */ - w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, tosbmailboxdata), - &retries); - if (retries <= retry_limit) - w_sdreg32(bus, SMB_DEV_INT, - offsetof(struct sdpcmd_regs, tosbmailbox), - &retries); - - if (retries > retry_limit) - brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP TO CLEAR OOB!!\n"); - - /* Make sure we have SD bus access */ - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - - /* Change state */ - bus->sleeping = false; - } - - return 0; -} - -static void bus_wake(struct brcmf_bus *bus) -{ - if (bus->sleeping) - brcmf_sdbrcm_bussleep(bus, false); -} - -static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) -{ - u32 intstatus = 0; - u32 hmb_data; - u8 fcbits; - uint retries = 0; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Read mailbox data and ack that we did so */ - r_sdreg32(bus, &hmb_data, - offsetof(struct sdpcmd_regs, tohostmailboxdata), &retries); - - if (retries <= retry_limit) - w_sdreg32(bus, SMB_INT_ACK, - offsetof(struct sdpcmd_regs, tosbmailbox), &retries); - bus->f1regdata += 2; - - /* Dongle recomposed rx frames, accept them again */ - if (hmb_data & HMB_DATA_NAKHANDLED) { - brcmf_dbg(INFO, "Dongle reports NAK handled, expect rtx of %d\n", - bus->rx_seq); - if (!bus->rxskip) - brcmf_dbg(ERROR, "unexpected NAKHANDLED!\n"); - - bus->rxskip = false; - intstatus |= I_HMB_FRAME_IND; - } - - /* - * DEVREADY does not occur with gSPI. - */ - if (hmb_data & (HMB_DATA_DEVREADY | HMB_DATA_FWREADY)) { - bus->sdpcm_ver = - (hmb_data & HMB_DATA_VERSION_MASK) >> - HMB_DATA_VERSION_SHIFT; - if (bus->sdpcm_ver != SDPCM_PROT_VERSION) - brcmf_dbg(ERROR, "Version mismatch, dongle reports %d, " - "expecting %d\n", - bus->sdpcm_ver, SDPCM_PROT_VERSION); - else - brcmf_dbg(INFO, "Dongle ready, protocol version %d\n", - bus->sdpcm_ver); - } - - /* - * Flow Control has been moved into the RX headers and this out of band - * method isn't used any more. - * remaining backward compatible with older dongles. - */ - if (hmb_data & HMB_DATA_FC) { - fcbits = (hmb_data & HMB_DATA_FCDATA_MASK) >> - HMB_DATA_FCDATA_SHIFT; - - if (fcbits & ~bus->flowcontrol) - bus->fc_xoff++; - - if (bus->flowcontrol & ~fcbits) - bus->fc_xon++; - - bus->fc_rcvd++; - bus->flowcontrol = fcbits; - } - - /* Shouldn't be any others */ - if (hmb_data & ~(HMB_DATA_DEVREADY | - HMB_DATA_NAKHANDLED | - HMB_DATA_FC | - HMB_DATA_FWREADY | - HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) - brcmf_dbg(ERROR, "Unknown mailbox data content: 0x%02x\n", - hmb_data); - - return intstatus; -} - -static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) -{ - uint retries = 0; - u16 lastrbc; - u8 hi, lo; - int err; - - brcmf_dbg(ERROR, "%sterminate frame%s\n", - abort ? "abort command, " : "", - rtx ? ", send NAK" : ""); - - if (abort) - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, - SFC_RF_TERM, &err); - bus->f1regdata++; - - /* Wait until the packet has been flushed (device/FIFO stable) */ - for (lastrbc = retries = 0xffff; retries > 0; retries--) { - hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_RFRAMEBCHI, NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_RFRAMEBCLO, NULL); - bus->f1regdata += 2; - - if ((hi == 0) && (lo == 0)) - break; - - if ((hi > (lastrbc >> 8)) && (lo > (lastrbc & 0x00ff))) { - brcmf_dbg(ERROR, "count growing: last 0x%04x now 0x%04x\n", - lastrbc, (hi << 8) + lo); - } - lastrbc = (hi << 8) + lo; - } - - if (!retries) - brcmf_dbg(ERROR, "count never zeroed: last 0x%04x\n", lastrbc); - else - brcmf_dbg(INFO, "flush took %d iterations\n", 0xffff - retries); - - if (rtx) { - bus->rxrtx++; - w_sdreg32(bus, SMB_NAK, - offsetof(struct sdpcmd_regs, tosbmailbox), &retries); - - bus->f1regdata++; - if (retries <= retry_limit) - bus->rxskip = true; - } - - /* Clear partial in any case */ - bus->nextlen = 0; - - /* If we can't reach the device, signal failure */ - if (err || brcmf_sdcard_regfail(bus->sdiodev)) - bus->drvr->busstate = BRCMF_BUS_DOWN; -} - -static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) -{ - u16 dlen, totlen; - u8 *dptr, num = 0; - - u16 sublen, check; - struct sk_buff *pfirst, *plast, *pnext, *save_pfirst; - - int errcode; - u8 chan, seq, doff, sfdoff; - u8 txmax; - - int ifidx = 0; - bool usechain = bus->use_rxchain; - - /* If packets, issue read(s) and send up packet chain */ - /* Return sequence numbers consumed? */ - - brcmf_dbg(TRACE, "start: glomd %p glom %p\n", bus->glomd, bus->glom); - - /* If there's a descriptor, generate the packet chain */ - if (bus->glomd) { - pfirst = plast = pnext = NULL; - dlen = (u16) (bus->glomd->len); - dptr = bus->glomd->data; - if (!dlen || (dlen & 1)) { - brcmf_dbg(ERROR, "bad glomd len(%d), ignore descriptor\n", - dlen); - dlen = 0; - } - - for (totlen = num = 0; dlen; num++) { - /* Get (and move past) next length */ - sublen = get_unaligned_le16(dptr); - dlen -= sizeof(u16); - dptr += sizeof(u16); - if ((sublen < SDPCM_HDRLEN) || - ((num == 0) && (sublen < (2 * SDPCM_HDRLEN)))) { - brcmf_dbg(ERROR, "descriptor len %d bad: %d\n", - num, sublen); - pnext = NULL; - break; - } - if (sublen % BRCMF_SDALIGN) { - brcmf_dbg(ERROR, "sublen %d not multiple of %d\n", - sublen, BRCMF_SDALIGN); - usechain = false; - } - totlen += sublen; - - /* For last frame, adjust read len so total - is a block multiple */ - if (!dlen) { - sublen += - (roundup(totlen, bus->blocksize) - totlen); - totlen = roundup(totlen, bus->blocksize); - } - - /* Allocate/chain packet for next subframe */ - pnext = brcmu_pkt_buf_get_skb(sublen + BRCMF_SDALIGN); - if (pnext == NULL) { - brcmf_dbg(ERROR, "bcm_pkt_buf_get_skb failed, num %d len %d\n", - num, sublen); - break; - } - if (!pfirst) { - pfirst = plast = pnext; - } else { - plast->next = pnext; - plast = pnext; - } - - /* Adhere to start alignment requirements */ - pkt_align(pnext, sublen, BRCMF_SDALIGN); - } - - /* If all allocations succeeded, save packet chain - in bus structure */ - if (pnext) { - brcmf_dbg(GLOM, "allocated %d-byte packet chain for %d subframes\n", - totlen, num); - if (BRCMF_GLOM_ON() && bus->nextlen && - totlen != bus->nextlen) { - brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", - bus->nextlen, totlen, rxseq); - } - bus->glom = pfirst; - pfirst = pnext = NULL; - } else { - if (pfirst) - brcmu_pkt_buf_free_skb(pfirst); - bus->glom = NULL; - num = 0; - } - - /* Done with descriptor packet */ - brcmu_pkt_buf_free_skb(bus->glomd); - bus->glomd = NULL; - bus->nextlen = 0; - } - - /* Ok -- either we just generated a packet chain, - or had one from before */ - if (bus->glom) { - if (BRCMF_GLOM_ON()) { - brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); - for (pnext = bus->glom; pnext; pnext = pnext->next) { - brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", - pnext, (u8 *) (pnext->data), - pnext->len, pnext->len); - } - } - - pfirst = bus->glom; - dlen = (u16) brcmu_pkttotlen(pfirst); - - /* Do an SDIO read for the superframe. Configurable iovar to - * read directly into the chained packet, or allocate a large - * packet and and copy into the chain. - */ - if (usechain) { - errcode = brcmf_sdcard_recv_buf(bus->sdiodev, - bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, (u8 *) pfirst->data, dlen, - pfirst); - } else if (bus->dataptr) { - errcode = brcmf_sdcard_recv_buf(bus->sdiodev, - bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, bus->dataptr, dlen, - NULL); - sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, - bus->dataptr); - if (sublen != dlen) { - brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", - dlen, sublen); - errcode = -1; - } - pnext = NULL; - } else { - brcmf_dbg(ERROR, "COULDN'T ALLOC %d-BYTE GLOM, FORCE FAILURE\n", - dlen); - errcode = -1; - } - bus->f2rxdata++; - - /* On failure, kill the superframe, allow a couple retries */ - if (errcode < 0) { - brcmf_dbg(ERROR, "glom read of %d bytes failed: %d\n", - dlen, errcode); - bus->drvr->rx_errors++; - - if (bus->glomerr++ < 3) { - brcmf_sdbrcm_rxfail(bus, true, true); - } else { - bus->glomerr = 0; - brcmf_sdbrcm_rxfail(bus, true, false); - brcmu_pkt_buf_free_skb(bus->glom); - bus->rxglomfail++; - bus->glom = NULL; - } - return 0; - } -#ifdef BCMDBG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "SUPERFRAME:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pfirst->data, min_t(int, pfirst->len, 48)); - } -#endif - - /* Validate the superframe header */ - dptr = (u8 *) (pfirst->data); - sublen = get_unaligned_le16(dptr); - check = get_unaligned_le16(dptr + sizeof(u16)); - - chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); - seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); - bus->nextlen = dptr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; - if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - brcmf_dbg(INFO, "nextlen too large (%d) seq %d\n", - bus->nextlen, seq); - bus->nextlen = 0; - } - doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); - txmax = SDPCM_WINDOW_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); - - errcode = 0; - if ((u16)~(sublen ^ check)) { - brcmf_dbg(ERROR, "(superframe): HW hdr error: len/check 0x%04x/0x%04x\n", - sublen, check); - errcode = -1; - } else if (roundup(sublen, bus->blocksize) != dlen) { - brcmf_dbg(ERROR, "(superframe): len 0x%04x, rounded 0x%04x, expect 0x%04x\n", - sublen, roundup(sublen, bus->blocksize), - dlen); - errcode = -1; - } else if (SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]) != - SDPCM_GLOM_CHANNEL) { - brcmf_dbg(ERROR, "(superframe): bad channel %d\n", - SDPCM_PACKET_CHANNEL( - &dptr[SDPCM_FRAMETAG_LEN])); - errcode = -1; - } else if (SDPCM_GLOMDESC(&dptr[SDPCM_FRAMETAG_LEN])) { - brcmf_dbg(ERROR, "(superframe): got 2nd descriptor?\n"); - errcode = -1; - } else if ((doff < SDPCM_HDRLEN) || - (doff > (pfirst->len - SDPCM_HDRLEN))) { - brcmf_dbg(ERROR, "(superframe): Bad data offset %d: HW %d pkt %d min %d\n", - doff, sublen, pfirst->len, SDPCM_HDRLEN); - errcode = -1; - } - - /* Check sequence number of superframe SW header */ - if (rxseq != seq) { - brcmf_dbg(INFO, "(superframe) rx_seq %d, expected %d\n", - seq, rxseq); - bus->rx_badseq++; - rxseq = seq; - } - - /* Check window for sanity */ - if ((u8) (txmax - bus->tx_seq) > 0x40) { - brcmf_dbg(ERROR, "unlikely tx max %d with tx_seq %d\n", - txmax, bus->tx_seq); - txmax = bus->tx_seq + 2; - } - bus->tx_max = txmax; - - /* Remove superframe header, remember offset */ - skb_pull(pfirst, doff); - sfdoff = doff; - - /* Validate all the subframe headers */ - for (num = 0, pnext = pfirst; pnext && !errcode; - num++, pnext = pnext->next) { - dptr = (u8 *) (pnext->data); - dlen = (u16) (pnext->len); - sublen = get_unaligned_le16(dptr); - check = get_unaligned_le16(dptr + sizeof(u16)); - chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); - doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); -#ifdef BCMDBG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "subframe:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - dptr, 32); - } -#endif - - if ((u16)~(sublen ^ check)) { - brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n", - num, sublen, check); - errcode = -1; - } else if ((sublen > dlen) || (sublen < SDPCM_HDRLEN)) { - brcmf_dbg(ERROR, "(subframe %d): length mismatch: len 0x%04x, expect 0x%04x\n", - num, sublen, dlen); - errcode = -1; - } else if ((chan != SDPCM_DATA_CHANNEL) && - (chan != SDPCM_EVENT_CHANNEL)) { - brcmf_dbg(ERROR, "(subframe %d): bad channel %d\n", - num, chan); - errcode = -1; - } else if ((doff < SDPCM_HDRLEN) || (doff > sublen)) { - brcmf_dbg(ERROR, "(subframe %d): Bad data offset %d: HW %d min %d\n", - num, doff, sublen, SDPCM_HDRLEN); - errcode = -1; - } - } - - if (errcode) { - /* Terminate frame on error, request - a couple retries */ - if (bus->glomerr++ < 3) { - /* Restore superframe header space */ - skb_push(pfirst, sfdoff); - brcmf_sdbrcm_rxfail(bus, true, true); - } else { - bus->glomerr = 0; - brcmf_sdbrcm_rxfail(bus, true, false); - brcmu_pkt_buf_free_skb(bus->glom); - bus->rxglomfail++; - bus->glom = NULL; - } - bus->nextlen = 0; - return 0; - } - - /* Basic SD framing looks ok - process each packet (header) */ - save_pfirst = pfirst; - bus->glom = NULL; - plast = NULL; - - for (num = 0; pfirst; rxseq++, pfirst = pnext) { - pnext = pfirst->next; - pfirst->next = NULL; - - dptr = (u8 *) (pfirst->data); - sublen = get_unaligned_le16(dptr); - chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); - seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); - doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); - - brcmf_dbg(GLOM, "Get subframe %d, %p(%p/%d), sublen %d chan %d seq %d\n", - num, pfirst, pfirst->data, - pfirst->len, sublen, chan, seq); - - /* precondition: chan == SDPCM_DATA_CHANNEL || - chan == SDPCM_EVENT_CHANNEL */ - - if (rxseq != seq) { - brcmf_dbg(GLOM, "rx_seq %d, expected %d\n", - seq, rxseq); - bus->rx_badseq++; - rxseq = seq; - } -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Subframe Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - dptr, dlen); - } -#endif - - __skb_trim(pfirst, sublen); - skb_pull(pfirst, doff); - - if (pfirst->len == 0) { - brcmu_pkt_buf_free_skb(pfirst); - if (plast) - plast->next = pnext; - else - save_pfirst = pnext; - - continue; - } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, - pfirst) != 0) { - brcmf_dbg(ERROR, "rx protocol error\n"); - bus->drvr->rx_errors++; - brcmu_pkt_buf_free_skb(pfirst); - if (plast) - plast->next = pnext; - else - save_pfirst = pnext; - - continue; - } - - /* this packet will go up, link back into - chain and count it */ - pfirst->next = pnext; - plast = pfirst; - num++; - -#ifdef BCMDBG - if (BRCMF_GLOM_ON()) { - brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", - num, pfirst, pfirst->data, - pfirst->len, pfirst->next, - pfirst->prev); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pfirst->data, - min_t(int, pfirst->len, 32)); - } -#endif /* BCMDBG */ - } - if (num) { - up(&bus->sdsem); - brcmf_rx_frame(bus->drvr, ifidx, save_pfirst, num); - down(&bus->sdsem); - } - - bus->rxglomframes++; - bus->rxglompkts += num; - } - return num; -} - -static int brcmf_sdbrcm_dcmd_resp_wait(struct brcmf_bus *bus, uint *condition, - bool *pending) -{ - DECLARE_WAITQUEUE(wait, current); - int timeout = msecs_to_jiffies(DCMD_RESP_TIMEOUT); - - /* Wait until control frame is available */ - add_wait_queue(&bus->dcmd_resp_wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); - - while (!(*condition) && (!signal_pending(current) && timeout)) - timeout = schedule_timeout(timeout); - - if (signal_pending(current)) - *pending = true; - - set_current_state(TASK_RUNNING); - remove_wait_queue(&bus->dcmd_resp_wait, &wait); - - return timeout; -} - -static int brcmf_sdbrcm_dcmd_resp_wake(struct brcmf_bus *bus) -{ - if (waitqueue_active(&bus->dcmd_resp_wait)) - wake_up_interruptible(&bus->dcmd_resp_wait); - - return 0; -} -static void -brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) -{ - uint rdlen, pad; - - int sdret; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Set rxctl for frame (w/optional alignment) */ - bus->rxctl = bus->rxbuf; - bus->rxctl += BRCMF_FIRSTREAD; - pad = ((unsigned long)bus->rxctl % BRCMF_SDALIGN); - if (pad) - bus->rxctl += (BRCMF_SDALIGN - pad); - bus->rxctl -= BRCMF_FIRSTREAD; - - /* Copy the already-read portion over */ - memcpy(bus->rxctl, hdr, BRCMF_FIRSTREAD); - if (len <= BRCMF_FIRSTREAD) - goto gotpkt; - - /* Raise rdlen to next SDIO block to avoid tail command */ - rdlen = len - BRCMF_FIRSTREAD; - if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { - pad = bus->blocksize - (rdlen % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize) && - ((len + pad) < bus->drvr->maxctl)) - rdlen += pad; - } else if (rdlen % BRCMF_SDALIGN) { - rdlen += BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); - } - - /* Satisfy length-alignment requirements */ - if (rdlen & (ALIGNMENT - 1)) - rdlen = roundup(rdlen, ALIGNMENT); - - /* Drop if the read is too big or it exceeds our maximum */ - if ((rdlen + BRCMF_FIRSTREAD) > bus->drvr->maxctl) { - brcmf_dbg(ERROR, "%d-byte control read exceeds %d-byte buffer\n", - rdlen, bus->drvr->maxctl); - bus->drvr->rx_errors++; - brcmf_sdbrcm_rxfail(bus, false, false); - goto done; - } - - if ((len - doff) > bus->drvr->maxctl) { - brcmf_dbg(ERROR, "%d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n", - len, len - doff, bus->drvr->maxctl); - bus->drvr->rx_errors++; - bus->rx_toolong++; - brcmf_sdbrcm_rxfail(bus, false, false); - goto done; - } - - /* Read remainder of frame body into the rxctl buffer */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, - bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, (bus->rxctl + BRCMF_FIRSTREAD), rdlen, - NULL); - bus->f2rxdata++; - - /* Control frame failures need retransmission */ - if (sdret < 0) { - brcmf_dbg(ERROR, "read %d control bytes failed: %d\n", - rdlen, sdret); - bus->rxc_errors++; - brcmf_sdbrcm_rxfail(bus, true, true); - goto done; - } - -gotpkt: - -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "RxCtrl:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len); - } -#endif - - /* Point to valid data and indicate its length */ - bus->rxctl += doff; - bus->rxlen = len - doff; - -done: - /* Awake any waiters */ - brcmf_sdbrcm_dcmd_resp_wake(bus); -} - -/* Pad read to blocksize for efficiency */ -static void brcmf_pad(struct brcmf_bus *bus, u16 *pad, u16 *rdlen) -{ - if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) { - *pad = bus->blocksize - (*rdlen % bus->blocksize); - if (*pad <= bus->roundup && *pad < bus->blocksize && - *rdlen + *pad + BRCMF_FIRSTREAD < MAX_RX_DATASZ) - *rdlen += *pad; - } else if (*rdlen % BRCMF_SDALIGN) { - *rdlen += BRCMF_SDALIGN - (*rdlen % BRCMF_SDALIGN); - } -} - -static void -brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, - struct sk_buff **pkt, u8 **rxbuf) -{ - int sdret; /* Return code from calls */ - - *pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN); - if (*pkt == NULL) - return; - - pkt_align(*pkt, rdlen, BRCMF_SDALIGN); - *rxbuf = (u8 *) ((*pkt)->data); - /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, - *rxbuf, rdlen, *pkt); - bus->f2rxdata++; - - if (sdret < 0) { - brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n", - rdlen, sdret); - brcmu_pkt_buf_free_skb(*pkt); - bus->drvr->rx_errors++; - /* Force retry w/normal header read. - * Don't attempt NAK for - * gSPI - */ - brcmf_sdbrcm_rxfail(bus, true, true); - *pkt = NULL; - } -} - -/* Checks the header */ -static int -brcmf_check_rxbuf(struct brcmf_bus *bus, struct sk_buff *pkt, u8 *rxbuf, - u8 rxseq, u16 nextlen, u16 *len) -{ - u16 check; - bool len_consistent; /* Result of comparing readahead len and - len from hw-hdr */ - - memcpy(bus->rxhdr, rxbuf, SDPCM_HDRLEN); - - /* Extract hardware header fields */ - *len = get_unaligned_le16(bus->rxhdr); - check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); - - /* All zeros means readahead info was bad */ - if (!(*len | check)) { - brcmf_dbg(INFO, "(nextlen): read zeros in HW header???\n"); - goto fail; - } - - /* Validate check bytes */ - if ((u16)~(*len ^ check)) { - brcmf_dbg(ERROR, "(nextlen): HW hdr error: nextlen/len/check 0x%04x/0x%04x/0x%04x\n", - nextlen, *len, check); - bus->rx_badhdr++; - brcmf_sdbrcm_rxfail(bus, false, false); - goto fail; - } - - /* Validate frame length */ - if (*len < SDPCM_HDRLEN) { - brcmf_dbg(ERROR, "(nextlen): HW hdr length invalid: %d\n", - *len); - goto fail; - } - - /* Check for consistency with readahead info */ - len_consistent = (nextlen != (roundup(*len, 16) >> 4)); - if (len_consistent) { - /* Mismatch, force retry w/normal - header (may be >4K) */ - brcmf_dbg(ERROR, "(nextlen): mismatch, nextlen %d len %d rnd %d; expected rxseq %d\n", - nextlen, *len, roundup(*len, 16), - rxseq); - brcmf_sdbrcm_rxfail(bus, true, true); - goto fail; - } - - return 0; - -fail: - brcmf_sdbrcm_pktfree2(bus, pkt); - return -EINVAL; -} - -/* Return true if there may be more frames to read */ -static uint -brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) -{ - u16 len, check; /* Extracted hardware header fields */ - u8 chan, seq, doff; /* Extracted software header fields */ - u8 fcbits; /* Extracted fcbits from software header */ - - struct sk_buff *pkt; /* Packet for event or data frames */ - u16 pad; /* Number of pad bytes to read */ - u16 rdlen; /* Total number of bytes to read */ - u8 rxseq; /* Next sequence number to expect */ - uint rxleft = 0; /* Remaining number of frames allowed */ - int sdret; /* Return code from calls */ - u8 txmax; /* Maximum tx sequence offered */ - u8 *rxbuf; - int ifidx = 0; - uint rxcount = 0; /* Total frames read */ - - brcmf_dbg(TRACE, "Enter\n"); - - /* Not finished unless we encounter no more frames indication */ - *finished = false; - - for (rxseq = bus->rx_seq, rxleft = maxframes; - !bus->rxskip && rxleft && bus->drvr->busstate != BRCMF_BUS_DOWN; - rxseq++, rxleft--) { - - /* Handle glomming separately */ - if (bus->glom || bus->glomd) { - u8 cnt; - brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", - bus->glomd, bus->glom); - cnt = brcmf_sdbrcm_rxglom(bus, rxseq); - brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); - rxseq += cnt - 1; - rxleft = (rxleft > cnt) ? (rxleft - cnt) : 1; - continue; - } - - /* Try doing single read if we can */ - if (bus->nextlen) { - u16 nextlen = bus->nextlen; - bus->nextlen = 0; - - rdlen = len = nextlen << 4; - brcmf_pad(bus, &pad, &rdlen); - - /* - * After the frame is received we have to - * distinguish whether it is data - * or non-data frame. - */ - brcmf_alloc_pkt_and_read(bus, rdlen, &pkt, &rxbuf); - if (pkt == NULL) { - /* Give up on data, request rtx of events */ - brcmf_dbg(ERROR, "(nextlen): brcmf_alloc_pkt_and_read failed: len %d rdlen %d expected rxseq %d\n", - len, rdlen, rxseq); - continue; - } - - if (brcmf_check_rxbuf(bus, pkt, rxbuf, rxseq, nextlen, - &len) < 0) - continue; - - /* Extract software header fields */ - chan = SDPCM_PACKET_CHANNEL( - &bus->rxhdr[SDPCM_FRAMETAG_LEN]); - seq = SDPCM_PACKET_SEQUENCE( - &bus->rxhdr[SDPCM_FRAMETAG_LEN]); - doff = SDPCM_DOFFSET_VALUE( - &bus->rxhdr[SDPCM_FRAMETAG_LEN]); - txmax = SDPCM_WINDOW_VALUE( - &bus->rxhdr[SDPCM_FRAMETAG_LEN]); - - bus->nextlen = - bus->rxhdr[SDPCM_FRAMETAG_LEN + - SDPCM_NEXTLEN_OFFSET]; - if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - brcmf_dbg(INFO, "(nextlen): got frame w/nextlen too large (%d), seq %d\n", - bus->nextlen, seq); - bus->nextlen = 0; - } - - bus->drvr->rx_readahead_cnt++; - - /* Handle Flow Control */ - fcbits = SDPCM_FCMASK_VALUE( - &bus->rxhdr[SDPCM_FRAMETAG_LEN]); - - if (bus->flowcontrol != fcbits) { - if (~bus->flowcontrol & fcbits) - bus->fc_xoff++; - - if (bus->flowcontrol & ~fcbits) - bus->fc_xon++; - - bus->fc_rcvd++; - bus->flowcontrol = fcbits; - } - - /* Check and update sequence number */ - if (rxseq != seq) { - brcmf_dbg(INFO, "(nextlen): rx_seq %d, expected %d\n", - seq, rxseq); - bus->rx_badseq++; - rxseq = seq; - } - - /* Check window for sanity */ - if ((u8) (txmax - bus->tx_seq) > 0x40) { - brcmf_dbg(ERROR, "got unlikely tx max %d with tx_seq %d\n", - txmax, bus->tx_seq); - txmax = bus->tx_seq + 2; - } - bus->tx_max = txmax; - -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - rxbuf, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "RxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - bus->rxhdr, SDPCM_HDRLEN); - } -#endif - - if (chan == SDPCM_CONTROL_CHANNEL) { - brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n", - seq); - /* Force retry w/normal header read */ - bus->nextlen = 0; - brcmf_sdbrcm_rxfail(bus, false, true); - brcmf_sdbrcm_pktfree2(bus, pkt); - continue; - } - - /* Validate data offset */ - if ((doff < SDPCM_HDRLEN) || (doff > len)) { - brcmf_dbg(ERROR, "(nextlen): bad data offset %d: HW len %d min %d\n", - doff, len, SDPCM_HDRLEN); - brcmf_sdbrcm_rxfail(bus, false, false); - brcmf_sdbrcm_pktfree2(bus, pkt); - continue; - } - - /* All done with this one -- now deliver the packet */ - goto deliver; - } - - /* Read frame header (hardware and software) */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, bus->rxhdr, - BRCMF_FIRSTREAD, NULL); - bus->f2rxhdrs++; - - if (sdret < 0) { - brcmf_dbg(ERROR, "RXHEADER FAILED: %d\n", sdret); - bus->rx_hdrfail++; - brcmf_sdbrcm_rxfail(bus, true, true); - continue; - } -#ifdef BCMDBG - if (BRCMF_BYTES_ON() || BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "RxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - bus->rxhdr, SDPCM_HDRLEN); - } -#endif - - /* Extract hardware header fields */ - len = get_unaligned_le16(bus->rxhdr); - check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); - - /* All zeros means no more frames */ - if (!(len | check)) { - *finished = true; - break; - } - - /* Validate check bytes */ - if ((u16) ~(len ^ check)) { - brcmf_dbg(ERROR, "HW hdr err: len/check 0x%04x/0x%04x\n", - len, check); - bus->rx_badhdr++; - brcmf_sdbrcm_rxfail(bus, false, false); - continue; - } - - /* Validate frame length */ - if (len < SDPCM_HDRLEN) { - brcmf_dbg(ERROR, "HW hdr length invalid: %d\n", len); - continue; - } - - /* Extract software header fields */ - chan = SDPCM_PACKET_CHANNEL(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); - seq = SDPCM_PACKET_SEQUENCE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); - doff = SDPCM_DOFFSET_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); - txmax = SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); - - /* Validate data offset */ - if ((doff < SDPCM_HDRLEN) || (doff > len)) { - brcmf_dbg(ERROR, "Bad data offset %d: HW len %d, min %d seq %d\n", - doff, len, SDPCM_HDRLEN, seq); - bus->rx_badhdr++; - brcmf_sdbrcm_rxfail(bus, false, false); - continue; - } - - /* Save the readahead length if there is one */ - bus->nextlen = - bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; - if ((bus->nextlen << 4) > MAX_RX_DATASZ) { - brcmf_dbg(INFO, "(nextlen): got frame w/nextlen too large (%d), seq %d\n", - bus->nextlen, seq); - bus->nextlen = 0; - } - - /* Handle Flow Control */ - fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); - - if (bus->flowcontrol != fcbits) { - if (~bus->flowcontrol & fcbits) - bus->fc_xoff++; - - if (bus->flowcontrol & ~fcbits) - bus->fc_xon++; - - bus->fc_rcvd++; - bus->flowcontrol = fcbits; - } - - /* Check and update sequence number */ - if (rxseq != seq) { - brcmf_dbg(INFO, "rx_seq %d, expected %d\n", seq, rxseq); - bus->rx_badseq++; - rxseq = seq; - } - - /* Check window for sanity */ - if ((u8) (txmax - bus->tx_seq) > 0x40) { - brcmf_dbg(ERROR, "unlikely tx max %d with tx_seq %d\n", - txmax, bus->tx_seq); - txmax = bus->tx_seq + 2; - } - bus->tx_max = txmax; - - /* Call a separate function for control frames */ - if (chan == SDPCM_CONTROL_CHANNEL) { - brcmf_sdbrcm_read_control(bus, bus->rxhdr, len, doff); - continue; - } - - /* precondition: chan is either SDPCM_DATA_CHANNEL, - SDPCM_EVENT_CHANNEL, SDPCM_TEST_CHANNEL or - SDPCM_GLOM_CHANNEL */ - - /* Length to read */ - rdlen = (len > BRCMF_FIRSTREAD) ? (len - BRCMF_FIRSTREAD) : 0; - - /* May pad read to blocksize for efficiency */ - if (bus->roundup && bus->blocksize && - (rdlen > bus->blocksize)) { - pad = bus->blocksize - (rdlen % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize) && - ((rdlen + pad + BRCMF_FIRSTREAD) < MAX_RX_DATASZ)) - rdlen += pad; - } else if (rdlen % BRCMF_SDALIGN) { - rdlen += BRCMF_SDALIGN - (rdlen % BRCMF_SDALIGN); - } - - /* Satisfy length-alignment requirements */ - if (rdlen & (ALIGNMENT - 1)) - rdlen = roundup(rdlen, ALIGNMENT); - - if ((rdlen + BRCMF_FIRSTREAD) > MAX_RX_DATASZ) { - /* Too long -- skip this frame */ - brcmf_dbg(ERROR, "too long: len %d rdlen %d\n", - len, rdlen); - bus->drvr->rx_errors++; - bus->rx_toolong++; - brcmf_sdbrcm_rxfail(bus, false, false); - continue; - } - - pkt = brcmu_pkt_buf_get_skb(rdlen + - BRCMF_FIRSTREAD + BRCMF_SDALIGN); - if (!pkt) { - /* Give up on data, request rtx of events */ - brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: rdlen %d chan %d\n", - rdlen, chan); - bus->drvr->rx_dropped++; - brcmf_sdbrcm_rxfail(bus, false, RETRYCHAN(chan)); - continue; - } - - /* Leave room for what we already read, and align remainder */ - skb_pull(pkt, BRCMF_FIRSTREAD); - pkt_align(pkt, rdlen, BRCMF_SDALIGN); - - /* Read the remaining frame data */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), - rdlen, pkt); - bus->f2rxdata++; - - if (sdret < 0) { - brcmf_dbg(ERROR, "read %d %s bytes failed: %d\n", rdlen, - ((chan == SDPCM_EVENT_CHANNEL) ? "event" - : ((chan == SDPCM_DATA_CHANNEL) ? "data" - : "test")), sdret); - brcmu_pkt_buf_free_skb(pkt); - bus->drvr->rx_errors++; - brcmf_sdbrcm_rxfail(bus, true, RETRYCHAN(chan)); - continue; - } - - /* Copy the already-read portion */ - skb_push(pkt, BRCMF_FIRSTREAD); - memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); - -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pkt->data, len); - } -#endif - -deliver: - /* Save superframe descriptor and allocate packet frame */ - if (chan == SDPCM_GLOM_CHANNEL) { - if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { - brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", - len); -#ifdef BCMDBG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "Glom Data:\n"); - print_hex_dump_bytes("", - DUMP_PREFIX_OFFSET, - pkt->data, len); - } -#endif - __skb_trim(pkt, len); - skb_pull(pkt, SDPCM_HDRLEN); - bus->glomd = pkt; - } else { - brcmf_dbg(ERROR, "%s: glom superframe w/o " - "descriptor!\n", __func__); - brcmf_sdbrcm_rxfail(bus, false, false); - } - continue; - } - - /* Fill in packet len and prio, deliver upward */ - __skb_trim(pkt, len); - skb_pull(pkt, doff); - - if (pkt->len == 0) { - brcmu_pkt_buf_free_skb(pkt); - continue; - } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pkt) != 0) { - brcmf_dbg(ERROR, "rx protocol error\n"); - brcmu_pkt_buf_free_skb(pkt); - bus->drvr->rx_errors++; - continue; - } - - /* Unlock during rx call */ - up(&bus->sdsem); - brcmf_rx_frame(bus->drvr, ifidx, pkt, 1); - down(&bus->sdsem); - } - rxcount = maxframes - rxleft; -#ifdef BCMDBG - /* Message if we hit the limit */ - if (!rxleft) - brcmf_dbg(DATA, "hit rx limit of %d frames\n", - maxframes); - else -#endif /* BCMDBG */ - brcmf_dbg(DATA, "processed %d frames\n", rxcount); - /* Back off rxseq if awaiting rtx, update rx_seq */ - if (bus->rxskip) - rxseq--; - bus->rx_seq = rxseq; - - return rxcount; -} - -static int -brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt) -{ - return brcmf_sdcard_send_buf - (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt); -} - -static void -brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) -{ - up(&bus->sdsem); - wait_event_interruptible_timeout(bus->ctrl_wait, - (*lockvar == false), HZ * 2); - down(&bus->sdsem); - return; -} - -static void -brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus) -{ - if (waitqueue_active(&bus->ctrl_wait)) - wake_up_interruptible(&bus->ctrl_wait); - return; -} - -/* Writes a HW/SW header into the packet and sends it. */ -/* Assumes: (a) header space already there, (b) caller holds lock */ -static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, - uint chan, bool free_pkt) -{ - int ret; - u8 *frame; - u16 len, pad = 0; - u32 swheader; - struct sk_buff *new; - int i; - - brcmf_dbg(TRACE, "Enter\n"); - - frame = (u8 *) (pkt->data); - - /* Add alignment padding, allocate new packet if needed */ - pad = ((unsigned long)frame % BRCMF_SDALIGN); - if (pad) { - if (skb_headroom(pkt) < pad) { - brcmf_dbg(INFO, "insufficient headroom %d for %d pad\n", - skb_headroom(pkt), pad); - bus->drvr->tx_realloc++; - new = brcmu_pkt_buf_get_skb(pkt->len + BRCMF_SDALIGN); - if (!new) { - brcmf_dbg(ERROR, "couldn't allocate new %d-byte packet\n", - pkt->len + BRCMF_SDALIGN); - ret = -ENOMEM; - goto done; - } - - pkt_align(new, pkt->len, BRCMF_SDALIGN); - memcpy(new->data, pkt->data, pkt->len); - if (free_pkt) - brcmu_pkt_buf_free_skb(pkt); - /* free the pkt if canned one is not used */ - free_pkt = true; - pkt = new; - frame = (u8 *) (pkt->data); - /* precondition: (frame % BRCMF_SDALIGN) == 0) */ - pad = 0; - } else { - skb_push(pkt, pad); - frame = (u8 *) (pkt->data); - /* precondition: pad + SDPCM_HDRLEN <= pkt->len */ - memset(frame, 0, pad + SDPCM_HDRLEN); - } - } - /* precondition: pad < BRCMF_SDALIGN */ - - /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - len = (u16) (pkt->len); - *(__le16 *) frame = cpu_to_le16(len); - *(((__le16 *) frame) + 1) = cpu_to_le16(~len); - - /* Software tag: channel, sequence number, data offset */ - swheader = - ((chan << SDPCM_CHANNEL_SHIFT) & SDPCM_CHANNEL_MASK) | bus->tx_seq | - (((pad + - SDPCM_HDRLEN) << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); - - put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); - put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); - -#ifdef BCMDBG - tx_packets[pkt->priority]++; - if (BRCMF_BYTES_ON() && - (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || - (BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } -#endif - - /* Raise len to next SDIO block to eliminate tail command */ - if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { - u16 pad = bus->blocksize - (len % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize)) - len += pad; - } else if (len % BRCMF_SDALIGN) { - len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); - } - - /* Some controllers have trouble with odd bytes -- round to even */ - if (len & (ALIGNMENT - 1)) - len = roundup(len, ALIGNMENT); - - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, - len, pkt); - bus->f2txdata++; - - if (ret < 0) { - /* On failure, abort the command and terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, - NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } - - } - if (ret == 0) - bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - -done: - /* restore pkt buffer pointer before calling tx complete routine */ - skb_pull(pkt, SDPCM_HDRLEN + pad); - up(&bus->sdsem); - brcmf_txcomplete(bus->drvr, pkt, ret != 0); - down(&bus->sdsem); - - if (free_pkt) - brcmu_pkt_buf_free_skb(pkt); - - return ret; -} - -static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) -{ - struct sk_buff *pkt; - u32 intstatus = 0; - uint retries = 0; - int ret = 0, prec_out; - uint cnt = 0; - uint datalen; - u8 tx_prec_map; - - struct brcmf_pub *drvr = bus->drvr; - - brcmf_dbg(TRACE, "Enter\n"); - - tx_prec_map = ~bus->flowcontrol; - - /* Send frames until the limit or some other event */ - for (cnt = 0; (cnt < maxframes) && data_ok(bus); cnt++) { - spin_lock_bh(&bus->txqlock); - pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); - if (pkt == NULL) { - spin_unlock_bh(&bus->txqlock); - break; - } - spin_unlock_bh(&bus->txqlock); - datalen = pkt->len - SDPCM_HDRLEN; - - ret = brcmf_sdbrcm_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true); - if (ret) - bus->drvr->tx_errors++; - else - bus->drvr->dstats.tx_bytes += datalen; - - /* In poll mode, need to check for other events */ - if (!bus->intr && cnt) { - /* Check device status, signal pending interrupt */ - r_sdreg32(bus, &intstatus, - offsetof(struct sdpcmd_regs, intstatus), - &retries); - bus->f2txdata++; - if (brcmf_sdcard_regfail(bus->sdiodev)) - break; - if (intstatus & bus->hostintmask) - bus->ipend = true; - } - } - - /* Deflow-control stack if needed */ - if (drvr->up && (drvr->busstate == BRCMF_BUS_DATA) && - drvr->txoff && (pktq_len(&bus->txq) < TXLOW)) - brcmf_txflowcontrol(drvr, 0, OFF); - - return cnt; -} - -static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) -{ - u32 intstatus, newstatus = 0; - uint retries = 0; - uint rxlimit = bus->rxbound; /* Rx frames to read before resched */ - uint txlimit = bus->txbound; /* Tx frames to send before resched */ - uint framecnt = 0; /* Temporary counter of tx/rx frames */ - bool rxdone = true; /* Flag for no more read data */ - bool resched = false; /* Flag indicating resched wanted */ - - brcmf_dbg(TRACE, "Enter\n"); - - /* Start with leftover status bits */ - intstatus = bus->intstatus; - - down(&bus->sdsem); - - /* If waiting for HTAVAIL, check status */ - if (bus->clkstate == CLK_PENDING) { - int err; - u8 clkctl, devctl = 0; - -#ifdef BCMDBG - /* Check for inconsistent device control */ - devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, &err); - if (err) { - brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); - bus->drvr->busstate = BRCMF_BUS_DOWN; - } -#endif /* BCMDBG */ - - /* Read CSR, if clock on switch to AVAIL, else ignore */ - clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (err) { - brcmf_dbg(ERROR, "error reading CSR: %d\n", - err); - bus->drvr->busstate = BRCMF_BUS_DOWN; - } - - brcmf_dbg(INFO, "DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", - devctl, clkctl); - - if (SBSDIO_HTAV(clkctl)) { - devctl = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, &err); - if (err) { - brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", - err); - bus->drvr->busstate = BRCMF_BUS_DOWN; - } - devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, devctl, &err); - if (err) { - brcmf_dbg(ERROR, "error writing DEVCTL: %d\n", - err); - bus->drvr->busstate = BRCMF_BUS_DOWN; - } - bus->clkstate = CLK_AVAIL; - } else { - goto clkwait; - } - } - - bus_wake(bus); - - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, true); - if (bus->clkstate == CLK_PENDING) - goto clkwait; - - /* Pending interrupt indicates new device status */ - if (bus->ipend) { - bus->ipend = false; - r_sdreg32(bus, &newstatus, - offsetof(struct sdpcmd_regs, intstatus), &retries); - bus->f1regdata++; - if (brcmf_sdcard_regfail(bus->sdiodev)) - newstatus = 0; - newstatus &= bus->hostintmask; - bus->fcstate = !!(newstatus & I_HMB_FC_STATE); - if (newstatus) { - w_sdreg32(bus, newstatus, - offsetof(struct sdpcmd_regs, intstatus), - &retries); - bus->f1regdata++; - } - } - - /* Merge new bits with previous */ - intstatus |= newstatus; - bus->intstatus = 0; - - /* Handle flow-control change: read new state in case our ack - * crossed another change interrupt. If change still set, assume - * FC ON for safety, let next loop through do the debounce. - */ - if (intstatus & I_HMB_FC_CHANGE) { - intstatus &= ~I_HMB_FC_CHANGE; - w_sdreg32(bus, I_HMB_FC_CHANGE, - offsetof(struct sdpcmd_regs, intstatus), &retries); - - r_sdreg32(bus, &newstatus, - offsetof(struct sdpcmd_regs, intstatus), &retries); - bus->f1regdata += 2; - bus->fcstate = - !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE)); - intstatus |= (newstatus & bus->hostintmask); - } - - /* Handle host mailbox indication */ - if (intstatus & I_HMB_HOST_INT) { - intstatus &= ~I_HMB_HOST_INT; - intstatus |= brcmf_sdbrcm_hostmail(bus); - } - - /* Generally don't ask for these, can get CRC errors... */ - if (intstatus & I_WR_OOSYNC) { - brcmf_dbg(ERROR, "Dongle reports WR_OOSYNC\n"); - intstatus &= ~I_WR_OOSYNC; - } - - if (intstatus & I_RD_OOSYNC) { - brcmf_dbg(ERROR, "Dongle reports RD_OOSYNC\n"); - intstatus &= ~I_RD_OOSYNC; - } - - if (intstatus & I_SBINT) { - brcmf_dbg(ERROR, "Dongle reports SBINT\n"); - intstatus &= ~I_SBINT; - } - - /* Would be active due to wake-wlan in gSPI */ - if (intstatus & I_CHIPACTIVE) { - brcmf_dbg(INFO, "Dongle reports CHIPACTIVE\n"); - intstatus &= ~I_CHIPACTIVE; - } - - /* Ignore frame indications if rxskip is set */ - if (bus->rxskip) - intstatus &= ~I_HMB_FRAME_IND; - - /* On frame indication, read available frames */ - if (PKT_AVAILABLE()) { - framecnt = brcmf_sdbrcm_readframes(bus, rxlimit, &rxdone); - if (rxdone || bus->rxskip) - intstatus &= ~I_HMB_FRAME_IND; - rxlimit -= min(framecnt, rxlimit); - } - - /* Keep still-pending events for next scheduling */ - bus->intstatus = intstatus; - -clkwait: - if (data_ok(bus) && bus->ctrl_frame_stat && - (bus->clkstate == CLK_AVAIL)) { - int ret, i; - - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, - (u32) bus->ctrl_frame_len, NULL); - - if (ret < 0) { - /* On failure, abort the command and - terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, - NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if ((hi == 0) && (lo == 0)) - break; - } - - } - if (ret == 0) - bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - - brcmf_dbg(INFO, "Return_dpc value is : %d\n", ret); - bus->ctrl_frame_stat = false; - brcmf_sdbrcm_wait_event_wakeup(bus); - } - /* Send queued frames (limit 1 if rx may still be pending) */ - else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate && - brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit - && data_ok(bus)) { - framecnt = rxdone ? txlimit : min(txlimit, bus->txminmax); - framecnt = brcmf_sdbrcm_sendfromq(bus, framecnt); - txlimit -= framecnt; - } - - /* Resched if events or tx frames are pending, - else await next interrupt */ - /* On failed register access, all bets are off: - no resched or interrupts */ - if ((bus->drvr->busstate == BRCMF_BUS_DOWN) || - brcmf_sdcard_regfail(bus->sdiodev)) { - brcmf_dbg(ERROR, "failed backplane access over SDIO, halting operation %d\n", - brcmf_sdcard_regfail(bus->sdiodev)); - bus->drvr->busstate = BRCMF_BUS_DOWN; - bus->intstatus = 0; - } else if (bus->clkstate == CLK_PENDING) { - brcmf_dbg(INFO, "rescheduled due to CLK_PENDING awaiting I_CHIPACTIVE interrupt\n"); - resched = true; - } else if (bus->intstatus || bus->ipend || - (!bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) - && data_ok(bus)) || PKT_AVAILABLE()) { - resched = true; - } - - bus->dpc_sched = resched; - - /* If we're done for now, turn off clock request. */ - if ((bus->clkstate != CLK_PENDING) - && bus->idletime == BRCMF_IDLE_IMMEDIATE) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - } - - up(&bus->sdsem); - - return resched; -} - -static int brcmf_sdbrcm_dpc_thread(void *data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) data; - - allow_signal(SIGTERM); - /* Run until signal received */ - while (1) { - if (kthread_should_stop()) - break; - if (!wait_for_completion_interruptible(&bus->dpc_wait)) { - /* Call bus dpc unless it indicated down - (then clean stop) */ - if (bus->drvr->busstate != BRCMF_BUS_DOWN) { - if (brcmf_sdbrcm_dpc(bus)) - complete(&bus->dpc_wait); - } else { - /* after stopping the bus, exit thread */ - brcmf_sdbrcm_bus_stop(bus); - bus->dpc_tsk = NULL; - break; - } - } else - break; - } - return 0; -} - -int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) -{ - int ret = -EBADE; - uint datalen, prec; - - brcmf_dbg(TRACE, "Enter\n"); - - datalen = pkt->len; - - /* Add space for the header */ - skb_push(pkt, SDPCM_HDRLEN); - /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ - - prec = prio2prec((pkt->priority & PRIOMASK)); - - /* Check for existing queue, current flow-control, - pending event, or pending clock */ - brcmf_dbg(TRACE, "deferring pktq len %d\n", pktq_len(&bus->txq)); - bus->fcqueued++; - - /* Priority based enq */ - spin_lock_bh(&bus->txqlock); - if (brcmf_c_prec_enq(bus->drvr, &bus->txq, pkt, prec) == false) { - skb_pull(pkt, SDPCM_HDRLEN); - brcmf_txcomplete(bus->drvr, pkt, false); - brcmu_pkt_buf_free_skb(pkt); - brcmf_dbg(ERROR, "out of bus->txq !!!\n"); - ret = -ENOSR; - } else { - ret = 0; - } - spin_unlock_bh(&bus->txqlock); - - if (pktq_len(&bus->txq) >= TXHI) - brcmf_txflowcontrol(bus->drvr, 0, ON); - -#ifdef BCMDBG - if (pktq_plen(&bus->txq, prec) > qcount[prec]) - qcount[prec] = pktq_plen(&bus->txq, prec); -#endif - /* Schedule DPC if needed to send queued packet(s) */ - if (!bus->dpc_sched) { - bus->dpc_sched = true; - if (bus->dpc_tsk) - complete(&bus->dpc_wait); - } - - return ret; -} - -static int -brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, - uint size) -{ - int bcmerror = 0; - u32 sdaddr; - uint dsize; - - /* Determine initial transfer parameters */ - sdaddr = address & SBSDIO_SB_OFT_ADDR_MASK; - if ((sdaddr + size) & SBSDIO_SBWINDOW_MASK) - dsize = (SBSDIO_SB_OFT_ADDR_LIMIT - sdaddr); - else - dsize = size; - - /* Set the backplane window to include the start address */ - bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, address); - if (bcmerror) { - brcmf_dbg(ERROR, "window change failed\n"); - goto xfer_done; - } - - /* Do the transfer(s) */ - while (size) { - brcmf_dbg(INFO, "%s %d bytes at offset 0x%08x in window 0x%08x\n", - write ? "write" : "read", dsize, - sdaddr, address & SBSDIO_SBWINDOW_MASK); - bcmerror = brcmf_sdcard_rwdata(bus->sdiodev, write, - sdaddr, data, dsize); - if (bcmerror) { - brcmf_dbg(ERROR, "membytes transfer failed\n"); - break; - } - - /* Adjust for next transfer (if any) */ - size -= dsize; - if (size) { - data += dsize; - address += dsize; - bcmerror = brcmf_sdcard_set_sbaddr_window(bus->sdiodev, - address); - if (bcmerror) { - brcmf_dbg(ERROR, "window change failed\n"); - break; - } - sdaddr = 0; - dsize = min_t(uint, SBSDIO_SB_OFT_ADDR_LIMIT, size); - } - } - -xfer_done: - /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, bus->sdiodev->sbwad)) - brcmf_dbg(ERROR, "FAILED to set window back to 0x%x\n", - bus->sdiodev->sbwad); - - return bcmerror; -} - -#ifdef BCMDBG -#define CONSOLE_LINE_MAX 192 - -static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) -{ - struct brcmf_console *c = &bus->console; - u8 line[CONSOLE_LINE_MAX], ch; - u32 n, idx, addr; - int rv; - - /* Don't do anything until FWREADY updates console address */ - if (bus->console_addr == 0) - return 0; - - /* Read console log struct */ - addr = bus->console_addr + offsetof(struct rte_console, log_le); - rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&c->log_le, - sizeof(c->log_le)); - if (rv < 0) - return rv; - - /* Allocate console buffer (one time only) */ - if (c->buf == NULL) { - c->bufsize = le32_to_cpu(c->log_le.buf_size); - c->buf = kmalloc(c->bufsize, GFP_ATOMIC); - if (c->buf == NULL) - return -ENOMEM; - } - - idx = le32_to_cpu(c->log_le.idx); - - /* Protect against corrupt value */ - if (idx > c->bufsize) - return -EBADE; - - /* Skip reading the console buffer if the index pointer - has not moved */ - if (idx == c->last) - return 0; - - /* Read the console buffer */ - addr = le32_to_cpu(c->log_le.buf); - rv = brcmf_sdbrcm_membytes(bus, false, addr, c->buf, c->bufsize); - if (rv < 0) - return rv; - - while (c->last != idx) { - for (n = 0; n < CONSOLE_LINE_MAX - 2; n++) { - if (c->last == idx) { - /* This would output a partial line. - * Instead, back up - * the buffer pointer and output this - * line next time around. - */ - if (c->last >= n) - c->last -= n; - else - c->last = c->bufsize - n; - goto break2; - } - ch = c->buf[c->last]; - c->last = (c->last + 1) % c->bufsize; - if (ch == '\n') - break; - line[n] = ch; - } - - if (n > 0) { - if (line[n - 1] == '\r') - n--; - line[n] = 0; - printk(KERN_DEBUG "CONSOLE: %s\n", line); - } - } -break2: - - return 0; -} -#endif /* BCMDBG */ - -static int brcmf_tx_frame(struct brcmf_bus *bus, u8 *frame, u16 len) -{ - int i; - int ret; - - bus->ctrl_frame_stat = false; - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, len, NULL); - - if (ret < 0) { - /* On failure, abort the command and terminate the frame */ - brcmf_dbg(INFO, "sdio error %d, abort command and terminate frame\n", - ret); - bus->tx_sderrs++; - - brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_FRAMECTRL, - SFC_WF_TERM, NULL); - bus->f1regdata++; - - for (i = 0; i < 3; i++) { - u8 hi, lo; - hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCHI, - NULL); - lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_WFRAMEBCLO, - NULL); - bus->f1regdata += 2; - if (hi == 0 && lo == 0) - break; - } - return ret; - } - - bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - - return ret; -} - -int -brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) -{ - u8 *frame; - u16 len; - u32 swheader; - uint retries = 0; - u8 doff = 0; - int ret = -1; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Back the pointer to make a room for bus header */ - frame = msg - SDPCM_HDRLEN; - len = (msglen += SDPCM_HDRLEN); - - /* Add alignment padding (optional for ctl frames) */ - doff = ((unsigned long)frame % BRCMF_SDALIGN); - if (doff) { - frame -= doff; - len += doff; - msglen += doff; - memset(frame, 0, doff + SDPCM_HDRLEN); - } - /* precondition: doff < BRCMF_SDALIGN */ - doff += SDPCM_HDRLEN; - - /* Round send length to next SDIO block */ - if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { - u16 pad = bus->blocksize - (len % bus->blocksize); - if ((pad <= bus->roundup) && (pad < bus->blocksize)) - len += pad; - } else if (len % BRCMF_SDALIGN) { - len += BRCMF_SDALIGN - (len % BRCMF_SDALIGN); - } - - /* Satisfy length-alignment requirements */ - if (len & (ALIGNMENT - 1)) - len = roundup(len, ALIGNMENT); - - /* precondition: IS_ALIGNED((unsigned long)frame, 2) */ - - /* Need to lock here to protect txseq and SDIO tx calls */ - down(&bus->sdsem); - - bus_wake(bus); - - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - *(__le16 *) frame = cpu_to_le16((u16) msglen); - *(((__le16 *) frame) + 1) = cpu_to_le16(~msglen); - - /* Software tag: channel, sequence number, data offset */ - swheader = - ((SDPCM_CONTROL_CHANNEL << SDPCM_CHANNEL_SHIFT) & - SDPCM_CHANNEL_MASK) - | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & - SDPCM_DOFFSET_MASK); - put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); - put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); - - if (!data_ok(bus)) { - brcmf_dbg(INFO, "No bus credit bus->tx_max %d, bus->tx_seq %d\n", - bus->tx_max, bus->tx_seq); - bus->ctrl_frame_stat = true; - /* Send from dpc */ - bus->ctrl_frame_buf = frame; - bus->ctrl_frame_len = len; - - brcmf_sdbrcm_wait_for_event(bus, &bus->ctrl_frame_stat); - - if (bus->ctrl_frame_stat == false) { - brcmf_dbg(INFO, "ctrl_frame_stat == false\n"); - ret = 0; - } else { - brcmf_dbg(INFO, "ctrl_frame_stat == true\n"); - ret = -1; - } - } - - if (ret == -1) { -#ifdef BCMDBG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } -#endif - - do { - ret = brcmf_tx_frame(bus, frame, len); - } while (ret < 0 && retries++ < TXRETRIES); - } - - if ((bus->idletime == BRCMF_IDLE_IMMEDIATE) && !bus->dpc_sched) { - bus->activity = false; - brcmf_sdbrcm_clkctl(bus, CLK_NONE, true); - } - - up(&bus->sdsem); - - if (ret) - bus->drvr->tx_ctlerrs++; - else - bus->drvr->tx_ctlpkts++; - - return ret ? -EIO : 0; -} - -int -brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) -{ - int timeleft; - uint rxlen = 0; - bool pending; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Wait until control frame is available */ - timeleft = brcmf_sdbrcm_dcmd_resp_wait(bus, &bus->rxlen, &pending); - - down(&bus->sdsem); - rxlen = bus->rxlen; - memcpy(msg, bus->rxctl, min(msglen, rxlen)); - bus->rxlen = 0; - up(&bus->sdsem); - - if (rxlen) { - brcmf_dbg(CTL, "resumed on rxctl frame, got %d expected %d\n", - rxlen, msglen); - } else if (timeleft == 0) { - brcmf_dbg(ERROR, "resumed on timeout\n"); - } else if (pending == true) { - brcmf_dbg(CTL, "cancelled\n"); - return -ERESTARTSYS; - } else { - brcmf_dbg(CTL, "resumed for unknown reason?\n"); - } - - if (rxlen) - bus->drvr->rx_ctlpkts++; - else - bus->drvr->rx_ctlerrs++; - - return rxlen ? (int)rxlen : -ETIMEDOUT; -} - -static int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) -{ - int bcmerror = 0; - - brcmf_dbg(TRACE, "Enter\n"); - - /* Basic sanity checks */ - if (bus->drvr->up) { - bcmerror = -EISCONN; - goto err; - } - if (!len) { - bcmerror = -EOVERFLOW; - goto err; - } - - /* Free the old ones and replace with passed variables */ - kfree(bus->vars); - - bus->vars = kmalloc(len, GFP_ATOMIC); - bus->varsz = bus->vars ? len : 0; - if (bus->vars == NULL) { - bcmerror = -ENOMEM; - goto err; - } - - /* Copy the passed variables, which should include the - terminating double-null */ - memcpy(bus->vars, arg, bus->varsz); -err: - return bcmerror; -} - -static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) -{ - int bcmerror = 0; - u32 varsize; - u32 varaddr; - u8 *vbuffer; - u32 varsizew; - __le32 varsizew_le; -#ifdef BCMDBG - char *nvram_ularray; -#endif /* BCMDBG */ - - /* Even if there are no vars are to be written, we still - need to set the ramsize. */ - varsize = bus->varsz ? roundup(bus->varsz, 4) : 0; - varaddr = (bus->ramsize - 4) - varsize; - - if (bus->vars) { - vbuffer = kzalloc(varsize, GFP_ATOMIC); - if (!vbuffer) - return -ENOMEM; - - memcpy(vbuffer, bus->vars, bus->varsz); - - /* Write the vars list */ - bcmerror = - brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); -#ifdef BCMDBG - /* Verify NVRAM bytes */ - brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); - nvram_ularray = kmalloc(varsize, GFP_ATOMIC); - if (!nvram_ularray) - return -ENOMEM; - - /* Upload image to verify downloaded contents. */ - memset(nvram_ularray, 0xaa, varsize); - - /* Read the vars list to temp buffer for comparison */ - bcmerror = - brcmf_sdbrcm_membytes(bus, false, varaddr, nvram_ularray, - varsize); - if (bcmerror) { - brcmf_dbg(ERROR, "error %d on reading %d nvram bytes at 0x%08x\n", - bcmerror, varsize, varaddr); - } - /* Compare the org NVRAM with the one read from RAM */ - if (memcmp(vbuffer, nvram_ularray, varsize)) - brcmf_dbg(ERROR, "Downloaded NVRAM image is corrupted\n"); - else - brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); - - kfree(nvram_ularray); -#endif /* BCMDBG */ - - kfree(vbuffer); - } - - /* adjust to the user specified RAM */ - brcmf_dbg(INFO, "Physical memory size: %d\n", bus->ramsize); - brcmf_dbg(INFO, "Vars are at %d, orig varsize is %d\n", - varaddr, varsize); - varsize = ((bus->ramsize - 4) - varaddr); - - /* - * Determine the length token: - * Varsize, converted to words, in lower 16-bits, checksum - * in upper 16-bits. - */ - if (bcmerror) { - varsizew = 0; - varsizew_le = cpu_to_le32(0); - } else { - varsizew = varsize / 4; - varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF); - varsizew_le = cpu_to_le32(varsizew); - } - - brcmf_dbg(INFO, "New varsize is %d, length token=0x%08x\n", - varsize, varsizew); - - /* Write the length token to the last word */ - bcmerror = brcmf_sdbrcm_membytes(bus, true, (bus->ramsize - 4), - (u8 *)&varsizew_le, 4); - - return bcmerror; -} - -static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) -{ - u32 regdata; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if (regdata & SBTML_RESET) - return; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { - /* - * set target reject and spin until busy is clear - * (preserve core-specific bits) - */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), - 4, regdata | SBTML_REJ); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4) & - SBTMH_BUSY), 100000); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_BUSY) - brcmf_dbg(ERROR, "ARM core still busy\n"); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) | - SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - SBIM_BY), 100000); - } - - /* set reset and reject while enabling the clocks */ - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4, - (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_REJ | SBTML_RESET)); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(10); - - /* clear the initiator reject bit */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - ~SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - } - } - - /* leave reset and reject asserted */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SBTML_REJ | SBTML_RESET)); - udelay(1); -} - -static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) -{ - u32 regdata; - - /* - * Must do the disable sequence first to work for - * arbitrary current core state. - */ - brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); - - /* - * Now do the initialization sequence. - * set reset while enabling the clock and - * forcing them on throughout the core - */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_RESET); - udelay(1); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_SERR) - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4, 0); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - if (regdata & (SBIM_IBE | SBIM_TO)) - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, - regdata & ~(SBIM_IBE | SBIM_TO)); - - /* clear reset and allow it to propagate throughout the core */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_FGC << SBTML_SICF_SHIFT) | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); - - /* leave clock enabled */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); -} - -static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) -{ - uint retries; - u32 regdata; - int bcmerror = 0; - - /* To enter download state, disable ARM and reset SOCRAM. - * To exit download state, simply reset ARM (default is RAM boot). - */ - if (enter) { - bus->alp_only = true; - - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, - bus->ci->armcorebase); - - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); - - /* Clear the top bit of memory */ - if (bus->ramsize) { - u32 zeros = 0; - brcmf_sdbrcm_membytes(bus, true, bus->ramsize - 4, - (u8 *)&zeros, 4); - } - } else { - regdata = brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); - regdata &= (SBTML_RESET | SBTML_REJ_MASK | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { - brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); - bcmerror = -EBADE; - goto fail; - } - - bcmerror = brcmf_sdbrcm_write_vars(bus); - if (bcmerror) { - brcmf_dbg(ERROR, "no vars written to RAM\n"); - bcmerror = 0; - } - - w_sdreg32(bus, 0xFFFFFFFF, - offsetof(struct sdpcmd_regs, intstatus), &retries); - - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); - - /* Allow HT Clock now that the ARM is running. */ - bus->alp_only = false; - - bus->drvr->busstate = BRCMF_BUS_LOAD; - } -fail: - return bcmerror; -} - -static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) -{ - if (bus->firmware->size < bus->fw_ptr + len) - len = bus->firmware->size - bus->fw_ptr; - - memcpy(buf, &bus->firmware->data[bus->fw_ptr], len); - bus->fw_ptr += len; - return len; -} - -MODULE_FIRMWARE(BCM4329_FW_NAME); -MODULE_FIRMWARE(BCM4329_NV_NAME); - -static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) -{ - int offset = 0; - uint len; - u8 *memblock = NULL, *memptr; - int ret; - - brcmf_dbg(INFO, "Enter\n"); - - bus->fw_name = BCM4329_FW_NAME; - ret = request_firmware(&bus->firmware, bus->fw_name, - &bus->sdiodev->func[2]->dev); - if (ret) { - brcmf_dbg(ERROR, "Fail to request firmware %d\n", ret); - return ret; - } - bus->fw_ptr = 0; - - memptr = memblock = kmalloc(MEMBLOCK + BRCMF_SDALIGN, GFP_ATOMIC); - if (memblock == NULL) { - ret = -ENOMEM; - goto err; - } - if ((u32)(unsigned long)memblock % BRCMF_SDALIGN) - memptr += (BRCMF_SDALIGN - - ((u32)(unsigned long)memblock % BRCMF_SDALIGN)); - - /* Download image */ - while ((len = - brcmf_sdbrcm_get_image((char *)memptr, MEMBLOCK, bus))) { - ret = brcmf_sdbrcm_membytes(bus, true, offset, memptr, len); - if (ret) { - brcmf_dbg(ERROR, "error %d on writing %d membytes at 0x%08x\n", - ret, MEMBLOCK, offset); - goto err; - } - - offset += MEMBLOCK; - } - -err: - kfree(memblock); - - release_firmware(bus->firmware); - bus->fw_ptr = 0; - - return ret; -} - -/* - * ProcessVars:Takes a buffer of "=\n" lines read from a file - * and ending in a NUL. - * Removes carriage returns, empty lines, comment lines, and converts - * newlines to NULs. - * Shortens buffer as needed and pads with NULs. End of buffer is marked - * by two NULs. -*/ - -static uint brcmf_process_nvram_vars(char *varbuf, uint len) -{ - char *dp; - bool findNewline; - int column; - uint buf_len, n; - - dp = varbuf; - - findNewline = false; - column = 0; - - for (n = 0; n < len; n++) { - if (varbuf[n] == 0) - break; - if (varbuf[n] == '\r') - continue; - if (findNewline && varbuf[n] != '\n') - continue; - findNewline = false; - if (varbuf[n] == '#') { - findNewline = true; - continue; - } - if (varbuf[n] == '\n') { - if (column == 0) - continue; - *dp++ = 0; - column = 0; - continue; - } - *dp++ = varbuf[n]; - column++; - } - buf_len = dp - varbuf; - - while (dp < varbuf + n) - *dp++ = 0; - - return buf_len; -} - -static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) -{ - uint len; - char *memblock = NULL; - char *bufp; - int ret; - - bus->nv_name = BCM4329_NV_NAME; - ret = request_firmware(&bus->firmware, bus->nv_name, - &bus->sdiodev->func[2]->dev); - if (ret) { - brcmf_dbg(ERROR, "Fail to request nvram %d\n", ret); - return ret; - } - bus->fw_ptr = 0; - - memblock = kmalloc(MEMBLOCK, GFP_ATOMIC); - if (memblock == NULL) { - ret = -ENOMEM; - goto err; - } - - len = brcmf_sdbrcm_get_image(memblock, MEMBLOCK, bus); - - if (len > 0 && len < MEMBLOCK) { - bufp = (char *)memblock; - bufp[len] = 0; - len = brcmf_process_nvram_vars(bufp, len); - bufp += len; - *bufp++ = 0; - if (len) - ret = brcmf_sdbrcm_downloadvars(bus, memblock, len + 1); - if (ret) - brcmf_dbg(ERROR, "error downloading vars: %d\n", ret); - } else { - brcmf_dbg(ERROR, "error reading nvram file: %d\n", len); - ret = -EIO; - } - -err: - kfree(memblock); - - release_firmware(bus->firmware); - bus->fw_ptr = 0; - - return ret; -} - -static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) -{ - int bcmerror = -1; - - /* Keep arm in reset */ - if (brcmf_sdbrcm_download_state(bus, true)) { - brcmf_dbg(ERROR, "error placing ARM core in reset\n"); - goto err; - } - - /* External image takes precedence if specified */ - if (brcmf_sdbrcm_download_code_file(bus)) { - brcmf_dbg(ERROR, "dongle image file download failed\n"); - goto err; - } - - /* External nvram takes precedence if specified */ - if (brcmf_sdbrcm_download_nvram(bus)) - brcmf_dbg(ERROR, "dongle nvram file download failed\n"); - - /* Take arm out of reset */ - if (brcmf_sdbrcm_download_state(bus, false)) { - brcmf_dbg(ERROR, "error getting out of ARM core reset\n"); - goto err; - } - - bcmerror = 0; - -err: - return bcmerror; -} - -static bool -brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) -{ - bool ret; - - /* Download the firmware */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - ret = _brcmf_sdbrcm_download_firmware(bus) == 0; - - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - - return ret; -} - -void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) -{ - u32 local_hostintmask; - u8 saveclk; - uint retries; - int err; - - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->watchdog_tsk) { - send_sig(SIGTERM, bus->watchdog_tsk, 1); - kthread_stop(bus->watchdog_tsk); - bus->watchdog_tsk = NULL; - } - - if (bus->dpc_tsk && bus->dpc_tsk != current) { - send_sig(SIGTERM, bus->dpc_tsk, 1); - kthread_stop(bus->dpc_tsk); - bus->dpc_tsk = NULL; - } - - down(&bus->sdsem); - - bus_wake(bus); - - /* Enable clock for device interrupts */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - - /* Disable and clear interrupts at the chip level also */ - w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries); - local_hostintmask = bus->hostintmask; - bus->hostintmask = 0; - - /* Change our idea of bus state */ - bus->drvr->busstate = BRCMF_BUS_DOWN; - - /* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (!err) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - (saveclk | SBSDIO_FORCE_HT), &err); - } - if (err) - brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); - - /* Turn off the bus (F2), free any pending packets */ - brcmf_dbg(INTR, "disable SDIO interrupts\n"); - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - /* Clear any pending interrupts now that F2 is disabled */ - w_sdreg32(bus, local_hostintmask, - offsetof(struct sdpcmd_regs, intstatus), &retries); - - /* Turn off the backplane clock (only) */ - brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); - - /* Clear the data packet queues */ - brcmu_pktq_flush(&bus->txq, true, NULL, NULL); - - /* Clear any held glomming stuff */ - if (bus->glomd) - brcmu_pkt_buf_free_skb(bus->glomd); - - if (bus->glom) - brcmu_pkt_buf_free_skb(bus->glom); - - bus->glom = bus->glomd = NULL; - - /* Clear rx control and wake any waiters */ - bus->rxlen = 0; - brcmf_sdbrcm_dcmd_resp_wake(bus); - - /* Reset some F2 state stuff */ - bus->rxskip = false; - bus->tx_seq = bus->rx_seq = 0; - - up(&bus->sdsem); -} - -int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) -{ - struct brcmf_bus *bus = drvr->bus; - unsigned long timeout; - uint retries = 0; - u8 ready, enable; - int err, ret = 0; - u8 saveclk; - - brcmf_dbg(TRACE, "Enter\n"); - - /* try to download image and nvram to the dongle */ - if (drvr->busstate == BRCMF_BUS_DOWN) { - if (!(brcmf_sdbrcm_download_firmware(bus))) - return -1; - } - - if (!bus->drvr) - return 0; - - /* Start the watchdog timer */ - bus->drvr->tickcnt = 0; - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - - down(&bus->sdsem); - - /* Make sure backplane clock is on, needed to generate F2 interrupt */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - if (bus->clkstate != CLK_AVAIL) - goto exit; - - /* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - if (!err) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - (saveclk | SBSDIO_FORCE_HT), &err); - } - if (err) { - brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err); - goto exit; - } - - /* Enable function 2 (frame transfers) */ - w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, - offsetof(struct sdpcmd_regs, tosbmailboxdata), &retries); - enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - enable, NULL); - - timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); - ready = 0; - while (enable != ready) { - ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, - SDIO_CCCR_IORx, NULL); - if (time_after(jiffies, timeout)) - break; - else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50)) - /* prevent busy waiting if it takes too long */ - msleep_interruptible(20); - } - - brcmf_dbg(INFO, "enable 0x%02x, ready 0x%02x\n", enable, ready); - - /* If F2 successfully enabled, set core and enable interrupts */ - if (ready == enable) { - /* Set up the interrupt mask and enable interrupts */ - bus->hostintmask = HOSTINTMASK; - w_sdreg32(bus, bus->hostintmask, - offsetof(struct sdpcmd_regs, hostintmask), &retries); - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_WATERMARK, 8, &err); - - /* Set bus state according to enable result */ - drvr->busstate = BRCMF_BUS_DATA; - } - - else { - /* Disable F2 again */ - enable = SDIO_FUNC_ENABLE_1; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, - SDIO_CCCR_IOEx, enable, NULL); - } - - /* Restore previous clock setting */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); - - /* If we didn't come up, turn off backplane clock */ - if (drvr->busstate != BRCMF_BUS_DATA) - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - -exit: - up(&bus->sdsem); - - return ret; -} - -void brcmf_sdbrcm_isr(void *arg) -{ - struct brcmf_bus *bus = (struct brcmf_bus *) arg; - - brcmf_dbg(TRACE, "Enter\n"); - - if (!bus) { - brcmf_dbg(ERROR, "bus is null pointer, exiting\n"); - return; - } - - if (bus->drvr->busstate == BRCMF_BUS_DOWN) { - brcmf_dbg(ERROR, "bus is down. we have nothing to do\n"); - return; - } - /* Count the interrupt call */ - bus->intrcount++; - bus->ipend = true; - - /* Shouldn't get this interrupt if we're sleeping? */ - if (bus->sleeping) { - brcmf_dbg(ERROR, "INTERRUPT WHILE SLEEPING??\n"); - return; - } - - /* Disable additional interrupts (is this needed now)? */ - if (!bus->intr) - brcmf_dbg(ERROR, "isr w/o interrupt configured!\n"); - - bus->dpc_sched = true; - if (bus->dpc_tsk) - complete(&bus->dpc_wait); -} - -static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) -{ - struct brcmf_bus *bus; - - brcmf_dbg(TIMER, "Enter\n"); - - bus = drvr->bus; - - /* Ignore the timer if simulating bus down */ - if (bus->sleeping) - return false; - - down(&bus->sdsem); - - /* Poll period: check device if appropriate. */ - if (bus->poll && (++bus->polltick >= bus->pollrate)) { - u32 intstatus = 0; - - /* Reset poll tick */ - bus->polltick = 0; - - /* Check device if no interrupts */ - if (!bus->intr || (bus->intrcount == bus->lastintrs)) { - - if (!bus->dpc_sched) { - u8 devpend; - devpend = brcmf_sdcard_cfg_read(bus->sdiodev, - SDIO_FUNC_0, SDIO_CCCR_INTx, - NULL); - intstatus = - devpend & (INTR_STATUS_FUNC1 | - INTR_STATUS_FUNC2); - } - - /* If there is something, make like the ISR and - schedule the DPC */ - if (intstatus) { - bus->pollcnt++; - bus->ipend = true; - - bus->dpc_sched = true; - if (bus->dpc_tsk) - complete(&bus->dpc_wait); - } - } - - /* Update interrupt tracking */ - bus->lastintrs = bus->intrcount; - } -#ifdef BCMDBG - /* Poll for console output periodically */ - if (drvr->busstate == BRCMF_BUS_DATA && bus->console_interval != 0) { - bus->console.count += BRCMF_WD_POLL_MS; - if (bus->console.count >= bus->console_interval) { - bus->console.count -= bus->console_interval; - /* Make sure backplane clock is on */ - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - if (brcmf_sdbrcm_readconsole(bus) < 0) - /* stop on error */ - bus->console_interval = 0; - } - } -#endif /* BCMDBG */ - - /* On idle timeout clear activity flag and/or turn off clock */ - if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { - if (++bus->idlecount >= bus->idletime) { - bus->idlecount = 0; - if (bus->activity) { - bus->activity = false; - brcmf_sdbrcm_wd_timer(bus, BRCMF_WD_POLL_MS); - } else { - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - } - } - } - - up(&bus->sdsem); - - return bus->ipend; -} - -static bool brcmf_sdbrcm_chipmatch(u16 chipid) -{ - if (chipid == BCM4329_CHIP_ID) - return true; - return false; -} - -static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - kfree(bus->rxbuf); - bus->rxctl = bus->rxbuf = NULL; - bus->rxlen = 0; - - kfree(bus->databuf); - bus->databuf = NULL; -} - -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->drvr->maxctl) { - bus->rxblen = - roundup((bus->drvr->maxctl + SDPCM_HDRLEN), - ALIGNMENT) + BRCMF_SDALIGN; - bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC); - if (!(bus->rxbuf)) - goto fail; - } - - /* Allocate buffer to receive glomed packet */ - bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC); - if (!(bus->databuf)) { - /* release rxbuf which was already located as above */ - if (!bus->rxblen) - kfree(bus->rxbuf); - goto fail; - } - - /* Align the buffer */ - if ((unsigned long)bus->databuf % BRCMF_SDALIGN) - bus->dataptr = bus->databuf + (BRCMF_SDALIGN - - ((unsigned long)bus->databuf % BRCMF_SDALIGN)); - else - bus->dataptr = bus->databuf; - - return true; - -fail: - return false; -} - -/* SDIO Pad drive strength to select value mappings */ -struct sdiod_drive_str { - u8 strength; /* Pad Drive Strength in mA */ - u8 sel; /* Chip-specific select value */ -}; - -/* SDIO Drive Strength to sel value table for PMU Rev 1 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { - { - 4, 0x2}, { - 2, 0x3}, { - 1, 0x0}, { - 0, 0x0} - }; - -/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { - { - 12, 0x7}, { - 10, 0x6}, { - 8, 0x5}, { - 6, 0x4}, { - 4, 0x2}, { - 2, 0x1}, { - 0, 0x0} - }; - -/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ -static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { - { - 32, 0x7}, { - 26, 0x6}, { - 22, 0x5}, { - 16, 0x4}, { - 12, 0x3}, { - 8, 0x2}, { - 4, 0x1}, { - 0, 0x0} - }; - -#define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) - -static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, - u32 drivestrength) { - struct sdiod_drive_str *str_tab = NULL; - u32 str_mask = 0; - u32 str_shift = 0; - char chn[8]; - - if (!(bus->ci->cccaps & CC_CAP_PMU)) - return; - - switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) { - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; - str_mask = 0x30000000; - str_shift = 28; - break; - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; - str_mask = 0x00003800; - str_shift = 11; - break; - case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; - str_mask = 0x00003800; - str_shift = 11; - break; - default: - brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", - brcmu_chipname(bus->ci->chip, chn, 8), - bus->ci->chiprev, bus->ci->pmurev); - break; - } - - if (str_tab != NULL) { - u32 drivestrength_sel = 0; - u32 cc_data_temp; - int i; - - for (i = 0; str_tab[i].strength != 0; i++) { - if (drivestrength >= str_tab[i].strength) { - drivestrength_sel = str_tab[i].sel; - break; - } - } - - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), - 4, 1); - cc_data_temp = brcmf_sdcard_reg_read(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); - cc_data_temp &= ~str_mask; - drivestrength_sel <<= str_shift; - cc_data_temp |= drivestrength_sel; - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), - 4, cc_data_temp); - - brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", - drivestrength, cc_data_temp); - } -} - -static int -brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u32 regs) -{ - u32 regdata; - - /* - * Get CC core rev - * Chipid is assume to be at offset 0 from regs arg - * For different chiptypes or old sdio hosts w/o chipcommon, - * other ways of recognition should be added here. - */ - ci->cccorebase = regs; - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, chipid), 4); - ci->chip = regdata & CID_ID_MASK; - ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; - - brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); - - /* Address of cores for new chips should be added here */ - switch (ci->chip) { - case BCM4329_CHIP_ID: - ci->buscorebase = BCM4329_CORE_BUS_BASE; - ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; - ci->armcorebase = BCM4329_CORE_ARM_BASE; - ci->ramsize = BCM4329_RAMSIZE; - break; - default: - brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); - return -ENODEV; - } - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->cccorebase, sbidhigh), 4); - ci->ccrev = SBCOREREV(regdata); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); - ci->pmurev = regdata & PCAP_REV_MASK; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscorerev = SBCOREREV(regdata); - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; - - brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); - - /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, capabilities), 4); - - return 0; -} - -static int -brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) -{ - struct chip_info *ci; - int err; - u8 clkval, clkset; - - brcmf_dbg(TRACE, "Enter\n"); - - /* alloc chip_info_t */ - ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); - if (NULL == ci) - return -ENOMEM; - - /* bus/core/clk setup for register access */ - /* Try forcing SDIO core to do ALPAvail request only */ - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); - if (err) { - brcmf_dbg(ERROR, "error writing for HT off\n"); - goto fail; - } - - /* If register supported, wait for ALPAvail and then force ALP */ - /* This may take up to 15 milliseconds */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, NULL); - if ((clkval & ~SBSDIO_AVBITS) == clkset) { - SPINWAIT(((clkval = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - NULL)), - !SBSDIO_ALPAV(clkval)), - PMU_MAX_TRANSITION_DLY); - if (!SBSDIO_ALPAV(clkval)) { - brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", - clkval); - err = -EBUSY; - goto fail; - } - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | - SBSDIO_FORCE_ALP; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - clkset, &err); - udelay(65); - } else { - brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", - clkset, clkval); - err = -EACCES; - goto fail; - } - - /* Also, disable the extra SDIO pull-ups */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); - - err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); - if (err) - goto fail; - - /* - * Make sure any on-chip ARM is off (in case strapping is wrong), - * or downloaded code was already running. - */ - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); - - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); - - /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - /* WAR: cmd52 backplane read so core HW will drop ALPReq */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - 0, NULL); - - /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - - bus->ci = ci; - return 0; -fail: - bus->ci = NULL; - kfree(ci); - return err; -} - -static bool -brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) -{ - u8 clkctl = 0; - int err = 0; - int reg_addr; - u32 reg_val; - - bus->alp_only = true; - - /* Return the window to backplane enumeration space for core access */ - if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) - brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); - -#ifdef BCMDBG - printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", - brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); - -#endif /* BCMDBG */ - - /* - * Force PLL off until brcmf_sdbrcm_chip_attach() - * programs PLL control regs - */ - - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - BRCMF_INIT_CLKCTL1, &err); - if (!err) - clkctl = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, &err); - - if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { - brcmf_dbg(ERROR, "ChipClkCSR access: err %d wrote 0x%02x read 0x%02x\n", - err, BRCMF_INIT_CLKCTL1, clkctl); - goto fail; - } - - if (brcmf_sdbrcm_chip_attach(bus, regsva)) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); - goto fail; - } - - if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) { - brcmf_dbg(ERROR, "unsupported chip: 0x%04x\n", bus->ci->chip); - goto fail; - } - - brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); - - /* Get info on the ARM and SOCRAM cores... */ - brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->armcorebase, sbidhigh), 4); - bus->ramsize = bus->ci->ramsize; - if (!(bus->ramsize)) { - brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); - goto fail; - } - - /* Set core control so an SDIO reset does a backplane reset */ - reg_addr = bus->ci->buscorebase + - offsetof(struct sdpcmd_regs, corecontrol); - reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); - brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), - reg_val | CC_BPRESEN); - - brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); - - /* Locate an appropriately-aligned portion of hdrbuf */ - bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], - BRCMF_SDALIGN); - - /* Set the poll and/or interrupt flags */ - bus->intr = true; - bus->poll = false; - if (bus->poll) - bus->pollrate = 1; - - return true; - -fail: - return false; -} - -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - bus->drvr->busstate = BRCMF_BUS_DOWN; - bus->sleeping = false; - bus->rxflow = false; - - /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - - /* ...and initialize clock/power states */ - bus->clkstate = CLK_SDONLY; - bus->idletime = BRCMF_IDLE_INTERVAL; - bus->idleclock = BRCMF_IDLE_ACTIVE; - - /* Query the F2 block size, set roundup accordingly */ - bus->blocksize = bus->sdiodev->func[2]->cur_blksize; - bus->roundup = min(max_roundup, bus->blocksize); - - /* bus module does not support packet chaining */ - bus->use_rxchain = false; - bus->sd_rxchain = false; - - return true; -} - -static int -brcmf_sdbrcm_watchdog_thread(void *data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *)data; - - allow_signal(SIGTERM); - /* Run until signal received */ - while (1) { - if (kthread_should_stop()) - break; - if (!wait_for_completion_interruptible(&bus->watchdog_wait)) { - brcmf_sdbrcm_bus_watchdog(bus->drvr); - /* Count the tick for reference */ - bus->drvr->tickcnt++; - } else - break; - } - return 0; -} - -static void -brcmf_sdbrcm_watchdog(unsigned long data) -{ - struct brcmf_bus *bus = (struct brcmf_bus *)data; - - if (bus->watchdog_tsk) { - complete(&bus->watchdog_wait); - /* Reschedule the watchdog */ - if (bus->wd_timer_valid) - mod_timer(&bus->timer, - jiffies + BRCMF_WD_POLL_MS * HZ / 1000); - } -} - -static void -brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - kfree(bus->ci); - bus->ci = NULL; -} - -static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (bus->ci) { - brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); - brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - brcmf_sdbrcm_chip_detach(bus); - if (bus->vars && bus->varsz) - kfree(bus->vars); - bus->vars = NULL; - } - - brcmf_dbg(TRACE, "Disconnected\n"); -} - -/* Detach and free everything */ -static void brcmf_sdbrcm_release(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - if (bus) { - /* De-register interrupt handler */ - brcmf_sdcard_intr_dereg(bus->sdiodev); - - if (bus->drvr) { - brcmf_detach(bus->drvr); - brcmf_sdbrcm_release_dongle(bus); - bus->drvr = NULL; - } - - brcmf_sdbrcm_release_malloc(bus); - - kfree(bus); - } - - brcmf_dbg(TRACE, "Disconnected\n"); -} - -void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, struct brcmf_sdio_dev *sdiodev) -{ - int ret; - struct brcmf_bus *bus; - - /* Init global variables at run-time, not as part of the declaration. - * This is required to support init/de-init of the driver. - * Initialization - * of globals as part of the declaration results in non-deterministic - * behavior since the value of the globals may be different on the - * first time that the driver is initialized vs subsequent - * initializations. - */ - brcmf_c_init(); - - brcmf_dbg(TRACE, "Enter\n"); - - /* We make an assumption about address window mappings: - * regsva == SI_ENUM_BASE*/ - - /* Allocate private bus interface state */ - bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); - if (!bus) - goto fail; - - bus->sdiodev = sdiodev; - sdiodev->bus = bus; - bus->txbound = BRCMF_TXBOUND; - bus->rxbound = BRCMF_RXBOUND; - bus->txminmax = BRCMF_TXMINMAX; - bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; - bus->usebufpool = false; /* Use bufpool if allocated, - else use locally malloced rxbuf */ - - /* attempt to attach to the dongle */ - if (!(brcmf_sdbrcm_probe_attach(bus, regsva))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_attach failed\n"); - goto fail; - } - - spin_lock_init(&bus->txqlock); - init_waitqueue_head(&bus->ctrl_wait); - init_waitqueue_head(&bus->dcmd_resp_wait); - - /* Set up the watchdog timer */ - init_timer(&bus->timer); - bus->timer.data = (unsigned long)bus; - bus->timer.function = brcmf_sdbrcm_watchdog; - - /* Initialize thread based operation and lock */ - sema_init(&bus->sdsem, 1); - - /* Initialize watchdog thread */ - init_completion(&bus->watchdog_wait); - bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, - bus, "brcmf_watchdog"); - if (IS_ERR(bus->watchdog_tsk)) { - printk(KERN_WARNING - "brcmf_watchdog thread failed to start\n"); - bus->watchdog_tsk = NULL; - } - /* Initialize DPC thread */ - init_completion(&bus->dpc_wait); - bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, - bus, "brcmf_dpc"); - if (IS_ERR(bus->dpc_tsk)) { - printk(KERN_WARNING - "brcmf_dpc thread failed to start\n"); - bus->dpc_tsk = NULL; - } - - /* Attach to the brcmf/OS/network interface */ - bus->drvr = brcmf_attach(bus, SDPCM_RESERVE); - if (!bus->drvr) { - brcmf_dbg(ERROR, "brcmf_attach failed\n"); - goto fail; - } - - /* Allocate buffers */ - if (!(brcmf_sdbrcm_probe_malloc(bus))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_malloc failed\n"); - goto fail; - } - - if (!(brcmf_sdbrcm_probe_init(bus))) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_probe_init failed\n"); - goto fail; - } - - /* Register interrupt callback, but mask it (not operational yet). */ - brcmf_dbg(INTR, "disable SDIO interrupts (not interested yet)\n"); - ret = brcmf_sdcard_intr_reg(bus->sdiodev); - if (ret != 0) { - brcmf_dbg(ERROR, "FAILED: sdcard_intr_reg returned %d\n", ret); - goto fail; - } - brcmf_dbg(INTR, "registered SDIO interrupt function ok\n"); - - brcmf_dbg(INFO, "completed!!\n"); - - /* if firmware path present try to download and bring up bus */ - ret = brcmf_bus_start(bus->drvr); - if (ret != 0) { - if (ret == -ENOLINK) { - brcmf_dbg(ERROR, "dongle is not responding\n"); - goto fail; - } - } - /* Ok, have the per-port tell the stack we're open for business */ - if (brcmf_net_attach(bus->drvr, 0) != 0) { - brcmf_dbg(ERROR, "Net attach failed!!\n"); - goto fail; - } - - return bus; - -fail: - brcmf_sdbrcm_release(bus); - return NULL; -} - -void brcmf_sdbrcm_disconnect(void *ptr) -{ - struct brcmf_bus *bus = (struct brcmf_bus *)ptr; - - brcmf_dbg(TRACE, "Enter\n"); - - if (bus) - brcmf_sdbrcm_release(bus); - - brcmf_dbg(TRACE, "Disconnected\n"); -} - -struct device *brcmf_bus_get_device(struct brcmf_bus *bus) -{ - return &bus->sdiodev->func[2]->dev; -} - -void -brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) -{ - /* don't start the wd until fw is loaded */ - if (bus->drvr->busstate == BRCMF_BUS_DOWN) - return; - - /* Totally stop the timer */ - if (!wdtick && bus->wd_timer_valid == true) { - del_timer_sync(&bus->timer); - bus->wd_timer_valid = false; - bus->save_ms = wdtick; - return; - } - - if (wdtick) { - if (bus->save_ms != BRCMF_WD_POLL_MS) { - if (bus->wd_timer_valid == true) - /* Stop timer and restart at new value */ - del_timer_sync(&bus->timer); - - /* Create timer again when watchdog period is - dynamically changed or in the first instance - */ - bus->timer.expires = - jiffies + BRCMF_WD_POLL_MS * HZ / 1000; - add_timer(&bus->timer); - - } else { - /* Re arm the timer, at last watchdog period */ - mod_timer(&bus->timer, - jiffies + BRCMF_WD_POLL_MS * HZ / 1000); - } - - bus->wd_timer_valid = true; - bus->save_ms = wdtick; - } -} diff --git a/drivers/staging/brcm80211/brcmfmac/sdio_host.h b/drivers/staging/brcm80211/brcmfmac/sdio_host.h deleted file mode 100644 index 726fa898111..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/sdio_host.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_SDH_H_ -#define _BRCM_SDH_H_ - -#include - -#define SDIO_FUNC_0 0 -#define SDIO_FUNC_1 1 -#define SDIO_FUNC_2 2 - -#define SDIOD_FBR_SIZE 0x100 - -/* io_en */ -#define SDIO_FUNC_ENABLE_1 0x02 -#define SDIO_FUNC_ENABLE_2 0x04 - -/* io_rdys */ -#define SDIO_FUNC_READY_1 0x02 -#define SDIO_FUNC_READY_2 0x04 - -/* intr_status */ -#define INTR_STATUS_FUNC1 0x2 -#define INTR_STATUS_FUNC2 0x4 - -/* Maximum number of I/O funcs */ -#define SDIOD_MAX_IOFUNCS 7 - -/* as of sdiod rev 0, supports 3 functions */ -#define SBSDIO_NUM_FUNCTION 3 - -/* function 1 miscellaneous registers */ - -/* sprom command and status */ -#define SBSDIO_SPROM_CS 0x10000 -/* sprom info register */ -#define SBSDIO_SPROM_INFO 0x10001 -/* sprom indirect access data byte 0 */ -#define SBSDIO_SPROM_DATA_LOW 0x10002 -/* sprom indirect access data byte 1 */ -#define SBSDIO_SPROM_DATA_HIGH 0x10003 -/* sprom indirect access addr byte 0 */ -#define SBSDIO_SPROM_ADDR_LOW 0x10004 -/* sprom indirect access addr byte 0 */ -#define SBSDIO_SPROM_ADDR_HIGH 0x10005 -/* xtal_pu (gpio) output */ -#define SBSDIO_CHIP_CTRL_DATA 0x10006 -/* xtal_pu (gpio) enable */ -#define SBSDIO_CHIP_CTRL_EN 0x10007 -/* rev < 7, watermark for sdio device */ -#define SBSDIO_WATERMARK 0x10008 -/* control busy signal generation */ -#define SBSDIO_DEVICE_CTL 0x10009 - -/* SB Address Window Low (b15) */ -#define SBSDIO_FUNC1_SBADDRLOW 0x1000A -/* SB Address Window Mid (b23:b16) */ -#define SBSDIO_FUNC1_SBADDRMID 0x1000B -/* SB Address Window High (b31:b24) */ -#define SBSDIO_FUNC1_SBADDRHIGH 0x1000C -/* Frame Control (frame term/abort) */ -#define SBSDIO_FUNC1_FRAMECTRL 0x1000D -/* ChipClockCSR (ALP/HT ctl/status) */ -#define SBSDIO_FUNC1_CHIPCLKCSR 0x1000E -/* SdioPullUp (on cmd, d0-d2) */ -#define SBSDIO_FUNC1_SDIOPULLUP 0x1000F -/* Write Frame Byte Count Low */ -#define SBSDIO_FUNC1_WFRAMEBCLO 0x10019 -/* Write Frame Byte Count High */ -#define SBSDIO_FUNC1_WFRAMEBCHI 0x1001A -/* Read Frame Byte Count Low */ -#define SBSDIO_FUNC1_RFRAMEBCLO 0x1001B -/* Read Frame Byte Count High */ -#define SBSDIO_FUNC1_RFRAMEBCHI 0x1001C - -#define SBSDIO_FUNC1_MISC_REG_START 0x10000 /* f1 misc register start */ -#define SBSDIO_FUNC1_MISC_REG_LIMIT 0x1001C /* f1 misc register end */ - -/* function 1 OCP space */ - -/* sb offset addr is <= 15 bits, 32k */ -#define SBSDIO_SB_OFT_ADDR_MASK 0x07FFF -#define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000 -/* with b15, maps to 32-bit SB access */ -#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000 - -/* valid bits in SBSDIO_FUNC1_SBADDRxxx regs */ - -#define SBSDIO_SBADDRLOW_MASK 0x80 /* Valid bits in SBADDRLOW */ -#define SBSDIO_SBADDRMID_MASK 0xff /* Valid bits in SBADDRMID */ -#define SBSDIO_SBADDRHIGH_MASK 0xffU /* Valid bits in SBADDRHIGH */ -/* Address bits from SBADDR regs */ -#define SBSDIO_SBWINDOW_MASK 0xffff8000 - -#define SDIOH_READ 0 /* Read request */ -#define SDIOH_WRITE 1 /* Write request */ - -#define SDIOH_DATA_FIX 0 /* Fixed addressing */ -#define SDIOH_DATA_INC 1 /* Incremental addressing */ - -/* internal return code */ -#define SUCCESS 0 -#define ERROR 1 - -struct brcmf_sdreg { - int func; - int offset; - int value; -}; - -struct brcmf_sdio_dev { - struct sdio_func *func[SDIO_MAX_FUNCS]; - u8 num_funcs; /* Supported funcs on client */ - u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; - u32 sbwad; /* Save backplane window address */ - bool regfail; /* status of last reg_r/w call */ - void *bus; - atomic_t suspend; /* suspend flag */ - wait_queue_head_t request_byte_wait; - wait_queue_head_t request_word_wait; - wait_queue_head_t request_packet_wait; - wait_queue_head_t request_buffer_wait; - -}; - -/* Register/deregister device interrupt handler. */ -extern int -brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev); - -extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev); - -/* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface). - * fn: function number - * addr: unmodified SDIO-space address - * data: data byte to write - * err: pointer to error code (or NULL) - */ -extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func, - u32 addr, int *err); -extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func, - u32 addr, u8 data, int *err); - -/* Synchronous access to device (client) core registers via CMD53 to F1. - * addr: backplane address (i.e. >= regsva from attach) - * size: register width in bytes (2 or 4) - * data: data for register write - */ -extern u32 -brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size); - -extern u32 -brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size, - u32 data); - -/* Indicate if last reg read/write failed */ -extern bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev); - -/* Buffer transfer to/from device (client) core via cmd53. - * fn: function number - * addr: backplane address (i.e. >= regsva from attach) - * flags: backplane width, address increment, sync/async - * buf: pointer to memory data buffer - * nbytes: number of bytes to transfer to/from buf - * pkt: pointer to packet associated with buf (if any) - * complete: callback function for command completion (async only) - * handle: handle for completion callback (first arg in callback) - * Returns 0 or error code. - * NOTE: Async operation is not currently supported. - */ -extern int -brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); -extern int -brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); - -/* Flags bits */ - -/* Four-byte target (backplane) width (vs. two-byte) */ -#define SDIO_REQ_4BYTE 0x1 -/* Fixed address (FIFO) (vs. incrementing address) */ -#define SDIO_REQ_FIXED 0x2 -/* Async request (vs. sync request) */ -#define SDIO_REQ_ASYNC 0x4 - -/* Read/write to memory block (F1, no FIFO) via CMD53 (sync only). - * rw: read or write (0/1) - * addr: direct SDIO address - * buf: pointer to memory data buffer - * nbytes: number of bytes to transfer to/from buf - * Returns 0 or error code. - */ -extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, - u32 addr, u8 *buf, uint nbytes); - -/* Issue an abort to the specified function */ -extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn); - -/* platform specific/high level functions */ -extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); -extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev); - -extern int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, - u32 address); - -/* attach, return handler on success, NULL if failed. - * The handler shall be provided by all subsequent calls. No local cache - * cfghdl points to the starting address of pci device mapped memory - */ -extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); -extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); - -/* read or write one byte using cmd52 */ -extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, - uint fnc, uint addr, u8 *byte); - -/* read or write 2/4 bytes using cmd53 */ -extern int -brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, - uint rw, uint fnc, uint addr, - u32 *word, uint nbyte); - -/* read or write any buffer using cmd53 */ -extern int -brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, - uint fix_inc, uint rw, uint fnc_num, - u32 addr, uint regwidth, - u32 buflen, u8 *buffer, struct sk_buff *pkt); - -/* Watchdog timer interface for pm ops */ -extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, - bool enable); - -extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, struct brcmf_sdio_dev *sdiodev); -extern void brcmf_sdbrcm_disconnect(void *ptr); -extern void brcmf_sdbrcm_isr(void *arg); -#endif /* _BRCM_SDH_H_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c deleted file mode 100644 index fc643c1eb59..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ /dev/null @@ -1,3730 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "dhd.h" -#include "wl_cfg80211.h" - -#define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ - (sizeof(struct brcmf_assoc_params_le) - sizeof(u16)) - -static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; - -static u32 brcmf_dbg_level = WL_DBG_ERR; - -static void brcmf_set_drvdata(struct brcmf_cfg80211_dev *dev, void *data) -{ - dev->driver_data = data; -} - -static void *brcmf_get_drvdata(struct brcmf_cfg80211_dev *dev) -{ - void *data = NULL; - - if (dev) - data = dev->driver_data; - return data; -} - -static -struct brcmf_cfg80211_priv *brcmf_priv_get(struct brcmf_cfg80211_dev *cfg_dev) -{ - struct brcmf_cfg80211_iface *ci = brcmf_get_drvdata(cfg_dev); - return ci->cfg_priv; -} - -static bool check_sys_up(struct wiphy *wiphy) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - if (!test_bit(WL_STATUS_READY, &cfg_priv->status)) { - WL_INFO("device is not ready : status (%d)\n", - (int)cfg_priv->status); - return false; - } - return true; -} - -#define CHAN2G(_channel, _freq, _flags) { \ - .band = IEEE80211_BAND_2GHZ, \ - .center_freq = (_freq), \ - .hw_value = (_channel), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -#define CHAN5G(_channel, _flags) { \ - .band = IEEE80211_BAND_5GHZ, \ - .center_freq = 5000 + (5 * (_channel)), \ - .hw_value = (_channel), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -#define RATE_TO_BASE100KBPS(rate) (((rate) * 10) / 2) -#define RATETAB_ENT(_rateid, _flags) \ - { \ - .bitrate = RATE_TO_BASE100KBPS(_rateid), \ - .hw_value = (_rateid), \ - .flags = (_flags), \ - } - -static struct ieee80211_rate __wl_rates[] = { - RATETAB_ENT(BRCM_RATE_1M, 0), - RATETAB_ENT(BRCM_RATE_2M, IEEE80211_RATE_SHORT_PREAMBLE), - RATETAB_ENT(BRCM_RATE_5M5, IEEE80211_RATE_SHORT_PREAMBLE), - RATETAB_ENT(BRCM_RATE_11M, IEEE80211_RATE_SHORT_PREAMBLE), - RATETAB_ENT(BRCM_RATE_6M, 0), - RATETAB_ENT(BRCM_RATE_9M, 0), - RATETAB_ENT(BRCM_RATE_12M, 0), - RATETAB_ENT(BRCM_RATE_18M, 0), - RATETAB_ENT(BRCM_RATE_24M, 0), - RATETAB_ENT(BRCM_RATE_36M, 0), - RATETAB_ENT(BRCM_RATE_48M, 0), - RATETAB_ENT(BRCM_RATE_54M, 0), -}; - -#define wl_a_rates (__wl_rates + 4) -#define wl_a_rates_size 8 -#define wl_g_rates (__wl_rates + 0) -#define wl_g_rates_size 12 - -static struct ieee80211_channel __wl_2ghz_channels[] = { - CHAN2G(1, 2412, 0), - CHAN2G(2, 2417, 0), - CHAN2G(3, 2422, 0), - CHAN2G(4, 2427, 0), - CHAN2G(5, 2432, 0), - CHAN2G(6, 2437, 0), - CHAN2G(7, 2442, 0), - CHAN2G(8, 2447, 0), - CHAN2G(9, 2452, 0), - CHAN2G(10, 2457, 0), - CHAN2G(11, 2462, 0), - CHAN2G(12, 2467, 0), - CHAN2G(13, 2472, 0), - CHAN2G(14, 2484, 0), -}; - -static struct ieee80211_channel __wl_5ghz_a_channels[] = { - CHAN5G(34, 0), CHAN5G(36, 0), - CHAN5G(38, 0), CHAN5G(40, 0), - CHAN5G(42, 0), CHAN5G(44, 0), - CHAN5G(46, 0), CHAN5G(48, 0), - CHAN5G(52, 0), CHAN5G(56, 0), - CHAN5G(60, 0), CHAN5G(64, 0), - CHAN5G(100, 0), CHAN5G(104, 0), - CHAN5G(108, 0), CHAN5G(112, 0), - CHAN5G(116, 0), CHAN5G(120, 0), - CHAN5G(124, 0), CHAN5G(128, 0), - CHAN5G(132, 0), CHAN5G(136, 0), - CHAN5G(140, 0), CHAN5G(149, 0), - CHAN5G(153, 0), CHAN5G(157, 0), - CHAN5G(161, 0), CHAN5G(165, 0), - CHAN5G(184, 0), CHAN5G(188, 0), - CHAN5G(192, 0), CHAN5G(196, 0), - CHAN5G(200, 0), CHAN5G(204, 0), - CHAN5G(208, 0), CHAN5G(212, 0), - CHAN5G(216, 0), -}; - -static struct ieee80211_channel __wl_5ghz_n_channels[] = { - CHAN5G(32, 0), CHAN5G(34, 0), - CHAN5G(36, 0), CHAN5G(38, 0), - CHAN5G(40, 0), CHAN5G(42, 0), - CHAN5G(44, 0), CHAN5G(46, 0), - CHAN5G(48, 0), CHAN5G(50, 0), - CHAN5G(52, 0), CHAN5G(54, 0), - CHAN5G(56, 0), CHAN5G(58, 0), - CHAN5G(60, 0), CHAN5G(62, 0), - CHAN5G(64, 0), CHAN5G(66, 0), - CHAN5G(68, 0), CHAN5G(70, 0), - CHAN5G(72, 0), CHAN5G(74, 0), - CHAN5G(76, 0), CHAN5G(78, 0), - CHAN5G(80, 0), CHAN5G(82, 0), - CHAN5G(84, 0), CHAN5G(86, 0), - CHAN5G(88, 0), CHAN5G(90, 0), - CHAN5G(92, 0), CHAN5G(94, 0), - CHAN5G(96, 0), CHAN5G(98, 0), - CHAN5G(100, 0), CHAN5G(102, 0), - CHAN5G(104, 0), CHAN5G(106, 0), - CHAN5G(108, 0), CHAN5G(110, 0), - CHAN5G(112, 0), CHAN5G(114, 0), - CHAN5G(116, 0), CHAN5G(118, 0), - CHAN5G(120, 0), CHAN5G(122, 0), - CHAN5G(124, 0), CHAN5G(126, 0), - CHAN5G(128, 0), CHAN5G(130, 0), - CHAN5G(132, 0), CHAN5G(134, 0), - CHAN5G(136, 0), CHAN5G(138, 0), - CHAN5G(140, 0), CHAN5G(142, 0), - CHAN5G(144, 0), CHAN5G(145, 0), - CHAN5G(146, 0), CHAN5G(147, 0), - CHAN5G(148, 0), CHAN5G(149, 0), - CHAN5G(150, 0), CHAN5G(151, 0), - CHAN5G(152, 0), CHAN5G(153, 0), - CHAN5G(154, 0), CHAN5G(155, 0), - CHAN5G(156, 0), CHAN5G(157, 0), - CHAN5G(158, 0), CHAN5G(159, 0), - CHAN5G(160, 0), CHAN5G(161, 0), - CHAN5G(162, 0), CHAN5G(163, 0), - CHAN5G(164, 0), CHAN5G(165, 0), - CHAN5G(166, 0), CHAN5G(168, 0), - CHAN5G(170, 0), CHAN5G(172, 0), - CHAN5G(174, 0), CHAN5G(176, 0), - CHAN5G(178, 0), CHAN5G(180, 0), - CHAN5G(182, 0), CHAN5G(184, 0), - CHAN5G(186, 0), CHAN5G(188, 0), - CHAN5G(190, 0), CHAN5G(192, 0), - CHAN5G(194, 0), CHAN5G(196, 0), - CHAN5G(198, 0), CHAN5G(200, 0), - CHAN5G(202, 0), CHAN5G(204, 0), - CHAN5G(206, 0), CHAN5G(208, 0), - CHAN5G(210, 0), CHAN5G(212, 0), - CHAN5G(214, 0), CHAN5G(216, 0), - CHAN5G(218, 0), CHAN5G(220, 0), - CHAN5G(222, 0), CHAN5G(224, 0), - CHAN5G(226, 0), CHAN5G(228, 0), -}; - -static struct ieee80211_supported_band __wl_band_2ghz = { - .band = IEEE80211_BAND_2GHZ, - .channels = __wl_2ghz_channels, - .n_channels = ARRAY_SIZE(__wl_2ghz_channels), - .bitrates = wl_g_rates, - .n_bitrates = wl_g_rates_size, -}; - -static struct ieee80211_supported_band __wl_band_5ghz_a = { - .band = IEEE80211_BAND_5GHZ, - .channels = __wl_5ghz_a_channels, - .n_channels = ARRAY_SIZE(__wl_5ghz_a_channels), - .bitrates = wl_a_rates, - .n_bitrates = wl_a_rates_size, -}; - -static struct ieee80211_supported_band __wl_band_5ghz_n = { - .band = IEEE80211_BAND_5GHZ, - .channels = __wl_5ghz_n_channels, - .n_channels = ARRAY_SIZE(__wl_5ghz_n_channels), - .bitrates = wl_a_rates, - .n_bitrates = wl_a_rates_size, -}; - -static const u32 __wl_cipher_suites[] = { - WLAN_CIPHER_SUITE_WEP40, - WLAN_CIPHER_SUITE_WEP104, - WLAN_CIPHER_SUITE_TKIP, - WLAN_CIPHER_SUITE_CCMP, - WLAN_CIPHER_SUITE_AES_CMAC, -}; - -/* function for reading/writing a single u32 from/to the dongle */ -static int -brcmf_exec_dcmd_u32(struct net_device *ndev, u32 cmd, u32 *par) -{ - int err; - __le32 par_le = cpu_to_le32(*par); - - err = brcmf_exec_dcmd(ndev, cmd, &par_le, sizeof(__le32)); - *par = le32_to_cpu(par_le); - - return err; -} - -static void convert_key_from_CPU(struct brcmf_wsec_key *key, - struct brcmf_wsec_key_le *key_le) -{ - key_le->index = cpu_to_le32(key->index); - key_le->len = cpu_to_le32(key->len); - key_le->algo = cpu_to_le32(key->algo); - key_le->flags = cpu_to_le32(key->flags); - key_le->rxiv.hi = cpu_to_le32(key->rxiv.hi); - key_le->rxiv.lo = cpu_to_le16(key->rxiv.lo); - key_le->iv_initialized = cpu_to_le32(key->iv_initialized); - memcpy(key_le->data, key->data, sizeof(key->data)); - memcpy(key_le->ea, key->ea, sizeof(key->ea)); -} - -static int send_key_to_dongle(struct net_device *ndev, - struct brcmf_wsec_key *key) -{ - int err; - struct brcmf_wsec_key_le key_le; - - convert_key_from_CPU(key, &key_le); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_KEY, &key_le, sizeof(key_le)); - if (err) - WL_ERR("WLC_SET_KEY error (%d)\n", err); - return err; -} - -static s32 -brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct wireless_dev *wdev; - s32 infra = 0; - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - switch (type) { - case NL80211_IFTYPE_MONITOR: - case NL80211_IFTYPE_WDS: - WL_ERR("type (%d) : currently we do not support this type\n", - type); - return -EOPNOTSUPP; - case NL80211_IFTYPE_ADHOC: - cfg_priv->conf->mode = WL_MODE_IBSS; - infra = 0; - break; - case NL80211_IFTYPE_STATION: - cfg_priv->conf->mode = WL_MODE_BSS; - infra = 1; - break; - default: - err = -EINVAL; - goto done; - } - - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_INFRA, &infra); - if (err) { - WL_ERR("WLC_SET_INFRA error (%d)\n", err); - err = -EAGAIN; - } else { - wdev = ndev->ieee80211_ptr; - wdev->iftype = type; - } - - WL_INFO("IF Type = %s\n", - (cfg_priv->conf->mode == WL_MODE_IBSS) ? "Adhoc" : "Infra"); - -done: - WL_TRACE("Exit\n"); - - return err; -} - -static s32 brcmf_dev_intvar_set(struct net_device *ndev, s8 *name, s32 val) -{ - s8 buf[BRCMF_DCMD_SMLEN]; - u32 len; - s32 err = 0; - __le32 val_le; - - val_le = cpu_to_le32(val); - len = brcmu_mkiovar(name, (char *)(&val_le), sizeof(val_le), buf, - sizeof(buf)); - BUG_ON(!len); - - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, buf, len); - if (err) - WL_ERR("error (%d)\n", err); - - return err; -} - -static s32 -brcmf_dev_intvar_get(struct net_device *ndev, s8 *name, s32 *retval) -{ - union { - s8 buf[BRCMF_DCMD_SMLEN]; - __le32 val; - } var; - u32 len; - u32 data_null; - s32 err = 0; - - len = - brcmu_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), - sizeof(var.buf)); - BUG_ON(!len); - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, &var, len); - if (err) - WL_ERR("error (%d)\n", err); - - *retval = le32_to_cpu(var.val); - - return err; -} - -static void brcmf_set_mpc(struct net_device *ndev, int mpc) -{ - s32 err = 0; - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) { - err = brcmf_dev_intvar_set(ndev, "mpc", mpc); - if (err) { - WL_ERR("fail to set mpc\n"); - return; - } - WL_INFO("MPC : %d\n", mpc); - } -} - -static void wl_iscan_prep(struct brcmf_scan_params_le *params_le, - struct brcmf_ssid *ssid) -{ - memcpy(params_le->bssid, ether_bcast, ETH_ALEN); - params_le->bss_type = DOT11_BSSTYPE_ANY; - params_le->scan_type = 0; - params_le->channel_num = 0; - params_le->nprobes = cpu_to_le32(-1); - params_le->active_time = cpu_to_le32(-1); - params_le->passive_time = cpu_to_le32(-1); - params_le->home_time = cpu_to_le32(-1); - if (ssid && ssid->SSID_len) - memcpy(¶ms_le->ssid_le, ssid, sizeof(struct brcmf_ssid)); -} - -static s32 -brcmf_dev_iovar_setbuf(struct net_device *ndev, s8 * iovar, void *param, - s32 paramlen, void *bufptr, s32 buflen) -{ - s32 iolen; - - iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); - BUG_ON(!iolen); - - return brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, bufptr, iolen); -} - -static s32 -brcmf_dev_iovar_getbuf(struct net_device *ndev, s8 * iovar, void *param, - s32 paramlen, void *bufptr, s32 buflen) -{ - s32 iolen; - - iolen = brcmu_mkiovar(iovar, param, paramlen, bufptr, buflen); - BUG_ON(!iolen); - - return brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, bufptr, buflen); -} - -static s32 -brcmf_run_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan, - struct brcmf_ssid *ssid, u16 action) -{ - s32 params_size = BRCMF_SCAN_PARAMS_FIXED_SIZE + - offsetof(struct brcmf_iscan_params_le, params_le); - struct brcmf_iscan_params_le *params; - s32 err = 0; - - if (ssid && ssid->SSID_len) - params_size += sizeof(struct brcmf_ssid); - params = kzalloc(params_size, GFP_KERNEL); - if (!params) - return -ENOMEM; - BUG_ON(params_size >= BRCMF_DCMD_SMLEN); - - wl_iscan_prep(¶ms->params_le, ssid); - - params->version = cpu_to_le32(BRCMF_ISCAN_REQ_VERSION); - params->action = cpu_to_le16(action); - params->scan_duration = cpu_to_le16(0); - - err = brcmf_dev_iovar_setbuf(iscan->ndev, "iscan", params, params_size, - iscan->dcmd_buf, BRCMF_DCMD_SMLEN); - if (err) { - if (err == -EBUSY) - WL_INFO("system busy : iscan canceled\n"); - else - WL_ERR("error (%d)\n", err); - } - - kfree(params); - return err; -} - -static s32 brcmf_do_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - struct brcmf_ssid ssid; - s32 passive_scan; - s32 err = 0; - - /* Broadcast scan by default */ - memset(&ssid, 0, sizeof(ssid)); - - iscan->state = WL_ISCAN_STATE_SCANING; - - passive_scan = cfg_priv->active_scan ? 0 : 1; - err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCMF_C_SET_PASSIVE_SCAN, - &passive_scan, sizeof(passive_scan)); - if (err) { - WL_ERR("error (%d)\n", err); - return err; - } - brcmf_set_mpc(ndev, 0); - cfg_priv->iscan_kickstart = true; - err = brcmf_run_iscan(iscan, &ssid, BRCMF_SCAN_ACTION_START); - if (err) { - brcmf_set_mpc(ndev, 1); - cfg_priv->iscan_kickstart = false; - return err; - } - mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); - iscan->timer_on = 1; - return err; -} - -static s32 -__brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_scan_request *request, - struct cfg80211_ssid *this_ssid) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct cfg80211_ssid *ssids; - struct brcmf_cfg80211_scan_req *sr = cfg_priv->scan_req_int; - s32 passive_scan; - bool iscan_req; - bool spec_scan; - s32 err = 0; - u32 SSID_len; - - if (test_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { - WL_ERR("Scanning already : status (%lu)\n", cfg_priv->status); - return -EAGAIN; - } - if (test_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status)) { - WL_ERR("Scanning being aborted : status (%lu)\n", - cfg_priv->status); - return -EAGAIN; - } - if (test_bit(WL_STATUS_CONNECTING, &cfg_priv->status)) { - WL_ERR("Connecting : status (%lu)\n", - cfg_priv->status); - return -EAGAIN; - } - - iscan_req = false; - spec_scan = false; - if (request) { - /* scan bss */ - ssids = request->ssids; - if (cfg_priv->iscan_on && (!ssids || !ssids->ssid_len)) - iscan_req = true; - } else { - /* scan in ibss */ - /* we don't do iscan in ibss */ - ssids = this_ssid; - } - - cfg_priv->scan_request = request; - set_bit(WL_STATUS_SCANNING, &cfg_priv->status); - if (iscan_req) { - err = brcmf_do_iscan(cfg_priv); - if (!err) - return err; - else - goto scan_out; - } else { - WL_SCAN("ssid \"%s\", ssid_len (%d)\n", - ssids->ssid, ssids->ssid_len); - memset(&sr->ssid_le, 0, sizeof(sr->ssid_le)); - SSID_len = min_t(u8, sizeof(sr->ssid_le.SSID), ssids->ssid_len); - sr->ssid_le.SSID_len = cpu_to_le32(0); - if (SSID_len) { - memcpy(sr->ssid_le.SSID, ssids->ssid, SSID_len); - sr->ssid_le.SSID_len = cpu_to_le32(SSID_len); - spec_scan = true; - } else { - WL_SCAN("Broadcast scan\n"); - } - - passive_scan = cfg_priv->active_scan ? 0 : 1; - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_PASSIVE_SCAN, - &passive_scan, sizeof(passive_scan)); - if (err) { - WL_ERR("WLC_SET_PASSIVE_SCAN error (%d)\n", err); - goto scan_out; - } - brcmf_set_mpc(ndev, 0); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SCAN, &sr->ssid_le, - sizeof(sr->ssid_le)); - if (err) { - if (err == -EBUSY) - WL_INFO("system busy : scan for \"%s\" " - "canceled\n", sr->ssid_le.SSID); - else - WL_ERR("WLC_SCAN error (%d)\n", err); - - brcmf_set_mpc(ndev, 1); - goto scan_out; - } - } - - return 0; - -scan_out: - clear_bit(WL_STATUS_SCANNING, &cfg_priv->status); - cfg_priv->scan_request = NULL; - return err; -} - -static s32 -brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_scan_request *request) -{ - s32 err = 0; - - WL_TRACE("Enter\n"); - - if (!check_sys_up(wiphy)) - return -EIO; - - err = __brcmf_cfg80211_scan(wiphy, ndev, request, NULL); - if (err) - WL_ERR("scan error (%d)\n", err); - - WL_TRACE("Exit\n"); - return err; -} - -static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold) -{ - s32 err = 0; - - err = brcmf_dev_intvar_set(ndev, "rtsthresh", rts_threshold); - if (err) - WL_ERR("Error (%d)\n", err); - - return err; -} - -static s32 brcmf_set_frag(struct net_device *ndev, u32 frag_threshold) -{ - s32 err = 0; - - err = brcmf_dev_intvar_set(ndev, "fragthresh", frag_threshold); - if (err) - WL_ERR("Error (%d)\n", err); - - return err; -} - -static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l) -{ - s32 err = 0; - u32 cmd = (l ? BRCM_SET_LRL : BRCM_SET_SRL); - - err = brcmf_exec_dcmd_u32(ndev, cmd, &retry); - if (err) { - WL_ERR("cmd (%d) , error (%d)\n", cmd, err); - return err; - } - return err; -} - -static s32 brcmf_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - if (changed & WIPHY_PARAM_RTS_THRESHOLD && - (cfg_priv->conf->rts_threshold != wiphy->rts_threshold)) { - cfg_priv->conf->rts_threshold = wiphy->rts_threshold; - err = brcmf_set_rts(ndev, cfg_priv->conf->rts_threshold); - if (!err) - goto done; - } - if (changed & WIPHY_PARAM_FRAG_THRESHOLD && - (cfg_priv->conf->frag_threshold != wiphy->frag_threshold)) { - cfg_priv->conf->frag_threshold = wiphy->frag_threshold; - err = brcmf_set_frag(ndev, cfg_priv->conf->frag_threshold); - if (!err) - goto done; - } - if (changed & WIPHY_PARAM_RETRY_LONG - && (cfg_priv->conf->retry_long != wiphy->retry_long)) { - cfg_priv->conf->retry_long = wiphy->retry_long; - err = brcmf_set_retry(ndev, cfg_priv->conf->retry_long, true); - if (!err) - goto done; - } - if (changed & WIPHY_PARAM_RETRY_SHORT - && (cfg_priv->conf->retry_short != wiphy->retry_short)) { - cfg_priv->conf->retry_short = wiphy->retry_short; - err = brcmf_set_retry(ndev, cfg_priv->conf->retry_short, false); - if (!err) - goto done; - } - -done: - WL_TRACE("Exit\n"); - return err; -} - -static void *brcmf_read_prof(struct brcmf_cfg80211_priv *cfg_priv, s32 item) -{ - switch (item) { - case WL_PROF_SEC: - return &cfg_priv->profile->sec; - case WL_PROF_BSSID: - return &cfg_priv->profile->bssid; - case WL_PROF_SSID: - return &cfg_priv->profile->ssid; - } - WL_ERR("invalid item (%d)\n", item); - return NULL; -} - -static s32 -brcmf_update_prof(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e, void *data, s32 item) -{ - s32 err = 0; - struct brcmf_ssid *ssid; - - switch (item) { - case WL_PROF_SSID: - ssid = (struct brcmf_ssid *) data; - memset(cfg_priv->profile->ssid.SSID, 0, - sizeof(cfg_priv->profile->ssid.SSID)); - memcpy(cfg_priv->profile->ssid.SSID, - ssid->SSID, ssid->SSID_len); - cfg_priv->profile->ssid.SSID_len = ssid->SSID_len; - break; - case WL_PROF_BSSID: - if (data) - memcpy(cfg_priv->profile->bssid, data, ETH_ALEN); - else - memset(cfg_priv->profile->bssid, 0, ETH_ALEN); - break; - case WL_PROF_SEC: - memcpy(&cfg_priv->profile->sec, data, - sizeof(cfg_priv->profile->sec)); - break; - case WL_PROF_BEACONINT: - cfg_priv->profile->beacon_interval = *(u16 *)data; - break; - case WL_PROF_DTIMPERIOD: - cfg_priv->profile->dtim_period = *(u8 *)data; - break; - default: - WL_ERR("unsupported item (%d)\n", item); - err = -EOPNOTSUPP; - break; - } - - return err; -} - -static void brcmf_init_prof(struct brcmf_cfg80211_profile *prof) -{ - memset(prof, 0, sizeof(*prof)); -} - -static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, - size_t *join_params_size) -{ - u16 chanspec = 0; - - if (ch != 0) { - if (ch <= CH_MAX_2G_CHANNEL) - chanspec |= WL_CHANSPEC_BAND_2G; - else - chanspec |= WL_CHANSPEC_BAND_5G; - - chanspec |= WL_CHANSPEC_BW_20; - chanspec |= WL_CHANSPEC_CTL_SB_NONE; - - *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + - sizeof(u16); - - chanspec |= (ch & WL_CHANSPEC_CHAN_MASK); - join_params->params_le.chanspec_list[0] = cpu_to_le16(chanspec); - join_params->params_le.chanspec_num = cpu_to_le32(1); - - WL_CONN("join_params->params.chanspec_list[0]= %#X," - "channel %d, chanspec %#X\n", - chanspec, ch, chanspec); - } -} - -static void brcmf_link_down(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct net_device *ndev = NULL; - s32 err = 0; - - WL_TRACE("Enter\n"); - - if (cfg_priv->link_up) { - ndev = cfg_to_ndev(cfg_priv); - WL_INFO("Call WLC_DISASSOC to stop excess roaming\n "); - err = brcmf_exec_dcmd(ndev, BRCMF_C_DISASSOC, NULL, 0); - if (err) - WL_ERR("WLC_DISASSOC failed (%d)\n", err); - cfg_priv->link_up = false; - } - WL_TRACE("Exit\n"); -} - -static s32 -brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_ibss_params *params) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_join_params join_params; - size_t join_params_size = 0; - s32 err = 0; - s32 wsec = 0; - s32 bcnprd; - struct brcmf_ssid ssid; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - if (params->ssid) - WL_CONN("SSID: %s\n", params->ssid); - else { - WL_CONN("SSID: NULL, Not supported\n"); - return -EOPNOTSUPP; - } - - set_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - - if (params->bssid) - WL_CONN("BSSID: %02X %02X %02X %02X %02X %02X\n", - params->bssid[0], params->bssid[1], params->bssid[2], - params->bssid[3], params->bssid[4], params->bssid[5]); - else - WL_CONN("No BSSID specified\n"); - - if (params->channel) - WL_CONN("channel: %d\n", params->channel->center_freq); - else - WL_CONN("no channel specified\n"); - - if (params->channel_fixed) - WL_CONN("fixed channel required\n"); - else - WL_CONN("no fixed channel required\n"); - - if (params->ie && params->ie_len) - WL_CONN("ie len: %d\n", params->ie_len); - else - WL_CONN("no ie specified\n"); - - if (params->beacon_interval) - WL_CONN("beacon interval: %d\n", params->beacon_interval); - else - WL_CONN("no beacon interval specified\n"); - - if (params->basic_rates) - WL_CONN("basic rates: %08X\n", params->basic_rates); - else - WL_CONN("no basic rates specified\n"); - - if (params->privacy) - WL_CONN("privacy required\n"); - else - WL_CONN("no privacy required\n"); - - /* Configure Privacy for starter */ - if (params->privacy) - wsec |= WEP_ENABLED; - - err = brcmf_dev_intvar_set(ndev, "wsec", wsec); - if (err) { - WL_ERR("wsec failed (%d)\n", err); - goto done; - } - - /* Configure Beacon Interval for starter */ - if (params->beacon_interval) - bcnprd = params->beacon_interval; - else - bcnprd = 100; - - err = brcmf_exec_dcmd_u32(ndev, BRCM_SET_BCNPRD, &bcnprd); - if (err) { - WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err); - goto done; - } - - /* Configure required join parameter */ - memset(&join_params, 0, sizeof(struct brcmf_join_params)); - - /* SSID */ - ssid.SSID_len = min_t(u32, params->ssid_len, 32); - memcpy(ssid.SSID, params->ssid, ssid.SSID_len); - memcpy(join_params.ssid_le.SSID, params->ssid, ssid.SSID_len); - join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); - join_params_size = sizeof(join_params.ssid_le); - brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); - - /* BSSID */ - if (params->bssid) { - memcpy(join_params.params_le.bssid, params->bssid, ETH_ALEN); - join_params_size = sizeof(join_params.ssid_le) + - BRCMF_ASSOC_PARAMS_FIXED_SIZE; - } else { - memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); - } - - brcmf_update_prof(cfg_priv, NULL, - &join_params.params_le.bssid, WL_PROF_BSSID); - - /* Channel */ - if (params->channel) { - u32 target_channel; - - cfg_priv->channel = - ieee80211_frequency_to_channel( - params->channel->center_freq); - if (params->channel_fixed) { - /* adding chanspec */ - brcmf_ch_to_chanspec(cfg_priv->channel, - &join_params, &join_params_size); - } - - /* set channel for starter */ - target_channel = cfg_priv->channel; - err = brcmf_exec_dcmd_u32(ndev, BRCM_SET_CHANNEL, - &target_channel); - if (err) { - WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err); - goto done; - } - } else - cfg_priv->channel = 0; - - cfg_priv->ibss_starter = false; - - - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SSID, - &join_params, join_params_size); - if (err) { - WL_ERR("WLC_SET_SSID failed (%d)\n", err); - goto done; - } - -done: - if (err) - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - brcmf_link_down(cfg_priv); - - WL_TRACE("Exit\n"); - - return err; -} - -static s32 brcmf_set_wpa_version(struct net_device *ndev, - struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct brcmf_cfg80211_security *sec; - s32 val = 0; - s32 err = 0; - - if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) - val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED; - else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) - val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED; - else - val = WPA_AUTH_DISABLED; - WL_CONN("setting wpa_auth to 0x%0x\n", val); - err = brcmf_dev_intvar_set(ndev, "wpa_auth", val); - if (err) { - WL_ERR("set wpa_auth failed (%d)\n", err); - return err; - } - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - sec->wpa_versions = sme->crypto.wpa_versions; - return err; -} - -static s32 brcmf_set_auth_type(struct net_device *ndev, - struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct brcmf_cfg80211_security *sec; - s32 val = 0; - s32 err = 0; - - switch (sme->auth_type) { - case NL80211_AUTHTYPE_OPEN_SYSTEM: - val = 0; - WL_CONN("open system\n"); - break; - case NL80211_AUTHTYPE_SHARED_KEY: - val = 1; - WL_CONN("shared key\n"); - break; - case NL80211_AUTHTYPE_AUTOMATIC: - val = 2; - WL_CONN("automatic\n"); - break; - case NL80211_AUTHTYPE_NETWORK_EAP: - WL_CONN("network eap\n"); - default: - val = 2; - WL_ERR("invalid auth type (%d)\n", sme->auth_type); - break; - } - - err = brcmf_dev_intvar_set(ndev, "auth", val); - if (err) { - WL_ERR("set auth failed (%d)\n", err); - return err; - } - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - sec->auth_type = sme->auth_type; - return err; -} - -static s32 -brcmf_set_set_cipher(struct net_device *ndev, - struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct brcmf_cfg80211_security *sec; - s32 pval = 0; - s32 gval = 0; - s32 err = 0; - - if (sme->crypto.n_ciphers_pairwise) { - switch (sme->crypto.ciphers_pairwise[0]) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - pval = WEP_ENABLED; - break; - case WLAN_CIPHER_SUITE_TKIP: - pval = TKIP_ENABLED; - break; - case WLAN_CIPHER_SUITE_CCMP: - pval = AES_ENABLED; - break; - case WLAN_CIPHER_SUITE_AES_CMAC: - pval = AES_ENABLED; - break; - default: - WL_ERR("invalid cipher pairwise (%d)\n", - sme->crypto.ciphers_pairwise[0]); - return -EINVAL; - } - } - if (sme->crypto.cipher_group) { - switch (sme->crypto.cipher_group) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - gval = WEP_ENABLED; - break; - case WLAN_CIPHER_SUITE_TKIP: - gval = TKIP_ENABLED; - break; - case WLAN_CIPHER_SUITE_CCMP: - gval = AES_ENABLED; - break; - case WLAN_CIPHER_SUITE_AES_CMAC: - gval = AES_ENABLED; - break; - default: - WL_ERR("invalid cipher group (%d)\n", - sme->crypto.cipher_group); - return -EINVAL; - } - } - - WL_CONN("pval (%d) gval (%d)\n", pval, gval); - err = brcmf_dev_intvar_set(ndev, "wsec", pval | gval); - if (err) { - WL_ERR("error (%d)\n", err); - return err; - } - - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - sec->cipher_pairwise = sme->crypto.ciphers_pairwise[0]; - sec->cipher_group = sme->crypto.cipher_group; - - return err; -} - -static s32 -brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct brcmf_cfg80211_security *sec; - s32 val = 0; - s32 err = 0; - - if (sme->crypto.n_akm_suites) { - err = brcmf_dev_intvar_get(ndev, "wpa_auth", &val); - if (err) { - WL_ERR("could not get wpa_auth (%d)\n", err); - return err; - } - if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) { - switch (sme->crypto.akm_suites[0]) { - case WLAN_AKM_SUITE_8021X: - val = WPA_AUTH_UNSPECIFIED; - break; - case WLAN_AKM_SUITE_PSK: - val = WPA_AUTH_PSK; - break; - default: - WL_ERR("invalid cipher group (%d)\n", - sme->crypto.cipher_group); - return -EINVAL; - } - } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) { - switch (sme->crypto.akm_suites[0]) { - case WLAN_AKM_SUITE_8021X: - val = WPA2_AUTH_UNSPECIFIED; - break; - case WLAN_AKM_SUITE_PSK: - val = WPA2_AUTH_PSK; - break; - default: - WL_ERR("invalid cipher group (%d)\n", - sme->crypto.cipher_group); - return -EINVAL; - } - } - - WL_CONN("setting wpa_auth to %d\n", val); - err = brcmf_dev_intvar_set(ndev, "wpa_auth", val); - if (err) { - WL_ERR("could not set wpa_auth (%d)\n", err); - return err; - } - } - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - sec->wpa_auth = sme->crypto.akm_suites[0]; - - return err; -} - -static s32 -brcmf_set_set_sharedkey(struct net_device *ndev, - struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - struct brcmf_cfg80211_security *sec; - struct brcmf_wsec_key key; - s32 val; - s32 err = 0; - - WL_CONN("key len (%d)\n", sme->key_len); - if (sme->key_len) { - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - WL_CONN("wpa_versions 0x%x cipher_pairwise 0x%x\n", - sec->wpa_versions, sec->cipher_pairwise); - if (! - (sec->wpa_versions & (NL80211_WPA_VERSION_1 | - NL80211_WPA_VERSION_2)) -&& (sec->cipher_pairwise & (WLAN_CIPHER_SUITE_WEP40 | - WLAN_CIPHER_SUITE_WEP104))) { - memset(&key, 0, sizeof(key)); - key.len = (u32) sme->key_len; - key.index = (u32) sme->key_idx; - if (key.len > sizeof(key.data)) { - WL_ERR("Too long key length (%u)\n", key.len); - return -EINVAL; - } - memcpy(key.data, sme->key, key.len); - key.flags = BRCMF_PRIMARY_KEY; - switch (sec->cipher_pairwise) { - case WLAN_CIPHER_SUITE_WEP40: - key.algo = CRYPTO_ALGO_WEP1; - break; - case WLAN_CIPHER_SUITE_WEP104: - key.algo = CRYPTO_ALGO_WEP128; - break; - default: - WL_ERR("Invalid algorithm (%d)\n", - sme->crypto.ciphers_pairwise[0]); - return -EINVAL; - } - /* Set the new key/index */ - WL_CONN("key length (%d) key index (%d) algo (%d)\n", - key.len, key.index, key.algo); - WL_CONN("key \"%s\"\n", key.data); - err = send_key_to_dongle(ndev, &key); - if (err) - return err; - - if (sec->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) { - WL_CONN("set auth_type to shared key\n"); - val = 1; /* shared key */ - err = brcmf_dev_intvar_set(ndev, "auth", val); - if (err) { - WL_ERR("set auth failed (%d)\n", err); - return err; - } - } - } - } - return err; -} - -static s32 -brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_connect_params *sme) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct ieee80211_channel *chan = sme->channel; - struct brcmf_join_params join_params; - size_t join_params_size; - struct brcmf_ssid ssid; - - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - if (!sme->ssid) { - WL_ERR("Invalid ssid\n"); - return -EOPNOTSUPP; - } - - set_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - - if (chan) { - cfg_priv->channel = - ieee80211_frequency_to_channel(chan->center_freq); - WL_CONN("channel (%d), center_req (%d)\n", - cfg_priv->channel, chan->center_freq); - } else - cfg_priv->channel = 0; - - WL_INFO("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len); - - err = brcmf_set_wpa_version(ndev, sme); - if (err) { - WL_ERR("wl_set_wpa_version failed (%d)\n", err); - goto done; - } - - err = brcmf_set_auth_type(ndev, sme); - if (err) { - WL_ERR("wl_set_auth_type failed (%d)\n", err); - goto done; - } - - err = brcmf_set_set_cipher(ndev, sme); - if (err) { - WL_ERR("wl_set_set_cipher failed (%d)\n", err); - goto done; - } - - err = brcmf_set_key_mgmt(ndev, sme); - if (err) { - WL_ERR("wl_set_key_mgmt failed (%d)\n", err); - goto done; - } - - err = brcmf_set_set_sharedkey(ndev, sme); - if (err) { - WL_ERR("wl_set_set_sharedkey failed (%d)\n", err); - goto done; - } - - memset(&join_params, 0, sizeof(join_params)); - join_params_size = sizeof(join_params.ssid_le); - - ssid.SSID_len = min_t(u32, sizeof(ssid.SSID), sme->ssid_len); - memcpy(&join_params.ssid_le.SSID, sme->ssid, ssid.SSID_len); - memcpy(&ssid.SSID, sme->ssid, ssid.SSID_len); - join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); - brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); - - memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); - - if (ssid.SSID_len < IEEE80211_MAX_SSID_LEN) - WL_CONN("ssid \"%s\", len (%d)\n", - ssid.SSID, ssid.SSID_len); - - brcmf_ch_to_chanspec(cfg_priv->channel, - &join_params, &join_params_size); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SSID, - &join_params, join_params_size); - if (err) - WL_ERR("WLC_SET_SSID failed (%d)\n", err); - -done: - if (err) - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev, - u16 reason_code) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_scb_val_le scbval; - s32 err = 0; - - WL_TRACE("Enter. Reason code = %d\n", reason_code); - if (!check_sys_up(wiphy)) - return -EIO; - - clear_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - - memcpy(&scbval.ea, brcmf_read_prof(cfg_priv, WL_PROF_BSSID), ETH_ALEN); - scbval.val = cpu_to_le32(reason_code); - err = brcmf_exec_dcmd(ndev, BRCMF_C_DISASSOC, &scbval, - sizeof(struct brcmf_scb_val_le)); - if (err) - WL_ERR("error (%d)\n", err); - - cfg_priv->link_up = false; - - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, - enum nl80211_tx_power_setting type, s32 dbm) -{ - - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - u16 txpwrmw; - s32 err = 0; - s32 disable = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - switch (type) { - case NL80211_TX_POWER_AUTOMATIC: - break; - case NL80211_TX_POWER_LIMITED: - if (dbm < 0) { - WL_ERR("TX_POWER_LIMITED - dbm is negative\n"); - err = -EINVAL; - goto done; - } - break; - case NL80211_TX_POWER_FIXED: - if (dbm < 0) { - WL_ERR("TX_POWER_FIXED - dbm is negative\n"); - err = -EINVAL; - goto done; - } - break; - } - /* Make sure radio is off or on as far as software is concerned */ - disable = WL_RADIO_SW_DISABLE << 16; - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_RADIO, &disable); - if (err) - WL_ERR("WLC_SET_RADIO error (%d)\n", err); - - if (dbm > 0xffff) - txpwrmw = 0xffff; - else - txpwrmw = (u16) dbm; - err = brcmf_dev_intvar_set(ndev, "qtxpower", - (s32) (brcmu_mw_to_qdbm(txpwrmw))); - if (err) - WL_ERR("qtxpower error (%d)\n", err); - cfg_priv->conf->tx_power = dbm; - -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - s32 txpwrdbm; - u8 result; - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - err = brcmf_dev_intvar_get(ndev, "qtxpower", &txpwrdbm); - if (err) { - WL_ERR("error (%d)\n", err); - goto done; - } - - result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE); - *dbm = (s32) brcmu_qdbm_to_mw(result); - -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_idx, bool unicast, bool multicast) -{ - u32 index; - u32 wsec; - s32 err = 0; - - WL_TRACE("Enter\n"); - WL_CONN("key index (%d)\n", key_idx); - if (!check_sys_up(wiphy)) - return -EIO; - - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_WSEC, &wsec); - if (err) { - WL_ERR("WLC_GET_WSEC error (%d)\n", err); - goto done; - } - - if (wsec & WEP_ENABLED) { - /* Just select a new current key */ - index = key_idx; - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_KEY_PRIMARY, - &index); - if (err) - WL_ERR("error (%d)\n", err); - } -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_add_keyext(struct wiphy *wiphy, struct net_device *ndev, - u8 key_idx, const u8 *mac_addr, struct key_params *params) -{ - struct brcmf_wsec_key key; - struct brcmf_wsec_key_le key_le; - s32 err = 0; - - memset(&key, 0, sizeof(key)); - key.index = (u32) key_idx; - /* Instead of bcast for ea address for default wep keys, - driver needs it to be Null */ - if (!is_multicast_ether_addr(mac_addr)) - memcpy((char *)&key.ea, (void *)mac_addr, ETH_ALEN); - key.len = (u32) params->key_len; - /* check for key index change */ - if (key.len == 0) { - /* key delete */ - err = send_key_to_dongle(ndev, &key); - if (err) - return err; - } else { - if (key.len > sizeof(key.data)) { - WL_ERR("Invalid key length (%d)\n", key.len); - return -EINVAL; - } - - WL_CONN("Setting the key index %d\n", key.index); - memcpy(key.data, params->key, key.len); - - if (params->cipher == WLAN_CIPHER_SUITE_TKIP) { - u8 keybuf[8]; - memcpy(keybuf, &key.data[24], sizeof(keybuf)); - memcpy(&key.data[24], &key.data[16], sizeof(keybuf)); - memcpy(&key.data[16], keybuf, sizeof(keybuf)); - } - - /* if IW_ENCODE_EXT_RX_SEQ_VALID set */ - if (params->seq && params->seq_len == 6) { - /* rx iv */ - u8 *ivptr; - ivptr = (u8 *) params->seq; - key.rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) | - (ivptr[3] << 8) | ivptr[2]; - key.rxiv.lo = (ivptr[1] << 8) | ivptr[0]; - key.iv_initialized = true; - } - - switch (params->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - key.algo = CRYPTO_ALGO_WEP1; - WL_CONN("WLAN_CIPHER_SUITE_WEP40\n"); - break; - case WLAN_CIPHER_SUITE_WEP104: - key.algo = CRYPTO_ALGO_WEP128; - WL_CONN("WLAN_CIPHER_SUITE_WEP104\n"); - break; - case WLAN_CIPHER_SUITE_TKIP: - key.algo = CRYPTO_ALGO_TKIP; - WL_CONN("WLAN_CIPHER_SUITE_TKIP\n"); - break; - case WLAN_CIPHER_SUITE_AES_CMAC: - key.algo = CRYPTO_ALGO_AES_CCM; - WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n"); - break; - case WLAN_CIPHER_SUITE_CCMP: - key.algo = CRYPTO_ALGO_AES_CCM; - WL_CONN("WLAN_CIPHER_SUITE_CCMP\n"); - break; - default: - WL_ERR("Invalid cipher (0x%x)\n", params->cipher); - return -EINVAL; - } - convert_key_from_CPU(&key, &key_le); - - brcmf_netdev_wait_pend8021x(ndev); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_KEY, &key_le, - sizeof(key_le)); - if (err) { - WL_ERR("WLC_SET_KEY error (%d)\n", err); - return err; - } - } - return err; -} - -static s32 -brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_idx, bool pairwise, const u8 *mac_addr, - struct key_params *params) -{ - struct brcmf_wsec_key key; - s32 val; - s32 wsec; - s32 err = 0; - u8 keybuf[8]; - - WL_TRACE("Enter\n"); - WL_CONN("key index (%d)\n", key_idx); - if (!check_sys_up(wiphy)) - return -EIO; - - if (mac_addr) { - WL_TRACE("Exit"); - return brcmf_add_keyext(wiphy, ndev, key_idx, mac_addr, params); - } - memset(&key, 0, sizeof(key)); - - key.len = (u32) params->key_len; - key.index = (u32) key_idx; - - if (key.len > sizeof(key.data)) { - WL_ERR("Too long key length (%u)\n", key.len); - err = -EINVAL; - goto done; - } - memcpy(key.data, params->key, key.len); - - key.flags = BRCMF_PRIMARY_KEY; - switch (params->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - key.algo = CRYPTO_ALGO_WEP1; - WL_CONN("WLAN_CIPHER_SUITE_WEP40\n"); - break; - case WLAN_CIPHER_SUITE_WEP104: - key.algo = CRYPTO_ALGO_WEP128; - WL_CONN("WLAN_CIPHER_SUITE_WEP104\n"); - break; - case WLAN_CIPHER_SUITE_TKIP: - memcpy(keybuf, &key.data[24], sizeof(keybuf)); - memcpy(&key.data[24], &key.data[16], sizeof(keybuf)); - memcpy(&key.data[16], keybuf, sizeof(keybuf)); - key.algo = CRYPTO_ALGO_TKIP; - WL_CONN("WLAN_CIPHER_SUITE_TKIP\n"); - break; - case WLAN_CIPHER_SUITE_AES_CMAC: - key.algo = CRYPTO_ALGO_AES_CCM; - WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n"); - break; - case WLAN_CIPHER_SUITE_CCMP: - key.algo = CRYPTO_ALGO_AES_CCM; - WL_CONN("WLAN_CIPHER_SUITE_CCMP\n"); - break; - default: - WL_ERR("Invalid cipher (0x%x)\n", params->cipher); - err = -EINVAL; - goto done; - } - - err = send_key_to_dongle(ndev, &key); /* Set the new key/index */ - if (err) - goto done; - - val = WEP_ENABLED; - err = brcmf_dev_intvar_get(ndev, "wsec", &wsec); - if (err) { - WL_ERR("get wsec error (%d)\n", err); - goto done; - } - wsec &= ~(WEP_ENABLED); - wsec |= val; - err = brcmf_dev_intvar_set(ndev, "wsec", wsec); - if (err) { - WL_ERR("set wsec error (%d)\n", err); - goto done; - } - - val = 1; /* assume shared key. otherwise 0 */ - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_AUTH, &val); - if (err) - WL_ERR("WLC_SET_AUTH error (%d)\n", err); -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_idx, bool pairwise, const u8 *mac_addr) -{ - struct brcmf_wsec_key key; - s32 err = 0; - s32 val; - s32 wsec; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - memset(&key, 0, sizeof(key)); - - key.index = (u32) key_idx; - key.flags = BRCMF_PRIMARY_KEY; - key.algo = CRYPTO_ALGO_OFF; - - WL_CONN("key index (%d)\n", key_idx); - - /* Set the new key/index */ - err = send_key_to_dongle(ndev, &key); - if (err) { - if (err == -EINVAL) { - if (key.index >= DOT11_MAX_DEFAULT_KEYS) - /* we ignore this key index in this case */ - WL_ERR("invalid key index (%d)\n", key_idx); - } - /* Ignore this error, may happen during DISASSOC */ - err = -EAGAIN; - goto done; - } - - val = 0; - err = brcmf_dev_intvar_get(ndev, "wsec", &wsec); - if (err) { - WL_ERR("get wsec error (%d)\n", err); - /* Ignore this error, may happen during DISASSOC */ - err = -EAGAIN; - goto done; - } - wsec &= ~(WEP_ENABLED); - wsec |= val; - err = brcmf_dev_intvar_set(ndev, "wsec", wsec); - if (err) { - WL_ERR("set wsec error (%d)\n", err); - /* Ignore this error, may happen during DISASSOC */ - err = -EAGAIN; - goto done; - } - - val = 0; /* assume open key. otherwise 1 */ - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_AUTH, &val); - if (err) { - WL_ERR("WLC_SET_AUTH error (%d)\n", err); - /* Ignore this error, may happen during DISASSOC */ - err = -EAGAIN; - } -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, - u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie, - void (*callback) (void *cookie, struct key_params * params)) -{ - struct key_params params; - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_cfg80211_security *sec; - s32 wsec; - s32 err = 0; - - WL_TRACE("Enter\n"); - WL_CONN("key index (%d)\n", key_idx); - if (!check_sys_up(wiphy)) - return -EIO; - - memset(¶ms, 0, sizeof(params)); - - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_WSEC, &wsec); - if (err) { - WL_ERR("WLC_GET_WSEC error (%d)\n", err); - /* Ignore this error, may happen during DISASSOC */ - err = -EAGAIN; - goto done; - } - switch (wsec) { - case WEP_ENABLED: - sec = brcmf_read_prof(cfg_priv, WL_PROF_SEC); - if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP40) { - params.cipher = WLAN_CIPHER_SUITE_WEP40; - WL_CONN("WLAN_CIPHER_SUITE_WEP40\n"); - } else if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP104) { - params.cipher = WLAN_CIPHER_SUITE_WEP104; - WL_CONN("WLAN_CIPHER_SUITE_WEP104\n"); - } - break; - case TKIP_ENABLED: - params.cipher = WLAN_CIPHER_SUITE_TKIP; - WL_CONN("WLAN_CIPHER_SUITE_TKIP\n"); - break; - case AES_ENABLED: - params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; - WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n"); - break; - default: - WL_ERR("Invalid algo (0x%x)\n", wsec); - err = -EINVAL; - goto done; - } - callback(cookie, ¶ms); - -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_idx) -{ - WL_INFO("Not supported\n"); - - return -EOPNOTSUPP; -} - -static s32 -brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, - u8 *mac, struct station_info *sinfo) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct brcmf_scb_val_le scb_val; - int rssi; - s32 rate; - s32 err = 0; - u8 *bssid = brcmf_read_prof(cfg_priv, WL_PROF_BSSID); - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - if (memcmp(mac, bssid, ETH_ALEN)) { - WL_ERR("Wrong Mac address cfg_mac-%X:%X:%X:%X:%X:%X" - "wl_bssid-%X:%X:%X:%X:%X:%X\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - bssid[0], bssid[1], bssid[2], bssid[3], - bssid[4], bssid[5]); - err = -ENOENT; - goto done; - } - - /* Report the current tx rate */ - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_GET_RATE, &rate); - if (err) { - WL_ERR("Could not get rate (%d)\n", err); - } else { - sinfo->filled |= STATION_INFO_TX_BITRATE; - sinfo->txrate.legacy = rate * 5; - WL_CONN("Rate %d Mbps\n", rate / 2); - } - - if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { - scb_val.val = cpu_to_le32(0); - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_RSSI, &scb_val, - sizeof(struct brcmf_scb_val_le)); - if (err) - WL_ERR("Could not get rssi (%d)\n", err); - - rssi = le32_to_cpu(scb_val.val); - sinfo->filled |= STATION_INFO_SIGNAL; - sinfo->signal = rssi; - WL_CONN("RSSI %d dBm\n", rssi); - } - -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, - bool enabled, s32 timeout) -{ - s32 pm; - s32 err = 0; - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - - WL_TRACE("Enter\n"); - - /* - * Powersave enable/disable request is coming from the - * cfg80211 even before the interface is up. In that - * scenario, driver will be storing the power save - * preference in cfg_priv struct to apply this to - * FW later while initializing the dongle - */ - cfg_priv->pwr_save = enabled; - if (!test_bit(WL_STATUS_READY, &cfg_priv->status)) { - - WL_INFO("Device is not ready," - "storing the value in cfg_priv struct\n"); - goto done; - } - - pm = enabled ? PM_FAST : PM_OFF; - WL_INFO("power save %s\n", (pm ? "enabled" : "disabled")); - - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_PM, &pm); - if (err) { - if (err == -ENODEV) - WL_ERR("net_device is not ready yet\n"); - else - WL_ERR("error (%d)\n", err); - } -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *ndev, - const u8 *addr, - const struct cfg80211_bitrate_mask *mask) -{ - struct brcm_rateset_le rateset_le; - s32 rate; - s32 val; - s32 err_bg; - s32 err_a; - u32 legacy; - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - /* addr param is always NULL. ignore it */ - /* Get current rateset */ - err = brcmf_exec_dcmd(ndev, BRCM_GET_CURR_RATESET, &rateset_le, - sizeof(rateset_le)); - if (err) { - WL_ERR("could not get current rateset (%d)\n", err); - goto done; - } - - legacy = ffs(mask->control[IEEE80211_BAND_2GHZ].legacy & 0xFFFF); - if (!legacy) - legacy = ffs(mask->control[IEEE80211_BAND_5GHZ].legacy & - 0xFFFF); - - val = wl_g_rates[legacy - 1].bitrate * 100000; - - if (val < le32_to_cpu(rateset_le.count)) - /* Select rate by rateset index */ - rate = rateset_le.rates[val] & 0x7f; - else - /* Specified rate in bps */ - rate = val / 500000; - - WL_CONN("rate %d mbps\n", rate / 2); - - /* - * - * Set rate override, - * Since the is a/b/g-blind, both a/bg_rate are enforced. - */ - err_bg = brcmf_dev_intvar_set(ndev, "bg_rate", rate); - err_a = brcmf_dev_intvar_set(ndev, "a_rate", rate); - if (err_bg && err_a) { - WL_ERR("could not set fixed rate (%d) (%d)\n", err_bg, err_a); - err = err_bg | err_a; - } - -done: - WL_TRACE("Exit\n"); - return err; -} - -static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, - struct brcmf_bss_info *bi) -{ - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct ieee80211_channel *notify_channel; - struct cfg80211_bss *bss; - struct ieee80211_supported_band *band; - s32 err = 0; - u16 channel; - u32 freq; - u64 notify_timestamp; - u16 notify_capability; - u16 notify_interval; - u8 *notify_ie; - size_t notify_ielen; - s32 notify_signal; - - if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) { - WL_ERR("Bss info is larger than buffer. Discarding\n"); - return 0; - } - - channel = bi->ctl_ch ? bi->ctl_ch : - CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); - - if (channel <= CH_MAX_2G_CHANNEL) - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - else - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - - freq = ieee80211_channel_to_frequency(channel, band->band); - notify_channel = ieee80211_get_channel(wiphy, freq); - - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ - notify_capability = le16_to_cpu(bi->capability); - notify_interval = le16_to_cpu(bi->beacon_period); - notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le32_to_cpu(bi->ie_length); - notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; - - WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - bi->BSSID[0], bi->BSSID[1], bi->BSSID[2], - bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]); - WL_CONN("Channel: %d(%d)\n", channel, freq); - WL_CONN("Capability: %X\n", notify_capability); - WL_CONN("Beacon interval: %d\n", notify_interval); - WL_CONN("Signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); - - bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID, - notify_timestamp, notify_capability, notify_interval, notify_ie, - notify_ielen, notify_signal, GFP_KERNEL); - - if (!bss) { - WL_ERR("cfg80211_inform_bss_frame error\n"); - return -EINVAL; - } - - return err; -} - -static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_scan_results *bss_list; - struct brcmf_bss_info *bi = NULL; /* must be initialized */ - s32 err = 0; - int i; - - bss_list = cfg_priv->bss_list; - if (bss_list->version != BRCMF_BSS_INFO_VERSION) { - WL_ERR("Version %d != WL_BSS_INFO_VERSION\n", - bss_list->version); - return -EOPNOTSUPP; - } - WL_SCAN("scanned AP count (%d)\n", bss_list->count); - for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { - bi = next_bss(bss_list, bi); - err = brcmf_inform_single_bss(cfg_priv, bi); - if (err) - break; - } - return err; -} - -static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, const u8 *bssid) -{ - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct ieee80211_channel *notify_channel; - struct brcmf_bss_info *bi = NULL; - struct ieee80211_supported_band *band; - u8 *buf = NULL; - s32 err = 0; - u16 channel; - u32 freq; - u64 notify_timestamp; - u16 notify_capability; - u16 notify_interval; - u8 *notify_ie; - size_t notify_ielen; - s32 notify_signal; - - WL_TRACE("Enter\n"); - - buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); - if (buf == NULL) { - err = -ENOMEM; - goto CleanUp; - } - - *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); - - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX); - if (err) { - WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err); - goto CleanUp; - } - - bi = (struct brcmf_bss_info *)(buf + 4); - - channel = bi->ctl_ch ? bi->ctl_ch : - CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); - - if (channel <= CH_MAX_2G_CHANNEL) - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - else - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - - freq = ieee80211_channel_to_frequency(channel, band->band); - notify_channel = ieee80211_get_channel(wiphy, freq); - - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ - notify_capability = le16_to_cpu(bi->capability); - notify_interval = le16_to_cpu(bi->beacon_period); - notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); - notify_ielen = le32_to_cpu(bi->ie_length); - notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; - - WL_CONN("channel: %d(%d)\n", channel, freq); - WL_CONN("capability: %X\n", notify_capability); - WL_CONN("beacon interval: %d\n", notify_interval); - WL_CONN("signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); - - cfg80211_inform_bss(wiphy, notify_channel, bssid, - notify_timestamp, notify_capability, notify_interval, - notify_ie, notify_ielen, notify_signal, GFP_KERNEL); - -CleanUp: - - kfree(buf); - - WL_TRACE("Exit\n"); - - return err; -} - -static bool brcmf_is_ibssmode(struct brcmf_cfg80211_priv *cfg_priv) -{ - return cfg_priv->conf->mode == WL_MODE_IBSS; -} - -static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_bss_info *bi; - struct brcmf_ssid *ssid; - struct brcmu_tlv *tim; - u16 beacon_interval; - u8 dtim_period; - size_t ie_len; - u8 *ie; - s32 err = 0; - - WL_TRACE("Enter\n"); - if (brcmf_is_ibssmode(cfg_priv)) - return err; - - ssid = (struct brcmf_ssid *)brcmf_read_prof(cfg_priv, WL_PROF_SSID); - - *(__le32 *)cfg_priv->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); - err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCMF_C_GET_BSS_INFO, - cfg_priv->extra_buf, WL_EXTRA_BUF_MAX); - if (err) { - WL_ERR("Could not get bss info %d\n", err); - goto update_bss_info_out; - } - - bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); - err = brcmf_inform_single_bss(cfg_priv, bi); - if (err) - goto update_bss_info_out; - - ie = ((u8 *)bi) + le16_to_cpu(bi->ie_offset); - ie_len = le32_to_cpu(bi->ie_length); - beacon_interval = le16_to_cpu(bi->beacon_period); - - tim = brcmu_parse_tlvs(ie, ie_len, WLAN_EID_TIM); - if (tim) - dtim_period = tim->data[1]; - else { - /* - * active scan was done so we could not get dtim - * information out of probe response. - * so we speficially query dtim information to dongle. - */ - u32 var; - err = brcmf_dev_intvar_get(cfg_to_ndev(cfg_priv), - "dtim_assoc", &var); - if (err) { - WL_ERR("wl dtim_assoc failed (%d)\n", err); - goto update_bss_info_out; - } - dtim_period = (u8)var; - } - - brcmf_update_prof(cfg_priv, NULL, &beacon_interval, WL_PROF_BEACONINT); - brcmf_update_prof(cfg_priv, NULL, &dtim_period, WL_PROF_DTIMPERIOD); - -update_bss_info_out: - WL_TRACE("Exit"); - return err; -} - -static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - struct brcmf_ssid ssid; - - if (cfg_priv->iscan_on) { - iscan->state = WL_ISCAN_STATE_IDLE; - - if (iscan->timer_on) { - del_timer_sync(&iscan->timer); - iscan->timer_on = 0; - } - - cancel_work_sync(&iscan->work); - - /* Abort iscan running in FW */ - memset(&ssid, 0, sizeof(ssid)); - brcmf_run_iscan(iscan, &ssid, WL_SCAN_ACTION_ABORT); - } -} - -static void brcmf_notify_iscan_complete(struct brcmf_cfg80211_iscan_ctrl *iscan, - bool aborted) -{ - struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - - if (!test_and_clear_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { - WL_ERR("Scan complete while device not scanning\n"); - return; - } - if (cfg_priv->scan_request) { - WL_SCAN("ISCAN Completed scan: %s\n", - aborted ? "Aborted" : "Done"); - cfg80211_scan_done(cfg_priv->scan_request, aborted); - brcmf_set_mpc(ndev, 1); - cfg_priv->scan_request = NULL; - } - cfg_priv->iscan_kickstart = false; -} - -static s32 brcmf_wakeup_iscan(struct brcmf_cfg80211_iscan_ctrl *iscan) -{ - if (iscan->state != WL_ISCAN_STATE_IDLE) { - WL_SCAN("wake up iscan\n"); - schedule_work(&iscan->work); - return 0; - } - - return -EIO; -} - -static s32 -brcmf_get_iscan_results(struct brcmf_cfg80211_iscan_ctrl *iscan, u32 *status, - struct brcmf_scan_results **bss_list) -{ - struct brcmf_iscan_results list; - struct brcmf_scan_results *results; - struct brcmf_scan_results_le *results_le; - struct brcmf_iscan_results *list_buf; - s32 err = 0; - - memset(iscan->scan_buf, 0, WL_ISCAN_BUF_MAX); - list_buf = (struct brcmf_iscan_results *)iscan->scan_buf; - results = &list_buf->results; - results_le = &list_buf->results_le; - results->buflen = BRCMF_ISCAN_RESULTS_FIXED_SIZE; - results->version = 0; - results->count = 0; - - memset(&list, 0, sizeof(list)); - list.results_le.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); - err = brcmf_dev_iovar_getbuf(iscan->ndev, "iscanresults", &list, - BRCMF_ISCAN_RESULTS_FIXED_SIZE, - iscan->scan_buf, WL_ISCAN_BUF_MAX); - if (err) { - WL_ERR("error (%d)\n", err); - return err; - } - results->buflen = le32_to_cpu(results_le->buflen); - results->version = le32_to_cpu(results_le->version); - results->count = le32_to_cpu(results_le->count); - WL_SCAN("results->count = %d\n", results_le->count); - WL_SCAN("results->buflen = %d\n", results_le->buflen); - *status = le32_to_cpu(list_buf->status_le); - WL_SCAN("status = %d\n", *status); - *bss_list = results; - - return err; -} - -static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - iscan->state = WL_ISCAN_STATE_IDLE; - brcmf_inform_bss(cfg_priv); - brcmf_notify_iscan_complete(iscan, false); - - return err; -} - -static s32 brcmf_iscan_pending(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - /* Reschedule the timer */ - mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); - iscan->timer_on = 1; - - return err; -} - -static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - brcmf_inform_bss(cfg_priv); - brcmf_run_iscan(iscan, NULL, BRCMF_SCAN_ACTION_CONTINUE); - /* Reschedule the timer */ - mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000); - iscan->timer_on = 1; - - return err; -} - -static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan; - s32 err = 0; - - iscan->state = WL_ISCAN_STATE_IDLE; - brcmf_notify_iscan_complete(iscan, true); - - return err; -} - -static void brcmf_cfg80211_iscan_handler(struct work_struct *work) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = - container_of(work, struct brcmf_cfg80211_iscan_ctrl, - work); - struct brcmf_cfg80211_priv *cfg_priv = iscan_to_cfg(iscan); - struct brcmf_cfg80211_iscan_eloop *el = &iscan->el; - u32 status = BRCMF_SCAN_RESULTS_PARTIAL; - - if (iscan->timer_on) { - del_timer_sync(&iscan->timer); - iscan->timer_on = 0; - } - - if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) { - status = BRCMF_SCAN_RESULTS_ABORTED; - WL_ERR("Abort iscan\n"); - } - - el->handler[status](cfg_priv); -} - -static void brcmf_iscan_timer(unsigned long data) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = - (struct brcmf_cfg80211_iscan_ctrl *)data; - - if (iscan) { - iscan->timer_on = 0; - WL_SCAN("timer expired\n"); - brcmf_wakeup_iscan(iscan); - } -} - -static s32 brcmf_invoke_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - - if (cfg_priv->iscan_on) { - iscan->state = WL_ISCAN_STATE_IDLE; - INIT_WORK(&iscan->work, brcmf_cfg80211_iscan_handler); - } - - return 0; -} - -static void brcmf_init_iscan_eloop(struct brcmf_cfg80211_iscan_eloop *el) -{ - memset(el, 0, sizeof(*el)); - el->handler[BRCMF_SCAN_RESULTS_SUCCESS] = brcmf_iscan_done; - el->handler[BRCMF_SCAN_RESULTS_PARTIAL] = brcmf_iscan_inprogress; - el->handler[BRCMF_SCAN_RESULTS_PENDING] = brcmf_iscan_pending; - el->handler[BRCMF_SCAN_RESULTS_ABORTED] = brcmf_iscan_aborted; - el->handler[BRCMF_SCAN_RESULTS_NO_MEM] = brcmf_iscan_aborted; -} - -static s32 brcmf_init_iscan(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_to_iscan(cfg_priv); - int err = 0; - - if (cfg_priv->iscan_on) { - iscan->ndev = cfg_to_ndev(cfg_priv); - brcmf_init_iscan_eloop(&iscan->el); - iscan->timer_ms = WL_ISCAN_TIMER_INTERVAL_MS; - init_timer(&iscan->timer); - iscan->timer.data = (unsigned long) iscan; - iscan->timer.function = brcmf_iscan_timer; - err = brcmf_invoke_iscan(cfg_priv); - if (!err) - iscan->data = cfg_priv; - } - - return err; -} - -static void brcmf_delay(u32 ms) -{ - if (ms < 1000 / HZ) { - cond_resched(); - mdelay(ms); - } else { - msleep(ms); - } -} - -static s32 brcmf_cfg80211_resume(struct wiphy *wiphy) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - - /* - * Check for WL_STATUS_READY before any function call which - * could result is bus access. Don't block the resume for - * any driver error conditions - */ - WL_TRACE("Enter\n"); - - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) - brcmf_invoke_iscan(wiphy_to_cfg(wiphy)); - - WL_TRACE("Exit\n"); - return 0; -} - -static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, - struct cfg80211_wowlan *wow) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct net_device *ndev = cfg_to_ndev(cfg_priv); - - WL_TRACE("Enter\n"); - - /* - * Check for WL_STATUS_READY before any function call which - * could result is bus access. Don't block the suspend for - * any driver error conditions - */ - - /* - * While going to suspend if associated with AP disassociate - * from AP to save power while system is in suspended state - */ - if ((test_bit(WL_STATUS_CONNECTED, &cfg_priv->status) || - test_bit(WL_STATUS_CONNECTING, &cfg_priv->status)) && - test_bit(WL_STATUS_READY, &cfg_priv->status)) { - WL_INFO("Disassociating from AP" - " while entering suspend state\n"); - brcmf_link_down(cfg_priv); - - /* - * Make sure WPA_Supplicant receives all the event - * generated due to DISASSOC call to the fw to keep - * the state fw and WPA_Supplicant state consistent - */ - brcmf_delay(500); - } - - set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) - brcmf_term_iscan(cfg_priv); - - if (cfg_priv->scan_request) { - /* Indidate scan abort to cfg80211 layer */ - WL_INFO("Terminating scan in progress\n"); - cfg80211_scan_done(cfg_priv->scan_request, true); - cfg_priv->scan_request = NULL; - } - clear_bit(WL_STATUS_SCANNING, &cfg_priv->status); - clear_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); - - /* Turn off watchdog timer */ - if (test_bit(WL_STATUS_READY, &cfg_priv->status)) { - WL_INFO("Enable MPC\n"); - brcmf_set_mpc(ndev, 1); - } - - WL_TRACE("Exit\n"); - - return 0; -} - -static __used s32 -brcmf_dev_bufvar_set(struct net_device *ndev, s8 *name, s8 *buf, s32 len) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - u32 buflen; - - buflen = brcmu_mkiovar(name, buf, len, cfg_priv->dcmd_buf, - WL_DCMD_LEN_MAX); - BUG_ON(!buflen); - - return brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, cfg_priv->dcmd_buf, - buflen); -} - -static s32 -brcmf_dev_bufvar_get(struct net_device *ndev, s8 *name, s8 *buf, - s32 buf_len) -{ - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - u32 len; - s32 err = 0; - - len = brcmu_mkiovar(name, NULL, 0, cfg_priv->dcmd_buf, - WL_DCMD_LEN_MAX); - BUG_ON(!len); - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, cfg_priv->dcmd_buf, - WL_DCMD_LEN_MAX); - if (err) { - WL_ERR("error (%d)\n", err); - return err; - } - memcpy(buf, cfg_priv->dcmd_buf, buf_len); - - return err; -} - -static __used s32 -brcmf_update_pmklist(struct net_device *ndev, - struct brcmf_cfg80211_pmk_list *pmk_list, s32 err) -{ - int i, j; - - WL_CONN("No of elements %d\n", pmk_list->pmkids.npmkid); - for (i = 0; i < pmk_list->pmkids.npmkid; i++) { - WL_CONN("PMKID[%d]: %pM =\n", i, - &pmk_list->pmkids.pmkid[i].BSSID); - for (j = 0; j < WLAN_PMKID_LEN; j++) - WL_CONN("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]); - } - - if (!err) - brcmf_dev_bufvar_set(ndev, "pmkid_info", (char *)pmk_list, - sizeof(*pmk_list)); - - return err; -} - -static s32 -brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_pmksa *pmksa) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct pmkid_list *pmkids = &cfg_priv->pmk_list->pmkids; - s32 err = 0; - int i; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - for (i = 0; i < pmkids->npmkid; i++) - if (!memcmp(pmksa->bssid, pmkids->pmkid[i].BSSID, ETH_ALEN)) - break; - if (i < WL_NUM_PMKIDS_MAX) { - memcpy(pmkids->pmkid[i].BSSID, pmksa->bssid, ETH_ALEN); - memcpy(pmkids->pmkid[i].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); - if (i == pmkids->npmkid) - pmkids->npmkid++; - } else - err = -EINVAL; - - WL_CONN("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n", - pmkids->pmkid[pmkids->npmkid].BSSID); - for (i = 0; i < WLAN_PMKID_LEN; i++) - WL_CONN("%02x\n", pmkids->pmkid[pmkids->npmkid].PMKID[i]); - - err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); - - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_pmksa *pmksa) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - struct pmkid_list pmkid; - s32 err = 0; - int i; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN); - memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); - - WL_CONN("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n", - &pmkid.pmkid[0].BSSID); - for (i = 0; i < WLAN_PMKID_LEN; i++) - WL_CONN("%02x\n", pmkid.pmkid[0].PMKID[i]); - - for (i = 0; i < cfg_priv->pmk_list->pmkids.npmkid; i++) - if (!memcmp - (pmksa->bssid, &cfg_priv->pmk_list->pmkids.pmkid[i].BSSID, - ETH_ALEN)) - break; - - if ((cfg_priv->pmk_list->pmkids.npmkid > 0) - && (i < cfg_priv->pmk_list->pmkids.npmkid)) { - memset(&cfg_priv->pmk_list->pmkids.pmkid[i], 0, - sizeof(struct pmkid)); - for (; i < (cfg_priv->pmk_list->pmkids.npmkid - 1); i++) { - memcpy(&cfg_priv->pmk_list->pmkids.pmkid[i].BSSID, - &cfg_priv->pmk_list->pmkids.pmkid[i + 1].BSSID, - ETH_ALEN); - memcpy(&cfg_priv->pmk_list->pmkids.pmkid[i].PMKID, - &cfg_priv->pmk_list->pmkids.pmkid[i + 1].PMKID, - WLAN_PMKID_LEN); - } - cfg_priv->pmk_list->pmkids.npmkid--; - } else - err = -EINVAL; - - err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); - - WL_TRACE("Exit\n"); - return err; - -} - -static s32 -brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev) -{ - struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); - s32 err = 0; - - WL_TRACE("Enter\n"); - if (!check_sys_up(wiphy)) - return -EIO; - - memset(cfg_priv->pmk_list, 0, sizeof(*cfg_priv->pmk_list)); - err = brcmf_update_pmklist(ndev, cfg_priv->pmk_list, err); - - WL_TRACE("Exit\n"); - return err; - -} - -static struct cfg80211_ops wl_cfg80211_ops = { - .change_virtual_intf = brcmf_cfg80211_change_iface, - .scan = brcmf_cfg80211_scan, - .set_wiphy_params = brcmf_cfg80211_set_wiphy_params, - .join_ibss = brcmf_cfg80211_join_ibss, - .leave_ibss = brcmf_cfg80211_leave_ibss, - .get_station = brcmf_cfg80211_get_station, - .set_tx_power = brcmf_cfg80211_set_tx_power, - .get_tx_power = brcmf_cfg80211_get_tx_power, - .add_key = brcmf_cfg80211_add_key, - .del_key = brcmf_cfg80211_del_key, - .get_key = brcmf_cfg80211_get_key, - .set_default_key = brcmf_cfg80211_config_default_key, - .set_default_mgmt_key = brcmf_cfg80211_config_default_mgmt_key, - .set_power_mgmt = brcmf_cfg80211_set_power_mgmt, - .set_bitrate_mask = brcmf_cfg80211_set_bitrate_mask, - .connect = brcmf_cfg80211_connect, - .disconnect = brcmf_cfg80211_disconnect, - .suspend = brcmf_cfg80211_suspend, - .resume = brcmf_cfg80211_resume, - .set_pmksa = brcmf_cfg80211_set_pmksa, - .del_pmksa = brcmf_cfg80211_del_pmksa, - .flush_pmksa = brcmf_cfg80211_flush_pmksa -}; - -static s32 brcmf_mode_to_nl80211_iftype(s32 mode) -{ - s32 err = 0; - - switch (mode) { - case WL_MODE_BSS: - return NL80211_IFTYPE_STATION; - case WL_MODE_IBSS: - return NL80211_IFTYPE_ADHOC; - default: - return NL80211_IFTYPE_UNSPECIFIED; - } - - return err; -} - -static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, - struct device *ndev) -{ - struct wireless_dev *wdev; - s32 err = 0; - - wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); - if (!wdev) - return ERR_PTR(-ENOMEM); - - wdev->wiphy = - wiphy_new(&wl_cfg80211_ops, - sizeof(struct brcmf_cfg80211_priv) + sizeof_iface); - if (!wdev->wiphy) { - WL_ERR("Couldn not allocate wiphy device\n"); - err = -ENOMEM; - goto wiphy_new_out; - } - set_wiphy_dev(wdev->wiphy, ndev); - wdev->wiphy->max_scan_ssids = WL_NUM_SCAN_MAX; - wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX; - wdev->wiphy->interface_modes = - BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz; - wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a; /* Set - * it as 11a by default. - * This will be updated with - * 11n phy tables in - * "ifconfig up" - * if phy has 11n capability - */ - wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - wdev->wiphy->cipher_suites = __wl_cipher_suites; - wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites); - wdev->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; /* enable power - * save mode - * by default - */ - err = wiphy_register(wdev->wiphy); - if (err < 0) { - WL_ERR("Couldn not register wiphy device (%d)\n", err); - goto wiphy_register_out; - } - return wdev; - -wiphy_register_out: - wiphy_free(wdev->wiphy); - -wiphy_new_out: - kfree(wdev); - - return ERR_PTR(err); -} - -static void brcmf_free_wdev(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct wireless_dev *wdev = cfg_priv->wdev; - - if (!wdev) { - WL_ERR("wdev is invalid\n"); - return; - } - wiphy_unregister(wdev->wiphy); - wiphy_free(wdev->wiphy); - kfree(wdev); - cfg_priv->wdev = NULL; -} - -static bool brcmf_is_linkup(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e) -{ - u32 event = be32_to_cpu(e->event_type); - u32 status = be32_to_cpu(e->status); - - if (event == BRCMF_E_SET_SSID && status == BRCMF_E_STATUS_SUCCESS) { - WL_CONN("Processing set ssid\n"); - cfg_priv->link_up = true; - return true; - } - - return false; -} - -static bool brcmf_is_linkdown(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e) -{ - u32 event = be32_to_cpu(e->event_type); - u16 flags = be16_to_cpu(e->flags); - - if (event == BRCMF_E_LINK && (!(flags & BRCMF_EVENT_MSG_LINK))) { - WL_CONN("Processing link down\n"); - return true; - } - return false; -} - -static bool brcmf_is_nonetwork(struct brcmf_cfg80211_priv *cfg_priv, - const struct brcmf_event_msg *e) -{ - u32 event = be32_to_cpu(e->event_type); - u32 status = be32_to_cpu(e->status); - - if (event == BRCMF_E_LINK && status == BRCMF_E_STATUS_NO_NETWORKS) { - WL_CONN("Processing Link %s & no network found\n", - be16_to_cpu(e->flags) & BRCMF_EVENT_MSG_LINK ? - "up" : "down"); - return true; - } - - if (event == BRCMF_E_SET_SSID && status != BRCMF_E_STATUS_SUCCESS) { - WL_CONN("Processing connecting & no network found\n"); - return true; - } - - return false; -} - -static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - - kfree(conn_info->req_ie); - conn_info->req_ie = NULL; - conn_info->req_ie_len = 0; - kfree(conn_info->resp_ie); - conn_info->resp_ie = NULL; - conn_info->resp_ie_len = 0; -} - -static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct net_device *ndev = cfg_to_ndev(cfg_priv); - struct brcmf_cfg80211_assoc_ielen *assoc_info; - struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - u32 req_len; - u32 resp_len; - s32 err = 0; - - brcmf_clear_assoc_ies(cfg_priv); - - err = brcmf_dev_bufvar_get(ndev, "assoc_info", cfg_priv->extra_buf, - WL_ASSOC_INFO_MAX); - if (err) { - WL_ERR("could not get assoc info (%d)\n", err); - return err; - } - assoc_info = (struct brcmf_cfg80211_assoc_ielen *)cfg_priv->extra_buf; - req_len = assoc_info->req_len; - resp_len = assoc_info->resp_len; - if (req_len) { - err = brcmf_dev_bufvar_get(ndev, "assoc_req_ies", - cfg_priv->extra_buf, - WL_ASSOC_INFO_MAX); - if (err) { - WL_ERR("could not get assoc req (%d)\n", err); - return err; - } - conn_info->req_ie_len = req_len; - conn_info->req_ie = - kmemdup(cfg_priv->extra_buf, conn_info->req_ie_len, - GFP_KERNEL); - } else { - conn_info->req_ie_len = 0; - conn_info->req_ie = NULL; - } - if (resp_len) { - err = brcmf_dev_bufvar_get(ndev, "assoc_resp_ies", - cfg_priv->extra_buf, - WL_ASSOC_INFO_MAX); - if (err) { - WL_ERR("could not get assoc resp (%d)\n", err); - return err; - } - conn_info->resp_ie_len = resp_len; - conn_info->resp_ie = - kmemdup(cfg_priv->extra_buf, conn_info->resp_ie_len, - GFP_KERNEL); - } else { - conn_info->resp_ie_len = 0; - conn_info->resp_ie = NULL; - } - WL_CONN("req len (%d) resp len (%d)\n", - conn_info->req_ie_len, conn_info->resp_ie_len); - - return err; -} - -static s32 -brcmf_bss_roaming_done(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e) -{ - struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); - struct brcmf_channel_info_le channel_le; - struct ieee80211_channel *notify_channel; - struct ieee80211_supported_band *band; - u32 freq; - s32 err = 0; - u32 target_channel; - - WL_TRACE("Enter\n"); - - brcmf_get_assoc_ies(cfg_priv); - brcmf_update_prof(cfg_priv, NULL, &e->addr, WL_PROF_BSSID); - brcmf_update_bss_info(cfg_priv); - - brcmf_exec_dcmd(ndev, BRCMF_C_GET_CHANNEL, &channel_le, - sizeof(channel_le)); - - target_channel = le32_to_cpu(channel_le.target_channel); - WL_CONN("Roamed to channel %d\n", target_channel); - - if (target_channel <= CH_MAX_2G_CHANNEL) - band = wiphy->bands[IEEE80211_BAND_2GHZ]; - else - band = wiphy->bands[IEEE80211_BAND_5GHZ]; - - freq = ieee80211_channel_to_frequency(target_channel, band->band); - notify_channel = ieee80211_get_channel(wiphy, freq); - - cfg80211_roamed(ndev, notify_channel, - (u8 *)brcmf_read_prof(cfg_priv, WL_PROF_BSSID), - conn_info->req_ie, conn_info->req_ie_len, - conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL); - WL_CONN("Report roaming result\n"); - - set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_bss_connect_done(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, const struct brcmf_event_msg *e, - bool completed) -{ - struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg_priv); - s32 err = 0; - - WL_TRACE("Enter\n"); - - if (test_and_clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status)) { - if (completed) { - brcmf_get_assoc_ies(cfg_priv); - brcmf_update_prof(cfg_priv, NULL, &e->addr, - WL_PROF_BSSID); - brcmf_update_bss_info(cfg_priv); - } - cfg80211_connect_result(ndev, - (u8 *)brcmf_read_prof(cfg_priv, - WL_PROF_BSSID), - conn_info->req_ie, - conn_info->req_ie_len, - conn_info->resp_ie, - conn_info->resp_ie_len, - completed ? WLAN_STATUS_SUCCESS : - WLAN_STATUS_AUTH_TIMEOUT, - GFP_KERNEL); - if (completed) - set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - WL_CONN("Report connect result - connection %s\n", - completed ? "succeeded" : "failed"); - } - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_notify_connect_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - s32 err = 0; - - if (brcmf_is_linkup(cfg_priv, e)) { - WL_CONN("Linkup\n"); - if (brcmf_is_ibssmode(cfg_priv)) { - brcmf_update_prof(cfg_priv, NULL, (void *)e->addr, - WL_PROF_BSSID); - wl_inform_ibss(cfg_priv, ndev, e->addr); - cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL); - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - set_bit(WL_STATUS_CONNECTED, &cfg_priv->status); - } else - brcmf_bss_connect_done(cfg_priv, ndev, e, true); - } else if (brcmf_is_linkdown(cfg_priv, e)) { - WL_CONN("Linkdown\n"); - if (brcmf_is_ibssmode(cfg_priv)) { - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - if (test_and_clear_bit(WL_STATUS_CONNECTED, - &cfg_priv->status)) - brcmf_link_down(cfg_priv); - } else { - brcmf_bss_connect_done(cfg_priv, ndev, e, false); - if (test_and_clear_bit(WL_STATUS_CONNECTED, - &cfg_priv->status)) { - cfg80211_disconnected(ndev, 0, NULL, 0, - GFP_KERNEL); - brcmf_link_down(cfg_priv); - } - } - brcmf_init_prof(cfg_priv->profile); - } else if (brcmf_is_nonetwork(cfg_priv, e)) { - if (brcmf_is_ibssmode(cfg_priv)) - clear_bit(WL_STATUS_CONNECTING, &cfg_priv->status); - else - brcmf_bss_connect_done(cfg_priv, ndev, e, false); - } - - return err; -} - -static s32 -brcmf_notify_roaming_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - s32 err = 0; - u32 event = be32_to_cpu(e->event_type); - u32 status = be32_to_cpu(e->status); - - if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { - if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) - brcmf_bss_roaming_done(cfg_priv, ndev, e); - else - brcmf_bss_connect_done(cfg_priv, ndev, e, true); - } - - return err; -} - -static s32 -brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - u16 flags = be16_to_cpu(e->flags); - enum nl80211_key_type key_type; - - if (flags & BRCMF_EVENT_MSG_GROUP) - key_type = NL80211_KEYTYPE_GROUP; - else - key_type = NL80211_KEYTYPE_PAIRWISE; - - cfg80211_michael_mic_failure(ndev, (u8 *)&e->addr, key_type, -1, - NULL, GFP_KERNEL); - - return 0; -} - -static s32 -brcmf_notify_scan_status(struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - struct brcmf_channel_info_le channel_inform_le; - struct brcmf_scan_results_le *bss_list_le; - u32 len = WL_SCAN_BUF_MAX; - s32 err = 0; - bool scan_abort = false; - u32 scan_channel; - - WL_TRACE("Enter\n"); - - if (cfg_priv->iscan_on && cfg_priv->iscan_kickstart) { - WL_TRACE("Exit\n"); - return brcmf_wakeup_iscan(cfg_to_iscan(cfg_priv)); - } - - if (!test_and_clear_bit(WL_STATUS_SCANNING, &cfg_priv->status)) { - WL_ERR("Scan complete while device not scanning\n"); - scan_abort = true; - err = -EINVAL; - goto scan_done_out; - } - - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_CHANNEL, &channel_inform_le, - sizeof(channel_inform_le)); - if (err) { - WL_ERR("scan busy (%d)\n", err); - scan_abort = true; - goto scan_done_out; - } - scan_channel = le32_to_cpu(channel_inform_le.scan_channel); - if (scan_channel) - WL_CONN("channel_inform.scan_channel (%d)\n", scan_channel); - cfg_priv->bss_list = cfg_priv->scan_results; - bss_list_le = (struct brcmf_scan_results_le *) cfg_priv->bss_list; - - memset(cfg_priv->scan_results, 0, len); - bss_list_le->buflen = cpu_to_le32(len); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SCAN_RESULTS, - cfg_priv->scan_results, len); - if (err) { - WL_ERR("%s Scan_results error (%d)\n", ndev->name, err); - err = -EINVAL; - scan_abort = true; - goto scan_done_out; - } - cfg_priv->scan_results->buflen = le32_to_cpu(bss_list_le->buflen); - cfg_priv->scan_results->version = le32_to_cpu(bss_list_le->version); - cfg_priv->scan_results->count = le32_to_cpu(bss_list_le->count); - - err = brcmf_inform_bss(cfg_priv); - if (err) { - scan_abort = true; - goto scan_done_out; - } - -scan_done_out: - if (cfg_priv->scan_request) { - WL_SCAN("calling cfg80211_scan_done\n"); - cfg80211_scan_done(cfg_priv->scan_request, scan_abort); - brcmf_set_mpc(ndev, 1); - cfg_priv->scan_request = NULL; - } - - WL_TRACE("Exit\n"); - - return err; -} - -static void brcmf_init_conf(struct brcmf_cfg80211_conf *conf) -{ - conf->mode = (u32)-1; - conf->frag_threshold = (u32)-1; - conf->rts_threshold = (u32)-1; - conf->retry_short = (u32)-1; - conf->retry_long = (u32)-1; - conf->tx_power = -1; -} - -static void brcmf_init_eloop_handler(struct brcmf_cfg80211_event_loop *el) -{ - memset(el, 0, sizeof(*el)); - el->handler[BRCMF_E_SCAN_COMPLETE] = brcmf_notify_scan_status; - el->handler[BRCMF_E_LINK] = brcmf_notify_connect_status; - el->handler[BRCMF_E_ROAM] = brcmf_notify_roaming_status; - el->handler[BRCMF_E_MIC_ERROR] = brcmf_notify_mic_status; - el->handler[BRCMF_E_SET_SSID] = brcmf_notify_connect_status; -} - -static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) -{ - kfree(cfg_priv->scan_results); - cfg_priv->scan_results = NULL; - kfree(cfg_priv->bss_info); - cfg_priv->bss_info = NULL; - kfree(cfg_priv->conf); - cfg_priv->conf = NULL; - kfree(cfg_priv->profile); - cfg_priv->profile = NULL; - kfree(cfg_priv->scan_req_int); - cfg_priv->scan_req_int = NULL; - kfree(cfg_priv->dcmd_buf); - cfg_priv->dcmd_buf = NULL; - kfree(cfg_priv->extra_buf); - cfg_priv->extra_buf = NULL; - kfree(cfg_priv->iscan); - cfg_priv->iscan = NULL; - kfree(cfg_priv->pmk_list); - cfg_priv->pmk_list = NULL; -} - -static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_priv *cfg_priv) -{ - cfg_priv->scan_results = kzalloc(WL_SCAN_BUF_MAX, GFP_KERNEL); - if (!cfg_priv->scan_results) - goto init_priv_mem_out; - cfg_priv->conf = kzalloc(sizeof(*cfg_priv->conf), GFP_KERNEL); - if (!cfg_priv->conf) - goto init_priv_mem_out; - cfg_priv->profile = kzalloc(sizeof(*cfg_priv->profile), GFP_KERNEL); - if (!cfg_priv->profile) - goto init_priv_mem_out; - cfg_priv->bss_info = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); - if (!cfg_priv->bss_info) - goto init_priv_mem_out; - cfg_priv->scan_req_int = kzalloc(sizeof(*cfg_priv->scan_req_int), - GFP_KERNEL); - if (!cfg_priv->scan_req_int) - goto init_priv_mem_out; - cfg_priv->dcmd_buf = kzalloc(WL_DCMD_LEN_MAX, GFP_KERNEL); - if (!cfg_priv->dcmd_buf) - goto init_priv_mem_out; - cfg_priv->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); - if (!cfg_priv->extra_buf) - goto init_priv_mem_out; - cfg_priv->iscan = kzalloc(sizeof(*cfg_priv->iscan), GFP_KERNEL); - if (!cfg_priv->iscan) - goto init_priv_mem_out; - cfg_priv->pmk_list = kzalloc(sizeof(*cfg_priv->pmk_list), GFP_KERNEL); - if (!cfg_priv->pmk_list) - goto init_priv_mem_out; - - return 0; - -init_priv_mem_out: - brcmf_deinit_priv_mem(cfg_priv); - - return -ENOMEM; -} - -/* -* retrieve first queued event from head -*/ - -static struct brcmf_cfg80211_event_q *brcmf_deq_event( - struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_event_q *e = NULL; - - spin_lock_irq(&cfg_priv->evt_q_lock); - if (!list_empty(&cfg_priv->evt_q_list)) { - e = list_first_entry(&cfg_priv->evt_q_list, - struct brcmf_cfg80211_event_q, evt_q_list); - list_del(&e->evt_q_list); - } - spin_unlock_irq(&cfg_priv->evt_q_lock); - - return e; -} - -/* -** push event to tail of the queue -*/ - -static s32 -brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, - const struct brcmf_event_msg *msg) -{ - struct brcmf_cfg80211_event_q *e; - s32 err = 0; - - e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); - if (!e) - return -ENOMEM; - - e->etype = event; - memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); - - spin_lock_irq(&cfg_priv->evt_q_lock); - list_add_tail(&e->evt_q_list, &cfg_priv->evt_q_list); - spin_unlock_irq(&cfg_priv->evt_q_lock); - - return err; -} - -static void brcmf_put_event(struct brcmf_cfg80211_event_q *e) -{ - kfree(e); -} - -static void brcmf_cfg80211_event_handler(struct work_struct *work) -{ - struct brcmf_cfg80211_priv *cfg_priv = - container_of(work, struct brcmf_cfg80211_priv, - event_work); - struct brcmf_cfg80211_event_q *e; - - e = brcmf_deq_event(cfg_priv); - if (unlikely(!e)) { - WL_ERR("event queue empty...\n"); - return; - } - - do { - WL_INFO("event type (%d)\n", e->etype); - if (cfg_priv->el.handler[e->etype]) - cfg_priv->el.handler[e->etype](cfg_priv, - cfg_to_ndev(cfg_priv), - &e->emsg, e->edata); - else - WL_INFO("Unknown Event (%d): ignoring\n", e->etype); - brcmf_put_event(e); - } while ((e = brcmf_deq_event(cfg_priv))); - -} - -static void brcmf_init_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - spin_lock_init(&cfg_priv->evt_q_lock); - INIT_LIST_HEAD(&cfg_priv->evt_q_list); -} - -static void brcmf_flush_eq(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct brcmf_cfg80211_event_q *e; - - spin_lock_irq(&cfg_priv->evt_q_lock); - while (!list_empty(&cfg_priv->evt_q_list)) { - e = list_first_entry(&cfg_priv->evt_q_list, - struct brcmf_cfg80211_event_q, evt_q_list); - list_del(&e->evt_q_list); - kfree(e); - } - spin_unlock_irq(&cfg_priv->evt_q_lock); -} - -static s32 wl_init_priv(struct brcmf_cfg80211_priv *cfg_priv) -{ - s32 err = 0; - - cfg_priv->scan_request = NULL; - cfg_priv->pwr_save = true; - cfg_priv->iscan_on = true; /* iscan on & off switch. - we enable iscan per default */ - cfg_priv->roam_on = true; /* roam on & off switch. - we enable roam per default */ - - cfg_priv->iscan_kickstart = false; - cfg_priv->active_scan = true; /* we do active scan for - specific scan per default */ - cfg_priv->dongle_up = false; /* dongle is not up yet */ - brcmf_init_eq(cfg_priv); - err = brcmf_init_priv_mem(cfg_priv); - if (err) - return err; - INIT_WORK(&cfg_priv->event_work, brcmf_cfg80211_event_handler); - brcmf_init_eloop_handler(&cfg_priv->el); - mutex_init(&cfg_priv->usr_sync); - err = brcmf_init_iscan(cfg_priv); - if (err) - return err; - brcmf_init_conf(cfg_priv->conf); - brcmf_init_prof(cfg_priv->profile); - brcmf_link_down(cfg_priv); - - return err; -} - -static void wl_deinit_priv(struct brcmf_cfg80211_priv *cfg_priv) -{ - cancel_work_sync(&cfg_priv->event_work); - cfg_priv->dongle_up = false; /* dongle down */ - brcmf_flush_eq(cfg_priv); - brcmf_link_down(cfg_priv); - brcmf_term_iscan(cfg_priv); - brcmf_deinit_priv_mem(cfg_priv); -} - -struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, - struct device *busdev, - void *data) -{ - struct wireless_dev *wdev; - struct brcmf_cfg80211_priv *cfg_priv; - struct brcmf_cfg80211_iface *ci; - struct brcmf_cfg80211_dev *cfg_dev; - s32 err = 0; - - if (!ndev) { - WL_ERR("ndev is invalid\n"); - return NULL; - } - cfg_dev = kzalloc(sizeof(struct brcmf_cfg80211_dev), GFP_KERNEL); - if (!cfg_dev) - return NULL; - - wdev = brcmf_alloc_wdev(sizeof(struct brcmf_cfg80211_iface), busdev); - if (IS_ERR(wdev)) { - kfree(cfg_dev); - return NULL; - } - - wdev->iftype = brcmf_mode_to_nl80211_iftype(WL_MODE_BSS); - cfg_priv = wdev_to_cfg(wdev); - cfg_priv->wdev = wdev; - cfg_priv->pub = data; - ci = (struct brcmf_cfg80211_iface *)&cfg_priv->ci; - ci->cfg_priv = cfg_priv; - ndev->ieee80211_ptr = wdev; - SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); - wdev->netdev = ndev; - err = wl_init_priv(cfg_priv); - if (err) { - WL_ERR("Failed to init iwm_priv (%d)\n", err); - goto cfg80211_attach_out; - } - brcmf_set_drvdata(cfg_dev, ci); - - return cfg_dev; - -cfg80211_attach_out: - brcmf_free_wdev(cfg_priv); - kfree(cfg_dev); - return NULL; -} - -void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg_dev) -{ - struct brcmf_cfg80211_priv *cfg_priv; - - cfg_priv = brcmf_priv_get(cfg_dev); - - wl_deinit_priv(cfg_priv); - brcmf_free_wdev(cfg_priv); - brcmf_set_drvdata(cfg_dev, NULL); - kfree(cfg_dev); -} - -void -brcmf_cfg80211_event(struct net_device *ndev, - const struct brcmf_event_msg *e, void *data) -{ - u32 event_type = be32_to_cpu(e->event_type); - struct brcmf_cfg80211_priv *cfg_priv = ndev_to_cfg(ndev); - - if (!brcmf_enq_event(cfg_priv, event_type, e)) - schedule_work(&cfg_priv->event_work); -} - -static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype) -{ - s32 infra = 0; - s32 err = 0; - - switch (iftype) { - case NL80211_IFTYPE_MONITOR: - case NL80211_IFTYPE_WDS: - WL_ERR("type (%d) : currently we do not support this mode\n", - iftype); - err = -EINVAL; - return err; - case NL80211_IFTYPE_ADHOC: - infra = 0; - break; - case NL80211_IFTYPE_STATION: - infra = 1; - break; - default: - err = -EINVAL; - WL_ERR("invalid type (%d)\n", iftype); - return err; - } - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_INFRA, &infra); - if (err) { - WL_ERR("WLC_SET_INFRA error (%d)\n", err); - return err; - } - - return 0; -} - -static s32 brcmf_dongle_eventmsg(struct net_device *ndev) -{ - /* Room for "event_msgs" + '\0' + bitvec */ - s8 iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; - s8 eventmask[BRCMF_EVENTING_MASK_LEN]; - s32 err = 0; - - WL_TRACE("Enter\n"); - - /* Setup event_msgs */ - brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, - sizeof(iovbuf)); - err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_VAR, iovbuf, sizeof(iovbuf)); - if (err) { - WL_ERR("Get event_msgs error (%d)\n", err); - goto dongle_eventmsg_out; - } - memcpy(eventmask, iovbuf, BRCMF_EVENTING_MASK_LEN); - - setbit(eventmask, BRCMF_E_SET_SSID); - setbit(eventmask, BRCMF_E_ROAM); - setbit(eventmask, BRCMF_E_PRUNE); - setbit(eventmask, BRCMF_E_AUTH); - setbit(eventmask, BRCMF_E_REASSOC); - setbit(eventmask, BRCMF_E_REASSOC_IND); - setbit(eventmask, BRCMF_E_DEAUTH_IND); - setbit(eventmask, BRCMF_E_DISASSOC_IND); - setbit(eventmask, BRCMF_E_DISASSOC); - setbit(eventmask, BRCMF_E_JOIN); - setbit(eventmask, BRCMF_E_ASSOC_IND); - setbit(eventmask, BRCMF_E_PSK_SUP); - setbit(eventmask, BRCMF_E_LINK); - setbit(eventmask, BRCMF_E_NDIS_LINK); - setbit(eventmask, BRCMF_E_MIC_ERROR); - setbit(eventmask, BRCMF_E_PMKID_CACHE); - setbit(eventmask, BRCMF_E_TXFAIL); - setbit(eventmask, BRCMF_E_JOIN_START); - setbit(eventmask, BRCMF_E_SCAN_COMPLETE); - - brcmu_mkiovar("event_msgs", eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, - sizeof(iovbuf)); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - if (err) { - WL_ERR("Set event_msgs error (%d)\n", err); - goto dongle_eventmsg_out; - } - -dongle_eventmsg_out: - WL_TRACE("Exit\n"); - return err; -} - -static s32 -brcmf_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout) -{ - s8 iovbuf[32]; - s32 roamtrigger[2]; - s32 roam_delta[2]; - s32 err = 0; - - /* - * Setup timeout if Beacons are lost and roam is - * off to report link down - */ - if (roamvar) { - brcmu_mkiovar("bcn_timeout", (char *)&bcn_timeout, - sizeof(bcn_timeout), iovbuf, sizeof(iovbuf)); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, - iovbuf, sizeof(iovbuf)); - if (err) { - WL_ERR("bcn_timeout error (%d)\n", err); - goto dongle_rom_out; - } - } - - /* - * Enable/Disable built-in roaming to allow supplicant - * to take care of roaming - */ - WL_INFO("Internal Roaming = %s\n", roamvar ? "Off" : "On"); - brcmu_mkiovar("roam_off", (char *)&roamvar, - sizeof(roamvar), iovbuf, sizeof(iovbuf)); - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf)); - if (err) { - WL_ERR("roam_off error (%d)\n", err); - goto dongle_rom_out; - } - - roamtrigger[0] = WL_ROAM_TRIGGER_LEVEL; - roamtrigger[1] = BRCM_BAND_ALL; - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_ROAM_TRIGGER, - (void *)roamtrigger, sizeof(roamtrigger)); - if (err) { - WL_ERR("WLC_SET_ROAM_TRIGGER error (%d)\n", err); - goto dongle_rom_out; - } - - roam_delta[0] = WL_ROAM_DELTA; - roam_delta[1] = BRCM_BAND_ALL; - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_ROAM_DELTA, - (void *)roam_delta, sizeof(roam_delta)); - if (err) { - WL_ERR("WLC_SET_ROAM_DELTA error (%d)\n", err); - goto dongle_rom_out; - } - -dongle_rom_out: - return err; -} - -static s32 -brcmf_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time, - s32 scan_unassoc_time, s32 scan_passive_time) -{ - s32 err = 0; - - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_CHANNEL_TIME, - &scan_assoc_time, sizeof(scan_assoc_time)); - if (err) { - if (err == -EOPNOTSUPP) - WL_INFO("Scan assoc time is not supported\n"); - else - WL_ERR("Scan assoc time error (%d)\n", err); - goto dongle_scantime_out; - } - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_UNASSOC_TIME, - &scan_unassoc_time, sizeof(scan_unassoc_time)); - if (err) { - if (err == -EOPNOTSUPP) - WL_INFO("Scan unassoc time is not supported\n"); - else - WL_ERR("Scan unassoc time error (%d)\n", err); - goto dongle_scantime_out; - } - - err = brcmf_exec_dcmd(ndev, BRCMF_C_SET_SCAN_PASSIVE_TIME, - &scan_passive_time, sizeof(scan_passive_time)); - if (err) { - if (err == -EOPNOTSUPP) - WL_INFO("Scan passive time is not supported\n"); - else - WL_ERR("Scan passive time error (%d)\n", err); - goto dongle_scantime_out; - } - -dongle_scantime_out: - return err; -} - -static s32 wl_update_wiphybands(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct wiphy *wiphy; - s32 phy_list; - s8 phy; - s32 err = 0; - - err = brcmf_exec_dcmd(cfg_to_ndev(cfg_priv), BRCM_GET_PHYLIST, - &phy_list, sizeof(phy_list)); - if (err) { - WL_ERR("error (%d)\n", err); - return err; - } - - phy = ((char *)&phy_list)[1]; - WL_INFO("%c phy\n", phy); - if (phy == 'n' || phy == 'a') { - wiphy = cfg_to_wiphy(cfg_priv); - wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n; - } - - return err; -} - -static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv) -{ - return wl_update_wiphybands(cfg_priv); -} - -static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv) -{ - struct net_device *ndev; - struct wireless_dev *wdev; - s32 power_mode; - s32 err = 0; - - if (cfg_priv->dongle_up) - return err; - - ndev = cfg_to_ndev(cfg_priv); - wdev = ndev->ieee80211_ptr; - - brcmf_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME, - WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME); - - err = brcmf_dongle_eventmsg(ndev); - if (err) - goto default_conf_out; - - power_mode = cfg_priv->pwr_save ? PM_FAST : PM_OFF; - err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_PM, &power_mode); - if (err) - goto default_conf_out; - WL_INFO("power save set to %s\n", - (power_mode ? "enabled" : "disabled")); - - err = brcmf_dongle_roam(ndev, (cfg_priv->roam_on ? 0 : 1), - WL_BEACON_TIMEOUT); - if (err) - goto default_conf_out; - err = brcmf_dongle_mode(ndev, wdev->iftype); - if (err && err != -EINPROGRESS) - goto default_conf_out; - err = brcmf_dongle_probecap(cfg_priv); - if (err) - goto default_conf_out; - - /* -EINPROGRESS: Call commit handler */ - -default_conf_out: - - cfg_priv->dongle_up = true; - - return err; - -} - -static int brcmf_debugfs_add_netdev_params(struct brcmf_cfg80211_priv *cfg_priv) -{ - char buf[10+IFNAMSIZ]; - struct dentry *fd; - s32 err = 0; - - sprintf(buf, "netdev:%s", cfg_to_ndev(cfg_priv)->name); - cfg_priv->debugfsdir = debugfs_create_dir(buf, - cfg_to_wiphy(cfg_priv)->debugfsdir); - - fd = debugfs_create_u16("beacon_int", S_IRUGO, cfg_priv->debugfsdir, - (u16 *)&cfg_priv->profile->beacon_interval); - if (!fd) { - err = -ENOMEM; - goto err_out; - } - - fd = debugfs_create_u8("dtim_period", S_IRUGO, cfg_priv->debugfsdir, - (u8 *)&cfg_priv->profile->dtim_period); - if (!fd) { - err = -ENOMEM; - goto err_out; - } - -err_out: - return err; -} - -static void brcmf_debugfs_remove_netdev(struct brcmf_cfg80211_priv *cfg_priv) -{ - debugfs_remove_recursive(cfg_priv->debugfsdir); - cfg_priv->debugfsdir = NULL; -} - -static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv) -{ - s32 err = 0; - - set_bit(WL_STATUS_READY, &cfg_priv->status); - - brcmf_debugfs_add_netdev_params(cfg_priv); - - err = brcmf_config_dongle(cfg_priv); - if (err) - return err; - - brcmf_invoke_iscan(cfg_priv); - - return err; -} - -static s32 __brcmf_cfg80211_down(struct brcmf_cfg80211_priv *cfg_priv) -{ - /* - * While going down, if associated with AP disassociate - * from AP to save power - */ - if ((test_bit(WL_STATUS_CONNECTED, &cfg_priv->status) || - test_bit(WL_STATUS_CONNECTING, &cfg_priv->status)) && - test_bit(WL_STATUS_READY, &cfg_priv->status)) { - WL_INFO("Disassociating from AP"); - brcmf_link_down(cfg_priv); - - /* Make sure WPA_Supplicant receives all the event - generated due to DISASSOC call to the fw to keep - the state fw and WPA_Supplicant state consistent - */ - brcmf_delay(500); - } - - set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); - brcmf_term_iscan(cfg_priv); - if (cfg_priv->scan_request) { - cfg80211_scan_done(cfg_priv->scan_request, true); - /* May need to perform this to cover rmmod */ - /* wl_set_mpc(cfg_to_ndev(wl), 1); */ - cfg_priv->scan_request = NULL; - } - clear_bit(WL_STATUS_READY, &cfg_priv->status); - clear_bit(WL_STATUS_SCANNING, &cfg_priv->status); - clear_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status); - - brcmf_debugfs_remove_netdev(cfg_priv); - - return 0; -} - -s32 brcmf_cfg80211_up(struct brcmf_cfg80211_dev *cfg_dev) -{ - struct brcmf_cfg80211_priv *cfg_priv; - s32 err = 0; - - cfg_priv = brcmf_priv_get(cfg_dev); - mutex_lock(&cfg_priv->usr_sync); - err = __brcmf_cfg80211_up(cfg_priv); - mutex_unlock(&cfg_priv->usr_sync); - - return err; -} - -s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev) -{ - struct brcmf_cfg80211_priv *cfg_priv; - s32 err = 0; - - cfg_priv = brcmf_priv_get(cfg_dev); - mutex_lock(&cfg_priv->usr_sync); - err = __brcmf_cfg80211_down(cfg_priv); - mutex_unlock(&cfg_priv->usr_sync); - - return err; -} - -static __used s32 brcmf_add_ie(struct brcmf_cfg80211_priv *cfg_priv, - u8 t, u8 l, u8 *v) -{ - struct brcmf_cfg80211_ie *ie = &cfg_priv->ie; - s32 err = 0; - - if (ie->offset + l + 2 > WL_TLV_INFO_MAX) { - WL_ERR("ei crosses buffer boundary\n"); - return -ENOSPC; - } - ie->buf[ie->offset] = t; - ie->buf[ie->offset + 1] = l; - memcpy(&ie->buf[ie->offset + 2], v, l); - ie->offset += l + 2; - - return err; -} diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h deleted file mode 100644 index e69f4f6bf94..00000000000 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _wl_cfg80211_h_ -#define _wl_cfg80211_h_ - -struct brcmf_cfg80211_conf; -struct brcmf_cfg80211_iface; -struct brcmf_cfg80211_priv; -struct brcmf_cfg80211_security; -struct brcmf_cfg80211_ibss; - -#define WL_DBG_NONE 0 -#define WL_DBG_CONN (1 << 5) -#define WL_DBG_SCAN (1 << 4) -#define WL_DBG_TRACE (1 << 3) -#define WL_DBG_INFO (1 << 1) -#define WL_DBG_ERR (1 << 0) -#define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \ - (WL_DBG_SCAN) | (WL_DBG_CONN)) - -#define WL_ERR(fmt, args...) \ -do { \ - if (brcmf_dbg_level & WL_DBG_ERR) { \ - if (net_ratelimit()) { \ - printk(KERN_ERR "ERROR @%s : " fmt, \ - __func__, ##args); \ - } \ - } \ -} while (0) - -#if (defined BCMDBG) -#define WL_INFO(fmt, args...) \ -do { \ - if (brcmf_dbg_level & WL_DBG_INFO) { \ - if (net_ratelimit()) { \ - printk(KERN_ERR "INFO @%s : " fmt, \ - __func__, ##args); \ - } \ - } \ -} while (0) - -#define WL_TRACE(fmt, args...) \ -do { \ - if (brcmf_dbg_level & WL_DBG_TRACE) { \ - if (net_ratelimit()) { \ - printk(KERN_ERR "TRACE @%s : " fmt, \ - __func__, ##args); \ - } \ - } \ -} while (0) - -#define WL_SCAN(fmt, args...) \ -do { \ - if (brcmf_dbg_level & WL_DBG_SCAN) { \ - if (net_ratelimit()) { \ - printk(KERN_ERR "SCAN @%s : " fmt, \ - __func__, ##args); \ - } \ - } \ -} while (0) - -#define WL_CONN(fmt, args...) \ -do { \ - if (brcmf_dbg_level & WL_DBG_CONN) { \ - if (net_ratelimit()) { \ - printk(KERN_ERR "CONN @%s : " fmt, \ - __func__, ##args); \ - } \ - } \ -} while (0) - -#else /* (defined BCMDBG) */ -#define WL_INFO(fmt, args...) -#define WL_TRACE(fmt, args...) -#define WL_SCAN(fmt, args...) -#define WL_CONN(fmt, args...) -#endif /* (defined BCMDBG) */ - -#define WL_NUM_SCAN_MAX 1 -#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used - * for 2.6.33 kernel - * or later - */ -#define WL_SCAN_BUF_MAX (1024 * 8) -#define WL_TLV_INFO_MAX 1024 -#define WL_BSS_INFO_MAX 2048 -#define WL_ASSOC_INFO_MAX 512 /* - * needs to grab assoc info from dongle to - * report it to cfg80211 through "connect" - * event - */ -#define WL_DCMD_LEN_MAX 1024 -#define WL_EXTRA_BUF_MAX 2048 -#define WL_ISCAN_BUF_MAX 2048 /* - * the buf length can be BRCMF_DCMD_MAXLEN - * to reduce iteration - */ -#define WL_ISCAN_TIMER_INTERVAL_MS 3000 -#define WL_SCAN_ERSULTS_LAST (BRCMF_SCAN_RESULTS_NO_MEM+1) -#define WL_AP_MAX 256 /* virtually unlimitted as long - * as kernel memory allows - */ - -#define WL_ROAM_TRIGGER_LEVEL -75 -#define WL_ROAM_DELTA 20 -#define WL_BEACON_TIMEOUT 3 - -#define WL_SCAN_CHANNEL_TIME 40 -#define WL_SCAN_UNASSOC_TIME 40 -#define WL_SCAN_PASSIVE_TIME 120 - -/* dongle status */ -enum wl_status { - WL_STATUS_READY, - WL_STATUS_SCANNING, - WL_STATUS_SCAN_ABORTING, - WL_STATUS_CONNECTING, - WL_STATUS_CONNECTED -}; - -/* wi-fi mode */ -enum wl_mode { - WL_MODE_BSS, - WL_MODE_IBSS, - WL_MODE_AP -}; - -/* dongle profile list */ -enum wl_prof_list { - WL_PROF_MODE, - WL_PROF_SSID, - WL_PROF_SEC, - WL_PROF_IBSS, - WL_PROF_BAND, - WL_PROF_BSSID, - WL_PROF_ACT, - WL_PROF_BEACONINT, - WL_PROF_DTIMPERIOD -}; - -/* dongle iscan state */ -enum wl_iscan_state { - WL_ISCAN_STATE_IDLE, - WL_ISCAN_STATE_SCANING -}; - -/* dongle configuration */ -struct brcmf_cfg80211_conf { - u32 mode; /* adhoc , infrastructure or ap */ - u32 frag_threshold; - u32 rts_threshold; - u32 retry_short; - u32 retry_long; - s32 tx_power; - struct ieee80211_channel channel; -}; - -/* cfg80211 main event loop */ -struct brcmf_cfg80211_event_loop { - s32(*handler[BRCMF_E_LAST]) (struct brcmf_cfg80211_priv *cfg_priv, - struct net_device *ndev, - const struct brcmf_event_msg *e, - void *data); -}; - -/* representing interface of cfg80211 plane */ -struct brcmf_cfg80211_iface { - struct brcmf_cfg80211_priv *cfg_priv; -}; - -struct brcmf_cfg80211_dev { - void *driver_data; /* to store cfg80211 object information */ -}; - -/* basic structure of scan request */ -struct brcmf_cfg80211_scan_req { - struct brcmf_ssid_le ssid_le; -}; - -/* basic structure of information element */ -struct brcmf_cfg80211_ie { - u16 offset; - u8 buf[WL_TLV_INFO_MAX]; -}; - -/* event queue for cfg80211 main event */ -struct brcmf_cfg80211_event_q { - struct list_head evt_q_list; - u32 etype; - struct brcmf_event_msg emsg; - s8 edata[1]; -}; - -/* security information with currently associated ap */ -struct brcmf_cfg80211_security { - u32 wpa_versions; - u32 auth_type; - u32 cipher_pairwise; - u32 cipher_group; - u32 wpa_auth; -}; - -/* ibss information for currently joined ibss network */ -struct brcmf_cfg80211_ibss { - u8 beacon_interval; /* in millisecond */ - u8 atim; /* in millisecond */ - s8 join_only; - u8 band; - u8 channel; -}; - -/* dongle profile */ -struct brcmf_cfg80211_profile { - u32 mode; - struct brcmf_ssid ssid; - u8 bssid[ETH_ALEN]; - u16 beacon_interval; - u8 dtim_period; - struct brcmf_cfg80211_security sec; - struct brcmf_cfg80211_ibss ibss; - s32 band; -}; - -/* dongle iscan event loop */ -struct brcmf_cfg80211_iscan_eloop { - s32 (*handler[WL_SCAN_ERSULTS_LAST]) - (struct brcmf_cfg80211_priv *cfg_priv); -}; - -/* dongle iscan controller */ -struct brcmf_cfg80211_iscan_ctrl { - struct net_device *ndev; - struct timer_list timer; - u32 timer_ms; - u32 timer_on; - s32 state; - struct work_struct work; - struct brcmf_cfg80211_iscan_eloop el; - void *data; - s8 dcmd_buf[BRCMF_DCMD_SMLEN]; - s8 scan_buf[WL_ISCAN_BUF_MAX]; -}; - -/* association inform */ -struct brcmf_cfg80211_connect_info { - u8 *req_ie; - s32 req_ie_len; - u8 *resp_ie; - s32 resp_ie_len; -}; - -/* assoc ie length */ -struct brcmf_cfg80211_assoc_ielen { - u32 req_len; - u32 resp_len; -}; - -/* wpa2 pmk list */ -struct brcmf_cfg80211_pmk_list { - struct pmkid_list pmkids; - struct pmkid foo[MAXPMKID - 1]; -}; - -/* dongle private data of cfg80211 interface */ -struct brcmf_cfg80211_priv { - struct wireless_dev *wdev; /* representing wl cfg80211 device */ - struct brcmf_cfg80211_conf *conf; /* dongle configuration */ - struct cfg80211_scan_request *scan_request; /* scan request - object */ - struct brcmf_cfg80211_event_loop el; /* main event loop */ - struct list_head evt_q_list; /* used for event queue */ - spinlock_t evt_q_lock; /* for event queue synchronization */ - struct mutex usr_sync; /* maily for dongle up/down synchronization */ - struct brcmf_scan_results *bss_list; /* bss_list holding scanned - ap information */ - struct brcmf_scan_results *scan_results; - struct brcmf_cfg80211_scan_req *scan_req_int; /* scan request object - for internal purpose */ - struct wl_cfg80211_bss_info *bss_info; /* bss information for - cfg80211 layer */ - struct brcmf_cfg80211_ie ie; /* information element object for - internal purpose */ - struct brcmf_cfg80211_profile *profile; /* holding dongle profile */ - struct brcmf_cfg80211_iscan_ctrl *iscan; /* iscan controller */ - struct brcmf_cfg80211_connect_info conn_info; /* association info */ - struct brcmf_cfg80211_pmk_list *pmk_list; /* wpa2 pmk list */ - struct work_struct event_work; /* event handler work struct */ - unsigned long status; /* current dongle status */ - void *pub; - u32 channel; /* current channel */ - bool iscan_on; /* iscan on/off switch */ - bool iscan_kickstart; /* indicate iscan already started */ - bool active_scan; /* current scan mode */ - bool ibss_starter; /* indicates this sta is ibss starter */ - bool link_up; /* link/connection up flag */ - bool pwr_save; /* indicate whether dongle to support - power save mode */ - bool dongle_up; /* indicate whether dongle up or not */ - bool roam_on; /* on/off switch for dongle self-roaming */ - bool scan_tried; /* indicates if first scan attempted */ - u8 *dcmd_buf; /* dcmd buffer */ - u8 *extra_buf; /* maily to grab assoc information */ - struct dentry *debugfsdir; - u8 ci[0] __aligned(NETDEV_ALIGN); -}; - -static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_priv *w) -{ - return w->wdev->wiphy; -} - -static inline struct brcmf_cfg80211_priv *wiphy_to_cfg(struct wiphy *w) -{ - return (struct brcmf_cfg80211_priv *)(wiphy_priv(w)); -} - -static inline struct brcmf_cfg80211_priv *wdev_to_cfg(struct wireless_dev *wd) -{ - return (struct brcmf_cfg80211_priv *)(wdev_priv(wd)); -} - -static inline struct net_device *cfg_to_ndev(struct brcmf_cfg80211_priv *cfg) -{ - return cfg->wdev->netdev; -} - -static inline struct brcmf_cfg80211_priv *ndev_to_cfg(struct net_device *ndev) -{ - return wdev_to_cfg(ndev->ieee80211_ptr); -} - -#define iscan_to_cfg(i) ((struct brcmf_cfg80211_priv *)(i->data)) -#define cfg_to_iscan(w) (w->iscan) - -static inline struct -brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg) -{ - return &cfg->conn_info; -} - -static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, - struct brcmf_bss_info *bss) -{ - return bss = bss ? - (struct brcmf_bss_info *)((unsigned long)bss + - le32_to_cpu(bss->length)) : - list->bss_info; -} - -extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, - struct device *busdev, - void *data); -extern void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg); - -/* event handler from dongle */ -extern void brcmf_cfg80211_event(struct net_device *ndev, - const struct brcmf_event_msg *e, void *data); -extern s32 brcmf_cfg80211_up(struct brcmf_cfg80211_dev *cfg_dev); -extern s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev); - -#endif /* _wl_cfg80211_h_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile deleted file mode 100644 index a8a152b7e01..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Makefile fragment for Broadcom 802.11n Networking Device Driver -# -# Copyright (c) 2010 Broadcom Corporation -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -ccflags-y := \ - -D__CHECK_ENDIAN__ \ - -Idrivers/staging/brcm80211/brcmsmac \ - -Idrivers/staging/brcm80211/brcmsmac/phy \ - -Idrivers/staging/brcm80211/include - -BRCMSMAC_OFILES := \ - mac80211_if.o \ - ucode_loader.o \ - ampdu.o \ - antsel.o \ - channel.o \ - main.o \ - phy_shim.o \ - pmu.o \ - rate.o \ - stf.o \ - aiutils.o \ - phy/phy_cmn.o \ - phy/phy_lcn.o \ - phy/phy_n.o \ - phy/phytbl_lcn.o \ - phy/phytbl_n.o \ - phy/phy_qmath.o \ - otp.o \ - srom.o \ - dma.o \ - nicpci.o \ - brcms_trace_events.o - -MODULEPFX := brcmsmac - -obj-$(CONFIG_BRCMSMAC) += $(MODULEPFX).o -$(MODULEPFX)-objs = $(BRCMSMAC_OFILES) diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.c b/drivers/staging/brcm80211/brcmsmac/aiutils.c deleted file mode 100644 index 025fa0eb6f4..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.c +++ /dev/null @@ -1,2079 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * File contents: support functions for PCI/PCIe - */ - -#include -#include - -#include -#include -#include -#include -#include -#include "types.h" -#include "pub.h" -#include "pmu.h" -#include "srom.h" -#include "nicpci.h" -#include "aiutils.h" - -/* slow_clk_ctl */ - /* slow clock source mask */ -#define SCC_SS_MASK 0x00000007 - /* source of slow clock is LPO */ -#define SCC_SS_LPO 0x00000000 - /* source of slow clock is crystal */ -#define SCC_SS_XTAL 0x00000001 - /* source of slow clock is PCI */ -#define SCC_SS_PCI 0x00000002 - /* LPOFreqSel, 1: 160Khz, 0: 32KHz */ -#define SCC_LF 0x00000200 - /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */ -#define SCC_LP 0x00000400 - /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */ -#define SCC_FS 0x00000800 - /* IgnorePllOffReq, 1/0: - * power logic ignores/honors PLL clock disable requests from core - */ -#define SCC_IP 0x00001000 - /* XtalControlEn, 1/0: - * power logic does/doesn't disable crystal when appropriate - */ -#define SCC_XC 0x00002000 - /* XtalPU (RO), 1/0: crystal running/disabled */ -#define SCC_XP 0x00004000 - /* ClockDivider (SlowClk = 1/(4+divisor)) */ -#define SCC_CD_MASK 0xffff0000 -#define SCC_CD_SHIFT 16 - -/* system_clk_ctl */ - /* ILPen: Enable Idle Low Power */ -#define SYCC_IE 0x00000001 - /* ALPen: Enable Active Low Power */ -#define SYCC_AE 0x00000002 - /* ForcePLLOn */ -#define SYCC_FP 0x00000004 - /* Force ALP (or HT if ALPen is not set */ -#define SYCC_AR 0x00000008 - /* Force HT */ -#define SYCC_HR 0x00000010 - /* ClkDiv (ILP = 1/(4 * (divisor + 1)) */ -#define SYCC_CD_MASK 0xffff0000 -#define SYCC_CD_SHIFT 16 - -#define CST4329_SPROM_OTP_SEL_MASK 0x00000003 - /* OTP is powered up, use def. CIS, no SPROM */ -#define CST4329_DEFCIS_SEL 0 - /* OTP is powered up, SPROM is present */ -#define CST4329_SPROM_SEL 1 - /* OTP is powered up, no SPROM */ -#define CST4329_OTP_SEL 2 - /* OTP is powered down, SPROM is present */ -#define CST4329_OTP_PWRDN 3 - -#define CST4329_SPI_SDIO_MODE_MASK 0x00000004 -#define CST4329_SPI_SDIO_MODE_SHIFT 2 - -/* 43224 chip-specific ChipControl register bits */ -#define CCTRL43224_GPIO_TOGGLE 0x8000 - /* 12 mA drive strength */ -#define CCTRL_43224A0_12MA_LED_DRIVE 0x00F000F0 - /* 12 mA drive strength for later 43224s */ -#define CCTRL_43224B0_12MA_LED_DRIVE 0xF0 - -/* 43236 Chip specific ChipStatus register bits */ -#define CST43236_SFLASH_MASK 0x00000040 -#define CST43236_OTP_MASK 0x00000080 -#define CST43236_HSIC_MASK 0x00000100 /* USB/HSIC */ -#define CST43236_BP_CLK 0x00000200 /* 120/96Mbps */ -#define CST43236_BOOT_MASK 0x00001800 -#define CST43236_BOOT_SHIFT 11 -#define CST43236_BOOT_FROM_SRAM 0 /* boot from SRAM, ARM in reset */ -#define CST43236_BOOT_FROM_ROM 1 /* boot from ROM */ -#define CST43236_BOOT_FROM_FLASH 2 /* boot from FLASH */ -#define CST43236_BOOT_FROM_INVALID 3 - -/* 4331 chip-specific ChipControl register bits */ - /* 0 disable */ -#define CCTRL4331_BT_COEXIST (1<<0) - /* 0 SECI is disabled (JTAG functional) */ -#define CCTRL4331_SECI (1<<1) - /* 0 disable */ -#define CCTRL4331_EXT_LNA (1<<2) - /* sprom/gpio13-15 mux */ -#define CCTRL4331_SPROM_GPIO13_15 (1<<3) - /* 0 ext pa disable, 1 ext pa enabled */ -#define CCTRL4331_EXTPA_EN (1<<4) - /* set drive out GPIO_CLK on sprom_cs pin */ -#define CCTRL4331_GPIOCLK_ON_SPROMCS (1<<5) - /* use sprom_cs pin as PCIE mdio interface */ -#define CCTRL4331_PCIE_MDIO_ON_SPROMCS (1<<6) - /* aband extpa will be at gpio2/5 and sprom_dout */ -#define CCTRL4331_EXTPA_ON_GPIO2_5 (1<<7) - /* override core control on pipe_AuxClkEnable */ -#define CCTRL4331_OVR_PIPEAUXCLKEN (1<<8) - /* override core control on pipe_AuxPowerDown */ -#define CCTRL4331_OVR_PIPEAUXPWRDOWN (1<<9) - /* pcie_auxclkenable */ -#define CCTRL4331_PCIE_AUXCLKEN (1<<10) - /* pcie_pipe_pllpowerdown */ -#define CCTRL4331_PCIE_PIPE_PLLDOWN (1<<11) - /* enable bt_shd0 at gpio4 */ -#define CCTRL4331_BT_SHD0_ON_GPIO4 (1<<16) - /* enable bt_shd1 at gpio5 */ -#define CCTRL4331_BT_SHD1_ON_GPIO5 (1<<17) - -/* 4331 Chip specific ChipStatus register bits */ - /* crystal frequency 20/40Mhz */ -#define CST4331_XTAL_FREQ 0x00000001 -#define CST4331_SPROM_PRESENT 0x00000002 -#define CST4331_OTP_PRESENT 0x00000004 -#define CST4331_LDO_RF 0x00000008 -#define CST4331_LDO_PAR 0x00000010 - -/* 4319 chip-specific ChipStatus register bits */ -#define CST4319_SPI_CPULESSUSB 0x00000001 -#define CST4319_SPI_CLK_POL 0x00000002 -#define CST4319_SPI_CLK_PH 0x00000008 - /* gpio [7:6], SDIO CIS selection */ -#define CST4319_SPROM_OTP_SEL_MASK 0x000000c0 -#define CST4319_SPROM_OTP_SEL_SHIFT 6 - /* use default CIS, OTP is powered up */ -#define CST4319_DEFCIS_SEL 0x00000000 - /* use SPROM, OTP is powered up */ -#define CST4319_SPROM_SEL 0x00000040 - /* use OTP, OTP is powered up */ -#define CST4319_OTP_SEL 0x00000080 - /* use SPROM, OTP is powered down */ -#define CST4319_OTP_PWRDN 0x000000c0 - /* gpio [8], sdio/usb mode */ -#define CST4319_SDIO_USB_MODE 0x00000100 -#define CST4319_REMAP_SEL_MASK 0x00000600 -#define CST4319_ILPDIV_EN 0x00000800 -#define CST4319_XTAL_PD_POL 0x00001000 -#define CST4319_LPO_SEL 0x00002000 -#define CST4319_RES_INIT_MODE 0x0000c000 - /* PALDO is configured with external PNP */ -#define CST4319_PALDO_EXTPNP 0x00010000 -#define CST4319_CBUCK_MODE_MASK 0x00060000 -#define CST4319_CBUCK_MODE_BURST 0x00020000 -#define CST4319_CBUCK_MODE_LPBURST 0x00060000 -#define CST4319_RCAL_VALID 0x01000000 -#define CST4319_RCAL_VALUE_MASK 0x3e000000 -#define CST4319_RCAL_VALUE_SHIFT 25 - -/* 4336 chip-specific ChipStatus register bits */ -#define CST4336_SPI_MODE_MASK 0x00000001 -#define CST4336_SPROM_PRESENT 0x00000002 -#define CST4336_OTP_PRESENT 0x00000004 -#define CST4336_ARMREMAP_0 0x00000008 -#define CST4336_ILPDIV_EN_MASK 0x00000010 -#define CST4336_ILPDIV_EN_SHIFT 4 -#define CST4336_XTAL_PD_POL_MASK 0x00000020 -#define CST4336_XTAL_PD_POL_SHIFT 5 -#define CST4336_LPO_SEL_MASK 0x00000040 -#define CST4336_LPO_SEL_SHIFT 6 -#define CST4336_RES_INIT_MODE_MASK 0x00000180 -#define CST4336_RES_INIT_MODE_SHIFT 7 -#define CST4336_CBUCK_MODE_MASK 0x00000600 -#define CST4336_CBUCK_MODE_SHIFT 9 - -/* 4313 chip-specific ChipStatus register bits */ -#define CST4313_SPROM_PRESENT 1 -#define CST4313_OTP_PRESENT 2 -#define CST4313_SPROM_OTP_SEL_MASK 0x00000002 -#define CST4313_SPROM_OTP_SEL_SHIFT 0 - -/* 4313 Chip specific ChipControl register bits */ - /* 12 mA drive strengh for later 4313 */ -#define CCTRL_4313_12MA_LED_DRIVE 0x00000007 - -/* Manufacturer Ids */ -#define MFGID_ARM 0x43b -#define MFGID_BRCM 0x4bf -#define MFGID_MIPS 0x4a7 - -/* Enumeration ROM registers */ -#define ER_EROMENTRY 0x000 -#define ER_REMAPCONTROL 0xe00 -#define ER_REMAPSELECT 0xe04 -#define ER_MASTERSELECT 0xe10 -#define ER_ITCR 0xf00 -#define ER_ITIP 0xf04 - -/* Erom entries */ -#define ER_TAG 0xe -#define ER_TAG1 0x6 -#define ER_VALID 1 -#define ER_CI 0 -#define ER_MP 2 -#define ER_ADD 4 -#define ER_END 0xe -#define ER_BAD 0xffffffff - -/* EROM CompIdentA */ -#define CIA_MFG_MASK 0xfff00000 -#define CIA_MFG_SHIFT 20 -#define CIA_CID_MASK 0x000fff00 -#define CIA_CID_SHIFT 8 -#define CIA_CCL_MASK 0x000000f0 -#define CIA_CCL_SHIFT 4 - -/* EROM CompIdentB */ -#define CIB_REV_MASK 0xff000000 -#define CIB_REV_SHIFT 24 -#define CIB_NSW_MASK 0x00f80000 -#define CIB_NSW_SHIFT 19 -#define CIB_NMW_MASK 0x0007c000 -#define CIB_NMW_SHIFT 14 -#define CIB_NSP_MASK 0x00003e00 -#define CIB_NSP_SHIFT 9 -#define CIB_NMP_MASK 0x000001f0 -#define CIB_NMP_SHIFT 4 - -/* EROM AddrDesc */ -#define AD_ADDR_MASK 0xfffff000 -#define AD_SP_MASK 0x00000f00 -#define AD_SP_SHIFT 8 -#define AD_ST_MASK 0x000000c0 -#define AD_ST_SHIFT 6 -#define AD_ST_SLAVE 0x00000000 -#define AD_ST_BRIDGE 0x00000040 -#define AD_ST_SWRAP 0x00000080 -#define AD_ST_MWRAP 0x000000c0 -#define AD_SZ_MASK 0x00000030 -#define AD_SZ_SHIFT 4 -#define AD_SZ_4K 0x00000000 -#define AD_SZ_8K 0x00000010 -#define AD_SZ_16K 0x00000020 -#define AD_SZ_SZD 0x00000030 -#define AD_AG32 0x00000008 -#define AD_ADDR_ALIGN 0x00000fff -#define AD_SZ_BASE 0x00001000 /* 4KB */ - -/* EROM SizeDesc */ -#define SD_SZ_MASK 0xfffff000 -#define SD_SG32 0x00000008 -#define SD_SZ_ALIGN 0x00000fff - -/* PCI config space bit 4 for 4306c0 slow clock source */ -#define PCI_CFG_GPIO_SCS 0x10 -/* PCI config space GPIO 14 for Xtal power-up */ -#define PCI_CFG_GPIO_XTAL 0x40 -/* PCI config space GPIO 15 for PLL power-down */ -#define PCI_CFG_GPIO_PLL 0x80 - -/* power control defines */ -#define PLL_DELAY 150 /* us pll on delay */ -#define FREF_DELAY 200 /* us fref change delay */ -#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */ - -/* resetctrl */ -#define AIRC_RESET 1 - -#define NOREV -1 /* Invalid rev */ - -/* GPIO Based LED powersave defines */ -#define DEFAULT_GPIO_ONTIME 10 /* Default: 10% on */ -#define DEFAULT_GPIO_OFFTIME 90 /* Default: 10% on */ - -/* When Srom support present, fields in sromcontrol */ -#define SRC_START 0x80000000 -#define SRC_BUSY 0x80000000 -#define SRC_OPCODE 0x60000000 -#define SRC_OP_READ 0x00000000 -#define SRC_OP_WRITE 0x20000000 -#define SRC_OP_WRDIS 0x40000000 -#define SRC_OP_WREN 0x60000000 -#define SRC_OTPSEL 0x00000010 -#define SRC_LOCK 0x00000008 -#define SRC_SIZE_MASK 0x00000006 -#define SRC_SIZE_1K 0x00000000 -#define SRC_SIZE_4K 0x00000002 -#define SRC_SIZE_16K 0x00000004 -#define SRC_SIZE_SHIFT 1 -#define SRC_PRESENT 0x00000001 - -/* External PA enable mask */ -#define GPIO_CTRL_EPA_EN_MASK 0x40 - -#define DEFAULT_GPIOTIMERVAL \ - ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME) - -#define BADIDX (SI_MAXCORES + 1) - -/* Newer chips can access PCI/PCIE and CC core without requiring to change - * PCI BAR0 WIN - */ -#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) || \ - (((si)->pub.buscoretype == PCI_CORE_ID) && \ - (si)->pub.buscorerev >= 13)) - -#define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \ - PCI_16KB0_CCREGS_OFFSET)) - -#define IS_SIM(chippkg) \ - ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) - -/* - * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts - * before after core switching to avoid invalid register accesss inside ISR. - */ -#define INTR_OFF(si, intr_val) \ - if ((si)->intrsoff_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - intr_val = (*(si)->intrsoff_fn)((si)->intr_arg) - -#define INTR_RESTORE(si, intr_val) \ - if ((si)->intrsrestore_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val) - -#define PCI(si) ((si)->pub.buscoretype == PCI_CORE_ID) -#define PCIE(si) ((si)->pub.buscoretype == PCIE_CORE_ID) - -#define PCI_FORCEHT(si) (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID)) - -#ifdef BCMDBG -#define SI_MSG(args) printk args -#else -#define SI_MSG(args) -#endif /* BCMDBG */ - -#define GOODCOREADDR(x, b) \ - (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ - IS_ALIGNED((x), SI_CORE_SIZE)) - -#define PCIEREGS(si) ((__iomem char *)((si)->curmap) + \ - PCI_16KB0_PCIREGS_OFFSET) - -struct aidmp { - u32 oobselina30; /* 0x000 */ - u32 oobselina74; /* 0x004 */ - u32 PAD[6]; - u32 oobselinb30; /* 0x020 */ - u32 oobselinb74; /* 0x024 */ - u32 PAD[6]; - u32 oobselinc30; /* 0x040 */ - u32 oobselinc74; /* 0x044 */ - u32 PAD[6]; - u32 oobselind30; /* 0x060 */ - u32 oobselind74; /* 0x064 */ - u32 PAD[38]; - u32 oobselouta30; /* 0x100 */ - u32 oobselouta74; /* 0x104 */ - u32 PAD[6]; - u32 oobseloutb30; /* 0x120 */ - u32 oobseloutb74; /* 0x124 */ - u32 PAD[6]; - u32 oobseloutc30; /* 0x140 */ - u32 oobseloutc74; /* 0x144 */ - u32 PAD[6]; - u32 oobseloutd30; /* 0x160 */ - u32 oobseloutd74; /* 0x164 */ - u32 PAD[38]; - u32 oobsynca; /* 0x200 */ - u32 oobseloutaen; /* 0x204 */ - u32 PAD[6]; - u32 oobsyncb; /* 0x220 */ - u32 oobseloutben; /* 0x224 */ - u32 PAD[6]; - u32 oobsyncc; /* 0x240 */ - u32 oobseloutcen; /* 0x244 */ - u32 PAD[6]; - u32 oobsyncd; /* 0x260 */ - u32 oobseloutden; /* 0x264 */ - u32 PAD[38]; - u32 oobaextwidth; /* 0x300 */ - u32 oobainwidth; /* 0x304 */ - u32 oobaoutwidth; /* 0x308 */ - u32 PAD[5]; - u32 oobbextwidth; /* 0x320 */ - u32 oobbinwidth; /* 0x324 */ - u32 oobboutwidth; /* 0x328 */ - u32 PAD[5]; - u32 oobcextwidth; /* 0x340 */ - u32 oobcinwidth; /* 0x344 */ - u32 oobcoutwidth; /* 0x348 */ - u32 PAD[5]; - u32 oobdextwidth; /* 0x360 */ - u32 oobdinwidth; /* 0x364 */ - u32 oobdoutwidth; /* 0x368 */ - u32 PAD[37]; - u32 ioctrlset; /* 0x400 */ - u32 ioctrlclear; /* 0x404 */ - u32 ioctrl; /* 0x408 */ - u32 PAD[61]; - u32 iostatus; /* 0x500 */ - u32 PAD[127]; - u32 ioctrlwidth; /* 0x700 */ - u32 iostatuswidth; /* 0x704 */ - u32 PAD[62]; - u32 resetctrl; /* 0x800 */ - u32 resetstatus; /* 0x804 */ - u32 resetreadid; /* 0x808 */ - u32 resetwriteid; /* 0x80c */ - u32 PAD[60]; - u32 errlogctrl; /* 0x900 */ - u32 errlogdone; /* 0x904 */ - u32 errlogstatus; /* 0x908 */ - u32 errlogaddrlo; /* 0x90c */ - u32 errlogaddrhi; /* 0x910 */ - u32 errlogid; /* 0x914 */ - u32 errloguser; /* 0x918 */ - u32 errlogflags; /* 0x91c */ - u32 PAD[56]; - u32 intstatus; /* 0xa00 */ - u32 PAD[127]; - u32 config; /* 0xe00 */ - u32 PAD[63]; - u32 itcr; /* 0xf00 */ - u32 PAD[3]; - u32 itipooba; /* 0xf10 */ - u32 itipoobb; /* 0xf14 */ - u32 itipoobc; /* 0xf18 */ - u32 itipoobd; /* 0xf1c */ - u32 PAD[4]; - u32 itipoobaout; /* 0xf30 */ - u32 itipoobbout; /* 0xf34 */ - u32 itipoobcout; /* 0xf38 */ - u32 itipoobdout; /* 0xf3c */ - u32 PAD[4]; - u32 itopooba; /* 0xf50 */ - u32 itopoobb; /* 0xf54 */ - u32 itopoobc; /* 0xf58 */ - u32 itopoobd; /* 0xf5c */ - u32 PAD[4]; - u32 itopoobain; /* 0xf70 */ - u32 itopoobbin; /* 0xf74 */ - u32 itopoobcin; /* 0xf78 */ - u32 itopoobdin; /* 0xf7c */ - u32 PAD[4]; - u32 itopreset; /* 0xf90 */ - u32 PAD[15]; - u32 peripherialid4; /* 0xfd0 */ - u32 peripherialid5; /* 0xfd4 */ - u32 peripherialid6; /* 0xfd8 */ - u32 peripherialid7; /* 0xfdc */ - u32 peripherialid0; /* 0xfe0 */ - u32 peripherialid1; /* 0xfe4 */ - u32 peripherialid2; /* 0xfe8 */ - u32 peripherialid3; /* 0xfec */ - u32 componentid0; /* 0xff0 */ - u32 componentid1; /* 0xff4 */ - u32 componentid2; /* 0xff8 */ - u32 componentid3; /* 0xffc */ -}; - -/* EROM parsing */ - -static u32 -get_erom_ent(struct si_pub *sih, u32 __iomem **eromptr, u32 mask, u32 match) -{ - u32 ent; - uint inv = 0, nom = 0; - - while (true) { - ent = R_REG(*eromptr); - (*eromptr)++; - - if (mask == 0) - break; - - if ((ent & ER_VALID) == 0) { - inv++; - continue; - } - - if (ent == (ER_END | ER_VALID)) - break; - - if ((ent & mask) == match) - break; - - nom++; - } - - return ent; -} - -static u32 -get_asd(struct si_pub *sih, u32 __iomem **eromptr, uint sp, uint ad, uint st, - u32 *addrl, u32 *addrh, u32 *sizel, u32 *sizeh) -{ - u32 asd, sz, szd; - - asd = get_erom_ent(sih, eromptr, ER_VALID, ER_VALID); - if (((asd & ER_TAG1) != ER_ADD) || - (((asd & AD_SP_MASK) >> AD_SP_SHIFT) != sp) || - ((asd & AD_ST_MASK) != st)) { - /* This is not what we want, "push" it back */ - (*eromptr)--; - return 0; - } - *addrl = asd & AD_ADDR_MASK; - if (asd & AD_AG32) - *addrh = get_erom_ent(sih, eromptr, 0, 0); - else - *addrh = 0; - *sizeh = 0; - sz = asd & AD_SZ_MASK; - if (sz == AD_SZ_SZD) { - szd = get_erom_ent(sih, eromptr, 0, 0); - *sizel = szd & SD_SZ_MASK; - if (szd & SD_SG32) - *sizeh = get_erom_ent(sih, eromptr, 0, 0); - } else - *sizel = AD_SZ_BASE << (sz >> AD_SZ_SHIFT); - - return asd; -} - -static void ai_hwfixup(struct si_info *sii) -{ -} - -/* parse the enumeration rom to identify all cores */ -static void ai_scan(struct si_pub *sih, struct chipcregs __iomem *cc) -{ - struct si_info *sii = (struct si_info *)sih; - - u32 erombase; - u32 __iomem *eromptr, *eromlim; - void __iomem *regs = cc; - - erombase = R_REG(&cc->eromptr); - - /* Set wrappers address */ - sii->curwrap = (void *)((unsigned long)cc + SI_CORE_SIZE); - - /* Now point the window at the erom */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); - eromptr = regs; - eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); - - while (eromptr < eromlim) { - u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp; - u32 mpd, asd, addrl, addrh, sizel, sizeh; - u32 __iomem *base; - uint i, j, idx; - bool br; - - br = false; - - /* Grok a component */ - cia = get_erom_ent(sih, &eromptr, ER_TAG, ER_CI); - if (cia == (ER_END | ER_VALID)) { - /* Found END of erom */ - ai_hwfixup(sii); - return; - } - base = eromptr - 1; - cib = get_erom_ent(sih, &eromptr, 0, 0); - - if ((cib & ER_TAG) != ER_CI) { - /* CIA not followed by CIB */ - goto error; - } - - cid = (cia & CIA_CID_MASK) >> CIA_CID_SHIFT; - mfg = (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT; - crev = (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; - nmw = (cib & CIB_NMW_MASK) >> CIB_NMW_SHIFT; - nsw = (cib & CIB_NSW_MASK) >> CIB_NSW_SHIFT; - nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT; - nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT; - - if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0)) - continue; - if ((nmw + nsw == 0)) { - /* A component which is not a core */ - if (cid == OOB_ROUTER_CORE_ID) { - asd = get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, - &addrl, &addrh, &sizel, &sizeh); - if (asd != 0) - sii->oob_router = addrl; - } - continue; - } - - idx = sii->numcores; -/* sii->eromptr[idx] = base; */ - sii->cia[idx] = cia; - sii->cib[idx] = cib; - sii->coreid[idx] = cid; - - for (i = 0; i < nmp; i++) { - mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID); - if ((mpd & ER_TAG) != ER_MP) { - /* Not enough MP entries for component */ - goto error; - } - } - - /* First Slave Address Descriptor should be port 0: - * the main register space for the core - */ - asd = - get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, &addrl, &addrh, - &sizel, &sizeh); - if (asd == 0) { - /* Try again to see if it is a bridge */ - asd = - get_asd(sih, &eromptr, 0, 0, AD_ST_BRIDGE, &addrl, - &addrh, &sizel, &sizeh); - if (asd != 0) - br = true; - else if ((addrh != 0) || (sizeh != 0) - || (sizel != SI_CORE_SIZE)) { - /* First Slave ASD for core malformed */ - goto error; - } - } - sii->coresba[idx] = addrl; - sii->coresba_size[idx] = sizel; - /* Get any more ASDs in port 0 */ - j = 1; - do { - asd = - get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl, - &addrh, &sizel, &sizeh); - if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) { - sii->coresba2[idx] = addrl; - sii->coresba2_size[idx] = sizel; - } - j++; - } while (asd != 0); - - /* Go through the ASDs for other slave ports */ - for (i = 1; i < nsp; i++) { - j = 0; - do { - asd = - get_asd(sih, &eromptr, i, j++, AD_ST_SLAVE, - &addrl, &addrh, &sizel, &sizeh); - } while (asd != 0); - if (j == 0) { - /* SP has no address descriptors */ - goto error; - } - } - - /* Now get master wrappers */ - for (i = 0; i < nmw; i++) { - asd = - get_asd(sih, &eromptr, i, 0, AD_ST_MWRAP, &addrl, - &addrh, &sizel, &sizeh); - if (asd == 0) { - /* Missing descriptor for MW */ - goto error; - } - if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - /* Master wrapper %d is not 4KB */ - goto error; - } - if (i == 0) - sii->wrapba[idx] = addrl; - } - - /* And finally slave wrappers */ - for (i = 0; i < nsw; i++) { - uint fwp = (nsp == 1) ? 0 : 1; - asd = - get_asd(sih, &eromptr, fwp + i, 0, AD_ST_SWRAP, - &addrl, &addrh, &sizel, &sizeh); - if (asd == 0) { - /* Missing descriptor for SW */ - goto error; - } - if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - /* Slave wrapper is not 4KB */ - goto error; - } - if ((nmw == 0) && (i == 0)) - sii->wrapba[idx] = addrl; - } - - /* Don't record bridges */ - if (br) - continue; - - /* Done with core */ - sii->numcores++; - } - - error: - /* Reached end of erom without finding END */ - sii->numcores = 0; - return; -} - -/* - * This function changes the logical "focus" to the indicated core. - * Return the current core's virtual address. Since each core starts with the - * same set of registers (BIST, clock control, etc), the returned address - * contains the first register of this 'common' register block (not to be - * confused with 'common core'). - */ -void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) -{ - struct si_info *sii = (struct si_info *)sih; - u32 addr = sii->coresba[coreidx]; - u32 wrap = sii->wrapba[coreidx]; - - if (coreidx >= sii->numcores) - return NULL; - - /* point bar0 window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr); - /* point bar0 2nd 4KB window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap); - sii->curidx = coreidx; - - return sii->curmap; -} - -/* Return the number of address spaces in current core */ -int ai_numaddrspaces(struct si_pub *sih) -{ - return 2; -} - -/* Return the address of the nth address space in the current core */ -u32 ai_addrspace(struct si_pub *sih, uint asidx) -{ - struct si_info *sii; - uint cidx; - - sii = (struct si_info *)sih; - cidx = sii->curidx; - - if (asidx == 0) - return sii->coresba[cidx]; - else if (asidx == 1) - return sii->coresba2[cidx]; - else { - /* Need to parse the erom again to find addr space */ - return 0; - } -} - -/* Return the size of the nth address space in the current core */ -u32 ai_addrspacesize(struct si_pub *sih, uint asidx) -{ - struct si_info *sii; - uint cidx; - - sii = (struct si_info *)sih; - cidx = sii->curidx; - - if (asidx == 0) - return sii->coresba_size[cidx]; - else if (asidx == 1) - return sii->coresba2_size[cidx]; - else { - /* Need to parse the erom again to find addr */ - return 0; - } -} - -uint ai_flag(struct si_pub *sih) -{ - struct si_info *sii; - struct aidmp *ai; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - return R_REG(&ai->oobselouta30) & 0x1f; -} - -void ai_setint(struct si_pub *sih, int siflag) -{ -} - -uint ai_corevendor(struct si_pub *sih) -{ - struct si_info *sii; - u32 cia; - - sii = (struct si_info *)sih; - cia = sii->cia[sii->curidx]; - return (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT; -} - -uint ai_corerev(struct si_pub *sih) -{ - struct si_info *sii; - u32 cib; - - sii = (struct si_info *)sih; - cib = sii->cib[sii->curidx]; - return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; -} - -bool ai_iscoreup(struct si_pub *sih) -{ - struct si_info *sii; - struct aidmp *ai; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) == - SICF_CLOCK_EN) - && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0)); -} - -void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->ioctrl) & ~mask) | val); - W_REG(&ai->ioctrl, w); - } -} - -u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->ioctrl) & ~mask) | val); - W_REG(&ai->ioctrl, w); - } - - return R_REG(&ai->ioctrl); -} - -/* return true if PCIE capability exists in the pci config space */ -static bool ai_ispcie(struct si_info *sii) -{ - u8 cap_ptr; - - cap_ptr = - pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL, - NULL); - if (!cap_ptr) - return false; - - return true; -} - -static bool ai_buscore_prep(struct si_info *sii) -{ - /* kludge to enable the clock on the 4306 which lacks a slowclock */ - if (!ai_ispcie(sii)) - ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON); - return true; -} - -u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->iostatus) & ~mask) | val); - W_REG(&ai->iostatus, w); - } - - return R_REG(&ai->iostatus); -} - -static bool -ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) -{ - bool pci, pcie; - uint i; - uint pciidx, pcieidx, pcirev, pcierev; - struct chipcregs __iomem *cc; - - cc = ai_setcoreidx(&sii->pub, SI_CC_IDX); - - /* get chipcommon rev */ - sii->pub.ccrev = (int)ai_corerev(&sii->pub); - - /* get chipcommon chipstatus */ - if (sii->pub.ccrev >= 11) - sii->pub.chipst = R_REG(&cc->chipstatus); - - /* get chipcommon capabilites */ - sii->pub.cccaps = R_REG(&cc->capabilities); - /* get chipcommon extended capabilities */ - - if (sii->pub.ccrev >= 35) - sii->pub.cccaps_ext = R_REG(&cc->capabilities_ext); - - /* get pmu rev and caps */ - if (sii->pub.cccaps & CC_CAP_PMU) { - sii->pub.pmucaps = R_REG(&cc->pmucapabilities); - sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; - } - - /* figure out bus/orignal core idx */ - sii->pub.buscoretype = NODEV_CORE_ID; - sii->pub.buscorerev = NOREV; - sii->pub.buscoreidx = BADIDX; - - pci = pcie = false; - pcirev = pcierev = NOREV; - pciidx = pcieidx = BADIDX; - - for (i = 0; i < sii->numcores; i++) { - uint cid, crev; - - ai_setcoreidx(&sii->pub, i); - cid = ai_coreid(&sii->pub); - crev = ai_corerev(&sii->pub); - - if (cid == PCI_CORE_ID) { - pciidx = i; - pcirev = crev; - pci = true; - } else if (cid == PCIE_CORE_ID) { - pcieidx = i; - pcierev = crev; - pcie = true; - } - - /* find the core idx before entering this func. */ - if ((savewin && (savewin == sii->coresba[i])) || - (cc == sii->regs[i])) - *origidx = i; - } - - if (pci && pcie) { - if (ai_ispcie(sii)) - pci = false; - else - pcie = false; - } - if (pci) { - sii->pub.buscoretype = PCI_CORE_ID; - sii->pub.buscorerev = pcirev; - sii->pub.buscoreidx = pciidx; - } else if (pcie) { - sii->pub.buscoretype = PCIE_CORE_ID; - sii->pub.buscorerev = pcierev; - sii->pub.buscoreidx = pcieidx; - } - - /* fixup necessary chip/core configurations */ - if (SI_FAST(sii)) { - if (!sii->pch) { - sii->pch = pcicore_init(&sii->pub, sii->pbus, - (__iomem void *)PCIEREGS(sii)); - if (sii->pch == NULL) - return false; - } - } - if (ai_pci_fixcfg(&sii->pub)) { - /* si_doattach: si_pci_fixcfg failed */ - return false; - } - - /* return to the original core */ - ai_setcoreidx(&sii->pub, *origidx); - - return true; -} - -/* - * get boardtype and boardrev - */ -static __used void ai_nvram_process(struct si_info *sii) -{ - uint w = 0; - - /* do a pci config read to get subsystem id and subvendor id */ - pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w); - - sii->pub.boardvendor = w & 0xffff; - sii->pub.boardtype = (w >> 16) & 0xffff; - sii->pub.boardflags = getintvar(&sii->pub, BRCMS_SROM_BOARDFLAGS); -} - -static struct si_info *ai_doattach(struct si_info *sii, - void __iomem *regs, struct pci_dev *pbus) -{ - struct si_pub *sih = &sii->pub; - u32 w, savewin; - struct chipcregs __iomem *cc; - uint socitype; - uint origidx; - - memset((unsigned char *) sii, 0, sizeof(struct si_info)); - - savewin = 0; - - sih->buscoreidx = BADIDX; - - sii->curmap = regs; - sii->pbus = pbus; - - /* find Chipcommon address */ - pci_read_config_dword(sii->pbus, PCI_BAR0_WIN, &savewin); - if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) - savewin = SI_ENUM_BASE; - - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, - SI_ENUM_BASE); - cc = (struct chipcregs __iomem *) regs; - - /* bus/core/clk setup for register access */ - if (!ai_buscore_prep(sii)) - return NULL; - - /* - * ChipID recognition. - * We assume we can read chipid at offset 0 from the regs arg. - * If we add other chiptypes (or if we need to support old sdio - * hosts w/o chipcommon), some way of recognizing them needs to - * be added here. - */ - w = R_REG(&cc->chipid); - socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT; - /* Might as wll fill in chip id rev & pkg */ - sih->chip = w & CID_ID_MASK; - sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT; - sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT; - - sih->issim = false; - - /* scan for cores */ - if (socitype == SOCI_AI) { - SI_MSG(("Found chip type AI (0x%08x)\n", w)); - /* pass chipc address instead of original core base */ - ai_scan(&sii->pub, cc); - } else { - /* Found chip of unknown type */ - return NULL; - } - /* no cores found, bail out */ - if (sii->numcores == 0) - return NULL; - - /* bus/core/clk setup */ - origidx = SI_CC_IDX; - if (!ai_buscore_setup(sii, savewin, &origidx)) - goto exit; - - /* Init nvram from sprom/otp if they exist */ - if (srom_var_init(&sii->pub, cc)) - goto exit; - - ai_nvram_process(sii); - - /* === NVRAM, clock is ready === */ - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); - W_REG(&cc->gpiopullup, 0); - W_REG(&cc->gpiopulldown, 0); - ai_setcoreidx(sih, origidx); - - /* PMU specific initializations */ - if (sih->cccaps & CC_CAP_PMU) { - u32 xtalfreq; - si_pmu_init(sih); - si_pmu_chip_init(sih); - - xtalfreq = si_pmu_measure_alpclk(sih); - si_pmu_pll_init(sih, xtalfreq); - si_pmu_res_init(sih); - si_pmu_swreg_init(sih); - } - - /* setup the GPIO based LED powersave register */ - w = getintvar(sih, BRCMS_SROM_LEDDC); - if (w == 0) - w = DEFAULT_GPIOTIMERVAL; - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), - ~0, w); - - if (PCIE(sii)) - pcicore_attach(sii->pch, SI_DOATTACH); - - if (sih->chip == BCM43224_CHIP_ID) { - /* - * enable 12 mA drive strenth for 43224 and - * set chipControl register bit 15 - */ - if (sih->chiprev == 0) { - SI_MSG(("Applying 43224A0 WARs\n")); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol), - CCTRL43224_GPIO_TOGGLE, - CCTRL43224_GPIO_TOGGLE); - si_pmu_chipcontrol(sih, 0, CCTRL_43224A0_12MA_LED_DRIVE, - CCTRL_43224A0_12MA_LED_DRIVE); - } - if (sih->chiprev >= 1) { - SI_MSG(("Applying 43224B0+ WARs\n")); - si_pmu_chipcontrol(sih, 0, CCTRL_43224B0_12MA_LED_DRIVE, - CCTRL_43224B0_12MA_LED_DRIVE); - } - } - - if (sih->chip == BCM4313_CHIP_ID) { - /* - * enable 12 mA drive strenth for 4313 and - * set chipControl register bit 1 - */ - SI_MSG(("Applying 4313 WARs\n")); - si_pmu_chipcontrol(sih, 0, CCTRL_4313_12MA_LED_DRIVE, - CCTRL_4313_12MA_LED_DRIVE); - } - - return sii; - - exit: - if (sii->pch) - pcicore_deinit(sii->pch); - sii->pch = NULL; - - return NULL; -} - -/* - * Allocate a si handle. - * devid - pci device id (used to determine chip#) - * osh - opaque OS handle - * regs - virtual address of initial core registers - */ -struct si_pub * -ai_attach(void __iomem *regs, struct pci_dev *sdh) -{ - struct si_info *sii; - - /* alloc struct si_info */ - sii = kmalloc(sizeof(struct si_info), GFP_ATOMIC); - if (sii == NULL) - return NULL; - - if (ai_doattach(sii, regs, sdh) == NULL) { - kfree(sii); - return NULL; - } - - return (struct si_pub *) sii; -} - -/* may be called with core in reset */ -void ai_detach(struct si_pub *sih) -{ - struct si_info *sii; - - struct si_pub *si_local = NULL; - memcpy(&si_local, &sih, sizeof(struct si_pub **)); - - sii = (struct si_info *)sih; - - if (sii == NULL) - return; - - if (sii->pch) - pcicore_deinit(sii->pch); - sii->pch = NULL; - - srom_free_vars(sih); - kfree(sii); -} - -/* register driver interrupt disabling and restoring callback functions */ -void -ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, - void *intrsrestore_fn, - void *intrsenabled_fn, void *intr_arg) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - sii->intr_arg = intr_arg; - sii->intrsoff_fn = (u32 (*)(void *)) intrsoff_fn; - sii->intrsrestore_fn = (void (*) (void *, u32)) intrsrestore_fn; - sii->intrsenabled_fn = (bool (*)(void *)) intrsenabled_fn; - /* save current core id. when this function called, the current core - * must be the core which provides driver functions(il, et, wl, etc.) - */ - sii->dev_coreid = sii->coreid[sii->curidx]; -} - -void ai_deregister_intr_callback(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - sii->intrsoff_fn = NULL; -} - -uint ai_coreid(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - return sii->coreid[sii->curidx]; -} - -uint ai_coreidx(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - return sii->curidx; -} - -bool ai_backplane64(struct si_pub *sih) -{ - return (sih->cccaps & CC_CAP_BKPLN64) != 0; -} - -/* return index of coreid or BADIDX if not found */ -uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) -{ - struct si_info *sii; - uint found; - uint i; - - sii = (struct si_info *)sih; - - found = 0; - - for (i = 0; i < sii->numcores; i++) - if (sii->coreid[i] == coreid) { - if (found == coreunit) - return i; - found++; - } - - return BADIDX; -} - -/* - * This function changes logical "focus" to the indicated core; - * must be called with interrupts off. - * Moreover, callers should keep interrupts off during switching - * out of and back to d11 core. - */ -void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) -{ - uint idx; - - idx = ai_findcoreidx(sih, coreid, coreunit); - if (idx >= SI_MAXCORES) - return NULL; - - return ai_setcoreidx(sih, idx); -} - -/* Turn off interrupt as required by ai_setcore, before switch core */ -void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, - uint *intr_val) -{ - void __iomem *cc; - struct si_info *sii; - - sii = (struct si_info *)sih; - - if (SI_FAST(sii)) { - /* Overloading the origidx variable to remember the coreid, - * this works because the core ids cannot be confused with - * core indices. - */ - *origidx = coreid; - if (coreid == CC_CORE_ID) - return CCREGS_FAST(sii); - else if (coreid == sih->buscoretype) - return PCIEREGS(sii); - } - INTR_OFF(sii, *intr_val); - *origidx = sii->curidx; - cc = ai_setcore(sih, coreid, 0); - return cc; -} - -/* restore coreidx and restore interrupt */ -void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - if (SI_FAST(sii) - && ((coreid == CC_CORE_ID) || (coreid == sih->buscoretype))) - return; - - ai_setcoreidx(sih, coreid); - INTR_RESTORE(sii, intr_val); -} - -void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val) -{ - struct si_info *sii = (struct si_info *)sih; - u32 *w = (u32 *) sii->curwrap; - W_REG(w + (offset / 4), val); - return; -} - -/* - * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set - * operation, switch back to the original core, and return the new value. - * - * When using the silicon backplane, no fiddling with interrupts or core - * switches is needed. - * - * Also, when using pci/pcie, we can optimize away the core switching for pci - * registers and (on newer pci cores) chipcommon registers. - */ -uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val) -{ - uint origidx = 0; - u32 __iomem *r = NULL; - uint w; - uint intr_val = 0; - bool fast = false; - struct si_info *sii; - - sii = (struct si_info *)sih; - - if (coreidx >= SI_MAXCORES) - return 0; - - /* - * If pci/pcie, we can get at pci/pcie regs - * and on newer cores to chipc - */ - if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { - /* Chipc registers are mapped at 12KB */ - fast = true; - r = (u32 __iomem *)((__iomem char *)sii->curmap + - PCI_16KB0_CCREGS_OFFSET + regoff); - } else if (sii->pub.buscoreidx == coreidx) { - /* - * pci registers are at either in the last 2KB of - * an 8KB window or, in pcie and pci rev 13 at 8KB - */ - fast = true; - if (SI_FAST(sii)) - r = (u32 __iomem *)((__iomem char *)sii->curmap + - PCI_16KB0_PCIREGS_OFFSET + regoff); - else - r = (u32 __iomem *)((__iomem char *)sii->curmap + - ((regoff >= SBCONFIGOFF) ? - PCI_BAR0_PCISBR_OFFSET : - PCI_BAR0_PCIREGS_OFFSET) + regoff); - } - - if (!fast) { - INTR_OFF(sii, intr_val); - - /* save current core index */ - origidx = ai_coreidx(&sii->pub); - - /* switch core */ - r = (u32 __iomem *) ((unsigned char __iomem *) - ai_setcoreidx(&sii->pub, coreidx) + regoff); - } - - /* mask and set */ - if (mask || val) { - w = (R_REG(r) & ~mask) | val; - W_REG(r, w); - } - - /* readback */ - w = R_REG(r); - - if (!fast) { - /* restore core index */ - if (origidx != coreidx) - ai_setcoreidx(&sii->pub, origidx); - - INTR_RESTORE(sii, intr_val); - } - - return w; -} - -void ai_core_disable(struct si_pub *sih, u32 bits) -{ - struct si_info *sii; - u32 dummy; - struct aidmp *ai; - - sii = (struct si_info *)sih; - - ai = sii->curwrap; - - /* if core is already in reset, just return */ - if (R_REG(&ai->resetctrl) & AIRC_RESET) - return; - - W_REG(&ai->ioctrl, bits); - dummy = R_REG(&ai->ioctrl); - udelay(10); - - W_REG(&ai->resetctrl, AIRC_RESET); - udelay(1); -} - -/* reset and re-enable a core - * inputs: - * bits - core specific bits that are set during and after reset sequence - * resetbits - core specific bits that are set only during reset sequence - */ -void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits) -{ - struct si_info *sii; - struct aidmp *ai; - u32 dummy; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - /* - * Must do the disable sequence first to work - * for arbitrary current core state. - */ - ai_core_disable(sih, (bits | resetbits)); - - /* - * Now do the initialization sequence. - */ - W_REG(&ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN)); - dummy = R_REG(&ai->ioctrl); - W_REG(&ai->resetctrl, 0); - udelay(1); - - W_REG(&ai->ioctrl, (bits | SICF_CLOCK_EN)); - dummy = R_REG(&ai->ioctrl); - udelay(1); -} - -/* return the slow clock source - LPO, XTAL, or PCI */ -static uint ai_slowclk_src(struct si_info *sii) -{ - struct chipcregs __iomem *cc; - u32 val; - - if (sii->pub.ccrev < 6) { - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, - &val); - if (val & PCI_CFG_GPIO_SCS) - return SCC_SS_PCI; - return SCC_SS_XTAL; - } else if (sii->pub.ccrev < 10) { - cc = (struct chipcregs __iomem *) - ai_setcoreidx(&sii->pub, sii->curidx); - return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; - } else /* Insta-clock */ - return SCC_SS_XTAL; -} - -/* -* return the ILP (slowclock) min or max frequency -* precondition: we've established the chip has dynamic clk control -*/ -static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, - struct chipcregs __iomem *cc) -{ - u32 slowclk; - uint div; - - slowclk = ai_slowclk_src(sii); - if (sii->pub.ccrev < 6) { - if (slowclk == SCC_SS_PCI) - return max_freq ? (PCIMAXFREQ / 64) - : (PCIMINFREQ / 64); - else - return max_freq ? (XTALMAXFREQ / 32) - : (XTALMINFREQ / 32); - } else if (sii->pub.ccrev < 10) { - div = 4 * - (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> - SCC_CD_SHIFT) + 1); - if (slowclk == SCC_SS_LPO) - return max_freq ? LPOMAXFREQ : LPOMINFREQ; - else if (slowclk == SCC_SS_XTAL) - return max_freq ? (XTALMAXFREQ / div) - : (XTALMINFREQ / div); - else if (slowclk == SCC_SS_PCI) - return max_freq ? (PCIMAXFREQ / div) - : (PCIMINFREQ / div); - } else { - /* Chipc rev 10 is InstaClock */ - div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT; - div = 4 * (div + 1); - return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div); - } - return 0; -} - -static void -ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) -{ - uint slowmaxfreq, pll_delay, slowclk; - uint pll_on_delay, fref_sel_delay; - - pll_delay = PLL_DELAY; - - /* - * If the slow clock is not sourced by the xtal then - * add the xtal_on_delay since the xtal will also be - * powered down by dynamic clk control logic. - */ - - slowclk = ai_slowclk_src(sii); - if (slowclk != SCC_SS_XTAL) - pll_delay += XTAL_ON_DELAY; - - /* Starting with 4318 it is ILP that is used for the delays */ - slowmaxfreq = - ai_slowclk_freq(sii, (sii->pub.ccrev >= 10) ? false : true, cc); - - pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; - fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; - - W_REG(&cc->pll_on_delay, pll_on_delay); - W_REG(&cc->fref_sel_delay, fref_sel_delay); -} - -/* initialize power control delay registers */ -void ai_clkctl_init(struct si_pub *sih) -{ - struct si_info *sii; - uint origidx = 0; - struct chipcregs __iomem *cc; - bool fast; - - if (!(sih->cccaps & CC_CAP_PWR_CTL)) - return; - - sii = (struct si_info *)sih; - fast = SI_FAST(sii); - if (!fast) { - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); - if (cc == NULL) - return; - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - return; - } - - /* set all Instaclk chip ILP to 1 MHz */ - if (sih->ccrev >= 10) - SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, - (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); - - ai_clkctl_setdelay(sii, cc); - - if (!fast) - ai_setcoreidx(sih, origidx); -} - -/* - * return the value suitable for writing to the - * dot11 core FAST_PWRUP_DELAY register - */ -u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) -{ - struct si_info *sii; - uint origidx = 0; - struct chipcregs __iomem *cc; - uint slowminfreq; - u16 fpdelay; - uint intr_val = 0; - bool fast; - - sii = (struct si_info *)sih; - if (sih->cccaps & CC_CAP_PMU) { - INTR_OFF(sii, intr_val); - fpdelay = si_pmu_fast_pwrup_delay(sih); - INTR_RESTORE(sii, intr_val); - return fpdelay; - } - - if (!(sih->cccaps & CC_CAP_PWR_CTL)) - return 0; - - fast = SI_FAST(sii); - fpdelay = 0; - if (!fast) { - origidx = sii->curidx; - INTR_OFF(sii, intr_val); - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); - if (cc == NULL) - goto done; - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - goto done; - } - - slowminfreq = ai_slowclk_freq(sii, false, cc); - fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + - (slowminfreq - 1)) / slowminfreq; - - done: - if (!fast) { - ai_setcoreidx(sih, origidx); - INTR_RESTORE(sii, intr_val); - } - return fpdelay; -} - -/* turn primary xtal and/or pll off/on */ -int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) -{ - struct si_info *sii; - u32 in, out, outen; - - sii = (struct si_info *)sih; - - /* pcie core doesn't have any mapping to control the xtal pu */ - if (PCIE(sii)) - return -1; - - pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &out); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUTEN, &outen); - - /* - * Avoid glitching the clock if GPRS is already using it. - * We can't actually read the state of the PLLPD so we infer it - * by the value of XTAL_PU which *is* readable via gpioin. - */ - if (on && (in & PCI_CFG_GPIO_XTAL)) - return 0; - - if (what & XTAL) - outen |= PCI_CFG_GPIO_XTAL; - if (what & PLL) - outen |= PCI_CFG_GPIO_PLL; - - if (on) { - /* turn primary xtal on */ - if (what & XTAL) { - out |= PCI_CFG_GPIO_XTAL; - if (what & PLL) - out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUT, out); - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUTEN, outen); - udelay(XTAL_ON_DELAY); - } - - /* turn pll on */ - if (what & PLL) { - out &= ~PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUT, out); - mdelay(2); - } - } else { - if (what & XTAL) - out &= ~PCI_CFG_GPIO_XTAL; - if (what & PLL) - out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUT, out); - pci_write_config_dword(sii->pbus, - PCI_GPIO_OUTEN, outen); - } - - return 0; -} - -/* clk control mechanism through chipcommon, no policy checking */ -static bool _ai_clkctl_cc(struct si_info *sii, uint mode) -{ - uint origidx = 0; - struct chipcregs __iomem *cc; - u32 scc; - uint intr_val = 0; - bool fast = SI_FAST(sii); - - /* chipcommon cores prior to rev6 don't support dynamic clock control */ - if (sii->pub.ccrev < 6) - return false; - - if (!fast) { - INTR_OFF(sii, intr_val); - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(&sii->pub, CC_CORE_ID, 0); - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - goto done; - } - - if (!(sii->pub.cccaps & CC_CAP_PWR_CTL) && (sii->pub.ccrev < 20)) - goto done; - - switch (mode) { - case CLK_FAST: /* FORCEHT, fast (pll) clock */ - if (sii->pub.ccrev < 10) { - /* - * don't forget to force xtal back - * on before we clear SCC_DYN_XTAL.. - */ - ai_clkctl_xtal(&sii->pub, XTAL, ON); - SET_REG(&cc->slow_clk_ctl, - (SCC_XC | SCC_FS | SCC_IP), SCC_IP); - } else if (sii->pub.ccrev < 20) { - OR_REG(&cc->system_clk_ctl, SYCC_HR); - } else { - OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); - } - - /* wait for the PLL */ - if (sii->pub.cccaps & CC_CAP_PMU) { - u32 htavail = CCS_HTAVAIL; - SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) - == 0), PMU_MAX_TRANSITION_DLY); - } else { - udelay(PLL_DELAY); - } - break; - - case CLK_DYNAMIC: /* enable dynamic clock control */ - if (sii->pub.ccrev < 10) { - scc = R_REG(&cc->slow_clk_ctl); - scc &= ~(SCC_FS | SCC_IP | SCC_XC); - if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) - scc |= SCC_XC; - W_REG(&cc->slow_clk_ctl, scc); - - /* - * for dynamic control, we have to - * release our xtal_pu "force on" - */ - if (scc & SCC_XC) - ai_clkctl_xtal(&sii->pub, XTAL, OFF); - } else if (sii->pub.ccrev < 20) { - /* Instaclock */ - AND_REG(&cc->system_clk_ctl, ~SYCC_HR); - } else { - AND_REG(&cc->clk_ctl_st, ~CCS_FORCEHT); - } - break; - - default: - break; - } - - done: - if (!fast) { - ai_setcoreidx(&sii->pub, origidx); - INTR_RESTORE(sii, intr_val); - } - return mode == CLK_FAST; -} - -/* - * clock control policy function throught chipcommon - * - * set dynamic clk control mode (forceslow, forcefast, dynamic) - * returns true if we are forcing fast clock - * this is a wrapper over the next internal function - * to allow flexible policy settings for outside caller - */ -bool ai_clkctl_cc(struct si_pub *sih, uint mode) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - /* chipcommon cores prior to rev6 don't support dynamic clock control */ - if (sih->ccrev < 6) - return false; - - if (PCI_FORCEHT(sii)) - return mode == CLK_FAST; - - return _ai_clkctl_cc(sii, mode); -} - -/* Build device path */ -int ai_devpath(struct si_pub *sih, char *path, int size) -{ - int slen; - - if (!path || size <= 0) - return -1; - - slen = snprintf(path, (size_t) size, "pci/%u/%u/", - ((struct si_info *)sih)->pbus->bus->number, - PCI_SLOT(((struct pci_dev *) - (((struct si_info *)(sih))->pbus))->devfn)); - - if (slen < 0 || slen >= size) { - path[0] = '\0'; - return -1; - } - - return 0; -} - -void ai_pci_up(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - if (PCI_FORCEHT(sii)) - _ai_clkctl_cc(sii, CLK_FAST); - - if (PCIE(sii)) - pcicore_up(sii->pch, SI_PCIUP); - -} - -/* Unconfigure and/or apply various WARs when system is going to sleep mode */ -void ai_pci_sleep(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - pcicore_sleep(sii->pch); -} - -/* Unconfigure and/or apply various WARs when going down */ -void ai_pci_down(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - /* release FORCEHT since chip is going to "down" state */ - if (PCI_FORCEHT(sii)) - _ai_clkctl_cc(sii, CLK_DYNAMIC); - - pcicore_down(sii->pch, SI_PCIDOWN); -} - -/* - * Configure the pci core for pci client (NIC) action - * coremask is the bitvec of cores by index to be enabled. - */ -void ai_pci_setup(struct si_pub *sih, uint coremask) -{ - struct si_info *sii; - struct sbpciregs __iomem *regs = NULL; - u32 siflag = 0, w; - uint idx = 0; - - sii = (struct si_info *)sih; - - if (PCI(sii)) { - /* get current core index */ - idx = sii->curidx; - - /* we interrupt on this backplane flag number */ - siflag = ai_flag(sih); - - /* switch over to pci core */ - regs = ai_setcoreidx(sih, sii->pub.buscoreidx); - } - - /* - * Enable sb->pci interrupts. Assume - * PCI rev 2.3 support was added in pci core rev 6 and things changed.. - */ - if (PCIE(sii) || (PCI(sii) && ((sii->pub.buscorerev) >= 6))) { - /* pci config write to set this core bit in PCIIntMask */ - pci_read_config_dword(sii->pbus, PCI_INT_MASK, &w); - w |= (coremask << PCI_SBIM_SHIFT); - pci_write_config_dword(sii->pbus, PCI_INT_MASK, w); - } else { - /* set sbintvec bit for our flag number */ - ai_setint(sih, siflag); - } - - if (PCI(sii)) { - pcicore_pci_setup(sii->pch, regs); - - /* switch back to previous core */ - ai_setcoreidx(sih, idx); - } -} - -/* - * Fixup SROMless PCI device's configuration. - * The current core may be changed upon return. - */ -int ai_pci_fixcfg(struct si_pub *sih) -{ - uint origidx; - void __iomem *regs = NULL; - struct si_info *sii = (struct si_info *)sih; - - /* Fixup PI in SROM shadow area to enable the correct PCI core access */ - /* save the current index */ - origidx = ai_coreidx(&sii->pub); - - /* check 'pi' is correct and fix it if not */ - regs = ai_setcore(&sii->pub, sii->pub.buscoretype, 0); - if (sii->pub.buscoretype == PCIE_CORE_ID) - pcicore_fixcfg_pcie(sii->pch, - (struct sbpcieregs __iomem *)regs); - else if (sii->pub.buscoretype == PCI_CORE_ID) - pcicore_fixcfg_pci(sii->pch, (struct sbpciregs __iomem *)regs); - - /* restore the original index */ - ai_setcoreidx(&sii->pub, origidx); - - pcicore_hwup(sii->pch); - return 0; -} - -/* mask&set gpiocontrol bits */ -u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) -{ - uint regoff; - - regoff = offsetof(struct chipcregs, gpiocontrol); - return ai_corereg(sih, SI_CC_IDX, regoff, mask, val); -} - -void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) -{ - struct si_info *sii; - struct chipcregs __iomem *cc; - uint origidx; - u32 val; - - sii = (struct si_info *)sih; - origidx = ai_coreidx(sih); - - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); - - val = R_REG(&cc->chipcontrol); - - if (on) { - if (sih->chippkg == 9 || sih->chippkg == 0xb) - /* Ext PA Controls for 4331 12x9 Package */ - W_REG(&cc->chipcontrol, val | - CCTRL4331_EXTPA_EN | - CCTRL4331_EXTPA_ON_GPIO2_5); - else - /* Ext PA Controls for 4331 12x12 Package */ - W_REG(&cc->chipcontrol, - val | CCTRL4331_EXTPA_EN); - } else { - val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); - W_REG(&cc->chipcontrol, val); - } - - ai_setcoreidx(sih, origidx); -} - -/* Enable BT-COEX & Ex-PA for 4313 */ -void ai_epa_4313war(struct si_pub *sih) -{ - struct si_info *sii; - struct chipcregs __iomem *cc; - uint origidx; - - sii = (struct si_info *)sih; - origidx = ai_coreidx(sih); - - cc = ai_setcore(sih, CC_CORE_ID, 0); - - /* EPA Fix */ - W_REG(&cc->gpiocontrol, - R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK); - - ai_setcoreidx(sih, origidx); -} - -/* check if the device is removed */ -bool ai_deviceremoved(struct si_pub *sih) -{ - u32 w; - struct si_info *sii; - - sii = (struct si_info *)sih; - - pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w); - if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM) - return true; - - return false; -} - -bool ai_is_sprom_available(struct si_pub *sih) -{ - if (sih->ccrev >= 31) { - struct si_info *sii; - uint origidx; - struct chipcregs __iomem *cc; - u32 sromctrl; - - if ((sih->cccaps & CC_CAP_SROM) == 0) - return false; - - sii = (struct si_info *)sih; - origidx = sii->curidx; - cc = ai_setcoreidx(sih, SI_CC_IDX); - sromctrl = R_REG(&cc->sromcontrol); - ai_setcoreidx(sih, origidx); - return sromctrl & SRC_PRESENT; - } - - switch (sih->chip) { - case BCM4313_CHIP_ID: - return (sih->chipst & CST4313_SPROM_PRESENT) != 0; - default: - return true; - } -} - -bool ai_is_otp_disabled(struct si_pub *sih) -{ - switch (sih->chip) { - case BCM4313_CHIP_ID: - return (sih->chipst & CST4313_OTP_PRESENT) == 0; - /* These chips always have their OTP on */ - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - default: - return false; - } -} diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h deleted file mode 100644 index 106a7424a7c..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/aiutils.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_AIUTILS_H_ -#define _BRCM_AIUTILS_H_ - -#include "types.h" - -/* - * SOC Interconnect Address Map. - * All regions may not exist on all chips. - */ -/* each core gets 4Kbytes for registers */ -#define SI_CORE_SIZE 0x1000 -/* - * Max cores (this is arbitrary, for software - * convenience and could be changed if we - * make any larger chips - */ -#define SI_MAXCORES 16 - -/* Client Mode sb2pcitranslation2 size in bytes */ -#define SI_PCI_DMA_SZ 0x40000000 - -/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ -#define SI_PCIE_DMA_H32 0x80000000 - -/* core codes */ -#define NODEV_CORE_ID 0x700 /* Invalid coreid */ -#define CC_CORE_ID 0x800 /* chipcommon core */ -#define ILINE20_CORE_ID 0x801 /* iline20 core */ -#define SRAM_CORE_ID 0x802 /* sram core */ -#define SDRAM_CORE_ID 0x803 /* sdram core */ -#define PCI_CORE_ID 0x804 /* pci core */ -#define MIPS_CORE_ID 0x805 /* mips core */ -#define ENET_CORE_ID 0x806 /* enet mac core */ -#define CODEC_CORE_ID 0x807 /* v90 codec core */ -#define USB_CORE_ID 0x808 /* usb 1.1 host/device core */ -#define ADSL_CORE_ID 0x809 /* ADSL core */ -#define ILINE100_CORE_ID 0x80a /* iline100 core */ -#define IPSEC_CORE_ID 0x80b /* ipsec core */ -#define UTOPIA_CORE_ID 0x80c /* utopia core */ -#define PCMCIA_CORE_ID 0x80d /* pcmcia core */ -#define SOCRAM_CORE_ID 0x80e /* internal memory core */ -#define MEMC_CORE_ID 0x80f /* memc sdram core */ -#define OFDM_CORE_ID 0x810 /* OFDM phy core */ -#define EXTIF_CORE_ID 0x811 /* external interface core */ -#define D11_CORE_ID 0x812 /* 802.11 MAC core */ -#define APHY_CORE_ID 0x813 /* 802.11a phy core */ -#define BPHY_CORE_ID 0x814 /* 802.11b phy core */ -#define GPHY_CORE_ID 0x815 /* 802.11g phy core */ -#define MIPS33_CORE_ID 0x816 /* mips3302 core */ -#define USB11H_CORE_ID 0x817 /* usb 1.1 host core */ -#define USB11D_CORE_ID 0x818 /* usb 1.1 device core */ -#define USB20H_CORE_ID 0x819 /* usb 2.0 host core */ -#define USB20D_CORE_ID 0x81a /* usb 2.0 device core */ -#define SDIOH_CORE_ID 0x81b /* sdio host core */ -#define ROBO_CORE_ID 0x81c /* roboswitch core */ -#define ATA100_CORE_ID 0x81d /* parallel ATA core */ -#define SATAXOR_CORE_ID 0x81e /* serial ATA & XOR DMA core */ -#define GIGETH_CORE_ID 0x81f /* gigabit ethernet core */ -#define PCIE_CORE_ID 0x820 /* pci express core */ -#define NPHY_CORE_ID 0x821 /* 802.11n 2x2 phy core */ -#define SRAMC_CORE_ID 0x822 /* SRAM controller core */ -#define MINIMAC_CORE_ID 0x823 /* MINI MAC/phy core */ -#define ARM11_CORE_ID 0x824 /* ARM 1176 core */ -#define ARM7S_CORE_ID 0x825 /* ARM7tdmi-s core */ -#define LPPHY_CORE_ID 0x826 /* 802.11a/b/g phy core */ -#define PMU_CORE_ID 0x827 /* PMU core */ -#define SSNPHY_CORE_ID 0x828 /* 802.11n single-stream phy core */ -#define SDIOD_CORE_ID 0x829 /* SDIO device core */ -#define ARMCM3_CORE_ID 0x82a /* ARM Cortex M3 core */ -#define HTPHY_CORE_ID 0x82b /* 802.11n 4x4 phy core */ -#define MIPS74K_CORE_ID 0x82c /* mips 74k core */ -#define GMAC_CORE_ID 0x82d /* Gigabit MAC core */ -#define DMEMC_CORE_ID 0x82e /* DDR1/2 memory controller core */ -#define PCIERC_CORE_ID 0x82f /* PCIE Root Complex core */ -#define OCP_CORE_ID 0x830 /* OCP2OCP bridge core */ -#define SC_CORE_ID 0x831 /* shared common core */ -#define AHB_CORE_ID 0x832 /* OCP2AHB bridge core */ -#define SPIH_CORE_ID 0x833 /* SPI host core */ -#define I2S_CORE_ID 0x834 /* I2S core */ -#define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ -#define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ -#define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ -#define DEF_AI_COMP 0xfff /* Default component, in ai chips it - * maps all unused address ranges - */ - -/* chipcommon being the first core: */ -#define SI_CC_IDX 0 - -/* SOC Interconnect types (aka chip types) */ -#define SOCI_AI 1 - -/* Common core control flags */ -#define SICF_BIST_EN 0x8000 -#define SICF_PME_EN 0x4000 -#define SICF_CORE_BITS 0x3ffc -#define SICF_FGC 0x0002 -#define SICF_CLOCK_EN 0x0001 - -/* Common core status flags */ -#define SISF_BIST_DONE 0x8000 -#define SISF_BIST_ERROR 0x4000 -#define SISF_GATED_CLK 0x2000 -#define SISF_DMA64 0x1000 -#define SISF_CORE_BITS 0x0fff - -/* A register that is common to all cores to - * communicate w/PMU regarding clock control. - */ -#define SI_CLK_CTL_ST 0x1e0 /* clock control and status */ - -/* clk_ctl_st register */ -#define CCS_FORCEALP 0x00000001 /* force ALP request */ -#define CCS_FORCEHT 0x00000002 /* force HT request */ -#define CCS_FORCEILP 0x00000004 /* force ILP request */ -#define CCS_ALPAREQ 0x00000008 /* ALP Avail Request */ -#define CCS_HTAREQ 0x00000010 /* HT Avail Request */ -#define CCS_FORCEHWREQOFF 0x00000020 /* Force HW Clock Request Off */ -#define CCS_ERSRC_REQ_MASK 0x00000700 /* external resource requests */ -#define CCS_ERSRC_REQ_SHIFT 8 -#define CCS_ALPAVAIL 0x00010000 /* ALP is available */ -#define CCS_HTAVAIL 0x00020000 /* HT is available */ -#define CCS_BP_ON_APL 0x00040000 /* RO: running on ALP clock */ -#define CCS_BP_ON_HT 0x00080000 /* RO: running on HT clock */ -#define CCS_ERSRC_STS_MASK 0x07000000 /* external resource status */ -#define CCS_ERSRC_STS_SHIFT 24 - -/* HT avail in chipc and pcmcia on 4328a0 */ -#define CCS0_HTAVAIL 0x00010000 -/* ALP avail in chipc and pcmcia on 4328a0 */ -#define CCS0_ALPAVAIL 0x00020000 - -/* Not really related to SOC Interconnect, but a couple of software - * conventions for the use the flash space: - */ - -/* Minumum amount of flash we support */ -#define FLASH_MIN 0x00020000 /* Minimum flash size */ - -#define CC_SROM_OTP 0x800 /* SROM/OTP address space */ - -/* gpiotimerval */ -#define GPIO_ONTIME_SHIFT 16 - -/* Fields in clkdiv */ -#define CLKD_OTP 0x000f0000 -#define CLKD_OTP_SHIFT 16 - -/* Package IDs */ -#define BCM4717_PKG_ID 9 /* 4717 package id */ -#define BCM4718_PKG_ID 10 /* 4718 package id */ -#define BCM43224_FAB_SMIC 0xa /* the chip is manufactured by SMIC */ - -/* these are router chips */ -#define BCM4716_CHIP_ID 0x4716 /* 4716 chipcommon chipid */ -#define BCM47162_CHIP_ID 47162 /* 47162 chipcommon chipid */ -#define BCM4748_CHIP_ID 0x4748 /* 4716 chipcommon chipid (OTP, RBBU) */ - -/* dynamic clock control defines */ -#define LPOMINFREQ 25000 /* low power oscillator min */ -#define LPOMAXFREQ 43000 /* low power oscillator max */ -#define XTALMINFREQ 19800000 /* 20 MHz - 1% */ -#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */ -#define PCIMINFREQ 25000000 /* 25 MHz */ -#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */ - -#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */ -#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */ - -/* clkctl xtal what flags */ -#define XTAL 0x1 /* primary crystal oscillator (2050) */ -#define PLL 0x2 /* main chip pll */ - -/* clkctl clk mode */ -#define CLK_FAST 0 /* force fast (pll) clock */ -#define CLK_DYNAMIC 2 /* enable dynamic clock control */ - -/* GPIO usage priorities */ -#define GPIO_DRV_PRIORITY 0 /* Driver */ -#define GPIO_APP_PRIORITY 1 /* Application */ -#define GPIO_HI_PRIORITY 2 /* Highest priority. Ignore GPIO - * reservation - */ - -/* GPIO pull up/down */ -#define GPIO_PULLUP 0 -#define GPIO_PULLDN 1 - -/* GPIO event regtype */ -#define GPIO_REGEVT 0 /* GPIO register event */ -#define GPIO_REGEVT_INTMSK 1 /* GPIO register event int mask */ -#define GPIO_REGEVT_INTPOL 2 /* GPIO register event int polarity */ - -/* device path */ -#define SI_DEVPATH_BUFSZ 16 /* min buffer size in bytes */ - -/* SI routine enumeration: to be used by update function with multiple hooks */ -#define SI_DOATTACH 1 -#define SI_PCIDOWN 2 -#define SI_PCIUP 3 - -/* - * Data structure to export all chip specific common variables - * public (read-only) portion of aiutils handle returned by si_attach() - */ -struct si_pub { - uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ - uint buscorerev; /* buscore rev */ - uint buscoreidx; /* buscore index */ - int ccrev; /* chip common core rev */ - u32 cccaps; /* chip common capabilities */ - u32 cccaps_ext; /* chip common capabilities extension */ - int pmurev; /* pmu core rev */ - u32 pmucaps; /* pmu capabilities */ - uint boardtype; /* board type */ - uint boardvendor; /* board vendor */ - uint boardflags; /* board flags */ - uint boardflags2; /* board flags2 */ - uint chip; /* chip number */ - uint chiprev; /* chip revision */ - uint chippkg; /* chip package option */ - u32 chipst; /* chip status */ - bool issim; /* chip is in simulation or emulation */ - uint socirev; /* SOC interconnect rev */ - bool pci_pr32414; - -}; - -struct pci_dev; - -struct gpioh_item { - void *arg; - bool level; - void (*handler) (u32 stat, void *arg); - u32 event; - struct gpioh_item *next; -}; - -/* misc si info needed by some of the routines */ -struct si_info { - struct si_pub pub; /* back plane public state (must be first) */ - struct pci_dev *pbus; /* handle to pci bus */ - uint dev_coreid; /* the core provides driver functions */ - void *intr_arg; /* interrupt callback function arg */ - u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */ - /* restore chip interrupts */ - void (*intrsrestore_fn) (void *intr_arg, u32 arg); - /* check if interrupts are enabled */ - bool (*intrsenabled_fn) (void *intr_arg); - - struct pcicore_info *pch; /* PCI/E core handle */ - - struct list_head var_list; /* list of srom variables */ - - void __iomem *curmap; /* current regs va */ - void __iomem *regs[SI_MAXCORES]; /* other regs va */ - - uint curidx; /* current core index */ - uint numcores; /* # discovered cores */ - uint coreid[SI_MAXCORES]; /* id of each core */ - u32 coresba[SI_MAXCORES]; /* backplane address of each core */ - void *regs2[SI_MAXCORES]; /* 2nd virtual address per core (usbh20) */ - u32 coresba2[SI_MAXCORES]; /* 2nd phys address per core (usbh20) */ - u32 coresba_size[SI_MAXCORES]; /* backplane address space size */ - u32 coresba2_size[SI_MAXCORES]; /* second address space size */ - - void *curwrap; /* current wrapper va */ - void *wrappers[SI_MAXCORES]; /* other cores wrapper va */ - u32 wrapba[SI_MAXCORES]; /* address of controlling wrapper */ - - u32 cia[SI_MAXCORES]; /* erom cia entry for each core */ - u32 cib[SI_MAXCORES]; /* erom cia entry for each core */ - u32 oob_router; /* oob router registers for axi */ -}; - -/* - * Many of the routines below take an 'sih' handle as their first arg. - * Allocate this by calling si_attach(). Free it by calling si_detach(). - * At any one time, the sih is logically focused on one particular si core - * (the "current core"). - * Use si_setcore() or si_setcoreidx() to change the association to another core - */ - - -/* AMBA Interconnect exported externs */ -extern uint ai_flag(struct si_pub *sih); -extern void ai_setint(struct si_pub *sih, int siflag); -extern uint ai_coreidx(struct si_pub *sih); -extern uint ai_corevendor(struct si_pub *sih); -extern uint ai_corerev(struct si_pub *sih); -extern bool ai_iscoreup(struct si_pub *sih); -extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); -extern void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val); -extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); -extern uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val); -extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); -extern void ai_core_disable(struct si_pub *sih, u32 bits); -extern int ai_numaddrspaces(struct si_pub *sih); -extern u32 ai_addrspace(struct si_pub *sih, uint asidx); -extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); -extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); - -/* === exported functions === */ -extern struct si_pub *ai_attach(void __iomem *regs, struct pci_dev *sdh); -extern void ai_detach(struct si_pub *sih); -extern uint ai_coreid(struct si_pub *sih); -extern uint ai_corerev(struct si_pub *sih); -extern uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val); -extern void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val); -extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); -extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); -extern bool ai_iscoreup(struct si_pub *sih); -extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit); -extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx); -extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); -extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, - uint *origidx, uint *intr_val); -extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val); -extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); -extern void ai_core_disable(struct si_pub *sih, u32 bits); -extern u32 ai_alp_clock(struct si_pub *sih); -extern u32 ai_ilp_clock(struct si_pub *sih); -extern void ai_pci_setup(struct si_pub *sih, uint coremask); -extern void ai_setint(struct si_pub *sih, int siflag); -extern bool ai_backplane64(struct si_pub *sih); -extern void ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, - void *intrsrestore_fn, - void *intrsenabled_fn, void *intr_arg); -extern void ai_deregister_intr_callback(struct si_pub *sih); -extern void ai_clkctl_init(struct si_pub *sih); -extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih); -extern bool ai_clkctl_cc(struct si_pub *sih, uint mode); -extern int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on); -extern bool ai_deviceremoved(struct si_pub *sih); -extern u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, - u8 priority); - -/* OTP status */ -extern bool ai_is_otp_disabled(struct si_pub *sih); - -/* SPROM availability */ -extern bool ai_is_sprom_available(struct si_pub *sih); - -/* - * Build device path. Path size must be >= SI_DEVPATH_BUFSZ. - * The returned path is NULL terminated and has trailing '/'. - * Return 0 on success, nonzero otherwise. - */ -extern int ai_devpath(struct si_pub *sih, char *path, int size); - -extern void ai_pci_sleep(struct si_pub *sih); -extern void ai_pci_down(struct si_pub *sih); -extern void ai_pci_up(struct si_pub *sih); -extern int ai_pci_fixcfg(struct si_pub *sih); - -extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on); -/* Enable Ex-PA for 4313 */ -extern void ai_epa_4313war(struct si_pub *sih); - -#endif /* _BRCM_AIUTILS_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.c b/drivers/staging/brcm80211/brcmsmac/ampdu.c deleted file mode 100644 index 7f27dbdb6b6..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.c +++ /dev/null @@ -1,1241 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include - -#include "rate.h" -#include "scb.h" -#include "phy/phy_hal.h" -#include "antsel.h" -#include "main.h" -#include "ampdu.h" - -/* max number of mpdus in an ampdu */ -#define AMPDU_MAX_MPDU 32 -/* max number of mpdus in an ampdu to a legacy */ -#define AMPDU_NUM_MPDU_LEGACY 16 -/* max Tx ba window size (in pdu) */ -#define AMPDU_TX_BA_MAX_WSIZE 64 -/* default Tx ba window size (in pdu) */ -#define AMPDU_TX_BA_DEF_WSIZE 64 -/* default Rx ba window size (in pdu) */ -#define AMPDU_RX_BA_DEF_WSIZE 64 -/* max Rx ba window size (in pdu) */ -#define AMPDU_RX_BA_MAX_WSIZE 64 -/* max dur of tx ampdu (in msec) */ -#define AMPDU_MAX_DUR 5 -/* default tx retry limit */ -#define AMPDU_DEF_RETRY_LIMIT 5 -/* default tx retry limit at reg rate */ -#define AMPDU_DEF_RR_RETRY_LIMIT 2 -/* default weight of ampdu in txfifo */ -#define AMPDU_DEF_TXPKT_WEIGHT 2 -/* default ffpld reserved bytes */ -#define AMPDU_DEF_FFPLD_RSVD 2048 -/* # of inis to be freed on detach */ -#define AMPDU_INI_FREE 10 -/* max # of mpdus released at a time */ -#define AMPDU_SCB_MAX_RELEASE 20 - -#define NUM_FFPLD_FIFO 4 /* number of fifo concerned by pre-loading */ -#define FFPLD_TX_MAX_UNFL 200 /* default value of the average number of ampdu - * without underflows - */ -#define FFPLD_MPDU_SIZE 1800 /* estimate of maximum mpdu size */ -#define FFPLD_MAX_MCS 23 /* we don't deal with mcs 32 */ -#define FFPLD_PLD_INCR 1000 /* increments in bytes */ -#define FFPLD_MAX_AMPDU_CNT 5000 /* maximum number of ampdu we - * accumulate between resets. - */ - -#define AMPDU_DELIMITER_LEN 4 - -/* max allowed number of mpdus in an ampdu (2 streams) */ -#define AMPDU_NUM_MPDU 16 - -#define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) - -/* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ -#define AMPDU_MAX_MPDU_OVERHEAD (FCS_LEN + DOT11_ICV_AES_LEN +\ - AMPDU_DELIMITER_LEN + 3\ - + DOT11_A4_HDR_LEN + DOT11_QOS_LEN + DOT11_IV_MAX_LEN) - -/* modulo add/sub, bound = 2^k */ -#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) -#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) - -/* structure to hold tx fifo information and pre-loading state - * counters specific to tx underflows of ampdus - * some counters might be redundant with the ones in wlc or ampdu structures. - * This allows to maintain a specific state independently of - * how often and/or when the wlc counters are updated. - * - * ampdu_pld_size: number of bytes to be pre-loaded - * mcs2ampdu_table: per-mcs max # of mpdus in an ampdu - * prev_txfunfl: num of underflows last read from the HW macstats counter - * accum_txfunfl: num of underflows since we modified pld params - * accum_txampdu: num of tx ampdu since we modified pld params - * prev_txampdu: previous reading of tx ampdu - * dmaxferrate: estimated dma avg xfer rate in kbits/sec - */ -struct brcms_fifo_info { - u16 ampdu_pld_size; - u8 mcs2ampdu_table[FFPLD_MAX_MCS + 1]; - u16 prev_txfunfl; - u32 accum_txfunfl; - u32 accum_txampdu; - u32 prev_txampdu; - u32 dmaxferrate; -}; - -/* AMPDU module specific state - * - * wlc: pointer to main wlc structure - * scb_handle: scb cubby handle to retrieve data from scb - * ini_enable: per-tid initiator enable/disable of ampdu - * ba_tx_wsize: Tx ba window size (in pdu) - * ba_rx_wsize: Rx ba window size (in pdu) - * retry_limit: mpdu transmit retry limit - * rr_retry_limit: mpdu transmit retry limit at regular rate - * retry_limit_tid: per-tid mpdu transmit retry limit - * rr_retry_limit_tid: per-tid mpdu transmit retry limit at regular rate - * mpdu_density: min mpdu spacing (0-7) ==> 2^(x-1)/8 usec - * max_pdu: max pdus allowed in ampdu - * dur: max duration of an ampdu (in msec) - * txpkt_weight: weight of ampdu in txfifo; reduces rate lag - * rx_factor: maximum rx ampdu factor (0-3) ==> 2^(13+x) bytes - * ffpld_rsvd: number of bytes to reserve for preload - * max_txlen: max size of ampdu per mcs, bw and sgi - * mfbr: enable multiple fallback rate - * tx_max_funl: underflows should be kept such that - * (tx_max_funfl*underflows) < tx frames - * fifo_tb: table of fifo infos - */ -struct ampdu_info { - struct brcms_c_info *wlc; - int scb_handle; - u8 ini_enable[AMPDU_MAX_SCB_TID]; - u8 ba_tx_wsize; - u8 ba_rx_wsize; - u8 retry_limit; - u8 rr_retry_limit; - u8 retry_limit_tid[AMPDU_MAX_SCB_TID]; - u8 rr_retry_limit_tid[AMPDU_MAX_SCB_TID]; - u8 mpdu_density; - s8 max_pdu; - u8 dur; - u8 txpkt_weight; - u8 rx_factor; - u32 ffpld_rsvd; - u32 max_txlen[MCS_TABLE_SIZE][2][2]; - bool mfbr; - u32 tx_max_funl; - struct brcms_fifo_info fifo_tb[NUM_FFPLD_FIFO]; -}; - -/* used for flushing ampdu packets */ -struct cb_del_ampdu_pars { - struct ieee80211_sta *sta; - u16 tid; -}; - -static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) -{ - u32 rate, mcs; - - for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) { - /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */ - /* 20MHz, No SGI */ - rate = mcs_2_rate(mcs, false, false); - ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3; - /* 40 MHz, No SGI */ - rate = mcs_2_rate(mcs, true, false); - ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3; - /* 20MHz, SGI */ - rate = mcs_2_rate(mcs, false, true); - ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3; - /* 40 MHz, SGI */ - rate = mcs_2_rate(mcs, true, true); - ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3; - } -} - -static bool brcms_c_ampdu_cap(struct ampdu_info *ampdu) -{ - if (BRCMS_PHY_11N_CAP(ampdu->wlc->band)) - return true; - else - return false; -} - -static int brcms_c_ampdu_set(struct ampdu_info *ampdu, bool on) -{ - struct brcms_c_info *wlc = ampdu->wlc; - - wlc->pub->_ampdu = false; - - if (on) { - if (!(wlc->pub->_n_enab & SUPPORT_11N)) { - wiphy_err(ampdu->wlc->wiphy, "wl%d: driver not " - "nmode enabled\n", wlc->pub->unit); - return -ENOTSUPP; - } - if (!brcms_c_ampdu_cap(ampdu)) { - wiphy_err(ampdu->wlc->wiphy, "wl%d: device not " - "ampdu capable\n", wlc->pub->unit); - return -ENOTSUPP; - } - wlc->pub->_ampdu = on; - } - - return 0; -} - -static void brcms_c_ffpld_init(struct ampdu_info *ampdu) -{ - int i, j; - struct brcms_fifo_info *fifo; - - for (j = 0; j < NUM_FFPLD_FIFO; j++) { - fifo = (ampdu->fifo_tb + j); - fifo->ampdu_pld_size = 0; - for (i = 0; i <= FFPLD_MAX_MCS; i++) - fifo->mcs2ampdu_table[i] = 255; - fifo->dmaxferrate = 0; - fifo->accum_txampdu = 0; - fifo->prev_txfunfl = 0; - fifo->accum_txfunfl = 0; - - } -} - -struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc) -{ - struct ampdu_info *ampdu; - int i; - - ampdu = kzalloc(sizeof(struct ampdu_info), GFP_ATOMIC); - if (!ampdu) - return NULL; - - ampdu->wlc = wlc; - - for (i = 0; i < AMPDU_MAX_SCB_TID; i++) - ampdu->ini_enable[i] = true; - /* Disable ampdu for VO by default */ - ampdu->ini_enable[PRIO_8021D_VO] = false; - ampdu->ini_enable[PRIO_8021D_NC] = false; - - /* Disable ampdu for BK by default since not enough fifo space */ - ampdu->ini_enable[PRIO_8021D_NONE] = false; - ampdu->ini_enable[PRIO_8021D_BK] = false; - - ampdu->ba_tx_wsize = AMPDU_TX_BA_DEF_WSIZE; - ampdu->ba_rx_wsize = AMPDU_RX_BA_DEF_WSIZE; - ampdu->mpdu_density = AMPDU_DEF_MPDU_DENSITY; - ampdu->max_pdu = AUTO; - ampdu->dur = AMPDU_MAX_DUR; - ampdu->txpkt_weight = AMPDU_DEF_TXPKT_WEIGHT; - - ampdu->ffpld_rsvd = AMPDU_DEF_FFPLD_RSVD; - /* - * bump max ampdu rcv size to 64k for all 11n - * devices except 4321A0 and 4321A1 - */ - if (BRCMS_ISNPHY(wlc->band) && NREV_LT(wlc->band->phyrev, 2)) - ampdu->rx_factor = IEEE80211_HT_MAX_AMPDU_32K; - else - ampdu->rx_factor = IEEE80211_HT_MAX_AMPDU_64K; - ampdu->retry_limit = AMPDU_DEF_RETRY_LIMIT; - ampdu->rr_retry_limit = AMPDU_DEF_RR_RETRY_LIMIT; - - for (i = 0; i < AMPDU_MAX_SCB_TID; i++) { - ampdu->retry_limit_tid[i] = ampdu->retry_limit; - ampdu->rr_retry_limit_tid[i] = ampdu->rr_retry_limit; - } - - brcms_c_scb_ampdu_update_max_txlen(ampdu, ampdu->dur); - ampdu->mfbr = false; - /* try to set ampdu to the default value */ - brcms_c_ampdu_set(ampdu, wlc->pub->_ampdu); - - ampdu->tx_max_funl = FFPLD_TX_MAX_UNFL; - brcms_c_ffpld_init(ampdu); - - return ampdu; -} - -void brcms_c_ampdu_detach(struct ampdu_info *ampdu) -{ - kfree(ampdu); -} - -static void brcms_c_scb_ampdu_update_config(struct ampdu_info *ampdu, - struct scb *scb) -{ - struct scb_ampdu *scb_ampdu = &scb->scb_ampdu; - int i; - - scb_ampdu->max_pdu = AMPDU_NUM_MPDU; - - /* go back to legacy size if some preloading is occurring */ - for (i = 0; i < NUM_FFPLD_FIFO; i++) { - if (ampdu->fifo_tb[i].ampdu_pld_size > FFPLD_PLD_INCR) - scb_ampdu->max_pdu = AMPDU_NUM_MPDU_LEGACY; - } - - /* apply user override */ - if (ampdu->max_pdu != AUTO) - scb_ampdu->max_pdu = (u8) ampdu->max_pdu; - - scb_ampdu->release = min_t(u8, scb_ampdu->max_pdu, - AMPDU_SCB_MAX_RELEASE); - - if (scb_ampdu->max_rx_ampdu_bytes) - scb_ampdu->release = min_t(u8, scb_ampdu->release, - scb_ampdu->max_rx_ampdu_bytes / 1600); - - scb_ampdu->release = min(scb_ampdu->release, - ampdu->fifo_tb[TX_AC_BE_FIFO]. - mcs2ampdu_table[FFPLD_MAX_MCS]); -} - -static void brcms_c_scb_ampdu_update_config_all(struct ampdu_info *ampdu) -{ - brcms_c_scb_ampdu_update_config(ampdu, &du->wlc->pri_scb); -} - -static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) -{ - int i; - u32 phy_rate, dma_rate, tmp; - u8 max_mpdu; - struct brcms_fifo_info *fifo = (ampdu->fifo_tb + f); - - /* recompute the dma rate */ - /* note : we divide/multiply by 100 to avoid integer overflows */ - max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], - AMPDU_NUM_MPDU_LEGACY); - phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false); - dma_rate = - (((phy_rate / 100) * - (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) - / (max_mpdu * FFPLD_MPDU_SIZE)) * 100; - fifo->dmaxferrate = dma_rate; - - /* fill up the mcs2ampdu table; do not recalc the last mcs */ - dma_rate = dma_rate >> 7; - for (i = 0; i < FFPLD_MAX_MCS; i++) { - /* shifting to keep it within integer range */ - phy_rate = mcs_2_rate(i, true, false) >> 7; - if (phy_rate > dma_rate) { - tmp = ((fifo->ampdu_pld_size * phy_rate) / - ((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1; - tmp = min_t(u32, tmp, 255); - fifo->mcs2ampdu_table[i] = (u8) tmp; - } - } -} - -/* evaluate the dma transfer rate using the tx underflows as feedback. - * If necessary, increase tx fifo preloading. If not enough, - * decrease maximum ampdu size for each mcs till underflows stop - * Return 1 if pre-loading not active, -1 if not an underflow event, - * 0 if pre-loading module took care of the event. - */ -static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) -{ - struct ampdu_info *ampdu = wlc->ampdu; - u32 phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false); - u32 txunfl_ratio; - u8 max_mpdu; - u32 current_ampdu_cnt = 0; - u16 max_pld_size; - u32 new_txunfl; - struct brcms_fifo_info *fifo = (ampdu->fifo_tb + fid); - uint xmtfifo_sz; - u16 cur_txunfl; - - /* return if we got here for a different reason than underflows */ - cur_txunfl = brcms_b_read_shm(wlc->hw, - M_UCODE_MACSTAT + - offsetof(struct macstat, txfunfl[fid])); - new_txunfl = (u16) (cur_txunfl - fifo->prev_txfunfl); - if (new_txunfl == 0) { - BCMMSG(wlc->wiphy, "TX status FRAG set but no tx underflows\n"); - return -1; - } - fifo->prev_txfunfl = cur_txunfl; - - if (!ampdu->tx_max_funl) - return 1; - - /* check if fifo is big enough */ - if (brcms_b_xmtfifo_sz_get(wlc->hw, fid, &xmtfifo_sz)) - return -1; - - if ((TXFIFO_SIZE_UNIT * (u32) xmtfifo_sz) <= ampdu->ffpld_rsvd) - return 1; - - max_pld_size = TXFIFO_SIZE_UNIT * xmtfifo_sz - ampdu->ffpld_rsvd; - fifo->accum_txfunfl += new_txunfl; - - /* we need to wait for at least 10 underflows */ - if (fifo->accum_txfunfl < 10) - return 0; - - BCMMSG(wlc->wiphy, "ampdu_count %d tx_underflows %d\n", - current_ampdu_cnt, fifo->accum_txfunfl); - - /* - compute the current ratio of tx unfl per ampdu. - When the current ampdu count becomes too - big while the ratio remains small, we reset - the current count in order to not - introduce too big of a latency in detecting a - large amount of tx underflows later. - */ - - txunfl_ratio = current_ampdu_cnt / fifo->accum_txfunfl; - - if (txunfl_ratio > ampdu->tx_max_funl) { - if (current_ampdu_cnt >= FFPLD_MAX_AMPDU_CNT) - fifo->accum_txfunfl = 0; - - return 0; - } - max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], - AMPDU_NUM_MPDU_LEGACY); - - /* In case max value max_pdu is already lower than - the fifo depth, there is nothing more we can do. - */ - - if (fifo->ampdu_pld_size >= max_mpdu * FFPLD_MPDU_SIZE) { - fifo->accum_txfunfl = 0; - return 0; - } - - if (fifo->ampdu_pld_size < max_pld_size) { - - /* increment by TX_FIFO_PLD_INC bytes */ - fifo->ampdu_pld_size += FFPLD_PLD_INCR; - if (fifo->ampdu_pld_size > max_pld_size) - fifo->ampdu_pld_size = max_pld_size; - - /* update scb release size */ - brcms_c_scb_ampdu_update_config_all(ampdu); - - /* - * compute a new dma xfer rate for max_mpdu @ max mcs. - * This is the minimum dma rate that can achieve no - * underflow condition for the current mpdu size. - * - * note : we divide/multiply by 100 to avoid integer overflows - */ - fifo->dmaxferrate = - (((phy_rate / 100) * - (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) - / (max_mpdu * FFPLD_MPDU_SIZE)) * 100; - - BCMMSG(wlc->wiphy, "DMA estimated transfer rate %d; " - "pre-load size %d\n", - fifo->dmaxferrate, fifo->ampdu_pld_size); - } else { - - /* decrease ampdu size */ - if (fifo->mcs2ampdu_table[FFPLD_MAX_MCS] > 1) { - if (fifo->mcs2ampdu_table[FFPLD_MAX_MCS] == 255) - fifo->mcs2ampdu_table[FFPLD_MAX_MCS] = - AMPDU_NUM_MPDU_LEGACY - 1; - else - fifo->mcs2ampdu_table[FFPLD_MAX_MCS] -= 1; - - /* recompute the table */ - brcms_c_ffpld_calc_mcs2ampdu_table(ampdu, fid); - - /* update scb release size */ - brcms_c_scb_ampdu_update_config_all(ampdu); - } - } - fifo->accum_txfunfl = 0; - return 0; -} - -void -brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, - u8 ba_wsize, /* negotiated ba window size (in pdu) */ - uint max_rx_ampdu_bytes) /* from ht_cap in beacon */ -{ - struct scb_ampdu *scb_ampdu; - struct scb_ampdu_tid_ini *ini; - struct ampdu_info *ampdu = wlc->ampdu; - struct scb *scb = &wlc->pri_scb; - scb_ampdu = &scb->scb_ampdu; - - if (!ampdu->ini_enable[tid]) { - wiphy_err(ampdu->wlc->wiphy, "%s: Rejecting tid %d\n", - __func__, tid); - return; - } - - ini = &scb_ampdu->ini[tid]; - ini->tid = tid; - ini->scb = scb_ampdu->scb; - ini->ba_wsize = ba_wsize; - scb_ampdu->max_rx_ampdu_bytes = max_rx_ampdu_bytes; -} - -int -brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, - struct sk_buff **pdu, int prec) -{ - struct brcms_c_info *wlc; - struct sk_buff *p, *pkt[AMPDU_MAX_MPDU]; - u8 tid, ndelim; - int err = 0; - u8 preamble_type = BRCMS_GF_PREAMBLE; - u8 fbr_preamble_type = BRCMS_GF_PREAMBLE; - u8 rts_preamble_type = BRCMS_LONG_PREAMBLE; - u8 rts_fbr_preamble_type = BRCMS_LONG_PREAMBLE; - - bool rr = true, fbr = false; - uint i, count = 0, fifo, seg_cnt = 0; - u16 plen, len, seq = 0, mcl, mch, index, frameid, dma_len = 0; - u32 ampdu_len, max_ampdu_bytes = 0; - struct d11txh *txh = NULL; - u8 *plcp; - struct ieee80211_hdr *h; - struct scb *scb; - struct scb_ampdu *scb_ampdu; - struct scb_ampdu_tid_ini *ini; - u8 mcs = 0; - bool use_rts = false, use_cts = false; - u32 rspec = 0, rspec_fallback = 0; - u32 rts_rspec = 0, rts_rspec_fallback = 0; - u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; - struct ieee80211_rts *rts; - u8 rr_retry_limit; - struct brcms_fifo_info *f; - bool fbr_iscck; - struct ieee80211_tx_info *tx_info; - u16 qlen; - struct wiphy *wiphy; - - wlc = ampdu->wlc; - wiphy = wlc->wiphy; - p = *pdu; - - tid = (u8) (p->priority); - - f = ampdu->fifo_tb + prio2fifo[tid]; - - scb = &wlc->pri_scb; - scb_ampdu = &scb->scb_ampdu; - ini = &scb_ampdu->ini[tid]; - - /* Let pressure continue to build ... */ - qlen = pktq_plen(&qi->q, prec); - if (ini->tx_in_transit > 0 && - qlen < min(scb_ampdu->max_pdu, ini->ba_wsize)) - /* Collect multiple MPDU's to be sent in the next AMPDU */ - return -EBUSY; - - /* at this point we intend to transmit an AMPDU */ - rr_retry_limit = ampdu->rr_retry_limit_tid[tid]; - ampdu_len = 0; - dma_len = 0; - while (p) { - struct ieee80211_tx_rate *txrate; - - tx_info = IEEE80211_SKB_CB(p); - txrate = tx_info->status.rates; - - if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { - err = brcms_c_prep_pdu(wlc, p, &fifo); - } else { - wiphy_err(wiphy, "%s: AMPDU flag is off!\n", __func__); - *pdu = NULL; - err = 0; - break; - } - - if (err) { - if (err == -EBUSY) { - wiphy_err(wiphy, "wl%d: sendampdu: " - "prep_xdu retry; seq 0x%x\n", - wlc->pub->unit, seq); - *pdu = p; - break; - } - - /* error in the packet; reject it */ - wiphy_err(wiphy, "wl%d: sendampdu: prep_xdu " - "rejected; seq 0x%x\n", wlc->pub->unit, seq); - *pdu = NULL; - break; - } - - /* pkt is good to be aggregated */ - txh = (struct d11txh *) p->data; - plcp = (u8 *) (txh + 1); - h = (struct ieee80211_hdr *)(plcp + D11_PHY_HDR_LEN); - seq = le16_to_cpu(h->seq_ctrl) >> SEQNUM_SHIFT; - index = TX_SEQ_TO_INDEX(seq); - - /* check mcl fields and test whether it can be agg'd */ - mcl = le16_to_cpu(txh->MacTxControlLow); - mcl &= ~TXC_AMPDU_MASK; - fbr_iscck = !(le16_to_cpu(txh->XtraFrameTypes) & 0x3); - txh->PreloadSize = 0; /* always default to 0 */ - - /* Handle retry limits */ - if (txrate[0].count <= rr_retry_limit) { - txrate[0].count++; - rr = true; - fbr = false; - } else { - fbr = true; - rr = false; - txrate[1].count++; - } - - /* extract the length info */ - len = fbr_iscck ? BRCMS_GET_CCK_PLCP_LEN(txh->FragPLCPFallback) - : BRCMS_GET_MIMO_PLCP_LEN(txh->FragPLCPFallback); - - /* retrieve null delimiter count */ - ndelim = txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM]; - seg_cnt += 1; - - BCMMSG(wlc->wiphy, "wl%d: mpdu %d plcp_len %d\n", - wlc->pub->unit, count, len); - - /* - * aggregateable mpdu. For ucode/hw agg, - * test whether need to break or change the epoch - */ - if (count == 0) { - mcl |= (TXC_AMPDU_FIRST << TXC_AMPDU_SHIFT); - /* refill the bits since might be a retx mpdu */ - mcl |= TXC_STARTMSDU; - rts = (struct ieee80211_rts *)&txh->rts_frame; - - if (ieee80211_is_rts(rts->frame_control)) { - mcl |= TXC_SENDRTS; - use_rts = true; - } - if (ieee80211_is_cts(rts->frame_control)) { - mcl |= TXC_SENDCTS; - use_cts = true; - } - } else { - mcl |= (TXC_AMPDU_MIDDLE << TXC_AMPDU_SHIFT); - mcl &= ~(TXC_STARTMSDU | TXC_SENDRTS | TXC_SENDCTS); - } - - len = roundup(len, 4); - ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); - - dma_len += (u16) brcmu_pkttotlen(p); - - BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d" - " seg_cnt %d null delim %d\n", - wlc->pub->unit, ampdu_len, seg_cnt, ndelim); - - txh->MacTxControlLow = cpu_to_le16(mcl); - - /* this packet is added */ - pkt[count++] = p; - - /* patch the first MPDU */ - if (count == 1) { - u8 plcp0, plcp3, is40, sgi; - struct ieee80211_sta *sta; - - sta = tx_info->control.sta; - - if (rr) { - plcp0 = plcp[0]; - plcp3 = plcp[3]; - } else { - plcp0 = txh->FragPLCPFallback[0]; - plcp3 = txh->FragPLCPFallback[3]; - - } - is40 = (plcp0 & MIMO_PLCP_40MHZ) ? 1 : 0; - sgi = plcp3_issgi(plcp3) ? 1 : 0; - mcs = plcp0 & ~MIMO_PLCP_40MHZ; - max_ampdu_bytes = - min(scb_ampdu->max_rx_ampdu_bytes, - ampdu->max_txlen[mcs][is40][sgi]); - - if (is40) - mimo_ctlchbw = - CHSPEC_SB_UPPER(wlc_phy_chanspec_get( - wlc->band->pi)) - ? PHY_TXC1_BW_20MHZ_UP : PHY_TXC1_BW_20MHZ; - - /* rebuild the rspec and rspec_fallback */ - rspec = RSPEC_MIMORATE; - rspec |= plcp[0] & ~MIMO_PLCP_40MHZ; - if (plcp[0] & MIMO_PLCP_40MHZ) - rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT); - - if (fbr_iscck) /* CCK */ - rspec_fallback = cck_rspec(cck_phy2mac_rate - (txh->FragPLCPFallback[0])); - else { /* MIMO */ - rspec_fallback = RSPEC_MIMORATE; - rspec_fallback |= - txh->FragPLCPFallback[0] & ~MIMO_PLCP_40MHZ; - if (txh->FragPLCPFallback[0] & MIMO_PLCP_40MHZ) - rspec_fallback |= - (PHY_TXC1_BW_40MHZ << - RSPEC_BW_SHIFT); - } - - if (use_rts || use_cts) { - rts_rspec = - brcms_c_rspec_to_rts_rspec(wlc, - rspec, false, mimo_ctlchbw); - rts_rspec_fallback = - brcms_c_rspec_to_rts_rspec(wlc, - rspec_fallback, false, mimo_ctlchbw); - } - } - - /* if (first mpdu for host agg) */ - /* test whether to add more */ - if ((mcs_2_rate(mcs, true, false) >= f->dmaxferrate) && - (count == f->mcs2ampdu_table[mcs])) { - BCMMSG(wlc->wiphy, "wl%d: PR 37644: stopping" - " ampdu at %d for mcs %d\n", - wlc->pub->unit, count, mcs); - break; - } - - if (count == scb_ampdu->max_pdu) - break; - - /* - * check to see if the next pkt is - * a candidate for aggregation - */ - p = pktq_ppeek(&qi->q, prec); - /* tx_info must be checked with current p */ - tx_info = IEEE80211_SKB_CB(p); - - if (p) { - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && - ((u8) (p->priority) == tid)) { - - plen = brcmu_pkttotlen(p) + - AMPDU_MAX_MPDU_OVERHEAD; - plen = max(scb_ampdu->min_len, plen); - - if ((plen + ampdu_len) > max_ampdu_bytes) { - p = NULL; - continue; - } - - /* - * check if there are enough - * descriptors available - */ - if (*wlc->core->txavail[fifo] <= seg_cnt + 1) { - wiphy_err(wiphy, "%s: No fifo space " - "!!\n", __func__); - p = NULL; - continue; - } - p = brcmu_pktq_pdeq(&qi->q, prec); - } else { - p = NULL; - } - } - } /* end while(p) */ - - ini->tx_in_transit += count; - - if (count) { - /* patch up the last txh */ - txh = (struct d11txh *) pkt[count - 1]->data; - mcl = le16_to_cpu(txh->MacTxControlLow); - mcl &= ~TXC_AMPDU_MASK; - mcl |= (TXC_AMPDU_LAST << TXC_AMPDU_SHIFT); - txh->MacTxControlLow = cpu_to_le16(mcl); - - /* remove the null delimiter after last mpdu */ - ndelim = txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM]; - txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = 0; - ampdu_len -= ndelim * AMPDU_DELIMITER_LEN; - - /* remove the pad len from last mpdu */ - fbr_iscck = ((le16_to_cpu(txh->XtraFrameTypes) & 0x3) == 0); - len = fbr_iscck ? BRCMS_GET_CCK_PLCP_LEN(txh->FragPLCPFallback) - : BRCMS_GET_MIMO_PLCP_LEN(txh->FragPLCPFallback); - ampdu_len -= roundup(len, 4) - len; - - /* patch up the first txh & plcp */ - txh = (struct d11txh *) pkt[0]->data; - plcp = (u8 *) (txh + 1); - - BRCMS_SET_MIMO_PLCP_LEN(plcp, ampdu_len); - /* mark plcp to indicate ampdu */ - BRCMS_SET_MIMO_PLCP_AMPDU(plcp); - - /* reset the mixed mode header durations */ - if (txh->MModeLen) { - u16 mmodelen = - brcms_c_calc_lsig_len(wlc, rspec, ampdu_len); - txh->MModeLen = cpu_to_le16(mmodelen); - preamble_type = BRCMS_MM_PREAMBLE; - } - if (txh->MModeFbrLen) { - u16 mmfbrlen = - brcms_c_calc_lsig_len(wlc, rspec_fallback, - ampdu_len); - txh->MModeFbrLen = cpu_to_le16(mmfbrlen); - fbr_preamble_type = BRCMS_MM_PREAMBLE; - } - - /* set the preload length */ - if (mcs_2_rate(mcs, true, false) >= f->dmaxferrate) { - dma_len = min(dma_len, f->ampdu_pld_size); - txh->PreloadSize = cpu_to_le16(dma_len); - } else - txh->PreloadSize = 0; - - mch = le16_to_cpu(txh->MacTxControlHigh); - - /* update RTS dur fields */ - if (use_rts || use_cts) { - u16 durid; - rts = (struct ieee80211_rts *)&txh->rts_frame; - if ((mch & TXC_PREAMBLE_RTS_MAIN_SHORT) == - TXC_PREAMBLE_RTS_MAIN_SHORT) - rts_preamble_type = BRCMS_SHORT_PREAMBLE; - - if ((mch & TXC_PREAMBLE_RTS_FB_SHORT) == - TXC_PREAMBLE_RTS_FB_SHORT) - rts_fbr_preamble_type = BRCMS_SHORT_PREAMBLE; - - durid = - brcms_c_compute_rtscts_dur(wlc, use_cts, rts_rspec, - rspec, rts_preamble_type, - preamble_type, ampdu_len, - true); - rts->duration = cpu_to_le16(durid); - durid = brcms_c_compute_rtscts_dur(wlc, use_cts, - rts_rspec_fallback, - rspec_fallback, - rts_fbr_preamble_type, - fbr_preamble_type, - ampdu_len, true); - txh->RTSDurFallback = cpu_to_le16(durid); - /* set TxFesTimeNormal */ - txh->TxFesTimeNormal = rts->duration; - /* set fallback rate version of TxFesTimeNormal */ - txh->TxFesTimeFallback = txh->RTSDurFallback; - } - - /* set flag and plcp for fallback rate */ - if (fbr) { - mch |= TXC_AMPDU_FBR; - txh->MacTxControlHigh = cpu_to_le16(mch); - BRCMS_SET_MIMO_PLCP_AMPDU(plcp); - BRCMS_SET_MIMO_PLCP_AMPDU(txh->FragPLCPFallback); - } - - BCMMSG(wlc->wiphy, "wl%d: count %d ampdu_len %d\n", - wlc->pub->unit, count, ampdu_len); - - /* inform rate_sel if it this is a rate probe pkt */ - frameid = le16_to_cpu(txh->TxFrameID); - if (frameid & TXFID_RATE_PROBE_MASK) - wiphy_err(wiphy, "%s: XXX what to do with " - "TXFID_RATE_PROBE_MASK!?\n", __func__); - - for (i = 0; i < count; i++) - brcms_c_txfifo(wlc, fifo, pkt[i], i == (count - 1), - ampdu->txpkt_weight); - - } - /* endif (count) */ - return err; -} - -static void -brcms_c_ampdu_rate_status(struct brcms_c_info *wlc, - struct ieee80211_tx_info *tx_info, - struct tx_status *txs, u8 mcs) -{ - struct ieee80211_tx_rate *txrate = tx_info->status.rates; - int i; - - /* clear the rest of the rates */ - for (i = 2; i < IEEE80211_TX_MAX_RATES; i++) { - txrate[i].idx = -1; - txrate[i].count = 0; - } -} - -static void -brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, - struct sk_buff *p, struct tx_status *txs, - u32 s1, u32 s2) -{ - struct scb_ampdu *scb_ampdu; - struct brcms_c_info *wlc = ampdu->wlc; - struct scb_ampdu_tid_ini *ini; - u8 bitmap[8], queue, tid; - struct d11txh *txh; - u8 *plcp; - struct ieee80211_hdr *h; - u16 seq, start_seq = 0, bindex, index, mcl; - u8 mcs = 0; - bool ba_recd = false, ack_recd = false; - u8 suc_mpdu = 0, tot_mpdu = 0; - uint supr_status; - bool update_rate = true, retry = true, tx_error = false; - u16 mimoantsel = 0; - u8 antselid = 0; - u8 retry_limit, rr_retry_limit; - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(p); - struct wiphy *wiphy = wlc->wiphy; - -#ifdef BCMDBG - u8 hole[AMPDU_MAX_MPDU]; - memset(hole, 0, sizeof(hole)); -#endif - - scb_ampdu = &scb->scb_ampdu; - tid = (u8) (p->priority); - - ini = &scb_ampdu->ini[tid]; - retry_limit = ampdu->retry_limit_tid[tid]; - rr_retry_limit = ampdu->rr_retry_limit_tid[tid]; - memset(bitmap, 0, sizeof(bitmap)); - queue = txs->frameid & TXFID_QUEUE_MASK; - supr_status = txs->status & TX_STATUS_SUPR_MASK; - - if (txs->status & TX_STATUS_ACK_RCV) { - if (TX_STATUS_SUPR_UF == supr_status) - update_rate = false; - - WARN_ON(!(txs->status & TX_STATUS_INTERMEDIATE)); - start_seq = txs->sequence >> SEQNUM_SHIFT; - bitmap[0] = (txs->status & TX_STATUS_BA_BMAP03_MASK) >> - TX_STATUS_BA_BMAP03_SHIFT; - - WARN_ON(s1 & TX_STATUS_INTERMEDIATE); - WARN_ON(!(s1 & TX_STATUS_AMPDU)); - - bitmap[0] |= - (s1 & TX_STATUS_BA_BMAP47_MASK) << - TX_STATUS_BA_BMAP47_SHIFT; - bitmap[1] = (s1 >> 8) & 0xff; - bitmap[2] = (s1 >> 16) & 0xff; - bitmap[3] = (s1 >> 24) & 0xff; - - bitmap[4] = s2 & 0xff; - bitmap[5] = (s2 >> 8) & 0xff; - bitmap[6] = (s2 >> 16) & 0xff; - bitmap[7] = (s2 >> 24) & 0xff; - - ba_recd = true; - } else { - if (supr_status) { - update_rate = false; - if (supr_status == TX_STATUS_SUPR_BADCH) { - wiphy_err(wiphy, "%s: Pkt tx suppressed, " - "illegal channel possibly %d\n", - __func__, CHSPEC_CHANNEL( - wlc->default_bss->chanspec)); - } else { - if (supr_status != TX_STATUS_SUPR_FRAG) - wiphy_err(wiphy, "%s:" - "supr_status 0x%x\n", - __func__, supr_status); - } - /* no need to retry for badch; will fail again */ - if (supr_status == TX_STATUS_SUPR_BADCH || - supr_status == TX_STATUS_SUPR_EXPTIME) { - retry = false; - } else if (supr_status == TX_STATUS_SUPR_EXPTIME) { - /* TX underflow: - * try tuning pre-loading or ampdu size - */ - } else if (supr_status == TX_STATUS_SUPR_FRAG) { - /* - * if there were underflows, but pre-loading - * is not active, notify rate adaptation. - */ - if (brcms_c_ffpld_check_txfunfl(wlc, - prio2fifo[tid]) > 0) - tx_error = true; - } - } else if (txs->phyerr) { - update_rate = false; - wiphy_err(wiphy, "wl%d: ampdu tx phy " - "error (0x%x)\n", wlc->pub->unit, - txs->phyerr); - - if (brcm_msg_level & LOG_ERROR_VAL) { - brcmu_prpkt("txpkt (AMPDU)", p); - brcms_c_print_txdesc((struct d11txh *) p->data); - } - brcms_c_print_txstatus(txs); - } - } - - /* loop through all pkts and retry if not acked */ - while (p) { - tx_info = IEEE80211_SKB_CB(p); - txh = (struct d11txh *) p->data; - mcl = le16_to_cpu(txh->MacTxControlLow); - plcp = (u8 *) (txh + 1); - h = (struct ieee80211_hdr *)(plcp + D11_PHY_HDR_LEN); - seq = le16_to_cpu(h->seq_ctrl) >> SEQNUM_SHIFT; - - if (tot_mpdu == 0) { - mcs = plcp[0] & MIMO_PLCP_MCS_MASK; - mimoantsel = le16_to_cpu(txh->ABI_MimoAntSel); - } - - index = TX_SEQ_TO_INDEX(seq); - ack_recd = false; - if (ba_recd) { - bindex = MODSUB_POW2(seq, start_seq, SEQNUM_MAX); - BCMMSG(wlc->wiphy, "tid %d seq %d," - " start_seq %d, bindex %d set %d, index %d\n", - tid, seq, start_seq, bindex, - isset(bitmap, bindex), index); - /* if acked then clear bit and free packet */ - if ((bindex < AMPDU_TX_BA_MAX_WSIZE) - && isset(bitmap, bindex)) { - ini->tx_in_transit--; - ini->txretry[index] = 0; - - /* - * ampdu_ack_len: - * number of acked aggregated frames - */ - /* ampdu_len: number of aggregated frames */ - brcms_c_ampdu_rate_status(wlc, tx_info, txs, - mcs); - tx_info->flags |= IEEE80211_TX_STAT_ACK; - tx_info->flags |= IEEE80211_TX_STAT_AMPDU; - tx_info->status.ampdu_ack_len = - tx_info->status.ampdu_len = 1; - - skb_pull(p, D11_PHY_HDR_LEN); - skb_pull(p, D11_TXH_LEN); - - ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, - p); - ack_recd = true; - suc_mpdu++; - } - } - /* either retransmit or send bar if ack not recd */ - if (!ack_recd) { - struct ieee80211_tx_rate *txrate = - tx_info->status.rates; - if (retry && (txrate[0].count < (int)retry_limit)) { - ini->txretry[index]++; - ini->tx_in_transit--; - /* - * Use high prededence for retransmit to - * give some punch - */ - /* brcms_c_txq_enq(wlc, scb, p, - * BRCMS_PRIO_TO_PREC(tid)); */ - brcms_c_txq_enq(wlc, scb, p, - BRCMS_PRIO_TO_HI_PREC(tid)); - } else { - /* Retry timeout */ - ini->tx_in_transit--; - ieee80211_tx_info_clear_status(tx_info); - tx_info->status.ampdu_ack_len = 0; - tx_info->status.ampdu_len = 1; - tx_info->flags |= - IEEE80211_TX_STAT_AMPDU_NO_BACK; - skb_pull(p, D11_PHY_HDR_LEN); - skb_pull(p, D11_TXH_LEN); - wiphy_err(wiphy, "%s: BA Timeout, seq %d, in_" - "transit %d\n", "AMPDU status", seq, - ini->tx_in_transit); - ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, - p); - } - } - tot_mpdu++; - - /* break out if last packet of ampdu */ - if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == - TXC_AMPDU_LAST) - break; - - p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); - } - brcms_c_send_q(wlc); - - /* update rate state */ - antselid = brcms_c_antsel_antsel2id(wlc->asi, mimoantsel); - - brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); -} - -void -brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, - struct sk_buff *p, struct tx_status *txs) -{ - struct scb_ampdu *scb_ampdu; - struct brcms_c_info *wlc = ampdu->wlc; - struct scb_ampdu_tid_ini *ini; - u32 s1 = 0, s2 = 0; - struct ieee80211_tx_info *tx_info; - - tx_info = IEEE80211_SKB_CB(p); - - /* BMAC_NOTE: For the split driver, second level txstatus comes later - * So if the ACK was received then wait for the second level else just - * call the first one - */ - if (txs->status & TX_STATUS_ACK_RCV) { - u8 status_delay = 0; - - /* wait till the next 8 bytes of txstatus is available */ - while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { - udelay(1); - status_delay++; - if (status_delay > 10) - return; /* error condition */ - } - - s2 = R_REG(&wlc->regs->frmtxstatus2); - } - - if (scb) { - scb_ampdu = &scb->scb_ampdu; - ini = &scb_ampdu->ini[p->priority]; - brcms_c_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); - } else { - /* loop through all pkts and free */ - u8 queue = txs->frameid & TXFID_QUEUE_MASK; - struct d11txh *txh; - u16 mcl; - while (p) { - tx_info = IEEE80211_SKB_CB(p); - txh = (struct d11txh *) p->data; - mcl = le16_to_cpu(txh->MacTxControlLow); - brcmu_pkt_buf_free_skb(p); - /* break out if last packet of ampdu */ - if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == - TXC_AMPDU_LAST) - break; - p = dma_getnexttxp(wlc->hw->di[queue], - DMA_RANGE_TRANSMITTED); - } - brcms_c_txfifo_complete(wlc, queue, ampdu->txpkt_weight); - } -} - -void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc) -{ - char template[T_RAM_ACCESS_SZ * 2]; - - /* driver needs to write the ta in the template; ta is at offset 16 */ - memset(template, 0, sizeof(template)); - memcpy(template, wlc->pub->cur_etheraddr, ETH_ALEN); - brcms_b_write_template_ram(wlc->hw, (T_BA_TPL_BASE + 16), - (T_RAM_ACCESS_SZ * 2), - template); -} - -bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid) -{ - return wlc->ampdu->ini_enable[tid]; -} - -void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu) -{ - struct brcms_c_info *wlc = ampdu->wlc; - - /* - * Extend ucode internal watchdog timer to - * match larger received frames - */ - if ((ampdu->rx_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) == - IEEE80211_HT_MAX_AMPDU_64K) { - brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX); - brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_MAX); - } else { - brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_DEF); - brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_DEF); - } -} - -/* - * callback function that helps flushing ampdu packets from a priority queue - */ -static bool cb_del_ampdu_pkt(struct sk_buff *mpdu, void *arg_a) -{ - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(mpdu); - struct cb_del_ampdu_pars *ampdu_pars = - (struct cb_del_ampdu_pars *)arg_a; - bool rc; - - rc = tx_info->flags & IEEE80211_TX_CTL_AMPDU ? true : false; - rc = rc && (tx_info->control.sta == NULL || ampdu_pars->sta == NULL || - tx_info->control.sta == ampdu_pars->sta); - rc = rc && ((u8)(mpdu->priority) == ampdu_pars->tid); - return rc; -} - -/* - * callback function that helps invalidating ampdu packets in a DMA queue - */ -static void dma_cb_fn_ampdu(void *txi, void *arg_a) -{ - struct ieee80211_sta *sta = arg_a; - struct ieee80211_tx_info *tx_info = (struct ieee80211_tx_info *)txi; - - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && - (tx_info->control.sta == sta || sta == NULL)) - tx_info->control.sta = NULL; -} - -/* - * When a remote party is no longer available for ampdu communication, any - * pending tx ampdu packets in the driver have to be flushed. - */ -void brcms_c_ampdu_flush(struct brcms_c_info *wlc, - struct ieee80211_sta *sta, u16 tid) -{ - struct brcms_txq_info *qi = wlc->pkt_queue; - struct pktq *pq = &qi->q; - int prec; - struct cb_del_ampdu_pars ampdu_pars; - - ampdu_pars.sta = sta; - ampdu_pars.tid = tid; - for (prec = 0; prec < pq->num_prec; prec++) - brcmu_pktq_pflush(pq, prec, true, cb_del_ampdu_pkt, - (void *)&du_pars); - brcms_c_inval_dma_pkts(wlc->hw, sta, dma_cb_fn_ampdu); -} diff --git a/drivers/staging/brcm80211/brcmsmac/ampdu.h b/drivers/staging/brcm80211/brcmsmac/ampdu.h deleted file mode 100644 index 421f4ba7c63..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/ampdu.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_AMPDU_H_ -#define _BRCM_AMPDU_H_ - -extern struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc); -extern void brcms_c_ampdu_detach(struct ampdu_info *ampdu); -extern int brcms_c_sendampdu(struct ampdu_info *ampdu, - struct brcms_txq_info *qi, - struct sk_buff **aggp, int prec); -extern void brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, - struct sk_buff *p, struct tx_status *txs); -extern void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc); -extern void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu); - -#endif /* _BRCM_AMPDU_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.c b/drivers/staging/brcm80211/brcmsmac/antsel.c deleted file mode 100644 index edc4016fd9a..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/antsel.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include "types.h" -#include "main.h" -#include "phy_shim.h" -#include "antsel.h" - -#define ANT_SELCFG_AUTO 0x80 /* bit indicates antenna sel AUTO */ -#define ANT_SELCFG_MASK 0x33 /* antenna configuration mask */ -#define ANT_SELCFG_TX_UNICAST 0 /* unicast tx antenna configuration */ -#define ANT_SELCFG_RX_UNICAST 1 /* unicast rx antenna configuration */ -#define ANT_SELCFG_TX_DEF 2 /* default tx antenna configuration */ -#define ANT_SELCFG_RX_DEF 3 /* default rx antenna configuration */ - -/* useful macros */ -#define BRCMS_ANTSEL_11N_0(ant) ((((ant) & ANT_SELCFG_MASK) >> 4) & 0xf) -#define BRCMS_ANTSEL_11N_1(ant) (((ant) & ANT_SELCFG_MASK) & 0xf) -#define BRCMS_ANTIDX_11N(ant) (((BRCMS_ANTSEL_11N_0(ant)) << 2) +\ - (BRCMS_ANTSEL_11N_1(ant))) -#define BRCMS_ANT_ISAUTO_11N(ant) (((ant) & ANT_SELCFG_AUTO) == ANT_SELCFG_AUTO) -#define BRCMS_ANTSEL_11N(ant) ((ant) & ANT_SELCFG_MASK) - -/* antenna switch */ -/* defines for no boardlevel antenna diversity */ -#define ANT_SELCFG_DEF_2x2 0x01 /* default antenna configuration */ - -/* 2x3 antdiv defines and tables for GPIO communication */ -#define ANT_SELCFG_NUM_2x3 3 -#define ANT_SELCFG_DEF_2x3 0x01 /* default antenna configuration */ - -/* 2x4 antdiv rev4 defines and tables for GPIO communication */ -#define ANT_SELCFG_NUM_2x4 4 -#define ANT_SELCFG_DEF_2x4 0x02 /* default antenna configuration */ - -static const u16 mimo_2x4_div_antselpat_tbl[] = { - 0, 0, 0x9, 0xa, /* ant0: 0 ant1: 2,3 */ - 0, 0, 0x5, 0x6, /* ant0: 1 ant1: 2,3 */ - 0, 0, 0, 0, /* n.a. */ - 0, 0, 0, 0 /* n.a. */ -}; - -static const u8 mimo_2x4_div_antselid_tbl[16] = { - 0, 0, 0, 0, 0, 2, 3, 0, - 0, 0, 1, 0, 0, 0, 0, 0 /* pat to antselid */ -}; - -static const u16 mimo_2x3_div_antselpat_tbl[] = { - 16, 0, 1, 16, /* ant0: 0 ant1: 1,2 */ - 16, 16, 16, 16, /* n.a. */ - 16, 2, 16, 16, /* ant0: 2 ant1: 1 */ - 16, 16, 16, 16 /* n.a. */ -}; - -static const u8 mimo_2x3_div_antselid_tbl[16] = { - 0, 1, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 /* pat to antselid */ -}; - -/* boardlevel antenna selection: init antenna selection structure */ -static void -brcms_c_antsel_init_cfg(struct antsel_info *asi, struct brcms_antselcfg *antsel, - bool auto_sel) -{ - if (asi->antsel_type == ANTSEL_2x3) { - u8 antcfg_def = ANT_SELCFG_DEF_2x3 | - ((asi->antsel_avail && auto_sel) ? ANT_SELCFG_AUTO : 0); - antsel->ant_config[ANT_SELCFG_TX_DEF] = antcfg_def; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = antcfg_def; - antsel->ant_config[ANT_SELCFG_RX_DEF] = antcfg_def; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = antcfg_def; - antsel->num_antcfg = ANT_SELCFG_NUM_2x3; - - } else if (asi->antsel_type == ANTSEL_2x4) { - - antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x4; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x4; - antsel->num_antcfg = ANT_SELCFG_NUM_2x4; - - } else { /* no antenna selection available */ - - antsel->ant_config[ANT_SELCFG_TX_DEF] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_TX_UNICAST] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_RX_DEF] = ANT_SELCFG_DEF_2x2; - antsel->ant_config[ANT_SELCFG_RX_UNICAST] = ANT_SELCFG_DEF_2x2; - antsel->num_antcfg = 0; - } -} - -struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) -{ - struct antsel_info *asi; - struct si_pub *sih = wlc->hw->sih; - - asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC); - if (!asi) - return NULL; - - asi->wlc = wlc; - asi->pub = wlc->pub; - asi->antsel_type = ANTSEL_NA; - asi->antsel_avail = false; - asi->antsel_antswitch = (u8) getintvar(sih, BRCMS_SROM_ANTSWITCH); - - if ((asi->pub->sromrev >= 4) && (asi->antsel_antswitch != 0)) { - switch (asi->antsel_antswitch) { - case ANTSWITCH_TYPE_1: - case ANTSWITCH_TYPE_2: - case ANTSWITCH_TYPE_3: - /* 4321/2 board with 2x3 switch logic */ - asi->antsel_type = ANTSEL_2x3; - /* Antenna selection availability */ - if (((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) || - ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 7)) { - asi->antsel_avail = true; - } else if ( - (u16) getintvar(sih, BRCMS_SROM_AA2G) == 3 || - (u16) getintvar(sih, BRCMS_SROM_AA5G) == 3) { - asi->antsel_avail = false; - } else { - asi->antsel_avail = false; - wiphy_err(wlc->wiphy, "antsel_attach: 2o3 " - "board cfg invalid\n"); - } - - break; - default: - break; - } - } else if ((asi->pub->sromrev == 4) && - ((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) && - ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 0)) { - /* hack to match old 4321CB2 cards with 2of3 antenna switch */ - asi->antsel_type = ANTSEL_2x3; - asi->antsel_avail = true; - } else if (asi->pub->boardflags2 & BFL2_2X4_DIV) { - asi->antsel_type = ANTSEL_2x4; - asi->antsel_avail = true; - } - - /* Set the antenna selection type for the low driver */ - brcms_b_antsel_type_set(wlc->hw, asi->antsel_type); - - /* Init (auto/manual) antenna selection */ - brcms_c_antsel_init_cfg(asi, &asi->antcfg_11n, true); - brcms_c_antsel_init_cfg(asi, &asi->antcfg_cur, true); - - return asi; -} - -void brcms_c_antsel_detach(struct antsel_info *asi) -{ - kfree(asi); -} - -/* - * boardlevel antenna selection: - * convert ant_cfg to mimo_antsel (ucode interface) - */ -static u16 brcms_c_antsel_antcfg2antsel(struct antsel_info *asi, u8 ant_cfg) -{ - u8 idx = BRCMS_ANTIDX_11N(BRCMS_ANTSEL_11N(ant_cfg)); - u16 mimo_antsel = 0; - - if (asi->antsel_type == ANTSEL_2x4) { - /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ - mimo_antsel = (mimo_2x4_div_antselpat_tbl[idx] & 0xf); - return mimo_antsel; - - } else if (asi->antsel_type == ANTSEL_2x3) { - /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ - mimo_antsel = (mimo_2x3_div_antselpat_tbl[idx] & 0xf); - return mimo_antsel; - } - - return mimo_antsel; -} - -/* boardlevel antenna selection: ucode interface control */ -static int brcms_c_antsel_cfgupd(struct antsel_info *asi, - struct brcms_antselcfg *antsel) -{ - struct brcms_c_info *wlc = asi->wlc; - u8 ant_cfg; - u16 mimo_antsel; - - /* 1) Update TX antconfig for all frames that are not unicast data - * (aka default TX) - */ - ant_cfg = antsel->ant_config[ANT_SELCFG_TX_DEF]; - mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); - brcms_b_write_shm(wlc->hw, M_MIMO_ANTSEL_TXDFLT, mimo_antsel); - /* - * Update driver stats for currently selected - * default tx/rx antenna config - */ - asi->antcfg_cur.ant_config[ANT_SELCFG_TX_DEF] = ant_cfg; - - /* 2) Update RX antconfig for all frames that are not unicast data - * (aka default RX) - */ - ant_cfg = antsel->ant_config[ANT_SELCFG_RX_DEF]; - mimo_antsel = brcms_c_antsel_antcfg2antsel(asi, ant_cfg); - brcms_b_write_shm(wlc->hw, M_MIMO_ANTSEL_RXDFLT, mimo_antsel); - /* - * Update driver stats for currently selected - * default tx/rx antenna config - */ - asi->antcfg_cur.ant_config[ANT_SELCFG_RX_DEF] = ant_cfg; - - return 0; -} - -void brcms_c_antsel_init(struct antsel_info *asi) -{ - if ((asi->antsel_type == ANTSEL_2x3) || - (asi->antsel_type == ANTSEL_2x4)) - brcms_c_antsel_cfgupd(asi, &asi->antcfg_11n); -} - -/* boardlevel antenna selection: convert id to ant_cfg */ -static u8 brcms_c_antsel_id2antcfg(struct antsel_info *asi, u8 id) -{ - u8 antcfg = ANT_SELCFG_DEF_2x2; - - if (asi->antsel_type == ANTSEL_2x4) { - /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ - antcfg = (((id & 0x2) << 3) | ((id & 0x1) + 2)); - return antcfg; - - } else if (asi->antsel_type == ANTSEL_2x3) { - /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ - antcfg = (((id & 0x02) << 4) | ((id & 0x1) + 1)); - return antcfg; - } - - return antcfg; -} - -void -brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef, bool sel, - u8 antselid, u8 fbantselid, u8 *antcfg, - u8 *fbantcfg) -{ - u8 ant; - - /* if use default, assign it and return */ - if (usedef) { - *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_DEF]; - *fbantcfg = *antcfg; - return; - } - - if (!sel) { - *antcfg = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - *fbantcfg = *antcfg; - - } else { - ant = asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - if ((ant & ANT_SELCFG_AUTO) == ANT_SELCFG_AUTO) { - *antcfg = brcms_c_antsel_id2antcfg(asi, antselid); - *fbantcfg = brcms_c_antsel_id2antcfg(asi, fbantselid); - } else { - *antcfg = - asi->antcfg_11n.ant_config[ANT_SELCFG_TX_UNICAST]; - *fbantcfg = *antcfg; - } - } - return; -} - -/* boardlevel antenna selection: convert mimo_antsel (ucode interface) to id */ -u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel) -{ - u8 antselid = 0; - - if (asi->antsel_type == ANTSEL_2x4) { - /* 2x4 antenna diversity board, 4 cfgs: 0-2 0-3 1-2 1-3 */ - antselid = mimo_2x4_div_antselid_tbl[(antsel & 0xf)]; - return antselid; - - } else if (asi->antsel_type == ANTSEL_2x3) { - /* 2x3 antenna selection, 3 cfgs: 0-1 0-2 2-1 */ - antselid = mimo_2x3_div_antselid_tbl[(antsel & 0xf)]; - return antselid; - } - - return antselid; -} - diff --git a/drivers/staging/brcm80211/brcmsmac/antsel.h b/drivers/staging/brcm80211/brcmsmac/antsel.h deleted file mode 100644 index 97ea3881a8e..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/antsel.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_ANTSEL_H_ -#define _BRCM_ANTSEL_H_ - -extern struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc); -extern void brcms_c_antsel_detach(struct antsel_info *asi); -extern void brcms_c_antsel_init(struct antsel_info *asi); -extern void brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef, - bool sel, - u8 id, u8 fbid, u8 *antcfg, - u8 *fbantcfg); -extern u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel); - -#endif /* _BRCM_ANTSEL_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c deleted file mode 100644 index 52fc9eeb5fa..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include /* bug in tracepoint.h, it should include this */ - -#ifndef __CHECKER__ -#include "mac80211_if.h" -#define CREATE_TRACE_POINTS -#include "brcms_trace_events.h" -#endif diff --git a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h b/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h deleted file mode 100644 index 27dd73eef56..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/brcms_trace_events.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM brcmsmac - -#if !defined(__TRACE_BRCMSMAC_H) || defined(TRACE_HEADER_MULTI_READ) - -#define __TRACE_BRCMSMAC_H - -#include -#include "mac80211_if.h" - -#ifndef CONFIG_BRCMDBG -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, ...) \ -static inline void trace_ ## name(proto) {} -#endif - -/* - * We define a tracepoint, its arguments, its printk format and its - * 'fast binary record' layout. - */ -TRACE_EVENT(brcms_timer, - /* TPPROTO is the prototype of the function called by this tracepoint */ - TP_PROTO(struct brcms_timer *t), - /* - * TPARGS(firstarg, p) are the parameters names, same as found in the - * prototype. - */ - TP_ARGS(t), - /* - * Fast binary tracing: define the trace record via TP_STRUCT__entry(). - * You can think about it like a regular C structure local variable - * definition. - */ - TP_STRUCT__entry( - __field(uint, ms) - __field(uint, set) - __field(uint, periodic) - ), - TP_fast_assign( - __entry->ms = t->ms; - __entry->set = t->set; - __entry->periodic = t->periodic; - ), - TP_printk( - "ms=%u set=%u periodic=%u", - __entry->ms, __entry->set, __entry->periodic - ) -); - -TRACE_EVENT(brcms_dpc, - TP_PROTO(unsigned long data), - TP_ARGS(data), - TP_STRUCT__entry( - __field(unsigned long, data) - ), - TP_fast_assign( - __entry->data = data; - ), - TP_printk( - "data=%p", - (void *)__entry->data - ) -); - -#endif /* __TRACE_BRCMSMAC_H */ - -#ifdef CONFIG_BRCMDBG - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE brcms_trace_events - -#include - -#endif /* CONFIG_BRCMDBG */ diff --git a/drivers/staging/brcm80211/brcmsmac/channel.c b/drivers/staging/brcm80211/brcmsmac/channel.c deleted file mode 100644 index a1b415da6c3..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/channel.c +++ /dev/null @@ -1,1565 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include "pub.h" -#include "phy/phy_hal.h" -#include "main.h" -#include "stf.h" -#include "channel.h" - -/* QDB() macro takes a dB value and converts to a quarter dB value */ -#define QDB(n) ((n) * BRCMS_TXPWR_DB_FACTOR) - -#define LOCALE_CHAN_01_11 (1<<0) -#define LOCALE_CHAN_12_13 (1<<1) -#define LOCALE_CHAN_14 (1<<2) -#define LOCALE_SET_5G_LOW_JP1 (1<<3) /* 34-48, step 2 */ -#define LOCALE_SET_5G_LOW_JP2 (1<<4) /* 34-46, step 4 */ -#define LOCALE_SET_5G_LOW1 (1<<5) /* 36-48, step 4 */ -#define LOCALE_SET_5G_LOW2 (1<<6) /* 52 */ -#define LOCALE_SET_5G_LOW3 (1<<7) /* 56-64, step 4 */ -#define LOCALE_SET_5G_MID1 (1<<8) /* 100-116, step 4 */ -#define LOCALE_SET_5G_MID2 (1<<9) /* 120-124, step 4 */ -#define LOCALE_SET_5G_MID3 (1<<10) /* 128 */ -#define LOCALE_SET_5G_HIGH1 (1<<11) /* 132-140, step 4 */ -#define LOCALE_SET_5G_HIGH2 (1<<12) /* 149-161, step 4 */ -#define LOCALE_SET_5G_HIGH3 (1<<13) /* 165 */ -#define LOCALE_CHAN_52_140_ALL (1<<14) -#define LOCALE_SET_5G_HIGH4 (1<<15) /* 184-216 */ - -#define LOCALE_CHAN_36_64 (LOCALE_SET_5G_LOW1 | \ - LOCALE_SET_5G_LOW2 | \ - LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_52_64 (LOCALE_SET_5G_LOW2 | LOCALE_SET_5G_LOW3) -#define LOCALE_CHAN_100_124 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2) -#define LOCALE_CHAN_100_140 (LOCALE_SET_5G_MID1 | LOCALE_SET_5G_MID2 | \ - LOCALE_SET_5G_MID3 | LOCALE_SET_5G_HIGH1) -#define LOCALE_CHAN_149_165 (LOCALE_SET_5G_HIGH2 | LOCALE_SET_5G_HIGH3) -#define LOCALE_CHAN_184_216 LOCALE_SET_5G_HIGH4 - -#define LOCALE_CHAN_01_14 (LOCALE_CHAN_01_11 | \ - LOCALE_CHAN_12_13 | \ - LOCALE_CHAN_14) - -#define LOCALE_RADAR_SET_NONE 0 -#define LOCALE_RADAR_SET_1 1 - -#define LOCALE_RESTRICTED_NONE 0 -#define LOCALE_RESTRICTED_SET_2G_SHORT 1 -#define LOCALE_RESTRICTED_CHAN_165 2 -#define LOCALE_CHAN_ALL_5G 3 -#define LOCALE_RESTRICTED_JAPAN_LEGACY 4 -#define LOCALE_RESTRICTED_11D_2G 5 -#define LOCALE_RESTRICTED_11D_5G 6 -#define LOCALE_RESTRICTED_LOW_HI 7 -#define LOCALE_RESTRICTED_12_13_14 8 - -#define LOCALE_2G_IDX_i 0 -#define LOCALE_5G_IDX_11 0 -#define LOCALE_MIMO_IDX_bn 0 -#define LOCALE_MIMO_IDX_11n 0 - -/* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */ -#define BRCMS_MAXPWR_TBL_SIZE 6 -/* max of BAND_5G_PWR_LVLS and 14 for 2.4 GHz */ -#define BRCMS_MAXPWR_MIMO_TBL_SIZE 14 - -/* power level in group of 2.4GHz band channels: - * maxpwr[0] - CCK channels [1] - * maxpwr[1] - CCK channels [2-10] - * maxpwr[2] - CCK channels [11-14] - * maxpwr[3] - OFDM channels [1] - * maxpwr[4] - OFDM channels [2-10] - * maxpwr[5] - OFDM channels [11-14] - */ - -/* maxpwr mapping to 5GHz band channels: - * maxpwr[0] - channels [34-48] - * maxpwr[1] - channels [52-60] - * maxpwr[2] - channels [62-64] - * maxpwr[3] - channels [100-140] - * maxpwr[4] - channels [149-165] - */ -#define BAND_5G_PWR_LVLS 5 /* 5 power levels for 5G */ - -#define LC(id) LOCALE_MIMO_IDX_ ## id - -#define LC_2G(id) LOCALE_2G_IDX_ ## id - -#define LC_5G(id) LOCALE_5G_IDX_ ## id - -#define LOCALES(band2, band5, mimo2, mimo5) \ - {LC_2G(band2), LC_5G(band5), LC(mimo2), LC(mimo5)} - -/* macro to get 2.4 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) -#define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) - -/* macro to get 5 GHz channel group index for tx power */ -#define CHANNEL_POWER_IDX_5G(c) (((c) < 52) ? 0 : \ - (((c) < 62) ? 1 : \ - (((c) < 100) ? 2 : \ - (((c) < 149) ? 3 : 4)))) - -#define ISDFS_EU(fl) (((fl) & BRCMS_DFS_EU) == BRCMS_DFS_EU) - -struct brcms_cm_band { - /* struct locale_info flags */ - u8 locale_flags; - /* List of valid channels in the country */ - struct brcms_chanvec valid_channels; - /* List of restricted use channels */ - const struct brcms_chanvec *restricted_channels; - /* List of radar sensitive channels */ - const struct brcms_chanvec *radar_channels; - u8 PAD[8]; -}; - - /* locale per-channel tx power limits for MIMO frames - * maxpwr arrays are index by channel for 2.4 GHz limits, and - * by sub-band for 5 GHz limits using CHANNEL_POWER_IDX_5G(channel) - */ -struct locale_mimo_info { - /* tx 20 MHz power limits, qdBm units */ - s8 maxpwr20[BRCMS_MAXPWR_MIMO_TBL_SIZE]; - /* tx 40 MHz power limits, qdBm units */ - s8 maxpwr40[BRCMS_MAXPWR_MIMO_TBL_SIZE]; - u8 flags; -}; - -/* Country names and abbreviations with locale defined from ISO 3166 */ -struct country_info { - const u8 locale_2G; /* 2.4G band locale */ - const u8 locale_5G; /* 5G band locale */ - const u8 locale_mimo_2G; /* 2.4G mimo info */ - const u8 locale_mimo_5G; /* 5G mimo info */ -}; - -struct brcms_cm_info { - struct brcms_pub *pub; - struct brcms_c_info *wlc; - char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */ - uint srom_regrev; /* Regulatory Rev for the SROM ccode */ - const struct country_info *country; /* current country def */ - char ccode[BRCM_CNTRY_BUF_SZ]; /* current internal Country Code */ - uint regrev; /* current Regulatory Revision */ - char country_abbrev[BRCM_CNTRY_BUF_SZ]; /* current advertised ccode */ - /* per-band state (one per phy/radio) */ - struct brcms_cm_band bandstate[MAXBANDS]; - /* quiet channels currently for radar sensitivity or 11h support */ - /* channels on which we cannot transmit */ - struct brcms_chanvec quiet_channels; -}; - -/* locale channel and power info. */ -struct locale_info { - u32 valid_channels; - /* List of radar sensitive channels */ - u8 radar_channels; - /* List of channels used only if APs are detected */ - u8 restricted_channels; - /* Max tx pwr in qdBm for each sub-band */ - s8 maxpwr[BRCMS_MAXPWR_TBL_SIZE]; - /* Country IE advertised max tx pwr in dBm per sub-band */ - s8 pub_maxpwr[BAND_5G_PWR_LVLS]; - u8 flags; -}; - -/* Regulatory Matrix Spreadsheet (CLM) MIMO v3.7.9 */ - -/* - * Some common channel sets - */ - -/* No channels */ -static const struct brcms_chanvec chanvec_none = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* All 2.4 GHz HW channels */ -static const struct brcms_chanvec chanvec_all_2G = { - {0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* All 5 GHz HW channels */ -static const struct brcms_chanvec chanvec_all_5G = { - {0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x11, 0x11, - 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x20, 0x22, 0x22, 0x00, 0x00, 0x11, - 0x11, 0x11, 0x11, 0x01} -}; - -/* - * Radar channel sets - */ - -/* Channels 52 - 64, 100 - 140 */ -static const struct brcms_chanvec radar_set1 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, /* 52 - 60 */ - 0x01, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x11, /* 64, 100 - 124 */ - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128 - 140 */ - 0x00, 0x00, 0x00, 0x00} -}; - -/* - * Restricted channel sets - */ - -/* Channels 34, 38, 42, 46 */ -static const struct brcms_chanvec restricted_set_japan_legacy = { - {0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* Channels 12, 13 */ -static const struct brcms_chanvec restricted_set_2g_short = { - {0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* Channel 165 */ -static const struct brcms_chanvec restricted_chan_165 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* Channels 36 - 48 & 149 - 165 */ -static const struct brcms_chanvec restricted_low_hi = { - {0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x22, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* Channels 12 - 14 */ -static const struct brcms_chanvec restricted_set_12_13_14 = { - {0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -/* global memory to provide working buffer for expanded locale */ - -static const struct brcms_chanvec *g_table_radar_set[] = { - &chanvec_none, - &radar_set1 -}; - -static const struct brcms_chanvec *g_table_restricted_chan[] = { - &chanvec_none, /* restricted_set_none */ - &restricted_set_2g_short, - &restricted_chan_165, - &chanvec_all_5G, - &restricted_set_japan_legacy, - &chanvec_all_2G, /* restricted_set_11d_2G */ - &chanvec_all_5G, /* restricted_set_11d_5G */ - &restricted_low_hi, - &restricted_set_12_13_14 -}; - -static const struct brcms_chanvec locale_2g_01_11 = { - {0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_2g_12_13 = { - {0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_2g_14 = { - {0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_LOW_JP1 = { - {0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_LOW_JP2 = { - {0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_LOW1 = { - {0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_LOW2 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_LOW3 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_MID1 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x11, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_MID2 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_MID3 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_HIGH1 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_HIGH2 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x22, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_HIGH3 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_52_140_ALL = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_chanvec locale_5g_HIGH4 = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x11, 0x11, 0x11, 0x11} -}; - -static const struct brcms_chanvec *g_table_locale_base[] = { - &locale_2g_01_11, - &locale_2g_12_13, - &locale_2g_14, - &locale_5g_LOW_JP1, - &locale_5g_LOW_JP2, - &locale_5g_LOW1, - &locale_5g_LOW2, - &locale_5g_LOW3, - &locale_5g_MID1, - &locale_5g_MID2, - &locale_5g_MID3, - &locale_5g_HIGH1, - &locale_5g_HIGH2, - &locale_5g_HIGH3, - &locale_5g_52_140_ALL, - &locale_5g_HIGH4 -}; - -static void brcms_c_locale_add_channels(struct brcms_chanvec *target, - const struct brcms_chanvec *channels) -{ - u8 i; - for (i = 0; i < sizeof(struct brcms_chanvec); i++) - target->vec[i] |= channels->vec[i]; -} - -static void brcms_c_locale_get_channels(const struct locale_info *locale, - struct brcms_chanvec *channels) -{ - u8 i; - - memset(channels, 0, sizeof(struct brcms_chanvec)); - - for (i = 0; i < ARRAY_SIZE(g_table_locale_base); i++) { - if (locale->valid_channels & (1 << i)) - brcms_c_locale_add_channels(channels, - g_table_locale_base[i]); - } -} - -/* - * Locale Definitions - 2.4 GHz - */ -static const struct locale_info locale_i = { /* locale i. channel 1 - 13 */ - LOCALE_CHAN_01_11 | LOCALE_CHAN_12_13, - LOCALE_RADAR_SET_NONE, - LOCALE_RESTRICTED_SET_2G_SHORT, - {QDB(19), QDB(19), QDB(19), - QDB(19), QDB(19), QDB(19)}, - {20, 20, 20, 0}, - BRCMS_EIRP -}; - -/* - * Locale Definitions - 5 GHz - */ -static const struct locale_info locale_11 = { - /* locale 11. channel 36 - 48, 52 - 64, 100 - 140, 149 - 165 */ - LOCALE_CHAN_36_64 | LOCALE_CHAN_100_140 | LOCALE_CHAN_149_165, - LOCALE_RADAR_SET_1, - LOCALE_RESTRICTED_NONE, - {QDB(21), QDB(21), QDB(21), QDB(21), QDB(21)}, - {23, 23, 23, 30, 30}, - BRCMS_EIRP | BRCMS_DFS_EU -}; - -static const struct locale_info *g_locale_2g_table[] = { - &locale_i -}; - -static const struct locale_info *g_locale_5g_table[] = { - &locale_11 -}; - -/* - * MIMO Locale Definitions - 2.4 GHz - */ -static const struct locale_mimo_info locale_bn = { - {QDB(13), QDB(13), QDB(13), QDB(13), QDB(13), - QDB(13), QDB(13), QDB(13), QDB(13), QDB(13), - QDB(13), QDB(13), QDB(13)}, - {0, 0, QDB(13), QDB(13), QDB(13), - QDB(13), QDB(13), QDB(13), QDB(13), QDB(13), - QDB(13), 0, 0}, - 0 -}; - -static const struct locale_mimo_info *g_mimo_2g_table[] = { - &locale_bn -}; - -/* - * MIMO Locale Definitions - 5 GHz - */ -static const struct locale_mimo_info locale_11n = { - { /* 12.5 dBm */ 50, 50, 50, QDB(15), QDB(15)}, - {QDB(14), QDB(15), QDB(15), QDB(15), QDB(15)}, - 0 -}; - -static const struct locale_mimo_info *g_mimo_5g_table[] = { - &locale_11n -}; - -static const struct { - char abbrev[BRCM_CNTRY_BUF_SZ]; /* country abbreviation */ - struct country_info country; -} cntry_locales[] = { - { - "X2", LOCALES(i, 11, bn, 11n)}, /* Worldwide RoW 2 */ -}; - -#ifdef SUPPORT_40MHZ -/* 20MHz channel info for 40MHz pairing support */ -struct chan20_info { - u8 sb; - u8 adj_sbs; -}; - -/* indicates adjacent channels that are allowed for a 40 Mhz channel and - * those that permitted by the HT - */ -struct chan20_info chan20_info[] = { - /* 11b/11g */ -/* 0 */ {1, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 1 */ {2, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 2 */ {3, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 3 */ {4, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 4 */ {5, (CH_UPPER_SB | CH_LOWER_SB | CH_EWA_VALID)}, -/* 5 */ {6, (CH_UPPER_SB | CH_LOWER_SB | CH_EWA_VALID)}, -/* 6 */ {7, (CH_UPPER_SB | CH_LOWER_SB | CH_EWA_VALID)}, -/* 7 */ {8, (CH_UPPER_SB | CH_LOWER_SB | CH_EWA_VALID)}, -/* 8 */ {9, (CH_UPPER_SB | CH_LOWER_SB | CH_EWA_VALID)}, -/* 9 */ {10, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 10 */ {11, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 11 */ {12, (CH_LOWER_SB)}, -/* 12 */ {13, (CH_LOWER_SB)}, -/* 13 */ {14, (CH_LOWER_SB)}, - -/* 11a japan high */ -/* 14 */ {34, (CH_UPPER_SB)}, -/* 15 */ {38, (CH_LOWER_SB)}, -/* 16 */ {42, (CH_LOWER_SB)}, -/* 17 */ {46, (CH_LOWER_SB)}, - -/* 11a usa low */ -/* 18 */ {36, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 19 */ {40, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 20 */ {44, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 21 */ {48, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 22 */ {52, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 23 */ {56, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 24 */ {60, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 25 */ {64, (CH_LOWER_SB | CH_EWA_VALID)}, - -/* 11a Europe */ -/* 26 */ {100, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 27 */ {104, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 28 */ {108, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 29 */ {112, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 30 */ {116, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 31 */ {120, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 32 */ {124, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 33 */ {128, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 34 */ {132, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 35 */ {136, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 36 */ {140, (CH_LOWER_SB)}, - -/* 11a usa high, ref5 only */ -/* The 0x80 bit in pdiv means these are REF5, other entries are REF20 */ -/* 37 */ {149, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 38 */ {153, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 39 */ {157, (CH_UPPER_SB | CH_EWA_VALID)}, -/* 40 */ {161, (CH_LOWER_SB | CH_EWA_VALID)}, -/* 41 */ {165, (CH_LOWER_SB)}, - -/* 11a japan */ -/* 42 */ {184, (CH_UPPER_SB)}, -/* 43 */ {188, (CH_LOWER_SB)}, -/* 44 */ {192, (CH_UPPER_SB)}, -/* 45 */ {196, (CH_LOWER_SB)}, -/* 46 */ {200, (CH_UPPER_SB)}, -/* 47 */ {204, (CH_LOWER_SB)}, -/* 48 */ {208, (CH_UPPER_SB)}, -/* 49 */ {212, (CH_LOWER_SB)}, -/* 50 */ {216, (CH_LOWER_SB)} -}; -#endif /* SUPPORT_40MHZ */ - -static const struct locale_info *brcms_c_get_locale_2g(u8 locale_idx) -{ - if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) - return NULL; /* error condition */ - - return g_locale_2g_table[locale_idx]; -} - -static const struct locale_info *brcms_c_get_locale_5g(u8 locale_idx) -{ - if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) - return NULL; /* error condition */ - - return g_locale_5g_table[locale_idx]; -} - -static const struct locale_mimo_info *brcms_c_get_mimo_2g(u8 locale_idx) -{ - if (locale_idx >= ARRAY_SIZE(g_mimo_2g_table)) - return NULL; - - return g_mimo_2g_table[locale_idx]; -} - -static const struct locale_mimo_info *brcms_c_get_mimo_5g(u8 locale_idx) -{ - if (locale_idx >= ARRAY_SIZE(g_mimo_5g_table)) - return NULL; - - return g_mimo_5g_table[locale_idx]; -} - -static int -brcms_c_country_aggregate_map(struct brcms_cm_info *wlc_cm, const char *ccode, - char *mapped_ccode, uint *mapped_regrev) -{ - return false; -} - -/* Lookup a country info structure from a null terminated country - * abbreviation and regrev directly with no translation. - */ -static const struct country_info * -brcms_c_country_lookup_direct(const char *ccode, uint regrev) -{ - uint size, i; - - /* Should just return 0 for single locale driver. */ - /* Keep it this way in case we add more locales. (for now anyway) */ - - /* - * all other country def arrays are for regrev == 0, so if - * regrev is non-zero, fail - */ - if (regrev > 0) - return NULL; - - /* find matched table entry from country code */ - size = ARRAY_SIZE(cntry_locales); - for (i = 0; i < size; i++) { - if (strcmp(ccode, cntry_locales[i].abbrev) == 0) - return &cntry_locales[i].country; - } - return NULL; -} - -static const struct country_info * -brcms_c_countrycode_map(struct brcms_cm_info *wlc_cm, const char *ccode, - char *mapped_ccode, uint *mapped_regrev) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - const struct country_info *country; - uint srom_regrev = wlc_cm->srom_regrev; - const char *srom_ccode = wlc_cm->srom_ccode; - int mapped; - - /* check for currently supported ccode size */ - if (strlen(ccode) > (BRCM_CNTRY_BUF_SZ - 1)) { - wiphy_err(wlc->wiphy, "wl%d: %s: ccode \"%s\" too long for " - "match\n", wlc->pub->unit, __func__, ccode); - return NULL; - } - - /* default mapping is the given ccode and regrev 0 */ - strncpy(mapped_ccode, ccode, BRCM_CNTRY_BUF_SZ); - *mapped_regrev = 0; - - /* If the desired country code matches the srom country code, - * then the mapped country is the srom regulatory rev. - * Otherwise look for an aggregate mapping. - */ - if (!strcmp(srom_ccode, ccode)) { - *mapped_regrev = srom_regrev; - mapped = 0; - wiphy_err(wlc->wiphy, "srom_code == ccode %s\n", __func__); - } else { - mapped = - brcms_c_country_aggregate_map(wlc_cm, ccode, mapped_ccode, - mapped_regrev); - } - - /* find the matching built-in country definition */ - country = brcms_c_country_lookup_direct(mapped_ccode, *mapped_regrev); - - /* if there is not an exact rev match, default to rev zero */ - if (country == NULL && *mapped_regrev != 0) { - *mapped_regrev = 0; - country = - brcms_c_country_lookup_direct(mapped_ccode, *mapped_regrev); - } - - return country; -} - -/* Lookup a country info structure from a null terminated country code - * The lookup is case sensitive. - */ -static const struct country_info * -brcms_c_country_lookup(struct brcms_c_info *wlc, const char *ccode) -{ - const struct country_info *country; - char mapped_ccode[BRCM_CNTRY_BUF_SZ]; - uint mapped_regrev; - - /* - * map the country code to a built-in country code, regrev, and - * country_info struct - */ - country = brcms_c_countrycode_map(wlc->cmi, ccode, mapped_ccode, - &mapped_regrev); - - return country; -} - -/* - * reset the quiet channels vector to the union - * of the restricted and radar channel sets - */ -static void brcms_c_quiet_channels_reset(struct brcms_cm_info *wlc_cm) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint i, j; - struct brcms_band *band; - const struct brcms_chanvec *chanvec; - - memset(&wlc_cm->quiet_channels, 0, sizeof(struct brcms_chanvec)); - - band = wlc->band; - for (i = 0; i < wlc->pub->_nbands; - i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { - - /* initialize quiet channels for restricted channels */ - chanvec = wlc_cm->bandstate[band->bandunit].restricted_channels; - for (j = 0; j < sizeof(struct brcms_chanvec); j++) - wlc_cm->quiet_channels.vec[j] |= chanvec->vec[j]; - - } -} - -/* Is the channel valid for the current locale and current band? */ -static bool brcms_c_valid_channel20(struct brcms_cm_info *wlc_cm, uint val) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - - return ((val < MAXCHANNEL) && - isset(wlc_cm->bandstate[wlc->band->bandunit].valid_channels.vec, - val)); -} - -/* Is the channel valid for the current locale and specified band? */ -static bool brcms_c_valid_channel20_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit, uint val) -{ - return ((val < MAXCHANNEL) - && isset(wlc_cm->bandstate[bandunit].valid_channels.vec, val)); -} - -/* Is the channel valid for the current locale? (but don't consider channels not - * available due to bandlocking) - */ -static bool brcms_c_valid_channel20_db(struct brcms_cm_info *wlc_cm, uint val) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - - return brcms_c_valid_channel20(wlc->cmi, val) || - (!wlc->bandlocked - && brcms_c_valid_channel20_in_band(wlc->cmi, - OTHERBANDUNIT(wlc), val)); -} - -/* JP, J1 - J10 are Japan ccodes */ -static bool brcms_c_japan_ccode(const char *ccode) -{ - return (ccode[0] == 'J' && - (ccode[1] == 'P' || (ccode[1] >= '1' && ccode[1] <= '9'))); -} - -/* Returns true if currently set country is Japan or variant */ -static bool brcms_c_japan(struct brcms_c_info *wlc) -{ - return brcms_c_japan_ccode(wlc->cmi->country_abbrev); -} - -static void -brcms_c_channel_min_txpower_limits_with_local_constraint( - struct brcms_cm_info *wlc_cm, struct txpwr_limits *txpwr, - u8 local_constraint_qdbm) -{ - int j; - - /* CCK Rates */ - for (j = 0; j < WL_TX_POWER_CCK_NUM; j++) - txpwr->cck[j] = min(txpwr->cck[j], local_constraint_qdbm); - - /* 20 MHz Legacy OFDM SISO */ - for (j = 0; j < WL_TX_POWER_OFDM_NUM; j++) - txpwr->ofdm[j] = min(txpwr->ofdm[j], local_constraint_qdbm); - - /* 20 MHz Legacy OFDM CDD */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) - txpwr->ofdm_cdd[j] = - min(txpwr->ofdm_cdd[j], local_constraint_qdbm); - - /* 40 MHz Legacy OFDM SISO */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) - txpwr->ofdm_40_siso[j] = - min(txpwr->ofdm_40_siso[j], local_constraint_qdbm); - - /* 40 MHz Legacy OFDM CDD */ - for (j = 0; j < BRCMS_NUM_RATES_OFDM; j++) - txpwr->ofdm_40_cdd[j] = - min(txpwr->ofdm_40_cdd[j], local_constraint_qdbm); - - /* 20MHz MCS 0-7 SISO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_20_siso[j] = - min(txpwr->mcs_20_siso[j], local_constraint_qdbm); - - /* 20MHz MCS 0-7 CDD */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_20_cdd[j] = - min(txpwr->mcs_20_cdd[j], local_constraint_qdbm); - - /* 20MHz MCS 0-7 STBC */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_20_stbc[j] = - min(txpwr->mcs_20_stbc[j], local_constraint_qdbm); - - /* 20MHz MCS 8-15 MIMO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_2_STREAM; j++) - txpwr->mcs_20_mimo[j] = - min(txpwr->mcs_20_mimo[j], local_constraint_qdbm); - - /* 40MHz MCS 0-7 SISO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_40_siso[j] = - min(txpwr->mcs_40_siso[j], local_constraint_qdbm); - - /* 40MHz MCS 0-7 CDD */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_40_cdd[j] = - min(txpwr->mcs_40_cdd[j], local_constraint_qdbm); - - /* 40MHz MCS 0-7 STBC */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_1_STREAM; j++) - txpwr->mcs_40_stbc[j] = - min(txpwr->mcs_40_stbc[j], local_constraint_qdbm); - - /* 40MHz MCS 8-15 MIMO */ - for (j = 0; j < BRCMS_NUM_RATES_MCS_2_STREAM; j++) - txpwr->mcs_40_mimo[j] = - min(txpwr->mcs_40_mimo[j], local_constraint_qdbm); - - /* 40MHz MCS 32 */ - txpwr->mcs32 = min(txpwr->mcs32, local_constraint_qdbm); - -} - -/* Update the radio state (enable/disable) and tx power targets - * based on a new set of channel/regulatory information - */ -static void brcms_c_channels_commit(struct brcms_cm_info *wlc_cm) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint chan; - struct txpwr_limits txpwr; - - /* search for the existence of any valid channel */ - for (chan = 0; chan < MAXCHANNEL; chan++) { - if (brcms_c_valid_channel20_db(wlc->cmi, chan)) - break; - } - if (chan == MAXCHANNEL) - chan = INVCHANNEL; - - /* - * based on the channel search above, set or - * clear WL_RADIO_COUNTRY_DISABLE. - */ - if (chan == INVCHANNEL) { - /* - * country/locale with no valid channels, set - * the radio disable bit - */ - mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); - wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" " - "nbands %d bandlocked %d\n", wlc->pub->unit, - __func__, wlc_cm->country_abbrev, wlc->pub->_nbands, - wlc->bandlocked); - } else if (mboolisset(wlc->pub->radio_disabled, - WL_RADIO_COUNTRY_DISABLE)) { - /* - * country/locale with valid channel, clear - * the radio disable bit - */ - mboolclr(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE); - } - - /* - * Now that the country abbreviation is set, if the radio supports 2G, - * then set channel 14 restrictions based on the new locale. - */ - if (wlc->pub->_nbands > 1 || wlc->band->bandtype == BRCM_BAND_2G) - wlc_phy_chanspec_ch14_widefilter_set(wlc->band->pi, - brcms_c_japan(wlc) ? true : - false); - - if (wlc->pub->up && chan != INVCHANNEL) { - brcms_c_channel_reg_limits(wlc_cm, wlc->chanspec, &txpwr); - brcms_c_channel_min_txpower_limits_with_local_constraint(wlc_cm, - &txpwr, BRCMS_TXPWR_MAX); - wlc_phy_txpower_limit_set(wlc->band->pi, &txpwr, wlc->chanspec); - } -} - -static int -brcms_c_channels_init(struct brcms_cm_info *wlc_cm, - const struct country_info *country) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint i, j; - struct brcms_band *band; - const struct locale_info *li; - struct brcms_chanvec sup_chan; - const struct locale_mimo_info *li_mimo; - - band = wlc->band; - for (i = 0; i < wlc->pub->_nbands; - i++, band = wlc->bandstate[OTHERBANDUNIT(wlc)]) { - - li = (band->bandtype == BRCM_BAND_5G) ? - brcms_c_get_locale_5g(country->locale_5G) : - brcms_c_get_locale_2g(country->locale_2G); - wlc_cm->bandstate[band->bandunit].locale_flags = li->flags; - li_mimo = (band->bandtype == BRCM_BAND_5G) ? - brcms_c_get_mimo_5g(country->locale_mimo_5G) : - brcms_c_get_mimo_2g(country->locale_mimo_2G); - - /* merge the mimo non-mimo locale flags */ - wlc_cm->bandstate[band->bandunit].locale_flags |= - li_mimo->flags; - - wlc_cm->bandstate[band->bandunit].restricted_channels = - g_table_restricted_chan[li->restricted_channels]; - wlc_cm->bandstate[band->bandunit].radar_channels = - g_table_radar_set[li->radar_channels]; - - /* - * set the channel availability, masking out the channels - * that may not be supported on this phy. - */ - wlc_phy_chanspec_band_validch(band->pi, band->bandtype, - &sup_chan); - brcms_c_locale_get_channels(li, - &wlc_cm->bandstate[band->bandunit]. - valid_channels); - for (j = 0; j < sizeof(struct brcms_chanvec); j++) - wlc_cm->bandstate[band->bandunit].valid_channels. - vec[j] &= sup_chan.vec[j]; - } - - brcms_c_quiet_channels_reset(wlc_cm); - brcms_c_channels_commit(wlc_cm); - - return 0; -} - -/* - * set the driver's current country and regulatory information - * using a country code as the source. Look up built in country - * information found with the country code. - */ -static void -brcms_c_set_country_common(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, uint regrev, - const struct country_info *country) -{ - const struct locale_info *locale; - struct brcms_c_info *wlc = wlc_cm->wlc; - char prev_country_abbrev[BRCM_CNTRY_BUF_SZ]; - - /* save current country state */ - wlc_cm->country = country; - - memset(&prev_country_abbrev, 0, BRCM_CNTRY_BUF_SZ); - strncpy(prev_country_abbrev, wlc_cm->country_abbrev, - BRCM_CNTRY_BUF_SZ - 1); - - strncpy(wlc_cm->country_abbrev, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); - strncpy(wlc_cm->ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - wlc_cm->regrev = regrev; - - if ((wlc->pub->_n_enab & SUPPORT_11N) != - wlc->protection->nmode_user) - brcms_c_set_nmode(wlc); - - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); - /* set or restore gmode as required by regulatory */ - locale = brcms_c_get_locale_2g(country->locale_2G); - if (locale && (locale->flags & BRCMS_NO_OFDM)) - brcms_c_set_gmode(wlc, GMODE_LEGACY_B, false); - else - brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); - - brcms_c_channels_init(wlc_cm, country); - - return; -} - -static int -brcms_c_set_countrycode_rev(struct brcms_cm_info *wlc_cm, - const char *country_abbrev, - const char *ccode, int regrev) -{ - const struct country_info *country; - char mapped_ccode[BRCM_CNTRY_BUF_SZ]; - uint mapped_regrev; - - /* if regrev is -1, lookup the mapped country code, - * otherwise use the ccode and regrev directly - */ - if (regrev == -1) { - /* - * map the country code to a built-in country - * code, regrev, and country_info - */ - country = - brcms_c_countrycode_map(wlc_cm, ccode, mapped_ccode, - &mapped_regrev); - } else { - /* find the matching built-in country definition */ - country = brcms_c_country_lookup_direct(ccode, regrev); - strncpy(mapped_ccode, ccode, BRCM_CNTRY_BUF_SZ); - mapped_regrev = regrev; - } - - if (country == NULL) - return -EINVAL; - - /* set the driver state for the country */ - brcms_c_set_country_common(wlc_cm, country_abbrev, mapped_ccode, - mapped_regrev, country); - - return 0; -} - -/* - * set the driver's current country and regulatory information using - * a country code as the source. Lookup built in country information - * found with the country code. - */ -static int -brcms_c_set_countrycode(struct brcms_cm_info *wlc_cm, const char *ccode) -{ - char country_abbrev[BRCM_CNTRY_BUF_SZ]; - strncpy(country_abbrev, ccode, BRCM_CNTRY_BUF_SZ); - return brcms_c_set_countrycode_rev(wlc_cm, country_abbrev, ccode, -1); -} - -struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) -{ - struct brcms_cm_info *wlc_cm; - char country_abbrev[BRCM_CNTRY_BUF_SZ]; - const struct country_info *country; - struct brcms_pub *pub = wlc->pub; - char *ccode; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - wlc_cm = kzalloc(sizeof(struct brcms_cm_info), GFP_ATOMIC); - if (wlc_cm == NULL) - return NULL; - wlc_cm->pub = pub; - wlc_cm->wlc = wlc; - wlc->cmi = wlc_cm; - - /* store the country code for passing up as a regulatory hint */ - ccode = getvar(wlc->hw->sih, BRCMS_SROM_CCODE); - if (ccode) - strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); - - /* - * internal country information which must match - * regulatory constraints in firmware - */ - memset(country_abbrev, 0, BRCM_CNTRY_BUF_SZ); - strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1); - country = brcms_c_country_lookup(wlc, country_abbrev); - - /* save default country for exiting 11d regulatory mode */ - strncpy(wlc->country_default, country_abbrev, BRCM_CNTRY_BUF_SZ - 1); - - /* initialize autocountry_default to driver default */ - strncpy(wlc->autocountry_default, "X2", BRCM_CNTRY_BUF_SZ - 1); - - brcms_c_set_countrycode(wlc_cm, country_abbrev); - - return wlc_cm; -} - -void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm) -{ - kfree(wlc_cm); -} - -u8 -brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit) -{ - return wlc_cm->bandstate[bandunit].locale_flags; -} - -static bool -brcms_c_quiet_chanspec(struct brcms_cm_info *wlc_cm, u16 chspec) -{ - return (wlc_cm->wlc->pub->_n_enab & SUPPORT_11N) && - CHSPEC_IS40(chspec) ? - (isset(wlc_cm->quiet_channels.vec, - lower_20_sb(CHSPEC_CHANNEL(chspec))) || - isset(wlc_cm->quiet_channels.vec, - upper_20_sb(CHSPEC_CHANNEL(chspec)))) : - isset(wlc_cm->quiet_channels.vec, CHSPEC_CHANNEL(chspec)); -} - -void -brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, - u8 local_constraint_qdbm) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - struct txpwr_limits txpwr; - - brcms_c_channel_reg_limits(wlc_cm, chanspec, &txpwr); - - brcms_c_channel_min_txpower_limits_with_local_constraint( - wlc_cm, &txpwr, local_constraint_qdbm - ); - - brcms_b_set_chanspec(wlc->hw, chanspec, - (brcms_c_quiet_chanspec(wlc_cm, chanspec) != 0), - &txpwr); -} - -#ifdef POWER_DBG -static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) -{ - int i; - char buf[80]; - char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; - - sprintf(buf, "CCK "); - for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->cck[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->cck[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_stbc[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_stbc[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_mimo[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_mimo[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_stbc[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_stbc[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_mimo[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_mimo[i] % - BRCMS_TXPWR_DB_FACTOR]); - } - printk(KERN_DEBUG "%s\n", buf); - - printk(KERN_DEBUG "MCS32 %2d%s\n", - txpwr->mcs32 / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs32 % BRCMS_TXPWR_DB_FACTOR]); -} -#endif /* POWER_DBG */ - -void -brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, - struct txpwr_limits *txpwr) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - uint i; - uint chan; - int maxpwr; - int delta; - const struct country_info *country; - struct brcms_band *band; - const struct locale_info *li; - int conducted_max = BRCMS_TXPWR_MAX; - int conducted_ofdm_max = BRCMS_TXPWR_MAX; - const struct locale_mimo_info *li_mimo; - int maxpwr20, maxpwr40; - int maxpwr_idx; - uint j; - - memset(txpwr, 0, sizeof(struct txpwr_limits)); - - if (!brcms_c_valid_chanspec_db(wlc_cm, chanspec)) { - country = brcms_c_country_lookup(wlc, wlc->autocountry_default); - if (country == NULL) - return; - } else { - country = wlc_cm->country; - } - - chan = CHSPEC_CHANNEL(chanspec); - band = wlc->bandstate[chspec_bandunit(chanspec)]; - li = (band->bandtype == BRCM_BAND_5G) ? - brcms_c_get_locale_5g(country->locale_5G) : - brcms_c_get_locale_2g(country->locale_2G); - - li_mimo = (band->bandtype == BRCM_BAND_5G) ? - brcms_c_get_mimo_5g(country->locale_mimo_5G) : - brcms_c_get_mimo_2g(country->locale_mimo_2G); - - if (li->flags & BRCMS_EIRP) { - delta = band->antgain; - } else { - delta = 0; - if (band->antgain > QDB(6)) - delta = band->antgain - QDB(6); /* Excess over 6 dB */ - } - - if (li == &locale_i) { - conducted_max = QDB(22); - conducted_ofdm_max = QDB(22); - } - - /* CCK txpwr limits for 2.4G band */ - if (band->bandtype == BRCM_BAND_2G) { - maxpwr = li->maxpwr[CHANNEL_POWER_IDX_2G_CCK(chan)]; - - maxpwr = maxpwr - delta; - maxpwr = max(maxpwr, 0); - maxpwr = min(maxpwr, conducted_max); - - for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) - txpwr->cck[i] = (u8) maxpwr; - } - - /* OFDM txpwr limits for 2.4G or 5G bands */ - if (band->bandtype == BRCM_BAND_2G) - maxpwr = li->maxpwr[CHANNEL_POWER_IDX_2G_OFDM(chan)]; - else - maxpwr = li->maxpwr[CHANNEL_POWER_IDX_5G(chan)]; - - maxpwr = maxpwr - delta; - maxpwr = max(maxpwr, 0); - maxpwr = min(maxpwr, conducted_ofdm_max); - - /* Keep OFDM lmit below CCK limit */ - if (band->bandtype == BRCM_BAND_2G) - maxpwr = min_t(int, maxpwr, txpwr->cck[0]); - - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - txpwr->ofdm[i] = (u8) maxpwr; - - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) { - /* - * OFDM 40 MHz SISO has the same power as the corresponding - * MCS0-7 rate unless overriden by the locale specific code. - * We set this value to 0 as a flag (presumably 0 dBm isn't - * a possibility) and then copy the MCS0-7 value to the 40 MHz - * value if it wasn't explicitly set. - */ - txpwr->ofdm_40_siso[i] = 0; - - txpwr->ofdm_cdd[i] = (u8) maxpwr; - - txpwr->ofdm_40_cdd[i] = 0; - } - - /* MIMO/HT specific limits */ - if (li_mimo->flags & BRCMS_EIRP) { - delta = band->antgain; - } else { - delta = 0; - if (band->antgain > QDB(6)) - delta = band->antgain - QDB(6); /* Excess over 6 dB */ - } - - if (band->bandtype == BRCM_BAND_2G) - maxpwr_idx = (chan - 1); - else - maxpwr_idx = CHANNEL_POWER_IDX_5G(chan); - - maxpwr20 = li_mimo->maxpwr20[maxpwr_idx]; - maxpwr40 = li_mimo->maxpwr40[maxpwr_idx]; - - maxpwr20 = maxpwr20 - delta; - maxpwr20 = max(maxpwr20, 0); - maxpwr40 = maxpwr40 - delta; - maxpwr40 = max(maxpwr40, 0); - - /* Fill in the MCS 0-7 (SISO) rates */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - - /* - * 20 MHz has the same power as the corresponding OFDM rate - * unless overriden by the locale specific code. - */ - txpwr->mcs_20_siso[i] = txpwr->ofdm[i]; - txpwr->mcs_40_siso[i] = 0; - } - - /* Fill in the MCS 0-7 CDD rates */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - txpwr->mcs_20_cdd[i] = (u8) maxpwr20; - txpwr->mcs_40_cdd[i] = (u8) maxpwr40; - } - - /* - * These locales have SISO expressed in the - * table and override CDD later - */ - if (li_mimo == &locale_bn) { - if (li_mimo == &locale_bn) { - maxpwr20 = QDB(16); - maxpwr40 = 0; - - if (chan >= 3 && chan <= 11) - maxpwr40 = QDB(16); - } - - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - txpwr->mcs_20_siso[i] = (u8) maxpwr20; - txpwr->mcs_40_siso[i] = (u8) maxpwr40; - } - } - - /* Fill in the MCS 0-7 STBC rates */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - txpwr->mcs_20_stbc[i] = 0; - txpwr->mcs_40_stbc[i] = 0; - } - - /* Fill in the MCS 8-15 SDM rates */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) { - txpwr->mcs_20_mimo[i] = (u8) maxpwr20; - txpwr->mcs_40_mimo[i] = (u8) maxpwr40; - } - - /* Fill in MCS32 */ - txpwr->mcs32 = (u8) maxpwr40; - - for (i = 0, j = 0; i < BRCMS_NUM_RATES_OFDM; i++, j++) { - if (txpwr->ofdm_40_cdd[i] == 0) - txpwr->ofdm_40_cdd[i] = txpwr->mcs_40_cdd[j]; - if (i == 0) { - i = i + 1; - if (txpwr->ofdm_40_cdd[i] == 0) - txpwr->ofdm_40_cdd[i] = txpwr->mcs_40_cdd[j]; - } - } - - /* - * Copy the 40 MHZ MCS 0-7 CDD value to the 40 MHZ MCS 0-7 SISO - * value if it wasn't provided explicitly. - */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - if (txpwr->mcs_40_siso[i] == 0) - txpwr->mcs_40_siso[i] = txpwr->mcs_40_cdd[i]; - } - - for (i = 0, j = 0; i < BRCMS_NUM_RATES_OFDM; i++, j++) { - if (txpwr->ofdm_40_siso[i] == 0) - txpwr->ofdm_40_siso[i] = txpwr->mcs_40_siso[j]; - if (i == 0) { - i = i + 1; - if (txpwr->ofdm_40_siso[i] == 0) - txpwr->ofdm_40_siso[i] = txpwr->mcs_40_siso[j]; - } - } - - /* - * Copy the 20 and 40 MHz MCS0-7 CDD values to the corresponding - * STBC values if they weren't provided explicitly. - */ - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) { - if (txpwr->mcs_20_stbc[i] == 0) - txpwr->mcs_20_stbc[i] = txpwr->mcs_20_cdd[i]; - - if (txpwr->mcs_40_stbc[i] == 0) - txpwr->mcs_40_stbc[i] = txpwr->mcs_40_cdd[i]; - } - -#ifdef POWER_DBG - wlc_phy_txpower_limits_dump(txpwr); -#endif - return; -} - -/* - * Validate the chanspec for this locale, for 40MHZ we need to also - * check that the sidebands are valid 20MZH channels in this locale - * and they are also a legal HT combination - */ -static bool -brcms_c_valid_chanspec_ext(struct brcms_cm_info *wlc_cm, u16 chspec, - bool dualband) -{ - struct brcms_c_info *wlc = wlc_cm->wlc; - u8 channel = CHSPEC_CHANNEL(chspec); - - /* check the chanspec */ - if (brcmu_chspec_malformed(chspec)) { - wiphy_err(wlc->wiphy, "wl%d: malformed chanspec 0x%x\n", - wlc->pub->unit, chspec); - return false; - } - - if (CHANNEL_BANDUNIT(wlc_cm->wlc, channel) != - chspec_bandunit(chspec)) - return false; - - /* Check a 20Mhz channel */ - if (CHSPEC_IS20(chspec)) { - if (dualband) - return brcms_c_valid_channel20_db(wlc_cm->wlc->cmi, - channel); - else - return brcms_c_valid_channel20(wlc_cm->wlc->cmi, - channel); - } -#ifdef SUPPORT_40MHZ - /* - * We know we are now checking a 40MHZ channel, so we should - * only be here for NPHYS - */ - if (BRCMS_ISNPHY(wlc->band) || BRCMS_ISSSLPNPHY(wlc->band)) { - u8 upper_sideband = 0, idx; - u8 num_ch20_entries = - sizeof(chan20_info) / sizeof(struct chan20_info); - - if (!VALID_40CHANSPEC_IN_BAND(wlc, chspec_bandunit(chspec))) - return false; - - if (dualband) { - if (!brcms_c_valid_channel20_db(wlc->cmi, - lower_20_sb(channel)) || - !brcms_c_valid_channel20_db(wlc->cmi, - upper_20_sb(channel))) - return false; - } else { - if (!brcms_c_valid_channel20(wlc->cmi, - lower_20_sb(channel)) || - !brcms_c_valid_channel20(wlc->cmi, - upper_20_sb(channel))) - return false; - } - - /* find the lower sideband info in the sideband array */ - for (idx = 0; idx < num_ch20_entries; idx++) { - if (chan20_info[idx].sb == lower_20_sb(channel)) - upper_sideband = chan20_info[idx].adj_sbs; - } - /* check that the lower sideband allows an upper sideband */ - if ((upper_sideband & (CH_UPPER_SB | CH_EWA_VALID)) == - (CH_UPPER_SB | CH_EWA_VALID)) - return true; - return false; - } -#endif /* 40 MHZ */ - - return false; -} - -bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, u16 chspec) -{ - return brcms_c_valid_chanspec_ext(wlc_cm, chspec, true); -} diff --git a/drivers/staging/brcm80211/brcmsmac/channel.h b/drivers/staging/brcm80211/brcmsmac/channel.h deleted file mode 100644 index 808cb4fbfbe..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/channel.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_CHANNEL_H_ -#define _BRCM_CHANNEL_H_ - -/* conversion for phy txpwr calculations that use .25 dB units */ -#define BRCMS_TXPWR_DB_FACTOR 4 - -/* bits for locale_info flags */ -#define BRCMS_PEAK_CONDUCTED 0x00 /* Peak for locals */ -#define BRCMS_EIRP 0x01 /* Flag for EIRP */ -#define BRCMS_DFS_TPC 0x02 /* Flag for DFS TPC */ -#define BRCMS_NO_OFDM 0x04 /* Flag for No OFDM */ -#define BRCMS_NO_40MHZ 0x08 /* Flag for No MIMO 40MHz */ -#define BRCMS_NO_MIMO 0x10 /* Flag for No MIMO, 20 or 40 MHz */ -#define BRCMS_RADAR_TYPE_EU 0x20 /* Flag for EU */ -#define BRCMS_DFS_FCC BRCMS_DFS_TPC /* Flag for DFS FCC */ - -#define BRCMS_DFS_EU (BRCMS_DFS_TPC | BRCMS_RADAR_TYPE_EU) /* Flag for DFS EU */ - -extern struct brcms_cm_info * -brcms_c_channel_mgr_attach(struct brcms_c_info *wlc); - -extern void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm); - -extern u8 brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm, - uint bandunit); - -extern bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, - u16 chspec); - -extern void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, - u16 chanspec, - struct txpwr_limits *txpwr); -extern void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, - u16 chanspec, - u8 local_constraint_qdbm); - -#endif /* _WLC_CHANNEL_H */ diff --git a/drivers/staging/brcm80211/brcmsmac/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h deleted file mode 100644 index ed51616abc8..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/d11.h +++ /dev/null @@ -1,1898 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_D11_H_ -#define _BRCM_D11_H_ - -#include - -#include -#include "pub.h" -#include "dma.h" - -/* RX FIFO numbers */ -#define RX_FIFO 0 /* data and ctl frames */ -#define RX_TXSTATUS_FIFO 3 /* RX fifo for tx status packages */ - -/* TX FIFO numbers using WME Access Category */ -#define TX_AC_BK_FIFO 0 /* Background TX FIFO */ -#define TX_AC_BE_FIFO 1 /* Best-Effort TX FIFO */ -#define TX_AC_VI_FIFO 2 /* Video TX FIFO */ -#define TX_AC_VO_FIFO 3 /* Voice TX FIFO */ -#define TX_BCMC_FIFO 4 /* Broadcast/Multicast TX FIFO */ -#define TX_ATIM_FIFO 5 /* TX fifo for ATIM window info */ - -/* Addr is byte address used by SW; offset is word offset used by uCode */ - -/* Per AC TX limit settings */ -#define M_AC_TXLMT_BASE_ADDR (0x180 * 2) -#define M_AC_TXLMT_ADDR(_ac) (M_AC_TXLMT_BASE_ADDR + (2 * (_ac))) - -/* Legacy TX FIFO numbers */ -#define TX_DATA_FIFO TX_AC_BE_FIFO -#define TX_CTL_FIFO TX_AC_VO_FIFO - -#define WL_RSSI_ANT_MAX 4 /* max possible rx antennas */ - -struct intctrlregs { - u32 intstatus; - u32 intmask; -}; - -/* PIO structure, - * support two PIO format: 2 bytes access and 4 bytes access - * basic FIFO register set is per channel(transmit or receive) - * a pair of channels is defined for convenience - */ -/* 2byte-wide pio register set per channel(xmt or rcv) */ -struct pio2regs { - u16 fifocontrol; - u16 fifodata; - u16 fifofree; /* only valid in xmt channel, not in rcv channel */ - u16 PAD; -}; - -/* a pair of pio channels(tx and rx) */ -struct pio2regp { - struct pio2regs tx; - struct pio2regs rx; -}; - -/* 4byte-wide pio register set per channel(xmt or rcv) */ -struct pio4regs { - u32 fifocontrol; - u32 fifodata; -}; - -/* a pair of pio channels(tx and rx) */ -struct pio4regp { - struct pio4regs tx; - struct pio4regs rx; -}; - -/* read: 32-bit register that can be read as 32-bit or as 2 16-bit - * write: only low 16b-it half can be written - */ -union pmqreg { - u32 pmqhostdata; /* read only! */ - struct { - u16 pmqctrlstatus; /* read/write */ - u16 PAD; - } w; -}; - -struct fifo64 { - struct dma64regs dmaxmt; /* dma tx */ - struct pio4regs piotx; /* pio tx */ - struct dma64regs dmarcv; /* dma rx */ - struct pio4regs piorx; /* pio rx */ -}; - -/* - * Host Interface Registers - */ -struct d11regs { - /* Device Control ("semi-standard host registers") */ - u32 PAD[3]; /* 0x0 - 0x8 */ - u32 biststatus; /* 0xC */ - u32 biststatus2; /* 0x10 */ - u32 PAD; /* 0x14 */ - u32 gptimer; /* 0x18 */ - u32 usectimer; /* 0x1c *//* for corerev >= 26 */ - - /* Interrupt Control *//* 0x20 */ - struct intctrlregs intctrlregs[8]; - - u32 PAD[40]; /* 0x60 - 0xFC */ - - u32 intrcvlazy[4]; /* 0x100 - 0x10C */ - - u32 PAD[4]; /* 0x110 - 0x11c */ - - u32 maccontrol; /* 0x120 */ - u32 maccommand; /* 0x124 */ - u32 macintstatus; /* 0x128 */ - u32 macintmask; /* 0x12C */ - - /* Transmit Template Access */ - u32 tplatewrptr; /* 0x130 */ - u32 tplatewrdata; /* 0x134 */ - u32 PAD[2]; /* 0x138 - 0x13C */ - - /* PMQ registers */ - union pmqreg pmqreg; /* 0x140 */ - u32 pmqpatl; /* 0x144 */ - u32 pmqpath; /* 0x148 */ - u32 PAD; /* 0x14C */ - - u32 chnstatus; /* 0x150 */ - u32 psmdebug; /* 0x154 */ - u32 phydebug; /* 0x158 */ - u32 machwcap; /* 0x15C */ - - /* Extended Internal Objects */ - u32 objaddr; /* 0x160 */ - u32 objdata; /* 0x164 */ - u32 PAD[2]; /* 0x168 - 0x16c */ - - u32 frmtxstatus; /* 0x170 */ - u32 frmtxstatus2; /* 0x174 */ - u32 PAD[2]; /* 0x178 - 0x17c */ - - /* TSF host access */ - u32 tsf_timerlow; /* 0x180 */ - u32 tsf_timerhigh; /* 0x184 */ - u32 tsf_cfprep; /* 0x188 */ - u32 tsf_cfpstart; /* 0x18c */ - u32 tsf_cfpmaxdur32; /* 0x190 */ - u32 PAD[3]; /* 0x194 - 0x19c */ - - u32 maccontrol1; /* 0x1a0 */ - u32 machwcap1; /* 0x1a4 */ - u32 PAD[14]; /* 0x1a8 - 0x1dc */ - - /* Clock control and hardware workarounds*/ - u32 clk_ctl_st; /* 0x1e0 */ - u32 hw_war; - u32 d11_phypllctl; /* the phypll request/avail bits are - * moved to clk_ctl_st - */ - u32 PAD[5]; /* 0x1ec - 0x1fc */ - - /* 0x200-0x37F dma/pio registers */ - struct fifo64 fifo64regs[6]; - - /* FIFO diagnostic port access */ - struct dma32diag dmafifo; /* 0x380 - 0x38C */ - - u32 aggfifocnt; /* 0x390 */ - u32 aggfifodata; /* 0x394 */ - u32 PAD[16]; /* 0x398 - 0x3d4 */ - u16 radioregaddr; /* 0x3d8 */ - u16 radioregdata; /* 0x3da */ - - /* - * time delay between the change on rf disable input and - * radio shutdown - */ - u32 rfdisabledly; /* 0x3DC */ - - /* PHY register access */ - u16 phyversion; /* 0x3e0 - 0x0 */ - u16 phybbconfig; /* 0x3e2 - 0x1 */ - u16 phyadcbias; /* 0x3e4 - 0x2 Bphy only */ - u16 phyanacore; /* 0x3e6 - 0x3 pwwrdwn on aphy */ - u16 phyrxstatus0; /* 0x3e8 - 0x4 */ - u16 phyrxstatus1; /* 0x3ea - 0x5 */ - u16 phycrsth; /* 0x3ec - 0x6 */ - u16 phytxerror; /* 0x3ee - 0x7 */ - u16 phychannel; /* 0x3f0 - 0x8 */ - u16 PAD[1]; /* 0x3f2 - 0x9 */ - u16 phytest; /* 0x3f4 - 0xa */ - u16 phy4waddr; /* 0x3f6 - 0xb */ - u16 phy4wdatahi; /* 0x3f8 - 0xc */ - u16 phy4wdatalo; /* 0x3fa - 0xd */ - u16 phyregaddr; /* 0x3fc - 0xe */ - u16 phyregdata; /* 0x3fe - 0xf */ - - /* IHR *//* 0x400 - 0x7FE */ - - /* RXE Block */ - u16 PAD[3]; /* 0x400 - 0x406 */ - u16 rcv_fifo_ctl; /* 0x406 */ - u16 PAD; /* 0x408 - 0x40a */ - u16 rcv_frm_cnt; /* 0x40a */ - u16 PAD[4]; /* 0x40a - 0x414 */ - u16 rssi; /* 0x414 */ - u16 PAD[5]; /* 0x414 - 0x420 */ - u16 rcm_ctl; /* 0x420 */ - u16 rcm_mat_data; /* 0x422 */ - u16 rcm_mat_mask; /* 0x424 */ - u16 rcm_mat_dly; /* 0x426 */ - u16 rcm_cond_mask_l; /* 0x428 */ - u16 rcm_cond_mask_h; /* 0x42A */ - u16 rcm_cond_dly; /* 0x42C */ - u16 PAD[1]; /* 0x42E */ - u16 ext_ihr_addr; /* 0x430 */ - u16 ext_ihr_data; /* 0x432 */ - u16 rxe_phyrs_2; /* 0x434 */ - u16 rxe_phyrs_3; /* 0x436 */ - u16 phy_mode; /* 0x438 */ - u16 rcmta_ctl; /* 0x43a */ - u16 rcmta_size; /* 0x43c */ - u16 rcmta_addr0; /* 0x43e */ - u16 rcmta_addr1; /* 0x440 */ - u16 rcmta_addr2; /* 0x442 */ - u16 PAD[30]; /* 0x444 - 0x480 */ - - /* PSM Block *//* 0x480 - 0x500 */ - - u16 PAD; /* 0x480 */ - u16 psm_maccontrol_h; /* 0x482 */ - u16 psm_macintstatus_l; /* 0x484 */ - u16 psm_macintstatus_h; /* 0x486 */ - u16 psm_macintmask_l; /* 0x488 */ - u16 psm_macintmask_h; /* 0x48A */ - u16 PAD; /* 0x48C */ - u16 psm_maccommand; /* 0x48E */ - u16 psm_brc; /* 0x490 */ - u16 psm_phy_hdr_param; /* 0x492 */ - u16 psm_postcard; /* 0x494 */ - u16 psm_pcard_loc_l; /* 0x496 */ - u16 psm_pcard_loc_h; /* 0x498 */ - u16 psm_gpio_in; /* 0x49A */ - u16 psm_gpio_out; /* 0x49C */ - u16 psm_gpio_oe; /* 0x49E */ - - u16 psm_bred_0; /* 0x4A0 */ - u16 psm_bred_1; /* 0x4A2 */ - u16 psm_bred_2; /* 0x4A4 */ - u16 psm_bred_3; /* 0x4A6 */ - u16 psm_brcl_0; /* 0x4A8 */ - u16 psm_brcl_1; /* 0x4AA */ - u16 psm_brcl_2; /* 0x4AC */ - u16 psm_brcl_3; /* 0x4AE */ - u16 psm_brpo_0; /* 0x4B0 */ - u16 psm_brpo_1; /* 0x4B2 */ - u16 psm_brpo_2; /* 0x4B4 */ - u16 psm_brpo_3; /* 0x4B6 */ - u16 psm_brwk_0; /* 0x4B8 */ - u16 psm_brwk_1; /* 0x4BA */ - u16 psm_brwk_2; /* 0x4BC */ - u16 psm_brwk_3; /* 0x4BE */ - - u16 psm_base_0; /* 0x4C0 */ - u16 psm_base_1; /* 0x4C2 */ - u16 psm_base_2; /* 0x4C4 */ - u16 psm_base_3; /* 0x4C6 */ - u16 psm_base_4; /* 0x4C8 */ - u16 psm_base_5; /* 0x4CA */ - u16 psm_base_6; /* 0x4CC */ - u16 psm_pc_reg_0; /* 0x4CE */ - u16 psm_pc_reg_1; /* 0x4D0 */ - u16 psm_pc_reg_2; /* 0x4D2 */ - u16 psm_pc_reg_3; /* 0x4D4 */ - u16 PAD[0xD]; /* 0x4D6 - 0x4DE */ - u16 psm_corectlsts; /* 0x4f0 *//* Corerev >= 13 */ - u16 PAD[0x7]; /* 0x4f2 - 0x4fE */ - - /* TXE0 Block *//* 0x500 - 0x580 */ - u16 txe_ctl; /* 0x500 */ - u16 txe_aux; /* 0x502 */ - u16 txe_ts_loc; /* 0x504 */ - u16 txe_time_out; /* 0x506 */ - u16 txe_wm_0; /* 0x508 */ - u16 txe_wm_1; /* 0x50A */ - u16 txe_phyctl; /* 0x50C */ - u16 txe_status; /* 0x50E */ - u16 txe_mmplcp0; /* 0x510 */ - u16 txe_mmplcp1; /* 0x512 */ - u16 txe_phyctl1; /* 0x514 */ - - u16 PAD[0x05]; /* 0x510 - 0x51E */ - - /* Transmit control */ - u16 xmtfifodef; /* 0x520 */ - u16 xmtfifo_frame_cnt; /* 0x522 *//* Corerev >= 16 */ - u16 xmtfifo_byte_cnt; /* 0x524 *//* Corerev >= 16 */ - u16 xmtfifo_head; /* 0x526 *//* Corerev >= 16 */ - u16 xmtfifo_rd_ptr; /* 0x528 *//* Corerev >= 16 */ - u16 xmtfifo_wr_ptr; /* 0x52A *//* Corerev >= 16 */ - u16 xmtfifodef1; /* 0x52C *//* Corerev >= 16 */ - - u16 PAD[0x09]; /* 0x52E - 0x53E */ - - u16 xmtfifocmd; /* 0x540 */ - u16 xmtfifoflush; /* 0x542 */ - u16 xmtfifothresh; /* 0x544 */ - u16 xmtfifordy; /* 0x546 */ - u16 xmtfifoprirdy; /* 0x548 */ - u16 xmtfiforqpri; /* 0x54A */ - u16 xmttplatetxptr; /* 0x54C */ - u16 PAD; /* 0x54E */ - u16 xmttplateptr; /* 0x550 */ - u16 smpl_clct_strptr; /* 0x552 *//* Corerev >= 22 */ - u16 smpl_clct_stpptr; /* 0x554 *//* Corerev >= 22 */ - u16 smpl_clct_curptr; /* 0x556 *//* Corerev >= 22 */ - u16 PAD[0x04]; /* 0x558 - 0x55E */ - u16 xmttplatedatalo; /* 0x560 */ - u16 xmttplatedatahi; /* 0x562 */ - - u16 PAD[2]; /* 0x564 - 0x566 */ - - u16 xmtsel; /* 0x568 */ - u16 xmttxcnt; /* 0x56A */ - u16 xmttxshmaddr; /* 0x56C */ - - u16 PAD[0x09]; /* 0x56E - 0x57E */ - - /* TXE1 Block */ - u16 PAD[0x40]; /* 0x580 - 0x5FE */ - - /* TSF Block */ - u16 PAD[0X02]; /* 0x600 - 0x602 */ - u16 tsf_cfpstrt_l; /* 0x604 */ - u16 tsf_cfpstrt_h; /* 0x606 */ - u16 PAD[0X05]; /* 0x608 - 0x610 */ - u16 tsf_cfppretbtt; /* 0x612 */ - u16 PAD[0XD]; /* 0x614 - 0x62C */ - u16 tsf_clk_frac_l; /* 0x62E */ - u16 tsf_clk_frac_h; /* 0x630 */ - u16 PAD[0X14]; /* 0x632 - 0x658 */ - u16 tsf_random; /* 0x65A */ - u16 PAD[0x05]; /* 0x65C - 0x664 */ - /* GPTimer 2 registers */ - u16 tsf_gpt2_stat; /* 0x666 */ - u16 tsf_gpt2_ctr_l; /* 0x668 */ - u16 tsf_gpt2_ctr_h; /* 0x66A */ - u16 tsf_gpt2_val_l; /* 0x66C */ - u16 tsf_gpt2_val_h; /* 0x66E */ - u16 tsf_gptall_stat; /* 0x670 */ - u16 PAD[0x07]; /* 0x672 - 0x67E */ - - /* IFS Block */ - u16 ifs_sifs_rx_tx_tx; /* 0x680 */ - u16 ifs_sifs_nav_tx; /* 0x682 */ - u16 ifs_slot; /* 0x684 */ - u16 PAD; /* 0x686 */ - u16 ifs_ctl; /* 0x688 */ - u16 PAD[0x3]; /* 0x68a - 0x68F */ - u16 ifsstat; /* 0x690 */ - u16 ifsmedbusyctl; /* 0x692 */ - u16 iftxdur; /* 0x694 */ - u16 PAD[0x3]; /* 0x696 - 0x69b */ - /* EDCF support in dot11macs */ - u16 ifs_aifsn; /* 0x69c */ - u16 ifs_ctl1; /* 0x69e */ - - /* slow clock registers */ - u16 scc_ctl; /* 0x6a0 */ - u16 scc_timer_l; /* 0x6a2 */ - u16 scc_timer_h; /* 0x6a4 */ - u16 scc_frac; /* 0x6a6 */ - u16 scc_fastpwrup_dly; /* 0x6a8 */ - u16 scc_per; /* 0x6aa */ - u16 scc_per_frac; /* 0x6ac */ - u16 scc_cal_timer_l; /* 0x6ae */ - u16 scc_cal_timer_h; /* 0x6b0 */ - u16 PAD; /* 0x6b2 */ - - u16 PAD[0x26]; - - /* NAV Block */ - u16 nav_ctl; /* 0x700 */ - u16 navstat; /* 0x702 */ - u16 PAD[0x3e]; /* 0x702 - 0x77E */ - - /* WEP/PMQ Block *//* 0x780 - 0x7FE */ - u16 PAD[0x20]; /* 0x780 - 0x7BE */ - - u16 wepctl; /* 0x7C0 */ - u16 wepivloc; /* 0x7C2 */ - u16 wepivkey; /* 0x7C4 */ - u16 wepwkey; /* 0x7C6 */ - - u16 PAD[4]; /* 0x7C8 - 0x7CE */ - u16 pcmctl; /* 0X7D0 */ - u16 pcmstat; /* 0X7D2 */ - u16 PAD[6]; /* 0x7D4 - 0x7DE */ - - u16 pmqctl; /* 0x7E0 */ - u16 pmqstatus; /* 0x7E2 */ - u16 pmqpat0; /* 0x7E4 */ - u16 pmqpat1; /* 0x7E6 */ - u16 pmqpat2; /* 0x7E8 */ - - u16 pmqdat; /* 0x7EA */ - u16 pmqdator; /* 0x7EC */ - u16 pmqhst; /* 0x7EE */ - u16 pmqpath0; /* 0x7F0 */ - u16 pmqpath1; /* 0x7F2 */ - u16 pmqpath2; /* 0x7F4 */ - u16 pmqdath; /* 0x7F6 */ - - u16 PAD[0x04]; /* 0x7F8 - 0x7FE */ - - /* SHM *//* 0x800 - 0xEFE */ - u16 PAD[0x380]; /* 0x800 - 0xEFE */ -}; - -#define PIHR_BASE 0x0400 /* byte address of packed IHR region */ - -/* biststatus */ -#define BT_DONE (1U << 31) /* bist done */ -#define BT_B2S (1 << 30) /* bist2 ram summary bit */ - -/* intstatus and intmask */ -#define I_PC (1 << 10) /* pci descriptor error */ -#define I_PD (1 << 11) /* pci data error */ -#define I_DE (1 << 12) /* descriptor protocol error */ -#define I_RU (1 << 13) /* receive descriptor underflow */ -#define I_RO (1 << 14) /* receive fifo overflow */ -#define I_XU (1 << 15) /* transmit fifo underflow */ -#define I_RI (1 << 16) /* receive interrupt */ -#define I_XI (1 << 24) /* transmit interrupt */ - -/* interrupt receive lazy */ -#define IRL_TO_MASK 0x00ffffff /* timeout */ -#define IRL_FC_MASK 0xff000000 /* frame count */ -#define IRL_FC_SHIFT 24 /* frame count */ - -/*== maccontrol register ==*/ -#define MCTL_GMODE (1U << 31) -#define MCTL_DISCARD_PMQ (1 << 30) -#define MCTL_WAKE (1 << 26) -#define MCTL_HPS (1 << 25) -#define MCTL_PROMISC (1 << 24) -#define MCTL_KEEPBADFCS (1 << 23) -#define MCTL_KEEPCONTROL (1 << 22) -#define MCTL_PHYLOCK (1 << 21) -#define MCTL_BCNS_PROMISC (1 << 20) -#define MCTL_LOCK_RADIO (1 << 19) -#define MCTL_AP (1 << 18) -#define MCTL_INFRA (1 << 17) -#define MCTL_BIGEND (1 << 16) -#define MCTL_GPOUT_SEL_MASK (3 << 14) -#define MCTL_GPOUT_SEL_SHIFT 14 -#define MCTL_EN_PSMDBG (1 << 13) -#define MCTL_IHR_EN (1 << 10) -#define MCTL_SHM_UPPER (1 << 9) -#define MCTL_SHM_EN (1 << 8) -#define MCTL_PSM_JMP_0 (1 << 2) -#define MCTL_PSM_RUN (1 << 1) -#define MCTL_EN_MAC (1 << 0) - -/*== maccommand register ==*/ -#define MCMD_BCN0VLD (1 << 0) -#define MCMD_BCN1VLD (1 << 1) -#define MCMD_DIRFRMQVAL (1 << 2) -#define MCMD_CCA (1 << 3) -#define MCMD_BG_NOISE (1 << 4) -#define MCMD_SKIP_SHMINIT (1 << 5) /* only used for simulation */ -#define MCMD_SAMPLECOLL MCMD_SKIP_SHMINIT /* reuse for sample collect */ - -/*== macintstatus/macintmask ==*/ -/* gracefully suspended */ -#define MI_MACSSPNDD (1 << 0) -/* beacon template available */ -#define MI_BCNTPL (1 << 1) -/* TBTT indication */ -#define MI_TBTT (1 << 2) -/* beacon successfully tx'd */ -#define MI_BCNSUCCESS (1 << 3) -/* beacon canceled (IBSS) */ -#define MI_BCNCANCLD (1 << 4) -/* end of ATIM-window (IBSS) */ -#define MI_ATIMWINEND (1 << 5) -/* PMQ entries available */ -#define MI_PMQ (1 << 6) -/* non-specific gen-stat bits that are set by PSM */ -#define MI_NSPECGEN_0 (1 << 7) -/* non-specific gen-stat bits that are set by PSM */ -#define MI_NSPECGEN_1 (1 << 8) -/* MAC level Tx error */ -#define MI_MACTXERR (1 << 9) -/* non-specific gen-stat bits that are set by PSM */ -#define MI_NSPECGEN_3 (1 << 10) -/* PHY Tx error */ -#define MI_PHYTXERR (1 << 11) -/* Power Management Event */ -#define MI_PME (1 << 12) -/* General-purpose timer0 */ -#define MI_GP0 (1 << 13) -/* General-purpose timer1 */ -#define MI_GP1 (1 << 14) -/* (ORed) DMA-interrupts */ -#define MI_DMAINT (1 << 15) -/* MAC has completed a TX FIFO Suspend/Flush */ -#define MI_TXSTOP (1 << 16) -/* MAC has completed a CCA measurement */ -#define MI_CCA (1 << 17) -/* MAC has collected background noise samples */ -#define MI_BG_NOISE (1 << 18) -/* MBSS DTIM TBTT indication */ -#define MI_DTIM_TBTT (1 << 19) -/* Probe response queue needs attention */ -#define MI_PRQ (1 << 20) -/* Radio/PHY has been powered back up. */ -#define MI_PWRUP (1 << 21) -#define MI_RESERVED3 (1 << 22) -#define MI_RESERVED2 (1 << 23) -#define MI_RESERVED1 (1 << 25) -/* MAC detected change on RF Disable input*/ -#define MI_RFDISABLE (1 << 28) -/* MAC has completed a TX */ -#define MI_TFS (1 << 29) -/* A phy status change wrt G mode */ -#define MI_PHYCHANGED (1 << 30) -/* general purpose timeout */ -#define MI_TO (1U << 31) - -/* Mac capabilities registers */ -/*== machwcap ==*/ -#define MCAP_TKIPMIC 0x80000000 /* TKIP MIC hardware present */ - -/*== pmqhost data ==*/ -/* data entry of head pmq entry */ -#define PMQH_DATA_MASK 0xffff0000 -/* PM entry for BSS config */ -#define PMQH_BSSCFG 0x00100000 -/* PM Mode OFF: power save off */ -#define PMQH_PMOFF 0x00010000 -/* PM Mode ON: power save on */ -#define PMQH_PMON 0x00020000 -/* Dis-associated or De-authenticated */ -#define PMQH_DASAT 0x00040000 -/* ATIM not acknowledged */ -#define PMQH_ATIMFAIL 0x00080000 -/* delete head entry */ -#define PMQH_DEL_ENTRY 0x00000001 -/* delete head entry to cur read pointer -1 */ -#define PMQH_DEL_MULT 0x00000002 -/* pmq overflow indication */ -#define PMQH_OFLO 0x00000004 -/* entries are present in pmq */ -#define PMQH_NOT_EMPTY 0x00000008 - -/*== phydebug ==*/ -/* phy is asserting carrier sense */ -#define PDBG_CRS (1 << 0) -/* phy is taking xmit byte from mac this cycle */ -#define PDBG_TXA (1 << 1) -/* mac is instructing the phy to transmit a frame */ -#define PDBG_TXF (1 << 2) -/* phy is signalling a transmit Error to the mac */ -#define PDBG_TXE (1 << 3) -/* phy detected the end of a valid frame preamble */ -#define PDBG_RXF (1 << 4) -/* phy detected the end of a valid PLCP header */ -#define PDBG_RXS (1 << 5) -/* rx start not asserted */ -#define PDBG_RXFRG (1 << 6) -/* mac is taking receive byte from phy this cycle */ -#define PDBG_RXV (1 << 7) -/* RF portion of the radio is disabled */ -#define PDBG_RFD (1 << 16) - -/*== objaddr register ==*/ -#define OBJADDR_SEL_MASK 0x000F0000 -#define OBJADDR_UCM_SEL 0x00000000 -#define OBJADDR_SHM_SEL 0x00010000 -#define OBJADDR_SCR_SEL 0x00020000 -#define OBJADDR_IHR_SEL 0x00030000 -#define OBJADDR_RCMTA_SEL 0x00040000 -#define OBJADDR_SRCHM_SEL 0x00060000 -#define OBJADDR_WINC 0x01000000 -#define OBJADDR_RINC 0x02000000 -#define OBJADDR_AUTO_INC 0x03000000 - -#define WEP_PCMADDR 0x07d4 -#define WEP_PCMDATA 0x07d6 - -/*== frmtxstatus ==*/ -#define TXS_V (1 << 0) /* valid bit */ -#define TXS_STATUS_MASK 0xffff -#define TXS_FID_MASK 0xffff0000 -#define TXS_FID_SHIFT 16 - -/*== frmtxstatus2 ==*/ -#define TXS_SEQ_MASK 0xffff -#define TXS_PTX_MASK 0xff0000 -#define TXS_PTX_SHIFT 16 -#define TXS_MU_MASK 0x01000000 -#define TXS_MU_SHIFT 24 - -/*== clk_ctl_st ==*/ -#define CCS_ERSRC_REQ_D11PLL 0x00000100 /* d11 core pll request */ -#define CCS_ERSRC_REQ_PHYPLL 0x00000200 /* PHY pll request */ -#define CCS_ERSRC_AVAIL_D11PLL 0x01000000 /* d11 core pll available */ -#define CCS_ERSRC_AVAIL_PHYPLL 0x02000000 /* PHY pll available */ - -/* HT Cloclk Ctrl and Clock Avail for 4313 */ -#define CCS_ERSRC_REQ_HT 0x00000010 /* HT avail request */ -#define CCS_ERSRC_AVAIL_HT 0x00020000 /* HT clock available */ - -/* tsf_cfprep register */ -#define CFPREP_CBI_MASK 0xffffffc0 -#define CFPREP_CBI_SHIFT 6 -#define CFPREP_CFPP 0x00000001 - -/* tx fifo sizes values are in terms of 256 byte blocks */ -#define TXFIFOCMD_RESET_MASK (1 << 15) /* reset */ -#define TXFIFOCMD_FIFOSEL_SHIFT 8 /* fifo */ -#define TXFIFO_FIFOTOP_SHIFT 8 /* fifo start */ - -#define TXFIFO_START_BLK16 65 /* Base address + 32 * 512 B/P */ -#define TXFIFO_START_BLK 6 /* Base address + 6 * 256 B */ -#define TXFIFO_SIZE_UNIT 256 /* one unit corresponds to 256 bytes */ -#define MBSS16_TEMPLMEM_MINBLKS 65 /* one unit corresponds to 256 bytes */ - -/*== phy versions (PhyVersion:Revision field) ==*/ -/* analog block version */ -#define PV_AV_MASK 0xf000 -/* analog block version bitfield offset */ -#define PV_AV_SHIFT 12 -/* phy type */ -#define PV_PT_MASK 0x0f00 -/* phy type bitfield offset */ -#define PV_PT_SHIFT 8 -/* phy version */ -#define PV_PV_MASK 0x000f -#define PHY_TYPE(v) ((v & PV_PT_MASK) >> PV_PT_SHIFT) - -/*== phy types (PhyVersion:PhyType field) ==*/ -#define PHY_TYPE_N 4 /* N-Phy value */ -#define PHY_TYPE_SSN 6 /* SSLPN-Phy value */ -#define PHY_TYPE_LCN 8 /* LCN-Phy value */ -#define PHY_TYPE_LCNXN 9 /* LCNXN-Phy value */ -#define PHY_TYPE_NULL 0xf /* Invalid Phy value */ - -/*== analog types (PhyVersion:AnalogType field) ==*/ -#define ANA_11N_013 5 - -/* 802.11a PLCP header def */ -struct ofdm_phy_hdr { - u8 rlpt[3]; /* rate, length, parity, tail */ - u16 service; - u8 pad; -} __packed; - -#define D11A_PHY_HDR_GRATE(phdr) ((phdr)->rlpt[0] & 0x0f) -#define D11A_PHY_HDR_GRES(phdr) (((phdr)->rlpt[0] >> 4) & 0x01) -#define D11A_PHY_HDR_GLENGTH(phdr) (((u32 *)((phdr)->rlpt) >> 5) & 0x0fff) -#define D11A_PHY_HDR_GPARITY(phdr) (((phdr)->rlpt[3] >> 1) & 0x01) -#define D11A_PHY_HDR_GTAIL(phdr) (((phdr)->rlpt[3] >> 2) & 0x3f) - -/* rate encoded per 802.11a-1999 sec 17.3.4.1 */ -#define D11A_PHY_HDR_SRATE(phdr, rate) \ - ((phdr)->rlpt[0] = ((phdr)->rlpt[0] & 0xf0) | ((rate) & 0xf)) -/* set reserved field to zero */ -#define D11A_PHY_HDR_SRES(phdr) ((phdr)->rlpt[0] &= 0xef) -/* length is number of octets in PSDU */ -#define D11A_PHY_HDR_SLENGTH(phdr, length) \ - (*(u32 *)((phdr)->rlpt) = *(u32 *)((phdr)->rlpt) | \ - (((length) & 0x0fff) << 5)) -/* set the tail to all zeros */ -#define D11A_PHY_HDR_STAIL(phdr) ((phdr)->rlpt[3] &= 0x03) - -#define D11A_PHY_HDR_LEN_L 3 /* low-rate part of PLCP header */ -#define D11A_PHY_HDR_LEN_R 2 /* high-rate part of PLCP header */ - -#define D11A_PHY_TX_DELAY (2) /* 2.1 usec */ - -#define D11A_PHY_HDR_TIME (4) /* low-rate part of PLCP header */ -#define D11A_PHY_PRE_TIME (16) -#define D11A_PHY_PREHDR_TIME (D11A_PHY_PRE_TIME + D11A_PHY_HDR_TIME) - -/* 802.11b PLCP header def */ -struct cck_phy_hdr { - u8 signal; - u8 service; - u16 length; - u16 crc; -} __packed; - -#define D11B_PHY_HDR_LEN 6 - -#define D11B_PHY_TX_DELAY (3) /* 3.4 usec */ - -#define D11B_PHY_LHDR_TIME (D11B_PHY_HDR_LEN << 3) -#define D11B_PHY_LPRE_TIME (144) -#define D11B_PHY_LPREHDR_TIME (D11B_PHY_LPRE_TIME + D11B_PHY_LHDR_TIME) - -#define D11B_PHY_SHDR_TIME (D11B_PHY_LHDR_TIME >> 1) -#define D11B_PHY_SPRE_TIME (D11B_PHY_LPRE_TIME >> 1) -#define D11B_PHY_SPREHDR_TIME (D11B_PHY_SPRE_TIME + D11B_PHY_SHDR_TIME) - -#define D11B_PLCP_SIGNAL_LOCKED (1 << 2) -#define D11B_PLCP_SIGNAL_LE (1 << 7) - -#define MIMO_PLCP_MCS_MASK 0x7f /* mcs index */ -#define MIMO_PLCP_40MHZ 0x80 /* 40 Hz frame */ -#define MIMO_PLCP_AMPDU 0x08 /* ampdu */ - -#define BRCMS_GET_CCK_PLCP_LEN(plcp) (plcp[4] + (plcp[5] << 8)) -#define BRCMS_GET_MIMO_PLCP_LEN(plcp) (plcp[1] + (plcp[2] << 8)) -#define BRCMS_SET_MIMO_PLCP_LEN(plcp, len) \ - do { \ - plcp[1] = len & 0xff; \ - plcp[2] = ((len >> 8) & 0xff); \ - } while (0); - -#define BRCMS_SET_MIMO_PLCP_AMPDU(plcp) (plcp[3] |= MIMO_PLCP_AMPDU) -#define BRCMS_CLR_MIMO_PLCP_AMPDU(plcp) (plcp[3] &= ~MIMO_PLCP_AMPDU) -#define BRCMS_IS_MIMO_PLCP_AMPDU(plcp) (plcp[3] & MIMO_PLCP_AMPDU) - -/* - * The dot11a PLCP header is 5 bytes. To simplify the software (so that we - * don't need e.g. different tx DMA headers for 11a and 11b), the PLCP header - * has padding added in the ucode. - */ -#define D11_PHY_HDR_LEN 6 - -/* TX DMA buffer header */ -struct d11txh { - __le16 MacTxControlLow; /* 0x0 */ - __le16 MacTxControlHigh; /* 0x1 */ - __le16 MacFrameControl; /* 0x2 */ - __le16 TxFesTimeNormal; /* 0x3 */ - __le16 PhyTxControlWord; /* 0x4 */ - __le16 PhyTxControlWord_1; /* 0x5 */ - __le16 PhyTxControlWord_1_Fbr; /* 0x6 */ - __le16 PhyTxControlWord_1_Rts; /* 0x7 */ - __le16 PhyTxControlWord_1_FbrRts; /* 0x8 */ - __le16 MainRates; /* 0x9 */ - __le16 XtraFrameTypes; /* 0xa */ - u8 IV[16]; /* 0x0b - 0x12 */ - u8 TxFrameRA[6]; /* 0x13 - 0x15 */ - __le16 TxFesTimeFallback; /* 0x16 */ - u8 RTSPLCPFallback[6]; /* 0x17 - 0x19 */ - __le16 RTSDurFallback; /* 0x1a */ - u8 FragPLCPFallback[6]; /* 0x1b - 1d */ - __le16 FragDurFallback; /* 0x1e */ - __le16 MModeLen; /* 0x1f */ - __le16 MModeFbrLen; /* 0x20 */ - __le16 TstampLow; /* 0x21 */ - __le16 TstampHigh; /* 0x22 */ - __le16 ABI_MimoAntSel; /* 0x23 */ - __le16 PreloadSize; /* 0x24 */ - __le16 AmpduSeqCtl; /* 0x25 */ - __le16 TxFrameID; /* 0x26 */ - __le16 TxStatus; /* 0x27 */ - __le16 MaxNMpdus; /* 0x28 */ - __le16 MaxABytes_MRT; /* 0x29 */ - __le16 MaxABytes_FBR; /* 0x2a */ - __le16 MinMBytes; /* 0x2b */ - u8 RTSPhyHeader[D11_PHY_HDR_LEN]; /* 0x2c - 0x2e */ - struct ieee80211_rts rts_frame; /* 0x2f - 0x36 */ - u16 PAD; /* 0x37 */ -} __packed; - -#define D11_TXH_LEN 112 /* bytes */ - -/* Frame Types */ -#define FT_CCK 0 -#define FT_OFDM 1 -#define FT_HT 2 -#define FT_N 3 - -/* - * Position of MPDU inside A-MPDU; indicated with bits 10:9 - * of MacTxControlLow - */ -#define TXC_AMPDU_SHIFT 9 /* shift for ampdu settings */ -#define TXC_AMPDU_NONE 0 /* Regular MPDU, not an A-MPDU */ -#define TXC_AMPDU_FIRST 1 /* first MPDU of an A-MPDU */ -#define TXC_AMPDU_MIDDLE 2 /* intermediate MPDU of an A-MPDU */ -#define TXC_AMPDU_LAST 3 /* last (or single) MPDU of an A-MPDU */ - -/*== MacTxControlLow ==*/ -#define TXC_AMIC 0x8000 -#define TXC_SENDCTS 0x0800 -#define TXC_AMPDU_MASK 0x0600 -#define TXC_BW_40 0x0100 -#define TXC_FREQBAND_5G 0x0080 -#define TXC_DFCS 0x0040 -#define TXC_IGNOREPMQ 0x0020 -#define TXC_HWSEQ 0x0010 -#define TXC_STARTMSDU 0x0008 -#define TXC_SENDRTS 0x0004 -#define TXC_LONGFRAME 0x0002 -#define TXC_IMMEDACK 0x0001 - -/*== MacTxControlHigh ==*/ -/* RTS fallback preamble type 1 = SHORT 0 = LONG */ -#define TXC_PREAMBLE_RTS_FB_SHORT 0x8000 -/* RTS main rate preamble type 1 = SHORT 0 = LONG */ -#define TXC_PREAMBLE_RTS_MAIN_SHORT 0x4000 -/* - * Main fallback rate preamble type - * 1 = SHORT for OFDM/GF for MIMO - * 0 = LONG for CCK/MM for MIMO - */ -#define TXC_PREAMBLE_DATA_FB_SHORT 0x2000 - -/* TXC_PREAMBLE_DATA_MAIN is in PhyTxControl bit 5 */ -/* use fallback rate for this AMPDU */ -#define TXC_AMPDU_FBR 0x1000 -#define TXC_SECKEY_MASK 0x0FF0 -#define TXC_SECKEY_SHIFT 4 -/* Use alternate txpwr defined at loc. M_ALT_TXPWR_IDX */ -#define TXC_ALT_TXPWR 0x0008 -#define TXC_SECTYPE_MASK 0x0007 -#define TXC_SECTYPE_SHIFT 0 - -/* Null delimiter for Fallback rate */ -#define AMPDU_FBR_NULL_DELIM 5 /* Location of Null delimiter count for AMPDU */ - -/* PhyTxControl for Mimophy */ -#define PHY_TXC_PWR_MASK 0xFC00 -#define PHY_TXC_PWR_SHIFT 10 -#define PHY_TXC_ANT_MASK 0x03C0 /* bit 6, 7, 8, 9 */ -#define PHY_TXC_ANT_SHIFT 6 -#define PHY_TXC_ANT_0_1 0x00C0 /* auto, last rx */ -#define PHY_TXC_LCNPHY_ANT_LAST 0x0000 -#define PHY_TXC_ANT_3 0x0200 /* virtual antenna 3 */ -#define PHY_TXC_ANT_2 0x0100 /* virtual antenna 2 */ -#define PHY_TXC_ANT_1 0x0080 /* virtual antenna 1 */ -#define PHY_TXC_ANT_0 0x0040 /* virtual antenna 0 */ -#define PHY_TXC_SHORT_HDR 0x0010 - -#define PHY_TXC_OLD_ANT_0 0x0000 -#define PHY_TXC_OLD_ANT_1 0x0100 -#define PHY_TXC_OLD_ANT_LAST 0x0300 - -/* PhyTxControl_1 for Mimophy */ -#define PHY_TXC1_BW_MASK 0x0007 -#define PHY_TXC1_BW_10MHZ 0 -#define PHY_TXC1_BW_10MHZ_UP 1 -#define PHY_TXC1_BW_20MHZ 2 -#define PHY_TXC1_BW_20MHZ_UP 3 -#define PHY_TXC1_BW_40MHZ 4 -#define PHY_TXC1_BW_40MHZ_DUP 5 -#define PHY_TXC1_MODE_SHIFT 3 -#define PHY_TXC1_MODE_MASK 0x0038 -#define PHY_TXC1_MODE_SISO 0 -#define PHY_TXC1_MODE_CDD 1 -#define PHY_TXC1_MODE_STBC 2 -#define PHY_TXC1_MODE_SDM 3 - -/* PhyTxControl for HTphy that are different from Mimophy */ -#define PHY_TXC_HTANT_MASK 0x3fC0 /* bits 6-13 */ - -/* XtraFrameTypes */ -#define XFTS_RTS_FT_SHIFT 2 -#define XFTS_FBRRTS_FT_SHIFT 4 -#define XFTS_CHANNEL_SHIFT 8 - -/* Antenna diversity bit in ant_wr_settle */ -#define PHY_AWS_ANTDIV 0x2000 - -/* IFS ctl */ -#define IFS_USEEDCF (1 << 2) - -/* IFS ctl1 */ -#define IFS_CTL1_EDCRS (1 << 3) -#define IFS_CTL1_EDCRS_20L (1 << 4) -#define IFS_CTL1_EDCRS_40 (1 << 5) - -/* ABI_MimoAntSel */ -#define ABI_MAS_ADDR_BMP_IDX_MASK 0x0f00 -#define ABI_MAS_ADDR_BMP_IDX_SHIFT 8 -#define ABI_MAS_FBR_ANT_PTN_MASK 0x00f0 -#define ABI_MAS_FBR_ANT_PTN_SHIFT 4 -#define ABI_MAS_MRT_ANT_PTN_MASK 0x000f - -/* tx status packet */ -struct tx_status { - u16 framelen; - u16 PAD; - u16 frameid; - u16 status; - u16 lasttxtime; - u16 sequence; - u16 phyerr; - u16 ackphyrxsh; -} __packed; - -#define TXSTATUS_LEN 16 - -/* status field bit definitions */ -#define TX_STATUS_FRM_RTX_MASK 0xF000 -#define TX_STATUS_FRM_RTX_SHIFT 12 -#define TX_STATUS_RTS_RTX_MASK 0x0F00 -#define TX_STATUS_RTS_RTX_SHIFT 8 -#define TX_STATUS_MASK 0x00FE -#define TX_STATUS_PMINDCTD (1 << 7) /* PM mode indicated to AP */ -#define TX_STATUS_INTERMEDIATE (1 << 6) /* intermediate or 1st ampdu pkg */ -#define TX_STATUS_AMPDU (1 << 5) /* AMPDU status */ -#define TX_STATUS_SUPR_MASK 0x1C /* suppress status bits (4:2) */ -#define TX_STATUS_SUPR_SHIFT 2 -#define TX_STATUS_ACK_RCV (1 << 1) /* ACK received */ -#define TX_STATUS_VALID (1 << 0) /* Tx status valid */ -#define TX_STATUS_NO_ACK 0 - -/* suppress status reason codes */ -#define TX_STATUS_SUPR_PMQ (1 << 2) /* PMQ entry */ -#define TX_STATUS_SUPR_FLUSH (2 << 2) /* flush request */ -#define TX_STATUS_SUPR_FRAG (3 << 2) /* previous frag failure */ -#define TX_STATUS_SUPR_TBTT (3 << 2) /* SHARED: Probe resp supr for TBTT */ -#define TX_STATUS_SUPR_BADCH (4 << 2) /* channel mismatch */ -#define TX_STATUS_SUPR_EXPTIME (5 << 2) /* lifetime expiry */ -#define TX_STATUS_SUPR_UF (6 << 2) /* underflow */ - -/* Unexpected tx status for rate update */ -#define TX_STATUS_UNEXP(status) \ - ((((status) & TX_STATUS_INTERMEDIATE) != 0) && \ - TX_STATUS_UNEXP_AMPDU(status)) - -/* Unexpected tx status for A-MPDU rate update */ -#define TX_STATUS_UNEXP_AMPDU(status) \ - ((((status) & TX_STATUS_SUPR_MASK) != 0) && \ - (((status) & TX_STATUS_SUPR_MASK) != TX_STATUS_SUPR_EXPTIME)) - -#define TX_STATUS_BA_BMAP03_MASK 0xF000 /* ba bitmap 0:3 in 1st pkg */ -#define TX_STATUS_BA_BMAP03_SHIFT 12 /* ba bitmap 0:3 in 1st pkg */ -#define TX_STATUS_BA_BMAP47_MASK 0x001E /* ba bitmap 4:7 in 2nd pkg */ -#define TX_STATUS_BA_BMAP47_SHIFT 3 /* ba bitmap 4:7 in 2nd pkg */ - -/* RXE (Receive Engine) */ - -/* RCM_CTL */ -#define RCM_INC_MASK_H 0x0080 -#define RCM_INC_MASK_L 0x0040 -#define RCM_INC_DATA 0x0020 -#define RCM_INDEX_MASK 0x001F -#define RCM_SIZE 15 - -#define RCM_MAC_OFFSET 0 /* current MAC address */ -#define RCM_BSSID_OFFSET 3 /* current BSSID address */ -#define RCM_F_BSSID_0_OFFSET 6 /* foreign BSS CFP tracking */ -#define RCM_F_BSSID_1_OFFSET 9 /* foreign BSS CFP tracking */ -#define RCM_F_BSSID_2_OFFSET 12 /* foreign BSS CFP tracking */ - -#define RCM_WEP_TA0_OFFSET 16 -#define RCM_WEP_TA1_OFFSET 19 -#define RCM_WEP_TA2_OFFSET 22 -#define RCM_WEP_TA3_OFFSET 25 - -/* PSM Block */ - -/* psm_phy_hdr_param bits */ -#define MAC_PHY_RESET 1 -#define MAC_PHY_CLOCK_EN 2 -#define MAC_PHY_FORCE_CLK 4 - -/* WEP Block */ - -/* WEP_WKEY */ -#define WKEY_START (1 << 8) -#define WKEY_SEL_MASK 0x1F - -/* WEP data formats */ - -/* the number of RCMTA entries */ -#define RCMTA_SIZE 50 - -#define M_ADDR_BMP_BLK (0x37e * 2) -#define M_ADDR_BMP_BLK_SZ 12 - -#define ADDR_BMP_RA (1 << 0) /* Receiver Address (RA) */ -#define ADDR_BMP_TA (1 << 1) /* Transmitter Address (TA) */ -#define ADDR_BMP_BSSID (1 << 2) /* BSSID */ -#define ADDR_BMP_AP (1 << 3) /* Infra-BSS Access Point */ -#define ADDR_BMP_STA (1 << 4) /* Infra-BSS Station */ -#define ADDR_BMP_RESERVED1 (1 << 5) -#define ADDR_BMP_RESERVED2 (1 << 6) -#define ADDR_BMP_RESERVED3 (1 << 7) -#define ADDR_BMP_BSS_IDX_MASK (3 << 8) /* BSS control block index */ -#define ADDR_BMP_BSS_IDX_SHIFT 8 - -#define WSEC_MAX_RCMTA_KEYS 54 - -/* max keys in M_TKMICKEYS_BLK */ -#define WSEC_MAX_TKMIC_ENGINE_KEYS 12 /* 8 + 4 default */ - -/* max RXE match registers */ -#define WSEC_MAX_RXE_KEYS 4 - -/* SECKINDXALGO (Security Key Index & Algorithm Block) word format */ -/* SKL (Security Key Lookup) */ -#define SKL_ALGO_MASK 0x0007 -#define SKL_ALGO_SHIFT 0 -#define SKL_KEYID_MASK 0x0008 -#define SKL_KEYID_SHIFT 3 -#define SKL_INDEX_MASK 0x03F0 -#define SKL_INDEX_SHIFT 4 -#define SKL_GRP_ALGO_MASK 0x1c00 -#define SKL_GRP_ALGO_SHIFT 10 - -/* additional bits defined for IBSS group key support */ -#define SKL_IBSS_INDEX_MASK 0x01F0 -#define SKL_IBSS_INDEX_SHIFT 4 -#define SKL_IBSS_KEYID1_MASK 0x0600 -#define SKL_IBSS_KEYID1_SHIFT 9 -#define SKL_IBSS_KEYID2_MASK 0x1800 -#define SKL_IBSS_KEYID2_SHIFT 11 -#define SKL_IBSS_KEYALGO_MASK 0xE000 -#define SKL_IBSS_KEYALGO_SHIFT 13 - -#define WSEC_MODE_OFF 0 -#define WSEC_MODE_HW 1 -#define WSEC_MODE_SW 2 - -#define WSEC_ALGO_OFF 0 -#define WSEC_ALGO_WEP1 1 -#define WSEC_ALGO_TKIP 2 -#define WSEC_ALGO_AES 3 -#define WSEC_ALGO_WEP128 4 -#define WSEC_ALGO_AES_LEGACY 5 -#define WSEC_ALGO_NALG 6 - -#define AES_MODE_NONE 0 -#define AES_MODE_CCM 1 - -/* WEP_CTL (Rev 0) */ -#define WECR0_KEYREG_SHIFT 0 -#define WECR0_KEYREG_MASK 0x7 -#define WECR0_DECRYPT (1 << 3) -#define WECR0_IVINLINE (1 << 4) -#define WECR0_WEPALG_SHIFT 5 -#define WECR0_WEPALG_MASK (0x7 << 5) -#define WECR0_WKEYSEL_SHIFT 8 -#define WECR0_WKEYSEL_MASK (0x7 << 8) -#define WECR0_WKEYSTART (1 << 11) -#define WECR0_WEPINIT (1 << 14) -#define WECR0_ICVERR (1 << 15) - -/* Frame template map byte offsets */ -#define T_ACTS_TPL_BASE (0) -#define T_NULL_TPL_BASE (0xc * 2) -#define T_QNULL_TPL_BASE (0x1c * 2) -#define T_RR_TPL_BASE (0x2c * 2) -#define T_BCN0_TPL_BASE (0x34 * 2) -#define T_PRS_TPL_BASE (0x134 * 2) -#define T_BCN1_TPL_BASE (0x234 * 2) -#define T_TX_FIFO_TXRAM_BASE (T_ACTS_TPL_BASE + \ - (TXFIFO_START_BLK * TXFIFO_SIZE_UNIT)) - -#define T_BA_TPL_BASE T_QNULL_TPL_BASE /* template area for BA */ - -#define T_RAM_ACCESS_SZ 4 /* template ram is 4 byte access only */ - -/* Shared Mem byte offsets */ - -/* Location where the ucode expects the corerev */ -#define M_MACHW_VER (0x00b * 2) - -/* Location where the ucode expects the MAC capabilities */ -#define M_MACHW_CAP_L (0x060 * 2) -#define M_MACHW_CAP_H (0x061 * 2) - -/* WME shared memory */ -#define M_EDCF_STATUS_OFF (0x007 * 2) -#define M_TXF_CUR_INDEX (0x018 * 2) -#define M_EDCF_QINFO (0x120 * 2) - -/* PS-mode related parameters */ -#define M_DOT11_SLOT (0x008 * 2) -#define M_DOT11_DTIMPERIOD (0x009 * 2) -#define M_NOSLPZNATDTIM (0x026 * 2) - -/* Beacon-related parameters */ -#define M_BCN0_FRM_BYTESZ (0x00c * 2) /* Bcn 0 template length */ -#define M_BCN1_FRM_BYTESZ (0x00d * 2) /* Bcn 1 template length */ -#define M_BCN_TXTSF_OFFSET (0x00e * 2) -#define M_TIMBPOS_INBEACON (0x00f * 2) -#define M_SFRMTXCNTFBRTHSD (0x022 * 2) -#define M_LFRMTXCNTFBRTHSD (0x023 * 2) -#define M_BCN_PCTLWD (0x02a * 2) -#define M_BCN_LI (0x05b * 2) /* beacon listen interval */ - -/* MAX Rx Frame len */ -#define M_MAXRXFRM_LEN (0x010 * 2) - -/* ACK/CTS related params */ -#define M_RSP_PCTLWD (0x011 * 2) - -/* Hardware Power Control */ -#define M_TXPWR_N (0x012 * 2) -#define M_TXPWR_TARGET (0x013 * 2) -#define M_TXPWR_MAX (0x014 * 2) -#define M_TXPWR_CUR (0x019 * 2) - -/* Rx-related parameters */ -#define M_RX_PAD_DATA_OFFSET (0x01a * 2) - -/* WEP Shared mem data */ -#define M_SEC_DEFIVLOC (0x01e * 2) -#define M_SEC_VALNUMSOFTMCHTA (0x01f * 2) -#define M_PHYVER (0x028 * 2) -#define M_PHYTYPE (0x029 * 2) -#define M_SECRXKEYS_PTR (0x02b * 2) -#define M_TKMICKEYS_PTR (0x059 * 2) -#define M_SECKINDXALGO_BLK (0x2ea * 2) -#define M_SECKINDXALGO_BLK_SZ 54 -#define M_SECPSMRXTAMCH_BLK (0x2fa * 2) -#define M_TKIP_TSC_TTAK (0x18c * 2) -#define D11_MAX_KEY_SIZE 16 - -#define M_MAX_ANTCNT (0x02e * 2) /* antenna swap threshold */ - -/* Probe response related parameters */ -#define M_SSIDLEN (0x024 * 2) -#define M_PRB_RESP_FRM_LEN (0x025 * 2) -#define M_PRS_MAXTIME (0x03a * 2) -#define M_SSID (0xb0 * 2) -#define M_CTXPRS_BLK (0xc0 * 2) -#define C_CTX_PCTLWD_POS (0x4 * 2) - -/* Delta between OFDM and CCK power in CCK power boost mode */ -#define M_OFDM_OFFSET (0x027 * 2) - -/* TSSI for last 4 11b/g CCK packets transmitted */ -#define M_B_TSSI_0 (0x02c * 2) -#define M_B_TSSI_1 (0x02d * 2) - -/* Host flags to turn on ucode options */ -#define M_HOST_FLAGS1 (0x02f * 2) -#define M_HOST_FLAGS2 (0x030 * 2) -#define M_HOST_FLAGS3 (0x031 * 2) -#define M_HOST_FLAGS4 (0x03c * 2) -#define M_HOST_FLAGS5 (0x06a * 2) -#define M_HOST_FLAGS_SZ 16 - -#define M_RADAR_REG (0x033 * 2) - -/* TSSI for last 4 11a OFDM packets transmitted */ -#define M_A_TSSI_0 (0x034 * 2) -#define M_A_TSSI_1 (0x035 * 2) - -/* noise interference measurement */ -#define M_NOISE_IF_COUNT (0x034 * 2) -#define M_NOISE_IF_TIMEOUT (0x035 * 2) - -#define M_RF_RX_SP_REG1 (0x036 * 2) - -/* TSSI for last 4 11g OFDM packets transmitted */ -#define M_G_TSSI_0 (0x038 * 2) -#define M_G_TSSI_1 (0x039 * 2) - -/* Background noise measure */ -#define M_JSSI_0 (0x44 * 2) -#define M_JSSI_1 (0x45 * 2) -#define M_JSSI_AUX (0x46 * 2) - -#define M_CUR_2050_RADIOCODE (0x47 * 2) - -/* TX fifo sizes */ -#define M_FIFOSIZE0 (0x4c * 2) -#define M_FIFOSIZE1 (0x4d * 2) -#define M_FIFOSIZE2 (0x4e * 2) -#define M_FIFOSIZE3 (0x4f * 2) -#define D11_MAX_TX_FRMS 32 /* max frames allowed in tx fifo */ - -/* Current channel number plus upper bits */ -#define M_CURCHANNEL (0x50 * 2) -#define D11_CURCHANNEL_5G 0x0100; -#define D11_CURCHANNEL_40 0x0200; -#define D11_CURCHANNEL_MAX 0x00FF; - -/* last posted frameid on the bcmc fifo */ -#define M_BCMC_FID (0x54 * 2) -#define INVALIDFID 0xffff - -/* extended beacon phyctl bytes for 11N */ -#define M_BCN_PCTL1WD (0x058 * 2) - -/* idle busy ratio to duty_cycle requirement */ -#define M_TX_IDLE_BUSY_RATIO_X_16_CCK (0x52 * 2) -#define M_TX_IDLE_BUSY_RATIO_X_16_OFDM (0x5A * 2) - -/* CW RSSI for LCNPHY */ -#define M_LCN_RSSI_0 0x1332 -#define M_LCN_RSSI_1 0x1338 -#define M_LCN_RSSI_2 0x133e -#define M_LCN_RSSI_3 0x1344 - -/* SNR for LCNPHY */ -#define M_LCN_SNR_A_0 0x1334 -#define M_LCN_SNR_B_0 0x1336 - -#define M_LCN_SNR_A_1 0x133a -#define M_LCN_SNR_B_1 0x133c - -#define M_LCN_SNR_A_2 0x1340 -#define M_LCN_SNR_B_2 0x1342 - -#define M_LCN_SNR_A_3 0x1346 -#define M_LCN_SNR_B_3 0x1348 - -#define M_LCN_LAST_RESET (81*2) -#define M_LCN_LAST_LOC (63*2) -#define M_LCNPHY_RESET_STATUS (4902) -#define M_LCNPHY_DSC_TIME (0x98d*2) -#define M_LCNPHY_RESET_CNT_DSC (0x98b*2) -#define M_LCNPHY_RESET_CNT (0x98c*2) - -/* Rate table offsets */ -#define M_RT_DIRMAP_A (0xe0 * 2) -#define M_RT_BBRSMAP_A (0xf0 * 2) -#define M_RT_DIRMAP_B (0x100 * 2) -#define M_RT_BBRSMAP_B (0x110 * 2) - -/* Rate table entry offsets */ -#define M_RT_PRS_PLCP_POS 10 -#define M_RT_PRS_DUR_POS 16 -#define M_RT_OFDM_PCTL1_POS 18 - -#define M_20IN40_IQ (0x380 * 2) - -/* SHM locations where ucode stores the current power index */ -#define M_CURR_IDX1 (0x384 * 2) -#define M_CURR_IDX2 (0x387 * 2) - -#define M_BSCALE_ANT0 (0x5e * 2) -#define M_BSCALE_ANT1 (0x5f * 2) - -/* Antenna Diversity Testing */ -#define M_MIMO_ANTSEL_RXDFLT (0x63 * 2) -#define M_ANTSEL_CLKDIV (0x61 * 2) -#define M_MIMO_ANTSEL_TXDFLT (0x64 * 2) - -#define M_MIMO_MAXSYM (0x5d * 2) -#define MIMO_MAXSYM_DEF 0x8000 /* 32k */ -#define MIMO_MAXSYM_MAX 0xffff /* 64k */ - -#define M_WATCHDOG_8TU (0x1e * 2) -#define WATCHDOG_8TU_DEF 5 -#define WATCHDOG_8TU_MAX 10 - -/* Manufacturing Test Variables */ -/* PER test mode */ -#define M_PKTENG_CTRL (0x6c * 2) -/* IFS for TX mode */ -#define M_PKTENG_IFS (0x6d * 2) -/* Lower word of tx frmcnt/rx lostcnt */ -#define M_PKTENG_FRMCNT_LO (0x6e * 2) -/* Upper word of tx frmcnt/rx lostcnt */ -#define M_PKTENG_FRMCNT_HI (0x6f * 2) - -/* Index variation in vbat ripple */ -#define M_LCN_PWR_IDX_MAX (0x67 * 2) /* highest index read by ucode */ -#define M_LCN_PWR_IDX_MIN (0x66 * 2) /* lowest index read by ucode */ - -/* M_PKTENG_CTRL bit definitions */ -#define M_PKTENG_MODE_TX 0x0001 -#define M_PKTENG_MODE_TX_RIFS 0x0004 -#define M_PKTENG_MODE_TX_CTS 0x0008 -#define M_PKTENG_MODE_RX 0x0002 -#define M_PKTENG_MODE_RX_WITH_ACK 0x0402 -#define M_PKTENG_MODE_MASK 0x0003 -/* TX frames indicated in the frmcnt reg */ -#define M_PKTENG_FRMCNT_VLD 0x0100 - -/* Sample Collect parameters (bitmap and type) */ -/* Trigger bitmap for sample collect */ -#define M_SMPL_COL_BMP (0x37d * 2) -/* Sample collect type */ -#define M_SMPL_COL_CTL (0x3b2 * 2) - -#define ANTSEL_CLKDIV_4MHZ 6 -#define MIMO_ANTSEL_BUSY 0x4000 /* bit 14 (busy) */ -#define MIMO_ANTSEL_SEL 0x8000 /* bit 15 write the value */ -#define MIMO_ANTSEL_WAIT 50 /* 50us wait */ -#define MIMO_ANTSEL_OVERRIDE 0x8000 /* flag */ - -struct shm_acparams { - u16 txop; - u16 cwmin; - u16 cwmax; - u16 cwcur; - u16 aifs; - u16 bslots; - u16 reggap; - u16 status; - u16 rsvd[8]; -} __packed; -#define M_EDCF_QLEN (16 * 2) - -#define WME_STATUS_NEWAC (1 << 8) - -/* M_HOST_FLAGS */ -#define MHFMAX 5 /* Number of valid hostflag half-word (u16) */ -#define MHF1 0 /* Hostflag 1 index */ -#define MHF2 1 /* Hostflag 2 index */ -#define MHF3 2 /* Hostflag 3 index */ -#define MHF4 3 /* Hostflag 4 index */ -#define MHF5 4 /* Hostflag 5 index */ - -/* Flags in M_HOST_FLAGS */ -/* Enable ucode antenna diversity help */ -#define MHF1_ANTDIV 0x0001 -/* Enable EDCF access control */ -#define MHF1_EDCF 0x0100 -#define MHF1_IQSWAP_WAR 0x0200 -/* Disable Slow clock request, for corerev < 11 */ -#define MHF1_FORCEFASTCLK 0x0400 - -/* Flags in M_HOST_FLAGS2 */ - -/* Flush BCMC FIFO immediately */ -#define MHF2_TXBCMC_NOW 0x0040 -/* Enable ucode/hw power control */ -#define MHF2_HWPWRCTL 0x0080 -#define MHF2_NPHY40MHZ_WAR 0x0800 - -/* Flags in M_HOST_FLAGS3 */ -/* enabled mimo antenna selection */ -#define MHF3_ANTSEL_EN 0x0001 -/* antenna selection mode: 0: 2x3, 1: 2x4 */ -#define MHF3_ANTSEL_MODE 0x0002 -#define MHF3_RESERVED1 0x0004 -#define MHF3_RESERVED2 0x0008 -#define MHF3_NPHY_MLADV_WAR 0x0010 - -/* Flags in M_HOST_FLAGS4 */ -/* force bphy Tx on core 0 (board level WAR) */ -#define MHF4_BPHY_TXCORE0 0x0080 -/* for 4313A0 FEM boards */ -#define MHF4_EXTPA_ENABLE 0x4000 - -/* Flags in M_HOST_FLAGS5 */ -#define MHF5_4313_GPIOCTRL 0x0001 -#define MHF5_RESERVED1 0x0002 -#define MHF5_RESERVED2 0x0004 -/* Radio power setting for ucode */ -#define M_RADIO_PWR (0x32 * 2) - -/* phy noise recorded by ucode right after tx */ -#define M_PHY_NOISE (0x037 * 2) -#define PHY_NOISE_MASK 0x00ff - -/* - * Receive Frame Data Header for 802.11b DCF-only frames - * - * RxFrameSize: Actual byte length of the frame data received - * PAD: padding (not used) - * PhyRxStatus_0: PhyRxStatus 15:0 - * PhyRxStatus_1: PhyRxStatus 31:16 - * PhyRxStatus_2: PhyRxStatus 47:32 - * PhyRxStatus_3: PhyRxStatus 63:48 - * PhyRxStatus_4: PhyRxStatus 79:64 - * PhyRxStatus_5: PhyRxStatus 95:80 - * RxStatus1: MAC Rx Status - * RxStatus2: extended MAC Rx status - * RxTSFTime: RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY - * RxChan: gain code, channel radio code, and phy type - */ -struct d11rxhdr_le { - __le16 RxFrameSize; - u16 PAD; - __le16 PhyRxStatus_0; - __le16 PhyRxStatus_1; - __le16 PhyRxStatus_2; - __le16 PhyRxStatus_3; - __le16 PhyRxStatus_4; - __le16 PhyRxStatus_5; - __le16 RxStatus1; - __le16 RxStatus2; - __le16 RxTSFTime; - __le16 RxChan; -} __packed; - -struct d11rxhdr { - u16 RxFrameSize; - u16 PAD; - u16 PhyRxStatus_0; - u16 PhyRxStatus_1; - u16 PhyRxStatus_2; - u16 PhyRxStatus_3; - u16 PhyRxStatus_4; - u16 PhyRxStatus_5; - u16 RxStatus1; - u16 RxStatus2; - u16 RxTSFTime; - u16 RxChan; -} __packed; - -/* PhyRxStatus_0: */ -/* NPHY only: CCK, OFDM, preN, N */ -#define PRXS0_FT_MASK 0x0003 -/* NPHY only: clip count adjustment steps by AGC */ -#define PRXS0_CLIP_MASK 0x000C -#define PRXS0_CLIP_SHIFT 2 -/* PHY received a frame with unsupported rate */ -#define PRXS0_UNSRATE 0x0010 -/* GPHY: rx ant, NPHY: upper sideband */ -#define PRXS0_RXANT_UPSUBBAND 0x0020 -/* CCK frame only: lost crs during cck frame reception */ -#define PRXS0_LCRS 0x0040 -/* Short Preamble */ -#define PRXS0_SHORTH 0x0080 -/* PLCP violation */ -#define PRXS0_PLCPFV 0x0100 -/* PLCP header integrity check failed */ -#define PRXS0_PLCPHCF 0x0200 -/* legacy PHY gain control */ -#define PRXS0_GAIN_CTL 0x4000 -/* NPHY: Antennas used for received frame, bitmask */ -#define PRXS0_ANTSEL_MASK 0xF000 -#define PRXS0_ANTSEL_SHIFT 0x12 - -/* subfield PRXS0_FT_MASK */ -#define PRXS0_CCK 0x0000 -/* valid only for G phy, use rxh->RxChan for A phy */ -#define PRXS0_OFDM 0x0001 -#define PRXS0_PREN 0x0002 -#define PRXS0_STDN 0x0003 - -/* subfield PRXS0_ANTSEL_MASK */ -#define PRXS0_ANTSEL_0 0x0 /* antenna 0 is used */ -#define PRXS0_ANTSEL_1 0x2 /* antenna 1 is used */ -#define PRXS0_ANTSEL_2 0x4 /* antenna 2 is used */ -#define PRXS0_ANTSEL_3 0x8 /* antenna 3 is used */ - -/* PhyRxStatus_1: */ -#define PRXS1_JSSI_MASK 0x00FF -#define PRXS1_JSSI_SHIFT 0 -#define PRXS1_SQ_MASK 0xFF00 -#define PRXS1_SQ_SHIFT 8 - -/* nphy PhyRxStatus_1: */ -#define PRXS1_nphy_PWR0_MASK 0x00FF -#define PRXS1_nphy_PWR1_MASK 0xFF00 - -/* HTPHY Rx Status defines */ -/* htphy PhyRxStatus_0: those bit are overlapped with PhyRxStatus_0 */ -#define PRXS0_BAND 0x0400 /* 0 = 2.4G, 1 = 5G */ -#define PRXS0_RSVD 0x0800 /* reserved; set to 0 */ -#define PRXS0_UNUSED 0xF000 /* unused and not defined; set to 0 */ - -/* htphy PhyRxStatus_1: */ -/* core enables for {3..0}, 0=disabled, 1=enabled */ -#define PRXS1_HTPHY_CORE_MASK 0x000F -/* antenna configation */ -#define PRXS1_HTPHY_ANTCFG_MASK 0x00F0 -/* Mixmode PLCP Length low byte mask */ -#define PRXS1_HTPHY_MMPLCPLenL_MASK 0xFF00 - -/* htphy PhyRxStatus_2: */ -/* Mixmode PLCP Length high byte maskw */ -#define PRXS2_HTPHY_MMPLCPLenH_MASK 0x000F -/* Mixmode PLCP rate mask */ -#define PRXS2_HTPHY_MMPLCH_RATE_MASK 0x00F0 -/* Rx power on core 0 */ -#define PRXS2_HTPHY_RXPWR_ANT0 0xFF00 - -/* htphy PhyRxStatus_3: */ -/* Rx power on core 1 */ -#define PRXS3_HTPHY_RXPWR_ANT1 0x00FF -/* Rx power on core 2 */ -#define PRXS3_HTPHY_RXPWR_ANT2 0xFF00 - -/* htphy PhyRxStatus_4: */ -/* Rx power on core 3 */ -#define PRXS4_HTPHY_RXPWR_ANT3 0x00FF -/* Coarse frequency offset */ -#define PRXS4_HTPHY_CFO 0xFF00 - -/* htphy PhyRxStatus_5: */ -/* Fine frequency offset */ -#define PRXS5_HTPHY_FFO 0x00FF -/* Advance Retard */ -#define PRXS5_HTPHY_AR 0xFF00 - -#define HTPHY_MMPLCPLen(rxs) \ - ((((rxs)->PhyRxStatus_1 & PRXS1_HTPHY_MMPLCPLenL_MASK) >> 8) | \ - (((rxs)->PhyRxStatus_2 & PRXS2_HTPHY_MMPLCPLenH_MASK) << 8)) -/* Get Rx power on core 0 */ -#define HTPHY_RXPWR_ANT0(rxs) \ - ((((rxs)->PhyRxStatus_2) & PRXS2_HTPHY_RXPWR_ANT0) >> 8) -/* Get Rx power on core 1 */ -#define HTPHY_RXPWR_ANT1(rxs) \ - (((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT1) -/* Get Rx power on core 2 */ -#define HTPHY_RXPWR_ANT2(rxs) \ - ((((rxs)->PhyRxStatus_3) & PRXS3_HTPHY_RXPWR_ANT2) >> 8) - -/* ucode RxStatus1: */ -#define RXS_BCNSENT 0x8000 -#define RXS_SECKINDX_MASK 0x07e0 -#define RXS_SECKINDX_SHIFT 5 -#define RXS_DECERR (1 << 4) -#define RXS_DECATMPT (1 << 3) -/* PAD bytes to make IP data 4 bytes aligned */ -#define RXS_PBPRES (1 << 2) -#define RXS_RESPFRAMETX (1 << 1) -#define RXS_FCSERR (1 << 0) - -/* ucode RxStatus2: */ -#define RXS_AMSDU_MASK 1 -#define RXS_AGGTYPE_MASK 0x6 -#define RXS_AGGTYPE_SHIFT 1 -#define RXS_PHYRXST_VALID (1 << 8) -#define RXS_RXANT_MASK 0x3 -#define RXS_RXANT_SHIFT 12 - -/* RxChan */ -#define RXS_CHAN_40 0x1000 -#define RXS_CHAN_5G 0x0800 -#define RXS_CHAN_ID_MASK 0x07f8 -#define RXS_CHAN_ID_SHIFT 3 -#define RXS_CHAN_PHYTYPE_MASK 0x0007 -#define RXS_CHAN_PHYTYPE_SHIFT 0 - -/* Index of attenuations used during ucode power control. */ -#define M_PWRIND_BLKS (0x184 * 2) -#define M_PWRIND_MAP0 (M_PWRIND_BLKS + 0x0) -#define M_PWRIND_MAP1 (M_PWRIND_BLKS + 0x2) -#define M_PWRIND_MAP2 (M_PWRIND_BLKS + 0x4) -#define M_PWRIND_MAP3 (M_PWRIND_BLKS + 0x6) -/* M_PWRIND_MAP(core) macro */ -#define M_PWRIND_MAP(core) (M_PWRIND_BLKS + ((core)<<1)) - -/* PSM SHM variable offsets */ -#define M_PSM_SOFT_REGS 0x0 -#define M_BOM_REV_MAJOR (M_PSM_SOFT_REGS + 0x0) -#define M_BOM_REV_MINOR (M_PSM_SOFT_REGS + 0x2) -#define M_UCODE_DBGST (M_PSM_SOFT_REGS + 0x40) /* ucode debug status code */ -#define M_UCODE_MACSTAT (M_PSM_SOFT_REGS + 0xE0) /* macstat counters */ - -#define M_AGING_THRSH (0x3e * 2) /* max time waiting for medium before tx */ -#define M_MBURST_SIZE (0x40 * 2) /* max frames in a frameburst */ -#define M_MBURST_TXOP (0x41 * 2) /* max frameburst TXOP in unit of us */ -#define M_SYNTHPU_DLY (0x4a * 2) /* pre-wakeup for synthpu, default: 500 */ -#define M_PRETBTT (0x4b * 2) - -/* offset to the target txpwr */ -#define M_ALT_TXPWR_IDX (M_PSM_SOFT_REGS + (0x3b * 2)) -#define M_PHY_TX_FLT_PTR (M_PSM_SOFT_REGS + (0x3d * 2)) -#define M_CTS_DURATION (M_PSM_SOFT_REGS + (0x5c * 2)) -#define M_LP_RCCAL_OVR (M_PSM_SOFT_REGS + (0x6b * 2)) - -/* PKTENG Rx Stats Block */ -#define M_RXSTATS_BLK_PTR (M_PSM_SOFT_REGS + (0x65 * 2)) - -/* ucode debug status codes */ -/* not valid really */ -#define DBGST_INACTIVE 0 -/* after zeroing SHM, before suspending at init */ -#define DBGST_INIT 1 -/* "normal" state */ -#define DBGST_ACTIVE 2 -/* suspended */ -#define DBGST_SUSPENDED 3 -/* asleep (PS mode) */ -#define DBGST_ASLEEP 4 - -/* Scratch Reg defs */ -enum _ePsmScratchPadRegDefinitions { - S_RSV0 = 0, - S_RSV1, - S_RSV2, - - /* offset 0x03: scratch registers for Dot11-contants */ - S_DOT11_CWMIN, /* CW-minimum */ - S_DOT11_CWMAX, /* CW-maximum */ - S_DOT11_CWCUR, /* CW-current */ - S_DOT11_SRC_LMT, /* short retry count limit */ - S_DOT11_LRC_LMT, /* long retry count limit */ - S_DOT11_DTIMCOUNT, /* DTIM-count */ - - /* offset 0x09: Tx-side scratch registers */ - S_SEQ_NUM, /* hardware sequence number reg */ - S_SEQ_NUM_FRAG, /* seq num for frags (at the start of MSDU) */ - S_FRMRETX_CNT, /* frame retx count */ - S_SSRC, /* Station short retry count */ - S_SLRC, /* Station long retry count */ - S_EXP_RSP, /* Expected response frame */ - S_OLD_BREM, /* Remaining backoff ctr */ - S_OLD_CWWIN, /* saved-off CW-cur */ - S_TXECTL, /* TXE-Ctl word constructed in scr-pad */ - S_CTXTST, /* frm type-subtype as read from Tx-descr */ - - /* offset 0x13: Rx-side scratch registers */ - S_RXTST, /* Type and subtype in Rxframe */ - - /* Global state register */ - S_STREG, /* state storage actual bit maps below */ - - S_TXPWR_SUM, /* Tx power control: accumulator */ - S_TXPWR_ITER, /* Tx power control: iteration */ - S_RX_FRMTYPE, /* Rate and PHY type for frames */ - S_THIS_AGG, /* Size of this AGG (A-MSDU) */ - - S_KEYINDX, - S_RXFRMLEN, /* Receive MPDU length in bytes */ - - /* offset 0x1B: Receive TSF time stored in SCR */ - S_RXTSFTMRVAL_WD3, /* TSF value at the start of rx */ - S_RXTSFTMRVAL_WD2, /* TSF value at the start of rx */ - S_RXTSFTMRVAL_WD1, /* TSF value at the start of rx */ - S_RXTSFTMRVAL_WD0, /* TSF value at the start of rx */ - S_RXSSN, /* Received start seq number for A-MPDU BA */ - S_RXQOSFLD, /* Rx-QoS field (if present) */ - - /* offset 0x21: Scratch pad regs used in microcode as temp storage */ - S_TMP0, /* stmp0 */ - S_TMP1, /* stmp1 */ - S_TMP2, /* stmp2 */ - S_TMP3, /* stmp3 */ - S_TMP4, /* stmp4 */ - S_TMP5, /* stmp5 */ - S_PRQPENALTY_CTR, /* Probe response queue penalty counter */ - S_ANTCNT, /* unsuccessful attempts on current ant. */ - S_SYMBOL, /* flag for possible symbol ctl frames */ - S_RXTP, /* rx frame type */ - S_STREG2, /* extra state storage */ - S_STREG3, /* even more extra state storage */ - S_STREG4, /* ... */ - S_STREG5, /* remember to initialize it to zero */ - - S_ADJPWR_IDX, - S_CUR_PTR, /* Temp pointer for A-MPDU re-Tx SHM table */ - S_REVID4, /* 0x33 */ - S_INDX, /* 0x34 */ - S_ADDR0, /* 0x35 */ - S_ADDR1, /* 0x36 */ - S_ADDR2, /* 0x37 */ - S_ADDR3, /* 0x38 */ - S_ADDR4, /* 0x39 */ - S_ADDR5, /* 0x3A */ - S_TMP6, /* 0x3B */ - S_KEYINDX_BU, /* Backup for Key index */ - S_MFGTEST_TMP0, /* Temp regs used for RX test calculations */ - S_RXESN, /* Received end sequence number for A-MPDU BA */ - S_STREG6, /* 0x3F */ -}; - -#define S_BEACON_INDX S_OLD_BREM -#define S_PRS_INDX S_OLD_CWWIN -#define S_PHYTYPE S_SSRC -#define S_PHYVER S_SLRC - -/* IHR SLOW_CTRL values */ -#define SLOW_CTRL_PDE (1 << 0) -#define SLOW_CTRL_FD (1 << 8) - -/* ucode mac statistic counters in shared memory */ -struct macstat { - u16 txallfrm; /* 0x80 */ - u16 txrtsfrm; /* 0x82 */ - u16 txctsfrm; /* 0x84 */ - u16 txackfrm; /* 0x86 */ - u16 txdnlfrm; /* 0x88 */ - u16 txbcnfrm; /* 0x8a */ - u16 txfunfl[8]; /* 0x8c - 0x9b */ - u16 txtplunfl; /* 0x9c */ - u16 txphyerr; /* 0x9e */ - u16 pktengrxducast; /* 0xa0 */ - u16 pktengrxdmcast; /* 0xa2 */ - u16 rxfrmtoolong; /* 0xa4 */ - u16 rxfrmtooshrt; /* 0xa6 */ - u16 rxinvmachdr; /* 0xa8 */ - u16 rxbadfcs; /* 0xaa */ - u16 rxbadplcp; /* 0xac */ - u16 rxcrsglitch; /* 0xae */ - u16 rxstrt; /* 0xb0 */ - u16 rxdfrmucastmbss; /* 0xb2 */ - u16 rxmfrmucastmbss; /* 0xb4 */ - u16 rxcfrmucast; /* 0xb6 */ - u16 rxrtsucast; /* 0xb8 */ - u16 rxctsucast; /* 0xba */ - u16 rxackucast; /* 0xbc */ - u16 rxdfrmocast; /* 0xbe */ - u16 rxmfrmocast; /* 0xc0 */ - u16 rxcfrmocast; /* 0xc2 */ - u16 rxrtsocast; /* 0xc4 */ - u16 rxctsocast; /* 0xc6 */ - u16 rxdfrmmcast; /* 0xc8 */ - u16 rxmfrmmcast; /* 0xca */ - u16 rxcfrmmcast; /* 0xcc */ - u16 rxbeaconmbss; /* 0xce */ - u16 rxdfrmucastobss; /* 0xd0 */ - u16 rxbeaconobss; /* 0xd2 */ - u16 rxrsptmout; /* 0xd4 */ - u16 bcntxcancl; /* 0xd6 */ - u16 PAD; - u16 rxf0ovfl; /* 0xda */ - u16 rxf1ovfl; /* 0xdc */ - u16 rxf2ovfl; /* 0xde */ - u16 txsfovfl; /* 0xe0 */ - u16 pmqovfl; /* 0xe2 */ - u16 rxcgprqfrm; /* 0xe4 */ - u16 rxcgprsqovfl; /* 0xe6 */ - u16 txcgprsfail; /* 0xe8 */ - u16 txcgprssuc; /* 0xea */ - u16 prs_timeout; /* 0xec */ - u16 rxnack; - u16 frmscons; - u16 txnack; - u16 txglitch_nack; - u16 txburst; /* 0xf6 # tx bursts */ - u16 bphy_rxcrsglitch; /* bphy rx crs glitch */ - u16 phywatchdog; /* 0xfa # of phy watchdog events */ - u16 PAD; - u16 bphy_badplcp; /* bphy bad plcp */ -}; - -/* dot11 core-specific control flags */ -#define SICF_PCLKE 0x0004 /* PHY clock enable */ -#define SICF_PRST 0x0008 /* PHY reset */ -#define SICF_MPCLKE 0x0010 /* MAC PHY clockcontrol enable */ -#define SICF_FREF 0x0020 /* PLL FreqRefSelect */ -/* NOTE: the following bw bits only apply when the core is attached - * to a NPHY - */ -#define SICF_BWMASK 0x00c0 /* phy clock mask (b6 & b7) */ -#define SICF_BW40 0x0080 /* 40MHz BW (160MHz phyclk) */ -#define SICF_BW20 0x0040 /* 20MHz BW (80MHz phyclk) */ -#define SICF_BW10 0x0000 /* 10MHz BW (40MHz phyclk) */ -#define SICF_GMODE 0x2000 /* gmode enable */ - -/* dot11 core-specific status flags */ -#define SISF_2G_PHY 0x0001 /* 2.4G capable phy */ -#define SISF_5G_PHY 0x0002 /* 5G capable phy */ -#define SISF_FCLKA 0x0004 /* FastClkAvailable */ -#define SISF_DB_PHY 0x0008 /* Dualband phy */ - -/* === End of MAC reg, Beginning of PHY(b/a/g/n) reg === */ -/* radio and LPPHY regs are separated */ - -#define BPHY_REG_OFT_BASE 0x0 -/* offsets for indirect access to bphy registers */ -#define BPHY_BB_CONFIG 0x01 -#define BPHY_ADCBIAS 0x02 -#define BPHY_ANACORE 0x03 -#define BPHY_PHYCRSTH 0x06 -#define BPHY_TEST 0x0a -#define BPHY_PA_TX_TO 0x10 -#define BPHY_SYNTH_DC_TO 0x11 -#define BPHY_PA_TX_TIME_UP 0x12 -#define BPHY_RX_FLTR_TIME_UP 0x13 -#define BPHY_TX_POWER_OVERRIDE 0x14 -#define BPHY_RF_OVERRIDE 0x15 -#define BPHY_RF_TR_LOOKUP1 0x16 -#define BPHY_RF_TR_LOOKUP2 0x17 -#define BPHY_COEFFS 0x18 -#define BPHY_PLL_OUT 0x19 -#define BPHY_REFRESH_MAIN 0x1a -#define BPHY_REFRESH_TO0 0x1b -#define BPHY_REFRESH_TO1 0x1c -#define BPHY_RSSI_TRESH 0x20 -#define BPHY_IQ_TRESH_HH 0x21 -#define BPHY_IQ_TRESH_H 0x22 -#define BPHY_IQ_TRESH_L 0x23 -#define BPHY_IQ_TRESH_LL 0x24 -#define BPHY_GAIN 0x25 -#define BPHY_LNA_GAIN_RANGE 0x26 -#define BPHY_JSSI 0x27 -#define BPHY_TSSI_CTL 0x28 -#define BPHY_TSSI 0x29 -#define BPHY_TR_LOSS_CTL 0x2a -#define BPHY_LO_LEAKAGE 0x2b -#define BPHY_LO_RSSI_ACC 0x2c -#define BPHY_LO_IQMAG_ACC 0x2d -#define BPHY_TX_DC_OFF1 0x2e -#define BPHY_TX_DC_OFF2 0x2f -#define BPHY_PEAK_CNT_THRESH 0x30 -#define BPHY_FREQ_OFFSET 0x31 -#define BPHY_DIVERSITY_CTL 0x32 -#define BPHY_PEAK_ENERGY_LO 0x33 -#define BPHY_PEAK_ENERGY_HI 0x34 -#define BPHY_SYNC_CTL 0x35 -#define BPHY_TX_PWR_CTRL 0x36 -#define BPHY_TX_EST_PWR 0x37 -#define BPHY_STEP 0x38 -#define BPHY_WARMUP 0x39 -#define BPHY_LMS_CFF_READ 0x3a -#define BPHY_LMS_COEFF_I 0x3b -#define BPHY_LMS_COEFF_Q 0x3c -#define BPHY_SIG_POW 0x3d -#define BPHY_RFDC_CANCEL_CTL 0x3e -#define BPHY_HDR_TYPE 0x40 -#define BPHY_SFD_TO 0x41 -#define BPHY_SFD_CTL 0x42 -#define BPHY_DEBUG 0x43 -#define BPHY_RX_DELAY_COMP 0x44 -#define BPHY_CRS_DROP_TO 0x45 -#define BPHY_SHORT_SFD_NZEROS 0x46 -#define BPHY_DSSS_COEFF1 0x48 -#define BPHY_DSSS_COEFF2 0x49 -#define BPHY_CCK_COEFF1 0x4a -#define BPHY_CCK_COEFF2 0x4b -#define BPHY_TR_CORR 0x4c -#define BPHY_ANGLE_SCALE 0x4d -#define BPHY_TX_PWR_BASE_IDX 0x4e -#define BPHY_OPTIONAL_MODES2 0x4f -#define BPHY_CCK_LMS_STEP 0x50 -#define BPHY_BYPASS 0x51 -#define BPHY_CCK_DELAY_LONG 0x52 -#define BPHY_CCK_DELAY_SHORT 0x53 -#define BPHY_PPROC_CHAN_DELAY 0x54 -#define BPHY_DDFS_ENABLE 0x58 -#define BPHY_PHASE_SCALE 0x59 -#define BPHY_FREQ_CONTROL 0x5a -#define BPHY_LNA_GAIN_RANGE_10 0x5b -#define BPHY_LNA_GAIN_RANGE_32 0x5c -#define BPHY_OPTIONAL_MODES 0x5d -#define BPHY_RX_STATUS2 0x5e -#define BPHY_RX_STATUS3 0x5f -#define BPHY_DAC_CONTROL 0x60 -#define BPHY_ANA11G_FILT_CTRL 0x62 -#define BPHY_REFRESH_CTRL 0x64 -#define BPHY_RF_OVERRIDE2 0x65 -#define BPHY_SPUR_CANCEL_CTRL 0x66 -#define BPHY_FINE_DIGIGAIN_CTRL 0x67 -#define BPHY_RSSI_LUT 0x88 -#define BPHY_RSSI_LUT_END 0xa7 -#define BPHY_TSSI_LUT 0xa8 -#define BPHY_TSSI_LUT_END 0xc7 -#define BPHY_TSSI2PWR_LUT 0x380 -#define BPHY_TSSI2PWR_LUT_END 0x39f -#define BPHY_LOCOMP_LUT 0x3a0 -#define BPHY_LOCOMP_LUT_END 0x3bf -#define BPHY_TXGAIN_LUT 0x3c0 -#define BPHY_TXGAIN_LUT_END 0x3ff - -/* Bits in BB_CONFIG: */ -#define PHY_BBC_ANT_MASK 0x0180 -#define PHY_BBC_ANT_SHIFT 7 -#define BB_DARWIN 0x1000 -#define BBCFG_RESETCCA 0x4000 -#define BBCFG_RESETRX 0x8000 - -/* Bits in phytest(0x0a): */ -#define TST_DDFS 0x2000 -#define TST_TXFILT1 0x0800 -#define TST_UNSCRAM 0x0400 -#define TST_CARR_SUPP 0x0200 -#define TST_DC_COMP_LOOP 0x0100 -#define TST_LOOPBACK 0x0080 -#define TST_TXFILT0 0x0040 -#define TST_TXTEST_ENABLE 0x0020 -#define TST_TXTEST_RATE 0x0018 -#define TST_TXTEST_PHASE 0x0007 - -/* phytest txTestRate values */ -#define TST_TXTEST_RATE_1MBPS 0 -#define TST_TXTEST_RATE_2MBPS 1 -#define TST_TXTEST_RATE_5_5MBPS 2 -#define TST_TXTEST_RATE_11MBPS 3 -#define TST_TXTEST_RATE_SHIFT 3 - -#define SHM_BYT_CNT 0x2 /* IHR location */ -#define MAX_BYT_CNT 0x600 /* Maximum frame len */ - -struct d11cnt { - u32 txfrag; - u32 txmulti; - u32 txfail; - u32 txretry; - u32 txretrie; - u32 rxdup; - u32 txrts; - u32 txnocts; - u32 txnoack; - u32 rxfrag; - u32 rxmulti; - u32 rxcrc; - u32 txfrmsnt; - u32 rxundec; -}; - -#endif /* _BRCM_D11_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/dma.c b/drivers/staging/brcm80211/brcmsmac/dma.c deleted file mode 100644 index b56a30297c2..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/dma.c +++ /dev/null @@ -1,1425 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include -#include - -#include -#include -#include "types.h" -#include "dma.h" - -/* - * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within - * a contiguous 8kB physical address. - */ -#define D64RINGALIGN_BITS 13 -#define D64MAXRINGSZ (1 << D64RINGALIGN_BITS) -#define D64RINGALIGN (1 << D64RINGALIGN_BITS) - -#define D64MAXDD (D64MAXRINGSZ / sizeof(struct dma64desc)) - -/* transmit channel control */ -#define D64_XC_XE 0x00000001 /* transmit enable */ -#define D64_XC_SE 0x00000002 /* transmit suspend request */ -#define D64_XC_LE 0x00000004 /* loopback enable */ -#define D64_XC_FL 0x00000010 /* flush request */ -#define D64_XC_PD 0x00000800 /* parity check disable */ -#define D64_XC_AE 0x00030000 /* address extension bits */ -#define D64_XC_AE_SHIFT 16 - -/* transmit descriptor table pointer */ -#define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */ - -/* transmit channel status */ -#define D64_XS0_CD_MASK 0x00001fff /* current descriptor pointer */ -#define D64_XS0_XS_MASK 0xf0000000 /* transmit state */ -#define D64_XS0_XS_SHIFT 28 -#define D64_XS0_XS_DISABLED 0x00000000 /* disabled */ -#define D64_XS0_XS_ACTIVE 0x10000000 /* active */ -#define D64_XS0_XS_IDLE 0x20000000 /* idle wait */ -#define D64_XS0_XS_STOPPED 0x30000000 /* stopped */ -#define D64_XS0_XS_SUSP 0x40000000 /* suspend pending */ - -#define D64_XS1_AD_MASK 0x00001fff /* active descriptor */ -#define D64_XS1_XE_MASK 0xf0000000 /* transmit errors */ -#define D64_XS1_XE_SHIFT 28 -#define D64_XS1_XE_NOERR 0x00000000 /* no error */ -#define D64_XS1_XE_DPE 0x10000000 /* descriptor protocol error */ -#define D64_XS1_XE_DFU 0x20000000 /* data fifo underrun */ -#define D64_XS1_XE_DTE 0x30000000 /* data transfer error */ -#define D64_XS1_XE_DESRE 0x40000000 /* descriptor read error */ -#define D64_XS1_XE_COREE 0x50000000 /* core error */ - -/* receive channel control */ -/* receive enable */ -#define D64_RC_RE 0x00000001 -/* receive frame offset */ -#define D64_RC_RO_MASK 0x000000fe -#define D64_RC_RO_SHIFT 1 -/* direct fifo receive (pio) mode */ -#define D64_RC_FM 0x00000100 -/* separate rx header descriptor enable */ -#define D64_RC_SH 0x00000200 -/* overflow continue */ -#define D64_RC_OC 0x00000400 -/* parity check disable */ -#define D64_RC_PD 0x00000800 -/* address extension bits */ -#define D64_RC_AE 0x00030000 -#define D64_RC_AE_SHIFT 16 - -/* flags for dma controller */ -/* partity enable */ -#define DMA_CTRL_PEN (1 << 0) -/* rx overflow continue */ -#define DMA_CTRL_ROC (1 << 1) -/* allow rx scatter to multiple descriptors */ -#define DMA_CTRL_RXMULTI (1 << 2) -/* Unframed Rx/Tx data */ -#define DMA_CTRL_UNFRAMED (1 << 3) - -/* receive descriptor table pointer */ -#define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */ - -/* receive channel status */ -#define D64_RS0_CD_MASK 0x00001fff /* current descriptor pointer */ -#define D64_RS0_RS_MASK 0xf0000000 /* receive state */ -#define D64_RS0_RS_SHIFT 28 -#define D64_RS0_RS_DISABLED 0x00000000 /* disabled */ -#define D64_RS0_RS_ACTIVE 0x10000000 /* active */ -#define D64_RS0_RS_IDLE 0x20000000 /* idle wait */ -#define D64_RS0_RS_STOPPED 0x30000000 /* stopped */ -#define D64_RS0_RS_SUSP 0x40000000 /* suspend pending */ - -#define D64_RS1_AD_MASK 0x0001ffff /* active descriptor */ -#define D64_RS1_RE_MASK 0xf0000000 /* receive errors */ -#define D64_RS1_RE_SHIFT 28 -#define D64_RS1_RE_NOERR 0x00000000 /* no error */ -#define D64_RS1_RE_DPO 0x10000000 /* descriptor protocol error */ -#define D64_RS1_RE_DFU 0x20000000 /* data fifo overflow */ -#define D64_RS1_RE_DTE 0x30000000 /* data transfer error */ -#define D64_RS1_RE_DESRE 0x40000000 /* descriptor read error */ -#define D64_RS1_RE_COREE 0x50000000 /* core error */ - -/* fifoaddr */ -#define D64_FA_OFF_MASK 0xffff /* offset */ -#define D64_FA_SEL_MASK 0xf0000 /* select */ -#define D64_FA_SEL_SHIFT 16 -#define D64_FA_SEL_XDD 0x00000 /* transmit dma data */ -#define D64_FA_SEL_XDP 0x10000 /* transmit dma pointers */ -#define D64_FA_SEL_RDD 0x40000 /* receive dma data */ -#define D64_FA_SEL_RDP 0x50000 /* receive dma pointers */ -#define D64_FA_SEL_XFD 0x80000 /* transmit fifo data */ -#define D64_FA_SEL_XFP 0x90000 /* transmit fifo pointers */ -#define D64_FA_SEL_RFD 0xc0000 /* receive fifo data */ -#define D64_FA_SEL_RFP 0xd0000 /* receive fifo pointers */ -#define D64_FA_SEL_RSD 0xe0000 /* receive frame status data */ -#define D64_FA_SEL_RSP 0xf0000 /* receive frame status pointers */ - -/* descriptor control flags 1 */ -#define D64_CTRL_COREFLAGS 0x0ff00000 /* core specific flags */ -#define D64_CTRL1_EOT ((u32)1 << 28) /* end of descriptor table */ -#define D64_CTRL1_IOC ((u32)1 << 29) /* interrupt on completion */ -#define D64_CTRL1_EOF ((u32)1 << 30) /* end of frame */ -#define D64_CTRL1_SOF ((u32)1 << 31) /* start of frame */ - -/* descriptor control flags 2 */ -/* buffer byte count. real data len must <= 16KB */ -#define D64_CTRL2_BC_MASK 0x00007fff -/* address extension bits */ -#define D64_CTRL2_AE 0x00030000 -#define D64_CTRL2_AE_SHIFT 16 -/* parity bit */ -#define D64_CTRL2_PARITY 0x00040000 - -/* control flags in the range [27:20] are core-specific and not defined here */ -#define D64_CTRL_CORE_MASK 0x0ff00000 - -#define D64_RX_FRM_STS_LEN 0x0000ffff /* frame length mask */ -#define D64_RX_FRM_STS_OVFL 0x00800000 /* RxOverFlow */ -#define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1 */ -#define D64_RX_FRM_STS_DATATYPE 0xf0000000 /* core-dependent data type */ - -/* - * packet headroom necessary to accommodate the largest header - * in the system, (i.e TXOFF). By doing, we avoid the need to - * allocate an extra buffer for the header when bridging to WL. - * There is a compile time check in wlc.c which ensure that this - * value is at least as big as TXOFF. This value is used in - * dma_rxfill(). - */ - -#define BCMEXTRAHDROOM 172 - -/* debug/trace */ -#ifdef BCMDBG -#define DMA_ERROR(args) \ - do { \ - if (!(*di->msg_level & 1)) \ - ; \ - else \ - printk args; \ - } while (0) -#define DMA_TRACE(args) \ - do { \ - if (!(*di->msg_level & 2)) \ - ; \ - else \ - printk args; \ - } while (0) -#else -#define DMA_ERROR(args) -#define DMA_TRACE(args) -#endif /* BCMDBG */ - -#define DMA_NONE(args) - -#define MAXNAMEL 8 /* 8 char names */ - -/* macros to convert between byte offsets and indexes */ -#define B2I(bytes, type) ((bytes) / sizeof(type)) -#define I2B(index, type) ((index) * sizeof(type)) - -#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */ -#define PCI32ADDR_HIGH_SHIFT 30 /* address[31:30] */ - -#define PCI64ADDR_HIGH 0x80000000 /* address[63] */ -#define PCI64ADDR_HIGH_SHIFT 31 /* address[63] */ - -/* - * DMA Descriptor - * Descriptors are only read by the hardware, never written back. - */ -struct dma64desc { - __le32 ctrl1; /* misc control bits & bufcount */ - __le32 ctrl2; /* buffer count and address extension */ - __le32 addrlow; /* memory address of the date buffer, bits 31:0 */ - __le32 addrhigh; /* memory address of the date buffer, bits 63:32 */ -}; - -/* dma engine software state */ -struct dma_info { - struct dma_pub dma; /* exported structure */ - uint *msg_level; /* message level pointer */ - char name[MAXNAMEL]; /* callers name for diag msgs */ - - struct pci_dev *pbus; /* bus handle */ - - bool dma64; /* this dma engine is operating in 64-bit mode */ - bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ - - /* 64-bit dma tx engine registers */ - struct dma64regs __iomem *d64txregs; - /* 64-bit dma rx engine registers */ - struct dma64regs __iomem *d64rxregs; - /* pointer to dma64 tx descriptor ring */ - struct dma64desc *txd64; - /* pointer to dma64 rx descriptor ring */ - struct dma64desc *rxd64; - - u16 dmadesc_align; /* alignment requirement for dma descriptors */ - - u16 ntxd; /* # tx descriptors tunable */ - u16 txin; /* index of next descriptor to reclaim */ - u16 txout; /* index of next descriptor to post */ - /* pointer to parallel array of pointers to packets */ - struct sk_buff **txp; - /* Aligned physical address of descriptor ring */ - dma_addr_t txdpa; - /* Original physical address of descriptor ring */ - dma_addr_t txdpaorig; - u16 txdalign; /* #bytes added to alloc'd mem to align txd */ - u32 txdalloc; /* #bytes allocated for the ring */ - u32 xmtptrbase; /* When using unaligned descriptors, the ptr register - * is not just an index, it needs all 13 bits to be - * an offset from the addr register. - */ - - u16 nrxd; /* # rx descriptors tunable */ - u16 rxin; /* index of next descriptor to reclaim */ - u16 rxout; /* index of next descriptor to post */ - /* pointer to parallel array of pointers to packets */ - struct sk_buff **rxp; - /* Aligned physical address of descriptor ring */ - dma_addr_t rxdpa; - /* Original physical address of descriptor ring */ - dma_addr_t rxdpaorig; - u16 rxdalign; /* #bytes added to alloc'd mem to align rxd */ - u32 rxdalloc; /* #bytes allocated for the ring */ - u32 rcvptrbase; /* Base for ptr reg when using unaligned descriptors */ - - /* tunables */ - unsigned int rxbufsize; /* rx buffer size in bytes, not including - * the extra headroom - */ - uint rxextrahdrroom; /* extra rx headroom, reverseved to assist upper - * stack, e.g. some rx pkt buffers will be - * bridged to tx side without byte copying. - * The extra headroom needs to be large enough - * to fit txheader needs. Some dongle driver may - * not need it. - */ - uint nrxpost; /* # rx buffers to keep posted */ - unsigned int rxoffset; /* rxcontrol offset */ - /* add to get dma address of descriptor ring, low 32 bits */ - uint ddoffsetlow; - /* high 32 bits */ - uint ddoffsethigh; - /* add to get dma address of data buffer, low 32 bits */ - uint dataoffsetlow; - /* high 32 bits */ - uint dataoffsethigh; - /* descriptor base need to be aligned or not */ - bool aligndesc_4k; -}; - -/* - * default dma message level (if input msg_level - * pointer is null in dma_attach()) - */ -static uint dma_msg_level; - -/* Check for odd number of 1's */ -static u32 parity32(__le32 data) -{ - /* no swap needed for counting 1's */ - u32 par_data = *(u32 *)&data; - - par_data ^= par_data >> 16; - par_data ^= par_data >> 8; - par_data ^= par_data >> 4; - par_data ^= par_data >> 2; - par_data ^= par_data >> 1; - - return par_data & 1; -} - -static bool dma64_dd_parity(struct dma64desc *dd) -{ - return parity32(dd->addrlow ^ dd->addrhigh ^ dd->ctrl1 ^ dd->ctrl2); -} - -/* descriptor bumping functions */ - -static uint xxd(uint x, uint n) -{ - return x & (n - 1); /* faster than %, but n must be power of 2 */ -} - -static uint txd(struct dma_info *di, uint x) -{ - return xxd(x, di->ntxd); -} - -static uint rxd(struct dma_info *di, uint x) -{ - return xxd(x, di->nrxd); -} - -static uint nexttxd(struct dma_info *di, uint i) -{ - return txd(di, i + 1); -} - -static uint prevtxd(struct dma_info *di, uint i) -{ - return txd(di, i - 1); -} - -static uint nextrxd(struct dma_info *di, uint i) -{ - return txd(di, i + 1); -} - -static uint ntxdactive(struct dma_info *di, uint h, uint t) -{ - return txd(di, t-h); -} - -static uint nrxdactive(struct dma_info *di, uint h, uint t) -{ - return rxd(di, t-h); -} - -static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) -{ - uint dmactrlflags = di->dma.dmactrlflags; - - if (di == NULL) { - DMA_ERROR(("%s: _dma_ctrlflags: NULL dma handle\n", di->name)); - return 0; - } - - dmactrlflags &= ~mask; - dmactrlflags |= flags; - - /* If trying to enable parity, check if parity is actually supported */ - if (dmactrlflags & DMA_CTRL_PEN) { - u32 control; - - control = R_REG(&di->d64txregs->control); - W_REG(&di->d64txregs->control, - control | D64_XC_PD); - if (R_REG(&di->d64txregs->control) & D64_XC_PD) - /* We *can* disable it so it is supported, - * restore control register - */ - W_REG(&di->d64txregs->control, - control); - else - /* Not supported, don't allow it to be enabled */ - dmactrlflags &= ~DMA_CTRL_PEN; - } - - di->dma.dmactrlflags = dmactrlflags; - - return dmactrlflags; -} - -static bool _dma64_addrext(struct dma64regs __iomem *dma64regs) -{ - u32 w; - OR_REG(&dma64regs->control, D64_XC_AE); - w = R_REG(&dma64regs->control); - AND_REG(&dma64regs->control, ~D64_XC_AE); - return (w & D64_XC_AE) == D64_XC_AE; -} - -/* - * return true if this dma engine supports DmaExtendedAddrChanges, - * otherwise false - */ -static bool _dma_isaddrext(struct dma_info *di) -{ - /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ - - /* not all tx or rx channel are available */ - if (di->d64txregs != NULL) { - if (!_dma64_addrext(di->d64txregs)) - DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have " - "AE set\n", di->name)); - return true; - } else if (di->d64rxregs != NULL) { - if (!_dma64_addrext(di->d64rxregs)) - DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have " - "AE set\n", di->name)); - return true; - } - - return false; -} - -static bool _dma_descriptor_align(struct dma_info *di) -{ - u32 addrl; - - /* Check to see if the descriptors need to be aligned on 4K/8K or not */ - if (di->d64txregs != NULL) { - W_REG(&di->d64txregs->addrlow, 0xff0); - addrl = R_REG(&di->d64txregs->addrlow); - if (addrl != 0) - return false; - } else if (di->d64rxregs != NULL) { - W_REG(&di->d64rxregs->addrlow, 0xff0); - addrl = R_REG(&di->d64rxregs->addrlow); - if (addrl != 0) - return false; - } - return true; -} - -/* - * Descriptor table must start at the DMA hardware dictated alignment, so - * allocated memory must be large enough to support this requirement. - */ -static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, - u16 align_bits, uint *alloced, - dma_addr_t *pap) -{ - if (align_bits) { - u16 align = (1 << align_bits); - if (!IS_ALIGNED(PAGE_SIZE, align)) - size += align; - *alloced = size; - } - return pci_alloc_consistent(pdev, size, pap); -} - -static -u8 dma_align_sizetobits(uint size) -{ - u8 bitpos = 0; - while (size >>= 1) - bitpos++; - return bitpos; -} - -/* This function ensures that the DMA descriptor ring will not get allocated - * across Page boundary. If the allocation is done across the page boundary - * at the first time, then it is freed and the allocation is done at - * descriptor ring size aligned location. This will ensure that the ring will - * not cross page boundary - */ -static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, - u16 *alignbits, uint *alloced, - dma_addr_t *descpa) -{ - void *va; - u32 desc_strtaddr; - u32 alignbytes = 1 << *alignbits; - - va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); - - if (NULL == va) - return NULL; - - desc_strtaddr = (u32) roundup((unsigned long)va, alignbytes); - if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr - & boundary)) { - *alignbits = dma_align_sizetobits(size); - pci_free_consistent(di->pbus, size, va, *descpa); - va = dma_alloc_consistent(di->pbus, size, *alignbits, - alloced, descpa); - } - return va; -} - -static bool dma64_alloc(struct dma_info *di, uint direction) -{ - u16 size; - uint ddlen; - void *va; - uint alloced = 0; - u16 align; - u16 align_bits; - - ddlen = sizeof(struct dma64desc); - - size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen); - align_bits = di->dmadesc_align; - align = (1 << align_bits); - - if (direction == DMA_TX) { - va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig); - if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd)" - " failed\n", di->name)); - return false; - } - align = (1 << align_bits); - di->txd64 = (struct dma64desc *) - roundup((unsigned long)va, align); - di->txdalign = (uint) ((s8 *)di->txd64 - (s8 *) va); - di->txdpa = di->txdpaorig + di->txdalign; - di->txdalloc = alloced; - } else { - va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig); - if (va == NULL) { - DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd)" - " failed\n", di->name)); - return false; - } - align = (1 << align_bits); - di->rxd64 = (struct dma64desc *) - roundup((unsigned long)va, align); - di->rxdalign = (uint) ((s8 *)di->rxd64 - (s8 *) va); - di->rxdpa = di->rxdpaorig + di->rxdalign; - di->rxdalloc = alloced; - } - - return true; -} - -static bool _dma_alloc(struct dma_info *di, uint direction) -{ - return dma64_alloc(di, direction); -} - -struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void __iomem *dmaregstx, void __iomem *dmaregsrx, - uint ntxd, uint nrxd, - uint rxbufsize, int rxextheadroom, - uint nrxpost, uint rxoffset, uint *msg_level) -{ - struct dma_info *di; - uint size; - - /* allocate private info structure */ - di = kzalloc(sizeof(struct dma_info), GFP_ATOMIC); - if (di == NULL) - return NULL; - - di->msg_level = msg_level ? msg_level : &dma_msg_level; - - - di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); - - /* init dma reg pointer */ - di->d64txregs = (struct dma64regs __iomem *) dmaregstx; - di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; - - /* - * Default flags (which can be changed by the driver calling - * dma_ctrlflags before enable): For backwards compatibility - * both Rx Overflow Continue and Parity are DISABLED. - */ - _dma_ctrlflags(di, DMA_CTRL_ROC | DMA_CTRL_PEN, 0); - - DMA_TRACE(("%s: dma_attach: %s flags 0x%x ntxd %d nrxd %d " - "rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d " - "dmaregstx %p dmaregsrx %p\n", name, "DMA64", - di->dma.dmactrlflags, ntxd, nrxd, rxbufsize, - rxextheadroom, nrxpost, rxoffset, dmaregstx, dmaregsrx)); - - /* make a private copy of our callers name */ - strncpy(di->name, name, MAXNAMEL); - di->name[MAXNAMEL - 1] = '\0'; - - di->pbus = ((struct si_info *)sih)->pbus; - - /* save tunables */ - di->ntxd = (u16) ntxd; - di->nrxd = (u16) nrxd; - - /* the actual dma size doesn't include the extra headroom */ - di->rxextrahdrroom = - (rxextheadroom == -1) ? BCMEXTRAHDROOM : rxextheadroom; - if (rxbufsize > BCMEXTRAHDROOM) - di->rxbufsize = (u16) (rxbufsize - di->rxextrahdrroom); - else - di->rxbufsize = (u16) rxbufsize; - - di->nrxpost = (u16) nrxpost; - di->rxoffset = (u8) rxoffset; - - /* - * figure out the DMA physical address offset for dd and data - * PCI/PCIE: they map silicon backplace address to zero - * based memory, need offset - * Other bus: use zero SI_BUS BIGENDIAN kludge: use sdram - * swapped region for data buffer, not descriptor - */ - di->ddoffsetlow = 0; - di->dataoffsetlow = 0; - /* add offset for pcie with DMA64 bus */ - di->ddoffsetlow = 0; - di->ddoffsethigh = SI_PCIE_DMA_H32; - di->dataoffsetlow = di->ddoffsetlow; - di->dataoffsethigh = di->ddoffsethigh; - /* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */ - if ((ai_coreid(sih) == SDIOD_CORE_ID) - && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2))) - di->addrext = 0; - else if ((ai_coreid(sih) == I2S_CORE_ID) && - ((ai_corerev(sih) == 0) || (ai_corerev(sih) == 1))) - di->addrext = 0; - else - di->addrext = _dma_isaddrext(di); - - /* does the descriptor need to be aligned and if yes, on 4K/8K or not */ - di->aligndesc_4k = _dma_descriptor_align(di); - if (di->aligndesc_4k) { - di->dmadesc_align = D64RINGALIGN_BITS; - if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) - /* for smaller dd table, HW relax alignment reqmnt */ - di->dmadesc_align = D64RINGALIGN_BITS - 1; - } else { - di->dmadesc_align = 4; /* 16 byte alignment */ - } - - DMA_NONE(("DMA descriptor align_needed %d, align %d\n", - di->aligndesc_4k, di->dmadesc_align)); - - /* allocate tx packet pointer vector */ - if (ntxd) { - size = ntxd * sizeof(void *); - di->txp = kzalloc(size, GFP_ATOMIC); - if (di->txp == NULL) - goto fail; - } - - /* allocate rx packet pointer vector */ - if (nrxd) { - size = nrxd * sizeof(void *); - di->rxp = kzalloc(size, GFP_ATOMIC); - if (di->rxp == NULL) - goto fail; - } - - /* - * allocate transmit descriptor ring, only need ntxd descriptors - * but it must be aligned - */ - if (ntxd) { - if (!_dma_alloc(di, DMA_TX)) - goto fail; - } - - /* - * allocate receive descriptor ring, only need nrxd descriptors - * but it must be aligned - */ - if (nrxd) { - if (!_dma_alloc(di, DMA_RX)) - goto fail; - } - - if ((di->ddoffsetlow != 0) && !di->addrext) { - if (di->txdpa > SI_PCI_DMA_SZ) { - DMA_ERROR(("%s: dma_attach: txdpa 0x%x: addrext not " - "supported\n", di->name, (u32)di->txdpa)); - goto fail; - } - if (di->rxdpa > SI_PCI_DMA_SZ) { - DMA_ERROR(("%s: dma_attach: rxdpa 0x%x: addrext not " - "supported\n", di->name, (u32)di->rxdpa)); - goto fail; - } - } - - DMA_TRACE(("ddoffsetlow 0x%x ddoffsethigh 0x%x dataoffsetlow 0x%x " - "dataoffsethigh " "0x%x addrext %d\n", di->ddoffsetlow, - di->ddoffsethigh, di->dataoffsetlow, di->dataoffsethigh, - di->addrext)); - - return (struct dma_pub *) di; - - fail: - dma_detach((struct dma_pub *)di); - return NULL; -} - -static inline void -dma64_dd_upd(struct dma_info *di, struct dma64desc *ddring, - dma_addr_t pa, uint outidx, u32 *flags, u32 bufcount) -{ - u32 ctrl2 = bufcount & D64_CTRL2_BC_MASK; - - /* PCI bus with big(>1G) physical address, use address extension */ - if ((di->dataoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { - ddring[outidx].addrlow = cpu_to_le32(pa + di->dataoffsetlow); - ddring[outidx].addrhigh = cpu_to_le32(di->dataoffsethigh); - ddring[outidx].ctrl1 = cpu_to_le32(*flags); - ddring[outidx].ctrl2 = cpu_to_le32(ctrl2); - } else { - /* address extension for 32-bit PCI */ - u32 ae; - - ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; - pa &= ~PCI32ADDR_HIGH; - - ctrl2 |= (ae << D64_CTRL2_AE_SHIFT) & D64_CTRL2_AE; - ddring[outidx].addrlow = cpu_to_le32(pa + di->dataoffsetlow); - ddring[outidx].addrhigh = cpu_to_le32(di->dataoffsethigh); - ddring[outidx].ctrl1 = cpu_to_le32(*flags); - ddring[outidx].ctrl2 = cpu_to_le32(ctrl2); - } - if (di->dma.dmactrlflags & DMA_CTRL_PEN) { - if (dma64_dd_parity(&ddring[outidx])) - ddring[outidx].ctrl2 = - cpu_to_le32(ctrl2 | D64_CTRL2_PARITY); - } -} - -/* !! may be called with core in reset */ -void dma_detach(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - - DMA_TRACE(("%s: dma_detach\n", di->name)); - - /* free dma descriptor rings */ - if (di->txd64) - pci_free_consistent(di->pbus, di->txdalloc, - ((s8 *)di->txd64 - di->txdalign), - (di->txdpaorig)); - if (di->rxd64) - pci_free_consistent(di->pbus, di->rxdalloc, - ((s8 *)di->rxd64 - di->rxdalign), - (di->rxdpaorig)); - - /* free packet pointer vectors */ - kfree(di->txp); - kfree(di->rxp); - - /* free our private info structure */ - kfree(di); - -} - -/* initialize descriptor table base address */ -static void -_dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) -{ - if (!di->aligndesc_4k) { - if (direction == DMA_TX) - di->xmtptrbase = pa; - else - di->rcvptrbase = pa; - } - - if ((di->ddoffsetlow == 0) - || !(pa & PCI32ADDR_HIGH)) { - if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); - } else { - W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); - } - } else { - /* DMA64 32bits address extension */ - u32 ae; - - /* shift the high bit(s) from pa to ae */ - ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; - pa &= ~PCI32ADDR_HIGH; - - if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); - SET_REG(&di->d64txregs->control, - D64_XC_AE, (ae << D64_XC_AE_SHIFT)); - } else { - W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); - SET_REG(&di->d64rxregs->control, - D64_RC_AE, (ae << D64_RC_AE_SHIFT)); - } - } -} - -static void _dma_rxenable(struct dma_info *di) -{ - uint dmactrlflags = di->dma.dmactrlflags; - u32 control; - - DMA_TRACE(("%s: dma_rxenable\n", di->name)); - - control = - (R_REG(&di->d64rxregs->control) & D64_RC_AE) | - D64_RC_RE; - - if ((dmactrlflags & DMA_CTRL_PEN) == 0) - control |= D64_RC_PD; - - if (dmactrlflags & DMA_CTRL_ROC) - control |= D64_RC_OC; - - W_REG(&di->d64rxregs->control, - ((di->rxoffset << D64_RC_RO_SHIFT) | control)); -} - -void dma_rxinit(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - - DMA_TRACE(("%s: dma_rxinit\n", di->name)); - - if (di->nrxd == 0) - return; - - di->rxin = di->rxout = 0; - - /* clear rx descriptor ring */ - memset(di->rxd64, '\0', di->nrxd * sizeof(struct dma64desc)); - - /* DMA engine with out alignment requirement requires table to be inited - * before enabling the engine - */ - if (!di->aligndesc_4k) - _dma_ddtable_init(di, DMA_RX, di->rxdpa); - - _dma_rxenable(di); - - if (di->aligndesc_4k) - _dma_ddtable_init(di, DMA_RX, di->rxdpa); -} - -static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) -{ - uint i, curr; - struct sk_buff *rxp; - dma_addr_t pa; - - i = di->rxin; - - /* return if no packets posted */ - if (i == di->rxout) - return NULL; - - curr = - B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); - - /* ignore curr if forceall */ - if (!forceall && (i == curr)) - return NULL; - - /* get the packet pointer that corresponds to the rx descriptor */ - rxp = di->rxp[i]; - di->rxp[i] = NULL; - - pa = le32_to_cpu(di->rxd64[i].addrlow) - di->dataoffsetlow; - - /* clear this packet from the descriptor ring */ - pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); - - di->rxd64[i].addrlow = cpu_to_le32(0xdeadbeef); - di->rxd64[i].addrhigh = cpu_to_le32(0xdeadbeef); - - di->rxin = nextrxd(di, i); - - return rxp; -} - -static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) -{ - if (di->nrxd == 0) - return NULL; - - return dma64_getnextrxp(di, forceall); -} - -/* - * !! rx entry routine - * returns a pointer to the next frame received, or NULL if there are no more - * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is - * supported with pkts chain - * otherwise, it's treated as giant pkt and will be tossed. - * The DMA scattering starts with normal DMA header, followed by first - * buffer data. After it reaches the max size of buffer, the data continues - * in next DMA descriptor buffer WITHOUT DMA header - */ -struct sk_buff *dma_rx(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p, *head, *tail; - uint len; - uint pkt_len; - int resid = 0; - - next_frame: - head = _dma_getnextrxp(di, false); - if (head == NULL) - return NULL; - - len = le16_to_cpu(*(__le16 *) (head->data)); - DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); - dma_spin_for_len(len, head); - - /* set actual length */ - pkt_len = min((di->rxoffset + len), di->rxbufsize); - __skb_trim(head, pkt_len); - resid = len - (di->rxbufsize - di->rxoffset); - - /* check for single or multi-buffer rx */ - if (resid > 0) { - tail = head; - while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { - tail->next = p; - pkt_len = min_t(uint, resid, di->rxbufsize); - __skb_trim(p, pkt_len); - - tail = p; - resid -= di->rxbufsize; - } - -#ifdef BCMDBG - if (resid > 0) { - uint cur; - cur = - B2I(((R_REG(&di->d64rxregs->status0) & - D64_RS0_CD_MASK) - - di->rcvptrbase) & D64_RS0_CD_MASK, - struct dma64desc); - DMA_ERROR(("dma_rx, rxin %d rxout %d, hw_curr %d\n", - di->rxin, di->rxout, cur)); - } -#endif /* BCMDBG */ - - if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { - DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", - di->name, len)); - brcmu_pkt_buf_free_skb(head); - di->dma.rxgiants++; - goto next_frame; - } - } - - return head; -} - -static bool dma64_rxidle(struct dma_info *di) -{ - DMA_TRACE(("%s: dma_rxidle\n", di->name)); - - if (di->nrxd == 0) - return true; - - return ((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) == - (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); -} - -/* - * post receive buffers - * return false is refill failed completely and ring is empty this will stall - * the rx dma and user might want to call rxfill again asap. This unlikely - * happens on memory-rich NIC, but often on memory-constrained dongle - */ -bool dma_rxfill(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p; - u16 rxin, rxout; - u32 flags = 0; - uint n; - uint i; - dma_addr_t pa; - uint extra_offset = 0; - bool ring_empty; - - ring_empty = false; - - /* - * Determine how many receive buffers we're lacking - * from the full complement, allocate, initialize, - * and post them, then update the chip rx lastdscr. - */ - - rxin = di->rxin; - rxout = di->rxout; - - n = di->nrxpost - nrxdactive(di, rxin, rxout); - - DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n)); - - if (di->rxbufsize > BCMEXTRAHDROOM) - extra_offset = di->rxextrahdrroom; - - for (i = 0; i < n; i++) { - /* - * the di->rxbufsize doesn't include the extra headroom, - * we need to add it to the size to be allocated - */ - p = brcmu_pkt_buf_get_skb(di->rxbufsize + extra_offset); - - if (p == NULL) { - DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", - di->name)); - if (i == 0 && dma64_rxidle(di)) { - DMA_ERROR(("%s: rxfill64: ring is empty !\n", - di->name)); - ring_empty = true; - } - di->dma.rxnobuf++; - break; - } - /* reserve an extra headroom, if applicable */ - if (extra_offset) - skb_pull(p, extra_offset); - - /* Do a cached write instead of uncached write since DMA_MAP - * will flush the cache. - */ - *(u32 *) (p->data) = 0; - - pa = pci_map_single(di->pbus, p->data, - di->rxbufsize, PCI_DMA_FROMDEVICE); - - /* save the free packet pointer */ - di->rxp[rxout] = p; - - /* reset flags for each descriptor */ - flags = 0; - if (rxout == (di->nrxd - 1)) - flags = D64_CTRL1_EOT; - - dma64_dd_upd(di, di->rxd64, pa, rxout, &flags, - di->rxbufsize); - rxout = nextrxd(di, rxout); - } - - di->rxout = rxout; - - /* update the chip lastdscr pointer */ - W_REG(&di->d64rxregs->ptr, - di->rcvptrbase + I2B(rxout, struct dma64desc)); - - return ring_empty; -} - -void dma_rxreclaim(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p; - - DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); - - while ((p = _dma_getnextrxp(di, true))) - brcmu_pkt_buf_free_skb(p); -} - -void dma_counterreset(struct dma_pub *pub) -{ - /* reset all software counters */ - pub->rxgiants = 0; - pub->rxnobuf = 0; - pub->txnobuf = 0; -} - -/* get the address of the var in order to change later */ -unsigned long dma_getvar(struct dma_pub *pub, const char *name) -{ - struct dma_info *di = (struct dma_info *)pub; - - if (!strcmp(name, "&txavail")) - return (unsigned long)&(di->dma.txavail); - return 0; -} - -/* 64-bit DMA functions */ - -void dma_txinit(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - u32 control = D64_XC_XE; - - DMA_TRACE(("%s: dma_txinit\n", di->name)); - - if (di->ntxd == 0) - return; - - di->txin = di->txout = 0; - di->dma.txavail = di->ntxd - 1; - - /* clear tx descriptor ring */ - memset(di->txd64, '\0', (di->ntxd * sizeof(struct dma64desc))); - - /* DMA engine with out alignment requirement requires table to be inited - * before enabling the engine - */ - if (!di->aligndesc_4k) - _dma_ddtable_init(di, DMA_TX, di->txdpa); - - if ((di->dma.dmactrlflags & DMA_CTRL_PEN) == 0) - control |= D64_XC_PD; - OR_REG(&di->d64txregs->control, control); - - /* DMA engine with alignment requirement requires table to be inited - * before enabling the engine - */ - if (di->aligndesc_4k) - _dma_ddtable_init(di, DMA_TX, di->txdpa); -} - -void dma_txsuspend(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - - DMA_TRACE(("%s: dma_txsuspend\n", di->name)); - - if (di->ntxd == 0) - return; - - OR_REG(&di->d64txregs->control, D64_XC_SE); -} - -void dma_txresume(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - - DMA_TRACE(("%s: dma_txresume\n", di->name)); - - if (di->ntxd == 0) - return; - - AND_REG(&di->d64txregs->control, ~D64_XC_SE); -} - -bool dma_txsuspended(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - - return (di->ntxd == 0) || - ((R_REG(&di->d64txregs->control) & D64_XC_SE) == - D64_XC_SE); -} - -void dma_txreclaim(struct dma_pub *pub, enum txd_range range) -{ - struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p; - - DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, - (range == DMA_RANGE_ALL) ? "all" : - ((range == - DMA_RANGE_TRANSMITTED) ? "transmitted" : - "transferred"))); - - if (di->txin == di->txout) - return; - - while ((p = dma_getnexttxp(pub, range))) { - /* For unframed data, we don't have any packets to free */ - if (!(di->dma.dmactrlflags & DMA_CTRL_UNFRAMED)) - brcmu_pkt_buf_free_skb(p); - } -} - -bool dma_txreset(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - u32 status; - - if (di->ntxd == 0) - return true; - - /* suspend tx DMA first */ - W_REG(&di->d64txregs->control, D64_XC_SE); - SPINWAIT(((status = - (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) - != D64_XS0_XS_DISABLED) && (status != D64_XS0_XS_IDLE) - && (status != D64_XS0_XS_STOPPED), 10000); - - W_REG(&di->d64txregs->control, 0); - SPINWAIT(((status = - (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) - != D64_XS0_XS_DISABLED), 10000); - - /* wait for the last transaction to complete */ - udelay(300); - - return status == D64_XS0_XS_DISABLED; -} - -bool dma_rxreset(struct dma_pub *pub) -{ - struct dma_info *di = (struct dma_info *)pub; - u32 status; - - if (di->nrxd == 0) - return true; - - W_REG(&di->d64rxregs->control, 0); - SPINWAIT(((status = - (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) - != D64_RS0_RS_DISABLED), 10000); - - return status == D64_RS0_RS_DISABLED; -} - -/* - * !! tx entry routine - * WARNING: call must check the return value for error. - * the error(toss frames) could be fatal and cause many subsequent hard - * to debug problems - */ -int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) -{ - struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p, *next; - unsigned char *data; - uint len; - u16 txout; - u32 flags = 0; - dma_addr_t pa; - - DMA_TRACE(("%s: dma_txfast\n", di->name)); - - txout = di->txout; - - /* - * Walk the chain of packet buffers - * allocating and initializing transmit descriptor entries. - */ - for (p = p0; p; p = next) { - data = p->data; - len = p->len; - next = p->next; - - /* return nonzero if out of tx descriptors */ - if (nexttxd(di, txout) == di->txin) - goto outoftxd; - - if (len == 0) - continue; - - /* get physical address of buffer start */ - pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); - - flags = 0; - if (p == p0) - flags |= D64_CTRL1_SOF; - - /* With a DMA segment list, Descriptor table is filled - * using the segment list instead of looping over - * buffers in multi-chain DMA. Therefore, EOF for SGLIST - * is when end of segment list is reached. - */ - if (next == NULL) - flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF); - if (txout == (di->ntxd - 1)) - flags |= D64_CTRL1_EOT; - - dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - - txout = nexttxd(di, txout); - } - - /* if last txd eof not set, fix it */ - if (!(flags & D64_CTRL1_EOF)) - di->txd64[prevtxd(di, txout)].ctrl1 = - cpu_to_le32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); - - /* save the packet */ - di->txp[prevtxd(di, txout)] = p0; - - /* bump the tx descriptor index */ - di->txout = txout; - - /* kick the chip */ - if (commit) - W_REG(&di->d64txregs->ptr, - di->xmtptrbase + I2B(txout, struct dma64desc)); - - /* tx flow control */ - di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; - - return 0; - - outoftxd: - DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name)); - brcmu_pkt_buf_free_skb(p0); - di->dma.txavail = 0; - di->dma.txnobuf++; - return -1; -} - -/* - * Reclaim next completed txd (txds if using chained buffers) in the range - * specified and return associated packet. - * If range is DMA_RANGE_TRANSMITTED, reclaim descriptors that have be - * transmitted as noted by the hardware "CurrDescr" pointer. - * If range is DMA_RANGE_TRANSFERED, reclaim descriptors that have be - * transferred by the DMA as noted by the hardware "ActiveDescr" pointer. - * If range is DMA_RANGE_ALL, reclaim all txd(s) posted to the ring and - * return associated packet regardless of the value of hardware pointers. - */ -struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) -{ - struct dma_info *di = (struct dma_info *)pub; - u16 start, end, i; - u16 active_desc; - struct sk_buff *txp; - - DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, - (range == DMA_RANGE_ALL) ? "all" : - ((range == - DMA_RANGE_TRANSMITTED) ? "transmitted" : - "transferred"))); - - if (di->ntxd == 0) - return NULL; - - txp = NULL; - - start = di->txin; - if (range == DMA_RANGE_ALL) - end = di->txout; - else { - struct dma64regs __iomem *dregs = di->d64txregs; - - end = (u16) (B2I(((R_REG(&dregs->status0) & - D64_XS0_CD_MASK) - - di->xmtptrbase) & D64_XS0_CD_MASK, - struct dma64desc)); - - if (range == DMA_RANGE_TRANSFERED) { - active_desc = - (u16) (R_REG(&dregs->status1) & - D64_XS1_AD_MASK); - active_desc = - (active_desc - di->xmtptrbase) & D64_XS0_CD_MASK; - active_desc = B2I(active_desc, struct dma64desc); - if (end != active_desc) - end = prevtxd(di, active_desc); - } - } - - if ((start == 0) && (end > di->txout)) - goto bogus; - - for (i = start; i != end && !txp; i = nexttxd(di, i)) { - dma_addr_t pa; - uint size; - - pa = le32_to_cpu(di->txd64[i].addrlow) - di->dataoffsetlow; - - size = - (le32_to_cpu(di->txd64[i].ctrl2) & - D64_CTRL2_BC_MASK); - - di->txd64[i].addrlow = cpu_to_le32(0xdeadbeef); - di->txd64[i].addrhigh = cpu_to_le32(0xdeadbeef); - - txp = di->txp[i]; - di->txp[i] = NULL; - - pci_unmap_single(di->pbus, pa, size, PCI_DMA_TODEVICE); - } - - di->txin = i; - - /* tx flow control */ - di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; - - return txp; - - bogus: - DMA_NONE(("dma_getnexttxp: bogus curr: start %d end %d txout %d " - "force %d\n", start, end, di->txout, forceall)); - return NULL; -} - -/* - * Mac80211 initiated actions sometimes require packets in the DMA queue to be - * modified. The modified portion of the packet is not under control of the DMA - * engine. This function calls a caller-supplied function for each packet in - * the caller specified dma chain. - */ -void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) - (void *pkt, void *arg_a), void *arg_a) -{ - struct dma_info *di = (struct dma_info *) dmah; - uint i = di->txin; - uint end = di->txout; - struct sk_buff *skb; - struct ieee80211_tx_info *tx_info; - - while (i != end) { - skb = (struct sk_buff *)di->txp[i]; - if (skb != NULL) { - tx_info = (struct ieee80211_tx_info *)skb->cb; - (callback_fnc)(tx_info, arg_a); - } - i = nexttxd(di, i); - } -} diff --git a/drivers/staging/brcm80211/brcmsmac/dma.h b/drivers/staging/brcm80211/brcmsmac/dma.h deleted file mode 100644 index ebc5bc546f3..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/dma.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_DMA_H_ -#define _BRCM_DMA_H_ - -#include -#include "types.h" /* forward structure declarations */ - -/* map/unmap direction */ -#define DMA_TX 1 /* TX direction for DMA */ -#define DMA_RX 2 /* RX direction for DMA */ - -/* DMA structure: - * support two DMA engines: 32 bits address or 64 bit addressing - * basic DMA register set is per channel(transmit or receive) - * a pair of channels is defined for convenience - */ - -/* 32 bits addressing */ - -struct dma32diag { /* diag access */ - u32 fifoaddr; /* diag address */ - u32 fifodatalow; /* low 32bits of data */ - u32 fifodatahigh; /* high 32bits of data */ - u32 pad; /* reserved */ -}; - -/* 64 bits addressing */ - -/* dma registers per channel(xmt or rcv) */ -struct dma64regs { - u32 control; /* enable, et al */ - u32 ptr; /* last descriptor posted to chip */ - u32 addrlow; /* desc ring base address low 32-bits (8K aligned) */ - u32 addrhigh; /* desc ring base address bits 63:32 (8K aligned) */ - u32 status0; /* current descriptor, xmt state */ - u32 status1; /* active descriptor, xmt error */ -}; - -/* range param for dma_getnexttxp() and dma_txreclaim */ -enum txd_range { - DMA_RANGE_ALL = 1, - DMA_RANGE_TRANSMITTED, - DMA_RANGE_TRANSFERED -}; - -/* - * Exported data structure (read-only) - */ -/* export structure */ -struct dma_pub { - uint txavail; /* # free tx descriptors */ - uint dmactrlflags; /* dma control flags */ - - /* rx error counters */ - uint rxgiants; /* rx giant frames */ - uint rxnobuf; /* rx out of dma descriptors */ - /* tx error counters */ - uint txnobuf; /* tx out of dma descriptors */ -}; - -extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void __iomem *dmaregstx, void __iomem *dmaregsrx, - uint ntxd, uint nrxd, - uint rxbufsize, int rxextheadroom, - uint nrxpost, uint rxoffset, uint *msg_level); - -void dma_rxinit(struct dma_pub *pub); -struct sk_buff *dma_rx(struct dma_pub *pub); -bool dma_rxfill(struct dma_pub *pub); -bool dma_rxreset(struct dma_pub *pub); -bool dma_txreset(struct dma_pub *pub); -void dma_txinit(struct dma_pub *pub); -int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit); -void dma_txsuspend(struct dma_pub *pub); -bool dma_txsuspended(struct dma_pub *pub); -void dma_txresume(struct dma_pub *pub); -void dma_txreclaim(struct dma_pub *pub, enum txd_range range); -void dma_rxreclaim(struct dma_pub *pub); -void dma_detach(struct dma_pub *pub); -unsigned long dma_getvar(struct dma_pub *pub, const char *name); -struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range); -void dma_counterreset(struct dma_pub *pub); - -void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc) - (void *pkt, void *arg_a), void *arg_a); - -/* - * DMA(Bug) on bcm47xx chips seems to declare that the packet is ready, but - * the packet length is not updated yet (by DMA) on the expected time. - * Workaround is to hold processor till DMA updates the length, and stay off - * the bus to allow DMA update the length in buffer - */ -static inline void dma_spin_for_len(uint len, struct sk_buff *head) -{ -#if defined(CONFIG_BCM47XX) - if (!len) { - while (!(len = *(u16 *) KSEG1ADDR(head->data))) - udelay(1); - - *(u16 *) (head->data) = cpu_to_le16((u16) len); - } -#endif /* defined(CONFIG_BCM47XX) */ -} - -#endif /* _BRCM_DMA_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c b/drivers/staging/brcm80211/brcmsmac/mac80211_if.c deleted file mode 100644 index 185a098dd13..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.c +++ /dev/null @@ -1,1701 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#define __UNDEF_NO_VERSION__ - -#include -#include -#include -#include -#include -#include -#include -#include "nicpci.h" -#include "phy/phy_int.h" -#include "d11.h" -#include "channel.h" -#include "scb.h" -#include "pub.h" -#include "ucode_loader.h" -#include "mac80211_if.h" -#include "main.h" - -#define N_TX_QUEUES 4 /* #tx queues on mac80211<->driver interface */ - -/* Flags we support */ -#define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ - FIF_ALLMULTI | \ - FIF_FCSFAIL | \ - FIF_PLCPFAIL | \ - FIF_CONTROL | \ - FIF_OTHER_BSS | \ - FIF_BCN_PRBRESP_PROMISC) - -#define CHAN2GHZ(channel, freqency, chflags) { \ - .band = IEEE80211_BAND_2GHZ, \ - .center_freq = (freqency), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 19, \ -} - -#define CHAN5GHZ(channel, chflags) { \ - .band = IEEE80211_BAND_5GHZ, \ - .center_freq = 5000 + 5*(channel), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 21, \ -} - -#define RATE(rate100m, _flags) { \ - .bitrate = (rate100m), \ - .flags = (_flags), \ - .hw_value = (rate100m / 5), \ -} - -struct firmware_hdr { - __le32 offset; - __le32 len; - __le32 idx; -}; - -static const char * const brcms_firmwares[MAX_FW_IMAGES] = { - "brcm/bcm43xx", - NULL -}; - -static int n_adapters_found; - -MODULE_AUTHOR("Broadcom Corporation"); -MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); -MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); -MODULE_LICENSE("Dual BSD/GPL"); - -/* recognized PCI IDs */ -static DEFINE_PCI_DEVICE_TABLE(brcms_pci_id_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, /* 43225 2G */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, /* 43224 DUAL */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, /* 4313 DUAL */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, /* 43224 Ven */ - {0} -}; - -MODULE_DEVICE_TABLE(pci, brcms_pci_id_table); - -#ifdef BCMDBG -static int msglevel = 0xdeadbeef; -module_param(msglevel, int, 0); -#endif /* BCMDBG */ - -static struct ieee80211_channel brcms_2ghz_chantable[] = { - CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS), - CHAN2GHZ(5, 2432, 0), - CHAN2GHZ(6, 2437, 0), - CHAN2GHZ(7, 2442, 0), - CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(12, 2467, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(13, 2472, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS), - CHAN2GHZ(14, 2484, - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) -}; - -static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { - /* UNII-1 */ - CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS), - /* UNII-2 */ - CHAN5GHZ(52, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(56, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(60, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(64, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - /* MID */ - CHAN5GHZ(100, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(104, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(108, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(112, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(116, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(120, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(124, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(128, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(132, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(136, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(140, - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS | - IEEE80211_CHAN_NO_HT40MINUS), - /* UNII-3 */ - CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS), - CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS), - CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) -}; - -/* - * The rate table is used for both 2.4G and 5G rates. The - * latter being a subset as it does not support CCK rates. - */ -static struct ieee80211_rate legacy_ratetable[] = { - RATE(10, 0), - RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(55, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(110, IEEE80211_RATE_SHORT_PREAMBLE), - RATE(60, 0), - RATE(90, 0), - RATE(120, 0), - RATE(180, 0), - RATE(240, 0), - RATE(360, 0), - RATE(480, 0), - RATE(540, 0), -}; - -static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { - .band = IEEE80211_BAND_2GHZ, - .channels = brcms_2ghz_chantable, - .n_channels = ARRAY_SIZE(brcms_2ghz_chantable), - .bitrates = legacy_ratetable, - .n_bitrates = ARRAY_SIZE(legacy_ratetable), - .ht_cap = { - /* from include/linux/ieee80211.h */ - .cap = IEEE80211_HT_CAP_GRN_FLD | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, - .ht_supported = true, - .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, - .ampdu_density = AMPDU_DEF_MPDU_DENSITY, - .mcs = { - /* placeholders for now */ - .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = cpu_to_le16(500), - .tx_params = IEEE80211_HT_MCS_TX_DEFINED} - } -}; - -static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { - .band = IEEE80211_BAND_5GHZ, - .channels = brcms_5ghz_nphy_chantable, - .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), - .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET, - .n_bitrates = ARRAY_SIZE(legacy_ratetable) - - BRCMS_LEGACY_5G_RATE_OFFSET, - .ht_cap = { - .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ - .ht_supported = true, - .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, - .ampdu_density = AMPDU_DEF_MPDU_DENSITY, - .mcs = { - /* placeholders for now */ - .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, - .rx_highest = cpu_to_le16(500), - .tx_params = IEEE80211_HT_MCS_TX_DEFINED} - } -}; - -/* flags the given rate in rateset as requested */ -static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br) -{ - u32 i; - - for (i = 0; i < rs->count; i++) { - if (rate != (rs->rates[i] & 0x7f)) - continue; - - if (is_br) - rs->rates[i] |= BRCMS_RATE_FLAG; - else - rs->rates[i] &= BRCMS_RATE_MASK; - return; - } -} - -static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct brcms_info *wl = hw->priv; - - spin_lock_bh(&wl->lock); - if (!wl->pub->up) { - wiphy_err(wl->wiphy, "ops->tx called while down\n"); - kfree_skb(skb); - goto done; - } - brcms_c_sendpkt_mac80211(wl->wlc, skb, hw); - done: - spin_unlock_bh(&wl->lock); -} - -static int brcms_ops_start(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = hw->priv; - bool blocked; - - ieee80211_wake_queues(hw); - spin_lock_bh(&wl->lock); - blocked = brcms_rfkill_set_hw_state(wl); - spin_unlock_bh(&wl->lock); - if (!blocked) - wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); - - return 0; -} - -static void brcms_ops_stop(struct ieee80211_hw *hw) -{ - ieee80211_stop_queues(hw); -} - -static int -brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -{ - struct brcms_info *wl; - int err; - - /* Just STA for now */ - if (vif->type != NL80211_IFTYPE_AP && - vif->type != NL80211_IFTYPE_MESH_POINT && - vif->type != NL80211_IFTYPE_STATION && - vif->type != NL80211_IFTYPE_WDS && - vif->type != NL80211_IFTYPE_ADHOC) { - wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" - " STA for now\n", __func__, vif->type); - return -EOPNOTSUPP; - } - - wl = hw->priv; - spin_lock_bh(&wl->lock); - if (!wl->pub->up) - err = brcms_up(wl); - else - err = -ENODEV; - spin_unlock_bh(&wl->lock); - - if (err != 0) - wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, - err); - - return err; -} - -static void -brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -{ - struct brcms_info *wl; - - wl = hw->priv; - - /* put driver in down state */ - spin_lock_bh(&wl->lock); - brcms_down(wl); - spin_unlock_bh(&wl->lock); -} - -static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) -{ - struct ieee80211_conf *conf = &hw->conf; - struct brcms_info *wl = hw->priv; - int err = 0; - int new_int; - struct wiphy *wiphy = hw->wiphy; - - spin_lock_bh(&wl->lock); - if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { - brcms_c_set_beacon_listen_interval(wl->wlc, - conf->listen_interval); - } - if (changed & IEEE80211_CONF_CHANGE_MONITOR) - wiphy_err(wiphy, "%s: change monitor mode: %s (implement)\n", - __func__, conf->flags & IEEE80211_CONF_MONITOR ? - "true" : "false"); - if (changed & IEEE80211_CONF_CHANGE_PS) - wiphy_err(wiphy, "%s: change power-save mode: %s (implement)\n", - __func__, conf->flags & IEEE80211_CONF_PS ? - "true" : "false"); - - if (changed & IEEE80211_CONF_CHANGE_POWER) { - err = brcms_c_set_tx_power(wl->wlc, conf->power_level); - if (err < 0) { - wiphy_err(wiphy, "%s: Error setting power_level\n", - __func__); - goto config_out; - } - new_int = brcms_c_get_tx_power(wl->wlc); - if (new_int != conf->power_level) - wiphy_err(wiphy, "%s: Power level req != actual, %d %d" - "\n", __func__, conf->power_level, - new_int); - } - if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { - if (conf->channel_type == NL80211_CHAN_HT20 || - conf->channel_type == NL80211_CHAN_NO_HT) - err = brcms_c_set_channel(wl->wlc, - conf->channel->hw_value); - else - err = -ENOTSUPP; - } - if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) - err = brcms_c_set_rate_limit(wl->wlc, - conf->short_frame_max_tx_count, - conf->long_frame_max_tx_count); - - config_out: - spin_unlock_bh(&wl->lock); - return err; -} - -static void -brcms_ops_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *info, u32 changed) -{ - struct brcms_info *wl = hw->priv; - struct wiphy *wiphy = hw->wiphy; - - if (changed & BSS_CHANGED_ASSOC) { - /* association status changed (associated/disassociated) - * also implies a change in the AID. - */ - wiphy_err(wiphy, "%s: %s: %sassociated\n", KBUILD_MODNAME, - __func__, info->assoc ? "" : "dis"); - spin_lock_bh(&wl->lock); - brcms_c_associate_upd(wl->wlc, info->assoc); - spin_unlock_bh(&wl->lock); - } - if (changed & BSS_CHANGED_ERP_SLOT) { - s8 val; - - /* slot timing changed */ - if (info->use_short_slot) - val = 1; - else - val = 0; - spin_lock_bh(&wl->lock); - brcms_c_set_shortslot_override(wl->wlc, val); - spin_unlock_bh(&wl->lock); - } - - if (changed & BSS_CHANGED_HT) { - /* 802.11n parameters changed */ - u16 mode = info->ht_operation_mode; - - spin_lock_bh(&wl->lock); - brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG, - mode & IEEE80211_HT_OP_MODE_PROTECTION); - brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF, - mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); - brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS, - mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT); - spin_unlock_bh(&wl->lock); - } - if (changed & BSS_CHANGED_BASIC_RATES) { - struct ieee80211_supported_band *bi; - u32 br_mask, i; - u16 rate; - struct brcm_rateset rs; - int error; - - /* retrieve the current rates */ - spin_lock_bh(&wl->lock); - brcms_c_get_current_rateset(wl->wlc, &rs); - spin_unlock_bh(&wl->lock); - - br_mask = info->basic_rates; - bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)]; - for (i = 0; i < bi->n_bitrates; i++) { - /* convert to internal rate value */ - rate = (bi->bitrates[i].bitrate << 1) / 10; - - /* set/clear basic rate flag */ - brcms_set_basic_rate(&rs, rate, br_mask & 1); - br_mask >>= 1; - } - - /* update the rate set */ - spin_lock_bh(&wl->lock); - error = brcms_c_set_rateset(wl->wlc, &rs); - spin_unlock_bh(&wl->lock); - if (error) - wiphy_err(wiphy, "changing basic rates failed: %d\n", - error); - } - if (changed & BSS_CHANGED_BEACON_INT) { - /* Beacon interval changed */ - spin_lock_bh(&wl->lock); - brcms_c_set_beacon_period(wl->wlc, info->beacon_int); - spin_unlock_bh(&wl->lock); - } - if (changed & BSS_CHANGED_BSSID) { - /* BSSID changed, for whatever reason (IBSS and managed mode) */ - spin_lock_bh(&wl->lock); - brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid); - spin_unlock_bh(&wl->lock); - } - if (changed & BSS_CHANGED_BEACON) - /* Beacon data changed, retrieve new beacon (beaconing modes) */ - wiphy_err(wiphy, "%s: beacon changed\n", __func__); - - if (changed & BSS_CHANGED_BEACON_ENABLED) { - /* Beaconing should be enabled/disabled (beaconing modes) */ - wiphy_err(wiphy, "%s: Beacon enabled: %s\n", __func__, - info->enable_beacon ? "true" : "false"); - } - - if (changed & BSS_CHANGED_CQM) { - /* Connection quality monitor config changed */ - wiphy_err(wiphy, "%s: cqm change: threshold %d, hys %d " - " (implement)\n", __func__, info->cqm_rssi_thold, - info->cqm_rssi_hyst); - } - - if (changed & BSS_CHANGED_IBSS) { - /* IBSS join status changed */ - wiphy_err(wiphy, "%s: IBSS joined: %s (implement)\n", __func__, - info->ibss_joined ? "true" : "false"); - } - - if (changed & BSS_CHANGED_ARP_FILTER) { - /* Hardware ARP filter address list or state changed */ - wiphy_err(wiphy, "%s: arp filtering: enabled %s, count %d" - " (implement)\n", __func__, info->arp_filter_enabled ? - "true" : "false", info->arp_addr_cnt); - } - - if (changed & BSS_CHANGED_QOS) { - /* - * QoS for this association was enabled/disabled. - * Note that it is only ever disabled for station mode. - */ - wiphy_err(wiphy, "%s: qos enabled: %s (implement)\n", __func__, - info->qos ? "true" : "false"); - } - return; -} - -static void -brcms_ops_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, u64 multicast) -{ - struct brcms_info *wl = hw->priv; - struct wiphy *wiphy = hw->wiphy; - - changed_flags &= MAC_FILTERS; - *total_flags &= MAC_FILTERS; - if (changed_flags & FIF_PROMISC_IN_BSS) - wiphy_err(wiphy, "FIF_PROMISC_IN_BSS\n"); - if (changed_flags & FIF_ALLMULTI) - wiphy_err(wiphy, "FIF_ALLMULTI\n"); - if (changed_flags & FIF_FCSFAIL) - wiphy_err(wiphy, "FIF_FCSFAIL\n"); - if (changed_flags & FIF_PLCPFAIL) - wiphy_err(wiphy, "FIF_PLCPFAIL\n"); - if (changed_flags & FIF_CONTROL) - wiphy_err(wiphy, "FIF_CONTROL\n"); - if (changed_flags & FIF_OTHER_BSS) - wiphy_err(wiphy, "FIF_OTHER_BSS\n"); - if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { - spin_lock_bh(&wl->lock); - if (*total_flags & FIF_BCN_PRBRESP_PROMISC) { - wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS; - brcms_c_mac_bcn_promisc_change(wl->wlc, 1); - } else { - brcms_c_mac_bcn_promisc_change(wl->wlc, 0); - wl->pub->mac80211_state &= ~MAC80211_PROMISC_BCNS; - } - spin_unlock_bh(&wl->lock); - } - return; -} - -static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = hw->priv; - spin_lock_bh(&wl->lock); - brcms_c_scan_start(wl->wlc); - spin_unlock_bh(&wl->lock); - return; -} - -static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = hw->priv; - spin_lock_bh(&wl->lock); - brcms_c_scan_stop(wl->wlc); - spin_unlock_bh(&wl->lock); - return; -} - -static int -brcms_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, - const struct ieee80211_tx_queue_params *params) -{ - struct brcms_info *wl = hw->priv; - - spin_lock_bh(&wl->lock); - brcms_c_wme_setparams(wl->wlc, queue, params, true); - spin_unlock_bh(&wl->lock); - - return 0; -} - -static int -brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct brcms_info *wl = hw->priv; - struct scb *scb = &wl->wlc->pri_scb; - - brcms_c_init_scb(scb); - - wl->pub->global_ampdu = &(scb->scb_ampdu); - wl->pub->global_ampdu->scb = scb; - wl->pub->global_ampdu->max_pdu = 16; - - sta->ht_cap.ht_supported = true; - sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; - sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; - sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; - - /* - * minstrel_ht initiates addBA on our behalf by calling - * ieee80211_start_tx_ba_session() - */ - return 0; -} - -static int -brcms_ops_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) -{ - struct brcms_info *wl = hw->priv; - struct scb *scb = &wl->wlc->pri_scb; - int status; - - if (WARN_ON(scb->magic != SCB_MAGIC)) - return -EIDRM; - switch (action) { - case IEEE80211_AMPDU_RX_START: - break; - case IEEE80211_AMPDU_RX_STOP: - break; - case IEEE80211_AMPDU_TX_START: - spin_lock_bh(&wl->lock); - status = brcms_c_aggregatable(wl->wlc, tid); - spin_unlock_bh(&wl->lock); - if (!status) { - wiphy_err(wl->wiphy, "START: tid %d is not agg\'able\n", - tid); - return -EINVAL; - } - ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); - break; - - case IEEE80211_AMPDU_TX_STOP: - spin_lock_bh(&wl->lock); - brcms_c_ampdu_flush(wl->wlc, sta, tid); - spin_unlock_bh(&wl->lock); - ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); - break; - case IEEE80211_AMPDU_TX_OPERATIONAL: - /* - * BA window size from ADDBA response ('buf_size') defines how - * many outstanding MPDUs are allowed for the BA stream by - * recipient and traffic class. 'ampdu_factor' gives maximum - * AMPDU size. - */ - spin_lock_bh(&wl->lock); - brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size, - (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + - sta->ht_cap.ampdu_factor)) - 1); - spin_unlock_bh(&wl->lock); - /* Power save wakeup */ - break; - default: - wiphy_err(wl->wiphy, "%s: Invalid command, ignoring\n", - __func__); - } - - return 0; -} - -static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = hw->priv; - bool blocked; - - spin_lock_bh(&wl->lock); - blocked = brcms_c_check_radio_disabled(wl->wlc); - spin_unlock_bh(&wl->lock); - - wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); -} - -static void brcms_ops_flush(struct ieee80211_hw *hw, bool drop) -{ - struct brcms_info *wl = hw->priv; - - no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false"); - - /* wait for packet queue and dma fifos to run empty */ - spin_lock_bh(&wl->lock); - brcms_c_wait_for_tx_completion(wl->wlc, drop); - spin_unlock_bh(&wl->lock); -} - -static const struct ieee80211_ops brcms_ops = { - .tx = brcms_ops_tx, - .start = brcms_ops_start, - .stop = brcms_ops_stop, - .add_interface = brcms_ops_add_interface, - .remove_interface = brcms_ops_remove_interface, - .config = brcms_ops_config, - .bss_info_changed = brcms_ops_bss_info_changed, - .configure_filter = brcms_ops_configure_filter, - .sw_scan_start = brcms_ops_sw_scan_start, - .sw_scan_complete = brcms_ops_sw_scan_complete, - .conf_tx = brcms_ops_conf_tx, - .sta_add = brcms_ops_sta_add, - .ampdu_action = brcms_ops_ampdu_action, - .rfkill_poll = brcms_ops_rfkill_poll, - .flush = brcms_ops_flush, -}; - -/* - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static int brcms_set_hint(struct brcms_info *wl, char *abbrev) -{ - return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); -} - -void brcms_dpc(unsigned long data) -{ - struct brcms_info *wl; - - wl = (struct brcms_info *) data; - - spin_lock_bh(&wl->lock); - - /* call the common second level interrupt handler */ - if (wl->pub->up) { - if (wl->resched) { - unsigned long flags; - - spin_lock_irqsave(&wl->isr_lock, flags); - brcms_c_intrsupd(wl->wlc); - spin_unlock_irqrestore(&wl->isr_lock, flags); - } - - wl->resched = brcms_c_dpc(wl->wlc, true); - } - - /* brcms_c_dpc() may bring the driver down */ - if (!wl->pub->up) - goto done; - - /* re-schedule dpc */ - if (wl->resched) - tasklet_schedule(&wl->tasklet); - else - /* re-enable interrupts */ - brcms_intrson(wl); - - done: - spin_unlock_bh(&wl->lock); -} - -/* - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev) -{ - int status; - struct device *device = &pdev->dev; - char fw_name[100]; - int i; - - memset(&wl->fw, 0, sizeof(struct brcms_firmware)); - for (i = 0; i < MAX_FW_IMAGES; i++) { - if (brcms_firmwares[i] == NULL) - break; - sprintf(fw_name, "%s-%d.fw", brcms_firmwares[i], - UCODE_LOADER_API_VER); - status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); - if (status) { - wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - return status; - } - sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i], - UCODE_LOADER_API_VER); - status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); - if (status) { - wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - return status; - } - wl->fw.hdr_num_entries[i] = - wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr)); - } - wl->fw.fw_cnt = i; - return brcms_ucode_data_init(wl, &wl->ucode); -} - -/* - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -static void brcms_release_fw(struct brcms_info *wl) -{ - int i; - for (i = 0; i < MAX_FW_IMAGES; i++) { - release_firmware(wl->fw.fw_bin[i]); - release_firmware(wl->fw.fw_hdr[i]); - } -} - -/** - * This function frees the WL per-device resources. - * - * This function frees resources owned by the WL device pointed to - * by the wl parameter. - * - * precondition: can both be called locked and unlocked - * - */ -static void brcms_free(struct brcms_info *wl) -{ - struct brcms_timer *t, *next; - - /* free ucode data */ - if (wl->fw.fw_cnt) - brcms_ucode_data_free(&wl->ucode); - if (wl->irq) - free_irq(wl->irq, wl); - - /* kill dpc */ - tasklet_kill(&wl->tasklet); - - if (wl->pub) - brcms_c_module_unregister(wl->pub, "linux", wl); - - /* free common resources */ - if (wl->wlc) { - brcms_c_detach(wl->wlc); - wl->wlc = NULL; - wl->pub = NULL; - } - - /* virtual interface deletion is deferred so we cannot spinwait */ - - /* wait for all pending callbacks to complete */ - while (atomic_read(&wl->callbacks) > 0) - schedule(); - - /* free timers */ - for (t = wl->timers; t; t = next) { - next = t->next; -#ifdef BCMDBG - kfree(t->name); -#endif - kfree(t); - } - - /* - * unregister_netdev() calls get_stats() which may read chip - * registers so we cannot unmap the chip registers until - * after calling unregister_netdev() . - */ - if (wl->regsva) - iounmap(wl->regsva); - - wl->regsva = NULL; -} - -/* -* called from both kernel as from this kernel module. -* precondition: perimeter lock is not acquired. -*/ -static void brcms_remove(struct pci_dev *pdev) -{ - struct brcms_info *wl; - struct ieee80211_hw *hw; - int status; - - hw = pci_get_drvdata(pdev); - wl = hw->priv; - if (!wl) { - pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); - return; - } - - spin_lock_bh(&wl->lock); - status = brcms_c_chipmatch(pdev->vendor, pdev->device); - spin_unlock_bh(&wl->lock); - if (!status) { - wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " - "failed\n"); - return; - } - if (wl->wlc) { - wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); - wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); - ieee80211_unregister_hw(hw); - spin_lock_bh(&wl->lock); - brcms_down(wl); - spin_unlock_bh(&wl->lock); - } - pci_disable_device(pdev); - - brcms_free(wl); - - pci_set_drvdata(pdev, NULL); - ieee80211_free_hw(hw); -} - -static irqreturn_t brcms_isr(int irq, void *dev_id) -{ - struct brcms_info *wl; - bool ours, wantdpc; - - wl = (struct brcms_info *) dev_id; - - spin_lock(&wl->isr_lock); - - /* call common first level interrupt handler */ - ours = brcms_c_isr(wl->wlc, &wantdpc); - if (ours) { - /* if more to do... */ - if (wantdpc) { - - /* ...and call the second level interrupt handler */ - /* schedule dpc */ - tasklet_schedule(&wl->tasklet); - } - } - - spin_unlock(&wl->isr_lock); - - return IRQ_RETVAL(ours); -} - -/* - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static int ieee_hw_rate_init(struct ieee80211_hw *hw) -{ - struct brcms_info *wl = hw->priv; - struct brcms_c_info *wlc = wl->wlc; - struct ieee80211_supported_band *band; - int has_5g = 0; - u16 phy_type; - - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; - hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; - - phy_type = brcms_c_get_phy_type(wl->wlc, 0); - if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) { - band = &wlc->bandstate[BAND_2G_INDEX]->band; - *band = brcms_band_2GHz_nphy_template; - if (phy_type == PHY_TYPE_LCN) { - /* Single stream */ - band->ht_cap.mcs.rx_mask[1] = 0; - band->ht_cap.mcs.rx_highest = 72; - } - hw->wiphy->bands[IEEE80211_BAND_2GHZ] = band; - } else { - return -EPERM; - } - - /* Assume all bands use the same phy. True for 11n devices. */ - if (wl->pub->_nbands > 1) { - has_5g++; - if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) { - band = &wlc->bandstate[BAND_5G_INDEX]->band; - *band = brcms_band_5GHz_nphy_template; - hw->wiphy->bands[IEEE80211_BAND_5GHZ] = band; - } else { - return -EPERM; - } - } - return 0; -} - -/* - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static int ieee_hw_init(struct ieee80211_hw *hw) -{ - hw->flags = IEEE80211_HW_SIGNAL_DBM - /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */ - | IEEE80211_HW_REPORTS_TX_ACK_STATUS - | IEEE80211_HW_AMPDU_AGGREGATION; - - hw->extra_tx_headroom = brcms_c_get_header_len(); - hw->queues = N_TX_QUEUES; - hw->max_rates = 2; /* Primary rate and 1 fallback rate */ - - /* channel change time is dependent on chip and band */ - hw->channel_change_time = 7 * 1000; - hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); - - hw->rate_control_algorithm = "minstrel_ht"; - - hw->sta_data_size = 0; - return ieee_hw_rate_init(hw); -} - -/** - * attach to the WL device. - * - * Attach to the WL device identified by vendor and device parameters. - * regs is a host accessible memory address pointing to WL device registers. - * - * brcms_attach is not defined as static because in the case where no bus - * is defined, wl_attach will never be called, and thus, gcc will issue - * a warning that this function is defined but not used if we declare - * it as static. - * - * - * is called in brcms_pci_probe() context, therefore no locking required. - */ -static struct brcms_info *brcms_attach(u16 vendor, u16 device, - resource_size_t regs, - struct pci_dev *btparam, uint irq) -{ - struct brcms_info *wl = NULL; - int unit, err; - struct ieee80211_hw *hw; - u8 perm[ETH_ALEN]; - - unit = n_adapters_found; - err = 0; - - if (unit < 0) - return NULL; - - /* allocate private info */ - hw = pci_get_drvdata(btparam); /* btparam == pdev */ - if (hw != NULL) - wl = hw->priv; - if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL)) - return NULL; - wl->wiphy = hw->wiphy; - - atomic_set(&wl->callbacks, 0); - - /* setup the bottom half handler */ - tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl); - - wl->regsva = ioremap_nocache(regs, PCI_BAR0_WINSZ); - if (wl->regsva == NULL) { - wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit); - goto fail; - } - spin_lock_init(&wl->lock); - spin_lock_init(&wl->isr_lock); - - /* prepare ucode */ - if (brcms_request_fw(wl, btparam) < 0) { - wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in " - "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm"); - brcms_release_fw(wl); - brcms_remove(btparam); - return NULL; - } - - /* common load-time initialization */ - wl->wlc = brcms_c_attach(wl, vendor, device, unit, false, - wl->regsva, btparam, &err); - brcms_release_fw(wl); - if (!wl->wlc) { - wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n", - KBUILD_MODNAME, err); - goto fail; - } - wl->pub = brcms_c_pub(wl->wlc); - - wl->pub->ieee_hw = hw; - - /* disable mpc */ - brcms_c_set_radio_mpc(wl->wlc, false); - - /* register our interrupt handler */ - if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { - wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); - goto fail; - } - wl->irq = irq; - - /* register module */ - brcms_c_module_register(wl->pub, "linux", wl, NULL); - - if (ieee_hw_init(hw)) { - wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit, - __func__); - goto fail; - } - - memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN); - if (WARN_ON(!is_valid_ether_addr(perm))) - goto fail; - SET_IEEE80211_PERM_ADDR(hw, perm); - - err = ieee80211_register_hw(hw); - if (err) - wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status" - "%d\n", __func__, err); - - if (wl->pub->srom_ccode[0]) - err = brcms_set_hint(wl, wl->pub->srom_ccode); - else - err = brcms_set_hint(wl, "US"); - if (err) - wiphy_err(wl->wiphy, "%s: regulatory_hint failed, status %d\n", - __func__, err); - - n_adapters_found++; - return wl; - -fail: - brcms_free(wl); - return NULL; -} - - - -/** - * determines if a device is a WL device, and if so, attaches it. - * - * This function determines if a device pointed to by pdev is a WL device, - * and if so, performs a brcms_attach() on it. - * - * Perimeter lock is initialized in the course of this function. - */ -static int __devinit -brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - int rc; - struct brcms_info *wl; - struct ieee80211_hw *hw; - u32 val; - - dev_info(&pdev->dev, "bus %d slot %d func %d irq %d\n", - pdev->bus->number, PCI_SLOT(pdev->devfn), - PCI_FUNC(pdev->devfn), pdev->irq); - - if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || - ((pdev->device != 0x0576) && - ((pdev->device & 0xff00) != 0x4300) && - ((pdev->device & 0xff00) != 0x4700) && - ((pdev->device < 43000) || (pdev->device > 43999)))) - return -ENODEV; - - rc = pci_enable_device(pdev); - if (rc) { - pr_err("%s: Cannot enable device %d-%d_%d\n", - __func__, pdev->bus->number, PCI_SLOT(pdev->devfn), - PCI_FUNC(pdev->devfn)); - return -ENODEV; - } - pci_set_master(pdev); - - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - - hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops); - if (!hw) { - pr_err("%s: ieee80211_alloc_hw failed\n", __func__); - return -ENOMEM; - } - - SET_IEEE80211_DEV(hw, &pdev->dev); - - pci_set_drvdata(pdev, hw); - - memset(hw->priv, 0, sizeof(*wl)); - - wl = brcms_attach(pdev->vendor, pdev->device, - pci_resource_start(pdev, 0), pdev, - pdev->irq); - - if (!wl) { - pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME, - __func__); - return -ENODEV; - } - return 0; -} - -static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) -{ - struct brcms_info *wl; - struct ieee80211_hw *hw; - - hw = pci_get_drvdata(pdev); - wl = hw->priv; - if (!wl) { - wiphy_err(wl->wiphy, - "brcms_suspend: pci_get_drvdata failed\n"); - return -ENODEV; - } - - /* only need to flag hw is down for proper resume */ - spin_lock_bh(&wl->lock); - wl->pub->hw_up = false; - spin_unlock_bh(&wl->lock); - - pci_save_state(pdev); - pci_disable_device(pdev); - return pci_set_power_state(pdev, PCI_D3hot); -} - -static int brcms_resume(struct pci_dev *pdev) -{ - struct brcms_info *wl; - struct ieee80211_hw *hw; - int err = 0; - u32 val; - - hw = pci_get_drvdata(pdev); - wl = hw->priv; - if (!wl) { - wiphy_err(wl->wiphy, - "wl: brcms_resume: pci_get_drvdata failed\n"); - return -ENODEV; - } - - err = pci_set_power_state(pdev, PCI_D0); - if (err) - return err; - - pci_restore_state(pdev); - - err = pci_enable_device(pdev); - if (err) - return err; - - pci_set_master(pdev); - - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - - /* - * done. driver will be put in up state - * in brcms_ops_add_interface() call. - */ - return err; -} - -static struct pci_driver brcms_pci_driver = { - .name = KBUILD_MODNAME, - .probe = brcms_pci_probe, - .suspend = brcms_suspend, - .resume = brcms_resume, - .remove = __devexit_p(brcms_remove), - .id_table = brcms_pci_id_table, -}; - -/** - * This is the main entry point for the WL driver. - * - * This function determines if a device pointed to by pdev is a WL device, - * and if so, performs a brcms_attach() on it. - * - */ -static int __init brcms_module_init(void) -{ - int error = -ENODEV; - -#ifdef BCMDBG - if (msglevel != 0xdeadbeef) - brcm_msg_level = msglevel; -#endif /* BCMDBG */ - - error = pci_register_driver(&brcms_pci_driver); - if (!error) - return 0; - - - - return error; -} - -/** - * This function unloads the WL driver from the system. - * - * This function unconditionally unloads the WL driver module from the - * system. - * - */ -static void __exit brcms_module_exit(void) -{ - pci_unregister_driver(&brcms_pci_driver); - -} - -module_init(brcms_module_init); -module_exit(brcms_module_exit); - -/* - * precondition: perimeter lock has been acquired - */ -void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif, - bool state, int prio) -{ - wiphy_err(wl->wiphy, "Shouldn't be here %s\n", __func__); -} - -/* - * precondition: perimeter lock has been acquired - */ -void brcms_init(struct brcms_info *wl) -{ - BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); - brcms_reset(wl); - - brcms_c_init(wl->wlc); -} - -/* - * precondition: perimeter lock has been acquired - */ -uint brcms_reset(struct brcms_info *wl) -{ - BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); - brcms_c_reset(wl->wlc); - - /* dpc will not be rescheduled */ - wl->resched = 0; - - return 0; -} - -/* - * These are interrupt on/off entry points. Disable interrupts - * during interrupt state transition. - */ -void brcms_intrson(struct brcms_info *wl) -{ - unsigned long flags; - - spin_lock_irqsave(&wl->isr_lock, flags); - brcms_c_intrson(wl->wlc); - spin_unlock_irqrestore(&wl->isr_lock, flags); -} - -u32 brcms_intrsoff(struct brcms_info *wl) -{ - unsigned long flags; - u32 status; - - spin_lock_irqsave(&wl->isr_lock, flags); - status = brcms_c_intrsoff(wl->wlc); - spin_unlock_irqrestore(&wl->isr_lock, flags); - return status; -} - -void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask) -{ - unsigned long flags; - - spin_lock_irqsave(&wl->isr_lock, flags); - brcms_c_intrsrestore(wl->wlc, macintmask); - spin_unlock_irqrestore(&wl->isr_lock, flags); -} - -/* - * precondition: perimeter lock has been acquired - */ -int brcms_up(struct brcms_info *wl) -{ - int error = 0; - - if (wl->pub->up) - return 0; - - error = brcms_c_up(wl->wlc); - - return error; -} - -/* - * precondition: perimeter lock has been acquired - */ -void brcms_down(struct brcms_info *wl) -{ - uint callbacks, ret_val = 0; - - /* call common down function */ - ret_val = brcms_c_down(wl->wlc); - callbacks = atomic_read(&wl->callbacks) - ret_val; - - /* wait for down callbacks to complete */ - spin_unlock_bh(&wl->lock); - - /* For HIGH_only driver, it's important to actually schedule other work, - * not just spin wait since everything runs at schedule level - */ - SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000); - - spin_lock_bh(&wl->lock); -} - -/* -* precondition: perimeter lock is not acquired - */ -void brcms_timer(struct brcms_timer *t) -{ - spin_lock_bh(&t->wl->lock); - - if (t->set) { - if (t->periodic) { - t->timer.expires = jiffies + t->ms * HZ / 1000; - atomic_inc(&t->wl->callbacks); - add_timer(&t->timer); - t->set = true; - } else - t->set = false; - - t->fn(t->arg); - } - - atomic_dec(&t->wl->callbacks); - - spin_unlock_bh(&t->wl->lock); -} - -/* - * is called by the kernel from software irq context - */ -static void _brcms_timer(unsigned long data) -{ - brcms_timer((struct brcms_timer *) data); -} - -/* - * Adds a timer to the list. Caller supplies a timer function. - * Is called from wlc. - * - * precondition: perimeter lock has been acquired - */ -struct brcms_timer *brcms_init_timer(struct brcms_info *wl, - void (*fn) (void *arg), - void *arg, const char *name) -{ - struct brcms_timer *t; - - t = kzalloc(sizeof(struct brcms_timer), GFP_ATOMIC); - if (!t) - return NULL; - - init_timer(&t->timer); - t->timer.data = (unsigned long) t; - t->timer.function = _brcms_timer; - t->wl = wl; - t->fn = fn; - t->arg = arg; - t->next = wl->timers; - wl->timers = t; - -#ifdef BCMDBG - t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC); - if (t->name) - strcpy(t->name, name); -#endif - - return t; -} - -/* - * adds only the kernel timer since it's going to be more accurate - * as well as it's easier to make it periodic - * - * precondition: perimeter lock has been acquired - */ -void brcms_add_timer(struct brcms_info *wl, struct brcms_timer *t, uint ms, - int periodic) -{ -#ifdef BCMDBG - if (t->set) - wiphy_err(wl->wiphy, "%s: Already set. Name: %s, per %d\n", - __func__, t->name, periodic); - -#endif - t->ms = ms; - t->periodic = (bool) periodic; - t->set = true; - t->timer.expires = jiffies + ms * HZ / 1000; - - atomic_inc(&wl->callbacks); - add_timer(&t->timer); -} - -/* - * return true if timer successfully deleted, false if still pending - * - * precondition: perimeter lock has been acquired - */ -bool brcms_del_timer(struct brcms_info *wl, struct brcms_timer *t) -{ - if (t->set) { - t->set = false; - if (!del_timer(&t->timer)) - return false; - - atomic_dec(&wl->callbacks); - } - - return true; -} - -/* - * precondition: perimeter lock has been acquired - */ -void brcms_free_timer(struct brcms_info *wl, struct brcms_timer *t) -{ - struct brcms_timer *tmp; - - /* delete the timer in case it is active */ - brcms_del_timer(wl, t); - - if (wl->timers == t) { - wl->timers = wl->timers->next; -#ifdef BCMDBG - kfree(t->name); -#endif - kfree(t); - return; - - } - - tmp = wl->timers; - while (tmp) { - if (tmp->next == t) { - tmp->next = t->next; -#ifdef BCMDBG - kfree(t->name); -#endif - kfree(t); - return; - } - tmp = tmp->next; - } - -} - -/* - * precondition: perimeter lock has been acquired - */ -int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx) -{ - int i, entry; - const u8 *pdata; - struct firmware_hdr *hdr; - for (i = 0; i < wl->fw.fw_cnt; i++) { - hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data; - for (entry = 0; entry < wl->fw.hdr_num_entries[i]; - entry++, hdr++) { - u32 len = le32_to_cpu(hdr->len); - if (le32_to_cpu(hdr->idx) == idx) { - pdata = wl->fw.fw_bin[i]->data + - le32_to_cpu(hdr->offset); - *pbuf = kmalloc(len, GFP_ATOMIC); - if (*pbuf == NULL) - goto fail; - - memcpy(*pbuf, pdata, len); - return 0; - } - } - } - wiphy_err(wl->wiphy, "ERROR: ucode buf tag:%d can not be found!\n", - idx); - *pbuf = NULL; -fail: - return -ENODATA; -} - -/* - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx) -{ - int i, entry; - const u8 *pdata; - struct firmware_hdr *hdr; - for (i = 0; i < wl->fw.fw_cnt; i++) { - hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data; - for (entry = 0; entry < wl->fw.hdr_num_entries[i]; - entry++, hdr++) { - if (le32_to_cpu(hdr->idx) == idx) { - pdata = wl->fw.fw_bin[i]->data + - le32_to_cpu(hdr->offset); - if (le32_to_cpu(hdr->len) != 4) { - wiphy_err(wl->wiphy, - "ERROR: fw hdr len\n"); - return -ENOMSG; - } - *n_bytes = le32_to_cpu(*((__le32 *) pdata)); - return 0; - } - } - } - wiphy_err(wl->wiphy, "ERROR: ucode tag:%d can not be found!\n", idx); - return -ENOMSG; -} - -/* - * precondition: can both be called locked and unlocked - */ -void brcms_ucode_free_buf(void *p) -{ - kfree(p); -} - -/* - * checks validity of all firmware images loaded from user space - * - * Precondition: Since this function is called in brcms_pci_probe() context, - * no locking is required. - */ -int brcms_check_firmwares(struct brcms_info *wl) -{ - int i; - int entry; - int rc = 0; - const struct firmware *fw; - const struct firmware *fw_hdr; - struct firmware_hdr *ucode_hdr; - for (i = 0; i < MAX_FW_IMAGES && rc == 0; i++) { - fw = wl->fw.fw_bin[i]; - fw_hdr = wl->fw.fw_hdr[i]; - if (fw == NULL && fw_hdr == NULL) { - break; - } else if (fw == NULL || fw_hdr == NULL) { - wiphy_err(wl->wiphy, "%s: invalid bin/hdr fw\n", - __func__); - rc = -EBADF; - } else if (fw_hdr->size % sizeof(struct firmware_hdr)) { - wiphy_err(wl->wiphy, "%s: non integral fw hdr file " - "size %zu/%zu\n", __func__, fw_hdr->size, - sizeof(struct firmware_hdr)); - rc = -EBADF; - } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) { - wiphy_err(wl->wiphy, "%s: out of bounds fw file size " - "%zu\n", __func__, fw->size); - rc = -EBADF; - } else { - /* check if ucode section overruns firmware image */ - ucode_hdr = (struct firmware_hdr *)fw_hdr->data; - for (entry = 0; entry < wl->fw.hdr_num_entries[i] && - !rc; entry++, ucode_hdr++) { - if (le32_to_cpu(ucode_hdr->offset) + - le32_to_cpu(ucode_hdr->len) > - fw->size) { - wiphy_err(wl->wiphy, - "%s: conflicting bin/hdr\n", - __func__); - rc = -EBADF; - } - } - } - } - if (rc == 0 && wl->fw.fw_cnt != i) { - wiphy_err(wl->wiphy, "%s: invalid fw_cnt=%d\n", __func__, - wl->fw.fw_cnt); - rc = -EBADF; - } - return rc; -} - -/* - * precondition: perimeter lock has been acquired - */ -bool brcms_rfkill_set_hw_state(struct brcms_info *wl) -{ - bool blocked = brcms_c_check_radio_disabled(wl->wlc); - - spin_unlock_bh(&wl->lock); - wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); - if (blocked) - wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy); - spin_lock_bh(&wl->lock); - return blocked; -} - -/* - * precondition: perimeter lock has been acquired - */ -void brcms_msleep(struct brcms_info *wl, uint ms) -{ - spin_unlock_bh(&wl->lock); - msleep(ms); - spin_lock_bh(&wl->lock); -} diff --git a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h b/drivers/staging/brcm80211/brcmsmac/mac80211_if.h deleted file mode 100644 index 92256d0318f..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/mac80211_if.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_MAC80211_IF_H_ -#define _BRCM_MAC80211_IF_H_ - -#include -#include -#include "ucode_loader.h" -/* - * Starting index for 5G rates in the - * legacy rate table. - */ -#define BRCMS_LEGACY_5G_RATE_OFFSET 4 - -/* softmac ioctl definitions */ -#define BRCMS_SET_SHORTSLOT_OVERRIDE 146 - -struct brcms_timer { - struct timer_list timer; - struct brcms_info *wl; - void (*fn) (void *); - void *arg; /* argument to fn */ - uint ms; - bool periodic; - bool set; - struct brcms_timer *next; -#ifdef BCMDBG - char *name; /* Description of the timer */ -#endif -}; - -struct brcms_if { - uint subunit; /* WDS/BSS unit */ - struct pci_dev *pci_dev; -}; - -#define MAX_FW_IMAGES 4 -struct brcms_firmware { - u32 fw_cnt; - const struct firmware *fw_bin[MAX_FW_IMAGES]; - const struct firmware *fw_hdr[MAX_FW_IMAGES]; - u32 hdr_num_entries[MAX_FW_IMAGES]; -}; - -struct brcms_info { - struct brcms_pub *pub; /* pointer to public wlc state */ - struct brcms_c_info *wlc; /* pointer to private common data */ - u32 magic; - - int irq; - - spinlock_t lock; /* per-device perimeter lock */ - spinlock_t isr_lock; /* per-device ISR synchronization lock */ - - /* regsva for unmap in brcms_free() */ - void __iomem *regsva; /* opaque chip registers virtual address */ - - /* timer related fields */ - atomic_t callbacks; /* # outstanding callback functions */ - struct brcms_timer *timers; /* timer cleanup queue */ - - struct tasklet_struct tasklet; /* dpc tasklet */ - bool resched; /* dpc needs to be and is rescheduled */ - struct brcms_firmware fw; - struct wiphy *wiphy; - struct brcms_ucode ucode; -}; - -/* misc callbacks */ -extern void brcms_init(struct brcms_info *wl); -extern uint brcms_reset(struct brcms_info *wl); -extern void brcms_intrson(struct brcms_info *wl); -extern u32 brcms_intrsoff(struct brcms_info *wl); -extern void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask); -extern int brcms_up(struct brcms_info *wl); -extern void brcms_down(struct brcms_info *wl); -extern void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif, - bool state, int prio); -extern bool brcms_rfkill_set_hw_state(struct brcms_info *wl); - -/* timer functions */ -extern struct brcms_timer *brcms_init_timer(struct brcms_info *wl, - void (*fn) (void *arg), void *arg, - const char *name); -extern void brcms_free_timer(struct brcms_info *wl, struct brcms_timer *timer); -extern void brcms_add_timer(struct brcms_info *wl, struct brcms_timer *timer, - uint ms, int periodic); -extern bool brcms_del_timer(struct brcms_info *wl, struct brcms_timer *timer); -extern void brcms_msleep(struct brcms_info *wl, uint ms); -extern void brcms_dpc(unsigned long data); -extern void brcms_timer(struct brcms_timer *t); - -#endif /* _BRCM_MAC80211_IF_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/main.c b/drivers/staging/brcm80211/brcmsmac/main.c deleted file mode 100644 index 1e35be95262..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/main.c +++ /dev/null @@ -1,8841 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include "rate.h" -#include "scb.h" -#include "phy/phy_hal.h" -#include "channel.h" -#include "antsel.h" -#include "stf.h" -#include "ampdu.h" -#include "mac80211_if.h" -#include "ucode_loader.h" -#include "main.h" - -/* - * Indication for txflowcontrol that all priority bits in - * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. - */ -#define ALLPRIO -1 - -/* - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. - */ -#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) - -/* watchdog timer, in unit of ms */ -#define TIMER_INTERVAL_WATCHDOG 1000 -/* radio monitor timer, in unit of ms */ -#define TIMER_INTERVAL_RADIOCHK 800 - -/* Max MPC timeout, in unit of watchdog */ -#ifndef BRCMS_MPC_MAX_DELAYCNT -#define BRCMS_MPC_MAX_DELAYCNT 10 -#endif - -/* Min MPC timeout, in unit of watchdog */ -#define BRCMS_MPC_MIN_DELAYCNT 1 -#define BRCMS_MPC_THRESHOLD 3 /* MPC count threshold level */ - -/* beacon interval, in unit of 1024TU */ -#define BEACON_INTERVAL_DEFAULT 100 -/* DTIM interval, in unit of beacon interval */ -#define DTIM_INTERVAL_DEFAULT 3 - -/* Scale down delays to accommodate QT slow speed */ -/* beacon interval, in unit of 1024TU */ -#define BEACON_INTERVAL_DEF_QT 20 -/* DTIM interval, in unit of beacon interval */ -#define DTIM_INTERVAL_DEF_QT 1 - -#define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ - -/* n-mode support capability */ -/* 2x2 includes both 1x1 & 2x2 devices - * reserved #define 2 for future when we want to separate 1x1 & 2x2 and - * control it independently - */ -#define WL_11N_2x2 1 -#define WL_11N_3x3 3 -#define WL_11N_4x4 4 - -/* define 11n feature disable flags */ -#define WLFEATURE_DISABLE_11N 0x00000001 -#define WLFEATURE_DISABLE_11N_STBC_TX 0x00000002 -#define WLFEATURE_DISABLE_11N_STBC_RX 0x00000004 -#define WLFEATURE_DISABLE_11N_SGI_TX 0x00000008 -#define WLFEATURE_DISABLE_11N_SGI_RX 0x00000010 -#define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020 -#define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040 -#define WLFEATURE_DISABLE_11N_GF 0x00000080 - -#define EDCF_ACI_MASK 0x60 -#define EDCF_ACI_SHIFT 5 -#define EDCF_ECWMIN_MASK 0x0f -#define EDCF_ECWMAX_SHIFT 4 -#define EDCF_AIFSN_MASK 0x0f -#define EDCF_AIFSN_MAX 15 -#define EDCF_ECWMAX_MASK 0xf0 - -#define EDCF_AC_BE_TXOP_STA 0x0000 -#define EDCF_AC_BK_TXOP_STA 0x0000 -#define EDCF_AC_VO_ACI_STA 0x62 -#define EDCF_AC_VO_ECW_STA 0x32 -#define EDCF_AC_VI_ACI_STA 0x42 -#define EDCF_AC_VI_ECW_STA 0x43 -#define EDCF_AC_BK_ECW_STA 0xA4 -#define EDCF_AC_VI_TXOP_STA 0x005e -#define EDCF_AC_VO_TXOP_STA 0x002f -#define EDCF_AC_BE_ACI_STA 0x03 -#define EDCF_AC_BE_ECW_STA 0xA4 -#define EDCF_AC_BK_ACI_STA 0x27 -#define EDCF_AC_VO_TXOP_AP 0x002f - -#define EDCF_TXOP2USEC(txop) ((txop) << 5) -#define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) - -#define APHY_SYMBOL_TIME 4 -#define APHY_PREAMBLE_TIME 16 -#define APHY_SIGNAL_TIME 4 -#define APHY_SIFS_TIME 16 -#define APHY_SERVICE_NBITS 16 -#define APHY_TAIL_NBITS 6 -#define BPHY_SIFS_TIME 10 -#define BPHY_PLCP_SHORT_TIME 96 - -#define PREN_PREAMBLE 24 -#define PREN_MM_EXT 12 -#define PREN_PREAMBLE_EXT 4 - -#define DOT11_MAC_HDR_LEN 24 -#define DOT11_ACK_LEN 10 -#define DOT11_BA_LEN 4 -#define DOT11_OFDM_SIGNAL_EXTENSION 6 -#define DOT11_MIN_FRAG_LEN 256 -#define DOT11_RTS_LEN 16 -#define DOT11_CTS_LEN 10 -#define DOT11_BA_BITMAP_LEN 128 -#define DOT11_MIN_BEACON_PERIOD 1 -#define DOT11_MAX_BEACON_PERIOD 0xFFFF -#define DOT11_MAXNUMFRAGS 16 -#define DOT11_MAX_FRAG_LEN 2346 - -#define BPHY_PLCP_TIME 192 -#define RIFS_11N_TIME 2 - -#define WME_VER 1 -#define WME_SUBTYPE_PARAM_IE 1 -#define WME_TYPE 2 -#define WME_OUI "\x00\x50\xf2" - -#define AC_BE 0 -#define AC_BK 1 -#define AC_VI 2 -#define AC_VO 3 - -#define BCN_TMPL_LEN 512 /* length of the BCN template area */ - -/* brcms_bss_info flag bit values */ -#define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ - -/* Flags used in brcms_c_txq_info.stopped */ -/* per prio flow control bits */ -#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF -/* stop txq enqueue for packet drain */ -#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 -/* stop txq enqueue for ampdu flow control */ -#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 - -#define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ - -/* Find basic rate for a given rate */ -static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) -{ - if (is_mcs_rate(rspec)) - return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] - .leg_ofdm]; - return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; -} - -static u16 frametype(u32 rspec, u8 mimoframe) -{ - if (is_mcs_rate(rspec)) - return mimoframe; - return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; -} - -/* rfdisable delay timer 500 ms, runs of ALP clock */ -#define RFDISABLE_DEFAULT 10000000 - -#define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ - -/* precedences numbers for wlc queues. These are twice as may levels as - * 802.1D priorities. - * Odd numbers are used for HI priority traffic at same precedence levels - * These constants are used ONLY by wlc_prio2prec_map. Do not use them - * elsewhere. - */ -#define _BRCMS_PREC_NONE 0 /* None = - */ -#define _BRCMS_PREC_BK 2 /* BK - Background */ -#define _BRCMS_PREC_BE 4 /* BE - Best-effort */ -#define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ -#define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ -#define _BRCMS_PREC_VI 10 /* Vi - Video */ -#define _BRCMS_PREC_VO 12 /* Vo - Voice */ -#define _BRCMS_PREC_NC 14 /* NC - Network Control */ - -/* The BSS is generating beacons in HW */ -#define BRCMS_BSSCFG_HW_BCN 0x20 - -#define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ -#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ -#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ -#define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ - -#define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ - -#define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ - -/* Per-AC retry limit register definitions; uses defs.h bitfield macros */ -#define EDCF_SHORT_S 0 -#define EDCF_SFB_S 4 -#define EDCF_LONG_S 8 -#define EDCF_LFB_S 12 -#define EDCF_SHORT_M BITFIELD_MASK(4) -#define EDCF_SFB_M BITFIELD_MASK(4) -#define EDCF_LONG_M BITFIELD_MASK(4) -#define EDCF_LFB_M BITFIELD_MASK(4) - -#define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ -#define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ -#define RETRY_LONG_DEF 4 /* Default Long retry count */ -#define RETRY_SHORT_FB 3 /* Short count for fallback rate */ -#define RETRY_LONG_FB 2 /* Long count for fallback rate */ - -#define APHY_CWMIN 15 -#define PHY_CWMAX 1023 - -#define EDCF_AIFSN_MIN 1 - -#define FRAGNUM_MASK 0xF - -#define APHY_SLOT_TIME 9 -#define BPHY_SLOT_TIME 20 - -#define WL_SPURAVOID_OFF 0 -#define WL_SPURAVOID_ON1 1 -#define WL_SPURAVOID_ON2 2 - -/* invalid core flags, use the saved coreflags */ -#define BRCMS_USE_COREFLAGS 0xffffffff - -/* values for PLCPHdr_override */ -#define BRCMS_PLCP_AUTO -1 -#define BRCMS_PLCP_SHORT 0 -#define BRCMS_PLCP_LONG 1 - -/* values for g_protection_override and n_protection_override */ -#define BRCMS_PROTECTION_AUTO -1 -#define BRCMS_PROTECTION_OFF 0 -#define BRCMS_PROTECTION_ON 1 -#define BRCMS_PROTECTION_MMHDR_ONLY 2 -#define BRCMS_PROTECTION_CTS_ONLY 3 - -/* values for g_protection_control and n_protection_control */ -#define BRCMS_PROTECTION_CTL_OFF 0 -#define BRCMS_PROTECTION_CTL_LOCAL 1 -#define BRCMS_PROTECTION_CTL_OVERLAP 2 - -/* values for n_protection */ -#define BRCMS_N_PROTECTION_OFF 0 -#define BRCMS_N_PROTECTION_OPTIONAL 1 -#define BRCMS_N_PROTECTION_20IN40 2 -#define BRCMS_N_PROTECTION_MIXEDMODE 3 - -/* values for band specific 40MHz capabilities */ -#define BRCMS_N_BW_20ALL 0 -#define BRCMS_N_BW_40ALL 1 -#define BRCMS_N_BW_20IN2G_40IN5G 2 - -/* bitflags for SGI support (sgi_rx iovar) */ -#define BRCMS_N_SGI_20 0x01 -#define BRCMS_N_SGI_40 0x02 - -/* defines used by the nrate iovar */ -/* MSC in use,indicates b0-6 holds an mcs */ -#define NRATE_MCS_INUSE 0x00000080 -/* rate/mcs value */ -#define NRATE_RATE_MASK 0x0000007f -/* stf mode mask: siso, cdd, stbc, sdm */ -#define NRATE_STF_MASK 0x0000ff00 -/* stf mode shift */ -#define NRATE_STF_SHIFT 8 -/* bit indicates override both rate & mode */ -#define NRATE_OVERRIDE 0x80000000 -/* bit indicate to override mcs only */ -#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 -#define NRATE_SGI_MASK 0x00800000 /* sgi mode */ -#define NRATE_SGI_SHIFT 23 /* sgi mode */ -#define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ -#define NRATE_LDPC_SHIFT 22 /* ldpc shift */ - -#define NRATE_STF_SISO 0 /* stf mode SISO */ -#define NRATE_STF_CDD 1 /* stf mode CDD */ -#define NRATE_STF_STBC 2 /* stf mode STBC */ -#define NRATE_STF_SDM 3 /* stf mode SDM */ - -#define MAX_DMA_SEGS 4 - -/* Max # of entries in Tx FIFO based on 4kb page size */ -#define NTXD 256 -/* Max # of entries in Rx FIFO based on 4kb page size */ -#define NRXD 256 - -/* try to keep this # rbufs posted to the chip */ -#define NRXBUFPOST 32 - -/* data msg txq hiwat mark */ -#define BRCMS_DATAHIWAT 50 - -/* bounded rx loops */ -#define RXBND 8 /* max # frames to process in brcms_c_recv() */ -#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ - -/* - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. - */ -#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) - -/* - * The following table lists the buffer memory allocated to xmt fifos in HW. - * the size is in units of 256bytes(one block), total size is HW dependent - * ucode has default fifo partition, sw can overwrite if necessary - * - * This is documented in twiki under the topic UcodeTxFifo. Please ensure - * the twiki is updated before making changes. - */ - -/* Starting corerev for the fifo size table */ -#define XMTFIFOTBL_STARTREV 20 - -struct d11init { - __le16 addr; - __le16 size; - __le32 value; -}; - -/* currently the best mechanism for determining SIFS is the band in use */ -static u16 get_sifs(struct brcms_band *band) -{ - return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : - BPHY_SIFS_TIME; -} - - -/* - * Detect Card removed. - * Even checking an sbconfig register read will not false trigger when the core - * is in reset it breaks CF address mechanism. Accessing gphy phyversion will - * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible - * reg with fixed 0/1 pattern (some platforms return all 0). - * If clocks are present, call the sb routine which will figure out if the - * device is removed. - */ -static bool brcms_deviceremoved(struct brcms_c_info *wlc) -{ - if (!wlc->hw->clk) - return ai_deviceremoved(wlc->hw->sih); - return (R_REG(&wlc->hw->regs->maccontrol) & - (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; -} - -/* sum the individual fifo tx pending packet counts */ -static s16 brcms_txpktpendtot(struct brcms_c_info *wlc) -{ - return wlc->core->txpktpend[0] + wlc->core->txpktpend[1] + - wlc->core->txpktpend[2] + wlc->core->txpktpend[3]; -} - -static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc) -{ - return wlc->pub->_nbands > 1 && !wlc->bandlocked; -} - -static int brcms_chspec_bw(u16 chanspec) -{ - if (CHSPEC_IS40(chanspec)) - return BRCMS_40_MHZ; - if (CHSPEC_IS20(chanspec)) - return BRCMS_20_MHZ; - - return BRCMS_10_MHZ; -} - -struct edcf_acparam { - u8 ACI; - u8 ECW; - u16 TXOP; -} __packed; - -const u8 prio2fifo[NUMPRIO] = { - TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */ - TX_AC_BK_FIFO, /* 1 BK AC_BK Background */ - TX_AC_BK_FIFO, /* 2 -- AC_BK Background */ - TX_AC_BE_FIFO, /* 3 EE AC_BE Best Effort */ - TX_AC_VI_FIFO, /* 4 CL AC_VI Video */ - TX_AC_VI_FIFO, /* 5 VI AC_VI Video */ - TX_AC_VO_FIFO, /* 6 VO AC_VO Voice */ - TX_AC_VO_FIFO /* 7 NC AC_VO Voice */ -}; - -/* debug/trace */ -uint brcm_msg_level = -#if defined(BCMDBG) - LOG_ERROR_VAL; -#else - 0; -#endif /* BCMDBG */ - -/* TX FIFO number to WME/802.1E Access Category */ -static const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; - -/* WME/802.1E Access Category to TX FIFO number */ -static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; - -/* 802.1D Priority to precedence queue mapping */ -const u8 wlc_prio2prec_map[] = { - _BRCMS_PREC_BE, /* 0 BE - Best-effort */ - _BRCMS_PREC_BK, /* 1 BK - Background */ - _BRCMS_PREC_NONE, /* 2 None = - */ - _BRCMS_PREC_EE, /* 3 EE - Excellent-effort */ - _BRCMS_PREC_CL, /* 4 CL - Controlled Load */ - _BRCMS_PREC_VI, /* 5 Vi - Video */ - _BRCMS_PREC_VO, /* 6 Vo - Voice */ - _BRCMS_PREC_NC, /* 7 NC - Network Control */ -}; - -static const u16 xmtfifo_sz[][NFIFO] = { - /* corerev 20: 5120, 49152, 49152, 5376, 4352, 1280 */ - {20, 192, 192, 21, 17, 5}, - /* corerev 21: 2304, 14848, 5632, 3584, 3584, 1280 */ - {9, 58, 22, 14, 14, 5}, - /* corerev 22: 5120, 49152, 49152, 5376, 4352, 1280 */ - {20, 192, 192, 21, 17, 5}, - /* corerev 23: 5120, 49152, 49152, 5376, 4352, 1280 */ - {20, 192, 192, 21, 17, 5}, - /* corerev 24: 2304, 14848, 5632, 3584, 3584, 1280 */ - {9, 58, 22, 14, 14, 5}, -}; - -static const u8 acbitmap2maxprio[] = { - PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, - PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO -}; - -#ifdef BCMDBG -static const char * const fifo_names[] = { - "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; -#else -static const char fifo_names[6][0]; -#endif - -#ifdef BCMDBG -/* pointer to most recently allocated wl/wlc */ -static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); -#endif - -static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) -{ - if (cfg == NULL) - return; - - kfree(cfg->current_bss); - kfree(cfg); -} - -static void brcms_c_detach_mfree(struct brcms_c_info *wlc) -{ - if (wlc == NULL) - return; - - brcms_c_bsscfg_mfree(wlc->bsscfg); - kfree(wlc->pub); - kfree(wlc->modulecb); - kfree(wlc->default_bss); - kfree(wlc->protection); - kfree(wlc->stf); - kfree(wlc->bandstate[0]); - kfree(wlc->corestate->macstat_snapshot); - kfree(wlc->corestate); - kfree(wlc->hw->bandstate[0]); - kfree(wlc->hw); - - /* free the wlc */ - kfree(wlc); - wlc = NULL; -} - -static struct brcms_bss_cfg *brcms_c_bsscfg_malloc(uint unit) -{ - struct brcms_bss_cfg *cfg; - - cfg = kzalloc(sizeof(struct brcms_bss_cfg), GFP_ATOMIC); - if (cfg == NULL) - goto fail; - - cfg->current_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); - if (cfg->current_bss == NULL) - goto fail; - - return cfg; - - fail: - brcms_c_bsscfg_mfree(cfg); - return NULL; -} - -static struct brcms_c_info * -brcms_c_attach_malloc(uint unit, uint *err, uint devid) -{ - struct brcms_c_info *wlc; - - wlc = kzalloc(sizeof(struct brcms_c_info), GFP_ATOMIC); - if (wlc == NULL) { - *err = 1002; - goto fail; - } - - /* allocate struct brcms_c_pub state structure */ - wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); - if (wlc->pub == NULL) { - *err = 1003; - goto fail; - } - wlc->pub->wlc = wlc; - - /* allocate struct brcms_hardware state structure */ - - wlc->hw = kzalloc(sizeof(struct brcms_hardware), GFP_ATOMIC); - if (wlc->hw == NULL) { - *err = 1005; - goto fail; - } - wlc->hw->wlc = wlc; - - wlc->hw->bandstate[0] = - kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC); - if (wlc->hw->bandstate[0] == NULL) { - *err = 1006; - goto fail; - } else { - int i; - - for (i = 1; i < MAXBANDS; i++) - wlc->hw->bandstate[i] = (struct brcms_hw_band *) - ((unsigned long)wlc->hw->bandstate[0] + - (sizeof(struct brcms_hw_band) * i)); - } - - wlc->modulecb = - kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC); - if (wlc->modulecb == NULL) { - *err = 1009; - goto fail; - } - - wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); - if (wlc->default_bss == NULL) { - *err = 1010; - goto fail; - } - - wlc->bsscfg = brcms_c_bsscfg_malloc(unit); - if (wlc->bsscfg == NULL) { - *err = 1011; - goto fail; - } - - wlc->protection = kzalloc(sizeof(struct brcms_protection), - GFP_ATOMIC); - if (wlc->protection == NULL) { - *err = 1016; - goto fail; - } - - wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); - if (wlc->stf == NULL) { - *err = 1017; - goto fail; - } - - wlc->bandstate[0] = - kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC); - if (wlc->bandstate[0] == NULL) { - *err = 1025; - goto fail; - } else { - int i; - - for (i = 1; i < MAXBANDS; i++) - wlc->bandstate[i] = (struct brcms_band *) - ((unsigned long)wlc->bandstate[0] - + (sizeof(struct brcms_band)*i)); - } - - wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); - if (wlc->corestate == NULL) { - *err = 1026; - goto fail; - } - - wlc->corestate->macstat_snapshot = - kzalloc(sizeof(struct macstat), GFP_ATOMIC); - if (wlc->corestate->macstat_snapshot == NULL) { - *err = 1027; - goto fail; - } - - return wlc; - - fail: - brcms_c_detach_mfree(wlc); - return NULL; -} - -/* - * Update the slot timing for standard 11b/g (20us slots) - * or shortslot 11g (9us slots) - * The PSM needs to be suspended for this call. - */ -static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, - bool shortslot) -{ - struct d11regs __iomem *regs; - - regs = wlc_hw->regs; - - if (shortslot) { - /* 11g short slot: 11a timing */ - W_REG(®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ - brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); - } else { - /* 11g long slot: 11b timing */ - W_REG(®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ - brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); - } -} - -static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, - const struct d11init *inits) -{ - int i; - u8 __iomem *base; - u8 __iomem *addr; - u16 size; - u32 value; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - base = (u8 __iomem *)wlc_hw->regs; - - for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { - size = le16_to_cpu(inits[i].size); - addr = base + le16_to_cpu(inits[i].addr); - value = le32_to_cpu(inits[i].value); - if (size == 2) - W_REG((u16 __iomem *)addr, value); - else if (size == 4) - W_REG((u32 __iomem *)addr, value); - else - break; - } -} - -static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) -{ - u8 idx; - u16 addr[] = { - M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, - M_HOST_FLAGS5 - }; - - for (idx = 0; idx < MHFMAX; idx++) - brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); -} - -static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) -{ - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; - - /* init microcode host flags */ - brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); - - /* do band-specific ucode IHR, SHM, and SCR inits */ - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } else { - if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, - ucode->d11lcn0bsinitvals24); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in" - " core rev %d\n", __func__, - wlc_hw->unit, wlc_hw->corerev); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - } -} - -static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); - - wlc_hw->phyclk = clk; - - if (OFF == clk) { /* clear gmode bit, put phy into reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), - (SICF_PRST | SICF_FGC)); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); - udelay(1); - - } else { /* take phy out of reset */ - - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); - udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); - udelay(1); - - } -} - -/* switch to new band but leave it inactive */ -static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintmask; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); - - /* disable interrupts */ - macintmask = brcms_intrsoff(wlc->wl); - - /* radio off */ - wlc_phy_switch_radio(wlc_hw->band->pi, OFF); - - brcms_b_core_phy_clk(wlc_hw, OFF); - - brcms_c_setxband(wlc_hw, bandunit); - - return macintmask; -} - -/* Process received frames */ -/* - * Return true if more frames need to be processed. false otherwise. - * Param 'bound' indicates max. # frames to process before break out. - */ -static bool -brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) -{ - struct sk_buff *p; - struct sk_buff *head = NULL; - struct sk_buff *tail = NULL; - uint n = 0; - uint bound_limit = bound ? RXBND : -1; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - /* gather received frames */ - while ((p = dma_rx(wlc_hw->di[fifo]))) { - - if (!tail) - head = tail = p; - else { - tail->prev = p; - tail = p; - } - - /* !give others some time to run! */ - if (++n >= bound_limit) - break; - } - - /* post more rbufs */ - dma_rxfill(wlc_hw->di[fifo]); - - /* process each frame */ - while ((p = head) != NULL) { - struct d11rxhdr_le *rxh_le; - struct d11rxhdr *rxh; - head = head->prev; - p->prev = NULL; - - rxh_le = (struct d11rxhdr_le *)p->data; - rxh = (struct d11rxhdr *)p->data; - - /* fixup rx header endianness */ - rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); - rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); - rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); - rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); - rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); - rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); - rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); - rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); - rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); - rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); - rxh->RxChan = le16_to_cpu(rxh_le->RxChan); - - brcms_c_recv(wlc_hw->wlc, p); - } - - return n >= bound_limit; -} - -/* process an individual struct tx_status */ -static bool -brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) -{ - struct sk_buff *p; - uint queue; - struct d11txh *txh; - struct scb *scb = NULL; - bool free_pdu; - int tx_rts, tx_frame_count, tx_rts_count; - uint totlen, supr_status; - bool lastframe; - struct ieee80211_hdr *h; - u16 mcl; - struct ieee80211_tx_info *tx_info; - struct ieee80211_tx_rate *txrate; - int i; - - /* discard intermediate indications for ucode with one legitimate case: - * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, - * but the subsequent tx of DATA failed. so it will start rts/cts - * from the beginning (resetting the rts transmission count) - */ - if (!(txs->status & TX_STATUS_AMPDU) - && (txs->status & TX_STATUS_INTERMEDIATE)) { - wiphy_err(wlc->wiphy, "%s: INTERMEDIATE but not AMPDU\n", - __func__); - return false; - } - - queue = txs->frameid & TXFID_QUEUE_MASK; - if (queue >= NFIFO) { - p = NULL; - goto fatal; - } - - p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); - if (p == NULL) - goto fatal; - - txh = (struct d11txh *) (p->data); - mcl = le16_to_cpu(txh->MacTxControlLow); - - if (txs->phyerr) { - if (brcm_msg_level & LOG_ERROR_VAL) { - wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n", - txs->phyerr, txh->MainRates); - brcms_c_print_txdesc(txh); - } - brcms_c_print_txstatus(txs); - } - - if (txs->frameid != le16_to_cpu(txh->TxFrameID)) - goto fatal; - tx_info = IEEE80211_SKB_CB(p); - h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - - if (tx_info->control.sta) - scb = &wlc->pri_scb; - - if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { - brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); - return false; - } - - supr_status = txs->status & TX_STATUS_SUPR_MASK; - if (supr_status == TX_STATUS_SUPR_BADCH) - BCMMSG(wlc->wiphy, - "%s: Pkt tx suppressed, possibly channel %d\n", - __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); - - tx_rts = le16_to_cpu(txh->MacTxControlLow) & TXC_SENDRTS; - tx_frame_count = - (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; - tx_rts_count = - (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT; - - lastframe = !ieee80211_has_morefrags(h->frame_control); - - if (!lastframe) { - wiphy_err(wlc->wiphy, "Not last frame!\n"); - } else { - /* - * Set information to be consumed by Minstrel ht. - * - * The "fallback limit" is the number of tx attempts a given - * MPDU is sent at the "primary" rate. Tx attempts beyond that - * limit are sent at the "secondary" rate. - * A 'short frame' does not exceed RTS treshold. - */ - u16 sfbl, /* Short Frame Rate Fallback Limit */ - lfbl, /* Long Frame Rate Fallback Limit */ - fbl; - - if (queue < AC_COUNT) { - sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], - EDCF_SFB); - lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], - EDCF_LFB); - } else { - sfbl = wlc->SFBL; - lfbl = wlc->LFBL; - } - - txrate = tx_info->status.rates; - if (txrate[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) - fbl = lfbl; - else - fbl = sfbl; - - ieee80211_tx_info_clear_status(tx_info); - - if ((tx_frame_count > fbl) && (txrate[1].idx >= 0)) { - /* - * rate selection requested a fallback rate - * and we used it - */ - txrate[0].count = fbl; - txrate[1].count = tx_frame_count - fbl; - } else { - /* - * rate selection did not request fallback rate, or - * we didn't need it - */ - txrate[0].count = tx_frame_count; - /* - * rc80211_minstrel.c:minstrel_tx_status() expects - * unused rates to be marked with idx = -1 - */ - txrate[1].idx = -1; - txrate[1].count = 0; - } - - /* clear the rest of the rates */ - for (i = 2; i < IEEE80211_TX_MAX_RATES; i++) { - txrate[i].idx = -1; - txrate[i].count = 0; - } - - if (txs->status & TX_STATUS_ACK_RCV) - tx_info->flags |= IEEE80211_TX_STAT_ACK; - } - - totlen = brcmu_pkttotlen(p); - free_pdu = true; - - brcms_c_txfifo_complete(wlc, queue, 1); - - if (lastframe) { - p->next = NULL; - p->prev = NULL; - /* remove PLCP & Broadcom tx descriptor header */ - skb_pull(p, D11_PHY_HDR_LEN); - skb_pull(p, D11_TXH_LEN); - ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); - } else { - wiphy_err(wlc->wiphy, "%s: Not last frame => not calling " - "tx_status\n", __func__); - } - - return false; - - fatal: - if (p) - brcmu_pkt_buf_free_skb(p); - - return true; - -} - -/* process tx completion events in BMAC - * Return true if more tx status need to be processed. false otherwise. - */ -static bool -brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) -{ - bool morepending = false; - struct brcms_c_info *wlc = wlc_hw->wlc; - struct d11regs __iomem *regs; - struct tx_status txstatus, *txs; - u32 s1, s2; - uint n = 0; - /* - * Param 'max_tx_num' indicates max. # tx status to process before - * break out. - */ - uint max_tx_num = bound ? TXSBND : -1; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - txs = &txstatus; - regs = wlc_hw->regs; - *fatal = false; - while (!(*fatal) - && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { - - if (s1 == 0xffffffff) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", - wlc_hw->unit, __func__); - return morepending; - } - - s2 = R_REG(®s->frmtxstatus2); - - txs->status = s1 & TXS_STATUS_MASK; - txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; - txs->sequence = s2 & TXS_SEQ_MASK; - txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; - txs->lasttxtime = 0; - - *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); - - /* !give others some time to run! */ - if (++n >= max_tx_num) - break; - } - - if (*fatal) - return 0; - - if (n >= max_tx_num) - morepending = true; - - if (!pktq_empty(&wlc->pkt_queue->q)) - brcms_c_send_q(wlc); - - return morepending; -} - -/* second-level interrupt processing - * Return true if another dpc needs to be re-scheduled. false otherwise. - * Param 'bounded' indicates if applicable loops should be bounded. - */ -bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) -{ - u32 macintstatus; - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; - struct wiphy *wiphy = wlc->wiphy; - - if (brcms_deviceremoved(wlc)) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return false; - } - - /* grab and clear the saved software intstatus bits */ - macintstatus = wlc->macintstatus; - wlc->macintstatus = 0; - - BCMMSG(wlc->wiphy, "wl%d: macintstatus 0x%x\n", - wlc_hw->unit, macintstatus); - - WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ - - /* tx status */ - if (macintstatus & MI_TFS) { - bool fatal; - if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) - wlc->macintstatus |= MI_TFS; - if (fatal) { - wiphy_err(wiphy, "MI_TFS: fatal\n"); - goto fatal; - } - } - - if (macintstatus & (MI_TBTT | MI_DTIM_TBTT)) - brcms_c_tbtt(wlc); - - /* ATIM window end */ - if (macintstatus & MI_ATIMWINEND) { - BCMMSG(wlc->wiphy, "end of ATIM window\n"); - OR_REG(®s->maccommand, wlc->qvalid); - wlc->qvalid = 0; - } - - /* - * received data or control frame, MI_DMAINT is - * indication of RX_FIFO interrupt - */ - if (macintstatus & MI_DMAINT) - if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) - wlc->macintstatus |= MI_DMAINT; - - /* noise sample collected */ - if (macintstatus & MI_BG_NOISE) - wlc_phy_noise_sample_intr(wlc_hw->band->pi); - - if (macintstatus & MI_GP0) { - wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " - "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); - - printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", - __func__, wlc_hw->sih->chip, - wlc_hw->sih->chiprev); - /* big hammer */ - brcms_init(wlc->wl); - } - - /* gptimer timeout */ - if (macintstatus & MI_TO) - W_REG(®s->gptimer, 0); - - if (macintstatus & MI_RFDISABLE) { - BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" - " RF Disable Input\n", wlc_hw->unit); - brcms_rfkill_set_hw_state(wlc->wl); - } - - /* send any enq'd tx packets. Just makes sure to jump start tx */ - if (!pktq_empty(&wlc->pkt_queue->q)) - brcms_c_send_q(wlc); - - /* it isn't done and needs to be resched if macintstatus is non-zero */ - return wlc->macintstatus != 0; - - fatal: - brcms_init(wlc->wl); - return wlc->macintstatus != 0; -} - -/* set initial host flags value */ -static void -brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - - memset(mhfs, 0, MHFMAX * sizeof(u16)); - - mhfs[MHF2] |= mhf2_init; - - /* prohibit use of slowclock on multifunction boards */ - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - mhfs[MHF1] |= MHF1_FORCEFASTCLK; - - if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { - mhfs[MHF2] |= MHF2_NPHY40MHZ_WAR; - mhfs[MHF1] |= MHF1_IQSWAP_WAR; - } -} - -static struct dma64regs __iomem * -dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) -{ - if (direction == DMA_TX) - return &(hw->regs->fifo64regs[fifonum].dmaxmt); - return &(hw->regs->fifo64regs[fifonum].dmarcv); -} - -static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) -{ - uint i; - char name[8]; - /* - * ucode host flag 2 needed for pio mode, independent of band and fifo - */ - u16 pio_mhf2 = 0; - struct brcms_hardware *wlc_hw = wlc->hw; - uint unit = wlc_hw->unit; - struct wiphy *wiphy = wlc->wiphy; - - /* name and offsets for dma_attach */ - snprintf(name, sizeof(name), "wl%d", unit); - - if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ - int dma_attach_err = 0; - - /* - * FIFO 0 - * TX: TX_AC_BK_FIFO (TX AC Background data packets) - * RX: RX_FIFO (RX data packets) - */ - wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, - (wme ? dmareg(wlc_hw, DMA_TX, 0) : - NULL), dmareg(wlc_hw, DMA_RX, 0), - (wme ? NTXD : 0), NRXD, - RXBUFSZ, -1, NRXBUFPOST, - BRCMS_HWRXOFF, &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[0]); - - /* - * FIFO 1 - * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) - * (legacy) TX_DATA_FIFO (TX data packets) - * RX: UNUSED - */ - wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, - dmareg(wlc_hw, DMA_TX, 1), NULL, - NTXD, 0, 0, -1, 0, 0, - &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[1]); - - /* - * FIFO 2 - * TX: TX_AC_VI_FIFO (TX AC Video data packets) - * RX: UNUSED - */ - wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, - dmareg(wlc_hw, DMA_TX, 2), NULL, - NTXD, 0, 0, -1, 0, 0, - &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[2]); - /* - * FIFO 3 - * TX: TX_AC_VO_FIFO (TX AC Voice data packets) - * (legacy) TX_CTL_FIFO (TX control & mgmt packets) - */ - wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, - dmareg(wlc_hw, DMA_TX, 3), - NULL, NTXD, 0, 0, -1, - 0, 0, &brcm_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[3]); -/* Cleaner to leave this as if with AP defined */ - - if (dma_attach_err) { - wiphy_err(wiphy, "wl%d: wlc_attach: dma_attach failed" - "\n", unit); - return false; - } - - /* get pointer to dma engine tx flow control variable */ - for (i = 0; i < NFIFO; i++) - if (wlc_hw->di[i]) - wlc_hw->txavail[i] = - (uint *) dma_getvar(wlc_hw->di[i], - "&txavail"); - } - - /* initial ucode host flags */ - brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); - - return true; -} - -static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw) -{ - uint j; - - for (j = 0; j < NFIFO; j++) { - if (wlc_hw->di[j]) { - dma_detach(wlc_hw->di[j]); - wlc_hw->di[j] = NULL; - } - } -} - -/* - * Initialize brcms_c_info default values ... - * may get overrides later in this function - * BMAC_NOTES, move low out and resolve the dangling ones - */ -static void brcms_b_info_init(struct brcms_hardware *wlc_hw) -{ - struct brcms_c_info *wlc = wlc_hw->wlc; - - /* set default sw macintmask value */ - wlc->defmacintmask = DEF_MACINTMASK; - - /* various 802.11g modes */ - wlc_hw->shortslot = false; - - wlc_hw->SFBL = RETRY_SHORT_FB; - wlc_hw->LFBL = RETRY_LONG_FB; - - /* default mac retry limits */ - wlc_hw->SRL = RETRY_SHORT_DEF; - wlc_hw->LRL = RETRY_LONG_DEF; - wlc_hw->chanspec = ch20mhz_chspec(1); -} - -static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) -{ - /* delay before first read of ucode state */ - udelay(40); - - /* wait until ucode is no longer asleep */ - SPINWAIT((brcms_b_read_shm(wlc_hw, M_UCODE_DBGST) == - DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); -} - -/* control chip clock to save power, enable dynamic clock or force fast clock */ -static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) -{ - if (wlc_hw->sih->cccaps & CC_CAP_PMU) { - /* new chips with PMU, CCS_FORCEHT will distribute the HT clock - * on backplane, but mac core will still run on ALP(not HT) when - * it enters powersave mode, which means the FCA bit may not be - * set. Should wakeup mac if driver wants it to run on HT. - */ - - if (wlc_hw->clk) { - if (mode == CLK_FAST) { - OR_REG(&wlc_hw->regs->clk_ctl_st, - CCS_FORCEHT); - - udelay(64); - - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) == 0), - PMU_MAX_TRANSITION_DLY); - WARN_ON(!(R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL)); - } else { - if ((wlc_hw->sih->pmurev == 0) && - (R_REG - (&wlc_hw->regs-> - clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) - == 0), - PMU_MAX_TRANSITION_DLY); - AND_REG(&wlc_hw->regs->clk_ctl_st, - ~CCS_FORCEHT); - } - } - wlc_hw->forcefastclk = (mode == CLK_FAST); - } else { - - /* old chips w/o PMU, force HT through cc, - * then use FCA to verify mac is running fast clock - */ - - wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); - - /* check fast clock is available (if core is not in reset) */ - if (wlc_hw->forcefastclk && wlc_hw->clk) - WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) & - SISF_FCLKA)); - - /* - * keep the ucode wake bit on if forcefastclk is on since we - * do not want ucode to put us back to slow clock when it dozes - * for PM mode. Code below matches the wake override bit with - * current forcefastclk state. Only setting bit in wake_override - * instead of waking ucode immediately since old code had this - * behavior. Older code set wlc->forcefastclk but only had the - * wake happen if the wakup_ucode work (protected by an up - * check) was executed just below. - */ - if (wlc_hw->forcefastclk) - mboolset(wlc_hw->wake_override, - BRCMS_WAKE_OVERRIDE_FORCEFAST); - else - mboolclr(wlc_hw->wake_override, - BRCMS_WAKE_OVERRIDE_FORCEFAST); - } -} - -/* set or clear ucode host flag bits - * it has an optimization for no-change write - * it only writes through shared memory when the core has clock; - * pre-CLK changes should use wlc_write_mhf to get around the optimization - * - * - * bands values are: BRCM_BAND_AUTO <--- Current band only - * BRCM_BAND_5G <--- 5G band only - * BRCM_BAND_2G <--- 2G band only - * BRCM_BAND_ALL <--- All bands - */ -void -brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, - int bands) -{ - u16 save; - u16 addr[MHFMAX] = { - M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, - M_HOST_FLAGS5 - }; - struct brcms_hw_band *band; - - if ((val & ~mask) || idx >= MHFMAX) - return; /* error condition */ - - switch (bands) { - /* Current band only or all bands, - * then set the band to current band - */ - case BRCM_BAND_AUTO: - case BRCM_BAND_ALL: - band = wlc_hw->band; - break; - case BRCM_BAND_5G: - band = wlc_hw->bandstate[BAND_5G_INDEX]; - break; - case BRCM_BAND_2G: - band = wlc_hw->bandstate[BAND_2G_INDEX]; - break; - default: - band = NULL; /* error condition */ - } - - if (band) { - save = band->mhfs[idx]; - band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; - - /* optimization: only write through if changed, and - * changed band is the current band - */ - if (wlc_hw->clk && (band->mhfs[idx] != save) - && (band == wlc_hw->band)) - brcms_b_write_shm(wlc_hw, addr[idx], - (u16) band->mhfs[idx]); - } - - if (bands == BRCM_BAND_ALL) { - wlc_hw->bandstate[0]->mhfs[idx] = - (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; - wlc_hw->bandstate[1]->mhfs[idx] = - (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; - } -} - -/* set the maccontrol register to desired reset state and - * initialize the sw cache of the register - */ -static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw) -{ - /* IHR accesses are always enabled, PSM disabled, HPS off and WAKE on */ - wlc_hw->maccontrol = 0; - wlc_hw->suspended_fifos = 0; - wlc_hw->wake_override = 0; - wlc_hw->mute_override = 0; - brcms_b_mctrl(wlc_hw, ~0, MCTL_IHR_EN | MCTL_WAKE); -} - -/* - * write the software state of maccontrol and - * overrides to the maccontrol register - */ -static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) -{ - u32 maccontrol = wlc_hw->maccontrol; - - /* OR in the wake bit if overridden */ - if (wlc_hw->wake_override) - maccontrol |= MCTL_WAKE; - - /* set AP and INFRA bits for mute if needed */ - if (wlc_hw->mute_override) { - maccontrol &= ~(MCTL_AP); - maccontrol |= MCTL_INFRA; - } - - W_REG(&wlc_hw->regs->maccontrol, maccontrol); -} - -/* set or clear maccontrol bits */ -void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) -{ - u32 maccontrol; - u32 new_maccontrol; - - if (val & ~mask) - return; /* error condition */ - maccontrol = wlc_hw->maccontrol; - new_maccontrol = (maccontrol & ~mask) | val; - - /* if the new maccontrol value is the same as the old, nothing to do */ - if (new_maccontrol == maccontrol) - return; - - /* something changed, cache the new value */ - wlc_hw->maccontrol = new_maccontrol; - - /* write the new values with overrides applied */ - brcms_c_mctrl_write(wlc_hw); -} - -void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, - u32 override_bit) -{ - if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { - mboolset(wlc_hw->wake_override, override_bit); - return; - } - - mboolset(wlc_hw->wake_override, override_bit); - - brcms_c_mctrl_write(wlc_hw); - brcms_b_wait_for_wake(wlc_hw); -} - -void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, - u32 override_bit) -{ - mboolclr(wlc_hw->wake_override, override_bit); - - if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) - return; - - brcms_c_mctrl_write(wlc_hw); -} - -/* When driver needs ucode to stop beaconing, it has to make sure that - * MCTL_AP is clear and MCTL_INFRA is set - * Mode MCTL_AP MCTL_INFRA - * AP 1 1 - * STA 0 1 <--- This will ensure no beacons - * IBSS 0 0 - */ -static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw) -{ - wlc_hw->mute_override = 1; - - /* if maccontrol already has AP == 0 and INFRA == 1 without this - * override, then there is no change to write - */ - if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) - return; - - brcms_c_mctrl_write(wlc_hw); -} - -/* Clear the override on AP and INFRA bits */ -static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw) -{ - if (wlc_hw->mute_override == 0) - return; - - wlc_hw->mute_override = 0; - - /* if maccontrol already has AP == 0 and INFRA == 1 without this - * override, then there is no change to write - */ - if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) - return; - - brcms_c_mctrl_write(wlc_hw); -} - -/* - * Write a MAC address to the given match reg offset in the RXE match engine. - */ -static void -brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, - const u8 *addr) -{ - struct d11regs __iomem *regs; - u16 mac_l; - u16 mac_m; - u16 mac_h; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", - wlc_hw->unit); - - regs = wlc_hw->regs; - mac_l = addr[0] | (addr[1] << 8); - mac_m = addr[2] | (addr[3] << 8); - mac_h = addr[4] | (addr[5] << 8); - - /* enter the MAC addr into the RXE match registers */ - W_REG(®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); - W_REG(®s->rcm_mat_data, mac_l); - W_REG(®s->rcm_mat_data, mac_m); - W_REG(®s->rcm_mat_data, mac_h); - -} - -void -brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, - void *buf) -{ - struct d11regs __iomem *regs; - u32 word; - __le32 word_le; - __be32 word_be; - bool be_bit; - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - W_REG(®s->tplatewrptr, offset); - - /* if MCTL_BIGEND bit set in mac control register, - * the chip swaps data in fifo, as well as data in - * template ram - */ - be_bit = (R_REG(®s->maccontrol) & MCTL_BIGEND) != 0; - - while (len > 0) { - memcpy(&word, buf, sizeof(u32)); - - if (be_bit) { - word_be = cpu_to_be32(word); - word = *(u32 *)&word_be; - } else { - word_le = cpu_to_le32(word); - word = *(u32 *)&word_le; - } - - W_REG(®s->tplatewrdata, word); - - buf = (u8 *) buf + sizeof(u32); - len -= sizeof(u32); - } -} - -static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) -{ - wlc_hw->band->CWmin = newmin; - - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmin); -} - -static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) -{ - wlc_hw->band->CWmax = newmax; - - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmax); -} - -void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) -{ - bool fastclk; - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - wlc_phy_bw_state_set(wlc_hw->band->pi, bw); - - brcms_b_phy_reset(wlc_hw); - wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); - - /* restore the clk */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) -{ - u16 v; - struct brcms_c_info *wlc = wlc_hw->wlc; - /* update SYNTHPU_DLY */ - - if (BRCMS_ISLCNPHY(wlc->band)) - v = SYNTHPU_DLY_LPPHY_US; - else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) - v = SYNTHPU_DLY_NPHY_US; - else - v = SYNTHPU_DLY_BPHY_US; - - brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); -} - -static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) -{ - u16 phyctl; - u16 phytxant = wlc_hw->bmac_phytxant; - u16 mask = PHY_TXC_ANT_MASK; - - /* set the Probe Response frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); - - /* set the Response (ACK/CTS) frame phy control word */ - phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); -} - -static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, - u8 rate) -{ - uint i; - u8 plcp_rate = 0; - struct plcp_signal_rate_lookup { - u8 rate; - u8 signal_rate; - }; - /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ - const struct plcp_signal_rate_lookup rate_lookup[] = { - {BRCM_RATE_6M, 0xB}, - {BRCM_RATE_9M, 0xF}, - {BRCM_RATE_12M, 0xA}, - {BRCM_RATE_18M, 0xE}, - {BRCM_RATE_24M, 0x9}, - {BRCM_RATE_36M, 0xD}, - {BRCM_RATE_48M, 0x8}, - {BRCM_RATE_54M, 0xC} - }; - - for (i = 0; i < ARRAY_SIZE(rate_lookup); i++) { - if (rate == rate_lookup[i].rate) { - plcp_rate = rate_lookup[i].signal_rate; - break; - } - } - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); -} - -static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) -{ - u8 rate; - u8 rates[8] = { - BRCM_RATE_6M, BRCM_RATE_9M, BRCM_RATE_12M, BRCM_RATE_18M, - BRCM_RATE_24M, BRCM_RATE_36M, BRCM_RATE_48M, BRCM_RATE_54M - }; - u16 entry_ptr; - u16 pctl1; - uint i; - - if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) - return; - - /* walk the phy rate table and update the entries */ - for (i = 0; i < ARRAY_SIZE(rates); i++) { - rate = rates[i]; - - entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); - - /* read the SHM Rate Table entry OFDM PCTL1 values */ - pctl1 = - brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); - - /* modify the value */ - pctl1 &= ~PHY_TXC1_MODE_MASK; - pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); - - /* Update the SHM Rate Table entry OFDM PCTL1 values */ - brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, - pctl1); - } -} - -/* band-specific init */ -static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc_hw->band->bandunit); - - brcms_c_ucode_bsinit(wlc_hw); - - wlc_phy_init(wlc_hw->band->pi, chanspec); - - brcms_c_ucode_txant_set(wlc_hw); - - /* - * cwmin is band-specific, update hardware - * with value for current band - */ - brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); - brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); - - brcms_b_update_slot_timing(wlc_hw, - wlc_hw->band->bandtype == BRCM_BAND_5G ? - true : wlc_hw->shortslot); - - /* write phytype and phyvers */ - brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); - brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); - - /* - * initialize the txphyctl1 rate table since - * shmem is shared between bands - */ - brcms_upd_ofdm_pctl1_table(wlc_hw); - - brcms_b_upd_synthpu(wlc_hw); -} - -/* Perform a soft reset of the PHY PLL */ -void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 4); - udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); - udelay(1); -} - -/* light way to turn on phy clock without reset for NPHY only - * refer to brcms_b_core_phy_clk for full version - */ -void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk) -{ - /* support(necessary for NPHY and HYPHY) only */ - if (!BRCMS_ISNPHY(wlc_hw->band)) - return; - - if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC); - else - ai_core_cflags(wlc_hw->sih, SICF_FGC, 0); - -} - -void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk) -{ - if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE); - else - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0); -} - -void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) -{ - struct brcms_phy_pub *pih = wlc_hw->band->pi; - u32 phy_bw_clkbits; - bool phy_in_reset = false; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (pih == NULL) - return; - - phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); - - /* Specific reset sequence required for NPHY rev 3 and 4 */ - if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && - NREV_LE(wlc_hw->band->phyrev, 4)) { - /* Set the PHY bandwidth */ - ai_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits); - - udelay(1); - - /* Perform a soft reset of the PHY PLL */ - brcms_b_core_phypll_reset(wlc_hw); - - /* reset the PHY */ - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE), - (SICF_PRST | SICF_PCLKE)); - phy_in_reset = true; - } else { - ai_core_cflags(wlc_hw->sih, - (SICF_PRST | SICF_PCLKE | SICF_BWMASK), - (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); - } - - udelay(2); - brcms_b_core_phy_clk(wlc_hw, ON); - - if (pih) - wlc_phy_anacore(pih, ON); -} - -/* switch to and initialize new band */ -static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, - u16 chanspec) { - struct brcms_c_info *wlc = wlc_hw->wlc; - u32 macintmask; - - /* Enable the d11 core before accessing it */ - if (!ai_iscoreup(wlc_hw->sih)) { - ai_core_reset(wlc_hw->sih, 0, 0); - brcms_c_mctrl_reset(wlc_hw); - } - - macintmask = brcms_c_setband_inact(wlc, bandunit); - - if (!wlc_hw->up) - return; - - brcms_b_core_phy_clk(wlc_hw, ON); - - /* band-specific initializations */ - brcms_b_bsinit(wlc, chanspec); - - /* - * If there are any pending software interrupt bits, - * then replace these with a harmless nonzero value - * so brcms_c_dpc() will re-enable interrupts when done. - */ - if (wlc->macintstatus) - wlc->macintstatus = MI_DMAINT; - - /* restore macintmask */ - brcms_intrsrestore(wlc->wl, macintmask); - - /* ucode should still be suspended.. */ - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); -} - -/* low-level band switch utility routine */ -void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - bandunit); - - wlc_hw->band = wlc_hw->bandstate[bandunit]; - - /* - * BMAC_NOTE: - * until we eliminate need for wlc->band refs in low level code - */ - wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; - - /* set gmode core flag */ - if (wlc_hw->sbclk && !wlc_hw->noreset) - ai_core_cflags(wlc_hw->sih, SICF_GMODE, - ((bandunit == 0) ? SICF_GMODE : 0)); -} - -static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) -{ - - /* reject unsupported corerev */ - if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { - wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", - wlc_hw->corerev); - return false; - } - - return true; -} - -/* Validate some board info parameters */ -static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) -{ - uint boardrev = wlc_hw->boardrev; - - /* 4 bits each for board type, major, minor, and tiny version */ - uint brt = (boardrev & 0xf000) >> 12; - uint b0 = (boardrev & 0xf00) >> 8; - uint b1 = (boardrev & 0xf0) >> 4; - uint b2 = boardrev & 0xf; - - /* voards from other vendors are always considered valid */ - if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM) - return true; - - /* do some boardrev sanity checks when boardvendor is Broadcom */ - if (boardrev == 0) - return false; - - if (boardrev <= 0xff) - return true; - - if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9) - || (b2 > 9)) - return false; - - return true; -} - -static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw) -{ - enum brcms_srom_id var_id = BRCMS_SROM_MACADDR; - char *macaddr; - - /* If macaddr exists, use it (Sromrev4, CIS, ...). */ - macaddr = getvar(wlc_hw->sih, var_id); - if (macaddr != NULL) - return macaddr; - - if (wlc_hw->_nbands > 1) - var_id = BRCMS_SROM_ET1MACADDR; - else - var_id = BRCMS_SROM_IL0MACADDR; - - macaddr = getvar(wlc_hw->sih, var_id); - if (macaddr == NULL) - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr " - "getvar(%d) not found\n", wlc_hw->unit, var_id); - - return macaddr; -} - -/* power both the pll and external oscillator on/off */ -static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); - - /* - * dont power down if plldown is false or - * we must poll hw radio disable - */ - if (!want && wlc_hw->pllreq) - return; - - if (wlc_hw->sih) - ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want); - - wlc_hw->sbclk = want; - if (!wlc_hw->sbclk) { - wlc_hw->clk = false; - if (wlc_hw->band && wlc_hw->band->pi) - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - } -} - -/* - * Return true if radio is disabled, otherwise false. - * hw radio disable signal is an external pin, users activate it asynchronously - * this function could be called when driver is down and w/o clock - * it operates on different registers depending on corerev and boardflag. - */ -static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) -{ - bool v, clk, xtal; - u32 resetbits = 0, flags = 0; - - xtal = wlc_hw->sbclk; - if (!xtal) - brcms_b_xtal(wlc_hw, ON); - - /* may need to take core out of reset first */ - clk = wlc_hw->clk; - if (!clk) { - /* - * mac no longer enables phyclk automatically when driver - * accesses phyreg throughput mac. This can be skipped since - * only mac reg is accessed below - */ - flags |= SICF_PCLKE; - - /* - * AI chip doesn't restore bar0win2 on - * hibernation/resume, need sw fixup - */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - ai_core_reset(wlc_hw->sih, flags, resetbits); - brcms_c_mctrl_reset(wlc_hw); - } - - v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); - - /* put core back into reset */ - if (!clk) - ai_core_disable(wlc_hw->sih, 0); - - if (!xtal) - brcms_b_xtal(wlc_hw, OFF); - - return v; -} - -static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) -{ - struct dma_pub *di = wlc_hw->di[fifo]; - return dma_rxreset(di); -} - -/* d11 core reset - * ensure fask clock during reset - * reset dma - * reset d11(out of reset) - * reset phy(out of reset) - * clear software macintstatus for fresh new start - * one testing hack wlc_hw->noreset will bypass the d11/phy reset - */ -void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) -{ - struct d11regs __iomem *regs; - uint i; - bool fastclk; - u32 resetbits = 0; - - if (flags == BRCMS_USE_COREFLAGS) - flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* reset the dma engines except first time thru */ - if (ai_iscoreup(wlc_hw->sih)) { - for (i = 0; i < NFIFO; i++) - if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " - "dma_txreset[%d]: cannot stop dma\n", - wlc_hw->unit, __func__, i); - - if ((wlc_hw->di[RX_FIFO]) - && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) - wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset" - "[%d]: cannot stop dma\n", - wlc_hw->unit, __func__, RX_FIFO); - } - /* if noreset, just stop the psm and return */ - if (wlc_hw->noreset) { - wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ - brcms_b_mctrl(wlc_hw, MCTL_PSM_RUN | MCTL_EN_MAC, 0); - return; - } - - /* - * mac no longer enables phyclk automatically when driver accesses - * phyreg throughput mac, AND phy_reset is skipped at early stage when - * band->pi is invalid. need to enable PHY CLK - */ - flags |= SICF_PCLKE; - - /* - * reset the core - * In chips with PMU, the fastclk request goes through d11 core - * reg 0x1e0, which is cleared by the core_reset. have to re-request it. - * - * This adds some delay and we can optimize it by also requesting - * fastclk through chipcommon during this period if necessary. But - * that has to work coordinate with other driver like mips/arm since - * they may touch chipcommon as well. - */ - wlc_hw->clk = false; - ai_core_reset(wlc_hw->sih, flags, resetbits); - wlc_hw->clk = true; - if (wlc_hw->band && wlc_hw->band->pi) - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); - - brcms_c_mctrl_reset(wlc_hw); - - if (wlc_hw->sih->cccaps & CC_CAP_PMU) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - brcms_b_phy_reset(wlc_hw); - - /* turn on PHY_PLL */ - brcms_b_core_phypll_ctl(wlc_hw, true); - - /* clear sw intstatus */ - wlc_hw->wlc->macintstatus = 0; - - /* restore the clk setting */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -/* txfifo sizes needs to be modified(increased) since the newer cores - * have more memory. - */ -static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - u16 fifo_nu; - u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; - u16 txfifo_def, txfifo_def1; - u16 txfifo_cmd; - - /* tx fifos start at TXFIFO_START_BLK from the Base address */ - txfifo_startblk = TXFIFO_START_BLK; - - /* sequence of operations: reset fifo, set fifo size, reset fifo */ - for (fifo_nu = 0; fifo_nu < NFIFO; fifo_nu++) { - - txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; - txfifo_def = (txfifo_startblk & 0xff) | - (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); - txfifo_def1 = ((txfifo_startblk >> 8) & 0x1) | - ((((txfifo_endblk - - 1) >> 8) & 0x1) << TXFIFO_FIFOTOP_SHIFT); - txfifo_cmd = - TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); - - W_REG(®s->xmtfifocmd, txfifo_cmd); - W_REG(®s->xmtfifodef, txfifo_def); - W_REG(®s->xmtfifodef1, txfifo_def1); - - W_REG(®s->xmtfifocmd, txfifo_cmd); - - txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; - } - /* - * need to propagate to shm location to be in sync since ucode/hw won't - * do this - */ - brcms_b_write_shm(wlc_hw, M_FIFOSIZE0, - wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE1, - wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE2, - ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> - xmtfifo_sz[TX_AC_BK_FIFO])); - brcms_b_write_shm(wlc_hw, M_FIFOSIZE3, - ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> - xmtfifo_sz[TX_BCMC_FIFO])); -} - -/* This function is used for changing the tsf frac register - * If spur avoidance mode is off, the mac freq will be 80/120/160Mhz - * If spur avoidance mode is on1, the mac freq will be 82/123/164Mhz - * If spur avoidance mode is on2, the mac freq will be 84/126/168Mhz - * HTPHY Formula is 2^26/freq(MHz) e.g. - * For spuron2 - 126MHz -> 2^26/126 = 532610.0 - * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082 - * For spuron: 123MHz -> 2^26/123 = 545600.5 - * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341 - * For spur off: 120MHz -> 2^26/120 = 559240.5 - * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889 - */ - -void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { - if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x2082); - W_REG(®s->tsf_clk_frac_h, 0x8); - } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x5341); - W_REG(®s->tsf_clk_frac_h, 0x8); - } else { /* 120Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x8889); - W_REG(®s->tsf_clk_frac_h, 0x8); - } - } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { - if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x7CE0); - W_REG(®s->tsf_clk_frac_h, 0xC); - } else { /* 80Mhz */ - W_REG(®s->tsf_clk_frac_l, 0xCCCD); - W_REG(®s->tsf_clk_frac_h, 0xC); - } - } -} - -/* Initialize GPIOs that are controlled by D11 core */ -static void brcms_c_gpio_init(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs; - u32 gc, gm; - - regs = wlc_hw->regs; - - /* use GPIO select 0 to get all gpio signals from the gpio out reg */ - brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); - - /* - * Common GPIO setup: - * G0 = LED 0 = WLAN Activity - * G1 = LED 1 = WLAN 2.4 GHz Radio State - * G2 = LED 2 = WLAN 5 GHz Radio State - * G4 = radio disable input (HI enabled, LO disabled) - */ - - gc = gm = 0; - - /* Allocate GPIOs for mimo antenna diversity feature */ - if (wlc_hw->antsel_type == ANTSEL_2x3) { - /* Enable antenna diversity, use 2x3 mode */ - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, BRCM_BAND_ALL); - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, - MHF3_ANTSEL_MODE, BRCM_BAND_ALL); - - /* init superswitch control */ - wlc_phy_antsel_init(wlc_hw->band->pi, false); - - } else if (wlc_hw->antsel_type == ANTSEL_2x4) { - gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13); - /* - * The board itself is powered by these GPIOs - * (when not sending pattern) so set them high - */ - OR_REG(®s->psm_gpio_oe, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - OR_REG(®s->psm_gpio_out, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - - /* Enable antenna diversity, use 2x4 mode */ - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, BRCM_BAND_ALL); - brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, - BRCM_BAND_ALL); - - /* Configure the desired clock to be 4Mhz */ - brcms_b_write_shm(wlc_hw, M_ANTSEL_CLKDIV, - ANTSEL_CLKDIV_4MHZ); - } - - /* - * gpio 9 controls the PA. ucode is responsible - * for wiggling out and oe - */ - if (wlc_hw->boardflags & BFL_PACTRL) - gm |= gc |= BOARD_GPIO_PACTRL; - - /* apply to gpiocontrol register */ - ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY); -} - -static void brcms_ucode_write(struct brcms_hardware *wlc_hw, - const __le32 ucode[], const size_t nbytes) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - uint i; - uint count; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - count = (nbytes / sizeof(u32)); - - W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); - (void)R_REG(®s->objaddr); - for (i = 0; i < count; i++) - W_REG(®s->objdata, le32_to_cpu(ucode[i])); - -} - -static void brcms_ucode_download(struct brcms_hardware *wlc_hw) -{ - struct brcms_c_info *wlc; - struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; - - wlc = wlc_hw->wlc; - - if (wlc_hw->ucode_loaded) - return; - - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, - ucode->bcm43xx_16_mimosz); - wlc_hw->ucode_loaded = true; - } else - wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " - "corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) { - brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, - ucode->bcm43xx_24_lcnsz); - wlc_hw->ucode_loaded = true; - } else { - wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " - "corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - } -} - -void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant) -{ - /* update sw state */ - wlc_hw->bmac_phytxant = phytxant; - - /* push to ucode if up */ - if (!wlc_hw->up) - return; - brcms_c_ucode_txant_set(wlc_hw); - -} - -u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw) -{ - return (u16) wlc_hw->wlc->stf->txant; -} - -void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) -{ - wlc_hw->antsel_type = antsel_type; - - /* Update the antsel type for phy module to use */ - wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); -} - -static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) -{ - bool fatal = false; - uint unit; - uint intstatus, idx; - struct d11regs __iomem *regs = wlc_hw->regs; - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - - unit = wlc_hw->unit; - - for (idx = 0; idx < NFIFO; idx++) { - /* read intstatus register and ignore any non-error bits */ - intstatus = - R_REG(®s->intctrlregs[idx].intstatus) & I_ERRORS; - if (!intstatus) - continue; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: intstatus%d 0x%x\n", - unit, idx, intstatus); - - if (intstatus & I_RO) { - wiphy_err(wiphy, "wl%d: fifo %d: receive fifo " - "overflow\n", unit, idx); - fatal = true; - } - - if (intstatus & I_PC) { - wiphy_err(wiphy, "wl%d: fifo %d: descriptor error\n", - unit, idx); - fatal = true; - } - - if (intstatus & I_PD) { - wiphy_err(wiphy, "wl%d: fifo %d: data error\n", unit, - idx); - fatal = true; - } - - if (intstatus & I_DE) { - wiphy_err(wiphy, "wl%d: fifo %d: descriptor protocol " - "error\n", unit, idx); - fatal = true; - } - - if (intstatus & I_RU) - wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor " - "underflow\n", idx, unit); - - if (intstatus & I_XU) { - wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo " - "underflow\n", idx, unit); - fatal = true; - } - - if (fatal) { - brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ - break; - } else - W_REG(®s->intctrlregs[idx].intstatus, - intstatus); - } -} - -void brcms_c_intrson(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - wlc->macintmask = wlc->defmacintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); -} - -/* - * callback for siutils.c, which has only wlc handler, no wl they both check - * up, not only because there is no need to off/restore d11 interrupt but also - * because per-port code may require sync with valid interrupt. - */ -static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc) -{ - if (!wlc->hw->up) - return 0; - - return brcms_intrsoff(wlc->wl); -} - -static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask) -{ - if (!wlc->hw->up) - return; - - brcms_intrsrestore(wlc->wl, macintmask); -} - -u32 brcms_c_intrsoff(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintmask; - - if (!wlc_hw->clk) - return 0; - - macintmask = wlc->macintmask; /* isr can still happen */ - - W_REG(&wlc_hw->regs->macintmask, 0); - (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ - udelay(1); /* ensure int line is no longer driven */ - wlc->macintmask = 0; - - /* return previous macintmask; resolve race between us and our isr */ - return wlc->macintstatus ? 0 : macintmask; -} - -void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - if (!wlc_hw->clk) - return; - - wlc->macintmask = macintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); -} - -static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - u8 fifo = 1 << tx_fifo; - - /* Two clients of this code, 11h Quiet period and scanning. */ - - /* only suspend if not already suspended */ - if ((wlc_hw->suspended_fifos & fifo) == fifo) - return; - - /* force the core awake only if not already */ - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_set(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - - wlc_hw->suspended_fifos |= fifo; - - if (wlc_hw->di[tx_fifo]) { - /* - * Suspending AMPDU transmissions in the middle can cause - * underflow which may result in mismatch between ucode and - * driver so suspend the mac before suspending the FIFO - */ - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - - dma_txsuspend(wlc_hw->di[tx_fifo]); - - if (BRCMS_PHY_11N_CAP(wlc_hw->band)) - brcms_c_enable_mac(wlc_hw->wlc); - } -} - -static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, - uint tx_fifo) -{ - /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case - * but need to be done here for PIO otherwise the watchdog will catch - * the inconsistency and fire - */ - /* Two clients of this code, 11h Quiet period and scanning. */ - if (wlc_hw->di[tx_fifo]) - dma_txresume(wlc_hw->di[tx_fifo]); - - /* allow core to sleep again */ - if (wlc_hw->suspended_fifos == 0) - return; - else { - wlc_hw->suspended_fifos &= ~(1 << tx_fifo); - if (wlc_hw->suspended_fifos == 0) - brcms_c_ucode_wake_override_clear(wlc_hw, - BRCMS_WAKE_OVERRIDE_TXFIFO); - } -} - -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) -{ - const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; - - if (on) { - /* suspend tx fifos */ - brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_BK_FIFO); - brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_VI_FIFO); - - /* zero the address match register so we do not send ACKs */ - brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - null_ether_addr); - } else { - /* resume tx fifos */ - brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); - brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); - brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); - brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); - - /* Restore address */ - brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - wlc_hw->etheraddr); - } - - wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); - - if (on) - brcms_c_ucode_mute_override_set(wlc_hw); - else - brcms_c_ucode_mute_override_clear(wlc_hw); -} - -/* - * Read and clear macintmask and macintstatus and intstatus registers. - * This routine should be called with interrupts off - * Return: - * -1 if brcms_deviceremoved(wlc) evaluates to true; - * 0 if the interrupt is not for us, or we are in some special cases; - * device interrupt status bits otherwise. - */ -static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; - u32 macintstatus; - - /* macintstatus includes a DMA interrupt summary bit */ - macintstatus = R_REG(®s->macintstatus); - - BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, - macintstatus); - - /* detect cardbus removed, in power down(suspend) and in reset */ - if (brcms_deviceremoved(wlc)) - return -1; - - /* brcms_deviceremoved() succeeds even when the core is still resetting, - * handle that case here. - */ - if (macintstatus == 0xffffffff) - return 0; - - /* defer unsolicited interrupts */ - macintstatus &= (in_isr ? wlc->macintmask : wlc->defmacintmask); - - /* if not for us */ - if (macintstatus == 0) - return 0; - - /* interrupts are already turned off for CFE build - * Caution: For CFE Turning off the interrupts again has some undesired - * consequences - */ - /* turn off the interrupts */ - W_REG(®s->macintmask, 0); - (void)R_REG(®s->macintmask); /* sync readback */ - wlc->macintmask = 0; - - /* clear device interrupts */ - W_REG(®s->macintstatus, macintstatus); - - /* MI_DMAINT is indication of non-zero intstatus */ - if (macintstatus & MI_DMAINT) - /* - * only fifo interrupt enabled is I_RI in - * RX_FIFO. If MI_DMAINT is set, assume it - * is set and clear the interrupt. - */ - W_REG(®s->intctrlregs[RX_FIFO].intstatus, - DEF_RXINTMASK); - - return macintstatus; -} - -/* Update wlc->macintstatus and wlc->intstatus[]. */ -/* Return true if they are updated successfully. false otherwise */ -bool brcms_c_intrsupd(struct brcms_c_info *wlc) -{ - u32 macintstatus; - - /* read and clear macintstatus and intstatus registers */ - macintstatus = wlc_intstatus(wlc, false); - - /* device is removed */ - if (macintstatus == 0xffffffff) - return false; - - /* update interrupt status in software */ - wlc->macintstatus |= macintstatus; - - return true; -} - -/* - * First-level interrupt processing. - * Return true if this was our interrupt, false otherwise. - * *wantdpc will be set to true if further brcms_c_dpc() processing is required, - * false otherwise. - */ -bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - u32 macintstatus; - - *wantdpc = false; - - if (!wlc_hw->up || !wlc->macintmask) - return false; - - /* read and clear macintstatus and intstatus registers */ - macintstatus = wlc_intstatus(wlc, true); - - if (macintstatus == 0xffffffff) - wiphy_err(wlc->wiphy, "DEVICEREMOVED detected in the ISR code" - " path\n"); - - /* it is not for us */ - if (macintstatus == 0) - return false; - - *wantdpc = true; - - /* save interrupt status bits */ - wlc->macintstatus = macintstatus; - - return true; - -} - -void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; - u32 mc, mi; - struct wiphy *wiphy = wlc->wiphy; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc_hw->band->bandunit); - - /* - * Track overlapping suspend requests - */ - wlc_hw->mac_suspend_depth++; - if (wlc_hw->mac_suspend_depth > 1) - return; - - /* force the core awake */ - brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - - mc = R_REG(®s->maccontrol); - - if (mc == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_PSM_RUN)); - WARN_ON(!(mc & MCTL_EN_MAC)); - - mi = R_REG(®s->macintstatus); - if (mi == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mi & MI_MACSSPNDD); - - brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); - - SPINWAIT(!(R_REG(®s->macintstatus) & MI_MACSSPNDD), - BRCMS_MAX_MAC_SUSPEND); - - if (!(R_REG(®s->macintstatus) & MI_MACSSPNDD)) { - wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" - " and MI_MACSSPNDD is still not on.\n", - wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); - wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " - "psm_brc 0x%04x\n", wlc_hw->unit, - R_REG(®s->psmdebug), - R_REG(®s->phydebug), - R_REG(®s->psm_brc)); - } - - mc = R_REG(®s->maccontrol); - if (mc == 0xffffffff) { - wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, - __func__); - brcms_down(wlc->wl); - return; - } - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_PSM_RUN)); - WARN_ON(mc & MCTL_EN_MAC); -} - -void brcms_c_enable_mac(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; - u32 mc, mi; - - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, - wlc->band->bandunit); - - /* - * Track overlapping suspend requests - */ - wlc_hw->mac_suspend_depth--; - if (wlc_hw->mac_suspend_depth > 0) - return; - - mc = R_REG(®s->maccontrol); - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(mc & MCTL_EN_MAC); - WARN_ON(!(mc & MCTL_PSM_RUN)); - - brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); - W_REG(®s->macintstatus, MI_MACSSPNDD); - - mc = R_REG(®s->maccontrol); - WARN_ON(mc & MCTL_PSM_JMP_0); - WARN_ON(!(mc & MCTL_EN_MAC)); - WARN_ON(!(mc & MCTL_PSM_RUN)); - - mi = R_REG(®s->macintstatus); - WARN_ON(mi & MI_MACSSPNDD); - - brcms_c_ucode_wake_override_clear(wlc_hw, - BRCMS_WAKE_OVERRIDE_MACSUSPEND); -} - -void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) -{ - wlc_hw->hw_stf_ss_opmode = stf_mode; - - if (wlc_hw->clk) - brcms_upd_ofdm_pctl1_table(wlc_hw); -} - -static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) -{ - struct d11regs __iomem *regs; - u32 w, val; - struct wiphy *wiphy = wlc_hw->wlc->wiphy; - - BCMMSG(wiphy, "wl%d\n", wlc_hw->unit); - - regs = wlc_hw->regs; - - /* Validate dchip register access */ - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - w = R_REG(®s->objdata); - - /* Can we write and read back a 32bit register? */ - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0xaa5555aa); - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); - if (val != (u32) 0xaa5555aa) { - wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " - "expected 0xaa5555aa\n", wlc_hw->unit, val); - return false; - } - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0x55aaaa55); - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); - if (val != (u32) 0x55aaaa55) { - wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " - "expected 0x55aaaa55\n", wlc_hw->unit, val); - return false; - } - - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, w); - - /* clear CFPStart */ - W_REG(®s->tsf_cfpstart, 0); - - w = R_REG(®s->maccontrol); - if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && - (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { - wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = " - "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, - (MCTL_IHR_EN | MCTL_WAKE), - (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE)); - return false; - } - - return true; -} - -#define PHYPLL_WAIT_US 100000 - -void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) -{ - struct d11regs __iomem *regs; - u32 tmp; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - tmp = 0; - regs = wlc_hw->regs; - - if (on) { - if ((wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | - CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & - (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), - PHYPLL_WAIT_US); - - tmp = R_REG(®s->clk_ctl_st); - if ((tmp & (CCS_ERSRC_AVAIL_HT)) != - (CCS_ERSRC_AVAIL_HT)) - wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" - " PLL failed\n", __func__); - } else { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & - (CCS_ERSRC_AVAIL_D11PLL | - CCS_ERSRC_AVAIL_PHYPLL)) != - (CCS_ERSRC_AVAIL_D11PLL | - CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); - - tmp = R_REG(®s->clk_ctl_st); - if ((tmp & - (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) - != - (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) - wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on " - "PHY PLL failed\n", __func__); - } - } else { - /* - * Since the PLL may be shared, other cores can still - * be requesting it; so we'll deassert the request but - * not wait for status to comply. - */ - AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); - tmp = R_REG(®s->clk_ctl_st); - } -} - -void brcms_c_coredisable(struct brcms_hardware *wlc_hw) -{ - bool dev_gone; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - dev_gone = brcms_deviceremoved(wlc_hw->wlc); - - if (dev_gone) - return; - - if (wlc_hw->noreset) - return; - - /* radio off */ - wlc_phy_switch_radio(wlc_hw->band->pi, OFF); - - /* turn off analog core */ - wlc_phy_anacore(wlc_hw->band->pi, OFF); - - /* turn off PHYPLL to save power */ - brcms_b_core_phypll_ctl(wlc_hw, false); - - wlc_hw->clk = false; - ai_core_disable(wlc_hw->sih, 0); - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); -} - -static void brcms_c_flushqueues(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - uint i; - - /* free any posted tx packets */ - for (i = 0; i < NFIFO; i++) - if (wlc_hw->di[i]) { - dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); - wlc->core->txpktpend[i] = 0; - BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); - } - - /* free any posted rx packets */ - dma_rxreclaim(wlc_hw->di[RX_FIFO]); -} - -static u16 -brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; - u16 __iomem *objdata_hi = objdata_lo + 1; - u16 v; - - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); - if (offset & 2) - v = R_REG(objdata_hi); - else - v = R_REG(objdata_lo); - - return v; -} - -static void -brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, - u32 sel) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; - u16 __iomem *objdata_hi = objdata_lo + 1; - - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); - if (offset & 2) - W_REG(objdata_hi, v); - else - W_REG(objdata_lo, v); -} - -/* - * Read a single u16 from shared memory. - * SHM 'offset' needs to be an even address - */ -u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) -{ - return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); -} - -/* - * Write a single u16 to shared memory. - * SHM 'offset' needs to be an even address - */ -void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) -{ - brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); -} - -/* - * Copy a buffer to shared memory of specified type . - * SHM 'offset' needs to be an even address and - * Buffer length 'len' must be an even number of bytes - * 'sel' selects the type of memory - */ -void -brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset, - const void *buf, int len, u32 sel) -{ - u16 v; - const u8 *p = (const u8 *)buf; - int i; - - if (len <= 0 || (offset & 1) || (len & 1)) - return; - - for (i = 0; i < len; i += 2) { - v = p[i] | (p[i + 1] << 8); - brcms_b_write_objmem(wlc_hw, offset + i, v, sel); - } -} - -/* - * Copy a piece of shared memory of specified type to a buffer . - * SHM 'offset' needs to be an even address and - * Buffer length 'len' must be an even number of bytes - * 'sel' selects the type of memory - */ -void -brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, - int len, u32 sel) -{ - u16 v; - u8 *p = (u8 *) buf; - int i; - - if (len <= 0 || (offset & 1) || (len & 1)) - return; - - for (i = 0; i < len; i += 2) { - v = brcms_b_read_objmem(wlc_hw, offset + i, sel); - p[i] = v & 0xFF; - p[i + 1] = (v >> 8) & 0xFF; - } -} - -static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, - u16 SRL, u16 LRL) -{ - wlc_hw->SRL = SRL; - wlc_hw->LRL = LRL; - - /* write retry limit to SCR, shouldn't need to suspend */ - if (wlc_hw->up) { - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); - } -} - -static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) -{ - if (set) { - if (mboolisset(wlc_hw->pllreq, req_bit)) - return; - - mboolset(wlc_hw->pllreq, req_bit); - - if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (!wlc_hw->sbclk) - brcms_b_xtal(wlc_hw, ON); - } - } else { - if (!mboolisset(wlc_hw->pllreq, req_bit)) - return; - - mboolclr(wlc_hw->pllreq, req_bit); - - if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { - if (wlc_hw->sbclk) - brcms_b_xtal(wlc_hw, OFF); - } - } -} - -static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) -{ - wlc_hw->antsel_avail = antsel_avail; -} - -/* - * conditions under which the PM bit should be set in outgoing frames - * and STAY_AWAKE is meaningful - */ -bool brcms_c_ps_allowed(struct brcms_c_info *wlc) -{ - struct brcms_bss_cfg *cfg = wlc->bsscfg; - - /* disallow PS when one of the following global conditions meets */ - if (!wlc->pub->associated) - return false; - - /* disallow PS when one of these meets when not scanning */ - if (wlc->monitor) - return false; - - if (cfg->associated) { - /* - * disallow PS when one of the following - * bsscfg specific conditions meets - */ - if (!cfg->BSS) - return false; - - return false; - } - - return true; -} - -static void brcms_b_reset(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset the core */ - if (!brcms_deviceremoved(wlc_hw->wlc)) - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - /* purge the dma rings */ - brcms_c_flushqueues(wlc_hw->wlc); -} - -void brcms_c_reset(struct brcms_c_info *wlc) -{ - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - /* slurp up hw mac counters before core reset */ - brcms_c_statsupd(wlc); - - /* reset our snapshot of macstat counters */ - memset((char *)wlc->core->macstat_snapshot, 0, - sizeof(struct macstat)); - - brcms_b_reset(wlc->hw); -} - -void brcms_c_fatal_error(struct brcms_c_info *wlc) -{ - wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n", - wlc->pub->unit); - brcms_init(wlc->wl); -} - -/* Return the channel the driver should initialize during brcms_c_init. - * the channel may have to be changed from the currently configured channel - * if other configurations are in conflict (bandlocked, 11n mode disabled, - * invalid channel for current country, etc.) - */ -static u16 brcms_c_init_chanspec(struct brcms_c_info *wlc) -{ - u16 chanspec = - 1 | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE | - WL_CHANSPEC_BAND_2G; - - return chanspec; -} - -void brcms_c_init_scb(struct scb *scb) -{ - int i; - - memset(scb, 0, sizeof(struct scb)); - scb->flags = SCB_WMECAP | SCB_HTCAP; - for (i = 0; i < NUMPRIO; i++) { - scb->seqnum[i] = 0; - scb->seqctl[i] = 0xFFFF; - } - - scb->seqctl_nonqos = 0xFFFF; - scb->magic = SCB_MAGIC; -} - -/* d11 core init - * reset PSM - * download ucode/PCM - * let ucode run to suspended - * download ucode inits - * config other core registers - * init dma - */ -static void brcms_b_coreinit(struct brcms_c_info *wlc) -{ - struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs; - u32 sflags; - uint bcnint_us; - uint i = 0; - bool fifosz_fixup = false; - int err = 0; - u16 buf[NFIFO]; - struct wiphy *wiphy = wlc->wiphy; - struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; - - regs = wlc_hw->regs; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* reset PSM */ - brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); - - brcms_ucode_download(wlc_hw); - /* - * FIFOSZ fixup. driver wants to controls the fifo allocation. - */ - fifosz_fixup = true; - - /* let the PSM run to the suspended state, set mode to BSS STA */ - W_REG(®s->macintstatus, -1); - brcms_b_mctrl(wlc_hw, ~0, - (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); - - /* wait for ucode to self-suspend after auto-init */ - SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), - 1000 * 1000); - if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) - wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" - "suspend!\n", wlc_hw->unit); - - brcms_c_gpio_init(wlc); - - sflags = ai_core_sflags(wlc_hw->sih, 0, 0); - - if (D11REV_IS(wlc_hw->corerev, 23)) { - if (BRCMS_ISNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } else if (D11REV_IS(wlc_hw->corerev, 24)) { - if (BRCMS_ISLCNPHY(wlc_hw->band)) - brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); - else - wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" - " %d\n", __func__, wlc_hw->unit, - wlc_hw->corerev); - } else { - wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", - __func__, wlc_hw->unit, wlc_hw->corerev); - } - - /* For old ucode, txfifo sizes needs to be modified(increased) */ - if (fifosz_fixup == true) - brcms_b_corerev_fifofixup(wlc_hw); - - /* check txfifo allocations match between ucode and driver */ - buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); - if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { - i = TX_AC_BE_FIFO; - err = -1; - } - buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); - if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { - i = TX_AC_VI_FIFO; - err = -1; - } - buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); - buf[TX_AC_VO_FIFO] = (buf[TX_AC_BK_FIFO] >> 8) & 0xff; - buf[TX_AC_BK_FIFO] &= 0xff; - if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { - i = TX_AC_BK_FIFO; - err = -1; - } - if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { - i = TX_AC_VO_FIFO; - err = -1; - } - buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); - buf[TX_ATIM_FIFO] = (buf[TX_BCMC_FIFO] >> 8) & 0xff; - buf[TX_BCMC_FIFO] &= 0xff; - if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { - i = TX_BCMC_FIFO; - err = -1; - } - if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { - i = TX_ATIM_FIFO; - err = -1; - } - if (err != 0) - wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" - " driver size %d index %d\n", buf[i], - wlc_hw->xmtfifo_sz[i], i); - - /* make sure we can still talk to the mac */ - WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); - - /* band-specific inits done by wlc_bsinit() */ - - /* Set up frame burst size and antenna swap threshold init values */ - brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); - brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); - - /* enable one rx interrupt per received frame */ - W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); - - /* set the station mode (BSS STA) */ - brcms_b_mctrl(wlc_hw, - (MCTL_INFRA | MCTL_DISCARD_PMQ | MCTL_AP), - (MCTL_INFRA | MCTL_DISCARD_PMQ)); - - /* set up Beacon interval */ - bcnint_us = 0x8000 << 10; - W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); - W_REG(®s->tsf_cfpstart, bcnint_us); - W_REG(®s->macintstatus, MI_GP1); - - /* write interrupt mask */ - W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); - - /* allow the MAC to control the PHY clock (dynamic on/off) */ - brcms_b_macphyclk_set(wlc_hw, ON); - - /* program dynamic clock control fast powerup delay register */ - wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); - W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); - - /* tell the ucode the corerev */ - brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); - - /* tell the ucode MAC capabilities */ - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, - (u16) (wlc_hw->machwcap & 0xffff)); - brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, - (u16) ((wlc_hw-> - machwcap >> 16) & 0xffff)); - - /* write retry limits to SCR, this done after PSM init */ - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->SRL); - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->LRL); - - /* write rate fallback retry limits */ - brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); - brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); - - AND_REG(®s->ifs_ctl, 0x0FFF); - W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); - - /* init the tx dma engines */ - for (i = 0; i < NFIFO; i++) { - if (wlc_hw->di[i]) - dma_txinit(wlc_hw->di[i]); - } - - /* init the rx dma engine(s) and post receive buffers */ - dma_rxinit(wlc_hw->di[RX_FIFO]); - dma_rxfill(wlc_hw->di[RX_FIFO]); -} - -void -static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, - bool mute) { - u32 macintmask; - bool fastclk; - struct brcms_c_info *wlc = wlc_hw->wlc; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* request FAST clock if not on */ - fastclk = wlc_hw->forcefastclk; - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* disable interrupts */ - macintmask = brcms_intrsoff(wlc->wl); - - /* set up the specified band and chanspec */ - brcms_c_setxband(wlc_hw, chspec_bandunit(chanspec)); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - - /* do one-time phy inits and calibration */ - wlc_phy_cal_init(wlc_hw->band->pi); - - /* core-specific initialization */ - brcms_b_coreinit(wlc); - - /* suspend the tx fifos and mute the phy for preism cac time */ - if (mute) - brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); - - /* band-specific inits */ - brcms_b_bsinit(wlc, chanspec); - - /* restore macintmask */ - brcms_intrsrestore(wlc->wl, macintmask); - - /* seed wake_override with BRCMS_WAKE_OVERRIDE_MACSUSPEND since the mac - * is suspended and brcms_c_enable_mac() will clear this override bit. - */ - mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - - /* - * initialize mac_suspend_depth to 1 to match ucode - * initial suspended state - */ - wlc_hw->mac_suspend_depth = 1; - - /* restore the clk */ - if (!fastclk) - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); -} - -static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, - u16 chanspec) -{ - /* Save our copy of the chanspec */ - wlc->chanspec = chanspec; - - /* Set the chanspec and power limits for this locale */ - brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); - - if (wlc->stf->ss_algosel_auto) - brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, - chanspec); - - brcms_c_stf_ss_update(wlc, wlc->band); - -} - -static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, - u16 chanspec) -{ - struct brcms_c_rateset default_rateset; - uint parkband; - uint i, band_order[2]; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - /* - * We might have been bandlocked during down and the chip - * power-cycled (hibernate). Figure out the right band to park on - */ - if (wlc->bandlocked || wlc->pub->_nbands == 1) { - /* updated in brcms_c_bandlock() */ - parkband = wlc->band->bandunit; - band_order[0] = band_order[1] = parkband; - } else { - /* park on the band of the specified chanspec */ - parkband = chspec_bandunit(chanspec); - - /* order so that parkband initialize last */ - band_order[0] = parkband ^ 1; - band_order[1] = parkband; - } - - /* make each band operational, software state init */ - for (i = 0; i < wlc->pub->_nbands; i++) { - uint j = band_order[i]; - - wlc->band = wlc->bandstate[j]; - - brcms_default_rateset(wlc, &default_rateset); - - /* fill in hw_rate */ - brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, - false, BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, - (bool) (wlc->pub->_n_enab & SUPPORT_11N)); - - /* init basic rate lookup */ - brcms_c_rate_lookup_init(wlc, &default_rateset); - } - - /* sync up phy/radio chanspec */ - brcms_c_set_phy_chanspec(wlc, chanspec); -} - -/* - * ucode, hwmac update - * Channel dependent updates for ucode and hw - */ -static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) -{ - /* enable or disable any active IBSSs depending on whether or not - * we are on the home channel - */ - if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { - if (wlc->pub->associated) { - /* - * BMAC_NOTE: This is something that should be fixed - * in ucode inits. I think that the ucode inits set - * up the bcn templates and shm values with a bogus - * beacon. This should not be done in the inits. If - * ucode needs to set up a beacon for testing, the - * test routines should write it down, not expect the - * inits to populate a bogus beacon. - */ - if (BRCMS_PHY_11N_CAP(wlc->band)) - brcms_b_write_shm(wlc->hw, - M_BCN_TXTSF_OFFSET, 0); - } - } else { - /* disable an active IBSS if we are not on the home channel */ - } - - /* update the various promisc bits */ - brcms_c_mac_bcn_promisc(wlc); - brcms_c_mac_promisc(wlc); -} - -/* band-specific init */ -static void brcms_c_bsinit(struct brcms_c_info *wlc) -{ - BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", - wlc->pub->unit, wlc->band->bandunit); - - /* write ucode ACK/CTS rate table */ - brcms_c_set_ratetable(wlc); - - /* update some band specific mac configuration */ - brcms_c_ucode_mac_upd(wlc); - - /* init antenna selection */ - brcms_c_antsel_init(wlc->asi); - -} - -/* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */ -static int -brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, - bool writeToShm) -{ - int idle_busy_ratio_x_16 = 0; - uint offset = - isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM : - M_TX_IDLE_BUSY_RATIO_X_16_CCK; - if (duty_cycle > 100 || duty_cycle < 0) { - wiphy_err(wlc->wiphy, "wl%d: duty cycle value off limit\n", - wlc->pub->unit); - return -EINVAL; - } - if (duty_cycle) - idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; - /* Only write to shared memory when wl is up */ - if (writeToShm) - brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); - - if (isOFDM) - wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; - else - wlc->tx_duty_cycle_cck = (u16) duty_cycle; - - return 0; -} - -/* - * Initialize the base precedence map for dequeueing - * from txq based on WME settings - */ -static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc) -{ - wlc->tx_prec_map = BRCMS_PREC_BMP_ALL; - memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16)); - - wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK; - wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE; - wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI; - wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO; -} - -static void -brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, bool on, int prio) -{ - /* transmit flowcontrol is not yet implemented */ -} - -static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc) -{ - struct brcms_txq_info *qi; - - for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { - if (qi->stopped) { - brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO); - qi->stopped = 0; - } - } -} - -void brcms_c_init(struct brcms_c_info *wlc) -{ - struct d11regs __iomem *regs; - u16 chanspec; - bool mute = false; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - regs = wlc->regs; - - /* - * This will happen if a big-hammer was executed. In - * that case, we want to go back to the channel that - * we were on and not new channel - */ - if (wlc->pub->associated) - chanspec = wlc->home_chanspec; - else - chanspec = brcms_c_init_chanspec(wlc); - - brcms_b_init(wlc->hw, chanspec, mute); - - /* update beacon listen interval */ - brcms_c_bcn_li_upd(wlc); - - /* write ethernet address to core */ - brcms_c_set_mac(wlc->bsscfg); - brcms_c_set_bssid(wlc->bsscfg); - - /* Update tsf_cfprep if associated and up */ - if (wlc->pub->associated && wlc->bsscfg->up) { - u32 bi; - - /* get beacon period and convert to uS */ - bi = wlc->bsscfg->current_bss->beacon_period << 10; - /* - * update since init path would reset - * to default value - */ - W_REG(®s->tsf_cfprep, - (bi << CFPREP_CBI_SHIFT)); - - /* Update maccontrol PM related bits */ - brcms_c_set_ps_ctrl(wlc); - } - - brcms_c_bandinit_ordered(wlc, chanspec); - - /* init probe response timeout */ - brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); - - /* init max burst txop (framebursting) */ - brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, - (wlc-> - _rifs ? (EDCF_AC_VO_TXOP_AP << 5) : MAXFRAMEBURST_TXOP)); - - /* initialize maximum allowed duty cycle */ - brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); - brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); - - /* - * Update some shared memory locations related to - * max AMPDU size allowed to received - */ - brcms_c_ampdu_shm_upd(wlc->ampdu); - - /* band-specific inits */ - brcms_c_bsinit(wlc); - - /* Enable EDCF mode (while the MAC is suspended) */ - OR_REG(®s->ifs_ctl, IFS_USEEDCF); - brcms_c_edcf_setparams(wlc, false); - - /* Init precedence maps for empty FIFOs */ - brcms_c_tx_prec_map_init(wlc); - - /* read the ucode version if we have not yet done so */ - if (wlc->ucode_rev == 0) { - wlc->ucode_rev = - brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR) << NBITS(u16); - wlc->ucode_rev |= brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); - } - - /* ..now really unleash hell (allow the MAC out of suspend) */ - brcms_c_enable_mac(wlc); - - /* clear tx flow control */ - brcms_c_txflowcontrol_reset(wlc); - - /* enable the RF Disable Delay timer */ - W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); - - /* initialize mpc delay */ - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; - - /* - * Initialize WME parameters; if they haven't been set by some other - * mechanism (IOVar, etc) then read them from the hardware. - */ - if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { - /* Uninitialized; read from HW */ - int ac; - - for (ac = 0; ac < AC_COUNT; ac++) - wlc->wme_retries[ac] = - brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); - } -} - -void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) -{ - wlc->bcnmisc_monitor = promisc; - brcms_c_mac_bcn_promisc(wlc); -} - -void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) -{ - if (wlc->bcnmisc_monitor) - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); - else - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, 0); -} - -/* set or clear maccontrol bits MCTL_PROMISC and MCTL_KEEPCONTROL */ -void brcms_c_mac_promisc(struct brcms_c_info *wlc) -{ - u32 promisc_bits = 0; - - /* - * promiscuous mode just sets MCTL_PROMISC - * Note: APs get all BSS traffic without the need to set - * the MCTL_PROMISC bit since all BSS data traffic is - * directed at the AP - */ - if (wlc->pub->promisc) - promisc_bits |= MCTL_PROMISC; - - /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL - * Note: monitor mode also needs MCTL_BCNS_PROMISC, but that is - * handled in brcms_c_mac_bcn_promisc() - */ - if (wlc->monitor) - promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; - - brcms_b_mctrl(wlc->hw, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); -} - -/* push sw hps and wake state through hardware */ -void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) -{ - u32 v1, v2; - bool hps; - bool awake_before; - - hps = brcms_c_ps_allowed(wlc); - - BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps); - - v1 = R_REG(&wlc->regs->maccontrol); - v2 = MCTL_WAKE; - if (hps) - v2 |= MCTL_HPS; - - brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); - - awake_before = ((v1 & MCTL_WAKE) || ((v1 & MCTL_HPS) == 0)); - - if (!awake_before) - brcms_b_wait_for_wake(wlc->hw); - -} - -/* - * Write this BSS config's MAC address to core. - * Updates RXE match engine. - */ -int brcms_c_set_mac(struct brcms_bss_cfg *bsscfg) -{ - int err = 0; - struct brcms_c_info *wlc = bsscfg->wlc; - - /* enter the MAC addr into the RXE match registers */ - brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, bsscfg->cur_etheraddr); - - brcms_c_ampdu_macaddr_upd(wlc); - - return err; -} - -/* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl). - * Updates RXE match engine. - */ -void brcms_c_set_bssid(struct brcms_bss_cfg *bsscfg) -{ - /* we need to update BSSID in RXE match registers */ - brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); -} - -static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) -{ - wlc_hw->shortslot = shortslot; - - if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - brcms_b_update_slot_timing(wlc_hw, shortslot); - brcms_c_enable_mac(wlc_hw->wlc); - } -} - -/* - * Suspend the the MAC and update the slot timing - * for standard 11b/g (20us slots) or shortslot 11g (9us slots). - */ -void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) -{ - /* use the override if it is set */ - if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) - shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); - - if (wlc->shortslot == shortslot) - return; - - wlc->shortslot = shortslot; - - brcms_b_set_shortslot(wlc->hw, shortslot); -} - -void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) -{ - if (wlc->home_chanspec != chanspec) { - wlc->home_chanspec = chanspec; - - if (wlc->bsscfg->associated) - wlc->bsscfg->current_bss->chanspec = chanspec; - } -} - -void -brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, - bool mute, struct txpwr_limits *txpwr) -{ - uint bandunit; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); - - wlc_hw->chanspec = chanspec; - - /* Switch bands if necessary */ - if (wlc_hw->_nbands > 1) { - bandunit = chspec_bandunit(chanspec); - if (wlc_hw->band->bandunit != bandunit) { - /* brcms_b_setband disables other bandunit, - * use light band switch if not up yet - */ - if (wlc_hw->up) { - wlc_phy_chanspec_radio_set(wlc_hw-> - bandstate[bandunit]-> - pi, chanspec); - brcms_b_setband(wlc_hw, bandunit, chanspec); - } else { - brcms_c_setxband(wlc_hw, bandunit); - } - } - } - - wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); - - if (!wlc_hw->up) { - if (wlc_hw->clk) - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, - chanspec); - wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); - } else { - wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); - wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); - - /* Update muting of the channel */ - brcms_b_mute(wlc_hw, mute, 0); - } -} - -/* switch to and initialize new band */ -static void brcms_c_setband(struct brcms_c_info *wlc, - uint bandunit) -{ - wlc->band = wlc->bandstate[bandunit]; - - if (!wlc->pub->up) - return; - - /* wait for at least one beacon before entering sleeping state */ - brcms_c_set_ps_ctrl(wlc); - - /* band-specific initializations */ - brcms_c_bsinit(wlc); -} - -void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) -{ - uint bandunit; - bool switchband = false; - u16 old_chanspec = wlc->chanspec; - - if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Bad channel %d\n", - wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); - return; - } - - /* Switch bands if necessary */ - if (wlc->pub->_nbands > 1) { - bandunit = chspec_bandunit(chanspec); - if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { - switchband = true; - if (wlc->bandlocked) { - wiphy_err(wlc->wiphy, "wl%d: %s: chspec %d " - "band is locked!\n", - wlc->pub->unit, __func__, - CHSPEC_CHANNEL(chanspec)); - return; - } - /* - * should the setband call come after the - * brcms_b_chanspec() ? if the setband updates - * (brcms_c_bsinit) use low level calls to inspect and - * set state, the state inspected may be from the wrong - * band, or the following brcms_b_set_chanspec() may - * undo the work. - */ - brcms_c_setband(wlc, bandunit); - } - } - - /* sync up phy/radio chanspec */ - brcms_c_set_phy_chanspec(wlc, chanspec); - - /* init antenna selection */ - if (brcms_chspec_bw(old_chanspec) != brcms_chspec_bw(chanspec)) { - brcms_c_antsel_init(wlc->asi); - - /* Fix the hardware rateset based on bw. - * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz - */ - brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, - wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); - } - - /* update some mac configuration since chanspec changed */ - brcms_c_ucode_mac_upd(wlc); -} - -u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, - struct brcms_c_rateset *rs) -{ - u32 lowest_basic_rspec; - uint i; - - /* Use the lowest basic rate */ - lowest_basic_rspec = rs->rates[0] & BRCMS_RATE_MASK; - for (i = 0; i < rs->count; i++) { - if (rs->rates[i] & BRCMS_RATE_FLAG) { - lowest_basic_rspec = rs->rates[i] & BRCMS_RATE_MASK; - break; - } - } - - /* - * pick siso/cdd as default for OFDM (note no basic - * rate MCSs are supported yet) - */ - if (is_ofdm_rate(lowest_basic_rspec)) - lowest_basic_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); - - return lowest_basic_rspec; -} - -/* - * This function changes the phytxctl for beacon based on current - * beacon ratespec AND txant setting as per this table: - * ratespec CCK ant = wlc->stf->txant - * OFDM ant = 3 - */ -void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, - u32 bcn_rspec) -{ - u16 phyctl; - u16 phytxant = wlc->stf->phytxant; - u16 mask = PHY_TXC_ANT_MASK; - - /* for non-siso rates or default setting, use the available chains */ - if (BRCMS_PHY_11N_CAP(wlc->band)) - phytxant = brcms_c_stf_phytxchain_sel(wlc, bcn_rspec); - - phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); - phyctl = (phyctl & ~mask) | phytxant; - brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); -} - -/* - * centralized protection config change function to simplify debugging, no - * consistency checking this should be called only on changes to avoid overhead - * in periodic function - */ -void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) -{ - BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); - - switch (idx) { - case BRCMS_PROT_G_SPEC: - wlc->protection->_g = (bool) val; - break; - case BRCMS_PROT_G_OVR: - wlc->protection->g_override = (s8) val; - break; - case BRCMS_PROT_G_USER: - wlc->protection->gmode_user = (u8) val; - break; - case BRCMS_PROT_OVERLAP: - wlc->protection->overlap = (s8) val; - break; - case BRCMS_PROT_N_USER: - wlc->protection->nmode_user = (s8) val; - break; - case BRCMS_PROT_N_CFG: - wlc->protection->n_cfg = (s8) val; - break; - case BRCMS_PROT_N_CFG_OVR: - wlc->protection->n_cfg_override = (s8) val; - break; - case BRCMS_PROT_N_NONGF: - wlc->protection->nongf = (bool) val; - break; - case BRCMS_PROT_N_NONGF_OVR: - wlc->protection->nongf_override = (s8) val; - break; - case BRCMS_PROT_N_PAM_OVR: - wlc->protection->n_pam_override = (s8) val; - break; - case BRCMS_PROT_N_OBSS: - wlc->protection->n_obss = (bool) val; - break; - - default: - break; - } - -} - -static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val) -{ - if (wlc->pub->up) { - brcms_c_update_beacon(wlc); - brcms_c_update_probe_resp(wlc, true); - } -} - -static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) -{ - wlc->stf->ldpc = val; - - if (wlc->pub->up) { - brcms_c_update_beacon(wlc); - brcms_c_update_probe_resp(wlc, true); - wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); - } -} - -void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, - const struct ieee80211_tx_queue_params *params, - bool suspend) -{ - int i; - struct shm_acparams acp_shm; - u16 *shm_entry; - - /* Only apply params if the core is out of reset and has clocks */ - if (!wlc->clk) { - wiphy_err(wlc->wiphy, "wl%d: %s : no-clock\n", wlc->pub->unit, - __func__); - return; - } - - memset((char *)&acp_shm, 0, sizeof(struct shm_acparams)); - /* fill in shm ac params struct */ - acp_shm.txop = params->txop; - /* convert from units of 32us to us for ucode */ - wlc->edcf_txop[aci & 0x3] = acp_shm.txop = - EDCF_TXOP2USEC(acp_shm.txop); - acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); - - if (aci == AC_VI && acp_shm.txop == 0 - && acp_shm.aifs < EDCF_AIFSN_MAX) - acp_shm.aifs++; - - if (acp_shm.aifs < EDCF_AIFSN_MIN - || acp_shm.aifs > EDCF_AIFSN_MAX) { - wiphy_err(wlc->wiphy, "wl%d: edcf_setparams: bad " - "aifs %d\n", wlc->pub->unit, acp_shm.aifs); - } else { - acp_shm.cwmin = params->cw_min; - acp_shm.cwmax = params->cw_max; - acp_shm.cwcur = acp_shm.cwmin; - acp_shm.bslots = - R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; - acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; - /* Indicate the new params to the ucode */ - acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + - wme_ac2fifo[aci] * - M_EDCF_QLEN + - M_EDCF_STATUS_OFF)); - acp_shm.status |= WME_STATUS_NEWAC; - - /* Fill in shm acparam table */ - shm_entry = (u16 *) &acp_shm; - for (i = 0; i < (int)sizeof(struct shm_acparams); i += 2) - brcms_b_write_shm(wlc->hw, - M_EDCF_QINFO + - wme_ac2fifo[aci] * M_EDCF_QLEN + i, - *shm_entry++); - } - - if (suspend) { - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_enable_mac(wlc); - } -} - -void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) -{ - u16 aci; - int i_ac; - struct ieee80211_tx_queue_params txq_pars; - static const struct edcf_acparam default_edcf_acparams[] = { - {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, EDCF_AC_BE_TXOP_STA}, - {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, EDCF_AC_BK_TXOP_STA}, - {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, EDCF_AC_VI_TXOP_STA}, - {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, EDCF_AC_VO_TXOP_STA} - }; /* ucode needs these parameters during its initialization */ - const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; - - for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { - /* find out which ac this set of params applies to */ - aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; - - /* fill in shm ac params struct */ - txq_pars.txop = edcf_acp->TXOP; - txq_pars.aifs = edcf_acp->ACI; - - /* CWmin = 2^(ECWmin) - 1 */ - txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); - /* CWmax = 2^(ECWmax) - 1 */ - txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) - >> EDCF_ECWMAX_SHIFT); - brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); - } - - if (suspend) { - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_enable_mac(wlc); - } -} - -/* maintain LED behavior in down state */ -static void brcms_c_down_led_upd(struct brcms_c_info *wlc) -{ - /* - * maintain LEDs while in down state, turn on sbclk if - * not available yet. Turn on sbclk if necessary - */ - brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_FLIP); - brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_FLIP); -} - -static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) -{ - /* Don't start the timer if HWRADIO feature is disabled */ - if (wlc->radio_monitor) - return; - - wlc->radio_monitor = true; - brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); - brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, - true); -} - -void brcms_c_radio_disable(struct brcms_c_info *wlc) -{ - if (!wlc->pub->up) { - brcms_c_down_led_upd(wlc); - return; - } - - brcms_c_radio_monitor_start(wlc); - brcms_down(wlc->wl); -} - -static void brcms_c_radio_enable(struct brcms_c_info *wlc) -{ - if (wlc->pub->up) - return; - - if (brcms_deviceremoved(wlc)) - return; - - brcms_up(wlc->wl); -} - -bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) -{ - if (!wlc->radio_monitor) - return true; - - wlc->radio_monitor = false; - brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); - return brcms_del_timer(wlc->wl, wlc->radio_timer); -} - -/* read hwdisable state and propagate to wlc flag */ -static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) -{ - if (wlc->pub->hw_off) - return; - - if (brcms_b_radio_read_hwdisabled(wlc->hw)) - mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); - else - mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); -} - -/* - * centralized radio disable/enable function, - * invoke radio enable/disable after updating hwradio status - */ -static void brcms_c_radio_upd(struct brcms_c_info *wlc) -{ - if (wlc->pub->radio_disabled) - brcms_c_radio_disable(wlc); - else - brcms_c_radio_enable(wlc); -} - -/* update hwradio status and return it */ -bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) -{ - brcms_c_radio_hwdisable_upd(wlc); - - return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? - true : false; -} - -/* periodical query hw radio button while driver is "down" */ -static void brcms_c_radio_timer(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - - if (brcms_deviceremoved(wlc)) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, - __func__); - brcms_down(wlc->wl); - return; - } - - /* cap mpc off count */ - if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) - wlc->mpc_offcnt++; - - brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); -} - -/* common low-level watchdog code */ -static void brcms_b_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - struct brcms_hardware *wlc_hw = wlc->hw; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return; - - /* increment second count */ - wlc_hw->now++; - - /* Check for FIFO error interrupts */ - brcms_b_fifoerrors(wlc_hw); - - /* make sure RX dma has buffers */ - dma_rxfill(wlc->hw->di[RX_FIFO]); - - wlc_phy_watchdog(wlc_hw->band->pi); -} - -/* common watchdog code */ -static void brcms_c_watchdog(void *arg) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) arg; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - if (!wlc->pub->up) - return; - - if (brcms_deviceremoved(wlc)) { - wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, - __func__); - brcms_down(wlc->wl); - return; - } - - /* increment second count */ - wlc->pub->now++; - - /* delay radio disable */ - if (wlc->mpc_delay_off) { - if (--wlc->mpc_delay_off == 0) { - mboolset(wlc->pub->radio_disabled, - WL_RADIO_MPC_DISABLE); - if (wlc->mpc && brcms_c_ismpc(wlc)) - wlc->mpc_offcnt = 0; - } - } - - /* mpc sync */ - brcms_c_radio_mpc_upd(wlc); - /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ - brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); - /* if radio is disable, driver may be down, quit here */ - if (wlc->pub->radio_disabled) - return; - - brcms_b_watchdog(wlc); - - /* - * occasionally sample mac stat counters to - * detect 16-bit counter wrap - */ - if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) - brcms_c_statsupd(wlc); - - if (BRCMS_ISNPHY(wlc->band) && - ((wlc->pub->now - wlc->tempsense_lasttime) >= - BRCMS_TEMPSENSE_PERIOD)) { - wlc->tempsense_lasttime = wlc->pub->now; - brcms_c_tempsense_upd(wlc); - } -} - -static void brcms_c_watchdog_by_timer(void *arg) -{ - brcms_c_watchdog(arg); -} - -bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) -{ - wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, - wlc, "watchdog"); - if (!wlc->wdtimer) { - wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " - "failed\n", unit); - goto fail; - } - - wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, - wlc, "radio"); - if (!wlc->radio_timer) { - wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " - "failed\n", unit); - goto fail; - } - - return true; - - fail: - return false; -} - -/* - * Initialize brcms_c_info default values ... - * may get overrides later in this function - */ -void brcms_c_info_init(struct brcms_c_info *wlc, int unit) -{ - int i; - - /* Save our copy of the chanspec */ - wlc->chanspec = ch20mhz_chspec(1); - - /* various 802.11g modes */ - wlc->shortslot = false; - wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; - - brcms_c_protection_upd(wlc, BRCMS_PROT_G_OVR, BRCMS_PROTECTION_AUTO); - brcms_c_protection_upd(wlc, BRCMS_PROT_G_SPEC, false); - - brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG_OVR, - BRCMS_PROTECTION_AUTO); - brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG, BRCMS_N_PROTECTION_OFF); - brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF_OVR, - BRCMS_PROTECTION_AUTO); - brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF, false); - brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, AUTO); - - brcms_c_protection_upd(wlc, BRCMS_PROT_OVERLAP, - BRCMS_PROTECTION_CTL_OVERLAP); - - /* 802.11g draft 4.0 NonERP elt advertisement */ - wlc->include_legacy_erp = true; - - wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; - wlc->stf->txant = ANT_TX_DEF; - - wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; - - wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; - for (i = 0; i < NFIFO; i++) - wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; - wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; - - /* default rate fallback retry limits */ - wlc->SFBL = RETRY_SHORT_FB; - wlc->LFBL = RETRY_LONG_FB; - - /* default mac retry limits */ - wlc->SRL = RETRY_SHORT_DEF; - wlc->LRL = RETRY_LONG_DEF; - - /* WME QoS mode is Auto by default */ - wlc->pub->_ampdu = AMPDU_AGG_HOST; - wlc->pub->bcmerror = 0; - - /* initialize mpc delay */ - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; -} - -static uint brcms_c_attach_module(struct brcms_c_info *wlc) -{ - uint err = 0; - uint unit; - unit = wlc->pub->unit; - - wlc->asi = brcms_c_antsel_attach(wlc); - if (wlc->asi == NULL) { - wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " - "failed\n", unit); - err = 44; - goto fail; - } - - wlc->ampdu = brcms_c_ampdu_attach(wlc); - if (wlc->ampdu == NULL) { - wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " - "failed\n", unit); - err = 50; - goto fail; - } - - if ((brcms_c_stf_attach(wlc) != 0)) { - wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " - "failed\n", unit); - err = 68; - goto fail; - } - fail: - return err; -} - -struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) -{ - return wlc->pub; -} - -/* low level attach - * run backplane attach, init nvram - * run phy attach - * initialize software state for each core and band - * put the whole chip in reset(driver down state), no clock - */ -static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void __iomem *regsva, - struct pci_dev *btparam) -{ - struct brcms_hardware *wlc_hw; - struct d11regs __iomem *regs; - char *macaddr = NULL; - uint err = 0; - uint j; - bool wme = false; - struct shared_phy_params sha_params; - struct wiphy *wiphy = wlc->wiphy; - - BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, - device); - - wme = true; - - wlc_hw = wlc->hw; - wlc_hw->wlc = wlc; - wlc_hw->unit = unit; - wlc_hw->band = wlc_hw->bandstate[0]; - wlc_hw->_piomode = piomode; - - /* populate struct brcms_hardware with default values */ - brcms_b_info_init(wlc_hw); - - /* - * Do the hardware portion of the attach. Also initialize software - * state that depends on the particular hardware we are running. - */ - wlc_hw->sih = ai_attach(regsva, btparam); - if (wlc_hw->sih == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", - unit); - err = 11; - goto fail; - } - - /* verify again the device is supported */ - if (!brcms_c_chipmatch(vendor, device)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " - "vendor/device (0x%x/0x%x)\n", - unit, vendor, device); - err = 12; - goto fail; - } - - wlc_hw->vendorid = vendor; - wlc_hw->deviceid = device; - - /* set bar0 window to point at D11 core */ - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - wlc_hw->corerev = ai_corerev(wlc_hw->sih); - - regs = wlc_hw->regs; - - wlc->regs = wlc_hw->regs; - - /* validate chip, chiprev and corerev */ - if (!brcms_c_isgoodchip(wlc_hw)) { - err = 13; - goto fail; - } - - /* initialize power control registers */ - ai_clkctl_init(wlc_hw->sih); - - /* request fastclock and force fastclock for the rest of attach - * bring the d11 core out of reset. - * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk - * is still false; But it will be called again inside wlc_corereset, - * after d11 is out of reset. - */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - if (!brcms_b_validate_chip_access(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: validate_chip_access " - "failed\n", unit); - err = 14; - goto fail; - } - - /* get the board rev, used just below */ - j = getintvar(wlc_hw->sih, BRCMS_SROM_BOARDREV); - /* promote srom boardrev of 0xFF to 1 */ - if (j == BOARDREV_PROMOTABLE) - j = BOARDREV_PROMOTED; - wlc_hw->boardrev = (u16) j; - if (!brcms_c_validboardtype(wlc_hw)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " - "board type (0x%x)" " or revision level (0x%x)\n", - unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); - err = 15; - goto fail; - } - wlc_hw->sromrev = (u8) getintvar(wlc_hw->sih, BRCMS_SROM_REV); - wlc_hw->boardflags = (u32) getintvar(wlc_hw->sih, - BRCMS_SROM_BOARDFLAGS); - wlc_hw->boardflags2 = (u32) getintvar(wlc_hw->sih, - BRCMS_SROM_BOARDFLAGS2); - - if (wlc_hw->boardflags & BFL_NOPLLDOWN) - brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); - - /* check device id(srom, nvram etc.) to set bands */ - if (wlc_hw->deviceid == BCM43224_D11N_ID || - wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) - /* Dualband boards */ - wlc_hw->_nbands = 2; - else - wlc_hw->_nbands = 1; - - if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->_nbands = 1; - - /* BMAC_NOTE: remove init of pub values when brcms_c_attach() - * unconditionally does the init of these values - */ - wlc->vendorid = wlc_hw->vendorid; - wlc->deviceid = wlc_hw->deviceid; - wlc->pub->sih = wlc_hw->sih; - wlc->pub->corerev = wlc_hw->corerev; - wlc->pub->sromrev = wlc_hw->sromrev; - wlc->pub->boardrev = wlc_hw->boardrev; - wlc->pub->boardflags = wlc_hw->boardflags; - wlc->pub->boardflags2 = wlc_hw->boardflags2; - wlc->pub->_nbands = wlc_hw->_nbands; - - wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); - - if (wlc_hw->physhim == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_shim_attach " - "failed\n", unit); - err = 25; - goto fail; - } - - /* pass all the parameters to wlc_phy_shared_attach in one struct */ - sha_params.sih = wlc_hw->sih; - sha_params.physhim = wlc_hw->physhim; - sha_params.unit = unit; - sha_params.corerev = wlc_hw->corerev; - sha_params.vid = wlc_hw->vendorid; - sha_params.did = wlc_hw->deviceid; - sha_params.chip = wlc_hw->sih->chip; - sha_params.chiprev = wlc_hw->sih->chiprev; - sha_params.chippkg = wlc_hw->sih->chippkg; - sha_params.sromrev = wlc_hw->sromrev; - sha_params.boardtype = wlc_hw->sih->boardtype; - sha_params.boardrev = wlc_hw->boardrev; - sha_params.boardvendor = wlc_hw->sih->boardvendor; - sha_params.boardflags = wlc_hw->boardflags; - sha_params.boardflags2 = wlc_hw->boardflags2; - sha_params.buscorerev = wlc_hw->sih->buscorerev; - - /* alloc and save pointer to shared phy state area */ - wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); - if (!wlc_hw->phy_sh) { - err = 16; - goto fail; - } - - /* initialize software state for each core and band */ - for (j = 0; j < wlc_hw->_nbands; j++) { - /* - * band0 is always 2.4Ghz - * band1, if present, is 5Ghz - */ - - brcms_c_setxband(wlc_hw, j); - - wlc_hw->band->bandunit = j; - wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->band->bandunit = j; - wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->core->coreidx = ai_coreidx(wlc_hw->sih); - - wlc_hw->machwcap = R_REG(®s->machwcap); - wlc_hw->machwcap_backup = wlc_hw->machwcap; - - /* init tx fifo size */ - wlc_hw->xmtfifo_sz = - xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; - - /* Get a phy for this band */ - wlc_hw->band->pi = - wlc_phy_attach(wlc_hw->phy_sh, regs, - wlc_hw->band->bandtype, - wlc->wiphy); - if (wlc_hw->band->pi == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: wlc_phy_" - "attach failed\n", unit); - err = 17; - goto fail; - } - - wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); - - wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, - &wlc_hw->band->phyrev, - &wlc_hw->band->radioid, - &wlc_hw->band->radiorev); - wlc_hw->band->abgphy_encore = - wlc_phy_get_encore(wlc_hw->band->pi); - wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); - wlc_hw->band->core_flags = - wlc_phy_get_coreflags(wlc_hw->band->pi); - - /* verify good phy_type & supported phy revision */ - if (BRCMS_ISNPHY(wlc_hw->band)) { - if (NCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { - if (LCNCONF_HAS(wlc_hw->band->phyrev)) - goto good_phy; - else - goto bad_phy; - } else { - bad_phy: - wiphy_err(wiphy, "wl%d: brcms_b_attach: unsupported " - "phy type/rev (%d/%d)\n", unit, - wlc_hw->band->phytype, wlc_hw->band->phyrev); - err = 18; - goto fail; - } - - good_phy: - /* - * BMAC_NOTE: wlc->band->pi should not be set below and should - * be done in the high level attach. However we can not make - * that change until all low level access is changed to - * wlc_hw->band->pi. Instead do the wlc->band->pi init below, - * keeping wlc_hw->band->pi as well for incremental update of - * low level fns, and cut over low only init when all fns - * updated. - */ - wlc->band->pi = wlc_hw->band->pi; - wlc->band->phytype = wlc_hw->band->phytype; - wlc->band->phyrev = wlc_hw->band->phyrev; - wlc->band->radioid = wlc_hw->band->radioid; - wlc->band->radiorev = wlc_hw->band->radiorev; - - /* default contention windows size limits */ - wlc_hw->band->CWmin = APHY_CWMIN; - wlc_hw->band->CWmax = PHY_CWMAX; - - if (!brcms_b_attach_dmapio(wlc, j, wme)) { - err = 19; - goto fail; - } - } - - /* disable core to match driver "down" state */ - brcms_c_coredisable(wlc_hw); - - /* Match driver "down" state */ - ai_pci_down(wlc_hw->sih); - - /* register sb interrupt callback functions */ - ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, - (void *)brcms_c_wlintrsrestore, NULL, wlc); - - /* turn off pll and xtal to match driver "down" state */ - brcms_b_xtal(wlc_hw, OFF); - - /* ******************************************************************* - * The hardware is in the DOWN state at this point. D11 core - * or cores are in reset with clocks off, and the board PLLs - * are off if possible. - * - * Beyond this point, wlc->sbclk == false and chip registers - * should not be touched. - ********************************************************************* - */ - - /* init etheraddr state variables */ - macaddr = brcms_c_get_macaddr(wlc_hw); - if (macaddr == NULL) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n", - unit); - err = 21; - goto fail; - } - if (!mac_pton(macaddr, wlc_hw->etheraddr) || - is_broadcast_ether_addr(wlc_hw->etheraddr) || - is_zero_ether_addr(wlc_hw->etheraddr)) { - wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n", - unit, macaddr); - err = 22; - goto fail; - } - - BCMMSG(wlc->wiphy, - "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", - wlc_hw->deviceid, wlc_hw->_nbands, - wlc_hw->sih->boardtype, macaddr); - - return err; - - fail: - wiphy_err(wiphy, "wl%d: brcms_b_attach: failed with err %d\n", unit, - err); - return err; -} - -static void brcms_c_attach_antgain_init(struct brcms_c_info *wlc) -{ - uint unit; - unit = wlc->pub->unit; - - if ((wlc->band->antgain == -1) && (wlc->pub->sromrev == 1)) { - /* default antenna gain for srom rev 1 is 2 dBm (8 qdbm) */ - wlc->band->antgain = 8; - } else if (wlc->band->antgain == -1) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" - " srom, using 2dB\n", unit, __func__); - wlc->band->antgain = 8; - } else { - s8 gain, fract; - /* Older sroms specified gain in whole dbm only. In order - * be able to specify qdbm granularity and remain backward - * compatible the whole dbms are now encoded in only - * low 6 bits and remaining qdbms are encoded in the hi 2 bits. - * 6 bit signed number ranges from -32 - 31. - * - * Examples: - * 0x1 = 1 db, - * 0xc1 = 1.75 db (1 + 3 quarters), - * 0x3f = -1 (-1 + 0 quarters), - * 0x7f = -.75 (-1 + 1 quarters) = -3 qdbm. - * 0xbf = -.50 (-1 + 2 quarters) = -2 qdbm. - */ - gain = wlc->band->antgain & 0x3f; - gain <<= 2; /* Sign extend */ - gain >>= 2; - fract = (wlc->band->antgain & 0xc0) >> 6; - wlc->band->antgain = 4 * gain + fract; - } -} - -static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) -{ - int aa; - uint unit; - int bandtype; - struct si_pub *sih = wlc->hw->sih; - - unit = wlc->pub->unit; - bandtype = wlc->band->bandtype; - - /* get antennas available */ - if (bandtype == BRCM_BAND_5G) - aa = (s8) getintvar(sih, BRCMS_SROM_AA5G); - else - aa = (s8) getintvar(sih, BRCMS_SROM_AA2G); - - if ((aa < 1) || (aa > 15)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" - " srom (0x%x), using 3\n", unit, __func__, aa); - aa = 3; - } - - /* reset the defaults if we have a single antenna */ - if (aa == 1) { - wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; - wlc->stf->txant = ANT_TX_FORCE_0; - } else if (aa == 2) { - wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; - wlc->stf->txant = ANT_TX_FORCE_1; - } else { - } - - /* Compute Antenna Gain */ - if (bandtype == BRCM_BAND_5G) - wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG1); - else - wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG0); - - brcms_c_attach_antgain_init(wlc); - - return true; -} - -static void brcms_c_bss_default_init(struct brcms_c_info *wlc) -{ - u16 chanspec; - struct brcms_band *band; - struct brcms_bss_info *bi = wlc->default_bss; - - /* init default and target BSS with some sane initial values */ - memset((char *)(bi), 0, sizeof(struct brcms_bss_info)); - bi->beacon_period = BEACON_INTERVAL_DEFAULT; - - /* fill the default channel as the first valid channel - * starting from the 2G channels - */ - chanspec = ch20mhz_chspec(1); - wlc->home_chanspec = bi->chanspec = chanspec; - - /* find the band of our default channel */ - band = wlc->band; - if (wlc->pub->_nbands > 1 && - band->bandunit != chspec_bandunit(chanspec)) - band = wlc->bandstate[OTHERBANDUNIT(wlc)]; - - /* init bss rates to the band specific default rate set */ - brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, - band->bandtype, false, BRCMS_RATE_MASK_FULL, - (bool) (wlc->pub->_n_enab & SUPPORT_11N), - brcms_chspec_bw(chanspec), wlc->stf->txstreams); - - if (wlc->pub->_n_enab & SUPPORT_11N) - bi->flags |= BRCMS_BSS_HT; -} - -static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc) -{ - struct brcms_txq_info *qi, *p; - - qi = kzalloc(sizeof(struct brcms_txq_info), GFP_ATOMIC); - if (qi != NULL) { - /* - * Have enough room for control packets along with HI watermark - * Also, add room to txq for total psq packets if all the SCBs - * leave PS mode. The watermark for flowcontrol to OS packets - * will remain the same - */ - brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT, - 2 * BRCMS_DATAHIWAT + PKTQ_LEN_DEFAULT); - - /* add this queue to the the global list */ - p = wlc->tx_queues; - if (p == NULL) { - wlc->tx_queues = qi; - } else { - while (p->next != NULL) - p = p->next; - p->next = qi; - } - } - return qi; -} - -static void brcms_c_txq_free(struct brcms_c_info *wlc, - struct brcms_txq_info *qi) -{ - struct brcms_txq_info *p; - - if (qi == NULL) - return; - - /* remove the queue from the linked list */ - p = wlc->tx_queues; - if (p == qi) - wlc->tx_queues = p->next; - else { - while (p != NULL && p->next != qi) - p = p->next; - if (p != NULL) - p->next = p->next->next; - } - - kfree(qi); -} - -static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) -{ - uint i; - struct brcms_band *band; - - for (i = 0; i < wlc->pub->_nbands; i++) { - band = wlc->bandstate[i]; - if (band->bandtype == BRCM_BAND_5G) { - if ((bwcap == BRCMS_N_BW_40ALL) - || (bwcap == BRCMS_N_BW_20IN2G_40IN5G)) - band->mimo_cap_40 = true; - else - band->mimo_cap_40 = false; - } else { - if (bwcap == BRCMS_N_BW_40ALL) - band->mimo_cap_40 = true; - else - band->mimo_cap_40 = false; - } - } -} - -/* - * The common driver entry routine. Error codes should be unique - */ -struct brcms_c_info * -brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void __iomem *regsva, struct pci_dev *btparam, - uint *perr) -{ - struct brcms_c_info *wlc; - uint err = 0; - uint i, j; - struct brcms_pub *pub; - - /* allocate struct brcms_c_info state and its substructures */ - wlc = (struct brcms_c_info *) brcms_c_attach_malloc(unit, &err, device); - if (wlc == NULL) - goto fail; - wlc->wiphy = wl->wiphy; - pub = wlc->pub; - -#if defined(BCMDBG) - wlc_info_dbg = wlc; -#endif - - wlc->band = wlc->bandstate[0]; - wlc->core = wlc->corestate; - wlc->wl = wl; - pub->unit = unit; - pub->_piomode = piomode; - wlc->bandinit_pending = false; - - /* populate struct brcms_c_info with default values */ - brcms_c_info_init(wlc, unit); - - /* update sta/ap related parameters */ - brcms_c_ap_upd(wlc); - - /* - * low level attach steps(all hw accesses go - * inside, no more in rest of the attach) - */ - err = brcms_b_attach(wlc, vendor, device, unit, piomode, regsva, - btparam); - if (err) - goto fail; - - brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, OFF); - - pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); - - /* disable allowed duty cycle */ - wlc->tx_duty_cycle_ofdm = 0; - wlc->tx_duty_cycle_cck = 0; - - brcms_c_stf_phy_chain_calc(wlc); - - /* txchain 1: txant 0, txchain 2: txant 1 */ - if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) - wlc->stf->txant = wlc->stf->hw_txchain - 1; - - /* push to BMAC driver */ - wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, - wlc->stf->hw_rxchain); - - /* pull up some info resulting from the low attach */ - for (i = 0; i < NFIFO; i++) - wlc->core->txavail[i] = wlc->hw->txavail[i]; - - memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); - memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); - - for (j = 0; j < wlc->pub->_nbands; j++) { - wlc->band = wlc->bandstate[j]; - - if (!brcms_c_attach_stf_ant_init(wlc)) { - err = 24; - goto fail; - } - - /* default contention windows size limits */ - wlc->band->CWmin = APHY_CWMIN; - wlc->band->CWmax = PHY_CWMAX; - - /* init gmode value */ - if (wlc->band->bandtype == BRCM_BAND_2G) { - wlc->band->gmode = GMODE_AUTO; - brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, - wlc->band->gmode); - } - - /* init _n_enab supported mode */ - if (BRCMS_PHY_11N_CAP(wlc->band)) { - pub->_n_enab = SUPPORT_11N; - brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, - ((pub->_n_enab == - SUPPORT_11N) ? WL_11N_2x2 : - WL_11N_3x3)); - } - - /* init per-band default rateset, depend on band->gmode */ - brcms_default_rateset(wlc, &wlc->band->defrateset); - - /* fill in hw_rateset */ - brcms_c_rateset_filter(&wlc->band->defrateset, - &wlc->band->hw_rateset, false, - BRCMS_RATES_CCK_OFDM, BRCMS_RATE_MASK, - (bool) (wlc->pub->_n_enab & SUPPORT_11N)); - } - - /* - * update antenna config due to - * wlc->stf->txant/txchain/ant_rx_ovr change - */ - brcms_c_stf_phy_txant_upd(wlc); - - /* attach each modules */ - err = brcms_c_attach_module(wlc); - if (err != 0) - goto fail; - - if (!brcms_c_timers_init(wlc, unit)) { - wiphy_err(wl->wiphy, "wl%d: %s: init_timer failed\n", unit, - __func__); - err = 32; - goto fail; - } - - /* depend on rateset, gmode */ - wlc->cmi = brcms_c_channel_mgr_attach(wlc); - if (!wlc->cmi) { - wiphy_err(wl->wiphy, "wl%d: %s: channel_mgr_attach failed" - "\n", unit, __func__); - err = 33; - goto fail; - } - - /* init default when all parameters are ready, i.e. ->rateset */ - brcms_c_bss_default_init(wlc); - - /* - * Complete the wlc default state initializations.. - */ - - /* allocate our initial queue */ - wlc->pkt_queue = brcms_c_txq_alloc(wlc); - if (wlc->pkt_queue == NULL) { - wiphy_err(wl->wiphy, "wl%d: %s: failed to malloc tx queue\n", - unit, __func__); - err = 100; - goto fail; - } - - wlc->bsscfg->wlc = wlc; - - wlc->mimoft = FT_HT; - wlc->mimo_40txbw = AUTO; - wlc->ofdm_40txbw = AUTO; - wlc->cck_40txbw = AUTO; - brcms_c_update_mimo_band_bwcap(wlc, BRCMS_N_BW_20IN2G_40IN5G); - - /* Set default values of SGI */ - if (BRCMS_SGI_CAP_PHY(wlc)) { - brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | - BRCMS_N_SGI_40)); - } else if (BRCMS_ISSSLPNPHY(wlc->band)) { - brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | - BRCMS_N_SGI_40)); - } else { - brcms_c_ht_update_sgi_rx(wlc, 0); - } - - /* initialize radio_mpc_disable according to wlc->mpc */ - brcms_c_radio_mpc_upd(wlc); - brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); - - if (perr) - *perr = 0; - - return wlc; - - fail: - wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", - unit, __func__, err); - if (wlc) - brcms_c_detach(wlc); - - if (perr) - *perr = err; - return NULL; -} - -static void brcms_c_timers_deinit(struct brcms_c_info *wlc) -{ - /* free timer state */ - if (wlc->wdtimer) { - brcms_free_timer(wlc->wl, wlc->wdtimer); - wlc->wdtimer = NULL; - } - if (wlc->radio_timer) { - brcms_free_timer(wlc->wl, wlc->radio_timer); - wlc->radio_timer = NULL; - } -} - -static void brcms_c_detach_module(struct brcms_c_info *wlc) -{ - if (wlc->asi) { - brcms_c_antsel_detach(wlc->asi); - wlc->asi = NULL; - } - - if (wlc->ampdu) { - brcms_c_ampdu_detach(wlc->ampdu); - wlc->ampdu = NULL; - } - - brcms_c_stf_detach(wlc); -} - -/* - * low level detach - */ -static int brcms_b_detach(struct brcms_c_info *wlc) -{ - uint i; - struct brcms_hw_band *band; - struct brcms_hardware *wlc_hw = wlc->hw; - int callbacks; - - callbacks = 0; - - if (wlc_hw->sih) { - /* - * detach interrupt sync mechanism since interrupt is disabled - * and per-port interrupt object may has been freed. this must - * be done before sb core switch - */ - ai_deregister_intr_callback(wlc_hw->sih); - ai_pci_sleep(wlc_hw->sih); - } - - brcms_b_detach_dmapio(wlc_hw); - - band = wlc_hw->band; - for (i = 0; i < wlc_hw->_nbands; i++) { - if (band->pi) { - /* Detach this band's phy */ - wlc_phy_detach(band->pi); - band->pi = NULL; - } - band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; - } - - /* Free shared phy state */ - kfree(wlc_hw->phy_sh); - - wlc_phy_shim_detach(wlc_hw->physhim); - - if (wlc_hw->sih) { - ai_detach(wlc_hw->sih); - wlc_hw->sih = NULL; - } - - return callbacks; - -} - -/* - * Return a count of the number of driver callbacks still pending. - * - * General policy is that brcms_c_detach can only dealloc/free software states. - * It can NOT touch hardware registers since the d11core may be in reset and - * clock may not be available. - * One exception is sb register access, which is possible if crystal is turned - * on after "down" state, driver should avoid software timer with the exception - * of radio_monitor. - */ -uint brcms_c_detach(struct brcms_c_info *wlc) -{ - uint callbacks = 0; - - if (wlc == NULL) - return 0; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - callbacks += brcms_b_detach(wlc); - - /* delete software timers */ - if (!brcms_c_radio_monitor_stop(wlc)) - callbacks++; - - brcms_c_channel_mgr_detach(wlc->cmi); - - brcms_c_timers_deinit(wlc); - - brcms_c_detach_module(wlc); - - - while (wlc->tx_queues != NULL) - brcms_c_txq_free(wlc, wlc->tx_queues); - - brcms_c_detach_mfree(wlc); - return callbacks; -} - -/* update state that depends on the current value of "ap" */ -void brcms_c_ap_upd(struct brcms_c_info *wlc) -{ - /* STA-BSS; short capable */ - wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; - - /* fixup mpc */ - wlc->mpc = true; -} - -/* - * return true if Minimum Power Consumption should - * be entered, false otherwise - */ -bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc) -{ - return false; -} - -bool brcms_c_ismpc(struct brcms_c_info *wlc) -{ - return (wlc->mpc_delay_off == 0) && (brcms_c_is_non_delay_mpc(wlc)); -} - -void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) -{ - bool mpc_radio, radio_state; - - /* - * Clear the WL_RADIO_MPC_DISABLE bit when mpc feature is disabled - * in case the WL_RADIO_MPC_DISABLE bit was set. Stop the radio - * monitor also when WL_RADIO_MPC_DISABLE is the only reason that - * the radio is going down. - */ - if (!wlc->mpc) { - if (!wlc->pub->radio_disabled) - return; - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); - brcms_c_radio_upd(wlc); - if (!wlc->pub->radio_disabled) - brcms_c_radio_monitor_stop(wlc); - return; - } - - /* - * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in - * wlc->pub->radio_disabled to go ON, always call radio_upd - * synchronously to go OFF, postpone radio_upd to later when - * context is safe(e.g. watchdog) - */ - radio_state = - (mboolisset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE) ? OFF : - ON); - mpc_radio = (brcms_c_ismpc(wlc) == true) ? OFF : ON; - - if (radio_state == ON && mpc_radio == OFF) - wlc->mpc_delay_off = wlc->mpc_dlycnt; - else if (radio_state == OFF && mpc_radio == ON) { - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); - brcms_c_radio_upd(wlc); - if (wlc->mpc_offcnt < BRCMS_MPC_THRESHOLD) - wlc->mpc_dlycnt = BRCMS_MPC_MAX_DELAYCNT; - else - wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; - } - /* - * Below logic is meant to capture the transition from mpc off - * to mpc on for reasons other than wlc->mpc_delay_off keeping - * the mpc off. In that case reset wlc->mpc_delay_off to - * wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off - */ - if ((wlc->prev_non_delay_mpc == false) && - (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) - wlc->mpc_delay_off = wlc->mpc_dlycnt; - - wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); -} -/* Initialize just the hardware when coming out of POR or S3/S5 system states */ -static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) -{ - if (wlc_hw->wlc->pub->hw_up) - return; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - ai_pci_fixcfg(wlc_hw->sih); - - /* - * AI chip doesn't restore bar0win2 on - * hibernation/resume, need sw fixup - */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - - /* - * Inform phy that a POR reset has occurred so - * it does a complete phy init - */ - wlc_phy_por_inform(wlc_hw->band->pi); - - wlc_hw->ucode_loaded = false; - wlc_hw->wlc->pub->hw_up = true; - - if ((wlc_hw->boardflags & BFL_FEM) - && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - if (! - (wlc_hw->boardrev >= 0x1250 - && (wlc_hw->boardflags & BFL_FEM_BT))) - ai_epa_4313war(wlc_hw->sih); - } -} - -static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) -{ - uint coremask; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - /* - * Enable pll and xtal, initialize the power control registers, - * and force fastclock for the remainder of brcms_c_up(). - */ - brcms_b_xtal(wlc_hw, ON); - ai_clkctl_init(wlc_hw->sih); - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - - /* - * Configure pci/pcmcia here instead of in brcms_c_attach() - * to allow mfg hotswap: down, hotswap (chip power cycle), up. - */ - coremask = (1 << wlc_hw->wlc->core->coreidx); - - ai_pci_setup(wlc_hw->sih, coremask); - - /* - * Need to read the hwradio status here to cover the case where the - * system is loaded with the hw radio disabled. We do not want to - * bring the driver up in this case. - */ - if (brcms_b_radio_read_hwdisabled(wlc_hw)) { - /* put SB PCI in down state again */ - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - return -ENOMEDIUM; - } - - ai_pci_up(wlc_hw->sih); - - /* reset the d11 core */ - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); - - return 0; -} - -static int brcms_b_up_finish(struct brcms_hardware *wlc_hw) -{ - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - wlc_hw->up = true; - wlc_phy_hw_state_upd(wlc_hw->band->pi, true); - - /* FULLY enable dynamic power control and d11 core interrupt */ - brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC); - brcms_intrson(wlc_hw->wlc->wl); - return 0; -} - -/* - * Write WME tunable parameters for retransmit/max rate - * from wlc struct to ucode - */ -static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) -{ - int ac; - - /* Need clock to do this */ - if (!wlc->clk) - return; - - for (ac = 0; ac < AC_COUNT; ac++) - brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), - wlc->wme_retries[ac]); -} - -/* make interface operational */ -int brcms_c_up(struct brcms_c_info *wlc) -{ - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - /* HW is turned off so don't try to access it */ - if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) - return -ENOMEDIUM; - - if (!wlc->pub->hw_up) { - brcms_b_hw_up(wlc->hw); - wlc->pub->hw_up = true; - } - - if ((wlc->pub->boardflags & BFL_FEM) - && (wlc->pub->sih->chip == BCM4313_CHIP_ID)) { - if (wlc->pub->boardrev >= 0x1250 - && (wlc->pub->boardflags & BFL_FEM_BT)) - brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, - MHF5_4313_GPIOCTRL, BRCM_BAND_ALL); - else - brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, - MHF4_EXTPA_ENABLE, BRCM_BAND_ALL); - } - - /* - * Need to read the hwradio status here to cover the case where the - * system is loaded with the hw radio disabled. We do not want to bring - * the driver up in this case. If radio is disabled, abort up, lower - * power, start radio timer and return 0(for NDIS) don't call - * radio_update to avoid looping brcms_c_up. - * - * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only - */ - if (!wlc->pub->radio_disabled) { - int status = brcms_b_up_prep(wlc->hw); - if (status == -ENOMEDIUM) { - if (!mboolisset - (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { - struct brcms_bss_cfg *bsscfg = wlc->bsscfg; - mboolset(wlc->pub->radio_disabled, - WL_RADIO_HW_DISABLE); - - if (bsscfg->enable && bsscfg->BSS) - wiphy_err(wlc->wiphy, "wl%d: up" - ": rfdisable -> " - "bsscfg_disable()\n", - wlc->pub->unit); - } - } - } - - if (wlc->pub->radio_disabled) { - brcms_c_radio_monitor_start(wlc); - return 0; - } - - /* brcms_b_up_prep has done brcms_c_corereset(). so clk is on, set it */ - wlc->clk = true; - - brcms_c_radio_monitor_stop(wlc); - - /* Set EDCF hostflags */ - brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); - - brcms_init(wlc->wl); - wlc->pub->up = true; - - if (wlc->bandinit_pending) { - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_set_chanspec(wlc, wlc->default_bss->chanspec); - wlc->bandinit_pending = false; - brcms_c_enable_mac(wlc); - } - - brcms_b_up_finish(wlc->hw); - - /* Program the TX wme params with the current settings */ - brcms_c_wme_retries_write(wlc); - - /* start one second watchdog timer */ - brcms_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); - wlc->WDarmed = true; - - /* ensure antenna config is up to date */ - brcms_c_stf_phy_txant_upd(wlc); - /* ensure LDPC config is in sync */ - brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); - - return 0; -} - -static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) -{ - uint callbacks = 0; - - return callbacks; -} - -static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) -{ - bool dev_gone; - uint callbacks = 0; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - dev_gone = brcms_deviceremoved(wlc_hw->wlc); - - /* disable interrupts */ - if (dev_gone) - wlc_hw->wlc->macintmask = 0; - else { - /* now disable interrupts */ - brcms_intrsoff(wlc_hw->wlc->wl); - - /* ensure we're running on the pll clock again */ - brcms_b_clkctl_clk(wlc_hw, CLK_FAST); - } - /* down phy at the last of this stage */ - callbacks += wlc_phy_down(wlc_hw->band->pi); - - return callbacks; -} - -static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) -{ - uint callbacks = 0; - bool dev_gone; - - BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - - if (!wlc_hw->up) - return callbacks; - - wlc_hw->up = false; - wlc_phy_hw_state_upd(wlc_hw->band->pi, false); - - dev_gone = brcms_deviceremoved(wlc_hw->wlc); - - if (dev_gone) { - wlc_hw->sbclk = false; - wlc_hw->clk = false; - wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); - - /* reclaim any posted packets */ - brcms_c_flushqueues(wlc_hw->wlc); - } else { - - /* Reset and disable the core */ - if (ai_iscoreup(wlc_hw->sih)) { - if (R_REG(&wlc_hw->regs->maccontrol) & - MCTL_EN_MAC) - brcms_c_suspend_mac_and_wait(wlc_hw->wlc); - callbacks += brcms_reset(wlc_hw->wlc->wl); - brcms_c_coredisable(wlc_hw); - } - - /* turn off primary xtal and pll */ - if (!wlc_hw->noreset) { - ai_pci_down(wlc_hw->sih); - brcms_b_xtal(wlc_hw, OFF); - } - } - - return callbacks; -} - -/* - * Mark the interface nonoperational, stop the software mechanisms, - * disable the hardware, free any transient buffer state. - * Return a count of the number of driver callbacks still pending. - */ -uint brcms_c_down(struct brcms_c_info *wlc) -{ - - uint callbacks = 0; - int i; - bool dev_gone = false; - struct brcms_txq_info *qi; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - /* check if we are already in the going down path */ - if (wlc->going_down) { - wiphy_err(wlc->wiphy, "wl%d: %s: Driver going down so return" - "\n", wlc->pub->unit, __func__); - return 0; - } - if (!wlc->pub->up) - return callbacks; - - /* in between, mpc could try to bring down again.. */ - wlc->going_down = true; - - callbacks += brcms_b_bmac_down_prep(wlc->hw); - - dev_gone = brcms_deviceremoved(wlc); - - /* Call any registered down handlers */ - for (i = 0; i < BRCMS_MAXMODULES; i++) { - if (wlc->modulecb[i].down_fn) - callbacks += - wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); - } - - /* cancel the watchdog timer */ - if (wlc->WDarmed) { - if (!brcms_del_timer(wlc->wl, wlc->wdtimer)) - callbacks++; - wlc->WDarmed = false; - } - /* cancel all other timers */ - callbacks += brcms_c_down_del_timer(wlc); - - wlc->pub->up = false; - - wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); - - /* clear txq flow control */ - brcms_c_txflowcontrol_reset(wlc); - - /* flush tx queues */ - for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) - brcmu_pktq_flush(&qi->q, true, NULL, NULL); - - callbacks += brcms_b_down_finish(wlc->hw); - - /* brcms_b_down_finish has done brcms_c_coredisable(). so clk is off */ - wlc->clk = false; - - wlc->going_down = false; - return callbacks; -} - -/* Set the current gmode configuration */ -int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) -{ - int ret = 0; - uint i; - struct brcms_c_rateset rs; - /* Default to 54g Auto */ - /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ - s8 shortslot = BRCMS_SHORTSLOT_AUTO; - bool shortslot_restrict = false; /* Restrict association to stations - * that support shortslot - */ - bool ofdm_basic = false; /* Make 6, 12, and 24 basic rates */ - /* Advertise and use short preambles (-1/0/1 Auto/Off/On) */ - int preamble = BRCMS_PLCP_LONG; - bool preamble_restrict = false; /* Restrict association to stations - * that support short preambles - */ - struct brcms_band *band; - - /* if N-support is enabled, allow Gmode set as long as requested - * Gmode is not GMODE_LEGACY_B - */ - if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) - return -ENOTSUPP; - - /* verify that we are dealing with 2G band and grab the band pointer */ - if (wlc->band->bandtype == BRCM_BAND_2G) - band = wlc->band; - else if ((wlc->pub->_nbands > 1) && - (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) - band = wlc->bandstate[OTHERBANDUNIT(wlc)]; - else - return -EINVAL; - - /* Legacy or bust when no OFDM is supported by regulatory */ - if ((brcms_c_channel_locale_flags_in_band(wlc->cmi, band->bandunit) & - BRCMS_NO_OFDM) && (gmode != GMODE_LEGACY_B)) - return -EINVAL; - - /* update configuration value */ - if (config == true) - brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); - - /* Clear rateset override */ - memset(&rs, 0, sizeof(struct brcms_c_rateset)); - - switch (gmode) { - case GMODE_LEGACY_B: - shortslot = BRCMS_SHORTSLOT_OFF; - brcms_c_rateset_copy(&gphy_legacy_rates, &rs); - - break; - - case GMODE_LRS: - break; - - case GMODE_AUTO: - /* Accept defaults */ - break; - - case GMODE_ONLY: - ofdm_basic = true; - preamble = BRCMS_PLCP_SHORT; - preamble_restrict = true; - break; - - case GMODE_PERFORMANCE: - shortslot = BRCMS_SHORTSLOT_ON; - shortslot_restrict = true; - ofdm_basic = true; - preamble = BRCMS_PLCP_SHORT; - preamble_restrict = true; - break; - - default: - /* Error */ - wiphy_err(wlc->wiphy, "wl%d: %s: invalid gmode %d\n", - wlc->pub->unit, __func__, gmode); - return -ENOTSUPP; - } - - band->gmode = gmode; - - wlc->shortslot_override = shortslot; - - /* Use the default 11g rateset */ - if (!rs.count) - brcms_c_rateset_copy(&cck_ofdm_rates, &rs); - - if (ofdm_basic) { - for (i = 0; i < rs.count; i++) { - if (rs.rates[i] == BRCM_RATE_6M - || rs.rates[i] == BRCM_RATE_12M - || rs.rates[i] == BRCM_RATE_24M) - rs.rates[i] |= BRCMS_RATE_FLAG; - } - } - - /* Set default bss rateset */ - wlc->default_bss->rateset.count = rs.count; - memcpy(wlc->default_bss->rateset.rates, rs.rates, - sizeof(wlc->default_bss->rateset.rates)); - - return ret; -} - -int brcms_c_set_nmode(struct brcms_c_info *wlc) -{ - uint i; - s32 nmode = AUTO; - - if (wlc->stf->txstreams == WL_11N_3x3) - nmode = WL_11N_3x3; - else - nmode = WL_11N_2x2; - - /* force GMODE_AUTO if NMODE is ON */ - brcms_c_set_gmode(wlc, GMODE_AUTO, true); - if (nmode == WL_11N_3x3) - wlc->pub->_n_enab = SUPPORT_HT; - else - wlc->pub->_n_enab = SUPPORT_11N; - wlc->default_bss->flags |= BRCMS_BSS_HT; - /* add the mcs rates to the default and hw ratesets */ - brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, - wlc->stf->txstreams); - for (i = 0; i < wlc->pub->_nbands; i++) - memcpy(wlc->bandstate[i]->hw_rateset.mcs, - wlc->default_bss->rateset.mcs, MCSSET_LEN); - - return 0; -} - -static int -brcms_c_set_internal_rateset(struct brcms_c_info *wlc, - struct brcms_c_rateset *rs_arg) -{ - struct brcms_c_rateset rs, new; - uint bandunit; - - memcpy(&rs, rs_arg, sizeof(struct brcms_c_rateset)); - - /* check for bad count value */ - if ((rs.count == 0) || (rs.count > BRCMS_NUMRATES)) - return -EINVAL; - - /* try the current band */ - bandunit = wlc->band->bandunit; - memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); - if (brcms_c_rate_hwrs_filter_sort_validate - (&new, &wlc->bandstate[bandunit]->hw_rateset, true, - wlc->stf->txstreams)) - goto good; - - /* try the other band */ - if (brcms_is_mband_unlocked(wlc)) { - bandunit = OTHERBANDUNIT(wlc); - memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); - if (brcms_c_rate_hwrs_filter_sort_validate(&new, - &wlc-> - bandstate[bandunit]-> - hw_rateset, true, - wlc->stf->txstreams)) - goto good; - } - - return -EBADE; - - good: - /* apply new rateset */ - memcpy(&wlc->default_bss->rateset, &new, - sizeof(struct brcms_c_rateset)); - memcpy(&wlc->bandstate[bandunit]->defrateset, &new, - sizeof(struct brcms_c_rateset)); - return 0; -} - -static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) -{ - u8 r; - bool war = false; - - if (wlc->bsscfg->associated) - r = wlc->bsscfg->current_bss->rateset.rates[0]; - else - r = wlc->default_bss->rateset.rates[0]; - - wlc_phy_ofdm_rateset_war(wlc->band->pi, war); -} - -int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) -{ - u16 chspec = ch20mhz_chspec(channel); - - if (channel < 0 || channel > MAXCHANNEL) - return -EINVAL; - - if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) - return -EINVAL; - - - if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { - if (wlc->band->bandunit != chspec_bandunit(chspec)) - wlc->bandinit_pending = true; - else - wlc->bandinit_pending = false; - } - - wlc->default_bss->chanspec = chspec; - /* brcms_c_BSSinit() will sanitize the rateset before - * using it.. */ - if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { - brcms_c_set_home_chanspec(wlc, chspec); - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_set_chanspec(wlc, chspec); - brcms_c_enable_mac(wlc); - } - return 0; -} - -int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) -{ - int ac; - - if (srl < 1 || srl > RETRY_SHORT_MAX || - lrl < 1 || lrl > RETRY_SHORT_MAX) - return -EINVAL; - - wlc->SRL = srl; - wlc->LRL = lrl; - - brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - - for (ac = 0; ac < AC_COUNT; ac++) { - wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], - EDCF_SHORT, wlc->SRL); - wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], - EDCF_LONG, wlc->LRL); - } - brcms_c_wme_retries_write(wlc); - - return 0; -} - -void brcms_c_get_current_rateset(struct brcms_c_info *wlc, - struct brcm_rateset *currs) -{ - struct brcms_c_rateset *rs; - - if (wlc->pub->associated) - rs = &wlc->bsscfg->current_bss->rateset; - else - rs = &wlc->default_bss->rateset; - - /* Copy only legacy rateset section */ - currs->count = rs->count; - memcpy(&currs->rates, &rs->rates, rs->count); -} - -int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) -{ - struct brcms_c_rateset internal_rs; - int bcmerror; - - if (rs->count > BRCMS_NUMRATES) - return -ENOBUFS; - - memset(&internal_rs, 0, sizeof(struct brcms_c_rateset)); - - /* Copy only legacy rateset section */ - internal_rs.count = rs->count; - memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); - - /* merge rateset coming in with the current mcsset */ - if (wlc->pub->_n_enab & SUPPORT_11N) { - struct brcms_bss_info *mcsset_bss; - if (wlc->bsscfg->associated) - mcsset_bss = wlc->bsscfg->current_bss; - else - mcsset_bss = wlc->default_bss; - memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], - MCSSET_LEN); - } - - bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs); - if (!bcmerror) - brcms_c_ofdm_rateset_war(wlc); - - return bcmerror; -} - -int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period) -{ - if (period < DOT11_MIN_BEACON_PERIOD || - period > DOT11_MAX_BEACON_PERIOD) - return -EINVAL; - - wlc->default_bss->beacon_period = period; - return 0; -} - -u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) -{ - return wlc->band->phytype; -} - -void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) -{ - wlc->shortslot_override = sslot_override; - - /* - * shortslot is an 11g feature, so no more work if we are - * currently on the 5G band - */ - if (wlc->band->bandtype == BRCM_BAND_5G) - return; - - if (wlc->pub->up && wlc->pub->associated) { - /* let watchdog or beacon processing update shortslot */ - } else if (wlc->pub->up) { - /* unassociated shortslot is off */ - brcms_c_switch_shortslot(wlc, false); - } else { - /* driver is down, so just update the brcms_c_info - * value */ - if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) - wlc->shortslot = false; - else - wlc->shortslot = - (wlc->shortslot_override == - BRCMS_SHORTSLOT_ON); - } -} - -/* - * register watchdog and down handlers. - */ -int brcms_c_module_register(struct brcms_pub *pub, - const char *name, struct brcms_info *hdl, - int (*d_fn)(void *handle)) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; - int i; - - /* find an empty entry and just add, no duplication check! */ - for (i = 0; i < BRCMS_MAXMODULES; i++) { - if (wlc->modulecb[i].name[0] == '\0') { - strncpy(wlc->modulecb[i].name, name, - sizeof(wlc->modulecb[i].name) - 1); - wlc->modulecb[i].hdl = hdl; - wlc->modulecb[i].down_fn = d_fn; - return 0; - } - } - - return -ENOSR; -} - -/* unregister module callbacks */ -int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, - struct brcms_info *hdl) -{ - struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; - int i; - - if (wlc == NULL) - return -ENODATA; - - for (i = 0; i < BRCMS_MAXMODULES; i++) { - if (!strcmp(wlc->modulecb[i].name, name) && - (wlc->modulecb[i].hdl == hdl)) { - memset(&wlc->modulecb[i], 0, sizeof(struct modulecb)); - return 0; - } - } - - /* table not found! */ - return -ENODATA; -} - -#ifdef BCMDBG -static const char * const supr_reason[] = { - "None", "PMQ Entry", "Flush request", - "Previous frag failure", "Channel mismatch", - "Lifetime Expiry", "Underflow" -}; - -static void brcms_c_print_txs_status(u16 s) -{ - printk(KERN_DEBUG "[15:12] %d frame attempts\n", - (s & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT); - printk(KERN_DEBUG " [11:8] %d rts attempts\n", - (s & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT); - printk(KERN_DEBUG " [7] %d PM mode indicated\n", - ((s & TX_STATUS_PMINDCTD) ? 1 : 0)); - printk(KERN_DEBUG " [6] %d intermediate status\n", - ((s & TX_STATUS_INTERMEDIATE) ? 1 : 0)); - printk(KERN_DEBUG " [5] %d AMPDU\n", - (s & TX_STATUS_AMPDU) ? 1 : 0); - printk(KERN_DEBUG " [4:2] %d Frame Suppressed Reason (%s)\n", - ((s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT), - supr_reason[(s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT]); - printk(KERN_DEBUG " [1] %d acked\n", - ((s & TX_STATUS_ACK_RCV) ? 1 : 0)); -} -#endif /* BCMDBG */ - -void brcms_c_print_txstatus(struct tx_status *txs) -{ -#if defined(BCMDBG) - u16 s = txs->status; - u16 ackphyrxsh = txs->ackphyrxsh; - - printk(KERN_DEBUG "\ntxpkt (MPDU) Complete\n"); - - printk(KERN_DEBUG "FrameID: %04x ", txs->frameid); - printk(KERN_DEBUG "TxStatus: %04x", s); - printk(KERN_DEBUG "\n"); - - brcms_c_print_txs_status(s); - - printk(KERN_DEBUG "LastTxTime: %04x ", txs->lasttxtime); - printk(KERN_DEBUG "Seq: %04x ", txs->sequence); - printk(KERN_DEBUG "PHYTxStatus: %04x ", txs->phyerr); - printk(KERN_DEBUG "RxAckRSSI: %04x ", - (ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT); - printk(KERN_DEBUG "RxAckSQ: %04x", - (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); - printk(KERN_DEBUG "\n"); -#endif /* defined(BCMDBG) */ -} - -void brcms_c_statsupd(struct brcms_c_info *wlc) -{ - int i; - struct macstat macstats; -#ifdef BCMDBG - u16 delta; - u16 rxf0ovfl; - u16 txfunfl[NFIFO]; -#endif /* BCMDBG */ - - /* if driver down, make no sense to update stats */ - if (!wlc->pub->up) - return; - -#ifdef BCMDBG - /* save last rx fifo 0 overflow count */ - rxf0ovfl = wlc->core->macstat_snapshot->rxf0ovfl; - - /* save last tx fifo underflow count */ - for (i = 0; i < NFIFO; i++) - txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i]; -#endif /* BCMDBG */ - - /* Read mac stats from contiguous shared memory */ - brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats, - sizeof(struct macstat), OBJADDR_SHM_SEL); - -#ifdef BCMDBG - /* check for rx fifo 0 overflow */ - delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl); - if (delta) - wiphy_err(wlc->wiphy, "wl%d: %u rx fifo 0 overflows!\n", - wlc->pub->unit, delta); - - /* check for tx fifo underflows */ - for (i = 0; i < NFIFO; i++) { - delta = - (u16) (wlc->core->macstat_snapshot->txfunfl[i] - - txfunfl[i]); - if (delta) - wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!" - "\n", wlc->pub->unit, delta, i); - } -#endif /* BCMDBG */ - - /* merge counters from dma module */ - for (i = 0; i < NFIFO; i++) { - if (wlc->hw->di[i]) - dma_counterreset(wlc->hw->di[i]); - } -} - -bool brcms_c_chipmatch(u16 vendor, u16 device) -{ - if (vendor != PCI_VENDOR_ID_BROADCOM) { - pr_err("chipmatch: unknown vendor id %04x\n", vendor); - return false; - } - - if (device == BCM43224_D11N_ID_VEN1) - return true; - if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID)) - return true; - if (device == BCM4313_D11N2G_ID) - return true; - if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID)) - return true; - - pr_err("chipmatch: unknown device id %04x\n", device); - return false; -} - -#if defined(BCMDBG) -void brcms_c_print_txdesc(struct d11txh *txh) -{ - u16 mtcl = le16_to_cpu(txh->MacTxControlLow); - u16 mtch = le16_to_cpu(txh->MacTxControlHigh); - u16 mfc = le16_to_cpu(txh->MacFrameControl); - u16 tfest = le16_to_cpu(txh->TxFesTimeNormal); - u16 ptcw = le16_to_cpu(txh->PhyTxControlWord); - u16 ptcw_1 = le16_to_cpu(txh->PhyTxControlWord_1); - u16 ptcw_1_Fbr = le16_to_cpu(txh->PhyTxControlWord_1_Fbr); - u16 ptcw_1_Rts = le16_to_cpu(txh->PhyTxControlWord_1_Rts); - u16 ptcw_1_FbrRts = le16_to_cpu(txh->PhyTxControlWord_1_FbrRts); - u16 mainrates = le16_to_cpu(txh->MainRates); - u16 xtraft = le16_to_cpu(txh->XtraFrameTypes); - u8 *iv = txh->IV; - u8 *ra = txh->TxFrameRA; - u16 tfestfb = le16_to_cpu(txh->TxFesTimeFallback); - u8 *rtspfb = txh->RTSPLCPFallback; - u16 rtsdfb = le16_to_cpu(txh->RTSDurFallback); - u8 *fragpfb = txh->FragPLCPFallback; - u16 fragdfb = le16_to_cpu(txh->FragDurFallback); - u16 mmodelen = le16_to_cpu(txh->MModeLen); - u16 mmodefbrlen = le16_to_cpu(txh->MModeFbrLen); - u16 tfid = le16_to_cpu(txh->TxFrameID); - u16 txs = le16_to_cpu(txh->TxStatus); - u16 mnmpdu = le16_to_cpu(txh->MaxNMpdus); - u16 mabyte = le16_to_cpu(txh->MaxABytes_MRT); - u16 mabyte_f = le16_to_cpu(txh->MaxABytes_FBR); - u16 mmbyte = le16_to_cpu(txh->MinMBytes); - - u8 *rtsph = txh->RTSPhyHeader; - struct ieee80211_rts rts = txh->rts_frame; - char hexbuf[256]; - - /* add plcp header along with txh descriptor */ - printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - txh, sizeof(struct d11txh) + 48); - - printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl); - printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch); - printk(KERN_DEBUG "FC: %04x ", mfc); - printk(KERN_DEBUG "FES Time: %04x\n", tfest); - printk(KERN_DEBUG "PhyCtl: %04x%s ", ptcw, - (ptcw & PHY_TXC_SHORT_HDR) ? " short" : ""); - printk(KERN_DEBUG "PhyCtl_1: %04x ", ptcw_1); - printk(KERN_DEBUG "PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); - printk(KERN_DEBUG "PhyCtl_1_Rts: %04x ", ptcw_1_Rts); - printk(KERN_DEBUG "PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); - printk(KERN_DEBUG "MainRates: %04x ", mainrates); - printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); - printk(KERN_DEBUG "\n"); - - brcmu_format_hex(hexbuf, iv, sizeof(txh->IV)); - printk(KERN_DEBUG "SecIV: %s\n", hexbuf); - brcmu_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA)); - printk(KERN_DEBUG "RA: %s\n", hexbuf); - - printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); - brcmu_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback)); - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); - printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); - brcmu_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback)); - printk(KERN_DEBUG "PLCP: %s ", hexbuf); - printk(KERN_DEBUG "DUR: %04x", fragdfb); - printk(KERN_DEBUG "\n"); - - printk(KERN_DEBUG "MModeLen: %04x ", mmodelen); - printk(KERN_DEBUG "MModeFbrLen: %04x\n", mmodefbrlen); - - printk(KERN_DEBUG "FrameID: %04x\n", tfid); - printk(KERN_DEBUG "TxStatus: %04x\n", txs); - - printk(KERN_DEBUG "MaxNumMpdu: %04x\n", mnmpdu); - printk(KERN_DEBUG "MaxAggbyte: %04x\n", mabyte); - printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); - printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); - - brcmu_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader)); - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); - brcmu_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame)); - printk(KERN_DEBUG "RTS Frame: %s", hexbuf); - printk(KERN_DEBUG "\n"); -} -#endif /* defined(BCMDBG) */ - -#if defined(BCMDBG) -void brcms_c_print_rxh(struct d11rxhdr *rxh) -{ - u16 len = rxh->RxFrameSize; - u16 phystatus_0 = rxh->PhyRxStatus_0; - u16 phystatus_1 = rxh->PhyRxStatus_1; - u16 phystatus_2 = rxh->PhyRxStatus_2; - u16 phystatus_3 = rxh->PhyRxStatus_3; - u16 macstatus1 = rxh->RxStatus1; - u16 macstatus2 = rxh->RxStatus2; - char flagstr[64]; - char lenbuf[20]; - static const struct brcmu_bit_desc macstat_flags[] = { - {RXS_FCSERR, "FCSErr"}, - {RXS_RESPFRAMETX, "Reply"}, - {RXS_PBPRES, "PADDING"}, - {RXS_DECATMPT, "DeCr"}, - {RXS_DECERR, "DeCrErr"}, - {RXS_BCNSENT, "Bcn"}, - {0, NULL} - }; - - printk(KERN_DEBUG "Raw RxDesc:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, - sizeof(struct d11rxhdr)); - - brcmu_format_flags(macstat_flags, macstatus1, flagstr, 64); - - snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); - - printk(KERN_DEBUG "RxFrameSize: %6s (%d)%s\n", lenbuf, len, - (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : ""); - printk(KERN_DEBUG "RxPHYStatus: %04x %04x %04x %04x\n", - phystatus_0, phystatus_1, phystatus_2, phystatus_3); - printk(KERN_DEBUG "RxMACStatus: %x %s\n", macstatus1, flagstr); - printk(KERN_DEBUG "RXMACaggtype: %x\n", - (macstatus2 & RXS_AGGTYPE_MASK)); - printk(KERN_DEBUG "RxTSFTime: %04x\n", rxh->RxTSFTime); -} -#endif /* defined(BCMDBG) */ - -u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) -{ - u16 table_ptr; - u8 phy_rate, index; - - /* get the phy specific rate encoding for the PLCP SIGNAL field */ - if (is_ofdm_rate(rate)) - table_ptr = M_RT_DIRMAP_A; - else - table_ptr = M_RT_DIRMAP_B; - - /* for a given rate, the LS-nibble of the PLCP SIGNAL field is - * the index into the rate table. - */ - phy_rate = rate_info[rate] & BRCMS_RATE_MASK; - index = phy_rate & 0xf; - - /* Find the SHM pointer to the rate table entry by looking in the - * Direct-map Table - */ - return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); -} - -/* Callback for device removed */ - -/* - * Attempts to queue a packet onto a multiple-precedence queue, - * if necessary evicting a lower precedence packet from the queue. - * - * 'prec' is the precedence number that has already been mapped - * from the packet priority. - * - * Returns true if packet consumed (queued), false if not. - */ -static bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q, - struct sk_buff *pkt, int prec) -{ - return brcms_c_prec_enq_head(wlc, q, pkt, prec, false); -} - -bool -brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, - struct sk_buff *pkt, int prec, bool head) -{ - struct sk_buff *p; - int eprec = -1; /* precedence to evict from */ - - /* Determine precedence from which to evict packet, if any */ - if (pktq_pfull(q, prec)) - eprec = prec; - else if (pktq_full(q)) { - p = brcmu_pktq_peek_tail(q, &eprec); - if (eprec > prec) { - wiphy_err(wlc->wiphy, "%s: Failing: eprec %d > prec %d" - "\n", __func__, eprec, prec); - return false; - } - } - - /* Evict if needed */ - if (eprec >= 0) { - bool discard_oldest; - - discard_oldest = ac_bitmap_tst(0, eprec); - - /* Refuse newer packet unless configured to discard oldest */ - if (eprec == prec && !discard_oldest) { - wiphy_err(wlc->wiphy, "%s: No where to go, prec == %d" - "\n", __func__, prec); - return false; - } - - /* Evict packet according to discard policy */ - p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) : - brcmu_pktq_pdeq_tail(q, eprec); - brcmu_pkt_buf_free_skb(p); - } - - /* Enqueue */ - if (head) - p = brcmu_pktq_penq_head(q, prec, pkt); - else - p = brcmu_pktq_penq(q, prec, pkt); - - return true; -} - -void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, - struct sk_buff *sdu, uint prec) -{ - struct brcms_txq_info *qi = wlc->pkt_queue; /* Check me */ - struct pktq *q = &qi->q; - int prio; - - prio = sdu->priority; - - if (!brcms_c_prec_enq(wlc, q, sdu, prec)) { - /* - * we might hit this condtion in case - * packet flooding from mac80211 stack - */ - brcmu_pkt_buf_free_skb(sdu); - } -} - -/* - * bcmc_fid_generate: - * Generate frame ID for a BCMC packet. The frag field is not used - * for MC frames so is used as part of the sequence number. - */ -static inline u16 -bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, - struct d11txh *txh) -{ - u16 frameid; - - frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | - TXFID_QUEUE_MASK); - frameid |= - (((wlc-> - mc_fid_counter++) << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) | - TX_BCMC_FIFO; - - return frameid; -} - -static uint -brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - uint dur = 0; - - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n", - wlc->pub->unit, rspec, preamble_type); - /* - * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that - * is less than or equal to the rate of the immediately previous - * frame in the FES - */ - rspec = brcms_basic_rate(wlc, rspec); - /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ - dur = - brcms_c_calc_frame_time(wlc, rspec, preamble_type, - (DOT11_ACK_LEN + FCS_LEN)); - return dur; -} - -static uint -brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n", - wlc->pub->unit, rspec, preamble_type); - return brcms_c_calc_ack_time(wlc, rspec, preamble_type); -} - -static uint -brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, - u8 preamble_type) -{ - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, " - "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type); - /* - * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that - * is less than or equal to the rate of the immediately previous - * frame in the FES - */ - rspec = brcms_basic_rate(wlc, rspec); - /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ - return brcms_c_calc_frame_time(wlc, rspec, preamble_type, - (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + - FCS_LEN)); -} - -/* brcms_c_compute_frame_dur() - * - * Calculate the 802.11 MAC header DUR field for MPDU - * DUR for a single frame = 1 SIFS + 1 ACK - * DUR for a frame with following frags = 3 SIFS + 2 ACK + next frag time - * - * rate MPDU rate in unit of 500kbps - * next_frag_len next MPDU length in bytes - * preamble_type use short/GF or long/MM PLCP header - */ -static u16 -brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, - u8 preamble_type, uint next_frag_len) -{ - u16 dur, sifs; - - sifs = get_sifs(wlc->band); - - dur = sifs; - dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); - - if (next_frag_len) { - /* Double the current DUR to get 2 SIFS + 2 ACKs */ - dur *= 2; - /* add another SIFS and the frag time */ - dur += sifs; - dur += - (u16) brcms_c_calc_frame_time(wlc, rate, preamble_type, - next_frag_len); - } - return dur; -} - -/* The opposite of brcms_c_calc_frame_time */ -static uint -brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, - u8 preamble_type, uint dur) -{ - uint nsyms, mac_len, Ndps, kNdps; - uint rate = rspec2rate(ratespec); - - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n", - wlc->pub->unit, ratespec, preamble_type, dur); - - if (is_mcs_rate(ratespec)) { - uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); - dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); - /* payload calculation matches that of regular ofdm */ - if (wlc->band->bandtype == BRCM_BAND_2G) - dur -= DOT11_OFDM_SIGNAL_EXTENSION; - /* kNdbps = kbps * 4 */ - kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), - rspec_issgi(ratespec)) * 4; - nsyms = dur / APHY_SYMBOL_TIME; - mac_len = - ((nsyms * kNdps) - - ((APHY_SERVICE_NBITS + APHY_TAIL_NBITS) * 1000)) / 8000; - } else if (is_ofdm_rate(ratespec)) { - dur -= APHY_PREAMBLE_TIME; - dur -= APHY_SIGNAL_TIME; - /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ - Ndps = rate * 2; - nsyms = dur / APHY_SYMBOL_TIME; - mac_len = - ((nsyms * Ndps) - - (APHY_SERVICE_NBITS + APHY_TAIL_NBITS)) / 8; - } else { - if (preamble_type & BRCMS_SHORT_PREAMBLE) - dur -= BPHY_PLCP_SHORT_TIME; - else - dur -= BPHY_PLCP_TIME; - mac_len = dur * rate; - /* divide out factor of 2 in rate (1/2 mbps) */ - mac_len = mac_len / 8 / 2; - } - return mac_len; -} - -static u32 -mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, - u32 int_val) -{ - u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT; - u8 rate = int_val & NRATE_RATE_MASK; - u32 rspec; - bool ismcs = ((int_val & NRATE_MCS_INUSE) == NRATE_MCS_INUSE); - bool issgi = ((int_val & NRATE_SGI_MASK) >> NRATE_SGI_SHIFT); - bool override_mcs_only = ((int_val & NRATE_OVERRIDE_MCS_ONLY) - == NRATE_OVERRIDE_MCS_ONLY); - int bcmerror = 0; - - if (!ismcs) - return (u32) rate; - - /* validate the combination of rate/mcs/stf is allowed */ - if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { - /* mcs only allowed when nmode */ - if (stf > PHY_TXC1_MODE_SDM) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", - wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - - /* mcs 32 is a special case, DUP mode 40 only */ - if (rate == 32) { - if (!CHSPEC_IS40(wlc->home_chanspec) || - ((stf != PHY_TXC1_MODE_SISO) - && (stf != PHY_TXC1_MODE_CDD))) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs " - "32\n", wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - /* mcs > 7 must use stf SDM */ - } else if (rate > HIGHEST_SINGLE_STREAM_MCS) { - /* mcs > 7 must use stf SDM */ - if (stf != PHY_TXC1_MODE_SDM) { - BCMMSG(wlc->wiphy, "wl%d: enabling " - "SDM mode for mcs %d\n", - wlc->pub->unit, rate); - stf = PHY_TXC1_MODE_SDM; - } - } else { - /* - * MCS 0-7 may use SISO, CDD, and for - * phy_rev >= 3 STBC - */ - if ((stf > PHY_TXC1_MODE_STBC) || - (!BRCMS_STBC_CAP_PHY(wlc) - && (stf == PHY_TXC1_MODE_STBC))) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC" - "\n", wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - } - } else if (is_ofdm_rate(rate)) { - if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", - wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - } else if (is_cck_rate(rate)) { - if ((cur_band->bandtype != BRCM_BAND_2G) - || (stf != PHY_TXC1_MODE_SISO)) { - wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", - wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - } else { - wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n", - wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - /* make sure multiple antennae are available for non-siso rates */ - if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { - wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO " - "request\n", wlc->pub->unit, __func__); - bcmerror = -EINVAL; - goto done; - } - - rspec = rate; - if (ismcs) { - rspec |= RSPEC_MIMORATE; - /* For STBC populate the STC field of the ratespec */ - if (stf == PHY_TXC1_MODE_STBC) { - u8 stc; - stc = 1; /* Nss for single stream is always 1 */ - rspec |= (stc << RSPEC_STC_SHIFT); - } - } - - rspec |= (stf << RSPEC_STF_SHIFT); - - if (override_mcs_only) - rspec |= RSPEC_OVERRIDE_MCS_ONLY; - - if (issgi) - rspec |= RSPEC_SHORT_GI; - - if ((rate != 0) - && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) - return rate; - - return rspec; -done: - return rate; -} - -/* - * Add struct d11txh, struct cck_phy_hdr. - * - * 'p' data must start with 802.11 MAC header - * 'p' must allow enough bytes of local headers to be "pushed" onto the packet - * - * headroom == D11_PHY_HDR_LEN + D11_TXH_LEN (D11_TXH_LEN is now 104 bytes) - * - */ -static u16 -brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, - struct sk_buff *p, struct scb *scb, uint frag, - uint nfrags, uint queue, uint next_frag_len) -{ - struct ieee80211_hdr *h; - struct d11txh *txh; - u8 *plcp, plcp_fallback[D11_PHY_HDR_LEN]; - int len, phylen, rts_phylen; - u16 mch, phyctl, xfts, mainrates; - u16 seq = 0, mcl = 0, status = 0, frameid = 0; - u32 rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }; - u32 rts_rspec[2] = { BRCM_RATE_1M, BRCM_RATE_1M }; - bool use_rts = false; - bool use_cts = false; - bool use_rifs = false; - bool short_preamble[2] = { false, false }; - u8 preamble_type[2] = { BRCMS_LONG_PREAMBLE, BRCMS_LONG_PREAMBLE }; - u8 rts_preamble_type[2] = { BRCMS_LONG_PREAMBLE, BRCMS_LONG_PREAMBLE }; - u8 *rts_plcp, rts_plcp_fallback[D11_PHY_HDR_LEN]; - struct ieee80211_rts *rts = NULL; - bool qos; - uint ac; - bool hwtkmic = false; - u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; -#define ANTCFG_NONE 0xFF - u8 antcfg = ANTCFG_NONE; - u8 fbantcfg = ANTCFG_NONE; - uint phyctl1_stf = 0; - u16 durid = 0; - struct ieee80211_tx_rate *txrate[2]; - int k; - struct ieee80211_tx_info *tx_info; - bool is_mcs; - u16 mimo_txbw; - u8 mimo_preamble_type; - - /* locate 802.11 MAC header */ - h = (struct ieee80211_hdr *)(p->data); - qos = ieee80211_is_data_qos(h->frame_control); - - /* compute length of frame in bytes for use in PLCP computations */ - len = brcmu_pkttotlen(p); - phylen = len + FCS_LEN; - - /* Get tx_info */ - tx_info = IEEE80211_SKB_CB(p); - - /* add PLCP */ - plcp = skb_push(p, D11_PHY_HDR_LEN); - - /* add Broadcom tx descriptor header */ - txh = (struct d11txh *) skb_push(p, D11_TXH_LEN); - memset(txh, 0, D11_TXH_LEN); - - /* setup frameid */ - if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { - /* non-AP STA should never use BCMC queue */ - if (queue == TX_BCMC_FIFO) { - wiphy_err(wlc->wiphy, "wl%d: %s: ASSERT queue == " - "TX_BCMC!\n", wlc->pub->unit, __func__); - frameid = bcmc_fid_generate(wlc, NULL, txh); - } else { - /* Increment the counter for first fragment */ - if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) - scb->seqnum[p->priority]++; - - /* extract fragment number from frame first */ - seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; - seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); - h->seq_ctrl = cpu_to_le16(seq); - - frameid = ((seq << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) | - (queue & TXFID_QUEUE_MASK); - } - } - frameid |= queue & TXFID_QUEUE_MASK; - - /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */ - if (ieee80211_is_beacon(h->frame_control)) - mcl |= TXC_IGNOREPMQ; - - txrate[0] = tx_info->control.rates; - txrate[1] = txrate[0] + 1; - - /* - * if rate control algorithm didn't give us a fallback - * rate, use the primary rate - */ - if (txrate[1]->idx < 0) - txrate[1] = txrate[0]; - - for (k = 0; k < hw->max_rates; k++) { - is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; - if (!is_mcs) { - if ((txrate[k]->idx >= 0) - && (txrate[k]->idx < - hw->wiphy->bands[tx_info->band]->n_bitrates)) { - rspec[k] = - hw->wiphy->bands[tx_info->band]-> - bitrates[txrate[k]->idx].hw_value; - short_preamble[k] = - txrate[k]-> - flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ? - true : false; - } else { - rspec[k] = BRCM_RATE_1M; - } - } else { - rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, - NRATE_MCS_INUSE | txrate[k]->idx); - } - - /* - * Currently only support same setting for primay and - * fallback rates. Unify flags for each rate into a - * single value for the frame - */ - use_rts |= - txrate[k]-> - flags & IEEE80211_TX_RC_USE_RTS_CTS ? true : false; - use_cts |= - txrate[k]-> - flags & IEEE80211_TX_RC_USE_CTS_PROTECT ? true : false; - - - /* - * (1) RATE: - * determine and validate primary rate - * and fallback rates - */ - if (!rspec_active(rspec[k])) { - rspec[k] = BRCM_RATE_1M; - } else { - if (!is_multicast_ether_addr(h->addr1)) { - /* set tx antenna config */ - brcms_c_antsel_antcfg_get(wlc->asi, false, - false, 0, 0, &antcfg, &fbantcfg); - } - } - } - - phyctl1_stf = wlc->stf->ss_opmode; - - if (wlc->pub->_n_enab & SUPPORT_11N) { - for (k = 0; k < hw->max_rates; k++) { - /* - * apply siso/cdd to single stream mcs's or ofdm - * if rspec is auto selected - */ - if (((is_mcs_rate(rspec[k]) && - is_single_stream(rspec[k] & RSPEC_RATE_MASK)) || - is_ofdm_rate(rspec[k])) - && ((rspec[k] & RSPEC_OVERRIDE_MCS_ONLY) - || !(rspec[k] & RSPEC_OVERRIDE))) { - rspec[k] &= ~(RSPEC_STF_MASK | RSPEC_STC_MASK); - - /* For SISO MCS use STBC if possible */ - if (is_mcs_rate(rspec[k]) - && BRCMS_STF_SS_STBC_TX(wlc, scb)) { - u8 stc; - - /* Nss for single stream is always 1 */ - stc = 1; - rspec[k] |= (PHY_TXC1_MODE_STBC << - RSPEC_STF_SHIFT) | - (stc << RSPEC_STC_SHIFT); - } else - rspec[k] |= - (phyctl1_stf << RSPEC_STF_SHIFT); - } - - /* - * Is the phy configured to use 40MHZ frames? If - * so then pick the desired txbw - */ - if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { - /* default txbw is 20in40 SB */ - mimo_ctlchbw = mimo_txbw = - CHSPEC_SB_UPPER(wlc_phy_chanspec_get( - wlc->band->pi)) - ? PHY_TXC1_BW_20MHZ_UP : PHY_TXC1_BW_20MHZ; - - if (is_mcs_rate(rspec[k])) { - /* mcs 32 must be 40b/w DUP */ - if ((rspec[k] & RSPEC_RATE_MASK) - == 32) { - mimo_txbw = - PHY_TXC1_BW_40MHZ_DUP; - /* use override */ - } else if (wlc->mimo_40txbw != AUTO) - mimo_txbw = wlc->mimo_40txbw; - /* else check if dst is using 40 Mhz */ - else if (scb->flags & SCB_IS40) - mimo_txbw = PHY_TXC1_BW_40MHZ; - } else if (is_ofdm_rate(rspec[k])) { - if (wlc->ofdm_40txbw != AUTO) - mimo_txbw = wlc->ofdm_40txbw; - } else if (wlc->cck_40txbw != AUTO) { - mimo_txbw = wlc->cck_40txbw; - } - } else { - /* - * mcs32 is 40 b/w only. - * This is possible for probe packets on - * a STA during SCAN - */ - if ((rspec[k] & RSPEC_RATE_MASK) == 32) - /* mcs 0 */ - rspec[k] = RSPEC_MIMORATE; - - mimo_txbw = PHY_TXC1_BW_20MHZ; - } - - /* Set channel width */ - rspec[k] &= ~RSPEC_BW_MASK; - if ((k == 0) || ((k > 0) && is_mcs_rate(rspec[k]))) - rspec[k] |= (mimo_txbw << RSPEC_BW_SHIFT); - else - rspec[k] |= (mimo_ctlchbw << RSPEC_BW_SHIFT); - - /* Disable short GI, not supported yet */ - rspec[k] &= ~RSPEC_SHORT_GI; - - mimo_preamble_type = BRCMS_MM_PREAMBLE; - if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) - mimo_preamble_type = BRCMS_GF_PREAMBLE; - - if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) - && (!is_mcs_rate(rspec[k]))) { - wiphy_err(wlc->wiphy, "wl%d: %s: IEEE80211_TX_" - "RC_MCS != is_mcs_rate(rspec)\n", - wlc->pub->unit, __func__); - } - - if (is_mcs_rate(rspec[k])) { - preamble_type[k] = mimo_preamble_type; - - /* - * if SGI is selected, then forced mm - * for single stream - */ - if ((rspec[k] & RSPEC_SHORT_GI) - && is_single_stream(rspec[k] & - RSPEC_RATE_MASK)) - preamble_type[k] = BRCMS_MM_PREAMBLE; - } - - /* should be better conditionalized */ - if (!is_mcs_rate(rspec[0]) - && (tx_info->control.rates[0]. - flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)) - preamble_type[k] = BRCMS_SHORT_PREAMBLE; - } - } else { - for (k = 0; k < hw->max_rates; k++) { - /* Set ctrlchbw as 20Mhz */ - rspec[k] &= ~RSPEC_BW_MASK; - rspec[k] |= (PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT); - - /* for nphy, stf of ofdm frames must follow policies */ - if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { - rspec[k] &= ~RSPEC_STF_MASK; - rspec[k] |= phyctl1_stf << RSPEC_STF_SHIFT; - } - } - } - - /* Reset these for use with AMPDU's */ - txrate[0]->count = 0; - txrate[1]->count = 0; - - /* (2) PROTECTION, may change rspec */ - if ((ieee80211_is_data(h->frame_control) || - ieee80211_is_mgmt(h->frame_control)) && - (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) - use_rts = true; - - /* (3) PLCP: determine PLCP header and MAC duration, - * fill struct d11txh */ - brcms_c_compute_plcp(wlc, rspec[0], phylen, plcp); - brcms_c_compute_plcp(wlc, rspec[1], phylen, plcp_fallback); - memcpy(&txh->FragPLCPFallback, - plcp_fallback, sizeof(txh->FragPLCPFallback)); - - /* Length field now put in CCK FBR CRC field */ - if (is_cck_rate(rspec[1])) { - txh->FragPLCPFallback[4] = phylen & 0xff; - txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; - } - - /* MIMO-RATE: need validation ?? */ - mainrates = is_ofdm_rate(rspec[0]) ? - D11A_PHY_HDR_GRATE((struct ofdm_phy_hdr *) plcp) : - plcp[0]; - - /* DUR field for main rate */ - if (!ieee80211_is_pspoll(h->frame_control) && - !is_multicast_ether_addr(h->addr1) && !use_rifs) { - durid = - brcms_c_compute_frame_dur(wlc, rspec[0], preamble_type[0], - next_frag_len); - h->duration_id = cpu_to_le16(durid); - } else if (use_rifs) { - /* NAV protect to end of next max packet size */ - durid = - (u16) brcms_c_calc_frame_time(wlc, rspec[0], - preamble_type[0], - DOT11_MAX_FRAG_LEN); - durid += RIFS_11N_TIME; - h->duration_id = cpu_to_le16(durid); - } - - /* DUR field for fallback rate */ - if (ieee80211_is_pspoll(h->frame_control)) - txh->FragDurFallback = h->duration_id; - else if (is_multicast_ether_addr(h->addr1) || use_rifs) - txh->FragDurFallback = 0; - else { - durid = brcms_c_compute_frame_dur(wlc, rspec[1], - preamble_type[1], next_frag_len); - txh->FragDurFallback = cpu_to_le16(durid); - } - - /* (4) MAC-HDR: MacTxControlLow */ - if (frag == 0) - mcl |= TXC_STARTMSDU; - - if (!is_multicast_ether_addr(h->addr1)) - mcl |= TXC_IMMEDACK; - - if (wlc->band->bandtype == BRCM_BAND_5G) - mcl |= TXC_FREQBAND_5G; - - if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) - mcl |= TXC_BW_40; - - /* set AMIC bit if using hardware TKIP MIC */ - if (hwtkmic) - mcl |= TXC_AMIC; - - txh->MacTxControlLow = cpu_to_le16(mcl); - - /* MacTxControlHigh */ - mch = 0; - - /* Set fallback rate preamble type */ - if ((preamble_type[1] == BRCMS_SHORT_PREAMBLE) || - (preamble_type[1] == BRCMS_GF_PREAMBLE)) { - if (rspec2rate(rspec[1]) != BRCM_RATE_1M) - mch |= TXC_PREAMBLE_DATA_FB_SHORT; - } - - /* MacFrameControl */ - memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); - txh->TxFesTimeNormal = cpu_to_le16(0); - - txh->TxFesTimeFallback = cpu_to_le16(0); - - /* TxFrameRA */ - memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); - - /* TxFrameID */ - txh->TxFrameID = cpu_to_le16(frameid); - - /* - * TxStatus, Note the case of recreating the first frag of a suppressed - * frame then we may need to reset the retry cnt's via the status reg - */ - txh->TxStatus = cpu_to_le16(status); - - /* - * extra fields for ucode AMPDU aggregation, the new fields are added to - * the END of previous structure so that it's compatible in driver. - */ - txh->MaxNMpdus = cpu_to_le16(0); - txh->MaxABytes_MRT = cpu_to_le16(0); - txh->MaxABytes_FBR = cpu_to_le16(0); - txh->MinMBytes = cpu_to_le16(0); - - /* (5) RTS/CTS: determine RTS/CTS PLCP header and MAC duration, - * furnish struct d11txh */ - /* RTS PLCP header and RTS frame */ - if (use_rts || use_cts) { - if (use_rts && use_cts) - use_cts = false; - - for (k = 0; k < 2; k++) { - rts_rspec[k] = brcms_c_rspec_to_rts_rspec(wlc, rspec[k], - false, - mimo_ctlchbw); - } - - if (!is_ofdm_rate(rts_rspec[0]) && - !((rspec2rate(rts_rspec[0]) == BRCM_RATE_1M) || - (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { - rts_preamble_type[0] = BRCMS_SHORT_PREAMBLE; - mch |= TXC_PREAMBLE_RTS_MAIN_SHORT; - } - - if (!is_ofdm_rate(rts_rspec[1]) && - !((rspec2rate(rts_rspec[1]) == BRCM_RATE_1M) || - (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { - rts_preamble_type[1] = BRCMS_SHORT_PREAMBLE; - mch |= TXC_PREAMBLE_RTS_FB_SHORT; - } - - /* RTS/CTS additions to MacTxControlLow */ - if (use_cts) { - txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); - } else { - txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); - txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); - } - - /* RTS PLCP header */ - rts_plcp = txh->RTSPhyHeader; - if (use_cts) - rts_phylen = DOT11_CTS_LEN + FCS_LEN; - else - rts_phylen = DOT11_RTS_LEN + FCS_LEN; - - brcms_c_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp); - - /* fallback rate version of RTS PLCP header */ - brcms_c_compute_plcp(wlc, rts_rspec[1], rts_phylen, - rts_plcp_fallback); - memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, - sizeof(txh->RTSPLCPFallback)); - - /* RTS frame fields... */ - rts = (struct ieee80211_rts *)&txh->rts_frame; - - durid = brcms_c_compute_rtscts_dur(wlc, use_cts, rts_rspec[0], - rspec[0], rts_preamble_type[0], - preamble_type[0], phylen, false); - rts->duration = cpu_to_le16(durid); - /* fallback rate version of RTS DUR field */ - durid = brcms_c_compute_rtscts_dur(wlc, use_cts, - rts_rspec[1], rspec[1], - rts_preamble_type[1], - preamble_type[1], phylen, false); - txh->RTSDurFallback = cpu_to_le16(durid); - - if (use_cts) { - rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | - IEEE80211_STYPE_CTS); - - memcpy(&rts->ra, &h->addr2, ETH_ALEN); - } else { - rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | - IEEE80211_STYPE_RTS); - - memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN); - } - - /* mainrate - * low 8 bits: main frag rate/mcs, - * high 8 bits: rts/cts rate/mcs - */ - mainrates |= (is_ofdm_rate(rts_rspec[0]) ? - D11A_PHY_HDR_GRATE( - (struct ofdm_phy_hdr *) rts_plcp) : - rts_plcp[0]) << 8; - } else { - memset((char *)txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); - memset((char *)&txh->rts_frame, 0, - sizeof(struct ieee80211_rts)); - memset((char *)txh->RTSPLCPFallback, 0, - sizeof(txh->RTSPLCPFallback)); - txh->RTSDurFallback = 0; - } - -#ifdef SUPPORT_40MHZ - /* add null delimiter count */ - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) - txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = - brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); - -#endif - - /* - * Now that RTS/RTS FB preamble types are updated, write - * the final value - */ - txh->MacTxControlHigh = cpu_to_le16(mch); - - /* - * MainRates (both the rts and frag plcp rates have - * been calculated now) - */ - txh->MainRates = cpu_to_le16(mainrates); - - /* XtraFrameTypes */ - xfts = frametype(rspec[1], wlc->mimoft); - xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); - xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); - xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << - XFTS_CHANNEL_SHIFT; - txh->XtraFrameTypes = cpu_to_le16(xfts); - - /* PhyTxControlWord */ - phyctl = frametype(rspec[0], wlc->mimoft); - if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) || - (preamble_type[0] == BRCMS_GF_PREAMBLE)) { - if (rspec2rate(rspec[0]) != BRCM_RATE_1M) - phyctl |= PHY_TXC_SHORT_HDR; - } - - /* phytxant is properly bit shifted */ - phyctl |= brcms_c_stf_d11hdrs_phyctl_txant(wlc, rspec[0]); - txh->PhyTxControlWord = cpu_to_le16(phyctl); - - /* PhyTxControlWord_1 */ - if (BRCMS_PHY_11N_CAP(wlc->band)) { - u16 phyctl1 = 0; - - phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[0]); - txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); - phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[1]); - txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); - - if (use_rts || use_cts) { - phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[0]); - txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); - phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[1]); - txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); - } - - /* - * For mcs frames, if mixedmode(overloaded with long preamble) - * is going to be set, fill in non-zero MModeLen and/or - * MModeFbrLen it will be unnecessary if they are separated - */ - if (is_mcs_rate(rspec[0]) && - (preamble_type[0] == BRCMS_MM_PREAMBLE)) { - u16 mmodelen = - brcms_c_calc_lsig_len(wlc, rspec[0], phylen); - txh->MModeLen = cpu_to_le16(mmodelen); - } - - if (is_mcs_rate(rspec[1]) && - (preamble_type[1] == BRCMS_MM_PREAMBLE)) { - u16 mmodefbrlen = - brcms_c_calc_lsig_len(wlc, rspec[1], phylen); - txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); - } - } - - ac = skb_get_queue_mapping(p); - if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { - uint frag_dur, dur, dur_fallback; - - /* WME: Update TXOP threshold */ - if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { - frag_dur = - brcms_c_calc_frame_time(wlc, rspec[0], - preamble_type[0], phylen); - - if (rts) { - /* 1 RTS or CTS-to-self frame */ - dur = - brcms_c_calc_cts_time(wlc, rts_rspec[0], - rts_preamble_type[0]); - dur_fallback = - brcms_c_calc_cts_time(wlc, rts_rspec[1], - rts_preamble_type[1]); - /* (SIFS + CTS) + SIFS + frame + SIFS + ACK */ - dur += le16_to_cpu(rts->duration); - dur_fallback += - le16_to_cpu(txh->RTSDurFallback); - } else if (use_rifs) { - dur = frag_dur; - dur_fallback = 0; - } else { - /* frame + SIFS + ACK */ - dur = frag_dur; - dur += - brcms_c_compute_frame_dur(wlc, rspec[0], - preamble_type[0], 0); - - dur_fallback = - brcms_c_calc_frame_time(wlc, rspec[1], - preamble_type[1], - phylen); - dur_fallback += - brcms_c_compute_frame_dur(wlc, rspec[1], - preamble_type[1], 0); - } - /* NEED to set TxFesTimeNormal (hard) */ - txh->TxFesTimeNormal = cpu_to_le16((u16) dur); - /* - * NEED to set fallback rate version of - * TxFesTimeNormal (hard) - */ - txh->TxFesTimeFallback = - cpu_to_le16((u16) dur_fallback); - - /* - * update txop byte threshold (txop minus intraframe - * overhead) - */ - if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { - uint newfragthresh; - - newfragthresh = - brcms_c_calc_frame_len(wlc, - rspec[0], preamble_type[0], - (wlc->edcf_txop[ac] - - (dur - frag_dur))); - /* range bound the fragthreshold */ - if (newfragthresh < DOT11_MIN_FRAG_LEN) - newfragthresh = - DOT11_MIN_FRAG_LEN; - else if (newfragthresh > - wlc->usr_fragthresh) - newfragthresh = - wlc->usr_fragthresh; - /* update the fragthresh and do txc update */ - if (wlc->fragthresh[queue] != - (u16) newfragthresh) - wlc->fragthresh[queue] = - (u16) newfragthresh; - } else { - wiphy_err(wlc->wiphy, "wl%d: %s txop invalid " - "for rate %d\n", - wlc->pub->unit, fifo_names[queue], - rspec2rate(rspec[0])); - } - - if (dur > wlc->edcf_txop[ac]) - wiphy_err(wlc->wiphy, "wl%d: %s: %s txop " - "exceeded phylen %d/%d dur %d/%d\n", - wlc->pub->unit, __func__, - fifo_names[queue], - phylen, wlc->fragthresh[queue], - dur, wlc->edcf_txop[ac]); - } - } - - return 0; -} - -void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, - struct ieee80211_hw *hw) -{ - u8 prio; - uint fifo; - struct scb *scb = &wlc->pri_scb; - struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); - - /* - * 802.11 standard requires management traffic - * to go at highest priority - */ - prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : - MAXPRIO; - fifo = prio2fifo[prio]; - if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0)) - return; - brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio)); - brcms_c_send_q(wlc); -} - -void brcms_c_send_q(struct brcms_c_info *wlc) -{ - struct sk_buff *pkt[DOT11_MAXNUMFRAGS]; - int prec; - u16 prec_map; - int err = 0, i, count; - uint fifo; - struct brcms_txq_info *qi = wlc->pkt_queue; - struct pktq *q = &qi->q; - struct ieee80211_tx_info *tx_info; - - prec_map = wlc->tx_prec_map; - - /* Send all the enq'd pkts that we can. - * Dequeue packets with precedence with empty HW fifo only - */ - while (prec_map && (pkt[0] = brcmu_pktq_mdeq(q, prec_map, &prec))) { - tx_info = IEEE80211_SKB_CB(pkt[0]); - if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { - err = brcms_c_sendampdu(wlc->ampdu, qi, pkt, prec); - } else { - count = 1; - err = brcms_c_prep_pdu(wlc, pkt[0], &fifo); - if (!err) { - for (i = 0; i < count; i++) - brcms_c_txfifo(wlc, fifo, pkt[i], true, - 1); - } - } - - if (err == -EBUSY) { - brcmu_pktq_penq_head(q, prec, pkt[0]); - /* - * If send failed due to any other reason than a - * change in HW FIFO condition, quit. Otherwise, - * read the new prec_map! - */ - if (prec_map == wlc->tx_prec_map) - break; - prec_map = wlc->tx_prec_map; - } - } -} - -void -brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, - bool commit, s8 txpktpend) -{ - u16 frameid = INVALIDFID; - struct d11txh *txh; - - txh = (struct d11txh *) (p->data); - - /* When a BC/MC frame is being committed to the BCMC fifo - * via DMA (NOT PIO), update ucode or BSS info as appropriate. - */ - if (fifo == TX_BCMC_FIFO) - frameid = le16_to_cpu(txh->TxFrameID); - - /* - * Bump up pending count for if not using rpc. If rpc is - * used, this will be handled in brcms_b_txfifo() - */ - if (commit) { - wlc->core->txpktpend[fifo] += txpktpend; - BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n", - txpktpend, wlc->core->txpktpend[fifo]); - } - - /* Commit BCMC sequence number in the SHM frame ID location */ - if (frameid != INVALIDFID) { - /* - * To inform the ucode of the last mcast frame posted - * so that it can clear moredata bit - */ - brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); - } - - if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) - wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); -} - -/* - * Compute PLCP, but only requires actual rate and length of pkt. - * Rate is given in the driver standard multiple of 500 kbps. - * le is set for 11 Mbps rate if necessary. - * Broken out for PRQ. - */ - -static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, - uint length, u8 *plcp) -{ - u16 usec = 0; - u8 le = 0; - - switch (rate_500) { - case BRCM_RATE_1M: - usec = length << 3; - break; - case BRCM_RATE_2M: - usec = length << 2; - break; - case BRCM_RATE_5M5: - usec = (length << 4) / 11; - if ((length << 4) - (usec * 11) > 0) - usec++; - break; - case BRCM_RATE_11M: - usec = (length << 3) / 11; - if ((length << 3) - (usec * 11) > 0) { - usec++; - if ((usec * 11) - (length << 3) >= 8) - le = D11B_PLCP_SIGNAL_LE; - } - break; - - default: - wiphy_err(wlc->wiphy, - "brcms_c_cck_plcp_set: unsupported rate %d\n", - rate_500); - rate_500 = BRCM_RATE_1M; - usec = length << 3; - break; - } - /* PLCP signal byte */ - plcp[0] = rate_500 * 5; /* r (500kbps) * 5 == r (100kbps) */ - /* PLCP service byte */ - plcp[1] = (u8) (le | D11B_PLCP_SIGNAL_LOCKED); - /* PLCP length u16, little endian */ - plcp[2] = usec & 0xff; - plcp[3] = (usec >> 8) & 0xff; - /* PLCP CRC16 */ - plcp[4] = 0; - plcp[5] = 0; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_mimo_plcp(u32 rspec, uint length, u8 *plcp) -{ - u8 mcs = (u8) (rspec & RSPEC_RATE_MASK); - plcp[0] = mcs; - if (rspec_is40mhz(rspec) || (mcs == 32)) - plcp[0] |= MIMO_PLCP_40MHZ; - BRCMS_SET_MIMO_PLCP_LEN(plcp, length); - plcp[3] = rspec_mimoplcp3(rspec); /* rspec already holds this byte */ - plcp[3] |= 0x7; /* set smoothing, not sounding ppdu & reserved */ - plcp[4] = 0; /* number of extension spatial streams bit 0 & 1 */ - plcp[5] = 0; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void -brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp) -{ - u8 rate_signal; - u32 tmp = 0; - int rate = rspec2rate(rspec); - - /* - * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb - * transmitted first - */ - rate_signal = rate_info[rate] & BRCMS_RATE_MASK; - memset(plcp, 0, D11_PHY_HDR_LEN); - D11A_PHY_HDR_SRATE((struct ofdm_phy_hdr *) plcp, rate_signal); - - tmp = (length & 0xfff) << 5; - plcp[2] |= (tmp >> 16) & 0xff; - plcp[1] |= (tmp >> 8) & 0xff; - plcp[0] |= tmp & 0xff; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, - uint length, u8 *plcp) -{ - int rate = rspec2rate(rspec); - - brcms_c_cck_plcp_set(wlc, rate, length, plcp); -} - -void -brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, - uint length, u8 *plcp) -{ - if (is_mcs_rate(rspec)) - brcms_c_compute_mimo_plcp(rspec, length, plcp); - else if (is_ofdm_rate(rspec)) - brcms_c_compute_ofdm_plcp(rspec, length, plcp); - else - brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); -} - -/* brcms_c_compute_rtscts_dur() - * - * Calculate the 802.11 MAC header DUR field for an RTS or CTS frame - * DUR for normal RTS/CTS w/ frame = 3 SIFS + 1 CTS + next frame time + 1 ACK - * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK - * - * cts cts-to-self or rts/cts - * rts_rate rts or cts rate in unit of 500kbps - * rate next MPDU rate in unit of 500kbps - * frame_len next MPDU frame length in bytes - */ -u16 -brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, - u32 rts_rate, - u32 frame_rate, u8 rts_preamble_type, - u8 frame_preamble_type, uint frame_len, bool ba) -{ - u16 dur, sifs; - - sifs = get_sifs(wlc->band); - - if (!cts_only) { - /* RTS/CTS */ - dur = 3 * sifs; - dur += - (u16) brcms_c_calc_cts_time(wlc, rts_rate, - rts_preamble_type); - } else { - /* CTS-TO-SELF */ - dur = 2 * sifs; - } - - dur += - (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, - frame_len); - if (ba) - dur += - (u16) brcms_c_calc_ba_time(wlc, frame_rate, - BRCMS_SHORT_PREAMBLE); - else - dur += - (u16) brcms_c_calc_ack_time(wlc, frame_rate, - frame_preamble_type); - return dur; -} - -u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) -{ - u16 phyctl1 = 0; - u16 bw; - - if (BRCMS_ISLCNPHY(wlc->band)) { - bw = PHY_TXC1_BW_20MHZ; - } else { - bw = rspec_get_bw(rspec); - /* 10Mhz is not supported yet */ - if (bw < PHY_TXC1_BW_20MHZ) { - wiphy_err(wlc->wiphy, "phytxctl1_calc: bw %d is " - "not supported yet, set to 20L\n", bw); - bw = PHY_TXC1_BW_20MHZ; - } - } - - if (is_mcs_rate(rspec)) { - uint mcs = rspec & RSPEC_RATE_MASK; - - /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ - phyctl1 = rspec_phytxbyte2(rspec); - /* set the upper byte of phyctl1 */ - phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 << 8); - } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) - && !BRCMS_ISSSLPNPHY(wlc->band)) { - /* - * In CCK mode LPPHY overloads OFDM Modulation bits with CCK - * Data Rate. Eventually MIMOPHY would also be converted to - * this format - */ - /* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ - phyctl1 = (bw | (rspec_stf(rspec) << PHY_TXC1_MODE_SHIFT)); - } else { /* legacy OFDM/CCK */ - s16 phycfg; - /* get the phyctl byte from rate phycfg table */ - phycfg = brcms_c_rate_legacy_phyctl(rspec2rate(rspec)); - if (phycfg == -1) { - wiphy_err(wlc->wiphy, "phytxctl1_calc: wrong " - "legacy OFDM/CCK rate\n"); - phycfg = 0; - } - /* set the upper byte of phyctl1 */ - phyctl1 = - (bw | (phycfg << 8) | - (rspec_stf(rspec) << PHY_TXC1_MODE_SHIFT)); - } - return phyctl1; -} - -u32 -brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, - bool use_rspec, u16 mimo_ctlchbw) -{ - u32 rts_rspec = 0; - - if (use_rspec) - /* use frame rate as rts rate */ - rts_rspec = rspec; - else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) - /* Use 11Mbps as the g protection RTS target rate and fallback. - * Use the brcms_basic_rate() lookup to find the best basic rate - * under the target in case 11 Mbps is not Basic. - * 6 and 9 Mbps are not usually selected by rate selection, but - * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 - * is more robust. - */ - rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M); - else - /* calculate RTS rate and fallback rate based on the frame rate - * RTS must be sent at a basic rate since it is a - * control frame, sec 9.6 of 802.11 spec - */ - rts_rspec = brcms_basic_rate(wlc, rspec); - - if (BRCMS_PHY_11N_CAP(wlc->band)) { - /* set rts txbw to correct side band */ - rts_rspec &= ~RSPEC_BW_MASK; - - /* - * if rspec/rspec_fallback is 40MHz, then send RTS on both - * 20MHz channel (DUP), otherwise send RTS on control channel - */ - if (rspec_is40mhz(rspec) && !is_cck_rate(rts_rspec)) - rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT); - else - rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT); - - /* pick siso/cdd as default for ofdm */ - if (is_ofdm_rate(rts_rspec)) { - rts_rspec &= ~RSPEC_STF_MASK; - rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); - } - } - return rts_rspec; -} - -void brcms_c_tbtt(struct brcms_c_info *wlc) -{ - if (!wlc->bsscfg->BSS) - /* - * DirFrmQ is now valid...defer setting until end - * of ATIM window - */ - wlc->qvalid |= MCMD_DIRFRMQVAL; -} - -void -brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) -{ - wlc->core->txpktpend[fifo] -= txpktpend; - BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend, - wlc->core->txpktpend[fifo]); - - /* There is more room; mark precedences related to this FIFO sendable */ - wlc->tx_prec_map |= wlc->fifo2prec_map[fifo]; - - /* figure out which bsscfg is being worked on... */ -} - -/* Update beacon listen interval in shared memory */ -void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) -{ - /* wake up every DTIM is the default */ - if (wlc->bcn_li_dtim == 1) - brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); - else - brcms_b_write_shm(wlc->hw, M_BCN_LI, - (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); -} - -static void -brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, - u32 *tsf_h_ptr) -{ - struct d11regs __iomem *regs = wlc_hw->regs; - - /* read the tsf timer low, then high to get an atomic read */ - *tsf_l_ptr = R_REG(®s->tsf_timerlow); - *tsf_h_ptr = R_REG(®s->tsf_timerhigh); -} - -/* - * recover 64bit TSF value from the 16bit TSF value in the rx header - * given the assumption that the TSF passed in header is within 65ms - * of the current tsf. - * - * 6 5 4 4 3 2 1 - * 3.......6.......8.......0.......2.......4.......6.......8......0 - * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->| - * - * The RxTSFTime are the lowest 16 bits and provided by the ucode. The - * tsf_l is filled in by brcms_b_recv, which is done earlier in the - * receive call sequence after rx interrupt. Only the higher 16 bits - * are used. Finally, the tsf_h is read from the tsf register. - */ -static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, - struct d11rxhdr *rxh) -{ - u32 tsf_h, tsf_l; - u16 rx_tsf_0_15, rx_tsf_16_31; - - brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); - - rx_tsf_16_31 = (u16)(tsf_l >> 16); - rx_tsf_0_15 = rxh->RxTSFTime; - - /* - * a greater tsf time indicates the low 16 bits of - * tsf_l wrapped, so decrement the high 16 bits. - */ - if ((u16)tsf_l < rx_tsf_0_15) { - rx_tsf_16_31 -= 1; - if (rx_tsf_16_31 == 0xffff) - tsf_h -= 1; - } - - return ((u64)tsf_h << 32) | (((u32)rx_tsf_16_31 << 16) + rx_tsf_0_15); -} - -static void -prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, - struct sk_buff *p, - struct ieee80211_rx_status *rx_status) -{ - int preamble; - int channel; - u32 rspec; - unsigned char *plcp; - - /* fill in TSF and flag its presence */ - rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); - rx_status->flag |= RX_FLAG_MACTIME_MPDU; - - channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); - - if (channel > 14) { - rx_status->band = IEEE80211_BAND_5GHZ; - rx_status->freq = ieee80211_ofdm_chan_to_freq( - WF_CHAN_FACTOR_5_G/2, channel); - - } else { - rx_status->band = IEEE80211_BAND_2GHZ; - rx_status->freq = ieee80211_dsss_chan_to_freq(channel); - } - - rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); - - /* noise */ - /* qual */ - rx_status->antenna = - (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; - - plcp = p->data; - - rspec = brcms_c_compute_rspec(rxh, plcp); - if (is_mcs_rate(rspec)) { - rx_status->rate_idx = rspec & RSPEC_RATE_MASK; - rx_status->flag |= RX_FLAG_HT; - if (rspec_is40mhz(rspec)) - rx_status->flag |= RX_FLAG_40MHZ; - } else { - switch (rspec2rate(rspec)) { - case BRCM_RATE_1M: - rx_status->rate_idx = 0; - break; - case BRCM_RATE_2M: - rx_status->rate_idx = 1; - break; - case BRCM_RATE_5M5: - rx_status->rate_idx = 2; - break; - case BRCM_RATE_11M: - rx_status->rate_idx = 3; - break; - case BRCM_RATE_6M: - rx_status->rate_idx = 4; - break; - case BRCM_RATE_9M: - rx_status->rate_idx = 5; - break; - case BRCM_RATE_12M: - rx_status->rate_idx = 6; - break; - case BRCM_RATE_18M: - rx_status->rate_idx = 7; - break; - case BRCM_RATE_24M: - rx_status->rate_idx = 8; - break; - case BRCM_RATE_36M: - rx_status->rate_idx = 9; - break; - case BRCM_RATE_48M: - rx_status->rate_idx = 10; - break; - case BRCM_RATE_54M: - rx_status->rate_idx = 11; - break; - default: - wiphy_err(wlc->wiphy, "%s: Unknown rate\n", __func__); - } - - /* - * For 5GHz, we should decrease the index as it is - * a subset of the 2.4G rates. See bitrates field - * of brcms_band_5GHz_nphy (in mac80211_if.c). - */ - if (rx_status->band == IEEE80211_BAND_5GHZ) - rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; - - /* Determine short preamble and rate_idx */ - preamble = 0; - if (is_cck_rate(rspec)) { - if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) - rx_status->flag |= RX_FLAG_SHORTPRE; - } else if (is_ofdm_rate(rspec)) { - rx_status->flag |= RX_FLAG_SHORTPRE; - } else { - wiphy_err(wlc->wiphy, "%s: Unknown modulation\n", - __func__); - } - } - - if (plcp3_issgi(plcp[3])) - rx_status->flag |= RX_FLAG_SHORT_GI; - - if (rxh->RxStatus1 & RXS_DECERR) { - rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; - wiphy_err(wlc->wiphy, "%s: RX_FLAG_FAILED_PLCP_CRC\n", - __func__); - } - if (rxh->RxStatus1 & RXS_FCSERR) { - rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; - wiphy_err(wlc->wiphy, "%s: RX_FLAG_FAILED_FCS_CRC\n", - __func__); - } -} - -static void -brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, - struct sk_buff *p) -{ - int len_mpdu; - struct ieee80211_rx_status rx_status; - - memset(&rx_status, 0, sizeof(rx_status)); - prep_mac80211_status(wlc, rxh, p, &rx_status); - - /* mac header+body length, exclude CRC and plcp header */ - len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; - skb_pull(p, D11_PHY_HDR_LEN); - __skb_trim(p, len_mpdu); - - memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status)); - ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); -} - -/* Process received frames */ -/* - * Return true if more frames need to be processed. false otherwise. - * Param 'bound' indicates max. # frames to process before break out. - */ -void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) -{ - struct d11rxhdr *rxh; - struct ieee80211_hdr *h; - uint len; - bool is_amsdu; - - BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - - /* frame starts with rxhdr */ - rxh = (struct d11rxhdr *) (p->data); - - /* strip off rxhdr */ - skb_pull(p, BRCMS_HWRXOFF); - - /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ - if (rxh->RxStatus1 & RXS_PBPRES) { - if (p->len < 2) { - wiphy_err(wlc->wiphy, "wl%d: recv: rcvd runt of " - "len %d\n", wlc->pub->unit, p->len); - goto toss; - } - skb_pull(p, 2); - } - - h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); - len = p->len; - - if (rxh->RxStatus1 & RXS_FCSERR) { - if (wlc->pub->mac80211_state & MAC80211_PROMISC_BCNS) { - wiphy_err(wlc->wiphy, "FCSERR while scanning******* -" - " tossing\n"); - goto toss; - } else { - wiphy_err(wlc->wiphy, "RCSERR!!!\n"); - goto toss; - } - } - - /* check received pkt has at least frame control field */ - if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) - goto toss; - - /* not supporting A-MSDU */ - is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; - if (is_amsdu) - goto toss; - - brcms_c_recvctl(wlc, rxh, p); - return; - - toss: - brcmu_pkt_buf_free_skb(p); -} - -/* calculate frame duration for Mixed-mode L-SIG spoofing, return - * number of bytes goes in the length field - * - * Formula given by HT PHY Spec v 1.13 - * len = 3(nsyms + nstream + 3) - 3 - */ -u16 -brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, - uint mac_len) -{ - uint nsyms, len = 0, kNdps; - - BCMMSG(wlc->wiphy, "wl%d: rate %d, len%d\n", - wlc->pub->unit, rspec2rate(ratespec), mac_len); - - if (is_mcs_rate(ratespec)) { - uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = (mcs_2_txstreams(mcs) + 1) + - rspec_stc(ratespec); - - /* - * the payload duration calculation matches that - * of regular ofdm - */ - /* 1000Ndbps = kbps * 4 */ - kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), - rspec_issgi(ratespec)) * 4; - - if (rspec_stc(ratespec) == 0) - nsyms = - CEIL((APHY_SERVICE_NBITS + 8 * mac_len + - APHY_TAIL_NBITS) * 1000, kNdps); - else - /* STBC needs to have even number of symbols */ - nsyms = - 2 * - CEIL((APHY_SERVICE_NBITS + 8 * mac_len + - APHY_TAIL_NBITS) * 1000, 2 * kNdps); - - /* (+3) account for HT-SIG(2) and HT-STF(1) */ - nsyms += (tot_streams + 3); - /* - * 3 bytes/symbol @ legacy 6Mbps rate - * (-3) excluding service bits and tail bits - */ - len = (3 * nsyms) - 3; - } - - return (u16) len; -} - -/* - * calculate frame duration of a given rate and length, return - * time in usec unit - */ -uint -brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, - u8 preamble_type, uint mac_len) -{ - uint nsyms, dur = 0, Ndps, kNdps; - uint rate = rspec2rate(ratespec); - - if (rate == 0) { - wiphy_err(wlc->wiphy, "wl%d: WAR: using rate of 1 mbps\n", - wlc->pub->unit); - rate = BRCM_RATE_1M; - } - - BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, len%d\n", - wlc->pub->unit, ratespec, preamble_type, mac_len); - - if (is_mcs_rate(ratespec)) { - uint mcs = ratespec & RSPEC_RATE_MASK; - int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); - - dur = PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); - if (preamble_type == BRCMS_MM_PREAMBLE) - dur += PREN_MM_EXT; - /* 1000Ndbps = kbps * 4 */ - kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), - rspec_issgi(ratespec)) * 4; - - if (rspec_stc(ratespec) == 0) - nsyms = - CEIL((APHY_SERVICE_NBITS + 8 * mac_len + - APHY_TAIL_NBITS) * 1000, kNdps); - else - /* STBC needs to have even number of symbols */ - nsyms = - 2 * - CEIL((APHY_SERVICE_NBITS + 8 * mac_len + - APHY_TAIL_NBITS) * 1000, 2 * kNdps); - - dur += APHY_SYMBOL_TIME * nsyms; - if (wlc->band->bandtype == BRCM_BAND_2G) - dur += DOT11_OFDM_SIGNAL_EXTENSION; - } else if (is_ofdm_rate(rate)) { - dur = APHY_PREAMBLE_TIME; - dur += APHY_SIGNAL_TIME; - /* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ - Ndps = rate * 2; - /* NSyms = CEILING((SERVICE + 8*NBytes + TAIL) / Ndbps) */ - nsyms = - CEIL((APHY_SERVICE_NBITS + 8 * mac_len + APHY_TAIL_NBITS), - Ndps); - dur += APHY_SYMBOL_TIME * nsyms; - if (wlc->band->bandtype == BRCM_BAND_2G) - dur += DOT11_OFDM_SIGNAL_EXTENSION; - } else { - /* - * calc # bits * 2 so factor of 2 in rate (1/2 mbps) - * will divide out - */ - mac_len = mac_len * 8 * 2; - /* calc ceiling of bits/rate = microseconds of air time */ - dur = (mac_len + rate - 1) / rate; - if (preamble_type & BRCMS_SHORT_PREAMBLE) - dur += BPHY_PLCP_SHORT_TIME; - else - dur += BPHY_PLCP_TIME; - } - return dur; -} - -/* derive wlc->band->basic_rate[] table from 'rateset' */ -void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, - struct brcms_c_rateset *rateset) -{ - u8 rate; - u8 mandatory; - u8 cck_basic = 0; - u8 ofdm_basic = 0; - u8 *br = wlc->band->basic_rate; - uint i; - - /* incoming rates are in 500kbps units as in 802.11 Supported Rates */ - memset(br, 0, BRCM_MAXRATE + 1); - - /* For each basic rate in the rates list, make an entry in the - * best basic lookup. - */ - for (i = 0; i < rateset->count; i++) { - /* only make an entry for a basic rate */ - if (!(rateset->rates[i] & BRCMS_RATE_FLAG)) - continue; - - /* mask off basic bit */ - rate = (rateset->rates[i] & BRCMS_RATE_MASK); - - if (rate > BRCM_MAXRATE) { - wiphy_err(wlc->wiphy, "brcms_c_rate_lookup_init: " - "invalid rate 0x%X in rate set\n", - rateset->rates[i]); - continue; - } - - br[rate] = rate; - } - - /* The rate lookup table now has non-zero entries for each - * basic rate, equal to the basic rate: br[basicN] = basicN - * - * To look up the best basic rate corresponding to any - * particular rate, code can use the basic_rate table - * like this - * - * basic_rate = wlc->band->basic_rate[tx_rate] - * - * Make sure there is a best basic rate entry for - * every rate by walking up the table from low rates - * to high, filling in holes in the lookup table - */ - - for (i = 0; i < wlc->band->hw_rateset.count; i++) { - rate = wlc->band->hw_rateset.rates[i]; - - if (br[rate] != 0) { - /* This rate is a basic rate. - * Keep track of the best basic rate so far by - * modulation type. - */ - if (is_ofdm_rate(rate)) - ofdm_basic = rate; - else - cck_basic = rate; - - continue; - } - - /* This rate is not a basic rate so figure out the - * best basic rate less than this rate and fill in - * the hole in the table - */ - - br[rate] = is_ofdm_rate(rate) ? ofdm_basic : cck_basic; - - if (br[rate] != 0) - continue; - - if (is_ofdm_rate(rate)) { - /* - * In 11g and 11a, the OFDM mandatory rates - * are 6, 12, and 24 Mbps - */ - if (rate >= BRCM_RATE_24M) - mandatory = BRCM_RATE_24M; - else if (rate >= BRCM_RATE_12M) - mandatory = BRCM_RATE_12M; - else - mandatory = BRCM_RATE_6M; - } else { - /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ - mandatory = rate; - } - - br[rate] = mandatory; - } -} - -static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, - u8 basic_rate) -{ - u8 phy_rate, index; - u8 basic_phy_rate, basic_index; - u16 dir_table, basic_table; - u16 basic_ptr; - - /* Shared memory address for the table we are reading */ - dir_table = is_ofdm_rate(basic_rate) ? M_RT_DIRMAP_A : M_RT_DIRMAP_B; - - /* Shared memory address for the table we are writing */ - basic_table = is_ofdm_rate(rate) ? M_RT_BBRSMAP_A : M_RT_BBRSMAP_B; - - /* - * for a given rate, the LS-nibble of the PLCP SIGNAL field is - * the index into the rate table. - */ - phy_rate = rate_info[rate] & BRCMS_RATE_MASK; - basic_phy_rate = rate_info[basic_rate] & BRCMS_RATE_MASK; - index = phy_rate & 0xf; - basic_index = basic_phy_rate & 0xf; - - /* Find the SHM pointer to the ACK rate entry by looking in the - * Direct-map Table - */ - basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); - - /* Update the SHM BSS-basic-rate-set mapping table with the pointer - * to the correct basic rate for the given incoming rate - */ - brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); -} - -static const struct brcms_c_rateset * -brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) -{ - const struct brcms_c_rateset *rs_dflt; - - if (BRCMS_PHY_11N_CAP(wlc->band)) { - if (wlc->band->bandtype == BRCM_BAND_5G) - rs_dflt = &ofdm_mimo_rates; - else - rs_dflt = &cck_ofdm_mimo_rates; - } else if (wlc->band->gmode) - rs_dflt = &cck_ofdm_rates; - else - rs_dflt = &cck_rates; - - return rs_dflt; -} - -void brcms_c_set_ratetable(struct brcms_c_info *wlc) -{ - const struct brcms_c_rateset *rs_dflt; - struct brcms_c_rateset rs; - u8 rate, basic_rate; - uint i; - - rs_dflt = brcms_c_rateset_get_hwrs(wlc); - - brcms_c_rateset_copy(rs_dflt, &rs); - brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); - - /* walk the phy rate table and update SHM basic rate lookup table */ - for (i = 0; i < rs.count; i++) { - rate = rs.rates[i] & BRCMS_RATE_MASK; - - /* for a given rate brcms_basic_rate returns the rate at - * which a response ACK/CTS should be sent. - */ - basic_rate = brcms_basic_rate(wlc, rate); - if (basic_rate == 0) - /* This should only happen if we are using a - * restricted rateset. - */ - basic_rate = rs.rates[0] & BRCMS_RATE_MASK; - - brcms_c_write_rate_shm(wlc, rate, basic_rate); - } -} - -/* - * Return true if the specified rate is supported by the specified band. - * BRCM_BAND_AUTO indicates the current band. - */ -bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, - bool verbose) -{ - struct brcms_c_rateset *hw_rateset; - uint i; - - if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) - hw_rateset = &wlc->band->hw_rateset; - else if (wlc->pub->_nbands > 1) - hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; - else - /* other band specified and we are a single band device */ - return false; - - /* check if this is a mimo rate */ - if (is_mcs_rate(rspec)) { - if ((rspec & RSPEC_RATE_MASK) >= MCS_TABLE_SIZE) - goto error; - - return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); - } - - for (i = 0; i < hw_rateset->count; i++) - if (hw_rateset->rates[i] == rspec2rate(rspec)) - return true; - error: - if (verbose) - wiphy_err(wlc->wiphy, "wl%d: valid_rate: rate spec 0x%x " - "not in hw_rateset\n", wlc->pub->unit, rspec); - - return false; -} - -void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) -{ - const struct brcms_c_rateset *rs_dflt; - struct brcms_c_rateset rs; - u8 rate; - u16 entry_ptr; - u8 plcp[D11_PHY_HDR_LEN]; - u16 dur, sifs; - uint i; - - sifs = get_sifs(wlc->band); - - rs_dflt = brcms_c_rateset_get_hwrs(wlc); - - brcms_c_rateset_copy(rs_dflt, &rs); - brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); - - /* - * walk the phy rate table and update MAC core SHM - * basic rate table entries - */ - for (i = 0; i < rs.count; i++) { - rate = rs.rates[i] & BRCMS_RATE_MASK; - - entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); - - /* Calculate the Probe Response PLCP for the given rate */ - brcms_c_compute_plcp(wlc, rate, frame_len, plcp); - - /* - * Calculate the duration of the Probe Response - * frame plus SIFS for the MAC - */ - dur = (u16) brcms_c_calc_frame_time(wlc, rate, - BRCMS_LONG_PREAMBLE, frame_len); - dur += sifs; - - /* Update the SHM Rate Table entry Probe Response values */ - brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, - (u16) (plcp[0] + (plcp[1] << 8))); - brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, - (u16) (plcp[2] + (plcp[3] << 8))); - brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); - } -} - -/* Max buffering needed for beacon template/prb resp template is 142 bytes. - * - * PLCP header is 6 bytes. - * 802.11 A3 header is 24 bytes. - * Max beacon frame body template length is 112 bytes. - * Max probe resp frame body template length is 110 bytes. - * - * *len on input contains the max length of the packet available. - * - * The *len value is set to the number of bytes in buf used, and starts - * with the PLCP and included up to, but not including, the 4 byte FCS. - */ -static void -brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type, - u32 bcn_rspec, - struct brcms_bss_cfg *cfg, u16 *buf, int *len) -{ - static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; - struct cck_phy_hdr *plcp; - struct ieee80211_mgmt *h; - int hdr_len, body_len; - - hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN; - - /* calc buffer size provided for frame body */ - body_len = *len - hdr_len; - /* return actual size */ - *len = hdr_len + body_len; - - /* format PHY and MAC headers */ - memset((char *)buf, 0, hdr_len); - - plcp = (struct cck_phy_hdr *) buf; - - /* - * PLCP for Probe Response frames are filled in from - * core's rate table - */ - if (type == IEEE80211_STYPE_BEACON) - /* fill in PLCP */ - brcms_c_compute_plcp(wlc, bcn_rspec, - (DOT11_MAC_HDR_LEN + body_len + FCS_LEN), - (u8 *) plcp); - - /* "Regular" and 16 MBSS but not for 4 MBSS */ - /* Update the phytxctl for the beacon based on the rspec */ - brcms_c_beacon_phytxctl_txant_upd(wlc, bcn_rspec); - - h = (struct ieee80211_mgmt *)&plcp[1]; - - /* fill in 802.11 header */ - h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type); - - /* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */ - /* A1 filled in by MAC for prb resp, broadcast for bcn */ - if (type == IEEE80211_STYPE_BEACON) - memcpy(&h->da, ðer_bcast, ETH_ALEN); - memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN); - memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN); - - /* SEQ filled in by MAC */ -} - -int brcms_c_get_header_len(void) -{ - return TXOFF; -} - -/* - * Update all beacons for the system. - */ -void brcms_c_update_beacon(struct brcms_c_info *wlc) -{ - struct brcms_bss_cfg *bsscfg = wlc->bsscfg; - - if (bsscfg->up && !bsscfg->BSS) - /* Clear the soft intmask */ - wlc->defmacintmask &= ~MI_BCNTPL; -} - -/* Write ssid into shared memory */ -void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) -{ - u8 *ssidptr = cfg->SSID; - u16 base = M_SSID; - u8 ssidbuf[IEEE80211_MAX_SSID_LEN]; - - /* padding the ssid with zero and copy it into shm */ - memset(ssidbuf, 0, IEEE80211_MAX_SSID_LEN); - memcpy(ssidbuf, ssidptr, cfg->SSID_len); - - brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); - brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); -} - -void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) -{ - struct brcms_bss_cfg *bsscfg = wlc->bsscfg; - - /* update AP or IBSS probe responses */ - if (bsscfg->up && !bsscfg->BSS) - brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); -} - -void -brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, - struct brcms_bss_cfg *cfg, - bool suspend) -{ - u16 prb_resp[BCN_TMPL_LEN / 2]; - int len = BCN_TMPL_LEN; - - /* - * write the probe response to hardware, or save in - * the config structure - */ - - /* create the probe response template */ - brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, - cfg, prb_resp, &len); - - if (suspend) - brcms_c_suspend_mac_and_wait(wlc); - - /* write the probe response into the template region */ - brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, - (len + 3) & ~3, prb_resp); - - /* write the length of the probe response frame (+PLCP/-FCS) */ - brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); - - /* write the SSID and SSID length */ - brcms_c_shm_ssid_upd(wlc, cfg); - - /* - * Write PLCP headers and durations for probe response frames - * at all rates. Use the actual frame length covered by the - * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table() - * by subtracting the PLCP len and adding the FCS. - */ - len += (-D11_PHY_HDR_LEN + FCS_LEN); - brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len); - - if (suspend) - brcms_c_enable_mac(wlc); -} - -/* prepares pdu for transmission. returns BCM error codes */ -int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) -{ - uint fifo; - struct d11txh *txh; - struct ieee80211_hdr *h; - struct scb *scb; - - txh = (struct d11txh *) (pdu->data); - h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - - /* get the pkt queue info. This was put at brcms_c_sendctl or - * brcms_c_send for PDU */ - fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK; - - scb = NULL; - - *fifop = fifo; - - /* return if insufficient dma resources */ - if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) { - /* Mark precedences related to this FIFO, unsendable */ - /* A fifo is full. Clear precedences related to that FIFO */ - wlc->tx_prec_map &= ~(wlc->fifo2prec_map[fifo]); - return -EBUSY; - } - return 0; -} - -void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) -{ - brcms_c_rateset_default(rs, NULL, wlc->band->phytype, - wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, - (bool) (wlc->pub->_n_enab & SUPPORT_11N), - brcms_chspec_bw(wlc->default_bss->chanspec), - wlc->stf->txstreams); -} - -/* Copy a buffer to shared memory. - * SHM 'offset' needs to be an even address and - * Buffer length 'len' must be an even number of bytes - */ -void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, const void *buf, - int len) -{ - brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); -} - -int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks) -{ - if (fifo >= NFIFO) - return -EINVAL; - - *blocks = wlc_hw->xmtfifo_sz[fifo]; - - return 0; -} - -void -brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, - const u8 *addr) -{ - brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); - if (match_reg_offset == RCM_BSSID_OFFSET) - memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); -} - -/* check for the particular priority flow control bit being set */ -bool -brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc, - struct brcms_txq_info *q, - int prio) -{ - uint prio_mask; - - if (prio == ALLPRIO) - prio_mask = TXQ_STOP_FOR_PRIOFC_MASK; - else - prio_mask = NBITVAL(prio); - - return (q->stopped & prio_mask) == prio_mask; -} - -/* propagate the flow control to all interfaces using the given tx queue */ -void brcms_c_txflowcontrol(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - bool on, int prio) -{ - uint prio_bits; - uint cur_bits; - - BCMMSG(wlc->wiphy, "flow control kicks in\n"); - - if (prio == ALLPRIO) - prio_bits = TXQ_STOP_FOR_PRIOFC_MASK; - else - prio_bits = NBITVAL(prio); - - cur_bits = qi->stopped & prio_bits; - - /* Check for the case of no change and return early - * Otherwise update the bit and continue - */ - if (on) { - if (cur_bits == prio_bits) - return; - - mboolset(qi->stopped, prio_bits); - } else { - if (cur_bits == 0) - return; - - mboolclr(qi->stopped, prio_bits); - } - - /* If there is a flow control override we will not change the external - * flow control state. - */ - if (qi->stopped & ~TXQ_STOP_FOR_PRIOFC_MASK) - return; - - brcms_c_txflowcontrol_signal(wlc, qi, on, prio); -} - -void -brcms_c_txflowcontrol_override(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - bool on, uint override) -{ - uint prev_override; - - prev_override = (qi->stopped & ~TXQ_STOP_FOR_PRIOFC_MASK); - - /* Update the flow control bits and do an early return if there is - * no change in the external flow control state. - */ - if (on) { - mboolset(qi->stopped, override); - /* if there was a previous override bit on, then setting this - * makes no difference. - */ - if (prev_override) - return; - - brcms_c_txflowcontrol_signal(wlc, qi, ON, ALLPRIO); - } else { - mboolclr(qi->stopped, override); - /* clearing an override bit will only make a difference for - * flow control if it was the only bit set. For any other - * override setting, just return - */ - if (prev_override != override) - return; - - if (qi->stopped == 0) { - brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO); - } else { - int prio; - - for (prio = MAXPRIO; prio >= 0; prio--) { - if (!mboolisset(qi->stopped, NBITVAL(prio))) - brcms_c_txflowcontrol_signal( - wlc, qi, OFF, prio); - } - } - } -} - -/* - * Flag 'scan in progress' to withhold dynamic phy calibration - */ -void brcms_c_scan_start(struct brcms_c_info *wlc) -{ - wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); -} - -void brcms_c_scan_stop(struct brcms_c_info *wlc) -{ - wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); -} - -void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state) -{ - wlc->pub->associated = state; - wlc->bsscfg->associated = state; -} - -/* - * When a remote STA/AP is removed by Mac80211, or when it can no longer accept - * AMPDU traffic, packets pending in hardware have to be invalidated so that - * when later on hardware releases them, they can be handled appropriately. - */ -void brcms_c_inval_dma_pkts(struct brcms_hardware *hw, - struct ieee80211_sta *sta, - void (*dma_callback_fn)) -{ - struct dma_pub *dmah; - int i; - for (i = 0; i < NFIFO; i++) { - dmah = hw->di[i]; - if (dmah != NULL) - dma_walk_packets(dmah, dma_callback_fn, sta); - } -} - -int brcms_c_get_curband(struct brcms_c_info *wlc) -{ - return wlc->band->bandunit; -} - -void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) -{ - /* flush packet queue when requested */ - if (drop) - brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL); - - /* wait for queue and DMA fifos to run dry */ - while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) - brcms_msleep(wlc->wl, 1); -} - -void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) -{ - wlc->bcn_li_bcn = interval; - if (wlc->pub->up) - brcms_c_bcn_li_upd(wlc); -} - -int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr) -{ - uint qdbm; - - /* Remove override bit and clip to max qdbm value */ - qdbm = min_t(uint, txpwr * BRCMS_TXPWR_DB_FACTOR, 0xff); - return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); -} - -int brcms_c_get_tx_power(struct brcms_c_info *wlc) -{ - uint qdbm; - bool override; - - wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); - - /* Return qdbm units */ - return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); -} - -void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) -{ - wlc->mpc = mpc; - brcms_c_radio_mpc_upd(wlc); -} diff --git a/drivers/staging/brcm80211/brcmsmac/main.h b/drivers/staging/brcm80211/brcmsmac/main.h deleted file mode 100644 index 7a2554f611a..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/main.h +++ /dev/null @@ -1,819 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_MAIN_H_ -#define _BRCM_MAIN_H_ - -#include - -#include -#include "types.h" -#include "d11.h" -#include "scb.h" - -#define INVCHANNEL 255 /* invalid channel */ - -/* max # brcms_c_module_register() calls */ -#define BRCMS_MAXMODULES 22 - -#define SEQNUM_SHIFT 4 -#define SEQNUM_MAX 0x1000 - -#define NTXRATE 64 /* # tx MPDUs rate is reported for */ - -/* Maximum wait time for a MAC suspend */ -/* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */ -#define BRCMS_MAX_MAC_SUSPEND 83000 - -/* responses for probe requests older that this are tossed, zero to disable */ -#define BRCMS_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */ - -/* transmit buffer max headroom for protocol headers */ -#define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) - -#define AC_COUNT 4 - -/* Macros for doing definition and get/set of bitfields - * Usage example, e.g. a three-bit field (bits 4-6): - * #define _M BITFIELD_MASK(3) - * #define _S 4 - * ... - * regval = R_REG(osh, ®s->regfoo); - * field = GFIELD(regval, ); - * regval = SFIELD(regval, , 1); - * W_REG(osh, ®s->regfoo, regval); - */ -#define BITFIELD_MASK(width) \ - (((unsigned)1 << (width)) - 1) -#define GFIELD(val, field) \ - (((val) >> field ## _S) & field ## _M) -#define SFIELD(val, field, bits) \ - (((val) & (~(field ## _M << field ## _S))) | \ - ((unsigned)(bits) << field ## _S)) - -#define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */ - -/* max # supported core revisions (0 .. MAXCOREREV - 1) */ -#define MAXCOREREV 28 - -/* Double check that unsupported cores are not enabled */ -#if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV) -#error "Configuration for D11CONF includes unsupported versions." -#endif /* Bad versions */ - -/* values for shortslot_override */ -#define BRCMS_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */ -#define BRCMS_SHORTSLOT_OFF 0 /* Turn off short slot */ -#define BRCMS_SHORTSLOT_ON 1 /* Turn on short slot */ - -/* value for short/long and mixmode/greenfield preamble */ -#define BRCMS_LONG_PREAMBLE (0) -#define BRCMS_SHORT_PREAMBLE (1 << 0) -#define BRCMS_GF_PREAMBLE (1 << 1) -#define BRCMS_MM_PREAMBLE (1 << 2) -#define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \ - ((_pre) == BRCMS_MM_PREAMBLE)) - -/* TxFrameID */ -/* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */ -/* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */ -#define TXFID_QUEUE_MASK 0x0007 /* Bits 0-2 */ -#define TXFID_SEQ_MASK 0x7FE0 /* Bits 5-15 */ -#define TXFID_SEQ_SHIFT 5 /* Number of bit shifts */ -#define TXFID_RATE_PROBE_MASK 0x8000 /* Bit 15 for rate probe */ -#define TXFID_RATE_MASK 0x0018 /* Mask for bits 3 and 4 */ -#define TXFID_RATE_SHIFT 3 /* Shift 3 bits for rate mask */ - -/* promote boardrev */ -#define BOARDREV_PROMOTABLE 0xFF /* from */ -#define BOARDREV_PROMOTED 1 /* to */ - -#define DATA_BLOCK_TX_SUPR (1 << 4) - -/* 802.1D Priority to TX FIFO number for wme */ -extern const u8 prio2fifo[]; - -/* Ucode MCTL_WAKE override bits */ -#define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01 -#define BRCMS_WAKE_OVERRIDE_PHYREG 0x02 -#define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04 -#define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08 -#define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10 - -/* stuff pulled in from wlc.c */ - -/* Interrupt bit error summary. Don't include I_RU: we refill DMA at other - * times; and if we run out, constant I_RU interrupts may cause lockup. We - * will still get error counts from rx0ovfl. - */ -#define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU) -/* default software intmasks */ -#define DEF_RXINTMASK (I_RI) /* enable rx int on rxfifo only */ -#define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \ - MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \ - MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP) - -#define MAXTXPKTS 6 /* max # pkts pending */ - -/* frameburst */ -#define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */ -#define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */ - -#define NFIFO 6 /* # tx/rx fifopairs */ - -/* PLL requests */ - -/* pll is shared on old chips */ -#define BRCMS_PLLREQ_SHARED 0x1 -/* hold pll for radio monitor register checking */ -#define BRCMS_PLLREQ_RADIO_MON 0x2 -/* hold/release pll for some short operation */ -#define BRCMS_PLLREQ_FLIP 0x4 - -#define CHANNEL_BANDUNIT(wlc, ch) \ - (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX) - -#define OTHERBANDUNIT(wlc) \ - ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX)) - -/* - * 802.11 protection information - * - * _g: use g spec protection, driver internal. - * g_override: override for use of g spec protection. - * gmode_user: user config gmode, operating band->gmode is different. - * overlap: Overlap BSS/IBSS protection for both 11g and 11n. - * nmode_user: user config nmode, operating pub->nmode is different. - * n_cfg: use OFDM protection on MIMO frames. - * n_cfg_override: override for use of N protection. - * nongf: non-GF present protection. - * nongf_override: override for use of GF protection. - * n_pam_override: override for preamble: MM or GF. - * n_obss: indicated OBSS Non-HT STA present. -*/ -struct brcms_protection { - bool _g; - s8 g_override; - u8 gmode_user; - s8 overlap; - s8 nmode_user; - s8 n_cfg; - s8 n_cfg_override; - bool nongf; - s8 nongf_override; - s8 n_pam_override; - bool n_obss; -}; - -/* - * anything affecting the single/dual streams/antenna operation - * - * hw_txchain: HW txchain bitmap cfg. - * txchain: txchain bitmap being used. - * txstreams: number of txchains being used. - * hw_rxchain: HW rxchain bitmap cfg. - * rxchain: rxchain bitmap being used. - * rxstreams: number of rxchains being used. - * ant_rx_ovr: rx antenna override. - * txant: userTx antenna setting. - * phytxant: phyTx antenna setting in txheader. - * ss_opmode: singlestream Operational mode, 0:siso; 1:cdd. - * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel; - * else use wlc->band->stf->ss_mode_band. - * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC. - * rxchain_restore_delay: delay time to restore default rxchain. - * ldpc: AUTO/ON/OFF ldpc cap supported. - * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts. - * spatial_policy: - */ -struct brcms_stf { - u8 hw_txchain; - u8 txchain; - u8 txstreams; - u8 hw_rxchain; - u8 rxchain; - u8 rxstreams; - u8 ant_rx_ovr; - s8 txant; - u16 phytxant; - u8 ss_opmode; - bool ss_algosel_auto; - u16 ss_algo_channel; - u8 rxchain_restore_delay; - s8 ldpc; - u8 txcore[MAX_STREAMS_SUPPORTED + 1]; - s8 spatial_policy; -}; - -#define BRCMS_STF_SS_STBC_TX(wlc, scb) \ - (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \ - || (((scb)->flags & SCB_STBCCAP) && \ - (wlc)->band->band_stf_stbc_tx == AUTO && \ - isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC)))) - -#define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \ - NREV_GE(wlc->band->phyrev, 3)) - -#define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \ - NREV_GE(wlc->band->phyrev, 3)) || \ - BRCMS_ISLCNPHY(wlc->band)) - -#define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \ - >> RXS_CHAN_PHYTYPE_SHIFT) -#define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \ - >> RXS_CHAN_ID_SHIFT) - -/* - * core state (mac) - */ -struct brcms_core { - uint coreidx; /* # sb enumerated core */ - - /* fifo */ - uint *txavail[NFIFO]; /* # tx descriptors available */ - s16 txpktpend[NFIFO]; /* tx admission control */ - - struct macstat *macstat_snapshot; /* mac hw prev read values */ -}; - -/* - * band state (phy+ana+radio) - */ -struct brcms_band { - int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */ - uint bandunit; /* bandstate[] index */ - - u16 phytype; /* phytype */ - u16 phyrev; - u16 radioid; - u16 radiorev; - struct brcms_phy_pub *pi; /* pointer to phy specific information */ - bool abgphy_encore; - - u8 gmode; /* currently active gmode */ - - struct scb *hwrs_scb; /* permanent scb for hw rateset */ - - /* band-specific copy of default_bss.rateset */ - struct brcms_c_rateset defrateset; - - u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */ - s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */ - /* rates supported by chip (phy-specific) */ - struct brcms_c_rateset hw_rateset; - u8 basic_rate[BRCM_MAXRATE + 1]; /* basic rates indexed by rate */ - bool mimo_cap_40; /* 40 MHz cap enabled on this band */ - s8 antgain; /* antenna gain from srom */ - - u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */ - u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */ - struct ieee80211_supported_band band; -}; - -/* module control blocks */ -struct modulecb { - /* module name : NULL indicates empty array member */ - char name[32]; - /* handle passed when handler 'doiovar' is called */ - struct brcms_info *hdl; - - int (*down_fn)(void *handle); /* down handler. Note: the int returned - * by the down function is a count of the - * number of timers that could not be - * freed. - */ - -}; - -struct brcms_hw_band { - int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */ - uint bandunit; /* bandstate[] index */ - u16 mhfs[MHFMAX]; /* MHF array shadow */ - u8 bandhw_stf_ss_mode; /* HW configured STF type, 0:siso; 1:cdd */ - u16 CWmin; - u16 CWmax; - u32 core_flags; - - u16 phytype; /* phytype */ - u16 phyrev; - u16 radioid; - u16 radiorev; - struct brcms_phy_pub *pi; /* pointer to phy specific information */ - bool abgphy_encore; -}; - -struct brcms_hardware { - bool _piomode; /* true if pio mode */ - struct brcms_c_info *wlc; - - /* fifo */ - struct dma_pub *di[NFIFO]; /* dma handles, per fifo */ - - uint unit; /* device instance number */ - - /* version info */ - u16 vendorid; /* PCI vendor id */ - u16 deviceid; /* PCI device id */ - uint corerev; /* core revision */ - u8 sromrev; /* version # of the srom */ - u16 boardrev; /* version # of particular board */ - u32 boardflags; /* Board specific flags from srom */ - u32 boardflags2; /* More board flags if sromrev >= 4 */ - u32 machwcap; /* MAC capabilities */ - u32 machwcap_backup; /* backup of machwcap */ - - struct si_pub *sih; /* SI handle (cookie for siutils calls) */ - struct d11regs __iomem *regs; /* pointer to device registers */ - struct phy_shim_info *physhim; /* phy shim layer handler */ - struct shared_phy *phy_sh; /* pointer to shared phy state */ - struct brcms_hw_band *band;/* pointer to active per-band state */ - /* band state per phy/radio */ - struct brcms_hw_band *bandstate[MAXBANDS]; - u16 bmac_phytxant; /* cache of high phytxant state */ - bool shortslot; /* currently using 11g ShortSlot timing */ - u16 SRL; /* 802.11 dot11ShortRetryLimit */ - u16 LRL; /* 802.11 dot11LongRetryLimit */ - u16 SFBL; /* Short Frame Rate Fallback Limit */ - u16 LFBL; /* Long Frame Rate Fallback Limit */ - - bool up; /* d11 hardware up and running */ - uint now; /* # elapsed seconds */ - uint _nbands; /* # bands supported */ - u16 chanspec; /* bmac chanspec shadow */ - - uint *txavail[NFIFO]; /* # tx descriptors available */ - const u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */ - - u32 pllreq; /* pll requests to keep PLL on */ - - u8 suspended_fifos; /* Which TX fifo to remain awake for */ - u32 maccontrol; /* Cached value of maccontrol */ - uint mac_suspend_depth; /* current depth of mac_suspend levels */ - u32 wake_override; /* bit flags to force MAC to WAKE mode */ - u32 mute_override; /* Prevent ucode from sending beacons */ - u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */ - bool noreset; /* true= do not reset hw, used by WLC_OUT */ - bool forcefastclk; /* true if h/w is forcing to use fast clk */ - bool clk; /* core is out of reset and has clock */ - bool sbclk; /* sb has clock */ - bool phyclk; /* phy is out of reset and has clock */ - - bool ucode_loaded; /* true after ucode downloaded */ - - - u8 hw_stf_ss_opmode; /* STF single stream operation mode */ - u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic - * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board - */ - u32 antsel_avail; /* - * put struct antsel_info here if more info is - * needed - */ -}; - -/* TX Queue information - * - * Each flow of traffic out of the device has a TX Queue with independent - * flow control. Several interfaces may be associated with a single TX Queue - * if they belong to the same flow of traffic from the device. For multi-channel - * operation there are independent TX Queues for each channel. - */ -struct brcms_txq_info { - struct brcms_txq_info *next; - struct pktq q; - uint stopped; /* tx flow control bits */ -}; - -/* - * Principal common driver data structure. - * - * pub: pointer to driver public state. - * wl: pointer to specific private state. - * regs: pointer to device registers. - * hw: HW related state. - * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1. - * fastpwrup_dly: time in us needed to bring up d11 fast clock. - * macintstatus: bit channel between isr and dpc. - * macintmask: sw runtime master macintmask value. - * defmacintmask: default "on" macintmask value. - * clk: core is out of reset and has clock. - * core: pointer to active io core. - * band: pointer to active per-band state. - * corestate: per-core state (one per hw core). - * bandstate: per-band state (one per phy/radio). - * qvalid: DirFrmQValid and BcMcFrmQValid. - * ampdu: ampdu module handler. - * asi: antsel module handler. - * cmi: channel manager module handler. - * vendorid: PCI vendor id. - * deviceid: PCI device id. - * ucode_rev: microcode revision. - * machwcap: MAC capabilities, BMAC shadow. - * perm_etheraddr: original sprom local ethernet address. - * bandlocked: disable auto multi-band switching. - * bandinit_pending: track band init in auto band. - * radio_monitor: radio timer is running. - * going_down: down path intermediate variable. - * mpc: enable minimum power consumption. - * mpc_dlycnt: # of watchdog cnt before turn disable radio. - * mpc_offcnt: # of watchdog cnt that radio is disabled. - * mpc_delay_off: delay radio disable by # of watchdog cnt. - * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc. - * wdtimer: timer for watchdog routine. - * radio_timer: timer for hw radio button monitor routine. - * monitor: monitor (MPDU sniffing) mode. - * bcnmisc_monitor: bcns promisc mode override for monitor. - * _rifs: enable per-packet rifs. - * bcn_li_bcn: beacon listen interval in # beacons. - * bcn_li_dtim: beacon listen interval in # dtims. - * WDarmed: watchdog timer is armed. - * WDlast: last time wlc_watchdog() was called. - * edcf_txop[AC_COUNT]: current txop for each ac. - * wme_retries: per-AC retry limits. - * tx_prec_map: Precedence map based on HW FIFO space. - * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. - * bsscfg: set of BSS configurations, idx 0 is default and always valid. - * cfg: the primary bsscfg (can be AP or STA). - * tx_queues: common TX Queue list. - * modulecb: - * mimoft: SIGN or 11N. - * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode. - * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode. - * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode. - * default_bss: configured BSS parameters. - * mc_fid_counter: BC/MC FIFO frame ID counter. - * country_default: saved country for leaving 802.11d auto-country mode. - * autocountry_default: initial country for 802.11d auto-country mode. - * prb_resp_timeout: do not send prb resp if request older - * than this, 0 = disable. - * home_chanspec: shared home chanspec. - * chanspec: target operational channel. - * usr_fragthresh: user configured fragmentation threshold. - * fragthresh[NFIFO]: per-fifo fragmentation thresholds. - * RTSThresh: 802.11 dot11RTSThreshold. - * SRL: 802.11 dot11ShortRetryLimit. - * LRL: 802.11 dot11LongRetryLimit. - * SFBL: Short Frame Rate Fallback Limit. - * LFBL: Long Frame Rate Fallback Limit. - * shortslot: currently using 11g ShortSlot timing. - * shortslot_override: 11g ShortSlot override. - * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42. - * PLCPHdr_override: 802.11b Preamble Type override. - * stf: - * bcn_rspec: save bcn ratespec purpose. - * tempsense_lasttime; - * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM. - * tx_duty_cycle_cck: maximum allowed duty cycle for CCK. - * pkt_queue: txq for transmit packets. - * wiphy: - * pri_scb: primary Station Control Block - */ -struct brcms_c_info { - struct brcms_pub *pub; - struct brcms_info *wl; - struct d11regs __iomem *regs; - struct brcms_hardware *hw; - - /* clock */ - u16 fastpwrup_dly; - - /* interrupt */ - u32 macintstatus; - u32 macintmask; - u32 defmacintmask; - - bool clk; - - /* multiband */ - struct brcms_core *core; - struct brcms_band *band; - struct brcms_core *corestate; - struct brcms_band *bandstate[MAXBANDS]; - - /* packet queue */ - uint qvalid; - - struct ampdu_info *ampdu; - struct antsel_info *asi; - struct brcms_cm_info *cmi; - - u16 vendorid; - u16 deviceid; - uint ucode_rev; - - u8 perm_etheraddr[ETH_ALEN]; - - bool bandlocked; - bool bandinit_pending; - - bool radio_monitor; - bool going_down; - - bool mpc; - u8 mpc_dlycnt; - u8 mpc_offcnt; - u8 mpc_delay_off; - u8 prev_non_delay_mpc; - - struct brcms_timer *wdtimer; - struct brcms_timer *radio_timer; - - /* promiscuous */ - bool monitor; - bool bcnmisc_monitor; - - /* driver feature */ - bool _rifs; - - /* AP-STA synchronization, power save */ - u8 bcn_li_bcn; - u8 bcn_li_dtim; - - bool WDarmed; - u32 WDlast; - - /* WME */ - u16 edcf_txop[AC_COUNT]; - - u16 wme_retries[AC_COUNT]; - u16 tx_prec_map; - u16 fifo2prec_map[NFIFO]; - - struct brcms_bss_cfg *bsscfg; - - /* tx queue */ - struct brcms_txq_info *tx_queues; - - struct modulecb *modulecb; - - u8 mimoft; - s8 cck_40txbw; - s8 ofdm_40txbw; - s8 mimo_40txbw; - - struct brcms_bss_info *default_bss; - - u16 mc_fid_counter; - - char country_default[BRCM_CNTRY_BUF_SZ]; - char autocountry_default[BRCM_CNTRY_BUF_SZ]; - u16 prb_resp_timeout; - - u16 home_chanspec; - - /* PHY parameters */ - u16 chanspec; - u16 usr_fragthresh; - u16 fragthresh[NFIFO]; - u16 RTSThresh; - u16 SRL; - u16 LRL; - u16 SFBL; - u16 LFBL; - - /* network config */ - bool shortslot; - s8 shortslot_override; - bool include_legacy_erp; - - struct brcms_protection *protection; - s8 PLCPHdr_override; - - struct brcms_stf *stf; - - u32 bcn_rspec; - - uint tempsense_lasttime; - - u16 tx_duty_cycle_ofdm; - u16 tx_duty_cycle_cck; - - struct brcms_txq_info *pkt_queue; - struct wiphy *wiphy; - struct scb pri_scb; -}; - -/* antsel module specific state */ -struct antsel_info { - struct brcms_c_info *wlc; /* pointer to main wlc structure */ - struct brcms_pub *pub; /* pointer to public fn */ - u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic - * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board - */ - u8 antsel_antswitch; /* board level antenna switch type */ - bool antsel_avail; /* Ant selection availability (SROM based) */ - struct brcms_antselcfg antcfg_11n; /* antenna configuration */ - struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */ -}; - -/* - * BSS configuration state - * - * wlc: wlc to which this bsscfg belongs to. - * up: is this configuration up operational - * enable: is this configuration enabled - * associated: is BSS in ASSOCIATED state - * BSS: infraustructure or adhoc - * SSID_len: the length of SSID - * SSID: SSID string - * - * - * BSSID: BSSID (associated) - * cur_etheraddr: h/w address - * flags: BSSCFG flags; see below - * - * current_bss: BSS parms in ASSOCIATED state - * - * - * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation - */ -struct brcms_bss_cfg { - struct brcms_c_info *wlc; - bool up; - bool enable; - bool associated; - bool BSS; - u8 SSID_len; - u8 SSID[IEEE80211_MAX_SSID_LEN]; - u8 BSSID[ETH_ALEN]; - u8 cur_etheraddr[ETH_ALEN]; - struct brcms_bss_info *current_bss; -}; - -extern void brcms_c_fatal_error(struct brcms_c_info *wlc); -extern void brcms_b_rpc_watchdog(struct brcms_c_info *wlc); -extern void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p); -extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, - struct sk_buff *p, - bool commit, s8 txpktpend); -extern void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, - s8 txpktpend); -extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb, - struct sk_buff *sdu, uint prec); -extern void brcms_c_info_init(struct brcms_c_info *wlc, int unit); -extern void brcms_c_print_txstatus(struct tx_status *txs); -extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, - uint *blocks); - -#if defined(BCMDBG) -extern void brcms_c_print_rxh(struct d11rxhdr *rxh); -extern void brcms_c_print_txdesc(struct d11txh *txh); -#else -#define brcms_c_print_txdesc(a) -#endif - -extern void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit); -extern void brcms_c_coredisable(struct brcms_hardware *wlc_hw); - -extern bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rate, - int band, bool verbose); -extern void brcms_c_ap_upd(struct brcms_c_info *wlc); - -/* helper functions */ -extern void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, - struct brcms_bss_cfg *cfg); -extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config); - -extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, - bool promisc); -extern void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc); -extern void brcms_c_mac_promisc(struct brcms_c_info *wlc); -extern void brcms_c_txflowcontrol(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - bool on, int prio); -extern void brcms_c_txflowcontrol_override(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - bool on, uint override); -extern bool brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc, - struct brcms_txq_info *qi, - int prio); -extern void brcms_c_send_q(struct brcms_c_info *wlc); -extern int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, - uint *fifo); - -extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, - uint mac_len); -extern u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, - u32 rspec, - bool use_rspec, u16 mimo_ctlchbw); -extern u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, - u32 rts_rate, - u32 frame_rate, - u8 rts_preamble_type, - u8 frame_preamble_type, uint frame_len, - bool ba); - -extern void brcms_c_tbtt(struct brcms_c_info *wlc); -extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw, - struct ieee80211_sta *sta, - void (*dma_callback_fn)); - -/* Shared memory access */ -extern void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, - const void *buf, int len); - -extern void brcms_c_update_beacon(struct brcms_c_info *wlc); - -extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend); -extern void brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, - struct brcms_bss_cfg *cfg, - bool suspend); -extern bool brcms_c_ismpc(struct brcms_c_info *wlc); -extern bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc); -extern void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc); -extern bool brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q, - struct sk_buff *pkt, int prec, bool head); -extern u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec); -extern void brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rate, - uint length, u8 *plcp); -extern uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, - u32 ratespec, - u8 preamble_type, uint mac_len); - -extern void brcms_c_set_chanspec(struct brcms_c_info *wlc, - u16 chanspec); - -extern bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit); - -extern int brcms_c_set_nmode(struct brcms_c_info *wlc); -extern void brcms_c_mimops_action_ht_send(struct brcms_c_info *wlc, - struct brcms_bss_cfg *bsscfg, - u8 mimops_mode); - -extern void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot); -extern void brcms_c_set_bssid(struct brcms_bss_cfg *cfg); -extern void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend); - -extern void brcms_c_set_ratetable(struct brcms_c_info *wlc); -extern int brcms_c_set_mac(struct brcms_bss_cfg *cfg); -extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, - u32 bcn_rate); -extern void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, - uint frame_len); -extern u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc, - struct brcms_c_rateset *rs); -extern void brcms_c_radio_disable(struct brcms_c_info *wlc); -extern void brcms_c_bcn_li_upd(struct brcms_c_info *wlc); -extern void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, - u16 chanspec); -extern bool brcms_c_ps_allowed(struct brcms_c_info *wlc); -extern bool brcms_c_stay_awake(struct brcms_c_info *wlc); - -extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, - u8 antsel_type); - -/* chanspec, ucode interface */ -extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, - u16 chanspec, - bool mute, struct txpwr_limits *txpwr); - -extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, - u16 v); -extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset); - -extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, - u16 val, int bands); - -extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags); - -extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val); - -extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw); -extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw); -extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw); -extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, - u32 override_bit); -extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, - u32 override_bit); -extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, - int offset, int len, void *buf); -extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate); -extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, - uint offset, const void *buf, int len, - u32 sel); -extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, - void *buf, int len, u32 sel); -extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode); -extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw); -extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk); -extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk); -extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on); -extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant); -extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, - u8 stf_mode); -extern void brcms_c_init_scb(struct scb *scb); - -#endif /* _BRCM_MAIN_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c deleted file mode 100644 index 0bcb2679204..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ /dev/null @@ -1,835 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include "aiutils.h" -#include "pub.h" -#include "nicpci.h" - -/* SPROM offsets */ -#define SRSH_ASPM_OFFSET 4 /* word 4 */ -#define SRSH_ASPM_ENB 0x18 /* bit 3, 4 */ -#define SRSH_ASPM_L1_ENB 0x10 /* bit 4 */ -#define SRSH_ASPM_L0s_ENB 0x8 /* bit 3 */ - -#define SRSH_PCIE_MISC_CONFIG 5 /* word 5 */ -#define SRSH_L23READY_EXIT_NOPERST 0x8000 /* bit 15 */ -#define SRSH_CLKREQ_OFFSET_REV5 20 /* word 20 for srom rev <= 5 */ -#define SRSH_CLKREQ_ENB 0x0800 /* bit 11 */ -#define SRSH_BD_OFFSET 6 /* word 6 */ - -/* chipcontrol */ -#define CHIPCTRL_4321_PLL_DOWN 0x800000/* serdes PLL down override */ - -/* MDIO control */ -#define MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */ -#define MDIOCTL_DIVISOR_VAL 0x2 -#define MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */ -#define MDIOCTL_ACCESS_DONE 0x100 /* Transaction complete */ - -/* MDIO Data */ -#define MDIODATA_MASK 0x0000ffff /* data 2 bytes */ -#define MDIODATA_TA 0x00020000 /* Turnaround */ - -#define MDIODATA_REGADDR_SHF 18 /* Regaddr shift */ -#define MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */ -#define MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */ -#define MDIODATA_DEVADDR_MASK 0x0f800000 - /* Physmedia devaddr Mask */ - -/* MDIO Data for older revisions < 10 */ -#define MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift */ -#define MDIODATA_REGADDR_MASK_OLD 0x003c0000 - /* Regaddr Mask */ -#define MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift */ -#define MDIODATA_DEVADDR_MASK_OLD 0x0fc00000 - /* Physmedia devaddr Mask */ - -/* Transactions flags */ -#define MDIODATA_WRITE 0x10000000 -#define MDIODATA_READ 0x20000000 -#define MDIODATA_START 0x40000000 - -#define MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */ -#define MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */ - -/* serdes regs (rev < 10) */ -#define MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */ -#define MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */ -#define MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */ - -/* SERDES RX registers */ -#define SERDES_RX_CTRL 1 /* Rx cntrl */ -#define SERDES_RX_TIMER1 2 /* Rx Timer1 */ -#define SERDES_RX_CDR 6 /* CDR */ -#define SERDES_RX_CDRBW 7 /* CDR BW */ -/* SERDES RX control register */ -#define SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */ -#define SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */ - -/* SERDES PLL registers */ -#define SERDES_PLL_CTRL 1 /* PLL control reg */ -#define PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */ - -/* Linkcontrol reg offset in PCIE Cap */ -#define PCIE_CAP_LINKCTRL_OFFSET 16 /* offset in pcie cap */ -#define PCIE_CAP_LCREG_ASPML0s 0x01 /* ASPM L0s in linkctrl */ -#define PCIE_CAP_LCREG_ASPML1 0x02 /* ASPM L1 in linkctrl */ -#define PCIE_CLKREQ_ENAB 0x100 /* CLKREQ Enab in linkctrl */ - -#define PCIE_ASPM_ENAB 3 /* ASPM L0s & L1 in linkctrl */ -#define PCIE_ASPM_L1_ENAB 2 /* ASPM L0s & L1 in linkctrl */ -#define PCIE_ASPM_L0s_ENAB 1 /* ASPM L0s & L1 in linkctrl */ -#define PCIE_ASPM_DISAB 0 /* ASPM L0s & L1 in linkctrl */ - -/* Power management threshold */ -#define PCIE_L1THRESHOLDTIME_MASK 0xFF00 /* bits 8 - 15 */ -#define PCIE_L1THRESHOLDTIME_SHIFT 8 /* PCIE_L1THRESHOLDTIME_SHIFT */ -#define PCIE_L1THRESHOLD_WARVAL 0x72 /* WAR value */ -#define PCIE_ASPMTIMER_EXTEND 0x01000000 - /* > rev7: - * enable extend ASPM timer - */ - -/* different register spaces to access thru pcie indirect access */ -#define PCIE_CONFIGREGS 1 /* Access to config space */ -#define PCIE_PCIEREGS 2 /* Access to pcie registers */ - -/* PCIE protocol PHY diagnostic registers */ -#define PCIE_PLP_STATUSREG 0x204 /* Status */ - -/* Status reg PCIE_PLP_STATUSREG */ -#define PCIE_PLP_POLARITYINV_STAT 0x10 - -/* PCIE protocol DLLP diagnostic registers */ -#define PCIE_DLLP_LCREG 0x100 /* Link Control */ -#define PCIE_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */ - -/* PCIE protocol TLP diagnostic registers */ -#define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */ - -/* Sonics to PCI translation types */ -#define SBTOPCI_PREF 0x4 /* prefetch enable */ -#define SBTOPCI_BURST 0x8 /* burst enable */ -#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */ - -#define PCI_CLKRUN_DSBL 0x8000 /* Bit 15 forceClkrun */ - -/* PCI core index in SROM shadow area */ -#define SRSH_PI_OFFSET 0 /* first word */ -#define SRSH_PI_MASK 0xf000 /* bit 15:12 */ -#define SRSH_PI_SHIFT 12 /* bit 15:12 */ - -/* Sonics side: PCI core and host control registers */ -struct sbpciregs { - u32 control; /* PCI control */ - u32 PAD[3]; - u32 arbcontrol; /* PCI arbiter control */ - u32 clkrun; /* Clkrun Control (>=rev11) */ - u32 PAD[2]; - u32 intstatus; /* Interrupt status */ - u32 intmask; /* Interrupt mask */ - u32 sbtopcimailbox; /* Sonics to PCI mailbox */ - u32 PAD[9]; - u32 bcastaddr; /* Sonics broadcast address */ - u32 bcastdata; /* Sonics broadcast data */ - u32 PAD[2]; - u32 gpioin; /* ro: gpio input (>=rev2) */ - u32 gpioout; /* rw: gpio output (>=rev2) */ - u32 gpioouten; /* rw: gpio output enable (>= rev2) */ - u32 gpiocontrol; /* rw: gpio control (>= rev2) */ - u32 PAD[36]; - u32 sbtopci0; /* Sonics to PCI translation 0 */ - u32 sbtopci1; /* Sonics to PCI translation 1 */ - u32 sbtopci2; /* Sonics to PCI translation 2 */ - u32 PAD[189]; - u32 pcicfg[4][64]; /* 0x400 - 0x7FF, PCI Cfg Space (>=rev8) */ - u16 sprom[36]; /* SPROM shadow Area */ - u32 PAD[46]; -}; - -/* SB side: PCIE core and host control registers */ -struct sbpcieregs { - u32 control; /* host mode only */ - u32 PAD[2]; - u32 biststatus; /* bist Status: 0x00C */ - u32 gpiosel; /* PCIE gpio sel: 0x010 */ - u32 gpioouten; /* PCIE gpio outen: 0x14 */ - u32 PAD[2]; - u32 intstatus; /* Interrupt status: 0x20 */ - u32 intmask; /* Interrupt mask: 0x24 */ - u32 sbtopcimailbox; /* sb to pcie mailbox: 0x028 */ - u32 PAD[53]; - u32 sbtopcie0; /* sb to pcie translation 0: 0x100 */ - u32 sbtopcie1; /* sb to pcie translation 1: 0x104 */ - u32 sbtopcie2; /* sb to pcie translation 2: 0x108 */ - u32 PAD[5]; - - /* pcie core supports in direct access to config space */ - u32 configaddr; /* pcie config space access: Address field: 0x120 */ - u32 configdata; /* pcie config space access: Data field: 0x124 */ - - /* mdio access to serdes */ - u32 mdiocontrol; /* controls the mdio access: 0x128 */ - u32 mdiodata; /* Data to the mdio access: 0x12c */ - - /* pcie protocol phy/dllp/tlp register indirect access mechanism */ - u32 pcieindaddr; /* indirect access to - * the internal register: 0x130 - */ - u32 pcieinddata; /* Data to/from the internal regsiter: 0x134 */ - - u32 clkreqenctrl; /* >= rev 6, Clkreq rdma control : 0x138 */ - u32 PAD[177]; - u32 pciecfg[4][64]; /* 0x400 - 0x7FF, PCIE Cfg Space */ - u16 sprom[64]; /* SPROM shadow Area */ -}; - -struct pcicore_info { - union { - struct sbpcieregs __iomem *pcieregs; - struct sbpciregs __iomem *pciregs; - } regs; /* Memory mapped register to the core */ - - struct si_pub *sih; /* System interconnect handle */ - struct pci_dev *dev; - u8 pciecap_lcreg_offset;/* PCIE capability LCreg offset - * in the config space - */ - bool pcie_pr42767; - u8 pcie_polarity; - u8 pcie_war_aspm_ovr; /* Override ASPM/Clkreq settings */ - - u8 pmecap_offset; /* PM Capability offset in the config space */ - bool pmecap; /* Capable of generating PME */ -}; - -#define PCIE_ASPM(sih) \ - (((sih)->buscoretype == PCIE_CORE_ID) && \ - (((sih)->buscorerev >= 3) && \ - ((sih)->buscorerev <= 5))) - - -/* delay needed between the mdio control/ mdiodata register data access */ -static void pr28829_delay(void) -{ - udelay(10); -} - -/* Initialize the PCI core. - * It's caller's responsibility to make sure that this is done only once - */ -struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, - void __iomem *regs) -{ - struct pcicore_info *pi; - - /* alloc struct pcicore_info */ - pi = kzalloc(sizeof(struct pcicore_info), GFP_ATOMIC); - if (pi == NULL) - return NULL; - - pi->sih = sih; - pi->dev = pdev; - - if (sih->buscoretype == PCIE_CORE_ID) { - u8 cap_ptr; - pi->regs.pcieregs = regs; - cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP, - NULL, NULL); - pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET; - } else - pi->regs.pciregs = regs; - - return pi; -} - -void pcicore_deinit(struct pcicore_info *pch) -{ - kfree(pch); -} - -/* return cap_offset if requested capability exists in the PCI config space */ -/* Note that it's caller's responsibility to make sure it's a pci bus */ -u8 -pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, - unsigned char *buf, u32 *buflen) -{ - u8 cap_id; - u8 cap_ptr = 0; - u32 bufsize; - u8 byte_val; - - /* check for Header type 0 */ - pci_read_config_byte(dev, PCI_HEADER_TYPE, &byte_val); - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL) - goto end; - - /* check if the capability pointer field exists */ - pci_read_config_byte(dev, PCI_STATUS, &byte_val); - if (!(byte_val & PCI_STATUS_CAP_LIST)) - goto end; - - pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr); - /* check if the capability pointer is 0x00 */ - if (cap_ptr == 0x00) - goto end; - - /* loop thru the capability list - * and see if the pcie capability exists - */ - - pci_read_config_byte(dev, cap_ptr, &cap_id); - - while (cap_id != req_cap_id) { - pci_read_config_byte(dev, cap_ptr + 1, &cap_ptr); - if (cap_ptr == 0x00) - break; - pci_read_config_byte(dev, cap_ptr, &cap_id); - } - if (cap_id != req_cap_id) - goto end; - - /* found the caller requested capability */ - if (buf != NULL && buflen != NULL) { - u8 cap_data; - - bufsize = *buflen; - if (!bufsize) - goto end; - *buflen = 0; - /* copy the capability data excluding cap ID and next ptr */ - cap_data = cap_ptr + 2; - if ((bufsize + cap_data) > PCI_SZPCR) - bufsize = PCI_SZPCR - cap_data; - *buflen = bufsize; - while (bufsize--) { - pci_read_config_byte(dev, cap_data, buf); - cap_data++; - buf++; - } - } -end: - return cap_ptr; -} - -/* ***** Register Access API */ -static uint -pcie_readreg(struct sbpcieregs __iomem *pcieregs, uint addrtype, uint offset) -{ - uint retval = 0xFFFFFFFF; - - switch (addrtype) { - case PCIE_CONFIGREGS: - W_REG(&pcieregs->configaddr, offset); - (void)R_REG((&pcieregs->configaddr)); - retval = R_REG(&pcieregs->configdata); - break; - case PCIE_PCIEREGS: - W_REG(&pcieregs->pcieindaddr, offset); - (void)R_REG(&pcieregs->pcieindaddr); - retval = R_REG(&pcieregs->pcieinddata); - break; - } - - return retval; -} - -static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype, - uint offset, uint val) -{ - switch (addrtype) { - case PCIE_CONFIGREGS: - W_REG((&pcieregs->configaddr), offset); - W_REG((&pcieregs->configdata), val); - break; - case PCIE_PCIEREGS: - W_REG((&pcieregs->pcieindaddr), offset); - W_REG((&pcieregs->pcieinddata), val); - break; - default: - break; - } - return 0; -} - -static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) -{ - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - uint mdiodata, i = 0; - uint pcie_serdes_spinwait = 200; - - mdiodata = (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA | - (MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) | - (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) | - (blk << 4)); - W_REG(&pcieregs->mdiodata, mdiodata); - - pr28829_delay(); - /* retry till the transaction is complete */ - while (i < pcie_serdes_spinwait) { - if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) - break; - - udelay(1000); - i++; - } - - if (i >= pcie_serdes_spinwait) - return false; - - return true; -} - -static int -pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, - uint *val) -{ - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - uint mdiodata; - uint i = 0; - uint pcie_serdes_spinwait = 10; - - /* enable mdio access to SERDES */ - W_REG(&pcieregs->mdiocontrol, MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); - - if (pi->sih->buscorerev >= 10) { - /* new serdes is slower in rw, - * using two layers of reg address mapping - */ - if (!pcie_mdiosetblock(pi, physmedia)) - return 1; - mdiodata = ((MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) | - (regaddr << MDIODATA_REGADDR_SHF)); - pcie_serdes_spinwait *= 20; - } else { - mdiodata = ((physmedia << MDIODATA_DEVADDR_SHF_OLD) | - (regaddr << MDIODATA_REGADDR_SHF_OLD)); - } - - if (!write) - mdiodata |= (MDIODATA_START | MDIODATA_READ | MDIODATA_TA); - else - mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA | - *val); - - W_REG(&pcieregs->mdiodata, mdiodata); - - pr28829_delay(); - - /* retry till the transaction is complete */ - while (i < pcie_serdes_spinwait) { - if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) { - if (!write) { - pr28829_delay(); - *val = (R_REG(&pcieregs->mdiodata) & - MDIODATA_MASK); - } - /* Disable mdio access to SERDES */ - W_REG(&pcieregs->mdiocontrol, 0); - return 0; - } - udelay(1000); - i++; - } - - /* Timed out. Disable mdio access to SERDES. */ - W_REG(&pcieregs->mdiocontrol, 0); - return 1; -} - -/* use the mdio interface to read from mdio slaves */ -static int -pcie_mdioread(struct pcicore_info *pi, uint physmedia, uint regaddr, - uint *regval) -{ - return pcie_mdioop(pi, physmedia, regaddr, false, regval); -} - -/* use the mdio interface to write to mdio slaves */ -static int -pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint regaddr, uint val) -{ - return pcie_mdioop(pi, physmedia, regaddr, true, &val); -} - -/* ***** Support functions ***** */ -static u8 pcie_clkreq(struct pcicore_info *pi, u32 mask, u32 val) -{ - u32 reg_val; - u8 offset; - - offset = pi->pciecap_lcreg_offset; - if (!offset) - return 0; - - pci_read_config_dword(pi->dev, offset, ®_val); - /* set operation */ - if (mask) { - if (val) - reg_val |= PCIE_CLKREQ_ENAB; - else - reg_val &= ~PCIE_CLKREQ_ENAB; - pci_write_config_dword(pi->dev, offset, reg_val); - pci_read_config_dword(pi->dev, offset, ®_val); - } - if (reg_val & PCIE_CLKREQ_ENAB) - return 1; - else - return 0; -} - -static void pcie_extendL1timer(struct pcicore_info *pi, bool extend) -{ - u32 w; - struct si_pub *sih = pi->sih; - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - - if (sih->buscoretype != PCIE_CORE_ID || sih->buscorerev < 7) - return; - - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); - if (extend) - w |= PCIE_ASPMTIMER_EXTEND; - else - w &= ~PCIE_ASPMTIMER_EXTEND; - pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); -} - -/* centralized clkreq control policy */ -static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) -{ - struct si_pub *sih = pi->sih; - - switch (state) { - case SI_DOATTACH: - if (PCIE_ASPM(sih)) - pcie_clkreq(pi, 1, 0); - break; - case SI_PCIDOWN: - if (sih->buscorerev == 6) { /* turn on serdes PLL down */ - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), - ~0, 0); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), - ~0x40, 0); - } else if (pi->pcie_pr42767) { - pcie_clkreq(pi, 1, 1); - } - break; - case SI_PCIUP: - if (sih->buscorerev == 6) { /* turn off serdes PLL down */ - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), - ~0, 0); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), - ~0x40, 0x40); - } else if (PCIE_ASPM(sih)) { /* disable clkreq */ - pcie_clkreq(pi, 1, 0); - } - break; - } -} - -/* ***** PCI core WARs ***** */ -/* Done only once at attach time */ -static void pcie_war_polarity(struct pcicore_info *pi) -{ - u32 w; - - if (pi->pcie_polarity != 0) - return; - - w = pcie_readreg(pi->regs.pcieregs, PCIE_PCIEREGS, PCIE_PLP_STATUSREG); - - /* Detect the current polarity at attach and force that polarity and - * disable changing the polarity - */ - if ((w & PCIE_PLP_POLARITYINV_STAT) == 0) - pi->pcie_polarity = SERDES_RX_CTRL_FORCE; - else - pi->pcie_polarity = (SERDES_RX_CTRL_FORCE | - SERDES_RX_CTRL_POLARITY); -} - -/* enable ASPM and CLKREQ if srom doesn't have it */ -/* Needs to happen when update to shadow SROM is needed - * : Coming out of 'standby'/'hibernate' - * : If pcie_war_aspm_ovr state changed - */ -static void pcie_war_aspm_clkreq(struct pcicore_info *pi) -{ - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - struct si_pub *sih = pi->sih; - u16 val16; - u16 __iomem *reg16; - u32 w; - - if (!PCIE_ASPM(sih)) - return; - - /* bypass this on QT or VSIM */ - reg16 = &pcieregs->sprom[SRSH_ASPM_OFFSET]; - val16 = R_REG(reg16); - - val16 &= ~SRSH_ASPM_ENB; - if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB) - val16 |= SRSH_ASPM_ENB; - else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L1_ENAB) - val16 |= SRSH_ASPM_L1_ENB; - else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB) - val16 |= SRSH_ASPM_L0s_ENB; - - W_REG(reg16, val16); - - pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); - w &= ~PCIE_ASPM_ENAB; - w |= pi->pcie_war_aspm_ovr; - pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); - - reg16 = &pcieregs->sprom[SRSH_CLKREQ_OFFSET_REV5]; - val16 = R_REG(reg16); - - if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) { - val16 |= SRSH_CLKREQ_ENB; - pi->pcie_pr42767 = true; - } else - val16 &= ~SRSH_CLKREQ_ENB; - - W_REG(reg16, val16); -} - -/* Apply the polarity determined at the start */ -/* Needs to happen when coming out of 'standby'/'hibernate' */ -static void pcie_war_serdes(struct pcicore_info *pi) -{ - u32 w = 0; - - if (pi->pcie_polarity != 0) - pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CTRL, - pi->pcie_polarity); - - pcie_mdioread(pi, MDIODATA_DEV_PLL, SERDES_PLL_CTRL, &w); - if (w & PLL_CTRL_FREQDET_EN) { - w &= ~PLL_CTRL_FREQDET_EN; - pcie_mdiowrite(pi, MDIODATA_DEV_PLL, SERDES_PLL_CTRL, w); - } -} - -/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */ -/* Needs to happen when coming out of 'standby'/'hibernate' */ -static void pcie_misc_config_fixup(struct pcicore_info *pi) -{ - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - u16 val16; - u16 __iomem *reg16; - - reg16 = &pcieregs->sprom[SRSH_PCIE_MISC_CONFIG]; - val16 = R_REG(reg16); - - if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) { - val16 |= SRSH_L23READY_EXIT_NOPERST; - W_REG(reg16, val16); - } -} - -/* quick hack for testing */ -/* Needs to happen when coming out of 'standby'/'hibernate' */ -static void pcie_war_noplldown(struct pcicore_info *pi) -{ - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - u16 __iomem *reg16; - - /* turn off serdes PLL down */ - ai_corereg(pi->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), - CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); - - /* clear srom shadow backdoor */ - reg16 = &pcieregs->sprom[SRSH_BD_OFFSET]; - W_REG(reg16, 0); -} - -/* Needs to happen when coming out of 'standby'/'hibernate' */ -static void pcie_war_pci_setup(struct pcicore_info *pi) -{ - struct si_pub *sih = pi->sih; - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - u32 w; - - if (sih->buscorerev == 0 || sih->buscorerev == 1) { - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, - PCIE_TLP_WORKAROUNDSREG); - w |= 0x8; - pcie_writereg(pcieregs, PCIE_PCIEREGS, - PCIE_TLP_WORKAROUNDSREG, w); - } - - if (sih->buscorerev == 1) { - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); - w |= 0x40; - pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); - } - - if (sih->buscorerev == 0) { - pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128); - pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100); - pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); - } else if (PCIE_ASPM(sih)) { - /* Change the L1 threshold for better performance */ - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, - PCIE_DLLP_PMTHRESHREG); - w &= ~PCIE_L1THRESHOLDTIME_MASK; - w |= PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT; - pcie_writereg(pcieregs, PCIE_PCIEREGS, - PCIE_DLLP_PMTHRESHREG, w); - - pcie_war_serdes(pi); - - pcie_war_aspm_clkreq(pi); - } else if (pi->sih->buscorerev == 7) - pcie_war_noplldown(pi); - - /* Note that the fix is actually in the SROM, - * that's why this is open-ended - */ - if (pi->sih->buscorerev >= 6) - pcie_misc_config_fixup(pi); -} - -/* ***** Functions called during driver state changes ***** */ -void pcicore_attach(struct pcicore_info *pi, int state) -{ - struct si_pub *sih = pi->sih; - u32 bfl2 = (u32)getintvar(sih, BRCMS_SROM_BOARDFLAGS2); - - /* Determine if this board needs override */ - if (PCIE_ASPM(sih)) { - if (bfl2 & BFL2_PCIEWAR_OVR) - pi->pcie_war_aspm_ovr = PCIE_ASPM_DISAB; - else - pi->pcie_war_aspm_ovr = PCIE_ASPM_ENAB; - } - - /* These need to happen in this order only */ - pcie_war_polarity(pi); - - pcie_war_serdes(pi); - - pcie_war_aspm_clkreq(pi); - - pcie_clkreq_upd(pi, state); - -} - -void pcicore_hwup(struct pcicore_info *pi) -{ - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) - return; - - pcie_war_pci_setup(pi); -} - -void pcicore_up(struct pcicore_info *pi, int state) -{ - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) - return; - - /* Restore L1 timer for better performance */ - pcie_extendL1timer(pi, true); - - pcie_clkreq_upd(pi, state); -} - -/* When the device is going to enter D3 state - * (or the system is going to enter S3/S4 states) - */ -void pcicore_sleep(struct pcicore_info *pi) -{ - u32 w; - - if (!pi || !PCIE_ASPM(pi->sih)) - return; - - pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); - w &= ~PCIE_CAP_LCREG_ASPML1; - pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); - - pi->pcie_pr42767 = false; -} - -void pcicore_down(struct pcicore_info *pi, int state) -{ - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) - return; - - pcie_clkreq_upd(pi, state); - - /* Reduce L1 timer for better power savings */ - pcie_extendL1timer(pi, false); -} - -/* precondition: current core is sii->buscoretype */ -static void pcicore_fixcfg(struct pcicore_info *pi, u16 __iomem *reg16) -{ - struct si_info *sii = (struct si_info *)(pi->sih); - u16 val16; - uint pciidx; - - pciidx = ai_coreidx(&sii->pub); - val16 = R_REG(reg16); - if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { - val16 = (u16)(pciidx << SRSH_PI_SHIFT) | - (val16 & ~SRSH_PI_MASK); - W_REG(reg16, val16); - } -} - -void -pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) -{ - pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]); -} - -void pcicore_fixcfg_pcie(struct pcicore_info *pi, - struct sbpcieregs __iomem *pcieregs) -{ - pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); -} - -/* precondition: current core is pci core */ -void -pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) -{ - u32 w; - - OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); - - if (((struct si_info *)(pi->sih))->pub.buscorerev >= 11) { - OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); - w = R_REG(&pciregs->clkrun); - W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL); - w = R_REG(&pciregs->clkrun); - } -} diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.h b/drivers/staging/brcm80211/brcmsmac/nicpci.h deleted file mode 100644 index 58aa80dc332..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_NICPCI_H_ -#define _BRCM_NICPCI_H_ - -#include "types.h" - -/* PCI configuration address space size */ -#define PCI_SZPCR 256 - -/* Brcm PCI configuration registers */ -/* backplane address space accessed by BAR0 */ -#define PCI_BAR0_WIN 0x80 -/* sprom property control */ -#define PCI_SPROM_CONTROL 0x88 -/* mask of PCI and other cores interrupts */ -#define PCI_INT_MASK 0x94 -/* backplane core interrupt mask bits offset */ -#define PCI_SBIM_SHIFT 8 -/* backplane address space accessed by second 4KB of BAR0 */ -#define PCI_BAR0_WIN2 0xac -/* pci config space gpio input (>=rev3) */ -#define PCI_GPIO_IN 0xb0 -/* pci config space gpio output (>=rev3) */ -#define PCI_GPIO_OUT 0xb4 -/* pci config space gpio output enable (>=rev3) */ -#define PCI_GPIO_OUTEN 0xb8 - -/* bar0 + 4K accesses external sprom */ -#define PCI_BAR0_SPROM_OFFSET (4 * 1024) -/* bar0 + 6K accesses pci core registers */ -#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) -/* - * pci core SB registers are at the end of the - * 8KB window, so their address is the "regular" - * address plus 4K - */ -#define PCI_BAR0_PCISBR_OFFSET (4 * 1024) -/* bar0 window size Match with corerev 13 */ -#define PCI_BAR0_WINSZ (16 * 1024) -/* On pci corerev >= 13 and all pcie, the bar0 is now 16KB and it maps: */ -/* bar0 + 8K accesses pci/pcie core registers */ -#define PCI_16KB0_PCIREGS_OFFSET (8 * 1024) -/* bar0 + 12K accesses chipc core registers */ -#define PCI_16KB0_CCREGS_OFFSET (12 * 1024) - -struct sbpciregs; -struct sbpcieregs; - -extern struct pcicore_info *pcicore_init(struct si_pub *sih, - struct pci_dev *pdev, - void __iomem *regs); -extern void pcicore_deinit(struct pcicore_info *pch); -extern void pcicore_attach(struct pcicore_info *pch, int state); -extern void pcicore_hwup(struct pcicore_info *pch); -extern void pcicore_up(struct pcicore_info *pch, int state); -extern void pcicore_sleep(struct pcicore_info *pch); -extern void pcicore_down(struct pcicore_info *pch, int state); -extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, - unsigned char *buf, u32 *buflen); -extern void pcicore_fixcfg_pci(struct pcicore_info *pch, - struct sbpciregs __iomem *pciregs); -extern void pcicore_fixcfg_pcie(struct pcicore_info *pch, - struct sbpcieregs __iomem *pciregs); -extern void pcicore_pci_setup(struct pcicore_info *pch, - struct sbpciregs __iomem *pciregs); - -#endif /* _BRCM_NICPCI_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c deleted file mode 100644 index edf551561fd..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/otp.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include "aiutils.h" -#include "otp.h" - -#define OTPS_GUP_MASK 0x00000f00 -#define OTPS_GUP_SHIFT 8 -/* h/w subregion is programmed */ -#define OTPS_GUP_HW 0x00000100 -/* s/w subregion is programmed */ -#define OTPS_GUP_SW 0x00000200 -/* chipid/pkgopt subregion is programmed */ -#define OTPS_GUP_CI 0x00000400 -/* fuse subregion is programmed */ -#define OTPS_GUP_FUSE 0x00000800 - -/* Fields in otpprog in rev >= 21 */ -#define OTPP_COL_MASK 0x000000ff -#define OTPP_COL_SHIFT 0 -#define OTPP_ROW_MASK 0x0000ff00 -#define OTPP_ROW_SHIFT 8 -#define OTPP_OC_MASK 0x0f000000 -#define OTPP_OC_SHIFT 24 -#define OTPP_READERR 0x10000000 -#define OTPP_VALUE_MASK 0x20000000 -#define OTPP_VALUE_SHIFT 29 -#define OTPP_START_BUSY 0x80000000 -#define OTPP_READ 0x40000000 - -/* Opcodes for OTPP_OC field */ -#define OTPPOC_READ 0 -#define OTPPOC_BIT_PROG 1 -#define OTPPOC_VERIFY 3 -#define OTPPOC_INIT 4 -#define OTPPOC_SET 5 -#define OTPPOC_RESET 6 -#define OTPPOC_OCST 7 -#define OTPPOC_ROW_LOCK 8 -#define OTPPOC_PRESCN_TEST 9 - -#define OTPTYPE_IPX(ccrev) ((ccrev) == 21 || (ccrev) >= 23) - -#define OTPP_TRIES 10000000 /* # of tries for OTPP */ - -#define MAXNUMRDES 9 /* Maximum OTP redundancy entries */ - -/* Fixed size subregions sizes in words */ -#define OTPGU_CI_SZ 2 - -struct otpinfo; - -/* OTP function struct */ -struct otp_fn_s { - int (*init)(struct si_pub *sih, struct otpinfo *oi); - int (*read_region)(struct otpinfo *oi, int region, u16 *data, - uint *wlen); -}; - -struct otpinfo { - uint ccrev; /* chipc revision */ - const struct otp_fn_s *fn; /* OTP functions */ - struct si_pub *sih; /* Saved sb handle */ - - /* IPX OTP section */ - u16 wsize; /* Size of otp in words */ - u16 rows; /* Geometry */ - u16 cols; /* Geometry */ - u32 status; /* Flag bits (lock/prog/rv). - * (Reflected only when OTP is power cycled) - */ - u16 hwbase; /* hardware subregion offset */ - u16 hwlim; /* hardware subregion boundary */ - u16 swbase; /* software subregion offset */ - u16 swlim; /* software subregion boundary */ - u16 fbase; /* fuse subregion offset */ - u16 flim; /* fuse subregion boundary */ - int otpgu_base; /* offset to General Use Region */ -}; - -/* OTP layout */ -/* CC revs 21, 24 and 27 OTP General Use Region word offset */ -#define REVA4_OTPGU_BASE 12 - -/* CC revs 23, 25, 26, 28 and above OTP General Use Region word offset */ -#define REVB8_OTPGU_BASE 20 - -/* CC rev 36 OTP General Use Region word offset */ -#define REV36_OTPGU_BASE 12 - -/* Subregion word offsets in General Use region */ -#define OTPGU_HSB_OFF 0 -#define OTPGU_SFB_OFF 1 -#define OTPGU_CI_OFF 2 -#define OTPGU_P_OFF 3 -#define OTPGU_SROM_OFF 4 - -/* Flag bit offsets in General Use region */ -#define OTPGU_HWP_OFF 60 -#define OTPGU_SWP_OFF 61 -#define OTPGU_CIP_OFF 62 -#define OTPGU_FUSEP_OFF 63 -#define OTPGU_CIP_MSK 0x4000 -#define OTPGU_P_MSK 0xf000 -#define OTPGU_P_SHIFT (OTPGU_HWP_OFF % 16) - -/* OTP Size */ -#define OTP_SZ_FU_324 ((roundup(324, 8))/8) /* 324 bits */ -#define OTP_SZ_FU_288 (288/8) /* 288 bits */ -#define OTP_SZ_FU_216 (216/8) /* 216 bits */ -#define OTP_SZ_FU_72 (72/8) /* 72 bits */ -#define OTP_SZ_CHECKSUM (16/8) /* 16 bits */ -#define OTP4315_SWREG_SZ 178 /* 178 bytes */ -#define OTP_SZ_FU_144 (144/8) /* 144 bits */ - -static u16 -ipxotp_otpr(struct otpinfo *oi, struct chipcregs __iomem *cc, uint wn) -{ - return R_REG(&cc->sromotp[wn]); -} - -/* - * Calculate max HW/SW region byte size by subtracting fuse region - * and checksum size, osizew is oi->wsize (OTP size - GU size) in words - */ -static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) -{ - int ret = 0; - - switch (sih->chip) { - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM; - break; - case BCM4313_CHIP_ID: - ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM; - break; - default: - break; /* Don't know about this chip */ - } - - return ret; -} - -static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) -{ - uint k; - u32 otpp, st; - - /* - * record word offset of General Use Region - * for various chipcommon revs - */ - if (oi->sih->ccrev == 21 || oi->sih->ccrev == 24 - || oi->sih->ccrev == 27) { - oi->otpgu_base = REVA4_OTPGU_BASE; - } else if (oi->sih->ccrev == 36) { - /* - * OTP size greater than equal to 2KB (128 words), - * otpgu_base is similar to rev23 - */ - if (oi->wsize >= 128) - oi->otpgu_base = REVB8_OTPGU_BASE; - else - oi->otpgu_base = REV36_OTPGU_BASE; - } else if (oi->sih->ccrev == 23 || oi->sih->ccrev >= 25) { - oi->otpgu_base = REVB8_OTPGU_BASE; - } - - /* First issue an init command so the status is up to date */ - otpp = - OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK); - - W_REG(&cc->otpprog, otpp); - for (k = 0; - ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) - && (k < OTPP_TRIES); k++) - ; - if (k >= OTPP_TRIES) - return; - - /* Read OTP lock bits and subregion programmed indication bits */ - oi->status = R_REG(&cc->otpstatus); - - if ((oi->sih->chip == BCM43224_CHIP_ID) - || (oi->sih->chip == BCM43225_CHIP_ID)) { - u32 p_bits; - p_bits = - (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) & - OTPGU_P_MSK) - >> OTPGU_P_SHIFT; - oi->status |= (p_bits << OTPS_GUP_SHIFT); - } - - /* - * h/w region base and fuse region limit are fixed to - * the top and the bottom of the general use region. - * Everything else can be flexible. - */ - oi->hwbase = oi->otpgu_base + OTPGU_SROM_OFF; - oi->hwlim = oi->wsize; - if (oi->status & OTPS_GUP_HW) { - oi->hwlim = - ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_HSB_OFF) / 16; - oi->swbase = oi->hwlim; - } else - oi->swbase = oi->hwbase; - - /* subtract fuse and checksum from beginning */ - oi->swlim = ipxotp_max_rgnsz(oi->sih, oi->wsize) / 2; - - if (oi->status & OTPS_GUP_SW) { - oi->swlim = - ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_SFB_OFF) / 16; - oi->fbase = oi->swlim; - } else - oi->fbase = oi->swbase; - - oi->flim = oi->wsize; -} - -static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) -{ - uint idx; - struct chipcregs __iomem *cc; - - /* Make sure we're running IPX OTP */ - if (!OTPTYPE_IPX(sih->ccrev)) - return -EBADE; - - /* Make sure OTP is not disabled */ - if (ai_is_otp_disabled(sih)) - return -EBADE; - - /* Check for otp size */ - switch ((sih->cccaps & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) { - case 0: - /* Nothing there */ - return -EBADE; - case 1: /* 32x64 */ - oi->rows = 32; - oi->cols = 64; - oi->wsize = 128; - break; - case 2: /* 64x64 */ - oi->rows = 64; - oi->cols = 64; - oi->wsize = 256; - break; - case 5: /* 96x64 */ - oi->rows = 96; - oi->cols = 64; - oi->wsize = 384; - break; - case 7: /* 16x64 *//* 1024 bits */ - oi->rows = 16; - oi->cols = 64; - oi->wsize = 64; - break; - default: - /* Don't know the geometry */ - return -EBADE; - } - - /* Retrieve OTP region info */ - idx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - _ipxotp_init(oi, cc); - - ai_setcoreidx(sih, idx); - - return 0; -} - -static int -ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) -{ - uint idx; - struct chipcregs __iomem *cc; - uint base, i, sz; - - /* Validate region selection */ - switch (region) { - case OTP_HW_RGN: - sz = (uint) oi->hwlim - oi->hwbase; - if (!(oi->status & OTPS_GUP_HW)) { - *wlen = sz; - return -ENODATA; - } - if (*wlen < sz) { - *wlen = sz; - return -EOVERFLOW; - } - base = oi->hwbase; - break; - case OTP_SW_RGN: - sz = ((uint) oi->swlim - oi->swbase); - if (!(oi->status & OTPS_GUP_SW)) { - *wlen = sz; - return -ENODATA; - } - if (*wlen < sz) { - *wlen = sz; - return -EOVERFLOW; - } - base = oi->swbase; - break; - case OTP_CI_RGN: - sz = OTPGU_CI_SZ; - if (!(oi->status & OTPS_GUP_CI)) { - *wlen = sz; - return -ENODATA; - } - if (*wlen < sz) { - *wlen = sz; - return -EOVERFLOW; - } - base = oi->otpgu_base + OTPGU_CI_OFF; - break; - case OTP_FUSE_RGN: - sz = (uint) oi->flim - oi->fbase; - if (!(oi->status & OTPS_GUP_FUSE)) { - *wlen = sz; - return -ENODATA; - } - if (*wlen < sz) { - *wlen = sz; - return -EOVERFLOW; - } - base = oi->fbase; - break; - case OTP_ALL_RGN: - sz = ((uint) oi->flim - oi->hwbase); - if (!(oi->status & (OTPS_GUP_HW | OTPS_GUP_SW))) { - *wlen = sz; - return -ENODATA; - } - if (*wlen < sz) { - *wlen = sz; - return -EOVERFLOW; - } - base = oi->hwbase; - break; - default: - return -EINVAL; - } - - idx = ai_coreidx(oi->sih); - cc = ai_setcoreidx(oi->sih, SI_CC_IDX); - - /* Read the data */ - for (i = 0; i < sz; i++) - data[i] = ipxotp_otpr(oi, cc, base + i); - - ai_setcoreidx(oi->sih, idx); - *wlen = sz; - return 0; -} - -static const struct otp_fn_s ipxotp_fn = { - (int (*)(struct si_pub *, struct otpinfo *)) ipxotp_init, - (int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region, -}; - -static int otp_init(struct si_pub *sih, struct otpinfo *oi) -{ - - int ret; - - memset(oi, 0, sizeof(struct otpinfo)); - - oi->ccrev = sih->ccrev; - - if (OTPTYPE_IPX(oi->ccrev)) - oi->fn = &ipxotp_fn; - - if (oi->fn == NULL) - return -EBADE; - - oi->sih = sih; - - ret = (oi->fn->init) (sih, oi); - - return ret; -} - -int -otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) { - struct otpinfo otpinfo; - struct otpinfo *oi = &otpinfo; - int err = 0; - - if (ai_is_otp_disabled(sih)) { - err = -EPERM; - goto out; - } - - err = otp_init(sih, oi); - if (err) - goto out; - - err = ((oi)->fn->read_region)(oi, region, data, wlen); - - out: - return err; -} diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h deleted file mode 100644 index 6b6d31cf956..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/otp.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_OTP_H_ -#define _BRCM_OTP_H_ - -#include "types.h" - -/* OTP regions */ -#define OTP_HW_RGN 1 -#define OTP_SW_RGN 2 -#define OTP_CI_RGN 4 -#define OTP_FUSE_RGN 8 -/* From h/w region to end of OTP including checksum */ -#define OTP_ALL_RGN 0xf - -/* OTP Size */ -#define OTP_SZ_MAX (6144/8) /* maximum bytes in one CIS */ - -extern int otp_read_region(struct si_pub *sih, int region, u16 *data, - uint *wlen); - -#endif /* _BRCM_OTP_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c deleted file mode 100644 index d54cfdb0a8e..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +++ /dev/null @@ -1,2988 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include "phy_hal.h" -#include "phy_int.h" -#include "phy_radio.h" -#include "phy_lcn.h" -#include "phyreg_n.h" - -#define VALID_N_RADIO(radioid) ((radioid == BCM2055_ID) || \ - (radioid == BCM2056_ID) || \ - (radioid == BCM2057_ID)) - -#define VALID_LCN_RADIO(radioid) (radioid == BCM2064_ID) - -#define VALID_RADIO(pi, radioid) ( \ - (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \ - (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false)) - -/* basic mux operation - can be optimized on several architectures */ -#define MUX(pred, true, false) ((pred) ? (true) : (false)) - -/* modulo inc/dec - assumes x E [0, bound - 1] */ -#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) - -/* modulo inc/dec, bound = 2^k */ -#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) -#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) - -struct chan_info_basic { - u16 chan; - u16 freq; -}; - -static const struct chan_info_basic chan_info_all[] = { - {1, 2412}, - {2, 2417}, - {3, 2422}, - {4, 2427}, - {5, 2432}, - {6, 2437}, - {7, 2442}, - {8, 2447}, - {9, 2452}, - {10, 2457}, - {11, 2462}, - {12, 2467}, - {13, 2472}, - {14, 2484}, - - {34, 5170}, - {38, 5190}, - {42, 5210}, - {46, 5230}, - - {36, 5180}, - {40, 5200}, - {44, 5220}, - {48, 5240}, - {52, 5260}, - {56, 5280}, - {60, 5300}, - {64, 5320}, - - {100, 5500}, - {104, 5520}, - {108, 5540}, - {112, 5560}, - {116, 5580}, - {120, 5600}, - {124, 5620}, - {128, 5640}, - {132, 5660}, - {136, 5680}, - {140, 5700}, - - {149, 5745}, - {153, 5765}, - {157, 5785}, - {161, 5805}, - {165, 5825}, - - {184, 4920}, - {188, 4940}, - {192, 4960}, - {196, 4980}, - {200, 5000}, - {204, 5020}, - {208, 5040}, - {212, 5060}, - {216, 50800} -}; - -const u8 ofdm_rate_lookup[] = { - - BRCM_RATE_48M, - BRCM_RATE_24M, - BRCM_RATE_12M, - BRCM_RATE_6M, - BRCM_RATE_54M, - BRCM_RATE_36M, - BRCM_RATE_18M, - BRCM_RATE_9M -}; - -#define PHY_WREG_LIMIT 24 - -void wlc_phyreg_enter(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - wlapi_bmac_ucode_wake_override_phyreg_set(pi->sh->physhim); -} - -void wlc_phyreg_exit(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - wlapi_bmac_ucode_wake_override_phyreg_clear(pi->sh->physhim); -} - -void wlc_radioreg_enter(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, MCTL_LOCK_RADIO); - - udelay(10); -} - -void wlc_radioreg_exit(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 dummy; - - dummy = R_REG(&pi->regs->phyversion); - pi->phy_wreg = 0; - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, 0); -} - -u16 read_radio_reg(struct brcms_phy *pi, u16 addr) -{ - u16 data; - - if ((addr == RADIO_IDCODE)) - return 0xffff; - - switch (pi->pubpi.phy_type) { - case PHY_TYPE_N: - if (!CONF_HAS(PHYTYPE, PHY_TYPE_N)) - break; - if (NREV_GE(pi->pubpi.phy_rev, 7)) - addr |= RADIO_2057_READ_OFF; - else - addr |= RADIO_2055_READ_OFF; - break; - - case PHY_TYPE_LCN: - if (!CONF_HAS(PHYTYPE, PHY_TYPE_LCN)) - break; - addr |= RADIO_2064_READ_OFF; - break; - - default: - break; - } - - if ((D11REV_GE(pi->sh->corerev, 24)) || - (D11REV_IS(pi->sh->corerev, 22) - && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - W_REG_FLUSH(&pi->regs->radioregaddr, addr); - data = R_REG(&pi->regs->radioregdata); - } else { - W_REG_FLUSH(&pi->regs->phy4waddr, addr); - -#ifdef __ARM_ARCH_4T__ - __asm__(" .align 4 "); - __asm__(" nop "); - data = R_REG(&pi->regs->phy4wdatalo); -#else - data = R_REG(&pi->regs->phy4wdatalo); -#endif - - } - pi->phy_wreg = 0; - - return data; -} - -void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - if ((D11REV_GE(pi->sh->corerev, 24)) || - (D11REV_IS(pi->sh->corerev, 22) - && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - - W_REG_FLUSH(&pi->regs->radioregaddr, addr); - W_REG(&pi->regs->radioregdata, val); - } else { - W_REG_FLUSH(&pi->regs->phy4waddr, addr); - W_REG(&pi->regs->phy4wdatalo, val); - } - - if (++pi->phy_wreg >= pi->phy_wreg_limit) { - (void)R_REG(&pi->regs->maccontrol); - pi->phy_wreg = 0; - } -} - -static u32 read_radio_id(struct brcms_phy *pi) -{ - u32 id; - - if (D11REV_GE(pi->sh->corerev, 24)) { - u32 b0, b1, b2; - - W_REG_FLUSH(&pi->regs->radioregaddr, 0); - b0 = (u32) R_REG(&pi->regs->radioregdata); - W_REG_FLUSH(&pi->regs->radioregaddr, 1); - b1 = (u32) R_REG(&pi->regs->radioregdata); - W_REG_FLUSH(&pi->regs->radioregaddr, 2); - b2 = (u32) R_REG(&pi->regs->radioregdata); - - id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4) - & 0xf); - } else { - W_REG_FLUSH(&pi->regs->phy4waddr, RADIO_IDCODE); - id = (u32) R_REG(&pi->regs->phy4wdatalo); - id |= (u32) R_REG(&pi->regs->phy4wdatahi) << 16; - } - pi->phy_wreg = 0; - return id; -} - -void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - u16 rval; - - rval = read_radio_reg(pi, addr); - write_radio_reg(pi, addr, (rval & val)); -} - -void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - u16 rval; - - rval = read_radio_reg(pi, addr); - write_radio_reg(pi, addr, (rval | val)); -} - -void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask) -{ - u16 rval; - - rval = read_radio_reg(pi, addr); - write_radio_reg(pi, addr, (rval ^ mask)); -} - -void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) -{ - u16 rval; - - rval = read_radio_reg(pi, addr); - write_radio_reg(pi, addr, (rval & ~mask) | (val & mask)); -} - -void write_phy_channel_reg(struct brcms_phy *pi, uint val) -{ - W_REG(&pi->regs->phychannel, val); -} - -u16 read_phy_reg(struct brcms_phy *pi, u16 addr) -{ - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - pi->phy_wreg = 0; - return R_REG(®s->phyregdata); -} - -void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - struct d11regs __iomem *regs; - - regs = pi->regs; - -#ifdef CONFIG_BCM47XX - W_REG_FLUSH(®s->phyregaddr, addr); - W_REG(®s->phyregdata, val); - if (addr == 0x72) - (void)R_REG(®s->phyregdata); -#else - W_REG((u32 __iomem *)(®s->phyregaddr), addr | (val << 16)); - if (++pi->phy_wreg >= pi->phy_wreg_limit) { - pi->phy_wreg = 0; - (void)R_REG(®s->phyversion); - } -#endif -} - -void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) & val)); - pi->phy_wreg = 0; -} - -void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) -{ - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) | val)); - pi->phy_wreg = 0; -} - -void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) -{ - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, - ((R_REG(®s->phyregdata) & ~mask) | (val & mask))); - pi->phy_wreg = 0; -} - -static void wlc_set_phy_uninitted(struct brcms_phy *pi) -{ - int i, j; - - pi->initialized = false; - - pi->tx_vos = 0xffff; - pi->nrssi_table_delta = 0x7fffffff; - pi->rc_cal = 0xffff; - pi->mintxbias = 0xffff; - pi->txpwridx = -1; - if (ISNPHY(pi)) { - pi->phy_spuravoid = SPURAVOID_DISABLE; - - if (NREV_GE(pi->pubpi.phy_rev, 3) - && NREV_LT(pi->pubpi.phy_rev, 7)) - pi->phy_spuravoid = SPURAVOID_AUTO; - - pi->nphy_papd_skip = 0; - pi->nphy_papd_epsilon_offset[0] = 0xf588; - pi->nphy_papd_epsilon_offset[1] = 0xf588; - pi->nphy_txpwr_idx[0] = 128; - pi->nphy_txpwr_idx[1] = 128; - pi->nphy_txpwrindex[0].index_internal = 40; - pi->nphy_txpwrindex[1].index_internal = 40; - pi->phy_pabias = 0; - } else { - pi->phy_spuravoid = SPURAVOID_AUTO; - } - pi->radiopwr = 0xffff; - for (i = 0; i < STATIC_NUM_RF; i++) { - for (j = 0; j < STATIC_NUM_BB; j++) - pi->stats_11b_txpower[i][j] = -1; - } -} - -struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) -{ - struct shared_phy *sh; - - sh = kzalloc(sizeof(struct shared_phy), GFP_ATOMIC); - if (sh == NULL) - return NULL; - - sh->sih = shp->sih; - sh->physhim = shp->physhim; - sh->unit = shp->unit; - sh->corerev = shp->corerev; - - sh->vid = shp->vid; - sh->did = shp->did; - sh->chip = shp->chip; - sh->chiprev = shp->chiprev; - sh->chippkg = shp->chippkg; - sh->sromrev = shp->sromrev; - sh->boardtype = shp->boardtype; - sh->boardrev = shp->boardrev; - sh->boardvendor = shp->boardvendor; - sh->boardflags = shp->boardflags; - sh->boardflags2 = shp->boardflags2; - sh->buscorerev = shp->buscorerev; - - sh->fast_timer = PHY_SW_TIMER_FAST; - sh->slow_timer = PHY_SW_TIMER_SLOW; - sh->glacial_timer = PHY_SW_TIMER_GLACIAL; - - sh->rssi_mode = RSSI_ANT_MERGE_MAX; - - return sh; -} - -static void wlc_phy_timercb_phycal(struct brcms_phy *pi) -{ - uint delay = 5; - - if (PHY_PERICAL_MPHASE_PENDING(pi)) { - if (!pi->sh->up) { - wlc_phy_cal_perical_mphase_reset(pi); - return; - } - - if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)) { - - delay = 1000; - wlc_phy_cal_perical_mphase_restart(pi); - } else - wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); - wlapi_add_timer(pi->sh->physhim, pi->phycal_timer, delay, 0); - return; - } - -} - -static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) -{ - u32 ver; - - ver = read_radio_id(pi); - - return ver; -} - -struct brcms_phy_pub * -wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, - int bandtype, struct wiphy *wiphy) -{ - struct brcms_phy *pi; - u32 sflags = 0; - uint phyversion; - u32 idcode; - int i; - - if (D11REV_IS(sh->corerev, 4)) - sflags = SISF_2G_PHY | SISF_5G_PHY; - else - sflags = ai_core_sflags(sh->sih, 0, 0); - - if (bandtype == BRCM_BAND_5G) { - if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) - return NULL; - } - - pi = sh->phy_head; - if ((sflags & SISF_DB_PHY) && pi) { - wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); - pi->refcnt++; - return &pi->pubpi_ro; - } - - pi = kzalloc(sizeof(struct brcms_phy), GFP_ATOMIC); - if (pi == NULL) - return NULL; - pi->wiphy = wiphy; - pi->regs = regs; - pi->sh = sh; - pi->phy_init_por = true; - pi->phy_wreg_limit = PHY_WREG_LIMIT; - - pi->txpwr_percent = 100; - - pi->do_initcal = true; - - pi->phycal_tempdelta = 0; - - if (bandtype == BRCM_BAND_2G && (sflags & SISF_2G_PHY)) - pi->pubpi.coreflags = SICF_GMODE; - - wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); - phyversion = R_REG(&pi->regs->phyversion); - - pi->pubpi.phy_type = PHY_TYPE(phyversion); - pi->pubpi.phy_rev = phyversion & PV_PV_MASK; - - if (pi->pubpi.phy_type == PHY_TYPE_LCNXN) { - pi->pubpi.phy_type = PHY_TYPE_N; - pi->pubpi.phy_rev += LCNXN_BASEREV; - } - pi->pubpi.phy_corenum = PHY_CORE_NUM_2; - pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; - - if (!pi->pubpi.phy_type == PHY_TYPE_N && - !pi->pubpi.phy_type == PHY_TYPE_LCN) - goto err; - - if (bandtype == BRCM_BAND_5G) { - if (!ISNPHY(pi)) - goto err; - } else if (!ISNPHY(pi) && !ISLCNPHY(pi)) { - goto err; - } - - wlc_phy_anacore((struct brcms_phy_pub *) pi, ON); - - idcode = wlc_phy_get_radio_ver(pi); - pi->pubpi.radioid = - (idcode & IDCODE_ID_MASK) >> IDCODE_ID_SHIFT; - pi->pubpi.radiorev = - (idcode & IDCODE_REV_MASK) >> IDCODE_REV_SHIFT; - pi->pubpi.radiover = - (idcode & IDCODE_VER_MASK) >> IDCODE_VER_SHIFT; - if (!VALID_RADIO(pi, pi->pubpi.radioid)) - goto err; - - wlc_phy_switch_radio((struct brcms_phy_pub *) pi, OFF); - - wlc_set_phy_uninitted(pi); - - pi->bw = WL_CHANSPEC_BW_20; - pi->radio_chanspec = (bandtype == BRCM_BAND_2G) ? - ch20mhz_chspec(1) : ch20mhz_chspec(36); - - pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; - pi->rxiq_antsel = ANT_RX_DIV_DEF; - - pi->watchdog_override = true; - - pi->cal_type_override = PHY_PERICAL_AUTO; - - pi->nphy_saved_noisevars.bufcount = 0; - - if (ISNPHY(pi)) - pi->min_txpower = PHY_TXPWR_MIN_NPHY; - else - pi->min_txpower = PHY_TXPWR_MIN; - - pi->sh->phyrxchain = 0x3; - - pi->rx2tx_biasentry = -1; - - pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - pi->phy_txcore_enable_temp = - PHY_CHAIN_TX_DISABLE_TEMP - PHY_HYSTERESIS_DELTATEMP; - pi->phy_tempsense_offset = 0; - pi->phy_txcore_heatedup = false; - - pi->nphy_lastcal_temp = -50; - - pi->phynoise_polling = true; - if (ISNPHY(pi) || ISLCNPHY(pi)) - pi->phynoise_polling = false; - - for (i = 0; i < TXP_NUM_RATES; i++) { - pi->txpwr_limit[i] = BRCMS_TXPWR_MAX; - pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; - pi->tx_user_target[i] = BRCMS_TXPWR_MAX; - } - - pi->radiopwr_override = RADIOPWR_OVERRIDE_DEF; - - pi->user_txpwr_at_rfport = false; - - if (ISNPHY(pi)) { - - pi->phycal_timer = wlapi_init_timer(pi->sh->physhim, - wlc_phy_timercb_phycal, - pi, "phycal"); - if (!pi->phycal_timer) - goto err; - - if (!wlc_phy_attach_nphy(pi)) - goto err; - - } else if (ISLCNPHY(pi)) { - if (!wlc_phy_attach_lcnphy(pi)) - goto err; - - } - - pi->refcnt++; - pi->next = pi->sh->phy_head; - sh->phy_head = pi; - - memcpy(&pi->pubpi_ro, &pi->pubpi, sizeof(struct brcms_phy_pub)); - - return &pi->pubpi_ro; - -err: - kfree(pi); - return NULL; -} - -void wlc_phy_detach(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (pih) { - if (--pi->refcnt) - return; - - if (pi->phycal_timer) { - wlapi_free_timer(pi->sh->physhim, pi->phycal_timer); - pi->phycal_timer = NULL; - } - - if (pi->sh->phy_head == pi) - pi->sh->phy_head = pi->next; - else if (pi->sh->phy_head->next == pi) - pi->sh->phy_head->next = NULL; - - if (pi->pi_fptr.detach) - (pi->pi_fptr.detach)(pi); - - kfree(pi); - } -} - -bool -wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, u16 *phyrev, - u16 *radioid, u16 *radiover) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - *phytype = (u16) pi->pubpi.phy_type; - *phyrev = (u16) pi->pubpi.phy_rev; - *radioid = pi->pubpi.radioid; - *radiover = pi->pubpi.radiorev; - - return true; -} - -bool wlc_phy_get_encore(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - return pi->pubpi.abgphy_encore; -} - -u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - return pi->pubpi.coreflags; -} - -void wlc_phy_anacore(struct brcms_phy_pub *pih, bool on) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (ISNPHY(pi)) { - if (on) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0xa6, 0x0d); - write_phy_reg(pi, 0x8f, 0x0); - write_phy_reg(pi, 0xa7, 0x0d); - write_phy_reg(pi, 0xa5, 0x0); - } else { - write_phy_reg(pi, 0xa5, 0x0); - } - } else { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0x8f, 0x07ff); - write_phy_reg(pi, 0xa6, 0x0fd); - write_phy_reg(pi, 0xa5, 0x07ff); - write_phy_reg(pi, 0xa7, 0x0fd); - } else { - write_phy_reg(pi, 0xa5, 0x7fff); - } - } - } else if (ISLCNPHY(pi)) { - if (on) { - and_phy_reg(pi, 0x43b, - ~((0x1 << 0) | (0x1 << 1) | (0x1 << 2))); - } else { - or_phy_reg(pi, 0x43c, - (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); - or_phy_reg(pi, 0x43b, - (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); - } - } -} - -u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - u32 phy_bw_clkbits = 0; - - if (pi && (ISNPHY(pi) || ISLCNPHY(pi))) { - switch (pi->bw) { - case WL_CHANSPEC_BW_10: - phy_bw_clkbits = SICF_BW10; - break; - case WL_CHANSPEC_BW_20: - phy_bw_clkbits = SICF_BW20; - break; - case WL_CHANSPEC_BW_40: - phy_bw_clkbits = SICF_BW40; - break; - default: - break; - } - } - - return phy_bw_clkbits; -} - -void wlc_phy_por_inform(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->phy_init_por = true; -} - -void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->edcrs_threshold_lock = lock; - - write_phy_reg(pi, 0x22c, 0x46b); - write_phy_reg(pi, 0x22d, 0x46b); - write_phy_reg(pi, 0x22e, 0x3c0); - write_phy_reg(pi, 0x22f, 0x3c0); -} - -void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->do_initcal = initcal; -} - -void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *pih, bool newstate) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (!pi || !pi->sh) - return; - - pi->sh->clk = newstate; -} - -void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (!pi || !pi->sh) - return; - - pi->sh->up = newstate; -} - -void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) -{ - u32 mc; - void (*phy_init)(struct brcms_phy *) = NULL; - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (pi->init_in_progress) - return; - - pi->init_in_progress = true; - - pi->radio_chanspec = chanspec; - - mc = R_REG(&pi->regs->maccontrol); - if (WARN(mc & MCTL_EN_MAC, "HW error MAC running on init")) - return; - - if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) - pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - - if (WARN(!(ai_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA), - "HW error SISF_FCLKA\n")) - return; - - phy_init = pi->pi_fptr.init; - - if (phy_init == NULL) - return; - - wlc_phy_anacore(pih, ON); - - if (CHSPEC_BW(pi->radio_chanspec) != pi->bw) - wlapi_bmac_bw_set(pi->sh->physhim, - CHSPEC_BW(pi->radio_chanspec)); - - pi->nphy_gain_boost = true; - - wlc_phy_switch_radio((struct brcms_phy_pub *) pi, ON); - - (*phy_init)(pi); - - pi->phy_init_por = false; - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlc_phy_do_dummy_tx(pi, true, OFF); - - if (!(ISNPHY(pi))) - wlc_phy_txpower_update_shm(pi); - - wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, pi->sh->rx_antdiv); - - pi->init_in_progress = false; -} - -void wlc_phy_cal_init(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - void (*cal_init)(struct brcms_phy *) = NULL; - - if (WARN((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) != 0, - "HW error: MAC enabled during phy cal\n")) - return; - - if (!pi->initialized) { - cal_init = pi->pi_fptr.calinit; - if (cal_init) - (*cal_init)(pi); - - pi->initialized = true; - } -} - -int wlc_phy_down(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - int callbacks = 0; - - if (pi->phycal_timer - && !wlapi_del_timer(pi->sh->physhim, pi->phycal_timer)) - callbacks++; - - pi->nphy_iqcal_chanspec_2G = 0; - pi->nphy_iqcal_chanspec_5G = 0; - - return callbacks; -} - -void -wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset, - u16 tblAddr, u16 tblDataHi, u16 tblDataLo) -{ - write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); - - pi->tbl_data_hi = tblDataHi; - pi->tbl_data_lo = tblDataLo; - - if (pi->sh->chip == BCM43224_CHIP_ID && - pi->sh->chiprev == 1) { - pi->tbl_addr = tblAddr; - pi->tbl_save_id = tbl_id; - pi->tbl_save_offset = tbl_offset; - } -} - -void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val) -{ - if ((pi->sh->chip == BCM43224_CHIP_ID) && - (pi->sh->chiprev == 1) && - (pi->tbl_save_id == NPHY_TBL_ID_ANTSWCTRLLUT)) { - read_phy_reg(pi, pi->tbl_data_lo); - - write_phy_reg(pi, pi->tbl_addr, - (pi->tbl_save_id << 10) | pi->tbl_save_offset); - pi->tbl_save_offset++; - } - - if (width == 32) { - write_phy_reg(pi, pi->tbl_data_hi, (u16) (val >> 16)); - write_phy_reg(pi, pi->tbl_data_lo, (u16) val); - } else { - write_phy_reg(pi, pi->tbl_data_lo, (u16) val); - } -} - -void -wlc_phy_write_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, - u16 tblAddr, u16 tblDataHi, u16 tblDataLo) -{ - uint idx; - uint tbl_id = ptbl_info->tbl_id; - uint tbl_offset = ptbl_info->tbl_offset; - uint tbl_width = ptbl_info->tbl_width; - const u8 *ptbl_8b = (const u8 *)ptbl_info->tbl_ptr; - const u16 *ptbl_16b = (const u16 *)ptbl_info->tbl_ptr; - const u32 *ptbl_32b = (const u32 *)ptbl_info->tbl_ptr; - - write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); - - for (idx = 0; idx < ptbl_info->tbl_len; idx++) { - - if ((pi->sh->chip == BCM43224_CHIP_ID) && - (pi->sh->chiprev == 1) && - (tbl_id == NPHY_TBL_ID_ANTSWCTRLLUT)) { - read_phy_reg(pi, tblDataLo); - - write_phy_reg(pi, tblAddr, - (tbl_id << 10) | (tbl_offset + idx)); - } - - if (tbl_width == 32) { - write_phy_reg(pi, tblDataHi, - (u16) (ptbl_32b[idx] >> 16)); - write_phy_reg(pi, tblDataLo, (u16) ptbl_32b[idx]); - } else if (tbl_width == 16) { - write_phy_reg(pi, tblDataLo, ptbl_16b[idx]); - } else { - write_phy_reg(pi, tblDataLo, ptbl_8b[idx]); - } - } -} - -void -wlc_phy_read_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, - u16 tblAddr, u16 tblDataHi, u16 tblDataLo) -{ - uint idx; - uint tbl_id = ptbl_info->tbl_id; - uint tbl_offset = ptbl_info->tbl_offset; - uint tbl_width = ptbl_info->tbl_width; - u8 *ptbl_8b = (u8 *)ptbl_info->tbl_ptr; - u16 *ptbl_16b = (u16 *)ptbl_info->tbl_ptr; - u32 *ptbl_32b = (u32 *)ptbl_info->tbl_ptr; - - write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); - - for (idx = 0; idx < ptbl_info->tbl_len; idx++) { - - if ((pi->sh->chip == BCM43224_CHIP_ID) && - (pi->sh->chiprev == 1)) { - (void)read_phy_reg(pi, tblDataLo); - - write_phy_reg(pi, tblAddr, - (tbl_id << 10) | (tbl_offset + idx)); - } - - if (tbl_width == 32) { - ptbl_32b[idx] = read_phy_reg(pi, tblDataLo); - ptbl_32b[idx] |= (read_phy_reg(pi, tblDataHi) << 16); - } else if (tbl_width == 16) { - ptbl_16b[idx] = read_phy_reg(pi, tblDataLo); - } else { - ptbl_8b[idx] = (u8) read_phy_reg(pi, tblDataLo); - } - } -} - -uint -wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, - struct radio_20xx_regs *radioregs) -{ - uint i = 0; - - do { - if (radioregs[i].do_init) - write_radio_reg(pi, radioregs[i].address, - (u16) radioregs[i].init); - - i++; - } while (radioregs[i].address != 0xffff); - - return i; -} - -uint -wlc_phy_init_radio_regs(struct brcms_phy *pi, - const struct radio_regs *radioregs, - u16 core_offset) -{ - uint i = 0; - uint count = 0; - - do { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (radioregs[i].do_init_a) { - write_radio_reg(pi, - radioregs[i]. - address | core_offset, - (u16) radioregs[i].init_a); - if (ISNPHY(pi) && (++count % 4 == 0)) - BRCMS_PHY_WAR_PR51571(pi); - } - } else { - if (radioregs[i].do_init_g) { - write_radio_reg(pi, - radioregs[i]. - address | core_offset, - (u16) radioregs[i].init_g); - if (ISNPHY(pi) && (++count % 4 == 0)) - BRCMS_PHY_WAR_PR51571(pi); - } - } - - i++; - } while (radioregs[i].address != 0xffff); - - return i; -} - -void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) -{ -#define DUMMY_PKT_LEN 20 - struct d11regs __iomem *regs = pi->regs; - int i, count; - u8 ofdmpkt[DUMMY_PKT_LEN] = { - 0xcc, 0x01, 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 - }; - u8 cckpkt[DUMMY_PKT_LEN] = { - 0x6e, 0x84, 0x0b, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 - }; - u32 *dummypkt; - - dummypkt = (u32 *) (ofdm ? ofdmpkt : cckpkt); - wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, - dummypkt); - - W_REG(®s->xmtsel, 0); - - if (D11REV_GE(pi->sh->corerev, 11)) - W_REG(®s->wepctl, 0x100); - else - W_REG(®s->wepctl, 0); - - W_REG(®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); - if (ISNPHY(pi) || ISLCNPHY(pi)) - W_REG(®s->txe_phyctl1, 0x1A02); - - W_REG(®s->txe_wm_0, 0); - W_REG(®s->txe_wm_1, 0); - - W_REG(®s->xmttplatetxptr, 0); - W_REG(®s->xmttxcnt, DUMMY_PKT_LEN); - - W_REG(®s->xmtsel, ((8 << 8) | (1 << 5) | (1 << 2) | 2)); - - W_REG(®s->txe_ctl, 0); - - if (!pa_on) { - if (ISNPHY(pi)) - wlc_phy_pa_override_nphy(pi, OFF); - } - - if (ISNPHY(pi) || ISLCNPHY(pi)) - W_REG(®s->txe_aux, 0xD0); - else - W_REG(®s->txe_aux, ((1 << 5) | (1 << 4))); - - (void)R_REG(®s->txe_aux); - - i = 0; - count = ofdm ? 30 : 250; - while ((i++ < count) - && (R_REG(®s->txe_status) & (1 << 7))) - udelay(10); - - i = 0; - - while ((i++ < 10) - && ((R_REG(®s->txe_status) & (1 << 10)) == 0)) - udelay(10); - - i = 0; - - while ((i++ < 10) && ((R_REG(®s->ifsstat) & (1 << 8)))) - udelay(10); - - if (!pa_on) { - if (ISNPHY(pi)) - wlc_phy_pa_override_nphy(pi, ON); - } -} - -void wlc_phy_hold_upd(struct brcms_phy_pub *pih, u32 id, bool set) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (set) - mboolset(pi->measure_hold, id); - else - mboolclr(pi->measure_hold, id); - - return; -} - -void wlc_phy_mute_upd(struct brcms_phy_pub *pih, bool mute, u32 flags) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (mute) - mboolset(pi->measure_hold, PHY_HOLD_FOR_MUTE); - else - mboolclr(pi->measure_hold, PHY_HOLD_FOR_MUTE); - - if (!mute && (flags & PHY_MUTE_FOR_PREISM)) - pi->nphy_perical_last = pi->sh->now - pi->sh->glacial_timer; - return; -} - -void wlc_phy_clear_tssi(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (ISNPHY(pi)) { - return; - } else { - wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_0, NULL_TSSI_W); - wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_1, NULL_TSSI_W); - wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_0, NULL_TSSI_W); - wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_1, NULL_TSSI_W); - } -} - -static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi) -{ - return false; -} - -void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - (void)R_REG(&pi->regs->maccontrol); - - if (ISNPHY(pi)) { - wlc_phy_switch_radio_nphy(pi, on); - } else if (ISLCNPHY(pi)) { - if (on) { - and_phy_reg(pi, 0x44c, - ~((0x1 << 8) | - (0x1 << 9) | - (0x1 << 10) | (0x1 << 11) | (0x1 << 12))); - and_phy_reg(pi, 0x4b0, ~((0x1 << 3) | (0x1 << 11))); - and_phy_reg(pi, 0x4f9, ~(0x1 << 3)); - } else { - and_phy_reg(pi, 0x44d, - ~((0x1 << 10) | - (0x1 << 11) | - (0x1 << 12) | (0x1 << 13) | (0x1 << 14))); - or_phy_reg(pi, 0x44c, - (0x1 << 8) | - (0x1 << 9) | - (0x1 << 10) | (0x1 << 11) | (0x1 << 12)); - - and_phy_reg(pi, 0x4b7, ~((0x7f << 8))); - and_phy_reg(pi, 0x4b1, ~((0x1 << 13))); - or_phy_reg(pi, 0x4b0, (0x1 << 3) | (0x1 << 11)); - and_phy_reg(pi, 0x4fa, ~((0x1 << 3))); - or_phy_reg(pi, 0x4f9, (0x1 << 3)); - } - } -} - -u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - return pi->bw; -} - -void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->bw = bw; -} - -void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - pi->radio_chanspec = newch; - -} - -u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - return pi->radio_chanspec; -} - -void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - u16 m_cur_channel; - void (*chanspec_set)(struct brcms_phy *, u16) = NULL; - m_cur_channel = CHSPEC_CHANNEL(chanspec); - if (CHSPEC_IS5G(chanspec)) - m_cur_channel |= D11_CURCHANNEL_5G; - if (CHSPEC_IS40(chanspec)) - m_cur_channel |= D11_CURCHANNEL_40; - wlapi_bmac_write_shm(pi->sh->physhim, M_CURCHANNEL, m_cur_channel); - - chanspec_set = pi->pi_fptr.chanset; - if (chanspec_set) - (*chanspec_set)(pi, chanspec); - -} - -int wlc_phy_chanspec_freq2bandrange_lpssn(uint freq) -{ - int range = -1; - - if (freq < 2500) - range = WL_CHAN_FREQ_RANGE_2G; - else if (freq <= 5320) - range = WL_CHAN_FREQ_RANGE_5GL; - else if (freq <= 5700) - range = WL_CHAN_FREQ_RANGE_5GM; - else - range = WL_CHAN_FREQ_RANGE_5GH; - - return range; -} - -int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, u16 chanspec) -{ - int range = -1; - uint channel = CHSPEC_CHANNEL(chanspec); - uint freq = wlc_phy_channel2freq(channel); - - if (ISNPHY(pi)) - range = wlc_phy_get_chan_freq_range_nphy(pi, channel); - else if (ISLCNPHY(pi)) - range = wlc_phy_chanspec_freq2bandrange_lpssn(freq); - - return range; -} - -void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi, - bool wide_filter) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->channel_14_wide_filter = wide_filter; - -} - -int wlc_phy_channel2freq(uint channel) -{ - uint i; - - for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) - if (chan_info_all[i].chan == channel) - return chan_info_all[i].freq; - return 0; -} - -void -wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, - struct brcms_chanvec *channels) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - uint i; - uint channel; - - memset(channels, 0, sizeof(struct brcms_chanvec)); - - for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { - channel = chan_info_all[i].chan; - - if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) - && (channel <= LAST_REF5_CHANNUM)) - continue; - - if ((band == BRCM_BAND_2G && channel <= CH_MAX_2G_CHANNEL) || - (band == BRCM_BAND_5G && channel > CH_MAX_2G_CHANNEL)) - setbit(channels->vec, channel); - } -} - -u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - uint i; - uint channel; - u16 chspec; - - for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { - channel = chan_info_all[i].chan; - - if (ISNPHY(pi) && pi->bw == WL_CHANSPEC_BW_40) { - uint j; - - for (j = 0; j < ARRAY_SIZE(chan_info_all); j++) { - if (chan_info_all[j].chan == - channel + CH_10MHZ_APART) - break; - } - - if (j == ARRAY_SIZE(chan_info_all)) - continue; - - channel = upper_20_sb(channel); - chspec = channel | WL_CHANSPEC_BW_40 | - WL_CHANSPEC_CTL_SB_LOWER; - if (band == BRCM_BAND_2G) - chspec |= WL_CHANSPEC_BAND_2G; - else - chspec |= WL_CHANSPEC_BAND_5G; - } else - chspec = ch20mhz_chspec(channel); - - if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) - && (channel <= LAST_REF5_CHANNUM)) - continue; - - if ((band == BRCM_BAND_2G && channel <= CH_MAX_2G_CHANNEL) || - (band == BRCM_BAND_5G && channel > CH_MAX_2G_CHANNEL)) - return chspec; - } - - return (u16) INVCHANSPEC; -} - -int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - *qdbm = pi->tx_user_target[0]; - if (override != NULL) - *override = pi->txpwroverride; - return 0; -} - -void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi, - struct txpwr_limits *txpwr) -{ - bool mac_enabled = false; - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - memcpy(&pi->tx_user_target[TXP_FIRST_CCK], - &txpwr->cck[0], BRCMS_NUM_RATES_CCK); - - memcpy(&pi->tx_user_target[TXP_FIRST_OFDM], - &txpwr->ofdm[0], BRCMS_NUM_RATES_OFDM); - memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_20_CDD], - &txpwr->ofdm_cdd[0], BRCMS_NUM_RATES_OFDM); - - memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_SISO], - &txpwr->ofdm_40_siso[0], BRCMS_NUM_RATES_OFDM); - memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_CDD], - &txpwr->ofdm_40_cdd[0], BRCMS_NUM_RATES_OFDM); - - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SISO], - &txpwr->mcs_20_siso[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_CDD], - &txpwr->mcs_20_cdd[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_STBC], - &txpwr->mcs_20_stbc[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SDM], - &txpwr->mcs_20_mimo[0], BRCMS_NUM_RATES_MCS_2_STREAM); - - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SISO], - &txpwr->mcs_40_siso[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_CDD], - &txpwr->mcs_40_cdd[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_STBC], - &txpwr->mcs_40_stbc[0], BRCMS_NUM_RATES_MCS_1_STREAM); - memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SDM], - &txpwr->mcs_40_mimo[0], BRCMS_NUM_RATES_MCS_2_STREAM); - - if (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) - mac_enabled = true; - - if (mac_enabled) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_txpower_recalc_target(pi); - wlc_phy_cal_txpower_recalc_sw(pi); - - if (mac_enabled) - wlapi_enable_mac(pi->sh->physhim); -} - -int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - int i; - - if (qdbm > 127) - return -EINVAL; - - for (i = 0; i < TXP_NUM_RATES; i++) - pi->tx_user_target[i] = (u8) qdbm; - - pi->txpwroverride = false; - - if (pi->sh->up) { - if (!SCAN_INPROG_PHY(pi)) { - bool suspend; - - suspend = (0 == (R_REG(&pi->regs->maccontrol) & - MCTL_EN_MAC)); - - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_txpower_recalc_target(pi); - wlc_phy_cal_txpower_recalc_sw(pi); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - } - } - return 0; -} - -void -wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint channel, u8 *min_pwr, - u8 *max_pwr, int txp_rate_idx) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - uint i; - - *min_pwr = pi->min_txpower * BRCMS_TXPWR_DB_FACTOR; - - if (ISNPHY(pi)) { - if (txp_rate_idx < 0) - txp_rate_idx = TXP_FIRST_CCK; - wlc_phy_txpower_sromlimit_get_nphy(pi, channel, max_pwr, - (u8) txp_rate_idx); - - } else if ((channel <= CH_MAX_2G_CHANNEL)) { - if (txp_rate_idx < 0) - txp_rate_idx = TXP_FIRST_CCK; - *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx]; - } else { - - *max_pwr = BRCMS_TXPWR_MAX; - - if (txp_rate_idx < 0) - txp_rate_idx = TXP_FIRST_OFDM; - - for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { - if (channel == chan_info_all[i].chan) - break; - } - - if (pi->hwtxpwr) { - *max_pwr = pi->hwtxpwr[i]; - } else { - - if ((i >= FIRST_MID_5G_CHAN) && (i <= LAST_MID_5G_CHAN)) - *max_pwr = - pi->tx_srom_max_rate_5g_mid[txp_rate_idx]; - if ((i >= FIRST_HIGH_5G_CHAN) - && (i <= LAST_HIGH_5G_CHAN)) - *max_pwr = - pi->tx_srom_max_rate_5g_hi[txp_rate_idx]; - if ((i >= FIRST_LOW_5G_CHAN) && (i <= LAST_LOW_5G_CHAN)) - *max_pwr = - pi->tx_srom_max_rate_5g_low[txp_rate_idx]; - } - } -} - -void -wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan, - u8 *max_txpwr, u8 *min_txpwr) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - u8 tx_pwr_max = 0; - u8 tx_pwr_min = 255; - u8 max_num_rate; - u8 maxtxpwr, mintxpwr, rate, pactrl; - - pactrl = 0; - - max_num_rate = ISNPHY(pi) ? TXP_NUM_RATES : - ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + - 1) : (TXP_LAST_OFDM + 1); - - for (rate = 0; rate < max_num_rate; rate++) { - - wlc_phy_txpower_sromlimit(ppi, chan, &mintxpwr, &maxtxpwr, - rate); - - maxtxpwr = (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; - - maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0; - - tx_pwr_max = max(tx_pwr_max, maxtxpwr); - tx_pwr_min = min(tx_pwr_min, maxtxpwr); - } - *max_txpwr = tx_pwr_max; - *min_txpwr = tx_pwr_min; -} - -void -wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, uint bandunit, - s32 *max_pwr, s32 *min_pwr, u32 *step_pwr) -{ - return; -} - -u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - return pi->tx_power_min; -} - -u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - return pi->tx_power_max; -} - -static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi) -{ - if (ISLCNPHY(pi)) - return wlc_lcnphy_vbatsense(pi, 0); - else - return 0; -} - -static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi) -{ - if (ISLCNPHY(pi)) - return wlc_lcnphy_tempsense_degree(pi, 0); - else - return 0; -} - -static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band) -{ - u8 i; - s8 temp, vbat; - - for (i = 0; i < TXP_NUM_RATES; i++) - pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; - - vbat = wlc_phy_env_measure_vbat(pi); - temp = wlc_phy_env_measure_temperature(pi); - -} - -static s8 -wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, u32 band, - u8 rate) -{ - s8 offset = 0; - - if (!pi->user_txpwr_at_rfport) - return offset; - return offset; -} - -void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) -{ - u8 maxtxpwr, mintxpwr, rate, pactrl; - uint target_chan; - u8 tx_pwr_target[TXP_NUM_RATES]; - u8 tx_pwr_max = 0; - u8 tx_pwr_min = 255; - u8 tx_pwr_max_rate_ind = 0; - u8 max_num_rate; - u8 start_rate = 0; - u16 chspec; - u32 band = CHSPEC2BAND(pi->radio_chanspec); - void (*txpwr_recalc_fn)(struct brcms_phy *) = NULL; - - chspec = pi->radio_chanspec; - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) - target_chan = CHSPEC_CHANNEL(chspec); - else if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) - target_chan = upper_20_sb(CHSPEC_CHANNEL(chspec)); - else - target_chan = lower_20_sb(CHSPEC_CHANNEL(chspec)); - - pactrl = 0; - if (ISLCNPHY(pi)) { - u32 offset_mcs, i; - - if (CHSPEC_IS40(pi->radio_chanspec)) { - offset_mcs = pi->mcs40_po; - for (i = TXP_FIRST_SISO_MCS_20; - i <= TXP_LAST_SISO_MCS_20; i++) { - pi->tx_srom_max_rate_2g[i - 8] = - pi->tx_srom_max_2g - - ((offset_mcs & 0xf) * 2); - offset_mcs >>= 4; - } - } else { - offset_mcs = pi->mcs20_po; - for (i = TXP_FIRST_SISO_MCS_20; - i <= TXP_LAST_SISO_MCS_20; i++) { - pi->tx_srom_max_rate_2g[i - 8] = - pi->tx_srom_max_2g - - ((offset_mcs & 0xf) * 2); - offset_mcs >>= 4; - } - } - } - - max_num_rate = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : - ((ISLCNPHY(pi)) ? - (TXP_LAST_SISO_MCS_20 + 1) : (TXP_LAST_OFDM + 1))); - - wlc_phy_upd_env_txpwr_rate_limits(pi, band); - - for (rate = start_rate; rate < max_num_rate; rate++) { - - tx_pwr_target[rate] = pi->tx_user_target[rate]; - - if (pi->user_txpwr_at_rfport) - tx_pwr_target[rate] += - wlc_user_txpwr_antport_to_rfport(pi, - target_chan, - band, - rate); - - wlc_phy_txpower_sromlimit((struct brcms_phy_pub *) pi, - target_chan, - &mintxpwr, &maxtxpwr, rate); - - maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); - - maxtxpwr = (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0; - - maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0; - - maxtxpwr = min(maxtxpwr, tx_pwr_target[rate]); - - if (pi->txpwr_percent <= 100) - maxtxpwr = (maxtxpwr * pi->txpwr_percent) / 100; - - tx_pwr_target[rate] = max(maxtxpwr, mintxpwr); - - tx_pwr_target[rate] = - min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); - - if (tx_pwr_target[rate] > tx_pwr_max) - tx_pwr_max_rate_ind = rate; - - tx_pwr_max = max(tx_pwr_max, tx_pwr_target[rate]); - tx_pwr_min = min(tx_pwr_min, tx_pwr_target[rate]); - } - - memset(pi->tx_power_offset, 0, sizeof(pi->tx_power_offset)); - pi->tx_power_max = tx_pwr_max; - pi->tx_power_min = tx_pwr_min; - pi->tx_power_max_rate_ind = tx_pwr_max_rate_ind; - for (rate = 0; rate < max_num_rate; rate++) { - - pi->tx_power_target[rate] = tx_pwr_target[rate]; - - if (!pi->hwpwrctrl || ISNPHY(pi)) - pi->tx_power_offset[rate] = - pi->tx_power_max - pi->tx_power_target[rate]; - else - pi->tx_power_offset[rate] = - pi->tx_power_target[rate] - pi->tx_power_min; - } - - txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc; - if (txpwr_recalc_fn) - (*txpwr_recalc_fn)(pi); -} - -static void -wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, - u16 chanspec) -{ - u8 tmp_txpwr_limit[2 * BRCMS_NUM_RATES_OFDM]; - u8 *txpwr_ptr1 = NULL, *txpwr_ptr2 = NULL; - int rate_start_index = 0, rate1, rate2, k; - - for (rate1 = WL_TX_POWER_CCK_FIRST, rate2 = 0; - rate2 < WL_TX_POWER_CCK_NUM; rate1++, rate2++) - pi->txpwr_limit[rate1] = txpwr->cck[rate2]; - - for (rate1 = WL_TX_POWER_OFDM_FIRST, rate2 = 0; - rate2 < WL_TX_POWER_OFDM_NUM; rate1++, rate2++) - pi->txpwr_limit[rate1] = txpwr->ofdm[rate2]; - - if (ISNPHY(pi)) { - - for (k = 0; k < 4; k++) { - switch (k) { - case 0: - - txpwr_ptr1 = txpwr->mcs_20_siso; - txpwr_ptr2 = txpwr->ofdm; - rate_start_index = WL_TX_POWER_OFDM_FIRST; - break; - case 1: - - txpwr_ptr1 = txpwr->mcs_20_cdd; - txpwr_ptr2 = txpwr->ofdm_cdd; - rate_start_index = WL_TX_POWER_OFDM20_CDD_FIRST; - break; - case 2: - - txpwr_ptr1 = txpwr->mcs_40_siso; - txpwr_ptr2 = txpwr->ofdm_40_siso; - rate_start_index = - WL_TX_POWER_OFDM40_SISO_FIRST; - break; - case 3: - - txpwr_ptr1 = txpwr->mcs_40_cdd; - txpwr_ptr2 = txpwr->ofdm_40_cdd; - rate_start_index = WL_TX_POWER_OFDM40_CDD_FIRST; - break; - } - - for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; - rate2++) { - tmp_txpwr_limit[rate2] = 0; - tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] = - txpwr_ptr1[rate2]; - } - wlc_phy_mcs_to_ofdm_powers_nphy( - tmp_txpwr_limit, 0, - BRCMS_NUM_RATES_OFDM - - 1, BRCMS_NUM_RATES_OFDM); - for (rate1 = rate_start_index, rate2 = 0; - rate2 < BRCMS_NUM_RATES_OFDM; rate1++, rate2++) - pi->txpwr_limit[rate1] = - min(txpwr_ptr2[rate2], - tmp_txpwr_limit[rate2]); - } - - for (k = 0; k < 4; k++) { - switch (k) { - case 0: - - txpwr_ptr1 = txpwr->ofdm; - txpwr_ptr2 = txpwr->mcs_20_siso; - rate_start_index = WL_TX_POWER_MCS20_SISO_FIRST; - break; - case 1: - - txpwr_ptr1 = txpwr->ofdm_cdd; - txpwr_ptr2 = txpwr->mcs_20_cdd; - rate_start_index = WL_TX_POWER_MCS20_CDD_FIRST; - break; - case 2: - - txpwr_ptr1 = txpwr->ofdm_40_siso; - txpwr_ptr2 = txpwr->mcs_40_siso; - rate_start_index = WL_TX_POWER_MCS40_SISO_FIRST; - break; - case 3: - - txpwr_ptr1 = txpwr->ofdm_40_cdd; - txpwr_ptr2 = txpwr->mcs_40_cdd; - rate_start_index = WL_TX_POWER_MCS40_CDD_FIRST; - break; - } - for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; - rate2++) { - tmp_txpwr_limit[rate2] = 0; - tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] = - txpwr_ptr1[rate2]; - } - wlc_phy_ofdm_to_mcs_powers_nphy( - tmp_txpwr_limit, 0, - BRCMS_NUM_RATES_OFDM - - 1, BRCMS_NUM_RATES_OFDM); - for (rate1 = rate_start_index, rate2 = 0; - rate2 < BRCMS_NUM_RATES_MCS_1_STREAM; - rate1++, rate2++) - pi->txpwr_limit[rate1] = - min(txpwr_ptr2[rate2], - tmp_txpwr_limit[rate2]); - } - - for (k = 0; k < 2; k++) { - switch (k) { - case 0: - - rate_start_index = WL_TX_POWER_MCS20_STBC_FIRST; - txpwr_ptr1 = txpwr->mcs_20_stbc; - break; - case 1: - - rate_start_index = WL_TX_POWER_MCS40_STBC_FIRST; - txpwr_ptr1 = txpwr->mcs_40_stbc; - break; - } - for (rate1 = rate_start_index, rate2 = 0; - rate2 < BRCMS_NUM_RATES_MCS_1_STREAM; - rate1++, rate2++) - pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; - } - - for (k = 0; k < 2; k++) { - switch (k) { - case 0: - - rate_start_index = WL_TX_POWER_MCS20_SDM_FIRST; - txpwr_ptr1 = txpwr->mcs_20_mimo; - break; - case 1: - - rate_start_index = WL_TX_POWER_MCS40_SDM_FIRST; - txpwr_ptr1 = txpwr->mcs_40_mimo; - break; - } - for (rate1 = rate_start_index, rate2 = 0; - rate2 < BRCMS_NUM_RATES_MCS_2_STREAM; - rate1++, rate2++) - pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; - } - - pi->txpwr_limit[WL_TX_POWER_MCS_32] = txpwr->mcs32; - - pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST] = - min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST], - pi->txpwr_limit[WL_TX_POWER_MCS_32]); - pi->txpwr_limit[WL_TX_POWER_MCS_32] = - pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST]; - } -} - -void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, u8 txpwr_percent) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->txpwr_percent = txpwr_percent; -} - -void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->sh->machwcap = machwcap; -} - -void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - u16 rxc; - rxc = 0; - - if (start_end == ON) { - if (!ISNPHY(pi)) - return; - - if (NREV_IS(pi->pubpi.phy_rev, 3) - || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(&pi->regs->phyregaddr, 0xa0); - (void)R_REG(&pi->regs->phyregaddr); - rxc = R_REG(&pi->regs->phyregdata); - W_REG(&pi->regs->phyregdata, - (0x1 << 15) | rxc); - } - } else { - if (NREV_IS(pi->pubpi.phy_rev, 3) - || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(&pi->regs->phyregaddr, 0xa0); - (void)R_REG(&pi->regs->phyregaddr); - W_REG(&pi->regs->phyregdata, rxc); - } - - wlc_phy_por_inform(ppi); - } -} - -void -wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *txpwr, - u16 chanspec) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - wlc_phy_txpower_reg_limit_calc(pi, txpwr, chanspec); - - if (ISLCNPHY(pi)) { - int i, j; - for (i = TXP_FIRST_OFDM_20_CDD, j = 0; - j < BRCMS_NUM_RATES_MCS_1_STREAM; i++, j++) { - if (txpwr->mcs_20_siso[j]) - pi->txpwr_limit[i] = txpwr->mcs_20_siso[j]; - else - pi->txpwr_limit[i] = txpwr->ofdm[j]; - } - } - - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_txpower_recalc_target(pi); - wlc_phy_cal_txpower_recalc_sw(pi); - wlapi_enable_mac(pi->sh->physhim); -} - -void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->ofdm_rateset_war = war; -} - -void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->bf_preempt_4306 = bf_preempt; -} - -void wlc_phy_txpower_update_shm(struct brcms_phy *pi) -{ - int j; - if (ISNPHY(pi)) - return; - - if (!pi->sh->clk) - return; - - if (pi->hwpwrctrl) { - u16 offset; - - wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_MAX, 63); - wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_N, - 1 << NUM_TSSI_FRAMES); - - wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_TARGET, - pi->tx_power_min << NUM_TSSI_FRAMES); - - wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_CUR, - pi->hwpwr_txcur); - - for (j = TXP_FIRST_OFDM; j <= TXP_LAST_OFDM; j++) { - const u8 ucode_ofdm_rates[] = { - 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c - }; - offset = wlapi_bmac_rate_shm_offset( - pi->sh->physhim, - ucode_ofdm_rates[j - TXP_FIRST_OFDM]); - wlapi_bmac_write_shm(pi->sh->physhim, offset + 6, - pi->tx_power_offset[j]); - wlapi_bmac_write_shm(pi->sh->physhim, offset + 14, - -(pi->tx_power_offset[j] / 2)); - } - - wlapi_bmac_mhf(pi->sh->physhim, MHF2, MHF2_HWPWRCTL, - MHF2_HWPWRCTL, BRCM_BAND_ALL); - } else { - int i; - - for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) - pi->tx_power_offset[i] = - (u8) roundup(pi->tx_power_offset[i], 8); - wlapi_bmac_write_shm(pi->sh->physhim, M_OFDM_OFFSET, - (u16) - ((pi->tx_power_offset[TXP_FIRST_OFDM] - + 7) >> 3)); - } -} - -bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - if (ISNPHY(pi)) - return pi->nphy_txpwrctrl; - else - return pi->hwpwrctrl; -} - -void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - bool suspend; - - if (!pi->hwpwrctrl_capable) - return; - - pi->hwpwrctrl = hwpwrctrl; - pi->nphy_txpwrctrl = hwpwrctrl; - pi->txpwrctrl = hwpwrctrl; - - if (ISNPHY(pi)) { - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); - if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) - wlc_phy_txpwr_fixpower_nphy(pi); - else - mod_phy_reg(pi, 0x1e7, (0x7f << 0), - pi->saved_txpwr_idx); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - } -} - -void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi) -{ - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->ipa2g_on = (pi->srom_fem2g.extpagain == 2); - pi->ipa5g_on = (pi->srom_fem5g.extpagain == 2); - } else { - pi->ipa2g_on = false; - pi->ipa5g_on = false; - } -} - -static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) -{ - s16 tx0_status, tx1_status; - u16 estPower1, estPower2; - u8 pwr0, pwr1, adj_pwr0, adj_pwr1; - u32 est_pwr; - - estPower1 = read_phy_reg(pi, 0x118); - estPower2 = read_phy_reg(pi, 0x119); - - if ((estPower1 & (0x1 << 8)) == (0x1 << 8)) - pwr0 = (u8) (estPower1 & (0xff << 0)) >> 0; - else - pwr0 = 0x80; - - if ((estPower2 & (0x1 << 8)) == (0x1 << 8)) - pwr1 = (u8) (estPower2 & (0xff << 0)) >> 0; - else - pwr1 = 0x80; - - tx0_status = read_phy_reg(pi, 0x1ed); - tx1_status = read_phy_reg(pi, 0x1ee); - - if ((tx0_status & (0x1 << 15)) == (0x1 << 15)) - adj_pwr0 = (u8) (tx0_status & (0xff << 0)) >> 0; - else - adj_pwr0 = 0x80; - if ((tx1_status & (0x1 << 15)) == (0x1 << 15)) - adj_pwr1 = (u8) (tx1_status & (0xff << 0)) >> 0; - else - adj_pwr1 = 0x80; - - est_pwr = (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) | - adj_pwr1); - - return est_pwr; -} - -void -wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power, - uint channel) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - uint rate, num_rates; - u8 min_pwr, max_pwr; - -#if WL_TX_POWER_RATES != TXP_NUM_RATES -#error "struct tx_power out of sync with this fn" -#endif - - if (ISNPHY(pi)) { - power->rf_cores = 2; - power->flags |= (WL_TX_POWER_F_MIMO); - if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) - power->flags |= - (WL_TX_POWER_F_ENABLED | WL_TX_POWER_F_HW); - } else if (ISLCNPHY(pi)) { - power->rf_cores = 1; - power->flags |= (WL_TX_POWER_F_SISO); - if (pi->radiopwr_override == RADIOPWR_OVERRIDE_DEF) - power->flags |= WL_TX_POWER_F_ENABLED; - if (pi->hwpwrctrl) - power->flags |= WL_TX_POWER_F_HW; - } - - num_rates = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : - ((ISLCNPHY(pi)) ? - (TXP_LAST_OFDM_20_CDD + 1) : (TXP_LAST_OFDM + 1))); - - for (rate = 0; rate < num_rates; rate++) { - power->user_limit[rate] = pi->tx_user_target[rate]; - wlc_phy_txpower_sromlimit(ppi, channel, &min_pwr, &max_pwr, - rate); - power->board_limit[rate] = (u8) max_pwr; - power->target[rate] = pi->tx_power_target[rate]; - } - - if (ISNPHY(pi)) { - u32 est_pout; - - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_phyreg_enter((struct brcms_phy_pub *) pi); - est_pout = wlc_phy_txpower_est_power_nphy(pi); - wlc_phyreg_exit((struct brcms_phy_pub *) pi); - wlapi_enable_mac(pi->sh->physhim); - - power->est_Pout[0] = (est_pout >> 8) & 0xff; - power->est_Pout[1] = est_pout & 0xff; - - power->est_Pout_act[0] = est_pout >> 24; - power->est_Pout_act[1] = (est_pout >> 16) & 0xff; - - if (power->est_Pout[0] == 0x80) - power->est_Pout[0] = 0; - if (power->est_Pout[1] == 0x80) - power->est_Pout[1] = 0; - - if (power->est_Pout_act[0] == 0x80) - power->est_Pout_act[0] = 0; - if (power->est_Pout_act[1] == 0x80) - power->est_Pout_act[1] = 0; - - power->est_Pout_cck = 0; - - power->tx_power_max[0] = pi->tx_power_max; - power->tx_power_max[1] = pi->tx_power_max; - - power->tx_power_max_rate_ind[0] = pi->tx_power_max_rate_ind; - power->tx_power_max_rate_ind[1] = pi->tx_power_max_rate_ind; - } else if (pi->hwpwrctrl && pi->sh->up) { - - wlc_phyreg_enter(ppi); - if (ISLCNPHY(pi)) { - - power->tx_power_max[0] = pi->tx_power_max; - power->tx_power_max[1] = pi->tx_power_max; - - power->tx_power_max_rate_ind[0] = - pi->tx_power_max_rate_ind; - power->tx_power_max_rate_ind[1] = - pi->tx_power_max_rate_ind; - - if (wlc_phy_tpc_isenabled_lcnphy(pi)) - power->flags |= - (WL_TX_POWER_F_HW | - WL_TX_POWER_F_ENABLED); - else - power->flags &= - ~(WL_TX_POWER_F_HW | - WL_TX_POWER_F_ENABLED); - - wlc_lcnphy_get_tssi(pi, (s8 *) &power->est_Pout[0], - (s8 *) &power->est_Pout_cck); - } - wlc_phyreg_exit(ppi); - } -} - -void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - pi->antsel_type = antsel_type; -} - -bool wlc_phy_test_ison(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - return pi->phytest_on; -} - -void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - bool suspend; - - pi->sh->rx_antdiv = val; - - if (!(ISNPHY(pi) && D11REV_IS(pi->sh->corerev, 16))) { - if (val > ANT_RX_DIV_FORCE_1) - wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, - MHF1_ANTDIV, BRCM_BAND_ALL); - else - wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, 0, - BRCM_BAND_ALL); - } - - if (ISNPHY(pi)) - return; - - if (!pi->sh->clk) - return; - - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - if (ISLCNPHY(pi)) { - if (val > ANT_RX_DIV_FORCE_1) { - mod_phy_reg(pi, 0x410, (0x1 << 1), 0x01 << 1); - mod_phy_reg(pi, 0x410, - (0x1 << 0), - ((ANT_RX_DIV_START_1 == val) ? 1 : 0) << 0); - } else { - mod_phy_reg(pi, 0x410, (0x1 << 1), 0x00 << 1); - mod_phy_reg(pi, 0x410, (0x1 << 0), (u16) val << 0); - } - } - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - - return; -} - -static bool -wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant) -{ - s8 cmplx_pwr_dbm[PHY_CORE_MAX]; - u8 i; - - memset((u8 *) cmplx_pwr_dbm, 0, sizeof(cmplx_pwr_dbm)); - wlc_phy_compute_dB(cmplx_pwr, cmplx_pwr_dbm, pi->pubpi.phy_corenum); - - for (i = 0; i < pi->pubpi.phy_corenum; i++) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) - cmplx_pwr_dbm[i] += (s8) PHY_NOISE_OFFSETFACT_4322; - else - - cmplx_pwr_dbm[i] += (s8) (16 - (15) * 3 - 70); - } - - for (i = 0; i < pi->pubpi.phy_corenum; i++) { - pi->nphy_noise_win[i][pi->nphy_noise_index] = cmplx_pwr_dbm[i]; - pwr_ant[i] = cmplx_pwr_dbm[i]; - } - pi->nphy_noise_index = - MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); - return true; -} - -static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) -{ - if (!pi->phynoise_state) - return; - - if (pi->phynoise_state & PHY_NOISE_STATE_MON) { - if (pi->phynoise_chan_watchdog == channel) { - pi->sh->phy_noise_window[pi->sh->phy_noise_index] = - noise_dbm; - pi->sh->phy_noise_index = - MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); - } - pi->phynoise_state &= ~PHY_NOISE_STATE_MON; - } - - if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) - pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; - -} - -static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) -{ - u32 cmplx_pwr[PHY_CORE_MAX]; - s8 noise_dbm_ant[PHY_CORE_MAX]; - u16 lo, hi; - u32 cmplx_pwr_tot = 0; - s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - u8 idx, core; - - memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); - memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); - - for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, - core++) { - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); - hi = wlapi_bmac_read_shm(pi->sh->physhim, - M_PWRIND_MAP(idx + 1)); - cmplx_pwr[core] = (hi << 16) + lo; - cmplx_pwr_tot += cmplx_pwr[core]; - if (cmplx_pwr[core] == 0) - noise_dbm_ant[core] = PHY_NOISE_FIXED_VAL_NPHY; - else - cmplx_pwr[core] >>= PHY_NOISE_SAMPLE_LOG_NUM_UCODE; - } - - if (cmplx_pwr_tot != 0) - wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - pi->nphy_noise_win[core][pi->nphy_noise_index] = - noise_dbm_ant[core]; - - if (noise_dbm_ant[core] > noise_dbm) - noise_dbm = noise_dbm_ant[core]; - } - pi->nphy_noise_index = - MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); - - return noise_dbm; - -} - -void wlc_phy_noise_sample_intr(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 jssi_aux; - u8 channel = 0; - s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - - if (ISLCNPHY(pi)) { - u32 cmplx_pwr, cmplx_pwr0, cmplx_pwr1; - u16 lo, hi; - s32 pwr_offset_dB, gain_dB; - u16 status_0, status_1; - - jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); - channel = jssi_aux & D11_CURCHANNEL_MAX; - - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP0); - hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP1); - cmplx_pwr0 = (hi << 16) + lo; - - lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP2); - hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP3); - cmplx_pwr1 = (hi << 16) + lo; - cmplx_pwr = (cmplx_pwr0 + cmplx_pwr1) >> 6; - - status_0 = 0x44; - status_1 = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_0); - if ((cmplx_pwr > 0 && cmplx_pwr < 500) - && ((status_1 & 0xc000) == 0x4000)) { - - wlc_phy_compute_dB(&cmplx_pwr, &noise_dbm, - pi->pubpi.phy_corenum); - pwr_offset_dB = (read_phy_reg(pi, 0x434) & 0xFF); - if (pwr_offset_dB > 127) - pwr_offset_dB -= 256; - - noise_dbm += (s8) (pwr_offset_dB - 30); - - gain_dB = (status_0 & 0x1ff); - noise_dbm -= (s8) (gain_dB); - } else { - noise_dbm = PHY_NOISE_FIXED_VAL_LCNPHY; - } - } else if (ISNPHY(pi)) { - - jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); - channel = jssi_aux & D11_CURCHANNEL_MAX; - - noise_dbm = wlc_phy_noise_read_shmem(pi); - } - - wlc_phy_noise_cb(pi, channel, noise_dbm); - -} - -static void -wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - bool sampling_in_progress = (pi->phynoise_state != 0); - bool wait_for_intr = true; - - switch (reason) { - case PHY_NOISE_SAMPLE_MON: - pi->phynoise_chan_watchdog = ch; - pi->phynoise_state |= PHY_NOISE_STATE_MON; - break; - - case PHY_NOISE_SAMPLE_EXTERNAL: - pi->phynoise_state |= PHY_NOISE_STATE_EXTERNAL; - break; - - default: - break; - } - - if (sampling_in_progress) - return; - - pi->phynoise_now = pi->sh->now; - - if (pi->phy_fixed_noise) { - if (ISNPHY(pi)) { - pi->nphy_noise_win[WL_ANT_IDX_1][pi->nphy_noise_index] = - PHY_NOISE_FIXED_VAL_NPHY; - pi->nphy_noise_win[WL_ANT_IDX_2][pi->nphy_noise_index] = - PHY_NOISE_FIXED_VAL_NPHY; - pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, - PHY_NOISE_WINDOW_SZ); - noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; - } else { - noise_dbm = PHY_NOISE_FIXED_VAL; - } - - wait_for_intr = false; - goto done; - } - - if (ISLCNPHY(pi)) { - if (!pi->phynoise_polling - || (reason == PHY_NOISE_SAMPLE_EXTERNAL)) { - wlapi_bmac_write_shm(pi->sh->physhim, M_JSSI_0, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - - OR_REG(&pi->regs->maccommand, - MCMD_BG_NOISE); - } else { - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_deaf_mode(pi, (bool) 0); - noise_dbm = (s8) wlc_lcnphy_rx_signal_power(pi, 20); - wlc_lcnphy_deaf_mode(pi, (bool) 1); - wlapi_enable_mac(pi->sh->physhim); - wait_for_intr = false; - } - } else if (ISNPHY(pi)) { - if (!pi->phynoise_polling - || (reason == PHY_NOISE_SAMPLE_EXTERNAL)) { - - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); - wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - - OR_REG(&pi->regs->maccommand, - MCMD_BG_NOISE); - } else { - struct phy_iq_est est[PHY_CORE_MAX]; - u32 cmplx_pwr[PHY_CORE_MAX]; - s8 noise_dbm_ant[PHY_CORE_MAX]; - u16 log_num_samps, num_samps, classif_state = 0; - u8 wait_time = 32; - u8 wait_crs = 0; - u8 i; - - memset((u8 *) est, 0, sizeof(est)); - memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); - memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); - - log_num_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; - num_samps = 1 << log_num_samps; - - wlapi_suspend_mac_and_wait(pi->sh->physhim); - classif_state = wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_classifier_nphy(pi, 3, 0); - wlc_phy_rx_iq_est_nphy(pi, est, num_samps, wait_time, - wait_crs); - wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); - wlapi_enable_mac(pi->sh->physhim); - - for (i = 0; i < pi->pubpi.phy_corenum; i++) - cmplx_pwr[i] = (est[i].i_pwr + est[i].q_pwr) >> - log_num_samps; - - wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); - - for (i = 0; i < pi->pubpi.phy_corenum; i++) { - pi->nphy_noise_win[i][pi->nphy_noise_index] = - noise_dbm_ant[i]; - - if (noise_dbm_ant[i] > noise_dbm) - noise_dbm = noise_dbm_ant[i]; - } - pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, - PHY_NOISE_WINDOW_SZ); - - wait_for_intr = false; - } - } - -done: - - if (!wait_for_intr) - wlc_phy_noise_cb(pi, ch, noise_dbm); - -} - -void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *pih) -{ - u8 channel; - - channel = CHSPEC_CHANNEL(wlc_phy_chanspec_get(pih)); - - wlc_phy_noise_sample_request(pih, PHY_NOISE_SAMPLE_EXTERNAL, channel); -} - -static const s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { - 8, - 8, - 8, - 8, - 8, - 8, - 8, - 9, - 10, - 8, - 8, - 7, - 7, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 0, - 0, - 0, - 0 -}; - -void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) -{ - u8 msb, secondmsb, i; - u32 tmp; - - for (i = 0; i < core; i++) { - secondmsb = 0; - tmp = cmplx_pwr[i]; - msb = fls(tmp); - if (msb) - secondmsb = (u8) ((tmp >> (--msb - 1)) & 1); - p_cmplx_pwr_dB[i] = (s8) (3 * msb + 2 * secondmsb); - } -} - -int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, - struct d11rxhdr *rxh) -{ - int rssi = rxh->PhyRxStatus_1 & PRXS1_JSSI_MASK; - uint radioid = pih->radioid; - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if ((pi->sh->corerev >= 11) - && !(rxh->RxStatus2 & RXS_PHYRXST_VALID)) { - rssi = BRCMS_RSSI_INVALID; - goto end; - } - - if (ISLCNPHY(pi)) { - u8 gidx = (rxh->PhyRxStatus_2 & 0xFC00) >> 10; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (rssi > 127) - rssi -= 256; - - rssi = rssi + lcnphy_gain_index_offset_for_pkt_rssi[gidx]; - if ((rssi > -46) && (gidx > 18)) - rssi = rssi + 7; - - rssi = rssi + pi_lcn->lcnphy_pkteng_rssi_slope; - - rssi = rssi + 2; - - } - - if (ISLCNPHY(pi)) { - if (rssi > 127) - rssi -= 256; - } else if (radioid == BCM2055_ID || radioid == BCM2056_ID - || radioid == BCM2057_ID) { - rssi = wlc_phy_rssi_compute_nphy(pi, rxh); - } - -end: - return rssi; -} - -void wlc_phy_freqtrack_start(struct brcms_phy_pub *pih) -{ - return; -} - -void wlc_phy_freqtrack_end(struct brcms_phy_pub *pih) -{ - return; -} - -void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag) -{ - struct brcms_phy *pi; - pi = (struct brcms_phy *) ppi; - - if (ISLCNPHY(pi)) - wlc_lcnphy_deaf_mode(pi, true); - else if (ISNPHY(pi)) - wlc_nphy_deaf_mode(pi, true); -} - -void wlc_phy_watchdog(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - bool delay_phy_cal = false; - pi->sh->now++; - - if (!pi->watchdog_override) - return; - - if (!(SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi))) - wlc_phy_noise_sample_request((struct brcms_phy_pub *) pi, - PHY_NOISE_SAMPLE_MON, - CHSPEC_CHANNEL(pi-> - radio_chanspec)); - - if (pi->phynoise_state && (pi->sh->now - pi->phynoise_now) > 5) - pi->phynoise_state = 0; - - if ((!pi->phycal_txpower) || - ((pi->sh->now - pi->phycal_txpower) >= pi->sh->fast_timer)) { - - if (!SCAN_INPROG_PHY(pi) && wlc_phy_cal_txpower_recalc_sw(pi)) - pi->phycal_txpower = pi->sh->now; - } - - if ((SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) - || ASSOC_INPROG_PHY(pi))) - return; - - if (ISNPHY(pi) && !pi->disable_percal && !delay_phy_cal) { - - if ((pi->nphy_perical != PHY_PERICAL_DISABLE) && - (pi->nphy_perical != PHY_PERICAL_MANUAL) && - ((pi->sh->now - pi->nphy_perical_last) >= - pi->sh->glacial_timer)) - wlc_phy_cal_perical((struct brcms_phy_pub *) pi, - PHY_PERICAL_WATCHDOG); - - wlc_phy_txpwr_papd_cal_nphy(pi); - } - - if (ISLCNPHY(pi)) { - if (pi->phy_forcecal || - ((pi->sh->now - pi->phy_lastcal) >= - pi->sh->glacial_timer)) { - if (!(SCAN_RM_IN_PROGRESS(pi) || ASSOC_INPROG_PHY(pi))) - wlc_lcnphy_calib_modes( - pi, - LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL); - if (! - (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) - || ASSOC_INPROG_PHY(pi) - || pi->carrier_suppr_disable - || pi->disable_percal)) - wlc_lcnphy_calib_modes(pi, - PHY_PERICAL_WATCHDOG); - } - } -} - -void wlc_phy_BSSinit(struct brcms_phy_pub *pih, bool bonlyap, int rssi) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - uint i; - uint k; - - for (i = 0; i < MA_WINDOW_SZ; i++) - pi->sh->phy_noise_window[i] = (s8) (rssi & 0xff); - if (ISLCNPHY(pi)) { - for (i = 0; i < MA_WINDOW_SZ; i++) - pi->sh->phy_noise_window[i] = - PHY_NOISE_FIXED_VAL_LCNPHY; - } - pi->sh->phy_noise_index = 0; - - for (i = 0; i < PHY_NOISE_WINDOW_SZ; i++) { - for (k = WL_ANT_IDX_1; k < WL_ANT_RX_MAX; k++) - pi->nphy_noise_win[k][i] = PHY_NOISE_FIXED_VAL_NPHY; - } - pi->nphy_noise_index = 0; -} - -void -wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag) -{ - *eps_imag = (epsilon >> 13); - if (*eps_imag > 0xfff) - *eps_imag -= 0x2000; - - *eps_real = (epsilon & 0x1fff); - if (*eps_real > 0xfff) - *eps_real -= 0x2000; -} - -void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi) -{ - wlapi_del_timer(pi->sh->physhim, pi->phycal_timer); - - pi->cal_type_override = PHY_PERICAL_AUTO; - pi->mphase_cal_phase_id = MPHASE_CAL_STATE_IDLE; - pi->mphase_txcal_cmdidx = 0; -} - -static void -wlc_phy_cal_perical_mphase_schedule(struct brcms_phy *pi, uint delay) -{ - - if ((pi->nphy_perical != PHY_PERICAL_MPHASE) && - (pi->nphy_perical != PHY_PERICAL_MANUAL)) - return; - - wlapi_del_timer(pi->sh->physhim, pi->phycal_timer); - - pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; - wlapi_add_timer(pi->sh->physhim, pi->phycal_timer, delay, 0); -} - -void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason) -{ - s16 nphy_currtemp = 0; - s16 delta_temp = 0; - bool do_periodic_cal = true; - struct brcms_phy *pi = (struct brcms_phy *) pih; - - if (!ISNPHY(pi)) - return; - - if ((pi->nphy_perical == PHY_PERICAL_DISABLE) || - (pi->nphy_perical == PHY_PERICAL_MANUAL)) - return; - - switch (reason) { - case PHY_PERICAL_DRIVERUP: - break; - - case PHY_PERICAL_PHYINIT: - if (pi->nphy_perical == PHY_PERICAL_MPHASE) { - if (PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_reset(pi); - - wlc_phy_cal_perical_mphase_schedule( - pi, - PHY_PERICAL_INIT_DELAY); - } - break; - - case PHY_PERICAL_JOIN_BSS: - case PHY_PERICAL_START_IBSS: - case PHY_PERICAL_UP_BSS: - if ((pi->nphy_perical == PHY_PERICAL_MPHASE) && - PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_reset(pi); - - pi->first_cal_after_assoc = true; - - pi->cal_type_override = PHY_PERICAL_FULL; - - if (pi->phycal_tempdelta) - pi->nphy_lastcal_temp = wlc_phy_tempsense_nphy(pi); - - wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_FULL); - break; - - case PHY_PERICAL_WATCHDOG: - if (pi->phycal_tempdelta) { - nphy_currtemp = wlc_phy_tempsense_nphy(pi); - delta_temp = - (nphy_currtemp > pi->nphy_lastcal_temp) ? - nphy_currtemp - pi->nphy_lastcal_temp : - pi->nphy_lastcal_temp - nphy_currtemp; - - if ((delta_temp < (s16) pi->phycal_tempdelta) && - (pi->nphy_txiqlocal_chanspec == - pi->radio_chanspec)) - do_periodic_cal = false; - else - pi->nphy_lastcal_temp = nphy_currtemp; - } - - if (do_periodic_cal) { - if (pi->nphy_perical == PHY_PERICAL_MPHASE) { - if (!PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_schedule( - pi, - PHY_PERICAL_WDOG_DELAY); - } else if (pi->nphy_perical == PHY_PERICAL_SPHASE) - wlc_phy_cal_perical_nphy_run(pi, - PHY_PERICAL_AUTO); - } - break; - default: - break; - } -} - -void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi) -{ - pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; - pi->mphase_txcal_cmdidx = 0; -} - -u8 wlc_phy_nbits(s32 value) -{ - s32 abs_val; - u8 nbits = 0; - - abs_val = abs(value); - while ((abs_val >> nbits) > 0) - nbits++; - - return nbits; -} - -void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->sh->hw_phytxchain = txchain; - pi->sh->hw_phyrxchain = rxchain; - pi->sh->phytxchain = txchain; - pi->sh->phyrxchain = rxchain; - pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); -} - -void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - pi->sh->phytxchain = txchain; - - if (ISNPHY(pi)) - wlc_phy_rxcore_setstate_nphy(pih, rxchain); - - pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); -} - -void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - - *txchain = pi->sh->phytxchain; - *rxchain = pi->sh->phyrxchain; -} - -u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih) -{ - s16 nphy_currtemp; - u8 active_bitmap; - struct brcms_phy *pi = (struct brcms_phy *) pih; - - active_bitmap = (pi->phy_txcore_heatedup) ? 0x31 : 0x33; - - if (!pi->watchdog_override) - return active_bitmap; - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - wlapi_suspend_mac_and_wait(pi->sh->physhim); - nphy_currtemp = wlc_phy_tempsense_nphy(pi); - wlapi_enable_mac(pi->sh->physhim); - - if (!pi->phy_txcore_heatedup) { - if (nphy_currtemp >= pi->phy_txcore_disable_temp) { - active_bitmap &= 0xFD; - pi->phy_txcore_heatedup = true; - } - } else { - if (nphy_currtemp <= pi->phy_txcore_enable_temp) { - active_bitmap |= 0x2; - pi->phy_txcore_heatedup = false; - } - } - } - - return active_bitmap; -} - -s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - u8 siso_mcs_id, cdd_mcs_id; - - siso_mcs_id = - (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_SISO : - TXP_FIRST_MCS_20_SISO; - cdd_mcs_id = - (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_CDD : - TXP_FIRST_MCS_20_CDD; - - if (pi->tx_power_target[siso_mcs_id] > - (pi->tx_power_target[cdd_mcs_id] + 12)) - return PHY_TXC1_MODE_SISO; - else - return PHY_TXC1_MODE_CDD; -} - -const u8 *wlc_phy_get_ofdm_rate_lookup(void) -{ - return ofdm_rate_lookup; -} - -void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) -{ - if ((pi->sh->chip == BCM4313_CHIP_ID) && - (pi->sh->boardflags & BFL_FEM)) { - if (mode) { - u16 txant = 0; - txant = wlapi_bmac_get_txant(pi->sh->physhim); - if (txant == 1) { - mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2); - - } - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpiocontrol), - ~0x0, 0x0); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioout), 0x40, - 0x40); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioouten), 0x40, - 0x40); - } else { - mod_phy_reg(pi, 0x44c, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); - - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioout), 0x40, - 0x00); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioouten), 0x40, - 0x0); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpiocontrol), - ~0x0, 0x40); - } - } -} - -void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool ldpc) -{ - return; -} - -void -wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset) -{ - *cckoffset = 0; - *ofdmoffset = 0; -} - -s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec) -{ - - return rssi; -} - -bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *ppi) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - if (ISNPHY(pi)) - return wlc_phy_n_txpower_ipa_ison(pi); - else - return 0; -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h deleted file mode 100644 index 96e15163222..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * phy_hal.h: functionality exported from the phy to higher layers - */ - -#ifndef _BRCM_PHY_HAL_H_ -#define _BRCM_PHY_HAL_H_ - -#include -#include -#include - -#define IDCODE_VER_MASK 0x0000000f -#define IDCODE_VER_SHIFT 0 -#define IDCODE_MFG_MASK 0x00000fff -#define IDCODE_MFG_SHIFT 0 -#define IDCODE_ID_MASK 0x0ffff000 -#define IDCODE_ID_SHIFT 12 -#define IDCODE_REV_MASK 0xf0000000 -#define IDCODE_REV_SHIFT 28 - -#define NORADIO_ID 0xe4f5 -#define NORADIO_IDCODE 0x4e4f5246 - -#define BCM2055_ID 0x2055 -#define BCM2055_IDCODE 0x02055000 -#define BCM2055A0_IDCODE 0x1205517f - -#define BCM2056_ID 0x2056 -#define BCM2056_IDCODE 0x02056000 -#define BCM2056A0_IDCODE 0x1205617f - -#define BCM2057_ID 0x2057 -#define BCM2057_IDCODE 0x02057000 -#define BCM2057A0_IDCODE 0x1205717f - -#define BCM2064_ID 0x2064 -#define BCM2064_IDCODE 0x02064000 -#define BCM2064A0_IDCODE 0x0206417f - -#define PHY_TPC_HW_OFF false -#define PHY_TPC_HW_ON true - -#define PHY_PERICAL_DRIVERUP 1 -#define PHY_PERICAL_WATCHDOG 2 -#define PHY_PERICAL_PHYINIT 3 -#define PHY_PERICAL_JOIN_BSS 4 -#define PHY_PERICAL_START_IBSS 5 -#define PHY_PERICAL_UP_BSS 6 -#define PHY_PERICAL_CHAN 7 -#define PHY_FULLCAL 8 - -#define PHY_PERICAL_DISABLE 0 -#define PHY_PERICAL_SPHASE 1 -#define PHY_PERICAL_MPHASE 2 -#define PHY_PERICAL_MANUAL 3 - -#define PHY_HOLD_FOR_ASSOC 1 -#define PHY_HOLD_FOR_SCAN 2 -#define PHY_HOLD_FOR_RM 4 -#define PHY_HOLD_FOR_PLT 8 -#define PHY_HOLD_FOR_MUTE 16 -#define PHY_HOLD_FOR_NOT_ASSOC 0x20 - -#define PHY_MUTE_FOR_PREISM 1 -#define PHY_MUTE_ALL 0xffffffff - -#define PHY_NOISE_FIXED_VAL (-95) -#define PHY_NOISE_FIXED_VAL_NPHY (-92) -#define PHY_NOISE_FIXED_VAL_LCNPHY (-92) - -#define PHY_MODE_CAL 0x0002 -#define PHY_MODE_NOISEM 0x0004 - -#define BRCMS_TXPWR_DB_FACTOR 4 - -/* a large TX Power as an init value to factor out of min() calculations, - * keep low enough to fit in an s8, units are .25 dBm - */ -#define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */ - -#define BRCMS_NUM_RATES_CCK 4 -#define BRCMS_NUM_RATES_OFDM 8 -#define BRCMS_NUM_RATES_MCS_1_STREAM 8 -#define BRCMS_NUM_RATES_MCS_2_STREAM 8 -#define BRCMS_NUM_RATES_MCS_3_STREAM 8 -#define BRCMS_NUM_RATES_MCS_4_STREAM 8 - -#define BRCMS_RSSI_INVALID 0 /* invalid RSSI value */ - -struct d11regs; -struct phy_shim_info; - -struct txpwr_limits { - u8 cck[BRCMS_NUM_RATES_CCK]; - u8 ofdm[BRCMS_NUM_RATES_OFDM]; - - u8 ofdm_cdd[BRCMS_NUM_RATES_OFDM]; - - u8 ofdm_40_siso[BRCMS_NUM_RATES_OFDM]; - u8 ofdm_40_cdd[BRCMS_NUM_RATES_OFDM]; - - u8 mcs_20_siso[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_20_cdd[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_20_stbc[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_20_mimo[BRCMS_NUM_RATES_MCS_2_STREAM]; - - u8 mcs_40_siso[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_40_cdd[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_40_stbc[BRCMS_NUM_RATES_MCS_1_STREAM]; - u8 mcs_40_mimo[BRCMS_NUM_RATES_MCS_2_STREAM]; - u8 mcs32; -}; - -struct tx_power { - u32 flags; - u16 chanspec; /* txpwr report for this channel */ - u16 local_chanspec; /* channel on which we are associated */ - u8 local_max; /* local max according to the AP */ - u8 local_constraint; /* local constraint according to the AP */ - s8 antgain[2]; /* Ant gain for each band - from SROM */ - u8 rf_cores; /* count of RF Cores being reported */ - u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */ - u8 est_Pout_act[4]; /* Latest tx power out estimate per RF chain - * without adjustment */ - u8 est_Pout_cck; /* Latest CCK tx power out estimate */ - u8 tx_power_max[4]; /* Maximum target power among all rates */ - /* Index of the rate with the max target power */ - u8 tx_power_max_rate_ind[4]; - /* User limit */ - u8 user_limit[WL_TX_POWER_RATES]; - /* Regulatory power limit */ - u8 reg_limit[WL_TX_POWER_RATES]; - /* Max power board can support (SROM) */ - u8 board_limit[WL_TX_POWER_RATES]; - /* Latest target power */ - u8 target[WL_TX_POWER_RATES]; -}; - -struct tx_inst_power { - u8 txpwr_est_Pout[2]; /* Latest estimate for 2.4 and 5 Ghz */ - u8 txpwr_est_Pout_gofdm; /* Pwr estimate for 2.4 OFDM */ -}; - -struct brcms_chanvec { - u8 vec[MAXCHANNEL / NBBY]; -}; - -struct shared_phy_params { - struct si_pub *sih; - struct phy_shim_info *physhim; - uint unit; - uint corerev; - uint buscorerev; - u16 vid; - u16 did; - uint chip; - uint chiprev; - uint chippkg; - uint sromrev; - uint boardtype; - uint boardrev; - uint boardvendor; - u32 boardflags; - u32 boardflags2; -}; - - -extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); -extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, - struct d11regs __iomem *regs, - int bandtype, struct wiphy *wiphy); -extern void wlc_phy_detach(struct brcms_phy_pub *ppi); - -extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, - u16 *phyrev, u16 *radioid, - u16 *radiover); -extern bool wlc_phy_get_encore(struct brcms_phy_pub *pih); -extern u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih); - -extern void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate); -extern void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate); -extern void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec); -extern void wlc_phy_watchdog(struct brcms_phy_pub *ppi); -extern int wlc_phy_down(struct brcms_phy_pub *ppi); -extern u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih); -extern void wlc_phy_cal_init(struct brcms_phy_pub *ppi); -extern void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init); - -extern void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, - u16 chanspec); -extern u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi); -extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, - u16 newch); -extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi); -extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw); - -extern int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, - struct d11rxhdr *rxh); -extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi); -extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi); -extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi); - -extern void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag); - -extern void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on); -extern void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on); - - -extern void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi); - -extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi, - bool wide_filter); -extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, - struct brcms_chanvec *channels); -extern u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, - uint band); - -extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, - u8 *_min_, u8 *_max_, int rate); -extern void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, - uint chan, u8 *_max_, u8 *_min_); -extern void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, - uint band, s32 *, s32 *, u32 *); -extern void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, - struct txpwr_limits *, - u16 chanspec); -extern int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, - bool *override); -extern int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, - bool override); -extern void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi, - struct txpwr_limits *); -extern bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi); -extern void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, - bool hwpwrctrl); -extern u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi); -extern u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi); -extern bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih); - -extern void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, - u8 rxchain); -extern void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, - u8 rxchain); -extern void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, - u8 *rxchain); -extern u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih); -extern s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, - u16 chanspec); -extern void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val); - -extern void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason); -extern void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi); -extern void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock); -extern void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi); - -extern void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val); -extern void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi); -extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val); -extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags); - -extern void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type); - -extern void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, - struct tx_power *power, uint channel); - -extern void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal); -extern bool wlc_phy_test_ison(struct brcms_phy_pub *ppi); -extern void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, - u8 txpwr_percent); -extern void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war); -extern void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, - bool bf_preempt); -extern void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap); - -extern void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end); - -extern void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi); -extern void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi); - -extern const u8 *wlc_phy_get_ofdm_rate_lookup(void); - -extern s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi, - u8 mcs_offset); -extern s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset); -#endif /* _BRCM_PHY_HAL_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h deleted file mode 100644 index bea85241a24..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +++ /dev/null @@ -1,1169 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_PHY_INT_H_ -#define _BRCM_PHY_INT_H_ - -#include -#include -#include - -#define PHY_VERSION { 1, 82, 8, 0 } - -#define LCNXN_BASEREV 16 - -struct phy_shim_info; - -struct brcms_phy_srom_fem { - /* TSSI positive slope, 1: positive, 0: negative */ - u8 tssipos; - /* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */ - u8 extpagain; - /* support 32 combinations of different Pdet dynamic ranges */ - u8 pdetrange; - /* TR switch isolation */ - u8 triso; - /* antswctrl lookup table configuration: 32 possible choices */ - u8 antswctrllut; -}; - -#define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N) -#define ISLCNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_LCN) - -#define PHY_GET_RFATTN(rfgain) ((rfgain) & 0x0f) -#define PHY_GET_PADMIX(rfgain) (((rfgain) & 0x10) >> 4) -#define PHY_GET_RFGAINID(rfattn, padmix, width) ((rfattn) + ((padmix)*(width))) -#define PHY_SAT(x, n) ((x) > ((1<<((n)-1))-1) ? ((1<<((n)-1))-1) : \ - ((x) < -(1<<((n)-1)) ? -(1<<((n)-1)) : (x))) -#define PHY_SHIFT_ROUND(x, n) ((x) >= 0 ? ((x)+(1<<((n)-1)))>>(n) : (x)>>(n)) -#define PHY_HW_ROUND(x, s) ((x >> s) + ((x >> (s-1)) & (s != 0))) - -#define CH_5G_GROUP 3 -#define A_LOW_CHANS 0 -#define A_MID_CHANS 1 -#define A_HIGH_CHANS 2 -#define CH_2G_GROUP 1 -#define G_ALL_CHANS 0 - -#define FIRST_REF5_CHANNUM 149 -#define LAST_REF5_CHANNUM 165 -#define FIRST_5G_CHAN 14 -#define LAST_5G_CHAN 50 -#define FIRST_MID_5G_CHAN 14 -#define LAST_MID_5G_CHAN 35 -#define FIRST_HIGH_5G_CHAN 36 -#define LAST_HIGH_5G_CHAN 41 -#define FIRST_LOW_5G_CHAN 42 -#define LAST_LOW_5G_CHAN 50 - -#define BASE_LOW_5G_CHAN 4900 -#define BASE_MID_5G_CHAN 5100 -#define BASE_HIGH_5G_CHAN 5500 - -#define CHAN5G_FREQ(chan) (5000 + chan*5) -#define CHAN2G_FREQ(chan) (2407 + chan*5) - -#define TXP_FIRST_CCK 0 -#define TXP_LAST_CCK 3 -#define TXP_FIRST_OFDM 4 -#define TXP_LAST_OFDM 11 -#define TXP_FIRST_OFDM_20_CDD 12 -#define TXP_LAST_OFDM_20_CDD 19 -#define TXP_FIRST_MCS_20_SISO 20 -#define TXP_LAST_MCS_20_SISO 27 -#define TXP_FIRST_MCS_20_CDD 28 -#define TXP_LAST_MCS_20_CDD 35 -#define TXP_FIRST_MCS_20_STBC 36 -#define TXP_LAST_MCS_20_STBC 43 -#define TXP_FIRST_MCS_20_SDM 44 -#define TXP_LAST_MCS_20_SDM 51 -#define TXP_FIRST_OFDM_40_SISO 52 -#define TXP_LAST_OFDM_40_SISO 59 -#define TXP_FIRST_OFDM_40_CDD 60 -#define TXP_LAST_OFDM_40_CDD 67 -#define TXP_FIRST_MCS_40_SISO 68 -#define TXP_LAST_MCS_40_SISO 75 -#define TXP_FIRST_MCS_40_CDD 76 -#define TXP_LAST_MCS_40_CDD 83 -#define TXP_FIRST_MCS_40_STBC 84 -#define TXP_LAST_MCS_40_STBC 91 -#define TXP_FIRST_MCS_40_SDM 92 -#define TXP_LAST_MCS_40_SDM 99 -#define TXP_MCS_32 100 -#define TXP_NUM_RATES 101 -#define ADJ_PWR_TBL_LEN 84 - -#define TXP_FIRST_SISO_MCS_20 20 -#define TXP_LAST_SISO_MCS_20 27 - -#define PHY_CORE_NUM_1 1 -#define PHY_CORE_NUM_2 2 -#define PHY_CORE_NUM_3 3 -#define PHY_CORE_NUM_4 4 -#define PHY_CORE_MAX PHY_CORE_NUM_4 -#define PHY_CORE_0 0 -#define PHY_CORE_1 1 -#define PHY_CORE_2 2 -#define PHY_CORE_3 3 - -#define MA_WINDOW_SZ 8 - -#define PHY_NOISE_SAMPLE_MON 1 -#define PHY_NOISE_SAMPLE_EXTERNAL 2 -#define PHY_NOISE_WINDOW_SZ 16 -#define PHY_NOISE_GLITCH_INIT_MA 10 -#define PHY_NOISE_GLITCH_INIT_MA_BADPlCP 10 -#define PHY_NOISE_STATE_MON 0x1 -#define PHY_NOISE_STATE_EXTERNAL 0x2 -#define PHY_NOISE_SAMPLE_LOG_NUM_NPHY 10 -#define PHY_NOISE_SAMPLE_LOG_NUM_UCODE 9 - -#define PHY_NOISE_OFFSETFACT_4322 (-103) -#define PHY_NOISE_MA_WINDOW_SZ 2 - -#define PHY_RSSI_TABLE_SIZE 64 -#define RSSI_ANT_MERGE_MAX 0 -#define RSSI_ANT_MERGE_MIN 1 -#define RSSI_ANT_MERGE_AVG 2 - -#define PHY_TSSI_TABLE_SIZE 64 -#define APHY_TSSI_TABLE_SIZE 256 -#define TX_GAIN_TABLE_LENGTH 64 -#define DEFAULT_11A_TXP_IDX 24 -#define NUM_TSSI_FRAMES 4 -#define NULL_TSSI 0x7f -#define NULL_TSSI_W 0x7f7f - -#define PHY_PAPD_EPS_TBL_SIZE_LCNPHY 64 - -#define LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL 9 - -#define PHY_TXPWR_MIN 10 -#define PHY_TXPWR_MIN_NPHY 8 -#define RADIOPWR_OVERRIDE_DEF (-1) - -#define PWRTBL_NUM_COEFF 3 - -#define SPURAVOID_DISABLE 0 -#define SPURAVOID_AUTO 1 -#define SPURAVOID_FORCEON 2 -#define SPURAVOID_FORCEON2 3 - -#define PHY_SW_TIMER_FAST 15 -#define PHY_SW_TIMER_SLOW 60 -#define PHY_SW_TIMER_GLACIAL 120 - -#define PHY_PERICAL_AUTO 0 -#define PHY_PERICAL_FULL 1 -#define PHY_PERICAL_PARTIAL 2 - -#define PHY_PERICAL_NODELAY 0 -#define PHY_PERICAL_INIT_DELAY 5 -#define PHY_PERICAL_ASSOC_DELAY 5 -#define PHY_PERICAL_WDOG_DELAY 5 - -#define MPHASE_TXCAL_NUMCMDS 2 - -#define PHY_PERICAL_MPHASE_PENDING(pi) \ - (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE) - -enum { - MPHASE_CAL_STATE_IDLE = 0, - MPHASE_CAL_STATE_INIT = 1, - MPHASE_CAL_STATE_TXPHASE0, - MPHASE_CAL_STATE_TXPHASE1, - MPHASE_CAL_STATE_TXPHASE2, - MPHASE_CAL_STATE_TXPHASE3, - MPHASE_CAL_STATE_TXPHASE4, - MPHASE_CAL_STATE_TXPHASE5, - MPHASE_CAL_STATE_PAPDCAL, - MPHASE_CAL_STATE_RXCAL, - MPHASE_CAL_STATE_RSSICAL, - MPHASE_CAL_STATE_IDLETSSI -}; - -enum phy_cal_mode { - CAL_FULL, - CAL_RECAL, - CAL_CURRECAL, - CAL_DIGCAL, - CAL_GCTRL, - CAL_SOFT, - CAL_DIGLO -}; - -#define RDR_NTIERS 1 -#define RDR_TIER_SIZE 64 -#define RDR_LIST_SIZE (512/3) -#define RDR_EPOCH_SIZE 40 -#define RDR_NANTENNAS 2 -#define RDR_NTIER_SIZE RDR_LIST_SIZE -#define RDR_LP_BUFFER_SIZE 64 -#define LP_LEN_HIS_SIZE 10 - -#define STATIC_NUM_RF 32 -#define STATIC_NUM_BB 9 - -#define BB_MULT_MASK 0x0000ffff -#define BB_MULT_VALID_MASK 0x80000000 - -#define CORDIC_AG 39797 -#define CORDIC_NI 18 -#define FIXED(X) ((s32)((X) << 16)) - -#define FLOAT(X) \ - (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1)) - -#define PHY_CHAIN_TX_DISABLE_TEMP 115 -#define PHY_HYSTERESIS_DELTATEMP 5 - -#define SCAN_INPROG_PHY(pi) \ - (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN)) - -#define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT)) - -#define ASSOC_INPROG_PHY(pi) \ - (mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC)) - -#define SCAN_RM_IN_PROGRESS(pi) \ - (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM)) - -#define PHY_MUTED(pi) \ - (mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE)) - -#define PUB_NOT_ASSOC(pi) \ - (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC)) - -struct phy_table_info { - uint table; - int q; - uint max; -}; - -struct phytbl_info { - const void *tbl_ptr; - u32 tbl_len; - u32 tbl_id; - u32 tbl_offset; - u32 tbl_width; -}; - -struct interference_info { - u8 curr_home_channel; - u16 crsminpwrthld_40_stored; - u16 crsminpwrthld_20L_stored; - u16 crsminpwrthld_20U_stored; - u16 init_gain_code_core1_stored; - u16 init_gain_code_core2_stored; - u16 init_gain_codeb_core1_stored; - u16 init_gain_codeb_core2_stored; - u16 init_gain_table_stored[4]; - - u16 clip1_hi_gain_code_core1_stored; - u16 clip1_hi_gain_code_core2_stored; - u16 clip1_hi_gain_codeb_core1_stored; - u16 clip1_hi_gain_codeb_core2_stored; - u16 nb_clip_thresh_core1_stored; - u16 nb_clip_thresh_core2_stored; - u16 init_ofdmlna2gainchange_stored[4]; - u16 init_ccklna2gainchange_stored[4]; - u16 clip1_lo_gain_code_core1_stored; - u16 clip1_lo_gain_code_core2_stored; - u16 clip1_lo_gain_codeb_core1_stored; - u16 clip1_lo_gain_codeb_core2_stored; - u16 w1_clip_thresh_core1_stored; - u16 w1_clip_thresh_core2_stored; - u16 radio_2056_core1_rssi_gain_stored; - u16 radio_2056_core2_rssi_gain_stored; - u16 energy_drop_timeout_len_stored; - - u16 ed_crs40_assertthld0_stored; - u16 ed_crs40_assertthld1_stored; - u16 ed_crs40_deassertthld0_stored; - u16 ed_crs40_deassertthld1_stored; - u16 ed_crs20L_assertthld0_stored; - u16 ed_crs20L_assertthld1_stored; - u16 ed_crs20L_deassertthld0_stored; - u16 ed_crs20L_deassertthld1_stored; - u16 ed_crs20U_assertthld0_stored; - u16 ed_crs20U_assertthld1_stored; - u16 ed_crs20U_deassertthld0_stored; - u16 ed_crs20U_deassertthld1_stored; - - u16 badplcp_ma; - u16 badplcp_ma_previous; - u16 badplcp_ma_total; - u16 badplcp_ma_list[MA_WINDOW_SZ]; - int badplcp_ma_index; - s16 pre_badplcp_cnt; - s16 bphy_pre_badplcp_cnt; - - u16 init_gain_core1; - u16 init_gain_core2; - u16 init_gainb_core1; - u16 init_gainb_core2; - u16 init_gain_rfseq[4]; - - u16 crsminpwr0; - u16 crsminpwrl0; - u16 crsminpwru0; - - s16 crsminpwr_index; - - u16 radio_2057_core1_rssi_wb1a_gc_stored; - u16 radio_2057_core2_rssi_wb1a_gc_stored; - u16 radio_2057_core1_rssi_wb1g_gc_stored; - u16 radio_2057_core2_rssi_wb1g_gc_stored; - u16 radio_2057_core1_rssi_wb2_gc_stored; - u16 radio_2057_core2_rssi_wb2_gc_stored; - u16 radio_2057_core1_rssi_nb_gc_stored; - u16 radio_2057_core2_rssi_nb_gc_stored; -}; - -struct aci_save_gphy { - u16 rc_cal_ovr; - u16 phycrsth1; - u16 phycrsth2; - u16 init_n1p1_gain; - u16 p1_p2_gain; - u16 n1_n2_gain; - u16 n1_p1_gain; - u16 div_search_gain; - u16 div_p1_p2_gain; - u16 div_search_gn_change; - u16 table_7_2; - u16 table_7_3; - u16 cckshbits_gnref; - u16 clip_thresh; - u16 clip2_thresh; - u16 clip3_thresh; - u16 clip_p2_thresh; - u16 clip_pwdn_thresh; - u16 clip_n1p1_thresh; - u16 clip_n1_pwdn_thresh; - u16 bbconfig; - u16 cthr_sthr_shdin; - u16 energy; - u16 clip_p1_p2_thresh; - u16 threshold; - u16 reg15; - u16 reg16; - u16 reg17; - u16 div_srch_idx; - u16 div_srch_p1_p2; - u16 div_srch_gn_back; - u16 ant_dwell; - u16 ant_wr_settle; -}; - -struct lo_complex_abgphy_info { - s8 i; - s8 q; -}; - -struct nphy_iq_comp { - s16 a0; - s16 b0; - s16 a1; - s16 b1; -}; - -struct nphy_txpwrindex { - s8 index; - s8 index_internal; - s8 index_internal_save; - u16 AfectrlOverride; - u16 AfeCtrlDacGain; - u16 rad_gain; - u8 bbmult; - u16 iqcomp_a; - u16 iqcomp_b; - u16 locomp; -}; - -struct txiqcal_cache { - - u16 txcal_coeffs_2G[8]; - u16 txcal_radio_regs_2G[8]; - struct nphy_iq_comp rxcal_coeffs_2G; - - u16 txcal_coeffs_5G[8]; - u16 txcal_radio_regs_5G[8]; - struct nphy_iq_comp rxcal_coeffs_5G; -}; - -struct nphy_pwrctrl { - s8 max_pwr_2g; - s8 idle_targ_2g; - s16 pwrdet_2g_a1; - s16 pwrdet_2g_b0; - s16 pwrdet_2g_b1; - s8 max_pwr_5gm; - s8 idle_targ_5gm; - s8 max_pwr_5gh; - s8 max_pwr_5gl; - s16 pwrdet_5gm_a1; - s16 pwrdet_5gm_b0; - s16 pwrdet_5gm_b1; - s16 pwrdet_5gl_a1; - s16 pwrdet_5gl_b0; - s16 pwrdet_5gl_b1; - s16 pwrdet_5gh_a1; - s16 pwrdet_5gh_b0; - s16 pwrdet_5gh_b1; - s8 idle_targ_5gl; - s8 idle_targ_5gh; - s8 idle_tssi_2g; - s8 idle_tssi_5g; - s8 idle_tssi; - s16 a1; - s16 b0; - s16 b1; -}; - -struct nphy_txgains { - u16 txlpf[2]; - u16 txgm[2]; - u16 pga[2]; - u16 pad[2]; - u16 ipa[2]; -}; - -#define PHY_NOISEVAR_BUFSIZE 10 - -struct nphy_noisevar_buf { - int bufcount; - int tone_id[PHY_NOISEVAR_BUFSIZE]; - u32 noise_vars[PHY_NOISEVAR_BUFSIZE]; - u32 min_noise_vars[PHY_NOISEVAR_BUFSIZE]; -}; - -struct rssical_cache { - u16 rssical_radio_regs_2G[2]; - u16 rssical_phyregs_2G[12]; - - u16 rssical_radio_regs_5G[2]; - u16 rssical_phyregs_5G[12]; -}; - -struct lcnphy_cal_results { - - u16 txiqlocal_a; - u16 txiqlocal_b; - u16 txiqlocal_didq; - u8 txiqlocal_ei0; - u8 txiqlocal_eq0; - u8 txiqlocal_fi0; - u8 txiqlocal_fq0; - - u16 txiqlocal_bestcoeffs[11]; - u16 txiqlocal_bestcoeffs_valid; - - u32 papd_eps_tbl[PHY_PAPD_EPS_TBL_SIZE_LCNPHY]; - u16 analog_gain_ref; - u16 lut_begin; - u16 lut_end; - u16 lut_step; - u16 rxcompdbm; - u16 papdctrl; - u16 sslpnCalibClkEnCtrl; - - u16 rxiqcal_coeff_a0; - u16 rxiqcal_coeff_b0; -}; - -struct shared_phy { - struct brcms_phy *phy_head; - uint unit; - struct si_pub *sih; - struct phy_shim_info *physhim; - uint corerev; - u32 machwcap; - bool up; - bool clk; - uint now; - u16 vid; - u16 did; - uint chip; - uint chiprev; - uint chippkg; - uint sromrev; - uint boardtype; - uint boardrev; - uint boardvendor; - u32 boardflags; - u32 boardflags2; - uint buscorerev; - uint fast_timer; - uint slow_timer; - uint glacial_timer; - u8 rx_antdiv; - s8 phy_noise_window[MA_WINDOW_SZ]; - uint phy_noise_index; - u8 hw_phytxchain; - u8 hw_phyrxchain; - u8 phytxchain; - u8 phyrxchain; - u8 rssi_mode; - bool _rifs_phy; -}; - -struct brcms_phy_pub { - uint phy_type; - uint phy_rev; - u8 phy_corenum; - u16 radioid; - u8 radiorev; - u8 radiover; - - uint coreflags; - uint ana_rev; - bool abgphy_encore; -}; - -struct phy_func_ptr { - void (*init)(struct brcms_phy *); - void (*calinit)(struct brcms_phy *); - void (*chanset)(struct brcms_phy *, u16 chanspec); - void (*txpwrrecalc)(struct brcms_phy *); - int (*longtrn)(struct brcms_phy *, int); - void (*txiqccget)(struct brcms_phy *, u16 *, u16 *); - void (*txiqccset)(struct brcms_phy *, u16, u16); - u16 (*txloccget)(struct brcms_phy *); - void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *); - void (*carrsuppr)(struct brcms_phy *); - s32 (*rxsigpwr)(struct brcms_phy *, s32); - void (*detach)(struct brcms_phy *); -}; - -struct brcms_phy { - struct brcms_phy_pub pubpi_ro; - struct shared_phy *sh; - struct phy_func_ptr pi_fptr; - - union { - struct brcms_phy_lcnphy *pi_lcnphy; - } u; - bool user_txpwr_at_rfport; - - struct d11regs __iomem *regs; - struct brcms_phy *next; - struct brcms_phy_pub pubpi; - - bool do_initcal; - bool phytest_on; - bool ofdm_rateset_war; - bool bf_preempt_4306; - u16 radio_chanspec; - u8 antsel_type; - u16 bw; - u8 txpwr_percent; - bool phy_init_por; - - bool init_in_progress; - bool initialized; - bool sbtml_gm; - uint refcnt; - bool watchdog_override; - u8 phynoise_state; - uint phynoise_now; - int phynoise_chan_watchdog; - bool phynoise_polling; - bool disable_percal; - u32 measure_hold; - - s16 txpa_2g[PWRTBL_NUM_COEFF]; - s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF]; - s16 txpa_2g_high_temp[PWRTBL_NUM_COEFF]; - s16 txpa_5g_low[PWRTBL_NUM_COEFF]; - s16 txpa_5g_mid[PWRTBL_NUM_COEFF]; - s16 txpa_5g_hi[PWRTBL_NUM_COEFF]; - - u8 tx_srom_max_2g; - u8 tx_srom_max_5g_low; - u8 tx_srom_max_5g_mid; - u8 tx_srom_max_5g_hi; - u8 tx_srom_max_rate_2g[TXP_NUM_RATES]; - u8 tx_srom_max_rate_5g_low[TXP_NUM_RATES]; - u8 tx_srom_max_rate_5g_mid[TXP_NUM_RATES]; - u8 tx_srom_max_rate_5g_hi[TXP_NUM_RATES]; - u8 tx_user_target[TXP_NUM_RATES]; - s8 tx_power_offset[TXP_NUM_RATES]; - u8 tx_power_target[TXP_NUM_RATES]; - - struct brcms_phy_srom_fem srom_fem2g; - struct brcms_phy_srom_fem srom_fem5g; - - u8 tx_power_max; - u8 tx_power_max_rate_ind; - bool hwpwrctrl; - u8 nphy_txpwrctrl; - s8 nphy_txrx_chain; - bool phy_5g_pwrgain; - - u16 phy_wreg; - u16 phy_wreg_limit; - - s8 n_preamble_override; - u8 antswitch; - u8 aa2g, aa5g; - - s8 idle_tssi[CH_5G_GROUP]; - s8 target_idle_tssi; - s8 txpwr_est_Pout; - u8 tx_power_min; - u8 txpwr_limit[TXP_NUM_RATES]; - u8 txpwr_env_limit[TXP_NUM_RATES]; - u8 adj_pwr_tbl_nphy[ADJ_PWR_TBL_LEN]; - - bool channel_14_wide_filter; - - bool txpwroverride; - bool txpwridx_override_aphy; - s16 radiopwr_override; - u16 hwpwr_txcur; - u8 saved_txpwr_idx; - - bool edcrs_threshold_lock; - - u32 tr_R_gain_val; - u32 tr_T_gain_val; - - s16 ofdm_analog_filt_bw_override; - s16 cck_analog_filt_bw_override; - s16 ofdm_rccal_override; - s16 cck_rccal_override; - u16 extlna_type; - - uint interference_mode_crs_time; - u16 crsglitch_prev; - bool interference_mode_crs; - - u32 phy_tx_tone_freq; - uint phy_lastcal; - bool phy_forcecal; - bool phy_fixed_noise; - u32 xtalfreq; - u8 pdiv; - s8 carrier_suppr_disable; - - bool phy_bphy_evm; - bool phy_bphy_rfcs; - s8 phy_scraminit; - u8 phy_gpiosel; - - s16 phy_txcore_disable_temp; - s16 phy_txcore_enable_temp; - s8 phy_tempsense_offset; - bool phy_txcore_heatedup; - - u16 radiopwr; - u16 bb_atten; - u16 txctl1; - - u16 mintxbias; - u16 mintxmag; - struct lo_complex_abgphy_info gphy_locomp_iq - [STATIC_NUM_RF][STATIC_NUM_BB]; - s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB]; - u16 gain_table[TX_GAIN_TABLE_LENGTH]; - bool loopback_gain; - s16 max_lpback_gain_hdB; - s16 trsw_rx_gain_hdB; - u8 power_vec[8]; - - u16 rc_cal; - int nrssi_table_delta; - int nrssi_slope_scale; - int nrssi_slope_offset; - int min_rssi; - int max_rssi; - - s8 txpwridx; - u8 min_txpower; - - u8 a_band_high_disable; - - u16 tx_vos; - u16 global_tx_bb_dc_bias_loft; - - int rf_max; - int bb_max; - int rf_list_size; - int bb_list_size; - u16 *rf_attn_list; - u16 *bb_attn_list; - u16 padmix_mask; - u16 padmix_reg; - u16 *txmag_list; - uint txmag_len; - bool txmag_enable; - - s8 *a_tssi_to_dbm; - s8 *m_tssi_to_dbm; - s8 *l_tssi_to_dbm; - s8 *h_tssi_to_dbm; - u8 *hwtxpwr; - - u16 freqtrack_saved_regs[2]; - int cur_interference_mode; - bool hwpwrctrl_capable; - bool temppwrctrl_capable; - - uint phycal_nslope; - uint phycal_noffset; - uint phycal_mlo; - uint phycal_txpower; - - u8 phy_aa2g; - - bool nphy_tableloaded; - s8 nphy_rssisel; - u32 nphy_bb_mult_save; - u16 nphy_txiqlocal_bestc[11]; - bool nphy_txiqlocal_coeffsvalid; - struct nphy_txpwrindex nphy_txpwrindex[PHY_CORE_NUM_2]; - struct nphy_pwrctrl nphy_pwrctrl_info[PHY_CORE_NUM_2]; - u16 cck2gpo; - u32 ofdm2gpo; - u32 ofdm5gpo; - u32 ofdm5glpo; - u32 ofdm5ghpo; - u8 bw402gpo; - u8 bw405gpo; - u8 bw405glpo; - u8 bw405ghpo; - u8 cdd2gpo; - u8 cdd5gpo; - u8 cdd5glpo; - u8 cdd5ghpo; - u8 stbc2gpo; - u8 stbc5gpo; - u8 stbc5glpo; - u8 stbc5ghpo; - u8 bwdup2gpo; - u8 bwdup5gpo; - u8 bwdup5glpo; - u8 bwdup5ghpo; - u16 mcs2gpo[8]; - u16 mcs5gpo[8]; - u16 mcs5glpo[8]; - u16 mcs5ghpo[8]; - u32 nphy_rxcalparams; - - u8 phy_spuravoid; - bool phy_isspuravoid; - - u8 phy_pabias; - u8 nphy_papd_skip; - u8 nphy_tssi_slope; - - s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ]; - u8 nphy_noise_index; - - u8 nphy_txpid2g[PHY_CORE_NUM_2]; - u8 nphy_txpid5g[PHY_CORE_NUM_2]; - u8 nphy_txpid5gl[PHY_CORE_NUM_2]; - u8 nphy_txpid5gh[PHY_CORE_NUM_2]; - - bool nphy_gain_boost; - bool nphy_elna_gain_config; - u16 old_bphy_test; - u16 old_bphy_testcontrol; - - bool phyhang_avoid; - - bool rssical_nphy; - u8 nphy_perical; - uint nphy_perical_last; - u8 cal_type_override; - u8 mphase_cal_phase_id; - u8 mphase_txcal_cmdidx; - u8 mphase_txcal_numcmds; - u16 mphase_txcal_bestcoeffs[11]; - u16 nphy_txiqlocal_chanspec; - u16 nphy_iqcal_chanspec_2G; - u16 nphy_iqcal_chanspec_5G; - u16 nphy_rssical_chanspec_2G; - u16 nphy_rssical_chanspec_5G; - struct wlapi_timer *phycal_timer; - bool use_int_tx_iqlo_cal_nphy; - bool internal_tx_iqlo_cal_tapoff_intpa_nphy; - s16 nphy_lastcal_temp; - - struct txiqcal_cache calibration_cache; - struct rssical_cache rssical_cache; - - u8 nphy_txpwr_idx[2]; - u8 nphy_papd_cal_type; - uint nphy_papd_last_cal; - u16 nphy_papd_tx_gain_at_last_cal[2]; - u8 nphy_papd_cal_gain_index[2]; - s16 nphy_papd_epsilon_offset[2]; - bool nphy_papd_recal_enable; - u32 nphy_papd_recal_counter; - bool nphy_force_papd_cal; - bool nphy_papdcomp; - bool ipa2g_on; - bool ipa5g_on; - - u16 classifier_state; - u16 clip_state[2]; - uint nphy_deaf_count; - u8 rxiq_samps; - u8 rxiq_antsel; - - u16 rfctrlIntc1_save; - u16 rfctrlIntc2_save; - bool first_cal_after_assoc; - u16 tx_rx_cal_radio_saveregs[22]; - u16 tx_rx_cal_phy_saveregs[15]; - - u8 nphy_cal_orig_pwr_idx[2]; - u8 nphy_txcal_pwr_idx[2]; - u8 nphy_rxcal_pwr_idx[2]; - u16 nphy_cal_orig_tx_gain[2]; - struct nphy_txgains nphy_cal_target_gain; - u16 nphy_txcal_bbmult; - u16 nphy_gmval; - - u16 nphy_saved_bbconf; - - bool nphy_gband_spurwar_en; - bool nphy_gband_spurwar2_en; - bool nphy_aband_spurwar_en; - u16 nphy_rccal_value; - u16 nphy_crsminpwr[3]; - struct nphy_noisevar_buf nphy_saved_noisevars; - bool nphy_anarxlpf_adjusted; - bool nphy_crsminpwr_adjusted; - bool nphy_noisevars_adjusted; - - bool nphy_rxcal_active; - u16 radar_percal_mask; - bool dfs_lp_buffer_nphy; - - u16 nphy_fineclockgatecontrol; - - s8 rx2tx_biasentry; - - u16 crsminpwr0; - u16 crsminpwrl0; - u16 crsminpwru0; - s16 noise_crsminpwr_index; - u16 init_gain_core1; - u16 init_gain_core2; - u16 init_gainb_core1; - u16 init_gainb_core2; - u8 aci_noise_curr_channel; - u16 init_gain_rfseq[4]; - - bool radio_is_on; - - bool nphy_sample_play_lpf_bw_ctl_ovr; - - u16 tbl_data_hi; - u16 tbl_data_lo; - u16 tbl_addr; - - uint tbl_save_id; - uint tbl_save_offset; - - u8 txpwrctrl; - s8 txpwrindex[PHY_CORE_MAX]; - - u8 phycal_tempdelta; - u32 mcs20_po; - u32 mcs40_po; - struct wiphy *wiphy; -}; - -struct cs32 { - s32 q; - s32 i; -}; - -struct radio_regs { - u16 address; - u32 init_a; - u32 init_g; - u8 do_init_a; - u8 do_init_g; -}; - -struct radio_20xx_regs { - u16 address; - u8 init; - u8 do_init; -}; - -struct lcnphy_radio_regs { - u16 address; - u8 init_a; - u8 init_g; - u8 do_init_a; - u8 do_init_g; -}; - -extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr); -extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); -extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); -extern void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val); -extern void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val); - -extern u16 read_radio_reg(struct brcms_phy *pi, u16 addr); -extern void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val); -extern void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val); -extern void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, - u16 val); -extern void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask); - -extern void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val); - -extern void wlc_phyreg_enter(struct brcms_phy_pub *pih); -extern void wlc_phyreg_exit(struct brcms_phy_pub *pih); -extern void wlc_radioreg_enter(struct brcms_phy_pub *pih); -extern void wlc_radioreg_exit(struct brcms_phy_pub *pih); - -extern void wlc_phy_read_table(struct brcms_phy *pi, - const struct phytbl_info *ptbl_info, - u16 tblAddr, u16 tblDataHi, - u16 tblDatalo); -extern void wlc_phy_write_table(struct brcms_phy *pi, - const struct phytbl_info *ptbl_info, - u16 tblAddr, u16 tblDataHi, u16 tblDatalo); -extern void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, - uint tbl_offset, u16 tblAddr, u16 tblDataHi, - u16 tblDataLo); -extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val); - -extern void write_phy_channel_reg(struct brcms_phy *pi, uint val); -extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi); - -extern u8 wlc_phy_nbits(s32 value); -extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core); - -extern uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, - struct radio_20xx_regs *radioregs); -extern uint wlc_phy_init_radio_regs(struct brcms_phy *pi, - const struct radio_regs *radioregs, - u16 core_offset); - -extern void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi); - -extern void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on); -extern void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, - s32 *eps_imag); - -extern void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi); -extern void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi); - -extern bool wlc_phy_attach_nphy(struct brcms_phy *pi); -extern bool wlc_phy_attach_lcnphy(struct brcms_phy *pi); - -extern void wlc_phy_detach_lcnphy(struct brcms_phy *pi); - -extern void wlc_phy_init_nphy(struct brcms_phy *pi); -extern void wlc_phy_init_lcnphy(struct brcms_phy *pi); - -extern void wlc_phy_cal_init_nphy(struct brcms_phy *pi); -extern void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi); - -extern void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, - u16 chanspec); -extern void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, - u16 chanspec); -extern void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, - u16 chanspec); -extern int wlc_phy_channel2freq(uint channel); -extern int wlc_phy_chanspec_freq2bandrange_lpssn(uint); -extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec); - -extern void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode); -extern s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi); - -extern void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi); -extern void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi); -extern void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi); - -extern void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index); -extern void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable); -extern void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi); -extern void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, - u16 max_val, bool iqcalmode); - -extern void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan, - u8 *max_pwr, u8 rate_id); -extern void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start, - u8 rate_mcs_end, - u8 rate_ofdm_start); -extern void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, - u8 rate_ofdm_start, - u8 rate_ofdm_end, - u8 rate_mcs_start); - -extern u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode); -extern s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode); -extern s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode); -extern s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode); -extern void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi); -extern void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel); -extern void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode); -extern void wlc_2064_vco_cal(struct brcms_phy *pi); - -extern void wlc_phy_txpower_recalc_target(struct brcms_phy *pi); - -#define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18 -#define LCNPHY_TX_POWER_TABLE_SIZE 128 -#define LCNPHY_MAX_TX_POWER_INDEX (LCNPHY_TX_POWER_TABLE_SIZE - 1) -#define LCNPHY_TBL_ID_TXPWRCTL 0x07 -#define LCNPHY_TX_PWR_CTRL_OFF 0 -#define LCNPHY_TX_PWR_CTRL_SW (0x1 << 15) -#define LCNPHY_TX_PWR_CTRL_HW ((0x1 << 15) | \ - (0x1 << 14) | \ - (0x1 << 13)) - -#define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE001 - -extern void wlc_lcnphy_write_table(struct brcms_phy *pi, - const struct phytbl_info *pti); -extern void wlc_lcnphy_read_table(struct brcms_phy *pi, - struct phytbl_info *pti); -extern void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b); -extern void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq); -extern void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b); -extern u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi); -extern void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0, - u8 *eq0, u8 *fi0, u8 *fq0); -extern void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode); -extern void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode); -extern bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi); -extern void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi); -extern s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1); -extern void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, - s8 *cck_pwr); -extern void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi); - -extern s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index); - -#define NPHY_MAX_HPVGA1_INDEX 10 -#define NPHY_DEF_HPVGA1_INDEXLIMIT 7 - -struct phy_iq_est { - s32 iq_prod; - u32 i_pwr; - u32 q_pwr; -}; - -extern void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, - bool enable); -extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode); - -#define wlc_phy_write_table_nphy(pi, pti) \ - wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73) - -#define wlc_phy_read_table_nphy(pi, pti) \ - wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73) - -#define wlc_nphy_table_addr(pi, id, off) \ - wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73) - -#define wlc_nphy_table_data_write(pi, w, v) \ - wlc_phy_table_data_write((pi), (w), (v)) - -extern void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, - u32 w, void *d); -extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, - u32, const void *); - -#define PHY_IPA(pi) \ - ((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \ - (pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec))) - -#define BRCMS_PHY_WAR_PR51571(pi) \ - if (NREV_LT((pi)->pubpi.phy_rev, 3)) \ - (void)R_REG(&(pi)->regs->maccontrol) - -extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype); -extern void wlc_phy_aci_reset_nphy(struct brcms_phy *pi); -extern void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en); - -extern u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan); -extern void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on); - -extern void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi); - -extern void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd); -extern s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi); - -extern u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val); - -extern void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est, - u16 num_samps, u8 wait_time, - u8 wait_for_crs); - -extern void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write, - struct nphy_iq_comp *comp); -extern void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi); - -extern void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, - u8 rxcore_bitmask); -extern u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih); - -extern void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type); -extern void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi); -extern void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi); -extern void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi); -extern u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi); - -extern struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi); -extern int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, - struct nphy_txgains target_gain, - bool full, bool m); -extern int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, - struct nphy_txgains target_gain, - u8 type, bool d); -extern void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, - s8 txpwrindex, bool res); -extern void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type); -extern int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type, - s32 *rssi_buf, u8 nsamps); -extern void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi); -extern int wlc_phy_aci_scan_nphy(struct brcms_phy *pi); -extern void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, - s32 dBm_targetpower, bool debug); -extern int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, - u8 mode, u8, bool); -extern void wlc_phy_stopplayback_nphy(struct brcms_phy *pi); -extern void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, - u8 num_samps); -extern void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi); - -extern int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, - struct d11rxhdr *rxh); - -#define NPHY_TESTPATTERN_BPHY_EVM 0 -#define NPHY_TESTPATTERN_BPHY_RFCS 1 - -extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs); - -void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, - s8 *ofdmoffset); -extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, - u16 chanspec); - -extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih); -#endif /* _BRCM_PHY_INT_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c deleted file mode 100644 index a63aa99d981..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +++ /dev/null @@ -1,5154 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include "phy_qmath.h" -#include "phy_hal.h" -#include "phy_radio.h" -#include "phytbl_lcn.h" -#include "phy_lcn.h" - -#define PLL_2064_NDIV 90 -#define PLL_2064_LOW_END_VCO 3000 -#define PLL_2064_LOW_END_KVCO 27 -#define PLL_2064_HIGH_END_VCO 4200 -#define PLL_2064_HIGH_END_KVCO 68 -#define PLL_2064_LOOP_BW_DOUBLER 200 -#define PLL_2064_D30_DOUBLER 10500 -#define PLL_2064_LOOP_BW 260 -#define PLL_2064_D30 8000 -#define PLL_2064_CAL_REF_TO 8 -#define PLL_2064_MHZ 1000000 -#define PLL_2064_OPEN_LOOP_DELAY 5 - -#define TEMPSENSE 1 -#define VBATSENSE 2 - -#define NOISE_IF_UPD_CHK_INTERVAL 1 -#define NOISE_IF_UPD_RST_INTERVAL 60 -#define NOISE_IF_UPD_THRESHOLD_CNT 1 -#define NOISE_IF_UPD_TRHRESHOLD 50 -#define NOISE_IF_UPD_TIMEOUT 1000 -#define NOISE_IF_OFF 0 -#define NOISE_IF_CHK 1 -#define NOISE_IF_ON 2 - -#define PAPD_BLANKING_PROFILE 3 -#define PAPD2LUT 0 -#define PAPD_CORR_NORM 0 -#define PAPD_BLANKING_THRESHOLD 0 -#define PAPD_STOP_AFTER_LAST_UPDATE 0 - -#define LCN_TARGET_PWR 60 - -#define LCN_VBAT_OFFSET_433X 34649679 -#define LCN_VBAT_SLOPE_433X 8258032 - -#define LCN_VBAT_SCALE_NOM 53 -#define LCN_VBAT_SCALE_DEN 432 - -#define LCN_TEMPSENSE_OFFSET 80812 -#define LCN_TEMPSENSE_DEN 2647 - -#define LCN_BW_LMT 200 -#define LCN_CUR_LMT 1250 -#define LCN_MULT 1 -#define LCN_VCO_DIV 30 -#define LCN_OFFSET 680 -#define LCN_FACT 490 -#define LCN_CUR_DIV 2640 - -#define LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT \ - (0 + 8) -#define LCNPHY_txgainctrlovrval1_pagain_ovr_val1_MASK \ - (0x7f << LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT) - -#define LCNPHY_stxtxgainctrlovrval1_pagain_ovr_val1_SHIFT \ - (0 + 8) -#define LCNPHY_stxtxgainctrlovrval1_pagain_ovr_val1_MASK \ - (0x7f << LCNPHY_stxtxgainctrlovrval1_pagain_ovr_val1_SHIFT) - -#define wlc_lcnphy_enable_tx_gain_override(pi) \ - wlc_lcnphy_set_tx_gain_override(pi, true) -#define wlc_lcnphy_disable_tx_gain_override(pi) \ - wlc_lcnphy_set_tx_gain_override(pi, false) - -#define wlc_lcnphy_iqcal_active(pi) \ - (read_phy_reg((pi), 0x451) & \ - ((0x1 << 15) | (0x1 << 14))) - -#define txpwrctrl_off(pi) (0x7 != ((read_phy_reg(pi, 0x4a4) & 0xE000) >> 13)) -#define wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) \ - (pi->temppwrctrl_capable) -#define wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi) \ - (pi->hwpwrctrl_capable) - -#define SWCTRL_BT_TX 0x18 -#define SWCTRL_OVR_DISABLE 0x40 - -#define AFE_CLK_INIT_MODE_TXRX2X 1 -#define AFE_CLK_INIT_MODE_PAPD 0 - -#define LCNPHY_TBL_ID_IQLOCAL 0x00 - -#define LCNPHY_TBL_ID_RFSEQ 0x08 -#define LCNPHY_TBL_ID_GAIN_IDX 0x0d -#define LCNPHY_TBL_ID_SW_CTRL 0x0f -#define LCNPHY_TBL_ID_GAIN_TBL 0x12 -#define LCNPHY_TBL_ID_SPUR 0x14 -#define LCNPHY_TBL_ID_SAMPLEPLAY 0x15 -#define LCNPHY_TBL_ID_SAMPLEPLAY1 0x16 - -#define LCNPHY_TX_PWR_CTRL_RATE_OFFSET 832 -#define LCNPHY_TX_PWR_CTRL_MAC_OFFSET 128 -#define LCNPHY_TX_PWR_CTRL_GAIN_OFFSET 192 -#define LCNPHY_TX_PWR_CTRL_IQ_OFFSET 320 -#define LCNPHY_TX_PWR_CTRL_LO_OFFSET 448 -#define LCNPHY_TX_PWR_CTRL_PWR_OFFSET 576 - -#define LCNPHY_TX_PWR_CTRL_START_INDEX_2G_4313 140 - -#define LCNPHY_TX_PWR_CTRL_START_NPT 1 -#define LCNPHY_TX_PWR_CTRL_MAX_NPT 7 - -#define LCNPHY_NOISE_SAMPLES_DEFAULT 5000 - -#define LCNPHY_ACI_DETECT_START 1 -#define LCNPHY_ACI_DETECT_PROGRESS 2 -#define LCNPHY_ACI_DETECT_STOP 3 - -#define LCNPHY_ACI_CRSHIFRMLO_TRSH 100 -#define LCNPHY_ACI_GLITCH_TRSH 2000 -#define LCNPHY_ACI_TMOUT 250 -#define LCNPHY_ACI_DETECT_TIMEOUT 2 -#define LCNPHY_ACI_START_DELAY 0 - -#define wlc_lcnphy_tx_gain_override_enabled(pi) \ - (0 != (read_phy_reg((pi), 0x43b) & (0x1 << 6))) - -#define wlc_lcnphy_total_tx_frames(pi) \ - wlapi_bmac_read_shm((pi)->sh->physhim, M_UCODE_MACSTAT + \ - offsetof(struct macstat, txallfrm)) - -struct lcnphy_txgains { - u16 gm_gain; - u16 pga_gain; - u16 pad_gain; - u16 dac_gain; -}; - -enum lcnphy_cal_mode { - LCNPHY_CAL_FULL, - LCNPHY_CAL_RECAL, - LCNPHY_CAL_CURRECAL, - LCNPHY_CAL_DIGCAL, - LCNPHY_CAL_GCTRL -}; - -struct lcnphy_rx_iqcomp { - u8 chan; - s16 a; - s16 b; -}; - -struct lcnphy_spb_tone { - s16 re; - s16 im; -}; - -struct lcnphy_unsign16_struct { - u16 re; - u16 im; -}; - -struct lcnphy_iq_est { - u32 iq_prod; - u32 i_pwr; - u32 q_pwr; -}; - -struct lcnphy_sfo_cfg { - u16 ptcentreTs20; - u16 ptcentreFactor; -}; - -enum lcnphy_papd_cal_type { - LCNPHY_PAPD_CAL_CW, - LCNPHY_PAPD_CAL_OFDM -}; - -typedef u16 iqcal_gain_params_lcnphy[9]; - -static const iqcal_gain_params_lcnphy tbl_iqcal_gainparams_lcnphy_2G[] = { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, -}; - -static const iqcal_gain_params_lcnphy *tbl_iqcal_gainparams_lcnphy[1] = { - tbl_iqcal_gainparams_lcnphy_2G, -}; - -static const u16 iqcal_gainparams_numgains_lcnphy[1] = { - sizeof(tbl_iqcal_gainparams_lcnphy_2G) / - sizeof(*tbl_iqcal_gainparams_lcnphy_2G), -}; - -static const struct lcnphy_sfo_cfg lcnphy_sfo_cfg[] = { - {965, 1087}, - {967, 1085}, - {969, 1082}, - {971, 1080}, - {973, 1078}, - {975, 1076}, - {977, 1073}, - {979, 1071}, - {981, 1069}, - {983, 1067}, - {985, 1065}, - {987, 1063}, - {989, 1060}, - {994, 1055} -}; - -static const -u16 lcnphy_iqcal_loft_gainladder[] = { - ((2 << 8) | 0), - ((3 << 8) | 0), - ((4 << 8) | 0), - ((6 << 8) | 0), - ((8 << 8) | 0), - ((11 << 8) | 0), - ((16 << 8) | 0), - ((16 << 8) | 1), - ((16 << 8) | 2), - ((16 << 8) | 3), - ((16 << 8) | 4), - ((16 << 8) | 5), - ((16 << 8) | 6), - ((16 << 8) | 7), - ((23 << 8) | 7), - ((32 << 8) | 7), - ((45 << 8) | 7), - ((64 << 8) | 7), - ((91 << 8) | 7), - ((128 << 8) | 7) -}; - -static const -u16 lcnphy_iqcal_ir_gainladder[] = { - ((1 << 8) | 0), - ((2 << 8) | 0), - ((4 << 8) | 0), - ((6 << 8) | 0), - ((8 << 8) | 0), - ((11 << 8) | 0), - ((16 << 8) | 0), - ((23 << 8) | 0), - ((32 << 8) | 0), - ((45 << 8) | 0), - ((64 << 8) | 0), - ((64 << 8) | 1), - ((64 << 8) | 2), - ((64 << 8) | 3), - ((64 << 8) | 4), - ((64 << 8) | 5), - ((64 << 8) | 6), - ((64 << 8) | 7), - ((91 << 8) | 7), - ((128 << 8) | 7) -}; - -static const -struct lcnphy_spb_tone lcnphy_spb_tone_3750[] = { - {88, 0}, - {73, 49}, - {34, 81}, - {-17, 86}, - {-62, 62}, - {-86, 17}, - {-81, -34}, - {-49, -73}, - {0, -88}, - {49, -73}, - {81, -34}, - {86, 17}, - {62, 62}, - {17, 86}, - {-34, 81}, - {-73, 49}, - {-88, 0}, - {-73, -49}, - {-34, -81}, - {17, -86}, - {62, -62}, - {86, -17}, - {81, 34}, - {49, 73}, - {0, 88}, - {-49, 73}, - {-81, 34}, - {-86, -17}, - {-62, -62}, - {-17, -86}, - {34, -81}, - {73, -49}, -}; - -static const -u16 iqlo_loopback_rf_regs[20] = { - RADIO_2064_REG036, - RADIO_2064_REG11A, - RADIO_2064_REG03A, - RADIO_2064_REG025, - RADIO_2064_REG028, - RADIO_2064_REG005, - RADIO_2064_REG112, - RADIO_2064_REG0FF, - RADIO_2064_REG11F, - RADIO_2064_REG00B, - RADIO_2064_REG113, - RADIO_2064_REG007, - RADIO_2064_REG0FC, - RADIO_2064_REG0FD, - RADIO_2064_REG012, - RADIO_2064_REG057, - RADIO_2064_REG059, - RADIO_2064_REG05C, - RADIO_2064_REG078, - RADIO_2064_REG092, -}; - -static const -u16 tempsense_phy_regs[14] = { - 0x503, - 0x4a4, - 0x4d0, - 0x4d9, - 0x4da, - 0x4a6, - 0x938, - 0x939, - 0x4d8, - 0x4d0, - 0x4d7, - 0x4a5, - 0x40d, - 0x4a2, -}; - -static const -u16 rxiq_cal_rf_reg[11] = { - RADIO_2064_REG098, - RADIO_2064_REG116, - RADIO_2064_REG12C, - RADIO_2064_REG06A, - RADIO_2064_REG00B, - RADIO_2064_REG01B, - RADIO_2064_REG113, - RADIO_2064_REG01D, - RADIO_2064_REG114, - RADIO_2064_REG02E, - RADIO_2064_REG12A, -}; - -static const -struct lcnphy_rx_iqcomp lcnphy_rx_iqcomp_table_rev0[] = { - {1, 0, 0}, - {2, 0, 0}, - {3, 0, 0}, - {4, 0, 0}, - {5, 0, 0}, - {6, 0, 0}, - {7, 0, 0}, - {8, 0, 0}, - {9, 0, 0}, - {10, 0, 0}, - {11, 0, 0}, - {12, 0, 0}, - {13, 0, 0}, - {14, 0, 0}, - {34, 0, 0}, - {38, 0, 0}, - {42, 0, 0}, - {46, 0, 0}, - {36, 0, 0}, - {40, 0, 0}, - {44, 0, 0}, - {48, 0, 0}, - {52, 0, 0}, - {56, 0, 0}, - {60, 0, 0}, - {64, 0, 0}, - {100, 0, 0}, - {104, 0, 0}, - {108, 0, 0}, - {112, 0, 0}, - {116, 0, 0}, - {120, 0, 0}, - {124, 0, 0}, - {128, 0, 0}, - {132, 0, 0}, - {136, 0, 0}, - {140, 0, 0}, - {149, 0, 0}, - {153, 0, 0}, - {157, 0, 0}, - {161, 0, 0}, - {165, 0, 0}, - {184, 0, 0}, - {188, 0, 0}, - {192, 0, 0}, - {196, 0, 0}, - {200, 0, 0}, - {204, 0, 0}, - {208, 0, 0}, - {212, 0, 0}, - {216, 0, 0}, -}; - -static const u32 lcnphy_23bitgaincode_table[] = { - 0x200100, - 0x200200, - 0x200004, - 0x200014, - 0x200024, - 0x200034, - 0x200134, - 0x200234, - 0x200334, - 0x200434, - 0x200037, - 0x200137, - 0x200237, - 0x200337, - 0x200437, - 0x000035, - 0x000135, - 0x000235, - 0x000037, - 0x000137, - 0x000237, - 0x000337, - 0x00013f, - 0x00023f, - 0x00033f, - 0x00034f, - 0x00044f, - 0x00144f, - 0x00244f, - 0x00254f, - 0x00354f, - 0x00454f, - 0x00464f, - 0x01464f, - 0x02464f, - 0x03464f, - 0x04464f, -}; - -static const s8 lcnphy_gain_table[] = { - -16, - -13, - 10, - 7, - 4, - 0, - 3, - 6, - 9, - 12, - 15, - 18, - 21, - 24, - 27, - 30, - 33, - 36, - 39, - 42, - 45, - 48, - 50, - 53, - 56, - 59, - 62, - 65, - 68, - 71, - 74, - 77, - 80, - 83, - 86, - 89, - 92, -}; - -static const s8 lcnphy_gain_index_offset_for_rssi[] = { - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 8, - 7, - 7, - 6, - 7, - 7, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 2, - 2, - 2, - 2, - 2, - 2, - -1, - -2, - -2, - -2 -}; - -struct chan_info_2064_lcnphy { - uint chan; - uint freq; - u8 logen_buftune; - u8 logen_rccr_tx; - u8 txrf_mix_tune_ctrl; - u8 pa_input_tune_g; - u8 logen_rccr_rx; - u8 pa_rxrf_lna1_freq_tune; - u8 pa_rxrf_lna2_freq_tune; - u8 rxrf_rxrf_spare1; -}; - -static const struct chan_info_2064_lcnphy chan_info_2064_lcnphy[] = { - {1, 2412, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {2, 2417, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {3, 2422, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {4, 2427, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {5, 2432, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {6, 2437, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {7, 2442, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {8, 2447, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {9, 2452, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {10, 2457, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {11, 2462, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {12, 2467, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {13, 2472, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, - {14, 2484, 0x0B, 0x0A, 0x00, 0x07, 0x0A, 0x88, 0x88, 0x80}, -}; - -static const struct lcnphy_radio_regs lcnphy_radio_regs_2064[] = { - {0x00, 0, 0, 0, 0}, - {0x01, 0x64, 0x64, 0, 0}, - {0x02, 0x20, 0x20, 0, 0}, - {0x03, 0x66, 0x66, 0, 0}, - {0x04, 0xf8, 0xf8, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0x10, 0x10, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0x37, 0x37, 0, 0}, - {0x0B, 0x6, 0x6, 0, 0}, - {0x0C, 0x55, 0x55, 0, 0}, - {0x0D, 0x8b, 0x8b, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0x5, 0x5, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0xe, 0xe, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0xb, 0xb, 0, 0}, - {0x14, 0x2, 0x2, 0, 0}, - {0x15, 0x12, 0x12, 0, 0}, - {0x16, 0x12, 0x12, 0, 0}, - {0x17, 0xc, 0xc, 0, 0}, - {0x18, 0xc, 0xc, 0, 0}, - {0x19, 0xc, 0xc, 0, 0}, - {0x1A, 0x8, 0x8, 0, 0}, - {0x1B, 0x2, 0x2, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0x1, 0x1, 0, 0}, - {0x1E, 0x12, 0x12, 0, 0}, - {0x1F, 0x6e, 0x6e, 0, 0}, - {0x20, 0x2, 0x2, 0, 0}, - {0x21, 0x23, 0x23, 0, 0}, - {0x22, 0x8, 0x8, 0, 0}, - {0x23, 0, 0, 0, 0}, - {0x24, 0, 0, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0x33, 0x33, 0, 0}, - {0x27, 0x55, 0x55, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x30, 0x30, 0, 0}, - {0x2A, 0xb, 0xb, 0, 0}, - {0x2B, 0x1b, 0x1b, 0, 0}, - {0x2C, 0x3, 0x3, 0, 0}, - {0x2D, 0x1b, 0x1b, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x20, 0x20, 0, 0}, - {0x30, 0xa, 0xa, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0x62, 0x62, 0, 0}, - {0x33, 0x19, 0x19, 0, 0}, - {0x34, 0x33, 0x33, 0, 0}, - {0x35, 0x77, 0x77, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x70, 0x70, 0, 0}, - {0x38, 0x3, 0x3, 0, 0}, - {0x39, 0xf, 0xf, 0, 0}, - {0x3A, 0x6, 0x6, 0, 0}, - {0x3B, 0xcf, 0xcf, 0, 0}, - {0x3C, 0x1a, 0x1a, 0, 0}, - {0x3D, 0x6, 0x6, 0, 0}, - {0x3E, 0x42, 0x42, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0xfb, 0xfb, 0, 0}, - {0x41, 0x9a, 0x9a, 0, 0}, - {0x42, 0x7a, 0x7a, 0, 0}, - {0x43, 0x29, 0x29, 0, 0}, - {0x44, 0, 0, 0, 0}, - {0x45, 0x8, 0x8, 0, 0}, - {0x46, 0xce, 0xce, 0, 0}, - {0x47, 0x27, 0x27, 0, 0}, - {0x48, 0x62, 0x62, 0, 0}, - {0x49, 0x6, 0x6, 0, 0}, - {0x4A, 0x58, 0x58, 0, 0}, - {0x4B, 0xf7, 0xf7, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0xb3, 0xb3, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0, 0, 0, 0}, - {0x51, 0x9, 0x9, 0, 0}, - {0x52, 0x5, 0x5, 0, 0}, - {0x53, 0x17, 0x17, 0, 0}, - {0x54, 0x38, 0x38, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0xb, 0xb, 0, 0}, - {0x58, 0, 0, 0, 0}, - {0x59, 0, 0, 0, 0}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0, 0, 0, 0}, - {0x5C, 0, 0, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x88, 0x88, 0, 0}, - {0x5F, 0xcc, 0xcc, 0, 0}, - {0x60, 0x74, 0x74, 0, 0}, - {0x61, 0x74, 0x74, 0, 0}, - {0x62, 0x74, 0x74, 0, 0}, - {0x63, 0x44, 0x44, 0, 0}, - {0x64, 0x77, 0x77, 0, 0}, - {0x65, 0x44, 0x44, 0, 0}, - {0x66, 0x77, 0x77, 0, 0}, - {0x67, 0x55, 0x55, 0, 0}, - {0x68, 0x77, 0x77, 0, 0}, - {0x69, 0x77, 0x77, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0x7f, 0x7f, 0, 0}, - {0x6C, 0x8, 0x8, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0x88, 0x88, 0, 0}, - {0x6F, 0x66, 0x66, 0, 0}, - {0x70, 0x66, 0x66, 0, 0}, - {0x71, 0x28, 0x28, 0, 0}, - {0x72, 0x55, 0x55, 0, 0}, - {0x73, 0x4, 0x4, 0, 0}, - {0x74, 0, 0, 0, 0}, - {0x75, 0, 0, 0, 0}, - {0x76, 0, 0, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0xd6, 0xd6, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0xb4, 0xb4, 0, 0}, - {0x84, 0x1, 0x1, 0, 0}, - {0x85, 0x20, 0x20, 0, 0}, - {0x86, 0x5, 0x5, 0, 0}, - {0x87, 0xff, 0xff, 0, 0}, - {0x88, 0x7, 0x7, 0, 0}, - {0x89, 0x77, 0x77, 0, 0}, - {0x8A, 0x77, 0x77, 0, 0}, - {0x8B, 0x77, 0x77, 0, 0}, - {0x8C, 0x77, 0x77, 0, 0}, - {0x8D, 0x8, 0x8, 0, 0}, - {0x8E, 0xa, 0xa, 0, 0}, - {0x8F, 0x8, 0x8, 0, 0}, - {0x90, 0x18, 0x18, 0, 0}, - {0x91, 0x5, 0x5, 0, 0}, - {0x92, 0x1f, 0x1f, 0, 0}, - {0x93, 0x10, 0x10, 0, 0}, - {0x94, 0x3, 0x3, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0xaa, 0xaa, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0x23, 0x23, 0, 0}, - {0x9A, 0x7, 0x7, 0, 0}, - {0x9B, 0xf, 0xf, 0, 0}, - {0x9C, 0x10, 0x10, 0, 0}, - {0x9D, 0x3, 0x3, 0, 0}, - {0x9E, 0x4, 0x4, 0, 0}, - {0x9F, 0x20, 0x20, 0, 0}, - {0xA0, 0, 0, 0, 0}, - {0xA1, 0, 0, 0, 0}, - {0xA2, 0, 0, 0, 0}, - {0xA3, 0, 0, 0, 0}, - {0xA4, 0x1, 0x1, 0, 0}, - {0xA5, 0x77, 0x77, 0, 0}, - {0xA6, 0x77, 0x77, 0, 0}, - {0xA7, 0x77, 0x77, 0, 0}, - {0xA8, 0x77, 0x77, 0, 0}, - {0xA9, 0x8c, 0x8c, 0, 0}, - {0xAA, 0x88, 0x88, 0, 0}, - {0xAB, 0x78, 0x78, 0, 0}, - {0xAC, 0x57, 0x57, 0, 0}, - {0xAD, 0x88, 0x88, 0, 0}, - {0xAE, 0, 0, 0, 0}, - {0xAF, 0x8, 0x8, 0, 0}, - {0xB0, 0x88, 0x88, 0, 0}, - {0xB1, 0, 0, 0, 0}, - {0xB2, 0x1b, 0x1b, 0, 0}, - {0xB3, 0x3, 0x3, 0, 0}, - {0xB4, 0x24, 0x24, 0, 0}, - {0xB5, 0x3, 0x3, 0, 0}, - {0xB6, 0x1b, 0x1b, 0, 0}, - {0xB7, 0x24, 0x24, 0, 0}, - {0xB8, 0x3, 0x3, 0, 0}, - {0xB9, 0, 0, 0, 0}, - {0xBA, 0xaa, 0xaa, 0, 0}, - {0xBB, 0, 0, 0, 0}, - {0xBC, 0x4, 0x4, 0, 0}, - {0xBD, 0, 0, 0, 0}, - {0xBE, 0x8, 0x8, 0, 0}, - {0xBF, 0x11, 0x11, 0, 0}, - {0xC0, 0, 0, 0, 0}, - {0xC1, 0, 0, 0, 0}, - {0xC2, 0x62, 0x62, 0, 0}, - {0xC3, 0x1e, 0x1e, 0, 0}, - {0xC4, 0x33, 0x33, 0, 0}, - {0xC5, 0x37, 0x37, 0, 0}, - {0xC6, 0, 0, 0, 0}, - {0xC7, 0x70, 0x70, 0, 0}, - {0xC8, 0x1e, 0x1e, 0, 0}, - {0xC9, 0x6, 0x6, 0, 0}, - {0xCA, 0x4, 0x4, 0, 0}, - {0xCB, 0x2f, 0x2f, 0, 0}, - {0xCC, 0xf, 0xf, 0, 0}, - {0xCD, 0, 0, 0, 0}, - {0xCE, 0xff, 0xff, 0, 0}, - {0xCF, 0x8, 0x8, 0, 0}, - {0xD0, 0x3f, 0x3f, 0, 0}, - {0xD1, 0x3f, 0x3f, 0, 0}, - {0xD2, 0x3f, 0x3f, 0, 0}, - {0xD3, 0, 0, 0, 0}, - {0xD4, 0, 0, 0, 0}, - {0xD5, 0, 0, 0, 0}, - {0xD6, 0xcc, 0xcc, 0, 0}, - {0xD7, 0, 0, 0, 0}, - {0xD8, 0x8, 0x8, 0, 0}, - {0xD9, 0x8, 0x8, 0, 0}, - {0xDA, 0x8, 0x8, 0, 0}, - {0xDB, 0x11, 0x11, 0, 0}, - {0xDC, 0, 0, 0, 0}, - {0xDD, 0x87, 0x87, 0, 0}, - {0xDE, 0x88, 0x88, 0, 0}, - {0xDF, 0x8, 0x8, 0, 0}, - {0xE0, 0x8, 0x8, 0, 0}, - {0xE1, 0x8, 0x8, 0, 0}, - {0xE2, 0, 0, 0, 0}, - {0xE3, 0, 0, 0, 0}, - {0xE4, 0, 0, 0, 0}, - {0xE5, 0xf5, 0xf5, 0, 0}, - {0xE6, 0x30, 0x30, 0, 0}, - {0xE7, 0x1, 0x1, 0, 0}, - {0xE8, 0, 0, 0, 0}, - {0xE9, 0xff, 0xff, 0, 0}, - {0xEA, 0, 0, 0, 0}, - {0xEB, 0, 0, 0, 0}, - {0xEC, 0x22, 0x22, 0, 0}, - {0xED, 0, 0, 0, 0}, - {0xEE, 0, 0, 0, 0}, - {0xEF, 0, 0, 0, 0}, - {0xF0, 0x3, 0x3, 0, 0}, - {0xF1, 0x1, 0x1, 0, 0}, - {0xF2, 0, 0, 0, 0}, - {0xF3, 0, 0, 0, 0}, - {0xF4, 0, 0, 0, 0}, - {0xF5, 0, 0, 0, 0}, - {0xF6, 0, 0, 0, 0}, - {0xF7, 0x6, 0x6, 0, 0}, - {0xF8, 0, 0, 0, 0}, - {0xF9, 0, 0, 0, 0}, - {0xFA, 0x40, 0x40, 0, 0}, - {0xFB, 0, 0, 0, 0}, - {0xFC, 0x1, 0x1, 0, 0}, - {0xFD, 0x80, 0x80, 0, 0}, - {0xFE, 0x2, 0x2, 0, 0}, - {0xFF, 0x10, 0x10, 0, 0}, - {0x100, 0x2, 0x2, 0, 0}, - {0x101, 0x1e, 0x1e, 0, 0}, - {0x102, 0x1e, 0x1e, 0, 0}, - {0x103, 0, 0, 0, 0}, - {0x104, 0x1f, 0x1f, 0, 0}, - {0x105, 0, 0x8, 0, 1}, - {0x106, 0x2a, 0x2a, 0, 0}, - {0x107, 0xf, 0xf, 0, 0}, - {0x108, 0, 0, 0, 0}, - {0x109, 0, 0, 0, 0}, - {0x10A, 0, 0, 0, 0}, - {0x10B, 0, 0, 0, 0}, - {0x10C, 0, 0, 0, 0}, - {0x10D, 0, 0, 0, 0}, - {0x10E, 0, 0, 0, 0}, - {0x10F, 0, 0, 0, 0}, - {0x110, 0, 0, 0, 0}, - {0x111, 0, 0, 0, 0}, - {0x112, 0, 0, 0, 0}, - {0x113, 0, 0, 0, 0}, - {0x114, 0, 0, 0, 0}, - {0x115, 0, 0, 0, 0}, - {0x116, 0, 0, 0, 0}, - {0x117, 0, 0, 0, 0}, - {0x118, 0, 0, 0, 0}, - {0x119, 0, 0, 0, 0}, - {0x11A, 0, 0, 0, 0}, - {0x11B, 0, 0, 0, 0}, - {0x11C, 0x1, 0x1, 0, 0}, - {0x11D, 0, 0, 0, 0}, - {0x11E, 0, 0, 0, 0}, - {0x11F, 0, 0, 0, 0}, - {0x120, 0, 0, 0, 0}, - {0x121, 0, 0, 0, 0}, - {0x122, 0x80, 0x80, 0, 0}, - {0x123, 0, 0, 0, 0}, - {0x124, 0xf8, 0xf8, 0, 0}, - {0x125, 0, 0, 0, 0}, - {0x126, 0, 0, 0, 0}, - {0x127, 0, 0, 0, 0}, - {0x128, 0, 0, 0, 0}, - {0x129, 0, 0, 0, 0}, - {0x12A, 0, 0, 0, 0}, - {0x12B, 0, 0, 0, 0}, - {0x12C, 0, 0, 0, 0}, - {0x12D, 0, 0, 0, 0}, - {0x12E, 0, 0, 0, 0}, - {0x12F, 0, 0, 0, 0}, - {0x130, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -#define LCNPHY_NUM_DIG_FILT_COEFFS 16 -#define LCNPHY_NUM_TX_DIG_FILTERS_CCK 13 - -static const u16 LCNPHY_txdigfiltcoeffs_cck[LCNPHY_NUM_TX_DIG_FILTERS_CCK] - [LCNPHY_NUM_DIG_FILT_COEFFS + 1] = { - {0, 1, 415, 1874, 64, 128, 64, 792, 1656, 64, 128, 64, 778, 1582, 64, - 128, 64,}, - {1, 1, 402, 1847, 259, 59, 259, 671, 1794, 68, 54, 68, 608, 1863, 93, - 167, 93,}, - {2, 1, 415, 1874, 64, 128, 64, 792, 1656, 192, 384, 192, 778, 1582, 64, - 128, 64,}, - {3, 1, 302, 1841, 129, 258, 129, 658, 1720, 205, 410, 205, 754, 1760, - 170, 340, 170,}, - {20, 1, 360, 1884, 242, 1734, 242, 752, 1720, 205, 1845, 205, 767, 1760, - 256, 185, 256,}, - {21, 1, 360, 1884, 149, 1874, 149, 752, 1720, 205, 1883, 205, 767, 1760, - 256, 273, 256,}, - {22, 1, 360, 1884, 98, 1948, 98, 752, 1720, 205, 1924, 205, 767, 1760, - 256, 352, 256,}, - {23, 1, 350, 1884, 116, 1966, 116, 752, 1720, 205, 2008, 205, 767, 1760, - 128, 233, 128,}, - {24, 1, 325, 1884, 32, 40, 32, 756, 1720, 256, 471, 256, 766, 1760, 256, - 1881, 256,}, - {25, 1, 299, 1884, 51, 64, 51, 736, 1720, 256, 471, 256, 765, 1760, 256, - 1881, 256,}, - {26, 1, 277, 1943, 39, 117, 88, 637, 1838, 64, 192, 144, 614, 1864, 128, - 384, 288,}, - {27, 1, 245, 1943, 49, 147, 110, 626, 1838, 256, 768, 576, 613, 1864, - 128, 384, 288,}, - {30, 1, 302, 1841, 61, 122, 61, 658, 1720, 205, 410, 205, 754, 1760, - 170, 340, 170,}, -}; - -#define LCNPHY_NUM_TX_DIG_FILTERS_OFDM 3 -static const u16 LCNPHY_txdigfiltcoeffs_ofdm[LCNPHY_NUM_TX_DIG_FILTERS_OFDM] - [LCNPHY_NUM_DIG_FILT_COEFFS + 1] = { - {0, 0, 0xa2, 0x0, 0x100, 0x100, 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, - 0x278, 0xfea0, 0x80, 0x100, 0x80,}, - {1, 0, 374, 0xFF79, 16, 32, 16, 799, 0xFE74, 50, 32, 50, - 750, 0xFE2B, 212, 0xFFCE, 212,}, - {2, 0, 375, 0xFF16, 37, 76, 37, 799, 0xFE74, 32, 20, 32, 748, - 0xFEF2, 128, 0xFFE2, 128} -}; - -#define wlc_lcnphy_set_start_tx_pwr_idx(pi, idx) \ - mod_phy_reg(pi, 0x4a4, \ - (0x1ff << 0), \ - (u16)(idx) << 0) - -#define wlc_lcnphy_set_tx_pwr_npt(pi, npt) \ - mod_phy_reg(pi, 0x4a5, \ - (0x7 << 8), \ - (u16)(npt) << 8) - -#define wlc_lcnphy_get_tx_pwr_ctrl(pi) \ - (read_phy_reg((pi), 0x4a4) & \ - ((0x1 << 15) | \ - (0x1 << 14) | \ - (0x1 << 13))) - -#define wlc_lcnphy_get_tx_pwr_npt(pi) \ - ((read_phy_reg(pi, 0x4a5) & \ - (0x7 << 8)) >> \ - 8) - -#define wlc_lcnphy_get_current_tx_pwr_idx_if_pwrctrl_on(pi) \ - (read_phy_reg(pi, 0x473) & 0x1ff) - -#define wlc_lcnphy_get_target_tx_pwr(pi) \ - ((read_phy_reg(pi, 0x4a7) & \ - (0xff << 0)) >> \ - 0) - -#define wlc_lcnphy_set_target_tx_pwr(pi, target) \ - mod_phy_reg(pi, 0x4a7, \ - (0xff << 0), \ - (u16)(target) << 0) - -#define wlc_radio_2064_rcal_done(pi) \ - (0 != (read_radio_reg(pi, RADIO_2064_REG05C) & 0x20)) - -#define tempsense_done(pi) \ - (0x8000 == (read_phy_reg(pi, 0x476) & 0x8000)) - -#define LCNPHY_IQLOCC_READ(val) \ - ((u8)(-(s8)(((val) & 0xf0) >> 4) + (s8)((val) & 0x0f))) - -#define FIXED_TXPWR 78 -#define LCNPHY_TEMPSENSE(val) ((s16)((val > 255) ? (val - 512) : val)) - -void wlc_lcnphy_write_table(struct brcms_phy *pi, const struct phytbl_info *pti) -{ - wlc_phy_write_table(pi, pti, 0x455, 0x457, 0x456); -} - -void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti) -{ - wlc_phy_read_table(pi, pti, 0x455, 0x457, 0x456); -} - -static void -wlc_lcnphy_common_read_table(struct brcms_phy *pi, u32 tbl_id, - const u16 *tbl_ptr, u32 tbl_len, - u32 tbl_width, u32 tbl_offset) -{ - struct phytbl_info tab; - tab.tbl_id = tbl_id; - tab.tbl_ptr = tbl_ptr; - tab.tbl_len = tbl_len; - tab.tbl_width = tbl_width; - tab.tbl_offset = tbl_offset; - wlc_lcnphy_read_table(pi, &tab); -} - -static void -wlc_lcnphy_common_write_table(struct brcms_phy *pi, u32 tbl_id, - const u16 *tbl_ptr, u32 tbl_len, - u32 tbl_width, u32 tbl_offset) -{ - - struct phytbl_info tab; - tab.tbl_id = tbl_id; - tab.tbl_ptr = tbl_ptr; - tab.tbl_len = tbl_len; - tab.tbl_width = tbl_width; - tab.tbl_offset = tbl_offset; - wlc_lcnphy_write_table(pi, &tab); -} - -static u32 -wlc_lcnphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) -{ - u32 quotient, remainder, roundup, rbit; - - quotient = dividend / divisor; - remainder = dividend % divisor; - rbit = divisor & 1; - roundup = (divisor >> 1) + rbit; - - while (precision--) { - quotient <<= 1; - if (remainder >= roundup) { - quotient++; - remainder = ((remainder - roundup) << 1) + rbit; - } else { - remainder <<= 1; - } - } - - if (remainder >= roundup) - quotient++; - - return quotient; -} - -static int wlc_lcnphy_calc_floor(s16 coeff_x, int type) -{ - int k; - k = 0; - if (type == 0) { - if (coeff_x < 0) - k = (coeff_x - 1) / 2; - else - k = coeff_x / 2; - } - - if (type == 1) { - if ((coeff_x + 1) < 0) - k = (coeff_x) / 2; - else - k = (coeff_x + 1) / 2; - } - return k; -} - -static void -wlc_lcnphy_get_tx_gain(struct brcms_phy *pi, struct lcnphy_txgains *gains) -{ - u16 dac_gain, rfgain0, rfgain1; - - dac_gain = read_phy_reg(pi, 0x439) >> 0; - gains->dac_gain = (dac_gain & 0x380) >> 7; - - rfgain0 = (read_phy_reg(pi, 0x4b5) & (0xffff << 0)) >> 0; - rfgain1 = (read_phy_reg(pi, 0x4fb) & (0x7fff << 0)) >> 0; - - gains->gm_gain = rfgain0 & 0xff; - gains->pga_gain = (rfgain0 >> 8) & 0xff; - gains->pad_gain = rfgain1 & 0xff; -} - - -static void wlc_lcnphy_set_dac_gain(struct brcms_phy *pi, u16 dac_gain) -{ - u16 dac_ctrl; - - dac_ctrl = (read_phy_reg(pi, 0x439) >> 0); - dac_ctrl = dac_ctrl & 0xc7f; - dac_ctrl = dac_ctrl | (dac_gain << 7); - mod_phy_reg(pi, 0x439, (0xfff << 0), (dac_ctrl) << 0); - -} - -static void wlc_lcnphy_set_tx_gain_override(struct brcms_phy *pi, bool bEnable) -{ - u16 bit = bEnable ? 1 : 0; - - mod_phy_reg(pi, 0x4b0, (0x1 << 7), bit << 7); - - mod_phy_reg(pi, 0x4b0, (0x1 << 14), bit << 14); - - mod_phy_reg(pi, 0x43b, (0x1 << 6), bit << 6); -} - -static void -wlc_lcnphy_rx_gain_override_enable(struct brcms_phy *pi, bool enable) -{ - u16 ebit = enable ? 1 : 0; - - mod_phy_reg(pi, 0x4b0, (0x1 << 8), ebit << 8); - - mod_phy_reg(pi, 0x44c, (0x1 << 0), ebit << 0); - - if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { - mod_phy_reg(pi, 0x44c, (0x1 << 4), ebit << 4); - mod_phy_reg(pi, 0x44c, (0x1 << 6), ebit << 6); - mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); - mod_phy_reg(pi, 0x4b0, (0x1 << 6), ebit << 6); - } else { - mod_phy_reg(pi, 0x4b0, (0x1 << 12), ebit << 12); - mod_phy_reg(pi, 0x4b0, (0x1 << 13), ebit << 13); - mod_phy_reg(pi, 0x4b0, (0x1 << 5), ebit << 5); - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x4b0, (0x1 << 10), ebit << 10); - mod_phy_reg(pi, 0x4e5, (0x1 << 3), ebit << 3); - } -} - -static void -wlc_lcnphy_set_rx_gain_by_distribution(struct brcms_phy *pi, - u16 trsw, - u16 ext_lna, - u16 biq2, - u16 biq1, - u16 tia, u16 lna2, u16 lna1) -{ - u16 gain0_15, gain16_19; - - gain16_19 = biq2 & 0xf; - gain0_15 = ((biq1 & 0xf) << 12) | - ((tia & 0xf) << 8) | - ((lna2 & 0x3) << 6) | - ((lna2 & - 0x3) << 4) | ((lna1 & 0x3) << 2) | ((lna1 & 0x3) << 0); - - mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); - mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); - mod_phy_reg(pi, 0x4b1, (0x3 << 11), lna1 << 11); - - if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { - mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); - mod_phy_reg(pi, 0x4b1, (0x1 << 10), ext_lna << 10); - } else { - mod_phy_reg(pi, 0x4b1, (0x1 << 10), 0 << 10); - - mod_phy_reg(pi, 0x4b1, (0x1 << 15), 0 << 15); - - mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); - } - - mod_phy_reg(pi, 0x44d, (0x1 << 0), (!trsw) << 0); - -} - -static void wlc_lcnphy_set_trsw_override(struct brcms_phy *pi, bool tx, bool rx) -{ - - mod_phy_reg(pi, 0x44d, - (0x1 << 1) | - (0x1 << 0), (tx ? (0x1 << 1) : 0) | (rx ? (0x1 << 0) : 0)); - - or_phy_reg(pi, 0x44c, (0x1 << 1) | (0x1 << 0)); -} - -static void wlc_lcnphy_clear_trsw_override(struct brcms_phy *pi) -{ - - and_phy_reg(pi, 0x44c, (u16) ~((0x1 << 1) | (0x1 << 0))); -} - -static void wlc_lcnphy_set_rx_iq_comp(struct brcms_phy *pi, u16 a, u16 b) -{ - mod_phy_reg(pi, 0x645, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x646, (0x3ff << 0), (b) << 0); - - mod_phy_reg(pi, 0x647, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x648, (0x3ff << 0), (b) << 0); - - mod_phy_reg(pi, 0x649, (0x3ff << 0), (a) << 0); - - mod_phy_reg(pi, 0x64a, (0x3ff << 0), (b) << 0); - -} - -static bool -wlc_lcnphy_rx_iq_est(struct brcms_phy *pi, - u16 num_samps, - u8 wait_time, struct lcnphy_iq_est *iq_est) -{ - int wait_count = 0; - bool result = true; - u8 phybw40; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5); - - mod_phy_reg(pi, 0x410, (0x1 << 3), (0) << 3); - - mod_phy_reg(pi, 0x482, (0xffff << 0), (num_samps) << 0); - - mod_phy_reg(pi, 0x481, (0xff << 0), ((u16) wait_time) << 0); - - mod_phy_reg(pi, 0x481, (0x1 << 8), (0) << 8); - - mod_phy_reg(pi, 0x481, (0x1 << 9), (1) << 9); - - while (read_phy_reg(pi, 0x481) & (0x1 << 9)) { - - if (wait_count > (10 * 500)) { - result = false; - goto cleanup; - } - udelay(100); - wait_count++; - } - - iq_est->iq_prod = ((u32) read_phy_reg(pi, 0x483) << 16) | - (u32) read_phy_reg(pi, 0x484); - iq_est->i_pwr = ((u32) read_phy_reg(pi, 0x485) << 16) | - (u32) read_phy_reg(pi, 0x486); - iq_est->q_pwr = ((u32) read_phy_reg(pi, 0x487) << 16) | - (u32) read_phy_reg(pi, 0x488); - -cleanup: - mod_phy_reg(pi, 0x410, (0x1 << 3), (1) << 3); - - mod_phy_reg(pi, 0x6da, (0x1 << 5), (0) << 5); - - return result; -} - -static bool wlc_lcnphy_calc_rx_iq_comp(struct brcms_phy *pi, u16 num_samps) -{ -#define LCNPHY_MIN_RXIQ_PWR 2 - bool result; - u16 a0_new, b0_new; - struct lcnphy_iq_est iq_est = { 0, 0, 0 }; - s32 a, b, temp; - s16 iq_nbits, qq_nbits, arsh, brsh; - s32 iq; - u32 ii, qq; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - a0_new = ((read_phy_reg(pi, 0x645) & (0x3ff << 0)) >> 0); - b0_new = ((read_phy_reg(pi, 0x646) & (0x3ff << 0)) >> 0); - mod_phy_reg(pi, 0x6d1, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x64b, (0x1 << 6), (1) << 6); - - wlc_lcnphy_set_rx_iq_comp(pi, 0, 0); - - result = wlc_lcnphy_rx_iq_est(pi, num_samps, 32, &iq_est); - if (!result) - goto cleanup; - - iq = (s32) iq_est.iq_prod; - ii = iq_est.i_pwr; - qq = iq_est.q_pwr; - - if ((ii + qq) < LCNPHY_MIN_RXIQ_PWR) { - result = false; - goto cleanup; - } - - iq_nbits = wlc_phy_nbits(iq); - qq_nbits = wlc_phy_nbits(qq); - - arsh = 10 - (30 - iq_nbits); - if (arsh >= 0) { - a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); - temp = (s32) (ii >> arsh); - if (temp == 0) - return false; - } else { - a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); - temp = (s32) (ii << -arsh); - if (temp == 0) - return false; - } - a /= temp; - brsh = qq_nbits - 31 + 20; - if (brsh >= 0) { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii >> brsh); - if (temp == 0) - return false; - } else { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii << -brsh); - if (temp == 0) - return false; - } - b /= temp; - b -= a * a; - b = (s32) int_sqrt((unsigned long) b); - b -= (1 << 10); - a0_new = (u16) (a & 0x3ff); - b0_new = (u16) (b & 0x3ff); -cleanup: - - wlc_lcnphy_set_rx_iq_comp(pi, a0_new, b0_new); - - mod_phy_reg(pi, 0x64b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, 0x64b, (0x1 << 3), (1) << 3); - - pi_lcn->lcnphy_cal_results.rxiqcal_coeff_a0 = a0_new; - pi_lcn->lcnphy_cal_results.rxiqcal_coeff_b0 = b0_new; - - return result; -} - -static u32 wlc_lcnphy_measure_digital_power(struct brcms_phy *pi, u16 nsamples) -{ - struct lcnphy_iq_est iq_est = { 0, 0, 0 }; - - if (!wlc_lcnphy_rx_iq_est(pi, nsamples, 32, &iq_est)) - return 0; - return (iq_est.i_pwr + iq_est.q_pwr) / nsamples; -} - -static bool -wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, - const struct lcnphy_rx_iqcomp *iqcomp, - int iqcomp_sz, bool tx_switch, bool rx_switch, int module, - int tx_gain_idx) -{ - struct lcnphy_txgains old_gains; - u16 tx_pwr_ctrl; - u8 tx_gain_index_old = 0; - bool result = false, tx_gain_override_old = false; - u16 i, Core1TxControl_old, RFOverride0_old, - RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, - rfoverride3_old, rfoverride3val_old, rfoverride4_old, - rfoverride4val_old, afectrlovr_old, afectrlovrval_old; - int tia_gain; - u32 received_power, rx_pwr_threshold; - u16 old_sslpnCalibClkEnCtrl, old_sslpnRxFeClkEnCtrl; - u16 values_to_save[11]; - s16 *ptr; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) - return false; - if (module == 2) { - while (iqcomp_sz--) { - if (iqcomp[iqcomp_sz].chan == - CHSPEC_CHANNEL(pi->radio_chanspec)) { - wlc_lcnphy_set_rx_iq_comp(pi, - (u16) - iqcomp[iqcomp_sz].a, - (u16) - iqcomp[iqcomp_sz].b); - result = true; - break; - } - } - goto cal_done; - } - - if (module == 1) { - - tx_pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - for (i = 0; i < 11; i++) - values_to_save[i] = - read_radio_reg(pi, rxiq_cal_rf_reg[i]); - Core1TxControl_old = read_phy_reg(pi, 0x631); - - or_phy_reg(pi, 0x631, 0x0015); - - RFOverride0_old = read_phy_reg(pi, 0x44c); - RFOverrideVal0_old = read_phy_reg(pi, 0x44d); - rfoverride2_old = read_phy_reg(pi, 0x4b0); - rfoverride2val_old = read_phy_reg(pi, 0x4b1); - rfoverride3_old = read_phy_reg(pi, 0x4f9); - rfoverride3val_old = read_phy_reg(pi, 0x4fa); - rfoverride4_old = read_phy_reg(pi, 0x938); - rfoverride4val_old = read_phy_reg(pi, 0x939); - afectrlovr_old = read_phy_reg(pi, 0x43b); - afectrlovrval_old = read_phy_reg(pi, 0x43c); - old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - old_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); - - tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); - if (tx_gain_override_old) { - wlc_lcnphy_get_tx_gain(pi, &old_gains); - tx_gain_index_old = pi_lcn->lcnphy_current_index; - } - - wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_idx); - - mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); - - mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); - - write_radio_reg(pi, RADIO_2064_REG116, 0x06); - write_radio_reg(pi, RADIO_2064_REG12C, 0x07); - write_radio_reg(pi, RADIO_2064_REG06A, 0xd3); - write_radio_reg(pi, RADIO_2064_REG098, 0x03); - write_radio_reg(pi, RADIO_2064_REG00B, 0x7); - mod_radio_reg(pi, RADIO_2064_REG113, 1 << 4, 1 << 4); - write_radio_reg(pi, RADIO_2064_REG01D, 0x01); - write_radio_reg(pi, RADIO_2064_REG114, 0x01); - write_radio_reg(pi, RADIO_2064_REG02E, 0x10); - write_radio_reg(pi, RADIO_2064_REG12A, 0x08); - - mod_phy_reg(pi, 0x938, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x939, (0x1 << 0), 0 << 0); - mod_phy_reg(pi, 0x938, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x939, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x938, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x939, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x938, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x939, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x938, (0x1 << 5), 1 << 5); - mod_phy_reg(pi, 0x939, (0x1 << 5), 0 << 5); - - mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); - - wlc_lcnphy_start_tx_tone(pi, 2000, 120, 0); - write_phy_reg(pi, 0x6da, 0xffff); - or_phy_reg(pi, 0x6db, 0x3); - wlc_lcnphy_set_trsw_override(pi, tx_switch, rx_switch); - wlc_lcnphy_rx_gain_override_enable(pi, true); - - tia_gain = 8; - rx_pwr_threshold = 950; - while (tia_gain > 0) { - tia_gain -= 1; - wlc_lcnphy_set_rx_gain_by_distribution(pi, - 0, 0, 2, 2, - (u16) - tia_gain, 1, 0); - udelay(500); - - received_power = - wlc_lcnphy_measure_digital_power(pi, 2000); - if (received_power < rx_pwr_threshold) - break; - } - result = wlc_lcnphy_calc_rx_iq_comp(pi, 0xffff); - - wlc_lcnphy_stop_tx_tone(pi); - - write_phy_reg(pi, 0x631, Core1TxControl_old); - - write_phy_reg(pi, 0x44c, RFOverrideVal0_old); - write_phy_reg(pi, 0x44d, RFOverrideVal0_old); - write_phy_reg(pi, 0x4b0, rfoverride2_old); - write_phy_reg(pi, 0x4b1, rfoverride2val_old); - write_phy_reg(pi, 0x4f9, rfoverride3_old); - write_phy_reg(pi, 0x4fa, rfoverride3val_old); - write_phy_reg(pi, 0x938, rfoverride4_old); - write_phy_reg(pi, 0x939, rfoverride4val_old); - write_phy_reg(pi, 0x43b, afectrlovr_old); - write_phy_reg(pi, 0x43c, afectrlovrval_old); - write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - write_phy_reg(pi, 0x6db, old_sslpnRxFeClkEnCtrl); - - wlc_lcnphy_clear_trsw_override(pi); - - mod_phy_reg(pi, 0x44c, (0x1 << 2), 0 << 2); - - for (i = 0; i < 11; i++) - write_radio_reg(pi, rxiq_cal_rf_reg[i], - values_to_save[i]); - - if (tx_gain_override_old) - wlc_lcnphy_set_tx_pwr_by_index(pi, tx_gain_index_old); - else - wlc_lcnphy_disable_tx_gain_override(pi); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl); - wlc_lcnphy_rx_gain_override_enable(pi, false); - } - -cal_done: - kfree(ptr); - return result; -} - -s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi) -{ - s8 index; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (txpwrctrl_off(pi)) - index = pi_lcn->lcnphy_current_index; - else if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) - index = (s8) (wlc_lcnphy_get_current_tx_pwr_idx_if_pwrctrl_on( - pi) / 2); - else - index = pi_lcn->lcnphy_current_index; - return index; -} - -void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel) -{ - u16 afectrlovr, afectrlovrval; - afectrlovr = read_phy_reg(pi, 0x43b); - afectrlovrval = read_phy_reg(pi, 0x43c); - if (channel != 0) { - mod_phy_reg(pi, 0x43b, (0x1 << 1), (1) << 1); - - mod_phy_reg(pi, 0x43c, (0x1 << 1), (0) << 1); - - mod_phy_reg(pi, 0x43b, (0x1 << 4), (1) << 4); - - mod_phy_reg(pi, 0x43c, (0x1 << 6), (0) << 6); - - write_phy_reg(pi, 0x44b, 0xffff); - wlc_lcnphy_tx_pu(pi, 1); - - mod_phy_reg(pi, 0x634, (0xff << 8), (0) << 8); - - or_phy_reg(pi, 0x6da, 0x0080); - - or_phy_reg(pi, 0x00a, 0x228); - } else { - and_phy_reg(pi, 0x00a, ~(0x228)); - - and_phy_reg(pi, 0x6da, 0xFF7F); - write_phy_reg(pi, 0x43b, afectrlovr); - write_phy_reg(pi, 0x43c, afectrlovrval); - } -} - -static void wlc_lcnphy_toggle_afe_pwdn(struct brcms_phy *pi) -{ - u16 save_AfeCtrlOvrVal, save_AfeCtrlOvr; - - save_AfeCtrlOvrVal = read_phy_reg(pi, 0x43c); - save_AfeCtrlOvr = read_phy_reg(pi, 0x43b); - - write_phy_reg(pi, 0x43c, save_AfeCtrlOvrVal | 0x1); - write_phy_reg(pi, 0x43b, save_AfeCtrlOvr | 0x1); - - write_phy_reg(pi, 0x43c, save_AfeCtrlOvrVal & 0xfffe); - write_phy_reg(pi, 0x43b, save_AfeCtrlOvr & 0xfffe); - - write_phy_reg(pi, 0x43c, save_AfeCtrlOvrVal); - write_phy_reg(pi, 0x43b, save_AfeCtrlOvr); -} - -static void -wlc_lcnphy_txrx_spur_avoidance_mode(struct brcms_phy *pi, bool enable) -{ - if (enable) { - write_phy_reg(pi, 0x942, 0x7); - write_phy_reg(pi, 0x93b, ((1 << 13) + 23)); - write_phy_reg(pi, 0x93c, ((1 << 13) + 1989)); - - write_phy_reg(pi, 0x44a, 0x084); - write_phy_reg(pi, 0x44a, 0x080); - write_phy_reg(pi, 0x6d3, 0x2222); - write_phy_reg(pi, 0x6d3, 0x2220); - } else { - write_phy_reg(pi, 0x942, 0x0); - write_phy_reg(pi, 0x93b, ((0 << 13) + 23)); - write_phy_reg(pi, 0x93c, ((0 << 13) + 1989)); - } - wlapi_switch_macfreq(pi->sh->physhim, enable); -} - -static void -wlc_lcnphy_set_chanspec_tweaks(struct brcms_phy *pi, u16 chanspec) -{ - u8 channel = CHSPEC_CHANNEL(chanspec); - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (channel == 14) - mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); - else - mod_phy_reg(pi, 0x448, (0x3 << 8), (1) << 8); - - pi_lcn->lcnphy_bandedge_corr = 2; - if (channel == 1) - pi_lcn->lcnphy_bandedge_corr = 4; - - if (channel == 1 || channel == 2 || channel == 3 || - channel == 4 || channel == 9 || - channel == 10 || channel == 11 || channel == 12) { - si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03000c04); - si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x0); - si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x200005c0); - - si_pmu_pllupd(pi->sh->sih); - write_phy_reg(pi, 0x942, 0); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, false); - pi_lcn->lcnphy_spurmod = 0; - mod_phy_reg(pi, 0x424, (0xff << 8), (0x1b) << 8); - - write_phy_reg(pi, 0x425, 0x5907); - } else { - si_pmu_pllcontrol(pi->sh->sih, 0x2, 0xffffffff, 0x03140c04); - si_pmu_pllcontrol(pi->sh->sih, 0x3, 0xffffff, 0x333333); - si_pmu_pllcontrol(pi->sh->sih, 0x4, 0xffffffff, 0x202c2820); - - si_pmu_pllupd(pi->sh->sih); - write_phy_reg(pi, 0x942, 0); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, true); - - pi_lcn->lcnphy_spurmod = 0; - mod_phy_reg(pi, 0x424, (0xff << 8), (0x1f) << 8); - - write_phy_reg(pi, 0x425, 0x590a); - } - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); -} - -static void -wlc_lcnphy_radio_2064_channel_tune_4313(struct brcms_phy *pi, u8 channel) -{ - uint i; - const struct chan_info_2064_lcnphy *ci; - u8 rfpll_doubler = 0; - u8 pll_pwrup, pll_pwrup_ovr; - s32 qFxtal, qFref, qFvco, qFcal; - u8 d15, d16, f16, e44, e45; - u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; - u16 loop_bw, d30, setCount; - - u8 h29, h28_ten, e30, h30_ten, cp_current; - u16 g30, d28; - - ci = &chan_info_2064_lcnphy[0]; - rfpll_doubler = 1; - - mod_radio_reg(pi, RADIO_2064_REG09D, 0x4, 0x1 << 2); - - write_radio_reg(pi, RADIO_2064_REG09E, 0xf); - if (!rfpll_doubler) { - loop_bw = PLL_2064_LOOP_BW; - d30 = PLL_2064_D30; - } else { - loop_bw = PLL_2064_LOOP_BW_DOUBLER; - d30 = PLL_2064_D30_DOUBLER; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - for (i = 0; i < ARRAY_SIZE(chan_info_2064_lcnphy); i++) - if (chan_info_2064_lcnphy[i].chan == channel) - break; - - if (i >= ARRAY_SIZE(chan_info_2064_lcnphy)) - return; - - ci = &chan_info_2064_lcnphy[i]; - } - - write_radio_reg(pi, RADIO_2064_REG02A, ci->logen_buftune); - - mod_radio_reg(pi, RADIO_2064_REG030, 0x3, ci->logen_rccr_tx); - - mod_radio_reg(pi, RADIO_2064_REG091, 0x3, ci->txrf_mix_tune_ctrl); - - mod_radio_reg(pi, RADIO_2064_REG038, 0xf, ci->pa_input_tune_g); - - mod_radio_reg(pi, RADIO_2064_REG030, 0x3 << 2, - (ci->logen_rccr_rx) << 2); - - mod_radio_reg(pi, RADIO_2064_REG05E, 0xf, ci->pa_rxrf_lna1_freq_tune); - - mod_radio_reg(pi, RADIO_2064_REG05E, (0xf) << 4, - (ci->pa_rxrf_lna2_freq_tune) << 4); - - write_radio_reg(pi, RADIO_2064_REG06C, ci->rxrf_rxrf_spare1); - - pll_pwrup = (u8) read_radio_reg(pi, RADIO_2064_REG044); - pll_pwrup_ovr = (u8) read_radio_reg(pi, RADIO_2064_REG12B); - - or_radio_reg(pi, RADIO_2064_REG044, 0x07); - - or_radio_reg(pi, RADIO_2064_REG12B, (0x07) << 1); - e44 = 0; - e45 = 0; - - fpfd = rfpll_doubler ? (pi->xtalfreq << 1) : (pi->xtalfreq); - if (pi->xtalfreq > 26000000) - e44 = 1; - if (pi->xtalfreq > 52000000) - e45 = 1; - if (e44 == 0) - fcal_div = 1; - else if (e45 == 0) - fcal_div = 2; - else - fcal_div = 4; - fvco3 = (ci->freq * 3); - fref3 = 2 * fpfd; - - qFxtal = wlc_lcnphy_qdiv_roundup(pi->xtalfreq, PLL_2064_MHZ, 16); - qFref = wlc_lcnphy_qdiv_roundup(fpfd, PLL_2064_MHZ, 16); - qFcal = pi->xtalfreq * fcal_div / PLL_2064_MHZ; - qFvco = wlc_lcnphy_qdiv_roundup(fvco3, 2, 16); - - write_radio_reg(pi, RADIO_2064_REG04F, 0x02); - - d15 = (pi->xtalfreq * fcal_div * 4 / 5) / PLL_2064_MHZ - 1; - write_radio_reg(pi, RADIO_2064_REG052, (0x07 & (d15 >> 2))); - write_radio_reg(pi, RADIO_2064_REG053, (d15 & 0x3) << 5); - - d16 = (qFcal * 8 / (d15 + 1)) - 1; - write_radio_reg(pi, RADIO_2064_REG051, d16); - - f16 = ((d16 + 1) * (d15 + 1)) / qFcal; - setCount = f16 * 3 * (ci->freq) / 32 - 1; - mod_radio_reg(pi, RADIO_2064_REG053, (0x0f << 0), - (u8) (setCount >> 8)); - - or_radio_reg(pi, RADIO_2064_REG053, 0x10); - write_radio_reg(pi, RADIO_2064_REG054, (u8) (setCount & 0xff)); - - div_int = ((fvco3 * (PLL_2064_MHZ >> 4)) / fref3) << 4; - - div_frac = ((fvco3 * (PLL_2064_MHZ >> 4)) % fref3) << 4; - while (div_frac >= fref3) { - div_int++; - div_frac -= fref3; - } - div_frac = wlc_lcnphy_qdiv_roundup(div_frac, fref3, 20); - - mod_radio_reg(pi, RADIO_2064_REG045, (0x1f << 0), - (u8) (div_int >> 4)); - mod_radio_reg(pi, RADIO_2064_REG046, (0x1f << 4), - (u8) (div_int << 4)); - mod_radio_reg(pi, RADIO_2064_REG046, (0x0f << 0), - (u8) (div_frac >> 16)); - write_radio_reg(pi, RADIO_2064_REG047, (u8) (div_frac >> 8) & 0xff); - write_radio_reg(pi, RADIO_2064_REG048, (u8) div_frac & 0xff); - - write_radio_reg(pi, RADIO_2064_REG040, 0xfb); - - write_radio_reg(pi, RADIO_2064_REG041, 0x9A); - write_radio_reg(pi, RADIO_2064_REG042, 0xA3); - write_radio_reg(pi, RADIO_2064_REG043, 0x0C); - - h29 = LCN_BW_LMT / loop_bw; - d28 = (((PLL_2064_HIGH_END_KVCO - PLL_2064_LOW_END_KVCO) * - (fvco3 / 2 - PLL_2064_LOW_END_VCO)) / - (PLL_2064_HIGH_END_VCO - PLL_2064_LOW_END_VCO)) - + PLL_2064_LOW_END_KVCO; - h28_ten = (d28 * 10) / LCN_VCO_DIV; - e30 = (d30 - LCN_OFFSET) / LCN_FACT; - g30 = LCN_OFFSET + (e30 * LCN_FACT); - h30_ten = (g30 * 10) / LCN_CUR_DIV; - cp_current = ((LCN_CUR_LMT * h29 * LCN_MULT * 100) / h28_ten) / h30_ten; - mod_radio_reg(pi, RADIO_2064_REG03C, 0x3f, cp_current); - - if (channel >= 1 && channel <= 5) - write_radio_reg(pi, RADIO_2064_REG03C, 0x8); - else - write_radio_reg(pi, RADIO_2064_REG03C, 0x7); - write_radio_reg(pi, RADIO_2064_REG03D, 0x3); - - mod_radio_reg(pi, RADIO_2064_REG044, 0x0c, 0x0c); - udelay(1); - - wlc_2064_vco_cal(pi); - - write_radio_reg(pi, RADIO_2064_REG044, pll_pwrup); - write_radio_reg(pi, RADIO_2064_REG12B, pll_pwrup_ovr); - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { - write_radio_reg(pi, RADIO_2064_REG038, 3); - write_radio_reg(pi, RADIO_2064_REG091, 7); - } -} - -static int -wlc_lcnphy_load_tx_iir_filter(struct brcms_phy *pi, bool is_ofdm, s16 filt_type) -{ - s16 filt_index = -1; - int j; - - u16 addr[] = { - 0x910, - 0x91e, - 0x91f, - 0x924, - 0x925, - 0x926, - 0x920, - 0x921, - 0x927, - 0x928, - 0x929, - 0x922, - 0x923, - 0x930, - 0x931, - 0x932 - }; - - u16 addr_ofdm[] = { - 0x90f, - 0x900, - 0x901, - 0x906, - 0x907, - 0x908, - 0x902, - 0x903, - 0x909, - 0x90a, - 0x90b, - 0x904, - 0x905, - 0x90c, - 0x90d, - 0x90e - }; - - if (!is_ofdm) { - for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_CCK; j++) { - if (filt_type == LCNPHY_txdigfiltcoeffs_cck[j][0]) { - filt_index = (s16) j; - break; - } - } - - if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr[j], - LCNPHY_txdigfiltcoeffs_cck - [filt_index][j + 1]); - } - } else { - for (j = 0; j < LCNPHY_NUM_TX_DIG_FILTERS_OFDM; j++) { - if (filt_type == LCNPHY_txdigfiltcoeffs_ofdm[j][0]) { - filt_index = (s16) j; - break; - } - } - - if (filt_index != -1) { - for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_ofdm[j], - LCNPHY_txdigfiltcoeffs_ofdm - [filt_index][j + 1]); - } - } - - return (filt_index != -1) ? 0 : -1; -} - -void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec) -{ - u8 channel = CHSPEC_CHANNEL(chanspec); - - wlc_phy_chanspec_radio_set((struct brcms_phy_pub *) pi, chanspec); - - wlc_lcnphy_set_chanspec_tweaks(pi, pi->radio_chanspec); - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); - - wlc_lcnphy_radio_2064_channel_tune_4313(pi, channel); - udelay(1000); - - wlc_lcnphy_toggle_afe_pwdn(pi); - - write_phy_reg(pi, 0x657, lcnphy_sfo_cfg[channel - 1].ptcentreTs20); - write_phy_reg(pi, 0x658, lcnphy_sfo_cfg[channel - 1].ptcentreFactor); - - if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { - mod_phy_reg(pi, 0x448, (0x3 << 8), (2) << 8); - - wlc_lcnphy_load_tx_iir_filter(pi, false, 3); - } else { - mod_phy_reg(pi, 0x448, (0x3 << 8), (1) << 8); - - wlc_lcnphy_load_tx_iir_filter(pi, false, 2); - } - - wlc_lcnphy_load_tx_iir_filter(pi, true, 0); - - mod_phy_reg(pi, 0x4eb, (0x7 << 3), (1) << 3); - -} - -static u16 wlc_lcnphy_get_pa_gain(struct brcms_phy *pi) -{ - u16 pa_gain; - - pa_gain = (read_phy_reg(pi, 0x4fb) & - LCNPHY_txgainctrlovrval1_pagain_ovr_val1_MASK) >> - LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT; - - return pa_gain; -} - -static void wlc_lcnphy_set_tx_gain(struct brcms_phy *pi, - struct lcnphy_txgains *target_gains) -{ - u16 pa_gain = wlc_lcnphy_get_pa_gain(pi); - - mod_phy_reg( - pi, 0x4b5, - (0xffff << 0), - ((target_gains->gm_gain) | - (target_gains->pga_gain << 8)) << - 0); - mod_phy_reg(pi, 0x4fb, - (0x7fff << 0), - ((target_gains->pad_gain) | (pa_gain << 8)) << 0); - - mod_phy_reg( - pi, 0x4fc, - (0xffff << 0), - ((target_gains->gm_gain) | - (target_gains->pga_gain << 8)) << - 0); - mod_phy_reg(pi, 0x4fd, - (0x7fff << 0), - ((target_gains->pad_gain) | (pa_gain << 8)) << 0); - - wlc_lcnphy_set_dac_gain(pi, target_gains->dac_gain); - - wlc_lcnphy_enable_tx_gain_override(pi); -} - -static void wlc_lcnphy_set_bbmult(struct brcms_phy *pi, u8 m0) -{ - u16 m0m1 = (u16) m0 << 8; - struct phytbl_info tab; - - tab.tbl_ptr = &m0m1; - tab.tbl_len = 1; - tab.tbl_id = LCNPHY_TBL_ID_IQLOCAL; - tab.tbl_offset = 87; - tab.tbl_width = 16; - wlc_lcnphy_write_table(pi, &tab); -} - -static void wlc_lcnphy_clear_tx_power_offsets(struct brcms_phy *pi) -{ - u32 data_buf[64]; - struct phytbl_info tab; - - memset(data_buf, 0, sizeof(data_buf)); - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_ptr = data_buf; - - if (!wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { - - tab.tbl_len = 30; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_RATE_OFFSET; - wlc_lcnphy_write_table(pi, &tab); - } - - tab.tbl_len = 64; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_MAC_OFFSET; - wlc_lcnphy_write_table(pi, &tab); -} - -enum lcnphy_tssi_mode { - LCNPHY_TSSI_PRE_PA, - LCNPHY_TSSI_POST_PA, - LCNPHY_TSSI_EXT -}; - -static void -wlc_lcnphy_set_tssi_mux(struct brcms_phy *pi, enum lcnphy_tssi_mode pos) -{ - mod_phy_reg(pi, 0x4d7, (0x1 << 0), (0x1) << 0); - - mod_phy_reg(pi, 0x4d7, (0x1 << 6), (1) << 6); - - if (LCNPHY_TSSI_POST_PA == pos) { - mod_phy_reg(pi, 0x4d9, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x4d9, (0x1 << 3), (1) << 3); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - mod_radio_reg(pi, RADIO_2064_REG086, 0x4, 0x4); - } else { - mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0x1); - mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 0x8); - } - } else { - mod_phy_reg(pi, 0x4d9, (0x1 << 2), (0x1) << 2); - - mod_phy_reg(pi, 0x4d9, (0x1 << 3), (0) << 3); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - mod_radio_reg(pi, RADIO_2064_REG086, 0x4, 0x4); - } else { - mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0); - mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 0x8); - } - } - mod_phy_reg(pi, 0x637, (0x3 << 14), (0) << 14); - - if (LCNPHY_TSSI_EXT == pos) { - write_radio_reg(pi, RADIO_2064_REG07F, 1); - mod_radio_reg(pi, RADIO_2064_REG005, 0x7, 0x2); - mod_radio_reg(pi, RADIO_2064_REG112, 0x80, 0x1 << 7); - mod_radio_reg(pi, RADIO_2064_REG028, 0x1f, 0x3); - } -} - -static u16 wlc_lcnphy_rfseq_tbl_adc_pwrup(struct brcms_phy *pi) -{ - u16 N1, N2, N3, N4, N5, N6, N; - N1 = ((read_phy_reg(pi, 0x4a5) & (0xff << 0)) - >> 0); - N2 = 1 << ((read_phy_reg(pi, 0x4a5) & (0x7 << 12)) - >> 12); - N3 = ((read_phy_reg(pi, 0x40d) & (0xff << 0)) - >> 0); - N4 = 1 << ((read_phy_reg(pi, 0x40d) & (0x7 << 8)) - >> 8); - N5 = ((read_phy_reg(pi, 0x4a2) & (0xff << 0)) - >> 0); - N6 = 1 << ((read_phy_reg(pi, 0x4a2) & (0x7 << 8)) - >> 8); - N = 2 * (N1 + N2 + N3 + N4 + 2 * (N5 + N6)) + 80; - if (N < 1600) - N = 1600; - return N; -} - -static void wlc_lcnphy_pwrctrl_rssiparams(struct brcms_phy *pi) -{ - u16 auxpga_vmid, auxpga_vmid_temp, auxpga_gain_temp; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - auxpga_vmid = (2 << 8) | - (pi_lcn->lcnphy_rssi_vc << 4) | pi_lcn->lcnphy_rssi_vf; - auxpga_vmid_temp = (2 << 8) | (8 << 4) | 4; - auxpga_gain_temp = 2; - - mod_phy_reg(pi, 0x4d8, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, 0x4d8, (0x1 << 1), (0) << 1); - - mod_phy_reg(pi, 0x4d7, (0x1 << 3), (0) << 3); - - mod_phy_reg(pi, 0x4db, - (0x3ff << 0) | - (0x7 << 12), - (auxpga_vmid << 0) | (pi_lcn->lcnphy_rssi_gs << 12)); - - mod_phy_reg(pi, 0x4dc, - (0x3ff << 0) | - (0x7 << 12), - (auxpga_vmid << 0) | (pi_lcn->lcnphy_rssi_gs << 12)); - - mod_phy_reg(pi, 0x40a, - (0x3ff << 0) | - (0x7 << 12), - (auxpga_vmid << 0) | (pi_lcn->lcnphy_rssi_gs << 12)); - - mod_phy_reg(pi, 0x40b, - (0x3ff << 0) | - (0x7 << 12), - (auxpga_vmid_temp << 0) | (auxpga_gain_temp << 12)); - - mod_phy_reg(pi, 0x40c, - (0x3ff << 0) | - (0x7 << 12), - (auxpga_vmid_temp << 0) | (auxpga_gain_temp << 12)); - - mod_radio_reg(pi, RADIO_2064_REG082, (1 << 5), (1 << 5)); -} - -static void wlc_lcnphy_tssi_setup(struct brcms_phy *pi) -{ - struct phytbl_info tab; - u32 rfseq, ind; - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_ptr = &ind; - tab.tbl_len = 1; - tab.tbl_offset = 0; - for (ind = 0; ind < 128; ind++) { - wlc_lcnphy_write_table(pi, &tab); - tab.tbl_offset++; - } - tab.tbl_offset = 704; - for (ind = 0; ind < 128; ind++) { - wlc_lcnphy_write_table(pi, &tab); - tab.tbl_offset++; - } - mod_phy_reg(pi, 0x503, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, 0x503, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x503, (0x1 << 4), (1) << 4); - - wlc_lcnphy_set_tssi_mux(pi, LCNPHY_TSSI_EXT); - mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0) << 14); - - mod_phy_reg(pi, 0x4a4, (0x1 << 15), (1) << 15); - - mod_phy_reg(pi, 0x4d0, (0x1 << 5), (0) << 5); - - mod_phy_reg(pi, 0x4a4, (0x1ff << 0), (0) << 0); - - mod_phy_reg(pi, 0x4a5, (0xff << 0), (255) << 0); - - mod_phy_reg(pi, 0x4a5, (0x7 << 12), (5) << 12); - - mod_phy_reg(pi, 0x4a5, (0x7 << 8), (0) << 8); - - mod_phy_reg(pi, 0x40d, (0xff << 0), (64) << 0); - - mod_phy_reg(pi, 0x40d, (0x7 << 8), (4) << 8); - - mod_phy_reg(pi, 0x4a2, (0xff << 0), (64) << 0); - - mod_phy_reg(pi, 0x4a2, (0x7 << 8), (4) << 8); - - mod_phy_reg(pi, 0x4d0, (0x1ff << 6), (0) << 6); - - mod_phy_reg(pi, 0x4a8, (0xff << 0), (0x1) << 0); - - wlc_lcnphy_clear_tx_power_offsets(pi); - - mod_phy_reg(pi, 0x4a6, (0x1 << 15), (1) << 15); - - mod_phy_reg(pi, 0x4a6, (0x1ff << 0), (0xff) << 0); - - mod_phy_reg(pi, 0x49a, (0x1ff << 0), (0xff) << 0); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - mod_radio_reg(pi, RADIO_2064_REG028, 0xf, 0xe); - mod_radio_reg(pi, RADIO_2064_REG086, 0x4, 0x4); - } else { - mod_radio_reg(pi, RADIO_2064_REG03A, 0x1, 1); - mod_radio_reg(pi, RADIO_2064_REG11A, 0x8, 1 << 3); - } - - write_radio_reg(pi, RADIO_2064_REG025, 0xc); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - mod_radio_reg(pi, RADIO_2064_REG03A, 0x1, 1); - } else { - if (CHSPEC_IS2G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG03A, 0x2, 1 << 1); - else - mod_radio_reg(pi, RADIO_2064_REG03A, 0x2, 0 << 1); - } - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) - mod_radio_reg(pi, RADIO_2064_REG03A, 0x2, 1 << 1); - else - mod_radio_reg(pi, RADIO_2064_REG03A, 0x4, 1 << 2); - - mod_radio_reg(pi, RADIO_2064_REG11A, 0x1, 1 << 0); - - mod_radio_reg(pi, RADIO_2064_REG005, 0x8, 1 << 3); - - if (!wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - mod_phy_reg(pi, 0x4d7, - (0x1 << 3) | (0x7 << 12), 0 << 3 | 2 << 12); - - rfseq = wlc_lcnphy_rfseq_tbl_adc_pwrup(pi); - tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; - tab.tbl_width = 16; - tab.tbl_ptr = &rfseq; - tab.tbl_len = 1; - tab.tbl_offset = 6; - wlc_lcnphy_write_table(pi, &tab); - - mod_phy_reg(pi, 0x938, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x939, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x4a4, (0x1 << 12), (1) << 12); - - mod_phy_reg(pi, 0x4d7, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x4d7, (0xf << 8), (0) << 8); - - wlc_lcnphy_pwrctrl_rssiparams(pi); -} - -void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi) -{ - u16 tx_cnt, tx_total, npt; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - tx_total = wlc_lcnphy_total_tx_frames(pi); - tx_cnt = tx_total - pi_lcn->lcnphy_tssi_tx_cnt; - npt = wlc_lcnphy_get_tx_pwr_npt(pi); - - if (tx_cnt > (1 << npt)) { - - pi_lcn->lcnphy_tssi_tx_cnt = tx_total; - - pi_lcn->lcnphy_tssi_idx = wlc_lcnphy_get_current_tx_pwr_idx(pi); - pi_lcn->lcnphy_tssi_npt = npt; - - } -} - -s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1) -{ - s32 a, b, p; - - a = 32768 + (a1 * tssi); - b = (1024 * b0) + (64 * b1 * tssi); - p = ((2 * b) + a) / (2 * a); - - return p; -} - -static void wlc_lcnphy_txpower_reset_npt(struct brcms_phy *pi) -{ - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - return; - - pi_lcn->lcnphy_tssi_idx = LCNPHY_TX_PWR_CTRL_START_INDEX_2G_4313; - pi_lcn->lcnphy_tssi_npt = LCNPHY_TX_PWR_CTRL_START_NPT; -} - -void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi) -{ - struct phytbl_info tab; - u32 rate_table[BRCMS_NUM_RATES_CCK + BRCMS_NUM_RATES_OFDM + - BRCMS_NUM_RATES_MCS_1_STREAM]; - uint i, j; - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - return; - - for (i = 0, j = 0; i < ARRAY_SIZE(rate_table); i++, j++) { - - if (i == BRCMS_NUM_RATES_CCK + BRCMS_NUM_RATES_OFDM) - j = TXP_FIRST_MCS_20_SISO; - - rate_table[i] = (u32) ((s32) (-pi->tx_power_offset[j])); - } - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_len = ARRAY_SIZE(rate_table); - tab.tbl_ptr = rate_table; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_RATE_OFFSET; - wlc_lcnphy_write_table(pi, &tab); - - if (wlc_lcnphy_get_target_tx_pwr(pi) != pi->tx_power_min) { - wlc_lcnphy_set_target_tx_pwr(pi, pi->tx_power_min); - - wlc_lcnphy_txpower_reset_npt(pi); - } -} - -static void wlc_lcnphy_set_tx_pwr_soft_ctrl(struct brcms_phy *pi, s8 index) -{ - u32 cck_offset[4] = { 22, 22, 22, 22 }; - u32 ofdm_offset, reg_offset_cck; - int i; - u16 index2; - struct phytbl_info tab; - - if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) - return; - - mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0x1) << 14); - - mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0x0) << 14); - - or_phy_reg(pi, 0x6da, 0x0040); - - reg_offset_cck = 0; - for (i = 0; i < 4; i++) - cck_offset[i] -= reg_offset_cck; - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_len = 4; - tab.tbl_ptr = cck_offset; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_RATE_OFFSET; - wlc_lcnphy_write_table(pi, &tab); - ofdm_offset = 0; - tab.tbl_len = 1; - tab.tbl_ptr = &ofdm_offset; - for (i = 836; i < 862; i++) { - tab.tbl_offset = i; - wlc_lcnphy_write_table(pi, &tab); - } - - mod_phy_reg(pi, 0x4a4, (0x1 << 15), (0x1) << 15); - - mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0x1) << 14); - - mod_phy_reg(pi, 0x4a4, (0x1 << 13), (0x1) << 13); - - mod_phy_reg(pi, 0x4b0, (0x1 << 7), (0) << 7); - - mod_phy_reg(pi, 0x43b, (0x1 << 6), (0) << 6); - - mod_phy_reg(pi, 0x4a9, (0x1 << 15), (1) << 15); - - index2 = (u16) (index * 2); - mod_phy_reg(pi, 0x4a9, (0x1ff << 0), (index2) << 0); - - mod_phy_reg(pi, 0x6a3, (0x1 << 4), (0) << 4); - -} - -static s8 wlc_lcnphy_tempcompensated_txpwrctrl(struct brcms_phy *pi) -{ - s8 index, delta_brd, delta_temp, new_index, tempcorrx; - s16 manp, meas_temp, temp_diff; - bool neg = 0; - u16 temp; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) - return pi_lcn->lcnphy_current_index; - - index = FIXED_TXPWR; - - if (pi_lcn->lcnphy_tempsense_slope == 0) - return index; - - temp = (u16) wlc_lcnphy_tempsense(pi, 0); - meas_temp = LCNPHY_TEMPSENSE(temp); - - if (pi->tx_power_min != 0) - delta_brd = (pi_lcn->lcnphy_measPower - pi->tx_power_min); - else - delta_brd = 0; - - manp = LCNPHY_TEMPSENSE(pi_lcn->lcnphy_rawtempsense); - temp_diff = manp - meas_temp; - if (temp_diff < 0) { - neg = 1; - temp_diff = -temp_diff; - } - - delta_temp = (s8) wlc_lcnphy_qdiv_roundup((u32) (temp_diff * 192), - (u32) (pi_lcn-> - lcnphy_tempsense_slope - * 10), 0); - if (neg) - delta_temp = -delta_temp; - - if (pi_lcn->lcnphy_tempsense_option == 3 - && LCNREV_IS(pi->pubpi.phy_rev, 0)) - delta_temp = 0; - if (pi_lcn->lcnphy_tempcorrx > 31) - tempcorrx = (s8) (pi_lcn->lcnphy_tempcorrx - 64); - else - tempcorrx = (s8) pi_lcn->lcnphy_tempcorrx; - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) - tempcorrx = 4; - new_index = - index + delta_brd + delta_temp - pi_lcn->lcnphy_bandedge_corr; - new_index += tempcorrx; - - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) - index = 127; - - if (new_index < 0 || new_index > 126) - return index; - - return new_index; -} - -static u16 wlc_lcnphy_set_tx_pwr_ctrl_mode(struct brcms_phy *pi, u16 mode) -{ - - u16 current_mode = mode; - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) && - mode == LCNPHY_TX_PWR_CTRL_HW) - current_mode = LCNPHY_TX_PWR_CTRL_TEMPBASED; - if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi) && - mode == LCNPHY_TX_PWR_CTRL_TEMPBASED) - current_mode = LCNPHY_TX_PWR_CTRL_HW; - return current_mode; -} - -void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode) -{ - u16 old_mode = wlc_lcnphy_get_tx_pwr_ctrl(pi); - s8 index; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, mode); - old_mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, old_mode); - - mod_phy_reg(pi, 0x6da, (0x1 << 6), - ((LCNPHY_TX_PWR_CTRL_HW == mode) ? 1 : 0) << 6); - - mod_phy_reg(pi, 0x6a3, (0x1 << 4), - ((LCNPHY_TX_PWR_CTRL_HW == mode) ? 0 : 1) << 4); - - if (old_mode != mode) { - if (LCNPHY_TX_PWR_CTRL_HW == old_mode) { - - wlc_lcnphy_tx_pwr_update_npt(pi); - - wlc_lcnphy_clear_tx_power_offsets(pi); - } - if (LCNPHY_TX_PWR_CTRL_HW == mode) { - - wlc_lcnphy_txpower_recalc_target(pi); - - wlc_lcnphy_set_start_tx_pwr_idx(pi, - pi_lcn-> - lcnphy_tssi_idx); - wlc_lcnphy_set_tx_pwr_npt(pi, pi_lcn->lcnphy_tssi_npt); - mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 0); - - pi_lcn->lcnphy_tssi_tx_cnt = - wlc_lcnphy_total_tx_frames(pi); - - wlc_lcnphy_disable_tx_gain_override(pi); - pi_lcn->lcnphy_tx_power_idx_override = -1; - } else - wlc_lcnphy_enable_tx_gain_override(pi); - - mod_phy_reg(pi, 0x4a4, - ((0x1 << 15) | (0x1 << 14) | (0x1 << 13)), mode); - if (mode == LCNPHY_TX_PWR_CTRL_TEMPBASED) { - index = wlc_lcnphy_tempcompensated_txpwrctrl(pi); - wlc_lcnphy_set_tx_pwr_soft_ctrl(pi, index); - pi_lcn->lcnphy_current_index = (s8) - ((read_phy_reg(pi, - 0x4a9) & - 0xFF) / 2); - } - } -} - -static void -wlc_lcnphy_tx_iqlo_loopback(struct brcms_phy *pi, u16 *values_to_save) -{ - u16 vmid; - int i; - for (i = 0; i < 20; i++) - values_to_save[i] = - read_radio_reg(pi, iqlo_loopback_rf_regs[i]); - - mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); - mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); - - mod_phy_reg(pi, 0x44c, (0x1 << 11), 1 << 11); - mod_phy_reg(pi, 0x44d, (0x1 << 13), 0 << 13); - - mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); - - mod_phy_reg(pi, 0x43b, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x43c, (0x1 << 0), 0 << 0); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) - and_radio_reg(pi, RADIO_2064_REG03A, 0xFD); - else - and_radio_reg(pi, RADIO_2064_REG03A, 0xF9); - or_radio_reg(pi, RADIO_2064_REG11A, 0x1); - - or_radio_reg(pi, RADIO_2064_REG036, 0x01); - or_radio_reg(pi, RADIO_2064_REG11A, 0x18); - udelay(20); - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG03A, 1, 0); - else - or_radio_reg(pi, RADIO_2064_REG03A, 1); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG03A, 3, 1); - else - or_radio_reg(pi, RADIO_2064_REG03A, 0x3); - } - - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG025, 0xF); - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x4); - else - mod_radio_reg(pi, RADIO_2064_REG028, 0xF, 0x6); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) - mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x4 << 1); - else - mod_radio_reg(pi, RADIO_2064_REG028, 0x1e, 0x6 << 1); - } - - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG005, 0x8); - or_radio_reg(pi, RADIO_2064_REG112, 0x80); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); - or_radio_reg(pi, RADIO_2064_REG11F, 0x44); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG00B, 0x7); - or_radio_reg(pi, RADIO_2064_REG113, 0x10); - udelay(20); - - write_radio_reg(pi, RADIO_2064_REG007, 0x1); - udelay(20); - - vmid = 0x2A6; - mod_radio_reg(pi, RADIO_2064_REG0FC, 0x3 << 0, (vmid >> 8) & 0x3); - write_radio_reg(pi, RADIO_2064_REG0FD, (vmid & 0xff)); - or_radio_reg(pi, RADIO_2064_REG11F, 0x44); - udelay(20); - - or_radio_reg(pi, RADIO_2064_REG0FF, 0x10); - udelay(20); - write_radio_reg(pi, RADIO_2064_REG012, 0x02); - or_radio_reg(pi, RADIO_2064_REG112, 0x06); - write_radio_reg(pi, RADIO_2064_REG036, 0x11); - write_radio_reg(pi, RADIO_2064_REG059, 0xcc); - write_radio_reg(pi, RADIO_2064_REG05C, 0x2e); - write_radio_reg(pi, RADIO_2064_REG078, 0xd7); - write_radio_reg(pi, RADIO_2064_REG092, 0x15); -} - -static bool wlc_lcnphy_iqcal_wait(struct brcms_phy *pi) -{ - uint delay_count = 0; - - while (wlc_lcnphy_iqcal_active(pi)) { - udelay(100); - delay_count++; - - if (delay_count > (10 * 500)) - break; - } - - return (0 == wlc_lcnphy_iqcal_active(pi)); -} - -static void -wlc_lcnphy_tx_iqlo_loopback_cleanup(struct brcms_phy *pi, u16 *values_to_save) -{ - int i; - - and_phy_reg(pi, 0x44c, 0x0 >> 11); - - and_phy_reg(pi, 0x43b, 0xC); - - for (i = 0; i < 20; i++) - write_radio_reg(pi, iqlo_loopback_rf_regs[i], - values_to_save[i]); -} - -static void -wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, - struct lcnphy_txgains *target_gains, - enum lcnphy_cal_mode cal_mode, bool keep_tone) -{ - - struct lcnphy_txgains cal_gains, temp_gains; - u16 hash; - u8 band_idx; - int j; - u16 ncorr_override[5]; - u16 syst_coeffs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; - - u16 commands_fullcal[] = { - 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 - }; - - u16 commands_recal[] = { - 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 - }; - - u16 command_nums_fullcal[] = { - 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 - }; - - u16 command_nums_recal[] = { - 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 - }; - u16 *command_nums = command_nums_fullcal; - - u16 *start_coeffs = NULL, *cal_cmds = NULL, cal_type, diq_start; - u16 tx_pwr_ctrl_old, save_txpwrctrlrfctrl2; - u16 save_sslpnCalibClkEnCtrl, save_sslpnRxFeClkEnCtrl; - bool tx_gain_override_old; - struct lcnphy_txgains old_gains; - uint i, n_cal_cmds = 0, n_cal_start = 0; - u16 *values_to_save; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); - if (NULL == values_to_save) - return; - - save_sslpnRxFeClkEnCtrl = read_phy_reg(pi, 0x6db); - save_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - - or_phy_reg(pi, 0x6da, 0x40); - or_phy_reg(pi, 0x6db, 0x3); - - switch (cal_mode) { - case LCNPHY_CAL_FULL: - start_coeffs = syst_coeffs; - cal_cmds = commands_fullcal; - n_cal_cmds = ARRAY_SIZE(commands_fullcal); - break; - - case LCNPHY_CAL_RECAL: - start_coeffs = syst_coeffs; - cal_cmds = commands_recal; - n_cal_cmds = ARRAY_SIZE(commands_recal); - command_nums = command_nums_recal; - break; - - default: - break; - } - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - start_coeffs, 11, 16, 64); - - write_phy_reg(pi, 0x6da, 0xffff); - mod_phy_reg(pi, 0x503, (0x1 << 3), (1) << 3); - - tx_pwr_ctrl_old = wlc_lcnphy_get_tx_pwr_ctrl(pi); - - mod_phy_reg(pi, 0x4a4, (0x1 << 12), (1) << 12); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - save_txpwrctrlrfctrl2 = read_phy_reg(pi, 0x4db); - - mod_phy_reg(pi, 0x4db, (0x3ff << 0), (0x2a6) << 0); - - mod_phy_reg(pi, 0x4db, (0x7 << 12), (2) << 12); - - wlc_lcnphy_tx_iqlo_loopback(pi, values_to_save); - - tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); - if (tx_gain_override_old) - wlc_lcnphy_get_tx_gain(pi, &old_gains); - - if (!target_gains) { - if (!tx_gain_override_old) - wlc_lcnphy_set_tx_pwr_by_index(pi, - pi_lcn->lcnphy_tssi_idx); - wlc_lcnphy_get_tx_gain(pi, &temp_gains); - target_gains = &temp_gains; - } - - hash = (target_gains->gm_gain << 8) | - (target_gains->pga_gain << 4) | (target_gains->pad_gain); - - band_idx = (CHSPEC_IS5G(pi->radio_chanspec) ? 1 : 0); - - cal_gains = *target_gains; - memset(ncorr_override, 0, sizeof(ncorr_override)); - for (j = 0; j < iqcal_gainparams_numgains_lcnphy[band_idx]; j++) { - if (hash == tbl_iqcal_gainparams_lcnphy[band_idx][j][0]) { - cal_gains.gm_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][1]; - cal_gains.pga_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][2]; - cal_gains.pad_gain = - tbl_iqcal_gainparams_lcnphy[band_idx][j][3]; - memcpy(ncorr_override, - &tbl_iqcal_gainparams_lcnphy[band_idx][j][3], - sizeof(ncorr_override)); - break; - } - } - - wlc_lcnphy_set_tx_gain(pi, &cal_gains); - - write_phy_reg(pi, 0x453, 0xaa9); - write_phy_reg(pi, 0x93d, 0xc0); - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - lcnphy_iqcal_loft_gainladder, - ARRAY_SIZE(lcnphy_iqcal_loft_gainladder), - 16, 0); - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - lcnphy_iqcal_ir_gainladder, - ARRAY_SIZE( - lcnphy_iqcal_ir_gainladder), 16, - 32); - - if (pi->phy_tx_tone_freq) { - - wlc_lcnphy_stop_tx_tone(pi); - udelay(5); - wlc_lcnphy_start_tx_tone(pi, 3750, 88, 1); - } else { - wlc_lcnphy_start_tx_tone(pi, 3750, 88, 1); - } - - write_phy_reg(pi, 0x6da, 0xffff); - - for (i = n_cal_start; i < n_cal_cmds; i++) { - u16 zero_diq = 0; - u16 best_coeffs[11]; - u16 command_num; - - cal_type = (cal_cmds[i] & 0x0f00) >> 8; - - command_num = command_nums[i]; - if (ncorr_override[cal_type]) - command_num = - ncorr_override[cal_type] << 8 | (command_num & - 0xff); - - write_phy_reg(pi, 0x452, command_num); - - if ((cal_type == 3) || (cal_type == 4)) { - wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, - &diq_start, 1, 16, 69); - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - &zero_diq, 1, 16, 69); - } - - write_phy_reg(pi, 0x451, cal_cmds[i]); - - if (!wlc_lcnphy_iqcal_wait(pi)) - goto cleanup; - - wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, - best_coeffs, - ARRAY_SIZE(best_coeffs), 16, 96); - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - best_coeffs, - ARRAY_SIZE(best_coeffs), 16, 64); - - if ((cal_type == 3) || (cal_type == 4)) - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - &diq_start, 1, 16, 69); - wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, - pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs, - ARRAY_SIZE(pi_lcn-> - lcnphy_cal_results. - txiqlocal_bestcoeffs), - 16, 96); - } - - wlc_lcnphy_common_read_table(pi, LCNPHY_TBL_ID_IQLOCAL, - pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs, - ARRAY_SIZE(pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs), 16, 96); - pi_lcn->lcnphy_cal_results.txiqlocal_bestcoeffs_valid = true; - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - &pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs[0], 4, 16, 80); - - wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL, - &pi_lcn->lcnphy_cal_results. - txiqlocal_bestcoeffs[5], 2, 16, 85); - -cleanup: - wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, values_to_save); - kfree(values_to_save); - - if (!keep_tone) - wlc_lcnphy_stop_tx_tone(pi); - - write_phy_reg(pi, 0x4db, save_txpwrctrlrfctrl2); - - write_phy_reg(pi, 0x453, 0); - - if (tx_gain_override_old) - wlc_lcnphy_set_tx_gain(pi, &old_gains); - wlc_lcnphy_set_tx_pwr_ctrl(pi, tx_pwr_ctrl_old); - - write_phy_reg(pi, 0x6da, save_sslpnCalibClkEnCtrl); - write_phy_reg(pi, 0x6db, save_sslpnRxFeClkEnCtrl); - -} - -static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) -{ - bool suspend, tx_gain_override_old; - struct lcnphy_txgains old_gains; - struct brcms_phy *pi = (struct brcms_phy *) ppi; - u16 idleTssi, idleTssi0_2C, idleTssi0_OB, idleTssi0_regvalue_OB, - idleTssi0_regvalue_2C; - u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - u16 SAVE_lpfgain = read_radio_reg(pi, RADIO_2064_REG112); - u16 SAVE_jtag_bb_afe_switch = - read_radio_reg(pi, RADIO_2064_REG007) & 1; - u16 SAVE_jtag_auxpga = read_radio_reg(pi, RADIO_2064_REG0FF) & 0x10; - u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; - idleTssi = read_phy_reg(pi, 0x4ab); - suspend = - (0 == - (R_REG(&((struct brcms_phy *) pi)->regs->maccontrol) & - MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - tx_gain_override_old = wlc_lcnphy_tx_gain_override_enabled(pi); - wlc_lcnphy_get_tx_gain(pi, &old_gains); - - wlc_lcnphy_enable_tx_gain_override(pi); - wlc_lcnphy_set_tx_pwr_by_index(pi, 127); - write_radio_reg(pi, RADIO_2064_REG112, 0x6); - mod_radio_reg(pi, RADIO_2064_REG007, 0x1, 1); - mod_radio_reg(pi, RADIO_2064_REG0FF, 0x10, 1 << 4); - mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 1 << 2); - wlc_lcnphy_tssi_setup(pi); - wlc_phy_do_dummy_tx(pi, true, OFF); - idleTssi = ((read_phy_reg(pi, 0x4ab) & (0x1ff << 0)) - >> 0); - - idleTssi0_2C = ((read_phy_reg(pi, 0x63e) & (0x1ff << 0)) - >> 0); - - if (idleTssi0_2C >= 256) - idleTssi0_OB = idleTssi0_2C - 256; - else - idleTssi0_OB = idleTssi0_2C + 256; - - idleTssi0_regvalue_OB = idleTssi0_OB; - if (idleTssi0_regvalue_OB >= 256) - idleTssi0_regvalue_2C = idleTssi0_regvalue_OB - 256; - else - idleTssi0_regvalue_2C = idleTssi0_regvalue_OB + 256; - mod_phy_reg(pi, 0x4a6, (0x1ff << 0), (idleTssi0_regvalue_2C) << 0); - - mod_phy_reg(pi, 0x44c, (0x1 << 12), (0) << 12); - - wlc_lcnphy_set_tx_gain_override(pi, tx_gain_override_old); - wlc_lcnphy_set_tx_gain(pi, &old_gains); - wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_txpwrctrl); - - write_radio_reg(pi, RADIO_2064_REG112, SAVE_lpfgain); - mod_radio_reg(pi, RADIO_2064_REG007, 0x1, SAVE_jtag_bb_afe_switch); - mod_radio_reg(pi, RADIO_2064_REG0FF, 0x10, SAVE_jtag_auxpga); - mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, SAVE_iqadc_aux_en); - mod_radio_reg(pi, RADIO_2064_REG112, 0x80, 1 << 7); - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); -} - -static void wlc_lcnphy_vbat_temp_sense_setup(struct brcms_phy *pi, u8 mode) -{ - bool suspend; - u16 save_txpwrCtrlEn; - u8 auxpga_vmidcourse, auxpga_vmidfine, auxpga_gain; - u16 auxpga_vmid; - struct phytbl_info tab; - u32 val; - u8 save_reg007, save_reg0FF, save_reg11F, save_reg005, save_reg025, - save_reg112; - u16 values_to_save[14]; - s8 index; - int i; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - udelay(999); - - save_reg007 = (u8) read_radio_reg(pi, RADIO_2064_REG007); - save_reg0FF = (u8) read_radio_reg(pi, RADIO_2064_REG0FF); - save_reg11F = (u8) read_radio_reg(pi, RADIO_2064_REG11F); - save_reg005 = (u8) read_radio_reg(pi, RADIO_2064_REG005); - save_reg025 = (u8) read_radio_reg(pi, RADIO_2064_REG025); - save_reg112 = (u8) read_radio_reg(pi, RADIO_2064_REG112); - - for (i = 0; i < 14; i++) - values_to_save[i] = read_phy_reg(pi, tempsense_phy_regs[i]); - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - save_txpwrCtrlEn = read_radio_reg(pi, 0x4a4); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - index = pi_lcn->lcnphy_current_index; - wlc_lcnphy_set_tx_pwr_by_index(pi, 127); - mod_radio_reg(pi, RADIO_2064_REG007, 0x1, 0x1); - mod_radio_reg(pi, RADIO_2064_REG0FF, 0x10, 0x1 << 4); - mod_radio_reg(pi, RADIO_2064_REG11F, 0x4, 0x1 << 2); - mod_phy_reg(pi, 0x503, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, 0x503, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, 0x4a4, (0x1 << 14), (0) << 14); - - mod_phy_reg(pi, 0x4a4, (0x1 << 15), (0) << 15); - - mod_phy_reg(pi, 0x4d0, (0x1 << 5), (0) << 5); - - mod_phy_reg(pi, 0x4a5, (0xff << 0), (255) << 0); - - mod_phy_reg(pi, 0x4a5, (0x7 << 12), (5) << 12); - - mod_phy_reg(pi, 0x4a5, (0x7 << 8), (0) << 8); - - mod_phy_reg(pi, 0x40d, (0xff << 0), (64) << 0); - - mod_phy_reg(pi, 0x40d, (0x7 << 8), (6) << 8); - - mod_phy_reg(pi, 0x4a2, (0xff << 0), (64) << 0); - - mod_phy_reg(pi, 0x4a2, (0x7 << 8), (6) << 8); - - mod_phy_reg(pi, 0x4d9, (0x7 << 4), (2) << 4); - - mod_phy_reg(pi, 0x4d9, (0x7 << 8), (3) << 8); - - mod_phy_reg(pi, 0x4d9, (0x7 << 12), (1) << 12); - - mod_phy_reg(pi, 0x4da, (0x1 << 12), (0) << 12); - - mod_phy_reg(pi, 0x4da, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, 0x4a6, (0x1 << 15), (1) << 15); - - write_radio_reg(pi, RADIO_2064_REG025, 0xC); - - mod_radio_reg(pi, RADIO_2064_REG005, 0x8, 0x1 << 3); - - mod_phy_reg(pi, 0x938, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x939, (0x1 << 2), (1) << 2); - - mod_phy_reg(pi, 0x4a4, (0x1 << 12), (1) << 12); - - val = wlc_lcnphy_rfseq_tbl_adc_pwrup(pi); - tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; - tab.tbl_width = 16; - tab.tbl_len = 1; - tab.tbl_ptr = &val; - tab.tbl_offset = 6; - wlc_lcnphy_write_table(pi, &tab); - if (mode == TEMPSENSE) { - mod_phy_reg(pi, 0x4d7, (0x1 << 3), (1) << 3); - - mod_phy_reg(pi, 0x4d7, (0x7 << 12), (1) << 12); - - auxpga_vmidcourse = 8; - auxpga_vmidfine = 0x4; - auxpga_gain = 2; - mod_radio_reg(pi, RADIO_2064_REG082, 0x20, 1 << 5); - } else { - mod_phy_reg(pi, 0x4d7, (0x1 << 3), (1) << 3); - - mod_phy_reg(pi, 0x4d7, (0x7 << 12), (3) << 12); - - auxpga_vmidcourse = 7; - auxpga_vmidfine = 0xa; - auxpga_gain = 2; - } - auxpga_vmid = - (u16) ((2 << 8) | (auxpga_vmidcourse << 4) | auxpga_vmidfine); - mod_phy_reg(pi, 0x4d8, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, 0x4d8, (0x3ff << 2), (auxpga_vmid) << 2); - - mod_phy_reg(pi, 0x4d8, (0x1 << 1), (1) << 1); - - mod_phy_reg(pi, 0x4d8, (0x7 << 12), (auxpga_gain) << 12); - - mod_phy_reg(pi, 0x4d0, (0x1 << 5), (1) << 5); - - write_radio_reg(pi, RADIO_2064_REG112, 0x6); - - wlc_phy_do_dummy_tx(pi, true, OFF); - if (!tempsense_done(pi)) - udelay(10); - - write_radio_reg(pi, RADIO_2064_REG007, (u16) save_reg007); - write_radio_reg(pi, RADIO_2064_REG0FF, (u16) save_reg0FF); - write_radio_reg(pi, RADIO_2064_REG11F, (u16) save_reg11F); - write_radio_reg(pi, RADIO_2064_REG005, (u16) save_reg005); - write_radio_reg(pi, RADIO_2064_REG025, (u16) save_reg025); - write_radio_reg(pi, RADIO_2064_REG112, (u16) save_reg112); - for (i = 0; i < 14; i++) - write_phy_reg(pi, tempsense_phy_regs[i], values_to_save[i]); - wlc_lcnphy_set_tx_pwr_by_index(pi, (int)index); - - write_radio_reg(pi, 0x4a4, save_txpwrCtrlEn); - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - udelay(999); -} - -static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi) -{ - struct lcnphy_txgains tx_gains; - u8 bbmult; - struct phytbl_info tab; - s32 a1, b0, b1; - s32 tssi, pwr, maxtargetpwr, mintargetpwr; - bool suspend; - struct brcms_phy *pi = (struct brcms_phy *) ppi; - - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - if (!pi->hwpwrctrl_capable) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - tx_gains.gm_gain = 4; - tx_gains.pga_gain = 12; - tx_gains.pad_gain = 12; - tx_gains.dac_gain = 0; - - bbmult = 150; - } else { - tx_gains.gm_gain = 7; - tx_gains.pga_gain = 15; - tx_gains.pad_gain = 14; - tx_gains.dac_gain = 0; - - bbmult = 150; - } - wlc_lcnphy_set_tx_gain(pi, &tx_gains); - wlc_lcnphy_set_bbmult(pi, bbmult); - wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); - } else { - - wlc_lcnphy_idle_tssi_est(ppi); - - wlc_lcnphy_clear_tx_power_offsets(pi); - - b0 = pi->txpa_2g[0]; - b1 = pi->txpa_2g[1]; - a1 = pi->txpa_2g[2]; - maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1); - mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_ptr = &pwr; - tab.tbl_len = 1; - tab.tbl_offset = 0; - for (tssi = 0; tssi < 128; tssi++) { - pwr = wlc_lcnphy_tssi2dbm(tssi, a1, b0, b1); - - pwr = (pwr < mintargetpwr) ? mintargetpwr : pwr; - wlc_lcnphy_write_table(pi, &tab); - tab.tbl_offset++; - } - - mod_phy_reg(pi, 0x410, (0x1 << 7), (0) << 7); - - write_phy_reg(pi, 0x4a8, 10); - - wlc_lcnphy_set_target_tx_pwr(pi, LCN_TARGET_PWR); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_HW); - } - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); -} - -static u8 wlc_lcnphy_get_bbmult(struct brcms_phy *pi) -{ - u16 m0m1; - struct phytbl_info tab; - - tab.tbl_ptr = &m0m1; - tab.tbl_len = 1; - tab.tbl_id = LCNPHY_TBL_ID_IQLOCAL; - tab.tbl_offset = 87; - tab.tbl_width = 16; - wlc_lcnphy_read_table(pi, &tab); - - return (u8) ((m0m1 & 0xff00) >> 8); -} - -static void wlc_lcnphy_set_pa_gain(struct brcms_phy *pi, u16 gain) -{ - mod_phy_reg(pi, 0x4fb, - LCNPHY_txgainctrlovrval1_pagain_ovr_val1_MASK, - gain << LCNPHY_txgainctrlovrval1_pagain_ovr_val1_SHIFT); - mod_phy_reg(pi, 0x4fd, - LCNPHY_stxtxgainctrlovrval1_pagain_ovr_val1_MASK, - gain << LCNPHY_stxtxgainctrlovrval1_pagain_ovr_val1_SHIFT); -} - -void -wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, - u8 *ei0, u8 *eq0, u8 *fi0, u8 *fq0) -{ - *ei0 = LCNPHY_IQLOCC_READ(read_radio_reg(pi, RADIO_2064_REG089)); - *eq0 = LCNPHY_IQLOCC_READ(read_radio_reg(pi, RADIO_2064_REG08A)); - *fi0 = LCNPHY_IQLOCC_READ(read_radio_reg(pi, RADIO_2064_REG08B)); - *fq0 = LCNPHY_IQLOCC_READ(read_radio_reg(pi, RADIO_2064_REG08C)); -} - -void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b) -{ - struct phytbl_info tab; - u16 iqcc[2]; - - iqcc[0] = a; - iqcc[1] = b; - - tab.tbl_id = LCNPHY_TBL_ID_IQLOCAL; - tab.tbl_width = 16; - tab.tbl_ptr = iqcc; - tab.tbl_len = 2; - tab.tbl_offset = 80; - wlc_lcnphy_write_table(pi, &tab); -} - -void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq) -{ - struct phytbl_info tab; - - tab.tbl_id = LCNPHY_TBL_ID_IQLOCAL; - tab.tbl_width = 16; - tab.tbl_ptr = &didq; - tab.tbl_len = 1; - tab.tbl_offset = 85; - wlc_lcnphy_write_table(pi, &tab); -} - -void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index) -{ - struct phytbl_info tab; - u16 a, b; - u8 bb_mult; - u32 bbmultiqcomp, txgain, locoeffs, rfpower; - struct lcnphy_txgains gains; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - pi_lcn->lcnphy_tx_power_idx_override = (s8) index; - pi_lcn->lcnphy_current_index = (u8) index; - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_len = 1; - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_IQ_OFFSET + index; - tab.tbl_ptr = &bbmultiqcomp; - wlc_lcnphy_read_table(pi, &tab); - - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_GAIN_OFFSET + index; - tab.tbl_width = 32; - tab.tbl_ptr = &txgain; - wlc_lcnphy_read_table(pi, &tab); - - gains.gm_gain = (u16) (txgain & 0xff); - gains.pga_gain = (u16) (txgain >> 8) & 0xff; - gains.pad_gain = (u16) (txgain >> 16) & 0xff; - gains.dac_gain = (u16) (bbmultiqcomp >> 28) & 0x07; - wlc_lcnphy_set_tx_gain(pi, &gains); - wlc_lcnphy_set_pa_gain(pi, (u16) (txgain >> 24) & 0x7f); - - bb_mult = (u8) ((bbmultiqcomp >> 20) & 0xff); - wlc_lcnphy_set_bbmult(pi, bb_mult); - - wlc_lcnphy_enable_tx_gain_override(pi); - - if (!wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { - - a = (u16) ((bbmultiqcomp >> 10) & 0x3ff); - b = (u16) (bbmultiqcomp & 0x3ff); - wlc_lcnphy_set_tx_iqcc(pi, a, b); - - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_LO_OFFSET + index; - tab.tbl_ptr = &locoeffs; - wlc_lcnphy_read_table(pi, &tab); - - wlc_lcnphy_set_tx_locc(pi, (u16) locoeffs); - - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_PWR_OFFSET + index; - tab.tbl_ptr = &rfpower; - wlc_lcnphy_read_table(pi, &tab); - mod_phy_reg(pi, 0x6a6, (0x1fff << 0), (rfpower * 8) << 0); - - } -} - -static void wlc_lcnphy_clear_papd_comptable(struct brcms_phy *pi) -{ - u32 j; - struct phytbl_info tab; - u32 temp_offset[128]; - tab.tbl_ptr = temp_offset; - tab.tbl_len = 128; - tab.tbl_id = LCNPHY_TBL_ID_PAPDCOMPDELTATBL; - tab.tbl_width = 32; - tab.tbl_offset = 0; - - memset(temp_offset, 0, sizeof(temp_offset)); - for (j = 1; j < 128; j += 2) - temp_offset[j] = 0x80000; - - wlc_lcnphy_write_table(pi, &tab); - return; -} - -void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable) -{ - if (!bEnable) { - - and_phy_reg(pi, 0x43b, ~(u16) ((0x1 << 1) | (0x1 << 4))); - - mod_phy_reg(pi, 0x43c, (0x1 << 1), 1 << 1); - - and_phy_reg(pi, 0x44c, - ~(u16) ((0x1 << 3) | - (0x1 << 5) | - (0x1 << 12) | - (0x1 << 0) | (0x1 << 1) | (0x1 << 2))); - - and_phy_reg(pi, 0x44d, - ~(u16) ((0x1 << 3) | (0x1 << 5) | (0x1 << 14))); - mod_phy_reg(pi, 0x44d, (0x1 << 2), 1 << 2); - - mod_phy_reg(pi, 0x44d, (0x1 << 1) | (0x1 << 0), (0x1 << 0)); - - and_phy_reg(pi, 0x4f9, - ~(u16) ((0x1 << 0) | (0x1 << 1) | (0x1 << 2))); - - and_phy_reg(pi, 0x4fa, - ~(u16) ((0x1 << 0) | (0x1 << 1) | (0x1 << 2))); - } else { - - mod_phy_reg(pi, 0x43b, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x43c, (0x1 << 1), 0 << 1); - - mod_phy_reg(pi, 0x43b, (0x1 << 4), 1 << 4); - mod_phy_reg(pi, 0x43c, (0x1 << 6), 0 << 6); - - mod_phy_reg(pi, 0x44c, (0x1 << 12), 1 << 12); - mod_phy_reg(pi, 0x44d, (0x1 << 14), 1 << 14); - - wlc_lcnphy_set_trsw_override(pi, true, false); - - mod_phy_reg(pi, 0x44d, (0x1 << 2), 0 << 2); - mod_phy_reg(pi, 0x44c, (0x1 << 2), 1 << 2); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - - mod_phy_reg(pi, 0x44c, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x44d, (0x1 << 3), 1 << 3); - - mod_phy_reg(pi, 0x44c, (0x1 << 5), 1 << 5); - mod_phy_reg(pi, 0x44d, (0x1 << 5), 0 << 5); - - mod_phy_reg(pi, 0x4f9, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x4fa, (0x1 << 1), 1 << 1); - - mod_phy_reg(pi, 0x4f9, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x4fa, (0x1 << 2), 1 << 2); - - mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x4fa, (0x1 << 0), 1 << 0); - } else { - - mod_phy_reg(pi, 0x44c, (0x1 << 3), 1 << 3); - mod_phy_reg(pi, 0x44d, (0x1 << 3), 0 << 3); - - mod_phy_reg(pi, 0x44c, (0x1 << 5), 1 << 5); - mod_phy_reg(pi, 0x44d, (0x1 << 5), 1 << 5); - - mod_phy_reg(pi, 0x4f9, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0x4fa, (0x1 << 1), 0 << 1); - - mod_phy_reg(pi, 0x4f9, (0x1 << 2), 1 << 2); - mod_phy_reg(pi, 0x4fa, (0x1 << 2), 0 << 2); - - mod_phy_reg(pi, 0x4f9, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x4fa, (0x1 << 0), 0 << 0); - } - } -} - -static void -wlc_lcnphy_run_samples(struct brcms_phy *pi, - u16 num_samps, - u16 num_loops, u16 wait, bool iqcalmode) -{ - - or_phy_reg(pi, 0x6da, 0x8080); - - mod_phy_reg(pi, 0x642, (0x7f << 0), (num_samps - 1) << 0); - if (num_loops != 0xffff) - num_loops--; - mod_phy_reg(pi, 0x640, (0xffff << 0), num_loops << 0); - - mod_phy_reg(pi, 0x641, (0xffff << 0), wait << 0); - - if (iqcalmode) { - - and_phy_reg(pi, 0x453, (u16) ~(0x1 << 15)); - or_phy_reg(pi, 0x453, (0x1 << 15)); - } else { - write_phy_reg(pi, 0x63f, 1); - wlc_lcnphy_tx_pu(pi, 1); - } - - or_radio_reg(pi, RADIO_2064_REG112, 0x6); -} - -void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode) -{ - - u8 phybw40; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - if (LCNREV_LT(pi->pubpi.phy_rev, 2)) { - mod_phy_reg(pi, 0x4b0, (0x1 << 5), (mode) << 5); - mod_phy_reg(pi, 0x4b1, (0x1 << 9), 0 << 9); - } else { - mod_phy_reg(pi, 0x4b0, (0x1 << 5), (mode) << 5); - mod_phy_reg(pi, 0x4b1, (0x1 << 9), 0 << 9); - } - - if (phybw40 == 0) { - mod_phy_reg((pi), 0x410, - (0x1 << 6) | - (0x1 << 5), - ((CHSPEC_IS2G( - pi->radio_chanspec)) ? (!mode) : 0) << - 6 | (!mode) << 5); - mod_phy_reg(pi, 0x410, (0x1 << 7), (mode) << 7); - } -} - -void -wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, - bool iqcalmode) -{ - u8 phy_bw; - u16 num_samps, t, k; - u32 bw; - s32 theta = 0, rot = 0; - struct cordic_iq tone_samp; - u32 data_buf[64]; - u16 i_samp, q_samp; - struct phytbl_info tab; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - pi->phy_tx_tone_freq = f_kHz; - - wlc_lcnphy_deaf_mode(pi, true); - - phy_bw = 40; - if (pi_lcn->lcnphy_spurmod) { - write_phy_reg(pi, 0x942, 0x2); - write_phy_reg(pi, 0x93b, 0x0); - write_phy_reg(pi, 0x93c, 0x0); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, false); - } - - if (f_kHz) { - k = 1; - do { - bw = phy_bw * 1000 * k; - num_samps = bw / abs(f_kHz); - k++; - } while ((num_samps * (u32) (abs(f_kHz))) != bw); - } else - num_samps = 2; - - rot = ((f_kHz * 36) / phy_bw) / 100; - theta = 0; - - for (t = 0; t < num_samps; t++) { - - tone_samp = cordic_calc_iq(theta); - - theta += rot; - - i_samp = (u16) (FLOAT(tone_samp.i * max_val) & 0x3ff); - q_samp = (u16) (FLOAT(tone_samp.q * max_val) & 0x3ff); - data_buf[t] = (i_samp << 10) | q_samp; - } - - mod_phy_reg(pi, 0x6d6, (0x3 << 0), 0 << 0); - - mod_phy_reg(pi, 0x6da, (0x1 << 3), 1 << 3); - - tab.tbl_ptr = data_buf; - tab.tbl_len = num_samps; - tab.tbl_id = LCNPHY_TBL_ID_SAMPLEPLAY; - tab.tbl_offset = 0; - tab.tbl_width = 32; - wlc_lcnphy_write_table(pi, &tab); - - wlc_lcnphy_run_samples(pi, num_samps, 0xffff, 0, iqcalmode); -} - -void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi) -{ - s16 playback_status; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - pi->phy_tx_tone_freq = 0; - if (pi_lcn->lcnphy_spurmod) { - write_phy_reg(pi, 0x942, 0x7); - write_phy_reg(pi, 0x93b, 0x2017); - write_phy_reg(pi, 0x93c, 0x27c5); - wlc_lcnphy_txrx_spur_avoidance_mode(pi, true); - } - - playback_status = read_phy_reg(pi, 0x644); - if (playback_status & (0x1 << 0)) { - wlc_lcnphy_tx_pu(pi, 0); - mod_phy_reg(pi, 0x63f, (0x1 << 1), 1 << 1); - } else if (playback_status & (0x1 << 1)) - mod_phy_reg(pi, 0x453, (0x1 << 15), 0 << 15); - - mod_phy_reg(pi, 0x6d6, (0x3 << 0), 1 << 0); - - mod_phy_reg(pi, 0x6da, (0x1 << 3), 0 << 3); - - mod_phy_reg(pi, 0x6da, (0x1 << 7), 0 << 7); - - and_radio_reg(pi, RADIO_2064_REG112, 0xFFF9); - - wlc_lcnphy_deaf_mode(pi, false); -} - -static void -wlc_lcnphy_set_cc(struct brcms_phy *pi, int cal_type, s16 coeff_x, s16 coeff_y) -{ - u16 di0dq0; - u16 x, y, data_rf; - int k; - switch (cal_type) { - case 0: - wlc_lcnphy_set_tx_iqcc(pi, coeff_x, coeff_y); - break; - case 2: - di0dq0 = (coeff_x & 0xff) << 8 | (coeff_y & 0xff); - wlc_lcnphy_set_tx_locc(pi, di0dq0); - break; - case 3: - k = wlc_lcnphy_calc_floor(coeff_x, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_x, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG089, data_rf); - k = wlc_lcnphy_calc_floor(coeff_y, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_y, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08A, data_rf); - break; - case 4: - k = wlc_lcnphy_calc_floor(coeff_x, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_x, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08B, data_rf); - k = wlc_lcnphy_calc_floor(coeff_y, 0); - y = 8 + k; - k = wlc_lcnphy_calc_floor(coeff_y, 1); - x = 8 - k; - data_rf = (x * 16 + y); - write_radio_reg(pi, RADIO_2064_REG08C, data_rf); - break; - } -} - -static struct lcnphy_unsign16_struct -wlc_lcnphy_get_cc(struct brcms_phy *pi, int cal_type) -{ - u16 a, b, didq; - u8 di0, dq0, ei, eq, fi, fq; - struct lcnphy_unsign16_struct cc; - cc.re = 0; - cc.im = 0; - switch (cal_type) { - case 0: - wlc_lcnphy_get_tx_iqcc(pi, &a, &b); - cc.re = a; - cc.im = b; - break; - case 2: - didq = wlc_lcnphy_get_tx_locc(pi); - di0 = (((didq & 0xff00) << 16) >> 24); - dq0 = (((didq & 0x00ff) << 24) >> 24); - cc.re = (u16) di0; - cc.im = (u16) dq0; - break; - case 3: - wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); - cc.re = (u16) ei; - cc.im = (u16) eq; - break; - case 4: - wlc_lcnphy_get_radio_loft(pi, &ei, &eq, &fi, &fq); - cc.re = (u16) fi; - cc.im = (u16) fq; - break; - } - return cc; -} - -static void -wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, - s16 *ptr, int mode) -{ - u32 curval1, curval2, stpptr, curptr, strptr, val; - u16 sslpnCalibClkEnCtrl, timer; - u16 old_sslpnCalibClkEnCtrl; - s16 imag, real; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - timer = 0; - old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - - curval1 = R_REG(&pi->regs->psm_corectlsts); - ptr[130] = 0; - W_REG(&pi->regs->psm_corectlsts, ((1 << 6) | curval1)); - - W_REG(&pi->regs->smpl_clct_strptr, 0x7E00); - W_REG(&pi->regs->smpl_clct_stpptr, 0x8000); - udelay(20); - curval2 = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, curval2 | 0x30); - - write_phy_reg(pi, 0x555, 0x0); - write_phy_reg(pi, 0x5a6, 0x5); - - write_phy_reg(pi, 0x5a2, (u16) (mode | mode << 6)); - write_phy_reg(pi, 0x5cf, 3); - write_phy_reg(pi, 0x5a5, 0x3); - write_phy_reg(pi, 0x583, 0x0); - write_phy_reg(pi, 0x584, 0x0); - write_phy_reg(pi, 0x585, 0x0fff); - write_phy_reg(pi, 0x586, 0x0000); - - write_phy_reg(pi, 0x580, 0x4501); - - sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - write_phy_reg(pi, 0x6da, (u32) (sslpnCalibClkEnCtrl | 0x2008)); - stpptr = R_REG(&pi->regs->smpl_clct_stpptr); - curptr = R_REG(&pi->regs->smpl_clct_curptr); - do { - udelay(10); - curptr = R_REG(&pi->regs->smpl_clct_curptr); - timer++; - } while ((curptr != stpptr) && (timer < 500)); - - W_REG(&pi->regs->psm_phy_hdr_param, 0x2); - strptr = 0x7E00; - W_REG(&pi->regs->tplatewrptr, strptr); - while (strptr < 0x8000) { - val = R_REG(&pi->regs->tplatewrdata); - imag = ((val >> 16) & 0x3ff); - real = ((val) & 0x3ff); - if (imag > 511) - imag -= 1024; - - if (real > 511) - real -= 1024; - - if (pi_lcn->lcnphy_iqcal_swp_dis) - ptr[(strptr - 0x7E00) / 4] = real; - else - ptr[(strptr - 0x7E00) / 4] = imag; - - if (clip_detect_algo) { - if (imag > thresh || imag < -thresh) { - strptr = 0x8000; - ptr[130] = 1; - } - } - - strptr += 4; - } - - write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - W_REG(&pi->regs->psm_phy_hdr_param, curval2); - W_REG(&pi->regs->psm_corectlsts, curval1); -} - -static void -wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, - int step_size_lg2) -{ - const struct lcnphy_spb_tone *phy_c1; - struct lcnphy_spb_tone phy_c2; - struct lcnphy_unsign16_struct phy_c3; - int phy_c4, phy_c5, k, l, j, phy_c6; - u16 phy_c7, phy_c8, phy_c9; - s16 phy_c10, phy_c11, phy_c12, phy_c13, phy_c14, phy_c15, phy_c16; - s16 *ptr, phy_c17; - s32 phy_c18, phy_c19; - u32 phy_c20, phy_c21; - bool phy_c22, phy_c23, phy_c24, phy_c25; - u16 phy_c26, phy_c27; - u16 phy_c28, phy_c29, phy_c30; - u16 phy_c31; - u16 *phy_c32; - phy_c21 = 0; - phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; - ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); - if (NULL == ptr) - return; - - phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); - if (NULL == phy_c32) { - kfree(ptr); - return; - } - phy_c26 = read_phy_reg(pi, 0x6da); - phy_c27 = read_phy_reg(pi, 0x6db); - phy_c31 = read_radio_reg(pi, RADIO_2064_REG026); - write_phy_reg(pi, 0x93d, 0xC0); - - wlc_lcnphy_start_tx_tone(pi, 3750, 88, 0); - write_phy_reg(pi, 0x6da, 0xffff); - or_phy_reg(pi, 0x6db, 0x3); - - wlc_lcnphy_tx_iqlo_loopback(pi, phy_c32); - udelay(500); - phy_c28 = read_phy_reg(pi, 0x938); - phy_c29 = read_phy_reg(pi, 0x4d7); - phy_c30 = read_phy_reg(pi, 0x4d8); - or_phy_reg(pi, 0x938, 0x1 << 2); - or_phy_reg(pi, 0x4d7, 0x1 << 2); - or_phy_reg(pi, 0x4d7, 0x1 << 3); - mod_phy_reg(pi, 0x4d7, (0x7 << 12), 0x2 << 12); - or_phy_reg(pi, 0x4d8, 1 << 0); - or_phy_reg(pi, 0x4d8, 1 << 1); - mod_phy_reg(pi, 0x4d8, (0x3ff << 2), 0x23A << 2); - mod_phy_reg(pi, 0x4d8, (0x7 << 12), 0x7 << 12); - phy_c1 = &lcnphy_spb_tone_3750[0]; - phy_c4 = 32; - - if (num_levels == 0) { - if (cal_type != 0) - num_levels = 4; - else - num_levels = 9; - } - if (step_size_lg2 == 0) { - if (cal_type != 0) - step_size_lg2 = 3; - else - step_size_lg2 = 8; - } - - phy_c7 = (1 << step_size_lg2); - phy_c3 = wlc_lcnphy_get_cc(pi, cal_type); - phy_c15 = (s16) phy_c3.re; - phy_c16 = (s16) phy_c3.im; - if (cal_type == 2) { - if (phy_c3.re > 127) - phy_c15 = phy_c3.re - 256; - if (phy_c3.im > 127) - phy_c16 = phy_c3.im - 256; - } - wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); - udelay(20); - for (phy_c8 = 0; phy_c7 != 0 && phy_c8 < num_levels; phy_c8++) { - phy_c23 = 1; - phy_c22 = 0; - switch (cal_type) { - case 0: - phy_c10 = 511; - break; - case 2: - phy_c10 = 127; - break; - case 3: - phy_c10 = 15; - break; - case 4: - phy_c10 = 15; - break; - } - - phy_c9 = read_phy_reg(pi, 0x93d); - phy_c9 = 2 * phy_c9; - phy_c24 = 0; - phy_c5 = 7; - phy_c25 = 1; - while (1) { - write_radio_reg(pi, RADIO_2064_REG026, - (phy_c5 & 0x7) | ((phy_c5 & 0x7) << 4)); - udelay(50); - phy_c22 = 0; - ptr[130] = 0; - wlc_lcnphy_samp_cap(pi, 1, phy_c9, &ptr[0], 2); - if (ptr[130] == 1) - phy_c22 = 1; - if (phy_c22) - phy_c5 -= 1; - if ((phy_c22 != phy_c24) && (!phy_c25)) - break; - if (!phy_c22) - phy_c5 += 1; - if (phy_c5 <= 0 || phy_c5 >= 7) - break; - phy_c24 = phy_c22; - phy_c25 = 0; - } - - if (phy_c5 < 0) - phy_c5 = 0; - else if (phy_c5 > 7) - phy_c5 = 7; - - for (k = -phy_c7; k <= phy_c7; k += phy_c7) { - for (l = -phy_c7; l <= phy_c7; l += phy_c7) { - phy_c11 = phy_c15 + k; - phy_c12 = phy_c16 + l; - - if (phy_c11 < -phy_c10) - phy_c11 = -phy_c10; - else if (phy_c11 > phy_c10) - phy_c11 = phy_c10; - if (phy_c12 < -phy_c10) - phy_c12 = -phy_c10; - else if (phy_c12 > phy_c10) - phy_c12 = phy_c10; - wlc_lcnphy_set_cc(pi, cal_type, phy_c11, - phy_c12); - udelay(20); - wlc_lcnphy_samp_cap(pi, 0, 0, ptr, 2); - - phy_c18 = 0; - phy_c19 = 0; - for (j = 0; j < 128; j++) { - if (cal_type != 0) - phy_c6 = j % phy_c4; - else - phy_c6 = (2 * j) % phy_c4; - - phy_c2.re = phy_c1[phy_c6].re; - phy_c2.im = phy_c1[phy_c6].im; - phy_c17 = ptr[j]; - phy_c18 = phy_c18 + phy_c17 * phy_c2.re; - phy_c19 = phy_c19 + phy_c17 * phy_c2.im; - } - - phy_c18 = phy_c18 >> 10; - phy_c19 = phy_c19 >> 10; - phy_c20 = ((phy_c18 * phy_c18) + - (phy_c19 * phy_c19)); - - if (phy_c23 || phy_c20 < phy_c21) { - phy_c21 = phy_c20; - phy_c13 = phy_c11; - phy_c14 = phy_c12; - } - phy_c23 = 0; - } - } - phy_c23 = 1; - phy_c15 = phy_c13; - phy_c16 = phy_c14; - phy_c7 = phy_c7 >> 1; - wlc_lcnphy_set_cc(pi, cal_type, phy_c15, phy_c16); - udelay(20); - } - goto cleanup; -cleanup: - wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, phy_c32); - wlc_lcnphy_stop_tx_tone(pi); - write_phy_reg(pi, 0x6da, phy_c26); - write_phy_reg(pi, 0x6db, phy_c27); - write_phy_reg(pi, 0x938, phy_c28); - write_phy_reg(pi, 0x4d7, phy_c29); - write_phy_reg(pi, 0x4d8, phy_c30); - write_radio_reg(pi, RADIO_2064_REG026, phy_c31); - - kfree(phy_c32); - kfree(ptr); -} - -void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b) -{ - u16 iqcc[2]; - struct phytbl_info tab; - - tab.tbl_ptr = iqcc; - tab.tbl_len = 2; - tab.tbl_id = 0; - tab.tbl_offset = 80; - tab.tbl_width = 16; - wlc_lcnphy_read_table(pi, &tab); - - *a = iqcc[0]; - *b = iqcc[1]; -} - -static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi) -{ - struct lcnphy_unsign16_struct iqcc0, locc2, locc3, locc4; - - wlc_lcnphy_set_cc(pi, 0, 0, 0); - wlc_lcnphy_set_cc(pi, 2, 0, 0); - wlc_lcnphy_set_cc(pi, 3, 0, 0); - wlc_lcnphy_set_cc(pi, 4, 0, 0); - - wlc_lcnphy_a1(pi, 4, 0, 0); - wlc_lcnphy_a1(pi, 3, 0, 0); - wlc_lcnphy_a1(pi, 2, 3, 2); - wlc_lcnphy_a1(pi, 0, 5, 8); - wlc_lcnphy_a1(pi, 2, 2, 1); - wlc_lcnphy_a1(pi, 0, 4, 3); - - iqcc0 = wlc_lcnphy_get_cc(pi, 0); - locc2 = wlc_lcnphy_get_cc(pi, 2); - locc3 = wlc_lcnphy_get_cc(pi, 3); - locc4 = wlc_lcnphy_get_cc(pi, 4); -} - -u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi) -{ - struct phytbl_info tab; - u16 didq; - - tab.tbl_id = 0; - tab.tbl_width = 16; - tab.tbl_ptr = &didq; - tab.tbl_len = 1; - tab.tbl_offset = 85; - wlc_lcnphy_read_table(pi, &tab); - - return didq; -} - -static void wlc_lcnphy_txpwrtbl_iqlo_cal(struct brcms_phy *pi) -{ - - struct lcnphy_txgains target_gains, old_gains; - u8 save_bb_mult; - u16 a, b, didq, save_pa_gain = 0; - uint idx, SAVE_txpwrindex = 0xFF; - u32 val; - u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - struct phytbl_info tab; - u8 ei0, eq0, fi0, fq0; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - wlc_lcnphy_get_tx_gain(pi, &old_gains); - save_pa_gain = wlc_lcnphy_get_pa_gain(pi); - - save_bb_mult = wlc_lcnphy_get_bbmult(pi); - - if (SAVE_txpwrctrl == LCNPHY_TX_PWR_CTRL_OFF) - SAVE_txpwrindex = wlc_lcnphy_get_current_tx_pwr_idx(pi); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - - target_gains.gm_gain = 7; - target_gains.pga_gain = 0; - target_gains.pad_gain = 21; - target_gains.dac_gain = 0; - wlc_lcnphy_set_tx_gain(pi, &target_gains); - wlc_lcnphy_set_tx_pwr_by_index(pi, 16); - - if (LCNREV_IS(pi->pubpi.phy_rev, 1) || pi_lcn->lcnphy_hw_iqcal_en) { - - wlc_lcnphy_set_tx_pwr_by_index(pi, 30); - - wlc_lcnphy_tx_iqlo_cal(pi, &target_gains, - (pi_lcn-> - lcnphy_recal ? LCNPHY_CAL_RECAL : - LCNPHY_CAL_FULL), false); - } else { - wlc_lcnphy_tx_iqlo_soft_cal_full(pi); - } - - wlc_lcnphy_get_radio_loft(pi, &ei0, &eq0, &fi0, &fq0); - if ((abs((s8) fi0) == 15) && (abs((s8) fq0) == 15)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - target_gains.gm_gain = 255; - target_gains.pga_gain = 255; - target_gains.pad_gain = 0xf0; - target_gains.dac_gain = 0; - } else { - target_gains.gm_gain = 7; - target_gains.pga_gain = 45; - target_gains.pad_gain = 186; - target_gains.dac_gain = 0; - } - - if (LCNREV_IS(pi->pubpi.phy_rev, 1) - || pi_lcn->lcnphy_hw_iqcal_en) { - - target_gains.pga_gain = 0; - target_gains.pad_gain = 30; - wlc_lcnphy_set_tx_pwr_by_index(pi, 16); - wlc_lcnphy_tx_iqlo_cal(pi, &target_gains, - LCNPHY_CAL_FULL, false); - } else { - wlc_lcnphy_tx_iqlo_soft_cal_full(pi); - } - } - - wlc_lcnphy_get_tx_iqcc(pi, &a, &b); - - didq = wlc_lcnphy_get_tx_locc(pi); - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_ptr = &val; - - tab.tbl_len = 1; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_RATE_OFFSET; - - for (idx = 0; idx < 128; idx++) { - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_IQ_OFFSET + idx; - - wlc_lcnphy_read_table(pi, &tab); - val = (val & 0xfff00000) | - ((u32) (a & 0x3FF) << 10) | (b & 0x3ff); - wlc_lcnphy_write_table(pi, &tab); - - val = didq; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_LO_OFFSET + idx; - wlc_lcnphy_write_table(pi, &tab); - } - - pi_lcn->lcnphy_cal_results.txiqlocal_a = a; - pi_lcn->lcnphy_cal_results.txiqlocal_b = b; - pi_lcn->lcnphy_cal_results.txiqlocal_didq = didq; - pi_lcn->lcnphy_cal_results.txiqlocal_ei0 = ei0; - pi_lcn->lcnphy_cal_results.txiqlocal_eq0 = eq0; - pi_lcn->lcnphy_cal_results.txiqlocal_fi0 = fi0; - pi_lcn->lcnphy_cal_results.txiqlocal_fq0 = fq0; - - wlc_lcnphy_set_bbmult(pi, save_bb_mult); - wlc_lcnphy_set_pa_gain(pi, save_pa_gain); - wlc_lcnphy_set_tx_gain(pi, &old_gains); - - if (SAVE_txpwrctrl != LCNPHY_TX_PWR_CTRL_OFF) - wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_txpwrctrl); - else - wlc_lcnphy_set_tx_pwr_by_index(pi, SAVE_txpwrindex); -} - -s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode) -{ - u16 tempsenseval1, tempsenseval2; - s16 avg = 0; - bool suspend = 0; - - if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); - } - tempsenseval1 = read_phy_reg(pi, 0x476) & 0x1FF; - tempsenseval2 = read_phy_reg(pi, 0x477) & 0x1FF; - - if (tempsenseval1 > 255) - avg = (s16) (tempsenseval1 - 512); - else - avg = (s16) tempsenseval1; - - if (tempsenseval2 > 255) - avg += (s16) (tempsenseval2 - 512); - else - avg += (s16) tempsenseval2; - - avg /= 2; - - if (mode == 1) { - - mod_phy_reg(pi, 0x448, (0x1 << 14), (1) << 14); - - udelay(100); - mod_phy_reg(pi, 0x448, (0x1 << 14), (0) << 14); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - } - return avg; -} - -u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode) -{ - u16 tempsenseval1, tempsenseval2; - s32 avg = 0; - bool suspend = 0; - u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); - } - tempsenseval1 = read_phy_reg(pi, 0x476) & 0x1FF; - tempsenseval2 = read_phy_reg(pi, 0x477) & 0x1FF; - - if (tempsenseval1 > 255) - avg = (int)(tempsenseval1 - 512); - else - avg = (int)tempsenseval1; - - if (pi_lcn->lcnphy_tempsense_option == 1 || pi->hwpwrctrl_capable) { - if (tempsenseval2 > 255) - avg = (int)(avg - tempsenseval2 + 512); - else - avg = (int)(avg - tempsenseval2); - } else { - if (tempsenseval2 > 255) - avg = (int)(avg + tempsenseval2 - 512); - else - avg = (int)(avg + tempsenseval2); - avg = avg / 2; - } - if (avg < 0) - avg = avg + 512; - - if (pi_lcn->lcnphy_tempsense_option == 2) - avg = tempsenseval1; - - if (mode) - wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_txpwrctrl); - - if (mode == 1) { - - mod_phy_reg(pi, 0x448, (0x1 << 14), (1) << 14); - - udelay(100); - mod_phy_reg(pi, 0x448, (0x1 << 14), (0) << 14); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - } - return (u16) avg; -} - -s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode) -{ - s32 degree = wlc_lcnphy_tempsense_new(pi, mode); - degree = - ((degree << - 10) + LCN_TEMPSENSE_OFFSET + (LCN_TEMPSENSE_DEN >> 1)) - / LCN_TEMPSENSE_DEN; - return (s8) degree; -} - -s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode) -{ - u16 vbatsenseval; - s32 avg = 0; - bool suspend = 0; - - if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_vbat_temp_sense_setup(pi, VBATSENSE); - } - - vbatsenseval = read_phy_reg(pi, 0x475) & 0x1FF; - - if (vbatsenseval > 255) - avg = (s32) (vbatsenseval - 512); - else - avg = (s32) vbatsenseval; - - avg = (avg * LCN_VBAT_SCALE_NOM + - (LCN_VBAT_SCALE_DEN >> 1)) / LCN_VBAT_SCALE_DEN; - - if (mode == 1) { - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - } - return (s8) avg; -} - -static void wlc_lcnphy_afe_clk_init(struct brcms_phy *pi, u8 mode) -{ - u8 phybw40; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - mod_phy_reg(pi, 0x6d1, (0x1 << 7), (1) << 7); - - if (((mode == AFE_CLK_INIT_MODE_PAPD) && (phybw40 == 0)) || - (mode == AFE_CLK_INIT_MODE_TXRX2X)) - write_phy_reg(pi, 0x6d0, 0x7); - - wlc_lcnphy_toggle_afe_pwdn(pi); -} - -static void wlc_lcnphy_temp_adj(struct brcms_phy *pi) -{ -} - -static void wlc_lcnphy_glacial_timer_based_cal(struct brcms_phy *pi) -{ - bool suspend; - s8 index; - u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_lcnphy_deaf_mode(pi, true); - pi->phy_lastcal = pi->sh->now; - pi->phy_forcecal = false; - index = pi_lcn->lcnphy_current_index; - - wlc_lcnphy_txpwrtbl_iqlo_cal(pi); - - wlc_lcnphy_set_tx_pwr_by_index(pi, index); - wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_pwrctrl); - wlc_lcnphy_deaf_mode(pi, false); - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); - -} - -static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) -{ - bool suspend, full_cal; - const struct lcnphy_rx_iqcomp *rx_iqcomp; - int rx_iqcomp_sz; - u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - s8 index; - struct phytbl_info tab; - s32 a1, b0, b1; - s32 tssi, pwr, maxtargetpwr, mintargetpwr; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - pi->phy_lastcal = pi->sh->now; - pi->phy_forcecal = false; - full_cal = - (pi_lcn->lcnphy_full_cal_channel != - CHSPEC_CHANNEL(pi->radio_chanspec)); - pi_lcn->lcnphy_full_cal_channel = CHSPEC_CHANNEL(pi->radio_chanspec); - index = pi_lcn->lcnphy_current_index; - - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) { - wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); - wlapi_suspend_mac_and_wait(pi->sh->physhim); - } - - wlc_lcnphy_deaf_mode(pi, true); - - wlc_lcnphy_txpwrtbl_iqlo_cal(pi); - - rx_iqcomp = lcnphy_rx_iqcomp_table_rev0; - rx_iqcomp_sz = ARRAY_SIZE(lcnphy_rx_iqcomp_table_rev0); - - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) - wlc_lcnphy_rx_iq_cal(pi, NULL, 0, true, false, 1, 40); - else - wlc_lcnphy_rx_iq_cal(pi, NULL, 0, true, false, 1, 127); - - if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) { - - wlc_lcnphy_idle_tssi_est((struct brcms_phy_pub *) pi); - - b0 = pi->txpa_2g[0]; - b1 = pi->txpa_2g[1]; - a1 = pi->txpa_2g[2]; - maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1); - mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_ptr = &pwr; - tab.tbl_len = 1; - tab.tbl_offset = 0; - for (tssi = 0; tssi < 128; tssi++) { - pwr = wlc_lcnphy_tssi2dbm(tssi, a1, b0, b1); - pwr = (pwr < mintargetpwr) ? mintargetpwr : pwr; - wlc_lcnphy_write_table(pi, &tab); - tab.tbl_offset++; - } - } - - wlc_lcnphy_set_tx_pwr_by_index(pi, index); - wlc_lcnphy_set_tx_pwr_ctrl(pi, SAVE_pwrctrl); - wlc_lcnphy_deaf_mode(pi, false); - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); -} - -void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode) -{ - u16 temp_new; - int temp1, temp2, temp_diff; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - switch (mode) { - case PHY_PERICAL_CHAN: - break; - case PHY_FULLCAL: - wlc_lcnphy_periodic_cal(pi); - break; - case PHY_PERICAL_PHYINIT: - wlc_lcnphy_periodic_cal(pi); - break; - case PHY_PERICAL_WATCHDOG: - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { - temp_new = wlc_lcnphy_tempsense(pi, 0); - temp1 = LCNPHY_TEMPSENSE(temp_new); - temp2 = LCNPHY_TEMPSENSE(pi_lcn->lcnphy_cal_temper); - temp_diff = temp1 - temp2; - if ((pi_lcn->lcnphy_cal_counter > 90) || - (temp_diff > 60) || (temp_diff < -60)) { - wlc_lcnphy_glacial_timer_based_cal(pi); - wlc_2064_vco_cal(pi); - pi_lcn->lcnphy_cal_temper = temp_new; - pi_lcn->lcnphy_cal_counter = 0; - } else - pi_lcn->lcnphy_cal_counter++; - } - break; - case LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL: - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - wlc_lcnphy_tx_power_adjustment( - (struct brcms_phy_pub *) pi); - break; - } -} - -void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr) -{ - s8 cck_offset; - u16 status; - status = (read_phy_reg(pi, 0x4ab)); - if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi) && - (status & (0x1 << 15))) { - *ofdm_pwr = (s8) (((read_phy_reg(pi, 0x4ab) & (0x1ff << 0)) - >> 0) >> 1); - - if (wlc_phy_tpc_isenabled_lcnphy(pi)) - cck_offset = pi->tx_power_offset[TXP_FIRST_CCK]; - else - cck_offset = 0; - - *cck_pwr = *ofdm_pwr + cck_offset; - } else { - *cck_pwr = 0; - *ofdm_pwr = 0; - } -} - -void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi) -{ - return; - -} - -void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi) -{ - s8 index; - u16 index2; - struct brcms_phy *pi = (struct brcms_phy *) ppi; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi) && - SAVE_txpwrctrl) { - index = wlc_lcnphy_tempcompensated_txpwrctrl(pi); - index2 = (u16) (index * 2); - mod_phy_reg(pi, 0x4a9, (0x1ff << 0), (index2) << 0); - - pi_lcn->lcnphy_current_index = - (s8)((read_phy_reg(pi, 0x4a9) & 0xFF) / 2); - } -} - -static void -wlc_lcnphy_load_tx_gain_table(struct brcms_phy *pi, - const struct lcnphy_tx_gain_tbl_entry *gain_table) -{ - u32 j; - struct phytbl_info tab; - u32 val; - u16 pa_gain; - u16 gm_gain; - - if (CHSPEC_IS5G(pi->radio_chanspec)) - pa_gain = 0x70; - else - pa_gain = 0x70; - - if (pi->sh->boardflags & BFL_FEM) - pa_gain = 0x10; - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_len = 1; - tab.tbl_ptr = &val; - - for (j = 0; j < 128; j++) { - gm_gain = gain_table[j].gm; - val = (((u32) pa_gain << 24) | - (gain_table[j].pad << 16) | - (gain_table[j].pga << 8) | gm_gain); - - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_GAIN_OFFSET + j; - wlc_lcnphy_write_table(pi, &tab); - - val = (gain_table[j].dac << 28) | (gain_table[j].bb_mult << 20); - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_IQ_OFFSET + j; - wlc_lcnphy_write_table(pi, &tab); - } -} - -static void wlc_lcnphy_load_rfpower(struct brcms_phy *pi) -{ - struct phytbl_info tab; - u32 val, bbmult, rfgain; - u8 index; - u8 scale_factor = 1; - s16 temp, temp1, temp2, qQ, qQ1, qQ2, shift; - - tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; - tab.tbl_width = 32; - tab.tbl_len = 1; - - for (index = 0; index < 128; index++) { - tab.tbl_ptr = &bbmult; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_IQ_OFFSET + index; - wlc_lcnphy_read_table(pi, &tab); - bbmult = bbmult >> 20; - - tab.tbl_ptr = &rfgain; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_GAIN_OFFSET + index; - wlc_lcnphy_read_table(pi, &tab); - - qm_log10((s32) (bbmult), 0, &temp1, &qQ1); - qm_log10((s32) (1 << 6), 0, &temp2, &qQ2); - - if (qQ1 < qQ2) { - temp2 = qm_shr16(temp2, qQ2 - qQ1); - qQ = qQ1; - } else { - temp1 = qm_shr16(temp1, qQ1 - qQ2); - qQ = qQ2; - } - temp = qm_sub16(temp1, temp2); - - if (qQ >= 4) - shift = qQ - 4; - else - shift = 4 - qQ; - - val = (((index << shift) + (5 * temp) + - (1 << (scale_factor + shift - 3))) >> (scale_factor + - shift - 2)); - - tab.tbl_ptr = &val; - tab.tbl_offset = LCNPHY_TX_PWR_CTRL_PWR_OFFSET + index; - wlc_lcnphy_write_table(pi, &tab); - } -} - -static void wlc_lcnphy_bu_tweaks(struct brcms_phy *pi) -{ - or_phy_reg(pi, 0x805, 0x1); - - mod_phy_reg(pi, 0x42f, (0x7 << 0), (0x3) << 0); - - mod_phy_reg(pi, 0x030, (0x7 << 0), (0x3) << 0); - - write_phy_reg(pi, 0x414, 0x1e10); - write_phy_reg(pi, 0x415, 0x0640); - - mod_phy_reg(pi, 0x4df, (0xff << 8), -9 << 8); - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); - mod_phy_reg(pi, 0x434, (0xff << 0), (0xFD) << 0); - - mod_phy_reg(pi, 0x420, (0xff << 0), (16) << 0); - - if (!(pi->sh->boardrev < 0x1204)) - mod_radio_reg(pi, RADIO_2064_REG09B, 0xF0, 0xF0); - - write_phy_reg(pi, 0x7d6, 0x0902); - mod_phy_reg(pi, 0x429, (0xf << 0), (0x9) << 0); - - mod_phy_reg(pi, 0x429, (0x3f << 4), (0xe) << 4); - - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { - mod_phy_reg(pi, 0x423, (0xff << 0), (0x46) << 0); - - mod_phy_reg(pi, 0x411, (0xff << 0), (1) << 0); - - mod_phy_reg(pi, 0x434, (0xff << 0), (0xFF) << 0); - - mod_phy_reg(pi, 0x656, (0xf << 0), (2) << 0); - - mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); - - mod_radio_reg(pi, RADIO_2064_REG0F7, 0x4, 0x4); - mod_radio_reg(pi, RADIO_2064_REG0F1, 0x3, 0); - mod_radio_reg(pi, RADIO_2064_REG0F2, 0xF8, 0x90); - mod_radio_reg(pi, RADIO_2064_REG0F3, 0x3, 0x2); - mod_radio_reg(pi, RADIO_2064_REG0F3, 0xf0, 0xa0); - - mod_radio_reg(pi, RADIO_2064_REG11F, 0x2, 0x2); - - wlc_lcnphy_clear_tx_power_offsets(pi); - mod_phy_reg(pi, 0x4d0, (0x1ff << 6), (10) << 6); - - } -} - -static void wlc_lcnphy_rcal(struct brcms_phy *pi) -{ - u8 rcal_value; - - and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); - - or_radio_reg(pi, RADIO_2064_REG004, 0x40); - or_radio_reg(pi, RADIO_2064_REG120, 0x10); - - or_radio_reg(pi, RADIO_2064_REG078, 0x80); - or_radio_reg(pi, RADIO_2064_REG129, 0x02); - - or_radio_reg(pi, RADIO_2064_REG057, 0x01); - - or_radio_reg(pi, RADIO_2064_REG05B, 0x02); - mdelay(5); - SPINWAIT(!wlc_radio_2064_rcal_done(pi), 10 * 1000 * 1000); - - if (wlc_radio_2064_rcal_done(pi)) { - rcal_value = (u8) read_radio_reg(pi, RADIO_2064_REG05C); - rcal_value = rcal_value & 0x1f; - } - - and_radio_reg(pi, RADIO_2064_REG05B, 0xfD); - - and_radio_reg(pi, RADIO_2064_REG057, 0xFE); -} - -static void wlc_lcnphy_rc_cal(struct brcms_phy *pi) -{ - u8 dflt_rc_cal_val; - u16 flt_val; - - dflt_rc_cal_val = 7; - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) - dflt_rc_cal_val = 11; - flt_val = - (dflt_rc_cal_val << 10) | (dflt_rc_cal_val << 5) | - (dflt_rc_cal_val); - write_phy_reg(pi, 0x933, flt_val); - write_phy_reg(pi, 0x934, flt_val); - write_phy_reg(pi, 0x935, flt_val); - write_phy_reg(pi, 0x936, flt_val); - write_phy_reg(pi, 0x937, (flt_val & 0x1FF)); - - return; -} - -static void wlc_radio_2064_init(struct brcms_phy *pi) -{ - u32 i; - const struct lcnphy_radio_regs *lcnphyregs = NULL; - - lcnphyregs = lcnphy_radio_regs_2064; - - for (i = 0; lcnphyregs[i].address != 0xffff; i++) - if (CHSPEC_IS5G(pi->radio_chanspec) && lcnphyregs[i].do_init_a) - write_radio_reg(pi, - ((lcnphyregs[i].address & 0x3fff) | - RADIO_DEFAULT_CORE), - (u16) lcnphyregs[i].init_a); - else if (lcnphyregs[i].do_init_g) - write_radio_reg(pi, - ((lcnphyregs[i].address & 0x3fff) | - RADIO_DEFAULT_CORE), - (u16) lcnphyregs[i].init_g); - - write_radio_reg(pi, RADIO_2064_REG032, 0x62); - write_radio_reg(pi, RADIO_2064_REG033, 0x19); - - write_radio_reg(pi, RADIO_2064_REG090, 0x10); - - write_radio_reg(pi, RADIO_2064_REG010, 0x00); - - if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { - - write_radio_reg(pi, RADIO_2064_REG060, 0x7f); - write_radio_reg(pi, RADIO_2064_REG061, 0x72); - write_radio_reg(pi, RADIO_2064_REG062, 0x7f); - } - - write_radio_reg(pi, RADIO_2064_REG01D, 0x02); - write_radio_reg(pi, RADIO_2064_REG01E, 0x06); - - mod_phy_reg(pi, 0x4ea, (0x7 << 0), 0 << 0); - - mod_phy_reg(pi, 0x4ea, (0x7 << 3), 1 << 3); - - mod_phy_reg(pi, 0x4ea, (0x7 << 6), 2 << 6); - - mod_phy_reg(pi, 0x4ea, (0x7 << 9), 3 << 9); - - mod_phy_reg(pi, 0x4ea, (0x7 << 12), 4 << 12); - - write_phy_reg(pi, 0x4ea, 0x4688); - - mod_phy_reg(pi, 0x4eb, (0x7 << 0), 2 << 0); - - mod_phy_reg(pi, 0x4eb, (0x7 << 6), 0 << 6); - - mod_phy_reg(pi, 0x46a, (0xffff << 0), 25 << 0); - - wlc_lcnphy_set_tx_locc(pi, 0); - - wlc_lcnphy_rcal(pi); - - wlc_lcnphy_rc_cal(pi); -} - -static void wlc_lcnphy_radio_init(struct brcms_phy *pi) -{ - wlc_radio_2064_init(pi); -} - -static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) -{ - uint idx; - u8 phybw40; - struct phytbl_info tab; - u32 val; - - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++) - wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]); - - if (pi->sh->boardflags & BFL_FEM_BT) { - tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; - tab.tbl_width = 16; - tab.tbl_ptr = &val; - tab.tbl_len = 1; - val = 100; - tab.tbl_offset = 4; - wlc_lcnphy_write_table(pi, &tab); - } - - tab.tbl_id = LCNPHY_TBL_ID_RFSEQ; - tab.tbl_width = 16; - tab.tbl_ptr = &val; - tab.tbl_len = 1; - - val = 114; - tab.tbl_offset = 0; - wlc_lcnphy_write_table(pi, &tab); - - val = 130; - tab.tbl_offset = 1; - wlc_lcnphy_write_table(pi, &tab); - - val = 6; - tab.tbl_offset = 8; - wlc_lcnphy_write_table(pi, &tab); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->sh->boardflags & BFL_FEM) - wlc_lcnphy_load_tx_gain_table( - pi, - dot11lcnphy_2GHz_extPA_gaintable_rev0); - else - wlc_lcnphy_load_tx_gain_table( - pi, - dot11lcnphy_2GHz_gaintable_rev0); - } - - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) { - const struct phytbl_info *tb; - int l; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - l = dot11lcnphytbl_rx_gain_info_2G_rev2_sz; - if (pi->sh->boardflags & BFL_EXTLNA) - tb = dot11lcnphytbl_rx_gain_info_extlna_2G_rev2; - else - tb = dot11lcnphytbl_rx_gain_info_2G_rev2; - } else { - l = dot11lcnphytbl_rx_gain_info_5G_rev2_sz; - if (pi->sh->boardflags & BFL_EXTLNA_5GHz) - tb = dot11lcnphytbl_rx_gain_info_extlna_5G_rev2; - else - tb = dot11lcnphytbl_rx_gain_info_5G_rev2; - } - - for (idx = 0; idx < l; idx++) - wlc_lcnphy_write_table(pi, &tb[idx]); - } - - if ((pi->sh->boardflags & BFL_FEM) - && !(pi->sh->boardflags & BFL_FEM_BT)) - wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313_epa); - else if (pi->sh->boardflags & BFL_FEM_BT) { - if (pi->sh->boardrev < 0x1250) - wlc_lcnphy_write_table( - pi, - &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa); - else - wlc_lcnphy_write_table( - pi, - &dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250); - } else - wlc_lcnphy_write_table(pi, &dot11lcn_sw_ctrl_tbl_info_4313); - - wlc_lcnphy_load_rfpower(pi); - - wlc_lcnphy_clear_papd_comptable(pi); -} - -static void wlc_lcnphy_rev0_baseband_init(struct brcms_phy *pi) -{ - u16 afectrl1; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - write_radio_reg(pi, RADIO_2064_REG11C, 0x0); - - write_phy_reg(pi, 0x43b, 0x0); - write_phy_reg(pi, 0x43c, 0x0); - write_phy_reg(pi, 0x44c, 0x0); - write_phy_reg(pi, 0x4e6, 0x0); - write_phy_reg(pi, 0x4f9, 0x0); - write_phy_reg(pi, 0x4b0, 0x0); - write_phy_reg(pi, 0x938, 0x0); - write_phy_reg(pi, 0x4b0, 0x0); - write_phy_reg(pi, 0x44e, 0); - - or_phy_reg(pi, 0x567, 0x03); - - or_phy_reg(pi, 0x44a, 0x44); - write_phy_reg(pi, 0x44a, 0x80); - - if (!(pi->sh->boardflags & BFL_FEM)) - wlc_lcnphy_set_tx_pwr_by_index(pi, 52); - - if (0) { - afectrl1 = 0; - afectrl1 = (u16) ((pi_lcn->lcnphy_rssi_vf) | - (pi_lcn->lcnphy_rssi_vc << 4) | - (pi_lcn->lcnphy_rssi_gs << 10)); - write_phy_reg(pi, 0x43e, afectrl1); - } - - mod_phy_reg(pi, 0x634, (0xff << 0), 0xC << 0); - if (pi->sh->boardflags & BFL_FEM) { - mod_phy_reg(pi, 0x634, (0xff << 0), 0xA << 0); - - write_phy_reg(pi, 0x910, 0x1); - } - - mod_phy_reg(pi, 0x448, (0x3 << 8), 1 << 8); - mod_phy_reg(pi, 0x608, (0xff << 0), 0x17 << 0); - mod_phy_reg(pi, 0x604, (0x7ff << 0), 0x3EA << 0); - -} - -static void wlc_lcnphy_rev2_baseband_init(struct brcms_phy *pi) -{ - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x416, (0xff << 0), 80 << 0); - mod_phy_reg(pi, 0x416, (0xff << 8), 80 << 8); - } -} - -static void wlc_lcnphy_agc_temp_init(struct brcms_phy *pi) -{ - s16 temp; - struct phytbl_info tab; - u32 tableBuffer[2]; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - temp = (s16) read_phy_reg(pi, 0x4df); - pi_lcn->lcnphy_ofdmgainidxtableoffset = (temp & (0xff << 0)) >> 0; - - if (pi_lcn->lcnphy_ofdmgainidxtableoffset > 127) - pi_lcn->lcnphy_ofdmgainidxtableoffset -= 256; - - pi_lcn->lcnphy_dsssgainidxtableoffset = (temp & (0xff << 8)) >> 8; - - if (pi_lcn->lcnphy_dsssgainidxtableoffset > 127) - pi_lcn->lcnphy_dsssgainidxtableoffset -= 256; - - tab.tbl_ptr = tableBuffer; - tab.tbl_len = 2; - tab.tbl_id = 17; - tab.tbl_offset = 59; - tab.tbl_width = 32; - wlc_lcnphy_read_table(pi, &tab); - - if (tableBuffer[0] > 63) - tableBuffer[0] -= 128; - pi_lcn->lcnphy_tr_R_gain_val = tableBuffer[0]; - - if (tableBuffer[1] > 63) - tableBuffer[1] -= 128; - pi_lcn->lcnphy_tr_T_gain_val = tableBuffer[1]; - - temp = (s16) (read_phy_reg(pi, 0x434) & (0xff << 0)); - if (temp > 127) - temp -= 256; - pi_lcn->lcnphy_input_pwr_offset_db = (s8) temp; - - pi_lcn->lcnphy_Med_Low_Gain_db = - (read_phy_reg(pi, 0x424) & (0xff << 8)) >> 8; - pi_lcn->lcnphy_Very_Low_Gain_db = - (read_phy_reg(pi, 0x425) & (0xff << 0)) >> 0; - - tab.tbl_ptr = tableBuffer; - tab.tbl_len = 2; - tab.tbl_id = LCNPHY_TBL_ID_GAIN_IDX; - tab.tbl_offset = 28; - tab.tbl_width = 32; - wlc_lcnphy_read_table(pi, &tab); - - pi_lcn->lcnphy_gain_idx_14_lowword = tableBuffer[0]; - pi_lcn->lcnphy_gain_idx_14_hiword = tableBuffer[1]; - -} - -static void wlc_lcnphy_baseband_init(struct brcms_phy *pi) -{ - - wlc_lcnphy_tbl_init(pi); - wlc_lcnphy_rev0_baseband_init(pi); - if (LCNREV_IS(pi->pubpi.phy_rev, 2)) - wlc_lcnphy_rev2_baseband_init(pi); - wlc_lcnphy_bu_tweaks(pi); -} - -void wlc_phy_init_lcnphy(struct brcms_phy *pi) -{ - u8 phybw40; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - phybw40 = CHSPEC_IS40(pi->radio_chanspec); - - pi_lcn->lcnphy_cal_counter = 0; - pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense; - - or_phy_reg(pi, 0x44a, 0x80); - and_phy_reg(pi, 0x44a, 0x7f); - - wlc_lcnphy_afe_clk_init(pi, AFE_CLK_INIT_MODE_TXRX2X); - - write_phy_reg(pi, 0x60a, 160); - - write_phy_reg(pi, 0x46a, 25); - - wlc_lcnphy_baseband_init(pi); - - wlc_lcnphy_radio_init(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_lcnphy_tx_pwr_ctrl_init((struct brcms_phy_pub *) pi); - - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); - - si_pmu_regcontrol(pi->sh->sih, 0, 0xf, 0x9); - - si_pmu_chipcontrol(pi->sh->sih, 0, 0xffffffff, 0x03CDDDDD); - - if ((pi->sh->boardflags & BFL_FEM) - && wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - wlc_lcnphy_set_tx_pwr_by_index(pi, FIXED_TXPWR); - - wlc_lcnphy_agc_temp_init(pi); - - wlc_lcnphy_temp_adj(pi); - - mod_phy_reg(pi, 0x448, (0x1 << 14), (1) << 14); - - udelay(100); - mod_phy_reg(pi, 0x448, (0x1 << 14), (0) << 14); - - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_HW); - pi_lcn->lcnphy_noise_samples = LCNPHY_NOISE_SAMPLES_DEFAULT; - wlc_lcnphy_calib_modes(pi, PHY_PERICAL_PHYINIT); -} - -static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) -{ - s8 txpwr = 0; - int i; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - struct phy_shim_info *shim = pi->sh->physhim; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - u16 cckpo = 0; - u32 offset_ofdm, offset_mcs; - - pi_lcn->lcnphy_tr_isolation_mid = - (u8)wlapi_getintvar(shim, BRCMS_SROM_TRISO2G); - - pi_lcn->lcnphy_rx_power_offset = - (u8)wlapi_getintvar(shim, BRCMS_SROM_RXPO2G); - - pi->txpa_2g[0] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B0); - pi->txpa_2g[1] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B1); - pi->txpa_2g[2] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B2); - - pi_lcn->lcnphy_rssi_vf = - (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMF2G); - pi_lcn->lcnphy_rssi_vc = - (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMC2G); - pi_lcn->lcnphy_rssi_gs = - (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISAV2G); - - pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf; - pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc; - pi_lcn->lcnphy_rssi_gs_lowtemp = pi_lcn->lcnphy_rssi_gs; - - pi_lcn->lcnphy_rssi_vf_hightemp = pi_lcn->lcnphy_rssi_vf; - pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc; - pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs; - - txpwr = (s8)wlapi_getintvar(shim, BRCMS_SROM_MAXP2GA0); - pi->tx_srom_max_2g = txpwr; - - for (i = 0; i < PWRTBL_NUM_COEFF; i++) { - pi->txpa_2g_low_temp[i] = pi->txpa_2g[i]; - pi->txpa_2g_high_temp[i] = pi->txpa_2g[i]; - } - - cckpo = (u16)wlapi_getintvar(shim, BRCMS_SROM_CCK2GPO); - offset_ofdm = (u32)wlapi_getintvar(shim, BRCMS_SROM_OFDM2GPO); - if (cckpo) { - uint max_pwr_chan = txpwr; - - for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) { - pi->tx_srom_max_rate_2g[i] = - max_pwr_chan - ((cckpo & 0xf) * 2); - cckpo >>= 4; - } - - for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { - pi->tx_srom_max_rate_2g[i] = - max_pwr_chan - - ((offset_ofdm & 0xf) * 2); - offset_ofdm >>= 4; - } - } else { - u8 opo = 0; - - opo = (u8)wlapi_getintvar(shim, BRCMS_SROM_OPO); - - for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) - pi->tx_srom_max_rate_2g[i] = txpwr; - - for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) { - pi->tx_srom_max_rate_2g[i] = txpwr - - ((offset_ofdm & 0xf) * 2); - offset_ofdm >>= 4; - } - offset_mcs = - wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO1) << 16; - offset_mcs |= - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO0); - pi_lcn->lcnphy_mcs20_po = offset_mcs; - for (i = TXP_FIRST_SISO_MCS_20; - i <= TXP_LAST_SISO_MCS_20; i++) { - pi->tx_srom_max_rate_2g[i] = - txpwr - ((offset_mcs & 0xf) * 2); - offset_mcs >>= 4; - } - } - - pi_lcn->lcnphy_rawtempsense = - (u16)wlapi_getintvar(shim, BRCMS_SROM_RAWTEMPSENSE); - pi_lcn->lcnphy_measPower = - (u8)wlapi_getintvar(shim, BRCMS_SROM_MEASPOWER); - pi_lcn->lcnphy_tempsense_slope = - (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_SLOPE); - pi_lcn->lcnphy_hw_iqcal_en = - (bool)wlapi_getintvar(shim, BRCMS_SROM_HW_IQCAL_EN); - pi_lcn->lcnphy_iqcal_swp_dis = - (bool)wlapi_getintvar(shim, BRCMS_SROM_IQCAL_SWP_DIS); - pi_lcn->lcnphy_tempcorrx = - (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPCORRX); - pi_lcn->lcnphy_tempsense_option = - (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_OPTION); - pi_lcn->lcnphy_freqoffset_corr = - (u8)wlapi_getintvar(shim, BRCMS_SROM_FREQOFFSET_CORR); - if ((u8)wlapi_getintvar(shim, BRCMS_SROM_AA2G) > 1) - wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, - (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G)); - } - pi_lcn->lcnphy_cck_dig_filt_type = -1; - - return true; -} - -void wlc_2064_vco_cal(struct brcms_phy *pi) -{ - u8 calnrst; - - mod_radio_reg(pi, RADIO_2064_REG057, 1 << 3, 1 << 3); - calnrst = (u8) read_radio_reg(pi, RADIO_2064_REG056) & 0xf8; - write_radio_reg(pi, RADIO_2064_REG056, calnrst); - udelay(1); - write_radio_reg(pi, RADIO_2064_REG056, calnrst | 0x03); - udelay(1); - write_radio_reg(pi, RADIO_2064_REG056, calnrst | 0x07); - udelay(300); - mod_radio_reg(pi, RADIO_2064_REG057, 1 << 3, 0); -} - -bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi) -{ - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) - return 0; - else - return (LCNPHY_TX_PWR_CTRL_HW == - wlc_lcnphy_get_tx_pwr_ctrl((pi))); -} - -void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi) -{ - u16 pwr_ctrl; - if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi)) { - wlc_lcnphy_calib_modes(pi, LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL); - } else if (wlc_lcnphy_tssi_based_pwr_ctrl_enabled(pi)) { - pwr_ctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); - wlc_lcnphy_txpower_recalc_target(pi); - wlc_lcnphy_set_tx_pwr_ctrl(pi, pwr_ctrl); - } -} - -void wlc_phy_detach_lcnphy(struct brcms_phy *pi) -{ - kfree(pi->u.pi_lcnphy); -} - -bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) -{ - struct brcms_phy_lcnphy *pi_lcn; - - pi->u.pi_lcnphy = kzalloc(sizeof(struct brcms_phy_lcnphy), GFP_ATOMIC); - if (pi->u.pi_lcnphy == NULL) - return false; - - pi_lcn = pi->u.pi_lcnphy; - - if (0 == (pi->sh->boardflags & BFL_NOPA)) { - pi->hwpwrctrl = true; - pi->hwpwrctrl_capable = true; - } - - pi->xtalfreq = si_pmu_alp_clock(pi->sh->sih); - pi_lcn->lcnphy_papd_rxGnCtrl_init = 0; - - pi->pi_fptr.init = wlc_phy_init_lcnphy; - pi->pi_fptr.calinit = wlc_phy_cal_init_lcnphy; - pi->pi_fptr.chanset = wlc_phy_chanspec_set_lcnphy; - pi->pi_fptr.txpwrrecalc = wlc_phy_txpower_recalc_target_lcnphy; - pi->pi_fptr.txiqccget = wlc_lcnphy_get_tx_iqcc; - pi->pi_fptr.txiqccset = wlc_lcnphy_set_tx_iqcc; - pi->pi_fptr.txloccget = wlc_lcnphy_get_tx_locc; - pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft; - pi->pi_fptr.detach = wlc_phy_detach_lcnphy; - - if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) - return false; - - if ((pi->sh->boardflags & BFL_FEM) && - (LCNREV_IS(pi->pubpi.phy_rev, 1))) { - if (pi_lcn->lcnphy_tempsense_option == 3) { - pi->hwpwrctrl = true; - pi->hwpwrctrl_capable = true; - pi->temppwrctrl_capable = false; - } else { - pi->hwpwrctrl = false; - pi->hwpwrctrl_capable = false; - pi->temppwrctrl_capable = true; - } - } - - return true; -} - -static void wlc_lcnphy_set_rx_gain(struct brcms_phy *pi, u32 gain) -{ - u16 trsw, ext_lna, lna1, lna2, tia, biq0, biq1, gain0_15, gain16_19; - - trsw = (gain & ((u32) 1 << 28)) ? 0 : 1; - ext_lna = (u16) (gain >> 29) & 0x01; - lna1 = (u16) (gain >> 0) & 0x0f; - lna2 = (u16) (gain >> 4) & 0x0f; - tia = (u16) (gain >> 8) & 0xf; - biq0 = (u16) (gain >> 12) & 0xf; - biq1 = (u16) (gain >> 16) & 0xf; - - gain0_15 = (u16) ((lna1 & 0x3) | ((lna1 & 0x3) << 2) | - ((lna2 & 0x3) << 4) | ((lna2 & 0x3) << 6) | - ((tia & 0xf) << 8) | ((biq0 & 0xf) << 12)); - gain16_19 = biq1; - - mod_phy_reg(pi, 0x44d, (0x1 << 0), trsw << 0); - mod_phy_reg(pi, 0x4b1, (0x1 << 9), ext_lna << 9); - mod_phy_reg(pi, 0x4b1, (0x1 << 10), ext_lna << 10); - mod_phy_reg(pi, 0x4b6, (0xffff << 0), gain0_15 << 0); - mod_phy_reg(pi, 0x4b7, (0xf << 0), gain16_19 << 0); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x4b1, (0x3 << 11), lna1 << 11); - mod_phy_reg(pi, 0x4e6, (0x3 << 3), lna1 << 3); - } - wlc_lcnphy_rx_gain_override_enable(pi, true); -} - -static u32 wlc_lcnphy_get_receive_power(struct brcms_phy *pi, s32 *gain_index) -{ - u32 received_power = 0; - s32 max_index = 0; - u32 gain_code = 0; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - max_index = 36; - if (*gain_index >= 0) - gain_code = lcnphy_23bitgaincode_table[*gain_index]; - - if (-1 == *gain_index) { - *gain_index = 0; - while ((*gain_index <= (s32) max_index) - && (received_power < 700)) { - wlc_lcnphy_set_rx_gain(pi, - lcnphy_23bitgaincode_table - [*gain_index]); - received_power = - wlc_lcnphy_measure_digital_power( - pi, - pi_lcn-> - lcnphy_noise_samples); - (*gain_index)++; - } - (*gain_index)--; - } else { - wlc_lcnphy_set_rx_gain(pi, gain_code); - received_power = - wlc_lcnphy_measure_digital_power(pi, - pi_lcn-> - lcnphy_noise_samples); - } - - return received_power; -} - -s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index) -{ - s32 gain = 0; - s32 nominal_power_db; - s32 log_val, gain_mismatch, desired_gain, input_power_offset_db, - input_power_db; - s32 received_power, temperature; - u32 power; - u32 msb1, msb2, val1, val2, diff1, diff2; - uint freq; - struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - - received_power = wlc_lcnphy_get_receive_power(pi, &gain_index); - - gain = lcnphy_gain_table[gain_index]; - - nominal_power_db = read_phy_reg(pi, 0x425) >> 8; - - power = (received_power * 16); - msb1 = ffs(power) - 1; - msb2 = msb1 + 1; - val1 = 1 << msb1; - val2 = 1 << msb2; - diff1 = (power - val1); - diff2 = (val2 - power); - if (diff1 < diff2) - log_val = msb1; - else - log_val = msb2; - - log_val = log_val * 3; - - gain_mismatch = (nominal_power_db / 2) - (log_val); - - desired_gain = gain + gain_mismatch; - - input_power_offset_db = read_phy_reg(pi, 0x434) & 0xFF; - - if (input_power_offset_db > 127) - input_power_offset_db -= 256; - - input_power_db = input_power_offset_db - desired_gain; - - input_power_db = - input_power_db + lcnphy_gain_index_offset_for_rssi[gain_index]; - - freq = wlc_phy_channel2freq(CHSPEC_CHANNEL(pi->radio_chanspec)); - if ((freq > 2427) && (freq <= 2467)) - input_power_db = input_power_db - 1; - - temperature = pi_lcn->lcnphy_lastsensed_temperature; - - if ((temperature - 15) < -30) - input_power_db = - input_power_db + - (((temperature - 10 - 25) * 286) >> 12) - - 7; - else if ((temperature - 15) < 4) - input_power_db = - input_power_db + - (((temperature - 10 - 25) * 286) >> 12) - - 3; - else - input_power_db = input_power_db + - (((temperature - 10 - 25) * 286) >> 12); - - wlc_lcnphy_rx_gain_override_enable(pi, 0); - - return input_power_db; -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.h deleted file mode 100644 index f4a8ab09da4..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_PHY_LCN_H_ -#define _BRCM_PHY_LCN_H_ - -#include - -struct brcms_phy_lcnphy { - int lcnphy_txrf_sp_9_override; - u8 lcnphy_full_cal_channel; - u8 lcnphy_cal_counter; - u16 lcnphy_cal_temper; - bool lcnphy_recal; - - u8 lcnphy_rc_cap; - u32 lcnphy_mcs20_po; - - u8 lcnphy_tr_isolation_mid; - u8 lcnphy_tr_isolation_low; - u8 lcnphy_tr_isolation_hi; - - u8 lcnphy_bx_arch; - u8 lcnphy_rx_power_offset; - u8 lcnphy_rssi_vf; - u8 lcnphy_rssi_vc; - u8 lcnphy_rssi_gs; - u8 lcnphy_tssi_val; - u8 lcnphy_rssi_vf_lowtemp; - u8 lcnphy_rssi_vc_lowtemp; - u8 lcnphy_rssi_gs_lowtemp; - - u8 lcnphy_rssi_vf_hightemp; - u8 lcnphy_rssi_vc_hightemp; - u8 lcnphy_rssi_gs_hightemp; - - s16 lcnphy_pa0b0; - s16 lcnphy_pa0b1; - s16 lcnphy_pa0b2; - - u16 lcnphy_rawtempsense; - u8 lcnphy_measPower; - u8 lcnphy_tempsense_slope; - u8 lcnphy_freqoffset_corr; - u8 lcnphy_tempsense_option; - u8 lcnphy_tempcorrx; - bool lcnphy_iqcal_swp_dis; - bool lcnphy_hw_iqcal_en; - uint lcnphy_bandedge_corr; - bool lcnphy_spurmod; - u16 lcnphy_tssi_tx_cnt; - u16 lcnphy_tssi_idx; - u16 lcnphy_tssi_npt; - - u16 lcnphy_target_tx_freq; - s8 lcnphy_tx_power_idx_override; - u16 lcnphy_noise_samples; - - u32 lcnphy_papdRxGnIdx; - u32 lcnphy_papd_rxGnCtrl_init; - - u32 lcnphy_gain_idx_14_lowword; - u32 lcnphy_gain_idx_14_hiword; - u32 lcnphy_gain_idx_27_lowword; - u32 lcnphy_gain_idx_27_hiword; - s16 lcnphy_ofdmgainidxtableoffset; - s16 lcnphy_dsssgainidxtableoffset; - u32 lcnphy_tr_R_gain_val; - u32 lcnphy_tr_T_gain_val; - s8 lcnphy_input_pwr_offset_db; - u16 lcnphy_Med_Low_Gain_db; - u16 lcnphy_Very_Low_Gain_db; - s8 lcnphy_lastsensed_temperature; - s8 lcnphy_pkteng_rssi_slope; - u8 lcnphy_saved_tx_user_target[TXP_NUM_RATES]; - u8 lcnphy_volt_winner; - u8 lcnphy_volt_low; - u8 lcnphy_54_48_36_24mbps_backoff; - u8 lcnphy_11n_backoff; - u8 lcnphy_lowerofdm; - u8 lcnphy_cck; - u8 lcnphy_psat_2pt3_detected; - s32 lcnphy_lowest_Re_div_Im; - s8 lcnphy_final_papd_cal_idx; - u16 lcnphy_extstxctrl4; - u16 lcnphy_extstxctrl0; - u16 lcnphy_extstxctrl1; - s16 lcnphy_cck_dig_filt_type; - s16 lcnphy_ofdm_dig_filt_type; - struct lcnphy_cal_results lcnphy_cal_results; - - u8 lcnphy_psat_pwr; - u8 lcnphy_psat_indx; - s32 lcnphy_min_phase; - u8 lcnphy_final_idx; - u8 lcnphy_start_idx; - u8 lcnphy_current_index; - u16 lcnphy_logen_buf_1; - u16 lcnphy_local_ovr_2; - u16 lcnphy_local_oval_6; - u16 lcnphy_local_oval_5; - u16 lcnphy_logen_mixer_1; - - u8 lcnphy_aci_stat; - uint lcnphy_aci_start_time; - s8 lcnphy_tx_power_offset[TXP_NUM_RATES]; -}; -#endif /* _BRCM_PHY_LCN_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c deleted file mode 100644 index cd19c2f7a34..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +++ /dev/null @@ -1,28876 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "phy_int.h" -#include "phy_hal.h" -#include "phy_radio.h" -#include "phyreg_n.h" -#include "phytbl_n.h" - -#define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ - ((core == PHY_CORE_0) ? \ - radio_type##_##jspace##0 : \ - radio_type##_##jspace##1)) - -#define WRITE_RADIO_REG2(pi, radio_type, jspace, core, reg_name, value) \ - write_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ - ((core == PHY_CORE_0) ? \ - radio_type##_##jspace##0 : \ - radio_type##_##jspace##1), value) - -#define WRITE_RADIO_SYN(pi, radio_type, reg_name, value) \ - write_radio_reg(pi, radio_type##_##SYN##_##reg_name, value) - -#define READ_RADIO_REG3(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, ((core == PHY_CORE_0) ? \ - radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name)) - -#define WRITE_RADIO_REG3(pi, radio_type, jspace, core, reg_name, value) \ - write_radio_reg(pi, ((core == PHY_CORE_0) ? \ - radio_type##_##jspace##0##_##reg_name : \ - radio_type##_##jspace##1##_##reg_name), \ - value) - -#define READ_RADIO_REG4(pi, radio_type, jspace, core, reg_name) \ - read_radio_reg(pi, ((core == PHY_CORE_0) ? \ - radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1)) - -#define WRITE_RADIO_REG4(pi, radio_type, jspace, core, reg_name, value) \ - write_radio_reg(pi, ((core == PHY_CORE_0) ? \ - radio_type##_##reg_name##_##jspace##0 : \ - radio_type##_##reg_name##_##jspace##1), \ - value) - -#define NPHY_ACI_MAX_UNDETECT_WINDOW_SZ 40 -#define NPHY_ACI_CHANNEL_DELTA 5 -#define NPHY_ACI_CHANNEL_SKIP 4 -#define NPHY_ACI_40MHZ_CHANNEL_DELTA 6 -#define NPHY_ACI_40MHZ_CHANNEL_SKIP 5 -#define NPHY_ACI_40MHZ_CHANNEL_DELTA_GE_REV3 6 -#define NPHY_ACI_40MHZ_CHANNEL_SKIP_GE_REV3 5 -#define NPHY_ACI_CHANNEL_DELTA_GE_REV3 4 -#define NPHY_ACI_CHANNEL_SKIP_GE_REV3 3 - -#define NPHY_NOISE_NOASSOC_GLITCH_TH_UP 2 - -#define NPHY_NOISE_NOASSOC_GLITCH_TH_DN 8 - -#define NPHY_NOISE_ASSOC_GLITCH_TH_UP 2 - -#define NPHY_NOISE_ASSOC_GLITCH_TH_DN 8 - -#define NPHY_NOISE_ASSOC_ACI_GLITCH_TH_UP 2 - -#define NPHY_NOISE_ASSOC_ACI_GLITCH_TH_DN 8 - -#define NPHY_NOISE_NOASSOC_ENTER_TH 400 - -#define NPHY_NOISE_ASSOC_ENTER_TH 400 - -#define NPHY_NOISE_ASSOC_RX_GLITCH_BADPLCP_ENTER_TH 400 - -#define NPHY_NOISE_CRSMINPWR_ARRAY_MAX_INDEX 44 -#define NPHY_NOISE_CRSMINPWR_ARRAY_MAX_INDEX_REV_7 56 - -#define NPHY_NOISE_NOASSOC_CRSIDX_INCR 16 - -#define NPHY_NOISE_ASSOC_CRSIDX_INCR 8 - -#define NPHY_IS_SROM_REINTERPRET NREV_GE(pi->pubpi.phy_rev, 5) - -#define NPHY_RSSICAL_MAXREAD 31 - -#define NPHY_RSSICAL_NPOLL 8 -#define NPHY_RSSICAL_MAXD (1<<20) -#define NPHY_MIN_RXIQ_PWR 2 - -#define NPHY_RSSICAL_W1_TARGET 25 -#define NPHY_RSSICAL_W2_TARGET NPHY_RSSICAL_W1_TARGET -#define NPHY_RSSICAL_NB_TARGET 0 - -#define NPHY_RSSICAL_W1_TARGET_REV3 29 -#define NPHY_RSSICAL_W2_TARGET_REV3 NPHY_RSSICAL_W1_TARGET_REV3 - -#define NPHY_CALSANITY_RSSI_NB_MAX_POS 9 -#define NPHY_CALSANITY_RSSI_NB_MAX_NEG -9 -#define NPHY_CALSANITY_RSSI_W1_MAX_POS 12 -#define NPHY_CALSANITY_RSSI_W1_MAX_NEG (NPHY_RSSICAL_W1_TARGET - \ - NPHY_RSSICAL_MAXREAD) -#define NPHY_CALSANITY_RSSI_W2_MAX_POS NPHY_CALSANITY_RSSI_W1_MAX_POS -#define NPHY_CALSANITY_RSSI_W2_MAX_NEG (NPHY_RSSICAL_W2_TARGET - \ - NPHY_RSSICAL_MAXREAD) -#define NPHY_RSSI_SXT(x) ((s8) (-((x) & 0x20) + ((x) & 0x1f))) -#define NPHY_RSSI_NB_VIOL(x) (((x) > NPHY_CALSANITY_RSSI_NB_MAX_POS) || \ - ((x) < NPHY_CALSANITY_RSSI_NB_MAX_NEG)) -#define NPHY_RSSI_W1_VIOL(x) (((x) > NPHY_CALSANITY_RSSI_W1_MAX_POS) || \ - ((x) < NPHY_CALSANITY_RSSI_W1_MAX_NEG)) -#define NPHY_RSSI_W2_VIOL(x) (((x) > NPHY_CALSANITY_RSSI_W2_MAX_POS) || \ - ((x) < NPHY_CALSANITY_RSSI_W2_MAX_NEG)) - -#define NPHY_IQCAL_NUMGAINS 9 -#define NPHY_N_GCTL 0x66 - -#define NPHY_PAPD_EPS_TBL_SIZE 64 -#define NPHY_PAPD_SCL_TBL_SIZE 64 -#define NPHY_NUM_DIG_FILT_COEFFS 15 - -#define NPHY_PAPD_COMP_OFF 0 -#define NPHY_PAPD_COMP_ON 1 - -#define NPHY_SROM_TEMPSHIFT 32 -#define NPHY_SROM_MAXTEMPOFFSET 16 -#define NPHY_SROM_MINTEMPOFFSET -16 - -#define NPHY_CAL_MAXTEMPDELTA 64 - -#define NPHY_NOISEVAR_TBLLEN40 256 -#define NPHY_NOISEVAR_TBLLEN20 128 - -#define NPHY_ANARXLPFBW_REDUCTIONFACT 7 - -#define NPHY_ADJUSTED_MINCRSPOWER 0x1e - -/* 5357 Chip specific ChipControl register bits */ -#define CCTRL5357_EXTPA (1<<14) /* extPA in ChipControl 1, bit 14 */ -#define CCTRL5357_ANT_MUX_2o3 (1<<15) /* 2o3 in ChipControl 1, bit 15 */ - -#define NPHY_CAL_TSSISAMPS 64 -#define NPHY_TEST_TONE_FREQ_40MHz 4000 -#define NPHY_TEST_TONE_FREQ_20MHz 2500 - -#define MAX_205x_RCAL_WAITLOOPS 10000 - -#define NPHY_RXCAL_TONEAMP 181 -#define NPHY_RXCAL_TONEFREQ_40MHz 4000 -#define NPHY_RXCAL_TONEFREQ_20MHz 2000 - -#define TXFILT_SHAPING_OFDM20 0 -#define TXFILT_SHAPING_OFDM40 1 -#define TXFILT_SHAPING_CCK 2 -#define TXFILT_DEFAULT_OFDM20 3 -#define TXFILT_DEFAULT_OFDM40 4 - -struct nphy_iqcal_params { - u16 txlpf; - u16 txgm; - u16 pga; - u16 pad; - u16 ipa; - u16 cal_gain; - u16 ncorr[5]; -}; - -struct nphy_txiqcal_ladder { - u8 percent; - u8 g_env; -}; - -struct nphy_ipa_txcalgains { - struct nphy_txgains gains; - bool useindex; - u8 index; -}; - -struct nphy_papd_restore_state { - u16 fbmix[2]; - u16 vga_master[2]; - u16 intpa_master[2]; - u16 afectrl[2]; - u16 afeoverride[2]; - u16 pwrup[2]; - u16 atten[2]; - u16 mm; -}; - -struct nphy_ipa_txrxgain { - u16 hpvga; - u16 lpf_biq1; - u16 lpf_biq0; - u16 lna2; - u16 lna1; - s8 txpwrindex; -}; - -#define NPHY_IPA_RXCAL_MAXGAININDEX (6 - 1) - -static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { - {0, 0, 0, 0, 0, 100}, - {0, 0, 0, 0, 0, 50}, - {0, 0, 0, 0, 0, -1}, - {0, 0, 0, 3, 0, -1}, - {0, 0, 3, 3, 0, -1}, - {0, 2, 3, 3, 0, -1} -}; - -static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { - {0, 0, 0, 0, 0, 128}, - {0, 0, 0, 0, 0, 70}, - {0, 0, 0, 0, 0, 20}, - {0, 0, 0, 3, 0, 20}, - {0, 0, 3, 3, 0, 20}, - {0, 2, 3, 3, 0, 20} -}; - -static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz_rev7[] = { - {0, 0, 0, 0, 0, 100}, - {0, 0, 0, 0, 0, 50}, - {0, 0, 0, 0, 0, -1}, - {0, 0, 0, 3, 0, -1}, - {0, 0, 3, 3, 0, -1}, - {0, 0, 5, 3, 0, -1} -}; - -static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz_rev7[] = { - {0, 0, 0, 0, 0, 10}, - {0, 0, 0, 1, 0, 10}, - {0, 0, 1, 2, 0, 10}, - {0, 0, 1, 3, 0, 10}, - {0, 0, 4, 3, 0, 10}, - {0, 0, 6, 3, 0, 10} -}; - -enum { - NPHY_RXCAL_GAIN_INIT = 0, - NPHY_RXCAL_GAIN_UP, - NPHY_RXCAL_GAIN_DOWN -}; - -#define wlc_phy_get_papd_nphy(pi) \ - (read_phy_reg((pi), 0x1e7) & \ - ((0x1 << 15) | \ - (0x1 << 14) | \ - (0x1 << 13))) - -static const u16 NPHY_IPA_REV4_txdigi_filtcoeffs[][NPHY_NUM_DIG_FILT_COEFFS] = { - {-377, 137, -407, 208, -1527, 956, 93, 186, 93, - 230, -44, 230, 201, -191, 201}, - {-77, 20, -98, 49, -93, 60, 56, 111, 56, 26, -5, - 26, 34, -32, 34}, - {-360, 164, -376, 164, -1533, 576, 308, -314, 308, - 121, -73, 121, 91, 124, 91}, - {-295, 200, -363, 142, -1391, 826, 151, 301, 151, - 151, 301, 151, 602, -752, 602}, - {-92, 58, -96, 49, -104, 44, 17, 35, 17, - 12, 25, 12, 13, 27, 13}, - {-375, 136, -399, 209, -1479, 949, 130, 260, 130, - 230, -44, 230, 201, -191, 201}, - {0xed9, 0xc8, 0xe95, 0x8e, 0xa91, 0x33a, 0x97, 0x12d, 0x97, - 0x97, 0x12d, 0x97, 0x25a, 0xd10, 0x25a} -}; - -struct chan_info_nphy_2055 { - u16 chan; - u16 freq; - uint unknown; - u8 RF_pll_ref; - u8 RF_rf_pll_mod1; - u8 RF_rf_pll_mod0; - u8 RF_vco_cap_tail; - u8 RF_vco_cal1; - u8 RF_vco_cal2; - u8 RF_pll_lf_c1; - u8 RF_pll_lf_r1; - u8 RF_pll_lf_c2; - u8 RF_lgbuf_cen_buf; - u8 RF_lgen_tune1; - u8 RF_lgen_tune2; - u8 RF_core1_lgbuf_a_tune; - u8 RF_core1_lgbuf_g_tune; - u8 RF_core1_rxrf_reg1; - u8 RF_core1_tx_pga_pad_tn; - u8 RF_core1_tx_mx_bgtrim; - u8 RF_core2_lgbuf_a_tune; - u8 RF_core2_lgbuf_g_tune; - u8 RF_core2_rxrf_reg1; - u8 RF_core2_tx_pga_pad_tn; - u8 RF_core2_tx_mx_bgtrim; - u16 PHY_BW1a; - u16 PHY_BW2; - u16 PHY_BW3; - u16 PHY_BW4; - u16 PHY_BW5; - u16 PHY_BW6; -}; - -struct chan_info_nphy_radio205x { - u16 chan; - u16 freq; - u8 RF_SYN_pll_vcocal1; - u8 RF_SYN_pll_vcocal2; - u8 RF_SYN_pll_refdiv; - u8 RF_SYN_pll_mmd2; - u8 RF_SYN_pll_mmd1; - u8 RF_SYN_pll_loopfilter1; - u8 RF_SYN_pll_loopfilter2; - u8 RF_SYN_pll_loopfilter3; - u8 RF_SYN_pll_loopfilter4; - u8 RF_SYN_pll_loopfilter5; - u8 RF_SYN_reserved_addr27; - u8 RF_SYN_reserved_addr28; - u8 RF_SYN_reserved_addr29; - u8 RF_SYN_logen_VCOBUF1; - u8 RF_SYN_logen_MIXER2; - u8 RF_SYN_logen_BUF3; - u8 RF_SYN_logen_BUF4; - u8 RF_RX0_lnaa_tune; - u8 RF_RX0_lnag_tune; - u8 RF_TX0_intpaa_boost_tune; - u8 RF_TX0_intpag_boost_tune; - u8 RF_TX0_pada_boost_tune; - u8 RF_TX0_padg_boost_tune; - u8 RF_TX0_pgaa_boost_tune; - u8 RF_TX0_pgag_boost_tune; - u8 RF_TX0_mixa_boost_tune; - u8 RF_TX0_mixg_boost_tune; - u8 RF_RX1_lnaa_tune; - u8 RF_RX1_lnag_tune; - u8 RF_TX1_intpaa_boost_tune; - u8 RF_TX1_intpag_boost_tune; - u8 RF_TX1_pada_boost_tune; - u8 RF_TX1_padg_boost_tune; - u8 RF_TX1_pgaa_boost_tune; - u8 RF_TX1_pgag_boost_tune; - u8 RF_TX1_mixa_boost_tune; - u8 RF_TX1_mixg_boost_tune; - u16 PHY_BW1a; - u16 PHY_BW2; - u16 PHY_BW3; - u16 PHY_BW4; - u16 PHY_BW5; - u16 PHY_BW6; -}; - -struct chan_info_nphy_radio2057 { - u16 chan; - u16 freq; - u8 RF_vcocal_countval0; - u8 RF_vcocal_countval1; - u8 RF_rfpll_refmaster_sparextalsize; - u8 RF_rfpll_loopfilter_r1; - u8 RF_rfpll_loopfilter_c2; - u8 RF_rfpll_loopfilter_c1; - u8 RF_cp_kpd_idac; - u8 RF_rfpll_mmd0; - u8 RF_rfpll_mmd1; - u8 RF_vcobuf_tune; - u8 RF_logen_mx2g_tune; - u8 RF_logen_mx5g_tune; - u8 RF_logen_indbuf2g_tune; - u8 RF_logen_indbuf5g_tune; - u8 RF_txmix2g_tune_boost_pu_core0; - u8 RF_pad2g_tune_pus_core0; - u8 RF_pga_boost_tune_core0; - u8 RF_txmix5g_boost_tune_core0; - u8 RF_pad5g_tune_misc_pus_core0; - u8 RF_lna2g_tune_core0; - u8 RF_lna5g_tune_core0; - u8 RF_txmix2g_tune_boost_pu_core1; - u8 RF_pad2g_tune_pus_core1; - u8 RF_pga_boost_tune_core1; - u8 RF_txmix5g_boost_tune_core1; - u8 RF_pad5g_tune_misc_pus_core1; - u8 RF_lna2g_tune_core1; - u8 RF_lna5g_tune_core1; - u16 PHY_BW1a; - u16 PHY_BW2; - u16 PHY_BW3; - u16 PHY_BW4; - u16 PHY_BW5; - u16 PHY_BW6; -}; - -struct chan_info_nphy_radio2057_rev5 { - u16 chan; - u16 freq; - u8 RF_vcocal_countval0; - u8 RF_vcocal_countval1; - u8 RF_rfpll_refmaster_sparextalsize; - u8 RF_rfpll_loopfilter_r1; - u8 RF_rfpll_loopfilter_c2; - u8 RF_rfpll_loopfilter_c1; - u8 RF_cp_kpd_idac; - u8 RF_rfpll_mmd0; - u8 RF_rfpll_mmd1; - u8 RF_vcobuf_tune; - u8 RF_logen_mx2g_tune; - u8 RF_logen_indbuf2g_tune; - u8 RF_txmix2g_tune_boost_pu_core0; - u8 RF_pad2g_tune_pus_core0; - u8 RF_lna2g_tune_core0; - u8 RF_txmix2g_tune_boost_pu_core1; - u8 RF_pad2g_tune_pus_core1; - u8 RF_lna2g_tune_core1; - u16 PHY_BW1a; - u16 PHY_BW2; - u16 PHY_BW3; - u16 PHY_BW4; - u16 PHY_BW5; - u16 PHY_BW6; -}; - -struct nphy_sfo_cfg { - u16 PHY_BW1a; - u16 PHY_BW2; - u16 PHY_BW3; - u16 PHY_BW4; - u16 PHY_BW5; - u16 PHY_BW6; -}; - -static const struct chan_info_nphy_2055 chan_info_nphy_2055[] = { - { - 184, 4920, 3280, 0x71, 0x01, 0xEC, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xFF, 0xFF, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7B4, 0x7B0, 0x7AC, 0x214, 0x215, 0x216}, - { - 186, 4930, 3287, 0x71, 0x01, 0xED, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xFF, 0xFF, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7B8, 0x7B4, 0x7B0, 0x213, 0x214, 0x215}, - { - 188, 4940, 3293, 0x71, 0x01, 0xEE, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xEE, 0xEE, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7BC, 0x7B8, 0x7B4, 0x212, 0x213, 0x214}, - { - 190, 4950, 3300, 0x71, 0x01, 0xEF, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xEE, 0xEE, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7C0, 0x7BC, 0x7B8, 0x211, 0x212, 0x213}, - { - 192, 4960, 3307, 0x71, 0x01, 0xF0, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xEE, 0xEE, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7C4, 0x7C0, 0x7BC, 0x20F, 0x211, 0x212}, - { - 194, 4970, 3313, 0x71, 0x01, 0xF1, 0x0F, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xEE, 0xEE, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7C8, 0x7C4, 0x7C0, 0x20E, 0x20F, 0x211}, - { - 196, 4980, 3320, 0x71, 0x01, 0xF2, 0x0E, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xDD, 0xDD, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7CC, 0x7C8, 0x7C4, 0x20D, 0x20E, 0x20F}, - { - 198, 4990, 3327, 0x71, 0x01, 0xF3, 0x0E, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xDD, 0xDD, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7D0, 0x7CC, 0x7C8, 0x20C, 0x20D, 0x20E}, - { - 200, 5000, 3333, 0x71, 0x01, 0xF4, 0x0E, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xDD, 0xDD, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7D4, 0x7D0, 0x7CC, 0x20B, 0x20C, 0x20D}, - { - 202, 5010, 3340, 0x71, 0x01, 0xF5, 0x0E, 0xFF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xDD, 0xDD, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7D8, 0x7D4, 0x7D0, 0x20A, 0x20B, 0x20C}, - { - 204, 5020, 3347, 0x71, 0x01, 0xF6, 0x0E, 0xF7, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xCC, 0xCC, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7DC, 0x7D8, 0x7D4, 0x209, 0x20A, 0x20B}, - { - 206, 5030, 3353, 0x71, 0x01, 0xF7, 0x0E, 0xF7, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xCC, 0xCC, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7E0, 0x7DC, 0x7D8, 0x208, 0x209, 0x20A}, - { - 208, 5040, 3360, 0x71, 0x01, 0xF8, 0x0D, 0xEF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xCC, 0xCC, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7E4, 0x7E0, 0x7DC, 0x207, 0x208, 0x209}, - { - 210, 5050, 3367, 0x71, 0x01, 0xF9, 0x0D, 0xEF, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xCC, 0xCC, 0xFF, 0x00, 0x0F, 0x0F, 0x8F, 0xFF, 0x00, 0x0F, - 0x0F, 0x8F, 0x7E8, 0x7E4, 0x7E0, 0x206, 0x207, 0x208}, - { - 212, 5060, 3373, 0x71, 0x01, 0xFA, 0x0D, 0xE6, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xBB, 0xBB, 0xFF, 0x00, 0x0E, 0x0F, 0x8E, 0xFF, 0x00, 0x0E, - 0x0F, 0x8E, 0x7EC, 0x7E8, 0x7E4, 0x205, 0x206, 0x207}, - { - 214, 5070, 3380, 0x71, 0x01, 0xFB, 0x0D, 0xE6, 0x01, 0x04, 0x0A, - 0x00, 0x8F, 0xBB, 0xBB, 0xFF, 0x00, 0x0E, 0x0F, 0x8E, 0xFF, 0x00, 0x0E, - 0x0F, 0x8E, 0x7F0, 0x7EC, 0x7E8, 0x204, 0x205, 0x206}, - { - 216, 5080, 3387, 0x71, 0x01, 0xFC, 0x0D, 0xDE, 0x01, 0x04, 0x0A, - 0x00, 0x8E, 0xBB, 0xBB, 0xEE, 0x00, 0x0E, 0x0F, 0x8D, 0xEE, 0x00, 0x0E, - 0x0F, 0x8D, 0x7F4, 0x7F0, 0x7EC, 0x203, 0x204, 0x205}, - { - 218, 5090, 3393, 0x71, 0x01, 0xFD, 0x0D, 0xDE, 0x01, 0x04, 0x0A, - 0x00, 0x8E, 0xBB, 0xBB, 0xEE, 0x00, 0x0E, 0x0F, 0x8D, 0xEE, 0x00, 0x0E, - 0x0F, 0x8D, 0x7F8, 0x7F4, 0x7F0, 0x202, 0x203, 0x204}, - { - 220, 5100, 3400, 0x71, 0x01, 0xFE, 0x0C, 0xD6, 0x01, 0x04, 0x0A, - 0x00, 0x8E, 0xAA, 0xAA, 0xEE, 0x00, 0x0D, 0x0F, 0x8D, 0xEE, 0x00, 0x0D, - 0x0F, 0x8D, 0x7FC, 0x7F8, 0x7F4, 0x201, 0x202, 0x203}, - { - 222, 5110, 3407, 0x71, 0x01, 0xFF, 0x0C, 0xD6, 0x01, 0x04, 0x0A, - 0x00, 0x8E, 0xAA, 0xAA, 0xEE, 0x00, 0x0D, 0x0F, 0x8D, 0xEE, 0x00, 0x0D, - 0x0F, 0x8D, 0x800, 0x7FC, 0x7F8, 0x200, 0x201, 0x202}, - { - 224, 5120, 3413, 0x71, 0x02, 0x00, 0x0C, 0xCE, 0x01, 0x04, 0x0A, - 0x00, 0x8D, 0xAA, 0xAA, 0xDD, 0x00, 0x0D, 0x0F, 0x8C, 0xDD, 0x00, 0x0D, - 0x0F, 0x8C, 0x804, 0x800, 0x7FC, 0x1FF, 0x200, 0x201}, - { - 226, 5130, 3420, 0x71, 0x02, 0x01, 0x0C, 0xCE, 0x01, 0x04, 0x0A, - 0x00, 0x8D, 0xAA, 0xAA, 0xDD, 0x00, 0x0D, 0x0F, 0x8C, 0xDD, 0x00, 0x0D, - 0x0F, 0x8C, 0x808, 0x804, 0x800, 0x1FE, 0x1FF, 0x200}, - { - 228, 5140, 3427, 0x71, 0x02, 0x02, 0x0C, 0xC6, 0x01, 0x04, 0x0A, - 0x00, 0x8D, 0x99, 0x99, 0xDD, 0x00, 0x0C, 0x0E, 0x8B, 0xDD, 0x00, 0x0C, - 0x0E, 0x8B, 0x80C, 0x808, 0x804, 0x1FD, 0x1FE, 0x1FF}, - { - 32, 5160, 3440, 0x71, 0x02, 0x04, 0x0B, 0xBE, 0x01, 0x04, 0x0A, - 0x00, 0x8C, 0x99, 0x99, 0xCC, 0x00, 0x0B, 0x0D, 0x8A, 0xCC, 0x00, 0x0B, - 0x0D, 0x8A, 0x814, 0x810, 0x80C, 0x1FB, 0x1FC, 0x1FD}, - { - 34, 5170, 3447, 0x71, 0x02, 0x05, 0x0B, 0xBE, 0x01, 0x04, 0x0A, - 0x00, 0x8C, 0x99, 0x99, 0xCC, 0x00, 0x0B, 0x0D, 0x8A, 0xCC, 0x00, 0x0B, - 0x0D, 0x8A, 0x818, 0x814, 0x810, 0x1FA, 0x1FB, 0x1FC}, - { - 36, 5180, 3453, 0x71, 0x02, 0x06, 0x0B, 0xB6, 0x01, 0x04, 0x0A, - 0x00, 0x8C, 0x88, 0x88, 0xCC, 0x00, 0x0B, 0x0C, 0x89, 0xCC, 0x00, 0x0B, - 0x0C, 0x89, 0x81C, 0x818, 0x814, 0x1F9, 0x1FA, 0x1FB}, - { - 38, 5190, 3460, 0x71, 0x02, 0x07, 0x0B, 0xB6, 0x01, 0x04, 0x0A, - 0x00, 0x8C, 0x88, 0x88, 0xCC, 0x00, 0x0B, 0x0C, 0x89, 0xCC, 0x00, 0x0B, - 0x0C, 0x89, 0x820, 0x81C, 0x818, 0x1F8, 0x1F9, 0x1FA}, - { - 40, 5200, 3467, 0x71, 0x02, 0x08, 0x0B, 0xAF, 0x01, 0x04, 0x0A, - 0x00, 0x8B, 0x88, 0x88, 0xBB, 0x00, 0x0A, 0x0B, 0x89, 0xBB, 0x00, 0x0A, - 0x0B, 0x89, 0x824, 0x820, 0x81C, 0x1F7, 0x1F8, 0x1F9}, - { - 42, 5210, 3473, 0x71, 0x02, 0x09, 0x0B, 0xAF, 0x01, 0x04, 0x0A, - 0x00, 0x8B, 0x88, 0x88, 0xBB, 0x00, 0x0A, 0x0B, 0x89, 0xBB, 0x00, 0x0A, - 0x0B, 0x89, 0x828, 0x824, 0x820, 0x1F6, 0x1F7, 0x1F8}, - { - 44, 5220, 3480, 0x71, 0x02, 0x0A, 0x0A, 0xA7, 0x01, 0x04, 0x0A, - 0x00, 0x8B, 0x77, 0x77, 0xBB, 0x00, 0x09, 0x0A, 0x88, 0xBB, 0x00, 0x09, - 0x0A, 0x88, 0x82C, 0x828, 0x824, 0x1F5, 0x1F6, 0x1F7}, - { - 46, 5230, 3487, 0x71, 0x02, 0x0B, 0x0A, 0xA7, 0x01, 0x04, 0x0A, - 0x00, 0x8B, 0x77, 0x77, 0xBB, 0x00, 0x09, 0x0A, 0x88, 0xBB, 0x00, 0x09, - 0x0A, 0x88, 0x830, 0x82C, 0x828, 0x1F4, 0x1F5, 0x1F6}, - { - 48, 5240, 3493, 0x71, 0x02, 0x0C, 0x0A, 0xA0, 0x01, 0x04, 0x0A, - 0x00, 0x8A, 0x77, 0x77, 0xAA, 0x00, 0x09, 0x0A, 0x87, 0xAA, 0x00, 0x09, - 0x0A, 0x87, 0x834, 0x830, 0x82C, 0x1F3, 0x1F4, 0x1F5}, - { - 50, 5250, 3500, 0x71, 0x02, 0x0D, 0x0A, 0xA0, 0x01, 0x04, 0x0A, - 0x00, 0x8A, 0x77, 0x77, 0xAA, 0x00, 0x09, 0x0A, 0x87, 0xAA, 0x00, 0x09, - 0x0A, 0x87, 0x838, 0x834, 0x830, 0x1F2, 0x1F3, 0x1F4}, - { - 52, 5260, 3507, 0x71, 0x02, 0x0E, 0x0A, 0x98, 0x01, 0x04, 0x0A, - 0x00, 0x8A, 0x66, 0x66, 0xAA, 0x00, 0x08, 0x09, 0x87, 0xAA, 0x00, 0x08, - 0x09, 0x87, 0x83C, 0x838, 0x834, 0x1F1, 0x1F2, 0x1F3}, - { - 54, 5270, 3513, 0x71, 0x02, 0x0F, 0x0A, 0x98, 0x01, 0x04, 0x0A, - 0x00, 0x8A, 0x66, 0x66, 0xAA, 0x00, 0x08, 0x09, 0x87, 0xAA, 0x00, 0x08, - 0x09, 0x87, 0x840, 0x83C, 0x838, 0x1F0, 0x1F1, 0x1F2}, - { - 56, 5280, 3520, 0x71, 0x02, 0x10, 0x09, 0x91, 0x01, 0x04, 0x0A, - 0x00, 0x89, 0x66, 0x66, 0x99, 0x00, 0x08, 0x08, 0x86, 0x99, 0x00, 0x08, - 0x08, 0x86, 0x844, 0x840, 0x83C, 0x1F0, 0x1F0, 0x1F1}, - { - 58, 5290, 3527, 0x71, 0x02, 0x11, 0x09, 0x91, 0x01, 0x04, 0x0A, - 0x00, 0x89, 0x66, 0x66, 0x99, 0x00, 0x08, 0x08, 0x86, 0x99, 0x00, 0x08, - 0x08, 0x86, 0x848, 0x844, 0x840, 0x1EF, 0x1F0, 0x1F0}, - { - 60, 5300, 3533, 0x71, 0x02, 0x12, 0x09, 0x8A, 0x01, 0x04, 0x0A, - 0x00, 0x89, 0x55, 0x55, 0x99, 0x00, 0x08, 0x07, 0x85, 0x99, 0x00, 0x08, - 0x07, 0x85, 0x84C, 0x848, 0x844, 0x1EE, 0x1EF, 0x1F0}, - { - 62, 5310, 3540, 0x71, 0x02, 0x13, 0x09, 0x8A, 0x01, 0x04, 0x0A, - 0x00, 0x89, 0x55, 0x55, 0x99, 0x00, 0x08, 0x07, 0x85, 0x99, 0x00, 0x08, - 0x07, 0x85, 0x850, 0x84C, 0x848, 0x1ED, 0x1EE, 0x1EF}, - { - 64, 5320, 3547, 0x71, 0x02, 0x14, 0x09, 0x83, 0x01, 0x04, 0x0A, - 0x00, 0x88, 0x55, 0x55, 0x88, 0x00, 0x07, 0x07, 0x84, 0x88, 0x00, 0x07, - 0x07, 0x84, 0x854, 0x850, 0x84C, 0x1EC, 0x1ED, 0x1EE}, - { - 66, 5330, 3553, 0x71, 0x02, 0x15, 0x09, 0x83, 0x01, 0x04, 0x0A, - 0x00, 0x88, 0x55, 0x55, 0x88, 0x00, 0x07, 0x07, 0x84, 0x88, 0x00, 0x07, - 0x07, 0x84, 0x858, 0x854, 0x850, 0x1EB, 0x1EC, 0x1ED}, - { - 68, 5340, 3560, 0x71, 0x02, 0x16, 0x08, 0x7C, 0x01, 0x04, 0x0A, - 0x00, 0x88, 0x44, 0x44, 0x88, 0x00, 0x07, 0x06, 0x84, 0x88, 0x00, 0x07, - 0x06, 0x84, 0x85C, 0x858, 0x854, 0x1EA, 0x1EB, 0x1EC}, - { - 70, 5350, 3567, 0x71, 0x02, 0x17, 0x08, 0x7C, 0x01, 0x04, 0x0A, - 0x00, 0x88, 0x44, 0x44, 0x88, 0x00, 0x07, 0x06, 0x84, 0x88, 0x00, 0x07, - 0x06, 0x84, 0x860, 0x85C, 0x858, 0x1E9, 0x1EA, 0x1EB}, - { - 72, 5360, 3573, 0x71, 0x02, 0x18, 0x08, 0x75, 0x01, 0x04, 0x0A, - 0x00, 0x87, 0x44, 0x44, 0x77, 0x00, 0x06, 0x05, 0x83, 0x77, 0x00, 0x06, - 0x05, 0x83, 0x864, 0x860, 0x85C, 0x1E8, 0x1E9, 0x1EA}, - { - 74, 5370, 3580, 0x71, 0x02, 0x19, 0x08, 0x75, 0x01, 0x04, 0x0A, - 0x00, 0x87, 0x44, 0x44, 0x77, 0x00, 0x06, 0x05, 0x83, 0x77, 0x00, 0x06, - 0x05, 0x83, 0x868, 0x864, 0x860, 0x1E7, 0x1E8, 0x1E9}, - { - 76, 5380, 3587, 0x71, 0x02, 0x1A, 0x08, 0x6E, 0x01, 0x04, 0x0A, - 0x00, 0x87, 0x33, 0x33, 0x77, 0x00, 0x06, 0x04, 0x82, 0x77, 0x00, 0x06, - 0x04, 0x82, 0x86C, 0x868, 0x864, 0x1E6, 0x1E7, 0x1E8}, - { - 78, 5390, 3593, 0x71, 0x02, 0x1B, 0x08, 0x6E, 0x01, 0x04, 0x0A, - 0x00, 0x87, 0x33, 0x33, 0x77, 0x00, 0x06, 0x04, 0x82, 0x77, 0x00, 0x06, - 0x04, 0x82, 0x870, 0x86C, 0x868, 0x1E5, 0x1E6, 0x1E7}, - { - 80, 5400, 3600, 0x71, 0x02, 0x1C, 0x07, 0x67, 0x01, 0x04, 0x0A, - 0x00, 0x86, 0x33, 0x33, 0x66, 0x00, 0x05, 0x04, 0x81, 0x66, 0x00, 0x05, - 0x04, 0x81, 0x874, 0x870, 0x86C, 0x1E5, 0x1E5, 0x1E6}, - { - 82, 5410, 3607, 0x71, 0x02, 0x1D, 0x07, 0x67, 0x01, 0x04, 0x0A, - 0x00, 0x86, 0x33, 0x33, 0x66, 0x00, 0x05, 0x04, 0x81, 0x66, 0x00, 0x05, - 0x04, 0x81, 0x878, 0x874, 0x870, 0x1E4, 0x1E5, 0x1E5}, - { - 84, 5420, 3613, 0x71, 0x02, 0x1E, 0x07, 0x61, 0x01, 0x04, 0x0A, - 0x00, 0x86, 0x22, 0x22, 0x66, 0x00, 0x05, 0x03, 0x80, 0x66, 0x00, 0x05, - 0x03, 0x80, 0x87C, 0x878, 0x874, 0x1E3, 0x1E4, 0x1E5}, - { - 86, 5430, 3620, 0x71, 0x02, 0x1F, 0x07, 0x61, 0x01, 0x04, 0x0A, - 0x00, 0x86, 0x22, 0x22, 0x66, 0x00, 0x05, 0x03, 0x80, 0x66, 0x00, 0x05, - 0x03, 0x80, 0x880, 0x87C, 0x878, 0x1E2, 0x1E3, 0x1E4}, - { - 88, 5440, 3627, 0x71, 0x02, 0x20, 0x07, 0x5A, 0x01, 0x04, 0x0A, - 0x00, 0x85, 0x22, 0x22, 0x55, 0x00, 0x04, 0x02, 0x80, 0x55, 0x00, 0x04, - 0x02, 0x80, 0x884, 0x880, 0x87C, 0x1E1, 0x1E2, 0x1E3}, - { - 90, 5450, 3633, 0x71, 0x02, 0x21, 0x07, 0x5A, 0x01, 0x04, 0x0A, - 0x00, 0x85, 0x22, 0x22, 0x55, 0x00, 0x04, 0x02, 0x80, 0x55, 0x00, 0x04, - 0x02, 0x80, 0x888, 0x884, 0x880, 0x1E0, 0x1E1, 0x1E2}, - { - 92, 5460, 3640, 0x71, 0x02, 0x22, 0x06, 0x53, 0x01, 0x04, 0x0A, - 0x00, 0x85, 0x11, 0x11, 0x55, 0x00, 0x04, 0x01, 0x80, 0x55, 0x00, 0x04, - 0x01, 0x80, 0x88C, 0x888, 0x884, 0x1DF, 0x1E0, 0x1E1}, - { - 94, 5470, 3647, 0x71, 0x02, 0x23, 0x06, 0x53, 0x01, 0x04, 0x0A, - 0x00, 0x85, 0x11, 0x11, 0x55, 0x00, 0x04, 0x01, 0x80, 0x55, 0x00, 0x04, - 0x01, 0x80, 0x890, 0x88C, 0x888, 0x1DE, 0x1DF, 0x1E0}, - { - 96, 5480, 3653, 0x71, 0x02, 0x24, 0x06, 0x4D, 0x01, 0x04, 0x0A, - 0x00, 0x84, 0x11, 0x11, 0x44, 0x00, 0x03, 0x00, 0x80, 0x44, 0x00, 0x03, - 0x00, 0x80, 0x894, 0x890, 0x88C, 0x1DD, 0x1DE, 0x1DF}, - { - 98, 5490, 3660, 0x71, 0x02, 0x25, 0x06, 0x4D, 0x01, 0x04, 0x0A, - 0x00, 0x84, 0x11, 0x11, 0x44, 0x00, 0x03, 0x00, 0x80, 0x44, 0x00, 0x03, - 0x00, 0x80, 0x898, 0x894, 0x890, 0x1DD, 0x1DD, 0x1DE}, - { - 100, 5500, 3667, 0x71, 0x02, 0x26, 0x06, 0x47, 0x01, 0x04, 0x0A, - 0x00, 0x84, 0x00, 0x00, 0x44, 0x00, 0x03, 0x00, 0x80, 0x44, 0x00, 0x03, - 0x00, 0x80, 0x89C, 0x898, 0x894, 0x1DC, 0x1DD, 0x1DD}, - { - 102, 5510, 3673, 0x71, 0x02, 0x27, 0x06, 0x47, 0x01, 0x04, 0x0A, - 0x00, 0x84, 0x00, 0x00, 0x44, 0x00, 0x03, 0x00, 0x80, 0x44, 0x00, 0x03, - 0x00, 0x80, 0x8A0, 0x89C, 0x898, 0x1DB, 0x1DC, 0x1DD}, - { - 104, 5520, 3680, 0x71, 0x02, 0x28, 0x05, 0x40, 0x01, 0x04, 0x0A, - 0x00, 0x83, 0x00, 0x00, 0x33, 0x00, 0x02, 0x00, 0x80, 0x33, 0x00, 0x02, - 0x00, 0x80, 0x8A4, 0x8A0, 0x89C, 0x1DA, 0x1DB, 0x1DC}, - { - 106, 5530, 3687, 0x71, 0x02, 0x29, 0x05, 0x40, 0x01, 0x04, 0x0A, - 0x00, 0x83, 0x00, 0x00, 0x33, 0x00, 0x02, 0x00, 0x80, 0x33, 0x00, 0x02, - 0x00, 0x80, 0x8A8, 0x8A4, 0x8A0, 0x1D9, 0x1DA, 0x1DB}, - { - 108, 5540, 3693, 0x71, 0x02, 0x2A, 0x05, 0x3A, 0x01, 0x04, 0x0A, - 0x00, 0x83, 0x00, 0x00, 0x33, 0x00, 0x02, 0x00, 0x80, 0x33, 0x00, 0x02, - 0x00, 0x80, 0x8AC, 0x8A8, 0x8A4, 0x1D8, 0x1D9, 0x1DA}, - { - 110, 5550, 3700, 0x71, 0x02, 0x2B, 0x05, 0x3A, 0x01, 0x04, 0x0A, - 0x00, 0x83, 0x00, 0x00, 0x33, 0x00, 0x02, 0x00, 0x80, 0x33, 0x00, 0x02, - 0x00, 0x80, 0x8B0, 0x8AC, 0x8A8, 0x1D7, 0x1D8, 0x1D9}, - { - 112, 5560, 3707, 0x71, 0x02, 0x2C, 0x05, 0x34, 0x01, 0x04, 0x0A, - 0x00, 0x82, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x80, 0x22, 0x00, 0x01, - 0x00, 0x80, 0x8B4, 0x8B0, 0x8AC, 0x1D7, 0x1D7, 0x1D8}, - { - 114, 5570, 3713, 0x71, 0x02, 0x2D, 0x05, 0x34, 0x01, 0x04, 0x0A, - 0x00, 0x82, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x80, 0x22, 0x00, 0x01, - 0x00, 0x80, 0x8B8, 0x8B4, 0x8B0, 0x1D6, 0x1D7, 0x1D7}, - { - 116, 5580, 3720, 0x71, 0x02, 0x2E, 0x04, 0x2E, 0x01, 0x04, 0x0A, - 0x00, 0x82, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x80, 0x22, 0x00, 0x01, - 0x00, 0x80, 0x8BC, 0x8B8, 0x8B4, 0x1D5, 0x1D6, 0x1D7}, - { - 118, 5590, 3727, 0x71, 0x02, 0x2F, 0x04, 0x2E, 0x01, 0x04, 0x0A, - 0x00, 0x82, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x80, 0x22, 0x00, 0x01, - 0x00, 0x80, 0x8C0, 0x8BC, 0x8B8, 0x1D4, 0x1D5, 0x1D6}, - { - 120, 5600, 3733, 0x71, 0x02, 0x30, 0x04, 0x28, 0x01, 0x04, 0x0A, - 0x00, 0x81, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x80, 0x11, 0x00, 0x01, - 0x00, 0x80, 0x8C4, 0x8C0, 0x8BC, 0x1D3, 0x1D4, 0x1D5}, - { - 122, 5610, 3740, 0x71, 0x02, 0x31, 0x04, 0x28, 0x01, 0x04, 0x0A, - 0x00, 0x81, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x80, 0x11, 0x00, 0x01, - 0x00, 0x80, 0x8C8, 0x8C4, 0x8C0, 0x1D2, 0x1D3, 0x1D4}, - { - 124, 5620, 3747, 0x71, 0x02, 0x32, 0x04, 0x21, 0x01, 0x04, 0x0A, - 0x00, 0x81, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, - 0x00, 0x80, 0x8CC, 0x8C8, 0x8C4, 0x1D2, 0x1D2, 0x1D3}, - { - 126, 5630, 3753, 0x71, 0x02, 0x33, 0x04, 0x21, 0x01, 0x04, 0x0A, - 0x00, 0x81, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, - 0x00, 0x80, 0x8D0, 0x8CC, 0x8C8, 0x1D1, 0x1D2, 0x1D2}, - { - 128, 5640, 3760, 0x71, 0x02, 0x34, 0x03, 0x1C, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8D4, 0x8D0, 0x8CC, 0x1D0, 0x1D1, 0x1D2}, - { - 130, 5650, 3767, 0x71, 0x02, 0x35, 0x03, 0x1C, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8D8, 0x8D4, 0x8D0, 0x1CF, 0x1D0, 0x1D1}, - { - 132, 5660, 3773, 0x71, 0x02, 0x36, 0x03, 0x16, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8DC, 0x8D8, 0x8D4, 0x1CE, 0x1CF, 0x1D0}, - { - 134, 5670, 3780, 0x71, 0x02, 0x37, 0x03, 0x16, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8E0, 0x8DC, 0x8D8, 0x1CE, 0x1CE, 0x1CF}, - { - 136, 5680, 3787, 0x71, 0x02, 0x38, 0x03, 0x10, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8E4, 0x8E0, 0x8DC, 0x1CD, 0x1CE, 0x1CE}, - { - 138, 5690, 3793, 0x71, 0x02, 0x39, 0x03, 0x10, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8E8, 0x8E4, 0x8E0, 0x1CC, 0x1CD, 0x1CE}, - { - 140, 5700, 3800, 0x71, 0x02, 0x3A, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8EC, 0x8E8, 0x8E4, 0x1CB, 0x1CC, 0x1CD}, - { - 142, 5710, 3807, 0x71, 0x02, 0x3B, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8F0, 0x8EC, 0x8E8, 0x1CA, 0x1CB, 0x1CC}, - { - 144, 5720, 3813, 0x71, 0x02, 0x3C, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8F4, 0x8F0, 0x8EC, 0x1C9, 0x1CA, 0x1CB}, - { - 145, 5725, 3817, 0x72, 0x04, 0x79, 0x02, 0x03, 0x01, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8F6, 0x8F2, 0x8EE, 0x1C9, 0x1CA, 0x1CB}, - { - 146, 5730, 3820, 0x71, 0x02, 0x3D, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8F8, 0x8F4, 0x8F0, 0x1C9, 0x1C9, 0x1CA}, - { - 147, 5735, 3823, 0x72, 0x04, 0x7B, 0x02, 0x03, 0x01, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8FA, 0x8F6, 0x8F2, 0x1C8, 0x1C9, 0x1CA}, - { - 148, 5740, 3827, 0x71, 0x02, 0x3E, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8FC, 0x8F8, 0x8F4, 0x1C8, 0x1C9, 0x1C9}, - { - 149, 5745, 3830, 0x72, 0x04, 0x7D, 0x02, 0xFE, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x8FE, 0x8FA, 0x8F6, 0x1C8, 0x1C8, 0x1C9}, - { - 150, 5750, 3833, 0x71, 0x02, 0x3F, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x900, 0x8FC, 0x8F8, 0x1C7, 0x1C8, 0x1C9}, - { - 151, 5755, 3837, 0x72, 0x04, 0x7F, 0x02, 0xFE, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x902, 0x8FE, 0x8FA, 0x1C7, 0x1C8, 0x1C8}, - { - 152, 5760, 3840, 0x71, 0x02, 0x40, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x904, 0x900, 0x8FC, 0x1C6, 0x1C7, 0x1C8}, - { - 153, 5765, 3843, 0x72, 0x04, 0x81, 0x02, 0xF8, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x906, 0x902, 0x8FE, 0x1C6, 0x1C7, 0x1C8}, - { - 154, 5770, 3847, 0x71, 0x02, 0x41, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x908, 0x904, 0x900, 0x1C6, 0x1C6, 0x1C7}, - { - 155, 5775, 3850, 0x72, 0x04, 0x83, 0x02, 0xF8, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x90A, 0x906, 0x902, 0x1C5, 0x1C6, 0x1C7}, - { - 156, 5780, 3853, 0x71, 0x02, 0x42, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x90C, 0x908, 0x904, 0x1C5, 0x1C6, 0x1C6}, - { - 157, 5785, 3857, 0x72, 0x04, 0x85, 0x02, 0xF2, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x90E, 0x90A, 0x906, 0x1C4, 0x1C5, 0x1C6}, - { - 158, 5790, 3860, 0x71, 0x02, 0x43, 0x02, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x910, 0x90C, 0x908, 0x1C4, 0x1C5, 0x1C6}, - { - 159, 5795, 3863, 0x72, 0x04, 0x87, 0x02, 0xF2, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x912, 0x90E, 0x90A, 0x1C4, 0x1C4, 0x1C5}, - { - 160, 5800, 3867, 0x71, 0x02, 0x44, 0x01, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x914, 0x910, 0x90C, 0x1C3, 0x1C4, 0x1C5}, - { - 161, 5805, 3870, 0x72, 0x04, 0x89, 0x01, 0xED, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x916, 0x912, 0x90E, 0x1C3, 0x1C4, 0x1C4}, - { - 162, 5810, 3873, 0x71, 0x02, 0x45, 0x01, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x918, 0x914, 0x910, 0x1C2, 0x1C3, 0x1C4}, - { - 163, 5815, 3877, 0x72, 0x04, 0x8B, 0x01, 0xED, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x91A, 0x916, 0x912, 0x1C2, 0x1C3, 0x1C4}, - { - 164, 5820, 3880, 0x71, 0x02, 0x46, 0x01, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x91C, 0x918, 0x914, 0x1C2, 0x1C2, 0x1C3}, - { - 165, 5825, 3883, 0x72, 0x04, 0x8D, 0x01, 0xED, 0x00, 0x03, 0x14, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x91E, 0x91A, 0x916, 0x1C1, 0x1C2, 0x1C3}, - { - 166, 5830, 3887, 0x71, 0x02, 0x47, 0x01, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x920, 0x91C, 0x918, 0x1C1, 0x1C2, 0x1C2}, - { - 168, 5840, 3893, 0x71, 0x02, 0x48, 0x01, 0x0A, 0x01, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x924, 0x920, 0x91C, 0x1C0, 0x1C1, 0x1C2}, - { - 170, 5850, 3900, 0x71, 0x02, 0x49, 0x01, 0xE0, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x928, 0x924, 0x920, 0x1BF, 0x1C0, 0x1C1}, - { - 172, 5860, 3907, 0x71, 0x02, 0x4A, 0x01, 0xDE, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x92C, 0x928, 0x924, 0x1BF, 0x1BF, 0x1C0}, - { - 174, 5870, 3913, 0x71, 0x02, 0x4B, 0x00, 0xDB, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x930, 0x92C, 0x928, 0x1BE, 0x1BF, 0x1BF}, - { - 176, 5880, 3920, 0x71, 0x02, 0x4C, 0x00, 0xD8, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x934, 0x930, 0x92C, 0x1BD, 0x1BE, 0x1BF}, - { - 178, 5890, 3927, 0x71, 0x02, 0x4D, 0x00, 0xD6, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x938, 0x934, 0x930, 0x1BC, 0x1BD, 0x1BE}, - { - 180, 5900, 3933, 0x71, 0x02, 0x4E, 0x00, 0xD3, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x93C, 0x938, 0x934, 0x1BC, 0x1BC, 0x1BD}, - { - 182, 5910, 3940, 0x71, 0x02, 0x4F, 0x00, 0xD6, 0x00, 0x04, 0x0A, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x940, 0x93C, 0x938, 0x1BB, 0x1BC, 0x1BC}, - { - 1, 2412, 3216, 0x73, 0x09, 0x6C, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0D, 0x0C, 0x80, 0xFF, 0x88, 0x0D, - 0x0C, 0x80, 0x3C9, 0x3C5, 0x3C1, 0x43A, 0x43F, 0x443}, - { - 2, 2417, 3223, 0x73, 0x09, 0x71, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0C, 0x0B, 0x80, 0xFF, 0x88, 0x0C, - 0x0B, 0x80, 0x3CB, 0x3C7, 0x3C3, 0x438, 0x43D, 0x441}, - { - 3, 2422, 3229, 0x73, 0x09, 0x76, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0C, 0x0A, 0x80, 0xFF, 0x88, 0x0C, - 0x0A, 0x80, 0x3CD, 0x3C9, 0x3C5, 0x436, 0x43A, 0x43F}, - { - 4, 2427, 3236, 0x73, 0x09, 0x7B, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0C, 0x0A, 0x80, 0xFF, 0x88, 0x0C, - 0x0A, 0x80, 0x3CF, 0x3CB, 0x3C7, 0x434, 0x438, 0x43D}, - { - 5, 2432, 3243, 0x73, 0x09, 0x80, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0C, 0x09, 0x80, 0xFF, 0x88, 0x0C, - 0x09, 0x80, 0x3D1, 0x3CD, 0x3C9, 0x431, 0x436, 0x43A}, - { - 6, 2437, 3249, 0x73, 0x09, 0x85, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0B, 0x08, 0x80, 0xFF, 0x88, 0x0B, - 0x08, 0x80, 0x3D3, 0x3CF, 0x3CB, 0x42F, 0x434, 0x438}, - { - 7, 2442, 3256, 0x73, 0x09, 0x8A, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0A, 0x07, 0x80, 0xFF, 0x88, 0x0A, - 0x07, 0x80, 0x3D5, 0x3D1, 0x3CD, 0x42D, 0x431, 0x436}, - { - 8, 2447, 3263, 0x73, 0x09, 0x8F, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x0A, 0x06, 0x80, 0xFF, 0x88, 0x0A, - 0x06, 0x80, 0x3D7, 0x3D3, 0x3CF, 0x42B, 0x42F, 0x434}, - { - 9, 2452, 3269, 0x73, 0x09, 0x94, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x09, 0x06, 0x80, 0xFF, 0x88, 0x09, - 0x06, 0x80, 0x3D9, 0x3D5, 0x3D1, 0x429, 0x42D, 0x431}, - { - 10, 2457, 3276, 0x73, 0x09, 0x99, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x08, 0x05, 0x80, 0xFF, 0x88, 0x08, - 0x05, 0x80, 0x3DB, 0x3D7, 0x3D3, 0x427, 0x42B, 0x42F}, - { - 11, 2462, 3283, 0x73, 0x09, 0x9E, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x08, 0x04, 0x80, 0xFF, 0x88, 0x08, - 0x04, 0x80, 0x3DD, 0x3D9, 0x3D5, 0x424, 0x429, 0x42D}, - { - 12, 2467, 3289, 0x73, 0x09, 0xA3, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x08, 0x03, 0x80, 0xFF, 0x88, 0x08, - 0x03, 0x80, 0x3DF, 0x3DB, 0x3D7, 0x422, 0x427, 0x42B}, - { - 13, 2472, 3296, 0x73, 0x09, 0xA8, 0x0F, 0x00, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x07, 0x03, 0x80, 0xFF, 0x88, 0x07, - 0x03, 0x80, 0x3E1, 0x3DD, 0x3D9, 0x420, 0x424, 0x429}, - { - 14, 2484, 3312, 0x73, 0x09, 0xB4, 0x0F, 0xFF, 0x01, 0x07, 0x15, - 0x01, 0x8F, 0xFF, 0xFF, 0xFF, 0x88, 0x07, 0x01, 0x80, 0xFF, 0x88, 0x07, - 0x01, 0x80, 0x3E6, 0x3E2, 0x3DE, 0x41B, 0x41F, 0x424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev3_2056[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xff, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xff, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xff, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xef, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xfc, 0x00, 0xef, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xfc, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xef, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xbf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xbf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xbf, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xfc, 0x00, 0xbf, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xfc, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfc, 0x00, 0xbf, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfc, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0xbf, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0xbf, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xaf, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0xaf, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xaf, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0xaf, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x8f, 0x00, 0x05, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xfa, 0x00, 0x8f, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xfa, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8f, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x8f, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8f, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x8f, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8e, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x8e, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8e, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x8e, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x7e, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x7e, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x7d, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xfa, 0x00, 0x7d, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xfa, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x6d, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xf8, 0x00, 0x6d, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xf8, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x6d, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xf8, 0x00, 0x6d, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xf8, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x5d, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xf8, 0x00, 0x5d, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xf8, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x5c, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x08, 0x00, 0xf8, 0x00, 0x5c, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x08, - 0x00, 0xf8, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x5c, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x5c, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x4c, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x4c, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x3b, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x3b, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x3b, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x2b, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x2b, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x2a, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x2a, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x1a, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x1a, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x1a, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x1a, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x1a, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x1a, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x19, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x19, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x19, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x19, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x09, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x09, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x09, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x09, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf8, 0x00, 0x08, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf8, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf6, 0x00, 0x08, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf6, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf6, 0x00, 0x08, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf6, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf6, 0x00, 0x08, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf6, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x07, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf6, 0x00, 0x07, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf6, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf6, 0x00, 0x07, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf6, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x07, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x07, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x06, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf4, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf4, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf2, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf2, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf2, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf2, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf2, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf2, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x06, 0x00, 0xf2, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x06, - 0x00, 0xf2, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x05, 0x00, 0xf2, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x05, - 0x00, 0xf2, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x05, 0x00, 0xf2, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x05, - 0x00, 0xf2, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xff, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xfd, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfb, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xfb, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xf7, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0xf6, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0f, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0xf5, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0d, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0xf4, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0d, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf3, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0xf3, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0d, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0d, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x05, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0xf0, 0x00, 0x05, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0d, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev4_2056_A1[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x0d, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xff, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xef, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x0c, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfe, 0x00, 0xef, 0x00, 0x0c, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfe, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xef, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xef, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xdf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xdf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xcf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xcf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xbf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xbf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xbf, 0x00, 0x0a, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfc, 0x00, 0xbf, 0x00, 0x0a, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfc, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0xbf, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0xbf, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xbf, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0xbf, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xaf, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0xaf, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xaf, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0xaf, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x9f, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x9f, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x8f, 0x00, 0x08, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xfa, 0x00, 0x8f, 0x00, 0x08, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xfa, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8f, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x8f, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8f, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x8f, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8e, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x8e, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x8e, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x8e, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x7e, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x7e, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x7d, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x7d, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x6d, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x6d, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x6d, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x6d, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x5d, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x5d, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x5c, 0x00, 0x07, 0x00, 0x7f, - 0x00, 0x0f, 0x00, 0xf8, 0x00, 0x5c, 0x00, 0x07, 0x00, 0x7f, 0x00, 0x0f, - 0x00, 0xf8, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x5c, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x5c, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x4c, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x4c, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x4c, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x4c, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x3b, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x3b, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x3b, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x3b, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x2b, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x2b, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x2a, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x2a, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x1a, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x1a, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x1a, 0x00, 0x06, 0x00, 0x7f, - 0x00, 0x0d, 0x00, 0xf6, 0x00, 0x1a, 0x00, 0x06, 0x00, 0x7f, 0x00, 0x0d, - 0x00, 0xf6, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x1a, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x1a, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x19, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x19, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x19, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x19, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x09, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x09, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x09, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x09, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x08, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x08, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x08, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x08, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x08, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x07, 0x00, 0x04, 0x00, 0x7f, - 0x00, 0x0b, 0x00, 0xf4, 0x00, 0x07, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x0b, - 0x00, 0xf4, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x07, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x07, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x07, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x07, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x06, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x06, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x05, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x04, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x04, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x04, 0x00, 0x03, 0x00, 0x7f, - 0x00, 0x0a, 0x00, 0xf2, 0x00, 0x04, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x0a, - 0x00, 0xf2, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x04, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x02, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x02, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x02, 0x00, 0x02, 0x00, 0x7f, - 0x00, 0x09, 0x00, 0xf0, 0x00, 0x02, 0x00, 0x02, 0x00, 0x7f, 0x00, 0x09, - 0x00, 0xf0, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf0, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf0, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, - 0x00, 0x07, 0x00, 0xf0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x07, - 0x00, 0xf0, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xff, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xff, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xff, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xff, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xfd, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfb, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xfb, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf8, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf7, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf6, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf5, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf4, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf3, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf3, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf2, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x04, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0e, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0e, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev5_2056v5[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0f, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfd, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0a, 0x00, 0x9f, 0x00, 0xfb, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x07, 0x00, 0x70, - 0x00, 0x0a, 0x00, 0x9f, 0x00, 0xfb, 0x00, 0x07, 0x00, 0x70, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x07, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfb, 0x00, 0x07, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfb, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xea, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9e, 0x00, 0xea, 0x00, 0x06, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6e, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xe9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xe9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xe9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xe9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xd9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xd9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xd8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xd8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0f, 0x00, 0xff, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xb8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xb8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xb7, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9b, 0x00, 0xb7, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6b, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xb7, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9b, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6b, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xa7, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa7, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x6b, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xa6, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x6b, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0xa6, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x5b, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x96, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x96, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x5a, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8f, 0x0e, 0x00, 0xff, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x5a, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x5a, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x5a, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x5a, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xc8, 0x85, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x85, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x59, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x59, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x59, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x74, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x99, 0x00, 0x74, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0d, 0x00, 0xc8, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x63, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x98, 0x00, 0x63, 0x00, 0x01, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x78, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x52, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x52, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x52, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x52, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8d, 0x0b, 0x00, 0x84, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x95, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x75, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x50, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x95, 0x00, 0x50, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x75, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x50, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x95, 0x00, 0x50, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x75, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8b, 0x09, 0x00, 0x70, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x74, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x84, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x83, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x8a, 0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x8a, 0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x82, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x72, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x72, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x72, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x72, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x71, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x71, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x88, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x71, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x71, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x71, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x1f, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0b, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x1f, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0a, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0a, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x09, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x09, 0x00, 0x08, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x09, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x07, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x09, 0x00, 0x07, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x09, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x09, 0x00, 0x06, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x09, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x09, 0x00, 0x05, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x09, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x03, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v6[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfb, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xfe, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xc8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xed, 0xc7, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdb, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xcb, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xa7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x94, 0x73, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x84, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x83, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x71, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x60, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x50, 0x61, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6d, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6d, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x78, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x78, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x67, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x57, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x57, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x56, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x56, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x46, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x46, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x45, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x45, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x34, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x23, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x23, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x12, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x02, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x01, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x01, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev5n6_2056v7[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0f, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0b, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0b, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0e, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x0a, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0d, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xff, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x70, - 0x00, 0x0c, 0x00, 0x9f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x70, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfd, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0b, 0x00, 0x9f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x08, 0x00, 0x70, - 0x00, 0x0a, 0x00, 0x9f, 0x00, 0xfb, 0x00, 0x08, 0x00, 0x70, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x07, 0x00, 0x70, - 0x00, 0x0a, 0x00, 0x9f, 0x00, 0xfb, 0x00, 0x07, 0x00, 0x70, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x07, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfb, 0x00, 0x07, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfb, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xfe, 0xfa, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x09, 0x00, 0x9e, 0x00, 0xfa, 0x00, 0x06, 0x00, 0x70, 0x00, 0x09, - 0x00, 0x6e, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xea, 0x00, 0x06, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9e, 0x00, 0xea, 0x00, 0x06, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6e, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xe9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xe9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xed, 0xe9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xe9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0e, 0x00, 0xed, 0xd9, 0x00, 0x05, 0x00, 0x70, - 0x00, 0x08, 0x00, 0x9d, 0x00, 0xd9, 0x00, 0x05, 0x00, 0x70, 0x00, 0x08, - 0x00, 0x6d, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8e, 0x0e, 0x00, 0xed, 0xd8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xd8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xc8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xc8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdb, 0xb8, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9c, 0x00, 0xb8, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6c, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xcb, 0xb7, 0x00, 0x04, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9b, 0x00, 0xb7, 0x00, 0x04, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6b, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xca, 0xb7, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x07, 0x00, 0x9b, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x70, 0x00, 0x07, - 0x00, 0x6b, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xca, 0xa7, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa7, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x6b, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0xa6, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x6b, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0xa6, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9b, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x7b, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x96, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x96, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x7a, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x7a, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x06, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x06, - 0x00, 0x7a, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb7, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x7a, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xa7, 0x95, 0x00, 0x03, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x9a, 0x00, 0x95, 0x00, 0x03, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x7a, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0b, 0x00, 0xa6, 0x85, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x85, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x79, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x79, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x05, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x05, - 0x00, 0x79, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x02, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x99, 0x00, 0x84, 0x00, 0x02, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x79, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x94, 0x74, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x99, 0x00, 0x74, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x79, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x84, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x83, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x72, 0x73, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x04, 0x00, 0x98, 0x00, 0x73, 0x00, 0x01, 0x00, 0x70, 0x00, 0x04, - 0x00, 0x78, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x72, 0x63, 0x00, 0x01, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x98, 0x00, 0x63, 0x00, 0x01, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x78, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x71, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x62, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x03, 0x00, 0x97, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x03, - 0x00, 0x77, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x52, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x52, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x76, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x60, 0x52, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x52, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x96, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x86, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x51, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x02, 0x00, 0x95, 0x00, 0x51, 0x00, 0x00, 0x00, 0x70, 0x00, 0x02, - 0x00, 0x85, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x95, 0x00, 0x50, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x85, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x95, 0x00, 0x50, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x85, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x84, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x84, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x01, 0x00, 0x94, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, - 0x00, 0x94, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x93, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x93, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x92, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x91, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x91, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x91, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x91, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x91, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x89, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0b, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x89, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0a, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x89, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0f, 0x00, 0x0a, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x78, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x76, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x76, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x66, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x66, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x0a, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x55, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x09, 0x00, 0x55, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x09, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x45, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0e, 0x00, 0x09, 0x00, 0x45, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0e, 0x00, 0x09, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x09, 0x00, 0x34, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x09, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x33, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x09, 0x00, 0x33, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x09, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x22, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x22, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x11, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0d, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0d, 0x00, 0x08, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v8[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfb, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xfe, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xc8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xed, 0xc7, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdb, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xcb, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xa7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x94, 0x73, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x84, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x83, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x71, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x60, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x50, 0x61, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6d, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6d, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x07, 0x07, 0x04, 0x10, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x04, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x67, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x57, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x78, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x56, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x46, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x76, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x45, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x66, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x55, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x23, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x45, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x34, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x33, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x22, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x11, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x08, 0x08, 0x04, 0x16, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio205x chan_info_nphyrev6_2056v11[] = { - { - 184, 4920, 0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b4, 0x07b0, 0x07ac, 0x0214, 0x0215, 0x0216}, - { - 186, 4930, 0xff, 0x01, 0x01, 0x01, 0xed, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07b8, 0x07b4, 0x07b0, 0x0213, 0x0214, 0x0215}, - { - 188, 4940, 0xff, 0x01, 0x01, 0x01, 0xee, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07bc, 0x07b8, 0x07b4, 0x0212, 0x0213, 0x0214}, - { - 190, 4950, 0xff, 0x01, 0x01, 0x01, 0xef, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x00, 0x00, 0x00, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c0, 0x07bc, 0x07b8, 0x0211, 0x0212, 0x0213}, - { - 192, 4960, 0xff, 0x01, 0x01, 0x01, 0xf0, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c4, 0x07c0, 0x07bc, 0x020f, 0x0211, 0x0212}, - { - 194, 4970, 0xff, 0x01, 0x01, 0x01, 0xf1, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07c8, 0x07c4, 0x07c0, 0x020e, 0x020f, 0x0211}, - { - 196, 4980, 0xff, 0x01, 0x01, 0x01, 0xf2, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07cc, 0x07c8, 0x07c4, 0x020d, 0x020e, 0x020f}, - { - 198, 4990, 0xff, 0x01, 0x01, 0x01, 0xf3, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d0, 0x07cc, 0x07c8, 0x020c, 0x020d, 0x020e}, - { - 200, 5000, 0xff, 0x01, 0x01, 0x01, 0xf4, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d4, 0x07d0, 0x07cc, 0x020b, 0x020c, 0x020d}, - { - 202, 5010, 0xff, 0x01, 0x01, 0x01, 0xf5, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07d8, 0x07d4, 0x07d0, 0x020a, 0x020b, 0x020c}, - { - 204, 5020, 0xf7, 0x01, 0x01, 0x01, 0xf6, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07dc, 0x07d8, 0x07d4, 0x0209, 0x020a, 0x020b}, - { - 206, 5030, 0xf7, 0x01, 0x01, 0x01, 0xf7, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e0, 0x07dc, 0x07d8, 0x0208, 0x0209, 0x020a}, - { - 208, 5040, 0xef, 0x01, 0x01, 0x01, 0xf8, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e4, 0x07e0, 0x07dc, 0x0207, 0x0208, 0x0209}, - { - 210, 5050, 0xef, 0x01, 0x01, 0x01, 0xf9, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07e8, 0x07e4, 0x07e0, 0x0206, 0x0207, 0x0208}, - { - 212, 5060, 0xe6, 0x01, 0x01, 0x01, 0xfa, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfe, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfe, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07ec, 0x07e8, 0x07e4, 0x0205, 0x0206, 0x0207}, - { - 214, 5070, 0xe6, 0x01, 0x01, 0x01, 0xfb, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f0, 0x07ec, 0x07e8, 0x0204, 0x0205, 0x0206}, - { - 216, 5080, 0xde, 0x01, 0x01, 0x01, 0xfc, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f4, 0x07f0, 0x07ec, 0x0203, 0x0204, 0x0205}, - { - 218, 5090, 0xde, 0x01, 0x01, 0x01, 0xfd, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x01, 0x01, 0x01, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x09, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x09, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07f8, 0x07f4, 0x07f0, 0x0202, 0x0203, 0x0204}, - { - 220, 5100, 0xd6, 0x01, 0x01, 0x01, 0xfe, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfd, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfd, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x07fc, 0x07f8, 0x07f4, 0x0201, 0x0202, 0x0203}, - { - 222, 5110, 0xd6, 0x01, 0x01, 0x01, 0xff, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0800, 0x07fc, 0x07f8, 0x0200, 0x0201, 0x0202}, - { - 224, 5120, 0xce, 0x01, 0x01, 0x02, 0x00, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0804, 0x0800, 0x07fc, 0x01ff, 0x0200, 0x0201}, - { - 226, 5130, 0xce, 0x01, 0x01, 0x02, 0x01, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfc, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfc, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x0808, 0x0804, 0x0800, 0x01fe, 0x01ff, 0x0200}, - { - 228, 5140, 0xc6, 0x01, 0x01, 0x02, 0x02, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfb, 0x00, 0x08, 0x00, 0x77, - 0x00, 0x0f, 0x00, 0x6f, 0x00, 0xfb, 0x00, 0x08, 0x00, 0x77, 0x00, 0x0f, - 0x00, 0x6f, 0x00, 0x080c, 0x0808, 0x0804, 0x01fd, 0x01fe, 0x01ff}, - { - 32, 5160, 0xbe, 0x01, 0x01, 0x02, 0x04, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0814, 0x0810, 0x080c, 0x01fb, 0x01fc, 0x01fd}, - { - 34, 5170, 0xbe, 0x01, 0x01, 0x02, 0x05, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xfa, 0x00, 0x07, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xfa, 0x00, 0x07, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x0818, 0x0814, 0x0810, 0x01fa, 0x01fb, 0x01fc}, - { - 36, 5180, 0xb6, 0x01, 0x01, 0x02, 0x06, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0e, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0e, - 0x00, 0x6f, 0x00, 0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb}, - { - 38, 5190, 0xb6, 0x01, 0x01, 0x02, 0x07, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x06, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x06, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0820, 0x081c, 0x0818, 0x01f8, 0x01f9, 0x01fa}, - { - 40, 5200, 0xaf, 0x01, 0x01, 0x02, 0x08, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9}, - { - 42, 5210, 0xaf, 0x01, 0x01, 0x02, 0x09, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8f, 0x0f, 0x00, 0xff, 0xf9, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xf9, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0828, 0x0824, 0x0820, 0x01f6, 0x01f7, 0x01f8}, - { - 44, 5220, 0xa7, 0x01, 0x01, 0x02, 0x0a, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xfe, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7}, - { - 46, 5230, 0xa7, 0x01, 0x01, 0x02, 0x0b, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xd8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xd8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0830, 0x082c, 0x0828, 0x01f4, 0x01f5, 0x01f6}, - { - 48, 5240, 0xa0, 0x01, 0x01, 0x02, 0x0c, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xee, 0xc8, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc8, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5}, - { - 50, 5250, 0xa0, 0x01, 0x01, 0x02, 0x0d, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0f, 0x00, 0xed, 0xc7, 0x00, 0x05, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x05, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x0838, 0x0834, 0x0830, 0x01f2, 0x01f3, 0x01f4}, - { - 52, 5260, 0x98, 0x01, 0x01, 0x02, 0x0e, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x02, 0x02, 0x02, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0d, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0d, - 0x00, 0x6f, 0x00, 0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3}, - { - 54, 5270, 0x98, 0x01, 0x01, 0x02, 0x0f, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8e, 0x0e, 0x00, 0xed, 0xc7, 0x00, 0x04, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xc7, 0x00, 0x04, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0840, 0x083c, 0x0838, 0x01f0, 0x01f1, 0x01f2}, - { - 56, 5280, 0x91, 0x01, 0x01, 0x02, 0x10, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1}, - { - 58, 5290, 0x91, 0x01, 0x01, 0x02, 0x11, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0848, 0x0844, 0x0840, 0x01ef, 0x01f0, 0x01f0}, - { - 60, 5300, 0x8a, 0x01, 0x01, 0x02, 0x12, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0}, - { - 62, 5310, 0x8a, 0x01, 0x01, 0x02, 0x13, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdc, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0850, 0x084c, 0x0848, 0x01ed, 0x01ee, 0x01ef}, - { - 64, 5320, 0x83, 0x01, 0x01, 0x02, 0x14, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0e, 0x00, 0xdb, 0xb7, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0c, 0x00, 0x6f, 0x00, 0xb7, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0c, - 0x00, 0x6f, 0x00, 0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee}, - { - 66, 5330, 0x83, 0x01, 0x01, 0x02, 0x15, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xcb, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0858, 0x0854, 0x0850, 0x01eb, 0x01ec, 0x01ed}, - { - 68, 5340, 0x7c, 0x01, 0x01, 0x02, 0x16, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8d, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x085c, 0x0858, 0x0854, 0x01ea, 0x01eb, 0x01ec}, - { - 70, 5350, 0x7c, 0x01, 0x01, 0x02, 0x17, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xca, 0xa6, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0b, 0x00, 0x6f, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0b, - 0x00, 0x6f, 0x00, 0x0860, 0x085c, 0x0858, 0x01e9, 0x01ea, 0x01eb}, - { - 72, 5360, 0x75, 0x01, 0x01, 0x02, 0x18, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0864, 0x0860, 0x085c, 0x01e8, 0x01e9, 0x01ea}, - { - 74, 5370, 0x75, 0x01, 0x01, 0x02, 0x19, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0d, 0x00, 0xc9, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0868, 0x0864, 0x0860, 0x01e7, 0x01e8, 0x01e9}, - { - 76, 5380, 0x6e, 0x01, 0x01, 0x02, 0x1a, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x95, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x95, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x086c, 0x0868, 0x0864, 0x01e6, 0x01e7, 0x01e8}, - { - 78, 5390, 0x6e, 0x01, 0x01, 0x02, 0x1b, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0870, 0x086c, 0x0868, 0x01e5, 0x01e6, 0x01e7}, - { - 80, 5400, 0x67, 0x01, 0x01, 0x02, 0x1c, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb8, 0x84, 0x00, 0x03, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x03, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0874, 0x0870, 0x086c, 0x01e5, 0x01e5, 0x01e6}, - { - 82, 5410, 0x67, 0x01, 0x01, 0x02, 0x1d, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xb7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0878, 0x0874, 0x0870, 0x01e4, 0x01e5, 0x01e5}, - { - 84, 5420, 0x61, 0x01, 0x01, 0x02, 0x1e, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0c, 0x00, 0xa7, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x087c, 0x0878, 0x0874, 0x01e3, 0x01e4, 0x01e5}, - { - 86, 5430, 0x61, 0x01, 0x01, 0x02, 0x1f, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x03, 0x03, 0x03, 0x8c, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x0a, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x0a, - 0x00, 0x6f, 0x00, 0x0880, 0x087c, 0x0878, 0x01e2, 0x01e3, 0x01e4}, - { - 88, 5440, 0x5a, 0x01, 0x01, 0x02, 0x20, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0xa6, 0x84, 0x00, 0x02, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x02, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0884, 0x0880, 0x087c, 0x01e1, 0x01e2, 0x01e3}, - { - 90, 5450, 0x5a, 0x01, 0x01, 0x02, 0x21, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0888, 0x0884, 0x0880, 0x01e0, 0x01e1, 0x01e2}, - { - 92, 5460, 0x53, 0x01, 0x01, 0x02, 0x22, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x95, 0x84, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x84, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x088c, 0x0888, 0x0884, 0x01df, 0x01e0, 0x01e1}, - { - 94, 5470, 0x53, 0x01, 0x01, 0x02, 0x23, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8b, 0x0b, 0x00, 0x94, 0x73, 0x00, 0x01, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x01, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0890, 0x088c, 0x0888, 0x01de, 0x01df, 0x01e0}, - { - 96, 5480, 0x4d, 0x01, 0x01, 0x02, 0x24, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x84, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0894, 0x0890, 0x088c, 0x01dd, 0x01de, 0x01df}, - { - 98, 5490, 0x4d, 0x01, 0x01, 0x02, 0x25, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x83, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x0898, 0x0894, 0x0890, 0x01dd, 0x01dd, 0x01de}, - { - 100, 5500, 0x47, 0x01, 0x01, 0x02, 0x26, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd}, - { - 102, 5510, 0x47, 0x01, 0x01, 0x02, 0x27, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x82, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a0, 0x089c, 0x0898, 0x01db, 0x01dc, 0x01dd}, - { - 104, 5520, 0x40, 0x01, 0x01, 0x02, 0x28, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x0a, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc}, - { - 106, 5530, 0x40, 0x01, 0x01, 0x02, 0x29, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x72, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08a8, 0x08a4, 0x08a0, 0x01d9, 0x01da, 0x01db}, - { - 108, 5540, 0x3a, 0x01, 0x01, 0x02, 0x2a, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x8a, 0x09, 0x00, 0x71, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da}, - { - 110, 5550, 0x3a, 0x01, 0x01, 0x02, 0x2b, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b0, 0x08ac, 0x08a8, 0x01d7, 0x01d8, 0x01d9}, - { - 112, 5560, 0x34, 0x01, 0x01, 0x02, 0x2c, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8}, - { - 114, 5570, 0x34, 0x01, 0x01, 0x02, 0x2d, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x09, 0x00, 0x61, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x09, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x09, - 0x00, 0x6f, 0x00, 0x08b8, 0x08b4, 0x08b0, 0x01d6, 0x01d7, 0x01d7}, - { - 116, 5580, 0x2e, 0x01, 0x01, 0x02, 0x2e, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x60, 0x62, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7}, - { - 118, 5590, 0x2e, 0x01, 0x01, 0x02, 0x2f, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x04, 0x04, 0x04, 0x89, 0x08, 0x00, 0x50, 0x61, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c0, 0x08bc, 0x08b8, 0x01d4, 0x01d5, 0x01d6}, - { - 120, 5600, 0x28, 0x01, 0x01, 0x02, 0x30, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5}, - { - 122, 5610, 0x28, 0x01, 0x01, 0x02, 0x31, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x51, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x08, 0x00, 0x6f, 0x00, 0x51, 0x00, 0x00, 0x00, 0x77, 0x00, 0x08, - 0x00, 0x6f, 0x00, 0x08c8, 0x08c4, 0x08c0, 0x01d2, 0x01d3, 0x01d4}, - { - 124, 5620, 0x21, 0x01, 0x01, 0x02, 0x32, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x89, 0x08, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3}, - { - 126, 5630, 0x21, 0x01, 0x01, 0x02, 0x33, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d0, 0x08cc, 0x08c8, 0x01d1, 0x01d2, 0x01d2}, - { - 128, 5640, 0x1c, 0x01, 0x01, 0x02, 0x34, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x50, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2}, - { - 130, 5650, 0x1c, 0x01, 0x01, 0x02, 0x35, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x07, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x07, - 0x00, 0x6f, 0x00, 0x08d8, 0x08d4, 0x08d0, 0x01cf, 0x01d0, 0x01d1}, - { - 132, 5660, 0x16, 0x01, 0x01, 0x02, 0x36, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0}, - { - 134, 5670, 0x16, 0x01, 0x01, 0x02, 0x37, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x88, 0x07, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, 0x01ce, 0x01cf}, - { - 136, 5680, 0x10, 0x01, 0x01, 0x02, 0x38, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce}, - { - 138, 5690, 0x10, 0x01, 0x01, 0x02, 0x39, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6f, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, 0x01cd, 0x01ce}, - { - 140, 5700, 0x0a, 0x01, 0x01, 0x02, 0x3a, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd}, - { - 142, 5710, 0x0a, 0x01, 0x01, 0x02, 0x3b, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, 0x01cb, 0x01cc}, - { - 144, 5720, 0x0a, 0x01, 0x01, 0x02, 0x3c, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, 0x01ca, 0x01cb}, - { - 145, 5725, 0x03, 0x01, 0x02, 0x04, 0x79, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x06, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, 0x01ca, 0x01cb}, - { - 146, 5730, 0x0a, 0x01, 0x01, 0x02, 0x3d, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6e, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, 0x01c9, 0x01ca}, - { - 147, 5735, 0x03, 0x01, 0x02, 0x04, 0x7b, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, 0x01c9, 0x01ca}, - { - 148, 5740, 0x0a, 0x01, 0x01, 0x02, 0x3e, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, 0x01c9, 0x01c9}, - { - 149, 5745, 0xfe, 0x00, 0x02, 0x04, 0x7d, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x06, 0x00, 0x6d, 0x00, 0x30, 0x00, 0x00, 0x00, 0x77, 0x00, 0x06, - 0x00, 0x6d, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9}, - { - 150, 5750, 0x0a, 0x01, 0x01, 0x02, 0x3f, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6d, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6d, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, 0x01c8, 0x01c9}, - { - 151, 5755, 0xfe, 0x00, 0x02, 0x04, 0x7f, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x87, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, 0x01c8, 0x01c8}, - { - 152, 5760, 0x0a, 0x01, 0x01, 0x02, 0x40, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, 0x01c7, 0x01c8}, - { - 153, 5765, 0xf8, 0x00, 0x02, 0x04, 0x81, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x05, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6c, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8}, - { - 154, 5770, 0x0a, 0x01, 0x01, 0x02, 0x41, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, 0x01c6, 0x01c7}, - { - 155, 5775, 0xf8, 0x00, 0x02, 0x04, 0x83, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, 0x01c6, 0x01c7}, - { - 156, 5780, 0x0a, 0x01, 0x01, 0x02, 0x42, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x05, 0x05, 0x05, 0x86, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, 0x01c6, 0x01c6}, - { - 157, 5785, 0xf2, 0x00, 0x02, 0x04, 0x85, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6}, - { - 158, 5790, 0x0a, 0x01, 0x01, 0x02, 0x43, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, 0x01c5, 0x01c6}, - { - 159, 5795, 0xf2, 0x00, 0x02, 0x04, 0x87, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, 0x01c4, 0x01c5}, - { - 160, 5800, 0x0a, 0x01, 0x01, 0x02, 0x44, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6b, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, 0x01c4, 0x01c5}, - { - 161, 5805, 0xed, 0x00, 0x02, 0x04, 0x89, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4}, - { - 162, 5810, 0x0a, 0x01, 0x01, 0x02, 0x45, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, 0x01c3, 0x01c4}, - { - 163, 5815, 0xed, 0x00, 0x02, 0x04, 0x8b, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, 0x01c3, 0x01c4}, - { - 164, 5820, 0x0a, 0x01, 0x01, 0x02, 0x46, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x6a, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, 0x01c2, 0x01c3}, - { - 165, 5825, 0xed, 0x00, 0x02, 0x04, 0x8d, 0x05, 0x05, 0x02, 0x15, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3}, - { - 166, 5830, 0x0a, 0x01, 0x01, 0x02, 0x47, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x05, - 0x00, 0x69, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, 0x01c2, 0x01c2}, - { - 168, 5840, 0x0a, 0x01, 0x01, 0x02, 0x48, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x86, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, 0x01c1, 0x01c2}, - { - 170, 5850, 0xe0, 0x00, 0x01, 0x02, 0x49, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, 0x01c0, 0x01c1}, - { - 172, 5860, 0xde, 0x00, 0x01, 0x02, 0x4a, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x69, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, 0x01bf, 0x01c0}, - { - 174, 5870, 0xdb, 0x00, 0x01, 0x02, 0x4b, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, 0x01bf, 0x01bf}, - { - 176, 5880, 0xd8, 0x00, 0x01, 0x02, 0x4c, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, 0x01be, 0x01bf}, - { - 178, 5890, 0xd6, 0x00, 0x01, 0x02, 0x4d, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, 0x01bd, 0x01be}, - { - 180, 5900, 0xd3, 0x00, 0x01, 0x02, 0x4e, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, 0x01bc, 0x01bd}, - { - 182, 5910, 0xd6, 0x00, 0x01, 0x02, 0x4f, 0x05, 0x05, 0x02, 0x0c, 0x01, - 0x06, 0x06, 0x06, 0x85, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, - 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x04, - 0x00, 0x68, 0x00, 0x0940, 0x093c, 0x0938, 0x01bb, 0x01bc, 0x01bc}, - { - 1, 2412, 0x00, 0x01, 0x03, 0x09, 0x6c, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x04, 0x04, 0x04, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x00, 0x01, 0x03, 0x09, 0x71, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x00, 0x01, 0x03, 0x09, 0x76, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x67, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x89, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0b, 0x00, 0x0a, 0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x00, 0x01, 0x03, 0x09, 0x7b, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x57, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x78, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x00, 0x01, 0x03, 0x09, 0x80, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x56, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x00, 0x01, 0x03, 0x09, 0x85, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x46, 0x00, 0x03, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x76, 0x00, 0x03, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x00, 0x01, 0x03, 0x09, 0x8a, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x05, 0x05, 0x05, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x45, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x66, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x0a, 0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x00, 0x01, 0x03, 0x09, 0x8f, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x55, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x00, 0x01, 0x03, 0x09, 0x94, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x23, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x45, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x00, 0x01, 0x03, 0x09, 0x99, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x34, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x0a, 0x00, 0x09, 0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x00, 0x01, 0x03, 0x09, 0x9e, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x33, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x00, 0x01, 0x03, 0x09, 0xa3, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x06, 0x06, 0x06, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x22, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x00, 0x01, 0x03, 0x09, 0xa8, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x11, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0xff, 0x01, 0x03, 0x09, 0xb4, 0x06, 0x06, 0x04, 0x2b, 0x01, - 0x07, 0x07, 0x07, 0x8f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x70, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, - 0x09, 0x00, 0x09, 0x03e6, 0x03e2, 0x03de, 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio2057 chan_info_nphyrev7_2057_rev4[] = { - { - 184, 4920, 0x68, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xec, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07b4, 0x07b0, 0x07ac, 0x0214, - 0x0215, - 0x0216, - }, - { - 186, 4930, 0x6b, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xed, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07b8, 0x07b4, 0x07b0, 0x0213, - 0x0214, - 0x0215, - }, - { - 188, 4940, 0x6e, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xee, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07bc, 0x07b8, 0x07b4, 0x0212, - 0x0213, - 0x0214, - }, - { - 190, 4950, 0x72, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xef, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07c0, 0x07bc, 0x07b8, 0x0211, - 0x0212, - 0x0213, - }, - { - 192, 4960, 0x75, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf0, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07c4, 0x07c0, 0x07bc, 0x020f, - 0x0211, - 0x0212, - }, - { - 194, 4970, 0x78, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf1, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07c8, 0x07c4, 0x07c0, 0x020e, - 0x020f, - 0x0211, - }, - { - 196, 4980, 0x7c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf2, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07cc, 0x07c8, 0x07c4, 0x020d, - 0x020e, - 0x020f, - }, - { - 198, 4990, 0x7f, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf3, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07d0, 0x07cc, 0x07c8, 0x020c, - 0x020d, - 0x020e, - }, - { - 200, 5000, 0x82, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf4, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07d4, 0x07d0, 0x07cc, 0x020b, - 0x020c, - 0x020d, - }, - { - 202, 5010, 0x86, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf5, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07d8, 0x07d4, 0x07d0, 0x020a, - 0x020b, - 0x020c, - }, - { - 204, 5020, 0x89, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf6, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07dc, 0x07d8, 0x07d4, 0x0209, - 0x020a, - 0x020b, - }, - { - 206, 5030, 0x8c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf7, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07e0, 0x07dc, 0x07d8, 0x0208, - 0x0209, - 0x020a, - }, - { - 208, 5040, 0x90, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf8, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07e4, 0x07e0, 0x07dc, 0x0207, - 0x0208, - 0x0209, - }, - { - 210, 5050, 0x93, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf9, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xf3, 0x00, 0xef, 0x07e8, 0x07e4, 0x07e0, 0x0206, - 0x0207, - 0x0208, - }, - { - 212, 5060, 0x96, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfa, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xe3, 0x00, 0xef, 0x00, - 0x00, 0x0f, 0x0f, 0xe3, 0x00, 0xef, 0x07ec, 0x07e8, 0x07e4, 0x0205, - 0x0206, - 0x0207, - }, - { - 214, 5070, 0x9a, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfb, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xef, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xef, 0x07f0, 0x07ec, 0x07e8, 0x0204, - 0x0205, - 0x0206, - }, - { - 216, 5080, 0x9d, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfc, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xef, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xef, 0x07f4, 0x07f0, 0x07ec, 0x0203, - 0x0204, - 0x0205, - }, - { - 218, 5090, 0xa0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfd, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x07f8, 0x07f4, 0x07f0, 0x0202, - 0x0203, - 0x0204, - }, - { - 220, 5100, 0xa4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfe, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x07fc, 0x07f8, 0x07f4, 0x0201, - 0x0202, - 0x0203, - }, - { - 222, 5110, 0xa7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xff, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x0800, 0x07fc, 0x07f8, 0x0200, - 0x0201, - 0x0202, - }, - { - 224, 5120, 0xaa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x00, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x0804, 0x0800, 0x07fc, 0x01ff, - 0x0200, - 0x0201, - }, - { - 226, 5130, 0xae, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x01, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0f, 0xe3, 0x00, 0xd6, 0x0808, 0x0804, 0x0800, 0x01fe, - 0x01ff, - 0x0200, - }, - { - 228, 5140, 0xb1, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x02, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0e, 0x0e, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0e, 0x0e, 0xe3, 0x00, 0xd6, 0x080c, 0x0808, 0x0804, 0x01fd, - 0x01fe, - 0x01ff, - }, - { - 32, 5160, 0xb8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x04, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0d, 0x0e, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xe3, 0x00, 0xd6, 0x0814, 0x0810, 0x080c, 0x01fb, - 0x01fc, - 0x01fd, - }, - { - 34, 5170, 0xbb, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x05, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0d, 0x0e, 0xe3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xe3, 0x00, 0xd6, 0x0818, 0x0814, 0x0810, 0x01fa, - 0x01fb, - 0x01fc, - }, - { - 36, 5180, 0xbe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x06, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x081c, 0x0818, 0x0814, 0x01f9, - 0x01fa, - 0x01fb, - }, - { - 38, 5190, 0xc2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x07, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x0820, 0x081c, 0x0818, 0x01f8, - 0x01f9, - 0x01fa, - }, - { - 40, 5200, 0xc5, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x08, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x0824, 0x0820, 0x081c, 0x01f7, - 0x01f8, - 0x01f9, - }, - { - 42, 5210, 0xc8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x09, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0d, 0x0e, 0xd3, 0x00, 0xd6, 0x0828, 0x0824, 0x0820, 0x01f6, - 0x01f7, - 0x01f8, - }, - { - 44, 5220, 0xcc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0a, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x082c, 0x0828, 0x0824, 0x01f5, - 0x01f6, - 0x01f7, - }, - { - 46, 5230, 0xcf, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0b, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x0830, 0x082c, 0x0828, 0x01f4, - 0x01f5, - 0x01f6, - }, - { - 48, 5240, 0xd2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0c, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x0834, 0x0830, 0x082c, 0x01f3, - 0x01f4, - 0x01f5, - }, - { - 50, 5250, 0xd6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0d, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0e, 0xd3, 0x00, 0xd6, 0x0838, 0x0834, 0x0830, 0x01f2, - 0x01f3, - 0x01f4, - }, - { - 52, 5260, 0xd9, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0e, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0c, 0x0d, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0d, 0xd3, 0x00, 0xd6, 0x083c, 0x0838, 0x0834, 0x01f1, - 0x01f2, - 0x01f3, - }, - { - 54, 5270, 0xdc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0f, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0c, 0x0d, 0xd3, 0x00, 0xd6, 0x00, - 0x00, 0x0c, 0x0d, 0xd3, 0x00, 0xd6, 0x0840, 0x083c, 0x0838, 0x01f0, - 0x01f1, - 0x01f2, - }, - { - 56, 5280, 0xe0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x10, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x0844, 0x0840, 0x083c, 0x01f0, - 0x01f0, - 0x01f1, - }, - { - 58, 5290, 0xe3, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x11, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x0848, 0x0844, 0x0840, 0x01ef, - 0x01f0, - 0x01f0, - }, - { - 60, 5300, 0xe6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x12, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0xd4, 0x084c, 0x0848, 0x0844, 0x01ee, - 0x01ef, - 0x01f0, - }, - { - 62, 5310, 0xea, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x13, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x0850, 0x084c, 0x0848, 0x01ed, - 0x01ee, - 0x01ef, - }, - { - 64, 5320, 0xed, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x14, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x0854, 0x0850, 0x084c, 0x01ec, - 0x01ed, - 0x01ee, - }, - { - 66, 5330, 0xf0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x15, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x00, - 0x00, 0x0b, 0x0c, 0xc3, 0x00, 0xd4, 0x0858, 0x0854, 0x0850, 0x01eb, - 0x01ec, - 0x01ed, - }, - { - 68, 5340, 0xf4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x16, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0c, 0xc3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0c, 0xc3, 0x00, 0xa1, 0x085c, 0x0858, 0x0854, 0x01ea, - 0x01eb, - 0x01ec, - }, - { - 70, 5350, 0xf7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x17, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x0860, 0x085c, 0x0858, 0x01e9, - 0x01ea, - 0x01eb, - }, - { - 72, 5360, 0xfa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x18, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x0864, 0x0860, 0x085c, 0x01e8, - 0x01e9, - 0x01ea, - }, - { - 74, 5370, 0xfe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x19, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x0868, 0x0864, 0x0860, 0x01e7, - 0x01e8, - 0x01e9, - }, - { - 76, 5380, 0x01, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1a, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0b, 0xb3, 0x00, 0xa1, 0x086c, 0x0868, 0x0864, 0x01e6, - 0x01e7, - 0x01e8, - }, - { - 78, 5390, 0x04, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1b, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0a, 0x0a, 0xa3, 0x00, 0xa1, 0x00, - 0x00, 0x0a, 0x0a, 0xa3, 0x00, 0xa1, 0x0870, 0x086c, 0x0868, 0x01e5, - 0x01e6, - 0x01e7, - }, - { - 80, 5400, 0x08, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1c, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x09, 0x0a, 0xa3, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x0a, 0xa3, 0x00, 0x90, 0x0874, 0x0870, 0x086c, 0x01e5, - 0x01e5, - 0x01e6, - }, - { - 82, 5410, 0x0b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1d, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x09, 0x0a, 0xa3, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x0a, 0xa3, 0x00, 0x90, 0x0878, 0x0874, 0x0870, 0x01e4, - 0x01e5, - 0x01e5, - }, - { - 84, 5420, 0x0e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1e, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x09, 0x09, 0xa3, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x09, 0xa3, 0x00, 0x90, 0x087c, 0x0878, 0x0874, 0x01e3, - 0x01e4, - 0x01e5, - }, - { - 86, 5430, 0x12, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1f, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x0880, 0x087c, 0x0878, 0x01e2, - 0x01e3, - 0x01e4, - }, - { - 88, 5440, 0x15, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x20, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x0884, 0x0880, 0x087c, 0x01e1, - 0x01e2, - 0x01e3, - }, - { - 90, 5450, 0x18, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x21, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x00, - 0x00, 0x09, 0x09, 0x93, 0x00, 0x90, 0x0888, 0x0884, 0x0880, 0x01e0, - 0x01e1, - 0x01e2, - }, - { - 92, 5460, 0x1c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x22, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x08, 0x93, 0x00, 0x90, 0x00, - 0x00, 0x08, 0x08, 0x93, 0x00, 0x90, 0x088c, 0x0888, 0x0884, 0x01df, - 0x01e0, - 0x01e1, - }, - { - 94, 5470, 0x1f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x23, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x08, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x08, 0x93, 0x00, 0x60, 0x0890, 0x088c, 0x0888, 0x01de, - 0x01df, - 0x01e0, - }, - { - 96, 5480, 0x22, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x24, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x0894, 0x0890, 0x088c, 0x01dd, - 0x01de, - 0x01df, - }, - { - 98, 5490, 0x26, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x25, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x0898, 0x0894, 0x0890, 0x01dd, - 0x01dd, - 0x01de, - }, - { - 100, 5500, 0x29, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x26, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x089c, 0x0898, 0x0894, 0x01dc, - 0x01dd, - 0x01dd, - }, - { - 102, 5510, 0x2c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x27, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x07, 0x93, 0x00, 0x60, 0x08a0, 0x089c, 0x0898, 0x01db, - 0x01dc, - 0x01dd, - }, - { - 104, 5520, 0x30, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x28, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x08a4, 0x08a0, 0x089c, 0x01da, - 0x01db, - 0x01dc, - }, - { - 106, 5530, 0x33, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x29, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x08a8, 0x08a4, 0x08a0, 0x01d9, - 0x01da, - 0x01db, - }, - { - 108, 5540, 0x36, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2a, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x06, 0x93, 0x00, 0x60, 0x08ac, 0x08a8, 0x08a4, 0x01d8, - 0x01d9, - 0x01da, - }, - { - 110, 5550, 0x3a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2b, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x08b0, 0x08ac, 0x08a8, 0x01d7, - 0x01d8, - 0x01d9, - }, - { - 112, 5560, 0x3d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2c, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x08b4, 0x08b0, 0x08ac, 0x01d7, - 0x01d7, - 0x01d8, - }, - { - 114, 5570, 0x40, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2d, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x00, - 0x00, 0x08, 0x05, 0x83, 0x00, 0x60, 0x08b8, 0x08b4, 0x08b0, 0x01d6, - 0x01d7, - 0x01d7, - }, - { - 116, 5580, 0x44, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2e, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x07, 0x05, 0x83, 0x00, 0x60, 0x00, - 0x00, 0x07, 0x05, 0x83, 0x00, 0x60, 0x08bc, 0x08b8, 0x08b4, 0x01d5, - 0x01d6, - 0x01d7, - }, - { - 118, 5590, 0x47, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2f, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x07, 0x04, 0x83, 0x00, 0x60, 0x00, - 0x00, 0x07, 0x04, 0x83, 0x00, 0x60, 0x08c0, 0x08bc, 0x08b8, 0x01d4, - 0x01d5, - 0x01d6, - }, - { - 120, 5600, 0x4a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x30, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x07, 0x04, 0x73, 0x00, 0x30, 0x00, - 0x00, 0x07, 0x04, 0x73, 0x00, 0x30, 0x08c4, 0x08c0, 0x08bc, 0x01d3, - 0x01d4, - 0x01d5, - }, - { - 122, 5610, 0x4e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x31, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x08c8, 0x08c4, 0x08c0, 0x01d2, - 0x01d3, - 0x01d4, - }, - { - 124, 5620, 0x51, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x32, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x08cc, 0x08c8, 0x08c4, 0x01d2, - 0x01d2, - 0x01d3, - }, - { - 126, 5630, 0x54, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x33, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x08d0, 0x08cc, 0x08c8, 0x01d1, - 0x01d2, - 0x01d2, - }, - { - 128, 5640, 0x58, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x34, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x04, 0x73, 0x00, 0x30, 0x08d4, 0x08d0, 0x08cc, 0x01d0, - 0x01d1, - 0x01d2, - }, - { - 130, 5650, 0x5b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x35, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x06, 0x03, 0x63, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x03, 0x63, 0x00, 0x30, 0x08d8, 0x08d4, 0x08d0, 0x01cf, - 0x01d0, - 0x01d1, - }, - { - 132, 5660, 0x5e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x36, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x06, 0x03, 0x63, 0x00, 0x30, 0x00, - 0x00, 0x06, 0x03, 0x63, 0x00, 0x30, 0x08dc, 0x08d8, 0x08d4, 0x01ce, - 0x01cf, - 0x01d0, - }, - { - 134, 5670, 0x62, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x37, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x03, 0x63, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x03, 0x63, 0x00, 0x00, 0x08e0, 0x08dc, 0x08d8, 0x01ce, - 0x01ce, - 0x01cf, - }, - { - 136, 5680, 0x65, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x38, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x08e4, 0x08e0, 0x08dc, 0x01cd, - 0x01ce, - 0x01ce, - }, - { - 138, 5690, 0x68, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x39, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x08e8, 0x08e4, 0x08e0, 0x01cc, - 0x01cd, - 0x01ce, - }, - { - 140, 5700, 0x6c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3a, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x08ec, 0x08e8, 0x08e4, 0x01cb, - 0x01cc, - 0x01cd, - }, - { - 142, 5710, 0x6f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3b, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x08f0, 0x08ec, 0x08e8, 0x01ca, - 0x01cb, - 0x01cc, - }, - { - 144, 5720, 0x72, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3c, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x02, 0x53, 0x00, 0x00, 0x08f4, 0x08f0, 0x08ec, 0x01c9, - 0x01ca, - 0x01cb, - }, - { - 145, 5725, 0x74, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x79, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x05, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x01, 0x53, 0x00, 0x00, 0x08f6, 0x08f2, 0x08ee, 0x01c9, - 0x01ca, - 0x01cb, - }, - { - 146, 5730, 0x76, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3d, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x08f8, 0x08f4, 0x08f0, 0x01c9, - 0x01c9, - 0x01ca, - }, - { - 147, 5735, 0x77, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7b, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x08fa, 0x08f6, 0x08f2, 0x01c8, - 0x01c9, - 0x01ca, - }, - { - 148, 5740, 0x79, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3e, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x08fc, 0x08f8, 0x08f4, 0x01c8, - 0x01c9, - 0x01c9, - }, - { - 149, 5745, 0x7b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7d, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x08fe, 0x08fa, 0x08f6, 0x01c8, - 0x01c8, - 0x01c9, - }, - { - 150, 5750, 0x7c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3f, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, - 0x01c8, - 0x01c9, - }, - { - 151, 5755, 0x7e, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7f, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x53, 0x00, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, - 0x01c8, - 0x01c8, - }, - { - 152, 5760, 0x80, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x40, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, - 0x01c7, - 0x01c8, - }, - { - 153, 5765, 0x81, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x81, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, - 0x01c7, - 0x01c8, - }, - { - 154, 5770, 0x83, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x41, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, - 0x01c6, - 0x01c7, - }, - { - 155, 5775, 0x85, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x83, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x01, 0x43, 0x00, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, - 0x01c6, - 0x01c7, - }, - { - 156, 5780, 0x86, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x42, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x03, 0x01, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x01, 0x43, 0x00, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, - 0x01c6, - 0x01c6, - }, - { - 157, 5785, 0x88, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x85, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, - 0x01c5, - 0x01c6, - }, - { - 158, 5790, 0x8a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x43, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, - 0x01c5, - 0x01c6, - }, - { - 159, 5795, 0x8b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x87, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, - 0x01c4, - 0x01c5, - }, - { - 160, 5800, 0x8d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x44, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, - 0x01c4, - 0x01c5, - }, - { - 161, 5805, 0x8f, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x89, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, - 0x01c4, - 0x01c4, - }, - { - 162, 5810, 0x90, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x45, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, - 0x01c3, - 0x01c4, - }, - { - 163, 5815, 0x92, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8b, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, - 0x01c3, - 0x01c4, - }, - { - 164, 5820, 0x94, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x46, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, - 0x01c2, - 0x01c3, - }, - { - 165, 5825, 0x95, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8d, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, - 0x01c2, - 0x01c3, - }, - { - 166, 5830, 0x97, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x47, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, - 0x01c2, - 0x01c2, - }, - { - 168, 5840, 0x9a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x48, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, - 0x01c1, - 0x01c2, - }, - { - 170, 5850, 0x9e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x49, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, - 0x01c0, - 0x01c1, - }, - { - 172, 5860, 0xa1, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4a, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, - 0x01bf, - 0x01c0, - }, - { - 174, 5870, 0xa4, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4b, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, - 0x01bf, - 0x01bf, - }, - { - 176, 5880, 0xa8, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4c, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, - 0x01be, - 0x01bf, - }, - { - 178, 5890, 0xab, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4d, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, - 0x01bd, - 0x01be, - }, - { - 180, 5900, 0xae, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4e, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, - 0x01bc, - 0x01bd, - }, - { - 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x71, 0xa3, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x71, - 0xa3, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03c9, 0x03c5, 0x03c1, 0x043a, - 0x043f, - 0x0443, - }, - { - 2, 2417, 0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x71, 0xa3, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x71, - 0xa3, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cb, 0x03c7, 0x03c3, 0x0438, - 0x043d, - 0x0441, - }, - { - 3, 2422, 0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x71, 0x93, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x71, - 0x93, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cd, 0x03c9, 0x03c5, 0x0436, - 0x043a, - 0x043f, - }, - { - 4, 2427, 0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x71, 0x93, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x71, - 0x93, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cf, 0x03cb, 0x03c7, 0x0434, - 0x0438, - 0x043d, - }, - { - 5, 2432, 0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x51, 0x83, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x51, - 0x83, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d1, 0x03cd, 0x03c9, 0x0431, - 0x0436, - 0x043a, - }, - { - 6, 2437, 0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x51, 0x83, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x51, - 0x83, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d3, 0x03cf, 0x03cb, 0x042f, - 0x0434, - 0x0438, - }, - { - 7, 2442, 0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x51, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x51, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d5, 0x03d1, 0x03cd, 0x042d, - 0x0431, - 0x0436, - }, - { - 8, 2447, 0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x31, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x31, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d7, 0x03d3, 0x03cf, 0x042b, - 0x042f, - 0x0434, - }, - { - 9, 2452, 0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x31, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x31, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d9, 0x03d5, 0x03d1, 0x0429, - 0x042d, - 0x0431, - }, - { - 10, 2457, 0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x31, 0x63, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x31, - 0x63, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03db, 0x03d7, 0x03d3, 0x0427, - 0x042b, - 0x042f, - }, - { - 11, 2462, 0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x31, 0x63, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x31, - 0x63, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03dd, 0x03d9, 0x03d5, 0x0424, - 0x0429, - 0x042d, - }, - { - 12, 2467, 0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x11, 0x53, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x11, - 0x53, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03df, 0x03db, 0x03d7, 0x0422, - 0x0427, - 0x042b, - }, - { - 13, 2472, 0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x11, 0x53, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x11, - 0x53, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03e1, 0x03dd, 0x03d9, 0x0420, - 0x0424, - 0x0429, - }, - { - 14, 2484, 0x78, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xb4, 0x09, 0x0f, - 0x04, 0x00, 0x04, 0x00, 0x11, 0x43, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x11, - 0x43, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x03e6, 0x03e2, 0x03de, 0x041b, - 0x041f, - 0x0424} -}; - -static const struct chan_info_nphy_radio2057_rev5 -chan_info_nphyrev8_2057_rev5[] = { - { - 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03c9, 0x03c5, 0x03c1, - 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03cb, 0x03c7, 0x03c3, - 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xef, 0x61, 0x03, 0xef, 0x03cd, 0x03c9, 0x03c5, - 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, 0x09, 0x0c, - 0x08, 0x0e, 0x61, 0x03, 0xdf, 0x61, 0x03, 0xdf, 0x03cf, 0x03cb, 0x03c7, - 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, 0x09, 0x0c, - 0x07, 0x0d, 0x61, 0x03, 0xcf, 0x61, 0x03, 0xcf, 0x03d1, 0x03cd, 0x03c9, - 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, 0x09, 0x0c, - 0x07, 0x0d, 0x61, 0x03, 0xbf, 0x61, 0x03, 0xbf, 0x03d3, 0x03cf, 0x03cb, - 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0xaf, 0x61, 0x03, 0xaf, 0x03d5, 0x03d1, 0x03cd, - 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0x9f, 0x61, 0x03, 0x9f, 0x03d7, 0x03d3, 0x03cf, - 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0x8f, 0x61, 0x03, 0x8f, 0x03d9, 0x03d5, 0x03d1, - 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, 0x09, 0x0b, - 0x07, 0x0c, 0x61, 0x03, 0x7f, 0x61, 0x03, 0x7f, 0x03db, 0x03d7, 0x03d3, - 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, 0x09, 0x0b, - 0x07, 0x0c, 0x61, 0x03, 0x6f, 0x61, 0x03, 0x6f, 0x03dd, 0x03d9, 0x03d5, - 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, 0x09, 0x0b, - 0x06, 0x0c, 0x61, 0x03, 0x5f, 0x61, 0x03, 0x5f, 0x03df, 0x03db, 0x03d7, - 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, 0x09, 0x0a, - 0x06, 0x0b, 0x61, 0x03, 0x4f, 0x61, 0x03, 0x4f, 0x03e1, 0x03dd, 0x03d9, - 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0x78, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xb4, 0x09, 0x0a, - 0x06, 0x0b, 0x61, 0x03, 0x3f, 0x61, 0x03, 0x3f, 0x03e6, 0x03e2, 0x03de, - 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio2057_rev5 -chan_info_nphyrev9_2057_rev5v1[] = { - { - 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03c9, 0x03c5, 0x03c1, - 0x043a, 0x043f, 0x0443}, - { - 2, 2417, 0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xff, 0x61, 0x03, 0xff, 0x03cb, 0x03c7, 0x03c3, - 0x0438, 0x043d, 0x0441}, - { - 3, 2422, 0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, 0x09, 0x0d, - 0x08, 0x0e, 0x61, 0x03, 0xef, 0x61, 0x03, 0xef, 0x03cd, 0x03c9, 0x03c5, - 0x0436, 0x043a, 0x043f}, - { - 4, 2427, 0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, 0x09, 0x0c, - 0x08, 0x0e, 0x61, 0x03, 0xdf, 0x61, 0x03, 0xdf, 0x03cf, 0x03cb, 0x03c7, - 0x0434, 0x0438, 0x043d}, - { - 5, 2432, 0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, 0x09, 0x0c, - 0x07, 0x0d, 0x61, 0x03, 0xcf, 0x61, 0x03, 0xcf, 0x03d1, 0x03cd, 0x03c9, - 0x0431, 0x0436, 0x043a}, - { - 6, 2437, 0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, 0x09, 0x0c, - 0x07, 0x0d, 0x61, 0x03, 0xbf, 0x61, 0x03, 0xbf, 0x03d3, 0x03cf, 0x03cb, - 0x042f, 0x0434, 0x0438}, - { - 7, 2442, 0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0xaf, 0x61, 0x03, 0xaf, 0x03d5, 0x03d1, 0x03cd, - 0x042d, 0x0431, 0x0436}, - { - 8, 2447, 0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0x9f, 0x61, 0x03, 0x9f, 0x03d7, 0x03d3, 0x03cf, - 0x042b, 0x042f, 0x0434}, - { - 9, 2452, 0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, 0x09, 0x0b, - 0x07, 0x0d, 0x61, 0x03, 0x8f, 0x61, 0x03, 0x8f, 0x03d9, 0x03d5, 0x03d1, - 0x0429, 0x042d, 0x0431}, - { - 10, 2457, 0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, 0x09, 0x0b, - 0x07, 0x0c, 0x61, 0x03, 0x7f, 0x61, 0x03, 0x7f, 0x03db, 0x03d7, 0x03d3, - 0x0427, 0x042b, 0x042f}, - { - 11, 2462, 0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, 0x09, 0x0b, - 0x07, 0x0c, 0x61, 0x03, 0x6f, 0x61, 0x03, 0x6f, 0x03dd, 0x03d9, 0x03d5, - 0x0424, 0x0429, 0x042d}, - { - 12, 2467, 0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, 0x09, 0x0b, - 0x06, 0x0c, 0x61, 0x03, 0x5f, 0x61, 0x03, 0x5f, 0x03df, 0x03db, 0x03d7, - 0x0422, 0x0427, 0x042b}, - { - 13, 2472, 0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, 0x09, 0x0a, - 0x06, 0x0b, 0x61, 0x03, 0x4f, 0x61, 0x03, 0x4f, 0x03e1, 0x03dd, 0x03d9, - 0x0420, 0x0424, 0x0429}, - { - 14, 2484, 0x78, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xb4, 0x09, 0x0a, - 0x06, 0x0b, 0x61, 0x03, 0x3f, 0x61, 0x03, 0x3f, 0x03e6, 0x03e2, 0x03de, - 0x041b, 0x041f, 0x0424} -}; - -static const struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev7[] = { - { - 184, 4920, 0x68, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xec, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07b4, 0x07b0, 0x07ac, 0x0214, - 0x0215, - 0x0216}, - { - 186, 4930, 0x6b, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xed, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07b8, 0x07b4, 0x07b0, 0x0213, - 0x0214, - 0x0215}, - { - 188, 4940, 0x6e, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xee, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07bc, 0x07b8, 0x07b4, 0x0212, - 0x0213, - 0x0214}, - { - 190, 4950, 0x72, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xef, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c0, 0x07bc, 0x07b8, 0x0211, - 0x0212, - 0x0213}, - { - 192, 4960, 0x75, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf0, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c4, 0x07c0, 0x07bc, 0x020f, - 0x0211, - 0x0212}, - { - 194, 4970, 0x78, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf1, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c8, 0x07c4, 0x07c0, 0x020e, - 0x020f, - 0x0211}, - { - 196, 4980, 0x7c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf2, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07cc, 0x07c8, 0x07c4, 0x020d, - 0x020e, - 0x020f}, - { - 198, 4990, 0x7f, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf3, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07d0, 0x07cc, 0x07c8, 0x020c, - 0x020d, - 0x020e}, - { - 200, 5000, 0x82, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf4, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07d4, 0x07d0, 0x07cc, 0x020b, - 0x020c, - 0x020d}, - { - 202, 5010, 0x86, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf5, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07d8, 0x07d4, 0x07d0, 0x020a, - 0x020b, - 0x020c}, - { - 204, 5020, 0x89, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf6, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07dc, 0x07d8, 0x07d4, 0x0209, - 0x020a, - 0x020b}, - { - 206, 5030, 0x8c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf7, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e0, 0x07dc, 0x07d8, 0x0208, - 0x0209, - 0x020a}, - { - 208, 5040, 0x90, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf8, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e4, 0x07e0, 0x07dc, 0x0207, - 0x0208, - 0x0209}, - { - 210, 5050, 0x93, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf9, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e8, 0x07e4, 0x07e0, 0x0206, - 0x0207, - 0x0208}, - { - 212, 5060, 0x96, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfa, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07ec, 0x07e8, 0x07e4, 0x0205, - 0x0206, - 0x0207}, - { - 214, 5070, 0x9a, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfb, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f0, 0x07ec, 0x07e8, 0x0204, - 0x0205, - 0x0206}, - { - 216, 5080, 0x9d, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfc, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f4, 0x07f0, 0x07ec, 0x0203, - 0x0204, - 0x0205}, - { - 218, 5090, 0xa0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfd, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f8, 0x07f4, 0x07f0, 0x0202, - 0x0203, - 0x0204}, - { - 220, 5100, 0xa4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfe, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x07fc, 0x07f8, 0x07f4, 0x0201, - 0x0202, - 0x0203}, - { - 222, 5110, 0xa7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xff, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0800, 0x07fc, 0x07f8, 0x0200, - 0x0201, - 0x0202}, - { - 224, 5120, 0xaa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x00, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0804, 0x0800, 0x07fc, 0x01ff, - 0x0200, - 0x0201}, - { - 226, 5130, 0xae, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x01, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0808, 0x0804, 0x0800, 0x01fe, - 0x01ff, - 0x0200}, - { - 228, 5140, 0xb1, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x02, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x080c, 0x0808, 0x0804, 0x01fd, - 0x01fe, - 0x01ff}, - { - 32, 5160, 0xb8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x04, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0814, 0x0810, 0x080c, 0x01fb, - 0x01fc, - 0x01fd}, - { - 34, 5170, 0xbb, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x05, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0818, 0x0814, 0x0810, 0x01fa, - 0x01fb, - 0x01fc}, - { - 36, 5180, 0xbe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x06, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x081c, 0x0818, 0x0814, 0x01f9, - 0x01fa, - 0x01fb}, - { - 38, 5190, 0xc2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x07, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0820, 0x081c, 0x0818, 0x01f8, - 0x01f9, - 0x01fa}, - { - 40, 5200, 0xc5, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x08, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0824, 0x0820, 0x081c, 0x01f7, - 0x01f8, - 0x01f9}, - { - 42, 5210, 0xc8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x09, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0828, 0x0824, 0x0820, 0x01f6, - 0x01f7, - 0x01f8}, - { - 44, 5220, 0xcc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0a, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x082c, 0x0828, 0x0824, 0x01f5, - 0x01f6, - 0x01f7}, - { - 46, 5230, 0xcf, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0b, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0830, 0x082c, 0x0828, 0x01f4, - 0x01f5, - 0x01f6}, - { - 48, 5240, 0xd2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0c, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0834, 0x0830, 0x082c, 0x01f3, - 0x01f4, - 0x01f5}, - { - 50, 5250, 0xd6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0d, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0838, 0x0834, 0x0830, 0x01f2, - 0x01f3, - 0x01f4}, - { - 52, 5260, 0xd9, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0e, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x083c, 0x0838, 0x0834, 0x01f1, - 0x01f2, - 0x01f3}, - { - 54, 5270, 0xdc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0f, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0840, 0x083c, 0x0838, 0x01f0, - 0x01f1, - 0x01f2}, - { - 56, 5280, 0xe0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x10, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0844, 0x0840, 0x083c, 0x01f0, - 0x01f0, - 0x01f1}, - { - 58, 5290, 0xe3, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x11, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0848, 0x0844, 0x0840, 0x01ef, - 0x01f0, - 0x01f0}, - { - 60, 5300, 0xe6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x12, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x084c, 0x0848, 0x0844, 0x01ee, - 0x01ef, - 0x01f0}, - { - 62, 5310, 0xea, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x13, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0850, 0x084c, 0x0848, 0x01ed, - 0x01ee, - 0x01ef}, - { - 64, 5320, 0xed, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x14, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0854, 0x0850, 0x084c, 0x01ec, - 0x01ed, - 0x01ee}, - { - 66, 5330, 0xf0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x15, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0858, 0x0854, 0x0850, 0x01eb, - 0x01ec, - 0x01ed}, - { - 68, 5340, 0xf4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x16, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x085c, 0x0858, 0x0854, 0x01ea, - 0x01eb, - 0x01ec}, - { - 70, 5350, 0xf7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x17, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0860, 0x085c, 0x0858, 0x01e9, - 0x01ea, - 0x01eb}, - { - 72, 5360, 0xfa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x18, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0864, 0x0860, 0x085c, 0x01e8, - 0x01e9, - 0x01ea}, - { - 74, 5370, 0xfe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x19, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0868, 0x0864, 0x0860, 0x01e7, - 0x01e8, - 0x01e9}, - { - 76, 5380, 0x01, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1a, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x086c, 0x0868, 0x0864, 0x01e6, - 0x01e7, - 0x01e8}, - { - 78, 5390, 0x04, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1b, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0870, 0x086c, 0x0868, 0x01e5, - 0x01e6, - 0x01e7}, - { - 80, 5400, 0x08, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1c, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0874, 0x0870, 0x086c, 0x01e5, - 0x01e5, - 0x01e6}, - { - 82, 5410, 0x0b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1d, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0878, 0x0874, 0x0870, 0x01e4, - 0x01e5, - 0x01e5}, - { - 84, 5420, 0x0e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1e, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x087c, 0x0878, 0x0874, 0x01e3, - 0x01e4, - 0x01e5}, - { - 86, 5430, 0x12, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1f, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0880, 0x087c, 0x0878, 0x01e2, - 0x01e3, - 0x01e4}, - { - 88, 5440, 0x15, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x20, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0884, 0x0880, 0x087c, 0x01e1, - 0x01e2, - 0x01e3}, - { - 90, 5450, 0x18, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x21, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0888, 0x0884, 0x0880, 0x01e0, - 0x01e1, - 0x01e2}, - { - 92, 5460, 0x1c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x22, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x088c, 0x0888, 0x0884, 0x01df, - 0x01e0, - 0x01e1}, - { - 94, 5470, 0x1f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x23, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0890, 0x088c, 0x0888, 0x01de, - 0x01df, - 0x01e0}, - { - 96, 5480, 0x22, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x24, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0894, 0x0890, 0x088c, 0x01dd, - 0x01de, - 0x01df}, - { - 98, 5490, 0x26, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x25, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0898, 0x0894, 0x0890, 0x01dd, - 0x01dd, - 0x01de}, - { - 100, 5500, 0x29, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x26, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x089c, 0x0898, 0x0894, 0x01dc, - 0x01dd, - 0x01dd}, - { - 102, 5510, 0x2c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x27, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a0, 0x089c, 0x0898, 0x01db, - 0x01dc, - 0x01dd}, - { - 104, 5520, 0x30, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x28, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a4, 0x08a0, 0x089c, 0x01da, - 0x01db, - 0x01dc}, - { - 106, 5530, 0x33, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x29, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a8, 0x08a4, 0x08a0, 0x01d9, - 0x01da, - 0x01db}, - { - 108, 5540, 0x36, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2a, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08ac, 0x08a8, 0x08a4, 0x01d8, - 0x01d9, - 0x01da}, - { - 110, 5550, 0x3a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2b, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b0, 0x08ac, 0x08a8, 0x01d7, - 0x01d8, - 0x01d9}, - { - 112, 5560, 0x3d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2c, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b4, 0x08b0, 0x08ac, 0x01d7, - 0x01d7, - 0x01d8}, - { - 114, 5570, 0x40, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2d, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b8, 0x08b4, 0x08b0, 0x01d6, - 0x01d7, - 0x01d7}, - { - 116, 5580, 0x44, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2e, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08bc, 0x08b8, 0x08b4, 0x01d5, - 0x01d6, - 0x01d7}, - { - 118, 5590, 0x47, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2f, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08c0, 0x08bc, 0x08b8, 0x01d4, - 0x01d5, - 0x01d6}, - { - 120, 5600, 0x4a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x30, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08c4, 0x08c0, 0x08bc, 0x01d3, - 0x01d4, - 0x01d5}, - { - 122, 5610, 0x4e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x31, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08c8, 0x08c4, 0x08c0, 0x01d2, - 0x01d3, - 0x01d4}, - { - 124, 5620, 0x51, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x32, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08cc, 0x08c8, 0x08c4, 0x01d2, - 0x01d2, - 0x01d3}, - { - 126, 5630, 0x54, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x33, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08d0, 0x08cc, 0x08c8, 0x01d1, - 0x01d2, - 0x01d2}, - { - 128, 5640, 0x58, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x34, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08d4, 0x08d0, 0x08cc, 0x01d0, - 0x01d1, - 0x01d2}, - { - 130, 5650, 0x5b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x35, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08d8, 0x08d4, 0x08d0, 0x01cf, - 0x01d0, - 0x01d1}, - { - 132, 5660, 0x5e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x36, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08dc, 0x08d8, 0x08d4, 0x01ce, - 0x01cf, - 0x01d0}, - { - 134, 5670, 0x62, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x37, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08e0, 0x08dc, 0x08d8, 0x01ce, - 0x01ce, - 0x01cf}, - { - 136, 5680, 0x65, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x38, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x08e4, 0x08e0, 0x08dc, 0x01cd, - 0x01ce, - 0x01ce}, - { - 138, 5690, 0x68, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x39, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x08e8, 0x08e4, 0x08e0, 0x01cc, - 0x01cd, - 0x01ce}, - { - 140, 5700, 0x6c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3a, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08ec, 0x08e8, 0x08e4, 0x01cb, - 0x01cc, - 0x01cd}, - { - 142, 5710, 0x6f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3b, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f0, 0x08ec, 0x08e8, 0x01ca, - 0x01cb, - 0x01cc}, - { - 144, 5720, 0x72, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3c, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f4, 0x08f0, 0x08ec, 0x01c9, - 0x01ca, - 0x01cb}, - { - 145, 5725, 0x74, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x79, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f6, 0x08f2, 0x08ee, 0x01c9, - 0x01ca, - 0x01cb}, - { - 146, 5730, 0x76, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3d, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f8, 0x08f4, 0x08f0, 0x01c9, - 0x01c9, - 0x01ca}, - { - 147, 5735, 0x77, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7b, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fa, 0x08f6, 0x08f2, 0x01c8, - 0x01c9, - 0x01ca}, - { - 148, 5740, 0x79, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3e, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fc, 0x08f8, 0x08f4, 0x01c8, - 0x01c9, - 0x01c9}, - { - 149, 5745, 0x7b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7d, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fe, 0x08fa, 0x08f6, 0x01c8, - 0x01c8, - 0x01c9}, - { - 150, 5750, 0x7c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3f, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, - 0x01c8, - 0x01c9}, - { - 151, 5755, 0x7e, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7f, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, - 0x01c8, - 0x01c8}, - { - 152, 5760, 0x80, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x40, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, - 0x01c7, - 0x01c8}, - { - 153, 5765, 0x81, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x81, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, - 0x01c7, - 0x01c8}, - { - 154, 5770, 0x83, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x41, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, - 0x01c6, - 0x01c7}, - { - 155, 5775, 0x85, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x83, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, - 0x01c6, - 0x01c7}, - { - 156, 5780, 0x86, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x42, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, - 0x01c6, - 0x01c6}, - { - 157, 5785, 0x88, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x85, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, - 0x01c5, - 0x01c6}, - { - 158, 5790, 0x8a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x43, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, - 0x01c5, - 0x01c6}, - { - 159, 5795, 0x8b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x87, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, - 0x01c4, - 0x01c5}, - { - 160, 5800, 0x8d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x44, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x01, 0x03, 0x00, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, - 0x01c4, - 0x01c5}, - { - 161, 5805, 0x8f, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x89, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, - 0x01c4, - 0x01c4}, - { - 162, 5810, 0x90, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x45, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, - 0x01c3, - 0x01c4}, - { - 163, 5815, 0x92, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8b, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, - 0x01c3, - 0x01c4}, - { - 164, 5820, 0x94, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x46, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, - 0x01c2, - 0x01c3}, - { - 165, 5825, 0x95, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8d, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, - 0x01c2, - 0x01c3}, - { - 166, 5830, 0x97, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x47, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, - 0x01c2, - 0x01c2}, - { - 168, 5840, 0x9a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x48, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, - 0x01c1, - 0x01c2}, - { - 170, 5850, 0x9e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x49, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, - 0x01c0, - 0x01c1}, - { - 172, 5860, 0xa1, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4a, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, - 0x01bf, - 0x01c0}, - { - 174, 5870, 0xa4, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4b, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, - 0x01bf, - 0x01bf}, - { - 176, 5880, 0xa8, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4c, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, - 0x01be, - 0x01bf}, - { - 178, 5890, 0xab, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4d, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, - 0x01bd, - 0x01be}, - { - 180, 5900, 0xae, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4e, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, - 0x01bc, - 0x01bd}, - { - 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03c9, 0x03c5, 0x03c1, 0x043a, - 0x043f, - 0x0443}, - { - 2, 2417, 0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cb, 0x03c7, 0x03c3, 0x0438, - 0x043d, - 0x0441}, - { - 3, 2422, 0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cd, 0x03c9, 0x03c5, 0x0436, - 0x043a, - 0x043f}, - { - 4, 2427, 0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cf, 0x03cb, 0x03c7, 0x0434, - 0x0438, - 0x043d}, - { - 5, 2432, 0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d1, 0x03cd, 0x03c9, 0x0431, - 0x0436, - 0x043a}, - { - 6, 2437, 0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d3, 0x03cf, 0x03cb, 0x042f, - 0x0434, - 0x0438}, - { - 7, 2442, 0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d5, 0x03d1, 0x03cd, 0x042d, - 0x0431, - 0x0436}, - { - 8, 2447, 0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d7, 0x03d3, 0x03cf, 0x042b, - 0x042f, - 0x0434}, - { - 9, 2452, 0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d9, 0x03d5, 0x03d1, 0x0429, - 0x042d, - 0x0431}, - { - 10, 2457, 0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03db, 0x03d7, 0x03d3, 0x0427, - 0x042b, - 0x042f}, - { - 11, 2462, 0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03dd, 0x03d9, 0x03d5, 0x0424, - 0x0429, - 0x042d}, - { - 12, 2467, 0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03df, 0x03db, 0x03d7, 0x0422, - 0x0427, - 0x042b}, - { - 13, 2472, 0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03e1, 0x03dd, 0x03d9, 0x0420, - 0x0424, - 0x0429}, - { - 14, 2484, 0x78, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xb4, 0x09, 0x0f, - 0x04, 0x00, 0x04, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x03e6, 0x03e2, 0x03de, 0x041b, - 0x041f, - 0x0424} -}; - -static const struct chan_info_nphy_radio2057 chan_info_nphyrev8_2057_rev8[] = { - { - 186, 4930, 0x6b, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xed, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07b8, 0x07b4, 0x07b0, 0x0213, - 0x0214, - 0x0215}, - { - 188, 4940, 0x6e, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xee, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0xd3, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07bc, 0x07b8, 0x07b4, 0x0212, - 0x0213, - 0x0214}, - { - 190, 4950, 0x72, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xef, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c0, 0x07bc, 0x07b8, 0x0211, - 0x0212, - 0x0213}, - { - 192, 4960, 0x75, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf0, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c4, 0x07c0, 0x07bc, 0x020f, - 0x0211, - 0x0212}, - { - 194, 4970, 0x78, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf1, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07c8, 0x07c4, 0x07c0, 0x020e, - 0x020f, - 0x0211}, - { - 196, 4980, 0x7c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf2, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07cc, 0x07c8, 0x07c4, 0x020d, - 0x020e, - 0x020f}, - { - 198, 4990, 0x7f, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf3, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xd3, 0x00, 0xff, 0x07d0, 0x07cc, 0x07c8, 0x020c, - 0x020d, - 0x020e}, - { - 200, 5000, 0x82, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf4, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07d4, 0x07d0, 0x07cc, 0x020b, - 0x020c, - 0x020d}, - { - 202, 5010, 0x86, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf5, 0x01, 0x0f, - 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07d8, 0x07d4, 0x07d0, 0x020a, - 0x020b, - 0x020c}, - { - 204, 5020, 0x89, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf6, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07dc, 0x07d8, 0x07d4, 0x0209, - 0x020a, - 0x020b}, - { - 206, 5030, 0x8c, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf7, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e0, 0x07dc, 0x07d8, 0x0208, - 0x0209, - 0x020a}, - { - 208, 5040, 0x90, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf8, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e4, 0x07e0, 0x07dc, 0x0207, - 0x0208, - 0x0209}, - { - 210, 5050, 0x93, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xf9, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07e8, 0x07e4, 0x07e0, 0x0206, - 0x0207, - 0x0208}, - { - 212, 5060, 0x96, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfa, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07ec, 0x07e8, 0x07e4, 0x0205, - 0x0206, - 0x0207}, - { - 214, 5070, 0x9a, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfb, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f0, 0x07ec, 0x07e8, 0x0204, - 0x0205, - 0x0206}, - { - 216, 5080, 0x9d, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfc, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f4, 0x07f0, 0x07ec, 0x0203, - 0x0204, - 0x0205}, - { - 218, 5090, 0xa0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfd, 0x01, 0x0e, - 0x00, 0x0e, 0x00, 0xee, 0x00, 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x00, - 0x00, 0x0f, 0x0f, 0xb3, 0x00, 0xff, 0x07f8, 0x07f4, 0x07f0, 0x0202, - 0x0203, - 0x0204}, - { - 220, 5100, 0xa4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xfe, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x07fc, 0x07f8, 0x07f4, 0x0201, - 0x0202, - 0x0203}, - { - 222, 5110, 0xa7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0xff, 0x01, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0800, 0x07fc, 0x07f8, 0x0200, - 0x0201, - 0x0202}, - { - 224, 5120, 0xaa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x00, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0804, 0x0800, 0x07fc, 0x01ff, - 0x0200, - 0x0201}, - { - 226, 5130, 0xae, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x01, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0808, 0x0804, 0x0800, 0x01fe, - 0x01ff, - 0x0200}, - { - 228, 5140, 0xb1, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x02, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x080c, 0x0808, 0x0804, 0x01fd, - 0x01fe, - 0x01ff}, - { - 32, 5160, 0xb8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x04, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0814, 0x0810, 0x080c, 0x01fb, - 0x01fc, - 0x01fd}, - { - 34, 5170, 0xbb, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x05, 0x02, 0x0d, - 0x00, 0x0d, 0x00, 0xdd, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0818, 0x0814, 0x0810, 0x01fa, - 0x01fb, - 0x01fc}, - { - 36, 5180, 0xbe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x06, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x081c, 0x0818, 0x0814, 0x01f9, - 0x01fa, - 0x01fb}, - { - 38, 5190, 0xc2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x07, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x00, - 0x00, 0x0f, 0x0f, 0xa3, 0x00, 0xfc, 0x0820, 0x081c, 0x0818, 0x01f8, - 0x01f9, - 0x01fa}, - { - 40, 5200, 0xc5, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x08, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0824, 0x0820, 0x081c, 0x01f7, - 0x01f8, - 0x01f9}, - { - 42, 5210, 0xc8, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x09, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0828, 0x0824, 0x0820, 0x01f6, - 0x01f7, - 0x01f8}, - { - 44, 5220, 0xcc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0a, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x082c, 0x0828, 0x0824, 0x01f5, - 0x01f6, - 0x01f7}, - { - 46, 5230, 0xcf, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0b, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0830, 0x082c, 0x0828, 0x01f4, - 0x01f5, - 0x01f6}, - { - 48, 5240, 0xd2, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0c, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0834, 0x0830, 0x082c, 0x01f3, - 0x01f4, - 0x01f5}, - { - 50, 5250, 0xd6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0d, 0x02, 0x0c, - 0x00, 0x0c, 0x00, 0xcc, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0838, 0x0834, 0x0830, 0x01f2, - 0x01f3, - 0x01f4}, - { - 52, 5260, 0xd9, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0e, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x083c, 0x0838, 0x0834, 0x01f1, - 0x01f2, - 0x01f3}, - { - 54, 5270, 0xdc, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x0f, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0840, 0x083c, 0x0838, 0x01f0, - 0x01f1, - 0x01f2}, - { - 56, 5280, 0xe0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x10, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0844, 0x0840, 0x083c, 0x01f0, - 0x01f0, - 0x01f1}, - { - 58, 5290, 0xe3, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x11, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x00, - 0x00, 0x0f, 0x0f, 0x93, 0x00, 0xf8, 0x0848, 0x0844, 0x0840, 0x01ef, - 0x01f0, - 0x01f0}, - { - 60, 5300, 0xe6, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x12, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x084c, 0x0848, 0x0844, 0x01ee, - 0x01ef, - 0x01f0}, - { - 62, 5310, 0xea, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x13, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0850, 0x084c, 0x0848, 0x01ed, - 0x01ee, - 0x01ef}, - { - 64, 5320, 0xed, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x14, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0854, 0x0850, 0x084c, 0x01ec, - 0x01ed, - 0x01ee}, - { - 66, 5330, 0xf0, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x15, 0x02, 0x0b, - 0x00, 0x0b, 0x00, 0xbb, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0858, 0x0854, 0x0850, 0x01eb, - 0x01ec, - 0x01ed}, - { - 68, 5340, 0xf4, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x16, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x085c, 0x0858, 0x0854, 0x01ea, - 0x01eb, - 0x01ec}, - { - 70, 5350, 0xf7, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x17, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0860, 0x085c, 0x0858, 0x01e9, - 0x01ea, - 0x01eb}, - { - 72, 5360, 0xfa, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x18, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0864, 0x0860, 0x085c, 0x01e8, - 0x01e9, - 0x01ea}, - { - 74, 5370, 0xfe, 0x16, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x19, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0868, 0x0864, 0x0860, 0x01e7, - 0x01e8, - 0x01e9}, - { - 76, 5380, 0x01, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1a, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x086c, 0x0868, 0x0864, 0x01e6, - 0x01e7, - 0x01e8}, - { - 78, 5390, 0x04, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1b, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x00, - 0x00, 0x0f, 0x0c, 0x83, 0x00, 0xf5, 0x0870, 0x086c, 0x0868, 0x01e5, - 0x01e6, - 0x01e7}, - { - 80, 5400, 0x08, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1c, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0874, 0x0870, 0x086c, 0x01e5, - 0x01e5, - 0x01e6}, - { - 82, 5410, 0x0b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1d, 0x02, 0x0a, - 0x00, 0x0a, 0x00, 0xaa, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0878, 0x0874, 0x0870, 0x01e4, - 0x01e5, - 0x01e5}, - { - 84, 5420, 0x0e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1e, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x087c, 0x0878, 0x0874, 0x01e3, - 0x01e4, - 0x01e5}, - { - 86, 5430, 0x12, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x1f, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0880, 0x087c, 0x0878, 0x01e2, - 0x01e3, - 0x01e4}, - { - 88, 5440, 0x15, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x20, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0884, 0x0880, 0x087c, 0x01e1, - 0x01e2, - 0x01e3}, - { - 90, 5450, 0x18, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x21, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0888, 0x0884, 0x0880, 0x01e0, - 0x01e1, - 0x01e2}, - { - 92, 5460, 0x1c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x22, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x088c, 0x0888, 0x0884, 0x01df, - 0x01e0, - 0x01e1}, - { - 94, 5470, 0x1f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x23, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0890, 0x088c, 0x0888, 0x01de, - 0x01df, - 0x01e0}, - { - 96, 5480, 0x22, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x24, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0894, 0x0890, 0x088c, 0x01dd, - 0x01de, - 0x01df}, - { - 98, 5490, 0x26, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x25, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x00, - 0x00, 0x0d, 0x09, 0x53, 0x00, 0xb1, 0x0898, 0x0894, 0x0890, 0x01dd, - 0x01dd, - 0x01de}, - { - 100, 5500, 0x29, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x26, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x089c, 0x0898, 0x0894, 0x01dc, - 0x01dd, - 0x01dd}, - { - 102, 5510, 0x2c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x27, 0x02, 0x09, - 0x00, 0x09, 0x00, 0x99, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a0, 0x089c, 0x0898, 0x01db, - 0x01dc, - 0x01dd}, - { - 104, 5520, 0x30, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x28, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a4, 0x08a0, 0x089c, 0x01da, - 0x01db, - 0x01dc}, - { - 106, 5530, 0x33, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x29, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08a8, 0x08a4, 0x08a0, 0x01d9, - 0x01da, - 0x01db}, - { - 108, 5540, 0x36, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2a, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08ac, 0x08a8, 0x08a4, 0x01d8, - 0x01d9, - 0x01da}, - { - 110, 5550, 0x3a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2b, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b0, 0x08ac, 0x08a8, 0x01d7, - 0x01d8, - 0x01d9}, - { - 112, 5560, 0x3d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2c, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b4, 0x08b0, 0x08ac, 0x01d7, - 0x01d7, - 0x01d8}, - { - 114, 5570, 0x40, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2d, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08b8, 0x08b4, 0x08b0, 0x01d6, - 0x01d7, - 0x01d7}, - { - 116, 5580, 0x44, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2e, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08bc, 0x08b8, 0x08b4, 0x01d5, - 0x01d6, - 0x01d7}, - { - 118, 5590, 0x47, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x2f, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x00, - 0x00, 0x0a, 0x06, 0x43, 0x00, 0x80, 0x08c0, 0x08bc, 0x08b8, 0x01d4, - 0x01d5, - 0x01d6}, - { - 120, 5600, 0x4a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x30, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08c4, 0x08c0, 0x08bc, 0x01d3, - 0x01d4, - 0x01d5}, - { - 122, 5610, 0x4e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x31, 0x02, 0x08, - 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08c8, 0x08c4, 0x08c0, 0x01d2, - 0x01d3, - 0x01d4}, - { - 124, 5620, 0x51, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x32, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08cc, 0x08c8, 0x08c4, 0x01d2, - 0x01d2, - 0x01d3}, - { - 126, 5630, 0x54, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x33, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08d0, 0x08cc, 0x08c8, 0x01d1, - 0x01d2, - 0x01d2}, - { - 128, 5640, 0x58, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x34, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x04, 0x23, 0x00, 0x60, 0x08d4, 0x08d0, 0x08cc, 0x01d0, - 0x01d1, - 0x01d2}, - { - 130, 5650, 0x5b, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x35, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08d8, 0x08d4, 0x08d0, 0x01cf, - 0x01d0, - 0x01d1}, - { - 132, 5660, 0x5e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x36, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08dc, 0x08d8, 0x08d4, 0x01ce, - 0x01cf, - 0x01d0}, - { - 134, 5670, 0x62, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x37, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x03, 0x23, 0x00, 0x60, 0x08e0, 0x08dc, 0x08d8, 0x01ce, - 0x01ce, - 0x01cf}, - { - 136, 5680, 0x65, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x38, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x08e4, 0x08e0, 0x08dc, 0x01cd, - 0x01ce, - 0x01ce}, - { - 138, 5690, 0x68, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x39, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x00, - 0x00, 0x09, 0x02, 0x23, 0x00, 0x60, 0x08e8, 0x08e4, 0x08e0, 0x01cc, - 0x01cd, - 0x01ce}, - { - 140, 5700, 0x6c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3a, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08ec, 0x08e8, 0x08e4, 0x01cb, - 0x01cc, - 0x01cd}, - { - 142, 5710, 0x6f, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3b, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f0, 0x08ec, 0x08e8, 0x01ca, - 0x01cb, - 0x01cc}, - { - 144, 5720, 0x72, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3c, 0x02, 0x07, - 0x00, 0x07, 0x00, 0x77, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f4, 0x08f0, 0x08ec, 0x01c9, - 0x01ca, - 0x01cb}, - { - 145, 5725, 0x74, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x79, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f6, 0x08f2, 0x08ee, 0x01c9, - 0x01ca, - 0x01cb}, - { - 146, 5730, 0x76, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3d, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08f8, 0x08f4, 0x08f0, 0x01c9, - 0x01c9, - 0x01ca}, - { - 147, 5735, 0x77, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7b, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fa, 0x08f6, 0x08f2, 0x01c8, - 0x01c9, - 0x01ca}, - { - 148, 5740, 0x79, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3e, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fc, 0x08f8, 0x08f4, 0x01c8, - 0x01c9, - 0x01c9}, - { - 149, 5745, 0x7b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7d, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x30, 0x08fe, 0x08fa, 0x08f6, 0x01c8, - 0x01c8, - 0x01c9}, - { - 150, 5750, 0x7c, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x3f, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0900, 0x08fc, 0x08f8, 0x01c7, - 0x01c8, - 0x01c9}, - { - 151, 5755, 0x7e, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x7f, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0902, 0x08fe, 0x08fa, 0x01c7, - 0x01c8, - 0x01c8}, - { - 152, 5760, 0x80, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x40, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0904, 0x0900, 0x08fc, 0x01c6, - 0x01c7, - 0x01c8}, - { - 153, 5765, 0x81, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x81, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0906, 0x0902, 0x08fe, 0x01c6, - 0x01c7, - 0x01c8}, - { - 154, 5770, 0x83, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x41, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0908, 0x0904, 0x0900, 0x01c6, - 0x01c6, - 0x01c7}, - { - 155, 5775, 0x85, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x83, 0x04, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090a, 0x0906, 0x0902, 0x01c5, - 0x01c6, - 0x01c7}, - { - 156, 5780, 0x86, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x42, 0x02, 0x06, - 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090c, 0x0908, 0x0904, 0x01c5, - 0x01c6, - 0x01c6}, - { - 157, 5785, 0x88, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x85, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x090e, 0x090a, 0x0906, 0x01c4, - 0x01c5, - 0x01c6}, - { - 158, 5790, 0x8a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x43, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0910, 0x090c, 0x0908, 0x01c4, - 0x01c5, - 0x01c6}, - { - 159, 5795, 0x8b, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x87, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x02, 0x13, 0x00, 0x00, 0x0912, 0x090e, 0x090a, 0x01c4, - 0x01c4, - 0x01c5}, - { - 160, 5800, 0x8d, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x44, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x08, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x01, 0x03, 0x00, 0x00, 0x0914, 0x0910, 0x090c, 0x01c3, - 0x01c4, - 0x01c5}, - { - 161, 5805, 0x8f, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x89, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0916, 0x0912, 0x090e, 0x01c3, - 0x01c4, - 0x01c4}, - { - 162, 5810, 0x90, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x45, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0918, 0x0914, 0x0910, 0x01c2, - 0x01c3, - 0x01c4}, - { - 163, 5815, 0x92, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8b, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091a, 0x0916, 0x0912, 0x01c2, - 0x01c3, - 0x01c4}, - { - 164, 5820, 0x94, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x46, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091c, 0x0918, 0x0914, 0x01c2, - 0x01c2, - 0x01c3}, - { - 165, 5825, 0x95, 0x17, 0x20, 0x14, 0x08, 0x08, 0x30, 0x8d, 0x04, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x091e, 0x091a, 0x0916, 0x01c1, - 0x01c2, - 0x01c3}, - { - 166, 5830, 0x97, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x47, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0920, 0x091c, 0x0918, 0x01c1, - 0x01c2, - 0x01c2}, - { - 168, 5840, 0x9a, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x48, 0x02, 0x05, - 0x00, 0x05, 0x00, 0x55, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0924, 0x0920, 0x091c, 0x01c0, - 0x01c1, - 0x01c2}, - { - 170, 5850, 0x9e, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x49, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0928, 0x0924, 0x0920, 0x01bf, - 0x01c0, - 0x01c1}, - { - 172, 5860, 0xa1, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4a, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x092c, 0x0928, 0x0924, 0x01bf, - 0x01bf, - 0x01c0}, - { - 174, 5870, 0xa4, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4b, 0x02, 0x04, - 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0930, 0x092c, 0x0928, 0x01be, - 0x01bf, - 0x01bf}, - { - 176, 5880, 0xa8, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4c, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0934, 0x0930, 0x092c, 0x01bd, - 0x01be, - 0x01bf}, - { - 178, 5890, 0xab, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4d, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x0938, 0x0934, 0x0930, 0x01bc, - 0x01bd, - 0x01be}, - { - 180, 5900, 0xae, 0x17, 0x10, 0x0c, 0x0c, 0x0c, 0x30, 0x4e, 0x02, 0x03, - 0x00, 0x03, 0x00, 0x33, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x093c, 0x0938, 0x0934, 0x01bc, - 0x01bc, - 0x01bd}, - { - 1, 2412, 0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03c9, 0x03c5, 0x03c1, 0x043a, - 0x043f, - 0x0443}, - { - 2, 2417, 0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, 0x09, 0x0f, - 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cb, 0x03c7, 0x03c3, 0x0438, - 0x043d, - 0x0441}, - { - 3, 2422, 0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cd, 0x03c9, 0x03c5, 0x0436, - 0x043a, - 0x043f}, - { - 4, 2427, 0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, 0x09, 0x0f, - 0x09, 0x00, 0x09, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03cf, 0x03cb, 0x03c7, 0x0434, - 0x0438, - 0x043d}, - { - 5, 2432, 0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d1, 0x03cd, 0x03c9, 0x0431, - 0x0436, - 0x043a}, - { - 6, 2437, 0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, 0x09, 0x0f, - 0x08, 0x00, 0x08, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d3, 0x03cf, 0x03cb, 0x042f, - 0x0434, - 0x0438}, - { - 7, 2442, 0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d5, 0x03d1, 0x03cd, 0x042d, - 0x0431, - 0x0436}, - { - 8, 2447, 0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d7, 0x03d3, 0x03cf, 0x042b, - 0x042f, - 0x0434}, - { - 9, 2452, 0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, 0x09, 0x0f, - 0x07, 0x00, 0x07, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03d9, 0x03d5, 0x03d1, 0x0429, - 0x042d, - 0x0431}, - { - 10, 2457, 0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03db, 0x03d7, 0x03d3, 0x0427, - 0x042b, - 0x042f}, - { - 11, 2462, 0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, 0x09, 0x0f, - 0x06, 0x00, 0x06, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03dd, 0x03d9, 0x03d5, 0x0424, - 0x0429, - 0x042d}, - { - 12, 2467, 0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03df, 0x03db, 0x03d7, 0x0422, - 0x0427, - 0x042b}, - { - 13, 2472, 0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, 0x09, 0x0f, - 0x05, 0x00, 0x05, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x03e1, 0x03dd, 0x03d9, 0x0420, - 0x0424, - 0x0429}, - { - 14, 2484, 0x78, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xb4, 0x09, 0x0f, - 0x04, 0x00, 0x04, 0x00, 0x61, 0x73, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x61, - 0x73, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x03e6, 0x03e2, 0x03de, 0x041b, - 0x041f, - 0x0424} -}; - -static struct radio_regs regs_2055[] = { - {0x02, 0x80, 0x80, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0x27, 0x27, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0x27, 0x27, 0, 0}, - {0x07, 0x7f, 0x7f, 1, 1}, - {0x08, 0x7, 0x7, 1, 1}, - {0x09, 0x7f, 0x7f, 1, 1}, - {0x0A, 0x7, 0x7, 1, 1}, - {0x0B, 0x15, 0x15, 0, 0}, - {0x0C, 0x15, 0x15, 0, 0}, - {0x0D, 0x4f, 0x4f, 1, 1}, - {0x0E, 0x5, 0x5, 1, 1}, - {0x0F, 0x4f, 0x4f, 1, 1}, - {0x10, 0x5, 0x5, 1, 1}, - {0x11, 0xd0, 0xd0, 0, 0}, - {0x12, 0x2, 0x2, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0x40, 0x40, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0xc0, 0xc0, 0, 0}, - {0x1E, 0xff, 0xff, 0, 0}, - {0x1F, 0xc0, 0xc0, 0, 0}, - {0x20, 0xff, 0xff, 0, 0}, - {0x21, 0xc0, 0xc0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x2c, 0x2c, 0, 0}, - {0x24, 0, 0, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0xa4, 0xa4, 0, 0}, - {0x2E, 0x38, 0x38, 0, 0}, - {0x2F, 0, 0, 0, 0}, - {0x30, 0x4, 0x4, 1, 1}, - {0x31, 0, 0, 0, 0}, - {0x32, 0xa, 0xa, 0, 0}, - {0x33, 0x87, 0x87, 0, 0}, - {0x34, 0x9, 0x9, 0, 0}, - {0x35, 0x70, 0x70, 0, 0}, - {0x36, 0x11, 0x11, 0, 0}, - {0x37, 0x18, 0x18, 1, 1}, - {0x38, 0x6, 0x6, 0, 0}, - {0x39, 0x4, 0x4, 1, 1}, - {0x3A, 0x6, 0x6, 0, 0}, - {0x3B, 0x9e, 0x9e, 0, 0}, - {0x3C, 0x9, 0x9, 0, 0}, - {0x3D, 0xc8, 0xc8, 1, 1}, - {0x3E, 0x88, 0x88, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0, 0, 0, 0}, - {0x42, 0x1, 0x1, 0, 0}, - {0x43, 0x2, 0x2, 0, 0}, - {0x44, 0x96, 0x96, 0, 0}, - {0x45, 0x3e, 0x3e, 0, 0}, - {0x46, 0x3e, 0x3e, 0, 0}, - {0x47, 0x13, 0x13, 0, 0}, - {0x48, 0x2, 0x2, 0, 0}, - {0x49, 0x15, 0x15, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0, 0, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0, 0, 0, 0}, - {0x50, 0x8, 0x8, 0, 0}, - {0x51, 0x8, 0x8, 0, 0}, - {0x52, 0x6, 0x6, 0, 0}, - {0x53, 0x84, 0x84, 1, 1}, - {0x54, 0xc3, 0xc3, 0, 0}, - {0x55, 0x8f, 0x8f, 0, 0}, - {0x56, 0xff, 0xff, 0, 0}, - {0x57, 0xff, 0xff, 0, 0}, - {0x58, 0x88, 0x88, 0, 0}, - {0x59, 0x88, 0x88, 0, 0}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0xcc, 0xcc, 0, 0}, - {0x5C, 0x6, 0x6, 0, 0}, - {0x5D, 0x80, 0x80, 0, 0}, - {0x5E, 0x80, 0x80, 0, 0}, - {0x5F, 0xf8, 0xf8, 0, 0}, - {0x60, 0x88, 0x88, 0, 0}, - {0x61, 0x88, 0x88, 0, 0}, - {0x62, 0x88, 0x8, 1, 1}, - {0x63, 0x88, 0x88, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0x1, 0x1, 1, 1}, - {0x66, 0x8a, 0x8a, 0, 0}, - {0x67, 0x8, 0x8, 0, 0}, - {0x68, 0x83, 0x83, 0, 0}, - {0x69, 0x6, 0x6, 0, 0}, - {0x6A, 0xa0, 0xa0, 0, 0}, - {0x6B, 0xa, 0xa, 0, 0}, - {0x6C, 0x87, 0x87, 1, 1}, - {0x6D, 0x2a, 0x2a, 0, 0}, - {0x6E, 0x2a, 0x2a, 0, 0}, - {0x6F, 0x2a, 0x2a, 0, 0}, - {0x70, 0x2a, 0x2a, 0, 0}, - {0x71, 0x18, 0x18, 0, 0}, - {0x72, 0x6a, 0x6a, 1, 1}, - {0x73, 0xab, 0xab, 1, 1}, - {0x74, 0x13, 0x13, 1, 1}, - {0x75, 0xc1, 0xc1, 1, 1}, - {0x76, 0xaa, 0xaa, 1, 1}, - {0x77, 0x87, 0x87, 1, 1}, - {0x78, 0, 0, 0, 0}, - {0x79, 0x6, 0x6, 0, 0}, - {0x7A, 0x7, 0x7, 0, 0}, - {0x7B, 0x7, 0x7, 0, 0}, - {0x7C, 0x15, 0x15, 0, 0}, - {0x7D, 0x55, 0x55, 0, 0}, - {0x7E, 0x97, 0x97, 1, 1}, - {0x7F, 0x8, 0x8, 0, 0}, - {0x80, 0x14, 0x14, 1, 1}, - {0x81, 0x33, 0x33, 0, 0}, - {0x82, 0x88, 0x88, 0, 0}, - {0x83, 0x6, 0x6, 0, 0}, - {0x84, 0x3, 0x3, 1, 1}, - {0x85, 0xa, 0xa, 0, 0}, - {0x86, 0x3, 0x3, 1, 1}, - {0x87, 0x2a, 0x2a, 0, 0}, - {0x88, 0xa4, 0xa4, 0, 0}, - {0x89, 0x18, 0x18, 0, 0}, - {0x8A, 0x28, 0x28, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0x4a, 0x4a, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0xf8, 0xf8, 0, 0}, - {0x8F, 0x88, 0x88, 0, 0}, - {0x90, 0x88, 0x88, 0, 0}, - {0x91, 0x88, 0x8, 1, 1}, - {0x92, 0x88, 0x88, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0x1, 0x1, 1, 1}, - {0x95, 0x8a, 0x8a, 0, 0}, - {0x96, 0x8, 0x8, 0, 0}, - {0x97, 0x83, 0x83, 0, 0}, - {0x98, 0x6, 0x6, 0, 0}, - {0x99, 0xa0, 0xa0, 0, 0}, - {0x9A, 0xa, 0xa, 0, 0}, - {0x9B, 0x87, 0x87, 1, 1}, - {0x9C, 0x2a, 0x2a, 0, 0}, - {0x9D, 0x2a, 0x2a, 0, 0}, - {0x9E, 0x2a, 0x2a, 0, 0}, - {0x9F, 0x2a, 0x2a, 0, 0}, - {0xA0, 0x18, 0x18, 0, 0}, - {0xA1, 0x6a, 0x6a, 1, 1}, - {0xA2, 0xab, 0xab, 1, 1}, - {0xA3, 0x13, 0x13, 1, 1}, - {0xA4, 0xc1, 0xc1, 1, 1}, - {0xA5, 0xaa, 0xaa, 1, 1}, - {0xA6, 0x87, 0x87, 1, 1}, - {0xA7, 0, 0, 0, 0}, - {0xA8, 0x6, 0x6, 0, 0}, - {0xA9, 0x7, 0x7, 0, 0}, - {0xAA, 0x7, 0x7, 0, 0}, - {0xAB, 0x15, 0x15, 0, 0}, - {0xAC, 0x55, 0x55, 0, 0}, - {0xAD, 0x97, 0x97, 1, 1}, - {0xAE, 0x8, 0x8, 0, 0}, - {0xAF, 0x14, 0x14, 1, 1}, - {0xB0, 0x33, 0x33, 0, 0}, - {0xB1, 0x88, 0x88, 0, 0}, - {0xB2, 0x6, 0x6, 0, 0}, - {0xB3, 0x3, 0x3, 1, 1}, - {0xB4, 0xa, 0xa, 0, 0}, - {0xB5, 0x3, 0x3, 1, 1}, - {0xB6, 0x2a, 0x2a, 0, 0}, - {0xB7, 0xa4, 0xa4, 0, 0}, - {0xB8, 0x18, 0x18, 0, 0}, - {0xB9, 0x28, 0x28, 0, 0}, - {0xBA, 0, 0, 0, 0}, - {0xBB, 0x4a, 0x4a, 0, 0}, - {0xBC, 0, 0, 0, 0}, - {0xBD, 0x71, 0x71, 0, 0}, - {0xBE, 0x72, 0x72, 0, 0}, - {0xBF, 0x73, 0x73, 0, 0}, - {0xC0, 0x74, 0x74, 0, 0}, - {0xC1, 0x75, 0x75, 0, 0}, - {0xC2, 0x76, 0x76, 0, 0}, - {0xC3, 0x77, 0x77, 0, 0}, - {0xC4, 0x78, 0x78, 0, 0}, - {0xC5, 0x79, 0x79, 0, 0}, - {0xC6, 0x7a, 0x7a, 0, 0}, - {0xC7, 0, 0, 0, 0}, - {0xC8, 0, 0, 0, 0}, - {0xC9, 0, 0, 0, 0}, - {0xCA, 0, 0, 0, 0}, - {0xCB, 0, 0, 0, 0}, - {0xCC, 0, 0, 0, 0}, - {0xCD, 0, 0, 0, 0}, - {0xCE, 0x6, 0x6, 0, 0}, - {0xCF, 0, 0, 0, 0}, - {0xD0, 0, 0, 0, 0}, - {0xD1, 0x18, 0x18, 0, 0}, - {0xD2, 0x88, 0x88, 0, 0}, - {0xD3, 0, 0, 0, 0}, - {0xD4, 0, 0, 0, 0}, - {0xD5, 0, 0, 0, 0}, - {0xD6, 0, 0, 0, 0}, - {0xD7, 0, 0, 0, 0}, - {0xD8, 0, 0, 0, 0}, - {0xD9, 0, 0, 0, 0}, - {0xDA, 0x6, 0x6, 0, 0}, - {0xDB, 0, 0, 0, 0}, - {0xDC, 0, 0, 0, 0}, - {0xDD, 0x18, 0x18, 0, 0}, - {0xDE, 0x88, 0x88, 0, 0}, - {0xDF, 0, 0, 0, 0}, - {0xE0, 0, 0, 0, 0}, - {0xE1, 0, 0, 0, 0}, - {0xE2, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_SYN_2056[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0xd, 0xd, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_TX_2056[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0x11, 0x11, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0xf, 0xf, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x2d, 0x2d, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0x74, 0x74, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_RX_2056[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x99, 0x99, 0, 0}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x44, 0x44, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0x44, 0x44, 0, 0}, - {0x40, 0xf, 0xf, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0x50, 0x50, 1, 1}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x99, 0x99, 0, 0}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x44, 0x44, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x66, 0x66, 0, 0}, - {0x50, 0x66, 0x66, 0, 0}, - {0x51, 0x57, 0x57, 0, 0}, - {0x52, 0x57, 0x57, 0, 0}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x23, 0x23, 0, 0}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0x2, 0x2, 0, 0}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_SYN_2056_A1[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0xd, 0xd, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_TX_2056_A1[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0x11, 0x11, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0xf, 0xf, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x2d, 0x2d, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0x72, 0x72, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_RX_2056_A1[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x44, 0x44, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0x44, 0x44, 0, 0}, - {0x40, 0xf, 0xf, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0x50, 0x50, 1, 1}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x44, 0x44, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x2f, 0x2f, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_SYN_2056_rev5[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_TX_2056_rev5[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0x11, 0x11, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0xf, 0xf, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x2d, 0x2d, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0x70, 0x70, 0, 0}, - {0x94, 0x70, 0x70, 0, 0}, - {0x95, 0x71, 0x71, 1, 1}, - {0x96, 0x71, 0x71, 1, 1}, - {0x97, 0x72, 0x72, 1, 1}, - {0x98, 0x73, 0x73, 1, 1}, - {0x99, 0x74, 0x74, 1, 1}, - {0x9A, 0x75, 0x75, 1, 1}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_RX_2056_rev5[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x88, 0x88, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 1, 1}, - {0x40, 0x7, 0x7, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0, 0, 1, 1}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x4, 0x4, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_SYN_2056_rev6[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_TX_2056_rev6[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0xee, 0xee, 1, 1}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0x50, 0x50, 1, 1}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x50, 0x50, 1, 1}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0x30, 0x30, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0x70, 0x70, 0, 0}, - {0x94, 0x70, 0x70, 0, 0}, - {0x95, 0x70, 0x70, 0, 0}, - {0x96, 0x70, 0x70, 0, 0}, - {0x97, 0x70, 0x70, 0, 0}, - {0x98, 0x70, 0x70, 0, 0}, - {0x99, 0x70, 0x70, 0, 0}, - {0x9A, 0x70, 0x70, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_RX_2056_rev6[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x88, 0x88, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0x44, 0x44, 0, 0}, - {0x40, 0x7, 0x7, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x44, 0x44, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x4, 0x4, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0x5, 0x5, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0} -}; - -static struct radio_regs regs_SYN_2056_rev7[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_TX_2056_rev7[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0xee, 0xee, 1, 1}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0x50, 0x50, 1, 1}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x50, 0x50, 1, 1}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0x30, 0x30, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0x70, 0x70, 0, 0}, - {0x94, 0x70, 0x70, 0, 0}, - {0x95, 0x71, 0x71, 1, 1}, - {0x96, 0x71, 0x71, 1, 1}, - {0x97, 0x72, 0x72, 1, 1}, - {0x98, 0x73, 0x73, 1, 1}, - {0x99, 0x74, 0x74, 1, 1}, - {0x9A, 0x75, 0x75, 1, 1}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_RX_2056_rev7[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x88, 0x88, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 1, 1}, - {0x40, 0x7, 0x7, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0, 0, 1, 1}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x4, 0x4, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_SYN_2056_rev8[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x4, 0x4, 0, 0}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x30, 0x30, 0, 0}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0xd, 0xd, 0, 0}, - {0x4C, 0xd, 0xd, 0, 0}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x6, 0x6, 0, 0}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_TX_2056_rev8[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0xee, 0xee, 1, 1}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0x50, 0x50, 1, 1}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x50, 0x50, 1, 1}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0x30, 0x30, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0x70, 0x70, 0, 0}, - {0x94, 0x70, 0x70, 0, 0}, - {0x95, 0x70, 0x70, 0, 0}, - {0x96, 0x70, 0x70, 0, 0}, - {0x97, 0x70, 0x70, 0, 0}, - {0x98, 0x70, 0x70, 0, 0}, - {0x99, 0x70, 0x70, 0, 0}, - {0x9A, 0x70, 0x70, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_regs regs_RX_2056_rev8[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x88, 0x88, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0x44, 0x44, 0, 0}, - {0x40, 0x7, 0x7, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x44, 0x44, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x4, 0x4, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0x5, 0x5, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static const struct radio_regs regs_SYN_2056_rev11[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0x1, 0x1, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0x60, 0x60, 0, 0}, - {0x23, 0x6, 0x6, 0, 0}, - {0x24, 0xc, 0xc, 0, 0}, - {0x25, 0, 0, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0, 0, 0, 0}, - {0x28, 0x1, 0x1, 0, 0}, - {0x29, 0, 0, 0, 0}, - {0x2A, 0, 0, 0, 0}, - {0x2B, 0, 0, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0, 0, 0, 0}, - {0x2F, 0x1f, 0x1f, 0, 0}, - {0x30, 0x15, 0x15, 0, 0}, - {0x31, 0xf, 0xf, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0, 0, 0, 0}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0, 0, 0, 0}, - {0x38, 0, 0, 0, 0}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0, 0, 0, 0}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x13, 0x13, 0, 0}, - {0x3D, 0xf, 0xf, 0, 0}, - {0x3E, 0x18, 0x18, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x20, 0x20, 0, 0}, - {0x42, 0x20, 0x20, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x77, 0x77, 0, 0}, - {0x45, 0x7, 0x7, 0, 0}, - {0x46, 0x1, 0x1, 0, 0}, - {0x47, 0x6, 0x6, 1, 1}, - {0x48, 0xf, 0xf, 0, 0}, - {0x49, 0x3f, 0x3f, 1, 1}, - {0x4A, 0x32, 0x32, 0, 0}, - {0x4B, 0x6, 0x6, 1, 1}, - {0x4C, 0x6, 0x6, 1, 1}, - {0x4D, 0x4, 0x4, 0, 0}, - {0x4E, 0x2b, 0x2b, 1, 1}, - {0x4F, 0x1, 0x1, 0, 0}, - {0x50, 0x1c, 0x1c, 0, 0}, - {0x51, 0x2, 0x2, 0, 0}, - {0x52, 0x2, 0x2, 0, 0}, - {0x53, 0xf7, 0xf7, 1, 1}, - {0x54, 0xb4, 0xb4, 0, 0}, - {0x55, 0xd2, 0xd2, 0, 0}, - {0x56, 0, 0, 0, 0}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x4, 0x4, 0, 0}, - {0x59, 0x96, 0x96, 0, 0}, - {0x5A, 0x3e, 0x3e, 0, 0}, - {0x5B, 0x3e, 0x3e, 0, 0}, - {0x5C, 0x13, 0x13, 0, 0}, - {0x5D, 0x2, 0x2, 0, 0}, - {0x5E, 0, 0, 0, 0}, - {0x5F, 0x7, 0x7, 0, 0}, - {0x60, 0x7, 0x7, 1, 1}, - {0x61, 0x8, 0x8, 0, 0}, - {0x62, 0x3, 0x3, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0x40, 0x40, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0x1, 0x1, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0x60, 0x60, 0, 0}, - {0x71, 0x66, 0x66, 0, 0}, - {0x72, 0xc, 0xc, 0, 0}, - {0x73, 0x66, 0x66, 0, 0}, - {0x74, 0x8f, 0x8f, 1, 1}, - {0x75, 0, 0, 0, 0}, - {0x76, 0xcc, 0xcc, 0, 0}, - {0x77, 0x1, 0x1, 0, 0}, - {0x78, 0x66, 0x66, 0, 0}, - {0x79, 0x66, 0x66, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0, 0, 0, 0}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0xff, 0xff, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0x95, 0, 0, 0, 0}, - {0x96, 0, 0, 0, 0}, - {0x97, 0, 0, 0, 0}, - {0x98, 0, 0, 0, 0}, - {0x99, 0, 0, 0, 0}, - {0x9A, 0, 0, 0, 0}, - {0x9B, 0, 0, 0, 0}, - {0x9C, 0, 0, 0, 0}, - {0x9D, 0, 0, 0, 0}, - {0x9E, 0, 0, 0, 0}, - {0x9F, 0x6, 0x6, 0, 0}, - {0xA0, 0x66, 0x66, 0, 0}, - {0xA1, 0x66, 0x66, 0, 0}, - {0xA2, 0x66, 0x66, 0, 0}, - {0xA3, 0x66, 0x66, 0, 0}, - {0xA4, 0x66, 0x66, 0, 0}, - {0xA5, 0x66, 0x66, 0, 0}, - {0xA6, 0x66, 0x66, 0, 0}, - {0xA7, 0x66, 0x66, 0, 0}, - {0xA8, 0x66, 0x66, 0, 0}, - {0xA9, 0x66, 0x66, 0, 0}, - {0xAA, 0x66, 0x66, 0, 0}, - {0xAB, 0x66, 0x66, 0, 0}, - {0xAC, 0x66, 0x66, 0, 0}, - {0xAD, 0x66, 0x66, 0, 0}, - {0xAE, 0x66, 0x66, 0, 0}, - {0xAF, 0x66, 0x66, 0, 0}, - {0xB0, 0x66, 0x66, 0, 0}, - {0xB1, 0x66, 0x66, 0, 0}, - {0xB2, 0x66, 0x66, 0, 0}, - {0xB3, 0xa, 0xa, 0, 0}, - {0xB4, 0, 0, 0, 0}, - {0xB5, 0, 0, 0, 0}, - {0xB6, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static const struct radio_regs regs_TX_2056_rev11[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0, 0, 0, 0}, - {0x21, 0x88, 0x88, 0, 0}, - {0x22, 0x88, 0x88, 0, 0}, - {0x23, 0x88, 0x88, 0, 0}, - {0x24, 0x88, 0x88, 0, 0}, - {0x25, 0xc, 0xc, 0, 0}, - {0x26, 0, 0, 0, 0}, - {0x27, 0x3, 0x3, 0, 0}, - {0x28, 0, 0, 0, 0}, - {0x29, 0x3, 0x3, 0, 0}, - {0x2A, 0x37, 0x37, 0, 0}, - {0x2B, 0x3, 0x3, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0, 0, 0, 0}, - {0x2E, 0x1, 0x1, 0, 0}, - {0x2F, 0x1, 0x1, 0, 0}, - {0x30, 0, 0, 0, 0}, - {0x31, 0, 0, 0, 0}, - {0x32, 0, 0, 0, 0}, - {0x33, 0x11, 0x11, 0, 0}, - {0x34, 0xee, 0xee, 1, 1}, - {0x35, 0, 0, 0, 0}, - {0x36, 0, 0, 0, 0}, - {0x37, 0x3, 0x3, 0, 0}, - {0x38, 0x50, 0x50, 1, 1}, - {0x39, 0, 0, 0, 0}, - {0x3A, 0x50, 0x50, 1, 1}, - {0x3B, 0, 0, 0, 0}, - {0x3C, 0x6e, 0x6e, 0, 0}, - {0x3D, 0xf0, 0xf0, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0, 0, 0, 0}, - {0x40, 0, 0, 0, 0}, - {0x41, 0x3, 0x3, 0, 0}, - {0x42, 0x3, 0x3, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x1e, 0x1e, 0, 0}, - {0x45, 0, 0, 0, 0}, - {0x46, 0x6e, 0x6e, 0, 0}, - {0x47, 0xf0, 0xf0, 1, 1}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x2, 0x2, 0, 0}, - {0x4A, 0xff, 0xff, 1, 1}, - {0x4B, 0xc, 0xc, 0, 0}, - {0x4C, 0, 0, 0, 0}, - {0x4D, 0x38, 0x38, 0, 0}, - {0x4E, 0x70, 0x70, 1, 1}, - {0x4F, 0x2, 0x2, 0, 0}, - {0x50, 0x88, 0x88, 0, 0}, - {0x51, 0xc, 0xc, 0, 0}, - {0x52, 0, 0, 0, 0}, - {0x53, 0x8, 0x8, 0, 0}, - {0x54, 0x70, 0x70, 1, 1}, - {0x55, 0x2, 0x2, 0, 0}, - {0x56, 0xff, 0xff, 1, 1}, - {0x57, 0, 0, 0, 0}, - {0x58, 0x83, 0x83, 0, 0}, - {0x59, 0x77, 0x77, 1, 1}, - {0x5A, 0, 0, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x88, 0x88, 0, 0}, - {0x5D, 0, 0, 0, 0}, - {0x5E, 0x8, 0x8, 0, 0}, - {0x5F, 0x77, 0x77, 1, 1}, - {0x60, 0x1, 0x1, 0, 0}, - {0x61, 0, 0, 0, 0}, - {0x62, 0x7, 0x7, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0x7, 0x7, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 1, 1}, - {0x68, 0, 0, 0, 0}, - {0x69, 0xa, 0xa, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0, 0, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0x2, 0x2, 0, 0}, - {0x72, 0, 0, 0, 0}, - {0x73, 0, 0, 0, 0}, - {0x74, 0xe, 0xe, 0, 0}, - {0x75, 0xe, 0xe, 0, 0}, - {0x76, 0xe, 0xe, 0, 0}, - {0x77, 0x13, 0x13, 0, 0}, - {0x78, 0x13, 0x13, 0, 0}, - {0x79, 0x1b, 0x1b, 0, 0}, - {0x7A, 0x1b, 0x1b, 0, 0}, - {0x7B, 0x55, 0x55, 0, 0}, - {0x7C, 0x5b, 0x5b, 0, 0}, - {0x7D, 0x30, 0x30, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0x70, 0x70, 0, 0}, - {0x94, 0x70, 0x70, 0, 0}, - {0x95, 0x70, 0x70, 0, 0}, - {0x96, 0x70, 0x70, 0, 0}, - {0x97, 0x70, 0x70, 0, 0}, - {0x98, 0x70, 0x70, 0, 0}, - {0x99, 0x70, 0x70, 0, 0}, - {0x9A, 0x70, 0x70, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static const struct radio_regs regs_RX_2056_rev11[] = { - {0x02, 0, 0, 0, 0}, - {0x03, 0, 0, 0, 0}, - {0x04, 0, 0, 0, 0}, - {0x05, 0, 0, 0, 0}, - {0x06, 0, 0, 0, 0}, - {0x07, 0, 0, 0, 0}, - {0x08, 0, 0, 0, 0}, - {0x09, 0, 0, 0, 0}, - {0x0A, 0, 0, 0, 0}, - {0x0B, 0, 0, 0, 0}, - {0x0C, 0, 0, 0, 0}, - {0x0D, 0, 0, 0, 0}, - {0x0E, 0, 0, 0, 0}, - {0x0F, 0, 0, 0, 0}, - {0x10, 0, 0, 0, 0}, - {0x11, 0, 0, 0, 0}, - {0x12, 0, 0, 0, 0}, - {0x13, 0, 0, 0, 0}, - {0x14, 0, 0, 0, 0}, - {0x15, 0, 0, 0, 0}, - {0x16, 0, 0, 0, 0}, - {0x17, 0, 0, 0, 0}, - {0x18, 0, 0, 0, 0}, - {0x19, 0, 0, 0, 0}, - {0x1A, 0, 0, 0, 0}, - {0x1B, 0, 0, 0, 0}, - {0x1C, 0, 0, 0, 0}, - {0x1D, 0, 0, 0, 0}, - {0x1E, 0, 0, 0, 0}, - {0x1F, 0, 0, 0, 0}, - {0x20, 0x3, 0x3, 0, 0}, - {0x21, 0, 0, 0, 0}, - {0x22, 0, 0, 0, 0}, - {0x23, 0x90, 0x90, 0, 0}, - {0x24, 0x55, 0x55, 0, 0}, - {0x25, 0x15, 0x15, 0, 0}, - {0x26, 0x5, 0x5, 0, 0}, - {0x27, 0x15, 0x15, 0, 0}, - {0x28, 0x5, 0x5, 0, 0}, - {0x29, 0x20, 0x20, 0, 0}, - {0x2A, 0x11, 0x11, 0, 0}, - {0x2B, 0x90, 0x90, 0, 0}, - {0x2C, 0, 0, 0, 0}, - {0x2D, 0x88, 0x88, 0, 0}, - {0x2E, 0x32, 0x32, 0, 0}, - {0x2F, 0x77, 0x77, 0, 0}, - {0x30, 0x17, 0x17, 1, 1}, - {0x31, 0xff, 0xff, 1, 1}, - {0x32, 0x20, 0x20, 0, 0}, - {0x33, 0, 0, 0, 0}, - {0x34, 0x88, 0x88, 0, 0}, - {0x35, 0x32, 0x32, 0, 0}, - {0x36, 0x77, 0x77, 0, 0}, - {0x37, 0x17, 0x17, 1, 1}, - {0x38, 0xf0, 0xf0, 1, 1}, - {0x39, 0x20, 0x20, 0, 0}, - {0x3A, 0x8, 0x8, 0, 0}, - {0x3B, 0x55, 0x55, 1, 1}, - {0x3C, 0, 0, 0, 0}, - {0x3D, 0x88, 0x88, 1, 1}, - {0x3E, 0, 0, 0, 0}, - {0x3F, 0x44, 0x44, 0, 0}, - {0x40, 0x7, 0x7, 1, 1}, - {0x41, 0x6, 0x6, 0, 0}, - {0x42, 0x4, 0x4, 0, 0}, - {0x43, 0, 0, 0, 0}, - {0x44, 0x8, 0x8, 0, 0}, - {0x45, 0x55, 0x55, 1, 1}, - {0x46, 0, 0, 0, 0}, - {0x47, 0x11, 0x11, 0, 0}, - {0x48, 0, 0, 0, 0}, - {0x49, 0x44, 0x44, 0, 0}, - {0x4A, 0x7, 0x7, 0, 0}, - {0x4B, 0x6, 0x6, 0, 0}, - {0x4C, 0x4, 0x4, 0, 0}, - {0x4D, 0, 0, 0, 0}, - {0x4E, 0, 0, 0, 0}, - {0x4F, 0x26, 0x26, 1, 1}, - {0x50, 0x26, 0x26, 1, 1}, - {0x51, 0xf, 0xf, 1, 1}, - {0x52, 0xf, 0xf, 1, 1}, - {0x53, 0x44, 0x44, 0, 0}, - {0x54, 0, 0, 0, 0}, - {0x55, 0, 0, 0, 0}, - {0x56, 0x8, 0x8, 0, 0}, - {0x57, 0x8, 0x8, 0, 0}, - {0x58, 0x7, 0x7, 0, 0}, - {0x59, 0x22, 0x22, 0, 0}, - {0x5A, 0x22, 0x22, 0, 0}, - {0x5B, 0x2, 0x2, 0, 0}, - {0x5C, 0x4, 0x4, 1, 1}, - {0x5D, 0x7, 0x7, 0, 0}, - {0x5E, 0x55, 0x55, 0, 0}, - {0x5F, 0x23, 0x23, 0, 0}, - {0x60, 0x41, 0x41, 0, 0}, - {0x61, 0x1, 0x1, 0, 0}, - {0x62, 0xa, 0xa, 0, 0}, - {0x63, 0, 0, 0, 0}, - {0x64, 0, 0, 0, 0}, - {0x65, 0, 0, 0, 0}, - {0x66, 0, 0, 0, 0}, - {0x67, 0, 0, 0, 0}, - {0x68, 0, 0, 0, 0}, - {0x69, 0, 0, 0, 0}, - {0x6A, 0, 0, 0, 0}, - {0x6B, 0xc, 0xc, 0, 0}, - {0x6C, 0, 0, 0, 0}, - {0x6D, 0, 0, 0, 0}, - {0x6E, 0, 0, 0, 0}, - {0x6F, 0, 0, 0, 0}, - {0x70, 0, 0, 0, 0}, - {0x71, 0, 0, 0, 0}, - {0x72, 0x22, 0x22, 0, 0}, - {0x73, 0x22, 0x22, 0, 0}, - {0x74, 0, 0, 1, 1}, - {0x75, 0xa, 0xa, 0, 0}, - {0x76, 0x1, 0x1, 0, 0}, - {0x77, 0x22, 0x22, 0, 0}, - {0x78, 0x30, 0x30, 0, 0}, - {0x79, 0, 0, 0, 0}, - {0x7A, 0, 0, 0, 0}, - {0x7B, 0, 0, 0, 0}, - {0x7C, 0, 0, 0, 0}, - {0x7D, 0x5, 0x5, 1, 1}, - {0x7E, 0, 0, 0, 0}, - {0x7F, 0, 0, 0, 0}, - {0x80, 0, 0, 0, 0}, - {0x81, 0, 0, 0, 0}, - {0x82, 0, 0, 0, 0}, - {0x83, 0, 0, 0, 0}, - {0x84, 0, 0, 0, 0}, - {0x85, 0, 0, 0, 0}, - {0x86, 0, 0, 0, 0}, - {0x87, 0, 0, 0, 0}, - {0x88, 0, 0, 0, 0}, - {0x89, 0, 0, 0, 0}, - {0x8A, 0, 0, 0, 0}, - {0x8B, 0, 0, 0, 0}, - {0x8C, 0, 0, 0, 0}, - {0x8D, 0, 0, 0, 0}, - {0x8E, 0, 0, 0, 0}, - {0x8F, 0, 0, 0, 0}, - {0x90, 0, 0, 0, 0}, - {0x91, 0, 0, 0, 0}, - {0x92, 0, 0, 0, 0}, - {0x93, 0, 0, 0, 0}, - {0x94, 0, 0, 0, 0}, - {0xFFFF, 0, 0, 0, 0}, -}; - -static struct radio_20xx_regs regs_2057_rev4[] = { - {0x00, 0x84, 0}, - {0x01, 0, 0}, - {0x02, 0x60, 0}, - {0x03, 0x1f, 0}, - {0x04, 0x4, 0}, - {0x05, 0x2, 0}, - {0x06, 0x1, 0}, - {0x07, 0x1, 0}, - {0x08, 0x1, 0}, - {0x09, 0x69, 0}, - {0x0A, 0x66, 0}, - {0x0B, 0x6, 0}, - {0x0C, 0x18, 0}, - {0x0D, 0x3, 0}, - {0x0E, 0x20, 1}, - {0x0F, 0x20, 0}, - {0x10, 0, 0}, - {0x11, 0x7c, 0}, - {0x12, 0x42, 0}, - {0x13, 0xbd, 0}, - {0x14, 0x7, 0}, - {0x15, 0xf7, 0}, - {0x16, 0x8, 0}, - {0x17, 0x17, 0}, - {0x18, 0x7, 0}, - {0x19, 0, 0}, - {0x1A, 0x2, 0}, - {0x1B, 0x13, 0}, - {0x1C, 0x3e, 0}, - {0x1D, 0x3e, 0}, - {0x1E, 0x96, 0}, - {0x1F, 0x4, 0}, - {0x20, 0, 0}, - {0x21, 0, 0}, - {0x22, 0x17, 0}, - {0x23, 0x4, 0}, - {0x24, 0x1, 0}, - {0x25, 0x6, 0}, - {0x26, 0x4, 0}, - {0x27, 0xd, 0}, - {0x28, 0xd, 0}, - {0x29, 0x30, 0}, - {0x2A, 0x32, 0}, - {0x2B, 0x8, 0}, - {0x2C, 0x1c, 0}, - {0x2D, 0x2, 0}, - {0x2E, 0x4, 0}, - {0x2F, 0x7f, 0}, - {0x30, 0x27, 0}, - {0x31, 0, 1}, - {0x32, 0, 1}, - {0x33, 0, 1}, - {0x34, 0, 0}, - {0x35, 0x26, 1}, - {0x36, 0x18, 0}, - {0x37, 0x7, 0}, - {0x38, 0x66, 0}, - {0x39, 0x66, 0}, - {0x3A, 0x66, 0}, - {0x3B, 0x66, 0}, - {0x3C, 0xff, 1}, - {0x3D, 0xff, 1}, - {0x3E, 0xff, 1}, - {0x3F, 0xff, 1}, - {0x40, 0x16, 0}, - {0x41, 0x7, 0}, - {0x42, 0x19, 0}, - {0x43, 0x7, 0}, - {0x44, 0x6, 0}, - {0x45, 0x3, 0}, - {0x46, 0x1, 0}, - {0x47, 0x7, 0}, - {0x48, 0x33, 0}, - {0x49, 0x5, 0}, - {0x4A, 0x77, 0}, - {0x4B, 0x66, 0}, - {0x4C, 0x66, 0}, - {0x4D, 0, 0}, - {0x4E, 0x4, 0}, - {0x4F, 0xc, 0}, - {0x50, 0, 0}, - {0x51, 0x75, 0}, - {0x56, 0x7, 0}, - {0x57, 0, 0}, - {0x58, 0, 0}, - {0x59, 0xa8, 0}, - {0x5A, 0, 0}, - {0x5B, 0x1f, 0}, - {0x5C, 0x30, 0}, - {0x5D, 0x1, 0}, - {0x5E, 0x30, 0}, - {0x5F, 0x70, 0}, - {0x60, 0, 0}, - {0x61, 0, 0}, - {0x62, 0x33, 1}, - {0x63, 0x19, 0}, - {0x64, 0x62, 0}, - {0x65, 0, 0}, - {0x66, 0x11, 0}, - {0x69, 0, 0}, - {0x6A, 0x7e, 0}, - {0x6B, 0x3f, 0}, - {0x6C, 0x7f, 0}, - {0x6D, 0x78, 0}, - {0x6E, 0xc8, 0}, - {0x6F, 0x88, 0}, - {0x70, 0x8, 0}, - {0x71, 0xf, 0}, - {0x72, 0xbc, 0}, - {0x73, 0x8, 0}, - {0x74, 0x60, 0}, - {0x75, 0x1e, 0}, - {0x76, 0x70, 0}, - {0x77, 0, 0}, - {0x78, 0, 0}, - {0x79, 0, 0}, - {0x7A, 0x33, 0}, - {0x7B, 0x1e, 0}, - {0x7C, 0x62, 0}, - {0x7D, 0x11, 0}, - {0x80, 0x3c, 0}, - {0x81, 0x9c, 0}, - {0x82, 0xa, 0}, - {0x83, 0x9d, 0}, - {0x84, 0xa, 0}, - {0x85, 0, 0}, - {0x86, 0x40, 0}, - {0x87, 0x40, 0}, - {0x88, 0x88, 0}, - {0x89, 0x10, 0}, - {0x8A, 0xf0, 1}, - {0x8B, 0x10, 1}, - {0x8C, 0xf0, 1}, - {0x8D, 0, 0}, - {0x8E, 0, 0}, - {0x8F, 0x10, 0}, - {0x90, 0x55, 0}, - {0x91, 0x3f, 1}, - {0x92, 0x36, 1}, - {0x93, 0, 0}, - {0x94, 0, 0}, - {0x95, 0, 0}, - {0x96, 0x87, 0}, - {0x97, 0x11, 0}, - {0x98, 0, 0}, - {0x99, 0x33, 0}, - {0x9A, 0x88, 0}, - {0x9B, 0, 0}, - {0x9C, 0x87, 0}, - {0x9D, 0x11, 0}, - {0x9E, 0, 0}, - {0x9F, 0x33, 0}, - {0xA0, 0x88, 0}, - {0xA1, 0xe1, 0}, - {0xA2, 0x3f, 0}, - {0xA3, 0x44, 0}, - {0xA4, 0x8c, 1}, - {0xA5, 0x6d, 0}, - {0xA6, 0x22, 0}, - {0xA7, 0xbe, 0}, - {0xA8, 0x55, 1}, - {0xA9, 0xc, 0}, - {0xAA, 0xc, 0}, - {0xAB, 0xaa, 0}, - {0xAC, 0x2, 0}, - {0xAD, 0, 0}, - {0xAE, 0x10, 0}, - {0xAF, 0x1, 1}, - {0xB0, 0, 0}, - {0xB1, 0, 0}, - {0xB2, 0x80, 0}, - {0xB3, 0x60, 0}, - {0xB4, 0x44, 0}, - {0xB5, 0x55, 0}, - {0xB6, 0x1, 0}, - {0xB7, 0x55, 0}, - {0xB8, 0x1, 0}, - {0xB9, 0x5, 0}, - {0xBA, 0x55, 0}, - {0xBB, 0x55, 0}, - {0xC1, 0, 0}, - {0xC2, 0, 0}, - {0xC3, 0, 0}, - {0xC4, 0, 0}, - {0xC5, 0, 0}, - {0xC6, 0, 0}, - {0xC7, 0, 0}, - {0xC8, 0, 0}, - {0xC9, 0, 0}, - {0xCA, 0, 0}, - {0xCB, 0, 0}, - {0xCC, 0, 0}, - {0xCD, 0, 0}, - {0xCE, 0x5e, 0}, - {0xCF, 0xc, 0}, - {0xD0, 0xc, 0}, - {0xD1, 0xc, 0}, - {0xD2, 0, 0}, - {0xD3, 0x2b, 0}, - {0xD4, 0xc, 0}, - {0xD5, 0, 0}, - {0xD6, 0x75, 0}, - {0xDB, 0x7, 0}, - {0xDC, 0, 0}, - {0xDD, 0, 0}, - {0xDE, 0xa8, 0}, - {0xDF, 0, 0}, - {0xE0, 0x1f, 0}, - {0xE1, 0x30, 0}, - {0xE2, 0x1, 0}, - {0xE3, 0x30, 0}, - {0xE4, 0x70, 0}, - {0xE5, 0, 0}, - {0xE6, 0, 0}, - {0xE7, 0x33, 0}, - {0xE8, 0x19, 0}, - {0xE9, 0x62, 0}, - {0xEA, 0, 0}, - {0xEB, 0x11, 0}, - {0xEE, 0, 0}, - {0xEF, 0x7e, 0}, - {0xF0, 0x3f, 0}, - {0xF1, 0x7f, 0}, - {0xF2, 0x78, 0}, - {0xF3, 0xc8, 0}, - {0xF4, 0x88, 0}, - {0xF5, 0x8, 0}, - {0xF6, 0xf, 0}, - {0xF7, 0xbc, 0}, - {0xF8, 0x8, 0}, - {0xF9, 0x60, 0}, - {0xFA, 0x1e, 0}, - {0xFB, 0x70, 0}, - {0xFC, 0, 0}, - {0xFD, 0, 0}, - {0xFE, 0, 0}, - {0xFF, 0x33, 0}, - {0x100, 0x1e, 0}, - {0x101, 0x62, 0}, - {0x102, 0x11, 0}, - {0x105, 0x3c, 0}, - {0x106, 0x9c, 0}, - {0x107, 0xa, 0}, - {0x108, 0x9d, 0}, - {0x109, 0xa, 0}, - {0x10A, 0, 0}, - {0x10B, 0x40, 0}, - {0x10C, 0x40, 0}, - {0x10D, 0x88, 0}, - {0x10E, 0x10, 0}, - {0x10F, 0xf0, 1}, - {0x110, 0x10, 1}, - {0x111, 0xf0, 1}, - {0x112, 0, 0}, - {0x113, 0, 0}, - {0x114, 0x10, 0}, - {0x115, 0x55, 0}, - {0x116, 0x3f, 1}, - {0x117, 0x36, 1}, - {0x118, 0, 0}, - {0x119, 0, 0}, - {0x11A, 0, 0}, - {0x11B, 0x87, 0}, - {0x11C, 0x11, 0}, - {0x11D, 0, 0}, - {0x11E, 0x33, 0}, - {0x11F, 0x88, 0}, - {0x120, 0, 0}, - {0x121, 0x87, 0}, - {0x122, 0x11, 0}, - {0x123, 0, 0}, - {0x124, 0x33, 0}, - {0x125, 0x88, 0}, - {0x126, 0xe1, 0}, - {0x127, 0x3f, 0}, - {0x128, 0x44, 0}, - {0x129, 0x8c, 1}, - {0x12A, 0x6d, 0}, - {0x12B, 0x22, 0}, - {0x12C, 0xbe, 0}, - {0x12D, 0x55, 1}, - {0x12E, 0xc, 0}, - {0x12F, 0xc, 0}, - {0x130, 0xaa, 0}, - {0x131, 0x2, 0}, - {0x132, 0, 0}, - {0x133, 0x10, 0}, - {0x134, 0x1, 1}, - {0x135, 0, 0}, - {0x136, 0, 0}, - {0x137, 0x80, 0}, - {0x138, 0x60, 0}, - {0x139, 0x44, 0}, - {0x13A, 0x55, 0}, - {0x13B, 0x1, 0}, - {0x13C, 0x55, 0}, - {0x13D, 0x1, 0}, - {0x13E, 0x5, 0}, - {0x13F, 0x55, 0}, - {0x140, 0x55, 0}, - {0x146, 0, 0}, - {0x147, 0, 0}, - {0x148, 0, 0}, - {0x149, 0, 0}, - {0x14A, 0, 0}, - {0x14B, 0, 0}, - {0x14C, 0, 0}, - {0x14D, 0, 0}, - {0x14E, 0, 0}, - {0x14F, 0, 0}, - {0x150, 0, 0}, - {0x151, 0, 0}, - {0x152, 0, 0}, - {0x153, 0, 0}, - {0x154, 0xc, 0}, - {0x155, 0xc, 0}, - {0x156, 0xc, 0}, - {0x157, 0, 0}, - {0x158, 0x2b, 0}, - {0x159, 0x84, 0}, - {0x15A, 0x15, 0}, - {0x15B, 0xf, 0}, - {0x15C, 0, 0}, - {0x15D, 0, 0}, - {0x15E, 0, 1}, - {0x15F, 0, 1}, - {0x160, 0, 1}, - {0x161, 0, 1}, - {0x162, 0, 1}, - {0x163, 0, 1}, - {0x164, 0, 0}, - {0x165, 0, 0}, - {0x166, 0, 0}, - {0x167, 0, 0}, - {0x168, 0, 0}, - {0x169, 0x2, 1}, - {0x16A, 0, 1}, - {0x16B, 0, 1}, - {0x16C, 0, 1}, - {0x16D, 0, 0}, - {0x170, 0, 0}, - {0x171, 0x77, 0}, - {0x172, 0x77, 0}, - {0x173, 0x77, 0}, - {0x174, 0x77, 0}, - {0x175, 0, 0}, - {0x176, 0x3, 0}, - {0x177, 0x37, 0}, - {0x178, 0x3, 0}, - {0x179, 0, 0}, - {0x17A, 0x21, 0}, - {0x17B, 0x21, 0}, - {0x17C, 0, 0}, - {0x17D, 0xaa, 0}, - {0x17E, 0, 0}, - {0x17F, 0xaa, 0}, - {0x180, 0, 0}, - {0x190, 0, 0}, - {0x191, 0x77, 0}, - {0x192, 0x77, 0}, - {0x193, 0x77, 0}, - {0x194, 0x77, 0}, - {0x195, 0, 0}, - {0x196, 0x3, 0}, - {0x197, 0x37, 0}, - {0x198, 0x3, 0}, - {0x199, 0, 0}, - {0x19A, 0x21, 0}, - {0x19B, 0x21, 0}, - {0x19C, 0, 0}, - {0x19D, 0xaa, 0}, - {0x19E, 0, 0}, - {0x19F, 0xaa, 0}, - {0x1A0, 0, 0}, - {0x1A1, 0x2, 0}, - {0x1A2, 0xf, 0}, - {0x1A3, 0xf, 0}, - {0x1A4, 0, 1}, - {0x1A5, 0, 1}, - {0x1A6, 0, 1}, - {0x1A7, 0x2, 0}, - {0x1A8, 0xf, 0}, - {0x1A9, 0xf, 0}, - {0x1AA, 0, 1}, - {0x1AB, 0, 1}, - {0x1AC, 0, 1}, - {0xFFFF, 0, 0}, -}; - -static struct radio_20xx_regs regs_2057_rev5[] = { - {0x00, 0, 1}, - {0x01, 0x57, 1}, - {0x02, 0x20, 1}, - {0x03, 0x1f, 0}, - {0x04, 0x4, 0}, - {0x05, 0x2, 0}, - {0x06, 0x1, 0}, - {0x07, 0x1, 0}, - {0x08, 0x1, 0}, - {0x09, 0x69, 0}, - {0x0A, 0x66, 0}, - {0x0B, 0x6, 0}, - {0x0C, 0x18, 0}, - {0x0D, 0x3, 0}, - {0x0E, 0x20, 0}, - {0x0F, 0x20, 0}, - {0x10, 0, 0}, - {0x11, 0x7c, 0}, - {0x12, 0x42, 0}, - {0x13, 0xbd, 0}, - {0x14, 0x7, 0}, - {0x15, 0x87, 0}, - {0x16, 0x8, 0}, - {0x17, 0x17, 0}, - {0x18, 0x7, 0}, - {0x19, 0, 0}, - {0x1A, 0x2, 0}, - {0x1B, 0x13, 0}, - {0x1C, 0x3e, 0}, - {0x1D, 0x3e, 0}, - {0x1E, 0x96, 0}, - {0x1F, 0x4, 0}, - {0x20, 0, 0}, - {0x21, 0, 0}, - {0x22, 0x17, 0}, - {0x23, 0x6, 1}, - {0x24, 0x1, 0}, - {0x25, 0x6, 0}, - {0x26, 0x4, 0}, - {0x27, 0xd, 0}, - {0x28, 0xd, 0}, - {0x29, 0x30, 0}, - {0x2A, 0x32, 0}, - {0x2B, 0x8, 0}, - {0x2C, 0x1c, 0}, - {0x2D, 0x2, 0}, - {0x2E, 0x4, 0}, - {0x2F, 0x7f, 0}, - {0x30, 0x27, 0}, - {0x31, 0, 1}, - {0x32, 0, 1}, - {0x33, 0, 1}, - {0x34, 0, 0}, - {0x35, 0x20, 0}, - {0x36, 0x18, 0}, - {0x37, 0x7, 0}, - {0x38, 0x66, 0}, - {0x39, 0x66, 0}, - {0x3C, 0xff, 0}, - {0x3D, 0xff, 0}, - {0x40, 0x16, 0}, - {0x41, 0x7, 0}, - {0x45, 0x3, 0}, - {0x46, 0x1, 0}, - {0x47, 0x7, 0}, - {0x4B, 0x66, 0}, - {0x4C, 0x66, 0}, - {0x4D, 0, 0}, - {0x4E, 0x4, 0}, - {0x4F, 0xc, 0}, - {0x50, 0, 0}, - {0x51, 0x70, 1}, - {0x56, 0x7, 0}, - {0x57, 0, 0}, - {0x58, 0, 0}, - {0x59, 0x88, 1}, - {0x5A, 0, 0}, - {0x5B, 0x1f, 0}, - {0x5C, 0x20, 1}, - {0x5D, 0x1, 0}, - {0x5E, 0x30, 0}, - {0x5F, 0x70, 0}, - {0x60, 0, 0}, - {0x61, 0, 0}, - {0x62, 0x33, 1}, - {0x63, 0xf, 1}, - {0x64, 0xf, 1}, - {0x65, 0, 0}, - {0x66, 0x11, 0}, - {0x80, 0x3c, 0}, - {0x81, 0x1, 1}, - {0x82, 0xa, 0}, - {0x85, 0, 0}, - {0x86, 0x40, 0}, - {0x87, 0x40, 0}, - {0x88, 0x88, 0}, - {0x89, 0x10, 0}, - {0x8A, 0xf0, 0}, - {0x8B, 0x10, 0}, - {0x8C, 0xf0, 0}, - {0x8F, 0x10, 0}, - {0x90, 0x55, 0}, - {0x91, 0x3f, 1}, - {0x92, 0x36, 1}, - {0x93, 0, 0}, - {0x94, 0, 0}, - {0x95, 0, 0}, - {0x96, 0x87, 0}, - {0x97, 0x11, 0}, - {0x98, 0, 0}, - {0x99, 0x33, 0}, - {0x9A, 0x88, 0}, - {0xA1, 0x20, 1}, - {0xA2, 0x3f, 0}, - {0xA3, 0x44, 0}, - {0xA4, 0x8c, 0}, - {0xA5, 0x6c, 0}, - {0xA6, 0x22, 0}, - {0xA7, 0xbe, 0}, - {0xA8, 0x55, 0}, - {0xAA, 0xc, 0}, - {0xAB, 0xaa, 0}, - {0xAC, 0x2, 0}, - {0xAD, 0, 0}, - {0xAE, 0x10, 0}, - {0xAF, 0x1, 0}, - {0xB0, 0, 0}, - {0xB1, 0, 0}, - {0xB2, 0x80, 0}, - {0xB3, 0x60, 0}, - {0xB4, 0x44, 0}, - {0xB5, 0x55, 0}, - {0xB6, 0x1, 0}, - {0xB7, 0x55, 0}, - {0xB8, 0x1, 0}, - {0xB9, 0x5, 0}, - {0xBA, 0x55, 0}, - {0xBB, 0x55, 0}, - {0xC3, 0, 0}, - {0xC4, 0, 0}, - {0xC5, 0, 0}, - {0xC6, 0, 0}, - {0xC7, 0, 0}, - {0xC8, 0, 0}, - {0xC9, 0, 0}, - {0xCA, 0, 0}, - {0xCB, 0, 0}, - {0xCD, 0, 0}, - {0xCE, 0x5e, 0}, - {0xCF, 0xc, 0}, - {0xD0, 0xc, 0}, - {0xD1, 0xc, 0}, - {0xD2, 0, 0}, - {0xD3, 0x2b, 0}, - {0xD4, 0xc, 0}, - {0xD5, 0, 0}, - {0xD6, 0x70, 1}, - {0xDB, 0x7, 0}, - {0xDC, 0, 0}, - {0xDD, 0, 0}, - {0xDE, 0x88, 1}, - {0xDF, 0, 0}, - {0xE0, 0x1f, 0}, - {0xE1, 0x20, 1}, - {0xE2, 0x1, 0}, - {0xE3, 0x30, 0}, - {0xE4, 0x70, 0}, - {0xE5, 0, 0}, - {0xE6, 0, 0}, - {0xE7, 0x33, 0}, - {0xE8, 0xf, 1}, - {0xE9, 0xf, 1}, - {0xEA, 0, 0}, - {0xEB, 0x11, 0}, - {0x105, 0x3c, 0}, - {0x106, 0x1, 1}, - {0x107, 0xa, 0}, - {0x10A, 0, 0}, - {0x10B, 0x40, 0}, - {0x10C, 0x40, 0}, - {0x10D, 0x88, 0}, - {0x10E, 0x10, 0}, - {0x10F, 0xf0, 0}, - {0x110, 0x10, 0}, - {0x111, 0xf0, 0}, - {0x114, 0x10, 0}, - {0x115, 0x55, 0}, - {0x116, 0x3f, 1}, - {0x117, 0x36, 1}, - {0x118, 0, 0}, - {0x119, 0, 0}, - {0x11A, 0, 0}, - {0x11B, 0x87, 0}, - {0x11C, 0x11, 0}, - {0x11D, 0, 0}, - {0x11E, 0x33, 0}, - {0x11F, 0x88, 0}, - {0x126, 0x20, 1}, - {0x127, 0x3f, 0}, - {0x128, 0x44, 0}, - {0x129, 0x8c, 0}, - {0x12A, 0x6c, 0}, - {0x12B, 0x22, 0}, - {0x12C, 0xbe, 0}, - {0x12D, 0x55, 0}, - {0x12F, 0xc, 0}, - {0x130, 0xaa, 0}, - {0x131, 0x2, 0}, - {0x132, 0, 0}, - {0x133, 0x10, 0}, - {0x134, 0x1, 0}, - {0x135, 0, 0}, - {0x136, 0, 0}, - {0x137, 0x80, 0}, - {0x138, 0x60, 0}, - {0x139, 0x44, 0}, - {0x13A, 0x55, 0}, - {0x13B, 0x1, 0}, - {0x13C, 0x55, 0}, - {0x13D, 0x1, 0}, - {0x13E, 0x5, 0}, - {0x13F, 0x55, 0}, - {0x140, 0x55, 0}, - {0x148, 0, 0}, - {0x149, 0, 0}, - {0x14A, 0, 0}, - {0x14B, 0, 0}, - {0x14C, 0, 0}, - {0x14D, 0, 0}, - {0x14E, 0, 0}, - {0x14F, 0, 0}, - {0x150, 0, 0}, - {0x154, 0xc, 0}, - {0x155, 0xc, 0}, - {0x156, 0xc, 0}, - {0x157, 0, 0}, - {0x158, 0x2b, 0}, - {0x159, 0x84, 0}, - {0x15A, 0x15, 0}, - {0x15B, 0xf, 0}, - {0x15C, 0, 0}, - {0x15D, 0, 0}, - {0x15E, 0, 1}, - {0x15F, 0, 1}, - {0x160, 0, 1}, - {0x161, 0, 1}, - {0x162, 0, 1}, - {0x163, 0, 1}, - {0x164, 0, 0}, - {0x165, 0, 0}, - {0x166, 0, 0}, - {0x167, 0, 0}, - {0x168, 0, 0}, - {0x169, 0, 0}, - {0x16A, 0, 1}, - {0x16B, 0, 1}, - {0x16C, 0, 1}, - {0x16D, 0, 0}, - {0x170, 0, 0}, - {0x171, 0x77, 0}, - {0x172, 0x77, 0}, - {0x173, 0x77, 0}, - {0x174, 0x77, 0}, - {0x175, 0, 0}, - {0x176, 0x3, 0}, - {0x177, 0x37, 0}, - {0x178, 0x3, 0}, - {0x179, 0, 0}, - {0x17B, 0x21, 0}, - {0x17C, 0, 0}, - {0x17D, 0xaa, 0}, - {0x17E, 0, 0}, - {0x190, 0, 0}, - {0x191, 0x77, 0}, - {0x192, 0x77, 0}, - {0x193, 0x77, 0}, - {0x194, 0x77, 0}, - {0x195, 0, 0}, - {0x196, 0x3, 0}, - {0x197, 0x37, 0}, - {0x198, 0x3, 0}, - {0x199, 0, 0}, - {0x19B, 0x21, 0}, - {0x19C, 0, 0}, - {0x19D, 0xaa, 0}, - {0x19E, 0, 0}, - {0x1A1, 0x2, 0}, - {0x1A2, 0xf, 0}, - {0x1A3, 0xf, 0}, - {0x1A4, 0, 1}, - {0x1A5, 0, 1}, - {0x1A6, 0, 1}, - {0x1A7, 0x2, 0}, - {0x1A8, 0xf, 0}, - {0x1A9, 0xf, 0}, - {0x1AA, 0, 1}, - {0x1AB, 0, 1}, - {0x1AC, 0, 1}, - {0x1AD, 0x84, 0}, - {0x1AE, 0x60, 0}, - {0x1AF, 0x47, 0}, - {0x1B0, 0x47, 0}, - {0x1B1, 0, 0}, - {0x1B2, 0, 0}, - {0x1B3, 0, 0}, - {0x1B4, 0, 0}, - {0x1B5, 0, 0}, - {0x1B6, 0, 0}, - {0x1B7, 0xc, 1}, - {0x1B8, 0, 0}, - {0x1B9, 0, 0}, - {0x1BA, 0, 0}, - {0x1BB, 0, 0}, - {0x1BC, 0, 0}, - {0x1BD, 0, 0}, - {0x1BE, 0, 0}, - {0x1BF, 0, 0}, - {0x1C0, 0, 0}, - {0x1C1, 0x1, 1}, - {0x1C2, 0x80, 1}, - {0x1C3, 0, 0}, - {0x1C4, 0, 0}, - {0x1C5, 0, 0}, - {0x1C6, 0, 0}, - {0x1C7, 0, 0}, - {0x1C8, 0, 0}, - {0x1C9, 0, 0}, - {0x1CA, 0, 0}, - {0xFFFF, 0, 0} -}; - -static struct radio_20xx_regs regs_2057_rev5v1[] = { - {0x00, 0x15, 1}, - {0x01, 0x57, 1}, - {0x02, 0x20, 1}, - {0x03, 0x1f, 0}, - {0x04, 0x4, 0}, - {0x05, 0x2, 0}, - {0x06, 0x1, 0}, - {0x07, 0x1, 0}, - {0x08, 0x1, 0}, - {0x09, 0x69, 0}, - {0x0A, 0x66, 0}, - {0x0B, 0x6, 0}, - {0x0C, 0x18, 0}, - {0x0D, 0x3, 0}, - {0x0E, 0x20, 0}, - {0x0F, 0x20, 0}, - {0x10, 0, 0}, - {0x11, 0x7c, 0}, - {0x12, 0x42, 0}, - {0x13, 0xbd, 0}, - {0x14, 0x7, 0}, - {0x15, 0x87, 0}, - {0x16, 0x8, 0}, - {0x17, 0x17, 0}, - {0x18, 0x7, 0}, - {0x19, 0, 0}, - {0x1A, 0x2, 0}, - {0x1B, 0x13, 0}, - {0x1C, 0x3e, 0}, - {0x1D, 0x3e, 0}, - {0x1E, 0x96, 0}, - {0x1F, 0x4, 0}, - {0x20, 0, 0}, - {0x21, 0, 0}, - {0x22, 0x17, 0}, - {0x23, 0x6, 1}, - {0x24, 0x1, 0}, - {0x25, 0x6, 0}, - {0x26, 0x4, 0}, - {0x27, 0xd, 0}, - {0x28, 0xd, 0}, - {0x29, 0x30, 0}, - {0x2A, 0x32, 0}, - {0x2B, 0x8, 0}, - {0x2C, 0x1c, 0}, - {0x2D, 0x2, 0}, - {0x2E, 0x4, 0}, - {0x2F, 0x7f, 0}, - {0x30, 0x27, 0}, - {0x31, 0, 1}, - {0x32, 0, 1}, - {0x33, 0, 1}, - {0x34, 0, 0}, - {0x35, 0x20, 0}, - {0x36, 0x18, 0}, - {0x37, 0x7, 0}, - {0x38, 0x66, 0}, - {0x39, 0x66, 0}, - {0x3C, 0xff, 0}, - {0x3D, 0xff, 0}, - {0x40, 0x16, 0}, - {0x41, 0x7, 0}, - {0x45, 0x3, 0}, - {0x46, 0x1, 0}, - {0x47, 0x7, 0}, - {0x4B, 0x66, 0}, - {0x4C, 0x66, 0}, - {0x4D, 0, 0}, - {0x4E, 0x4, 0}, - {0x4F, 0xc, 0}, - {0x50, 0, 0}, - {0x51, 0x70, 1}, - {0x56, 0x7, 0}, - {0x57, 0, 0}, - {0x58, 0, 0}, - {0x59, 0x88, 1}, - {0x5A, 0, 0}, - {0x5B, 0x1f, 0}, - {0x5C, 0x20, 1}, - {0x5D, 0x1, 0}, - {0x5E, 0x30, 0}, - {0x5F, 0x70, 0}, - {0x60, 0, 0}, - {0x61, 0, 0}, - {0x62, 0x33, 1}, - {0x63, 0xf, 1}, - {0x64, 0xf, 1}, - {0x65, 0, 0}, - {0x66, 0x11, 0}, - {0x80, 0x3c, 0}, - {0x81, 0x1, 1}, - {0x82, 0xa, 0}, - {0x85, 0, 0}, - {0x86, 0x40, 0}, - {0x87, 0x40, 0}, - {0x88, 0x88, 0}, - {0x89, 0x10, 0}, - {0x8A, 0xf0, 0}, - {0x8B, 0x10, 0}, - {0x8C, 0xf0, 0}, - {0x8F, 0x10, 0}, - {0x90, 0x55, 0}, - {0x91, 0x3f, 1}, - {0x92, 0x36, 1}, - {0x93, 0, 0}, - {0x94, 0, 0}, - {0x95, 0, 0}, - {0x96, 0x87, 0}, - {0x97, 0x11, 0}, - {0x98, 0, 0}, - {0x99, 0x33, 0}, - {0x9A, 0x88, 0}, - {0xA1, 0x20, 1}, - {0xA2, 0x3f, 0}, - {0xA3, 0x44, 0}, - {0xA4, 0x8c, 0}, - {0xA5, 0x6c, 0}, - {0xA6, 0x22, 0}, - {0xA7, 0xbe, 0}, - {0xA8, 0x55, 0}, - {0xAA, 0xc, 0}, - {0xAB, 0xaa, 0}, - {0xAC, 0x2, 0}, - {0xAD, 0, 0}, - {0xAE, 0x10, 0}, - {0xAF, 0x1, 0}, - {0xB0, 0, 0}, - {0xB1, 0, 0}, - {0xB2, 0x80, 0}, - {0xB3, 0x60, 0}, - {0xB4, 0x44, 0}, - {0xB5, 0x55, 0}, - {0xB6, 0x1, 0}, - {0xB7, 0x55, 0}, - {0xB8, 0x1, 0}, - {0xB9, 0x5, 0}, - {0xBA, 0x55, 0}, - {0xBB, 0x55, 0}, - {0xC3, 0, 0}, - {0xC4, 0, 0}, - {0xC5, 0, 0}, - {0xC6, 0, 0}, - {0xC7, 0, 0}, - {0xC8, 0, 0}, - {0xC9, 0x1, 1}, - {0xCA, 0, 0}, - {0xCB, 0, 0}, - {0xCD, 0, 0}, - {0xCE, 0x5e, 0}, - {0xCF, 0xc, 0}, - {0xD0, 0xc, 0}, - {0xD1, 0xc, 0}, - {0xD2, 0, 0}, - {0xD3, 0x2b, 0}, - {0xD4, 0xc, 0}, - {0xD5, 0, 0}, - {0xD6, 0x70, 1}, - {0xDB, 0x7, 0}, - {0xDC, 0, 0}, - {0xDD, 0, 0}, - {0xDE, 0x88, 1}, - {0xDF, 0, 0}, - {0xE0, 0x1f, 0}, - {0xE1, 0x20, 1}, - {0xE2, 0x1, 0}, - {0xE3, 0x30, 0}, - {0xE4, 0x70, 0}, - {0xE5, 0, 0}, - {0xE6, 0, 0}, - {0xE7, 0x33, 0}, - {0xE8, 0xf, 1}, - {0xE9, 0xf, 1}, - {0xEA, 0, 0}, - {0xEB, 0x11, 0}, - {0x105, 0x3c, 0}, - {0x106, 0x1, 1}, - {0x107, 0xa, 0}, - {0x10A, 0, 0}, - {0x10B, 0x40, 0}, - {0x10C, 0x40, 0}, - {0x10D, 0x88, 0}, - {0x10E, 0x10, 0}, - {0x10F, 0xf0, 0}, - {0x110, 0x10, 0}, - {0x111, 0xf0, 0}, - {0x114, 0x10, 0}, - {0x115, 0x55, 0}, - {0x116, 0x3f, 1}, - {0x117, 0x36, 1}, - {0x118, 0, 0}, - {0x119, 0, 0}, - {0x11A, 0, 0}, - {0x11B, 0x87, 0}, - {0x11C, 0x11, 0}, - {0x11D, 0, 0}, - {0x11E, 0x33, 0}, - {0x11F, 0x88, 0}, - {0x126, 0x20, 1}, - {0x127, 0x3f, 0}, - {0x128, 0x44, 0}, - {0x129, 0x8c, 0}, - {0x12A, 0x6c, 0}, - {0x12B, 0x22, 0}, - {0x12C, 0xbe, 0}, - {0x12D, 0x55, 0}, - {0x12F, 0xc, 0}, - {0x130, 0xaa, 0}, - {0x131, 0x2, 0}, - {0x132, 0, 0}, - {0x133, 0x10, 0}, - {0x134, 0x1, 0}, - {0x135, 0, 0}, - {0x136, 0, 0}, - {0x137, 0x80, 0}, - {0x138, 0x60, 0}, - {0x139, 0x44, 0}, - {0x13A, 0x55, 0}, - {0x13B, 0x1, 0}, - {0x13C, 0x55, 0}, - {0x13D, 0x1, 0}, - {0x13E, 0x5, 0}, - {0x13F, 0x55, 0}, - {0x140, 0x55, 0}, - {0x148, 0, 0}, - {0x149, 0, 0}, - {0x14A, 0, 0}, - {0x14B, 0, 0}, - {0x14C, 0, 0}, - {0x14D, 0, 0}, - {0x14E, 0x1, 1}, - {0x14F, 0, 0}, - {0x150, 0, 0}, - {0x154, 0xc, 0}, - {0x155, 0xc, 0}, - {0x156, 0xc, 0}, - {0x157, 0, 0}, - {0x158, 0x2b, 0}, - {0x159, 0x84, 0}, - {0x15A, 0x15, 0}, - {0x15B, 0xf, 0}, - {0x15C, 0, 0}, - {0x15D, 0, 0}, - {0x15E, 0, 1}, - {0x15F, 0, 1}, - {0x160, 0, 1}, - {0x161, 0, 1}, - {0x162, 0, 1}, - {0x163, 0, 1}, - {0x164, 0, 0}, - {0x165, 0, 0}, - {0x166, 0, 0}, - {0x167, 0, 0}, - {0x168, 0, 0}, - {0x169, 0, 0}, - {0x16A, 0, 1}, - {0x16B, 0, 1}, - {0x16C, 0, 1}, - {0x16D, 0, 0}, - {0x170, 0, 0}, - {0x171, 0x77, 0}, - {0x172, 0x77, 0}, - {0x173, 0x77, 0}, - {0x174, 0x77, 0}, - {0x175, 0, 0}, - {0x176, 0x3, 0}, - {0x177, 0x37, 0}, - {0x178, 0x3, 0}, - {0x179, 0, 0}, - {0x17B, 0x21, 0}, - {0x17C, 0, 0}, - {0x17D, 0xaa, 0}, - {0x17E, 0, 0}, - {0x190, 0, 0}, - {0x191, 0x77, 0}, - {0x192, 0x77, 0}, - {0x193, 0x77, 0}, - {0x194, 0x77, 0}, - {0x195, 0, 0}, - {0x196, 0x3, 0}, - {0x197, 0x37, 0}, - {0x198, 0x3, 0}, - {0x199, 0, 0}, - {0x19B, 0x21, 0}, - {0x19C, 0, 0}, - {0x19D, 0xaa, 0}, - {0x19E, 0, 0}, - {0x1A1, 0x2, 0}, - {0x1A2, 0xf, 0}, - {0x1A3, 0xf, 0}, - {0x1A4, 0, 1}, - {0x1A5, 0, 1}, - {0x1A6, 0, 1}, - {0x1A7, 0x2, 0}, - {0x1A8, 0xf, 0}, - {0x1A9, 0xf, 0}, - {0x1AA, 0, 1}, - {0x1AB, 0, 1}, - {0x1AC, 0, 1}, - {0x1AD, 0x84, 0}, - {0x1AE, 0x60, 0}, - {0x1AF, 0x47, 0}, - {0x1B0, 0x47, 0}, - {0x1B1, 0, 0}, - {0x1B2, 0, 0}, - {0x1B3, 0, 0}, - {0x1B4, 0, 0}, - {0x1B5, 0, 0}, - {0x1B6, 0, 0}, - {0x1B7, 0xc, 1}, - {0x1B8, 0, 0}, - {0x1B9, 0, 0}, - {0x1BA, 0, 0}, - {0x1BB, 0, 0}, - {0x1BC, 0, 0}, - {0x1BD, 0, 0}, - {0x1BE, 0, 0}, - {0x1BF, 0, 0}, - {0x1C0, 0, 0}, - {0x1C1, 0x1, 1}, - {0x1C2, 0x80, 1}, - {0x1C3, 0, 0}, - {0x1C4, 0, 0}, - {0x1C5, 0, 0}, - {0x1C6, 0, 0}, - {0x1C7, 0, 0}, - {0x1C8, 0, 0}, - {0x1C9, 0, 0}, - {0x1CA, 0, 0}, - {0xFFFF, 0, 0} -}; - -static struct radio_20xx_regs regs_2057_rev7[] = { - {0x00, 0, 1}, - {0x01, 0x57, 1}, - {0x02, 0x20, 1}, - {0x03, 0x1f, 0}, - {0x04, 0x4, 0}, - {0x05, 0x2, 0}, - {0x06, 0x1, 0}, - {0x07, 0x1, 0}, - {0x08, 0x1, 0}, - {0x09, 0x69, 0}, - {0x0A, 0x66, 0}, - {0x0B, 0x6, 0}, - {0x0C, 0x18, 0}, - {0x0D, 0x3, 0}, - {0x0E, 0x20, 0}, - {0x0F, 0x20, 0}, - {0x10, 0, 0}, - {0x11, 0x7c, 0}, - {0x12, 0x42, 0}, - {0x13, 0xbd, 0}, - {0x14, 0x7, 0}, - {0x15, 0x87, 0}, - {0x16, 0x8, 0}, - {0x17, 0x17, 0}, - {0x18, 0x7, 0}, - {0x19, 0, 0}, - {0x1A, 0x2, 0}, - {0x1B, 0x13, 0}, - {0x1C, 0x3e, 0}, - {0x1D, 0x3e, 0}, - {0x1E, 0x96, 0}, - {0x1F, 0x4, 0}, - {0x20, 0, 0}, - {0x21, 0, 0}, - {0x22, 0x17, 0}, - {0x23, 0x6, 0}, - {0x24, 0x1, 0}, - {0x25, 0x6, 0}, - {0x26, 0x4, 0}, - {0x27, 0xd, 0}, - {0x28, 0xd, 0}, - {0x29, 0x30, 0}, - {0x2A, 0x32, 0}, - {0x2B, 0x8, 0}, - {0x2C, 0x1c, 0}, - {0x2D, 0x2, 0}, - {0x2E, 0x4, 0}, - {0x2F, 0x7f, 0}, - {0x30, 0x27, 0}, - {0x31, 0, 1}, - {0x32, 0, 1}, - {0x33, 0, 1}, - {0x34, 0, 0}, - {0x35, 0x20, 0}, - {0x36, 0x18, 0}, - {0x37, 0x7, 0}, - {0x38, 0x66, 0}, - {0x39, 0x66, 0}, - {0x3A, 0x66, 0}, - {0x3B, 0x66, 0}, - {0x3C, 0xff, 0}, - {0x3D, 0xff, 0}, - {0x3E, 0xff, 0}, - {0x3F, 0xff, 0}, - {0x40, 0x16, 0}, - {0x41, 0x7, 0}, - {0x42, 0x19, 0}, - {0x43, 0x7, 0}, - {0x44, 0x6, 0}, - {0x45, 0x3, 0}, - {0x46, 0x1, 0}, - {0x47, 0x7, 0}, - {0x48, 0x33, 0}, - {0x49, 0x5, 0}, - {0x4A, 0x77, 0}, - {0x4B, 0x66, 0}, - {0x4C, 0x66, 0}, - {0x4D, 0, 0}, - {0x4E, 0x4, 0}, - {0x4F, 0xc, 0}, - {0x50, 0, 0}, - {0x51, 0x70, 1}, - {0x56, 0x7, 0}, - {0x57, 0, 0}, - {0x58, 0, 0}, - {0x59, 0x88, 1}, - {0x5A, 0, 0}, - {0x5B, 0x1f, 0}, - {0x5C, 0x20, 1}, - {0x5D, 0x1, 0}, - {0x5E, 0x30, 0}, - {0x5F, 0x70, 0}, - {0x60, 0, 0}, - {0x61, 0, 0}, - {0x62, 0x33, 1}, - {0x63, 0xf, 1}, - {0x64, 0x13, 1}, - {0x65, 0, 0}, - {0x66, 0xee, 1}, - {0x69, 0, 0}, - {0x6A, 0x7e, 0}, - {0x6B, 0x3f, 0}, - {0x6C, 0x7f, 0}, - {0x6D, 0x78, 0}, - {0x6E, 0x58, 1}, - {0x6F, 0x88, 0}, - {0x70, 0x8, 0}, - {0x71, 0xf, 0}, - {0x72, 0xbc, 0}, - {0x73, 0x8, 0}, - {0x74, 0x60, 0}, - {0x75, 0x13, 1}, - {0x76, 0x70, 0}, - {0x77, 0, 0}, - {0x78, 0, 0}, - {0x79, 0, 0}, - {0x7A, 0x33, 0}, - {0x7B, 0x13, 1}, - {0x7C, 0x14, 1}, - {0x7D, 0xee, 1}, - {0x80, 0x3c, 0}, - {0x81, 0x1, 1}, - {0x82, 0xa, 0}, - {0x83, 0x9d, 0}, - {0x84, 0xa, 0}, - {0x85, 0, 0}, - {0x86, 0x40, 0}, - {0x87, 0x40, 0}, - {0x88, 0x88, 0}, - {0x89, 0x10, 0}, - {0x8A, 0xf0, 0}, - {0x8B, 0x10, 0}, - {0x8C, 0xf0, 0}, - {0x8D, 0, 0}, - {0x8E, 0, 0}, - {0x8F, 0x10, 0}, - {0x90, 0x55, 0}, - {0x91, 0x3f, 1}, - {0x92, 0x36, 1}, - {0x93, 0, 0}, - {0x94, 0, 0}, - {0x95, 0, 0}, - {0x96, 0x87, 0}, - {0x97, 0x11, 0}, - {0x98, 0, 0}, - {0x99, 0x33, 0}, - {0x9A, 0x88, 0}, - {0x9B, 0, 0}, - {0x9C, 0x87, 0}, - {0x9D, 0x11, 0}, - {0x9E, 0, 0}, - {0x9F, 0x33, 0}, - {0xA0, 0x88, 0}, - {0xA1, 0x20, 1}, - {0xA2, 0x3f, 0}, - {0xA3, 0x44, 0}, - {0xA4, 0x8c, 0}, - {0xA5, 0x6c, 0}, - {0xA6, 0x22, 0}, - {0xA7, 0xbe, 0}, - {0xA8, 0x55, 0}, - {0xAA, 0xc, 0}, - {0xAB, 0xaa, 0}, - {0xAC, 0x2, 0}, - {0xAD, 0, 0}, - {0xAE, 0x10, 0}, - {0xAF, 0x1, 0}, - {0xB0, 0, 0}, - {0xB1, 0, 0}, - {0xB2, 0x80, 0}, - {0xB3, 0x60, 0}, - {0xB4, 0x44, 0}, - {0xB5, 0x55, 0}, - {0xB6, 0x1, 0}, - {0xB7, 0x55, 0}, - {0xB8, 0x1, 0}, - {0xB9, 0x5, 0}, - {0xBA, 0x55, 0}, - {0xBB, 0x55, 0}, - {0xC1, 0, 0}, - {0xC2, 0, 0}, - {0xC3, 0, 0}, - {0xC4, 0, 0}, - {0xC5, 0, 0}, - {0xC6, 0, 0}, - {0xC7, 0, 0}, - {0xC8, 0, 0}, - {0xC9, 0, 0}, - {0xCA, 0, 0}, - {0xCB, 0, 0}, - {0xCC, 0, 0}, - {0xCD, 0, 0}, - {0xCE, 0x5e, 0}, - {0xCF, 0xc, 0}, - {0xD0, 0xc, 0}, - {0xD1, 0xc, 0}, - {0xD2, 0, 0}, - {0xD3, 0x2b, 0}, - {0xD4, 0xc, 0}, - {0xD5, 0, 0}, - {0xD6, 0x70, 1}, - {0xDB, 0x7, 0}, - {0xDC, 0, 0}, - {0xDD, 0, 0}, - {0xDE, 0x88, 1}, - {0xDF, 0, 0}, - {0xE0, 0x1f, 0}, - {0xE1, 0x20, 1}, - {0xE2, 0x1, 0}, - {0xE3, 0x30, 0}, - {0xE4, 0x70, 0}, - {0xE5, 0, 0}, - {0xE6, 0, 0}, - {0xE7, 0x33, 0}, - {0xE8, 0xf, 1}, - {0xE9, 0x13, 1}, - {0xEA, 0, 0}, - {0xEB, 0xee, 1}, - {0xEE, 0, 0}, - {0xEF, 0x7e, 0}, - {0xF0, 0x3f, 0}, - {0xF1, 0x7f, 0}, - {0xF2, 0x78, 0}, - {0xF3, 0x58, 1}, - {0xF4, 0x88, 0}, - {0xF5, 0x8, 0}, - {0xF6, 0xf, 0}, - {0xF7, 0xbc, 0}, - {0xF8, 0x8, 0}, - {0xF9, 0x60, 0}, - {0xFA, 0x13, 1}, - {0xFB, 0x70, 0}, - {0xFC, 0, 0}, - {0xFD, 0, 0}, - {0xFE, 0, 0}, - {0xFF, 0x33, 0}, - {0x100, 0x13, 1}, - {0x101, 0x14, 1}, - {0x102, 0xee, 1}, - {0x105, 0x3c, 0}, - {0x106, 0x1, 1}, - {0x107, 0xa, 0}, - {0x108, 0x9d, 0}, - {0x109, 0xa, 0}, - {0x10A, 0, 0}, - {0x10B, 0x40, 0}, - {0x10C, 0x40, 0}, - {0x10D, 0x88, 0}, - {0x10E, 0x10, 0}, - {0x10F, 0xf0, 0}, - {0x110, 0x10, 0}, - {0x111, 0xf0, 0}, - {0x112, 0, 0}, - {0x113, 0, 0}, - {0x114, 0x10, 0}, - {0x115, 0x55, 0}, - {0x116, 0x3f, 1}, - {0x117, 0x36, 1}, - {0x118, 0, 0}, - {0x119, 0, 0}, - {0x11A, 0, 0}, - {0x11B, 0x87, 0}, - {0x11C, 0x11, 0}, - {0x11D, 0, 0}, - {0x11E, 0x33, 0}, - {0x11F, 0x88, 0}, - {0x120, 0, 0}, - {0x121, 0x87, 0}, - {0x122, 0x11, 0}, - {0x123, 0, 0}, - {0x124, 0x33, 0}, - {0x125, 0x88, 0}, - {0x126, 0x20, 1}, - {0x127, 0x3f, 0}, - {0x128, 0x44, 0}, - {0x129, 0x8c, 0}, - {0x12A, 0x6c, 0}, - {0x12B, 0x22, 0}, - {0x12C, 0xbe, 0}, - {0x12D, 0x55, 0}, - {0x12F, 0xc, 0}, - {0x130, 0xaa, 0}, - {0x131, 0x2, 0}, - {0x132, 0, 0}, - {0x133, 0x10, 0}, - {0x134, 0x1, 0}, - {0x135, 0, 0}, - {0x136, 0, 0}, - {0x137, 0x80, 0}, - {0x138, 0x60, 0}, - {0x139, 0x44, 0}, - {0x13A, 0x55, 0}, - {0x13B, 0x1, 0}, - {0x13C, 0x55, 0}, - {0x13D, 0x1, 0}, - {0x13E, 0x5, 0}, - {0x13F, 0x55, 0}, - {0x140, 0x55, 0}, - {0x146, 0, 0}, - {0x147, 0, 0}, - {0x148, 0, 0}, - {0x149, 0, 0}, - {0x14A, 0, 0}, - {0x14B, 0, 0}, - {0x14C, 0, 0}, - {0x14D, 0, 0}, - {0x14E, 0, 0}, - {0x14F, 0, 0}, - {0x150, 0, 0}, - {0x151, 0, 0}, - {0x154, 0xc, 0}, - {0x155, 0xc, 0}, - {0x156, 0xc, 0}, - {0x157, 0, 0}, - {0x158, 0x2b, 0}, - {0x159, 0x84, 0}, - {0x15A, 0x15, 0}, - {0x15B, 0xf, 0}, - {0x15C, 0, 0}, - {0x15D, 0, 0}, - {0x15E, 0, 1}, - {0x15F, 0, 1}, - {0x160, 0, 1}, - {0x161, 0, 1}, - {0x162, 0, 1}, - {0x163, 0, 1}, - {0x164, 0, 0}, - {0x165, 0, 0}, - {0x166, 0, 0}, - {0x167, 0, 0}, - {0x168, 0, 0}, - {0x169, 0, 0}, - {0x16A, 0, 1}, - {0x16B, 0, 1}, - {0x16C, 0, 1}, - {0x16D, 0, 0}, - {0x170, 0, 0}, - {0x171, 0x77, 0}, - {0x172, 0x77, 0}, - {0x173, 0x77, 0}, - {0x174, 0x77, 0}, - {0x175, 0, 0}, - {0x176, 0x3, 0}, - {0x177, 0x37, 0}, - {0x178, 0x3, 0}, - {0x179, 0, 0}, - {0x17A, 0x21, 0}, - {0x17B, 0x21, 0}, - {0x17C, 0, 0}, - {0x17D, 0xaa, 0}, - {0x17E, 0, 0}, - {0x17F, 0xaa, 0}, - {0x180, 0, 0}, - {0x190, 0, 0}, - {0x191, 0x77, 0}, - {0x192, 0x77, 0}, - {0x193, 0x77, 0}, - {0x194, 0x77, 0}, - {0x195, 0, 0}, - {0x196, 0x3, 0}, - {0x197, 0x37, 0}, - {0x198, 0x3, 0}, - {0x199, 0, 0}, - {0x19A, 0x21, 0}, - {0x19B, 0x21, 0}, - {0x19C, 0, 0}, - {0x19D, 0xaa, 0}, - {0x19E, 0, 0}, - {0x19F, 0xaa, 0}, - {0x1A0, 0, 0}, - {0x1A1, 0x2, 0}, - {0x1A2, 0xf, 0}, - {0x1A3, 0xf, 0}, - {0x1A4, 0, 1}, - {0x1A5, 0, 1}, - {0x1A6, 0, 1}, - {0x1A7, 0x2, 0}, - {0x1A8, 0xf, 0}, - {0x1A9, 0xf, 0}, - {0x1AA, 0, 1}, - {0x1AB, 0, 1}, - {0x1AC, 0, 1}, - {0x1AD, 0x84, 0}, - {0x1AE, 0x60, 0}, - {0x1AF, 0x47, 0}, - {0x1B0, 0x47, 0}, - {0x1B1, 0, 0}, - {0x1B2, 0, 0}, - {0x1B3, 0, 0}, - {0x1B4, 0, 0}, - {0x1B5, 0, 0}, - {0x1B6, 0, 0}, - {0x1B7, 0x5, 1}, - {0x1B8, 0, 0}, - {0x1B9, 0, 0}, - {0x1BA, 0, 0}, - {0x1BB, 0, 0}, - {0x1BC, 0, 0}, - {0x1BD, 0, 0}, - {0x1BE, 0, 0}, - {0x1BF, 0, 0}, - {0x1C0, 0, 0}, - {0x1C1, 0, 0}, - {0x1C2, 0xa0, 1}, - {0x1C3, 0, 0}, - {0x1C4, 0, 0}, - {0x1C5, 0, 0}, - {0x1C6, 0, 0}, - {0x1C7, 0, 0}, - {0x1C8, 0, 0}, - {0x1C9, 0, 0}, - {0x1CA, 0, 0}, - {0xFFFF, 0, 0} -}; - -static struct radio_20xx_regs regs_2057_rev8[] = { - {0x00, 0x8, 1}, - {0x01, 0x57, 1}, - {0x02, 0x20, 1}, - {0x03, 0x1f, 0}, - {0x04, 0x4, 0}, - {0x05, 0x2, 0}, - {0x06, 0x1, 0}, - {0x07, 0x1, 0}, - {0x08, 0x1, 0}, - {0x09, 0x69, 0}, - {0x0A, 0x66, 0}, - {0x0B, 0x6, 0}, - {0x0C, 0x18, 0}, - {0x0D, 0x3, 0}, - {0x0E, 0x20, 0}, - {0x0F, 0x20, 0}, - {0x10, 0, 0}, - {0x11, 0x7c, 0}, - {0x12, 0x42, 0}, - {0x13, 0xbd, 0}, - {0x14, 0x7, 0}, - {0x15, 0x87, 0}, - {0x16, 0x8, 0}, - {0x17, 0x17, 0}, - {0x18, 0x7, 0}, - {0x19, 0, 0}, - {0x1A, 0x2, 0}, - {0x1B, 0x13, 0}, - {0x1C, 0x3e, 0}, - {0x1D, 0x3e, 0}, - {0x1E, 0x96, 0}, - {0x1F, 0x4, 0}, - {0x20, 0, 0}, - {0x21, 0, 0}, - {0x22, 0x17, 0}, - {0x23, 0x6, 0}, - {0x24, 0x1, 0}, - {0x25, 0x6, 0}, - {0x26, 0x4, 0}, - {0x27, 0xd, 0}, - {0x28, 0xd, 0}, - {0x29, 0x30, 0}, - {0x2A, 0x32, 0}, - {0x2B, 0x8, 0}, - {0x2C, 0x1c, 0}, - {0x2D, 0x2, 0}, - {0x2E, 0x4, 0}, - {0x2F, 0x7f, 0}, - {0x30, 0x27, 0}, - {0x31, 0, 1}, - {0x32, 0, 1}, - {0x33, 0, 1}, - {0x34, 0, 0}, - {0x35, 0x20, 0}, - {0x36, 0x18, 0}, - {0x37, 0x7, 0}, - {0x38, 0x66, 0}, - {0x39, 0x66, 0}, - {0x3A, 0x66, 0}, - {0x3B, 0x66, 0}, - {0x3C, 0xff, 0}, - {0x3D, 0xff, 0}, - {0x3E, 0xff, 0}, - {0x3F, 0xff, 0}, - {0x40, 0x16, 0}, - {0x41, 0x7, 0}, - {0x42, 0x19, 0}, - {0x43, 0x7, 0}, - {0x44, 0x6, 0}, - {0x45, 0x3, 0}, - {0x46, 0x1, 0}, - {0x47, 0x7, 0}, - {0x48, 0x33, 0}, - {0x49, 0x5, 0}, - {0x4A, 0x77, 0}, - {0x4B, 0x66, 0}, - {0x4C, 0x66, 0}, - {0x4D, 0, 0}, - {0x4E, 0x4, 0}, - {0x4F, 0xc, 0}, - {0x50, 0, 0}, - {0x51, 0x70, 1}, - {0x56, 0x7, 0}, - {0x57, 0, 0}, - {0x58, 0, 0}, - {0x59, 0x88, 1}, - {0x5A, 0, 0}, - {0x5B, 0x1f, 0}, - {0x5C, 0x20, 1}, - {0x5D, 0x1, 0}, - {0x5E, 0x30, 0}, - {0x5F, 0x70, 0}, - {0x60, 0, 0}, - {0x61, 0, 0}, - {0x62, 0x33, 1}, - {0x63, 0xf, 1}, - {0x64, 0xf, 1}, - {0x65, 0, 0}, - {0x66, 0x11, 0}, - {0x69, 0, 0}, - {0x6A, 0x7e, 0}, - {0x6B, 0x3f, 0}, - {0x6C, 0x7f, 0}, - {0x6D, 0x78, 0}, - {0x6E, 0x58, 1}, - {0x6F, 0x88, 0}, - {0x70, 0x8, 0}, - {0x71, 0xf, 0}, - {0x72, 0xbc, 0}, - {0x73, 0x8, 0}, - {0x74, 0x60, 0}, - {0x75, 0x13, 1}, - {0x76, 0x70, 0}, - {0x77, 0, 0}, - {0x78, 0, 0}, - {0x79, 0, 0}, - {0x7A, 0x33, 0}, - {0x7B, 0x13, 1}, - {0x7C, 0xf, 1}, - {0x7D, 0xee, 1}, - {0x80, 0x3c, 0}, - {0x81, 0x1, 1}, - {0x82, 0xa, 0}, - {0x83, 0x9d, 0}, - {0x84, 0xa, 0}, - {0x85, 0, 0}, - {0x86, 0x40, 0}, - {0x87, 0x40, 0}, - {0x88, 0x88, 0}, - {0x89, 0x10, 0}, - {0x8A, 0xf0, 0}, - {0x8B, 0x10, 0}, - {0x8C, 0xf0, 0}, - {0x8D, 0, 0}, - {0x8E, 0, 0}, - {0x8F, 0x10, 0}, - {0x90, 0x55, 0}, - {0x91, 0x3f, 1}, - {0x92, 0x36, 1}, - {0x93, 0, 0}, - {0x94, 0, 0}, - {0x95, 0, 0}, - {0x96, 0x87, 0}, - {0x97, 0x11, 0}, - {0x98, 0, 0}, - {0x99, 0x33, 0}, - {0x9A, 0x88, 0}, - {0x9B, 0, 0}, - {0x9C, 0x87, 0}, - {0x9D, 0x11, 0}, - {0x9E, 0, 0}, - {0x9F, 0x33, 0}, - {0xA0, 0x88, 0}, - {0xA1, 0x20, 1}, - {0xA2, 0x3f, 0}, - {0xA3, 0x44, 0}, - {0xA4, 0x8c, 0}, - {0xA5, 0x6c, 0}, - {0xA6, 0x22, 0}, - {0xA7, 0xbe, 0}, - {0xA8, 0x55, 0}, - {0xAA, 0xc, 0}, - {0xAB, 0xaa, 0}, - {0xAC, 0x2, 0}, - {0xAD, 0, 0}, - {0xAE, 0x10, 0}, - {0xAF, 0x1, 0}, - {0xB0, 0, 0}, - {0xB1, 0, 0}, - {0xB2, 0x80, 0}, - {0xB3, 0x60, 0}, - {0xB4, 0x44, 0}, - {0xB5, 0x55, 0}, - {0xB6, 0x1, 0}, - {0xB7, 0x55, 0}, - {0xB8, 0x1, 0}, - {0xB9, 0x5, 0}, - {0xBA, 0x55, 0}, - {0xBB, 0x55, 0}, - {0xC1, 0, 0}, - {0xC2, 0, 0}, - {0xC3, 0, 0}, - {0xC4, 0, 0}, - {0xC5, 0, 0}, - {0xC6, 0, 0}, - {0xC7, 0, 0}, - {0xC8, 0, 0}, - {0xC9, 0x1, 1}, - {0xCA, 0, 0}, - {0xCB, 0, 0}, - {0xCC, 0, 0}, - {0xCD, 0, 0}, - {0xCE, 0x5e, 0}, - {0xCF, 0xc, 0}, - {0xD0, 0xc, 0}, - {0xD1, 0xc, 0}, - {0xD2, 0, 0}, - {0xD3, 0x2b, 0}, - {0xD4, 0xc, 0}, - {0xD5, 0, 0}, - {0xD6, 0x70, 1}, - {0xDB, 0x7, 0}, - {0xDC, 0, 0}, - {0xDD, 0, 0}, - {0xDE, 0x88, 1}, - {0xDF, 0, 0}, - {0xE0, 0x1f, 0}, - {0xE1, 0x20, 1}, - {0xE2, 0x1, 0}, - {0xE3, 0x30, 0}, - {0xE4, 0x70, 0}, - {0xE5, 0, 0}, - {0xE6, 0, 0}, - {0xE7, 0x33, 0}, - {0xE8, 0xf, 1}, - {0xE9, 0xf, 1}, - {0xEA, 0, 0}, - {0xEB, 0x11, 0}, - {0xEE, 0, 0}, - {0xEF, 0x7e, 0}, - {0xF0, 0x3f, 0}, - {0xF1, 0x7f, 0}, - {0xF2, 0x78, 0}, - {0xF3, 0x58, 1}, - {0xF4, 0x88, 0}, - {0xF5, 0x8, 0}, - {0xF6, 0xf, 0}, - {0xF7, 0xbc, 0}, - {0xF8, 0x8, 0}, - {0xF9, 0x60, 0}, - {0xFA, 0x13, 1}, - {0xFB, 0x70, 0}, - {0xFC, 0, 0}, - {0xFD, 0, 0}, - {0xFE, 0, 0}, - {0xFF, 0x33, 0}, - {0x100, 0x13, 1}, - {0x101, 0xf, 1}, - {0x102, 0xee, 1}, - {0x105, 0x3c, 0}, - {0x106, 0x1, 1}, - {0x107, 0xa, 0}, - {0x108, 0x9d, 0}, - {0x109, 0xa, 0}, - {0x10A, 0, 0}, - {0x10B, 0x40, 0}, - {0x10C, 0x40, 0}, - {0x10D, 0x88, 0}, - {0x10E, 0x10, 0}, - {0x10F, 0xf0, 0}, - {0x110, 0x10, 0}, - {0x111, 0xf0, 0}, - {0x112, 0, 0}, - {0x113, 0, 0}, - {0x114, 0x10, 0}, - {0x115, 0x55, 0}, - {0x116, 0x3f, 1}, - {0x117, 0x36, 1}, - {0x118, 0, 0}, - {0x119, 0, 0}, - {0x11A, 0, 0}, - {0x11B, 0x87, 0}, - {0x11C, 0x11, 0}, - {0x11D, 0, 0}, - {0x11E, 0x33, 0}, - {0x11F, 0x88, 0}, - {0x120, 0, 0}, - {0x121, 0x87, 0}, - {0x122, 0x11, 0}, - {0x123, 0, 0}, - {0x124, 0x33, 0}, - {0x125, 0x88, 0}, - {0x126, 0x20, 1}, - {0x127, 0x3f, 0}, - {0x128, 0x44, 0}, - {0x129, 0x8c, 0}, - {0x12A, 0x6c, 0}, - {0x12B, 0x22, 0}, - {0x12C, 0xbe, 0}, - {0x12D, 0x55, 0}, - {0x12F, 0xc, 0}, - {0x130, 0xaa, 0}, - {0x131, 0x2, 0}, - {0x132, 0, 0}, - {0x133, 0x10, 0}, - {0x134, 0x1, 0}, - {0x135, 0, 0}, - {0x136, 0, 0}, - {0x137, 0x80, 0}, - {0x138, 0x60, 0}, - {0x139, 0x44, 0}, - {0x13A, 0x55, 0}, - {0x13B, 0x1, 0}, - {0x13C, 0x55, 0}, - {0x13D, 0x1, 0}, - {0x13E, 0x5, 0}, - {0x13F, 0x55, 0}, - {0x140, 0x55, 0}, - {0x146, 0, 0}, - {0x147, 0, 0}, - {0x148, 0, 0}, - {0x149, 0, 0}, - {0x14A, 0, 0}, - {0x14B, 0, 0}, - {0x14C, 0, 0}, - {0x14D, 0, 0}, - {0x14E, 0x1, 1}, - {0x14F, 0, 0}, - {0x150, 0, 0}, - {0x151, 0, 0}, - {0x154, 0xc, 0}, - {0x155, 0xc, 0}, - {0x156, 0xc, 0}, - {0x157, 0, 0}, - {0x158, 0x2b, 0}, - {0x159, 0x84, 0}, - {0x15A, 0x15, 0}, - {0x15B, 0xf, 0}, - {0x15C, 0, 0}, - {0x15D, 0, 0}, - {0x15E, 0, 1}, - {0x15F, 0, 1}, - {0x160, 0, 1}, - {0x161, 0, 1}, - {0x162, 0, 1}, - {0x163, 0, 1}, - {0x164, 0, 0}, - {0x165, 0, 0}, - {0x166, 0, 0}, - {0x167, 0, 0}, - {0x168, 0, 0}, - {0x169, 0, 0}, - {0x16A, 0, 1}, - {0x16B, 0, 1}, - {0x16C, 0, 1}, - {0x16D, 0, 0}, - {0x170, 0, 0}, - {0x171, 0x77, 0}, - {0x172, 0x77, 0}, - {0x173, 0x77, 0}, - {0x174, 0x77, 0}, - {0x175, 0, 0}, - {0x176, 0x3, 0}, - {0x177, 0x37, 0}, - {0x178, 0x3, 0}, - {0x179, 0, 0}, - {0x17A, 0x21, 0}, - {0x17B, 0x21, 0}, - {0x17C, 0, 0}, - {0x17D, 0xaa, 0}, - {0x17E, 0, 0}, - {0x17F, 0xaa, 0}, - {0x180, 0, 0}, - {0x190, 0, 0}, - {0x191, 0x77, 0}, - {0x192, 0x77, 0}, - {0x193, 0x77, 0}, - {0x194, 0x77, 0}, - {0x195, 0, 0}, - {0x196, 0x3, 0}, - {0x197, 0x37, 0}, - {0x198, 0x3, 0}, - {0x199, 0, 0}, - {0x19A, 0x21, 0}, - {0x19B, 0x21, 0}, - {0x19C, 0, 0}, - {0x19D, 0xaa, 0}, - {0x19E, 0, 0}, - {0x19F, 0xaa, 0}, - {0x1A0, 0, 0}, - {0x1A1, 0x2, 0}, - {0x1A2, 0xf, 0}, - {0x1A3, 0xf, 0}, - {0x1A4, 0, 1}, - {0x1A5, 0, 1}, - {0x1A6, 0, 1}, - {0x1A7, 0x2, 0}, - {0x1A8, 0xf, 0}, - {0x1A9, 0xf, 0}, - {0x1AA, 0, 1}, - {0x1AB, 0, 1}, - {0x1AC, 0, 1}, - {0x1AD, 0x84, 0}, - {0x1AE, 0x60, 0}, - {0x1AF, 0x47, 0}, - {0x1B0, 0x47, 0}, - {0x1B1, 0, 0}, - {0x1B2, 0, 0}, - {0x1B3, 0, 0}, - {0x1B4, 0, 0}, - {0x1B5, 0, 0}, - {0x1B6, 0, 0}, - {0x1B7, 0x5, 1}, - {0x1B8, 0, 0}, - {0x1B9, 0, 0}, - {0x1BA, 0, 0}, - {0x1BB, 0, 0}, - {0x1BC, 0, 0}, - {0x1BD, 0, 0}, - {0x1BE, 0, 0}, - {0x1BF, 0, 0}, - {0x1C0, 0, 0}, - {0x1C1, 0, 0}, - {0x1C2, 0xa0, 1}, - {0x1C3, 0, 0}, - {0x1C4, 0, 0}, - {0x1C5, 0, 0}, - {0x1C6, 0, 0}, - {0x1C7, 0, 0}, - {0x1C8, 0, 0}, - {0x1C9, 0, 0}, - {0x1CA, 0, 0}, - {0xFFFF, 0, 0} -}; - -static s16 nphy_def_lnagains[] = { -2, 10, 19, 25 }; - -static s32 nphy_lnagain_est0[] = { -315, 40370 }; -static s32 nphy_lnagain_est1[] = { -224, 23242 }; - -static const u16 tbl_iqcal_gainparams_nphy[2][NPHY_IQCAL_NUMGAINS][8] = { - { - {0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69}, - {0x700, 7, 0, 0, 0x69, 0x69, 0x69, 0x69}, - {0x710, 7, 1, 0, 0x68, 0x68, 0x68, 0x68}, - {0x720, 7, 2, 0, 0x67, 0x67, 0x67, 0x67}, - {0x730, 7, 3, 0, 0x66, 0x66, 0x66, 0x66}, - {0x740, 7, 4, 0, 0x65, 0x65, 0x65, 0x65}, - {0x741, 7, 4, 1, 0x65, 0x65, 0x65, 0x65}, - {0x742, 7, 4, 2, 0x65, 0x65, 0x65, 0x65}, - {0x743, 7, 4, 3, 0x65, 0x65, 0x65, 0x65} - }, - { - {0x000, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, - {0x700, 7, 0, 0, 0x79, 0x79, 0x79, 0x79}, - {0x710, 7, 1, 0, 0x79, 0x79, 0x79, 0x79}, - {0x720, 7, 2, 0, 0x78, 0x78, 0x78, 0x78}, - {0x730, 7, 3, 0, 0x78, 0x78, 0x78, 0x78}, - {0x740, 7, 4, 0, 0x78, 0x78, 0x78, 0x78}, - {0x741, 7, 4, 1, 0x78, 0x78, 0x78, 0x78}, - {0x742, 7, 4, 2, 0x78, 0x78, 0x78, 0x78}, - {0x743, 7, 4, 3, 0x78, 0x78, 0x78, 0x78} - } -}; - -static const u32 nphy_tpc_txgain[] = { - 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, - 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44, - 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844, - 0x03c82842, 0x03c42b44, 0x03c42b42, 0x03c42a44, - 0x03c42a42, 0x03c42944, 0x03c42942, 0x03c42844, - 0x03c42842, 0x03c42744, 0x03c42742, 0x03c42644, - 0x03c42642, 0x03c42544, 0x03c42542, 0x03c42444, - 0x03c42442, 0x03c02b44, 0x03c02b42, 0x03c02a44, - 0x03c02a42, 0x03c02944, 0x03c02942, 0x03c02844, - 0x03c02842, 0x03c02744, 0x03c02742, 0x03b02b44, - 0x03b02b42, 0x03b02a44, 0x03b02a42, 0x03b02944, - 0x03b02942, 0x03b02844, 0x03b02842, 0x03b02744, - 0x03b02742, 0x03b02644, 0x03b02642, 0x03b02544, - 0x03b02542, 0x03a02b44, 0x03a02b42, 0x03a02a44, - 0x03a02a42, 0x03a02944, 0x03a02942, 0x03a02844, - 0x03a02842, 0x03a02744, 0x03a02742, 0x03902b44, - 0x03902b42, 0x03902a44, 0x03902a42, 0x03902944, - 0x03902942, 0x03902844, 0x03902842, 0x03902744, - 0x03902742, 0x03902644, 0x03902642, 0x03902544, - 0x03902542, 0x03802b44, 0x03802b42, 0x03802a44, - 0x03802a42, 0x03802944, 0x03802942, 0x03802844, - 0x03802842, 0x03802744, 0x03802742, 0x03802644, - 0x03802642, 0x03802544, 0x03802542, 0x03802444, - 0x03802442, 0x03802344, 0x03802342, 0x03802244, - 0x03802242, 0x03802144, 0x03802142, 0x03802044, - 0x03802042, 0x03801f44, 0x03801f42, 0x03801e44, - 0x03801e42, 0x03801d44, 0x03801d42, 0x03801c44, - 0x03801c42, 0x03801b44, 0x03801b42, 0x03801a44, - 0x03801a42, 0x03801944, 0x03801942, 0x03801844, - 0x03801842, 0x03801744, 0x03801742, 0x03801644, - 0x03801642, 0x03801544, 0x03801542, 0x03801444, - 0x03801442, 0x03801344, 0x03801342, 0x00002b00 -}; - -static const u16 nphy_tpc_loscale[] = { - 256, 256, 271, 271, 287, 256, 256, 271, - 271, 287, 287, 304, 304, 256, 256, 271, - 271, 287, 287, 304, 304, 322, 322, 341, - 341, 362, 362, 383, 383, 256, 256, 271, - 271, 287, 287, 304, 304, 322, 322, 256, - 256, 271, 271, 287, 287, 304, 304, 322, - 322, 341, 341, 362, 362, 256, 256, 271, - 271, 287, 287, 304, 304, 322, 322, 256, - 256, 271, 271, 287, 287, 304, 304, 322, - 322, 341, 341, 362, 362, 256, 256, 271, - 271, 287, 287, 304, 304, 322, 322, 341, - 341, 362, 362, 383, 383, 406, 406, 430, - 430, 455, 455, 482, 482, 511, 511, 541, - 541, 573, 573, 607, 607, 643, 643, 681, - 681, 722, 722, 764, 764, 810, 810, 858, - 858, 908, 908, 962, 962, 1019, 1019, 256 -}; - -static u32 nphy_tpc_txgain_ipa[] = { - 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029, - 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025, - 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029, - 0x5ef70028, 0x5ef70027, 0x5ef70026, 0x5ef70025, - 0x5df7002d, 0x5df7002b, 0x5df7002a, 0x5df70029, - 0x5df70028, 0x5df70027, 0x5df70026, 0x5df70025, - 0x5cf7002d, 0x5cf7002b, 0x5cf7002a, 0x5cf70029, - 0x5cf70028, 0x5cf70027, 0x5cf70026, 0x5cf70025, - 0x5bf7002d, 0x5bf7002b, 0x5bf7002a, 0x5bf70029, - 0x5bf70028, 0x5bf70027, 0x5bf70026, 0x5bf70025, - 0x5af7002d, 0x5af7002b, 0x5af7002a, 0x5af70029, - 0x5af70028, 0x5af70027, 0x5af70026, 0x5af70025, - 0x59f7002d, 0x59f7002b, 0x59f7002a, 0x59f70029, - 0x59f70028, 0x59f70027, 0x59f70026, 0x59f70025, - 0x58f7002d, 0x58f7002b, 0x58f7002a, 0x58f70029, - 0x58f70028, 0x58f70027, 0x58f70026, 0x58f70025, - 0x57f7002d, 0x57f7002b, 0x57f7002a, 0x57f70029, - 0x57f70028, 0x57f70027, 0x57f70026, 0x57f70025, - 0x56f7002d, 0x56f7002b, 0x56f7002a, 0x56f70029, - 0x56f70028, 0x56f70027, 0x56f70026, 0x56f70025, - 0x55f7002d, 0x55f7002b, 0x55f7002a, 0x55f70029, - 0x55f70028, 0x55f70027, 0x55f70026, 0x55f70025, - 0x54f7002d, 0x54f7002b, 0x54f7002a, 0x54f70029, - 0x54f70028, 0x54f70027, 0x54f70026, 0x54f70025, - 0x53f7002d, 0x53f7002b, 0x53f7002a, 0x53f70029, - 0x53f70028, 0x53f70027, 0x53f70026, 0x53f70025, - 0x52f7002d, 0x52f7002b, 0x52f7002a, 0x52f70029, - 0x52f70028, 0x52f70027, 0x52f70026, 0x52f70025, - 0x51f7002d, 0x51f7002b, 0x51f7002a, 0x51f70029, - 0x51f70028, 0x51f70027, 0x51f70026, 0x51f70025, - 0x50f7002d, 0x50f7002b, 0x50f7002a, 0x50f70029, - 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025 -}; - -static u32 nphy_tpc_txgain_ipa_rev5[] = { - 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029, - 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025, - 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029, - 0x1ef70028, 0x1ef70027, 0x1ef70026, 0x1ef70025, - 0x1df7002d, 0x1df7002b, 0x1df7002a, 0x1df70029, - 0x1df70028, 0x1df70027, 0x1df70026, 0x1df70025, - 0x1cf7002d, 0x1cf7002b, 0x1cf7002a, 0x1cf70029, - 0x1cf70028, 0x1cf70027, 0x1cf70026, 0x1cf70025, - 0x1bf7002d, 0x1bf7002b, 0x1bf7002a, 0x1bf70029, - 0x1bf70028, 0x1bf70027, 0x1bf70026, 0x1bf70025, - 0x1af7002d, 0x1af7002b, 0x1af7002a, 0x1af70029, - 0x1af70028, 0x1af70027, 0x1af70026, 0x1af70025, - 0x19f7002d, 0x19f7002b, 0x19f7002a, 0x19f70029, - 0x19f70028, 0x19f70027, 0x19f70026, 0x19f70025, - 0x18f7002d, 0x18f7002b, 0x18f7002a, 0x18f70029, - 0x18f70028, 0x18f70027, 0x18f70026, 0x18f70025, - 0x17f7002d, 0x17f7002b, 0x17f7002a, 0x17f70029, - 0x17f70028, 0x17f70027, 0x17f70026, 0x17f70025, - 0x16f7002d, 0x16f7002b, 0x16f7002a, 0x16f70029, - 0x16f70028, 0x16f70027, 0x16f70026, 0x16f70025, - 0x15f7002d, 0x15f7002b, 0x15f7002a, 0x15f70029, - 0x15f70028, 0x15f70027, 0x15f70026, 0x15f70025, - 0x14f7002d, 0x14f7002b, 0x14f7002a, 0x14f70029, - 0x14f70028, 0x14f70027, 0x14f70026, 0x14f70025, - 0x13f7002d, 0x13f7002b, 0x13f7002a, 0x13f70029, - 0x13f70028, 0x13f70027, 0x13f70026, 0x13f70025, - 0x12f7002d, 0x12f7002b, 0x12f7002a, 0x12f70029, - 0x12f70028, 0x12f70027, 0x12f70026, 0x12f70025, - 0x11f7002d, 0x11f7002b, 0x11f7002a, 0x11f70029, - 0x11f70028, 0x11f70027, 0x11f70026, 0x11f70025, - 0x10f7002d, 0x10f7002b, 0x10f7002a, 0x10f70029, - 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025 -}; - -static u32 nphy_tpc_txgain_ipa_rev6[] = { - 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029, - 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025, - 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029, - 0x0ef70028, 0x0ef70027, 0x0ef70026, 0x0ef70025, - 0x0df7002d, 0x0df7002b, 0x0df7002a, 0x0df70029, - 0x0df70028, 0x0df70027, 0x0df70026, 0x0df70025, - 0x0cf7002d, 0x0cf7002b, 0x0cf7002a, 0x0cf70029, - 0x0cf70028, 0x0cf70027, 0x0cf70026, 0x0cf70025, - 0x0bf7002d, 0x0bf7002b, 0x0bf7002a, 0x0bf70029, - 0x0bf70028, 0x0bf70027, 0x0bf70026, 0x0bf70025, - 0x0af7002d, 0x0af7002b, 0x0af7002a, 0x0af70029, - 0x0af70028, 0x0af70027, 0x0af70026, 0x0af70025, - 0x09f7002d, 0x09f7002b, 0x09f7002a, 0x09f70029, - 0x09f70028, 0x09f70027, 0x09f70026, 0x09f70025, - 0x08f7002d, 0x08f7002b, 0x08f7002a, 0x08f70029, - 0x08f70028, 0x08f70027, 0x08f70026, 0x08f70025, - 0x07f7002d, 0x07f7002b, 0x07f7002a, 0x07f70029, - 0x07f70028, 0x07f70027, 0x07f70026, 0x07f70025, - 0x06f7002d, 0x06f7002b, 0x06f7002a, 0x06f70029, - 0x06f70028, 0x06f70027, 0x06f70026, 0x06f70025, - 0x05f7002d, 0x05f7002b, 0x05f7002a, 0x05f70029, - 0x05f70028, 0x05f70027, 0x05f70026, 0x05f70025, - 0x04f7002d, 0x04f7002b, 0x04f7002a, 0x04f70029, - 0x04f70028, 0x04f70027, 0x04f70026, 0x04f70025, - 0x03f7002d, 0x03f7002b, 0x03f7002a, 0x03f70029, - 0x03f70028, 0x03f70027, 0x03f70026, 0x03f70025, - 0x02f7002d, 0x02f7002b, 0x02f7002a, 0x02f70029, - 0x02f70028, 0x02f70027, 0x02f70026, 0x02f70025, - 0x01f7002d, 0x01f7002b, 0x01f7002a, 0x01f70029, - 0x01f70028, 0x01f70027, 0x01f70026, 0x01f70025, - 0x00f7002d, 0x00f7002b, 0x00f7002a, 0x00f70029, - 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025 -}; - -static u32 nphy_tpc_txgain_ipa_2g_2057rev3[] = { - 0x70ff0040, 0x70f7003e, 0x70ef003b, 0x70e70039, - 0x70df0037, 0x70d70036, 0x70cf0033, 0x70c70032, - 0x70bf0031, 0x70b7002f, 0x70af002e, 0x70a7002d, - 0x709f002d, 0x7097002c, 0x708f002c, 0x7087002c, - 0x707f002b, 0x7077002c, 0x706f002c, 0x7067002d, - 0x705f002e, 0x705f002b, 0x705f0029, 0x7057002a, - 0x70570028, 0x704f002a, 0x7047002c, 0x7047002a, - 0x70470028, 0x70470026, 0x70470024, 0x70470022, - 0x7047001f, 0x70370027, 0x70370024, 0x70370022, - 0x70370020, 0x7037001f, 0x7037001d, 0x7037001b, - 0x7037001a, 0x70370018, 0x70370017, 0x7027001e, - 0x7027001d, 0x7027001a, 0x701f0024, 0x701f0022, - 0x701f0020, 0x701f001f, 0x701f001d, 0x701f001b, - 0x701f001a, 0x701f0018, 0x701f0017, 0x701f0015, - 0x701f0014, 0x701f0013, 0x701f0012, 0x701f0011, - 0x70170019, 0x70170018, 0x70170016, 0x70170015, - 0x70170014, 0x70170013, 0x70170012, 0x70170010, - 0x70170010, 0x7017000f, 0x700f001d, 0x700f001b, - 0x700f001a, 0x700f0018, 0x700f0017, 0x700f0015, - 0x700f0015, 0x700f0013, 0x700f0013, 0x700f0011, - 0x700f0010, 0x700f0010, 0x700f000f, 0x700f000e, - 0x700f000d, 0x700f000c, 0x700f000b, 0x700f000b, - 0x700f000b, 0x700f000a, 0x700f0009, 0x700f0009, - 0x700f0009, 0x700f0008, 0x700f0007, 0x700f0007, - 0x700f0006, 0x700f0006, 0x700f0006, 0x700f0006, - 0x700f0005, 0x700f0005, 0x700f0005, 0x700f0004, - 0x700f0004, 0x700f0004, 0x700f0004, 0x700f0004, - 0x700f0004, 0x700f0003, 0x700f0003, 0x700f0003, - 0x700f0003, 0x700f0002, 0x700f0002, 0x700f0002, - 0x700f0002, 0x700f0002, 0x700f0002, 0x700f0001, - 0x700f0001, 0x700f0001, 0x700f0001, 0x700f0001, - 0x700f0001, 0x700f0001, 0x700f0001, 0x700f0001 -}; - -static u32 nphy_tpc_txgain_ipa_2g_2057rev4n6[] = { - 0xf0ff0040, 0xf0f7003e, 0xf0ef003b, 0xf0e70039, - 0xf0df0037, 0xf0d70036, 0xf0cf0033, 0xf0c70032, - 0xf0bf0031, 0xf0b7002f, 0xf0af002e, 0xf0a7002d, - 0xf09f002d, 0xf097002c, 0xf08f002c, 0xf087002c, - 0xf07f002b, 0xf077002c, 0xf06f002c, 0xf067002d, - 0xf05f002e, 0xf05f002b, 0xf05f0029, 0xf057002a, - 0xf0570028, 0xf04f002a, 0xf047002c, 0xf047002a, - 0xf0470028, 0xf0470026, 0xf0470024, 0xf0470022, - 0xf047001f, 0xf0370027, 0xf0370024, 0xf0370022, - 0xf0370020, 0xf037001f, 0xf037001d, 0xf037001b, - 0xf037001a, 0xf0370018, 0xf0370017, 0xf027001e, - 0xf027001d, 0xf027001a, 0xf01f0024, 0xf01f0022, - 0xf01f0020, 0xf01f001f, 0xf01f001d, 0xf01f001b, - 0xf01f001a, 0xf01f0018, 0xf01f0017, 0xf01f0015, - 0xf01f0014, 0xf01f0013, 0xf01f0012, 0xf01f0011, - 0xf0170019, 0xf0170018, 0xf0170016, 0xf0170015, - 0xf0170014, 0xf0170013, 0xf0170012, 0xf0170010, - 0xf0170010, 0xf017000f, 0xf00f001d, 0xf00f001b, - 0xf00f001a, 0xf00f0018, 0xf00f0017, 0xf00f0015, - 0xf00f0015, 0xf00f0013, 0xf00f0013, 0xf00f0011, - 0xf00f0010, 0xf00f0010, 0xf00f000f, 0xf00f000e, - 0xf00f000d, 0xf00f000c, 0xf00f000b, 0xf00f000b, - 0xf00f000b, 0xf00f000a, 0xf00f0009, 0xf00f0009, - 0xf00f0009, 0xf00f0008, 0xf00f0007, 0xf00f0007, - 0xf00f0006, 0xf00f0006, 0xf00f0006, 0xf00f0006, - 0xf00f0005, 0xf00f0005, 0xf00f0005, 0xf00f0004, - 0xf00f0004, 0xf00f0004, 0xf00f0004, 0xf00f0004, - 0xf00f0004, 0xf00f0003, 0xf00f0003, 0xf00f0003, - 0xf00f0003, 0xf00f0002, 0xf00f0002, 0xf00f0002, - 0xf00f0002, 0xf00f0002, 0xf00f0002, 0xf00f0001, - 0xf00f0001, 0xf00f0001, 0xf00f0001, 0xf00f0001, - 0xf00f0001, 0xf00f0001, 0xf00f0001, 0xf00f0001 -}; - -static u32 nphy_tpc_txgain_ipa_2g_2057rev5[] = { - 0x30ff0031, 0x30e70031, 0x30e7002e, 0x30cf002e, - 0x30bf002e, 0x30af002e, 0x309f002f, 0x307f0033, - 0x307f0031, 0x307f002e, 0x3077002e, 0x306f002e, - 0x3067002e, 0x305f002f, 0x30570030, 0x3057002d, - 0x304f002e, 0x30470031, 0x3047002e, 0x3047002c, - 0x30470029, 0x303f002c, 0x303f0029, 0x3037002d, - 0x3037002a, 0x30370028, 0x302f002c, 0x302f002a, - 0x302f0028, 0x302f0026, 0x3027002c, 0x30270029, - 0x30270027, 0x30270025, 0x30270023, 0x301f002c, - 0x301f002a, 0x301f0028, 0x301f0025, 0x301f0024, - 0x301f0022, 0x301f001f, 0x3017002d, 0x3017002b, - 0x30170028, 0x30170026, 0x30170024, 0x30170022, - 0x30170020, 0x3017001e, 0x3017001d, 0x3017001b, - 0x3017001a, 0x30170018, 0x30170017, 0x30170015, - 0x300f002c, 0x300f0029, 0x300f0027, 0x300f0024, - 0x300f0022, 0x300f0021, 0x300f001f, 0x300f001d, - 0x300f001b, 0x300f001a, 0x300f0018, 0x300f0017, - 0x300f0016, 0x300f0015, 0x300f0115, 0x300f0215, - 0x300f0315, 0x300f0415, 0x300f0515, 0x300f0615, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715 -}; - -static u32 nphy_tpc_txgain_ipa_2g_2057rev7[] = { - 0x30ff0031, 0x30e70031, 0x30e7002e, 0x30cf002e, - 0x30bf002e, 0x30af002e, 0x309f002f, 0x307f0033, - 0x307f0031, 0x307f002e, 0x3077002e, 0x306f002e, - 0x3067002e, 0x305f002f, 0x30570030, 0x3057002d, - 0x304f002e, 0x30470031, 0x3047002e, 0x3047002c, - 0x30470029, 0x303f002c, 0x303f0029, 0x3037002d, - 0x3037002a, 0x30370028, 0x302f002c, 0x302f002a, - 0x302f0028, 0x302f0026, 0x3027002c, 0x30270029, - 0x30270027, 0x30270025, 0x30270023, 0x301f002c, - 0x301f002a, 0x301f0028, 0x301f0025, 0x301f0024, - 0x301f0022, 0x301f001f, 0x3017002d, 0x3017002b, - 0x30170028, 0x30170026, 0x30170024, 0x30170022, - 0x30170020, 0x3017001e, 0x3017001d, 0x3017001b, - 0x3017001a, 0x30170018, 0x30170017, 0x30170015, - 0x300f002c, 0x300f0029, 0x300f0027, 0x300f0024, - 0x300f0022, 0x300f0021, 0x300f001f, 0x300f001d, - 0x300f001b, 0x300f001a, 0x300f0018, 0x300f0017, - 0x300f0016, 0x300f0015, 0x300f0115, 0x300f0215, - 0x300f0315, 0x300f0415, 0x300f0515, 0x300f0615, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, - 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715 -}; - -static u32 nphy_tpc_txgain_ipa_5g[] = { - 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031, - 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b, - 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027, - 0x7ff70026, 0x7ff70024, 0x7ff70023, 0x7ff70022, - 0x7ef70028, 0x7ef70027, 0x7ef70026, 0x7ef70025, - 0x7ef70024, 0x7ef70023, 0x7df70028, 0x7df70027, - 0x7df70026, 0x7df70025, 0x7df70024, 0x7df70023, - 0x7df70022, 0x7cf70029, 0x7cf70028, 0x7cf70027, - 0x7cf70026, 0x7cf70025, 0x7cf70023, 0x7cf70022, - 0x7bf70029, 0x7bf70028, 0x7bf70026, 0x7bf70025, - 0x7bf70024, 0x7bf70023, 0x7bf70022, 0x7bf70021, - 0x7af70029, 0x7af70028, 0x7af70027, 0x7af70026, - 0x7af70025, 0x7af70024, 0x7af70023, 0x7af70022, - 0x79f70029, 0x79f70028, 0x79f70027, 0x79f70026, - 0x79f70025, 0x79f70024, 0x79f70023, 0x79f70022, - 0x78f70029, 0x78f70028, 0x78f70027, 0x78f70026, - 0x78f70025, 0x78f70024, 0x78f70023, 0x78f70022, - 0x77f70029, 0x77f70028, 0x77f70027, 0x77f70026, - 0x77f70025, 0x77f70024, 0x77f70023, 0x77f70022, - 0x76f70029, 0x76f70028, 0x76f70027, 0x76f70026, - 0x76f70024, 0x76f70023, 0x76f70022, 0x76f70021, - 0x75f70029, 0x75f70028, 0x75f70027, 0x75f70026, - 0x75f70025, 0x75f70024, 0x75f70023, 0x74f70029, - 0x74f70028, 0x74f70026, 0x74f70025, 0x74f70024, - 0x74f70023, 0x74f70022, 0x73f70029, 0x73f70027, - 0x73f70026, 0x73f70025, 0x73f70024, 0x73f70023, - 0x73f70022, 0x72f70028, 0x72f70027, 0x72f70026, - 0x72f70025, 0x72f70024, 0x72f70023, 0x72f70022, - 0x71f70028, 0x71f70027, 0x71f70026, 0x71f70025, - 0x71f70024, 0x71f70023, 0x70f70028, 0x70f70027, - 0x70f70026, 0x70f70024, 0x70f70023, 0x70f70022, - 0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f -}; - -static u32 nphy_tpc_txgain_ipa_5g_2057[] = { - 0x7f7f0044, 0x7f7f0040, 0x7f7f003c, 0x7f7f0039, - 0x7f7f0036, 0x7e7f003c, 0x7e7f0038, 0x7e7f0035, - 0x7d7f003c, 0x7d7f0039, 0x7d7f0036, 0x7d7f0033, - 0x7c7f003b, 0x7c7f0037, 0x7c7f0034, 0x7b7f003a, - 0x7b7f0036, 0x7b7f0033, 0x7a7f003c, 0x7a7f0039, - 0x7a7f0036, 0x7a7f0033, 0x797f003b, 0x797f0038, - 0x797f0035, 0x797f0032, 0x787f003b, 0x787f0038, - 0x787f0035, 0x787f0032, 0x777f003a, 0x777f0037, - 0x777f0034, 0x777f0031, 0x767f003a, 0x767f0036, - 0x767f0033, 0x767f0031, 0x757f003a, 0x757f0037, - 0x757f0034, 0x747f003c, 0x747f0039, 0x747f0036, - 0x747f0033, 0x737f003b, 0x737f0038, 0x737f0035, - 0x737f0032, 0x727f0039, 0x727f0036, 0x727f0033, - 0x727f0030, 0x717f003a, 0x717f0037, 0x717f0034, - 0x707f003b, 0x707f0038, 0x707f0035, 0x707f0032, - 0x707f002f, 0x707f002d, 0x707f002a, 0x707f0028, - 0x707f0025, 0x707f0023, 0x707f0021, 0x707f0020, - 0x707f001e, 0x707f001c, 0x707f001b, 0x707f0019, - 0x707f0018, 0x707f0016, 0x707f0015, 0x707f0014, - 0x707f0013, 0x707f0012, 0x707f0011, 0x707f0010, - 0x707f000f, 0x707f000e, 0x707f000d, 0x707f000d, - 0x707f000c, 0x707f000b, 0x707f000b, 0x707f000a, - 0x707f0009, 0x707f0009, 0x707f0008, 0x707f0008, - 0x707f0007, 0x707f0007, 0x707f0007, 0x707f0006, - 0x707f0006, 0x707f0006, 0x707f0005, 0x707f0005, - 0x707f0005, 0x707f0004, 0x707f0004, 0x707f0004, - 0x707f0004, 0x707f0004, 0x707f0003, 0x707f0003, - 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, - 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, - 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, - 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001, - 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001 -}; - -static u32 nphy_tpc_txgain_ipa_5g_2057rev7[] = { - 0x6f7f0031, 0x6f7f002e, 0x6f7f002c, 0x6f7f002a, - 0x6f7f0027, 0x6e7f002e, 0x6e7f002c, 0x6e7f002a, - 0x6d7f0030, 0x6d7f002d, 0x6d7f002a, 0x6d7f0028, - 0x6c7f0030, 0x6c7f002d, 0x6c7f002b, 0x6b7f002e, - 0x6b7f002c, 0x6b7f002a, 0x6b7f0027, 0x6a7f002e, - 0x6a7f002c, 0x6a7f002a, 0x697f0030, 0x697f002e, - 0x697f002b, 0x697f0029, 0x687f002f, 0x687f002d, - 0x687f002a, 0x687f0027, 0x677f002f, 0x677f002d, - 0x677f002a, 0x667f0031, 0x667f002e, 0x667f002c, - 0x667f002a, 0x657f0030, 0x657f002e, 0x657f002b, - 0x657f0029, 0x647f0030, 0x647f002d, 0x647f002b, - 0x647f0029, 0x637f002f, 0x637f002d, 0x637f002a, - 0x627f0030, 0x627f002d, 0x627f002b, 0x627f0029, - 0x617f0030, 0x617f002e, 0x617f002b, 0x617f0029, - 0x607f002f, 0x607f002d, 0x607f002a, 0x607f0027, - 0x607f0026, 0x607f0023, 0x607f0021, 0x607f0020, - 0x607f001e, 0x607f001c, 0x607f001a, 0x607f0019, - 0x607f0018, 0x607f0016, 0x607f0015, 0x607f0014, - 0x607f0012, 0x607f0012, 0x607f0011, 0x607f000f, - 0x607f000f, 0x607f000e, 0x607f000d, 0x607f000c, - 0x607f000c, 0x607f000b, 0x607f000b, 0x607f000a, - 0x607f0009, 0x607f0009, 0x607f0008, 0x607f0008, - 0x607f0008, 0x607f0007, 0x607f0007, 0x607f0006, - 0x607f0006, 0x607f0005, 0x607f0005, 0x607f0005, - 0x607f0005, 0x607f0005, 0x607f0004, 0x607f0004, - 0x607f0004, 0x607f0004, 0x607f0003, 0x607f0003, - 0x607f0003, 0x607f0003, 0x607f0002, 0x607f0002, - 0x607f0002, 0x607f0002, 0x607f0002, 0x607f0002, - 0x607f0002, 0x607f0002, 0x607f0002, 0x607f0002, - 0x607f0002, 0x607f0002, 0x607f0002, 0x607f0002, - 0x607f0002, 0x607f0001, 0x607f0001, 0x607f0001, - 0x607f0001, 0x607f0001, 0x607f0001, 0x607f0001 -}; - -static s8 nphy_papd_pga_gain_delta_ipa_2g[] = { - -114, -108, -98, -91, -84, -78, -70, -62, - -54, -46, -39, -31, -23, -15, -8, 0 -}; - -static s8 nphy_papd_pga_gain_delta_ipa_5g[] = { - -100, -95, -89, -83, -77, -70, -63, -56, - -48, -41, -33, -25, -19, -12, -6, 0 -}; - -static s16 nphy_papd_padgain_dlt_2g_2057rev3n4[] = { - -159, -113, -86, -72, -62, -54, -48, -43, - -39, -35, -31, -28, -25, -23, -20, -18, - -17, -15, -13, -11, -10, -8, -7, -6, - -5, -4, -3, -3, -2, -1, -1, 0 -}; - -static s16 nphy_papd_padgain_dlt_2g_2057rev5[] = { - -109, -109, -82, -68, -58, -50, -44, -39, - -35, -31, -28, -26, -23, -21, -19, -17, - -16, -14, -13, -11, -10, -9, -8, -7, - -5, -5, -4, -3, -2, -1, -1, 0 -}; - -static s16 nphy_papd_padgain_dlt_2g_2057rev7[] = { - -122, -122, -95, -80, -69, -61, -54, -49, - -43, -39, -35, -32, -28, -26, -23, -21, - -18, -16, -15, -13, -11, -10, -8, -7, - -6, -5, -4, -3, -2, -1, -1, 0 -}; - -static s8 nphy_papd_pgagain_dlt_5g_2057[] = { - -107, -101, -92, -85, -78, -71, -62, -55, - -47, -39, -32, -24, -19, -12, -6, 0 -}; - -static s8 nphy_papd_pgagain_dlt_5g_2057rev7[] = { - -110, -104, -95, -88, -81, -74, -66, -58, - -50, -44, -36, -28, -23, -15, -8, 0 -}; - -static u8 pad_gain_codes_used_2057rev5[] = { - 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 -}; - -static u8 pad_gain_codes_used_2057rev7[] = { - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, - 5, 4, 3, 2, 1 -}; - -static u8 pad_all_gain_codes_2057[] = { - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, - 1, 0 -}; - -static u8 pga_all_gain_codes_2057[] = { - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -}; - -static u32 nphy_papd_scaltbl[] = { - 0x0ae2002f, 0x0a3b0032, 0x09a70035, 0x09220038, - 0x0887003c, 0x081f003f, 0x07a20043, 0x07340047, - 0x06d2004b, 0x067a004f, 0x06170054, 0x05bf0059, - 0x0571005e, 0x051e0064, 0x04d3006a, 0x04910070, - 0x044c0077, 0x040f007e, 0x03d90085, 0x03a1008d, - 0x036f0095, 0x033d009e, 0x030b00a8, 0x02e000b2, - 0x02b900bc, 0x029200c7, 0x026d00d3, 0x024900e0, - 0x022900ed, 0x020a00fb, 0x01ec010a, 0x01d0011a, - 0x01b7012a, 0x019e013c, 0x0187014f, 0x01720162, - 0x015d0177, 0x0149018e, 0x013701a5, 0x012601be, - 0x011501d9, 0x010501f5, 0x00f70212, 0x00e90232, - 0x00dc0253, 0x00d00276, 0x00c4029c, 0x00b902c3, - 0x00af02ed, 0x00a5031a, 0x009c0349, 0x0093037a, - 0x008b03af, 0x008303e7, 0x007c0422, 0x00750461, - 0x006e04a3, 0x006804ea, 0x00620534, 0x005d0583, - 0x005805d7, 0x0053062f, 0x004e068d, 0x004a06f1 -}; - -static u32 nphy_tpc_txgain_rev3[] = { - 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e, - 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037, - 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e, - 0x1e41003c, 0x1e41003b, 0x1e410039, 0x1e410037, - 0x1d410044, 0x1d410042, 0x1d410040, 0x1d41003e, - 0x1d41003c, 0x1d41003b, 0x1d410039, 0x1d410037, - 0x1c410044, 0x1c410042, 0x1c410040, 0x1c41003e, - 0x1c41003c, 0x1c41003b, 0x1c410039, 0x1c410037, - 0x1b410044, 0x1b410042, 0x1b410040, 0x1b41003e, - 0x1b41003c, 0x1b41003b, 0x1b410039, 0x1b410037, - 0x1a410044, 0x1a410042, 0x1a410040, 0x1a41003e, - 0x1a41003c, 0x1a41003b, 0x1a410039, 0x1a410037, - 0x19410044, 0x19410042, 0x19410040, 0x1941003e, - 0x1941003c, 0x1941003b, 0x19410039, 0x19410037, - 0x18410044, 0x18410042, 0x18410040, 0x1841003e, - 0x1841003c, 0x1841003b, 0x18410039, 0x18410037, - 0x17410044, 0x17410042, 0x17410040, 0x1741003e, - 0x1741003c, 0x1741003b, 0x17410039, 0x17410037, - 0x16410044, 0x16410042, 0x16410040, 0x1641003e, - 0x1641003c, 0x1641003b, 0x16410039, 0x16410037, - 0x15410044, 0x15410042, 0x15410040, 0x1541003e, - 0x1541003c, 0x1541003b, 0x15410039, 0x15410037, - 0x14410044, 0x14410042, 0x14410040, 0x1441003e, - 0x1441003c, 0x1441003b, 0x14410039, 0x14410037, - 0x13410044, 0x13410042, 0x13410040, 0x1341003e, - 0x1341003c, 0x1341003b, 0x13410039, 0x13410037, - 0x12410044, 0x12410042, 0x12410040, 0x1241003e, - 0x1241003c, 0x1241003b, 0x12410039, 0x12410037, - 0x11410044, 0x11410042, 0x11410040, 0x1141003e, - 0x1141003c, 0x1141003b, 0x11410039, 0x11410037, - 0x10410044, 0x10410042, 0x10410040, 0x1041003e, - 0x1041003c, 0x1041003b, 0x10410039, 0x10410037 -}; - -static u32 nphy_tpc_txgain_HiPwrEPA[] = { - 0x0f410044, 0x0f410042, 0x0f410040, 0x0f41003e, - 0x0f41003c, 0x0f41003b, 0x0f410039, 0x0f410037, - 0x0e410044, 0x0e410042, 0x0e410040, 0x0e41003e, - 0x0e41003c, 0x0e41003b, 0x0e410039, 0x0e410037, - 0x0d410044, 0x0d410042, 0x0d410040, 0x0d41003e, - 0x0d41003c, 0x0d41003b, 0x0d410039, 0x0d410037, - 0x0c410044, 0x0c410042, 0x0c410040, 0x0c41003e, - 0x0c41003c, 0x0c41003b, 0x0c410039, 0x0c410037, - 0x0b410044, 0x0b410042, 0x0b410040, 0x0b41003e, - 0x0b41003c, 0x0b41003b, 0x0b410039, 0x0b410037, - 0x0a410044, 0x0a410042, 0x0a410040, 0x0a41003e, - 0x0a41003c, 0x0a41003b, 0x0a410039, 0x0a410037, - 0x09410044, 0x09410042, 0x09410040, 0x0941003e, - 0x0941003c, 0x0941003b, 0x09410039, 0x09410037, - 0x08410044, 0x08410042, 0x08410040, 0x0841003e, - 0x0841003c, 0x0841003b, 0x08410039, 0x08410037, - 0x07410044, 0x07410042, 0x07410040, 0x0741003e, - 0x0741003c, 0x0741003b, 0x07410039, 0x07410037, - 0x06410044, 0x06410042, 0x06410040, 0x0641003e, - 0x0641003c, 0x0641003b, 0x06410039, 0x06410037, - 0x05410044, 0x05410042, 0x05410040, 0x0541003e, - 0x0541003c, 0x0541003b, 0x05410039, 0x05410037, - 0x04410044, 0x04410042, 0x04410040, 0x0441003e, - 0x0441003c, 0x0441003b, 0x04410039, 0x04410037, - 0x03410044, 0x03410042, 0x03410040, 0x0341003e, - 0x0341003c, 0x0341003b, 0x03410039, 0x03410037, - 0x02410044, 0x02410042, 0x02410040, 0x0241003e, - 0x0241003c, 0x0241003b, 0x02410039, 0x02410037, - 0x01410044, 0x01410042, 0x01410040, 0x0141003e, - 0x0141003c, 0x0141003b, 0x01410039, 0x01410037, - 0x00410044, 0x00410042, 0x00410040, 0x0041003e, - 0x0041003c, 0x0041003b, 0x00410039, 0x00410037 -}; - -static u32 nphy_tpc_txgain_epa_2057rev3[] = { - 0x80f90040, 0x80e10040, 0x80e1003c, 0x80c9003d, - 0x80b9003c, 0x80a9003d, 0x80a1003c, 0x8099003b, - 0x8091003b, 0x8089003a, 0x8081003a, 0x80790039, - 0x80710039, 0x8069003a, 0x8061003b, 0x8059003d, - 0x8051003f, 0x80490042, 0x8049003e, 0x8049003b, - 0x8041003e, 0x8041003b, 0x8039003e, 0x8039003b, - 0x80390038, 0x80390035, 0x8031003a, 0x80310036, - 0x80310033, 0x8029003a, 0x80290037, 0x80290034, - 0x80290031, 0x80210039, 0x80210036, 0x80210033, - 0x80210030, 0x8019003c, 0x80190039, 0x80190036, - 0x80190033, 0x80190030, 0x8019002d, 0x8019002b, - 0x80190028, 0x8011003a, 0x80110036, 0x80110033, - 0x80110030, 0x8011002e, 0x8011002b, 0x80110029, - 0x80110027, 0x80110024, 0x80110022, 0x80110020, - 0x8011001f, 0x8011001d, 0x8009003a, 0x80090037, - 0x80090034, 0x80090031, 0x8009002e, 0x8009002c, - 0x80090029, 0x80090027, 0x80090025, 0x80090023, - 0x80090021, 0x8009001f, 0x8009001d, 0x8009011d, - 0x8009021d, 0x8009031d, 0x8009041d, 0x8009051d, - 0x8009061d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d, - 0x8009071d, 0x8009071d, 0x8009071d, 0x8009071d -}; - -static u32 nphy_tpc_txgain_epa_2057rev5[] = { - 0x10f90040, 0x10e10040, 0x10e1003c, 0x10c9003d, - 0x10b9003c, 0x10a9003d, 0x10a1003c, 0x1099003b, - 0x1091003b, 0x1089003a, 0x1081003a, 0x10790039, - 0x10710039, 0x1069003a, 0x1061003b, 0x1059003d, - 0x1051003f, 0x10490042, 0x1049003e, 0x1049003b, - 0x1041003e, 0x1041003b, 0x1039003e, 0x1039003b, - 0x10390038, 0x10390035, 0x1031003a, 0x10310036, - 0x10310033, 0x1029003a, 0x10290037, 0x10290034, - 0x10290031, 0x10210039, 0x10210036, 0x10210033, - 0x10210030, 0x1019003c, 0x10190039, 0x10190036, - 0x10190033, 0x10190030, 0x1019002d, 0x1019002b, - 0x10190028, 0x1011003a, 0x10110036, 0x10110033, - 0x10110030, 0x1011002e, 0x1011002b, 0x10110029, - 0x10110027, 0x10110024, 0x10110022, 0x10110020, - 0x1011001f, 0x1011001d, 0x1009003a, 0x10090037, - 0x10090034, 0x10090031, 0x1009002e, 0x1009002c, - 0x10090029, 0x10090027, 0x10090025, 0x10090023, - 0x10090021, 0x1009001f, 0x1009001d, 0x1009001b, - 0x1009001a, 0x10090018, 0x10090017, 0x10090016, - 0x10090015, 0x10090013, 0x10090012, 0x10090011, - 0x10090010, 0x1009000f, 0x1009000f, 0x1009000e, - 0x1009000d, 0x1009000c, 0x1009000c, 0x1009000b, - 0x1009000a, 0x1009000a, 0x10090009, 0x10090009, - 0x10090008, 0x10090008, 0x10090007, 0x10090007, - 0x10090007, 0x10090006, 0x10090006, 0x10090005, - 0x10090005, 0x10090005, 0x10090005, 0x10090004, - 0x10090004, 0x10090004, 0x10090004, 0x10090003, - 0x10090003, 0x10090003, 0x10090003, 0x10090003, - 0x10090003, 0x10090002, 0x10090002, 0x10090002, - 0x10090002, 0x10090002, 0x10090002, 0x10090002, - 0x10090002, 0x10090002, 0x10090001, 0x10090001, - 0x10090001, 0x10090001, 0x10090001, 0x10090001 -}; - -static u32 nphy_tpc_5GHz_txgain_rev3[] = { - 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e, - 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037, - 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e, - 0xcef7003c, 0xcef7003b, 0xcef70039, 0xcef70037, - 0xcdf70044, 0xcdf70042, 0xcdf70040, 0xcdf7003e, - 0xcdf7003c, 0xcdf7003b, 0xcdf70039, 0xcdf70037, - 0xccf70044, 0xccf70042, 0xccf70040, 0xccf7003e, - 0xccf7003c, 0xccf7003b, 0xccf70039, 0xccf70037, - 0xcbf70044, 0xcbf70042, 0xcbf70040, 0xcbf7003e, - 0xcbf7003c, 0xcbf7003b, 0xcbf70039, 0xcbf70037, - 0xcaf70044, 0xcaf70042, 0xcaf70040, 0xcaf7003e, - 0xcaf7003c, 0xcaf7003b, 0xcaf70039, 0xcaf70037, - 0xc9f70044, 0xc9f70042, 0xc9f70040, 0xc9f7003e, - 0xc9f7003c, 0xc9f7003b, 0xc9f70039, 0xc9f70037, - 0xc8f70044, 0xc8f70042, 0xc8f70040, 0xc8f7003e, - 0xc8f7003c, 0xc8f7003b, 0xc8f70039, 0xc8f70037, - 0xc7f70044, 0xc7f70042, 0xc7f70040, 0xc7f7003e, - 0xc7f7003c, 0xc7f7003b, 0xc7f70039, 0xc7f70037, - 0xc6f70044, 0xc6f70042, 0xc6f70040, 0xc6f7003e, - 0xc6f7003c, 0xc6f7003b, 0xc6f70039, 0xc6f70037, - 0xc5f70044, 0xc5f70042, 0xc5f70040, 0xc5f7003e, - 0xc5f7003c, 0xc5f7003b, 0xc5f70039, 0xc5f70037, - 0xc4f70044, 0xc4f70042, 0xc4f70040, 0xc4f7003e, - 0xc4f7003c, 0xc4f7003b, 0xc4f70039, 0xc4f70037, - 0xc3f70044, 0xc3f70042, 0xc3f70040, 0xc3f7003e, - 0xc3f7003c, 0xc3f7003b, 0xc3f70039, 0xc3f70037, - 0xc2f70044, 0xc2f70042, 0xc2f70040, 0xc2f7003e, - 0xc2f7003c, 0xc2f7003b, 0xc2f70039, 0xc2f70037, - 0xc1f70044, 0xc1f70042, 0xc1f70040, 0xc1f7003e, - 0xc1f7003c, 0xc1f7003b, 0xc1f70039, 0xc1f70037, - 0xc0f70044, 0xc0f70042, 0xc0f70040, 0xc0f7003e, - 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037 -}; - -static u32 nphy_tpc_5GHz_txgain_rev4[] = { - 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e, - 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037, - 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e, - 0x2ef2003c, 0x2ef2003b, 0x2ef20039, 0x2ef20037, - 0x2df20044, 0x2df20042, 0x2df20040, 0x2df2003e, - 0x2df2003c, 0x2df2003b, 0x2df20039, 0x2df20037, - 0x2cf20044, 0x2cf20042, 0x2cf20040, 0x2cf2003e, - 0x2cf2003c, 0x2cf2003b, 0x2cf20039, 0x2cf20037, - 0x2bf20044, 0x2bf20042, 0x2bf20040, 0x2bf2003e, - 0x2bf2003c, 0x2bf2003b, 0x2bf20039, 0x2bf20037, - 0x2af20044, 0x2af20042, 0x2af20040, 0x2af2003e, - 0x2af2003c, 0x2af2003b, 0x2af20039, 0x2af20037, - 0x29f20044, 0x29f20042, 0x29f20040, 0x29f2003e, - 0x29f2003c, 0x29f2003b, 0x29f20039, 0x29f20037, - 0x28f20044, 0x28f20042, 0x28f20040, 0x28f2003e, - 0x28f2003c, 0x28f2003b, 0x28f20039, 0x28f20037, - 0x27f20044, 0x27f20042, 0x27f20040, 0x27f2003e, - 0x27f2003c, 0x27f2003b, 0x27f20039, 0x27f20037, - 0x26f20044, 0x26f20042, 0x26f20040, 0x26f2003e, - 0x26f2003c, 0x26f2003b, 0x26f20039, 0x26f20037, - 0x25f20044, 0x25f20042, 0x25f20040, 0x25f2003e, - 0x25f2003c, 0x25f2003b, 0x25f20039, 0x25f20037, - 0x24f20044, 0x24f20042, 0x24f20040, 0x24f2003e, - 0x24f2003c, 0x24f2003b, 0x24f20039, 0x24f20038, - 0x23f20041, 0x23f20040, 0x23f2003f, 0x23f2003e, - 0x23f2003c, 0x23f2003b, 0x23f20039, 0x23f20037, - 0x22f20044, 0x22f20042, 0x22f20040, 0x22f2003e, - 0x22f2003c, 0x22f2003b, 0x22f20039, 0x22f20037, - 0x21f20044, 0x21f20042, 0x21f20040, 0x21f2003e, - 0x21f2003c, 0x21f2003b, 0x21f20039, 0x21f20037, - 0x20d20043, 0x20d20041, 0x20d2003e, 0x20d2003c, - 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034 -}; - -static u32 nphy_tpc_5GHz_txgain_rev5[] = { - 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044, - 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c, - 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e, - 0x0e62003c, 0x0e62003d, 0x0e62003b, 0x0e62003a, - 0x0d620043, 0x0d620041, 0x0d620040, 0x0d62003e, - 0x0d62003d, 0x0d62003c, 0x0d62003b, 0x0d62003a, - 0x0c620041, 0x0c620040, 0x0c62003f, 0x0c62003e, - 0x0c62003c, 0x0c62003b, 0x0c620039, 0x0c620037, - 0x0b620046, 0x0b620044, 0x0b620042, 0x0b620040, - 0x0b62003e, 0x0b62003c, 0x0b62003b, 0x0b62003a, - 0x0a620041, 0x0a620040, 0x0a62003e, 0x0a62003c, - 0x0a62003b, 0x0a62003a, 0x0a620039, 0x0a620038, - 0x0962003e, 0x0962003d, 0x0962003c, 0x0962003b, - 0x09620039, 0x09620037, 0x09620035, 0x09620033, - 0x08620044, 0x08620042, 0x08620040, 0x0862003e, - 0x0862003c, 0x0862003b, 0x0862003a, 0x08620039, - 0x07620043, 0x07620042, 0x07620040, 0x0762003f, - 0x0762003d, 0x0762003b, 0x0762003a, 0x07620039, - 0x0662003e, 0x0662003d, 0x0662003c, 0x0662003b, - 0x06620039, 0x06620037, 0x06620035, 0x06620033, - 0x05620046, 0x05620044, 0x05620042, 0x05620040, - 0x0562003e, 0x0562003c, 0x0562003b, 0x05620039, - 0x04620044, 0x04620042, 0x04620040, 0x0462003e, - 0x0462003c, 0x0462003b, 0x04620039, 0x04620038, - 0x0362003c, 0x0362003b, 0x0362003a, 0x03620039, - 0x03620038, 0x03620037, 0x03620035, 0x03620033, - 0x0262004c, 0x0262004a, 0x02620048, 0x02620047, - 0x02620046, 0x02620044, 0x02620043, 0x02620042, - 0x0162004a, 0x01620048, 0x01620046, 0x01620044, - 0x01620043, 0x01620042, 0x01620041, 0x01620040, - 0x00620042, 0x00620040, 0x0062003e, 0x0062003c, - 0x0062003b, 0x00620039, 0x00620037, 0x00620035 -}; - -static u32 nphy_tpc_5GHz_txgain_HiPwrEPA[] = { - 0x2ff10044, 0x2ff10042, 0x2ff10040, 0x2ff1003e, - 0x2ff1003c, 0x2ff1003b, 0x2ff10039, 0x2ff10037, - 0x2ef10044, 0x2ef10042, 0x2ef10040, 0x2ef1003e, - 0x2ef1003c, 0x2ef1003b, 0x2ef10039, 0x2ef10037, - 0x2df10044, 0x2df10042, 0x2df10040, 0x2df1003e, - 0x2df1003c, 0x2df1003b, 0x2df10039, 0x2df10037, - 0x2cf10044, 0x2cf10042, 0x2cf10040, 0x2cf1003e, - 0x2cf1003c, 0x2cf1003b, 0x2cf10039, 0x2cf10037, - 0x2bf10044, 0x2bf10042, 0x2bf10040, 0x2bf1003e, - 0x2bf1003c, 0x2bf1003b, 0x2bf10039, 0x2bf10037, - 0x2af10044, 0x2af10042, 0x2af10040, 0x2af1003e, - 0x2af1003c, 0x2af1003b, 0x2af10039, 0x2af10037, - 0x29f10044, 0x29f10042, 0x29f10040, 0x29f1003e, - 0x29f1003c, 0x29f1003b, 0x29f10039, 0x29f10037, - 0x28f10044, 0x28f10042, 0x28f10040, 0x28f1003e, - 0x28f1003c, 0x28f1003b, 0x28f10039, 0x28f10037, - 0x27f10044, 0x27f10042, 0x27f10040, 0x27f1003e, - 0x27f1003c, 0x27f1003b, 0x27f10039, 0x27f10037, - 0x26f10044, 0x26f10042, 0x26f10040, 0x26f1003e, - 0x26f1003c, 0x26f1003b, 0x26f10039, 0x26f10037, - 0x25f10044, 0x25f10042, 0x25f10040, 0x25f1003e, - 0x25f1003c, 0x25f1003b, 0x25f10039, 0x25f10037, - 0x24f10044, 0x24f10042, 0x24f10040, 0x24f1003e, - 0x24f1003c, 0x24f1003b, 0x24f10039, 0x24f10038, - 0x23f10041, 0x23f10040, 0x23f1003f, 0x23f1003e, - 0x23f1003c, 0x23f1003b, 0x23f10039, 0x23f10037, - 0x22f10044, 0x22f10042, 0x22f10040, 0x22f1003e, - 0x22f1003c, 0x22f1003b, 0x22f10039, 0x22f10037, - 0x21f10044, 0x21f10042, 0x21f10040, 0x21f1003e, - 0x21f1003c, 0x21f1003b, 0x21f10039, 0x21f10037, - 0x20d10043, 0x20d10041, 0x20d1003e, 0x20d1003c, - 0x20d1003a, 0x20d10038, 0x20d10036, 0x20d10034 -}; - -static u8 ant_sw_ctrl_tbl_rev8_2o3[] = { 0x14, 0x18 }; -static u8 ant_sw_ctrl_tbl_rev8[] = { 0x4, 0x8, 0x4, 0x8, 0x11, 0x12 }; -static u8 ant_sw_ctrl_tbl_rev8_2057v7_core0[] = { - 0x09, 0x0a, 0x15, 0x16, 0x09, 0x0a -}; -static u8 ant_sw_ctrl_tbl_rev8_2057v7_core1[] = { - 0x09, 0x0a, 0x09, 0x0a, 0x15, 0x16 -}; - -bool wlc_phy_bist_check_phy(struct brcms_phy_pub *pih) -{ - struct brcms_phy *pi = (struct brcms_phy *) pih; - u32 phybist0, phybist1, phybist2, phybist3, phybist4; - - if (NREV_GE(pi->pubpi.phy_rev, 16)) - return true; - - phybist0 = read_phy_reg(pi, 0x0e); - phybist1 = read_phy_reg(pi, 0x0f); - phybist2 = read_phy_reg(pi, 0xea); - phybist3 = read_phy_reg(pi, 0xeb); - phybist4 = read_phy_reg(pi, 0x156); - - if ((phybist0 == 0) && (phybist1 == 0x4000) && (phybist2 == 0x1fe0) && - (phybist3 == 0) && (phybist4 == 0)) - return true; - - return false; -} - -static void wlc_phy_bphy_init_nphy(struct brcms_phy *pi) -{ - u16 addr, val; - - val = 0x1e1f; - for (addr = (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT); - addr <= (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT_END); addr++) { - write_phy_reg(pi, addr, val); - if (addr == (NPHY_TO_BPHY_OFF + 0x97)) - val = 0x3e3f; - else - val -= 0x0202; - } - - write_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_STEP, 0x668); -} - -void -wlc_phy_table_write_nphy(struct brcms_phy *pi, u32 id, u32 len, u32 offset, - u32 width, const void *data) -{ - struct phytbl_info tbl; - - tbl.tbl_id = id; - tbl.tbl_len = len; - tbl.tbl_offset = offset; - tbl.tbl_width = width; - tbl.tbl_ptr = data; - wlc_phy_write_table_nphy(pi, &tbl); -} - -void -wlc_phy_table_read_nphy(struct brcms_phy *pi, u32 id, u32 len, u32 offset, - u32 width, void *data) -{ - struct phytbl_info tbl; - - tbl.tbl_id = id; - tbl.tbl_len = len; - tbl.tbl_offset = offset; - tbl.tbl_width = width; - tbl.tbl_ptr = data; - wlc_phy_read_table_nphy(pi, &tbl); -} - -static void -wlc_phy_static_table_download_nphy(struct brcms_phy *pi) -{ - uint idx; - - if (NREV_GE(pi->pubpi.phy_rev, 16)) { - for (idx = 0; idx < mimophytbl_info_sz_rev16; idx++) - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev16[idx]); - } else if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (idx = 0; idx < mimophytbl_info_sz_rev7; idx++) - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev7[idx]); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - for (idx = 0; idx < mimophytbl_info_sz_rev3; idx++) - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev3[idx]); - } else { - for (idx = 0; idx < mimophytbl_info_sz_rev0; idx++) - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev0[idx]); - } -} - -static void wlc_phy_tbl_init_nphy(struct brcms_phy *pi) -{ - uint idx = 0; - u8 antswctrllut; - - if (pi->phy_init_por) - wlc_phy_static_table_download_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - antswctrllut = CHSPEC_IS2G(pi->radio_chanspec) ? - pi->srom_fem2g.antswctrllut : pi->srom_fem5g. - antswctrllut; - - switch (antswctrllut) { - case 0: - - break; - - case 1: - - if (pi->aa2g == 7) - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8_2o3[0]); - else - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8 - [0]); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x25, 8, - &ant_sw_ctrl_tbl_rev8[2]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x29, 8, - &ant_sw_ctrl_tbl_rev8[4]); - break; - - case 2: - - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x1, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0[0]); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x5, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0[2]); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x9, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core0[4]); - - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x21, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1[0]); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x25, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1[2]); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 2, 0x29, 8, - &ant_sw_ctrl_tbl_rev8_2057v7_core1[4]); - break; - - default: - break; - } - - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - for (idx = 0; idx < mimophytbl_info_sz_rev3_volatile; idx++) { - - if (idx == ANT_SWCTRL_TBL_REV3_IDX) { - antswctrllut = - CHSPEC_IS2G(pi->radio_chanspec) ? - pi->srom_fem2g.antswctrllut : - pi->srom_fem5g.antswctrllut; - switch (antswctrllut) { - case 0: - wlc_phy_write_table_nphy( - pi, - &mimophytbl_info_rev3_volatile - [idx]); - break; - case 1: - wlc_phy_write_table_nphy( - pi, - &mimophytbl_info_rev3_volatile1 - [idx]); - break; - case 2: - wlc_phy_write_table_nphy( - pi, - &mimophytbl_info_rev3_volatile2 - [idx]); - break; - case 3: - wlc_phy_write_table_nphy( - pi, - &mimophytbl_info_rev3_volatile3 - [idx]); - break; - default: - break; - } - } else { - wlc_phy_write_table_nphy( - pi, - &mimophytbl_info_rev3_volatile[idx]); - } - } - } else { - for (idx = 0; idx < mimophytbl_info_sz_rev0_volatile; idx++) - wlc_phy_write_table_nphy(pi, - &mimophytbl_info_rev0_volatile - [idx]); - } -} - -static void -wlc_phy_write_txmacreg_nphy(struct brcms_phy *pi, u16 holdoff, u16 delay) -{ - write_phy_reg(pi, 0x77, holdoff); - write_phy_reg(pi, 0xb4, delay); -} - -void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs) -{ - u16 holdoff, delay; - - if (rifs) { - - holdoff = 0x10; - delay = 0x258; - } else { - - holdoff = 0x15; - delay = 0x320; - } - - wlc_phy_write_txmacreg_nphy(pi, holdoff, delay); - - if (pi && pi->sh && (pi->sh->_rifs_phy != rifs)) - pi->sh->_rifs_phy = rifs; -} - -static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi) -{ - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->nphy_txpwrctrl = PHY_TPC_HW_ON; - pi->phy_5g_pwrgain = true; - return; - } - - pi->nphy_txpwrctrl = PHY_TPC_HW_OFF; - pi->phy_5g_pwrgain = false; - - if ((pi->sh->boardflags2 & BFL2_TXPWRCTRL_EN) && - NREV_GE(pi->pubpi.phy_rev, 2) && (pi->sh->sromrev >= 4)) - pi->nphy_txpwrctrl = PHY_TPC_HW_ON; - else if ((pi->sh->sromrev >= 4) - && (pi->sh->boardflags2 & BFL2_5G_PWRGAIN)) - pi->phy_5g_pwrgain = true; -} - -static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) -{ - u16 bw40po, cddpo, stbcpo, bwduppo; - uint band_num; - struct phy_shim_info *shim = pi->sh->physhim; - - if (pi->sh->sromrev >= 9) - return; - - bw40po = (u16) wlapi_getintvar(shim, BRCMS_SROM_BW40PO); - pi->bw402gpo = bw40po & 0xf; - pi->bw405gpo = (bw40po & 0xf0) >> 4; - pi->bw405glpo = (bw40po & 0xf00) >> 8; - pi->bw405ghpo = (bw40po & 0xf000) >> 12; - - cddpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_CDDPO); - pi->cdd2gpo = cddpo & 0xf; - pi->cdd5gpo = (cddpo & 0xf0) >> 4; - pi->cdd5glpo = (cddpo & 0xf00) >> 8; - pi->cdd5ghpo = (cddpo & 0xf000) >> 12; - - stbcpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_STBCPO); - pi->stbc2gpo = stbcpo & 0xf; - pi->stbc5gpo = (stbcpo & 0xf0) >> 4; - pi->stbc5glpo = (stbcpo & 0xf00) >> 8; - pi->stbc5ghpo = (stbcpo & 0xf000) >> 12; - - bwduppo = (u16) wlapi_getintvar(shim, BRCMS_SROM_BWDUPPO); - pi->bwdup2gpo = bwduppo & 0xf; - pi->bwdup5gpo = (bwduppo & 0xf0) >> 4; - pi->bwdup5glpo = (bwduppo & 0xf00) >> 8; - pi->bwdup5ghpo = (bwduppo & 0xf000) >> 12; - - for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); - band_num++) { - switch (band_num) { - case 0: - - pi->nphy_txpid2g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID2GA0); - pi->nphy_txpid2g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID2GA1); - pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP2GA0); - pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP2GA1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW0A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW0A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW1A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW1A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW2A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA2GW2A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g = - (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA0); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g = - (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA1); - - pi->cck2gpo = (u16) wlapi_getintvar(shim, - BRCMS_SROM_CCK2GPO); - - pi->ofdm2gpo = - (u32) wlapi_getintvar(shim, - BRCMS_SROM_OFDM2GPO); - - pi->mcs2gpo[0] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO0); - pi->mcs2gpo[1] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO1); - pi->mcs2gpo[2] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO2); - pi->mcs2gpo[3] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO3); - pi->mcs2gpo[4] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO4); - pi->mcs2gpo[5] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO5); - pi->mcs2gpo[6] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO6); - pi->mcs2gpo[7] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS2GPO7); - break; - case 1: - - pi->nphy_txpid5g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GA0); - pi->nphy_txpid5g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GA1); - pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = - (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); - pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP5GA1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW0A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW0A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW1A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW1A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW2A0); - pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GW2A1); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm = - (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA0); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm = - (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA1); - - pi->ofdm5gpo = - (u32) wlapi_getintvar(shim, - BRCMS_SROM_OFDM5GPO); - - pi->mcs5gpo[0] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO0); - pi->mcs5gpo[1] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO1); - pi->mcs5gpo[2] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO2); - pi->mcs5gpo[3] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO3); - pi->mcs5gpo[4] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO4); - pi->mcs5gpo[5] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO5); - pi->mcs5gpo[6] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO6); - pi->mcs5gpo[7] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GPO7); - break; - case 2: - - pi->nphy_txpid5gl[0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GLA0); - pi->nphy_txpid5gl[1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GLA1); - pi->nphy_pwrctrl_info[0].max_pwr_5gl = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP5GLA0); - pi->nphy_pwrctrl_info[1].max_pwr_5gl = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP5GLA1); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW0A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW0A1); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW1A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW1A1); - pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW2A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GLW2A1); - pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0; - pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0; - - pi->ofdm5glpo = - (u32) wlapi_getintvar(shim, - BRCMS_SROM_OFDM5GLPO); - - pi->mcs5glpo[0] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO0); - pi->mcs5glpo[1] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO1); - pi->mcs5glpo[2] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO2); - pi->mcs5glpo[3] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO3); - pi->mcs5glpo[4] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO4); - pi->mcs5glpo[5] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO5); - pi->mcs5glpo[6] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO6); - pi->mcs5glpo[7] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GLPO7); - break; - case 3: - - pi->nphy_txpid5gh[0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GHA0); - pi->nphy_txpid5gh[1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GHA1); - pi->nphy_pwrctrl_info[0].max_pwr_5gh = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP5GHA0); - pi->nphy_pwrctrl_info[1].max_pwr_5gh = - (s8) wlapi_getintvar(shim, - BRCMS_SROM_MAXP5GHA1); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW0A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW0A1); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW1A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW1A1); - pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW2A0); - pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 = - (s16) wlapi_getintvar(shim, - BRCMS_SROM_PA5GHW2A1); - pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0; - pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0; - - pi->ofdm5ghpo = - (u32) wlapi_getintvar(shim, - BRCMS_SROM_OFDM5GHPO); - - pi->mcs5ghpo[0] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO0); - pi->mcs5ghpo[1] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO1); - pi->mcs5ghpo[2] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO2); - pi->mcs5ghpo[3] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO3); - pi->mcs5ghpo[4] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO4); - pi->mcs5ghpo[5] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO5); - pi->mcs5ghpo[6] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO6); - pi->mcs5ghpo[7] = - (u16) wlapi_getintvar(shim, - BRCMS_SROM_MCS5GHPO7); - break; - } - } - - wlc_phy_txpwr_apply_nphy(pi); -} - -static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) -{ - struct phy_shim_info *shim = pi->sh->physhim; - - pi->antswitch = (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWITCH); - pi->aa2g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G); - pi->aa5g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA5G); - - pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(shim, - BRCMS_SROM_TSSIPOS2G); - pi->srom_fem2g.extpagain = (u8) wlapi_getintvar(shim, - BRCMS_SROM_EXTPAGAIN2G); - pi->srom_fem2g.pdetrange = (u8) wlapi_getintvar(shim, - BRCMS_SROM_PDETRANGE2G); - pi->srom_fem2g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO2G); - pi->srom_fem2g.antswctrllut = - (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G); - - pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(shim, - BRCMS_SROM_TSSIPOS5G); - pi->srom_fem5g.extpagain = (u8) wlapi_getintvar(shim, - BRCMS_SROM_EXTPAGAIN5G); - pi->srom_fem5g.pdetrange = (u8) wlapi_getintvar(shim, - BRCMS_SROM_PDETRANGE5G); - pi->srom_fem5g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO5G); - if (wlapi_getvar(shim, BRCMS_SROM_ANTSWCTL5G)) - pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL5G); - else - pi->srom_fem5g.antswctrllut = - (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G); - - wlc_phy_txpower_ipa_upd(pi); - - pi->phy_txcore_disable_temp = - (s16) wlapi_getintvar(shim, BRCMS_SROM_TEMPTHRESH); - if (pi->phy_txcore_disable_temp == 0) - pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; - - pi->phy_tempsense_offset = (s8) wlapi_getintvar(shim, - BRCMS_SROM_TEMPOFFSET); - if (pi->phy_tempsense_offset != 0) { - if (pi->phy_tempsense_offset > - (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET)) - pi->phy_tempsense_offset = NPHY_SROM_MAXTEMPOFFSET; - else if (pi->phy_tempsense_offset < (NPHY_SROM_TEMPSHIFT + - NPHY_SROM_MINTEMPOFFSET)) - pi->phy_tempsense_offset = NPHY_SROM_MINTEMPOFFSET; - else - pi->phy_tempsense_offset -= NPHY_SROM_TEMPSHIFT; - } - - pi->phy_txcore_enable_temp = - pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP; - - pi->phycal_tempdelta = - (u8) wlapi_getintvar(shim, BRCMS_SROM_PHYCAL_TEMPDELTA); - if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA) - pi->phycal_tempdelta = 0; - - wlc_phy_txpwr_srom_read_ppr_nphy(pi); - - return true; -} - -bool wlc_phy_attach_nphy(struct brcms_phy *pi) -{ - uint i; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 6)) - pi->phyhang_avoid = true; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - pi->nphy_gband_spurwar_en = true; - if (pi->sh->boardflags2 & BFL2_SPUR_WAR) - pi->nphy_aband_spurwar_en = true; - } - if (NREV_GE(pi->pubpi.phy_rev, 6) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if (pi->sh->boardflags2 & BFL2_2G_SPUR_WAR) - pi->nphy_gband_spurwar2_en = true; - } - - pi->n_preamble_override = AUTO; - if (NREV_IS(pi->pubpi.phy_rev, 3) || NREV_IS(pi->pubpi.phy_rev, 4)) - pi->n_preamble_override = BRCMS_N_PREAMBLE_MIXEDMODE; - - pi->nphy_txrx_chain = AUTO; - pi->phy_scraminit = AUTO; - - pi->nphy_rxcalparams = 0x010100B5; - - pi->nphy_perical = PHY_PERICAL_MPHASE; - pi->mphase_cal_phase_id = MPHASE_CAL_STATE_IDLE; - pi->mphase_txcal_numcmds = MPHASE_TXCAL_NUMCMDS; - - pi->nphy_gain_boost = true; - pi->nphy_elna_gain_config = false; - pi->radio_is_on = false; - - for (i = 0; i < pi->pubpi.phy_corenum; i++) - pi->nphy_txpwrindex[i].index = AUTO; - - wlc_phy_txpwrctrl_config_nphy(pi); - if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) - pi->hwpwrctrl_capable = true; - - pi->pi_fptr.init = wlc_phy_init_nphy; - pi->pi_fptr.calinit = wlc_phy_cal_init_nphy; - pi->pi_fptr.chanset = wlc_phy_chanspec_set_nphy; - pi->pi_fptr.txpwrrecalc = wlc_phy_txpower_recalc_target_nphy; - - if (!wlc_phy_txpwr_srom_read_nphy(pi)) - return false; - - return true; -} - -static s32 get_rf_pwr_offset(struct brcms_phy *pi, s16 pga_gn, s16 pad_gn) -{ - s32 rfpwr_offset = 0; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev3n4 - [pad_gn]; - else if (pi->pubpi.radiorev == 5) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev5 - [pad_gn]; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) - rfpwr_offset = (s16) - nphy_papd_padgain_dlt_2g_2057rev7 - [pad_gn]; - } else { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057 - [pga_gn]; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == - 8)) - rfpwr_offset = (s16) - nphy_papd_pgagain_dlt_5g_2057rev7 - [pga_gn]; - } - return rfpwr_offset; -} - -static void wlc_phy_update_mimoconfig_nphy(struct brcms_phy *pi, s32 preamble) -{ - bool gf_preamble = false; - u16 val; - - if (preamble == BRCMS_N_PREAMBLE_GF) - gf_preamble = true; - - val = read_phy_reg(pi, 0xed); - - val |= RX_GF_MM_AUTO; - val &= ~RX_GF_OR_MM; - if (gf_preamble) - val |= RX_GF_OR_MM; - - write_phy_reg(pi, 0xed, val); -} - -static void wlc_phy_ipa_set_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j, type; - u16 addr_offset[] = { 0x186, 0x195, 0x2c5}; - - for (type = 0; type < 3; type++) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_offset[type] + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); - } - - if (pi->bw == WL_CHANSPEC_BW_40) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[5][j]); - } - - if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x2c5 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[6][j]); - } - } -} - -static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j; - - if (pi->bw == WL_CHANSPEC_BW_40) { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x195 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[4][j]); - } else { - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, 0x186 + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[3][j]); - } -} - -static void -wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, - u8 len) -{ - u32 t1_offset, t2_offset; - u8 ctr; - u8 end_event = - NREV_GE(pi->pubpi.phy_rev, - 3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END; - u8 end_dly = 1; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - t1_offset = cmd << 4; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t1_offset, 8, - events); - t2_offset = t1_offset + 0x080; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, len, t2_offset, 8, - dlys); - - for (ctr = len; ctr < 16; ctr++) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - t1_offset + ctr, 8, &end_event); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - t2_offset + ctr, 8, &end_dly); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static u16 wlc_phy_read_lpf_bw_ctl_nphy(struct brcms_phy *pi, u16 offset) -{ - u16 lpf_bw_ctl_val = 0; - u16 rx2tx_lpf_rc_lut_offset = 0; - - if (offset == 0) { - if (CHSPEC_IS40(pi->radio_chanspec)) - rx2tx_lpf_rc_lut_offset = 0x159; - else - rx2tx_lpf_rc_lut_offset = 0x154; - } else { - rx2tx_lpf_rc_lut_offset = offset; - } - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, - (u32) rx2tx_lpf_rc_lut_offset, 16, - &lpf_bw_ctl_val); - - lpf_bw_ctl_val = lpf_bw_ctl_val & 0x7; - - return lpf_bw_ctl_val; -} - -static void -wlc_phy_rfctrl_override_nphy_rev7(struct brcms_phy *pi, u16 field, u16 value, - u8 core_mask, u8 off, u8 override_id) -{ - u8 core_num; - u16 addr = 0, en_addr = 0, val_addr = 0, en_mask = 0, val_mask = 0; - u8 val_shift = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - en_mask = field; - for (core_num = 0; core_num < 2; core_num++) { - if (override_id == NPHY_REV7_RFCTRLOVERRIDE_ID0) { - - switch (field) { - case (0x1 << 2): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 7): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : - 0x7d; - val_mask = (0x1 << 7); - val_shift = 7; - break; - case (0x1 << 10): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : - 0xfa; - val_mask = (0x7 << 4); - val_shift = 4; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7b : - 0x7e; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 12): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7c : - 0x7f; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x3 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x348 : - 0x349; - val_mask = (0xff << 0); - val_shift = 0; - break; - case (0x1 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x348 : - 0x349; - val_mask = (0xf << 0); - val_shift = 0; - break; - default: - addr = 0xffff; - break; - } - } else if (override_id == - NPHY_REV7_RFCTRLOVERRIDE_ID1) { - - switch (field) { - case (0x1 << 1): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 3); - val_shift = 3; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 2): - - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 7): - - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x7 << 8); - val_shift = 8; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 14); - val_shift = 14; - break; - case (0x1 << 10): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 13); - val_shift = 13; - break; - case (0x1 << 9): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 12); - val_shift = 12; - break; - case (0x1 << 8): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 11); - val_shift = 11; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0x342 : - 0x343; - val_addr = (core_num == 0) ? 0x340 : - 0x341; - val_mask = (0x1 << 0); - val_shift = 0; - break; - default: - addr = 0xffff; - break; - } - } else if (override_id == - NPHY_REV7_RFCTRLOVERRIDE_ID2) { - - switch (field) { - case (0x1 << 3): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 3); - val_shift = 3; - break; - case (0x1 << 1): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 0); - val_shift = 0; - break; - case (0x1 << 2): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0x346 : - 0x347; - val_addr = (core_num == 0) ? 0x344 : - 0x345; - val_mask = (0x1 << 4); - val_shift = 4; - break; - default: - addr = 0xffff; - break; - } - } - - if (off) { - and_phy_reg(pi, en_addr, ~en_mask); - and_phy_reg(pi, val_addr, ~val_mask); - } else { - - if ((core_mask == 0) - || (core_mask & (1 << core_num))) { - or_phy_reg(pi, en_addr, en_mask); - - if (addr != 0xffff) - mod_phy_reg(pi, val_addr, - val_mask, - (value << - val_shift)); - } - } - } - } -} - -static void wlc_phy_adjust_lnagaintbl_nphy(struct brcms_phy *pi) -{ - uint core; - int ctr; - s16 gain_delta[2]; - u8 curr_channel; - u16 minmax_gain[2]; - u16 regval[4]; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (pi->nphy_gain_boost) { - if ((CHSPEC_IS2G(pi->radio_chanspec))) { - - gain_delta[0] = 6; - gain_delta[1] = 6; - } else { - - curr_channel = CHSPEC_CHANNEL(pi->radio_chanspec); - gain_delta[0] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est0[0] * - curr_channel) + - nphy_lnagain_est0[1]), 13); - gain_delta[1] = - (s16) - PHY_HW_ROUND(((nphy_lnagain_est1[0] * - curr_channel) + - nphy_lnagain_est1[1]), 13); - } - } else { - - gain_delta[0] = 0; - gain_delta[1] = 0; - } - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (pi->nphy_elna_gain_config) { - - regval[0] = nphy_def_lnagains[2] + gain_delta[core]; - regval[1] = nphy_def_lnagains[3] + gain_delta[core]; - regval[2] = nphy_def_lnagains[3] + gain_delta[core]; - regval[3] = nphy_def_lnagains[3] + gain_delta[core]; - } else { - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = - nphy_def_lnagains[ctr] + - gain_delta[core]; - } - wlc_phy_table_write_nphy(pi, core, 4, 8, 16, regval); - - minmax_gain[core] = - (u16) (nphy_def_lnagains[2] + gain_delta[core] + 4); - } - - mod_phy_reg(pi, 0x1e, (0xff << 0), (minmax_gain[0] << 0)); - mod_phy_reg(pi, 0x34, (0xff << 0), (minmax_gain[1] << 0)); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void -wlc_phy_war_force_trsw_to_R_cliplo_nphy(struct brcms_phy *pi, u8 core) -{ - if (core == PHY_CORE_0) { - write_phy_reg(pi, 0x38, 0x4); - if (CHSPEC_IS2G(pi->radio_chanspec)) - write_phy_reg(pi, 0x37, 0x0060); - else - write_phy_reg(pi, 0x37, 0x1080); - } else if (core == PHY_CORE_1) { - write_phy_reg(pi, 0x2ae, 0x4); - if (CHSPEC_IS2G(pi->radio_chanspec)) - write_phy_reg(pi, 0x2ad, 0x0060); - else - write_phy_reg(pi, 0x2ad, 0x1080); - } -} - -static void wlc_phy_war_txchain_upd_nphy(struct brcms_phy *pi, u8 txchain) -{ - u8 txchain0, txchain1; - - txchain0 = txchain & 0x1; - txchain1 = (txchain & 0x2) >> 1; - if (!txchain0) - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); - - if (!txchain1) - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); -} - -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) -{ - s8 lna1_gain_db[] = { 8, 13, 17, 22 }; - s8 lna2_gain_db[] = { -2, 7, 11, 15 }; - s8 tia_gain_db[] = { -4, -1, 2, 5, 5, 5, 5, 5, 5, 5 }; - s8 tia_gainbits[] = { - 0x0, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); - - mod_phy_reg(pi, 0x283, (0xff << 0), (0x3c << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (0x3c << 0)); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x8, 8, - lna1_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, 8, - lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, 8, - lna2_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, - tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, - tia_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, - tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, - tia_gainbits); - - write_phy_reg(pi, 0x37, 0x74); - write_phy_reg(pi, 0x2ad, 0x74); - write_phy_reg(pi, 0x38, 0x18); - write_phy_reg(pi, 0x2ae, 0x18); - - write_phy_reg(pi, 0x2b, 0xe8); - write_phy_reg(pi, 0x41, 0xe8); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - - mod_phy_reg(pi, 0x300, (0x3f << 0), (0x12 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (0x12 << 0)); - } else { - - mod_phy_reg(pi, 0x300, (0x3f << 0), (0x10 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (0x10 << 0)); - } -} - -static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) -{ - u16 currband; - s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; - s8 *lna1_gain_db = NULL; - s8 *lna1_gain_db_2 = NULL; - s8 *lna2_gain_db = NULL; - s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; - s8 *tia_gain_db; - s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; - s8 *tia_gainbits; - u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; - u16 *rfseq_init_gain; - u16 init_gaincode; - u16 clip1hi_gaincode; - u16 clip1md_gaincode = 0; - u16 clip1md_gaincode_B; - u16 clip1lo_gaincode; - u16 clip1lo_gaincode_B; - u8 crsminl_th = 0; - u8 crsminu_th; - u16 nbclip_th = 0; - u8 w1clip_th; - u16 freq; - s8 nvar_baseline_offset0 = 0, nvar_baseline_offset1 = 0; - u8 chg_nbclip_th = 0; - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - currband = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; - if (currband == 0) { - - lna1_gain_db = lna1G_gain_db_rev7; - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, - lna1_gain_db); - - mod_phy_reg(pi, 0x283, (0xff << 0), (0x40 << 0)); - - if (CHSPEC_IS40(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x280, (0xff << 0), (0x3e << 0)); - mod_phy_reg(pi, 0x283, (0xff << 0), (0x3e << 0)); - } - - mod_phy_reg(pi, 0x289, (0xff << 0), (0x46 << 0)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x300, (0x3f << 0), (13 << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (13 << 0)); - } - } else { - - init_gaincode = 0x9e; - clip1hi_gaincode = 0x9e; - clip1md_gaincode_B = 0x24; - clip1lo_gaincode = 0x8a; - clip1lo_gaincode_B = 8; - rfseq_init_gain = rfseqA_init_gain_rev7; - - tia_gain_db = tiaA_gain_db_rev7; - tia_gainbits = tiaA_gainbits_rev7; - - freq = CHAN5G_FREQ(CHSPEC_CHANNEL(pi->radio_chanspec)); - if (CHSPEC_IS20(pi->radio_chanspec)) { - - w1clip_th = 25; - clip1md_gaincode = 0x82; - - if ((freq <= 5080) || (freq == 5825)) { - - s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; - s8 lna1A_gain_db_2_rev7[] = { - 11, 17, 22, 25}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; - - crsminu_th = 0x3e; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } else if ((freq >= 5500) && (freq <= 5700)) { - - s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; - - crsminu_th = 0x45; - clip1md_gaincode_B = 0x14; - nbclip_th = 0xff; - chg_nbclip_th = 1; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } else { - - s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; - - crsminu_th = 0x41; - lna1_gain_db = lna1A_gain_db_rev7; - lna1_gain_db_2 = lna1A_gain_db_2_rev7; - lna2_gain_db = lna2A_gain_db_rev7; - } - - if (freq <= 4920) { - nvar_baseline_offset0 = 5; - nvar_baseline_offset1 = 5; - } else if ((freq > 4920) && (freq <= 5320)) { - nvar_baseline_offset0 = 3; - nvar_baseline_offset1 = 5; - } else if ((freq > 5320) && (freq <= 5700)) { - nvar_baseline_offset0 = 3; - nvar_baseline_offset1 = 2; - } else { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 0; - } - } else { - - crsminu_th = 0x3a; - crsminl_th = 0x3a; - w1clip_th = 20; - - if ((freq >= 4920) && (freq <= 5320)) { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 5; - } else if ((freq > 5320) && (freq <= 5550)) { - nvar_baseline_offset0 = 4; - nvar_baseline_offset1 = 2; - } else { - nvar_baseline_offset0 = 5; - nvar_baseline_offset1 = 3; - } - } - - write_phy_reg(pi, 0x20, init_gaincode); - write_phy_reg(pi, 0x2a7, init_gaincode); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - pi->pubpi.phy_corenum, 0x106, 16, - rfseq_init_gain); - - write_phy_reg(pi, 0x22, clip1hi_gaincode); - write_phy_reg(pi, 0x2a9, clip1hi_gaincode); - - write_phy_reg(pi, 0x36, clip1md_gaincode_B); - write_phy_reg(pi, 0x2ac, clip1md_gaincode_B); - - write_phy_reg(pi, 0x37, clip1lo_gaincode); - write_phy_reg(pi, 0x2ad, clip1lo_gaincode); - write_phy_reg(pi, 0x38, clip1lo_gaincode_B); - write_phy_reg(pi, 0x2ae, clip1lo_gaincode_B); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, 8, - tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, 8, - tia_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, 8, - tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, 8, - tia_gainbits); - - mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); - - if (chg_nbclip_th == 1) { - write_phy_reg(pi, 0x2b, nbclip_th); - write_phy_reg(pi, 0x41, nbclip_th); - } - - mod_phy_reg(pi, 0x300, (0x3f << 0), (w1clip_th << 0)); - mod_phy_reg(pi, 0x301, (0x3f << 0), (w1clip_th << 0)); - - mod_phy_reg(pi, 0x2e4, - (0x3f << 0), (nvar_baseline_offset0 << 0)); - - mod_phy_reg(pi, 0x2e4, - (0x3f << 6), (nvar_baseline_offset1 << 6)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, 8, - lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, 8, - lna1_gain_db_2); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, - 8, lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, - 8, lna2_gain_db); - - write_phy_reg(pi, 0x24, clip1md_gaincode); - write_phy_reg(pi, 0x2ab, clip1md_gaincode); - } else { - mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); - } - } -} - -static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) -{ - u16 w1th, hpf_code, currband; - int ctr; - u8 rfseq_updategainu_events[] = { - NPHY_RFSEQ_CMD_RX_GAIN, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_RFSEQ_CMD_SET_HPF_BW - }; - u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; - s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; - s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; - s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; - s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; - s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; - s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; - s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; - s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; - s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; - s8 *lna1_gain_db = NULL; - s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; - s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; - s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; - s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; - s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; - s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; - s8 *lna2_gain_db = NULL; - s8 tiaG_gain_db[] = { - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; - s8 tiaA_gain_db[] = { - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; - s8 tiaA_gain_db_rev4[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev5[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev6[] = { - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 *tia_gain_db; - s8 tiaG_gainbits[] = { - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; - s8 tiaA_gainbits[] = { - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; - s8 tiaA_gainbits_rev4[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev5[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev6[] = { - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 *tia_gainbits; - s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; - s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; - u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; - u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev5_elna[] = { - 0x013f, 0x013f, 0x013f, 0x013f }; - u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; - u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; - u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; - u16 rfseqA_init_gain_rev4_elna[] = { - 0x314f, 0x314f, 0x314f, 0x314f }; - u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; - u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; - u16 *rfseq_init_gain; - u16 initG_gaincode = 0x627e; - u16 initG_gaincode_rev4 = 0x527e; - u16 initG_gaincode_rev5 = 0x427e; - u16 initG_gaincode_rev5_elna = 0x027e; - u16 initG_gaincode_rev6 = 0x527e; - u16 initG_gaincode_rev6_224B0 = 0x427e; - u16 initG_gaincode_rev6_elna = 0x127e; - u16 initA_gaincode = 0x52de; - u16 initA_gaincode_rev4 = 0x629e; - u16 initA_gaincode_rev4_elna = 0x329e; - u16 initA_gaincode_rev5 = 0x729e; - u16 initA_gaincode_rev6 = 0x729e; - u16 init_gaincode; - u16 clip1hiG_gaincode = 0x107e; - u16 clip1hiG_gaincode_rev4 = 0x007e; - u16 clip1hiG_gaincode_rev5 = 0x1076; - u16 clip1hiG_gaincode_rev6 = 0x007e; - u16 clip1hiA_gaincode = 0x00de; - u16 clip1hiA_gaincode_rev4 = 0x029e; - u16 clip1hiA_gaincode_rev5 = 0x029e; - u16 clip1hiA_gaincode_rev6 = 0x029e; - u16 clip1hi_gaincode; - u16 clip1mdG_gaincode = 0x0066; - u16 clip1mdA_gaincode = 0x00ca; - u16 clip1mdA_gaincode_rev4 = 0x1084; - u16 clip1mdA_gaincode_rev5 = 0x2084; - u16 clip1mdA_gaincode_rev6 = 0x2084; - u16 clip1md_gaincode = 0; - u16 clip1loG_gaincode = 0x0074; - u16 clip1loG_gaincode_rev5[] = { - 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c - }; - u16 clip1loG_gaincode_rev6[] = { - 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e - }; - u16 clip1loG_gaincode_rev6_224B0 = 0x1074; - u16 clip1loA_gaincode = 0x00cc; - u16 clip1loA_gaincode_rev4 = 0x0086; - u16 clip1loA_gaincode_rev5 = 0x2086; - u16 clip1loA_gaincode_rev6 = 0x2086; - u16 clip1lo_gaincode; - u8 crsminG_th = 0x18; - u8 crsminG_th_rev5 = 0x18; - u8 crsminG_th_rev6 = 0x18; - u8 crsminA_th = 0x1e; - u8 crsminA_th_rev4 = 0x24; - u8 crsminA_th_rev5 = 0x24; - u8 crsminA_th_rev6 = 0x24; - u8 crsmin_th; - u8 crsminlG_th = 0x18; - u8 crsminlG_th_rev5 = 0x18; - u8 crsminlG_th_rev6 = 0x18; - u8 crsminlA_th = 0x1e; - u8 crsminlA_th_rev4 = 0x24; - u8 crsminlA_th_rev5 = 0x24; - u8 crsminlA_th_rev6 = 0x24; - u8 crsminl_th = 0; - u8 crsminuG_th = 0x18; - u8 crsminuG_th_rev5 = 0x18; - u8 crsminuG_th_rev6 = 0x18; - u8 crsminuA_th = 0x1e; - u8 crsminuA_th_rev4 = 0x24; - u8 crsminuA_th_rev5 = 0x24; - u8 crsminuA_th_rev6 = 0x24; - u8 crsminuA_th_rev6_224B0 = 0x2d; - u8 crsminu_th; - u16 nbclipG_th = 0x20d; - u16 nbclipG_th_rev4 = 0x1a1; - u16 nbclipG_th_rev5 = 0x1d0; - u16 nbclipG_th_rev6 = 0x1d0; - u16 nbclipA_th = 0x1a1; - u16 nbclipA_th_rev4 = 0x107; - u16 nbclipA_th_rev5 = 0x0a9; - u16 nbclipA_th_rev6 = 0x0f0; - u16 nbclip_th = 0; - u8 w1clipG_th = 5; - u8 w1clipG_th_rev5 = 9; - u8 w1clipG_th_rev6 = 5; - u8 w1clipA_th = 25, w1clip_th; - u8 rssi_gain_default = 0x50; - u8 rssiG_gain_rev6_224B0 = 0x50; - u8 rssiA_gain_rev5 = 0x90; - u8 rssiA_gain_rev6 = 0x90; - u8 rssi_gain; - u16 regval[21]; - u8 triso; - - triso = (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g.triso : - pi->srom_fem2g.triso; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (pi->pubpi.radiorev == 5) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev5(pi); - } else if (pi->pubpi.radiorev == 7) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); - - mod_phy_reg(pi, 0x283, (0xff << 0), (0x44 << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (0x44 << 0)); - - } else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 8)) { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); - - if (pi->pubpi.radiorev == 8) { - mod_phy_reg(pi, 0x283, - (0xff << 0), (0x44 << 0)); - mod_phy_reg(pi, 0x280, - (0xff << 0), (0x44 << 0)); - } - } else { - wlc_phy_workarounds_nphy_gainctrl_2057_rev6(pi); - } - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - mod_phy_reg(pi, 0xa0, (0x1 << 6), (1 << 6)); - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - currband = - read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; - if (currband == 0) { - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - if (pi->pubpi.radiorev == 11) { - lna1_gain_db = lna1G_gain_db_rev6_224B0; - lna2_gain_db = lna2G_gain_db_rev6_224B0; - rfseq_init_gain = - rfseqG_init_gain_rev6_224B0; - init_gaincode = - initG_gaincode_rev6_224B0; - clip1hi_gaincode = - clip1hiG_gaincode_rev6; - clip1lo_gaincode = - clip1loG_gaincode_rev6_224B0; - nbclip_th = nbclipG_th_rev6; - w1clip_th = w1clipG_th_rev6; - crsmin_th = crsminG_th_rev6; - crsminl_th = crsminlG_th_rev6; - crsminu_th = crsminuG_th_rev6; - rssi_gain = rssiG_gain_rev6_224B0; - } else { - lna1_gain_db = lna1G_gain_db_rev6; - lna2_gain_db = lna2G_gain_db_rev6; - if (pi->sh->boardflags & BFL_EXTLNA) { - - rfseq_init_gain = - rfseqG_init_gain_rev6_elna; - init_gaincode = - initG_gaincode_rev6_elna; - } else { - rfseq_init_gain = - rfseqG_init_gain_rev6; - init_gaincode = - initG_gaincode_rev6; - } - clip1hi_gaincode = - clip1hiG_gaincode_rev6; - switch (triso) { - case 0: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [0]; - break; - case 1: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [1]; - break; - case 2: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [2]; - break; - case 3: - default: - - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [3]; - break; - case 4: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [4]; - break; - case 5: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [5]; - break; - case 6: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [6]; - break; - case 7: - clip1lo_gaincode = - clip1loG_gaincode_rev6 - [7]; - break; - } - nbclip_th = nbclipG_th_rev6; - w1clip_th = w1clipG_th_rev6; - crsmin_th = crsminG_th_rev6; - crsminl_th = crsminlG_th_rev6; - crsminu_th = crsminuG_th_rev6; - rssi_gain = rssi_gain_default; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - lna1_gain_db = lna1G_gain_db_rev5; - lna2_gain_db = lna2G_gain_db_rev5; - if (pi->sh->boardflags & BFL_EXTLNA) { - - rfseq_init_gain = - rfseqG_init_gain_rev5_elna; - init_gaincode = - initG_gaincode_rev5_elna; - } else { - rfseq_init_gain = rfseqG_init_gain_rev5; - init_gaincode = initG_gaincode_rev5; - } - clip1hi_gaincode = clip1hiG_gaincode_rev5; - switch (triso) { - case 0: - clip1lo_gaincode = - clip1loG_gaincode_rev5[0]; - break; - case 1: - clip1lo_gaincode = - clip1loG_gaincode_rev5[1]; - break; - case 2: - clip1lo_gaincode = - clip1loG_gaincode_rev5[2]; - break; - case 3: - - clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; - break; - case 4: - clip1lo_gaincode = - clip1loG_gaincode_rev5[4]; - break; - case 5: - clip1lo_gaincode = - clip1loG_gaincode_rev5[5]; - break; - case 6: - clip1lo_gaincode = - clip1loG_gaincode_rev5[6]; - break; - case 7: - clip1lo_gaincode = - clip1loG_gaincode_rev5[7]; - break; - default: - clip1lo_gaincode = - clip1loG_gaincode_rev5[3]; - break; - } - nbclip_th = nbclipG_th_rev5; - w1clip_th = w1clipG_th_rev5; - crsmin_th = crsminG_th_rev5; - crsminl_th = crsminlG_th_rev5; - crsminu_th = crsminuG_th_rev5; - rssi_gain = rssi_gain_default; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - lna1_gain_db = lna1G_gain_db_rev4; - lna2_gain_db = lna2G_gain_db; - rfseq_init_gain = rfseqG_init_gain_rev4; - init_gaincode = initG_gaincode_rev4; - clip1hi_gaincode = clip1hiG_gaincode_rev4; - clip1lo_gaincode = clip1loG_gaincode; - nbclip_th = nbclipG_th_rev4; - w1clip_th = w1clipG_th; - crsmin_th = crsminG_th; - crsminl_th = crsminlG_th; - crsminu_th = crsminuG_th; - rssi_gain = rssi_gain_default; - } else { - lna1_gain_db = lna1G_gain_db; - lna2_gain_db = lna2G_gain_db; - rfseq_init_gain = rfseqG_init_gain; - init_gaincode = initG_gaincode; - clip1hi_gaincode = clip1hiG_gaincode; - clip1lo_gaincode = clip1loG_gaincode; - nbclip_th = nbclipG_th; - w1clip_th = w1clipG_th; - crsmin_th = crsminG_th; - crsminl_th = crsminlG_th; - crsminu_th = crsminuG_th; - rssi_gain = rssi_gain_default; - } - tia_gain_db = tiaG_gain_db; - tia_gainbits = tiaG_gainbits; - clip1md_gaincode = clip1mdG_gaincode; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - lna1_gain_db = lna1A_gain_db_rev6; - lna2_gain_db = lna2A_gain_db_rev6; - tia_gain_db = tiaA_gain_db_rev6; - tia_gainbits = tiaA_gainbits_rev6; - rfseq_init_gain = rfseqA_init_gain_rev6; - init_gaincode = initA_gaincode_rev6; - clip1hi_gaincode = clip1hiA_gaincode_rev6; - clip1md_gaincode = clip1mdA_gaincode_rev6; - clip1lo_gaincode = clip1loA_gaincode_rev6; - crsmin_th = crsminA_th_rev6; - crsminl_th = crsminlA_th_rev6; - if ((pi->pubpi.radiorev == 11) && - (CHSPEC_IS40(pi->radio_chanspec) == 0)) - crsminu_th = crsminuA_th_rev6_224B0; - else - crsminu_th = crsminuA_th_rev6; - - nbclip_th = nbclipA_th_rev6; - rssi_gain = rssiA_gain_rev6; - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - lna1_gain_db = lna1A_gain_db_rev5; - lna2_gain_db = lna2A_gain_db_rev5; - tia_gain_db = tiaA_gain_db_rev5; - tia_gainbits = tiaA_gainbits_rev5; - rfseq_init_gain = rfseqA_init_gain_rev5; - init_gaincode = initA_gaincode_rev5; - clip1hi_gaincode = clip1hiA_gaincode_rev5; - clip1md_gaincode = clip1mdA_gaincode_rev5; - clip1lo_gaincode = clip1loA_gaincode_rev5; - crsmin_th = crsminA_th_rev5; - crsminl_th = crsminlA_th_rev5; - crsminu_th = crsminuA_th_rev5; - nbclip_th = nbclipA_th_rev5; - rssi_gain = rssiA_gain_rev5; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - lna1_gain_db = lna1A_gain_db_rev4; - lna2_gain_db = lna2A_gain_db_rev4; - tia_gain_db = tiaA_gain_db_rev4; - tia_gainbits = tiaA_gainbits_rev4; - if (pi->sh->boardflags & BFL_EXTLNA_5GHz) { - - rfseq_init_gain = - rfseqA_init_gain_rev4_elna; - init_gaincode = - initA_gaincode_rev4_elna; - } else { - rfseq_init_gain = rfseqA_init_gain_rev4; - init_gaincode = initA_gaincode_rev4; - } - clip1hi_gaincode = clip1hiA_gaincode_rev4; - clip1md_gaincode = clip1mdA_gaincode_rev4; - clip1lo_gaincode = clip1loA_gaincode_rev4; - crsmin_th = crsminA_th_rev4; - crsminl_th = crsminlA_th_rev4; - crsminu_th = crsminuA_th_rev4; - nbclip_th = nbclipA_th_rev4; - rssi_gain = rssi_gain_default; - } else { - lna1_gain_db = lna1A_gain_db; - lna2_gain_db = lna2A_gain_db; - tia_gain_db = tiaA_gain_db; - tia_gainbits = tiaA_gainbits; - rfseq_init_gain = rfseqA_init_gain; - init_gaincode = initA_gaincode; - clip1hi_gaincode = clip1hiA_gaincode; - clip1md_gaincode = clip1mdA_gaincode; - clip1lo_gaincode = clip1loA_gaincode; - crsmin_th = crsminA_th; - crsminl_th = crsminlA_th; - crsminu_th = crsminuA_th; - nbclip_th = nbclipA_th; - rssi_gain = rssi_gain_default; - } - w1clip_th = w1clipA_th; - } - - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | - RADIO_2056_RX0), 0x17); - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAG1_IDAC | - RADIO_2056_RX1), 0x17); - - write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX0), - 0xf0); - write_radio_reg(pi, (RADIO_2056_RX_LNAG2_IDAC | RADIO_2056_RX1), - 0xf0); - - write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, (RADIO_2056_RX_RSSI_POLE | RADIO_2056_RX1), - 0x0); - - write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX0), - rssi_gain); - write_radio_reg(pi, (RADIO_2056_RX_RSSI_GAIN | RADIO_2056_RX1), - rssi_gain); - - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | - RADIO_2056_RX0), 0x17); - write_radio_reg(pi, - (RADIO_2056_RX_BIASPOLE_LNAA1_IDAC | - RADIO_2056_RX1), 0x17); - - write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX0), - 0xFF); - write_radio_reg(pi, (RADIO_2056_RX_LNAA2_IDAC | RADIO_2056_RX1), - 0xFF); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 8, - 8, lna1_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 8, - 8, lna1_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 4, 0x10, - 8, lna2_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 4, 0x10, - 8, lna2_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 10, 0x20, - 8, tia_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 10, 0x20, - 8, tia_gain_db); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 10, 0x20, - 8, tia_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 10, 0x20, - 8, tia_gainbits); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN1, 6, 0x40, - 8, &lpf_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAIN2, 6, 0x40, - 8, &lpf_gain_db); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS1, 6, 0x40, - 8, &lpf_gainbits); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_GAINBITS2, 6, 0x40, - 8, &lpf_gainbits); - - write_phy_reg(pi, 0x20, init_gaincode); - write_phy_reg(pi, 0x2a7, init_gaincode); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - pi->pubpi.phy_corenum, 0x106, 16, - rfseq_init_gain); - - write_phy_reg(pi, 0x22, clip1hi_gaincode); - write_phy_reg(pi, 0x2a9, clip1hi_gaincode); - - write_phy_reg(pi, 0x24, clip1md_gaincode); - write_phy_reg(pi, 0x2ab, clip1md_gaincode); - - write_phy_reg(pi, 0x37, clip1lo_gaincode); - write_phy_reg(pi, 0x2ad, clip1lo_gaincode); - - mod_phy_reg(pi, 0x27d, (0xff << 0), (crsmin_th << 0)); - mod_phy_reg(pi, 0x280, (0xff << 0), (crsminl_th << 0)); - mod_phy_reg(pi, 0x283, (0xff << 0), (crsminu_th << 0)); - - write_phy_reg(pi, 0x2b, nbclip_th); - write_phy_reg(pi, 0x41, nbclip_th); - - mod_phy_reg(pi, 0x27, (0x3f << 0), (w1clip_th << 0)); - mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1clip_th << 0)); - - write_phy_reg(pi, 0x150, 0x809c); - - } else { - - mod_phy_reg(pi, 0x1c, (0x1 << 13), (1 << 13)); - mod_phy_reg(pi, 0x32, (0x1 << 13), (1 << 13)); - - write_phy_reg(pi, 0x2b, 0x84); - write_phy_reg(pi, 0x41, 0x84); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - write_phy_reg(pi, 0x6b, 0x2b); - write_phy_reg(pi, 0x6c, 0x2b); - write_phy_reg(pi, 0x6d, 0x9); - write_phy_reg(pi, 0x6e, 0x9); - } - - w1th = NPHY_RSSICAL_W1_TARGET - 4; - mod_phy_reg(pi, 0x27, (0x3f << 0), (w1th << 0)); - mod_phy_reg(pi, 0x3d, (0x3f << 0), (w1th << 0)); - - if (CHSPEC_IS20(pi->radio_chanspec)) { - mod_phy_reg(pi, 0x1c, (0x1f << 0), (0x1 << 0)); - mod_phy_reg(pi, 0x32, (0x1f << 0), (0x1 << 0)); - - mod_phy_reg(pi, 0x1d, (0x1f << 0), (0x1 << 0)); - mod_phy_reg(pi, 0x33, (0x1f << 0), (0x1 << 0)); - } - - write_phy_reg(pi, 0x150, 0x809c); - - if (pi->nphy_gain_boost) - if ((CHSPEC_IS2G(pi->radio_chanspec)) && - (CHSPEC_IS40(pi->radio_chanspec))) - hpf_code = 4; - else - hpf_code = 5; - else if (CHSPEC_IS40(pi->radio_chanspec)) - hpf_code = 6; - else - hpf_code = 7; - - mod_phy_reg(pi, 0x20, (0x1f << 7), (hpf_code << 7)); - mod_phy_reg(pi, 0x36, (0x1f << 7), (hpf_code << 7)); - - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = (hpf_code << 8) | 0x7c; - wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); - - wlc_phy_adjust_lnagaintbl_nphy(pi); - - if (pi->nphy_elna_gain_config) { - regval[0] = 0; - regval[1] = 1; - regval[2] = 1; - regval[3] = 1; - wlc_phy_table_write_nphy(pi, 2, 4, 8, 16, regval); - wlc_phy_table_write_nphy(pi, 3, 4, 8, 16, regval); - - for (ctr = 0; ctr < 4; ctr++) - regval[ctr] = (hpf_code << 8) | 0x74; - wlc_phy_table_write_nphy(pi, 7, 4, 0x106, 16, regval); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) { - for (ctr = 0; ctr < 21; ctr++) - regval[ctr] = 3 * ctr; - wlc_phy_table_write_nphy(pi, 0, 21, 32, 16, regval); - wlc_phy_table_write_nphy(pi, 1, 21, 32, 16, regval); - - for (ctr = 0; ctr < 21; ctr++) - regval[ctr] = (u16) ctr; - wlc_phy_table_write_nphy(pi, 2, 21, 32, 16, regval); - wlc_phy_table_write_nphy(pi, 3, 21, 32, 16, regval); - } - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_UPDATEGAINU, - rfseq_updategainu_events, - rfseq_updategainu_dlys, - sizeof(rfseq_updategainu_events) / - sizeof(rfseq_updategainu_events[0])); - - mod_phy_reg(pi, 0x153, (0xff << 8), (90 << 8)); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - mod_phy_reg(pi, - (NPHY_TO_BPHY_OFF + BPHY_OPTIONAL_MODES), - 0x7f, 0x4); - } -} - -static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) -{ - u8 rfseq_rx2tx_events[] = { - NPHY_RFSEQ_CMD_NOP, - NPHY_RFSEQ_CMD_RXG_FBW, - NPHY_RFSEQ_CMD_TR_SWITCH, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_RFSEQ_CMD_RXPD_TXPD, - NPHY_RFSEQ_CMD_TX_GAIN, - NPHY_RFSEQ_CMD_EXT_PA - }; - u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; - u8 rfseq_tx2rx_events[] = { - NPHY_RFSEQ_CMD_NOP, - NPHY_RFSEQ_CMD_EXT_PA, - NPHY_RFSEQ_CMD_TX_GAIN, - NPHY_RFSEQ_CMD_RXPD_TXPD, - NPHY_RFSEQ_CMD_TR_SWITCH, - NPHY_RFSEQ_CMD_RXG_FBW, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS - }; - u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; - u8 rfseq_tx2rx_events_rev3[] = { - NPHY_REV3_RFSEQ_CMD_EXT_PA, - NPHY_REV3_RFSEQ_CMD_INT_PA_PU, - NPHY_REV3_RFSEQ_CMD_TX_GAIN, - NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, - NPHY_REV3_RFSEQ_CMD_TR_SWITCH, - NPHY_REV3_RFSEQ_CMD_RXG_FBW, - NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_REV3_RFSEQ_CMD_END - }; - u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; - u8 rfseq_rx2tx_events_rev3[] = { - NPHY_REV3_RFSEQ_CMD_NOP, - NPHY_REV3_RFSEQ_CMD_RXG_FBW, - NPHY_REV3_RFSEQ_CMD_TR_SWITCH, - NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, - NPHY_REV3_RFSEQ_CMD_TX_GAIN, - NPHY_REV3_RFSEQ_CMD_INT_PA_PU, - NPHY_REV3_RFSEQ_CMD_EXT_PA, - NPHY_REV3_RFSEQ_CMD_END - }; - u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; - - u8 rfseq_rx2tx_events_rev3_ipa[] = { - NPHY_REV3_RFSEQ_CMD_NOP, - NPHY_REV3_RFSEQ_CMD_RXG_FBW, - NPHY_REV3_RFSEQ_CMD_TR_SWITCH, - NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, - NPHY_REV3_RFSEQ_CMD_TX_GAIN, - NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS, - NPHY_REV3_RFSEQ_CMD_INT_PA_PU, - NPHY_REV3_RFSEQ_CMD_END - }; - u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; - u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; - - s16 alpha0, alpha1, alpha2; - s16 beta0, beta1, beta2; - u32 leg_data_weights, ht_data_weights, nss1_data_weights, - stbc_data_weights; - u8 chan_freq_range = 0; - u16 dac_control = 0x0002; - u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 }; - u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 }; - u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; - u16 aux_adc_vmid_rev3[] = { 0xa2, 0xb4, 0xb4, 0x89 }; - u16 *aux_adc_vmid; - u16 aux_adc_gain_rev7[] = { 0x02, 0x02, 0x02, 0x02 }; - u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; - u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; - u16 *aux_adc_gain; - u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; - u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; - s32 min_nvar_val = 0x18d; - s32 min_nvar_offset_6mbps = 20; - u8 pdetrange; - u8 triso; - u16 regval; - u16 afectrl_adc_ctrl1_rev7 = 0x20; - u16 afectrl_adc_ctrl2_rev7 = 0x0; - u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77; - u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77; - u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77; - u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; - u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; - u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; - u16 ipalvlshift_3p3_war_en = 0; - u16 rccal_bcap_val, rccal_scap_val; - u16 rccal_tx20_11b_bcap = 0; - u16 rccal_tx20_11b_scap = 0; - u16 rccal_tx20_11n_bcap = 0; - u16 rccal_tx20_11n_scap = 0; - u16 rccal_tx40_11n_bcap = 0; - u16 rccal_tx40_11n_scap = 0; - u16 rx2tx_lpf_rc_lut_tx20_11b = 0; - u16 rx2tx_lpf_rc_lut_tx20_11n = 0; - u16 rx2tx_lpf_rc_lut_tx40_11n = 0; - u16 tx_lpf_bw_ofdm_20mhz = 0; - u16 tx_lpf_bw_ofdm_40mhz = 0; - u16 tx_lpf_bw_11b = 0; - u16 ipa2g_mainbias, ipa2g_casconv, ipa2g_biasfilt; - u16 txgm_idac_bleed = 0; - bool rccal_ovrd = false; - u16 freq; - int coreNum; - - if (CHSPEC_IS5G(pi->radio_chanspec)) - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 0); - else - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 1); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - or_phy_reg(pi, 0xb1, NPHY_IQFlip_ADC1 | NPHY_IQFlip_ADC2); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - mod_phy_reg(pi, 0x221, (0x1 << 4), (1 << 4)); - - mod_phy_reg(pi, 0x160, (0x7f << 0), (32 << 0)); - mod_phy_reg(pi, 0x160, (0x7f << 8), (39 << 8)); - mod_phy_reg(pi, 0x161, (0x7f << 0), (46 << 0)); - mod_phy_reg(pi, 0x161, (0x7f << 8), (51 << 8)); - mod_phy_reg(pi, 0x162, (0x7f << 0), (55 << 0)); - mod_phy_reg(pi, 0x162, (0x7f << 8), (58 << 8)); - mod_phy_reg(pi, 0x163, (0x7f << 0), (60 << 0)); - mod_phy_reg(pi, 0x163, (0x7f << 8), (62 << 8)); - mod_phy_reg(pi, 0x164, (0x7f << 0), (62 << 0)); - mod_phy_reg(pi, 0x164, (0x7f << 8), (63 << 8)); - mod_phy_reg(pi, 0x165, (0x7f << 0), (63 << 0)); - mod_phy_reg(pi, 0x165, (0x7f << 8), (64 << 8)); - mod_phy_reg(pi, 0x166, (0x7f << 0), (64 << 0)); - mod_phy_reg(pi, 0x166, (0x7f << 8), (64 << 8)); - mod_phy_reg(pi, 0x167, (0x7f << 0), (64 << 0)); - mod_phy_reg(pi, 0x167, (0x7f << 8), (64 << 8)); - } - - if (NREV_LE(pi->pubpi.phy_rev, 8)) { - write_phy_reg(pi, 0x23f, 0x1b0); - write_phy_reg(pi, 0x240, 0x1b0); - } - - if (NREV_GE(pi->pubpi.phy_rev, 8)) - mod_phy_reg(pi, 0xbd, (0xff << 0), (114 << 0)); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, - &dac_control); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, - &dac_control); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - leg_data_weights = leg_data_weights & 0xffffff; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 2, 0x15e, 16, - rfseq_rx2tx_dacbufpu_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x16e, 16, - rfseq_rx2tx_dacbufpu_rev7); - - if (PHY_IPA(pi)) - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3_ipa, - rfseq_rx2tx_dlys_rev3_ipa, - sizeof - (rfseq_rx2tx_events_rev3_ipa) / - sizeof - (rfseq_rx2tx_events_rev3_ipa - [0])); - - mod_phy_reg(pi, 0x299, (0x3 << 14), (0x1 << 14)); - mod_phy_reg(pi, 0x29d, (0x3 << 14), (0x1 << 14)); - - tx_lpf_bw_ofdm_20mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x154); - tx_lpf_bw_ofdm_40mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x159); - tx_lpf_bw_11b = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x152); - - if (PHY_IPA(pi)) { - - if (((pi->pubpi.radiorev == 5) - && (CHSPEC_IS40(pi->radio_chanspec) == 1)) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - rccal_bcap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_BCAP_VAL); - rccal_scap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_SCAP_VAL); - - rccal_tx20_11b_bcap = rccal_bcap_val; - rccal_tx20_11b_scap = rccal_scap_val; - - if ((pi->pubpi.radiorev == 5) && - (CHSPEC_IS40(pi->radio_chanspec) == 1)) { - - rccal_tx20_11n_bcap = rccal_bcap_val; - rccal_tx20_11n_scap = rccal_scap_val; - rccal_tx40_11n_bcap = 0xc; - rccal_tx40_11n_scap = 0xc; - - rccal_ovrd = true; - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - tx_lpf_bw_ofdm_20mhz = 4; - tx_lpf_bw_11b = 1; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - rccal_tx20_11n_bcap = 0xc; - rccal_tx20_11n_scap = 0xc; - rccal_tx40_11n_bcap = 0xa; - rccal_tx40_11n_scap = 0xa; - } else { - rccal_tx20_11n_bcap = 0x14; - rccal_tx20_11n_scap = 0x14; - rccal_tx40_11n_bcap = 0xf; - rccal_tx40_11n_scap = 0xf; - } - - rccal_ovrd = true; - } - } - - } else { - - if (pi->pubpi.radiorev == 5) { - - tx_lpf_bw_ofdm_20mhz = 1; - tx_lpf_bw_ofdm_40mhz = 3; - - rccal_bcap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_BCAP_VAL); - rccal_scap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_SCAP_VAL); - - rccal_tx20_11b_bcap = rccal_bcap_val; - rccal_tx20_11b_scap = rccal_scap_val; - - rccal_tx20_11n_bcap = 0x13; - rccal_tx20_11n_scap = 0x11; - rccal_tx40_11n_bcap = 0x13; - rccal_tx40_11n_scap = 0x11; - - rccal_ovrd = true; - } - } - - if (rccal_ovrd) { - - rx2tx_lpf_rc_lut_tx20_11b = - (rccal_tx20_11b_bcap << 8) | - (rccal_tx20_11b_scap << 3) | - tx_lpf_bw_11b; - rx2tx_lpf_rc_lut_tx20_11n = - (rccal_tx20_11n_bcap << 8) | - (rccal_tx20_11n_scap << 3) | - tx_lpf_bw_ofdm_20mhz; - rx2tx_lpf_rc_lut_tx40_11n = - (rccal_tx40_11n_bcap << 8) | - (rccal_tx40_11n_scap << 3) | - tx_lpf_bw_ofdm_40mhz; - - for (coreNum = 0; coreNum <= 1; coreNum++) { - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x152 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11b); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x153 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x154 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x155 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x156 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x157 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x158 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x159 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - } - - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 4), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - } - - write_phy_reg(pi, 0x32f, 0x3); - - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - if ((pi->sh->sromrev >= 8) - && (pi->sh->boardflags2 & BFL2_IPALVLSHIFT_3P3)) - ipalvlshift_3p3_war_en = 1; - - if (ipalvlshift_3p3_war_en) { - write_radio_reg(pi, RADIO_2057_GPAIO_CONFIG, - 0x5); - write_radio_reg(pi, RADIO_2057_GPAIO_SEL1, - 0x30); - write_radio_reg(pi, RADIO_2057_GPAIO_SEL0, 0x0); - or_radio_reg(pi, - RADIO_2057_RXTXBIAS_CONFIG_CORE0, - 0x1); - or_radio_reg(pi, - RADIO_2057_RXTXBIAS_CONFIG_CORE1, - 0x1); - - ipa2g_mainbias = 0x1f; - - ipa2g_casconv = 0x6f; - - ipa2g_biasfilt = 0xaa; - } else { - - ipa2g_mainbias = 0x2b; - - ipa2g_casconv = 0x7f; - - ipa2g_biasfilt = 0xee; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, IPA2G_IMAIN, - ipa2g_mainbias); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, IPA2G_CASCONV, - ipa2g_casconv); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - IPA2G_BIAS_FILTER, - ipa2g_biasfilt); - } - } - } - - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) - txgm_idac_bleed = 0x7f; - - for (coreNum = 0; coreNum <= 1; coreNum++) { - if (txgm_idac_bleed != 0) - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - TXGM_IDAC_BLEED, - txgm_idac_bleed); - } - - if (pi->pubpi.radiorev == 5) { - - for (coreNum = 0; coreNum <= 1; - coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - IPA2G_CASCONV, - 0x13); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - IPA2G_IMAIN, - 0x1f); - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - IPA2G_BIAS_FILTER, - 0xee); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - PAD2G_IDACS, - 0x8a); - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - PAD_BIAS_FILTER_BWS, - 0x3e); - } - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - if (CHSPEC_IS40(pi->radio_chanspec) == - 0) { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 0, - IPA2G_IMAIN, - 0x14); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 1, - IPA2G_IMAIN, - 0x12); - } else { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 0, - IPA2G_IMAIN, - 0x16); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 1, - IPA2G_IMAIN, - 0x16); - } - } - - } else { - freq = CHAN5G_FREQ(CHSPEC_CHANNEL( - pi->radio_chanspec)); - if (((freq >= 5180) && (freq <= 5230)) - || ((freq >= 5745) && (freq <= 5805))) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - 0, IPA5G_BIAS_FILTER, - 0xff); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - 1, IPA5G_BIAS_FILTER, - 0xff); - } - } - } else { - - if (pi->pubpi.radiorev != 5) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - TXMIX2G_TUNE_BOOST_PU, - 0x61); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - TXGM_IDAC_BLEED, 0x70); - } - } - } - - if (pi->pubpi.radiorev == 4) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x05, 16, - &afectrl_adc_ctrl1_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x15, 16, - &afectrl_adc_ctrl1_rev7); - - for (coreNum = 0; coreNum <= 1; coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_VCM_CAL_MASTER, 0x0); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_SET_VCM_I, 0x3f); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_SET_VCM_Q, 0x3f); - } - } else { - mod_phy_reg(pi, 0xa6, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0x8f, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa7, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa5, (0x1 << 2), (0x1 << 2)); - - mod_phy_reg(pi, 0xa6, (0x1 << 0), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 0), (0x1 << 0)); - mod_phy_reg(pi, 0xa7, (0x1 << 0), 0); - mod_phy_reg(pi, 0xa5, (0x1 << 0), (0x1 << 0)); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x05, 16, - &afectrl_adc_ctrl2_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x15, 16, - &afectrl_adc_ctrl2_rev7); - - mod_phy_reg(pi, 0xa6, (0x1 << 2), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa5, (0x1 << 2), 0); - } - - write_phy_reg(pi, 0x6a, 0x2); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 256, 32, - &min_nvar_offset_6mbps); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x138, 16, - &rfseq_pktgn_lpf_hpc_rev7); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x141, 16, - &rfseq_pktgn_lpf_h_hpc_rev7); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 3, 0x133, 16, - &rfseq_htpktgn_lpf_hpc_rev7); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x146, 16, - &rfseq_cckpktgn_lpf_hpc_rev7); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x123, 16, - &rfseq_tx2rx_lpf_h_hpc_rev7); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x12A, 16, - &rfseq_rx2tx_lpf_h_hpc_rev7); - - if (CHSPEC_IS40(pi->radio_chanspec) == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } else { - min_nvar_val = noise_var_tbl_rev7[3]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - - min_nvar_val = noise_var_tbl_rev7[127]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } - - wlc_phy_workarounds_nphy_gainctrl(pi); - - pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; - - if (pdetrange == 0) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x70; - aux_adc_vmid_rev7_core1[3] = 0x70; - aux_adc_gain_rev7[3] = 2; - } else { - aux_adc_vmid_rev7_core0[3] = 0x80; - aux_adc_vmid_rev7_core1[3] = 0x80; - aux_adc_gain_rev7[3] = 3; - } - } else if (pdetrange == 1) { - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x7c; - aux_adc_vmid_rev7_core1[3] = 0x7c; - aux_adc_gain_rev7[3] = 2; - } else { - aux_adc_vmid_rev7_core0[3] = 0x8c; - aux_adc_vmid_rev7_core1[3] = 0x8c; - aux_adc_gain_rev7[3] = 1; - } - } else if (pdetrange == 2) { - if (pi->pubpi.radioid == BCM2057_ID) { - if ((pi->pubpi.radiorev == 5) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - if (chan_freq_range == - WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = - 0x8c; - aux_adc_vmid_rev7_core1[3] = - 0x8c; - aux_adc_gain_rev7[3] = 0; - } else { - aux_adc_vmid_rev7_core0[3] = - 0x96; - aux_adc_vmid_rev7_core1[3] = - 0x96; - aux_adc_gain_rev7[3] = 0; - } - } - } - - } else if (pdetrange == 3) { - if (chan_freq_range == WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x89; - aux_adc_vmid_rev7_core1[3] = 0x89; - aux_adc_gain_rev7[3] = 0; - } - - } else if (pdetrange == 5) { - - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x80; - aux_adc_vmid_rev7_core1[3] = 0x80; - aux_adc_gain_rev7[3] = 3; - } else { - aux_adc_vmid_rev7_core0[3] = 0x70; - aux_adc_vmid_rev7_core1[3] = 0x70; - aux_adc_gain_rev7[3] = 2; - } - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x08, 16, - &aux_adc_vmid_rev7_core0); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x18, 16, - &aux_adc_vmid_rev7_core1); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x0c, 16, - &aux_adc_gain_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x1c, 16, - &aux_adc_gain_rev7); - - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - write_phy_reg(pi, 0x23f, 0x1f8); - write_phy_reg(pi, 0x240, 0x1f8); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - leg_data_weights = leg_data_weights & 0xffffff; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - - alpha0 = 293; - alpha1 = 435; - alpha2 = 261; - beta0 = 366; - beta1 = 205; - beta2 = 32; - write_phy_reg(pi, 0x145, alpha0); - write_phy_reg(pi, 0x146, alpha1); - write_phy_reg(pi, 0x147, alpha2); - write_phy_reg(pi, 0x148, beta0); - write_phy_reg(pi, 0x149, beta1); - write_phy_reg(pi, 0x14a, beta2); - - write_phy_reg(pi, 0x38, 0xC); - write_phy_reg(pi, 0x2ae, 0xC); - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, - rfseq_tx2rx_events_rev3, - rfseq_tx2rx_dlys_rev3, - sizeof(rfseq_tx2rx_events_rev3) / - sizeof(rfseq_tx2rx_events_rev3[0])); - - if (PHY_IPA(pi)) - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3_ipa, - rfseq_rx2tx_dlys_rev3_ipa, - sizeof - (rfseq_rx2tx_events_rev3_ipa) / - sizeof - (rfseq_rx2tx_events_rev3_ipa - [0])); - - if ((pi->sh->hw_phyrxchain != 0x3) && - (pi->sh->hw_phyrxchain != pi->sh->hw_phytxchain)) { - - if (PHY_IPA(pi)) { - rfseq_rx2tx_dlys_rev3[5] = 59; - rfseq_rx2tx_dlys_rev3[6] = 1; - rfseq_rx2tx_events_rev3[7] = - NPHY_REV3_RFSEQ_CMD_END; - } - - wlc_phy_set_rfseq_nphy( - pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3, - rfseq_rx2tx_dlys_rev3, - sizeof(rfseq_rx2tx_events_rev3) / - sizeof(rfseq_rx2tx_events_rev3[0])); - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) - write_phy_reg(pi, 0x6a, 0x2); - else - write_phy_reg(pi, 0x6a, 0x9c40); - - mod_phy_reg(pi, 0x294, (0xf << 8), (7 << 8)); - - if (CHSPEC_IS40(pi->radio_chanspec) == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } else { - min_nvar_val = noise_var_tbl_rev3[3]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - - min_nvar_val = noise_var_tbl_rev3[127]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } - - wlc_phy_workarounds_nphy_gainctrl(pi); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, - &dac_control); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, - &dac_control); - - pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; - - if (pdetrange == 0) { - if (NREV_GE(pi->pubpi.phy_rev, 4)) { - aux_adc_vmid = aux_adc_vmid_rev4; - aux_adc_gain = aux_adc_gain_rev4; - } else { - aux_adc_vmid = aux_adc_vmid_rev3; - aux_adc_gain = aux_adc_gain_rev3; - } - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_5GL: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - case WL_CHAN_FREQ_RANGE_5GM: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - case WL_CHAN_FREQ_RANGE_5GH: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - default: - break; - } - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, aux_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, aux_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, aux_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, aux_adc_gain); - } else if (pdetrange == 1) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, sk_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, sk_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, sk_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, sk_adc_gain); - } else if (pdetrange == 2) { - - u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x74 }; - u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x04 }; - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - bcm_adc_vmid[3] = 0x8e; - bcm_adc_gain[3] = 0x03; - } else { - bcm_adc_vmid[3] = 0x94; - bcm_adc_gain[3] = 0x03; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - bcm_adc_vmid[3] = 0x84; - bcm_adc_gain[3] = 0x02; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, bcm_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, bcm_adc_gain); - } else if (pdetrange == 3) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if ((NREV_GE(pi->pubpi.phy_rev, 4)) - && (chan_freq_range == WL_CHAN_FREQ_RANGE_2G)) { - - u16 auxadc_vmid[] = { - 0xa2, 0xb4, 0xb4, 0x270 - }; - u16 auxadc_gain[] = { - 0x02, 0x02, 0x02, 0x00 - }; - - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, auxadc_vmid); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, auxadc_vmid); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, auxadc_gain); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, auxadc_gain); - } - } else if ((pdetrange == 4) || (pdetrange == 5)) { - u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x0 }; - u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x0 }; - u16 Vmid[2], Av[2]; - - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - Vmid[0] = (pdetrange == 4) ? 0x8e : 0x89; - Vmid[1] = (pdetrange == 4) ? 0x96 : 0x89; - Av[0] = (pdetrange == 4) ? 2 : 0; - Av[1] = (pdetrange == 4) ? 2 : 0; - } else { - Vmid[0] = (pdetrange == 4) ? 0x89 : 0x74; - Vmid[1] = (pdetrange == 4) ? 0x8b : 0x70; - Av[0] = (pdetrange == 4) ? 2 : 0; - Av[1] = (pdetrange == 4) ? 2 : 0; - } - - bcm_adc_vmid[3] = Vmid[0]; - bcm_adc_gain[3] = Av[0]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, bcm_adc_gain); - - bcm_adc_vmid[3] = Vmid[1]; - bcm_adc_gain[3] = Av[1]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, bcm_adc_gain); - } - - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX1), - 0x0); - - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX0), - 0x6); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX1), - 0x6); - - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX0), - 0x7); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX1), - 0x7); - - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX0), - 0x88); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX1), - 0x88); - - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX1), - 0x0); - - write_radio_reg(pi, - (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX1), - 0x0); - - triso = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - triso : pi->srom_fem2g.triso; - if (triso == 7) { - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); - } - - wlc_phy_war_txchain_upd_nphy(pi, pi->sh->hw_phytxchain); - - if (((pi->sh->boardflags2 & BFL2_APLL_WAR) && - (CHSPEC_IS5G(pi->radio_chanspec))) || - (((pi->sh->boardflags2 & BFL2_GPLL_WAR) || - (pi->sh->boardflags2 & BFL2_GPLL_WAR2)) && - (CHSPEC_IS2G(pi->radio_chanspec)))) { - nss1_data_weights = 0x00088888; - ht_data_weights = 0x00088888; - stbc_data_weights = 0x00088888; - } else { - nss1_data_weights = 0x88888888; - ht_data_weights = 0x88888888; - stbc_data_weights = 0x88888888; - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 1, 32, &nss1_data_weights); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 2, 32, &ht_data_weights); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 3, 32, &stbc_data_weights); - - if (NREV_IS(pi->pubpi.phy_rev, 4)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, - RADIO_2056_TX_GMBB_IDAC | - RADIO_2056_TX0, 0x70); - write_radio_reg(pi, - RADIO_2056_TX_GMBB_IDAC | - RADIO_2056_TX1, 0x70); - } - } - - if (!pi->edcrs_threshold_lock) { - write_phy_reg(pi, 0x224, 0x3eb); - write_phy_reg(pi, 0x225, 0x3eb); - write_phy_reg(pi, 0x226, 0x341); - write_phy_reg(pi, 0x227, 0x341); - write_phy_reg(pi, 0x228, 0x42b); - write_phy_reg(pi, 0x229, 0x42b); - write_phy_reg(pi, 0x22a, 0x381); - write_phy_reg(pi, 0x22b, 0x381); - write_phy_reg(pi, 0x22c, 0x42b); - write_phy_reg(pi, 0x22d, 0x42b); - write_phy_reg(pi, 0x22e, 0x381); - write_phy_reg(pi, 0x22f, 0x381); - } - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - - if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) - wlapi_bmac_mhf(pi->sh->physhim, MHF4, - MHF4_BPHY_TXCORE0, - MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); - } - } else { - - if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD || - (pi->sh->boardtype == 0x8b)) { - uint i; - u8 war_dlys[] = { 1, 6, 6, 2, 4, 20, 1 }; - for (i = 0; i < ARRAY_SIZE(rfseq_rx2tx_dlys); i++) - rfseq_rx2tx_dlys[i] = war_dlys[i]; - } - - if (CHSPEC_IS5G(pi->radio_chanspec) && pi->phy_5g_pwrgain) { - and_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0xf7); - and_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0xf7); - } else { - or_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0x8); - or_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0x8); - } - - regval = 0x000a; - wlc_phy_table_write_nphy(pi, 8, 1, 0, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x10, 16, ®val); - - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - regval = 0xcdaa; - wlc_phy_table_write_nphy(pi, 8, 1, 0x02, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x12, 16, ®val); - } - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - regval = 0x0000; - wlc_phy_table_write_nphy(pi, 8, 1, 0x08, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x18, 16, ®val); - - regval = 0x7aab; - wlc_phy_table_write_nphy(pi, 8, 1, 0x07, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x17, 16, ®val); - - regval = 0x0800; - wlc_phy_table_write_nphy(pi, 8, 1, 0x06, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x16, 16, ®val); - } - - write_phy_reg(pi, 0xf8, 0x02d8); - write_phy_reg(pi, 0xf9, 0x0301); - write_phy_reg(pi, 0xfa, 0x02d8); - write_phy_reg(pi, 0xfb, 0x0301); - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, rfseq_rx2tx_events, - rfseq_rx2tx_dlys, - sizeof(rfseq_rx2tx_events) / - sizeof(rfseq_rx2tx_events[0])); - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, rfseq_tx2rx_events, - rfseq_tx2rx_dlys, - sizeof(rfseq_tx2rx_events) / - sizeof(rfseq_tx2rx_events[0])); - - wlc_phy_workarounds_nphy_gainctrl(pi); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - - if (read_phy_reg(pi, 0xa0) & NPHY_MLenable) - wlapi_bmac_mhf(pi->sh->physhim, MHF3, - MHF3_NPHY_MLADV_WAR, - MHF3_NPHY_MLADV_WAR, - BRCM_BAND_ALL); - - } else if (NREV_IS(pi->pubpi.phy_rev, 2)) { - write_phy_reg(pi, 0x1e3, 0x0); - write_phy_reg(pi, 0x1e4, 0x0); - } - - if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0x90, (0x1 << 7), 0); - - alpha0 = 293; - alpha1 = 435; - alpha2 = 261; - beta0 = 366; - beta1 = 205; - beta2 = 32; - write_phy_reg(pi, 0x145, alpha0); - write_phy_reg(pi, 0x146, alpha1); - write_phy_reg(pi, 0x147, alpha2); - write_phy_reg(pi, 0x148, beta0); - write_phy_reg(pi, 0x149, beta1); - write_phy_reg(pi, 0x14a, beta2); - - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - mod_phy_reg(pi, 0x142, (0xf << 12), 0); - - write_phy_reg(pi, 0x192, 0xb5); - write_phy_reg(pi, 0x193, 0xa4); - write_phy_reg(pi, 0x194, 0x0); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0x221, - NPHY_FORCESIG_DECODEGATEDCLKS, - NPHY_FORCESIG_DECODEGATEDCLKS); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_extpa_set_tx_digi_filts_nphy(struct brcms_phy *pi) -{ - int j, type = 2; - u16 addr_offset = 0x2c5; - - for (j = 0; j < NPHY_NUM_DIG_FILT_COEFFS; j++) - write_phy_reg(pi, addr_offset + j, - NPHY_IPA_REV4_txdigi_filtcoeffs[type][j]); -} - -static void wlc_phy_clip_det_nphy(struct brcms_phy *pi, u8 write, u16 *vals) -{ - - if (write == 0) { - vals[0] = read_phy_reg(pi, 0x2c); - vals[1] = read_phy_reg(pi, 0x42); - } else { - write_phy_reg(pi, 0x2c, vals[0]); - write_phy_reg(pi, 0x42, vals[1]); - } -} - -static void wlc_phy_ipa_internal_tssi_setup_nphy(struct brcms_phy *pi) -{ - u8 core; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x5); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX, 0xe); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIA, 0); - - if (!NREV_IS(pi->pubpi.phy_rev, 7)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIG, 0x1); - else - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIG, 0x31); - } else { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x9); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX, 0xc); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSIG, 0); - - if (pi->pubpi.radiorev != 5) { - if (!NREV_IS(pi->pubpi.phy_rev, 7)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x1); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x31); - } - } - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_VCM_HG, - 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_IDAC, - 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_VCM, - 0x3); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, - 0x0); - } - } else { - WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR31, - (CHSPEC_IS2G(pi->radio_chanspec)) ? 0x128 : - 0x80); - WRITE_RADIO_SYN(pi, RADIO_2056, RESERVED_ADDR30, 0x0); - WRITE_RADIO_SYN(pi, RADIO_2056, GPIO_MASTER1, 0x29); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_VCM_HG, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, IQCAL_IDAC, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_VCM, - 0x3); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TX_AMP_DET, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC1, - 0x8); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC2, - 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, TSSI_MISC3, - 0x0); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MASTER, 0x5); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIA, 0x0); - if (NREV_GE(pi->pubpi.phy_rev, 5)) - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIG, 0x31); - else - WRITE_RADIO_REG2(pi, RADIO_2056, TX, - core, TSSIG, 0x11); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MUX, 0xe); - } else { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MASTER, 0x9); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TSSIA, 0x31); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TSSIG, 0x0); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TX_SSI_MUX, 0xc); - } - } - } -} - -static void -wlc_phy_rfctrl_override_nphy(struct brcms_phy *pi, u16 field, u16 value, - u8 core_mask, u8 off) -{ - u8 core_num; - u16 addr = 0, mask = 0, en_addr = 0, val_addr = 0, en_mask = - 0, val_mask = 0; - u8 shift = 0, val_shift = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - - en_mask = field; - for (core_num = 0; core_num < 2; core_num++) { - - switch (field) { - case (0x1 << 1): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 0); - val_shift = 0; - break; - case (0x1 << 2): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 1); - val_shift = 1; - break; - case (0x1 << 3): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 2); - val_shift = 2; - break; - case (0x1 << 4): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 4); - val_shift = 4; - break; - case (0x1 << 5): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 5); - val_shift = 5; - break; - case (0x1 << 6): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 6); - val_shift = 6; - break; - case (0x1 << 7): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x1 << 7); - val_shift = 7; - break; - case (0x1 << 8): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x7 << 8); - val_shift = 8; - break; - case (0x1 << 11): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7a : 0x7d; - val_mask = (0x7 << 13); - val_shift = 13; - break; - - case (0x1 << 9): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : 0xfa; - val_mask = (0x7 << 0); - val_shift = 0; - break; - - case (0x1 << 10): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf8 : 0xfa; - val_mask = (0x7 << 4); - val_shift = 4; - break; - - case (0x1 << 12): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7b : 0x7e; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 13): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0x7c : 0x7f; - val_mask = (0xffff << 0); - val_shift = 0; - break; - case (0x1 << 14): - en_addr = (core_num == 0) ? 0xe7 : 0xec; - val_addr = (core_num == 0) ? 0xf9 : 0xfb; - val_mask = (0x3 << 6); - val_shift = 6; - break; - case (0x1 << 0): - en_addr = (core_num == 0) ? 0xe5 : 0xe6; - val_addr = (core_num == 0) ? 0xf9 : 0xfb; - val_mask = (0x1 << 15); - val_shift = 15; - break; - default: - addr = 0xffff; - break; - } - - if (off) { - and_phy_reg(pi, en_addr, ~en_mask); - and_phy_reg(pi, val_addr, ~val_mask); - } else { - - if ((core_mask == 0) - || (core_mask & (1 << core_num))) { - or_phy_reg(pi, en_addr, en_mask); - - if (addr != 0xffff) - mod_phy_reg(pi, val_addr, - val_mask, - (value << - val_shift)); - } - } - } - } else { - - if (off) { - and_phy_reg(pi, 0xec, ~field); - value = 0x0; - } else { - or_phy_reg(pi, 0xec, field); - } - - for (core_num = 0; core_num < 2; core_num++) { - - switch (field) { - case (0x1 << 1): - case (0x1 << 9): - case (0x1 << 12): - case (0x1 << 13): - case (0x1 << 14): - addr = 0x78; - - core_mask = 0x1; - break; - case (0x1 << 2): - case (0x1 << 3): - case (0x1 << 4): - case (0x1 << 5): - case (0x1 << 6): - case (0x1 << 7): - case (0x1 << 8): - addr = (core_num == 0) ? 0x7a : 0x7d; - break; - case (0x1 << 10): - addr = (core_num == 0) ? 0x7b : 0x7e; - break; - case (0x1 << 11): - addr = (core_num == 0) ? 0x7c : 0x7f; - break; - default: - addr = 0xffff; - } - - switch (field) { - case (0x1 << 1): - mask = (0x7 << 3); - shift = 3; - break; - case (0x1 << 9): - mask = (0x1 << 2); - shift = 2; - break; - case (0x1 << 12): - mask = (0x1 << 8); - shift = 8; - break; - case (0x1 << 13): - mask = (0x1 << 9); - shift = 9; - break; - case (0x1 << 14): - mask = (0xf << 12); - shift = 12; - break; - case (0x1 << 2): - mask = (0x1 << 0); - shift = 0; - break; - case (0x1 << 3): - mask = (0x1 << 1); - shift = 1; - break; - case (0x1 << 4): - mask = (0x1 << 2); - shift = 2; - break; - case (0x1 << 5): - mask = (0x3 << 4); - shift = 4; - break; - case (0x1 << 6): - mask = (0x3 << 6); - shift = 6; - break; - case (0x1 << 7): - mask = (0x1 << 8); - shift = 8; - break; - case (0x1 << 8): - mask = (0x1 << 9); - shift = 9; - break; - case (0x1 << 10): - mask = 0x1fff; - shift = 0x0; - break; - case (0x1 << 11): - mask = 0x1fff; - shift = 0x0; - break; - default: - mask = 0x0; - shift = 0x0; - break; - } - - if ((addr != 0xffff) && (core_mask & (1 << core_num))) - mod_phy_reg(pi, addr, mask, (value << shift)); - } - - or_phy_reg(pi, 0xec, (0x1 << 0)); - or_phy_reg(pi, 0x78, (0x1 << 0)); - udelay(1); - and_phy_reg(pi, 0xec, ~(0x1 << 0)); - } -} - -static void wlc_phy_txpwrctrl_idle_tssi_nphy(struct brcms_phy *pi) -{ - s32 rssi_buf[4]; - s32 int_val; - - if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) || PHY_MUTED(pi)) - - return; - - if (PHY_IPA(pi)) - wlc_phy_ipa_internal_tssi_setup_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 0); - - wlc_phy_stopplayback_nphy(pi); - - wlc_phy_tx_tone_nphy(pi, 4000, 0, 0, 0, false); - - udelay(20); - int_val = - wlc_phy_poll_rssi_nphy(pi, (u8) NPHY_RSSI_SEL_TSSI_2G, rssi_buf, - 1); - wlc_phy_stopplayback_nphy(pi); - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, 0); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 3, 1); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 24) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val >> 8) & 0xff); - } else { - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_2g = - (u8) ((int_val >> 24) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_2g = - (u8) ((int_val >> 8) & 0xff); - - pi->nphy_pwrctrl_info[PHY_CORE_0].idle_tssi_5g = - (u8) ((int_val >> 16) & 0xff); - pi->nphy_pwrctrl_info[PHY_CORE_1].idle_tssi_5g = - (u8) ((int_val) & 0xff); - } - -} - -static void wlc_phy_txpwr_limit_to_tbl_nphy(struct brcms_phy *pi) -{ - u8 idx, idx2, i, delta_ind; - - for (idx = TXP_FIRST_CCK; idx <= TXP_LAST_CCK; idx++) - pi->adj_pwr_tbl_nphy[idx] = pi->tx_power_offset[idx]; - - for (i = 0; i < 4; i++) { - idx2 = 0; - - delta_ind = 0; - - switch (i) { - case 0: - - if (CHSPEC_IS40(pi->radio_chanspec) - && NPHY_IS_SROM_REINTERPRET) { - idx = TXP_FIRST_MCS_40_SISO; - } else { - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_OFDM_40_SISO : TXP_FIRST_OFDM; - delta_ind = 1; - } - break; - - case 1: - - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_CDD : TXP_FIRST_MCS_20_CDD; - break; - - case 2: - - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_STBC : TXP_FIRST_MCS_20_STBC; - break; - - case 3: - - idx = (CHSPEC_IS40(pi->radio_chanspec)) ? - TXP_FIRST_MCS_40_SDM : TXP_FIRST_MCS_20_SDM; - break; - } - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - idx = idx + delta_ind; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx++]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - idx = idx + 1 - delta_ind; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - pi->adj_pwr_tbl_nphy[4 + 4 * (idx2++) + i] = - pi->tx_power_offset[idx]; - } -} - -static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) -{ - u32 idx; - s16 a1[2], b0[2], b1[2]; - s8 target_pwr_qtrdbm[2]; - s32 num, den, pwr_est; - u8 chan_freq_range; - u8 idle_tssi[2]; - u32 tbl_id, tbl_len, tbl_offset; - u32 regval[64]; - u8 core; - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); - udelay(1); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - or_phy_reg(pi, 0x122, (0x1 << 0)); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - and_phy_reg(pi, 0x1e7, (u16) (~(0x1 << 15))); - else - or_phy_reg(pi, 0x1e7, (0x1 << 15)); - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); - - if (pi->sh->sromrev < 4) { - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; - a1[0] = -424; - a1[1] = -424; - b0[0] = 5612; - b0[1] = 5612; - b1[1] = -1393; - b1[0] = -1393; - } else { - - chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_2G: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_2g; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_2g; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_b1; - break; - case WL_CHAN_FREQ_RANGE_5GL: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gl; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gl; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1; - break; - case WL_CHAN_FREQ_RANGE_5GM: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gm; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gm; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_b1; - break; - case WL_CHAN_FREQ_RANGE_5GH: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gh; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gh; - a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1; - a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1; - b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0; - b0[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0; - b1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1; - b1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1; - break; - default: - idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; - idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; - a1[0] = -424; - a1[1] = -424; - b0[0] = 5612; - b0[1] = 5612; - b1[1] = -1393; - b1[0] = -1393; - break; - } - } - - target_pwr_qtrdbm[0] = (s8) pi->tx_power_max; - target_pwr_qtrdbm[1] = (s8) pi->tx_power_max; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->srom_fem2g.tssipos) - or_phy_reg(pi, 0x1e9, (0x1 << 14)); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (core = 0; core <= 1; core++) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TX_SSI_MUX, - 0xe); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TX_SSI_MUX, - 0xc); - } - } - } else { - if (PHY_IPA(pi)) { - - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX0, - (CHSPEC_IS5G - (pi->radio_chanspec)) ? - 0xc : 0xe); - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX1, - (CHSPEC_IS5G - (pi->radio_chanspec)) ? - 0xc : 0xe); - } else { - - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX0, 0x11); - write_radio_reg(pi, RADIO_2056_TX_TX_SSI_MUX | - RADIO_2056_TX1, 0x11); - } - } - } - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); - udelay(1); - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_phy_reg(pi, 0x1e7, (0x7f << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - else - mod_phy_reg(pi, 0x1e7, (0x7f << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_phy_reg(pi, 0x222, (0xff << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 << 0)); - else if (NREV_GT(pi->pubpi.phy_rev, 1)) - mod_phy_reg(pi, 0x222, (0xff << 0), - (NPHY_TxPwrCtrlCmd_pwrIndex_init << 0)); - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); - - write_phy_reg(pi, 0x1e8, (0x3 << 8) | (240 << 0)); - - write_phy_reg(pi, 0x1e9, - (1 << 15) | (idle_tssi[0] << 0) | (idle_tssi[1] << 8)); - - write_phy_reg(pi, 0x1ea, - (target_pwr_qtrdbm[0] << 0) | - (target_pwr_qtrdbm[1] << 8)); - - tbl_len = 64; - tbl_offset = 0; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - - for (idx = 0; idx < tbl_len; idx++) { - num = 8 * - (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx); - den = 32768 + a1[tbl_id - 26] * idx; - pwr_est = max(((4 * num + den / 2) / den), -8); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - if (idx <= - (uint) (31 - idle_tssi[tbl_id - 26] + 1)) - pwr_est = - max(pwr_est, - target_pwr_qtrdbm - [tbl_id - 26] + 1); - } - regval[idx] = (u32) pwr_est; - } - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - wlc_phy_txpwr_limit_to_tbl_nphy(pi); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 84, 64, 8, - pi->adj_pwr_tbl_nphy); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 84, 64, 8, - pi->adj_pwr_tbl_nphy); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static u32 *wlc_phy_get_ipa_gaintbl_nphy(struct brcms_phy *pi) -{ - u32 *tx_pwrctrl_tbl = NULL; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev4n6; - else if (pi->pubpi.radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev3; - else if (pi->pubpi.radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev5; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_2g_2057rev7; - } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev6; - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_rev5; - } else { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa; - } - } else { - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g_2057; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_ipa_5g_2057rev7; - } else { - tx_pwrctrl_tbl = nphy_tpc_txgain_ipa_5g; - } - } - - return tx_pwrctrl_tbl; -} - -static void wlc_phy_restore_rssical_nphy(struct brcms_phy *pi) -{ - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->nphy_rssical_chanspec_2G == 0) - return; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[0]); - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[1]); - } else { - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[0]); - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_2G[1]); - } - - write_phy_reg(pi, 0x1a6, - pi->rssical_cache.rssical_phyregs_2G[0]); - write_phy_reg(pi, 0x1ac, - pi->rssical_cache.rssical_phyregs_2G[1]); - write_phy_reg(pi, 0x1b2, - pi->rssical_cache.rssical_phyregs_2G[2]); - write_phy_reg(pi, 0x1b8, - pi->rssical_cache.rssical_phyregs_2G[3]); - write_phy_reg(pi, 0x1a4, - pi->rssical_cache.rssical_phyregs_2G[4]); - write_phy_reg(pi, 0x1aa, - pi->rssical_cache.rssical_phyregs_2G[5]); - write_phy_reg(pi, 0x1b0, - pi->rssical_cache.rssical_phyregs_2G[6]); - write_phy_reg(pi, 0x1b6, - pi->rssical_cache.rssical_phyregs_2G[7]); - write_phy_reg(pi, 0x1a5, - pi->rssical_cache.rssical_phyregs_2G[8]); - write_phy_reg(pi, 0x1ab, - pi->rssical_cache.rssical_phyregs_2G[9]); - write_phy_reg(pi, 0x1b1, - pi->rssical_cache.rssical_phyregs_2G[10]); - write_phy_reg(pi, 0x1b7, - pi->rssical_cache.rssical_phyregs_2G[11]); - - } else { - if (pi->nphy_rssical_chanspec_5G == 0) - return; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[0]); - mod_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[1]); - } else { - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX0, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[0]); - mod_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | RADIO_2056_RX1, - RADIO_2056_VCM_MASK, - pi->rssical_cache. - rssical_radio_regs_5G[1]); - } - - write_phy_reg(pi, 0x1a6, - pi->rssical_cache.rssical_phyregs_5G[0]); - write_phy_reg(pi, 0x1ac, - pi->rssical_cache.rssical_phyregs_5G[1]); - write_phy_reg(pi, 0x1b2, - pi->rssical_cache.rssical_phyregs_5G[2]); - write_phy_reg(pi, 0x1b8, - pi->rssical_cache.rssical_phyregs_5G[3]); - write_phy_reg(pi, 0x1a4, - pi->rssical_cache.rssical_phyregs_5G[4]); - write_phy_reg(pi, 0x1aa, - pi->rssical_cache.rssical_phyregs_5G[5]); - write_phy_reg(pi, 0x1b0, - pi->rssical_cache.rssical_phyregs_5G[6]); - write_phy_reg(pi, 0x1b6, - pi->rssical_cache.rssical_phyregs_5G[7]); - write_phy_reg(pi, 0x1a5, - pi->rssical_cache.rssical_phyregs_5G[8]); - write_phy_reg(pi, 0x1ab, - pi->rssical_cache.rssical_phyregs_5G[9]); - write_phy_reg(pi, 0x1b1, - pi->rssical_cache.rssical_phyregs_5G[10]); - write_phy_reg(pi, 0x1b7, - pi->rssical_cache.rssical_phyregs_5G[11]); - } -} - -static void wlc_phy_internal_cal_txgain_nphy(struct brcms_phy *pi) -{ - u16 txcal_gain[2]; - - pi->nphy_txcal_pwr_idx[0] = pi->nphy_cal_orig_pwr_idx[0]; - pi->nphy_txcal_pwr_idx[1] = pi->nphy_cal_orig_pwr_idx[0]; - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - txcal_gain); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F40; - txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F40; - } else { - txcal_gain[0] = (txcal_gain[0] & 0xF000) | 0x0F60; - txcal_gain[1] = (txcal_gain[1] & 0xF000) | 0x0F60; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - txcal_gain); -} - -static void wlc_phy_precal_txgain_nphy(struct brcms_phy *pi) -{ - bool save_bbmult = false; - u8 txcal_index_2057_rev5n7 = 0; - u8 txcal_index_2057_rev3n4n6 = 10; - - if (pi->use_int_tx_iqlo_cal_nphy) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - - pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev3n4n6; - pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev3n4n6; - wlc_phy_txpwr_index_nphy( - pi, 3, - txcal_index_2057_rev3n4n6, - false); - } else { - - pi->nphy_txcal_pwr_idx[0] = - txcal_index_2057_rev5n7; - pi->nphy_txcal_pwr_idx[1] = - txcal_index_2057_rev5n7; - wlc_phy_txpwr_index_nphy( - pi, 3, - txcal_index_2057_rev5n7, - false); - } - save_bbmult = true; - - } else if (NREV_LT(pi->pubpi.phy_rev, 5)) { - wlc_phy_cal_txgainctrl_nphy(pi, 11, false); - if (pi->sh->hw_phytxchain != 3) { - pi->nphy_txcal_pwr_idx[1] = - pi->nphy_txcal_pwr_idx[0]; - wlc_phy_txpwr_index_nphy(pi, 3, - pi-> - nphy_txcal_pwr_idx[0], - true); - save_bbmult = true; - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - wlc_phy_cal_txgainctrl_nphy(pi, 12, - false); - } else { - pi->nphy_txcal_pwr_idx[0] = 80; - pi->nphy_txcal_pwr_idx[1] = 80; - wlc_phy_txpwr_index_nphy(pi, 3, 80, - false); - save_bbmult = true; - } - } else { - wlc_phy_internal_cal_txgain_nphy(pi); - save_bbmult = true; - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 6)) { - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_phy_cal_txgainctrl_nphy(pi, 12, - false); - else - wlc_phy_cal_txgainctrl_nphy(pi, 14, - false); - } else { - wlc_phy_internal_cal_txgain_nphy(pi); - save_bbmult = true; - } - } - - } else { - wlc_phy_cal_txgainctrl_nphy(pi, 10, false); - } - - if (save_bbmult) - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, - &pi->nphy_txcal_bbmult); -} - -static void -wlc_phy_rfctrlintc_override_nphy(struct brcms_phy *pi, u8 field, u16 value, - u8 core_code) -{ - u16 mask; - u16 val; - u8 core; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (core_code == RADIO_MIMO_CORESEL_CORE1 - && core == PHY_CORE_1) - continue; - else if (core_code == RADIO_MIMO_CORESEL_CORE2 - && core == PHY_CORE_0) - continue; - - if (NREV_LT(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 10); - val = 1 << 10; - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : - 0x92, mask, val); - } - - if (field == NPHY_RfctrlIntc_override_OFF) { - - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x91 : - 0x92, 0); - - wlc_phy_force_rfseq_nphy(pi, - NPHY_RFSEQ_RESET2RX); - } else if (field == NPHY_RfctrlIntc_override_TRSW) { - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 6) | (0x1 << 7); - - val = value << 6; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - or_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - (0x1 << 10)); - - and_phy_reg(pi, 0x2ff, (u16) - ~(0x3 << 14)); - or_phy_reg(pi, 0x2ff, (0x1 << 13)); - or_phy_reg(pi, 0x2ff, (0x1 << 0)); - } else { - - mask = (0x1 << 6) | - (0x1 << 7) | - (0x1 << 8) | (0x1 << 9); - val = value << 6; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - mask = (0x1 << 0); - val = 1 << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xe7 : 0xec, - mask, val); - - mask = (core == PHY_CORE_0) ? - (0x1 << 0) : (0x1 << 1); - val = 1 << ((core == PHY_CORE_0) ? - 0 : 1); - mod_phy_reg(pi, 0x78, mask, val); - - SPINWAIT(((read_phy_reg(pi, 0x78) & val) - != 0), 10000); - if (WARN(read_phy_reg(pi, 0x78) & val, - "HW error: override failed")) - return; - - mask = (0x1 << 0); - val = 0 << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xe7 : 0xec, - mask, val); - } - } else if (field == NPHY_RfctrlIntc_override_PA) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - mask = (0x1 << 4) | (0x1 << 5); - - if (CHSPEC_IS5G(pi->radio_chanspec)) - val = value << 5; - else - val = value << 4; - - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - - or_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - (0x1 << 12)); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 5); - val = value << 5; - } else { - mask = (0x1 << 4); - val = value << 4; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } else if (field == - NPHY_RfctrlIntc_override_EXT_LNA_PU) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - mask = (0x1 << 0); - val = value << 0; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 2); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } else { - - mask = (0x1 << 2); - val = value << 2; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 0); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } - - mask = (0x1 << 11); - val = 1 << 11; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 0); - val = value << 0; - } else { - mask = (0x1 << 2); - val = value << 2; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } else if (field == - NPHY_RfctrlIntc_override_EXT_LNA_GAIN) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - mask = (0x1 << 1); - val = value << 1; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 3); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } else { - - mask = (0x1 << 3); - val = value << 3; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, val); - - mask = (0x1 << 1); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 - : 0x92, mask, 0); - } - - mask = (0x1 << 11); - val = 1 << 11; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } else { - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - mask = (0x1 << 1); - val = value << 1; - } else { - mask = (0x1 << 3); - val = value << 3; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x91 : 0x92, - mask, val); - } - } - } - } -} - -void -wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower, - bool debug) -{ - int gainctrl_loopidx; - uint core; - u16 m0m1, curr_m0m1; - s32 delta_power; - s32 txpwrindex; - s32 qdBm_power[2]; - u16 orig_BBConfig; - u16 phy_saveregs[4]; - u32 freq_test; - u16 ampl_test = 250; - uint stepsize; - bool phyhang_avoid_state = false; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - stepsize = 2; - else - stepsize = 1; - - if (CHSPEC_IS40(pi->radio_chanspec)) - freq_test = 5000; - else - freq_test = 2500; - - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_cal_orig_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_cal_orig_pwr_idx[1], true); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - phyhang_avoid_state = pi->phyhang_avoid; - pi->phyhang_avoid = false; - - phy_saveregs[0] = read_phy_reg(pi, 0x91); - phy_saveregs[1] = read_phy_reg(pi, 0x92); - phy_saveregs[2] = read_phy_reg(pi, 0xe7); - phy_saveregs[3] = read_phy_reg(pi, 0xec); - wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 1, - RADIO_MIMO_CORESEL_CORE1 | - RADIO_MIMO_CORESEL_CORE2); - - if (!debug) { - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x2, RADIO_MIMO_CORESEL_CORE1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x8, RADIO_MIMO_CORESEL_CORE2); - } else { - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x1, RADIO_MIMO_CORESEL_CORE1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x7, RADIO_MIMO_CORESEL_CORE2); - } - - orig_BBConfig = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - txpwrindex = (s32) pi->nphy_cal_orig_pwr_idx[core]; - - for (gainctrl_loopidx = 0; gainctrl_loopidx < 2; - gainctrl_loopidx++) { - wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, - false); - - if (core == PHY_CORE_0) - curr_m0m1 = m0m1 & 0xff00; - else - curr_m0m1 = m0m1 & 0x00ff; - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &curr_m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &curr_m0m1); - - udelay(50); - - wlc_phy_est_tonepwr_nphy(pi, qdBm_power, - NPHY_CAL_TSSISAMPS); - - pi->nphy_bb_mult_save = 0; - wlc_phy_stopplayback_nphy(pi); - - delta_power = (dBm_targetpower * 4) - qdBm_power[core]; - - txpwrindex -= stepsize * delta_power; - if (txpwrindex < 0) - txpwrindex = 0; - else if (txpwrindex > 127) - txpwrindex = 127; - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(pi->pubpi.phy_rev, 4) && - (pi->srom_fem5g.extpagain == 3)) { - if (txpwrindex < 30) - txpwrindex = 30; - } - } else { - if (NREV_GE(pi->pubpi.phy_rev, 5) && - (pi->srom_fem2g.extpagain == 3)) { - if (txpwrindex < 50) - txpwrindex = 50; - } - } - - wlc_phy_txpwr_index_nphy(pi, (1 << core), - (u8) txpwrindex, true); - } - - pi->nphy_txcal_pwr_idx[core] = (u8) txpwrindex; - - if (debug) { - u16 radio_gain; - u16 dbg_m0m1; - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); - - wlc_phy_tx_tone_nphy(pi, freq_test, ampl_test, 0, 0, - false); - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &dbg_m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &dbg_m0m1); - - udelay(100); - - wlc_phy_est_tonepwr_nphy(pi, qdBm_power, - NPHY_CAL_TSSISAMPS); - - wlc_phy_table_read_nphy(pi, 7, 1, (0x110 + core), 16, - &radio_gain); - - mdelay(4000); - pi->nphy_bb_mult_save = 0; - wlc_phy_stopplayback_nphy(pi); - } - } - - wlc_phy_txpwr_index_nphy(pi, 1, pi->nphy_txcal_pwr_idx[0], true); - wlc_phy_txpwr_index_nphy(pi, 2, pi->nphy_txcal_pwr_idx[1], true); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &pi->nphy_txcal_bbmult); - - write_phy_reg(pi, 0x01, orig_BBConfig); - - write_phy_reg(pi, 0x91, phy_saveregs[0]); - write_phy_reg(pi, 0x92, phy_saveregs[1]); - write_phy_reg(pi, 0xe7, phy_saveregs[2]); - write_phy_reg(pi, 0xec, phy_saveregs[3]); - - pi->phyhang_avoid = phyhang_avoid_state; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_savecal_nphy(struct brcms_phy *pi) -{ - void *tbl_ptr; - int coreNum; - u16 *txcal_radio_regs = NULL; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, - &pi->calibration_cache. - rxcal_coeffs_2G); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); - - pi->calibration_cache.txcal_radio_regs_2G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_2G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_2G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); - } else { - pi->calibration_cache.txcal_radio_regs_2G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_2G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_2G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); - pi->calibration_cache.txcal_radio_regs_2G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); - } - - pi->nphy_iqcal_chanspec_2G = pi->radio_chanspec; - tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; - } else { - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, - &pi->calibration_cache. - rxcal_coeffs_5G); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1); - - pi->calibration_cache.txcal_radio_regs_5G[4] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[5] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0); - pi->calibration_cache.txcal_radio_regs_5G[6] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1); - pi->calibration_cache.txcal_radio_regs_5G[7] = - read_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1); - } else { - pi->calibration_cache.txcal_radio_regs_5G[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_5G[1] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL); - pi->calibration_cache.txcal_radio_regs_5G[2] = - read_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM); - pi->calibration_cache.txcal_radio_regs_5G[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM); - } - - pi->nphy_iqcal_chanspec_5G = pi->radio_chanspec; - tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; - } - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - - txcal_radio_regs[2 * coreNum] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_I); - txcal_radio_regs[2 * coreNum + 1] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_Q); - - txcal_radio_regs[2 * coreNum + 4] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_I); - txcal_radio_regs[2 * coreNum + 5] = - READ_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_Q); - } - } - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 8, 80, 16, tbl_ptr); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_tx_iq_war_nphy(struct brcms_phy *pi) -{ - struct nphy_iq_comp tx_comp; - - wlc_phy_table_read_nphy(pi, 15, 4, 0x50, 16, &tx_comp); - - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ, tx_comp.a0); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 2, tx_comp.b0); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 4, tx_comp.a1); - wlapi_bmac_write_shm(pi->sh->physhim, M_20IN40_IQ + 6, tx_comp.b1); -} - -static void wlc_phy_restorecal_nphy(struct brcms_phy *pi) -{ - u16 *loft_comp; - u16 txcal_coeffs_bphy[4]; - u16 *tbl_ptr; - int coreNum; - u16 *txcal_radio_regs = NULL; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->nphy_iqcal_chanspec_2G == 0) - return; - - tbl_ptr = pi->calibration_cache.txcal_coeffs_2G; - loft_comp = &pi->calibration_cache.txcal_coeffs_2G[5]; - } else { - if (pi->nphy_iqcal_chanspec_5G == 0) - return; - - tbl_ptr = pi->calibration_cache.txcal_coeffs_5G; - loft_comp = &pi->calibration_cache.txcal_coeffs_5G[5]; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, 16, tbl_ptr); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - txcal_coeffs_bphy[0] = tbl_ptr[0]; - txcal_coeffs_bphy[1] = tbl_ptr[1]; - txcal_coeffs_bphy[2] = tbl_ptr[2]; - txcal_coeffs_bphy[3] = tbl_ptr[3]; - } else { - txcal_coeffs_bphy[0] = 0; - txcal_coeffs_bphy[1] = 0; - txcal_coeffs_bphy[2] = 0; - txcal_coeffs_bphy[3] = 0; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 88, 16, - txcal_coeffs_bphy); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 85, 16, loft_comp); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 93, 16, loft_comp); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) - wlc_phy_tx_iq_war_nphy(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_2G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[0]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[1]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[2]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[3]); - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[4]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_2G[5]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[6]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_2G[7]); - } else { - write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_2G[0]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_2G[1]); - write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_2G[2]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_2G[3]); - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, - &pi->calibration_cache. - rxcal_coeffs_2G); - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - txcal_radio_regs = - pi->calibration_cache.txcal_radio_regs_5G; - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[0]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[1]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[2]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_FINE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[3]); - - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[4]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX0, - pi->calibration_cache. - txcal_radio_regs_5G[5]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_I | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[6]); - write_radio_reg(pi, - RADIO_2056_TX_LOFT_COARSE_Q | - RADIO_2056_TX1, - pi->calibration_cache. - txcal_radio_regs_5G[7]); - } else { - write_radio_reg(pi, RADIO_2055_CORE1_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_5G[0]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_VOS_CNCL, - pi->calibration_cache. - txcal_radio_regs_5G[1]); - write_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_5G[2]); - write_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, - pi->calibration_cache. - txcal_radio_regs_5G[3]); - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, - &pi->calibration_cache. - rxcal_coeffs_5G); - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_I, - txcal_radio_regs[2 * coreNum]); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_FINE_Q, - txcal_radio_regs[2 * coreNum + 1]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_I, - txcal_radio_regs[2 * coreNum + 4]); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, coreNum, - LOFT_COARSE_Q, - txcal_radio_regs[2 * coreNum + 5]); - } - } -} - -static void wlc_phy_txpwrctrl_coeff_setup_nphy(struct brcms_phy *pi) -{ - u32 idx; - u16 iqloCalbuf[7]; - u32 iqcomp, locomp, curr_locomp; - s8 locomp_i, locomp_q; - s8 curr_locomp_i, curr_locomp_q; - u32 tbl_id, tbl_len, tbl_offset; - u32 regval[128]; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - wlc_phy_table_read_nphy(pi, 15, 7, 80, 16, iqloCalbuf); - - tbl_len = 128; - tbl_offset = 320; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - iqcomp = - (tbl_id == - 26) ? (((u32) (iqloCalbuf[0] & 0x3ff)) << 10) | - (iqloCalbuf[1] & 0x3ff) - : (((u32) (iqloCalbuf[2] & 0x3ff)) << 10) | - (iqloCalbuf[3] & 0x3ff); - - for (idx = 0; idx < tbl_len; idx++) - regval[idx] = iqcomp; - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - tbl_offset = 448; - for (tbl_id = NPHY_TBL_ID_CORE1TXPWRCTL; - tbl_id <= NPHY_TBL_ID_CORE2TXPWRCTL; tbl_id++) { - - locomp = - (u32) ((tbl_id == 26) ? iqloCalbuf[5] : iqloCalbuf[6]); - locomp_i = (s8) ((locomp >> 8) & 0xff); - locomp_q = (s8) ((locomp) & 0xff); - for (idx = 0; idx < tbl_len; idx++) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - curr_locomp_i = locomp_i; - curr_locomp_q = locomp_q; - } else { - curr_locomp_i = (s8) ((locomp_i * - nphy_tpc_loscale[idx] + - 128) >> 8); - curr_locomp_q = - (s8) ((locomp_q * - nphy_tpc_loscale[idx] + - 128) >> 8); - } - curr_locomp = (u32) ((curr_locomp_i & 0xff) << 8); - curr_locomp |= (u32) (curr_locomp_q & 0xff); - regval[idx] = curr_locomp; - } - wlc_phy_table_write_nphy(pi, tbl_id, tbl_len, tbl_offset, 32, - regval); - } - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - - wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX1, 0xFFFF); - wlapi_bmac_write_shm(pi->sh->physhim, M_CURR_IDX2, 0xFFFF); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void wlc_phy_txlpfbw_nphy(struct brcms_phy *pi) -{ - u8 tx_lpf_bw = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 3; - else - tx_lpf_bw = 1; - - if (PHY_IPA(pi)) { - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 5; - else - tx_lpf_bw = 4; - } - - write_phy_reg(pi, 0xe8, - (tx_lpf_bw << 0) | - (tx_lpf_bw << 3) | - (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); - - if (PHY_IPA(pi)) { - - if (CHSPEC_IS40(pi->radio_chanspec)) - tx_lpf_bw = 4; - else - tx_lpf_bw = 1; - - write_phy_reg(pi, 0xe9, - (tx_lpf_bw << 0) | - (tx_lpf_bw << 3) | - (tx_lpf_bw << 6) | (tx_lpf_bw << 9)); - } - } -} - -static void -wlc_phy_adjust_rx_analpfbw_nphy(struct brcms_phy *pi, u16 reduction_factr) -{ - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LT(pi->pubpi.phy_rev, 7)) { - if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && - CHSPEC_IS40(pi->radio_chanspec)) { - if (!pi->nphy_anarxlpf_adjusted) { - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - RADIO_2056_RX0), - ((pi->nphy_rccal_value + - reduction_factr) | 0x80)); - - pi->nphy_anarxlpf_adjusted = true; - } - } else { - if (pi->nphy_anarxlpf_adjusted) { - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - RADIO_2056_RX0), - (pi->nphy_rccal_value | 0x80)); - - pi->nphy_anarxlpf_adjusted = false; - } - } - } -} - -static void -wlc_phy_adjust_min_noisevar_nphy(struct brcms_phy *pi, int ntones, - int *tone_id_buf, u32 *noise_var_buf) -{ - int i; - u32 offset; - int tone_id; - int tbllen = - CHSPEC_IS40(pi->radio_chanspec) ? - NPHY_NOISEVAR_TBLLEN40 : NPHY_NOISEVAR_TBLLEN20; - - if (pi->nphy_noisevars_adjusted) { - for (i = 0; i < pi->nphy_saved_noisevars.bufcount; i++) { - tone_id = pi->nphy_saved_noisevars.tone_id[i]; - offset = (tone_id >= 0) ? - ((tone_id * - 2) + 1) : (tbllen + (tone_id * 2) + 1); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - &pi->nphy_saved_noisevars.min_noise_vars[i]); - } - - pi->nphy_saved_noisevars.bufcount = 0; - pi->nphy_noisevars_adjusted = false; - } - - if ((noise_var_buf != NULL) && (tone_id_buf != NULL)) { - pi->nphy_saved_noisevars.bufcount = 0; - - for (i = 0; i < ntones; i++) { - tone_id = tone_id_buf[i]; - offset = (tone_id >= 0) ? - ((tone_id * 2) + 1) : - (tbllen + (tone_id * 2) + 1); - pi->nphy_saved_noisevars.tone_id[i] = tone_id; - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, - &pi->nphy_saved_noisevars. - min_noise_vars[i]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - offset, 32, &noise_var_buf[i]); - pi->nphy_saved_noisevars.bufcount++; - } - - pi->nphy_noisevars_adjusted = true; - } -} - -static void wlc_phy_adjust_crsminpwr_nphy(struct brcms_phy *pi, u8 minpwr) -{ - u16 regval; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if ((CHSPEC_CHANNEL(pi->radio_chanspec) == 11) && - CHSPEC_IS40(pi->radio_chanspec)) { - if (!pi->nphy_crsminpwr_adjusted) { - regval = read_phy_reg(pi, 0x27d); - pi->nphy_crsminpwr[0] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x27d, regval); - - regval = read_phy_reg(pi, 0x280); - pi->nphy_crsminpwr[1] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x280, regval); - - regval = read_phy_reg(pi, 0x283); - pi->nphy_crsminpwr[2] = regval & 0xff; - regval &= 0xff00; - regval |= (u16) minpwr; - write_phy_reg(pi, 0x283, regval); - - pi->nphy_crsminpwr_adjusted = true; - } - } else { - if (pi->nphy_crsminpwr_adjusted) { - regval = read_phy_reg(pi, 0x27d); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[0]; - write_phy_reg(pi, 0x27d, regval); - - regval = read_phy_reg(pi, 0x280); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[1]; - write_phy_reg(pi, 0x280, regval); - - regval = read_phy_reg(pi, 0x283); - regval &= 0xff00; - regval |= pi->nphy_crsminpwr[2]; - write_phy_reg(pi, 0x283, regval); - - pi->nphy_crsminpwr_adjusted = false; - } - } - } -} - -static void wlc_phy_spurwar_nphy(struct brcms_phy *pi) -{ - u16 cur_channel = 0; - int nphy_adj_tone_id_buf[] = { 57, 58 }; - u32 nphy_adj_noise_var_buf[] = { 0x3ff, 0x3ff }; - bool isAdjustNoiseVar = false; - uint numTonesAdjust = 0; - u32 tempval = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - cur_channel = CHSPEC_CHANNEL(pi->radio_chanspec); - - if (pi->nphy_gband_spurwar_en) { - - wlc_phy_adjust_rx_analpfbw_nphy( - pi, - NPHY_ANARXLPFBW_REDUCTIONFACT); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((cur_channel == 11) - && CHSPEC_IS40(pi->radio_chanspec)) - wlc_phy_adjust_min_noisevar_nphy( - pi, 2, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - else - wlc_phy_adjust_min_noisevar_nphy(pi, 0, - NULL, - NULL); - } - - wlc_phy_adjust_crsminpwr_nphy(pi, - NPHY_ADJUSTED_MINCRSPOWER); - } - - if ((pi->nphy_gband_spurwar2_en) - && CHSPEC_IS2G(pi->radio_chanspec)) { - - if (CHSPEC_IS40(pi->radio_chanspec)) { - switch (cur_channel) { - case 3: - nphy_adj_tone_id_buf[0] = 57; - nphy_adj_tone_id_buf[1] = 58; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 4: - nphy_adj_tone_id_buf[0] = 41; - nphy_adj_tone_id_buf[1] = 42; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 5: - nphy_adj_tone_id_buf[0] = 25; - nphy_adj_tone_id_buf[1] = 26; - nphy_adj_noise_var_buf[0] = 0x24f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 6: - nphy_adj_tone_id_buf[0] = 9; - nphy_adj_tone_id_buf[1] = 10; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 7: - nphy_adj_tone_id_buf[0] = 121; - nphy_adj_tone_id_buf[1] = 122; - nphy_adj_noise_var_buf[0] = 0x18f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 8: - nphy_adj_tone_id_buf[0] = 105; - nphy_adj_tone_id_buf[1] = 106; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x25f; - isAdjustNoiseVar = true; - break; - case 9: - nphy_adj_tone_id_buf[0] = 89; - nphy_adj_tone_id_buf[1] = 90; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - case 10: - nphy_adj_tone_id_buf[0] = 73; - nphy_adj_tone_id_buf[1] = 74; - nphy_adj_noise_var_buf[0] = 0x22f; - nphy_adj_noise_var_buf[1] = 0x24f; - isAdjustNoiseVar = true; - break; - default: - isAdjustNoiseVar = false; - break; - } - } - - if (isAdjustNoiseVar) { - numTonesAdjust = sizeof(nphy_adj_tone_id_buf) / - sizeof(nphy_adj_tone_id_buf[0]); - - wlc_phy_adjust_min_noisevar_nphy( - pi, - numTonesAdjust, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - - tempval = 0; - - } else { - wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, - NULL); - } - } - - if ((pi->nphy_aband_spurwar_en) && - (CHSPEC_IS5G(pi->radio_chanspec))) { - switch (cur_channel) { - case 54: - nphy_adj_tone_id_buf[0] = 32; - nphy_adj_noise_var_buf[0] = 0x25f; - break; - case 38: - case 102: - case 118: - nphy_adj_tone_id_buf[0] = 0; - nphy_adj_noise_var_buf[0] = 0x0; - break; - case 134: - nphy_adj_tone_id_buf[0] = 32; - nphy_adj_noise_var_buf[0] = 0x21f; - break; - case 151: - nphy_adj_tone_id_buf[0] = 16; - nphy_adj_noise_var_buf[0] = 0x23f; - break; - case 153: - case 161: - nphy_adj_tone_id_buf[0] = 48; - nphy_adj_noise_var_buf[0] = 0x23f; - break; - default: - nphy_adj_tone_id_buf[0] = 0; - nphy_adj_noise_var_buf[0] = 0x0; - break; - } - - if (nphy_adj_tone_id_buf[0] - && nphy_adj_noise_var_buf[0]) - wlc_phy_adjust_min_noisevar_nphy( - pi, 1, - nphy_adj_tone_id_buf, - nphy_adj_noise_var_buf); - else - wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL, - NULL); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); - } -} - -void wlc_phy_init_nphy(struct brcms_phy *pi) -{ - u16 val; - u16 clip1_ths[2]; - struct nphy_txgains target_gain; - u8 tx_pwr_ctrl_state; - bool do_nphy_cal = false; - uint core; - uint origidx, intr_val; - struct d11regs __iomem *regs; - u32 d11_clk_ctl_st; - bool do_rssi_cal = false; - - core = 0; - - if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) - pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - - if ((ISNPHY(pi)) && (NREV_GE(pi->pubpi.phy_rev, 5)) && - ((pi->sh->chippkg == BCM4717_PKG_ID) || - (pi->sh->chippkg == BCM4718_PKG_ID))) { - if ((pi->sh->boardflags & BFL_EXTLNA) && - (CHSPEC_IS2G(pi->radio_chanspec))) - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol), - 0x40, 0x40); - } - - if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && - CHSPEC_IS40(pi->radio_chanspec)) { - - regs = (struct d11regs __iomem *) - ai_switch_core(pi->sh->sih, - D11_CORE_ID, &origidx, - &intr_val); - d11_clk_ctl_st = R_REG(®s->clk_ctl_st); - AND_REG(®s->clk_ctl_st, - ~(CCS_FORCEHT | CCS_HTAREQ)); - - W_REG(®s->clk_ctl_st, d11_clk_ctl_st); - - ai_restore_core(pi->sh->sih, origidx, intr_val); - } - - pi->use_int_tx_iqlo_cal_nphy = - (PHY_IPA(pi) || - (NREV_GE(pi->pubpi.phy_rev, 7) || - (NREV_GE(pi->pubpi.phy_rev, 5) - && pi->sh->boardflags2 & BFL2_INTERNDET_TXIQCAL))); - - pi->internal_tx_iqlo_cal_tapoff_intpa_nphy = false; - - pi->nphy_deaf_count = 0; - - wlc_phy_tbl_init_nphy(pi); - - pi->nphy_crsminpwr_adjusted = false; - pi->nphy_noisevars_adjusted = false; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0xe7, 0); - write_phy_reg(pi, 0xec, 0); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_phy_reg(pi, 0x342, 0); - write_phy_reg(pi, 0x343, 0); - write_phy_reg(pi, 0x346, 0); - write_phy_reg(pi, 0x347, 0); - } - write_phy_reg(pi, 0xe5, 0); - write_phy_reg(pi, 0xe6, 0); - } else { - write_phy_reg(pi, 0xec, 0); - } - - write_phy_reg(pi, 0x91, 0); - write_phy_reg(pi, 0x92, 0); - if (NREV_LT(pi->pubpi.phy_rev, 6)) { - write_phy_reg(pi, 0x93, 0); - write_phy_reg(pi, 0x94, 0); - } - - and_phy_reg(pi, 0xa1, ~3); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0x8f, 0); - write_phy_reg(pi, 0xa5, 0); - } else { - write_phy_reg(pi, 0xa5, 0); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x3b); - else if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x40); - - write_phy_reg(pi, 0x203, 32); - write_phy_reg(pi, 0x201, 32); - - if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD) - write_phy_reg(pi, 0x20d, 160); - else - write_phy_reg(pi, 0x20d, 184); - - write_phy_reg(pi, 0x13a, 200); - - write_phy_reg(pi, 0x70, 80); - - write_phy_reg(pi, 0x1ff, 48); - - if (NREV_LT(pi->pubpi.phy_rev, 8)) - wlc_phy_update_mimoconfig_nphy(pi, pi->n_preamble_override); - - wlc_phy_stf_chain_upd_nphy(pi); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - write_phy_reg(pi, 0x180, 0xaa8); - write_phy_reg(pi, 0x181, 0x9a4); - } - - if (PHY_IPA(pi)) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), - (pi->nphy_papd_epsilon_offset[core]) << 7); - - } - - wlc_phy_ipa_set_tx_digi_filts_nphy(pi); - } else if (NREV_GE(pi->pubpi.phy_rev, 5)) { - wlc_phy_extpa_set_tx_digi_filts_nphy(pi); - } - - wlc_phy_workarounds_nphy(pi); - - wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); - - val = read_phy_reg(pi, 0x01); - write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); - write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); - wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); - - wlapi_bmac_macphyclk_set(pi->sh->physhim, ON); - - wlc_phy_pa_override_nphy(pi, OFF); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - wlc_phy_pa_override_nphy(pi, ON); - - wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_clip_det_nphy(pi, 0, clip1_ths); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - wlc_phy_bphy_init_nphy(pi); - - tx_pwr_ctrl_state = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - wlc_phy_txpwr_fixpower_nphy(pi); - - wlc_phy_txpwrctrl_idle_tssi_nphy(pi); - - wlc_phy_txpwrctrl_pwr_setup_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - u32 *tx_pwrctrl_tbl = NULL; - u16 idx; - s16 pga_gn = 0; - s16 pad_gn = 0; - s32 rfpwr_offset; - - if (PHY_IPA(pi)) { - tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(pi->pubpi.phy_rev, 3)) - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev3; - else if (NREV_IS(pi->pubpi.phy_rev, 4)) - tx_pwrctrl_tbl = - (pi->srom_fem5g.extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA : - nphy_tpc_5GHz_txgain_rev4; - else - tx_pwrctrl_tbl = - nphy_tpc_5GHz_txgain_rev5; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (pi->pubpi.radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev5; - else if (pi->pubpi.radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev3; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 5) && - (pi->srom_fem2g.extpagain == 3)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_HiPwrEPA; - else - tx_pwrctrl_tbl = - nphy_tpc_txgain_rev3; - } - } - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, - 192, 32, tx_pwrctrl_tbl); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, - 192, 32, tx_pwrctrl_tbl); - - pi->nphy_gmval = (u16) ((*tx_pwrctrl_tbl >> 16) & 0x7000); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - for (idx = 0; idx < 128; idx++) { - pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; - pad_gn = (tx_pwrctrl_tbl[idx] >> 19) & 0x1f; - rfpwr_offset = get_rf_pwr_offset(pi, pga_gn, - pad_gn); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - } - } else { - - for (idx = 0; idx < 128; idx++) { - pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf; - if (CHSPEC_IS2G(pi->radio_chanspec)) - rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_2g - [pga_gn]; - else - rfpwr_offset = (s16) - nphy_papd_pga_gain_delta_ipa_5g - [pga_gn]; - - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE1TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_CORE2TXPWRCTL, - 1, 576 + idx, 32, - &rfpwr_offset); - } - - } - } else { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 128, - 192, 32, nphy_tpc_txgain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 128, - 192, 32, nphy_tpc_txgain); - } - - if (pi->sh->phyrxchain != 0x3) - wlc_phy_rxcore_setstate_nphy((struct brcms_phy_pub *) pi, - pi->sh->phyrxchain); - - if (PHY_PERICAL_MPHASE_PENDING(pi)) - wlc_phy_cal_perical_mphase_restart(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - do_rssi_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_rssical_chanspec_2G == 0) : - (pi->nphy_rssical_chanspec_5G == 0); - - if (do_rssi_cal) - wlc_phy_rssi_cal_nphy(pi); - else - wlc_phy_restore_rssical_nphy(pi); - } else { - wlc_phy_rssi_cal_nphy(pi); - } - - if (!SCAN_RM_IN_PROGRESS(pi)) - do_nphy_cal = (CHSPEC_IS2G(pi->radio_chanspec)) ? - (pi->nphy_iqcal_chanspec_2G == 0) : - (pi->nphy_iqcal_chanspec_5G == 0); - - if (!pi->do_initcal) - do_nphy_cal = false; - - if (do_nphy_cal) { - - target_gain = wlc_phy_get_tx_gain_nphy(pi); - - if (pi->antsel_type == ANTSEL_2x3) - wlc_phy_antsel_init((struct brcms_phy_pub *) pi, - true); - - if (pi->nphy_perical != PHY_PERICAL_MPHASE) { - wlc_phy_rssi_cal_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->nphy_cal_orig_pwr_idx[0] = - pi->nphy_txpwrindex[PHY_CORE_0] - . - index_internal; - pi->nphy_cal_orig_pwr_idx[1] = - pi->nphy_txpwrindex[PHY_CORE_1] - . - index_internal; - - wlc_phy_precal_txgain_nphy(pi); - target_gain = - wlc_phy_get_tx_gain_nphy(pi); - } - - if (wlc_phy_cal_txiqlo_nphy - (pi, target_gain, true, - false) == 0) { - if (wlc_phy_cal_rxiq_nphy - (pi, target_gain, 2, - false) == 0) - wlc_phy_savecal_nphy(pi); - - } - } else if (pi->mphase_cal_phase_id == - MPHASE_CAL_STATE_IDLE) { - wlc_phy_cal_perical((struct brcms_phy_pub *) pi, - PHY_PERICAL_PHYINIT); - } - } else { - wlc_phy_restorecal_nphy(pi); - } - - wlc_phy_txpwrctrl_coeff_setup_nphy(pi); - - wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); - - wlc_phy_nphy_tkip_rifs_war(pi, pi->sh->_rifs_phy); - - if (NREV_GE(pi->pubpi.phy_rev, 3) && NREV_LE(pi->pubpi.phy_rev, 6)) - - write_phy_reg(pi, 0x70, 50); - - wlc_phy_txlpfbw_nphy(pi); - - wlc_phy_spurwar_nphy(pi); - -} - -static void wlc_phy_resetcca_nphy(struct brcms_phy *pi) -{ - u16 val; - - wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); - - val = read_phy_reg(pi, 0x01); - write_phy_reg(pi, 0x01, val | BBCFG_RESETCCA); - udelay(1); - write_phy_reg(pi, 0x01, val & (~BBCFG_RESETCCA)); - - wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); -} - -void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en) -{ - u16 rfctrlintc_override_val; - - if (!en) { - - pi->rfctrlIntc1_save = read_phy_reg(pi, 0x91); - pi->rfctrlIntc2_save = read_phy_reg(pi, 0x92); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - rfctrlintc_override_val = 0x1480; - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x600 : 0x480; - else - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; - - write_phy_reg(pi, 0x91, rfctrlintc_override_val); - write_phy_reg(pi, 0x92, rfctrlintc_override_val); - } else { - write_phy_reg(pi, 0x91, pi->rfctrlIntc1_save); - write_phy_reg(pi, 0x92, pi->rfctrlIntc2_save); - } - -} - -void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi) -{ - - u16 txrx_chain = - (NPHY_RfseqCoreActv_TxRxChain0 | NPHY_RfseqCoreActv_TxRxChain1); - bool CoreActv_override = false; - - if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN0) { - txrx_chain = NPHY_RfseqCoreActv_TxRxChain0; - CoreActv_override = true; - - if (NREV_LE(pi->pubpi.phy_rev, 2)) - and_phy_reg(pi, 0xa0, ~0x20); - } else if (pi->nphy_txrx_chain == BRCMS_N_TXRX_CHAIN1) { - txrx_chain = NPHY_RfseqCoreActv_TxRxChain1; - CoreActv_override = true; - - if (NREV_LE(pi->pubpi.phy_rev, 2)) - or_phy_reg(pi, 0xa0, 0x20); - } - - mod_phy_reg(pi, 0xa2, ((0xf << 0) | (0xf << 4)), txrx_chain); - - if (CoreActv_override) { - pi->nphy_perical = PHY_PERICAL_DISABLE; - or_phy_reg(pi, 0xa1, NPHY_RfseqMode_CoreActv_override); - } else { - pi->nphy_perical = PHY_PERICAL_MPHASE; - and_phy_reg(pi, 0xa1, ~NPHY_RfseqMode_CoreActv_override); - } -} - -void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) -{ - u16 regval; - u16 tbl_buf[16]; - uint i; - struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 tbl_opcode; - bool suspend; - - pi->sh->phyrxchain = rxcore_bitmask; - - if (!pi->sh->clk) - return; - - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!suspend) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - regval = read_phy_reg(pi, 0xa2); - regval &= ~(0xf << 4); - regval |= ((u16) (rxcore_bitmask & 0x3)) << 4; - write_phy_reg(pi, 0xa2, regval); - - if ((rxcore_bitmask & 0x3) != 0x3) { - - write_phy_reg(pi, 0x20e, 1); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->rx2tx_biasentry == -1) { - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, - ARRAY_SIZE(tbl_buf), 80, - 16, tbl_buf); - - for (i = 0; i < ARRAY_SIZE(tbl_buf); i++) { - if (tbl_buf[i] == - NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS) { - pi->rx2tx_biasentry = (u8) i; - tbl_opcode = - NPHY_REV3_RFSEQ_CMD_NOP; - wlc_phy_table_write_nphy( - pi, - NPHY_TBL_ID_RFSEQ, - 1, i, - 16, - &tbl_opcode); - break; - } else if (tbl_buf[i] == - NPHY_REV3_RFSEQ_CMD_END) - break; - } - } - } - } else { - - write_phy_reg(pi, 0x20e, 30); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (pi->rx2tx_biasentry != -1) { - tbl_opcode = NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 1, pi->rx2tx_biasentry, - 16, &tbl_opcode); - pi->rx2tx_biasentry = -1; - } - } - } - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - if (!suspend) - wlapi_enable_mac(pi->sh->physhim); -} - -u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih) -{ - u16 regval, rxen_bits; - struct brcms_phy *pi = (struct brcms_phy *) pih; - - regval = read_phy_reg(pi, 0xa2); - rxen_bits = (regval >> 4) & 0xf; - - return (u8) rxen_bits; -} - -bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pi) -{ - return PHY_IPA(pi); -} - -void wlc_phy_cal_init_nphy(struct brcms_phy *pi) -{ -} - -static void wlc_phy_radio_preinit_205x(struct brcms_phy *pi) -{ - - and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); - and_phy_reg(pi, 0x78, RFCC_OE_POR_FORCE); - - or_phy_reg(pi, 0x78, ~RFCC_OE_POR_FORCE); - or_phy_reg(pi, 0x78, RFCC_CHIP0_PU); - -} - -static void wlc_phy_radio_init_2057(struct brcms_phy *pi) -{ - struct radio_20xx_regs *regs_2057_ptr = NULL; - - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - regs_2057_ptr = regs_2057_rev4; - } else if (NREV_IS(pi->pubpi.phy_rev, 8) - || NREV_IS(pi->pubpi.phy_rev, 9)) { - switch (pi->pubpi.radiorev) { - case 5: - - if (pi->pubpi.radiover == 0x0) - regs_2057_ptr = regs_2057_rev5; - else if (pi->pubpi.radiover == 0x1) - regs_2057_ptr = regs_2057_rev5v1; - else - break; - - case 7: - - regs_2057_ptr = regs_2057_rev7; - break; - - case 8: - - regs_2057_ptr = regs_2057_rev8; - break; - - default: - break; - } - } - - wlc_phy_init_radio_regs_allbands(pi, regs_2057_ptr); -} - -static u16 wlc_phy_radio205x_rcal(struct brcms_phy *pi) -{ - u16 rcal_reg = 0; - int i; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (pi->pubpi.radiorev == 5) { - - and_phy_reg(pi, 0x342, ~(0x1 << 1)); - - udelay(10); - - mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x1); - mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, - 0x1); - } - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x1); - - udelay(10); - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x3, 0x3); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS); - if (rcal_reg & 0x1) - break; - - udelay(100); - } - - if (WARN(i == MAX_205x_RCAL_WAITLOOPS, - "HW error: radio calib2")) - return 0; - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x2, 0x0); - - rcal_reg = read_radio_reg(pi, RADIO_2057_RCAL_STATUS) & 0x3e; - - mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x1, 0x0); - if (pi->pubpi.radiorev == 5) { - - mod_radio_reg(pi, RADIO_2057_IQTEST_SEL_PU, 0x1, 0x0); - mod_radio_reg(pi, RADIO_2057v7_IQTEST_SEL_PU2, 0x2, - 0x0); - } - - if ((pi->pubpi.radiorev <= 4) || (pi->pubpi.radiorev == 6)) { - - mod_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, 0x3c, - rcal_reg); - mod_radio_reg(pi, RADIO_2057_BANDGAP_RCAL_TRIM, 0xf0, - rcal_reg << 2); - } - - } else if (NREV_IS(pi->pubpi.phy_rev, 3)) { - u16 savereg; - - savereg = - read_radio_reg( - pi, - RADIO_2056_SYN_PLL_MAST2 | - RADIO_2056_SYN); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, - savereg | 0x7); - udelay(10); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x1); - udelay(10); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x9); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rcal_reg = read_radio_reg( - pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); - if (rcal_reg & 0x80) - break; - - udelay(100); - } - - if (WARN(i == MAX_205x_RCAL_WAITLOOPS, - "HW error: radio calib3")) - return 0; - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x1); - - rcal_reg = - read_radio_reg(pi, - RADIO_2056_SYN_RCAL_CODE_OUT | - RADIO_2056_SYN); - - write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN, - 0x0); - - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2 | RADIO_2056_SYN, - savereg); - - return rcal_reg & 0x1f; - } - return rcal_reg & 0x3e; -} - -static u16 wlc_phy_radio2057_rccal(struct brcms_phy *pi) -{ - u16 rccal_valid; - int i; - bool chip43226_6362A0; - - chip43226_6362A0 = ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x61); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xc0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x61); - - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xe9); - } - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x69); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x69); - - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xd5); - } - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - rccal_valid = 0; - if (chip43226_6362A0) { - write_radio_reg(pi, RADIO_2057_RCCAL_MASTER, 0x73); - - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x28); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0xb0); - } else { - write_radio_reg(pi, RADIO_2057v7_RCCAL_MASTER, 0x73); - write_radio_reg(pi, RADIO_2057_RCCAL_X1, 0x6e); - write_radio_reg(pi, RADIO_2057_RCCAL_TRC0, 0x99); - } - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x55); - - for (i = 0; i < MAX_205x_RCAL_WAITLOOPS; i++) { - rccal_valid = read_radio_reg(pi, RADIO_2057_RCCAL_DONE_OSCCAP); - if (rccal_valid & 0x2) - break; - - udelay(500); - } - - if (WARN(!(rccal_valid & 0x2), "HW error: radio calib4")) - return 0; - - write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15); - - return rccal_valid; -} - -static void wlc_phy_radio_postinit_2057(struct brcms_phy *pi) -{ - - mod_radio_reg(pi, RADIO_2057_XTALPUOVR_PINCTRL, 0x1, 0x1); - - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x78); - mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x80); - mdelay(2); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x78, 0x0); - mod_radio_reg(pi, RADIO_2057_XTAL_CONFIG2, 0x80, 0x0); - - if (pi->phy_init_por) { - wlc_phy_radio205x_rcal(pi); - wlc_phy_radio2057_rccal(pi); - } - - mod_radio_reg(pi, RADIO_2057_RFPLL_MASTER, 0x8, 0x0); -} - -static void wlc_phy_radio_init_2056(struct brcms_phy *pi) -{ - const struct radio_regs *regs_SYN_2056_ptr = NULL; - const struct radio_regs *regs_TX_2056_ptr = NULL; - const struct radio_regs *regs_RX_2056_ptr = NULL; - - if (NREV_IS(pi->pubpi.phy_rev, 3)) { - regs_SYN_2056_ptr = regs_SYN_2056; - regs_TX_2056_ptr = regs_TX_2056; - regs_RX_2056_ptr = regs_RX_2056; - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - regs_SYN_2056_ptr = regs_SYN_2056_A1; - regs_TX_2056_ptr = regs_TX_2056_A1; - regs_RX_2056_ptr = regs_RX_2056_A1; - } else { - switch (pi->pubpi.radiorev) { - case 5: - regs_SYN_2056_ptr = regs_SYN_2056_rev5; - regs_TX_2056_ptr = regs_TX_2056_rev5; - regs_RX_2056_ptr = regs_RX_2056_rev5; - break; - - case 6: - regs_SYN_2056_ptr = regs_SYN_2056_rev6; - regs_TX_2056_ptr = regs_TX_2056_rev6; - regs_RX_2056_ptr = regs_RX_2056_rev6; - break; - - case 7: - case 9: - regs_SYN_2056_ptr = regs_SYN_2056_rev7; - regs_TX_2056_ptr = regs_TX_2056_rev7; - regs_RX_2056_ptr = regs_RX_2056_rev7; - break; - - case 8: - regs_SYN_2056_ptr = regs_SYN_2056_rev8; - regs_TX_2056_ptr = regs_TX_2056_rev8; - regs_RX_2056_ptr = regs_RX_2056_rev8; - break; - - case 11: - regs_SYN_2056_ptr = regs_SYN_2056_rev11; - regs_TX_2056_ptr = regs_TX_2056_rev11; - regs_RX_2056_ptr = regs_RX_2056_rev11; - break; - - default: - break; - } - } - - wlc_phy_init_radio_regs(pi, regs_SYN_2056_ptr, (u16) RADIO_2056_SYN); - - wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX0); - - wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX1); - - wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX0); - - wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX1); -} - -static void wlc_phy_radio_postinit_2056(struct brcms_phy *pi) -{ - mod_radio_reg(pi, RADIO_2056_SYN_COM_CTRL, 0xb, 0xb); - - mod_radio_reg(pi, RADIO_2056_SYN_COM_PU, 0x2, 0x2); - mod_radio_reg(pi, RADIO_2056_SYN_COM_RESET, 0x2, 0x2); - udelay(1000); - mod_radio_reg(pi, RADIO_2056_SYN_COM_RESET, 0x2, 0x0); - - if ((pi->sh->boardflags2 & BFL2_LEGACY) - || (pi->sh->boardflags2 & BFL2_XTALBUFOUTEN)) - mod_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2, 0xf4, 0x0); - else - mod_radio_reg(pi, RADIO_2056_SYN_PLL_MAST2, 0xfc, 0x0); - - mod_radio_reg(pi, RADIO_2056_SYN_RCCAL_CTRL0, 0x1, 0x0); - - if (pi->phy_init_por) - wlc_phy_radio205x_rcal(pi); -} - -static void wlc_phy_radio_preinit_2055(struct brcms_phy *pi) -{ - - and_phy_reg(pi, 0x78, ~RFCC_POR_FORCE); - or_phy_reg(pi, 0x78, RFCC_CHIP0_PU | RFCC_OE_POR_FORCE); - - or_phy_reg(pi, 0x78, RFCC_POR_FORCE); -} - -static void wlc_phy_radio_init_2055(struct brcms_phy *pi) -{ - wlc_phy_init_radio_regs(pi, regs_2055, RADIO_DEFAULT_CORE); -} - -static void wlc_phy_radio_postinit_2055(struct brcms_phy *pi) -{ - - and_radio_reg(pi, RADIO_2055_MASTER_CNTRL1, - ~(RADIO_2055_JTAGCTRL_MASK | RADIO_2055_JTAGSYNC_MASK)); - - if (((pi->sh->sromrev >= 4) - && !(pi->sh->boardflags2 & BFL2_RXBB_INT_REG_DIS)) - || ((pi->sh->sromrev < 4))) { - and_radio_reg(pi, RADIO_2055_CORE1_RXBB_REGULATOR, 0x7F); - and_radio_reg(pi, RADIO_2055_CORE2_RXBB_REGULATOR, 0x7F); - } - - mod_radio_reg(pi, RADIO_2055_RRCCAL_N_OPT_SEL, 0x3F, 0x2C); - write_radio_reg(pi, RADIO_2055_CAL_MISC, 0x3C); - - and_radio_reg(pi, RADIO_2055_CAL_MISC, - ~(RADIO_2055_RRCAL_START | RADIO_2055_RRCAL_RST_N)); - - or_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, RADIO_2055_CAL_LPO_ENABLE); - - or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_RST_N); - - udelay(1000); - - or_radio_reg(pi, RADIO_2055_CAL_MISC, RADIO_2055_RRCAL_START); - - SPINWAIT(((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & - RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000); - - if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) & - RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE, - "HW error: radio calibration1\n")) - return; - - and_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL, - ~(RADIO_2055_CAL_LPO_ENABLE)); - - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, pi->radio_chanspec); - - write_radio_reg(pi, RADIO_2055_CORE1_RXBB_LPF, 9); - write_radio_reg(pi, RADIO_2055_CORE2_RXBB_LPF, 9); - - write_radio_reg(pi, RADIO_2055_CORE1_RXBB_MIDAC_HIPAS, 0x83); - write_radio_reg(pi, RADIO_2055_CORE2_RXBB_MIDAC_HIPAS, 0x83); - - mod_radio_reg(pi, RADIO_2055_CORE1_LNA_GAINBST, - RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); - mod_radio_reg(pi, RADIO_2055_CORE2_LNA_GAINBST, - RADIO_2055_GAINBST_VAL_MASK, RADIO_2055_GAINBST_CODE); - if (pi->nphy_gain_boost) { - and_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, - ~(RADIO_2055_GAINBST_DISABLE)); - and_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, - ~(RADIO_2055_GAINBST_DISABLE)); - } else { - or_radio_reg(pi, RADIO_2055_CORE1_RXRF_SPC1, - RADIO_2055_GAINBST_DISABLE); - or_radio_reg(pi, RADIO_2055_CORE2_RXRF_SPC1, - RADIO_2055_GAINBST_DISABLE); - } - - udelay(2); -} - -void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on) -{ - if (on) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (!pi->radio_is_on) { - wlc_phy_radio_preinit_205x(pi); - wlc_phy_radio_init_2057(pi); - wlc_phy_radio_postinit_2057(pi); - } - - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, - pi->radio_chanspec); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_radio_preinit_205x(pi); - wlc_phy_radio_init_2056(pi); - wlc_phy_radio_postinit_2056(pi); - - wlc_phy_chanspec_set((struct brcms_phy_pub *) pi, - pi->radio_chanspec); - } else { - wlc_phy_radio_preinit_2055(pi); - wlc_phy_radio_init_2055(pi); - wlc_phy_radio_postinit_2055(pi); - } - - pi->radio_is_on = true; - - } else { - - if (NREV_GE(pi->pubpi.phy_rev, 3) - && NREV_LT(pi->pubpi.phy_rev, 7)) { - and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); - mod_radio_reg(pi, RADIO_2056_SYN_COM_PU, 0x2, 0x0); - - write_radio_reg(pi, - RADIO_2056_TX_PADA_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PADG_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAA_BOOST_TUNE | - RADIO_2056_TX0, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAG_BOOST_TUNE | - RADIO_2056_TX0, 0); - mod_radio_reg(pi, - RADIO_2056_TX_MIXA_BOOST_TUNE | - RADIO_2056_TX0, 0xf0, 0); - write_radio_reg(pi, - RADIO_2056_TX_MIXG_BOOST_TUNE | - RADIO_2056_TX0, 0); - - write_radio_reg(pi, - RADIO_2056_TX_PADA_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PADG_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAA_BOOST_TUNE | - RADIO_2056_TX1, 0); - write_radio_reg(pi, - RADIO_2056_TX_PGAG_BOOST_TUNE | - RADIO_2056_TX1, 0); - mod_radio_reg(pi, - RADIO_2056_TX_MIXA_BOOST_TUNE | - RADIO_2056_TX1, 0xf0, 0); - write_radio_reg(pi, - RADIO_2056_TX_MIXG_BOOST_TUNE | - RADIO_2056_TX1, 0); - - pi->radio_is_on = false; - } - - if (NREV_GE(pi->pubpi.phy_rev, 8)) { - and_phy_reg(pi, 0x78, ~RFCC_CHIP0_PU); - pi->radio_is_on = false; - } - - } -} - -static bool -wlc_phy_chan2freq_nphy(struct brcms_phy *pi, uint channel, int *f, - const struct chan_info_nphy_radio2057 **t0, - const struct chan_info_nphy_radio205x **t1, - const struct chan_info_nphy_radio2057_rev5 **t2, - const struct chan_info_nphy_2055 **t3) -{ - uint i; - const struct chan_info_nphy_radio2057 *chan_info_tbl_p_0 = NULL; - const struct chan_info_nphy_radio205x *chan_info_tbl_p_1 = NULL; - const struct chan_info_nphy_radio2057_rev5 *chan_info_tbl_p_2 = NULL; - u32 tbl_len = 0; - - int freq = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - - chan_info_tbl_p_0 = chan_info_nphyrev7_2057_rev4; - tbl_len = ARRAY_SIZE(chan_info_nphyrev7_2057_rev4); - - } else if (NREV_IS(pi->pubpi.phy_rev, 8) - || NREV_IS(pi->pubpi.phy_rev, 9)) { - switch (pi->pubpi.radiorev) { - - case 5: - - if (pi->pubpi.radiover == 0x0) { - - chan_info_tbl_p_2 = - chan_info_nphyrev8_2057_rev5; - tbl_len = ARRAY_SIZE( - chan_info_nphyrev8_2057_rev5); - - } else if (pi->pubpi.radiover == 0x1) { - - chan_info_tbl_p_2 = - chan_info_nphyrev9_2057_rev5v1; - tbl_len = ARRAY_SIZE( - chan_info_nphyrev9_2057_rev5v1); - - } - break; - - case 7: - chan_info_tbl_p_0 = - chan_info_nphyrev8_2057_rev7; - tbl_len = ARRAY_SIZE( - chan_info_nphyrev8_2057_rev7); - break; - - case 8: - chan_info_tbl_p_0 = - chan_info_nphyrev8_2057_rev8; - tbl_len = ARRAY_SIZE( - chan_info_nphyrev8_2057_rev8); - break; - - default: - break; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 16)) { - - chan_info_tbl_p_0 = chan_info_nphyrev8_2057_rev8; - tbl_len = ARRAY_SIZE(chan_info_nphyrev8_2057_rev8); - } else { - goto fail; - } - - for (i = 0; i < tbl_len; i++) { - if (pi->pubpi.radiorev == 5) { - - if (chan_info_tbl_p_2[i].chan == channel) - break; - } else { - - if (chan_info_tbl_p_0[i].chan == channel) - break; - } - } - - if (i >= tbl_len) - goto fail; - - if (pi->pubpi.radiorev == 5) { - *t2 = &chan_info_tbl_p_2[i]; - freq = chan_info_tbl_p_2[i].freq; - } else { - *t0 = &chan_info_tbl_p_0[i]; - freq = chan_info_tbl_p_0[i].freq; - } - - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (NREV_IS(pi->pubpi.phy_rev, 3)) { - chan_info_tbl_p_1 = chan_info_nphyrev3_2056; - tbl_len = ARRAY_SIZE(chan_info_nphyrev3_2056); - } else if (NREV_IS(pi->pubpi.phy_rev, 4)) { - chan_info_tbl_p_1 = chan_info_nphyrev4_2056_A1; - tbl_len = ARRAY_SIZE(chan_info_nphyrev4_2056_A1); - } else if (NREV_IS(pi->pubpi.phy_rev, 5) - || NREV_IS(pi->pubpi.phy_rev, 6)) { - switch (pi->pubpi.radiorev) { - case 5: - chan_info_tbl_p_1 = chan_info_nphyrev5_2056v5; - tbl_len = ARRAY_SIZE(chan_info_nphyrev5_2056v5); - break; - case 6: - chan_info_tbl_p_1 = chan_info_nphyrev6_2056v6; - tbl_len = ARRAY_SIZE(chan_info_nphyrev6_2056v6); - break; - case 7: - case 9: - chan_info_tbl_p_1 = chan_info_nphyrev5n6_2056v7; - tbl_len = - ARRAY_SIZE(chan_info_nphyrev5n6_2056v7); - break; - case 8: - chan_info_tbl_p_1 = chan_info_nphyrev6_2056v8; - tbl_len = ARRAY_SIZE(chan_info_nphyrev6_2056v8); - break; - case 11: - chan_info_tbl_p_1 = chan_info_nphyrev6_2056v11; - tbl_len = ARRAY_SIZE( - chan_info_nphyrev6_2056v11); - break; - default: - break; - } - } - - for (i = 0; i < tbl_len; i++) { - if (chan_info_tbl_p_1[i].chan == channel) - break; - } - - if (i >= tbl_len) - goto fail; - - *t1 = &chan_info_tbl_p_1[i]; - freq = chan_info_tbl_p_1[i].freq; - - } else { - for (i = 0; i < ARRAY_SIZE(chan_info_nphy_2055); i++) - if (chan_info_nphy_2055[i].chan == channel) - break; - - if (i >= ARRAY_SIZE(chan_info_nphy_2055)) - goto fail; - - *t3 = &chan_info_nphy_2055[i]; - freq = chan_info_nphy_2055[i].freq; - } - - *f = freq; - return true; - -fail: - *f = WL_CHAN_FREQ_RANGE_2G; - return false; -} - -u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint channel) -{ - int freq; - const struct chan_info_nphy_radio2057 *t0 = NULL; - const struct chan_info_nphy_radio205x *t1 = NULL; - const struct chan_info_nphy_radio2057_rev5 *t2 = NULL; - const struct chan_info_nphy_2055 *t3 = NULL; - - if (channel == 0) - channel = CHSPEC_CHANNEL(pi->radio_chanspec); - - wlc_phy_chan2freq_nphy(pi, channel, &freq, &t0, &t1, &t2, &t3); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - return WL_CHAN_FREQ_RANGE_2G; - - if ((freq >= BASE_LOW_5G_CHAN) && (freq < BASE_MID_5G_CHAN)) - return WL_CHAN_FREQ_RANGE_5GL; - else if ((freq >= BASE_MID_5G_CHAN) && (freq < BASE_HIGH_5G_CHAN)) - return WL_CHAN_FREQ_RANGE_5GM; - else - return WL_CHAN_FREQ_RANGE_5GH; -} - -static void -wlc_phy_chanspec_radio2055_setup(struct brcms_phy *pi, - const struct chan_info_nphy_2055 *ci) -{ - - write_radio_reg(pi, RADIO_2055_PLL_REF, ci->RF_pll_ref); - write_radio_reg(pi, RADIO_2055_RF_PLL_MOD0, ci->RF_rf_pll_mod0); - write_radio_reg(pi, RADIO_2055_RF_PLL_MOD1, ci->RF_rf_pll_mod1); - write_radio_reg(pi, RADIO_2055_VCO_CAP_TAIL, ci->RF_vco_cap_tail); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_VCO_CAL1, ci->RF_vco_cal1); - write_radio_reg(pi, RADIO_2055_VCO_CAL2, ci->RF_vco_cal2); - write_radio_reg(pi, RADIO_2055_PLL_LF_C1, ci->RF_pll_lf_c1); - write_radio_reg(pi, RADIO_2055_PLL_LF_R1, ci->RF_pll_lf_r1); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_PLL_LF_C2, ci->RF_pll_lf_c2); - write_radio_reg(pi, RADIO_2055_LGBUF_CEN_BUF, ci->RF_lgbuf_cen_buf); - write_radio_reg(pi, RADIO_2055_LGEN_TUNE1, ci->RF_lgen_tune1); - write_radio_reg(pi, RADIO_2055_LGEN_TUNE2, ci->RF_lgen_tune2); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_CORE1_LGBUF_A_TUNE, - ci->RF_core1_lgbuf_a_tune); - write_radio_reg(pi, RADIO_2055_CORE1_LGBUF_G_TUNE, - ci->RF_core1_lgbuf_g_tune); - write_radio_reg(pi, RADIO_2055_CORE1_RXRF_REG1, ci->RF_core1_rxrf_reg1); - write_radio_reg(pi, RADIO_2055_CORE1_TX_PGA_PAD_TN, - ci->RF_core1_tx_pga_pad_tn); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_CORE1_TX_MX_BGTRIM, - ci->RF_core1_tx_mx_bgtrim); - write_radio_reg(pi, RADIO_2055_CORE2_LGBUF_A_TUNE, - ci->RF_core2_lgbuf_a_tune); - write_radio_reg(pi, RADIO_2055_CORE2_LGBUF_G_TUNE, - ci->RF_core2_lgbuf_g_tune); - write_radio_reg(pi, RADIO_2055_CORE2_RXRF_REG1, ci->RF_core2_rxrf_reg1); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_CORE2_TX_PGA_PAD_TN, - ci->RF_core2_tx_pga_pad_tn); - write_radio_reg(pi, RADIO_2055_CORE2_TX_MX_BGTRIM, - ci->RF_core2_tx_mx_bgtrim); - - udelay(50); - - write_radio_reg(pi, RADIO_2055_VCO_CAL10, 0x05); - write_radio_reg(pi, RADIO_2055_VCO_CAL10, 0x45); - - BRCMS_PHY_WAR_PR51571(pi); - - write_radio_reg(pi, RADIO_2055_VCO_CAL10, 0x65); - - udelay(300); -} - -static void -wlc_phy_chanspec_radio2056_setup(struct brcms_phy *pi, - const struct chan_info_nphy_radio205x *ci) -{ - const struct radio_regs *regs_SYN_2056_ptr = NULL; - - write_radio_reg(pi, - RADIO_2056_SYN_PLL_VCOCAL1 | RADIO_2056_SYN, - ci->RF_SYN_pll_vcocal1); - write_radio_reg(pi, RADIO_2056_SYN_PLL_VCOCAL2 | RADIO_2056_SYN, - ci->RF_SYN_pll_vcocal2); - write_radio_reg(pi, RADIO_2056_SYN_PLL_REFDIV | RADIO_2056_SYN, - ci->RF_SYN_pll_refdiv); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MMD2 | RADIO_2056_SYN, - ci->RF_SYN_pll_mmd2); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MMD1 | RADIO_2056_SYN, - ci->RF_SYN_pll_mmd1); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER1 | RADIO_2056_SYN, - ci->RF_SYN_pll_loopfilter1); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER2 | RADIO_2056_SYN, - ci->RF_SYN_pll_loopfilter2); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER3 | RADIO_2056_SYN, - ci->RF_SYN_pll_loopfilter3); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER4 | RADIO_2056_SYN, - ci->RF_SYN_pll_loopfilter4); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER5 | RADIO_2056_SYN, - ci->RF_SYN_pll_loopfilter5); - write_radio_reg(pi, RADIO_2056_SYN_RESERVED_ADDR27 | RADIO_2056_SYN, - ci->RF_SYN_reserved_addr27); - write_radio_reg(pi, RADIO_2056_SYN_RESERVED_ADDR28 | RADIO_2056_SYN, - ci->RF_SYN_reserved_addr28); - write_radio_reg(pi, RADIO_2056_SYN_RESERVED_ADDR29 | RADIO_2056_SYN, - ci->RF_SYN_reserved_addr29); - write_radio_reg(pi, RADIO_2056_SYN_LOGEN_VCOBUF1 | RADIO_2056_SYN, - ci->RF_SYN_logen_VCOBUF1); - write_radio_reg(pi, RADIO_2056_SYN_LOGEN_MIXER2 | RADIO_2056_SYN, - ci->RF_SYN_logen_MIXER2); - write_radio_reg(pi, RADIO_2056_SYN_LOGEN_BUF3 | RADIO_2056_SYN, - ci->RF_SYN_logen_BUF3); - write_radio_reg(pi, RADIO_2056_SYN_LOGEN_BUF4 | RADIO_2056_SYN, - ci->RF_SYN_logen_BUF4); - - write_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE | RADIO_2056_RX0, - ci->RF_RX0_lnaa_tune); - write_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | RADIO_2056_RX0, - ci->RF_RX0_lnag_tune); - write_radio_reg(pi, RADIO_2056_TX_INTPAA_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_intpaa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_INTPAG_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_intpag_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PADA_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_pada_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PADG_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_padg_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PGAA_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_pgaa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PGAG_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_pgag_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_MIXA_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_mixa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_MIXG_BOOST_TUNE | RADIO_2056_TX0, - ci->RF_TX0_mixg_boost_tune); - - write_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE | RADIO_2056_RX1, - ci->RF_RX1_lnaa_tune); - write_radio_reg(pi, RADIO_2056_RX_LNAG_TUNE | RADIO_2056_RX1, - ci->RF_RX1_lnag_tune); - write_radio_reg(pi, RADIO_2056_TX_INTPAA_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_intpaa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_INTPAG_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_intpag_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PADA_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_pada_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PADG_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_padg_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PGAA_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_pgaa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_PGAG_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_pgag_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_MIXA_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_mixa_boost_tune); - write_radio_reg(pi, RADIO_2056_TX_MIXG_BOOST_TUNE | RADIO_2056_TX1, - ci->RF_TX1_mixg_boost_tune); - - if (NREV_IS(pi->pubpi.phy_rev, 3)) - regs_SYN_2056_ptr = regs_SYN_2056; - else if (NREV_IS(pi->pubpi.phy_rev, 4)) - regs_SYN_2056_ptr = regs_SYN_2056_A1; - else { - switch (pi->pubpi.radiorev) { - case 5: - regs_SYN_2056_ptr = regs_SYN_2056_rev5; - break; - case 6: - regs_SYN_2056_ptr = regs_SYN_2056_rev6; - break; - case 7: - case 9: - regs_SYN_2056_ptr = regs_SYN_2056_rev7; - break; - case 8: - regs_SYN_2056_ptr = regs_SYN_2056_rev8; - break; - case 11: - regs_SYN_2056_ptr = regs_SYN_2056_rev11; - break; - } - } - if (CHSPEC_IS2G(pi->radio_chanspec)) - write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | - RADIO_2056_SYN, - (u16) regs_SYN_2056_ptr[0x49 - 2].init_g); - else - write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | - RADIO_2056_SYN, - (u16) regs_SYN_2056_ptr[0x49 - 2].init_a); - - if (pi->sh->boardflags2 & BFL2_GPLL_WAR) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER1 | - RADIO_2056_SYN, 0x1f); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER2 | - RADIO_2056_SYN, 0x1f); - - write_radio_reg(pi, - RADIO_2056_SYN_PLL_LOOPFILTER4 | - RADIO_2056_SYN, 0xb); - write_radio_reg(pi, - RADIO_2056_SYN_PLL_CP2 | - RADIO_2056_SYN, 0x14); - } - } - - if ((pi->sh->boardflags2 & BFL2_GPLL_WAR2) && - (CHSPEC_IS2G(pi->radio_chanspec))) { - write_radio_reg(pi, - RADIO_2056_SYN_PLL_LOOPFILTER1 | RADIO_2056_SYN, - 0x1f); - write_radio_reg(pi, - RADIO_2056_SYN_PLL_LOOPFILTER2 | RADIO_2056_SYN, - 0x1f); - write_radio_reg(pi, - RADIO_2056_SYN_PLL_LOOPFILTER4 | RADIO_2056_SYN, - 0xb); - write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | RADIO_2056_SYN, - 0x20); - } - - if (pi->sh->boardflags2 & BFL2_APLL_WAR) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER1 | - RADIO_2056_SYN, 0x1f); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER2 | - RADIO_2056_SYN, 0x1f); - write_radio_reg(pi, RADIO_2056_SYN_PLL_LOOPFILTER4 | - RADIO_2056_SYN, 0x5); - write_radio_reg(pi, RADIO_2056_SYN_PLL_CP2 | - RADIO_2056_SYN, 0xc); - } - } - - if (PHY_IPA(pi) && CHSPEC_IS2G(pi->radio_chanspec)) { - u16 pag_boost_tune; - u16 padg_boost_tune; - u16 pgag_boost_tune; - u16 mixg_boost_tune; - u16 bias, cascbias; - uint core; - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if (NREV_GE(pi->pubpi.phy_rev, 5)) { - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PADG_IDAC, 0xcc); - - bias = 0x25; - cascbias = 0x20; - - if ((pi->sh->chip == - BCM43224_CHIP_ID) - || (pi->sh->chip == - BCM43225_CHIP_ID)) { - if (pi->sh->chippkg == - BCM43224_FAB_SMIC) { - bias = 0x2a; - cascbias = 0x38; - } - } - - pag_boost_tune = 0x4; - pgag_boost_tune = 0x03; - padg_boost_tune = 0x77; - mixg_boost_tune = 0x65; - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_IMAIN_STAT, bias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_IAUX_STAT, bias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_CASCBIAS, cascbias); - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_BOOST_TUNE, - pag_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PGAG_BOOST_TUNE, - pgag_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PADG_BOOST_TUNE, - padg_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - MIXG_BOOST_TUNE, - mixg_boost_tune); - } else { - - bias = (pi->bw == WL_CHANSPEC_BW_40) ? - 0x40 : 0x20; - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_IMAIN_STAT, bias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_IAUX_STAT, bias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_CASCBIAS, 0x30); - } - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, PA_SPARE1, - 0xee); - } - } - - if (PHY_IPA(pi) && NREV_IS(pi->pubpi.phy_rev, 6) - && CHSPEC_IS5G(pi->radio_chanspec)) { - u16 paa_boost_tune; - u16 pada_boost_tune; - u16 pgaa_boost_tune; - u16 mixa_boost_tune; - u16 freq, pabias, cascbias; - uint core; - - freq = CHAN5G_FREQ(CHSPEC_CHANNEL(pi->radio_chanspec)); - - if (freq < 5150) { - - paa_boost_tune = 0xa; - pada_boost_tune = 0x77; - pgaa_boost_tune = 0xf; - mixa_boost_tune = 0xf; - } else if (freq < 5340) { - - paa_boost_tune = 0x8; - pada_boost_tune = 0x77; - pgaa_boost_tune = 0xfb; - mixa_boost_tune = 0xf; - } else if (freq < 5650) { - - paa_boost_tune = 0x0; - pada_boost_tune = 0x77; - pgaa_boost_tune = 0xb; - mixa_boost_tune = 0xf; - } else { - - paa_boost_tune = 0x0; - pada_boost_tune = 0x77; - if (freq != 5825) - pgaa_boost_tune = -(int)(freq - 18) / 36 + 168; - else - pgaa_boost_tune = 6; - - mixa_boost_tune = 0xf; - } - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_BOOST_TUNE, paa_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PADA_BOOST_TUNE, pada_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PGAA_BOOST_TUNE, pgaa_boost_tune); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - MIXA_BOOST_TUNE, mixa_boost_tune); - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - TXSPARE1, 0x30); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PA_SPARE2, 0xee); - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - PADA_CASCBIAS, 0x3); - - cascbias = 0x30; - - if ((pi->sh->chip == BCM43224_CHIP_ID) || - (pi->sh->chip == BCM43225_CHIP_ID)) { - if (pi->sh->chippkg == BCM43224_FAB_SMIC) - cascbias = 0x35; - } - - pabias = (pi->phy_pabias == 0) ? 0x30 : pi->phy_pabias; - - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_IAUX_STAT, pabias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_IMAIN_STAT, pabias); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_CASCBIAS, cascbias); - } - } - - udelay(50); - - wlc_phy_radio205x_vcocal_nphy(pi); -} - -void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi) -{ - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_EN, 0x01, 0x0); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x04, 0x0); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_CAL_RESETN, 0x04, - (1 << 2)); - mod_radio_reg(pi, RADIO_2057_RFPLL_MISC_EN, 0x01, 0x01); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_radio_reg(pi, RADIO_2056_SYN_PLL_VCOCAL12, 0x0); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST3, 0x38); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST3, 0x18); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST3, 0x38); - write_radio_reg(pi, RADIO_2056_SYN_PLL_MAST3, 0x39); - } - - udelay(300); -} - -static void -wlc_phy_chanspec_radio2057_setup( - struct brcms_phy *pi, - const struct chan_info_nphy_radio2057 *ci, - const struct chan_info_nphy_radio2057_rev5 * - ci2) -{ - int coreNum; - u16 txmix2g_tune_boost_pu = 0; - u16 pad2g_tune_pus = 0; - - if (pi->pubpi.radiorev == 5) { - - write_radio_reg(pi, - RADIO_2057_VCOCAL_COUNTVAL0, - ci2->RF_vcocal_countval0); - write_radio_reg(pi, RADIO_2057_VCOCAL_COUNTVAL1, - ci2->RF_vcocal_countval1); - write_radio_reg(pi, RADIO_2057_RFPLL_REFMASTER_SPAREXTALSIZE, - ci2->RF_rfpll_refmaster_sparextalsize); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - ci2->RF_rfpll_loopfilter_r1); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - ci2->RF_rfpll_loopfilter_c2); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - ci2->RF_rfpll_loopfilter_c1); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, - ci2->RF_cp_kpd_idac); - write_radio_reg(pi, RADIO_2057_RFPLL_MMD0, ci2->RF_rfpll_mmd0); - write_radio_reg(pi, RADIO_2057_RFPLL_MMD1, ci2->RF_rfpll_mmd1); - write_radio_reg(pi, - RADIO_2057_VCOBUF_TUNE, ci2->RF_vcobuf_tune); - write_radio_reg(pi, - RADIO_2057_LOGEN_MX2G_TUNE, - ci2->RF_logen_mx2g_tune); - write_radio_reg(pi, RADIO_2057_LOGEN_INDBUF2G_TUNE, - ci2->RF_logen_indbuf2g_tune); - - write_radio_reg(pi, - RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE0, - ci2->RF_txmix2g_tune_boost_pu_core0); - write_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - ci2->RF_pad2g_tune_pus_core0); - write_radio_reg(pi, RADIO_2057_LNA2G_TUNE_CORE0, - ci2->RF_lna2g_tune_core0); - - write_radio_reg(pi, - RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE1, - ci2->RF_txmix2g_tune_boost_pu_core1); - write_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - ci2->RF_pad2g_tune_pus_core1); - write_radio_reg(pi, RADIO_2057_LNA2G_TUNE_CORE1, - ci2->RF_lna2g_tune_core1); - - } else { - - write_radio_reg(pi, - RADIO_2057_VCOCAL_COUNTVAL0, - ci->RF_vcocal_countval0); - write_radio_reg(pi, RADIO_2057_VCOCAL_COUNTVAL1, - ci->RF_vcocal_countval1); - write_radio_reg(pi, RADIO_2057_RFPLL_REFMASTER_SPAREXTALSIZE, - ci->RF_rfpll_refmaster_sparextalsize); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - ci->RF_rfpll_loopfilter_r1); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - ci->RF_rfpll_loopfilter_c2); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - ci->RF_rfpll_loopfilter_c1); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, ci->RF_cp_kpd_idac); - write_radio_reg(pi, RADIO_2057_RFPLL_MMD0, ci->RF_rfpll_mmd0); - write_radio_reg(pi, RADIO_2057_RFPLL_MMD1, ci->RF_rfpll_mmd1); - write_radio_reg(pi, RADIO_2057_VCOBUF_TUNE, ci->RF_vcobuf_tune); - write_radio_reg(pi, - RADIO_2057_LOGEN_MX2G_TUNE, - ci->RF_logen_mx2g_tune); - write_radio_reg(pi, RADIO_2057_LOGEN_MX5G_TUNE, - ci->RF_logen_mx5g_tune); - write_radio_reg(pi, RADIO_2057_LOGEN_INDBUF2G_TUNE, - ci->RF_logen_indbuf2g_tune); - write_radio_reg(pi, RADIO_2057_LOGEN_INDBUF5G_TUNE, - ci->RF_logen_indbuf5g_tune); - - write_radio_reg(pi, - RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE0, - ci->RF_txmix2g_tune_boost_pu_core0); - write_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - ci->RF_pad2g_tune_pus_core0); - write_radio_reg(pi, RADIO_2057_PGA_BOOST_TUNE_CORE0, - ci->RF_pga_boost_tune_core0); - write_radio_reg(pi, RADIO_2057_TXMIX5G_BOOST_TUNE_CORE0, - ci->RF_txmix5g_boost_tune_core0); - write_radio_reg(pi, RADIO_2057_PAD5G_TUNE_MISC_PUS_CORE0, - ci->RF_pad5g_tune_misc_pus_core0); - write_radio_reg(pi, RADIO_2057_LNA2G_TUNE_CORE0, - ci->RF_lna2g_tune_core0); - write_radio_reg(pi, RADIO_2057_LNA5G_TUNE_CORE0, - ci->RF_lna5g_tune_core0); - - write_radio_reg(pi, - RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE1, - ci->RF_txmix2g_tune_boost_pu_core1); - write_radio_reg(pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - ci->RF_pad2g_tune_pus_core1); - write_radio_reg(pi, RADIO_2057_PGA_BOOST_TUNE_CORE1, - ci->RF_pga_boost_tune_core1); - write_radio_reg(pi, RADIO_2057_TXMIX5G_BOOST_TUNE_CORE1, - ci->RF_txmix5g_boost_tune_core1); - write_radio_reg(pi, RADIO_2057_PAD5G_TUNE_MISC_PUS_CORE1, - ci->RF_pad5g_tune_misc_pus_core1); - write_radio_reg(pi, RADIO_2057_LNA2G_TUNE_CORE1, - ci->RF_lna2g_tune_core1); - write_radio_reg(pi, RADIO_2057_LNA5G_TUNE_CORE1, - ci->RF_lna5g_tune_core1); - } - - if ((pi->pubpi.radiorev <= 4) || (pi->pubpi.radiorev == 6)) { - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - 0x3f); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, 0x3f); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - 0x8); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - 0x8); - } else { - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - 0x1f); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, 0x3f); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - 0x8); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - 0x8); - } - } else if ((pi->pubpi.radiorev == 5) || (pi->pubpi.radiorev == 7) || - (pi->pubpi.radiorev == 8)) { - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - 0x1b); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, 0x30); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - 0xa); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - 0xa); - } else { - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_R1, - 0x1f); - write_radio_reg(pi, RADIO_2057_CP_KPD_IDAC, 0x3f); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C1, - 0x8); - write_radio_reg(pi, RADIO_2057_RFPLL_LOOPFILTER_C2, - 0x8); - } - - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (PHY_IPA(pi)) { - if (pi->pubpi.radiorev == 3) - txmix2g_tune_boost_pu = 0x6b; - - if (pi->pubpi.radiorev == 5) - pad2g_tune_pus = 0x73; - - } else { - if (pi->pubpi.radiorev != 5) { - pad2g_tune_pus = 0x3; - - txmix2g_tune_boost_pu = 0x61; - } - } - - for (coreNum = 0; coreNum <= 1; coreNum++) { - - if (txmix2g_tune_boost_pu != 0) - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - TXMIX2G_TUNE_BOOST_PU, - txmix2g_tune_boost_pu); - - if (pad2g_tune_pus != 0) - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - PAD2G_TUNE_PUS, - pad2g_tune_pus); - } - } - - udelay(50); - - wlc_phy_radio205x_vcocal_nphy(pi); -} - -static void -wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, - const struct nphy_sfo_cfg *ci) -{ - u16 val; - - val = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; - if (CHSPEC_IS5G(chanspec) && !val) { - - val = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, - (val | MAC_PHY_FORCE_CLK)); - - or_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), - (BBCFG_RESETCCA | BBCFG_RESETRX)); - - W_REG(&pi->regs->psm_phy_hdr_param, val); - - or_phy_reg(pi, 0x09, NPHY_BandControl_currentBand); - } else if (!CHSPEC_IS5G(chanspec) && val) { - - and_phy_reg(pi, 0x09, ~NPHY_BandControl_currentBand); - - val = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, - (val | MAC_PHY_FORCE_CLK)); - - and_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), - (u16) (~(BBCFG_RESETCCA | BBCFG_RESETRX))); - - W_REG(&pi->regs->psm_phy_hdr_param, val); - } - - write_phy_reg(pi, 0x1ce, ci->PHY_BW1a); - write_phy_reg(pi, 0x1cf, ci->PHY_BW2); - write_phy_reg(pi, 0x1d0, ci->PHY_BW3); - - write_phy_reg(pi, 0x1d1, ci->PHY_BW4); - write_phy_reg(pi, 0x1d2, ci->PHY_BW5); - write_phy_reg(pi, 0x1d3, ci->PHY_BW6); - - if (CHSPEC_CHANNEL(pi->radio_chanspec) == 14) { - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_ofdm_en, 0); - - or_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_TEST, 0x800); - } else { - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_ofdm_en, - NPHY_ClassifierCtrl_ofdm_en); - - if (CHSPEC_IS2G(chanspec)) - and_phy_reg(pi, NPHY_TO_BPHY_OFF + BPHY_TEST, ~0x840); - } - - if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) - wlc_phy_txpwr_fixpower_nphy(pi); - - if (NREV_LT(pi->pubpi.phy_rev, 3)) - wlc_phy_adjust_lnagaintbl_nphy(pi); - - wlc_phy_txlpfbw_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3) - && (pi->phy_spuravoid != SPURAVOID_DISABLE)) { - u8 spuravoid = 0; - - val = CHSPEC_CHANNEL(chanspec); - if (!CHSPEC_IS40(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if ((val == 13) || (val == 14) || (val == 153)) - spuravoid = 1; - } else if (((val >= 5) && (val <= 8)) || (val == 13) - || (val == 14)) { - spuravoid = 1; - } - } else if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (val == 54) - spuravoid = 1; - } else { - if (pi->nphy_aband_spurwar_en && - ((val == 38) || (val == 102) - || (val == 118))) - spuravoid = 1; - } - - if (pi->phy_spuravoid == SPURAVOID_FORCEON) - spuravoid = 1; - - wlapi_bmac_core_phypll_ctl(pi->sh->physhim, false); - si_pmu_spuravoid(pi->sh->sih, spuravoid); - wlapi_bmac_core_phypll_ctl(pi->sh->physhim, true); - - if ((pi->sh->chip == BCM43224_CHIP_ID) || - (pi->sh->chip == BCM43225_CHIP_ID)) { - - if (spuravoid == 1) { - - W_REG(&pi->regs->tsf_clk_frac_l, - 0x5341); - W_REG(&pi->regs->tsf_clk_frac_h, - 0x8); - } else { - - W_REG(&pi->regs->tsf_clk_frac_l, - 0x8889); - W_REG(&pi->regs->tsf_clk_frac_h, - 0x8); - } - } - - wlapi_bmac_core_phypll_reset(pi->sh->physhim); - - mod_phy_reg(pi, 0x01, (0x1 << 15), - ((spuravoid > 0) ? (0x1 << 15) : 0)); - - wlc_phy_resetcca_nphy(pi); - - pi->phy_isspuravoid = (spuravoid > 0); - } - - if (NREV_LT(pi->pubpi.phy_rev, 7)) - write_phy_reg(pi, 0x17e, 0x3830); - - wlc_phy_spurwar_nphy(pi); -} - -void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec) -{ - int freq; - const struct chan_info_nphy_radio2057 *t0 = NULL; - const struct chan_info_nphy_radio205x *t1 = NULL; - const struct chan_info_nphy_radio2057_rev5 *t2 = NULL; - const struct chan_info_nphy_2055 *t3 = NULL; - - if (!wlc_phy_chan2freq_nphy - (pi, CHSPEC_CHANNEL(chanspec), &freq, &t0, &t1, &t2, &t3)) - return; - - wlc_phy_chanspec_radio_set((struct brcms_phy_pub *) pi, chanspec); - - if (CHSPEC_BW(chanspec) != pi->bw) - wlapi_bmac_bw_set(pi->sh->physhim, CHSPEC_BW(chanspec)); - - if (CHSPEC_IS40(chanspec)) { - if (CHSPEC_SB_UPPER(chanspec)) { - or_phy_reg(pi, 0xa0, BPHY_BAND_SEL_UP20); - if (NREV_GE(pi->pubpi.phy_rev, 7)) - or_phy_reg(pi, 0x310, PRIM_SEL_UP20); - } else { - and_phy_reg(pi, 0xa0, ~BPHY_BAND_SEL_UP20); - if (NREV_GE(pi->pubpi.phy_rev, 7)) - and_phy_reg(pi, 0x310, - (~PRIM_SEL_UP20 & 0xffff)); - } - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) { - mod_radio_reg(pi, RADIO_2057_TIA_CONFIG_CORE0, - 0x2, - (CHSPEC_IS5G(chanspec) ? (1 << 1) - : 0)); - mod_radio_reg(pi, RADIO_2057_TIA_CONFIG_CORE1, - 0x2, - (CHSPEC_IS5G(chanspec) ? (1 << 1) - : 0)); - } - - wlc_phy_chanspec_radio2057_setup(pi, t0, t2); - wlc_phy_chanspec_nphy_setup(pi, chanspec, - (pi->pubpi.radiorev == 5) ? - (const struct nphy_sfo_cfg *)&(t2->PHY_BW1a) : - (const struct nphy_sfo_cfg *)&(t0->PHY_BW1a)); - - } else { - - mod_radio_reg(pi, - RADIO_2056_SYN_COM_CTRL | RADIO_2056_SYN, - 0x4, - (CHSPEC_IS5G(chanspec) ? (0x1 << 2) : 0)); - wlc_phy_chanspec_radio2056_setup(pi, t1); - - wlc_phy_chanspec_nphy_setup(pi, chanspec, - (const struct nphy_sfo_cfg *) &(t1->PHY_BW1a)); - } - - } else { - - mod_radio_reg(pi, RADIO_2055_MASTER_CNTRL1, 0x70, - (CHSPEC_IS5G(chanspec) ? (0x02 << 4) - : (0x05 << 4))); - - wlc_phy_chanspec_radio2055_setup(pi, t3); - wlc_phy_chanspec_nphy_setup(pi, chanspec, - (const struct nphy_sfo_cfg *) - &(t3->PHY_BW1a)); - } - -} - -void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init) -{ - struct brcms_phy *pi = (struct brcms_phy *) ppi; - u16 mask = 0xfc00; - u32 mc = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - return; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - u16 v0 = 0x211, v1 = 0x222, v2 = 0x144, v3 = 0x188; - - if (lut_init == false) - return; - - if (pi->srom_fem2g.antswctrllut == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x02, 16, &v0); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x03, 16, &v1); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x08, 16, &v2); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x0C, 16, &v3); - } - - if (pi->srom_fem5g.antswctrllut == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x12, 16, &v0); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x13, 16, &v1); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x18, 16, &v2); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT, - 1, 0x1C, 16, &v3); - } - } else { - - write_phy_reg(pi, 0xc8, 0x0); - write_phy_reg(pi, 0xc9, 0x0); - - ai_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY); - - mc = R_REG(&pi->regs->maccontrol); - mc &= ~MCTL_GPOUT_SEL_MASK; - W_REG(&pi->regs->maccontrol, mc); - - OR_REG(&pi->regs->psm_gpio_oe, mask); - - AND_REG(&pi->regs->psm_gpio_out, ~mask); - - if (lut_init) { - write_phy_reg(pi, 0xf8, 0x02d8); - write_phy_reg(pi, 0xf9, 0x0301); - write_phy_reg(pi, 0xfa, 0x02d8); - write_phy_reg(pi, 0xfb, 0x0301); - } - } -} - -u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val) -{ - u16 curr_ctl, new_ctl; - bool suspended = false; - - if (D11REV_IS(pi->sh->corerev, 16)) { - suspended = - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) ? - false : true; - if (!suspended) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - } - - curr_ctl = read_phy_reg(pi, 0xb0) & (0x7 << 0); - - new_ctl = (curr_ctl & (~mask)) | (val & mask); - - mod_phy_reg(pi, 0xb0, (0x7 << 0), new_ctl); - - if (D11REV_IS(pi->sh->corerev, 16) && !suspended) - wlapi_enable_mac(pi->sh->physhim); - - return new_ctl; -} - -void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd) -{ - u16 trigger_mask, status_mask; - u16 orig_RfseqCoreActv; - - switch (cmd) { - case NPHY_RFSEQ_RX2TX: - trigger_mask = NPHY_RfseqTrigger_rx2tx; - status_mask = NPHY_RfseqStatus_rx2tx; - break; - case NPHY_RFSEQ_TX2RX: - trigger_mask = NPHY_RfseqTrigger_tx2rx; - status_mask = NPHY_RfseqStatus_tx2rx; - break; - case NPHY_RFSEQ_RESET2RX: - trigger_mask = NPHY_RfseqTrigger_reset2rx; - status_mask = NPHY_RfseqStatus_reset2rx; - break; - case NPHY_RFSEQ_UPDATEGAINH: - trigger_mask = NPHY_RfseqTrigger_updategainh; - status_mask = NPHY_RfseqStatus_updategainh; - break; - case NPHY_RFSEQ_UPDATEGAINL: - trigger_mask = NPHY_RfseqTrigger_updategainl; - status_mask = NPHY_RfseqStatus_updategainl; - break; - case NPHY_RFSEQ_UPDATEGAINU: - trigger_mask = NPHY_RfseqTrigger_updategainu; - status_mask = NPHY_RfseqStatus_updategainu; - break; - default: - return; - } - - orig_RfseqCoreActv = read_phy_reg(pi, 0xa1); - or_phy_reg(pi, 0xa1, - (NPHY_RfseqMode_CoreActv_override | - NPHY_RfseqMode_Trigger_override)); - or_phy_reg(pi, 0xa3, trigger_mask); - SPINWAIT((read_phy_reg(pi, 0xa4) & status_mask), 200000); - write_phy_reg(pi, 0xa1, orig_RfseqCoreActv); - WARN(read_phy_reg(pi, 0xa4) & status_mask, "HW error in rf"); -} - -static void -wlc_phy_rfctrl_override_1tomany_nphy(struct brcms_phy *pi, u16 cmd, u16 value, - u8 core_mask, u8 off) -{ - u16 rfmxgain = 0, lpfgain = 0; - u16 tgain = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - switch (cmd) { - case NPHY_REV7_RfctrlOverride_cmd_rxrf_pu: - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 5), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 4), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 3), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - break; - case NPHY_REV7_RfctrlOverride_cmd_rx_pu: - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 0), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 11), 0, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - break; - case NPHY_REV7_RfctrlOverride_cmd_tx_pu: - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - value, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 1), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 0), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), value, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 11), 1, - core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - break; - case NPHY_REV7_RfctrlOverride_cmd_rxgain: - rfmxgain = value & 0x000ff; - lpfgain = value & 0x0ff00; - lpfgain = lpfgain >> 8; - - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 11), - rfmxgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x3 << 13), - lpfgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - break; - case NPHY_REV7_RfctrlOverride_cmd_txgain: - tgain = value & 0x7fff; - lpfgain = value & 0x8000; - lpfgain = lpfgain >> 14; - - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 12), - tgain, core_mask, off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 13), - lpfgain, core_mask, - off, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - break; - } - } -} - -static void -wlc_phy_scale_offset_rssi_nphy(struct brcms_phy *pi, u16 scale, s8 offset, - u8 coresel, u8 rail, u8 rssi_type) -{ - u16 valuetostuff; - - offset = (offset > NPHY_RSSICAL_MAXREAD) ? - NPHY_RSSICAL_MAXREAD : offset; - offset = (offset < (-NPHY_RSSICAL_MAXREAD - 1)) ? - -NPHY_RSSICAL_MAXREAD - 1 : offset; - - valuetostuff = ((scale & 0x3f) << 8) | (offset & 0x3f); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) - write_phy_reg(pi, 0x1a6, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) - write_phy_reg(pi, 0x1ac, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_NB)) - write_phy_reg(pi, 0x1b2, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_NB)) - write_phy_reg(pi, 0x1b8, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) - write_phy_reg(pi, 0x1a4, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) - write_phy_reg(pi, 0x1aa, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W1)) - write_phy_reg(pi, 0x1b0, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W1)) - write_phy_reg(pi, 0x1b6, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) - write_phy_reg(pi, 0x1a5, valuetostuff); - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) - write_phy_reg(pi, 0x1ab, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_W2)) - write_phy_reg(pi, 0x1b1, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_W2)) - write_phy_reg(pi, 0x1b7, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) - write_phy_reg(pi, 0x1a7, valuetostuff); - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) - write_phy_reg(pi, 0x1ad, valuetostuff); - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_TBD)) - write_phy_reg(pi, 0x1b3, valuetostuff); - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_TBD)) - write_phy_reg(pi, 0x1b9, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) - write_phy_reg(pi, 0x1a8, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) - write_phy_reg(pi, 0x1ae, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_I) && (rssi_type == NPHY_RSSI_SEL_IQ)) - write_phy_reg(pi, 0x1b4, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rail == NPHY_RAIL_Q) && (rssi_type == NPHY_RSSI_SEL_IQ)) - write_phy_reg(pi, 0x1ba, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) - write_phy_reg(pi, 0x1a9, valuetostuff); - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_2G)) - write_phy_reg(pi, 0x1b5, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE1) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) - write_phy_reg(pi, 0x1af, valuetostuff); - - if (((coresel == RADIO_MIMO_CORESEL_CORE2) || - (coresel == RADIO_MIMO_CORESEL_ALLRX)) && - (rssi_type == NPHY_RSSI_SEL_TSSI_5G)) - write_phy_reg(pi, 0x1bb, valuetostuff); -} - -static void brcms_phy_wr_tx_mux(struct brcms_phy *pi, u8 core) -{ - if (PHY_IPA(pi)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) - write_radio_reg(pi, - ((core == PHY_CORE_0) ? - RADIO_2057_TX0_TX_SSI_MUX : - RADIO_2057_TX1_TX_SSI_MUX), - (CHSPEC_IS5G(pi->radio_chanspec) ? - 0xc : 0xe)); - else - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - ((core == PHY_CORE_0) ? - RADIO_2056_TX0 : RADIO_2056_TX1), - (CHSPEC_IS5G(pi->radio_chanspec) ? - 0xc : 0xe)); - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_radio_reg(pi, - ((core == PHY_CORE_0) ? - RADIO_2057_TX0_TX_SSI_MUX : - RADIO_2057_TX1_TX_SSI_MUX), - 0x11); - - if (pi->pubpi.radioid == BCM2057_ID) - write_radio_reg(pi, - RADIO_2057_IQTEST_SEL_PU, 0x1); - - } else { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - ((core == PHY_CORE_0) ? - RADIO_2056_TX0 : RADIO_2056_TX1), - 0x11); - } - } -} - -void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type) -{ - u16 mask, val; - u16 afectrlovr_rssi_val, rfctrlcmd_rxen_val, rfctrlcmd_coresel_val, - startseq; - u16 rfctrlovr_rssi_val, rfctrlovr_rxen_val, rfctrlovr_coresel_val, - rfctrlovr_trigger_val; - u16 afectrlovr_rssi_mask, rfctrlcmd_mask, rfctrlovr_mask; - u16 rfctrlcmd_val, rfctrlovr_val; - u8 core; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (core_code == RADIO_MIMO_CORESEL_OFF) { - mod_phy_reg(pi, 0x8f, (0x1 << 9), 0); - mod_phy_reg(pi, 0xa5, (0x1 << 9), 0); - - mod_phy_reg(pi, 0xa6, (0x3 << 8), 0); - mod_phy_reg(pi, 0xa7, (0x3 << 8), 0); - - mod_phy_reg(pi, 0xe5, (0x1 << 5), 0); - mod_phy_reg(pi, 0xe6, (0x1 << 5), 0); - - mask = (0x1 << 2) | - (0x1 << 3) | (0x1 << 4) | (0x1 << 5); - mod_phy_reg(pi, 0xf9, mask, 0); - mod_phy_reg(pi, 0xfb, mask, 0); - - } else { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (core_code == RADIO_MIMO_CORESEL_CORE1 - && core == PHY_CORE_1) - continue; - else if (core_code == RADIO_MIMO_CORESEL_CORE2 - && core == PHY_CORE_0) - continue; - - mod_phy_reg(pi, (core == PHY_CORE_0) ? - 0x8f : 0xa5, (0x1 << 9), 1 << 9); - - if (rssi_type == NPHY_RSSI_SEL_W1 || - rssi_type == NPHY_RSSI_SEL_W2 || - rssi_type == NPHY_RSSI_SEL_NB) { - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 : 0xa7, - (0x3 << 8), 0); - - mask = (0x1 << 2) | - (0x1 << 3) | - (0x1 << 4) | (0x1 << 5); - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xf9 : 0xfb, - mask, 0); - - if (rssi_type == NPHY_RSSI_SEL_W1) { - if (CHSPEC_IS5G( - pi->radio_chanspec)) { - mask = (0x1 << 2); - val = 1 << 2; - } else { - mask = (0x1 << 3); - val = 1 << 3; - } - } else if (rssi_type == - NPHY_RSSI_SEL_W2) { - mask = (0x1 << 4); - val = 1 << 4; - } else { - mask = (0x1 << 5); - val = 1 << 5; - } - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xf9 : 0xfb, - mask, val); - - mask = (0x1 << 5); - val = 1 << 5; - mod_phy_reg(pi, (core == PHY_CORE_0) ? - 0xe5 : 0xe6, mask, val); - } else { - if (rssi_type == NPHY_RSSI_SEL_TBD) { - mask = (0x3 << 8); - val = 1 << 8; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - mask = (0x3 << 10); - val = 1 << 10; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - } else if (rssi_type == - NPHY_RSSI_SEL_IQ) { - mask = (0x3 << 8); - val = 2 << 8; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - mask = (0x3 << 10); - val = 2 << 10; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - } else { - mask = (0x3 << 8); - val = 3 << 8; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - mask = (0x3 << 10); - val = 3 << 10; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0xa6 - : 0xa7, mask, val); - brcms_phy_wr_tx_mux(pi, core); - afectrlovr_rssi_val = 1 << 9; - mod_phy_reg(pi, - (core == - PHY_CORE_0) ? 0x8f - : 0xa5, (0x1 << 9), - afectrlovr_rssi_val); - } - } - } - } - } else { - - if ((rssi_type == NPHY_RSSI_SEL_W1) || - (rssi_type == NPHY_RSSI_SEL_W2) || - (rssi_type == NPHY_RSSI_SEL_NB)) - val = 0x0; - else if (rssi_type == NPHY_RSSI_SEL_TBD) - val = 0x1; - else if (rssi_type == NPHY_RSSI_SEL_IQ) - val = 0x2; - else - val = 0x3; - - mask = ((0x3 << 12) | (0x3 << 14)); - val = (val << 12) | (val << 14); - mod_phy_reg(pi, 0xa6, mask, val); - mod_phy_reg(pi, 0xa7, mask, val); - - if ((rssi_type == NPHY_RSSI_SEL_W1) || - (rssi_type == NPHY_RSSI_SEL_W2) || - (rssi_type == NPHY_RSSI_SEL_NB)) { - if (rssi_type == NPHY_RSSI_SEL_W1) - val = 0x1; - if (rssi_type == NPHY_RSSI_SEL_W2) - val = 0x2; - if (rssi_type == NPHY_RSSI_SEL_NB) - val = 0x3; - - mask = (0x3 << 4); - val = (val << 4); - mod_phy_reg(pi, 0x7a, mask, val); - mod_phy_reg(pi, 0x7d, mask, val); - } - - if (core_code == RADIO_MIMO_CORESEL_OFF) { - afectrlovr_rssi_val = 0; - rfctrlcmd_rxen_val = 0; - rfctrlcmd_coresel_val = 0; - rfctrlovr_rssi_val = 0; - rfctrlovr_rxen_val = 0; - rfctrlovr_coresel_val = 0; - rfctrlovr_trigger_val = 0; - startseq = 0; - } else { - afectrlovr_rssi_val = 1; - rfctrlcmd_rxen_val = 1; - rfctrlcmd_coresel_val = core_code; - rfctrlovr_rssi_val = 1; - rfctrlovr_rxen_val = 1; - rfctrlovr_coresel_val = 1; - rfctrlovr_trigger_val = 1; - startseq = 1; - } - - afectrlovr_rssi_mask = ((0x1 << 12) | (0x1 << 13)); - afectrlovr_rssi_val = (afectrlovr_rssi_val << - 12) | (afectrlovr_rssi_val << 13); - mod_phy_reg(pi, 0xa5, afectrlovr_rssi_mask, - afectrlovr_rssi_val); - - if ((rssi_type == NPHY_RSSI_SEL_W1) || - (rssi_type == NPHY_RSSI_SEL_W2) || - (rssi_type == NPHY_RSSI_SEL_NB)) { - rfctrlcmd_mask = ((0x1 << 8) | (0x7 << 3)); - rfctrlcmd_val = (rfctrlcmd_rxen_val << 8) | - (rfctrlcmd_coresel_val << 3); - - rfctrlovr_mask = ((0x1 << 5) | - (0x1 << 12) | - (0x1 << 1) | (0x1 << 0)); - rfctrlovr_val = (rfctrlovr_rssi_val << - 5) | - (rfctrlovr_rxen_val << 12) | - (rfctrlovr_coresel_val << 1) | - (rfctrlovr_trigger_val << 0); - - mod_phy_reg(pi, 0x78, rfctrlcmd_mask, rfctrlcmd_val); - mod_phy_reg(pi, 0xec, rfctrlovr_mask, rfctrlovr_val); - - mod_phy_reg(pi, 0x78, (0x1 << 0), (startseq << 0)); - udelay(20); - - mod_phy_reg(pi, 0xec, (0x1 << 0), 0); - } - } -} - -int -wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type, s32 *rssi_buf, - u8 nsamps) -{ - s16 rssi0, rssi1; - u16 afectrlCore1_save = 0; - u16 afectrlCore2_save = 0; - u16 afectrlOverride1_save = 0; - u16 afectrlOverride2_save = 0; - u16 rfctrlOverrideAux0_save = 0; - u16 rfctrlOverrideAux1_save = 0; - u16 rfctrlMiscReg1_save = 0; - u16 rfctrlMiscReg2_save = 0; - u16 rfctrlcmd_save = 0; - u16 rfctrloverride_save = 0; - u16 rfctrlrssiothers1_save = 0; - u16 rfctrlrssiothers2_save = 0; - s8 tmp_buf[4]; - u8 ctr = 0, samp = 0; - s32 rssi_out_val; - u16 gpiosel_orig; - - afectrlCore1_save = read_phy_reg(pi, 0xa6); - afectrlCore2_save = read_phy_reg(pi, 0xa7); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - rfctrlMiscReg1_save = read_phy_reg(pi, 0xf9); - rfctrlMiscReg2_save = read_phy_reg(pi, 0xfb); - afectrlOverride1_save = read_phy_reg(pi, 0x8f); - afectrlOverride2_save = read_phy_reg(pi, 0xa5); - rfctrlOverrideAux0_save = read_phy_reg(pi, 0xe5); - rfctrlOverrideAux1_save = read_phy_reg(pi, 0xe6); - } else { - afectrlOverride1_save = read_phy_reg(pi, 0xa5); - rfctrlcmd_save = read_phy_reg(pi, 0x78); - rfctrloverride_save = read_phy_reg(pi, 0xec); - rfctrlrssiothers1_save = read_phy_reg(pi, 0x7a); - rfctrlrssiothers2_save = read_phy_reg(pi, 0x7d); - } - - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); - - gpiosel_orig = read_phy_reg(pi, 0xca); - if (NREV_LT(pi->pubpi.phy_rev, 2)) - write_phy_reg(pi, 0xca, 5); - - for (ctr = 0; ctr < 4; ctr++) - rssi_buf[ctr] = 0; - - for (samp = 0; samp < nsamps; samp++) { - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - rssi0 = read_phy_reg(pi, 0x1c9); - rssi1 = read_phy_reg(pi, 0x1ca); - } else { - rssi0 = read_phy_reg(pi, 0x219); - rssi1 = read_phy_reg(pi, 0x21a); - } - - ctr = 0; - tmp_buf[ctr++] = ((s8) ((rssi0 & 0x3f) << 2)) >> 2; - tmp_buf[ctr++] = ((s8) (((rssi0 >> 8) & 0x3f) << 2)) >> 2; - tmp_buf[ctr++] = ((s8) ((rssi1 & 0x3f) << 2)) >> 2; - tmp_buf[ctr++] = ((s8) (((rssi1 >> 8) & 0x3f) << 2)) >> 2; - - for (ctr = 0; ctr < 4; ctr++) - rssi_buf[ctr] += tmp_buf[ctr]; - - } - - rssi_out_val = rssi_buf[3] & 0xff; - rssi_out_val |= (rssi_buf[2] & 0xff) << 8; - rssi_out_val |= (rssi_buf[1] & 0xff) << 16; - rssi_out_val |= (rssi_buf[0] & 0xff) << 24; - - if (NREV_LT(pi->pubpi.phy_rev, 2)) - write_phy_reg(pi, 0xca, gpiosel_orig); - - write_phy_reg(pi, 0xa6, afectrlCore1_save); - write_phy_reg(pi, 0xa7, afectrlCore2_save); - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0xf9, rfctrlMiscReg1_save); - write_phy_reg(pi, 0xfb, rfctrlMiscReg2_save); - write_phy_reg(pi, 0x8f, afectrlOverride1_save); - write_phy_reg(pi, 0xa5, afectrlOverride2_save); - write_phy_reg(pi, 0xe5, rfctrlOverrideAux0_save); - write_phy_reg(pi, 0xe6, rfctrlOverrideAux1_save); - } else { - write_phy_reg(pi, 0xa5, afectrlOverride1_save); - write_phy_reg(pi, 0x78, rfctrlcmd_save); - write_phy_reg(pi, 0xec, rfctrloverride_save); - write_phy_reg(pi, 0x7a, rfctrlrssiothers1_save); - write_phy_reg(pi, 0x7d, rfctrlrssiothers2_save); - } - - return rssi_out_val; -} - -s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi) -{ - u16 core1_txrf_iqcal1_save, core1_txrf_iqcal2_save; - u16 core2_txrf_iqcal1_save, core2_txrf_iqcal2_save; - u16 pwrdet_rxtx_core1_save; - u16 pwrdet_rxtx_core2_save; - u16 afectrlCore1_save; - u16 afectrlCore2_save; - u16 afectrlOverride_save; - u16 afectrlOverride2_save; - u16 pd_pll_ts_save; - u16 gpioSel_save; - s32 radio_temp[4]; - s32 radio_temp2[4]; - u16 syn_tempprocsense_save; - s16 offset = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - u16 auxADC_Vmid, auxADC_Av, auxADC_Vmid_save, auxADC_Av_save; - u16 auxADC_rssi_ctrlL_save, auxADC_rssi_ctrlH_save; - u16 auxADC_rssi_ctrlL, auxADC_rssi_ctrlH; - s32 auxADC_Vl; - u16 RfctrlOverride5_save, RfctrlOverride6_save; - u16 RfctrlMiscReg5_save, RfctrlMiscReg6_save; - u16 RSSIMultCoef0QPowerDet_save; - u16 tempsense_Rcal; - - syn_tempprocsense_save = - read_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG); - - afectrlCore1_save = read_phy_reg(pi, 0xa6); - afectrlCore2_save = read_phy_reg(pi, 0xa7); - afectrlOverride_save = read_phy_reg(pi, 0x8f); - afectrlOverride2_save = read_phy_reg(pi, 0xa5); - RSSIMultCoef0QPowerDet_save = read_phy_reg(pi, 0x1ae); - RfctrlOverride5_save = read_phy_reg(pi, 0x346); - RfctrlOverride6_save = read_phy_reg(pi, 0x347); - RfctrlMiscReg5_save = read_phy_reg(pi, 0x344); - RfctrlMiscReg6_save = read_phy_reg(pi, 0x345); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0A, 16, - &auxADC_Vmid_save); - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0E, 16, - &auxADC_Av_save); - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x02, 16, - &auxADC_rssi_ctrlL_save); - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x03, 16, - &auxADC_rssi_ctrlH_save); - - write_phy_reg(pi, 0x1ae, 0x0); - - auxADC_rssi_ctrlL = 0x0; - auxADC_rssi_ctrlH = 0x20; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x02, 16, - &auxADC_rssi_ctrlL); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x03, 16, - &auxADC_rssi_ctrlH); - - tempsense_Rcal = syn_tempprocsense_save & 0x1c; - - write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, - tempsense_Rcal | 0x01); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), - 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - mod_phy_reg(pi, 0xa6, (0x1 << 7), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 7), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 7), (0x1 << 7)); - mod_phy_reg(pi, 0xa5, (0x1 << 7), (0x1 << 7)); - - mod_phy_reg(pi, 0xa6, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa7, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0x8f, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa5, (0x1 << 2), (0x1 << 2)); - udelay(5); - mod_phy_reg(pi, 0xa6, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa6, (0x1 << 3), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 3), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 3), (0x1 << 3)); - mod_phy_reg(pi, 0xa5, (0x1 << 3), (0x1 << 3)); - mod_phy_reg(pi, 0xa6, (0x1 << 6), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 6), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 6), (0x1 << 6)); - mod_phy_reg(pi, 0xa5, (0x1 << 6), (0x1 << 6)); - - auxADC_Vmid = 0xA3; - auxADC_Av = 0x0; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0A, 16, - &auxADC_Vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0E, 16, - &auxADC_Av); - - udelay(3); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp, 1); - write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, - tempsense_Rcal | 0x03); - - udelay(5); - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp2, 1); - - auxADC_Av = 0x7; - if (radio_temp[1] + radio_temp2[1] < -30) { - auxADC_Vmid = 0x45; - auxADC_Vl = 263; - } else if (radio_temp[1] + radio_temp2[1] < -9) { - auxADC_Vmid = 0x200; - auxADC_Vl = 467; - } else if (radio_temp[1] + radio_temp2[1] < 11) { - auxADC_Vmid = 0x266; - auxADC_Vl = 634; - } else { - auxADC_Vmid = 0x2D5; - auxADC_Vl = 816; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0A, 16, - &auxADC_Vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0E, 16, - &auxADC_Av); - - udelay(3); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp2, 1); - write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, - tempsense_Rcal | 0x01); - - udelay(5); - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp, 1); - - write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, - syn_tempprocsense_save); - - write_phy_reg(pi, 0xa6, afectrlCore1_save); - write_phy_reg(pi, 0xa7, afectrlCore2_save); - write_phy_reg(pi, 0x8f, afectrlOverride_save); - write_phy_reg(pi, 0xa5, afectrlOverride2_save); - write_phy_reg(pi, 0x1ae, RSSIMultCoef0QPowerDet_save); - write_phy_reg(pi, 0x346, RfctrlOverride5_save); - write_phy_reg(pi, 0x347, RfctrlOverride6_save); - write_phy_reg(pi, 0x344, RfctrlMiscReg5_save); - write_phy_reg(pi, 0x345, RfctrlMiscReg5_save); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0A, 16, - &auxADC_Vmid_save); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0E, 16, - &auxADC_Av_save); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x02, 16, - &auxADC_rssi_ctrlL_save); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x03, 16, - &auxADC_rssi_ctrlH_save); - - radio_temp[0] = (179 * (radio_temp[1] + radio_temp2[1]) - + 82 * (auxADC_Vl) - 28861 + - 128) / 256; - - offset = (s16) pi->phy_tempsense_offset; - - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - syn_tempprocsense_save = - read_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE); - - afectrlCore1_save = read_phy_reg(pi, 0xa6); - afectrlCore2_save = read_phy_reg(pi, 0xa7); - afectrlOverride_save = read_phy_reg(pi, 0x8f); - afectrlOverride2_save = read_phy_reg(pi, 0xa5); - gpioSel_save = read_phy_reg(pi, 0xca); - - write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x01); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp, 1); - if (NREV_LT(pi->pubpi.phy_rev, 7)) - write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x05); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp2, 1); - if (NREV_GE(pi->pubpi.phy_rev, 7)) - write_radio_reg(pi, RADIO_2057_TEMPSENSE_CONFIG, 0x01); - else - write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, 0x01); - - radio_temp[0] = - (126 * (radio_temp[1] + radio_temp2[1]) + 3987) / 64; - - write_radio_reg(pi, RADIO_2056_SYN_TEMPPROCSENSE, - syn_tempprocsense_save); - - write_phy_reg(pi, 0xca, gpioSel_save); - write_phy_reg(pi, 0xa6, afectrlCore1_save); - write_phy_reg(pi, 0xa7, afectrlCore2_save); - write_phy_reg(pi, 0x8f, afectrlOverride_save); - write_phy_reg(pi, 0xa5, afectrlOverride2_save); - - offset = (s16) pi->phy_tempsense_offset; - } else { - - pwrdet_rxtx_core1_save = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); - pwrdet_rxtx_core2_save = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); - core1_txrf_iqcal1_save = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); - core1_txrf_iqcal2_save = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); - core2_txrf_iqcal1_save = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); - core2_txrf_iqcal2_save = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); - pd_pll_ts_save = read_radio_reg(pi, RADIO_2055_PD_PLL_TS); - - afectrlCore1_save = read_phy_reg(pi, 0xa6); - afectrlCore2_save = read_phy_reg(pi, 0xa7); - afectrlOverride_save = read_phy_reg(pi, 0xa5); - gpioSel_save = read_phy_reg(pi, 0xca); - - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1, 0x01); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1, 0x01); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2, 0x08); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2, 0x08); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1, 0x04); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2, 0x04); - write_radio_reg(pi, RADIO_2055_PD_PLL_TS, 0x00); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp, 1); - xor_radio_reg(pi, RADIO_2055_CAL_TS, 0x80); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp, 1); - xor_radio_reg(pi, RADIO_2055_CAL_TS, 0x80); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_IQ, radio_temp2, 1); - xor_radio_reg(pi, RADIO_2055_CAL_TS, 0x80); - - radio_temp[0] = (radio_temp[0] + radio_temp2[0]); - radio_temp[1] = (radio_temp[1] + radio_temp2[1]); - radio_temp[2] = (radio_temp[2] + radio_temp2[2]); - radio_temp[3] = (radio_temp[3] + radio_temp2[3]); - - radio_temp[0] = - (radio_temp[0] + radio_temp[1] + radio_temp[2] + - radio_temp[3]); - - radio_temp[0] = - (radio_temp[0] + - (8 * 32)) * (950 - 350) / 63 + (350 * 8); - - radio_temp[0] = (radio_temp[0] - (8 * 420)) / 38; - - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1, - pwrdet_rxtx_core1_save); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2, - pwrdet_rxtx_core2_save); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1, - core1_txrf_iqcal1_save); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1, - core2_txrf_iqcal1_save); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2, - core1_txrf_iqcal2_save); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2, - core2_txrf_iqcal2_save); - write_radio_reg(pi, RADIO_2055_PD_PLL_TS, pd_pll_ts_save); - - write_phy_reg(pi, 0xca, gpioSel_save); - write_phy_reg(pi, 0xa6, afectrlCore1_save); - write_phy_reg(pi, 0xa7, afectrlCore2_save); - write_phy_reg(pi, 0xa5, afectrlOverride_save); - } - - return (s16) radio_temp[0] + offset; -} - -static void -wlc_phy_set_rssi_2055_vcm(struct brcms_phy *pi, u8 rssi_type, u8 *vcm_buf) -{ - u8 core; - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - if (rssi_type == NPHY_RSSI_SEL_NB) { - if (core == PHY_CORE_0) { - mod_radio_reg(pi, - RADIO_2055_CORE1_B0_NBRSSI_VCM, - RADIO_2055_NBRSSI_VCM_I_MASK, - vcm_buf[2 * - core] << - RADIO_2055_NBRSSI_VCM_I_SHIFT); - mod_radio_reg(pi, - RADIO_2055_CORE1_RXBB_RSSI_CTRL5, - RADIO_2055_NBRSSI_VCM_Q_MASK, - vcm_buf[2 * core + - 1] << - RADIO_2055_NBRSSI_VCM_Q_SHIFT); - } else { - mod_radio_reg(pi, - RADIO_2055_CORE2_B0_NBRSSI_VCM, - RADIO_2055_NBRSSI_VCM_I_MASK, - vcm_buf[2 * - core] << - RADIO_2055_NBRSSI_VCM_I_SHIFT); - mod_radio_reg(pi, - RADIO_2055_CORE2_RXBB_RSSI_CTRL5, - RADIO_2055_NBRSSI_VCM_Q_MASK, - vcm_buf[2 * core + - 1] << - RADIO_2055_NBRSSI_VCM_Q_SHIFT); - } - } else { - if (core == PHY_CORE_0) - mod_radio_reg(pi, - RADIO_2055_CORE1_RXBB_RSSI_CTRL5, - RADIO_2055_WBRSSI_VCM_IQ_MASK, - vcm_buf[2 * - core] << - RADIO_2055_WBRSSI_VCM_IQ_SHIFT); - else - mod_radio_reg(pi, - RADIO_2055_CORE2_RXBB_RSSI_CTRL5, - RADIO_2055_WBRSSI_VCM_IQ_MASK, - vcm_buf[2 * - core] << - RADIO_2055_WBRSSI_VCM_IQ_SHIFT); - } - } -} - -static void wlc_phy_rssi_cal_nphy_rev3(struct brcms_phy *pi) -{ - u16 classif_state; - u16 clip_state[2]; - u16 clip_off[] = { 0xffff, 0xffff }; - s32 target_code; - u8 vcm, min_vcm; - u8 vcm_final = 0; - u8 result_idx; - s32 poll_results[8][4] = { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - }; - s32 poll_result_core[4] = { 0, 0, 0, 0 }; - s32 min_d = NPHY_RSSICAL_MAXD, curr_d; - s32 fine_digital_offset[4]; - s32 poll_results_min[4] = { 0, 0, 0, 0 }; - s32 min_poll; - u8 vcm_level_max; - u8 core; - u8 wb_cnt; - u8 rssi_type; - u16 NPHY_Rfctrlintc1_save, NPHY_Rfctrlintc2_save; - u16 NPHY_AfectrlOverride1_save, NPHY_AfectrlOverride2_save; - u16 NPHY_AfectrlCore1_save, NPHY_AfectrlCore2_save; - u16 NPHY_RfctrlOverride0_save, NPHY_RfctrlOverride1_save; - u16 NPHY_RfctrlOverrideAux0_save, NPHY_RfctrlOverrideAux1_save; - u16 NPHY_RfctrlCmd_save; - u16 NPHY_RfctrlMiscReg1_save, NPHY_RfctrlMiscReg2_save; - u16 NPHY_RfctrlRSSIOTHERS1_save, NPHY_RfctrlRSSIOTHERS2_save; - u8 rxcore_state; - u16 NPHY_REV7_RfctrlOverride3_save, NPHY_REV7_RfctrlOverride4_save; - u16 NPHY_REV7_RfctrlOverride5_save, NPHY_REV7_RfctrlOverride6_save; - u16 NPHY_REV7_RfctrlMiscReg3_save, NPHY_REV7_RfctrlMiscReg4_save; - u16 NPHY_REV7_RfctrlMiscReg5_save, NPHY_REV7_RfctrlMiscReg6_save; - - NPHY_REV7_RfctrlOverride3_save = - NPHY_REV7_RfctrlOverride4_save = - NPHY_REV7_RfctrlOverride5_save = - NPHY_REV7_RfctrlOverride6_save = - NPHY_REV7_RfctrlMiscReg3_save = - NPHY_REV7_RfctrlMiscReg4_save = - NPHY_REV7_RfctrlMiscReg5_save = - NPHY_REV7_RfctrlMiscReg6_save = 0; - - classif_state = wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); - wlc_phy_clip_det_nphy(pi, 0, clip_state); - wlc_phy_clip_det_nphy(pi, 1, clip_off); - - NPHY_Rfctrlintc1_save = read_phy_reg(pi, 0x91); - NPHY_Rfctrlintc2_save = read_phy_reg(pi, 0x92); - NPHY_AfectrlOverride1_save = read_phy_reg(pi, 0x8f); - NPHY_AfectrlOverride2_save = read_phy_reg(pi, 0xa5); - NPHY_AfectrlCore1_save = read_phy_reg(pi, 0xa6); - NPHY_AfectrlCore2_save = read_phy_reg(pi, 0xa7); - NPHY_RfctrlOverride0_save = read_phy_reg(pi, 0xe7); - NPHY_RfctrlOverride1_save = read_phy_reg(pi, 0xec); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - NPHY_REV7_RfctrlOverride3_save = read_phy_reg(pi, 0x342); - NPHY_REV7_RfctrlOverride4_save = read_phy_reg(pi, 0x343); - NPHY_REV7_RfctrlOverride5_save = read_phy_reg(pi, 0x346); - NPHY_REV7_RfctrlOverride6_save = read_phy_reg(pi, 0x347); - } - NPHY_RfctrlOverrideAux0_save = read_phy_reg(pi, 0xe5); - NPHY_RfctrlOverrideAux1_save = read_phy_reg(pi, 0xe6); - NPHY_RfctrlCmd_save = read_phy_reg(pi, 0x78); - NPHY_RfctrlMiscReg1_save = read_phy_reg(pi, 0xf9); - NPHY_RfctrlMiscReg2_save = read_phy_reg(pi, 0xfb); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - NPHY_REV7_RfctrlMiscReg3_save = read_phy_reg(pi, 0x340); - NPHY_REV7_RfctrlMiscReg4_save = read_phy_reg(pi, 0x341); - NPHY_REV7_RfctrlMiscReg5_save = read_phy_reg(pi, 0x344); - NPHY_REV7_RfctrlMiscReg6_save = read_phy_reg(pi, 0x345); - } - NPHY_RfctrlRSSIOTHERS1_save = read_phy_reg(pi, 0x7a); - NPHY_RfctrlRSSIOTHERS2_save = read_phy_reg(pi, 0x7d); - - wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_OFF, 0, - RADIO_MIMO_CORESEL_ALLRXTX); - wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_TRSW, 1, - RADIO_MIMO_CORESEL_ALLRXTX); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_rxrf_pu, - 0, 0, 0); - else - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0, 0); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_rx_pu, - 1, 0, 0); - else - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0, 0); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), - 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 6), 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 7), 1, 0, 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 6), 1, 0, 0); - } - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 5), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 4), 1, 0, - 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 5), 0, 0, 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 4), 1, 0, 0); - } - - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 4), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 5), 1, 0, - 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 4), 0, 0, 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 5), 1, 0, 0); - } - } - - rxcore_state = wlc_phy_rxcore_getstate_nphy( - (struct brcms_phy_pub *) pi); - - vcm_level_max = 8; - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if ((rxcore_state & (1 << core)) == 0) - continue; - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, - core == - PHY_CORE_0 ? - RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - NPHY_RAIL_I, NPHY_RSSI_SEL_NB); - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, - core == - PHY_CORE_0 ? - RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - NPHY_RAIL_Q, NPHY_RSSI_SEL_NB); - - for (vcm = 0; vcm < vcm_level_max; vcm++) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_radio_reg(pi, (core == PHY_CORE_0) ? - RADIO_2057_NB_MASTER_CORE0 : - RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, vcm); - else - mod_radio_reg(pi, RADIO_2056_RX_RSSI_MISC | - ((core == - PHY_CORE_0) ? RADIO_2056_RX0 : - RADIO_2056_RX1), - RADIO_2056_VCM_MASK, - vcm << RADIO_2056_RSSI_VCM_SHIFT); - - wlc_phy_poll_rssi_nphy(pi, NPHY_RSSI_SEL_NB, - &poll_results[vcm][0], - NPHY_RSSICAL_NPOLL); - } - - for (result_idx = 0; result_idx < 4; result_idx++) { - if ((core == result_idx / 2) && - (result_idx % 2 == 0)) { - - min_d = NPHY_RSSICAL_MAXD; - min_vcm = 0; - min_poll = - NPHY_RSSICAL_MAXREAD * - NPHY_RSSICAL_NPOLL + 1; - for (vcm = 0; vcm < vcm_level_max; vcm++) { - curr_d = - poll_results[vcm][result_idx] * - poll_results[vcm][result_idx] + - poll_results[vcm][result_idx + - 1] * - poll_results[vcm][result_idx + - 1]; - if (curr_d < min_d) { - min_d = curr_d; - min_vcm = vcm; - } - if (poll_results[vcm][result_idx] < - min_poll) - min_poll = - poll_results[vcm] - [result_idx]; - } - vcm_final = min_vcm; - poll_results_min[result_idx] = min_poll; - } - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mod_radio_reg(pi, (core == PHY_CORE_0) ? - RADIO_2057_NB_MASTER_CORE0 : - RADIO_2057_NB_MASTER_CORE1, - RADIO_2057_VCM_MASK, vcm_final); - else - mod_radio_reg(pi, RADIO_2056_RX_RSSI_MISC | - ((core == - PHY_CORE_0) ? RADIO_2056_RX0 : - RADIO_2056_RX1), RADIO_2056_VCM_MASK, - vcm_final << RADIO_2056_RSSI_VCM_SHIFT); - - for (result_idx = 0; result_idx < 4; result_idx++) { - if (core == result_idx / 2) { - fine_digital_offset[result_idx] = - (NPHY_RSSICAL_NB_TARGET * - NPHY_RSSICAL_NPOLL) - - poll_results[vcm_final][result_idx]; - if (fine_digital_offset[result_idx] < 0) { - fine_digital_offset[result_idx] = - abs(fine_digital_offset - [result_idx]); - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= - NPHY_RSSICAL_NPOLL; - fine_digital_offset[result_idx] = - -fine_digital_offset[ - result_idx]; - } else { - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= - NPHY_RSSICAL_NPOLL; - } - - if (poll_results_min[result_idx] == - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) - fine_digital_offset[result_idx] = - (NPHY_RSSICAL_NB_TARGET - - NPHY_RSSICAL_MAXREAD - 1); - - wlc_phy_scale_offset_rssi_nphy( - pi, 0x0, - (s8) - fine_digital_offset - [result_idx], - (result_idx / 2 == 0) ? - RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - (result_idx % 2 == 0) ? - NPHY_RAIL_I : NPHY_RAIL_Q, - NPHY_RSSI_SEL_NB); - } - } - - } - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if ((rxcore_state & (1 << core)) == 0) - continue; - - for (wb_cnt = 0; wb_cnt < 2; wb_cnt++) { - if (wb_cnt == 0) { - rssi_type = NPHY_RSSI_SEL_W1; - target_code = NPHY_RSSICAL_W1_TARGET_REV3; - } else { - rssi_type = NPHY_RSSI_SEL_W2; - target_code = NPHY_RSSICAL_W2_TARGET_REV3; - } - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, - core == - PHY_CORE_0 ? - RADIO_MIMO_CORESEL_CORE1 - : - RADIO_MIMO_CORESEL_CORE2, - NPHY_RAIL_I, rssi_type); - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, - core == - PHY_CORE_0 ? - RADIO_MIMO_CORESEL_CORE1 - : - RADIO_MIMO_CORESEL_CORE2, - NPHY_RAIL_Q, rssi_type); - - wlc_phy_poll_rssi_nphy(pi, rssi_type, poll_result_core, - NPHY_RSSICAL_NPOLL); - - for (result_idx = 0; result_idx < 4; result_idx++) { - if (core == result_idx / 2) { - fine_digital_offset[result_idx] = - (target_code * - NPHY_RSSICAL_NPOLL) - - poll_result_core[result_idx]; - if (fine_digital_offset[result_idx] < - 0) { - fine_digital_offset[result_idx] - = abs( - fine_digital_offset - [result_idx]); - fine_digital_offset[result_idx] - += (NPHY_RSSICAL_NPOLL - / 2); - fine_digital_offset[result_idx] - /= NPHY_RSSICAL_NPOLL; - fine_digital_offset[result_idx] - = -fine_digital_offset - [result_idx]; - } else { - fine_digital_offset[result_idx] - += (NPHY_RSSICAL_NPOLL - / 2); - fine_digital_offset[result_idx] - /= NPHY_RSSICAL_NPOLL; - } - - wlc_phy_scale_offset_rssi_nphy( - pi, 0x0, - (s8) - fine_digital_offset - [core * - 2], - (core == PHY_CORE_0) ? - RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - (result_idx % 2 == 0) ? - NPHY_RAIL_I : - NPHY_RAIL_Q, - rssi_type); - } - } - - } - } - - write_phy_reg(pi, 0x91, NPHY_Rfctrlintc1_save); - write_phy_reg(pi, 0x92, NPHY_Rfctrlintc2_save); - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - - mod_phy_reg(pi, 0xe7, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x78, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0xe7, (0x1 << 0), 0); - - mod_phy_reg(pi, 0xec, (0x1 << 0), 1 << 0); - mod_phy_reg(pi, 0x78, (0x1 << 1), 1 << 1); - mod_phy_reg(pi, 0xec, (0x1 << 0), 0); - - write_phy_reg(pi, 0x8f, NPHY_AfectrlOverride1_save); - write_phy_reg(pi, 0xa5, NPHY_AfectrlOverride2_save); - write_phy_reg(pi, 0xa6, NPHY_AfectrlCore1_save); - write_phy_reg(pi, 0xa7, NPHY_AfectrlCore2_save); - write_phy_reg(pi, 0xe7, NPHY_RfctrlOverride0_save); - write_phy_reg(pi, 0xec, NPHY_RfctrlOverride1_save); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_phy_reg(pi, 0x342, NPHY_REV7_RfctrlOverride3_save); - write_phy_reg(pi, 0x343, NPHY_REV7_RfctrlOverride4_save); - write_phy_reg(pi, 0x346, NPHY_REV7_RfctrlOverride5_save); - write_phy_reg(pi, 0x347, NPHY_REV7_RfctrlOverride6_save); - } - write_phy_reg(pi, 0xe5, NPHY_RfctrlOverrideAux0_save); - write_phy_reg(pi, 0xe6, NPHY_RfctrlOverrideAux1_save); - write_phy_reg(pi, 0x78, NPHY_RfctrlCmd_save); - write_phy_reg(pi, 0xf9, NPHY_RfctrlMiscReg1_save); - write_phy_reg(pi, 0xfb, NPHY_RfctrlMiscReg2_save); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_phy_reg(pi, 0x340, NPHY_REV7_RfctrlMiscReg3_save); - write_phy_reg(pi, 0x341, NPHY_REV7_RfctrlMiscReg4_save); - write_phy_reg(pi, 0x344, NPHY_REV7_RfctrlMiscReg5_save); - write_phy_reg(pi, 0x345, NPHY_REV7_RfctrlMiscReg6_save); - } - write_phy_reg(pi, 0x7a, NPHY_RfctrlRSSIOTHERS1_save); - write_phy_reg(pi, 0x7d, NPHY_RfctrlRSSIOTHERS2_save); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - pi->rssical_cache.rssical_radio_regs_2G[0] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); - pi->rssical_cache.rssical_radio_regs_2G[1] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); - } else { - pi->rssical_cache.rssical_radio_regs_2G[0] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX0); - pi->rssical_cache.rssical_radio_regs_2G[1] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX1); - } - - pi->rssical_cache.rssical_phyregs_2G[0] = - read_phy_reg(pi, 0x1a6); - pi->rssical_cache.rssical_phyregs_2G[1] = - read_phy_reg(pi, 0x1ac); - pi->rssical_cache.rssical_phyregs_2G[2] = - read_phy_reg(pi, 0x1b2); - pi->rssical_cache.rssical_phyregs_2G[3] = - read_phy_reg(pi, 0x1b8); - pi->rssical_cache.rssical_phyregs_2G[4] = - read_phy_reg(pi, 0x1a4); - pi->rssical_cache.rssical_phyregs_2G[5] = - read_phy_reg(pi, 0x1aa); - pi->rssical_cache.rssical_phyregs_2G[6] = - read_phy_reg(pi, 0x1b0); - pi->rssical_cache.rssical_phyregs_2G[7] = - read_phy_reg(pi, 0x1b6); - pi->rssical_cache.rssical_phyregs_2G[8] = - read_phy_reg(pi, 0x1a5); - pi->rssical_cache.rssical_phyregs_2G[9] = - read_phy_reg(pi, 0x1ab); - pi->rssical_cache.rssical_phyregs_2G[10] = - read_phy_reg(pi, 0x1b1); - pi->rssical_cache.rssical_phyregs_2G[11] = - read_phy_reg(pi, 0x1b7); - - pi->nphy_rssical_chanspec_2G = pi->radio_chanspec; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - pi->rssical_cache.rssical_radio_regs_5G[0] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE0); - pi->rssical_cache.rssical_radio_regs_5G[1] = - read_radio_reg(pi, RADIO_2057_NB_MASTER_CORE1); - } else { - pi->rssical_cache.rssical_radio_regs_5G[0] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX0); - pi->rssical_cache.rssical_radio_regs_5G[1] = - read_radio_reg(pi, - RADIO_2056_RX_RSSI_MISC | - RADIO_2056_RX1); - } - - pi->rssical_cache.rssical_phyregs_5G[0] = - read_phy_reg(pi, 0x1a6); - pi->rssical_cache.rssical_phyregs_5G[1] = - read_phy_reg(pi, 0x1ac); - pi->rssical_cache.rssical_phyregs_5G[2] = - read_phy_reg(pi, 0x1b2); - pi->rssical_cache.rssical_phyregs_5G[3] = - read_phy_reg(pi, 0x1b8); - pi->rssical_cache.rssical_phyregs_5G[4] = - read_phy_reg(pi, 0x1a4); - pi->rssical_cache.rssical_phyregs_5G[5] = - read_phy_reg(pi, 0x1aa); - pi->rssical_cache.rssical_phyregs_5G[6] = - read_phy_reg(pi, 0x1b0); - pi->rssical_cache.rssical_phyregs_5G[7] = - read_phy_reg(pi, 0x1b6); - pi->rssical_cache.rssical_phyregs_5G[8] = - read_phy_reg(pi, 0x1a5); - pi->rssical_cache.rssical_phyregs_5G[9] = - read_phy_reg(pi, 0x1ab); - pi->rssical_cache.rssical_phyregs_5G[10] = - read_phy_reg(pi, 0x1b1); - pi->rssical_cache.rssical_phyregs_5G[11] = - read_phy_reg(pi, 0x1b7); - - pi->nphy_rssical_chanspec_5G = pi->radio_chanspec; - } - - wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); - wlc_phy_clip_det_nphy(pi, 1, clip_state); -} - -static void wlc_phy_rssi_cal_nphy_rev2(struct brcms_phy *pi, u8 rssi_type) -{ - s32 target_code; - u16 classif_state; - u16 clip_state[2]; - u16 rssi_ctrl_state[2], pd_state[2]; - u16 rfctrlintc_state[2], rfpdcorerxtx_state[2]; - u16 rfctrlintc_override_val; - u16 clip_off[] = { 0xffff, 0xffff }; - u16 rf_pd_val, pd_mask, rssi_ctrl_mask; - u8 vcm, min_vcm, vcm_tmp[4]; - u8 vcm_final[4] = { 0, 0, 0, 0 }; - u8 result_idx, ctr; - s32 poll_results[4][4] = { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - }; - s32 poll_miniq[4][2] = { - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0} - }; - s32 min_d, curr_d; - s32 fine_digital_offset[4]; - s32 poll_results_min[4] = { 0, 0, 0, 0 }; - s32 min_poll; - - switch (rssi_type) { - case NPHY_RSSI_SEL_NB: - target_code = NPHY_RSSICAL_NB_TARGET; - break; - case NPHY_RSSI_SEL_W1: - target_code = NPHY_RSSICAL_W1_TARGET; - break; - case NPHY_RSSI_SEL_W2: - target_code = NPHY_RSSICAL_W2_TARGET; - break; - default: - return; - break; - } - - classif_state = wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); - wlc_phy_clip_det_nphy(pi, 0, clip_state); - wlc_phy_clip_det_nphy(pi, 1, clip_off); - - rf_pd_val = (rssi_type == NPHY_RSSI_SEL_NB) ? 0x6 : 0x4; - rfctrlintc_override_val = - CHSPEC_IS5G(pi->radio_chanspec) ? 0x140 : 0x110; - - rfctrlintc_state[0] = read_phy_reg(pi, 0x91); - rfpdcorerxtx_state[0] = read_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX); - write_phy_reg(pi, 0x91, rfctrlintc_override_val); - write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rf_pd_val); - - rfctrlintc_state[1] = read_phy_reg(pi, 0x92); - rfpdcorerxtx_state[1] = read_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX); - write_phy_reg(pi, 0x92, rfctrlintc_override_val); - write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rf_pd_val); - - pd_mask = RADIO_2055_NBRSSI_PD | RADIO_2055_WBRSSI_G1_PD | - RADIO_2055_WBRSSI_G2_PD; - pd_state[0] = - read_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC) & pd_mask; - pd_state[1] = - read_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC) & pd_mask; - mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, 0); - mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, 0); - rssi_ctrl_mask = RADIO_2055_NBRSSI_SEL | RADIO_2055_WBRSSI_G1_SEL | - RADIO_2055_WBRSSI_G2_SEL; - rssi_ctrl_state[0] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE1) & rssi_ctrl_mask; - rssi_ctrl_state[1] = - read_radio_reg(pi, RADIO_2055_SP_RSSI_CORE2) & rssi_ctrl_mask; - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_ALLRX, rssi_type); - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, - NPHY_RAIL_I, rssi_type); - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, 0x0, RADIO_MIMO_CORESEL_ALLRX, - NPHY_RAIL_Q, rssi_type); - - for (vcm = 0; vcm < 4; vcm++) { - - vcm_tmp[0] = vcm_tmp[1] = vcm_tmp[2] = vcm_tmp[3] = vcm; - if (rssi_type != NPHY_RSSI_SEL_W2) - wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_tmp); - - wlc_phy_poll_rssi_nphy(pi, rssi_type, &poll_results[vcm][0], - NPHY_RSSICAL_NPOLL); - - if ((rssi_type == NPHY_RSSI_SEL_W1) - || (rssi_type == NPHY_RSSI_SEL_W2)) { - for (ctr = 0; ctr < 2; ctr++) - poll_miniq[vcm][ctr] = - min(poll_results[vcm][ctr * 2 + 0], - poll_results[vcm][ctr * 2 + 1]); - } - } - - for (result_idx = 0; result_idx < 4; result_idx++) { - min_d = NPHY_RSSICAL_MAXD; - min_vcm = 0; - min_poll = NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL + 1; - for (vcm = 0; vcm < 4; vcm++) { - curr_d = abs(((rssi_type == NPHY_RSSI_SEL_NB) ? - poll_results[vcm][result_idx] : - poll_miniq[vcm][result_idx / 2]) - - (target_code * NPHY_RSSICAL_NPOLL)); - if (curr_d < min_d) { - min_d = curr_d; - min_vcm = vcm; - } - if (poll_results[vcm][result_idx] < min_poll) - min_poll = poll_results[vcm][result_idx]; - } - vcm_final[result_idx] = min_vcm; - poll_results_min[result_idx] = min_poll; - } - - if (rssi_type != NPHY_RSSI_SEL_W2) - wlc_phy_set_rssi_2055_vcm(pi, rssi_type, vcm_final); - - for (result_idx = 0; result_idx < 4; result_idx++) { - fine_digital_offset[result_idx] = - (target_code * NPHY_RSSICAL_NPOLL) - - poll_results[vcm_final[result_idx]][result_idx]; - if (fine_digital_offset[result_idx] < 0) { - fine_digital_offset[result_idx] = - abs(fine_digital_offset[result_idx]); - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; - fine_digital_offset[result_idx] = - -fine_digital_offset[result_idx]; - } else { - fine_digital_offset[result_idx] += - (NPHY_RSSICAL_NPOLL / 2); - fine_digital_offset[result_idx] /= NPHY_RSSICAL_NPOLL; - } - - if (poll_results_min[result_idx] == - NPHY_RSSICAL_MAXREAD * NPHY_RSSICAL_NPOLL) - fine_digital_offset[result_idx] = - (target_code - NPHY_RSSICAL_MAXREAD - 1); - - wlc_phy_scale_offset_rssi_nphy(pi, 0x0, - (s8) - fine_digital_offset[result_idx], - (result_idx / 2 == - 0) ? RADIO_MIMO_CORESEL_CORE1 : - RADIO_MIMO_CORESEL_CORE2, - (result_idx % 2 == - 0) ? NPHY_RAIL_I : NPHY_RAIL_Q, - rssi_type); - } - - mod_radio_reg(pi, RADIO_2055_PD_CORE1_RSSI_MISC, pd_mask, pd_state[0]); - mod_radio_reg(pi, RADIO_2055_PD_CORE2_RSSI_MISC, pd_mask, pd_state[1]); - if (rssi_ctrl_state[0] == RADIO_2055_NBRSSI_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_NB); - else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G1_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W1); - else if (rssi_ctrl_state[0] == RADIO_2055_WBRSSI_G2_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W2); - else - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE1, - NPHY_RSSI_SEL_W2); - if (rssi_ctrl_state[1] == RADIO_2055_NBRSSI_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_NB); - else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G1_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W1); - else if (rssi_ctrl_state[1] == RADIO_2055_WBRSSI_G2_SEL) - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W2); - else - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_CORE2, - NPHY_RSSI_SEL_W2); - - wlc_phy_rssisel_nphy(pi, RADIO_MIMO_CORESEL_OFF, rssi_type); - - write_phy_reg(pi, 0x91, rfctrlintc_state[0]); - write_radio_reg(pi, RADIO_2055_PD_CORE1_RXTX, rfpdcorerxtx_state[0]); - write_phy_reg(pi, 0x92, rfctrlintc_state[1]); - write_radio_reg(pi, RADIO_2055_PD_CORE2_RXTX, rfpdcorerxtx_state[1]); - - wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); - wlc_phy_clip_det_nphy(pi, 1, clip_state); - - wlc_phy_resetcca_nphy(pi); -} - -void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi) -{ - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_rssi_cal_nphy_rev3(pi); - } else { - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_NB); - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W1); - wlc_phy_rssi_cal_nphy_rev2(pi, NPHY_RSSI_SEL_W2); - } -} - -int -wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh) -{ - s16 rxpwr, rxpwr0, rxpwr1; - s16 phyRx0_l, phyRx2_l; - - rxpwr = 0; - rxpwr0 = rxh->PhyRxStatus_1 & PRXS1_nphy_PWR0_MASK; - rxpwr1 = (rxh->PhyRxStatus_1 & PRXS1_nphy_PWR1_MASK) >> 8; - - if (rxpwr0 > 127) - rxpwr0 -= 256; - if (rxpwr1 > 127) - rxpwr1 -= 256; - - phyRx0_l = rxh->PhyRxStatus_0 & 0x00ff; - phyRx2_l = rxh->PhyRxStatus_2 & 0x00ff; - if (phyRx2_l > 127) - phyRx2_l -= 256; - - if (((rxpwr0 == 16) || (rxpwr0 == 32))) { - rxpwr0 = rxpwr1; - rxpwr1 = phyRx2_l; - } - - if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MAX) - rxpwr = (rxpwr0 > rxpwr1) ? rxpwr0 : rxpwr1; - else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_MIN) - rxpwr = (rxpwr0 < rxpwr1) ? rxpwr0 : rxpwr1; - else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_AVG) - rxpwr = (rxpwr0 + rxpwr1) >> 1; - - return rxpwr; -} - -static void -wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, - u16 num_samps) -{ - u16 t; - u32 *data_buf = NULL; - - data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); - if (data_buf == NULL) - return; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - for (t = 0; t < num_samps; t++) - data_buf[t] = ((((unsigned int)tone_buf[t].i) & 0x3ff) << 10) | - (((unsigned int)tone_buf[t].q) & 0x3ff); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, - data_buf); - - kfree(data_buf); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static u16 -wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, - u8 dac_test_mode) -{ - u8 phy_bw, is_phybw40; - u16 num_samps, t, spur; - s32 theta = 0, rot = 0; - u32 tbl_len; - struct cordic_iq *tone_buf = NULL; - - is_phybw40 = CHSPEC_IS40(pi->radio_chanspec); - phy_bw = (is_phybw40 == 1) ? 40 : 20; - tbl_len = (phy_bw << 3); - - if (dac_test_mode == 1) { - spur = read_phy_reg(pi, 0x01); - spur = (spur >> 15) & 1; - phy_bw = (spur == 1) ? 82 : 80; - phy_bw = (is_phybw40 == 1) ? (phy_bw << 1) : phy_bw; - - tbl_len = (phy_bw << 1); - } - - tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC); - if (tone_buf == NULL) - return 0; - - num_samps = (u16) tbl_len; - rot = ((f_kHz * 36) / phy_bw) / 100; - theta = 0; - - for (t = 0; t < num_samps; t++) { - - tone_buf[t] = cordic_calc_iq(theta); - - theta += rot; - - tone_buf[t].q = (s32) FLOAT(tone_buf[t].q * max_val); - tone_buf[t].i = (s32) FLOAT(tone_buf[t].i * max_val); - } - - wlc_phy_loadsampletable_nphy(pi, tone_buf, num_samps); - - kfree(tone_buf); - - return num_samps; -} - -static void -wlc_phy_runsamples_nphy(struct brcms_phy *pi, u16 num_samps, u16 loops, - u16 wait, u8 iqmode, u8 dac_test_mode, - bool modify_bbmult) -{ - u16 bb_mult; - u8 phy_bw, sample_cmd; - u16 orig_RfseqCoreActv; - u16 lpf_bw_ctl_override3, lpf_bw_ctl_override4, lpf_bw_ctl_miscreg3, - lpf_bw_ctl_miscreg4; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - phy_bw = 20; - if (CHSPEC_IS40(pi->radio_chanspec)) - phy_bw = 40; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - lpf_bw_ctl_override3 = read_phy_reg(pi, 0x342) & (0x1 << 7); - lpf_bw_ctl_override4 = read_phy_reg(pi, 0x343) & (0x1 << 7); - if (lpf_bw_ctl_override3 | lpf_bw_ctl_override4) { - lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) & - (0x7 << 8); - lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) & - (0x7 << 8); - } else { - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, - 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - pi->nphy_sample_play_lpf_bw_ctl_ovr = true; - - lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) & - (0x7 << 8); - lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) & - (0x7 << 8); - } - } - - if ((pi->nphy_bb_mult_save & BB_MULT_VALID_MASK) == 0) { - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, 87, 16, - &bb_mult); - pi->nphy_bb_mult_save = - BB_MULT_VALID_MASK | (bb_mult & BB_MULT_MASK); - } - - if (modify_bbmult) { - bb_mult = (phy_bw == 20) ? 100 : 71; - bb_mult = (bb_mult << 8) + bb_mult; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, 87, 16, - &bb_mult); - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - write_phy_reg(pi, 0xc6, num_samps - 1); - - if (loops != 0xffff) - write_phy_reg(pi, 0xc4, loops - 1); - else - write_phy_reg(pi, 0xc4, loops); - - write_phy_reg(pi, 0xc5, wait); - - orig_RfseqCoreActv = read_phy_reg(pi, 0xa1); - or_phy_reg(pi, 0xa1, NPHY_RfseqMode_CoreActv_override); - if (iqmode) { - - and_phy_reg(pi, 0xc2, 0x7FFF); - - or_phy_reg(pi, 0xc2, 0x8000); - } else { - - sample_cmd = (dac_test_mode == 1) ? 0x5 : 0x1; - write_phy_reg(pi, 0xc3, sample_cmd); - } - - SPINWAIT(((read_phy_reg(pi, 0xa4) & 0x1) == 1), 1000); - - write_phy_reg(pi, 0xa1, orig_RfseqCoreActv); -} - -int -wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, - u8 iqmode, u8 dac_test_mode, bool modify_bbmult) -{ - u16 num_samps; - u16 loops = 0xffff; - u16 wait = 0; - - num_samps = wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, - dac_test_mode); - if (num_samps == 0) - return -EBADE; - - wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode, - dac_test_mode, modify_bbmult); - - return 0; -} - -void wlc_phy_stopplayback_nphy(struct brcms_phy *pi) -{ - u16 playback_status; - u16 bb_mult; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - playback_status = read_phy_reg(pi, 0xc7); - if (playback_status & 0x1) - or_phy_reg(pi, 0xc3, NPHY_sampleCmd_STOP); - else if (playback_status & 0x2) - and_phy_reg(pi, 0xc2, - (u16) ~NPHY_iqloCalCmdGctl_IQLO_CAL_EN); - - and_phy_reg(pi, 0xc3, (u16) ~(0x1 << 2)); - - if ((pi->nphy_bb_mult_save & BB_MULT_VALID_MASK) != 0) { - - bb_mult = pi->nphy_bb_mult_save & BB_MULT_MASK; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, 87, 16, - &bb_mult); - - pi->nphy_bb_mult_save = 0; - } - - if (NREV_IS(pi->pubpi.phy_rev, 7) || NREV_GE(pi->pubpi.phy_rev, 8)) { - if (pi->nphy_sample_play_lpf_bw_ctl_ovr) { - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 7), - 0, 0, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - pi->nphy_sample_play_lpf_bw_ctl_ovr = false; - } - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static u32 *brcms_phy_get_tx_pwrctrl_tbl(struct brcms_phy *pi) -{ - u32 *tx_pwrctrl_tbl = NULL; - uint phyrev = pi->pubpi.phy_rev; - - if (PHY_IPA(pi)) { - tx_pwrctrl_tbl = - wlc_phy_get_ipa_gaintbl_nphy(pi); - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(phyrev, 3)) - tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev3; - else if (NREV_IS(phyrev, 4)) - tx_pwrctrl_tbl = - (pi->srom_fem5g.extpagain == 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA : - nphy_tpc_5GHz_txgain_rev4; - else - tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev5; - } else { - if (NREV_GE(phyrev, 7)) { - if (pi->pubpi.radiorev == 3) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev3; - else if (pi->pubpi.radiorev == 5) - tx_pwrctrl_tbl = - nphy_tpc_txgain_epa_2057rev5; - } else { - if (NREV_GE(phyrev, 5) && - (pi->srom_fem2g.extpagain == 3)) - tx_pwrctrl_tbl = - nphy_tpc_txgain_HiPwrEPA; - else - tx_pwrctrl_tbl = - nphy_tpc_txgain_rev3; - } - } - } - return tx_pwrctrl_tbl; -} - -struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi) -{ - u16 base_idx[2], curr_gain[2]; - u8 core_no; - struct nphy_txgains target_gain; - u32 *tx_pwrctrl_tbl = NULL; - - if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) { - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - curr_gain); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - for (core_no = 0; core_no < 2; core_no++) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - target_gain.ipa[core_no] = - curr_gain[core_no] & 0x0007; - target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x00F8) >> 3); - target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0F00) >> 8); - target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x7000) >> 12); - target_gain.txlpf[core_no] = - ((curr_gain[core_no] & 0x8000) >> 15); - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - target_gain.ipa[core_no] = - curr_gain[core_no] & 0x000F; - target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x00F0) >> 4); - target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0F00) >> 8); - target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x7000) >> 12); - } else { - target_gain.ipa[core_no] = - curr_gain[core_no] & 0x0003; - target_gain.pad[core_no] = - ((curr_gain[core_no] & 0x000C) >> 2); - target_gain.pga[core_no] = - ((curr_gain[core_no] & 0x0070) >> 4); - target_gain.txgm[core_no] = - ((curr_gain[core_no] & 0x0380) >> 7); - } - } - } else { - uint phyrev = pi->pubpi.phy_rev; - - base_idx[0] = (read_phy_reg(pi, 0x1ed) >> 8) & 0x7f; - base_idx[1] = (read_phy_reg(pi, 0x1ee) >> 8) & 0x7f; - for (core_no = 0; core_no < 2; core_no++) { - if (NREV_GE(phyrev, 3)) { - tx_pwrctrl_tbl = - brcms_phy_get_tx_pwrctrl_tbl(pi); - if (NREV_GE(phyrev, 7)) { - target_gain.ipa[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 16) & 0x7; - target_gain.pad[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 19) & 0x1f; - target_gain.pga[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 24) & 0xf; - target_gain.txgm[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 28) & 0x7; - target_gain.txlpf[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 31) & 0x1; - } else { - target_gain.ipa[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 16) & 0xf; - target_gain.pad[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 20) & 0xf; - target_gain.pga[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 24) & 0xf; - target_gain.txgm[core_no] = - (tx_pwrctrl_tbl - [base_idx[core_no]] - >> 28) & 0x7; - } - } else { - target_gain.ipa[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> - 16) & 0x3; - target_gain.pad[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> - 18) & 0x3; - target_gain.pga[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> - 20) & 0x7; - target_gain.txgm[core_no] = - (nphy_tpc_txgain[base_idx[core_no]] >> - 23) & 0x7; - } - } - } - - return target_gain; -} - -static void -wlc_phy_iqcal_gainparams_nphy(struct brcms_phy *pi, u16 core_no, - struct nphy_txgains target_gain, - struct nphy_iqcal_params *params) -{ - u8 k; - int idx; - u16 gain_index; - u8 band_idx = (CHSPEC_IS5G(pi->radio_chanspec) ? 1 : 0); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) - params->txlpf = target_gain.txlpf[core_no]; - - params->txgm = target_gain.txgm[core_no]; - params->pga = target_gain.pga[core_no]; - params->pad = target_gain.pad[core_no]; - params->ipa = target_gain.ipa[core_no]; - if (NREV_GE(pi->pubpi.phy_rev, 7)) - params->cal_gain = - ((params->txlpf << 15) | (params->txgm << 12) | - (params->pga << 8) | - (params->pad << 3) | (params->ipa)); - else - params->cal_gain = - ((params->txgm << 12) | (params->pga << 8) | - (params->pad << 4) | (params->ipa)); - - params->ncorr[0] = 0x79; - params->ncorr[1] = 0x79; - params->ncorr[2] = 0x79; - params->ncorr[3] = 0x79; - params->ncorr[4] = 0x79; - } else { - - gain_index = ((target_gain.pad[core_no] << 0) | - (target_gain.pga[core_no] << 4) | - (target_gain.txgm[core_no] << 8)); - - idx = -1; - for (k = 0; k < NPHY_IQCAL_NUMGAINS; k++) { - if (tbl_iqcal_gainparams_nphy[band_idx][k][0] == - gain_index) { - idx = k; - break; - } - } - - params->txgm = tbl_iqcal_gainparams_nphy[band_idx][k][1]; - params->pga = tbl_iqcal_gainparams_nphy[band_idx][k][2]; - params->pad = tbl_iqcal_gainparams_nphy[band_idx][k][3]; - params->cal_gain = ((params->txgm << 7) | (params->pga << 4) | - (params->pad << 2)); - params->ncorr[0] = tbl_iqcal_gainparams_nphy[band_idx][k][4]; - params->ncorr[1] = tbl_iqcal_gainparams_nphy[band_idx][k][5]; - params->ncorr[2] = tbl_iqcal_gainparams_nphy[band_idx][k][6]; - params->ncorr[3] = tbl_iqcal_gainparams_nphy[band_idx][k][7]; - } -} - -static void wlc_phy_txcal_radio_setup_nphy(struct brcms_phy *pi) -{ - u16 jtag_core, core; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - for (core = 0; core <= 1; core++) { - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 0] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 1] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_VCM_HG); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 2] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_IDAC); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 3] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_VCM); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 4] = 0; - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 5] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MUX); - - if (pi->pubpi.radiorev != 5) - pi->tx_rx_cal_radio_saveregs[(core * 11) + 6] = - READ_RADIO_REG3(pi, RADIO_2057, TX, - core, - TSSIA); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 7] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 8] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_MISC1); - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x0a); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_VCM_HG, 0x43); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_IDAC, 0x55); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_VCM, 0x00); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSIG, 0x00); - if (pi->use_int_tx_iqlo_cal_nphy) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TX_SSI_MUX, 0x4); - if (!(pi-> - internal_tx_iqlo_cal_tapoff_intpa_nphy)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x31); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIA, 0x21); - } - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_MISC1, 0x00); - } else { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, 0x06); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_VCM_HG, 0x43); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - IQCAL_IDAC, 0x55); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_VCM, 0x00); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TSSIA, 0x00); - if (pi->use_int_tx_iqlo_cal_nphy) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, - core, TX_SSI_MUX, - 0x06); - if (!(pi-> - internal_tx_iqlo_cal_tapoff_intpa_nphy)) - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIG, 0x31); - else - WRITE_RADIO_REG3(pi, RADIO_2057, - TX, core, - TSSIG, 0x21); - } - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSI_MISC1, 0x00); - } - } - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - for (core = 0; core <= 1; core++) { - jtag_core = - (core == - PHY_CORE_0) ? RADIO_2056_TX0 : RADIO_2056_TX1; - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 0] = - read_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MASTER | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 1] = - read_radio_reg(pi, - RADIO_2056_TX_IQCAL_VCM_HG | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 2] = - read_radio_reg(pi, - RADIO_2056_TX_IQCAL_IDAC | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 3] = - read_radio_reg( - pi, - RADIO_2056_TX_TSSI_VCM | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 4] = - read_radio_reg(pi, - RADIO_2056_TX_TX_AMP_DET | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 5] = - read_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 6] = - read_radio_reg(pi, - RADIO_2056_TX_TSSIA | jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 7] = - read_radio_reg(pi, - RADIO_2056_TX_TSSIG | jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 8] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC1 | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 9] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC2 | - jtag_core); - - pi->tx_rx_cal_radio_saveregs[(core * 11) + 10] = - read_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC3 | - jtag_core); - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MASTER | - jtag_core, 0x0a); - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_VCM_HG | - jtag_core, 0x40); - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_IDAC | - jtag_core, 0x55); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_VCM | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TX_AMP_DET | - jtag_core, 0x00); - - if (PHY_IPA(pi)) { - write_radio_reg( - pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x4); - write_radio_reg(pi, - RADIO_2056_TX_TSSIA | - jtag_core, 0x1); - } else { - write_radio_reg( - pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSIA | - jtag_core, 0x2f); - } - write_radio_reg(pi, - RADIO_2056_TX_TSSIG | jtag_core, - 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC1 | - jtag_core, 0x00); - - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC2 | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC3 | - jtag_core, 0x00); - } else { - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MASTER | - jtag_core, 0x06); - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_VCM_HG | - jtag_core, 0x40); - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_IDAC | - jtag_core, 0x55); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_VCM | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TX_AMP_DET | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSIA | jtag_core, - 0x00); - - if (PHY_IPA(pi)) { - - write_radio_reg( - pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x06); - if (NREV_LT(pi->pubpi.phy_rev, 5)) - write_radio_reg( - pi, - RADIO_2056_TX_TSSIG - | jtag_core, - 0x11); - else - write_radio_reg( - pi, - RADIO_2056_TX_TSSIG - | jtag_core, - 0x1); - } else { - write_radio_reg( - pi, - RADIO_2056_TX_TX_SSI_MUX - | jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSIG | - jtag_core, 0x20); - } - - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC1 | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC2 | - jtag_core, 0x00); - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC3 | - jtag_core, 0x00); - } - } - } else { - - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1, 0x29); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2, 0x54); - - pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1, 0x29); - pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2, 0x54); - - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1); - pi->tx_rx_cal_radio_saveregs[5] = - read_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2); - - if ((read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand) == - 0) { - - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1, 0x04); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2, 0x04); - } else { - - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1, 0x20); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2, 0x20); - } - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - - or_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, 0x20); - or_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, 0x20); - } else { - - and_radio_reg(pi, RADIO_2055_CORE1_TX_BB_MXGM, 0xdf); - and_radio_reg(pi, RADIO_2055_CORE2_TX_BB_MXGM, 0xdf); - } - } -} - -static void wlc_phy_txcal_radio_cleanup_nphy(struct brcms_phy *pi) -{ - u16 jtag_core, core; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - for (core = 0; core <= 1; core++) { - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TX_SSI_MASTER, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 0]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_VCM_HG, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 1]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, IQCAL_IDAC, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 2]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_VCM, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 3]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TX_SSI_MUX, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 5]); - - if (pi->pubpi.radiorev != 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TSSIA, - pi->tx_rx_cal_radio_saveregs - [(core * 11) + 6]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSIG, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 7]); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, TSSI_MISC1, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 8]); - } - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { - for (core = 0; core <= 1; core++) { - jtag_core = (core == PHY_CORE_0) ? - RADIO_2056_TX0 : RADIO_2056_TX1; - - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MASTER | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 0]); - - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_VCM_HG | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 1]); - - write_radio_reg(pi, - RADIO_2056_TX_IQCAL_IDAC | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 2]); - - write_radio_reg(pi, RADIO_2056_TX_TSSI_VCM | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 3]); - - write_radio_reg(pi, - RADIO_2056_TX_TX_AMP_DET | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 4]); - - write_radio_reg(pi, - RADIO_2056_TX_TX_SSI_MUX | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 5]); - - write_radio_reg(pi, RADIO_2056_TX_TSSIA | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 6]); - - write_radio_reg(pi, RADIO_2056_TX_TSSIG | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 7]); - - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC1 | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 8]); - - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC2 | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 9]); - - write_radio_reg(pi, - RADIO_2056_TX_TSSI_MISC3 | jtag_core, - pi-> - tx_rx_cal_radio_saveregs[(core * 11) + - 10]); - } - } else { - - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL1, - pi->tx_rx_cal_radio_saveregs[0]); - write_radio_reg(pi, RADIO_2055_CORE1_TXRF_IQCAL2, - pi->tx_rx_cal_radio_saveregs[1]); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL1, - pi->tx_rx_cal_radio_saveregs[2]); - write_radio_reg(pi, RADIO_2055_CORE2_TXRF_IQCAL2, - pi->tx_rx_cal_radio_saveregs[3]); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE1, - pi->tx_rx_cal_radio_saveregs[4]); - write_radio_reg(pi, RADIO_2055_PWRDET_RXTX_CORE2, - pi->tx_rx_cal_radio_saveregs[5]); - } -} - -static void wlc_phy_txcal_physetup_nphy(struct brcms_phy *pi) -{ - u16 val, mask; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - pi->tx_rx_cal_phy_saveregs[0] = read_phy_reg(pi, 0xa6); - pi->tx_rx_cal_phy_saveregs[1] = read_phy_reg(pi, 0xa7); - - mask = ((0x3 << 8) | (0x3 << 10)); - val = (0x2 << 8); - val |= (0x2 << 10); - mod_phy_reg(pi, 0xa6, mask, val); - mod_phy_reg(pi, 0xa7, mask, val); - - val = read_phy_reg(pi, 0x8f); - pi->tx_rx_cal_phy_saveregs[2] = val; - val |= ((0x1 << 9) | (0x1 << 10)); - write_phy_reg(pi, 0x8f, val); - - val = read_phy_reg(pi, 0xa5); - pi->tx_rx_cal_phy_saveregs[3] = val; - val |= ((0x1 << 9) | (0x1 << 10)); - write_phy_reg(pi, 0xa5, val); - - pi->tx_rx_cal_phy_saveregs[4] = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 3, 16, - &val); - pi->tx_rx_cal_phy_saveregs[5] = val; - val = 0; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 3, 16, - &val); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 19, 16, - &val); - pi->tx_rx_cal_phy_saveregs[6] = val; - val = 0; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 19, 16, - &val); - - pi->tx_rx_cal_phy_saveregs[7] = read_phy_reg(pi, 0x91); - pi->tx_rx_cal_phy_saveregs[8] = read_phy_reg(pi, 0x92); - - if (!(pi->use_int_tx_iqlo_cal_nphy)) - wlc_phy_rfctrlintc_override_nphy( - pi, - NPHY_RfctrlIntc_override_PA, - 1, - RADIO_MIMO_CORESEL_CORE1 - | - RADIO_MIMO_CORESEL_CORE2); - else - wlc_phy_rfctrlintc_override_nphy( - pi, - NPHY_RfctrlIntc_override_PA, - 0, - RADIO_MIMO_CORESEL_CORE1 - | - RADIO_MIMO_CORESEL_CORE2); - - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x2, RADIO_MIMO_CORESEL_CORE1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x8, RADIO_MIMO_CORESEL_CORE2); - - pi->tx_rx_cal_phy_saveregs[9] = read_phy_reg(pi, 0x297); - pi->tx_rx_cal_phy_saveregs[10] = read_phy_reg(pi, 0x29b); - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, - 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - if (pi->use_int_tx_iqlo_cal_nphy - && !(pi->internal_tx_iqlo_cal_tapoff_intpa_nphy)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - - mod_radio_reg(pi, RADIO_2057_OVR_REG0, 1 << 4, - 1 << 4); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_radio_reg( - pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - 1, 0); - mod_radio_reg( - pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - 1, 0); - } else { - mod_radio_reg( - pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, - 1, 0); - mod_radio_reg( - pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, - 1, 0); - } - } else if (NREV_GE(pi->pubpi.phy_rev, 8)) { - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 3), 0, - 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - } - } - } else { - pi->tx_rx_cal_phy_saveregs[0] = read_phy_reg(pi, 0xa6); - pi->tx_rx_cal_phy_saveregs[1] = read_phy_reg(pi, 0xa7); - - mask = ((0x3 << 12) | (0x3 << 14)); - val = (0x2 << 12); - val |= (0x2 << 14); - mod_phy_reg(pi, 0xa6, mask, val); - mod_phy_reg(pi, 0xa7, mask, val); - - val = read_phy_reg(pi, 0xa5); - pi->tx_rx_cal_phy_saveregs[2] = val; - val |= ((0x1 << 12) | (0x1 << 13)); - write_phy_reg(pi, 0xa5, val); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 2, 16, - &val); - pi->tx_rx_cal_phy_saveregs[3] = val; - val |= 0x2000; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 2, 16, - &val); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 18, 16, - &val); - pi->tx_rx_cal_phy_saveregs[4] = val; - val |= 0x2000; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 18, 16, - &val); - - pi->tx_rx_cal_phy_saveregs[5] = read_phy_reg(pi, 0x91); - pi->tx_rx_cal_phy_saveregs[6] = read_phy_reg(pi, 0x92); - val = CHSPEC_IS5G(pi->radio_chanspec) ? 0x180 : 0x120; - write_phy_reg(pi, 0x91, val); - write_phy_reg(pi, 0x92, val); - } -} - -static void wlc_phy_txcal_phycleanup_nphy(struct brcms_phy *pi) -{ - u16 mask; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - write_phy_reg(pi, 0xa6, pi->tx_rx_cal_phy_saveregs[0]); - write_phy_reg(pi, 0xa7, pi->tx_rx_cal_phy_saveregs[1]); - write_phy_reg(pi, 0x8f, pi->tx_rx_cal_phy_saveregs[2]); - write_phy_reg(pi, 0xa5, pi->tx_rx_cal_phy_saveregs[3]); - write_phy_reg(pi, 0x01, pi->tx_rx_cal_phy_saveregs[4]); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 3, 16, - &pi->tx_rx_cal_phy_saveregs[5]); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 19, 16, - &pi->tx_rx_cal_phy_saveregs[6]); - - write_phy_reg(pi, 0x91, pi->tx_rx_cal_phy_saveregs[7]); - write_phy_reg(pi, 0x92, pi->tx_rx_cal_phy_saveregs[8]); - - write_phy_reg(pi, 0x297, pi->tx_rx_cal_phy_saveregs[9]); - write_phy_reg(pi, 0x29b, pi->tx_rx_cal_phy_saveregs[10]); - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), 0, 0, - 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - wlc_phy_resetcca_nphy(pi); - - if (pi->use_int_tx_iqlo_cal_nphy - && !(pi->internal_tx_iqlo_cal_tapoff_intpa_nphy)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - mod_radio_reg( - pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE0, - 1, 1); - mod_radio_reg( - pi, - RADIO_2057_PAD2G_TUNE_PUS_CORE1, - 1, 1); - } else { - mod_radio_reg( - pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE0, - 1, 1); - mod_radio_reg( - pi, - RADIO_2057_IPA5G_CASCOFFV_PU_CORE1, - 1, 1); - } - - mod_radio_reg(pi, RADIO_2057_OVR_REG0, 1 << 4, - 0); - } else if (NREV_GE(pi->pubpi.phy_rev, 8)) { - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 3), 0, - 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - } - } - } else { - mask = ((0x3 << 12) | (0x3 << 14)); - mod_phy_reg(pi, 0xa6, mask, pi->tx_rx_cal_phy_saveregs[0]); - mod_phy_reg(pi, 0xa7, mask, pi->tx_rx_cal_phy_saveregs[1]); - write_phy_reg(pi, 0xa5, pi->tx_rx_cal_phy_saveregs[2]); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 2, 16, - &pi->tx_rx_cal_phy_saveregs[3]); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 18, 16, - &pi->tx_rx_cal_phy_saveregs[4]); - - write_phy_reg(pi, 0x91, pi->tx_rx_cal_phy_saveregs[5]); - write_phy_reg(pi, 0x92, pi->tx_rx_cal_phy_saveregs[6]); - } -} - -void -wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf, u8 num_samps) -{ - u16 tssi_reg; - s32 temp, pwrindex[2]; - s32 idle_tssi[2]; - s32 rssi_buf[4]; - s32 tssival[2]; - u8 tssi_type; - - tssi_reg = read_phy_reg(pi, 0x1e9); - - temp = (s32) (tssi_reg & 0x3f); - idle_tssi[0] = (temp <= 31) ? temp : (temp - 64); - - temp = (s32) ((tssi_reg >> 8) & 0x3f); - idle_tssi[1] = (temp <= 31) ? temp : (temp - 64); - - tssi_type = - CHSPEC_IS5G(pi->radio_chanspec) ? - (u8)NPHY_RSSI_SEL_TSSI_5G : (u8)NPHY_RSSI_SEL_TSSI_2G; - - wlc_phy_poll_rssi_nphy(pi, tssi_type, rssi_buf, num_samps); - - tssival[0] = rssi_buf[0] / ((s32) num_samps); - tssival[1] = rssi_buf[2] / ((s32) num_samps); - - pwrindex[0] = idle_tssi[0] - tssival[0] + 64; - pwrindex[1] = idle_tssi[1] - tssival[1] + 64; - - if (pwrindex[0] < 0) - pwrindex[0] = 0; - else if (pwrindex[0] > 63) - pwrindex[0] = 63; - - if (pwrindex[1] < 0) - pwrindex[1] = 0; - else if (pwrindex[1] > 63) - pwrindex[1] = 63; - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 1, - (u32) pwrindex[0], 32, &qdBm_pwrbuf[0]); - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 1, - (u32) pwrindex[1], 32, &qdBm_pwrbuf[1]); -} - -static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) -{ - int index; - u32 bbmult_scale; - u16 bbmult; - u16 tblentry; - - struct nphy_txiqcal_ladder ladder_lo[] = { - {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, - {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5}, - {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7} - }; - - struct nphy_txiqcal_ladder ladder_iq[] = { - {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, - {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1}, - {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7} - }; - - bbmult = (core == PHY_CORE_0) ? - ((pi->nphy_txcal_bbmult >> 8) & 0xff) : - (pi->nphy_txcal_bbmult & 0xff); - - for (index = 0; index < 18; index++) { - bbmult_scale = ladder_lo[index].percent * bbmult; - bbmult_scale /= 100; - - tblentry = - ((bbmult_scale & 0xff) << 8) | ladder_lo[index].g_env; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, index, 16, - &tblentry); - - bbmult_scale = ladder_iq[index].percent * bbmult; - bbmult_scale /= 100; - - tblentry = - ((bbmult_scale & 0xff) << 8) | ladder_iq[index].g_env; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 1, index + 32, - 16, &tblentry); - } -} - -static u8 wlc_phy_txpwr_idx_cur_get_nphy(struct brcms_phy *pi, u8 core) -{ - u16 tmp; - tmp = read_phy_reg(pi, ((core == PHY_CORE_0) ? 0x1ed : 0x1ee)); - - tmp = (tmp & (0x7f << 8)) >> 8; - return (u8) tmp; -} - -static void -wlc_phy_txpwr_idx_cur_set_nphy(struct brcms_phy *pi, u8 idx0, u8 idx1) -{ - mod_phy_reg(pi, 0x1e7, (0x7f << 0), idx0); - - if (NREV_GT(pi->pubpi.phy_rev, 1)) - mod_phy_reg(pi, 0x222, (0xff << 0), idx1); -} - -static u16 wlc_phy_ipa_get_bbmult_nphy(struct brcms_phy *pi) -{ - u16 m0m1; - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m0m1); - - return m0m1; -} - -static void wlc_phy_ipa_set_bbmult_nphy(struct brcms_phy *pi, u8 m0, u8 m1) -{ - u16 m0m1 = (u16) ((m0 << 8) | m1); - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m0m1); - wlc_phy_table_write_nphy(pi, 15, 1, 95, 16, &m0m1); -} - -static void -wlc_phy_papd_cal_setup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state, u8 core) -{ - s32 tone_freq; - u8 off_core; - u16 mixgain = 0; - - off_core = core ^ 0x1; - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), - wlc_phy_read_lpf_bw_ctl_nphy - (pi, - 0), 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 5) - mixgain = (core == 0) ? 0x20 : 0x00; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - mixgain = 0x00; - else if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) - mixgain = 0x00; - } else { - if ((pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - mixgain = 0x50; - else if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - mixgain = 0x0; - } - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), - mixgain, (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 1, (1 << core), 0); - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_tx_pu, - 0, (1 << off_core), 0); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), - 0, (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, - (1 << core), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7); - state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); - state->afectrl[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa7 : 0xa6); - state->afeoverride[off_core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0xa5 : 0x8f); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), - (0x1 << 2), 0); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), (0x1 << 2), (0x1 << 2)); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa7 : 0xa6), - (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa5 : - 0x8f), (0x1 << 2), (0x1 << 2)); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP); - state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN); - state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_PWRUP); - state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_ATTEN); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP, 0xc); - - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, 0xf0); - else if (pi->pubpi.radiorev == 5) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, - (core == 0) ? 0xf7 : 0xf2); - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, 0xf0); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_PWRUP, 0x0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_2G_ATTEN, 0xff); - } else { - state->pwrup[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP); - state->atten[core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN); - state->pwrup[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_PWRUP); - state->atten[off_core] = - READ_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_ATTEN); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP, 0xc); - - if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, 0xf4); - - else - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, 0xf0); - - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_PWRUP, 0x0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core, - TXRXCOUPLE_5G_ATTEN, 0xff); - } - - tone_freq = 4000; - - wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_OFF) << 0); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - } else { - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 1, 0x3, 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 1, 0x3, 0); - - state->afectrl[core] = read_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7); - state->afeoverride[core] = - read_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : 0xa5); - - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0xa6 : 0xa7), - (0x1 << 0) | (0x1 << 1) | (0x1 << 2), 0); - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), - (0x1 << 0) | - (0x1 << 1) | - (0x1 << 2), (0x1 << 0) | (0x1 << 1) | (0x1 << 2)); - - state->vga_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER); - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, 0x2b); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_G); - state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER); - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_G, - 0x03); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER, 0x04); - } else { - state->fbmix[core] = - READ_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_A); - state->intpa_master[core] = - READ_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER); - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, TXFBMIX_A, - 0x03); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER, 0x04); - - } - - tone_freq = 4000; - - wlc_phy_tx_tone_nphy(pi, tone_freq, 181, 0, 0, false); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (off_core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); - } -} - -static void -wlc_phy_papd_cal_cleanup_nphy(struct brcms_phy *pi, - struct nphy_papd_restore_state *state) -{ - u8 core; - - wlc_phy_stopplayback_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_PWRUP, 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_2G_ATTEN, - state->atten[core]); - } else { - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_PWRUP, 0); - WRITE_RADIO_REG3(pi, RADIO_2057, TX, core, - TXRXCOUPLE_5G_ATTEN, - state->atten[core]); - } - } - - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - else - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), - 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 12), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 8), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), 1, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 0, 0x3, 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7, state->afectrl[core]); - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : - 0xa5, state->afeoverride[core]); - } - - wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, - (state->mm & 0xff)); - - if (NREV_IS(pi->pubpi.phy_rev, 7) - || NREV_GE(pi->pubpi.phy_rev, 8)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 7), 0, 0, - 1, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 13), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 0), 0, 0x3, 1); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 2), 0, 0x3, 1); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 1), 0, 0x3, 1); - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, VGA_MASTER, - state->vga_master[core]); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_G, state->fbmix[core]); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAG_MASTER, - state->intpa_master[core]); - } else { - WRITE_RADIO_REG2(pi, RADIO_2056, RX, core, - TXFBMIX_A, state->fbmix[core]); - WRITE_RADIO_REG2(pi, RADIO_2056, TX, core, - INTPAA_MASTER, - state->intpa_master[core]); - } - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xa6 : 0xa7, state->afectrl[core]); - write_phy_reg(pi, (core == PHY_CORE_0) ? 0x8f : - 0xa5, state->afeoverride[core]); - } - - wlc_phy_ipa_set_bbmult_nphy(pi, (state->mm >> 8) & 0xff, - (state->mm & 0xff)); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 1); - } -} - -static void -wlc_phy_a1_nphy(struct brcms_phy *pi, u8 core, u32 winsz, u32 start, - u32 end) -{ - u32 *buf, *src, *dst, sz; - - sz = end - start + 1; - - buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC); - if (NULL == buf) - return; - - src = buf; - dst = buf + NPHY_PAPD_EPS_TBL_SIZE; - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), - NPHY_PAPD_EPS_TBL_SIZE, 0, 32, src); - - do { - u32 phy_a1, phy_a2; - s32 phy_a3, phy_a4, phy_a5, phy_a6, phy_a7; - - phy_a1 = end - min(end, (winsz >> 1)); - phy_a2 = min_t(u32, NPHY_PAPD_EPS_TBL_SIZE - 1, - end + (winsz >> 1)); - phy_a3 = phy_a2 - phy_a1 + 1; - phy_a6 = 0; - phy_a7 = 0; - - do { - wlc_phy_papd_decode_epsilon(src[phy_a2], &phy_a4, - &phy_a5); - phy_a6 += phy_a4; - phy_a7 += phy_a5; - } while (phy_a2-- != phy_a1); - - phy_a6 /= phy_a3; - phy_a7 /= phy_a3; - dst[end] = ((u32) phy_a7 << 13) | ((u32) phy_a6 & 0x1fff); - } while (end-- != start); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1, sz, start, 32, dst); - - kfree(buf); -} - -static void -wlc_phy_a2_nphy(struct brcms_phy *pi, struct nphy_ipa_txcalgains *txgains, - enum phy_cal_mode cal_mode, u8 core) -{ - u16 phy_a1, phy_a2, phy_a3; - u16 phy_a4, phy_a5; - bool phy_a6; - u8 phy_a7, m[2]; - u32 phy_a8 = 0; - struct nphy_txgains phy_a9; - - if (NREV_LT(pi->pubpi.phy_rev, 3)) - return; - - phy_a7 = (core == PHY_CORE_0) ? 1 : 0; - - phy_a6 = ((cal_mode == CAL_GCTRL) - || (cal_mode == CAL_SOFT)) ? true : false; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - phy_a9 = wlc_phy_get_tx_gain_nphy(pi); - - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_a5 = ((phy_a9.txlpf[core] << 15) | - (phy_a9.txgm[core] << 12) | - (phy_a9.pga[core] << 8) | - (txgains->gains.pad[core] << 3) | - (phy_a9.ipa[core])); - else - phy_a5 = ((phy_a9.txlpf[core] << 15) | - (phy_a9.txgm[core] << 12) | - (txgains->gains.pga[core] << 8) | - (phy_a9.pad[core] << 3) | (phy_a9.ipa[core])); - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 0); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev <= 4) - || (pi->pubpi.radiorev == 6)) - m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? - 60 : 79; - else - m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? - 45 : 64; - } else { - m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 75 : 107; - } - - m[phy_a7] = 0; - wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); - - phy_a2 = 63; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - phy_a1 = 30; - phy_a3 = 30; - } else { - phy_a1 = 25; - phy_a3 = 25; - } - } else { - if ((pi->pubpi.radiorev == 5) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - phy_a1 = 25; - phy_a3 = 25; - } else { - phy_a1 = 35; - phy_a3 = 35; - } - } - - if (cal_mode == CAL_GCTRL) { - if ((pi->pubpi.radiorev == 5) - && (CHSPEC_IS2G(pi->radio_chanspec))) - phy_a1 = 55; - else if (((pi->pubpi.radiorev == 7) && - (CHSPEC_IS2G(pi->radio_chanspec))) || - ((pi->pubpi.radiorev == 8) && - (CHSPEC_IS2G(pi->radio_chanspec)))) - phy_a1 = 60; - else - phy_a1 = 63; - - } else if ((cal_mode != CAL_FULL) && (cal_mode != CAL_SOFT)) { - - phy_a1 = 35; - phy_a3 = 35; - } - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - write_phy_reg(pi, 0x2a1, 0x80); - write_phy_reg(pi, 0x2a2, 0x100); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 4), (11) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 8), (11) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 0), (0x3) << 0); - - write_phy_reg(pi, 0x2e5, 0x20); - - mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 1, ((core == 0) ? 1 : 2), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, ((core == 0) ? 2 : 1), 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - write_phy_reg(pi, 0x2be, 1); - SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 - : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, - 32, &phy_a8); - - if (cal_mode != CAL_GCTRL) { - if (CHSPEC_IS5G(pi->radio_chanspec)) - wlc_phy_a1_nphy(pi, core, 5, 0, 35); - } - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_txgain, - phy_a5, (1 << core), 1); - - } else { - - if (txgains) { - if (txgains->useindex) { - phy_a4 = 15 - ((txgains->index) >> 3); - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 6)) - phy_a5 = 0x00f7 | (phy_a4 << 8); - - else - if (NREV_IS(pi->pubpi.phy_rev, 5)) - phy_a5 = 0x10f7 | (phy_a4 << 8); - else - phy_a5 = 0x50f7 | (phy_a4 << 8); - } else { - phy_a5 = 0x70f7 | (phy_a4 << 8); - } - wlc_phy_rfctrl_override_nphy(pi, - (0x1 << 13), - phy_a5, - (1 << core), 0); - } else { - wlc_phy_rfctrl_override_nphy(pi, - (0x1 << 13), - 0x5bf7, - (1 << core), 0); - } - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) - m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 45 : 64; - else - m[core] = (pi->bw == WL_CHANSPEC_BW_40) ? 75 : 107; - - m[phy_a7] = 0; - wlc_phy_ipa_set_bbmult_nphy(pi, m[0], m[1]); - - phy_a2 = 63; - - if (cal_mode == CAL_FULL) { - phy_a1 = 25; - phy_a3 = 25; - } else if (cal_mode == CAL_SOFT) { - phy_a1 = 25; - phy_a3 = 25; - } else if (cal_mode == CAL_GCTRL) { - phy_a1 = 63; - phy_a3 = 25; - } else { - - phy_a1 = 25; - phy_a3 = 25; - } - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (1) << 0); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (1) << 13); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - write_phy_reg(pi, 0x2a1, 0x20); - write_phy_reg(pi, 0x2a2, 0x60); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 4), (9) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 8), (9) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0xf << 0), (0x2) << 0); - - write_phy_reg(pi, 0x2e5, 0x20); - } else { - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (1) << 11); - - mod_phy_reg(pi, (phy_a7 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - write_phy_reg(pi, 0x2a1, 0x80); - write_phy_reg(pi, 0x2a2, 0x600); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 4), (0) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 8), (0) << 8); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x7 << 0), (0x3) << 0); - - mod_phy_reg(pi, 0x2a0, (0x3f << 8), (0x20) << 8); - - } - - mod_phy_reg(pi, 0x2a0, (0x3f << 0), (phy_a3) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 0), (phy_a1) << 0); - - mod_phy_reg(pi, 0x29f, (0x3f << 8), (phy_a2) << 8); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 1, 0x3, 0); - - write_phy_reg(pi, 0x2be, 1); - SPINWAIT(read_phy_reg(pi, 0x2be), 10 * 1000 * 1000); - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 0x3, 0); - - wlc_phy_table_write_nphy(pi, - (core == - PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 - : NPHY_TBL_ID_EPSILONTBL1, 1, phy_a3, - 32, &phy_a8); - - if (cal_mode != CAL_GCTRL) - wlc_phy_a1_nphy(pi, core, 5, 0, 40); - } -} - -static u8 wlc_phy_a3_nphy(struct brcms_phy *pi, u8 start_gain, u8 core) -{ - int phy_a1; - int phy_a2; - bool phy_a3; - struct nphy_ipa_txcalgains phy_a4; - bool phy_a5 = false; - bool phy_a6 = true; - s32 phy_a7, phy_a8; - u32 phy_a9; - int phy_a10; - bool phy_a11 = false; - int phy_a12; - u8 phy_a13 = 0; - u8 phy_a14; - u8 *phy_a15 = NULL; - - phy_a4.useindex = true; - phy_a12 = start_gain; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - phy_a2 = 20; - phy_a1 = 1; - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 5) { - - phy_a15 = pad_gain_codes_used_2057rev5; - phy_a13 = - sizeof(pad_gain_codes_used_2057rev5) / - sizeof(pad_gain_codes_used_2057rev5 - [0]) - 1; - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - phy_a15 = pad_gain_codes_used_2057rev7; - phy_a13 = - sizeof(pad_gain_codes_used_2057rev7) / - sizeof(pad_gain_codes_used_2057rev7 - [0]) - 1; - - } else { - - phy_a15 = pad_all_gain_codes_2057; - phy_a13 = sizeof(pad_all_gain_codes_2057) / - sizeof(pad_all_gain_codes_2057[0]) - - 1; - } - - } else { - - phy_a15 = pga_all_gain_codes_2057; - phy_a13 = sizeof(pga_all_gain_codes_2057) / - sizeof(pga_all_gain_codes_2057[0]) - 1; - } - - phy_a14 = 0; - - for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_a4.gains.pad[core] = - (u16) phy_a15[phy_a12]; - else - phy_a4.gains.pga[core] = - (u16) phy_a15[phy_a12]; - - wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - 63, 32, &phy_a9); - - wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); - - phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || - (phy_a8 == 4095) || (phy_a8 == -4096)); - - if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) - phy_a12 -= (u8) phy_a1; - - phy_a11 = true; - break; - } - - if (phy_a3) - phy_a12 += (u8) phy_a1; - else - phy_a12 -= (u8) phy_a1; - - if ((phy_a12 < phy_a14) || (phy_a12 > phy_a13)) { - if (phy_a12 < phy_a14) - phy_a12 = phy_a14; - else - phy_a12 = phy_a13; - - phy_a11 = true; - break; - } - - phy_a6 = false; - phy_a5 = phy_a3; - } - - } else { - phy_a2 = 10; - phy_a1 = 8; - for (phy_a10 = 0; phy_a10 < phy_a2; phy_a10++) { - phy_a4.index = (u8) phy_a12; - wlc_phy_a2_nphy(pi, &phy_a4, CAL_GCTRL, core); - - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - 63, 32, &phy_a9); - - wlc_phy_papd_decode_epsilon(phy_a9, &phy_a7, &phy_a8); - - phy_a3 = ((phy_a7 == 4095) || (phy_a7 == -4096) || - (phy_a8 == 4095) || (phy_a8 == -4096)); - - if (!phy_a6 && (phy_a3 != phy_a5)) { - if (!phy_a3) - phy_a12 -= (u8) phy_a1; - - phy_a11 = true; - break; - } - - if (phy_a3) - phy_a12 += (u8) phy_a1; - else - phy_a12 -= (u8) phy_a1; - - if ((phy_a12 < 0) || (phy_a12 > 127)) { - if (phy_a12 < 0) - phy_a12 = 0; - else - phy_a12 = 127; - - phy_a11 = true; - break; - } - - phy_a6 = false; - phy_a5 = phy_a3; - } - - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - return (u8) phy_a15[phy_a12]; - else - return (u8) phy_a12; - -} - -static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) -{ - struct nphy_ipa_txcalgains phy_b1[2]; - struct nphy_papd_restore_state phy_b2; - bool phy_b3; - u8 phy_b4; - u8 phy_b5; - s16 phy_b6, phy_b7, phy_b8; - u16 phy_b9; - s16 phy_b10, phy_b11, phy_b12; - - phy_b11 = 0; - phy_b12 = 0; - phy_b7 = 0; - phy_b8 = 0; - phy_b6 = 0; - - if (pi->nphy_papd_skip == 1) - return; - - phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); - if (!phy_b3) - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - pi->nphy_force_papd_cal = false; - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) - pi->nphy_papd_tx_gain_at_last_cal[phy_b5] = - wlc_phy_txpwr_idx_cur_get_nphy(pi, phy_b5); - - pi->nphy_papd_last_cal = pi->sh->now; - pi->nphy_papd_recal_counter++; - - phy_b4 = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL0, 64, 0, 32, - nphy_papd_scaltbl); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SCALARTBL1, 64, 0, 32, - nphy_papd_scaltbl); - - phy_b9 = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - s32 i, val = 0; - for (i = 0; i < 64; i++) - wlc_phy_table_write_nphy(pi, - ((phy_b5 == - PHY_CORE_0) ? - NPHY_TBL_ID_EPSILONTBL0 : - NPHY_TBL_ID_EPSILONTBL1), 1, - i, 32, &val); - } - - wlc_phy_ipa_restore_tx_digi_filts_nphy(pi); - - phy_b2.mm = wlc_phy_ipa_get_bbmult_nphy(pi); - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - wlc_phy_papd_cal_setup_nphy(pi, &phy_b2, phy_b5); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) { - pi->nphy_papd_cal_gain_index[phy_b5] = - 23; - } else if (pi->pubpi.radiorev == 5) { - pi->nphy_papd_cal_gain_index[phy_b5] = - 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], - phy_b5); - - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - - pi->nphy_papd_cal_gain_index[phy_b5] = - 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], - phy_b5); - - } - - phy_b1[phy_b5].gains.pad[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; - - } else { - pi->nphy_papd_cal_gain_index[phy_b5] = 0; - pi->nphy_papd_cal_gain_index[phy_b5] = - wlc_phy_a3_nphy( - pi, - pi-> - nphy_papd_cal_gain_index - [phy_b5], phy_b5); - phy_b1[phy_b5].gains.pga[phy_b5] = - pi->nphy_papd_cal_gain_index[phy_b5]; - } - } else { - phy_b1[phy_b5].useindex = true; - phy_b1[phy_b5].index = 16; - phy_b1[phy_b5].index = - wlc_phy_a3_nphy(pi, phy_b1[phy_b5].index, - phy_b5); - - pi->nphy_papd_cal_gain_index[phy_b5] = - 15 - ((phy_b1[phy_b5].index) >> 3); - } - - switch (pi->nphy_papd_cal_type) { - case 0: - wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_FULL, phy_b5); - break; - case 1: - wlc_phy_a2_nphy(pi, &phy_b1[phy_b5], CAL_SOFT, phy_b5); - break; - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - } - - if (NREV_LT(pi->pubpi.phy_rev, 7)) - wlc_phy_papd_cal_cleanup_nphy(pi, &phy_b2); - - for (phy_b5 = 0; phy_b5 < pi->pubpi.phy_corenum; phy_b5++) { - int eps_offset = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev == 3) - eps_offset = -2; - else if (pi->pubpi.radiorev == 5) - eps_offset = 3; - else - eps_offset = -1; - } else { - eps_offset = 2; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - phy_b8 = phy_b1[phy_b5].gains.pad[phy_b5]; - phy_b10 = 0; - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev3n4 - [phy_b8] + 1) / 2; - phy_b10 = -1; - } else if (pi->pubpi.radiorev == 5) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev5 - [phy_b8] + 1) / 2; - } else if ((pi->pubpi.radiorev == 7) || - (pi->pubpi.radiorev == 8)) { - phy_b12 = -( - nphy_papd_padgain_dlt_2g_2057rev7 - [phy_b8] + 1) / 2; - } - } else { - phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5]; - if ((pi->pubpi.radiorev == 3) || - (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) - phy_b11 = - -(nphy_papd_pgagain_dlt_5g_2057 - [phy_b7] - + 1) / 2; - else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) - phy_b11 = -( - nphy_papd_pgagain_dlt_5g_2057rev7 - [phy_b7] + 1) / 2; - - phy_b10 = -9; - } - - if (CHSPEC_IS2G(pi->radio_chanspec)) - phy_b6 = - -60 + 27 + eps_offset + phy_b12 + - phy_b10; - else - phy_b6 = - -60 + 27 + eps_offset + phy_b11 + - phy_b10; - - mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), (phy_b6) << 7); - - pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; - } else { - if (NREV_LT(pi->pubpi.phy_rev, 5)) - eps_offset = 4; - else - eps_offset = 2; - - phy_b7 = 15 - ((phy_b1[phy_b5].index) >> 3); - - if (CHSPEC_IS2G(pi->radio_chanspec)) { - phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_2g[ - phy_b7] + - 1) / 2; - phy_b10 = 0; - } else { - phy_b11 = - -(nphy_papd_pga_gain_delta_ipa_5g[ - phy_b7] + - 1) / 2; - phy_b10 = -9; - } - - phy_b6 = -60 + 27 + eps_offset + phy_b11 + phy_b10; - - mod_phy_reg(pi, (phy_b5 == PHY_CORE_0) ? 0x298 : - 0x29c, (0x1ff << 7), (phy_b6) << 7); - - pi->nphy_papd_epsilon_offset[phy_b5] = phy_b6; - } - } - - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (NPHY_PAPD_COMP_ON) << 0); - - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 13), (0) << 13); - - } else { - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x2a3 : - 0x2a4, (0x1 << 11), (0) << 11); - - } - pi->nphy_papdcomp = NPHY_PAPD_COMP_ON; - - write_phy_reg(pi, 0x01, phy_b9); - - wlc_phy_ipa_set_tx_digi_filts_nphy(pi); - - wlc_phy_txpwrctrl_enable_nphy(pi, phy_b4); - if (phy_b4 == PHY_TPC_HW_OFF) { - wlc_phy_txpwr_index_nphy(pi, (1 << 0), - (s8) (pi->nphy_txpwrindex[0]. - index_internal), false); - wlc_phy_txpwr_index_nphy(pi, (1 << 1), - (s8) (pi->nphy_txpwrindex[1]. - index_internal), false); - } - - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - if (!phy_b3) - wlapi_enable_mac(pi->sh->physhim); -} - -void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype) -{ - struct nphy_txgains target_gain; - u8 tx_pwr_ctrl_state; - bool fullcal = true; - bool restore_tx_gain = false; - bool mphase; - - if (PHY_MUTED(pi)) - return; - - if (caltype == PHY_PERICAL_AUTO) - fullcal = (pi->radio_chanspec != pi->nphy_txiqlocal_chanspec); - else if (caltype == PHY_PERICAL_PARTIAL) - fullcal = false; - - if (pi->cal_type_override != PHY_PERICAL_AUTO) - fullcal = - (pi->cal_type_override == - PHY_PERICAL_FULL) ? true : false; - - if ((pi->mphase_cal_phase_id > MPHASE_CAL_STATE_INIT)) { - if (pi->nphy_txiqlocal_chanspec != pi->radio_chanspec) - wlc_phy_cal_perical_mphase_restart(pi); - } - - if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_RXCAL)) - wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); - - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - wlc_phyreg_enter((struct brcms_phy_pub *) pi); - - if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_IDLE) || - (pi->mphase_cal_phase_id == MPHASE_CAL_STATE_INIT)) { - pi->nphy_cal_orig_pwr_idx[0] = - (u8) ((read_phy_reg(pi, 0x1ed) >> 8) & 0x7f); - pi->nphy_cal_orig_pwr_idx[1] = - (u8) ((read_phy_reg(pi, 0x1ee) >> 8) & 0x7f); - - if (pi->nphy_txpwrctrl != PHY_TPC_HW_OFF) { - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, - 0x110, 16, - pi->nphy_cal_orig_tx_gain); - } else { - pi->nphy_cal_orig_tx_gain[0] = 0; - pi->nphy_cal_orig_tx_gain[1] = 0; - } - } - target_gain = wlc_phy_get_tx_gain_nphy(pi); - tx_pwr_ctrl_state = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - if (pi->antsel_type == ANTSEL_2x3) - wlc_phy_antsel_init((struct brcms_phy_pub *) pi, true); - - mphase = (pi->mphase_cal_phase_id != MPHASE_CAL_STATE_IDLE); - if (!mphase) { - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - wlc_phy_precal_txgain_nphy(pi); - pi->nphy_cal_target_gain = wlc_phy_get_tx_gain_nphy(pi); - restore_tx_gain = true; - - target_gain = pi->nphy_cal_target_gain; - } - if (0 == - wlc_phy_cal_txiqlo_nphy(pi, target_gain, fullcal, - mphase)) { - if (PHY_IPA(pi)) - wlc_phy_a4(pi, true); - - wlc_phyreg_exit((struct brcms_phy_pub *) pi); - wlapi_enable_mac(pi->sh->physhim); - wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, - 10000); - wlapi_suspend_mac_and_wait(pi->sh->physhim); - wlc_phyreg_enter((struct brcms_phy_pub *) pi); - - if (0 == wlc_phy_cal_rxiq_nphy(pi, target_gain, - (pi->first_cal_after_assoc || - (pi->cal_type_override == - PHY_PERICAL_FULL)) ? 2 : 0, false)) { - wlc_phy_savecal_nphy(pi); - - wlc_phy_txpwrctrl_coeff_setup_nphy(pi); - - pi->nphy_perical_last = pi->sh->now; - } - } - if (caltype != PHY_PERICAL_AUTO) - wlc_phy_rssi_cal_nphy(pi); - - if (pi->first_cal_after_assoc - || (pi->cal_type_override == PHY_PERICAL_FULL)) { - pi->first_cal_after_assoc = false; - wlc_phy_txpwrctrl_idle_tssi_nphy(pi); - wlc_phy_txpwrctrl_pwr_setup_nphy(pi); - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_radio205x_vcocal_nphy(pi); - } else { - switch (pi->mphase_cal_phase_id) { - case MPHASE_CAL_STATE_INIT: - pi->nphy_perical_last = pi->sh->now; - pi->nphy_txiqlocal_chanspec = pi->radio_chanspec; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_precal_txgain_nphy(pi); - - pi->nphy_cal_target_gain = wlc_phy_get_tx_gain_nphy(pi); - pi->mphase_cal_phase_id++; - break; - - case MPHASE_CAL_STATE_TXPHASE0: - case MPHASE_CAL_STATE_TXPHASE1: - case MPHASE_CAL_STATE_TXPHASE2: - case MPHASE_CAL_STATE_TXPHASE3: - case MPHASE_CAL_STATE_TXPHASE4: - case MPHASE_CAL_STATE_TXPHASE5: - if ((pi->radar_percal_mask & 0x10) != 0) - pi->nphy_rxcal_active = true; - - if (wlc_phy_cal_txiqlo_nphy - (pi, pi->nphy_cal_target_gain, fullcal, - true) != 0) { - - wlc_phy_cal_perical_mphase_reset(pi); - break; - } - - if (NREV_LE(pi->pubpi.phy_rev, 2) && - (pi->mphase_cal_phase_id == - MPHASE_CAL_STATE_TXPHASE4)) - pi->mphase_cal_phase_id += 2; - else - pi->mphase_cal_phase_id++; - break; - - case MPHASE_CAL_STATE_PAPDCAL: - if ((pi->radar_percal_mask & 0x2) != 0) - pi->nphy_rxcal_active = true; - - if (PHY_IPA(pi)) - wlc_phy_a4(pi, true); - - pi->mphase_cal_phase_id++; - break; - - case MPHASE_CAL_STATE_RXCAL: - if ((pi->radar_percal_mask & 0x1) != 0) - pi->nphy_rxcal_active = true; - if (wlc_phy_cal_rxiq_nphy(pi, target_gain, - (pi->first_cal_after_assoc || - (pi->cal_type_override == - PHY_PERICAL_FULL)) ? 2 : 0, - false) == 0) - wlc_phy_savecal_nphy(pi); - - pi->mphase_cal_phase_id++; - break; - - case MPHASE_CAL_STATE_RSSICAL: - if ((pi->radar_percal_mask & 0x4) != 0) - pi->nphy_rxcal_active = true; - wlc_phy_txpwrctrl_coeff_setup_nphy(pi); - wlc_phy_rssi_cal_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_radio205x_vcocal_nphy(pi); - - restore_tx_gain = true; - - if (pi->first_cal_after_assoc) - pi->mphase_cal_phase_id++; - else - wlc_phy_cal_perical_mphase_reset(pi); - - break; - - case MPHASE_CAL_STATE_IDLETSSI: - if ((pi->radar_percal_mask & 0x8) != 0) - pi->nphy_rxcal_active = true; - - if (pi->first_cal_after_assoc) { - pi->first_cal_after_assoc = false; - wlc_phy_txpwrctrl_idle_tssi_nphy(pi); - wlc_phy_txpwrctrl_pwr_setup_nphy(pi); - } - - wlc_phy_cal_perical_mphase_reset(pi); - break; - - default: - wlc_phy_cal_perical_mphase_reset(pi); - break; - } - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if (restore_tx_gain) { - if (tx_pwr_ctrl_state != PHY_TPC_HW_OFF) { - - wlc_phy_txpwr_index_nphy(pi, 1, - pi-> - nphy_cal_orig_pwr_idx - [0], false); - wlc_phy_txpwr_index_nphy(pi, 2, - pi-> - nphy_cal_orig_pwr_idx - [1], false); - - pi->nphy_txpwrindex[0].index = -1; - pi->nphy_txpwrindex[1].index = -1; - } else { - wlc_phy_txpwr_index_nphy(pi, (1 << 0), - (s8) (pi-> - nphy_txpwrindex - [0]. - index_internal), - false); - wlc_phy_txpwr_index_nphy(pi, (1 << 1), - (s8) (pi-> - nphy_txpwrindex - [1]. - index_internal), - false); - } - } - } - - wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); - wlc_phyreg_exit((struct brcms_phy_pub *) pi); - wlapi_enable_mac(pi->sh->physhim); -} - -int -wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, - bool fullcal, bool mphase) -{ - u16 val; - u16 tbl_buf[11]; - u8 cal_cnt; - u16 cal_cmd; - u8 num_cals, max_cal_cmds; - u16 core_no, cal_type; - u16 diq_start = 0; - u8 phy_bw; - u16 max_val; - u16 tone_freq; - u16 gain_save[2]; - u16 cal_gain[2]; - struct nphy_iqcal_params cal_params[2]; - u32 tbl_len; - void *tbl_ptr; - bool ladder_updated[2]; - u8 mphase_cal_lastphase = 0; - int bcmerror = 0; - bool phyhang_avoid_state = false; - - u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { - 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, - 0x1902, - 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, - 0x6407 - }; - - u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { - 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, - 0x3200, - 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, - 0x6407 - }; - - u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { - 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, - 0x1202, - 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, - 0x4707 - }; - - u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { - 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, - 0x2300, - 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, - 0x4707 - }; - - u16 tbl_tx_iqlo_cal_startcoefs[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000 - }; - - u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { - 0x8123, 0x8264, 0x8086, 0x8245, 0x8056, - 0x9123, 0x9264, 0x9086, 0x9245, 0x9056 - }; - - u16 tbl_tx_iqlo_cal_cmds_recal[] = { - 0x8101, 0x8253, 0x8053, 0x8234, 0x8034, - 0x9101, 0x9253, 0x9053, 0x9234, 0x9034 - }; - - u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000 - }; - - u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { - 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234, - 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234 - }; - - u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { - 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223, - 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223 - }; - - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (NREV_GE(pi->pubpi.phy_rev, 4)) { - phyhang_avoid_state = pi->phyhang_avoid; - pi->phyhang_avoid = false; - } - - if (CHSPEC_IS40(pi->radio_chanspec)) - phy_bw = 40; - else - phy_bw = 20; - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); - - for (core_no = 0; core_no <= 1; core_no++) { - wlc_phy_iqcal_gainparams_nphy(pi, core_no, target_gain, - &cal_params[core_no]); - cal_gain[core_no] = cal_params[core_no].cal_gain; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, cal_gain); - - wlc_phy_txcal_radio_setup_nphy(pi); - - wlc_phy_txcal_physetup_nphy(pi); - - ladder_updated[0] = ladder_updated[1] = false; - if (!(NREV_GE(pi->pubpi.phy_rev, 6) || - (NREV_IS(pi->pubpi.phy_rev, 5) && PHY_IPA(pi) - && (CHSPEC_IS2G(pi->radio_chanspec))))) { - - if (phy_bw == 40) { - tbl_ptr = tbl_tx_iqlo_cal_loft_ladder_40; - tbl_len = ARRAY_SIZE(tbl_tx_iqlo_cal_loft_ladder_40); - } else { - tbl_ptr = tbl_tx_iqlo_cal_loft_ladder_20; - tbl_len = ARRAY_SIZE(tbl_tx_iqlo_cal_loft_ladder_20); - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, tbl_len, 0, - 16, tbl_ptr); - - if (phy_bw == 40) { - tbl_ptr = tbl_tx_iqlo_cal_iqimb_ladder_40; - tbl_len = ARRAY_SIZE(tbl_tx_iqlo_cal_iqimb_ladder_40); - } else { - tbl_ptr = tbl_tx_iqlo_cal_iqimb_ladder_20; - tbl_len = ARRAY_SIZE(tbl_tx_iqlo_cal_iqimb_ladder_20); - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, tbl_len, 32, - 16, tbl_ptr); - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - write_phy_reg(pi, 0xc2, 0x8ad9); - else - write_phy_reg(pi, 0xc2, 0x8aa9); - - max_val = 250; - tone_freq = (phy_bw == 20) ? 2500 : 5000; - - if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) { - wlc_phy_runsamples_nphy(pi, phy_bw * 8, 0xffff, 0, 1, 0, false); - bcmerror = 0; - } else { - bcmerror = - wlc_phy_tx_tone_nphy(pi, tone_freq, max_val, 1, 0, - false); - } - - if (bcmerror == 0) { - - if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) { - tbl_ptr = pi->mphase_txcal_bestcoeffs; - tbl_len = ARRAY_SIZE(pi->mphase_txcal_bestcoeffs); - if (NREV_LT(pi->pubpi.phy_rev, 3)) - tbl_len -= 2; - } else { - if ((!fullcal) && (pi->nphy_txiqlocal_coeffsvalid)) { - - tbl_ptr = pi->nphy_txiqlocal_bestc; - tbl_len = ARRAY_SIZE(pi->nphy_txiqlocal_bestc); - if (NREV_LT(pi->pubpi.phy_rev, 3)) - tbl_len -= 2; - } else { - - fullcal = true; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - tbl_ptr = - tbl_tx_iqlo_cal_startcoefs_nphyrev3; - tbl_len = ARRAY_SIZE( - tbl_tx_iqlo_cal_startcoefs_nphyrev3); - } else { - tbl_ptr = tbl_tx_iqlo_cal_startcoefs; - tbl_len = ARRAY_SIZE( - tbl_tx_iqlo_cal_startcoefs); - } - } - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, tbl_len, 64, - 16, tbl_ptr); - - if (fullcal) { - max_cal_cmds = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - ARRAY_SIZE( - tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3) : - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_fullcal); - } else { - max_cal_cmds = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - ARRAY_SIZE( - tbl_tx_iqlo_cal_cmds_recal_nphyrev3) : - ARRAY_SIZE(tbl_tx_iqlo_cal_cmds_recal); - } - - if (mphase) { - cal_cnt = pi->mphase_txcal_cmdidx; - if ((cal_cnt + pi->mphase_txcal_numcmds) < max_cal_cmds) - num_cals = cal_cnt + pi->mphase_txcal_numcmds; - else - num_cals = max_cal_cmds; - } else { - cal_cnt = 0; - num_cals = max_cal_cmds; - } - - for (; cal_cnt < num_cals; cal_cnt++) { - - if (fullcal) { - cal_cmd = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3 - [cal_cnt] : - tbl_tx_iqlo_cal_cmds_fullcal[cal_cnt]; - } else { - cal_cmd = (NREV_GE(pi->pubpi.phy_rev, 3)) ? - tbl_tx_iqlo_cal_cmds_recal_nphyrev3[ - cal_cnt] - : tbl_tx_iqlo_cal_cmds_recal[cal_cnt]; - } - - core_no = ((cal_cmd & 0x3000) >> 12); - cal_type = ((cal_cmd & 0x0F00) >> 8); - - if (NREV_GE(pi->pubpi.phy_rev, 6) || - (NREV_IS(pi->pubpi.phy_rev, 5) && - PHY_IPA(pi) - && (CHSPEC_IS2G(pi->radio_chanspec)))) { - if (!ladder_updated[core_no]) { - wlc_phy_update_txcal_ladder_nphy( - pi, - core_no); - ladder_updated[core_no] = true; - } - } - - val = - (cal_params[core_no]. - ncorr[cal_type] << 8) | NPHY_N_GCTL; - write_phy_reg(pi, 0xc1, val); - - if ((cal_type == 1) || (cal_type == 3) - || (cal_type == 4)) { - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, - 1, 69 + core_no, 16, - tbl_buf); - - diq_start = tbl_buf[0]; - - tbl_buf[0] = 0; - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_IQLOCAL, 1, - 69 + core_no, 16, - tbl_buf); - } - - write_phy_reg(pi, 0xc0, cal_cmd); - - SPINWAIT(((read_phy_reg(pi, 0xc0) & 0xc000) != 0), - 20000); - if (WARN(read_phy_reg(pi, 0xc0) & 0xc000, - "HW error: txiq calib")) - return -EIO; - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, - tbl_len, 96, 16, tbl_buf); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, - tbl_len, 64, 16, tbl_buf); - - if ((cal_type == 1) || (cal_type == 3) - || (cal_type == 4)) { - - tbl_buf[0] = diq_start; - - } - - } - - if (mphase) { - pi->mphase_txcal_cmdidx = num_cals; - if (pi->mphase_txcal_cmdidx >= max_cal_cmds) - pi->mphase_txcal_cmdidx = 0; - } - - mphase_cal_lastphase = - (NREV_LE(pi->pubpi.phy_rev, 2)) ? - MPHASE_CAL_STATE_TXPHASE4 : MPHASE_CAL_STATE_TXPHASE5; - - if (!mphase - || (pi->mphase_cal_phase_id == mphase_cal_lastphase)) { - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 96, - 16, tbl_buf); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, - 16, tbl_buf); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - - tbl_buf[0] = 0; - tbl_buf[1] = 0; - tbl_buf[2] = 0; - tbl_buf[3] = 0; - - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 88, - 16, tbl_buf); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 101, - 16, tbl_buf); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 85, - 16, tbl_buf); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 93, - 16, tbl_buf); - - tbl_len = ARRAY_SIZE(pi->nphy_txiqlocal_bestc); - if (NREV_LT(pi->pubpi.phy_rev, 3)) - tbl_len -= 2; - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, - tbl_len, 96, 16, - pi->nphy_txiqlocal_bestc); - - pi->nphy_txiqlocal_coeffsvalid = true; - pi->nphy_txiqlocal_chanspec = pi->radio_chanspec; - } else { - tbl_len = ARRAY_SIZE(pi->mphase_txcal_bestcoeffs); - if (NREV_LT(pi->pubpi.phy_rev, 3)) - tbl_len -= 2; - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, - tbl_len, 96, 16, - pi->mphase_txcal_bestcoeffs); - } - - wlc_phy_stopplayback_nphy(pi); - - write_phy_reg(pi, 0xc2, 0x0000); - - } - - wlc_phy_txcal_phycleanup_nphy(pi); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - gain_save); - - wlc_phy_txcal_radio_cleanup_nphy(pi); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - if (!mphase - || (pi->mphase_cal_phase_id == mphase_cal_lastphase)) - wlc_phy_tx_iq_war_nphy(pi); - } - - if (NREV_GE(pi->pubpi.phy_rev, 4)) - pi->phyhang_avoid = phyhang_avoid_state; - - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - return bcmerror; -} - -static void wlc_phy_reapply_txcal_coeffs_nphy(struct brcms_phy *pi) -{ - u16 tbl_buf[7]; - - if ((pi->nphy_txiqlocal_chanspec == pi->radio_chanspec) && - (pi->nphy_txiqlocal_coeffsvalid)) { - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL, - ARRAY_SIZE(tbl_buf), 80, 16, tbl_buf); - - if ((pi->nphy_txiqlocal_bestc[0] != tbl_buf[0]) || - (pi->nphy_txiqlocal_bestc[1] != tbl_buf[1]) || - (pi->nphy_txiqlocal_bestc[2] != tbl_buf[2]) || - (pi->nphy_txiqlocal_bestc[3] != tbl_buf[3])) { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 80, - 16, pi->nphy_txiqlocal_bestc); - - tbl_buf[0] = 0; - tbl_buf[1] = 0; - tbl_buf[2] = 0; - tbl_buf[3] = 0; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 4, 88, - 16, tbl_buf); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 85, - 16, - &pi->nphy_txiqlocal_bestc[5]); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_IQLOCAL, 2, 93, - 16, - &pi->nphy_txiqlocal_bestc[5]); - } - } -} - -void -wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write, - struct nphy_iq_comp *pcomp) -{ - if (write) { - write_phy_reg(pi, 0x9a, pcomp->a0); - write_phy_reg(pi, 0x9b, pcomp->b0); - write_phy_reg(pi, 0x9c, pcomp->a1); - write_phy_reg(pi, 0x9d, pcomp->b1); - } else { - pcomp->a0 = read_phy_reg(pi, 0x9a); - pcomp->b0 = read_phy_reg(pi, 0x9b); - pcomp->a1 = read_phy_reg(pi, 0x9c); - pcomp->b1 = read_phy_reg(pi, 0x9d); - } -} - -void -wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est, - u16 num_samps, u8 wait_time, u8 wait_for_crs) -{ - u8 core; - - write_phy_reg(pi, 0x12b, num_samps); - mod_phy_reg(pi, 0x12a, (0xff << 0), (wait_time << 0)); - mod_phy_reg(pi, 0x129, NPHY_IqestCmd_iqMode, - (wait_for_crs) ? NPHY_IqestCmd_iqMode : 0); - - mod_phy_reg(pi, 0x129, NPHY_IqestCmd_iqstart, NPHY_IqestCmd_iqstart); - - SPINWAIT(((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) != 0), - 10000); - if (WARN(read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart, - "HW error: rxiq est")) - return; - - if ((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0) { - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - est[core].i_pwr = - (read_phy_reg(pi, - NPHY_IqestipwrAccHi(core)) << 16) - | read_phy_reg(pi, NPHY_IqestipwrAccLo(core)); - est[core].q_pwr = - (read_phy_reg(pi, - NPHY_IqestqpwrAccHi(core)) << 16) - | read_phy_reg(pi, NPHY_IqestqpwrAccLo(core)); - est[core].iq_prod = - (read_phy_reg(pi, - NPHY_IqestIqAccHi(core)) << 16) | - read_phy_reg(pi, NPHY_IqestIqAccLo(core)); - } - } -} - -#define CAL_RETRY_CNT 2 -static void wlc_phy_calc_rx_iq_comp_nphy(struct brcms_phy *pi, u8 core_mask) -{ - u8 curr_core; - struct phy_iq_est est[PHY_CORE_MAX]; - struct nphy_iq_comp old_comp, new_comp; - s32 iq = 0; - u32 ii = 0, qq = 0; - s16 iq_nbits, qq_nbits, brsh, arsh; - s32 a, b, temp; - int bcmerror = 0; - uint cal_retry = 0; - - if (core_mask == 0x0) - return; - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, &old_comp); - new_comp.a0 = new_comp.b0 = new_comp.a1 = new_comp.b1 = 0x0; - wlc_phy_rx_iq_coeffs_nphy(pi, 1, &new_comp); - -cal_try: - wlc_phy_rx_iq_est_nphy(pi, est, 0x4000, 32, 0); - - new_comp = old_comp; - - for (curr_core = 0; curr_core < pi->pubpi.phy_corenum; curr_core++) { - - if ((curr_core == PHY_CORE_0) && (core_mask & 0x1)) { - iq = est[curr_core].iq_prod; - ii = est[curr_core].i_pwr; - qq = est[curr_core].q_pwr; - } else if ((curr_core == PHY_CORE_1) && (core_mask & 0x2)) { - iq = est[curr_core].iq_prod; - ii = est[curr_core].i_pwr; - qq = est[curr_core].q_pwr; - } else { - continue; - } - - if ((ii + qq) < NPHY_MIN_RXIQ_PWR) { - bcmerror = -EBADE; - break; - } - - iq_nbits = wlc_phy_nbits(iq); - qq_nbits = wlc_phy_nbits(qq); - - arsh = 10 - (30 - iq_nbits); - if (arsh >= 0) { - a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); - temp = (s32) (ii >> arsh); - if (temp == 0) { - bcmerror = -EBADE; - break; - } - } else { - a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); - temp = (s32) (ii << -arsh); - if (temp == 0) { - bcmerror = -EBADE; - break; - } - } - - a /= temp; - - brsh = qq_nbits - 31 + 20; - if (brsh >= 0) { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii >> brsh); - if (temp == 0) { - bcmerror = -EBADE; - break; - } - } else { - b = (qq << (31 - qq_nbits)); - temp = (s32) (ii << -brsh); - if (temp == 0) { - bcmerror = -EBADE; - break; - } - } - b /= temp; - b -= a * a; - b = (s32) int_sqrt((unsigned long) b); - b -= (1 << 10); - - if ((curr_core == PHY_CORE_0) && (core_mask & 0x1)) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - new_comp.a0 = (s16) a & 0x3ff; - new_comp.b0 = (s16) b & 0x3ff; - } else { - - new_comp.a0 = (s16) b & 0x3ff; - new_comp.b0 = (s16) a & 0x3ff; - } - } - if ((curr_core == PHY_CORE_1) && (core_mask & 0x2)) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - new_comp.a1 = (s16) a & 0x3ff; - new_comp.b1 = (s16) b & 0x3ff; - } else { - - new_comp.a1 = (s16) b & 0x3ff; - new_comp.b1 = (s16) a & 0x3ff; - } - } - } - - if (bcmerror != 0) { - printk(KERN_DEBUG "%s: Failed, cnt = %d\n", __func__, - cal_retry); - - if (cal_retry < CAL_RETRY_CNT) { - cal_retry++; - goto cal_try; - } - - new_comp = old_comp; - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, &new_comp); -} - -static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core) -{ - u16 offtune_val; - u16 bias_g = 0; - u16 bias_a = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (rx_core == PHY_CORE_0) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN); - - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, - 0x3); - write_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, - 0xaf); - - } else { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN); - - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, - 0x3); - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, - 0x7f); - } - - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN); - - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, - 0x3); - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, - 0xaf); - - } else { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN); - - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, - 0x3); - write_radio_reg(pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, - 0x7f); - } - } - - } else { - if (rx_core == PHY_CORE_0) { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX1); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX0); - - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0); - pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1); - } - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0); - - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0, 0x40); - - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1, bias_a); - - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0, bias_a); - } else { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX0); - - offtune_val = - (pi->tx_rx_cal_radio_saveregs - [2] & 0xF0) >> 8; - offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; - - mod_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE | - RADIO_2056_RX0, 0xF0, - (offtune_val << 8)); - } - - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX1, 0x9); - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX0, 0x9); - } else { - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0); - - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0, 0x40); - - write_radio_reg( - pi, - RADIO_2056_TX_TXSPARE2 - | - RADIO_2056_TX1, bias_g); - - write_radio_reg( - pi, - RADIO_2056_RX_RXSPARE2 - | - RADIO_2056_RX0, bias_g); - - } else { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX0); - - offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & - 0xF0) >> 8; - offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; - - mod_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE | - RADIO_2056_RX0, 0xF0, - (offtune_val << 8)); - } - - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX1, 0x6); - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX0, 0x6); - } - - } else { - pi->tx_rx_cal_radio_saveregs[0] = - read_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX0); - pi->tx_rx_cal_radio_saveregs[1] = - read_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX1); - - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[2] = - read_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX1); - pi->tx_rx_cal_radio_saveregs[3] = - read_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX0); - } - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX1); - - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_MASTER | - RADIO_2056_RX1, 0x40); - - write_radio_reg( - pi, - RADIO_2056_TX_TXSPARE2 - | - RADIO_2056_TX0, bias_a); - - write_radio_reg( - pi, - RADIO_2056_RX_RXSPARE2 - | - RADIO_2056_RX1, bias_a); - } else { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX1); - - offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & - 0xF0) >> 8; - offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; - - mod_radio_reg(pi, - RADIO_2056_RX_LNAA_TUNE | - RADIO_2056_RX1, 0xF0, - (offtune_val << 8)); - } - - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX0, 0x9); - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX1, 0x9); - } else { - if (pi->pubpi.radiorev >= 5) { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1); - - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1, 0x40); - - write_radio_reg( - pi, - RADIO_2056_TX_TXSPARE2 - | - RADIO_2056_TX0, bias_g); - - write_radio_reg( - pi, - RADIO_2056_RX_RXSPARE2 - | - RADIO_2056_RX1, bias_g); - } else { - pi->tx_rx_cal_radio_saveregs[4] = - read_radio_reg( - pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX1); - - offtune_val = - (pi-> - tx_rx_cal_radio_saveregs[2] & - 0xF0) >> 8; - offtune_val = - (offtune_val <= 0x7) ? 0xF : 0; - - mod_radio_reg(pi, - RADIO_2056_RX_LNAG_TUNE | - RADIO_2056_RX1, 0xF0, - (offtune_val << 8)); - } - - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX0, 0x6); - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX1, 0x6); - } - } - } -} - -static void wlc_phy_rxcal_radio_cleanup_nphy(struct brcms_phy *pi, u8 rx_core) -{ - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - if (rx_core == PHY_CORE_0) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); - - } else { - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg( - pi, - RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); - } - - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); - - } else { - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP, - pi-> - tx_rx_cal_radio_saveregs[0]); - write_radio_reg( - pi, - RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN, - pi-> - tx_rx_cal_radio_saveregs[1]); - } - } - - } else { - if (rx_core == PHY_CORE_0) { - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX1, - pi->tx_rx_cal_radio_saveregs[0]); - - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX0, - pi->tx_rx_cal_radio_saveregs[1]); - - if (pi->pubpi.radiorev >= 5) { - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs[2]); - - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX1, - pi-> - tx_rx_cal_radio_saveregs[3]); - } - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev >= 5) - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); - else - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); - } else { - if (pi->pubpi.radiorev >= 5) - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); - else - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX0, - pi-> - tx_rx_cal_radio_saveregs - [4]); - } - - } else { - write_radio_reg(pi, - RADIO_2056_TX_RXIQCAL_TXMUX | - RADIO_2056_TX0, - pi->tx_rx_cal_radio_saveregs[0]); - - write_radio_reg(pi, - RADIO_2056_RX_RXIQCAL_RXMUX | - RADIO_2056_RX1, - pi->tx_rx_cal_radio_saveregs[1]); - - if (pi->pubpi.radiorev >= 5) { - write_radio_reg(pi, - RADIO_2056_RX_RXSPARE2 | - RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs[2]); - - write_radio_reg(pi, - RADIO_2056_TX_TXSPARE2 | - RADIO_2056_TX0, - pi-> - tx_rx_cal_radio_saveregs[3]); - } - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (pi->pubpi.radiorev >= 5) - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_MASTER - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); - else - write_radio_reg( - pi, - RADIO_2056_RX_LNAA_TUNE - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); - } else { - if (pi->pubpi.radiorev >= 5) - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_MASTER - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); - else - write_radio_reg( - pi, - RADIO_2056_RX_LNAG_TUNE - | RADIO_2056_RX1, - pi-> - tx_rx_cal_radio_saveregs - [4]); - } - } - } -} - -static void wlc_phy_rxcal_physetup_nphy(struct brcms_phy *pi, u8 rx_core) -{ - u8 tx_core; - u16 rx_antval, tx_antval; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - tx_core = rx_core; - else - tx_core = (rx_core == PHY_CORE_0) ? 1 : 0; - - pi->tx_rx_cal_phy_saveregs[0] = read_phy_reg(pi, 0xa2); - pi->tx_rx_cal_phy_saveregs[1] = - read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0xa6 : 0xa7); - pi->tx_rx_cal_phy_saveregs[2] = - read_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x8f : 0xa5); - pi->tx_rx_cal_phy_saveregs[3] = read_phy_reg(pi, 0x91); - pi->tx_rx_cal_phy_saveregs[4] = read_phy_reg(pi, 0x92); - pi->tx_rx_cal_phy_saveregs[5] = read_phy_reg(pi, 0x7a); - pi->tx_rx_cal_phy_saveregs[6] = read_phy_reg(pi, 0x7d); - pi->tx_rx_cal_phy_saveregs[7] = read_phy_reg(pi, 0xe7); - pi->tx_rx_cal_phy_saveregs[8] = read_phy_reg(pi, 0xec); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - pi->tx_rx_cal_phy_saveregs[11] = read_phy_reg(pi, 0x342); - pi->tx_rx_cal_phy_saveregs[12] = read_phy_reg(pi, 0x343); - pi->tx_rx_cal_phy_saveregs[13] = read_phy_reg(pi, 0x346); - pi->tx_rx_cal_phy_saveregs[14] = read_phy_reg(pi, 0x347); - } - - pi->tx_rx_cal_phy_saveregs[9] = read_phy_reg(pi, 0x297); - pi->tx_rx_cal_phy_saveregs[10] = read_phy_reg(pi, 0x29b); - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 0), (0) << 0); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - mod_phy_reg(pi, 0xa2, (0xf << 0), (1 << tx_core) << 0); - - mod_phy_reg(pi, 0xa2, (0xf << 12), (1 << (1 - rx_core)) << 12); - - } else { - - mod_phy_reg(pi, 0xa2, (0xf << 12), (1 << tx_core) << 12); - mod_phy_reg(pi, 0xa2, (0xf << 0), (1 << tx_core) << 0); - mod_phy_reg(pi, 0xa2, (0xf << 4), (1 << rx_core) << 4); - mod_phy_reg(pi, 0xa2, (0xf << 8), (1 << rx_core) << 8); - } - - mod_phy_reg(pi, ((rx_core == PHY_CORE_0) ? 0xa6 : 0xa7), (0x1 << 2), 0); - mod_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x8f : 0xa5, - (0x1 << 2), (0x1 << 2)); - if (NREV_LT(pi->pubpi.phy_rev, 7)) { - mod_phy_reg(pi, ((rx_core == PHY_CORE_0) ? 0xa6 : 0xa7), - (0x1 << 0) | (0x1 << 1), 0); - mod_phy_reg(pi, (rx_core == PHY_CORE_0) ? - 0x8f : 0xa5, - (0x1 << 0) | (0x1 << 1), (0x1 << 0) | (0x1 << 1)); - } - - wlc_phy_rfctrlintc_override_nphy(pi, NPHY_RfctrlIntc_override_PA, 0, - RADIO_MIMO_CORESEL_CORE1 | - RADIO_MIMO_CORESEL_CORE2); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 3), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 9), 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 10), 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 0), 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 1), 1, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 11), 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - if (CHSPEC_IS40(pi->radio_chanspec)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 7), - 2, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - else - wlc_phy_rfctrl_override_nphy_rev7( - pi, - (0x1 << 7), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 7), - 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 5), 0, 0, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID1); - } else { - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 3), 0, 3, 0); - } - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - 0x1, rx_core + 1); - } else { - - if (rx_core == PHY_CORE_0) { - rx_antval = 0x1; - tx_antval = 0x8; - } else { - rx_antval = 0x4; - tx_antval = 0x2; - } - - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - rx_antval, rx_core + 1); - wlc_phy_rfctrlintc_override_nphy(pi, - NPHY_RfctrlIntc_override_TRSW, - tx_antval, tx_core + 1); - } -} - -static void wlc_phy_rxcal_phycleanup_nphy(struct brcms_phy *pi, u8 rx_core) -{ - - write_phy_reg(pi, 0xa2, pi->tx_rx_cal_phy_saveregs[0]); - write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0xa6 : 0xa7, - pi->tx_rx_cal_phy_saveregs[1]); - write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x8f : 0xa5, - pi->tx_rx_cal_phy_saveregs[2]); - write_phy_reg(pi, 0x91, pi->tx_rx_cal_phy_saveregs[3]); - write_phy_reg(pi, 0x92, pi->tx_rx_cal_phy_saveregs[4]); - - write_phy_reg(pi, 0x7a, pi->tx_rx_cal_phy_saveregs[5]); - write_phy_reg(pi, 0x7d, pi->tx_rx_cal_phy_saveregs[6]); - write_phy_reg(pi, 0xe7, pi->tx_rx_cal_phy_saveregs[7]); - write_phy_reg(pi, 0xec, pi->tx_rx_cal_phy_saveregs[8]); - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - write_phy_reg(pi, 0x342, pi->tx_rx_cal_phy_saveregs[11]); - write_phy_reg(pi, 0x343, pi->tx_rx_cal_phy_saveregs[12]); - write_phy_reg(pi, 0x346, pi->tx_rx_cal_phy_saveregs[13]); - write_phy_reg(pi, 0x347, pi->tx_rx_cal_phy_saveregs[14]); - } - - write_phy_reg(pi, 0x297, pi->tx_rx_cal_phy_saveregs[9]); - write_phy_reg(pi, 0x29b, pi->tx_rx_cal_phy_saveregs[10]); -} - -static void -wlc_phy_rxcal_gainctrl_nphy_rev5(struct brcms_phy *pi, u8 rx_core, - u16 *rxgain, u8 cal_type) -{ - - u16 num_samps; - struct phy_iq_est est[PHY_CORE_MAX]; - u8 tx_core; - struct nphy_iq_comp save_comp, zero_comp; - u32 i_pwr, q_pwr, curr_pwr, optim_pwr = 0, prev_pwr = 0, - thresh_pwr = 10000; - s16 desired_log2_pwr, actual_log2_pwr, delta_pwr; - bool gainctrl_done = false; - u8 mix_tia_gain = 3; - s8 optim_gaintbl_index = 0, prev_gaintbl_index = 0; - s8 curr_gaintbl_index = 3; - u8 gainctrl_dirn = NPHY_RXCAL_GAIN_INIT; - const struct nphy_ipa_txrxgain *nphy_rxcal_gaintbl; - u16 hpvga, lpf_biq1, lpf_biq0, lna2, lna1; - int fine_gain_idx; - s8 txpwrindex; - u16 nphy_rxcal_txgain[2]; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - tx_core = rx_core; - else - tx_core = 1 - rx_core; - - num_samps = 1024; - desired_log2_pwr = (cal_type == 0) ? 13 : 13; - - wlc_phy_rx_iq_coeffs_nphy(pi, 0, &save_comp); - zero_comp.a0 = zero_comp.b0 = zero_comp.a1 = zero_comp.b1 = 0x0; - wlc_phy_rx_iq_coeffs_nphy(pi, 1, &zero_comp); - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) - mix_tia_gain = 3; - else if (NREV_GE(pi->pubpi.phy_rev, 4)) - mix_tia_gain = 4; - else - mix_tia_gain = 6; - if (NREV_GE(pi->pubpi.phy_rev, 7)) - nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_5GHz_rev7; - else - nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_5GHz; - } else { - if (NREV_GE(pi->pubpi.phy_rev, 7)) - nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_2GHz_rev7; - else - nphy_rxcal_gaintbl = nphy_ipa_rxcal_gaintbl_2GHz; - } - - do { - - hpvga = (NREV_GE(pi->pubpi.phy_rev, 7)) ? - 0 : nphy_rxcal_gaintbl[curr_gaintbl_index].hpvga; - lpf_biq1 = nphy_rxcal_gaintbl[curr_gaintbl_index].lpf_biq1; - lpf_biq0 = nphy_rxcal_gaintbl[curr_gaintbl_index].lpf_biq0; - lna2 = nphy_rxcal_gaintbl[curr_gaintbl_index].lna2; - lna1 = nphy_rxcal_gaintbl[curr_gaintbl_index].lna1; - txpwrindex = nphy_rxcal_gaintbl[curr_gaintbl_index].txpwrindex; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - ((lpf_biq1 << 12) | - (lpf_biq0 << 8) | - (mix_tia_gain << 4) | (lna2 << 2) - | lna1), 0x3, 0); - else - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), - ((hpvga << 12) | - (lpf_biq1 << 10) | - (lpf_biq0 << 8) | - (mix_tia_gain << 4) | - (lna2 << 2) | lna1), 0x3, - 0); - - pi->nphy_rxcal_pwr_idx[tx_core] = txpwrindex; - - if (txpwrindex == -1) { - nphy_rxcal_txgain[0] = 0x8ff0 | pi->nphy_gmval; - nphy_rxcal_txgain[1] = 0x8ff0 | pi->nphy_gmval; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 2, 0x110, 16, - nphy_rxcal_txgain); - } else { - wlc_phy_txpwr_index_nphy(pi, tx_core + 1, txpwrindex, - false); - } - - wlc_phy_tx_tone_nphy(pi, (CHSPEC_IS40(pi->radio_chanspec)) ? - NPHY_RXCAL_TONEFREQ_40MHz : - NPHY_RXCAL_TONEFREQ_20MHz, - NPHY_RXCAL_TONEAMP, 0, cal_type, false); - - wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - i_pwr = (est[rx_core].i_pwr + num_samps / 2) / num_samps; - q_pwr = (est[rx_core].q_pwr + num_samps / 2) / num_samps; - curr_pwr = i_pwr + q_pwr; - - switch (gainctrl_dirn) { - case NPHY_RXCAL_GAIN_INIT: - if (curr_pwr > thresh_pwr) { - gainctrl_dirn = NPHY_RXCAL_GAIN_DOWN; - prev_gaintbl_index = curr_gaintbl_index; - curr_gaintbl_index--; - } else { - gainctrl_dirn = NPHY_RXCAL_GAIN_UP; - prev_gaintbl_index = curr_gaintbl_index; - curr_gaintbl_index++; - } - break; - - case NPHY_RXCAL_GAIN_UP: - if (curr_pwr > thresh_pwr) { - gainctrl_done = true; - optim_pwr = prev_pwr; - optim_gaintbl_index = prev_gaintbl_index; - } else { - prev_gaintbl_index = curr_gaintbl_index; - curr_gaintbl_index++; - } - break; - - case NPHY_RXCAL_GAIN_DOWN: - if (curr_pwr > thresh_pwr) { - prev_gaintbl_index = curr_gaintbl_index; - curr_gaintbl_index--; - } else { - gainctrl_done = true; - optim_pwr = curr_pwr; - optim_gaintbl_index = curr_gaintbl_index; - } - break; - - default: - break; - } - - if ((curr_gaintbl_index < 0) || - (curr_gaintbl_index > NPHY_IPA_RXCAL_MAXGAININDEX)) { - gainctrl_done = true; - optim_pwr = curr_pwr; - optim_gaintbl_index = prev_gaintbl_index; - } else { - prev_pwr = curr_pwr; - } - - wlc_phy_stopplayback_nphy(pi); - } while (!gainctrl_done); - - hpvga = nphy_rxcal_gaintbl[optim_gaintbl_index].hpvga; - lpf_biq1 = nphy_rxcal_gaintbl[optim_gaintbl_index].lpf_biq1; - lpf_biq0 = nphy_rxcal_gaintbl[optim_gaintbl_index].lpf_biq0; - lna2 = nphy_rxcal_gaintbl[optim_gaintbl_index].lna2; - lna1 = nphy_rxcal_gaintbl[optim_gaintbl_index].lna1; - txpwrindex = nphy_rxcal_gaintbl[optim_gaintbl_index].txpwrindex; - - actual_log2_pwr = wlc_phy_nbits(optim_pwr); - delta_pwr = desired_log2_pwr - actual_log2_pwr; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - fine_gain_idx = (int)lpf_biq1 + delta_pwr; - - if (fine_gain_idx + (int)lpf_biq0 > 10) - lpf_biq1 = 10 - lpf_biq0; - else - lpf_biq1 = (u16) max(fine_gain_idx, 0); - - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - ((lpf_biq1 << 12) | - (lpf_biq0 << 8) | - (mix_tia_gain << 4) | - (lna2 << 2) | lna1), 0x3, - 0); - } else { - hpvga = (u16) max(min(((int)hpvga) + delta_pwr, 10), 0); - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), - ((hpvga << 12) | - (lpf_biq1 << 10) | - (lpf_biq0 << 8) | - (mix_tia_gain << 4) | - (lna2 << 2) | - lna1), 0x3, 0); - } - - if (rxgain != NULL) { - *rxgain++ = lna1; - *rxgain++ = lna2; - *rxgain++ = mix_tia_gain; - *rxgain++ = lpf_biq0; - *rxgain++ = lpf_biq1; - *rxgain = hpvga; - } - - wlc_phy_rx_iq_coeffs_nphy(pi, 1, &save_comp); -} - -static void -wlc_phy_rxcal_gainctrl_nphy(struct brcms_phy *pi, u8 rx_core, u16 *rxgain, - u8 cal_type) -{ - wlc_phy_rxcal_gainctrl_nphy_rev5(pi, rx_core, rxgain, cal_type); -} - -static u8 -wlc_phy_rc_sweep_nphy(struct brcms_phy *pi, u8 core_idx, u8 loopback_type) -{ - u32 target_bws[2] = { 9500, 21000 }; - u32 ref_tones[2] = { 3000, 6000 }; - u32 target_bw, ref_tone; - - u32 target_pwr_ratios[2] = { 28606, 18468 }; - u32 target_pwr_ratio, pwr_ratio, last_pwr_ratio = 0; - - u16 start_rccal_ovr_val = 128; - u16 txlpf_rccal_lpc_ovr_val = 128; - u16 rxlpf_rccal_hpc_ovr_val = 159; - - u16 orig_txlpf_rccal_lpc_ovr_val; - u16 orig_rxlpf_rccal_hpc_ovr_val; - u16 radio_addr_offset_rx; - u16 radio_addr_offset_tx; - u16 orig_dcBypass; - u16 orig_RxStrnFilt40Num[6]; - u16 orig_RxStrnFilt40Den[4]; - u16 orig_rfctrloverride[2]; - u16 orig_rfctrlauxreg[2]; - u16 orig_rfctrlrssiothers; - u16 tx_lpf_bw = 4; - - u16 rx_lpf_bw, rx_lpf_bws[2] = { 2, 4 }; - u16 lpf_hpc = 7, hpvga_hpc = 7; - - s8 rccal_stepsize; - u16 rccal_val, last_rccal_val = 0, best_rccal_val = 0; - u32 ref_iq_vals = 0, target_iq_vals = 0; - u16 num_samps, log_num_samps = 10; - struct phy_iq_est est[PHY_CORE_MAX]; - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - return 0; - - num_samps = (1 << log_num_samps); - - if (CHSPEC_IS40(pi->radio_chanspec)) { - target_bw = target_bws[1]; - target_pwr_ratio = target_pwr_ratios[1]; - ref_tone = ref_tones[1]; - rx_lpf_bw = rx_lpf_bws[1]; - } else { - target_bw = target_bws[0]; - target_pwr_ratio = target_pwr_ratios[0]; - ref_tone = ref_tones[0]; - rx_lpf_bw = rx_lpf_bws[0]; - } - - if (core_idx == 0) { - radio_addr_offset_rx = RADIO_2056_RX0; - radio_addr_offset_tx = - (loopback_type == 0) ? RADIO_2056_TX0 : RADIO_2056_TX1; - } else { - radio_addr_offset_rx = RADIO_2056_RX1; - radio_addr_offset_tx = - (loopback_type == 0) ? RADIO_2056_TX1 : RADIO_2056_TX0; - } - - orig_txlpf_rccal_lpc_ovr_val = - read_radio_reg(pi, - (RADIO_2056_TX_TXLPF_RCCAL | - radio_addr_offset_tx)); - orig_rxlpf_rccal_hpc_ovr_val = - read_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_HPC | - radio_addr_offset_rx)); - - orig_dcBypass = ((read_phy_reg(pi, 0x48) >> 8) & 1); - - orig_RxStrnFilt40Num[0] = read_phy_reg(pi, 0x267); - orig_RxStrnFilt40Num[1] = read_phy_reg(pi, 0x268); - orig_RxStrnFilt40Num[2] = read_phy_reg(pi, 0x269); - orig_RxStrnFilt40Den[0] = read_phy_reg(pi, 0x26a); - orig_RxStrnFilt40Den[1] = read_phy_reg(pi, 0x26b); - orig_RxStrnFilt40Num[3] = read_phy_reg(pi, 0x26c); - orig_RxStrnFilt40Num[4] = read_phy_reg(pi, 0x26d); - orig_RxStrnFilt40Num[5] = read_phy_reg(pi, 0x26e); - orig_RxStrnFilt40Den[2] = read_phy_reg(pi, 0x26f); - orig_RxStrnFilt40Den[3] = read_phy_reg(pi, 0x270); - - orig_rfctrloverride[0] = read_phy_reg(pi, 0xe7); - orig_rfctrloverride[1] = read_phy_reg(pi, 0xec); - orig_rfctrlauxreg[0] = read_phy_reg(pi, 0xf8); - orig_rfctrlauxreg[1] = read_phy_reg(pi, 0xfa); - orig_rfctrlrssiothers = read_phy_reg(pi, (core_idx == 0) ? 0x7a : 0x7d); - - write_radio_reg(pi, (RADIO_2056_TX_TXLPF_RCCAL | radio_addr_offset_tx), - txlpf_rccal_lpc_ovr_val); - - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_HPC | radio_addr_offset_rx), - rxlpf_rccal_hpc_ovr_val); - - mod_phy_reg(pi, 0x48, (0x1 << 8), (0x1 << 8)); - - write_phy_reg(pi, 0x267, 0x02d4); - write_phy_reg(pi, 0x268, 0x0000); - write_phy_reg(pi, 0x269, 0x0000); - write_phy_reg(pi, 0x26a, 0x0000); - write_phy_reg(pi, 0x26b, 0x0000); - write_phy_reg(pi, 0x26c, 0x02d4); - write_phy_reg(pi, 0x26d, 0x0000); - write_phy_reg(pi, 0x26e, 0x0000); - write_phy_reg(pi, 0x26f, 0x0000); - write_phy_reg(pi, 0x270, 0x0000); - - or_phy_reg(pi, (core_idx == 0) ? 0xe7 : 0xec, (0x1 << 8)); - or_phy_reg(pi, (core_idx == 0) ? 0xec : 0xe7, (0x1 << 15)); - or_phy_reg(pi, (core_idx == 0) ? 0xe7 : 0xec, (0x1 << 9)); - or_phy_reg(pi, (core_idx == 0) ? 0xe7 : 0xec, (0x1 << 10)); - - mod_phy_reg(pi, (core_idx == 0) ? 0xfa : 0xf8, - (0x7 << 10), (tx_lpf_bw << 10)); - mod_phy_reg(pi, (core_idx == 0) ? 0xf8 : 0xfa, - (0x7 << 0), (hpvga_hpc << 0)); - mod_phy_reg(pi, (core_idx == 0) ? 0xf8 : 0xfa, - (0x7 << 4), (lpf_hpc << 4)); - mod_phy_reg(pi, (core_idx == 0) ? 0x7a : 0x7d, - (0x7 << 8), (rx_lpf_bw << 8)); - - rccal_stepsize = 16; - rccal_val = start_rccal_ovr_val + rccal_stepsize; - - while (rccal_stepsize >= 0) { - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - radio_addr_offset_rx), rccal_val); - - if (rccal_stepsize == 16) { - - wlc_phy_tx_tone_nphy(pi, ref_tone, NPHY_RXCAL_TONEAMP, - 0, 1, false); - udelay(2); - - wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - - if (core_idx == 0) - ref_iq_vals = - max_t(u32, (est[0].i_pwr + - est[0].q_pwr) >> - (log_num_samps + 1), - 1); - else - ref_iq_vals = - max_t(u32, (est[1].i_pwr + - est[1].q_pwr) >> - (log_num_samps + 1), - 1); - - wlc_phy_tx_tone_nphy(pi, target_bw, NPHY_RXCAL_TONEAMP, - 0, 1, false); - udelay(2); - } - - wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0); - - if (core_idx == 0) - target_iq_vals = (est[0].i_pwr + est[0].q_pwr) >> - (log_num_samps + 1); - else - target_iq_vals = - (est[1].i_pwr + - est[1].q_pwr) >> (log_num_samps + 1); - - pwr_ratio = (uint) ((target_iq_vals << 16) / ref_iq_vals); - - if (rccal_stepsize == 0) - rccal_stepsize--; - else if (rccal_stepsize == 1) { - last_rccal_val = rccal_val; - rccal_val += (pwr_ratio > target_pwr_ratio) ? 1 : -1; - last_pwr_ratio = pwr_ratio; - rccal_stepsize--; - } else { - rccal_stepsize = (rccal_stepsize >> 1); - rccal_val += ((pwr_ratio > target_pwr_ratio) ? - rccal_stepsize : (-rccal_stepsize)); - } - - if (rccal_stepsize == -1) { - best_rccal_val = - (abs((int)last_pwr_ratio - - (int)target_pwr_ratio) < - abs((int)pwr_ratio - - (int)target_pwr_ratio)) ? last_rccal_val : - rccal_val; - - if (CHSPEC_IS40(pi->radio_chanspec)) { - if ((best_rccal_val > 140) - || (best_rccal_val < 135)) - best_rccal_val = 138; - } else { - if ((best_rccal_val > 142) - || (best_rccal_val < 137)) - best_rccal_val = 140; - } - - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - radio_addr_offset_rx), best_rccal_val); - } - } - - wlc_phy_stopplayback_nphy(pi); - - write_radio_reg(pi, (RADIO_2056_TX_TXLPF_RCCAL | radio_addr_offset_tx), - orig_txlpf_rccal_lpc_ovr_val); - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_HPC | radio_addr_offset_rx), - orig_rxlpf_rccal_hpc_ovr_val); - - mod_phy_reg(pi, 0x48, (0x1 << 8), (orig_dcBypass << 8)); - - write_phy_reg(pi, 0x267, orig_RxStrnFilt40Num[0]); - write_phy_reg(pi, 0x268, orig_RxStrnFilt40Num[1]); - write_phy_reg(pi, 0x269, orig_RxStrnFilt40Num[2]); - write_phy_reg(pi, 0x26a, orig_RxStrnFilt40Den[0]); - write_phy_reg(pi, 0x26b, orig_RxStrnFilt40Den[1]); - write_phy_reg(pi, 0x26c, orig_RxStrnFilt40Num[3]); - write_phy_reg(pi, 0x26d, orig_RxStrnFilt40Num[4]); - write_phy_reg(pi, 0x26e, orig_RxStrnFilt40Num[5]); - write_phy_reg(pi, 0x26f, orig_RxStrnFilt40Den[2]); - write_phy_reg(pi, 0x270, orig_RxStrnFilt40Den[3]); - - write_phy_reg(pi, 0xe7, orig_rfctrloverride[0]); - write_phy_reg(pi, 0xec, orig_rfctrloverride[1]); - write_phy_reg(pi, 0xf8, orig_rfctrlauxreg[0]); - write_phy_reg(pi, 0xfa, orig_rfctrlauxreg[1]); - write_phy_reg(pi, (core_idx == 0) ? 0x7a : 0x7d, orig_rfctrlrssiothers); - - pi->nphy_anarxlpf_adjusted = false; - - return best_rccal_val - 0x80; -} - -#define WAIT_FOR_SCOPE 4000 -static int wlc_phy_cal_rxiq_nphy_rev3(struct brcms_phy *pi, - struct nphy_txgains target_gain, - u8 cal_type, bool debug) -{ - u16 orig_BBConfig; - u8 core_no, rx_core; - u8 best_rccal[2]; - u16 gain_save[2]; - u16 cal_gain[2]; - struct nphy_iqcal_params cal_params[2]; - u8 rxcore_state; - s8 rxlpf_rccal_hpc, txlpf_rccal_lpc; - s8 txlpf_idac; - bool phyhang_avoid_state = false; - bool skip_rxiqcal = false; - - orig_BBConfig = read_phy_reg(pi, 0x01); - mod_phy_reg(pi, 0x01, (0x1 << 15), 0); - - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (NREV_GE(pi->pubpi.phy_rev, 4)) { - phyhang_avoid_state = pi->phyhang_avoid; - pi->phyhang_avoid = false; - } - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); - - for (core_no = 0; core_no <= 1; core_no++) { - wlc_phy_iqcal_gainparams_nphy(pi, core_no, target_gain, - &cal_params[core_no]); - cal_gain[core_no] = cal_params[core_no].cal_gain; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, cal_gain); - - rxcore_state = wlc_phy_rxcore_getstate_nphy( - (struct brcms_phy_pub *) pi); - - for (rx_core = 0; rx_core < pi->pubpi.phy_corenum; rx_core++) { - - skip_rxiqcal = - ((rxcore_state & (1 << rx_core)) == 0) ? true : false; - - wlc_phy_rxcal_physetup_nphy(pi, rx_core); - - wlc_phy_rxcal_radio_setup_nphy(pi, rx_core); - - if ((!skip_rxiqcal) && ((cal_type == 0) || (cal_type == 2))) { - - wlc_phy_rxcal_gainctrl_nphy(pi, rx_core, NULL, 0); - - wlc_phy_tx_tone_nphy(pi, - (CHSPEC_IS40( - pi->radio_chanspec)) ? - NPHY_RXCAL_TONEFREQ_40MHz : - NPHY_RXCAL_TONEFREQ_20MHz, - NPHY_RXCAL_TONEAMP, 0, cal_type, - false); - - if (debug) - mdelay(WAIT_FOR_SCOPE); - - wlc_phy_calc_rx_iq_comp_nphy(pi, rx_core + 1); - wlc_phy_stopplayback_nphy(pi); - } - - if (((cal_type == 1) || (cal_type == 2)) - && NREV_LT(pi->pubpi.phy_rev, 7)) { - - if (rx_core == PHY_CORE_1) { - - if (rxcore_state == 1) - wlc_phy_rxcore_setstate_nphy( - (struct brcms_phy_pub *) pi, 3); - - wlc_phy_rxcal_gainctrl_nphy(pi, rx_core, NULL, - 1); - - best_rccal[rx_core] = - wlc_phy_rc_sweep_nphy(pi, rx_core, 1); - pi->nphy_rccal_value = best_rccal[rx_core]; - - if (rxcore_state == 1) - wlc_phy_rxcore_setstate_nphy( - (struct brcms_phy_pub *) pi, - rxcore_state); - } - } - - wlc_phy_rxcal_radio_cleanup_nphy(pi, rx_core); - - wlc_phy_rxcal_phycleanup_nphy(pi, rx_core); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - } - - if ((cal_type == 1) || (cal_type == 2)) { - - best_rccal[0] = best_rccal[1]; - write_radio_reg(pi, - (RADIO_2056_RX_RXLPF_RCCAL_LPC | - RADIO_2056_RX0), (best_rccal[0] | 0x80)); - - for (rx_core = 0; rx_core < pi->pubpi.phy_corenum; rx_core++) { - rxlpf_rccal_hpc = - (((int)best_rccal[rx_core] - 12) >> 1) + 10; - txlpf_rccal_lpc = ((int)best_rccal[rx_core] - 12) + 10; - - if (PHY_IPA(pi)) { - txlpf_rccal_lpc += - (pi->bw == WL_CHANSPEC_BW_40) ? 24 : 12; - txlpf_idac = (pi->bw == WL_CHANSPEC_BW_40) ? - 0x0e : 0x13; - WRITE_RADIO_REG2(pi, RADIO_2056, TX, rx_core, - TXLPF_IDAC_4, txlpf_idac); - } - - rxlpf_rccal_hpc = max(min_t(u8, rxlpf_rccal_hpc, 31), - 0); - txlpf_rccal_lpc = max(min_t(u8, txlpf_rccal_lpc, 31), - 0); - - write_radio_reg(pi, (RADIO_2056_RX_RXLPF_RCCAL_HPC | - ((rx_core == - PHY_CORE_0) ? RADIO_2056_RX0 : - RADIO_2056_RX1)), - (rxlpf_rccal_hpc | 0x80)); - - write_radio_reg(pi, (RADIO_2056_TX_TXLPF_RCCAL | - ((rx_core == - PHY_CORE_0) ? RADIO_2056_TX0 : - RADIO_2056_TX1)), - (txlpf_rccal_lpc | 0x80)); - } - } - - write_phy_reg(pi, 0x01, orig_BBConfig); - - wlc_phy_resetcca_nphy(pi); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - wlc_phy_rfctrl_override_1tomany_nphy( - pi, - NPHY_REV7_RfctrlOverride_cmd_rxgain, - 0, 0x3, 1); - else - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 12), 0, 0x3, 1); - - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - gain_save); - - if (NREV_GE(pi->pubpi.phy_rev, 4)) - pi->phyhang_avoid = phyhang_avoid_state; - - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - return 0; -} - -static int -wlc_phy_cal_rxiq_nphy_rev2(struct brcms_phy *pi, - struct nphy_txgains target_gain, bool debug) -{ - struct phy_iq_est est[PHY_CORE_MAX]; - u8 core_num, rx_core, tx_core; - u16 lna_vals[] = { 0x3, 0x3, 0x1 }; - u16 hpf1_vals[] = { 0x7, 0x2, 0x0 }; - u16 hpf2_vals[] = { 0x2, 0x0, 0x0 }; - s16 curr_hpf1, curr_hpf2, curr_hpf, curr_lna; - s16 desired_log2_pwr, actual_log2_pwr, hpf_change; - u16 orig_RfseqCoreActv, orig_AfectrlCore, orig_AfectrlOverride; - u16 orig_RfctrlIntcRx, orig_RfctrlIntcTx; - u16 num_samps; - u32 i_pwr, q_pwr, tot_pwr[3]; - u8 gain_pass, use_hpf_num; - u16 mask, val1, val2; - u16 core_no; - u16 gain_save[2]; - u16 cal_gain[2]; - struct nphy_iqcal_params cal_params[2]; - u8 phy_bw; - int bcmerror = 0; - bool first_playtone = true; - - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (NREV_LT(pi->pubpi.phy_rev, 2)) - wlc_phy_reapply_txcal_coeffs_nphy(pi); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, gain_save); - - for (core_no = 0; core_no <= 1; core_no++) { - wlc_phy_iqcal_gainparams_nphy(pi, core_no, target_gain, - &cal_params[core_no]); - cal_gain[core_no] = cal_params[core_no].cal_gain; - } - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, cal_gain); - - num_samps = 1024; - desired_log2_pwr = 13; - - for (core_num = 0; core_num < 2; core_num++) { - - rx_core = core_num; - tx_core = 1 - core_num; - - orig_RfseqCoreActv = read_phy_reg(pi, 0xa2); - orig_AfectrlCore = read_phy_reg(pi, (rx_core == PHY_CORE_0) ? - 0xa6 : 0xa7); - orig_AfectrlOverride = read_phy_reg(pi, 0xa5); - orig_RfctrlIntcRx = read_phy_reg(pi, (rx_core == PHY_CORE_0) ? - 0x91 : 0x92); - orig_RfctrlIntcTx = read_phy_reg(pi, (tx_core == PHY_CORE_0) ? - 0x91 : 0x92); - - mod_phy_reg(pi, 0xa2, (0xf << 12), (1 << tx_core) << 12); - mod_phy_reg(pi, 0xa2, (0xf << 0), (1 << tx_core) << 0); - - or_phy_reg(pi, ((rx_core == PHY_CORE_0) ? 0xa6 : 0xa7), - ((0x1 << 1) | (0x1 << 2))); - or_phy_reg(pi, 0xa5, ((0x1 << 1) | (0x1 << 2))); - - if (((pi->nphy_rxcalparams) & 0xff000000)) - write_phy_reg(pi, - (rx_core == PHY_CORE_0) ? 0x91 : 0x92, - (CHSPEC_IS5G(pi->radio_chanspec) ? - 0x140 : 0x110)); - else - write_phy_reg(pi, - (rx_core == PHY_CORE_0) ? 0x91 : 0x92, - (CHSPEC_IS5G(pi->radio_chanspec) ? - 0x180 : 0x120)); - - write_phy_reg(pi, (tx_core == PHY_CORE_0) ? 0x91 : 0x92, - (CHSPEC_IS5G(pi->radio_chanspec) ? 0x148 : - 0x114)); - - mask = RADIO_2055_COUPLE_RX_MASK | RADIO_2055_COUPLE_TX_MASK; - if (rx_core == PHY_CORE_0) { - val1 = RADIO_2055_COUPLE_RX_MASK; - val2 = RADIO_2055_COUPLE_TX_MASK; - } else { - val1 = RADIO_2055_COUPLE_TX_MASK; - val2 = RADIO_2055_COUPLE_RX_MASK; - } - - if ((pi->nphy_rxcalparams & 0x10000)) { - mod_radio_reg(pi, RADIO_2055_CORE1_GEN_SPARE2, mask, - val1); - mod_radio_reg(pi, RADIO_2055_CORE2_GEN_SPARE2, mask, - val2); - } - - for (gain_pass = 0; gain_pass < 4; gain_pass++) { - - if (debug) - mdelay(WAIT_FOR_SCOPE); - - if (gain_pass < 3) { - curr_lna = lna_vals[gain_pass]; - curr_hpf1 = hpf1_vals[gain_pass]; - curr_hpf2 = hpf2_vals[gain_pass]; - } else { - - if (tot_pwr[1] > 10000) { - curr_lna = lna_vals[2]; - curr_hpf1 = hpf1_vals[2]; - curr_hpf2 = hpf2_vals[2]; - use_hpf_num = 1; - curr_hpf = curr_hpf1; - actual_log2_pwr = - wlc_phy_nbits(tot_pwr[2]); - } else { - if (tot_pwr[0] > 10000) { - curr_lna = lna_vals[1]; - curr_hpf1 = hpf1_vals[1]; - curr_hpf2 = hpf2_vals[1]; - use_hpf_num = 1; - curr_hpf = curr_hpf1; - actual_log2_pwr = - wlc_phy_nbits( - tot_pwr[1]); - } else { - curr_lna = lna_vals[0]; - curr_hpf1 = hpf1_vals[0]; - curr_hpf2 = hpf2_vals[0]; - use_hpf_num = 2; - curr_hpf = curr_hpf2; - actual_log2_pwr = - wlc_phy_nbits( - tot_pwr[0]); - } - } - - hpf_change = desired_log2_pwr - actual_log2_pwr; - curr_hpf += hpf_change; - curr_hpf = max(min_t(u16, curr_hpf, 10), 0); - if (use_hpf_num == 1) - curr_hpf1 = curr_hpf; - else - curr_hpf2 = curr_hpf; - } - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 10), - ((curr_hpf2 << 8) | - (curr_hpf1 << 4) | - (curr_lna << 2)), 0x3, 0); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - - wlc_phy_stopplayback_nphy(pi); - - if (first_playtone) { - bcmerror = wlc_phy_tx_tone_nphy(pi, 4000, - (u16) (pi->nphy_rxcalparams & - 0xffff), 0, 0, true); - first_playtone = false; - } else { - phy_bw = (CHSPEC_IS40(pi->radio_chanspec)) ? - 40 : 20; - wlc_phy_runsamples_nphy(pi, phy_bw * 8, 0xffff, - 0, 0, 0, true); - } - - if (bcmerror == 0) { - if (gain_pass < 3) { - - wlc_phy_rx_iq_est_nphy(pi, est, - num_samps, 32, - 0); - i_pwr = (est[rx_core].i_pwr + - num_samps / 2) / num_samps; - q_pwr = (est[rx_core].q_pwr + - num_samps / 2) / num_samps; - tot_pwr[gain_pass] = i_pwr + q_pwr; - } else { - - wlc_phy_calc_rx_iq_comp_nphy(pi, - (1 << - rx_core)); - } - - wlc_phy_stopplayback_nphy(pi); - } - - if (bcmerror != 0) - break; - } - - and_radio_reg(pi, RADIO_2055_CORE1_GEN_SPARE2, ~mask); - and_radio_reg(pi, RADIO_2055_CORE2_GEN_SPARE2, ~mask); - - write_phy_reg(pi, (tx_core == PHY_CORE_0) ? 0x91 : - 0x92, orig_RfctrlIntcTx); - write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0x91 : - 0x92, orig_RfctrlIntcRx); - write_phy_reg(pi, 0xa5, orig_AfectrlOverride); - write_phy_reg(pi, (rx_core == PHY_CORE_0) ? 0xa6 : - 0xa7, orig_AfectrlCore); - write_phy_reg(pi, 0xa2, orig_RfseqCoreActv); - - if (bcmerror != 0) - break; - } - - wlc_phy_rfctrl_override_nphy(pi, (0x1 << 10), 0, 0x3, 1); - wlc_phy_force_rfseq_nphy(pi, NPHY_RFSEQ_RESET2RX); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x110, 16, - gain_save); - - wlc_phy_stay_in_carriersearch_nphy(pi, false); - - return bcmerror; -} - -int -wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, - u8 cal_type, bool debug) -{ - if (NREV_GE(pi->pubpi.phy_rev, 7)) - cal_type = 0; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - return wlc_phy_cal_rxiq_nphy_rev3(pi, target_gain, cal_type, - debug); - else - return wlc_phy_cal_rxiq_nphy_rev2(pi, target_gain, debug); -} - -void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) -{ - uint core; - u32 txgain; - u16 rad_gain, dac_gain, bbmult, m1m2; - u8 txpi[2], chan_freq_range; - s32 rfpwr_offset; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - if (pi->sh->sromrev < 4) { - txpi[0] = txpi[1] = 72; - } else { - - chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_2G: - txpi[0] = pi->nphy_txpid2g[0]; - txpi[1] = pi->nphy_txpid2g[1]; - break; - case WL_CHAN_FREQ_RANGE_5GL: - txpi[0] = pi->nphy_txpid5gl[0]; - txpi[1] = pi->nphy_txpid5gl[1]; - break; - case WL_CHAN_FREQ_RANGE_5GM: - txpi[0] = pi->nphy_txpid5g[0]; - txpi[1] = pi->nphy_txpid5g[1]; - break; - case WL_CHAN_FREQ_RANGE_5GH: - txpi[0] = pi->nphy_txpid5gh[0]; - txpi[1] = pi->nphy_txpid5gh[1]; - break; - default: - txpi[0] = txpi[1] = 91; - break; - } - } - - if (NREV_GE(pi->pubpi.phy_rev, 7)) - txpi[0] = txpi[1] = 30; - else if (NREV_GE(pi->pubpi.phy_rev, 3)) - txpi[0] = txpi[1] = 40; - - if (NREV_LT(pi->pubpi.phy_rev, 7)) { - - if ((txpi[0] < 40) || (txpi[0] > 100) || - (txpi[1] < 40) || (txpi[1] > 100)) - txpi[0] = txpi[1] = 91; - } - - pi->nphy_txpwrindex[PHY_CORE_0].index_internal = txpi[0]; - pi->nphy_txpwrindex[PHY_CORE_1].index_internal = txpi[1]; - pi->nphy_txpwrindex[PHY_CORE_0].index_internal_save = txpi[0]; - pi->nphy_txpwrindex[PHY_CORE_1].index_internal_save = txpi[1]; - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - uint phyrev = pi->pubpi.phy_rev; - - if (NREV_GE(phyrev, 3)) { - if (PHY_IPA(pi)) { - u32 *tx_gaintbl = - wlc_phy_get_ipa_gaintbl_nphy(pi); - txgain = tx_gaintbl[txpi[core]]; - } else { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_IS(phyrev, 3)) { - txgain = - nphy_tpc_5GHz_txgain_rev3 - [txpi[core]]; - } else if (NREV_IS(phyrev, 4)) { - txgain = ( - pi->srom_fem5g.extpagain == - 3) ? - nphy_tpc_5GHz_txgain_HiPwrEPA - [txpi[core]] : - nphy_tpc_5GHz_txgain_rev4 - [txpi[core]]; - } else { - txgain = - nphy_tpc_5GHz_txgain_rev5 - [txpi[core]]; - } - } else { - if (NREV_GE(phyrev, 5) && - (pi->srom_fem2g.extpagain == 3)) { - txgain = - nphy_tpc_txgain_HiPwrEPA - [txpi[core]]; - } else { - txgain = nphy_tpc_txgain_rev3 - [txpi[core]]; - } - } - } - } else { - txgain = nphy_tpc_txgain[txpi[core]]; - } - - if (NREV_GE(phyrev, 3)) - rad_gain = (txgain >> 16) & ((1 << (32 - 16 + 1)) - 1); - else - rad_gain = (txgain >> 16) & ((1 << (28 - 16 + 1)) - 1); - - if (NREV_GE(phyrev, 7)) - dac_gain = (txgain >> 8) & ((1 << (10 - 8 + 1)) - 1); - else - dac_gain = (txgain >> 8) & ((1 << (13 - 8 + 1)) - 1); - - bbmult = (txgain >> 0) & ((1 << (7 - 0 + 1)) - 1); - - if (NREV_GE(phyrev, 3)) - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), (0x1 << 8), (0x1 << 8)); - else - mod_phy_reg(pi, 0xa5, (0x1 << 14), (0x1 << 14)); - - write_phy_reg(pi, (core == PHY_CORE_0) ? 0xaa : 0xab, dac_gain); - - wlc_phy_table_write_nphy(pi, 7, 1, (0x110 + core), 16, - &rad_gain); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m1m2); - m1m2 &= ((core == PHY_CORE_0) ? 0x00ff : 0xff00); - m1m2 |= ((core == PHY_CORE_0) ? (bbmult << 8) : (bbmult << 0)); - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m1m2); - - if (PHY_IPA(pi)) { - wlc_phy_table_read_nphy(pi, - (core == - PHY_CORE_0 ? - NPHY_TBL_ID_CORE1TXPWRCTL : - NPHY_TBL_ID_CORE2TXPWRCTL), 1, - 576 + txpi[core], 32, - &rfpwr_offset); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1ff << 4), - ((s16) rfpwr_offset) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 2), (1) << 2); - - } - } - - and_phy_reg(pi, 0xbf, (u16) (~(0x1f << 0))); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -static void -wlc_phy_txpwr_nphy_srom_convert(u8 *srom_max, u16 *pwr_offset, - u8 tmp_max_pwr, u8 rate_start, - u8 rate_end) -{ - u8 rate; - u8 word_num, nibble_num; - u8 tmp_nibble; - - for (rate = rate_start; rate <= rate_end; rate++) { - word_num = (rate - rate_start) >> 2; - nibble_num = (rate - rate_start) & 0x3; - tmp_nibble = (pwr_offset[word_num] >> 4 * nibble_num) & 0xf; - - srom_max[rate] = tmp_max_pwr - 2 * tmp_nibble; - } -} - -static void -wlc_phy_txpwr_nphy_po_apply(u8 *srom_max, u8 pwr_offset, - u8 rate_start, u8 rate_end) -{ - u8 rate; - - for (rate = rate_start; rate <= rate_end; rate++) - srom_max[rate] -= 2 * pwr_offset; -} - -void -wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start, - u8 rate_mcs_end, u8 rate_ofdm_start) -{ - u8 rate1, rate2; - - rate2 = rate_ofdm_start; - for (rate1 = rate_mcs_start; rate1 <= rate_mcs_end - 1; rate1++) { - power[rate1] = power[rate2]; - rate2 += (rate1 == rate_mcs_start) ? 2 : 1; - } - power[rate_mcs_end] = power[rate_mcs_end - 1]; -} - -void -wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, u8 rate_ofdm_start, - u8 rate_ofdm_end, u8 rate_mcs_start) -{ - u8 rate1, rate2; - - for (rate1 = rate_ofdm_start, rate2 = rate_mcs_start; - rate1 <= rate_ofdm_end; rate1++, rate2++) { - power[rate1] = power[rate2]; - if (rate1 == rate_ofdm_start) - power[++rate1] = power[rate2]; - } -} - -void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi) -{ - uint rate1, rate2, band_num; - u8 tmp_bw40po = 0, tmp_cddpo = 0, tmp_stbcpo = 0; - u8 tmp_max_pwr = 0; - u16 pwr_offsets1[2], *pwr_offsets2 = NULL; - u8 *tx_srom_max_rate = NULL; - - for (band_num = 0; band_num < (CH_2G_GROUP + CH_5G_GROUP); - band_num++) { - switch (band_num) { - case 0: - - tmp_max_pwr = min(pi->nphy_pwrctrl_info[0].max_pwr_2g, - pi->nphy_pwrctrl_info[1].max_pwr_2g); - - pwr_offsets1[0] = pi->cck2gpo; - wlc_phy_txpwr_nphy_srom_convert(pi->tx_srom_max_rate_2g, - pwr_offsets1, - tmp_max_pwr, - TXP_FIRST_CCK, - TXP_LAST_CCK); - - pwr_offsets1[0] = (u16) (pi->ofdm2gpo & 0xffff); - pwr_offsets1[1] = - (u16) (pi->ofdm2gpo >> 16) & 0xffff; - - pwr_offsets2 = pi->mcs2gpo; - - tmp_cddpo = pi->cdd2gpo; - tmp_stbcpo = pi->stbc2gpo; - tmp_bw40po = pi->bw402gpo; - - tx_srom_max_rate = pi->tx_srom_max_rate_2g; - break; - case 1: - - tmp_max_pwr = min(pi->nphy_pwrctrl_info[0].max_pwr_5gm, - pi->nphy_pwrctrl_info[1].max_pwr_5gm); - - pwr_offsets1[0] = (u16) (pi->ofdm5gpo & 0xffff); - pwr_offsets1[1] = - (u16) (pi->ofdm5gpo >> 16) & 0xffff; - - pwr_offsets2 = pi->mcs5gpo; - - tmp_cddpo = pi->cdd5gpo; - tmp_stbcpo = pi->stbc5gpo; - tmp_bw40po = pi->bw405gpo; - - tx_srom_max_rate = pi->tx_srom_max_rate_5g_mid; - break; - case 2: - - tmp_max_pwr = min(pi->nphy_pwrctrl_info[0].max_pwr_5gl, - pi->nphy_pwrctrl_info[1].max_pwr_5gl); - - pwr_offsets1[0] = (u16) (pi->ofdm5glpo & 0xffff); - pwr_offsets1[1] = - (u16) (pi->ofdm5glpo >> 16) & 0xffff; - - pwr_offsets2 = pi->mcs5glpo; - - tmp_cddpo = pi->cdd5glpo; - tmp_stbcpo = pi->stbc5glpo; - tmp_bw40po = pi->bw405glpo; - - tx_srom_max_rate = pi->tx_srom_max_rate_5g_low; - break; - case 3: - - tmp_max_pwr = min(pi->nphy_pwrctrl_info[0].max_pwr_5gh, - pi->nphy_pwrctrl_info[1].max_pwr_5gh); - - pwr_offsets1[0] = (u16) (pi->ofdm5ghpo & 0xffff); - pwr_offsets1[1] = - (u16) (pi->ofdm5ghpo >> 16) & 0xffff; - - pwr_offsets2 = pi->mcs5ghpo; - - tmp_cddpo = pi->cdd5ghpo; - tmp_stbcpo = pi->stbc5ghpo; - tmp_bw40po = pi->bw405ghpo; - - tx_srom_max_rate = pi->tx_srom_max_rate_5g_hi; - break; - } - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, pwr_offsets1, - tmp_max_pwr, TXP_FIRST_OFDM, - TXP_LAST_OFDM); - - wlc_phy_ofdm_to_mcs_powers_nphy(tx_srom_max_rate, - TXP_FIRST_MCS_20_SISO, - TXP_LAST_MCS_20_SISO, - TXP_FIRST_OFDM); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, pwr_offsets2, - tmp_max_pwr, - TXP_FIRST_MCS_20_CDD, - TXP_LAST_MCS_20_CDD); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, tmp_cddpo, - TXP_FIRST_MCS_20_CDD, - TXP_LAST_MCS_20_CDD); - - wlc_phy_mcs_to_ofdm_powers_nphy(tx_srom_max_rate, - TXP_FIRST_OFDM_20_CDD, - TXP_LAST_OFDM_20_CDD, - TXP_FIRST_MCS_20_CDD); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, pwr_offsets2, - tmp_max_pwr, - TXP_FIRST_MCS_20_STBC, - TXP_LAST_MCS_20_STBC); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, - tmp_stbcpo, - TXP_FIRST_MCS_20_STBC, - TXP_LAST_MCS_20_STBC); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, - &pwr_offsets2[2], tmp_max_pwr, - TXP_FIRST_MCS_20_SDM, - TXP_LAST_MCS_20_SDM); - - if (NPHY_IS_SROM_REINTERPRET) { - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, - &pwr_offsets2[4], - tmp_max_pwr, - TXP_FIRST_MCS_40_SISO, - TXP_LAST_MCS_40_SISO); - - wlc_phy_mcs_to_ofdm_powers_nphy(tx_srom_max_rate, - TXP_FIRST_OFDM_40_SISO, - TXP_LAST_OFDM_40_SISO, - TXP_FIRST_MCS_40_SISO); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, - &pwr_offsets2[4], - tmp_max_pwr, - TXP_FIRST_MCS_40_CDD, - TXP_LAST_MCS_40_CDD); - - wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, tmp_cddpo, - TXP_FIRST_MCS_40_CDD, - TXP_LAST_MCS_40_CDD); - - wlc_phy_mcs_to_ofdm_powers_nphy(tx_srom_max_rate, - TXP_FIRST_OFDM_40_CDD, - TXP_LAST_OFDM_40_CDD, - TXP_FIRST_MCS_40_CDD); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, - &pwr_offsets2[4], - tmp_max_pwr, - TXP_FIRST_MCS_40_STBC, - TXP_LAST_MCS_40_STBC); - - wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, - tmp_stbcpo, - TXP_FIRST_MCS_40_STBC, - TXP_LAST_MCS_40_STBC); - - wlc_phy_txpwr_nphy_srom_convert(tx_srom_max_rate, - &pwr_offsets2[6], - tmp_max_pwr, - TXP_FIRST_MCS_40_SDM, - TXP_LAST_MCS_40_SDM); - } else { - - for (rate1 = TXP_FIRST_OFDM_40_SISO, rate2 = - TXP_FIRST_OFDM; - rate1 <= TXP_LAST_MCS_40_SDM; - rate1++, rate2++) - tx_srom_max_rate[rate1] = - tx_srom_max_rate[rate2]; - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - wlc_phy_txpwr_nphy_po_apply(tx_srom_max_rate, - tmp_bw40po, - TXP_FIRST_OFDM_40_SISO, - TXP_LAST_MCS_40_SDM); - - tx_srom_max_rate[TXP_MCS_32] = - tx_srom_max_rate[TXP_FIRST_MCS_40_CDD]; - } - - return; -} - -void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi) -{ - u8 tx_pwr_ctrl_state; - wlc_phy_txpwr_limit_to_tbl_nphy(pi); - wlc_phy_txpwrctrl_pwr_setup_nphy(pi); - - tx_pwr_ctrl_state = pi->nphy_txpwrctrl; - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); - udelay(1); - } - - wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); - - if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) - wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, 0); -} - -static bool wlc_phy_txpwr_ison_nphy(struct brcms_phy *pi) -{ - return read_phy_reg((pi), 0x1e7) & ((0x1 << 15) | - (0x1 << 14) | (0x1 << 13)); -} - -u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi) -{ - u16 tmp; - u16 pwr_idx[2]; - - if (wlc_phy_txpwr_ison_nphy(pi)) { - pwr_idx[0] = wlc_phy_txpwr_idx_cur_get_nphy(pi, PHY_CORE_0); - pwr_idx[1] = wlc_phy_txpwr_idx_cur_get_nphy(pi, PHY_CORE_1); - - tmp = (pwr_idx[0] << 8) | pwr_idx[1]; - } else { - tmp = ((pi->nphy_txpwrindex[PHY_CORE_0].index_internal & 0xff) - << 8) | - (pi->nphy_txpwrindex[PHY_CORE_1].index_internal & 0xff); - } - - return tmp; -} - -void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi) -{ - if (PHY_IPA(pi) - && (pi->nphy_force_papd_cal - || (wlc_phy_txpwr_ison_nphy(pi) - && - (((u32) - abs(wlc_phy_txpwr_idx_cur_get_nphy(pi, 0) - - pi->nphy_papd_tx_gain_at_last_cal[0]) >= 4) - || ((u32) - abs(wlc_phy_txpwr_idx_cur_get_nphy(pi, 1) - - pi->nphy_papd_tx_gain_at_last_cal[1]) >= 4))))) - wlc_phy_a4(pi, true); -} - -void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type) -{ - u16 mask = 0, val = 0, ishw = 0; - u8 ctr; - uint core; - u32 tbl_offset; - u32 tbl_len; - u16 regval[84]; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - switch (ctrl_type) { - case PHY_TPC_HW_OFF: - case PHY_TPC_HW_ON: - pi->nphy_txpwrctrl = ctrl_type; - break; - default: - break; - } - - if (ctrl_type == PHY_TPC_HW_OFF) { - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - - if (wlc_phy_txpwr_ison_nphy(pi)) { - for (core = 0; core < pi->pubpi.phy_corenum; - core++) - pi->nphy_txpwr_idx[core] = - wlc_phy_txpwr_idx_cur_get_nphy( - pi, - (u8) core); - } - - } - - tbl_len = 84; - tbl_offset = 64; - for (ctr = 0; ctr < tbl_len; ctr++) - regval[ctr] = 0; - wlc_phy_table_write_nphy(pi, 26, tbl_len, tbl_offset, 16, - regval); - wlc_phy_table_write_nphy(pi, 27, tbl_len, tbl_offset, 16, - regval); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - and_phy_reg(pi, 0x1e7, - (u16) (~((0x1 << 15) | - (0x1 << 14) | (0x1 << 13)))); - else - and_phy_reg(pi, 0x1e7, - (u16) (~((0x1 << 14) | (0x1 << 13)))); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - or_phy_reg(pi, 0x8f, (0x1 << 8)); - or_phy_reg(pi, 0xa5, (0x1 << 8)); - } else { - or_phy_reg(pi, 0xa5, (0x1 << 14)); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x53); - else if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x5a); - - if (NREV_LT(pi->pubpi.phy_rev, 2) && - pi->bw == WL_CHANSPEC_BW_40) - wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_IQSWAP_WAR, - MHF1_IQSWAP_WAR, BRCM_BAND_ALL); - - } else { - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE1TXPWRCTL, 84, 64, - 8, pi->adj_pwr_tbl_nphy); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CORE2TXPWRCTL, 84, 64, - 8, pi->adj_pwr_tbl_nphy); - - ishw = (ctrl_type == PHY_TPC_HW_ON) ? 0x1 : 0x0; - mask = (0x1 << 14) | (0x1 << 13); - val = (ishw << 14) | (ishw << 13); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - mask |= (0x1 << 15); - val |= (ishw << 15); - } - - mod_phy_reg(pi, 0x1e7, mask, val); - - if (CHSPEC_IS5G(pi->radio_chanspec)) { - if (NREV_GE(pi->pubpi.phy_rev, 7)) { - mod_phy_reg(pi, 0x1e7, (0x7f << 0), 0x32); - mod_phy_reg(pi, 0x222, (0xff << 0), 0x32); - } else { - mod_phy_reg(pi, 0x1e7, (0x7f << 0), 0x64); - if (NREV_GT(pi->pubpi.phy_rev, 1)) - mod_phy_reg(pi, 0x222, - (0xff << 0), 0x64); - } - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - if ((pi->nphy_txpwr_idx[0] != 128) - && (pi->nphy_txpwr_idx[1] != 128)) - wlc_phy_txpwr_idx_cur_set_nphy(pi, - pi-> - nphy_txpwr_idx - [0], - pi-> - nphy_txpwr_idx - [1]); - } - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - and_phy_reg(pi, 0x8f, ~(0x1 << 8)); - and_phy_reg(pi, 0xa5, ~(0x1 << 8)); - } else { - and_phy_reg(pi, 0xa5, ~(0x1 << 14)); - } - - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x3b); - else if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0xdc, 0x00ff, 0x40); - - if (NREV_LT(pi->pubpi.phy_rev, 2) && - pi->bw == WL_CHANSPEC_BW_40) - wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_IQSWAP_WAR, - 0x0, BRCM_BAND_ALL); - - if (PHY_IPA(pi)) { - mod_phy_reg(pi, (0 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 2), (0) << 2); - - mod_phy_reg(pi, (1 == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 2), (0) << 2); - - } - - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -void -wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask, s8 txpwrindex, - bool restore_cals) -{ - u8 core, txpwrctl_tbl; - u16 tx_ind0, iq_ind0, lo_ind0; - u16 m1m2; - u32 txgain; - u16 rad_gain, dac_gain; - u8 bbmult; - u32 iqcomp; - u16 iqcomp_a, iqcomp_b; - u32 locomp; - u16 tmpval; - u8 tx_pwr_ctrl_state; - s32 rfpwr_offset; - u16 regval[2]; - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - tx_ind0 = 192; - iq_ind0 = 320; - lo_ind0 = 448; - - for (core = 0; core < pi->pubpi.phy_corenum; core++) { - - if ((core_mask & (1 << core)) == 0) - continue; - - txpwrctl_tbl = (core == PHY_CORE_0) ? 26 : 27; - - if (txpwrindex < 0) { - if (pi->nphy_txpwrindex[core].index < 0) - continue; - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - mod_phy_reg(pi, 0x8f, - (0x1 << 8), - pi->nphy_txpwrindex[core]. - AfectrlOverride); - mod_phy_reg(pi, 0xa5, (0x1 << 8), - pi->nphy_txpwrindex[core]. - AfectrlOverride); - } else { - mod_phy_reg(pi, 0xa5, - (0x1 << 14), - pi->nphy_txpwrindex[core]. - AfectrlOverride); - } - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xaa : 0xab, - pi->nphy_txpwrindex[core].AfeCtrlDacGain); - - wlc_phy_table_write_nphy(pi, 7, 1, (0x110 + core), 16, - &pi->nphy_txpwrindex[core]. - rad_gain); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m1m2); - m1m2 &= ((core == PHY_CORE_0) ? 0x00ff : 0xff00); - m1m2 |= ((core == PHY_CORE_0) ? - (pi->nphy_txpwrindex[core].bbmult << 8) : - (pi->nphy_txpwrindex[core].bbmult << 0)); - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m1m2); - - if (restore_cals) { - wlc_phy_table_write_nphy( - pi, 15, 2, (80 + 2 * core), 16, - &pi->nphy_txpwrindex[core].iqcomp_a); - wlc_phy_table_write_nphy( - pi, 15, 1, (85 + core), 16, - &pi->nphy_txpwrindex[core].locomp); - wlc_phy_table_write_nphy( - pi, 15, 1, (93 + core), 16, - &pi->nphy_txpwrindex[core].locomp); - } - - wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); - - pi->nphy_txpwrindex[core].index_internal = - pi->nphy_txpwrindex[core].index_internal_save; - } else { - - if (pi->nphy_txpwrindex[core].index < 0) { - - if (NREV_GE(pi->pubpi.phy_rev, 3)) { - mod_phy_reg(pi, 0x8f, - (0x1 << 8), - pi->nphy_txpwrindex[core]. - AfectrlOverride); - mod_phy_reg(pi, 0xa5, (0x1 << 8), - pi->nphy_txpwrindex[core]. - AfectrlOverride); - } else { - pi->nphy_txpwrindex[core]. - AfectrlOverride = - read_phy_reg(pi, 0xa5); - } - - pi->nphy_txpwrindex[core].AfeCtrlDacGain = - read_phy_reg(pi, (core == PHY_CORE_0) ? - 0xaa : 0xab); - - wlc_phy_table_read_nphy(pi, 7, 1, - (0x110 + core), 16, - &pi-> - nphy_txpwrindex[core]. - rad_gain); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, - &tmpval); - tmpval >>= ((core == PHY_CORE_0) ? 8 : 0); - tmpval &= 0xff; - pi->nphy_txpwrindex[core].bbmult = (u8) tmpval; - - wlc_phy_table_read_nphy(pi, 15, 2, - (80 + 2 * core), 16, - &pi-> - nphy_txpwrindex[core]. - iqcomp_a); - - wlc_phy_table_read_nphy(pi, 15, 1, (85 + core), - 16, - &pi-> - nphy_txpwrindex[core]. - locomp); - - pi->nphy_txpwrindex[core].index_internal_save = - pi->nphy_txpwrindex[core]. - index_internal; - } - - tx_pwr_ctrl_state = pi->nphy_txpwrctrl; - wlc_phy_txpwrctrl_enable_nphy(pi, PHY_TPC_HW_OFF); - - if (NREV_IS(pi->pubpi.phy_rev, 1)) - wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); - - wlc_phy_table_read_nphy(pi, txpwrctl_tbl, 1, - (tx_ind0 + txpwrindex), 32, - &txgain); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - rad_gain = (txgain >> 16) & - ((1 << (32 - 16 + 1)) - 1); - else - rad_gain = (txgain >> 16) & - ((1 << (28 - 16 + 1)) - 1); - - dac_gain = (txgain >> 8) & ((1 << (13 - 8 + 1)) - 1); - bbmult = (txgain >> 0) & ((1 << (7 - 0 + 1)) - 1); - - if (NREV_GE(pi->pubpi.phy_rev, 3)) - mod_phy_reg(pi, ((core == PHY_CORE_0) ? 0x8f : - 0xa5), (0x1 << 8), (0x1 << 8)); - else - mod_phy_reg(pi, 0xa5, (0x1 << 14), (0x1 << 14)); - - write_phy_reg(pi, (core == PHY_CORE_0) ? - 0xaa : 0xab, dac_gain); - - wlc_phy_table_write_nphy(pi, 7, 1, (0x110 + core), 16, - &rad_gain); - - wlc_phy_table_read_nphy(pi, 15, 1, 87, 16, &m1m2); - m1m2 &= ((core == PHY_CORE_0) ? 0x00ff : 0xff00); - m1m2 |= ((core == PHY_CORE_0) ? - (bbmult << 8) : (bbmult << 0)); - - wlc_phy_table_write_nphy(pi, 15, 1, 87, 16, &m1m2); - - wlc_phy_table_read_nphy(pi, txpwrctl_tbl, 1, - (iq_ind0 + txpwrindex), 32, - &iqcomp); - iqcomp_a = (iqcomp >> 10) & ((1 << (19 - 10 + 1)) - 1); - iqcomp_b = (iqcomp >> 0) & ((1 << (9 - 0 + 1)) - 1); - - if (restore_cals) { - regval[0] = (u16) iqcomp_a; - regval[1] = (u16) iqcomp_b; - wlc_phy_table_write_nphy(pi, 15, 2, - (80 + 2 * core), 16, - regval); - } - - wlc_phy_table_read_nphy(pi, txpwrctl_tbl, 1, - (lo_ind0 + txpwrindex), 32, - &locomp); - if (restore_cals) - wlc_phy_table_write_nphy(pi, 15, 1, (85 + core), - 16, &locomp); - - if (NREV_IS(pi->pubpi.phy_rev, 1)) - wlapi_bmac_phyclk_fgc(pi->sh->physhim, OFF); - - if (PHY_IPA(pi)) { - wlc_phy_table_read_nphy(pi, - (core == PHY_CORE_0 ? - NPHY_TBL_ID_CORE1TXPWRCTL : - NPHY_TBL_ID_CORE2TXPWRCTL), - 1, 576 + txpwrindex, 32, - &rfpwr_offset); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1ff << 4), - ((s16) rfpwr_offset) << 4); - - mod_phy_reg(pi, (core == PHY_CORE_0) ? 0x297 : - 0x29b, (0x1 << 2), (1) << 2); - - } - - wlc_phy_txpwrctrl_enable_nphy(pi, tx_pwr_ctrl_state); - } - - pi->nphy_txpwrindex[core].index = txpwrindex; - } - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, false); -} - -void -wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan, u8 *max_pwr, - u8 txp_rate_idx) -{ - u8 chan_freq_range; - - chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, chan); - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_2G: - *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx]; - break; - case WL_CHAN_FREQ_RANGE_5GM: - *max_pwr = pi->tx_srom_max_rate_5g_mid[txp_rate_idx]; - break; - case WL_CHAN_FREQ_RANGE_5GL: - *max_pwr = pi->tx_srom_max_rate_5g_low[txp_rate_idx]; - break; - case WL_CHAN_FREQ_RANGE_5GH: - *max_pwr = pi->tx_srom_max_rate_5g_hi[txp_rate_idx]; - break; - default: - *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx]; - break; - } - - return; -} - -void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable) -{ - u16 clip_off[] = { 0xffff, 0xffff }; - - if (enable) { - if (pi->nphy_deaf_count == 0) { - pi->classifier_state = - wlc_phy_classifier_nphy(pi, 0, 0); - wlc_phy_classifier_nphy(pi, (0x7 << 0), 4); - wlc_phy_clip_det_nphy(pi, 0, pi->clip_state); - wlc_phy_clip_det_nphy(pi, 1, clip_off); - } - - pi->nphy_deaf_count++; - - wlc_phy_resetcca_nphy(pi); - - } else { - pi->nphy_deaf_count--; - - if (pi->nphy_deaf_count == 0) { - wlc_phy_classifier_nphy(pi, (0x7 << 0), - pi->classifier_state); - wlc_phy_clip_det_nphy(pi, 1, pi->clip_state); - } - } -} - -void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode) -{ - wlapi_suspend_mac_and_wait(pi->sh->physhim); - - if (mode) { - if (pi->nphy_deaf_count == 0) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - } else if (pi->nphy_deaf_count > 0) { - wlc_phy_stay_in_carriersearch_nphy(pi, false); - } - - wlapi_enable_mac(pi->sh->physhim); -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c deleted file mode 100644 index faf1ebe7606..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "phy_qmath.h" - -/* - * Description: This function make 16 bit unsigned multiplication. - * To fit the output into 16 bits the 32 bit multiplication result is right - * shifted by 16 bits. - */ -u16 qm_mulu16(u16 op1, u16 op2) -{ - return (u16) (((u32) op1 * (u32) op2) >> 16); -} - -/* - * Description: This function make 16 bit multiplication and return the result - * in 16 bits. To fit the multiplication result into 16 bits the multiplication - * result is right shifted by 15 bits. Right shifting 15 bits instead of 16 bits - * is done to remove the extra sign bit formed due to the multiplication. - * When both the 16bit inputs are 0x8000 then the output is saturated to - * 0x7fffffff. - */ -s16 qm_muls16(s16 op1, s16 op2) -{ - s32 result; - if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) - result = 0x7fffffff; - else - result = ((s32) (op1) * (s32) (op2)); - - return (s16) (result >> 15); -} - -/* - * Description: This function add two 32 bit numbers and return the 32bit - * result. If the result overflow 32 bits, the output will be saturated to - * 32bits. - */ -s32 qm_add32(s32 op1, s32 op2) -{ - s32 result; - result = op1 + op2; - if (op1 < 0 && op2 < 0 && result > 0) - result = 0x80000000; - else if (op1 > 0 && op2 > 0 && result < 0) - result = 0x7fffffff; - - return result; -} - -/* - * Description: This function add two 16 bit numbers and return the 16bit - * result. If the result overflow 16 bits, the output will be saturated to - * 16bits. - */ -s16 qm_add16(s16 op1, s16 op2) -{ - s16 result; - s32 temp = (s32) op1 + (s32) op2; - if (temp > (s32) 0x7fff) - result = (s16) 0x7fff; - else if (temp < (s32) 0xffff8000) - result = (s16) 0xffff8000; - else - result = (s16) temp; - - return result; -} - -/* - * Description: This function make 16 bit subtraction and return the 16bit - * result. If the result overflow 16 bits, the output will be saturated to - * 16bits. - */ -s16 qm_sub16(s16 op1, s16 op2) -{ - s16 result; - s32 temp = (s32) op1 - (s32) op2; - if (temp > (s32) 0x7fff) - result = (s16) 0x7fff; - else if (temp < (s32) 0xffff8000) - result = (s16) 0xffff8000; - else - result = (s16) temp; - - return result; -} - -/* - * Description: This function make a 32 bit saturated left shift when the - * specified shift is +ve. This function will make a 32 bit right shift when - * the specified shift is -ve. This function return the result after shifting - * operation. - */ -s32 qm_shl32(s32 op, int shift) -{ - int i; - s32 result; - result = op; - if (shift > 31) - shift = 31; - else if (shift < -31) - shift = -31; - if (shift >= 0) { - for (i = 0; i < shift; i++) - result = qm_add32(result, result); - } else { - result = result >> (-shift); - } - - return result; -} - -/* - * Description: This function make a 16 bit saturated left shift when the - * specified shift is +ve. This function will make a 16 bit right shift when - * the specified shift is -ve. This function return the result after shifting - * operation. - */ -s16 qm_shl16(s16 op, int shift) -{ - int i; - s16 result; - result = op; - if (shift > 15) - shift = 15; - else if (shift < -15) - shift = -15; - if (shift > 0) { - for (i = 0; i < shift; i++) - result = qm_add16(result, result); - } else { - result = result >> (-shift); - } - - return result; -} - -/* - * Description: This function make a 16 bit right shift when shift is +ve. - * This function make a 16 bit saturated left shift when shift is -ve. This - * function return the result of the shift operation. - */ -s16 qm_shr16(s16 op, int shift) -{ - return qm_shl16(op, -shift); -} - -/* - * Description: This function return the number of redundant sign bits in a - * 32 bit number. Example: qm_norm32(0x00000080) = 23 - */ -s16 qm_norm32(s32 op) -{ - u16 u16extraSignBits; - if (op == 0) { - return 31; - } else { - u16extraSignBits = 0; - while ((op >> 31) == (op >> 30)) { - u16extraSignBits++; - op = op << 1; - } - } - return u16extraSignBits; -} - -/* This table is log2(1+(i/32)) where i=[0:1:31], in q.15 format */ -static const s16 log_table[] = { - 0, - 1455, - 2866, - 4236, - 5568, - 6863, - 8124, - 9352, - 10549, - 11716, - 12855, - 13968, - 15055, - 16117, - 17156, - 18173, - 19168, - 20143, - 21098, - 22034, - 22952, - 23852, - 24736, - 25604, - 26455, - 27292, - 28114, - 28922, - 29717, - 30498, - 31267, - 32024 -}; - -#define LOG_TABLE_SIZE 32 /* log_table size */ -#define LOG2_LOG_TABLE_SIZE 5 /* log2(log_table size) */ -#define Q_LOG_TABLE 15 /* qformat of log_table */ -#define LOG10_2 19728 /* log10(2) in q.16 */ - -/* - * Description: - * This routine takes the input number N and its q format qN and compute - * the log10(N). This routine first normalizes the input no N. Then N is in - * mag*(2^x) format. mag is any number in the range 2^30-(2^31 - 1). - * Then log2(mag * 2^x) = log2(mag) + x is computed. From that - * log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed. - * This routine looks the log2 value in the table considering - * LOG2_LOG_TABLE_SIZE+1 MSBs. As the MSB is always 1, only next - * LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup. Next 16 MSBs are used - * for interpolation. - * Inputs: - * N - number to which log10 has to be found. - * qN - q format of N - * log10N - address where log10(N) will be written. - * qLog10N - address where log10N qformat will be written. - * Note/Problem: - * For accurate results input should be in normalized or near normalized form. - */ -void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N) -{ - s16 s16norm, s16tableIndex, s16errorApproximation; - u16 u16offset; - s32 s32log; - - /* normalize the N. */ - s16norm = qm_norm32(N); - N = N << s16norm; - - /* The qformat of N after normalization. - * -30 is added to treat the no as between 1.0 to 2.0 - * i.e. after adding the -30 to the qformat the decimal point will be - * just rigtht of the MSB. (i.e. after sign bit and 1st MSB). i.e. - * at the right side of 30th bit. - */ - qN = qN + s16norm - 30; - - /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the - * MSB */ - s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE))); - - /* remove the MSB. the MSB is always 1 after normalization. */ - s16tableIndex = - s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1); - - /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */ - N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1); - - /* take the offset as the 16 MSBS after table index. - */ - u16offset = (u16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE + 16))); - - /* look the log value in the table. */ - s32log = log_table[s16tableIndex]; /* q.15 format */ - - /* interpolate using the offset. q.15 format. */ - s16errorApproximation = (s16) qm_mulu16(u16offset, - (u16) (log_table[s16tableIndex + 1] - - log_table[s16tableIndex])); - - /* q.15 format */ - s32log = qm_add16((s16) s32log, s16errorApproximation); - - /* adjust for the qformat of the N as - * log2(mag * 2^x) = log2(mag) + x - */ - s32log = qm_add32(s32log, ((s32) -qN) << 15); /* q.15 format */ - - /* normalize the result. */ - s16norm = qm_norm32(s32log); - - /* bring all the important bits into lower 16 bits */ - /* q.15+s16norm-16 format */ - s32log = qm_shl32(s32log, s16norm - 16); - - /* compute the log10(N) by multiplying log2(N) with log10(2). - * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2) - * log10N in q.15+s16norm-16+1 (LOG10_2 is in q.16) - */ - *log10N = qm_muls16((s16) s32log, (s16) LOG10_2); - - /* write the q format of the result. */ - *qLog10N = 15 + s16norm - 16 + 1; - - return; -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.h deleted file mode 100644 index 20e3783f921..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_QMATH_H_ -#define _BRCM_QMATH_H_ - -#include - -u16 qm_mulu16(u16 op1, u16 op2); - -s16 qm_muls16(s16 op1, s16 op2); - -s32 qm_add32(s32 op1, s32 op2); - -s16 qm_add16(s16 op1, s16 op2); - -s16 qm_sub16(s16 op1, s16 op2); - -s32 qm_shl32(s32 op, int shift); - -s16 qm_shl16(s16 op, int shift); - -s16 qm_shr16(s16 op, int shift); - -s16 qm_norm32(s32 op); - -void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N); - -#endif /* #ifndef _BRCM_QMATH_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phy_radio.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_radio.h deleted file mode 100644 index c3a675455ff..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phy_radio.h +++ /dev/null @@ -1,1533 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_PHY_RADIO_H_ -#define _BRCM_PHY_RADIO_H_ - -#define RADIO_IDCODE 0x01 - -#define RADIO_DEFAULT_CORE 0 - -#define RXC0_RSSI_RST 0x80 -#define RXC0_MODE_RSSI 0x40 -#define RXC0_MODE_OFF 0x20 -#define RXC0_MODE_CM 0x10 -#define RXC0_LAN_LOAD 0x08 -#define RXC0_OFF_ADJ_MASK 0x07 - -#define TXC0_MODE_TXLPF 0x04 -#define TXC0_PA_TSSI_EN 0x02 -#define TXC0_TSSI_EN 0x01 - -#define TXC1_PA_GAIN_MASK 0x60 -#define TXC1_PA_GAIN_3DB 0x40 -#define TXC1_PA_GAIN_2DB 0x20 -#define TXC1_TX_MIX_GAIN 0x10 -#define TXC1_OFF_I_MASK 0x0c -#define TXC1_OFF_Q_MASK 0x03 - -#define RADIO_2055_READ_OFF 0x100 -#define RADIO_2057_READ_OFF 0x200 - -#define RADIO_2055_GEN_SPARE 0x00 -#define RADIO_2055_SP_PIN_PD 0x02 -#define RADIO_2055_SP_RSSI_CORE1 0x03 -#define RADIO_2055_SP_PD_MISC_CORE1 0x04 -#define RADIO_2055_SP_RSSI_CORE2 0x05 -#define RADIO_2055_SP_PD_MISC_CORE2 0x06 -#define RADIO_2055_SP_RX_GC1_CORE1 0x07 -#define RADIO_2055_SP_RX_GC2_CORE1 0x08 -#define RADIO_2055_SP_RX_GC1_CORE2 0x09 -#define RADIO_2055_SP_RX_GC2_CORE2 0x0a -#define RADIO_2055_SP_LPF_BW_SELECT_CORE1 0x0b -#define RADIO_2055_SP_LPF_BW_SELECT_CORE2 0x0c -#define RADIO_2055_SP_TX_GC1_CORE1 0x0d -#define RADIO_2055_SP_TX_GC2_CORE1 0x0e -#define RADIO_2055_SP_TX_GC1_CORE2 0x0f -#define RADIO_2055_SP_TX_GC2_CORE2 0x10 -#define RADIO_2055_MASTER_CNTRL1 0x11 -#define RADIO_2055_MASTER_CNTRL2 0x12 -#define RADIO_2055_PD_LGEN 0x13 -#define RADIO_2055_PD_PLL_TS 0x14 -#define RADIO_2055_PD_CORE1_LGBUF 0x15 -#define RADIO_2055_PD_CORE1_TX 0x16 -#define RADIO_2055_PD_CORE1_RXTX 0x17 -#define RADIO_2055_PD_CORE1_RSSI_MISC 0x18 -#define RADIO_2055_PD_CORE2_LGBUF 0x19 -#define RADIO_2055_PD_CORE2_TX 0x1a -#define RADIO_2055_PD_CORE2_RXTX 0x1b -#define RADIO_2055_PD_CORE2_RSSI_MISC 0x1c -#define RADIO_2055_PWRDET_LGEN 0x1d -#define RADIO_2055_PWRDET_LGBUF_CORE1 0x1e -#define RADIO_2055_PWRDET_RXTX_CORE1 0x1f -#define RADIO_2055_PWRDET_LGBUF_CORE2 0x20 -#define RADIO_2055_PWRDET_RXTX_CORE2 0x21 -#define RADIO_2055_RRCCAL_CNTRL_SPARE 0x22 -#define RADIO_2055_RRCCAL_N_OPT_SEL 0x23 -#define RADIO_2055_CAL_MISC 0x24 -#define RADIO_2055_CAL_COUNTER_OUT 0x25 -#define RADIO_2055_CAL_COUNTER_OUT2 0x26 -#define RADIO_2055_CAL_CVAR_CNTRL 0x27 -#define RADIO_2055_CAL_RVAR_CNTRL 0x28 -#define RADIO_2055_CAL_LPO_CNTRL 0x29 -#define RADIO_2055_CAL_TS 0x2a -#define RADIO_2055_CAL_RCCAL_READ_TS 0x2b -#define RADIO_2055_CAL_RCAL_READ_TS 0x2c -#define RADIO_2055_PAD_DRIVER 0x2d -#define RADIO_2055_XO_CNTRL1 0x2e -#define RADIO_2055_XO_CNTRL2 0x2f -#define RADIO_2055_XO_REGULATOR 0x30 -#define RADIO_2055_XO_MISC 0x31 -#define RADIO_2055_PLL_LF_C1 0x32 -#define RADIO_2055_PLL_CAL_VTH 0x33 -#define RADIO_2055_PLL_LF_C2 0x34 -#define RADIO_2055_PLL_REF 0x35 -#define RADIO_2055_PLL_LF_R1 0x36 -#define RADIO_2055_PLL_PFD_CP 0x37 -#define RADIO_2055_PLL_IDAC_CPOPAMP 0x38 -#define RADIO_2055_PLL_CP_REGULATOR 0x39 -#define RADIO_2055_PLL_RCAL 0x3a -#define RADIO_2055_RF_PLL_MOD0 0x3b -#define RADIO_2055_RF_PLL_MOD1 0x3c -#define RADIO_2055_RF_MMD_IDAC1 0x3d -#define RADIO_2055_RF_MMD_IDAC0 0x3e -#define RADIO_2055_RF_MMD_SPARE 0x3f -#define RADIO_2055_VCO_CAL1 0x40 -#define RADIO_2055_VCO_CAL2 0x41 -#define RADIO_2055_VCO_CAL3 0x42 -#define RADIO_2055_VCO_CAL4 0x43 -#define RADIO_2055_VCO_CAL5 0x44 -#define RADIO_2055_VCO_CAL6 0x45 -#define RADIO_2055_VCO_CAL7 0x46 -#define RADIO_2055_VCO_CAL8 0x47 -#define RADIO_2055_VCO_CAL9 0x48 -#define RADIO_2055_VCO_CAL10 0x49 -#define RADIO_2055_VCO_CAL11 0x4a -#define RADIO_2055_VCO_CAL12 0x4b -#define RADIO_2055_VCO_CAL13 0x4c -#define RADIO_2055_VCO_CAL14 0x4d -#define RADIO_2055_VCO_CAL15 0x4e -#define RADIO_2055_VCO_CAL16 0x4f -#define RADIO_2055_VCO_KVCO 0x50 -#define RADIO_2055_VCO_CAP_TAIL 0x51 -#define RADIO_2055_VCO_IDAC_VCO 0x52 -#define RADIO_2055_VCO_REGULATOR 0x53 -#define RADIO_2055_PLL_RF_VTH 0x54 -#define RADIO_2055_LGBUF_CEN_BUF 0x55 -#define RADIO_2055_LGEN_TUNE1 0x56 -#define RADIO_2055_LGEN_TUNE2 0x57 -#define RADIO_2055_LGEN_IDAC1 0x58 -#define RADIO_2055_LGEN_IDAC2 0x59 -#define RADIO_2055_LGEN_BIAS_CNT 0x5a -#define RADIO_2055_LGEN_BIAS_IDAC 0x5b -#define RADIO_2055_LGEN_RCAL 0x5c -#define RADIO_2055_LGEN_DIV 0x5d -#define RADIO_2055_LGEN_SPARE2 0x5e -#define RADIO_2055_CORE1_LGBUF_A_TUNE 0x5f -#define RADIO_2055_CORE1_LGBUF_G_TUNE 0x60 -#define RADIO_2055_CORE1_LGBUF_DIV 0x61 -#define RADIO_2055_CORE1_LGBUF_A_IDAC 0x62 -#define RADIO_2055_CORE1_LGBUF_G_IDAC 0x63 -#define RADIO_2055_CORE1_LGBUF_IDACFIL_OVR 0x64 -#define RADIO_2055_CORE1_LGBUF_SPARE 0x65 -#define RADIO_2055_CORE1_RXRF_SPC1 0x66 -#define RADIO_2055_CORE1_RXRF_REG1 0x67 -#define RADIO_2055_CORE1_RXRF_REG2 0x68 -#define RADIO_2055_CORE1_RXRF_RCAL 0x69 -#define RADIO_2055_CORE1_RXBB_BUFI_LPFCMP 0x6a -#define RADIO_2055_CORE1_RXBB_LPF 0x6b -#define RADIO_2055_CORE1_RXBB_MIDAC_HIPAS 0x6c -#define RADIO_2055_CORE1_RXBB_VGA1_IDAC 0x6d -#define RADIO_2055_CORE1_RXBB_VGA2_IDAC 0x6e -#define RADIO_2055_CORE1_RXBB_VGA3_IDAC 0x6f -#define RADIO_2055_CORE1_RXBB_BUFO_CTRL 0x70 -#define RADIO_2055_CORE1_RXBB_RCCAL_CTRL 0x71 -#define RADIO_2055_CORE1_RXBB_RSSI_CTRL1 0x72 -#define RADIO_2055_CORE1_RXBB_RSSI_CTRL2 0x73 -#define RADIO_2055_CORE1_RXBB_RSSI_CTRL3 0x74 -#define RADIO_2055_CORE1_RXBB_RSSI_CTRL4 0x75 -#define RADIO_2055_CORE1_RXBB_RSSI_CTRL5 0x76 -#define RADIO_2055_CORE1_RXBB_REGULATOR 0x77 -#define RADIO_2055_CORE1_RXBB_SPARE1 0x78 -#define RADIO_2055_CORE1_RXTXBB_RCAL 0x79 -#define RADIO_2055_CORE1_TXRF_SGM_PGA 0x7a -#define RADIO_2055_CORE1_TXRF_SGM_PAD 0x7b -#define RADIO_2055_CORE1_TXRF_CNTR_PGA1 0x7c -#define RADIO_2055_CORE1_TXRF_CNTR_PAD1 0x7d -#define RADIO_2055_CORE1_TX_RFPGA_IDAC 0x7e -#define RADIO_2055_CORE1_TX_PGA_PAD_TN 0x7f -#define RADIO_2055_CORE1_TX_PAD_IDAC1 0x80 -#define RADIO_2055_CORE1_TX_PAD_IDAC2 0x81 -#define RADIO_2055_CORE1_TX_MX_BGTRIM 0x82 -#define RADIO_2055_CORE1_TXRF_RCAL 0x83 -#define RADIO_2055_CORE1_TXRF_PAD_TSSI1 0x84 -#define RADIO_2055_CORE1_TXRF_PAD_TSSI2 0x85 -#define RADIO_2055_CORE1_TX_RF_SPARE 0x86 -#define RADIO_2055_CORE1_TXRF_IQCAL1 0x87 -#define RADIO_2055_CORE1_TXRF_IQCAL2 0x88 -#define RADIO_2055_CORE1_TXBB_RCCAL_CTRL 0x89 -#define RADIO_2055_CORE1_TXBB_LPF1 0x8a -#define RADIO_2055_CORE1_TX_VOS_CNCL 0x8b -#define RADIO_2055_CORE1_TX_LPF_MXGM_IDAC 0x8c -#define RADIO_2055_CORE1_TX_BB_MXGM 0x8d -#define RADIO_2055_CORE2_LGBUF_A_TUNE 0x8e -#define RADIO_2055_CORE2_LGBUF_G_TUNE 0x8f -#define RADIO_2055_CORE2_LGBUF_DIV 0x90 -#define RADIO_2055_CORE2_LGBUF_A_IDAC 0x91 -#define RADIO_2055_CORE2_LGBUF_G_IDAC 0x92 -#define RADIO_2055_CORE2_LGBUF_IDACFIL_OVR 0x93 -#define RADIO_2055_CORE2_LGBUF_SPARE 0x94 -#define RADIO_2055_CORE2_RXRF_SPC1 0x95 -#define RADIO_2055_CORE2_RXRF_REG1 0x96 -#define RADIO_2055_CORE2_RXRF_REG2 0x97 -#define RADIO_2055_CORE2_RXRF_RCAL 0x98 -#define RADIO_2055_CORE2_RXBB_BUFI_LPFCMP 0x99 -#define RADIO_2055_CORE2_RXBB_LPF 0x9a -#define RADIO_2055_CORE2_RXBB_MIDAC_HIPAS 0x9b -#define RADIO_2055_CORE2_RXBB_VGA1_IDAC 0x9c -#define RADIO_2055_CORE2_RXBB_VGA2_IDAC 0x9d -#define RADIO_2055_CORE2_RXBB_VGA3_IDAC 0x9e -#define RADIO_2055_CORE2_RXBB_BUFO_CTRL 0x9f -#define RADIO_2055_CORE2_RXBB_RCCAL_CTRL 0xa0 -#define RADIO_2055_CORE2_RXBB_RSSI_CTRL1 0xa1 -#define RADIO_2055_CORE2_RXBB_RSSI_CTRL2 0xa2 -#define RADIO_2055_CORE2_RXBB_RSSI_CTRL3 0xa3 -#define RADIO_2055_CORE2_RXBB_RSSI_CTRL4 0xa4 -#define RADIO_2055_CORE2_RXBB_RSSI_CTRL5 0xa5 -#define RADIO_2055_CORE2_RXBB_REGULATOR 0xa6 -#define RADIO_2055_CORE2_RXBB_SPARE1 0xa7 -#define RADIO_2055_CORE2_RXTXBB_RCAL 0xa8 -#define RADIO_2055_CORE2_TXRF_SGM_PGA 0xa9 -#define RADIO_2055_CORE2_TXRF_SGM_PAD 0xaa -#define RADIO_2055_CORE2_TXRF_CNTR_PGA1 0xab -#define RADIO_2055_CORE2_TXRF_CNTR_PAD1 0xac -#define RADIO_2055_CORE2_TX_RFPGA_IDAC 0xad -#define RADIO_2055_CORE2_TX_PGA_PAD_TN 0xae -#define RADIO_2055_CORE2_TX_PAD_IDAC1 0xaf -#define RADIO_2055_CORE2_TX_PAD_IDAC2 0xb0 -#define RADIO_2055_CORE2_TX_MX_BGTRIM 0xb1 -#define RADIO_2055_CORE2_TXRF_RCAL 0xb2 -#define RADIO_2055_CORE2_TXRF_PAD_TSSI1 0xb3 -#define RADIO_2055_CORE2_TXRF_PAD_TSSI2 0xb4 -#define RADIO_2055_CORE2_TX_RF_SPARE 0xb5 -#define RADIO_2055_CORE2_TXRF_IQCAL1 0xb6 -#define RADIO_2055_CORE2_TXRF_IQCAL2 0xb7 -#define RADIO_2055_CORE2_TXBB_RCCAL_CTRL 0xb8 -#define RADIO_2055_CORE2_TXBB_LPF1 0xb9 -#define RADIO_2055_CORE2_TX_VOS_CNCL 0xba -#define RADIO_2055_CORE2_TX_LPF_MXGM_IDAC 0xbb -#define RADIO_2055_CORE2_TX_BB_MXGM 0xbc -#define RADIO_2055_PRG_GC_HPVGA23_21 0xbd -#define RADIO_2055_PRG_GC_HPVGA23_22 0xbe -#define RADIO_2055_PRG_GC_HPVGA23_23 0xbf -#define RADIO_2055_PRG_GC_HPVGA23_24 0xc0 -#define RADIO_2055_PRG_GC_HPVGA23_25 0xc1 -#define RADIO_2055_PRG_GC_HPVGA23_26 0xc2 -#define RADIO_2055_PRG_GC_HPVGA23_27 0xc3 -#define RADIO_2055_PRG_GC_HPVGA23_28 0xc4 -#define RADIO_2055_PRG_GC_HPVGA23_29 0xc5 -#define RADIO_2055_PRG_GC_HPVGA23_30 0xc6 -#define RADIO_2055_CORE1_LNA_GAINBST 0xcd -#define RADIO_2055_CORE1_B0_NBRSSI_VCM 0xd2 -#define RADIO_2055_CORE1_GEN_SPARE2 0xd6 -#define RADIO_2055_CORE2_LNA_GAINBST 0xd9 -#define RADIO_2055_CORE2_B0_NBRSSI_VCM 0xde -#define RADIO_2055_CORE2_GEN_SPARE2 0xe2 - -#define RADIO_2055_GAINBST_GAIN_DB 6 -#define RADIO_2055_GAINBST_CODE 0x6 - -#define RADIO_2055_JTAGCTRL_MASK 0x04 -#define RADIO_2055_JTAGSYNC_MASK 0x08 -#define RADIO_2055_RRCAL_START 0x40 -#define RADIO_2055_RRCAL_RST_N 0x01 -#define RADIO_2055_CAL_LPO_ENABLE 0x80 -#define RADIO_2055_RCAL_DONE 0x80 -#define RADIO_2055_NBRSSI_VCM_I_MASK 0x03 -#define RADIO_2055_NBRSSI_VCM_I_SHIFT 0x00 -#define RADIO_2055_NBRSSI_VCM_Q_MASK 0x03 -#define RADIO_2055_NBRSSI_VCM_Q_SHIFT 0x00 -#define RADIO_2055_WBRSSI_VCM_IQ_MASK 0x0c -#define RADIO_2055_WBRSSI_VCM_IQ_SHIFT 0x02 -#define RADIO_2055_NBRSSI_PD 0x01 -#define RADIO_2055_WBRSSI_G1_PD 0x04 -#define RADIO_2055_WBRSSI_G2_PD 0x02 -#define RADIO_2055_NBRSSI_SEL 0x01 -#define RADIO_2055_WBRSSI_G1_SEL 0x04 -#define RADIO_2055_WBRSSI_G2_SEL 0x02 -#define RADIO_2055_COUPLE_RX_MASK 0x01 -#define RADIO_2055_COUPLE_TX_MASK 0x02 -#define RADIO_2055_GAINBST_DISABLE 0x02 -#define RADIO_2055_GAINBST_VAL_MASK 0x07 -#define RADIO_2055_RXMX_GC_MASK 0x0c - -#define RADIO_MIMO_CORESEL_OFF 0x0 -#define RADIO_MIMO_CORESEL_CORE1 0x1 -#define RADIO_MIMO_CORESEL_CORE2 0x2 -#define RADIO_MIMO_CORESEL_CORE3 0x3 -#define RADIO_MIMO_CORESEL_CORE4 0x4 -#define RADIO_MIMO_CORESEL_ALLRX 0x5 -#define RADIO_MIMO_CORESEL_ALLTX 0x6 -#define RADIO_MIMO_CORESEL_ALLRXTX 0x7 - -#define RADIO_2064_READ_OFF 0x200 - -#define RADIO_2064_REG000 0x0 -#define RADIO_2064_REG001 0x1 -#define RADIO_2064_REG002 0x2 -#define RADIO_2064_REG003 0x3 -#define RADIO_2064_REG004 0x4 -#define RADIO_2064_REG005 0x5 -#define RADIO_2064_REG006 0x6 -#define RADIO_2064_REG007 0x7 -#define RADIO_2064_REG008 0x8 -#define RADIO_2064_REG009 0x9 -#define RADIO_2064_REG00A 0xa -#define RADIO_2064_REG00B 0xb -#define RADIO_2064_REG00C 0xc -#define RADIO_2064_REG00D 0xd -#define RADIO_2064_REG00E 0xe -#define RADIO_2064_REG00F 0xf -#define RADIO_2064_REG010 0x10 -#define RADIO_2064_REG011 0x11 -#define RADIO_2064_REG012 0x12 -#define RADIO_2064_REG013 0x13 -#define RADIO_2064_REG014 0x14 -#define RADIO_2064_REG015 0x15 -#define RADIO_2064_REG016 0x16 -#define RADIO_2064_REG017 0x17 -#define RADIO_2064_REG018 0x18 -#define RADIO_2064_REG019 0x19 -#define RADIO_2064_REG01A 0x1a -#define RADIO_2064_REG01B 0x1b -#define RADIO_2064_REG01C 0x1c -#define RADIO_2064_REG01D 0x1d -#define RADIO_2064_REG01E 0x1e -#define RADIO_2064_REG01F 0x1f -#define RADIO_2064_REG020 0x20 -#define RADIO_2064_REG021 0x21 -#define RADIO_2064_REG022 0x22 -#define RADIO_2064_REG023 0x23 -#define RADIO_2064_REG024 0x24 -#define RADIO_2064_REG025 0x25 -#define RADIO_2064_REG026 0x26 -#define RADIO_2064_REG027 0x27 -#define RADIO_2064_REG028 0x28 -#define RADIO_2064_REG029 0x29 -#define RADIO_2064_REG02A 0x2a -#define RADIO_2064_REG02B 0x2b -#define RADIO_2064_REG02C 0x2c -#define RADIO_2064_REG02D 0x2d -#define RADIO_2064_REG02E 0x2e -#define RADIO_2064_REG02F 0x2f -#define RADIO_2064_REG030 0x30 -#define RADIO_2064_REG031 0x31 -#define RADIO_2064_REG032 0x32 -#define RADIO_2064_REG033 0x33 -#define RADIO_2064_REG034 0x34 -#define RADIO_2064_REG035 0x35 -#define RADIO_2064_REG036 0x36 -#define RADIO_2064_REG037 0x37 -#define RADIO_2064_REG038 0x38 -#define RADIO_2064_REG039 0x39 -#define RADIO_2064_REG03A 0x3a -#define RADIO_2064_REG03B 0x3b -#define RADIO_2064_REG03C 0x3c -#define RADIO_2064_REG03D 0x3d -#define RADIO_2064_REG03E 0x3e -#define RADIO_2064_REG03F 0x3f -#define RADIO_2064_REG040 0x40 -#define RADIO_2064_REG041 0x41 -#define RADIO_2064_REG042 0x42 -#define RADIO_2064_REG043 0x43 -#define RADIO_2064_REG044 0x44 -#define RADIO_2064_REG045 0x45 -#define RADIO_2064_REG046 0x46 -#define RADIO_2064_REG047 0x47 -#define RADIO_2064_REG048 0x48 -#define RADIO_2064_REG049 0x49 -#define RADIO_2064_REG04A 0x4a -#define RADIO_2064_REG04B 0x4b -#define RADIO_2064_REG04C 0x4c -#define RADIO_2064_REG04D 0x4d -#define RADIO_2064_REG04E 0x4e -#define RADIO_2064_REG04F 0x4f -#define RADIO_2064_REG050 0x50 -#define RADIO_2064_REG051 0x51 -#define RADIO_2064_REG052 0x52 -#define RADIO_2064_REG053 0x53 -#define RADIO_2064_REG054 0x54 -#define RADIO_2064_REG055 0x55 -#define RADIO_2064_REG056 0x56 -#define RADIO_2064_REG057 0x57 -#define RADIO_2064_REG058 0x58 -#define RADIO_2064_REG059 0x59 -#define RADIO_2064_REG05A 0x5a -#define RADIO_2064_REG05B 0x5b -#define RADIO_2064_REG05C 0x5c -#define RADIO_2064_REG05D 0x5d -#define RADIO_2064_REG05E 0x5e -#define RADIO_2064_REG05F 0x5f -#define RADIO_2064_REG060 0x60 -#define RADIO_2064_REG061 0x61 -#define RADIO_2064_REG062 0x62 -#define RADIO_2064_REG063 0x63 -#define RADIO_2064_REG064 0x64 -#define RADIO_2064_REG065 0x65 -#define RADIO_2064_REG066 0x66 -#define RADIO_2064_REG067 0x67 -#define RADIO_2064_REG068 0x68 -#define RADIO_2064_REG069 0x69 -#define RADIO_2064_REG06A 0x6a -#define RADIO_2064_REG06B 0x6b -#define RADIO_2064_REG06C 0x6c -#define RADIO_2064_REG06D 0x6d -#define RADIO_2064_REG06E 0x6e -#define RADIO_2064_REG06F 0x6f -#define RADIO_2064_REG070 0x70 -#define RADIO_2064_REG071 0x71 -#define RADIO_2064_REG072 0x72 -#define RADIO_2064_REG073 0x73 -#define RADIO_2064_REG074 0x74 -#define RADIO_2064_REG075 0x75 -#define RADIO_2064_REG076 0x76 -#define RADIO_2064_REG077 0x77 -#define RADIO_2064_REG078 0x78 -#define RADIO_2064_REG079 0x79 -#define RADIO_2064_REG07A 0x7a -#define RADIO_2064_REG07B 0x7b -#define RADIO_2064_REG07C 0x7c -#define RADIO_2064_REG07D 0x7d -#define RADIO_2064_REG07E 0x7e -#define RADIO_2064_REG07F 0x7f -#define RADIO_2064_REG080 0x80 -#define RADIO_2064_REG081 0x81 -#define RADIO_2064_REG082 0x82 -#define RADIO_2064_REG083 0x83 -#define RADIO_2064_REG084 0x84 -#define RADIO_2064_REG085 0x85 -#define RADIO_2064_REG086 0x86 -#define RADIO_2064_REG087 0x87 -#define RADIO_2064_REG088 0x88 -#define RADIO_2064_REG089 0x89 -#define RADIO_2064_REG08A 0x8a -#define RADIO_2064_REG08B 0x8b -#define RADIO_2064_REG08C 0x8c -#define RADIO_2064_REG08D 0x8d -#define RADIO_2064_REG08E 0x8e -#define RADIO_2064_REG08F 0x8f -#define RADIO_2064_REG090 0x90 -#define RADIO_2064_REG091 0x91 -#define RADIO_2064_REG092 0x92 -#define RADIO_2064_REG093 0x93 -#define RADIO_2064_REG094 0x94 -#define RADIO_2064_REG095 0x95 -#define RADIO_2064_REG096 0x96 -#define RADIO_2064_REG097 0x97 -#define RADIO_2064_REG098 0x98 -#define RADIO_2064_REG099 0x99 -#define RADIO_2064_REG09A 0x9a -#define RADIO_2064_REG09B 0x9b -#define RADIO_2064_REG09C 0x9c -#define RADIO_2064_REG09D 0x9d -#define RADIO_2064_REG09E 0x9e -#define RADIO_2064_REG09F 0x9f -#define RADIO_2064_REG0A0 0xa0 -#define RADIO_2064_REG0A1 0xa1 -#define RADIO_2064_REG0A2 0xa2 -#define RADIO_2064_REG0A3 0xa3 -#define RADIO_2064_REG0A4 0xa4 -#define RADIO_2064_REG0A5 0xa5 -#define RADIO_2064_REG0A6 0xa6 -#define RADIO_2064_REG0A7 0xa7 -#define RADIO_2064_REG0A8 0xa8 -#define RADIO_2064_REG0A9 0xa9 -#define RADIO_2064_REG0AA 0xaa -#define RADIO_2064_REG0AB 0xab -#define RADIO_2064_REG0AC 0xac -#define RADIO_2064_REG0AD 0xad -#define RADIO_2064_REG0AE 0xae -#define RADIO_2064_REG0AF 0xaf -#define RADIO_2064_REG0B0 0xb0 -#define RADIO_2064_REG0B1 0xb1 -#define RADIO_2064_REG0B2 0xb2 -#define RADIO_2064_REG0B3 0xb3 -#define RADIO_2064_REG0B4 0xb4 -#define RADIO_2064_REG0B5 0xb5 -#define RADIO_2064_REG0B6 0xb6 -#define RADIO_2064_REG0B7 0xb7 -#define RADIO_2064_REG0B8 0xb8 -#define RADIO_2064_REG0B9 0xb9 -#define RADIO_2064_REG0BA 0xba -#define RADIO_2064_REG0BB 0xbb -#define RADIO_2064_REG0BC 0xbc -#define RADIO_2064_REG0BD 0xbd -#define RADIO_2064_REG0BE 0xbe -#define RADIO_2064_REG0BF 0xbf -#define RADIO_2064_REG0C0 0xc0 -#define RADIO_2064_REG0C1 0xc1 -#define RADIO_2064_REG0C2 0xc2 -#define RADIO_2064_REG0C3 0xc3 -#define RADIO_2064_REG0C4 0xc4 -#define RADIO_2064_REG0C5 0xc5 -#define RADIO_2064_REG0C6 0xc6 -#define RADIO_2064_REG0C7 0xc7 -#define RADIO_2064_REG0C8 0xc8 -#define RADIO_2064_REG0C9 0xc9 -#define RADIO_2064_REG0CA 0xca -#define RADIO_2064_REG0CB 0xcb -#define RADIO_2064_REG0CC 0xcc -#define RADIO_2064_REG0CD 0xcd -#define RADIO_2064_REG0CE 0xce -#define RADIO_2064_REG0CF 0xcf -#define RADIO_2064_REG0D0 0xd0 -#define RADIO_2064_REG0D1 0xd1 -#define RADIO_2064_REG0D2 0xd2 -#define RADIO_2064_REG0D3 0xd3 -#define RADIO_2064_REG0D4 0xd4 -#define RADIO_2064_REG0D5 0xd5 -#define RADIO_2064_REG0D6 0xd6 -#define RADIO_2064_REG0D7 0xd7 -#define RADIO_2064_REG0D8 0xd8 -#define RADIO_2064_REG0D9 0xd9 -#define RADIO_2064_REG0DA 0xda -#define RADIO_2064_REG0DB 0xdb -#define RADIO_2064_REG0DC 0xdc -#define RADIO_2064_REG0DD 0xdd -#define RADIO_2064_REG0DE 0xde -#define RADIO_2064_REG0DF 0xdf -#define RADIO_2064_REG0E0 0xe0 -#define RADIO_2064_REG0E1 0xe1 -#define RADIO_2064_REG0E2 0xe2 -#define RADIO_2064_REG0E3 0xe3 -#define RADIO_2064_REG0E4 0xe4 -#define RADIO_2064_REG0E5 0xe5 -#define RADIO_2064_REG0E6 0xe6 -#define RADIO_2064_REG0E7 0xe7 -#define RADIO_2064_REG0E8 0xe8 -#define RADIO_2064_REG0E9 0xe9 -#define RADIO_2064_REG0EA 0xea -#define RADIO_2064_REG0EB 0xeb -#define RADIO_2064_REG0EC 0xec -#define RADIO_2064_REG0ED 0xed -#define RADIO_2064_REG0EE 0xee -#define RADIO_2064_REG0EF 0xef -#define RADIO_2064_REG0F0 0xf0 -#define RADIO_2064_REG0F1 0xf1 -#define RADIO_2064_REG0F2 0xf2 -#define RADIO_2064_REG0F3 0xf3 -#define RADIO_2064_REG0F4 0xf4 -#define RADIO_2064_REG0F5 0xf5 -#define RADIO_2064_REG0F6 0xf6 -#define RADIO_2064_REG0F7 0xf7 -#define RADIO_2064_REG0F8 0xf8 -#define RADIO_2064_REG0F9 0xf9 -#define RADIO_2064_REG0FA 0xfa -#define RADIO_2064_REG0FB 0xfb -#define RADIO_2064_REG0FC 0xfc -#define RADIO_2064_REG0FD 0xfd -#define RADIO_2064_REG0FE 0xfe -#define RADIO_2064_REG0FF 0xff -#define RADIO_2064_REG100 0x100 -#define RADIO_2064_REG101 0x101 -#define RADIO_2064_REG102 0x102 -#define RADIO_2064_REG103 0x103 -#define RADIO_2064_REG104 0x104 -#define RADIO_2064_REG105 0x105 -#define RADIO_2064_REG106 0x106 -#define RADIO_2064_REG107 0x107 -#define RADIO_2064_REG108 0x108 -#define RADIO_2064_REG109 0x109 -#define RADIO_2064_REG10A 0x10a -#define RADIO_2064_REG10B 0x10b -#define RADIO_2064_REG10C 0x10c -#define RADIO_2064_REG10D 0x10d -#define RADIO_2064_REG10E 0x10e -#define RADIO_2064_REG10F 0x10f -#define RADIO_2064_REG110 0x110 -#define RADIO_2064_REG111 0x111 -#define RADIO_2064_REG112 0x112 -#define RADIO_2064_REG113 0x113 -#define RADIO_2064_REG114 0x114 -#define RADIO_2064_REG115 0x115 -#define RADIO_2064_REG116 0x116 -#define RADIO_2064_REG117 0x117 -#define RADIO_2064_REG118 0x118 -#define RADIO_2064_REG119 0x119 -#define RADIO_2064_REG11A 0x11a -#define RADIO_2064_REG11B 0x11b -#define RADIO_2064_REG11C 0x11c -#define RADIO_2064_REG11D 0x11d -#define RADIO_2064_REG11E 0x11e -#define RADIO_2064_REG11F 0x11f -#define RADIO_2064_REG120 0x120 -#define RADIO_2064_REG121 0x121 -#define RADIO_2064_REG122 0x122 -#define RADIO_2064_REG123 0x123 -#define RADIO_2064_REG124 0x124 -#define RADIO_2064_REG125 0x125 -#define RADIO_2064_REG126 0x126 -#define RADIO_2064_REG127 0x127 -#define RADIO_2064_REG128 0x128 -#define RADIO_2064_REG129 0x129 -#define RADIO_2064_REG12A 0x12a -#define RADIO_2064_REG12B 0x12b -#define RADIO_2064_REG12C 0x12c -#define RADIO_2064_REG12D 0x12d -#define RADIO_2064_REG12E 0x12e -#define RADIO_2064_REG12F 0x12f -#define RADIO_2064_REG130 0x130 - -#define RADIO_2056_SYN (0x0 << 12) -#define RADIO_2056_TX0 (0x2 << 12) -#define RADIO_2056_TX1 (0x3 << 12) -#define RADIO_2056_RX0 (0x6 << 12) -#define RADIO_2056_RX1 (0x7 << 12) -#define RADIO_2056_ALLTX (0xe << 12) -#define RADIO_2056_ALLRX (0xf << 12) - -#define RADIO_2056_SYN_RESERVED_ADDR0 0x0 -#define RADIO_2056_SYN_IDCODE 0x1 -#define RADIO_2056_SYN_RESERVED_ADDR2 0x2 -#define RADIO_2056_SYN_RESERVED_ADDR3 0x3 -#define RADIO_2056_SYN_RESERVED_ADDR4 0x4 -#define RADIO_2056_SYN_RESERVED_ADDR5 0x5 -#define RADIO_2056_SYN_RESERVED_ADDR6 0x6 -#define RADIO_2056_SYN_RESERVED_ADDR7 0x7 -#define RADIO_2056_SYN_COM_CTRL 0x8 -#define RADIO_2056_SYN_COM_PU 0x9 -#define RADIO_2056_SYN_COM_OVR 0xa -#define RADIO_2056_SYN_COM_RESET 0xb -#define RADIO_2056_SYN_COM_RCAL 0xc -#define RADIO_2056_SYN_COM_RC_RXLPF 0xd -#define RADIO_2056_SYN_COM_RC_TXLPF 0xe -#define RADIO_2056_SYN_COM_RC_RXHPF 0xf -#define RADIO_2056_SYN_RESERVED_ADDR16 0x10 -#define RADIO_2056_SYN_RESERVED_ADDR17 0x11 -#define RADIO_2056_SYN_RESERVED_ADDR18 0x12 -#define RADIO_2056_SYN_RESERVED_ADDR19 0x13 -#define RADIO_2056_SYN_RESERVED_ADDR20 0x14 -#define RADIO_2056_SYN_RESERVED_ADDR21 0x15 -#define RADIO_2056_SYN_RESERVED_ADDR22 0x16 -#define RADIO_2056_SYN_RESERVED_ADDR23 0x17 -#define RADIO_2056_SYN_RESERVED_ADDR24 0x18 -#define RADIO_2056_SYN_RESERVED_ADDR25 0x19 -#define RADIO_2056_SYN_RESERVED_ADDR26 0x1a -#define RADIO_2056_SYN_RESERVED_ADDR27 0x1b -#define RADIO_2056_SYN_RESERVED_ADDR28 0x1c -#define RADIO_2056_SYN_RESERVED_ADDR29 0x1d -#define RADIO_2056_SYN_RESERVED_ADDR30 0x1e -#define RADIO_2056_SYN_RESERVED_ADDR31 0x1f -#define RADIO_2056_SYN_GPIO_MASTER1 0x20 -#define RADIO_2056_SYN_GPIO_MASTER2 0x21 -#define RADIO_2056_SYN_TOPBIAS_MASTER 0x22 -#define RADIO_2056_SYN_TOPBIAS_RCAL 0x23 -#define RADIO_2056_SYN_AFEREG 0x24 -#define RADIO_2056_SYN_TEMPPROCSENSE 0x25 -#define RADIO_2056_SYN_TEMPPROCSENSEIDAC 0x26 -#define RADIO_2056_SYN_TEMPPROCSENSERCAL 0x27 -#define RADIO_2056_SYN_LPO 0x28 -#define RADIO_2056_SYN_VDDCAL_MASTER 0x29 -#define RADIO_2056_SYN_VDDCAL_IDAC 0x2a -#define RADIO_2056_SYN_VDDCAL_STATUS 0x2b -#define RADIO_2056_SYN_RCAL_MASTER 0x2c -#define RADIO_2056_SYN_RCAL_CODE_OUT 0x2d -#define RADIO_2056_SYN_RCCAL_CTRL0 0x2e -#define RADIO_2056_SYN_RCCAL_CTRL1 0x2f -#define RADIO_2056_SYN_RCCAL_CTRL2 0x30 -#define RADIO_2056_SYN_RCCAL_CTRL3 0x31 -#define RADIO_2056_SYN_RCCAL_CTRL4 0x32 -#define RADIO_2056_SYN_RCCAL_CTRL5 0x33 -#define RADIO_2056_SYN_RCCAL_CTRL6 0x34 -#define RADIO_2056_SYN_RCCAL_CTRL7 0x35 -#define RADIO_2056_SYN_RCCAL_CTRL8 0x36 -#define RADIO_2056_SYN_RCCAL_CTRL9 0x37 -#define RADIO_2056_SYN_RCCAL_CTRL10 0x38 -#define RADIO_2056_SYN_RCCAL_CTRL11 0x39 -#define RADIO_2056_SYN_ZCAL_SPARE1 0x3a -#define RADIO_2056_SYN_ZCAL_SPARE2 0x3b -#define RADIO_2056_SYN_PLL_MAST1 0x3c -#define RADIO_2056_SYN_PLL_MAST2 0x3d -#define RADIO_2056_SYN_PLL_MAST3 0x3e -#define RADIO_2056_SYN_PLL_BIAS_RESET 0x3f -#define RADIO_2056_SYN_PLL_XTAL0 0x40 -#define RADIO_2056_SYN_PLL_XTAL1 0x41 -#define RADIO_2056_SYN_PLL_XTAL3 0x42 -#define RADIO_2056_SYN_PLL_XTAL4 0x43 -#define RADIO_2056_SYN_PLL_XTAL5 0x44 -#define RADIO_2056_SYN_PLL_XTAL6 0x45 -#define RADIO_2056_SYN_PLL_REFDIV 0x46 -#define RADIO_2056_SYN_PLL_PFD 0x47 -#define RADIO_2056_SYN_PLL_CP1 0x48 -#define RADIO_2056_SYN_PLL_CP2 0x49 -#define RADIO_2056_SYN_PLL_CP3 0x4a -#define RADIO_2056_SYN_PLL_LOOPFILTER1 0x4b -#define RADIO_2056_SYN_PLL_LOOPFILTER2 0x4c -#define RADIO_2056_SYN_PLL_LOOPFILTER3 0x4d -#define RADIO_2056_SYN_PLL_LOOPFILTER4 0x4e -#define RADIO_2056_SYN_PLL_LOOPFILTER5 0x4f -#define RADIO_2056_SYN_PLL_MMD1 0x50 -#define RADIO_2056_SYN_PLL_MMD2 0x51 -#define RADIO_2056_SYN_PLL_VCO1 0x52 -#define RADIO_2056_SYN_PLL_VCO2 0x53 -#define RADIO_2056_SYN_PLL_MONITOR1 0x54 -#define RADIO_2056_SYN_PLL_MONITOR2 0x55 -#define RADIO_2056_SYN_PLL_VCOCAL1 0x56 -#define RADIO_2056_SYN_PLL_VCOCAL2 0x57 -#define RADIO_2056_SYN_PLL_VCOCAL4 0x58 -#define RADIO_2056_SYN_PLL_VCOCAL5 0x59 -#define RADIO_2056_SYN_PLL_VCOCAL6 0x5a -#define RADIO_2056_SYN_PLL_VCOCAL7 0x5b -#define RADIO_2056_SYN_PLL_VCOCAL8 0x5c -#define RADIO_2056_SYN_PLL_VCOCAL9 0x5d -#define RADIO_2056_SYN_PLL_VCOCAL10 0x5e -#define RADIO_2056_SYN_PLL_VCOCAL11 0x5f -#define RADIO_2056_SYN_PLL_VCOCAL12 0x60 -#define RADIO_2056_SYN_PLL_VCOCAL13 0x61 -#define RADIO_2056_SYN_PLL_VREG 0x62 -#define RADIO_2056_SYN_PLL_STATUS1 0x63 -#define RADIO_2056_SYN_PLL_STATUS2 0x64 -#define RADIO_2056_SYN_PLL_STATUS3 0x65 -#define RADIO_2056_SYN_LOGEN_PU0 0x66 -#define RADIO_2056_SYN_LOGEN_PU1 0x67 -#define RADIO_2056_SYN_LOGEN_PU2 0x68 -#define RADIO_2056_SYN_LOGEN_PU3 0x69 -#define RADIO_2056_SYN_LOGEN_PU5 0x6a -#define RADIO_2056_SYN_LOGEN_PU6 0x6b -#define RADIO_2056_SYN_LOGEN_PU7 0x6c -#define RADIO_2056_SYN_LOGEN_PU8 0x6d -#define RADIO_2056_SYN_LOGEN_BIAS_RESET 0x6e -#define RADIO_2056_SYN_LOGEN_RCCR1 0x6f -#define RADIO_2056_SYN_LOGEN_VCOBUF1 0x70 -#define RADIO_2056_SYN_LOGEN_MIXER1 0x71 -#define RADIO_2056_SYN_LOGEN_MIXER2 0x72 -#define RADIO_2056_SYN_LOGEN_BUF1 0x73 -#define RADIO_2056_SYN_LOGENBUF2 0x74 -#define RADIO_2056_SYN_LOGEN_BUF3 0x75 -#define RADIO_2056_SYN_LOGEN_BUF4 0x76 -#define RADIO_2056_SYN_LOGEN_DIV1 0x77 -#define RADIO_2056_SYN_LOGEN_DIV2 0x78 -#define RADIO_2056_SYN_LOGEN_DIV3 0x79 -#define RADIO_2056_SYN_LOGEN_ACL1 0x7a -#define RADIO_2056_SYN_LOGEN_ACL2 0x7b -#define RADIO_2056_SYN_LOGEN_ACL3 0x7c -#define RADIO_2056_SYN_LOGEN_ACL4 0x7d -#define RADIO_2056_SYN_LOGEN_ACL5 0x7e -#define RADIO_2056_SYN_LOGEN_ACL6 0x7f -#define RADIO_2056_SYN_LOGEN_ACLOUT 0x80 -#define RADIO_2056_SYN_LOGEN_ACLCAL1 0x81 -#define RADIO_2056_SYN_LOGEN_ACLCAL2 0x82 -#define RADIO_2056_SYN_LOGEN_ACLCAL3 0x83 -#define RADIO_2056_SYN_CALEN 0x84 -#define RADIO_2056_SYN_LOGEN_PEAKDET1 0x85 -#define RADIO_2056_SYN_LOGEN_CORE_ACL_OVR 0x86 -#define RADIO_2056_SYN_LOGEN_RX_DIFF_ACL_OVR 0x87 -#define RADIO_2056_SYN_LOGEN_TX_DIFF_ACL_OVR 0x88 -#define RADIO_2056_SYN_LOGEN_RX_CMOS_ACL_OVR 0x89 -#define RADIO_2056_SYN_LOGEN_TX_CMOS_ACL_OVR 0x8a -#define RADIO_2056_SYN_LOGEN_VCOBUF2 0x8b -#define RADIO_2056_SYN_LOGEN_MIXER3 0x8c -#define RADIO_2056_SYN_LOGEN_BUF5 0x8d -#define RADIO_2056_SYN_LOGEN_BUF6 0x8e -#define RADIO_2056_SYN_LOGEN_CBUFRX1 0x8f -#define RADIO_2056_SYN_LOGEN_CBUFRX2 0x90 -#define RADIO_2056_SYN_LOGEN_CBUFRX3 0x91 -#define RADIO_2056_SYN_LOGEN_CBUFRX4 0x92 -#define RADIO_2056_SYN_LOGEN_CBUFTX1 0x93 -#define RADIO_2056_SYN_LOGEN_CBUFTX2 0x94 -#define RADIO_2056_SYN_LOGEN_CBUFTX3 0x95 -#define RADIO_2056_SYN_LOGEN_CBUFTX4 0x96 -#define RADIO_2056_SYN_LOGEN_CMOSRX1 0x97 -#define RADIO_2056_SYN_LOGEN_CMOSRX2 0x98 -#define RADIO_2056_SYN_LOGEN_CMOSRX3 0x99 -#define RADIO_2056_SYN_LOGEN_CMOSRX4 0x9a -#define RADIO_2056_SYN_LOGEN_CMOSTX1 0x9b -#define RADIO_2056_SYN_LOGEN_CMOSTX2 0x9c -#define RADIO_2056_SYN_LOGEN_CMOSTX3 0x9d -#define RADIO_2056_SYN_LOGEN_CMOSTX4 0x9e -#define RADIO_2056_SYN_LOGEN_VCOBUF2_OVRVAL 0x9f -#define RADIO_2056_SYN_LOGEN_MIXER3_OVRVAL 0xa0 -#define RADIO_2056_SYN_LOGEN_BUF5_OVRVAL 0xa1 -#define RADIO_2056_SYN_LOGEN_BUF6_OVRVAL 0xa2 -#define RADIO_2056_SYN_LOGEN_CBUFRX1_OVRVAL 0xa3 -#define RADIO_2056_SYN_LOGEN_CBUFRX2_OVRVAL 0xa4 -#define RADIO_2056_SYN_LOGEN_CBUFRX3_OVRVAL 0xa5 -#define RADIO_2056_SYN_LOGEN_CBUFRX4_OVRVAL 0xa6 -#define RADIO_2056_SYN_LOGEN_CBUFTX1_OVRVAL 0xa7 -#define RADIO_2056_SYN_LOGEN_CBUFTX2_OVRVAL 0xa8 -#define RADIO_2056_SYN_LOGEN_CBUFTX3_OVRVAL 0xa9 -#define RADIO_2056_SYN_LOGEN_CBUFTX4_OVRVAL 0xaa -#define RADIO_2056_SYN_LOGEN_CMOSRX1_OVRVAL 0xab -#define RADIO_2056_SYN_LOGEN_CMOSRX2_OVRVAL 0xac -#define RADIO_2056_SYN_LOGEN_CMOSRX3_OVRVAL 0xad -#define RADIO_2056_SYN_LOGEN_CMOSRX4_OVRVAL 0xae -#define RADIO_2056_SYN_LOGEN_CMOSTX1_OVRVAL 0xaf -#define RADIO_2056_SYN_LOGEN_CMOSTX2_OVRVAL 0xb0 -#define RADIO_2056_SYN_LOGEN_CMOSTX3_OVRVAL 0xb1 -#define RADIO_2056_SYN_LOGEN_CMOSTX4_OVRVAL 0xb2 -#define RADIO_2056_SYN_LOGEN_ACL_WAITCNT 0xb3 -#define RADIO_2056_SYN_LOGEN_CORE_CALVALID 0xb4 -#define RADIO_2056_SYN_LOGEN_RX_CMOS_CALVALID 0xb5 -#define RADIO_2056_SYN_LOGEN_TX_CMOS_VALID 0xb6 - -#define RADIO_2056_TX_RESERVED_ADDR0 0x0 -#define RADIO_2056_TX_IDCODE 0x1 -#define RADIO_2056_TX_RESERVED_ADDR2 0x2 -#define RADIO_2056_TX_RESERVED_ADDR3 0x3 -#define RADIO_2056_TX_RESERVED_ADDR4 0x4 -#define RADIO_2056_TX_RESERVED_ADDR5 0x5 -#define RADIO_2056_TX_RESERVED_ADDR6 0x6 -#define RADIO_2056_TX_RESERVED_ADDR7 0x7 -#define RADIO_2056_TX_COM_CTRL 0x8 -#define RADIO_2056_TX_COM_PU 0x9 -#define RADIO_2056_TX_COM_OVR 0xa -#define RADIO_2056_TX_COM_RESET 0xb -#define RADIO_2056_TX_COM_RCAL 0xc -#define RADIO_2056_TX_COM_RC_RXLPF 0xd -#define RADIO_2056_TX_COM_RC_TXLPF 0xe -#define RADIO_2056_TX_COM_RC_RXHPF 0xf -#define RADIO_2056_TX_RESERVED_ADDR16 0x10 -#define RADIO_2056_TX_RESERVED_ADDR17 0x11 -#define RADIO_2056_TX_RESERVED_ADDR18 0x12 -#define RADIO_2056_TX_RESERVED_ADDR19 0x13 -#define RADIO_2056_TX_RESERVED_ADDR20 0x14 -#define RADIO_2056_TX_RESERVED_ADDR21 0x15 -#define RADIO_2056_TX_RESERVED_ADDR22 0x16 -#define RADIO_2056_TX_RESERVED_ADDR23 0x17 -#define RADIO_2056_TX_RESERVED_ADDR24 0x18 -#define RADIO_2056_TX_RESERVED_ADDR25 0x19 -#define RADIO_2056_TX_RESERVED_ADDR26 0x1a -#define RADIO_2056_TX_RESERVED_ADDR27 0x1b -#define RADIO_2056_TX_RESERVED_ADDR28 0x1c -#define RADIO_2056_TX_RESERVED_ADDR29 0x1d -#define RADIO_2056_TX_RESERVED_ADDR30 0x1e -#define RADIO_2056_TX_RESERVED_ADDR31 0x1f -#define RADIO_2056_TX_IQCAL_GAIN_BW 0x20 -#define RADIO_2056_TX_LOFT_FINE_I 0x21 -#define RADIO_2056_TX_LOFT_FINE_Q 0x22 -#define RADIO_2056_TX_LOFT_COARSE_I 0x23 -#define RADIO_2056_TX_LOFT_COARSE_Q 0x24 -#define RADIO_2056_TX_TX_COM_MASTER1 0x25 -#define RADIO_2056_TX_TX_COM_MASTER2 0x26 -#define RADIO_2056_TX_RXIQCAL_TXMUX 0x27 -#define RADIO_2056_TX_TX_SSI_MASTER 0x28 -#define RADIO_2056_TX_IQCAL_VCM_HG 0x29 -#define RADIO_2056_TX_IQCAL_IDAC 0x2a -#define RADIO_2056_TX_TSSI_VCM 0x2b -#define RADIO_2056_TX_TX_AMP_DET 0x2c -#define RADIO_2056_TX_TX_SSI_MUX 0x2d -#define RADIO_2056_TX_TSSIA 0x2e -#define RADIO_2056_TX_TSSIG 0x2f -#define RADIO_2056_TX_TSSI_MISC1 0x30 -#define RADIO_2056_TX_TSSI_MISC2 0x31 -#define RADIO_2056_TX_TSSI_MISC3 0x32 -#define RADIO_2056_TX_PA_SPARE1 0x33 -#define RADIO_2056_TX_PA_SPARE2 0x34 -#define RADIO_2056_TX_INTPAA_MASTER 0x35 -#define RADIO_2056_TX_INTPAA_GAIN 0x36 -#define RADIO_2056_TX_INTPAA_BOOST_TUNE 0x37 -#define RADIO_2056_TX_INTPAA_IAUX_STAT 0x38 -#define RADIO_2056_TX_INTPAA_IAUX_DYN 0x39 -#define RADIO_2056_TX_INTPAA_IMAIN_STAT 0x3a -#define RADIO_2056_TX_INTPAA_IMAIN_DYN 0x3b -#define RADIO_2056_TX_INTPAA_CASCBIAS 0x3c -#define RADIO_2056_TX_INTPAA_PASLOPE 0x3d -#define RADIO_2056_TX_INTPAA_PA_MISC 0x3e -#define RADIO_2056_TX_INTPAG_MASTER 0x3f -#define RADIO_2056_TX_INTPAG_GAIN 0x40 -#define RADIO_2056_TX_INTPAG_BOOST_TUNE 0x41 -#define RADIO_2056_TX_INTPAG_IAUX_STAT 0x42 -#define RADIO_2056_TX_INTPAG_IAUX_DYN 0x43 -#define RADIO_2056_TX_INTPAG_IMAIN_STAT 0x44 -#define RADIO_2056_TX_INTPAG_IMAIN_DYN 0x45 -#define RADIO_2056_TX_INTPAG_CASCBIAS 0x46 -#define RADIO_2056_TX_INTPAG_PASLOPE 0x47 -#define RADIO_2056_TX_INTPAG_PA_MISC 0x48 -#define RADIO_2056_TX_PADA_MASTER 0x49 -#define RADIO_2056_TX_PADA_IDAC 0x4a -#define RADIO_2056_TX_PADA_CASCBIAS 0x4b -#define RADIO_2056_TX_PADA_GAIN 0x4c -#define RADIO_2056_TX_PADA_BOOST_TUNE 0x4d -#define RADIO_2056_TX_PADA_SLOPE 0x4e -#define RADIO_2056_TX_PADG_MASTER 0x4f -#define RADIO_2056_TX_PADG_IDAC 0x50 -#define RADIO_2056_TX_PADG_CASCBIAS 0x51 -#define RADIO_2056_TX_PADG_GAIN 0x52 -#define RADIO_2056_TX_PADG_BOOST_TUNE 0x53 -#define RADIO_2056_TX_PADG_SLOPE 0x54 -#define RADIO_2056_TX_PGAA_MASTER 0x55 -#define RADIO_2056_TX_PGAA_IDAC 0x56 -#define RADIO_2056_TX_PGAA_GAIN 0x57 -#define RADIO_2056_TX_PGAA_BOOST_TUNE 0x58 -#define RADIO_2056_TX_PGAA_SLOPE 0x59 -#define RADIO_2056_TX_PGAA_MISC 0x5a -#define RADIO_2056_TX_PGAG_MASTER 0x5b -#define RADIO_2056_TX_PGAG_IDAC 0x5c -#define RADIO_2056_TX_PGAG_GAIN 0x5d -#define RADIO_2056_TX_PGAG_BOOST_TUNE 0x5e -#define RADIO_2056_TX_PGAG_SLOPE 0x5f -#define RADIO_2056_TX_PGAG_MISC 0x60 -#define RADIO_2056_TX_MIXA_MASTER 0x61 -#define RADIO_2056_TX_MIXA_BOOST_TUNE 0x62 -#define RADIO_2056_TX_MIXG 0x63 -#define RADIO_2056_TX_MIXG_BOOST_TUNE 0x64 -#define RADIO_2056_TX_BB_GM_MASTER 0x65 -#define RADIO_2056_TX_GMBB_GM 0x66 -#define RADIO_2056_TX_GMBB_IDAC 0x67 -#define RADIO_2056_TX_TXLPF_MASTER 0x68 -#define RADIO_2056_TX_TXLPF_RCCAL 0x69 -#define RADIO_2056_TX_TXLPF_RCCAL_OFF0 0x6a -#define RADIO_2056_TX_TXLPF_RCCAL_OFF1 0x6b -#define RADIO_2056_TX_TXLPF_RCCAL_OFF2 0x6c -#define RADIO_2056_TX_TXLPF_RCCAL_OFF3 0x6d -#define RADIO_2056_TX_TXLPF_RCCAL_OFF4 0x6e -#define RADIO_2056_TX_TXLPF_RCCAL_OFF5 0x6f -#define RADIO_2056_TX_TXLPF_RCCAL_OFF6 0x70 -#define RADIO_2056_TX_TXLPF_BW 0x71 -#define RADIO_2056_TX_TXLPF_GAIN 0x72 -#define RADIO_2056_TX_TXLPF_IDAC 0x73 -#define RADIO_2056_TX_TXLPF_IDAC_0 0x74 -#define RADIO_2056_TX_TXLPF_IDAC_1 0x75 -#define RADIO_2056_TX_TXLPF_IDAC_2 0x76 -#define RADIO_2056_TX_TXLPF_IDAC_3 0x77 -#define RADIO_2056_TX_TXLPF_IDAC_4 0x78 -#define RADIO_2056_TX_TXLPF_IDAC_5 0x79 -#define RADIO_2056_TX_TXLPF_IDAC_6 0x7a -#define RADIO_2056_TX_TXLPF_OPAMP_IDAC 0x7b -#define RADIO_2056_TX_TXLPF_MISC 0x7c -#define RADIO_2056_TX_TXSPARE1 0x7d -#define RADIO_2056_TX_TXSPARE2 0x7e -#define RADIO_2056_TX_TXSPARE3 0x7f -#define RADIO_2056_TX_TXSPARE4 0x80 -#define RADIO_2056_TX_TXSPARE5 0x81 -#define RADIO_2056_TX_TXSPARE6 0x82 -#define RADIO_2056_TX_TXSPARE7 0x83 -#define RADIO_2056_TX_TXSPARE8 0x84 -#define RADIO_2056_TX_TXSPARE9 0x85 -#define RADIO_2056_TX_TXSPARE10 0x86 -#define RADIO_2056_TX_TXSPARE11 0x87 -#define RADIO_2056_TX_TXSPARE12 0x88 -#define RADIO_2056_TX_TXSPARE13 0x89 -#define RADIO_2056_TX_TXSPARE14 0x8a -#define RADIO_2056_TX_TXSPARE15 0x8b -#define RADIO_2056_TX_TXSPARE16 0x8c -#define RADIO_2056_TX_STATUS_INTPA_GAIN 0x8d -#define RADIO_2056_TX_STATUS_PAD_GAIN 0x8e -#define RADIO_2056_TX_STATUS_PGA_GAIN 0x8f -#define RADIO_2056_TX_STATUS_GM_TXLPF_GAIN 0x90 -#define RADIO_2056_TX_STATUS_TXLPF_BW 0x91 -#define RADIO_2056_TX_STATUS_TXLPF_RC 0x92 -#define RADIO_2056_TX_GMBB_IDAC0 0x93 -#define RADIO_2056_TX_GMBB_IDAC1 0x94 -#define RADIO_2056_TX_GMBB_IDAC2 0x95 -#define RADIO_2056_TX_GMBB_IDAC3 0x96 -#define RADIO_2056_TX_GMBB_IDAC4 0x97 -#define RADIO_2056_TX_GMBB_IDAC5 0x98 -#define RADIO_2056_TX_GMBB_IDAC6 0x99 -#define RADIO_2056_TX_GMBB_IDAC7 0x9a - -#define RADIO_2056_RX_RESERVED_ADDR0 0x0 -#define RADIO_2056_RX_IDCODE 0x1 -#define RADIO_2056_RX_RESERVED_ADDR2 0x2 -#define RADIO_2056_RX_RESERVED_ADDR3 0x3 -#define RADIO_2056_RX_RESERVED_ADDR4 0x4 -#define RADIO_2056_RX_RESERVED_ADDR5 0x5 -#define RADIO_2056_RX_RESERVED_ADDR6 0x6 -#define RADIO_2056_RX_RESERVED_ADDR7 0x7 -#define RADIO_2056_RX_COM_CTRL 0x8 -#define RADIO_2056_RX_COM_PU 0x9 -#define RADIO_2056_RX_COM_OVR 0xa -#define RADIO_2056_RX_COM_RESET 0xb -#define RADIO_2056_RX_COM_RCAL 0xc -#define RADIO_2056_RX_COM_RC_RXLPF 0xd -#define RADIO_2056_RX_COM_RC_TXLPF 0xe -#define RADIO_2056_RX_COM_RC_RXHPF 0xf -#define RADIO_2056_RX_RESERVED_ADDR16 0x10 -#define RADIO_2056_RX_RESERVED_ADDR17 0x11 -#define RADIO_2056_RX_RESERVED_ADDR18 0x12 -#define RADIO_2056_RX_RESERVED_ADDR19 0x13 -#define RADIO_2056_RX_RESERVED_ADDR20 0x14 -#define RADIO_2056_RX_RESERVED_ADDR21 0x15 -#define RADIO_2056_RX_RESERVED_ADDR22 0x16 -#define RADIO_2056_RX_RESERVED_ADDR23 0x17 -#define RADIO_2056_RX_RESERVED_ADDR24 0x18 -#define RADIO_2056_RX_RESERVED_ADDR25 0x19 -#define RADIO_2056_RX_RESERVED_ADDR26 0x1a -#define RADIO_2056_RX_RESERVED_ADDR27 0x1b -#define RADIO_2056_RX_RESERVED_ADDR28 0x1c -#define RADIO_2056_RX_RESERVED_ADDR29 0x1d -#define RADIO_2056_RX_RESERVED_ADDR30 0x1e -#define RADIO_2056_RX_RESERVED_ADDR31 0x1f -#define RADIO_2056_RX_RXIQCAL_RXMUX 0x20 -#define RADIO_2056_RX_RSSI_PU 0x21 -#define RADIO_2056_RX_RSSI_SEL 0x22 -#define RADIO_2056_RX_RSSI_GAIN 0x23 -#define RADIO_2056_RX_RSSI_NB_IDAC 0x24 -#define RADIO_2056_RX_RSSI_WB2I_IDAC_1 0x25 -#define RADIO_2056_RX_RSSI_WB2I_IDAC_2 0x26 -#define RADIO_2056_RX_RSSI_WB2Q_IDAC_1 0x27 -#define RADIO_2056_RX_RSSI_WB2Q_IDAC_2 0x28 -#define RADIO_2056_RX_RSSI_POLE 0x29 -#define RADIO_2056_RX_RSSI_WB1_IDAC 0x2a -#define RADIO_2056_RX_RSSI_MISC 0x2b -#define RADIO_2056_RX_LNAA_MASTER 0x2c -#define RADIO_2056_RX_LNAA_TUNE 0x2d -#define RADIO_2056_RX_LNAA_GAIN 0x2e -#define RADIO_2056_RX_LNA_A_SLOPE 0x2f -#define RADIO_2056_RX_BIASPOLE_LNAA1_IDAC 0x30 -#define RADIO_2056_RX_LNAA2_IDAC 0x31 -#define RADIO_2056_RX_LNA1A_MISC 0x32 -#define RADIO_2056_RX_LNAG_MASTER 0x33 -#define RADIO_2056_RX_LNAG_TUNE 0x34 -#define RADIO_2056_RX_LNAG_GAIN 0x35 -#define RADIO_2056_RX_LNA_G_SLOPE 0x36 -#define RADIO_2056_RX_BIASPOLE_LNAG1_IDAC 0x37 -#define RADIO_2056_RX_LNAG2_IDAC 0x38 -#define RADIO_2056_RX_LNA1G_MISC 0x39 -#define RADIO_2056_RX_MIXA_MASTER 0x3a -#define RADIO_2056_RX_MIXA_VCM 0x3b -#define RADIO_2056_RX_MIXA_CTRLPTAT 0x3c -#define RADIO_2056_RX_MIXA_LOB_BIAS 0x3d -#define RADIO_2056_RX_MIXA_CORE_IDAC 0x3e -#define RADIO_2056_RX_MIXA_CMFB_IDAC 0x3f -#define RADIO_2056_RX_MIXA_BIAS_AUX 0x40 -#define RADIO_2056_RX_MIXA_BIAS_MAIN 0x41 -#define RADIO_2056_RX_MIXA_BIAS_MISC 0x42 -#define RADIO_2056_RX_MIXA_MAST_BIAS 0x43 -#define RADIO_2056_RX_MIXG_MASTER 0x44 -#define RADIO_2056_RX_MIXG_VCM 0x45 -#define RADIO_2056_RX_MIXG_CTRLPTAT 0x46 -#define RADIO_2056_RX_MIXG_LOB_BIAS 0x47 -#define RADIO_2056_RX_MIXG_CORE_IDAC 0x48 -#define RADIO_2056_RX_MIXG_CMFB_IDAC 0x49 -#define RADIO_2056_RX_MIXG_BIAS_AUX 0x4a -#define RADIO_2056_RX_MIXG_BIAS_MAIN 0x4b -#define RADIO_2056_RX_MIXG_BIAS_MISC 0x4c -#define RADIO_2056_RX_MIXG_MAST_BIAS 0x4d -#define RADIO_2056_RX_TIA_MASTER 0x4e -#define RADIO_2056_RX_TIA_IOPAMP 0x4f -#define RADIO_2056_RX_TIA_QOPAMP 0x50 -#define RADIO_2056_RX_TIA_IMISC 0x51 -#define RADIO_2056_RX_TIA_QMISC 0x52 -#define RADIO_2056_RX_TIA_GAIN 0x53 -#define RADIO_2056_RX_TIA_SPARE1 0x54 -#define RADIO_2056_RX_TIA_SPARE2 0x55 -#define RADIO_2056_RX_BB_LPF_MASTER 0x56 -#define RADIO_2056_RX_AACI_MASTER 0x57 -#define RADIO_2056_RX_RXLPF_IDAC 0x58 -#define RADIO_2056_RX_RXLPF_OPAMPBIAS_LOWQ 0x59 -#define RADIO_2056_RX_RXLPF_OPAMPBIAS_HIGHQ 0x5a -#define RADIO_2056_RX_RXLPF_BIAS_DCCANCEL 0x5b -#define RADIO_2056_RX_RXLPF_OUTVCM 0x5c -#define RADIO_2056_RX_RXLPF_INVCM_BODY 0x5d -#define RADIO_2056_RX_RXLPF_CC_OP 0x5e -#define RADIO_2056_RX_RXLPF_GAIN 0x5f -#define RADIO_2056_RX_RXLPF_Q_BW 0x60 -#define RADIO_2056_RX_RXLPF_HP_CORNER_BW 0x61 -#define RADIO_2056_RX_RXLPF_RCCAL_HPC 0x62 -#define RADIO_2056_RX_RXHPF_OFF0 0x63 -#define RADIO_2056_RX_RXHPF_OFF1 0x64 -#define RADIO_2056_RX_RXHPF_OFF2 0x65 -#define RADIO_2056_RX_RXHPF_OFF3 0x66 -#define RADIO_2056_RX_RXHPF_OFF4 0x67 -#define RADIO_2056_RX_RXHPF_OFF5 0x68 -#define RADIO_2056_RX_RXHPF_OFF6 0x69 -#define RADIO_2056_RX_RXHPF_OFF7 0x6a -#define RADIO_2056_RX_RXLPF_RCCAL_LPC 0x6b -#define RADIO_2056_RX_RXLPF_OFF_0 0x6c -#define RADIO_2056_RX_RXLPF_OFF_1 0x6d -#define RADIO_2056_RX_RXLPF_OFF_2 0x6e -#define RADIO_2056_RX_RXLPF_OFF_3 0x6f -#define RADIO_2056_RX_RXLPF_OFF_4 0x70 -#define RADIO_2056_RX_UNUSED 0x71 -#define RADIO_2056_RX_VGA_MASTER 0x72 -#define RADIO_2056_RX_VGA_BIAS 0x73 -#define RADIO_2056_RX_VGA_BIAS_DCCANCEL 0x74 -#define RADIO_2056_RX_VGA_GAIN 0x75 -#define RADIO_2056_RX_VGA_HP_CORNER_BW 0x76 -#define RADIO_2056_RX_VGABUF_BIAS 0x77 -#define RADIO_2056_RX_VGABUF_GAIN_BW 0x78 -#define RADIO_2056_RX_TXFBMIX_A 0x79 -#define RADIO_2056_RX_TXFBMIX_G 0x7a -#define RADIO_2056_RX_RXSPARE1 0x7b -#define RADIO_2056_RX_RXSPARE2 0x7c -#define RADIO_2056_RX_RXSPARE3 0x7d -#define RADIO_2056_RX_RXSPARE4 0x7e -#define RADIO_2056_RX_RXSPARE5 0x7f -#define RADIO_2056_RX_RXSPARE6 0x80 -#define RADIO_2056_RX_RXSPARE7 0x81 -#define RADIO_2056_RX_RXSPARE8 0x82 -#define RADIO_2056_RX_RXSPARE9 0x83 -#define RADIO_2056_RX_RXSPARE10 0x84 -#define RADIO_2056_RX_RXSPARE11 0x85 -#define RADIO_2056_RX_RXSPARE12 0x86 -#define RADIO_2056_RX_RXSPARE13 0x87 -#define RADIO_2056_RX_RXSPARE14 0x88 -#define RADIO_2056_RX_RXSPARE15 0x89 -#define RADIO_2056_RX_RXSPARE16 0x8a -#define RADIO_2056_RX_STATUS_LNAA_GAIN 0x8b -#define RADIO_2056_RX_STATUS_LNAG_GAIN 0x8c -#define RADIO_2056_RX_STATUS_MIXTIA_GAIN 0x8d -#define RADIO_2056_RX_STATUS_RXLPF_GAIN 0x8e -#define RADIO_2056_RX_STATUS_VGA_BUF_GAIN 0x8f -#define RADIO_2056_RX_STATUS_RXLPF_Q 0x90 -#define RADIO_2056_RX_STATUS_RXLPF_BUF_BW 0x91 -#define RADIO_2056_RX_STATUS_RXLPF_VGA_HPC 0x92 -#define RADIO_2056_RX_STATUS_RXLPF_RC 0x93 -#define RADIO_2056_RX_STATUS_HPC_RC 0x94 - -#define RADIO_2056_LNA1_A_PU 0x01 -#define RADIO_2056_LNA2_A_PU 0x02 -#define RADIO_2056_LNA1_G_PU 0x01 -#define RADIO_2056_LNA2_G_PU 0x02 -#define RADIO_2056_MIXA_PU_I 0x01 -#define RADIO_2056_MIXA_PU_Q 0x02 -#define RADIO_2056_MIXA_PU_GM 0x10 -#define RADIO_2056_MIXG_PU_I 0x01 -#define RADIO_2056_MIXG_PU_Q 0x02 -#define RADIO_2056_MIXG_PU_GM 0x10 -#define RADIO_2056_TIA_PU 0x01 -#define RADIO_2056_BB_LPF_PU 0x20 -#define RADIO_2056_W1_PU 0x02 -#define RADIO_2056_W2_PU 0x04 -#define RADIO_2056_NB_PU 0x08 -#define RADIO_2056_RSSI_W1_SEL 0x02 -#define RADIO_2056_RSSI_W2_SEL 0x04 -#define RADIO_2056_RSSI_NB_SEL 0x08 -#define RADIO_2056_VCM_MASK 0x1c -#define RADIO_2056_RSSI_VCM_SHIFT 0x02 - -#define RADIO_2057_DACBUF_VINCM_CORE0 0x0 -#define RADIO_2057_IDCODE 0x1 -#define RADIO_2057_RCCAL_MASTER 0x2 -#define RADIO_2057_RCCAL_CAP_SIZE 0x3 -#define RADIO_2057_RCAL_CONFIG 0x4 -#define RADIO_2057_GPAIO_CONFIG 0x5 -#define RADIO_2057_GPAIO_SEL1 0x6 -#define RADIO_2057_GPAIO_SEL0 0x7 -#define RADIO_2057_CLPO_CONFIG 0x8 -#define RADIO_2057_BANDGAP_CONFIG 0x9 -#define RADIO_2057_BANDGAP_RCAL_TRIM 0xa -#define RADIO_2057_AFEREG_CONFIG 0xb -#define RADIO_2057_TEMPSENSE_CONFIG 0xc -#define RADIO_2057_XTAL_CONFIG1 0xd -#define RADIO_2057_XTAL_ICORE_SIZE 0xe -#define RADIO_2057_XTAL_BUF_SIZE 0xf -#define RADIO_2057_XTAL_PULLCAP_SIZE 0x10 -#define RADIO_2057_RFPLL_MASTER 0x11 -#define RADIO_2057_VCOMONITOR_VTH_L 0x12 -#define RADIO_2057_VCOMONITOR_VTH_H 0x13 -#define RADIO_2057_VCOCAL_BIASRESET_RFPLLREG_VOUT 0x14 -#define RADIO_2057_VCO_VARCSIZE_IDAC 0x15 -#define RADIO_2057_VCOCAL_COUNTVAL0 0x16 -#define RADIO_2057_VCOCAL_COUNTVAL1 0x17 -#define RADIO_2057_VCOCAL_INTCLK_COUNT 0x18 -#define RADIO_2057_VCOCAL_MASTER 0x19 -#define RADIO_2057_VCOCAL_NUMCAPCHANGE 0x1a -#define RADIO_2057_VCOCAL_WINSIZE 0x1b -#define RADIO_2057_VCOCAL_DELAY_AFTER_REFRESH 0x1c -#define RADIO_2057_VCOCAL_DELAY_AFTER_CLOSELOOP 0x1d -#define RADIO_2057_VCOCAL_DELAY_AFTER_OPENLOOP 0x1e -#define RADIO_2057_VCOCAL_DELAY_BEFORE_OPENLOOP 0x1f -#define RADIO_2057_VCO_FORCECAPEN_FORCECAP1 0x20 -#define RADIO_2057_VCO_FORCECAP0 0x21 -#define RADIO_2057_RFPLL_REFMASTER_SPAREXTALSIZE 0x22 -#define RADIO_2057_RFPLL_PFD_RESET_PW 0x23 -#define RADIO_2057_RFPLL_LOOPFILTER_R2 0x24 -#define RADIO_2057_RFPLL_LOOPFILTER_R1 0x25 -#define RADIO_2057_RFPLL_LOOPFILTER_C3 0x26 -#define RADIO_2057_RFPLL_LOOPFILTER_C2 0x27 -#define RADIO_2057_RFPLL_LOOPFILTER_C1 0x28 -#define RADIO_2057_CP_KPD_IDAC 0x29 -#define RADIO_2057_RFPLL_IDACS 0x2a -#define RADIO_2057_RFPLL_MISC_EN 0x2b -#define RADIO_2057_RFPLL_MMD0 0x2c -#define RADIO_2057_RFPLL_MMD1 0x2d -#define RADIO_2057_RFPLL_MISC_CAL_RESETN 0x2e -#define RADIO_2057_JTAGXTAL_SIZE_CPBIAS_FILTRES 0x2f -#define RADIO_2057_VCO_ALCREF_BBPLLXTAL_SIZE 0x30 -#define RADIO_2057_VCOCAL_READCAP0 0x31 -#define RADIO_2057_VCOCAL_READCAP1 0x32 -#define RADIO_2057_VCOCAL_STATUS 0x33 -#define RADIO_2057_LOGEN_PUS 0x34 -#define RADIO_2057_LOGEN_PTAT_RESETS 0x35 -#define RADIO_2057_VCOBUF_IDACS 0x36 -#define RADIO_2057_VCOBUF_TUNE 0x37 -#define RADIO_2057_CMOSBUF_TX2GQ_IDACS 0x38 -#define RADIO_2057_CMOSBUF_TX2GI_IDACS 0x39 -#define RADIO_2057_CMOSBUF_TX5GQ_IDACS 0x3a -#define RADIO_2057_CMOSBUF_TX5GI_IDACS 0x3b -#define RADIO_2057_CMOSBUF_RX2GQ_IDACS 0x3c -#define RADIO_2057_CMOSBUF_RX2GI_IDACS 0x3d -#define RADIO_2057_CMOSBUF_RX5GQ_IDACS 0x3e -#define RADIO_2057_CMOSBUF_RX5GI_IDACS 0x3f -#define RADIO_2057_LOGEN_MX2G_IDACS 0x40 -#define RADIO_2057_LOGEN_MX2G_TUNE 0x41 -#define RADIO_2057_LOGEN_MX5G_IDACS 0x42 -#define RADIO_2057_LOGEN_MX5G_TUNE 0x43 -#define RADIO_2057_LOGEN_MX5G_RCCR 0x44 -#define RADIO_2057_LOGEN_INDBUF2G_IDAC 0x45 -#define RADIO_2057_LOGEN_INDBUF2G_IBOOST 0x46 -#define RADIO_2057_LOGEN_INDBUF2G_TUNE 0x47 -#define RADIO_2057_LOGEN_INDBUF5G_IDAC 0x48 -#define RADIO_2057_LOGEN_INDBUF5G_IBOOST 0x49 -#define RADIO_2057_LOGEN_INDBUF5G_TUNE 0x4a -#define RADIO_2057_CMOSBUF_TX_RCCR 0x4b -#define RADIO_2057_CMOSBUF_RX_RCCR 0x4c -#define RADIO_2057_LOGEN_SEL_PKDET 0x4d -#define RADIO_2057_CMOSBUF_SHAREIQ_PTAT 0x4e -#define RADIO_2057_RXTXBIAS_CONFIG_CORE0 0x4f -#define RADIO_2057_TXGM_TXRF_PUS_CORE0 0x50 -#define RADIO_2057_TXGM_IDAC_BLEED_CORE0 0x51 -#define RADIO_2057_TXGM_GAIN_CORE0 0x56 -#define RADIO_2057_TXGM2G_PKDET_PUS_CORE0 0x57 -#define RADIO_2057_PAD2G_PTATS_CORE0 0x58 -#define RADIO_2057_PAD2G_IDACS_CORE0 0x59 -#define RADIO_2057_PAD2G_BOOST_PU_CORE0 0x5a -#define RADIO_2057_PAD2G_CASCV_GAIN_CORE0 0x5b -#define RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE0 0x5c -#define RADIO_2057_TXMIX2G_LODC_CORE0 0x5d -#define RADIO_2057_PAD2G_TUNE_PUS_CORE0 0x5e -#define RADIO_2057_IPA2G_GAIN_CORE0 0x5f -#define RADIO_2057_TSSI2G_SPARE1_CORE0 0x60 -#define RADIO_2057_TSSI2G_SPARE2_CORE0 0x61 -#define RADIO_2057_IPA2G_TUNEV_CASCV_PTAT_CORE0 0x62 -#define RADIO_2057_IPA2G_IMAIN_CORE0 0x63 -#define RADIO_2057_IPA2G_CASCONV_CORE0 0x64 -#define RADIO_2057_IPA2G_CASCOFFV_CORE0 0x65 -#define RADIO_2057_IPA2G_BIAS_FILTER_CORE0 0x66 -#define RADIO_2057_TX5G_PKDET_CORE0 0x69 -#define RADIO_2057_PGA_PTAT_TXGM5G_PU_CORE0 0x6a -#define RADIO_2057_PAD5G_PTATS1_CORE0 0x6b -#define RADIO_2057_PAD5G_CLASS_PTATS2_CORE0 0x6c -#define RADIO_2057_PGA_BOOSTPTAT_IMAIN_CORE0 0x6d -#define RADIO_2057_PAD5G_CASCV_IMAIN_CORE0 0x6e -#define RADIO_2057_TXMIX5G_IBOOST_PAD_IAUX_CORE0 0x6f -#define RADIO_2057_PGA_BOOST_TUNE_CORE0 0x70 -#define RADIO_2057_PGA_GAIN_CORE0 0x71 -#define RADIO_2057_PAD5G_CASCOFFV_GAIN_PUS_CORE0 0x72 -#define RADIO_2057_TXMIX5G_BOOST_TUNE_CORE0 0x73 -#define RADIO_2057_PAD5G_TUNE_MISC_PUS_CORE0 0x74 -#define RADIO_2057_IPA5G_IAUX_CORE0 0x75 -#define RADIO_2057_IPA5G_GAIN_CORE0 0x76 -#define RADIO_2057_TSSI5G_SPARE1_CORE0 0x77 -#define RADIO_2057_TSSI5G_SPARE2_CORE0 0x78 -#define RADIO_2057_IPA5G_CASCOFFV_PU_CORE0 0x79 -#define RADIO_2057_IPA5G_PTAT_CORE0 0x7a -#define RADIO_2057_IPA5G_IMAIN_CORE0 0x7b -#define RADIO_2057_IPA5G_CASCONV_CORE0 0x7c -#define RADIO_2057_IPA5G_BIAS_FILTER_CORE0 0x7d -#define RADIO_2057_PAD_BIAS_FILTER_BWS_CORE0 0x80 -#define RADIO_2057_TR2G_CONFIG1_CORE0_NU 0x81 -#define RADIO_2057_TR2G_CONFIG2_CORE0_NU 0x82 -#define RADIO_2057_LNA5G_RFEN_CORE0 0x83 -#define RADIO_2057_TR5G_CONFIG2_CORE0_NU 0x84 -#define RADIO_2057_RXRFBIAS_IBOOST_PU_CORE0 0x85 -#define RADIO_2057_RXRF_IABAND_RXGM_IMAIN_PTAT_CORE0 0x86 -#define RADIO_2057_RXGM_CMFBITAIL_AUXPTAT_CORE0 0x87 -#define RADIO_2057_RXMIX_ICORE_RXGM_IAUX_CORE0 0x88 -#define RADIO_2057_RXMIX_CMFBITAIL_PU_CORE0 0x89 -#define RADIO_2057_LNA2_IMAIN_PTAT_PU_CORE0 0x8a -#define RADIO_2057_LNA2_IAUX_PTAT_CORE0 0x8b -#define RADIO_2057_LNA1_IMAIN_PTAT_PU_CORE0 0x8c -#define RADIO_2057_LNA15G_INPUT_MATCH_TUNE_CORE0 0x8d -#define RADIO_2057_RXRFBIAS_BANDSEL_CORE0 0x8e -#define RADIO_2057_TIA_CONFIG_CORE0 0x8f -#define RADIO_2057_TIA_IQGAIN_CORE0 0x90 -#define RADIO_2057_TIA_IBIAS2_CORE0 0x91 -#define RADIO_2057_TIA_IBIAS1_CORE0 0x92 -#define RADIO_2057_TIA_SPARE_Q_CORE0 0x93 -#define RADIO_2057_TIA_SPARE_I_CORE0 0x94 -#define RADIO_2057_RXMIX2G_PUS_CORE0 0x95 -#define RADIO_2057_RXMIX2G_VCMREFS_CORE0 0x96 -#define RADIO_2057_RXMIX2G_LODC_QI_CORE0 0x97 -#define RADIO_2057_W12G_BW_LNA2G_PUS_CORE0 0x98 -#define RADIO_2057_LNA2G_GAIN_CORE0 0x99 -#define RADIO_2057_LNA2G_TUNE_CORE0 0x9a -#define RADIO_2057_RXMIX5G_PUS_CORE0 0x9b -#define RADIO_2057_RXMIX5G_VCMREFS_CORE0 0x9c -#define RADIO_2057_RXMIX5G_LODC_QI_CORE0 0x9d -#define RADIO_2057_W15G_BW_LNA5G_PUS_CORE0 0x9e -#define RADIO_2057_LNA5G_GAIN_CORE0 0x9f -#define RADIO_2057_LNA5G_TUNE_CORE0 0xa0 -#define RADIO_2057_LPFSEL_TXRX_RXBB_PUS_CORE0 0xa1 -#define RADIO_2057_RXBB_BIAS_MASTER_CORE0 0xa2 -#define RADIO_2057_RXBB_VGABUF_IDACS_CORE0 0xa3 -#define RADIO_2057_LPF_VCMREF_TXBUF_VCMREF_CORE0 0xa4 -#define RADIO_2057_TXBUF_VINCM_CORE0 0xa5 -#define RADIO_2057_TXBUF_IDACS_CORE0 0xa6 -#define RADIO_2057_LPF_RESP_RXBUF_BW_CORE0 0xa7 -#define RADIO_2057_RXBB_CC_CORE0 0xa8 -#define RADIO_2057_RXBB_SPARE3_CORE0 0xa9 -#define RADIO_2057_RXBB_RCCAL_HPC_CORE0 0xaa -#define RADIO_2057_LPF_IDACS_CORE0 0xab -#define RADIO_2057_LPFBYP_DCLOOP_BYP_IDAC_CORE0 0xac -#define RADIO_2057_TXBUF_GAIN_CORE0 0xad -#define RADIO_2057_AFELOOPBACK_AACI_RESP_CORE0 0xae -#define RADIO_2057_RXBUF_DEGEN_CORE0 0xaf -#define RADIO_2057_RXBB_SPARE2_CORE0 0xb0 -#define RADIO_2057_RXBB_SPARE1_CORE0 0xb1 -#define RADIO_2057_RSSI_MASTER_CORE0 0xb2 -#define RADIO_2057_W2_MASTER_CORE0 0xb3 -#define RADIO_2057_NB_MASTER_CORE0 0xb4 -#define RADIO_2057_W2_IDACS0_Q_CORE0 0xb5 -#define RADIO_2057_W2_IDACS1_Q_CORE0 0xb6 -#define RADIO_2057_W2_IDACS0_I_CORE0 0xb7 -#define RADIO_2057_W2_IDACS1_I_CORE0 0xb8 -#define RADIO_2057_RSSI_GPAIOSEL_W1_IDACS_CORE0 0xb9 -#define RADIO_2057_NB_IDACS_Q_CORE0 0xba -#define RADIO_2057_NB_IDACS_I_CORE0 0xbb -#define RADIO_2057_BACKUP4_CORE0 0xc1 -#define RADIO_2057_BACKUP3_CORE0 0xc2 -#define RADIO_2057_BACKUP2_CORE0 0xc3 -#define RADIO_2057_BACKUP1_CORE0 0xc4 -#define RADIO_2057_SPARE16_CORE0 0xc5 -#define RADIO_2057_SPARE15_CORE0 0xc6 -#define RADIO_2057_SPARE14_CORE0 0xc7 -#define RADIO_2057_SPARE13_CORE0 0xc8 -#define RADIO_2057_SPARE12_CORE0 0xc9 -#define RADIO_2057_SPARE11_CORE0 0xca -#define RADIO_2057_TX2G_BIAS_RESETS_CORE0 0xcb -#define RADIO_2057_TX5G_BIAS_RESETS_CORE0 0xcc -#define RADIO_2057_IQTEST_SEL_PU 0xcd -#define RADIO_2057_XTAL_CONFIG2 0xce -#define RADIO_2057_BUFS_MISC_LPFBW_CORE0 0xcf -#define RADIO_2057_TXLPF_RCCAL_CORE0 0xd0 -#define RADIO_2057_RXBB_GPAIOSEL_RXLPF_RCCAL_CORE0 0xd1 -#define RADIO_2057_LPF_GAIN_CORE0 0xd2 -#define RADIO_2057_DACBUF_IDACS_BW_CORE0 0xd3 -#define RADIO_2057_RXTXBIAS_CONFIG_CORE1 0xd4 -#define RADIO_2057_TXGM_TXRF_PUS_CORE1 0xd5 -#define RADIO_2057_TXGM_IDAC_BLEED_CORE1 0xd6 -#define RADIO_2057_TXGM_GAIN_CORE1 0xdb -#define RADIO_2057_TXGM2G_PKDET_PUS_CORE1 0xdc -#define RADIO_2057_PAD2G_PTATS_CORE1 0xdd -#define RADIO_2057_PAD2G_IDACS_CORE1 0xde -#define RADIO_2057_PAD2G_BOOST_PU_CORE1 0xdf -#define RADIO_2057_PAD2G_CASCV_GAIN_CORE1 0xe0 -#define RADIO_2057_TXMIX2G_TUNE_BOOST_PU_CORE1 0xe1 -#define RADIO_2057_TXMIX2G_LODC_CORE1 0xe2 -#define RADIO_2057_PAD2G_TUNE_PUS_CORE1 0xe3 -#define RADIO_2057_IPA2G_GAIN_CORE1 0xe4 -#define RADIO_2057_TSSI2G_SPARE1_CORE1 0xe5 -#define RADIO_2057_TSSI2G_SPARE2_CORE1 0xe6 -#define RADIO_2057_IPA2G_TUNEV_CASCV_PTAT_CORE1 0xe7 -#define RADIO_2057_IPA2G_IMAIN_CORE1 0xe8 -#define RADIO_2057_IPA2G_CASCONV_CORE1 0xe9 -#define RADIO_2057_IPA2G_CASCOFFV_CORE1 0xea -#define RADIO_2057_IPA2G_BIAS_FILTER_CORE1 0xeb -#define RADIO_2057_TX5G_PKDET_CORE1 0xee -#define RADIO_2057_PGA_PTAT_TXGM5G_PU_CORE1 0xef -#define RADIO_2057_PAD5G_PTATS1_CORE1 0xf0 -#define RADIO_2057_PAD5G_CLASS_PTATS2_CORE1 0xf1 -#define RADIO_2057_PGA_BOOSTPTAT_IMAIN_CORE1 0xf2 -#define RADIO_2057_PAD5G_CASCV_IMAIN_CORE1 0xf3 -#define RADIO_2057_TXMIX5G_IBOOST_PAD_IAUX_CORE1 0xf4 -#define RADIO_2057_PGA_BOOST_TUNE_CORE1 0xf5 -#define RADIO_2057_PGA_GAIN_CORE1 0xf6 -#define RADIO_2057_PAD5G_CASCOFFV_GAIN_PUS_CORE1 0xf7 -#define RADIO_2057_TXMIX5G_BOOST_TUNE_CORE1 0xf8 -#define RADIO_2057_PAD5G_TUNE_MISC_PUS_CORE1 0xf9 -#define RADIO_2057_IPA5G_IAUX_CORE1 0xfa -#define RADIO_2057_IPA5G_GAIN_CORE1 0xfb -#define RADIO_2057_TSSI5G_SPARE1_CORE1 0xfc -#define RADIO_2057_TSSI5G_SPARE2_CORE1 0xfd -#define RADIO_2057_IPA5G_CASCOFFV_PU_CORE1 0xfe -#define RADIO_2057_IPA5G_PTAT_CORE1 0xff -#define RADIO_2057_IPA5G_IMAIN_CORE1 0x100 -#define RADIO_2057_IPA5G_CASCONV_CORE1 0x101 -#define RADIO_2057_IPA5G_BIAS_FILTER_CORE1 0x102 -#define RADIO_2057_PAD_BIAS_FILTER_BWS_CORE1 0x105 -#define RADIO_2057_TR2G_CONFIG1_CORE1_NU 0x106 -#define RADIO_2057_TR2G_CONFIG2_CORE1_NU 0x107 -#define RADIO_2057_LNA5G_RFEN_CORE1 0x108 -#define RADIO_2057_TR5G_CONFIG2_CORE1_NU 0x109 -#define RADIO_2057_RXRFBIAS_IBOOST_PU_CORE1 0x10a -#define RADIO_2057_RXRF_IABAND_RXGM_IMAIN_PTAT_CORE1 0x10b -#define RADIO_2057_RXGM_CMFBITAIL_AUXPTAT_CORE1 0x10c -#define RADIO_2057_RXMIX_ICORE_RXGM_IAUX_CORE1 0x10d -#define RADIO_2057_RXMIX_CMFBITAIL_PU_CORE1 0x10e -#define RADIO_2057_LNA2_IMAIN_PTAT_PU_CORE1 0x10f -#define RADIO_2057_LNA2_IAUX_PTAT_CORE1 0x110 -#define RADIO_2057_LNA1_IMAIN_PTAT_PU_CORE1 0x111 -#define RADIO_2057_LNA15G_INPUT_MATCH_TUNE_CORE1 0x112 -#define RADIO_2057_RXRFBIAS_BANDSEL_CORE1 0x113 -#define RADIO_2057_TIA_CONFIG_CORE1 0x114 -#define RADIO_2057_TIA_IQGAIN_CORE1 0x115 -#define RADIO_2057_TIA_IBIAS2_CORE1 0x116 -#define RADIO_2057_TIA_IBIAS1_CORE1 0x117 -#define RADIO_2057_TIA_SPARE_Q_CORE1 0x118 -#define RADIO_2057_TIA_SPARE_I_CORE1 0x119 -#define RADIO_2057_RXMIX2G_PUS_CORE1 0x11a -#define RADIO_2057_RXMIX2G_VCMREFS_CORE1 0x11b -#define RADIO_2057_RXMIX2G_LODC_QI_CORE1 0x11c -#define RADIO_2057_W12G_BW_LNA2G_PUS_CORE1 0x11d -#define RADIO_2057_LNA2G_GAIN_CORE1 0x11e -#define RADIO_2057_LNA2G_TUNE_CORE1 0x11f -#define RADIO_2057_RXMIX5G_PUS_CORE1 0x120 -#define RADIO_2057_RXMIX5G_VCMREFS_CORE1 0x121 -#define RADIO_2057_RXMIX5G_LODC_QI_CORE1 0x122 -#define RADIO_2057_W15G_BW_LNA5G_PUS_CORE1 0x123 -#define RADIO_2057_LNA5G_GAIN_CORE1 0x124 -#define RADIO_2057_LNA5G_TUNE_CORE1 0x125 -#define RADIO_2057_LPFSEL_TXRX_RXBB_PUS_CORE1 0x126 -#define RADIO_2057_RXBB_BIAS_MASTER_CORE1 0x127 -#define RADIO_2057_RXBB_VGABUF_IDACS_CORE1 0x128 -#define RADIO_2057_LPF_VCMREF_TXBUF_VCMREF_CORE1 0x129 -#define RADIO_2057_TXBUF_VINCM_CORE1 0x12a -#define RADIO_2057_TXBUF_IDACS_CORE1 0x12b -#define RADIO_2057_LPF_RESP_RXBUF_BW_CORE1 0x12c -#define RADIO_2057_RXBB_CC_CORE1 0x12d -#define RADIO_2057_RXBB_SPARE3_CORE1 0x12e -#define RADIO_2057_RXBB_RCCAL_HPC_CORE1 0x12f -#define RADIO_2057_LPF_IDACS_CORE1 0x130 -#define RADIO_2057_LPFBYP_DCLOOP_BYP_IDAC_CORE1 0x131 -#define RADIO_2057_TXBUF_GAIN_CORE1 0x132 -#define RADIO_2057_AFELOOPBACK_AACI_RESP_CORE1 0x133 -#define RADIO_2057_RXBUF_DEGEN_CORE1 0x134 -#define RADIO_2057_RXBB_SPARE2_CORE1 0x135 -#define RADIO_2057_RXBB_SPARE1_CORE1 0x136 -#define RADIO_2057_RSSI_MASTER_CORE1 0x137 -#define RADIO_2057_W2_MASTER_CORE1 0x138 -#define RADIO_2057_NB_MASTER_CORE1 0x139 -#define RADIO_2057_W2_IDACS0_Q_CORE1 0x13a -#define RADIO_2057_W2_IDACS1_Q_CORE1 0x13b -#define RADIO_2057_W2_IDACS0_I_CORE1 0x13c -#define RADIO_2057_W2_IDACS1_I_CORE1 0x13d -#define RADIO_2057_RSSI_GPAIOSEL_W1_IDACS_CORE1 0x13e -#define RADIO_2057_NB_IDACS_Q_CORE1 0x13f -#define RADIO_2057_NB_IDACS_I_CORE1 0x140 -#define RADIO_2057_BACKUP4_CORE1 0x146 -#define RADIO_2057_BACKUP3_CORE1 0x147 -#define RADIO_2057_BACKUP2_CORE1 0x148 -#define RADIO_2057_BACKUP1_CORE1 0x149 -#define RADIO_2057_SPARE16_CORE1 0x14a -#define RADIO_2057_SPARE15_CORE1 0x14b -#define RADIO_2057_SPARE14_CORE1 0x14c -#define RADIO_2057_SPARE13_CORE1 0x14d -#define RADIO_2057_SPARE12_CORE1 0x14e -#define RADIO_2057_SPARE11_CORE1 0x14f -#define RADIO_2057_TX2G_BIAS_RESETS_CORE1 0x150 -#define RADIO_2057_TX5G_BIAS_RESETS_CORE1 0x151 -#define RADIO_2057_SPARE8_CORE1 0x152 -#define RADIO_2057_SPARE7_CORE1 0x153 -#define RADIO_2057_BUFS_MISC_LPFBW_CORE1 0x154 -#define RADIO_2057_TXLPF_RCCAL_CORE1 0x155 -#define RADIO_2057_RXBB_GPAIOSEL_RXLPF_RCCAL_CORE1 0x156 -#define RADIO_2057_LPF_GAIN_CORE1 0x157 -#define RADIO_2057_DACBUF_IDACS_BW_CORE1 0x158 -#define RADIO_2057_DACBUF_VINCM_CORE1 0x159 -#define RADIO_2057_RCCAL_START_R1_Q1_P1 0x15a -#define RADIO_2057_RCCAL_X1 0x15b -#define RADIO_2057_RCCAL_TRC0 0x15c -#define RADIO_2057_RCCAL_TRC1 0x15d -#define RADIO_2057_RCCAL_DONE_OSCCAP 0x15e -#define RADIO_2057_RCCAL_N0_0 0x15f -#define RADIO_2057_RCCAL_N0_1 0x160 -#define RADIO_2057_RCCAL_N1_0 0x161 -#define RADIO_2057_RCCAL_N1_1 0x162 -#define RADIO_2057_RCAL_STATUS 0x163 -#define RADIO_2057_XTALPUOVR_PINCTRL 0x164 -#define RADIO_2057_OVR_REG0 0x165 -#define RADIO_2057_OVR_REG1 0x166 -#define RADIO_2057_OVR_REG2 0x167 -#define RADIO_2057_OVR_REG3 0x168 -#define RADIO_2057_OVR_REG4 0x169 -#define RADIO_2057_RCCAL_SCAP_VAL 0x16a -#define RADIO_2057_RCCAL_BCAP_VAL 0x16b -#define RADIO_2057_RCCAL_HPC_VAL 0x16c -#define RADIO_2057_RCCAL_OVERRIDES 0x16d -#define RADIO_2057_TX0_IQCAL_GAIN_BW 0x170 -#define RADIO_2057_TX0_LOFT_FINE_I 0x171 -#define RADIO_2057_TX0_LOFT_FINE_Q 0x172 -#define RADIO_2057_TX0_LOFT_COARSE_I 0x173 -#define RADIO_2057_TX0_LOFT_COARSE_Q 0x174 -#define RADIO_2057_TX0_TX_SSI_MASTER 0x175 -#define RADIO_2057_TX0_IQCAL_VCM_HG 0x176 -#define RADIO_2057_TX0_IQCAL_IDAC 0x177 -#define RADIO_2057_TX0_TSSI_VCM 0x178 -#define RADIO_2057_TX0_TX_SSI_MUX 0x179 -#define RADIO_2057_TX0_TSSIA 0x17a -#define RADIO_2057_TX0_TSSIG 0x17b -#define RADIO_2057_TX0_TSSI_MISC1 0x17c -#define RADIO_2057_TX0_TXRXCOUPLE_2G_ATTEN 0x17d -#define RADIO_2057_TX0_TXRXCOUPLE_2G_PWRUP 0x17e -#define RADIO_2057_TX0_TXRXCOUPLE_5G_ATTEN 0x17f -#define RADIO_2057_TX0_TXRXCOUPLE_5G_PWRUP 0x180 -#define RADIO_2057_TX1_IQCAL_GAIN_BW 0x190 -#define RADIO_2057_TX1_LOFT_FINE_I 0x191 -#define RADIO_2057_TX1_LOFT_FINE_Q 0x192 -#define RADIO_2057_TX1_LOFT_COARSE_I 0x193 -#define RADIO_2057_TX1_LOFT_COARSE_Q 0x194 -#define RADIO_2057_TX1_TX_SSI_MASTER 0x195 -#define RADIO_2057_TX1_IQCAL_VCM_HG 0x196 -#define RADIO_2057_TX1_IQCAL_IDAC 0x197 -#define RADIO_2057_TX1_TSSI_VCM 0x198 -#define RADIO_2057_TX1_TX_SSI_MUX 0x199 -#define RADIO_2057_TX1_TSSIA 0x19a -#define RADIO_2057_TX1_TSSIG 0x19b -#define RADIO_2057_TX1_TSSI_MISC1 0x19c -#define RADIO_2057_TX1_TXRXCOUPLE_2G_ATTEN 0x19d -#define RADIO_2057_TX1_TXRXCOUPLE_2G_PWRUP 0x19e -#define RADIO_2057_TX1_TXRXCOUPLE_5G_ATTEN 0x19f -#define RADIO_2057_TX1_TXRXCOUPLE_5G_PWRUP 0x1a0 -#define RADIO_2057_AFE_VCM_CAL_MASTER_CORE0 0x1a1 -#define RADIO_2057_AFE_SET_VCM_I_CORE0 0x1a2 -#define RADIO_2057_AFE_SET_VCM_Q_CORE0 0x1a3 -#define RADIO_2057_AFE_STATUS_VCM_IQADC_CORE0 0x1a4 -#define RADIO_2057_AFE_STATUS_VCM_I_CORE0 0x1a5 -#define RADIO_2057_AFE_STATUS_VCM_Q_CORE0 0x1a6 -#define RADIO_2057_AFE_VCM_CAL_MASTER_CORE1 0x1a7 -#define RADIO_2057_AFE_SET_VCM_I_CORE1 0x1a8 -#define RADIO_2057_AFE_SET_VCM_Q_CORE1 0x1a9 -#define RADIO_2057_AFE_STATUS_VCM_IQADC_CORE1 0x1aa -#define RADIO_2057_AFE_STATUS_VCM_I_CORE1 0x1ab -#define RADIO_2057_AFE_STATUS_VCM_Q_CORE1 0x1ac - -#define RADIO_2057v7_DACBUF_VINCM_CORE0 0x1ad -#define RADIO_2057v7_RCCAL_MASTER 0x1ae -#define RADIO_2057v7_TR2G_CONFIG3_CORE0_NU 0x1af -#define RADIO_2057v7_TR2G_CONFIG3_CORE1_NU 0x1b0 -#define RADIO_2057v7_LOGEN_PUS1 0x1b1 -#define RADIO_2057v7_OVR_REG5 0x1b2 -#define RADIO_2057v7_OVR_REG6 0x1b3 -#define RADIO_2057v7_OVR_REG7 0x1b4 -#define RADIO_2057v7_OVR_REG8 0x1b5 -#define RADIO_2057v7_OVR_REG9 0x1b6 -#define RADIO_2057v7_OVR_REG10 0x1b7 -#define RADIO_2057v7_OVR_REG11 0x1b8 -#define RADIO_2057v7_OVR_REG12 0x1b9 -#define RADIO_2057v7_OVR_REG13 0x1ba -#define RADIO_2057v7_OVR_REG14 0x1bb -#define RADIO_2057v7_OVR_REG15 0x1bc -#define RADIO_2057v7_OVR_REG16 0x1bd -#define RADIO_2057v7_OVR_REG1 0x1be -#define RADIO_2057v7_OVR_REG18 0x1bf -#define RADIO_2057v7_OVR_REG19 0x1c0 -#define RADIO_2057v7_OVR_REG20 0x1c1 -#define RADIO_2057v7_OVR_REG21 0x1c2 -#define RADIO_2057v7_OVR_REG2 0x1c3 -#define RADIO_2057v7_OVR_REG23 0x1c4 -#define RADIO_2057v7_OVR_REG24 0x1c5 -#define RADIO_2057v7_OVR_REG25 0x1c6 -#define RADIO_2057v7_OVR_REG26 0x1c7 -#define RADIO_2057v7_OVR_REG27 0x1c8 -#define RADIO_2057v7_OVR_REG28 0x1c9 -#define RADIO_2057v7_IQTEST_SEL_PU2 0x1ca - -#define RADIO_2057_VCM_MASK 0x7 - -#endif /* _BRCM_PHY_RADIO_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phyreg_n.h b/drivers/staging/brcm80211/brcmsmac/phy/phyreg_n.h deleted file mode 100644 index a97c3a79947..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phyreg_n.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#define NPHY_TBL_ID_GAIN1 0 -#define NPHY_TBL_ID_GAIN2 1 -#define NPHY_TBL_ID_GAINBITS1 2 -#define NPHY_TBL_ID_GAINBITS2 3 -#define NPHY_TBL_ID_GAINLIMIT 4 -#define NPHY_TBL_ID_WRSSIGainLimit 5 -#define NPHY_TBL_ID_RFSEQ 7 -#define NPHY_TBL_ID_AFECTRL 8 -#define NPHY_TBL_ID_ANTSWCTRLLUT 9 -#define NPHY_TBL_ID_IQLOCAL 15 -#define NPHY_TBL_ID_NOISEVAR 16 -#define NPHY_TBL_ID_SAMPLEPLAY 17 -#define NPHY_TBL_ID_CORE1TXPWRCTL 26 -#define NPHY_TBL_ID_CORE2TXPWRCTL 27 -#define NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL 30 - -#define NPHY_TBL_ID_EPSILONTBL0 31 -#define NPHY_TBL_ID_SCALARTBL0 32 -#define NPHY_TBL_ID_EPSILONTBL1 33 -#define NPHY_TBL_ID_SCALARTBL1 34 - -#define NPHY_TO_BPHY_OFF 0xc00 - -#define NPHY_BandControl_currentBand 0x0001 -#define RFCC_CHIP0_PU 0x0400 -#define RFCC_POR_FORCE 0x0040 -#define RFCC_OE_POR_FORCE 0x0080 -#define NPHY_RfctrlIntc_override_OFF 0 -#define NPHY_RfctrlIntc_override_TRSW 1 -#define NPHY_RfctrlIntc_override_PA 2 -#define NPHY_RfctrlIntc_override_EXT_LNA_PU 3 -#define NPHY_RfctrlIntc_override_EXT_LNA_GAIN 4 -#define RIFS_ENABLE 0x80 -#define BPHY_BAND_SEL_UP20 0x10 -#define NPHY_MLenable 0x02 - -#define NPHY_RfseqMode_CoreActv_override 0x0001 -#define NPHY_RfseqMode_Trigger_override 0x0002 -#define NPHY_RfseqCoreActv_TxRxChain0 (0x11) -#define NPHY_RfseqCoreActv_TxRxChain1 (0x22) - -#define NPHY_RfseqTrigger_rx2tx 0x0001 -#define NPHY_RfseqTrigger_tx2rx 0x0002 -#define NPHY_RfseqTrigger_updategainh 0x0004 -#define NPHY_RfseqTrigger_updategainl 0x0008 -#define NPHY_RfseqTrigger_updategainu 0x0010 -#define NPHY_RfseqTrigger_reset2rx 0x0020 -#define NPHY_RfseqStatus_rx2tx 0x0001 -#define NPHY_RfseqStatus_tx2rx 0x0002 -#define NPHY_RfseqStatus_updategainh 0x0004 -#define NPHY_RfseqStatus_updategainl 0x0008 -#define NPHY_RfseqStatus_updategainu 0x0010 -#define NPHY_RfseqStatus_reset2rx 0x0020 -#define NPHY_ClassifierCtrl_cck_en 0x1 -#define NPHY_ClassifierCtrl_ofdm_en 0x2 -#define NPHY_ClassifierCtrl_waited_en 0x4 -#define NPHY_IQFlip_ADC1 0x0001 -#define NPHY_IQFlip_ADC2 0x0010 -#define NPHY_sampleCmd_STOP 0x0002 - -#define RX_GF_OR_MM 0x0004 -#define RX_GF_MM_AUTO 0x0100 - -#define NPHY_iqloCalCmdGctl_IQLO_CAL_EN 0x8000 - -#define NPHY_IqestCmd_iqstart 0x1 -#define NPHY_IqestCmd_iqMode 0x2 - -#define NPHY_TxPwrCtrlCmd_pwrIndex_init 0x40 -#define NPHY_TxPwrCtrlCmd_pwrIndex_init_rev7 0x19 - -#define PRIM_SEL_UP20 0x8000 - -#define NPHY_RFSEQ_RX2TX 0x0 -#define NPHY_RFSEQ_TX2RX 0x1 -#define NPHY_RFSEQ_RESET2RX 0x2 -#define NPHY_RFSEQ_UPDATEGAINH 0x3 -#define NPHY_RFSEQ_UPDATEGAINL 0x4 -#define NPHY_RFSEQ_UPDATEGAINU 0x5 - -#define NPHY_RFSEQ_CMD_NOP 0x0 -#define NPHY_RFSEQ_CMD_RXG_FBW 0x1 -#define NPHY_RFSEQ_CMD_TR_SWITCH 0x2 -#define NPHY_RFSEQ_CMD_EXT_PA 0x3 -#define NPHY_RFSEQ_CMD_RXPD_TXPD 0x4 -#define NPHY_RFSEQ_CMD_TX_GAIN 0x5 -#define NPHY_RFSEQ_CMD_RX_GAIN 0x6 -#define NPHY_RFSEQ_CMD_SET_HPF_BW 0x7 -#define NPHY_RFSEQ_CMD_CLR_HIQ_DIS 0x8 -#define NPHY_RFSEQ_CMD_END 0xf - -#define NPHY_REV3_RFSEQ_CMD_NOP 0x0 -#define NPHY_REV3_RFSEQ_CMD_RXG_FBW 0x1 -#define NPHY_REV3_RFSEQ_CMD_TR_SWITCH 0x2 -#define NPHY_REV3_RFSEQ_CMD_INT_PA_PU 0x3 -#define NPHY_REV3_RFSEQ_CMD_EXT_PA 0x4 -#define NPHY_REV3_RFSEQ_CMD_RXPD_TXPD 0x5 -#define NPHY_REV3_RFSEQ_CMD_TX_GAIN 0x6 -#define NPHY_REV3_RFSEQ_CMD_RX_GAIN 0x7 -#define NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS 0x8 -#define NPHY_REV3_RFSEQ_CMD_SET_HPF_H_HPC 0x9 -#define NPHY_REV3_RFSEQ_CMD_SET_LPF_H_HPC 0xa -#define NPHY_REV3_RFSEQ_CMD_SET_HPF_M_HPC 0xb -#define NPHY_REV3_RFSEQ_CMD_SET_LPF_M_HPC 0xc -#define NPHY_REV3_RFSEQ_CMD_SET_HPF_L_HPC 0xd -#define NPHY_REV3_RFSEQ_CMD_SET_LPF_L_HPC 0xe -#define NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS 0xf -#define NPHY_REV3_RFSEQ_CMD_END 0x1f - -#define NPHY_RSSI_SEL_W1 0x0 -#define NPHY_RSSI_SEL_W2 0x1 -#define NPHY_RSSI_SEL_NB 0x2 -#define NPHY_RSSI_SEL_IQ 0x3 -#define NPHY_RSSI_SEL_TSSI_2G 0x4 -#define NPHY_RSSI_SEL_TSSI_5G 0x5 -#define NPHY_RSSI_SEL_TBD 0x6 - -#define NPHY_RAIL_I 0x0 -#define NPHY_RAIL_Q 0x1 - -#define NPHY_FORCESIG_DECODEGATEDCLKS 0x8 - -#define NPHY_REV7_RfctrlOverride_cmd_rxrf_pu 0x0 -#define NPHY_REV7_RfctrlOverride_cmd_rx_pu 0x1 -#define NPHY_REV7_RfctrlOverride_cmd_tx_pu 0x2 -#define NPHY_REV7_RfctrlOverride_cmd_rxgain 0x3 -#define NPHY_REV7_RfctrlOverride_cmd_txgain 0x4 - -#define NPHY_REV7_RXGAINCODE_RFMXGAIN_MASK 0x000ff -#define NPHY_REV7_RXGAINCODE_LPFGAIN_MASK 0x0ff00 -#define NPHY_REV7_RXGAINCODE_DVGAGAIN_MASK 0xf0000 - -#define NPHY_REV7_TXGAINCODE_TGAIN_MASK 0x7fff -#define NPHY_REV7_TXGAINCODE_LPFGAIN_MASK 0x8000 -#define NPHY_REV7_TXGAINCODE_BIQ0GAIN_SHIFT 14 - -#define NPHY_REV7_RFCTRLOVERRIDE_ID0 0x0 -#define NPHY_REV7_RFCTRLOVERRIDE_ID1 0x1 -#define NPHY_REV7_RFCTRLOVERRIDE_ID2 0x2 - -#define NPHY_IqestIqAccLo(core) ((core == 0) ? 0x12c : 0x134) - -#define NPHY_IqestIqAccHi(core) ((core == 0) ? 0x12d : 0x135) - -#define NPHY_IqestipwrAccLo(core) ((core == 0) ? 0x12e : 0x136) - -#define NPHY_IqestipwrAccHi(core) ((core == 0) ? 0x12f : 0x137) - -#define NPHY_IqestqpwrAccLo(core) ((core == 0) ? 0x130 : 0x138) - -#define NPHY_IqestqpwrAccHi(core) ((core == 0) ? 0x131 : 0x139) diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c deleted file mode 100644 index 622c01ca72c..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c +++ /dev/null @@ -1,3250 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include "phytbl_lcn.h" - -static const u32 dot11lcn_gain_tbl_rev0[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000004, - 0x00000000, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000d, - 0x0000004d, - 0x0000008d, - 0x0000000d, - 0x0000004d, - 0x0000008d, - 0x000000cd, - 0x0000004f, - 0x0000008f, - 0x000000cf, - 0x000000d3, - 0x00000113, - 0x00000513, - 0x00000913, - 0x00000953, - 0x00000d53, - 0x00001153, - 0x00001193, - 0x00005193, - 0x00009193, - 0x0000d193, - 0x00011193, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000004, - 0x00000000, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000d, - 0x0000004d, - 0x0000008d, - 0x0000000d, - 0x0000004d, - 0x0000008d, - 0x000000cd, - 0x0000004f, - 0x0000008f, - 0x000000cf, - 0x000000d3, - 0x00000113, - 0x00000513, - 0x00000913, - 0x00000953, - 0x00000d53, - 0x00001153, - 0x00005153, - 0x00009153, - 0x0000d153, - 0x00011153, - 0x00015153, - 0x00019153, - 0x0001d153, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 dot11lcn_gain_tbl_rev1[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000008, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000D, - 0x00000011, - 0x00000051, - 0x00000091, - 0x00000011, - 0x00000051, - 0x00000091, - 0x000000d1, - 0x00000053, - 0x00000093, - 0x000000d3, - 0x000000d7, - 0x00000117, - 0x00000517, - 0x00000917, - 0x00000957, - 0x00000d57, - 0x00001157, - 0x00001197, - 0x00005197, - 0x00009197, - 0x0000d197, - 0x00011197, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000008, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000D, - 0x00000011, - 0x00000051, - 0x00000091, - 0x00000011, - 0x00000051, - 0x00000091, - 0x000000d1, - 0x00000053, - 0x00000093, - 0x000000d3, - 0x000000d7, - 0x00000117, - 0x00000517, - 0x00000917, - 0x00000957, - 0x00000d57, - 0x00001157, - 0x00005157, - 0x00009157, - 0x0000d157, - 0x00011157, - 0x00015157, - 0x00019157, - 0x0001d157, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u16 dot11lcn_aux_gain_idx_tbl_rev0[] = { - 0x0401, - 0x0402, - 0x0403, - 0x0404, - 0x0405, - 0x0406, - 0x0407, - 0x0408, - 0x0409, - 0x040a, - 0x058b, - 0x058c, - 0x058d, - 0x058e, - 0x058f, - 0x0090, - 0x0091, - 0x0092, - 0x0193, - 0x0194, - 0x0195, - 0x0196, - 0x0197, - 0x0198, - 0x0199, - 0x019a, - 0x019b, - 0x019c, - 0x019d, - 0x019e, - 0x019f, - 0x01a0, - 0x01a1, - 0x01a2, - 0x01a3, - 0x01a4, - 0x01a5, - 0x0000, -}; - -static const u32 dot11lcn_gain_idx_tbl_rev0[] = { - 0x00000000, - 0x00000000, - 0x10000000, - 0x00000000, - 0x20000000, - 0x00000000, - 0x30000000, - 0x00000000, - 0x40000000, - 0x00000000, - 0x50000000, - 0x00000000, - 0x60000000, - 0x00000000, - 0x70000000, - 0x00000000, - 0x80000000, - 0x00000000, - 0x90000000, - 0x00000008, - 0xa0000000, - 0x00000008, - 0xb0000000, - 0x00000008, - 0xc0000000, - 0x00000008, - 0xd0000000, - 0x00000008, - 0xe0000000, - 0x00000008, - 0xf0000000, - 0x00000008, - 0x00000000, - 0x00000009, - 0x10000000, - 0x00000009, - 0x20000000, - 0x00000019, - 0x30000000, - 0x00000019, - 0x40000000, - 0x00000019, - 0x50000000, - 0x00000019, - 0x60000000, - 0x00000019, - 0x70000000, - 0x00000019, - 0x80000000, - 0x00000019, - 0x90000000, - 0x00000019, - 0xa0000000, - 0x00000019, - 0xb0000000, - 0x00000019, - 0xc0000000, - 0x00000019, - 0xd0000000, - 0x00000019, - 0xe0000000, - 0x00000019, - 0xf0000000, - 0x00000019, - 0x00000000, - 0x0000001a, - 0x10000000, - 0x0000001a, - 0x20000000, - 0x0000001a, - 0x30000000, - 0x0000001a, - 0x40000000, - 0x0000001a, - 0x50000000, - 0x00000002, - 0x60000000, - 0x00000002, - 0x70000000, - 0x00000002, - 0x80000000, - 0x00000002, - 0x90000000, - 0x00000002, - 0xa0000000, - 0x00000002, - 0xb0000000, - 0x00000002, - 0xc0000000, - 0x0000000a, - 0xd0000000, - 0x0000000a, - 0xe0000000, - 0x0000000a, - 0xf0000000, - 0x0000000a, - 0x00000000, - 0x0000000b, - 0x10000000, - 0x0000000b, - 0x20000000, - 0x0000000b, - 0x30000000, - 0x0000000b, - 0x40000000, - 0x0000000b, - 0x50000000, - 0x0000001b, - 0x60000000, - 0x0000001b, - 0x70000000, - 0x0000001b, - 0x80000000, - 0x0000001b, - 0x90000000, - 0x0000001b, - 0xa0000000, - 0x0000001b, - 0xb0000000, - 0x0000001b, - 0xc0000000, - 0x0000001b, - 0xd0000000, - 0x0000001b, - 0xe0000000, - 0x0000001b, - 0xf0000000, - 0x0000001b, - 0x00000000, - 0x0000001c, - 0x10000000, - 0x0000001c, - 0x20000000, - 0x0000001c, - 0x30000000, - 0x0000001c, - 0x40000000, - 0x0000001c, - 0x50000000, - 0x0000001c, - 0x60000000, - 0x0000001c, - 0x70000000, - 0x0000001c, - 0x80000000, - 0x0000001c, - 0x90000000, - 0x0000001c, -}; - -static const u16 dot11lcn_aux_gain_idx_tbl_2G[] = { - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0001, - 0x0080, - 0x0081, - 0x0100, - 0x0101, - 0x0180, - 0x0181, - 0x0182, - 0x0183, - 0x0184, - 0x0185, - 0x0186, - 0x0187, - 0x0188, - 0x0285, - 0x0289, - 0x028a, - 0x028b, - 0x028c, - 0x028d, - 0x028e, - 0x028f, - 0x0290, - 0x0291, - 0x0292, - 0x0293, - 0x0294, - 0x0295, - 0x0296, - 0x0297, - 0x0298, - 0x0299, - 0x029a, - 0x0000 -}; - -static const u8 dot11lcn_gain_val_tbl_2G[] = { - 0xfc, - 0x02, - 0x08, - 0x0e, - 0x13, - 0x1b, - 0xfc, - 0x02, - 0x08, - 0x0e, - 0x13, - 0x1b, - 0xfc, - 0x00, - 0x0c, - 0x03, - 0xeb, - 0xfe, - 0x07, - 0x0b, - 0x0f, - 0xfb, - 0xfe, - 0x01, - 0x05, - 0x08, - 0x0b, - 0x0e, - 0x11, - 0x14, - 0x17, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x15, - 0x18, - 0x1b, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 -}; - -static const u32 dot11lcn_gain_idx_tbl_2G[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x10000000, - 0x00000000, - 0x00000000, - 0x00000008, - 0x10000000, - 0x00000008, - 0x00000000, - 0x00000010, - 0x10000000, - 0x00000010, - 0x00000000, - 0x00000018, - 0x10000000, - 0x00000018, - 0x20000000, - 0x00000018, - 0x30000000, - 0x00000018, - 0x40000000, - 0x00000018, - 0x50000000, - 0x00000018, - 0x60000000, - 0x00000018, - 0x70000000, - 0x00000018, - 0x80000000, - 0x00000018, - 0x50000000, - 0x00000028, - 0x90000000, - 0x00000028, - 0xa0000000, - 0x00000028, - 0xb0000000, - 0x00000028, - 0xc0000000, - 0x00000028, - 0xd0000000, - 0x00000028, - 0xe0000000, - 0x00000028, - 0xf0000000, - 0x00000028, - 0x00000000, - 0x00000029, - 0x10000000, - 0x00000029, - 0x20000000, - 0x00000029, - 0x30000000, - 0x00000029, - 0x40000000, - 0x00000029, - 0x50000000, - 0x00000029, - 0x60000000, - 0x00000029, - 0x70000000, - 0x00000029, - 0x80000000, - 0x00000029, - 0x90000000, - 0x00000029, - 0xa0000000, - 0x00000029, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x10000000, - 0x00000000, - 0x00000000, - 0x00000008, - 0x10000000, - 0x00000008, - 0x00000000, - 0x00000010, - 0x10000000, - 0x00000010, - 0x00000000, - 0x00000018, - 0x10000000, - 0x00000018, - 0x20000000, - 0x00000018, - 0x30000000, - 0x00000018, - 0x40000000, - 0x00000018, - 0x50000000, - 0x00000018, - 0x60000000, - 0x00000018, - 0x70000000, - 0x00000018, - 0x80000000, - 0x00000018, - 0x50000000, - 0x00000028, - 0x90000000, - 0x00000028, - 0xa0000000, - 0x00000028, - 0xb0000000, - 0x00000028, - 0xc0000000, - 0x00000028, - 0xd0000000, - 0x00000028, - 0xe0000000, - 0x00000028, - 0xf0000000, - 0x00000028, - 0x00000000, - 0x00000029, - 0x10000000, - 0x00000029, - 0x20000000, - 0x00000029, - 0x30000000, - 0x00000029, - 0x40000000, - 0x00000029, - 0x50000000, - 0x00000029, - 0x60000000, - 0x00000029, - 0x70000000, - 0x00000029, - 0x80000000, - 0x00000029, - 0x90000000, - 0x00000029, - 0xa0000000, - 0x00000029, - 0xb0000000, - 0x00000029, - 0xc0000000, - 0x00000029, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -static const u32 dot11lcn_gain_tbl_2G[] = { - 0x00000000, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000d, - 0x0000004d, - 0x0000008d, - 0x00000049, - 0x00000089, - 0x000000c9, - 0x0000004b, - 0x0000008b, - 0x000000cb, - 0x000000cf, - 0x0000010f, - 0x0000050f, - 0x0000090f, - 0x0000094f, - 0x00000d4f, - 0x0000114f, - 0x0000118f, - 0x0000518f, - 0x0000918f, - 0x0000d18f, - 0x0001118f, - 0x0001518f, - 0x0001918f, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -static const u32 dot11lcn_gain_tbl_extlna_2G[] = { - 0x00000000, - 0x00000004, - 0x00000008, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000d, - 0x00000003, - 0x00000007, - 0x0000000b, - 0x0000000f, - 0x0000004f, - 0x0000008f, - 0x000000cf, - 0x0000010f, - 0x0000014f, - 0x0000018f, - 0x0000058f, - 0x0000098f, - 0x00000d8f, - 0x00008000, - 0x00008004, - 0x00008008, - 0x00008001, - 0x00008005, - 0x00008009, - 0x0000800d, - 0x00008003, - 0x00008007, - 0x0000800b, - 0x0000800f, - 0x0000804f, - 0x0000808f, - 0x000080cf, - 0x0000810f, - 0x0000814f, - 0x0000818f, - 0x0000858f, - 0x0000898f, - 0x00008d8f, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -static const u16 dot11lcn_aux_gain_idx_tbl_extlna_2G[] = { - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0400, - 0x0401, - 0x0402, - 0x0403, - 0x0404, - 0x0483, - 0x0484, - 0x0485, - 0x0486, - 0x0583, - 0x0584, - 0x0585, - 0x0587, - 0x0588, - 0x0589, - 0x058a, - 0x0687, - 0x0688, - 0x0689, - 0x068a, - 0x068b, - 0x068c, - 0x068d, - 0x068e, - 0x068f, - 0x0690, - 0x0691, - 0x0692, - 0x0693, - 0x0000 -}; - -static const u8 dot11lcn_gain_val_tbl_extlna_2G[] = { - 0xfc, - 0x02, - 0x08, - 0x0e, - 0x13, - 0x1b, - 0xfc, - 0x02, - 0x08, - 0x0e, - 0x13, - 0x1b, - 0xfc, - 0x00, - 0x0f, - 0x03, - 0xeb, - 0xfe, - 0x07, - 0x0b, - 0x0f, - 0xfb, - 0xfe, - 0x01, - 0x05, - 0x08, - 0x0b, - 0x0e, - 0x11, - 0x14, - 0x17, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x15, - 0x18, - 0x1b, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 -}; - -static const u32 dot11lcn_gain_idx_tbl_extlna_2G[] = { - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x00000000, - 0x00000040, - 0x10000000, - 0x00000040, - 0x20000000, - 0x00000040, - 0x30000000, - 0x00000040, - 0x40000000, - 0x00000040, - 0x30000000, - 0x00000048, - 0x40000000, - 0x00000048, - 0x50000000, - 0x00000048, - 0x60000000, - 0x00000048, - 0x30000000, - 0x00000058, - 0x40000000, - 0x00000058, - 0x50000000, - 0x00000058, - 0x70000000, - 0x00000058, - 0x80000000, - 0x00000058, - 0x90000000, - 0x00000058, - 0xa0000000, - 0x00000058, - 0x70000000, - 0x00000068, - 0x80000000, - 0x00000068, - 0x90000000, - 0x00000068, - 0xa0000000, - 0x00000068, - 0xb0000000, - 0x00000068, - 0xc0000000, - 0x00000068, - 0xd0000000, - 0x00000068, - 0xe0000000, - 0x00000068, - 0xf0000000, - 0x00000068, - 0x00000000, - 0x00000069, - 0x10000000, - 0x00000069, - 0x20000000, - 0x00000069, - 0x30000000, - 0x00000069, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x40000000, - 0x00000041, - 0x50000000, - 0x00000041, - 0x60000000, - 0x00000041, - 0x70000000, - 0x00000041, - 0x80000000, - 0x00000041, - 0x70000000, - 0x00000049, - 0x80000000, - 0x00000049, - 0x90000000, - 0x00000049, - 0xa0000000, - 0x00000049, - 0x70000000, - 0x00000059, - 0x80000000, - 0x00000059, - 0x90000000, - 0x00000059, - 0xb0000000, - 0x00000059, - 0xc0000000, - 0x00000059, - 0xd0000000, - 0x00000059, - 0xe0000000, - 0x00000059, - 0xb0000000, - 0x00000069, - 0xc0000000, - 0x00000069, - 0xd0000000, - 0x00000069, - 0xe0000000, - 0x00000069, - 0xf0000000, - 0x00000069, - 0x00000000, - 0x0000006a, - 0x10000000, - 0x0000006a, - 0x20000000, - 0x0000006a, - 0x30000000, - 0x0000006a, - 0x40000000, - 0x0000006a, - 0x50000000, - 0x0000006a, - 0x60000000, - 0x0000006a, - 0x70000000, - 0x0000006a, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -static const u32 dot11lcn_aux_gain_idx_tbl_5G[] = { - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0001, - 0x0002, - 0x0003, - 0x0004, - 0x0083, - 0x0084, - 0x0085, - 0x0086, - 0x0087, - 0x0186, - 0x0187, - 0x0188, - 0x0189, - 0x018a, - 0x018b, - 0x018c, - 0x018d, - 0x018e, - 0x018f, - 0x0190, - 0x0191, - 0x0192, - 0x0193, - 0x0194, - 0x0195, - 0x0196, - 0x0197, - 0x0198, - 0x0199, - 0x019a, - 0x019b, - 0x019c, - 0x019d, - 0x0000 -}; - -static const u32 dot11lcn_gain_val_tbl_5G[] = { - 0xf7, - 0xfd, - 0x00, - 0x04, - 0x04, - 0x04, - 0xf7, - 0xfd, - 0x00, - 0x04, - 0x04, - 0x04, - 0xf6, - 0x00, - 0x0c, - 0x03, - 0xeb, - 0xfe, - 0x06, - 0x0a, - 0x10, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x15, - 0x18, - 0x1b, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x15, - 0x18, - 0x1b, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 -}; - -static const u32 dot11lcn_gain_idx_tbl_5G[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x10000000, - 0x00000000, - 0x20000000, - 0x00000000, - 0x30000000, - 0x00000000, - 0x40000000, - 0x00000000, - 0x30000000, - 0x00000008, - 0x40000000, - 0x00000008, - 0x50000000, - 0x00000008, - 0x60000000, - 0x00000008, - 0x70000000, - 0x00000008, - 0x60000000, - 0x00000018, - 0x70000000, - 0x00000018, - 0x80000000, - 0x00000018, - 0x90000000, - 0x00000018, - 0xa0000000, - 0x00000018, - 0xb0000000, - 0x00000018, - 0xc0000000, - 0x00000018, - 0xd0000000, - 0x00000018, - 0xe0000000, - 0x00000018, - 0xf0000000, - 0x00000018, - 0x00000000, - 0x00000019, - 0x10000000, - 0x00000019, - 0x20000000, - 0x00000019, - 0x30000000, - 0x00000019, - 0x40000000, - 0x00000019, - 0x50000000, - 0x00000019, - 0x60000000, - 0x00000019, - 0x70000000, - 0x00000019, - 0x80000000, - 0x00000019, - 0x90000000, - 0x00000019, - 0xa0000000, - 0x00000019, - 0xb0000000, - 0x00000019, - 0xc0000000, - 0x00000019, - 0xd0000000, - 0x00000019, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -static const u32 dot11lcn_gain_tbl_5G[] = { - 0x00000000, - 0x00000040, - 0x00000080, - 0x00000001, - 0x00000005, - 0x00000009, - 0x0000000d, - 0x00000011, - 0x00000015, - 0x00000055, - 0x00000095, - 0x00000017, - 0x0000001b, - 0x0000005b, - 0x0000009b, - 0x000000db, - 0x0000011b, - 0x0000015b, - 0x0000019b, - 0x0000059b, - 0x0000099b, - 0x00000d9b, - 0x0000119b, - 0x0000519b, - 0x0000919b, - 0x0000d19b, - 0x0001119b, - 0x0001519b, - 0x0001919b, - 0x0001d19b, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 -}; - -const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[] = { - {&dot11lcn_gain_tbl_rev0, - sizeof(dot11lcn_gain_tbl_rev0) / sizeof(dot11lcn_gain_tbl_rev0[0]), 18, - 0, 32} - , - {&dot11lcn_aux_gain_idx_tbl_rev0, - sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / - sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_rev0, - sizeof(dot11lcn_gain_idx_tbl_rev0) / - sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} - , -}; - -static const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev1[] = { - {&dot11lcn_gain_tbl_rev1, - sizeof(dot11lcn_gain_tbl_rev1) / sizeof(dot11lcn_gain_tbl_rev1[0]), 18, - 0, 32} - , - {&dot11lcn_aux_gain_idx_tbl_rev0, - sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / - sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_rev0, - sizeof(dot11lcn_gain_idx_tbl_rev0) / - sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} - , -}; - -const struct phytbl_info dot11lcnphytbl_rx_gain_info_2G_rev2[] = { - {&dot11lcn_gain_tbl_2G, - sizeof(dot11lcn_gain_tbl_2G) / sizeof(dot11lcn_gain_tbl_2G[0]), 18, 0, - 32} - , - {&dot11lcn_aux_gain_idx_tbl_2G, - sizeof(dot11lcn_aux_gain_idx_tbl_2G) / - sizeof(dot11lcn_aux_gain_idx_tbl_2G[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_2G, - sizeof(dot11lcn_gain_idx_tbl_2G) / sizeof(dot11lcn_gain_idx_tbl_2G[0]), - 13, 0, 32} - , - {&dot11lcn_gain_val_tbl_2G, - sizeof(dot11lcn_gain_val_tbl_2G) / sizeof(dot11lcn_gain_val_tbl_2G[0]), - 17, 0, 8} -}; - -const struct phytbl_info dot11lcnphytbl_rx_gain_info_5G_rev2[] = { - {&dot11lcn_gain_tbl_5G, - sizeof(dot11lcn_gain_tbl_5G) / sizeof(dot11lcn_gain_tbl_5G[0]), 18, 0, - 32} - , - {&dot11lcn_aux_gain_idx_tbl_5G, - sizeof(dot11lcn_aux_gain_idx_tbl_5G) / - sizeof(dot11lcn_aux_gain_idx_tbl_5G[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_5G, - sizeof(dot11lcn_gain_idx_tbl_5G) / sizeof(dot11lcn_gain_idx_tbl_5G[0]), - 13, 0, 32} - , - {&dot11lcn_gain_val_tbl_5G, - sizeof(dot11lcn_gain_val_tbl_5G) / sizeof(dot11lcn_gain_val_tbl_5G[0]), - 17, 0, 8} -}; - -const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_2G_rev2[] = { - {&dot11lcn_gain_tbl_extlna_2G, - sizeof(dot11lcn_gain_tbl_extlna_2G) / - sizeof(dot11lcn_gain_tbl_extlna_2G[0]), 18, 0, 32} - , - {&dot11lcn_aux_gain_idx_tbl_extlna_2G, - sizeof(dot11lcn_aux_gain_idx_tbl_extlna_2G) / - sizeof(dot11lcn_aux_gain_idx_tbl_extlna_2G[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_extlna_2G, - sizeof(dot11lcn_gain_idx_tbl_extlna_2G) / - sizeof(dot11lcn_gain_idx_tbl_extlna_2G[0]), 13, 0, 32} - , - {&dot11lcn_gain_val_tbl_extlna_2G, - sizeof(dot11lcn_gain_val_tbl_extlna_2G) / - sizeof(dot11lcn_gain_val_tbl_extlna_2G[0]), 17, 0, 8} -}; - -const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_5G_rev2[] = { - {&dot11lcn_gain_tbl_5G, - sizeof(dot11lcn_gain_tbl_5G) / sizeof(dot11lcn_gain_tbl_5G[0]), 18, 0, - 32} - , - {&dot11lcn_aux_gain_idx_tbl_5G, - sizeof(dot11lcn_aux_gain_idx_tbl_5G) / - sizeof(dot11lcn_aux_gain_idx_tbl_5G[0]), 14, 0, 16} - , - {&dot11lcn_gain_idx_tbl_5G, - sizeof(dot11lcn_gain_idx_tbl_5G) / sizeof(dot11lcn_gain_idx_tbl_5G[0]), - 13, 0, 32} - , - {&dot11lcn_gain_val_tbl_5G, - sizeof(dot11lcn_gain_val_tbl_5G) / sizeof(dot11lcn_gain_val_tbl_5G[0]), - 17, 0, 8} -}; - -const u32 dot11lcnphytbl_rx_gain_info_sz_rev0 = - sizeof(dot11lcnphytbl_rx_gain_info_rev0) / - sizeof(dot11lcnphytbl_rx_gain_info_rev0[0]); - -const u32 dot11lcnphytbl_rx_gain_info_2G_rev2_sz = - sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2) / - sizeof(dot11lcnphytbl_rx_gain_info_2G_rev2[0]); - -const u32 dot11lcnphytbl_rx_gain_info_5G_rev2_sz = - sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2) / - sizeof(dot11lcnphytbl_rx_gain_info_5G_rev2[0]); - -static const u16 dot11lcn_min_sig_sq_tbl_rev0[] = { - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, - 0x014d, -}; - -static const u16 dot11lcn_noise_scale_tbl_rev0[] = { - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u32 dot11lcn_fltr_ctrl_tbl_rev0[] = { - 0x000141f8, - 0x000021f8, - 0x000021fb, - 0x000041fb, - 0x0001fe4b, - 0x0000217b, - 0x00002133, - 0x000040eb, - 0x0001fea3, - 0x0000024b, -}; - -static const u32 dot11lcn_ps_ctrl_tbl_rev0[] = { - 0x00100001, - 0x00200010, - 0x00300001, - 0x00400010, - 0x00500022, - 0x00600122, - 0x00700222, - 0x00800322, - 0x00900422, - 0x00a00522, - 0x00b00622, - 0x00c00722, - 0x00d00822, - 0x00f00922, - 0x00100a22, - 0x00200b22, - 0x00300c22, - 0x00400d22, - 0x00500e22, - 0x00600f22, -}; - -static const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[] = { - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x0007, - 0x0005, - 0x0006, - 0x0004, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - 0x000b, - 0x000b, - 0x000a, - 0x000a, - -}; - -static const u16 dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[] = { - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0005, - 0x0002, - 0x0000, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, - 0x0007, - 0x0007, - 0x0002, - 0x0002, -}; - -static const u16 dot11lcn_sw_ctrl_tbl_4313_epa_rev0[] = { - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, - 0x0002, - 0x0008, - 0x0004, - 0x0001, -}; - -static const u16 dot11lcn_sw_ctrl_tbl_4313_rev0[] = { - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, - 0x000a, - 0x0009, - 0x0006, - 0x0005, -}; - -static const u16 dot11lcn_sw_ctrl_tbl_rev0[] = { - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, - 0x0004, - 0x0004, - 0x0002, - 0x0002, -}; - -static const u8 dot11lcn_nf_table_rev0[] = { - 0x5f, - 0x36, - 0x29, - 0x1f, - 0x5f, - 0x36, - 0x29, - 0x1f, - 0x5f, - 0x36, - 0x29, - 0x1f, - 0x5f, - 0x36, - 0x29, - 0x1f, -}; - -static const u8 dot11lcn_gain_val_tbl_rev0[] = { - 0x09, - 0x0f, - 0x14, - 0x18, - 0xfe, - 0x07, - 0x0b, - 0x0f, - 0xfb, - 0xfe, - 0x01, - 0x05, - 0x08, - 0x0b, - 0x0e, - 0x11, - 0x14, - 0x17, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x06, - 0x09, - 0x0c, - 0x0f, - 0x12, - 0x15, - 0x18, - 0x1b, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0xeb, - 0x00, - 0x00, -}; - -static const u8 dot11lcn_spur_tbl_rev0[] = { - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x02, - 0x03, - 0x01, - 0x03, - 0x02, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x02, - 0x03, - 0x01, - 0x03, - 0x02, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, -}; - -static const u16 dot11lcn_unsup_mcs_tbl_rev0[] = { - 0x001a, - 0x0034, - 0x004e, - 0x0068, - 0x009c, - 0x00d0, - 0x00ea, - 0x0104, - 0x0034, - 0x0068, - 0x009c, - 0x00d0, - 0x0138, - 0x01a0, - 0x01d4, - 0x0208, - 0x004e, - 0x009c, - 0x00ea, - 0x0138, - 0x01d4, - 0x0270, - 0x02be, - 0x030c, - 0x0068, - 0x00d0, - 0x0138, - 0x01a0, - 0x0270, - 0x0340, - 0x03a8, - 0x0410, - 0x0018, - 0x009c, - 0x00d0, - 0x0104, - 0x00ea, - 0x0138, - 0x0186, - 0x00d0, - 0x0104, - 0x0104, - 0x0138, - 0x016c, - 0x016c, - 0x01a0, - 0x0138, - 0x0186, - 0x0186, - 0x01d4, - 0x0222, - 0x0222, - 0x0270, - 0x0104, - 0x0138, - 0x016c, - 0x0138, - 0x016c, - 0x01a0, - 0x01d4, - 0x01a0, - 0x01d4, - 0x0208, - 0x0208, - 0x023c, - 0x0186, - 0x01d4, - 0x0222, - 0x01d4, - 0x0222, - 0x0270, - 0x02be, - 0x0270, - 0x02be, - 0x030c, - 0x030c, - 0x035a, - 0x0036, - 0x006c, - 0x00a2, - 0x00d8, - 0x0144, - 0x01b0, - 0x01e6, - 0x021c, - 0x006c, - 0x00d8, - 0x0144, - 0x01b0, - 0x0288, - 0x0360, - 0x03cc, - 0x0438, - 0x00a2, - 0x0144, - 0x01e6, - 0x0288, - 0x03cc, - 0x0510, - 0x05b2, - 0x0654, - 0x00d8, - 0x01b0, - 0x0288, - 0x0360, - 0x0510, - 0x06c0, - 0x0798, - 0x0870, - 0x0018, - 0x0144, - 0x01b0, - 0x021c, - 0x01e6, - 0x0288, - 0x032a, - 0x01b0, - 0x021c, - 0x021c, - 0x0288, - 0x02f4, - 0x02f4, - 0x0360, - 0x0288, - 0x032a, - 0x032a, - 0x03cc, - 0x046e, - 0x046e, - 0x0510, - 0x021c, - 0x0288, - 0x02f4, - 0x0288, - 0x02f4, - 0x0360, - 0x03cc, - 0x0360, - 0x03cc, - 0x0438, - 0x0438, - 0x04a4, - 0x032a, - 0x03cc, - 0x046e, - 0x03cc, - 0x046e, - 0x0510, - 0x05b2, - 0x0510, - 0x05b2, - 0x0654, - 0x0654, - 0x06f6, -}; - -static const u16 dot11lcn_iq_local_tbl_rev0[] = { - 0x0200, - 0x0300, - 0x0400, - 0x0600, - 0x0800, - 0x0b00, - 0x1000, - 0x1001, - 0x1002, - 0x1003, - 0x1004, - 0x1005, - 0x1006, - 0x1007, - 0x1707, - 0x2007, - 0x2d07, - 0x4007, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0200, - 0x0300, - 0x0400, - 0x0600, - 0x0800, - 0x0b00, - 0x1000, - 0x1001, - 0x1002, - 0x1003, - 0x1004, - 0x1005, - 0x1006, - 0x1007, - 0x1707, - 0x2007, - 0x2d07, - 0x4007, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x4000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u32 dot11lcn_papd_compdelta_tbl_rev0[] = { - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, - 0x00080000, -}; - -const struct phytbl_info dot11lcnphytbl_info_rev0[] = { - {&dot11lcn_min_sig_sq_tbl_rev0, - sizeof(dot11lcn_min_sig_sq_tbl_rev0) / - sizeof(dot11lcn_min_sig_sq_tbl_rev0[0]), 2, 0, 16} - , - {&dot11lcn_noise_scale_tbl_rev0, - sizeof(dot11lcn_noise_scale_tbl_rev0) / - sizeof(dot11lcn_noise_scale_tbl_rev0[0]), 1, 0, 16} - , - {&dot11lcn_fltr_ctrl_tbl_rev0, - sizeof(dot11lcn_fltr_ctrl_tbl_rev0) / - sizeof(dot11lcn_fltr_ctrl_tbl_rev0[0]), 11, 0, 32} - , - {&dot11lcn_ps_ctrl_tbl_rev0, - sizeof(dot11lcn_ps_ctrl_tbl_rev0) / - sizeof(dot11lcn_ps_ctrl_tbl_rev0[0]), 12, 0, 32} - , - {&dot11lcn_gain_idx_tbl_rev0, - sizeof(dot11lcn_gain_idx_tbl_rev0) / - sizeof(dot11lcn_gain_idx_tbl_rev0[0]), 13, 0, 32} - , - {&dot11lcn_aux_gain_idx_tbl_rev0, - sizeof(dot11lcn_aux_gain_idx_tbl_rev0) / - sizeof(dot11lcn_aux_gain_idx_tbl_rev0[0]), 14, 0, 16} - , - {&dot11lcn_sw_ctrl_tbl_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_rev0[0]), 15, 0, 16} - , - {&dot11lcn_nf_table_rev0, - sizeof(dot11lcn_nf_table_rev0) / sizeof(dot11lcn_nf_table_rev0[0]), 16, - 0, 8} - , - {&dot11lcn_gain_val_tbl_rev0, - sizeof(dot11lcn_gain_val_tbl_rev0) / - sizeof(dot11lcn_gain_val_tbl_rev0[0]), 17, 0, 8} - , - {&dot11lcn_gain_tbl_rev0, - sizeof(dot11lcn_gain_tbl_rev0) / sizeof(dot11lcn_gain_tbl_rev0[0]), 18, - 0, 32} - , - {&dot11lcn_spur_tbl_rev0, - sizeof(dot11lcn_spur_tbl_rev0) / sizeof(dot11lcn_spur_tbl_rev0[0]), 20, - 0, 8} - , - {&dot11lcn_unsup_mcs_tbl_rev0, - sizeof(dot11lcn_unsup_mcs_tbl_rev0) / - sizeof(dot11lcn_unsup_mcs_tbl_rev0[0]), 23, 0, 16} - , - {&dot11lcn_iq_local_tbl_rev0, - sizeof(dot11lcn_iq_local_tbl_rev0) / - sizeof(dot11lcn_iq_local_tbl_rev0[0]), 0, 0, 16} - , - {&dot11lcn_papd_compdelta_tbl_rev0, - sizeof(dot11lcn_papd_compdelta_tbl_rev0) / - sizeof(dot11lcn_papd_compdelta_tbl_rev0[0]), 24, 0, 32} - , -}; - -const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313 = { - &dot11lcn_sw_ctrl_tbl_4313_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_rev0[0]), 15, 0, 16 -}; - -const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa = { - &dot11lcn_sw_ctrl_tbl_4313_epa_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0[0]), 15, 0, 16 -}; - -const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa = { - &dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo, - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_epa_rev0_combo[0]), 15, 0, 16 -}; - -const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250 = { - &dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0, - sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0) / - sizeof(dot11lcn_sw_ctrl_tbl_4313_bt_epa_p250_rev0[0]), 15, 0, 16 -}; - -const u32 dot11lcnphytbl_info_sz_rev0 = - sizeof(dot11lcnphytbl_info_rev0) / sizeof(dot11lcnphytbl_info_rev0[0]); - -const struct lcnphy_tx_gain_tbl_entry -dot11lcnphy_2GHz_extPA_gaintable_rev0[128] = { - {3, 0, 31, 0, 72}, - {3, 0, 31, 0, 70}, - {3, 0, 31, 0, 68}, - {3, 0, 30, 0, 67}, - {3, 0, 29, 0, 68}, - {3, 0, 28, 0, 68}, - {3, 0, 27, 0, 69}, - {3, 0, 26, 0, 70}, - {3, 0, 25, 0, 70}, - {3, 0, 24, 0, 71}, - {3, 0, 23, 0, 72}, - {3, 0, 23, 0, 70}, - {3, 0, 22, 0, 71}, - {3, 0, 21, 0, 72}, - {3, 0, 21, 0, 70}, - {3, 0, 21, 0, 68}, - {3, 0, 21, 0, 66}, - {3, 0, 21, 0, 64}, - {3, 0, 21, 0, 63}, - {3, 0, 20, 0, 64}, - {3, 0, 19, 0, 65}, - {3, 0, 19, 0, 64}, - {3, 0, 18, 0, 65}, - {3, 0, 18, 0, 64}, - {3, 0, 17, 0, 65}, - {3, 0, 17, 0, 64}, - {3, 0, 16, 0, 65}, - {3, 0, 16, 0, 64}, - {3, 0, 16, 0, 62}, - {3, 0, 16, 0, 60}, - {3, 0, 16, 0, 58}, - {3, 0, 15, 0, 61}, - {3, 0, 15, 0, 59}, - {3, 0, 14, 0, 61}, - {3, 0, 14, 0, 60}, - {3, 0, 14, 0, 58}, - {3, 0, 13, 0, 60}, - {3, 0, 13, 0, 59}, - {3, 0, 12, 0, 62}, - {3, 0, 12, 0, 60}, - {3, 0, 12, 0, 58}, - {3, 0, 11, 0, 62}, - {3, 0, 11, 0, 60}, - {3, 0, 11, 0, 59}, - {3, 0, 11, 0, 57}, - {3, 0, 10, 0, 61}, - {3, 0, 10, 0, 59}, - {3, 0, 10, 0, 57}, - {3, 0, 9, 0, 62}, - {3, 0, 9, 0, 60}, - {3, 0, 9, 0, 58}, - {3, 0, 9, 0, 57}, - {3, 0, 8, 0, 62}, - {3, 0, 8, 0, 60}, - {3, 0, 8, 0, 58}, - {3, 0, 8, 0, 57}, - {3, 0, 8, 0, 55}, - {3, 0, 7, 0, 61}, - {3, 0, 7, 0, 60}, - {3, 0, 7, 0, 58}, - {3, 0, 7, 0, 56}, - {3, 0, 7, 0, 55}, - {3, 0, 6, 0, 62}, - {3, 0, 6, 0, 60}, - {3, 0, 6, 0, 58}, - {3, 0, 6, 0, 57}, - {3, 0, 6, 0, 55}, - {3, 0, 6, 0, 54}, - {3, 0, 6, 0, 52}, - {3, 0, 5, 0, 61}, - {3, 0, 5, 0, 59}, - {3, 0, 5, 0, 57}, - {3, 0, 5, 0, 56}, - {3, 0, 5, 0, 54}, - {3, 0, 5, 0, 53}, - {3, 0, 5, 0, 51}, - {3, 0, 4, 0, 62}, - {3, 0, 4, 0, 60}, - {3, 0, 4, 0, 58}, - {3, 0, 4, 0, 57}, - {3, 0, 4, 0, 55}, - {3, 0, 4, 0, 54}, - {3, 0, 4, 0, 52}, - {3, 0, 4, 0, 51}, - {3, 0, 4, 0, 49}, - {3, 0, 4, 0, 48}, - {3, 0, 4, 0, 46}, - {3, 0, 3, 0, 60}, - {3, 0, 3, 0, 58}, - {3, 0, 3, 0, 57}, - {3, 0, 3, 0, 55}, - {3, 0, 3, 0, 54}, - {3, 0, 3, 0, 52}, - {3, 0, 3, 0, 51}, - {3, 0, 3, 0, 49}, - {3, 0, 3, 0, 48}, - {3, 0, 3, 0, 46}, - {3, 0, 3, 0, 45}, - {3, 0, 3, 0, 44}, - {3, 0, 3, 0, 43}, - {3, 0, 3, 0, 41}, - {3, 0, 2, 0, 61}, - {3, 0, 2, 0, 59}, - {3, 0, 2, 0, 57}, - {3, 0, 2, 0, 56}, - {3, 0, 2, 0, 54}, - {3, 0, 2, 0, 53}, - {3, 0, 2, 0, 51}, - {3, 0, 2, 0, 50}, - {3, 0, 2, 0, 48}, - {3, 0, 2, 0, 47}, - {3, 0, 2, 0, 46}, - {3, 0, 2, 0, 44}, - {3, 0, 2, 0, 43}, - {3, 0, 2, 0, 42}, - {3, 0, 2, 0, 41}, - {3, 0, 2, 0, 39}, - {3, 0, 2, 0, 38}, - {3, 0, 2, 0, 37}, - {3, 0, 2, 0, 36}, - {3, 0, 2, 0, 35}, - {3, 0, 2, 0, 34}, - {3, 0, 2, 0, 33}, - {3, 0, 2, 0, 32}, - {3, 0, 1, 0, 63}, - {3, 0, 1, 0, 61}, - {3, 0, 1, 0, 59}, - {3, 0, 1, 0, 57}, -}; - -const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_gaintable_rev0[128] = { - {7, 0, 31, 0, 72}, - {7, 0, 31, 0, 70}, - {7, 0, 31, 0, 68}, - {7, 0, 30, 0, 67}, - {7, 0, 29, 0, 68}, - {7, 0, 28, 0, 68}, - {7, 0, 27, 0, 69}, - {7, 0, 26, 0, 70}, - {7, 0, 25, 0, 70}, - {7, 0, 24, 0, 71}, - {7, 0, 23, 0, 72}, - {7, 0, 23, 0, 70}, - {7, 0, 22, 0, 71}, - {7, 0, 21, 0, 72}, - {7, 0, 21, 0, 70}, - {7, 0, 21, 0, 68}, - {7, 0, 21, 0, 66}, - {7, 0, 21, 0, 64}, - {7, 0, 21, 0, 63}, - {7, 0, 20, 0, 64}, - {7, 0, 19, 0, 65}, - {7, 0, 19, 0, 64}, - {7, 0, 18, 0, 65}, - {7, 0, 18, 0, 64}, - {7, 0, 17, 0, 65}, - {7, 0, 17, 0, 64}, - {7, 0, 16, 0, 65}, - {7, 0, 16, 0, 64}, - {7, 0, 16, 0, 62}, - {7, 0, 16, 0, 60}, - {7, 0, 16, 0, 58}, - {7, 0, 15, 0, 61}, - {7, 0, 15, 0, 59}, - {7, 0, 14, 0, 61}, - {7, 0, 14, 0, 60}, - {7, 0, 14, 0, 58}, - {7, 0, 13, 0, 60}, - {7, 0, 13, 0, 59}, - {7, 0, 12, 0, 62}, - {7, 0, 12, 0, 60}, - {7, 0, 12, 0, 58}, - {7, 0, 11, 0, 62}, - {7, 0, 11, 0, 60}, - {7, 0, 11, 0, 59}, - {7, 0, 11, 0, 57}, - {7, 0, 10, 0, 61}, - {7, 0, 10, 0, 59}, - {7, 0, 10, 0, 57}, - {7, 0, 9, 0, 62}, - {7, 0, 9, 0, 60}, - {7, 0, 9, 0, 58}, - {7, 0, 9, 0, 57}, - {7, 0, 8, 0, 62}, - {7, 0, 8, 0, 60}, - {7, 0, 8, 0, 58}, - {7, 0, 8, 0, 57}, - {7, 0, 8, 0, 55}, - {7, 0, 7, 0, 61}, - {7, 0, 7, 0, 60}, - {7, 0, 7, 0, 58}, - {7, 0, 7, 0, 56}, - {7, 0, 7, 0, 55}, - {7, 0, 6, 0, 62}, - {7, 0, 6, 0, 60}, - {7, 0, 6, 0, 58}, - {7, 0, 6, 0, 57}, - {7, 0, 6, 0, 55}, - {7, 0, 6, 0, 54}, - {7, 0, 6, 0, 52}, - {7, 0, 5, 0, 61}, - {7, 0, 5, 0, 59}, - {7, 0, 5, 0, 57}, - {7, 0, 5, 0, 56}, - {7, 0, 5, 0, 54}, - {7, 0, 5, 0, 53}, - {7, 0, 5, 0, 51}, - {7, 0, 4, 0, 62}, - {7, 0, 4, 0, 60}, - {7, 0, 4, 0, 58}, - {7, 0, 4, 0, 57}, - {7, 0, 4, 0, 55}, - {7, 0, 4, 0, 54}, - {7, 0, 4, 0, 52}, - {7, 0, 4, 0, 51}, - {7, 0, 4, 0, 49}, - {7, 0, 4, 0, 48}, - {7, 0, 4, 0, 46}, - {7, 0, 3, 0, 60}, - {7, 0, 3, 0, 58}, - {7, 0, 3, 0, 57}, - {7, 0, 3, 0, 55}, - {7, 0, 3, 0, 54}, - {7, 0, 3, 0, 52}, - {7, 0, 3, 0, 51}, - {7, 0, 3, 0, 49}, - {7, 0, 3, 0, 48}, - {7, 0, 3, 0, 46}, - {7, 0, 3, 0, 45}, - {7, 0, 3, 0, 44}, - {7, 0, 3, 0, 43}, - {7, 0, 3, 0, 41}, - {7, 0, 2, 0, 61}, - {7, 0, 2, 0, 59}, - {7, 0, 2, 0, 57}, - {7, 0, 2, 0, 56}, - {7, 0, 2, 0, 54}, - {7, 0, 2, 0, 53}, - {7, 0, 2, 0, 51}, - {7, 0, 2, 0, 50}, - {7, 0, 2, 0, 48}, - {7, 0, 2, 0, 47}, - {7, 0, 2, 0, 46}, - {7, 0, 2, 0, 44}, - {7, 0, 2, 0, 43}, - {7, 0, 2, 0, 42}, - {7, 0, 2, 0, 41}, - {7, 0, 2, 0, 39}, - {7, 0, 2, 0, 38}, - {7, 0, 2, 0, 37}, - {7, 0, 2, 0, 36}, - {7, 0, 2, 0, 35}, - {7, 0, 2, 0, 34}, - {7, 0, 2, 0, 33}, - {7, 0, 2, 0, 32}, - {7, 0, 1, 0, 63}, - {7, 0, 1, 0, 61}, - {7, 0, 1, 0, 59}, - {7, 0, 1, 0, 57}, -}; - -const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_5GHz_gaintable_rev0[128] = { - {255, 255, 0xf0, 0, 152}, - {255, 255, 0xf0, 0, 147}, - {255, 255, 0xf0, 0, 143}, - {255, 255, 0xf0, 0, 139}, - {255, 255, 0xf0, 0, 135}, - {255, 255, 0xf0, 0, 131}, - {255, 255, 0xf0, 0, 128}, - {255, 255, 0xf0, 0, 124}, - {255, 255, 0xf0, 0, 121}, - {255, 255, 0xf0, 0, 117}, - {255, 255, 0xf0, 0, 114}, - {255, 255, 0xf0, 0, 111}, - {255, 255, 0xf0, 0, 107}, - {255, 255, 0xf0, 0, 104}, - {255, 255, 0xf0, 0, 101}, - {255, 255, 0xf0, 0, 99}, - {255, 255, 0xf0, 0, 96}, - {255, 255, 0xf0, 0, 93}, - {255, 255, 0xf0, 0, 90}, - {255, 255, 0xf0, 0, 88}, - {255, 255, 0xf0, 0, 85}, - {255, 255, 0xf0, 0, 83}, - {255, 255, 0xf0, 0, 81}, - {255, 255, 0xf0, 0, 78}, - {255, 255, 0xf0, 0, 76}, - {255, 255, 0xf0, 0, 74}, - {255, 255, 0xf0, 0, 72}, - {255, 255, 0xf0, 0, 70}, - {255, 255, 0xf0, 0, 68}, - {255, 255, 0xf0, 0, 66}, - {255, 255, 0xf0, 0, 64}, - {255, 248, 0xf0, 0, 64}, - {255, 241, 0xf0, 0, 64}, - {255, 251, 0xe0, 0, 64}, - {255, 244, 0xe0, 0, 64}, - {255, 254, 0xd0, 0, 64}, - {255, 246, 0xd0, 0, 64}, - {255, 239, 0xd0, 0, 64}, - {255, 249, 0xc0, 0, 64}, - {255, 242, 0xc0, 0, 64}, - {255, 255, 0xb0, 0, 64}, - {255, 248, 0xb0, 0, 64}, - {255, 241, 0xb0, 0, 64}, - {255, 254, 0xa0, 0, 64}, - {255, 246, 0xa0, 0, 64}, - {255, 239, 0xa0, 0, 64}, - {255, 255, 0x90, 0, 64}, - {255, 248, 0x90, 0, 64}, - {255, 241, 0x90, 0, 64}, - {255, 234, 0x90, 0, 64}, - {255, 255, 0x80, 0, 64}, - {255, 248, 0x80, 0, 64}, - {255, 241, 0x80, 0, 64}, - {255, 234, 0x80, 0, 64}, - {255, 255, 0x70, 0, 64}, - {255, 248, 0x70, 0, 64}, - {255, 241, 0x70, 0, 64}, - {255, 234, 0x70, 0, 64}, - {255, 227, 0x70, 0, 64}, - {255, 221, 0x70, 0, 64}, - {255, 215, 0x70, 0, 64}, - {255, 208, 0x70, 0, 64}, - {255, 203, 0x70, 0, 64}, - {255, 197, 0x70, 0, 64}, - {255, 255, 0x60, 0, 64}, - {255, 248, 0x60, 0, 64}, - {255, 241, 0x60, 0, 64}, - {255, 234, 0x60, 0, 64}, - {255, 227, 0x60, 0, 64}, - {255, 221, 0x60, 0, 64}, - {255, 255, 0x50, 0, 64}, - {255, 248, 0x50, 0, 64}, - {255, 241, 0x50, 0, 64}, - {255, 234, 0x50, 0, 64}, - {255, 227, 0x50, 0, 64}, - {255, 221, 0x50, 0, 64}, - {255, 215, 0x50, 0, 64}, - {255, 208, 0x50, 0, 64}, - {255, 255, 0x40, 0, 64}, - {255, 248, 0x40, 0, 64}, - {255, 241, 0x40, 0, 64}, - {255, 234, 0x40, 0, 64}, - {255, 227, 0x40, 0, 64}, - {255, 221, 0x40, 0, 64}, - {255, 215, 0x40, 0, 64}, - {255, 208, 0x40, 0, 64}, - {255, 203, 0x40, 0, 64}, - {255, 197, 0x40, 0, 64}, - {255, 255, 0x30, 0, 64}, - {255, 248, 0x30, 0, 64}, - {255, 241, 0x30, 0, 64}, - {255, 234, 0x30, 0, 64}, - {255, 227, 0x30, 0, 64}, - {255, 221, 0x30, 0, 64}, - {255, 215, 0x30, 0, 64}, - {255, 208, 0x30, 0, 64}, - {255, 203, 0x30, 0, 64}, - {255, 197, 0x30, 0, 64}, - {255, 191, 0x30, 0, 64}, - {255, 186, 0x30, 0, 64}, - {255, 181, 0x30, 0, 64}, - {255, 175, 0x30, 0, 64}, - {255, 255, 0x20, 0, 64}, - {255, 248, 0x20, 0, 64}, - {255, 241, 0x20, 0, 64}, - {255, 234, 0x20, 0, 64}, - {255, 227, 0x20, 0, 64}, - {255, 221, 0x20, 0, 64}, - {255, 215, 0x20, 0, 64}, - {255, 208, 0x20, 0, 64}, - {255, 203, 0x20, 0, 64}, - {255, 197, 0x20, 0, 64}, - {255, 191, 0x20, 0, 64}, - {255, 186, 0x20, 0, 64}, - {255, 181, 0x20, 0, 64}, - {255, 175, 0x20, 0, 64}, - {255, 170, 0x20, 0, 64}, - {255, 166, 0x20, 0, 64}, - {255, 161, 0x20, 0, 64}, - {255, 156, 0x20, 0, 64}, - {255, 152, 0x20, 0, 64}, - {255, 148, 0x20, 0, 64}, - {255, 143, 0x20, 0, 64}, - {255, 139, 0x20, 0, 64}, - {255, 135, 0x20, 0, 64}, - {255, 132, 0x20, 0, 64}, - {255, 255, 0x10, 0, 64}, - {255, 248, 0x10, 0, 64}, -}; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.h b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.h deleted file mode 100644 index 5f75e16bf5a..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include "phy_int.h" - -extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_rev0[]; -extern const u32 dot11lcnphytbl_rx_gain_info_sz_rev0; -extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313; -extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa; -extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_epa_combo; -extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa; -extern const struct phytbl_info dot11lcn_sw_ctrl_tbl_info_4313_bt_epa_p250; - -extern const struct phytbl_info dot11lcnphytbl_info_rev0[]; -extern const u32 dot11lcnphytbl_info_sz_rev0; - -extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_2G_rev2[]; -extern const u32 dot11lcnphytbl_rx_gain_info_2G_rev2_sz; - -extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_5G_rev2[]; -extern const u32 dot11lcnphytbl_rx_gain_info_5G_rev2_sz; - -extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_2G_rev2[]; - -extern const struct phytbl_info dot11lcnphytbl_rx_gain_info_extlna_5G_rev2[]; - -struct lcnphy_tx_gain_tbl_entry { - unsigned char gm; - unsigned char pga; - unsigned char pad; - unsigned char dac; - unsigned char bb_mult; -}; - -extern const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_gaintable_rev0[]; - -extern const struct -lcnphy_tx_gain_tbl_entry dot11lcnphy_2GHz_extPA_gaintable_rev0[]; - -extern const struct lcnphy_tx_gain_tbl_entry dot11lcnphy_5GHz_gaintable_rev0[]; diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c deleted file mode 100644 index dbf50ef6cd7..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c +++ /dev/null @@ -1,10630 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include "phytbl_n.h" - -static const u32 frame_struct_rev0[] = { - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x09804506, - 0x00100030, - 0x09804507, - 0x00100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a0c, - 0x00100004, - 0x01000a0d, - 0x00100024, - 0x0980450e, - 0x00100034, - 0x0980450f, - 0x00100034, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a04, - 0x00100000, - 0x11008a05, - 0x00100020, - 0x1980c506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x01800504, - 0x00100030, - 0x11808505, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000a04, - 0x00100000, - 0x11008a05, - 0x00100020, - 0x21810506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x1980c50e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x0180050c, - 0x00100038, - 0x1180850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x1980c506, - 0x00100030, - 0x1980c506, - 0x00100030, - 0x11808504, - 0x00100030, - 0x3981ca05, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x10008a04, - 0x00100000, - 0x3981ca05, - 0x00100030, - 0x1980c506, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a0c, - 0x00100008, - 0x01000a0d, - 0x00100028, - 0x1980c50e, - 0x00100038, - 0x1980c50e, - 0x00100038, - 0x1180850c, - 0x00100038, - 0x3981ca0d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x10008a0c, - 0x00100008, - 0x3981ca0d, - 0x00100038, - 0x1980c50e, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x02001405, - 0x00100040, - 0x0b004a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x43020a04, - 0x00100060, - 0x1b00ca05, - 0x00100060, - 0x23010a07, - 0x01500060, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x13008a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x0200140d, - 0x00100050, - 0x0b004a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x50029404, - 0x00100000, - 0x32019405, - 0x00100040, - 0x0b004a06, - 0x01900060, - 0x0b004a06, - 0x01900060, - 0x5b02ca04, - 0x00100060, - 0x3b01d405, - 0x00100060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x5802d404, - 0x00100000, - 0x3b01d405, - 0x00100060, - 0x0b004a06, - 0x01900060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x5002940c, - 0x00100010, - 0x3201940d, - 0x00100050, - 0x0b004a0e, - 0x01900070, - 0x0b004a0e, - 0x01900070, - 0x5b02ca0c, - 0x00100070, - 0x3b01d40d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x5802d40c, - 0x00100010, - 0x3b01d40d, - 0x00100070, - 0x0b004a0e, - 0x01900070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x000f4800, - 0x62031405, - 0x00100040, - 0x53028a06, - 0x01900060, - 0x53028a07, - 0x01900060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x000f4808, - 0x6203140d, - 0x00100048, - 0x53028a0e, - 0x01900068, - 0x53028a0f, - 0x01900068, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100004, - 0x11008a0d, - 0x00100024, - 0x1980c50e, - 0x00100034, - 0x2181050e, - 0x00100034, - 0x2181050e, - 0x00100034, - 0x0180050c, - 0x00100038, - 0x1180850d, - 0x00100038, - 0x1181850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x1181850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x0180c506, - 0x00100030, - 0x0180c506, - 0x00100030, - 0x2180c50c, - 0x00100030, - 0x49820a0d, - 0x0016a130, - 0x41824a0d, - 0x0016a130, - 0x2981450f, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x2000ca0c, - 0x00100000, - 0x49820a0d, - 0x0016a130, - 0x1980c50e, - 0x00100030, - 0x41824a0d, - 0x0016a130, - 0x2981450f, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100008, - 0x0200140d, - 0x00100048, - 0x0b004a0e, - 0x01900068, - 0x13008a0e, - 0x01900068, - 0x13008a0e, - 0x01900068, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x1b014a0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x1b014a0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x50029404, - 0x00100000, - 0x32019405, - 0x00100040, - 0x03004a06, - 0x01900060, - 0x03004a06, - 0x01900060, - 0x6b030a0c, - 0x00100060, - 0x4b02140d, - 0x0016a160, - 0x4302540d, - 0x0016a160, - 0x23010a0f, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x6b03140c, - 0x00100060, - 0x4b02140d, - 0x0016a160, - 0x0b004a0e, - 0x01900060, - 0x4302540d, - 0x0016a160, - 0x23010a0f, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x53028a06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x43020a04, - 0x00100060, - 0x1b00ca05, - 0x00100060, - 0x53028a07, - 0x0190c060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x53028a0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x53028a0f, - 0x0190c070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x5b02ca06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x53028a07, - 0x0190c060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x5b02ca0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x53028a0f, - 0x0190c070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u8 frame_lut_rev0[] = { - 0x02, - 0x04, - 0x14, - 0x14, - 0x03, - 0x05, - 0x16, - 0x16, - 0x0a, - 0x0c, - 0x1c, - 0x1c, - 0x0b, - 0x0d, - 0x1e, - 0x1e, - 0x06, - 0x08, - 0x18, - 0x18, - 0x07, - 0x09, - 0x1a, - 0x1a, - 0x0e, - 0x10, - 0x20, - 0x28, - 0x0f, - 0x11, - 0x22, - 0x2a, -}; - -static const u32 tmap_tbl_rev0[] = { - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x000aa888, - 0x88880000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00011111, - 0x11110000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00088aaa, - 0xaaaa0000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xaaa8aaa0, - 0x8aaa8aaa, - 0xaa8a8a8a, - 0x000aaa88, - 0x8aaa0000, - 0xaaa8a888, - 0x8aa88a8a, - 0x8a88a888, - 0x08080a00, - 0x0a08080a, - 0x080a0a08, - 0x00080808, - 0x080a0000, - 0x080a0808, - 0x080a0808, - 0x0a0a0a08, - 0xa0a0a0a0, - 0x80a0a080, - 0x8080a0a0, - 0x00008080, - 0x80a00000, - 0x80a080a0, - 0xa080a0a0, - 0x8080a0a0, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x99999000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x22000000, - 0x2222b222, - 0x22222222, - 0x222222b2, - 0xb2222220, - 0x22222222, - 0x22d22222, - 0x00000222, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x33000000, - 0x3333b333, - 0x33333333, - 0x333333b3, - 0xb3333330, - 0x33333333, - 0x33d33333, - 0x00000333, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x99b99b00, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb99, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x22222200, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0x22222222, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x11111111, - 0xf1111111, - 0x11111111, - 0x11f11111, - 0x01111111, - 0xbb9bb900, - 0xb9b9bb99, - 0xb99bbbbb, - 0xbbbb9b9b, - 0xb9bb99bb, - 0xb99999b9, - 0xb9b9b99b, - 0x00000bbb, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88aa, - 0xa88888a8, - 0xa8a8a88a, - 0x0a888aaa, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00000aaa, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0xbbbbbb00, - 0x999bbbbb, - 0x9bb99b9b, - 0xb9b9b9bb, - 0xb9b99bbb, - 0xb9b9b9bb, - 0xb9bb9b99, - 0x00000999, - 0x8a000000, - 0xaa88a888, - 0xa88888aa, - 0xa88a8a88, - 0xa88aa88a, - 0x88a8aaaa, - 0xa8aa8aaa, - 0x0888a88a, - 0x0b0b0b00, - 0x090b0b0b, - 0x0b090b0b, - 0x0909090b, - 0x09090b0b, - 0x09090b0b, - 0x09090b09, - 0x00000909, - 0x0a000000, - 0x0a080808, - 0x080a080a, - 0x080a0a08, - 0x080a080a, - 0x0808080a, - 0x0a0a0a08, - 0x0808080a, - 0xb0b0b000, - 0x9090b0b0, - 0x90b09090, - 0xb0b0b090, - 0xb0b090b0, - 0x90b0b0b0, - 0xb0b09090, - 0x00000090, - 0x80000000, - 0xa080a080, - 0xa08080a0, - 0xa0808080, - 0xa080a080, - 0x80a0a0a0, - 0xa0a080a0, - 0x00a0a0a0, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x33000000, - 0x3333f333, - 0x33333333, - 0x333333f3, - 0xf3333330, - 0x33333333, - 0x33f33333, - 0x00000333, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x99000000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88888000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x88a88a00, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 tdtrn_tbl_rev0[] = { - 0x061c061c, - 0x0050ee68, - 0xf592fe36, - 0xfe5212f6, - 0x00000c38, - 0xfe5212f6, - 0xf592fe36, - 0x0050ee68, - 0x061c061c, - 0xee680050, - 0xfe36f592, - 0x12f6fe52, - 0x0c380000, - 0x12f6fe52, - 0xfe36f592, - 0xee680050, - 0x061c061c, - 0x0050ee68, - 0xf592fe36, - 0xfe5212f6, - 0x00000c38, - 0xfe5212f6, - 0xf592fe36, - 0x0050ee68, - 0x061c061c, - 0xee680050, - 0xfe36f592, - 0x12f6fe52, - 0x0c380000, - 0x12f6fe52, - 0xfe36f592, - 0xee680050, - 0x05e305e3, - 0x004def0c, - 0xf5f3fe47, - 0xfe611246, - 0x00000bc7, - 0xfe611246, - 0xf5f3fe47, - 0x004def0c, - 0x05e305e3, - 0xef0c004d, - 0xfe47f5f3, - 0x1246fe61, - 0x0bc70000, - 0x1246fe61, - 0xfe47f5f3, - 0xef0c004d, - 0x05e305e3, - 0x004def0c, - 0xf5f3fe47, - 0xfe611246, - 0x00000bc7, - 0xfe611246, - 0xf5f3fe47, - 0x004def0c, - 0x05e305e3, - 0xef0c004d, - 0xfe47f5f3, - 0x1246fe61, - 0x0bc70000, - 0x1246fe61, - 0xfe47f5f3, - 0xef0c004d, - 0xfa58fa58, - 0xf895043b, - 0xff4c09c0, - 0xfbc6ffa8, - 0xfb84f384, - 0x0798f6f9, - 0x05760122, - 0x058409f6, - 0x0b500000, - 0x05b7f542, - 0x08860432, - 0x06ddfee7, - 0xfb84f384, - 0xf9d90664, - 0xf7e8025c, - 0x00fff7bd, - 0x05a805a8, - 0xf7bd00ff, - 0x025cf7e8, - 0x0664f9d9, - 0xf384fb84, - 0xfee706dd, - 0x04320886, - 0xf54205b7, - 0x00000b50, - 0x09f60584, - 0x01220576, - 0xf6f90798, - 0xf384fb84, - 0xffa8fbc6, - 0x09c0ff4c, - 0x043bf895, - 0x02d402d4, - 0x07de0270, - 0xfc96079c, - 0xf90afe94, - 0xfe00ff2c, - 0x02d4065d, - 0x092a0096, - 0x0014fbb8, - 0xfd2cfd2c, - 0x076afb3c, - 0x0096f752, - 0xf991fd87, - 0xfb2c0200, - 0xfeb8f960, - 0x08e0fc96, - 0x049802a8, - 0xfd2cfd2c, - 0x02a80498, - 0xfc9608e0, - 0xf960feb8, - 0x0200fb2c, - 0xfd87f991, - 0xf7520096, - 0xfb3c076a, - 0xfd2cfd2c, - 0xfbb80014, - 0x0096092a, - 0x065d02d4, - 0xff2cfe00, - 0xfe94f90a, - 0x079cfc96, - 0x027007de, - 0x02d402d4, - 0x027007de, - 0x079cfc96, - 0xfe94f90a, - 0xff2cfe00, - 0x065d02d4, - 0x0096092a, - 0xfbb80014, - 0xfd2cfd2c, - 0xfb3c076a, - 0xf7520096, - 0xfd87f991, - 0x0200fb2c, - 0xf960feb8, - 0xfc9608e0, - 0x02a80498, - 0xfd2cfd2c, - 0x049802a8, - 0x08e0fc96, - 0xfeb8f960, - 0xfb2c0200, - 0xf991fd87, - 0x0096f752, - 0x076afb3c, - 0xfd2cfd2c, - 0x0014fbb8, - 0x092a0096, - 0x02d4065d, - 0xfe00ff2c, - 0xf90afe94, - 0xfc96079c, - 0x07de0270, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x062a0000, - 0xfefa0759, - 0x08b80908, - 0xf396fc2d, - 0xf9d6045c, - 0xfc4ef608, - 0xf748f596, - 0x07b207bf, - 0x062a062a, - 0xf84ef841, - 0xf748f596, - 0x03b209f8, - 0xf9d6045c, - 0x0c6a03d3, - 0x08b80908, - 0x0106f8a7, - 0x062a0000, - 0xfefaf8a7, - 0x08b8f6f8, - 0xf39603d3, - 0xf9d6fba4, - 0xfc4e09f8, - 0xf7480a6a, - 0x07b2f841, - 0x062af9d6, - 0xf84e07bf, - 0xf7480a6a, - 0x03b2f608, - 0xf9d6fba4, - 0x0c6afc2d, - 0x08b8f6f8, - 0x01060759, - 0x062a0000, - 0xfefa0759, - 0x08b80908, - 0xf396fc2d, - 0xf9d6045c, - 0xfc4ef608, - 0xf748f596, - 0x07b207bf, - 0x062a062a, - 0xf84ef841, - 0xf748f596, - 0x03b209f8, - 0xf9d6045c, - 0x0c6a03d3, - 0x08b80908, - 0x0106f8a7, - 0x062a0000, - 0xfefaf8a7, - 0x08b8f6f8, - 0xf39603d3, - 0xf9d6fba4, - 0xfc4e09f8, - 0xf7480a6a, - 0x07b2f841, - 0x062af9d6, - 0xf84e07bf, - 0xf7480a6a, - 0x03b2f608, - 0xf9d6fba4, - 0x0c6afc2d, - 0x08b8f6f8, - 0x01060759, - 0x061c061c, - 0xff30009d, - 0xffb21141, - 0xfd87fb54, - 0xf65dfe59, - 0x02eef99e, - 0x0166f03c, - 0xfff809b6, - 0x000008a4, - 0x000af42b, - 0x00eff577, - 0xfa840bf2, - 0xfc02ff51, - 0x08260f67, - 0xfff0036f, - 0x0842f9c3, - 0x00000000, - 0x063df7be, - 0xfc910010, - 0xf099f7da, - 0x00af03fe, - 0xf40e057c, - 0x0a89ff11, - 0x0bd5fff6, - 0xf75c0000, - 0xf64a0008, - 0x0fc4fe9a, - 0x0662fd12, - 0x01a709a3, - 0x04ac0279, - 0xeebf004e, - 0xff6300d0, - 0xf9e4f9e4, - 0x00d0ff63, - 0x004eeebf, - 0x027904ac, - 0x09a301a7, - 0xfd120662, - 0xfe9a0fc4, - 0x0008f64a, - 0x0000f75c, - 0xfff60bd5, - 0xff110a89, - 0x057cf40e, - 0x03fe00af, - 0xf7daf099, - 0x0010fc91, - 0xf7be063d, - 0x00000000, - 0xf9c30842, - 0x036ffff0, - 0x0f670826, - 0xff51fc02, - 0x0bf2fa84, - 0xf57700ef, - 0xf42b000a, - 0x08a40000, - 0x09b6fff8, - 0xf03c0166, - 0xf99e02ee, - 0xfe59f65d, - 0xfb54fd87, - 0x1141ffb2, - 0x009dff30, - 0x05e30000, - 0xff060705, - 0x085408a0, - 0xf425fc59, - 0xfa1d042a, - 0xfc78f67a, - 0xf7acf60e, - 0x075a0766, - 0x05e305e3, - 0xf8a6f89a, - 0xf7acf60e, - 0x03880986, - 0xfa1d042a, - 0x0bdb03a7, - 0x085408a0, - 0x00faf8fb, - 0x05e30000, - 0xff06f8fb, - 0x0854f760, - 0xf42503a7, - 0xfa1dfbd6, - 0xfc780986, - 0xf7ac09f2, - 0x075af89a, - 0x05e3fa1d, - 0xf8a60766, - 0xf7ac09f2, - 0x0388f67a, - 0xfa1dfbd6, - 0x0bdbfc59, - 0x0854f760, - 0x00fa0705, - 0x05e30000, - 0xff060705, - 0x085408a0, - 0xf425fc59, - 0xfa1d042a, - 0xfc78f67a, - 0xf7acf60e, - 0x075a0766, - 0x05e305e3, - 0xf8a6f89a, - 0xf7acf60e, - 0x03880986, - 0xfa1d042a, - 0x0bdb03a7, - 0x085408a0, - 0x00faf8fb, - 0x05e30000, - 0xff06f8fb, - 0x0854f760, - 0xf42503a7, - 0xfa1dfbd6, - 0xfc780986, - 0xf7ac09f2, - 0x075af89a, - 0x05e3fa1d, - 0xf8a60766, - 0xf7ac09f2, - 0x0388f67a, - 0xfa1dfbd6, - 0x0bdbfc59, - 0x0854f760, - 0x00fa0705, - 0xfa58fa58, - 0xf8f0fe00, - 0x0448073d, - 0xfdc9fe46, - 0xf9910258, - 0x089d0407, - 0xfd5cf71a, - 0x02affde0, - 0x083e0496, - 0xff5a0740, - 0xff7afd97, - 0x00fe01f1, - 0x0009082e, - 0xfa94ff75, - 0xfecdf8ea, - 0xffb0f693, - 0xfd2cfa58, - 0x0433ff16, - 0xfba405dd, - 0xfa610341, - 0x06a606cb, - 0x0039fd2d, - 0x0677fa97, - 0x01fa05e0, - 0xf896003e, - 0x075a068b, - 0x012cfc3e, - 0xfa23f98d, - 0xfc7cfd43, - 0xff90fc0d, - 0x01c10982, - 0x00c601d6, - 0xfd2cfd2c, - 0x01d600c6, - 0x098201c1, - 0xfc0dff90, - 0xfd43fc7c, - 0xf98dfa23, - 0xfc3e012c, - 0x068b075a, - 0x003ef896, - 0x05e001fa, - 0xfa970677, - 0xfd2d0039, - 0x06cb06a6, - 0x0341fa61, - 0x05ddfba4, - 0xff160433, - 0xfa58fd2c, - 0xf693ffb0, - 0xf8eafecd, - 0xff75fa94, - 0x082e0009, - 0x01f100fe, - 0xfd97ff7a, - 0x0740ff5a, - 0x0496083e, - 0xfde002af, - 0xf71afd5c, - 0x0407089d, - 0x0258f991, - 0xfe46fdc9, - 0x073d0448, - 0xfe00f8f0, - 0xfd2cfd2c, - 0xfce00500, - 0xfc09fddc, - 0xfe680157, - 0x04c70571, - 0xfc3aff21, - 0xfcd70228, - 0x056d0277, - 0x0200fe00, - 0x0022f927, - 0xfe3c032b, - 0xfc44ff3c, - 0x03e9fbdb, - 0x04570313, - 0x04c9ff5c, - 0x000d03b8, - 0xfa580000, - 0xfbe900d2, - 0xf9d0fe0b, - 0x0125fdf9, - 0x042501bf, - 0x0328fa2b, - 0xffa902f0, - 0xfa250157, - 0x0200fe00, - 0x03740438, - 0xff0405fd, - 0x030cfe52, - 0x0037fb39, - 0xff6904c5, - 0x04f8fd23, - 0xfd31fc1b, - 0xfd2cfd2c, - 0xfc1bfd31, - 0xfd2304f8, - 0x04c5ff69, - 0xfb390037, - 0xfe52030c, - 0x05fdff04, - 0x04380374, - 0xfe000200, - 0x0157fa25, - 0x02f0ffa9, - 0xfa2b0328, - 0x01bf0425, - 0xfdf90125, - 0xfe0bf9d0, - 0x00d2fbe9, - 0x0000fa58, - 0x03b8000d, - 0xff5c04c9, - 0x03130457, - 0xfbdb03e9, - 0xff3cfc44, - 0x032bfe3c, - 0xf9270022, - 0xfe000200, - 0x0277056d, - 0x0228fcd7, - 0xff21fc3a, - 0x057104c7, - 0x0157fe68, - 0xfddcfc09, - 0x0500fce0, - 0xfd2cfd2c, - 0x0500fce0, - 0xfddcfc09, - 0x0157fe68, - 0x057104c7, - 0xff21fc3a, - 0x0228fcd7, - 0x0277056d, - 0xfe000200, - 0xf9270022, - 0x032bfe3c, - 0xff3cfc44, - 0xfbdb03e9, - 0x03130457, - 0xff5c04c9, - 0x03b8000d, - 0x0000fa58, - 0x00d2fbe9, - 0xfe0bf9d0, - 0xfdf90125, - 0x01bf0425, - 0xfa2b0328, - 0x02f0ffa9, - 0x0157fa25, - 0xfe000200, - 0x04380374, - 0x05fdff04, - 0xfe52030c, - 0xfb390037, - 0x04c5ff69, - 0xfd2304f8, - 0xfc1bfd31, - 0xfd2cfd2c, - 0xfd31fc1b, - 0x04f8fd23, - 0xff6904c5, - 0x0037fb39, - 0x030cfe52, - 0xff0405fd, - 0x03740438, - 0x0200fe00, - 0xfa250157, - 0xffa902f0, - 0x0328fa2b, - 0x042501bf, - 0x0125fdf9, - 0xf9d0fe0b, - 0xfbe900d2, - 0xfa580000, - 0x000d03b8, - 0x04c9ff5c, - 0x04570313, - 0x03e9fbdb, - 0xfc44ff3c, - 0xfe3c032b, - 0x0022f927, - 0x0200fe00, - 0x056d0277, - 0xfcd70228, - 0xfc3aff21, - 0x04c70571, - 0xfe680157, - 0xfc09fddc, - 0xfce00500, - 0x05a80000, - 0xff1006be, - 0x0800084a, - 0xf49cfc7e, - 0xfa580400, - 0xfc9cf6da, - 0xf800f672, - 0x0710071c, - 0x05a805a8, - 0xf8f0f8e4, - 0xf800f672, - 0x03640926, - 0xfa580400, - 0x0b640382, - 0x0800084a, - 0x00f0f942, - 0x05a80000, - 0xff10f942, - 0x0800f7b6, - 0xf49c0382, - 0xfa58fc00, - 0xfc9c0926, - 0xf800098e, - 0x0710f8e4, - 0x05a8fa58, - 0xf8f0071c, - 0xf800098e, - 0x0364f6da, - 0xfa58fc00, - 0x0b64fc7e, - 0x0800f7b6, - 0x00f006be, - 0x05a80000, - 0xff1006be, - 0x0800084a, - 0xf49cfc7e, - 0xfa580400, - 0xfc9cf6da, - 0xf800f672, - 0x0710071c, - 0x05a805a8, - 0xf8f0f8e4, - 0xf800f672, - 0x03640926, - 0xfa580400, - 0x0b640382, - 0x0800084a, - 0x00f0f942, - 0x05a80000, - 0xff10f942, - 0x0800f7b6, - 0xf49c0382, - 0xfa58fc00, - 0xfc9c0926, - 0xf800098e, - 0x0710f8e4, - 0x05a8fa58, - 0xf8f0071c, - 0xf800098e, - 0x0364f6da, - 0xfa58fc00, - 0x0b64fc7e, - 0x0800f7b6, - 0x00f006be, -}; - -static const u32 intlv_tbl_rev0[] = { - 0x00802070, - 0x0671188d, - 0x0a60192c, - 0x0a300e46, - 0x00c1188d, - 0x080024d2, - 0x00000070, -}; - -static const u16 pilot_tbl_rev0[] = { - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0xff0a, - 0xff82, - 0xffa0, - 0xff28, - 0xffff, - 0xffff, - 0xffff, - 0xffff, - 0xff82, - 0xffa0, - 0xff28, - 0xff0a, - 0xffff, - 0xffff, - 0xffff, - 0xffff, - 0xf83f, - 0xfa1f, - 0xfa97, - 0xfab5, - 0xf2bd, - 0xf0bf, - 0xffff, - 0xffff, - 0xf017, - 0xf815, - 0xf215, - 0xf095, - 0xf035, - 0xf01d, - 0xffff, - 0xffff, - 0xff08, - 0xff02, - 0xff80, - 0xff20, - 0xff08, - 0xff02, - 0xff80, - 0xff20, - 0xf01f, - 0xf817, - 0xfa15, - 0xf295, - 0xf0b5, - 0xf03d, - 0xffff, - 0xffff, - 0xf82a, - 0xfa0a, - 0xfa82, - 0xfaa0, - 0xf2a8, - 0xf0aa, - 0xffff, - 0xffff, - 0xf002, - 0xf800, - 0xf200, - 0xf080, - 0xf020, - 0xf008, - 0xffff, - 0xffff, - 0xf00a, - 0xf802, - 0xfa00, - 0xf280, - 0xf0a0, - 0xf028, - 0xffff, - 0xffff, -}; - -static const u32 pltlut_tbl_rev0[] = { - 0x76540123, - 0x62407351, - 0x76543201, - 0x76540213, - 0x76540123, - 0x76430521, -}; - -static const u32 tdi_tbl20_ant0_rev0[] = { - 0x00091226, - 0x000a1429, - 0x000b56ad, - 0x000c58b0, - 0x000d5ab3, - 0x000e9cb6, - 0x000f9eba, - 0x0000c13d, - 0x00020301, - 0x00030504, - 0x00040708, - 0x0005090b, - 0x00064b8e, - 0x00095291, - 0x000a5494, - 0x000b9718, - 0x000c9927, - 0x000d9b2a, - 0x000edd2e, - 0x000fdf31, - 0x000101b4, - 0x000243b7, - 0x000345bb, - 0x000447be, - 0x00058982, - 0x00068c05, - 0x00099309, - 0x000a950c, - 0x000bd78f, - 0x000cd992, - 0x000ddb96, - 0x000f1d99, - 0x00005fa8, - 0x0001422c, - 0x0002842f, - 0x00038632, - 0x00048835, - 0x0005ca38, - 0x0006ccbc, - 0x0009d3bf, - 0x000b1603, - 0x000c1806, - 0x000d1a0a, - 0x000e1c0d, - 0x000f5e10, - 0x00008093, - 0x00018297, - 0x0002c49a, - 0x0003c680, - 0x0004c880, - 0x00060b00, - 0x00070d00, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl20_ant1_rev0[] = { - 0x00014b26, - 0x00028d29, - 0x000393ad, - 0x00049630, - 0x0005d833, - 0x0006da36, - 0x00099c3a, - 0x000a9e3d, - 0x000bc081, - 0x000cc284, - 0x000dc488, - 0x000f068b, - 0x0000488e, - 0x00018b91, - 0x0002d214, - 0x0003d418, - 0x0004d6a7, - 0x000618aa, - 0x00071aae, - 0x0009dcb1, - 0x000b1eb4, - 0x000c0137, - 0x000d033b, - 0x000e053e, - 0x000f4702, - 0x00008905, - 0x00020c09, - 0x0003128c, - 0x0004148f, - 0x00051712, - 0x00065916, - 0x00091b19, - 0x000a1d28, - 0x000b5f2c, - 0x000c41af, - 0x000d43b2, - 0x000e85b5, - 0x000f87b8, - 0x0000c9bc, - 0x00024cbf, - 0x00035303, - 0x00045506, - 0x0005978a, - 0x0006998d, - 0x00095b90, - 0x000a5d93, - 0x000b9f97, - 0x000c821a, - 0x000d8400, - 0x000ec600, - 0x000fc800, - 0x00010a00, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl40_ant0_rev0[] = { - 0x0011a346, - 0x00136ccf, - 0x0014f5d9, - 0x001641e2, - 0x0017cb6b, - 0x00195475, - 0x001b2383, - 0x001cad0c, - 0x001e7616, - 0x0000821f, - 0x00020ba8, - 0x0003d4b2, - 0x00056447, - 0x00072dd0, - 0x0008b6da, - 0x000a02e3, - 0x000b8c6c, - 0x000d15f6, - 0x0011e484, - 0x0013ae0d, - 0x00153717, - 0x00168320, - 0x00180ca9, - 0x00199633, - 0x001b6548, - 0x001ceed1, - 0x001eb7db, - 0x0000c3e4, - 0x00024d6d, - 0x000416f7, - 0x0005a585, - 0x00076f0f, - 0x0008f818, - 0x000a4421, - 0x000bcdab, - 0x000d9734, - 0x00122649, - 0x0013efd2, - 0x001578dc, - 0x0016c4e5, - 0x00184e6e, - 0x001a17f8, - 0x001ba686, - 0x001d3010, - 0x001ef999, - 0x00010522, - 0x00028eac, - 0x00045835, - 0x0005e74a, - 0x0007b0d3, - 0x00093a5d, - 0x000a85e6, - 0x000c0f6f, - 0x000dd8f9, - 0x00126787, - 0x00143111, - 0x0015ba9a, - 0x00170623, - 0x00188fad, - 0x001a5936, - 0x001be84b, - 0x001db1d4, - 0x001f3b5e, - 0x000146e7, - 0x00031070, - 0x000499fa, - 0x00062888, - 0x0007f212, - 0x00097b9b, - 0x000ac7a4, - 0x000c50ae, - 0x000e1a37, - 0x0012a94c, - 0x001472d5, - 0x0015fc5f, - 0x00174868, - 0x0018d171, - 0x001a9afb, - 0x001c2989, - 0x001df313, - 0x001f7c9c, - 0x000188a5, - 0x000351af, - 0x0004db38, - 0x0006aa4d, - 0x000833d7, - 0x0009bd60, - 0x000b0969, - 0x000c9273, - 0x000e5bfc, - 0x00132a8a, - 0x0014b414, - 0x00163d9d, - 0x001789a6, - 0x001912b0, - 0x001adc39, - 0x001c6bce, - 0x001e34d8, - 0x001fbe61, - 0x0001ca6a, - 0x00039374, - 0x00051cfd, - 0x0006ec0b, - 0x00087515, - 0x0009fe9e, - 0x000b4aa7, - 0x000cd3b1, - 0x000e9d3a, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl40_ant1_rev0[] = { - 0x001edb36, - 0x000129ca, - 0x0002b353, - 0x00047cdd, - 0x0005c8e6, - 0x000791ef, - 0x00091bf9, - 0x000aaa07, - 0x000c3391, - 0x000dfd1a, - 0x00120923, - 0x0013d22d, - 0x00155c37, - 0x0016eacb, - 0x00187454, - 0x001a3dde, - 0x001b89e7, - 0x001d12f0, - 0x001f1cfa, - 0x00016b88, - 0x00033492, - 0x0004be1b, - 0x00060a24, - 0x0007d32e, - 0x00095d38, - 0x000aec4c, - 0x000c7555, - 0x000e3edf, - 0x00124ae8, - 0x001413f1, - 0x0015a37b, - 0x00172c89, - 0x0018b593, - 0x001a419c, - 0x001bcb25, - 0x001d942f, - 0x001f63b9, - 0x0001ad4d, - 0x00037657, - 0x0004c260, - 0x00068be9, - 0x000814f3, - 0x0009a47c, - 0x000b2d8a, - 0x000cb694, - 0x000e429d, - 0x00128c26, - 0x001455b0, - 0x0015e4ba, - 0x00176e4e, - 0x0018f758, - 0x001a8361, - 0x001c0cea, - 0x001dd674, - 0x001fa57d, - 0x0001ee8b, - 0x0003b795, - 0x0005039e, - 0x0006cd27, - 0x000856b1, - 0x0009e5c6, - 0x000b6f4f, - 0x000cf859, - 0x000e8462, - 0x00130deb, - 0x00149775, - 0x00162603, - 0x0017af8c, - 0x00193896, - 0x001ac49f, - 0x001c4e28, - 0x001e17b2, - 0x0000a6c7, - 0x00023050, - 0x0003f9da, - 0x00054563, - 0x00070eec, - 0x00089876, - 0x000a2704, - 0x000bb08d, - 0x000d3a17, - 0x001185a0, - 0x00134f29, - 0x0014d8b3, - 0x001667c8, - 0x0017f151, - 0x00197adb, - 0x001b0664, - 0x001c8fed, - 0x001e5977, - 0x0000e805, - 0x0002718f, - 0x00043b18, - 0x000586a1, - 0x0007502b, - 0x0008d9b4, - 0x000a68c9, - 0x000bf252, - 0x000dbbdc, - 0x0011c7e5, - 0x001390ee, - 0x00151a78, - 0x0016a906, - 0x00183290, - 0x0019bc19, - 0x001b4822, - 0x001cd12c, - 0x001e9ab5, - 0x00000000, - 0x00000000, -}; - -static const u16 bdi_tbl_rev0[] = { - 0x0070, - 0x0126, - 0x012c, - 0x0246, - 0x048d, - 0x04d2, -}; - -static const u32 chanest_tbl_rev0[] = { - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, -}; - -static const u8 mcs_tbl_rev0[] = { - 0x00, - 0x08, - 0x0a, - 0x10, - 0x12, - 0x19, - 0x1a, - 0x1c, - 0x40, - 0x48, - 0x4a, - 0x50, - 0x52, - 0x59, - 0x5a, - 0x5c, - 0x80, - 0x88, - 0x8a, - 0x90, - 0x92, - 0x99, - 0x9a, - 0x9c, - 0xc0, - 0xc8, - 0xca, - 0xd0, - 0xd2, - 0xd9, - 0xda, - 0xdc, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x02, - 0x04, - 0x08, - 0x09, - 0x0a, - 0x0c, - 0x10, - 0x11, - 0x12, - 0x14, - 0x18, - 0x19, - 0x1a, - 0x1c, - 0x20, - 0x21, - 0x22, - 0x24, - 0x40, - 0x41, - 0x42, - 0x44, - 0x48, - 0x49, - 0x4a, - 0x4c, - 0x50, - 0x51, - 0x52, - 0x54, - 0x58, - 0x59, - 0x5a, - 0x5c, - 0x60, - 0x61, - 0x62, - 0x64, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; - -static const u32 noise_var_tbl0_rev0[] = { - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, -}; - -static const u32 noise_var_tbl1_rev0[] = { - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, -}; - -static const u8 est_pwr_lut_core0_rev0[] = { - 0x50, - 0x4f, - 0x4e, - 0x4d, - 0x4c, - 0x4b, - 0x4a, - 0x49, - 0x48, - 0x47, - 0x46, - 0x45, - 0x44, - 0x43, - 0x42, - 0x41, - 0x40, - 0x3f, - 0x3e, - 0x3d, - 0x3c, - 0x3b, - 0x3a, - 0x39, - 0x38, - 0x37, - 0x36, - 0x35, - 0x34, - 0x33, - 0x32, - 0x31, - 0x30, - 0x2f, - 0x2e, - 0x2d, - 0x2c, - 0x2b, - 0x2a, - 0x29, - 0x28, - 0x27, - 0x26, - 0x25, - 0x24, - 0x23, - 0x22, - 0x21, - 0x20, - 0x1f, - 0x1e, - 0x1d, - 0x1c, - 0x1b, - 0x1a, - 0x19, - 0x18, - 0x17, - 0x16, - 0x15, - 0x14, - 0x13, - 0x12, - 0x11, -}; - -static const u8 est_pwr_lut_core1_rev0[] = { - 0x50, - 0x4f, - 0x4e, - 0x4d, - 0x4c, - 0x4b, - 0x4a, - 0x49, - 0x48, - 0x47, - 0x46, - 0x45, - 0x44, - 0x43, - 0x42, - 0x41, - 0x40, - 0x3f, - 0x3e, - 0x3d, - 0x3c, - 0x3b, - 0x3a, - 0x39, - 0x38, - 0x37, - 0x36, - 0x35, - 0x34, - 0x33, - 0x32, - 0x31, - 0x30, - 0x2f, - 0x2e, - 0x2d, - 0x2c, - 0x2b, - 0x2a, - 0x29, - 0x28, - 0x27, - 0x26, - 0x25, - 0x24, - 0x23, - 0x22, - 0x21, - 0x20, - 0x1f, - 0x1e, - 0x1d, - 0x1c, - 0x1b, - 0x1a, - 0x19, - 0x18, - 0x17, - 0x16, - 0x15, - 0x14, - 0x13, - 0x12, - 0x11, -}; - -static const u8 adj_pwr_lut_core0_rev0[] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; - -static const u8 adj_pwr_lut_core1_rev0[] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; - -static const u32 gainctrl_lut_core0_rev0[] = { - 0x03cc2b44, - 0x03cc2b42, - 0x03cc2b40, - 0x03cc2b3e, - 0x03cc2b3d, - 0x03cc2b3b, - 0x03c82b44, - 0x03c82b42, - 0x03c82b40, - 0x03c82b3e, - 0x03c82b3d, - 0x03c82b3b, - 0x03c82b39, - 0x03c82b38, - 0x03c82b36, - 0x03c82b34, - 0x03c42b44, - 0x03c42b42, - 0x03c42b40, - 0x03c42b3e, - 0x03c42b3d, - 0x03c42b3b, - 0x03c42b39, - 0x03c42b38, - 0x03c42b36, - 0x03c42b34, - 0x03c42b33, - 0x03c42b32, - 0x03c42b30, - 0x03c42b2f, - 0x03c42b2d, - 0x03c02b44, - 0x03c02b42, - 0x03c02b40, - 0x03c02b3e, - 0x03c02b3d, - 0x03c02b3b, - 0x03c02b39, - 0x03c02b38, - 0x03c02b36, - 0x03c02b34, - 0x03b02b44, - 0x03b02b42, - 0x03b02b40, - 0x03b02b3e, - 0x03b02b3d, - 0x03b02b3b, - 0x03b02b39, - 0x03b02b38, - 0x03b02b36, - 0x03b02b34, - 0x03b02b33, - 0x03b02b32, - 0x03b02b30, - 0x03b02b2f, - 0x03b02b2d, - 0x03a02b44, - 0x03a02b42, - 0x03a02b40, - 0x03a02b3e, - 0x03a02b3d, - 0x03a02b3b, - 0x03a02b39, - 0x03a02b38, - 0x03a02b36, - 0x03a02b34, - 0x03902b44, - 0x03902b42, - 0x03902b40, - 0x03902b3e, - 0x03902b3d, - 0x03902b3b, - 0x03902b39, - 0x03902b38, - 0x03902b36, - 0x03902b34, - 0x03902b33, - 0x03902b32, - 0x03902b30, - 0x03802b44, - 0x03802b42, - 0x03802b40, - 0x03802b3e, - 0x03802b3d, - 0x03802b3b, - 0x03802b39, - 0x03802b38, - 0x03802b36, - 0x03802b34, - 0x03802b33, - 0x03802b32, - 0x03802b30, - 0x03802b2f, - 0x03802b2d, - 0x03802b2c, - 0x03802b2b, - 0x03802b2a, - 0x03802b29, - 0x03802b27, - 0x03802b26, - 0x03802b25, - 0x03802b24, - 0x03802b23, - 0x03802b22, - 0x03802b21, - 0x03802b20, - 0x03802b1f, - 0x03802b1e, - 0x03802b1e, - 0x03802b1d, - 0x03802b1c, - 0x03802b1b, - 0x03802b1a, - 0x03802b1a, - 0x03802b19, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x00002b00, -}; - -static const u32 gainctrl_lut_core1_rev0[] = { - 0x03cc2b44, - 0x03cc2b42, - 0x03cc2b40, - 0x03cc2b3e, - 0x03cc2b3d, - 0x03cc2b3b, - 0x03c82b44, - 0x03c82b42, - 0x03c82b40, - 0x03c82b3e, - 0x03c82b3d, - 0x03c82b3b, - 0x03c82b39, - 0x03c82b38, - 0x03c82b36, - 0x03c82b34, - 0x03c42b44, - 0x03c42b42, - 0x03c42b40, - 0x03c42b3e, - 0x03c42b3d, - 0x03c42b3b, - 0x03c42b39, - 0x03c42b38, - 0x03c42b36, - 0x03c42b34, - 0x03c42b33, - 0x03c42b32, - 0x03c42b30, - 0x03c42b2f, - 0x03c42b2d, - 0x03c02b44, - 0x03c02b42, - 0x03c02b40, - 0x03c02b3e, - 0x03c02b3d, - 0x03c02b3b, - 0x03c02b39, - 0x03c02b38, - 0x03c02b36, - 0x03c02b34, - 0x03b02b44, - 0x03b02b42, - 0x03b02b40, - 0x03b02b3e, - 0x03b02b3d, - 0x03b02b3b, - 0x03b02b39, - 0x03b02b38, - 0x03b02b36, - 0x03b02b34, - 0x03b02b33, - 0x03b02b32, - 0x03b02b30, - 0x03b02b2f, - 0x03b02b2d, - 0x03a02b44, - 0x03a02b42, - 0x03a02b40, - 0x03a02b3e, - 0x03a02b3d, - 0x03a02b3b, - 0x03a02b39, - 0x03a02b38, - 0x03a02b36, - 0x03a02b34, - 0x03902b44, - 0x03902b42, - 0x03902b40, - 0x03902b3e, - 0x03902b3d, - 0x03902b3b, - 0x03902b39, - 0x03902b38, - 0x03902b36, - 0x03902b34, - 0x03902b33, - 0x03902b32, - 0x03902b30, - 0x03802b44, - 0x03802b42, - 0x03802b40, - 0x03802b3e, - 0x03802b3d, - 0x03802b3b, - 0x03802b39, - 0x03802b38, - 0x03802b36, - 0x03802b34, - 0x03802b33, - 0x03802b32, - 0x03802b30, - 0x03802b2f, - 0x03802b2d, - 0x03802b2c, - 0x03802b2b, - 0x03802b2a, - 0x03802b29, - 0x03802b27, - 0x03802b26, - 0x03802b25, - 0x03802b24, - 0x03802b23, - 0x03802b22, - 0x03802b21, - 0x03802b20, - 0x03802b1f, - 0x03802b1e, - 0x03802b1e, - 0x03802b1d, - 0x03802b1c, - 0x03802b1b, - 0x03802b1a, - 0x03802b1a, - 0x03802b19, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x03802b18, - 0x00002b00, -}; - -static const u32 iq_lut_core0_rev0[] = { - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, -}; - -static const u32 iq_lut_core1_rev0[] = { - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, - 0x0000007f, -}; - -static const u16 loft_lut_core0_rev0[] = { - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, -}; - -static const u16 loft_lut_core1_rev0[] = { - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, - 0x0000, - 0x0101, - 0x0002, - 0x0103, -}; - -const struct phytbl_info mimophytbl_info_rev0_volatile[] = { - {&bdi_tbl_rev0, sizeof(bdi_tbl_rev0) / sizeof(bdi_tbl_rev0[0]), 21, 0, - 16} - , - {&pltlut_tbl_rev0, sizeof(pltlut_tbl_rev0) / sizeof(pltlut_tbl_rev0[0]), - 20, 0, 32} - , - {&gainctrl_lut_core0_rev0, - sizeof(gainctrl_lut_core0_rev0) / sizeof(gainctrl_lut_core0_rev0[0]), - 26, 192, 32} - , - {&gainctrl_lut_core1_rev0, - sizeof(gainctrl_lut_core1_rev0) / sizeof(gainctrl_lut_core1_rev0[0]), - 27, 192, 32} - , - - {&est_pwr_lut_core0_rev0, - sizeof(est_pwr_lut_core0_rev0) / sizeof(est_pwr_lut_core0_rev0[0]), 26, - 0, 8} - , - {&est_pwr_lut_core1_rev0, - sizeof(est_pwr_lut_core1_rev0) / sizeof(est_pwr_lut_core1_rev0[0]), 27, - 0, 8} - , - {&adj_pwr_lut_core0_rev0, - sizeof(adj_pwr_lut_core0_rev0) / sizeof(adj_pwr_lut_core0_rev0[0]), 26, - 64, 8} - , - {&adj_pwr_lut_core1_rev0, - sizeof(adj_pwr_lut_core1_rev0) / sizeof(adj_pwr_lut_core1_rev0[0]), 27, - 64, 8} - , - {&iq_lut_core0_rev0, - sizeof(iq_lut_core0_rev0) / sizeof(iq_lut_core0_rev0[0]), 26, 320, 32} - , - {&iq_lut_core1_rev0, - sizeof(iq_lut_core1_rev0) / sizeof(iq_lut_core1_rev0[0]), 27, 320, 32} - , - {&loft_lut_core0_rev0, - sizeof(loft_lut_core0_rev0) / sizeof(loft_lut_core0_rev0[0]), 26, 448, - 16} - , - {&loft_lut_core1_rev0, - sizeof(loft_lut_core1_rev0) / sizeof(loft_lut_core1_rev0[0]), 27, 448, - 16} - , -}; - -const struct phytbl_info mimophytbl_info_rev0[] = { - {&frame_struct_rev0, - sizeof(frame_struct_rev0) / sizeof(frame_struct_rev0[0]), 10, 0, 32} - , - {&frame_lut_rev0, sizeof(frame_lut_rev0) / sizeof(frame_lut_rev0[0]), - 24, 0, 8} - , - {&tmap_tbl_rev0, sizeof(tmap_tbl_rev0) / sizeof(tmap_tbl_rev0[0]), 12, - 0, 32} - , - {&tdtrn_tbl_rev0, sizeof(tdtrn_tbl_rev0) / sizeof(tdtrn_tbl_rev0[0]), - 14, 0, 32} - , - {&intlv_tbl_rev0, sizeof(intlv_tbl_rev0) / sizeof(intlv_tbl_rev0[0]), - 13, 0, 32} - , - {&pilot_tbl_rev0, sizeof(pilot_tbl_rev0) / sizeof(pilot_tbl_rev0[0]), - 11, 0, 16} - , - {&tdi_tbl20_ant0_rev0, - sizeof(tdi_tbl20_ant0_rev0) / sizeof(tdi_tbl20_ant0_rev0[0]), 19, 128, - 32} - , - {&tdi_tbl20_ant1_rev0, - sizeof(tdi_tbl20_ant1_rev0) / sizeof(tdi_tbl20_ant1_rev0[0]), 19, 256, - 32} - , - {&tdi_tbl40_ant0_rev0, - sizeof(tdi_tbl40_ant0_rev0) / sizeof(tdi_tbl40_ant0_rev0[0]), 19, 640, - 32} - , - {&tdi_tbl40_ant1_rev0, - sizeof(tdi_tbl40_ant1_rev0) / sizeof(tdi_tbl40_ant1_rev0[0]), 19, 768, - 32} - , - {&chanest_tbl_rev0, - sizeof(chanest_tbl_rev0) / sizeof(chanest_tbl_rev0[0]), 22, 0, 32} - , - {&mcs_tbl_rev0, sizeof(mcs_tbl_rev0) / sizeof(mcs_tbl_rev0[0]), 18, 0, - 8} - , - {&noise_var_tbl0_rev0, - sizeof(noise_var_tbl0_rev0) / sizeof(noise_var_tbl0_rev0[0]), 16, 0, - 32} - , - {&noise_var_tbl1_rev0, - sizeof(noise_var_tbl1_rev0) / sizeof(noise_var_tbl1_rev0[0]), 16, 128, - 32} - , -}; - -const u32 mimophytbl_info_sz_rev0 = - sizeof(mimophytbl_info_rev0) / sizeof(mimophytbl_info_rev0[0]); -const u32 mimophytbl_info_sz_rev0_volatile = - sizeof(mimophytbl_info_rev0_volatile) / - sizeof(mimophytbl_info_rev0_volatile[0]); - -static const u16 ant_swctrl_tbl_rev3[] = { - 0x0082, - 0x0082, - 0x0211, - 0x0222, - 0x0328, - 0x0000, - 0x0000, - 0x0000, - 0x0144, - 0x0000, - 0x0000, - 0x0000, - 0x0188, - 0x0000, - 0x0000, - 0x0000, - 0x0082, - 0x0082, - 0x0211, - 0x0222, - 0x0328, - 0x0000, - 0x0000, - 0x0000, - 0x0144, - 0x0000, - 0x0000, - 0x0000, - 0x0188, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u16 ant_swctrl_tbl_rev3_1[] = { - 0x0022, - 0x0022, - 0x0011, - 0x0022, - 0x0022, - 0x0000, - 0x0000, - 0x0000, - 0x0011, - 0x0000, - 0x0000, - 0x0000, - 0x0022, - 0x0000, - 0x0000, - 0x0000, - 0x0022, - 0x0022, - 0x0011, - 0x0022, - 0x0022, - 0x0000, - 0x0000, - 0x0000, - 0x0011, - 0x0000, - 0x0000, - 0x0000, - 0x0022, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u16 ant_swctrl_tbl_rev3_2[] = { - 0x0088, - 0x0088, - 0x0044, - 0x0088, - 0x0088, - 0x0000, - 0x0000, - 0x0000, - 0x0044, - 0x0000, - 0x0000, - 0x0000, - 0x0088, - 0x0000, - 0x0000, - 0x0000, - 0x0088, - 0x0088, - 0x0044, - 0x0088, - 0x0088, - 0x0000, - 0x0000, - 0x0000, - 0x0044, - 0x0000, - 0x0000, - 0x0000, - 0x0088, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u16 ant_swctrl_tbl_rev3_3[] = { - 0x022, - 0x022, - 0x011, - 0x022, - 0x000, - 0x000, - 0x000, - 0x000, - 0x011, - 0x000, - 0x000, - 0x000, - 0x022, - 0x000, - 0x000, - 0x3cc, - 0x022, - 0x022, - 0x011, - 0x022, - 0x000, - 0x000, - 0x000, - 0x000, - 0x011, - 0x000, - 0x000, - 0x000, - 0x022, - 0x000, - 0x000, - 0x3cc -}; - -static const u32 frame_struct_rev3[] = { - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x09804506, - 0x00100030, - 0x09804507, - 0x00100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a0c, - 0x00100004, - 0x01000a0d, - 0x00100024, - 0x0980450e, - 0x00100034, - 0x0980450f, - 0x00100034, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a04, - 0x00100000, - 0x11008a05, - 0x00100020, - 0x1980c506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x01800504, - 0x00100030, - 0x11808505, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000a04, - 0x00100000, - 0x11008a05, - 0x00100020, - 0x21810506, - 0x00100030, - 0x21810506, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x1980c50e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x0180050c, - 0x00100038, - 0x1180850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x1980c506, - 0x00100030, - 0x1980c506, - 0x00100030, - 0x11808504, - 0x00100030, - 0x3981ca05, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x10008a04, - 0x00100000, - 0x3981ca05, - 0x00100030, - 0x1980c506, - 0x00100030, - 0x29814507, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a0c, - 0x00100008, - 0x01000a0d, - 0x00100028, - 0x1980c50e, - 0x00100038, - 0x1980c50e, - 0x00100038, - 0x1180850c, - 0x00100038, - 0x3981ca0d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x10008a0c, - 0x00100008, - 0x3981ca0d, - 0x00100038, - 0x1980c50e, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x02001405, - 0x00100040, - 0x0b004a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x43020a04, - 0x00100060, - 0x1b00ca05, - 0x00100060, - 0x23010a07, - 0x01500060, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x13008a06, - 0x01900060, - 0x13008a06, - 0x01900060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x0200140d, - 0x00100050, - 0x0b004a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x50029404, - 0x00100000, - 0x32019405, - 0x00100040, - 0x0b004a06, - 0x01900060, - 0x0b004a06, - 0x01900060, - 0x5b02ca04, - 0x00100060, - 0x3b01d405, - 0x00100060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x5802d404, - 0x00100000, - 0x3b01d405, - 0x00100060, - 0x0b004a06, - 0x01900060, - 0x23010a07, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x5002940c, - 0x00100010, - 0x3201940d, - 0x00100050, - 0x0b004a0e, - 0x01900070, - 0x0b004a0e, - 0x01900070, - 0x5b02ca0c, - 0x00100070, - 0x3b01d40d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x5802d40c, - 0x00100010, - 0x3b01d40d, - 0x00100070, - 0x0b004a0e, - 0x01900070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x000f4800, - 0x62031405, - 0x00100040, - 0x53028a06, - 0x01900060, - 0x53028a07, - 0x01900060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x000f4808, - 0x6203140d, - 0x00100048, - 0x53028a0e, - 0x01900068, - 0x53028a0f, - 0x01900068, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100004, - 0x11008a0d, - 0x00100024, - 0x1980c50e, - 0x00100034, - 0x2181050e, - 0x00100034, - 0x2181050e, - 0x00100034, - 0x0180050c, - 0x00100038, - 0x1180850d, - 0x00100038, - 0x1181850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000a0c, - 0x00100008, - 0x11008a0d, - 0x00100028, - 0x2181050e, - 0x00100038, - 0x2181050e, - 0x00100038, - 0x1181850d, - 0x00100038, - 0x2981450f, - 0x01100038, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x08004a04, - 0x00100000, - 0x01000a05, - 0x00100020, - 0x0180c506, - 0x00100030, - 0x0180c506, - 0x00100030, - 0x2180c50c, - 0x00100030, - 0x49820a0d, - 0x0016a130, - 0x41824a0d, - 0x0016a130, - 0x2981450f, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x2000ca0c, - 0x00100000, - 0x49820a0d, - 0x0016a130, - 0x1980c50e, - 0x00100030, - 0x41824a0d, - 0x0016a130, - 0x2981450f, - 0x01100030, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100008, - 0x0200140d, - 0x00100048, - 0x0b004a0e, - 0x01900068, - 0x13008a0e, - 0x01900068, - 0x13008a0e, - 0x01900068, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x1b014a0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x13008a0e, - 0x01900070, - 0x13008a0e, - 0x01900070, - 0x1b014a0d, - 0x00100070, - 0x23010a0f, - 0x01500070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x50029404, - 0x00100000, - 0x32019405, - 0x00100040, - 0x03004a06, - 0x01900060, - 0x03004a06, - 0x01900060, - 0x6b030a0c, - 0x00100060, - 0x4b02140d, - 0x0016a160, - 0x4302540d, - 0x0016a160, - 0x23010a0f, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x6b03140c, - 0x00100060, - 0x4b02140d, - 0x0016a160, - 0x0b004a0e, - 0x01900060, - 0x4302540d, - 0x0016a160, - 0x23010a0f, - 0x01500060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x53028a06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x43020a04, - 0x00100060, - 0x1b00ca05, - 0x00100060, - 0x53028a07, - 0x0190c060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x53028a0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x43020a0c, - 0x00100070, - 0x1b00ca0d, - 0x00100070, - 0x53028a0f, - 0x0190c070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40021404, - 0x00100000, - 0x1a00d405, - 0x00100040, - 0x5b02ca06, - 0x01900060, - 0x5b02ca06, - 0x01900060, - 0x53028a07, - 0x0190c060, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x4002140c, - 0x00100010, - 0x1a00d40d, - 0x00100050, - 0x5b02ca0e, - 0x01900070, - 0x5b02ca0e, - 0x01900070, - 0x53028a0f, - 0x0190c070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u16 pilot_tbl_rev3[] = { - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0xff08, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0x80d5, - 0xff0a, - 0xff82, - 0xffa0, - 0xff28, - 0xffff, - 0xffff, - 0xffff, - 0xffff, - 0xff82, - 0xffa0, - 0xff28, - 0xff0a, - 0xffff, - 0xffff, - 0xffff, - 0xffff, - 0xf83f, - 0xfa1f, - 0xfa97, - 0xfab5, - 0xf2bd, - 0xf0bf, - 0xffff, - 0xffff, - 0xf017, - 0xf815, - 0xf215, - 0xf095, - 0xf035, - 0xf01d, - 0xffff, - 0xffff, - 0xff08, - 0xff02, - 0xff80, - 0xff20, - 0xff08, - 0xff02, - 0xff80, - 0xff20, - 0xf01f, - 0xf817, - 0xfa15, - 0xf295, - 0xf0b5, - 0xf03d, - 0xffff, - 0xffff, - 0xf82a, - 0xfa0a, - 0xfa82, - 0xfaa0, - 0xf2a8, - 0xf0aa, - 0xffff, - 0xffff, - 0xf002, - 0xf800, - 0xf200, - 0xf080, - 0xf020, - 0xf008, - 0xffff, - 0xffff, - 0xf00a, - 0xf802, - 0xfa00, - 0xf280, - 0xf0a0, - 0xf028, - 0xffff, - 0xffff, -}; - -static const u32 tmap_tbl_rev3[] = { - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x000aa888, - 0x88880000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00011111, - 0x11110000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00088aaa, - 0xaaaa0000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xaaa8aaa0, - 0x8aaa8aaa, - 0xaa8a8a8a, - 0x000aaa88, - 0x8aaa0000, - 0xaaa8a888, - 0x8aa88a8a, - 0x8a88a888, - 0x08080a00, - 0x0a08080a, - 0x080a0a08, - 0x00080808, - 0x080a0000, - 0x080a0808, - 0x080a0808, - 0x0a0a0a08, - 0xa0a0a0a0, - 0x80a0a080, - 0x8080a0a0, - 0x00008080, - 0x80a00000, - 0x80a080a0, - 0xa080a0a0, - 0x8080a0a0, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x99999000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x22000000, - 0x2222b222, - 0x22222222, - 0x222222b2, - 0xb2222220, - 0x22222222, - 0x22d22222, - 0x00000222, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x33000000, - 0x3333b333, - 0x33333333, - 0x333333b3, - 0xb3333330, - 0x33333333, - 0x33d33333, - 0x00000333, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x99b99b00, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb99, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x22222200, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0x22222222, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x11111111, - 0xf1111111, - 0x11111111, - 0x11f11111, - 0x01111111, - 0xbb9bb900, - 0xb9b9bb99, - 0xb99bbbbb, - 0xbbbb9b9b, - 0xb9bb99bb, - 0xb99999b9, - 0xb9b9b99b, - 0x00000bbb, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88aa, - 0xa88888a8, - 0xa8a8a88a, - 0x0a888aaa, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00000aaa, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0xbbbbbb00, - 0x999bbbbb, - 0x9bb99b9b, - 0xb9b9b9bb, - 0xb9b99bbb, - 0xb9b9b9bb, - 0xb9bb9b99, - 0x00000999, - 0x8a000000, - 0xaa88a888, - 0xa88888aa, - 0xa88a8a88, - 0xa88aa88a, - 0x88a8aaaa, - 0xa8aa8aaa, - 0x0888a88a, - 0x0b0b0b00, - 0x090b0b0b, - 0x0b090b0b, - 0x0909090b, - 0x09090b0b, - 0x09090b0b, - 0x09090b09, - 0x00000909, - 0x0a000000, - 0x0a080808, - 0x080a080a, - 0x080a0a08, - 0x080a080a, - 0x0808080a, - 0x0a0a0a08, - 0x0808080a, - 0xb0b0b000, - 0x9090b0b0, - 0x90b09090, - 0xb0b0b090, - 0xb0b090b0, - 0x90b0b0b0, - 0xb0b09090, - 0x00000090, - 0x80000000, - 0xa080a080, - 0xa08080a0, - 0xa0808080, - 0xa080a080, - 0x80a0a0a0, - 0xa0a080a0, - 0x00a0a0a0, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x33000000, - 0x3333f333, - 0x33333333, - 0x333333f3, - 0xf3333330, - 0x33333333, - 0x33f33333, - 0x00000333, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x99000000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88888000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x88a88a00, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 intlv_tbl_rev3[] = { - 0x00802070, - 0x0671188d, - 0x0a60192c, - 0x0a300e46, - 0x00c1188d, - 0x080024d2, - 0x00000070, -}; - -static const u32 tdtrn_tbl_rev3[] = { - 0x061c061c, - 0x0050ee68, - 0xf592fe36, - 0xfe5212f6, - 0x00000c38, - 0xfe5212f6, - 0xf592fe36, - 0x0050ee68, - 0x061c061c, - 0xee680050, - 0xfe36f592, - 0x12f6fe52, - 0x0c380000, - 0x12f6fe52, - 0xfe36f592, - 0xee680050, - 0x061c061c, - 0x0050ee68, - 0xf592fe36, - 0xfe5212f6, - 0x00000c38, - 0xfe5212f6, - 0xf592fe36, - 0x0050ee68, - 0x061c061c, - 0xee680050, - 0xfe36f592, - 0x12f6fe52, - 0x0c380000, - 0x12f6fe52, - 0xfe36f592, - 0xee680050, - 0x05e305e3, - 0x004def0c, - 0xf5f3fe47, - 0xfe611246, - 0x00000bc7, - 0xfe611246, - 0xf5f3fe47, - 0x004def0c, - 0x05e305e3, - 0xef0c004d, - 0xfe47f5f3, - 0x1246fe61, - 0x0bc70000, - 0x1246fe61, - 0xfe47f5f3, - 0xef0c004d, - 0x05e305e3, - 0x004def0c, - 0xf5f3fe47, - 0xfe611246, - 0x00000bc7, - 0xfe611246, - 0xf5f3fe47, - 0x004def0c, - 0x05e305e3, - 0xef0c004d, - 0xfe47f5f3, - 0x1246fe61, - 0x0bc70000, - 0x1246fe61, - 0xfe47f5f3, - 0xef0c004d, - 0xfa58fa58, - 0xf895043b, - 0xff4c09c0, - 0xfbc6ffa8, - 0xfb84f384, - 0x0798f6f9, - 0x05760122, - 0x058409f6, - 0x0b500000, - 0x05b7f542, - 0x08860432, - 0x06ddfee7, - 0xfb84f384, - 0xf9d90664, - 0xf7e8025c, - 0x00fff7bd, - 0x05a805a8, - 0xf7bd00ff, - 0x025cf7e8, - 0x0664f9d9, - 0xf384fb84, - 0xfee706dd, - 0x04320886, - 0xf54205b7, - 0x00000b50, - 0x09f60584, - 0x01220576, - 0xf6f90798, - 0xf384fb84, - 0xffa8fbc6, - 0x09c0ff4c, - 0x043bf895, - 0x02d402d4, - 0x07de0270, - 0xfc96079c, - 0xf90afe94, - 0xfe00ff2c, - 0x02d4065d, - 0x092a0096, - 0x0014fbb8, - 0xfd2cfd2c, - 0x076afb3c, - 0x0096f752, - 0xf991fd87, - 0xfb2c0200, - 0xfeb8f960, - 0x08e0fc96, - 0x049802a8, - 0xfd2cfd2c, - 0x02a80498, - 0xfc9608e0, - 0xf960feb8, - 0x0200fb2c, - 0xfd87f991, - 0xf7520096, - 0xfb3c076a, - 0xfd2cfd2c, - 0xfbb80014, - 0x0096092a, - 0x065d02d4, - 0xff2cfe00, - 0xfe94f90a, - 0x079cfc96, - 0x027007de, - 0x02d402d4, - 0x027007de, - 0x079cfc96, - 0xfe94f90a, - 0xff2cfe00, - 0x065d02d4, - 0x0096092a, - 0xfbb80014, - 0xfd2cfd2c, - 0xfb3c076a, - 0xf7520096, - 0xfd87f991, - 0x0200fb2c, - 0xf960feb8, - 0xfc9608e0, - 0x02a80498, - 0xfd2cfd2c, - 0x049802a8, - 0x08e0fc96, - 0xfeb8f960, - 0xfb2c0200, - 0xf991fd87, - 0x0096f752, - 0x076afb3c, - 0xfd2cfd2c, - 0x0014fbb8, - 0x092a0096, - 0x02d4065d, - 0xfe00ff2c, - 0xf90afe94, - 0xfc96079c, - 0x07de0270, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x062a0000, - 0xfefa0759, - 0x08b80908, - 0xf396fc2d, - 0xf9d6045c, - 0xfc4ef608, - 0xf748f596, - 0x07b207bf, - 0x062a062a, - 0xf84ef841, - 0xf748f596, - 0x03b209f8, - 0xf9d6045c, - 0x0c6a03d3, - 0x08b80908, - 0x0106f8a7, - 0x062a0000, - 0xfefaf8a7, - 0x08b8f6f8, - 0xf39603d3, - 0xf9d6fba4, - 0xfc4e09f8, - 0xf7480a6a, - 0x07b2f841, - 0x062af9d6, - 0xf84e07bf, - 0xf7480a6a, - 0x03b2f608, - 0xf9d6fba4, - 0x0c6afc2d, - 0x08b8f6f8, - 0x01060759, - 0x062a0000, - 0xfefa0759, - 0x08b80908, - 0xf396fc2d, - 0xf9d6045c, - 0xfc4ef608, - 0xf748f596, - 0x07b207bf, - 0x062a062a, - 0xf84ef841, - 0xf748f596, - 0x03b209f8, - 0xf9d6045c, - 0x0c6a03d3, - 0x08b80908, - 0x0106f8a7, - 0x062a0000, - 0xfefaf8a7, - 0x08b8f6f8, - 0xf39603d3, - 0xf9d6fba4, - 0xfc4e09f8, - 0xf7480a6a, - 0x07b2f841, - 0x062af9d6, - 0xf84e07bf, - 0xf7480a6a, - 0x03b2f608, - 0xf9d6fba4, - 0x0c6afc2d, - 0x08b8f6f8, - 0x01060759, - 0x061c061c, - 0xff30009d, - 0xffb21141, - 0xfd87fb54, - 0xf65dfe59, - 0x02eef99e, - 0x0166f03c, - 0xfff809b6, - 0x000008a4, - 0x000af42b, - 0x00eff577, - 0xfa840bf2, - 0xfc02ff51, - 0x08260f67, - 0xfff0036f, - 0x0842f9c3, - 0x00000000, - 0x063df7be, - 0xfc910010, - 0xf099f7da, - 0x00af03fe, - 0xf40e057c, - 0x0a89ff11, - 0x0bd5fff6, - 0xf75c0000, - 0xf64a0008, - 0x0fc4fe9a, - 0x0662fd12, - 0x01a709a3, - 0x04ac0279, - 0xeebf004e, - 0xff6300d0, - 0xf9e4f9e4, - 0x00d0ff63, - 0x004eeebf, - 0x027904ac, - 0x09a301a7, - 0xfd120662, - 0xfe9a0fc4, - 0x0008f64a, - 0x0000f75c, - 0xfff60bd5, - 0xff110a89, - 0x057cf40e, - 0x03fe00af, - 0xf7daf099, - 0x0010fc91, - 0xf7be063d, - 0x00000000, - 0xf9c30842, - 0x036ffff0, - 0x0f670826, - 0xff51fc02, - 0x0bf2fa84, - 0xf57700ef, - 0xf42b000a, - 0x08a40000, - 0x09b6fff8, - 0xf03c0166, - 0xf99e02ee, - 0xfe59f65d, - 0xfb54fd87, - 0x1141ffb2, - 0x009dff30, - 0x05e30000, - 0xff060705, - 0x085408a0, - 0xf425fc59, - 0xfa1d042a, - 0xfc78f67a, - 0xf7acf60e, - 0x075a0766, - 0x05e305e3, - 0xf8a6f89a, - 0xf7acf60e, - 0x03880986, - 0xfa1d042a, - 0x0bdb03a7, - 0x085408a0, - 0x00faf8fb, - 0x05e30000, - 0xff06f8fb, - 0x0854f760, - 0xf42503a7, - 0xfa1dfbd6, - 0xfc780986, - 0xf7ac09f2, - 0x075af89a, - 0x05e3fa1d, - 0xf8a60766, - 0xf7ac09f2, - 0x0388f67a, - 0xfa1dfbd6, - 0x0bdbfc59, - 0x0854f760, - 0x00fa0705, - 0x05e30000, - 0xff060705, - 0x085408a0, - 0xf425fc59, - 0xfa1d042a, - 0xfc78f67a, - 0xf7acf60e, - 0x075a0766, - 0x05e305e3, - 0xf8a6f89a, - 0xf7acf60e, - 0x03880986, - 0xfa1d042a, - 0x0bdb03a7, - 0x085408a0, - 0x00faf8fb, - 0x05e30000, - 0xff06f8fb, - 0x0854f760, - 0xf42503a7, - 0xfa1dfbd6, - 0xfc780986, - 0xf7ac09f2, - 0x075af89a, - 0x05e3fa1d, - 0xf8a60766, - 0xf7ac09f2, - 0x0388f67a, - 0xfa1dfbd6, - 0x0bdbfc59, - 0x0854f760, - 0x00fa0705, - 0xfa58fa58, - 0xf8f0fe00, - 0x0448073d, - 0xfdc9fe46, - 0xf9910258, - 0x089d0407, - 0xfd5cf71a, - 0x02affde0, - 0x083e0496, - 0xff5a0740, - 0xff7afd97, - 0x00fe01f1, - 0x0009082e, - 0xfa94ff75, - 0xfecdf8ea, - 0xffb0f693, - 0xfd2cfa58, - 0x0433ff16, - 0xfba405dd, - 0xfa610341, - 0x06a606cb, - 0x0039fd2d, - 0x0677fa97, - 0x01fa05e0, - 0xf896003e, - 0x075a068b, - 0x012cfc3e, - 0xfa23f98d, - 0xfc7cfd43, - 0xff90fc0d, - 0x01c10982, - 0x00c601d6, - 0xfd2cfd2c, - 0x01d600c6, - 0x098201c1, - 0xfc0dff90, - 0xfd43fc7c, - 0xf98dfa23, - 0xfc3e012c, - 0x068b075a, - 0x003ef896, - 0x05e001fa, - 0xfa970677, - 0xfd2d0039, - 0x06cb06a6, - 0x0341fa61, - 0x05ddfba4, - 0xff160433, - 0xfa58fd2c, - 0xf693ffb0, - 0xf8eafecd, - 0xff75fa94, - 0x082e0009, - 0x01f100fe, - 0xfd97ff7a, - 0x0740ff5a, - 0x0496083e, - 0xfde002af, - 0xf71afd5c, - 0x0407089d, - 0x0258f991, - 0xfe46fdc9, - 0x073d0448, - 0xfe00f8f0, - 0xfd2cfd2c, - 0xfce00500, - 0xfc09fddc, - 0xfe680157, - 0x04c70571, - 0xfc3aff21, - 0xfcd70228, - 0x056d0277, - 0x0200fe00, - 0x0022f927, - 0xfe3c032b, - 0xfc44ff3c, - 0x03e9fbdb, - 0x04570313, - 0x04c9ff5c, - 0x000d03b8, - 0xfa580000, - 0xfbe900d2, - 0xf9d0fe0b, - 0x0125fdf9, - 0x042501bf, - 0x0328fa2b, - 0xffa902f0, - 0xfa250157, - 0x0200fe00, - 0x03740438, - 0xff0405fd, - 0x030cfe52, - 0x0037fb39, - 0xff6904c5, - 0x04f8fd23, - 0xfd31fc1b, - 0xfd2cfd2c, - 0xfc1bfd31, - 0xfd2304f8, - 0x04c5ff69, - 0xfb390037, - 0xfe52030c, - 0x05fdff04, - 0x04380374, - 0xfe000200, - 0x0157fa25, - 0x02f0ffa9, - 0xfa2b0328, - 0x01bf0425, - 0xfdf90125, - 0xfe0bf9d0, - 0x00d2fbe9, - 0x0000fa58, - 0x03b8000d, - 0xff5c04c9, - 0x03130457, - 0xfbdb03e9, - 0xff3cfc44, - 0x032bfe3c, - 0xf9270022, - 0xfe000200, - 0x0277056d, - 0x0228fcd7, - 0xff21fc3a, - 0x057104c7, - 0x0157fe68, - 0xfddcfc09, - 0x0500fce0, - 0xfd2cfd2c, - 0x0500fce0, - 0xfddcfc09, - 0x0157fe68, - 0x057104c7, - 0xff21fc3a, - 0x0228fcd7, - 0x0277056d, - 0xfe000200, - 0xf9270022, - 0x032bfe3c, - 0xff3cfc44, - 0xfbdb03e9, - 0x03130457, - 0xff5c04c9, - 0x03b8000d, - 0x0000fa58, - 0x00d2fbe9, - 0xfe0bf9d0, - 0xfdf90125, - 0x01bf0425, - 0xfa2b0328, - 0x02f0ffa9, - 0x0157fa25, - 0xfe000200, - 0x04380374, - 0x05fdff04, - 0xfe52030c, - 0xfb390037, - 0x04c5ff69, - 0xfd2304f8, - 0xfc1bfd31, - 0xfd2cfd2c, - 0xfd31fc1b, - 0x04f8fd23, - 0xff6904c5, - 0x0037fb39, - 0x030cfe52, - 0xff0405fd, - 0x03740438, - 0x0200fe00, - 0xfa250157, - 0xffa902f0, - 0x0328fa2b, - 0x042501bf, - 0x0125fdf9, - 0xf9d0fe0b, - 0xfbe900d2, - 0xfa580000, - 0x000d03b8, - 0x04c9ff5c, - 0x04570313, - 0x03e9fbdb, - 0xfc44ff3c, - 0xfe3c032b, - 0x0022f927, - 0x0200fe00, - 0x056d0277, - 0xfcd70228, - 0xfc3aff21, - 0x04c70571, - 0xfe680157, - 0xfc09fddc, - 0xfce00500, - 0x05a80000, - 0xff1006be, - 0x0800084a, - 0xf49cfc7e, - 0xfa580400, - 0xfc9cf6da, - 0xf800f672, - 0x0710071c, - 0x05a805a8, - 0xf8f0f8e4, - 0xf800f672, - 0x03640926, - 0xfa580400, - 0x0b640382, - 0x0800084a, - 0x00f0f942, - 0x05a80000, - 0xff10f942, - 0x0800f7b6, - 0xf49c0382, - 0xfa58fc00, - 0xfc9c0926, - 0xf800098e, - 0x0710f8e4, - 0x05a8fa58, - 0xf8f0071c, - 0xf800098e, - 0x0364f6da, - 0xfa58fc00, - 0x0b64fc7e, - 0x0800f7b6, - 0x00f006be, - 0x05a80000, - 0xff1006be, - 0x0800084a, - 0xf49cfc7e, - 0xfa580400, - 0xfc9cf6da, - 0xf800f672, - 0x0710071c, - 0x05a805a8, - 0xf8f0f8e4, - 0xf800f672, - 0x03640926, - 0xfa580400, - 0x0b640382, - 0x0800084a, - 0x00f0f942, - 0x05a80000, - 0xff10f942, - 0x0800f7b6, - 0xf49c0382, - 0xfa58fc00, - 0xfc9c0926, - 0xf800098e, - 0x0710f8e4, - 0x05a8fa58, - 0xf8f0071c, - 0xf800098e, - 0x0364f6da, - 0xfa58fc00, - 0x0b64fc7e, - 0x0800f7b6, - 0x00f006be, -}; - -const u32 noise_var_tbl_rev3[] = { - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, - 0x02110211, - 0x0000014d, -}; - -static const u16 mcs_tbl_rev3[] = { - 0x0000, - 0x0008, - 0x000a, - 0x0010, - 0x0012, - 0x0019, - 0x001a, - 0x001c, - 0x0080, - 0x0088, - 0x008a, - 0x0090, - 0x0092, - 0x0099, - 0x009a, - 0x009c, - 0x0100, - 0x0108, - 0x010a, - 0x0110, - 0x0112, - 0x0119, - 0x011a, - 0x011c, - 0x0180, - 0x0188, - 0x018a, - 0x0190, - 0x0192, - 0x0199, - 0x019a, - 0x019c, - 0x0000, - 0x0098, - 0x00a0, - 0x00a8, - 0x009a, - 0x00a2, - 0x00aa, - 0x0120, - 0x0128, - 0x0128, - 0x0130, - 0x0138, - 0x0138, - 0x0140, - 0x0122, - 0x012a, - 0x012a, - 0x0132, - 0x013a, - 0x013a, - 0x0142, - 0x01a8, - 0x01b0, - 0x01b8, - 0x01b0, - 0x01b8, - 0x01c0, - 0x01c8, - 0x01c0, - 0x01c8, - 0x01d0, - 0x01d0, - 0x01d8, - 0x01aa, - 0x01b2, - 0x01ba, - 0x01b2, - 0x01ba, - 0x01c2, - 0x01ca, - 0x01c2, - 0x01ca, - 0x01d2, - 0x01d2, - 0x01da, - 0x0001, - 0x0002, - 0x0004, - 0x0009, - 0x000c, - 0x0011, - 0x0014, - 0x0018, - 0x0020, - 0x0021, - 0x0022, - 0x0024, - 0x0081, - 0x0082, - 0x0084, - 0x0089, - 0x008c, - 0x0091, - 0x0094, - 0x0098, - 0x00a0, - 0x00a1, - 0x00a2, - 0x00a4, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, - 0x0007, -}; - -static const u32 tdi_tbl20_ant0_rev3[] = { - 0x00091226, - 0x000a1429, - 0x000b56ad, - 0x000c58b0, - 0x000d5ab3, - 0x000e9cb6, - 0x000f9eba, - 0x0000c13d, - 0x00020301, - 0x00030504, - 0x00040708, - 0x0005090b, - 0x00064b8e, - 0x00095291, - 0x000a5494, - 0x000b9718, - 0x000c9927, - 0x000d9b2a, - 0x000edd2e, - 0x000fdf31, - 0x000101b4, - 0x000243b7, - 0x000345bb, - 0x000447be, - 0x00058982, - 0x00068c05, - 0x00099309, - 0x000a950c, - 0x000bd78f, - 0x000cd992, - 0x000ddb96, - 0x000f1d99, - 0x00005fa8, - 0x0001422c, - 0x0002842f, - 0x00038632, - 0x00048835, - 0x0005ca38, - 0x0006ccbc, - 0x0009d3bf, - 0x000b1603, - 0x000c1806, - 0x000d1a0a, - 0x000e1c0d, - 0x000f5e10, - 0x00008093, - 0x00018297, - 0x0002c49a, - 0x0003c680, - 0x0004c880, - 0x00060b00, - 0x00070d00, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl20_ant1_rev3[] = { - 0x00014b26, - 0x00028d29, - 0x000393ad, - 0x00049630, - 0x0005d833, - 0x0006da36, - 0x00099c3a, - 0x000a9e3d, - 0x000bc081, - 0x000cc284, - 0x000dc488, - 0x000f068b, - 0x0000488e, - 0x00018b91, - 0x0002d214, - 0x0003d418, - 0x0004d6a7, - 0x000618aa, - 0x00071aae, - 0x0009dcb1, - 0x000b1eb4, - 0x000c0137, - 0x000d033b, - 0x000e053e, - 0x000f4702, - 0x00008905, - 0x00020c09, - 0x0003128c, - 0x0004148f, - 0x00051712, - 0x00065916, - 0x00091b19, - 0x000a1d28, - 0x000b5f2c, - 0x000c41af, - 0x000d43b2, - 0x000e85b5, - 0x000f87b8, - 0x0000c9bc, - 0x00024cbf, - 0x00035303, - 0x00045506, - 0x0005978a, - 0x0006998d, - 0x00095b90, - 0x000a5d93, - 0x000b9f97, - 0x000c821a, - 0x000d8400, - 0x000ec600, - 0x000fc800, - 0x00010a00, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl40_ant0_rev3[] = { - 0x0011a346, - 0x00136ccf, - 0x0014f5d9, - 0x001641e2, - 0x0017cb6b, - 0x00195475, - 0x001b2383, - 0x001cad0c, - 0x001e7616, - 0x0000821f, - 0x00020ba8, - 0x0003d4b2, - 0x00056447, - 0x00072dd0, - 0x0008b6da, - 0x000a02e3, - 0x000b8c6c, - 0x000d15f6, - 0x0011e484, - 0x0013ae0d, - 0x00153717, - 0x00168320, - 0x00180ca9, - 0x00199633, - 0x001b6548, - 0x001ceed1, - 0x001eb7db, - 0x0000c3e4, - 0x00024d6d, - 0x000416f7, - 0x0005a585, - 0x00076f0f, - 0x0008f818, - 0x000a4421, - 0x000bcdab, - 0x000d9734, - 0x00122649, - 0x0013efd2, - 0x001578dc, - 0x0016c4e5, - 0x00184e6e, - 0x001a17f8, - 0x001ba686, - 0x001d3010, - 0x001ef999, - 0x00010522, - 0x00028eac, - 0x00045835, - 0x0005e74a, - 0x0007b0d3, - 0x00093a5d, - 0x000a85e6, - 0x000c0f6f, - 0x000dd8f9, - 0x00126787, - 0x00143111, - 0x0015ba9a, - 0x00170623, - 0x00188fad, - 0x001a5936, - 0x001be84b, - 0x001db1d4, - 0x001f3b5e, - 0x000146e7, - 0x00031070, - 0x000499fa, - 0x00062888, - 0x0007f212, - 0x00097b9b, - 0x000ac7a4, - 0x000c50ae, - 0x000e1a37, - 0x0012a94c, - 0x001472d5, - 0x0015fc5f, - 0x00174868, - 0x0018d171, - 0x001a9afb, - 0x001c2989, - 0x001df313, - 0x001f7c9c, - 0x000188a5, - 0x000351af, - 0x0004db38, - 0x0006aa4d, - 0x000833d7, - 0x0009bd60, - 0x000b0969, - 0x000c9273, - 0x000e5bfc, - 0x00132a8a, - 0x0014b414, - 0x00163d9d, - 0x001789a6, - 0x001912b0, - 0x001adc39, - 0x001c6bce, - 0x001e34d8, - 0x001fbe61, - 0x0001ca6a, - 0x00039374, - 0x00051cfd, - 0x0006ec0b, - 0x00087515, - 0x0009fe9e, - 0x000b4aa7, - 0x000cd3b1, - 0x000e9d3a, - 0x00000000, - 0x00000000, -}; - -static const u32 tdi_tbl40_ant1_rev3[] = { - 0x001edb36, - 0x000129ca, - 0x0002b353, - 0x00047cdd, - 0x0005c8e6, - 0x000791ef, - 0x00091bf9, - 0x000aaa07, - 0x000c3391, - 0x000dfd1a, - 0x00120923, - 0x0013d22d, - 0x00155c37, - 0x0016eacb, - 0x00187454, - 0x001a3dde, - 0x001b89e7, - 0x001d12f0, - 0x001f1cfa, - 0x00016b88, - 0x00033492, - 0x0004be1b, - 0x00060a24, - 0x0007d32e, - 0x00095d38, - 0x000aec4c, - 0x000c7555, - 0x000e3edf, - 0x00124ae8, - 0x001413f1, - 0x0015a37b, - 0x00172c89, - 0x0018b593, - 0x001a419c, - 0x001bcb25, - 0x001d942f, - 0x001f63b9, - 0x0001ad4d, - 0x00037657, - 0x0004c260, - 0x00068be9, - 0x000814f3, - 0x0009a47c, - 0x000b2d8a, - 0x000cb694, - 0x000e429d, - 0x00128c26, - 0x001455b0, - 0x0015e4ba, - 0x00176e4e, - 0x0018f758, - 0x001a8361, - 0x001c0cea, - 0x001dd674, - 0x001fa57d, - 0x0001ee8b, - 0x0003b795, - 0x0005039e, - 0x0006cd27, - 0x000856b1, - 0x0009e5c6, - 0x000b6f4f, - 0x000cf859, - 0x000e8462, - 0x00130deb, - 0x00149775, - 0x00162603, - 0x0017af8c, - 0x00193896, - 0x001ac49f, - 0x001c4e28, - 0x001e17b2, - 0x0000a6c7, - 0x00023050, - 0x0003f9da, - 0x00054563, - 0x00070eec, - 0x00089876, - 0x000a2704, - 0x000bb08d, - 0x000d3a17, - 0x001185a0, - 0x00134f29, - 0x0014d8b3, - 0x001667c8, - 0x0017f151, - 0x00197adb, - 0x001b0664, - 0x001c8fed, - 0x001e5977, - 0x0000e805, - 0x0002718f, - 0x00043b18, - 0x000586a1, - 0x0007502b, - 0x0008d9b4, - 0x000a68c9, - 0x000bf252, - 0x000dbbdc, - 0x0011c7e5, - 0x001390ee, - 0x00151a78, - 0x0016a906, - 0x00183290, - 0x0019bc19, - 0x001b4822, - 0x001cd12c, - 0x001e9ab5, - 0x00000000, - 0x00000000, -}; - -static const u32 pltlut_tbl_rev3[] = { - 0x76540213, - 0x62407351, - 0x76543210, - 0x76540213, - 0x76540213, - 0x76430521, -}; - -static const u32 chanest_tbl_rev3[] = { - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x44444444, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, - 0x10101010, -}; - -static const u8 frame_lut_rev3[] = { - 0x02, - 0x04, - 0x14, - 0x14, - 0x03, - 0x05, - 0x16, - 0x16, - 0x0a, - 0x0c, - 0x1c, - 0x1c, - 0x0b, - 0x0d, - 0x1e, - 0x1e, - 0x06, - 0x08, - 0x18, - 0x18, - 0x07, - 0x09, - 0x1a, - 0x1a, - 0x0e, - 0x10, - 0x20, - 0x28, - 0x0f, - 0x11, - 0x22, - 0x2a, -}; - -static const u8 est_pwr_lut_core0_rev3[] = { - 0x55, - 0x54, - 0x54, - 0x53, - 0x52, - 0x52, - 0x51, - 0x51, - 0x50, - 0x4f, - 0x4f, - 0x4e, - 0x4e, - 0x4d, - 0x4c, - 0x4c, - 0x4b, - 0x4a, - 0x49, - 0x49, - 0x48, - 0x47, - 0x46, - 0x46, - 0x45, - 0x44, - 0x43, - 0x42, - 0x41, - 0x40, - 0x40, - 0x3f, - 0x3e, - 0x3d, - 0x3c, - 0x3a, - 0x39, - 0x38, - 0x37, - 0x36, - 0x35, - 0x33, - 0x32, - 0x31, - 0x2f, - 0x2e, - 0x2c, - 0x2b, - 0x29, - 0x27, - 0x25, - 0x23, - 0x21, - 0x1f, - 0x1d, - 0x1a, - 0x18, - 0x15, - 0x12, - 0x0e, - 0x0b, - 0x07, - 0x02, - 0xfd, -}; - -static const u8 est_pwr_lut_core1_rev3[] = { - 0x55, - 0x54, - 0x54, - 0x53, - 0x52, - 0x52, - 0x51, - 0x51, - 0x50, - 0x4f, - 0x4f, - 0x4e, - 0x4e, - 0x4d, - 0x4c, - 0x4c, - 0x4b, - 0x4a, - 0x49, - 0x49, - 0x48, - 0x47, - 0x46, - 0x46, - 0x45, - 0x44, - 0x43, - 0x42, - 0x41, - 0x40, - 0x40, - 0x3f, - 0x3e, - 0x3d, - 0x3c, - 0x3a, - 0x39, - 0x38, - 0x37, - 0x36, - 0x35, - 0x33, - 0x32, - 0x31, - 0x2f, - 0x2e, - 0x2c, - 0x2b, - 0x29, - 0x27, - 0x25, - 0x23, - 0x21, - 0x1f, - 0x1d, - 0x1a, - 0x18, - 0x15, - 0x12, - 0x0e, - 0x0b, - 0x07, - 0x02, - 0xfd, -}; - -static const u8 adj_pwr_lut_core0_rev3[] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; - -static const u8 adj_pwr_lut_core1_rev3[] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; - -static const u32 gainctrl_lut_core0_rev3[] = { - 0x5bf70044, - 0x5bf70042, - 0x5bf70040, - 0x5bf7003e, - 0x5bf7003c, - 0x5bf7003b, - 0x5bf70039, - 0x5bf70037, - 0x5bf70036, - 0x5bf70034, - 0x5bf70033, - 0x5bf70031, - 0x5bf70030, - 0x5ba70044, - 0x5ba70042, - 0x5ba70040, - 0x5ba7003e, - 0x5ba7003c, - 0x5ba7003b, - 0x5ba70039, - 0x5ba70037, - 0x5ba70036, - 0x5ba70034, - 0x5ba70033, - 0x5b770044, - 0x5b770042, - 0x5b770040, - 0x5b77003e, - 0x5b77003c, - 0x5b77003b, - 0x5b770039, - 0x5b770037, - 0x5b770036, - 0x5b770034, - 0x5b770033, - 0x5b770031, - 0x5b770030, - 0x5b77002f, - 0x5b77002d, - 0x5b77002c, - 0x5b470044, - 0x5b470042, - 0x5b470040, - 0x5b47003e, - 0x5b47003c, - 0x5b47003b, - 0x5b470039, - 0x5b470037, - 0x5b470036, - 0x5b470034, - 0x5b470033, - 0x5b470031, - 0x5b470030, - 0x5b47002f, - 0x5b47002d, - 0x5b47002c, - 0x5b47002b, - 0x5b47002a, - 0x5b270044, - 0x5b270042, - 0x5b270040, - 0x5b27003e, - 0x5b27003c, - 0x5b27003b, - 0x5b270039, - 0x5b270037, - 0x5b270036, - 0x5b270034, - 0x5b270033, - 0x5b270031, - 0x5b270030, - 0x5b27002f, - 0x5b170044, - 0x5b170042, - 0x5b170040, - 0x5b17003e, - 0x5b17003c, - 0x5b17003b, - 0x5b170039, - 0x5b170037, - 0x5b170036, - 0x5b170034, - 0x5b170033, - 0x5b170031, - 0x5b170030, - 0x5b17002f, - 0x5b17002d, - 0x5b17002c, - 0x5b17002b, - 0x5b17002a, - 0x5b170028, - 0x5b170027, - 0x5b170026, - 0x5b170025, - 0x5b170024, - 0x5b170023, - 0x5b070044, - 0x5b070042, - 0x5b070040, - 0x5b07003e, - 0x5b07003c, - 0x5b07003b, - 0x5b070039, - 0x5b070037, - 0x5b070036, - 0x5b070034, - 0x5b070033, - 0x5b070031, - 0x5b070030, - 0x5b07002f, - 0x5b07002d, - 0x5b07002c, - 0x5b07002b, - 0x5b07002a, - 0x5b070028, - 0x5b070027, - 0x5b070026, - 0x5b070025, - 0x5b070024, - 0x5b070023, - 0x5b070022, - 0x5b070021, - 0x5b070020, - 0x5b07001f, - 0x5b07001e, - 0x5b07001d, - 0x5b07001d, - 0x5b07001c, -}; - -static const u32 gainctrl_lut_core1_rev3[] = { - 0x5bf70044, - 0x5bf70042, - 0x5bf70040, - 0x5bf7003e, - 0x5bf7003c, - 0x5bf7003b, - 0x5bf70039, - 0x5bf70037, - 0x5bf70036, - 0x5bf70034, - 0x5bf70033, - 0x5bf70031, - 0x5bf70030, - 0x5ba70044, - 0x5ba70042, - 0x5ba70040, - 0x5ba7003e, - 0x5ba7003c, - 0x5ba7003b, - 0x5ba70039, - 0x5ba70037, - 0x5ba70036, - 0x5ba70034, - 0x5ba70033, - 0x5b770044, - 0x5b770042, - 0x5b770040, - 0x5b77003e, - 0x5b77003c, - 0x5b77003b, - 0x5b770039, - 0x5b770037, - 0x5b770036, - 0x5b770034, - 0x5b770033, - 0x5b770031, - 0x5b770030, - 0x5b77002f, - 0x5b77002d, - 0x5b77002c, - 0x5b470044, - 0x5b470042, - 0x5b470040, - 0x5b47003e, - 0x5b47003c, - 0x5b47003b, - 0x5b470039, - 0x5b470037, - 0x5b470036, - 0x5b470034, - 0x5b470033, - 0x5b470031, - 0x5b470030, - 0x5b47002f, - 0x5b47002d, - 0x5b47002c, - 0x5b47002b, - 0x5b47002a, - 0x5b270044, - 0x5b270042, - 0x5b270040, - 0x5b27003e, - 0x5b27003c, - 0x5b27003b, - 0x5b270039, - 0x5b270037, - 0x5b270036, - 0x5b270034, - 0x5b270033, - 0x5b270031, - 0x5b270030, - 0x5b27002f, - 0x5b170044, - 0x5b170042, - 0x5b170040, - 0x5b17003e, - 0x5b17003c, - 0x5b17003b, - 0x5b170039, - 0x5b170037, - 0x5b170036, - 0x5b170034, - 0x5b170033, - 0x5b170031, - 0x5b170030, - 0x5b17002f, - 0x5b17002d, - 0x5b17002c, - 0x5b17002b, - 0x5b17002a, - 0x5b170028, - 0x5b170027, - 0x5b170026, - 0x5b170025, - 0x5b170024, - 0x5b170023, - 0x5b070044, - 0x5b070042, - 0x5b070040, - 0x5b07003e, - 0x5b07003c, - 0x5b07003b, - 0x5b070039, - 0x5b070037, - 0x5b070036, - 0x5b070034, - 0x5b070033, - 0x5b070031, - 0x5b070030, - 0x5b07002f, - 0x5b07002d, - 0x5b07002c, - 0x5b07002b, - 0x5b07002a, - 0x5b070028, - 0x5b070027, - 0x5b070026, - 0x5b070025, - 0x5b070024, - 0x5b070023, - 0x5b070022, - 0x5b070021, - 0x5b070020, - 0x5b07001f, - 0x5b07001e, - 0x5b07001d, - 0x5b07001d, - 0x5b07001c, -}; - -static const u32 iq_lut_core0_rev3[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u32 iq_lut_core1_rev3[] = { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -static const u16 loft_lut_core0_rev3[] = { - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u16 loft_lut_core1_rev3[] = { - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, -}; - -static const u16 papd_comp_rfpwr_tbl_core0_rev3[] = { - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, -}; - -static const u16 papd_comp_rfpwr_tbl_core1_rev3[] = { - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x0036, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x002a, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x001e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x000e, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01fc, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01ee, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, - 0x01d6, -}; - -static const u32 papd_comp_epsilon_tbl_core0_rev3[] = { - 0x00000000, - 0x00001fa0, - 0x00019f78, - 0x0001df7e, - 0x03fa9f86, - 0x03fd1f90, - 0x03fe5f8a, - 0x03fb1f94, - 0x03fd9fa0, - 0x00009f98, - 0x03fd1fac, - 0x03ff9fa2, - 0x03fe9fae, - 0x00001fae, - 0x03fddfb4, - 0x03ff1fb8, - 0x03ff9fbc, - 0x03ffdfbe, - 0x03fe9fc2, - 0x03fedfc6, - 0x03fedfc6, - 0x03ff9fc8, - 0x03ff5fc6, - 0x03fedfc2, - 0x03ff9fc0, - 0x03ff5fac, - 0x03ff5fac, - 0x03ff9fa2, - 0x03ff9fa6, - 0x03ff9faa, - 0x03ff5fb0, - 0x03ff5fb4, - 0x03ff1fca, - 0x03ff5fce, - 0x03fcdfdc, - 0x03fb4006, - 0x00000030, - 0x03ff808a, - 0x03ff80da, - 0x0000016c, - 0x03ff8318, - 0x03ff063a, - 0x03fd8bd6, - 0x00014ffe, - 0x00034ffe, - 0x00034ffe, - 0x0003cffe, - 0x00040ffe, - 0x00040ffe, - 0x0003cffe, - 0x0003cffe, - 0x00020ffe, - 0x03fe0ffe, - 0x03fdcffe, - 0x03f94ffe, - 0x03f54ffe, - 0x03f44ffe, - 0x03ef8ffe, - 0x03ee0ffe, - 0x03ebcffe, - 0x03e8cffe, - 0x03e74ffe, - 0x03e4cffe, - 0x03e38ffe, -}; - -static const u32 papd_cal_scalars_tbl_core0_rev3[] = { - 0x05af005a, - 0x0571005e, - 0x05040066, - 0x04bd006c, - 0x047d0072, - 0x04430078, - 0x03f70081, - 0x03cb0087, - 0x03870091, - 0x035e0098, - 0x032e00a1, - 0x030300aa, - 0x02d800b4, - 0x02ae00bf, - 0x028900ca, - 0x026400d6, - 0x024100e3, - 0x022200f0, - 0x020200ff, - 0x01e5010e, - 0x01ca011e, - 0x01b0012f, - 0x01990140, - 0x01830153, - 0x016c0168, - 0x0158017d, - 0x01450193, - 0x013301ab, - 0x012101c5, - 0x011101e0, - 0x010201fc, - 0x00f4021a, - 0x00e6011d, - 0x00d9012e, - 0x00cd0140, - 0x00c20153, - 0x00b70167, - 0x00ac017c, - 0x00a30193, - 0x009a01ab, - 0x009101c4, - 0x008901df, - 0x008101fb, - 0x007a0219, - 0x00730239, - 0x006d025b, - 0x0067027e, - 0x006102a4, - 0x005c02cc, - 0x005602f6, - 0x00520323, - 0x004d0353, - 0x00490385, - 0x004503bb, - 0x004103f3, - 0x003d042f, - 0x003a046f, - 0x003704b2, - 0x003404f9, - 0x00310545, - 0x002e0596, - 0x002b05f5, - 0x00290640, - 0x002606a4, -}; - -static const u32 papd_comp_epsilon_tbl_core1_rev3[] = { - 0x00000000, - 0x00001fa0, - 0x00019f78, - 0x0001df7e, - 0x03fa9f86, - 0x03fd1f90, - 0x03fe5f8a, - 0x03fb1f94, - 0x03fd9fa0, - 0x00009f98, - 0x03fd1fac, - 0x03ff9fa2, - 0x03fe9fae, - 0x00001fae, - 0x03fddfb4, - 0x03ff1fb8, - 0x03ff9fbc, - 0x03ffdfbe, - 0x03fe9fc2, - 0x03fedfc6, - 0x03fedfc6, - 0x03ff9fc8, - 0x03ff5fc6, - 0x03fedfc2, - 0x03ff9fc0, - 0x03ff5fac, - 0x03ff5fac, - 0x03ff9fa2, - 0x03ff9fa6, - 0x03ff9faa, - 0x03ff5fb0, - 0x03ff5fb4, - 0x03ff1fca, - 0x03ff5fce, - 0x03fcdfdc, - 0x03fb4006, - 0x00000030, - 0x03ff808a, - 0x03ff80da, - 0x0000016c, - 0x03ff8318, - 0x03ff063a, - 0x03fd8bd6, - 0x00014ffe, - 0x00034ffe, - 0x00034ffe, - 0x0003cffe, - 0x00040ffe, - 0x00040ffe, - 0x0003cffe, - 0x0003cffe, - 0x00020ffe, - 0x03fe0ffe, - 0x03fdcffe, - 0x03f94ffe, - 0x03f54ffe, - 0x03f44ffe, - 0x03ef8ffe, - 0x03ee0ffe, - 0x03ebcffe, - 0x03e8cffe, - 0x03e74ffe, - 0x03e4cffe, - 0x03e38ffe, -}; - -static const u32 papd_cal_scalars_tbl_core1_rev3[] = { - 0x05af005a, - 0x0571005e, - 0x05040066, - 0x04bd006c, - 0x047d0072, - 0x04430078, - 0x03f70081, - 0x03cb0087, - 0x03870091, - 0x035e0098, - 0x032e00a1, - 0x030300aa, - 0x02d800b4, - 0x02ae00bf, - 0x028900ca, - 0x026400d6, - 0x024100e3, - 0x022200f0, - 0x020200ff, - 0x01e5010e, - 0x01ca011e, - 0x01b0012f, - 0x01990140, - 0x01830153, - 0x016c0168, - 0x0158017d, - 0x01450193, - 0x013301ab, - 0x012101c5, - 0x011101e0, - 0x010201fc, - 0x00f4021a, - 0x00e6011d, - 0x00d9012e, - 0x00cd0140, - 0x00c20153, - 0x00b70167, - 0x00ac017c, - 0x00a30193, - 0x009a01ab, - 0x009101c4, - 0x008901df, - 0x008101fb, - 0x007a0219, - 0x00730239, - 0x006d025b, - 0x0067027e, - 0x006102a4, - 0x005c02cc, - 0x005602f6, - 0x00520323, - 0x004d0353, - 0x00490385, - 0x004503bb, - 0x004103f3, - 0x003d042f, - 0x003a046f, - 0x003704b2, - 0x003404f9, - 0x00310545, - 0x002e0596, - 0x002b05f5, - 0x00290640, - 0x002606a4, -}; - -const struct phytbl_info mimophytbl_info_rev3_volatile[] = { - {&ant_swctrl_tbl_rev3, - sizeof(ant_swctrl_tbl_rev3) / sizeof(ant_swctrl_tbl_rev3[0]), 9, 0, 16} - , -}; - -const struct phytbl_info mimophytbl_info_rev3_volatile1[] = { - {&ant_swctrl_tbl_rev3_1, - sizeof(ant_swctrl_tbl_rev3_1) / sizeof(ant_swctrl_tbl_rev3_1[0]), 9, 0, - 16} - , -}; - -const struct phytbl_info mimophytbl_info_rev3_volatile2[] = { - {&ant_swctrl_tbl_rev3_2, - sizeof(ant_swctrl_tbl_rev3_2) / sizeof(ant_swctrl_tbl_rev3_2[0]), 9, 0, - 16} - , -}; - -const struct phytbl_info mimophytbl_info_rev3_volatile3[] = { - {&ant_swctrl_tbl_rev3_3, - sizeof(ant_swctrl_tbl_rev3_3) / sizeof(ant_swctrl_tbl_rev3_3[0]), 9, 0, - 16} - , -}; - -const struct phytbl_info mimophytbl_info_rev3[] = { - {&frame_struct_rev3, - sizeof(frame_struct_rev3) / sizeof(frame_struct_rev3[0]), 10, 0, 32} - , - {&pilot_tbl_rev3, sizeof(pilot_tbl_rev3) / sizeof(pilot_tbl_rev3[0]), - 11, 0, 16} - , - {&tmap_tbl_rev3, sizeof(tmap_tbl_rev3) / sizeof(tmap_tbl_rev3[0]), 12, - 0, 32} - , - {&intlv_tbl_rev3, sizeof(intlv_tbl_rev3) / sizeof(intlv_tbl_rev3[0]), - 13, 0, 32} - , - {&tdtrn_tbl_rev3, sizeof(tdtrn_tbl_rev3) / sizeof(tdtrn_tbl_rev3[0]), - 14, 0, 32} - , - {&noise_var_tbl_rev3, - sizeof(noise_var_tbl_rev3) / sizeof(noise_var_tbl_rev3[0]), 16, 0, 32} - , - {&mcs_tbl_rev3, sizeof(mcs_tbl_rev3) / sizeof(mcs_tbl_rev3[0]), 18, 0, - 16} - , - {&tdi_tbl20_ant0_rev3, - sizeof(tdi_tbl20_ant0_rev3) / sizeof(tdi_tbl20_ant0_rev3[0]), 19, 128, - 32} - , - {&tdi_tbl20_ant1_rev3, - sizeof(tdi_tbl20_ant1_rev3) / sizeof(tdi_tbl20_ant1_rev3[0]), 19, 256, - 32} - , - {&tdi_tbl40_ant0_rev3, - sizeof(tdi_tbl40_ant0_rev3) / sizeof(tdi_tbl40_ant0_rev3[0]), 19, 640, - 32} - , - {&tdi_tbl40_ant1_rev3, - sizeof(tdi_tbl40_ant1_rev3) / sizeof(tdi_tbl40_ant1_rev3[0]), 19, 768, - 32} - , - {&pltlut_tbl_rev3, sizeof(pltlut_tbl_rev3) / sizeof(pltlut_tbl_rev3[0]), - 20, 0, 32} - , - {&chanest_tbl_rev3, - sizeof(chanest_tbl_rev3) / sizeof(chanest_tbl_rev3[0]), 22, 0, 32} - , - {&frame_lut_rev3, sizeof(frame_lut_rev3) / sizeof(frame_lut_rev3[0]), - 24, 0, 8} - , - {&est_pwr_lut_core0_rev3, - sizeof(est_pwr_lut_core0_rev3) / sizeof(est_pwr_lut_core0_rev3[0]), 26, - 0, 8} - , - {&est_pwr_lut_core1_rev3, - sizeof(est_pwr_lut_core1_rev3) / sizeof(est_pwr_lut_core1_rev3[0]), 27, - 0, 8} - , - {&adj_pwr_lut_core0_rev3, - sizeof(adj_pwr_lut_core0_rev3) / sizeof(adj_pwr_lut_core0_rev3[0]), 26, - 64, 8} - , - {&adj_pwr_lut_core1_rev3, - sizeof(adj_pwr_lut_core1_rev3) / sizeof(adj_pwr_lut_core1_rev3[0]), 27, - 64, 8} - , - {&gainctrl_lut_core0_rev3, - sizeof(gainctrl_lut_core0_rev3) / sizeof(gainctrl_lut_core0_rev3[0]), - 26, 192, 32} - , - {&gainctrl_lut_core1_rev3, - sizeof(gainctrl_lut_core1_rev3) / sizeof(gainctrl_lut_core1_rev3[0]), - 27, 192, 32} - , - {&iq_lut_core0_rev3, - sizeof(iq_lut_core0_rev3) / sizeof(iq_lut_core0_rev3[0]), 26, 320, 32} - , - {&iq_lut_core1_rev3, - sizeof(iq_lut_core1_rev3) / sizeof(iq_lut_core1_rev3[0]), 27, 320, 32} - , - {&loft_lut_core0_rev3, - sizeof(loft_lut_core0_rev3) / sizeof(loft_lut_core0_rev3[0]), 26, 448, - 16} - , - {&loft_lut_core1_rev3, - sizeof(loft_lut_core1_rev3) / sizeof(loft_lut_core1_rev3[0]), 27, 448, - 16} -}; - -const u32 mimophytbl_info_sz_rev3 = - sizeof(mimophytbl_info_rev3) / sizeof(mimophytbl_info_rev3[0]); -const u32 mimophytbl_info_sz_rev3_volatile = - sizeof(mimophytbl_info_rev3_volatile) / - sizeof(mimophytbl_info_rev3_volatile[0]); -const u32 mimophytbl_info_sz_rev3_volatile1 = - sizeof(mimophytbl_info_rev3_volatile1) / - sizeof(mimophytbl_info_rev3_volatile1[0]); -const u32 mimophytbl_info_sz_rev3_volatile2 = - sizeof(mimophytbl_info_rev3_volatile2) / - sizeof(mimophytbl_info_rev3_volatile2[0]); -const u32 mimophytbl_info_sz_rev3_volatile3 = - sizeof(mimophytbl_info_rev3_volatile3) / - sizeof(mimophytbl_info_rev3_volatile3[0]); - -static const u32 tmap_tbl_rev7[] = { - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x000aa888, - 0x88880000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00011111, - 0x11110000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00088aaa, - 0xaaaa0000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xaaa8aaa0, - 0x8aaa8aaa, - 0xaa8a8a8a, - 0x000aaa88, - 0x8aaa0000, - 0xaaa8a888, - 0x8aa88a8a, - 0x8a88a888, - 0x08080a00, - 0x0a08080a, - 0x080a0a08, - 0x00080808, - 0x080a0000, - 0x080a0808, - 0x080a0808, - 0x0a0a0a08, - 0xa0a0a0a0, - 0x80a0a080, - 0x8080a0a0, - 0x00008080, - 0x80a00000, - 0x80a080a0, - 0xa080a0a0, - 0x8080a0a0, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x99999000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x22000000, - 0x2222b222, - 0x22222222, - 0x222222b2, - 0xb2222220, - 0x22222222, - 0x22d22222, - 0x00000222, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x33000000, - 0x3333b333, - 0x33333333, - 0x333333b3, - 0xb3333330, - 0x33333333, - 0x33d33333, - 0x00000333, - 0x22000000, - 0x2222a222, - 0x22222222, - 0x222222a2, - 0xa2222220, - 0x22222222, - 0x22c22222, - 0x00000222, - 0x99b99b00, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb99, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x22222200, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0x22222222, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x11111111, - 0xf1111111, - 0x11111111, - 0x11f11111, - 0x01111111, - 0xbb9bb900, - 0xb9b9bb99, - 0xb99bbbbb, - 0xbbbb9b9b, - 0xb9bb99bb, - 0xb99999b9, - 0xb9b9b99b, - 0x00000bbb, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88aa, - 0xa88888a8, - 0xa8a8a88a, - 0x0a888aaa, - 0xaa000000, - 0xa8a8aa88, - 0xa88aaaaa, - 0xaaaa8a8a, - 0xa8aa88a0, - 0xa88888a8, - 0xa8a8a88a, - 0x00000aaa, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0xbbbbbb00, - 0x999bbbbb, - 0x9bb99b9b, - 0xb9b9b9bb, - 0xb9b99bbb, - 0xb9b9b9bb, - 0xb9bb9b99, - 0x00000999, - 0x8a000000, - 0xaa88a888, - 0xa88888aa, - 0xa88a8a88, - 0xa88aa88a, - 0x88a8aaaa, - 0xa8aa8aaa, - 0x0888a88a, - 0x0b0b0b00, - 0x090b0b0b, - 0x0b090b0b, - 0x0909090b, - 0x09090b0b, - 0x09090b0b, - 0x09090b09, - 0x00000909, - 0x0a000000, - 0x0a080808, - 0x080a080a, - 0x080a0a08, - 0x080a080a, - 0x0808080a, - 0x0a0a0a08, - 0x0808080a, - 0xb0b0b000, - 0x9090b0b0, - 0x90b09090, - 0xb0b0b090, - 0xb0b090b0, - 0x90b0b0b0, - 0xb0b09090, - 0x00000090, - 0x80000000, - 0xa080a080, - 0xa08080a0, - 0xa0808080, - 0xa080a080, - 0x80a0a0a0, - 0xa0a080a0, - 0x00a0a0a0, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x11000000, - 0x1111f111, - 0x11111111, - 0x111111f1, - 0xf1111110, - 0x11111111, - 0x11f11111, - 0x00000111, - 0x33000000, - 0x3333f333, - 0x33333333, - 0x333333f3, - 0xf3333330, - 0x33333333, - 0x33f33333, - 0x00000333, - 0x22000000, - 0x2222f222, - 0x22222222, - 0x222222f2, - 0xf2222220, - 0x22222222, - 0x22f22222, - 0x00000222, - 0x99000000, - 0x9b9b99bb, - 0x9bb99999, - 0x9999b9b9, - 0x9b99bb90, - 0x9bbbbb9b, - 0x9b9b9bb9, - 0x00000999, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88888000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00aaa888, - 0x88a88a00, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x000aa888, - 0x88880000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa88, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x08aaa888, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x11000000, - 0x1111a111, - 0x11111111, - 0x111111a1, - 0xa1111110, - 0x11111111, - 0x11c11111, - 0x00000111, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x88000000, - 0x8a8a88aa, - 0x8aa88888, - 0x8888a8a8, - 0x8a88aa80, - 0x8aaaaa8a, - 0x8a8a8aa8, - 0x00000888, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; - -const u32 noise_var_tbl_rev7[] = { - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, - 0x020c020c, - 0x0000014d, -}; - -static const u32 papd_comp_epsilon_tbl_core0_rev7[] = { - 0x00000000, - 0x00000000, - 0x00016023, - 0x00006028, - 0x00034036, - 0x0003402e, - 0x0007203c, - 0x0006e037, - 0x00070030, - 0x0009401f, - 0x0009a00f, - 0x000b600d, - 0x000c8007, - 0x000ce007, - 0x00101fff, - 0x00121ff9, - 0x0012e004, - 0x0014dffc, - 0x0016dff6, - 0x0018dfe9, - 0x001b3fe5, - 0x001c5fd0, - 0x001ddfc2, - 0x001f1fb6, - 0x00207fa4, - 0x00219f8f, - 0x0022ff7d, - 0x00247f6c, - 0x0024df5b, - 0x00267f4b, - 0x0027df3b, - 0x0029bf3b, - 0x002b5f2f, - 0x002d3f2e, - 0x002f5f2a, - 0x002fff15, - 0x00315f0b, - 0x0032defa, - 0x0033beeb, - 0x0034fed9, - 0x00353ec5, - 0x00361eb0, - 0x00363e9b, - 0x0036be87, - 0x0036be70, - 0x0038fe67, - 0x0044beb2, - 0x00513ef3, - 0x00595f11, - 0x00669f3d, - 0x0078dfdf, - 0x00a143aa, - 0x01642fff, - 0x0162afff, - 0x01620fff, - 0x0160cfff, - 0x015f0fff, - 0x015dafff, - 0x015bcfff, - 0x015bcfff, - 0x015b4fff, - 0x015acfff, - 0x01590fff, - 0x0156cfff, -}; - -static const u32 papd_cal_scalars_tbl_core0_rev7[] = { - 0x0b5e002d, - 0x0ae2002f, - 0x0a3b0032, - 0x09a70035, - 0x09220038, - 0x08ab003b, - 0x081f003f, - 0x07a20043, - 0x07340047, - 0x06d2004b, - 0x067a004f, - 0x06170054, - 0x05bf0059, - 0x0571005e, - 0x051e0064, - 0x04d3006a, - 0x04910070, - 0x044c0077, - 0x040f007e, - 0x03d90085, - 0x03a1008d, - 0x036f0095, - 0x033d009e, - 0x030b00a8, - 0x02e000b2, - 0x02b900bc, - 0x029200c7, - 0x026d00d3, - 0x024900e0, - 0x022900ed, - 0x020a00fb, - 0x01ec010a, - 0x01d20119, - 0x01b7012a, - 0x019e013c, - 0x0188014e, - 0x01720162, - 0x015d0177, - 0x0149018e, - 0x013701a5, - 0x012601be, - 0x011501d8, - 0x010601f4, - 0x00f70212, - 0x00e90231, - 0x00dc0253, - 0x00d00276, - 0x00c4029b, - 0x00b902c3, - 0x00af02ed, - 0x00a50319, - 0x009c0348, - 0x0093037a, - 0x008b03af, - 0x008303e6, - 0x007c0422, - 0x00750460, - 0x006e04a3, - 0x006804e9, - 0x00620533, - 0x005d0582, - 0x005805d6, - 0x0053062e, - 0x004e068c, -}; - -static const u32 papd_comp_epsilon_tbl_core1_rev7[] = { - 0x00000000, - 0x00000000, - 0x00016023, - 0x00006028, - 0x00034036, - 0x0003402e, - 0x0007203c, - 0x0006e037, - 0x00070030, - 0x0009401f, - 0x0009a00f, - 0x000b600d, - 0x000c8007, - 0x000ce007, - 0x00101fff, - 0x00121ff9, - 0x0012e004, - 0x0014dffc, - 0x0016dff6, - 0x0018dfe9, - 0x001b3fe5, - 0x001c5fd0, - 0x001ddfc2, - 0x001f1fb6, - 0x00207fa4, - 0x00219f8f, - 0x0022ff7d, - 0x00247f6c, - 0x0024df5b, - 0x00267f4b, - 0x0027df3b, - 0x0029bf3b, - 0x002b5f2f, - 0x002d3f2e, - 0x002f5f2a, - 0x002fff15, - 0x00315f0b, - 0x0032defa, - 0x0033beeb, - 0x0034fed9, - 0x00353ec5, - 0x00361eb0, - 0x00363e9b, - 0x0036be87, - 0x0036be70, - 0x0038fe67, - 0x0044beb2, - 0x00513ef3, - 0x00595f11, - 0x00669f3d, - 0x0078dfdf, - 0x00a143aa, - 0x01642fff, - 0x0162afff, - 0x01620fff, - 0x0160cfff, - 0x015f0fff, - 0x015dafff, - 0x015bcfff, - 0x015bcfff, - 0x015b4fff, - 0x015acfff, - 0x01590fff, - 0x0156cfff, -}; - -static const u32 papd_cal_scalars_tbl_core1_rev7[] = { - 0x0b5e002d, - 0x0ae2002f, - 0x0a3b0032, - 0x09a70035, - 0x09220038, - 0x08ab003b, - 0x081f003f, - 0x07a20043, - 0x07340047, - 0x06d2004b, - 0x067a004f, - 0x06170054, - 0x05bf0059, - 0x0571005e, - 0x051e0064, - 0x04d3006a, - 0x04910070, - 0x044c0077, - 0x040f007e, - 0x03d90085, - 0x03a1008d, - 0x036f0095, - 0x033d009e, - 0x030b00a8, - 0x02e000b2, - 0x02b900bc, - 0x029200c7, - 0x026d00d3, - 0x024900e0, - 0x022900ed, - 0x020a00fb, - 0x01ec010a, - 0x01d20119, - 0x01b7012a, - 0x019e013c, - 0x0188014e, - 0x01720162, - 0x015d0177, - 0x0149018e, - 0x013701a5, - 0x012601be, - 0x011501d8, - 0x010601f4, - 0x00f70212, - 0x00e90231, - 0x00dc0253, - 0x00d00276, - 0x00c4029b, - 0x00b902c3, - 0x00af02ed, - 0x00a50319, - 0x009c0348, - 0x0093037a, - 0x008b03af, - 0x008303e6, - 0x007c0422, - 0x00750460, - 0x006e04a3, - 0x006804e9, - 0x00620533, - 0x005d0582, - 0x005805d6, - 0x0053062e, - 0x004e068c, -}; - -const struct phytbl_info mimophytbl_info_rev7[] = { - {&frame_struct_rev3, - sizeof(frame_struct_rev3) / sizeof(frame_struct_rev3[0]), 10, 0, 32} - , - {&pilot_tbl_rev3, sizeof(pilot_tbl_rev3) / sizeof(pilot_tbl_rev3[0]), - 11, 0, 16} - , - {&tmap_tbl_rev7, sizeof(tmap_tbl_rev7) / sizeof(tmap_tbl_rev7[0]), 12, - 0, 32} - , - {&intlv_tbl_rev3, sizeof(intlv_tbl_rev3) / sizeof(intlv_tbl_rev3[0]), - 13, 0, 32} - , - {&tdtrn_tbl_rev3, sizeof(tdtrn_tbl_rev3) / sizeof(tdtrn_tbl_rev3[0]), - 14, 0, 32} - , - {&noise_var_tbl_rev7, - sizeof(noise_var_tbl_rev7) / sizeof(noise_var_tbl_rev7[0]), 16, 0, 32} - , - {&mcs_tbl_rev3, sizeof(mcs_tbl_rev3) / sizeof(mcs_tbl_rev3[0]), 18, 0, - 16} - , - {&tdi_tbl20_ant0_rev3, - sizeof(tdi_tbl20_ant0_rev3) / sizeof(tdi_tbl20_ant0_rev3[0]), 19, 128, - 32} - , - {&tdi_tbl20_ant1_rev3, - sizeof(tdi_tbl20_ant1_rev3) / sizeof(tdi_tbl20_ant1_rev3[0]), 19, 256, - 32} - , - {&tdi_tbl40_ant0_rev3, - sizeof(tdi_tbl40_ant0_rev3) / sizeof(tdi_tbl40_ant0_rev3[0]), 19, 640, - 32} - , - {&tdi_tbl40_ant1_rev3, - sizeof(tdi_tbl40_ant1_rev3) / sizeof(tdi_tbl40_ant1_rev3[0]), 19, 768, - 32} - , - {&pltlut_tbl_rev3, sizeof(pltlut_tbl_rev3) / sizeof(pltlut_tbl_rev3[0]), - 20, 0, 32} - , - {&chanest_tbl_rev3, - sizeof(chanest_tbl_rev3) / sizeof(chanest_tbl_rev3[0]), 22, 0, 32} - , - {&frame_lut_rev3, sizeof(frame_lut_rev3) / sizeof(frame_lut_rev3[0]), - 24, 0, 8} - , - {&est_pwr_lut_core0_rev3, - sizeof(est_pwr_lut_core0_rev3) / sizeof(est_pwr_lut_core0_rev3[0]), 26, - 0, 8} - , - {&est_pwr_lut_core1_rev3, - sizeof(est_pwr_lut_core1_rev3) / sizeof(est_pwr_lut_core1_rev3[0]), 27, - 0, 8} - , - {&adj_pwr_lut_core0_rev3, - sizeof(adj_pwr_lut_core0_rev3) / sizeof(adj_pwr_lut_core0_rev3[0]), 26, - 64, 8} - , - {&adj_pwr_lut_core1_rev3, - sizeof(adj_pwr_lut_core1_rev3) / sizeof(adj_pwr_lut_core1_rev3[0]), 27, - 64, 8} - , - {&gainctrl_lut_core0_rev3, - sizeof(gainctrl_lut_core0_rev3) / sizeof(gainctrl_lut_core0_rev3[0]), - 26, 192, 32} - , - {&gainctrl_lut_core1_rev3, - sizeof(gainctrl_lut_core1_rev3) / sizeof(gainctrl_lut_core1_rev3[0]), - 27, 192, 32} - , - {&iq_lut_core0_rev3, - sizeof(iq_lut_core0_rev3) / sizeof(iq_lut_core0_rev3[0]), 26, 320, 32} - , - {&iq_lut_core1_rev3, - sizeof(iq_lut_core1_rev3) / sizeof(iq_lut_core1_rev3[0]), 27, 320, 32} - , - {&loft_lut_core0_rev3, - sizeof(loft_lut_core0_rev3) / sizeof(loft_lut_core0_rev3[0]), 26, 448, - 16} - , - {&loft_lut_core1_rev3, - sizeof(loft_lut_core1_rev3) / sizeof(loft_lut_core1_rev3[0]), 27, 448, - 16} - , - {&papd_comp_rfpwr_tbl_core0_rev3, - sizeof(papd_comp_rfpwr_tbl_core0_rev3) / - sizeof(papd_comp_rfpwr_tbl_core0_rev3[0]), 26, 576, 16} - , - {&papd_comp_rfpwr_tbl_core1_rev3, - sizeof(papd_comp_rfpwr_tbl_core1_rev3) / - sizeof(papd_comp_rfpwr_tbl_core1_rev3[0]), 27, 576, 16} - , - {&papd_comp_epsilon_tbl_core0_rev7, - sizeof(papd_comp_epsilon_tbl_core0_rev7) / - sizeof(papd_comp_epsilon_tbl_core0_rev7[0]), 31, 0, 32} - , - {&papd_cal_scalars_tbl_core0_rev7, - sizeof(papd_cal_scalars_tbl_core0_rev7) / - sizeof(papd_cal_scalars_tbl_core0_rev7[0]), 32, 0, 32} - , - {&papd_comp_epsilon_tbl_core1_rev7, - sizeof(papd_comp_epsilon_tbl_core1_rev7) / - sizeof(papd_comp_epsilon_tbl_core1_rev7[0]), 33, 0, 32} - , - {&papd_cal_scalars_tbl_core1_rev7, - sizeof(papd_cal_scalars_tbl_core1_rev7) / - sizeof(papd_cal_scalars_tbl_core1_rev7[0]), 34, 0, 32} - , -}; - -const u32 mimophytbl_info_sz_rev7 = - sizeof(mimophytbl_info_rev7) / sizeof(mimophytbl_info_rev7[0]); - -const struct phytbl_info mimophytbl_info_rev16[] = { - {&noise_var_tbl_rev7, - sizeof(noise_var_tbl_rev7) / sizeof(noise_var_tbl_rev7[0]), 16, 0, 32} - , - {&est_pwr_lut_core0_rev3, - sizeof(est_pwr_lut_core0_rev3) / sizeof(est_pwr_lut_core0_rev3[0]), 26, - 0, 8} - , - {&est_pwr_lut_core1_rev3, - sizeof(est_pwr_lut_core1_rev3) / sizeof(est_pwr_lut_core1_rev3[0]), 27, - 0, 8} - , - {&adj_pwr_lut_core0_rev3, - sizeof(adj_pwr_lut_core0_rev3) / sizeof(adj_pwr_lut_core0_rev3[0]), 26, - 64, 8} - , - {&adj_pwr_lut_core1_rev3, - sizeof(adj_pwr_lut_core1_rev3) / sizeof(adj_pwr_lut_core1_rev3[0]), 27, - 64, 8} - , - {&gainctrl_lut_core0_rev3, - sizeof(gainctrl_lut_core0_rev3) / sizeof(gainctrl_lut_core0_rev3[0]), - 26, 192, 32} - , - {&gainctrl_lut_core1_rev3, - sizeof(gainctrl_lut_core1_rev3) / sizeof(gainctrl_lut_core1_rev3[0]), - 27, 192, 32} - , - {&iq_lut_core0_rev3, - sizeof(iq_lut_core0_rev3) / sizeof(iq_lut_core0_rev3[0]), 26, 320, 32} - , - {&iq_lut_core1_rev3, - sizeof(iq_lut_core1_rev3) / sizeof(iq_lut_core1_rev3[0]), 27, 320, 32} - , - {&loft_lut_core0_rev3, - sizeof(loft_lut_core0_rev3) / sizeof(loft_lut_core0_rev3[0]), 26, 448, - 16} - , - {&loft_lut_core1_rev3, - sizeof(loft_lut_core1_rev3) / sizeof(loft_lut_core1_rev3[0]), 27, 448, - 16} - , -}; - -const u32 mimophytbl_info_sz_rev16 = - sizeof(mimophytbl_info_rev16) / sizeof(mimophytbl_info_rev16[0]); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h b/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h deleted file mode 100644 index dc8a84e8511..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#define ANT_SWCTRL_TBL_REV3_IDX (0) - -#include -#include "phy_int.h" - -extern const struct phytbl_info mimophytbl_info_rev0[], - mimophytbl_info_rev0_volatile[]; - -extern const u32 mimophytbl_info_sz_rev0, - mimophytbl_info_sz_rev0_volatile; - -extern const struct phytbl_info mimophytbl_info_rev3[], - mimophytbl_info_rev3_volatile[], - mimophytbl_info_rev3_volatile1[], - mimophytbl_info_rev3_volatile2[], - mimophytbl_info_rev3_volatile3[]; - -extern const u32 mimophytbl_info_sz_rev3, - mimophytbl_info_sz_rev3_volatile, - mimophytbl_info_sz_rev3_volatile1, - mimophytbl_info_sz_rev3_volatile2, - mimophytbl_info_sz_rev3_volatile3; - -extern const u32 noise_var_tbl_rev3[]; - -extern const struct phytbl_info mimophytbl_info_rev7[]; - -extern const u32 mimophytbl_info_sz_rev7; - -extern const u32 noise_var_tbl_rev7[]; - -extern const struct phytbl_info mimophytbl_info_rev16[]; - -extern const u32 mimophytbl_info_sz_rev16; diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.c b/drivers/staging/brcm80211/brcmsmac/phy_shim.c deleted file mode 100644 index 676222ec2b8..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * This is "two-way" interface, acting as the SHIM layer between driver - * and PHY layer. The driver can optionally call this translation layer - * to do some preprocessing, then reach PHY. On the PHY->driver direction, - * all calls go through this layer since PHY doesn't have access to the - * driver's brcms_hardware pointer. - */ -#include -#include - -#include "main.h" -#include "mac80211_if.h" -#include "phy_shim.h" - -/* PHY SHIM module specific state */ -struct phy_shim_info { - struct brcms_hardware *wlc_hw; /* pointer to main wlc_hw structure */ - struct brcms_c_info *wlc; /* pointer to main wlc structure */ - struct brcms_info *wl; /* pointer to os-specific private state */ -}; - -struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, - struct brcms_info *wl, - struct brcms_c_info *wlc) { - struct phy_shim_info *physhim = NULL; - - physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC); - if (!physhim) - return NULL; - - physhim->wlc_hw = wlc_hw; - physhim->wlc = wlc; - physhim->wl = wl; - - return physhim; -} - -void wlc_phy_shim_detach(struct phy_shim_info *physhim) -{ - kfree(physhim); -} - -struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim, - void (*fn)(struct brcms_phy *pi), - void *arg, const char *name) -{ - return (struct wlapi_timer *) - brcms_init_timer(physhim->wl, (void (*)(void *))fn, - arg, name); -} - -void wlapi_free_timer(struct phy_shim_info *physhim, struct wlapi_timer *t) -{ - brcms_free_timer(physhim->wl, (struct brcms_timer *)t); -} - -void -wlapi_add_timer(struct phy_shim_info *physhim, struct wlapi_timer *t, uint ms, - int periodic) -{ - brcms_add_timer(physhim->wl, (struct brcms_timer *)t, ms, periodic); -} - -bool wlapi_del_timer(struct phy_shim_info *physhim, struct wlapi_timer *t) -{ - return brcms_del_timer(physhim->wl, (struct brcms_timer *)t); -} - -void wlapi_intrson(struct phy_shim_info *physhim) -{ - brcms_intrson(physhim->wl); -} - -u32 wlapi_intrsoff(struct phy_shim_info *physhim) -{ - return brcms_intrsoff(physhim->wl); -} - -void wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask) -{ - brcms_intrsrestore(physhim->wl, macintmask); -} - -void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v) -{ - brcms_b_write_shm(physhim->wlc_hw, offset, v); -} - -u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset) -{ - return brcms_b_read_shm(physhim->wlc_hw, offset); -} - -void -wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask, - u16 val, int bands) -{ - brcms_b_mhf(physhim->wlc_hw, idx, mask, val, bands); -} - -void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags) -{ - brcms_b_corereset(physhim->wlc_hw, flags); -} - -void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim) -{ - brcms_c_suspend_mac_and_wait(physhim->wlc); -} - -void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode) -{ - brcms_b_switch_macfreq(physhim->wlc_hw, spurmode); -} - -void wlapi_enable_mac(struct phy_shim_info *physhim) -{ - brcms_c_enable_mac(physhim->wlc); -} - -void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val) -{ - brcms_b_mctrl(physhim->wlc_hw, mask, val); -} - -void wlapi_bmac_phy_reset(struct phy_shim_info *physhim) -{ - brcms_b_phy_reset(physhim->wlc_hw); -} - -void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw) -{ - brcms_b_bw_set(physhim->wlc_hw, bw); -} - -u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim) -{ - return brcms_b_get_txant(physhim->wlc_hw); -} - -void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk) -{ - brcms_b_phyclk_fgc(physhim->wlc_hw, clk); -} - -void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk) -{ - brcms_b_macphyclk_set(physhim->wlc_hw, clk); -} - -void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on) -{ - brcms_b_core_phypll_ctl(physhim->wlc_hw, on); -} - -void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim) -{ - brcms_b_core_phypll_reset(physhim->wlc_hw); -} - -void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim) -{ - brcms_c_ucode_wake_override_set(physhim->wlc_hw, - BRCMS_WAKE_OVERRIDE_PHYREG); -} - -void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim) -{ - brcms_c_ucode_wake_override_clear(physhim->wlc_hw, - BRCMS_WAKE_OVERRIDE_PHYREG); -} - -void -wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int offset, - int len, void *buf) -{ - brcms_b_write_template_ram(physhim->wlc_hw, offset, len, buf); -} - -u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate) -{ - return brcms_b_rate_shm_offset(physhim->wlc_hw, rate); -} - -void wlapi_ucode_sample_init(struct phy_shim_info *physhim) -{ -} - -void -wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint offset, void *buf, - int len, u32 sel) -{ - brcms_b_copyfrom_objmem(physhim->wlc_hw, offset, buf, len, sel); -} - -void -wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf, - int l, u32 sel) -{ - brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel); -} - -char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id) -{ - return getvar(physhim->wlc_hw->sih, id); -} -int wlapi_getintvar(struct phy_shim_info *physhim, enum brcms_srom_id id) -{ - return getintvar(physhim->wlc_hw->sih, id); -} diff --git a/drivers/staging/brcm80211/brcmsmac/phy_shim.h b/drivers/staging/brcm80211/brcmsmac/phy_shim.h deleted file mode 100644 index 8de549dfb1c..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/phy_shim.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * phy_shim.h: stuff defined in phy_shim.c and included only by the phy - */ - -#ifndef _BRCM_PHY_SHIM_H_ -#define _BRCM_PHY_SHIM_H_ - -#include "types.h" - -#define RADAR_TYPE_NONE 0 /* Radar type None */ -#define RADAR_TYPE_ETSI_1 1 /* ETSI 1 Radar type */ -#define RADAR_TYPE_ETSI_2 2 /* ETSI 2 Radar type */ -#define RADAR_TYPE_ETSI_3 3 /* ETSI 3 Radar type */ -#define RADAR_TYPE_ITU_E 4 /* ITU E Radar type */ -#define RADAR_TYPE_ITU_K 5 /* ITU K Radar type */ -#define RADAR_TYPE_UNCLASSIFIED 6 /* Unclassified Radar type */ -#define RADAR_TYPE_BIN5 7 /* long pulse radar type */ -#define RADAR_TYPE_STG2 8 /* staggered-2 radar */ -#define RADAR_TYPE_STG3 9 /* staggered-3 radar */ -#define RADAR_TYPE_FRA 10 /* French radar */ - -/* French radar pulse widths */ -#define FRA_T1_20MHZ 52770 -#define FRA_T2_20MHZ 61538 -#define FRA_T3_20MHZ 66002 -#define FRA_T1_40MHZ 105541 -#define FRA_T2_40MHZ 123077 -#define FRA_T3_40MHZ 132004 -#define FRA_ERR_20MHZ 60 -#define FRA_ERR_40MHZ 120 - -#define ANTSEL_NA 0 /* No boardlevel selection available */ -#define ANTSEL_2x4 1 /* 2x4 boardlevel selection available */ -#define ANTSEL_2x3 2 /* 2x3 CB2 boardlevel selection available */ - -/* Rx Antenna diversity control values */ -#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ -#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ -#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ -#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ -#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ -#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* default antdiv setting */ - -#define WL_ANT_RX_MAX 2 /* max 2 receive antennas */ -#define WL_ANT_HT_RX_MAX 3 /* max 3 receive antennas/cores */ -#define WL_ANT_IDX_1 0 /* antenna index 1 */ -#define WL_ANT_IDX_2 1 /* antenna index 2 */ - -/* values for n_preamble_type */ -#define BRCMS_N_PREAMBLE_MIXEDMODE 0 -#define BRCMS_N_PREAMBLE_GF 1 -#define BRCMS_N_PREAMBLE_GF_BRCM 2 - -#define WL_TX_POWER_RATES_LEGACY 45 -#define WL_TX_POWER_MCS20_FIRST 12 -#define WL_TX_POWER_MCS20_NUM 16 -#define WL_TX_POWER_MCS40_FIRST 28 -#define WL_TX_POWER_MCS40_NUM 17 - - -#define WL_TX_POWER_RATES 101 -#define WL_TX_POWER_CCK_FIRST 0 -#define WL_TX_POWER_CCK_NUM 4 -/* Index for first 20MHz OFDM SISO rate */ -#define WL_TX_POWER_OFDM_FIRST 4 -/* Index for first 20MHz OFDM CDD rate */ -#define WL_TX_POWER_OFDM20_CDD_FIRST 12 -/* Index for first 40MHz OFDM SISO rate */ -#define WL_TX_POWER_OFDM40_SISO_FIRST 52 -/* Index for first 40MHz OFDM CDD rate */ -#define WL_TX_POWER_OFDM40_CDD_FIRST 60 -#define WL_TX_POWER_OFDM_NUM 8 -/* Index for first 20MHz MCS SISO rate */ -#define WL_TX_POWER_MCS20_SISO_FIRST 20 -/* Index for first 20MHz MCS CDD rate */ -#define WL_TX_POWER_MCS20_CDD_FIRST 28 -/* Index for first 20MHz MCS STBC rate */ -#define WL_TX_POWER_MCS20_STBC_FIRST 36 -/* Index for first 20MHz MCS SDM rate */ -#define WL_TX_POWER_MCS20_SDM_FIRST 44 -/* Index for first 40MHz MCS SISO rate */ -#define WL_TX_POWER_MCS40_SISO_FIRST 68 -/* Index for first 40MHz MCS CDD rate */ -#define WL_TX_POWER_MCS40_CDD_FIRST 76 -/* Index for first 40MHz MCS STBC rate */ -#define WL_TX_POWER_MCS40_STBC_FIRST 84 -/* Index for first 40MHz MCS SDM rate */ -#define WL_TX_POWER_MCS40_SDM_FIRST 92 -#define WL_TX_POWER_MCS_1_STREAM_NUM 8 -#define WL_TX_POWER_MCS_2_STREAM_NUM 8 -/* Index for 40MHz rate MCS 32 */ -#define WL_TX_POWER_MCS_32 100 -#define WL_TX_POWER_MCS_32_NUM 1 - -/* sslpnphy specifics */ -/* Index for first 20MHz MCS SISO rate */ -#define WL_TX_POWER_MCS20_SISO_FIRST_SSN 12 - -/* struct tx_power::flags bits */ -#define WL_TX_POWER_F_ENABLED 1 -#define WL_TX_POWER_F_HW 2 -#define WL_TX_POWER_F_MIMO 4 -#define WL_TX_POWER_F_SISO 8 - -/* values to force tx/rx chain */ -#define BRCMS_N_TXRX_CHAIN0 0 -#define BRCMS_N_TXRX_CHAIN1 1 - -struct brcms_phy; - -extern struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw, - struct brcms_info *wl, - struct brcms_c_info *wlc); -extern void wlc_phy_shim_detach(struct phy_shim_info *physhim); - -/* PHY to WL utility functions */ -extern struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim, - void (*fn) (struct brcms_phy *pi), - void *arg, const char *name); -extern void wlapi_free_timer(struct phy_shim_info *physhim, - struct wlapi_timer *t); -extern void wlapi_add_timer(struct phy_shim_info *physhim, - struct wlapi_timer *t, uint ms, int periodic); -extern bool wlapi_del_timer(struct phy_shim_info *physhim, - struct wlapi_timer *t); -extern void wlapi_intrson(struct phy_shim_info *physhim); -extern u32 wlapi_intrsoff(struct phy_shim_info *physhim); -extern void wlapi_intrsrestore(struct phy_shim_info *physhim, - u32 macintmask); - -extern void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, - u16 v); -extern u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset); -extern void wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, - u16 mask, u16 val, int bands); -extern void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags); -extern void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim); -extern void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode); -extern void wlapi_enable_mac(struct phy_shim_info *physhim); -extern void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, - u32 val); -extern void wlapi_bmac_phy_reset(struct phy_shim_info *physhim); -extern void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw); -extern void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk); -extern void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk); -extern void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on); -extern void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim); -extern void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info * - physhim); -extern void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info * - physhim); -extern void wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int o, - int len, void *buf); -extern u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, - u8 rate); -extern void wlapi_ucode_sample_init(struct phy_shim_info *physhim); -extern void wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint, - void *buf, int, u32 sel); -extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, - const void *buf, int, u32); - -extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, - u32 phy_mode); -extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim); -extern char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id); -extern int wlapi_getintvar(struct phy_shim_info *physhim, - enum brcms_srom_id id); - -#endif /* _BRCM_PHY_SHIM_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.c b/drivers/staging/brcm80211/brcmsmac/pmu.c deleted file mode 100644 index 3b36e3acfd7..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/pmu.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include -#include -#include "pub.h" -#include "aiutils.h" -#include "pmu.h" - -/* - * external LPO crystal frequency - */ -#define EXT_ILP_HZ 32768 - -/* - * Duration for ILP clock frequency measurment in milliseconds - * - * remark: 1000 must be an integer multiple of this duration - */ -#define ILP_CALC_DUR 10 - -/* Fields in pmucontrol */ -#define PCTL_ILP_DIV_MASK 0xffff0000 -#define PCTL_ILP_DIV_SHIFT 16 -#define PCTL_PLL_PLLCTL_UPD 0x00000400 /* rev 2 */ -#define PCTL_NOILP_ON_WAIT 0x00000200 /* rev 1 */ -#define PCTL_HT_REQ_EN 0x00000100 -#define PCTL_ALP_REQ_EN 0x00000080 -#define PCTL_XTALFREQ_MASK 0x0000007c -#define PCTL_XTALFREQ_SHIFT 2 -#define PCTL_ILP_DIV_EN 0x00000002 -#define PCTL_LPO_SEL 0x00000001 - -/* ILP clock */ -#define ILP_CLOCK 32000 - -/* ALP clock on pre-PMU chips */ -#define ALP_CLOCK 20000000 - -/* pmustatus */ -#define PST_EXTLPOAVAIL 0x0100 -#define PST_WDRESET 0x0080 -#define PST_INTPEND 0x0040 -#define PST_SBCLKST 0x0030 -#define PST_SBCLKST_ILP 0x0010 -#define PST_SBCLKST_ALP 0x0020 -#define PST_SBCLKST_HT 0x0030 -#define PST_ALPAVAIL 0x0008 -#define PST_HTAVAIL 0x0004 -#define PST_RESINIT 0x0003 - -/* PMU resource bit position */ -#define PMURES_BIT(bit) (1 << (bit)) - -/* PMU corerev and chip specific PLL controls. - * PMU_PLL_XX where is PMU corerev and is an arbitrary - * number to differentiate different PLLs controlled by the same PMU rev. - */ -/* pllcontrol registers: - * ndiv_pwrdn, pwrdn_ch, refcomp_pwrdn, dly_ch, - * p1div, p2div, _bypass_sdmod - */ -#define PMU1_PLL0_PLLCTL0 0 -#define PMU1_PLL0_PLLCTL1 1 -#define PMU1_PLL0_PLLCTL2 2 -#define PMU1_PLL0_PLLCTL3 3 -#define PMU1_PLL0_PLLCTL4 4 -#define PMU1_PLL0_PLLCTL5 5 - -/* pmu XtalFreqRatio */ -#define PMU_XTALFREQ_REG_ILPCTR_MASK 0x00001FFF -#define PMU_XTALFREQ_REG_MEASURE_MASK 0x80000000 -#define PMU_XTALFREQ_REG_MEASURE_SHIFT 31 - -/* 4313 resources */ -#define RES4313_BB_PU_RSRC 0 -#define RES4313_ILP_REQ_RSRC 1 -#define RES4313_XTAL_PU_RSRC 2 -#define RES4313_ALP_AVAIL_RSRC 3 -#define RES4313_RADIO_PU_RSRC 4 -#define RES4313_BG_PU_RSRC 5 -#define RES4313_VREG1P4_PU_RSRC 6 -#define RES4313_AFE_PWRSW_RSRC 7 -#define RES4313_RX_PWRSW_RSRC 8 -#define RES4313_TX_PWRSW_RSRC 9 -#define RES4313_BB_PWRSW_RSRC 10 -#define RES4313_SYNTH_PWRSW_RSRC 11 -#define RES4313_MISC_PWRSW_RSRC 12 -#define RES4313_BB_PLL_PWRSW_RSRC 13 -#define RES4313_HT_AVAIL_RSRC 14 -#define RES4313_MACPHY_CLK_AVAIL_RSRC 15 - -/* Determine min/max rsrc masks. Value 0 leaves hardware at default. */ -static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) -{ - u32 min_mask = 0, max_mask = 0; - uint rsrcs; - - /* # resources */ - rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT; - - /* determine min/max rsrc masks */ - switch (sih->chip) { - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - /* ??? */ - break; - - case BCM4313_CHIP_ID: - min_mask = PMURES_BIT(RES4313_BB_PU_RSRC) | - PMURES_BIT(RES4313_XTAL_PU_RSRC) | - PMURES_BIT(RES4313_ALP_AVAIL_RSRC) | - PMURES_BIT(RES4313_BB_PLL_PWRSW_RSRC); - max_mask = 0xffff; - break; - default: - break; - } - - *pmin = min_mask; - *pmax = max_mask; -} - -static void -si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, - u8 spuravoid) -{ - u32 tmp = 0; - - switch (sih->chip) { - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - if (spuravoid == 1) { - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11500010); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x000C0C06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x0F600a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x2001E920); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888815); - } else { - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11100010); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x000c0c06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x03000a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x200005c0); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888815); - } - tmp = 1 << 10; - break; - - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11100008); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x0c000c06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x03000a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x200005c0); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888855); - - tmp = 1 << 10; - break; - - default: - /* bail out */ - return; - } - - tmp |= R_REG(&cc->pmucontrol); - W_REG(&cc->pmucontrol, tmp); -} - -u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) -{ - uint delay = PMU_MAX_TRANSITION_DLY; - - switch (sih->chip) { - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - case BCM4313_CHIP_ID: - delay = 3700; - break; - default: - break; - } - - return (u16) delay; -} - -void si_pmu_sprom_enable(struct si_pub *sih, bool enable) -{ - struct chipcregs __iomem *cc; - uint origidx; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -/* Read/write a chipcontrol reg */ -u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) -{ - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), mask, - val); -} - -/* Read/write a regcontrol reg */ -u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) -{ - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, regcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, regcontrol_data), mask, - val); -} - -/* Read/write a pllcontrol reg */ -u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) -{ - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pllcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, pllcontrol_data), mask, - val); -} - -/* PMU PLL update */ -void si_pmu_pllupd(struct si_pub *sih) -{ - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pmucontrol), - PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD); -} - -/* query alp/xtal clock frequency */ -u32 si_pmu_alp_clock(struct si_pub *sih) -{ - u32 clock = ALP_CLOCK; - - /* bail out with default */ - if (!(sih->cccaps & CC_CAP_PMU)) - return clock; - - switch (sih->chip) { - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - case BCM4313_CHIP_ID: - /* always 20Mhz */ - clock = 20000 * 1000; - break; - default: - break; - } - - return clock; -} - -void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) -{ - struct chipcregs __iomem *cc; - uint origidx, intr_val; - - /* Remember original core before switch to chipc */ - cc = (struct chipcregs __iomem *) - ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); - - /* update the pll changes */ - si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); - - /* Return to original core */ - ai_restore_core(sih, origidx, intr_val); -} - -/* initialize PMU */ -void si_pmu_init(struct si_pub *sih) -{ - struct chipcregs __iomem *cc; - uint origidx; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - if (sih->pmurev == 1) - AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); - else if (sih->pmurev >= 2) - OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -/* initialize PMU chip controls and other chip level stuff */ -void si_pmu_chip_init(struct si_pub *sih) -{ - uint origidx; - - /* Gate off SPROM clock and chip select signals */ - si_pmu_sprom_enable(sih, false); - - /* Remember original core */ - origidx = ai_coreidx(sih); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -/* initialize PMU switch/regulators */ -void si_pmu_swreg_init(struct si_pub *sih) -{ -} - -/* initialize PLL */ -void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) -{ - struct chipcregs __iomem *cc; - uint origidx; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - switch (sih->chip) { - case BCM4313_CHIP_ID: - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - /* ??? */ - break; - default: - break; - } - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -/* initialize PMU resources */ -void si_pmu_res_init(struct si_pub *sih) -{ - struct chipcregs __iomem *cc; - uint origidx; - u32 min_mask = 0, max_mask = 0; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - /* Determine min/max rsrc masks */ - si_pmu_res_masks(sih, &min_mask, &max_mask); - - /* It is required to program max_mask first and then min_mask */ - - /* Program max resource mask */ - - if (max_mask) - W_REG(&cc->max_res_mask, max_mask); - - /* Program min resource mask */ - - if (min_mask) - W_REG(&cc->min_res_mask, min_mask); - - /* Add some delay; allow resources to come up and settle. */ - mdelay(2); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -u32 si_pmu_measure_alpclk(struct si_pub *sih) -{ - struct chipcregs __iomem *cc; - uint origidx; - u32 alp_khz; - - if (sih->pmurev < 10) - return 0; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) { - u32 ilp_ctr, alp_hz; - - /* - * Enable the reg to measure the freq, - * in case it was disabled before - */ - W_REG(&cc->pmu_xtalfreq, - 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); - - /* Delay for well over 4 ILP clocks */ - udelay(1000); - - /* Read the latched number of ALP ticks per 4 ILP ticks */ - ilp_ctr = - R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; - - /* - * Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT - * bit to save power - */ - W_REG(&cc->pmu_xtalfreq, 0); - - /* Calculate ALP frequency */ - alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4; - - /* - * Round to nearest 100KHz, and at - * the same time convert to KHz - */ - alp_khz = (alp_hz + 50000) / 100000 * 100; - } else - alp_khz = 0; - - /* Return to original core */ - ai_setcoreidx(sih, origidx); - - return alp_khz; -} diff --git a/drivers/staging/brcm80211/brcmsmac/pmu.h b/drivers/staging/brcm80211/brcmsmac/pmu.h deleted file mode 100644 index 3a08c620640..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/pmu.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifndef _BRCM_PMU_H_ -#define _BRCM_PMU_H_ - -#include "types.h" - -extern u16 si_pmu_fast_pwrup_delay(struct si_pub *sih); -extern void si_pmu_sprom_enable(struct si_pub *sih, bool enable); -extern u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); -extern u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); -extern u32 si_pmu_alp_clock(struct si_pub *sih); -extern void si_pmu_pllupd(struct si_pub *sih); -extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid); -extern u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); -extern void si_pmu_init(struct si_pub *sih); -extern void si_pmu_chip_init(struct si_pub *sih); -extern void si_pmu_pll_init(struct si_pub *sih, u32 xtalfreq); -extern void si_pmu_res_init(struct si_pub *sih); -extern void si_pmu_swreg_init(struct si_pub *sih); -extern u32 si_pmu_measure_alpclk(struct si_pub *sih); - -#endif /* _BRCM_PMU_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/pub.h b/drivers/staging/brcm80211/brcmsmac/pub.h deleted file mode 100644 index 3942f47b15c..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/pub.h +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_PUB_H_ -#define _BRCM_PUB_H_ - -#include -#include "types.h" -#include "defs.h" - -enum brcms_srom_id { - BRCMS_SROM_NULL, - BRCMS_SROM_CONT, - BRCMS_SROM_AA2G, - BRCMS_SROM_AA5G, - BRCMS_SROM_AG0, - BRCMS_SROM_AG1, - BRCMS_SROM_AG2, - BRCMS_SROM_AG3, - BRCMS_SROM_ANTSWCTL2G, - BRCMS_SROM_ANTSWCTL5G, - BRCMS_SROM_ANTSWITCH, - BRCMS_SROM_BOARDFLAGS2, - BRCMS_SROM_BOARDFLAGS, - BRCMS_SROM_BOARDNUM, - BRCMS_SROM_BOARDREV, - BRCMS_SROM_BOARDTYPE, - BRCMS_SROM_BW40PO, - BRCMS_SROM_BWDUPPO, - BRCMS_SROM_BXA2G, - BRCMS_SROM_BXA5G, - BRCMS_SROM_CC, - BRCMS_SROM_CCK2GPO, - BRCMS_SROM_CCKBW202GPO, - BRCMS_SROM_CCKBW20UL2GPO, - BRCMS_SROM_CCODE, - BRCMS_SROM_CDDPO, - BRCMS_SROM_DEVID, - BRCMS_SROM_ET1MACADDR, - BRCMS_SROM_EXTPAGAIN2G, - BRCMS_SROM_EXTPAGAIN5G, - BRCMS_SROM_FREQOFFSET_CORR, - BRCMS_SROM_HW_IQCAL_EN, - BRCMS_SROM_IL0MACADDR, - BRCMS_SROM_IQCAL_SWP_DIS, - BRCMS_SROM_LEDBH0, - BRCMS_SROM_LEDBH1, - BRCMS_SROM_LEDBH2, - BRCMS_SROM_LEDBH3, - BRCMS_SROM_LEDDC, - BRCMS_SROM_LEGOFDM40DUPPO, - BRCMS_SROM_LEGOFDMBW202GPO, - BRCMS_SROM_LEGOFDMBW205GHPO, - BRCMS_SROM_LEGOFDMBW205GLPO, - BRCMS_SROM_LEGOFDMBW205GMPO, - BRCMS_SROM_LEGOFDMBW20UL2GPO, - BRCMS_SROM_LEGOFDMBW20UL5GHPO, - BRCMS_SROM_LEGOFDMBW20UL5GLPO, - BRCMS_SROM_LEGOFDMBW20UL5GMPO, - BRCMS_SROM_MACADDR, - BRCMS_SROM_MCS2GPO0, - BRCMS_SROM_MCS2GPO1, - BRCMS_SROM_MCS2GPO2, - BRCMS_SROM_MCS2GPO3, - BRCMS_SROM_MCS2GPO4, - BRCMS_SROM_MCS2GPO5, - BRCMS_SROM_MCS2GPO6, - BRCMS_SROM_MCS2GPO7, - BRCMS_SROM_MCS32PO, - BRCMS_SROM_MCS5GHPO0, - BRCMS_SROM_MCS5GHPO1, - BRCMS_SROM_MCS5GHPO2, - BRCMS_SROM_MCS5GHPO3, - BRCMS_SROM_MCS5GHPO4, - BRCMS_SROM_MCS5GHPO5, - BRCMS_SROM_MCS5GHPO6, - BRCMS_SROM_MCS5GHPO7, - BRCMS_SROM_MCS5GLPO0, - BRCMS_SROM_MCS5GLPO1, - BRCMS_SROM_MCS5GLPO2, - BRCMS_SROM_MCS5GLPO3, - BRCMS_SROM_MCS5GLPO4, - BRCMS_SROM_MCS5GLPO5, - BRCMS_SROM_MCS5GLPO6, - BRCMS_SROM_MCS5GLPO7, - BRCMS_SROM_MCS5GPO0, - BRCMS_SROM_MCS5GPO1, - BRCMS_SROM_MCS5GPO2, - BRCMS_SROM_MCS5GPO3, - BRCMS_SROM_MCS5GPO4, - BRCMS_SROM_MCS5GPO5, - BRCMS_SROM_MCS5GPO6, - BRCMS_SROM_MCS5GPO7, - BRCMS_SROM_MCSBW202GPO, - BRCMS_SROM_MCSBW205GHPO, - BRCMS_SROM_MCSBW205GLPO, - BRCMS_SROM_MCSBW205GMPO, - BRCMS_SROM_MCSBW20UL2GPO, - BRCMS_SROM_MCSBW20UL5GHPO, - BRCMS_SROM_MCSBW20UL5GLPO, - BRCMS_SROM_MCSBW20UL5GMPO, - BRCMS_SROM_MCSBW402GPO, - BRCMS_SROM_MCSBW405GHPO, - BRCMS_SROM_MCSBW405GLPO, - BRCMS_SROM_MCSBW405GMPO, - BRCMS_SROM_MEASPOWER, - BRCMS_SROM_OFDM2GPO, - BRCMS_SROM_OFDM5GHPO, - BRCMS_SROM_OFDM5GLPO, - BRCMS_SROM_OFDM5GPO, - BRCMS_SROM_OPO, - BRCMS_SROM_PA0B0, - BRCMS_SROM_PA0B1, - BRCMS_SROM_PA0B2, - BRCMS_SROM_PA0ITSSIT, - BRCMS_SROM_PA0MAXPWR, - BRCMS_SROM_PA1B0, - BRCMS_SROM_PA1B1, - BRCMS_SROM_PA1B2, - BRCMS_SROM_PA1HIB0, - BRCMS_SROM_PA1HIB1, - BRCMS_SROM_PA1HIB2, - BRCMS_SROM_PA1HIMAXPWR, - BRCMS_SROM_PA1ITSSIT, - BRCMS_SROM_PA1LOB0, - BRCMS_SROM_PA1LOB1, - BRCMS_SROM_PA1LOB2, - BRCMS_SROM_PA1LOMAXPWR, - BRCMS_SROM_PA1MAXPWR, - BRCMS_SROM_PDETRANGE2G, - BRCMS_SROM_PDETRANGE5G, - BRCMS_SROM_PHYCAL_TEMPDELTA, - BRCMS_SROM_RAWTEMPSENSE, - BRCMS_SROM_REGREV, - BRCMS_SROM_REV, - BRCMS_SROM_RSSISAV2G, - BRCMS_SROM_RSSISAV5G, - BRCMS_SROM_RSSISMC2G, - BRCMS_SROM_RSSISMC5G, - BRCMS_SROM_RSSISMF2G, - BRCMS_SROM_RSSISMF5G, - BRCMS_SROM_RXCHAIN, - BRCMS_SROM_RXPO2G, - BRCMS_SROM_RXPO5G, - BRCMS_SROM_STBCPO, - BRCMS_SROM_TEMPCORRX, - BRCMS_SROM_TEMPOFFSET, - BRCMS_SROM_TEMPSENSE_OPTION, - BRCMS_SROM_TEMPSENSE_SLOPE, - BRCMS_SROM_TEMPTHRESH, - BRCMS_SROM_TRI2G, - BRCMS_SROM_TRI5GH, - BRCMS_SROM_TRI5GL, - BRCMS_SROM_TRI5G, - BRCMS_SROM_TRISO2G, - BRCMS_SROM_TRISO5G, - BRCMS_SROM_TSSIPOS2G, - BRCMS_SROM_TSSIPOS5G, - BRCMS_SROM_TXCHAIN, - BRCMS_SROM_TXPID2GA0, - BRCMS_SROM_TXPID2GA1, - BRCMS_SROM_TXPID2GA2, - BRCMS_SROM_TXPID2GA3, - BRCMS_SROM_TXPID5GA0, - BRCMS_SROM_TXPID5GA1, - BRCMS_SROM_TXPID5GA2, - BRCMS_SROM_TXPID5GA3, - BRCMS_SROM_TXPID5GHA0, - BRCMS_SROM_TXPID5GHA1, - BRCMS_SROM_TXPID5GHA2, - BRCMS_SROM_TXPID5GHA3, - BRCMS_SROM_TXPID5GLA0, - BRCMS_SROM_TXPID5GLA1, - BRCMS_SROM_TXPID5GLA2, - BRCMS_SROM_TXPID5GLA3, - /* - * per-path identifiers (see srom.c) - */ - BRCMS_SROM_ITT2GA0, - BRCMS_SROM_ITT2GA1, - BRCMS_SROM_ITT2GA2, - BRCMS_SROM_ITT2GA3, - BRCMS_SROM_ITT5GA0, - BRCMS_SROM_ITT5GA1, - BRCMS_SROM_ITT5GA2, - BRCMS_SROM_ITT5GA3, - BRCMS_SROM_MAXP2GA0, - BRCMS_SROM_MAXP2GA1, - BRCMS_SROM_MAXP2GA2, - BRCMS_SROM_MAXP2GA3, - BRCMS_SROM_MAXP5GA0, - BRCMS_SROM_MAXP5GA1, - BRCMS_SROM_MAXP5GA2, - BRCMS_SROM_MAXP5GA3, - BRCMS_SROM_MAXP5GHA0, - BRCMS_SROM_MAXP5GHA1, - BRCMS_SROM_MAXP5GHA2, - BRCMS_SROM_MAXP5GHA3, - BRCMS_SROM_MAXP5GLA0, - BRCMS_SROM_MAXP5GLA1, - BRCMS_SROM_MAXP5GLA2, - BRCMS_SROM_MAXP5GLA3, - BRCMS_SROM_PA2GW0A0, - BRCMS_SROM_PA2GW0A1, - BRCMS_SROM_PA2GW0A2, - BRCMS_SROM_PA2GW0A3, - BRCMS_SROM_PA2GW1A0, - BRCMS_SROM_PA2GW1A1, - BRCMS_SROM_PA2GW1A2, - BRCMS_SROM_PA2GW1A3, - BRCMS_SROM_PA2GW2A0, - BRCMS_SROM_PA2GW2A1, - BRCMS_SROM_PA2GW2A2, - BRCMS_SROM_PA2GW2A3, - BRCMS_SROM_PA2GW3A0, - BRCMS_SROM_PA2GW3A1, - BRCMS_SROM_PA2GW3A2, - BRCMS_SROM_PA2GW3A3, - BRCMS_SROM_PA5GHW0A0, - BRCMS_SROM_PA5GHW0A1, - BRCMS_SROM_PA5GHW0A2, - BRCMS_SROM_PA5GHW0A3, - BRCMS_SROM_PA5GHW1A0, - BRCMS_SROM_PA5GHW1A1, - BRCMS_SROM_PA5GHW1A2, - BRCMS_SROM_PA5GHW1A3, - BRCMS_SROM_PA5GHW2A0, - BRCMS_SROM_PA5GHW2A1, - BRCMS_SROM_PA5GHW2A2, - BRCMS_SROM_PA5GHW2A3, - BRCMS_SROM_PA5GHW3A0, - BRCMS_SROM_PA5GHW3A1, - BRCMS_SROM_PA5GHW3A2, - BRCMS_SROM_PA5GHW3A3, - BRCMS_SROM_PA5GLW0A0, - BRCMS_SROM_PA5GLW0A1, - BRCMS_SROM_PA5GLW0A2, - BRCMS_SROM_PA5GLW0A3, - BRCMS_SROM_PA5GLW1A0, - BRCMS_SROM_PA5GLW1A1, - BRCMS_SROM_PA5GLW1A2, - BRCMS_SROM_PA5GLW1A3, - BRCMS_SROM_PA5GLW2A0, - BRCMS_SROM_PA5GLW2A1, - BRCMS_SROM_PA5GLW2A2, - BRCMS_SROM_PA5GLW2A3, - BRCMS_SROM_PA5GLW3A0, - BRCMS_SROM_PA5GLW3A1, - BRCMS_SROM_PA5GLW3A2, - BRCMS_SROM_PA5GLW3A3, - BRCMS_SROM_PA5GW0A0, - BRCMS_SROM_PA5GW0A1, - BRCMS_SROM_PA5GW0A2, - BRCMS_SROM_PA5GW0A3, - BRCMS_SROM_PA5GW1A0, - BRCMS_SROM_PA5GW1A1, - BRCMS_SROM_PA5GW1A2, - BRCMS_SROM_PA5GW1A3, - BRCMS_SROM_PA5GW2A0, - BRCMS_SROM_PA5GW2A1, - BRCMS_SROM_PA5GW2A2, - BRCMS_SROM_PA5GW2A3, - BRCMS_SROM_PA5GW3A0, - BRCMS_SROM_PA5GW3A1, - BRCMS_SROM_PA5GW3A2, - BRCMS_SROM_PA5GW3A3, -}; - -#define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ -#define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ - -/* phy types */ -#define PHY_TYPE_A 0 /* Phy type A */ -#define PHY_TYPE_G 2 /* Phy type G */ -#define PHY_TYPE_N 4 /* Phy type N */ -#define PHY_TYPE_LP 5 /* Phy type Low Power A/B/G */ -#define PHY_TYPE_SSN 6 /* Phy type Single Stream N */ -#define PHY_TYPE_LCN 8 /* Phy type Single Stream N */ -#define PHY_TYPE_LCNXN 9 /* Phy type 2-stream N */ -#define PHY_TYPE_HT 7 /* Phy type 3-Stream N */ - -/* bw */ -#define BRCMS_10_MHZ 10 /* 10Mhz nphy channel bandwidth */ -#define BRCMS_20_MHZ 20 /* 20Mhz nphy channel bandwidth */ -#define BRCMS_40_MHZ 40 /* 40Mhz nphy channel bandwidth */ - -#define BRCMS_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */ -#define BRCMS_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */ -#define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */ -#define BRCMS_RSSI_LOW -70 /* Low quality cutoffs */ -#define BRCMS_RSSI_GOOD -68 /* Good quality cutoffs */ -#define BRCMS_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */ -#define BRCMS_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */ - -/* a large TX Power as an init value to factor out of min() calculations, - * keep low enough to fit in an s8, units are .25 dBm - */ -#define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */ - -/* rate related definitions */ -#define BRCMS_RATE_FLAG 0x80 /* Flag to indicate it is a basic rate */ -#define BRCMS_RATE_MASK 0x7f /* Rate value mask w/o basic rate flag */ - -/* legacy rx Antenna diversity for SISO rates */ -#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ -#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ -#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ -#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ -#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ -/* default antdiv setting */ -#define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 - -/* legacy rx Antenna diversity for SISO rates */ -/* Tx on antenna 0, "legacy term Main" */ -#define ANT_TX_FORCE_0 0 -/* Tx on antenna 1, "legacy term Aux" */ -#define ANT_TX_FORCE_1 1 -/* Tx on phy's last good Rx antenna */ -#define ANT_TX_LAST_RX 3 -/* driver's default tx antenna setting */ -#define ANT_TX_DEF 3 - -/* Tx Chain values */ -/* def bitmap of txchain */ -#define TXCHAIN_DEF 0x1 -/* default bitmap of tx chains for nphy */ -#define TXCHAIN_DEF_NPHY 0x3 -/* default bitmap of tx chains for nphy */ -#define TXCHAIN_DEF_HTPHY 0x7 -/* def bitmap of rxchain */ -#define RXCHAIN_DEF 0x1 -/* default bitmap of rx chains for nphy */ -#define RXCHAIN_DEF_NPHY 0x3 -/* default bitmap of rx chains for nphy */ -#define RXCHAIN_DEF_HTPHY 0x7 -/* no antenna switch */ -#define ANTSWITCH_NONE 0 -/* antenna switch on 4321CB2, 2of3 */ -#define ANTSWITCH_TYPE_1 1 -/* antenna switch on 4321MPCI, 2of3 */ -#define ANTSWITCH_TYPE_2 2 -/* antenna switch on 4322, 2of3 */ -#define ANTSWITCH_TYPE_3 3 - -#define RXBUFSZ PKTBUFSZ - -#define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */ - -struct brcm_rateset { - /* # rates in this set */ - u32 count; - /* rates in 500kbps units w/hi bit set if basic */ - u8 rates[WL_NUMRATES]; -}; - -struct brcms_c_rateset { - uint count; /* number of rates in rates[] */ - /* rates in 500kbps units w/hi bit set if basic */ - u8 rates[BRCMS_NUMRATES]; - u8 htphy_membership; /* HT PHY Membership */ - u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */ -}; - -/* All the HT-specific default advertised capabilities (including AMPDU) - * should be grouped here at one place - */ -#define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */ - -/* wlc internal bss_info */ -struct brcms_bss_info { - u8 BSSID[ETH_ALEN]; /* network BSSID */ - u16 flags; /* flags for internal attributes */ - u8 SSID_len; /* the length of SSID */ - u8 SSID[32]; /* SSID string */ - s16 RSSI; /* receive signal strength (in dBm) */ - s16 SNR; /* receive signal SNR in dB */ - u16 beacon_period; /* units are Kusec */ - u16 chanspec; /* Channel num, bw, ctrl_sb and band */ - struct brcms_c_rateset rateset; /* supported rates */ -}; - -#define MAC80211_PROMISC_BCNS (1 << 0) -#define MAC80211_SCAN (1 << 1) - -/* - * Public portion of common driver state structure. - * The wlc handle points at this. - */ -struct brcms_pub { - struct brcms_c_info *wlc; - struct ieee80211_hw *ieee_hw; - struct scb_ampdu *global_ampdu; - uint mac80211_state; - uint unit; /* device instance number */ - uint corerev; /* core revision */ - struct si_pub *sih; /* SI handle (cookie for siutils calls) */ - bool up; /* interface up and running */ - bool hw_off; /* HW is off */ - bool hw_up; /* one time hw up/down */ - bool _piomode; /* true if pio mode */ - uint _nbands; /* # bands supported */ - uint now; /* # elapsed seconds */ - - bool promisc; /* promiscuous destination address */ - bool delayed_down; /* down delayed */ - bool associated; /* true:part of [I]BSS, false: not */ - /* (union of stas_associated, aps_associated) */ - bool _ampdu; /* ampdu enabled or not */ - u8 _n_enab; /* bitmap of 11N + HT support */ - - u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */ - - int bcmerror; /* last bcm error */ - - u32 radio_disabled; /* bit vector for radio disabled reasons */ - - u16 boardrev; /* version # of particular board */ - u8 sromrev; /* version # of the srom */ - char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */ - u32 boardflags; /* Board specific flags from srom */ - u32 boardflags2; /* More board flags if sromrev >= 4 */ - bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */ - - struct wl_cnt *_cnt; /* low-level counters in driver */ -}; - -enum wlc_par_id { - IOV_MPC = 1, - IOV_RTSTHRESH, - IOV_QTXPOWER, - IOV_BCN_LI_BCN /* Beacon listen interval in # of beacons */ -}; - -/*********************************************** - * Feature-related macros to optimize out code * - * ********************************************* - */ - -#define ENAB_1x1 0x01 -#define ENAB_2x2 0x02 -#define ENAB_3x3 0x04 -#define ENAB_4x4 0x08 -#define SUPPORT_11N (ENAB_1x1|ENAB_2x2) -#define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) - -/* WL11N Support */ -#define AMPDU_AGG_HOST 1 - -/* pri is priority encoded in the packet. This maps the Packet priority to - * enqueue precedence as defined in wlc_prec_map - */ -extern const u8 wlc_prio2prec_map[]; -#define BRCMS_PRIO_TO_PREC(pri) wlc_prio2prec_map[(pri) & 7] - -#define BRCMS_PREC_COUNT 16 /* Max precedence level implemented */ - -/* Mask to describe all precedence levels */ -#define BRCMS_PREC_BMP_ALL MAXBITVAL(BRCMS_PREC_COUNT) - -/* - * This maps priority to one precedence higher - Used by PS-Poll response - * packets to simulate enqueue-at-head operation, but still maintain the - * order on the queue - */ -#define BRCMS_PRIO_TO_HI_PREC(pri) min(BRCMS_PRIO_TO_PREC(pri) + 1,\ - BRCMS_PREC_COUNT - 1) - -/* Define a bitmap of precedences comprised by each AC */ -#define BRCMS_PREC_BMP_AC_BE (NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_BE)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_BE)) | \ - NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_EE)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_EE))) -#define BRCMS_PREC_BMP_AC_BK (NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_BK)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_BK)) | \ - NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_NONE)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_NONE))) -#define BRCMS_PREC_BMP_AC_VI (NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_CL)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_CL)) | \ - NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_VI)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_VI))) -#define BRCMS_PREC_BMP_AC_VO (NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_VO)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_VO)) | \ - NBITVAL(BRCMS_PRIO_TO_PREC(PRIO_8021D_NC)) | \ - NBITVAL(BRCMS_PRIO_TO_HI_PREC(PRIO_8021D_NC))) - -/* network protection config */ -#define BRCMS_PROT_G_SPEC 1 /* SPEC g protection */ -#define BRCMS_PROT_G_OVR 2 /* SPEC g prot override */ -#define BRCMS_PROT_G_USER 3 /* gmode specified by user */ -#define BRCMS_PROT_OVERLAP 4 /* overlap */ -#define BRCMS_PROT_N_USER 10 /* nmode specified by user */ -#define BRCMS_PROT_N_CFG 11 /* n protection */ -#define BRCMS_PROT_N_CFG_OVR 12 /* n protection override */ -#define BRCMS_PROT_N_NONGF 13 /* non-GF protection */ -#define BRCMS_PROT_N_NONGF_OVR 14 /* non-GF protection override */ -#define BRCMS_PROT_N_PAM_OVR 15 /* n preamble override */ -#define BRCMS_PROT_N_OBSS 16 /* non-HT OBSS present */ - -/* - * 54g modes (basic bits may still be overridden) - * - * GMODE_LEGACY_B - * Rateset: 1b, 2b, 5.5, 11 - * Preamble: Long - * Shortslot: Off - * GMODE_AUTO - * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 - * Extended Rateset: 6, 9, 12, 48 - * Preamble: Long - * Shortslot: Auto - * GMODE_ONLY - * Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54 - * Extended Rateset: 6b, 9, 12b, 48 - * Preamble: Short required - * Shortslot: Auto - * GMODE_B_DEFERRED - * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54 - * Extended Rateset: 6, 9, 12, 48 - * Preamble: Long - * Shortslot: On - * GMODE_PERFORMANCE - * Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54 - * Preamble: Short required - * Shortslot: On and required - * GMODE_LRS - * Rateset: 1b, 2b, 5.5b, 11b - * Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54 - * Preamble: Long - * Shortslot: Auto - */ -#define GMODE_LEGACY_B 0 -#define GMODE_AUTO 1 -#define GMODE_ONLY 2 -#define GMODE_B_DEFERRED 3 -#define GMODE_PERFORMANCE 4 -#define GMODE_LRS 5 -#define GMODE_MAX 6 - -/* MCS values greater than this enable multiple streams */ -#define HIGHEST_SINGLE_STREAM_MCS 7 - -#define MAXBANDS 2 /* Maximum #of bands */ - -/* max number of antenna configurations */ -#define ANT_SELCFG_MAX 4 - -struct brcms_antselcfg { - u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */ - u8 num_antcfg; /* number of available antenna configurations */ -}; - -/* common functions for every port */ -struct brcms_c_info * -brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void __iomem *regsva, struct pci_dev *btparam, - uint *perr); -extern uint brcms_c_detach(struct brcms_c_info *wlc); -extern int brcms_c_up(struct brcms_c_info *wlc); -extern uint brcms_c_down(struct brcms_c_info *wlc); - -extern bool brcms_c_chipmatch(u16 vendor, u16 device); -extern void brcms_c_init(struct brcms_c_info *wlc); -extern void brcms_c_reset(struct brcms_c_info *wlc); - -extern void brcms_c_intrson(struct brcms_c_info *wlc); -extern u32 brcms_c_intrsoff(struct brcms_c_info *wlc); -extern void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask); -extern bool brcms_c_intrsupd(struct brcms_c_info *wlc); -extern bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc); -extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded); -extern void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, - struct sk_buff *sdu, - struct ieee80211_hw *hw); -extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid); - -/* helper functions */ -extern void brcms_c_statsupd(struct brcms_c_info *wlc); -extern void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, - int val); -extern int brcms_c_get_header_len(void); -extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, - bool promisc); -extern void brcms_c_set_addrmatch(struct brcms_c_info *wlc, - int match_reg_offset, - const u8 *addr); -extern void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, - const struct ieee80211_tx_queue_params *arg, - bool suspend); -extern struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc); - -/* common functions for every port */ -extern void brcms_c_mhf(struct brcms_c_info *wlc, u8 idx, u16 mask, u16 val, - int bands); -extern void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, - struct brcms_c_rateset *rateset); -extern void brcms_default_rateset(struct brcms_c_info *wlc, - struct brcms_c_rateset *rs); - -extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, - struct ieee80211_sta *sta, u16 tid); -extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid, - u8 ba_wsize, uint max_rx_ampdu_bytes); -extern char *getvar(struct si_pub *sih, enum brcms_srom_id id); -extern int getintvar(struct si_pub *sih, enum brcms_srom_id id); - -/* wlc_phy.c helper functions */ -extern void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc); -extern void brcms_c_mctrl(struct brcms_c_info *wlc, u32 mask, u32 val); - -extern int brcms_c_module_register(struct brcms_pub *pub, - const char *name, struct brcms_info *hdl, - int (*down_fn)(void *handle)); -extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, - struct brcms_info *hdl); -extern void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc); -extern void brcms_c_enable_mac(struct brcms_c_info *wlc); -extern void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state); -extern void brcms_c_scan_start(struct brcms_c_info *wlc); -extern void brcms_c_scan_stop(struct brcms_c_info *wlc); -extern int brcms_c_get_curband(struct brcms_c_info *wlc); -extern void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, - bool drop); - -int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel); -int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl); -void brcms_c_get_current_rateset(struct brcms_c_info *wlc, - struct brcm_rateset *currs); -int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs); -int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period); -u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx); -void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, - s8 sslot_override); -void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval); -int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); -int brcms_c_get_tx_power(struct brcms_c_info *wlc); -void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc); - -/* helper functions */ -extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); -extern bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc); - -#endif /* _BRCM_PUB_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/rate.c b/drivers/staging/brcm80211/brcmsmac/rate.c deleted file mode 100644 index 0a0c0ad4f96..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/rate.c +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include "d11.h" -#include "pub.h" -#include "rate.h" - -/* - * Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate - * value - */ -const u8 rate_info[BRCM_MAXRATE + 1] = { - /* 0 1 2 3 4 5 6 7 8 9 */ -/* 0 */ 0x00, 0x00, 0x0a, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 10 */ 0x00, 0x37, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x00, -/* 20 */ 0x00, 0x00, 0x6e, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 30 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, -/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, -/* 50 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 60 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 70 */ 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, -/* 100 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c -}; - -/* rates are in units of Kbps */ -const struct brcms_mcs_info mcs_table[MCS_TABLE_SIZE] = { - /* MCS 0: SS 1, MOD: BPSK, CR 1/2 */ - {6500, 13500, CEIL(6500 * 10, 9), CEIL(13500 * 10, 9), 0x00, - BRCM_RATE_6M}, - /* MCS 1: SS 1, MOD: QPSK, CR 1/2 */ - {13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x08, - BRCM_RATE_12M}, - /* MCS 2: SS 1, MOD: QPSK, CR 3/4 */ - {19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x0A, - BRCM_RATE_18M}, - /* MCS 3: SS 1, MOD: 16QAM, CR 1/2 */ - {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x10, - BRCM_RATE_24M}, - /* MCS 4: SS 1, MOD: 16QAM, CR 3/4 */ - {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x12, - BRCM_RATE_36M}, - /* MCS 5: SS 1, MOD: 64QAM, CR 2/3 */ - {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x19, - BRCM_RATE_48M}, - /* MCS 6: SS 1, MOD: 64QAM, CR 3/4 */ - {58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x1A, - BRCM_RATE_54M}, - /* MCS 7: SS 1, MOD: 64QAM, CR 5/6 */ - {65000, 135000, CEIL(65000 * 10, 9), CEIL(135000 * 10, 9), 0x1C, - BRCM_RATE_54M}, - /* MCS 8: SS 2, MOD: BPSK, CR 1/2 */ - {13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x40, - BRCM_RATE_6M}, - /* MCS 9: SS 2, MOD: QPSK, CR 1/2 */ - {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x48, - BRCM_RATE_12M}, - /* MCS 10: SS 2, MOD: QPSK, CR 3/4 */ - {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x4A, - BRCM_RATE_18M}, - /* MCS 11: SS 2, MOD: 16QAM, CR 1/2 */ - {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x50, - BRCM_RATE_24M}, - /* MCS 12: SS 2, MOD: 16QAM, CR 3/4 */ - {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x52, - BRCM_RATE_36M}, - /* MCS 13: SS 2, MOD: 64QAM, CR 2/3 */ - {104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0x59, - BRCM_RATE_48M}, - /* MCS 14: SS 2, MOD: 64QAM, CR 3/4 */ - {117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x5A, - BRCM_RATE_54M}, - /* MCS 15: SS 2, MOD: 64QAM, CR 5/6 */ - {130000, 270000, CEIL(130000 * 10, 9), CEIL(270000 * 10, 9), 0x5C, - BRCM_RATE_54M}, - /* MCS 16: SS 3, MOD: BPSK, CR 1/2 */ - {19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x80, - BRCM_RATE_6M}, - /* MCS 17: SS 3, MOD: QPSK, CR 1/2 */ - {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x88, - BRCM_RATE_12M}, - /* MCS 18: SS 3, MOD: QPSK, CR 3/4 */ - {58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x8A, - BRCM_RATE_18M}, - /* MCS 19: SS 3, MOD: 16QAM, CR 1/2 */ - {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x90, - BRCM_RATE_24M}, - /* MCS 20: SS 3, MOD: 16QAM, CR 3/4 */ - {117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x92, - BRCM_RATE_36M}, - /* MCS 21: SS 3, MOD: 64QAM, CR 2/3 */ - {156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0x99, - BRCM_RATE_48M}, - /* MCS 22: SS 3, MOD: 64QAM, CR 3/4 */ - {175500, 364500, CEIL(175500 * 10, 9), CEIL(364500 * 10, 9), 0x9A, - BRCM_RATE_54M}, - /* MCS 23: SS 3, MOD: 64QAM, CR 5/6 */ - {195000, 405000, CEIL(195000 * 10, 9), CEIL(405000 * 10, 9), 0x9B, - BRCM_RATE_54M}, - /* MCS 24: SS 4, MOD: BPSK, CR 1/2 */ - {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0xC0, - BRCM_RATE_6M}, - /* MCS 25: SS 4, MOD: QPSK, CR 1/2 */ - {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0xC8, - BRCM_RATE_12M}, - /* MCS 26: SS 4, MOD: QPSK, CR 3/4 */ - {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0xCA, - BRCM_RATE_18M}, - /* MCS 27: SS 4, MOD: 16QAM, CR 1/2 */ - {104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0xD0, - BRCM_RATE_24M}, - /* MCS 28: SS 4, MOD: 16QAM, CR 3/4 */ - {156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0xD2, - BRCM_RATE_36M}, - /* MCS 29: SS 4, MOD: 64QAM, CR 2/3 */ - {208000, 432000, CEIL(208000 * 10, 9), CEIL(432000 * 10, 9), 0xD9, - BRCM_RATE_48M}, - /* MCS 30: SS 4, MOD: 64QAM, CR 3/4 */ - {234000, 486000, CEIL(234000 * 10, 9), CEIL(486000 * 10, 9), 0xDA, - BRCM_RATE_54M}, - /* MCS 31: SS 4, MOD: 64QAM, CR 5/6 */ - {260000, 540000, CEIL(260000 * 10, 9), CEIL(540000 * 10, 9), 0xDB, - BRCM_RATE_54M}, - /* MCS 32: SS 1, MOD: BPSK, CR 1/2 */ - {0, 6000, 0, CEIL(6000 * 10, 9), 0x00, BRCM_RATE_6M}, -}; - -/* - * phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams - * Number of spatial streams: always 1 other fields: refer to table 78 of - * section 17.3.2.2 of the original .11a standard - */ -struct legacy_phycfg { - u32 rate_ofdm; /* ofdm mac rate */ - /* phy ctl byte 3, code rate, modulation type, # of streams */ - u8 tx_phy_ctl3; -}; - -/* Number of legacy_rate_cfg entries in the table */ -#define LEGACY_PHYCFG_TABLE_SIZE 12 - -/* - * In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate - * Eventually MIMOPHY would also be converted to this format - * 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps - */ -static const struct -legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = { - {BRCM_RATE_1M, 0x00}, /* CCK 1Mbps, data rate 0 */ - {BRCM_RATE_2M, 0x08}, /* CCK 2Mbps, data rate 1 */ - {BRCM_RATE_5M5, 0x10}, /* CCK 5.5Mbps, data rate 2 */ - {BRCM_RATE_11M, 0x18}, /* CCK 11Mbps, data rate 3 */ - /* OFDM 6Mbps, code rate 1/2, BPSK, 1 spatial stream */ - {BRCM_RATE_6M, 0x00}, - /* OFDM 9Mbps, code rate 3/4, BPSK, 1 spatial stream */ - {BRCM_RATE_9M, 0x02}, - /* OFDM 12Mbps, code rate 1/2, QPSK, 1 spatial stream */ - {BRCM_RATE_12M, 0x08}, - /* OFDM 18Mbps, code rate 3/4, QPSK, 1 spatial stream */ - {BRCM_RATE_18M, 0x0A}, - /* OFDM 24Mbps, code rate 1/2, 16-QAM, 1 spatial stream */ - {BRCM_RATE_24M, 0x10}, - /* OFDM 36Mbps, code rate 3/4, 16-QAM, 1 spatial stream */ - {BRCM_RATE_36M, 0x12}, - /* OFDM 48Mbps, code rate 2/3, 64-QAM, 1 spatial stream */ - {BRCM_RATE_48M, 0x19}, - /* OFDM 54Mbps, code rate 3/4, 64-QAM, 1 spatial stream */ - {BRCM_RATE_54M, 0x1A}, -}; - -/* Hardware rates (also encodes default basic rates) */ - -const struct brcms_c_rateset cck_ofdm_mimo_rates = { - 12, - /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, */ - { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - /* 54 Mbps */ - 0x6c}, - 0x00, - { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -const struct brcms_c_rateset ofdm_mimo_rates = { - 8, - /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, - 0x00, - { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -/* Default ratesets that include MCS32 for 40BW channels */ -static const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { - 12, - /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48 */ - { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - /* 54 Mbps */ - 0x6c}, - 0x00, - { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -static const struct brcms_c_rateset ofdm_40bw_mimo_rates = { - 8, - /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, - 0x00, - { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -const struct brcms_c_rateset cck_ofdm_rates = { - 12, - /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48,*/ - { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, - /*54 Mbps */ - 0x6c}, - 0x00, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -const struct brcms_c_rateset gphy_legacy_rates = { - 4, - /* 1b, 2b, 5.5b, 11b Mbps */ - { 0x82, 0x84, 0x8b, 0x96}, - 0x00, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -const struct brcms_c_rateset ofdm_rates = { - 8, - /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ - { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, - 0x00, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -const struct brcms_c_rateset cck_rates = { - 4, - /* 1b, 2b, 5.5, 11 Mbps */ - { 0x82, 0x84, 0x0b, 0x16}, - 0x00, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -/* check if rateset is valid. - * if check_brate is true, rateset without a basic rate is considered NOT valid. - */ -static bool brcms_c_rateset_valid(struct brcms_c_rateset *rs, bool check_brate) -{ - uint idx; - - if (!rs->count) - return false; - - if (!check_brate) - return true; - - /* error if no basic rates */ - for (idx = 0; idx < rs->count; idx++) { - if (rs->rates[idx] & BRCMS_RATE_FLAG) - return true; - } - return false; -} - -void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams) -{ - int i; - for (i = txstreams; i < MAX_STREAMS_SUPPORTED; i++) - rs->mcs[i] = 0; -} - -/* - * filter based on hardware rateset, and sort filtered rateset with basic - * bit(s) preserved, and check if resulting rateset is valid. -*/ -bool -brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, - const struct brcms_c_rateset *hw_rs, - bool check_brate, u8 txstreams) -{ - u8 rateset[BRCM_MAXRATE + 1]; - u8 r; - uint count; - uint i; - - memset(rateset, 0, sizeof(rateset)); - count = rs->count; - - for (i = 0; i < count; i++) { - /* mask off "basic rate" bit, BRCMS_RATE_FLAG */ - r = (int)rs->rates[i] & BRCMS_RATE_MASK; - if ((r > BRCM_MAXRATE) || (rate_info[r] == 0)) - continue; - rateset[r] = rs->rates[i]; /* preserve basic bit! */ - } - - /* fill out the rates in order, looking at only supported rates */ - count = 0; - for (i = 0; i < hw_rs->count; i++) { - r = hw_rs->rates[i] & BRCMS_RATE_MASK; - if (rateset[r]) - rs->rates[count++] = rateset[r]; - } - - rs->count = count; - - /* only set the mcs rate bit if the equivalent hw mcs bit is set */ - for (i = 0; i < MCSSET_LEN; i++) - rs->mcs[i] = (rs->mcs[i] & hw_rs->mcs[i]); - - if (brcms_c_rateset_valid(rs, check_brate)) - return true; - else - return false; -} - -/* calculate the rate of a rx'd frame and return it as a ratespec */ -u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) -{ - int phy_type; - u32 rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT; - - phy_type = - ((rxh->RxChan & RXS_CHAN_PHYTYPE_MASK) >> RXS_CHAN_PHYTYPE_SHIFT); - - if ((phy_type == PHY_TYPE_N) || (phy_type == PHY_TYPE_SSN) || - (phy_type == PHY_TYPE_LCN) || (phy_type == PHY_TYPE_HT)) { - switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) { - case PRXS0_CCK: - rspec = - cck_phy2mac_rate( - ((struct cck_phy_hdr *) plcp)->signal); - break; - case PRXS0_OFDM: - rspec = - ofdm_phy2mac_rate( - ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); - break; - case PRXS0_PREN: - rspec = (plcp[0] & MIMO_PLCP_MCS_MASK) | RSPEC_MIMORATE; - if (plcp[0] & MIMO_PLCP_40MHZ) { - /* indicate rspec is for 40 MHz mode */ - rspec &= ~RSPEC_BW_MASK; - rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT); - } - break; - case PRXS0_STDN: - /* fallthru */ - default: - /* not supported, error condition */ - break; - } - if (plcp3_issgi(plcp[3])) - rspec |= RSPEC_SHORT_GI; - } else - if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM)) - rspec = ofdm_phy2mac_rate( - ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); - else - rspec = cck_phy2mac_rate( - ((struct cck_phy_hdr *) plcp)->signal); - - return rspec; -} - -/* copy rateset src to dst as-is (no masking or sorting) */ -void brcms_c_rateset_copy(const struct brcms_c_rateset *src, - struct brcms_c_rateset *dst) -{ - memcpy(dst, src, sizeof(struct brcms_c_rateset)); -} - -/* - * Copy and selectively filter one rateset to another. - * 'basic_only' means only copy basic rates. - * 'rates' indicates cck (11b) and ofdm rates combinations. - * - 0: cck and ofdm - * - 1: cck only - * - 2: ofdm only - * 'xmask' is the copy mask (typically 0x7f or 0xff). - */ -void -brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, - bool basic_only, u8 rates, uint xmask, bool mcsallow) -{ - uint i; - uint r; - uint count; - - count = 0; - for (i = 0; i < src->count; i++) { - r = src->rates[i]; - if (basic_only && !(r & BRCMS_RATE_FLAG)) - continue; - if (rates == BRCMS_RATES_CCK && - is_ofdm_rate((r & BRCMS_RATE_MASK))) - continue; - if (rates == BRCMS_RATES_OFDM && - is_cck_rate((r & BRCMS_RATE_MASK))) - continue; - dst->rates[count++] = r & xmask; - } - dst->count = count; - dst->htphy_membership = src->htphy_membership; - - if (mcsallow && rates != BRCMS_RATES_CCK) - memcpy(&dst->mcs[0], &src->mcs[0], MCSSET_LEN); - else - brcms_c_rateset_mcs_clear(dst); -} - -/* select rateset for a given phy_type and bandtype and filter it, sort it - * and fill rs_tgt with result - */ -void -brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, - const struct brcms_c_rateset *rs_hw, - uint phy_type, int bandtype, bool cck_only, - uint rate_mask, bool mcsallow, u8 bw, u8 txstreams) -{ - const struct brcms_c_rateset *rs_dflt; - struct brcms_c_rateset rs_sel; - if ((PHYTYPE_IS(phy_type, PHY_TYPE_HT)) || - (PHYTYPE_IS(phy_type, PHY_TYPE_N)) || - (PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) || - (PHYTYPE_IS(phy_type, PHY_TYPE_SSN))) { - if (bandtype == BRCM_BAND_5G) - rs_dflt = (bw == BRCMS_20_MHZ ? - &ofdm_mimo_rates : &ofdm_40bw_mimo_rates); - else - rs_dflt = (bw == BRCMS_20_MHZ ? - &cck_ofdm_mimo_rates : - &cck_ofdm_40bw_mimo_rates); - } else if (PHYTYPE_IS(phy_type, PHY_TYPE_LP)) { - rs_dflt = (bandtype == BRCM_BAND_5G) ? - &ofdm_rates : &cck_ofdm_rates; - } else if (PHYTYPE_IS(phy_type, PHY_TYPE_A)) { - rs_dflt = &ofdm_rates; - } else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) { - rs_dflt = &cck_ofdm_rates; - } else { - /* should not happen, error condition */ - rs_dflt = &cck_rates; /* force cck */ - } - - /* if hw rateset is not supplied, assign selected rateset to it */ - if (!rs_hw) - rs_hw = rs_dflt; - - brcms_c_rateset_copy(rs_dflt, &rs_sel); - brcms_c_rateset_mcs_upd(&rs_sel, txstreams); - brcms_c_rateset_filter(&rs_sel, rs_tgt, false, - cck_only ? BRCMS_RATES_CCK : BRCMS_RATES_CCK_OFDM, - rate_mask, mcsallow); - brcms_c_rate_hwrs_filter_sort_validate(rs_tgt, rs_hw, false, - mcsallow ? txstreams : 1); -} - -s16 brcms_c_rate_legacy_phyctl(uint rate) -{ - uint i; - for (i = 0; i < LEGACY_PHYCFG_TABLE_SIZE; i++) - if (rate == legacy_phycfg_table[i].rate_ofdm) - return legacy_phycfg_table[i].tx_phy_ctl3; - - return -1; -} - -void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset) -{ - uint i; - for (i = 0; i < MCSSET_LEN; i++) - rateset->mcs[i] = 0; -} - -void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams) -{ - memcpy(&rateset->mcs[0], &cck_ofdm_mimo_rates.mcs[0], MCSSET_LEN); - brcms_c_rateset_mcs_upd(rateset, txstreams); -} - -/* Based on bandwidth passed, allow/disallow MCS 32 in the rateset */ -void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw) -{ - if (bw == BRCMS_40_MHZ) - setbit(rateset->mcs, 32); - else - clrbit(rateset->mcs, 32); -} diff --git a/drivers/staging/brcm80211/brcmsmac/rate.h b/drivers/staging/brcm80211/brcmsmac/rate.h deleted file mode 100644 index e7b9dc2f273..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/rate.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_RATE_H_ -#define _BRCM_RATE_H_ - -#include "types.h" -#include "d11.h" - -extern const u8 rate_info[]; -extern const struct brcms_c_rateset cck_ofdm_mimo_rates; -extern const struct brcms_c_rateset ofdm_mimo_rates; -extern const struct brcms_c_rateset cck_ofdm_rates; -extern const struct brcms_c_rateset ofdm_rates; -extern const struct brcms_c_rateset cck_rates; -extern const struct brcms_c_rateset gphy_legacy_rates; -extern const struct brcms_c_rateset rate_limit_1_2; - -struct brcms_mcs_info { - /* phy rate in kbps [20Mhz] */ - u32 phy_rate_20; - /* phy rate in kbps [40Mhz] */ - u32 phy_rate_40; - /* phy rate in kbps [20Mhz] with SGI */ - u32 phy_rate_20_sgi; - /* phy rate in kbps [40Mhz] with SGI */ - u32 phy_rate_40_sgi; - /* phy ctl byte 3, code rate, modulation type, # of streams */ - u8 tx_phy_ctl3; - /* matching legacy ofdm rate in 500bkps */ - u8 leg_ofdm; -}; - -#define BRCMS_MAXMCS 32 /* max valid mcs index */ -#define MCS_TABLE_SIZE 33 /* Number of mcs entries in the table */ -extern const struct brcms_mcs_info mcs_table[]; - -#define MCS_TXS_MASK 0xc0 /* num tx streams - 1 bit mask */ -#define MCS_TXS_SHIFT 6 /* num tx streams - 1 bit shift */ - -/* returns num tx streams - 1 */ -static inline u8 mcs_2_txstreams(u8 mcs) -{ - return (mcs_table[mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT; -} - -static inline uint mcs_2_rate(u8 mcs, bool is40, bool sgi) -{ - if (sgi) { - if (is40) - return mcs_table[mcs].phy_rate_40_sgi; - return mcs_table[mcs].phy_rate_20_sgi; - } - if (is40) - return mcs_table[mcs].phy_rate_40; - - return mcs_table[mcs].phy_rate_20; -} - -/* Macro to use the rate_info table */ -#define BRCMS_RATE_MASK_FULL 0xff /* Rate value mask with basic rate flag */ - -/* - * rate spec : holds rate and mode specific information required to generate a - * tx frame. Legacy CCK and OFDM information is held in the same manner as was - * done in the past (in the lower byte) the upper 3 bytes primarily hold MIMO - * specific information - */ - -/* rate spec bit fields */ - -/* Either 500Kbps units or MIMO MCS idx */ -#define RSPEC_RATE_MASK 0x0000007F -/* mimo MCS is stored in RSPEC_RATE_MASK */ -#define RSPEC_MIMORATE 0x08000000 -/* mimo bw mask */ -#define RSPEC_BW_MASK 0x00000700 -/* mimo bw shift */ -#define RSPEC_BW_SHIFT 8 -/* mimo Space/Time/Frequency mode mask */ -#define RSPEC_STF_MASK 0x00003800 -/* mimo Space/Time/Frequency mode shift */ -#define RSPEC_STF_SHIFT 11 -/* mimo coding type mask */ -#define RSPEC_CT_MASK 0x0000C000 -/* mimo coding type shift */ -#define RSPEC_CT_SHIFT 14 -/* mimo num STC streams per PLCP defn. */ -#define RSPEC_STC_MASK 0x00300000 -/* mimo num STC streams per PLCP defn. */ -#define RSPEC_STC_SHIFT 20 -/* mimo bit indicates adv coding in use */ -#define RSPEC_LDPC_CODING 0x00400000 -/* mimo bit indicates short GI in use */ -#define RSPEC_SHORT_GI 0x00800000 -/* bit indicates override both rate & mode */ -#define RSPEC_OVERRIDE 0x80000000 -/* bit indicates override rate only */ -#define RSPEC_OVERRIDE_MCS_ONLY 0x40000000 - -static inline bool rspec_active(u32 rspec) -{ - return rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE); -} - -static inline u8 rspec_phytxbyte2(u32 rspec) -{ - return (rspec & 0xff00) >> 8; -} - -static inline u32 rspec_get_bw(u32 rspec) -{ - return (rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT; -} - -static inline bool rspec_issgi(u32 rspec) -{ - return (rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI; -} - -static inline bool rspec_is40mhz(u32 rspec) -{ - u32 bw = rspec_get_bw(rspec); - - return bw == PHY_TXC1_BW_40MHZ || bw == PHY_TXC1_BW_40MHZ_DUP; -} - -static inline uint rspec2rate(u32 rspec) -{ - if (rspec & RSPEC_MIMORATE) - return mcs_2_rate(rspec & RSPEC_RATE_MASK, rspec_is40mhz(rspec), - rspec_issgi(rspec)); - return rspec & RSPEC_RATE_MASK; -} - -static inline u8 rspec_mimoplcp3(u32 rspec) -{ - return (rspec & 0xf00000) >> 16; -} - -static inline bool plcp3_issgi(u8 plcp) -{ - return (plcp & (RSPEC_SHORT_GI >> 16)) != 0; -} - -static inline uint rspec_stc(u32 rspec) -{ - return (rspec & RSPEC_STC_MASK) >> RSPEC_STC_SHIFT; -} - -static inline uint rspec_stf(u32 rspec) -{ - return (rspec & RSPEC_STF_MASK) >> RSPEC_STF_SHIFT; -} - -static inline bool is_mcs_rate(u32 ratespec) -{ - return (ratespec & RSPEC_MIMORATE) != 0; -} - -static inline bool is_ofdm_rate(u32 ratespec) -{ - return !is_mcs_rate(ratespec) && - (rate_info[ratespec & RSPEC_RATE_MASK] & BRCMS_RATE_FLAG); -} - -static inline bool is_cck_rate(u32 ratespec) -{ - u32 rate = (ratespec & BRCMS_RATE_MASK); - - return !is_mcs_rate(ratespec) && ( - rate == BRCM_RATE_1M || rate == BRCM_RATE_2M || - rate == BRCM_RATE_5M5 || rate == BRCM_RATE_11M); -} - -static inline bool is_single_stream(u8 mcs) -{ - return mcs <= HIGHEST_SINGLE_STREAM_MCS || mcs == 32; -} - -static inline u8 cck_rspec(u8 cck) -{ - return cck & RSPEC_RATE_MASK; -} - -/* Convert encoded rate value in plcp header to numerical rates in 500 KHz - * increments */ -extern const u8 ofdm_rate_lookup[]; - -static inline u8 ofdm_phy2mac_rate(u8 rlpt) -{ - return ofdm_rate_lookup[rlpt & 0x7]; -} - -static inline u8 cck_phy2mac_rate(u8 signal) -{ - return signal/5; -} - -/* Rates specified in brcms_c_rateset_filter() */ -#define BRCMS_RATES_CCK_OFDM 0 -#define BRCMS_RATES_CCK 1 -#define BRCMS_RATES_OFDM 2 - -/* sanitize, and sort a rateset with the basic bit(s) preserved, validate - * rateset */ -extern bool -brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, - const struct brcms_c_rateset *hw_rs, - bool check_brate, u8 txstreams); -/* copy rateset src to dst as-is (no masking or sorting) */ -extern void brcms_c_rateset_copy(const struct brcms_c_rateset *src, - struct brcms_c_rateset *dst); - -/* would be nice to have these documented ... */ -extern u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp); - -extern void brcms_c_rateset_filter(struct brcms_c_rateset *src, - struct brcms_c_rateset *dst, bool basic_only, u8 rates, uint xmask, - bool mcsallow); - -extern void -brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, - const struct brcms_c_rateset *rs_hw, uint phy_type, - int bandtype, bool cck_only, uint rate_mask, - bool mcsallow, u8 bw, u8 txstreams); - -extern s16 brcms_c_rate_legacy_phyctl(uint rate); - -extern void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams); -extern void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset); -extern void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, - u8 txstreams); -extern void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, - u8 bw); - -#endif /* _BRCM_RATE_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/scb.h b/drivers/staging/brcm80211/brcmsmac/scb.h deleted file mode 100644 index 51c79c7239b..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/scb.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_SCB_H_ -#define _BRCM_SCB_H_ - -#include -#include -#include -#include "types.h" - -#define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */ - -#define AMPDU_MAX_SCB_TID NUMPRIO - -/* scb flags */ -#define SCB_WMECAP 0x0040 -#define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */ -#define SCB_IS40 0x80000 /* 40MHz capable */ -#define SCB_STBCCAP 0x40000000 /* STBC Capable */ - -#define SCB_MAGIC 0xbeefcafe - -/* structure to store per-tid state for the ampdu initiator */ -struct scb_ampdu_tid_ini { - u8 tx_in_transit; /* number of pending mpdus in transit in driver */ - u8 tid; /* initiator tid for easy lookup */ - /* tx retry count; indexed by seq modulo */ - u8 txretry[AMPDU_TX_BA_MAX_WSIZE]; - struct scb *scb; /* backptr for easy lookup */ - u8 ba_wsize; /* negotiated ba window size (in pdu) */ -}; - -struct scb_ampdu { - struct scb *scb; /* back pointer for easy reference */ - u8 mpdu_density; /* mpdu density */ - u8 max_pdu; /* max pdus allowed in ampdu */ - u8 release; /* # of mpdus released at a time */ - u16 min_len; /* min mpdu len to support the density */ - u32 max_rx_ampdu_bytes; /* max ampdu rcv length; 8k, 16k, 32k, 64k */ - - /* - * This could easily be a ini[] pointer and we keep this info in wl - * itself instead of having mac80211 hold it for us. Also could be made - * dynamic per tid instead of static. - */ - /* initiator info - per tid (NUMPRIO): */ - struct scb_ampdu_tid_ini ini[AMPDU_MAX_SCB_TID]; -}; - -/* station control block - one per remote MAC address */ -struct scb { - u32 magic; - u32 flags; /* various bit flags as defined below */ - u32 flags2; /* various bit flags2 as defined below */ - u8 state; /* current state bitfield of auth/assoc process */ - u8 ea[ETH_ALEN]; /* station address */ - uint fragresid[NUMPRIO];/* #bytes unused in frag buffer per prio */ - - u16 seqctl[NUMPRIO]; /* seqctl of last received frame (for dups) */ - /* seqctl of last received frame (for dups) for non-QoS data and - * management */ - u16 seqctl_nonqos; - u16 seqnum[NUMPRIO];/* WME: driver maintained sw seqnum per priority */ - - struct scb_ampdu scb_ampdu; /* AMPDU state including per tid info */ -}; - -#endif /* _BRCM_SCB_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c deleted file mode 100644 index 99f791048e8..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include "pub.h" -#include "nicpci.h" -#include "aiutils.h" -#include "otp.h" -#include "srom.h" - -/* - * SROM CRC8 polynomial value: - * - * x^8 + x^7 +x^6 + x^4 + x^2 + 1 - */ -#define SROM_CRC8_POLY 0xAB - -/* Maximum srom: 6 Kilobits == 768 bytes */ -#define SROM_MAX 768 - -/* PCI fields */ -#define PCI_F0DEVID 48 - -#define SROM_WORDS 64 - -#define SROM_SSID 2 - -#define SROM_WL1LHMAXP 29 - -#define SROM_WL1LPAB0 30 -#define SROM_WL1LPAB1 31 -#define SROM_WL1LPAB2 32 - -#define SROM_WL1HPAB0 33 -#define SROM_WL1HPAB1 34 -#define SROM_WL1HPAB2 35 - -#define SROM_MACHI_IL0 36 -#define SROM_MACMID_IL0 37 -#define SROM_MACLO_IL0 38 -#define SROM_MACHI_ET1 42 -#define SROM_MACMID_ET1 43 -#define SROM_MACLO_ET1 44 -#define SROM3_MACHI 37 -#define SROM3_MACMID 38 -#define SROM3_MACLO 39 - -#define SROM_BXARSSI2G 40 -#define SROM_BXARSSI5G 41 - -#define SROM_TRI52G 42 -#define SROM_TRI5GHL 43 - -#define SROM_RXPO52G 45 - -#define SROM_AABREV 46 -/* Fields in AABREV */ -#define SROM_BR_MASK 0x00ff -#define SROM_CC_MASK 0x0f00 -#define SROM_CC_SHIFT 8 -#define SROM_AA0_MASK 0x3000 -#define SROM_AA0_SHIFT 12 -#define SROM_AA1_MASK 0xc000 -#define SROM_AA1_SHIFT 14 - -#define SROM_WL0PAB0 47 -#define SROM_WL0PAB1 48 -#define SROM_WL0PAB2 49 - -#define SROM_LEDBH10 50 -#define SROM_LEDBH32 51 - -#define SROM_WL10MAXP 52 - -#define SROM_WL1PAB0 53 -#define SROM_WL1PAB1 54 -#define SROM_WL1PAB2 55 - -#define SROM_ITT 56 - -#define SROM_BFL 57 -#define SROM_BFL2 28 -#define SROM3_BFL2 61 - -#define SROM_AG10 58 - -#define SROM_CCODE 59 - -#define SROM_OPO 60 - -#define SROM3_LEDDC 62 - -#define SROM_CRCREV 63 - -/* SROM Rev 4: Reallocate the software part of the srom to accommodate - * MIMO features. It assumes up to two PCIE functions and 440 bytes - * of usable srom i.e. the usable storage in chips with OTP that - * implements hardware redundancy. - */ - -#define SROM4_WORDS 220 - -#define SROM4_SIGN 32 -#define SROM4_SIGNATURE 0x5372 - -#define SROM4_BREV 33 - -#define SROM4_BFL0 34 -#define SROM4_BFL1 35 -#define SROM4_BFL2 36 -#define SROM4_BFL3 37 -#define SROM5_BFL0 37 -#define SROM5_BFL1 38 -#define SROM5_BFL2 39 -#define SROM5_BFL3 40 - -#define SROM4_MACHI 38 -#define SROM4_MACMID 39 -#define SROM4_MACLO 40 -#define SROM5_MACHI 41 -#define SROM5_MACMID 42 -#define SROM5_MACLO 43 - -#define SROM4_CCODE 41 -#define SROM4_REGREV 42 -#define SROM5_CCODE 34 -#define SROM5_REGREV 35 - -#define SROM4_LEDBH10 43 -#define SROM4_LEDBH32 44 -#define SROM5_LEDBH10 59 -#define SROM5_LEDBH32 60 - -#define SROM4_LEDDC 45 -#define SROM5_LEDDC 45 - -#define SROM4_AA 46 - -#define SROM4_AG10 47 -#define SROM4_AG32 48 - -#define SROM4_TXPID2G 49 -#define SROM4_TXPID5G 51 -#define SROM4_TXPID5GL 53 -#define SROM4_TXPID5GH 55 - -#define SROM4_TXRXC 61 -#define SROM4_TXCHAIN_MASK 0x000f -#define SROM4_TXCHAIN_SHIFT 0 -#define SROM4_RXCHAIN_MASK 0x00f0 -#define SROM4_RXCHAIN_SHIFT 4 -#define SROM4_SWITCH_MASK 0xff00 -#define SROM4_SWITCH_SHIFT 8 - -/* Per-path fields */ -#define MAX_PATH_SROM 4 -#define SROM4_PATH0 64 -#define SROM4_PATH1 87 -#define SROM4_PATH2 110 -#define SROM4_PATH3 133 - -#define SROM4_2G_ITT_MAXP 0 -#define SROM4_2G_PA 1 -#define SROM4_5G_ITT_MAXP 5 -#define SROM4_5GLH_MAXP 6 -#define SROM4_5G_PA 7 -#define SROM4_5GL_PA 11 -#define SROM4_5GH_PA 15 - -/* All the miriad power offsets */ -#define SROM4_2G_CCKPO 156 -#define SROM4_2G_OFDMPO 157 -#define SROM4_5G_OFDMPO 159 -#define SROM4_5GL_OFDMPO 161 -#define SROM4_5GH_OFDMPO 163 -#define SROM4_2G_MCSPO 165 -#define SROM4_5G_MCSPO 173 -#define SROM4_5GL_MCSPO 181 -#define SROM4_5GH_MCSPO 189 -#define SROM4_CDDPO 197 -#define SROM4_STBCPO 198 -#define SROM4_BW40PO 199 -#define SROM4_BWDUPPO 200 - -#define SROM4_CRCREV 219 - -/* SROM Rev 8: Make space for a 48word hardware header for PCIe rev >= 6. - * This is acombined srom for both MIMO and SISO boards, usable in - * the .130 4Kilobit OTP with hardware redundancy. - */ -#define SROM8_BREV 65 - -#define SROM8_BFL0 66 -#define SROM8_BFL1 67 -#define SROM8_BFL2 68 -#define SROM8_BFL3 69 - -#define SROM8_MACHI 70 -#define SROM8_MACMID 71 -#define SROM8_MACLO 72 - -#define SROM8_CCODE 73 -#define SROM8_REGREV 74 - -#define SROM8_LEDBH10 75 -#define SROM8_LEDBH32 76 - -#define SROM8_LEDDC 77 - -#define SROM8_AA 78 - -#define SROM8_AG10 79 -#define SROM8_AG32 80 - -#define SROM8_TXRXC 81 - -#define SROM8_BXARSSI2G 82 -#define SROM8_BXARSSI5G 83 -#define SROM8_TRI52G 84 -#define SROM8_TRI5GHL 85 -#define SROM8_RXPO52G 86 - -#define SROM8_FEM2G 87 -#define SROM8_FEM5G 88 -#define SROM8_FEM_ANTSWLUT_MASK 0xf800 -#define SROM8_FEM_ANTSWLUT_SHIFT 11 -#define SROM8_FEM_TR_ISO_MASK 0x0700 -#define SROM8_FEM_TR_ISO_SHIFT 8 -#define SROM8_FEM_PDET_RANGE_MASK 0x00f8 -#define SROM8_FEM_PDET_RANGE_SHIFT 3 -#define SROM8_FEM_EXTPA_GAIN_MASK 0x0006 -#define SROM8_FEM_EXTPA_GAIN_SHIFT 1 -#define SROM8_FEM_TSSIPOS_MASK 0x0001 -#define SROM8_FEM_TSSIPOS_SHIFT 0 - -#define SROM8_THERMAL 89 - -/* Temp sense related entries */ -#define SROM8_MPWR_RAWTS 90 -#define SROM8_TS_SLP_OPT_CORRX 91 -/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, - * IQSWP: IQ CAL swap disable */ -#define SROM8_FOC_HWIQ_IQSWP 92 - -/* Temperature delta for PHY calibration */ -#define SROM8_PHYCAL_TEMPDELTA 93 - -/* Per-path offsets & fields */ -#define SROM8_PATH0 96 -#define SROM8_PATH1 112 -#define SROM8_PATH2 128 -#define SROM8_PATH3 144 - -#define SROM8_2G_ITT_MAXP 0 -#define SROM8_2G_PA 1 -#define SROM8_5G_ITT_MAXP 4 -#define SROM8_5GLH_MAXP 5 -#define SROM8_5G_PA 6 -#define SROM8_5GL_PA 9 -#define SROM8_5GH_PA 12 - -/* All the miriad power offsets */ -#define SROM8_2G_CCKPO 160 - -#define SROM8_2G_OFDMPO 161 -#define SROM8_5G_OFDMPO 163 -#define SROM8_5GL_OFDMPO 165 -#define SROM8_5GH_OFDMPO 167 - -#define SROM8_2G_MCSPO 169 -#define SROM8_5G_MCSPO 177 -#define SROM8_5GL_MCSPO 185 -#define SROM8_5GH_MCSPO 193 - -#define SROM8_CDDPO 201 -#define SROM8_STBCPO 202 -#define SROM8_BW40PO 203 -#define SROM8_BWDUPPO 204 - -/* SISO PA parameters are in the path0 spaces */ -#define SROM8_SISO 96 - -/* Legacy names for SISO PA paramters */ -#define SROM8_W0_ITTMAXP (SROM8_SISO + SROM8_2G_ITT_MAXP) -#define SROM8_W0_PAB0 (SROM8_SISO + SROM8_2G_PA) -#define SROM8_W0_PAB1 (SROM8_SISO + SROM8_2G_PA + 1) -#define SROM8_W0_PAB2 (SROM8_SISO + SROM8_2G_PA + 2) -#define SROM8_W1_ITTMAXP (SROM8_SISO + SROM8_5G_ITT_MAXP) -#define SROM8_W1_MAXP_LCHC (SROM8_SISO + SROM8_5GLH_MAXP) -#define SROM8_W1_PAB0 (SROM8_SISO + SROM8_5G_PA) -#define SROM8_W1_PAB1 (SROM8_SISO + SROM8_5G_PA + 1) -#define SROM8_W1_PAB2 (SROM8_SISO + SROM8_5G_PA + 2) -#define SROM8_W1_PAB0_LC (SROM8_SISO + SROM8_5GL_PA) -#define SROM8_W1_PAB1_LC (SROM8_SISO + SROM8_5GL_PA + 1) -#define SROM8_W1_PAB2_LC (SROM8_SISO + SROM8_5GL_PA + 2) -#define SROM8_W1_PAB0_HC (SROM8_SISO + SROM8_5GH_PA) -#define SROM8_W1_PAB1_HC (SROM8_SISO + SROM8_5GH_PA + 1) -#define SROM8_W1_PAB2_HC (SROM8_SISO + SROM8_5GH_PA + 2) - -/* SROM REV 9 */ -#define SROM9_2GPO_CCKBW20 160 -#define SROM9_2GPO_CCKBW20UL 161 -#define SROM9_2GPO_LOFDMBW20 162 -#define SROM9_2GPO_LOFDMBW20UL 164 - -#define SROM9_5GLPO_LOFDMBW20 166 -#define SROM9_5GLPO_LOFDMBW20UL 168 -#define SROM9_5GMPO_LOFDMBW20 170 -#define SROM9_5GMPO_LOFDMBW20UL 172 -#define SROM9_5GHPO_LOFDMBW20 174 -#define SROM9_5GHPO_LOFDMBW20UL 176 - -#define SROM9_2GPO_MCSBW20 178 -#define SROM9_2GPO_MCSBW20UL 180 -#define SROM9_2GPO_MCSBW40 182 - -#define SROM9_5GLPO_MCSBW20 184 -#define SROM9_5GLPO_MCSBW20UL 186 -#define SROM9_5GLPO_MCSBW40 188 -#define SROM9_5GMPO_MCSBW20 190 -#define SROM9_5GMPO_MCSBW20UL 192 -#define SROM9_5GMPO_MCSBW40 194 -#define SROM9_5GHPO_MCSBW20 196 -#define SROM9_5GHPO_MCSBW20UL 198 -#define SROM9_5GHPO_MCSBW40 200 - -#define SROM9_PO_MCS32 202 -#define SROM9_PO_LOFDM40DUP 203 - -/* SROM flags (see sromvar_t) */ - -/* value continues as described by the next entry */ -#define SRFL_MORE 1 -#define SRFL_NOFFS 2 /* value bits can't be all one's */ -#define SRFL_PRHEX 4 /* value is in hexdecimal format */ -#define SRFL_PRSIGN 8 /* value is in signed decimal format */ -#define SRFL_CCODE 0x10 /* value is in country code format */ -#define SRFL_ETHADDR 0x20 /* value is an Ethernet address */ -#define SRFL_LEDDC 0x40 /* value is an LED duty cycle */ -/* do not generate a nvram param, entry is for mfgc */ -#define SRFL_NOVAR 0x80 - -/* Max. nvram variable table size */ -#define MAXSZ_NVRAM_VARS 4096 - -/* - * indicates type of value. - */ -enum brcms_srom_var_type { - BRCMS_SROM_STRING, - BRCMS_SROM_SNUMBER, - BRCMS_SROM_UNUMBER -}; - -/* - * storage type for srom variable. - * - * var_list: for linked list operations. - * varid: identifier of the variable. - * var_type: type of variable. - * buf: variable value when var_type == BRCMS_SROM_STRING. - * uval: unsigned variable value when var_type == BRCMS_SROM_UNUMBER. - * sval: signed variable value when var_type == BRCMS_SROM_SNUMBER. - */ -struct brcms_srom_list_head { - struct list_head var_list; - enum brcms_srom_id varid; - enum brcms_srom_var_type var_type; - union { - char buf[0]; - u32 uval; - s32 sval; - }; -}; - -struct brcms_sromvar { - enum brcms_srom_id varid; - u32 revmask; - u32 flags; - u16 off; - u16 mask; -}; - -struct brcms_varbuf { - char *base; /* pointer to buffer base */ - char *buf; /* pointer to current position */ - unsigned int size; /* current (residual) size in bytes */ -}; - -/* - * Assumptions: - * - Ethernet address spans across 3 consecutive words - * - * Table rules: - * - Add multiple entries next to each other if a value spans across multiple - * words (even multiple fields in the same word) with each entry except the - * last having it's SRFL_MORE bit set. - * - Ethernet address entry does not follow above rule and must not have - * SRFL_MORE bit set. Its SRFL_ETHADDR bit implies it takes multiple words. - * - The last entry's name field must be NULL to indicate the end of the table. - * Other entries must have non-NULL name. - */ -static const struct brcms_sromvar pci_sromvars[] = { - {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, - 0xffff}, - {BRCMS_SROM_BOARDREV, 0x0000000e, SRFL_PRHEX, SROM_AABREV, - SROM_BR_MASK}, - {BRCMS_SROM_BOARDREV, 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, - {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM_BFL2, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM3_BFL2, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL1, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL1, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, - {BRCMS_SROM_BOARDFLAGS2, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL3, 0xffff}, - {BRCMS_SROM_BOARDFLAGS2, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL3, 0xffff}, - {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, - {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000008, 0, SROM3_MACLO, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000010, 0, SROM4_MACLO, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x000000e0, 0, SROM5_MACLO, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, - {BRCMS_SROM_CC, 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, - {BRCMS_SROM_REGREV, 0x00000008, 0, SROM_OPO, 0xff00}, - {BRCMS_SROM_REGREV, 0x00000010, 0, SROM4_REGREV, 0x00ff}, - {BRCMS_SROM_REGREV, 0x000000e0, 0, SROM5_REGREV, 0x00ff}, - {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, - {BRCMS_SROM_LEDBH0, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, - {BRCMS_SROM_LEDBH0, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, - {BRCMS_SROM_LEDBH0, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, - {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, - {BRCMS_SROM_PA0B0, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, - {BRCMS_SROM_PA0B1, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, - {BRCMS_SROM_PA0B2, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, - {BRCMS_SROM_PA0ITSSIT, 0x0000000e, 0, SROM_ITT, 0x00ff}, - {BRCMS_SROM_PA0MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, - {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, - {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, - {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, - {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, - {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, - {BRCMS_SROM_OPO, 0x0000000c, 0, SROM_OPO, 0x00ff}, - {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, - {BRCMS_SROM_AA2G, 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, - {BRCMS_SROM_AA2G, 0x000000f0, 0, SROM4_AA, 0x00ff}, - {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, - {BRCMS_SROM_AA5G, 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, - {BRCMS_SROM_AA5G, 0x000000f0, 0, SROM4_AA, 0xff00}, - {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, - {BRCMS_SROM_AG0, 0x0000000e, 0, SROM_AG10, 0x00ff}, - {BRCMS_SROM_AG1, 0x0000000e, 0, SROM_AG10, 0xff00}, - {BRCMS_SROM_AG0, 0x000000f0, 0, SROM4_AG10, 0x00ff}, - {BRCMS_SROM_AG1, 0x000000f0, 0, SROM4_AG10, 0xff00}, - {BRCMS_SROM_AG2, 0x000000f0, 0, SROM4_AG32, 0x00ff}, - {BRCMS_SROM_AG3, 0x000000f0, 0, SROM4_AG32, 0xff00}, - {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, - {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, - {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, - {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, - {BRCMS_SROM_PA1B0, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, - {BRCMS_SROM_PA1B1, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, - {BRCMS_SROM_PA1B2, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, - {BRCMS_SROM_PA1LOB0, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, - {BRCMS_SROM_PA1LOB1, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, - {BRCMS_SROM_PA1LOB2, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, - {BRCMS_SROM_PA1HIB0, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, - {BRCMS_SROM_PA1HIB1, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, - {BRCMS_SROM_PA1HIB2, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, - {BRCMS_SROM_PA1ITSSIT, 0x0000000e, 0, SROM_ITT, 0xff00}, - {BRCMS_SROM_PA1MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, - {BRCMS_SROM_PA1LOMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, - {BRCMS_SROM_PA1HIMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, - {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, - {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, - {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, - {BRCMS_SROM_PA1LOB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_LC, 0xffff}, - {BRCMS_SROM_PA1LOB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_LC, 0xffff}, - {BRCMS_SROM_PA1LOB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_LC, 0xffff}, - {BRCMS_SROM_PA1HIB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_HC, 0xffff}, - {BRCMS_SROM_PA1HIB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_HC, 0xffff}, - {BRCMS_SROM_PA1HIB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_HC, 0xffff}, - {BRCMS_SROM_PA1ITSSIT, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0xff00}, - {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, - {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, - {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, - {BRCMS_SROM_BXA2G, 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, - {BRCMS_SROM_RSSISAV2G, 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, - {BRCMS_SROM_RSSISMC2G, 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, - {BRCMS_SROM_RSSISMF2G, 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, - {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, - {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, - {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, - {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, - {BRCMS_SROM_BXA5G, 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, - {BRCMS_SROM_RSSISAV5G, 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, - {BRCMS_SROM_RSSISMC5G, 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, - {BRCMS_SROM_RSSISMF5G, 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, - {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, - {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, - {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, - {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, - {BRCMS_SROM_TRI2G, 0x00000008, 0, SROM_TRI52G, 0x00ff}, - {BRCMS_SROM_TRI5G, 0x00000008, 0, SROM_TRI52G, 0xff00}, - {BRCMS_SROM_TRI5GL, 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, - {BRCMS_SROM_TRI5GH, 0x00000008, 0, SROM_TRI5GHL, 0xff00}, - {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, - {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, - {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, - {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, - {BRCMS_SROM_RXPO2G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, - {BRCMS_SROM_RXPO5G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, - {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, - {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, - {BRCMS_SROM_TXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_TXCHAIN_MASK}, - {BRCMS_SROM_RXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_RXCHAIN_MASK}, - {BRCMS_SROM_ANTSWITCH, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_SWITCH_MASK}, - {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, - SROM4_TXCHAIN_MASK}, - {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, - SROM4_RXCHAIN_MASK}, - {BRCMS_SROM_ANTSWITCH, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, - SROM4_SWITCH_MASK}, - {BRCMS_SROM_TSSIPOS2G, 0xffffff00, 0, SROM8_FEM2G, - SROM8_FEM_TSSIPOS_MASK}, - {BRCMS_SROM_EXTPAGAIN2G, 0xffffff00, 0, SROM8_FEM2G, - SROM8_FEM_EXTPA_GAIN_MASK}, - {BRCMS_SROM_PDETRANGE2G, 0xffffff00, 0, SROM8_FEM2G, - SROM8_FEM_PDET_RANGE_MASK}, - {BRCMS_SROM_TRISO2G, 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_TR_ISO_MASK}, - {BRCMS_SROM_ANTSWCTL2G, 0xffffff00, 0, SROM8_FEM2G, - SROM8_FEM_ANTSWLUT_MASK}, - {BRCMS_SROM_TSSIPOS5G, 0xffffff00, 0, SROM8_FEM5G, - SROM8_FEM_TSSIPOS_MASK}, - {BRCMS_SROM_EXTPAGAIN5G, 0xffffff00, 0, SROM8_FEM5G, - SROM8_FEM_EXTPA_GAIN_MASK}, - {BRCMS_SROM_PDETRANGE5G, 0xffffff00, 0, SROM8_FEM5G, - SROM8_FEM_PDET_RANGE_MASK}, - {BRCMS_SROM_TRISO5G, 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_TR_ISO_MASK}, - {BRCMS_SROM_ANTSWCTL5G, 0xffffff00, 0, SROM8_FEM5G, - SROM8_FEM_ANTSWLUT_MASK}, - {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, - {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, - {BRCMS_SROM_TXPID2GA0, 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, - {BRCMS_SROM_TXPID2GA1, 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, - {BRCMS_SROM_TXPID2GA2, 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, - {BRCMS_SROM_TXPID2GA3, 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, - {BRCMS_SROM_TXPID5GA0, 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, - {BRCMS_SROM_TXPID5GA1, 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, - {BRCMS_SROM_TXPID5GA2, 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GA3, 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, - {BRCMS_SROM_TXPID5GLA0, 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, - {BRCMS_SROM_TXPID5GLA1, 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, - {BRCMS_SROM_TXPID5GLA2, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GLA3, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, - {BRCMS_SROM_TXPID5GHA0, 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, - {BRCMS_SROM_TXPID5GHA1, 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, - {BRCMS_SROM_TXPID5GHA2, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GHA3, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, - - {BRCMS_SROM_CCODE, 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, - {BRCMS_SROM_CCODE, 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, - {BRCMS_SROM_CCODE, 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, - {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, - {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, - {BRCMS_SROM_IL0MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, - 0xffff}, - {BRCMS_SROM_ET1MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, - 0xffff}, - {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, - 0xffff}, - {BRCMS_SROM_LEDDC, 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, - 0xffff}, - {BRCMS_SROM_LEDDC, 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, - 0xffff}, - {BRCMS_SROM_LEDDC, 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, - 0xffff}, - {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, - 0x01ff}, - {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, - 0xfe00}, - {BRCMS_SROM_TEMPSENSE_SLOPE, 0xffffff00, SRFL_PRHEX, - SROM8_TS_SLP_OPT_CORRX, 0x00ff}, - {BRCMS_SROM_TEMPCORRX, 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX, - 0xfc00}, - {BRCMS_SROM_TEMPSENSE_OPTION, 0xffffff00, SRFL_PRHEX, - SROM8_TS_SLP_OPT_CORRX, 0x0300}, - {BRCMS_SROM_FREQOFFSET_CORR, 0xffffff00, SRFL_PRHEX, - SROM8_FOC_HWIQ_IQSWP, 0x000f}, - {BRCMS_SROM_IQCAL_SWP_DIS, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, - 0x0010}, - {BRCMS_SROM_HW_IQCAL_EN, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP, - 0x0020}, - {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, - 0x00ff}, - - {BRCMS_SROM_CCK2GPO, 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, - {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, - {BRCMS_SROM_OFDM2GPO, 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GPO, 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GLPO, 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GHPO, 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_5G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GLPO, 0x00000100, SRFL_MORE, SROM8_5GL_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_MCS2GPO0, 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS2GPO1, 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS2GPO2, 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS2GPO3, 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS2GPO4, 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS2GPO5, 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS2GPO6, 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS2GPO7, 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GPO0, 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GPO1, 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GPO2, 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GPO3, 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GPO4, 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GPO5, 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GPO6, 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GPO7, 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GLPO0, 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GLPO1, 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GLPO2, 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GLPO3, 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GLPO4, 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GLPO5, 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GLPO6, 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GLPO7, 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GHPO0, 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GHPO1, 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GHPO2, 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GHPO3, 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GHPO4, 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GHPO5, 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GHPO6, 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GHPO7, 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS2GPO3, 0x00000100, 0, SROM8_2G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS2GPO4, 0x00000100, 0, SROM8_2G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS2GPO5, 0x00000100, 0, SROM8_2G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS2GPO6, 0x00000100, 0, SROM8_2G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS2GPO7, 0x00000100, 0, SROM8_2G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GPO0, 0x00000100, 0, SROM8_5G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GPO1, 0x00000100, 0, SROM8_5G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GPO2, 0x00000100, 0, SROM8_5G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GPO3, 0x00000100, 0, SROM8_5G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GPO4, 0x00000100, 0, SROM8_5G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GPO5, 0x00000100, 0, SROM8_5G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GPO6, 0x00000100, 0, SROM8_5G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GPO7, 0x00000100, 0, SROM8_5G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GLPO0, 0x00000100, 0, SROM8_5GL_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GLPO1, 0x00000100, 0, SROM8_5GL_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GLPO2, 0x00000100, 0, SROM8_5GL_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GLPO3, 0x00000100, 0, SROM8_5GL_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GLPO4, 0x00000100, 0, SROM8_5GL_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GLPO5, 0x00000100, 0, SROM8_5GL_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GLPO6, 0x00000100, 0, SROM8_5GL_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GLPO7, 0x00000100, 0, SROM8_5GL_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GHPO0, 0x00000100, 0, SROM8_5GH_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GHPO1, 0x00000100, 0, SROM8_5GH_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GHPO2, 0x00000100, 0, SROM8_5GH_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GHPO3, 0x00000100, 0, SROM8_5GH_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GHPO4, 0x00000100, 0, SROM8_5GH_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, - {BRCMS_SROM_CDDPO, 0x000000f0, 0, SROM4_CDDPO, 0xffff}, - {BRCMS_SROM_STBCPO, 0x000000f0, 0, SROM4_STBCPO, 0xffff}, - {BRCMS_SROM_BW40PO, 0x000000f0, 0, SROM4_BW40PO, 0xffff}, - {BRCMS_SROM_BWDUPPO, 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, - {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, - {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, - {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, - {BRCMS_SROM_BWDUPPO, 0x00000100, 0, SROM8_BWDUPPO, 0xffff}, - - /* power per rate from sromrev 9 */ - {BRCMS_SROM_CCKBW202GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20, 0xffff}, - {BRCMS_SROM_CCKBW20UL2GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20UL, 0xffff}, - {BRCMS_SROM_LEGOFDMBW202GPO, 0xfffffe00, SRFL_MORE, - SROM9_2GPO_LOFDMBW20, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20 + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW20UL2GPO, 0xfffffe00, SRFL_MORE, - SROM9_2GPO_LOFDMBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20UL + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW205GLPO, 0xfffffe00, SRFL_MORE, - SROM9_5GLPO_LOFDMBW20, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20 + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW20UL5GLPO, 0xfffffe00, SRFL_MORE, - SROM9_5GLPO_LOFDMBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20UL + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW205GMPO, 0xfffffe00, SRFL_MORE, - SROM9_5GMPO_LOFDMBW20, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20 + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW20UL5GMPO, 0xfffffe00, SRFL_MORE, - SROM9_5GMPO_LOFDMBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20UL + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW205GHPO, 0xfffffe00, SRFL_MORE, - SROM9_5GHPO_LOFDMBW20, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20 + 1, 0xffff}, - {BRCMS_SROM_LEGOFDMBW20UL5GHPO, 0xfffffe00, SRFL_MORE, - SROM9_5GHPO_LOFDMBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20UL + 1, 0xffff}, - {BRCMS_SROM_MCSBW202GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20 + 1, 0xffff}, - {BRCMS_SROM_MCSBW20UL2GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20UL, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20UL + 1, 0xffff}, - {BRCMS_SROM_MCSBW402GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW40, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW40 + 1, 0xffff}, - {BRCMS_SROM_MCSBW205GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW20, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20 + 1, 0xffff}, - {BRCMS_SROM_MCSBW20UL5GLPO, 0xfffffe00, SRFL_MORE, - SROM9_5GLPO_MCSBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20UL + 1, 0xffff}, - {BRCMS_SROM_MCSBW405GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW40, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW40 + 1, 0xffff}, - {BRCMS_SROM_MCSBW205GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW20, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20 + 1, 0xffff}, - {BRCMS_SROM_MCSBW20UL5GMPO, 0xfffffe00, SRFL_MORE, - SROM9_5GMPO_MCSBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20UL + 1, 0xffff}, - {BRCMS_SROM_MCSBW405GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW40, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW40 + 1, 0xffff}, - {BRCMS_SROM_MCSBW205GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW20, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20 + 1, 0xffff}, - {BRCMS_SROM_MCSBW20UL5GHPO, 0xfffffe00, SRFL_MORE, - SROM9_5GHPO_MCSBW20UL, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20UL + 1, 0xffff}, - {BRCMS_SROM_MCSBW405GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW40, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW40 + 1, 0xffff}, - {BRCMS_SROM_MCS32PO, 0xfffffe00, 0, SROM9_PO_MCS32, 0xffff}, - {BRCMS_SROM_LEGOFDM40DUPPO, 0xfffffe00, 0, SROM9_PO_LOFDM40DUP, 0xffff}, - - {BRCMS_SROM_NULL, 0, 0, 0, 0} -}; - -static const struct brcms_sromvar perpath_pci_sromvars[] = { - {BRCMS_SROM_MAXP2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_ITT2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_ITT5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_PA2GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, - {BRCMS_SROM_PA2GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, - {BRCMS_SROM_PA2GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, - {BRCMS_SROM_PA2GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, - {BRCMS_SROM_MAXP5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GHA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GLA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, - {BRCMS_SROM_PA5GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, - {BRCMS_SROM_PA5GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, - {BRCMS_SROM_PA5GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, - {BRCMS_SROM_PA5GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, - {BRCMS_SROM_PA5GLW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, - {BRCMS_SROM_PA5GLW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GLW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, - 0xffff}, - {BRCMS_SROM_PA5GLW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, - 0xffff}, - {BRCMS_SROM_PA5GHW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, - {BRCMS_SROM_PA5GHW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GHW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, - 0xffff}, - {BRCMS_SROM_PA5GHW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, - 0xffff}, - {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_PA2GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA, 0xffff}, - {BRCMS_SROM_PA2GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 1, 0xffff}, - {BRCMS_SROM_PA2GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 2, 0xffff}, - {BRCMS_SROM_MAXP5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GHA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GLA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0xff00}, - {BRCMS_SROM_PA5GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA, 0xffff}, - {BRCMS_SROM_PA5GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 1, 0xffff}, - {BRCMS_SROM_PA5GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 2, 0xffff}, - {BRCMS_SROM_PA5GLW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA, 0xffff}, - {BRCMS_SROM_PA5GLW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GLW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 2, - 0xffff}, - {BRCMS_SROM_PA5GHW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA, 0xffff}, - {BRCMS_SROM_PA5GHW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GHW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 2, - 0xffff}, - {BRCMS_SROM_NULL, 0, 0, 0, 0} -}; - -/* crc table has the same contents for every device instance, so it can be - * shared between devices. */ -static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; - -static u16 __iomem * -srom_window_address(struct si_pub *sih, u8 __iomem *curmap) -{ - if (sih->ccrev < 32) - return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); - if (sih->cccaps & CC_CAP_SROM) - return (u16 __iomem *) - (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); - - return NULL; -} - -/* Parse SROM and create name=value pairs. 'srom' points to - * the SROM word array. 'off' specifies the offset of the - * first word 'srom' points to, which should be either 0 or - * SROM3_SWRG_OFF (full SROM or software region). - */ - -static uint mask_shift(u16 mask) -{ - uint i; - for (i = 0; i < (sizeof(mask) << 3); i++) { - if (mask & (1 << i)) - return i; - } - return 0; -} - -static uint mask_width(u16 mask) -{ - int i; - for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) { - if (mask & (1 << i)) - return (uint) (i - mask_shift(mask) + 1); - } - return 0; -} - -static inline void ltoh16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); -} - -static inline void htol16_buf(u16 *buf, unsigned int size) -{ - size /= 2; - while (size--) - *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); -} - -/* - * convert binary srom data into linked list of srom variable items. - */ -static void -_initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) -{ - struct brcms_srom_list_head *entry; - enum brcms_srom_id id; - u16 w; - u32 val; - const struct brcms_sromvar *srv; - uint width; - uint flags; - u32 sr = (1 << sromrev); - - /* first store the srom revision */ - entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); - entry->varid = BRCMS_SROM_REV; - entry->var_type = BRCMS_SROM_UNUMBER; - entry->uval = sromrev; - list_add(&entry->var_list, var_list); - - for (srv = pci_sromvars; srv->varid != BRCMS_SROM_NULL; srv++) { - enum brcms_srom_var_type type; - u8 ea[ETH_ALEN]; - u8 extra_space = 0; - - if ((srv->revmask & sr) == 0) - continue; - - flags = srv->flags; - id = srv->varid; - - /* This entry is for mfgc only. Don't generate param for it, */ - if (flags & SRFL_NOVAR) - continue; - - if (flags & SRFL_ETHADDR) { - /* - * stored in string format XX:XX:XX:XX:XX:XX (17 chars) - */ - ea[0] = (srom[srv->off] >> 8) & 0xff; - ea[1] = srom[srv->off] & 0xff; - ea[2] = (srom[srv->off + 1] >> 8) & 0xff; - ea[3] = srom[srv->off + 1] & 0xff; - ea[4] = (srom[srv->off + 2] >> 8) & 0xff; - ea[5] = srom[srv->off + 2] & 0xff; - /* 17 characters + string terminator - union size */ - extra_space = 18 - sizeof(s32); - type = BRCMS_SROM_STRING; - } else { - w = srom[srv->off]; - val = (w & srv->mask) >> mask_shift(srv->mask); - width = mask_width(srv->mask); - - while (srv->flags & SRFL_MORE) { - srv++; - if (srv->off == 0) - continue; - - w = srom[srv->off]; - val += - ((w & srv->mask) >> mask_shift(srv-> - mask)) << - width; - width += mask_width(srv->mask); - } - - if ((flags & SRFL_NOFFS) - && ((int)val == (1 << width) - 1)) - continue; - - if (flags & SRFL_CCODE) { - type = BRCMS_SROM_STRING; - } else if (flags & SRFL_LEDDC) { - /* LED Powersave duty cycle has to be scaled: - *(oncount >> 24) (offcount >> 8) - */ - u32 w32 = /* oncount */ - (((val >> 8) & 0xff) << 24) | - /* offcount */ - (((val & 0xff)) << 8); - type = BRCMS_SROM_UNUMBER; - val = w32; - } else if ((flags & SRFL_PRSIGN) - && (val & (1 << (width - 1)))) { - type = BRCMS_SROM_SNUMBER; - val |= ~0 << width; - } else - type = BRCMS_SROM_UNUMBER; - } - - entry = kzalloc(sizeof(struct brcms_srom_list_head) + - extra_space, GFP_KERNEL); - entry->varid = id; - entry->var_type = type; - if (flags & SRFL_ETHADDR) { - snprintf(entry->buf, 18, "%pM", ea); - } else if (flags & SRFL_CCODE) { - if (val == 0) - entry->buf[0] = '\0'; - else - snprintf(entry->buf, 3, "%c%c", - (val >> 8), (val & 0xff)); - } else { - entry->uval = val; - } - - list_add(&entry->var_list, var_list); - } - - if (sromrev >= 4) { - /* Do per-path variables */ - uint p, pb, psz; - - if (sromrev >= 8) { - pb = SROM8_PATH0; - psz = SROM8_PATH1 - SROM8_PATH0; - } else { - pb = SROM4_PATH0; - psz = SROM4_PATH1 - SROM4_PATH0; - } - - for (p = 0; p < MAX_PATH_SROM; p++) { - for (srv = perpath_pci_sromvars; - srv->varid != BRCMS_SROM_NULL; srv++) { - if ((srv->revmask & sr) == 0) - continue; - - if (srv->flags & SRFL_NOVAR) - continue; - - w = srom[pb + srv->off]; - val = (w & srv->mask) >> mask_shift(srv->mask); - width = mask_width(srv->mask); - - /* Cheating: no per-path var is more than - * 1 word */ - if ((srv->flags & SRFL_NOFFS) - && ((int)val == (1 << width) - 1)) - continue; - - entry = - kzalloc(sizeof(struct brcms_srom_list_head), - GFP_KERNEL); - entry->varid = srv->varid+p; - entry->var_type = BRCMS_SROM_UNUMBER; - entry->uval = val; - list_add(&entry->var_list, var_list); - } - pb += psz; - } - } -} - -/* - * Read in and validate sprom. - * Return 0 on success, nonzero on error. - */ -static int -sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, - u16 *buf, uint nwords, bool check_crc) -{ - int err = 0; - uint i; - - /* read the sprom */ - for (i = 0; i < nwords; i++) - buf[i] = R_REG(&sprom[wordoff + i]); - - if (check_crc) { - - if (buf[0] == 0xffff) - /* - * The hardware thinks that an srom that starts with - * 0xffff is blank, regardless of the rest of the - * content, so declare it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, nwords * 2); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, - CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE(brcms_srom_crc8_table)) - /* DBG only pci always read srom4 first, then srom8/9 */ - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, nwords * 2); - } - return err; -} - -static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) -{ - u8 *otp; - uint sz = OTP_SZ_MAX / 2; /* size in words */ - int err = 0; - - otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); - if (otp == NULL) - return -ENOMEM; - - err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); - - memcpy(buf, otp, bufsz); - - kfree(otp); - - /* Check CRC */ - if (buf[0] == 0xffff) - /* The hardware thinks that an srom that starts with 0xffff - * is blank, regardless of the rest of the content, so declare - * it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, bufsz); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, - CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) - err = -EIO; - - /* now correct the endianness of the byte array */ - ltoh16_buf(buf, bufsz); - - return err; -} - -/* - * Initialize nonvolatile variable table from sprom. - * Return 0 on success, nonzero on error. - */ -static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) -{ - u16 *srom; - u16 __iomem *sromwindow; - u8 sromrev = 0; - u32 sr; - int err = 0; - - /* - * Apply CRC over SROM content regardless SROM is present or not. - */ - srom = kmalloc(SROM_MAX, GFP_ATOMIC); - if (!srom) - return -ENOMEM; - - sromwindow = srom_window_address(sih, curmap); - - crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); - if (ai_is_sprom_available(sih)) { - err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, - true); - - if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || - (((sih->buscoretype == PCIE_CORE_ID) - && (sih->buscorerev >= 6)) - || ((sih->buscoretype == PCI_CORE_ID) - && (sih->buscorerev >= 0xe)))) { - /* sromrev >= 4, read more */ - err = sprom_read_pci(sih, sromwindow, 0, srom, - SROM4_WORDS, true); - sromrev = srom[SROM4_CRCREV] & 0xff; - } else if (err == 0) { - /* srom is good and is rev < 4 */ - /* top word of sprom contains version and crc8 */ - sromrev = srom[SROM_CRCREV] & 0xff; - /* bcm4401 sroms misprogrammed */ - if (sromrev == 0x10) - sromrev = 1; - } - } else { - /* Use OTP if SPROM not available */ - err = otp_read_pci(sih, srom, SROM_MAX); - if (err == 0) - /* OTP only contain SROM rev8/rev9 for now */ - sromrev = srom[SROM4_CRCREV] & 0xff; - } - - if (!err) { - struct si_info *sii = (struct si_info *)sih; - - /* Bitmask for the sromrev */ - sr = 1 << sromrev; - - /* - * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, - * 9 - */ - if ((sr & 0x33e) == 0) { - err = -EINVAL; - goto errout; - } - - INIT_LIST_HEAD(&sii->var_list); - - /* parse SROM into name=value pairs. */ - _initvars_srom_pci(sromrev, srom, &sii->var_list); - } - -errout: - kfree(srom); - return err; -} - -void srom_free_vars(struct si_pub *sih) -{ - struct si_info *sii; - struct brcms_srom_list_head *entry, *next; - - sii = (struct si_info *)sih; - list_for_each_entry_safe(entry, next, &sii->var_list, var_list) { - list_del(&entry->var_list); - kfree(entry); - } -} -/* - * Initialize local vars from the right source for this platform. - * Return 0 on success, nonzero on error. - */ -int srom_var_init(struct si_pub *sih, void __iomem *curmap) -{ - uint len; - - len = 0; - - if (curmap != NULL) - return initvars_srom_pci(sih, curmap); - - return -EINVAL; -} - -/* - * Search the name=value vars for a specific one and return its value. - * Returns NULL if not found. - */ -char *getvar(struct si_pub *sih, enum brcms_srom_id id) -{ - struct si_info *sii; - struct brcms_srom_list_head *entry; - - sii = (struct si_info *)sih; - - list_for_each_entry(entry, &sii->var_list, var_list) - if (entry->varid == id) - return &entry->buf[0]; - - /* nothing found */ - return NULL; -} - -/* - * Search the vars for a specific one and return its value as - * an integer. Returns 0 if not found.- - */ -int getintvar(struct si_pub *sih, enum brcms_srom_id id) -{ - struct si_info *sii; - struct brcms_srom_list_head *entry; - unsigned long res; - - sii = (struct si_info *)sih; - - list_for_each_entry(entry, &sii->var_list, var_list) - if (entry->varid == id) { - if (entry->var_type == BRCMS_SROM_SNUMBER || - entry->var_type == BRCMS_SROM_UNUMBER) - return (int)entry->sval; - else if (!kstrtoul(&entry->buf[0], 0, &res)) - return (int)res; - } - - return 0; -} diff --git a/drivers/staging/brcm80211/brcmsmac/srom.h b/drivers/staging/brcm80211/brcmsmac/srom.h deleted file mode 100644 index 708c43ff51c..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/srom.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_SROM_H_ -#define _BRCM_SROM_H_ - -#include "types.h" - -/* Prototypes */ -extern int srom_var_init(struct si_pub *sih, void __iomem *curmap); -extern void srom_free_vars(struct si_pub *sih); - -extern int srom_read(struct si_pub *sih, uint bus, void *curmap, - uint byteoff, uint nbytes, u16 *buf, bool check_crc); - -/* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP - * and extract from it into name=value pairs - */ -extern int srom_parsecis(u8 **pcis, uint ciscnt, - char **vars, uint *count); -#endif /* _BRCM_SROM_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/stf.c b/drivers/staging/brcm80211/brcmsmac/stf.c deleted file mode 100644 index f1bd1bf5485..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/stf.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include "types.h" -#include "d11.h" -#include "rate.h" -#include "phy/phy_hal.h" -#include "channel.h" -#include "main.h" -#include "stf.h" - -#define MIN_SPATIAL_EXPANSION 0 -#define MAX_SPATIAL_EXPANSION 1 - -#define BRCMS_STF_SS_STBC_RX(wlc) (BRCMS_ISNPHY(wlc->band) && \ - NREV_GT(wlc->band->phyrev, 3) && NREV_LE(wlc->band->phyrev, 6)) - -#define BRCMS_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8)) - -#define NSTS_1 1 -#define NSTS_2 2 -#define NSTS_3 3 -#define NSTS_4 4 - -static const u8 txcore_default[5] = { - (0), /* bitmap of the core enabled */ - (0x01), /* For Nsts = 1, enable core 1 */ - (0x03), /* For Nsts = 2, enable core 1 & 2 */ - (0x07), /* For Nsts = 3, enable core 1, 2 & 3 */ - (0x0f) /* For Nsts = 4, enable all cores */ -}; - -static void brcms_c_stf_stbc_rx_ht_update(struct brcms_c_info *wlc, int val) -{ - /* MIMOPHYs rev3-6 cannot receive STBC with only one rx core active */ - if (BRCMS_STF_SS_STBC_RX(wlc)) { - if ((wlc->stf->rxstreams == 1) && (val != HT_CAP_RX_STBC_NO)) - return; - } - - if (wlc->pub->up) { - brcms_c_update_beacon(wlc); - brcms_c_update_probe_resp(wlc, true); - } -} - -/* - * every WLC_TEMPSENSE_PERIOD seconds temperature check to decide whether to - * turn on/off txchain. - */ -void brcms_c_tempsense_upd(struct brcms_c_info *wlc) -{ - struct brcms_phy_pub *pi = wlc->band->pi; - uint active_chains, txchain; - - /* Check if the chip is too hot. Disable one Tx chain, if it is */ - /* high 4 bits are for Rx chain, low 4 bits are for Tx chain */ - active_chains = wlc_phy_stf_chain_active_get(pi); - txchain = active_chains & 0xf; - - if (wlc->stf->txchain == wlc->stf->hw_txchain) { - if (txchain && (txchain < wlc->stf->hw_txchain)) - /* turn off 1 tx chain */ - brcms_c_stf_txchain_set(wlc, txchain, true); - } else if (wlc->stf->txchain < wlc->stf->hw_txchain) { - if (txchain == wlc->stf->hw_txchain) - /* turn back on txchain */ - brcms_c_stf_txchain_set(wlc, txchain, true); - } -} - -void -brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, - u16 chanspec) -{ - struct tx_power power; - u8 siso_mcs_id, cdd_mcs_id, stbc_mcs_id; - - /* Clear previous settings */ - *ss_algo_channel = 0; - - if (!wlc->pub->up) { - *ss_algo_channel = (u16) -1; - return; - } - - wlc_phy_txpower_get_current(wlc->band->pi, &power, - CHSPEC_CHANNEL(chanspec)); - - siso_mcs_id = (CHSPEC_IS40(chanspec)) ? - WL_TX_POWER_MCS40_SISO_FIRST : WL_TX_POWER_MCS20_SISO_FIRST; - cdd_mcs_id = (CHSPEC_IS40(chanspec)) ? - WL_TX_POWER_MCS40_CDD_FIRST : WL_TX_POWER_MCS20_CDD_FIRST; - stbc_mcs_id = (CHSPEC_IS40(chanspec)) ? - WL_TX_POWER_MCS40_STBC_FIRST : WL_TX_POWER_MCS20_STBC_FIRST; - - /* criteria to choose stf mode */ - - /* - * the "+3dbm (12 0.25db units)" is to account for the fact that with - * CDD, tx occurs on both chains - */ - if (power.target[siso_mcs_id] > (power.target[cdd_mcs_id] + 12)) - setbit(ss_algo_channel, PHY_TXC1_MODE_SISO); - else - setbit(ss_algo_channel, PHY_TXC1_MODE_CDD); - - /* - * STBC is ORed into to algo channel as STBC requires per-packet SCB - * capability check so cannot be default mode of operation. One of - * SISO, CDD have to be set - */ - if (power.target[siso_mcs_id] <= (power.target[stbc_mcs_id] + 12)) - setbit(ss_algo_channel, PHY_TXC1_MODE_STBC); -} - -static bool brcms_c_stf_stbc_tx_set(struct brcms_c_info *wlc, s32 int_val) -{ - if ((int_val != AUTO) && (int_val != OFF) && (int_val != ON)) - return false; - - if ((int_val == ON) && (wlc->stf->txstreams == 1)) - return false; - - wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = (s8) int_val; - wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = (s8) int_val; - - return true; -} - -bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val) -{ - if ((int_val != HT_CAP_RX_STBC_NO) - && (int_val != HT_CAP_RX_STBC_ONE_STREAM)) - return false; - - if (BRCMS_STF_SS_STBC_RX(wlc)) { - if ((int_val != HT_CAP_RX_STBC_NO) - && (wlc->stf->rxstreams == 1)) - return false; - } - - brcms_c_stf_stbc_rx_ht_update(wlc, int_val); - return true; -} - -static int brcms_c_stf_txcore_set(struct brcms_c_info *wlc, u8 Nsts, - u8 core_mask) -{ - BCMMSG(wlc->wiphy, "wl%d: Nsts %d core_mask %x\n", - wlc->pub->unit, Nsts, core_mask); - - if (hweight8(core_mask) > wlc->stf->txstreams) - core_mask = 0; - - if ((hweight8(core_mask) == wlc->stf->txstreams) && - ((core_mask & ~wlc->stf->txchain) - || !(core_mask & wlc->stf->txchain))) - core_mask = wlc->stf->txchain; - - wlc->stf->txcore[Nsts] = core_mask; - /* Nsts = 1..4, txcore index = 1..4 */ - if (Nsts == 1) { - /* Needs to update beacon and ucode generated response - * frames when 1 stream core map changed - */ - wlc->stf->phytxant = core_mask << PHY_TXC_ANT_SHIFT; - brcms_b_txant_set(wlc->hw, wlc->stf->phytxant); - if (wlc->clk) { - brcms_c_suspend_mac_and_wait(wlc); - brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); - brcms_c_enable_mac(wlc); - } - } - - return 0; -} - -static int brcms_c_stf_spatial_policy_set(struct brcms_c_info *wlc, int val) -{ - int i; - u8 core_mask = 0; - - BCMMSG(wlc->wiphy, "wl%d: val %x\n", wlc->pub->unit, val); - - wlc->stf->spatial_policy = (s8) val; - for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++) { - core_mask = (val == MAX_SPATIAL_EXPANSION) ? - wlc->stf->txchain : txcore_default[i]; - brcms_c_stf_txcore_set(wlc, (u8) i, core_mask); - } - return 0; -} - -/* - * Centralized txant update function. call it whenever wlc->stf->txant and/or - * wlc->stf->txchain change. - * - * Antennas are controlled by ucode indirectly, which drives PHY or GPIO to - * achieve various tx/rx antenna selection schemes - * - * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 - * means auto(last rx). - * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 - * means last rx and do tx-antenna selection for SISO transmissions - * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 - * means last rx and do tx-antenna selection for SISO transmissions - * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 - * means both cores active -*/ -static void _brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) -{ - s8 txant; - - txant = (s8) wlc->stf->txant; - if (BRCMS_PHY_11N_CAP(wlc->band)) { - if (txant == ANT_TX_FORCE_0) { - wlc->stf->phytxant = PHY_TXC_ANT_0; - } else if (txant == ANT_TX_FORCE_1) { - wlc->stf->phytxant = PHY_TXC_ANT_1; - - if (BRCMS_ISNPHY(wlc->band) && - NREV_GE(wlc->band->phyrev, 3) - && NREV_LT(wlc->band->phyrev, 7)) - wlc->stf->phytxant = PHY_TXC_ANT_2; - } else { - if (BRCMS_ISLCNPHY(wlc->band) || - BRCMS_ISSSLPNPHY(wlc->band)) - wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST; - else { - /* catch out of sync wlc->stf->txcore */ - WARN_ON(wlc->stf->txchain <= 0); - wlc->stf->phytxant = - wlc->stf->txchain << PHY_TXC_ANT_SHIFT; - } - } - } else { - if (txant == ANT_TX_FORCE_0) - wlc->stf->phytxant = PHY_TXC_OLD_ANT_0; - else if (txant == ANT_TX_FORCE_1) - wlc->stf->phytxant = PHY_TXC_OLD_ANT_1; - else - wlc->stf->phytxant = PHY_TXC_OLD_ANT_LAST; - } - - brcms_b_txant_set(wlc->hw, wlc->stf->phytxant); -} - -int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force) -{ - u8 txchain = (u8) int_val; - u8 txstreams; - uint i; - - if (wlc->stf->txchain == txchain) - return 0; - - if ((txchain & ~wlc->stf->hw_txchain) - || !(txchain & wlc->stf->hw_txchain)) - return -EINVAL; - - /* - * if nrate override is configured to be non-SISO STF mode, reject - * reducing txchain to 1 - */ - txstreams = (u8) hweight8(txchain); - if (txstreams > MAX_STREAMS_SUPPORTED) - return -EINVAL; - - wlc->stf->txchain = txchain; - wlc->stf->txstreams = txstreams; - brcms_c_stf_stbc_tx_set(wlc, wlc->band->band_stf_stbc_tx); - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); - wlc->stf->txant = - (wlc->stf->txstreams == 1) ? ANT_TX_FORCE_0 : ANT_TX_DEF; - _brcms_c_stf_phy_txant_upd(wlc); - - wlc_phy_stf_chain_set(wlc->band->pi, wlc->stf->txchain, - wlc->stf->rxchain); - - for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++) - brcms_c_stf_txcore_set(wlc, (u8) i, txcore_default[i]); - - return 0; -} - -/* - * update wlc->stf->ss_opmode which represents the operational stf_ss mode - * we're using - */ -int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band) -{ - int ret_code = 0; - u8 prev_stf_ss; - u8 upd_stf_ss; - - prev_stf_ss = wlc->stf->ss_opmode; - - /* - * NOTE: opmode can only be SISO or CDD as STBC is decided on a - * per-packet basis - */ - if (BRCMS_STBC_CAP_PHY(wlc) && - wlc->stf->ss_algosel_auto - && (wlc->stf->ss_algo_channel != (u16) -1)) { - upd_stf_ss = (wlc->stf->txstreams == 1 || - isset(&wlc->stf->ss_algo_channel, - PHY_TXC1_MODE_SISO)) ? - PHY_TXC1_MODE_SISO : PHY_TXC1_MODE_CDD; - } else { - if (wlc->band != band) - return ret_code; - upd_stf_ss = (wlc->stf->txstreams == 1) ? - PHY_TXC1_MODE_SISO : band->band_stf_ss_mode; - } - if (prev_stf_ss != upd_stf_ss) { - wlc->stf->ss_opmode = upd_stf_ss; - brcms_b_band_stf_ss_set(wlc->hw, upd_stf_ss); - } - - return ret_code; -} - -int brcms_c_stf_attach(struct brcms_c_info *wlc) -{ - wlc->bandstate[BAND_2G_INDEX]->band_stf_ss_mode = PHY_TXC1_MODE_SISO; - wlc->bandstate[BAND_5G_INDEX]->band_stf_ss_mode = PHY_TXC1_MODE_CDD; - - if (BRCMS_ISNPHY(wlc->band) && - (wlc_phy_txpower_hw_ctrl_get(wlc->band->pi) != PHY_TPC_HW_ON)) - wlc->bandstate[BAND_2G_INDEX]->band_stf_ss_mode = - PHY_TXC1_MODE_CDD; - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); - brcms_c_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); - - brcms_c_stf_stbc_rx_ht_update(wlc, HT_CAP_RX_STBC_NO); - wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF; - wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF; - - if (BRCMS_STBC_CAP_PHY(wlc)) { - wlc->stf->ss_algosel_auto = true; - /* Init the default value */ - wlc->stf->ss_algo_channel = (u16) -1; - } - return 0; -} - -void brcms_c_stf_detach(struct brcms_c_info *wlc) -{ -} - -void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) -{ - _brcms_c_stf_phy_txant_upd(wlc); -} - -void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc) -{ - /* get available rx/tx chains */ - wlc->stf->hw_txchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_TXCHAIN); - wlc->stf->hw_rxchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_RXCHAIN); - - /* these parameter are intended to be used for all PHY types */ - if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) { - if (BRCMS_ISNPHY(wlc->band)) - wlc->stf->hw_txchain = TXCHAIN_DEF_NPHY; - else - wlc->stf->hw_txchain = TXCHAIN_DEF; - } - - wlc->stf->txchain = wlc->stf->hw_txchain; - wlc->stf->txstreams = (u8) hweight8(wlc->stf->hw_txchain); - - if (wlc->stf->hw_rxchain == 0 || wlc->stf->hw_rxchain == 0xf) { - if (BRCMS_ISNPHY(wlc->band)) - wlc->stf->hw_rxchain = RXCHAIN_DEF_NPHY; - else - wlc->stf->hw_rxchain = RXCHAIN_DEF; - } - - wlc->stf->rxchain = wlc->stf->hw_rxchain; - wlc->stf->rxstreams = (u8) hweight8(wlc->stf->hw_rxchain); - - /* initialize the txcore table */ - memcpy(wlc->stf->txcore, txcore_default, sizeof(wlc->stf->txcore)); - - /* default spatial_policy */ - wlc->stf->spatial_policy = MIN_SPATIAL_EXPANSION; - brcms_c_stf_spatial_policy_set(wlc, MIN_SPATIAL_EXPANSION); -} - -static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - u32 rspec) -{ - u16 phytxant = wlc->stf->phytxant; - - if (rspec_stf(rspec) != PHY_TXC1_MODE_SISO) - phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; - else if (wlc->stf->txant == ANT_TX_DEF) - phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; - phytxant &= PHY_TXC_ANT_MASK; - return phytxant; -} - -u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, u32 rspec) -{ - return _brcms_c_stf_phytxchain_sel(wlc, rspec); -} - -u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, u32 rspec) -{ - u16 phytxant = wlc->stf->phytxant; - u16 mask = PHY_TXC_ANT_MASK; - - /* for non-siso rates or default setting, use the available chains */ - if (BRCMS_ISNPHY(wlc->band)) { - phytxant = _brcms_c_stf_phytxchain_sel(wlc, rspec); - mask = PHY_TXC_HTANT_MASK; - } - phytxant |= phytxant & mask; - return phytxant; -} diff --git a/drivers/staging/brcm80211/brcmsmac/stf.h b/drivers/staging/brcm80211/brcmsmac/stf.h deleted file mode 100644 index 19f6580f69b..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/stf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_STF_H_ -#define _BRCM_STF_H_ - -#include "types.h" - -extern int brcms_c_stf_attach(struct brcms_c_info *wlc); -extern void brcms_c_stf_detach(struct brcms_c_info *wlc); - -extern void brcms_c_tempsense_upd(struct brcms_c_info *wlc); -extern void brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, - u16 *ss_algo_channel, - u16 chanspec); -extern int brcms_c_stf_ss_update(struct brcms_c_info *wlc, - struct brcms_band *band); -extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); -extern int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, - bool force); -extern bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val); -extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc); -extern void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc); -extern u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, - u32 rspec); -extern u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, - u32 rspec); - -#endif /* _BRCM_STF_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/types.h b/drivers/staging/brcm80211/brcmsmac/types.h deleted file mode 100644 index 27a814b0746..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/types.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_TYPES_H_ -#define _BRCM_TYPES_H_ - -#include -#include - -#define WL_CHAN_FREQ_RANGE_2G 0 -#define WL_CHAN_FREQ_RANGE_5GL 1 -#define WL_CHAN_FREQ_RANGE_5GM 2 -#define WL_CHAN_FREQ_RANGE_5GH 3 - -/* boardflags */ - -/* Board has gpio 9 controlling the PA */ -#define BFL_PACTRL 0x00000002 -/* Not ok to power down the chip pll and oscillator */ -#define BFL_NOPLLDOWN 0x00000020 -/* Board supports the Front End Module */ -#define BFL_FEM 0x00000800 -/* Board has an external LNA in 2.4GHz band */ -#define BFL_EXTLNA 0x00001000 -/* Board has no PA */ -#define BFL_NOPA 0x00010000 -/* Power topology uses BUCKBOOST */ -#define BFL_BUCKBOOST 0x00200000 -/* Board has FEM and switch to share antenna w/ BT */ -#define BFL_FEM_BT 0x00400000 -/* Power topology doesn't use CBUCK */ -#define BFL_NOCBUCK 0x00800000 -/* Power topology uses PALDO */ -#define BFL_PALDO 0x02000000 -/* Board has an external LNA in 5GHz band */ -#define BFL_EXTLNA_5GHz 0x10000000 - -/* boardflags2 */ - -/* Board has an external rxbb regulator */ -#define BFL2_RXBB_INT_REG_DIS 0x00000001 -/* Flag to implement alternative A-band PLL settings */ -#define BFL2_APLL_WAR 0x00000002 -/* Board permits enabling TX Power Control */ -#define BFL2_TXPWRCTRL_EN 0x00000004 -/* Board supports the 2X4 diversity switch */ -#define BFL2_2X4_DIV 0x00000008 -/* Board supports 5G band power gain */ -#define BFL2_5G_PWRGAIN 0x00000010 -/* Board overrides ASPM and Clkreq settings */ -#define BFL2_PCIEWAR_OVR 0x00000020 -#define BFL2_LEGACY 0x00000080 -/* 4321mcm93 board uses Skyworks FEM */ -#define BFL2_SKWRKFEM_BRD 0x00000100 -/* Board has a WAR for clock-harmonic spurs */ -#define BFL2_SPUR_WAR 0x00000200 -/* Flag to narrow G-band PLL loop b/w */ -#define BFL2_GPLL_WAR 0x00000400 -/* Tx CCK pkts on Ant 0 only */ -#define BFL2_SINGLEANT_CCK 0x00001000 -/* WAR to reduce and avoid clock-harmonic spurs in 2G */ -#define BFL2_2G_SPUR_WAR 0x00002000 -/* Flag to widen G-band PLL loop b/w */ -#define BFL2_GPLL_WAR2 0x00010000 -#define BFL2_IPALVLSHIFT_3P3 0x00020000 -/* Use internal envelope detector for TX IQCAL */ -#define BFL2_INTERNDET_TXIQCAL 0x00040000 -/* Keep the buffered Xtal output from radio "ON". Most drivers will turn it - * off without this flag to save power. */ -#define BFL2_XTALBUFOUTEN 0x00080000 - -/* - * board specific GPIO assignment, gpio 0-3 are also customer-configurable - * led - */ - -/* bit 9 controls the PA on new 4306 boards */ -#define BOARD_GPIO_PACTRL 0x200 -#define BOARD_GPIO_12 0x1000 -#define BOARD_GPIO_13 0x2000 - -/* **** Core type/rev defaults **** */ -#define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27 - * also need to update wlc.h MAXCOREREV - */ - -#define NCONF 0x000001ff /* Supported nphy revs: - * 0 4321a0 - * 1 4321a1 - * 2 4321b0/b1/c0/c1 - * 3 4322a0 - * 4 4322a1 - * 5 4716a0 - * 6 43222a0, 43224a0 - * 7 43226a0 - * 8 5357a0, 43236a0 - */ - -#define LCNCONF 0x00000007 /* Supported lcnphy revs: - * 0 4313a0, 4336a0, 4330a0 - * 1 - * 2 4330a0 - */ - -#define SSLPNCONF 0x0000000f /* Supported sslpnphy revs: - * 0 4329a0/k0 - * 1 4329b0/4329C0 - * 2 4319a0 - * 3 5356a0 - */ - -/******************************************************************** - * Phy/Core Configuration. Defines macros to to check core phy/rev * - * compile-time configuration. Defines default core support. * - * ****************************************************************** - */ - -/* Basic macros to check a configuration bitmask */ - -#define CONF_HAS(config, val) ((config) & (1 << (val))) -#define CONF_MSK(config, mask) ((config) & (mask)) -#define MSK_RANGE(low, hi) ((1 << ((hi)+1)) - (1 << (low))) -#define CONF_RANGE(config, low, hi) (CONF_MSK(config, MSK_RANGE(low, high))) - -#define CONF_IS(config, val) ((config) == (1 << (val))) -#define CONF_GE(config, val) ((config) & (0-(1 << (val)))) -#define CONF_GT(config, val) ((config) & (0-2*(1 << (val)))) -#define CONF_LT(config, val) ((config) & ((1 << (val))-1)) -#define CONF_LE(config, val) ((config) & (2*(1 << (val))-1)) - -/* Wrappers for some of the above, specific to config constants */ - -#define NCONF_HAS(val) CONF_HAS(NCONF, val) -#define NCONF_MSK(mask) CONF_MSK(NCONF, mask) -#define NCONF_IS(val) CONF_IS(NCONF, val) -#define NCONF_GE(val) CONF_GE(NCONF, val) -#define NCONF_GT(val) CONF_GT(NCONF, val) -#define NCONF_LT(val) CONF_LT(NCONF, val) -#define NCONF_LE(val) CONF_LE(NCONF, val) - -#define LCNCONF_HAS(val) CONF_HAS(LCNCONF, val) -#define LCNCONF_MSK(mask) CONF_MSK(LCNCONF, mask) -#define LCNCONF_IS(val) CONF_IS(LCNCONF, val) -#define LCNCONF_GE(val) CONF_GE(LCNCONF, val) -#define LCNCONF_GT(val) CONF_GT(LCNCONF, val) -#define LCNCONF_LT(val) CONF_LT(LCNCONF, val) -#define LCNCONF_LE(val) CONF_LE(LCNCONF, val) - -#define D11CONF_HAS(val) CONF_HAS(D11CONF, val) -#define D11CONF_MSK(mask) CONF_MSK(D11CONF, mask) -#define D11CONF_IS(val) CONF_IS(D11CONF, val) -#define D11CONF_GE(val) CONF_GE(D11CONF, val) -#define D11CONF_GT(val) CONF_GT(D11CONF, val) -#define D11CONF_LT(val) CONF_LT(D11CONF, val) -#define D11CONF_LE(val) CONF_LE(D11CONF, val) - -#define PHYCONF_HAS(val) CONF_HAS(PHYTYPE, val) -#define PHYCONF_IS(val) CONF_IS(PHYTYPE, val) - -#define NREV_IS(var, val) \ - (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val)))) - -#define NREV_GE(var, val) \ - (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val)))) - -#define NREV_GT(var, val) \ - (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val)))) - -#define NREV_LT(var, val) \ - (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val)))) - -#define NREV_LE(var, val) \ - (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val)))) - -#define LCNREV_IS(var, val) \ - (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val)))) - -#define LCNREV_GE(var, val) \ - (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val)))) - -#define LCNREV_GT(var, val) \ - (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val)))) - -#define LCNREV_LT(var, val) \ - (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val)))) - -#define LCNREV_LE(var, val) \ - (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val)))) - -#define D11REV_IS(var, val) \ - (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val)))) - -#define D11REV_GE(var, val) \ - (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val)))) - -#define D11REV_GT(var, val) \ - (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val)))) - -#define D11REV_LT(var, val) \ - (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val)))) - -#define D11REV_LE(var, val) \ - (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val)))) - -#define PHYTYPE_IS(var, val)\ - (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val)))) - -/* Set up PHYTYPE automatically: (depends on PHY_TYPE_X, from d11.h) */ - -#define _PHYCONF_N (1 << PHY_TYPE_N) -#define _PHYCONF_LCN (1 << PHY_TYPE_LCN) -#define _PHYCONF_SSLPN (1 << PHY_TYPE_SSN) - -#define PHYTYPE (_PHYCONF_N | _PHYCONF_LCN | _PHYCONF_SSLPN) - -/* Utility macro to identify 802.11n (HT) capable PHYs */ -#define PHYTYPE_11N_CAP(phytype) \ - (PHYTYPE_IS(phytype, PHY_TYPE_N) || \ - PHYTYPE_IS(phytype, PHY_TYPE_LCN) || \ - PHYTYPE_IS(phytype, PHY_TYPE_SSN)) - -/* Last but not least: shorter wlc-specific var checks */ -#define BRCMS_ISNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_N) -#define BRCMS_ISLCNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_LCN) -#define BRCMS_ISSSLPNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_SSN) - -#define BRCMS_PHY_11N_CAP(band) PHYTYPE_11N_CAP((band)->phytype) - -/********************************************************************** - * ------------- End of Core phy/rev configuration. ----------------- * - * ******************************************************************** - */ - -#define BCMMSG(dev, fmt, args...) \ -do { \ - if (brcm_msg_level & LOG_TRACE_VAL) \ - wiphy_err(dev, "%s: " fmt, __func__, ##args); \ -} while (0) - -/* - * Register access macros. - * - * These macro's take a pointer to the address to read as one of their - * arguments. The macro itself deduces the size of the IO transaction (u8, u16 - * or u32). Advantage of this approach in combination with using a struct to - * define the registers in a register block, is that access size and access - * location are defined in only one spot. This reduces the risk of the - * programmer trying to use an unsupported transaction size on a register. - * - */ - -#define R_REG(r) \ - ({ \ - __typeof(*(r)) __osl_v; \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - __osl_v = readb((u8 __iomem *)(r)); \ - break; \ - case sizeof(u16): \ - __osl_v = readw((u16 __iomem *)(r)); \ - break; \ - case sizeof(u32): \ - __osl_v = readl((u32 __iomem *)(r)); \ - break; \ - } \ - __osl_v; \ - }) - -#define W_REG(r, v) do { \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - writeb((u8)((v) & 0xFF), (u8 __iomem *)(r)); \ - break; \ - case sizeof(u16): \ - writew((u16)((v) & 0xFFFF), (u16 __iomem *)(r)); \ - break; \ - case sizeof(u32): \ - writel((u32)(v), (u32 __iomem *)(r)); \ - break; \ - } \ - } while (0) - -#ifdef CONFIG_BCM47XX -/* - * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder - * transactions. As a fix, a read after write is performed on certain places - * in the code. Older chips and the newer 5357 family don't require this fix. - */ -#define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); }) -#else -#define W_REG_FLUSH(r, v) W_REG((r), (v)) -#endif /* CONFIG_BCM47XX */ - -#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) -#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) - -#define SET_REG(r, mask, val) \ - W_REG((r), ((R_REG(r) & ~(mask)) | (val))) - -/* multi-bool data type: set of bools, mbool is true if any is set */ - -/* set one bool */ -#define mboolset(mb, bit) ((mb) |= (bit)) -/* clear one bool */ -#define mboolclr(mb, bit) ((mb) &= ~(bit)) -/* true if one bool is set */ -#define mboolisset(mb, bit) (((mb) & (bit)) != 0) -#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) - -#define CEIL(x, y) (((x) + ((y)-1)) / (y)) - -/* forward declarations */ -struct wiphy; -struct ieee80211_sta; -struct ieee80211_tx_queue_params; -struct brcms_info; -struct brcms_c_info; -struct brcms_hardware; -struct brcms_txq_info; -struct brcms_band; -struct dma_pub; -struct si_pub; -struct tx_status; -struct d11rxhdr; -struct txpwr_limits; - -/* iovar structure */ -struct brcmu_iovar { - const char *name; /* name for lookup and display */ - u16 varid; /* id for switch */ - u16 flags; /* driver-specific flag bits */ - u16 type; /* base type of argument */ - u16 minlen; /* min length for buffer vars */ -}; - -/* brcm_msg_level is a bit vector with defs in defs.h */ -extern u32 brcm_msg_level; - -#endif /* _BRCM_TYPES_H_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c b/drivers/staging/brcm80211/brcmsmac/ucode_loader.c deleted file mode 100644 index 80e3ccf865e..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include "types.h" -#include - -enum { - D11UCODE_NAMETAG_START = 0, - D11LCN0BSINITVALS24, - D11LCN0INITVALS24, - D11LCN1BSINITVALS24, - D11LCN1INITVALS24, - D11LCN2BSINITVALS24, - D11LCN2INITVALS24, - D11N0ABSINITVALS16, - D11N0BSINITVALS16, - D11N0INITVALS16, - D11UCODE_OVERSIGHT16_MIMO, - D11UCODE_OVERSIGHT16_MIMOSZ, - D11UCODE_OVERSIGHT24_LCN, - D11UCODE_OVERSIGHT24_LCNSZ, - D11UCODE_OVERSIGHT_BOMMAJOR, - D11UCODE_OVERSIGHT_BOMMINOR -}; - -int brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode) -{ - int rc; - - rc = brcms_check_firmwares(wl); - - rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn0bsinitvals24, - D11LCN0BSINITVALS24); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn0initvals24, - D11LCN0INITVALS24); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn1bsinitvals24, - D11LCN1BSINITVALS24); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn1initvals24, - D11LCN1INITVALS24); - rc = rc < 0 ? rc : - brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn2bsinitvals24, - D11LCN2BSINITVALS24); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11lcn2initvals24, - D11LCN2INITVALS24); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0absinitvals16, - D11N0ABSINITVALS16); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0bsinitvals16, - D11N0BSINITVALS16); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->d11n0initvals16, - D11N0INITVALS16); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_16_mimo, - D11UCODE_OVERSIGHT16_MIMO); - rc = rc < 0 ? - rc : brcms_ucode_init_uint(wl, &ucode->bcm43xx_16_mimosz, - D11UCODE_OVERSIGHT16_MIMOSZ); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_24_lcn, - D11UCODE_OVERSIGHT24_LCN); - rc = rc < 0 ? - rc : brcms_ucode_init_uint(wl, &ucode->bcm43xx_24_lcnsz, - D11UCODE_OVERSIGHT24_LCNSZ); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_bommajor, - D11UCODE_OVERSIGHT_BOMMAJOR); - rc = rc < 0 ? - rc : brcms_ucode_init_buf(wl, (void **)&ucode->bcm43xx_bomminor, - D11UCODE_OVERSIGHT_BOMMINOR); - return rc; -} - -void brcms_ucode_data_free(struct brcms_ucode *ucode) -{ - brcms_ucode_free_buf((void *)ucode->d11lcn0bsinitvals24); - brcms_ucode_free_buf((void *)ucode->d11lcn0initvals24); - brcms_ucode_free_buf((void *)ucode->d11lcn1bsinitvals24); - brcms_ucode_free_buf((void *)ucode->d11lcn1initvals24); - brcms_ucode_free_buf((void *)ucode->d11lcn2bsinitvals24); - brcms_ucode_free_buf((void *)ucode->d11lcn2initvals24); - brcms_ucode_free_buf((void *)ucode->d11n0absinitvals16); - brcms_ucode_free_buf((void *)ucode->d11n0bsinitvals16); - brcms_ucode_free_buf((void *)ucode->d11n0initvals16); - brcms_ucode_free_buf((void *)ucode->bcm43xx_16_mimo); - brcms_ucode_free_buf((void *)ucode->bcm43xx_24_lcn); - brcms_ucode_free_buf((void *)ucode->bcm43xx_bommajor); - brcms_ucode_free_buf((void *)ucode->bcm43xx_bomminor); -} diff --git a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h b/drivers/staging/brcm80211/brcmsmac/ucode_loader.h deleted file mode 100644 index 18750a814b4..00000000000 --- a/drivers/staging/brcm80211/brcmsmac/ucode_loader.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#ifndef _BRCM_UCODE_H_ -#define _BRCM_UCODE_H_ - -#include "types.h" /* forward structure declarations */ - -#define MIN_FW_SIZE 40000 /* minimum firmware file size in bytes */ -#define MAX_FW_SIZE 150000 - -#define UCODE_LOADER_API_VER 0 - -struct d11init; - -struct brcms_ucode { - struct d11init *d11lcn0bsinitvals24; - struct d11init *d11lcn0initvals24; - struct d11init *d11lcn1bsinitvals24; - struct d11init *d11lcn1initvals24; - struct d11init *d11lcn2bsinitvals24; - struct d11init *d11lcn2initvals24; - struct d11init *d11n0absinitvals16; - struct d11init *d11n0bsinitvals16; - struct d11init *d11n0initvals16; - __le32 *bcm43xx_16_mimo; - size_t bcm43xx_16_mimosz; - __le32 *bcm43xx_24_lcn; - size_t bcm43xx_24_lcnsz; - u32 *bcm43xx_bommajor; - u32 *bcm43xx_bomminor; -}; - -extern int -brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode); - -extern void brcms_ucode_data_free(struct brcms_ucode *ucode); - -extern int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, - unsigned int idx); -extern int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, - unsigned int idx); -extern void brcms_ucode_free_buf(void *); -extern int brcms_check_firmwares(struct brcms_info *wl); - -#endif /* _BRCM_UCODE_H_ */ diff --git a/drivers/staging/brcm80211/brcmutil/Makefile b/drivers/staging/brcm80211/brcmutil/Makefile deleted file mode 100644 index 6403423c021..00000000000 --- a/drivers/staging/brcm80211/brcmutil/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# -# Makefile fragment for Broadcom 802.11n Networking Device Driver Utilities -# -# Copyright (c) 2011 Broadcom Corporation -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -ccflags-y := \ - -Idrivers/staging/brcm80211/brcmutil \ - -Idrivers/staging/brcm80211/include - -BRCMUTIL_OFILES := \ - utils.o \ - wifi.o - -MODULEPFX := brcmutil - -obj-$(CONFIG_BRCMUTIL) += $(MODULEPFX).o -$(MODULEPFX)-objs = $(BRCMUTIL_OFILES) diff --git a/drivers/staging/brcm80211/brcmutil/utils.c b/drivers/staging/brcm80211/brcmutil/utils.c deleted file mode 100644 index 62bcc71eadf..00000000000 --- a/drivers/staging/brcm80211/brcmutil/utils.c +++ /dev/null @@ -1,600 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -MODULE_AUTHOR("Broadcom Corporation"); -MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver utilities."); -MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); -MODULE_LICENSE("Dual BSD/GPL"); - -struct sk_buff *brcmu_pkt_buf_get_skb(uint len) -{ - struct sk_buff *skb; - - skb = dev_alloc_skb(len); - if (skb) { - skb_put(skb, len); - skb->priority = 0; - } - - return skb; -} -EXPORT_SYMBOL(brcmu_pkt_buf_get_skb); - -/* Free the driver packet. Free the tag if present */ -void brcmu_pkt_buf_free_skb(struct sk_buff *skb) -{ - struct sk_buff *nskb; - int nest = 0; - - /* perversion: we use skb->next to chain multi-skb packets */ - while (skb) { - nskb = skb->next; - skb->next = NULL; - - if (skb->destructor) - /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if - * destructor exists - */ - dev_kfree_skb_any(skb); - else - /* can free immediately (even in_irq()) if destructor - * does not exist - */ - dev_kfree_skb(skb); - - nest++; - skb = nskb; - } -} -EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); - - -/* copy a buffer into a pkt buffer chain */ -uint brcmu_pktfrombuf(struct sk_buff *p, uint offset, int len, - unsigned char *buf) -{ - uint n, ret = 0; - - /* skip 'offset' bytes */ - for (; p && offset; p = p->next) { - if (offset < (uint) (p->len)) - break; - offset -= p->len; - } - - if (!p) - return 0; - - /* copy the data */ - for (; p && len; p = p->next) { - n = min((uint) (p->len) - offset, (uint) len); - memcpy(p->data + offset, buf, n); - buf += n; - len -= n; - ret += n; - offset = 0; - } - - return ret; -} -EXPORT_SYMBOL(brcmu_pktfrombuf); - -/* return total length of buffer chain */ -uint brcmu_pkttotlen(struct sk_buff *p) -{ - uint total; - - total = 0; - for (; p; p = p->next) - total += p->len; - return total; -} -EXPORT_SYMBOL(brcmu_pkttotlen); - -/* - * osl multiple-precedence packet queue - * hi_prec is always >= the number of the highest non-empty precedence - */ -struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, - struct sk_buff *p) -{ - struct pktq_prec *q; - - if (pktq_full(pq) || pktq_pfull(pq, prec)) - return NULL; - - q = &pq->q[prec]; - - if (q->head) - q->tail->prev = p; - else - q->head = p; - - q->tail = p; - q->len++; - - pq->len++; - - if (pq->hi_prec < prec) - pq->hi_prec = (u8) prec; - - return p; -} -EXPORT_SYMBOL(brcmu_pktq_penq); - -struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, - struct sk_buff *p) -{ - struct pktq_prec *q; - - if (pktq_full(pq) || pktq_pfull(pq, prec)) - return NULL; - - q = &pq->q[prec]; - - if (q->head == NULL) - q->tail = p; - - p->prev = q->head; - q->head = p; - q->len++; - - pq->len++; - - if (pq->hi_prec < prec) - pq->hi_prec = (u8) prec; - - return p; -} -EXPORT_SYMBOL(brcmu_pktq_penq_head); - -struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) -{ - struct pktq_prec *q; - struct sk_buff *p; - - q = &pq->q[prec]; - - p = q->head; - if (p == NULL) - return NULL; - - q->head = p->prev; - if (q->head == NULL) - q->tail = NULL; - - q->len--; - - pq->len--; - - p->prev = NULL; - - return p; -} -EXPORT_SYMBOL(brcmu_pktq_pdeq); - -struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) -{ - struct pktq_prec *q; - struct sk_buff *p, *prev; - - q = &pq->q[prec]; - - p = q->head; - if (p == NULL) - return NULL; - - for (prev = NULL; p != q->tail; p = p->prev) - prev = p; - - if (prev) - prev->prev = NULL; - else - q->head = NULL; - - q->tail = prev; - q->len--; - - pq->len--; - - return p; -} -EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); - -void -brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, - bool (*fn)(struct sk_buff *, void *), void *arg) -{ - struct pktq_prec *q; - struct sk_buff *p, *prev = NULL; - - q = &pq->q[prec]; - p = q->head; - while (p) { - if (fn == NULL || (*fn) (p, arg)) { - bool head = (p == q->head); - if (head) - q->head = p->prev; - else - prev->prev = p->prev; - p->prev = NULL; - brcmu_pkt_buf_free_skb(p); - q->len--; - pq->len--; - p = (head ? q->head : prev->prev); - } else { - prev = p; - p = p->prev; - } - } - - if (q->head == NULL) - q->tail = NULL; -} -EXPORT_SYMBOL(brcmu_pktq_pflush); - -void brcmu_pktq_flush(struct pktq *pq, bool dir, - bool (*fn)(struct sk_buff *, void *), void *arg) -{ - int prec; - for (prec = 0; prec < pq->num_prec; prec++) - brcmu_pktq_pflush(pq, prec, dir, fn, arg); -} -EXPORT_SYMBOL(brcmu_pktq_flush); - -void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len) -{ - int prec; - - /* pq is variable size; only zero out what's requested */ - memset(pq, 0, - offsetof(struct pktq, q) + (sizeof(struct pktq_prec) * num_prec)); - - pq->num_prec = (u16) num_prec; - - pq->max = (u16) max_len; - - for (prec = 0; prec < num_prec; prec++) - pq->q[prec].max = pq->max; -} -EXPORT_SYMBOL(brcmu_pktq_init); - -struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out) -{ - int prec; - - if (pq->len == 0) - return NULL; - - for (prec = 0; prec < pq->hi_prec; prec++) - if (pq->q[prec].head) - break; - - if (prec_out) - *prec_out = prec; - - return pq->q[prec].tail; -} -EXPORT_SYMBOL(brcmu_pktq_peek_tail); - -/* Return sum of lengths of a specific set of precedences */ -int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp) -{ - int prec, len; - - len = 0; - - for (prec = 0; prec <= pq->hi_prec; prec++) - if (prec_bmp & (1 << prec)) - len += pq->q[prec].len; - - return len; -} -EXPORT_SYMBOL(brcmu_pktq_mlen); - -/* Priority dequeue from a specific set of precedences */ -struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, - int *prec_out) -{ - struct pktq_prec *q; - struct sk_buff *p; - int prec; - - if (pq->len == 0) - return NULL; - - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) - pq->hi_prec--; - - while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL) - if (prec-- == 0) - return NULL; - - q = &pq->q[prec]; - - p = q->head; - if (p == NULL) - return NULL; - - q->head = p->prev; - if (q->head == NULL) - q->tail = NULL; - - q->len--; - - if (prec_out) - *prec_out = prec; - - pq->len--; - - p->prev = NULL; - - return p; -} -EXPORT_SYMBOL(brcmu_pktq_mdeq); - -#if defined(BCMDBG) -/* pretty hex print a pkt buffer chain */ -void brcmu_prpkt(const char *msg, struct sk_buff *p0) -{ - struct sk_buff *p; - - if (msg && (msg[0] != '\0')) - printk(KERN_DEBUG "%s:\n", msg); - - for (p = p0; p; p = p->next) - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); -} -EXPORT_SYMBOL(brcmu_prpkt); -#endif /* defined(BCMDBG) */ - -/* - * Traverse a string of 1-byte tag/1-byte length/variable-length value - * triples, returning a pointer to the substring whose first element - * matches tag - */ -struct brcmu_tlv *brcmu_parse_tlvs(void *buf, int buflen, uint key) -{ - struct brcmu_tlv *elt; - int totlen; - - elt = (struct brcmu_tlv *) buf; - totlen = buflen; - - /* find tagged parameter */ - while (totlen >= 2) { - int len = elt->len; - - /* validate remaining totlen */ - if ((elt->id == key) && (totlen >= (len + 2))) - return elt; - - elt = (struct brcmu_tlv *) ((u8 *) elt + (len + 2)); - totlen -= (len + 2); - } - - return NULL; -} -EXPORT_SYMBOL(brcmu_parse_tlvs); - - -#if defined(BCMDBG) -int -brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, char *buf, - int len) -{ - int i; - char *p = buf; - char hexstr[16]; - int slen = 0, nlen = 0; - u32 bit; - const char *name; - - if (len < 2 || !buf) - return 0; - - buf[0] = '\0'; - - for (i = 0; flags != 0; i++) { - bit = bd[i].bit; - name = bd[i].name; - if (bit == 0 && flags != 0) { - /* print any unnamed bits */ - snprintf(hexstr, 16, "0x%X", flags); - name = hexstr; - flags = 0; /* exit loop */ - } else if ((flags & bit) == 0) - continue; - flags &= ~bit; - nlen = strlen(name); - slen += nlen; - /* count btwn flag space */ - if (flags != 0) - slen += 1; - /* need NULL char as well */ - if (len <= slen) - break; - /* copy NULL char but don't count it */ - strncpy(p, name, nlen + 1); - p += nlen; - /* copy btwn flag space and NULL char */ - if (flags != 0) - p += snprintf(p, 2, " "); - len -= slen; - } - - /* indicate the str was too short */ - if (flags != 0) { - if (len < 2) - p -= 2 - len; /* overwrite last char */ - p += snprintf(p, 2, ">"); - } - - return (int)(p - buf); -} -EXPORT_SYMBOL(brcmu_format_flags); - -/* - * print bytes formatted as hex to a string. return the resulting - * string length - */ -int brcmu_format_hex(char *str, const void *bytes, int len) -{ - int i; - char *p = str; - const u8 *src = (const u8 *)bytes; - - for (i = 0; i < len; i++) { - p += snprintf(p, 3, "%02X", *src); - src++; - } - return (int)(p - str); -} -EXPORT_SYMBOL(brcmu_format_hex); -#endif /* defined(BCMDBG) */ - -char *brcmu_chipname(uint chipid, char *buf, uint len) -{ - const char *fmt; - - fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; - snprintf(buf, len, fmt, chipid); - return buf; -} -EXPORT_SYMBOL(brcmu_chipname); - -uint brcmu_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen) -{ - uint len; - - len = strlen(name) + 1; - - if ((len + datalen) > buflen) - return 0; - - strncpy(buf, name, buflen); - - /* append data onto the end of the name string */ - memcpy(&buf[len], data, datalen); - len += datalen; - - return len; -} -EXPORT_SYMBOL(brcmu_mkiovar); - -/* Quarter dBm units to mW - * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153 - * Table is offset so the last entry is largest mW value that fits in - * a u16. - */ - -#define QDBM_OFFSET 153 /* Offset for first entry */ -#define QDBM_TABLE_LEN 40 /* Table size */ - -/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET. - * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2 - */ -#define QDBM_TABLE_LOW_BOUND 6493 /* Low bound */ - -/* Largest mW value that will round down to the last table entry, - * QDBM_OFFSET + QDBM_TABLE_LEN-1. - * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + - * mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2. - */ -#define QDBM_TABLE_HIGH_BOUND 64938 /* High bound */ - -static const u16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = { -/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */ -/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000, -/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849, -/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119, -/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811, -/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096 -}; - -u16 brcmu_qdbm_to_mw(u8 qdbm) -{ - uint factor = 1; - int idx = qdbm - QDBM_OFFSET; - - if (idx >= QDBM_TABLE_LEN) - /* clamp to max u16 mW value */ - return 0xFFFF; - - /* scale the qdBm index up to the range of the table 0-40 - * where an offset of 40 qdBm equals a factor of 10 mW. - */ - while (idx < 0) { - idx += 40; - factor *= 10; - } - - /* return the mW value scaled down to the correct factor of 10, - * adding in factor/2 to get proper rounding. - */ - return (nqdBm_to_mW_map[idx] + factor / 2) / factor; -} -EXPORT_SYMBOL(brcmu_qdbm_to_mw); - -u8 brcmu_mw_to_qdbm(u16 mw) -{ - u8 qdbm; - int offset; - uint mw_uint = mw; - uint boundary; - - /* handle boundary case */ - if (mw_uint <= 1) - return 0; - - offset = QDBM_OFFSET; - - /* move mw into the range of the table */ - while (mw_uint < QDBM_TABLE_LOW_BOUND) { - mw_uint *= 10; - offset -= 40; - } - - for (qdbm = 0; qdbm < QDBM_TABLE_LEN - 1; qdbm++) { - boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm + 1] - - nqdBm_to_mW_map[qdbm]) / 2; - if (mw_uint < boundary) - break; - } - - qdbm += (u8) offset; - - return qdbm; -} -EXPORT_SYMBOL(brcmu_mw_to_qdbm); - -uint brcmu_bitcount(u8 *bitmap, uint length) -{ - uint bitcount = 0, i; - u8 tmp; - for (i = 0; i < length; i++) { - tmp = bitmap[i]; - while (tmp) { - bitcount++; - tmp &= (tmp - 1); - } - } - return bitcount; -} -EXPORT_SYMBOL(brcmu_bitcount); diff --git a/drivers/staging/brcm80211/brcmutil/wifi.c b/drivers/staging/brcm80211/brcmutil/wifi.c deleted file mode 100644 index 509e25c9c86..00000000000 --- a/drivers/staging/brcm80211/brcmutil/wifi.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include - -/* - * Verify the chanspec is using a legal set of parameters, i.e. that the - * chanspec specified a band, bw, ctl_sb and channel and that the - * combination could be legal given any set of circumstances. - * RETURNS: true is the chanspec is malformed, false if it looks good. - */ -bool brcmu_chspec_malformed(u16 chanspec) -{ - /* must be 2G or 5G band */ - if (!CHSPEC_IS5G(chanspec) && !CHSPEC_IS2G(chanspec)) - return true; - /* must be 20 or 40 bandwidth */ - if (!CHSPEC_IS40(chanspec) && !CHSPEC_IS20(chanspec)) - return true; - - /* 20MHZ b/w must have no ctl sb, 40 must have a ctl sb */ - if (CHSPEC_IS20(chanspec)) { - if (!CHSPEC_SB_NONE(chanspec)) - return true; - } else if (!CHSPEC_SB_UPPER(chanspec) && !CHSPEC_SB_LOWER(chanspec)) { - return true; - } - - return false; -} -EXPORT_SYMBOL(brcmu_chspec_malformed); - -/* - * This function returns the channel number that control traffic is being sent - * on, for legacy channels this is just the channel number, for 40MHZ channels - * it is the upper or lower 20MHZ sideband depending on the chanspec selected. - */ -u8 brcmu_chspec_ctlchan(u16 chspec) -{ - u8 ctl_chan; - - /* Is there a sideband ? */ - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) { - return CHSPEC_CHANNEL(chspec); - } else { - /* - * we only support 40MHZ with sidebands. chanspec channel holds - * the centre frequency, use that and the side band information - * to reconstruct the control channel number - */ - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) - /* - * control chan is the upper 20 MHZ SB of the - * 40MHZ channel - */ - ctl_chan = upper_20_sb(CHSPEC_CHANNEL(chspec)); - else - /* - * control chan is the lower 20 MHZ SB of the - * 40MHZ channel - */ - ctl_chan = lower_20_sb(CHSPEC_CHANNEL(chspec)); - } - - return ctl_chan; -} -EXPORT_SYMBOL(brcmu_chspec_ctlchan); - -/* - * Return the channel number for a given frequency and base frequency. - * The returned channel number is relative to the given base frequency. - * If the given base frequency is zero, a base frequency of 5 GHz is assumed for - * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz. - * - * Frequency is specified in MHz. - * The base frequency is specified as (start_factor * 500 kHz). - * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for - * 2.4 GHz and 5 GHz bands. - * - * The returned channel will be in the range [1, 14] in the 2.4 GHz band - * and [0, 200] otherwise. - * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the - * frequency is not a 2.4 GHz channel, or if the frequency is not and even - * multiple of 5 MHz from the base frequency to the base plus 1 GHz. - * - * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 - */ -int brcmu_mhz2channel(uint freq, uint start_factor) -{ - int ch = -1; - uint base; - int offset; - - /* take the default channel start frequency */ - if (start_factor == 0) { - if (freq >= 2400 && freq <= 2500) - start_factor = WF_CHAN_FACTOR_2_4_G; - else if (freq >= 5000 && freq <= 6000) - start_factor = WF_CHAN_FACTOR_5_G; - } - - if (freq == 2484 && start_factor == WF_CHAN_FACTOR_2_4_G) - return 14; - - base = start_factor / 2; - - /* check that the frequency is in 1GHz range of the base */ - if ((freq < base) || (freq > base + 1000)) - return -1; - - offset = freq - base; - ch = offset / 5; - - /* check that frequency is a 5MHz multiple from the base */ - if (offset != (ch * 5)) - return -1; - - /* restricted channel range check for 2.4G */ - if (start_factor == WF_CHAN_FACTOR_2_4_G && (ch < 1 || ch > 13)) - return -1; - - return ch; -} -EXPORT_SYMBOL(brcmu_mhz2channel); diff --git a/drivers/staging/brcm80211/include/brcm_hw_ids.h b/drivers/staging/brcm80211/include/brcm_hw_ids.h deleted file mode 100644 index 5fb17d53c9b..00000000000 --- a/drivers/staging/brcm80211/include/brcm_hw_ids.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_HW_IDS_H_ -#define _BRCM_HW_IDS_H_ - -#define BCM4325_D11DUAL_ID 0x431b -#define BCM4325_D11G_ID 0x431c -#define BCM4325_D11A_ID 0x431d - -#define BCM4329_D11N2G_ID 0x432f /* 4329 802.11n 2.4G device */ -#define BCM4329_D11N5G_ID 0x4330 /* 4329 802.11n 5G device */ -#define BCM4329_D11NDUAL_ID 0x432e - -#define BCM4319_D11N_ID 0x4337 /* 4319 802.11n dualband device */ -#define BCM4319_D11N2G_ID 0x4338 /* 4319 802.11n 2.4G device */ -#define BCM4319_D11N5G_ID 0x4339 /* 4319 802.11n 5G device */ - -#define BCM43224_D11N_ID 0x4353 /* 43224 802.11n dualband device */ -#define BCM43224_D11N_ID_VEN1 0x0576 /* Vendor specific 43224 802.11n db */ - -#define BCM43225_D11N2G_ID 0x4357 /* 43225 802.11n 2.4GHz device */ - -#define BCM43236_D11N_ID 0x4346 /* 43236 802.11n dualband device */ -#define BCM43236_D11N2G_ID 0x4347 /* 43236 802.11n 2.4GHz device */ - -#define BCM4313_D11N2G_ID 0x4727 /* 4313 802.11n 2.4G device */ - -/* Chip IDs */ -#define BCM4313_CHIP_ID 0x4313 /* 4313 chip id */ -#define BCM4319_CHIP_ID 0x4319 /* 4319 chip id */ - -#define BCM43224_CHIP_ID 43224 /* 43224 chipcommon chipid */ -#define BCM43225_CHIP_ID 43225 /* 43225 chipcommon chipid */ -#define BCM43421_CHIP_ID 43421 /* 43421 chipcommon chipid */ -#define BCM43235_CHIP_ID 43235 /* 43235 chipcommon chipid */ -#define BCM43236_CHIP_ID 43236 /* 43236 chipcommon chipid */ -#define BCM43238_CHIP_ID 43238 /* 43238 chipcommon chipid */ -#define BCM4329_CHIP_ID 0x4329 /* 4329 chipcommon chipid */ -#define BCM4325_CHIP_ID 0x4325 /* 4325 chipcommon chipid */ -#define BCM4331_CHIP_ID 0x4331 /* 4331 chipcommon chipid */ -#define BCM4336_CHIP_ID 0x4336 /* 4336 chipcommon chipid */ -#define BCM4330_CHIP_ID 0x4330 /* 4330 chipcommon chipid */ -#define BCM6362_CHIP_ID 0x6362 /* 6362 chipcommon chipid */ - -#endif /* _BRCM_HW_IDS_H_ */ diff --git a/drivers/staging/brcm80211/include/brcmu_utils.h b/drivers/staging/brcm80211/include/brcmu_utils.h deleted file mode 100644 index a7d3df23661..00000000000 --- a/drivers/staging/brcm80211/include/brcmu_utils.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCMU_UTILS_H_ -#define _BRCMU_UTILS_H_ - -#include - -/* - * Spin at most 'us' microseconds while 'exp' is true. - * Caller should explicitly test 'exp' when this completes - * and take appropriate error action if 'exp' is still true. - */ -#define SPINWAIT(exp, us) { \ - uint countdown = (us) + 9; \ - while ((exp) && (countdown >= 10)) {\ - udelay(10); \ - countdown -= 10; \ - } \ -} - -/* osl multi-precedence packet queue */ -#define PKTQ_LEN_DEFAULT 128 /* Max 128 packets */ -#define PKTQ_MAX_PREC 16 /* Maximum precedence levels */ - -#define BCME_STRLEN 64 /* Max string length for BCM errors */ - -/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ -#define PKTBUFSZ 2048 - -#ifndef setbit -#ifndef NBBY /* the BSD family defines NBBY */ -#define NBBY 8 /* 8 bits per byte */ -#endif /* #ifndef NBBY */ -#define setbit(a, i) (((u8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) -#define clrbit(a, i) (((u8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) -#define isset(a, i) (((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) -#define isclr(a, i) ((((const u8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) -#endif /* setbit */ - -#define NBITS(type) (sizeof(type) * 8) -#define NBITVAL(nbits) (1 << (nbits)) -#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) -#define NBITMASK(nbits) MAXBITVAL(nbits) -#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) - -/* crc defines */ -#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */ -#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */ - -/* 18-bytes of Ethernet address buffer length */ -#define ETHER_ADDR_STR_LEN 18 - -struct pktq_prec { - struct sk_buff *head; /* first packet to dequeue */ - struct sk_buff *tail; /* last packet to dequeue */ - u16 len; /* number of queued packets */ - u16 max; /* maximum number of queued packets */ -}; - -/* multi-priority pkt queue */ -struct pktq { - u16 num_prec; /* number of precedences in use */ - u16 hi_prec; /* rapid dequeue hint (>= highest non-empty prec) */ - u16 max; /* total max packets */ - u16 len; /* total number of packets */ - /* - * q array must be last since # of elements can be either - * PKTQ_MAX_PREC or 1 - */ - struct pktq_prec q[PKTQ_MAX_PREC]; -}; - -/* operations on a specific precedence in packet queue */ - -static inline int pktq_plen(struct pktq *pq, int prec) -{ - return pq->q[prec].len; -} - -static inline int pktq_pavail(struct pktq *pq, int prec) -{ - return pq->q[prec].max - pq->q[prec].len; -} - -static inline bool pktq_pfull(struct pktq *pq, int prec) -{ - return pq->q[prec].len >= pq->q[prec].max; -} - -static inline bool pktq_pempty(struct pktq *pq, int prec) -{ - return pq->q[prec].len == 0; -} - -static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) -{ - return pq->q[prec].head; -} - -static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) -{ - return pq->q[prec].tail; -} - -extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, - struct sk_buff *p); -extern struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, - struct sk_buff *p); -extern struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec); -extern struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec); - -/* packet primitives */ -extern struct sk_buff *brcmu_pkt_buf_get_skb(uint len); -extern void brcmu_pkt_buf_free_skb(struct sk_buff *skb); - -/* Empty the queue at particular precedence level */ -/* callback function fn(pkt, arg) returns true if pkt belongs to if */ -extern void brcmu_pktq_pflush(struct pktq *pq, int prec, - bool dir, bool (*fn)(struct sk_buff *, void *), void *arg); - -/* operations on a set of precedences in packet queue */ - -extern int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp); -extern struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, - int *prec_out); - -/* operations on packet queue as a whole */ - -static inline int pktq_len(struct pktq *pq) -{ - return (int)pq->len; -} - -static inline int pktq_max(struct pktq *pq) -{ - return (int)pq->max; -} - -static inline int pktq_avail(struct pktq *pq) -{ - return (int)(pq->max - pq->len); -} - -static inline bool pktq_full(struct pktq *pq) -{ - return pq->len >= pq->max; -} - -static inline bool pktq_empty(struct pktq *pq) -{ - return pq->len == 0; -} - -extern void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len); -/* prec_out may be NULL if caller is not interested in return value */ -extern struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out); -extern void brcmu_pktq_flush(struct pktq *pq, bool dir, - bool (*fn)(struct sk_buff *, void *), void *arg); - -/* externs */ -/* packet */ -extern uint brcmu_pktfrombuf(struct sk_buff *p, - uint offset, int len, unsigned char *buf); -extern uint brcmu_pkttotlen(struct sk_buff *p); - -/* ip address */ -struct ipv4_addr; - -#ifdef BCMDBG -extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); -#else -#define brcmu_prpkt(a, b) -#endif /* BCMDBG */ - -/* brcmu_format_flags() bit description structure */ -struct brcmu_bit_desc { - u32 bit; - const char *name; -}; - -/* tag_ID/length/value_buffer tuple */ -struct brcmu_tlv { - u8 id; - u8 len; - u8 data[1]; -}; - -/* externs */ -/* format/print */ -#if defined(BCMDBG) -extern int brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, - char *buf, int len); -extern int brcmu_format_hex(char *str, const void *bytes, int len); -#endif - -extern char *brcmu_chipname(uint chipid, char *buf, uint len); - -extern struct brcmu_tlv *brcmu_parse_tlvs(void *buf, int buflen, - uint key); - -/* power conversion */ -extern u16 brcmu_qdbm_to_mw(u8 qdbm); -extern u8 brcmu_mw_to_qdbm(u16 mw); - -extern uint brcmu_mkiovar(char *name, char *data, uint datalen, - char *buf, uint len); -extern uint brcmu_bitcount(u8 *bitmap, uint bytelength); - -#endif /* _BRCMU_UTILS_H_ */ diff --git a/drivers/staging/brcm80211/include/brcmu_wifi.h b/drivers/staging/brcm80211/include/brcmu_wifi.h deleted file mode 100644 index e98ed50c67c..00000000000 --- a/drivers/staging/brcm80211/include/brcmu_wifi.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCMU_WIFI_H_ -#define _BRCMU_WIFI_H_ - -#include /* for ETH_ALEN */ -#include /* for WLAN_PMKID_LEN */ - -/* - * A chanspec (u16) holds the channel number, band, bandwidth and control - * sideband - */ - -/* channel defines */ -#define CH_UPPER_SB 0x01 -#define CH_LOWER_SB 0x02 -#define CH_EWA_VALID 0x04 -#define CH_20MHZ_APART 4 -#define CH_10MHZ_APART 2 -#define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */ -#define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */ -#define BRCM_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */ - -/* bandstate array indices */ -#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ -#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ - -/* - * max # supported channels. The max channel no is 216, this is that + 1 - * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are - * u8's all over -*/ -#define MAXCHANNEL 224 - -#define WL_CHANSPEC_CHAN_MASK 0x00ff -#define WL_CHANSPEC_CHAN_SHIFT 0 - -#define WL_CHANSPEC_CTL_SB_MASK 0x0300 -#define WL_CHANSPEC_CTL_SB_SHIFT 8 -#define WL_CHANSPEC_CTL_SB_LOWER 0x0100 -#define WL_CHANSPEC_CTL_SB_UPPER 0x0200 -#define WL_CHANSPEC_CTL_SB_NONE 0x0300 - -#define WL_CHANSPEC_BW_MASK 0x0C00 -#define WL_CHANSPEC_BW_SHIFT 10 -#define WL_CHANSPEC_BW_10 0x0400 -#define WL_CHANSPEC_BW_20 0x0800 -#define WL_CHANSPEC_BW_40 0x0C00 - -#define WL_CHANSPEC_BAND_MASK 0xf000 -#define WL_CHANSPEC_BAND_SHIFT 12 -#define WL_CHANSPEC_BAND_5G 0x1000 -#define WL_CHANSPEC_BAND_2G 0x2000 -#define INVCHANSPEC 255 - -/* used to calculate the chan_freq = chan_factor * 500Mhz + 5 * chan_number */ -#define WF_CHAN_FACTOR_2_4_G 4814 /* 2.4 GHz band, 2407 MHz */ -#define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */ -#define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */ - -#define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK)) -#define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) - -#define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK) -#define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK) - -#define CHSPEC_IS10(chspec) \ - (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) - -#define CHSPEC_IS20(chspec) \ - (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) - -#ifndef CHSPEC_IS40 -#define CHSPEC_IS40(chspec) \ - (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) -#endif - -#define CHSPEC_IS5G(chspec) \ - (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) - -#define CHSPEC_IS2G(chspec) \ - (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) - -#define CHSPEC_SB_NONE(chspec) \ - (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) - -#define CHSPEC_SB_UPPER(chspec) \ - (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) - -#define CHSPEC_SB_LOWER(chspec) \ - (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) - -#define CHSPEC_CTL_CHAN(chspec) \ - ((CHSPEC_SB_LOWER(chspec)) ? \ - (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ - (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK)))) - -#define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G) - -#define CHANSPEC_STR_LEN 8 - -static inline int lower_20_sb(int channel) -{ - return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0; -} - -static inline int upper_20_sb(int channel) -{ - return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ? - channel + CH_10MHZ_APART : 0; -} - -static inline int chspec_bandunit(u16 chspec) -{ - return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX; -} - -static inline u16 ch20mhz_chspec(int channel) -{ - u16 rc = channel <= CH_MAX_2G_CHANNEL ? - WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G; - - return (u16)((u16)channel | WL_CHANSPEC_BW_20 | - WL_CHANSPEC_CTL_SB_NONE | rc); -} - -static inline int next_20mhz_chan(int channel) -{ - return channel < (MAXCHANNEL - CH_20MHZ_APART) ? - channel + CH_20MHZ_APART : 0; -} - -/* defined rate in 500kbps */ -#define BRCM_MAXRATE 108 /* in 500kbps units */ -#define BRCM_RATE_1M 2 /* in 500kbps units */ -#define BRCM_RATE_2M 4 /* in 500kbps units */ -#define BRCM_RATE_5M5 11 /* in 500kbps units */ -#define BRCM_RATE_11M 22 /* in 500kbps units */ -#define BRCM_RATE_6M 12 /* in 500kbps units */ -#define BRCM_RATE_9M 18 /* in 500kbps units */ -#define BRCM_RATE_12M 24 /* in 500kbps units */ -#define BRCM_RATE_18M 36 /* in 500kbps units */ -#define BRCM_RATE_24M 48 /* in 500kbps units */ -#define BRCM_RATE_36M 72 /* in 500kbps units */ -#define BRCM_RATE_48M 96 /* in 500kbps units */ -#define BRCM_RATE_54M 108 /* in 500kbps units */ - -#define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */ - -#define MCSSET_LEN 16 - -static inline bool ac_bitmap_tst(u8 bitmap, int prec) -{ - return (bitmap & (1 << (prec))) != 0; -} - -/* - * Verify the chanspec is using a legal set of parameters, i.e. that the - * chanspec specified a band, bw, ctl_sb and channel and that the - * combination could be legal given any set of circumstances. - * RETURNS: true is the chanspec is malformed, false if it looks good. - */ -extern bool brcmu_chspec_malformed(u16 chanspec); - -/* - * This function returns the channel number that control traffic is being sent - * on, for legacy channels this is just the channel number, for 40MHZ channels - * it is the upper or lower 20MHZ sideband depending on the chanspec selected. - */ -extern u8 brcmu_chspec_ctlchan(u16 chspec); - -/* - * Return the channel number for a given frequency and base frequency. - * The returned channel number is relative to the given base frequency. - * If the given base frequency is zero, a base frequency of 5 GHz is assumed for - * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz. - * - * Frequency is specified in MHz. - * The base frequency is specified as (start_factor * 500 kHz). - * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for - * 2.4 GHz and 5 GHz bands. - * - * The returned channel will be in the range [1, 14] in the 2.4 GHz band - * and [0, 200] otherwise. - * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the - * frequency is not a 2.4 GHz channel, or if the frequency is not and even - * multiple of 5 MHz from the base frequency to the base plus 1 GHz. - * - * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 - */ -extern int brcmu_mhz2channel(uint freq, uint start_factor); - -/* Enumerate crypto algorithms */ -#define CRYPTO_ALGO_OFF 0 -#define CRYPTO_ALGO_WEP1 1 -#define CRYPTO_ALGO_TKIP 2 -#define CRYPTO_ALGO_WEP128 3 -#define CRYPTO_ALGO_AES_CCM 4 -#define CRYPTO_ALGO_AES_RESERVED1 5 -#define CRYPTO_ALGO_AES_RESERVED2 6 -#define CRYPTO_ALGO_NALG 7 - -/* wireless security bitvec */ - -#define WEP_ENABLED 0x0001 -#define TKIP_ENABLED 0x0002 -#define AES_ENABLED 0x0004 -#define WSEC_SWFLAG 0x0008 -/* to go into transition mode without setting wep */ -#define SES_OW_ENABLED 0x0040 - -/* WPA authentication mode bitvec */ -#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */ -#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */ -#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */ -#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */ -#define WPA_AUTH_RESERVED1 0x0008 -#define WPA_AUTH_RESERVED2 0x0010 - -#define WPA2_AUTH_RESERVED1 0x0020 -#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */ -#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */ -#define WPA2_AUTH_RESERVED3 0x0200 -#define WPA2_AUTH_RESERVED4 0x0400 -#define WPA2_AUTH_RESERVED5 0x0800 - -/* pmkid */ -#define MAXPMKID 16 - -#define DOT11_DEFAULT_RTS_LEN 2347 -#define DOT11_DEFAULT_FRAG_LEN 2346 - -#define DOT11_ICV_AES_LEN 8 -#define DOT11_QOS_LEN 2 -#define DOT11_IV_MAX_LEN 8 -#define DOT11_A4_HDR_LEN 30 - -#define HT_CAP_RX_STBC_NO 0x0 -#define HT_CAP_RX_STBC_ONE_STREAM 0x1 - -struct pmkid { - u8 BSSID[ETH_ALEN]; - u8 PMKID[WLAN_PMKID_LEN]; -}; - -struct pmkid_list { - u32 npmkid; - struct pmkid pmkid[1]; -}; - -struct pmkid_cand { - u8 BSSID[ETH_ALEN]; - u8 preauth; -}; - -struct pmkid_cand_list { - u32 npmkid_cand; - struct pmkid_cand pmkid_cand[1]; -}; - -#endif /* _BRCMU_WIFI_H_ */ diff --git a/drivers/staging/brcm80211/include/chipcommon.h b/drivers/staging/brcm80211/include/chipcommon.h deleted file mode 100644 index fefabc39e64..00000000000 --- a/drivers/staging/brcm80211/include/chipcommon.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _SBCHIPC_H -#define _SBCHIPC_H - -#include "defs.h" /* for PAD macro */ - -struct chipcregs { - u32 chipid; /* 0x0 */ - u32 capabilities; - u32 corecontrol; /* corerev >= 1 */ - u32 bist; - - /* OTP */ - u32 otpstatus; /* 0x10, corerev >= 10 */ - u32 otpcontrol; - u32 otpprog; - u32 otplayout; /* corerev >= 23 */ - - /* Interrupt control */ - u32 intstatus; /* 0x20 */ - u32 intmask; - - /* Chip specific regs */ - u32 chipcontrol; /* 0x28, rev >= 11 */ - u32 chipstatus; /* 0x2c, rev >= 11 */ - - /* Jtag Master */ - u32 jtagcmd; /* 0x30, rev >= 10 */ - u32 jtagir; - u32 jtagdr; - u32 jtagctrl; - - /* serial flash interface registers */ - u32 flashcontrol; /* 0x40 */ - u32 flashaddress; - u32 flashdata; - u32 PAD[1]; - - /* Silicon backplane configuration broadcast control */ - u32 broadcastaddress; /* 0x50 */ - u32 broadcastdata; - - /* gpio - cleared only by power-on-reset */ - u32 gpiopullup; /* 0x58, corerev >= 20 */ - u32 gpiopulldown; /* 0x5c, corerev >= 20 */ - u32 gpioin; /* 0x60 */ - u32 gpioout; /* 0x64 */ - u32 gpioouten; /* 0x68 */ - u32 gpiocontrol; /* 0x6C */ - u32 gpiointpolarity; /* 0x70 */ - u32 gpiointmask; /* 0x74 */ - - /* GPIO events corerev >= 11 */ - u32 gpioevent; - u32 gpioeventintmask; - - /* Watchdog timer */ - u32 watchdog; /* 0x80 */ - - /* GPIO events corerev >= 11 */ - u32 gpioeventintpolarity; - - /* GPIO based LED powersave registers corerev >= 16 */ - u32 gpiotimerval; /* 0x88 */ - u32 gpiotimeroutmask; - - /* clock control */ - u32 clockcontrol_n; /* 0x90 */ - u32 clockcontrol_sb; /* aka m0 */ - u32 clockcontrol_pci; /* aka m1 */ - u32 clockcontrol_m2; /* mii/uart/mipsref */ - u32 clockcontrol_m3; /* cpu */ - u32 clkdiv; /* corerev >= 3 */ - u32 gpiodebugsel; /* corerev >= 28 */ - u32 capabilities_ext; /* 0xac */ - - /* pll delay registers (corerev >= 4) */ - u32 pll_on_delay; /* 0xb0 */ - u32 fref_sel_delay; - u32 slow_clk_ctl; /* 5 < corerev < 10 */ - u32 PAD; - - /* Instaclock registers (corerev >= 10) */ - u32 system_clk_ctl; /* 0xc0 */ - u32 clkstatestretch; - u32 PAD[2]; - - /* Indirect backplane access (corerev >= 22) */ - u32 bp_addrlow; /* 0xd0 */ - u32 bp_addrhigh; - u32 bp_data; - u32 PAD; - u32 bp_indaccess; - u32 PAD[3]; - - /* More clock dividers (corerev >= 32) */ - u32 clkdiv2; - u32 PAD[2]; - - /* In AI chips, pointer to erom */ - u32 eromptr; /* 0xfc */ - - /* ExtBus control registers (corerev >= 3) */ - u32 pcmcia_config; /* 0x100 */ - u32 pcmcia_memwait; - u32 pcmcia_attrwait; - u32 pcmcia_iowait; - u32 ide_config; - u32 ide_memwait; - u32 ide_attrwait; - u32 ide_iowait; - u32 prog_config; - u32 prog_waitcount; - u32 flash_config; - u32 flash_waitcount; - u32 SECI_config; /* 0x130 SECI configuration */ - u32 PAD[3]; - - /* Enhanced Coexistence Interface (ECI) registers (corerev >= 21) */ - u32 eci_output; /* 0x140 */ - u32 eci_control; - u32 eci_inputlo; - u32 eci_inputmi; - u32 eci_inputhi; - u32 eci_inputintpolaritylo; - u32 eci_inputintpolaritymi; - u32 eci_inputintpolarityhi; - u32 eci_intmasklo; - u32 eci_intmaskmi; - u32 eci_intmaskhi; - u32 eci_eventlo; - u32 eci_eventmi; - u32 eci_eventhi; - u32 eci_eventmasklo; - u32 eci_eventmaskmi; - u32 eci_eventmaskhi; - u32 PAD[3]; - - /* SROM interface (corerev >= 32) */ - u32 sromcontrol; /* 0x190 */ - u32 sromaddress; - u32 sromdata; - u32 PAD[17]; - - /* Clock control and hardware workarounds (corerev >= 20) */ - u32 clk_ctl_st; /* 0x1e0 */ - u32 hw_war; - u32 PAD[70]; - - /* UARTs */ - u8 uart0data; /* 0x300 */ - u8 uart0imr; - u8 uart0fcr; - u8 uart0lcr; - u8 uart0mcr; - u8 uart0lsr; - u8 uart0msr; - u8 uart0scratch; - u8 PAD[248]; /* corerev >= 1 */ - - u8 uart1data; /* 0x400 */ - u8 uart1imr; - u8 uart1fcr; - u8 uart1lcr; - u8 uart1mcr; - u8 uart1lsr; - u8 uart1msr; - u8 uart1scratch; - u32 PAD[126]; - - /* PMU registers (corerev >= 20) */ - u32 pmucontrol; /* 0x600 */ - u32 pmucapabilities; - u32 pmustatus; - u32 res_state; - u32 res_pending; - u32 pmutimer; - u32 min_res_mask; - u32 max_res_mask; - u32 res_table_sel; - u32 res_dep_mask; - u32 res_updn_timer; - u32 res_timer; - u32 clkstretch; - u32 pmuwatchdog; - u32 gpiosel; /* 0x638, rev >= 1 */ - u32 gpioenable; /* 0x63c, rev >= 1 */ - u32 res_req_timer_sel; - u32 res_req_timer; - u32 res_req_mask; - u32 PAD; - u32 chipcontrol_addr; /* 0x650 */ - u32 chipcontrol_data; /* 0x654 */ - u32 regcontrol_addr; - u32 regcontrol_data; - u32 pllcontrol_addr; - u32 pllcontrol_data; - u32 pmustrapopt; /* 0x668, corerev >= 28 */ - u32 pmu_xtalfreq; /* 0x66C, pmurev >= 10 */ - u32 PAD[100]; - u16 sromotp[768]; -}; - -/* chipid */ -#define CID_ID_MASK 0x0000ffff /* Chip Id mask */ -#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */ -#define CID_REV_SHIFT 16 /* Chip Revision shift */ -#define CID_PKG_MASK 0x00f00000 /* Package Option mask */ -#define CID_PKG_SHIFT 20 /* Package Option shift */ -#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */ -#define CID_CC_SHIFT 24 -#define CID_TYPE_MASK 0xf0000000 /* Chip Type */ -#define CID_TYPE_SHIFT 28 - -/* capabilities */ -#define CC_CAP_UARTS_MASK 0x00000003 /* Number of UARTs */ -#define CC_CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */ -#define CC_CAP_UCLKSEL 0x00000018 /* UARTs clock select */ -/* UARTs are driven by internal divided clock */ -#define CC_CAP_UINTCLK 0x00000008 -#define CC_CAP_UARTGPIO 0x00000020 /* UARTs own GPIOs 15:12 */ -#define CC_CAP_EXTBUS_MASK 0x000000c0 /* External bus mask */ -#define CC_CAP_EXTBUS_NONE 0x00000000 /* No ExtBus present */ -#define CC_CAP_EXTBUS_FULL 0x00000040 /* ExtBus: PCMCIA, IDE & Prog */ -#define CC_CAP_EXTBUS_PROG 0x00000080 /* ExtBus: ProgIf only */ -#define CC_CAP_FLASH_MASK 0x00000700 /* Type of flash */ -#define CC_CAP_PLL_MASK 0x00038000 /* Type of PLL */ -#define CC_CAP_PWR_CTL 0x00040000 /* Power control */ -#define CC_CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */ -#define CC_CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */ -#define CC_CAP_OTPSIZE_BASE 5 /* OTP Size base */ -#define CC_CAP_JTAGP 0x00400000 /* JTAG Master Present */ -#define CC_CAP_ROM 0x00800000 /* Internal boot rom active */ -#define CC_CAP_BKPLN64 0x08000000 /* 64-bit backplane */ -#define CC_CAP_PMU 0x10000000 /* PMU Present, rev >= 20 */ -#define CC_CAP_SROM 0x40000000 /* Srom Present, rev >= 32 */ -/* Nand flash present, rev >= 35 */ -#define CC_CAP_NFLASH 0x80000000 - -#define CC_CAP2_SECI 0x00000001 /* SECI Present, rev >= 36 */ -/* GSIO (spi/i2c) present, rev >= 37 */ -#define CC_CAP2_GSIO 0x00000002 - -/* pmucapabilities */ -#define PCAP_REV_MASK 0x000000ff -#define PCAP_RC_MASK 0x00001f00 -#define PCAP_RC_SHIFT 8 -#define PCAP_TC_MASK 0x0001e000 -#define PCAP_TC_SHIFT 13 -#define PCAP_PC_MASK 0x001e0000 -#define PCAP_PC_SHIFT 17 -#define PCAP_VC_MASK 0x01e00000 -#define PCAP_VC_SHIFT 21 -#define PCAP_CC_MASK 0x1e000000 -#define PCAP_CC_SHIFT 25 -#define PCAP5_PC_MASK 0x003e0000 /* PMU corerev >= 5 */ -#define PCAP5_PC_SHIFT 17 -#define PCAP5_VC_MASK 0x07c00000 -#define PCAP5_VC_SHIFT 22 -#define PCAP5_CC_MASK 0xf8000000 -#define PCAP5_CC_SHIFT 27 - -/* -* Maximum delay for the PMU state transition in us. -* This is an upper bound intended for spinwaits etc. -*/ -#define PMU_MAX_TRANSITION_DLY 15000 - -#endif /* _SBCHIPC_H */ diff --git a/drivers/staging/brcm80211/include/defs.h b/drivers/staging/brcm80211/include/defs.h deleted file mode 100644 index 1e5f310af1e..00000000000 --- a/drivers/staging/brcm80211/include/defs.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_DEFS_H_ -#define _BRCM_DEFS_H_ - -#include - -#define SI_BUS 0 -#define PCI_BUS 1 -#define PCMCIA_BUS 2 -#define SDIO_BUS 3 -#define JTAG_BUS 4 -#define USB_BUS 5 -#define SPI_BUS 6 - -#define OFF 0 -#define ON 1 /* ON = 1 */ -#define AUTO (-1) /* Auto = -1 */ - -/* - * Priority definitions according 802.1D - */ -#define PRIO_8021D_NONE 2 -#define PRIO_8021D_BK 1 -#define PRIO_8021D_BE 0 -#define PRIO_8021D_EE 3 -#define PRIO_8021D_CL 4 -#define PRIO_8021D_VI 5 -#define PRIO_8021D_VO 6 -#define PRIO_8021D_NC 7 - -#define MAXPRIO 7 -#define NUMPRIO (MAXPRIO + 1) - -#define WL_NUMRATES 16 /* max # of rates in a rateset */ - -#define BRCM_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NUL */ - -#define BRCM_SET_CHANNEL 30 -#define BRCM_SET_SRL 32 -#define BRCM_SET_LRL 34 -#define BRCM_SET_BCNPRD 76 - -#define BRCM_GET_CURR_RATESET 114 /* current rateset */ -#define BRCM_GET_PHYLIST 180 - -/* Bit masks for radio disabled status - returned by WL_GET_RADIO */ - -#define WL_RADIO_SW_DISABLE (1<<0) -#define WL_RADIO_HW_DISABLE (1<<1) -#define WL_RADIO_MPC_DISABLE (1<<2) -/* some countries don't support any channel */ -#define WL_RADIO_COUNTRY_DISABLE (1<<3) - -/* Override bit for SET_TXPWR. if set, ignore other level limits */ -#define WL_TXPWR_OVERRIDE (1U<<31) - -/* band types */ -#define BRCM_BAND_AUTO 0 /* auto-select */ -#define BRCM_BAND_5G 1 /* 5 Ghz */ -#define BRCM_BAND_2G 2 /* 2.4 Ghz */ -#define BRCM_BAND_ALL 3 /* all bands */ - -/* Values for PM */ -#define PM_OFF 0 -#define PM_MAX 1 - -/* Message levels */ -#define LOG_ERROR_VAL 0x00000001 -#define LOG_TRACE_VAL 0x00000002 - -#define PM_OFF 0 -#define PM_MAX 1 -#define PM_FAST 2 - -/* - * Sonics Configuration Space Registers. - */ - -/* core sbconfig regs are top 256bytes of regs */ -#define SBCONFIGOFF 0xf00 - -/* cpp contortions to concatenate w/arg prescan */ -#ifndef PAD -#define _PADLINE(line) pad ## line -#define _XSTR(line) _PADLINE(line) -#define PAD _XSTR(__LINE__) -#endif - -#endif /* _BRCM_DEFS_H_ */ diff --git a/drivers/staging/brcm80211/include/soc.h b/drivers/staging/brcm80211/include/soc.h deleted file mode 100644 index 4fcb956ad9e..00000000000 --- a/drivers/staging/brcm80211/include/soc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BRCM_SOC_H -#define _BRCM_SOC_H - -#define SI_ENUM_BASE 0x18000000 /* Enumeration space base */ - -/* core codes */ -#define NODEV_CORE_ID 0x700 /* Invalid coreid */ -#define CC_CORE_ID 0x800 /* chipcommon core */ -#define ILINE20_CORE_ID 0x801 /* iline20 core */ -#define SRAM_CORE_ID 0x802 /* sram core */ -#define SDRAM_CORE_ID 0x803 /* sdram core */ -#define PCI_CORE_ID 0x804 /* pci core */ -#define MIPS_CORE_ID 0x805 /* mips core */ -#define ENET_CORE_ID 0x806 /* enet mac core */ -#define CODEC_CORE_ID 0x807 /* v90 codec core */ -#define USB_CORE_ID 0x808 /* usb 1.1 host/device core */ -#define ADSL_CORE_ID 0x809 /* ADSL core */ -#define ILINE100_CORE_ID 0x80a /* iline100 core */ -#define IPSEC_CORE_ID 0x80b /* ipsec core */ -#define UTOPIA_CORE_ID 0x80c /* utopia core */ -#define PCMCIA_CORE_ID 0x80d /* pcmcia core */ -#define SOCRAM_CORE_ID 0x80e /* internal memory core */ -#define MEMC_CORE_ID 0x80f /* memc sdram core */ -#define OFDM_CORE_ID 0x810 /* OFDM phy core */ -#define EXTIF_CORE_ID 0x811 /* external interface core */ -#define D11_CORE_ID 0x812 /* 802.11 MAC core */ -#define APHY_CORE_ID 0x813 /* 802.11a phy core */ -#define BPHY_CORE_ID 0x814 /* 802.11b phy core */ -#define GPHY_CORE_ID 0x815 /* 802.11g phy core */ -#define MIPS33_CORE_ID 0x816 /* mips3302 core */ -#define USB11H_CORE_ID 0x817 /* usb 1.1 host core */ -#define USB11D_CORE_ID 0x818 /* usb 1.1 device core */ -#define USB20H_CORE_ID 0x819 /* usb 2.0 host core */ -#define USB20D_CORE_ID 0x81a /* usb 2.0 device core */ -#define SDIOH_CORE_ID 0x81b /* sdio host core */ -#define ROBO_CORE_ID 0x81c /* roboswitch core */ -#define ATA100_CORE_ID 0x81d /* parallel ATA core */ -#define SATAXOR_CORE_ID 0x81e /* serial ATA & XOR DMA core */ -#define GIGETH_CORE_ID 0x81f /* gigabit ethernet core */ -#define PCIE_CORE_ID 0x820 /* pci express core */ -#define NPHY_CORE_ID 0x821 /* 802.11n 2x2 phy core */ -#define SRAMC_CORE_ID 0x822 /* SRAM controller core */ -#define MINIMAC_CORE_ID 0x823 /* MINI MAC/phy core */ -#define ARM11_CORE_ID 0x824 /* ARM 1176 core */ -#define ARM7S_CORE_ID 0x825 /* ARM7tdmi-s core */ -#define LPPHY_CORE_ID 0x826 /* 802.11a/b/g phy core */ -#define PMU_CORE_ID 0x827 /* PMU core */ -#define SSNPHY_CORE_ID 0x828 /* 802.11n single-stream phy core */ -#define SDIOD_CORE_ID 0x829 /* SDIO device core */ -#define ARMCM3_CORE_ID 0x82a /* ARM Cortex M3 core */ -#define HTPHY_CORE_ID 0x82b /* 802.11n 4x4 phy core */ -#define MIPS74K_CORE_ID 0x82c /* mips 74k core */ -#define GMAC_CORE_ID 0x82d /* Gigabit MAC core */ -#define DMEMC_CORE_ID 0x82e /* DDR1/2 memory controller core */ -#define PCIERC_CORE_ID 0x82f /* PCIE Root Complex core */ -#define OCP_CORE_ID 0x830 /* OCP2OCP bridge core */ -#define SC_CORE_ID 0x831 /* shared common core */ -#define AHB_CORE_ID 0x832 /* OCP2AHB bridge core */ -#define SPIH_CORE_ID 0x833 /* SPI host core */ -#define I2S_CORE_ID 0x834 /* I2S core */ -#define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ -#define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ -#define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ -/* Default component, in ai chips it maps all unused address ranges */ -#define DEF_AI_COMP 0xfff - -/* Common core control flags */ -#define SICF_BIST_EN 0x8000 -#define SICF_PME_EN 0x4000 -#define SICF_CORE_BITS 0x3ffc -#define SICF_FGC 0x0002 -#define SICF_CLOCK_EN 0x0001 - -#endif /* _BRCM_SOC_H */ From 3d65c85f9187d311dbf1bf9e7fc2f5091a770853 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Tue, 4 Oct 2011 08:21:32 -0500 Subject: [PATCH 1412/1519] staging: zcache: reduce tmem bucket lock contention tmem uses hash buckets each with their own rbtree and lock to quickly lookup tmem objects. tmem has TMEM_HASH_BUCKETS (256) buckets per pool. However, because of the way the tmem_oid is generated for frontswap pages, only 16 unique tmem_oids are being generated, resulting in only 16 of the 256 buckets being used. This cause high lock contention for the per bucket locks. This patch changes SWIZ_BITS to include more bits of the offset. The result is that all 256 hash buckets are potentially used resulting in a 95% drop in hash bucket lock contention. Signed-off-by: Seth Jennings Acked-by: Dan Magenheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/zcache-main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index dae2f4ee06a..22b0a750649 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -1804,8 +1804,10 @@ static int zcache_frontswap_poolid = -1; /* * Swizzling increases objects per swaptype, increasing tmem concurrency * for heavy swaploads. Later, larger nr_cpus -> larger SWIZ_BITS + * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from + * frontswap_get_page() */ -#define SWIZ_BITS 4 +#define SWIZ_BITS 27 #define SWIZ_MASK ((1 << SWIZ_BITS) - 1) #define _oswiz(_type, _ind) ((_type << SWIZ_BITS) | (_ind & SWIZ_MASK)) #define iswiz(_ind) (_ind >> SWIZ_BITS) From 54301b5cfe3c16002ab25762a8cd2186beee4a75 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:13 +0300 Subject: [PATCH 1413/1519] staging: xgifb: use PCI drvdata Don't access the global xgi_video_info directly in xgifb_remove(). Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e6156f15f0b..6957b65c11d 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2415,6 +2415,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error_mtrr; } + pci_set_drvdata(pdev, &xgi_video_info); + dumpVGAReg(); return 0; @@ -2444,17 +2446,18 @@ error: static void __devexit xgifb_remove(struct pci_dev *pdev) { + struct video_info *xgifb_info = pci_get_drvdata(pdev); + unregister_framebuffer(fb_info); #ifdef CONFIG_MTRR - if (xgi_video_info.mtrr >= 0) - mtrr_del(xgi_video_info.mtrr, xgi_video_info.video_base, - xgi_video_info.video_size); + if (xgifb_info->mtrr >= 0) + mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, + xgifb_info->video_size); #endif /* CONFIG_MTRR */ - iounmap(xgi_video_info.mmio_vbase); - iounmap(xgi_video_info.video_vbase); - release_mem_region(xgi_video_info.mmio_base, xgi_video_info.mmio_size); - release_mem_region(xgi_video_info.video_base, - xgi_video_info.video_size); + iounmap(xgifb_info->mmio_vbase); + iounmap(xgifb_info->video_vbase); + release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); + release_mem_region(xgifb_info->video_base, xgifb_info->video_size); vfree(XGIhw_ext.pjVirtualRomBase); framebuffer_release(fb_info); pci_set_drvdata(pdev, NULL); From 19c1e88e02c63008745c8549513e53df4aac868f Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:14 +0300 Subject: [PATCH 1414/1519] staging: xgifb: eliminate global fb_info variable Move fb_info into xgi_video_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 3 --- drivers/staging/xgifb/XGI_main_26.c | 3 +++ drivers/staging/xgifb/XGIfb.h | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 467df83860a..dacef51e9ff 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -125,9 +125,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); /* ------------------- Global Variables ----------------------------- */ -/* Fbcon variables */ -static struct fb_info *fb_info; - static struct fb_var_screeninfo default_var = { .xres = 0, .yres = 0, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 6957b65c11d..f7c0afe7fc7 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1986,12 +1986,14 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, u8 CR48, CR38; int ret; bool xgi21_drvlcdcaplist = false; + struct fb_info *fb_info; memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); if (!fb_info) return -ENOMEM; + xgi_video_info.fb_info = fb_info; xgi_video_info.chip_id = pdev->device; pci_read_config_byte(pdev, PCI_REVISION_ID, @@ -2447,6 +2449,7 @@ error: static void __devexit xgifb_remove(struct pci_dev *pdev) { struct video_info *xgifb_info = pci_get_drvdata(pdev); + struct fb_info *fb_info = xgifb_info->fb_info; unregister_framebuffer(fb_info); #ifdef CONFIG_MTRR diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index f778293b553..83a19117308 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -53,6 +53,8 @@ enum xgi_tv_plug { /* vicki@030226 */ }; struct video_info { + struct fb_info *fb_info; + int chip_id; unsigned int video_size; unsigned long video_base; From c62f2e466f875a5eedb4d4f52115c3e7d1cb52f6 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:15 +0300 Subject: [PATCH 1415/1519] staging: xgifb: eliminate global XGIhw_ext data Move xgi_hw_device_info into xgi_video_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 3 - drivers/staging/xgifb/XGI_main_26.c | 94 +++++++++++++++-------------- drivers/staging/xgifb/XGIfb.h | 3 + 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index dacef51e9ff..d423823ca6c 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -184,9 +184,6 @@ static int XGIfb_tvplug = -1; /* TW: For ioctl XGIFB_GET_INFO */ /* XGIfb_info XGIfbinfo; */ -/* TW: Hardware extension; contains data on hardware */ -static struct xgi_hw_device_info XGIhw_ext; - /* TW: XGI private structure */ static struct vb_device_info XGI_Pr; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index f7c0afe7fc7..20ddf3a4d21 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -543,6 +543,7 @@ static int XGIfb_GetXG21LVDSData(void) static int XGIfb_validate_mode(int myindex) { u16 xres, yres; + struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; if (xgi_video_info.chip == XG21) { if ((xgi_video_info.disp_state & DISPTYPE_DISP2) @@ -573,7 +574,7 @@ static int XGIfb_validate_mode(int myindex) switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { case DISPTYPE_LCD: - switch (XGIhw_ext.ulCRT2LCDType) { + switch (hw_info->ulCRT2LCDType) { case LCD_640x480: xres = 640; yres = 480; @@ -629,13 +630,13 @@ static int XGIfb_validate_mode(int myindex) return -1; if (XGIbios_mode[myindex].yres > yres) return -1; - if ((XGIhw_ext.ulExternalChip == 0x01) || /* LVDS */ - (XGIhw_ext.ulExternalChip == 0x05)) { /* LVDS+Chrontel */ + if ((hw_info->ulExternalChip == 0x01) || /* LVDS */ + (hw_info->ulExternalChip == 0x05)) { /* LVDS+Chrontel */ switch (XGIbios_mode[myindex].xres) { case 512: if (XGIbios_mode[myindex].yres != 512) return -1; - if (XGIhw_ext.ulCRT2LCDType == LCD_1024x600) + if (hw_info->ulCRT2LCDType == LCD_1024x600) return -1; break; case 640: @@ -653,13 +654,13 @@ static int XGIfb_validate_mode(int myindex) (XGIbios_mode[myindex].yres != 768)) return -1; if ((XGIbios_mode[myindex].yres == 600) && - (XGIhw_ext.ulCRT2LCDType != LCD_1024x600)) + (hw_info->ulCRT2LCDType != LCD_1024x600)) return -1; break; case 1152: if ((XGIbios_mode[myindex].yres) != 768) return -1; - if (XGIhw_ext.ulCRT2LCDType != LCD_1152x768) + if (hw_info->ulCRT2LCDType != LCD_1152x768) return -1; break; case 1280: @@ -667,7 +668,7 @@ static int XGIfb_validate_mode(int myindex) (XGIbios_mode[myindex].yres != 1024)) return -1; if ((XGIbios_mode[myindex].yres == 768) && - (XGIhw_ext.ulCRT2LCDType != LCD_1280x768)) + (hw_info->ulCRT2LCDType != LCD_1280x768)) return -1; break; case 1400: @@ -705,7 +706,7 @@ static int XGIfb_validate_mode(int myindex) (XGIbios_mode[myindex].yres != 1024)) return -1; if (XGIbios_mode[myindex].yres == 960) { - if (XGIhw_ext.ulCRT2LCDType == + if (hw_info->ulCRT2LCDType == LCD_1400x1050) return -1; } @@ -1161,7 +1162,7 @@ static void XGIfb_post_setmode(void) static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *info) { - + struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; unsigned int htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len; unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin @@ -1248,7 +1249,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, if (isactive) { XGIfb_pre_setmode(); - if (XGISetModeNew(&XGIhw_ext, XGIfb_mode_no) == 0) { + if (XGISetModeNew(hw_info, XGIfb_mode_no) == 0) { printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", XGIfb_mode_no); return -EINVAL; @@ -1987,8 +1988,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, int ret; bool xgi21_drvlcdcaplist = false; struct fb_info *fb_info; + struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; - memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); + memset(hw_info, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); if (!fb_info) return -ENOMEM; @@ -1998,7 +2000,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, pci_read_config_byte(pdev, PCI_REVISION_ID, &xgi_video_info.revision_id); - XGIhw_ext.jChipRevision = xgi_video_info.revision_id; + hw_info->jChipRevision = xgi_video_info.revision_id; xgi_video_info.pcibus = pdev->bus->number; xgi_video_info.pcislot = PCI_SLOT(pdev->devfn); @@ -2010,7 +2012,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgi_video_info.mmio_base = pci_resource_start(pdev, 1); xgi_video_info.mmio_size = pci_resource_len(pdev, 1); xgi_video_info.vga_base = pci_resource_start(pdev, 2) + 0x30; - XGIhw_ext.pjIOAddress = (unsigned char *)xgi_video_info.vga_base; + hw_info->pjIOAddress = (unsigned char *)xgi_video_info.vga_base; /* XGI_Pr.RelIO = ioremap(pci_resource_start(pdev, 2), 128) + 0x30; */ printk("XGIfb: Relocate IO address: %lx [%08lx]\n", (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO); @@ -2020,7 +2022,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error; } - XGIRegInit(&XGI_Pr, (unsigned long)XGIhw_ext.pjIOAddress); + XGIRegInit(&XGI_Pr, (unsigned long)hw_info->pjIOAddress); xgifb_reg_set(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD); reg1 = xgifb_reg_get(XGISR, IND_XGI_PASSWORD); @@ -2063,20 +2065,20 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } printk("XGIfb:chipid = %x\n", xgi_video_info.chip); - XGIhw_ext.jChipType = xgi_video_info.chip; + hw_info->jChipType = xgi_video_info.chip; if ((xgi_video_info.chip == XG21) || (XGIfb_userom)) { - XGIhw_ext.pjVirtualRomBase = xgifb_copy_rom(pdev); - if (XGIhw_ext.pjVirtualRomBase) + hw_info->pjVirtualRomBase = xgifb_copy_rom(pdev); + if (hw_info->pjVirtualRomBase) printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n", - XGIhw_ext.pjVirtualRomBase); + hw_info->pjVirtualRomBase); else printk(KERN_INFO "XGIfb: Video ROM not found\n"); } else { - XGIhw_ext.pjVirtualRomBase = NULL; + hw_info->pjVirtualRomBase = NULL; printk(KERN_INFO "XGIfb: Video ROM usage disabled\n"); } - XGIhw_ext.pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space; + hw_info->pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space; if (XGIfb_get_dram_size()) { printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n"); @@ -2091,7 +2093,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, /* Enable 2D accelerator engine */ xgifb_reg_or(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D); - XGIhw_ext.ulVideoMemorySize = xgi_video_info.video_size; + hw_info->ulVideoMemorySize = xgi_video_info.video_size; if (!request_mem_region(xgi_video_info.video_base, xgi_video_info.video_size, @@ -2112,7 +2114,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error_0; } - xgi_video_info.video_vbase = XGIhw_ext.pjVideoMemoryAddress = + xgi_video_info.video_vbase = hw_info->pjVideoMemoryAddress = ioremap(xgi_video_info.video_base, xgi_video_info.video_size); xgi_video_info.mmio_vbase = ioremap(xgi_video_info.mmio_base, xgi_video_info.mmio_size); @@ -2126,7 +2128,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgi_video_info.mmio_base, xgi_video_info.mmio_vbase, xgi_video_info.mmio_size / 1024); printk("XGIfb: XGIInitNew() ..."); - if (XGIInitNew(&XGIhw_ext)) + if (XGIInitNew(hw_info)) printk("OK\n"); else printk("Fail\n"); @@ -2152,62 +2154,62 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_get_VB_type(); } - XGIhw_ext.ujVBChipID = VB_CHIP_UNKNOWN; + hw_info->ujVBChipID = VB_CHIP_UNKNOWN; - XGIhw_ext.ulExternalChip = 0; + hw_info->ulExternalChip = 0; switch (xgi_video_info.hasVB) { case HASVB_301: reg = xgifb_reg_get(XGIPART4, 0x01); if (reg >= 0xE0) { - XGIhw_ext.ujVBChipID = VB_CHIP_302LV; + hw_info->ujVBChipID = VB_CHIP_302LV; printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); } else if (reg >= 0xD0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301LV; + hw_info->ujVBChipID = VB_CHIP_301LV; printk(KERN_INFO "XGIfb: XGI301LV bridge detected (revision 0x%02x)\n", reg); } /* else if (reg >= 0xB0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301B; + hw_info->ujVBChipID = VB_CHIP_301B; reg1 = xgifb_reg_get(XGIPART4, 0x23); printk("XGIfb: XGI301B bridge detected\n"); } */ else { - XGIhw_ext.ujVBChipID = VB_CHIP_301; + hw_info->ujVBChipID = VB_CHIP_301; printk("XGIfb: XGI301 bridge detected\n"); } break; case HASVB_302: reg = xgifb_reg_get(XGIPART4, 0x01); if (reg >= 0xE0) { - XGIhw_ext.ujVBChipID = VB_CHIP_302LV; + hw_info->ujVBChipID = VB_CHIP_302LV; printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); } else if (reg >= 0xD0) { - XGIhw_ext.ujVBChipID = VB_CHIP_301LV; + hw_info->ujVBChipID = VB_CHIP_301LV; printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg); } else if (reg >= 0xB0) { reg1 = xgifb_reg_get(XGIPART4, 0x23); - XGIhw_ext.ujVBChipID = VB_CHIP_302B; + hw_info->ujVBChipID = VB_CHIP_302B; } else { - XGIhw_ext.ujVBChipID = VB_CHIP_302; + hw_info->ujVBChipID = VB_CHIP_302; printk(KERN_INFO "XGIfb: XGI302 bridge detected\n"); } break; case HASVB_LVDS: - XGIhw_ext.ulExternalChip = 0x1; + hw_info->ulExternalChip = 0x1; printk(KERN_INFO "XGIfb: LVDS transmitter detected\n"); break; case HASVB_TRUMPION: - XGIhw_ext.ulExternalChip = 0x2; + hw_info->ulExternalChip = 0x2; printk(KERN_INFO "XGIfb: Trumpion Zurac LVDS scaler detected\n"); break; case HASVB_CHRONTEL: - XGIhw_ext.ulExternalChip = 0x4; + hw_info->ulExternalChip = 0x4; printk(KERN_INFO "XGIfb: Chrontel TV encoder detected\n"); break; case HASVB_LVDS_CHRONTEL: - XGIhw_ext.ulExternalChip = 0x5; + hw_info->ulExternalChip = 0x5; printk(KERN_INFO "XGIfb: LVDS transmitter and Chrontel TV encoder detected\n"); break; default: @@ -2233,17 +2235,17 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (!enable_dstn) { reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); reg &= 0x0f; - XGIhw_ext.ulCRT2LCDType = XGI310paneltype[reg]; + hw_info->ulCRT2LCDType = XGI310paneltype[reg]; } else { /* TW: FSTN/DSTN */ - XGIhw_ext.ulCRT2LCDType = LCD_320x480; + hw_info->ulCRT2LCDType = LCD_320x480; } } - if ((XGIhw_ext.ujVBChipID == VB_CHIP_302B) || - (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) || - (XGIhw_ext.ujVBChipID == VB_CHIP_302LV)) { + if ((hw_info->ujVBChipID == VB_CHIP_302B) || + (hw_info->ujVBChipID == VB_CHIP_301LV) || + (hw_info->ujVBChipID == VB_CHIP_302LV)) { int tmp; tmp = xgifb_reg_get(XGICR, 0x34); if (tmp <= 0x13) { @@ -2371,10 +2373,10 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_bpp_to_var(&default_var); default_var.pixclock = (u32) (1000000000 / - XGIfb_mode_rate_to_dclock(&XGI_Pr, &XGIhw_ext, + XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, XGIfb_mode_no, XGIfb_rate_idx)); - if (XGIfb_mode_rate_to_ddata(&XGI_Pr, &XGIhw_ext, + if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, XGIfb_mode_no, XGIfb_rate_idx, &default_var.left_margin, &default_var.right_margin, &default_var.upper_margin, &default_var.lower_margin, @@ -2437,7 +2439,7 @@ error_0: release_mem_region(xgi_video_info.video_base, xgi_video_info.video_size); error: - vfree(XGIhw_ext.pjVirtualRomBase); + vfree(hw_info->pjVirtualRomBase); framebuffer_release(fb_info); return ret; } @@ -2461,7 +2463,7 @@ static void __devexit xgifb_remove(struct pci_dev *pdev) iounmap(xgifb_info->video_vbase); release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); release_mem_region(xgifb_info->video_base, xgifb_info->video_size); - vfree(XGIhw_ext.pjVirtualRomBase); + vfree(xgifb_info->hw_info.pjVirtualRomBase); framebuffer_release(fb_info); pci_set_drvdata(pdev, NULL); } diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 83a19117308..9b5552ba441 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -3,6 +3,8 @@ #include #include +#include "vgatypes.h" + #define DISPTYPE_CRT1 0x00000008L #define DISPTYPE_CRT2 0x00000004L #define DISPTYPE_LCD 0x00000002L @@ -54,6 +56,7 @@ enum xgi_tv_plug { /* vicki@030226 */ struct video_info { struct fb_info *fb_info; + struct xgi_hw_device_info hw_info; int chip_id; unsigned int video_size; From 6048d761d23958218ea0e67decafdfac81aed663 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:16 +0300 Subject: [PATCH 1416/1519] staging: xgifb: inline XGIfb_query_VGA_config_space() XGIfb_query_VGA_config_space() is used only once during the init and can be replaced with a single PCI configuration space read. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 44 ++--------------------------- drivers/staging/xgifb/vb_init.c | 15 +++++----- drivers/staging/xgifb/vb_init.h | 2 +- drivers/staging/xgifb/vgatypes.h | 4 --- 4 files changed, 11 insertions(+), 54 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 20ddf3a4d21..09aea30bb82 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -387,44 +387,6 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) } -/* ------------ Interface for init & mode switching code ------------- */ - -static unsigned char XGIfb_query_VGA_config_space( - struct xgi_hw_device_info *pXGIhw_ext, unsigned long offset, - unsigned long set, unsigned long *value) -{ - static struct pci_dev *pdev; - static unsigned char init, valid_pdev; - - if (!set) - DPRINTK("XGIfb: Get VGA offset 0x%lx\n", offset); - else - DPRINTK("XGIfb: Set offset 0x%lx to 0x%lx\n", offset, *value); - - if (!init) { - init = 1; - pdev = pci_get_device(PCI_VENDOR_ID_XG, xgi_video_info.chip_id, - pdev); - if (pdev) { - valid_pdev = 1; - pci_dev_put(pdev); - } - } - - if (!valid_pdev) { - printk(KERN_DEBUG "XGIfb: Can't find XGI %d VGA device.\n", - xgi_video_info.chip_id); - return 0; - } - - if (set == 0) - pci_read_config_dword(pdev, offset, (u32 *) value); - else - pci_write_config_dword(pdev, offset, (u32)(*value)); - - return 1; -} - /* ------------------ Internal helper routines ----------------- */ static int XGIfb_GetXG21DefaultLVDSModeIdx(void) @@ -2078,7 +2040,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, hw_info->pjVirtualRomBase = NULL; printk(KERN_INFO "XGIfb: Video ROM usage disabled\n"); } - hw_info->pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space; if (XGIfb_get_dram_size()) { printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n"); @@ -2128,7 +2089,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgi_video_info.mmio_base, xgi_video_info.mmio_vbase, xgi_video_info.mmio_size / 1024); printk("XGIfb: XGIInitNew() ..."); - if (XGIInitNew(hw_info)) + pci_set_drvdata(pdev, &xgi_video_info); + if (XGIInitNew(pdev)) printk("OK\n"); else printk("Fail\n"); @@ -2419,8 +2381,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error_mtrr; } - pci_set_drvdata(pdev, &xgi_video_info); - dumpVGAReg(); return 0; diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index ce5bf6839cf..b6178b498e2 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -1,5 +1,7 @@ #include #include /* udelay */ +#include + #include "vgatypes.h" #include "XGIfb.h" @@ -1427,8 +1429,10 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo) return temp; } -unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) +unsigned char XGIInitNew(struct pci_dev *pdev) { + struct video_info *xgifb_info = pci_get_drvdata(pdev); + struct xgi_hw_device_info *HwDeviceExtension = &xgifb_info->hw_info; struct vb_device_info VBINF; struct vb_device_info *pVBInfo = &VBINF; unsigned char i, temp = 0, temp1; @@ -1437,8 +1441,6 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) /* unsigned long j, k; */ - unsigned long Temp; - pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; @@ -1578,6 +1580,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) printk("12"); if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + u32 Temp; + /* Set AGP Rate */ /* temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B); @@ -1644,10 +1648,7 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) /* if (ChipsetID == 0x25308086) */ /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */ - HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension, - 0x50, - 0, - &Temp); /* Get */ + pci_read_config_dword(pdev, 0x50, &Temp); Temp >>= 20; Temp &= 0xF; diff --git a/drivers/staging/xgifb/vb_init.h b/drivers/staging/xgifb/vb_init.h index 6b7723057f7..a27b4fe0bb7 100644 --- a/drivers/staging/xgifb/vb_init.h +++ b/drivers/staging/xgifb/vb_init.h @@ -1,6 +1,6 @@ #ifndef _VBINIT_ #define _VBINIT_ -extern unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension); +extern unsigned char XGIInitNew(struct pci_dev *pdev); extern struct XGI21_LVDSCapStruct XGI21_LCDCapList[13]; #endif diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h index 76e2d81cbd5..9b939b75c30 100644 --- a/drivers/staging/xgifb/vgatypes.h +++ b/drivers/staging/xgifb/vgatypes.h @@ -73,10 +73,6 @@ struct xgi_hw_device_info { /* "XGI_VB_CHIP_TYPE" */ unsigned long ulCRT2LCDType; /* defined in the data structure type */ - - unsigned char(*pQueryVGAConfigSpace)(struct xgi_hw_device_info *, - unsigned long, unsigned long, - unsigned long *); }; /* Additional IOCTL for communication xgifb <> X driver */ From 7548a83e5f8885679fa568e55242500b6164ee2e Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:17 +0300 Subject: [PATCH 1417/1519] staging: xgifb: add a global variable for the default refresh rate Add a global variable for the default refresh rate. This is done to get rid of references to xgi_video_info before the probe routine, which should allocate the xgi_video_info dynamically in the future. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 09aea30bb82..f0f4746bf17 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -50,6 +50,7 @@ static char *mode; static int vesa = -1; +static unsigned int refresh_rate; /* -------------------- Macro definitions ---------------------------- */ @@ -1890,9 +1891,9 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "vesa:", 5)) { vesa = xgifb_optval(this_opt, 5); } else if (!strncmp(this_opt, "vrate:", 6)) { - xgi_video_info.refresh_rate = xgifb_optval(this_opt, 6); + refresh_rate = xgifb_optval(this_opt, 6); } else if (!strncmp(this_opt, "rate:", 5)) { - xgi_video_info.refresh_rate = xgifb_optval(this_opt, 5); + refresh_rate = xgifb_optval(this_opt, 5); } else if (!strncmp(this_opt, "crt1off", 7)) { XGIfb_crt1off = 1; } else if (!strncmp(this_opt, "filter:", 7)) { @@ -2276,6 +2277,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; /* yilin set default refresh rate */ + xgi_video_info.refresh_rate = refresh_rate; if (xgi_video_info.refresh_rate == 0) xgi_video_info.refresh_rate = 60; if (XGIfb_search_refresh_rate( From ab886ff86dbcae6f5006900bafaf6102ff4bd79b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:18 +0300 Subject: [PATCH 1418/1519] staging: xgifb: rename struct video_info to xgifb_video_info Rename struct video_info to xgifb_video_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 4 ++-- drivers/staging/xgifb/XGIfb.h | 4 ++-- drivers/staging/xgifb/vb_init.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index f0f4746bf17..ef9b969aac3 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -142,7 +142,7 @@ static inline void dumpVGAReg(void) #endif /* data for XGI components */ -struct video_info xgi_video_info; +struct xgifb_video_info xgi_video_info; #if 1 #define DEBUGPRN(x) @@ -2412,7 +2412,7 @@ error: static void __devexit xgifb_remove(struct pci_dev *pdev) { - struct video_info *xgifb_info = pci_get_drvdata(pdev); + struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev); struct fb_info *fb_info = xgifb_info->fb_info; unregister_framebuffer(fb_info); diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 9b5552ba441..0beda426884 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -54,7 +54,7 @@ enum xgi_tv_plug { /* vicki@030226 */ TVPLUG_TOTAL }; -struct video_info { +struct xgifb_video_info { struct fb_info *fb_info; struct xgi_hw_device_info hw_info; @@ -102,6 +102,6 @@ struct video_info { }; -extern struct video_info xgi_video_info; +extern struct xgifb_video_info xgi_video_info; #endif diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index b6178b498e2..ac36191dbff 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -1431,7 +1431,7 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo) unsigned char XGIInitNew(struct pci_dev *pdev) { - struct video_info *xgifb_info = pci_get_drvdata(pdev); + struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev); struct xgi_hw_device_info *HwDeviceExtension = &xgifb_info->hw_info; struct vb_device_info VBINF; struct vb_device_info *pVBInfo = &VBINF; From fd26d42019cbc502769fde01d714126c2ec6abd1 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:19 +0300 Subject: [PATCH 1419/1519] staging: xgifb: avoid direct references xgi_video_info Avoid direct references to global xgi_video_info. This will help changing the data from statically allocated to dynamically allocated. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 506 ++++++++++++++-------------- 1 file changed, 260 insertions(+), 246 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index ef9b969aac3..bb53144e588 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -458,10 +458,10 @@ invalid: printk(KERN_INFO "XGIfb: Invalid VESA mode 0x%x'\n", vesamode); } -static int XGIfb_GetXG21LVDSData(void) +static int XGIfb_GetXG21LVDSData(struct xgifb_video_info *xgifb_info) { u8 tmp; - void __iomem *data = xgi_video_info.mmio_vbase + 0x20000; + void __iomem *data = xgifb_info->mmio_vbase + 0x20000; int i, j, k; tmp = xgifb_reg_get(XGISR, 0x1e); @@ -503,13 +503,13 @@ static int XGIfb_GetXG21LVDSData(void) return 0; } -static int XGIfb_validate_mode(int myindex) +static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) { u16 xres, yres; - struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; + struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; - if (xgi_video_info.chip == XG21) { - if ((xgi_video_info.disp_state & DISPTYPE_DISP2) + if (xgifb_info->chip == XG21) { + if ((xgifb_info->disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD) { xres = XGI21_LCDCapList[0].LVDSHDE; yres = XGI21_LCDCapList[0].LVDSVDE; @@ -529,13 +529,13 @@ static int XGIfb_validate_mode(int myindex) } /* FIXME: for now, all is valid on XG27 */ - if (xgi_video_info.chip == XG27) + if (xgifb_info->chip == XG27) return myindex; if (!(XGIbios_mode[myindex].chipset & MD_XGI315)) return -1; - switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { + switch (xgifb_info->disp_state & DISPTYPE_DISP2) { case DISPTYPE_LCD: switch (hw_info->ulCRT2LCDType) { case LCD_640x480: @@ -694,21 +694,21 @@ static int XGIfb_validate_mode(int myindex) case 800: break; case 720: - if (xgi_video_info.TV_type == TVMODE_NTSC) { + if (xgifb_info->TV_type == TVMODE_NTSC) { if (XGIbios_mode[myindex].yres != 480) return -1; - } else if (xgi_video_info.TV_type == TVMODE_PAL) { + } else if (xgifb_info->TV_type == TVMODE_PAL) { if (XGIbios_mode[myindex].yres != 576) return -1; } /* TW: LVDS/CHRONTEL does not support 720 */ - if (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL || - xgi_video_info.hasVB == HASVB_CHRONTEL) { + if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL || + xgifb_info->hasVB == HASVB_CHRONTEL) { return -1; } break; case 1024: - if (xgi_video_info.TV_type == TVMODE_NTSC) { + if (xgifb_info->TV_type == TVMODE_NTSC) { if (XGIbios_mode[myindex].bpp == 32) return -1; } @@ -745,7 +745,8 @@ static void XGIfb_search_crt2type(const char *name) printk(KERN_INFO "XGIfb: Invalid CRT2 type: %s\n", name); } -static u8 XGIfb_search_refresh_rate(unsigned int rate) +static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, + unsigned int rate) { u16 xres, yres; int i = 0; @@ -765,7 +766,7 @@ static u8 XGIfb_search_refresh_rate(unsigned int rate) DPRINTK("XGIfb: Adjusting rate from %d up to %d\n", rate, XGIfb_vrate[i].refresh); XGIfb_rate_idx = XGIfb_vrate[i].idx; - xgi_video_info.refresh_rate = + xgifb_info->refresh_rate = XGIfb_vrate[i].refresh; } else if (((rate - XGIfb_vrate[i - 1].refresh) <= 2) && (XGIfb_vrate[i].idx @@ -773,7 +774,7 @@ static u8 XGIfb_search_refresh_rate(unsigned int rate) DPRINTK("XGIfb: Adjusting rate from %d down to %d\n", rate, XGIfb_vrate[i-1].refresh); XGIfb_rate_idx = XGIfb_vrate[i - 1].idx; - xgi_video_info.refresh_rate = + xgifb_info->refresh_rate = XGIfb_vrate[i - 1].refresh; } break; @@ -813,13 +814,14 @@ static void XGIfb_search_tvstd(const char *name) /* ----------- FBDev related routines for all series ----------- */ -static void XGIfb_bpp_to_var(struct fb_var_screeninfo *var) +static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info, + struct fb_var_screeninfo *var) { switch (var->bits_per_pixel) { case 8: var->red.offset = var->green.offset = var->blue.offset = 0; var->red.length = var->green.length = var->blue.length = 6; - xgi_video_info.video_cmap_len = 256; + xgifb_info->video_cmap_len = 256; break; case 16: var->red.offset = 11; @@ -830,7 +832,7 @@ static void XGIfb_bpp_to_var(struct fb_var_screeninfo *var) var->blue.length = 5; var->transp.offset = 0; var->transp.length = 0; - xgi_video_info.video_cmap_len = 16; + xgifb_info->video_cmap_len = 16; break; case 32: var->red.offset = 16; @@ -841,21 +843,21 @@ static void XGIfb_bpp_to_var(struct fb_var_screeninfo *var) var->blue.length = 8; var->transp.offset = 24; var->transp.length = 8; - xgi_video_info.video_cmap_len = 16; + xgifb_info->video_cmap_len = 16; break; } } /* --------------------- SetMode routines ------------------------- */ -static void XGIfb_pre_setmode(void) +static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) { u8 cr30 = 0, cr31 = 0; cr31 = xgifb_reg_get(XGICR, 0x31); cr31 &= ~0x60; - switch (xgi_video_info.disp_state & DISPTYPE_DISP2) { + switch (xgifb_info->disp_state & DISPTYPE_DISP2) { case DISPTYPE_CRT2: cr30 = (XGI_VB_OUTPUT_CRT2 | XGI_SIMULTANEOUS_VIEW_ENABLE); cr31 |= XGI_DRIVER_MODE; @@ -865,21 +867,21 @@ static void XGIfb_pre_setmode(void) cr31 |= XGI_DRIVER_MODE; break; case DISPTYPE_TV: - if (xgi_video_info.TV_type == TVMODE_HIVISION) + if (xgifb_info->TV_type == TVMODE_HIVISION) cr30 = (XGI_VB_OUTPUT_HIVISION | XGI_SIMULTANEOUS_VIEW_ENABLE); - else if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) + else if (xgifb_info->TV_plug == TVPLUG_SVIDEO) cr30 = (XGI_VB_OUTPUT_SVIDEO | XGI_SIMULTANEOUS_VIEW_ENABLE); - else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE) + else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE) cr30 = (XGI_VB_OUTPUT_COMPOSITE | XGI_SIMULTANEOUS_VIEW_ENABLE); - else if (xgi_video_info.TV_plug == TVPLUG_SCART) + else if (xgifb_info->TV_plug == TVPLUG_SCART) cr30 = (XGI_VB_OUTPUT_SCART | XGI_SIMULTANEOUS_VIEW_ENABLE); cr31 |= XGI_DRIVER_MODE; - if (XGIfb_tvmode == 1 || xgi_video_info.TV_type == TVMODE_PAL) + if (XGIfb_tvmode == 1 || xgifb_info->TV_type == TVMODE_PAL) cr31 |= 0x01; else cr31 &= ~0x01; @@ -894,7 +896,7 @@ static void XGIfb_pre_setmode(void) xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, (XGIfb_rate_idx & 0x0F)); } -static void XGIfb_post_setmode(void) +static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) { u8 reg; unsigned char doit = 1; @@ -904,21 +906,21 @@ static void XGIfb_post_setmode(void) xgifb_reg_and_or(XGISR,0x0E, 0xF0, 0x01); *test* */ - if (xgi_video_info.video_bpp == 8) { + if (xgifb_info->video_bpp == 8) { /* TW: We can't switch off CRT1 on LVDS/Chrontel * in 8bpp Modes */ - if ((xgi_video_info.hasVB == HASVB_LVDS) || - (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL)) { + if ((xgifb_info->hasVB == HASVB_LVDS) || + (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) { doit = 0; } /* TW: We can't switch off CRT1 on 301B-DH * in 8bpp Modes if using LCD */ - if (xgi_video_info.disp_state & DISPTYPE_LCD) + if (xgifb_info->disp_state & DISPTYPE_LCD) doit = 0; } /* TW: We can't switch off CRT1 if bridge is in slave mode */ - if (xgi_video_info.hasVB != HASVB_NONE) { + if (xgifb_info->hasVB != HASVB_NONE) { reg = xgifb_reg_get(XGIPART1, 0x00); if ((reg & 0x50) == 0x10) @@ -937,27 +939,27 @@ static void XGIfb_post_setmode(void) xgifb_reg_and(XGISR, IND_XGI_RAMDAC_CONTROL, ~0x04); - if ((xgi_video_info.disp_state & DISPTYPE_TV) && (xgi_video_info.hasVB + if ((xgifb_info->disp_state & DISPTYPE_TV) && (xgifb_info->hasVB == HASVB_301)) { reg = xgifb_reg_get(XGIPART4, 0x01); if (reg < 0xB0) { /* Set filter for XGI301 */ - switch (xgi_video_info.video_width) { + switch (xgifb_info->video_width) { case 320: - filter_tb = (xgi_video_info.TV_type == + filter_tb = (xgifb_info->TV_type == TVMODE_NTSC) ? 4 : 12; break; case 640: - filter_tb = (xgi_video_info.TV_type == + filter_tb = (xgifb_info->TV_type == TVMODE_NTSC) ? 5 : 13; break; case 720: - filter_tb = (xgi_video_info.TV_type == + filter_tb = (xgifb_info->TV_type == TVMODE_NTSC) ? 6 : 14; break; case 800: - filter_tb = (xgi_video_info.TV_type == + filter_tb = (xgifb_info->TV_type == TVMODE_NTSC) ? 7 : 15; break; default: @@ -966,20 +968,20 @@ static void XGIfb_post_setmode(void) } xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01); - if (xgi_video_info.TV_type == TVMODE_NTSC) { + if (xgifb_info->TV_type == TVMODE_NTSC) { xgifb_reg_and(XGIPART2, 0x3a, 0x1f); - if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) { + if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { xgifb_reg_and(XGIPART2, 0x30, 0xdf); - } else if (xgi_video_info.TV_plug + } else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE) { xgifb_reg_or(XGIPART2, 0x30, 0x20); - switch (xgi_video_info.video_width) { + switch (xgifb_info->video_width) { case 640: xgifb_reg_set(XGIPART2, 0x35, @@ -1025,20 +1027,20 @@ static void XGIfb_post_setmode(void) } } - } else if (xgi_video_info.TV_type == TVMODE_PAL) { + } else if (xgifb_info->TV_type == TVMODE_PAL) { xgifb_reg_and(XGIPART2, 0x3A, 0x1F); - if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) { + if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { xgifb_reg_and(XGIPART2, 0x30, 0xDF); - } else if (xgi_video_info.TV_plug + } else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE) { xgifb_reg_or(XGIPART2, 0x30, 0x20); - switch (xgi_video_info.video_width) { + switch (xgifb_info->video_width) { case 640: xgifb_reg_set(XGIPART2, 0x35, @@ -1125,7 +1127,8 @@ static void XGIfb_post_setmode(void) static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *info) { - struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; + struct xgifb_video_info *xgifb_info = info->par; + struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; unsigned int htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len; unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin @@ -1163,17 +1166,17 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, if (var->pixclock && htotal && vtotal) { drate = 1000000000 / var->pixclock; hrate = (drate * 1000) / htotal; - xgi_video_info.refresh_rate = (unsigned int) (hrate * 2 + xgifb_info->refresh_rate = (unsigned int) (hrate * 2 / vtotal); } else { - xgi_video_info.refresh_rate = 60; + xgifb_info->refresh_rate = 60; } printk(KERN_DEBUG "XGIfb: Change mode to %dx%dx%d-%dHz\n", var->xres, var->yres, var->bits_per_pixel, - xgi_video_info.refresh_rate); + xgifb_info->refresh_rate); old_mode = xgifb_mode_idx; xgifb_mode_idx = 0; @@ -1193,7 +1196,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, } if (found_mode) - xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); + xgifb_mode_idx = XGIfb_validate_mode(xgifb_info, + xgifb_mode_idx); else xgifb_mode_idx = -1; @@ -1204,14 +1208,15 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, return -EINVAL; } - if (XGIfb_search_refresh_rate(xgi_video_info.refresh_rate) == 0) { + if (XGIfb_search_refresh_rate(xgifb_info, + xgifb_info->refresh_rate) == 0) { XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; - xgi_video_info.refresh_rate = 60; + xgifb_info->refresh_rate = 60; } if (isactive) { - XGIfb_pre_setmode(); + XGIfb_pre_setmode(xgifb_info); if (XGISetModeNew(hw_info, XGIfb_mode_no) == 0) { printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", XGIfb_mode_no); @@ -1227,65 +1232,66 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, 0x0E, (info->fix.line_length & 0xff00) >> 8); - XGIfb_post_setmode(); + XGIfb_post_setmode(xgifb_info); DPRINTK("XGIfb: Set new mode: %dx%dx%d-%d\n", XGIbios_mode[xgifb_mode_idx].xres, XGIbios_mode[xgifb_mode_idx].yres, XGIbios_mode[xgifb_mode_idx].bpp, - xgi_video_info.refresh_rate); + xgifb_info->refresh_rate); - xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; - xgi_video_info.video_vwidth = info->var.xres_virtual; - xgi_video_info.video_width = XGIbios_mode[xgifb_mode_idx].xres; - xgi_video_info.video_vheight = info->var.yres_virtual; - xgi_video_info.video_height = XGIbios_mode[xgifb_mode_idx].yres; - xgi_video_info.org_x = xgi_video_info.org_y = 0; - xgi_video_info.video_linelength = info->var.xres_virtual - * (xgi_video_info.video_bpp >> 3); - switch (xgi_video_info.video_bpp) { + xgifb_info->video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; + xgifb_info->video_vwidth = info->var.xres_virtual; + xgifb_info->video_width = XGIbios_mode[xgifb_mode_idx].xres; + xgifb_info->video_vheight = info->var.yres_virtual; + xgifb_info->video_height = XGIbios_mode[xgifb_mode_idx].yres; + xgifb_info->org_x = xgifb_info->org_y = 0; + xgifb_info->video_linelength = info->var.xres_virtual + * (xgifb_info->video_bpp >> 3); + switch (xgifb_info->video_bpp) { case 8: - xgi_video_info.DstColor = 0x0000; - xgi_video_info.XGI310_AccelDepth = 0x00000000; - xgi_video_info.video_cmap_len = 256; + xgifb_info->DstColor = 0x0000; + xgifb_info->XGI310_AccelDepth = 0x00000000; + xgifb_info->video_cmap_len = 256; #if defined(__powerpc__) cr_data = xgifb_reg_get(XGICR, 0x4D); xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0)); #endif break; case 16: - xgi_video_info.DstColor = 0x8000; - xgi_video_info.XGI310_AccelDepth = 0x00010000; + xgifb_info->DstColor = 0x8000; + xgifb_info->XGI310_AccelDepth = 0x00010000; #if defined(__powerpc__) cr_data = xgifb_reg_get(XGICR, 0x4D); xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B)); #endif - xgi_video_info.video_cmap_len = 16; + xgifb_info->video_cmap_len = 16; break; case 32: - xgi_video_info.DstColor = 0xC000; - xgi_video_info.XGI310_AccelDepth = 0x00020000; - xgi_video_info.video_cmap_len = 16; + xgifb_info->DstColor = 0xC000; + xgifb_info->XGI310_AccelDepth = 0x00020000; + xgifb_info->video_cmap_len = 16; #if defined(__powerpc__) cr_data = xgifb_reg_get(XGICR, 0x4D); xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15)); #endif break; default: - xgi_video_info.video_cmap_len = 16; + xgifb_info->video_cmap_len = 16; printk(KERN_ERR "XGIfb: Unsupported depth %d", - xgi_video_info.video_bpp); + xgifb_info->video_bpp); break; } } - XGIfb_bpp_to_var(var); /*update ARGB info*/ + XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/ DEBUGPRN("End of do_set_var"); dumpVGAReg(); return 0; } -static int XGIfb_pan_var(struct fb_var_screeninfo *var) +static int XGIfb_pan_var(struct xgifb_video_info *xgifb_info, + struct fb_var_screeninfo *var) { unsigned int base; @@ -1324,7 +1330,7 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var) xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03); xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); - if (xgi_video_info.disp_state & DISPTYPE_DISP2) { + if (xgifb_info->disp_state & DISPTYPE_DISP2) { xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01); xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); @@ -1369,6 +1375,8 @@ static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var) static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { + struct xgifb_video_info *xgifb_info = info->par; + if (regno >= XGIfb_get_cmap_len(&info->var)) return 1; @@ -1378,7 +1386,7 @@ static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, outb((red >> 10), XGIDACD); outb((green >> 10), XGIDACD); outb((blue >> 10), XGIDACD); - if (xgi_video_info.disp_state & DISPTYPE_DISP2) { + if (xgifb_info->disp_state & DISPTYPE_DISP2) { outb(regno, XGIDAC2A); outb((red >> 8), XGIDAC2D); outb((green >> 8), XGIDAC2D); @@ -1406,16 +1414,18 @@ static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) { + struct xgifb_video_info *xgifb_info = info->par; + DEBUGPRN("inside get_fix"); memset(fix, 0, sizeof(struct fb_fix_screeninfo)); - fix->smem_start = xgi_video_info.video_base; + fix->smem_start = xgifb_info->video_base; - fix->smem_len = xgi_video_info.video_size; + fix->smem_len = xgifb_info->video_size; fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; - if (xgi_video_info.video_bpp == 8) + if (xgifb_info->video_bpp == 8) fix->visual = FB_VISUAL_PSEUDOCOLOR; else fix->visual = FB_VISUAL_DIRECTCOLOR; @@ -1423,9 +1433,9 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, if (XGIfb_ypan) fix->ypanstep = 1; fix->ywrapstep = 0; - fix->line_length = xgi_video_info.video_linelength; - fix->mmio_start = xgi_video_info.mmio_base; - fix->mmio_len = xgi_video_info.mmio_size; + fix->line_length = xgifb_info->video_linelength; + fix->mmio_start = xgifb_info->mmio_base; + fix->mmio_len = xgifb_info->mmio_size; fix->accel = FB_ACCEL_XGI_XABRE; DEBUGPRN("end of get_fix"); @@ -1447,6 +1457,7 @@ static int XGIfb_set_par(struct fb_info *info) static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { + struct xgifb_video_info *xgifb_info = info->par; unsigned int htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len; unsigned int vtotal = 0; @@ -1477,15 +1488,15 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) if (var->pixclock && htotal && vtotal) { drate = 1000000000 / var->pixclock; hrate = (drate * 1000) / htotal; - xgi_video_info.refresh_rate = + xgifb_info->refresh_rate = (unsigned int) (hrate * 2 / vtotal); printk(KERN_DEBUG "%s: pixclock = %d ,htotal=%d, vtotal=%d\n" "%s: drate=%d, hrate=%d, refresh_rate=%d\n", __func__, var->pixclock, htotal, vtotal, - __func__, drate, hrate, xgi_video_info.refresh_rate); + __func__, drate, hrate, xgifb_info->refresh_rate); } else { - xgi_video_info.refresh_rate = 60; + xgifb_info->refresh_rate = 60; } /* @@ -1507,7 +1518,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) if ((XGIbios_mode[search_idx].xres == var->xres) && (XGIbios_mode[search_idx].yres == var->yres) && (XGIbios_mode[search_idx].bpp == var->bits_per_pixel)) { - if (XGIfb_validate_mode(search_idx) > 0) { + if (XGIfb_validate_mode(xgifb_info, search_idx) > 0) { found_mode = 1; break; } @@ -1525,7 +1536,8 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) (var->yres <= XGIbios_mode[search_idx].yres) && (var->bits_per_pixel == XGIbios_mode[search_idx].bpp)) { - if (XGIfb_validate_mode(search_idx) > 0) { + if (XGIfb_validate_mode(xgifb_info, + search_idx) > 0) { found_mode = 1; break; } @@ -1548,7 +1560,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) /* TW: TODO: Check the refresh rate */ /* Adapt RGB settings */ - XGIfb_bpp_to_var(var); + XGIfb_bpp_to_var(xgifb_info, var); /* Sanity check for offsets */ if (var->xoffset < 0) @@ -1564,7 +1576,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) } /* else { */ /* TW: Now patch yres_virtual if we use panning */ /* May I do this? */ - /* var->yres_virtual = xgi_video_info.heapstart / + /* var->yres_virtual = xgifb_info->heapstart / (var->xres * (var->bits_per_pixel >> 3)); */ /* if (var->yres_virtual <= var->yres) { */ /* TW: Paranoia check */ @@ -1593,6 +1605,7 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { int err; + struct xgifb_video_info *xgifb_info = info->par; /* printk("\nInside pan_display:\n"); */ @@ -1611,7 +1624,7 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, > info->var.yres_virtual) return -EINVAL; } - err = XGIfb_pan_var(var); + err = XGIfb_pan_var(xgifb_info, var); if (err < 0) return err; @@ -1662,51 +1675,51 @@ static struct fb_ops XGIfb_ops = { /* for XGI 315/550/650/740/330 */ -static int XGIfb_get_dram_size(void) +static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info) { u8 ChannelNum, tmp; u8 reg = 0; /* xorg driver sets 32MB * 1 channel */ - if (xgi_video_info.chip == XG27) + if (xgifb_info->chip == XG27) xgifb_reg_set(XGISR, IND_XGI_DRAM_SIZE, 0x51); reg = xgifb_reg_get(XGISR, IND_XGI_DRAM_SIZE); switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) { case XGI_DRAM_SIZE_1MB: - xgi_video_info.video_size = 0x100000; + xgifb_info->video_size = 0x100000; break; case XGI_DRAM_SIZE_2MB: - xgi_video_info.video_size = 0x200000; + xgifb_info->video_size = 0x200000; break; case XGI_DRAM_SIZE_4MB: - xgi_video_info.video_size = 0x400000; + xgifb_info->video_size = 0x400000; break; case XGI_DRAM_SIZE_8MB: - xgi_video_info.video_size = 0x800000; + xgifb_info->video_size = 0x800000; break; case XGI_DRAM_SIZE_16MB: - xgi_video_info.video_size = 0x1000000; + xgifb_info->video_size = 0x1000000; break; case XGI_DRAM_SIZE_32MB: - xgi_video_info.video_size = 0x2000000; + xgifb_info->video_size = 0x2000000; break; case XGI_DRAM_SIZE_64MB: - xgi_video_info.video_size = 0x4000000; + xgifb_info->video_size = 0x4000000; break; case XGI_DRAM_SIZE_128MB: - xgi_video_info.video_size = 0x8000000; + xgifb_info->video_size = 0x8000000; break; case XGI_DRAM_SIZE_256MB: - xgi_video_info.video_size = 0x10000000; + xgifb_info->video_size = 0x10000000; break; default: return -1; } tmp = (reg & 0x0c) >> 2; - switch (xgi_video_info.chip) { + switch (xgifb_info->chip) { case XG20: case XG21: case XG27: @@ -1742,25 +1755,25 @@ static int XGIfb_get_dram_size(void) break; } - xgi_video_info.video_size = xgi_video_info.video_size * ChannelNum; + xgifb_info->video_size = xgifb_info->video_size * ChannelNum; /* PLiad fixed for benchmarking and fb set */ - /* xgi_video_info.video_size = 0x200000; */ /* 1024x768x16 */ - /* xgi_video_info.video_size = 0x1000000; */ /* benchmark */ + /* xgifb_info->video_size = 0x200000; */ /* 1024x768x16 */ + /* xgifb_info->video_size = 0x1000000; */ /* benchmark */ printk("XGIfb: SR14=%x DramSzie %x ChannelNum %x\n", reg, - xgi_video_info.video_size, ChannelNum); + xgifb_info->video_size, ChannelNum); return 0; } -static void XGIfb_detect_VB(void) +static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) { u8 cr32, temp = 0; - xgi_video_info.TV_plug = xgi_video_info.TV_type = 0; + xgifb_info->TV_plug = xgifb_info->TV_type = 0; - switch (xgi_video_info.hasVB) { + switch (xgifb_info->hasVB) { case HASVB_LVDS_CHRONTEL: case HASVB_CHRONTEL: break; @@ -1783,35 +1796,35 @@ static void XGIfb_detect_VB(void) if (XGIfb_crt2type != -1) /* TW: Override with option */ - xgi_video_info.disp_state = XGIfb_crt2type; + xgifb_info->disp_state = XGIfb_crt2type; else if (cr32 & XGI_VB_TV) - xgi_video_info.disp_state = DISPTYPE_TV; + xgifb_info->disp_state = DISPTYPE_TV; else if (cr32 & XGI_VB_LCD) - xgi_video_info.disp_state = DISPTYPE_LCD; + xgifb_info->disp_state = DISPTYPE_LCD; else if (cr32 & XGI_VB_CRT2) - xgi_video_info.disp_state = DISPTYPE_CRT2; + xgifb_info->disp_state = DISPTYPE_CRT2; else - xgi_video_info.disp_state = 0; + xgifb_info->disp_state = 0; if (XGIfb_tvplug != -1) /* PR/TW: Override with option */ - xgi_video_info.TV_plug = XGIfb_tvplug; + xgifb_info->TV_plug = XGIfb_tvplug; else if (cr32 & XGI_VB_HIVISION) { - xgi_video_info.TV_type = TVMODE_HIVISION; - xgi_video_info.TV_plug = TVPLUG_SVIDEO; + xgifb_info->TV_type = TVMODE_HIVISION; + xgifb_info->TV_plug = TVPLUG_SVIDEO; } else if (cr32 & XGI_VB_SVIDEO) - xgi_video_info.TV_plug = TVPLUG_SVIDEO; + xgifb_info->TV_plug = TVPLUG_SVIDEO; else if (cr32 & XGI_VB_COMPOSITE) - xgi_video_info.TV_plug = TVPLUG_COMPOSITE; + xgifb_info->TV_plug = TVPLUG_COMPOSITE; else if (cr32 & XGI_VB_SCART) - xgi_video_info.TV_plug = TVPLUG_SCART; + xgifb_info->TV_plug = TVPLUG_SCART; - if (xgi_video_info.TV_type == 0) { + if (xgifb_info->TV_type == 0) { temp = xgifb_reg_get(XGICR, 0x38); if (temp & 0x10) - xgi_video_info.TV_type = TVMODE_PAL; + xgifb_info->TV_type = TVMODE_PAL; else - xgi_video_info.TV_type = TVMODE_NTSC; + xgifb_info->TV_type = TVMODE_NTSC; } /* TW: Copy forceCRT1 option to CRT1off if option is given */ @@ -1823,37 +1836,37 @@ static void XGIfb_detect_VB(void) } } -static int XGIfb_has_VB(void) +static int XGIfb_has_VB(struct xgifb_video_info *xgifb_info) { u8 vb_chipid; vb_chipid = xgifb_reg_get(XGIPART4, 0x00); switch (vb_chipid) { case 0x01: - xgi_video_info.hasVB = HASVB_301; + xgifb_info->hasVB = HASVB_301; break; case 0x02: - xgi_video_info.hasVB = HASVB_302; + xgifb_info->hasVB = HASVB_302; break; default: - xgi_video_info.hasVB = HASVB_NONE; + xgifb_info->hasVB = HASVB_NONE; return 0; } return 1; } -static void XGIfb_get_VB_type(void) +static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info) { u8 reg; - if (!XGIfb_has_VB()) { + if (!XGIfb_has_VB(xgifb_info)) { reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37); switch ((reg & XGI_EXTERNAL_CHIP_MASK) >> 1) { case XGI310_EXTERNAL_CHIP_LVDS: - xgi_video_info.hasVB = HASVB_LVDS; + xgifb_info->hasVB = HASVB_LVDS; break; case XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL: - xgi_video_info.hasVB = HASVB_LVDS_CHRONTEL; + xgifb_info->hasVB = HASVB_LVDS_CHRONTEL; break; default: break; @@ -1951,31 +1964,32 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, int ret; bool xgi21_drvlcdcaplist = false; struct fb_info *fb_info; - struct xgi_hw_device_info *hw_info = &xgi_video_info.hw_info; + struct xgifb_video_info *xgifb_info = &xgi_video_info; + struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; memset(hw_info, 0, sizeof(struct xgi_hw_device_info)); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); if (!fb_info) return -ENOMEM; - xgi_video_info.fb_info = fb_info; - xgi_video_info.chip_id = pdev->device; + xgifb_info->fb_info = fb_info; + xgifb_info->chip_id = pdev->device; pci_read_config_byte(pdev, PCI_REVISION_ID, - &xgi_video_info.revision_id); - hw_info->jChipRevision = xgi_video_info.revision_id; + &xgifb_info->revision_id); + hw_info->jChipRevision = xgifb_info->revision_id; - xgi_video_info.pcibus = pdev->bus->number; - xgi_video_info.pcislot = PCI_SLOT(pdev->devfn); - xgi_video_info.pcifunc = PCI_FUNC(pdev->devfn); - xgi_video_info.subsysvendor = pdev->subsystem_vendor; - xgi_video_info.subsysdevice = pdev->subsystem_device; + xgifb_info->pcibus = pdev->bus->number; + xgifb_info->pcislot = PCI_SLOT(pdev->devfn); + xgifb_info->pcifunc = PCI_FUNC(pdev->devfn); + xgifb_info->subsysvendor = pdev->subsystem_vendor; + xgifb_info->subsysdevice = pdev->subsystem_device; - xgi_video_info.video_base = pci_resource_start(pdev, 0); - xgi_video_info.mmio_base = pci_resource_start(pdev, 1); - xgi_video_info.mmio_size = pci_resource_len(pdev, 1); - xgi_video_info.vga_base = pci_resource_start(pdev, 2) + 0x30; - hw_info->pjIOAddress = (unsigned char *)xgi_video_info.vga_base; + xgifb_info->video_base = pci_resource_start(pdev, 0); + xgifb_info->mmio_base = pci_resource_start(pdev, 1); + xgifb_info->mmio_size = pci_resource_len(pdev, 1); + xgifb_info->vga_base = pci_resource_start(pdev, 2) + 0x30; + hw_info->pjIOAddress = (unsigned char *)xgifb_info->vga_base; /* XGI_Pr.RelIO = ioremap(pci_resource_start(pdev, 2), 128) + 0x30; */ printk("XGIfb: Relocate IO address: %lx [%08lx]\n", (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO); @@ -1996,30 +2010,30 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error; } - switch (xgi_video_info.chip_id) { + switch (xgifb_info->chip_id) { case PCI_DEVICE_ID_XG_20: xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN); CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1); if (CR48&GPIOG_READ) - xgi_video_info.chip = XG21; + xgifb_info->chip = XG21; else - xgi_video_info.chip = XG20; + xgifb_info->chip = XG20; XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_40: - xgi_video_info.chip = XG40; + xgifb_info->chip = XG40; XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_41: - xgi_video_info.chip = XG41; + xgifb_info->chip = XG41; XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_42: - xgi_video_info.chip = XG42; + xgifb_info->chip = XG42; XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_27: - xgi_video_info.chip = XG27; + xgifb_info->chip = XG27; XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; default: @@ -2027,10 +2041,10 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, goto error; } - printk("XGIfb:chipid = %x\n", xgi_video_info.chip); - hw_info->jChipType = xgi_video_info.chip; + printk("XGIfb:chipid = %x\n", xgifb_info->chip); + hw_info->jChipType = xgifb_info->chip; - if ((xgi_video_info.chip == XG21) || (XGIfb_userom)) { + if ((xgifb_info->chip == XG21) || (XGIfb_userom)) { hw_info->pjVirtualRomBase = xgifb_copy_rom(pdev); if (hw_info->pjVirtualRomBase) printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n", @@ -2042,7 +2056,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, printk(KERN_INFO "XGIfb: Video ROM usage disabled\n"); } - if (XGIfb_get_dram_size()) { + if (XGIfb_get_dram_size(xgifb_info)) { printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n"); ret = -ENODEV; goto error; @@ -2055,40 +2069,40 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, /* Enable 2D accelerator engine */ xgifb_reg_or(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D); - hw_info->ulVideoMemorySize = xgi_video_info.video_size; + hw_info->ulVideoMemorySize = xgifb_info->video_size; - if (!request_mem_region(xgi_video_info.video_base, - xgi_video_info.video_size, + if (!request_mem_region(xgifb_info->video_base, + xgifb_info->video_size, "XGIfb FB")) { printk("unable request memory size %x", - xgi_video_info.video_size); + xgifb_info->video_size); printk(KERN_ERR "XGIfb: Fatal error: Unable to reserve frame buffer memory\n"); printk(KERN_ERR "XGIfb: Is there another framebuffer driver active?\n"); ret = -ENODEV; goto error; } - if (!request_mem_region(xgi_video_info.mmio_base, - xgi_video_info.mmio_size, + if (!request_mem_region(xgifb_info->mmio_base, + xgifb_info->mmio_size, "XGIfb MMIO")) { printk(KERN_ERR "XGIfb: Fatal error: Unable to reserve MMIO region\n"); ret = -ENODEV; goto error_0; } - xgi_video_info.video_vbase = hw_info->pjVideoMemoryAddress = - ioremap(xgi_video_info.video_base, xgi_video_info.video_size); - xgi_video_info.mmio_vbase = ioremap(xgi_video_info.mmio_base, - xgi_video_info.mmio_size); + xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress = + ioremap(xgifb_info->video_base, xgifb_info->video_size); + xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, + xgifb_info->mmio_size); printk(KERN_INFO "XGIfb: Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n", - xgi_video_info.video_base, - xgi_video_info.video_vbase, - xgi_video_info.video_size / 1024); + xgifb_info->video_base, + xgifb_info->video_vbase, + xgifb_info->video_size / 1024); printk(KERN_INFO "XGIfb: MMIO at 0x%lx, mapped to 0x%p, size %ldk\n", - xgi_video_info.mmio_base, xgi_video_info.mmio_vbase, - xgi_video_info.mmio_size / 1024); + xgifb_info->mmio_base, xgifb_info->mmio_vbase, + xgifb_info->mmio_size / 1024); printk("XGIfb: XGIInitNew() ..."); pci_set_drvdata(pdev, &xgi_video_info); if (XGIInitNew(pdev)) @@ -2096,32 +2110,32 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, else printk("Fail\n"); - xgi_video_info.mtrr = (unsigned int) 0; + xgifb_info->mtrr = (unsigned int) 0; - xgi_video_info.hasVB = HASVB_NONE; - if ((xgi_video_info.chip == XG20) || - (xgi_video_info.chip == XG27)) { - xgi_video_info.hasVB = HASVB_NONE; - } else if (xgi_video_info.chip == XG21) { + xgifb_info->hasVB = HASVB_NONE; + if ((xgifb_info->chip == XG20) || + (xgifb_info->chip == XG27)) { + xgifb_info->hasVB = HASVB_NONE; + } else if (xgifb_info->chip == XG21) { CR38 = xgifb_reg_get(XGICR, 0x38); if ((CR38&0xE0) == 0xC0) { - xgi_video_info.disp_state = DISPTYPE_LCD; - if (!XGIfb_GetXG21LVDSData()) + xgifb_info->disp_state = DISPTYPE_LCD; + if (!XGIfb_GetXG21LVDSData(xgifb_info)) xgi21_drvlcdcaplist = true; } else if ((CR38&0xE0) == 0x60) { - xgi_video_info.hasVB = HASVB_CHRONTEL; + xgifb_info->hasVB = HASVB_CHRONTEL; } else { - xgi_video_info.hasVB = HASVB_NONE; + xgifb_info->hasVB = HASVB_NONE; } } else { - XGIfb_get_VB_type(); + XGIfb_get_VB_type(xgifb_info); } hw_info->ujVBChipID = VB_CHIP_UNKNOWN; hw_info->ulExternalChip = 0; - switch (xgi_video_info.hasVB) { + switch (xgifb_info->hasVB) { case HASVB_301: reg = xgifb_reg_get(XGIPART4, 0x01); if (reg >= 0xE0) { @@ -2180,21 +2194,21 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, break; } - if (xgi_video_info.hasVB != HASVB_NONE) - XGIfb_detect_VB(); + if (xgifb_info->hasVB != HASVB_NONE) + XGIfb_detect_VB(xgifb_info); - if (xgi_video_info.disp_state & DISPTYPE_DISP2) { + if (xgifb_info->disp_state & DISPTYPE_DISP2) { if (XGIfb_crt1off) - xgi_video_info.disp_state |= DISPMODE_SINGLE; + xgifb_info->disp_state |= DISPMODE_SINGLE; else - xgi_video_info.disp_state |= (DISPMODE_MIRROR | + xgifb_info->disp_state |= (DISPMODE_MIRROR | DISPTYPE_CRT1); } else { - xgi_video_info.disp_state = DISPMODE_SINGLE | + xgifb_info->disp_state = DISPMODE_SINGLE | DISPTYPE_CRT1; } - if (xgi_video_info.disp_state & DISPTYPE_LCD) { + if (xgifb_info->disp_state & DISPTYPE_LCD) { if (!enable_dstn) { reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); reg &= 0x0f; @@ -2245,12 +2259,13 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_search_vesamode(vesa); if (xgifb_mode_idx >= 0) - xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx); + xgifb_mode_idx = XGIfb_validate_mode(xgifb_info, + xgifb_mode_idx); if (xgifb_mode_idx < 0) { - if ((xgi_video_info.disp_state & DISPTYPE_DISP2) == + if ((xgifb_info->disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD && - xgi_video_info.chip == XG21) + xgifb_info->chip == XG21) xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); else xgifb_mode_idx = DEFAULT_MODE; @@ -2277,64 +2292,64 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; /* yilin set default refresh rate */ - xgi_video_info.refresh_rate = refresh_rate; - if (xgi_video_info.refresh_rate == 0) - xgi_video_info.refresh_rate = 60; - if (XGIfb_search_refresh_rate( - xgi_video_info.refresh_rate) == 0) { + xgifb_info->refresh_rate = refresh_rate; + if (xgifb_info->refresh_rate == 0) + xgifb_info->refresh_rate = 60; + if (XGIfb_search_refresh_rate(xgifb_info, + xgifb_info->refresh_rate) == 0) { XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; - xgi_video_info.refresh_rate = 60; + xgifb_info->refresh_rate = 60; } - xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; - xgi_video_info.video_vwidth = - xgi_video_info.video_width = + xgifb_info->video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; + xgifb_info->video_vwidth = + xgifb_info->video_width = XGIbios_mode[xgifb_mode_idx].xres; - xgi_video_info.video_vheight = - xgi_video_info.video_height = + xgifb_info->video_vheight = + xgifb_info->video_height = XGIbios_mode[xgifb_mode_idx].yres; - xgi_video_info.org_x = xgi_video_info.org_y = 0; - xgi_video_info.video_linelength = - xgi_video_info.video_width * - (xgi_video_info.video_bpp >> 3); - switch (xgi_video_info.video_bpp) { + xgifb_info->org_x = xgifb_info->org_y = 0; + xgifb_info->video_linelength = + xgifb_info->video_width * + (xgifb_info->video_bpp >> 3); + switch (xgifb_info->video_bpp) { case 8: - xgi_video_info.DstColor = 0x0000; - xgi_video_info.XGI310_AccelDepth = 0x00000000; - xgi_video_info.video_cmap_len = 256; + xgifb_info->DstColor = 0x0000; + xgifb_info->XGI310_AccelDepth = 0x00000000; + xgifb_info->video_cmap_len = 256; break; case 16: - xgi_video_info.DstColor = 0x8000; - xgi_video_info.XGI310_AccelDepth = 0x00010000; - xgi_video_info.video_cmap_len = 16; + xgifb_info->DstColor = 0x8000; + xgifb_info->XGI310_AccelDepth = 0x00010000; + xgifb_info->video_cmap_len = 16; break; case 32: - xgi_video_info.DstColor = 0xC000; - xgi_video_info.XGI310_AccelDepth = 0x00020000; - xgi_video_info.video_cmap_len = 16; + xgifb_info->DstColor = 0xC000; + xgifb_info->XGI310_AccelDepth = 0x00020000; + xgifb_info->video_cmap_len = 16; break; default: - xgi_video_info.video_cmap_len = 16; + xgifb_info->video_cmap_len = 16; printk(KERN_INFO "XGIfb: Unsupported depth %d", - xgi_video_info.video_bpp); + xgifb_info->video_bpp); break; } printk(KERN_INFO "XGIfb: Default mode is %dx%dx%d (%dHz)\n", - xgi_video_info.video_width, - xgi_video_info.video_height, - xgi_video_info.video_bpp, - xgi_video_info.refresh_rate); + xgifb_info->video_width, + xgifb_info->video_height, + xgifb_info->video_bpp, + xgifb_info->refresh_rate); default_var.xres = default_var.xres_virtual = - xgi_video_info.video_width; + xgifb_info->video_width; default_var.yres = default_var.yres_virtual = - xgi_video_info.video_height; - default_var.bits_per_pixel = xgi_video_info.video_bpp; + xgifb_info->video_height; + default_var.bits_per_pixel = xgifb_info->video_bpp; - XGIfb_bpp_to_var(&default_var); + XGIfb_bpp_to_var(xgifb_info, &default_var); default_var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, @@ -2364,7 +2379,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, fb_info->var = default_var; fb_info->fix = XGIfb_fix; fb_info->par = &xgi_video_info; - fb_info->screen_base = xgi_video_info.video_vbase; + fb_info->screen_base = xgifb_info->video_vbase; fb_info->fbops = &XGIfb_ops; XGIfb_get_fix(&fb_info->fix, -1, fb_info); fb_info->pseudo_palette = pseudo_palette; @@ -2372,9 +2387,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, fb_alloc_cmap(&fb_info->cmap, 256 , 0); #ifdef CONFIG_MTRR - xgi_video_info.mtrr = mtrr_add(xgi_video_info.video_base, - xgi_video_info.video_size, MTRR_TYPE_WRCOMB, 1); - if (xgi_video_info.mtrr >= 0) + xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, + xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1); + if (xgifb_info->mtrr >= 0) dev_info(&pdev->dev, "added MTRR\n"); #endif @@ -2389,17 +2404,16 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, error_mtrr: #ifdef CONFIG_MTRR - if (xgi_video_info.mtrr >= 0) - mtrr_del(xgi_video_info.mtrr, xgi_video_info.video_base, - xgi_video_info.video_size); + if (xgifb_info->mtrr >= 0) + mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, + xgifb_info->video_size); #endif /* CONFIG_MTRR */ error_1: - iounmap(xgi_video_info.mmio_vbase); - iounmap(xgi_video_info.video_vbase); - release_mem_region(xgi_video_info.mmio_base, xgi_video_info.mmio_size); + iounmap(xgifb_info->mmio_vbase); + iounmap(xgifb_info->video_vbase); + release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); error_0: - release_mem_region(xgi_video_info.video_base, - xgi_video_info.video_size); + release_mem_region(xgifb_info->video_base, xgifb_info->video_size); error: vfree(hw_info->pjVirtualRomBase); framebuffer_release(fb_info); From fcbdda90ef9bedd521c56f0c7529013f03c139e0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:20 +0300 Subject: [PATCH 1420/1519] staging: xgifb: dynamically allocate xgifb_video_info Delete global xgi_video_info and dynamically allocate the data. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 15 ++++++--------- drivers/staging/xgifb/XGIfb.h | 3 --- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index bb53144e588..355a1780fe2 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -141,9 +141,6 @@ static inline void dumpVGAReg(void) } #endif -/* data for XGI components */ -struct xgifb_video_info xgi_video_info; - #if 1 #define DEBUGPRN(x) #else @@ -1964,14 +1961,15 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, int ret; bool xgi21_drvlcdcaplist = false; struct fb_info *fb_info; - struct xgifb_video_info *xgifb_info = &xgi_video_info; - struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; + struct xgifb_video_info *xgifb_info; + struct xgi_hw_device_info *hw_info; - memset(hw_info, 0, sizeof(struct xgi_hw_device_info)); - fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); + fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev); if (!fb_info) return -ENOMEM; + xgifb_info = fb_info->par; + hw_info = &xgifb_info->hw_info; xgifb_info->fb_info = fb_info; xgifb_info->chip_id = pdev->device; pci_read_config_byte(pdev, @@ -2104,7 +2102,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->mmio_base, xgifb_info->mmio_vbase, xgifb_info->mmio_size / 1024); printk("XGIfb: XGIInitNew() ..."); - pci_set_drvdata(pdev, &xgi_video_info); + pci_set_drvdata(pdev, xgifb_info); if (XGIInitNew(pdev)) printk("OK\n"); else @@ -2378,7 +2376,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, fb_info->flags = FBINFO_FLAG_DEFAULT; fb_info->var = default_var; fb_info->fix = XGIfb_fix; - fb_info->par = &xgi_video_info; fb_info->screen_base = xgifb_info->video_vbase; fb_info->fbops = &XGIfb_ops; XGIfb_get_fix(&fb_info->fix, -1, fb_info); diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 0beda426884..69112962108 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -101,7 +101,4 @@ struct xgifb_video_info { char reserved[236]; }; - -extern struct xgifb_video_info xgi_video_info; - #endif From 6928c18ee5978ed53ea7a70386b3754f8dd0a8b9 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:21 +0300 Subject: [PATCH 1421/1519] staging: xgifb: eliminate XGIfb_mode_no We can get the information from the table with mode index. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index d423823ca6c..ec288a41e21 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -354,7 +354,6 @@ static struct _XGIbios_mode { /* mode-related variables */ static int xgifb_mode_idx = -1; -static u8 XGIfb_mode_no; static u8 XGIfb_rate_idx; /* TW: CR36 evaluation */ diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 355a1780fe2..7bba394be5d 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -402,7 +402,6 @@ static int XGIfb_GetXG21DefaultLVDSModeIdx(void) && (XGIbios_mode[XGIfb_mode_idx].yres == XGI21_LCDCapList[0].LVDSVDE) && (XGIbios_mode[XGIfb_mode_idx].bpp == 8)) { - XGIfb_mode_no = XGIbios_mode[XGIfb_mode_idx].mode_no; found_mode = 1; break; } @@ -1185,7 +1184,6 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, == var->yres) && (XGIbios_mode[xgifb_mode_idx].bpp == var->bits_per_pixel)) { - XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; found_mode = 1; break; } @@ -1214,9 +1212,10 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, if (isactive) { XGIfb_pre_setmode(xgifb_info); - if (XGISetModeNew(hw_info, XGIfb_mode_no) == 0) { + if (XGISetModeNew(hw_info, + XGIbios_mode[xgifb_mode_idx].mode_no) == 0) { printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", - XGIfb_mode_no); + XGIbios_mode[xgifb_mode_idx].mode_no); return -EINVAL; } info->fix.line_length = ((info->var.xres_virtual @@ -2287,8 +2286,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } } - XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; - /* yilin set default refresh rate */ xgifb_info->refresh_rate = refresh_rate; if (xgifb_info->refresh_rate == 0) @@ -2351,10 +2348,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, default_var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, - XGIfb_mode_no, XGIfb_rate_idx)); + XGIbios_mode[xgifb_mode_idx].mode_no, + XGIfb_rate_idx)); if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, - XGIfb_mode_no, XGIfb_rate_idx, + XGIbios_mode[xgifb_mode_idx].mode_no, XGIfb_rate_idx, &default_var.left_margin, &default_var.right_margin, &default_var.upper_margin, &default_var.lower_margin, &default_var.hsync_len, &default_var.vsync_len, From ccf265ad5744263efba22b7c7a31f2dab198d653 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:22 +0300 Subject: [PATCH 1422/1519] staging: xgifb: move xgifb_mode_idx into xgifb_video_info The current mode index should be stored in the device-specific data allocated in probe(). Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 101 +++++++++++++++------------- drivers/staging/xgifb/XGIfb.h | 2 + 3 files changed, 56 insertions(+), 48 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index ec288a41e21..54597f52af2 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -353,7 +353,6 @@ static struct _XGIbios_mode { }; /* mode-related variables */ -static int xgifb_mode_idx = -1; static u8 XGIfb_rate_idx; /* TW: CR36 evaluation */ diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 7bba394be5d..893904d47fe 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -413,14 +413,15 @@ static int XGIfb_GetXG21DefaultLVDSModeIdx(void) return XGIfb_mode_idx; } -static void XGIfb_search_mode(const char *name) +static void XGIfb_search_mode(struct xgifb_video_info *xgifb_info, + const char *name) { int i = 0, j = 0, l; while (XGIbios_mode[i].mode_no != 0) { l = min(strlen(name), strlen(XGIbios_mode[i].name)); if (!strncmp(name, XGIbios_mode[i].name, l)) { - xgifb_mode_idx = i; + xgifb_info->mode_idx = i; j = 1; break; } @@ -430,7 +431,8 @@ static void XGIfb_search_mode(const char *name) printk(KERN_INFO "XGIfb: Invalid mode '%s'\n", name); } -static void XGIfb_search_vesamode(unsigned int vesamode) +static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info, + unsigned int vesamode) { int i = 0, j = 0; @@ -442,7 +444,7 @@ static void XGIfb_search_vesamode(unsigned int vesamode) while (XGIbios_mode[i].mode_no != 0) { if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) || (XGIbios_mode[i].vesa_mode_no_2 == vesamode)) { - xgifb_mode_idx = i; + xgifb_info->mode_idx = i; j = 1; break; } @@ -747,8 +749,8 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, u16 xres, yres; int i = 0; - xres = XGIbios_mode[xgifb_mode_idx].xres; - yres = XGIbios_mode[xgifb_mode_idx].yres; + xres = XGIbios_mode[xgifb_info->mode_idx].xres; + yres = XGIbios_mode[xgifb_info->mode_idx].yres; XGIfb_rate_idx = 0; while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) { @@ -1174,38 +1176,37 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, var->bits_per_pixel, xgifb_info->refresh_rate); - old_mode = xgifb_mode_idx; - xgifb_mode_idx = 0; + old_mode = xgifb_info->mode_idx; + xgifb_info->mode_idx = 0; - while ((XGIbios_mode[xgifb_mode_idx].mode_no != 0) - && (XGIbios_mode[xgifb_mode_idx].xres <= var->xres)) { - if ((XGIbios_mode[xgifb_mode_idx].xres == var->xres) - && (XGIbios_mode[xgifb_mode_idx].yres - == var->yres) - && (XGIbios_mode[xgifb_mode_idx].bpp + while ((XGIbios_mode[xgifb_info->mode_idx].mode_no != 0) && + (XGIbios_mode[xgifb_info->mode_idx].xres <= var->xres)) { + if ((XGIbios_mode[xgifb_info->mode_idx].xres == var->xres) && + (XGIbios_mode[xgifb_info->mode_idx].yres == var->yres) && + (XGIbios_mode[xgifb_info->mode_idx].bpp == var->bits_per_pixel)) { found_mode = 1; break; } - xgifb_mode_idx++; + xgifb_info->mode_idx++; } if (found_mode) - xgifb_mode_idx = XGIfb_validate_mode(xgifb_info, - xgifb_mode_idx); + xgifb_info->mode_idx = XGIfb_validate_mode(xgifb_info, + xgifb_info->mode_idx); else - xgifb_mode_idx = -1; + xgifb_info->mode_idx = -1; - if (xgifb_mode_idx < 0) { + if (xgifb_info->mode_idx < 0) { printk(KERN_ERR "XGIfb: Mode %dx%dx%d not supported\n", var->xres, var->yres, var->bits_per_pixel); - xgifb_mode_idx = old_mode; + xgifb_info->mode_idx = old_mode; return -EINVAL; } if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 0) { - XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; + XGIfb_rate_idx = XGIbios_mode[xgifb_info->mode_idx].rate_idx; xgifb_info->refresh_rate = 60; } @@ -1213,9 +1214,10 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, XGIfb_pre_setmode(xgifb_info); if (XGISetModeNew(hw_info, - XGIbios_mode[xgifb_mode_idx].mode_no) == 0) { + XGIbios_mode[xgifb_info->mode_idx].mode_no) + == 0) { printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", - XGIbios_mode[xgifb_mode_idx].mode_no); + XGIbios_mode[xgifb_info->mode_idx].mode_no); return -EINVAL; } info->fix.line_length = ((info->var.xres_virtual @@ -1231,16 +1233,18 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, XGIfb_post_setmode(xgifb_info); DPRINTK("XGIfb: Set new mode: %dx%dx%d-%d\n", - XGIbios_mode[xgifb_mode_idx].xres, - XGIbios_mode[xgifb_mode_idx].yres, - XGIbios_mode[xgifb_mode_idx].bpp, + XGIbios_mode[xgifb_info->mode_idx].xres, + XGIbios_mode[xgifb_info->mode_idx].yres, + XGIbios_mode[xgifb_info->mode_idx].bpp, xgifb_info->refresh_rate); - xgifb_info->video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; + xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp; xgifb_info->video_vwidth = info->var.xres_virtual; - xgifb_info->video_width = XGIbios_mode[xgifb_mode_idx].xres; + xgifb_info->video_width = + XGIbios_mode[xgifb_info->mode_idx].xres; xgifb_info->video_vheight = info->var.yres_virtual; - xgifb_info->video_height = XGIbios_mode[xgifb_mode_idx].yres; + xgifb_info->video_height = + XGIbios_mode[xgifb_info->mode_idx].yres; xgifb_info->org_x = xgifb_info->org_y = 0; xgifb_info->video_linelength = info->var.xres_virtual * (xgifb_info->video_bpp >> 3); @@ -2250,25 +2254,28 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } + xgifb_info->mode_idx = -1; + if (mode) - XGIfb_search_mode(mode); + XGIfb_search_mode(xgifb_info, mode); else if (vesa != -1) - XGIfb_search_vesamode(vesa); + XGIfb_search_vesamode(xgifb_info, vesa); - if (xgifb_mode_idx >= 0) - xgifb_mode_idx = XGIfb_validate_mode(xgifb_info, - xgifb_mode_idx); + if (xgifb_info->mode_idx >= 0) + xgifb_info->mode_idx = + XGIfb_validate_mode(xgifb_info, xgifb_info->mode_idx); - if (xgifb_mode_idx < 0) { + if (xgifb_info->mode_idx < 0) { if ((xgifb_info->disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD && xgifb_info->chip == XG21) - xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); + xgifb_info->mode_idx = + XGIfb_GetXG21DefaultLVDSModeIdx(); else - xgifb_mode_idx = DEFAULT_MODE; + xgifb_info->mode_idx = DEFAULT_MODE; } - if (xgifb_mode_idx < 0) { + if (xgifb_info->mode_idx < 0) { dev_err(&pdev->dev, "no supported video mode found\n"); goto error_1; } @@ -2278,9 +2285,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, for (m = 0; m < ARRAY_SIZE(XGI21_LCDCapList); m++) if ((XGI21_LCDCapList[m].LVDSHDE == - XGIbios_mode[xgifb_mode_idx].xres) && + XGIbios_mode[xgifb_info->mode_idx].xres) && (XGI21_LCDCapList[m].LVDSVDE == - XGIbios_mode[xgifb_mode_idx].yres)) { + XGIbios_mode[xgifb_info->mode_idx].yres)) { xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); break; } @@ -2292,17 +2299,17 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->refresh_rate = 60; if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 0) { - XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx; + XGIfb_rate_idx = XGIbios_mode[xgifb_info->mode_idx].rate_idx; xgifb_info->refresh_rate = 60; } - xgifb_info->video_bpp = XGIbios_mode[xgifb_mode_idx].bpp; + xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp; xgifb_info->video_vwidth = xgifb_info->video_width = - XGIbios_mode[xgifb_mode_idx].xres; + XGIbios_mode[xgifb_info->mode_idx].xres; xgifb_info->video_vheight = xgifb_info->video_height = - XGIbios_mode[xgifb_mode_idx].yres; + XGIbios_mode[xgifb_info->mode_idx].yres; xgifb_info->org_x = xgifb_info->org_y = 0; xgifb_info->video_linelength = xgifb_info->video_width * @@ -2348,11 +2355,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, default_var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, - XGIbios_mode[xgifb_mode_idx].mode_no, - XGIfb_rate_idx)); + XGIbios_mode[xgifb_info->mode_idx].mode_no, + XGIfb_rate_idx)); if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, - XGIbios_mode[xgifb_mode_idx].mode_no, XGIfb_rate_idx, + XGIbios_mode[xgifb_info->mode_idx].mode_no, XGIfb_rate_idx, &default_var.left_margin, &default_var.right_margin, &default_var.upper_margin, &default_var.lower_margin, &default_var.hsync_len, &default_var.vsync_len, diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 69112962108..e5a57e976be 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -58,6 +58,8 @@ struct xgifb_video_info { struct fb_info *fb_info; struct xgi_hw_device_info hw_info; + int mode_idx; + int chip_id; unsigned int video_size; unsigned long video_base; From 5aa55d9f97c63bbf53977e10154e2714e03586b2 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:23 +0300 Subject: [PATCH 1423/1519] staging: xgifb: move XGIfb_rate_idx into xgifb_video_info The current refresh rate index should be stored in the device-specific data allocated in probe(). Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 3 --- drivers/staging/xgifb/XGI_main_26.c | 30 +++++++++++++++++------------ drivers/staging/xgifb/XGIfb.h | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 54597f52af2..896cf142456 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -352,9 +352,6 @@ static struct _XGIbios_mode { {"\0", 0x00, 0, 0, 0, 0, 0, 0, 0} }; -/* mode-related variables */ -static u8 XGIfb_rate_idx; - /* TW: CR36 evaluation */ static const unsigned short XGI300paneltype[] = { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 893904d47fe..e89299c4ce6 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -752,18 +752,19 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, xres = XGIbios_mode[xgifb_info->mode_idx].xres; yres = XGIbios_mode[xgifb_info->mode_idx].yres; - XGIfb_rate_idx = 0; + xgifb_info->rate_idx = 0; while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) { if ((XGIfb_vrate[i].xres == xres) && (XGIfb_vrate[i].yres == yres)) { if (XGIfb_vrate[i].refresh == rate) { - XGIfb_rate_idx = XGIfb_vrate[i].idx; + xgifb_info->rate_idx = XGIfb_vrate[i].idx; break; } else if (XGIfb_vrate[i].refresh > rate) { if ((XGIfb_vrate[i].refresh - rate) <= 3) { DPRINTK("XGIfb: Adjusting rate from %d up to %d\n", rate, XGIfb_vrate[i].refresh); - XGIfb_rate_idx = XGIfb_vrate[i].idx; + xgifb_info->rate_idx = + XGIfb_vrate[i].idx; xgifb_info->refresh_rate = XGIfb_vrate[i].refresh; } else if (((rate - XGIfb_vrate[i - 1].refresh) @@ -771,7 +772,8 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, != 1)) { DPRINTK("XGIfb: Adjusting rate from %d down to %d\n", rate, XGIfb_vrate[i-1].refresh); - XGIfb_rate_idx = XGIfb_vrate[i - 1].idx; + xgifb_info->rate_idx = + XGIfb_vrate[i - 1].idx; xgifb_info->refresh_rate = XGIfb_vrate[i - 1].refresh; } @@ -779,14 +781,14 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, } else if ((rate - XGIfb_vrate[i].refresh) <= 2) { DPRINTK("XGIfb: Adjusting rate from %d down to %d\n", rate, XGIfb_vrate[i].refresh); - XGIfb_rate_idx = XGIfb_vrate[i].idx; + xgifb_info->rate_idx = XGIfb_vrate[i].idx; break; } } i++; } - if (XGIfb_rate_idx > 0) { - return XGIfb_rate_idx; + if (xgifb_info->rate_idx > 0) { + return xgifb_info->rate_idx; } else { printk(KERN_INFO "XGIfb: Unsupported rate %d for %dx%d\n", rate, xres, yres); @@ -891,7 +893,8 @@ static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30); xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31); - xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, (XGIfb_rate_idx & 0x0F)); + xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, + (xgifb_info->rate_idx & 0x0F)); } static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) @@ -1206,7 +1209,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 0) { - XGIfb_rate_idx = XGIbios_mode[xgifb_info->mode_idx].rate_idx; + xgifb_info->rate_idx = + XGIbios_mode[xgifb_info->mode_idx].rate_idx; xgifb_info->refresh_rate = 60; } @@ -2299,7 +2303,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->refresh_rate = 60; if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 0) { - XGIfb_rate_idx = XGIbios_mode[xgifb_info->mode_idx].rate_idx; + xgifb_info->rate_idx = + XGIbios_mode[xgifb_info->mode_idx].rate_idx; xgifb_info->refresh_rate = 60; } @@ -2356,10 +2361,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, default_var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, - XGIfb_rate_idx)); + xgifb_info->rate_idx)); if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, - XGIbios_mode[xgifb_info->mode_idx].mode_no, XGIfb_rate_idx, + XGIbios_mode[xgifb_info->mode_idx].mode_no, + xgifb_info->rate_idx, &default_var.left_margin, &default_var.right_margin, &default_var.upper_margin, &default_var.lower_margin, &default_var.hsync_len, &default_var.vsync_len, diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index e5a57e976be..46b696f24c2 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -59,6 +59,7 @@ struct xgifb_video_info { struct xgi_hw_device_info hw_info; int mode_idx; + int rate_idx; int chip_id; unsigned int video_size; From 76cabaa42800ac3dd3d64e60fa3a18c1dfcbf791 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:24 +0300 Subject: [PATCH 1424/1519] staging: xgifb: move pseudo_palette into xgifb_video_info pseudo_palette should be dynamically allocated for each fb. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 2 -- drivers/staging/xgifb/XGI_main_26.c | 2 +- drivers/staging/xgifb/XGIfb.h | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 896cf142456..e584f0b6543 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -160,8 +160,6 @@ static struct fb_fix_screeninfo XGIfb_fix = { .xpanstep = 1, .ypanstep = 1, }; -static u32 pseudo_palette[17]; - /* display status */ static int XGIfb_crt1off; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e89299c4ce6..45427d72027 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2390,7 +2390,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, fb_info->screen_base = xgifb_info->video_vbase; fb_info->fbops = &XGIfb_ops; XGIfb_get_fix(&fb_info->fix, -1, fb_info); - fb_info->pseudo_palette = pseudo_palette; + fb_info->pseudo_palette = xgifb_info->pseudo_palette; fb_alloc_cmap(&fb_info->cmap, 256 , 0); diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 46b696f24c2..efcfac86500 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -61,6 +61,8 @@ struct xgifb_video_info { int mode_idx; int rate_idx; + u32 pseudo_palette[17]; + int chip_id; unsigned int video_size; unsigned long video_base; From 39f10bf18c80c98d9fec376beabe80b9c59c7498 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:25 +0300 Subject: [PATCH 1425/1519] staging: xgifb: eliminate XGIfb_CRT2_write_enable variable Replace XGIfb_CRT2_write_enable with IND_XGI_CRT2_WRITE_ENABLE_315. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 3 --- drivers/staging/xgifb/XGI_main_26.c | 11 ++++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index e584f0b6543..7e5d029512d 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -171,9 +171,6 @@ static int XGIfb_tvmode; static int enable_dstn; static int XGIfb_ypan = -1; - -static int XGIfb_CRT2_write_enable; - /* TW: CRT2 type (for overriding autodetection) */ static int XGIfb_crt2type = -1; /* PR: Tv plug type (for overriding autodetection) */ diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 45427d72027..8c9c187e7e3 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -967,7 +967,9 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) filter = -1; break; } - xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01); + xgifb_reg_or(XGIPART1, + IND_XGI_CRT2_WRITE_ENABLE_315, + 0x01); if (xgifb_info->TV_type == TVMODE_NTSC) { @@ -1335,7 +1337,7 @@ static int XGIfb_pan_var(struct xgifb_video_info *xgifb_info, xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); if (xgifb_info->disp_state & DISPTYPE_DISP2) { - xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01); + xgifb_reg_or(XGIPART1, IND_XGI_CRT2_WRITE_ENABLE_315, 0x01); xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF)); @@ -2023,23 +2025,18 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->chip = XG21; else xgifb_info->chip = XG20; - XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_40: xgifb_info->chip = XG40; - XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_41: xgifb_info->chip = XG41; - XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_42: xgifb_info->chip = XG42; - XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; case PCI_DEVICE_ID_XG_27: xgifb_info->chip = XG27; - XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315; break; default: ret = -ENODEV; From e9865d47d44600b86e00a274adc8bf28e10677da Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:26 +0300 Subject: [PATCH 1426/1519] staging: xgifb: eliminate default_var Eliminate default_var and initialize needed fields of fb_info->var in probe(). Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 29 ----------------- drivers/staging/xgifb/XGI_main_26.c | 50 +++++++++++++++++------------ 2 files changed, 29 insertions(+), 50 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 7e5d029512d..0d439e90961 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -125,35 +125,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); /* ------------------- Global Variables ----------------------------- */ -static struct fb_var_screeninfo default_var = { - .xres = 0, - .yres = 0, - .xres_virtual = 0, - .yres_virtual = 0, - .xoffset = 0, - .yoffset = 0, - .bits_per_pixel = 0, - .grayscale = 0, - .red = {0, 8, 0}, - .green = {0, 8, 0}, - .blue = {0, 8, 0}, - .transp = {0, 0, 0}, - .nonstd = 0, - .activate = FB_ACTIVATE_NOW, - .height = -1, - .width = -1, - .accel_flags = 0, - .pixclock = 0, - .left_margin = 0, - .right_margin = 0, - .upper_margin = 0, - .lower_margin = 0, - .hsync_len = 0, - .vsync_len = 0, - .sync = 0, - .vmode = FB_VMODE_NONINTERLACED, -}; - static struct fb_fix_screeninfo XGIfb_fix = { .id = "XGI", .type = FB_TYPE_PACKED_PIXELS, diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 8c9c187e7e3..5eed802225a 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2345,17 +2345,22 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->video_bpp, xgifb_info->refresh_rate); - default_var.xres = - default_var.xres_virtual = - xgifb_info->video_width; - default_var.yres = - default_var.yres_virtual = - xgifb_info->video_height; - default_var.bits_per_pixel = xgifb_info->video_bpp; + fb_info->var.red.length = 8; + fb_info->var.green.length = 8; + fb_info->var.blue.length = 8; + fb_info->var.activate = FB_ACTIVATE_NOW; + fb_info->var.height = -1; + fb_info->var.width = -1; + fb_info->var.vmode = FB_VMODE_NONINTERLACED; + fb_info->var.xres = xgifb_info->video_width; + fb_info->var.xres_virtual = xgifb_info->video_width; + fb_info->var.yres = xgifb_info->video_height; + fb_info->var.yres_virtual = xgifb_info->video_height; + fb_info->var.bits_per_pixel = xgifb_info->video_bpp; - XGIfb_bpp_to_var(xgifb_info, &default_var); + XGIfb_bpp_to_var(xgifb_info, &fb_info->var); - default_var.pixclock = (u32) (1000000000 / + fb_info->var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, xgifb_info->rate_idx)); @@ -2363,26 +2368,29 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, xgifb_info->rate_idx, - &default_var.left_margin, &default_var.right_margin, - &default_var.upper_margin, &default_var.lower_margin, - &default_var.hsync_len, &default_var.vsync_len, - &default_var.sync, &default_var.vmode)) { + &fb_info->var.left_margin, + &fb_info->var.right_margin, + &fb_info->var.upper_margin, + &fb_info->var.lower_margin, + &fb_info->var.hsync_len, + &fb_info->var.vsync_len, + &fb_info->var.sync, + &fb_info->var.vmode)) { - if ((default_var.vmode & FB_VMODE_MASK) == + if ((fb_info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - default_var.yres <<= 1; - default_var.yres_virtual <<= 1; - } else if ((default_var.vmode & FB_VMODE_MASK) == + fb_info->var.yres <<= 1; + fb_info->var.yres_virtual <<= 1; + } else if ((fb_info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - default_var.pixclock >>= 1; - default_var.yres >>= 1; - default_var.yres_virtual >>= 1; + fb_info->var.pixclock >>= 1; + fb_info->var.yres >>= 1; + fb_info->var.yres_virtual >>= 1; } } fb_info->flags = FBINFO_FLAG_DEFAULT; - fb_info->var = default_var; fb_info->fix = XGIfb_fix; fb_info->screen_base = xgifb_info->video_vbase; fb_info->fbops = &XGIfb_ops; From c11d0ef3e250a4483e10e6984362b07fbf12c5ae Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:27 +0300 Subject: [PATCH 1427/1519] staging: xgifb: eliminate XGIfb_fix Eliminate XGIfb_fix and initialize needed fields of fb_info->fix in probe(). Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 7 ------- drivers/staging/xgifb/XGI_main_26.c | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 0d439e90961..1d0949c98c3 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -125,13 +125,6 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); /* ------------------- Global Variables ----------------------------- */ -static struct fb_fix_screeninfo XGIfb_fix = { - .id = "XGI", - .type = FB_TYPE_PACKED_PIXELS, - .xpanstep = 1, - .ypanstep = 1, -}; - /* display status */ static int XGIfb_crt1off; static int XGIfb_forcecrt1 = -1; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 5eed802225a..ba7f09630d2 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2390,8 +2390,12 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } + strncpy(fb_info->fix.id, "XGI", sizeof(fb_info->fix.id) - 1); + fb_info->fix.type = FB_TYPE_PACKED_PIXELS; + fb_info->fix.xpanstep = 1; + fb_info->fix.ypanstep = 1; + fb_info->flags = FBINFO_FLAG_DEFAULT; - fb_info->fix = XGIfb_fix; fb_info->screen_base = xgifb_info->video_vbase; fb_info->fbops = &XGIfb_ops; XGIfb_get_fix(&fb_info->fix, -1, fb_info); From 84a6c46eb2d4aac843d6946bf8319dfe78a35f96 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:28 +0300 Subject: [PATCH 1428/1519] staging: xgifb: eliminate filter_tb global variable filter_tb is only used inside a single function, and it does not need to be static. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 1 - drivers/staging/xgifb/XGI_main_26.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 1d0949c98c3..78f4c934b24 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -565,6 +565,5 @@ static const struct _XGI_TV_filter { }; static int filter = -1; -static unsigned char filter_tb; #endif diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index ba7f09630d2..bbbcdb7e50e 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -946,6 +946,8 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) reg = xgifb_reg_get(XGIPART4, 0x01); if (reg < 0xB0) { /* Set filter for XGI301 */ + int filter_tb; + switch (xgifb_info->video_width) { case 320: filter_tb = (xgifb_info->TV_type == @@ -964,6 +966,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) TVMODE_NTSC) ? 7 : 15; break; default: + filter_tb = 0; filter = -1; break; } From 7d2ab0c62dd3eb283853340e8aab095bdb6f6ac7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:29 +0300 Subject: [PATCH 1429/1519] staging: xgifb: make XGIbios_mode const Comments are wrong, the table is read-only and can be made const. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 78f4c934b24..6c1f5e0a1bf 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -150,8 +150,7 @@ static struct vb_device_info XGI_Pr; #define MD_XGI315 2 /* mode table */ -/* NOT const - will be patched for 1280x960 mode number chaos reasons */ -static struct _XGIbios_mode { +static const struct _XGIbios_mode { char name[15]; u8 mode_no; u16 vesa_mode_no_1; /* "XGI defined" VESA mode number */ @@ -261,7 +260,7 @@ static struct _XGIbios_mode { {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315}, {"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, - MD_XGI300|MD_XGI315}, /* TW: Modenumbers being patched */ + MD_XGI300|MD_XGI315}, {"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_XGI300|MD_XGI315}, {"1280x960x24", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, From f2df8c097a3cf0436c22358e11033c2d3b320aa4 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:30 +0300 Subject: [PATCH 1430/1519] staging: xgifb: eliminate global XGI_Pr data Move vb_device_info into xgifb_video_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 21 +++++++++------------ drivers/staging/xgifb/XGI_main_26.c | 15 ++++++++++----- drivers/staging/xgifb/XGIfb.h | 2 ++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 6c1f5e0a1bf..731262adee9 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -52,15 +52,15 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table); #define SEQ_DATA 0x15 -#define XGISR XGI_Pr.P3c4 -#define XGICR XGI_Pr.P3d4 -#define XGIDACA XGI_Pr.P3c8 -#define XGIDACD XGI_Pr.P3c9 -#define XGIPART1 XGI_Pr.Part1Port -#define XGIPART2 XGI_Pr.Part2Port -#define XGIPART3 XGI_Pr.Part3Port -#define XGIPART4 XGI_Pr.Part4Port -#define XGIPART5 XGI_Pr.Part5Port +#define XGISR (xgifb_info->dev_info.P3c4) +#define XGICR (xgifb_info->dev_info.P3d4) +#define XGIDACA (xgifb_info->dev_info.P3c8) +#define XGIDACD (xgifb_info->dev_info.P3c9) +#define XGIPART1 (xgifb_info->dev_info.Part1Port) +#define XGIPART2 (xgifb_info->dev_info.Part2Port) +#define XGIPART3 (xgifb_info->dev_info.Part3Port) +#define XGIPART4 (xgifb_info->dev_info.Part4Port) +#define XGIPART5 (xgifb_info->dev_info.Part5Port) #define XGIDAC2A XGIPART5 #define XGIDAC2D (XGIPART5 + 1) @@ -143,9 +143,6 @@ static int XGIfb_tvplug = -1; /* TW: For ioctl XGIFB_GET_INFO */ /* XGIfb_info XGIfbinfo; */ -/* TW: XGI private structure */ -static struct vb_device_info XGI_Pr; - #define MD_XGI300 1 #define MD_XGI315 2 diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index bbbcdb7e50e..dc6a9a8faf7 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1650,6 +1650,7 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, static int XGIfb_blank(int blank, struct fb_info *info) { + struct xgifb_video_info *xgifb_info = info->par; u8 reg; reg = xgifb_reg_get(XGICR, 0x17); @@ -2002,14 +2003,15 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, hw_info->pjIOAddress = (unsigned char *)xgifb_info->vga_base; /* XGI_Pr.RelIO = ioremap(pci_resource_start(pdev, 2), 128) + 0x30; */ printk("XGIfb: Relocate IO address: %lx [%08lx]\n", - (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO); + (unsigned long)pci_resource_start(pdev, 2), + xgifb_info->dev_info.RelIO); if (pci_enable_device(pdev)) { ret = -EIO; goto error; } - XGIRegInit(&XGI_Pr, (unsigned long)hw_info->pjIOAddress); + XGIRegInit(&xgifb_info->dev_info, (unsigned long)hw_info->pjIOAddress); xgifb_reg_set(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD); reg1 = xgifb_reg_get(XGISR, IND_XGI_PASSWORD); @@ -2292,7 +2294,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIbios_mode[xgifb_info->mode_idx].xres) && (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_info->mode_idx].yres)) { - xgifb_reg_set(XGI_Pr.P3d4, 0x36, m); + xgifb_reg_set(xgifb_info->dev_info.P3d4, + 0x36, + m); break; } } @@ -2364,11 +2368,12 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_bpp_to_var(xgifb_info, &fb_info->var); fb_info->var.pixclock = (u32) (1000000000 / - XGIfb_mode_rate_to_dclock(&XGI_Pr, hw_info, + XGIfb_mode_rate_to_dclock(&xgifb_info->dev_info, + hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, xgifb_info->rate_idx)); - if (XGIfb_mode_rate_to_ddata(&XGI_Pr, hw_info, + if (XGIfb_mode_rate_to_ddata(&xgifb_info->dev_info, hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, xgifb_info->rate_idx, &fb_info->var.left_margin, diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index efcfac86500..7d2b970991b 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -3,6 +3,7 @@ #include #include +#include "vb_struct.h" #include "vgatypes.h" #define DISPTYPE_CRT1 0x00000008L @@ -57,6 +58,7 @@ enum xgi_tv_plug { /* vicki@030226 */ struct xgifb_video_info { struct fb_info *fb_info; struct xgi_hw_device_info hw_info; + struct vb_device_info dev_info; int mode_idx; int rate_idx; From 2af1a29da78d8ba8076556e75a8e69f443ecf33d Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:31 +0300 Subject: [PATCH 1431/1519] staging: xgifb: move XGINew_RAMType into vb_device_info The RAM type is device specific, so move it into vb_device_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 128 +++++++++++++++++------------- drivers/staging/xgifb/vb_struct.h | 2 + 2 files changed, 73 insertions(+), 57 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index ac36191dbff..58b23303814 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -37,8 +37,6 @@ static unsigned short XGINew_DDRDRAM_TYPE20[12][5] = { { 2, 12, 9, 8, 0x35}, { 2, 12, 8, 4, 0x31} }; -static int XGINew_RAMType; - static unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) @@ -112,14 +110,18 @@ static void XGINew_DDR1x_MRS_340(unsigned long P3c4, } udelay(60); - xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ + xgifb_reg_set(P3c4, + 0x18, + pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ xgifb_reg_set(P3c4, 0x19, 0x01); xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[0]); xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[1]); mdelay(1); xgifb_reg_set(P3c4, 0x1B, 0x03); udelay(500); - xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ + xgifb_reg_set(P3c4, + 0x18, + pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ xgifb_reg_set(P3c4, 0x19, 0x00); xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[2]); xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[3]); @@ -132,23 +134,23 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x28, - pVBInfo->MCLKData[XGINew_RAMType].SR28); + pVBInfo->MCLKData[pVBInfo->ram_type].SR28); xgifb_reg_set(pVBInfo->P3c4, 0x29, - pVBInfo->MCLKData[XGINew_RAMType].SR29); + pVBInfo->MCLKData[pVBInfo->ram_type].SR29); xgifb_reg_set(pVBInfo->P3c4, 0x2A, - pVBInfo->MCLKData[XGINew_RAMType].SR2A); + pVBInfo->MCLKData[pVBInfo->ram_type].SR2A); xgifb_reg_set(pVBInfo->P3c4, 0x2E, - pVBInfo->ECLKData[XGINew_RAMType].SR2E); + pVBInfo->ECLKData[pVBInfo->ram_type].SR2E); xgifb_reg_set(pVBInfo->P3c4, 0x2F, - pVBInfo->ECLKData[XGINew_RAMType].SR2F); + pVBInfo->ECLKData[pVBInfo->ram_type].SR2F); xgifb_reg_set(pVBInfo->P3c4, 0x30, - pVBInfo->ECLKData[XGINew_RAMType].SR30); + pVBInfo->ECLKData[pVBInfo->ram_type].SR30); /* [Vicent] 2004/07/07, * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */ @@ -156,12 +158,12 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, * Set SR32 D[1:0] = 10b */ if (HwDeviceExtension->jChipType == XG42) { - if ((pVBInfo->MCLKData[XGINew_RAMType].SR28 == 0x1C) && - (pVBInfo->MCLKData[XGINew_RAMType].SR29 == 0x01) && - (((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x1C) && - (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01)) || - ((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x22) && - (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01)))) + if ((pVBInfo->MCLKData[pVBInfo->ram_type].SR28 == 0x1C) && + (pVBInfo->MCLKData[pVBInfo->ram_type].SR29 == 0x01) && + (((pVBInfo->ECLKData[pVBInfo->ram_type].SR2E == 0x1C) && + (pVBInfo->ECLKData[pVBInfo->ram_type].SR2F == 0x01)) || + ((pVBInfo->ECLKData[pVBInfo->ram_type].SR2E == 0x22) && + (pVBInfo->ECLKData[pVBInfo->ram_type].SR2F == 0x01)))) xgifb_reg_set(pVBInfo->P3c4, 0x32, ((unsigned char) xgifb_reg_get( @@ -174,8 +176,7 @@ static void XGINew_DDRII_Bootup_XG27( unsigned long P3c4, struct vb_device_info *pVBInfo) { unsigned long P3d4 = P3c4 + 0x10; - XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, - pVBInfo); + pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); /* Set Double Frequency */ @@ -250,8 +251,7 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension, { unsigned long P3d4 = P3c4 + 0x10; - XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, - pVBInfo); + pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); xgifb_reg_set(P3d4, 0x97, 0x11); /* CR97 */ @@ -307,7 +307,9 @@ static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4, xgifb_reg_set(P3c4, 0x16, 0x00); xgifb_reg_set(P3c4, 0x16, 0x80); udelay(60); - xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ + xgifb_reg_set(P3c4, + 0x18, + pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ /* xgifb_reg_set(P3c4, 0x18, 0x31); */ xgifb_reg_set(P3c4, 0x19, 0x01); xgifb_reg_set(P3c4, 0x16, 0x03); @@ -316,7 +318,9 @@ static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4, xgifb_reg_set(P3c4, 0x1B, 0x03); udelay(500); /* xgifb_reg_set(P3c4, 0x18, 0x31); */ - xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ + xgifb_reg_set(P3c4, + 0x18, + pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ xgifb_reg_set(P3c4, 0x19, 0x00); xgifb_reg_set(P3c4, 0x16, 0x03); xgifb_reg_set(P3c4, 0x16, 0x83); @@ -333,13 +337,13 @@ static void XGINew_DDR1x_DefaultRegister( XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); xgifb_reg_set(P3d4, 0x82, - pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */ + pVBInfo->CR40[11][pVBInfo->ram_type]); /* CR82 */ xgifb_reg_set(P3d4, 0x85, - pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */ + pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR85 */ xgifb_reg_set(P3d4, 0x86, - pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */ + pVBInfo->CR40[13][pVBInfo->ram_type]); /* CR86 */ xgifb_reg_set(P3d4, 0x98, 0x01); xgifb_reg_set(P3d4, 0x9A, 0x02); @@ -354,15 +358,15 @@ static void XGINew_DDR1x_DefaultRegister( /* CR82 */ xgifb_reg_set(P3d4, 0x82, - pVBInfo->CR40[11][XGINew_RAMType]); + pVBInfo->CR40[11][pVBInfo->ram_type]); /* CR85 */ xgifb_reg_set(P3d4, 0x85, - pVBInfo->CR40[12][XGINew_RAMType]); + pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR86 */ xgifb_reg_set(P3d4, 0x86, - pVBInfo->CR40[13][XGINew_RAMType]); + pVBInfo->CR40[13][pVBInfo->ram_type]); break; default: xgifb_reg_set(P3d4, 0x82, 0x88); @@ -373,7 +377,7 @@ static void XGINew_DDR1x_DefaultRegister( xgifb_reg_get(P3d4, 0x86); xgifb_reg_set(P3d4, 0x86, - pVBInfo->CR40[13][XGINew_RAMType]); + pVBInfo->CR40[13][pVBInfo->ram_type]); xgifb_reg_set(P3d4, 0x82, 0x77); xgifb_reg_set(P3d4, 0x85, 0x00); @@ -386,11 +390,11 @@ static void XGINew_DDR1x_DefaultRegister( /* CR85 */ xgifb_reg_set(P3d4, 0x85, - pVBInfo->CR40[12][XGINew_RAMType]); + pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR82 */ xgifb_reg_set(P3d4, 0x82, - pVBInfo->CR40[11][XGINew_RAMType]); + pVBInfo->CR40[11][pVBInfo->ram_type]); break; } @@ -415,16 +419,18 @@ static void XGINew_DDR2_DefaultRegister( xgifb_reg_set(P3d4, 0x86, 0x88); xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */ /* CR86 */ - xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]); + xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][pVBInfo->ram_type]); xgifb_reg_set(P3d4, 0x82, 0x77); xgifb_reg_set(P3d4, 0x85, 0x00); xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */ xgifb_reg_set(P3d4, 0x85, 0x88); xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */ - xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */ + xgifb_reg_set(P3d4, + 0x85, + pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR85 */ if (HwDeviceExtension->jChipType == XG27) /* CR82 */ - xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); + xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][pVBInfo->ram_type]); else xgifb_reg_set(P3d4, 0x82, 0xA8); /* CR82 */ @@ -444,15 +450,15 @@ static void XGINew_SetDRAMDefaultRegister340( unsigned long P3d4 = Port, P3c4 = Port - 0x10; - xgifb_reg_set(P3d4, 0x6D, pVBInfo->CR40[8][XGINew_RAMType]); - xgifb_reg_set(P3d4, 0x68, pVBInfo->CR40[5][XGINew_RAMType]); - xgifb_reg_set(P3d4, 0x69, pVBInfo->CR40[6][XGINew_RAMType]); - xgifb_reg_set(P3d4, 0x6A, pVBInfo->CR40[7][XGINew_RAMType]); + xgifb_reg_set(P3d4, 0x6D, pVBInfo->CR40[8][pVBInfo->ram_type]); + xgifb_reg_set(P3d4, 0x68, pVBInfo->CR40[5][pVBInfo->ram_type]); + xgifb_reg_set(P3d4, 0x69, pVBInfo->CR40[6][pVBInfo->ram_type]); + xgifb_reg_set(P3d4, 0x6A, pVBInfo->CR40[7][pVBInfo->ram_type]); temp2 = 0; for (i = 0; i < 4; i++) { /* CR6B DQS fine tune delay */ - temp = pVBInfo->CR6B[XGINew_RAMType][i]; + temp = pVBInfo->CR6B[pVBInfo->ram_type][i]; for (j = 0; j < 4; j++) { temp1 = ((temp >> (2 * j)) & 0x03) << 2; temp2 |= temp1; @@ -467,7 +473,7 @@ static void XGINew_SetDRAMDefaultRegister340( temp2 = 0; for (i = 0; i < 4; i++) { /* CR6E DQM fine tune delay */ - temp = pVBInfo->CR6E[XGINew_RAMType][i]; + temp = pVBInfo->CR6E[pVBInfo->ram_type][i]; for (j = 0; j < 4; j++) { temp1 = ((temp >> (2 * j)) & 0x03) << 2; temp2 |= temp1; @@ -486,7 +492,7 @@ static void XGINew_SetDRAMDefaultRegister340( temp2 = 0; for (i = 0; i < 8; i++) { /* CR6F DQ fine tune delay */ - temp = pVBInfo->CR6F[XGINew_RAMType][8 * k + i]; + temp = pVBInfo->CR6F[pVBInfo->ram_type][8 * k + i]; for (j = 0; j < 4; j++) { temp1 = (temp >> (2 * j)) & 0x03; temp2 |= temp1; @@ -500,12 +506,16 @@ static void XGINew_SetDRAMDefaultRegister340( temp3 += 0x01; } - xgifb_reg_set(P3d4, 0x80, pVBInfo->CR40[9][XGINew_RAMType]); /* CR80 */ - xgifb_reg_set(P3d4, 0x81, pVBInfo->CR40[10][XGINew_RAMType]); /* CR81 */ + xgifb_reg_set(P3d4, + 0x80, + pVBInfo->CR40[9][pVBInfo->ram_type]); /* CR80 */ + xgifb_reg_set(P3d4, + 0x81, + pVBInfo->CR40[10][pVBInfo->ram_type]); /* CR81 */ temp2 = 0x80; /* CR89 terminator type select */ - temp = pVBInfo->CR89[XGINew_RAMType][0]; + temp = pVBInfo->CR89[pVBInfo->ram_type][0]; for (j = 0; j < 4; j++) { temp1 = (temp >> (2 * j)) & 0x03; temp2 |= temp1; @@ -515,45 +525,49 @@ static void XGINew_SetDRAMDefaultRegister340( temp2 += 0x10; } - temp = pVBInfo->CR89[XGINew_RAMType][1]; + temp = pVBInfo->CR89[pVBInfo->ram_type][1]; temp1 = temp & 0x03; temp2 |= temp1; xgifb_reg_set(P3d4, 0x89, temp2); - temp = pVBInfo->CR40[3][XGINew_RAMType]; + temp = pVBInfo->CR40[3][pVBInfo->ram_type]; temp1 = temp & 0x0F; temp2 = (temp >> 4) & 0x07; temp3 = temp & 0x80; xgifb_reg_set(P3d4, 0x45, temp1); /* CR45 */ xgifb_reg_set(P3d4, 0x99, temp2); /* CR99 */ xgifb_reg_or(P3d4, 0x40, temp3); /* CR40_D[7] */ - xgifb_reg_set(P3d4, 0x41, pVBInfo->CR40[0][XGINew_RAMType]); /* CR41 */ + xgifb_reg_set(P3d4, + 0x41, + pVBInfo->CR40[0][pVBInfo->ram_type]); /* CR41 */ if (HwDeviceExtension->jChipType == XG27) xgifb_reg_set(P3d4, 0x8F, *pVBInfo->pCR8F); /* CR8F */ for (j = 0; j <= 6; j++) /* CR90 - CR96 */ xgifb_reg_set(P3d4, (0x90 + j), - pVBInfo->CR40[14 + j][XGINew_RAMType]); + pVBInfo->CR40[14 + j][pVBInfo->ram_type]); for (j = 0; j <= 2; j++) /* CRC3 - CRC5 */ xgifb_reg_set(P3d4, (0xC3 + j), - pVBInfo->CR40[21 + j][XGINew_RAMType]); + pVBInfo->CR40[21 + j][pVBInfo->ram_type]); for (j = 0; j < 2; j++) /* CR8A - CR8B */ xgifb_reg_set(P3d4, (0x8A + j), - pVBInfo->CR40[1 + j][XGINew_RAMType]); + pVBInfo->CR40[1 + j][pVBInfo->ram_type]); if ((HwDeviceExtension->jChipType == XG41) || (HwDeviceExtension->jChipType == XG42)) xgifb_reg_set(P3d4, 0x8C, 0x87); - xgifb_reg_set(P3d4, 0x59, pVBInfo->CR40[4][XGINew_RAMType]); /* CR59 */ + xgifb_reg_set(P3d4, + 0x59, + pVBInfo->CR40[4][pVBInfo->ram_type]); /* CR59 */ xgifb_reg_set(P3d4, 0x83, 0x09); /* CR83 */ xgifb_reg_set(P3d4, 0x87, 0x00); /* CR87 */ xgifb_reg_set(P3d4, 0xCF, *pVBInfo->pCRCF); /* CRCF */ - if (XGINew_RAMType) { + if (pVBInfo->ram_type) { /* xgifb_reg_set(P3c4, 0x17, 0xC0); */ /* SR17 DDRII */ xgifb_reg_set(P3c4, 0x17, 0x80); /* SR17 DDRII */ if (HwDeviceExtension->jChipType == XG27) @@ -571,7 +585,9 @@ static void XGINew_SetDRAMDefaultRegister340( xgifb_reg_set(P3d4, 0xB0, 0x80); /* DDRII Dual frequency mode */ XGINew_DDR2_DefaultRegister(HwDeviceExtension, P3d4, pVBInfo); } - xgifb_reg_set(P3c4, 0x1B, pVBInfo->SR15[3][XGINew_RAMType]); /* SR1B */ + xgifb_reg_set(P3c4, + 0x1B, + pVBInfo->SR15[3][pVBInfo->ram_type]); /* SR1B */ } static void XGINew_SetDRAMSizingType(int index, @@ -1552,8 +1568,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) /* 3.SetMemoryClock - XGINew_RAMType = (int)XGINew_GetXG20DRAMType(HwDeviceExtension, - pVBInfo); + pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); */ printk("11"); @@ -1754,8 +1769,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) } printk("19"); - XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, - pVBInfo); + pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); XGINew_SetDRAMDefaultRegister340(HwDeviceExtension, pVBInfo->P3d4, diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 860c98649bf..7b1edb92fa6 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -392,6 +392,8 @@ struct vb_device_info { struct XGI_StResInfoStruct *StResInfo; struct XGI_ModeResInfoStruct *ModeResInfo; struct XGI_XG21CRT1Struct *UpdateCRT1; + + int ram_type; }; /* _struct vb_device_info */ #endif /* _VB_STRUCT_ */ From ee055a48ce6272016cbb7e6f1a7de151bab7e1e0 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:32 +0300 Subject: [PATCH 1432/1519] staging: xgifb: move XGINew_ChannelAB into vb_device_info Move the memory channel info into vb_device_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 52 +++++++++++++++---------------- drivers/staging/xgifb/vb_struct.h | 1 + 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 58b23303814..036d1e41e0d 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -15,7 +15,7 @@ #include -static unsigned char XGINew_ChannelAB, XGINew_DataBusWidth; +static unsigned char XGINew_DataBusWidth; static unsigned short XGINew_DDRDRAM_TYPE340[4][5] = { { 2, 13, 9, 64, 0x45}, @@ -619,10 +619,10 @@ static unsigned short XGINew_SetDRAMSizeReg(int index, data = 0; - if (XGINew_ChannelAB == 3) + if (pVBInfo->ram_channel == 3) ChannelNo = 4; else - ChannelNo = XGINew_ChannelAB; + ChannelNo = pVBInfo->ram_channel; if (ChannelNo * RankSize <= 256) { while ((RankSize >>= 1) > 0) @@ -636,7 +636,7 @@ static unsigned short XGINew_SetDRAMSizeReg(int index, (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | (data & 0xF0)); - /* data |= XGINew_ChannelAB << 2; */ + /* data |= pVBInfo->ram_channel << 2; */ /* data |= (XGINew_DataBusWidth / 64) << 1; */ /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ @@ -663,10 +663,10 @@ static unsigned short XGINew_SetDRAMSize20Reg(int index, data = 0; - if (XGINew_ChannelAB == 3) + if (pVBInfo->ram_channel == 3) ChannelNo = 4; else - ChannelNo = XGINew_ChannelAB; + ChannelNo = pVBInfo->ram_channel; if (ChannelNo * RankSize <= 256) { while ((RankSize >>= 1) > 0) @@ -681,7 +681,7 @@ static unsigned short XGINew_SetDRAMSize20Reg(int index, (data & 0xF0)); udelay(15); - /* data |= XGINew_ChannelAB << 2; */ + /* data |= pVBInfo->ram_channel << 2; */ /* data |= (XGINew_DataBusWidth / 64) << 1; */ /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ @@ -746,7 +746,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, case XG21: data = xgifb_reg_get(pVBInfo->P3d4, 0x97); data = data & 0x01; - XGINew_ChannelAB = 1; /* XG20 "JUST" one channel */ + pVBInfo->ram_channel = 1; /* XG20 "JUST" one channel */ if (data == 0) { /* Single_32_16 */ @@ -851,20 +851,20 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, case XG27: XGINew_DataBusWidth = 16; /* 16 bits */ - XGINew_ChannelAB = 1; /* Single channel */ + pVBInfo->ram_channel = 1; /* Single channel */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x51); /* 32Mx16 bit*/ break; case XG41: if (XGINew_CheckFrequence(pVBInfo) == 1) { XGINew_DataBusWidth = 32; /* 32 bits */ - XGINew_ChannelAB = 3; /* Quad Channel */ + pVBInfo->ram_channel = 3; /* Quad Channel */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1) return; - XGINew_ChannelAB = 2; /* Dual channels */ + pVBInfo->ram_channel = 2; /* Dual channels */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48); if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) @@ -875,7 +875,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) return; - XGINew_ChannelAB = 3; + pVBInfo->ram_channel = 3; xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C); @@ -890,14 +890,14 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x39); } else { /* DDR */ XGINew_DataBusWidth = 64; /* 64 bits */ - XGINew_ChannelAB = 2; /* Dual channels */ + pVBInfo->ram_channel = 2; /* Dual channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); if (XGINew_ReadWriteRest(25, 24, pVBInfo) == 1) return; - XGINew_ChannelAB = 1; /* Single channels */ + pVBInfo->ram_channel = 1; /* Single channels */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) @@ -908,14 +908,14 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) return; - XGINew_ChannelAB = 2; /* Dual channels */ + pVBInfo->ram_channel = 2; /* Dual channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4A); if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) return; - XGINew_ChannelAB = 1; /* Single channels */ + pVBInfo->ram_channel = 1; /* Single channels */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42); if (XGINew_ReadWriteRest(8, 4, pVBInfo) == 1) @@ -936,7 +936,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, */ if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII, DDR2x */ XGINew_DataBusWidth = 32; /* 32 bits */ - XGINew_ChannelAB = 2; /* 2 Channel */ + pVBInfo->ram_channel = 2; /* 2 Channel */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x44); @@ -948,7 +948,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1) return; - XGINew_ChannelAB = 1; /* Single Channel */ + pVBInfo->ram_channel = 1; /* Single Channel */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x40); @@ -960,7 +960,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, } } else { /* DDR */ XGINew_DataBusWidth = 64; /* 64 bits */ - XGINew_ChannelAB = 1; /* 1 channels */ + pVBInfo->ram_channel = 1; /* 1 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); @@ -978,14 +978,14 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII */ XGINew_DataBusWidth = 32; /* 32 bits */ - XGINew_ChannelAB = 3; + pVBInfo->ram_channel = 3; xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1) return; - XGINew_ChannelAB = 2; /* 2 channels */ + pVBInfo->ram_channel = 2; /* 2 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48); if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) @@ -995,14 +995,14 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C); if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) { - XGINew_ChannelAB = 3; /* 4 channels */ + pVBInfo->ram_channel = 3; /* 4 channels */ } else { - XGINew_ChannelAB = 2; /* 2 channels */ + pVBInfo->ram_channel = 2; /* 2 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38); } } else { /* DDR */ XGINew_DataBusWidth = 64; /* 64 bits */ - XGINew_ChannelAB = 2; /* 2 channels */ + pVBInfo->ram_channel = 2; /* 2 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); @@ -1038,7 +1038,7 @@ static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension, if (memsize == 0) continue; - addr = memsize + (XGINew_ChannelAB - 2) + 20; + addr = memsize + (pVBInfo->ram_channel - 2) + 20; if ((HwDeviceExtension->ulVideoMemorySize - 1) < (unsigned long) (1 << addr)) continue; @@ -1058,7 +1058,7 @@ static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension, if (memsize == 0) continue; - addr = memsize + (XGINew_ChannelAB - 2) + 20; + addr = memsize + (pVBInfo->ram_channel - 2) + 20; if ((HwDeviceExtension->ulVideoMemorySize - 1) < (unsigned long) (1 << addr)) continue; diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index 7b1edb92fa6..c50eb7e8474 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -394,6 +394,7 @@ struct vb_device_info { struct XGI_XG21CRT1Struct *UpdateCRT1; int ram_type; + int ram_channel; }; /* _struct vb_device_info */ #endif /* _VB_STRUCT_ */ From 2f0f395ef788319b03bc0be785c5bee8d8bececa Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:33 +0300 Subject: [PATCH 1433/1519] staging: xgifb: move XGINew_DataBusWidth into vb_device_info Move the memory bus width info to vb_device_info. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 32 +++++++++++++++---------------- drivers/staging/xgifb/vb_struct.h | 1 + 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 036d1e41e0d..ce472dc417a 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -15,8 +15,6 @@ #include -static unsigned char XGINew_DataBusWidth; - static unsigned short XGINew_DDRDRAM_TYPE340[4][5] = { { 2, 13, 9, 64, 0x45}, { 2, 12, 9, 32, 0x35}, @@ -610,7 +608,7 @@ static unsigned short XGINew_SetDRAMSizeReg(int index, int RankSize; unsigned char ChannelNo; - RankSize = DRAMTYPE_TABLE[index][3] * XGINew_DataBusWidth / 32; + RankSize = DRAMTYPE_TABLE[index][3] * pVBInfo->ram_bus / 32; data = xgifb_reg_get(pVBInfo->P3c4, 0x13); data &= 0x80; @@ -637,7 +635,7 @@ static unsigned short XGINew_SetDRAMSizeReg(int index, (data & 0xF0)); /* data |= pVBInfo->ram_channel << 2; */ - /* data |= (XGINew_DataBusWidth / 64) << 1; */ + /* data |= (pVBInfo->ram_bus / 64) << 1; */ /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ /* should delay */ @@ -654,7 +652,7 @@ static unsigned short XGINew_SetDRAMSize20Reg(int index, int RankSize; unsigned char ChannelNo; - RankSize = DRAMTYPE_TABLE[index][3] * XGINew_DataBusWidth / 8; + RankSize = DRAMTYPE_TABLE[index][3] * pVBInfo->ram_bus / 8; data = xgifb_reg_get(pVBInfo->P3c4, 0x13); data &= 0x80; @@ -682,7 +680,7 @@ static unsigned short XGINew_SetDRAMSize20Reg(int index, udelay(15); /* data |= pVBInfo->ram_channel << 2; */ - /* data |= (XGINew_DataBusWidth / 64) << 1; */ + /* data |= (pVBInfo->ram_bus / 64) << 1; */ /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ /* should delay */ @@ -753,7 +751,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x1000000) { - XGINew_DataBusWidth = 32; /* 32 bits */ + pVBInfo->ram_bus = 32; /* 32 bits */ /* 22bit + 2 rank + 32bit */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); @@ -782,7 +780,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x800000) { - XGINew_DataBusWidth = 16; /* 16 bits */ + pVBInfo->ram_bus = 16; /* 16 bits */ /* 22bit + 2 rank + 16bit */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41); @@ -800,7 +798,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, } else { /* Dual_16_8 */ if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x800000) { - XGINew_DataBusWidth = 16; /* 16 bits */ + pVBInfo->ram_bus = 16; /* 16 bits */ /* (0x31:12x8x2) 22bit + 2 rank */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* 0x41:16Mx16 bit*/ @@ -831,7 +829,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x400000) { - XGINew_DataBusWidth = 8; /* 8 bits */ + pVBInfo->ram_bus = 8; /* 8 bits */ /* (0x31:12x8x2) 22bit + 2 rank */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* 0x30:8Mx8 bit*/ @@ -850,13 +848,13 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, break; case XG27: - XGINew_DataBusWidth = 16; /* 16 bits */ + pVBInfo->ram_bus = 16; /* 16 bits */ pVBInfo->ram_channel = 1; /* Single channel */ xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x51); /* 32Mx16 bit*/ break; case XG41: if (XGINew_CheckFrequence(pVBInfo) == 1) { - XGINew_DataBusWidth = 32; /* 32 bits */ + pVBInfo->ram_bus = 32; /* 32 bits */ pVBInfo->ram_channel = 3; /* Quad Channel */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); @@ -889,7 +887,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, else xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x39); } else { /* DDR */ - XGINew_DataBusWidth = 64; /* 64 bits */ + pVBInfo->ram_bus = 64; /* 64 bits */ pVBInfo->ram_channel = 2; /* Dual channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); @@ -935,7 +933,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, It's Different from Other XG40 Series. */ if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII, DDR2x */ - XGINew_DataBusWidth = 32; /* 32 bits */ + pVBInfo->ram_bus = 32; /* 32 bits */ pVBInfo->ram_channel = 2; /* 2 Channel */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x44); @@ -959,7 +957,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30); } } else { /* DDR */ - XGINew_DataBusWidth = 64; /* 64 bits */ + pVBInfo->ram_bus = 64; /* 64 bits */ pVBInfo->ram_channel = 1; /* 1 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); @@ -977,7 +975,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, default: /* XG40 */ if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII */ - XGINew_DataBusWidth = 32; /* 32 bits */ + pVBInfo->ram_bus = 32; /* 32 bits */ pVBInfo->ram_channel = 3; xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); @@ -1001,7 +999,7 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38); } } else { /* DDR */ - XGINew_DataBusWidth = 64; /* 64 bits */ + pVBInfo->ram_bus = 64; /* 64 bits */ pVBInfo->ram_channel = 2; /* 2 channels */ xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index c50eb7e8474..f9ade6f9f7e 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -395,6 +395,7 @@ struct vb_device_info { int ram_type; int ram_channel; + int ram_bus; }; /* _struct vb_device_info */ #endif /* _VB_STRUCT_ */ From 4397c7f03b52b3a26fd5e1ed934f0d1a66160b33 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:34 +0300 Subject: [PATCH 1434/1519] staging: xgifb: make RAM type tables const RAM type tables are read-only and can be made const. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index ce472dc417a..9e890a17fbc 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -15,13 +15,13 @@ #include -static unsigned short XGINew_DDRDRAM_TYPE340[4][5] = { +static const unsigned short XGINew_DDRDRAM_TYPE340[4][5] = { { 2, 13, 9, 64, 0x45}, { 2, 12, 9, 32, 0x35}, { 2, 12, 8, 16, 0x31}, { 2, 11, 8, 8, 0x21} }; -static unsigned short XGINew_DDRDRAM_TYPE20[12][5] = { +static const unsigned short XGINew_DDRDRAM_TYPE20[12][5] = { { 2, 14, 11, 128, 0x5D}, { 2, 14, 10, 64, 0x59}, { 2, 13, 11, 64, 0x4D}, @@ -589,7 +589,7 @@ static void XGINew_SetDRAMDefaultRegister340( } static void XGINew_SetDRAMSizingType(int index, - unsigned short DRAMTYPE_TABLE[][5], + const unsigned short DRAMTYPE_TABLE[][5], struct vb_device_info *pVBInfo) { unsigned short data; @@ -601,7 +601,7 @@ static void XGINew_SetDRAMSizingType(int index, } static unsigned short XGINew_SetDRAMSizeReg(int index, - unsigned short DRAMTYPE_TABLE[][5], + const unsigned short DRAMTYPE_TABLE[][5], struct vb_device_info *pVBInfo) { unsigned short data = 0, memsize = 0; @@ -645,7 +645,7 @@ static unsigned short XGINew_SetDRAMSizeReg(int index, } static unsigned short XGINew_SetDRAMSize20Reg(int index, - unsigned short DRAMTYPE_TABLE[][5], + const unsigned short DRAMTYPE_TABLE[][5], struct vb_device_info *pVBInfo) { unsigned short data = 0, memsize = 0; From 624554dae32ac1e0a2a2117224c778cf238ee233 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:35 +0300 Subject: [PATCH 1435/1519] staging: xgifb: make DAC tables const DAC tables are read-only and can be made const. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 8f3a8127d09..81c0cc41bb4 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -16,7 +16,7 @@ #define IndexMask 0xff -static unsigned short XGINew_MDA_DAC[] = { +static const unsigned short XGINew_MDA_DAC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, @@ -26,7 +26,7 @@ static unsigned short XGINew_MDA_DAC[] = { 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F}; -static unsigned short XGINew_CGA_DAC[] = { +static const unsigned short XGINew_CGA_DAC[] = { 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, @@ -36,7 +36,7 @@ static unsigned short XGINew_CGA_DAC[] = { 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; -static unsigned short XGINew_EGA_DAC[] = { +static const unsigned short XGINew_EGA_DAC[] = { 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, @@ -46,7 +46,7 @@ static unsigned short XGINew_EGA_DAC[] = { 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; -static unsigned short XGINew_VGA_DAC[] = { +static const unsigned short XGINew_VGA_DAC[] = { 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, @@ -1701,7 +1701,8 @@ static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, - ah, dh, *table = NULL; + ah, dh; + const unsigned short *table = NULL; if (ModeNo <= 0x13) data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; From 3261f2a1716993c5d88ab767d36a14bbc30d3717 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:36 +0300 Subject: [PATCH 1436/1519] staging: xgifb: delete CRT1 state The driver does not need to manage CRT1 state. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 11 ----------- drivers/staging/xgifb/XGIfb.h | 3 --- 2 files changed, 14 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index dc6a9a8faf7..03b6f78a667 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2204,17 +2204,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (xgifb_info->hasVB != HASVB_NONE) XGIfb_detect_VB(xgifb_info); - if (xgifb_info->disp_state & DISPTYPE_DISP2) { - if (XGIfb_crt1off) - xgifb_info->disp_state |= DISPMODE_SINGLE; - else - xgifb_info->disp_state |= (DISPMODE_MIRROR | - DISPTYPE_CRT1); - } else { - xgifb_info->disp_state = DISPMODE_SINGLE | - DISPTYPE_CRT1; - } - if (xgifb_info->disp_state & DISPTYPE_LCD) { if (!enable_dstn) { reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 7d2b970991b..2f62d19d0e9 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -6,13 +6,10 @@ #include "vb_struct.h" #include "vgatypes.h" -#define DISPTYPE_CRT1 0x00000008L #define DISPTYPE_CRT2 0x00000004L #define DISPTYPE_LCD 0x00000002L #define DISPTYPE_TV 0x00000001L #define DISPTYPE_DISP2 (DISPTYPE_CRT2 | DISPTYPE_LCD | DISPTYPE_TV) -#define DISPMODE_SINGLE 0x00000020L -#define DISPMODE_MIRROR 0x00000010L #define HASVB_NONE 0x00 #define HASVB_301 0x01 From 289ea5249c4615f21dc01e28aefce4c995f07402 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 11 Oct 2011 21:47:37 +0300 Subject: [PATCH 1437/1519] staging: xgifb: clean up 2nd display state Convert the display type to enum and rename disp_state to display2. Signed-off-by: Aaro Koskinen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 24 +++++++------- drivers/staging/xgifb/XGI_main_26.c | 50 ++++++++++++++--------------- drivers/staging/xgifb/XGIfb.h | 12 ++++--- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 731262adee9..71aebe3e84d 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -326,19 +326,19 @@ static const struct _XGI_crt2type { int tvplug_no; } XGI_crt2type[] = { {"NONE", 0, -1}, - {"LCD", DISPTYPE_LCD, -1}, - {"TV", DISPTYPE_TV, -1}, - {"VGA", DISPTYPE_CRT2, -1}, - {"SVIDEO", DISPTYPE_TV, TVPLUG_SVIDEO}, - {"COMPOSITE", DISPTYPE_TV, TVPLUG_COMPOSITE}, - {"SCART", DISPTYPE_TV, TVPLUG_SCART}, + {"LCD", XGIFB_DISP_LCD, -1}, + {"TV", XGIFB_DISP_TV, -1}, + {"VGA", XGIFB_DISP_CRT, -1}, + {"SVIDEO", XGIFB_DISP_TV, TVPLUG_SVIDEO}, + {"COMPOSITE", XGIFB_DISP_TV, TVPLUG_COMPOSITE}, + {"SCART", XGIFB_DISP_TV, TVPLUG_SCART}, {"none", 0, -1}, - {"lcd", DISPTYPE_LCD, -1}, - {"tv", DISPTYPE_TV, -1}, - {"vga", DISPTYPE_CRT2, -1}, - {"svideo", DISPTYPE_TV, TVPLUG_SVIDEO}, - {"composite", DISPTYPE_TV, TVPLUG_COMPOSITE}, - {"scart", DISPTYPE_TV, TVPLUG_SCART}, + {"lcd", XGIFB_DISP_LCD, -1}, + {"tv", XGIFB_DISP_TV, -1}, + {"vga", XGIFB_DISP_CRT, -1}, + {"svideo", XGIFB_DISP_TV, TVPLUG_SVIDEO}, + {"composite", XGIFB_DISP_TV, TVPLUG_COMPOSITE}, + {"scart", XGIFB_DISP_TV, TVPLUG_SCART}, {"\0", -1, -1} }; diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 03b6f78a667..36db231cd80 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -507,8 +507,7 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; if (xgifb_info->chip == XG21) { - if ((xgifb_info->disp_state & DISPTYPE_DISP2) - == DISPTYPE_LCD) { + if (xgifb_info->display2 == XGIFB_DISP_LCD) { xres = XGI21_LCDCapList[0].LVDSHDE; yres = XGI21_LCDCapList[0].LVDSVDE; if (XGIbios_mode[myindex].xres > xres) @@ -533,8 +532,8 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) if (!(XGIbios_mode[myindex].chipset & MD_XGI315)) return -1; - switch (xgifb_info->disp_state & DISPTYPE_DISP2) { - case DISPTYPE_LCD: + switch (xgifb_info->display2) { + case XGIFB_DISP_LCD: switch (hw_info->ulCRT2LCDType) { case LCD_640x480: xres = 640; @@ -685,7 +684,7 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) } } break; - case DISPTYPE_TV: + case XGIFB_DISP_TV: switch (XGIbios_mode[myindex].xres) { case 512: case 640: @@ -715,10 +714,12 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) return -1; } break; - case DISPTYPE_CRT2: + case XGIFB_DISP_CRT: if (XGIbios_mode[myindex].xres > 1280) return -1; break; + case XGIFB_DISP_NONE: + break; } return myindex; @@ -857,16 +858,16 @@ static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) cr31 = xgifb_reg_get(XGICR, 0x31); cr31 &= ~0x60; - switch (xgifb_info->disp_state & DISPTYPE_DISP2) { - case DISPTYPE_CRT2: + switch (xgifb_info->display2) { + case XGIFB_DISP_CRT: cr30 = (XGI_VB_OUTPUT_CRT2 | XGI_SIMULTANEOUS_VIEW_ENABLE); cr31 |= XGI_DRIVER_MODE; break; - case DISPTYPE_LCD: + case XGIFB_DISP_LCD: cr30 = (XGI_VB_OUTPUT_LCD | XGI_SIMULTANEOUS_VIEW_ENABLE); cr31 |= XGI_DRIVER_MODE; break; - case DISPTYPE_TV: + case XGIFB_DISP_TV: if (xgifb_info->TV_type == TVMODE_HIVISION) cr30 = (XGI_VB_OUTPUT_HIVISION | XGI_SIMULTANEOUS_VIEW_ENABLE); @@ -916,7 +917,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) } /* TW: We can't switch off CRT1 on 301B-DH * in 8bpp Modes if using LCD */ - if (xgifb_info->disp_state & DISPTYPE_LCD) + if (xgifb_info->display2 == XGIFB_DISP_LCD) doit = 0; } @@ -940,8 +941,8 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) xgifb_reg_and(XGISR, IND_XGI_RAMDAC_CONTROL, ~0x04); - if ((xgifb_info->disp_state & DISPTYPE_TV) && (xgifb_info->hasVB - == HASVB_301)) { + if (xgifb_info->display2 == XGIFB_DISP_TV && + xgifb_info->hasVB == HASVB_301) { reg = xgifb_reg_get(XGIPART4, 0x01); @@ -1339,7 +1340,7 @@ static int XGIfb_pan_var(struct xgifb_video_info *xgifb_info, xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03); xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); - if (xgifb_info->disp_state & DISPTYPE_DISP2) { + if (xgifb_info->display2 != XGIFB_DISP_NONE) { xgifb_reg_or(XGIPART1, IND_XGI_CRT2_WRITE_ENABLE_315, 0x01); xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); @@ -1395,7 +1396,7 @@ static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, outb((red >> 10), XGIDACD); outb((green >> 10), XGIDACD); outb((blue >> 10), XGIDACD); - if (xgifb_info->disp_state & DISPTYPE_DISP2) { + if (xgifb_info->display2 != XGIFB_DISP_NONE) { outb(regno, XGIDAC2A); outb((red >> 8), XGIDAC2D); outb((green >> 8), XGIDAC2D); @@ -1806,15 +1807,15 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) if (XGIfb_crt2type != -1) /* TW: Override with option */ - xgifb_info->disp_state = XGIfb_crt2type; + xgifb_info->display2 = XGIfb_crt2type; else if (cr32 & XGI_VB_TV) - xgifb_info->disp_state = DISPTYPE_TV; + xgifb_info->display2 = XGIFB_DISP_TV; else if (cr32 & XGI_VB_LCD) - xgifb_info->disp_state = DISPTYPE_LCD; + xgifb_info->display2 = XGIFB_DISP_LCD; else if (cr32 & XGI_VB_CRT2) - xgifb_info->disp_state = DISPTYPE_CRT2; + xgifb_info->display2 = XGIFB_DISP_CRT; else - xgifb_info->disp_state = 0; + xgifb_info->display2 = XGIFB_DISP_NONE; if (XGIfb_tvplug != -1) /* PR/TW: Override with option */ @@ -1932,7 +1933,7 @@ static int __init XGIfb_setup(char *options) } else if (!strncmp(this_opt, "dstn", 4)) { enable_dstn = 1; /* TW: DSTN overrules forcecrt2type */ - XGIfb_crt2type = DISPTYPE_LCD; + XGIfb_crt2type = XGIFB_DISP_LCD; } else if (!strncmp(this_opt, "noypan", 6)) { XGIfb_ypan = 0; } else if (!strncmp(this_opt, "userom:", 7)) { @@ -2126,7 +2127,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } else if (xgifb_info->chip == XG21) { CR38 = xgifb_reg_get(XGICR, 0x38); if ((CR38&0xE0) == 0xC0) { - xgifb_info->disp_state = DISPTYPE_LCD; + xgifb_info->display2 = XGIFB_DISP_LCD; if (!XGIfb_GetXG21LVDSData(xgifb_info)) xgi21_drvlcdcaplist = true; } else if ((CR38&0xE0) == 0x60) { @@ -2204,7 +2205,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (xgifb_info->hasVB != HASVB_NONE) XGIfb_detect_VB(xgifb_info); - if (xgifb_info->disp_state & DISPTYPE_LCD) { + if (xgifb_info->display2 == XGIFB_DISP_LCD) { if (!enable_dstn) { reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); reg &= 0x0f; @@ -2261,8 +2262,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, XGIfb_validate_mode(xgifb_info, xgifb_info->mode_idx); if (xgifb_info->mode_idx < 0) { - if ((xgifb_info->disp_state & DISPTYPE_DISP2) == - DISPTYPE_LCD && + if (xgifb_info->display2 == XGIFB_DISP_LCD && xgifb_info->chip == XG21) xgifb_info->mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx(); diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 2f62d19d0e9..7611846a703 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -6,10 +6,12 @@ #include "vb_struct.h" #include "vgatypes.h" -#define DISPTYPE_CRT2 0x00000004L -#define DISPTYPE_LCD 0x00000002L -#define DISPTYPE_TV 0x00000001L -#define DISPTYPE_DISP2 (DISPTYPE_CRT2 | DISPTYPE_LCD | DISPTYPE_TV) +enum xgifb_display_type { + XGIFB_DISP_NONE = 0, + XGIFB_DISP_CRT, + XGIFB_DISP_LCD, + XGIFB_DISP_TV, +}; #define HASVB_NONE 0x00 #define HASVB_301 0x01 @@ -83,7 +85,7 @@ struct xgifb_video_info { int video_linelength; unsigned int refresh_rate; - unsigned long disp_state; + enum xgifb_display_type display2; /* the second display output type */ unsigned char hasVB; unsigned char TV_type; unsigned char TV_plug; From 0bdd2b620794f4f8bddac620b774d7fbf879dcbc Mon Sep 17 00:00:00 2001 From: Nasir Abed Date: Mon, 10 Oct 2011 12:09:52 +0200 Subject: [PATCH 1438/1519] Staging: comedi: c6xdigio: fixed missing KERN_* in printk Fixed missing KERN_* in printk statements. Signed-off-by: Nasir Abed Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/c6xdigio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index e0ac825ea58..11cdaf2a5aa 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -343,7 +343,7 @@ static int c6xdigio_pwmo_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - printk("c6xdigio_pwmo_insn_read %x\n", insn->n); + printk(KERN_DEBUG "c6xdigio_pwmo_insn_read %x\n", insn->n); return insn->n; } @@ -439,9 +439,9 @@ static int c6xdigio_attach(struct comedi_device *dev, struct comedi_subdevice *s; iobase = it->options[0]; - printk("comedi%d: c6xdigio: 0x%04lx\n", dev->minor, iobase); + printk(KERN_DEBUG "comedi%d: c6xdigio: 0x%04lx\n", dev->minor, iobase); if (!request_region(iobase, C6XDIGIO_SIZE, "c6xdigio")) { - printk("comedi%d: I/O port conflict\n", dev->minor); + printk(KERN_ERR "comedi%d: I/O port conflict\n", dev->minor); return -EIO; } dev->iobase = iobase; @@ -456,9 +456,10 @@ static int c6xdigio_attach(struct comedi_device *dev, irq = it->options[1]; if (irq > 0) - printk("comedi%d: irq = %u ignored\n", dev->minor, irq); + printk(KERN_DEBUG "comedi%d: irq = %u ignored\n", + dev->minor, irq); else if (irq == 0) - printk("comedi%d: no irq\n", dev->minor); + printk(KERN_DEBUG "comedi%d: no irq\n", dev->minor); s = dev->subdevices + 0; /* pwm output subdevice */ @@ -503,7 +504,7 @@ static int c6xdigio_detach(struct comedi_device *dev) { /* board_halt(dev); may not need this */ - printk("comedi%d: c6xdigio: remove\n", dev->minor); + printk(KERN_DEBUG "comedi%d: c6xdigio: remove\n", dev->minor); if (dev->iobase) release_region(dev->iobase, C6XDIGIO_SIZE); From 963ff7740d52586a0fb79f459abebf39997d3ae6 Mon Sep 17 00:00:00 2001 From: Jake Burton Date: Mon, 10 Oct 2011 17:02:24 +0100 Subject: [PATCH 1439/1519] Staging: comedi: fix brace coding style issue in ni_atmio.c This is a patch to the ni_atmio.c file which fixes a brace and whitespace warning found by the checkpatch.pl tool Signed-off-by: Jake Burton Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 3330b3d53e8..647c228abfb 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -268,8 +268,9 @@ static const struct ni_board_struct ni_boards[] = { } }; -static const int ni_irqpin[] = - { -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 }; +static const int ni_irqpin[] = { + -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 +}; #define interrupt_pin(a) (ni_irqpin[(a)]) @@ -279,7 +280,10 @@ static const int ni_irqpin[] = struct ni_private { struct pnp_dev *isapnp_dev; - NI_PRIVATE_COMMON}; + NI_PRIVATE_COMMON + +}; + #define devpriv ((struct ni_private *)dev->private) /* How we access registers */ From b6fbd29c8b836246169296869c3103ccecc201ad Mon Sep 17 00:00:00 2001 From: wwang Date: Mon, 10 Oct 2011 14:47:08 +0800 Subject: [PATCH 1440/1519] staging:rts_pstor:Fix SDIO issue Fix a bug that SDIO and SD normal card would appear simultaneously if a SDIO card inserted. Signed-off-by: wwang Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/sd.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index fb62eafe4fc..aab690932ea 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c @@ -3134,41 +3134,40 @@ int reset_sd_card(struct rtsx_chip *chip) if (chip->sd_ctl & RESET_MMC_FIRST) { retval = reset_mmc(chip); - if ((retval != STATUS_SUCCESS) && !sd_check_err_code(chip, SD_NO_CARD)) { + if (retval != STATUS_SUCCESS) { + if (sd_check_err_code(chip, SD_NO_CARD)) + TRACE_RET(chip, STATUS_FAIL); + retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { - if (CHECK_PID(chip, 0x5209)) { - retval = sd_change_bank_voltage(chip, SD_IO_3V3); - if (retval != STATUS_SUCCESS) { - TRACE_RET(chip, STATUS_FAIL); - } - } + if (CHECK_PID(chip, 0x5209)) + sd_change_bank_voltage(chip, SD_IO_3V3); + + TRACE_RET(chip, STATUS_FAIL); } } } else { retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { - if (sd_check_err_code(chip, SD_NO_CARD)) { + if (sd_check_err_code(chip, SD_NO_CARD)) TRACE_RET(chip, STATUS_FAIL); - } if (CHECK_PID(chip, 0x5209)) { retval = sd_change_bank_voltage(chip, SD_IO_3V3); - if (retval != STATUS_SUCCESS) { + if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - } } - if (!chip->sd_io) { + if (chip->sd_io) { + TRACE_RET(chip, STATUS_FAIL); + } else { retval = reset_mmc(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); } } } - if (retval != STATUS_SUCCESS) { - TRACE_RET(chip, STATUS_FAIL); - } - retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0); if (retval != STATUS_SUCCESS) { TRACE_RET(chip, STATUS_FAIL); From 8122fa341d36ecacd2bc9e1b0f62594f8130b5ad Mon Sep 17 00:00:00 2001 From: Pelle Windestam Date: Mon, 10 Oct 2011 19:41:42 +0200 Subject: [PATCH 1441/1519] drivers: staging: rts_pstor fixed checkpatch warnings Fixed the checkpatch warnings in rtsx.c/.h, mostly braces and spaces before tabs issues. Also fixed warning about not using DEFINE_PCI_DEVICE_TABLE(...) macro. Signed-off-by: Pelle Windestam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/rtsx.c | 62 +++++++++++++++++--------------- drivers/staging/rts_pstor/rtsx.h | 10 +++--- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rts_pstor/rtsx.c b/drivers/staging/rts_pstor/rtsx.c index 16c73fbff51..480b0ed2e4d 100644 --- a/drivers/staging/rts_pstor/rtsx.c +++ b/drivers/staging/rts_pstor/rtsx.c @@ -36,7 +36,7 @@ #include "sd.h" #include "xd.h" -#define DRIVER_VERSION "v1.10" +#define DRIVER_VERSION "v1.10" MODULE_DESCRIPTION("Realtek PCI-Express card reader driver"); MODULE_LICENSE("GPL"); @@ -77,7 +77,7 @@ static const char *host_info(struct Scsi_Host *host) return "SCSI emulation for PCI-Express Mass Storage devices"; } -static int slave_alloc (struct scsi_device *sdev) +static int slave_alloc(struct scsi_device *sdev) { /* * Set the INQUIRY transfer length to 36. We don't use any of @@ -130,7 +130,7 @@ static int slave_configure(struct scsi_device *sdev) #define SPRINTF(args...) \ do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0) -static int proc_info (struct Scsi_Host *host, char *buffer, +static int proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) { char *pos = buffer; @@ -506,13 +506,15 @@ static int rtsx_control_thread(void *__dev) */ else if (chip->srb->device->id) { printk(KERN_ERR "Bad target number (%d:%d)\n", - chip->srb->device->id, chip->srb->device->lun); + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } else if (chip->srb->device->lun > chip->max_lun) { printk(KERN_ERR "Bad LUN (%d:%d)\n", - chip->srb->device->id, chip->srb->device->lun); + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } @@ -625,26 +627,23 @@ static irqreturn_t rtsx_interrupt(int irq, void *dev_id) int retval; u32 status; - if (dev) { + if (dev) chip = dev->chip; - } else { + else return IRQ_NONE; - } - if (!chip) { + if (!chip) return IRQ_NONE; - } spin_lock(&dev->reg_lock); retval = rtsx_pre_handle_interrupt(chip); if (retval == STATUS_FAIL) { spin_unlock(&dev->reg_lock); - if (chip->int_reg == 0xFFFFFFFF) { + if (chip->int_reg == 0xFFFFFFFF) return IRQ_HANDLED; - } else { + else return IRQ_NONE; - } } status = chip->int_reg; @@ -661,9 +660,8 @@ static irqreturn_t rtsx_interrupt(int irq, void *dev_id) if (status & (NEED_COMPLETE_INT | DELINK_INT)) { if (status & (TRANS_FAIL_INT | DELINK_INT)) { - if (status & DELINK_INT) { + if (status & DELINK_INT) RTSX_SET_DELINK(chip); - } dev->trans_result = TRANS_RESULT_FAIL; if (dev->done) complete(dev->done); @@ -844,7 +842,9 @@ static void rtsx_init_options(struct rtsx_chip *chip) chip->ssc_en = 1; chip->sd_speed_prior = 0x01040203; chip->sd_current_prior = 0x00010203; - chip->sd_ctl = SD_PUSH_POINT_AUTO | SD_SAMPLE_POINT_AUTO | SUPPORT_MMC_DDR_MODE; + chip->sd_ctl = SD_PUSH_POINT_AUTO | + SD_SAMPLE_POINT_AUTO | + SUPPORT_MMC_DDR_MODE; chip->sd_ddr_tx_phase = 0; chip->mmc_ddr_tx_phase = 1; chip->sd_default_tx_phase = 15; @@ -896,7 +896,8 @@ static void rtsx_init_options(struct rtsx_chip *chip) chip->s3_pwr_off_delay = 1000; } -static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +static int __devinit rtsx_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) { struct Scsi_Host *host; struct rtsx_dev *dev; @@ -913,7 +914,8 @@ static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id err = pci_request_regions(pci, CR_DRIVER_NAME); if (err < 0) { - printk(KERN_ERR "PCI request regions for %s failed!\n", CR_DRIVER_NAME); + printk(KERN_ERR "PCI request regions for %s failed!\n", + CR_DRIVER_NAME); pci_disable_device(pci); return err; } @@ -934,9 +936,8 @@ static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id memset(dev, 0, sizeof(struct rtsx_dev)); dev->chip = kzalloc(sizeof(struct rtsx_chip), GFP_KERNEL); - if (dev->chip == NULL) { + if (dev->chip == NULL) goto errout; - } spin_lock_init(&dev->reg_lock); mutex_init(&(dev->dev_mutex)); @@ -950,7 +951,8 @@ static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id dev->pci = pci; dev->irq = -1; - printk(KERN_INFO "Resource length: 0x%x\n", (unsigned int)pci_resource_len(pci, 0)); + printk(KERN_INFO "Resource length: 0x%x\n", + (unsigned int)pci_resource_len(pci, 0)); dev->addr = pci_resource_start(pci, 0); dev->remap_addr = ioremap_nocache(dev->addr, pci_resource_len(pci, 0)); if (dev->remap_addr == NULL) { @@ -959,9 +961,12 @@ static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id goto errout; } - /* Using "unsigned long" cast here to eliminate gcc warning in 64-bit system */ + /* + * Using "unsigned long" cast here to eliminate gcc warning in + * 64-bit system + */ printk(KERN_INFO "Original address: 0x%lx, remapped address: 0x%lx\n", - (unsigned long)(dev->addr), (unsigned long)(dev->remap_addr)); + (unsigned long)(dev->addr), (unsigned long)(dev->remap_addr)); dev->rtsx_resv_buf = dma_alloc_coherent(&(pci->dev), RTSX_RESV_BUF_LEN, &(dev->rtsx_resv_buf_addr), GFP_KERNEL); @@ -973,7 +978,8 @@ static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id dev->chip->host_cmds_ptr = dev->rtsx_resv_buf; dev->chip->host_cmds_addr = dev->rtsx_resv_buf_addr; dev->chip->host_sg_tbl_ptr = dev->rtsx_resv_buf + HOST_CMDS_BUF_LEN; - dev->chip->host_sg_tbl_addr = dev->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN; + dev->chip->host_sg_tbl_addr = dev->rtsx_resv_buf_addr + + HOST_CMDS_BUF_LEN; dev->chip->rtsx = dev; @@ -1058,10 +1064,10 @@ static void __devexit rtsx_remove(struct pci_dev *pci) } /* PCI IDs */ -static struct pci_device_id rtsx_ids[] = { - { 0x10EC, 0x5208, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_OTHERS << 16, 0xFF0000 }, - { 0x10EC, 0x5209, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_OTHERS << 16, 0xFF0000 }, - { 0x10EC, 0x5288, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_OTHERS << 16, 0xFF0000 }, +static DEFINE_PCI_DEVICE_TABLE(rtsx_ids) = { + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x5208), PCI_CLASS_OTHERS << 16, 0xFF0000 }, + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 }, + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x5288), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { 0, }, }; diff --git a/drivers/staging/rts_pstor/rtsx.h b/drivers/staging/rts_pstor/rtsx.h index 86e47c2e3e3..1ab42fcc47d 100644 --- a/drivers/staging/rts_pstor/rtsx.h +++ b/drivers/staging/rts_pstor/rtsx.h @@ -24,8 +24,8 @@ #ifndef __REALTEK_RTSX_H #define __REALTEK_RTSX_H -#include -#include +#include +#include #include #include #include @@ -80,7 +80,7 @@ #define wait_timeout_x(task_state, msecs) \ do { \ - set_current_state((task_state)); \ + set_current_state((task_state)); \ schedule_timeout((msecs) * HZ / 1000); \ } while (0) #define wait_timeout(msecs) wait_timeout_x(TASK_INTERRUPTIBLE, (msecs)) @@ -102,12 +102,12 @@ typedef unsigned long DELAY_PARA_T; struct rtsx_chip; struct rtsx_dev { - struct pci_dev *pci; + struct pci_dev *pci; /* pci resources */ unsigned long addr; void __iomem *remap_addr; - int irq; + int irq; /* locks */ spinlock_t reg_lock; From 1ca616711c830681faa04d5bbdaccc290a910110 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:31 +0100 Subject: [PATCH 1442/1519] staging: wlags49_h2: Handle sysfs_create_group return correctly The function returns 0 on success and non-zero on error. So correctly record the status so it is freed appropriately. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_internal.h | 2 +- drivers/staging/wlags49_h2/wl_sysfs.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_internal.h b/drivers/staging/wlags49_h2/wl_internal.h index 6351bb8b680..9ed28574e8a 100644 --- a/drivers/staging/wlags49_h2/wl_internal.h +++ b/drivers/staging/wlags49_h2/wl_internal.h @@ -883,7 +883,7 @@ struct wl_private int is_registered; int is_handling_int; int firmware_present; - char sysfsCreated; + bool sysfsCreated; CFG_DRV_INFO_STRCT driverInfo; CFG_IDENTITY_STRCT driverIdentity; CFG_FW_IDENTITY_STRCT StationIdentity; diff --git a/drivers/staging/wlags49_h2/wl_sysfs.c b/drivers/staging/wlags49_h2/wl_sysfs.c index 9b833b30ae6..1508f04b3c6 100644 --- a/drivers/staging/wlags49_h2/wl_sysfs.c +++ b/drivers/staging/wlags49_h2/wl_sysfs.c @@ -120,17 +120,19 @@ static struct attribute_group wlags_group = { void register_wlags_sysfs(struct net_device *net) { - struct device *dev = &(net->dev); - struct wl_private *lp = wl_priv(net); - - lp->sysfsCreated = sysfs_create_group(&dev->kobj, &wlags_group); + struct device *dev = &(net->dev); + struct wl_private *lp = wl_priv(net); + int err; + err = sysfs_create_group(&dev->kobj, &wlags_group); + if (!err) + lp->sysfsCreated = true; } void unregister_wlags_sysfs(struct net_device *net) { - struct device *dev = &(net->dev); - struct wl_private *lp = wl_priv(net); + struct device *dev = &(net->dev); + struct wl_private *lp = wl_priv(net); - if (lp->sysfsCreated) - sysfs_remove_group(&dev->kobj, &wlags_group); + if (lp->sysfsCreated) + sysfs_remove_group(&dev->kobj, &wlags_group); } From add54e5c8ac3a11b4fabe34fcea6c62d6b22a006 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:32 +0100 Subject: [PATCH 1443/1519] staging: wlags49_h2: Enable WPA in the HCF WPA has been disabled in the HCF layer. The firmware does support it (it is used on other platforms). Enable it so we can work through the issues. Note that we also enable this for the HERMES 2.5 non-WARP firmware cards. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/Makefile | 1 - drivers/staging/wlags49_h2/hcfcfg.h | 19 ++++++++++++++----- drivers/staging/wlags49_h25/Makefile | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wlags49_h2/Makefile b/drivers/staging/wlags49_h2/Makefile index e604ebd5aeb..c7220c61096 100644 --- a/drivers/staging/wlags49_h2/Makefile +++ b/drivers/staging/wlags49_h2/Makefile @@ -15,7 +15,6 @@ INSTALLDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless ccflags-y := -I$(KERNELDIR)/include ccflags-y += -I$(src) \ -DBUS_PCMCIA \ - -DUSE_WPA \ -DUSE_WEXT \ -DSTA_ONLY \ -DWVLAN_49 \ diff --git a/drivers/staging/wlags49_h2/hcfcfg.h b/drivers/staging/wlags49_h2/hcfcfg.h index 825550e1b9e..7545bc55411 100644 --- a/drivers/staging/wlags49_h2/hcfcfg.h +++ b/drivers/staging/wlags49_h2/hcfcfg.h @@ -316,16 +316,25 @@ typedef unsigned long hcf_32; //#define HCF_SLEEP (HCF_CDS | HCF_DDS ) #define HCF_SLEEP (HCF_CDS) -//#define HCF_TYPE (HCF_TYPE_HII5|HCF_TYPE_STA|HCF_TYPE_AP) +/* Note: Non-WARP firmware all support WPA. However the original Agere + * linux driver does not enable WPA. Enabling WPA here causes whatever + * preliminary WPA logic to be included, some of which may be specific + * to HERMESI. + * + * Various comment are clear that WARP and WPA are not compatible + * (which may just mean WARP does WPA in a different fashion). + */ + +/* #define HCF_TYPE (HCF_TYPE_HII5|HCF_TYPE_STA|HCF_TYPE_AP) */ #ifdef HERMES25 #ifdef WARP #define HCF_TYPE ( HCF_TYPE_WARP | HCF_TYPE_HII5 ) #else -#define HCF_TYPE HCF_TYPE_HII5 -#endif // WARP +#define HCF_TYPE (HCF_TYPE_HII5 | HCF_TYPE_WPA) +#endif /* WARP */ #else -#define HCF_TYPE HCF_TYPE_NONE -#endif // HERMES25 +#define HCF_TYPE HCF_TYPE_WPA +#endif /* HERMES25 */ #ifdef ENABLE_DMA #define HCF_DMA 1 diff --git a/drivers/staging/wlags49_h25/Makefile b/drivers/staging/wlags49_h25/Makefile index 7d4b5632c94..fe829299610 100644 --- a/drivers/staging/wlags49_h25/Makefile +++ b/drivers/staging/wlags49_h25/Makefile @@ -15,7 +15,6 @@ INSTALLDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless ccflags-y := -I$(KERNELDIR)/include ccflags-y += -I$(src) \ -DBUS_PCMCIA \ - -DUSE_WPA \ -DUSE_WEXT \ -DSTA_ONLY \ -DWVLAN_49 \ From 25b20463f30e98c7e939b706ba7696fcfb68d1fd Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:33 +0100 Subject: [PATCH 1444/1519] staging: wlags49_h2: Remove useless IWE_STREAM_ADD_XXX defines These macros don't map to anything different. Just remove them. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 33 ++++++++++++---------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 89563dadddc..c392fd82e98 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -75,15 +75,6 @@ #include #include - - -#define IWE_STREAM_ADD_EVENT(info, buf, end, iwe, len) \ - iwe_stream_add_event(info, buf, end, iwe, len) -#define IWE_STREAM_ADD_POINT(info, buf, end, iwe, msg) \ - iwe_stream_add_point(info, buf, end, iwe, msg) - - - /******************************************************************************* * global definitions ******************************************************************************/ @@ -2681,8 +2672,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf memcpy( iwe.u.ap_addr.sa_data, probe_resp->BSSID, ETH_ALEN); iwe.len = IW_EV_ADDR_LEN; - buf = IWE_STREAM_ADD_EVENT(info, buf, buf_end, &iwe, IW_EV_ADDR_LEN); - + buf = iwe_stream_add_event(info, buf, buf_end, + &iwe, IW_EV_ADDR_LEN); /* Use the mode to indicate if it's a station or AP */ /* Won't always be an AP if in IBSS mode */ @@ -2698,8 +2689,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf iwe.len = IW_EV_UINT_LEN; - buf = IWE_STREAM_ADD_EVENT(info, buf, buf_end, &iwe, IW_EV_UINT_LEN); - + buf = iwe_stream_add_event(info, buf, buf_end, + &iwe, IW_EV_UINT_LEN); /* Any quality information */ memset(&iwe, 0, sizeof(iwe)); @@ -2711,7 +2702,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf iwe.u.qual.updated = lp->probe_results.scan_complete | IW_QUAL_DBM; iwe.len = IW_EV_QUAL_LEN; - buf = IWE_STREAM_ADD_EVENT(info, buf, buf_end, &iwe, IW_EV_QUAL_LEN); + buf = iwe_stream_add_event(info, buf, buf_end, + &iwe, IW_EV_QUAL_LEN); /* ESSID information */ @@ -2722,7 +2714,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf iwe.u.data.length = probe_resp->rawData[1]; iwe.u.data.flags = 1; - buf = IWE_STREAM_ADD_POINT(info, buf, buf_end, &iwe, &probe_resp->rawData[2]); + buf = iwe_stream_add_point(info, buf, buf_end, + &iwe, &probe_resp->rawData[2]); } @@ -2740,7 +2733,7 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf iwe.u.data.flags |= IW_ENCODE_DISABLED; } - buf = IWE_STREAM_ADD_POINT(info, buf, buf_end, &iwe, NULL); + buf = iwe_stream_add_point(info, buf, buf_end, &iwe, NULL); /* Frequency Info */ @@ -2751,7 +2744,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf iwe.u.freq.m = wl_parse_ds_ie( probe_resp ); iwe.u.freq.e = 0; - buf = IWE_STREAM_ADD_EVENT(info, buf, buf_end, &iwe, IW_EV_FREQ_LEN); + buf = iwe_stream_add_event(info, buf, buf_end, + &iwe, IW_EV_FREQ_LEN); /* Custom info (Beacon Interval) */ @@ -2762,7 +2756,7 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf sprintf( msg, "beacon_interval=%d", probe_resp->beaconInterval ); iwe.u.data.length = strlen( msg ); - buf = IWE_STREAM_ADD_POINT(info, buf, buf_end, &iwe, msg); + buf = iwe_stream_add_point(info, buf, buf_end, &iwe, msg); /* Custom info (WPA-IE) */ @@ -2778,7 +2772,8 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf sprintf( msg, "wpa_ie=%s", wl_print_wpa_ie( wpa_ie, wpa_ie_len )); iwe.u.data.length = strlen( msg ); - buf = IWE_STREAM_ADD_POINT(info, buf, buf_end, &iwe, msg); + buf = iwe_stream_add_point(info, buf, buf_end, + &iwe, msg); } /* Add other custom info in formatted string format as needed... */ From 68da105637af306f5113441812c13209e4f939c4 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:34 +0100 Subject: [PATCH 1445/1519] staging: wlags49_h2: Report WPA IE in scan results with IWEVGENIE Report the IE using the appropriate event instead of a custom one. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index c392fd82e98..af9fec583a7 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -2759,21 +2759,19 @@ static int wireless_get_scan(struct net_device *dev, struct iw_request_info *inf buf = iwe_stream_add_point(info, buf, buf_end, &iwe, msg); - /* Custom info (WPA-IE) */ + /* WPA-IE */ wpa_ie = NULL; wpa_ie_len = 0; wpa_ie = wl_parse_wpa_ie( probe_resp, &wpa_ie_len ); if( wpa_ie != NULL ) { - memset( &iwe, 0, sizeof( iwe )); - memset( msg, 0, sizeof( msg )); + memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - sprintf( msg, "wpa_ie=%s", wl_print_wpa_ie( wpa_ie, wpa_ie_len )); - iwe.u.data.length = strlen( msg ); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = wpa_ie_len; buf = iwe_stream_add_point(info, buf, buf_end, - &iwe, msg); + &iwe, wpa_ie); } /* Add other custom info in formatted string format as needed... */ From 05df482e6e41734bb68221b2aae50ea8a3911c5b Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:35 +0100 Subject: [PATCH 1446/1519] staging: wlags49_h2: Make key setting more reliable Share logic between encodeext and encode, so that we can handle subtle differences between them (implied set_tx), and clear the appropriate keys if you attempt to switch straight from WPA to WEP and vice versa. Also reinstate the TX buffer flush, and ensure the key index is written to the card little endian. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_internal.h | 6 + drivers/staging/wlags49_h2/wl_wext.c | 669 ++++++++++++----------- 2 files changed, 347 insertions(+), 328 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_internal.h b/drivers/staging/wlags49_h2/wl_internal.h index 9ed28574e8a..57534083405 100644 --- a/drivers/staging/wlags49_h2/wl_internal.h +++ b/drivers/staging/wlags49_h2/wl_internal.h @@ -980,6 +980,12 @@ struct wl_private #ifdef USE_WDS WVLAN_WDS_IF wds_port[NUM_WDS_PORTS]; #endif // USE_WDS + + /* Track whether the card is using WEP encryption or WPA + * so we know what to disable next time through. + * IW_ENCODE_ALG_NONE, IW_ENCODE_ALG_WEP, IW_ENCODE_ALG_TKIP + */ + int wext_enc; }; // wl_private #define wl_priv(dev) ((struct wl_private *) netdev_priv(dev)) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index af9fec583a7..567a0dc2929 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -83,7 +83,223 @@ extern dbg_info_t *DbgInfo; #endif // DBG +/* Set up the LTV to program the appropriate key */ +static int hermes_set_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr, + int set_tx, u8 *seq, u8 *key, size_t key_len) +{ + int ret = -EINVAL; + int buf_idx = 0; + hcf_8 tsc[IW_ENCODE_SEQ_MAX_SIZE] = + { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 }; + DBG_ENTER(DbgInfo); + + /* + * Check the key index here; if 0, load as Pairwise Key, otherwise, + * load as a group key. Note that for the Hermes, the RIDs for + * group/pairwise keys are different from each other and different + * than the default WEP keys as well. + */ + switch (key_idx) { + case 0: + ltv->len = 28; + ltv->typ = CFG_ADD_TKIP_MAPPED_KEY; + + /* Load the BSSID */ + memcpy(<v->u.u8[buf_idx], addr, ETH_ALEN); + buf_idx += ETH_ALEN; + + /* Load the TKIP key */ + memcpy(<v->u.u8[buf_idx], &key[0], 16); + buf_idx += 16; + + /* Load the TSC */ + memcpy(<v->u.u8[buf_idx], tsc, IW_ENCODE_SEQ_MAX_SIZE); + buf_idx += IW_ENCODE_SEQ_MAX_SIZE; + + /* Load the RSC */ + memcpy(<v->u.u8[buf_idx], seq, IW_ENCODE_SEQ_MAX_SIZE); + buf_idx += IW_ENCODE_SEQ_MAX_SIZE; + + /* Load the TxMIC key */ + memcpy(<v->u.u8[buf_idx], &key[16], 8); + buf_idx += 8; + + /* Load the RxMIC key */ + memcpy(<v->u.u8[buf_idx], &key[24], 8); + + ret = 0; + break; + case 1: + case 2: + case 3: + ltv->len = 26; + ltv->typ = CFG_ADD_TKIP_DEFAULT_KEY; + + /* Load the key Index */ + + /* If this is a Tx Key, set bit 8000 */ + if (set_tx) + key_idx |= 0x8000; + ltv->u.u16[buf_idx] = cpu_to_le16(key_idx); + buf_idx += 2; + + /* Load the RSC */ + memcpy(<v->u.u8[buf_idx], seq, IW_ENCODE_SEQ_MAX_SIZE); + buf_idx += IW_ENCODE_SEQ_MAX_SIZE; + + /* Load the TKIP, TxMIC, and RxMIC keys in one shot, because in + CFG_ADD_TKIP_DEFAULT_KEY they are back-to-back */ + memcpy(<v->u.u8[buf_idx], key, key_len); + buf_idx += key_len; + + /* Load the TSC */ + memcpy(<v->u.u8[buf_idx], tsc, IW_ENCODE_SEQ_MAX_SIZE); + + ret = 0; + break; + default: + break; + } + + DBG_LEAVE(DbgInfo); + return ret; +} + +/* Set up the LTV to clear the appropriate key */ +static int hermes_clear_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr) +{ + int ret; + + switch (key_idx) { + case 0: + if (memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) { + ltv->len = 7; + ltv->typ = CFG_REMOVE_TKIP_MAPPED_KEY; + memcpy(<v->u.u8[0], addr, ETH_ALEN); + ret = 0; + } + break; + case 1: + case 2: + case 3: + /* Clear the Group TKIP keys by index */ + ltv->len = 2; + ltv->typ = CFG_REMOVE_TKIP_DEFAULT_KEY; + ltv->u.u16[0] = cpu_to_le16(key_idx); + + ret = 0; + break; + default: + break; + } + + return ret; +} + +/* Set the WEP keys in the wl_private structure */ +static int hermes_set_wep_keys(struct wl_private *lp, u16 key_idx, + u8 *key, size_t key_len, + bool enable, bool set_tx) +{ + hcf_8 encryption_state = lp->EnableEncryption; + int tk = lp->TransmitKeyID - 1; /* current key */ + int ret = 0; + + /* Is encryption supported? */ + if (!wl_has_wep(&(lp->hcfCtx))) { + DBG_WARNING(DbgInfo, "WEP not supported on this device\n"); + ret = -EOPNOTSUPP; + goto out; + } + + DBG_NOTICE(DbgInfo, "pointer: %p, length: %d\n", + key, key_len); + + /* Check the size of the key */ + switch (key_len) { + case MIN_KEY_SIZE: + case MAX_KEY_SIZE: + + /* Check the index */ + if ((key_idx < 0) || (key_idx >= MAX_KEYS)) + key_idx = tk; + + /* Cleanup */ + memset(lp->DefaultKeys.key[key_idx].key, 0, MAX_KEY_SIZE); + + /* Copy the key in the driver */ + memcpy(lp->DefaultKeys.key[key_idx].key, key, key_len); + + /* Set the length */ + lp->DefaultKeys.key[key_idx].len = key_len; + + DBG_NOTICE(DbgInfo, "encoding.length: %d\n", key_len); + DBG_NOTICE(DbgInfo, "set key: %s(%d) [%d]\n", + lp->DefaultKeys.key[key_idx].key, + lp->DefaultKeys.key[key_idx].len, key_idx); + + /* Enable WEP (if possible) */ + if ((key_idx == tk) && (lp->DefaultKeys.key[tk].len > 0)) + lp->EnableEncryption = 1; + + break; + + case 0: + /* Do we want to just set the current transmit key? */ + if (set_tx && (key_idx >= 0) && (key_idx < MAX_KEYS)) { + DBG_NOTICE(DbgInfo, "index: %d; len: %d\n", key_idx, + lp->DefaultKeys.key[key_idx].len); + + if (lp->DefaultKeys.key[key_idx].len > 0) { + lp->TransmitKeyID = key_idx + 1; + lp->EnableEncryption = 1; + } else { + DBG_WARNING(DbgInfo, "Problem setting the current TxKey\n"); + ret = -EINVAL; + } + } + break; + + default: + DBG_WARNING(DbgInfo, "Invalid Key length\n"); + ret = -EINVAL; + goto out; + } + + /* Read the flags */ + if (enable) { + lp->EnableEncryption = 1; + lp->wext_enc = IW_ENCODE_ALG_WEP; + } else { + lp->EnableEncryption = 0; /* disable encryption */ + lp->wext_enc = IW_ENCODE_ALG_NONE; + } + + DBG_TRACE(DbgInfo, "encryption_state : %d\n", encryption_state); + DBG_TRACE(DbgInfo, "lp->EnableEncryption : %d\n", lp->EnableEncryption); + DBG_TRACE(DbgInfo, "erq->length : %d\n", key_len); + + /* Write the changes to the card */ + if (ret == 0) { + DBG_NOTICE(DbgInfo, "encrypt: %d, ID: %d\n", lp->EnableEncryption, + lp->TransmitKeyID); + + if (lp->EnableEncryption == encryption_state) { + if (key_len != 0) { + /* Dynamic WEP key update */ + wl_set_wep_keys(lp); + } + } else { + /* To switch encryption on/off, soft reset is + * required */ + wl_apply(lp); + } + } + +out: + return ret; +} /******************************************************************************* * wireless_commit() @@ -1116,152 +1332,39 @@ static int wireless_set_encode(struct net_device *dev, struct iw_request_info *i { struct wl_private *lp = wl_priv(dev); unsigned long flags; - int ret = 0; - hcf_8 encryption_state; - /*------------------------------------------------------------------------*/ + int key_idx = (erq->flags & IW_ENCODE_INDEX) - 1; + int ret = 0; + bool enable = true; + DBG_ENTER(DbgInfo); - DBG_FUNC( "wireless_set_encode" ); - DBG_ENTER( DbgInfo ); - - if(lp->portState == WVLAN_PORT_STATE_DISABLED) { + if (lp->portState == WVLAN_PORT_STATE_DISABLED) { ret = -EBUSY; goto out; } - wl_lock( lp, &flags ); + if (erq->flags & IW_ENCODE_DISABLED) + enable = false; - wl_act_int_off( lp ); + wl_lock(lp, &flags); - /* Is encryption supported? */ - if( !wl_has_wep( &( lp->hcfCtx ))) { - DBG_WARNING( DbgInfo, "WEP not supported on this device\n" ); - ret = -EOPNOTSUPP; - goto out_unlock; - } + wl_act_int_off(lp); - DBG_NOTICE( DbgInfo, "pointer: %p, length: %d, flags: %#x\n", - keybuf, erq->length, - erq->flags); - - /* Save state of Encryption switch */ - encryption_state = lp->EnableEncryption; - - /* Basic checking: do we have a key to set? */ - if((erq->length) != 0) { - int index = ( erq->flags & IW_ENCODE_INDEX ) - 1; - int tk = lp->TransmitKeyID - 1; // current key - - - /* Check the size of the key */ - switch(erq->length) { - case 0: - break; - - case MIN_KEY_SIZE: - case MAX_KEY_SIZE: - - /* Check the index */ - if(( index < 0 ) || ( index >= MAX_KEYS )) { - index = tk; - } - - /* Cleanup */ - memset( lp->DefaultKeys.key[index].key, 0, MAX_KEY_SIZE ); - - /* Copy the key in the driver */ - memcpy( lp->DefaultKeys.key[index].key, keybuf, erq->length); - - /* Set the length */ - lp->DefaultKeys.key[index].len = erq->length; - - DBG_NOTICE( DbgInfo, "encoding.length: %d\n", erq->length ); - DBG_NOTICE( DbgInfo, "set key: %s(%d) [%d]\n", lp->DefaultKeys.key[index].key, - lp->DefaultKeys.key[index].len, index ); - - /* Enable WEP (if possible) */ - if(( index == tk ) && ( lp->DefaultKeys.key[tk].len > 0 )) { - lp->EnableEncryption = 1; - } - - break; - - default: - DBG_WARNING( DbgInfo, "Invalid Key length\n" ); - ret = -EINVAL; - goto out_unlock; - } - } else { - int index = ( erq->flags & IW_ENCODE_INDEX ) - 1; - - - /* Do we want to just set the current transmit key? */ - if(( index >= 0 ) && ( index < MAX_KEYS )) { - DBG_NOTICE( DbgInfo, "index: %d; len: %d\n", index, - lp->DefaultKeys.key[index].len ); - - if( lp->DefaultKeys.key[index].len > 0 ) { - lp->TransmitKeyID = index + 1; - lp->EnableEncryption = 1; - } else { - DBG_WARNING( DbgInfo, "Problem setting the current TxKey\n" ); - ret = -EINVAL; - } - } - } - - /* Read the flags */ - if( erq->flags & IW_ENCODE_DISABLED ) { - lp->EnableEncryption = 0; // disable encryption - } else { - lp->EnableEncryption = 1; - } - - if( erq->flags & IW_ENCODE_RESTRICTED ) { - DBG_WARNING( DbgInfo, "IW_ENCODE_RESTRICTED invalid\n" ); - ret = -EINVAL; // Invalid - } - - DBG_TRACE( DbgInfo, "encryption_state : %d\n", encryption_state ); - DBG_TRACE( DbgInfo, "lp->EnableEncryption : %d\n", lp->EnableEncryption ); - DBG_TRACE( DbgInfo, "erq->length : %d\n", - erq->length); - DBG_TRACE( DbgInfo, "erq->flags : 0x%x\n", - erq->flags); - - /* Write the changes to the card */ - if( ret == 0 ) { - DBG_NOTICE( DbgInfo, "encrypt: %d, ID: %d\n", lp->EnableEncryption, - lp->TransmitKeyID ); - - if( lp->EnableEncryption == encryption_state ) { - if( erq->length != 0 ) { - /* Dynamic WEP key update */ - wl_set_wep_keys( lp ); - } - } else { - /* To switch encryption on/off, soft reset is required */ - wl_apply( lp ); - } - } + ret = hermes_set_wep_keys(lp, key_idx, keybuf, erq->length, + enable, true); /* Send an event that Encryption has been set */ - wl_wext_event_encode( dev ); + if (ret == 0) + wl_wext_event_encode(dev); -out_unlock: - - wl_act_int_on( lp ); + wl_act_int_on(lp); wl_unlock(lp, &flags); out: - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ret; -} // wireless_set_encode -/*============================================================================*/ - - - +} /******************************************************************************* * wireless_get_encode() @@ -2911,243 +3014,153 @@ out: /*============================================================================*/ - -static int hermes_set_key(ltv_t *ltv, int alg, int key_idx, u8 *addr, - int set_tx, u8 *seq, u8 *key, size_t key_len) +static void flush_tx(struct wl_private *lp) { - int ret = -EINVAL; - // int count = 0; - int buf_idx = 0; - hcf_8 tsc[IW_ENCODE_SEQ_MAX_SIZE] = - { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 }; - - DBG_FUNC( "hermes_set_key" ); - DBG_ENTER( DbgInfo ); + ltv_t ltv; + int count; /* - * Check the key index here; if 0, load as Pairwise Key, otherwise, - * load as a group key. Note that for the Hermes, the RIDs for - * group/pariwise keys are different from each other and different - * than the default WEP keys as well. - */ - switch (alg) - { - case IW_ENCODE_ALG_TKIP: - DBG_TRACE( DbgInfo, "IW_ENCODE_ALG_TKIP: key(%d)\n", key_idx); -#if 0 - /* - * Make sure that there is no data queued up in the firmware - * before setting the TKIP keys. If this check is not - * performed, some data may be sent out with incorrect MIC - * and cause synchronizarion errors with the AP - */ - /* Check every 1ms for 100ms */ - for( count = 0; count < 100; count++ ) - { - usleep( 1000 ); + * Make sure that there is no data queued up in the firmware + * before setting the TKIP keys. If this check is not + * performed, some data may be sent out with incorrect MIC + * and cause synchronizarion errors with the AP + */ + /* Check every 1ms for 100ms */ + for (count = 0; count < 100; count++) { + udelay(1000); - ltv.len = 2; - ltv.typ = 0xFD91; // This RID not defined in HCF yet!!! - ltv.u.u16[0] = 0; + ltv.len = 2; + ltv.typ = 0xFD91; /* This RID not defined in HCF yet!!! */ + ltv.u.u16[0] = 0; - wl_get_info( sock, <v, ifname ); + hcf_get_info(&(lp->hcfCtx), (LTVP)<v); - if( ltv.u.u16[0] == 0 ) - { - break; - } - } - - if( count == 100 ) - { - wpa_printf( MSG_DEBUG, "Timed out waiting for TxQ!" ); - } -#endif - - switch (key_idx) { - case 0: - ltv->len = 28; - ltv->typ = CFG_ADD_TKIP_MAPPED_KEY; - - /* Load the BSSID */ - memcpy(<v->u.u8[buf_idx], addr, ETH_ALEN); - buf_idx += ETH_ALEN; - - /* Load the TKIP key */ - memcpy(<v->u.u8[buf_idx], &key[0], 16); - buf_idx += 16; - - /* Load the TSC */ - memcpy(<v->u.u8[buf_idx], tsc, IW_ENCODE_SEQ_MAX_SIZE); - buf_idx += IW_ENCODE_SEQ_MAX_SIZE; - - /* Load the RSC */ - memcpy(<v->u.u8[buf_idx], seq, IW_ENCODE_SEQ_MAX_SIZE); - buf_idx += IW_ENCODE_SEQ_MAX_SIZE; - - /* Load the TxMIC key */ - memcpy(<v->u.u8[buf_idx], &key[16], 8); - buf_idx += 8; - - /* Load the RxMIC key */ - memcpy(<v->u.u8[buf_idx], &key[24], 8); - - ret = 0; + if (ltv.u.u16[0] == 0) break; - case 1: - case 2: - case 3: - ltv->len = 26; - ltv->typ = CFG_ADD_TKIP_DEFAULT_KEY; - - /* Load the key Index */ - ltv->u.u16[buf_idx] = key_idx; - /* If this is a Tx Key, set bit 8000 */ - if(set_tx) - ltv->u.u16[buf_idx] |= 0x8000; - buf_idx += 2; - - /* Load the RSC */ - memcpy(<v->u.u8[buf_idx], seq, IW_ENCODE_SEQ_MAX_SIZE); - buf_idx += IW_ENCODE_SEQ_MAX_SIZE; - - /* Load the TKIP, TxMIC, and RxMIC keys in one shot, because in - CFG_ADD_TKIP_DEFAULT_KEY they are back-to-back */ - memcpy(<v->u.u8[buf_idx], key, key_len); - buf_idx += key_len; - - /* Load the TSC */ - memcpy(<v->u.u8[buf_idx], tsc, IW_ENCODE_SEQ_MAX_SIZE); - - ltv->u.u16[0] = CNV_INT_TO_LITTLE(ltv->u.u16[0]); - - ret = 0; - break; - default: - break; - } - - break; - - case IW_ENCODE_ALG_WEP: - DBG_TRACE( DbgInfo, "IW_ENCODE_ALG_WEP: key(%d)\n", key_idx); - break; - - case IW_ENCODE_ALG_CCMP: - DBG_TRACE( DbgInfo, "IW_ENCODE_ALG_CCMP: key(%d)\n", key_idx); - break; - - case IW_ENCODE_ALG_NONE: - DBG_TRACE( DbgInfo, "IW_ENCODE_ALG_NONE: key(%d)\n", key_idx); - switch (key_idx) { - case 0: - if (memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) { - //if (addr != NULL) { - ltv->len = 7; - ltv->typ = CFG_REMOVE_TKIP_MAPPED_KEY; - memcpy(<v->u.u8[0], addr, ETH_ALEN); - ret = 0; - } - break; - case 1: - case 2: - case 3: - /* Clear the Group TKIP keys by index */ - ltv->len = 2; - ltv->typ = CFG_REMOVE_TKIP_DEFAULT_KEY; - ltv->u.u16[0] = key_idx; - - ret = 0; - break; - default: - break; - } - break; - default: - DBG_TRACE( DbgInfo, "IW_ENCODE_??: key(%d)\n", key_idx); - break; } - DBG_LEAVE( DbgInfo ); - return ret; -} // hermes_set_key -/*============================================================================*/ + if (count >= 100) + DBG_TRACE(DbgInfo, "Timed out waiting for TxQ flush!\n"); +} - -static int wireless_set_encodeext (struct net_device *dev, - struct iw_request_info *info, - struct iw_point *erq, char *keybuf) +static int wireless_set_encodeext(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *erq, char *keybuf) { struct wl_private *lp = wl_priv(dev); unsigned long flags; - int ret; - int key_idx = (erq->flags&IW_ENCODE_INDEX) - 1; + int ret; + int key_idx = (erq->flags & IW_ENCODE_INDEX) - 1; ltv_t ltv; struct iw_encode_ext *ext = (struct iw_encode_ext *)keybuf; + bool enable = true; + bool set_tx = false; - DBG_FUNC( "wireless_set_encodeext" ); - DBG_ENTER( DbgInfo ); + DBG_ENTER(DbgInfo); - if(lp->portState == WVLAN_PORT_STATE_DISABLED) { + if (lp->portState == WVLAN_PORT_STATE_DISABLED) { ret = -EBUSY; goto out; } - if (sizeof(ext->rx_seq) != 8) { - DBG_TRACE(DbgInfo, "rz_seq size mismatch\n"); - DBG_LEAVE(DbgInfo); - return -EINVAL; + if (erq->flags & IW_ENCODE_DISABLED) { + ext->alg = IW_ENCODE_ALG_NONE; + enable = false; } - /* Handle WEP keys via the old set encode procedure */ - if(ext->alg == IW_ENCODE_ALG_WEP) { - struct iw_point wep_erq; - char *wep_keybuf; + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) + set_tx = true; - /* Build request structure */ - wep_erq.flags = erq->flags; // take over flags with key index - wep_erq.length = ext->key_len; // take length from extended key info - wep_keybuf = ext->key; // pointer to the key text + wl_lock(lp, &flags); - /* Call wireless_set_encode tot handle the WEP key */ - ret = wireless_set_encode(dev, info, &wep_erq, wep_keybuf); - goto out; - } - - /* Proceed for extended encode functions for WAP and NONE */ - wl_lock( lp, &flags ); - - wl_act_int_off( lp ); + wl_act_int_off(lp); memset(<v, 0, sizeof(ltv)); - ret = hermes_set_key(<v, ext->alg, key_idx, ext->addr.sa_data, - ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, - ext->rx_seq, ext->key, ext->key_len); - if (ret != 0) { - DBG_TRACE( DbgInfo, "hermes_set_key returned != 0, key not set\n"); - goto out_unlock; + switch (ext->alg) { + case IW_ENCODE_ALG_TKIP: + DBG_TRACE(DbgInfo, "IW_ENCODE_ALG_TKIP: key(%d)\n", key_idx); + + if (sizeof(ext->rx_seq) != 8) { + DBG_TRACE(DbgInfo, "rx_seq size mismatch\n"); + DBG_LEAVE(DbgInfo); + ret = -EINVAL; + goto out_unlock; + } + + ret = hermes_set_tkip_keys(<v, key_idx, ext->addr.sa_data, + set_tx, + ext->rx_seq, ext->key, ext->key_len); + + if (ret != 0) { + DBG_TRACE(DbgInfo, "hermes_set_tkip_keys returned != 0, key not set\n"); + goto out_unlock; + } + + flush_tx(lp); + + lp->wext_enc = IW_ENCODE_ALG_TKIP; + + /* Write the key */ + ret = hcf_put_info(&(lp->hcfCtx), (LTVP)<v); + break; + + case IW_ENCODE_ALG_WEP: + DBG_TRACE(DbgInfo, "IW_ENCODE_ALG_WEP: key(%d)\n", key_idx); + + if (erq->flags & IW_ENCODE_RESTRICTED) { + DBG_WARNING(DbgInfo, "IW_ENCODE_RESTRICTED invalid\n"); + ret = -EINVAL; + goto out_unlock; + } + + ret = hermes_set_wep_keys(lp, key_idx, ext->key, ext->key_len, + enable, set_tx); + + break; + + case IW_ENCODE_ALG_CCMP: + DBG_TRACE(DbgInfo, "IW_ENCODE_ALG_CCMP: key(%d)\n", key_idx); + ret = -EOPNOTSUPP; + break; + + case IW_ENCODE_ALG_NONE: + DBG_TRACE(DbgInfo, "IW_ENCODE_ALG_NONE: key(%d)\n", key_idx); + + if (lp->wext_enc == IW_ENCODE_ALG_TKIP) { + ret = hermes_clear_tkip_keys(<v, key_idx, + ext->addr.sa_data); + flush_tx(lp); + lp->wext_enc = IW_ENCODE_ALG_NONE; + ret = hcf_put_info(&(lp->hcfCtx), (LTVP)<v); + + } else if (lp->wext_enc == IW_ENCODE_ALG_WEP) { + ret = hermes_set_wep_keys(lp, key_idx, + ext->key, ext->key_len, + false, false); + } else { + ret = 0; + } + + break; + + default: + DBG_TRACE( DbgInfo, "IW_ENCODE_??: key(%d)\n", key_idx); + ret = -EOPNOTSUPP; + break; } - /* Put the key in HCF */ - ret = hcf_put_info(&(lp->hcfCtx), (LTVP)<v); - out_unlock: - if(ret == HCF_SUCCESS) { - DBG_TRACE( DbgInfo, "Put key info succes\n"); - } else { - DBG_TRACE( DbgInfo, "Put key info failed, key not set\n"); - } - wl_act_int_on( lp ); + wl_act_int_on(lp); wl_unlock(lp, &flags); out: - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ret; -} // wireless_set_encodeext +} /*============================================================================*/ From 9ef023006d8b94b892ec4cf5b05e5d4278af6451 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:36 +0100 Subject: [PATCH 1447/1519] staging: wlags49_h2: Fixup IW_AUTH handling Handle more cases in IW_AUTH. Avoid reporting errors (invalid parameter) on operations that we can't do anything with. Return -EINPROGRESS from some operations to get wpa_supplicant to batch and commit changes. In other operations apply the changes immediately. Avoid writing WEP keys from the commit handler when WEP is not being used. Accept WPA_VERSION_DISABLED, which is received from wpa_supplicant during WEP. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_main.c | 6 +- drivers/staging/wlags49_h2/wl_wext.c | 187 ++++++++++++++++----------- 2 files changed, 113 insertions(+), 80 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c index 6d45ab3f027..483eee1bf63 100644 --- a/drivers/staging/wlags49_h2/wl_main.c +++ b/drivers/staging/wlags49_h2/wl_main.c @@ -1993,8 +1993,10 @@ int wl_put_ltv( struct wl_private *lp ) lp->ltvRecord.typ = CFG_SET_WPA_AUTH_KEY_MGMT_SUITE; lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->AuthKeyMgmtSuite ); hcf_status = hcf_put_info( &lp->hcfCtx, (LTVP)&( lp->ltvRecord )); - /* WEP Keys */ - wl_set_wep_keys( lp ); + + /* If WEP (or no) keys are being used, write (or clear) them */ + if (lp->wext_enc != IW_ENCODE_ALG_TKIP) + wl_set_wep_keys(lp); /* Country Code */ /* countryInfo, ltvCountryInfo, CFG_CNF_COUNTRY_INFO */ diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 567a0dc2929..98843209536 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -2894,7 +2894,24 @@ out: } // wireless_get_scan /*============================================================================*/ - +#if DBG +static const char * const auth_names[] = { + "IW_AUTH_WPA_VERSION", + "IW_AUTH_CIPHER_PAIRWISE", + "IW_AUTH_CIPHER_GROUP", + "IW_AUTH_KEY_MGMT", + "IW_AUTH_TKIP_COUNTERMEASURES", + "IW_AUTH_DROP_UNENCRYPTED", + "IW_AUTH_80211_AUTH_ALG", + "IW_AUTH_WPA_ENABLED", + "IW_AUTH_RX_UNENCRYPTED_EAPOL", + "IW_AUTH_ROAMING_CONTROL", + "IW_AUTH_PRIVACY_INVOKED", + "IW_AUTH_CIPHER_GROUP_MGMT", + "IW_AUTH_MFP", + "Unsupported" +}; +#endif static int wireless_set_auth(struct net_device *dev, struct iw_request_info *info, @@ -2902,14 +2919,15 @@ static int wireless_set_auth(struct net_device *dev, { struct wl_private *lp = wl_priv(dev); unsigned long flags; - int ret; - int iwa_idx = data->flags & IW_AUTH_INDEX; - int iwa_val = data->value; + ltv_t ltv; + int ret; + int iwa_idx = data->flags & IW_AUTH_INDEX; + int iwa_val = data->value; DBG_FUNC( "wireless_set_auth" ); DBG_ENTER( DbgInfo ); - if(lp->portState == WVLAN_PORT_STATE_DISABLED) { + if (lp->portState == WVLAN_PORT_STATE_DISABLED) { ret = -EBUSY; goto out; } @@ -2918,89 +2936,102 @@ static int wireless_set_auth(struct net_device *dev, wl_act_int_off( lp ); + if (iwa_idx > IW_AUTH_MFP) + iwa_idx = IW_AUTH_MFP + 1; + DBG_TRACE(DbgInfo, "%s\n", auth_names[iwa_idx]); switch (iwa_idx) { - case IW_AUTH_WPA_VERSION: - DBG_TRACE( DbgInfo, "IW_AUTH_WPA_VERSION\n"); - /* We do support WPA only; how should DISABLED be treated? */ - if (iwa_val == IW_AUTH_WPA_VERSION_WPA) - ret = 0; - else - ret = -EINVAL; - break; - - case IW_AUTH_WPA_ENABLED: - DBG_TRACE( DbgInfo, "IW_AUTH_WPA_ENABLED: val = %d\n", iwa_val); - if (iwa_val) - lp->EnableEncryption = 2; - else - lp->EnableEncryption = 0; + case IW_AUTH_WPA_VERSION: + /* We do support WPA */ + if ((iwa_val == IW_AUTH_WPA_VERSION_WPA) || + (iwa_val == IW_AUTH_WPA_VERSION_DISABLED)) ret = 0; - break; + else + ret = -EINVAL; + break; - case IW_AUTH_TKIP_COUNTERMEASURES: - DBG_TRACE( DbgInfo, "IW_AUTH_TKIP_COUNTERMEASURES\n"); - lp->driverEnable = !iwa_val; - if(lp->driverEnable) - hcf_cntl(&(lp->hcfCtx), HCF_CNTL_ENABLE | HCF_PORT_0); - else - hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISABLE | HCF_PORT_0); + case IW_AUTH_WPA_ENABLED: + DBG_TRACE(DbgInfo, "val = %d\n", iwa_val); + if (iwa_val) + lp->EnableEncryption = 2; + else + lp->EnableEncryption = 0; + + /* Write straight to the card */ + ltv.len = 2; + ltv.typ = CFG_CNF_ENCRYPTION; + ltv.u.u16[0] = cpu_to_le16(lp->EnableEncryption); + ret = hcf_put_info(&lp->hcfCtx, (LTVP)<v); + + break; + + case IW_AUTH_TKIP_COUNTERMEASURES: + + /* Immediately disable card */ + lp->driverEnable = !iwa_val; + if (lp->driverEnable) + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_ENABLE | HCF_PORT_0); + else + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISABLE | HCF_PORT_0); + ret = 0; + break; + + case IW_AUTH_MFP: + /* Management Frame Protection not supported. + * Only fail if set to required. + */ + if (iwa_val == IW_AUTH_MFP_REQUIRED) + ret = -EINVAL; + else ret = 0; - break; + break; - case IW_AUTH_DROP_UNENCRYPTED: - DBG_TRACE( DbgInfo, "IW_AUTH_DROP_UNENCRYPTED\n"); - /* We do not actually do anything here, just to silence - * wpa_supplicant */ - ret = 0; - break; + case IW_AUTH_KEY_MGMT: - case IW_AUTH_CIPHER_PAIRWISE: - DBG_TRACE( DbgInfo, "IW_AUTH_CIPHER_PAIRWISE\n"); - /* not implemented, return an error */ + /* Record required management suite. + * Will take effect on next commit */ + if (iwa_val != 0) + lp->AuthKeyMgmtSuite = 4; + else + lp->AuthKeyMgmtSuite = 0; + + ret = -EINPROGRESS; + break; + + case IW_AUTH_80211_AUTH_ALG: + + /* Just record whether open or shared is required. + * Will take effect on next commit */ + ret = -EINPROGRESS; + + if (iwa_val & IW_AUTH_ALG_SHARED_KEY) + lp->authentication = 1; + else if (iwa_val & IW_AUTH_ALG_OPEN_SYSTEM) + lp->authentication = 0; + else ret = -EINVAL; - break; + break; - case IW_AUTH_CIPHER_GROUP: - DBG_TRACE( DbgInfo, "IW_AUTH_CIPHER_GROUP\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; + case IW_AUTH_DROP_UNENCRYPTED: + /* Only needed for AP */ + lp->ExcludeUnencrypted = iwa_val; + ret = -EINPROGRESS; + break; - case IW_AUTH_KEY_MGMT: - DBG_TRACE( DbgInfo, "IW_AUTH_KEY_MGMT\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_RX_UNENCRYPTED_EAPOL: + case IW_AUTH_ROAMING_CONTROL: + case IW_AUTH_PRIVACY_INVOKED: + /* Not used. May need to do something with + * CIPHER_PAIRWISE and CIPHER_GROUP*/ + ret = -EINPROGRESS; + break; - case IW_AUTH_80211_AUTH_ALG: - DBG_TRACE( DbgInfo, "IW_AUTH_80211_AUTH_ALG\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; - - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - DBG_TRACE( DbgInfo, "IW_AUTH_RX_UNENCRYPTED_EAPOL\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; - - case IW_AUTH_ROAMING_CONTROL: - DBG_TRACE( DbgInfo, "IW_AUTH_ROAMING_CONTROL\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; - - case IW_AUTH_PRIVACY_INVOKED: - DBG_TRACE( DbgInfo, "IW_AUTH_PRIVACY_INVOKED\n"); - /* not implemented, return an error */ - ret = -EINVAL; - break; - - default: - DBG_TRACE( DbgInfo, "IW_AUTH_?? (%d) unknown\n", iwa_idx); - /* return an error */ - ret = -EINVAL; - break; + default: + DBG_TRACE(DbgInfo, "IW_AUTH_?? (%d) unknown\n", iwa_idx); + /* return an error */ + ret = -EOPNOTSUPP; + break; } wl_act_int_on( lp ); From 729336b3267aa50011ec32574f88f1c3e6fee844 Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Sun, 9 Oct 2011 12:11:37 +0100 Subject: [PATCH 1448/1519] staging: wlags49_h2: Fixup SIOCSIWGENIE Setting the key management scheme is done in SIOCSIWAUTH, so no need to do anything in SIOCSIWGENIE. Fix up function name. Signed-off-by: David Kilroy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 40 +++++++--------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 98843209536..8ac5e1081aa 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -3196,42 +3196,20 @@ out: -static int wireless_get_genie(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *data, char *extra) +static int wireless_set_genie(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *data, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; int ret = 0; - ltv_t ltv; - DBG_FUNC( "wireless_get_genie" ); - DBG_ENTER( DbgInfo ); + DBG_ENTER(DbgInfo); - if(lp->portState == WVLAN_PORT_STATE_DISABLED) { - ret = -EBUSY; - goto out; - } + /* We can't write this to the card, but apparently this + * operation needs to succeed */ + ret = 0; - wl_lock( lp, &flags ); - - wl_act_int_off( lp ); - - memset(<v, 0, sizeof(ltv)); - ltv.len = 2; - ltv.typ = CFG_SET_WPA_AUTH_KEY_MGMT_SUITE; - lp->AuthKeyMgmtSuite = ltv.u.u16[0] = 4; - ltv.u.u16[0] = CNV_INT_TO_LITTLE(ltv.u.u16[0]); - - ret = hcf_put_info(&(lp->hcfCtx), (LTVP)<v); - - wl_act_int_on( lp ); - - wl_unlock(lp, &flags); - -out: - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ret; } /*============================================================================*/ @@ -3970,7 +3948,7 @@ static const iw_handler wl_handler[] = IW_HANDLER(SIOCGIWENCODE, (iw_handler) wireless_get_encode), IW_HANDLER(SIOCSIWPOWER, (iw_handler) wireless_set_power), IW_HANDLER(SIOCGIWPOWER, (iw_handler) wireless_get_power), - IW_HANDLER(SIOCSIWGENIE, (iw_handler) wireless_get_genie), + IW_HANDLER(SIOCSIWGENIE, (iw_handler) wireless_set_genie), IW_HANDLER(SIOCSIWAUTH, (iw_handler) wireless_set_auth), IW_HANDLER(SIOCSIWENCODEEXT, (iw_handler) wireless_set_encodeext), }; From b55e073e95804b022075e464b9cf82e269fd457a Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Mon, 10 Oct 2011 08:36:38 +0200 Subject: [PATCH 1449/1519] staging/easycap: kill timeval members of easycap struct timeval[0-9] were not used or used in a ready only code so we can remove them safely and so the code Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/easycap.h | 11 ------ drivers/staging/easycap/easycap_ioctl.c | 2 -- drivers/staging/easycap/easycap_main.c | 48 ------------------------- drivers/staging/easycap/easycap_sound.c | 3 -- 4 files changed, 64 deletions(-) diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h index 22b24b6c5a5..7b256a948c2 100644 --- a/drivers/staging/easycap/easycap.h +++ b/drivers/staging/easycap/easycap.h @@ -324,13 +324,6 @@ struct easycap { int lost[INPUT_MANY]; int merit[180]; - struct timeval timeval0; - struct timeval timeval1; - struct timeval timeval2; - struct timeval timeval3; - struct timeval timeval6; - struct timeval timeval7; - struct timeval timeval8; long long int dnbydt; int video_interface; @@ -543,10 +536,6 @@ int read_vt(struct usb_device *, u16); int write_vt(struct usb_device *, u16, u16); int isdongle(struct easycap *); /*---------------------------------------------------------------------------*/ -struct signed_div_result { - long long int quotient; - unsigned long long int remainder; -} signed_div(long long int, long long int); /*---------------------------------------------------------------------------*/ diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c index 91262fbd69e..c99addfb624 100644 --- a/drivers/staging/easycap/easycap_ioctl.c +++ b/drivers/staging/easycap/easycap_ioctl.c @@ -931,7 +931,6 @@ static int adjust_mute(struct easycap *peasycap, int value) switch (peasycap->mute) { case 1: { peasycap->audio_idle = 1; - peasycap->timeval0.tv_sec = 0; SAM("adjusting mute: %i=peasycap->audio_idle\n", peasycap->audio_idle); return 0; @@ -2333,7 +2332,6 @@ long easycap_unlocked_ioctl(struct file *file, peasycap->video_idle = 1; peasycap->audio_idle = 1; - peasycap->timeval0.tv_sec = 0; /*---------------------------------------------------------------------------*/ /* * IF THE WAIT QUEUES ARE NOT CLEARED IN RESPONSE TO THE STREAMOFF COMMAND diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 17444a72ec9..a45c0b50706 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -270,7 +270,6 @@ static int reset(struct easycap *peasycap) peasycap->video_eof = 0; peasycap->audio_eof = 0; - do_gettimeofday(&peasycap->timeval7); /*---------------------------------------------------------------------------*/ /* * RESTORE INPUT AND FORCE REFRESH OF STANDARD, FORMAT, ETC. @@ -1215,10 +1214,6 @@ int easycap_dqbuf(struct easycap *peasycap, int mode) int field2frame(struct easycap *peasycap) { - struct timeval timeval; - long long int above, below; - u32 remainder; - struct signed_div_result sdr; void *pex, *pad; int kex, kad, mex, mad, rex, rad, rad2; @@ -1576,52 +1571,11 @@ field2frame(struct easycap *peasycap) if (peasycap->field_read == peasycap->field_fill) SAM("WARNING: on exit, filling field buffer %i\n", peasycap->field_read); -/*---------------------------------------------------------------------------*/ -/* - * CALCULATE VIDEO STREAMING RATE - */ -/*---------------------------------------------------------------------------*/ - do_gettimeofday(&timeval); - if (peasycap->timeval6.tv_sec) { - below = ((long long int)(1000000)) * - ((long long int)(timeval.tv_sec - - peasycap->timeval6.tv_sec)) + - (long long int)(timeval.tv_usec - peasycap->timeval6.tv_usec); - above = (long long int)1000000; - - sdr = signed_div(above, below); - above = sdr.quotient; - remainder = (u32)sdr.remainder; - - JOM(8, "video streaming at %3lli.%03i fields per second\n", - above, (remainder/1000)); - } - peasycap->timeval6 = timeval; if (caches) JOM(8, "%i=caches\n", caches); return 0; } -/*****************************************************************************/ -struct signed_div_result -signed_div(long long int above, long long int below) -{ - struct signed_div_result sdr; - - if (((0 <= above) && (0 <= below)) || ((0 > above) && (0 > below))) { - sdr.remainder = (unsigned long long int) do_div(above, below); - sdr.quotient = (long long int) above; - } else { - if (0 > above) - above = -above; - if (0 > below) - below = -below; - sdr.remainder = (unsigned long long int) do_div(above, below); - sdr.quotient = -((long long int) above); - } - return sdr; -} -/*****************************************************************************/ /*---------------------------------------------------------------------------*/ /* * DECIMATION AND COLOURSPACE CONVERSION. @@ -2755,8 +2709,6 @@ static void easycap_complete(struct urb *purb) wake_up_interruptible (&(peasycap-> wq_video)); - do_gettimeofday - (&peasycap->timeval7); } else { peasycap->video_junk++; if (bad & 0x0010) diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c index 213d0400b3e..b22bb39b5f6 100644 --- a/drivers/staging/easycap/easycap_sound.c +++ b/drivers/staging/easycap/easycap_sound.c @@ -666,9 +666,6 @@ easycap_sound_setup(struct easycap *peasycap) peasycap->audio_eof = 0; peasycap->audio_idle = 0; - peasycap->timeval1.tv_sec = 0; - peasycap->timeval1.tv_usec = 0; - submit_audio_urbs(peasycap); JOM(4, "finished initialization\n"); From 3b769edd58371fb70417c3f43c6d4a2da075703a Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Mon, 10 Oct 2011 11:35:45 +0200 Subject: [PATCH 1450/1519] staging/nvec: fix compilation error in nvec.c This fixes a compilation error in nvec.c due to the missing module.h include. Signed-off-by: Marc Dietrich Cc: Julian Andres Klode Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index fb0f0959eaf..e06b867d1e0 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -17,6 +17,7 @@ /* #define DEBUG */ #include +#include #include #include #include From 00bf256011d362e7d61824f3cda8514f5d48585d Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Wed, 12 Oct 2011 14:41:00 -0500 Subject: [PATCH 1451/1519] staging: zcache: remove zcache_direct_reclaim_lock zcache_do_preload() currently does a spin_trylock() on the zcache_direct_reclaim_lock. Holding this lock intends to prevent shrink_zcache_memory() from evicting zbud pages as a result of a preload. However, it also prevents two threads from executing zcache_do_preload() at the same time. The first thread will obtain the lock and the second thread's spin_trylock() will fail (an aborted preload) causing the page to be either lost (cleancache) or pushed out to the swap device (frontswap). It also doesn't ensure that the call to shrink_zcache_memory() is on the same thread as the call to zcache_do_preload(). Additional, there is no need for this mechanism because all zcache_do_preload() calls that come down from cleancache already have PF_MEMALLOC set in the process flags which prevents direct reclaim in the memory manager. If the zcache_do_preload() call is done from the frontswap path, we _want_ reclaim to be done (which it isn't right now). This patch removes the zcache_direct_reclaim_lock and related statistics in zcache. Based on v3.1-rc8 Signed-off-by: Seth Jennings Reviewed-by: Dave Hansen Acked-by: Dan Magenheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/zcache-main.c | 31 ++++------------------------ 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index 22b0a750649..3768bf2e8d9 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -962,15 +962,6 @@ out: static unsigned long zcache_failed_get_free_pages; static unsigned long zcache_failed_alloc; static unsigned long zcache_put_to_flush; -static unsigned long zcache_aborted_preload; -static unsigned long zcache_aborted_shrink; - -/* - * Ensure that memory allocation requests in zcache don't result - * in direct reclaim requests via the shrinker, which would cause - * an infinite loop. Maybe a GFP flag would be better? - */ -static DEFINE_SPINLOCK(zcache_direct_reclaim_lock); /* * for now, used named slabs so can easily track usage; later can @@ -1009,10 +1000,6 @@ static int zcache_do_preload(struct tmem_pool *pool) goto out; if (unlikely(zcache_obj_cache == NULL)) goto out; - if (!spin_trylock(&zcache_direct_reclaim_lock)) { - zcache_aborted_preload++; - goto out; - } preempt_disable(); kp = &__get_cpu_var(zcache_preloads); while (kp->nr < ARRAY_SIZE(kp->objnodes)) { @@ -1021,7 +1008,7 @@ static int zcache_do_preload(struct tmem_pool *pool) ZCACHE_GFP_MASK); if (unlikely(objnode == NULL)) { zcache_failed_alloc++; - goto unlock_out; + goto out; } preempt_disable(); kp = &__get_cpu_var(zcache_preloads); @@ -1034,13 +1021,13 @@ static int zcache_do_preload(struct tmem_pool *pool) obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); if (unlikely(obj == NULL)) { zcache_failed_alloc++; - goto unlock_out; + goto out; } page = (void *)__get_free_page(ZCACHE_GFP_MASK); if (unlikely(page == NULL)) { zcache_failed_get_free_pages++; kmem_cache_free(zcache_obj_cache, obj); - goto unlock_out; + goto out; } preempt_disable(); kp = &__get_cpu_var(zcache_preloads); @@ -1053,8 +1040,6 @@ static int zcache_do_preload(struct tmem_pool *pool) else free_page((unsigned long)page); ret = 0; -unlock_out: - spin_unlock(&zcache_direct_reclaim_lock); out: return ret; } @@ -1429,8 +1414,6 @@ ZCACHE_SYSFS_RO(evicted_buddied_pages); ZCACHE_SYSFS_RO(failed_get_free_pages); ZCACHE_SYSFS_RO(failed_alloc); ZCACHE_SYSFS_RO(put_to_flush); -ZCACHE_SYSFS_RO(aborted_preload); -ZCACHE_SYSFS_RO(aborted_shrink); ZCACHE_SYSFS_RO(compress_poor); ZCACHE_SYSFS_RO(mean_compress_poor); ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_raw_pages); @@ -1472,8 +1455,6 @@ static struct attribute *zcache_attrs[] = { &zcache_failed_get_free_pages_attr.attr, &zcache_failed_alloc_attr.attr, &zcache_put_to_flush_attr.attr, - &zcache_aborted_preload_attr.attr, - &zcache_aborted_shrink_attr.attr, &zcache_zbud_unbuddied_list_counts_attr.attr, &zcache_zbud_cumul_chunk_counts_attr.attr, &zcache_zv_curr_dist_counts_attr.attr, @@ -1513,11 +1494,7 @@ static int shrink_zcache_memory(struct shrinker *shrink, if (!(gfp_mask & __GFP_FS)) /* does this case really need to be skipped? */ goto out; - if (spin_trylock(&zcache_direct_reclaim_lock)) { - zbud_evict_pages(nr); - spin_unlock(&zcache_direct_reclaim_lock); - } else - zcache_aborted_shrink++; + zbud_evict_pages(nr); } ret = (int)atomic_read(&zcache_zbud_curr_raw_pages); out: From 40d1bac4ad26066bea7c790d9d33446838dc8b6d Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Fri, 14 Oct 2011 14:30:58 +0200 Subject: [PATCH 1452/1519] staging: drop unused Kconfig symbols Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/Kconfig | 9 --------- drivers/staging/pohmelfs/Kconfig | 8 -------- 2 files changed, 17 deletions(-) diff --git a/drivers/staging/et131x/Kconfig b/drivers/staging/et131x/Kconfig index e11cf340856..f0ed08d6a97 100644 --- a/drivers/staging/et131x/Kconfig +++ b/drivers/staging/et131x/Kconfig @@ -7,12 +7,3 @@ config ET131X To compile this driver as a module, choose M here. The module will be called et131x. - -config ET131X_DEBUG - bool "Enable et131x debugging" - depends on ET131X - default n - ---help--- - Say Y for detailed debug information. - - If in doubt, say N. diff --git a/drivers/staging/pohmelfs/Kconfig b/drivers/staging/pohmelfs/Kconfig index 58158b8780f..8d53b1a1e71 100644 --- a/drivers/staging/pohmelfs/Kconfig +++ b/drivers/staging/pohmelfs/Kconfig @@ -18,11 +18,3 @@ config POHMELFS_DEBUG Turns on excessive POHMELFS debugging facilities. You usually do not want to slow things down noticeably and get really lots of kernel messages in syslog. - -config POHMELFS_CRYPTO - bool "POHMELFS crypto support" - depends on POHMELFS - help - This option allows to encrypt and/or protect with strong - cryptographic hash all dataflow between server and clients. - Each config group can have its own keys. From 1f46902371c50f72ef422e19119b8e3c0b0b3ef6 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Fri, 14 Oct 2011 21:31:56 -0700 Subject: [PATCH 1453/1519] Staging: hv: mousevsc: Fix a checkpatch warning Fix a checkpatch warning. Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/hv_mouse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index c354ade76ef..ccd39c70c52 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -597,4 +597,3 @@ MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); module_init(mousevsc_init); module_exit(mousevsc_exit); - From 41098f8f1473cf853125d2fde2ce936879ef1adc Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Fri, 14 Oct 2011 21:31:57 -0700 Subject: [PATCH 1454/1519] Staging: hv: storvsc: Fix checkpatch warnings Fix checkpatch warnings. Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 1f9d23e48b2..ae8c33e7849 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -522,8 +522,9 @@ static void storvsc_on_io_completion(struct hv_device *device, if (vstor_packet->vm_srb.srb_status & 0x80) { /* autosense data available */ dev_warn(&device->device, - "storvsc pkt %p autosense data valid - len %d\n", - request, vstor_packet->vm_srb.sense_info_length); + "stor pkt %p autosense data valid - len %d\n", + request, + vstor_packet->vm_srb.sense_info_length); memcpy(request->sense_buffer, vstor_packet->vm_srb.sense_data, @@ -1128,13 +1129,13 @@ static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd) u8 scsi_op = scmnd->cmnd[0]; switch (scsi_op) { - /* smartd sends this command, which will offline the device */ - case SET_WINDOW: - scmnd->result = DID_ERROR << 16; - allowed = false; - break; - default: - break; + /* smartd sends this command, which will offline the device */ + case SET_WINDOW: + scmnd->result = DID_ERROR << 16; + allowed = false; + break; + default: + break; } return allowed; } From 3e2c96eab9278317569e2baf165f71042c927712 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 12 Oct 2011 10:57:33 +0100 Subject: [PATCH 1455/1519] staging:iio: gpio build dependency fixing Numerous drivers either had pointless includes of gpio.h or should have been dependent on GENERIC_GPIO and were not. Conversion of ads1210 to use array registration triggered build failures that highlighted all was not well. Signed-off-by: Jonathan Cameron Reported-by: Randy Dunlap Acked-by: Randy Dunlap Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/Kconfig | 1 + drivers/staging/iio/accel/adis16204_core.c | 1 - drivers/staging/iio/accel/sca3000_core.c | 7 +++---- drivers/staging/iio/adc/Kconfig | 1 + drivers/staging/iio/addac/Kconfig | 1 + drivers/staging/iio/dac/ad5504.c | 1 - drivers/staging/iio/dac/ad5624r_spi.c | 1 - drivers/staging/iio/dac/ad5686.c | 1 - drivers/staging/iio/dac/ad5791.c | 1 - drivers/staging/iio/gyro/adis16080_core.c | 1 - drivers/staging/iio/gyro/adis16260_core.c | 1 - drivers/staging/iio/gyro/adxrs450_core.c | 1 - drivers/staging/iio/magnetometer/Kconfig | 1 + drivers/staging/iio/meter/ade7753.c | 1 - drivers/staging/iio/meter/ade7754.c | 1 - drivers/staging/iio/meter/ade7758_core.c | 1 - drivers/staging/iio/meter/ade7759.c | 1 - drivers/staging/iio/meter/ade7854.c | 1 - drivers/staging/iio/resolver/Kconfig | 2 ++ 19 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index 71f873997b0..5ab71670b70 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -67,6 +67,7 @@ config LIS3L02DQ depends on SPI select IIO_TRIGGER if IIO_BUFFER depends on !IIO_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING + depends on GENERIC_GPIO help Say yes here to build SPI support for the ST microelectronics accelerometer. The driver supplies direct access via sysfs files diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 2ca617d31bd..1b8b5940895 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index f2cdb1f3857..edc62eeddcd 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -11,7 +11,6 @@ */ #include -#include #include #include #include @@ -1167,7 +1166,7 @@ static int __devinit sca3000_probe(struct spi_device *spi) iio_scan_mask_set(indio_dev->buffer, 2); } - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { + if (spi->irq) { ret = request_threaded_irq(spi->irq, NULL, &sca3000_event_handler, @@ -1184,7 +1183,7 @@ static int __devinit sca3000_probe(struct spi_device *spi) return 0; error_free_irq: - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) + if (spi->irq) free_irq(spi->irq, indio_dev); error_unregister_ring: iio_buffer_unregister(indio_dev); @@ -1226,7 +1225,7 @@ static int sca3000_remove(struct spi_device *spi) ret = sca3000_stop_all_interrupts(st); if (ret) return ret; - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) + if (spi->irq) free_irq(spi->irq, indio_dev); iio_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 2c1b7ded701..3bf975ac5d9 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -150,6 +150,7 @@ config AD7746 config AD7816 tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver" depends on SPI + depends on GENERIC_GPIO help Say yes here to build support for Analog Devices AD7816/7/8 temperature sensors and ADC. diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig index 869540e6af8..4b763753454 100644 --- a/drivers/staging/iio/addac/Kconfig +++ b/drivers/staging/iio/addac/Kconfig @@ -5,6 +5,7 @@ menu "Analog digital bi-direction convertors" config ADT7316 tristate "Analog Devices ADT7316/7/8 ADT7516/7/9 temperature sensor, ADC and DAC driver" + depends on GENERIC_GPIO help Say yes here to build support for Analog Devices ADT7316, ADT7317, ADT7318 and ADT7516, ADT7517, ADT7519 temperature sensors, ADC and DAC. diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index a430874ee7c..c33643f28cb 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index 8e7fafb6cc4..2d2c946ba80 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index adf898f2492..fa59bfc9bc5 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 6c34700b9ed..8b1b1b543a8 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index 07b013a1159..1ca4506a666 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -5,7 +5,6 @@ * * Licensed under the GPL-2 or later. */ -#include #include #include #include diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index dc440d15f86..ccbf2262c4c 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 1fda3db1739..912baa15c8c 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig index b8c149db293..722c4e13f71 100644 --- a/drivers/staging/iio/magnetometer/Kconfig +++ b/drivers/staging/iio/magnetometer/Kconfig @@ -6,6 +6,7 @@ menu "Magnetometer sensors" config SENSORS_AK8975 tristate "Asahi Kasei AK8975 3-Axis Magnetometer" depends on I2C + depends on GENERIC_GPIO help Say yes here to build support for Asahi Kasei AK8975 3-Axis Magnetometer. diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 3d62bfdde97..3be88f28ef9 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index cdb62a40a42..f7b20a22082 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 3f31368e3d8..6ea5c740f78 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 69b1f8bba3d..511a60500d9 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index bc1f83eea7c..d438c038e00 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index 90b3bbcd875..49f69ef986f 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -13,6 +13,7 @@ config AD2S90 config AD2S1200 tristate "Analog Devices ad2s1200/ad2s1205 driver" depends on SPI + depends on GENERIC_GPIO help Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s1200 and ad2s1205, provides direct access @@ -21,6 +22,7 @@ config AD2S1200 config AD2S1210 tristate "Analog Devices ad2s1210 driver" depends on SPI + depends on GENERIC_GPIO help Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s1210, provides direct access via sysfs. From cdea0bec8d37f2943ae500512b0c178bc76de6e3 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 14 Oct 2011 09:00:44 +0200 Subject: [PATCH 1456/1519] iio: adc: remove ADT75 driver - hwmon/lm75 will take over ADT75 support Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/Kconfig | 7 - drivers/staging/iio/adc/Makefile | 1 - drivers/staging/iio/adc/adt75.c | 655 ------------------------------- 3 files changed, 663 deletions(-) delete mode 100644 drivers/staging/iio/adc/adt75.c diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 3bf975ac5d9..bfe91d77fe7 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -169,13 +169,6 @@ config AD7192 To compile this driver as a module, choose M here: the module will be called ad7192. -config ADT75 - tristate "Analog Devices ADT75 temperature sensor driver" - depends on I2C - help - Say yes here to build support for Analog Devices ADT75 - temperature sensors. - config ADT7310 tristate "Analog Devices ADT7310 temperature sensor driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 93dc84bee26..be7faaa2465 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -37,7 +37,6 @@ obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7816) += ad7816.o obj-$(CONFIG_AD7192) += ad7192.o -obj-$(CONFIG_ADT75) += adt75.o obj-$(CONFIG_ADT7310) += adt7310.o obj-$(CONFIG_ADT7410) += adt7410.o obj-$(CONFIG_AD7280) += ad7280a.o diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c deleted file mode 100644 index 08215e9edc8..00000000000 --- a/drivers/staging/iio/adc/adt75.c +++ /dev/null @@ -1,655 +0,0 @@ -/* - * ADT75 digital temperature sensor driver supporting ADT75 - * - * Copyright 2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../iio.h" -#include "../sysfs.h" - -/* - * ADT75 registers definition - */ - -#define ADT75_TEMPERATURE 0 -#define ADT75_CONFIG 1 -#define ADT75_T_HYST 2 -#define ADT75_T_OS 3 -#define ADT75_ONESHOT 4 - -/* - * ADT75 config - */ -#define ADT75_PD 0x1 -#define ADT75_OS_INT 0x2 -#define ADT75_OS_POLARITY 0x4 -#define ADT75_FAULT_QUEUE_MASK 0x18 -#define ADT75_FAULT_QUEUE_OFFSET 3 -#define ADT75_SMBUS_ALART 0x8 - -/* - * ADT75 masks - */ -#define ADT75_VALUE_SIGN 0x800 -#define ADT75_VALUE_OFFSET 4 -#define ADT75_VALUE_FLOAT_OFFSET 4 -#define ADT75_VALUE_FLOAT_MASK 0xF - - -/* - * struct adt75_chip_info - chip specifc information - */ - -struct adt75_chip_info { - struct i2c_client *client; - u8 config; -}; - -/* - * adt75 register access by I2C - */ - -static int adt75_i2c_read(struct iio_dev *dev_info, u8 reg, u8 *data) -{ - struct adt75_chip_info *chip = iio_priv(dev_info); - struct i2c_client *client = chip->client; - int ret = 0, len; - - ret = i2c_smbus_write_byte(client, reg); - if (ret < 0) { - dev_err(&client->dev, "I2C read register address error\n"); - return ret; - } - - if (reg == ADT75_CONFIG || reg == ADT75_ONESHOT) - len = 1; - else - len = 2; - - ret = i2c_master_recv(client, data, len); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - return ret; -} - -static int adt75_i2c_write(struct iio_dev *dev_info, u8 reg, u8 data) -{ - struct adt75_chip_info *chip = iio_priv(dev_info); - struct i2c_client *client = chip->client; - int ret = 0; - - if (reg == ADT75_CONFIG || reg == ADT75_ONESHOT) - ret = i2c_smbus_write_byte_data(client, reg, data); - else - ret = i2c_smbus_write_word_data(client, reg, data); - - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static ssize_t adt75_show_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct adt75_chip_info *chip = iio_priv(dev_get_drvdata(dev)); - - if (chip->config & ADT75_PD) - return sprintf(buf, "power-save\n"); - else - return sprintf(buf, "full\n"); -} - -static ssize_t adt75_store_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - int ret; - u8 config; - - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - config = chip->config & ~ADT75_PD; - if (!strcmp(buf, "full")) - config |= ADT75_PD; - - ret = adt75_i2c_write(dev_info, ADT75_CONFIG, config); - if (ret) - return -EIO; - - chip->config = config; - - return ret; -} - -static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, - adt75_show_mode, - adt75_store_mode, - 0); - -static ssize_t adt75_show_available_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "full\npower-down\n"); -} - -static IIO_DEVICE_ATTR(available_modes, S_IRUGO, adt75_show_available_modes, NULL, 0); - -static ssize_t adt75_show_oneshot(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct adt75_chip_info *chip = iio_priv(dev_get_drvdata(dev)); - - return sprintf(buf, "%d\n", !!(chip->config & ADT75_ONESHOT)); -} - -static ssize_t adt75_store_oneshot(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - unsigned long data = 0; - int ret; - u8 config; - - ret = strict_strtoul(buf, 10, &data); - if (ret) - return -EINVAL; - - - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - config = chip->config & ~ADT75_ONESHOT; - if (data) - config |= ADT75_ONESHOT; - - ret = adt75_i2c_write(dev_info, ADT75_CONFIG, config); - if (ret) - return -EIO; - - chip->config = config; - - return ret; -} - -static IIO_DEVICE_ATTR(oneshot, S_IRUGO | S_IWUSR, - adt75_show_oneshot, - adt75_store_oneshot, - 0); - -static ssize_t adt75_show_value(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - u16 data; - char sign = ' '; - int ret; - - if (chip->config & ADT75_PD) { - dev_err(dev, "Can't read value in power-down mode.\n"); - return -EIO; - } - - if (chip->config & ADT75_ONESHOT) { - /* write to active converter */ - ret = i2c_smbus_write_byte(chip->client, ADT75_ONESHOT); - if (ret) - return -EIO; - } - - ret = adt75_i2c_read(dev_info, ADT75_TEMPERATURE, (u8 *)&data); - if (ret) - return -EIO; - - data = swab16(data) >> ADT75_VALUE_OFFSET; - if (data & ADT75_VALUE_SIGN) { - /* convert supplement to positive value */ - data = (ADT75_VALUE_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.4d\n", sign, - (data >> ADT75_VALUE_FLOAT_OFFSET), - (data & ADT75_VALUE_FLOAT_MASK) * 625); -} - -static IIO_DEVICE_ATTR(value, S_IRUGO, adt75_show_value, NULL, 0); - -static struct attribute *adt75_attributes[] = { - &iio_dev_attr_available_modes.dev_attr.attr, - &iio_dev_attr_mode.dev_attr.attr, - &iio_dev_attr_oneshot.dev_attr.attr, - &iio_dev_attr_value.dev_attr.attr, - NULL, -}; - -static const struct attribute_group adt75_attribute_group = { - .attrs = adt75_attributes, -}; - -/* - * temperature bound events - */ - -#define IIO_EVENT_CODE_ADT75_OTI IIO_UNMOD_EVENT_CODE(IIO_TEMP, \ - 0, \ - IIO_EV_TYPE_THRESH, \ - IIO_EV_DIR_FALLING) - -static irqreturn_t adt75_event_handler(int irq, void *private) -{ - iio_push_event(private, - IIO_EVENT_CODE_ADT75_OTI, - iio_get_time_ns()); - - return IRQ_HANDLED; -} - -static ssize_t adt75_show_oti_mode(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - int ret; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - if (chip->config & ADT75_OS_INT) - return sprintf(buf, "interrupt\n"); - else - return sprintf(buf, "comparator\n"); -} - -static ssize_t adt75_set_oti_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - int ret; - u8 config; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - config = chip->config & ~ADT75_OS_INT; - if (strcmp(buf, "comparator") != 0) - config |= ADT75_OS_INT; - - ret = adt75_i2c_write(dev_info, ADT75_CONFIG, config); - if (ret) - return -EIO; - - chip->config = config; - - return ret; -} - -static ssize_t adt75_show_available_oti_modes(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "comparator\ninterrupt\n"); -} - -static ssize_t adt75_show_smbus_alart(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - int ret; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - return sprintf(buf, "%d\n", !!(chip->config & ADT75_SMBUS_ALART)); -} - -static ssize_t adt75_set_smbus_alart(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - unsigned long data = 0; - int ret; - u8 config; - - ret = strict_strtoul(buf, 10, &data); - if (ret) - return -EINVAL; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - config = chip->config & ~ADT75_SMBUS_ALART; - if (data) - config |= ADT75_SMBUS_ALART; - - ret = adt75_i2c_write(dev_info, ADT75_CONFIG, config); - if (ret) - return -EIO; - - chip->config = config; - - return ret; -} - -static ssize_t adt75_show_fault_queue(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - int ret; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - return sprintf(buf, "%d\n", (chip->config & ADT75_FAULT_QUEUE_MASK) >> - ADT75_FAULT_QUEUE_OFFSET); -} - -static ssize_t adt75_set_fault_queue(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct adt75_chip_info *chip = iio_priv(dev_info); - unsigned long data; - int ret; - u8 config; - - ret = strict_strtoul(buf, 10, &data); - if (ret || data > 3) - return -EINVAL; - - /* retrive ALART status */ - ret = adt75_i2c_read(dev_info, ADT75_CONFIG, &chip->config); - if (ret) - return -EIO; - - config = chip->config & ~ADT75_FAULT_QUEUE_MASK; - config |= (data << ADT75_FAULT_QUEUE_OFFSET); - ret = adt75_i2c_write(dev_info, ADT75_CONFIG, config); - if (ret) - return -EIO; - - chip->config = config; - - return ret; -} -static inline ssize_t adt75_show_t_bound(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *dev_info = dev_get_drvdata(dev); - u16 data; - char sign = ' '; - int ret; - - ret = adt75_i2c_read(dev_info, this_attr->address, (u8 *)&data); - if (ret) - return -EIO; - - data = swab16(data) >> ADT75_VALUE_OFFSET; - if (data & ADT75_VALUE_SIGN) { - /* convert supplement to positive value */ - data = (ADT75_VALUE_SIGN << 1) - data; - sign = '-'; - } - - return sprintf(buf, "%c%d.%.4d\n", sign, - (data >> ADT75_VALUE_FLOAT_OFFSET), - (data & ADT75_VALUE_FLOAT_MASK) * 625); -} - -static inline ssize_t adt75_set_t_bound(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - struct iio_dev *dev_info = dev_get_drvdata(dev); - long tmp1, tmp2; - u16 data; - char *pos; - int ret; - - pos = strchr(buf, '.'); - - ret = strict_strtol(buf, 10, &tmp1); - - if (ret || tmp1 > 127 || tmp1 < -128) - return -EINVAL; - - if (pos) { - len = strlen(pos); - if (len > ADT75_VALUE_FLOAT_OFFSET) - len = ADT75_VALUE_FLOAT_OFFSET; - pos[len] = 0; - ret = strict_strtol(pos, 10, &tmp2); - - if (!ret) - tmp2 = (tmp2 / 625) * 625; - } - - if (tmp1 < 0) - data = (u16)(-tmp1); - else - data = (u16)tmp1; - data = (data << ADT75_VALUE_FLOAT_OFFSET) | (tmp2 & ADT75_VALUE_FLOAT_MASK); - if (tmp1 < 0) - /* convert positive value to supplyment */ - data = (ADT75_VALUE_SIGN << 1) - data; - data <<= ADT75_VALUE_OFFSET; - data = swab16(data); - - ret = adt75_i2c_write(dev_info, this_attr->address, (u8)data); - if (ret) - return -EIO; - - return ret; -} - - -static IIO_DEVICE_ATTR(oti_mode, - S_IRUGO | S_IWUSR, - adt75_show_oti_mode, adt75_set_oti_mode, 0); -static IIO_DEVICE_ATTR(available_oti_modes, - S_IRUGO, - adt75_show_available_oti_modes, NULL, 0); -static IIO_DEVICE_ATTR(smbus_alart, - S_IRUGO | S_IWUSR, - adt75_show_smbus_alart, adt75_set_smbus_alart, 0); -static IIO_DEVICE_ATTR(fault_queue, - S_IRUGO | S_IWUSR, - adt75_show_fault_queue, adt75_set_fault_queue, 0); -static IIO_DEVICE_ATTR(t_os_value, - S_IRUGO | S_IWUSR, - adt75_show_t_bound, adt75_set_t_bound, - ADT75_T_OS); -static IIO_DEVICE_ATTR(t_hyst_value, - S_IRUGO | S_IWUSR, - adt75_show_t_bound, adt75_set_t_bound, - ADT75_T_HYST); - -static struct attribute *adt75_event_attributes[] = { - &iio_dev_attr_oti_mode.dev_attr.attr, - &iio_dev_attr_available_oti_modes.dev_attr.attr, - &iio_dev_attr_smbus_alart.dev_attr.attr, - &iio_dev_attr_fault_queue.dev_attr.attr, - &iio_dev_attr_t_os_value.dev_attr.attr, - &iio_dev_attr_t_hyst_value.dev_attr.attr, - NULL, -}; - -static struct attribute_group adt75_event_attribute_group = { - .attrs = adt75_event_attributes, - .name = "events", -}; - -static const struct iio_info adt75_info = { - .attrs = &adt75_attribute_group, - .event_attrs = &adt75_event_attribute_group, - .driver_module = THIS_MODULE, -}; - -/* - * device probe and remove - */ - -static int __devinit adt75_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct adt75_chip_info *chip; - struct iio_dev *indio_dev; - int ret = 0; - - indio_dev = iio_allocate_device(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - chip = iio_priv(indio_dev); - - /* this is only used for device removal purposes */ - i2c_set_clientdata(client, indio_dev); - - chip->client = client; - - indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; - indio_dev->info = &adt75_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - if (client->irq > 0) { - ret = request_threaded_irq(client->irq, - NULL, - &adt75_event_handler, - IRQF_TRIGGER_LOW, - indio_dev->name, - indio_dev); - if (ret) - goto error_free_dev; - - ret = adt75_i2c_read(indio_dev, ADT75_CONFIG, &chip->config); - if (ret) { - ret = -EIO; - goto error_unreg_irq; - } - - /* set irq polarity low level */ - chip->config &= ~ADT75_OS_POLARITY; - - ret = adt75_i2c_write(indio_dev, ADT75_CONFIG, chip->config); - if (ret) { - ret = -EIO; - goto error_unreg_irq; - } - } - - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_irq; - - dev_info(&client->dev, "%s temperature sensor registered.\n", - indio_dev->name); - - return 0; -error_unreg_irq: - free_irq(client->irq, indio_dev); -error_free_dev: - iio_free_device(indio_dev); -error_ret: - return ret; -} - -static int __devexit adt75_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - if (client->irq) - free_irq(client->irq, indio_dev); - iio_device_unregister(indio_dev); - - return 0; -} - -static const struct i2c_device_id adt75_id[] = { - { "adt75", 0 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, adt75_id); - -static struct i2c_driver adt75_driver = { - .driver = { - .name = "adt75", - }, - .probe = adt75_probe, - .remove = __devexit_p(adt75_remove), - .id_table = adt75_id, -}; - -static __init int adt75_init(void) -{ - return i2c_add_driver(&adt75_driver); -} - -static __exit void adt75_exit(void) -{ - i2c_del_driver(&adt75_driver); -} - -MODULE_AUTHOR("Sonic Zhang "); -MODULE_DESCRIPTION("Analog Devices ADT75 digital" - " temperature sensor driver"); -MODULE_LICENSE("GPL v2"); - -module_init(adt75_init); -module_exit(adt75_exit); From d2fffd6c2fd60fe9ab63ef30758d9d43a5057549 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 14 Oct 2011 14:46:58 +0100 Subject: [PATCH 1457/1519] staging:iio: fix removal path to allow correct freeing. Fix a dumb lack of consideration of the effect of combining the iio_device_unregister and iio_free_device calls into one. There is no valid place to free some of the sysfs array elements. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16201_core.c | 3 ++- drivers/staging/iio/accel/adis16203_core.c | 3 ++- drivers/staging/iio/accel/adis16204_core.c | 3 ++- drivers/staging/iio/accel/adis16209_core.c | 3 ++- drivers/staging/iio/accel/adis16220_core.c | 13 +++++----- drivers/staging/iio/accel/adis16240_core.c | 3 ++- drivers/staging/iio/accel/kxsd9.c | 1 + drivers/staging/iio/accel/lis3l02dq_core.c | 7 ++--- drivers/staging/iio/accel/sca3000_core.c | 13 +++++----- drivers/staging/iio/adc/ad7150.c | 3 ++- drivers/staging/iio/adc/ad7152.c | 1 + drivers/staging/iio/adc/ad7192.c | 26 +++++++------------ drivers/staging/iio/adc/ad7280a.c | 19 +++++++------- drivers/staging/iio/adc/ad7291.c | 4 ++- drivers/staging/iio/adc/ad7298_core.c | 4 +-- drivers/staging/iio/adc/ad7476_core.c | 3 ++- drivers/staging/iio/adc/ad7606_core.c | 3 ++- drivers/staging/iio/adc/ad7746.c | 1 + drivers/staging/iio/adc/ad7780.c | 3 ++- drivers/staging/iio/adc/ad7793.c | 3 ++- drivers/staging/iio/adc/ad7816.c | 3 ++- drivers/staging/iio/adc/ad7887_core.c | 3 ++- drivers/staging/iio/adc/ad799x_core.c | 3 ++- drivers/staging/iio/adc/adt7310.c | 3 ++- drivers/staging/iio/adc/adt7410.c | 3 ++- drivers/staging/iio/adc/max1363_core.c | 3 ++- drivers/staging/iio/addac/adt7316.c | 3 ++- drivers/staging/iio/dac/ad5446.c | 9 ++++--- drivers/staging/iio/dac/ad5504.c | 4 +-- drivers/staging/iio/dac/ad5624r_spi.c | 3 ++- drivers/staging/iio/dac/ad5686.c | 4 +-- drivers/staging/iio/dac/ad5791.c | 5 ++-- drivers/staging/iio/dds/ad5930.c | 1 + drivers/staging/iio/dds/ad9832.c | 9 ++++--- drivers/staging/iio/dds/ad9834.c | 8 +++--- drivers/staging/iio/dds/ad9850.c | 1 + drivers/staging/iio/dds/ad9852.c | 1 + drivers/staging/iio/dds/ad9910.c | 1 + drivers/staging/iio/dds/ad9951.c | 1 + drivers/staging/iio/gyro/adis16060_core.c | 1 + drivers/staging/iio/gyro/adis16080_core.c | 1 + drivers/staging/iio/gyro/adis16130_core.c | 1 + drivers/staging/iio/gyro/adis16260_core.c | 4 ++- drivers/staging/iio/gyro/adxrs450_core.c | 11 +++----- .../staging/iio/impedance-analyzer/ad5933.c | 3 ++- drivers/staging/iio/imu/adis16400_core.c | 3 ++- drivers/staging/iio/industrialio-core.c | 3 --- drivers/staging/iio/light/isl29018.c | 1 + drivers/staging/iio/light/tsl2563.c | 5 +++- drivers/staging/iio/light/tsl2583.c | 1 + drivers/staging/iio/magnetometer/ak8975.c | 7 ++--- drivers/staging/iio/magnetometer/hmc5843.c | 4 ++- drivers/staging/iio/meter/ade7753.c | 5 ++-- drivers/staging/iio/meter/ade7754.c | 3 ++- drivers/staging/iio/meter/ade7758_core.c | 5 ++-- drivers/staging/iio/meter/ade7759.c | 3 ++- drivers/staging/iio/meter/ade7854.c | 1 + drivers/staging/iio/resolver/ad2s1200.c | 1 + drivers/staging/iio/resolver/ad2s1210.c | 4 +-- drivers/staging/iio/resolver/ad2s90.c | 1 + 60 files changed, 146 insertions(+), 109 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index d7ec5052905..1c5dad53784 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -532,10 +532,11 @@ static int adis16201_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); adis16201_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16201_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 2ffcf4ed3dd..8a3337442af 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -487,10 +487,11 @@ static int adis16203_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); adis16203_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16203_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 1b8b5940895..644ac8e4d2a 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -560,10 +560,11 @@ static int adis16204_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); adis16204_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16204_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index d03ac01c8d5..0a8571b18b3 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -536,10 +536,11 @@ static int adis16209_remove(struct spi_device *spi) flush_scheduled_work(); + iio_device_unregister(indio_dev); adis16209_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16209_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 15f5f301068..6d4503de192 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -624,7 +624,7 @@ static const struct iio_info adis16220_info = { static int __devinit adis16220_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adis16220_state *st; struct iio_dev *indio_dev; @@ -652,11 +652,10 @@ static int __devinit adis16220_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - regdone = 1; ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin); if (ret) - goto error_free_dev; + goto error_unregister_dev; ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin); if (ret) @@ -678,11 +677,10 @@ error_rm_adc1_bin: sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); error_rm_accel_bin: sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); +error_unregister_dev: + iio_device_unregister(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } @@ -697,6 +695,7 @@ static int adis16220_remove(struct spi_device *spi) sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index ee1e873f177..b8be2925d61 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -589,10 +589,11 @@ static int adis16240_remove(struct spi_device *spi) flush_scheduled_work(); + iio_device_unregister(indio_dev); adis16240_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16240_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index eeee808f7f0..5238503f680 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c @@ -262,6 +262,7 @@ error_ret: static int __devexit kxsd9_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 737dd97f44a..559545a4233 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -736,7 +736,7 @@ error_uninitialize_buffer: error_unreg_buffer_funcs: lis3l02dq_unconfigure_buffer(indio_dev); error_free_dev: - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } @@ -774,6 +774,8 @@ static int lis3l02dq_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct lis3l02dq_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); + ret = lis3l02dq_disable_all_events(indio_dev); if (ret) goto err_ret; @@ -789,8 +791,7 @@ static int lis3l02dq_remove(struct spi_device *spi) iio_buffer_unregister(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev); - iio_device_unregister(indio_dev); - + iio_free_device(indio_dev); err_ret: return ret; } diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index edc62eeddcd..a44a70589db 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1122,7 +1122,7 @@ static const struct iio_info sca3000_info_with_temp = { static int __devinit sca3000_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct sca3000_state *st; struct iio_dev *indio_dev; @@ -1154,7 +1154,7 @@ static int __devinit sca3000_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret < 0) goto error_free_dev; - regdone = 1; + ret = iio_buffer_register(indio_dev, sca3000_channels, ARRAY_SIZE(sca3000_channels)); @@ -1188,11 +1188,9 @@ error_free_irq: error_unregister_ring: iio_buffer_unregister(indio_dev); error_unregister_dev: + iio_device_unregister(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; @@ -1227,9 +1225,10 @@ static int sca3000_remove(struct spi_device *spi) return ret; if (spi->irq) free_irq(spi->irq, indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 7d0509682fb..e185f0e052a 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -628,13 +628,14 @@ static int __devexit ad7150_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + iio_device_unregister(indio_dev); if (client->irq) free_irq(client->irq, indio_dev); if (client->dev.platform_data) free_irq(*(unsigned int *)client->dev.platform_data, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index f980a093882..662584d72a7 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -519,6 +519,7 @@ static int __devexit ad7152_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 29258f4a095..31c376b9d5e 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -1032,7 +1032,7 @@ static int __devinit ad7192_probe(struct spi_device *spi) struct ad7192_platform_data *pdata = spi->dev.platform_data; struct ad7192_state *st; struct iio_dev *indio_dev; - int ret, i , voltage_uv = 0, regdone = 0; + int ret, i , voltage_uv = 0; if (!pdata) { dev_err(&spi->dev, "no platform data?\n"); @@ -1090,14 +1090,9 @@ static int __devinit ad7192_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring; - regdone = 1; - ret = ad7192_probe_trigger(indio_dev); if (ret) - goto error_unreg_ring; + goto error_ring_cleanup; ret = iio_buffer_register(indio_dev, indio_dev->channels, @@ -1107,15 +1102,18 @@ static int __devinit ad7192_probe(struct spi_device *spi) ret = ad7192_setup(st); if (ret) - goto error_uninitialize_ring; + goto error_unreg_ring; + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_unreg_ring; return 0; -error_uninitialize_ring: +error_unreg_ring: iio_buffer_unregister(indio_dev); error_remove_trigger: ad7192_remove_trigger(indio_dev); -error_unreg_ring: +error_ring_cleanup: ad7192_ring_cleanup(indio_dev); error_disable_reg: if (!IS_ERR(st->reg)) @@ -1124,10 +1122,7 @@ error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } @@ -1137,6 +1132,7 @@ static int ad7192_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7192_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7192_remove_trigger(indio_dev); ad7192_ring_cleanup(indio_dev); @@ -1146,8 +1142,6 @@ static int ad7192_remove(struct spi_device *spi) regulator_put(st->reg); } - iio_device_unregister(indio_dev); - return 0; } diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 386834a9b69..372d059042f 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -831,7 +831,7 @@ static int __devinit ad7280_probe(struct spi_device *spi) { const struct ad7280_platform_data *pdata = spi->dev.platform_data; struct ad7280_state *st; - int ret, regdone = 0; + int ret; const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890}; const unsigned short nAVG[4] = {1, 2, 4, 8}; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -903,21 +903,20 @@ static int __devinit ad7280_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_attr; - regdone = 1; if (spi->irq > 0) { ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_ALERT, 1, AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN); if (ret) - goto error_free_attr; + goto error_unregister; ret = ad7280_write(st, AD7280A_DEVADDR(st->slave_num), AD7280A_ALERT, 0, AD7280A_ALERT_GEN_STATIC_HIGH | (pdata->chain_last_alert_ignore & 0xF)); if (ret) - goto error_free_attr; + goto error_unregister; ret = request_threaded_irq(spi->irq, NULL, @@ -927,10 +926,12 @@ static int __devinit ad7280_probe(struct spi_device *spi) indio_dev->name, indio_dev); if (ret) - goto error_free_attr; + goto error_unregister; } return 0; +error_unregister: + iio_device_unregister(indio_dev); error_free_attr: kfree(st->iio_attr); @@ -939,10 +940,7 @@ error_free_channels: kfree(st->channels); error_free_device: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } @@ -954,13 +952,14 @@ static int __devexit ad7280_remove(struct spi_device *spi) if (spi->irq > 0) free_irq(spi->irq, indio_dev); + iio_device_unregister(indio_dev); ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); kfree(st->channels); kfree(st->iio_attr); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index acdce8c5092..10e79e8ee64 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -670,6 +670,8 @@ static int __devexit ad7291_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad7291_chip_info *chip = iio_priv(indio_dev); + iio_device_unregister(indio_dev); + if (client->irq) free_irq(client->irq, indio_dev); @@ -678,7 +680,7 @@ static int __devexit ad7291_remove(struct i2c_client *client) regulator_put(chip->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index b77272722f5..c1de73a1ca9 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -249,14 +249,14 @@ static int __devexit ad7298_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7298_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7298_ring_cleanup(indio_dev); - iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 1953dbf2cbd..fd79facc6ca 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -211,13 +211,14 @@ static int ad7476_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7476_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7476_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 3c0fb729891..54423ab196f 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -545,6 +545,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq) { struct ad7606_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7606_ring_cleanup(indio_dev); @@ -555,7 +556,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq) } ad7606_free_gpios(st); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7746.c b/drivers/staging/iio/adc/ad7746.c index 3fe0c1715dc..2867943309c 100644 --- a/drivers/staging/iio/adc/ad7746.c +++ b/drivers/staging/iio/adc/ad7746.c @@ -766,6 +766,7 @@ static int __devexit ad7746_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index a8103c06e74..7a579a1fd69 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -255,13 +255,14 @@ static int ad7780_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7780_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); free_irq(spi->irq, st); gpio_free(st->pdata->gpio_pdrst); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 0a536c5ff36..a831b92cd08 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -1013,6 +1013,7 @@ static int ad7793_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7793_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7793_remove_trigger(indio_dev); ad7793_ring_cleanup(indio_dev); @@ -1022,7 +1023,7 @@ static int ad7793_remove(struct spi_device *spi) regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 1440619d74e..bdb90492b8a 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -435,13 +435,14 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev) struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); + iio_device_unregister(indio_dev); dev_set_drvdata(&spi_dev->dev, NULL); if (spi_dev->irq) free_irq(spi_dev->irq, indio_dev); gpio_free(chip->busy_pin); gpio_free(chip->convert_pin); gpio_free(chip->rdwr_pin); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 9456c032c05..609dcd5f2dd 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -230,13 +230,14 @@ static int ad7887_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7887_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7887_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 2d60539b4e4..ee6cd792bec 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -892,6 +892,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad799x_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (client->irq > 0) free_irq(client->irq, indio_dev); @@ -901,7 +902,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index cbbd34922d4..c9e0be3b1cf 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -856,12 +856,13 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev) struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); unsigned long *adt7310_platform_data = spi_dev->dev.platform_data; + iio_device_unregister(indio_dev); dev_set_drvdata(&spi_dev->dev, NULL); if (adt7310_platform_data[0]) free_irq(adt7310_platform_data[0], indio_dev); if (spi_dev->irq) free_irq(spi_dev->irq, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index cc913bc3510..a289e429dc4 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -819,11 +819,12 @@ static int __devexit adt7410_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); unsigned long *adt7410_platform_data = client->dev.platform_data; + iio_device_unregister(indio_dev); if (adt7410_platform_data[0]) free_irq(adt7410_platform_data[0], indio_dev); if (client->irq) free_irq(client->irq, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index e962f8412d3..12db93efaf8 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1347,6 +1347,7 @@ static int max1363_remove(struct i2c_client *client) struct max1363_state *st = iio_priv(indio_dev); struct regulator *reg = st->reg; + iio_device_unregister(indio_dev); if (client->irq) free_irq(st->client->irq, indio_dev); iio_buffer_unregister(indio_dev); @@ -1356,7 +1357,7 @@ static int max1363_remove(struct i2c_client *client) regulator_disable(reg); regulator_put(reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index d37726e5bde..8df24704ff2 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2219,9 +2219,10 @@ int __devexit adt7316_remove(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adt7316_chip_info *chip = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (chip->bus.irq) free_irq(chip->bus.irq, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index dc98867a160..e1c204d51d8 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -424,13 +424,14 @@ static int ad5446_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5446_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; iio_device_unregister(indio_dev); - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_free_device(indio_dev); + return 0; } diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index c33643f28cb..60dd6404d68 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -349,6 +349,7 @@ static int __devexit ad5504_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5504_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (spi->irq) free_irq(spi->irq, indio_dev); @@ -356,8 +357,7 @@ static int __devexit ad5504_remove(struct spi_device *spi) regulator_disable(st->reg); regulator_put(st->reg); } - - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index 2d2c946ba80..284d8790036 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -288,11 +288,12 @@ static int __devexit ad5624r_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5624r_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index fa59bfc9bc5..1d50dd17621 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -420,12 +420,12 @@ static int __devexit ad5686_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5686_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 8b1b1b543a8..fbf446d5671 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -370,6 +370,7 @@ static int __devexit ad5791_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5791_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (!IS_ERR(st->reg_vdd)) { regulator_disable(st->reg_vdd); regulator_put(st->reg_vdd); @@ -379,9 +380,7 @@ static int __devexit ad5791_remove(struct spi_device *spi) regulator_disable(st->reg_vss); regulator_put(st->reg_vss); } - iio_device_unregister(indio_dev); - - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/dds/ad5930.c index 4847ea2941d..f5e368b5665 100644 --- a/drivers/staging/iio/dds/ad5930.c +++ b/drivers/staging/iio/dds/ad5930.c @@ -130,6 +130,7 @@ error_ret: static int __devexit ad5930_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index aefcab1c3fe..0db0b3a8c85 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c @@ -328,13 +328,14 @@ static int __devexit ad9832_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad9832_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; iio_device_unregister(indio_dev); - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_free_device(indio_dev); + return 0; } diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index fe461199801..c468f696fe2 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -417,13 +417,13 @@ static int __devexit ad9834_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad9834_state *st = iio_priv(indio_dev); - struct regulator *reg = st->reg; iio_device_unregister(indio_dev); - if (!IS_ERR(reg)) { - regulator_disable(reg); - regulator_put(reg); + if (!IS_ERR(st->reg)) { + regulator_disable(st->reg); + regulator_put(st->reg); } + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/dds/ad9850.c index 7f2dd47334f..a14771b24c5 100644 --- a/drivers/staging/iio/dds/ad9850.c +++ b/drivers/staging/iio/dds/ad9850.c @@ -116,6 +116,7 @@ error_ret: static int __devexit ad9850_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index 7f65b92598d..cfceaa64a53 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c @@ -267,6 +267,7 @@ error_ret: static int __devexit ad9852_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index b72df8ca723..da83d2b88c4 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c @@ -400,6 +400,7 @@ error_ret: static int __devexit ad9910_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index 3d478e7a48f..20c182576de 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c @@ -211,6 +211,7 @@ error_ret: static int __devexit ad9951_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index abb6f05ce3d..38cf3f4bf72 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -183,6 +183,7 @@ error_ret: static int adis16060_r_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index 1ca4506a666..5d7a906fec7 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -176,6 +176,7 @@ error_ret: static int adis16080_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index 87670c01f88..749240d0d8c 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -155,6 +155,7 @@ error_ret: static int adis16130_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index ccbf2262c4c..aaa3967f8c0 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -672,6 +672,8 @@ static int adis16260_remove(struct spi_device *spi) int ret; struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); + ret = adis16260_stop_device(indio_dev); if (ret) goto err_ret; @@ -681,7 +683,7 @@ static int adis16260_remove(struct spi_device *spi) adis16260_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16260_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); err_ret: return ret; diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 912baa15c8c..3c3ef796d48 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -324,7 +324,7 @@ static const struct iio_info adxrs450_info = { static int __devinit adxrs450_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct adxrs450_state *st; struct iio_dev *indio_dev; @@ -350,20 +350,16 @@ static int __devinit adxrs450_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; - regdone = 1; /* Get the device into a sane initial state */ ret = adxrs450_initial_setup(indio_dev); if (ret) goto error_initial; return 0; - error_initial: + iio_device_unregister(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; @@ -372,6 +368,7 @@ error_ret: static int adxrs450_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index e7ef3b27388..1086e0befc2 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -768,13 +768,14 @@ static __devexit int ad5933_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad5933_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); iio_sw_rb_free(indio_dev->buffer); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 365f99ae86e..d082a37c4fb 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -1088,6 +1088,7 @@ static int adis16400_remove(struct spi_device *spi) int ret; struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); ret = adis16400_stop_device(indio_dev); if (ret) goto err_ret; @@ -1095,7 +1096,7 @@ static int adis16400_remove(struct spi_device *spi) adis16400_remove_trigger(indio_dev); iio_buffer_unregister(indio_dev); adis16400_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index f52fa3a3887..326e967d54e 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -971,7 +971,6 @@ static int iio_device_register_eventset(struct iio_dev *indio_dev) l) indio_dev->event_interface->group.attrs[attrn++] = &p->dev_attr.attr; - indio_dev->groups[indio_dev->groupcounter++] = &indio_dev->event_interface->group; @@ -1002,8 +1001,6 @@ static void iio_dev_release(struct device *device) iio_device_unregister_trigger_consumer(indio_dev); iio_device_unregister_eventset(indio_dev); iio_device_unregister_sysfs(indio_dev); - ida_simple_remove(&iio_ida, indio_dev->id); - kfree(indio_dev); } static struct device_type iio_dev_type = { diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 6958aa5809a..9dc9e635839 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -581,6 +581,7 @@ static int __devexit isl29018_remove(struct i2c_client *client) dev_dbg(&client->dev, "%s()\n", __func__); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index a5e08b32e42..7e984bcf8d7 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -789,6 +789,8 @@ static int tsl2563_remove(struct i2c_client *client) { struct tsl2563_chip *chip = i2c_get_clientdata(client); struct iio_dev *indio_dev = iio_priv_to_dev(chip); + + iio_device_unregister(indio_dev); if (!chip->int_enabled) cancel_delayed_work(&chip->poweroff_work); /* Ensure that interrupts are disabled - then flush any bottom halves */ @@ -799,7 +801,8 @@ static int tsl2563_remove(struct i2c_client *client) tsl2563_set_power(chip, 0); if (client->irq) free_irq(client->irq, indio_dev); - iio_device_unregister(indio_dev); + + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index c7daa2fcecf..80f77cf8e9c 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -909,6 +909,7 @@ static int taos_resume(struct i2c_client *client) static int __devexit taos_remove(struct i2c_client *client) { iio_device_unregister(i2c_get_clientdata(client)); + iio_free_device(i2c_get_clientdata(client)); return 0; } diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index ab0e26cbdba..8b017127fd4 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -546,12 +546,13 @@ static int ak8975_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ak8975_data *data = iio_priv(indio_dev); - int eoc_gpio = data->eoc_gpio; iio_device_unregister(indio_dev); - if (gpio_is_valid(eoc_gpio)) - gpio_free(eoc_gpio); + if (gpio_is_valid(data->eoc_gpio)) + gpio_free(data->eoc_gpio); + + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 04c7ab015b8..fc9ee970888 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -579,9 +579,11 @@ exit: static int hmc5843_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); /* sleep mode to save power */ hmc5843_configure(client, MODE_SLEEP); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 3be88f28ef9..940fef602b1 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -558,12 +558,13 @@ static int ade7753_remove(struct spi_device *spi) int ret; struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); + ret = ade7753_stop_device(&(indio_dev->dev)); if (ret) goto err_ret; - iio_device_unregister(indio_dev); - + iio_free_device(indio_dev); err_ret: return ret; } diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index f7b20a22082..33f0d327c9f 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -580,11 +580,12 @@ static int ade7754_remove(struct spi_device *spi) int ret; struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); ret = ade7754_stop_device(&(indio_dev->dev)); if (ret) goto err_ret; - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); err_ret: return ret; diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 6ea5c740f78..c5dafbdf3bd 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -822,6 +822,7 @@ static int ade7758_remove(struct spi_device *spi) struct ade7758_state *st = iio_priv(indio_dev); int ret; + iio_device_unregister(indio_dev); ret = ade7758_stop_device(&indio_dev->dev); if (ret) goto err_ret; @@ -831,9 +832,9 @@ static int ade7758_remove(struct spi_device *spi) ade7758_unconfigure_ring(indio_dev); kfree(st->tx); kfree(st->rx); - iio_device_unregister(indio_dev); - return 0; + iio_free_device(indio_dev); + err_ret: return ret; } diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 511a60500d9..b691f10ce98 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -502,11 +502,12 @@ static int ade7759_remove(struct spi_device *spi) int ret; struct iio_dev *indio_dev = spi_get_drvdata(spi); + iio_device_unregister(indio_dev); ret = ade7759_stop_device(&(indio_dev->dev)); if (ret) goto err_ret; - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); err_ret: return ret; diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index d438c038e00..49c01c5c1b5 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -590,6 +590,7 @@ EXPORT_SYMBOL(ade7854_probe); int ade7854_remove(struct iio_dev *indio_dev) { iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 26268bfccff..d7ad46aed0f 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -150,6 +150,7 @@ error_ret: static int __devexit ad2s1200_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 8a6fcb66977..6401a627362 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -737,10 +737,10 @@ error_ret: static int __devexit ad2s1210_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad2s1210_state *st = iio_priv(indio_dev); - ad2s1210_free_gpios(st); iio_device_unregister(indio_dev); + ad2s1210_free_gpios(iio_priv(indio_dev)); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 8b3d34dbe23..a9200d949dc 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -100,6 +100,7 @@ error_ret: static int __devexit ad2s90_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } From 9c95e01e84e31178b9a83b683a501ed76166c259 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 14 Oct 2011 14:46:59 +0100 Subject: [PATCH 1458/1519] staging:iio:adc:max1363 incorrect allocation of available_scanmasks Longs are not known for being 8 bits. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/max1363_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 12db93efaf8..eb699ade34b 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1271,7 +1271,7 @@ static int __devinit max1363_probe(struct i2c_client *client, st->client = client; indio_dev->available_scan_masks - = kzalloc(BITS_TO_LONGS(MAX1363_MAX_CHANNELS)* + = kzalloc(BITS_TO_LONGS(MAX1363_MAX_CHANNELS)*sizeof(long)* (st->chip_info->num_modes + 1), GFP_KERNEL); if (!indio_dev->available_scan_masks) { ret = -ENOMEM; From 3a84331db23b4cb4c497ef5aa5f7aea65d936309 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 14 Oct 2011 16:34:13 +0100 Subject: [PATCH 1459/1519] staging:iio:Documentation Simple dummy driver to explain the basics The documenation explaining how to go about writing a driver is lagging horribly, so here is another approach; an actual driver with lots of explanatory comments. Note it is currently minimal in that there are no events and no buffer. With care they can probably be added in additional files without messing up the clarity of what we have here. V2: Addressed some of Manuel Stahl's feedback. Fixed up kernel doc. Added more general description. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Kconfig | 8 + drivers/staging/iio/Makefile | 2 + drivers/staging/iio/iio_simple_dummy.c | 481 +++++++++++++++++++++++++ 3 files changed, 491 insertions(+) create mode 100644 drivers/staging/iio/iio_simple_dummy.c diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index db4a79ff2ec..0accc21d4e9 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -70,4 +70,12 @@ source "drivers/staging/iio/meter/Kconfig" source "drivers/staging/iio/resolver/Kconfig" source "drivers/staging/iio/trigger/Kconfig" +config IIO_SIMPLE_DUMMY + tristate "An example driver with no hardware requirements" + help + Driver intended mainly as documentation for how to write + a driver. May also be useful for testing userspace code + without hardward. + + endif # IIO diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index 788397d1a4b..014d8f1bf61 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -10,6 +10,8 @@ industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_SW_RING) += ring_sw.o obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o +obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_simple_dummy.o + obj-y += accel/ obj-y += adc/ obj-y += addac/ diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c new file mode 100644 index 00000000000..314a4a6d3ae --- /dev/null +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -0,0 +1,481 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * A reference industrial I/O driver to illustrate the functionality available. + * + * There are numerous real drivers to illustrate the finer points. + * The purpose of this driver is to provide a driver with far more comments + * and explanatory notes than any 'real' driver would have. + * Anyone starting out writing an IIO driver should first make sure they + * understand all of this driver except those bits specifically marked + * as being present to allow us to 'fake' the presence of hardware. + */ +#include +#include +#include +#include + +#include "iio.h" + +/* + * A few elements needed to fake a bus for this driver + * Note instances parmeter controls how many of these + * dummy devices are registered. + */ +static unsigned instances = 1; +module_param(instances, int, 0); + +/* Pointer array used to fake bus elements */ +static struct iio_dev **iio_dummy_devs; + +/* Fake a name for the part number, usually obtained from the id table */ +static const char *iio_dummy_part_number = "iio_dummy_part_no"; + +/** + * struct iio_dummy_accel_calibscale - realworld to register mapping + * @val: first value in read_raw - here integer part. + * @val2: second value in read_raw etc - here micro part. + * @regval: register value - magic device specific numbers. + */ +struct iio_dummy_accel_calibscale { + int val; + int val2; + int regval; /* what would be written to hardware */ +}; + +static const struct iio_dummy_accel_calibscale dummy_scales[] = { + { 0, 100, 0x8 }, /* 0.000100 */ + { 0, 133, 0x7 }, /* 0.000133 */ + { 733, 13, 0x9 }, /* 733.00013 */ +}; + +/** + * struct iio_dummy_state - device instance specific state. + * @dac_val: cache for dac value + * @single_ended_adc_val: cache for single ended adc value + * @differential_adc_val: cache for differential adc value + * @accel_val: cache for acceleration value + * @accel_calibbias: cache for acceleration calibbias + * @accel_calibscale: cache for acceleration calibscale + * @lock: lock to ensure state is consistent + */ +struct iio_dummy_state { + int dac_val; + int single_ended_adc_val; + int differential_adc_val[2]; + int accel_val; + int accel_calibbias; + const struct iio_dummy_accel_calibscale *accel_calibscale; + struct mutex lock; +}; + +/* + * iio_dummy_channels - Description of available channels + * + * This array of structures tells the IIO core about what the device + * actually provides for a given channel. + */ +static struct iio_chan_spec iio_dummy_channels[] = { + /* indexed ADC channel in_voltage0_raw etc */ + { + .type = IIO_VOLTAGE, + /* Channel has a numeric index of 0 */ + .indexed = 1, + .channel = 0, + /* What other information is available? */ + .info_mask = + /* + * in_voltage0_offset + * Offset for userspace to apply prior to scale + * when converting to standard units (microvolts) + */ + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | + /* + * in_voltage0_scale + * Multipler for userspace to apply post offset + * when converting to standard units (microvolts) + */ + (1 << IIO_CHAN_INFO_SCALE_SEPARATE), + + }, + /* Differential ADC channel in_voltage1-voltage2_raw etc*/ + { + .type = IIO_VOLTAGE, + .differential = 1, + /* + * Indexing for differential channels uses channel + * for the positive part, channel2 for the negative. + */ + .indexed = 1, + .channel = 1, + .channel2 = 2, + .info_mask = + /* + * in_voltage-voltage_scale + * Shared version of scale - shared by differential + * input channels of type IIO_VOLTAGE. + */ + (1 << IIO_CHAN_INFO_SCALE_SHARED), + }, + /* Differential ADC channel in_voltage3-voltage4_raw etc*/ + { + .type = IIO_VOLTAGE, + .differential = 1, + .indexed = 1, + .channel = 3, + .channel2 = 4, + .info_mask = + (1 << IIO_CHAN_INFO_SCALE_SHARED), + }, + /* DAC channel out_voltage0_raw */ + { + .type = IIO_VOLTAGE, + .output = 1, + .indexed = 1, + .channel = 0, + }, + /* + * 'modified' (i.e. axis specified) acceleration channel + * in_accel_z_raw + */ + { + .type = IIO_ACCEL, + .modified = 1, + /* Channel 2 is use for modifiers */ + .channel2 = IIO_MOD_X, + .info_mask = + /* + * Internal bias correction value. Applied + * by the hardware or driver prior to userspace + * seeing the readings. Typically part of hardware + * calibration. + */ + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + }, +}; + +/** + * iio_dummy_read_raw() - data read function. + * @indio_dev: the struct iio_dev associated with this device instance + * @chan: the channel whose data is to be read + * @val: first element of returned value (typically INT) + * @val2: second element of returned value (typically MICRO) + * @mask: what we actually want to read. 0 is the channel, everything else + * is as per the info_mask in iio_chan_spec. + */ +static int iio_dummy_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + int ret = -EINVAL; + + mutex_lock(&st->lock); + switch (mask) { + case 0: /* magic value - channel value read */ + switch (chan->type) { + case IIO_VOLTAGE: + if (chan->output) { + /* Set integer part to cached value */ + *val = st->dac_val; + ret = IIO_VAL_INT; + } else if (chan->differential) { + if (chan->channel == 1) + *val = st->differential_adc_val[0]; + else + *val = st->differential_adc_val[1]; + ret = IIO_VAL_INT; + } else { + *val = st->single_ended_adc_val; + ret = IIO_VAL_INT; + } + break; + case IIO_ACCEL: + *val = st->accel_val; + ret = IIO_VAL_INT; + break; + default: + break; + } + break; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + /* only single ended adc -> 7 */ + *val = 7; + ret = IIO_VAL_INT; + break; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + /* only single ended adc -> 0.001333 */ + *val = 0; + *val2 = 1333; + ret = IIO_VAL_INT_PLUS_MICRO; + break; + case (1 << IIO_CHAN_INFO_SCALE_SHARED): + /* all differential adc channels -> 0.000001344 */ + *val = 0; + *val2 = 1344; + ret = IIO_VAL_INT_PLUS_NANO; + break; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + /* only the acceleration axis - read from cache */ + *val = st->accel_calibbias; + ret = IIO_VAL_INT; + break; + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + *val = st->accel_calibscale->val; + *val2 = st->accel_calibscale->val2; + ret = IIO_VAL_INT_PLUS_MICRO; + break; + default: + break; + } + mutex_unlock(&st->lock); + return ret; +} + +/** + * iio_dummy_write_raw() - data write function. + * @indio_dev: the struct iio_dev associated with this device instance + * @chan: the channel whose data is to be read + * @val: first element of returned value (typically INT) + * @val2: second element of returned value (typically MICRO) + * @mask: what we actually want to read. 0 is the channel, everything else + * is as per the info_mask in iio_chan_spec. + * + * Note that all raw writes are assumed IIO_VAL_INT and info mask elements + * are assumed to be IIO_INT_PLUS_MICRO unless the callback write_raw_get_fmt + * in struct iio_info is provided by the driver. + */ +static int iio_dummy_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + int i; + int ret = 0; + struct iio_dummy_state *st = iio_priv(indio_dev); + + switch (mask) { + case 0: + if (chan->output == 0) + return -EINVAL; + + /* Locking not required as writing single value */ + mutex_lock(&st->lock); + st->dac_val = val; + mutex_unlock(&st->lock); + return 0; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + mutex_lock(&st->lock); + /* Compare against table - hard matching here */ + for (i = 0; i < ARRAY_SIZE(dummy_scales); i++) + if (val == dummy_scales[i].val && + val2 == dummy_scales[i].val2) + break; + if (i == ARRAY_SIZE(dummy_scales)) + ret = -EINVAL; + else + st->accel_calibscale = &dummy_scales[i]; + mutex_unlock(&st->lock); + return ret; + default: + return -EINVAL; + } +} + +/* + * Device type specific information. + */ +static const struct iio_info iio_dummy_info = { + .driver_module = THIS_MODULE, + .read_raw = &iio_dummy_read_raw, + .write_raw = &iio_dummy_write_raw, +}; + +/** + * iio_dummy_init_device() - device instance specific init + * @indio_dev: the iio device structure + * + * Most drivers have one of these to set up default values, + * reset the device to known state etc. + */ +static int iio_dummy_init_device(struct iio_dev *indio_dev) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + st->dac_val = 0; + st->single_ended_adc_val = 73; + st->differential_adc_val[0] = 33; + st->differential_adc_val[1] = -34; + st->accel_val = 34; + st->accel_calibbias = -7; + st->accel_calibscale = &dummy_scales[0]; + + return 0; +} + +/** + * iio_dummy_probe() - device instance probe + * @index: an id number for this instance. + * + * Arguments are bus type specific. + * I2C: iio_dummy_probe(struct i2c_client *client, + * const struct i2c_device_id *id) + * SPI: iio_dummy_probe(struct spi_device *spi) + */ +static int __devinit iio_dummy_probe(int index) +{ + int ret; + struct iio_dev *indio_dev; + struct iio_dummy_state *st; + + /* + * Allocate an IIO device. + * + * This structure contains all generic state + * information about the device instance. + * It also has a region (accessed by iio_priv() + * for chip specific state information. + */ + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) { + ret = -ENOMEM; + goto error_ret; + } + + st = iio_priv(indio_dev); + mutex_init(&st->lock); + + iio_dummy_init_device(indio_dev); + /* + * With hardware: Set the parent device. + * indio_dev->dev.parent = &spi->dev; + * indio_dev->dev.parent = &client->dev; + */ + + /* + * Make the iio_dev struct available to remove function. + * Bus equivalents + * i2c_set_clientdata(client, indio_dev); + * spi_set_drvdata(spi, indio_dev); + */ + iio_dummy_devs[index] = indio_dev; + + + /* + * Set the device name. + * + * This is typically a part number and obtained from the module + * id table. + * e.g. for i2c and spi: + * indio_dev->name = id->name; + * indio_dev->name = spi_get_device_id(spi)->name; + */ + indio_dev->name = iio_dummy_part_number; + + /* Provide description of available channels */ + indio_dev->channels = iio_dummy_channels; + indio_dev->num_channels = ARRAY_SIZE(iio_dummy_channels); + + /* + * Provide device type specific interface functions and + * constant data. + */ + indio_dev->info = &iio_dummy_info; + + /* Specify that device provides sysfs type interfaces */ + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_free_device; + + return 0; +error_free_device: + /* Note free device should only be called, before registration + * has succeeded. */ + iio_free_device(indio_dev); +error_ret: + return ret; +} + +/** + * iio_dummy_remove() - device instance removal function + * @index: device index. + * + * Parameters follow those of iio_dummy_probe for buses. + */ +static int iio_dummy_remove(int index) +{ + /* + * Get a pointer to the device instance iio_dev structure + * from the bus subsystem. E.g. + * struct iio_dev *indio_dev = i2c_get_clientdata(client); + * struct iio_dev *indio_dev = spi_get_drvdata(spi); + */ + struct iio_dev *indio_dev = iio_dummy_devs[index]; + + /* Unregister the device */ + iio_device_unregister(indio_dev); + + /* Device specific code to power down etc */ + + /* Free all structures */ + iio_free_device(indio_dev); + + return 0; +} + +/** + * iio_dummy_init() - device driver registration + * + * Varies depending on bus type of the device. As there is no device + * here, call probe directly. For information on device registration + * i2c: + * Documentation/i2c/writing-clients + * spi: + * Documentation/spi/spi-summary + */ +static __init int iio_dummy_init(void) +{ + int i, ret; + if (instances > 10) { + instances = 1; + return -EINVAL; + } + /* Fake a bus */ + iio_dummy_devs = kzalloc(sizeof(*iio_dummy_devs)*instances, GFP_KERNEL); + /* Here we have no actual device so call probe */ + for (i = 0; i < instances; i++) { + ret = iio_dummy_probe(i); + if (ret < 0) + return ret; + } + return 0; +} +module_init(iio_dummy_init); + +/** + * iio_dummy_exit() - device driver removal + * + * Varies depending on bus type of the device. + * As there is no device here, call remove directly. + */ +static __exit void iio_dummy_exit(void) +{ + int i; + for (i = 0; i < instances; i++) + iio_dummy_remove(i); + kfree(iio_dummy_devs); +} +module_exit(iio_dummy_exit); + +MODULE_AUTHOR("Jonathan Cameron "); +MODULE_DESCRIPTION("IIO dummy driver"); +MODULE_LICENSE("GPL v2"); From e6477000fced2c961c26fa42845bd388fdf95e79 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 14 Oct 2011 16:34:14 +0100 Subject: [PATCH 1460/1519] staging:iio:dummy Add event support + fake event generator The event generator is not very pretty but does the job and allows this driver to look a lot more like a normal driver than it otherwise would. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Kconfig | 20 +- drivers/staging/iio/Makefile | 6 +- drivers/staging/iio/iio_dummy_evgen.c | 217 ++++++++++++++++++ drivers/staging/iio/iio_dummy_evgen.h | 2 + drivers/staging/iio/iio_simple_dummy.c | 53 +++-- drivers/staging/iio/iio_simple_dummy.h | 81 +++++++ drivers/staging/iio/iio_simple_dummy_events.c | 190 +++++++++++++++ 7 files changed, 543 insertions(+), 26 deletions(-) create mode 100644 drivers/staging/iio/iio_dummy_evgen.c create mode 100644 drivers/staging/iio/iio_dummy_evgen.h create mode 100644 drivers/staging/iio/iio_simple_dummy.h create mode 100644 drivers/staging/iio/iio_simple_dummy_events.c diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index 0accc21d4e9..75128a0480c 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -70,12 +70,26 @@ source "drivers/staging/iio/meter/Kconfig" source "drivers/staging/iio/resolver/Kconfig" source "drivers/staging/iio/trigger/Kconfig" +config IIO_DUMMY_EVGEN + tristate + config IIO_SIMPLE_DUMMY tristate "An example driver with no hardware requirements" + select IIO_SIMPLE_DUMMY_EVGEN if IIO_SIMPLE_DUMMY_EVENTS help - Driver intended mainly as documentation for how to write - a driver. May also be useful for testing userspace code - without hardward. + Driver intended mainly as documentation for how to write + a driver. May also be useful for testing userspace code + without hardward. +if IIO_SIMPLE_DUMMY + +config IIO_SIMPLE_DUMMY_EVENTS + boolean "Event generation support" + select IIO_DUMMY_EVGEN + help + Add some dummy events to the simple dummy driver. + + +endif # IIO_SIMPLE_DUMMY endif # IIO diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index 014d8f1bf61..75aacfded53 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -10,7 +10,11 @@ industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_SW_RING) += ring_sw.o obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o -obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_simple_dummy.o +obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_dummy.o +iio_dummy-y := iio_simple_dummy.o +iio_dummy-$(CONFIG_IIO_SIMPLE_DUMMY_EVENTS) += iio_simple_dummy_events.o + +obj-$(CONFIG_IIO_DUMMY_EVGEN) += iio_dummy_evgen.o obj-y += accel/ obj-y += adc/ diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c new file mode 100644 index 00000000000..da657d10471 --- /dev/null +++ b/drivers/staging/iio/iio_dummy_evgen.c @@ -0,0 +1,217 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Companion module to the iio simple dummy example driver. + * The purpose of this is to generate 'fake' event interrupts thus + * allowing that driver's code to be as close as possible to that of + * a normal driver talking to hardware. The approach used here + * is not intended to be general and just happens to work for this + * particular use case. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "iio_dummy_evgen.h" +#include "iio.h" +#include "sysfs.h" + +/* Fiddly bit of faking and irq without hardware */ +#define IIO_EVENTGEN_NO 10 +/** + * struct iio_dummy_evgen - evgen state + * @chip: irq chip we are faking + * @base: base of irq range + * @enabled: mask of which irqs are enabled + * @inuse: mask of which irqs actually have anyone connected + * @lock: protect the evgen state + */ +struct iio_dummy_eventgen { + struct irq_chip chip; + int base; + bool enabled[IIO_EVENTGEN_NO]; + bool inuse[IIO_EVENTGEN_NO]; + struct mutex lock; +}; + +/* We can only ever have one instance of this 'device' */ +static struct iio_dummy_eventgen *iio_evgen; +static const char *iio_evgen_name = "iio_dummy_evgen"; + +static void iio_dummy_event_irqmask(struct irq_data *d) +{ + struct irq_chip *chip = irq_data_get_irq_chip(d); + struct iio_dummy_eventgen *evgen = + container_of(chip, struct iio_dummy_eventgen, chip); + + evgen->enabled[d->irq - evgen->base] = false; +} + +static void iio_dummy_event_irqunmask(struct irq_data *d) +{ + struct irq_chip *chip = irq_data_get_irq_chip(d); + struct iio_dummy_eventgen *evgen = + container_of(chip, struct iio_dummy_eventgen, chip); + + evgen->enabled[d->irq - evgen->base] = true; +} + +static int iio_dummy_evgen_create(void) +{ + int ret, i; + + iio_evgen = kzalloc(sizeof(*iio_evgen), GFP_KERNEL); + if (iio_evgen == NULL) + return -ENOMEM; + + iio_evgen->base = irq_alloc_descs(-1, 0, IIO_EVENTGEN_NO, 0); + if (iio_evgen->base < 0) { + ret = iio_evgen->base; + kfree(iio_evgen); + return ret; + } + iio_evgen->chip.name = iio_evgen_name; + iio_evgen->chip.irq_mask = &iio_dummy_event_irqmask; + iio_evgen->chip.irq_unmask = &iio_dummy_event_irqunmask; + for (i = 0; i < IIO_EVENTGEN_NO; i++) { + irq_set_chip(iio_evgen->base + i, &iio_evgen->chip); + irq_set_handler(iio_evgen->base + i, &handle_simple_irq); + irq_modify_status(iio_evgen->base + i, + IRQ_NOREQUEST | IRQ_NOAUTOEN, + IRQ_NOPROBE); + } + mutex_init(&iio_evgen->lock); + return 0; +} + +/** + * iio_dummy_evgen_get_irq() - get an evgen provided irq for a device + * + * This function will give a free allocated irq to a client device. + * That irq can then be caused to 'fire' by using the associated sysfs file. + */ +int iio_dummy_evgen_get_irq(void) +{ + int i, ret = 0; + mutex_lock(&iio_evgen->lock); + for (i = 0; i < IIO_EVENTGEN_NO; i++) + if (iio_evgen->inuse[i] == false) { + ret = iio_evgen->base + i; + iio_evgen->inuse[i] = true; + break; + } + mutex_unlock(&iio_evgen->lock); + if (i == IIO_EVENTGEN_NO) + return -ENOMEM; + return ret; +} +EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_irq); + +/** + * iio_dummy_evgen_release_irq() - give the irq back. + * @irq: irq being returned to the pool + * + * Used by client driver instances to give the irqs back when they disconnect + */ +int iio_dummy_evgen_release_irq(int irq) +{ + mutex_lock(&iio_evgen->lock); + iio_evgen->inuse[irq - iio_evgen->base] = false; + mutex_unlock(&iio_evgen->lock); + + return 0; +} +EXPORT_SYMBOL_GPL(iio_dummy_evgen_release_irq); + +static void iio_dummy_evgen_free(void) +{ + irq_free_descs(iio_evgen->base, IIO_EVENTGEN_NO); + kfree(iio_evgen); +} + +static void iio_evgen_release(struct device *dev) +{ + iio_dummy_evgen_free(); +} + +static ssize_t iio_evgen_poke(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + if (iio_evgen->enabled[this_attr->address]) + handle_nested_irq(iio_evgen->base + this_attr->address); + + return len; +} + +static IIO_DEVICE_ATTR(poke_ev0, S_IWUSR, NULL, &iio_evgen_poke, 0); +static IIO_DEVICE_ATTR(poke_ev1, S_IWUSR, NULL, &iio_evgen_poke, 1); +static IIO_DEVICE_ATTR(poke_ev2, S_IWUSR, NULL, &iio_evgen_poke, 2); +static IIO_DEVICE_ATTR(poke_ev3, S_IWUSR, NULL, &iio_evgen_poke, 3); +static IIO_DEVICE_ATTR(poke_ev4, S_IWUSR, NULL, &iio_evgen_poke, 4); +static IIO_DEVICE_ATTR(poke_ev5, S_IWUSR, NULL, &iio_evgen_poke, 5); +static IIO_DEVICE_ATTR(poke_ev6, S_IWUSR, NULL, &iio_evgen_poke, 6); +static IIO_DEVICE_ATTR(poke_ev7, S_IWUSR, NULL, &iio_evgen_poke, 7); +static IIO_DEVICE_ATTR(poke_ev8, S_IWUSR, NULL, &iio_evgen_poke, 8); +static IIO_DEVICE_ATTR(poke_ev9, S_IWUSR, NULL, &iio_evgen_poke, 9); + +static struct attribute *iio_evgen_attrs[] = { + &iio_dev_attr_poke_ev0.dev_attr.attr, + &iio_dev_attr_poke_ev1.dev_attr.attr, + &iio_dev_attr_poke_ev2.dev_attr.attr, + &iio_dev_attr_poke_ev3.dev_attr.attr, + &iio_dev_attr_poke_ev4.dev_attr.attr, + &iio_dev_attr_poke_ev5.dev_attr.attr, + &iio_dev_attr_poke_ev6.dev_attr.attr, + &iio_dev_attr_poke_ev7.dev_attr.attr, + &iio_dev_attr_poke_ev8.dev_attr.attr, + &iio_dev_attr_poke_ev9.dev_attr.attr, + NULL, +}; + +static const struct attribute_group iio_evgen_group = { + .attrs = iio_evgen_attrs, +}; + +static const struct attribute_group *iio_evgen_groups[] = { + &iio_evgen_group, + NULL +}; + +static struct device iio_evgen_dev = { + .bus = &iio_bus_type, + .groups = iio_evgen_groups, + .release = &iio_evgen_release, +}; +static __init int iio_dummy_evgen_init(void) +{ + int ret = iio_dummy_evgen_create(); + if (ret < 0) + return ret; + device_initialize(&iio_evgen_dev); + dev_set_name(&iio_evgen_dev, "iio_evgen"); + return device_add(&iio_evgen_dev); +} +module_init(iio_dummy_evgen_init); + +static __exit void iio_dummy_evgen_exit(void) +{ + device_unregister(&iio_evgen_dev); +} +module_exit(iio_dummy_evgen_exit); + +MODULE_AUTHOR("Jonathan Cameron "); +MODULE_DESCRIPTION("IIO dummy driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/iio_dummy_evgen.h b/drivers/staging/iio/iio_dummy_evgen.h new file mode 100644 index 00000000000..d8845e2288b --- /dev/null +++ b/drivers/staging/iio/iio_dummy_evgen.h @@ -0,0 +1,2 @@ +int iio_dummy_evgen_get_irq(void); +int iio_dummy_evgen_release_irq(int irq); diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index 314a4a6d3ae..c5119a0253b 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -20,6 +20,8 @@ #include #include "iio.h" +#include "sysfs.h" +#include "iio_simple_dummy.h" /* * A few elements needed to fake a bus for this driver @@ -53,26 +55,6 @@ static const struct iio_dummy_accel_calibscale dummy_scales[] = { { 733, 13, 0x9 }, /* 733.00013 */ }; -/** - * struct iio_dummy_state - device instance specific state. - * @dac_val: cache for dac value - * @single_ended_adc_val: cache for single ended adc value - * @differential_adc_val: cache for differential adc value - * @accel_val: cache for acceleration value - * @accel_calibbias: cache for acceleration calibbias - * @accel_calibscale: cache for acceleration calibscale - * @lock: lock to ensure state is consistent - */ -struct iio_dummy_state { - int dac_val; - int single_ended_adc_val; - int differential_adc_val[2]; - int accel_val; - int accel_calibbias; - const struct iio_dummy_accel_calibscale *accel_calibscale; - struct mutex lock; -}; - /* * iio_dummy_channels - Description of available channels * @@ -101,6 +83,14 @@ static struct iio_chan_spec iio_dummy_channels[] = { */ (1 << IIO_CHAN_INFO_SCALE_SEPARATE), +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + /* + * simple event - triggered when value rises above + * a threshold + */ + .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ }, /* Differential ADC channel in_voltage1-voltage2_raw etc*/ { @@ -296,6 +286,12 @@ static const struct iio_info iio_dummy_info = { .driver_module = THIS_MODULE, .read_raw = &iio_dummy_read_raw, .write_raw = &iio_dummy_write_raw, +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .read_event_config = &iio_simple_dummy_read_event_config, + .write_event_config = &iio_simple_dummy_write_event_config, + .read_event_value = &iio_simple_dummy_read_event_value, + .write_event_value = &iio_simple_dummy_write_event_value, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ }; /** @@ -392,11 +388,16 @@ static int __devinit iio_dummy_probe(int index) /* Specify that device provides sysfs type interfaces */ indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); + ret = iio_simple_dummy_events_register(indio_dev); if (ret < 0) goto error_free_device; + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_unregister_events; return 0; +error_unregister_events: + iio_simple_dummy_events_unregister(indio_dev); error_free_device: /* Note free device should only be called, before registration * has succeeded. */ @@ -413,6 +414,7 @@ error_ret: */ static int iio_dummy_remove(int index) { + int ret; /* * Get a pointer to the device instance iio_dev structure * from the bus subsystem. E.g. @@ -421,15 +423,22 @@ static int iio_dummy_remove(int index) */ struct iio_dev *indio_dev = iio_dummy_devs[index]; + /* Unregister the device */ iio_device_unregister(indio_dev); /* Device specific code to power down etc */ + + ret = iio_simple_dummy_events_unregister(indio_dev); + if (ret) + goto error_ret; + /* Free all structures */ iio_free_device(indio_dev); - return 0; +error_ret: + return ret; } /** diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h new file mode 100644 index 00000000000..998fd1fd356 --- /dev/null +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Join together the various functionality of iio_simple_dummy driver + */ + +#include + +struct iio_dummy_accel_calibscale; + +/** + * struct iio_dummy_state - device instance specific state. + * @dac_val: cache for dac value + * @single_ended_adc_val: cache for single ended adc value + * @differential_adc_val: cache for differential adc value + * @accel_val: cache for acceleration value + * @accel_calibbias: cache for acceleration calibbias + * @accel_calibscale: cache for acceleration calibscale + * @lock: lock to ensure state is consistent + * @event_irq: irq number for event line (faked) + * @event_val: cache for event theshold value + * @event_en: cache of whether event is enabled + */ +struct iio_dummy_state { + int dac_val; + int single_ended_adc_val; + int differential_adc_val[2]; + int accel_val; + int accel_calibbias; + const struct iio_dummy_accel_calibscale *accel_calibscale; + struct mutex lock; +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + int event_irq; + int event_val; + bool event_en; +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ +}; + +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + +struct iio_dev; + +int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev, + u64 event_code); + +int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, + u64 event_code, + int state); + +int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val); + +int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val); + +int iio_simple_dummy_events_register(struct iio_dev *indio_dev); +int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev); + +#else /* Stubs for when events are disabled at compile time */ + +static inline int +iio_simple_dummy_events_register(struct iio_dev *indio_dev) +{ + return 0; +}; + +static inline int +iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) +{ + return 0; +}; + +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ + + diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c new file mode 100644 index 00000000000..9f00cff7ddd --- /dev/null +++ b/drivers/staging/iio/iio_simple_dummy_events.c @@ -0,0 +1,190 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Event handling elements of industrial I/O reference driver. + */ +#include +#include +#include +#include + +#include "iio.h" +#include "sysfs.h" +#include "iio_simple_dummy.h" + +/* Evgen 'fakes' interrupt events for this example */ +#include "iio_dummy_evgen.h" + +/** + * iio_simple_dummy_read_event_config() - is event enabled? + * @indio_dev: the device instance data + * @event_code: event code of the event being queried + * + * This function would normally query the relevant registers or a cache to + * discover if the event generation is enabled on the device. + */ +int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev, + u64 event_code) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + return st->event_en; +} + +/** + * iio_simple_dummy_write_event_config() - set whether event is enabled + * @indio_dev: the device instance data + * @event_code: event code of event being enabled/disabled + * @state: whether to enable or disable the device. + * + * This function would normally set the relevant registers on the devices + * so that it generates the specified event. Here it just sets up a cached + * value. + */ +int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, + u64 event_code, + int state) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + /* + * Deliberately over the top code splitting to illustrate + * how this is done when multiple events exist. + */ + switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { + case IIO_VOLTAGE: + switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { + case IIO_EV_TYPE_THRESH: + if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == + IIO_EV_DIR_RISING) + st->event_en = state; + else + return -EINVAL; + break; + default: + return -EINVAL; + } + default: + return -EINVAL; + } + + return 0; +} + +/** + * iio_simple_dummy_read_event_value() - get value associated with event + * @indio_dev: device instance specific data + * @event_code: event code for the event whose value is being queried + * @val: value for the event code. + * + * Many devices provide a large set of events of which only a subset may + * be enabled at a time, with value registers whose meaning changes depending + * on the event enabled. This often means that the driver must cache the values + * associated with each possible events so that the right value is in place when + * the enabled event is changed. + */ +int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + *val = st->event_val; + + return 0; +} + +/** + * iio_simple_dummy_write_event_value() - set value associate with event + * @indio_dev: device instance specific data + * @event_code: event code for the event whose value is being set + * @val: the value to be set. + */ +int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + st->event_val = val; + + return 0; +} + +/** + * iio_simple_dummy_event_handler() - identify and pass on event + * @irq: irq of event line + * @private: pointer to device instance state. + * + * This handler is responsible for querying the device to find out what + * event occured and for then pushing that event towards userspace. + * Here only one event occurs so we push that directly on with locally + * grabbed timestamp. + */ +static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + iio_push_event(indio_dev, + IIO_EVENT_CODE(IIO_VOLTAGE, 0, 0, + IIO_EV_DIR_RISING, + IIO_EV_TYPE_THRESH, 0, 0, 0), + iio_get_time_ns()); + return IRQ_HANDLED; +} + +/** + * iio_simple_dummy_events_register() - setup interrupt handling for events + * @indio_dev: device instance data + * + * This function requests the threaded interrupt to handle the events. + * Normally the irq is a hardware interrupt and the number comes + * from board configuration files. Here we get it from a companion + * module that fakes the interrupt for us. Note that module in + * no way forms part of this example. Just assume that events magically + * appear via the provided interrupt. + */ +int iio_simple_dummy_events_register(struct iio_dev *indio_dev) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + int ret; + + /* Fire up event source - normally not present */ + st->event_irq = iio_dummy_evgen_get_irq(); + if (st->event_irq < 0) { + ret = st->event_irq; + goto error_ret; + } + ret = request_threaded_irq(st->event_irq, + NULL, + &iio_simple_dummy_event_handler, + IRQF_ONESHOT, + "iio_simple_event", + indio_dev); + if (ret < 0) + goto error_free_evgen; + return 0; + +error_free_evgen: + iio_dummy_evgen_release_irq(st->event_irq); +error_ret: + return ret; +} + +/** + * iio_simple_dummy_events_unregister() - tidy up interrupt handling on remove + * @indio_dev: device instance data + */ +int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) +{ + struct iio_dummy_state *st = iio_priv(indio_dev); + + free_irq(st->event_irq, indio_dev); + /* Not part of normal driver */ + iio_dummy_evgen_release_irq(st->event_irq); + + return 0; +} From 9ad2e2e1d6506252f31a142a9b04121992af25e3 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 14 Oct 2011 16:34:15 +0100 Subject: [PATCH 1461/1519] staging:iio:dummy Add buffered reading support Very simple buffered reading. Did not provide a trigger as the sysfs trigger already meets that requirement. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Kconfig | 5 + drivers/staging/iio/Makefile | 1 + drivers/staging/iio/iio_simple_dummy.c | 73 ++++++- drivers/staging/iio/iio_simple_dummy.h | 27 +++ drivers/staging/iio/iio_simple_dummy_buffer.c | 206 ++++++++++++++++++ 5 files changed, 303 insertions(+), 9 deletions(-) create mode 100644 drivers/staging/iio/iio_simple_dummy_buffer.c diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index 75128a0480c..09cf5800c8e 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -89,6 +89,11 @@ config IIO_SIMPLE_DUMMY_EVENTS help Add some dummy events to the simple dummy driver. +config IIO_SIMPLE_DUMMY_BUFFER + boolean "Buffered capture support" + depends on IIO_KFIFO_BUF + help + Add buffered data capture to the simple dummy driver. endif # IIO_SIMPLE_DUMMY diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index 75aacfded53..eaa07b07d58 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_dummy.o iio_dummy-y := iio_simple_dummy.o iio_dummy-$(CONFIG_IIO_SIMPLE_DUMMY_EVENTS) += iio_simple_dummy_events.o +iio_dummy-$(CONFIG_IIO_SIMPLE_DUMMY_BUFFER) += iio_simple_dummy_buffer.o obj-$(CONFIG_IIO_DUMMY_EVGEN) += iio_dummy_evgen.o diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index c5119a0253b..af0c99236d4 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -21,6 +21,7 @@ #include "iio.h" #include "sysfs.h" +#include "buffer_generic.h" #include "iio_simple_dummy.h" /* @@ -82,7 +83,14 @@ static struct iio_chan_spec iio_dummy_channels[] = { * when converting to standard units (microvolts) */ (1 << IIO_CHAN_INFO_SCALE_SEPARATE), - + /* The ordering of elements in the buffer via an enum */ + .scan_index = voltage0, + .scan_type = { /* Description of storage in buffer */ + .sign = 'u', /* unsigned */ + .realbits = 13, /* 13 bits */ + .storagebits = 16, /* 16 bits used for storage */ + .shift = 0, /* zero shift */ + }, #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS /* * simple event - triggered when value rises above @@ -110,6 +118,13 @@ static struct iio_chan_spec iio_dummy_channels[] = { * input channels of type IIO_VOLTAGE. */ (1 << IIO_CHAN_INFO_SCALE_SHARED), + .scan_index = diffvoltage1m2, + .scan_type = { /* Description of storage in buffer */ + .sign = 's', /* signed */ + .realbits = 12, /* 12 bits */ + .storagebits = 16, /* 16 bits used for storage */ + .shift = 0, /* zero shift */ + }, }, /* Differential ADC channel in_voltage3-voltage4_raw etc*/ { @@ -120,13 +135,13 @@ static struct iio_chan_spec iio_dummy_channels[] = { .channel2 = 4, .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), - }, - /* DAC channel out_voltage0_raw */ - { - .type = IIO_VOLTAGE, - .output = 1, - .indexed = 1, - .channel = 0, + .scan_index = diffvoltage3m4, + .scan_type = { + .sign = 's', + .realbits = 11, + .storagebits = 16, + .shift = 0, + }, }, /* * 'modified' (i.e. axis specified) acceleration channel @@ -145,6 +160,25 @@ static struct iio_chan_spec iio_dummy_channels[] = { * calibration. */ (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), + .scan_index = accelx, + .scan_type = { /* Description of storage in buffer */ + .sign = 's', /* signed */ + .realbits = 16, /* 12 bits */ + .storagebits = 16, /* 16 bits used for storage */ + .shift = 0, /* zero shift */ + }, + }, + /* + * Convenience macro for timestamps. 4 is the index in + * the buffer. + */ + IIO_CHAN_SOFT_TIMESTAMP(4), + /* DAC channel out_voltage0_raw */ + { + .type = IIO_VOLTAGE, + .output = 1, + .indexed = 1, + .channel = 0, }, }; @@ -391,11 +425,29 @@ static int __devinit iio_dummy_probe(int index) ret = iio_simple_dummy_events_register(indio_dev); if (ret < 0) goto error_free_device; - ret = iio_device_register(indio_dev); + + /* Configure buffered capture support. */ + ret = iio_simple_dummy_configure_buffer(indio_dev); if (ret < 0) goto error_unregister_events; + /* + * Register the channels with the buffer, but avoid the output + * channel being registered by reducing the number of channels by 1. + */ + ret = iio_buffer_register(indio_dev, iio_dummy_channels, 5); + if (ret < 0) + goto error_unconfigure_buffer; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_unregister_buffer; + return 0; +error_unregister_buffer: + iio_buffer_unregister(indio_dev); +error_unconfigure_buffer: + iio_simple_dummy_unconfigure_buffer(indio_dev); error_unregister_events: iio_simple_dummy_events_unregister(indio_dev); error_free_device: @@ -429,6 +481,9 @@ static int iio_dummy_remove(int index) /* Device specific code to power down etc */ + /* Buffered capture related cleanup */ + iio_buffer_unregister(indio_dev); + iio_simple_dummy_unconfigure_buffer(indio_dev); ret = iio_simple_dummy_events_unregister(indio_dev); if (ret) diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h index 998fd1fd356..53975d916fc 100644 --- a/drivers/staging/iio/iio_simple_dummy.h +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -78,4 +78,31 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ +/** + * enum iio_simple_dummy_scan_elements - scan index enum + * @voltage0: the single ended voltage channel + * @diffvoltage1m2: first differential channel + * @diffvoltage3m4: second differenial channel + * @accelx: acceleration channel + * + * Enum provides convenient numbering for the scan index. + */ +enum iio_simple_dummy_scan_elements { + voltage0, + diffvoltage1m2, + diffvoltage3m4, + accelx, +}; +#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER +int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev); +void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev); +#else +static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev) +{ + return 0; +}; +static inline +void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev) +{}; +#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */ diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c new file mode 100644 index 00000000000..f0b36d25414 --- /dev/null +++ b/drivers/staging/iio/iio_simple_dummy_buffer.c @@ -0,0 +1,206 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Buffer handling elements of industrial I/O reference driver. + * Uses the kfifo buffer. + * + * To test without hardware use the sysfs trigger. + */ + +#include +#include +#include +#include +#include + +#include "iio.h" +#include "trigger_consumer.h" +#include "kfifo_buf.h" + +#include "iio_simple_dummy.h" + +/* Some fake data */ + +static const s16 fakedata[] = { + [voltage0] = 7, + [diffvoltage1m2] = -33, + [diffvoltage3m4] = -2, + [accelx] = 344, +}; +/** + * iio_simple_dummy_trigger_h() - the trigger handler function + * @irq: the interrupt number + * @p: private data - always a pointer to the poll func. + * + * This is the guts of buffered capture. On a trigger event occuring, + * if the pollfunc is attached then this handler is called as a threaded + * interrupt (and hence may sleep). It is responsible for grabbing data + * from the device and pushing it into the associated buffer. + */ +static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct iio_buffer *buffer = indio_dev->buffer; + int len = 0; + /* + * The datasize is obtained from the buffer. It was stored when + * the preenable setup function was called. + */ + size_t datasize = buffer->access->get_bytes_per_datum(buffer); + u16 *data = kmalloc(datasize, GFP_KERNEL); + if (data == NULL) + return -ENOMEM; + + if (buffer->scan_count) { + /* + * Three common options here: + * hardware scans: certain combinations of channels make + * up a fast read. The capture will consist of all of them. + * Hence we just call the grab data function and fill the + * buffer without processing. + * sofware scans: can be considered to be random access + * so efficient reading is just a case of minimal bus + * transactions. + * software culled hardware scans: + * occasionally a driver may process the nearest hardware + * scan to avoid storing elements that are not desired. This + * is the fidliest option by far. + * Here lets pretend we have random access. And the values are + * in the constant table fakedata. + */ + int i, j; + for (i = 0, j = 0; i < buffer->scan_count; i++) { + j = find_next_bit(buffer->scan_mask, + indio_dev->masklength, j + 1); + /* random access read form the 'device' */ + data[i] = fakedata[j]; + len += 2; + } + } + /* Store a timestampe at an 8 byte boundary */ + if (buffer->scan_timestamp) + *(s64 *)(((phys_addr_t)data + len + + sizeof(s64) - 1) & ~(sizeof(s64) - 1)) + = iio_get_time_ns(); + buffer->access->store_to(buffer, (u8 *)data, pf->timestamp); + + kfree(data); + + /* + * Tell the core we are done with this trigger and ready for the + * next one. + */ + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static const struct iio_buffer_setup_ops iio_simple_dummy_buffer_setup_ops = { + /* + * iio_sw_buffer_preenable: + * Generic function for equal sized ring elements + 64 bit timestamp + * Assumes that any combination of channels can be enabled. + * Typically replaced to implement restrictions on what combinations + * can be captured (hardware scan modes). + */ + .preenable = &iio_sw_buffer_preenable, + /* + * iio_triggered_buffer_postenable: + * Generic function that simply attaches the pollfunc to the trigger. + * Replace this to mess with hardware state before we attach the + * trigger. + */ + .postenable = &iio_triggered_buffer_postenable, + /* + * iio_triggered_buffer_predisable: + * Generic function that simple detaches the pollfunc from the trigger. + * Replace this to put hardware state back again after the trigger is + * detached but before userspace knows we have disabled the ring. + */ + .predisable = &iio_triggered_buffer_predisable, +}; + +int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev) +{ + int ret; + struct iio_buffer *buffer; + + /* Allocate a buffer to use - here a kfifo */ + buffer = iio_kfifo_allocate(indio_dev); + if (buffer == NULL) { + ret = -ENOMEM; + goto error_ret; + } + + indio_dev->buffer = buffer; + /* Tell the core how to access the buffer */ + buffer->access = &kfifo_access_funcs; + + /* Number of bytes per element */ + buffer->bpe = 2; + /* Enable timestamps by default */ + buffer->scan_timestamp = true; + + /* + * Tell the core what device type specific functions should + * be run on either side of buffer capture enable / disable. + */ + buffer->setup_ops = &iio_simple_dummy_buffer_setup_ops; + buffer->owner = THIS_MODULE; + + /* + * Configure a polling function. + * When a trigger event with this polling function connected + * occurs, this function is run. Typically this grabs data + * from the device. + * + * NULL for the top half. This is normally implemented only if we + * either want to ping a capture now pin (no sleeping) or grab + * a timestamp as close as possible to a data ready trigger firing. + * + * IRQF_ONESHOT ensures irqs are masked such that only one instance + * of the handler can run at a time. + * + * "iio_simple_dummy_consumer%d" formatting string for the irq 'name' + * as seen under /proc/interrupts. Remaining parameters as per printk. + */ + indio_dev->pollfunc = iio_alloc_pollfunc(NULL, + &iio_simple_dummy_trigger_h, + IRQF_ONESHOT, + indio_dev, + "iio_simple_dummy_consumer%d", + indio_dev->id); + + if (indio_dev->pollfunc == NULL) { + ret = -ENOMEM; + goto error_free_buffer; + } + + /* + * Notify the core that this device is capable of buffered capture + * driven by a trigger. + */ + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; + return 0; + +error_free_buffer: + iio_kfifo_free(indio_dev->buffer); +error_ret: + return ret; + +} + +/** + * iio_simple_dummy_unconfigure_buffer() - release buffer resources + * @indo_dev: device instance state + */ +void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev) +{ + iio_dealloc_pollfunc(indio_dev->pollfunc); + iio_kfifo_free(indio_dev->buffer); +} From 8f966dc444b11adff6011a1d1fce424abdd876d8 Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Mon, 26 Sep 2011 11:27:15 +0200 Subject: [PATCH 1462/1519] staging: vme: add struct vme_dev for VME devices Instead of using a vanilla 'struct device' for VME devices, add new 'struct vme_dev'. Modifications have been made to the VME framework API as well as all in-tree VME drivers. The new vme_dev structure has the following advantages from the current model used by the driver: * Driver functions (probe, remove) now receive a VME device instead of a pointer to the bridge device (cleaner design) * It's easier to differenciate API calls as bridge-based or device-based (ie. cleaner interface). Signed-off-by: Manohar Vanga Cc: Martyn Welch Reviewed-by: Emilio G. Cota Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 14 ++- drivers/staging/vme/vme.c | 126 ++++++++++--------------- drivers/staging/vme/vme.h | 37 ++++++-- drivers/staging/vme/vme_api.txt | 41 +++++--- drivers/staging/vme/vme_bridge.h | 5 +- 5 files changed, 116 insertions(+), 107 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 3cbeb2ada41..bb33dc2ece4 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -116,7 +116,7 @@ static struct driver_stats statistics; static struct cdev *vme_user_cdev; /* Character device */ static struct class *vme_user_sysfs_class; /* Sysfs class */ -static struct device *vme_user_bridge; /* Pointer to bridge device */ +static struct vme_dev *vme_user_bridge; /* Pointer to user device */ static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR, @@ -135,8 +135,8 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t, static loff_t vme_user_llseek(struct file *, loff_t, int); static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); -static int __devinit vme_user_probe(struct device *, int, int); -static int __devexit vme_user_remove(struct device *, int, int); +static int __devinit vme_user_probe(struct vme_dev *); +static int __devexit vme_user_remove(struct vme_dev *); static const struct file_operations vme_user_fops = { .open = vme_user_open, @@ -689,8 +689,7 @@ err_nocard: * as practical. We will therefore reserve the buffers and request the images * here so that we don't have to do it later. */ -static int __devinit vme_user_probe(struct device *dev, int cur_bus, - int cur_slot) +static int __devinit vme_user_probe(struct vme_dev *vdev) { int i, err; char name[12]; @@ -702,7 +701,7 @@ static int __devinit vme_user_probe(struct device *dev, int cur_bus, err = -EINVAL; goto err_dev; } - vme_user_bridge = dev; + vme_user_bridge = vdev; /* Initialise descriptors */ for (i = 0; i < VME_DEVS; i++) { @@ -865,8 +864,7 @@ err_dev: return err; } -static int __devexit vme_user_remove(struct device *dev, int cur_bus, - int cur_slot) +static int __devexit vme_user_remove(struct vme_dev *dev) { int i; diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 63a8fa2ebc0..4bef7893dde 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -42,13 +42,9 @@ static DEFINE_MUTEX(vme_buses_lock); static void __exit vme_exit(void); static int __init vme_init(void); - -/* - * Find the bridge resource associated with a specific device resource - */ -static struct vme_bridge *dev_to_bridge(struct device *dev) +static struct vme_dev *dev_to_vme_dev(struct device *dev) { - return dev->platform_data; + return container_of(dev, struct vme_dev, dev); } /* @@ -236,7 +232,7 @@ static int vme_check_window(vme_address_t aspace, unsigned long long vme_base, * Request a slave image with specific attributes, return some unique * identifier. */ -struct vme_resource *vme_slave_request(struct device *dev, +struct vme_resource *vme_slave_request(struct vme_dev *vdev, vme_address_t address, vme_cycle_t cycle) { struct vme_bridge *bridge; @@ -245,7 +241,7 @@ struct vme_resource *vme_slave_request(struct device *dev, struct vme_slave_resource *slave_image = NULL; struct vme_resource *resource = NULL; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); goto err_bus; @@ -392,7 +388,7 @@ EXPORT_SYMBOL(vme_slave_free); * Request a master image with specific attributes, return some unique * identifier. */ -struct vme_resource *vme_master_request(struct device *dev, +struct vme_resource *vme_master_request(struct vme_dev *vdev, vme_address_t address, vme_cycle_t cycle, vme_width_t dwidth) { struct vme_bridge *bridge; @@ -401,7 +397,7 @@ struct vme_resource *vme_master_request(struct device *dev, struct vme_master_resource *master_image = NULL; struct vme_resource *resource = NULL; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); goto err_bus; @@ -650,7 +646,8 @@ EXPORT_SYMBOL(vme_master_free); * Request a DMA controller with specific attributes, return some unique * identifier. */ -struct vme_resource *vme_dma_request(struct device *dev, vme_dma_route_t route) +struct vme_resource *vme_dma_request(struct vme_dev *vdev, + vme_dma_route_t route) { struct vme_bridge *bridge; struct list_head *dma_pos = NULL; @@ -661,7 +658,7 @@ struct vme_resource *vme_dma_request(struct device *dev, vme_dma_route_t route) /* XXX Not checking resource attributes */ printk(KERN_ERR "No VME resource Attribute tests done\n"); - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); goto err_bus; @@ -994,13 +991,13 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid) } EXPORT_SYMBOL(vme_irq_handler); -int vme_irq_request(struct device *dev, int level, int statid, +int vme_irq_request(struct vme_dev *vdev, int level, int statid, void (*callback)(int, int, void *), void *priv_data) { struct vme_bridge *bridge; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); return -EINVAL; @@ -1037,11 +1034,11 @@ int vme_irq_request(struct device *dev, int level, int statid, } EXPORT_SYMBOL(vme_irq_request); -void vme_irq_free(struct device *dev, int level, int statid) +void vme_irq_free(struct vme_dev *vdev, int level, int statid) { struct vme_bridge *bridge; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); return; @@ -1072,11 +1069,11 @@ void vme_irq_free(struct device *dev, int level, int statid) } EXPORT_SYMBOL(vme_irq_free); -int vme_irq_generate(struct device *dev, int level, int statid) +int vme_irq_generate(struct vme_dev *vdev, int level, int statid) { struct vme_bridge *bridge; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); return -EINVAL; @@ -1099,7 +1096,7 @@ EXPORT_SYMBOL(vme_irq_generate); /* * Request the location monitor, return resource or NULL */ -struct vme_resource *vme_lm_request(struct device *dev) +struct vme_resource *vme_lm_request(struct vme_dev *vdev) { struct vme_bridge *bridge; struct list_head *lm_pos = NULL; @@ -1107,7 +1104,7 @@ struct vme_resource *vme_lm_request(struct device *dev) struct vme_lm_resource *lm = NULL; struct vme_resource *resource = NULL; - bridge = dev_to_bridge(dev); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); goto err_bus; @@ -1288,11 +1285,11 @@ void vme_lm_free(struct vme_resource *resource) } EXPORT_SYMBOL(vme_lm_free); -int vme_slot_get(struct device *bus) +int vme_slot_get(struct vme_dev *vdev) { struct vme_bridge *bridge; - bridge = dev_to_bridge(bus); + bridge = vdev->bridge; if (bridge == NULL) { printk(KERN_ERR "Can't find VME bus\n"); return -EINVAL; @@ -1340,12 +1337,12 @@ static void vme_remove_bus(struct vme_bridge *bridge) static void vme_dev_release(struct device *dev) { - kfree(dev); + kfree(dev_to_vme_dev(dev)); } int vme_register_bridge(struct vme_bridge *bridge) { - struct device *dev; + struct vme_dev *vdev; int retval; int i; @@ -1358,26 +1355,29 @@ int vme_register_bridge(struct vme_bridge *bridge) * specification. */ for (i = 0; i < VME_SLOTS_MAX; i++) { - bridge->dev[i] = kzalloc(sizeof(struct device), GFP_KERNEL); + bridge->dev[i] = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); if (!bridge->dev[i]) { retval = -ENOMEM; goto err_devalloc; } - dev = bridge->dev[i]; - memset(dev, 0, sizeof(struct device)); + vdev = bridge->dev[i]; + memset(vdev, 0, sizeof(struct vme_dev)); - dev->parent = bridge->parent; - dev->bus = &vme_bus_type; - dev->release = vme_dev_release; + vdev->id.bus = bridge->num; + vdev->id.slot = i + 1; + vdev->bridge = bridge; + vdev->dev.parent = bridge->parent; + vdev->dev.bus = &vme_bus_type; + vdev->dev.release = vme_dev_release; /* * We save a pointer to the bridge in platform_data so that we * can get to it later. We keep driver_data for use by the * driver that binds against the slot */ - dev->platform_data = bridge; - dev_set_name(dev, "vme-%x.%x", bridge->num, i + 1); + vdev->dev.platform_data = bridge; + dev_set_name(&vdev->dev, "vme-%x.%x", bridge->num, i + 1); - retval = device_register(dev); + retval = device_register(&vdev->dev); if (retval) goto err_reg; } @@ -1385,11 +1385,11 @@ int vme_register_bridge(struct vme_bridge *bridge) return retval; err_reg: - kfree(dev); + kfree(vdev); err_devalloc: while (--i >= 0) { - dev = bridge->dev[i]; - device_unregister(dev); + vdev = bridge->dev[i]; + device_unregister(&vdev->dev); } vme_remove_bus(bridge); return retval; @@ -1399,12 +1399,12 @@ EXPORT_SYMBOL(vme_register_bridge); void vme_unregister_bridge(struct vme_bridge *bridge) { int i; - struct device *dev; + struct vme_dev *vdev; for (i = 0; i < VME_SLOTS_MAX; i++) { - dev = bridge->dev[i]; - device_unregister(dev); + vdev = bridge->dev[i]; + device_unregister(&vdev->dev); } vme_remove_bus(bridge); } @@ -1430,32 +1430,6 @@ EXPORT_SYMBOL(vme_unregister_driver); /* - Bus Registration ------------------------------------------------------ */ -static int vme_calc_slot(struct device *dev) -{ - struct vme_bridge *bridge; - int num; - - bridge = dev_to_bridge(dev); - - /* Determine slot number */ - num = 0; - while (num < VME_SLOTS_MAX) { - if (bridge->dev[num] == dev) - break; - - num++; - } - if (num == VME_SLOTS_MAX) { - dev_err(dev, "Failed to identify slot\n"); - num = 0; - goto err_dev; - } - num++; - -err_dev: - return num; -} - static struct vme_driver *dev_to_vme_driver(struct device *dev) { if (dev->driver == NULL) @@ -1466,15 +1440,17 @@ static struct vme_driver *dev_to_vme_driver(struct device *dev) static int vme_bus_match(struct device *dev, struct device_driver *drv) { + struct vme_dev *vdev; struct vme_bridge *bridge; struct vme_driver *driver; int i, num; - bridge = dev_to_bridge(dev); + vdev = dev_to_vme_dev(dev); + bridge = vdev->bridge; driver = container_of(drv, struct vme_driver, driver); - num = vme_calc_slot(dev); - if (!num) + num = vdev->id.slot; + if (num <= 0 || num >= VME_SLOTS_MAX) goto err_dev; if (driver->bind_table == NULL) { @@ -1494,7 +1470,7 @@ static int vme_bus_match(struct device *dev, struct device_driver *drv) return 1; if ((driver->bind_table[i].slot == VME_SLOT_CURRENT) && - (num == vme_slot_get(dev))) + (num == vme_slot_get(vdev))) return 1; } i++; @@ -1507,30 +1483,30 @@ err_table: static int vme_bus_probe(struct device *dev) { - struct vme_bridge *bridge; struct vme_driver *driver; + struct vme_dev *vdev; int retval = -ENODEV; driver = dev_to_vme_driver(dev); - bridge = dev_to_bridge(dev); + vdev = dev_to_vme_dev(dev); if (driver->probe != NULL) - retval = driver->probe(dev, bridge->num, vme_calc_slot(dev)); + retval = driver->probe(vdev); return retval; } static int vme_bus_remove(struct device *dev) { - struct vme_bridge *bridge; struct vme_driver *driver; + struct vme_dev *vdev; int retval = -ENODEV; driver = dev_to_vme_driver(dev); - bridge = dev_to_bridge(dev); + vdev = dev_to_vme_dev(dev); if (driver->remove != NULL) - retval = driver->remove(dev, bridge->num, vme_calc_slot(dev)); + retval = driver->remove(vdev); return retval; } diff --git a/drivers/staging/vme/vme.h b/drivers/staging/vme/vme.h index 4155d8c2a53..d442cce33c0 100644 --- a/drivers/staging/vme/vme.h +++ b/drivers/staging/vme/vme.h @@ -91,17 +91,34 @@ extern struct bus_type vme_bus_type; #define VME_SLOT_CURRENT -1 #define VME_SLOT_ALL -2 +/** + * VME device identifier structure + * @bus: The bus ID of the bus the device is on + * @slot: The slot this device is plugged into + */ struct vme_device_id { int bus; int slot; }; +/** + * Structure representing a VME device + * @id: The ID of the device (currently the bus and slot number) + * @bridge: Pointer to the bridge device this device is on + * @dev: Internal device structure + */ +struct vme_dev { + struct vme_device_id id; + struct vme_bridge *bridge; + struct device dev; +}; + struct vme_driver { struct list_head node; const char *name; const struct vme_device_id *bind_table; - int (*probe) (struct device *, int, int); - int (*remove) (struct device *, int, int); + int (*probe) (struct vme_dev *); + int (*remove) (struct vme_dev *); void (*shutdown) (void); struct device_driver driver; }; @@ -112,7 +129,7 @@ void vme_free_consistent(struct vme_resource *, size_t, void *, size_t vme_get_size(struct vme_resource *); -struct vme_resource *vme_slave_request(struct device *, vme_address_t, +struct vme_resource *vme_slave_request(struct vme_dev *, vme_address_t, vme_cycle_t); int vme_slave_set(struct vme_resource *, int, unsigned long long, unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t); @@ -120,7 +137,7 @@ int vme_slave_get(struct vme_resource *, int *, unsigned long long *, unsigned long long *, dma_addr_t *, vme_address_t *, vme_cycle_t *); void vme_slave_free(struct vme_resource *); -struct vme_resource *vme_master_request(struct device *, vme_address_t, +struct vme_resource *vme_master_request(struct vme_dev *, vme_address_t, vme_cycle_t, vme_width_t); int vme_master_set(struct vme_resource *, int, unsigned long long, unsigned long long, vme_address_t, vme_cycle_t, vme_width_t); @@ -132,7 +149,7 @@ unsigned int vme_master_rmw(struct vme_resource *, unsigned int, unsigned int, unsigned int, loff_t); void vme_master_free(struct vme_resource *); -struct vme_resource *vme_dma_request(struct device *, vme_dma_route_t); +struct vme_resource *vme_dma_request(struct vme_dev *, vme_dma_route_t); struct vme_dma_list *vme_new_dma_list(struct vme_resource *); struct vme_dma_attr *vme_dma_pattern_attribute(u32, vme_pattern_t); struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t); @@ -145,12 +162,12 @@ int vme_dma_list_exec(struct vme_dma_list *); int vme_dma_list_free(struct vme_dma_list *); int vme_dma_free(struct vme_resource *); -int vme_irq_request(struct device *, int, int, +int vme_irq_request(struct vme_dev *, int, int, void (*callback)(int, int, void *), void *); -void vme_irq_free(struct device *, int, int); -int vme_irq_generate(struct device *, int, int); +void vme_irq_free(struct vme_dev *, int, int); +int vme_irq_generate(struct vme_dev *, int, int); -struct vme_resource * vme_lm_request(struct device *); +struct vme_resource * vme_lm_request(struct vme_dev *); int vme_lm_count(struct vme_resource *); int vme_lm_set(struct vme_resource *, unsigned long long, vme_address_t, vme_cycle_t); @@ -160,7 +177,7 @@ int vme_lm_attach(struct vme_resource *, int, void (*callback)(int)); int vme_lm_detach(struct vme_resource *, int); void vme_lm_free(struct vme_resource *); -int vme_slot_get(struct device *); +int vme_slot_get(struct vme_dev *); int vme_register_driver(struct vme_driver *); void vme_unregister_driver(struct vme_driver *); diff --git a/drivers/staging/vme/vme_api.txt b/drivers/staging/vme/vme_api.txt index 4910e92c52a..03f48134706 100644 --- a/drivers/staging/vme/vme_api.txt +++ b/drivers/staging/vme/vme_api.txt @@ -20,8 +20,8 @@ registration function. The structure is as follows: struct list_head node; char *name; const struct vme_device_id *bind_table; - int (*probe) (struct device *, int, int); - int (*remove) (struct device *, int, int); + int (*probe) (struct vme_dev *); + int (*remove) (struct vme_dev *); void (*shutdown) (void); struct device_driver driver; }; @@ -33,7 +33,26 @@ to the probe routine. The arguments of the probe routine are as follows: - probe(struct device *dev, int bus, int slot); + probe(struct vme_dev *dev); + +The device structure looks like the following: + + struct vme_dev { + struct vme_device_id id; + struct vme_bridge *bridge; + struct device dev; + }; + +The 'bridge' field contains a pointer to the bridge device. The 'id' field +contains information useful for the probe function: + + struct vme_device_id { + int bus; + int slot; + }; + +'bus' is the number of the bus the device being probed is on. 'slot' refers +to the specific slot on the VME bus. The '.bind_table' is a pointer to an array of type 'vme_device_id': @@ -71,13 +90,13 @@ specific window or DMA channel (which may be used by a different driver) this driver allows a resource to be assigned based on the required attributes of the driver in question: - struct vme_resource * vme_master_request(struct device *dev, + struct vme_resource * vme_master_request(struct vme_dev *dev, vme_address_t aspace, vme_cycle_t cycle, vme_width_t width); - struct vme_resource * vme_slave_request(struct device *dev, + struct vme_resource * vme_slave_request(struct vme_dev *dev, vme_address_t aspace, vme_cycle_t cycle); - struct vme_resource *vme_dma_request(struct device *dev, + struct vme_resource *vme_dma_request(struct vme_dev *dev, vme_dma_route_t route); For slave windows these attributes are split into those of type 'vme_address_t' @@ -301,10 +320,10 @@ status ID combination. Any given combination can only be assigned a single callback function. A void pointer parameter is provided, the value of which is passed to the callback function, the use of this pointer is user undefined: - int vme_irq_request(struct device *dev, int level, int statid, + int vme_irq_request(struct vme_dev *dev, int level, int statid, void (*callback)(int, int, void *), void *priv); - void vme_irq_free(struct device *dev, int level, int statid); + void vme_irq_free(struct vme_dev *dev, int level, int statid); The callback parameters are as follows. Care must be taken in writing a callback function, callback functions run in interrupt context: @@ -318,7 +337,7 @@ Interrupt Generation The following function can be used to generate a VME interrupt at a given VME level and VME status ID: - int vme_irq_generate(struct device *dev, int level, int statid); + int vme_irq_generate(struct vme_dev *dev, int level, int statid); Location monitors @@ -334,7 +353,7 @@ Location Monitor Management The following functions are provided to request the use of a block of location monitors and to free them after they are no longer required: - struct vme_resource * vme_lm_request(struct device *dev); + struct vme_resource * vme_lm_request(struct vme_dev *dev); void vme_lm_free(struct vme_resource * res); @@ -380,4 +399,4 @@ Slot Detection This function returns the slot ID of the provided bridge. - int vme_slot_get(struct device *dev); + int vme_slot_get(struct vme_dev *dev); diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h index 4b8566eb7e3..6dd2f4cf8b6 100644 --- a/drivers/staging/vme/vme_bridge.h +++ b/drivers/staging/vme/vme_bridge.h @@ -114,9 +114,8 @@ struct vme_bridge { void *driver_priv; /* Private pointer for the bridge driver */ struct list_head bus_list; /* list of VME buses */ - struct device *dev[VME_SLOTS_MAX]; /* Device registered with - * device model on VME bus - */ + struct vme_dev *dev[VME_SLOTS_MAX]; /* Device registered + * on VME bus */ /* Interrupt callbacks */ struct vme_irq irq[7]; From 5d6abf379d73efe390488e8edba972af4e93cb1c Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Mon, 26 Sep 2011 11:27:16 +0200 Subject: [PATCH 1463/1519] staging: vme: make match() driver specific to improve non-VME64x support For jumper based boards (non VME64x), there is no mechanism for detecting the card that is plugged into a specific slot. This leads to issues in non-autodiscovery crates/cards when a card is plugged into a slot that is "claimed" by a different driver. In reality, there is no problem, but the driver rejects such a configuration due to its dependence on the concept of slots. This patch makes the concept of slots less critical and pushes the driver match() to individual drivers (similar to what happens in the ISA bus in driver/base/isa.c). This allows drivers to register the number of devices that they expect without any restrictions. Devices in this new model are now formatted as $driver_name-$bus_id.$device_id (as compared to the earlier vme-$bus_id.$slot_number). This model also makes the device model more logical as devices are only registered when they actually exist whereas earlier, a set of devices were being created automatically regardless of them actually being there. Another change introduced in this patch is that devices are now created within the VME driver structure rather than in the VME bridge structure. This way, things don't go haywire if the bridge driver is removed while a driver is using it. Signed-off-by: Manohar Vanga Cc: Martyn Welch Reviewed-by: Emilio G. Cota Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 45 ++--- drivers/staging/vme/vme.c | 232 +++++++++++++------------ drivers/staging/vme/vme.h | 23 ++- drivers/staging/vme/vme_api.txt | 60 +++---- drivers/staging/vme/vme_bridge.h | 5 +- 5 files changed, 184 insertions(+), 181 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index bb33dc2ece4..c658ce9bd61 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -135,6 +135,7 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t, static loff_t vme_user_llseek(struct file *, loff_t, int); static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); +static int vme_user_match(struct vme_dev *); static int __devinit vme_user_probe(struct vme_dev *); static int __devexit vme_user_remove(struct vme_dev *); @@ -620,6 +621,7 @@ static void buf_unalloc(int num) static struct vme_driver vme_user_driver = { .name = driver_name, + .match = vme_user_match, .probe = vme_user_probe, .remove = __devexit_p(vme_user_remove), }; @@ -628,8 +630,6 @@ static struct vme_driver vme_user_driver = { static int __init vme_user_init(void) { int retval = 0; - int i; - struct vme_device_id *ids; printk(KERN_INFO "VME User Space Access Driver\n"); @@ -649,41 +649,30 @@ static int __init vme_user_init(void) bus_num = USER_BUS_MAX; } - - /* Dynamically create the bind table based on module parameters */ - ids = kzalloc(sizeof(struct vme_device_id) * (bus_num + 1), GFP_KERNEL); - if (ids == NULL) { - printk(KERN_ERR "%s: Unable to allocate ID table\n", - driver_name); - retval = -ENOMEM; - goto err_id; - } - - for (i = 0; i < bus_num; i++) { - ids[i].bus = bus[i]; - /* - * We register the driver against the slot occupied by *this* - * card, since it's really a low level way of controlling - * the VME bridge - */ - ids[i].slot = VME_SLOT_CURRENT; - } - - vme_user_driver.bind_table = ids; - - retval = vme_register_driver(&vme_user_driver); + /* + * Here we just register the maximum number of devices we can and + * leave vme_user_match() to allow only 1 to go through to probe(). + * This way, if we later want to allow multiple user access devices, + * we just change the code in vme_user_match(). + */ + retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS); if (retval != 0) goto err_reg; return retval; err_reg: - kfree(ids); -err_id: err_nocard: return retval; } +static int vme_user_match(struct vme_dev *vdev) +{ + if (vdev->id.num >= USER_BUS_MAX) + return 0; + return 1; +} + /* * In this simple access driver, the old behaviour is being preserved as much * as practical. We will therefore reserve the buffers and request the images @@ -896,8 +885,6 @@ static int __devexit vme_user_remove(struct vme_dev *dev) static void __exit vme_user_exit(void) { vme_unregister_driver(&vme_user_driver); - - kfree(vme_user_driver.bind_table); } diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 4bef7893dde..2abb9ebd3d6 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -1317,6 +1317,7 @@ static int vme_add_bus(struct vme_bridge *bridge) if ((vme_bus_numbers & (1 << i)) == 0) { vme_bus_numbers |= (1 << i); bridge->num = i; + INIT_LIST_HEAD(&bridge->devices); list_add_tail(&bridge->bus_list, &vme_bus_list); ret = 0; break; @@ -1329,8 +1330,16 @@ static int vme_add_bus(struct vme_bridge *bridge) static void vme_remove_bus(struct vme_bridge *bridge) { + struct vme_dev *vdev; + struct vme_dev *tmp; + mutex_lock(&vme_buses_lock); vme_bus_numbers &= ~(1 << bridge->num); + list_for_each_entry_safe(vdev, tmp, &bridge->devices, bridge_list) { + list_del(&vdev->drv_list); + list_del(&vdev->bridge_list); + device_unregister(&vdev->dev); + } list_del(&bridge->bus_list); mutex_unlock(&vme_buses_lock); } @@ -1342,153 +1351,153 @@ static void vme_dev_release(struct device *dev) int vme_register_bridge(struct vme_bridge *bridge) { - struct vme_dev *vdev; - int retval; - int i; - - retval = vme_add_bus(bridge); - if (retval) - return retval; - - /* This creates 32 vme "slot" devices. This equates to a slot for each - * ID available in a system conforming to the ANSI/VITA 1-1994 - * specification. - */ - for (i = 0; i < VME_SLOTS_MAX; i++) { - bridge->dev[i] = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); - if (!bridge->dev[i]) { - retval = -ENOMEM; - goto err_devalloc; - } - vdev = bridge->dev[i]; - memset(vdev, 0, sizeof(struct vme_dev)); - - vdev->id.bus = bridge->num; - vdev->id.slot = i + 1; - vdev->bridge = bridge; - vdev->dev.parent = bridge->parent; - vdev->dev.bus = &vme_bus_type; - vdev->dev.release = vme_dev_release; - /* - * We save a pointer to the bridge in platform_data so that we - * can get to it later. We keep driver_data for use by the - * driver that binds against the slot - */ - vdev->dev.platform_data = bridge; - dev_set_name(&vdev->dev, "vme-%x.%x", bridge->num, i + 1); - - retval = device_register(&vdev->dev); - if (retval) - goto err_reg; - } - - return retval; - -err_reg: - kfree(vdev); -err_devalloc: - while (--i >= 0) { - vdev = bridge->dev[i]; - device_unregister(&vdev->dev); - } - vme_remove_bus(bridge); - return retval; + return vme_add_bus(bridge); } EXPORT_SYMBOL(vme_register_bridge); void vme_unregister_bridge(struct vme_bridge *bridge) { - int i; - struct vme_dev *vdev; - - - for (i = 0; i < VME_SLOTS_MAX; i++) { - vdev = bridge->dev[i]; - device_unregister(&vdev->dev); - } vme_remove_bus(bridge); } EXPORT_SYMBOL(vme_unregister_bridge); - /* - Driver Registration --------------------------------------------------- */ -int vme_register_driver(struct vme_driver *drv) +static int __vme_register_driver_bus(struct vme_driver *drv, + struct vme_bridge *bridge, unsigned int ndevs) { + int err; + unsigned int i; + struct vme_dev *vdev; + struct vme_dev *tmp; + + for (i = 0; i < ndevs; i++) { + vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); + if (!vdev) { + err = -ENOMEM; + goto err_devalloc; + } + vdev->id.num = i; + vdev->id.bus = bridge->num; + vdev->id.slot = i + 1; + vdev->bridge = bridge; + vdev->dev.platform_data = drv; + vdev->dev.release = vme_dev_release; + vdev->dev.parent = bridge->parent; + vdev->dev.bus = &vme_bus_type; + dev_set_name(&vdev->dev, "%s.%u-%u", drv->name, vdev->id.bus, + vdev->id.num); + + err = device_register(&vdev->dev); + if (err) + goto err_reg; + + if (vdev->dev.platform_data) { + list_add_tail(&vdev->drv_list, &drv->devices); + list_add_tail(&vdev->bridge_list, &bridge->devices); + } else + device_unregister(&vdev->dev); + } + return 0; + +err_reg: + kfree(vdev); +err_devalloc: + list_for_each_entry_safe(vdev, tmp, &drv->devices, drv_list) { + list_del(&vdev->drv_list); + list_del(&vdev->bridge_list); + device_unregister(&vdev->dev); + } + return err; +} + +static int __vme_register_driver(struct vme_driver *drv, unsigned int ndevs) +{ + struct vme_bridge *bridge; + int err = 0; + + mutex_lock(&vme_buses_lock); + list_for_each_entry(bridge, &vme_bus_list, bus_list) { + /* + * This cannot cause trouble as we already have vme_buses_lock + * and if the bridge is removed, it will have to go through + * vme_unregister_bridge() to do it (which calls remove() on + * the bridge which in turn tries to acquire vme_buses_lock and + * will have to wait). The probe() called after device + * registration in __vme_register_driver below will also fail + * as the bridge is being removed (since the probe() calls + * vme_bridge_get()). + */ + err = __vme_register_driver_bus(drv, bridge, ndevs); + if (err) + break; + } + mutex_unlock(&vme_buses_lock); + return err; +} + +int vme_register_driver(struct vme_driver *drv, unsigned int ndevs) +{ + int err; + drv->driver.name = drv->name; drv->driver.bus = &vme_bus_type; + INIT_LIST_HEAD(&drv->devices); - return driver_register(&drv->driver); + err = driver_register(&drv->driver); + if (err) + return err; + + err = __vme_register_driver(drv, ndevs); + if (err) + driver_unregister(&drv->driver); + + return err; } EXPORT_SYMBOL(vme_register_driver); void vme_unregister_driver(struct vme_driver *drv) { + struct vme_dev *dev, *dev_tmp; + + mutex_lock(&vme_buses_lock); + list_for_each_entry_safe(dev, dev_tmp, &drv->devices, drv_list) { + list_del(&dev->drv_list); + list_del(&dev->bridge_list); + device_unregister(&dev->dev); + } + mutex_unlock(&vme_buses_lock); + driver_unregister(&drv->driver); } EXPORT_SYMBOL(vme_unregister_driver); /* - Bus Registration ------------------------------------------------------ */ -static struct vme_driver *dev_to_vme_driver(struct device *dev) -{ - if (dev->driver == NULL) - printk(KERN_ERR "Bugger dev->driver is NULL\n"); - - return container_of(dev->driver, struct vme_driver, driver); -} - static int vme_bus_match(struct device *dev, struct device_driver *drv) { - struct vme_dev *vdev; - struct vme_bridge *bridge; - struct vme_driver *driver; - int i, num; + struct vme_driver *vme_drv; - vdev = dev_to_vme_dev(dev); - bridge = vdev->bridge; - driver = container_of(drv, struct vme_driver, driver); + vme_drv = container_of(drv, struct vme_driver, driver); - num = vdev->id.slot; - if (num <= 0 || num >= VME_SLOTS_MAX) - goto err_dev; + if (dev->platform_data == vme_drv) { + struct vme_dev *vdev = dev_to_vme_dev(dev); - if (driver->bind_table == NULL) { - dev_err(dev, "Bind table NULL\n"); - goto err_table; + if (vme_drv->match && vme_drv->match(vdev)) + return 1; + + dev->platform_data = NULL; } - - i = 0; - while ((driver->bind_table[i].bus != 0) || - (driver->bind_table[i].slot != 0)) { - - if (bridge->num == driver->bind_table[i].bus) { - if (num == driver->bind_table[i].slot) - return 1; - - if (driver->bind_table[i].slot == VME_SLOT_ALL) - return 1; - - if ((driver->bind_table[i].slot == VME_SLOT_CURRENT) && - (num == vme_slot_get(vdev))) - return 1; - } - i++; - } - -err_dev: -err_table: return 0; } static int vme_bus_probe(struct device *dev) { - struct vme_driver *driver; - struct vme_dev *vdev; int retval = -ENODEV; + struct vme_driver *driver; + struct vme_dev *vdev = dev_to_vme_dev(dev); - driver = dev_to_vme_driver(dev); - vdev = dev_to_vme_dev(dev); + driver = dev->platform_data; if (driver->probe != NULL) retval = driver->probe(vdev); @@ -1498,12 +1507,11 @@ static int vme_bus_probe(struct device *dev) static int vme_bus_remove(struct device *dev) { - struct vme_driver *driver; - struct vme_dev *vdev; int retval = -ENODEV; + struct vme_driver *driver; + struct vme_dev *vdev = dev_to_vme_dev(dev); - driver = dev_to_vme_driver(dev); - vdev = dev_to_vme_dev(dev); + driver = dev->platform_data; if (driver->remove != NULL) retval = driver->remove(vdev); diff --git a/drivers/staging/vme/vme.h b/drivers/staging/vme/vme.h index d442cce33c0..95224d7452e 100644 --- a/drivers/staging/vme/vme.h +++ b/drivers/staging/vme/vme.h @@ -88,15 +88,21 @@ struct vme_resource { extern struct bus_type vme_bus_type; +/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */ +#define VME_MAX_BRIDGES (sizeof(unsigned int)*8) +#define VME_MAX_SLOTS 32 + #define VME_SLOT_CURRENT -1 #define VME_SLOT_ALL -2 /** * VME device identifier structure + * @num: The device ID (ranges from 0 to N-1 for N devices) * @bus: The bus ID of the bus the device is on * @slot: The slot this device is plugged into */ struct vme_device_id { + int num; int bus; int slot; }; @@ -106,21 +112,26 @@ struct vme_device_id { * @id: The ID of the device (currently the bus and slot number) * @bridge: Pointer to the bridge device this device is on * @dev: Internal device structure + * @drv_list: List of devices (per driver) + * @bridge_list: List of devices (per bridge) */ struct vme_dev { struct vme_device_id id; struct vme_bridge *bridge; struct device dev; + struct list_head drv_list; + struct list_head bridge_list; }; struct vme_driver { struct list_head node; const char *name; - const struct vme_device_id *bind_table; - int (*probe) (struct vme_dev *); - int (*remove) (struct vme_dev *); - void (*shutdown) (void); - struct device_driver driver; + int (*match)(struct vme_dev *); + int (*probe)(struct vme_dev *); + int (*remove)(struct vme_dev *); + void (*shutdown)(void); + struct device_driver driver; + struct list_head devices; }; void *vme_alloc_consistent(struct vme_resource *, size_t, dma_addr_t *); @@ -179,7 +190,7 @@ void vme_lm_free(struct vme_resource *); int vme_slot_get(struct vme_dev *); -int vme_register_driver(struct vme_driver *); +int vme_register_driver(struct vme_driver *, unsigned int); void vme_unregister_driver(struct vme_driver *); diff --git a/drivers/staging/vme/vme_api.txt b/drivers/staging/vme/vme_api.txt index 03f48134706..53abf7e7cb4 100644 --- a/drivers/staging/vme/vme_api.txt +++ b/drivers/staging/vme/vme_api.txt @@ -18,24 +18,37 @@ registration function. The structure is as follows: struct vme_driver { struct list_head node; - char *name; - const struct vme_device_id *bind_table; - int (*probe) (struct vme_dev *); - int (*remove) (struct vme_dev *); - void (*shutdown) (void); - struct device_driver driver; + const char *name; + int (*match)(struct vme_dev *); + int (*probe)(struct vme_dev *); + int (*remove)(struct vme_dev *); + void (*shutdown)(void); + struct device_driver driver; + struct list_head devices; + unsigned int ndev; }; -At the minimum, the '.name', '.probe' and '.bind_table' elements of this -structure should be correctly set. The '.name' element is a pointer to a string -holding the device driver's name. The '.probe' element should contain a pointer -to the probe routine. +At the minimum, the '.name', '.match' and '.probe' elements of this structure +should be correctly set. The '.name' element is a pointer to a string holding +the device driver's name. -The arguments of the probe routine are as follows: +The '.match' function allows controlling the number of devices that need to +be registered. The match function should return 1 if a device should be +probed and 0 otherwise. This example match function (from vme_user.c) limits +the number of devices probed to one: - probe(struct vme_dev *dev); + #define USER_BUS_MAX 1 + ... + static int vme_user_match(struct vme_dev *vdev) + { + if (vdev->id.num >= USER_BUS_MAX) + return 0; + return 1; + } -The device structure looks like the following: +The '.probe' element should contain a pointer to the probe routine. The +probe routine is passed a 'struct vme_dev' pointer as an argument. The +'struct vme_dev' structure looks like the following: struct vme_dev { struct vme_device_id id; @@ -49,25 +62,12 @@ contains information useful for the probe function: struct vme_device_id { int bus; int slot; + int num; }; -'bus' is the number of the bus the device being probed is on. 'slot' refers -to the specific slot on the VME bus. - -The '.bind_table' is a pointer to an array of type 'vme_device_id': - - struct vme_device_id { - int bus; - int slot; - }; - -Each structure in this array should provide a bus and slot number where the core -should probe, using the driver's probe routine, for a device on the specified -VME bus. - -The VME subsystem supports a single VME driver per 'slot'. There are considered -to be 32 slots per bus, one for each slot-ID as defined in the ANSI/VITA 1-1994 -specification and are analogious to the physical slots on the VME backplane. +Here, 'bus' is the number of the bus the device being probed is on. 'slot' +refers to the specific slot on the VME bus. The 'num' field refers to the +sequential device ID for this specific driver. A function is also provided to unregister the driver from the VME core and is usually called from the device driver's exit routine: diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h index 6dd2f4cf8b6..c2deda2c38d 100644 --- a/drivers/staging/vme/vme_bridge.h +++ b/drivers/staging/vme/vme_bridge.h @@ -2,7 +2,6 @@ #define _VME_BRIDGE_H_ #define VME_CRCSR_BUF_SIZE (508*1024) -#define VME_SLOTS_MAX 32 /* * Resource structures */ @@ -108,15 +107,13 @@ struct vme_bridge { struct list_head lm_resources; struct list_head vme_errors; /* List for errors generated on VME */ + struct list_head devices; /* List of devices on this bridge */ /* Bridge Info - XXX Move to private structure? */ struct device *parent; /* Parent device (eg. pdev->dev for PCI) */ void *driver_priv; /* Private pointer for the bridge driver */ struct list_head bus_list; /* list of VME buses */ - struct vme_dev *dev[VME_SLOTS_MAX]; /* Device registered - * on VME bus */ - /* Interrupt callbacks */ struct vme_irq irq[7]; /* Locking for VME irq callback configuration */ From a916a391d3e19593a104a8c3c4779a3084f1ca5b Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Mon, 26 Sep 2011 11:27:17 +0200 Subject: [PATCH 1464/1519] staging: vme: get rid of struct vme_device_id and slots Previously, the device-driver matching mechanism depended on the vme_device_id structure due to the need for a bind table per driver. This method of matching is no longer used so this patch merges the fields of struct vme_device_id into struct vme_dev. Since this also renders the slot field meaningless, it has also been removed in this patch. Signed-off-by: Manohar Vanga Cc: Martyn Welch Reviewed-by: Emilio G. Cota Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 2 +- drivers/staging/vme/vme.c | 8 +++----- drivers/staging/vme/vme.h | 14 +------------ drivers/staging/vme/vme_api.txt | 27 +++++++++++--------------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index c658ce9bd61..9518dda13ea 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -668,7 +668,7 @@ err_nocard: static int vme_user_match(struct vme_dev *vdev) { - if (vdev->id.num >= USER_BUS_MAX) + if (vdev->num >= USER_BUS_MAX) return 0; return 1; } diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 2abb9ebd3d6..b04b4688f70 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -1377,16 +1377,14 @@ static int __vme_register_driver_bus(struct vme_driver *drv, err = -ENOMEM; goto err_devalloc; } - vdev->id.num = i; - vdev->id.bus = bridge->num; - vdev->id.slot = i + 1; + vdev->num = i; vdev->bridge = bridge; vdev->dev.platform_data = drv; vdev->dev.release = vme_dev_release; vdev->dev.parent = bridge->parent; vdev->dev.bus = &vme_bus_type; - dev_set_name(&vdev->dev, "%s.%u-%u", drv->name, vdev->id.bus, - vdev->id.num); + dev_set_name(&vdev->dev, "%s.%u-%u", drv->name, bridge->num, + vdev->num); err = device_register(&vdev->dev); if (err) diff --git a/drivers/staging/vme/vme.h b/drivers/staging/vme/vme.h index 95224d7452e..e3828badca6 100644 --- a/drivers/staging/vme/vme.h +++ b/drivers/staging/vme/vme.h @@ -95,18 +95,6 @@ extern struct bus_type vme_bus_type; #define VME_SLOT_CURRENT -1 #define VME_SLOT_ALL -2 -/** - * VME device identifier structure - * @num: The device ID (ranges from 0 to N-1 for N devices) - * @bus: The bus ID of the bus the device is on - * @slot: The slot this device is plugged into - */ -struct vme_device_id { - int num; - int bus; - int slot; -}; - /** * Structure representing a VME device * @id: The ID of the device (currently the bus and slot number) @@ -116,7 +104,7 @@ struct vme_device_id { * @bridge_list: List of devices (per bridge) */ struct vme_dev { - struct vme_device_id id; + int num; struct vme_bridge *bridge; struct device dev; struct list_head drv_list; diff --git a/drivers/staging/vme/vme_api.txt b/drivers/staging/vme/vme_api.txt index 53abf7e7cb4..e8ff2151a48 100644 --- a/drivers/staging/vme/vme_api.txt +++ b/drivers/staging/vme/vme_api.txt @@ -51,23 +51,16 @@ probe routine is passed a 'struct vme_dev' pointer as an argument. The 'struct vme_dev' structure looks like the following: struct vme_dev { - struct vme_device_id id; + int num; struct vme_bridge *bridge; struct device dev; + struct list_head drv_list; + struct list_head bridge_list; }; -The 'bridge' field contains a pointer to the bridge device. The 'id' field -contains information useful for the probe function: - - struct vme_device_id { - int bus; - int slot; - int num; - }; - -Here, 'bus' is the number of the bus the device being probed is on. 'slot' -refers to the specific slot on the VME bus. The 'num' field refers to the -sequential device ID for this specific driver. +Here, the 'num' field refers to the sequential device ID for this specific +driver. The bridge number (or bus number) can be accessed using +dev->bridge->num. A function is also provided to unregister the driver from the VME core and is usually called from the device driver's exit routine: @@ -78,9 +71,11 @@ usually called from the device driver's exit routine: Resource management =================== -Once a driver has registered with the VME core the provided probe routine will -be called for each of the bus/slot combination that becomes valid as VME buses -are themselves registered. The probe routine is passed a pointer to the devices +Once a driver has registered with the VME core the provided match routine will +be called the number of times specified during the registration. If a match +succeeds, a non-zero value should be returned. A zero return value indicates +failure. For all successful matches, the probe routine of the corresponding +driver is called. The probe routine is passed a pointer to the devices device structure. This pointer should be saved, it will be required for requesting VME resources. From 0a4b6b0279d903df2d62aaf92edf360fb5312532 Mon Sep 17 00:00:00 2001 From: Manohar Vanga Date: Mon, 26 Sep 2011 11:27:18 +0200 Subject: [PATCH 1465/1519] staging: vme_user: rename USER_BUS_MAX to VME_USER_BUS_MAX Signed-off-by: Manohar Vanga Cc: Martyn Welch Reviewed-by: Emilio G. Cota Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 10 +++++----- drivers/staging/vme/devices/vme_user.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 9518dda13ea..7dcd1622b5f 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -43,7 +43,7 @@ static DEFINE_MUTEX(vme_user_mutex); static const char driver_name[] = "vme_user"; -static int bus[USER_BUS_MAX]; +static int bus[VME_USER_BUS_MAX]; static unsigned int bus_num; /* Currently Documentation/devices.txt defines the following for VME: @@ -643,10 +643,10 @@ static int __init vme_user_init(void) /* Let's start by supporting one bus, we can support more than one * in future revisions if that ever becomes necessary. */ - if (bus_num > USER_BUS_MAX) { + if (bus_num > VME_USER_BUS_MAX) { printk(KERN_ERR "%s: Driver only able to handle %d buses\n", - driver_name, USER_BUS_MAX); - bus_num = USER_BUS_MAX; + driver_name, VME_USER_BUS_MAX); + bus_num = VME_USER_BUS_MAX; } /* @@ -668,7 +668,7 @@ err_nocard: static int vme_user_match(struct vme_dev *vdev) { - if (vdev->num >= USER_BUS_MAX) + if (vdev->num >= VME_USER_BUS_MAX) return 0; return 1; } diff --git a/drivers/staging/vme/devices/vme_user.h b/drivers/staging/vme/devices/vme_user.h index 24bf4e54013..d85a1e9dbe3 100644 --- a/drivers/staging/vme/devices/vme_user.h +++ b/drivers/staging/vme/devices/vme_user.h @@ -1,7 +1,7 @@ #ifndef _VME_USER_H_ #define _VME_USER_H_ -#define USER_BUS_MAX 1 +#define VME_USER_BUS_MAX 1 /* * VMEbus Master Window Configuration Structure From d199fb7d6d83e185fde1a784ea9e45103db19581 Mon Sep 17 00:00:00 2001 From: Oren Weil Date: Mon, 17 Oct 2011 08:06:17 +0200 Subject: [PATCH 1466/1519] staging: mei: clean the TODO file from done tasks. 1) We move the AMT Watchdog to use the kernel watchdog core. the new code is still part of the MEI driver. we didn't find any good reason to extract the the MEI driver watchdog code from the MEI Driver to a new module. 2) Since the watchdog remains in the mei driver, exposing in-kernel API just for AMTHI is unnecessary. MEI new Watchdog Core Interface Patches set: https://lkml.org/lkml/2011/9/7/26 3) Code cleanup (init and probe, bug_on usage, headers and etc) was submitted in previous patches. Patches: https://lkml.org/lkml/2011/9/21/231 https://lkml.org/lkml/2011/6/15/358 https://lkml.org/lkml/2011/7/7/177 https://lkml.org/lkml/2011/9/7/38 https://lkml.org/lkml/2011/9/7/37 https://lkml.org/lkml/2011/9/7/28 4) mei.txt was updated with additional information. Patch: https://lkml.org/lkml/2011/10/16/52 Acked-by: Tomas Winkler Signed-off-by: Oren Weil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/TODO | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/mei/TODO b/drivers/staging/mei/TODO index 3b6a667a580..7d9a13b0f2d 100644 --- a/drivers/staging/mei/TODO +++ b/drivers/staging/mei/TODO @@ -1,14 +1,4 @@ TODO: - - Create in-kernel Client API. Examples of in-kernel clients are watchdog and AMTHI. - - ME Watchdog Driver to expose standard Linux watchdog interface - - Rewrite AMTHI to use in-kernel client interface - - Cleanup init and probe functions - - Review BUG/BUG_ON usage - - Cleanup and reorganize header files - - Rewrite client data structure - - Make state machine more readable - - Add mei.txt with driver explanation and it's driver - - Fix Kconfig - Cleanup and split the timer function Upon Unstaging: - move mei.h to include/linux/mei.h From 74116f561add85d03faabda3200e824dfeb9b6fe Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 18 Oct 2011 13:34:59 -0700 Subject: [PATCH 1467/1519] Staging: wlags49_h2: Makefile: remove unneeded stuff There's a lot of unused and unneeded things in this makefile, so delete it all. Reported-by: Grant Likely Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/Makefile | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/wlags49_h2/Makefile b/drivers/staging/wlags49_h2/Makefile index c7220c61096..31e1d89a384 100644 --- a/drivers/staging/wlags49_h2/Makefile +++ b/drivers/staging/wlags49_h2/Makefile @@ -11,7 +11,6 @@ # # If you want to build AP support (untested), comment out -DSTA_ONLY -INSTALLDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless ccflags-y := -I$(KERNELDIR)/include ccflags-y += -I$(src) \ -DBUS_PCMCIA \ @@ -38,9 +37,6 @@ $(WLNAME)-y += ap_h25.o endif endif -# If KERNELRELEASE is defined, we've been invoked from the -# kernel build system and can use its language. -ifneq ($(KERNELRELEASE),) obj-m += $(WLNAME).o @@ -57,24 +53,3 @@ $(WLNAME)-y += wl_profile.o \ dhf.o $(WLNAME)-$(CONFIG_SYSFS) += wl_sysfs.o - -# Otherwise we were called directly from the command -# line; invoke the kernel build system. -else - KERNELDIR ?= /lib/modules/$(shell uname -r)/build - PWD := $(shell pwd) - -default: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules -endif - -clean: - rm -fr *.o *.ko *.mod.c *.mod.o .*.*.cmd Module.symvers \ - Module.markers modules.order .tmp_versions - -install: default - -rmmod $(WLNAME) - install -d $(INSTALLDIR) - install -m 0644 -o root -g root $(WLNAME).ko $(INSTALLDIR) - /sbin/depmod -aq - From 5f9819c70991e7a4c68fb620fcfa80c5b38c4f86 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 18 Oct 2011 13:36:04 -0700 Subject: [PATCH 1468/1519] Staging: wlags49_h25: Makefile: remove unneeded stuff There's a lot of unused and unneeded things in this makefile, so delete it all. Reported-by: Grant Likely Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h25/Makefile | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/wlags49_h25/Makefile b/drivers/staging/wlags49_h25/Makefile index fe829299610..6e0159d0a34 100644 --- a/drivers/staging/wlags49_h25/Makefile +++ b/drivers/staging/wlags49_h25/Makefile @@ -11,7 +11,6 @@ # # If you want to build AP support (untested), comment out -DSTA_ONLY -INSTALLDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless ccflags-y := -I$(KERNELDIR)/include ccflags-y += -I$(src) \ -DBUS_PCMCIA \ @@ -38,10 +37,6 @@ $(WLNAME)-y += ap_h25.o endif endif -# If KERNELRELEASE is defined, we've been invoked from the -# kernel build system and can use its language. -ifneq ($(KERNELRELEASE),) - obj-m += $(WLNAME).o $(WLNAME)-y += wl_profile.o \ @@ -58,23 +53,3 @@ $(WLNAME)-y += wl_profile.o \ $(WLNAME)-$(CONFIG_SYSFS) += wl_sysfs.o -# Otherwise we were called directly from the command -# line; invoke the kernel build system. -else - KERNELDIR ?= /lib/modules/$(shell uname -r)/build - PWD := $(shell pwd) - -default: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules -endif - -clean: - rm -fr *.o *.ko *.mod.c *.mod.o .*.*.cmd Module.symvers \ - Module.markers modules.order .tmp_versions - -install: default - -rmmod $(WLNAME) - install -d $(INSTALLDIR) - install -m 0644 -o root -g root $(WLNAME).ko $(INSTALLDIR) - /sbin/depmod -aq - From 4535743304c7652f8e4a6dc35276d466fd97c0e3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 18 Oct 2011 13:36:18 -0700 Subject: [PATCH 1469/1519] Staging: rtl8192u: ieee80211: Makefile: remove unneeded stuff There's a lot of unused and unneeded things in this makefile, so delete it all. Reported-by: Grant Likely Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/Makefile | 109 -------------------- 1 file changed, 109 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/Makefile b/drivers/staging/rtl8192u/ieee80211/Makefile index 0775c5599d6..51effd6412a 100644 --- a/drivers/staging/rtl8192u/ieee80211/Makefile +++ b/drivers/staging/rtl8192u/ieee80211/Makefile @@ -1,25 +1,9 @@ NIC_SELECT = RTL8192U -KVER := $(shell uname -r) -MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/$(NIC_SELECT) - -CC = gcc -ifneq ($(shell uname -r|cut -d. -f1,2), 2.4) ccflags-y := -I$(TOPDIR)/drivers/net/wireless ccflags-y += -O2 ccflags-y += -DJACKSON_NEW_8187 -DJACKSON_NEW_RX -#it will fail to compile in suse linux enterprise 10 sp2. This flag is to solve this problem. -ifeq ($(shell uname -r | cut -d. -f1,2,3,4), 2.6.16.60-0) -ccflags-y := -DOPENSUSE_SLED -endif - -ifeq ($(NIC_SELECT),RTL8192U) -#ccflags-y := -DUSB_TX_DRIVER_AGGREGATION_ENABLE -#ccflags-y := -DUSB_RX_AGGREGATION_SUPPORT -endif -#ccflags-y := -DJOHN_NOCPY -#flags to enable or disble 80211D feature ieee80211-rsl-objs := ieee80211_rx.o \ ieee80211_softmac.o \ ieee80211_tx.o \ @@ -42,96 +26,3 @@ obj-m +=ieee80211_crypt_wep-rsl.o obj-m +=ieee80211_crypt_tkip-rsl.o obj-m +=ieee80211_crypt_ccmp-rsl.o -KSRC := /lib/modules/$(KVER)/build -INSTALL_PREFIX := - -all: modules - -modules: - $(MAKE) -C $(KSRC) M=$(PWD) CC=$(CC) modules - -install: modules - rm -fr $(MODDESTDIR) - mkdir -p $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt-rsl.ko $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_wep-rsl.ko $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_tkip-rsl.ko $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_ccmp-rsl.ko $(MODDESTDIR) - @install -p -m 644 ieee80211-rsl.ko $(MODDESTDIR) - depmod -a -uninstall: - rm -fr $(MODDESTDIR) - depmod -a - -else -LD := ld -KSRC := /lib/modules/$(KVER)/build -CONFIG_FILE := $(KSRC)/include/linux/autoconf.h - -CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall -CFLAGS += -I$(KSRC)/include -I. -#Kernel 2.4.31 -CFLAGS += -DMODVERSIONS -DEXPORT_SYMTAB -include $(KSRC)/include/linux/modversions.h -#Kernel 2.4.20 -#CFLAGS += -D__NO_VERSION__ -DEXPORT_SYMTAB -SMP := $(shell $(CC) $(MODCFLAGS) -E -dM $(CONFIG_FILE) | \ - grep CONFIG_SMP | awk '{print $$3}') -ifneq ($(SMP),1) - SMP := 0 -endif -ifeq ($(SMP),1) - CFLAGS += -D__SMP__ -endif - -#CFLAGS += -DJOHN_NOCPY - -OBJS := ${patsubst %.c, %.o, ${wildcard *.c}} -all:${OBJS} ieee80211_crypt-rsl.o michael_mic-rsl.o aes-rsl.o ieee80211_crypt_wep-rsl.o ieee80211_crypt_tkip-rsl.o ieee80211_crypt_ccmp-rsl.o crypto-rsl.o ieee80211-rsl.o - -ieee80211_crypt-rsl.o: ieee80211_crypt.o - mv $^ $@ - -michael_mic-rsl.o: michael_mic.o - mv $^ $@ - -aes-rsl.o: aes.o - mv $^ $@ - -ieee80211_crypt_wep-rsl.o: ieee80211_crypt_wep.o - mv $^ $@ - -ieee80211_crypt_tkip-rsl.o: ieee80211_crypt_tkip.o - mv $^ $@ - -ieee80211_crypt_ccmp-rsl.o: ieee80211_crypt_ccmp.o - mv $^ $@ - -crypto-rsl.o: arc4.o api.o autoload.o cipher.o compress.o digest.o scatterwalk.o proc.o - $(LD) -r $^ -o $@ - -ieee80211-rsl.o: ieee80211_rx.o ieee80211_tx.o ieee80211_wx.o ieee80211_module.o ieee80211_softmac_wx.o ieee80211_softmac.o rtl819x_HTProc.o rtl819x_TSProc.o rtl819x_BAProc.o dot11d.o - $(LD) -r $^ -o $@ -install: - rm -fr $(MODDESTDIR) - mkdir -p $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt-rsl.o $(MODDESTDIR) - @install -p -m 644 crypto-rsl.o $(MODDESTDIR) - @install -p -m 644 michael_mic-rsl.o $(MODDESTDIR) - @install -p -m 644 aes-rsl.o $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_wep-rsl.o $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_tkip-rsl.o $(MODDESTDIR) - @install -p -m 644 ieee80211_crypt_ccmp-rsl.o $(MODDESTDIR) - @install -p -m 644 ieee80211-rsl.o $(MODDESTDIR) - /sbin/depmod -a ${shell uname -r} - -uninstall: - rm -fr $(MODDESTDIR) - /sbin/depmod -a ${shell uname -r} - -endif - -.PHONY: clean -clean: - rm -fr *.mod.c *.mod *.o .*.cmd *.mod.* *.ko *.o *~ - rm -rf .tmp_versions - rm -rf Module.symvers From 6b7200fe0a59d7bda59e9e028b235b25a137dff9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 18 Oct 2011 09:27:25 +0300 Subject: [PATCH 1470/1519] Staging: vt6655: memory corruption in check in wpa_set_wpadev() The original code left it up to the user to decide how much data to copy, but that doesn't work with a fixed size array. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wpactl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index a0f994ed58f..732ba88dc79 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -213,7 +213,9 @@ int wpa_set_wpadev(PSDevice pDevice, int val) int uu, ii; - if (param->u.wpa_key.alg_name > WPA_ALG_CCMP) + if (param->u.wpa_key.alg_name > WPA_ALG_CCMP || + param->u.wpa_key.key_len >= MAX_KEY_LEN || + param->u.wpa_key.seq_len >= MAX_KEY_LEN) return -EINVAL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "param->u.wpa_key.alg_name = %d \n", param->u.wpa_key.alg_name); From fcde2bf0b9a0581db9fe5382e0c90f526c011114 Mon Sep 17 00:00:00 2001 From: Vladimir Zapolskiy Date: Wed, 19 Oct 2011 22:39:12 +0300 Subject: [PATCH 1471/1519] staging: tidspbridge: MMU2 registers are limited to 32-bit data access According to OMAP3 TRM access to MMU registers shall be strictly 32-bit aligned. Signed-off-by: Vladimir Zapolskiy Acked-by: Omar Ramirez Luna Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/hw/hw_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/tidspbridge/hw/hw_mmu.c b/drivers/staging/tidspbridge/hw/hw_mmu.c index c214df9b205..8a93d55ca59 100644 --- a/drivers/staging/tidspbridge/hw/hw_mmu.c +++ b/drivers/staging/tidspbridge/hw/hw_mmu.c @@ -558,5 +558,5 @@ static hw_status mmu_set_ram_entry(const void __iomem *base_address, void hw_mmu_tlb_flush_all(const void __iomem *base) { - __raw_writeb(1, base + MMU_GFLUSH); + __raw_writel(1, base + MMU_GFLUSH); } From fcf265d68dd990bd8be648ba5a590f887aa0d5cf Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Oct 2011 09:33:03 +0200 Subject: [PATCH 1472/1519] staging:iio:dac: Add AD5064 driver This patch adds support for the Analog Devices AD6064, AD6064-1, AD6044, AD6024 quad channel digital-to-analog converter devices. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/Kconfig | 10 + drivers/staging/iio/dac/Makefile | 1 + drivers/staging/iio/dac/ad5064.c | 463 +++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+) create mode 100644 drivers/staging/iio/dac/ad5064.c diff --git a/drivers/staging/iio/dac/Kconfig b/drivers/staging/iio/dac/Kconfig index 30001567ef0..724af7fb5b3 100644 --- a/drivers/staging/iio/dac/Kconfig +++ b/drivers/staging/iio/dac/Kconfig @@ -3,6 +3,16 @@ # menu "Digital to analog convertors" +config AD5064 + tristate "Analog Devices AD5064/64-1/44/24 DAC driver" + depends on SPI + help + Say yes here to build support for Analog Devices AD5064, AD5064-1, + AD5044, AD5024 Digital to Analog Converter. + + To compile this driver as a module, choose M here: the + module will be called ad5064. + config AD5624R_SPI tristate "Analog Devices AD5624/44/64R DAC spi driver" depends on SPI diff --git a/drivers/staging/iio/dac/Makefile b/drivers/staging/iio/dac/Makefile index 7f4f2ed031e..ea4975031fe 100644 --- a/drivers/staging/iio/dac/Makefile +++ b/drivers/staging/iio/dac/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_AD5624R_SPI) += ad5624r_spi.o +obj-$(CONFIG_AD5064) += ad5064.o obj-$(CONFIG_AD5504) += ad5504.o obj-$(CONFIG_AD5446) += ad5446.o obj-$(CONFIG_AD5791) += ad5791.o diff --git a/drivers/staging/iio/dac/ad5064.c b/drivers/staging/iio/dac/ad5064.c new file mode 100644 index 00000000000..24279f2ae41 --- /dev/null +++ b/drivers/staging/iio/dac/ad5064.c @@ -0,0 +1,463 @@ +/* + * AD5064, AD5064-1, AD5044, AD5024 Digital to analog converters driver + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" +#include "dac.h" + +#define AD5064_DAC_CHANNELS 4 + +#define AD5064_ADDR(x) ((x) << 20) +#define AD5064_CMD(x) ((x) << 24) + +#define AD5064_ADDR_DAC(chan) (chan) +#define AD5064_ADDR_ALL_DAC 0xF + +#define AD5064_CMD_WRITE_INPUT_N 0x0 +#define AD5064_CMD_UPDATE_DAC_N 0x1 +#define AD5064_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2 +#define AD5064_CMD_WRITE_INPUT_N_UPDATE_N 0x3 +#define AD5064_CMD_POWERDOWN_DAC 0x4 +#define AD5064_CMD_CLEAR 0x5 +#define AD5064_CMD_LDAC_MASK 0x6 +#define AD5064_CMD_RESET 0x7 +#define AD5064_CMD_DAISY_CHAIN_ENABLE 0x8 + +#define AD5064_LDAC_PWRDN_NONE 0x0 +#define AD5064_LDAC_PWRDN_1K 0x1 +#define AD5064_LDAC_PWRDN_100K 0x2 +#define AD5064_LDAC_PWRDN_3STATE 0x3 + +/** + * struct ad5064_chip_info - chip specific information + * @shared_vref: whether the vref supply is shared between channels + * @channel: channel specification +*/ + +struct ad5064_chip_info { + bool shared_vref; + struct iio_chan_spec channel[AD5064_DAC_CHANNELS]; +}; + +/** + * struct ad5064_state - driver instance specific data + * @spi: spi_device + * @chip_info: chip model specific constants, available modes etc + * @vref_reg: vref supply regulators + * @pwr_down: whether channel is powered down + * @pwr_down_mode: channel's current power down mode + * @dac_cache: current DAC raw value (chip does not support readback) + * @data: spi transfer buffers + */ + +struct ad5064_state { + struct spi_device *spi; + const struct ad5064_chip_info *chip_info; + struct regulator_bulk_data vref_reg[AD5064_DAC_CHANNELS]; + bool pwr_down[AD5064_DAC_CHANNELS]; + u8 pwr_down_mode[AD5064_DAC_CHANNELS]; + unsigned int dac_cache[AD5064_DAC_CHANNELS]; + + /* + * DMA (thus cache coherency maintenance) requires the + * transfer buffers to live in their own cache lines. + */ + __be32 data ____cacheline_aligned; +}; + +enum ad5064_type { + ID_AD5024, + ID_AD5044, + ID_AD5064, + ID_AD5064_1, +}; + +#define AD5064_CHANNEL(chan, bits) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (chan), \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE), \ + .address = AD5064_ADDR_DAC(chan), \ + .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)) \ +} + +static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { + [ID_AD5024] = { + .shared_vref = false, + .channel[0] = AD5064_CHANNEL(0, 12), + .channel[1] = AD5064_CHANNEL(1, 12), + .channel[2] = AD5064_CHANNEL(2, 12), + .channel[3] = AD5064_CHANNEL(3, 12), + }, + [ID_AD5044] = { + .shared_vref = false, + .channel[0] = AD5064_CHANNEL(0, 14), + .channel[1] = AD5064_CHANNEL(1, 14), + .channel[2] = AD5064_CHANNEL(2, 14), + .channel[3] = AD5064_CHANNEL(3, 14), + }, + [ID_AD5064] = { + .shared_vref = false, + .channel[0] = AD5064_CHANNEL(0, 16), + .channel[1] = AD5064_CHANNEL(1, 16), + .channel[2] = AD5064_CHANNEL(2, 16), + .channel[3] = AD5064_CHANNEL(3, 16), + }, + [ID_AD5064_1] = { + .shared_vref = true, + .channel[0] = AD5064_CHANNEL(0, 16), + .channel[1] = AD5064_CHANNEL(1, 16), + .channel[2] = AD5064_CHANNEL(2, 16), + .channel[3] = AD5064_CHANNEL(3, 16), + }, +}; + +static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd, + unsigned int addr, unsigned int val, unsigned int shift) +{ + val <<= shift; + + st->data = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); + + return spi_write(st->spi, &st->data, sizeof(st->data)); +} + +static int ad5064_sync_powerdown_mode(struct ad5064_state *st, + unsigned int channel) +{ + unsigned int val; + int ret; + + val = (0x1 << channel); + + if (st->pwr_down[channel]) + val |= st->pwr_down_mode[channel] << 8; + + ret = ad5064_spi_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0); + + return ret; +} + +static const char ad5064_powerdown_modes[][15] = { + [AD5064_LDAC_PWRDN_NONE] = "", + [AD5064_LDAC_PWRDN_1K] = "1kohm_to_gnd", + [AD5064_LDAC_PWRDN_100K] = "100kohm_to_gnd", + [AD5064_LDAC_PWRDN_3STATE] = "three_state", +}; + +static ssize_t ad5064_read_powerdown_mode(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5064_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%s\n", + ad5064_powerdown_modes[st->pwr_down_mode[this_attr->address]]); +} + +static ssize_t ad5064_write_powerdown_mode(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5064_state *st = iio_priv(indio_dev); + unsigned int mode, i; + int ret; + + mode = 0; + + for (i = 1; i < ARRAY_SIZE(ad5064_powerdown_modes); ++i) { + if (sysfs_streq(buf, ad5064_powerdown_modes[i])) { + mode = i; + break; + } + } + if (mode == 0) + return -EINVAL; + + mutex_lock(&indio_dev->mlock); + st->pwr_down_mode[this_attr->address] = mode; + + ret = ad5064_sync_powerdown_mode(st, this_attr->address); + mutex_unlock(&indio_dev->mlock); + + return ret ? ret : len; +} + +static ssize_t ad5064_read_dac_powerdown(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5064_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + return sprintf(buf, "%d\n", st->pwr_down[this_attr->address]); +} + +static ssize_t ad5064_write_dac_powerdown(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5064_state *st = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + bool pwr_down; + int ret; + + ret = strtobool(buf, &pwr_down); + if (ret) + return ret; + + mutex_lock(&indio_dev->mlock); + st->pwr_down[this_attr->address] = pwr_down; + + ret = ad5064_sync_powerdown_mode(st, this_attr->address); + mutex_unlock(&indio_dev->mlock); + return ret ? ret : len; +} + +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, + "1kohm_to_gnd 100kohm_to_gnd three_state"); + +#define IIO_DEV_ATTR_DAC_POWERDOWN_MODE(_chan) \ + IIO_DEVICE_ATTR(out_voltage##_chan##_powerdown_mode, \ + S_IRUGO | S_IWUSR, \ + ad5064_read_powerdown_mode, \ + ad5064_write_powerdown_mode, _chan); + +#define IIO_DEV_ATTR_DAC_POWERDOWN(_chan) \ + IIO_DEVICE_ATTR(out_voltage##_chan##_powerdown, \ + S_IRUGO | S_IWUSR, \ + ad5064_read_dac_powerdown, \ + ad5064_write_dac_powerdown, _chan) + +static IIO_DEV_ATTR_DAC_POWERDOWN(0); +static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(0); +static IIO_DEV_ATTR_DAC_POWERDOWN(1); +static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(1); +static IIO_DEV_ATTR_DAC_POWERDOWN(2); +static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(2); +static IIO_DEV_ATTR_DAC_POWERDOWN(3); +static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(3); + +static struct attribute *ad5064_attributes[] = { + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage1_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage2_powerdown_mode.dev_attr.attr, + &iio_dev_attr_out_voltage3_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group ad5064_attribute_group = { + .attrs = ad5064_attributes, +}; + +static int ad5064_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad5064_state *st = iio_priv(indio_dev); + unsigned long scale_uv; + unsigned int vref; + + switch (m) { + case 0: + *val = st->dac_cache[chan->channel]; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + vref = st->chip_info->shared_vref ? 0 : chan->channel; + scale_uv = regulator_get_voltage(st->vref_reg[vref].consumer); + if (scale_uv < 0) + return scale_uv; + + scale_uv = (scale_uv * 100) >> chan->scan_type.realbits; + *val = scale_uv / 100000; + *val2 = (scale_uv % 100000) * 10; + return IIO_VAL_INT_PLUS_MICRO; + default: + break; + } + return -EINVAL; +} + +static int ad5064_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, int val2, long mask) +{ + struct ad5064_state *st = iio_priv(indio_dev); + int ret; + + switch (mask) { + case 0: + if (val > (1 << chan->scan_type.realbits) || val < 0) + return -EINVAL; + + mutex_lock(&indio_dev->mlock); + ret = ad5064_spi_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N, + chan->address, val, chan->scan_type.shift); + if (ret == 0) + st->dac_cache[chan->channel] = val; + mutex_unlock(&indio_dev->mlock); + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static const struct iio_info ad5064_info = { + .read_raw = ad5064_read_raw, + .write_raw = ad5064_write_raw, + .attrs = &ad5064_attribute_group, + .driver_module = THIS_MODULE, +}; + +static inline unsigned int ad5064_num_vref(struct ad5064_state *st) +{ + return st->chip_info->shared_vref ? 1 : AD5064_DAC_CHANNELS; +} + +static const char * const ad5064_vref_names[] = { + "vrefA", + "vrefB", + "vrefC", + "vrefD", +}; + +static const char * const ad5064_vref_name(struct ad5064_state *st, + unsigned int vref) +{ + return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref]; +} + +static int __devinit ad5064_probe(struct spi_device *spi) +{ + enum ad5064_type type = spi_get_device_id(spi)->driver_data; + struct iio_dev *indio_dev; + struct ad5064_state *st; + unsigned int i; + int ret; + + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + + st->chip_info = &ad5064_chip_info_tbl[type]; + st->spi = spi; + + for (i = 0; i < ad5064_num_vref(st); ++i) + st->vref_reg[i].supply = ad5064_vref_name(st, i); + + ret = regulator_bulk_get(&st->spi->dev, ad5064_num_vref(st), + st->vref_reg); + if (ret) + goto error_free; + + ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); + if (ret) + goto error_free_reg; + + for (i = 0; i < AD5064_DAC_CHANNELS; ++i) { + st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K; + st->dac_cache[i] = 0x8000; + } + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad5064_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = st->chip_info->channel; + indio_dev->num_channels = AD5064_DAC_CHANNELS; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_disable_reg; + + return 0; + +error_disable_reg: + regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); +error_free_reg: + regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); +error_free: + iio_free_device(indio_dev); + + return ret; +} + + +static int __devexit ad5064_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad5064_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); + regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); + + iio_free_device(indio_dev); + + return 0; +} + +static const struct spi_device_id ad5064_id[] = { + {"ad5024", ID_AD5024}, + {"ad5044", ID_AD5044}, + {"ad5064", ID_AD5064}, + {"ad5064-1", ID_AD5064_1}, + {} +}; +MODULE_DEVICE_TABLE(spi, ad5064_id); + +static struct spi_driver ad5064_driver = { + .driver = { + .name = "ad5064", + .owner = THIS_MODULE, + }, + .probe = ad5064_probe, + .remove = __devexit_p(ad5064_remove), + .id_table = ad5064_id, +}; + +static __init int ad5064_spi_init(void) +{ + return spi_register_driver(&ad5064_driver); +} +module_init(ad5064_spi_init); + +static __exit void ad5064_spi_exit(void) +{ + spi_unregister_driver(&ad5064_driver); +} +module_exit(ad5064_spi_exit); + +MODULE_AUTHOR("Lars-Peter Clausen "); +MODULE_DESCRIPTION("Analog Devices AD5064/64-1/44/24 DAC"); +MODULE_LICENSE("GPL v2"); From e63abd0a1b757f6433869c13da4cf1b07fc14284 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 19 Oct 2011 11:17:53 +0200 Subject: [PATCH 1473/1519] iio: Spell fix - consistent use of Converter - no functional changes Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/Kconfig | 18 +++++++++--------- drivers/staging/iio/addac/Kconfig | 2 +- drivers/staging/iio/dac/Kconfig | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index bfe91d77fe7..13e93fb97a7 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -1,7 +1,7 @@ # # ADC drivers # -menu "Analog to digital convertors" +menu "Analog to digital converters" config AD7150 tristate "Analog Devices ad7150/1/6 capacitive sensor driver" @@ -42,7 +42,7 @@ config AD7606 select IIO_SW_RING help Say yes here to build support for Analog Devices: - ad7606, ad7606-6, ad7606-4 analog to digital convertors (ADC). + ad7606, ad7606-6, ad7606-4 analog to digital converters (ADC). To compile this driver as a module, choose M here: the module will be called ad7606. @@ -70,7 +70,7 @@ config AD799X help Say yes here to build support for Analog Devices: ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 - i2c analog to digital convertors (ADC). Provides direct access + i2c analog to digital converters (ADC). Provides direct access via sysfs. config AD799X_RING_BUFFER @@ -91,7 +91,7 @@ config AD7476 help Say yes here to build support for Analog Devices AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, AD7495 - SPI analog to digital convertors (ADC). + SPI analog to digital converters (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the @@ -105,7 +105,7 @@ config AD7887 select IIO_TRIGGER help Say yes here to build support for Analog Devices - AD7887 SPI analog to digital convertor (ADC). + AD7887 SPI analog to digital converter (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the @@ -117,7 +117,7 @@ config AD7780 depends on GPIOLIB help Say yes here to build support for Analog Devices - AD7780 and AD7781 SPI analog to digital convertors (ADC). + AD7780 and AD7781 SPI analog to digital converters (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the @@ -131,7 +131,7 @@ config AD7793 select IIO_TRIGGER help Say yes here to build support for Analog Devices - AD7792 and AD7793 SPI analog to digital convertors (ADC). + AD7792 and AD7793 SPI analog to digital converters (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the @@ -163,7 +163,7 @@ config AD7192 select IIO_TRIGGER help Say yes here to build support for Analog Devices AD7190, - AD7192 or AD7195 SPI analog to digital convertors (ADC). + AD7192 or AD7195 SPI analog to digital converters (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the @@ -200,7 +200,7 @@ config MAX1363 select MAX1363_RING_BUFFER help Say yes here to build support for many Maxim i2c analog to digital - convertors (ADC). (max1361, max1362, max1363, max1364, max1036, + converters (ADC). (max1361, max1362, max1363, max1364, max1036, max1037, max1038, max1039, max1136, max1136, max1137, max1138, max1139, max1236, max1237, max11238, max1239, max11600, max11601, max11602, max11603, max11604, max11605, max11606, max11607, diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig index 4b763753454..698a8970b37 100644 --- a/drivers/staging/iio/addac/Kconfig +++ b/drivers/staging/iio/addac/Kconfig @@ -1,7 +1,7 @@ # # ADDAC drivers # -menu "Analog digital bi-direction convertors" +menu "Analog digital bi-direction converters" config ADT7316 tristate "Analog Devices ADT7316/7/8 ADT7516/7/9 temperature sensor, ADC and DAC driver" diff --git a/drivers/staging/iio/dac/Kconfig b/drivers/staging/iio/dac/Kconfig index 724af7fb5b3..72281f87caa 100644 --- a/drivers/staging/iio/dac/Kconfig +++ b/drivers/staging/iio/dac/Kconfig @@ -1,7 +1,7 @@ # # DAC drivers # -menu "Digital to analog convertors" +menu "Digital to analog converters" config AD5064 tristate "Analog Devices AD5064/64-1/44/24 DAC driver" @@ -18,7 +18,7 @@ config AD5624R_SPI depends on SPI help Say yes here to build support for Analog Devices AD5624R, AD5644R and - AD5664R convertors (DAC). This driver uses the common SPI interface. + AD5664R converters (DAC). This driver uses the common SPI interface. config AD5446 tristate "Analog Devices AD5444/6, AD5620/40/60 and AD5542A/12A DAC SPI driver" From 5c48cb9de1fb9702d5cfbf659840d02fb226b601 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 19 Oct 2011 13:02:03 +0200 Subject: [PATCH 1474/1519] iio: adc: Relocate Capacitance to Digital Converters (CDC) into own subdir No functional changes. Fix Kconfig description. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Kconfig | 1 + drivers/staging/iio/Makefile | 1 + drivers/staging/iio/adc/Kconfig | 24 --------------- drivers/staging/iio/adc/Makefile | 3 -- drivers/staging/iio/cdc/Kconfig | 36 +++++++++++++++++++++++ drivers/staging/iio/cdc/Makefile | 7 +++++ drivers/staging/iio/{adc => cdc}/ad7150.c | 0 drivers/staging/iio/{adc => cdc}/ad7152.c | 0 drivers/staging/iio/{adc => cdc}/ad7746.c | 0 drivers/staging/iio/{adc => cdc}/ad7746.h | 0 10 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 drivers/staging/iio/cdc/Kconfig create mode 100644 drivers/staging/iio/cdc/Makefile rename drivers/staging/iio/{adc => cdc}/ad7150.c (100%) rename drivers/staging/iio/{adc => cdc}/ad7152.c (100%) rename drivers/staging/iio/{adc => cdc}/ad7746.c (100%) rename drivers/staging/iio/{adc => cdc}/ad7746.h (100%) diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index 09cf5800c8e..4ec9118955f 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -59,6 +59,7 @@ config IIO_CONSUMERS_PER_TRIGGER source "drivers/staging/iio/accel/Kconfig" source "drivers/staging/iio/adc/Kconfig" source "drivers/staging/iio/addac/Kconfig" +source "drivers/staging/iio/cdc/Kconfig" source "drivers/staging/iio/dac/Kconfig" source "drivers/staging/iio/dds/Kconfig" source "drivers/staging/iio/gyro/Kconfig" diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index eaa07b07d58..1340aead18b 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_IIO_DUMMY_EVGEN) += iio_dummy_evgen.o obj-y += accel/ obj-y += adc/ obj-y += addac/ +obj-y += cdc/ obj-y += dac/ obj-y += dds/ obj-y += gyro/ diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 13e93fb97a7..d9decea4fa6 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -3,20 +3,6 @@ # menu "Analog to digital converters" -config AD7150 - tristate "Analog Devices ad7150/1/6 capacitive sensor driver" - depends on I2C - help - Say yes here to build support for Analog Devices capacitive sensors. - (ad7150, ad7151, ad7156) Provides direct access via sysfs. - -config AD7152 - tristate "Analog Devices ad7152/3 capacitive sensor driver" - depends on I2C - help - Say yes here to build support for Analog Devices capacitive sensors. - (ad7152, ad7153) Provides direct access via sysfs. - config AD7291 tristate "Analog Devices AD7291 ADC driver" depends on I2C @@ -137,16 +123,6 @@ config AD7793 To compile this driver as a module, choose M here: the module will be called AD7793. -config AD7746 - tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver" - depends on I2C - help - Say yes here to build support for Analog Devices capacitive sensors. - (AD7745, AD7746, AD7747) Provides direct access via sysfs. - - To compile this driver as a module, choose M here: the - module will be called ad7745. - config AD7816 tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index be7faaa2465..ceee7f3c306 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -29,10 +29,7 @@ ad7298-y := ad7298_core.o ad7298-$(CONFIG_IIO_BUFFER) += ad7298_ring.o obj-$(CONFIG_AD7298) += ad7298.o -obj-$(CONFIG_AD7150) += ad7150.o -obj-$(CONFIG_AD7152) += ad7152.o obj-$(CONFIG_AD7291) += ad7291.o -obj-$(CONFIG_AD7746) += ad7746.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7816) += ad7816.o diff --git a/drivers/staging/iio/cdc/Kconfig b/drivers/staging/iio/cdc/Kconfig new file mode 100644 index 00000000000..80211df8c57 --- /dev/null +++ b/drivers/staging/iio/cdc/Kconfig @@ -0,0 +1,36 @@ +# +# CDC drivers +# +menu "Capacitance to digital converters" + +config AD7150 + tristate "Analog Devices ad7150/1/6 capacitive sensor driver" + depends on I2C + help + Say yes here to build support for Analog Devices capacitive sensors. + (ad7150, ad7151, ad7156) Provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad7150. + +config AD7152 + tristate "Analog Devices ad7152/3 capacitive sensor driver" + depends on I2C + help + Say yes here to build support for Analog Devices capacitive sensors. + (ad7152, ad7153) Provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad7152. + +config AD7746 + tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver" + depends on I2C + help + Say yes here to build support for Analog Devices capacitive sensors. + (AD7745, AD7746, AD7747) Provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad7746. + +endmenu diff --git a/drivers/staging/iio/cdc/Makefile b/drivers/staging/iio/cdc/Makefile new file mode 100644 index 00000000000..a5fbabf5c8b --- /dev/null +++ b/drivers/staging/iio/cdc/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for industrial I/O DAC drivers +# + +obj-$(CONFIG_AD7150) += ad7150.o +obj-$(CONFIG_AD7152) += ad7152.o +obj-$(CONFIG_AD7746) += ad7746.o diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c similarity index 100% rename from drivers/staging/iio/adc/ad7150.c rename to drivers/staging/iio/cdc/ad7150.c diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c similarity index 100% rename from drivers/staging/iio/adc/ad7152.c rename to drivers/staging/iio/cdc/ad7152.c diff --git a/drivers/staging/iio/adc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c similarity index 100% rename from drivers/staging/iio/adc/ad7746.c rename to drivers/staging/iio/cdc/ad7746.c diff --git a/drivers/staging/iio/adc/ad7746.h b/drivers/staging/iio/cdc/ad7746.h similarity index 100% rename from drivers/staging/iio/adc/ad7746.h rename to drivers/staging/iio/cdc/ad7746.h From 1b992320775691ba0124bd37c5fffe16172743cd Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 19 Oct 2011 14:41:08 +0200 Subject: [PATCH 1475/1519] iio: cdc: Fix pushed event code - Typo, should be IIO_CAPACITANCE. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/cdc/ad7150.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index e185f0e052a..a761ca94a17 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -473,7 +473,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -481,7 +481,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), @@ -490,7 +490,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), @@ -498,7 +498,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2)) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), From 021c0a381c5c1ae457bb9316669736d2ec66f972 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Oct 2011 17:47:49 +0200 Subject: [PATCH 1476/1519] staging:iio:dac:ad5791: Use correct DAC bit-size Commit c5b99396 ("staging:iio:dac:ad5791 chan spec conversion.") introduced a small bug, using storagebits instead of realbits throughout the driver, which causes the driver to work incorrectly. This patch fixes it. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5791.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index fbf446d5671..9a76c4311f9 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -234,11 +234,11 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, return ret; *val &= AD5791_DAC_MASK; *val >>= chan->scan_type.shift; - *val -= (1 << (chan->scan_type.storagebits - 1)); + *val -= (1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): *val = 0; - *val2 = (st->vref_mv * 1000) >> chan->scan_type.storagebits; + *val2 = (st->vref_mv * 1000) >> chan->scan_type.realbits; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; @@ -257,8 +257,8 @@ static int ad5791_write_raw(struct iio_dev *indio_dev, switch (mask) { case 0: - val += (1 << (chan->scan_type.storagebits - 1)); - val &= AD5791_RES_MASK(chan->scan_type.storagebits); + val += (1 << (chan->scan_type.realbits - 1)); + val &= AD5791_RES_MASK(chan->scan_type.realbits); val <<= chan->scan_type.shift; return ad5791_spi_write(st->spi, chan->address, val); From 9dc9961dca37379fd128508aac37e9f4928ee18f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Oct 2011 17:47:50 +0200 Subject: [PATCH 1477/1519] staging:iio:dac:ad5791: Allow asymmetrical reference voltages The ad5791 currently assumes that the negative and positive supply have the same absolute value, which is not necessarily true. This patch introduces a offset attribute which will contain the negative supply voltage scaled according to the iio spec. The raw attribute now accepts values in the range of 0 to max instead of -max/2 to max/2. While we are at it also fix the vref span calculation. Since both positive and negative reference voltages are specificed as absolute values we need to add them and not subtract them to get the reference voltage span. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5791.c | 24 ++++++++++++++++-------- drivers/staging/iio/dac/ad5791.h | 2 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 9a76c4311f9..c465fcfdac4 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -77,7 +77,8 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) .indexed = 1, \ .address = AD5791_ADDR_DAC0, \ .channel = 0, \ - .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED) | \ + (1 << IIO_CHAN_INFO_OFFSET_SHARED), \ .scan_type = IIO_ST('u', bits, 24, shift) \ } @@ -225,6 +226,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, long m) { struct ad5791_state *st = iio_priv(indio_dev); + u64 val64; int ret; switch (m) { @@ -234,12 +236,16 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, return ret; *val &= AD5791_DAC_MASK; *val >>= chan->scan_type.shift; - *val -= (1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): *val = 0; *val2 = (st->vref_mv * 1000) >> chan->scan_type.realbits; return IIO_VAL_INT_PLUS_MICRO; + case (1 << IIO_CHAN_INFO_OFFSET_SHARED): + val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits); + do_div(val64, st->vref_mv); + *val = -val64; + return IIO_VAL_INT; default: return -EINVAL; } @@ -257,7 +263,6 @@ static int ad5791_write_raw(struct iio_dev *indio_dev, switch (mask) { case 0: - val += (1 << (chan->scan_type.realbits - 1)); val &= AD5791_RES_MASK(chan->scan_type.realbits); val <<= chan->scan_type.shift; @@ -309,12 +314,15 @@ static int __devinit ad5791_probe(struct spi_device *spi) st->pwr_down = true; st->spi = spi; - if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) - st->vref_mv = (pos_voltage_uv - neg_voltage_uv) / 1000; - else if (pdata) - st->vref_mv = pdata->vref_pos_mv - pdata->vref_neg_mv; - else + if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { + st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; + st->vref_neg_mv = neg_voltage_uv / 1000; + } else if (pdata) { + st->vref_mv = pdata->vref_pos_mv + pdata->vref_neg_mv; + st->vref_neg_mv = pdata->vref_neg_mv; + } else { dev_warn(&spi->dev, "reference voltage unspecified\n"); + } ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); if (ret) diff --git a/drivers/staging/iio/dac/ad5791.h b/drivers/staging/iio/dac/ad5791.h index 2a50a112b96..fd7edbdb4ec 100644 --- a/drivers/staging/iio/dac/ad5791.h +++ b/drivers/staging/iio/dac/ad5791.h @@ -82,6 +82,7 @@ struct ad5791_chip_info { * @reg_vss: negative supply regulator * @chip_info: chip model specific constants * @vref_mv: actual reference voltage used + * @vref_neg_mv: voltage of the negative supply * @pwr_down_mode current power down mode */ @@ -91,6 +92,7 @@ struct ad5791_state { struct regulator *reg_vss; const struct ad5791_chip_info *chip_info; unsigned short vref_mv; + unsigned int vref_neg_mv; unsigned ctrl; unsigned pwr_down_mode; bool pwr_down; From f1a61a8888afb9c21bb7efdd25f2755b01f065d3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Oct 2011 17:47:51 +0200 Subject: [PATCH 1478/1519] staging:iio:dac:ad5791: Convert attributes to new naming spec Add the missing "voltage" chan_type to the powerdown attributes. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5791.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index c465fcfdac4..9ba45f1a237 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -158,24 +158,24 @@ static ssize_t ad5791_write_dac_powerdown(struct device *dev, return ret ? ret : len; } -static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO | +static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, ad5791_read_powerdown_mode, ad5791_write_powerdown_mode, 0); -static IIO_CONST_ATTR(out_powerdown_mode_available, +static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "6kohm_to_gnd three_state"); #define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \ - IIO_DEVICE_ATTR(out##_num##_powerdown, \ + IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \ S_IRUGO | S_IWUSR, _show, _store, _addr) static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5791_read_dac_powerdown, ad5791_write_dac_powerdown, 0); static struct attribute *ad5791_attributes[] = { - &iio_dev_attr_out0_powerdown.dev_attr.attr, - &iio_dev_attr_out_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_powerdown_mode_available.dev_attr.attr, + &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, + &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, + &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, NULL, }; From 75bb23a2150e385230d1db52065641ca7cef63d3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Oct 2011 17:47:52 +0200 Subject: [PATCH 1479/1519] staging:iio:dac:ad5791: Fix scale unit Scale is currently reported in volts instead of millivolts. This patch fixes it. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5791.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 9ba45f1a237..6fbca8d9615 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -239,7 +239,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): *val = 0; - *val2 = (st->vref_mv * 1000) >> chan->scan_type.realbits; + *val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits; return IIO_VAL_INT_PLUS_MICRO; case (1 << IIO_CHAN_INFO_OFFSET_SHARED): val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits); From cd8eca6f77108617a8c47a800533f1b78a357a79 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Oct 2011 17:51:28 +0200 Subject: [PATCH 1480/1519] staging:iio:dac:ad5686: Check for negative values Currently it is possible to write negative values to the ad5686's raw attribute. This will cause undefined behaviour, so reject negative values. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/ad5686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index 1d50dd17621..48389e1c19f 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -327,7 +327,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, switch (mask) { case 0: - if (val > (1 << chan->scan_type.realbits)) + if (val > (1 << chan->scan_type.realbits) || val < 0) return -EINVAL; mutex_lock(&indio_dev->mlock); From d2796743cba2d30f018e10288effce53fbd53fbe Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:30 +0100 Subject: [PATCH 1481/1519] staging: et131x: Put all .c files into one big file Created one big .c file for the driver, moving the contents of all driver .c files into it. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/Makefile | 11 - drivers/staging/et131x/et1310_eeprom.c | 408 -- drivers/staging/et131x/et1310_mac.c | 654 --- drivers/staging/et131x/et1310_phy.c | 375 -- drivers/staging/et131x/et1310_pm.c | 204 - drivers/staging/et131x/et1310_rx.c | 1160 ------ drivers/staging/et131x/et1310_tx.c | 793 ---- drivers/staging/et131x/et131x.c | 5042 +++++++++++++++++++++++ drivers/staging/et131x/et131x.h | 62 +- drivers/staging/et131x/et131x_ethtool.c | 201 - drivers/staging/et131x/et131x_initpci.c | 950 ----- drivers/staging/et131x/et131x_isr.c | 442 -- drivers/staging/et131x/et131x_netdev.c | 662 --- 13 files changed, 5102 insertions(+), 5862 deletions(-) delete mode 100644 drivers/staging/et131x/et1310_eeprom.c delete mode 100644 drivers/staging/et131x/et1310_mac.c delete mode 100644 drivers/staging/et131x/et1310_phy.c delete mode 100644 drivers/staging/et131x/et1310_pm.c delete mode 100644 drivers/staging/et131x/et1310_rx.c delete mode 100644 drivers/staging/et131x/et1310_tx.c create mode 100644 drivers/staging/et131x/et131x.c delete mode 100644 drivers/staging/et131x/et131x_ethtool.c delete mode 100644 drivers/staging/et131x/et131x_initpci.c delete mode 100644 drivers/staging/et131x/et131x_isr.c delete mode 100644 drivers/staging/et131x/et131x_netdev.c diff --git a/drivers/staging/et131x/Makefile b/drivers/staging/et131x/Makefile index 5ea0272fc7a..027ff9453fe 100644 --- a/drivers/staging/et131x/Makefile +++ b/drivers/staging/et131x/Makefile @@ -3,14 +3,3 @@ # obj-$(CONFIG_ET131X) += et131x.o - -et131x-y := et1310_eeprom.o \ - et1310_mac.o \ - et1310_phy.o \ - et1310_pm.o \ - et1310_rx.o \ - et1310_tx.o \ - et131x_initpci.o \ - et131x_ethtool.o \ - et131x_isr.o \ - et131x_netdev.o diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c deleted file mode 100644 index 20b96605e4c..00000000000 --- a/drivers/staging/et131x/et1310_eeprom.c +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_eeprom.c - Code used to access the device's EEPROM - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et131x_adapter.h" -#include "et131x.h" - -/* - * EEPROM Defines - */ - -/* LBCIF Register Groups (addressed via 32-bit offsets) */ -#define LBCIF_DWORD0_GROUP 0xAC -#define LBCIF_DWORD1_GROUP 0xB0 - -/* LBCIF Registers (addressed via 8-bit offsets) */ -#define LBCIF_ADDRESS_REGISTER 0xAC -#define LBCIF_DATA_REGISTER 0xB0 -#define LBCIF_CONTROL_REGISTER 0xB1 -#define LBCIF_STATUS_REGISTER 0xB2 - -/* LBCIF Control Register Bits */ -#define LBCIF_CONTROL_SEQUENTIAL_READ 0x01 -#define LBCIF_CONTROL_PAGE_WRITE 0x02 -#define LBCIF_CONTROL_EEPROM_RELOAD 0x08 -#define LBCIF_CONTROL_TWO_BYTE_ADDR 0x20 -#define LBCIF_CONTROL_I2C_WRITE 0x40 -#define LBCIF_CONTROL_LBCIF_ENABLE 0x80 - -/* LBCIF Status Register Bits */ -#define LBCIF_STATUS_PHY_QUEUE_AVAIL 0x01 -#define LBCIF_STATUS_I2C_IDLE 0x02 -#define LBCIF_STATUS_ACK_ERROR 0x04 -#define LBCIF_STATUS_GENERAL_ERROR 0x08 -#define LBCIF_STATUS_CHECKSUM_ERROR 0x40 -#define LBCIF_STATUS_EEPROM_PRESENT 0x80 - -/* Miscellaneous Constraints */ -#define MAX_NUM_REGISTER_POLLS 1000 -#define MAX_NUM_WRITE_RETRIES 2 - -static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) -{ - u32 reg; - int i; - - /* - * 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and - * bits 7,1:0 both equal to 1, at least once after reset. - * Subsequent operations need only to check that bits 1:0 are equal - * to 1 prior to starting a single byte read/write - */ - - for (i = 0; i < MAX_NUM_REGISTER_POLLS; i++) { - /* Read registers grouped in DWORD1 */ - if (pci_read_config_dword(pdev, LBCIF_DWORD1_GROUP, ®)) - return -EIO; - - /* I2C idle and Phy Queue Avail both true */ - if ((reg & 0x3000) == 0x3000) { - if (status) - *status = reg; - return reg & 0xFF; - } - } - return -ETIMEDOUT; -} - - -/** - * eeprom_write - Write a byte to the ET1310's EEPROM - * @adapter: pointer to our private adapter structure - * @addr: the address to write - * @data: the value to write - * - * Returns 1 for a successful write. - */ -static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) -{ - struct pci_dev *pdev = adapter->pdev; - int index = 0; - int retries; - int err = 0; - int i2c_wack = 0; - int writeok = 0; - u32 status; - u32 val = 0; - - /* - * For an EEPROM, an I2C single byte write is defined as a START - * condition followed by the device address, EEPROM address, one byte - * of data and a STOP condition. The STOP condition will trigger the - * EEPROM's internally timed write cycle to the nonvolatile memory. - * All inputs are disabled during this write cycle and the EEPROM will - * not respond to any access until the internal write is complete. - */ - - err = eeprom_wait_ready(pdev, NULL); - if (err) - return err; - - /* - * 2. Write to the LBCIF Control Register: bit 7=1, bit 6=1, bit 3=0, - * and bits 1:0 both =0. Bit 5 should be set according to the - * type of EEPROM being accessed (1=two byte addressing, 0=one - * byte addressing). - */ - if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, - LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE)) - return -EIO; - - i2c_wack = 1; - - /* Prepare EEPROM address for Step 3 */ - - for (retries = 0; retries < MAX_NUM_WRITE_RETRIES; retries++) { - /* Write the address to the LBCIF Address Register */ - if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) - break; - /* - * Write the data to the LBCIF Data Register (the I2C write - * will begin). - */ - if (pci_write_config_byte(pdev, LBCIF_DATA_REGISTER, data)) - break; - /* - * Monitor bit 1:0 of the LBCIF Status Register. When bits - * 1:0 are both equal to 1, the I2C write has completed and the - * internal write cycle of the EEPROM is about to start. - * (bits 1:0 = 01 is a legal state while waiting from both - * equal to 1, but bits 1:0 = 10 is invalid and implies that - * something is broken). - */ - err = eeprom_wait_ready(pdev, &status); - if (err < 0) - return 0; - - /* - * Check bit 3 of the LBCIF Status Register. If equal to 1, - * an error has occurred.Don't break here if we are revision - * 1, this is so we do a blind write for load bug. - */ - if ((status & LBCIF_STATUS_GENERAL_ERROR) - && adapter->pdev->revision == 0) - break; - - /* - * Check bit 2 of the LBCIF Status Register. If equal to 1 an - * ACK error has occurred on the address phase of the write. - * This could be due to an actual hardware failure or the - * EEPROM may still be in its internal write cycle from a - * previous write. This write operation was ignored and must be - *repeated later. - */ - if (status & LBCIF_STATUS_ACK_ERROR) { - /* - * This could be due to an actual hardware failure - * or the EEPROM may still be in its internal write - * cycle from a previous write. This write operation - * was ignored and must be repeated later. - */ - udelay(10); - continue; - } - - writeok = 1; - break; - } - - /* - * Set bit 6 of the LBCIF Control Register = 0. - */ - udelay(10); - - while (i2c_wack) { - if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, - LBCIF_CONTROL_LBCIF_ENABLE)) - writeok = 0; - - /* Do read until internal ACK_ERROR goes away meaning write - * completed - */ - do { - pci_write_config_dword(pdev, - LBCIF_ADDRESS_REGISTER, - addr); - do { - pci_read_config_dword(pdev, - LBCIF_DATA_REGISTER, &val); - } while ((val & 0x00010000) == 0); - } while (val & 0x00040000); - - if ((val & 0xFF00) != 0xC000 || index == 10000) - break; - index++; - } - return writeok ? 0 : -EIO; -} - -/** - * eeprom_read - Read a byte from the ET1310's EEPROM - * @adapter: pointer to our private adapter structure - * @addr: the address from which to read - * @pdata: a pointer to a byte in which to store the value of the read - * @eeprom_id: the ID of the EEPROM - * @addrmode: how the EEPROM is to be accessed - * - * Returns 1 for a successful read - */ -static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata) -{ - struct pci_dev *pdev = adapter->pdev; - int err; - u32 status; - - /* - * A single byte read is similar to the single byte write, with the - * exception of the data flow: - */ - - err = eeprom_wait_ready(pdev, NULL); - if (err) - return err; - /* - * Write to the LBCIF Control Register: bit 7=1, bit 6=0, bit 3=0, - * and bits 1:0 both =0. Bit 5 should be set according to the type - * of EEPROM being accessed (1=two byte addressing, 0=one byte - * addressing). - */ - if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, - LBCIF_CONTROL_LBCIF_ENABLE)) - return -EIO; - /* - * Write the address to the LBCIF Address Register (I2C read will - * begin). - */ - if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) - return -EIO; - /* - * Monitor bit 0 of the LBCIF Status Register. When = 1, I2C read - * is complete. (if bit 1 =1 and bit 0 stays = 0, a hardware failure - * has occurred). - */ - err = eeprom_wait_ready(pdev, &status); - if (err < 0) - return err; - /* - * Regardless of error status, read data byte from LBCIF Data - * Register. - */ - *pdata = err; - /* - * Check bit 2 of the LBCIF Status Register. If = 1, - * then an error has occurred. - */ - return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0; -} - -int et131x_init_eeprom(struct et131x_adapter *adapter) -{ - struct pci_dev *pdev = adapter->pdev; - u8 eestatus; - - /* We first need to check the EEPROM Status code located at offset - * 0xB2 of config space - */ - pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, - &eestatus); - - /* THIS IS A WORKAROUND: - * I need to call this function twice to get my card in a - * LG M1 Express Dual running. I tried also a msleep before this - * function, because I thougth there could be some time condidions - * but it didn't work. Call the whole function twice also work. - */ - if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) { - dev_err(&pdev->dev, - "Could not read PCI config space for EEPROM Status\n"); - return -EIO; - } - - /* Determine if the error(s) we care about are present. If they are - * present we need to fail. - */ - if (eestatus & 0x4C) { - int write_failed = 0; - if (pdev->revision == 0x01) { - int i; - static const u8 eedata[4] = { 0xFE, 0x13, 0x10, 0xFF }; - - /* Re-write the first 4 bytes if we have an eeprom - * present and the revision id is 1, this fixes the - * corruption seen with 1310 B Silicon - */ - for (i = 0; i < 3; i++) - if (eeprom_write(adapter, i, eedata[i]) < 0) - write_failed = 1; - } - if (pdev->revision != 0x01 || write_failed) { - dev_err(&pdev->dev, - "Fatal EEPROM Status Error - 0x%04x\n", eestatus); - - /* This error could mean that there was an error - * reading the eeprom or that the eeprom doesn't exist. - * We will treat each case the same and not try to - * gather additional information that normally would - * come from the eeprom, like MAC Address - */ - adapter->has_eeprom = 0; - return -EIO; - } - } - adapter->has_eeprom = 1; - - /* Read the EEPROM for information regarding LED behavior. Refer to - * ET1310_phy.c, et131x_xcvr_init(), for its use. - */ - eeprom_read(adapter, 0x70, &adapter->eeprom_data[0]); - eeprom_read(adapter, 0x71, &adapter->eeprom_data[1]); - - if (adapter->eeprom_data[0] != 0xcd) - /* Disable all optional features */ - adapter->eeprom_data[1] = 0x00; - - return 0; -} diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c deleted file mode 100644 index 65179a364b7..00000000000 --- a/drivers/staging/et131x/et1310_mac.c +++ /dev/null @@ -1,654 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_mac.c - All code and routines pertaining to the MAC - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et131x_adapter.h" -#include "et131x.h" - -#define COUNTER_WRAP_16_BIT 0x10000 -#define COUNTER_WRAP_12_BIT 0x1000 - -/** - * et1310_config_mac_regs1 - Initialize the first part of MAC regs - * @adapter: pointer to our adapter structure - */ -void et1310_config_mac_regs1(struct et131x_adapter *adapter) -{ - struct mac_regs __iomem *macregs = &adapter->regs->mac; - u32 station1; - u32 station2; - u32 ipg; - - /* First we need to reset everything. Write to MAC configuration - * register 1 to perform reset. - */ - writel(0xC00F0000, ¯egs->cfg1); - - /* Next lets configure the MAC Inter-packet gap register */ - ipg = 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */ - ipg |= 0x50 << 8; /* ifg enforce 0x50 */ - writel(ipg, ¯egs->ipg); - - /* Next lets configure the MAC Half Duplex register */ - /* BEB trunc 0xA, Ex Defer, Rexmit 0xF Coll 0x37 */ - writel(0x00A1F037, ¯egs->hfdp); - - /* Next lets configure the MAC Interface Control register */ - writel(0, ¯egs->if_ctrl); - - /* Let's move on to setting up the mii management configuration */ - writel(0x07, ¯egs->mii_mgmt_cfg); /* Clock reset 0x7 */ - - /* Next lets configure the MAC Station Address register. These - * values are read from the EEPROM during initialization and stored - * in the adapter structure. We write what is stored in the adapter - * structure to the MAC Station Address registers high and low. This - * station address is used for generating and checking pause control - * packets. - */ - station2 = (adapter->addr[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT) | - (adapter->addr[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT); - station1 = (adapter->addr[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT) | - (adapter->addr[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT) | - (adapter->addr[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT) | - adapter->addr[2]; - writel(station1, ¯egs->station_addr_1); - writel(station2, ¯egs->station_addr_2); - - /* Max ethernet packet in bytes that will passed by the mac without - * being truncated. Allow the MAC to pass 4 more than our max packet - * size. This is 4 for the Ethernet CRC. - * - * Packets larger than (registry_jumbo_packet) that do not contain a - * VLAN ID will be dropped by the Rx function. - */ - writel(adapter->registry_jumbo_packet + 4, ¯egs->max_fm_len); - - /* clear out MAC config reset */ - writel(0, ¯egs->cfg1); -} - -/** - * et1310_config_mac_regs2 - Initialize the second part of MAC regs - * @adapter: pointer to our adapter structure - */ -void et1310_config_mac_regs2(struct et131x_adapter *adapter) -{ - int32_t delay = 0; - struct mac_regs __iomem *mac = &adapter->regs->mac; - struct phy_device *phydev = adapter->phydev; - u32 cfg1; - u32 cfg2; - u32 ifctrl; - u32 ctl; - - ctl = readl(&adapter->regs->txmac.ctl); - cfg1 = readl(&mac->cfg1); - cfg2 = readl(&mac->cfg2); - ifctrl = readl(&mac->if_ctrl); - - /* Set up the if mode bits */ - cfg2 &= ~0x300; - if (phydev && phydev->speed == SPEED_1000) { - cfg2 |= 0x200; - /* Phy mode bit */ - ifctrl &= ~(1 << 24); - } else { - cfg2 |= 0x100; - ifctrl |= (1 << 24); - } - - /* We need to enable Rx/Tx */ - cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; - /* Initialize loop back to off */ - cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); - if (adapter->flowcontrol == FLOW_RXONLY || - adapter->flowcontrol == FLOW_BOTH) - cfg1 |= CFG1_RX_FLOW; - writel(cfg1, &mac->cfg1); - - /* Now we need to initialize the MAC Configuration 2 register */ - /* preamble 7, check length, huge frame off, pad crc, crc enable - full duplex off */ - cfg2 |= 0x7016; - cfg2 &= ~0x0021; - - /* Turn on duplex if needed */ - if (phydev && phydev->duplex == DUPLEX_FULL) - cfg2 |= 0x01; - - ifctrl &= ~(1 << 26); - if (phydev && phydev->duplex == DUPLEX_HALF) - ifctrl |= (1<<26); /* Enable ghd */ - - writel(ifctrl, &mac->if_ctrl); - writel(cfg2, &mac->cfg2); - - do { - udelay(10); - delay++; - cfg1 = readl(&mac->cfg1); - } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100); - - if (delay == 100) { - dev_warn(&adapter->pdev->dev, - "Syncd bits did not respond correctly cfg1 word 0x%08x\n", - cfg1); - } - - /* Enable txmac */ - ctl |= 0x09; /* TX mac enable, FC disable */ - writel(ctl, &adapter->regs->txmac.ctl); - - /* Ready to start the RXDMA/TXDMA engine */ - if (adapter->flags & fMP_ADAPTER_LOWER_POWER) { - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - } -} - -void et1310_config_rxmac_regs(struct et131x_adapter *adapter) -{ - struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; - struct phy_device *phydev = adapter->phydev; - u32 sa_lo; - u32 sa_hi = 0; - u32 pf_ctrl = 0; - - /* Disable the MAC while it is being configured (also disable WOL) */ - writel(0x8, &rxmac->ctrl); - - /* Initialize WOL to disabled. */ - writel(0, &rxmac->crc0); - writel(0, &rxmac->crc12); - writel(0, &rxmac->crc34); - - /* We need to set the WOL mask0 - mask4 next. We initialize it to - * its default Values of 0x00000000 because there are not WOL masks - * as of this time. - */ - writel(0, &rxmac->mask0_word0); - writel(0, &rxmac->mask0_word1); - writel(0, &rxmac->mask0_word2); - writel(0, &rxmac->mask0_word3); - - writel(0, &rxmac->mask1_word0); - writel(0, &rxmac->mask1_word1); - writel(0, &rxmac->mask1_word2); - writel(0, &rxmac->mask1_word3); - - writel(0, &rxmac->mask2_word0); - writel(0, &rxmac->mask2_word1); - writel(0, &rxmac->mask2_word2); - writel(0, &rxmac->mask2_word3); - - writel(0, &rxmac->mask3_word0); - writel(0, &rxmac->mask3_word1); - writel(0, &rxmac->mask3_word2); - writel(0, &rxmac->mask3_word3); - - writel(0, &rxmac->mask4_word0); - writel(0, &rxmac->mask4_word1); - writel(0, &rxmac->mask4_word2); - writel(0, &rxmac->mask4_word3); - - /* Lets setup the WOL Source Address */ - sa_lo = (adapter->addr[2] << ET_WOL_LO_SA3_SHIFT) | - (adapter->addr[3] << ET_WOL_LO_SA4_SHIFT) | - (adapter->addr[4] << ET_WOL_LO_SA5_SHIFT) | - adapter->addr[5]; - writel(sa_lo, &rxmac->sa_lo); - - sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) | - adapter->addr[1]; - writel(sa_hi, &rxmac->sa_hi); - - /* Disable all Packet Filtering */ - writel(0, &rxmac->pf_ctrl); - - /* Let's initialize the Unicast Packet filtering address */ - if (adapter->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { - et1310_setup_device_for_unicast(adapter); - pf_ctrl |= 4; /* Unicast filter */ - } else { - writel(0, &rxmac->uni_pf_addr1); - writel(0, &rxmac->uni_pf_addr2); - writel(0, &rxmac->uni_pf_addr3); - } - - /* Let's initialize the Multicast hash */ - if (!(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { - pf_ctrl |= 2; /* Multicast filter */ - et1310_setup_device_for_multicast(adapter); - } - - /* Runt packet filtering. Didn't work in version A silicon. */ - pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16; - pf_ctrl |= 8; /* Fragment filter */ - - if (adapter->registry_jumbo_packet > 8192) - /* In order to transmit jumbo packets greater than 8k, the - * FIFO between RxMAC and RxDMA needs to be reduced in size - * to (16k - Jumbo packet size). In order to implement this, - * we must use "cut through" mode in the RxMAC, which chops - * packets down into segments which are (max_size * 16). In - * this case we selected 256 bytes, since this is the size of - * the PCI-Express TLP's that the 1310 uses. - * - * seg_en on, fc_en off, size 0x10 - */ - writel(0x41, &rxmac->mcif_ctrl_max_seg); - else - writel(0, &rxmac->mcif_ctrl_max_seg); - - /* Initialize the MCIF water marks */ - writel(0, &rxmac->mcif_water_mark); - - /* Initialize the MIF control */ - writel(0, &rxmac->mif_ctrl); - - /* Initialize the Space Available Register */ - writel(0, &rxmac->space_avail); - - /* Initialize the the mif_ctrl register - * bit 3: Receive code error. One or more nibbles were signaled as - * errors during the reception of the packet. Clear this - * bit in Gigabit, set it in 100Mbit. This was derived - * experimentally at UNH. - * bit 4: Receive CRC error. The packet's CRC did not match the - * internally generated CRC. - * bit 5: Receive length check error. Indicates that frame length - * field value in the packet does not match the actual data - * byte length and is not a type field. - * bit 16: Receive frame truncated. - * bit 17: Drop packet enable - */ - if (phydev && phydev->speed == SPEED_100) - writel(0x30038, &rxmac->mif_ctrl); - else - writel(0x30030, &rxmac->mif_ctrl); - - /* Finally we initialize RxMac to be enabled & WOL disabled. Packet - * filter is always enabled since it is where the runt packets are - * supposed to be dropped. For version A silicon, runt packet - * dropping doesn't work, so it is disabled in the pf_ctrl register, - * but we still leave the packet filter on. - */ - writel(pf_ctrl, &rxmac->pf_ctrl); - writel(0x9, &rxmac->ctrl); -} - -void et1310_config_txmac_regs(struct et131x_adapter *adapter) -{ - struct txmac_regs __iomem *txmac = &adapter->regs->txmac; - - /* We need to update the Control Frame Parameters - * cfpt - control frame pause timer set to 64 (0x40) - * cfep - control frame extended pause timer set to 0x0 - */ - if (adapter->flowcontrol == FLOW_NONE) - writel(0, &txmac->cf_param); - else - writel(0x40, &txmac->cf_param); -} - -void et1310_config_macstat_regs(struct et131x_adapter *adapter) -{ - struct macstat_regs __iomem *macstat = - &adapter->regs->macstat; - - /* Next we need to initialize all the macstat registers to zero on - * the device. - */ - writel(0, &macstat->txrx_0_64_byte_frames); - writel(0, &macstat->txrx_65_127_byte_frames); - writel(0, &macstat->txrx_128_255_byte_frames); - writel(0, &macstat->txrx_256_511_byte_frames); - writel(0, &macstat->txrx_512_1023_byte_frames); - writel(0, &macstat->txrx_1024_1518_byte_frames); - writel(0, &macstat->txrx_1519_1522_gvln_frames); - - writel(0, &macstat->rx_bytes); - writel(0, &macstat->rx_packets); - writel(0, &macstat->rx_fcs_errs); - writel(0, &macstat->rx_multicast_packets); - writel(0, &macstat->rx_broadcast_packets); - writel(0, &macstat->rx_control_frames); - writel(0, &macstat->rx_pause_frames); - writel(0, &macstat->rx_unknown_opcodes); - writel(0, &macstat->rx_align_errs); - writel(0, &macstat->rx_frame_len_errs); - writel(0, &macstat->rx_code_errs); - writel(0, &macstat->rx_carrier_sense_errs); - writel(0, &macstat->rx_undersize_packets); - writel(0, &macstat->rx_oversize_packets); - writel(0, &macstat->rx_fragment_packets); - writel(0, &macstat->rx_jabbers); - writel(0, &macstat->rx_drops); - - writel(0, &macstat->tx_bytes); - writel(0, &macstat->tx_packets); - writel(0, &macstat->tx_multicast_packets); - writel(0, &macstat->tx_broadcast_packets); - writel(0, &macstat->tx_pause_frames); - writel(0, &macstat->tx_deferred); - writel(0, &macstat->tx_excessive_deferred); - writel(0, &macstat->tx_single_collisions); - writel(0, &macstat->tx_multiple_collisions); - writel(0, &macstat->tx_late_collisions); - writel(0, &macstat->tx_excessive_collisions); - writel(0, &macstat->tx_total_collisions); - writel(0, &macstat->tx_pause_honored_frames); - writel(0, &macstat->tx_drops); - writel(0, &macstat->tx_jabbers); - writel(0, &macstat->tx_fcs_errs); - writel(0, &macstat->tx_control_frames); - writel(0, &macstat->tx_oversize_frames); - writel(0, &macstat->tx_undersize_frames); - writel(0, &macstat->tx_fragments); - writel(0, &macstat->carry_reg1); - writel(0, &macstat->carry_reg2); - - /* Unmask any counters that we want to track the overflow of. - * Initially this will be all counters. It may become clear later - * that we do not need to track all counters. - */ - writel(0xFFFFBE32, &macstat->carry_reg1_mask); - writel(0xFFFE7E8B, &macstat->carry_reg2_mask); -} - -void et1310_config_flow_control(struct et131x_adapter *adapter) -{ - struct phy_device *phydev = adapter->phydev; - - if (phydev->duplex == DUPLEX_HALF) { - adapter->flowcontrol = FLOW_NONE; - } else { - char remote_pause, remote_async_pause; - - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_READ, 5, 10, &remote_pause); - et1310_phy_access_mii_bit(adapter, - TRUEPHY_BIT_READ, 5, 11, - &remote_async_pause); - - if ((remote_pause == TRUEPHY_BIT_SET) && - (remote_async_pause == TRUEPHY_BIT_SET)) { - adapter->flowcontrol = adapter->wanted_flow; - } else if ((remote_pause == TRUEPHY_BIT_SET) && - (remote_async_pause == TRUEPHY_BIT_CLEAR)) { - if (adapter->wanted_flow == FLOW_BOTH) - adapter->flowcontrol = FLOW_BOTH; - else - adapter->flowcontrol = FLOW_NONE; - } else if ((remote_pause == TRUEPHY_BIT_CLEAR) && - (remote_async_pause == TRUEPHY_BIT_CLEAR)) { - adapter->flowcontrol = FLOW_NONE; - } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT && - remote_async_pause == TRUEPHY_SET_BIT) */ - if (adapter->wanted_flow == FLOW_BOTH) - adapter->flowcontrol = FLOW_RXONLY; - else - adapter->flowcontrol = FLOW_NONE; - } - } -} - -/** - * et1310_update_macstat_host_counters - Update the local copy of the statistics - * @adapter: pointer to the adapter structure - */ -void et1310_update_macstat_host_counters(struct et131x_adapter *adapter) -{ - struct ce_stats *stats = &adapter->stats; - struct macstat_regs __iomem *macstat = - &adapter->regs->macstat; - - stats->tx_collisions += readl(&macstat->tx_total_collisions); - stats->tx_first_collisions += readl(&macstat->tx_single_collisions); - stats->tx_deferred += readl(&macstat->tx_deferred); - stats->tx_excessive_collisions += - readl(&macstat->tx_multiple_collisions); - stats->tx_late_collisions += readl(&macstat->tx_late_collisions); - stats->tx_underflows += readl(&macstat->tx_undersize_frames); - stats->tx_max_pkt_errs += readl(&macstat->tx_oversize_frames); - - stats->rx_align_errs += readl(&macstat->rx_align_errs); - stats->rx_crc_errs += readl(&macstat->rx_code_errs); - stats->rcvd_pkts_dropped += readl(&macstat->rx_drops); - stats->rx_overflows += readl(&macstat->rx_oversize_packets); - stats->rx_code_violations += readl(&macstat->rx_fcs_errs); - stats->rx_length_errs += readl(&macstat->rx_frame_len_errs); - stats->rx_other_errs += readl(&macstat->rx_fragment_packets); -} - -/** - * et1310_handle_macstat_interrupt - * @adapter: pointer to the adapter structure - * - * One of the MACSTAT counters has wrapped. Update the local copy of - * the statistics held in the adapter structure, checking the "wrap" - * bit for each counter. - */ -void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter) -{ - u32 carry_reg1; - u32 carry_reg2; - - /* Read the interrupt bits from the register(s). These are Clear On - * Write. - */ - carry_reg1 = readl(&adapter->regs->macstat.carry_reg1); - carry_reg2 = readl(&adapter->regs->macstat.carry_reg2); - - writel(carry_reg1, &adapter->regs->macstat.carry_reg1); - writel(carry_reg2, &adapter->regs->macstat.carry_reg2); - - /* We need to do update the host copy of all the MAC_STAT counters. - * For each counter, check it's overflow bit. If the overflow bit is - * set, then increment the host version of the count by one complete - * revolution of the counter. This routine is called when the counter - * block indicates that one of the counters has wrapped. - */ - if (carry_reg1 & (1 << 14)) - adapter->stats.rx_code_violations += COUNTER_WRAP_16_BIT; - if (carry_reg1 & (1 << 8)) - adapter->stats.rx_align_errs += COUNTER_WRAP_12_BIT; - if (carry_reg1 & (1 << 7)) - adapter->stats.rx_length_errs += COUNTER_WRAP_16_BIT; - if (carry_reg1 & (1 << 2)) - adapter->stats.rx_other_errs += COUNTER_WRAP_16_BIT; - if (carry_reg1 & (1 << 6)) - adapter->stats.rx_crc_errs += COUNTER_WRAP_16_BIT; - if (carry_reg1 & (1 << 3)) - adapter->stats.rx_overflows += COUNTER_WRAP_16_BIT; - if (carry_reg1 & (1 << 0)) - adapter->stats.rcvd_pkts_dropped += COUNTER_WRAP_16_BIT; - if (carry_reg2 & (1 << 16)) - adapter->stats.tx_max_pkt_errs += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 15)) - adapter->stats.tx_underflows += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 6)) - adapter->stats.tx_first_collisions += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 8)) - adapter->stats.tx_deferred += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 5)) - adapter->stats.tx_excessive_collisions += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 4)) - adapter->stats.tx_late_collisions += COUNTER_WRAP_12_BIT; - if (carry_reg2 & (1 << 2)) - adapter->stats.tx_collisions += COUNTER_WRAP_12_BIT; -} - -void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) -{ - struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; - uint32_t nIndex; - uint32_t result; - uint32_t hash1 = 0; - uint32_t hash2 = 0; - uint32_t hash3 = 0; - uint32_t hash4 = 0; - u32 pm_csr; - - /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision - * the multi-cast LIST. If it is NOT specified, (and "ALL" is not - * specified) then we should pass NO multi-cast addresses to the - * driver. - */ - if (adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { - /* Loop through our multicast array and set up the device */ - for (nIndex = 0; nIndex < adapter->multicast_addr_count; - nIndex++) { - result = ether_crc(6, adapter->multicast_list[nIndex]); - - result = (result & 0x3F800000) >> 23; - - if (result < 32) { - hash1 |= (1 << result); - } else if ((31 < result) && (result < 64)) { - result -= 32; - hash2 |= (1 << result); - } else if ((63 < result) && (result < 96)) { - result -= 64; - hash3 |= (1 << result); - } else { - result -= 96; - hash4 |= (1 << result); - } - } - } - - /* Write out the new hash to the device */ - pm_csr = readl(&adapter->regs->global.pm_csr); - if (!et1310_in_phy_coma(adapter)) { - writel(hash1, &rxmac->multi_hash1); - writel(hash2, &rxmac->multi_hash2); - writel(hash3, &rxmac->multi_hash3); - writel(hash4, &rxmac->multi_hash4); - } -} - -void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) -{ - struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; - u32 uni_pf1; - u32 uni_pf2; - u32 uni_pf3; - u32 pm_csr; - - /* Set up unicast packet filter reg 3 to be the first two octets of - * the MAC address for both address - * - * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the - * MAC address for second address - * - * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the - * MAC address for first address - */ - uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | - (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | - (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | - adapter->addr[1]; - - uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | - adapter->addr[5]; - - uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | - adapter->addr[5]; - - pm_csr = readl(&adapter->regs->global.pm_csr); - if (!et1310_in_phy_coma(adapter)) { - writel(uni_pf1, &rxmac->uni_pf_addr1); - writel(uni_pf2, &rxmac->uni_pf_addr2); - writel(uni_pf3, &rxmac->uni_pf_addr3); - } -} diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c deleted file mode 100644 index b809dd4e527..00000000000 --- a/drivers/staging/et131x/et1310_phy.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs - * - * Copyright * 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_phy.c - Routines for configuring and accessing the PHY - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright * 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" - -#include "et131x_adapter.h" - -#include "et1310_address_map.h" -#include "et1310_tx.h" -#include "et1310_rx.h" - -#include "et131x.h" - -int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg) -{ - struct net_device *netdev = bus->priv; - struct et131x_adapter *adapter = netdev_priv(netdev); - u16 value; - int ret; - - ret = et131x_phy_mii_read(adapter, phy_addr, reg, &value); - - if (ret < 0) - return ret; - else - return value; -} - -int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value) -{ - struct net_device *netdev = bus->priv; - struct et131x_adapter *adapter = netdev_priv(netdev); - - return et131x_mii_write(adapter, reg, value); -} - -int et131x_mdio_reset(struct mii_bus *bus) -{ - struct net_device *netdev = bus->priv; - struct et131x_adapter *adapter = netdev_priv(netdev); - - et131x_mii_write(adapter, MII_BMCR, BMCR_RESET); - - return 0; -} - -int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) -{ - struct phy_device *phydev = adapter->phydev; - - if (!phydev) - return -EIO; - - return et131x_phy_mii_read(adapter, phydev->addr, reg, value); -} - -/** - * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC - * @adapter: pointer to our private adapter structure - * @addr: the address of the transceiver - * @reg: the register to read - * @value: pointer to a 16-bit value in which the value will be stored - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, - u8 reg, u16 *value) -{ - struct mac_regs __iomem *mac = &adapter->regs->mac; - int status = 0; - u32 delay = 0; - u32 mii_addr; - u32 mii_cmd; - u32 mii_indicator; - - /* Save a local copy of the registers we are dealing with so we can - * set them back - */ - mii_addr = readl(&mac->mii_mgmt_addr); - mii_cmd = readl(&mac->mii_mgmt_cmd); - - /* Stop the current operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* Set up the register we need to read from on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); - - writel(0x1, &mac->mii_mgmt_cmd); - - do { - udelay(50); - delay++; - mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_WAIT) && delay < 50); - - /* If we hit the max delay, we could not read the register */ - if (delay == 50) { - dev_warn(&adapter->pdev->dev, - "reg 0x%08x could not be read\n", reg); - dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", - mii_indicator); - - status = -EIO; - } - - /* If we hit here we were able to read the register and we need to - * return the value to the caller */ - *value = readl(&mac->mii_mgmt_stat) & 0xFFFF; - - /* Stop the read operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* set the registers we touched back to the state at which we entered - * this function - */ - writel(mii_addr, &mac->mii_mgmt_addr); - writel(mii_cmd, &mac->mii_mgmt_cmd); - - return status; -} - -/** - * et131x_mii_write - Write to a PHY register through the MII interface of the MAC - * @adapter: pointer to our private adapter structure - * @reg: the register to read - * @value: 16-bit value to write - * - * FIXME: one caller in netdev still - * - * Return 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) -{ - struct mac_regs __iomem *mac = &adapter->regs->mac; - struct phy_device *phydev = adapter->phydev; - int status = 0; - u8 addr; - u32 delay = 0; - u32 mii_addr; - u32 mii_cmd; - u32 mii_indicator; - - if (!phydev) - return -EIO; - - addr = phydev->addr; - - /* Save a local copy of the registers we are dealing with so we can - * set them back - */ - mii_addr = readl(&mac->mii_mgmt_addr); - mii_cmd = readl(&mac->mii_mgmt_cmd); - - /* Stop the current operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* Set up the register we need to write to on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); - - /* Add the value to write to the registers to the mac */ - writel(value, &mac->mii_mgmt_ctrl); - - do { - udelay(50); - delay++; - mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_BUSY) && delay < 100); - - /* If we hit the max delay, we could not write the register */ - if (delay == 100) { - u16 tmp; - - dev_warn(&adapter->pdev->dev, - "reg 0x%08x could not be written", reg); - dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", - mii_indicator); - dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", - readl(&mac->mii_mgmt_cmd)); - - et131x_mii_read(adapter, reg, &tmp); - - status = -EIO; - } - /* Stop the write operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* - * set the registers we touched back to the state at which we entered - * this function - */ - writel(mii_addr, &mac->mii_mgmt_addr); - writel(mii_cmd, &mac->mii_mgmt_cmd); - - return status; -} - -/** - * et1310_phy_power_down - PHY power control - * @adapter: device to control - * @down: true for off/false for back on - * - * one hundred, ten, one thousand megs - * How would you like to have your LAN accessed - * Can't you see that this code processed - * Phy power, phy power.. - */ -void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) -{ - u16 data; - - et131x_mii_read(adapter, MII_BMCR, &data); - data &= ~BMCR_PDOWN; - if (down) - data |= BMCR_PDOWN; - et131x_mii_write(adapter, MII_BMCR, data); -} - -/* Still used from _mac for BIT_READ */ -void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, - u16 regnum, u16 bitnum, u8 *value) -{ - u16 reg; - u16 mask = 0x0001 << bitnum; - - /* Read the requested register */ - et131x_mii_read(adapter, regnum, ®); - - switch (action) { - case TRUEPHY_BIT_READ: - *value = (reg & mask) >> bitnum; - break; - - case TRUEPHY_BIT_SET: - et131x_mii_write(adapter, regnum, reg | mask); - break; - - case TRUEPHY_BIT_CLEAR: - et131x_mii_write(adapter, regnum, reg & ~mask); - break; - - default: - break; - } -} - -/** - * et131x_xcvr_init - Init the phy if we are setting it into force mode - * @adapter: pointer to our private adapter structure - * - */ -void et131x_xcvr_init(struct et131x_adapter *adapter) -{ - u16 imr; - u16 isr; - u16 lcr2; - - et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &isr); - et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &imr); - - /* Set the link status interrupt only. Bad behavior when link status - * and auto neg are set, we run into a nested interrupt problem - */ - imr |= (ET_PHY_INT_MASK_AUTONEGSTAT & - ET_PHY_INT_MASK_LINKSTAT & - ET_PHY_INT_MASK_ENABLE); - - et131x_mii_write(adapter, PHY_INTERRUPT_MASK, imr); - - /* Set the LED behavior such that LED 1 indicates speed (off = - * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates - * link and activity (on for link, blink off for activity). - * - * NOTE: Some customizations have been added here for specific - * vendors; The LED behavior is now determined by vendor data in the - * EEPROM. However, the above description is the default. - */ - if ((adapter->eeprom_data[1] & 0x4) == 0) { - et131x_mii_read(adapter, PHY_LED_2, &lcr2); - - lcr2 &= (ET_LED2_LED_100TX & ET_LED2_LED_1000T); - lcr2 |= (LED_VAL_LINKON_ACTIVE << LED_LINK_SHIFT); - - if ((adapter->eeprom_data[1] & 0x8) == 0) - lcr2 |= (LED_VAL_1000BT_100BTX << LED_TXRX_SHIFT); - else - lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); - - et131x_mii_write(adapter, PHY_LED_2, lcr2); - } -} - diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c deleted file mode 100644 index 91d47dc2ccd..00000000000 --- a/drivers/staging/et131x/et1310_pm.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_pm.c - All power management related code (not completely implemented) - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et1310_rx.h" -#include "et131x_adapter.h" -#include "et131x.h" - -/** - * et1310_in_phy_coma - check if the device is in phy coma - * @adapter: pointer to our adapter structure - * - * Returns 0 if the device is not in phy coma, 1 if it is in phy coma - */ -int et1310_in_phy_coma(struct et131x_adapter *adapter) -{ - u32 pmcsr; - - pmcsr = readl(&adapter->regs->global.pm_csr); - - return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; -} - -/** - * et1310_enable_phy_coma - called when network cable is unplugged - * @adapter: pointer to our adapter structure - * - * driver receive an phy status change interrupt while in D0 and check that - * phy_status is down. - * - * -- gate off JAGCore; - * -- set gigE PHY in Coma mode - * -- wake on phy_interrupt; Perform software reset JAGCore, - * re-initialize jagcore and gigE PHY - * - * Add D0-ASPM-PhyLinkDown Support: - * -- while in D0, when there is a phy_interrupt indicating phy link - * down status, call the MPSetPhyComa routine to enter this active - * state power saving mode - * -- while in D0-ASPM-PhyLinkDown mode, when there is a phy_interrupt - * indicating linkup status, call the MPDisablePhyComa routine to - * restore JAGCore and gigE PHY - */ -void et1310_enable_phy_coma(struct et131x_adapter *adapter) -{ - unsigned long flags; - u32 pmcsr; - - pmcsr = readl(&adapter->regs->global.pm_csr); - - /* Save the GbE PHY speed and duplex modes. Need to restore this - * when cable is plugged back in - */ - /* - * TODO - when PM is re-enabled, check if we need to - * perform a similar task as this - - * adapter->pdown_speed = adapter->ai_force_speed; - * adapter->pdown_duplex = adapter->ai_force_duplex; - */ - - /* Stop sending packets. */ - spin_lock_irqsave(&adapter->send_hw_lock, flags); - adapter->flags |= fMP_ADAPTER_LOWER_POWER; - spin_unlock_irqrestore(&adapter->send_hw_lock, flags); - - /* Wait for outstanding Receive packets */ - - et131x_disable_txrx(adapter->netdev); - - /* Gate off JAGCore 3 clock domains */ - pmcsr &= ~ET_PMCSR_INIT; - writel(pmcsr, &adapter->regs->global.pm_csr); - - /* Program gigE PHY in to Coma mode */ - pmcsr |= ET_PM_PHY_SW_COMA; - writel(pmcsr, &adapter->regs->global.pm_csr); -} - -/** - * et1310_disable_phy_coma - Disable the Phy Coma Mode - * @adapter: pointer to our adapter structure - */ -void et1310_disable_phy_coma(struct et131x_adapter *adapter) -{ - u32 pmcsr; - - pmcsr = readl(&adapter->regs->global.pm_csr); - - /* Disable phy_sw_coma register and re-enable JAGCore clocks */ - pmcsr |= ET_PMCSR_INIT; - pmcsr &= ~ET_PM_PHY_SW_COMA; - writel(pmcsr, &adapter->regs->global.pm_csr); - - /* Restore the GbE PHY speed and duplex modes; - * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY - */ - /* TODO - when PM is re-enabled, check if we need to - * perform a similar task as this - - * adapter->ai_force_speed = adapter->pdown_speed; - * adapter->ai_force_duplex = adapter->pdown_duplex; - */ - - /* Re-initialize the send structures */ - et131x_init_send(adapter); - - /* Reset the RFD list and re-start RU */ - et131x_reset_recv(adapter); - - /* Bring the device back to the state it was during init prior to - * autonegotiation being complete. This way, when we get the auto-neg - * complete interrupt, we can complete init by calling ConfigMacREGS2. - */ - et131x_soft_reset(adapter); - - /* setup et1310 as per the documentation ?? */ - et131x_adapter_setup(adapter); - - /* Allow Tx to restart */ - adapter->flags &= ~fMP_ADAPTER_LOWER_POWER; - - et131x_enable_txrx(adapter->netdev); -} - diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c deleted file mode 100644 index 814922bbff0..00000000000 --- a/drivers/staging/et131x/et1310_rx.c +++ /dev/null @@ -1,1160 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_rx.c - Routines used to perform data reception - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et131x_adapter.h" -#include "et1310_rx.h" -#include "et131x.h" - -static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) -{ - u32 tmp_free_buff_ring = *free_buff_ring; - tmp_free_buff_ring++; - /* This works for all cases where limit < 1024. The 1023 case - works because 1023++ is 1024 which means the if condition is not - taken but the carry of the bit into the wrap bit toggles the wrap - value correctly */ - if ((tmp_free_buff_ring & ET_DMA10_MASK) > limit) { - tmp_free_buff_ring &= ~ET_DMA10_MASK; - tmp_free_buff_ring ^= ET_DMA10_WRAP; - } - /* For the 1023 case */ - tmp_free_buff_ring &= (ET_DMA10_MASK|ET_DMA10_WRAP); - *free_buff_ring = tmp_free_buff_ring; - return tmp_free_buff_ring; -} - -/** - * et131x_rx_dma_memory_alloc - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success and errno on failure (as defined in errno.h) - * - * Allocates Free buffer ring 1 for sure, free buffer ring 0 if required, - * and the Packet Status Ring. - */ -int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) -{ - u32 i, j; - u32 bufsize; - u32 pktstat_ringsize, fbr_chunksize; - struct rx_ring *rx_ring; - - /* Setup some convenience pointers */ - rx_ring = &adapter->rx_ring; - - /* Alloc memory for the lookup table */ -#ifdef USE_FBR0 - rx_ring->fbr[0] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); -#endif - rx_ring->fbr[1] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); - - /* The first thing we will do is configure the sizes of the buffer - * rings. These will change based on jumbo packet support. Larger - * jumbo packets increases the size of each entry in FBR0, and the - * number of entries in FBR0, while at the same time decreasing the - * number of entries in FBR1. - * - * FBR1 holds "large" frames, FBR0 holds "small" frames. If FBR1 - * entries are huge in order to accommodate a "jumbo" frame, then it - * will have less entries. Conversely, FBR1 will now be relied upon - * to carry more "normal" frames, thus it's entry size also increases - * and the number of entries goes up too (since it now carries - * "small" + "regular" packets. - * - * In this scheme, we try to maintain 512 entries between the two - * rings. Also, FBR1 remains a constant size - when it's size doubles - * the number of entries halves. FBR0 increases in size, however. - */ - - if (adapter->registry_jumbo_packet < 2048) { -#ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 256; - rx_ring->fbr0_num_entries = 512; -#endif - rx_ring->fbr1_buffsize = 2048; - rx_ring->fbr1_num_entries = 512; - } else if (adapter->registry_jumbo_packet < 4096) { -#ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 512; - rx_ring->fbr0_num_entries = 1024; -#endif - rx_ring->fbr1_buffsize = 4096; - rx_ring->fbr1_num_entries = 512; - } else { -#ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 1024; - rx_ring->fbr0_num_entries = 768; -#endif - rx_ring->fbr1_buffsize = 16384; - rx_ring->fbr1_num_entries = 128; - } - -#ifdef USE_FBR0 - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr0_num_entries + - adapter->rx_ring.fbr1_num_entries; -#else - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr1_num_entries; -#endif - - /* Allocate an area of memory for Free Buffer Ring 1 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff; - rx_ring->fbr1_ring_virtaddr = pci_alloc_consistent(adapter->pdev, - bufsize, - &rx_ring->fbr1_ring_physaddr); - if (!rx_ring->fbr1_ring_virtaddr) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Free Buffer Ring 1\n"); - return -ENOMEM; - } - - /* Save physical address - * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here - * before storing the adjusted address. - */ - rx_ring->fbr1_real_physaddr = rx_ring->fbr1_ring_physaddr; - - /* Align Free Buffer Ring 1 on a 4K boundary */ - et131x_align_allocated_memory(adapter, - &rx_ring->fbr1_real_physaddr, - &rx_ring->fbr1_offset, 0x0FFF); - - rx_ring->fbr1_ring_virtaddr = - (void *)((u8 *) rx_ring->fbr1_ring_virtaddr + - rx_ring->fbr1_offset); - -#ifdef USE_FBR0 - /* Allocate an area of memory for Free Buffer Ring 0 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff; - rx_ring->fbr0_ring_virtaddr = pci_alloc_consistent(adapter->pdev, - bufsize, - &rx_ring->fbr0_ring_physaddr); - if (!rx_ring->fbr0_ring_virtaddr) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Free Buffer Ring 0\n"); - return -ENOMEM; - } - - /* Save physical address - * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here before - * storing the adjusted address. - */ - rx_ring->fbr0_real_physaddr = rx_ring->fbr0_ring_physaddr; - - /* Align Free Buffer Ring 0 on a 4K boundary */ - et131x_align_allocated_memory(adapter, - &rx_ring->fbr0_real_physaddr, - &rx_ring->fbr0_offset, 0x0FFF); - - rx_ring->fbr0_ring_virtaddr = - (void *)((u8 *) rx_ring->fbr0_ring_virtaddr + - rx_ring->fbr0_offset); -#endif - for (i = 0; i < (rx_ring->fbr1_num_entries / FBR_CHUNKS); i++) { - u64 fbr1_offset; - u64 fbr1_tmp_physaddr; - u32 fbr1_align; - - /* This code allocates an area of memory big enough for N - * free buffers + (buffer_size - 1) so that the buffers can - * be aligned on 4k boundaries. If each buffer were aligned - * to a buffer_size boundary, the effect would be to double - * the size of FBR0. By allocating N buffers at once, we - * reduce this overhead. - */ - if (rx_ring->fbr1_buffsize > 4096) - fbr1_align = 4096; - else - fbr1_align = rx_ring->fbr1_buffsize; - - fbr_chunksize = - (FBR_CHUNKS * rx_ring->fbr1_buffsize) + fbr1_align - 1; - rx_ring->fbr1_mem_virtaddrs[i] = - pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr1_mem_physaddrs[i]); - - if (!rx_ring->fbr1_mem_virtaddrs[i]) { - dev_err(&adapter->pdev->dev, - "Could not alloc memory\n"); - return -ENOMEM; - } - - /* See NOTE in "Save Physical Address" comment above */ - fbr1_tmp_physaddr = rx_ring->fbr1_mem_physaddrs[i]; - - et131x_align_allocated_memory(adapter, - &fbr1_tmp_physaddr, - &fbr1_offset, (fbr1_align - 1)); - - for (j = 0; j < FBR_CHUNKS; j++) { - u32 index = (i * FBR_CHUNKS) + j; - - /* Save the Virtual address of this index for quick - * access later - */ - rx_ring->fbr[1]->virt[index] = - (u8 *) rx_ring->fbr1_mem_virtaddrs[i] + - (j * rx_ring->fbr1_buffsize) + fbr1_offset; - - /* now store the physical address in the descriptor - * so the device can access it - */ - rx_ring->fbr[1]->bus_high[index] = - (u32) (fbr1_tmp_physaddr >> 32); - rx_ring->fbr[1]->bus_low[index] = - (u32) fbr1_tmp_physaddr; - - fbr1_tmp_physaddr += rx_ring->fbr1_buffsize; - - rx_ring->fbr[1]->buffer1[index] = - rx_ring->fbr[1]->virt[index]; - rx_ring->fbr[1]->buffer2[index] = - rx_ring->fbr[1]->virt[index] - 4; - } - } - -#ifdef USE_FBR0 - /* Same for FBR0 (if in use) */ - for (i = 0; i < (rx_ring->fbr0_num_entries / FBR_CHUNKS); i++) { - u64 fbr0_offset; - u64 fbr0_tmp_physaddr; - - fbr_chunksize = - ((FBR_CHUNKS + 1) * rx_ring->fbr0_buffsize) - 1; - rx_ring->fbr0_mem_virtaddrs[i] = - pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr0_mem_physaddrs[i]); - - if (!rx_ring->fbr0_mem_virtaddrs[i]) { - dev_err(&adapter->pdev->dev, - "Could not alloc memory\n"); - return -ENOMEM; - } - - /* See NOTE in "Save Physical Address" comment above */ - fbr0_tmp_physaddr = rx_ring->fbr0_mem_physaddrs[i]; - - et131x_align_allocated_memory(adapter, - &fbr0_tmp_physaddr, - &fbr0_offset, - rx_ring->fbr0_buffsize - 1); - - for (j = 0; j < FBR_CHUNKS; j++) { - u32 index = (i * FBR_CHUNKS) + j; - - rx_ring->fbr[0]->virt[index] = - (u8 *) rx_ring->fbr0_mem_virtaddrs[i] + - (j * rx_ring->fbr0_buffsize) + fbr0_offset; - - rx_ring->fbr[0]->bus_high[index] = - (u32) (fbr0_tmp_physaddr >> 32); - rx_ring->fbr[0]->bus_low[index] = - (u32) fbr0_tmp_physaddr; - - fbr0_tmp_physaddr += rx_ring->fbr0_buffsize; - - rx_ring->fbr[0]->buffer1[index] = - rx_ring->fbr[0]->virt[index]; - rx_ring->fbr[0]->buffer2[index] = - rx_ring->fbr[0]->virt[index] - 4; - } - } -#endif - - /* Allocate an area of memory for FIFO of Packet Status ring entries */ - pktstat_ringsize = - sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries; - - rx_ring->ps_ring_virtaddr = pci_alloc_consistent(adapter->pdev, - pktstat_ringsize, - &rx_ring->ps_ring_physaddr); - - if (!rx_ring->ps_ring_virtaddr) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Packet Status Ring\n"); - return -ENOMEM; - } - printk(KERN_INFO "Packet Status Ring %lx\n", - (unsigned long) rx_ring->ps_ring_physaddr); - - /* - * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here before - * storing the adjusted address. - */ - - /* Allocate an area of memory for writeback of status information */ - rx_ring->rx_status_block = pci_alloc_consistent(adapter->pdev, - sizeof(struct rx_status_block), - &rx_ring->rx_status_bus); - if (!rx_ring->rx_status_block) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Status Block\n"); - return -ENOMEM; - } - rx_ring->num_rfd = NIC_DEFAULT_NUM_RFD; - printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); - - /* Recv - * pci_pool_create initializes a lookaside list. After successful - * creation, nonpaged fixed-size blocks can be allocated from and - * freed to the lookaside list. - * RFDs will be allocated from this pool. - */ - rx_ring->recv_lookaside = kmem_cache_create(adapter->netdev->name, - sizeof(struct rfd), - 0, - SLAB_CACHE_DMA | - SLAB_HWCACHE_ALIGN, - NULL); - - adapter->flags |= fMP_ADAPTER_RECV_LOOKASIDE; - - /* The RFDs are going to be put on lists later on, so initialize the - * lists now. - */ - INIT_LIST_HEAD(&rx_ring->recv_list); - return 0; -} - -/** - * et131x_rx_dma_memory_free - Free all memory allocated within this module. - * @adapter: pointer to our private adapter structure - */ -void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) -{ - u32 index; - u32 bufsize; - u32 pktstat_ringsize; - struct rfd *rfd; - struct rx_ring *rx_ring; - - /* Setup some convenience pointers */ - rx_ring = &adapter->rx_ring; - - /* Free RFDs and associated packet descriptors */ - WARN_ON(rx_ring->num_ready_recv != rx_ring->num_rfd); - - while (!list_empty(&rx_ring->recv_list)) { - rfd = (struct rfd *) list_entry(rx_ring->recv_list.next, - struct rfd, list_node); - - list_del(&rfd->list_node); - rfd->skb = NULL; - kmem_cache_free(adapter->rx_ring.recv_lookaside, rfd); - } - - /* Free Free Buffer Ring 1 */ - if (rx_ring->fbr1_ring_virtaddr) { - /* First the packet memory */ - for (index = 0; index < - (rx_ring->fbr1_num_entries / FBR_CHUNKS); index++) { - if (rx_ring->fbr1_mem_virtaddrs[index]) { - u32 fbr1_align; - - if (rx_ring->fbr1_buffsize > 4096) - fbr1_align = 4096; - else - fbr1_align = rx_ring->fbr1_buffsize; - - bufsize = - (rx_ring->fbr1_buffsize * FBR_CHUNKS) + - fbr1_align - 1; - - pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->fbr1_mem_virtaddrs[index], - rx_ring->fbr1_mem_physaddrs[index]); - - rx_ring->fbr1_mem_virtaddrs[index] = NULL; - } - } - - /* Now the FIFO itself */ - rx_ring->fbr1_ring_virtaddr = (void *)((u8 *) - rx_ring->fbr1_ring_virtaddr - rx_ring->fbr1_offset); - - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) - + 0xfff; - - pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr1_ring_virtaddr, - rx_ring->fbr1_ring_physaddr); - - rx_ring->fbr1_ring_virtaddr = NULL; - } - -#ifdef USE_FBR0 - /* Now the same for Free Buffer Ring 0 */ - if (rx_ring->fbr0_ring_virtaddr) { - /* First the packet memory */ - for (index = 0; index < - (rx_ring->fbr0_num_entries / FBR_CHUNKS); index++) { - if (rx_ring->fbr0_mem_virtaddrs[index]) { - bufsize = - (rx_ring->fbr0_buffsize * - (FBR_CHUNKS + 1)) - 1; - - pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->fbr0_mem_virtaddrs[index], - rx_ring->fbr0_mem_physaddrs[index]); - - rx_ring->fbr0_mem_virtaddrs[index] = NULL; - } - } - - /* Now the FIFO itself */ - rx_ring->fbr0_ring_virtaddr = (void *)((u8 *) - rx_ring->fbr0_ring_virtaddr - rx_ring->fbr0_offset); - - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) - + 0xfff; - - pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->fbr0_ring_virtaddr, - rx_ring->fbr0_ring_physaddr); - - rx_ring->fbr0_ring_virtaddr = NULL; - } -#endif - - /* Free Packet Status Ring */ - if (rx_ring->ps_ring_virtaddr) { - pktstat_ringsize = - sizeof(struct pkt_stat_desc) * - adapter->rx_ring.psr_num_entries; - - pci_free_consistent(adapter->pdev, pktstat_ringsize, - rx_ring->ps_ring_virtaddr, - rx_ring->ps_ring_physaddr); - - rx_ring->ps_ring_virtaddr = NULL; - } - - /* Free area of memory for the writeback of status information */ - if (rx_ring->rx_status_block) { - pci_free_consistent(adapter->pdev, - sizeof(struct rx_status_block), - rx_ring->rx_status_block, rx_ring->rx_status_bus); - rx_ring->rx_status_block = NULL; - } - - /* Free receive buffer pool */ - - /* Free receive packet pool */ - - /* Destroy the lookaside (RFD) pool */ - if (adapter->flags & fMP_ADAPTER_RECV_LOOKASIDE) { - kmem_cache_destroy(rx_ring->recv_lookaside); - adapter->flags &= ~fMP_ADAPTER_RECV_LOOKASIDE; - } - - /* Free the FBR Lookup Table */ -#ifdef USE_FBR0 - kfree(rx_ring->fbr[0]); -#endif - - kfree(rx_ring->fbr[1]); - - /* Reset Counters */ - rx_ring->num_ready_recv = 0; -} - -/** - * et131x_init_recv - Initialize receive data structures. - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success and errno on failure (as defined in errno.h) - */ -int et131x_init_recv(struct et131x_adapter *adapter) -{ - int status = -ENOMEM; - struct rfd *rfd = NULL; - u32 rfdct; - u32 numrfd = 0; - struct rx_ring *rx_ring; - - /* Setup some convenience pointers */ - rx_ring = &adapter->rx_ring; - - /* Setup each RFD */ - for (rfdct = 0; rfdct < rx_ring->num_rfd; rfdct++) { - rfd = kmem_cache_alloc(rx_ring->recv_lookaside, - GFP_ATOMIC | GFP_DMA); - - if (!rfd) { - dev_err(&adapter->pdev->dev, - "Couldn't alloc RFD out of kmem_cache\n"); - status = -ENOMEM; - continue; - } - - rfd->skb = NULL; - - /* Add this RFD to the recv_list */ - list_add_tail(&rfd->list_node, &rx_ring->recv_list); - - /* Increment both the available RFD's, and the total RFD's. */ - rx_ring->num_ready_recv++; - numrfd++; - } - - if (numrfd > NIC_MIN_NUM_RFD) - status = 0; - - rx_ring->num_rfd = numrfd; - - if (status != 0) { - kmem_cache_free(rx_ring->recv_lookaside, rfd); - dev_err(&adapter->pdev->dev, - "Allocation problems in et131x_init_recv\n"); - } - return status; -} - -/** - * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence - * @adapter: pointer to our adapter structure - */ -void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) -{ - struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; - struct rx_ring *rx_local = &adapter->rx_ring; - struct fbr_desc *fbr_entry; - u32 entry; - u32 psr_num_des; - unsigned long flags; - - /* Halt RXDMA to perform the reconfigure. */ - et131x_rx_dma_disable(adapter); - - /* Load the completion writeback physical address - * - * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here - * before storing the adjusted address. - */ - writel((u32) ((u64)rx_local->rx_status_bus >> 32), - &rx_dma->dma_wb_base_hi); - writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo); - - memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block)); - - /* Set the address and parameters of the packet status ring into the - * 1310's registers - */ - writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32), - &rx_dma->psr_base_hi); - writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo); - writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); - writel(0, &rx_dma->psr_full_offset); - - psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; - writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, - &rx_dma->psr_min_des); - - spin_lock_irqsave(&adapter->rcv_lock, flags); - - /* These local variables track the PSR in the adapter structure */ - rx_local->local_psr_full = 0; - - /* Now's the best time to initialize FBR1 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr1_ring_virtaddr; - for (entry = 0; entry < rx_local->fbr1_num_entries; entry++) { - fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; - fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; - fbr_entry->word2 = entry; - fbr_entry++; - } - - /* Set the address and parameters of Free buffer ring 1 (and 0 if - * required) into the 1310's registers - */ - writel((u32) (rx_local->fbr1_real_physaddr >> 32), - &rx_dma->fbr1_base_hi); - writel((u32) rx_local->fbr1_real_physaddr, &rx_dma->fbr1_base_lo); - writel(rx_local->fbr1_num_entries - 1, &rx_dma->fbr1_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); - - /* This variable tracks the free buffer ring 1 full position, so it - * has to match the above. - */ - rx_local->local_fbr1_full = ET_DMA10_WRAP; - writel( - ((rx_local->fbr1_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr1_min_des); - -#ifdef USE_FBR0 - /* Now's the best time to initialize FBR0 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr0_ring_virtaddr; - for (entry = 0; entry < rx_local->fbr0_num_entries; entry++) { - fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; - fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; - fbr_entry->word2 = entry; - fbr_entry++; - } - - writel((u32) (rx_local->fbr0_real_physaddr >> 32), - &rx_dma->fbr0_base_hi); - writel((u32) rx_local->fbr0_real_physaddr, &rx_dma->fbr0_base_lo); - writel(rx_local->fbr0_num_entries - 1, &rx_dma->fbr0_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); - - /* This variable tracks the free buffer ring 0 full position, so it - * has to match the above. - */ - rx_local->local_fbr0_full = ET_DMA10_WRAP; - writel( - ((rx_local->fbr0_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr0_min_des); -#endif - - /* Program the number of packets we will receive before generating an - * interrupt. - * For version B silicon, this value gets updated once autoneg is - *complete. - */ - writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done); - - /* The "time_done" is not working correctly to coalesce interrupts - * after a given time period, but rather is giving us an interrupt - * regardless of whether we have received packets. - * This value gets updated once autoneg is complete. - */ - writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time); - - spin_unlock_irqrestore(&adapter->rcv_lock, flags); -} - -/** - * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. - * @adapter: pointer to our adapter structure - */ -void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) -{ - struct phy_device *phydev = adapter->phydev; - - if (!phydev) - return; - - /* For version B silicon, we do not use the RxDMA timer for 10 and 100 - * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. - */ - if ((phydev->speed == SPEED_100) || (phydev->speed == SPEED_10)) { - writel(0, &adapter->regs->rxdma.max_pkt_time); - writel(1, &adapter->regs->rxdma.num_pkt_done); - } -} - -/** - * NICReturnRFD - Recycle a RFD and put it back onto the receive list - * @adapter: pointer to our adapter - * @rfd: pointer to the RFD - */ -static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) -{ - struct rx_ring *rx_local = &adapter->rx_ring; - struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; - u16 buff_index = rfd->bufferindex; - u8 ring_index = rfd->ringindex; - unsigned long flags; - - /* We don't use any of the OOB data besides status. Otherwise, we - * need to clean up OOB data - */ - if ( -#ifdef USE_FBR0 - (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || -#endif - (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { - spin_lock_irqsave(&adapter->fbr_lock, flags); - - if (ring_index == 1) { - struct fbr_desc *next = - (struct fbr_desc *) (rx_local->fbr1_ring_virtaddr) + - INDEX10(rx_local->local_fbr1_full); - - /* Handle the Free Buffer Ring advancement here. Write - * the PA / Buffer Index for the returned buffer into - * the oldest (next to be freed)FBR entry - */ - next->addr_hi = rx_local->fbr[1]->bus_high[buff_index]; - next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; - next->word2 = buff_index; - - writel(bump_free_buff_ring(&rx_local->local_fbr1_full, - rx_local->fbr1_num_entries - 1), - &rx_dma->fbr1_full_offset); - } -#ifdef USE_FBR0 - else { - struct fbr_desc *next = (struct fbr_desc *) - rx_local->fbr0_ring_virtaddr + - INDEX10(rx_local->local_fbr0_full); - - /* Handle the Free Buffer Ring advancement here. Write - * the PA / Buffer Index for the returned buffer into - * the oldest (next to be freed) FBR entry - */ - next->addr_hi = rx_local->fbr[0]->bus_high[buff_index]; - next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; - next->word2 = buff_index; - - writel(bump_free_buff_ring(&rx_local->local_fbr0_full, - rx_local->fbr0_num_entries - 1), - &rx_dma->fbr0_full_offset); - } -#endif - spin_unlock_irqrestore(&adapter->fbr_lock, flags); - } else { - dev_err(&adapter->pdev->dev, - "%s illegal Buffer Index returned\n", __func__); - } - - /* The processing on this RFD is done, so put it back on the tail of - * our list - */ - spin_lock_irqsave(&adapter->rcv_lock, flags); - list_add_tail(&rfd->list_node, &rx_local->recv_list); - rx_local->num_ready_recv++; - spin_unlock_irqrestore(&adapter->rcv_lock, flags); - - WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); -} - -/** - * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 - * @adapter: pointer to our adapter structure - */ -void et131x_rx_dma_disable(struct et131x_adapter *adapter) -{ - u32 csr; - /* Setup the receive dma configuration register */ - writel(0x00002001, &adapter->regs->rxdma.csr); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ - udelay(5); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) - dev_err(&adapter->pdev->dev, - "RX Dma failed to enter halt state. CSR 0x%08x\n", - csr); - } -} - -/** - * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. - * @adapter: pointer to our adapter structure - */ -void et131x_rx_dma_enable(struct et131x_adapter *adapter) -{ - /* Setup the receive dma configuration register for normal operation */ - u32 csr = 0x2000; /* FBR1 enable */ - - if (adapter->rx_ring.fbr1_buffsize == 4096) - csr |= 0x0800; - else if (adapter->rx_ring.fbr1_buffsize == 8192) - csr |= 0x1000; - else if (adapter->rx_ring.fbr1_buffsize == 16384) - csr |= 0x1800; -#ifdef USE_FBR0 - csr |= 0x0400; /* FBR0 enable */ - if (adapter->rx_ring.fbr0_buffsize == 256) - csr |= 0x0100; - else if (adapter->rx_ring.fbr0_buffsize == 512) - csr |= 0x0200; - else if (adapter->rx_ring.fbr0_buffsize == 1024) - csr |= 0x0300; -#endif - writel(csr, &adapter->regs->rxdma.csr); - - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) != 0) { - udelay(5); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) != 0) { - dev_err(&adapter->pdev->dev, - "RX Dma failed to exit halt state. CSR 0x%08x\n", - csr); - } - } -} - -/** - * nic_rx_pkts - Checks the hardware for available packets - * @adapter: pointer to our adapter - * - * Returns rfd, a pointer to our MPRFD. - * - * Checks the hardware for available packets, using completion ring - * If packets are available, it gets an RFD from the recv_list, attaches - * the packet to it, puts the RFD in the RecvPendList, and also returns - * the pointer to the RFD. - */ -static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) -{ - struct rx_ring *rx_local = &adapter->rx_ring; - struct rx_status_block *status; - struct pkt_stat_desc *psr; - struct rfd *rfd; - u32 i; - u8 *buf; - unsigned long flags; - struct list_head *element; - u8 ring_index; - u16 buff_index; - u32 len; - u32 word0; - u32 word1; - - /* RX Status block is written by the DMA engine prior to every - * interrupt. It contains the next to be used entry in the Packet - * Status Ring, and also the two Free Buffer rings. - */ - status = rx_local->rx_status_block; - word1 = status->word1 >> 16; /* Get the useful bits */ - - /* Check the PSR and wrap bits do not match */ - if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF)) - /* Looks like this ring is not updated yet */ - return NULL; - - /* The packet status ring indicates that data is available. */ - psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) + - (rx_local->local_psr_full & 0xFFF); - - /* Grab any information that is required once the PSR is - * advanced, since we can no longer rely on the memory being - * accurate - */ - len = psr->word1 & 0xFFFF; - ring_index = (psr->word1 >> 26) & 0x03; - buff_index = (psr->word1 >> 16) & 0x3FF; - word0 = psr->word0; - - /* Indicate that we have used this PSR entry. */ - /* FIXME wrap 12 */ - add_12bit(&rx_local->local_psr_full, 1); - if ( - (rx_local->local_psr_full & 0xFFF) > rx_local->psr_num_entries - 1) { - /* Clear psr full and toggle the wrap bit */ - rx_local->local_psr_full &= ~0xFFF; - rx_local->local_psr_full ^= 0x1000; - } - - writel(rx_local->local_psr_full, - &adapter->regs->rxdma.psr_full_offset); - -#ifndef USE_FBR0 - if (ring_index != 1) - return NULL; -#endif - -#ifdef USE_FBR0 - if (ring_index > 1 || - (ring_index == 0 && - buff_index > rx_local->fbr0_num_entries - 1) || - (ring_index == 1 && - buff_index > rx_local->fbr1_num_entries - 1)) -#else - if (ring_index != 1 || buff_index > rx_local->fbr1_num_entries - 1) -#endif - { - /* Illegal buffer or ring index cannot be used by S/W*/ - dev_err(&adapter->pdev->dev, - "NICRxPkts PSR Entry %d indicates " - "length of %d and/or bad bi(%d)\n", - rx_local->local_psr_full & 0xFFF, - len, buff_index); - return NULL; - } - - /* Get and fill the RFD. */ - spin_lock_irqsave(&adapter->rcv_lock, flags); - - rfd = NULL; - element = rx_local->recv_list.next; - rfd = (struct rfd *) list_entry(element, struct rfd, list_node); - - if (rfd == NULL) { - spin_unlock_irqrestore(&adapter->rcv_lock, flags); - return NULL; - } - - list_del(&rfd->list_node); - rx_local->num_ready_recv--; - - spin_unlock_irqrestore(&adapter->rcv_lock, flags); - - rfd->bufferindex = buff_index; - rfd->ringindex = ring_index; - - /* In V1 silicon, there is a bug which screws up filtering of - * runt packets. Therefore runt packet filtering is disabled - * in the MAC and the packets are dropped here. They are - * also counted here. - */ - if (len < (NIC_MIN_PACKET_SIZE + 4)) { - adapter->stats.rx_other_errs++; - len = 0; - } - - if (len) { - /* Determine if this is a multicast packet coming in */ - if ((word0 & ALCATEL_MULTICAST_PKT) && - !(word0 & ALCATEL_BROADCAST_PKT)) { - /* Promiscuous mode and Multicast mode are - * not mutually exclusive as was first - * thought. I guess Promiscuous is just - * considered a super-set of the other - * filters. Generally filter is 0x2b when in - * promiscuous mode. - */ - if ((adapter->packet_filter & - ET131X_PACKET_TYPE_MULTICAST) - && !(adapter->packet_filter & - ET131X_PACKET_TYPE_PROMISCUOUS) - && !(adapter->packet_filter & - ET131X_PACKET_TYPE_ALL_MULTICAST)) { - buf = rx_local->fbr[ring_index]-> - virt[buff_index]; - - /* Loop through our list to see if the - * destination address of this packet - * matches one in our list. - */ - for (i = 0; i < adapter->multicast_addr_count; - i++) { - if (buf[0] == - adapter->multicast_list[i][0] - && buf[1] == - adapter->multicast_list[i][1] - && buf[2] == - adapter->multicast_list[i][2] - && buf[3] == - adapter->multicast_list[i][3] - && buf[4] == - adapter->multicast_list[i][4] - && buf[5] == - adapter->multicast_list[i][5]) { - break; - } - } - - /* If our index is equal to the number - * of Multicast address we have, then - * this means we did not find this - * packet's matching address in our - * list. Set the len to zero, - * so we free our RFD when we return - * from this function. - */ - if (i == adapter->multicast_addr_count) - len = 0; - } - - if (len > 0) - adapter->stats.multicast_pkts_rcvd++; - } else if (word0 & ALCATEL_BROADCAST_PKT) - adapter->stats.broadcast_pkts_rcvd++; - else - /* Not sure what this counter measures in - * promiscuous mode. Perhaps we should check - * the MAC address to see if it is directed - * to us in promiscuous mode. - */ - adapter->stats.unicast_pkts_rcvd++; - } - - if (len > 0) { - struct sk_buff *skb = NULL; - - /*rfd->len = len - 4; */ - rfd->len = len; - - skb = dev_alloc_skb(rfd->len + 2); - if (!skb) { - dev_err(&adapter->pdev->dev, - "Couldn't alloc an SKB for Rx\n"); - return NULL; - } - - adapter->net_stats.rx_bytes += rfd->len; - - memcpy(skb_put(skb, rfd->len), - rx_local->fbr[ring_index]->virt[buff_index], - rfd->len); - - skb->dev = adapter->netdev; - skb->protocol = eth_type_trans(skb, adapter->netdev); - skb->ip_summed = CHECKSUM_NONE; - - netif_rx(skb); - } else { - rfd->len = 0; - } - - nic_return_rfd(adapter, rfd); - return rfd; -} - -/** - * et131x_reset_recv - Reset the receive list - * @adapter: pointer to our adapter - * - * Assumption, Rcv spinlock has been acquired. - */ -void et131x_reset_recv(struct et131x_adapter *adapter) -{ - WARN_ON(list_empty(&adapter->rx_ring.recv_list)); -} - -/** - * et131x_handle_recv_interrupt - Interrupt handler for receive processing - * @adapter: pointer to our adapter - * - * Assumption, Rcv spinlock has been acquired. - */ -void et131x_handle_recv_interrupt(struct et131x_adapter *adapter) -{ - struct rfd *rfd = NULL; - u32 count = 0; - bool done = true; - - /* Process up to available RFD's */ - while (count < NUM_PACKETS_HANDLED) { - if (list_empty(&adapter->rx_ring.recv_list)) { - WARN_ON(adapter->rx_ring.num_ready_recv != 0); - done = false; - break; - } - - rfd = nic_rx_pkts(adapter); - - if (rfd == NULL) - break; - - /* Do not receive any packets until a filter has been set. - * Do not receive any packets until we have link. - * If length is zero, return the RFD in order to advance the - * Free buffer ring. - */ - if (!adapter->packet_filter || - !netif_carrier_ok(adapter->netdev) || - rfd->len == 0) - continue; - - /* Increment the number of packets we received */ - adapter->net_stats.rx_packets++; - - /* Set the status on the packet, either resources or success */ - if (adapter->rx_ring.num_ready_recv < RFD_LOW_WATER_MARK) { - dev_warn(&adapter->pdev->dev, - "RFD's are running out\n"); - } - count++; - } - - if (count == NUM_PACKETS_HANDLED || !done) { - adapter->rx_ring.unfinished_receives = true; - writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, - &adapter->regs->global.watchdog_timer); - } else - /* Watchdog timer will disable itself if appropriate. */ - adapter->rx_ring.unfinished_receives = false; -} - diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c deleted file mode 100644 index cd12500a265..00000000000 --- a/drivers/staging/et131x/et1310_tx.c +++ /dev/null @@ -1,793 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_tx.c - Routines used to perform data transmission. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et131x_adapter.h" -#include "et1310_tx.h" -#include "et131x.h" - -/** - * et131x_tx_dma_memory_alloc - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success and errno on failure (as defined in errno.h). - * - * Allocates memory that will be visible both to the device and to the CPU. - * The OS will pass us packets, pointers to which we will insert in the Tx - * Descriptor queue. The device will read this queue to find the packets in - * memory. The device will update the "status" in memory each time it xmits a - * packet. - */ -int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) -{ - int desc_size = 0; - struct tx_ring *tx_ring = &adapter->tx_ring; - - /* Allocate memory for the TCB's (Transmit Control Block) */ - adapter->tx_ring.tcb_ring = - kcalloc(NUM_TCB, sizeof(struct tcb), GFP_ATOMIC | GFP_DMA); - if (!adapter->tx_ring.tcb_ring) { - dev_err(&adapter->pdev->dev, "Cannot alloc memory for TCBs\n"); - return -ENOMEM; - } - - /* Allocate enough memory for the Tx descriptor ring, and allocate - * some extra so that the ring can be aligned on a 4k boundary. - */ - desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1; - tx_ring->tx_desc_ring = - (struct tx_desc *) pci_alloc_consistent(adapter->pdev, desc_size, - &tx_ring->tx_desc_ring_pa); - if (!adapter->tx_ring.tx_desc_ring) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Tx Ring\n"); - return -ENOMEM; - } - - /* Save physical address - * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here before - * storing the adjusted address. - */ - /* Allocate memory for the Tx status block */ - tx_ring->tx_status = pci_alloc_consistent(adapter->pdev, - sizeof(u32), - &tx_ring->tx_status_pa); - if (!adapter->tx_ring.tx_status_pa) { - dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Tx status block\n"); - return -ENOMEM; - } - return 0; -} - -/** - * et131x_tx_dma_memory_free - Free all memory allocated within this module - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success and errno on failure (as defined in errno.h). - */ -void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) -{ - int desc_size = 0; - - if (adapter->tx_ring.tx_desc_ring) { - /* Free memory relating to Tx rings here */ - desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) - + 4096 - 1; - pci_free_consistent(adapter->pdev, - desc_size, - adapter->tx_ring.tx_desc_ring, - adapter->tx_ring.tx_desc_ring_pa); - adapter->tx_ring.tx_desc_ring = NULL; - } - - /* Free memory for the Tx status block */ - if (adapter->tx_ring.tx_status) { - pci_free_consistent(adapter->pdev, - sizeof(u32), - adapter->tx_ring.tx_status, - adapter->tx_ring.tx_status_pa); - - adapter->tx_ring.tx_status = NULL; - } - /* Free the memory for the tcb structures */ - kfree(adapter->tx_ring.tcb_ring); -} - -/** - * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. - * @adapter: pointer to our private adapter structure - * - * Configure the transmit engine with the ring buffers we have created - * and prepare it for use. - */ -void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) -{ - struct txdma_regs __iomem *txdma = &adapter->regs->txdma; - - /* Load the hardware with the start of the transmit descriptor ring. */ - writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32), - &txdma->pr_base_hi); - writel((u32) adapter->tx_ring.tx_desc_ring_pa, - &txdma->pr_base_lo); - - /* Initialise the transmit DMA engine */ - writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des); - - /* Load the completion writeback physical address */ - writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32), - &txdma->dma_wb_base_hi); - writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); - - *adapter->tx_ring.tx_status = 0; - - writel(0, &txdma->service_request); - adapter->tx_ring.send_idx = 0; -} - -/** - * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 - * @adapter: pointer to our adapter structure - */ -void et131x_tx_dma_disable(struct et131x_adapter *adapter) -{ - /* Setup the tramsmit dma configuration register */ - writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, - &adapter->regs->txdma.csr); -} - -/** - * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. - * @adapter: pointer to our adapter structure - * - * Mainly used after a return to the D0 (full-power) state from a lower state. - */ -void et131x_tx_dma_enable(struct et131x_adapter *adapter) -{ - /* Setup the transmit dma configuration register for normal - * operation - */ - writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), - &adapter->regs->txdma.csr); -} - -/** - * et131x_init_send - Initialize send data structures - * @adapter: pointer to our private adapter structure - */ -void et131x_init_send(struct et131x_adapter *adapter) -{ - struct tcb *tcb; - u32 ct; - struct tx_ring *tx_ring; - - /* Setup some convenience pointers */ - tx_ring = &adapter->tx_ring; - tcb = adapter->tx_ring.tcb_ring; - - tx_ring->tcb_qhead = tcb; - - memset(tcb, 0, sizeof(struct tcb) * NUM_TCB); - - /* Go through and set up each TCB */ - for (ct = 0; ct++ < NUM_TCB; tcb++) - /* Set the link pointer in HW TCB to the next TCB in the - * chain - */ - tcb->next = tcb + 1; - - /* Set the tail pointer */ - tcb--; - tx_ring->tcb_qtail = tcb; - tcb->next = NULL; - /* Curr send queue should now be empty */ - tx_ring->send_head = NULL; - tx_ring->send_tail = NULL; -} - -/** - * nic_send_packet - NIC specific send handler for version B silicon. - * @adapter: pointer to our adapter - * @tcb: pointer to struct tcb - * - * Returns 0 or errno. - */ -static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) -{ - u32 i; - struct tx_desc desc[24]; /* 24 x 16 byte */ - u32 frag = 0; - u32 thiscopy, remainder; - struct sk_buff *skb = tcb->skb; - u32 nr_frags = skb_shinfo(skb)->nr_frags + 1; - struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0]; - unsigned long flags; - struct phy_device *phydev = adapter->phydev; - - /* Part of the optimizations of this send routine restrict us to - * sending 24 fragments at a pass. In practice we should never see - * more than 5 fragments. - * - * NOTE: The older version of this function (below) can handle any - * number of fragments. If needed, we can call this function, - * although it is less efficient. - */ - if (nr_frags > 23) - return -EIO; - - memset(desc, 0, sizeof(struct tx_desc) * (nr_frags + 1)); - - for (i = 0; i < nr_frags; i++) { - /* If there is something in this element, lets get a - * descriptor from the ring and get the necessary data - */ - if (i == 0) { - /* If the fragments are smaller than a standard MTU, - * then map them to a single descriptor in the Tx - * Desc ring. However, if they're larger, as is - * possible with support for jumbo packets, then - * split them each across 2 descriptors. - * - * This will work until we determine why the hardware - * doesn't seem to like large fragments. - */ - if ((skb->len - skb->data_len) <= 1514) { - desc[frag].addr_hi = 0; - /* Low 16bits are length, high is vlan and - unused currently so zero */ - desc[frag].len_vlan = - skb->len - skb->data_len; - - /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a - * u32. Although dma_addr_t can be - * 64-bit, the address returned by - * pci_map_single() is always 32-bit - * addressable (as defined by the pci/dma - * subsystem) - */ - desc[frag++].addr_lo = - pci_map_single(adapter->pdev, - skb->data, - skb->len - - skb->data_len, - PCI_DMA_TODEVICE); - } else { - desc[frag].addr_hi = 0; - desc[frag].len_vlan = - (skb->len - skb->data_len) / 2; - - /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a - * u32. Although dma_addr_t can be - * 64-bit, the address returned by - * pci_map_single() is always 32-bit - * addressable (as defined by the pci/dma - * subsystem) - */ - desc[frag++].addr_lo = - pci_map_single(adapter->pdev, - skb->data, - ((skb->len - - skb->data_len) / 2), - PCI_DMA_TODEVICE); - desc[frag].addr_hi = 0; - - desc[frag].len_vlan = - (skb->len - skb->data_len) / 2; - - /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a - * u32. Although dma_addr_t can be - * 64-bit, the address returned by - * pci_map_single() is always 32-bit - * addressable (as defined by the pci/dma - * subsystem) - */ - desc[frag++].addr_lo = - pci_map_single(adapter->pdev, - skb->data + - ((skb->len - - skb->data_len) / 2), - ((skb->len - - skb->data_len) / 2), - PCI_DMA_TODEVICE); - } - } else { - desc[frag].addr_hi = 0; - desc[frag].len_vlan = - frags[i - 1].size; - - /* NOTE: Here, the dma_addr_t returned from - * pci_map_page() is implicitly cast as a u32. - * Although dma_addr_t can be 64-bit, the address - * returned by pci_map_page() is always 32-bit - * addressable (as defined by the pci/dma subsystem) - */ - desc[frag++].addr_lo = - pci_map_page(adapter->pdev, - frags[i - 1].page, - frags[i - 1].page_offset, - frags[i - 1].size, - PCI_DMA_TODEVICE); - } - } - - if (frag == 0) - return -EIO; - - if (phydev && phydev->speed == SPEED_1000) { - if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { - /* Last element & Interrupt flag */ - desc[frag - 1].flags = 0x5; - adapter->tx_ring.since_irq = 0; - } else { /* Last element */ - desc[frag - 1].flags = 0x1; - } - } else - desc[frag - 1].flags = 0x5; - - desc[0].flags |= 2; /* First element flag */ - - tcb->index_start = adapter->tx_ring.send_idx; - tcb->stale = 0; - - spin_lock_irqsave(&adapter->send_hw_lock, flags); - - thiscopy = NUM_DESC_PER_RING_TX - - INDEX10(adapter->tx_ring.send_idx); - - if (thiscopy >= frag) { - remainder = 0; - thiscopy = frag; - } else { - remainder = frag - thiscopy; - } - - memcpy(adapter->tx_ring.tx_desc_ring + - INDEX10(adapter->tx_ring.send_idx), desc, - sizeof(struct tx_desc) * thiscopy); - - add_10bit(&adapter->tx_ring.send_idx, thiscopy); - - if (INDEX10(adapter->tx_ring.send_idx) == 0 || - INDEX10(adapter->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { - adapter->tx_ring.send_idx &= ~ET_DMA10_MASK; - adapter->tx_ring.send_idx ^= ET_DMA10_WRAP; - } - - if (remainder) { - memcpy(adapter->tx_ring.tx_desc_ring, - desc + thiscopy, - sizeof(struct tx_desc) * remainder); - - add_10bit(&adapter->tx_ring.send_idx, remainder); - } - - if (INDEX10(adapter->tx_ring.send_idx) == 0) { - if (adapter->tx_ring.send_idx) - tcb->index = NUM_DESC_PER_RING_TX - 1; - else - tcb->index = ET_DMA10_WRAP|(NUM_DESC_PER_RING_TX - 1); - } else - tcb->index = adapter->tx_ring.send_idx - 1; - - spin_lock(&adapter->tcb_send_qlock); - - if (adapter->tx_ring.send_tail) - adapter->tx_ring.send_tail->next = tcb; - else - adapter->tx_ring.send_head = tcb; - - adapter->tx_ring.send_tail = tcb; - - WARN_ON(tcb->next != NULL); - - adapter->tx_ring.used++; - - spin_unlock(&adapter->tcb_send_qlock); - - /* Write the new write pointer back to the device. */ - writel(adapter->tx_ring.send_idx, - &adapter->regs->txdma.service_request); - - /* For Gig only, we use Tx Interrupt coalescing. Enable the software - * timer to wake us up if this packet isn't followed by N more. - */ - if (phydev && phydev->speed == SPEED_1000) { - writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, - &adapter->regs->global.watchdog_timer); - } - spin_unlock_irqrestore(&adapter->send_hw_lock, flags); - - return 0; -} - -/** - * send_packet - Do the work to send a packet - * @skb: the packet(s) to send - * @adapter: a pointer to the device's private adapter structure - * - * Return 0 in almost all cases; non-zero value in extreme hard failure only. - * - * Assumption: Send spinlock has been acquired - */ -static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) -{ - int status; - struct tcb *tcb = NULL; - u16 *shbufva; - unsigned long flags; - - /* All packets must have at least a MAC address and a protocol type */ - if (skb->len < ETH_HLEN) - return -EIO; - - /* Get a TCB for this packet */ - spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - - tcb = adapter->tx_ring.tcb_qhead; - - if (tcb == NULL) { - spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); - return -ENOMEM; - } - - adapter->tx_ring.tcb_qhead = tcb->next; - - if (adapter->tx_ring.tcb_qhead == NULL) - adapter->tx_ring.tcb_qtail = NULL; - - spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); - - tcb->skb = skb; - - if (skb->data != NULL && skb->len - skb->data_len >= 6) { - shbufva = (u16 *) skb->data; - - if ((shbufva[0] == 0xffff) && - (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) { - tcb->flags |= fMP_DEST_BROAD; - } else if ((shbufva[0] & 0x3) == 0x0001) { - tcb->flags |= fMP_DEST_MULTI; - } - } - - tcb->next = NULL; - - /* Call the NIC specific send handler. */ - status = nic_send_packet(adapter, tcb); - - if (status != 0) { - spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - - if (adapter->tx_ring.tcb_qtail) - adapter->tx_ring.tcb_qtail->next = tcb; - else - /* Apparently ready Q is empty. */ - adapter->tx_ring.tcb_qhead = tcb; - - adapter->tx_ring.tcb_qtail = tcb; - spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); - return status; - } - WARN_ON(adapter->tx_ring.used > NUM_TCB); - return 0; -} - -/** - * et131x_send_packets - This function is called by the OS to send packets - * @skb: the packet(s) to send - * @netdev:device on which to TX the above packet(s) - * - * Return 0 in almost all cases; non-zero value in extreme hard failure only - */ -int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) -{ - int status = 0; - struct et131x_adapter *adapter = NULL; - - adapter = netdev_priv(netdev); - - /* Send these packets - * - * NOTE: The Linux Tx entry point is only given one packet at a time - * to Tx, so the PacketCount and it's array used makes no sense here - */ - - /* TCB is not available */ - if (adapter->tx_ring.used >= NUM_TCB) { - /* NOTE: If there's an error on send, no need to queue the - * packet under Linux; if we just send an error up to the - * netif layer, it will resend the skb to us. - */ - status = -ENOMEM; - } else { - /* We need to see if the link is up; if it's not, make the - * netif layer think we're good and drop the packet - */ - if ((adapter->flags & fMP_ADAPTER_FAIL_SEND_MASK) || - !netif_carrier_ok(netdev)) { - dev_kfree_skb_any(skb); - skb = NULL; - - adapter->net_stats.tx_dropped++; - } else { - status = send_packet(skb, adapter); - if (status != 0 && status != -ENOMEM) { - /* On any other error, make netif think we're - * OK and drop the packet - */ - dev_kfree_skb_any(skb); - skb = NULL; - adapter->net_stats.tx_dropped++; - } - } - } - return status; -} - -/** - * free_send_packet - Recycle a struct tcb - * @adapter: pointer to our adapter - * @tcb: pointer to struct tcb - * - * Complete the packet if necessary - * Assumption - Send spinlock has been acquired - */ -static inline void free_send_packet(struct et131x_adapter *adapter, - struct tcb *tcb) -{ - unsigned long flags; - struct tx_desc *desc = NULL; - struct net_device_stats *stats = &adapter->net_stats; - - if (tcb->flags & fMP_DEST_BROAD) - atomic_inc(&adapter->stats.broadcast_pkts_xmtd); - else if (tcb->flags & fMP_DEST_MULTI) - atomic_inc(&adapter->stats.multicast_pkts_xmtd); - else - atomic_inc(&adapter->stats.unicast_pkts_xmtd); - - if (tcb->skb) { - stats->tx_bytes += tcb->skb->len; - - /* Iterate through the TX descriptors on the ring - * corresponding to this packet and umap the fragments - * they point to - */ - do { - desc = (struct tx_desc *) - (adapter->tx_ring.tx_desc_ring + - INDEX10(tcb->index_start)); - - pci_unmap_single(adapter->pdev, - desc->addr_lo, - desc->len_vlan, PCI_DMA_TODEVICE); - - add_10bit(&tcb->index_start, 1); - if (INDEX10(tcb->index_start) >= - NUM_DESC_PER_RING_TX) { - tcb->index_start &= ~ET_DMA10_MASK; - tcb->index_start ^= ET_DMA10_WRAP; - } - } while (desc != (adapter->tx_ring.tx_desc_ring + - INDEX10(tcb->index))); - - dev_kfree_skb_any(tcb->skb); - } - - memset(tcb, 0, sizeof(struct tcb)); - - /* Add the TCB to the Ready Q */ - spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); - - adapter->net_stats.tx_packets++; - - if (adapter->tx_ring.tcb_qtail) - adapter->tx_ring.tcb_qtail->next = tcb; - else - /* Apparently ready Q is empty. */ - adapter->tx_ring.tcb_qhead = tcb; - - adapter->tx_ring.tcb_qtail = tcb; - - spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); - WARN_ON(adapter->tx_ring.used < 0); -} - -/** - * et131x_free_busy_send_packets - Free and complete the stopped active sends - * @adapter: pointer to our adapter - * - * Assumption - Send spinlock has been acquired - */ -void et131x_free_busy_send_packets(struct et131x_adapter *adapter) -{ - struct tcb *tcb; - unsigned long flags; - u32 freed = 0; - - /* Any packets being sent? Check the first TCB on the send list */ - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - tcb = adapter->tx_ring.send_head; - - while (tcb != NULL && freed < NUM_TCB) { - struct tcb *next = tcb->next; - - adapter->tx_ring.send_head = next; - - if (next == NULL) - adapter->tx_ring.send_tail = NULL; - - adapter->tx_ring.used--; - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - - freed++; - free_send_packet(adapter, tcb); - - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - tcb = adapter->tx_ring.send_head; - } - - WARN_ON(freed == NUM_TCB); - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - - adapter->tx_ring.used = 0; -} - -/** - * et131x_handle_send_interrupt - Interrupt handler for sending processing - * @adapter: pointer to our adapter - * - * Re-claim the send resources, complete sends and get more to send from - * the send wait queue. - * - * Assumption - Send spinlock has been acquired - */ -void et131x_handle_send_interrupt(struct et131x_adapter *adapter) -{ - unsigned long flags; - u32 serviced; - struct tcb *tcb; - u32 index; - - serviced = readl(&adapter->regs->txdma.new_service_complete); - index = INDEX10(serviced); - - /* Has the ring wrapped? Process any descriptors that do not have - * the same "wrap" indicator as the current completion indicator - */ - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - tcb = adapter->tx_ring.send_head; - - while (tcb && - ((serviced ^ tcb->index) & ET_DMA10_WRAP) && - index < INDEX10(tcb->index)) { - adapter->tx_ring.used--; - adapter->tx_ring.send_head = tcb->next; - if (tcb->next == NULL) - adapter->tx_ring.send_tail = NULL; - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - free_send_packet(adapter, tcb); - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - /* Goto the next packet */ - tcb = adapter->tx_ring.send_head; - } - while (tcb && - !((serviced ^ tcb->index) & ET_DMA10_WRAP) - && index > (tcb->index & ET_DMA10_MASK)) { - adapter->tx_ring.used--; - adapter->tx_ring.send_head = tcb->next; - if (tcb->next == NULL) - adapter->tx_ring.send_tail = NULL; - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); - free_send_packet(adapter, tcb); - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - /* Goto the next packet */ - tcb = adapter->tx_ring.send_head; - } - - /* Wake up the queue when we hit a low-water mark */ - if (adapter->tx_ring.used <= NUM_TCB / 3) - netif_wake_queue(adapter->netdev); - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); -} - diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c new file mode 100644 index 00000000000..fdf6385e06a --- /dev/null +++ b/drivers/staging/et131x/et131x.c @@ -0,0 +1,5042 @@ +/* + * Agere Systems Inc. + * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs + * + * Copyright © 2005 Agere Systems Inc. + * All rights reserved. + * http://www.agere.com + * + * Copyright (c) 2011 Mark Einon + * + *------------------------------------------------------------------------------ + * + * SOFTWARE LICENSE + * + * This software is provided subject to the following terms and conditions, + * which you should read carefully before using the software. Using this + * software indicates your acceptance of these terms and conditions. If you do + * not agree with these terms and conditions, do not use the software. + * + * Copyright © 2005 Agere Systems Inc. + * All rights reserved. + * + * Redistribution and use in source or binary forms, with or without + * modifications, are permitted provided that the following conditions are met: + * + * . Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following Disclaimer as comments in the code as + * well as in the documentation and/or other materials provided with the + * distribution. + * + * . Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following Disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * . Neither the name of Agere Systems Inc. nor the names of the contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Disclaimer + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY + * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN + * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + */ + +#include "et131x_defs.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "et1310_phy.h" +#include "et131x_adapter.h" +#include "et1310_address_map.h" +#include "et1310_tx.h" +#include "et1310_rx.h" +#include "et131x.h" + +MODULE_AUTHOR("Victor Soriano "); +MODULE_AUTHOR("Mark Einon "); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " + "for the ET1310 by Agere Systems"); + +/* EEPROM functions */ + +static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) +{ + u32 reg; + int i; + + /* + * 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and + * bits 7,1:0 both equal to 1, at least once after reset. + * Subsequent operations need only to check that bits 1:0 are equal + * to 1 prior to starting a single byte read/write + */ + + for (i = 0; i < MAX_NUM_REGISTER_POLLS; i++) { + /* Read registers grouped in DWORD1 */ + if (pci_read_config_dword(pdev, LBCIF_DWORD1_GROUP, ®)) + return -EIO; + + /* I2C idle and Phy Queue Avail both true */ + if ((reg & 0x3000) == 0x3000) { + if (status) + *status = reg; + return reg & 0xFF; + } + } + return -ETIMEDOUT; +} + + +/** + * eeprom_write - Write a byte to the ET1310's EEPROM + * @adapter: pointer to our private adapter structure + * @addr: the address to write + * @data: the value to write + * + * Returns 1 for a successful write. + */ +static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) +{ + struct pci_dev *pdev = adapter->pdev; + int index = 0; + int retries; + int err = 0; + int i2c_wack = 0; + int writeok = 0; + u32 status; + u32 val = 0; + + /* + * For an EEPROM, an I2C single byte write is defined as a START + * condition followed by the device address, EEPROM address, one byte + * of data and a STOP condition. The STOP condition will trigger the + * EEPROM's internally timed write cycle to the nonvolatile memory. + * All inputs are disabled during this write cycle and the EEPROM will + * not respond to any access until the internal write is complete. + */ + + err = eeprom_wait_ready(pdev, NULL); + if (err) + return err; + + /* + * 2. Write to the LBCIF Control Register: bit 7=1, bit 6=1, bit 3=0, + * and bits 1:0 both =0. Bit 5 should be set according to the + * type of EEPROM being accessed (1=two byte addressing, 0=one + * byte addressing). + */ + if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, + LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE)) + return -EIO; + + i2c_wack = 1; + + /* Prepare EEPROM address for Step 3 */ + + for (retries = 0; retries < MAX_NUM_WRITE_RETRIES; retries++) { + /* Write the address to the LBCIF Address Register */ + if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) + break; + /* + * Write the data to the LBCIF Data Register (the I2C write + * will begin). + */ + if (pci_write_config_byte(pdev, LBCIF_DATA_REGISTER, data)) + break; + /* + * Monitor bit 1:0 of the LBCIF Status Register. When bits + * 1:0 are both equal to 1, the I2C write has completed and the + * internal write cycle of the EEPROM is about to start. + * (bits 1:0 = 01 is a legal state while waiting from both + * equal to 1, but bits 1:0 = 10 is invalid and implies that + * something is broken). + */ + err = eeprom_wait_ready(pdev, &status); + if (err < 0) + return 0; + + /* + * Check bit 3 of the LBCIF Status Register. If equal to 1, + * an error has occurred.Don't break here if we are revision + * 1, this is so we do a blind write for load bug. + */ + if ((status & LBCIF_STATUS_GENERAL_ERROR) + && adapter->pdev->revision == 0) + break; + + /* + * Check bit 2 of the LBCIF Status Register. If equal to 1 an + * ACK error has occurred on the address phase of the write. + * This could be due to an actual hardware failure or the + * EEPROM may still be in its internal write cycle from a + * previous write. This write operation was ignored and must be + *repeated later. + */ + if (status & LBCIF_STATUS_ACK_ERROR) { + /* + * This could be due to an actual hardware failure + * or the EEPROM may still be in its internal write + * cycle from a previous write. This write operation + * was ignored and must be repeated later. + */ + udelay(10); + continue; + } + + writeok = 1; + break; + } + + /* + * Set bit 6 of the LBCIF Control Register = 0. + */ + udelay(10); + + while (i2c_wack) { + if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, + LBCIF_CONTROL_LBCIF_ENABLE)) + writeok = 0; + + /* Do read until internal ACK_ERROR goes away meaning write + * completed + */ + do { + pci_write_config_dword(pdev, + LBCIF_ADDRESS_REGISTER, + addr); + do { + pci_read_config_dword(pdev, + LBCIF_DATA_REGISTER, &val); + } while ((val & 0x00010000) == 0); + } while (val & 0x00040000); + + if ((val & 0xFF00) != 0xC000 || index == 10000) + break; + index++; + } + return writeok ? 0 : -EIO; +} + +/** + * eeprom_read - Read a byte from the ET1310's EEPROM + * @adapter: pointer to our private adapter structure + * @addr: the address from which to read + * @pdata: a pointer to a byte in which to store the value of the read + * @eeprom_id: the ID of the EEPROM + * @addrmode: how the EEPROM is to be accessed + * + * Returns 1 for a successful read + */ +static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata) +{ + struct pci_dev *pdev = adapter->pdev; + int err; + u32 status; + + /* + * A single byte read is similar to the single byte write, with the + * exception of the data flow: + */ + + err = eeprom_wait_ready(pdev, NULL); + if (err) + return err; + /* + * Write to the LBCIF Control Register: bit 7=1, bit 6=0, bit 3=0, + * and bits 1:0 both =0. Bit 5 should be set according to the type + * of EEPROM being accessed (1=two byte addressing, 0=one byte + * addressing). + */ + if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, + LBCIF_CONTROL_LBCIF_ENABLE)) + return -EIO; + /* + * Write the address to the LBCIF Address Register (I2C read will + * begin). + */ + if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) + return -EIO; + /* + * Monitor bit 0 of the LBCIF Status Register. When = 1, I2C read + * is complete. (if bit 1 =1 and bit 0 stays = 0, a hardware failure + * has occurred). + */ + err = eeprom_wait_ready(pdev, &status); + if (err < 0) + return err; + /* + * Regardless of error status, read data byte from LBCIF Data + * Register. + */ + *pdata = err; + /* + * Check bit 2 of the LBCIF Status Register. If = 1, + * then an error has occurred. + */ + return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0; +} + +int et131x_init_eeprom(struct et131x_adapter *adapter) +{ + struct pci_dev *pdev = adapter->pdev; + u8 eestatus; + + /* We first need to check the EEPROM Status code located at offset + * 0xB2 of config space + */ + pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, + &eestatus); + + /* THIS IS A WORKAROUND: + * I need to call this function twice to get my card in a + * LG M1 Express Dual running. I tried also a msleep before this + * function, because I thougth there could be some time condidions + * but it didn't work. Call the whole function twice also work. + */ + if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) { + dev_err(&pdev->dev, + "Could not read PCI config space for EEPROM Status\n"); + return -EIO; + } + + /* Determine if the error(s) we care about are present. If they are + * present we need to fail. + */ + if (eestatus & 0x4C) { + int write_failed = 0; + if (pdev->revision == 0x01) { + int i; + static const u8 eedata[4] = { 0xFE, 0x13, 0x10, 0xFF }; + + /* Re-write the first 4 bytes if we have an eeprom + * present and the revision id is 1, this fixes the + * corruption seen with 1310 B Silicon + */ + for (i = 0; i < 3; i++) + if (eeprom_write(adapter, i, eedata[i]) < 0) + write_failed = 1; + } + if (pdev->revision != 0x01 || write_failed) { + dev_err(&pdev->dev, + "Fatal EEPROM Status Error - 0x%04x\n", eestatus); + + /* This error could mean that there was an error + * reading the eeprom or that the eeprom doesn't exist. + * We will treat each case the same and not try to + * gather additional information that normally would + * come from the eeprom, like MAC Address + */ + adapter->has_eeprom = 0; + return -EIO; + } + } + adapter->has_eeprom = 1; + + /* Read the EEPROM for information regarding LED behavior. Refer to + * ET1310_phy.c, et131x_xcvr_init(), for its use. + */ + eeprom_read(adapter, 0x70, &adapter->eeprom_data[0]); + eeprom_read(adapter, 0x71, &adapter->eeprom_data[1]); + + if (adapter->eeprom_data[0] != 0xcd) + /* Disable all optional features */ + adapter->eeprom_data[1] = 0x00; + + return 0; +} + +/* MAC functions */ + +/** + * et1310_config_mac_regs1 - Initialize the first part of MAC regs + * @adapter: pointer to our adapter structure + */ +void et1310_config_mac_regs1(struct et131x_adapter *adapter) +{ + struct mac_regs __iomem *macregs = &adapter->regs->mac; + u32 station1; + u32 station2; + u32 ipg; + + /* First we need to reset everything. Write to MAC configuration + * register 1 to perform reset. + */ + writel(0xC00F0000, ¯egs->cfg1); + + /* Next lets configure the MAC Inter-packet gap register */ + ipg = 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */ + ipg |= 0x50 << 8; /* ifg enforce 0x50 */ + writel(ipg, ¯egs->ipg); + + /* Next lets configure the MAC Half Duplex register */ + /* BEB trunc 0xA, Ex Defer, Rexmit 0xF Coll 0x37 */ + writel(0x00A1F037, ¯egs->hfdp); + + /* Next lets configure the MAC Interface Control register */ + writel(0, ¯egs->if_ctrl); + + /* Let's move on to setting up the mii management configuration */ + writel(0x07, ¯egs->mii_mgmt_cfg); /* Clock reset 0x7 */ + + /* Next lets configure the MAC Station Address register. These + * values are read from the EEPROM during initialization and stored + * in the adapter structure. We write what is stored in the adapter + * structure to the MAC Station Address registers high and low. This + * station address is used for generating and checking pause control + * packets. + */ + station2 = (adapter->addr[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT) | + (adapter->addr[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT); + station1 = (adapter->addr[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT) | + (adapter->addr[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT) | + (adapter->addr[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT) | + adapter->addr[2]; + writel(station1, ¯egs->station_addr_1); + writel(station2, ¯egs->station_addr_2); + + /* Max ethernet packet in bytes that will passed by the mac without + * being truncated. Allow the MAC to pass 4 more than our max packet + * size. This is 4 for the Ethernet CRC. + * + * Packets larger than (registry_jumbo_packet) that do not contain a + * VLAN ID will be dropped by the Rx function. + */ + writel(adapter->registry_jumbo_packet + 4, ¯egs->max_fm_len); + + /* clear out MAC config reset */ + writel(0, ¯egs->cfg1); +} + +/** + * et1310_config_mac_regs2 - Initialize the second part of MAC regs + * @adapter: pointer to our adapter structure + */ +void et1310_config_mac_regs2(struct et131x_adapter *adapter) +{ + int32_t delay = 0; + struct mac_regs __iomem *mac = &adapter->regs->mac; + struct phy_device *phydev = adapter->phydev; + u32 cfg1; + u32 cfg2; + u32 ifctrl; + u32 ctl; + + ctl = readl(&adapter->regs->txmac.ctl); + cfg1 = readl(&mac->cfg1); + cfg2 = readl(&mac->cfg2); + ifctrl = readl(&mac->if_ctrl); + + /* Set up the if mode bits */ + cfg2 &= ~0x300; + if (phydev && phydev->speed == SPEED_1000) { + cfg2 |= 0x200; + /* Phy mode bit */ + ifctrl &= ~(1 << 24); + } else { + cfg2 |= 0x100; + ifctrl |= (1 << 24); + } + + /* We need to enable Rx/Tx */ + cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; + /* Initialize loop back to off */ + cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); + if (adapter->flowcontrol == FLOW_RXONLY || + adapter->flowcontrol == FLOW_BOTH) + cfg1 |= CFG1_RX_FLOW; + writel(cfg1, &mac->cfg1); + + /* Now we need to initialize the MAC Configuration 2 register */ + /* preamble 7, check length, huge frame off, pad crc, crc enable + full duplex off */ + cfg2 |= 0x7016; + cfg2 &= ~0x0021; + + /* Turn on duplex if needed */ + if (phydev && phydev->duplex == DUPLEX_FULL) + cfg2 |= 0x01; + + ifctrl &= ~(1 << 26); + if (phydev && phydev->duplex == DUPLEX_HALF) + ifctrl |= (1<<26); /* Enable ghd */ + + writel(ifctrl, &mac->if_ctrl); + writel(cfg2, &mac->cfg2); + + do { + udelay(10); + delay++; + cfg1 = readl(&mac->cfg1); + } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100); + + if (delay == 100) { + dev_warn(&adapter->pdev->dev, + "Syncd bits did not respond correctly cfg1 word 0x%08x\n", + cfg1); + } + + /* Enable txmac */ + ctl |= 0x09; /* TX mac enable, FC disable */ + writel(ctl, &adapter->regs->txmac.ctl); + + /* Ready to start the RXDMA/TXDMA engine */ + if (adapter->flags & fMP_ADAPTER_LOWER_POWER) { + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + } +} + +void et1310_config_rxmac_regs(struct et131x_adapter *adapter) +{ + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + struct phy_device *phydev = adapter->phydev; + u32 sa_lo; + u32 sa_hi = 0; + u32 pf_ctrl = 0; + + /* Disable the MAC while it is being configured (also disable WOL) */ + writel(0x8, &rxmac->ctrl); + + /* Initialize WOL to disabled. */ + writel(0, &rxmac->crc0); + writel(0, &rxmac->crc12); + writel(0, &rxmac->crc34); + + /* We need to set the WOL mask0 - mask4 next. We initialize it to + * its default Values of 0x00000000 because there are not WOL masks + * as of this time. + */ + writel(0, &rxmac->mask0_word0); + writel(0, &rxmac->mask0_word1); + writel(0, &rxmac->mask0_word2); + writel(0, &rxmac->mask0_word3); + + writel(0, &rxmac->mask1_word0); + writel(0, &rxmac->mask1_word1); + writel(0, &rxmac->mask1_word2); + writel(0, &rxmac->mask1_word3); + + writel(0, &rxmac->mask2_word0); + writel(0, &rxmac->mask2_word1); + writel(0, &rxmac->mask2_word2); + writel(0, &rxmac->mask2_word3); + + writel(0, &rxmac->mask3_word0); + writel(0, &rxmac->mask3_word1); + writel(0, &rxmac->mask3_word2); + writel(0, &rxmac->mask3_word3); + + writel(0, &rxmac->mask4_word0); + writel(0, &rxmac->mask4_word1); + writel(0, &rxmac->mask4_word2); + writel(0, &rxmac->mask4_word3); + + /* Lets setup the WOL Source Address */ + sa_lo = (adapter->addr[2] << ET_WOL_LO_SA3_SHIFT) | + (adapter->addr[3] << ET_WOL_LO_SA4_SHIFT) | + (adapter->addr[4] << ET_WOL_LO_SA5_SHIFT) | + adapter->addr[5]; + writel(sa_lo, &rxmac->sa_lo); + + sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) | + adapter->addr[1]; + writel(sa_hi, &rxmac->sa_hi); + + /* Disable all Packet Filtering */ + writel(0, &rxmac->pf_ctrl); + + /* Let's initialize the Unicast Packet filtering address */ + if (adapter->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { + et1310_setup_device_for_unicast(adapter); + pf_ctrl |= 4; /* Unicast filter */ + } else { + writel(0, &rxmac->uni_pf_addr1); + writel(0, &rxmac->uni_pf_addr2); + writel(0, &rxmac->uni_pf_addr3); + } + + /* Let's initialize the Multicast hash */ + if (!(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { + pf_ctrl |= 2; /* Multicast filter */ + et1310_setup_device_for_multicast(adapter); + } + + /* Runt packet filtering. Didn't work in version A silicon. */ + pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16; + pf_ctrl |= 8; /* Fragment filter */ + + if (adapter->registry_jumbo_packet > 8192) + /* In order to transmit jumbo packets greater than 8k, the + * FIFO between RxMAC and RxDMA needs to be reduced in size + * to (16k - Jumbo packet size). In order to implement this, + * we must use "cut through" mode in the RxMAC, which chops + * packets down into segments which are (max_size * 16). In + * this case we selected 256 bytes, since this is the size of + * the PCI-Express TLP's that the 1310 uses. + * + * seg_en on, fc_en off, size 0x10 + */ + writel(0x41, &rxmac->mcif_ctrl_max_seg); + else + writel(0, &rxmac->mcif_ctrl_max_seg); + + /* Initialize the MCIF water marks */ + writel(0, &rxmac->mcif_water_mark); + + /* Initialize the MIF control */ + writel(0, &rxmac->mif_ctrl); + + /* Initialize the Space Available Register */ + writel(0, &rxmac->space_avail); + + /* Initialize the the mif_ctrl register + * bit 3: Receive code error. One or more nibbles were signaled as + * errors during the reception of the packet. Clear this + * bit in Gigabit, set it in 100Mbit. This was derived + * experimentally at UNH. + * bit 4: Receive CRC error. The packet's CRC did not match the + * internally generated CRC. + * bit 5: Receive length check error. Indicates that frame length + * field value in the packet does not match the actual data + * byte length and is not a type field. + * bit 16: Receive frame truncated. + * bit 17: Drop packet enable + */ + if (phydev && phydev->speed == SPEED_100) + writel(0x30038, &rxmac->mif_ctrl); + else + writel(0x30030, &rxmac->mif_ctrl); + + /* Finally we initialize RxMac to be enabled & WOL disabled. Packet + * filter is always enabled since it is where the runt packets are + * supposed to be dropped. For version A silicon, runt packet + * dropping doesn't work, so it is disabled in the pf_ctrl register, + * but we still leave the packet filter on. + */ + writel(pf_ctrl, &rxmac->pf_ctrl); + writel(0x9, &rxmac->ctrl); +} + +void et1310_config_txmac_regs(struct et131x_adapter *adapter) +{ + struct txmac_regs __iomem *txmac = &adapter->regs->txmac; + + /* We need to update the Control Frame Parameters + * cfpt - control frame pause timer set to 64 (0x40) + * cfep - control frame extended pause timer set to 0x0 + */ + if (adapter->flowcontrol == FLOW_NONE) + writel(0, &txmac->cf_param); + else + writel(0x40, &txmac->cf_param); +} + +void et1310_config_macstat_regs(struct et131x_adapter *adapter) +{ + struct macstat_regs __iomem *macstat = + &adapter->regs->macstat; + + /* Next we need to initialize all the macstat registers to zero on + * the device. + */ + writel(0, &macstat->txrx_0_64_byte_frames); + writel(0, &macstat->txrx_65_127_byte_frames); + writel(0, &macstat->txrx_128_255_byte_frames); + writel(0, &macstat->txrx_256_511_byte_frames); + writel(0, &macstat->txrx_512_1023_byte_frames); + writel(0, &macstat->txrx_1024_1518_byte_frames); + writel(0, &macstat->txrx_1519_1522_gvln_frames); + + writel(0, &macstat->rx_bytes); + writel(0, &macstat->rx_packets); + writel(0, &macstat->rx_fcs_errs); + writel(0, &macstat->rx_multicast_packets); + writel(0, &macstat->rx_broadcast_packets); + writel(0, &macstat->rx_control_frames); + writel(0, &macstat->rx_pause_frames); + writel(0, &macstat->rx_unknown_opcodes); + writel(0, &macstat->rx_align_errs); + writel(0, &macstat->rx_frame_len_errs); + writel(0, &macstat->rx_code_errs); + writel(0, &macstat->rx_carrier_sense_errs); + writel(0, &macstat->rx_undersize_packets); + writel(0, &macstat->rx_oversize_packets); + writel(0, &macstat->rx_fragment_packets); + writel(0, &macstat->rx_jabbers); + writel(0, &macstat->rx_drops); + + writel(0, &macstat->tx_bytes); + writel(0, &macstat->tx_packets); + writel(0, &macstat->tx_multicast_packets); + writel(0, &macstat->tx_broadcast_packets); + writel(0, &macstat->tx_pause_frames); + writel(0, &macstat->tx_deferred); + writel(0, &macstat->tx_excessive_deferred); + writel(0, &macstat->tx_single_collisions); + writel(0, &macstat->tx_multiple_collisions); + writel(0, &macstat->tx_late_collisions); + writel(0, &macstat->tx_excessive_collisions); + writel(0, &macstat->tx_total_collisions); + writel(0, &macstat->tx_pause_honored_frames); + writel(0, &macstat->tx_drops); + writel(0, &macstat->tx_jabbers); + writel(0, &macstat->tx_fcs_errs); + writel(0, &macstat->tx_control_frames); + writel(0, &macstat->tx_oversize_frames); + writel(0, &macstat->tx_undersize_frames); + writel(0, &macstat->tx_fragments); + writel(0, &macstat->carry_reg1); + writel(0, &macstat->carry_reg2); + + /* Unmask any counters that we want to track the overflow of. + * Initially this will be all counters. It may become clear later + * that we do not need to track all counters. + */ + writel(0xFFFFBE32, &macstat->carry_reg1_mask); + writel(0xFFFE7E8B, &macstat->carry_reg2_mask); +} + +void et1310_config_flow_control(struct et131x_adapter *adapter) +{ + struct phy_device *phydev = adapter->phydev; + + if (phydev->duplex == DUPLEX_HALF) { + adapter->flowcontrol = FLOW_NONE; + } else { + char remote_pause, remote_async_pause; + + et1310_phy_access_mii_bit(adapter, + TRUEPHY_BIT_READ, 5, 10, &remote_pause); + et1310_phy_access_mii_bit(adapter, + TRUEPHY_BIT_READ, 5, 11, + &remote_async_pause); + + if ((remote_pause == TRUEPHY_BIT_SET) && + (remote_async_pause == TRUEPHY_BIT_SET)) { + adapter->flowcontrol = adapter->wanted_flow; + } else if ((remote_pause == TRUEPHY_BIT_SET) && + (remote_async_pause == TRUEPHY_BIT_CLEAR)) { + if (adapter->wanted_flow == FLOW_BOTH) + adapter->flowcontrol = FLOW_BOTH; + else + adapter->flowcontrol = FLOW_NONE; + } else if ((remote_pause == TRUEPHY_BIT_CLEAR) && + (remote_async_pause == TRUEPHY_BIT_CLEAR)) { + adapter->flowcontrol = FLOW_NONE; + } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT && + remote_async_pause == TRUEPHY_SET_BIT) */ + if (adapter->wanted_flow == FLOW_BOTH) + adapter->flowcontrol = FLOW_RXONLY; + else + adapter->flowcontrol = FLOW_NONE; + } + } +} + +/** + * et1310_update_macstat_host_counters - Update the local copy of the statistics + * @adapter: pointer to the adapter structure + */ +void et1310_update_macstat_host_counters(struct et131x_adapter *adapter) +{ + struct ce_stats *stats = &adapter->stats; + struct macstat_regs __iomem *macstat = + &adapter->regs->macstat; + + stats->tx_collisions += readl(&macstat->tx_total_collisions); + stats->tx_first_collisions += readl(&macstat->tx_single_collisions); + stats->tx_deferred += readl(&macstat->tx_deferred); + stats->tx_excessive_collisions += + readl(&macstat->tx_multiple_collisions); + stats->tx_late_collisions += readl(&macstat->tx_late_collisions); + stats->tx_underflows += readl(&macstat->tx_undersize_frames); + stats->tx_max_pkt_errs += readl(&macstat->tx_oversize_frames); + + stats->rx_align_errs += readl(&macstat->rx_align_errs); + stats->rx_crc_errs += readl(&macstat->rx_code_errs); + stats->rcvd_pkts_dropped += readl(&macstat->rx_drops); + stats->rx_overflows += readl(&macstat->rx_oversize_packets); + stats->rx_code_violations += readl(&macstat->rx_fcs_errs); + stats->rx_length_errs += readl(&macstat->rx_frame_len_errs); + stats->rx_other_errs += readl(&macstat->rx_fragment_packets); +} + +/** + * et1310_handle_macstat_interrupt + * @adapter: pointer to the adapter structure + * + * One of the MACSTAT counters has wrapped. Update the local copy of + * the statistics held in the adapter structure, checking the "wrap" + * bit for each counter. + */ +void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter) +{ + u32 carry_reg1; + u32 carry_reg2; + + /* Read the interrupt bits from the register(s). These are Clear On + * Write. + */ + carry_reg1 = readl(&adapter->regs->macstat.carry_reg1); + carry_reg2 = readl(&adapter->regs->macstat.carry_reg2); + + writel(carry_reg1, &adapter->regs->macstat.carry_reg1); + writel(carry_reg2, &adapter->regs->macstat.carry_reg2); + + /* We need to do update the host copy of all the MAC_STAT counters. + * For each counter, check it's overflow bit. If the overflow bit is + * set, then increment the host version of the count by one complete + * revolution of the counter. This routine is called when the counter + * block indicates that one of the counters has wrapped. + */ + if (carry_reg1 & (1 << 14)) + adapter->stats.rx_code_violations += COUNTER_WRAP_16_BIT; + if (carry_reg1 & (1 << 8)) + adapter->stats.rx_align_errs += COUNTER_WRAP_12_BIT; + if (carry_reg1 & (1 << 7)) + adapter->stats.rx_length_errs += COUNTER_WRAP_16_BIT; + if (carry_reg1 & (1 << 2)) + adapter->stats.rx_other_errs += COUNTER_WRAP_16_BIT; + if (carry_reg1 & (1 << 6)) + adapter->stats.rx_crc_errs += COUNTER_WRAP_16_BIT; + if (carry_reg1 & (1 << 3)) + adapter->stats.rx_overflows += COUNTER_WRAP_16_BIT; + if (carry_reg1 & (1 << 0)) + adapter->stats.rcvd_pkts_dropped += COUNTER_WRAP_16_BIT; + if (carry_reg2 & (1 << 16)) + adapter->stats.tx_max_pkt_errs += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 15)) + adapter->stats.tx_underflows += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 6)) + adapter->stats.tx_first_collisions += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 8)) + adapter->stats.tx_deferred += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 5)) + adapter->stats.tx_excessive_collisions += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 4)) + adapter->stats.tx_late_collisions += COUNTER_WRAP_12_BIT; + if (carry_reg2 & (1 << 2)) + adapter->stats.tx_collisions += COUNTER_WRAP_12_BIT; +} + +void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) +{ + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + uint32_t nIndex; + uint32_t result; + uint32_t hash1 = 0; + uint32_t hash2 = 0; + uint32_t hash3 = 0; + uint32_t hash4 = 0; + u32 pm_csr; + + /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision + * the multi-cast LIST. If it is NOT specified, (and "ALL" is not + * specified) then we should pass NO multi-cast addresses to the + * driver. + */ + if (adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { + /* Loop through our multicast array and set up the device */ + for (nIndex = 0; nIndex < adapter->multicast_addr_count; + nIndex++) { + result = ether_crc(6, adapter->multicast_list[nIndex]); + + result = (result & 0x3F800000) >> 23; + + if (result < 32) { + hash1 |= (1 << result); + } else if ((31 < result) && (result < 64)) { + result -= 32; + hash2 |= (1 << result); + } else if ((63 < result) && (result < 96)) { + result -= 64; + hash3 |= (1 << result); + } else { + result -= 96; + hash4 |= (1 << result); + } + } + } + + /* Write out the new hash to the device */ + pm_csr = readl(&adapter->regs->global.pm_csr); + if (!et1310_in_phy_coma(adapter)) { + writel(hash1, &rxmac->multi_hash1); + writel(hash2, &rxmac->multi_hash2); + writel(hash3, &rxmac->multi_hash3); + writel(hash4, &rxmac->multi_hash4); + } +} + +void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) +{ + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + u32 uni_pf1; + u32 uni_pf2; + u32 uni_pf3; + u32 pm_csr; + + /* Set up unicast packet filter reg 3 to be the first two octets of + * the MAC address for both address + * + * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the + * MAC address for second address + * + * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the + * MAC address for first address + */ + uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | + (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | + (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | + adapter->addr[1]; + + uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | + adapter->addr[5]; + + uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | + adapter->addr[5]; + + pm_csr = readl(&adapter->regs->global.pm_csr); + if (!et1310_in_phy_coma(adapter)) { + writel(uni_pf1, &rxmac->uni_pf_addr1); + writel(uni_pf2, &rxmac->uni_pf_addr2); + writel(uni_pf3, &rxmac->uni_pf_addr3); + } +} + +/* PHY functions */ + +int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + u16 value; + int ret; + + ret = et131x_phy_mii_read(adapter, phy_addr, reg, &value); + + if (ret < 0) + return ret; + else + return value; +} + +int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + + return et131x_mii_write(adapter, reg, value); +} + +int et131x_mdio_reset(struct mii_bus *bus) +{ + struct net_device *netdev = bus->priv; + struct et131x_adapter *adapter = netdev_priv(netdev); + + et131x_mii_write(adapter, MII_BMCR, BMCR_RESET); + + return 0; +} + +int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) +{ + struct phy_device *phydev = adapter->phydev; + + if (!phydev) + return -EIO; + + return et131x_phy_mii_read(adapter, phydev->addr, reg, value); +} + +/** + * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC + * @adapter: pointer to our private adapter structure + * @addr: the address of the transceiver + * @reg: the register to read + * @value: pointer to a 16-bit value in which the value will be stored + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, + u8 reg, u16 *value) +{ + struct mac_regs __iomem *mac = &adapter->regs->mac; + int status = 0; + u32 delay = 0; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; + + /* Save a local copy of the registers we are dealing with so we can + * set them back + */ + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); + + /* Stop the current operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* Set up the register we need to read from on the correct PHY */ + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + + writel(0x1, &mac->mii_mgmt_cmd); + + do { + udelay(50); + delay++; + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_WAIT) && delay < 50); + + /* If we hit the max delay, we could not read the register */ + if (delay == 50) { + dev_warn(&adapter->pdev->dev, + "reg 0x%08x could not be read\n", reg); + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", + mii_indicator); + + status = -EIO; + } + + /* If we hit here we were able to read the register and we need to + * return the value to the caller */ + *value = readl(&mac->mii_mgmt_stat) & 0xFFFF; + + /* Stop the read operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* set the registers we touched back to the state at which we entered + * this function + */ + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); + + return status; +} + +/** + * et131x_mii_write - Write to a PHY register through the MII interface of the MAC + * @adapter: pointer to our private adapter structure + * @reg: the register to read + * @value: 16-bit value to write + * + * FIXME: one caller in netdev still + * + * Return 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) +{ + struct mac_regs __iomem *mac = &adapter->regs->mac; + struct phy_device *phydev = adapter->phydev; + int status = 0; + u8 addr; + u32 delay = 0; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; + + if (!phydev) + return -EIO; + + addr = phydev->addr; + + /* Save a local copy of the registers we are dealing with so we can + * set them back + */ + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); + + /* Stop the current operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* Set up the register we need to write to on the correct PHY */ + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + + /* Add the value to write to the registers to the mac */ + writel(value, &mac->mii_mgmt_ctrl); + + do { + udelay(50); + delay++; + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_BUSY) && delay < 100); + + /* If we hit the max delay, we could not write the register */ + if (delay == 100) { + u16 tmp; + + dev_warn(&adapter->pdev->dev, + "reg 0x%08x could not be written", reg); + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", + mii_indicator); + dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", + readl(&mac->mii_mgmt_cmd)); + + et131x_mii_read(adapter, reg, &tmp); + + status = -EIO; + } + /* Stop the write operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* + * set the registers we touched back to the state at which we entered + * this function + */ + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); + + return status; +} + +/** + * et1310_phy_power_down - PHY power control + * @adapter: device to control + * @down: true for off/false for back on + * + * one hundred, ten, one thousand megs + * How would you like to have your LAN accessed + * Can't you see that this code processed + * Phy power, phy power.. + */ +void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) +{ + u16 data; + + et131x_mii_read(adapter, MII_BMCR, &data); + data &= ~BMCR_PDOWN; + if (down) + data |= BMCR_PDOWN; + et131x_mii_write(adapter, MII_BMCR, data); +} + +/* Still used from _mac for BIT_READ */ +void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, + u16 regnum, u16 bitnum, u8 *value) +{ + u16 reg; + u16 mask = 0x0001 << bitnum; + + /* Read the requested register */ + et131x_mii_read(adapter, regnum, ®); + + switch (action) { + case TRUEPHY_BIT_READ: + *value = (reg & mask) >> bitnum; + break; + + case TRUEPHY_BIT_SET: + et131x_mii_write(adapter, regnum, reg | mask); + break; + + case TRUEPHY_BIT_CLEAR: + et131x_mii_write(adapter, regnum, reg & ~mask); + break; + + default: + break; + } +} + +/** + * et131x_xcvr_init - Init the phy if we are setting it into force mode + * @adapter: pointer to our private adapter structure + * + */ +void et131x_xcvr_init(struct et131x_adapter *adapter) +{ + u16 imr; + u16 isr; + u16 lcr2; + + et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &isr); + et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &imr); + + /* Set the link status interrupt only. Bad behavior when link status + * and auto neg are set, we run into a nested interrupt problem + */ + imr |= (ET_PHY_INT_MASK_AUTONEGSTAT & + ET_PHY_INT_MASK_LINKSTAT & + ET_PHY_INT_MASK_ENABLE); + + et131x_mii_write(adapter, PHY_INTERRUPT_MASK, imr); + + /* Set the LED behavior such that LED 1 indicates speed (off = + * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates + * link and activity (on for link, blink off for activity). + * + * NOTE: Some customizations have been added here for specific + * vendors; The LED behavior is now determined by vendor data in the + * EEPROM. However, the above description is the default. + */ + if ((adapter->eeprom_data[1] & 0x4) == 0) { + et131x_mii_read(adapter, PHY_LED_2, &lcr2); + + lcr2 &= (ET_LED2_LED_100TX & ET_LED2_LED_1000T); + lcr2 |= (LED_VAL_LINKON_ACTIVE << LED_LINK_SHIFT); + + if ((adapter->eeprom_data[1] & 0x8) == 0) + lcr2 |= (LED_VAL_1000BT_100BTX << LED_TXRX_SHIFT); + else + lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); + + et131x_mii_write(adapter, PHY_LED_2, lcr2); + } +} + +/* PM functions */ + +/** + * et1310_in_phy_coma - check if the device is in phy coma + * @adapter: pointer to our adapter structure + * + * Returns 0 if the device is not in phy coma, 1 if it is in phy coma + */ +int et1310_in_phy_coma(struct et131x_adapter *adapter) +{ + u32 pmcsr; + + pmcsr = readl(&adapter->regs->global.pm_csr); + + return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; +} + +/** + * et1310_enable_phy_coma - called when network cable is unplugged + * @adapter: pointer to our adapter structure + * + * driver receive an phy status change interrupt while in D0 and check that + * phy_status is down. + * + * -- gate off JAGCore; + * -- set gigE PHY in Coma mode + * -- wake on phy_interrupt; Perform software reset JAGCore, + * re-initialize jagcore and gigE PHY + * + * Add D0-ASPM-PhyLinkDown Support: + * -- while in D0, when there is a phy_interrupt indicating phy link + * down status, call the MPSetPhyComa routine to enter this active + * state power saving mode + * -- while in D0-ASPM-PhyLinkDown mode, when there is a phy_interrupt + * indicating linkup status, call the MPDisablePhyComa routine to + * restore JAGCore and gigE PHY + */ +void et1310_enable_phy_coma(struct et131x_adapter *adapter) +{ + unsigned long flags; + u32 pmcsr; + + pmcsr = readl(&adapter->regs->global.pm_csr); + + /* Save the GbE PHY speed and duplex modes. Need to restore this + * when cable is plugged back in + */ + /* + * TODO - when PM is re-enabled, check if we need to + * perform a similar task as this - + * adapter->pdown_speed = adapter->ai_force_speed; + * adapter->pdown_duplex = adapter->ai_force_duplex; + */ + + /* Stop sending packets. */ + spin_lock_irqsave(&adapter->send_hw_lock, flags); + adapter->flags |= fMP_ADAPTER_LOWER_POWER; + spin_unlock_irqrestore(&adapter->send_hw_lock, flags); + + /* Wait for outstanding Receive packets */ + + et131x_disable_txrx(adapter->netdev); + + /* Gate off JAGCore 3 clock domains */ + pmcsr &= ~ET_PMCSR_INIT; + writel(pmcsr, &adapter->regs->global.pm_csr); + + /* Program gigE PHY in to Coma mode */ + pmcsr |= ET_PM_PHY_SW_COMA; + writel(pmcsr, &adapter->regs->global.pm_csr); +} + +/** + * et1310_disable_phy_coma - Disable the Phy Coma Mode + * @adapter: pointer to our adapter structure + */ +void et1310_disable_phy_coma(struct et131x_adapter *adapter) +{ + u32 pmcsr; + + pmcsr = readl(&adapter->regs->global.pm_csr); + + /* Disable phy_sw_coma register and re-enable JAGCore clocks */ + pmcsr |= ET_PMCSR_INIT; + pmcsr &= ~ET_PM_PHY_SW_COMA; + writel(pmcsr, &adapter->regs->global.pm_csr); + + /* Restore the GbE PHY speed and duplex modes; + * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY + */ + /* TODO - when PM is re-enabled, check if we need to + * perform a similar task as this - + * adapter->ai_force_speed = adapter->pdown_speed; + * adapter->ai_force_duplex = adapter->pdown_duplex; + */ + + /* Re-initialize the send structures */ + et131x_init_send(adapter); + + /* Reset the RFD list and re-start RU */ + et131x_reset_recv(adapter); + + /* Bring the device back to the state it was during init prior to + * autonegotiation being complete. This way, when we get the auto-neg + * complete interrupt, we can complete init by calling ConfigMacREGS2. + */ + et131x_soft_reset(adapter); + + /* setup et1310 as per the documentation ?? */ + et131x_adapter_setup(adapter); + + /* Allow Tx to restart */ + adapter->flags &= ~fMP_ADAPTER_LOWER_POWER; + + et131x_enable_txrx(adapter->netdev); +} + +/* RX functions */ + +static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) +{ + u32 tmp_free_buff_ring = *free_buff_ring; + tmp_free_buff_ring++; + /* This works for all cases where limit < 1024. The 1023 case + works because 1023++ is 1024 which means the if condition is not + taken but the carry of the bit into the wrap bit toggles the wrap + value correctly */ + if ((tmp_free_buff_ring & ET_DMA10_MASK) > limit) { + tmp_free_buff_ring &= ~ET_DMA10_MASK; + tmp_free_buff_ring ^= ET_DMA10_WRAP; + } + /* For the 1023 case */ + tmp_free_buff_ring &= (ET_DMA10_MASK|ET_DMA10_WRAP); + *free_buff_ring = tmp_free_buff_ring; + return tmp_free_buff_ring; +} + +/** + * et131x_rx_dma_memory_alloc + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success and errno on failure (as defined in errno.h) + * + * Allocates Free buffer ring 1 for sure, free buffer ring 0 if required, + * and the Packet Status Ring. + */ +int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) +{ + u32 i, j; + u32 bufsize; + u32 pktstat_ringsize, fbr_chunksize; + struct rx_ring *rx_ring; + + /* Setup some convenience pointers */ + rx_ring = &adapter->rx_ring; + + /* Alloc memory for the lookup table */ +#ifdef USE_FBR0 + rx_ring->fbr[0] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); +#endif + rx_ring->fbr[1] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); + + /* The first thing we will do is configure the sizes of the buffer + * rings. These will change based on jumbo packet support. Larger + * jumbo packets increases the size of each entry in FBR0, and the + * number of entries in FBR0, while at the same time decreasing the + * number of entries in FBR1. + * + * FBR1 holds "large" frames, FBR0 holds "small" frames. If FBR1 + * entries are huge in order to accommodate a "jumbo" frame, then it + * will have less entries. Conversely, FBR1 will now be relied upon + * to carry more "normal" frames, thus it's entry size also increases + * and the number of entries goes up too (since it now carries + * "small" + "regular" packets. + * + * In this scheme, we try to maintain 512 entries between the two + * rings. Also, FBR1 remains a constant size - when it's size doubles + * the number of entries halves. FBR0 increases in size, however. + */ + + if (adapter->registry_jumbo_packet < 2048) { +#ifdef USE_FBR0 + rx_ring->fbr0_buffsize = 256; + rx_ring->fbr0_num_entries = 512; +#endif + rx_ring->fbr1_buffsize = 2048; + rx_ring->fbr1_num_entries = 512; + } else if (adapter->registry_jumbo_packet < 4096) { +#ifdef USE_FBR0 + rx_ring->fbr0_buffsize = 512; + rx_ring->fbr0_num_entries = 1024; +#endif + rx_ring->fbr1_buffsize = 4096; + rx_ring->fbr1_num_entries = 512; + } else { +#ifdef USE_FBR0 + rx_ring->fbr0_buffsize = 1024; + rx_ring->fbr0_num_entries = 768; +#endif + rx_ring->fbr1_buffsize = 16384; + rx_ring->fbr1_num_entries = 128; + } + +#ifdef USE_FBR0 + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr0_num_entries + + adapter->rx_ring.fbr1_num_entries; +#else + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr1_num_entries; +#endif + + /* Allocate an area of memory for Free Buffer Ring 1 */ + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff; + rx_ring->fbr1_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize, + &rx_ring->fbr1_ring_physaddr); + if (!rx_ring->fbr1_ring_virtaddr) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Free Buffer Ring 1\n"); + return -ENOMEM; + } + + /* Save physical address + * + * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here + * before storing the adjusted address. + */ + rx_ring->fbr1_real_physaddr = rx_ring->fbr1_ring_physaddr; + + /* Align Free Buffer Ring 1 on a 4K boundary */ + et131x_align_allocated_memory(adapter, + &rx_ring->fbr1_real_physaddr, + &rx_ring->fbr1_offset, 0x0FFF); + + rx_ring->fbr1_ring_virtaddr = + (void *)((u8 *) rx_ring->fbr1_ring_virtaddr + + rx_ring->fbr1_offset); + +#ifdef USE_FBR0 + /* Allocate an area of memory for Free Buffer Ring 0 */ + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff; + rx_ring->fbr0_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize, + &rx_ring->fbr0_ring_physaddr); + if (!rx_ring->fbr0_ring_virtaddr) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Free Buffer Ring 0\n"); + return -ENOMEM; + } + + /* Save physical address + * + * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here before + * storing the adjusted address. + */ + rx_ring->fbr0_real_physaddr = rx_ring->fbr0_ring_physaddr; + + /* Align Free Buffer Ring 0 on a 4K boundary */ + et131x_align_allocated_memory(adapter, + &rx_ring->fbr0_real_physaddr, + &rx_ring->fbr0_offset, 0x0FFF); + + rx_ring->fbr0_ring_virtaddr = + (void *)((u8 *) rx_ring->fbr0_ring_virtaddr + + rx_ring->fbr0_offset); +#endif + for (i = 0; i < (rx_ring->fbr1_num_entries / FBR_CHUNKS); i++) { + u64 fbr1_offset; + u64 fbr1_tmp_physaddr; + u32 fbr1_align; + + /* This code allocates an area of memory big enough for N + * free buffers + (buffer_size - 1) so that the buffers can + * be aligned on 4k boundaries. If each buffer were aligned + * to a buffer_size boundary, the effect would be to double + * the size of FBR0. By allocating N buffers at once, we + * reduce this overhead. + */ + if (rx_ring->fbr1_buffsize > 4096) + fbr1_align = 4096; + else + fbr1_align = rx_ring->fbr1_buffsize; + + fbr_chunksize = + (FBR_CHUNKS * rx_ring->fbr1_buffsize) + fbr1_align - 1; + rx_ring->fbr1_mem_virtaddrs[i] = + pci_alloc_consistent(adapter->pdev, fbr_chunksize, + &rx_ring->fbr1_mem_physaddrs[i]); + + if (!rx_ring->fbr1_mem_virtaddrs[i]) { + dev_err(&adapter->pdev->dev, + "Could not alloc memory\n"); + return -ENOMEM; + } + + /* See NOTE in "Save Physical Address" comment above */ + fbr1_tmp_physaddr = rx_ring->fbr1_mem_physaddrs[i]; + + et131x_align_allocated_memory(adapter, + &fbr1_tmp_physaddr, + &fbr1_offset, (fbr1_align - 1)); + + for (j = 0; j < FBR_CHUNKS; j++) { + u32 index = (i * FBR_CHUNKS) + j; + + /* Save the Virtual address of this index for quick + * access later + */ + rx_ring->fbr[1]->virt[index] = + (u8 *) rx_ring->fbr1_mem_virtaddrs[i] + + (j * rx_ring->fbr1_buffsize) + fbr1_offset; + + /* now store the physical address in the descriptor + * so the device can access it + */ + rx_ring->fbr[1]->bus_high[index] = + (u32) (fbr1_tmp_physaddr >> 32); + rx_ring->fbr[1]->bus_low[index] = + (u32) fbr1_tmp_physaddr; + + fbr1_tmp_physaddr += rx_ring->fbr1_buffsize; + + rx_ring->fbr[1]->buffer1[index] = + rx_ring->fbr[1]->virt[index]; + rx_ring->fbr[1]->buffer2[index] = + rx_ring->fbr[1]->virt[index] - 4; + } + } + +#ifdef USE_FBR0 + /* Same for FBR0 (if in use) */ + for (i = 0; i < (rx_ring->fbr0_num_entries / FBR_CHUNKS); i++) { + u64 fbr0_offset; + u64 fbr0_tmp_physaddr; + + fbr_chunksize = + ((FBR_CHUNKS + 1) * rx_ring->fbr0_buffsize) - 1; + rx_ring->fbr0_mem_virtaddrs[i] = + pci_alloc_consistent(adapter->pdev, fbr_chunksize, + &rx_ring->fbr0_mem_physaddrs[i]); + + if (!rx_ring->fbr0_mem_virtaddrs[i]) { + dev_err(&adapter->pdev->dev, + "Could not alloc memory\n"); + return -ENOMEM; + } + + /* See NOTE in "Save Physical Address" comment above */ + fbr0_tmp_physaddr = rx_ring->fbr0_mem_physaddrs[i]; + + et131x_align_allocated_memory(adapter, + &fbr0_tmp_physaddr, + &fbr0_offset, + rx_ring->fbr0_buffsize - 1); + + for (j = 0; j < FBR_CHUNKS; j++) { + u32 index = (i * FBR_CHUNKS) + j; + + rx_ring->fbr[0]->virt[index] = + (u8 *) rx_ring->fbr0_mem_virtaddrs[i] + + (j * rx_ring->fbr0_buffsize) + fbr0_offset; + + rx_ring->fbr[0]->bus_high[index] = + (u32) (fbr0_tmp_physaddr >> 32); + rx_ring->fbr[0]->bus_low[index] = + (u32) fbr0_tmp_physaddr; + + fbr0_tmp_physaddr += rx_ring->fbr0_buffsize; + + rx_ring->fbr[0]->buffer1[index] = + rx_ring->fbr[0]->virt[index]; + rx_ring->fbr[0]->buffer2[index] = + rx_ring->fbr[0]->virt[index] - 4; + } + } +#endif + + /* Allocate an area of memory for FIFO of Packet Status ring entries */ + pktstat_ringsize = + sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries; + + rx_ring->ps_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + pktstat_ringsize, + &rx_ring->ps_ring_physaddr); + + if (!rx_ring->ps_ring_virtaddr) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Packet Status Ring\n"); + return -ENOMEM; + } + printk(KERN_INFO "Packet Status Ring %lx\n", + (unsigned long) rx_ring->ps_ring_physaddr); + + /* + * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here before + * storing the adjusted address. + */ + + /* Allocate an area of memory for writeback of status information */ + rx_ring->rx_status_block = pci_alloc_consistent(adapter->pdev, + sizeof(struct rx_status_block), + &rx_ring->rx_status_bus); + if (!rx_ring->rx_status_block) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Status Block\n"); + return -ENOMEM; + } + rx_ring->num_rfd = NIC_DEFAULT_NUM_RFD; + printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); + + /* Recv + * pci_pool_create initializes a lookaside list. After successful + * creation, nonpaged fixed-size blocks can be allocated from and + * freed to the lookaside list. + * RFDs will be allocated from this pool. + */ + rx_ring->recv_lookaside = kmem_cache_create(adapter->netdev->name, + sizeof(struct rfd), + 0, + SLAB_CACHE_DMA | + SLAB_HWCACHE_ALIGN, + NULL); + + adapter->flags |= fMP_ADAPTER_RECV_LOOKASIDE; + + /* The RFDs are going to be put on lists later on, so initialize the + * lists now. + */ + INIT_LIST_HEAD(&rx_ring->recv_list); + return 0; +} + +/** + * et131x_rx_dma_memory_free - Free all memory allocated within this module. + * @adapter: pointer to our private adapter structure + */ +void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) +{ + u32 index; + u32 bufsize; + u32 pktstat_ringsize; + struct rfd *rfd; + struct rx_ring *rx_ring; + + /* Setup some convenience pointers */ + rx_ring = &adapter->rx_ring; + + /* Free RFDs and associated packet descriptors */ + WARN_ON(rx_ring->num_ready_recv != rx_ring->num_rfd); + + while (!list_empty(&rx_ring->recv_list)) { + rfd = (struct rfd *) list_entry(rx_ring->recv_list.next, + struct rfd, list_node); + + list_del(&rfd->list_node); + rfd->skb = NULL; + kmem_cache_free(adapter->rx_ring.recv_lookaside, rfd); + } + + /* Free Free Buffer Ring 1 */ + if (rx_ring->fbr1_ring_virtaddr) { + /* First the packet memory */ + for (index = 0; index < + (rx_ring->fbr1_num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr1_mem_virtaddrs[index]) { + u32 fbr1_align; + + if (rx_ring->fbr1_buffsize > 4096) + fbr1_align = 4096; + else + fbr1_align = rx_ring->fbr1_buffsize; + + bufsize = + (rx_ring->fbr1_buffsize * FBR_CHUNKS) + + fbr1_align - 1; + + pci_free_consistent(adapter->pdev, + bufsize, + rx_ring->fbr1_mem_virtaddrs[index], + rx_ring->fbr1_mem_physaddrs[index]); + + rx_ring->fbr1_mem_virtaddrs[index] = NULL; + } + } + + /* Now the FIFO itself */ + rx_ring->fbr1_ring_virtaddr = (void *)((u8 *) + rx_ring->fbr1_ring_virtaddr - rx_ring->fbr1_offset); + + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + + 0xfff; + + pci_free_consistent(adapter->pdev, bufsize, + rx_ring->fbr1_ring_virtaddr, + rx_ring->fbr1_ring_physaddr); + + rx_ring->fbr1_ring_virtaddr = NULL; + } + +#ifdef USE_FBR0 + /* Now the same for Free Buffer Ring 0 */ + if (rx_ring->fbr0_ring_virtaddr) { + /* First the packet memory */ + for (index = 0; index < + (rx_ring->fbr0_num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr0_mem_virtaddrs[index]) { + bufsize = + (rx_ring->fbr0_buffsize * + (FBR_CHUNKS + 1)) - 1; + + pci_free_consistent(adapter->pdev, + bufsize, + rx_ring->fbr0_mem_virtaddrs[index], + rx_ring->fbr0_mem_physaddrs[index]); + + rx_ring->fbr0_mem_virtaddrs[index] = NULL; + } + } + + /* Now the FIFO itself */ + rx_ring->fbr0_ring_virtaddr = (void *)((u8 *) + rx_ring->fbr0_ring_virtaddr - rx_ring->fbr0_offset); + + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + + 0xfff; + + pci_free_consistent(adapter->pdev, + bufsize, + rx_ring->fbr0_ring_virtaddr, + rx_ring->fbr0_ring_physaddr); + + rx_ring->fbr0_ring_virtaddr = NULL; + } +#endif + + /* Free Packet Status Ring */ + if (rx_ring->ps_ring_virtaddr) { + pktstat_ringsize = + sizeof(struct pkt_stat_desc) * + adapter->rx_ring.psr_num_entries; + + pci_free_consistent(adapter->pdev, pktstat_ringsize, + rx_ring->ps_ring_virtaddr, + rx_ring->ps_ring_physaddr); + + rx_ring->ps_ring_virtaddr = NULL; + } + + /* Free area of memory for the writeback of status information */ + if (rx_ring->rx_status_block) { + pci_free_consistent(adapter->pdev, + sizeof(struct rx_status_block), + rx_ring->rx_status_block, rx_ring->rx_status_bus); + rx_ring->rx_status_block = NULL; + } + + /* Free receive buffer pool */ + + /* Free receive packet pool */ + + /* Destroy the lookaside (RFD) pool */ + if (adapter->flags & fMP_ADAPTER_RECV_LOOKASIDE) { + kmem_cache_destroy(rx_ring->recv_lookaside); + adapter->flags &= ~fMP_ADAPTER_RECV_LOOKASIDE; + } + + /* Free the FBR Lookup Table */ +#ifdef USE_FBR0 + kfree(rx_ring->fbr[0]); +#endif + + kfree(rx_ring->fbr[1]); + + /* Reset Counters */ + rx_ring->num_ready_recv = 0; +} + +/** + * et131x_init_recv - Initialize receive data structures. + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success and errno on failure (as defined in errno.h) + */ +int et131x_init_recv(struct et131x_adapter *adapter) +{ + int status = -ENOMEM; + struct rfd *rfd = NULL; + u32 rfdct; + u32 numrfd = 0; + struct rx_ring *rx_ring; + + /* Setup some convenience pointers */ + rx_ring = &adapter->rx_ring; + + /* Setup each RFD */ + for (rfdct = 0; rfdct < rx_ring->num_rfd; rfdct++) { + rfd = kmem_cache_alloc(rx_ring->recv_lookaside, + GFP_ATOMIC | GFP_DMA); + + if (!rfd) { + dev_err(&adapter->pdev->dev, + "Couldn't alloc RFD out of kmem_cache\n"); + status = -ENOMEM; + continue; + } + + rfd->skb = NULL; + + /* Add this RFD to the recv_list */ + list_add_tail(&rfd->list_node, &rx_ring->recv_list); + + /* Increment both the available RFD's, and the total RFD's. */ + rx_ring->num_ready_recv++; + numrfd++; + } + + if (numrfd > NIC_MIN_NUM_RFD) + status = 0; + + rx_ring->num_rfd = numrfd; + + if (status != 0) { + kmem_cache_free(rx_ring->recv_lookaside, rfd); + dev_err(&adapter->pdev->dev, + "Allocation problems in et131x_init_recv\n"); + } + return status; +} + +/** + * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence + * @adapter: pointer to our adapter structure + */ +void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) +{ + struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; + struct rx_ring *rx_local = &adapter->rx_ring; + struct fbr_desc *fbr_entry; + u32 entry; + u32 psr_num_des; + unsigned long flags; + + /* Halt RXDMA to perform the reconfigure. */ + et131x_rx_dma_disable(adapter); + + /* Load the completion writeback physical address + * + * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here + * before storing the adjusted address. + */ + writel((u32) ((u64)rx_local->rx_status_bus >> 32), + &rx_dma->dma_wb_base_hi); + writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo); + + memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block)); + + /* Set the address and parameters of the packet status ring into the + * 1310's registers + */ + writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32), + &rx_dma->psr_base_hi); + writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo); + writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); + writel(0, &rx_dma->psr_full_offset); + + psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; + writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, + &rx_dma->psr_min_des); + + spin_lock_irqsave(&adapter->rcv_lock, flags); + + /* These local variables track the PSR in the adapter structure */ + rx_local->local_psr_full = 0; + + /* Now's the best time to initialize FBR1 contents */ + fbr_entry = (struct fbr_desc *) rx_local->fbr1_ring_virtaddr; + for (entry = 0; entry < rx_local->fbr1_num_entries; entry++) { + fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; + fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; + fbr_entry->word2 = entry; + fbr_entry++; + } + + /* Set the address and parameters of Free buffer ring 1 (and 0 if + * required) into the 1310's registers + */ + writel((u32) (rx_local->fbr1_real_physaddr >> 32), + &rx_dma->fbr1_base_hi); + writel((u32) rx_local->fbr1_real_physaddr, &rx_dma->fbr1_base_lo); + writel(rx_local->fbr1_num_entries - 1, &rx_dma->fbr1_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); + + /* This variable tracks the free buffer ring 1 full position, so it + * has to match the above. + */ + rx_local->local_fbr1_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr1_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr1_min_des); + +#ifdef USE_FBR0 + /* Now's the best time to initialize FBR0 contents */ + fbr_entry = (struct fbr_desc *) rx_local->fbr0_ring_virtaddr; + for (entry = 0; entry < rx_local->fbr0_num_entries; entry++) { + fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; + fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; + fbr_entry->word2 = entry; + fbr_entry++; + } + + writel((u32) (rx_local->fbr0_real_physaddr >> 32), + &rx_dma->fbr0_base_hi); + writel((u32) rx_local->fbr0_real_physaddr, &rx_dma->fbr0_base_lo); + writel(rx_local->fbr0_num_entries - 1, &rx_dma->fbr0_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); + + /* This variable tracks the free buffer ring 0 full position, so it + * has to match the above. + */ + rx_local->local_fbr0_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr0_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr0_min_des); +#endif + + /* Program the number of packets we will receive before generating an + * interrupt. + * For version B silicon, this value gets updated once autoneg is + *complete. + */ + writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done); + + /* The "time_done" is not working correctly to coalesce interrupts + * after a given time period, but rather is giving us an interrupt + * regardless of whether we have received packets. + * This value gets updated once autoneg is complete. + */ + writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time); + + spin_unlock_irqrestore(&adapter->rcv_lock, flags); +} + +/** + * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. + * @adapter: pointer to our adapter structure + */ +void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) +{ + struct phy_device *phydev = adapter->phydev; + + if (!phydev) + return; + + /* For version B silicon, we do not use the RxDMA timer for 10 and 100 + * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. + */ + if ((phydev->speed == SPEED_100) || (phydev->speed == SPEED_10)) { + writel(0, &adapter->regs->rxdma.max_pkt_time); + writel(1, &adapter->regs->rxdma.num_pkt_done); + } +} + +/** + * NICReturnRFD - Recycle a RFD and put it back onto the receive list + * @adapter: pointer to our adapter + * @rfd: pointer to the RFD + */ +static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) +{ + struct rx_ring *rx_local = &adapter->rx_ring; + struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; + u16 buff_index = rfd->bufferindex; + u8 ring_index = rfd->ringindex; + unsigned long flags; + + /* We don't use any of the OOB data besides status. Otherwise, we + * need to clean up OOB data + */ + if ( +#ifdef USE_FBR0 + (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || +#endif + (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { + spin_lock_irqsave(&adapter->fbr_lock, flags); + + if (ring_index == 1) { + struct fbr_desc *next = + (struct fbr_desc *) (rx_local->fbr1_ring_virtaddr) + + INDEX10(rx_local->local_fbr1_full); + + /* Handle the Free Buffer Ring advancement here. Write + * the PA / Buffer Index for the returned buffer into + * the oldest (next to be freed)FBR entry + */ + next->addr_hi = rx_local->fbr[1]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; + next->word2 = buff_index; + + writel(bump_free_buff_ring(&rx_local->local_fbr1_full, + rx_local->fbr1_num_entries - 1), + &rx_dma->fbr1_full_offset); + } +#ifdef USE_FBR0 + else { + struct fbr_desc *next = (struct fbr_desc *) + rx_local->fbr0_ring_virtaddr + + INDEX10(rx_local->local_fbr0_full); + + /* Handle the Free Buffer Ring advancement here. Write + * the PA / Buffer Index for the returned buffer into + * the oldest (next to be freed) FBR entry + */ + next->addr_hi = rx_local->fbr[0]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; + next->word2 = buff_index; + + writel(bump_free_buff_ring(&rx_local->local_fbr0_full, + rx_local->fbr0_num_entries - 1), + &rx_dma->fbr0_full_offset); + } +#endif + spin_unlock_irqrestore(&adapter->fbr_lock, flags); + } else { + dev_err(&adapter->pdev->dev, + "%s illegal Buffer Index returned\n", __func__); + } + + /* The processing on this RFD is done, so put it back on the tail of + * our list + */ + spin_lock_irqsave(&adapter->rcv_lock, flags); + list_add_tail(&rfd->list_node, &rx_local->recv_list); + rx_local->num_ready_recv++; + spin_unlock_irqrestore(&adapter->rcv_lock, flags); + + WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); +} + +/** + * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 + * @adapter: pointer to our adapter structure + */ +void et131x_rx_dma_disable(struct et131x_adapter *adapter) +{ + u32 csr; + /* Setup the receive dma configuration register */ + writel(0x00002001, &adapter->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ + udelay(5); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) == 0) + dev_err(&adapter->pdev->dev, + "RX Dma failed to enter halt state. CSR 0x%08x\n", + csr); + } +} + +/** + * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. + * @adapter: pointer to our adapter structure + */ +void et131x_rx_dma_enable(struct et131x_adapter *adapter) +{ + /* Setup the receive dma configuration register for normal operation */ + u32 csr = 0x2000; /* FBR1 enable */ + + if (adapter->rx_ring.fbr1_buffsize == 4096) + csr |= 0x0800; + else if (adapter->rx_ring.fbr1_buffsize == 8192) + csr |= 0x1000; + else if (adapter->rx_ring.fbr1_buffsize == 16384) + csr |= 0x1800; +#ifdef USE_FBR0 + csr |= 0x0400; /* FBR0 enable */ + if (adapter->rx_ring.fbr0_buffsize == 256) + csr |= 0x0100; + else if (adapter->rx_ring.fbr0_buffsize == 512) + csr |= 0x0200; + else if (adapter->rx_ring.fbr0_buffsize == 1024) + csr |= 0x0300; +#endif + writel(csr, &adapter->regs->rxdma.csr); + + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) != 0) { + udelay(5); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) != 0) { + dev_err(&adapter->pdev->dev, + "RX Dma failed to exit halt state. CSR 0x%08x\n", + csr); + } + } +} + +/** + * nic_rx_pkts - Checks the hardware for available packets + * @adapter: pointer to our adapter + * + * Returns rfd, a pointer to our MPRFD. + * + * Checks the hardware for available packets, using completion ring + * If packets are available, it gets an RFD from the recv_list, attaches + * the packet to it, puts the RFD in the RecvPendList, and also returns + * the pointer to the RFD. + */ +static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) +{ + struct rx_ring *rx_local = &adapter->rx_ring; + struct rx_status_block *status; + struct pkt_stat_desc *psr; + struct rfd *rfd; + u32 i; + u8 *buf; + unsigned long flags; + struct list_head *element; + u8 ring_index; + u16 buff_index; + u32 len; + u32 word0; + u32 word1; + + /* RX Status block is written by the DMA engine prior to every + * interrupt. It contains the next to be used entry in the Packet + * Status Ring, and also the two Free Buffer rings. + */ + status = rx_local->rx_status_block; + word1 = status->word1 >> 16; /* Get the useful bits */ + + /* Check the PSR and wrap bits do not match */ + if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF)) + /* Looks like this ring is not updated yet */ + return NULL; + + /* The packet status ring indicates that data is available. */ + psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) + + (rx_local->local_psr_full & 0xFFF); + + /* Grab any information that is required once the PSR is + * advanced, since we can no longer rely on the memory being + * accurate + */ + len = psr->word1 & 0xFFFF; + ring_index = (psr->word1 >> 26) & 0x03; + buff_index = (psr->word1 >> 16) & 0x3FF; + word0 = psr->word0; + + /* Indicate that we have used this PSR entry. */ + /* FIXME wrap 12 */ + add_12bit(&rx_local->local_psr_full, 1); + if ( + (rx_local->local_psr_full & 0xFFF) > rx_local->psr_num_entries - 1) { + /* Clear psr full and toggle the wrap bit */ + rx_local->local_psr_full &= ~0xFFF; + rx_local->local_psr_full ^= 0x1000; + } + + writel(rx_local->local_psr_full, + &adapter->regs->rxdma.psr_full_offset); + +#ifndef USE_FBR0 + if (ring_index != 1) + return NULL; +#endif + +#ifdef USE_FBR0 + if (ring_index > 1 || + (ring_index == 0 && + buff_index > rx_local->fbr0_num_entries - 1) || + (ring_index == 1 && + buff_index > rx_local->fbr1_num_entries - 1)) +#else + if (ring_index != 1 || buff_index > rx_local->fbr1_num_entries - 1) +#endif + { + /* Illegal buffer or ring index cannot be used by S/W*/ + dev_err(&adapter->pdev->dev, + "NICRxPkts PSR Entry %d indicates " + "length of %d and/or bad bi(%d)\n", + rx_local->local_psr_full & 0xFFF, + len, buff_index); + return NULL; + } + + /* Get and fill the RFD. */ + spin_lock_irqsave(&adapter->rcv_lock, flags); + + rfd = NULL; + element = rx_local->recv_list.next; + rfd = (struct rfd *) list_entry(element, struct rfd, list_node); + + if (rfd == NULL) { + spin_unlock_irqrestore(&adapter->rcv_lock, flags); + return NULL; + } + + list_del(&rfd->list_node); + rx_local->num_ready_recv--; + + spin_unlock_irqrestore(&adapter->rcv_lock, flags); + + rfd->bufferindex = buff_index; + rfd->ringindex = ring_index; + + /* In V1 silicon, there is a bug which screws up filtering of + * runt packets. Therefore runt packet filtering is disabled + * in the MAC and the packets are dropped here. They are + * also counted here. + */ + if (len < (NIC_MIN_PACKET_SIZE + 4)) { + adapter->stats.rx_other_errs++; + len = 0; + } + + if (len) { + /* Determine if this is a multicast packet coming in */ + if ((word0 & ALCATEL_MULTICAST_PKT) && + !(word0 & ALCATEL_BROADCAST_PKT)) { + /* Promiscuous mode and Multicast mode are + * not mutually exclusive as was first + * thought. I guess Promiscuous is just + * considered a super-set of the other + * filters. Generally filter is 0x2b when in + * promiscuous mode. + */ + if ((adapter->packet_filter & + ET131X_PACKET_TYPE_MULTICAST) + && !(adapter->packet_filter & + ET131X_PACKET_TYPE_PROMISCUOUS) + && !(adapter->packet_filter & + ET131X_PACKET_TYPE_ALL_MULTICAST)) { + buf = rx_local->fbr[ring_index]-> + virt[buff_index]; + + /* Loop through our list to see if the + * destination address of this packet + * matches one in our list. + */ + for (i = 0; i < adapter->multicast_addr_count; + i++) { + if (buf[0] == + adapter->multicast_list[i][0] + && buf[1] == + adapter->multicast_list[i][1] + && buf[2] == + adapter->multicast_list[i][2] + && buf[3] == + adapter->multicast_list[i][3] + && buf[4] == + adapter->multicast_list[i][4] + && buf[5] == + adapter->multicast_list[i][5]) { + break; + } + } + + /* If our index is equal to the number + * of Multicast address we have, then + * this means we did not find this + * packet's matching address in our + * list. Set the len to zero, + * so we free our RFD when we return + * from this function. + */ + if (i == adapter->multicast_addr_count) + len = 0; + } + + if (len > 0) + adapter->stats.multicast_pkts_rcvd++; + } else if (word0 & ALCATEL_BROADCAST_PKT) + adapter->stats.broadcast_pkts_rcvd++; + else + /* Not sure what this counter measures in + * promiscuous mode. Perhaps we should check + * the MAC address to see if it is directed + * to us in promiscuous mode. + */ + adapter->stats.unicast_pkts_rcvd++; + } + + if (len > 0) { + struct sk_buff *skb = NULL; + + /*rfd->len = len - 4; */ + rfd->len = len; + + skb = dev_alloc_skb(rfd->len + 2); + if (!skb) { + dev_err(&adapter->pdev->dev, + "Couldn't alloc an SKB for Rx\n"); + return NULL; + } + + adapter->net_stats.rx_bytes += rfd->len; + + memcpy(skb_put(skb, rfd->len), + rx_local->fbr[ring_index]->virt[buff_index], + rfd->len); + + skb->dev = adapter->netdev; + skb->protocol = eth_type_trans(skb, adapter->netdev); + skb->ip_summed = CHECKSUM_NONE; + + netif_rx(skb); + } else { + rfd->len = 0; + } + + nic_return_rfd(adapter, rfd); + return rfd; +} + +/** + * et131x_reset_recv - Reset the receive list + * @adapter: pointer to our adapter + * + * Assumption, Rcv spinlock has been acquired. + */ +void et131x_reset_recv(struct et131x_adapter *adapter) +{ + WARN_ON(list_empty(&adapter->rx_ring.recv_list)); +} + +/** + * et131x_handle_recv_interrupt - Interrupt handler for receive processing + * @adapter: pointer to our adapter + * + * Assumption, Rcv spinlock has been acquired. + */ +void et131x_handle_recv_interrupt(struct et131x_adapter *adapter) +{ + struct rfd *rfd = NULL; + u32 count = 0; + bool done = true; + + /* Process up to available RFD's */ + while (count < NUM_PACKETS_HANDLED) { + if (list_empty(&adapter->rx_ring.recv_list)) { + WARN_ON(adapter->rx_ring.num_ready_recv != 0); + done = false; + break; + } + + rfd = nic_rx_pkts(adapter); + + if (rfd == NULL) + break; + + /* Do not receive any packets until a filter has been set. + * Do not receive any packets until we have link. + * If length is zero, return the RFD in order to advance the + * Free buffer ring. + */ + if (!adapter->packet_filter || + !netif_carrier_ok(adapter->netdev) || + rfd->len == 0) + continue; + + /* Increment the number of packets we received */ + adapter->net_stats.rx_packets++; + + /* Set the status on the packet, either resources or success */ + if (adapter->rx_ring.num_ready_recv < RFD_LOW_WATER_MARK) { + dev_warn(&adapter->pdev->dev, + "RFD's are running out\n"); + } + count++; + } + + if (count == NUM_PACKETS_HANDLED || !done) { + adapter->rx_ring.unfinished_receives = true; + writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, + &adapter->regs->global.watchdog_timer); + } else + /* Watchdog timer will disable itself if appropriate. */ + adapter->rx_ring.unfinished_receives = false; +} + +/* TX functions */ + +/** + * et131x_tx_dma_memory_alloc + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success and errno on failure (as defined in errno.h). + * + * Allocates memory that will be visible both to the device and to the CPU. + * The OS will pass us packets, pointers to which we will insert in the Tx + * Descriptor queue. The device will read this queue to find the packets in + * memory. The device will update the "status" in memory each time it xmits a + * packet. + */ +int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) +{ + int desc_size = 0; + struct tx_ring *tx_ring = &adapter->tx_ring; + + /* Allocate memory for the TCB's (Transmit Control Block) */ + adapter->tx_ring.tcb_ring = + kcalloc(NUM_TCB, sizeof(struct tcb), GFP_ATOMIC | GFP_DMA); + if (!adapter->tx_ring.tcb_ring) { + dev_err(&adapter->pdev->dev, "Cannot alloc memory for TCBs\n"); + return -ENOMEM; + } + + /* Allocate enough memory for the Tx descriptor ring, and allocate + * some extra so that the ring can be aligned on a 4k boundary. + */ + desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1; + tx_ring->tx_desc_ring = + (struct tx_desc *) pci_alloc_consistent(adapter->pdev, desc_size, + &tx_ring->tx_desc_ring_pa); + if (!adapter->tx_ring.tx_desc_ring) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Tx Ring\n"); + return -ENOMEM; + } + + /* Save physical address + * + * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here before + * storing the adjusted address. + */ + /* Allocate memory for the Tx status block */ + tx_ring->tx_status = pci_alloc_consistent(adapter->pdev, + sizeof(u32), + &tx_ring->tx_status_pa); + if (!adapter->tx_ring.tx_status_pa) { + dev_err(&adapter->pdev->dev, + "Cannot alloc memory for Tx status block\n"); + return -ENOMEM; + } + return 0; +} + +/** + * et131x_tx_dma_memory_free - Free all memory allocated within this module + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success and errno on failure (as defined in errno.h). + */ +void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) +{ + int desc_size = 0; + + if (adapter->tx_ring.tx_desc_ring) { + /* Free memory relating to Tx rings here */ + desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + + 4096 - 1; + pci_free_consistent(adapter->pdev, + desc_size, + adapter->tx_ring.tx_desc_ring, + adapter->tx_ring.tx_desc_ring_pa); + adapter->tx_ring.tx_desc_ring = NULL; + } + + /* Free memory for the Tx status block */ + if (adapter->tx_ring.tx_status) { + pci_free_consistent(adapter->pdev, + sizeof(u32), + adapter->tx_ring.tx_status, + adapter->tx_ring.tx_status_pa); + + adapter->tx_ring.tx_status = NULL; + } + /* Free the memory for the tcb structures */ + kfree(adapter->tx_ring.tcb_ring); +} + +/** + * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. + * @adapter: pointer to our private adapter structure + * + * Configure the transmit engine with the ring buffers we have created + * and prepare it for use. + */ +void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) +{ + struct txdma_regs __iomem *txdma = &adapter->regs->txdma; + + /* Load the hardware with the start of the transmit descriptor ring. */ + writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32), + &txdma->pr_base_hi); + writel((u32) adapter->tx_ring.tx_desc_ring_pa, + &txdma->pr_base_lo); + + /* Initialise the transmit DMA engine */ + writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des); + + /* Load the completion writeback physical address */ + writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32), + &txdma->dma_wb_base_hi); + writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); + + *adapter->tx_ring.tx_status = 0; + + writel(0, &txdma->service_request); + adapter->tx_ring.send_idx = 0; +} + +/** + * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 + * @adapter: pointer to our adapter structure + */ +void et131x_tx_dma_disable(struct et131x_adapter *adapter) +{ + /* Setup the tramsmit dma configuration register */ + writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, + &adapter->regs->txdma.csr); +} + +/** + * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. + * @adapter: pointer to our adapter structure + * + * Mainly used after a return to the D0 (full-power) state from a lower state. + */ +void et131x_tx_dma_enable(struct et131x_adapter *adapter) +{ + /* Setup the transmit dma configuration register for normal + * operation + */ + writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), + &adapter->regs->txdma.csr); +} + +/** + * et131x_init_send - Initialize send data structures + * @adapter: pointer to our private adapter structure + */ +void et131x_init_send(struct et131x_adapter *adapter) +{ + struct tcb *tcb; + u32 ct; + struct tx_ring *tx_ring; + + /* Setup some convenience pointers */ + tx_ring = &adapter->tx_ring; + tcb = adapter->tx_ring.tcb_ring; + + tx_ring->tcb_qhead = tcb; + + memset(tcb, 0, sizeof(struct tcb) * NUM_TCB); + + /* Go through and set up each TCB */ + for (ct = 0; ct++ < NUM_TCB; tcb++) + /* Set the link pointer in HW TCB to the next TCB in the + * chain + */ + tcb->next = tcb + 1; + + /* Set the tail pointer */ + tcb--; + tx_ring->tcb_qtail = tcb; + tcb->next = NULL; + /* Curr send queue should now be empty */ + tx_ring->send_head = NULL; + tx_ring->send_tail = NULL; +} + +/** + * nic_send_packet - NIC specific send handler for version B silicon. + * @adapter: pointer to our adapter + * @tcb: pointer to struct tcb + * + * Returns 0 or errno. + */ +static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) +{ + u32 i; + struct tx_desc desc[24]; /* 24 x 16 byte */ + u32 frag = 0; + u32 thiscopy, remainder; + struct sk_buff *skb = tcb->skb; + u32 nr_frags = skb_shinfo(skb)->nr_frags + 1; + struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0]; + unsigned long flags; + struct phy_device *phydev = adapter->phydev; + + /* Part of the optimizations of this send routine restrict us to + * sending 24 fragments at a pass. In practice we should never see + * more than 5 fragments. + * + * NOTE: The older version of this function (below) can handle any + * number of fragments. If needed, we can call this function, + * although it is less efficient. + */ + if (nr_frags > 23) + return -EIO; + + memset(desc, 0, sizeof(struct tx_desc) * (nr_frags + 1)); + + for (i = 0; i < nr_frags; i++) { + /* If there is something in this element, lets get a + * descriptor from the ring and get the necessary data + */ + if (i == 0) { + /* If the fragments are smaller than a standard MTU, + * then map them to a single descriptor in the Tx + * Desc ring. However, if they're larger, as is + * possible with support for jumbo packets, then + * split them each across 2 descriptors. + * + * This will work until we determine why the hardware + * doesn't seem to like large fragments. + */ + if ((skb->len - skb->data_len) <= 1514) { + desc[frag].addr_hi = 0; + /* Low 16bits are length, high is vlan and + unused currently so zero */ + desc[frag].len_vlan = + skb->len - skb->data_len; + + /* NOTE: Here, the dma_addr_t returned from + * pci_map_single() is implicitly cast as a + * u32. Although dma_addr_t can be + * 64-bit, the address returned by + * pci_map_single() is always 32-bit + * addressable (as defined by the pci/dma + * subsystem) + */ + desc[frag++].addr_lo = + pci_map_single(adapter->pdev, + skb->data, + skb->len - + skb->data_len, + PCI_DMA_TODEVICE); + } else { + desc[frag].addr_hi = 0; + desc[frag].len_vlan = + (skb->len - skb->data_len) / 2; + + /* NOTE: Here, the dma_addr_t returned from + * pci_map_single() is implicitly cast as a + * u32. Although dma_addr_t can be + * 64-bit, the address returned by + * pci_map_single() is always 32-bit + * addressable (as defined by the pci/dma + * subsystem) + */ + desc[frag++].addr_lo = + pci_map_single(adapter->pdev, + skb->data, + ((skb->len - + skb->data_len) / 2), + PCI_DMA_TODEVICE); + desc[frag].addr_hi = 0; + + desc[frag].len_vlan = + (skb->len - skb->data_len) / 2; + + /* NOTE: Here, the dma_addr_t returned from + * pci_map_single() is implicitly cast as a + * u32. Although dma_addr_t can be + * 64-bit, the address returned by + * pci_map_single() is always 32-bit + * addressable (as defined by the pci/dma + * subsystem) + */ + desc[frag++].addr_lo = + pci_map_single(adapter->pdev, + skb->data + + ((skb->len - + skb->data_len) / 2), + ((skb->len - + skb->data_len) / 2), + PCI_DMA_TODEVICE); + } + } else { + desc[frag].addr_hi = 0; + desc[frag].len_vlan = + frags[i - 1].size; + + /* NOTE: Here, the dma_addr_t returned from + * pci_map_page() is implicitly cast as a u32. + * Although dma_addr_t can be 64-bit, the address + * returned by pci_map_page() is always 32-bit + * addressable (as defined by the pci/dma subsystem) + */ + desc[frag++].addr_lo = + pci_map_page(adapter->pdev, + frags[i - 1].page, + frags[i - 1].page_offset, + frags[i - 1].size, + PCI_DMA_TODEVICE); + } + } + + if (frag == 0) + return -EIO; + + if (phydev && phydev->speed == SPEED_1000) { + if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { + /* Last element & Interrupt flag */ + desc[frag - 1].flags = 0x5; + adapter->tx_ring.since_irq = 0; + } else { /* Last element */ + desc[frag - 1].flags = 0x1; + } + } else + desc[frag - 1].flags = 0x5; + + desc[0].flags |= 2; /* First element flag */ + + tcb->index_start = adapter->tx_ring.send_idx; + tcb->stale = 0; + + spin_lock_irqsave(&adapter->send_hw_lock, flags); + + thiscopy = NUM_DESC_PER_RING_TX - + INDEX10(adapter->tx_ring.send_idx); + + if (thiscopy >= frag) { + remainder = 0; + thiscopy = frag; + } else { + remainder = frag - thiscopy; + } + + memcpy(adapter->tx_ring.tx_desc_ring + + INDEX10(adapter->tx_ring.send_idx), desc, + sizeof(struct tx_desc) * thiscopy); + + add_10bit(&adapter->tx_ring.send_idx, thiscopy); + + if (INDEX10(adapter->tx_ring.send_idx) == 0 || + INDEX10(adapter->tx_ring.send_idx) == NUM_DESC_PER_RING_TX) { + adapter->tx_ring.send_idx &= ~ET_DMA10_MASK; + adapter->tx_ring.send_idx ^= ET_DMA10_WRAP; + } + + if (remainder) { + memcpy(adapter->tx_ring.tx_desc_ring, + desc + thiscopy, + sizeof(struct tx_desc) * remainder); + + add_10bit(&adapter->tx_ring.send_idx, remainder); + } + + if (INDEX10(adapter->tx_ring.send_idx) == 0) { + if (adapter->tx_ring.send_idx) + tcb->index = NUM_DESC_PER_RING_TX - 1; + else + tcb->index = ET_DMA10_WRAP|(NUM_DESC_PER_RING_TX - 1); + } else + tcb->index = adapter->tx_ring.send_idx - 1; + + spin_lock(&adapter->tcb_send_qlock); + + if (adapter->tx_ring.send_tail) + adapter->tx_ring.send_tail->next = tcb; + else + adapter->tx_ring.send_head = tcb; + + adapter->tx_ring.send_tail = tcb; + + WARN_ON(tcb->next != NULL); + + adapter->tx_ring.used++; + + spin_unlock(&adapter->tcb_send_qlock); + + /* Write the new write pointer back to the device. */ + writel(adapter->tx_ring.send_idx, + &adapter->regs->txdma.service_request); + + /* For Gig only, we use Tx Interrupt coalescing. Enable the software + * timer to wake us up if this packet isn't followed by N more. + */ + if (phydev && phydev->speed == SPEED_1000) { + writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, + &adapter->regs->global.watchdog_timer); + } + spin_unlock_irqrestore(&adapter->send_hw_lock, flags); + + return 0; +} + +/** + * send_packet - Do the work to send a packet + * @skb: the packet(s) to send + * @adapter: a pointer to the device's private adapter structure + * + * Return 0 in almost all cases; non-zero value in extreme hard failure only. + * + * Assumption: Send spinlock has been acquired + */ +static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) +{ + int status; + struct tcb *tcb = NULL; + u16 *shbufva; + unsigned long flags; + + /* All packets must have at least a MAC address and a protocol type */ + if (skb->len < ETH_HLEN) + return -EIO; + + /* Get a TCB for this packet */ + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); + + tcb = adapter->tx_ring.tcb_qhead; + + if (tcb == NULL) { + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); + return -ENOMEM; + } + + adapter->tx_ring.tcb_qhead = tcb->next; + + if (adapter->tx_ring.tcb_qhead == NULL) + adapter->tx_ring.tcb_qtail = NULL; + + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); + + tcb->skb = skb; + + if (skb->data != NULL && skb->len - skb->data_len >= 6) { + shbufva = (u16 *) skb->data; + + if ((shbufva[0] == 0xffff) && + (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) { + tcb->flags |= fMP_DEST_BROAD; + } else if ((shbufva[0] & 0x3) == 0x0001) { + tcb->flags |= fMP_DEST_MULTI; + } + } + + tcb->next = NULL; + + /* Call the NIC specific send handler. */ + status = nic_send_packet(adapter, tcb); + + if (status != 0) { + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); + + if (adapter->tx_ring.tcb_qtail) + adapter->tx_ring.tcb_qtail->next = tcb; + else + /* Apparently ready Q is empty. */ + adapter->tx_ring.tcb_qhead = tcb; + + adapter->tx_ring.tcb_qtail = tcb; + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); + return status; + } + WARN_ON(adapter->tx_ring.used > NUM_TCB); + return 0; +} + +/** + * et131x_send_packets - This function is called by the OS to send packets + * @skb: the packet(s) to send + * @netdev:device on which to TX the above packet(s) + * + * Return 0 in almost all cases; non-zero value in extreme hard failure only + */ +int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) +{ + int status = 0; + struct et131x_adapter *adapter = NULL; + + adapter = netdev_priv(netdev); + + /* Send these packets + * + * NOTE: The Linux Tx entry point is only given one packet at a time + * to Tx, so the PacketCount and it's array used makes no sense here + */ + + /* TCB is not available */ + if (adapter->tx_ring.used >= NUM_TCB) { + /* NOTE: If there's an error on send, no need to queue the + * packet under Linux; if we just send an error up to the + * netif layer, it will resend the skb to us. + */ + status = -ENOMEM; + } else { + /* We need to see if the link is up; if it's not, make the + * netif layer think we're good and drop the packet + */ + if ((adapter->flags & fMP_ADAPTER_FAIL_SEND_MASK) || + !netif_carrier_ok(netdev)) { + dev_kfree_skb_any(skb); + skb = NULL; + + adapter->net_stats.tx_dropped++; + } else { + status = send_packet(skb, adapter); + if (status != 0 && status != -ENOMEM) { + /* On any other error, make netif think we're + * OK and drop the packet + */ + dev_kfree_skb_any(skb); + skb = NULL; + adapter->net_stats.tx_dropped++; + } + } + } + return status; +} + +/** + * free_send_packet - Recycle a struct tcb + * @adapter: pointer to our adapter + * @tcb: pointer to struct tcb + * + * Complete the packet if necessary + * Assumption - Send spinlock has been acquired + */ +static inline void free_send_packet(struct et131x_adapter *adapter, + struct tcb *tcb) +{ + unsigned long flags; + struct tx_desc *desc = NULL; + struct net_device_stats *stats = &adapter->net_stats; + + if (tcb->flags & fMP_DEST_BROAD) + atomic_inc(&adapter->stats.broadcast_pkts_xmtd); + else if (tcb->flags & fMP_DEST_MULTI) + atomic_inc(&adapter->stats.multicast_pkts_xmtd); + else + atomic_inc(&adapter->stats.unicast_pkts_xmtd); + + if (tcb->skb) { + stats->tx_bytes += tcb->skb->len; + + /* Iterate through the TX descriptors on the ring + * corresponding to this packet and umap the fragments + * they point to + */ + do { + desc = (struct tx_desc *) + (adapter->tx_ring.tx_desc_ring + + INDEX10(tcb->index_start)); + + pci_unmap_single(adapter->pdev, + desc->addr_lo, + desc->len_vlan, PCI_DMA_TODEVICE); + + add_10bit(&tcb->index_start, 1); + if (INDEX10(tcb->index_start) >= + NUM_DESC_PER_RING_TX) { + tcb->index_start &= ~ET_DMA10_MASK; + tcb->index_start ^= ET_DMA10_WRAP; + } + } while (desc != (adapter->tx_ring.tx_desc_ring + + INDEX10(tcb->index))); + + dev_kfree_skb_any(tcb->skb); + } + + memset(tcb, 0, sizeof(struct tcb)); + + /* Add the TCB to the Ready Q */ + spin_lock_irqsave(&adapter->tcb_ready_qlock, flags); + + adapter->net_stats.tx_packets++; + + if (adapter->tx_ring.tcb_qtail) + adapter->tx_ring.tcb_qtail->next = tcb; + else + /* Apparently ready Q is empty. */ + adapter->tx_ring.tcb_qhead = tcb; + + adapter->tx_ring.tcb_qtail = tcb; + + spin_unlock_irqrestore(&adapter->tcb_ready_qlock, flags); + WARN_ON(adapter->tx_ring.used < 0); +} + +/** + * et131x_free_busy_send_packets - Free and complete the stopped active sends + * @adapter: pointer to our adapter + * + * Assumption - Send spinlock has been acquired + */ +void et131x_free_busy_send_packets(struct et131x_adapter *adapter) +{ + struct tcb *tcb; + unsigned long flags; + u32 freed = 0; + + /* Any packets being sent? Check the first TCB on the send list */ + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + tcb = adapter->tx_ring.send_head; + + while (tcb != NULL && freed < NUM_TCB) { + struct tcb *next = tcb->next; + + adapter->tx_ring.send_head = next; + + if (next == NULL) + adapter->tx_ring.send_tail = NULL; + + adapter->tx_ring.used--; + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + + freed++; + free_send_packet(adapter, tcb); + + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + tcb = adapter->tx_ring.send_head; + } + + WARN_ON(freed == NUM_TCB); + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + + adapter->tx_ring.used = 0; +} + +/** + * et131x_handle_send_interrupt - Interrupt handler for sending processing + * @adapter: pointer to our adapter + * + * Re-claim the send resources, complete sends and get more to send from + * the send wait queue. + * + * Assumption - Send spinlock has been acquired + */ +void et131x_handle_send_interrupt(struct et131x_adapter *adapter) +{ + unsigned long flags; + u32 serviced; + struct tcb *tcb; + u32 index; + + serviced = readl(&adapter->regs->txdma.new_service_complete); + index = INDEX10(serviced); + + /* Has the ring wrapped? Process any descriptors that do not have + * the same "wrap" indicator as the current completion indicator + */ + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + tcb = adapter->tx_ring.send_head; + + while (tcb && + ((serviced ^ tcb->index) & ET_DMA10_WRAP) && + index < INDEX10(tcb->index)) { + adapter->tx_ring.used--; + adapter->tx_ring.send_head = tcb->next; + if (tcb->next == NULL) + adapter->tx_ring.send_tail = NULL; + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + free_send_packet(adapter, tcb); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + /* Goto the next packet */ + tcb = adapter->tx_ring.send_head; + } + while (tcb && + !((serviced ^ tcb->index) & ET_DMA10_WRAP) + && index > (tcb->index & ET_DMA10_MASK)) { + adapter->tx_ring.used--; + adapter->tx_ring.send_head = tcb->next; + if (tcb->next == NULL) + adapter->tx_ring.send_tail = NULL; + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); + free_send_packet(adapter, tcb); + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + /* Goto the next packet */ + tcb = adapter->tx_ring.send_head; + } + + /* Wake up the queue when we hit a low-water mark */ + if (adapter->tx_ring.used <= NUM_TCB / 3) + netif_wake_queue(adapter->netdev); + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); +} + +/* ETHTOOL functions */ + +static int et131x_get_settings(struct net_device *netdev, + struct ethtool_cmd *cmd) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + return phy_ethtool_gset(adapter->phydev, cmd); +} + +static int et131x_set_settings(struct net_device *netdev, + struct ethtool_cmd *cmd) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + return phy_ethtool_sset(adapter->phydev, cmd); +} + +static int et131x_get_regs_len(struct net_device *netdev) +{ +#define ET131X_REGS_LEN 256 + return ET131X_REGS_LEN * sizeof(u32); +} + +static void et131x_get_regs(struct net_device *netdev, + struct ethtool_regs *regs, void *regs_data) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct address_map __iomem *aregs = adapter->regs; + u32 *regs_buff = regs_data; + u32 num = 0; + + memset(regs_data, 0, et131x_get_regs_len(netdev)); + + regs->version = (1 << 24) | (adapter->pdev->revision << 16) | + adapter->pdev->device; + + /* PHY regs */ + et131x_mii_read(adapter, MII_BMCR, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_BMSR, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_PHYSID1, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_PHYSID2, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_ADVERTISE, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_LPA, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_EXPANSION, (u16 *)®s_buff[num++]); + /* Autoneg next page transmit reg */ + et131x_mii_read(adapter, 0x07, (u16 *)®s_buff[num++]); + /* Link partner next page reg */ + et131x_mii_read(adapter, 0x08, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_CTRL1000, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_STAT1000, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_ESTATUS, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_CONFIG, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_PHY_CONTROL, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INTERRUPT_MASK, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, + (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_PHY_STATUS, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LED_1, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, PHY_LED_2, (u16 *)®s_buff[num++]); + + /* Global regs */ + regs_buff[num++] = readl(&aregs->global.txq_start_addr); + regs_buff[num++] = readl(&aregs->global.txq_end_addr); + regs_buff[num++] = readl(&aregs->global.rxq_start_addr); + regs_buff[num++] = readl(&aregs->global.rxq_end_addr); + regs_buff[num++] = readl(&aregs->global.pm_csr); + regs_buff[num++] = adapter->stats.interrupt_status; + regs_buff[num++] = readl(&aregs->global.int_mask); + regs_buff[num++] = readl(&aregs->global.int_alias_clr_en); + regs_buff[num++] = readl(&aregs->global.int_status_alias); + regs_buff[num++] = readl(&aregs->global.sw_reset); + regs_buff[num++] = readl(&aregs->global.slv_timer); + regs_buff[num++] = readl(&aregs->global.msi_config); + regs_buff[num++] = readl(&aregs->global.loopback); + regs_buff[num++] = readl(&aregs->global.watchdog_timer); + + /* TXDMA regs */ + regs_buff[num++] = readl(&aregs->txdma.csr); + regs_buff[num++] = readl(&aregs->txdma.pr_base_hi); + regs_buff[num++] = readl(&aregs->txdma.pr_base_lo); + regs_buff[num++] = readl(&aregs->txdma.pr_num_des); + regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr); + regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr_ext); + regs_buff[num++] = readl(&aregs->txdma.txq_rd_addr); + regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_hi); + regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_lo); + regs_buff[num++] = readl(&aregs->txdma.service_request); + regs_buff[num++] = readl(&aregs->txdma.service_complete); + regs_buff[num++] = readl(&aregs->txdma.cache_rd_index); + regs_buff[num++] = readl(&aregs->txdma.cache_wr_index); + regs_buff[num++] = readl(&aregs->txdma.tx_dma_error); + regs_buff[num++] = readl(&aregs->txdma.desc_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_abort_cnt); + regs_buff[num++] = readl(&aregs->txdma.desc_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_timeout_cnt); + regs_buff[num++] = readl(&aregs->txdma.desc_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.payload_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.writeback_error_cnt); + regs_buff[num++] = readl(&aregs->txdma.dropped_tlp_cnt); + regs_buff[num++] = readl(&aregs->txdma.new_service_complete); + regs_buff[num++] = readl(&aregs->txdma.ethernet_packet_cnt); + + /* RXDMA regs */ + regs_buff[num++] = readl(&aregs->rxdma.csr); + regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.num_pkt_done); + regs_buff[num++] = readl(&aregs->rxdma.max_pkt_time); + regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr); + regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr_ext); + regs_buff[num++] = readl(&aregs->rxdma.rxq_wr_addr); + regs_buff[num++] = readl(&aregs->rxdma.psr_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.psr_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.psr_num_des); + regs_buff[num++] = readl(&aregs->rxdma.psr_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.psr_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.psr_access_index); + regs_buff[num++] = readl(&aregs->rxdma.psr_min_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_num_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_rd_index); + regs_buff[num++] = readl(&aregs->rxdma.fbr0_min_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_lo); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_hi); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_num_des); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_avail_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_full_offset); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_rd_index); + regs_buff[num++] = readl(&aregs->rxdma.fbr1_min_des); +} + +#define ET131X_DRVINFO_LEN 32 /* value from ethtool.h */ +static void et131x_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *info) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + strncpy(info->driver, DRIVER_NAME, ET131X_DRVINFO_LEN); + strncpy(info->version, DRIVER_VERSION, ET131X_DRVINFO_LEN); + strncpy(info->bus_info, pci_name(adapter->pdev), ET131X_DRVINFO_LEN); +} + +static struct ethtool_ops et131x_ethtool_ops = { + .get_settings = et131x_get_settings, + .set_settings = et131x_set_settings, + .get_drvinfo = et131x_get_drvinfo, + .get_regs_len = et131x_get_regs_len, + .get_regs = et131x_get_regs, + .get_link = ethtool_op_get_link, +}; + +void et131x_set_ethtool_ops(struct net_device *netdev) +{ + SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops); +} + +/* PCI functions */ + +/** + * et131x_hwaddr_init - set up the MAC Address on the ET1310 + * @adapter: pointer to our private adapter structure + */ +void et131x_hwaddr_init(struct et131x_adapter *adapter) +{ + /* If have our default mac from init and no mac address from + * EEPROM then we need to generate the last octet and set it on the + * device + */ + if (adapter->rom_addr[0] == 0x00 && + adapter->rom_addr[1] == 0x00 && + adapter->rom_addr[2] == 0x00 && + adapter->rom_addr[3] == 0x00 && + adapter->rom_addr[4] == 0x00 && + adapter->rom_addr[5] == 0x00) { + /* + * We need to randomly generate the last octet so we + * decrease our chances of setting the mac address to + * same as another one of our cards in the system + */ + get_random_bytes(&adapter->addr[5], 1); + /* + * We have the default value in the register we are + * working with so we need to copy the current + * address into the permanent address + */ + memcpy(adapter->rom_addr, + adapter->addr, ETH_ALEN); + } else { + /* We do not have an override address, so set the + * current address to the permanent address and add + * it to the device + */ + memcpy(adapter->addr, + adapter->rom_addr, ETH_ALEN); + } +} + +/** + * et131x_pci_init - initial PCI setup + * @adapter: pointer to our private adapter structure + * @pdev: our PCI device + * + * Perform the initial setup of PCI registers and if possible initialise + * the MAC address. At this point the I/O registers have yet to be mapped + */ +static int et131x_pci_init(struct et131x_adapter *adapter, + struct pci_dev *pdev) +{ + int i; + u8 max_payload; + u8 read_size_reg; + + if (et131x_init_eeprom(adapter) < 0) + return -EIO; + + /* Let's set up the PORT LOGIC Register. First we need to know what + * the max_payload_size is + */ + if (pci_read_config_byte(pdev, ET1310_PCI_MAX_PYLD, &max_payload)) { + dev_err(&pdev->dev, + "Could not read PCI config space for Max Payload Size\n"); + return -EIO; + } + + /* Program the Ack/Nak latency and replay timers */ + max_payload &= 0x07; /* Only the lower 3 bits are valid */ + + if (max_payload < 2) { + static const u16 acknak[2] = { 0x76, 0xD0 }; + static const u16 replay[2] = { 0x1E0, 0x2ED }; + + if (pci_write_config_word(pdev, ET1310_PCI_ACK_NACK, + acknak[max_payload])) { + dev_err(&pdev->dev, + "Could not write PCI config space for ACK/NAK\n"); + return -EIO; + } + if (pci_write_config_word(pdev, ET1310_PCI_REPLAY, + replay[max_payload])) { + dev_err(&pdev->dev, + "Could not write PCI config space for Replay Timer\n"); + return -EIO; + } + } + + /* l0s and l1 latency timers. We are using default values. + * Representing 001 for L0s and 010 for L1 + */ + if (pci_write_config_byte(pdev, ET1310_PCI_L0L1LATENCY, 0x11)) { + dev_err(&pdev->dev, + "Could not write PCI config space for Latency Timers\n"); + return -EIO; + } + + /* Change the max read size to 2k */ + if (pci_read_config_byte(pdev, 0x51, &read_size_reg)) { + dev_err(&pdev->dev, + "Could not read PCI config space for Max read size\n"); + return -EIO; + } + + read_size_reg &= 0x8f; + read_size_reg |= 0x40; + + if (pci_write_config_byte(pdev, 0x51, read_size_reg)) { + dev_err(&pdev->dev, + "Could not write PCI config space for Max read size\n"); + return -EIO; + } + + /* Get MAC address from config space if an eeprom exists, otherwise + * the MAC address there will not be valid + */ + if (!adapter->has_eeprom) { + et131x_hwaddr_init(adapter); + return 0; + } + + for (i = 0; i < ETH_ALEN; i++) { + if (pci_read_config_byte(pdev, ET1310_PCI_MAC_ADDRESS + i, + adapter->rom_addr + i)) { + dev_err(&pdev->dev, "Could not read PCI config space for MAC address\n"); + return -EIO; + } + } + memcpy(adapter->addr, adapter->rom_addr, ETH_ALEN); + return 0; +} + +/** + * et131x_error_timer_handler + * @data: timer-specific variable; here a pointer to our adapter structure + * + * The routine called when the error timer expires, to track the number of + * recurring errors. + */ +void et131x_error_timer_handler(unsigned long data) +{ + struct et131x_adapter *adapter = (struct et131x_adapter *) data; + struct phy_device *phydev = adapter->phydev; + + if (et1310_in_phy_coma(adapter)) { + /* Bring the device immediately out of coma, to + * prevent it from sleeping indefinitely, this + * mechanism could be improved! */ + et1310_disable_phy_coma(adapter); + adapter->boot_coma = 20; + } else { + et1310_update_macstat_host_counters(adapter); + } + + if (!phydev->link && adapter->boot_coma < 11) + adapter->boot_coma++; + + if (adapter->boot_coma == 10) { + if (!phydev->link) { + if (!et1310_in_phy_coma(adapter)) { + /* NOTE - This was originally a 'sync with + * interrupt'. How to do that under Linux? + */ + et131x_enable_interrupts(adapter); + et1310_enable_phy_coma(adapter); + } + } + } + + /* This is a periodic timer, so reschedule */ + mod_timer(&adapter->error_timer, jiffies + + TX_ERROR_PERIOD * HZ / 1000); +} + +/** + * et131x_configure_global_regs - configure JAGCore global regs + * @adapter: pointer to our adapter structure + * + * Used to configure the global registers on the JAGCore + */ +void et131x_configure_global_regs(struct et131x_adapter *adapter) +{ + struct global_regs __iomem *regs = &adapter->regs->global; + + writel(0, ®s->rxq_start_addr); + writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); + + if (adapter->registry_jumbo_packet < 2048) { + /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word + * block of RAM that the driver can split between Tx + * and Rx as it desires. Our default is to split it + * 50/50: + */ + writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); + writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); + } else if (adapter->registry_jumbo_packet < 8192) { + /* For jumbo packets > 2k but < 8k, split 50-50. */ + writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); + writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); + } else { + /* 9216 is the only packet size greater than 8k that + * is available. The Tx buffer has to be big enough + * for one whole packet on the Tx side. We'll make + * the Tx 9408, and give the rest to Rx + */ + writel(0x01b3, ®s->rxq_end_addr); + writel(0x01b4, ®s->txq_start_addr); + } + + /* Initialize the loopback register. Disable all loopbacks. */ + writel(0, ®s->loopback); + + /* MSI Register */ + writel(0, ®s->msi_config); + + /* By default, disable the watchdog timer. It will be enabled when + * a packet is queued. + */ + writel(0, ®s->watchdog_timer); +} + +/** + * et131x_adapter_setup - Set the adapter up as per cassini+ documentation + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +void et131x_adapter_setup(struct et131x_adapter *adapter) +{ + /* Configure the JAGCore */ + et131x_configure_global_regs(adapter); + + et1310_config_mac_regs1(adapter); + + /* Configure the MMC registers */ + /* All we need to do is initialize the Memory Control Register */ + writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl); + + et1310_config_rxmac_regs(adapter); + et1310_config_txmac_regs(adapter); + + et131x_config_rx_dma_regs(adapter); + et131x_config_tx_dma_regs(adapter); + + et1310_config_macstat_regs(adapter); + + et1310_phy_power_down(adapter, 0); + et131x_xcvr_init(adapter); +} + +/** + * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 + * @adapter: pointer to our private adapter structure + */ +void et131x_soft_reset(struct et131x_adapter *adapter) +{ + /* Disable MAC Core */ + writel(0xc00f0000, &adapter->regs->mac.cfg1); + + /* Set everything to a reset value */ + writel(0x7F, &adapter->regs->global.sw_reset); + writel(0x000f0000, &adapter->regs->mac.cfg1); + writel(0x00000000, &adapter->regs->mac.cfg1); +} + +/** + * et131x_align_allocated_memory - Align allocated memory on a given boundary + * @adapter: pointer to our adapter structure + * @phys_addr: pointer to Physical address + * @offset: pointer to the offset variable + * @mask: correct mask + */ +void et131x_align_allocated_memory(struct et131x_adapter *adapter, + uint64_t *phys_addr, + uint64_t *offset, uint64_t mask) +{ + uint64_t new_addr; + + *offset = 0; + + new_addr = *phys_addr & ~mask; + + if (new_addr != *phys_addr) { + /* Move to next aligned block */ + new_addr += mask + 1; + /* Return offset for adjusting virt addr */ + *offset = new_addr - *phys_addr; + /* Return new physical address */ + *phys_addr = new_addr; + } +} + +/** + * et131x_adapter_memory_alloc + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success, errno on failure (as defined in errno.h). + * + * Allocate all the memory blocks for send, receive and others. + */ +int et131x_adapter_memory_alloc(struct et131x_adapter *adapter) +{ + int status; + + /* Allocate memory for the Tx Ring */ + status = et131x_tx_dma_memory_alloc(adapter); + if (status != 0) { + dev_err(&adapter->pdev->dev, + "et131x_tx_dma_memory_alloc FAILED\n"); + return status; + } + /* Receive buffer memory allocation */ + status = et131x_rx_dma_memory_alloc(adapter); + if (status != 0) { + dev_err(&adapter->pdev->dev, + "et131x_rx_dma_memory_alloc FAILED\n"); + et131x_tx_dma_memory_free(adapter); + return status; + } + + /* Init receive data structures */ + status = et131x_init_recv(adapter); + if (status != 0) { + dev_err(&adapter->pdev->dev, + "et131x_init_recv FAILED\n"); + et131x_tx_dma_memory_free(adapter); + et131x_rx_dma_memory_free(adapter); + } + return status; +} + +/** + * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx + * @adapter: pointer to our private adapter structure + */ +void et131x_adapter_memory_free(struct et131x_adapter *adapter) +{ + /* Free DMA memory */ + et131x_tx_dma_memory_free(adapter); + et131x_rx_dma_memory_free(adapter); +} + +static void et131x_adjust_link(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev = adapter->phydev; + + if (netif_carrier_ok(netdev)) { + adapter->boot_coma = 20; + + if (phydev && phydev->speed == SPEED_10) { + /* + * NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(adapter->hTruePhy, 0)== + * EMI_TRUEPHY_A13O) { + */ + u16 register18; + + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18 | 0x4); + et131x_mii_write(adapter, PHY_INDEX_REG, + register18 | 0x8402); + et131x_mii_write(adapter, PHY_DATA_REG, + register18 | 511); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); + } + + et1310_config_flow_control(adapter); + + if (phydev && phydev->speed == SPEED_1000 && + adapter->registry_jumbo_packet > 2048) { + u16 reg; + + et131x_mii_read(adapter, PHY_CONFIG, ®); + reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; + reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; + et131x_mii_write(adapter, PHY_CONFIG, reg); + } + + et131x_set_rx_dma_timer(adapter); + et1310_config_mac_regs2(adapter); + } + + if (phydev && phydev->link != adapter->link) { + /* + * Check to see if we are in coma mode and if + * so, disable it because we will not be able + * to read PHY values until we are out. + */ + if (et1310_in_phy_coma(adapter)) + et1310_disable_phy_coma(adapter); + + if (phydev->link) { + adapter->boot_coma = 20; + } else { + dev_warn(&adapter->pdev->dev, + "Link down - cable problem ?\n"); + adapter->boot_coma = 0; + + if (phydev->speed == SPEED_10) { + /* NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(adapter->hTruePhy, 0) == + * EMI_TRUEPHY_A13O) + */ + u16 register18; + + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18 | 0x4); + et131x_mii_write(adapter, PHY_INDEX_REG, + register18 | 0x8402); + et131x_mii_write(adapter, PHY_DATA_REG, + register18 | 511); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); + } + + /* Free the packets being actively sent & stopped */ + et131x_free_busy_send_packets(adapter); + + /* Re-initialize the send structures */ + et131x_init_send(adapter); + + /* Reset the RFD list and re-start RU */ + et131x_reset_recv(adapter); + + /* + * Bring the device back to the state it was during + * init prior to autonegotiation being complete. This + * way, when we get the auto-neg complete interrupt, + * we can complete init by calling config_mac_regs2. + */ + et131x_soft_reset(adapter); + + /* Setup ET1310 as per the documentation */ + et131x_adapter_setup(adapter); + + /* perform reset of tx/rx */ + et131x_disable_txrx(netdev); + et131x_enable_txrx(netdev); + } + + adapter->link = phydev->link; + + phy_print_status(phydev); + } +} + +static int et131x_mii_probe(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev = NULL; + + phydev = phy_find_first(adapter->mii_bus); + if (!phydev) { + dev_err(&adapter->pdev->dev, "no PHY found\n"); + return -ENODEV; + } + + phydev = phy_connect(netdev, dev_name(&phydev->dev), + &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII); + + if (IS_ERR(phydev)) { + dev_err(&adapter->pdev->dev, "Could not attach to PHY\n"); + return PTR_ERR(phydev); + } + + phydev->supported &= (SUPPORTED_10baseT_Half + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_Autoneg + | SUPPORTED_MII + | SUPPORTED_TP); + + if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) + phydev->supported |= SUPPORTED_1000baseT_Full; + + phydev->advertising = phydev->supported; + adapter->phydev = phydev; + + dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " + "(mii_bus:phy_addr=%s)\n", + phydev->drv->name, dev_name(&phydev->dev)); + + return 0; +} + +/** + * et131x_adapter_init + * @adapter: pointer to the private adapter struct + * @pdev: pointer to the PCI device + * + * Initialize the data structures for the et131x_adapter object and link + * them together with the platform provided device structures. + */ +static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, + struct pci_dev *pdev) +{ + static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 }; + + struct et131x_adapter *adapter; + + /* Allocate private adapter struct and copy in relevant information */ + adapter = netdev_priv(netdev); + adapter->pdev = pci_dev_get(pdev); + adapter->netdev = netdev; + + /* Do the same for the netdev struct */ + netdev->irq = pdev->irq; + netdev->base_addr = pci_resource_start(pdev, 0); + + /* Initialize spinlocks here */ + spin_lock_init(&adapter->lock); + spin_lock_init(&adapter->tcb_send_qlock); + spin_lock_init(&adapter->tcb_ready_qlock); + spin_lock_init(&adapter->send_hw_lock); + spin_lock_init(&adapter->rcv_lock); + spin_lock_init(&adapter->rcv_pend_lock); + spin_lock_init(&adapter->fbr_lock); + spin_lock_init(&adapter->phy_lock); + + adapter->registry_jumbo_packet = 1514; /* 1514-9216 */ + + /* Set the MAC address to a default */ + memcpy(adapter->addr, default_mac, ETH_ALEN); + + return adapter; +} + +/** + * et131x_pci_setup - Perform device initialization + * @pdev: a pointer to the device's pci_dev structure + * @ent: this device's entry in the pci_device_id table + * + * Returns 0 on success, errno on failure (as defined in errno.h) + * + * Registered in the pci_driver structure, this function is called when the + * PCI subsystem finds a new PCI device which matches the information + * contained in the pci_device_id table. This routine is the equivalent to + * a device insertion routine. + */ +static int __devinit et131x_pci_setup(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int result; + int pm_cap; + struct net_device *netdev; + struct et131x_adapter *adapter; + int ii; + + result = pci_enable_device(pdev); + if (result) { + dev_err(&pdev->dev, "pci_enable_device() failed\n"); + goto err_out; + } + + /* Perform some basic PCI checks */ + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { + dev_err(&pdev->dev, "Can't find PCI device's base address\n"); + goto err_disable; + } + + if (pci_request_regions(pdev, DRIVER_NAME)) { + dev_err(&pdev->dev, "Can't get PCI resources\n"); + goto err_disable; + } + + pci_set_master(pdev); + + /* Query PCI for Power Mgmt Capabilities + * + * NOTE: Now reading PowerMgmt in another location; is this still + * needed? + */ + pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); + if (!pm_cap) { + dev_err(&pdev->dev, + "Cannot find Power Management capabilities\n"); + result = -EIO; + goto err_release_res; + } + + /* Check the DMA addressing support of this device */ + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { + result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + if (result) { + dev_err(&pdev->dev, + "Unable to obtain 64 bit DMA for consistent allocations\n"); + goto err_release_res; + } + } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { + result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (result) { + dev_err(&pdev->dev, + "Unable to obtain 32 bit DMA for consistent allocations\n"); + goto err_release_res; + } + } else { + dev_err(&pdev->dev, "No usable DMA addressing method\n"); + result = -EIO; + goto err_release_res; + } + + /* Allocate netdev and private adapter structs */ + netdev = et131x_device_alloc(); + if (!netdev) { + dev_err(&pdev->dev, "Couldn't alloc netdev struct\n"); + result = -ENOMEM; + goto err_release_res; + } + + SET_NETDEV_DEV(netdev, &pdev->dev); + et131x_set_ethtool_ops(netdev); + + adapter = et131x_adapter_init(netdev, pdev); + + /* Initialise the PCI setup for the device */ + et131x_pci_init(adapter, pdev); + + /* Map the bus-relative registers to system virtual memory */ + adapter->regs = pci_ioremap_bar(pdev, 0); + if (!adapter->regs) { + dev_err(&pdev->dev, "Cannot map device registers\n"); + result = -ENOMEM; + goto err_free_dev; + } + + /* If Phy COMA mode was enabled when we went down, disable it here. */ + writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr); + + /* Issue a global reset to the et1310 */ + et131x_soft_reset(adapter); + + /* Disable all interrupts (paranoid) */ + et131x_disable_interrupts(adapter); + + /* Allocate DMA memory */ + result = et131x_adapter_memory_alloc(adapter); + if (result) { + dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n"); + goto err_iounmap; + } + + /* Init send data structures */ + et131x_init_send(adapter); + + /* Set up the task structure for the ISR's deferred handler */ + INIT_WORK(&adapter->task, et131x_isr_handler); + + /* Copy address into the net_device struct */ + memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); + + /* Init variable for counting how long we do not have link status */ + adapter->boot_coma = 0; + et1310_disable_phy_coma(adapter); + + /* Setup the mii_bus struct */ + adapter->mii_bus = mdiobus_alloc(); + if (!adapter->mii_bus) { + dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); + goto err_mem_free; + } + + adapter->mii_bus->name = "et131x_eth_mii"; + snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", + (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); + adapter->mii_bus->priv = netdev; + adapter->mii_bus->read = et131x_mdio_read; + adapter->mii_bus->write = et131x_mdio_write; + adapter->mii_bus->reset = et131x_mdio_reset; + adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); + if (!adapter->mii_bus->irq) { + dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); + goto err_mdio_free; + } + + for (ii = 0; ii < PHY_MAX_ADDR; ii++) + adapter->mii_bus->irq[ii] = PHY_POLL; + + if (mdiobus_register(adapter->mii_bus)) { + dev_err(&pdev->dev, "failed to register MII bus\n"); + mdiobus_free(adapter->mii_bus); + goto err_mdio_free_irq; + } + + if (et131x_mii_probe(netdev)) { + dev_err(&pdev->dev, "failed to probe MII bus\n"); + goto err_mdio_unregister; + } + + /* Setup et1310 as per the documentation */ + et131x_adapter_setup(adapter); + + /* We can enable interrupts now + * + * NOTE - Because registration of interrupt handler is done in the + * device's open(), defer enabling device interrupts to that + * point + */ + + /* Register the net_device struct with the Linux network layer */ + result = register_netdev(netdev); + if (result != 0) { + dev_err(&pdev->dev, "register_netdev() failed\n"); + goto err_mdio_unregister; + } + + /* Register the net_device struct with the PCI subsystem. Save a copy + * of the PCI config space for this device now that the device has + * been initialized, just in case it needs to be quickly restored. + */ + pci_set_drvdata(pdev, netdev); + pci_save_state(adapter->pdev); + + return result; + +err_mdio_unregister: + mdiobus_unregister(adapter->mii_bus); +err_mdio_free_irq: + kfree(adapter->mii_bus->irq); +err_mdio_free: + mdiobus_free(adapter->mii_bus); +err_mem_free: + et131x_adapter_memory_free(adapter); +err_iounmap: + iounmap(adapter->regs); +err_free_dev: + pci_dev_put(pdev); + free_netdev(netdev); +err_release_res: + pci_release_regions(pdev); +err_disable: + pci_disable_device(pdev); +err_out: + return result; +} + +/** + * et131x_pci_remove + * @pdev: a pointer to the device's pci_dev structure + * + * Registered in the pci_driver structure, this function is called when the + * PCI subsystem detects that a PCI device which matches the information + * contained in the pci_device_id table has been removed. + */ +static void __devexit et131x_pci_remove(struct pci_dev *pdev) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + struct et131x_adapter *adapter = netdev_priv(netdev); + + unregister_netdev(netdev); + mdiobus_unregister(adapter->mii_bus); + kfree(adapter->mii_bus->irq); + mdiobus_free(adapter->mii_bus); + + et131x_adapter_memory_free(adapter); + iounmap(adapter->regs); + pci_dev_put(pdev); + + free_netdev(netdev); + pci_release_regions(pdev); + pci_disable_device(pdev); +} + +#ifdef CONFIG_PM_SLEEP +static int et131x_suspend(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct net_device *netdev = pci_get_drvdata(pdev); + + if (netif_running(netdev)) { + netif_device_detach(netdev); + et131x_down(netdev); + pci_save_state(pdev); + } + + return 0; +} + +static int et131x_resume(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct net_device *netdev = pci_get_drvdata(pdev); + + if (netif_running(netdev)) { + pci_restore_state(pdev); + et131x_up(netdev); + netif_device_attach(netdev); + } + + return 0; +} + +static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); +#define ET131X_PM_OPS (&et131x_pm_ops) +#else +#define ET131X_PM_OPS NULL +#endif + +static struct pci_device_id et131x_pci_table[] __devinitdata = { + {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0UL}, + {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0UL}, + {0,} +}; + +MODULE_DEVICE_TABLE(pci, et131x_pci_table); + +static struct pci_driver et131x_driver = { + .name = DRIVER_NAME, + .id_table = et131x_pci_table, + .probe = et131x_pci_setup, + .remove = __devexit_p(et131x_pci_remove), + .driver.pm = ET131X_PM_OPS, +}; + +/** + * et131x_init_module - The "main" entry point called on driver initialization + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static int __init et131x_init_module(void) +{ + return pci_register_driver(&et131x_driver); +} + +/** + * et131x_cleanup_module - The entry point called on driver cleanup + */ +static void __exit et131x_cleanup_module(void) +{ + pci_unregister_driver(&et131x_driver); +} + +module_init(et131x_init_module); +module_exit(et131x_cleanup_module); + +/* ISR functions */ + +/** + * et131x_enable_interrupts - enable interrupt + * @adapter: et131x device + * + * Enable the appropriate interrupts on the ET131x according to our + * configuration + */ +void et131x_enable_interrupts(struct et131x_adapter *adapter) +{ + u32 mask; + + /* Enable all global interrupts */ + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) + mask = INT_MASK_ENABLE; + else + mask = INT_MASK_ENABLE_NO_FLOW; + + writel(mask, &adapter->regs->global.int_mask); +} + +/** + * et131x_disable_interrupts - interrupt disable + * @adapter: et131x device + * + * Block all interrupts from the et131x device at the device itself + */ +void et131x_disable_interrupts(struct et131x_adapter *adapter) +{ + /* Disable all global interrupts */ + writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); +} + + +/** + * et131x_isr - The Interrupt Service Routine for the driver. + * @irq: the IRQ on which the interrupt was received. + * @dev_id: device-specific info (here a pointer to a net_device struct) + * + * Returns a value indicating if the interrupt was handled. + */ +irqreturn_t et131x_isr(int irq, void *dev_id) +{ + bool handled = true; + struct net_device *netdev = (struct net_device *)dev_id; + struct et131x_adapter *adapter = NULL; + u32 status; + + if (!netif_device_present(netdev)) { + handled = false; + goto out; + } + + adapter = netdev_priv(netdev); + + /* If the adapter is in low power state, then it should not + * recognize any interrupt + */ + + /* Disable Device Interrupts */ + et131x_disable_interrupts(adapter); + + /* Get a copy of the value in the interrupt status register + * so we can process the interrupting section + */ + status = readl(&adapter->regs->global.int_status); + + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) { + status &= ~INT_MASK_ENABLE; + } else { + status &= ~INT_MASK_ENABLE_NO_FLOW; + } + + /* Make sure this is our interrupt */ + if (!status) { + handled = false; + et131x_enable_interrupts(adapter); + goto out; + } + + /* This is our interrupt, so process accordingly */ + + if (status & ET_INTR_WATCHDOG) { + struct tcb *tcb = adapter->tx_ring.send_head; + + if (tcb) + if (++tcb->stale > 1) + status |= ET_INTR_TXDMA_ISR; + + if (adapter->rx_ring.unfinished_receives) + status |= ET_INTR_RXDMA_XFR_DONE; + else if (tcb == NULL) + writel(0, &adapter->regs->global.watchdog_timer); + + status &= ~ET_INTR_WATCHDOG; + } + + if (status == 0) { + /* This interrupt has in some way been "handled" by + * the ISR. Either it was a spurious Rx interrupt, or + * it was a Tx interrupt that has been filtered by + * the ISR. + */ + et131x_enable_interrupts(adapter); + goto out; + } + + /* We need to save the interrupt status value for use in our + * DPC. We will clear the software copy of that in that + * routine. + */ + adapter->stats.interrupt_status = status; + + /* Schedule the ISR handler as a bottom-half task in the + * kernel's tq_immediate queue, and mark the queue for + * execution + */ + schedule_work(&adapter->task); +out: + return IRQ_RETVAL(handled); +} + +/** + * et131x_isr_handler - The ISR handler + * @p_adapter, a pointer to the device's private adapter structure + * + * scheduled to run in a deferred context by the ISR. This is where the ISR's + * work actually gets done. + */ +void et131x_isr_handler(struct work_struct *work) +{ + struct et131x_adapter *adapter = + container_of(work, struct et131x_adapter, task); + u32 status = adapter->stats.interrupt_status; + struct address_map __iomem *iomem = adapter->regs; + + /* + * These first two are by far the most common. Once handled, we clear + * their two bits in the status word. If the word is now zero, we + * exit. + */ + /* Handle all the completed Transmit interrupts */ + if (status & ET_INTR_TXDMA_ISR) + et131x_handle_send_interrupt(adapter); + + /* Handle all the completed Receives interrupts */ + if (status & ET_INTR_RXDMA_XFR_DONE) + et131x_handle_recv_interrupt(adapter); + + status &= 0xffffffd7; + + if (status) { + /* Handle the TXDMA Error interrupt */ + if (status & ET_INTR_TXDMA_ERR) { + u32 txdma_err; + + /* Following read also clears the register (COR) */ + txdma_err = readl(&iomem->txdma.tx_dma_error); + + dev_warn(&adapter->pdev->dev, + "TXDMA_ERR interrupt, error = %d\n", + txdma_err); + } + + /* Handle Free Buffer Ring 0 and 1 Low interrupt */ + if (status & + (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) { + /* + * This indicates the number of unused buffers in + * RXDMA free buffer ring 0 is <= the limit you + * programmed. Free buffer resources need to be + * returned. Free buffers are consumed as packets + * are passed from the network to the host. The host + * becomes aware of the packets from the contents of + * the packet status ring. This ring is queried when + * the packet done interrupt occurs. Packets are then + * passed to the OS. When the OS is done with the + * packets the resources can be returned to the + * ET1310 for re-use. This interrupt is one method of + * returning resources. + */ + + /* If the user has flow control on, then we will + * send a pause packet, otherwise just exit + */ + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) { + u32 pm_csr; + + /* Tell the device to send a pause packet via + * the back pressure register (bp req and + * bp xon/xoff) + */ + pm_csr = readl(&iomem->global.pm_csr); + if (!et1310_in_phy_coma(adapter)) + writel(3, &iomem->txmac.bp_ctrl); + } + } + + /* Handle Packet Status Ring Low Interrupt */ + if (status & ET_INTR_RXDMA_STAT_LOW) { + + /* + * Same idea as with the two Free Buffer Rings. + * Packets going from the network to the host each + * consume a free buffer resource and a packet status + * resource. These resoures are passed to the OS. + * When the OS is done with the resources, they need + * to be returned to the ET1310. This is one method + * of returning the resources. + */ + } + + /* Handle RXDMA Error Interrupt */ + if (status & ET_INTR_RXDMA_ERR) { + /* + * The rxdma_error interrupt is sent when a time-out + * on a request issued by the JAGCore has occurred or + * a completion is returned with an un-successful + * status. In both cases the request is considered + * complete. The JAGCore will automatically re-try the + * request in question. Normally information on events + * like these are sent to the host using the "Advanced + * Error Reporting" capability. This interrupt is + * another way of getting similar information. The + * only thing required is to clear the interrupt by + * reading the ISR in the global resources. The + * JAGCore will do a re-try on the request. Normally + * you should never see this interrupt. If you start + * to see this interrupt occurring frequently then + * something bad has occurred. A reset might be the + * thing to do. + */ + /* TRAP();*/ + + dev_warn(&adapter->pdev->dev, + "RxDMA_ERR interrupt, error %x\n", + readl(&iomem->txmac.tx_test)); + } + + /* Handle the Wake on LAN Event */ + if (status & ET_INTR_WOL) { + /* + * This is a secondary interrupt for wake on LAN. + * The driver should never see this, if it does, + * something serious is wrong. We will TRAP the + * message when we are in DBG mode, otherwise we + * will ignore it. + */ + dev_err(&adapter->pdev->dev, "WAKE_ON_LAN interrupt\n"); + } + + /* Let's move on to the TxMac */ + if (status & ET_INTR_TXMAC) { + u32 err = readl(&iomem->txmac.err); + + /* + * When any of the errors occur and TXMAC generates + * an interrupt to report these errors, it usually + * means that TXMAC has detected an error in the data + * stream retrieved from the on-chip Tx Q. All of + * these errors are catastrophic and TXMAC won't be + * able to recover data when these errors occur. In + * a nutshell, the whole Tx path will have to be reset + * and re-configured afterwards. + */ + dev_warn(&adapter->pdev->dev, + "TXMAC interrupt, error 0x%08x\n", + err); + + /* If we are debugging, we want to see this error, + * otherwise we just want the device to be reset and + * continue + */ + } + + /* Handle RXMAC Interrupt */ + if (status & ET_INTR_RXMAC) { + /* + * These interrupts are catastrophic to the device, + * what we need to do is disable the interrupts and + * set the flag to cause us to reset so we can solve + * this issue. + */ + /* MP_SET_FLAG( adapter, + fMP_ADAPTER_HARDWARE_ERROR); */ + + dev_warn(&adapter->pdev->dev, + "RXMAC interrupt, error 0x%08x. Requesting reset\n", + readl(&iomem->rxmac.err_reg)); + + dev_warn(&adapter->pdev->dev, + "Enable 0x%08x, Diag 0x%08x\n", + readl(&iomem->rxmac.ctrl), + readl(&iomem->rxmac.rxq_diag)); + + /* + * If we are debugging, we want to see this error, + * otherwise we just want the device to be reset and + * continue + */ + } + + /* Handle MAC_STAT Interrupt */ + if (status & ET_INTR_MAC_STAT) { + /* + * This means at least one of the un-masked counters + * in the MAC_STAT block has rolled over. Use this + * to maintain the top, software managed bits of the + * counter(s). + */ + et1310_handle_macstat_interrupt(adapter); + } + + /* Handle SLV Timeout Interrupt */ + if (status & ET_INTR_SLV_TIMEOUT) { + /* + * This means a timeout has occurred on a read or + * write request to one of the JAGCore registers. The + * Global Resources block has terminated the request + * and on a read request, returned a "fake" value. + * The most likely reasons are: Bad Address or the + * addressed module is in a power-down state and + * can't respond. + */ + } + } + et131x_enable_interrupts(adapter); +} + +/* NETDEV functions */ + +/** + * et131x_stats - Return the current device statistics. + * @netdev: device whose stats are being queried + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static struct net_device_stats *et131x_stats(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct net_device_stats *stats = &adapter->net_stats; + struct ce_stats *devstat = &adapter->stats; + + stats->rx_errors = devstat->rx_length_errs + + devstat->rx_align_errs + + devstat->rx_crc_errs + + devstat->rx_code_violations + + devstat->rx_other_errs; + stats->tx_errors = devstat->tx_max_pkt_errs; + stats->multicast = devstat->multicast_pkts_rcvd; + stats->collisions = devstat->tx_collisions; + + stats->rx_length_errors = devstat->rx_length_errs; + stats->rx_over_errors = devstat->rx_overflows; + stats->rx_crc_errors = devstat->rx_crc_errs; + + /* NOTE: These stats don't have corresponding values in CE_STATS, + * so we're going to have to update these directly from within the + * TX/RX code + */ + /* stats->rx_bytes = 20; devstat->; */ + /* stats->tx_bytes = 20; devstat->; */ + /* stats->rx_dropped = devstat->; */ + /* stats->tx_dropped = devstat->; */ + + /* NOTE: Not used, can't find analogous statistics */ + /* stats->rx_frame_errors = devstat->; */ + /* stats->rx_fifo_errors = devstat->; */ + /* stats->rx_missed_errors = devstat->; */ + + /* stats->tx_aborted_errors = devstat->; */ + /* stats->tx_carrier_errors = devstat->; */ + /* stats->tx_fifo_errors = devstat->; */ + /* stats->tx_heartbeat_errors = devstat->; */ + /* stats->tx_window_errors = devstat->; */ + return stats; +} + +/** + * et131x_enable_txrx - Enable tx/rx queues + * @netdev: device to be enabled + */ +void et131x_enable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Enable the Tx and Rx DMA engines (if not already enabled) */ + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + + /* Enable device interrupts */ + if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) + et131x_enable_interrupts(adapter); + + /* We're ready to move some data, so start the queue */ + netif_start_queue(netdev); +} + +/** + * et131x_disable_txrx - Disable tx/rx queues + * @netdev: device to be disabled + */ +void et131x_disable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* First thing is to stop the queue */ + netif_stop_queue(netdev); + + /* Stop the Tx and Rx DMA engines */ + et131x_rx_dma_disable(adapter); + et131x_tx_dma_disable(adapter); + + /* Disable device interrupts */ + et131x_disable_interrupts(adapter); +} + +/** + * et131x_up - Bring up a device for use. + * @netdev: device to be opened + */ +void et131x_up(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + et131x_enable_txrx(netdev); + phy_start(adapter->phydev); +} + +/** + * et131x_open - Open the device for use. + * @netdev: device to be opened + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_open(struct net_device *netdev) +{ + int result = 0; + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Start the timer to track NIC errors */ + init_timer(&adapter->error_timer); + adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; + adapter->error_timer.function = et131x_error_timer_handler; + adapter->error_timer.data = (unsigned long)adapter; + add_timer(&adapter->error_timer); + + /* Register our IRQ */ + result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED, + netdev->name, netdev); + if (result) { + dev_err(&adapter->pdev->dev, "could not register IRQ %d\n", + netdev->irq); + return result; + } + + adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; + + et131x_up(netdev); + + return result; +} + +/** + * et131x_down - Bring down the device + * @netdev: device to be broght down + */ +void et131x_down(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Save the timestamp for the TX watchdog, prevent a timeout */ + netdev->trans_start = jiffies; + + phy_stop(adapter->phydev); + et131x_disable_txrx(netdev); +} + +/** + * et131x_close - Close the device + * @netdev: device to be closed + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_close(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + et131x_down(netdev); + + adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; + free_irq(netdev->irq, netdev); + + /* Stop the error timer */ + return del_timer_sync(&adapter->error_timer); +} + +/** + * et131x_ioctl - The I/O Control handler for the driver + * @netdev: device on which the control request is being made + * @reqbuf: a pointer to the IOCTL request buffer + * @cmd: the IOCTL command code + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + if (!adapter->phydev) + return -EINVAL; + + return phy_mii_ioctl(adapter->phydev, reqbuf, cmd); +} + +/** + * et131x_set_packet_filter - Configures the Rx Packet filtering on the device + * @adapter: pointer to our private adapter structure + * + * FIXME: lot of dups with MAC code + * + * Returns 0 on success, errno on failure + */ +static int et131x_set_packet_filter(struct et131x_adapter *adapter) +{ + int status = 0; + uint32_t filter = adapter->packet_filter; + u32 ctrl; + u32 pf_ctrl; + + ctrl = readl(&adapter->regs->rxmac.ctrl); + pf_ctrl = readl(&adapter->regs->rxmac.pf_ctrl); + + /* Default to disabled packet filtering. Enable it in the individual + * case statements that require the device to filter something + */ + ctrl |= 0x04; + + /* Set us to be in promiscuous mode so we receive everything, this + * is also true when we get a packet filter of 0 + */ + if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0) + pf_ctrl &= ~7; /* Clear filter bits */ + else { + /* + * Set us up with Multicast packet filtering. Three cases are + * possible - (1) we have a multi-cast list, (2) we receive ALL + * multicast entries or (3) we receive none. + */ + if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) + pf_ctrl &= ~2; /* Multicast filter bit */ + else { + et1310_setup_device_for_multicast(adapter); + pf_ctrl |= 2; + ctrl &= ~0x04; + } + + /* Set us up with Unicast packet filtering */ + if (filter & ET131X_PACKET_TYPE_DIRECTED) { + et1310_setup_device_for_unicast(adapter); + pf_ctrl |= 4; + ctrl &= ~0x04; + } + + /* Set us up with Broadcast packet filtering */ + if (filter & ET131X_PACKET_TYPE_BROADCAST) { + pf_ctrl |= 1; /* Broadcast filter bit */ + ctrl &= ~0x04; + } else + pf_ctrl &= ~1; + + /* Setup the receive mac configuration registers - Packet + * Filter control + the enable / disable for packet filter + * in the control reg. + */ + writel(pf_ctrl, &adapter->regs->rxmac.pf_ctrl); + writel(ctrl, &adapter->regs->rxmac.ctrl); + } + return status; +} + +/** + * et131x_multicast - The handler to configure multicasting on the interface + * @netdev: a pointer to a net_device struct representing the device + */ +static void et131x_multicast(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + uint32_t packet_filter = 0; + unsigned long flags; + struct netdev_hw_addr *ha; + int i; + + spin_lock_irqsave(&adapter->lock, flags); + + /* Before we modify the platform-independent filter flags, store them + * locally. This allows us to determine if anything's changed and if + * we even need to bother the hardware + */ + packet_filter = adapter->packet_filter; + + /* Clear the 'multicast' flag locally; because we only have a single + * flag to check multicast, and multiple multicast addresses can be + * set, this is the easiest way to determine if more than one + * multicast address is being set. + */ + packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; + + /* Check the net_device flags and set the device independent flags + * accordingly + */ + + if (netdev->flags & IFF_PROMISC) + adapter->packet_filter |= ET131X_PACKET_TYPE_PROMISCUOUS; + else + adapter->packet_filter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; + + if (netdev->flags & IFF_ALLMULTI) + adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; + + if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) + adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; + + if (netdev_mc_count(netdev) < 1) { + adapter->packet_filter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; + adapter->packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; + } else + adapter->packet_filter |= ET131X_PACKET_TYPE_MULTICAST; + + /* Set values in the private adapter struct */ + i = 0; + netdev_for_each_mc_addr(ha, netdev) { + if (i == NIC_MAX_MCAST_LIST) + break; + memcpy(adapter->multicast_list[i++], ha->addr, ETH_ALEN); + } + adapter->multicast_addr_count = i; + + /* Are the new flags different from the previous ones? If not, then no + * action is required + * + * NOTE - This block will always update the multicast_list with the + * hardware, even if the addresses aren't the same. + */ + if (packet_filter != adapter->packet_filter) { + /* Call the device's filter function */ + et131x_set_packet_filter(adapter); + } + spin_unlock_irqrestore(&adapter->lock, flags); +} + +/** + * et131x_tx - The handler to tx a packet on the device + * @skb: data to be Tx'd + * @netdev: device on which data is to be Tx'd + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) +{ + int status = 0; + + /* Save the timestamp for the TX timeout watchdog */ + netdev->trans_start = jiffies; + + /* Call the device-specific data Tx routine */ + status = et131x_send_packets(skb, netdev); + + /* Check status and manage the netif queue if necessary */ + if (status != 0) { + if (status == -ENOMEM) { + /* Put the queue to sleep until resources are + * available + */ + netif_stop_queue(netdev); + status = NETDEV_TX_BUSY; + } else { + status = NETDEV_TX_OK; + } + } + return status; +} + +/** + * et131x_tx_timeout - Timeout handler + * @netdev: a pointer to a net_device struct representing the device + * + * The handler called when a Tx request times out. The timeout period is + * specified by the 'tx_timeo" element in the net_device structure (see + * et131x_alloc_device() to see how this value is set). + */ +static void et131x_tx_timeout(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + struct tcb *tcb; + unsigned long flags; + + /* If the device is closed, ignore the timeout */ + if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)) + return; + + /* Any nonrecoverable hardware error? + * Checks adapter->flags for any failure in phy reading + */ + if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR) + return; + + /* Hardware failure? */ + if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) { + dev_err(&adapter->pdev->dev, "hardware error - reset\n"); + return; + } + + /* Is send stuck? */ + spin_lock_irqsave(&adapter->tcb_send_qlock, flags); + + tcb = adapter->tx_ring.send_head; + + if (tcb != NULL) { + tcb->count++; + + if (tcb->count > NIC_SEND_HANG_THRESHOLD) { + spin_unlock_irqrestore(&adapter->tcb_send_qlock, + flags); + + dev_warn(&adapter->pdev->dev, + "Send stuck - reset. tcb->WrIndex %x, flags 0x%08x\n", + tcb->index, + tcb->flags); + + adapter->net_stats.tx_errors++; + + /* perform reset of tx/rx */ + et131x_disable_txrx(netdev); + et131x_enable_txrx(netdev); + return; + } + } + + spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); +} + +/** + * et131x_change_mtu - The handler called to change the MTU for the device + * @netdev: device whose MTU is to be changed + * @new_mtu: the desired MTU + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static int et131x_change_mtu(struct net_device *netdev, int new_mtu) +{ + int result = 0; + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Make sure the requested MTU is valid */ + if (new_mtu < 64 || new_mtu > 9216) + return -EINVAL; + + et131x_disable_txrx(netdev); + et131x_handle_send_interrupt(adapter); + et131x_handle_recv_interrupt(adapter); + + /* Set the new MTU */ + netdev->mtu = new_mtu; + + /* Free Rx DMA memory */ + et131x_adapter_memory_free(adapter); + + /* Set the config parameter for Jumbo Packet support */ + adapter->registry_jumbo_packet = new_mtu + 14; + et131x_soft_reset(adapter); + + /* Alloc and init Rx DMA memory */ + result = et131x_adapter_memory_alloc(adapter); + if (result != 0) { + dev_warn(&adapter->pdev->dev, + "Change MTU failed; couldn't re-alloc DMA memory\n"); + return result; + } + + et131x_init_send(adapter); + + et131x_hwaddr_init(adapter); + memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); + + /* Init the device with the new settings */ + et131x_adapter_setup(adapter); + + et131x_enable_txrx(netdev); + + return result; +} + +/** + * et131x_set_mac_addr - handler to change the MAC address for the device + * @netdev: device whose MAC is to be changed + * @new_mac: the desired MAC address + * + * Returns 0 on success, errno on failure (as defined in errno.h) + * + * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14 + */ +static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) +{ + int result = 0; + struct et131x_adapter *adapter = netdev_priv(netdev); + struct sockaddr *address = new_mac; + + /* begin blux */ + + if (adapter == NULL) + return -ENODEV; + + /* Make sure the requested MAC is valid */ + if (!is_valid_ether_addr(address->sa_data)) + return -EINVAL; + + et131x_disable_txrx(netdev); + et131x_handle_send_interrupt(adapter); + et131x_handle_recv_interrupt(adapter); + + /* Set the new MAC */ + /* netdev->set_mac_address = &new_mac; */ + + memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len); + + printk(KERN_INFO "%s: Setting MAC address to %pM\n", + netdev->name, netdev->dev_addr); + + /* Free Rx DMA memory */ + et131x_adapter_memory_free(adapter); + + et131x_soft_reset(adapter); + + /* Alloc and init Rx DMA memory */ + result = et131x_adapter_memory_alloc(adapter); + if (result != 0) { + dev_err(&adapter->pdev->dev, + "Change MAC failed; couldn't re-alloc DMA memory\n"); + return result; + } + + et131x_init_send(adapter); + + et131x_hwaddr_init(adapter); + + /* Init the device with the new settings */ + et131x_adapter_setup(adapter); + + et131x_enable_txrx(netdev); + + return result; +} + +static const struct net_device_ops et131x_netdev_ops = { + .ndo_open = et131x_open, + .ndo_stop = et131x_close, + .ndo_start_xmit = et131x_tx, + .ndo_set_multicast_list = et131x_multicast, + .ndo_tx_timeout = et131x_tx_timeout, + .ndo_change_mtu = et131x_change_mtu, + .ndo_set_mac_address = et131x_set_mac_addr, + .ndo_validate_addr = eth_validate_addr, + .ndo_get_stats = et131x_stats, + .ndo_do_ioctl = et131x_ioctl, +}; + +/** + * et131x_device_alloc + * + * Returns pointer to the allocated and initialized net_device struct for + * this device. + * + * Create instances of net_device and wl_private for the new adapter and + * register the device's entry points in the net_device structure. + */ +struct net_device *et131x_device_alloc(void) +{ + struct net_device *netdev; + + /* Alloc net_device and adapter structs */ + netdev = alloc_etherdev(sizeof(struct et131x_adapter)); + + if (!netdev) { + printk(KERN_ERR "et131x: Alloc of net_device struct failed\n"); + return NULL; + } + + /* + * Setup the function registration table (and other data) for a + * net_device + */ + netdev->watchdog_timeo = ET131X_TX_TIMEOUT; + netdev->netdev_ops = &et131x_netdev_ops; + + /* Poll? */ + /* netdev->poll = &et131x_poll; */ + /* netdev->poll_controller = &et131x_poll_controller; */ + return netdev; +} + diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 24570ca8039..0531414f32d 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -1,6 +1,4 @@ /* - * Merged from files - * * Copyright © 2005 Agere Systems Inc. * All rights reserved. * http://www.agere.com @@ -51,6 +49,66 @@ #define DRIVER_NAME "et131x" #define DRIVER_VERSION "v2.0" +/* EEPROM defines */ + +/* LBCIF Register Groups (addressed via 32-bit offsets) */ +#define LBCIF_DWORD0_GROUP 0xAC +#define LBCIF_DWORD1_GROUP 0xB0 + +/* LBCIF Registers (addressed via 8-bit offsets) */ +#define LBCIF_ADDRESS_REGISTER 0xAC +#define LBCIF_DATA_REGISTER 0xB0 +#define LBCIF_CONTROL_REGISTER 0xB1 +#define LBCIF_STATUS_REGISTER 0xB2 + +/* LBCIF Control Register Bits */ +#define LBCIF_CONTROL_SEQUENTIAL_READ 0x01 +#define LBCIF_CONTROL_PAGE_WRITE 0x02 +#define LBCIF_CONTROL_EEPROM_RELOAD 0x08 +#define LBCIF_CONTROL_TWO_BYTE_ADDR 0x20 +#define LBCIF_CONTROL_I2C_WRITE 0x40 +#define LBCIF_CONTROL_LBCIF_ENABLE 0x80 + +/* LBCIF Status Register Bits */ +#define LBCIF_STATUS_PHY_QUEUE_AVAIL 0x01 +#define LBCIF_STATUS_I2C_IDLE 0x02 +#define LBCIF_STATUS_ACK_ERROR 0x04 +#define LBCIF_STATUS_GENERAL_ERROR 0x08 +#define LBCIF_STATUS_CHECKSUM_ERROR 0x40 +#define LBCIF_STATUS_EEPROM_PRESENT 0x80 + +/* Miscellaneous Constraints */ +#define MAX_NUM_REGISTER_POLLS 1000 +#define MAX_NUM_WRITE_RETRIES 2 + +/* MAC defines */ +#define COUNTER_WRAP_16_BIT 0x10000 +#define COUNTER_WRAP_12_BIT 0x1000 + +/* PCI defines */ +#define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */ +#define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ + +/* ISR defines */ +/* + * For interrupts, normal running is: + * rxdma_xfr_done, phy_interrupt, mac_stat_interrupt, + * watchdog_interrupt & txdma_xfer_done + * + * In both cases, when flow control is enabled for either Tx or bi-direction, + * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the + * buffer rings are running low. + */ +#define INT_MASK_DISABLE 0xffffffff + +/* NOTE: Masking out MAC_STAT Interrupt for now... + * #define INT_MASK_ENABLE 0xfff6bf17 + * #define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7 + */ +#define INT_MASK_ENABLE 0xfffebf17 +#define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 + + /* et131x_eeprom.c */ int et131x_init_eeprom(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c deleted file mode 100644 index ff95a3e8cb0..00000000000 --- a/drivers/staging/et131x/et131x_ethtool.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2011 Mark Einon - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include -#include - -#include "et131x_adapter.h" -#include "et1310_phy.h" -#include "et131x.h" - -static int et131x_get_settings(struct net_device *netdev, - struct ethtool_cmd *cmd) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - return phy_ethtool_gset(adapter->phydev, cmd); -} - -static int et131x_set_settings(struct net_device *netdev, - struct ethtool_cmd *cmd) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - return phy_ethtool_sset(adapter->phydev, cmd); -} - -static int et131x_get_regs_len(struct net_device *netdev) -{ -#define ET131X_REGS_LEN 256 - return ET131X_REGS_LEN * sizeof(u32); -} - -static void et131x_get_regs(struct net_device *netdev, - struct ethtool_regs *regs, void *regs_data) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - struct address_map __iomem *aregs = adapter->regs; - u32 *regs_buff = regs_data; - u32 num = 0; - - memset(regs_data, 0, et131x_get_regs_len(netdev)); - - regs->version = (1 << 24) | (adapter->pdev->revision << 16) | - adapter->pdev->device; - - /* PHY regs */ - et131x_mii_read(adapter, MII_BMCR, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_BMSR, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_PHYSID1, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_PHYSID2, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_ADVERTISE, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_LPA, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_EXPANSION, (u16 *)®s_buff[num++]); - /* Autoneg next page transmit reg */ - et131x_mii_read(adapter, 0x07, (u16 *)®s_buff[num++]); - /* Link partner next page reg */ - et131x_mii_read(adapter, 0x08, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_CTRL1000, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_STAT1000, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_ESTATUS, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_CONFIG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_PHY_CONTROL, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_INTERRUPT_MASK, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_PHY_STATUS, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LED_1, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LED_2, (u16 *)®s_buff[num++]); - - /* Global regs */ - regs_buff[num++] = readl(&aregs->global.txq_start_addr); - regs_buff[num++] = readl(&aregs->global.txq_end_addr); - regs_buff[num++] = readl(&aregs->global.rxq_start_addr); - regs_buff[num++] = readl(&aregs->global.rxq_end_addr); - regs_buff[num++] = readl(&aregs->global.pm_csr); - regs_buff[num++] = adapter->stats.interrupt_status; - regs_buff[num++] = readl(&aregs->global.int_mask); - regs_buff[num++] = readl(&aregs->global.int_alias_clr_en); - regs_buff[num++] = readl(&aregs->global.int_status_alias); - regs_buff[num++] = readl(&aregs->global.sw_reset); - regs_buff[num++] = readl(&aregs->global.slv_timer); - regs_buff[num++] = readl(&aregs->global.msi_config); - regs_buff[num++] = readl(&aregs->global.loopback); - regs_buff[num++] = readl(&aregs->global.watchdog_timer); - - /* TXDMA regs */ - regs_buff[num++] = readl(&aregs->txdma.csr); - regs_buff[num++] = readl(&aregs->txdma.pr_base_hi); - regs_buff[num++] = readl(&aregs->txdma.pr_base_lo); - regs_buff[num++] = readl(&aregs->txdma.pr_num_des); - regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr); - regs_buff[num++] = readl(&aregs->txdma.txq_wr_addr_ext); - regs_buff[num++] = readl(&aregs->txdma.txq_rd_addr); - regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_hi); - regs_buff[num++] = readl(&aregs->txdma.dma_wb_base_lo); - regs_buff[num++] = readl(&aregs->txdma.service_request); - regs_buff[num++] = readl(&aregs->txdma.service_complete); - regs_buff[num++] = readl(&aregs->txdma.cache_rd_index); - regs_buff[num++] = readl(&aregs->txdma.cache_wr_index); - regs_buff[num++] = readl(&aregs->txdma.tx_dma_error); - regs_buff[num++] = readl(&aregs->txdma.desc_abort_cnt); - regs_buff[num++] = readl(&aregs->txdma.payload_abort_cnt); - regs_buff[num++] = readl(&aregs->txdma.writeback_abort_cnt); - regs_buff[num++] = readl(&aregs->txdma.desc_timeout_cnt); - regs_buff[num++] = readl(&aregs->txdma.payload_timeout_cnt); - regs_buff[num++] = readl(&aregs->txdma.writeback_timeout_cnt); - regs_buff[num++] = readl(&aregs->txdma.desc_error_cnt); - regs_buff[num++] = readl(&aregs->txdma.payload_error_cnt); - regs_buff[num++] = readl(&aregs->txdma.writeback_error_cnt); - regs_buff[num++] = readl(&aregs->txdma.dropped_tlp_cnt); - regs_buff[num++] = readl(&aregs->txdma.new_service_complete); - regs_buff[num++] = readl(&aregs->txdma.ethernet_packet_cnt); - - /* RXDMA regs */ - regs_buff[num++] = readl(&aregs->rxdma.csr); - regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_hi); - regs_buff[num++] = readl(&aregs->rxdma.dma_wb_base_lo); - regs_buff[num++] = readl(&aregs->rxdma.num_pkt_done); - regs_buff[num++] = readl(&aregs->rxdma.max_pkt_time); - regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr); - regs_buff[num++] = readl(&aregs->rxdma.rxq_rd_addr_ext); - regs_buff[num++] = readl(&aregs->rxdma.rxq_wr_addr); - regs_buff[num++] = readl(&aregs->rxdma.psr_base_hi); - regs_buff[num++] = readl(&aregs->rxdma.psr_base_lo); - regs_buff[num++] = readl(&aregs->rxdma.psr_num_des); - regs_buff[num++] = readl(&aregs->rxdma.psr_avail_offset); - regs_buff[num++] = readl(&aregs->rxdma.psr_full_offset); - regs_buff[num++] = readl(&aregs->rxdma.psr_access_index); - regs_buff[num++] = readl(&aregs->rxdma.psr_min_des); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_lo); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_base_hi); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_num_des); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_avail_offset); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_full_offset); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_rd_index); - regs_buff[num++] = readl(&aregs->rxdma.fbr0_min_des); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_lo); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_base_hi); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_num_des); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_avail_offset); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_full_offset); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_rd_index); - regs_buff[num++] = readl(&aregs->rxdma.fbr1_min_des); -} - -#define ET131X_DRVINFO_LEN 32 /* value from ethtool.h */ -static void et131x_get_drvinfo(struct net_device *netdev, - struct ethtool_drvinfo *info) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - strncpy(info->driver, DRIVER_NAME, ET131X_DRVINFO_LEN); - strncpy(info->version, DRIVER_VERSION, ET131X_DRVINFO_LEN); - strncpy(info->bus_info, pci_name(adapter->pdev), ET131X_DRVINFO_LEN); -} - -static struct ethtool_ops et131x_ethtool_ops = { - .get_settings = et131x_get_settings, - .set_settings = et131x_set_settings, - .get_drvinfo = et131x_get_drvinfo, - .get_regs_len = et131x_get_regs_len, - .get_regs = et131x_get_regs, - .get_link = ethtool_op_get_link, -}; - -void et131x_set_ethtool_ops(struct net_device *netdev) -{ - SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops); -} - diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c deleted file mode 100644 index 45ce8321f31..00000000000 --- a/drivers/staging/et131x/et131x_initpci.c +++ /dev/null @@ -1,950 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et131x_initpci.c - Routines and data used to register the driver with the - * PCI (and PCI Express) subsystem, as well as basic driver - * init and startup. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" - -#include "et131x_adapter.h" - -#include "et1310_address_map.h" -#include "et1310_tx.h" -#include "et1310_rx.h" -#include "et131x.h" - -#define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */ -#define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ - -/** - * et131x_hwaddr_init - set up the MAC Address on the ET1310 - * @adapter: pointer to our private adapter structure - */ -void et131x_hwaddr_init(struct et131x_adapter *adapter) -{ - /* If have our default mac from init and no mac address from - * EEPROM then we need to generate the last octet and set it on the - * device - */ - if (adapter->rom_addr[0] == 0x00 && - adapter->rom_addr[1] == 0x00 && - adapter->rom_addr[2] == 0x00 && - adapter->rom_addr[3] == 0x00 && - adapter->rom_addr[4] == 0x00 && - adapter->rom_addr[5] == 0x00) { - /* - * We need to randomly generate the last octet so we - * decrease our chances of setting the mac address to - * same as another one of our cards in the system - */ - get_random_bytes(&adapter->addr[5], 1); - /* - * We have the default value in the register we are - * working with so we need to copy the current - * address into the permanent address - */ - memcpy(adapter->rom_addr, - adapter->addr, ETH_ALEN); - } else { - /* We do not have an override address, so set the - * current address to the permanent address and add - * it to the device - */ - memcpy(adapter->addr, - adapter->rom_addr, ETH_ALEN); - } -} - -/** - * et131x_pci_init - initial PCI setup - * @adapter: pointer to our private adapter structure - * @pdev: our PCI device - * - * Perform the initial setup of PCI registers and if possible initialise - * the MAC address. At this point the I/O registers have yet to be mapped - */ -static int et131x_pci_init(struct et131x_adapter *adapter, - struct pci_dev *pdev) -{ - int i; - u8 max_payload; - u8 read_size_reg; - - if (et131x_init_eeprom(adapter) < 0) - return -EIO; - - /* Let's set up the PORT LOGIC Register. First we need to know what - * the max_payload_size is - */ - if (pci_read_config_byte(pdev, ET1310_PCI_MAX_PYLD, &max_payload)) { - dev_err(&pdev->dev, - "Could not read PCI config space for Max Payload Size\n"); - return -EIO; - } - - /* Program the Ack/Nak latency and replay timers */ - max_payload &= 0x07; /* Only the lower 3 bits are valid */ - - if (max_payload < 2) { - static const u16 acknak[2] = { 0x76, 0xD0 }; - static const u16 replay[2] = { 0x1E0, 0x2ED }; - - if (pci_write_config_word(pdev, ET1310_PCI_ACK_NACK, - acknak[max_payload])) { - dev_err(&pdev->dev, - "Could not write PCI config space for ACK/NAK\n"); - return -EIO; - } - if (pci_write_config_word(pdev, ET1310_PCI_REPLAY, - replay[max_payload])) { - dev_err(&pdev->dev, - "Could not write PCI config space for Replay Timer\n"); - return -EIO; - } - } - - /* l0s and l1 latency timers. We are using default values. - * Representing 001 for L0s and 010 for L1 - */ - if (pci_write_config_byte(pdev, ET1310_PCI_L0L1LATENCY, 0x11)) { - dev_err(&pdev->dev, - "Could not write PCI config space for Latency Timers\n"); - return -EIO; - } - - /* Change the max read size to 2k */ - if (pci_read_config_byte(pdev, 0x51, &read_size_reg)) { - dev_err(&pdev->dev, - "Could not read PCI config space for Max read size\n"); - return -EIO; - } - - read_size_reg &= 0x8f; - read_size_reg |= 0x40; - - if (pci_write_config_byte(pdev, 0x51, read_size_reg)) { - dev_err(&pdev->dev, - "Could not write PCI config space for Max read size\n"); - return -EIO; - } - - /* Get MAC address from config space if an eeprom exists, otherwise - * the MAC address there will not be valid - */ - if (!adapter->has_eeprom) { - et131x_hwaddr_init(adapter); - return 0; - } - - for (i = 0; i < ETH_ALEN; i++) { - if (pci_read_config_byte(pdev, ET1310_PCI_MAC_ADDRESS + i, - adapter->rom_addr + i)) { - dev_err(&pdev->dev, "Could not read PCI config space for MAC address\n"); - return -EIO; - } - } - memcpy(adapter->addr, adapter->rom_addr, ETH_ALEN); - return 0; -} - -/** - * et131x_error_timer_handler - * @data: timer-specific variable; here a pointer to our adapter structure - * - * The routine called when the error timer expires, to track the number of - * recurring errors. - */ -void et131x_error_timer_handler(unsigned long data) -{ - struct et131x_adapter *adapter = (struct et131x_adapter *) data; - struct phy_device *phydev = adapter->phydev; - - if (et1310_in_phy_coma(adapter)) { - /* Bring the device immediately out of coma, to - * prevent it from sleeping indefinitely, this - * mechanism could be improved! */ - et1310_disable_phy_coma(adapter); - adapter->boot_coma = 20; - } else { - et1310_update_macstat_host_counters(adapter); - } - - if (!phydev->link && adapter->boot_coma < 11) - adapter->boot_coma++; - - if (adapter->boot_coma == 10) { - if (!phydev->link) { - if (!et1310_in_phy_coma(adapter)) { - /* NOTE - This was originally a 'sync with - * interrupt'. How to do that under Linux? - */ - et131x_enable_interrupts(adapter); - et1310_enable_phy_coma(adapter); - } - } - } - - /* This is a periodic timer, so reschedule */ - mod_timer(&adapter->error_timer, jiffies + - TX_ERROR_PERIOD * HZ / 1000); -} - -/** - * et131x_configure_global_regs - configure JAGCore global regs - * @adapter: pointer to our adapter structure - * - * Used to configure the global registers on the JAGCore - */ -void et131x_configure_global_regs(struct et131x_adapter *adapter) -{ - struct global_regs __iomem *regs = &adapter->regs->global; - - writel(0, ®s->rxq_start_addr); - writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); - - if (adapter->registry_jumbo_packet < 2048) { - /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word - * block of RAM that the driver can split between Tx - * and Rx as it desires. Our default is to split it - * 50/50: - */ - writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); - writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); - } else if (adapter->registry_jumbo_packet < 8192) { - /* For jumbo packets > 2k but < 8k, split 50-50. */ - writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); - writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); - } else { - /* 9216 is the only packet size greater than 8k that - * is available. The Tx buffer has to be big enough - * for one whole packet on the Tx side. We'll make - * the Tx 9408, and give the rest to Rx - */ - writel(0x01b3, ®s->rxq_end_addr); - writel(0x01b4, ®s->txq_start_addr); - } - - /* Initialize the loopback register. Disable all loopbacks. */ - writel(0, ®s->loopback); - - /* MSI Register */ - writel(0, ®s->msi_config); - - /* By default, disable the watchdog timer. It will be enabled when - * a packet is queued. - */ - writel(0, ®s->watchdog_timer); -} - -/** - * et131x_adapter_setup - Set the adapter up as per cassini+ documentation - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -void et131x_adapter_setup(struct et131x_adapter *adapter) -{ - /* Configure the JAGCore */ - et131x_configure_global_regs(adapter); - - et1310_config_mac_regs1(adapter); - - /* Configure the MMC registers */ - /* All we need to do is initialize the Memory Control Register */ - writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl); - - et1310_config_rxmac_regs(adapter); - et1310_config_txmac_regs(adapter); - - et131x_config_rx_dma_regs(adapter); - et131x_config_tx_dma_regs(adapter); - - et1310_config_macstat_regs(adapter); - - et1310_phy_power_down(adapter, 0); - et131x_xcvr_init(adapter); -} - -/** - * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 - * @adapter: pointer to our private adapter structure - */ -void et131x_soft_reset(struct et131x_adapter *adapter) -{ - /* Disable MAC Core */ - writel(0xc00f0000, &adapter->regs->mac.cfg1); - - /* Set everything to a reset value */ - writel(0x7F, &adapter->regs->global.sw_reset); - writel(0x000f0000, &adapter->regs->mac.cfg1); - writel(0x00000000, &adapter->regs->mac.cfg1); -} - -/** - * et131x_align_allocated_memory - Align allocated memory on a given boundary - * @adapter: pointer to our adapter structure - * @phys_addr: pointer to Physical address - * @offset: pointer to the offset variable - * @mask: correct mask - */ -void et131x_align_allocated_memory(struct et131x_adapter *adapter, - uint64_t *phys_addr, - uint64_t *offset, uint64_t mask) -{ - uint64_t new_addr; - - *offset = 0; - - new_addr = *phys_addr & ~mask; - - if (new_addr != *phys_addr) { - /* Move to next aligned block */ - new_addr += mask + 1; - /* Return offset for adjusting virt addr */ - *offset = new_addr - *phys_addr; - /* Return new physical address */ - *phys_addr = new_addr; - } -} - -/** - * et131x_adapter_memory_alloc - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success, errno on failure (as defined in errno.h). - * - * Allocate all the memory blocks for send, receive and others. - */ -int et131x_adapter_memory_alloc(struct et131x_adapter *adapter) -{ - int status; - - /* Allocate memory for the Tx Ring */ - status = et131x_tx_dma_memory_alloc(adapter); - if (status != 0) { - dev_err(&adapter->pdev->dev, - "et131x_tx_dma_memory_alloc FAILED\n"); - return status; - } - /* Receive buffer memory allocation */ - status = et131x_rx_dma_memory_alloc(adapter); - if (status != 0) { - dev_err(&adapter->pdev->dev, - "et131x_rx_dma_memory_alloc FAILED\n"); - et131x_tx_dma_memory_free(adapter); - return status; - } - - /* Init receive data structures */ - status = et131x_init_recv(adapter); - if (status != 0) { - dev_err(&adapter->pdev->dev, - "et131x_init_recv FAILED\n"); - et131x_tx_dma_memory_free(adapter); - et131x_rx_dma_memory_free(adapter); - } - return status; -} - -/** - * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx - * @adapter: pointer to our private adapter structure - */ -void et131x_adapter_memory_free(struct et131x_adapter *adapter) -{ - /* Free DMA memory */ - et131x_tx_dma_memory_free(adapter); - et131x_rx_dma_memory_free(adapter); -} - -static void et131x_adjust_link(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - struct phy_device *phydev = adapter->phydev; - - if (netif_carrier_ok(netdev)) { - adapter->boot_coma = 20; - - if (phydev && phydev->speed == SPEED_10) { - /* - * NOTE - Is there a way to query this without - * TruePHY? - * && TRU_QueryCoreType(adapter->hTruePhy, 0)== - * EMI_TRUEPHY_A13O) { - */ - u16 register18; - - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - ®ister18); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18 | 0x4); - et131x_mii_write(adapter, PHY_INDEX_REG, - register18 | 0x8402); - et131x_mii_write(adapter, PHY_DATA_REG, - register18 | 511); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18); - } - - et1310_config_flow_control(adapter); - - if (phydev && phydev->speed == SPEED_1000 && - adapter->registry_jumbo_packet > 2048) { - u16 reg; - - et131x_mii_read(adapter, PHY_CONFIG, ®); - reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; - reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; - et131x_mii_write(adapter, PHY_CONFIG, reg); - } - - et131x_set_rx_dma_timer(adapter); - et1310_config_mac_regs2(adapter); - } - - if (phydev && phydev->link != adapter->link) { - /* - * Check to see if we are in coma mode and if - * so, disable it because we will not be able - * to read PHY values until we are out. - */ - if (et1310_in_phy_coma(adapter)) - et1310_disable_phy_coma(adapter); - - if (phydev->link) { - adapter->boot_coma = 20; - } else { - dev_warn(&adapter->pdev->dev, - "Link down - cable problem ?\n"); - adapter->boot_coma = 0; - - if (phydev->speed == SPEED_10) { - /* NOTE - Is there a way to query this without - * TruePHY? - * && TRU_QueryCoreType(adapter->hTruePhy, 0) == - * EMI_TRUEPHY_A13O) - */ - u16 register18; - - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - ®ister18); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18 | 0x4); - et131x_mii_write(adapter, PHY_INDEX_REG, - register18 | 0x8402); - et131x_mii_write(adapter, PHY_DATA_REG, - register18 | 511); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18); - } - - /* Free the packets being actively sent & stopped */ - et131x_free_busy_send_packets(adapter); - - /* Re-initialize the send structures */ - et131x_init_send(adapter); - - /* Reset the RFD list and re-start RU */ - et131x_reset_recv(adapter); - - /* - * Bring the device back to the state it was during - * init prior to autonegotiation being complete. This - * way, when we get the auto-neg complete interrupt, - * we can complete init by calling config_mac_regs2. - */ - et131x_soft_reset(adapter); - - /* Setup ET1310 as per the documentation */ - et131x_adapter_setup(adapter); - - /* perform reset of tx/rx */ - et131x_disable_txrx(netdev); - et131x_enable_txrx(netdev); - } - - adapter->link = phydev->link; - - phy_print_status(phydev); - } -} - -static int et131x_mii_probe(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - struct phy_device *phydev = NULL; - - phydev = phy_find_first(adapter->mii_bus); - if (!phydev) { - dev_err(&adapter->pdev->dev, "no PHY found\n"); - return -ENODEV; - } - - phydev = phy_connect(netdev, dev_name(&phydev->dev), - &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII); - - if (IS_ERR(phydev)) { - dev_err(&adapter->pdev->dev, "Could not attach to PHY\n"); - return PTR_ERR(phydev); - } - - phydev->supported &= (SUPPORTED_10baseT_Half - | SUPPORTED_10baseT_Full - | SUPPORTED_100baseT_Half - | SUPPORTED_100baseT_Full - | SUPPORTED_Autoneg - | SUPPORTED_MII - | SUPPORTED_TP); - - if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) - phydev->supported |= SUPPORTED_1000baseT_Full; - - phydev->advertising = phydev->supported; - adapter->phydev = phydev; - - dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " - "(mii_bus:phy_addr=%s)\n", - phydev->drv->name, dev_name(&phydev->dev)); - - return 0; -} - -/** - * et131x_adapter_init - * @adapter: pointer to the private adapter struct - * @pdev: pointer to the PCI device - * - * Initialize the data structures for the et131x_adapter object and link - * them together with the platform provided device structures. - */ -static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, - struct pci_dev *pdev) -{ - static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 }; - - struct et131x_adapter *adapter; - - /* Allocate private adapter struct and copy in relevant information */ - adapter = netdev_priv(netdev); - adapter->pdev = pci_dev_get(pdev); - adapter->netdev = netdev; - - /* Do the same for the netdev struct */ - netdev->irq = pdev->irq; - netdev->base_addr = pci_resource_start(pdev, 0); - - /* Initialize spinlocks here */ - spin_lock_init(&adapter->lock); - spin_lock_init(&adapter->tcb_send_qlock); - spin_lock_init(&adapter->tcb_ready_qlock); - spin_lock_init(&adapter->send_hw_lock); - spin_lock_init(&adapter->rcv_lock); - spin_lock_init(&adapter->rcv_pend_lock); - spin_lock_init(&adapter->fbr_lock); - spin_lock_init(&adapter->phy_lock); - - adapter->registry_jumbo_packet = 1514; /* 1514-9216 */ - - /* Set the MAC address to a default */ - memcpy(adapter->addr, default_mac, ETH_ALEN); - - return adapter; -} - -/** - * et131x_pci_setup - Perform device initialization - * @pdev: a pointer to the device's pci_dev structure - * @ent: this device's entry in the pci_device_id table - * - * Returns 0 on success, errno on failure (as defined in errno.h) - * - * Registered in the pci_driver structure, this function is called when the - * PCI subsystem finds a new PCI device which matches the information - * contained in the pci_device_id table. This routine is the equivalent to - * a device insertion routine. - */ -static int __devinit et131x_pci_setup(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - int result; - int pm_cap; - struct net_device *netdev; - struct et131x_adapter *adapter; - int ii; - - result = pci_enable_device(pdev); - if (result) { - dev_err(&pdev->dev, "pci_enable_device() failed\n"); - goto err_out; - } - - /* Perform some basic PCI checks */ - if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { - dev_err(&pdev->dev, "Can't find PCI device's base address\n"); - goto err_disable; - } - - if (pci_request_regions(pdev, DRIVER_NAME)) { - dev_err(&pdev->dev, "Can't get PCI resources\n"); - goto err_disable; - } - - pci_set_master(pdev); - - /* Query PCI for Power Mgmt Capabilities - * - * NOTE: Now reading PowerMgmt in another location; is this still - * needed? - */ - pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); - if (!pm_cap) { - dev_err(&pdev->dev, - "Cannot find Power Management capabilities\n"); - result = -EIO; - goto err_release_res; - } - - /* Check the DMA addressing support of this device */ - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { - result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); - if (result) { - dev_err(&pdev->dev, - "Unable to obtain 64 bit DMA for consistent allocations\n"); - goto err_release_res; - } - } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); - if (result) { - dev_err(&pdev->dev, - "Unable to obtain 32 bit DMA for consistent allocations\n"); - goto err_release_res; - } - } else { - dev_err(&pdev->dev, "No usable DMA addressing method\n"); - result = -EIO; - goto err_release_res; - } - - /* Allocate netdev and private adapter structs */ - netdev = et131x_device_alloc(); - if (!netdev) { - dev_err(&pdev->dev, "Couldn't alloc netdev struct\n"); - result = -ENOMEM; - goto err_release_res; - } - - SET_NETDEV_DEV(netdev, &pdev->dev); - et131x_set_ethtool_ops(netdev); - - adapter = et131x_adapter_init(netdev, pdev); - - /* Initialise the PCI setup for the device */ - et131x_pci_init(adapter, pdev); - - /* Map the bus-relative registers to system virtual memory */ - adapter->regs = pci_ioremap_bar(pdev, 0); - if (!adapter->regs) { - dev_err(&pdev->dev, "Cannot map device registers\n"); - result = -ENOMEM; - goto err_free_dev; - } - - /* If Phy COMA mode was enabled when we went down, disable it here. */ - writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr); - - /* Issue a global reset to the et1310 */ - et131x_soft_reset(adapter); - - /* Disable all interrupts (paranoid) */ - et131x_disable_interrupts(adapter); - - /* Allocate DMA memory */ - result = et131x_adapter_memory_alloc(adapter); - if (result) { - dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n"); - goto err_iounmap; - } - - /* Init send data structures */ - et131x_init_send(adapter); - - /* Set up the task structure for the ISR's deferred handler */ - INIT_WORK(&adapter->task, et131x_isr_handler); - - /* Copy address into the net_device struct */ - memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); - - /* Init variable for counting how long we do not have link status */ - adapter->boot_coma = 0; - et1310_disable_phy_coma(adapter); - - /* Setup the mii_bus struct */ - adapter->mii_bus = mdiobus_alloc(); - if (!adapter->mii_bus) { - dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); - goto err_mem_free; - } - - adapter->mii_bus->name = "et131x_eth_mii"; - snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", - (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); - adapter->mii_bus->priv = netdev; - adapter->mii_bus->read = et131x_mdio_read; - adapter->mii_bus->write = et131x_mdio_write; - adapter->mii_bus->reset = et131x_mdio_reset; - adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); - if (!adapter->mii_bus->irq) { - dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); - goto err_mdio_free; - } - - for (ii = 0; ii < PHY_MAX_ADDR; ii++) - adapter->mii_bus->irq[ii] = PHY_POLL; - - if (mdiobus_register(adapter->mii_bus)) { - dev_err(&pdev->dev, "failed to register MII bus\n"); - mdiobus_free(adapter->mii_bus); - goto err_mdio_free_irq; - } - - if (et131x_mii_probe(netdev)) { - dev_err(&pdev->dev, "failed to probe MII bus\n"); - goto err_mdio_unregister; - } - - /* Setup et1310 as per the documentation */ - et131x_adapter_setup(adapter); - - /* We can enable interrupts now - * - * NOTE - Because registration of interrupt handler is done in the - * device's open(), defer enabling device interrupts to that - * point - */ - - /* Register the net_device struct with the Linux network layer */ - result = register_netdev(netdev); - if (result != 0) { - dev_err(&pdev->dev, "register_netdev() failed\n"); - goto err_mdio_unregister; - } - - /* Register the net_device struct with the PCI subsystem. Save a copy - * of the PCI config space for this device now that the device has - * been initialized, just in case it needs to be quickly restored. - */ - pci_set_drvdata(pdev, netdev); - pci_save_state(adapter->pdev); - - return result; - -err_mdio_unregister: - mdiobus_unregister(adapter->mii_bus); -err_mdio_free_irq: - kfree(adapter->mii_bus->irq); -err_mdio_free: - mdiobus_free(adapter->mii_bus); -err_mem_free: - et131x_adapter_memory_free(adapter); -err_iounmap: - iounmap(adapter->regs); -err_free_dev: - pci_dev_put(pdev); - free_netdev(netdev); -err_release_res: - pci_release_regions(pdev); -err_disable: - pci_disable_device(pdev); -err_out: - return result; -} - -/** - * et131x_pci_remove - * @pdev: a pointer to the device's pci_dev structure - * - * Registered in the pci_driver structure, this function is called when the - * PCI subsystem detects that a PCI device which matches the information - * contained in the pci_device_id table has been removed. - */ -static void __devexit et131x_pci_remove(struct pci_dev *pdev) -{ - struct net_device *netdev = pci_get_drvdata(pdev); - struct et131x_adapter *adapter = netdev_priv(netdev); - - unregister_netdev(netdev); - mdiobus_unregister(adapter->mii_bus); - kfree(adapter->mii_bus->irq); - mdiobus_free(adapter->mii_bus); - - et131x_adapter_memory_free(adapter); - iounmap(adapter->regs); - pci_dev_put(pdev); - - free_netdev(netdev); - pci_release_regions(pdev); - pci_disable_device(pdev); -} - -#ifdef CONFIG_PM_SLEEP -static int et131x_suspend(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - struct net_device *netdev = pci_get_drvdata(pdev); - - if (netif_running(netdev)) { - netif_device_detach(netdev); - et131x_down(netdev); - pci_save_state(pdev); - } - - return 0; -} - -static int et131x_resume(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - struct net_device *netdev = pci_get_drvdata(pdev); - - if (netif_running(netdev)) { - pci_restore_state(pdev); - et131x_up(netdev); - netif_device_attach(netdev); - } - - return 0; -} - -static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); -#define ET131X_PM_OPS (&et131x_pm_ops) -#else -#define ET131X_PM_OPS NULL -#endif - -static struct pci_device_id et131x_pci_table[] __devinitdata = { - {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0UL}, - {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0UL}, - {0,} -}; - -MODULE_DEVICE_TABLE(pci, et131x_pci_table); - -static struct pci_driver et131x_driver = { - .name = DRIVER_NAME, - .id_table = et131x_pci_table, - .probe = et131x_pci_setup, - .remove = __devexit_p(et131x_pci_remove), - .driver.pm = ET131X_PM_OPS, -}; - -/** - * et131x_init_module - The "main" entry point called on driver initialization - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int __init et131x_init_module(void) -{ - return pci_register_driver(&et131x_driver); -} - -/** - * et131x_cleanup_module - The entry point called on driver cleanup - */ -static void __exit et131x_cleanup_module(void) -{ - pci_unregister_driver(&et131x_driver); -} - -module_init(et131x_init_module); -module_exit(et131x_cleanup_module); - -MODULE_AUTHOR("Victor Soriano "); -MODULE_AUTHOR("Mark Einon "); -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " - "for the ET1310 by Agere Systems"); diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c deleted file mode 100644 index cf8665b1291..00000000000 --- a/drivers/staging/et131x/et131x_isr.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et131x_isr.c - File which contains the ISR, ISR handler, and related routines - * for processing interrupts from the device. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et131x_adapter.h" -#include "et131x.h" - -/* - * For interrupts, normal running is: - * rxdma_xfr_done, phy_interrupt, mac_stat_interrupt, - * watchdog_interrupt & txdma_xfer_done - * - * In both cases, when flow control is enabled for either Tx or bi-direction, - * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the - * buffer rings are running low. - */ -#define INT_MASK_DISABLE 0xffffffff - -/* NOTE: Masking out MAC_STAT Interrupt for now... - * #define INT_MASK_ENABLE 0xfff6bf17 - * #define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7 - */ -#define INT_MASK_ENABLE 0xfffebf17 -#define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 - - -/** - * et131x_enable_interrupts - enable interrupt - * @adapter: et131x device - * - * Enable the appropriate interrupts on the ET131x according to our - * configuration - */ - -void et131x_enable_interrupts(struct et131x_adapter *adapter) -{ - u32 mask; - - /* Enable all global interrupts */ - if (adapter->flowcontrol == FLOW_TXONLY || - adapter->flowcontrol == FLOW_BOTH) - mask = INT_MASK_ENABLE; - else - mask = INT_MASK_ENABLE_NO_FLOW; - - writel(mask, &adapter->regs->global.int_mask); -} - -/** - * et131x_disable_interrupts - interrupt disable - * @adapter: et131x device - * - * Block all interrupts from the et131x device at the device itself - */ - -void et131x_disable_interrupts(struct et131x_adapter *adapter) -{ - /* Disable all global interrupts */ - writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); -} - - -/** - * et131x_isr - The Interrupt Service Routine for the driver. - * @irq: the IRQ on which the interrupt was received. - * @dev_id: device-specific info (here a pointer to a net_device struct) - * - * Returns a value indicating if the interrupt was handled. - */ - -irqreturn_t et131x_isr(int irq, void *dev_id) -{ - bool handled = true; - struct net_device *netdev = (struct net_device *)dev_id; - struct et131x_adapter *adapter = NULL; - u32 status; - - if (!netif_device_present(netdev)) { - handled = false; - goto out; - } - - adapter = netdev_priv(netdev); - - /* If the adapter is in low power state, then it should not - * recognize any interrupt - */ - - /* Disable Device Interrupts */ - et131x_disable_interrupts(adapter); - - /* Get a copy of the value in the interrupt status register - * so we can process the interrupting section - */ - status = readl(&adapter->regs->global.int_status); - - if (adapter->flowcontrol == FLOW_TXONLY || - adapter->flowcontrol == FLOW_BOTH) { - status &= ~INT_MASK_ENABLE; - } else { - status &= ~INT_MASK_ENABLE_NO_FLOW; - } - - /* Make sure this is our interrupt */ - if (!status) { - handled = false; - et131x_enable_interrupts(adapter); - goto out; - } - - /* This is our interrupt, so process accordingly */ - - if (status & ET_INTR_WATCHDOG) { - struct tcb *tcb = adapter->tx_ring.send_head; - - if (tcb) - if (++tcb->stale > 1) - status |= ET_INTR_TXDMA_ISR; - - if (adapter->rx_ring.unfinished_receives) - status |= ET_INTR_RXDMA_XFR_DONE; - else if (tcb == NULL) - writel(0, &adapter->regs->global.watchdog_timer); - - status &= ~ET_INTR_WATCHDOG; - } - - if (status == 0) { - /* This interrupt has in some way been "handled" by - * the ISR. Either it was a spurious Rx interrupt, or - * it was a Tx interrupt that has been filtered by - * the ISR. - */ - et131x_enable_interrupts(adapter); - goto out; - } - - /* We need to save the interrupt status value for use in our - * DPC. We will clear the software copy of that in that - * routine. - */ - adapter->stats.interrupt_status = status; - - /* Schedule the ISR handler as a bottom-half task in the - * kernel's tq_immediate queue, and mark the queue for - * execution - */ - schedule_work(&adapter->task); -out: - return IRQ_RETVAL(handled); -} - -/** - * et131x_isr_handler - The ISR handler - * @p_adapter, a pointer to the device's private adapter structure - * - * scheduled to run in a deferred context by the ISR. This is where the ISR's - * work actually gets done. - */ -void et131x_isr_handler(struct work_struct *work) -{ - struct et131x_adapter *adapter = - container_of(work, struct et131x_adapter, task); - u32 status = adapter->stats.interrupt_status; - struct address_map __iomem *iomem = adapter->regs; - - /* - * These first two are by far the most common. Once handled, we clear - * their two bits in the status word. If the word is now zero, we - * exit. - */ - /* Handle all the completed Transmit interrupts */ - if (status & ET_INTR_TXDMA_ISR) - et131x_handle_send_interrupt(adapter); - - /* Handle all the completed Receives interrupts */ - if (status & ET_INTR_RXDMA_XFR_DONE) - et131x_handle_recv_interrupt(adapter); - - status &= 0xffffffd7; - - if (status) { - /* Handle the TXDMA Error interrupt */ - if (status & ET_INTR_TXDMA_ERR) { - u32 txdma_err; - - /* Following read also clears the register (COR) */ - txdma_err = readl(&iomem->txdma.tx_dma_error); - - dev_warn(&adapter->pdev->dev, - "TXDMA_ERR interrupt, error = %d\n", - txdma_err); - } - - /* Handle Free Buffer Ring 0 and 1 Low interrupt */ - if (status & - (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) { - /* - * This indicates the number of unused buffers in - * RXDMA free buffer ring 0 is <= the limit you - * programmed. Free buffer resources need to be - * returned. Free buffers are consumed as packets - * are passed from the network to the host. The host - * becomes aware of the packets from the contents of - * the packet status ring. This ring is queried when - * the packet done interrupt occurs. Packets are then - * passed to the OS. When the OS is done with the - * packets the resources can be returned to the - * ET1310 for re-use. This interrupt is one method of - * returning resources. - */ - - /* If the user has flow control on, then we will - * send a pause packet, otherwise just exit - */ - if (adapter->flowcontrol == FLOW_TXONLY || - adapter->flowcontrol == FLOW_BOTH) { - u32 pm_csr; - - /* Tell the device to send a pause packet via - * the back pressure register (bp req and - * bp xon/xoff) - */ - pm_csr = readl(&iomem->global.pm_csr); - if (!et1310_in_phy_coma(adapter)) - writel(3, &iomem->txmac.bp_ctrl); - } - } - - /* Handle Packet Status Ring Low Interrupt */ - if (status & ET_INTR_RXDMA_STAT_LOW) { - - /* - * Same idea as with the two Free Buffer Rings. - * Packets going from the network to the host each - * consume a free buffer resource and a packet status - * resource. These resoures are passed to the OS. - * When the OS is done with the resources, they need - * to be returned to the ET1310. This is one method - * of returning the resources. - */ - } - - /* Handle RXDMA Error Interrupt */ - if (status & ET_INTR_RXDMA_ERR) { - /* - * The rxdma_error interrupt is sent when a time-out - * on a request issued by the JAGCore has occurred or - * a completion is returned with an un-successful - * status. In both cases the request is considered - * complete. The JAGCore will automatically re-try the - * request in question. Normally information on events - * like these are sent to the host using the "Advanced - * Error Reporting" capability. This interrupt is - * another way of getting similar information. The - * only thing required is to clear the interrupt by - * reading the ISR in the global resources. The - * JAGCore will do a re-try on the request. Normally - * you should never see this interrupt. If you start - * to see this interrupt occurring frequently then - * something bad has occurred. A reset might be the - * thing to do. - */ - /* TRAP();*/ - - dev_warn(&adapter->pdev->dev, - "RxDMA_ERR interrupt, error %x\n", - readl(&iomem->txmac.tx_test)); - } - - /* Handle the Wake on LAN Event */ - if (status & ET_INTR_WOL) { - /* - * This is a secondary interrupt for wake on LAN. - * The driver should never see this, if it does, - * something serious is wrong. We will TRAP the - * message when we are in DBG mode, otherwise we - * will ignore it. - */ - dev_err(&adapter->pdev->dev, "WAKE_ON_LAN interrupt\n"); - } - - /* Let's move on to the TxMac */ - if (status & ET_INTR_TXMAC) { - u32 err = readl(&iomem->txmac.err); - - /* - * When any of the errors occur and TXMAC generates - * an interrupt to report these errors, it usually - * means that TXMAC has detected an error in the data - * stream retrieved from the on-chip Tx Q. All of - * these errors are catastrophic and TXMAC won't be - * able to recover data when these errors occur. In - * a nutshell, the whole Tx path will have to be reset - * and re-configured afterwards. - */ - dev_warn(&adapter->pdev->dev, - "TXMAC interrupt, error 0x%08x\n", - err); - - /* If we are debugging, we want to see this error, - * otherwise we just want the device to be reset and - * continue - */ - } - - /* Handle RXMAC Interrupt */ - if (status & ET_INTR_RXMAC) { - /* - * These interrupts are catastrophic to the device, - * what we need to do is disable the interrupts and - * set the flag to cause us to reset so we can solve - * this issue. - */ - /* MP_SET_FLAG( adapter, - fMP_ADAPTER_HARDWARE_ERROR); */ - - dev_warn(&adapter->pdev->dev, - "RXMAC interrupt, error 0x%08x. Requesting reset\n", - readl(&iomem->rxmac.err_reg)); - - dev_warn(&adapter->pdev->dev, - "Enable 0x%08x, Diag 0x%08x\n", - readl(&iomem->rxmac.ctrl), - readl(&iomem->rxmac.rxq_diag)); - - /* - * If we are debugging, we want to see this error, - * otherwise we just want the device to be reset and - * continue - */ - } - - /* Handle MAC_STAT Interrupt */ - if (status & ET_INTR_MAC_STAT) { - /* - * This means at least one of the un-masked counters - * in the MAC_STAT block has rolled over. Use this - * to maintain the top, software managed bits of the - * counter(s). - */ - et1310_handle_macstat_interrupt(adapter); - } - - /* Handle SLV Timeout Interrupt */ - if (status & ET_INTR_SLV_TIMEOUT) { - /* - * This means a timeout has occurred on a read or - * write request to one of the JAGCore registers. The - * Global Resources block has terminated the request - * and on a read request, returned a "fake" value. - * The most likely reasons are: Bad Address or the - * addressed module is in a power-down state and - * can't respond. - */ - } - } - et131x_enable_interrupts(adapter); -} diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c deleted file mode 100644 index 62070cff76f..00000000000 --- a/drivers/staging/et131x/et131x_netdev.c +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et131x_netdev.c - Routines and data required by all Linux network devices. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#include "et131x_defs.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "et1310_phy.h" -#include "et1310_tx.h" -#include "et131x_adapter.h" -#include "et131x.h" - -/** - * et131x_stats - Return the current device statistics. - * @netdev: device whose stats are being queried - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static struct net_device_stats *et131x_stats(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - struct net_device_stats *stats = &adapter->net_stats; - struct ce_stats *devstat = &adapter->stats; - - stats->rx_errors = devstat->rx_length_errs + - devstat->rx_align_errs + - devstat->rx_crc_errs + - devstat->rx_code_violations + - devstat->rx_other_errs; - stats->tx_errors = devstat->tx_max_pkt_errs; - stats->multicast = devstat->multicast_pkts_rcvd; - stats->collisions = devstat->tx_collisions; - - stats->rx_length_errors = devstat->rx_length_errs; - stats->rx_over_errors = devstat->rx_overflows; - stats->rx_crc_errors = devstat->rx_crc_errs; - - /* NOTE: These stats don't have corresponding values in CE_STATS, - * so we're going to have to update these directly from within the - * TX/RX code - */ - /* stats->rx_bytes = 20; devstat->; */ - /* stats->tx_bytes = 20; devstat->; */ - /* stats->rx_dropped = devstat->; */ - /* stats->tx_dropped = devstat->; */ - - /* NOTE: Not used, can't find analogous statistics */ - /* stats->rx_frame_errors = devstat->; */ - /* stats->rx_fifo_errors = devstat->; */ - /* stats->rx_missed_errors = devstat->; */ - - /* stats->tx_aborted_errors = devstat->; */ - /* stats->tx_carrier_errors = devstat->; */ - /* stats->tx_fifo_errors = devstat->; */ - /* stats->tx_heartbeat_errors = devstat->; */ - /* stats->tx_window_errors = devstat->; */ - return stats; -} - -/** - * et131x_enable_txrx - Enable tx/rx queues - * @netdev: device to be enabled - */ -void et131x_enable_txrx(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Enable the Tx and Rx DMA engines (if not already enabled) */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); - - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); -} - -/** - * et131x_disable_txrx - Disable tx/rx queues - * @netdev: device to be disabled - */ -void et131x_disable_txrx(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); -} - -/** - * et131x_up - Bring up a device for use. - * @netdev: device to be opened - */ -void et131x_up(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - et131x_enable_txrx(netdev); - phy_start(adapter->phydev); -} - -/** - * et131x_open - Open the device for use. - * @netdev: device to be opened - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_open(struct net_device *netdev) -{ - int result = 0; - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Start the timer to track NIC errors */ - init_timer(&adapter->error_timer); - adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; - adapter->error_timer.function = et131x_error_timer_handler; - adapter->error_timer.data = (unsigned long)adapter; - add_timer(&adapter->error_timer); - - /* Register our IRQ */ - result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED, - netdev->name, netdev); - if (result) { - dev_err(&adapter->pdev->dev, "could not register IRQ %d\n", - netdev->irq); - return result; - } - - adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; - - et131x_up(netdev); - - return result; -} - -/** - * et131x_down - Bring down the device - * @netdev: device to be broght down - */ -void et131x_down(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Save the timestamp for the TX watchdog, prevent a timeout */ - netdev->trans_start = jiffies; - - phy_stop(adapter->phydev); - et131x_disable_txrx(netdev); -} - -/** - * et131x_close - Close the device - * @netdev: device to be closed - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_close(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - et131x_down(netdev); - - adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; - free_irq(netdev->irq, netdev); - - /* Stop the error timer */ - return del_timer_sync(&adapter->error_timer); -} - -/** - * et131x_ioctl - The I/O Control handler for the driver - * @netdev: device on which the control request is being made - * @reqbuf: a pointer to the IOCTL request buffer - * @cmd: the IOCTL command code - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - if (!adapter->phydev) - return -EINVAL; - - return phy_mii_ioctl(adapter->phydev, reqbuf, cmd); -} - -/** - * et131x_set_packet_filter - Configures the Rx Packet filtering on the device - * @adapter: pointer to our private adapter structure - * - * FIXME: lot of dups with MAC code - * - * Returns 0 on success, errno on failure - */ -static int et131x_set_packet_filter(struct et131x_adapter *adapter) -{ - int status = 0; - uint32_t filter = adapter->packet_filter; - u32 ctrl; - u32 pf_ctrl; - - ctrl = readl(&adapter->regs->rxmac.ctrl); - pf_ctrl = readl(&adapter->regs->rxmac.pf_ctrl); - - /* Default to disabled packet filtering. Enable it in the individual - * case statements that require the device to filter something - */ - ctrl |= 0x04; - - /* Set us to be in promiscuous mode so we receive everything, this - * is also true when we get a packet filter of 0 - */ - if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0) - pf_ctrl &= ~7; /* Clear filter bits */ - else { - /* - * Set us up with Multicast packet filtering. Three cases are - * possible - (1) we have a multi-cast list, (2) we receive ALL - * multicast entries or (3) we receive none. - */ - if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) - pf_ctrl &= ~2; /* Multicast filter bit */ - else { - et1310_setup_device_for_multicast(adapter); - pf_ctrl |= 2; - ctrl &= ~0x04; - } - - /* Set us up with Unicast packet filtering */ - if (filter & ET131X_PACKET_TYPE_DIRECTED) { - et1310_setup_device_for_unicast(adapter); - pf_ctrl |= 4; - ctrl &= ~0x04; - } - - /* Set us up with Broadcast packet filtering */ - if (filter & ET131X_PACKET_TYPE_BROADCAST) { - pf_ctrl |= 1; /* Broadcast filter bit */ - ctrl &= ~0x04; - } else - pf_ctrl &= ~1; - - /* Setup the receive mac configuration registers - Packet - * Filter control + the enable / disable for packet filter - * in the control reg. - */ - writel(pf_ctrl, &adapter->regs->rxmac.pf_ctrl); - writel(ctrl, &adapter->regs->rxmac.ctrl); - } - return status; -} - -/** - * et131x_multicast - The handler to configure multicasting on the interface - * @netdev: a pointer to a net_device struct representing the device - */ -static void et131x_multicast(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - uint32_t packet_filter = 0; - unsigned long flags; - struct netdev_hw_addr *ha; - int i; - - spin_lock_irqsave(&adapter->lock, flags); - - /* Before we modify the platform-independent filter flags, store them - * locally. This allows us to determine if anything's changed and if - * we even need to bother the hardware - */ - packet_filter = adapter->packet_filter; - - /* Clear the 'multicast' flag locally; because we only have a single - * flag to check multicast, and multiple multicast addresses can be - * set, this is the easiest way to determine if more than one - * multicast address is being set. - */ - packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; - - /* Check the net_device flags and set the device independent flags - * accordingly - */ - - if (netdev->flags & IFF_PROMISC) - adapter->packet_filter |= ET131X_PACKET_TYPE_PROMISCUOUS; - else - adapter->packet_filter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; - - if (netdev->flags & IFF_ALLMULTI) - adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; - - if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) - adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST; - - if (netdev_mc_count(netdev) < 1) { - adapter->packet_filter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; - adapter->packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST; - } else - adapter->packet_filter |= ET131X_PACKET_TYPE_MULTICAST; - - /* Set values in the private adapter struct */ - i = 0; - netdev_for_each_mc_addr(ha, netdev) { - if (i == NIC_MAX_MCAST_LIST) - break; - memcpy(adapter->multicast_list[i++], ha->addr, ETH_ALEN); - } - adapter->multicast_addr_count = i; - - /* Are the new flags different from the previous ones? If not, then no - * action is required - * - * NOTE - This block will always update the multicast_list with the - * hardware, even if the addresses aren't the same. - */ - if (packet_filter != adapter->packet_filter) { - /* Call the device's filter function */ - et131x_set_packet_filter(adapter); - } - spin_unlock_irqrestore(&adapter->lock, flags); -} - -/** - * et131x_tx - The handler to tx a packet on the device - * @skb: data to be Tx'd - * @netdev: device on which data is to be Tx'd - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) -{ - int status = 0; - - /* Save the timestamp for the TX timeout watchdog */ - netdev->trans_start = jiffies; - - /* Call the device-specific data Tx routine */ - status = et131x_send_packets(skb, netdev); - - /* Check status and manage the netif queue if necessary */ - if (status != 0) { - if (status == -ENOMEM) { - /* Put the queue to sleep until resources are - * available - */ - netif_stop_queue(netdev); - status = NETDEV_TX_BUSY; - } else { - status = NETDEV_TX_OK; - } - } - return status; -} - -/** - * et131x_tx_timeout - Timeout handler - * @netdev: a pointer to a net_device struct representing the device - * - * The handler called when a Tx request times out. The timeout period is - * specified by the 'tx_timeo" element in the net_device structure (see - * et131x_alloc_device() to see how this value is set). - */ -static void et131x_tx_timeout(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - struct tcb *tcb; - unsigned long flags; - - /* If the device is closed, ignore the timeout */ - if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)) - return; - - /* Any nonrecoverable hardware error? - * Checks adapter->flags for any failure in phy reading - */ - if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR) - return; - - /* Hardware failure? */ - if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) { - dev_err(&adapter->pdev->dev, "hardware error - reset\n"); - return; - } - - /* Is send stuck? */ - spin_lock_irqsave(&adapter->tcb_send_qlock, flags); - - tcb = adapter->tx_ring.send_head; - - if (tcb != NULL) { - tcb->count++; - - if (tcb->count > NIC_SEND_HANG_THRESHOLD) { - spin_unlock_irqrestore(&adapter->tcb_send_qlock, - flags); - - dev_warn(&adapter->pdev->dev, - "Send stuck - reset. tcb->WrIndex %x, flags 0x%08x\n", - tcb->index, - tcb->flags); - - adapter->net_stats.tx_errors++; - - /* perform reset of tx/rx */ - et131x_disable_txrx(netdev); - et131x_enable_txrx(netdev); - return; - } - } - - spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); -} - -/** - * et131x_change_mtu - The handler called to change the MTU for the device - * @netdev: device whose MTU is to be changed - * @new_mtu: the desired MTU - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int et131x_change_mtu(struct net_device *netdev, int new_mtu) -{ - int result = 0; - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Make sure the requested MTU is valid */ - if (new_mtu < 64 || new_mtu > 9216) - return -EINVAL; - - et131x_disable_txrx(netdev); - et131x_handle_send_interrupt(adapter); - et131x_handle_recv_interrupt(adapter); - - /* Set the new MTU */ - netdev->mtu = new_mtu; - - /* Free Rx DMA memory */ - et131x_adapter_memory_free(adapter); - - /* Set the config parameter for Jumbo Packet support */ - adapter->registry_jumbo_packet = new_mtu + 14; - et131x_soft_reset(adapter); - - /* Alloc and init Rx DMA memory */ - result = et131x_adapter_memory_alloc(adapter); - if (result != 0) { - dev_warn(&adapter->pdev->dev, - "Change MTU failed; couldn't re-alloc DMA memory\n"); - return result; - } - - et131x_init_send(adapter); - - et131x_hwaddr_init(adapter); - memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); - - /* Init the device with the new settings */ - et131x_adapter_setup(adapter); - - et131x_enable_txrx(netdev); - - return result; -} - -/** - * et131x_set_mac_addr - handler to change the MAC address for the device - * @netdev: device whose MAC is to be changed - * @new_mac: the desired MAC address - * - * Returns 0 on success, errno on failure (as defined in errno.h) - * - * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14 - */ -static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) -{ - int result = 0; - struct et131x_adapter *adapter = netdev_priv(netdev); - struct sockaddr *address = new_mac; - - /* begin blux */ - - if (adapter == NULL) - return -ENODEV; - - /* Make sure the requested MAC is valid */ - if (!is_valid_ether_addr(address->sa_data)) - return -EINVAL; - - et131x_disable_txrx(netdev); - et131x_handle_send_interrupt(adapter); - et131x_handle_recv_interrupt(adapter); - - /* Set the new MAC */ - /* netdev->set_mac_address = &new_mac; */ - - memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len); - - printk(KERN_INFO "%s: Setting MAC address to %pM\n", - netdev->name, netdev->dev_addr); - - /* Free Rx DMA memory */ - et131x_adapter_memory_free(adapter); - - et131x_soft_reset(adapter); - - /* Alloc and init Rx DMA memory */ - result = et131x_adapter_memory_alloc(adapter); - if (result != 0) { - dev_err(&adapter->pdev->dev, - "Change MAC failed; couldn't re-alloc DMA memory\n"); - return result; - } - - et131x_init_send(adapter); - - et131x_hwaddr_init(adapter); - - /* Init the device with the new settings */ - et131x_adapter_setup(adapter); - - et131x_enable_txrx(netdev); - - return result; -} - -static const struct net_device_ops et131x_netdev_ops = { - .ndo_open = et131x_open, - .ndo_stop = et131x_close, - .ndo_start_xmit = et131x_tx, - .ndo_set_multicast_list = et131x_multicast, - .ndo_tx_timeout = et131x_tx_timeout, - .ndo_change_mtu = et131x_change_mtu, - .ndo_set_mac_address = et131x_set_mac_addr, - .ndo_validate_addr = eth_validate_addr, - .ndo_get_stats = et131x_stats, - .ndo_do_ioctl = et131x_ioctl, -}; - -/** - * et131x_device_alloc - * - * Returns pointer to the allocated and initialized net_device struct for - * this device. - * - * Create instances of net_device and wl_private for the new adapter and - * register the device's entry points in the net_device structure. - */ -struct net_device *et131x_device_alloc(void) -{ - struct net_device *netdev; - - /* Alloc net_device and adapter structs */ - netdev = alloc_etherdev(sizeof(struct et131x_adapter)); - - if (!netdev) { - printk(KERN_ERR "et131x: Alloc of net_device struct failed\n"); - return NULL; - } - - /* - * Setup the function registration table (and other data) for a - * net_device - */ - netdev->watchdog_timeo = ET131X_TX_TIMEOUT; - netdev->netdev_ops = &et131x_netdev_ops; - - /* Poll? */ - /* netdev->poll = &et131x_poll; */ - /* netdev->poll_controller = &et131x_poll_controller; */ - return netdev; -} - From 2d0c64ad04725778237885212225d97f9470d34c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:31 +0100 Subject: [PATCH 1482/1519] staging: et131x: Move function declarations from et131x.h to et131x.c The function declarations in et131x.h are no longer used now all functions are in one file. Removed declarations from et131x.h and added any required forward declarations to et131x.c. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 31 ++++++++++ drivers/staging/et131x/et131x.h | 102 -------------------------------- 2 files changed, 31 insertions(+), 102 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index fdf6385e06a..a038a3799e6 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -96,6 +96,37 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " "for the ET1310 by Agere Systems"); +void et131x_error_timer_handler(unsigned long data); +void et131x_enable_interrupts(struct et131x_adapter *adapter); +void et131x_disable_interrupts(struct et131x_adapter *adapter); +void et131x_align_allocated_memory(struct et131x_adapter *adapter, + u64 *phys_addr, + u64 *offset, u64 mask); +void et131x_adapter_setup(struct et131x_adapter *adapter); +void et131x_soft_reset(struct et131x_adapter *adapter); +void et131x_isr_handler(struct work_struct *work); +void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); +void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); +void et131x_up(struct net_device *netdev); +void et131x_down(struct net_device *netdev); +struct net_device *et131x_device_alloc(void); +void et131x_enable_txrx(struct net_device *netdev); +void et131x_disable_txrx(struct net_device *netdev); +int et1310_in_phy_coma(struct et131x_adapter *adapter); +void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, + u16 action, + u16 regnum, u16 bitnum, u8 *value); +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, + u8 reg, u16 *value); +int32_t et131x_mii_write(struct et131x_adapter *adapter, + u8 reg, u16 value); +void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); +void et131x_rx_dma_disable(struct et131x_adapter *adapter); +void et131x_rx_dma_enable(struct et131x_adapter *adapter); +void et131x_reset_recv(struct et131x_adapter *adapter); +void et131x_init_send(struct et131x_adapter *adapter); +void et131x_tx_dma_enable(struct et131x_adapter *adapter); + /* EEPROM functions */ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 0531414f32d..71fd7fe115e 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -108,105 +108,3 @@ #define INT_MASK_ENABLE 0xfffebf17 #define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 - -/* et131x_eeprom.c */ -int et131x_init_eeprom(struct et131x_adapter *adapter); - -/* et131x_initpci.c */ -void et131x_error_timer_handler(unsigned long data); -void et131x_configure_global_regs(struct et131x_adapter *adapter); -void et131x_enable_interrupts(struct et131x_adapter *adapter); -void et131x_disable_interrupts(struct et131x_adapter *adapter); -void et131x_align_allocated_memory(struct et131x_adapter *adapter, - u64 *phys_addr, - u64 *offset, u64 mask); - -void et131x_adapter_setup(struct et131x_adapter *adapter); -int et131x_adapter_memory_alloc(struct et131x_adapter *adapter); -void et131x_adapter_memory_free(struct et131x_adapter *adapter); -void et131x_hwaddr_init(struct et131x_adapter *adapter); -void et131x_soft_reset(struct et131x_adapter *adapter); - -/* et131x_isr.c */ -irqreturn_t et131x_isr(int irq, void *dev_id); -void et131x_isr_handler(struct work_struct *work); - -/* et1310_mac.c */ -void et1310_config_mac_regs1(struct et131x_adapter *adapter); -void et1310_config_mac_regs2(struct et131x_adapter *adapter); -void et1310_config_rxmac_regs(struct et131x_adapter *adapter); -void et1310_config_txmac_regs(struct et131x_adapter *adapter); -void et1310_config_macstat_regs(struct et131x_adapter *adapter); -void et1310_config_flow_control(struct et131x_adapter *adapter); -void et1310_update_macstat_host_counters(struct et131x_adapter *adapter); -void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter); -void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); -void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); - -/* et131x_netdev.c */ -int et131x_open(struct net_device *netdev); -int et131x_close(struct net_device *netdev); -void et131x_up(struct net_device *netdev); -void et131x_down(struct net_device *netdev); -struct net_device *et131x_device_alloc(void); -void et131x_enable_txrx(struct net_device *netdev); -void et131x_disable_txrx(struct net_device *netdev); - -/* et1310_pm.c */ -int et1310_in_phy_coma(struct et131x_adapter *adapter); -void et1310_enable_phy_coma(struct et131x_adapter *adapter); -void et1310_disable_phy_coma(struct et131x_adapter *adapter); - -/* et1310_phy.c */ -void et1310_phy_power_down(struct et131x_adapter *adapter, bool down); -void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, - u16 action, - u16 regnum, u16 bitnum, u8 *value); - -void et131x_xcvr_init(struct et131x_adapter *adapter); - -/* static inline function does not work because et131x_adapter is not always - * defined - */ -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, - u8 reg, u16 *value); -int32_t et131x_mii_read(struct et131x_adapter *adapter, - u8 reg, u16 *value); -int32_t et131x_mii_write(struct et131x_adapter *adapter, - u8 reg, u16 value); - -int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg); -int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value); -int et131x_mdio_reset(struct mii_bus *bus); - -/* et1310_rx.c */ -int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter); -void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); -int et131x_rfd_resources_alloc(struct et131x_adapter *adapter, - struct rfd *rfd); -void et131x_rfd_resources_free(struct et131x_adapter *adapter, - struct rfd *rfd); -int et131x_init_recv(struct et131x_adapter *adapter); - -void et131x_config_rx_dma_regs(struct et131x_adapter *adapter); -void et131x_set_rx_dma_timer(struct et131x_adapter *adapter); -void et131x_rx_dma_disable(struct et131x_adapter *adapter); -void et131x_rx_dma_enable(struct et131x_adapter *adapter); - -void et131x_reset_recv(struct et131x_adapter *adapter); - -void et131x_handle_recv_interrupt(struct et131x_adapter *adapter); - -/* et131x_tx.c */ -int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter); -void et131x_tx_dma_memory_free(struct et131x_adapter *adapter); -void et131x_config_tx_dma_regs(struct et131x_adapter *adapter); -void et131x_init_send(struct et131x_adapter *adapter); -void et131x_tx_dma_disable(struct et131x_adapter *adapter); -void et131x_tx_dma_enable(struct et131x_adapter *adapter); -void et131x_handle_send_interrupt(struct et131x_adapter *adapter); -void et131x_free_busy_send_packets(struct et131x_adapter *adapter); -int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev); - -/* et131x_ethtool.c */ -void et131x_set_ethtool_ops(struct net_device *netdev); From bd156af600b6c289cf58d02867a255c2f41d0b87 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:32 +0100 Subject: [PATCH 1483/1519] staging: et131x: Move non-register defines from et131x.h to et131x.c Header file should only have register defines, moved non-register defines to et131x.c Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 31 +++++++++++++++++++++++++++++++ drivers/staging/et131x/et131x.h | 33 +-------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index a038a3799e6..cad271bcad3 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -96,6 +96,37 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " "for the ET1310 by Agere Systems"); +/* EEPROM defines */ +#define MAX_NUM_REGISTER_POLLS 1000 +#define MAX_NUM_WRITE_RETRIES 2 + +/* MAC defines */ +#define COUNTER_WRAP_16_BIT 0x10000 +#define COUNTER_WRAP_12_BIT 0x1000 + +/* PCI defines */ +#define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */ +#define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ + +/* ISR defines */ +/* + * For interrupts, normal running is: + * rxdma_xfr_done, phy_interrupt, mac_stat_interrupt, + * watchdog_interrupt & txdma_xfer_done + * + * In both cases, when flow control is enabled for either Tx or bi-direction, + * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the + * buffer rings are running low. + */ +#define INT_MASK_DISABLE 0xffffffff + +/* NOTE: Masking out MAC_STAT Interrupt for now... + * #define INT_MASK_ENABLE 0xfff6bf17 + * #define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7 + */ +#define INT_MASK_ENABLE 0xfffebf17 +#define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 + void et131x_error_timer_handler(unsigned long data); void et131x_enable_interrupts(struct et131x_adapter *adapter); void et131x_disable_interrupts(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 71fd7fe115e..115d30715f5 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -49,7 +49,7 @@ #define DRIVER_NAME "et131x" #define DRIVER_VERSION "v2.0" -/* EEPROM defines */ +/* EEPROM registers */ /* LBCIF Register Groups (addressed via 32-bit offsets) */ #define LBCIF_DWORD0_GROUP 0xAC @@ -77,34 +77,3 @@ #define LBCIF_STATUS_CHECKSUM_ERROR 0x40 #define LBCIF_STATUS_EEPROM_PRESENT 0x80 -/* Miscellaneous Constraints */ -#define MAX_NUM_REGISTER_POLLS 1000 -#define MAX_NUM_WRITE_RETRIES 2 - -/* MAC defines */ -#define COUNTER_WRAP_16_BIT 0x10000 -#define COUNTER_WRAP_12_BIT 0x1000 - -/* PCI defines */ -#define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */ -#define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ - -/* ISR defines */ -/* - * For interrupts, normal running is: - * rxdma_xfr_done, phy_interrupt, mac_stat_interrupt, - * watchdog_interrupt & txdma_xfer_done - * - * In both cases, when flow control is enabled for either Tx or bi-direction, - * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the - * buffer rings are running low. - */ -#define INT_MASK_DISABLE 0xffffffff - -/* NOTE: Masking out MAC_STAT Interrupt for now... - * #define INT_MASK_ENABLE 0xfff6bf17 - * #define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7 - */ -#define INT_MASK_ENABLE 0xfffebf17 -#define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 - From 01df6aa2636335617a7a6f5b136b3f52b787a5f5 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:33 +0100 Subject: [PATCH 1484/1519] staging: et131x: move et1310_address_map.h contents into et131x.h Move et1310_address_map.h register defines into et131x.h and delete et1310_address_map.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_address_map.h | 1436 ------------------- drivers/staging/et131x/et1310_phy.h | 2 - drivers/staging/et131x/et1310_rx.h | 2 - drivers/staging/et131x/et131x.c | 1 - drivers/staging/et131x/et131x.h | 1370 ++++++++++++++++++ drivers/staging/et131x/et131x_adapter.h | 1 - 6 files changed, 1370 insertions(+), 1442 deletions(-) delete mode 100644 drivers/staging/et131x/et1310_address_map.h diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h deleted file mode 100644 index b502ce38cc2..00000000000 --- a/drivers/staging/et131x/et1310_address_map.h +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_address_map.h - Contains the register mapping for the ET1310 - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef _ET1310_ADDRESS_MAP_H_ -#define _ET1310_ADDRESS_MAP_H_ - - -/* START OF GLOBAL REGISTER ADDRESS MAP */ - -/* - * 10bit registers - * - * Tx queue start address reg in global address map at address 0x0000 - * tx queue end address reg in global address map at address 0x0004 - * rx queue start address reg in global address map at address 0x0008 - * rx queue end address reg in global address map at address 0x000C - */ - -/* - * structure for power management control status reg in global address map - * located at address 0x0010 - * jagcore_rx_rdy bit 9 - * jagcore_tx_rdy bit 8 - * phy_lped_en bit 7 - * phy_sw_coma bit 6 - * rxclk_gate bit 5 - * txclk_gate bit 4 - * sysclk_gate bit 3 - * jagcore_rx_en bit 2 - * jagcore_tx_en bit 1 - * gigephy_en bit 0 - */ - -#define ET_PM_PHY_SW_COMA 0x40 -#define ET_PMCSR_INIT 0x38 - -/* - * Interrupt status reg at address 0x0018 - */ - -#define ET_INTR_TXDMA_ISR 0x00000008 -#define ET_INTR_TXDMA_ERR 0x00000010 -#define ET_INTR_RXDMA_XFR_DONE 0x00000020 -#define ET_INTR_RXDMA_FB_R0_LOW 0x00000040 -#define ET_INTR_RXDMA_FB_R1_LOW 0x00000080 -#define ET_INTR_RXDMA_STAT_LOW 0x00000100 -#define ET_INTR_RXDMA_ERR 0x00000200 -#define ET_INTR_WATCHDOG 0x00004000 -#define ET_INTR_WOL 0x00008000 -#define ET_INTR_PHY 0x00010000 -#define ET_INTR_TXMAC 0x00020000 -#define ET_INTR_RXMAC 0x00040000 -#define ET_INTR_MAC_STAT 0x00080000 -#define ET_INTR_SLV_TIMEOUT 0x00100000 - -/* - * Interrupt mask register at address 0x001C - * Interrupt alias clear mask reg at address 0x0020 - * Interrupt status alias reg at address 0x0024 - * - * Same masks as above - */ - -/* - * Software reset reg at address 0x0028 - * 0: txdma_sw_reset - * 1: rxdma_sw_reset - * 2: txmac_sw_reset - * 3: rxmac_sw_reset - * 4: mac_sw_reset - * 5: mac_stat_sw_reset - * 6: mmc_sw_reset - *31: selfclr_disable - */ - -/* - * SLV Timer reg at address 0x002C (low 24 bits) - */ - -/* - * MSI Configuration reg at address 0x0030 - */ - -#define ET_MSI_VECTOR 0x0000001F -#define ET_MSI_TC 0x00070000 - -/* - * Loopback reg located at address 0x0034 - */ - -#define ET_LOOP_MAC 0x00000001 -#define ET_LOOP_DMA 0x00000002 - -/* - * GLOBAL Module of JAGCore Address Mapping - * Located at address 0x0000 - */ -struct global_regs { /* Location: */ - u32 txq_start_addr; /* 0x0000 */ - u32 txq_end_addr; /* 0x0004 */ - u32 rxq_start_addr; /* 0x0008 */ - u32 rxq_end_addr; /* 0x000C */ - u32 pm_csr; /* 0x0010 */ - u32 unused; /* 0x0014 */ - u32 int_status; /* 0x0018 */ - u32 int_mask; /* 0x001C */ - u32 int_alias_clr_en; /* 0x0020 */ - u32 int_status_alias; /* 0x0024 */ - u32 sw_reset; /* 0x0028 */ - u32 slv_timer; /* 0x002C */ - u32 msi_config; /* 0x0030 */ - u32 loopback; /* 0x0034 */ - u32 watchdog_timer; /* 0x0038 */ -}; - - -/* START OF TXDMA REGISTER ADDRESS MAP */ - -/* - * txdma control status reg at address 0x1000 - */ - -#define ET_TXDMA_CSR_HALT 0x00000001 -#define ET_TXDMA_DROP_TLP 0x00000002 -#define ET_TXDMA_CACHE_THRS 0x000000F0 -#define ET_TXDMA_CACHE_SHIFT 4 -#define ET_TXDMA_SNGL_EPKT 0x00000100 -#define ET_TXDMA_CLASS 0x00001E00 - -/* - * structure for txdma packet ring base address hi reg in txdma address map - * located at address 0x1004 - * Defined earlier (u32) - */ - -/* - * structure for txdma packet ring base address low reg in txdma address map - * located at address 0x1008 - * Defined earlier (u32) - */ - -/* - * structure for txdma packet ring number of descriptor reg in txdma address - * map. Located at address 0x100C - * - * 31-10: unused - * 9-0: pr ndes - */ - -#define ET_DMA12_MASK 0x0FFF /* 12 bit mask for DMA12W types */ -#define ET_DMA12_WRAP 0x1000 -#define ET_DMA10_MASK 0x03FF /* 10 bit mask for DMA10W types */ -#define ET_DMA10_WRAP 0x0400 -#define ET_DMA4_MASK 0x000F /* 4 bit mask for DMA4W types */ -#define ET_DMA4_WRAP 0x0010 - -#define INDEX12(x) ((x) & ET_DMA12_MASK) -#define INDEX10(x) ((x) & ET_DMA10_MASK) -#define INDEX4(x) ((x) & ET_DMA4_MASK) - -extern inline void add_10bit(u32 *v, int n) -{ - *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); -} - -extern inline void add_12bit(u32 *v, int n) -{ - *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); -} - -/* - * 10bit DMA with wrap - * txdma tx queue write address reg in txdma address map at 0x1010 - * txdma tx queue write address external reg in txdma address map at 0x1014 - * txdma tx queue read address reg in txdma address map at 0x1018 - * - * u32 - * txdma status writeback address hi reg in txdma address map at0x101C - * txdma status writeback address lo reg in txdma address map at 0x1020 - * - * 10bit DMA with wrap - * txdma service request reg in txdma address map at 0x1024 - * structure for txdma service complete reg in txdma address map at 0x1028 - * - * 4bit DMA with wrap - * txdma tx descriptor cache read index reg in txdma address map at 0x102C - * txdma tx descriptor cache write index reg in txdma address map at 0x1030 - * - * txdma error reg in txdma address map at address 0x1034 - * 0: PyldResend - * 1: PyldRewind - * 4: DescrResend - * 5: DescrRewind - * 8: WrbkResend - * 9: WrbkRewind - */ - -/* - * Tx DMA Module of JAGCore Address Mapping - * Located at address 0x1000 - */ -struct txdma_regs { /* Location: */ - u32 csr; /* 0x1000 */ - u32 pr_base_hi; /* 0x1004 */ - u32 pr_base_lo; /* 0x1008 */ - u32 pr_num_des; /* 0x100C */ - u32 txq_wr_addr; /* 0x1010 */ - u32 txq_wr_addr_ext; /* 0x1014 */ - u32 txq_rd_addr; /* 0x1018 */ - u32 dma_wb_base_hi; /* 0x101C */ - u32 dma_wb_base_lo; /* 0x1020 */ - u32 service_request; /* 0x1024 */ - u32 service_complete; /* 0x1028 */ - u32 cache_rd_index; /* 0x102C */ - u32 cache_wr_index; /* 0x1030 */ - u32 tx_dma_error; /* 0x1034 */ - u32 desc_abort_cnt; /* 0x1038 */ - u32 payload_abort_cnt; /* 0x103c */ - u32 writeback_abort_cnt; /* 0x1040 */ - u32 desc_timeout_cnt; /* 0x1044 */ - u32 payload_timeout_cnt; /* 0x1048 */ - u32 writeback_timeout_cnt; /* 0x104c */ - u32 desc_error_cnt; /* 0x1050 */ - u32 payload_error_cnt; /* 0x1054 */ - u32 writeback_error_cnt; /* 0x1058 */ - u32 dropped_tlp_cnt; /* 0x105c */ - u32 new_service_complete; /* 0x1060 */ - u32 ethernet_packet_cnt; /* 0x1064 */ -}; - -/* END OF TXDMA REGISTER ADDRESS MAP */ - - -/* START OF RXDMA REGISTER ADDRESS MAP */ - -/* - * structure for control status reg in rxdma address map - * Located at address 0x2000 - * - * CSR - * 0: halt - * 1-3: tc - * 4: fbr_big_endian - * 5: psr_big_endian - * 6: pkt_big_endian - * 7: dma_big_endian - * 8-9: fbr0_size - * 10: fbr0_enable - * 11-12: fbr1_size - * 13: fbr1_enable - * 14: unused - * 15: pkt_drop_disable - * 16: pkt_done_flush - * 17: halt_status - * 18-31: unused - */ - - -/* - * structure for dma writeback lo reg in rxdma address map - * located at address 0x2004 - * Defined earlier (u32) - */ - -/* - * structure for dma writeback hi reg in rxdma address map - * located at address 0x2008 - * Defined earlier (u32) - */ - -/* - * structure for number of packets done reg in rxdma address map - * located at address 0x200C - * - * 31-8: unused - * 7-0: num done - */ - -/* - * structure for max packet time reg in rxdma address map - * located at address 0x2010 - * - * 31-18: unused - * 17-0: time done - */ - -/* - * structure for rx queue read address reg in rxdma address map - * located at address 0x2014 - * Defined earlier (u32) - */ - -/* - * structure for rx queue read address external reg in rxdma address map - * located at address 0x2018 - * Defined earlier (u32) - */ - -/* - * structure for rx queue write address reg in rxdma address map - * located at address 0x201C - * Defined earlier (u32) - */ - -/* - * structure for packet status ring base address lo reg in rxdma address map - * located at address 0x2020 - * Defined earlier (u32) - */ - -/* - * structure for packet status ring base address hi reg in rxdma address map - * located at address 0x2024 - * Defined earlier (u32) - */ - -/* - * structure for packet status ring number of descriptors reg in rxdma address - * map. Located at address 0x2028 - * - * 31-12: unused - * 11-0: psr ndes - */ - -/* - * structure for packet status ring available offset reg in rxdma address map - * located at address 0x202C - * - * 31-13: unused - * 12: psr avail wrap - * 11-0: psr avail - */ - -/* - * structure for packet status ring full offset reg in rxdma address map - * located at address 0x2030 - * - * 31-13: unused - * 12: psr full wrap - * 11-0: psr full - */ - -/* - * structure for packet status ring access index reg in rxdma address map - * located at address 0x2034 - * - * 31-5: unused - * 4-0: psr_ai - */ - -/* - * structure for packet status ring minimum descriptors reg in rxdma address - * map. Located at address 0x2038 - * - * 31-12: unused - * 11-0: psr_min - */ - -/* - * structure for free buffer ring base lo address reg in rxdma address map - * located at address 0x203C - * Defined earlier (u32) - */ - -/* - * structure for free buffer ring base hi address reg in rxdma address map - * located at address 0x2040 - * Defined earlier (u32) - */ - -/* - * structure for free buffer ring number of descriptors reg in rxdma address - * map. Located at address 0x2044 - * - * 31-10: unused - * 9-0: fbr ndesc - */ - -/* - * structure for free buffer ring 0 available offset reg in rxdma address map - * located at address 0x2048 - * Defined earlier (u32) - */ - -/* - * structure for free buffer ring 0 full offset reg in rxdma address map - * located at address 0x204C - * Defined earlier (u32) - */ - -/* - * structure for free buffer cache 0 full offset reg in rxdma address map - * located at address 0x2050 - * - * 31-5: unused - * 4-0: fbc rdi - */ - -/* - * structure for free buffer ring 0 minimum descriptor reg in rxdma address map - * located at address 0x2054 - * - * 31-10: unused - * 9-0: fbr min - */ - -/* - * structure for free buffer ring 1 base address lo reg in rxdma address map - * located at address 0x2058 - 0x205C - * Defined earlier (RXDMA_FBR_BASE_LO_t and RXDMA_FBR_BASE_HI_t) - */ - -/* - * structure for free buffer ring 1 number of descriptors reg in rxdma address - * map. Located at address 0x2060 - * Defined earlier (RXDMA_FBR_NUM_DES_t) - */ - -/* - * structure for free buffer ring 1 available offset reg in rxdma address map - * located at address 0x2064 - * Defined Earlier (RXDMA_FBR_AVAIL_OFFSET_t) - */ - -/* - * structure for free buffer ring 1 full offset reg in rxdma address map - * located at address 0x2068 - * Defined Earlier (RXDMA_FBR_FULL_OFFSET_t) - */ - -/* - * structure for free buffer cache 1 read index reg in rxdma address map - * located at address 0x206C - * Defined Earlier (RXDMA_FBC_RD_INDEX_t) - */ - -/* - * structure for free buffer ring 1 minimum descriptor reg in rxdma address map - * located at address 0x2070 - * Defined Earlier (RXDMA_FBR_MIN_DES_t) - */ - -/* - * Rx DMA Module of JAGCore Address Mapping - * Located at address 0x2000 - */ -struct rxdma_regs { /* Location: */ - u32 csr; /* 0x2000 */ - u32 dma_wb_base_lo; /* 0x2004 */ - u32 dma_wb_base_hi; /* 0x2008 */ - u32 num_pkt_done; /* 0x200C */ - u32 max_pkt_time; /* 0x2010 */ - u32 rxq_rd_addr; /* 0x2014 */ - u32 rxq_rd_addr_ext; /* 0x2018 */ - u32 rxq_wr_addr; /* 0x201C */ - u32 psr_base_lo; /* 0x2020 */ - u32 psr_base_hi; /* 0x2024 */ - u32 psr_num_des; /* 0x2028 */ - u32 psr_avail_offset; /* 0x202C */ - u32 psr_full_offset; /* 0x2030 */ - u32 psr_access_index; /* 0x2034 */ - u32 psr_min_des; /* 0x2038 */ - u32 fbr0_base_lo; /* 0x203C */ - u32 fbr0_base_hi; /* 0x2040 */ - u32 fbr0_num_des; /* 0x2044 */ - u32 fbr0_avail_offset; /* 0x2048 */ - u32 fbr0_full_offset; /* 0x204C */ - u32 fbr0_rd_index; /* 0x2050 */ - u32 fbr0_min_des; /* 0x2054 */ - u32 fbr1_base_lo; /* 0x2058 */ - u32 fbr1_base_hi; /* 0x205C */ - u32 fbr1_num_des; /* 0x2060 */ - u32 fbr1_avail_offset; /* 0x2064 */ - u32 fbr1_full_offset; /* 0x2068 */ - u32 fbr1_rd_index; /* 0x206C */ - u32 fbr1_min_des; /* 0x2070 */ -}; - -/* END OF RXDMA REGISTER ADDRESS MAP */ - - -/* START OF TXMAC REGISTER ADDRESS MAP */ - -/* - * structure for control reg in txmac address map - * located at address 0x3000 - * - * bits - * 31-8: unused - * 7: cklseg_disable - * 6: ckbcnt_disable - * 5: cksegnum - * 4: async_disable - * 3: fc_disable - * 2: mcif_disable - * 1: mif_disable - * 0: txmac_en - */ - -/* - * structure for shadow pointer reg in txmac address map - * located at address 0x3004 - * 31-27: reserved - * 26-16: txq rd ptr - * 15-11: reserved - * 10-0: txq wr ptr - */ - -/* - * structure for error count reg in txmac address map - * located at address 0x3008 - * - * 31-12: unused - * 11-8: reserved - * 7-4: txq_underrun - * 3-0: fifo_underrun - */ - -/* - * structure for max fill reg in txmac address map - * located at address 0x300C - * 31-12: unused - * 11-0: max fill - */ - -/* - * structure for cf parameter reg in txmac address map - * located at address 0x3010 - * 31-16: cfep - * 15-0: cfpt - */ - -/* - * structure for tx test reg in txmac address map - * located at address 0x3014 - * 31-17: unused - * 16: reserved1 - * 15: txtest_en - * 14-11: unused - * 10-0: txq test pointer - */ - -/* - * structure for error reg in txmac address map - * located at address 0x3018 - * - * 31-9: unused - * 8: fifo_underrun - * 7-6: unused - * 5: ctrl2_err - * 4: txq_underrun - * 3: bcnt_err - * 2: lseg_err - * 1: segnum_err - * 0: seg0_err - */ - -/* - * structure for error interrupt reg in txmac address map - * located at address 0x301C - * - * 31-9: unused - * 8: fifo_underrun - * 7-6: unused - * 5: ctrl2_err - * 4: txq_underrun - * 3: bcnt_err - * 2: lseg_err - * 1: segnum_err - * 0: seg0_err - */ - -/* - * structure for error interrupt reg in txmac address map - * located at address 0x3020 - * - * 31-2: unused - * 1: bp_req - * 0: bp_xonxoff - */ - -/* - * Tx MAC Module of JAGCore Address Mapping - */ -struct txmac_regs { /* Location: */ - u32 ctl; /* 0x3000 */ - u32 shadow_ptr; /* 0x3004 */ - u32 err_cnt; /* 0x3008 */ - u32 max_fill; /* 0x300C */ - u32 cf_param; /* 0x3010 */ - u32 tx_test; /* 0x3014 */ - u32 err; /* 0x3018 */ - u32 err_int; /* 0x301C */ - u32 bp_ctrl; /* 0x3020 */ -}; - -/* END OF TXMAC REGISTER ADDRESS MAP */ - -/* START OF RXMAC REGISTER ADDRESS MAP */ - -/* - * structure for rxmac control reg in rxmac address map - * located at address 0x4000 - * - * 31-7: reserved - * 6: rxmac_int_disable - * 5: async_disable - * 4: mif_disable - * 3: wol_disable - * 2: pkt_filter_disable - * 1: mcif_disable - * 0: rxmac_en - */ - -/* - * structure for Wake On Lan Control and CRC 0 reg in rxmac address map - * located at address 0x4004 - * 31-16: crc - * 15-12: reserved - * 11: ignore_pp - * 10: ignore_mp - * 9: clr_intr - * 8: ignore_link_chg - * 7: ignore_uni - * 6: ignore_multi - * 5: ignore_broad - * 4-0: valid_crc 4-0 - */ - -/* - * structure for CRC 1 and CRC 2 reg in rxmac address map - * located at address 0x4008 - * - * 31-16: crc2 - * 15-0: crc1 - */ - -/* - * structure for CRC 3 and CRC 4 reg in rxmac address map - * located at address 0x400C - * - * 31-16: crc4 - * 15-0: crc3 - */ - -/* - * structure for Wake On Lan Source Address Lo reg in rxmac address map - * located at address 0x4010 - * - * 31-24: sa3 - * 23-16: sa4 - * 15-8: sa5 - * 7-0: sa6 - */ - -#define ET_WOL_LO_SA3_SHIFT 24 -#define ET_WOL_LO_SA4_SHIFT 16 -#define ET_WOL_LO_SA5_SHIFT 8 - -/* - * structure for Wake On Lan Source Address Hi reg in rxmac address map - * located at address 0x4014 - * - * 31-16: reserved - * 15-8: sa1 - * 7-0: sa2 - */ - -#define ET_WOL_HI_SA1_SHIFT 8 - -/* - * structure for Wake On Lan mask reg in rxmac address map - * located at address 0x4018 - 0x4064 - * Defined earlier (u32) - */ - -/* - * structure for Unicast Paket Filter Address 1 reg in rxmac address map - * located at address 0x4068 - * - * 31-24: addr1_3 - * 23-16: addr1_4 - * 15-8: addr1_5 - * 7-0: addr1_6 - */ - -#define ET_UNI_PF_ADDR1_3_SHIFT 24 -#define ET_UNI_PF_ADDR1_4_SHIFT 16 -#define ET_UNI_PF_ADDR1_5_SHIFT 8 - -/* - * structure for Unicast Paket Filter Address 2 reg in rxmac address map - * located at address 0x406C - * - * 31-24: addr2_3 - * 23-16: addr2_4 - * 15-8: addr2_5 - * 7-0: addr2_6 - */ - -#define ET_UNI_PF_ADDR2_3_SHIFT 24 -#define ET_UNI_PF_ADDR2_4_SHIFT 16 -#define ET_UNI_PF_ADDR2_5_SHIFT 8 - -/* - * structure for Unicast Paket Filter Address 1 & 2 reg in rxmac address map - * located at address 0x4070 - * - * 31-24: addr2_1 - * 23-16: addr2_2 - * 15-8: addr1_1 - * 7-0: addr1_2 - */ - -#define ET_UNI_PF_ADDR2_1_SHIFT 24 -#define ET_UNI_PF_ADDR2_2_SHIFT 16 -#define ET_UNI_PF_ADDR1_1_SHIFT 8 - - -/* - * structure for Multicast Hash reg in rxmac address map - * located at address 0x4074 - 0x4080 - * Defined earlier (u32) - */ - -/* - * structure for Packet Filter Control reg in rxmac address map - * located at address 0x4084 - * - * 31-23: unused - * 22-16: min_pkt_size - * 15-4: unused - * 3: filter_frag_en - * 2: filter_uni_en - * 1: filter_multi_en - * 0: filter_broad_en - */ - -/* - * structure for Memory Controller Interface Control Max Segment reg in rxmac - * address map. Located at address 0x4088 - * - * 31-10: reserved - * 9-2: max_size - * 1: fc_en - * 0: seg_en - */ - -/* - * structure for Memory Controller Interface Water Mark reg in rxmac address - * map. Located at address 0x408C - * - * 31-26: unused - * 25-16: mark_hi - * 15-10: unused - * 9-0: mark_lo - */ - -/* - * structure for Rx Queue Dialog reg in rxmac address map. - * located at address 0x4090 - * - * 31-26: reserved - * 25-16: rd_ptr - * 15-10: reserved - * 9-0: wr_ptr - */ - -/* - * structure for space available reg in rxmac address map. - * located at address 0x4094 - * - * 31-17: reserved - * 16: space_avail_en - * 15-10: reserved - * 9-0: space_avail - */ - -/* - * structure for management interface reg in rxmac address map. - * located at address 0x4098 - * - * 31-18: reserved - * 17: drop_pkt_en - * 16-0: drop_pkt_mask - */ - -/* - * structure for Error reg in rxmac address map. - * located at address 0x409C - * - * 31-4: unused - * 3: mif - * 2: async - * 1: pkt_filter - * 0: mcif - */ - -/* - * Rx MAC Module of JAGCore Address Mapping - */ -struct rxmac_regs { /* Location: */ - u32 ctrl; /* 0x4000 */ - u32 crc0; /* 0x4004 */ - u32 crc12; /* 0x4008 */ - u32 crc34; /* 0x400C */ - u32 sa_lo; /* 0x4010 */ - u32 sa_hi; /* 0x4014 */ - u32 mask0_word0; /* 0x4018 */ - u32 mask0_word1; /* 0x401C */ - u32 mask0_word2; /* 0x4020 */ - u32 mask0_word3; /* 0x4024 */ - u32 mask1_word0; /* 0x4028 */ - u32 mask1_word1; /* 0x402C */ - u32 mask1_word2; /* 0x4030 */ - u32 mask1_word3; /* 0x4034 */ - u32 mask2_word0; /* 0x4038 */ - u32 mask2_word1; /* 0x403C */ - u32 mask2_word2; /* 0x4040 */ - u32 mask2_word3; /* 0x4044 */ - u32 mask3_word0; /* 0x4048 */ - u32 mask3_word1; /* 0x404C */ - u32 mask3_word2; /* 0x4050 */ - u32 mask3_word3; /* 0x4054 */ - u32 mask4_word0; /* 0x4058 */ - u32 mask4_word1; /* 0x405C */ - u32 mask4_word2; /* 0x4060 */ - u32 mask4_word3; /* 0x4064 */ - u32 uni_pf_addr1; /* 0x4068 */ - u32 uni_pf_addr2; /* 0x406C */ - u32 uni_pf_addr3; /* 0x4070 */ - u32 multi_hash1; /* 0x4074 */ - u32 multi_hash2; /* 0x4078 */ - u32 multi_hash3; /* 0x407C */ - u32 multi_hash4; /* 0x4080 */ - u32 pf_ctrl; /* 0x4084 */ - u32 mcif_ctrl_max_seg; /* 0x4088 */ - u32 mcif_water_mark; /* 0x408C */ - u32 rxq_diag; /* 0x4090 */ - u32 space_avail; /* 0x4094 */ - - u32 mif_ctrl; /* 0x4098 */ - u32 err_reg; /* 0x409C */ -}; - -/* END OF RXMAC REGISTER ADDRESS MAP */ - - -/* START OF MAC REGISTER ADDRESS MAP */ - -/* - * structure for configuration #1 reg in mac address map. - * located at address 0x5000 - * - * 31: soft reset - * 30: sim reset - * 29-20: reserved - * 19: reset rx mc - * 18: reset tx mc - * 17: reset rx func - * 16: reset tx fnc - * 15-9: reserved - * 8: loopback - * 7-6: reserved - * 5: rx flow - * 4: tx flow - * 3: syncd rx en - * 2: rx enable - * 1: syncd tx en - * 0: tx enable - */ - -#define CFG1_LOOPBACK 0x00000100 -#define CFG1_RX_FLOW 0x00000020 -#define CFG1_TX_FLOW 0x00000010 -#define CFG1_RX_ENABLE 0x00000004 -#define CFG1_TX_ENABLE 0x00000001 -#define CFG1_WAIT 0x0000000A /* RX & TX syncd */ - -/* - * structure for configuration #2 reg in mac address map. - * located at address 0x5004 - * 31-16: reserved - * 15-12: preamble - * 11-10: reserved - * 9-8: if mode - * 7-6: reserved - * 5: huge frame - * 4: length check - * 3: undefined - * 2: pad crc - * 1: crc enable - * 0: full duplex - */ - - -/* - * structure for Interpacket gap reg in mac address map. - * located at address 0x5008 - * - * 31: reserved - * 30-24: non B2B ipg 1 - * 23: undefined - * 22-16: non B2B ipg 2 - * 15-8: Min ifg enforce - * 7-0: B2B ipg - * - * structure for half duplex reg in mac address map. - * located at address 0x500C - * 31-24: reserved - * 23-20: Alt BEB trunc - * 19: Alt BEB enable - * 18: BP no backoff - * 17: no backoff - * 16: excess defer - * 15-12: re-xmit max - * 11-10: reserved - * 9-0: collision window - */ - -/* - * structure for Maximum Frame Length reg in mac address map. - * located at address 0x5010: bits 0-15 hold the length. - */ - -/* - * structure for Reserve 1 reg in mac address map. - * located at address 0x5014 - 0x5018 - * Defined earlier (u32) - */ - -/* - * structure for Test reg in mac address map. - * located at address 0x501C - * test: bits 0-2, rest unused - */ - -/* - * structure for MII Management Configuration reg in mac address map. - * located at address 0x5020 - * - * 31: reset MII mgmt - * 30-6: unused - * 5: scan auto increment - * 4: preamble suppress - * 3: undefined - * 2-0: mgmt clock reset - */ - -/* - * structure for MII Management Command reg in mac address map. - * located at address 0x5024 - * bit 1: scan cycle - * bit 0: read cycle - */ - -/* - * structure for MII Management Address reg in mac address map. - * located at address 0x5028 - * 31-13: reserved - * 12-8: phy addr - * 7-5: reserved - * 4-0: register - */ - -#define MII_ADDR(phy, reg) ((phy) << 8 | (reg)) - -/* - * structure for MII Management Control reg in mac address map. - * located at address 0x502C - * 31-16: reserved - * 15-0: phy control - */ - -/* - * structure for MII Management Status reg in mac address map. - * located at address 0x5030 - * 31-16: reserved - * 15-0: phy control - */ - -/* - * structure for MII Management Indicators reg in mac address map. - * located at address 0x5034 - * 31-3: reserved - * 2: not valid - * 1: scanning - * 0: busy - */ - -#define MGMT_BUSY 0x00000001 /* busy */ -#define MGMT_WAIT 0x00000005 /* busy | not valid */ - -/* - * structure for Interface Control reg in mac address map. - * located at address 0x5038 - * - * 31: reset if module - * 30-28: reserved - * 27: tbi mode - * 26: ghd mode - * 25: lhd mode - * 24: phy mode - * 23: reset per mii - * 22-17: reserved - * 16: speed - * 15: reset pe100x - * 14-11: reserved - * 10: force quiet - * 9: no cipher - * 8: disable link fail - * 7: reset gpsi - * 6-1: reserved - * 0: enable jabber protection - */ - -/* - * structure for Interface Status reg in mac address map. - * located at address 0x503C - * - * 31-10: reserved - * 9: excess_defer - * 8: clash - * 7: phy_jabber - * 6: phy_link_ok - * 5: phy_full_duplex - * 4: phy_speed - * 3: pe100x_link_fail - * 2: pe10t_loss_carrier - * 1: pe10t_sqe_error - * 0: pe10t_jabber - */ - -/* - * structure for Mac Station Address, Part 1 reg in mac address map. - * located at address 0x5040 - * - * 31-24: Octet6 - * 23-16: Octet5 - * 15-8: Octet4 - * 7-0: Octet3 - */ - -#define ET_MAC_STATION_ADDR1_OC6_SHIFT 24 -#define ET_MAC_STATION_ADDR1_OC5_SHIFT 16 -#define ET_MAC_STATION_ADDR1_OC4_SHIFT 8 - -/* - * structure for Mac Station Address, Part 2 reg in mac address map. - * located at address 0x5044 - * - * 31-24: Octet2 - * 23-16: Octet1 - * 15-0: reserved - */ - -#define ET_MAC_STATION_ADDR2_OC2_SHIFT 24 -#define ET_MAC_STATION_ADDR2_OC1_SHIFT 16 - -/* - * MAC Module of JAGCore Address Mapping - */ -struct mac_regs { /* Location: */ - u32 cfg1; /* 0x5000 */ - u32 cfg2; /* 0x5004 */ - u32 ipg; /* 0x5008 */ - u32 hfdp; /* 0x500C */ - u32 max_fm_len; /* 0x5010 */ - u32 rsv1; /* 0x5014 */ - u32 rsv2; /* 0x5018 */ - u32 mac_test; /* 0x501C */ - u32 mii_mgmt_cfg; /* 0x5020 */ - u32 mii_mgmt_cmd; /* 0x5024 */ - u32 mii_mgmt_addr; /* 0x5028 */ - u32 mii_mgmt_ctrl; /* 0x502C */ - u32 mii_mgmt_stat; /* 0x5030 */ - u32 mii_mgmt_indicator; /* 0x5034 */ - u32 if_ctrl; /* 0x5038 */ - u32 if_stat; /* 0x503C */ - u32 station_addr_1; /* 0x5040 */ - u32 station_addr_2; /* 0x5044 */ -}; - -/* END OF MAC REGISTER ADDRESS MAP */ - -/* START OF MAC STAT REGISTER ADDRESS MAP */ - -/* - * structure for Carry Register One and it's Mask Register reg located in mac - * stat address map address 0x6130 and 0x6138. - * - * 31: tr64 - * 30: tr127 - * 29: tr255 - * 28: tr511 - * 27: tr1k - * 26: trmax - * 25: trmgv - * 24-17: unused - * 16: rbyt - * 15: rpkt - * 14: rfcs - * 13: rmca - * 12: rbca - * 11: rxcf - * 10: rxpf - * 9: rxuo - * 8: raln - * 7: rflr - * 6: rcde - * 5: rcse - * 4: rund - * 3: rovr - * 2: rfrg - * 1: rjbr - * 0: rdrp - */ - -/* - * structure for Carry Register Two Mask Register reg in mac stat address map. - * located at address 0x613C - * - * 31-20: unused - * 19: tjbr - * 18: tfcs - * 17: txcf - * 16: tovr - * 15: tund - * 14: trfg - * 13: tbyt - * 12: tpkt - * 11: tmca - * 10: tbca - * 9: txpf - * 8: tdfr - * 7: tedf - * 6: tscl - * 5: tmcl - * 4: tlcl - * 3: txcl - * 2: tncl - * 1: tpfh - * 0: tdrp - */ - -/* - * MAC STATS Module of JAGCore Address Mapping - */ -struct macstat_regs { /* Location: */ - u32 pad[32]; /* 0x6000 - 607C */ - - /* Tx/Rx 0-64 Byte Frame Counter */ - u32 txrx_0_64_byte_frames; /* 0x6080 */ - - /* Tx/Rx 65-127 Byte Frame Counter */ - u32 txrx_65_127_byte_frames; /* 0x6084 */ - - /* Tx/Rx 128-255 Byte Frame Counter */ - u32 txrx_128_255_byte_frames; /* 0x6088 */ - - /* Tx/Rx 256-511 Byte Frame Counter */ - u32 txrx_256_511_byte_frames; /* 0x608C */ - - /* Tx/Rx 512-1023 Byte Frame Counter */ - u32 txrx_512_1023_byte_frames; /* 0x6090 */ - - /* Tx/Rx 1024-1518 Byte Frame Counter */ - u32 txrx_1024_1518_byte_frames; /* 0x6094 */ - - /* Tx/Rx 1519-1522 Byte Good VLAN Frame Count */ - u32 txrx_1519_1522_gvln_frames; /* 0x6098 */ - - /* Rx Byte Counter */ - u32 rx_bytes; /* 0x609C */ - - /* Rx Packet Counter */ - u32 rx_packets; /* 0x60A0 */ - - /* Rx FCS Error Counter */ - u32 rx_fcs_errs; /* 0x60A4 */ - - /* Rx Multicast Packet Counter */ - u32 rx_multicast_packets; /* 0x60A8 */ - - /* Rx Broadcast Packet Counter */ - u32 rx_broadcast_packets; /* 0x60AC */ - - /* Rx Control Frame Packet Counter */ - u32 rx_control_frames; /* 0x60B0 */ - - /* Rx Pause Frame Packet Counter */ - u32 rx_pause_frames; /* 0x60B4 */ - - /* Rx Unknown OP Code Counter */ - u32 rx_unknown_opcodes; /* 0x60B8 */ - - /* Rx Alignment Error Counter */ - u32 rx_align_errs; /* 0x60BC */ - - /* Rx Frame Length Error Counter */ - u32 rx_frame_len_errs; /* 0x60C0 */ - - /* Rx Code Error Counter */ - u32 rx_code_errs; /* 0x60C4 */ - - /* Rx Carrier Sense Error Counter */ - u32 rx_carrier_sense_errs; /* 0x60C8 */ - - /* Rx Undersize Packet Counter */ - u32 rx_undersize_packets; /* 0x60CC */ - - /* Rx Oversize Packet Counter */ - u32 rx_oversize_packets; /* 0x60D0 */ - - /* Rx Fragment Counter */ - u32 rx_fragment_packets; /* 0x60D4 */ - - /* Rx Jabber Counter */ - u32 rx_jabbers; /* 0x60D8 */ - - /* Rx Drop */ - u32 rx_drops; /* 0x60DC */ - - /* Tx Byte Counter */ - u32 tx_bytes; /* 0x60E0 */ - - /* Tx Packet Counter */ - u32 tx_packets; /* 0x60E4 */ - - /* Tx Multicast Packet Counter */ - u32 tx_multicast_packets; /* 0x60E8 */ - - /* Tx Broadcast Packet Counter */ - u32 tx_broadcast_packets; /* 0x60EC */ - - /* Tx Pause Control Frame Counter */ - u32 tx_pause_frames; /* 0x60F0 */ - - /* Tx Deferral Packet Counter */ - u32 tx_deferred; /* 0x60F4 */ - - /* Tx Excessive Deferral Packet Counter */ - u32 tx_excessive_deferred; /* 0x60F8 */ - - /* Tx Single Collision Packet Counter */ - u32 tx_single_collisions; /* 0x60FC */ - - /* Tx Multiple Collision Packet Counter */ - u32 tx_multiple_collisions; /* 0x6100 */ - - /* Tx Late Collision Packet Counter */ - u32 tx_late_collisions; /* 0x6104 */ - - /* Tx Excessive Collision Packet Counter */ - u32 tx_excessive_collisions; /* 0x6108 */ - - /* Tx Total Collision Packet Counter */ - u32 tx_total_collisions; /* 0x610C */ - - /* Tx Pause Frame Honored Counter */ - u32 tx_pause_honored_frames; /* 0x6110 */ - - /* Tx Drop Frame Counter */ - u32 tx_drops; /* 0x6114 */ - - /* Tx Jabber Frame Counter */ - u32 tx_jabbers; /* 0x6118 */ - - /* Tx FCS Error Counter */ - u32 tx_fcs_errs; /* 0x611C */ - - /* Tx Control Frame Counter */ - u32 tx_control_frames; /* 0x6120 */ - - /* Tx Oversize Frame Counter */ - u32 tx_oversize_frames; /* 0x6124 */ - - /* Tx Undersize Frame Counter */ - u32 tx_undersize_frames; /* 0x6128 */ - - /* Tx Fragments Frame Counter */ - u32 tx_fragments; /* 0x612C */ - - /* Carry Register One Register */ - u32 carry_reg1; /* 0x6130 */ - - /* Carry Register Two Register */ - u32 carry_reg2; /* 0x6134 */ - - /* Carry Register One Mask Register */ - u32 carry_reg1_mask; /* 0x6138 */ - - /* Carry Register Two Mask Register */ - u32 carry_reg2_mask; /* 0x613C */ -}; - -/* END OF MAC STAT REGISTER ADDRESS MAP */ - - -/* START OF MMC REGISTER ADDRESS MAP */ - -/* - * Main Memory Controller Control reg in mmc address map. - * located at address 0x7000 - */ - -#define ET_MMC_ENABLE 1 -#define ET_MMC_ARB_DISABLE 2 -#define ET_MMC_RXMAC_DISABLE 4 -#define ET_MMC_TXMAC_DISABLE 8 -#define ET_MMC_TXDMA_DISABLE 16 -#define ET_MMC_RXDMA_DISABLE 32 -#define ET_MMC_FORCE_CE 64 - -/* - * Main Memory Controller Host Memory Access Address reg in mmc - * address map. Located at address 0x7004. Top 16 bits hold the address bits - */ - -#define ET_SRAM_REQ_ACCESS 1 -#define ET_SRAM_WR_ACCESS 2 -#define ET_SRAM_IS_CTRL 4 - -/* - * structure for Main Memory Controller Host Memory Access Data reg in mmc - * address map. Located at address 0x7008 - 0x7014 - * Defined earlier (u32) - */ - -/* - * Memory Control Module of JAGCore Address Mapping - */ -struct mmc_regs { /* Location: */ - u32 mmc_ctrl; /* 0x7000 */ - u32 sram_access; /* 0x7004 */ - u32 sram_word1; /* 0x7008 */ - u32 sram_word2; /* 0x700C */ - u32 sram_word3; /* 0x7010 */ - u32 sram_word4; /* 0x7014 */ -}; - -/* END OF MMC REGISTER ADDRESS MAP */ - - -/* - * JAGCore Address Mapping - */ -struct address_map { - struct global_regs global; - /* unused section of global address map */ - u8 unused_global[4096 - sizeof(struct global_regs)]; - struct txdma_regs txdma; - /* unused section of txdma address map */ - u8 unused_txdma[4096 - sizeof(struct txdma_regs)]; - struct rxdma_regs rxdma; - /* unused section of rxdma address map */ - u8 unused_rxdma[4096 - sizeof(struct rxdma_regs)]; - struct txmac_regs txmac; - /* unused section of txmac address map */ - u8 unused_txmac[4096 - sizeof(struct txmac_regs)]; - struct rxmac_regs rxmac; - /* unused section of rxmac address map */ - u8 unused_rxmac[4096 - sizeof(struct rxmac_regs)]; - struct mac_regs mac; - /* unused section of mac address map */ - u8 unused_mac[4096 - sizeof(struct mac_regs)]; - struct macstat_regs macstat; - /* unused section of mac stat address map */ - u8 unused_mac_stat[4096 - sizeof(struct macstat_regs)]; - struct mmc_regs mmc; - /* unused section of mmc address map */ - u8 unused_mmc[4096 - sizeof(struct mmc_regs)]; - /* unused section of address map */ - u8 unused_[1015808]; - - u8 unused_exp_rom[4096]; /* MGS-size TBD */ - u8 unused__[524288]; /* unused section of address map */ -}; - -#endif /* _ET1310_ADDRESS_MAP_H_ */ diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 2803bdf8c68..feb5761f1ec 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h @@ -61,8 +61,6 @@ #ifndef _ET1310_PHY_H_ #define _ET1310_PHY_H_ -#include "et1310_address_map.h" - /* * Defines for generic MII registers 0x00 -> 0x0F can be found in * include/linux/mii.h diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h index a19fab997bc..b3b1bc959d1 100644 --- a/drivers/staging/et131x/et1310_rx.h +++ b/drivers/staging/et131x/et1310_rx.h @@ -61,8 +61,6 @@ #ifndef __ET1310_RX_H__ #define __ET1310_RX_H__ -#include "et1310_address_map.h" - #define USE_FBR0 true #ifdef USE_FBR0 diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index cad271bcad3..60ff3bca358 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -85,7 +85,6 @@ #include "et1310_phy.h" #include "et131x_adapter.h" -#include "et1310_address_map.h" #include "et1310_tx.h" #include "et1310_rx.h" #include "et131x.h" diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 115d30715f5..8f61a7225c2 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -77,3 +77,1373 @@ #define LBCIF_STATUS_CHECKSUM_ERROR 0x40 #define LBCIF_STATUS_EEPROM_PRESENT 0x80 +/* START OF GLOBAL REGISTER ADDRESS MAP */ + +/* + * 10bit registers + * + * Tx queue start address reg in global address map at address 0x0000 + * tx queue end address reg in global address map at address 0x0004 + * rx queue start address reg in global address map at address 0x0008 + * rx queue end address reg in global address map at address 0x000C + */ + +/* + * structure for power management control status reg in global address map + * located at address 0x0010 + * jagcore_rx_rdy bit 9 + * jagcore_tx_rdy bit 8 + * phy_lped_en bit 7 + * phy_sw_coma bit 6 + * rxclk_gate bit 5 + * txclk_gate bit 4 + * sysclk_gate bit 3 + * jagcore_rx_en bit 2 + * jagcore_tx_en bit 1 + * gigephy_en bit 0 + */ + +#define ET_PM_PHY_SW_COMA 0x40 +#define ET_PMCSR_INIT 0x38 + +/* + * Interrupt status reg at address 0x0018 + */ + +#define ET_INTR_TXDMA_ISR 0x00000008 +#define ET_INTR_TXDMA_ERR 0x00000010 +#define ET_INTR_RXDMA_XFR_DONE 0x00000020 +#define ET_INTR_RXDMA_FB_R0_LOW 0x00000040 +#define ET_INTR_RXDMA_FB_R1_LOW 0x00000080 +#define ET_INTR_RXDMA_STAT_LOW 0x00000100 +#define ET_INTR_RXDMA_ERR 0x00000200 +#define ET_INTR_WATCHDOG 0x00004000 +#define ET_INTR_WOL 0x00008000 +#define ET_INTR_PHY 0x00010000 +#define ET_INTR_TXMAC 0x00020000 +#define ET_INTR_RXMAC 0x00040000 +#define ET_INTR_MAC_STAT 0x00080000 +#define ET_INTR_SLV_TIMEOUT 0x00100000 + +/* + * Interrupt mask register at address 0x001C + * Interrupt alias clear mask reg at address 0x0020 + * Interrupt status alias reg at address 0x0024 + * + * Same masks as above + */ + +/* + * Software reset reg at address 0x0028 + * 0: txdma_sw_reset + * 1: rxdma_sw_reset + * 2: txmac_sw_reset + * 3: rxmac_sw_reset + * 4: mac_sw_reset + * 5: mac_stat_sw_reset + * 6: mmc_sw_reset + *31: selfclr_disable + */ + +/* + * SLV Timer reg at address 0x002C (low 24 bits) + */ + +/* + * MSI Configuration reg at address 0x0030 + */ + +#define ET_MSI_VECTOR 0x0000001F +#define ET_MSI_TC 0x00070000 + +/* + * Loopback reg located at address 0x0034 + */ + +#define ET_LOOP_MAC 0x00000001 +#define ET_LOOP_DMA 0x00000002 + +/* + * GLOBAL Module of JAGCore Address Mapping + * Located at address 0x0000 + */ +struct global_regs { /* Location: */ + u32 txq_start_addr; /* 0x0000 */ + u32 txq_end_addr; /* 0x0004 */ + u32 rxq_start_addr; /* 0x0008 */ + u32 rxq_end_addr; /* 0x000C */ + u32 pm_csr; /* 0x0010 */ + u32 unused; /* 0x0014 */ + u32 int_status; /* 0x0018 */ + u32 int_mask; /* 0x001C */ + u32 int_alias_clr_en; /* 0x0020 */ + u32 int_status_alias; /* 0x0024 */ + u32 sw_reset; /* 0x0028 */ + u32 slv_timer; /* 0x002C */ + u32 msi_config; /* 0x0030 */ + u32 loopback; /* 0x0034 */ + u32 watchdog_timer; /* 0x0038 */ +}; + + +/* START OF TXDMA REGISTER ADDRESS MAP */ + +/* + * txdma control status reg at address 0x1000 + */ + +#define ET_TXDMA_CSR_HALT 0x00000001 +#define ET_TXDMA_DROP_TLP 0x00000002 +#define ET_TXDMA_CACHE_THRS 0x000000F0 +#define ET_TXDMA_CACHE_SHIFT 4 +#define ET_TXDMA_SNGL_EPKT 0x00000100 +#define ET_TXDMA_CLASS 0x00001E00 + +/* + * structure for txdma packet ring base address hi reg in txdma address map + * located at address 0x1004 + * Defined earlier (u32) + */ + +/* + * structure for txdma packet ring base address low reg in txdma address map + * located at address 0x1008 + * Defined earlier (u32) + */ + +/* + * structure for txdma packet ring number of descriptor reg in txdma address + * map. Located at address 0x100C + * + * 31-10: unused + * 9-0: pr ndes + */ + +#define ET_DMA12_MASK 0x0FFF /* 12 bit mask for DMA12W types */ +#define ET_DMA12_WRAP 0x1000 +#define ET_DMA10_MASK 0x03FF /* 10 bit mask for DMA10W types */ +#define ET_DMA10_WRAP 0x0400 +#define ET_DMA4_MASK 0x000F /* 4 bit mask for DMA4W types */ +#define ET_DMA4_WRAP 0x0010 + +#define INDEX12(x) ((x) & ET_DMA12_MASK) +#define INDEX10(x) ((x) & ET_DMA10_MASK) +#define INDEX4(x) ((x) & ET_DMA4_MASK) + +extern inline void add_10bit(u32 *v, int n) +{ + *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); +} + +extern inline void add_12bit(u32 *v, int n) +{ + *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); +} + +/* + * 10bit DMA with wrap + * txdma tx queue write address reg in txdma address map at 0x1010 + * txdma tx queue write address external reg in txdma address map at 0x1014 + * txdma tx queue read address reg in txdma address map at 0x1018 + * + * u32 + * txdma status writeback address hi reg in txdma address map at0x101C + * txdma status writeback address lo reg in txdma address map at 0x1020 + * + * 10bit DMA with wrap + * txdma service request reg in txdma address map at 0x1024 + * structure for txdma service complete reg in txdma address map at 0x1028 + * + * 4bit DMA with wrap + * txdma tx descriptor cache read index reg in txdma address map at 0x102C + * txdma tx descriptor cache write index reg in txdma address map at 0x1030 + * + * txdma error reg in txdma address map at address 0x1034 + * 0: PyldResend + * 1: PyldRewind + * 4: DescrResend + * 5: DescrRewind + * 8: WrbkResend + * 9: WrbkRewind + */ + +/* + * Tx DMA Module of JAGCore Address Mapping + * Located at address 0x1000 + */ +struct txdma_regs { /* Location: */ + u32 csr; /* 0x1000 */ + u32 pr_base_hi; /* 0x1004 */ + u32 pr_base_lo; /* 0x1008 */ + u32 pr_num_des; /* 0x100C */ + u32 txq_wr_addr; /* 0x1010 */ + u32 txq_wr_addr_ext; /* 0x1014 */ + u32 txq_rd_addr; /* 0x1018 */ + u32 dma_wb_base_hi; /* 0x101C */ + u32 dma_wb_base_lo; /* 0x1020 */ + u32 service_request; /* 0x1024 */ + u32 service_complete; /* 0x1028 */ + u32 cache_rd_index; /* 0x102C */ + u32 cache_wr_index; /* 0x1030 */ + u32 tx_dma_error; /* 0x1034 */ + u32 desc_abort_cnt; /* 0x1038 */ + u32 payload_abort_cnt; /* 0x103c */ + u32 writeback_abort_cnt; /* 0x1040 */ + u32 desc_timeout_cnt; /* 0x1044 */ + u32 payload_timeout_cnt; /* 0x1048 */ + u32 writeback_timeout_cnt; /* 0x104c */ + u32 desc_error_cnt; /* 0x1050 */ + u32 payload_error_cnt; /* 0x1054 */ + u32 writeback_error_cnt; /* 0x1058 */ + u32 dropped_tlp_cnt; /* 0x105c */ + u32 new_service_complete; /* 0x1060 */ + u32 ethernet_packet_cnt; /* 0x1064 */ +}; + +/* END OF TXDMA REGISTER ADDRESS MAP */ + + +/* START OF RXDMA REGISTER ADDRESS MAP */ + +/* + * structure for control status reg in rxdma address map + * Located at address 0x2000 + * + * CSR + * 0: halt + * 1-3: tc + * 4: fbr_big_endian + * 5: psr_big_endian + * 6: pkt_big_endian + * 7: dma_big_endian + * 8-9: fbr0_size + * 10: fbr0_enable + * 11-12: fbr1_size + * 13: fbr1_enable + * 14: unused + * 15: pkt_drop_disable + * 16: pkt_done_flush + * 17: halt_status + * 18-31: unused + */ + + +/* + * structure for dma writeback lo reg in rxdma address map + * located at address 0x2004 + * Defined earlier (u32) + */ + +/* + * structure for dma writeback hi reg in rxdma address map + * located at address 0x2008 + * Defined earlier (u32) + */ + +/* + * structure for number of packets done reg in rxdma address map + * located at address 0x200C + * + * 31-8: unused + * 7-0: num done + */ + +/* + * structure for max packet time reg in rxdma address map + * located at address 0x2010 + * + * 31-18: unused + * 17-0: time done + */ + +/* + * structure for rx queue read address reg in rxdma address map + * located at address 0x2014 + * Defined earlier (u32) + */ + +/* + * structure for rx queue read address external reg in rxdma address map + * located at address 0x2018 + * Defined earlier (u32) + */ + +/* + * structure for rx queue write address reg in rxdma address map + * located at address 0x201C + * Defined earlier (u32) + */ + +/* + * structure for packet status ring base address lo reg in rxdma address map + * located at address 0x2020 + * Defined earlier (u32) + */ + +/* + * structure for packet status ring base address hi reg in rxdma address map + * located at address 0x2024 + * Defined earlier (u32) + */ + +/* + * structure for packet status ring number of descriptors reg in rxdma address + * map. Located at address 0x2028 + * + * 31-12: unused + * 11-0: psr ndes + */ + +/* + * structure for packet status ring available offset reg in rxdma address map + * located at address 0x202C + * + * 31-13: unused + * 12: psr avail wrap + * 11-0: psr avail + */ + +/* + * structure for packet status ring full offset reg in rxdma address map + * located at address 0x2030 + * + * 31-13: unused + * 12: psr full wrap + * 11-0: psr full + */ + +/* + * structure for packet status ring access index reg in rxdma address map + * located at address 0x2034 + * + * 31-5: unused + * 4-0: psr_ai + */ + +/* + * structure for packet status ring minimum descriptors reg in rxdma address + * map. Located at address 0x2038 + * + * 31-12: unused + * 11-0: psr_min + */ + +/* + * structure for free buffer ring base lo address reg in rxdma address map + * located at address 0x203C + * Defined earlier (u32) + */ + +/* + * structure for free buffer ring base hi address reg in rxdma address map + * located at address 0x2040 + * Defined earlier (u32) + */ + +/* + * structure for free buffer ring number of descriptors reg in rxdma address + * map. Located at address 0x2044 + * + * 31-10: unused + * 9-0: fbr ndesc + */ + +/* + * structure for free buffer ring 0 available offset reg in rxdma address map + * located at address 0x2048 + * Defined earlier (u32) + */ + +/* + * structure for free buffer ring 0 full offset reg in rxdma address map + * located at address 0x204C + * Defined earlier (u32) + */ + +/* + * structure for free buffer cache 0 full offset reg in rxdma address map + * located at address 0x2050 + * + * 31-5: unused + * 4-0: fbc rdi + */ + +/* + * structure for free buffer ring 0 minimum descriptor reg in rxdma address map + * located at address 0x2054 + * + * 31-10: unused + * 9-0: fbr min + */ + +/* + * structure for free buffer ring 1 base address lo reg in rxdma address map + * located at address 0x2058 - 0x205C + * Defined earlier (RXDMA_FBR_BASE_LO_t and RXDMA_FBR_BASE_HI_t) + */ + +/* + * structure for free buffer ring 1 number of descriptors reg in rxdma address + * map. Located at address 0x2060 + * Defined earlier (RXDMA_FBR_NUM_DES_t) + */ + +/* + * structure for free buffer ring 1 available offset reg in rxdma address map + * located at address 0x2064 + * Defined Earlier (RXDMA_FBR_AVAIL_OFFSET_t) + */ + +/* + * structure for free buffer ring 1 full offset reg in rxdma address map + * located at address 0x2068 + * Defined Earlier (RXDMA_FBR_FULL_OFFSET_t) + */ + +/* + * structure for free buffer cache 1 read index reg in rxdma address map + * located at address 0x206C + * Defined Earlier (RXDMA_FBC_RD_INDEX_t) + */ + +/* + * structure for free buffer ring 1 minimum descriptor reg in rxdma address map + * located at address 0x2070 + * Defined Earlier (RXDMA_FBR_MIN_DES_t) + */ + +/* + * Rx DMA Module of JAGCore Address Mapping + * Located at address 0x2000 + */ +struct rxdma_regs { /* Location: */ + u32 csr; /* 0x2000 */ + u32 dma_wb_base_lo; /* 0x2004 */ + u32 dma_wb_base_hi; /* 0x2008 */ + u32 num_pkt_done; /* 0x200C */ + u32 max_pkt_time; /* 0x2010 */ + u32 rxq_rd_addr; /* 0x2014 */ + u32 rxq_rd_addr_ext; /* 0x2018 */ + u32 rxq_wr_addr; /* 0x201C */ + u32 psr_base_lo; /* 0x2020 */ + u32 psr_base_hi; /* 0x2024 */ + u32 psr_num_des; /* 0x2028 */ + u32 psr_avail_offset; /* 0x202C */ + u32 psr_full_offset; /* 0x2030 */ + u32 psr_access_index; /* 0x2034 */ + u32 psr_min_des; /* 0x2038 */ + u32 fbr0_base_lo; /* 0x203C */ + u32 fbr0_base_hi; /* 0x2040 */ + u32 fbr0_num_des; /* 0x2044 */ + u32 fbr0_avail_offset; /* 0x2048 */ + u32 fbr0_full_offset; /* 0x204C */ + u32 fbr0_rd_index; /* 0x2050 */ + u32 fbr0_min_des; /* 0x2054 */ + u32 fbr1_base_lo; /* 0x2058 */ + u32 fbr1_base_hi; /* 0x205C */ + u32 fbr1_num_des; /* 0x2060 */ + u32 fbr1_avail_offset; /* 0x2064 */ + u32 fbr1_full_offset; /* 0x2068 */ + u32 fbr1_rd_index; /* 0x206C */ + u32 fbr1_min_des; /* 0x2070 */ +}; + +/* END OF RXDMA REGISTER ADDRESS MAP */ + + +/* START OF TXMAC REGISTER ADDRESS MAP */ + +/* + * structure for control reg in txmac address map + * located at address 0x3000 + * + * bits + * 31-8: unused + * 7: cklseg_disable + * 6: ckbcnt_disable + * 5: cksegnum + * 4: async_disable + * 3: fc_disable + * 2: mcif_disable + * 1: mif_disable + * 0: txmac_en + */ + +/* + * structure for shadow pointer reg in txmac address map + * located at address 0x3004 + * 31-27: reserved + * 26-16: txq rd ptr + * 15-11: reserved + * 10-0: txq wr ptr + */ + +/* + * structure for error count reg in txmac address map + * located at address 0x3008 + * + * 31-12: unused + * 11-8: reserved + * 7-4: txq_underrun + * 3-0: fifo_underrun + */ + +/* + * structure for max fill reg in txmac address map + * located at address 0x300C + * 31-12: unused + * 11-0: max fill + */ + +/* + * structure for cf parameter reg in txmac address map + * located at address 0x3010 + * 31-16: cfep + * 15-0: cfpt + */ + +/* + * structure for tx test reg in txmac address map + * located at address 0x3014 + * 31-17: unused + * 16: reserved1 + * 15: txtest_en + * 14-11: unused + * 10-0: txq test pointer + */ + +/* + * structure for error reg in txmac address map + * located at address 0x3018 + * + * 31-9: unused + * 8: fifo_underrun + * 7-6: unused + * 5: ctrl2_err + * 4: txq_underrun + * 3: bcnt_err + * 2: lseg_err + * 1: segnum_err + * 0: seg0_err + */ + +/* + * structure for error interrupt reg in txmac address map + * located at address 0x301C + * + * 31-9: unused + * 8: fifo_underrun + * 7-6: unused + * 5: ctrl2_err + * 4: txq_underrun + * 3: bcnt_err + * 2: lseg_err + * 1: segnum_err + * 0: seg0_err + */ + +/* + * structure for error interrupt reg in txmac address map + * located at address 0x3020 + * + * 31-2: unused + * 1: bp_req + * 0: bp_xonxoff + */ + +/* + * Tx MAC Module of JAGCore Address Mapping + */ +struct txmac_regs { /* Location: */ + u32 ctl; /* 0x3000 */ + u32 shadow_ptr; /* 0x3004 */ + u32 err_cnt; /* 0x3008 */ + u32 max_fill; /* 0x300C */ + u32 cf_param; /* 0x3010 */ + u32 tx_test; /* 0x3014 */ + u32 err; /* 0x3018 */ + u32 err_int; /* 0x301C */ + u32 bp_ctrl; /* 0x3020 */ +}; + +/* END OF TXMAC REGISTER ADDRESS MAP */ + +/* START OF RXMAC REGISTER ADDRESS MAP */ + +/* + * structure for rxmac control reg in rxmac address map + * located at address 0x4000 + * + * 31-7: reserved + * 6: rxmac_int_disable + * 5: async_disable + * 4: mif_disable + * 3: wol_disable + * 2: pkt_filter_disable + * 1: mcif_disable + * 0: rxmac_en + */ + +/* + * structure for Wake On Lan Control and CRC 0 reg in rxmac address map + * located at address 0x4004 + * 31-16: crc + * 15-12: reserved + * 11: ignore_pp + * 10: ignore_mp + * 9: clr_intr + * 8: ignore_link_chg + * 7: ignore_uni + * 6: ignore_multi + * 5: ignore_broad + * 4-0: valid_crc 4-0 + */ + +/* + * structure for CRC 1 and CRC 2 reg in rxmac address map + * located at address 0x4008 + * + * 31-16: crc2 + * 15-0: crc1 + */ + +/* + * structure for CRC 3 and CRC 4 reg in rxmac address map + * located at address 0x400C + * + * 31-16: crc4 + * 15-0: crc3 + */ + +/* + * structure for Wake On Lan Source Address Lo reg in rxmac address map + * located at address 0x4010 + * + * 31-24: sa3 + * 23-16: sa4 + * 15-8: sa5 + * 7-0: sa6 + */ + +#define ET_WOL_LO_SA3_SHIFT 24 +#define ET_WOL_LO_SA4_SHIFT 16 +#define ET_WOL_LO_SA5_SHIFT 8 + +/* + * structure for Wake On Lan Source Address Hi reg in rxmac address map + * located at address 0x4014 + * + * 31-16: reserved + * 15-8: sa1 + * 7-0: sa2 + */ + +#define ET_WOL_HI_SA1_SHIFT 8 + +/* + * structure for Wake On Lan mask reg in rxmac address map + * located at address 0x4018 - 0x4064 + * Defined earlier (u32) + */ + +/* + * structure for Unicast Paket Filter Address 1 reg in rxmac address map + * located at address 0x4068 + * + * 31-24: addr1_3 + * 23-16: addr1_4 + * 15-8: addr1_5 + * 7-0: addr1_6 + */ + +#define ET_UNI_PF_ADDR1_3_SHIFT 24 +#define ET_UNI_PF_ADDR1_4_SHIFT 16 +#define ET_UNI_PF_ADDR1_5_SHIFT 8 + +/* + * structure for Unicast Paket Filter Address 2 reg in rxmac address map + * located at address 0x406C + * + * 31-24: addr2_3 + * 23-16: addr2_4 + * 15-8: addr2_5 + * 7-0: addr2_6 + */ + +#define ET_UNI_PF_ADDR2_3_SHIFT 24 +#define ET_UNI_PF_ADDR2_4_SHIFT 16 +#define ET_UNI_PF_ADDR2_5_SHIFT 8 + +/* + * structure for Unicast Paket Filter Address 1 & 2 reg in rxmac address map + * located at address 0x4070 + * + * 31-24: addr2_1 + * 23-16: addr2_2 + * 15-8: addr1_1 + * 7-0: addr1_2 + */ + +#define ET_UNI_PF_ADDR2_1_SHIFT 24 +#define ET_UNI_PF_ADDR2_2_SHIFT 16 +#define ET_UNI_PF_ADDR1_1_SHIFT 8 + + +/* + * structure for Multicast Hash reg in rxmac address map + * located at address 0x4074 - 0x4080 + * Defined earlier (u32) + */ + +/* + * structure for Packet Filter Control reg in rxmac address map + * located at address 0x4084 + * + * 31-23: unused + * 22-16: min_pkt_size + * 15-4: unused + * 3: filter_frag_en + * 2: filter_uni_en + * 1: filter_multi_en + * 0: filter_broad_en + */ + +/* + * structure for Memory Controller Interface Control Max Segment reg in rxmac + * address map. Located at address 0x4088 + * + * 31-10: reserved + * 9-2: max_size + * 1: fc_en + * 0: seg_en + */ + +/* + * structure for Memory Controller Interface Water Mark reg in rxmac address + * map. Located at address 0x408C + * + * 31-26: unused + * 25-16: mark_hi + * 15-10: unused + * 9-0: mark_lo + */ + +/* + * structure for Rx Queue Dialog reg in rxmac address map. + * located at address 0x4090 + * + * 31-26: reserved + * 25-16: rd_ptr + * 15-10: reserved + * 9-0: wr_ptr + */ + +/* + * structure for space available reg in rxmac address map. + * located at address 0x4094 + * + * 31-17: reserved + * 16: space_avail_en + * 15-10: reserved + * 9-0: space_avail + */ + +/* + * structure for management interface reg in rxmac address map. + * located at address 0x4098 + * + * 31-18: reserved + * 17: drop_pkt_en + * 16-0: drop_pkt_mask + */ + +/* + * structure for Error reg in rxmac address map. + * located at address 0x409C + * + * 31-4: unused + * 3: mif + * 2: async + * 1: pkt_filter + * 0: mcif + */ + +/* + * Rx MAC Module of JAGCore Address Mapping + */ +struct rxmac_regs { /* Location: */ + u32 ctrl; /* 0x4000 */ + u32 crc0; /* 0x4004 */ + u32 crc12; /* 0x4008 */ + u32 crc34; /* 0x400C */ + u32 sa_lo; /* 0x4010 */ + u32 sa_hi; /* 0x4014 */ + u32 mask0_word0; /* 0x4018 */ + u32 mask0_word1; /* 0x401C */ + u32 mask0_word2; /* 0x4020 */ + u32 mask0_word3; /* 0x4024 */ + u32 mask1_word0; /* 0x4028 */ + u32 mask1_word1; /* 0x402C */ + u32 mask1_word2; /* 0x4030 */ + u32 mask1_word3; /* 0x4034 */ + u32 mask2_word0; /* 0x4038 */ + u32 mask2_word1; /* 0x403C */ + u32 mask2_word2; /* 0x4040 */ + u32 mask2_word3; /* 0x4044 */ + u32 mask3_word0; /* 0x4048 */ + u32 mask3_word1; /* 0x404C */ + u32 mask3_word2; /* 0x4050 */ + u32 mask3_word3; /* 0x4054 */ + u32 mask4_word0; /* 0x4058 */ + u32 mask4_word1; /* 0x405C */ + u32 mask4_word2; /* 0x4060 */ + u32 mask4_word3; /* 0x4064 */ + u32 uni_pf_addr1; /* 0x4068 */ + u32 uni_pf_addr2; /* 0x406C */ + u32 uni_pf_addr3; /* 0x4070 */ + u32 multi_hash1; /* 0x4074 */ + u32 multi_hash2; /* 0x4078 */ + u32 multi_hash3; /* 0x407C */ + u32 multi_hash4; /* 0x4080 */ + u32 pf_ctrl; /* 0x4084 */ + u32 mcif_ctrl_max_seg; /* 0x4088 */ + u32 mcif_water_mark; /* 0x408C */ + u32 rxq_diag; /* 0x4090 */ + u32 space_avail; /* 0x4094 */ + + u32 mif_ctrl; /* 0x4098 */ + u32 err_reg; /* 0x409C */ +}; + +/* END OF RXMAC REGISTER ADDRESS MAP */ + + +/* START OF MAC REGISTER ADDRESS MAP */ + +/* + * structure for configuration #1 reg in mac address map. + * located at address 0x5000 + * + * 31: soft reset + * 30: sim reset + * 29-20: reserved + * 19: reset rx mc + * 18: reset tx mc + * 17: reset rx func + * 16: reset tx fnc + * 15-9: reserved + * 8: loopback + * 7-6: reserved + * 5: rx flow + * 4: tx flow + * 3: syncd rx en + * 2: rx enable + * 1: syncd tx en + * 0: tx enable + */ + +#define CFG1_LOOPBACK 0x00000100 +#define CFG1_RX_FLOW 0x00000020 +#define CFG1_TX_FLOW 0x00000010 +#define CFG1_RX_ENABLE 0x00000004 +#define CFG1_TX_ENABLE 0x00000001 +#define CFG1_WAIT 0x0000000A /* RX & TX syncd */ + +/* + * structure for configuration #2 reg in mac address map. + * located at address 0x5004 + * 31-16: reserved + * 15-12: preamble + * 11-10: reserved + * 9-8: if mode + * 7-6: reserved + * 5: huge frame + * 4: length check + * 3: undefined + * 2: pad crc + * 1: crc enable + * 0: full duplex + */ + + +/* + * structure for Interpacket gap reg in mac address map. + * located at address 0x5008 + * + * 31: reserved + * 30-24: non B2B ipg 1 + * 23: undefined + * 22-16: non B2B ipg 2 + * 15-8: Min ifg enforce + * 7-0: B2B ipg + * + * structure for half duplex reg in mac address map. + * located at address 0x500C + * 31-24: reserved + * 23-20: Alt BEB trunc + * 19: Alt BEB enable + * 18: BP no backoff + * 17: no backoff + * 16: excess defer + * 15-12: re-xmit max + * 11-10: reserved + * 9-0: collision window + */ + +/* + * structure for Maximum Frame Length reg in mac address map. + * located at address 0x5010: bits 0-15 hold the length. + */ + +/* + * structure for Reserve 1 reg in mac address map. + * located at address 0x5014 - 0x5018 + * Defined earlier (u32) + */ + +/* + * structure for Test reg in mac address map. + * located at address 0x501C + * test: bits 0-2, rest unused + */ + +/* + * structure for MII Management Configuration reg in mac address map. + * located at address 0x5020 + * + * 31: reset MII mgmt + * 30-6: unused + * 5: scan auto increment + * 4: preamble suppress + * 3: undefined + * 2-0: mgmt clock reset + */ + +/* + * structure for MII Management Command reg in mac address map. + * located at address 0x5024 + * bit 1: scan cycle + * bit 0: read cycle + */ + +/* + * structure for MII Management Address reg in mac address map. + * located at address 0x5028 + * 31-13: reserved + * 12-8: phy addr + * 7-5: reserved + * 4-0: register + */ + +#define MII_ADDR(phy, reg) ((phy) << 8 | (reg)) + +/* + * structure for MII Management Control reg in mac address map. + * located at address 0x502C + * 31-16: reserved + * 15-0: phy control + */ + +/* + * structure for MII Management Status reg in mac address map. + * located at address 0x5030 + * 31-16: reserved + * 15-0: phy control + */ + +/* + * structure for MII Management Indicators reg in mac address map. + * located at address 0x5034 + * 31-3: reserved + * 2: not valid + * 1: scanning + * 0: busy + */ + +#define MGMT_BUSY 0x00000001 /* busy */ +#define MGMT_WAIT 0x00000005 /* busy | not valid */ + +/* + * structure for Interface Control reg in mac address map. + * located at address 0x5038 + * + * 31: reset if module + * 30-28: reserved + * 27: tbi mode + * 26: ghd mode + * 25: lhd mode + * 24: phy mode + * 23: reset per mii + * 22-17: reserved + * 16: speed + * 15: reset pe100x + * 14-11: reserved + * 10: force quiet + * 9: no cipher + * 8: disable link fail + * 7: reset gpsi + * 6-1: reserved + * 0: enable jabber protection + */ + +/* + * structure for Interface Status reg in mac address map. + * located at address 0x503C + * + * 31-10: reserved + * 9: excess_defer + * 8: clash + * 7: phy_jabber + * 6: phy_link_ok + * 5: phy_full_duplex + * 4: phy_speed + * 3: pe100x_link_fail + * 2: pe10t_loss_carrier + * 1: pe10t_sqe_error + * 0: pe10t_jabber + */ + +/* + * structure for Mac Station Address, Part 1 reg in mac address map. + * located at address 0x5040 + * + * 31-24: Octet6 + * 23-16: Octet5 + * 15-8: Octet4 + * 7-0: Octet3 + */ + +#define ET_MAC_STATION_ADDR1_OC6_SHIFT 24 +#define ET_MAC_STATION_ADDR1_OC5_SHIFT 16 +#define ET_MAC_STATION_ADDR1_OC4_SHIFT 8 + +/* + * structure for Mac Station Address, Part 2 reg in mac address map. + * located at address 0x5044 + * + * 31-24: Octet2 + * 23-16: Octet1 + * 15-0: reserved + */ + +#define ET_MAC_STATION_ADDR2_OC2_SHIFT 24 +#define ET_MAC_STATION_ADDR2_OC1_SHIFT 16 + +/* + * MAC Module of JAGCore Address Mapping + */ +struct mac_regs { /* Location: */ + u32 cfg1; /* 0x5000 */ + u32 cfg2; /* 0x5004 */ + u32 ipg; /* 0x5008 */ + u32 hfdp; /* 0x500C */ + u32 max_fm_len; /* 0x5010 */ + u32 rsv1; /* 0x5014 */ + u32 rsv2; /* 0x5018 */ + u32 mac_test; /* 0x501C */ + u32 mii_mgmt_cfg; /* 0x5020 */ + u32 mii_mgmt_cmd; /* 0x5024 */ + u32 mii_mgmt_addr; /* 0x5028 */ + u32 mii_mgmt_ctrl; /* 0x502C */ + u32 mii_mgmt_stat; /* 0x5030 */ + u32 mii_mgmt_indicator; /* 0x5034 */ + u32 if_ctrl; /* 0x5038 */ + u32 if_stat; /* 0x503C */ + u32 station_addr_1; /* 0x5040 */ + u32 station_addr_2; /* 0x5044 */ +}; + +/* END OF MAC REGISTER ADDRESS MAP */ + +/* START OF MAC STAT REGISTER ADDRESS MAP */ + +/* + * structure for Carry Register One and it's Mask Register reg located in mac + * stat address map address 0x6130 and 0x6138. + * + * 31: tr64 + * 30: tr127 + * 29: tr255 + * 28: tr511 + * 27: tr1k + * 26: trmax + * 25: trmgv + * 24-17: unused + * 16: rbyt + * 15: rpkt + * 14: rfcs + * 13: rmca + * 12: rbca + * 11: rxcf + * 10: rxpf + * 9: rxuo + * 8: raln + * 7: rflr + * 6: rcde + * 5: rcse + * 4: rund + * 3: rovr + * 2: rfrg + * 1: rjbr + * 0: rdrp + */ + +/* + * structure for Carry Register Two Mask Register reg in mac stat address map. + * located at address 0x613C + * + * 31-20: unused + * 19: tjbr + * 18: tfcs + * 17: txcf + * 16: tovr + * 15: tund + * 14: trfg + * 13: tbyt + * 12: tpkt + * 11: tmca + * 10: tbca + * 9: txpf + * 8: tdfr + * 7: tedf + * 6: tscl + * 5: tmcl + * 4: tlcl + * 3: txcl + * 2: tncl + * 1: tpfh + * 0: tdrp + */ + +/* + * MAC STATS Module of JAGCore Address Mapping + */ +struct macstat_regs { /* Location: */ + u32 pad[32]; /* 0x6000 - 607C */ + + /* Tx/Rx 0-64 Byte Frame Counter */ + u32 txrx_0_64_byte_frames; /* 0x6080 */ + + /* Tx/Rx 65-127 Byte Frame Counter */ + u32 txrx_65_127_byte_frames; /* 0x6084 */ + + /* Tx/Rx 128-255 Byte Frame Counter */ + u32 txrx_128_255_byte_frames; /* 0x6088 */ + + /* Tx/Rx 256-511 Byte Frame Counter */ + u32 txrx_256_511_byte_frames; /* 0x608C */ + + /* Tx/Rx 512-1023 Byte Frame Counter */ + u32 txrx_512_1023_byte_frames; /* 0x6090 */ + + /* Tx/Rx 1024-1518 Byte Frame Counter */ + u32 txrx_1024_1518_byte_frames; /* 0x6094 */ + + /* Tx/Rx 1519-1522 Byte Good VLAN Frame Count */ + u32 txrx_1519_1522_gvln_frames; /* 0x6098 */ + + /* Rx Byte Counter */ + u32 rx_bytes; /* 0x609C */ + + /* Rx Packet Counter */ + u32 rx_packets; /* 0x60A0 */ + + /* Rx FCS Error Counter */ + u32 rx_fcs_errs; /* 0x60A4 */ + + /* Rx Multicast Packet Counter */ + u32 rx_multicast_packets; /* 0x60A8 */ + + /* Rx Broadcast Packet Counter */ + u32 rx_broadcast_packets; /* 0x60AC */ + + /* Rx Control Frame Packet Counter */ + u32 rx_control_frames; /* 0x60B0 */ + + /* Rx Pause Frame Packet Counter */ + u32 rx_pause_frames; /* 0x60B4 */ + + /* Rx Unknown OP Code Counter */ + u32 rx_unknown_opcodes; /* 0x60B8 */ + + /* Rx Alignment Error Counter */ + u32 rx_align_errs; /* 0x60BC */ + + /* Rx Frame Length Error Counter */ + u32 rx_frame_len_errs; /* 0x60C0 */ + + /* Rx Code Error Counter */ + u32 rx_code_errs; /* 0x60C4 */ + + /* Rx Carrier Sense Error Counter */ + u32 rx_carrier_sense_errs; /* 0x60C8 */ + + /* Rx Undersize Packet Counter */ + u32 rx_undersize_packets; /* 0x60CC */ + + /* Rx Oversize Packet Counter */ + u32 rx_oversize_packets; /* 0x60D0 */ + + /* Rx Fragment Counter */ + u32 rx_fragment_packets; /* 0x60D4 */ + + /* Rx Jabber Counter */ + u32 rx_jabbers; /* 0x60D8 */ + + /* Rx Drop */ + u32 rx_drops; /* 0x60DC */ + + /* Tx Byte Counter */ + u32 tx_bytes; /* 0x60E0 */ + + /* Tx Packet Counter */ + u32 tx_packets; /* 0x60E4 */ + + /* Tx Multicast Packet Counter */ + u32 tx_multicast_packets; /* 0x60E8 */ + + /* Tx Broadcast Packet Counter */ + u32 tx_broadcast_packets; /* 0x60EC */ + + /* Tx Pause Control Frame Counter */ + u32 tx_pause_frames; /* 0x60F0 */ + + /* Tx Deferral Packet Counter */ + u32 tx_deferred; /* 0x60F4 */ + + /* Tx Excessive Deferral Packet Counter */ + u32 tx_excessive_deferred; /* 0x60F8 */ + + /* Tx Single Collision Packet Counter */ + u32 tx_single_collisions; /* 0x60FC */ + + /* Tx Multiple Collision Packet Counter */ + u32 tx_multiple_collisions; /* 0x6100 */ + + /* Tx Late Collision Packet Counter */ + u32 tx_late_collisions; /* 0x6104 */ + + /* Tx Excessive Collision Packet Counter */ + u32 tx_excessive_collisions; /* 0x6108 */ + + /* Tx Total Collision Packet Counter */ + u32 tx_total_collisions; /* 0x610C */ + + /* Tx Pause Frame Honored Counter */ + u32 tx_pause_honored_frames; /* 0x6110 */ + + /* Tx Drop Frame Counter */ + u32 tx_drops; /* 0x6114 */ + + /* Tx Jabber Frame Counter */ + u32 tx_jabbers; /* 0x6118 */ + + /* Tx FCS Error Counter */ + u32 tx_fcs_errs; /* 0x611C */ + + /* Tx Control Frame Counter */ + u32 tx_control_frames; /* 0x6120 */ + + /* Tx Oversize Frame Counter */ + u32 tx_oversize_frames; /* 0x6124 */ + + /* Tx Undersize Frame Counter */ + u32 tx_undersize_frames; /* 0x6128 */ + + /* Tx Fragments Frame Counter */ + u32 tx_fragments; /* 0x612C */ + + /* Carry Register One Register */ + u32 carry_reg1; /* 0x6130 */ + + /* Carry Register Two Register */ + u32 carry_reg2; /* 0x6134 */ + + /* Carry Register One Mask Register */ + u32 carry_reg1_mask; /* 0x6138 */ + + /* Carry Register Two Mask Register */ + u32 carry_reg2_mask; /* 0x613C */ +}; + +/* END OF MAC STAT REGISTER ADDRESS MAP */ + +/* START OF MMC REGISTER ADDRESS MAP */ + +/* + * Main Memory Controller Control reg in mmc address map. + * located at address 0x7000 + */ + +#define ET_MMC_ENABLE 1 +#define ET_MMC_ARB_DISABLE 2 +#define ET_MMC_RXMAC_DISABLE 4 +#define ET_MMC_TXMAC_DISABLE 8 +#define ET_MMC_TXDMA_DISABLE 16 +#define ET_MMC_RXDMA_DISABLE 32 +#define ET_MMC_FORCE_CE 64 + +/* + * Main Memory Controller Host Memory Access Address reg in mmc + * address map. Located at address 0x7004. Top 16 bits hold the address bits + */ + +#define ET_SRAM_REQ_ACCESS 1 +#define ET_SRAM_WR_ACCESS 2 +#define ET_SRAM_IS_CTRL 4 + +/* + * structure for Main Memory Controller Host Memory Access Data reg in mmc + * address map. Located at address 0x7008 - 0x7014 + * Defined earlier (u32) + */ + +/* + * Memory Control Module of JAGCore Address Mapping + */ +struct mmc_regs { /* Location: */ + u32 mmc_ctrl; /* 0x7000 */ + u32 sram_access; /* 0x7004 */ + u32 sram_word1; /* 0x7008 */ + u32 sram_word2; /* 0x700C */ + u32 sram_word3; /* 0x7010 */ + u32 sram_word4; /* 0x7014 */ +}; + +/* END OF MMC REGISTER ADDRESS MAP */ + + +/* + * JAGCore Address Mapping + */ +struct address_map { + struct global_regs global; + /* unused section of global address map */ + u8 unused_global[4096 - sizeof(struct global_regs)]; + struct txdma_regs txdma; + /* unused section of txdma address map */ + u8 unused_txdma[4096 - sizeof(struct txdma_regs)]; + struct rxdma_regs rxdma; + /* unused section of rxdma address map */ + u8 unused_rxdma[4096 - sizeof(struct rxdma_regs)]; + struct txmac_regs txmac; + /* unused section of txmac address map */ + u8 unused_txmac[4096 - sizeof(struct txmac_regs)]; + struct rxmac_regs rxmac; + /* unused section of rxmac address map */ + u8 unused_rxmac[4096 - sizeof(struct rxmac_regs)]; + struct mac_regs mac; + /* unused section of mac address map */ + u8 unused_mac[4096 - sizeof(struct mac_regs)]; + struct macstat_regs macstat; + /* unused section of mac stat address map */ + u8 unused_mac_stat[4096 - sizeof(struct macstat_regs)]; + struct mmc_regs mmc; + /* unused section of mmc address map */ + u8 unused_mmc[4096 - sizeof(struct mmc_regs)]; + /* unused section of address map */ + u8 unused_[1015808]; + + u8 unused_exp_rom[4096]; /* MGS-size TBD */ + u8 unused__[524288]; /* unused section of address map */ +}; diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index b062e6dc585..74efdb04b20 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h @@ -61,7 +61,6 @@ #ifndef __ET131X_ADAPTER_H__ #define __ET131X_ADAPTER_H__ -#include "et1310_address_map.h" #include "et1310_tx.h" #include "et1310_rx.h" From 2b2b9554de6c1e0695bd349324f17cf0973f4c25 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:34 +0100 Subject: [PATCH 1485/1519] staging: et131x: move et1310_phy.h contents into et131x.h Move et1310_phy.h register defines into et131x.h and delete et1310_phy.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.h | 290 ---------------------------- drivers/staging/et131x/et131x.c | 1 - drivers/staging/et131x/et131x.h | 227 ++++++++++++++++++++++ 3 files changed, 227 insertions(+), 291 deletions(-) delete mode 100644 drivers/staging/et131x/et1310_phy.h diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h deleted file mode 100644 index feb5761f1ec..00000000000 --- a/drivers/staging/et131x/et1310_phy.h +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_phy.h - Defines, structs, enums, prototypes, etc. pertaining to the - * PHY. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef _ET1310_PHY_H_ -#define _ET1310_PHY_H_ - -/* - * Defines for generic MII registers 0x00 -> 0x0F can be found in - * include/linux/mii.h - */ - -/* some defines for modem registers that seem to be 'reserved' */ -#define PHY_INDEX_REG 0x10 -#define PHY_DATA_REG 0x11 -#define PHY_MPHY_CONTROL_REG 0x12 - -/* defines for specified registers */ -#define PHY_LOOPBACK_CONTROL 0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */ - /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */ -#define PHY_REGISTER_MGMT_CONTROL 0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG 21 */ -#define PHY_CONFIG 0x16 /* TRU_VMI_CONFIGURATION_REG 22 */ -#define PHY_PHY_CONTROL 0x17 /* TRU_VMI_PHY_CONTROL_REG 23 */ -#define PHY_INTERRUPT_MASK 0x18 /* TRU_VMI_INTERRUPT_MASK_REG 24 */ -#define PHY_INTERRUPT_STATUS 0x19 /* TRU_VMI_INTERRUPT_STATUS_REG 25 */ -#define PHY_PHY_STATUS 0x1A /* TRU_VMI_PHY_STATUS_REG 26 */ -#define PHY_LED_1 0x1B /* TRU_VMI_LED_CONTROL_1_REG 27 */ -#define PHY_LED_2 0x1C /* TRU_VMI_LED_CONTROL_2_REG 28 */ - /* TRU_VMI_LINK_CONTROL_REG 29 */ - /* TRU_VMI_TIMING_CONTROL_REG */ - -/* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */ -#define ET_1000BT_MSTR_SLV 0x4000 - -/* MI Register 16 - 18: Reserved Reg(0x10-0x12) */ - -/* MI Register 19: Loopback Control Reg(0x13) - * 15: mii_en - * 14: pcs_en - * 13: pmd_en - * 12: all_digital_en - * 11: replica_en - * 10: line_driver_en - * 9-0: reserved - */ - -/* MI Register 20: Reserved Reg(0x14) */ - -/* MI Register 21: Management Interface Control Reg(0x15) - * 15-11: reserved - * 10-4: mi_error_count - * 3: reserved - * 2: ignore_10g_fr - * 1: reserved - * 0: preamble_supress_en - */ - -/* MI Register 22: PHY Configuration Reg(0x16) - * 15: crs_tx_en - * 14: reserved - * 13-12: tx_fifo_depth - * 11-10: speed_downshift - * 9: pbi_detect - * 8: tbi_rate - * 7: alternate_np - * 6: group_mdio_en - * 5: tx_clock_en - * 4: sys_clock_en - * 3: reserved - * 2-0: mac_if_mode - */ - -#define ET_PHY_CONFIG_TX_FIFO_DEPTH 0x3000 - -#define ET_PHY_CONFIG_FIFO_DEPTH_8 0x0000 -#define ET_PHY_CONFIG_FIFO_DEPTH_16 0x1000 -#define ET_PHY_CONFIG_FIFO_DEPTH_32 0x2000 -#define ET_PHY_CONFIG_FIFO_DEPTH_64 0x3000 - -/* MI Register 23: PHY CONTROL Reg(0x17) - * 15: reserved - * 14: tdr_en - * 13: reserved - * 12-11: downshift_attempts - * 10-6: reserved - * 5: jabber_10baseT - * 4: sqe_10baseT - * 3: tp_loopback_10baseT - * 2: preamble_gen_en - * 1: reserved - * 0: force_int - */ - -/* MI Register 24: Interrupt Mask Reg(0x18) - * 15-10: reserved - * 9: mdio_sync_lost - * 8: autoneg_status - * 7: hi_bit_err - * 6: np_rx - * 5: err_counter_full - * 4: fifo_over_underflow - * 3: rx_status - * 2: link_status - * 1: automatic_speed - * 0: int_en - */ - -#define ET_PHY_INT_MASK_AUTONEGSTAT 0x0100 -#define ET_PHY_INT_MASK_LINKSTAT 0x0004 -#define ET_PHY_INT_MASK_ENABLE 0x0001 - -/* MI Register 25: Interrupt Status Reg(0x19) - * 15-10: reserved - * 9: mdio_sync_lost - * 8: autoneg_status - * 7: hi_bit_err - * 6: np_rx - * 5: err_counter_full - * 4: fifo_over_underflow - * 3: rx_status - * 2: link_status - * 1: automatic_speed - * 0: int_en - */ - -/* MI Register 26: PHY Status Reg(0x1A) - * 15: reserved - * 14-13: autoneg_fault - * 12: autoneg_status - * 11: mdi_x_status - * 10: polarity_status - * 9-8: speed_status - * 7: duplex_status - * 6: link_status - * 5: tx_status - * 4: rx_status - * 3: collision_status - * 2: autoneg_en - * 1: pause_en - * 0: asymmetric_dir - */ -#define ET_PHY_AUTONEG_STATUS 0x1000 -#define ET_PHY_POLARITY_STATUS 0x0400 -#define ET_PHY_SPEED_STATUS 0x0300 -#define ET_PHY_DUPLEX_STATUS 0x0080 -#define ET_PHY_LSTATUS 0x0040 -#define ET_PHY_AUTONEG_ENABLE 0x0020 - -/* MI Register 27: LED Control Reg 1(0x1B) - * 15-14: reserved - * 13-12: led_dup_indicate - * 11-10: led_10baseT - * 9-8: led_collision - * 7-4: reserved - * 3-2: pulse_dur - * 1: pulse_stretch1 - * 0: pulse_stretch0 - */ - -/* MI Register 28: LED Control Reg 2(0x1C) - * 15-12: led_link - * 11-8: led_tx_rx - * 7-4: led_100BaseTX - * 3-0: led_1000BaseT - */ -#define ET_LED2_LED_LINK 0xF000 -#define ET_LED2_LED_TXRX 0x0F00 -#define ET_LED2_LED_100TX 0x00F0 -#define ET_LED2_LED_1000T 0x000F - -/* defines for LED control reg 2 values */ -#define LED_VAL_1000BT 0x0 -#define LED_VAL_100BTX 0x1 -#define LED_VAL_10BT 0x2 -#define LED_VAL_1000BT_100BTX 0x3 /* 1000BT on, 100BTX blink */ -#define LED_VAL_LINKON 0x4 -#define LED_VAL_TX 0x5 -#define LED_VAL_RX 0x6 -#define LED_VAL_TXRX 0x7 /* TX or RX */ -#define LED_VAL_DUPLEXFULL 0x8 -#define LED_VAL_COLLISION 0x9 -#define LED_VAL_LINKON_ACTIVE 0xA /* Link on, activity blink */ -#define LED_VAL_LINKON_RECV 0xB /* Link on, receive blink */ -#define LED_VAL_DUPLEXFULL_COLLISION 0xC /* Duplex on, collision blink */ -#define LED_VAL_BLINK 0xD -#define LED_VAL_ON 0xE -#define LED_VAL_OFF 0xF - -#define LED_LINK_SHIFT 12 -#define LED_TXRX_SHIFT 8 -#define LED_100TX_SHIFT 4 - -/* MI Register 29 - 31: Reserved Reg(0x1D - 0x1E) */ - -/* Defines for PHY access routines */ - -/* Define bit operation flags */ -#define TRUEPHY_BIT_CLEAR 0 -#define TRUEPHY_BIT_SET 1 -#define TRUEPHY_BIT_READ 2 - -/* Define read/write operation flags */ -#ifndef TRUEPHY_READ -#define TRUEPHY_READ 0 -#define TRUEPHY_WRITE 1 -#define TRUEPHY_MASK 2 -#endif - -/* Define master/slave configuration values */ -#define TRUEPHY_CFG_SLAVE 0 -#define TRUEPHY_CFG_MASTER 1 - -/* Define MDI/MDI-X settings */ -#define TRUEPHY_MDI 0 -#define TRUEPHY_MDIX 1 -#define TRUEPHY_AUTO_MDI_MDIX 2 - -/* Define 10Base-T link polarities */ -#define TRUEPHY_POLARITY_NORMAL 0 -#define TRUEPHY_POLARITY_INVERTED 1 - -/* Define auto-negotiation results */ -#define TRUEPHY_ANEG_NOT_COMPLETE 0 -#define TRUEPHY_ANEG_COMPLETE 1 -#define TRUEPHY_ANEG_DISABLED 2 - -/* Define duplex advertisement flags */ -#define TRUEPHY_ADV_DUPLEX_NONE 0x00 -#define TRUEPHY_ADV_DUPLEX_FULL 0x01 -#define TRUEPHY_ADV_DUPLEX_HALF 0x02 -#define TRUEPHY_ADV_DUPLEX_BOTH \ - (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF) - -#endif /* _ET1310_PHY_H_ */ diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 60ff3bca358..271ae31b77f 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -83,7 +83,6 @@ #include #include -#include "et1310_phy.h" #include "et131x_adapter.h" #include "et1310_tx.h" #include "et1310_rx.h" diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 8f61a7225c2..84b274d90ce 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -1447,3 +1447,230 @@ struct address_map { u8 unused_exp_rom[4096]; /* MGS-size TBD */ u8 unused__[524288]; /* unused section of address map */ }; + +/* + * Defines for generic MII registers 0x00 -> 0x0F can be found in + * include/linux/mii.h + */ + +/* some defines for modem registers that seem to be 'reserved' */ +#define PHY_INDEX_REG 0x10 +#define PHY_DATA_REG 0x11 +#define PHY_MPHY_CONTROL_REG 0x12 + +/* defines for specified registers */ +#define PHY_LOOPBACK_CONTROL 0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */ + /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */ +#define PHY_REGISTER_MGMT_CONTROL 0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG 21 */ +#define PHY_CONFIG 0x16 /* TRU_VMI_CONFIGURATION_REG 22 */ +#define PHY_PHY_CONTROL 0x17 /* TRU_VMI_PHY_CONTROL_REG 23 */ +#define PHY_INTERRUPT_MASK 0x18 /* TRU_VMI_INTERRUPT_MASK_REG 24 */ +#define PHY_INTERRUPT_STATUS 0x19 /* TRU_VMI_INTERRUPT_STATUS_REG 25 */ +#define PHY_PHY_STATUS 0x1A /* TRU_VMI_PHY_STATUS_REG 26 */ +#define PHY_LED_1 0x1B /* TRU_VMI_LED_CONTROL_1_REG 27 */ +#define PHY_LED_2 0x1C /* TRU_VMI_LED_CONTROL_2_REG 28 */ + /* TRU_VMI_LINK_CONTROL_REG 29 */ + /* TRU_VMI_TIMING_CONTROL_REG */ + +/* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */ +#define ET_1000BT_MSTR_SLV 0x4000 + +/* MI Register 16 - 18: Reserved Reg(0x10-0x12) */ + +/* MI Register 19: Loopback Control Reg(0x13) + * 15: mii_en + * 14: pcs_en + * 13: pmd_en + * 12: all_digital_en + * 11: replica_en + * 10: line_driver_en + * 9-0: reserved + */ + +/* MI Register 20: Reserved Reg(0x14) */ + +/* MI Register 21: Management Interface Control Reg(0x15) + * 15-11: reserved + * 10-4: mi_error_count + * 3: reserved + * 2: ignore_10g_fr + * 1: reserved + * 0: preamble_supress_en + */ + +/* MI Register 22: PHY Configuration Reg(0x16) + * 15: crs_tx_en + * 14: reserved + * 13-12: tx_fifo_depth + * 11-10: speed_downshift + * 9: pbi_detect + * 8: tbi_rate + * 7: alternate_np + * 6: group_mdio_en + * 5: tx_clock_en + * 4: sys_clock_en + * 3: reserved + * 2-0: mac_if_mode + */ + +#define ET_PHY_CONFIG_TX_FIFO_DEPTH 0x3000 + +#define ET_PHY_CONFIG_FIFO_DEPTH_8 0x0000 +#define ET_PHY_CONFIG_FIFO_DEPTH_16 0x1000 +#define ET_PHY_CONFIG_FIFO_DEPTH_32 0x2000 +#define ET_PHY_CONFIG_FIFO_DEPTH_64 0x3000 + +/* MI Register 23: PHY CONTROL Reg(0x17) + * 15: reserved + * 14: tdr_en + * 13: reserved + * 12-11: downshift_attempts + * 10-6: reserved + * 5: jabber_10baseT + * 4: sqe_10baseT + * 3: tp_loopback_10baseT + * 2: preamble_gen_en + * 1: reserved + * 0: force_int + */ + +/* MI Register 24: Interrupt Mask Reg(0x18) + * 15-10: reserved + * 9: mdio_sync_lost + * 8: autoneg_status + * 7: hi_bit_err + * 6: np_rx + * 5: err_counter_full + * 4: fifo_over_underflow + * 3: rx_status + * 2: link_status + * 1: automatic_speed + * 0: int_en + */ + +#define ET_PHY_INT_MASK_AUTONEGSTAT 0x0100 +#define ET_PHY_INT_MASK_LINKSTAT 0x0004 +#define ET_PHY_INT_MASK_ENABLE 0x0001 + +/* MI Register 25: Interrupt Status Reg(0x19) + * 15-10: reserved + * 9: mdio_sync_lost + * 8: autoneg_status + * 7: hi_bit_err + * 6: np_rx + * 5: err_counter_full + * 4: fifo_over_underflow + * 3: rx_status + * 2: link_status + * 1: automatic_speed + * 0: int_en + */ + +/* MI Register 26: PHY Status Reg(0x1A) + * 15: reserved + * 14-13: autoneg_fault + * 12: autoneg_status + * 11: mdi_x_status + * 10: polarity_status + * 9-8: speed_status + * 7: duplex_status + * 6: link_status + * 5: tx_status + * 4: rx_status + * 3: collision_status + * 2: autoneg_en + * 1: pause_en + * 0: asymmetric_dir + */ +#define ET_PHY_AUTONEG_STATUS 0x1000 +#define ET_PHY_POLARITY_STATUS 0x0400 +#define ET_PHY_SPEED_STATUS 0x0300 +#define ET_PHY_DUPLEX_STATUS 0x0080 +#define ET_PHY_LSTATUS 0x0040 +#define ET_PHY_AUTONEG_ENABLE 0x0020 + +/* MI Register 27: LED Control Reg 1(0x1B) + * 15-14: reserved + * 13-12: led_dup_indicate + * 11-10: led_10baseT + * 9-8: led_collision + * 7-4: reserved + * 3-2: pulse_dur + * 1: pulse_stretch1 + * 0: pulse_stretch0 + */ + +/* MI Register 28: LED Control Reg 2(0x1C) + * 15-12: led_link + * 11-8: led_tx_rx + * 7-4: led_100BaseTX + * 3-0: led_1000BaseT + */ +#define ET_LED2_LED_LINK 0xF000 +#define ET_LED2_LED_TXRX 0x0F00 +#define ET_LED2_LED_100TX 0x00F0 +#define ET_LED2_LED_1000T 0x000F + +/* defines for LED control reg 2 values */ +#define LED_VAL_1000BT 0x0 +#define LED_VAL_100BTX 0x1 +#define LED_VAL_10BT 0x2 +#define LED_VAL_1000BT_100BTX 0x3 /* 1000BT on, 100BTX blink */ +#define LED_VAL_LINKON 0x4 +#define LED_VAL_TX 0x5 +#define LED_VAL_RX 0x6 +#define LED_VAL_TXRX 0x7 /* TX or RX */ +#define LED_VAL_DUPLEXFULL 0x8 +#define LED_VAL_COLLISION 0x9 +#define LED_VAL_LINKON_ACTIVE 0xA /* Link on, activity blink */ +#define LED_VAL_LINKON_RECV 0xB /* Link on, receive blink */ +#define LED_VAL_DUPLEXFULL_COLLISION 0xC /* Duplex on, collision blink */ +#define LED_VAL_BLINK 0xD +#define LED_VAL_ON 0xE +#define LED_VAL_OFF 0xF + +#define LED_LINK_SHIFT 12 +#define LED_TXRX_SHIFT 8 +#define LED_100TX_SHIFT 4 + +/* MI Register 29 - 31: Reserved Reg(0x1D - 0x1E) */ + +/* Defines for PHY access routines */ + +/* Define bit operation flags */ +#define TRUEPHY_BIT_CLEAR 0 +#define TRUEPHY_BIT_SET 1 +#define TRUEPHY_BIT_READ 2 + +/* Define read/write operation flags */ +#ifndef TRUEPHY_READ +#define TRUEPHY_READ 0 +#define TRUEPHY_WRITE 1 +#define TRUEPHY_MASK 2 +#endif + +/* Define master/slave configuration values */ +#define TRUEPHY_CFG_SLAVE 0 +#define TRUEPHY_CFG_MASTER 1 + +/* Define MDI/MDI-X settings */ +#define TRUEPHY_MDI 0 +#define TRUEPHY_MDIX 1 +#define TRUEPHY_AUTO_MDI_MDIX 2 + +/* Define 10Base-T link polarities */ +#define TRUEPHY_POLARITY_NORMAL 0 +#define TRUEPHY_POLARITY_INVERTED 1 + +/* Define auto-negotiation results */ +#define TRUEPHY_ANEG_NOT_COMPLETE 0 +#define TRUEPHY_ANEG_COMPLETE 1 +#define TRUEPHY_ANEG_DISABLED 2 + +/* Define duplex advertisement flags */ +#define TRUEPHY_ADV_DUPLEX_NONE 0x00 +#define TRUEPHY_ADV_DUPLEX_FULL 0x01 +#define TRUEPHY_ADV_DUPLEX_HALF 0x02 +#define TRUEPHY_ADV_DUPLEX_BOTH \ + (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF) + From fd0651a6d185e9572e1b2530d9f8f18c4cd5295c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:35 +0100 Subject: [PATCH 1486/1519] staging: et131x: move et131x_adapter.h contents into et131x.c Move et131x_adapter.h contents into et131x.c and delete et131x_adapter.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 152 ++++++++++++++++- drivers/staging/et131x/et131x_adapter.h | 217 ------------------------ 2 files changed, 151 insertions(+), 218 deletions(-) delete mode 100644 drivers/staging/et131x/et131x_adapter.h diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 271ae31b77f..e88c277b254 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -83,7 +83,6 @@ #include #include -#include "et131x_adapter.h" #include "et1310_tx.h" #include "et1310_rx.h" #include "et131x.h" @@ -125,6 +124,157 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define INT_MASK_ENABLE 0xfffebf17 #define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 +/* ADAPTER defines */ +/* + * Do not change these values: if changed, then change also in respective + * TXdma and Rxdma engines + */ +#define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */ +#define NUM_TCB 64 + +/* + * These values are all superseded by registry entries to facilitate tuning. + * Once the desired performance has been achieved, the optimal registry values + * should be re-populated to these #defines: + */ +#define NUM_TRAFFIC_CLASSES 1 + +#define TX_ERROR_PERIOD 1000 + +#define LO_MARK_PERCENT_FOR_PSR 15 +#define LO_MARK_PERCENT_FOR_RX 15 + +/* RFD (Receive Frame Descriptor) */ +struct rfd { + struct list_head list_node; + struct sk_buff *skb; + u32 len; /* total size of receive frame */ + u16 bufferindex; + u8 ringindex; +}; + +/* Flow Control */ +#define FLOW_BOTH 0 +#define FLOW_TXONLY 1 +#define FLOW_RXONLY 2 +#define FLOW_NONE 3 + +/* Struct to define some device statistics */ +struct ce_stats { + /* MIB II variables + * + * NOTE: atomic_t types are only guaranteed to store 24-bits; if we + * MUST have 32, then we'll need another way to perform atomic + * operations + */ + u32 unicast_pkts_rcvd; + atomic_t unicast_pkts_xmtd; + u32 multicast_pkts_rcvd; + atomic_t multicast_pkts_xmtd; + u32 broadcast_pkts_rcvd; + atomic_t broadcast_pkts_xmtd; + u32 rcvd_pkts_dropped; + + /* Tx Statistics. */ + u32 tx_underflows; + + u32 tx_collisions; + u32 tx_excessive_collisions; + u32 tx_first_collisions; + u32 tx_late_collisions; + u32 tx_max_pkt_errs; + u32 tx_deferred; + + /* Rx Statistics. */ + u32 rx_overflows; + + u32 rx_length_errs; + u32 rx_align_errs; + u32 rx_crc_errs; + u32 rx_code_violations; + u32 rx_other_errs; + + u32 synchronous_iterations; + u32 interrupt_status; +}; + +/* The private adapter structure */ +struct et131x_adapter { + struct net_device *netdev; + struct pci_dev *pdev; + struct mii_bus *mii_bus; + struct phy_device *phydev; + struct work_struct task; + + /* Flags that indicate current state of the adapter */ + u32 flags; + + /* local link state, to determine if a state change has occurred */ + int link; + + /* Configuration */ + u8 rom_addr[ETH_ALEN]; + u8 addr[ETH_ALEN]; + bool has_eeprom; + u8 eeprom_data[2]; + + /* Spinlocks */ + spinlock_t lock; + + spinlock_t tcb_send_qlock; + spinlock_t tcb_ready_qlock; + spinlock_t send_hw_lock; + + spinlock_t rcv_lock; + spinlock_t rcv_pend_lock; + spinlock_t fbr_lock; + + spinlock_t phy_lock; + + /* Packet Filter and look ahead size */ + u32 packet_filter; + + /* multicast list */ + u32 multicast_addr_count; + u8 multicast_list[NIC_MAX_MCAST_LIST][ETH_ALEN]; + + /* Pointer to the device's PCI register space */ + struct address_map __iomem *regs; + + /* Registry parameters */ + u8 wanted_flow; /* Flow we want for 802.3x flow control */ + u32 registry_jumbo_packet; /* Max supported ethernet packet size */ + + /* Derived from the registry: */ + u8 flowcontrol; /* flow control validated by the far-end */ + + /* Minimize init-time */ + struct timer_list error_timer; + + /* variable putting the phy into coma mode when boot up with no cable + * plugged in after 5 seconds + */ + u8 boot_coma; + + /* Next two used to save power information at power down. This + * information will be used during power up to set up parts of Power + * Management in JAGCore + */ + u16 pdown_speed; + u8 pdown_duplex; + + /* Tx Memory Variables */ + struct tx_ring tx_ring; + + /* Rx Memory Variables */ + struct rx_ring rx_ring; + + /* Stats */ + struct ce_stats stats; + + struct net_device_stats net_stats; +}; + void et131x_error_timer_handler(unsigned long data); void et131x_enable_interrupts(struct et131x_adapter *adapter); void et131x_disable_interrupts(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h deleted file mode 100644 index 74efdb04b20..00000000000 --- a/drivers/staging/et131x/et131x_adapter.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et131x_adapter.h - Header which includes the private adapter structure, along - * with related support structures, macros, definitions, etc. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef __ET131X_ADAPTER_H__ -#define __ET131X_ADAPTER_H__ - -#include "et1310_tx.h" -#include "et1310_rx.h" - -/* - * Do not change these values: if changed, then change also in respective - * TXdma and Rxdma engines - */ -#define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */ -#define NUM_TCB 64 - -/* - * These values are all superseded by registry entries to facilitate tuning. - * Once the desired performance has been achieved, the optimal registry values - * should be re-populated to these #defines: - */ -#define NUM_TRAFFIC_CLASSES 1 - -#define TX_ERROR_PERIOD 1000 - -#define LO_MARK_PERCENT_FOR_PSR 15 -#define LO_MARK_PERCENT_FOR_RX 15 - -/* RFD (Receive Frame Descriptor) */ -struct rfd { - struct list_head list_node; - struct sk_buff *skb; - u32 len; /* total size of receive frame */ - u16 bufferindex; - u8 ringindex; -}; - -/* Flow Control */ -#define FLOW_BOTH 0 -#define FLOW_TXONLY 1 -#define FLOW_RXONLY 2 -#define FLOW_NONE 3 - -/* Struct to define some device statistics */ -struct ce_stats { - /* MIB II variables - * - * NOTE: atomic_t types are only guaranteed to store 24-bits; if we - * MUST have 32, then we'll need another way to perform atomic - * operations - */ - u32 unicast_pkts_rcvd; - atomic_t unicast_pkts_xmtd; - u32 multicast_pkts_rcvd; - atomic_t multicast_pkts_xmtd; - u32 broadcast_pkts_rcvd; - atomic_t broadcast_pkts_xmtd; - u32 rcvd_pkts_dropped; - - /* Tx Statistics. */ - u32 tx_underflows; - - u32 tx_collisions; - u32 tx_excessive_collisions; - u32 tx_first_collisions; - u32 tx_late_collisions; - u32 tx_max_pkt_errs; - u32 tx_deferred; - - /* Rx Statistics. */ - u32 rx_overflows; - - u32 rx_length_errs; - u32 rx_align_errs; - u32 rx_crc_errs; - u32 rx_code_violations; - u32 rx_other_errs; - - u32 synchronous_iterations; - u32 interrupt_status; -}; - -/* The private adapter structure */ -struct et131x_adapter { - struct net_device *netdev; - struct pci_dev *pdev; - struct mii_bus *mii_bus; - struct phy_device *phydev; - struct work_struct task; - - /* Flags that indicate current state of the adapter */ - u32 flags; - - /* local link state, to determine if a state change has occurred */ - int link; - - /* Configuration */ - u8 rom_addr[ETH_ALEN]; - u8 addr[ETH_ALEN]; - bool has_eeprom; - u8 eeprom_data[2]; - - /* Spinlocks */ - spinlock_t lock; - - spinlock_t tcb_send_qlock; - spinlock_t tcb_ready_qlock; - spinlock_t send_hw_lock; - - spinlock_t rcv_lock; - spinlock_t rcv_pend_lock; - spinlock_t fbr_lock; - - spinlock_t phy_lock; - - /* Packet Filter and look ahead size */ - u32 packet_filter; - - /* multicast list */ - u32 multicast_addr_count; - u8 multicast_list[NIC_MAX_MCAST_LIST][ETH_ALEN]; - - /* Pointer to the device's PCI register space */ - struct address_map __iomem *regs; - - /* Registry parameters */ - u8 wanted_flow; /* Flow we want for 802.3x flow control */ - u32 registry_jumbo_packet; /* Max supported ethernet packet size */ - - /* Derived from the registry: */ - u8 flowcontrol; /* flow control validated by the far-end */ - - /* Minimize init-time */ - struct timer_list error_timer; - - /* variable putting the phy into coma mode when boot up with no cable - * plugged in after 5 seconds - */ - u8 boot_coma; - - /* Next two used to save power information at power down. This - * information will be used during power up to set up parts of Power - * Management in JAGCore - */ - u16 pdown_speed; - u8 pdown_duplex; - - /* Tx Memory Variables */ - struct tx_ring tx_ring; - - /* Rx Memory Variables */ - struct rx_ring rx_ring; - - /* Stats */ - struct ce_stats stats; - - struct net_device_stats net_stats; -}; - -#endif /* __ET131X_ADAPTER_H__ */ From 1c1c1b5fda62419615c8fda99359206b2b279489 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:36 +0100 Subject: [PATCH 1487/1519] staging: et131x: move et131x_defs.h contents into et131x.c Move et131x_defs.h contents into et131x.c and delete et131x_defs.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 66 +++++++++++++- drivers/staging/et131x/et131x_defs.h | 128 --------------------------- 2 files changed, 64 insertions(+), 130 deletions(-) delete mode 100644 drivers/staging/et131x/et131x_defs.h diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index e88c277b254..402ab7f7ae2 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -53,8 +53,6 @@ * */ -#include "et131x_defs.h" - #include #include #include @@ -124,6 +122,70 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define INT_MASK_ENABLE 0xfffebf17 #define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7 +/* General defines */ +/* Packet and header sizes */ +#define NIC_MIN_PACKET_SIZE 60 + +/* Multicast list size */ +#define NIC_MAX_MCAST_LIST 128 + +/* Supported Filters */ +#define ET131X_PACKET_TYPE_DIRECTED 0x0001 +#define ET131X_PACKET_TYPE_MULTICAST 0x0002 +#define ET131X_PACKET_TYPE_BROADCAST 0x0004 +#define ET131X_PACKET_TYPE_PROMISCUOUS 0x0008 +#define ET131X_PACKET_TYPE_ALL_MULTICAST 0x0010 + +/* Tx Timeout */ +#define ET131X_TX_TIMEOUT (1 * HZ) +#define NIC_SEND_HANG_THRESHOLD 0 + +/* MP_TCB flags */ +#define fMP_DEST_MULTI 0x00000001 +#define fMP_DEST_BROAD 0x00000002 + +/* MP_ADAPTER flags */ +#define fMP_ADAPTER_RECV_LOOKASIDE 0x00000004 +#define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008 +#define fMP_ADAPTER_SECONDARY 0x00000010 + +/* MP_SHARED flags */ +#define fMP_ADAPTER_SHUTDOWN 0x00100000 +#define fMP_ADAPTER_LOWER_POWER 0x00200000 + +#define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000 +#define fMP_ADAPTER_RESET_IN_PROGRESS 0x01000000 +#define fMP_ADAPTER_NO_CABLE 0x02000000 +#define fMP_ADAPTER_HARDWARE_ERROR 0x04000000 +#define fMP_ADAPTER_REMOVE_IN_PROGRESS 0x08000000 +#define fMP_ADAPTER_HALT_IN_PROGRESS 0x10000000 + +#define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000 +#define fMP_ADAPTER_NOT_READY_MASK 0x3ff00000 + +/* Some offsets in PCI config space that are actually used. */ +#define ET1310_PCI_MAX_PYLD 0x4C +#define ET1310_PCI_MAC_ADDRESS 0xA4 +#define ET1310_PCI_EEPROM_STATUS 0xB2 +#define ET1310_PCI_ACK_NACK 0xC0 +#define ET1310_PCI_REPLAY 0xC2 +#define ET1310_PCI_L0L1LATENCY 0xCF + +/* PCI Vendor/Product IDs */ +#define ET131X_PCI_VENDOR_ID 0x11C1 /* Agere Systems */ +#define ET131X_PCI_DEVICE_ID_GIG 0xED00 /* ET1310 1000 Base-T 8 */ +#define ET131X_PCI_DEVICE_ID_FAST 0xED01 /* ET1310 100 Base-T */ + +/* Define order of magnitude converter */ +#define NANO_IN_A_MICRO 1000 + +#define PARM_RX_NUM_BUFS_DEF 4 +#define PARM_RX_TIME_INT_DEF 10 +#define PARM_RX_MEM_END_DEF 0x2bc +#define PARM_TX_TIME_INT_DEF 40 +#define PARM_TX_NUM_BUFS_DEF 4 +#define PARM_DMA_CACHE_DEF 0 + /* ADAPTER defines */ /* * Do not change these values: if changed, then change also in respective diff --git a/drivers/staging/et131x/et131x_defs.h b/drivers/staging/et131x/et131x_defs.h deleted file mode 100644 index 872a5afc357..00000000000 --- a/drivers/staging/et131x/et131x_defs.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et131x_defs.h - Defines, structs, enums, prototypes, etc. to assist with OS - * compatibility - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef __ET131X_DEFS_H__ -#define __ET131X_DEFS_H__ - -/* Packet and header sizes */ -#define NIC_MIN_PACKET_SIZE 60 - -/* Multicast list size */ -#define NIC_MAX_MCAST_LIST 128 - -/* Supported Filters */ -#define ET131X_PACKET_TYPE_DIRECTED 0x0001 -#define ET131X_PACKET_TYPE_MULTICAST 0x0002 -#define ET131X_PACKET_TYPE_BROADCAST 0x0004 -#define ET131X_PACKET_TYPE_PROMISCUOUS 0x0008 -#define ET131X_PACKET_TYPE_ALL_MULTICAST 0x0010 - -/* Tx Timeout */ -#define ET131X_TX_TIMEOUT (1 * HZ) -#define NIC_SEND_HANG_THRESHOLD 0 - -/* MP_TCB flags */ -#define fMP_DEST_MULTI 0x00000001 -#define fMP_DEST_BROAD 0x00000002 - -/* MP_ADAPTER flags */ -#define fMP_ADAPTER_RECV_LOOKASIDE 0x00000004 -#define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008 -#define fMP_ADAPTER_SECONDARY 0x00000010 - -/* MP_SHARED flags */ -#define fMP_ADAPTER_SHUTDOWN 0x00100000 -#define fMP_ADAPTER_LOWER_POWER 0x00200000 - -#define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000 -#define fMP_ADAPTER_RESET_IN_PROGRESS 0x01000000 -#define fMP_ADAPTER_NO_CABLE 0x02000000 -#define fMP_ADAPTER_HARDWARE_ERROR 0x04000000 -#define fMP_ADAPTER_REMOVE_IN_PROGRESS 0x08000000 -#define fMP_ADAPTER_HALT_IN_PROGRESS 0x10000000 - -#define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000 -#define fMP_ADAPTER_NOT_READY_MASK 0x3ff00000 - -/* Some offsets in PCI config space that are actually used. */ -#define ET1310_PCI_MAX_PYLD 0x4C -#define ET1310_PCI_MAC_ADDRESS 0xA4 -#define ET1310_PCI_EEPROM_STATUS 0xB2 -#define ET1310_PCI_ACK_NACK 0xC0 -#define ET1310_PCI_REPLAY 0xC2 -#define ET1310_PCI_L0L1LATENCY 0xCF - -/* PCI Vendor/Product IDs */ -#define ET131X_PCI_VENDOR_ID 0x11C1 /* Agere Systems */ -#define ET131X_PCI_DEVICE_ID_GIG 0xED00 /* ET1310 1000 Base-T 8 */ -#define ET131X_PCI_DEVICE_ID_FAST 0xED01 /* ET1310 100 Base-T */ - -/* Define order of magnitude converter */ -#define NANO_IN_A_MICRO 1000 - -#define PARM_RX_NUM_BUFS_DEF 4 -#define PARM_RX_TIME_INT_DEF 10 -#define PARM_RX_MEM_END_DEF 0x2bc -#define PARM_TX_TIME_INT_DEF 40 -#define PARM_TX_NUM_BUFS_DEF 4 -#define PARM_DMA_CACHE_DEF 0 - - -#endif /* __ET131X_DEFS_H__ */ From 562550b02bbe9e376b05c5ff7d7ef12e7c32fc30 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:37 +0100 Subject: [PATCH 1488/1519] staging: et131x: move et1310_rx.h contents into et131x.c Move et1310_rx.h contents into et131x.c and delete et1310_rx.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_rx.h | 243 ----------------------------- drivers/staging/et131x/et131x.c | 181 ++++++++++++++++++++- 2 files changed, 180 insertions(+), 244 deletions(-) delete mode 100644 drivers/staging/et131x/et1310_rx.h diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h deleted file mode 100644 index b3b1bc959d1..00000000000 --- a/drivers/staging/et131x/et1310_rx.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - * Copyright (c) 2011 Mark Einon - * - *------------------------------------------------------------------------------ - * - * et1310_rx.h - Defines, structs, enums, prototypes, etc. pertaining to data - * reception. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef __ET1310_RX_H__ -#define __ET1310_RX_H__ - -#define USE_FBR0 true - -#ifdef USE_FBR0 -/* #define FBR0_BUFFER_SIZE 256 */ -#endif - -/* #define FBR1_BUFFER_SIZE 2048 */ - -#define FBR_CHUNKS 32 - -#define MAX_DESC_PER_RING_RX 1024 - -/* number of RFDs - default and min */ -#ifdef USE_FBR0 -#define RFD_LOW_WATER_MARK 40 -#define NIC_MIN_NUM_RFD 64 -#define NIC_DEFAULT_NUM_RFD 1024 -#else -#define RFD_LOW_WATER_MARK 20 -#define NIC_MIN_NUM_RFD 64 -#define NIC_DEFAULT_NUM_RFD 256 -#endif - -#define NUM_PACKETS_HANDLED 256 - -#define ALCATEL_BAD_STATUS 0xe47f0000 -#define ALCATEL_MULTICAST_PKT 0x01000000 -#define ALCATEL_BROADCAST_PKT 0x02000000 - -/* typedefs for Free Buffer Descriptors */ -struct fbr_desc { - u32 addr_lo; - u32 addr_hi; - u32 word2; /* Bits 10-31 reserved, 0-9 descriptor */ -}; - -/* Packet Status Ring Descriptors - * - * Word 0: - * - * top 16 bits are from the Alcatel Status Word as enumerated in - * PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2) - * - * 0: hp hash pass - * 1: ipa IP checksum assist - * 2: ipp IP checksum pass - * 3: tcpa TCP checksum assist - * 4: tcpp TCP checksum pass - * 5: wol WOL Event - * 6: rxmac_error RXMAC Error Indicator - * 7: drop Drop packet - * 8: ft Frame Truncated - * 9: jp Jumbo Packet - * 10: vp VLAN Packet - * 11-15: unused - * 16: asw_prev_pkt_dropped e.g. IFG too small on previous - * 17: asw_RX_DV_event short receive event detected - * 18: asw_false_carrier_event bad carrier since last good packet - * 19: asw_code_err one or more nibbles signalled as errors - * 20: asw_CRC_err CRC error - * 21: asw_len_chk_err frame length field incorrect - * 22: asw_too_long frame length > 1518 bytes - * 23: asw_OK valid CRC + no code error - * 24: asw_multicast has a multicast address - * 25: asw_broadcast has a broadcast address - * 26: asw_dribble_nibble spurious bits after EOP - * 27: asw_control_frame is a control frame - * 28: asw_pause_frame is a pause frame - * 29: asw_unsupported_op unsupported OP code - * 30: asw_VLAN_tag VLAN tag detected - * 31: asw_long_evt Rx long event - * - * Word 1: - * 0-15: length length in bytes - * 16-25: bi Buffer Index - * 26-27: ri Ring Index - * 28-31: reserved - */ - -struct pkt_stat_desc { - u32 word0; - u32 word1; -}; - -/* Typedefs for the RX DMA status word */ - -/* - * rx status word 0 holds part of the status bits of the Rx DMA engine - * that get copied out to memory by the ET-1310. Word 0 is a 32 bit word - * which contains the Free Buffer ring 0 and 1 available offset. - * - * bit 0-9 FBR1 offset - * bit 10 Wrap flag for FBR1 - * bit 16-25 FBR0 offset - * bit 26 Wrap flag for FBR0 - */ - -/* - * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine - * that get copied out to memory by the ET-1310. Word 3 is a 32 bit word - * which contains the Packet Status Ring available offset. - * - * bit 0-15 reserved - * bit 16-27 PSRoffset - * bit 28 PSRwrap - * bit 29-31 unused - */ - -/* - * struct rx_status_block is a structure representing the status of the Rx - * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020 - */ -struct rx_status_block { - u32 word0; - u32 word1; -}; - -/* - * Structure for look-up table holding free buffer ring pointers - */ -struct fbr_lookup { - void *virt[MAX_DESC_PER_RING_RX]; - void *buffer1[MAX_DESC_PER_RING_RX]; - void *buffer2[MAX_DESC_PER_RING_RX]; - u32 bus_high[MAX_DESC_PER_RING_RX]; - u32 bus_low[MAX_DESC_PER_RING_RX]; -}; - -/* - * struct rx_ring is the sructure representing the adaptor's local - * reference(s) to the rings - */ -struct rx_ring { -#ifdef USE_FBR0 - void *fbr0_ring_virtaddr; - dma_addr_t fbr0_ring_physaddr; - void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t fbr0_real_physaddr; - uint64_t fbr0_offset; - u32 local_fbr0_full; - u32 fbr0_num_entries; - u32 fbr0_buffsize; -#endif - void *fbr1_ring_virtaddr; - dma_addr_t fbr1_ring_physaddr; - void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t fbr1_real_physaddr; - uint64_t fbr1_offset; - struct fbr_lookup *fbr[2]; /* One per ring */ - u32 local_fbr1_full; - u32 fbr1_num_entries; - u32 fbr1_buffsize; - - void *ps_ring_virtaddr; - dma_addr_t ps_ring_physaddr; - u32 local_psr_full; - u32 psr_num_entries; - - struct rx_status_block *rx_status_block; - dma_addr_t rx_status_bus; - - struct list_head recv_buff_pool; - - /* RECV */ - struct list_head recv_list; - u32 num_ready_recv; - - u32 num_rfd; - - bool unfinished_receives; - - struct list_head recv_packet_pool; - - /* lookaside lists */ - struct kmem_cache *recv_lookaside; -}; - -#endif /* __ET1310_RX_H__ */ diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 402ab7f7ae2..484a626a81f 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -82,7 +82,6 @@ #include #include "et1310_tx.h" -#include "et1310_rx.h" #include "et131x.h" MODULE_AUTHOR("Victor Soriano "); @@ -186,6 +185,186 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define PARM_TX_NUM_BUFS_DEF 4 #define PARM_DMA_CACHE_DEF 0 +/* RX defines */ +#define USE_FBR0 true + +#ifdef USE_FBR0 +/* #define FBR0_BUFFER_SIZE 256 */ +#endif + +/* #define FBR1_BUFFER_SIZE 2048 */ + +#define FBR_CHUNKS 32 + +#define MAX_DESC_PER_RING_RX 1024 + +/* number of RFDs - default and min */ +#ifdef USE_FBR0 +#define RFD_LOW_WATER_MARK 40 +#define NIC_MIN_NUM_RFD 64 +#define NIC_DEFAULT_NUM_RFD 1024 +#else +#define RFD_LOW_WATER_MARK 20 +#define NIC_MIN_NUM_RFD 64 +#define NIC_DEFAULT_NUM_RFD 256 +#endif + +#define NUM_PACKETS_HANDLED 256 + +#define ALCATEL_BAD_STATUS 0xe47f0000 +#define ALCATEL_MULTICAST_PKT 0x01000000 +#define ALCATEL_BROADCAST_PKT 0x02000000 + +/* typedefs for Free Buffer Descriptors */ +struct fbr_desc { + u32 addr_lo; + u32 addr_hi; + u32 word2; /* Bits 10-31 reserved, 0-9 descriptor */ +}; + +/* Packet Status Ring Descriptors + * + * Word 0: + * + * top 16 bits are from the Alcatel Status Word as enumerated in + * PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2) + * + * 0: hp hash pass + * 1: ipa IP checksum assist + * 2: ipp IP checksum pass + * 3: tcpa TCP checksum assist + * 4: tcpp TCP checksum pass + * 5: wol WOL Event + * 6: rxmac_error RXMAC Error Indicator + * 7: drop Drop packet + * 8: ft Frame Truncated + * 9: jp Jumbo Packet + * 10: vp VLAN Packet + * 11-15: unused + * 16: asw_prev_pkt_dropped e.g. IFG too small on previous + * 17: asw_RX_DV_event short receive event detected + * 18: asw_false_carrier_event bad carrier since last good packet + * 19: asw_code_err one or more nibbles signalled as errors + * 20: asw_CRC_err CRC error + * 21: asw_len_chk_err frame length field incorrect + * 22: asw_too_long frame length > 1518 bytes + * 23: asw_OK valid CRC + no code error + * 24: asw_multicast has a multicast address + * 25: asw_broadcast has a broadcast address + * 26: asw_dribble_nibble spurious bits after EOP + * 27: asw_control_frame is a control frame + * 28: asw_pause_frame is a pause frame + * 29: asw_unsupported_op unsupported OP code + * 30: asw_VLAN_tag VLAN tag detected + * 31: asw_long_evt Rx long event + * + * Word 1: + * 0-15: length length in bytes + * 16-25: bi Buffer Index + * 26-27: ri Ring Index + * 28-31: reserved + */ + +struct pkt_stat_desc { + u32 word0; + u32 word1; +}; + +/* Typedefs for the RX DMA status word */ + +/* + * rx status word 0 holds part of the status bits of the Rx DMA engine + * that get copied out to memory by the ET-1310. Word 0 is a 32 bit word + * which contains the Free Buffer ring 0 and 1 available offset. + * + * bit 0-9 FBR1 offset + * bit 10 Wrap flag for FBR1 + * bit 16-25 FBR0 offset + * bit 26 Wrap flag for FBR0 + */ + +/* + * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine + * that get copied out to memory by the ET-1310. Word 3 is a 32 bit word + * which contains the Packet Status Ring available offset. + * + * bit 0-15 reserved + * bit 16-27 PSRoffset + * bit 28 PSRwrap + * bit 29-31 unused + */ + +/* + * struct rx_status_block is a structure representing the status of the Rx + * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020 + */ +struct rx_status_block { + u32 word0; + u32 word1; +}; + +/* + * Structure for look-up table holding free buffer ring pointers + */ +struct fbr_lookup { + void *virt[MAX_DESC_PER_RING_RX]; + void *buffer1[MAX_DESC_PER_RING_RX]; + void *buffer2[MAX_DESC_PER_RING_RX]; + u32 bus_high[MAX_DESC_PER_RING_RX]; + u32 bus_low[MAX_DESC_PER_RING_RX]; +}; + +/* + * struct rx_ring is the sructure representing the adaptor's local + * reference(s) to the rings + */ +struct rx_ring { +#ifdef USE_FBR0 + void *fbr0_ring_virtaddr; + dma_addr_t fbr0_ring_physaddr; + void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + uint64_t fbr0_real_physaddr; + uint64_t fbr0_offset; + u32 local_fbr0_full; + u32 fbr0_num_entries; + u32 fbr0_buffsize; +#endif + void *fbr1_ring_virtaddr; + dma_addr_t fbr1_ring_physaddr; + void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + uint64_t fbr1_real_physaddr; + uint64_t fbr1_offset; + struct fbr_lookup *fbr[2]; /* One per ring */ + u32 local_fbr1_full; + u32 fbr1_num_entries; + u32 fbr1_buffsize; + + void *ps_ring_virtaddr; + dma_addr_t ps_ring_physaddr; + u32 local_psr_full; + u32 psr_num_entries; + + struct rx_status_block *rx_status_block; + dma_addr_t rx_status_bus; + + struct list_head recv_buff_pool; + + /* RECV */ + struct list_head recv_list; + u32 num_ready_recv; + + u32 num_rfd; + + bool unfinished_receives; + + struct list_head recv_packet_pool; + + /* lookaside lists */ + struct kmem_cache *recv_lookaside; +}; + /* ADAPTER defines */ /* * Do not change these values: if changed, then change also in respective From 17ec9ff32c0fb8478958f3a2a99be6758846f657 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:38 +0100 Subject: [PATCH 1489/1519] staging: et131x: move et1310_tx.h contents into et131x.c Move et1310_tx.h contents into et131x.c and delete et1310_tx.h Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_tx.h | 150 ----------------------------- drivers/staging/et131x/et131x.c | 87 ++++++++++++++++- 2 files changed, 86 insertions(+), 151 deletions(-) delete mode 100644 drivers/staging/et131x/et1310_tx.h diff --git a/drivers/staging/et131x/et1310_tx.h b/drivers/staging/et131x/et1310_tx.h deleted file mode 100644 index 82d06e9870d..00000000000 --- a/drivers/staging/et131x/et1310_tx.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Agere Systems Inc. - * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * http://www.agere.com - * - *------------------------------------------------------------------------------ - * - * et1310_tx.h - Defines, structs, enums, prototypes, etc. pertaining to data - * transmission. - * - *------------------------------------------------------------------------------ - * - * SOFTWARE LICENSE - * - * This software is provided subject to the following terms and conditions, - * which you should read carefully before using the software. Using this - * software indicates your acceptance of these terms and conditions. If you do - * not agree with these terms and conditions, do not use the software. - * - * Copyright © 2005 Agere Systems Inc. - * All rights reserved. - * - * Redistribution and use in source or binary forms, with or without - * modifications, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following Disclaimer as comments in the code as - * well as in the documentation and/or other materials provided with the - * distribution. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following Disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name of Agere Systems Inc. nor the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * Disclaimer - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY - * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN - * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - */ - -#ifndef __ET1310_TX_H__ -#define __ET1310_TX_H__ - - -/* Typedefs for Tx Descriptor Ring */ - -/* - * word 2 of the control bits in the Tx Descriptor ring for the ET-1310 - * - * 0-15: length of packet - * 16-27: VLAN tag - * 28: VLAN CFI - * 29-31: VLAN priority - * - * word 3 of the control bits in the Tx Descriptor ring for the ET-1310 - * - * 0: last packet in the sequence - * 1: first packet in the sequence - * 2: interrupt the processor when this pkt sent - * 3: Control word - no packet data - * 4: Issue half-duplex backpressure : XON/XOFF - * 5: send pause frame - * 6: Tx frame has error - * 7: append CRC - * 8: MAC override - * 9: pad packet - * 10: Packet is a Huge packet - * 11: append VLAN tag - * 12: IP checksum assist - * 13: TCP checksum assist - * 14: UDP checksum assist - */ - -/* struct tx_desc represents each descriptor on the ring */ -struct tx_desc { - u32 addr_hi; - u32 addr_lo; - u32 len_vlan; /* control words how to xmit the */ - u32 flags; /* data (detailed above) */ -}; - -/* - * The status of the Tx DMA engine it sits in free memory, and is pointed to - * by 0x101c / 0x1020. This is a DMA10 type - */ - -/* TCB (Transmit Control Block: Host Side) */ -struct tcb { - struct tcb *next; /* Next entry in ring */ - u32 flags; /* Our flags for the packet */ - u32 count; /* Used to spot stuck/lost packets */ - u32 stale; /* Used to spot stuck/lost packets */ - struct sk_buff *skb; /* Network skb we are tied to */ - u32 index; /* Ring indexes */ - u32 index_start; -}; - -/* Structure representing our local reference(s) to the ring */ -struct tx_ring { - /* TCB (Transmit Control Block) memory and lists */ - struct tcb *tcb_ring; - - /* List of TCBs that are ready to be used */ - struct tcb *tcb_qhead; - struct tcb *tcb_qtail; - - /* list of TCBs that are currently being sent. NOTE that access to all - * three of these (including used) are controlled via the - * TCBSendQLock. This lock should be secured prior to incementing / - * decrementing used, or any queue manipulation on send_head / - * tail - */ - struct tcb *send_head; - struct tcb *send_tail; - int used; - - /* The actual descriptor ring */ - struct tx_desc *tx_desc_ring; - dma_addr_t tx_desc_ring_pa; - - /* send_idx indicates where we last wrote to in the descriptor ring. */ - u32 send_idx; - - /* The location of the write-back status block */ - u32 *tx_status; - dma_addr_t tx_status_pa; - - /* Packets since the last IRQ: used for interrupt coalescing */ - int since_irq; -}; - -#endif /* __ET1310_TX_H__ */ diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 484a626a81f..959610226d7 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -81,7 +81,6 @@ #include #include -#include "et1310_tx.h" #include "et131x.h" MODULE_AUTHOR("Victor Soriano "); @@ -365,6 +364,92 @@ struct rx_ring { struct kmem_cache *recv_lookaside; }; +/* TX defines */ +/* + * word 2 of the control bits in the Tx Descriptor ring for the ET-1310 + * + * 0-15: length of packet + * 16-27: VLAN tag + * 28: VLAN CFI + * 29-31: VLAN priority + * + * word 3 of the control bits in the Tx Descriptor ring for the ET-1310 + * + * 0: last packet in the sequence + * 1: first packet in the sequence + * 2: interrupt the processor when this pkt sent + * 3: Control word - no packet data + * 4: Issue half-duplex backpressure : XON/XOFF + * 5: send pause frame + * 6: Tx frame has error + * 7: append CRC + * 8: MAC override + * 9: pad packet + * 10: Packet is a Huge packet + * 11: append VLAN tag + * 12: IP checksum assist + * 13: TCP checksum assist + * 14: UDP checksum assist + */ + +/* struct tx_desc represents each descriptor on the ring */ +struct tx_desc { + u32 addr_hi; + u32 addr_lo; + u32 len_vlan; /* control words how to xmit the */ + u32 flags; /* data (detailed above) */ +}; + +/* + * The status of the Tx DMA engine it sits in free memory, and is pointed to + * by 0x101c / 0x1020. This is a DMA10 type + */ + +/* TCB (Transmit Control Block: Host Side) */ +struct tcb { + struct tcb *next; /* Next entry in ring */ + u32 flags; /* Our flags for the packet */ + u32 count; /* Used to spot stuck/lost packets */ + u32 stale; /* Used to spot stuck/lost packets */ + struct sk_buff *skb; /* Network skb we are tied to */ + u32 index; /* Ring indexes */ + u32 index_start; +}; + +/* Structure representing our local reference(s) to the ring */ +struct tx_ring { + /* TCB (Transmit Control Block) memory and lists */ + struct tcb *tcb_ring; + + /* List of TCBs that are ready to be used */ + struct tcb *tcb_qhead; + struct tcb *tcb_qtail; + + /* list of TCBs that are currently being sent. NOTE that access to all + * three of these (including used) are controlled via the + * TCBSendQLock. This lock should be secured prior to incementing / + * decrementing used, or any queue manipulation on send_head / + * tail + */ + struct tcb *send_head; + struct tcb *send_tail; + int used; + + /* The actual descriptor ring */ + struct tx_desc *tx_desc_ring; + dma_addr_t tx_desc_ring_pa; + + /* send_idx indicates where we last wrote to in the descriptor ring. */ + u32 send_idx; + + /* The location of the write-back status block */ + u32 *tx_status; + dma_addr_t tx_status_pa; + + /* Packets since the last IRQ: used for interrupt coalescing */ + int since_irq; +}; + /* ADAPTER defines */ /* * Do not change these values: if changed, then change also in respective From 82e4b35f4d71199e90ab00a84bdbfae028f9fa62 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:39 +0100 Subject: [PATCH 1490/1519] staging: et131x: Update TODO list - remove 'put driver into single file' Driver now resides in a single file with a separate header with registers, updated the README TODO list. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index c67f83ebfc0..a7b33dc5f09 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -8,7 +8,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - Put the driver into a single file, with a .h for the registers layout. - rx_ring.fbr{0, 1} can probably share a common structure - Use of kmem_cache seems a bit unusual - Use dma_alloc_... in place of pci_alloc_... From 920d74a405a91248c65490b668c556d4d8f8028a Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:40 +0100 Subject: [PATCH 1491/1519] staging: et131x: Moving two extern inline functions to .c file Two helper functions for adding 10bit/12bit umbers with wrapping are defined in the header. Moved them to the driver .c file. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 11 +++++++++++ drivers/staging/et131x/et131x.h | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 959610226d7..14f54e42a23 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -2666,6 +2666,17 @@ void et131x_rx_dma_enable(struct et131x_adapter *adapter) } } + +static inline void add_10bit(u32 *v, int n) +{ + *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); +} + +static inline void add_12bit(u32 *v, int n) +{ + *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); +} + /** * nic_rx_pkts - Checks the hardware for available packets * @adapter: pointer to our adapter diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 84b274d90ce..7eed3c8986f 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -230,16 +230,6 @@ struct global_regs { /* Location: */ #define INDEX10(x) ((x) & ET_DMA10_MASK) #define INDEX4(x) ((x) & ET_DMA4_MASK) -extern inline void add_10bit(u32 *v, int n) -{ - *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); -} - -extern inline void add_12bit(u32 *v, int n) -{ - *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); -} - /* * 10bit DMA with wrap * txdma tx queue write address reg in txdma address map at 0x1010 From 6abafc164c13d4fa9e009d401ad7537991295add Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:41 +0100 Subject: [PATCH 1492/1519] staging: et131x: Make rx_ring.fbr{0,1} share a common structure Sharing a common structure by moving common structure items into fbr_lookup. TODO - Currently will not work if USE_FBR0 = 0 as FBR1 uses fbr[1] which is removed in this case Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 293 +++++++++++++++----------------- 1 file changed, 140 insertions(+), 153 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 14f54e42a23..0bc3e0426bc 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -185,13 +185,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define PARM_DMA_CACHE_DEF 0 /* RX defines */ -#define USE_FBR0 true - -#ifdef USE_FBR0 -/* #define FBR0_BUFFER_SIZE 256 */ -#endif - -/* #define FBR1_BUFFER_SIZE 2048 */ +#define USE_FBR0 1 #define FBR_CHUNKS 32 @@ -200,14 +194,16 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " /* number of RFDs - default and min */ #ifdef USE_FBR0 #define RFD_LOW_WATER_MARK 40 -#define NIC_MIN_NUM_RFD 64 #define NIC_DEFAULT_NUM_RFD 1024 +#define NUM_FBRS 2 #else #define RFD_LOW_WATER_MARK 20 -#define NIC_MIN_NUM_RFD 64 #define NIC_DEFAULT_NUM_RFD 256 +#define NUM_FBRS 1 #endif +#define NIC_MIN_NUM_RFD 64 + #define NUM_PACKETS_HANDLED 256 #define ALCATEL_BAD_STATUS 0xe47f0000 @@ -303,14 +299,24 @@ struct rx_status_block { }; /* - * Structure for look-up table holding free buffer ring pointers + * Structure for look-up table holding free buffer ring pointers, addresses + * and state. */ struct fbr_lookup { - void *virt[MAX_DESC_PER_RING_RX]; - void *buffer1[MAX_DESC_PER_RING_RX]; - void *buffer2[MAX_DESC_PER_RING_RX]; - u32 bus_high[MAX_DESC_PER_RING_RX]; - u32 bus_low[MAX_DESC_PER_RING_RX]; + void *virt[MAX_DESC_PER_RING_RX]; + void *buffer1[MAX_DESC_PER_RING_RX]; + void *buffer2[MAX_DESC_PER_RING_RX]; + u32 bus_high[MAX_DESC_PER_RING_RX]; + u32 bus_low[MAX_DESC_PER_RING_RX]; + void *ring_virtaddr; + dma_addr_t ring_physaddr; + void *mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + dma_addr_t mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; + uint64_t real_physaddr; + uint64_t offset; + u32 local_full; + u32 num_entries; + u32 buffsize; }; /* @@ -318,27 +324,7 @@ struct fbr_lookup { * reference(s) to the rings */ struct rx_ring { -#ifdef USE_FBR0 - void *fbr0_ring_virtaddr; - dma_addr_t fbr0_ring_physaddr; - void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t fbr0_real_physaddr; - uint64_t fbr0_offset; - u32 local_fbr0_full; - u32 fbr0_num_entries; - u32 fbr0_buffsize; -#endif - void *fbr1_ring_virtaddr; - dma_addr_t fbr1_ring_physaddr; - void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS]; - uint64_t fbr1_real_physaddr; - uint64_t fbr1_offset; - struct fbr_lookup *fbr[2]; /* One per ring */ - u32 local_fbr1_full; - u32 fbr1_num_entries; - u32 fbr1_buffsize; + struct fbr_lookup *fbr[NUM_FBRS]; void *ps_ring_virtaddr; dma_addr_t ps_ring_physaddr; @@ -1945,40 +1931,40 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) if (adapter->registry_jumbo_packet < 2048) { #ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 256; - rx_ring->fbr0_num_entries = 512; + rx_ring->fbr[0]->buffsize = 256; + rx_ring->fbr[0]->num_entries = 512; #endif - rx_ring->fbr1_buffsize = 2048; - rx_ring->fbr1_num_entries = 512; + rx_ring->fbr[1]->buffsize = 2048; + rx_ring->fbr[1]->num_entries = 512; } else if (adapter->registry_jumbo_packet < 4096) { #ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 512; - rx_ring->fbr0_num_entries = 1024; + rx_ring->fbr[0]->buffsize = 512; + rx_ring->fbr[0]->num_entries = 1024; #endif - rx_ring->fbr1_buffsize = 4096; - rx_ring->fbr1_num_entries = 512; + rx_ring->fbr[1]->buffsize = 4096; + rx_ring->fbr[1]->num_entries = 512; } else { #ifdef USE_FBR0 - rx_ring->fbr0_buffsize = 1024; - rx_ring->fbr0_num_entries = 768; + rx_ring->fbr[0]->buffsize = 1024; + rx_ring->fbr[0]->num_entries = 768; #endif - rx_ring->fbr1_buffsize = 16384; - rx_ring->fbr1_num_entries = 128; + rx_ring->fbr[1]->buffsize = 16384; + rx_ring->fbr[1]->num_entries = 128; } #ifdef USE_FBR0 - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr0_num_entries + - adapter->rx_ring.fbr1_num_entries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[0]->num_entries + + adapter->rx_ring.fbr[1]->num_entries; #else - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr1_num_entries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[1]->num_entries; #endif /* Allocate an area of memory for Free Buffer Ring 1 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff; - rx_ring->fbr1_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; + rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, bufsize, - &rx_ring->fbr1_ring_physaddr); - if (!rx_ring->fbr1_ring_virtaddr) { + &rx_ring->fbr[1]->ring_physaddr); + if (!rx_ring->fbr[1]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 1\n"); return -ENOMEM; @@ -1991,24 +1977,24 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here * before storing the adjusted address. */ - rx_ring->fbr1_real_physaddr = rx_ring->fbr1_ring_physaddr; + rx_ring->fbr[1]->real_physaddr = rx_ring->fbr[1]->ring_physaddr; /* Align Free Buffer Ring 1 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->fbr1_real_physaddr, - &rx_ring->fbr1_offset, 0x0FFF); + &rx_ring->fbr[1]->real_physaddr, + &rx_ring->fbr[1]->offset, 0x0FFF); - rx_ring->fbr1_ring_virtaddr = - (void *)((u8 *) rx_ring->fbr1_ring_virtaddr + - rx_ring->fbr1_offset); + rx_ring->fbr[1]->ring_virtaddr = + (void *)((u8 *) rx_ring->fbr[1]->ring_virtaddr + + rx_ring->fbr[1]->offset); #ifdef USE_FBR0 /* Allocate an area of memory for Free Buffer Ring 0 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff; - rx_ring->fbr0_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; + rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, bufsize, - &rx_ring->fbr0_ring_physaddr); - if (!rx_ring->fbr0_ring_virtaddr) { + &rx_ring->fbr[0]->ring_physaddr); + if (!rx_ring->fbr[0]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 0\n"); return -ENOMEM; @@ -2021,18 +2007,18 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. */ - rx_ring->fbr0_real_physaddr = rx_ring->fbr0_ring_physaddr; + rx_ring->fbr[0]->real_physaddr = rx_ring->fbr[0]->ring_physaddr; /* Align Free Buffer Ring 0 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->fbr0_real_physaddr, - &rx_ring->fbr0_offset, 0x0FFF); + &rx_ring->fbr[0]->real_physaddr, + &rx_ring->fbr[0]->offset, 0x0FFF); - rx_ring->fbr0_ring_virtaddr = - (void *)((u8 *) rx_ring->fbr0_ring_virtaddr + - rx_ring->fbr0_offset); + rx_ring->fbr[0]->ring_virtaddr = + (void *)((u8 *) rx_ring->fbr[0]->ring_virtaddr + + rx_ring->fbr[0]->offset); #endif - for (i = 0; i < (rx_ring->fbr1_num_entries / FBR_CHUNKS); i++) { + for (i = 0; i < (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); i++) { u64 fbr1_offset; u64 fbr1_tmp_physaddr; u32 fbr1_align; @@ -2044,25 +2030,25 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * the size of FBR0. By allocating N buffers at once, we * reduce this overhead. */ - if (rx_ring->fbr1_buffsize > 4096) + if (rx_ring->fbr[1]->buffsize > 4096) fbr1_align = 4096; else - fbr1_align = rx_ring->fbr1_buffsize; + fbr1_align = rx_ring->fbr[1]->buffsize; fbr_chunksize = - (FBR_CHUNKS * rx_ring->fbr1_buffsize) + fbr1_align - 1; - rx_ring->fbr1_mem_virtaddrs[i] = + (FBR_CHUNKS * rx_ring->fbr[1]->buffsize) + fbr1_align - 1; + rx_ring->fbr[1]->mem_virtaddrs[i] = pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr1_mem_physaddrs[i]); + &rx_ring->fbr[1]->mem_physaddrs[i]); - if (!rx_ring->fbr1_mem_virtaddrs[i]) { + if (!rx_ring->fbr[1]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, "Could not alloc memory\n"); return -ENOMEM; } /* See NOTE in "Save Physical Address" comment above */ - fbr1_tmp_physaddr = rx_ring->fbr1_mem_physaddrs[i]; + fbr1_tmp_physaddr = rx_ring->fbr[1]->mem_physaddrs[i]; et131x_align_allocated_memory(adapter, &fbr1_tmp_physaddr, @@ -2075,8 +2061,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * access later */ rx_ring->fbr[1]->virt[index] = - (u8 *) rx_ring->fbr1_mem_virtaddrs[i] + - (j * rx_ring->fbr1_buffsize) + fbr1_offset; + (u8 *) rx_ring->fbr[1]->mem_virtaddrs[i] + + (j * rx_ring->fbr[1]->buffsize) + fbr1_offset; /* now store the physical address in the descriptor * so the device can access it @@ -2086,7 +2072,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) rx_ring->fbr[1]->bus_low[index] = (u32) fbr1_tmp_physaddr; - fbr1_tmp_physaddr += rx_ring->fbr1_buffsize; + fbr1_tmp_physaddr += rx_ring->fbr[1]->buffsize; rx_ring->fbr[1]->buffer1[index] = rx_ring->fbr[1]->virt[index]; @@ -2097,43 +2083,43 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) #ifdef USE_FBR0 /* Same for FBR0 (if in use) */ - for (i = 0; i < (rx_ring->fbr0_num_entries / FBR_CHUNKS); i++) { + for (i = 0; i < (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); i++) { u64 fbr0_offset; u64 fbr0_tmp_physaddr; fbr_chunksize = - ((FBR_CHUNKS + 1) * rx_ring->fbr0_buffsize) - 1; - rx_ring->fbr0_mem_virtaddrs[i] = + ((FBR_CHUNKS + 1) * rx_ring->fbr[0]->buffsize) - 1; + rx_ring->fbr[0]->mem_virtaddrs[i] = pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr0_mem_physaddrs[i]); + &rx_ring->fbr[0]->mem_physaddrs[i]); - if (!rx_ring->fbr0_mem_virtaddrs[i]) { + if (!rx_ring->fbr[0]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, "Could not alloc memory\n"); return -ENOMEM; } /* See NOTE in "Save Physical Address" comment above */ - fbr0_tmp_physaddr = rx_ring->fbr0_mem_physaddrs[i]; + fbr0_tmp_physaddr = rx_ring->fbr[0]->mem_physaddrs[i]; et131x_align_allocated_memory(adapter, &fbr0_tmp_physaddr, &fbr0_offset, - rx_ring->fbr0_buffsize - 1); + rx_ring->fbr[0]->buffsize - 1); for (j = 0; j < FBR_CHUNKS; j++) { u32 index = (i * FBR_CHUNKS) + j; rx_ring->fbr[0]->virt[index] = - (u8 *) rx_ring->fbr0_mem_virtaddrs[i] + - (j * rx_ring->fbr0_buffsize) + fbr0_offset; + (u8 *) rx_ring->fbr[0]->mem_virtaddrs[i] + + (j * rx_ring->fbr[0]->buffsize) + fbr0_offset; rx_ring->fbr[0]->bus_high[index] = (u32) (fbr0_tmp_physaddr >> 32); rx_ring->fbr[0]->bus_low[index] = (u32) fbr0_tmp_physaddr; - fbr0_tmp_physaddr += rx_ring->fbr0_buffsize; + fbr0_tmp_physaddr += rx_ring->fbr[0]->buffsize; rx_ring->fbr[0]->buffer1[index] = rx_ring->fbr[0]->virt[index]; @@ -2228,78 +2214,78 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) } /* Free Free Buffer Ring 1 */ - if (rx_ring->fbr1_ring_virtaddr) { + if (rx_ring->fbr[1]->ring_virtaddr) { /* First the packet memory */ for (index = 0; index < - (rx_ring->fbr1_num_entries / FBR_CHUNKS); index++) { - if (rx_ring->fbr1_mem_virtaddrs[index]) { + (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr[1]->mem_virtaddrs[index]) { u32 fbr1_align; - if (rx_ring->fbr1_buffsize > 4096) + if (rx_ring->fbr[1]->buffsize > 4096) fbr1_align = 4096; else - fbr1_align = rx_ring->fbr1_buffsize; + fbr1_align = rx_ring->fbr[1]->buffsize; bufsize = - (rx_ring->fbr1_buffsize * FBR_CHUNKS) + + (rx_ring->fbr[1]->buffsize * FBR_CHUNKS) + fbr1_align - 1; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr1_mem_virtaddrs[index], - rx_ring->fbr1_mem_physaddrs[index]); + rx_ring->fbr[1]->mem_virtaddrs[index], + rx_ring->fbr[1]->mem_physaddrs[index]); - rx_ring->fbr1_mem_virtaddrs[index] = NULL; + rx_ring->fbr[1]->mem_virtaddrs[index] = NULL; } } /* Now the FIFO itself */ - rx_ring->fbr1_ring_virtaddr = (void *)((u8 *) - rx_ring->fbr1_ring_virtaddr - rx_ring->fbr1_offset); + rx_ring->fbr[1]->ring_virtaddr = (void *)((u8 *) + rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr1_ring_virtaddr, - rx_ring->fbr1_ring_physaddr); + rx_ring->fbr[1]->ring_virtaddr, + rx_ring->fbr[1]->ring_physaddr); - rx_ring->fbr1_ring_virtaddr = NULL; + rx_ring->fbr[1]->ring_virtaddr = NULL; } #ifdef USE_FBR0 /* Now the same for Free Buffer Ring 0 */ - if (rx_ring->fbr0_ring_virtaddr) { + if (rx_ring->fbr[0]->ring_virtaddr) { /* First the packet memory */ for (index = 0; index < - (rx_ring->fbr0_num_entries / FBR_CHUNKS); index++) { - if (rx_ring->fbr0_mem_virtaddrs[index]) { + (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr[0]->mem_virtaddrs[index]) { bufsize = - (rx_ring->fbr0_buffsize * + (rx_ring->fbr[0]->buffsize * (FBR_CHUNKS + 1)) - 1; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr0_mem_virtaddrs[index], - rx_ring->fbr0_mem_physaddrs[index]); + rx_ring->fbr[0]->mem_virtaddrs[index], + rx_ring->fbr[0]->mem_physaddrs[index]); - rx_ring->fbr0_mem_virtaddrs[index] = NULL; + rx_ring->fbr[0]->mem_virtaddrs[index] = NULL; } } /* Now the FIFO itself */ - rx_ring->fbr0_ring_virtaddr = (void *)((u8 *) - rx_ring->fbr0_ring_virtaddr - rx_ring->fbr0_offset); + rx_ring->fbr[0]->ring_virtaddr = (void *)((u8 *) + rx_ring->fbr[0]->ring_virtaddr - rx_ring->fbr[0]->offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr0_ring_virtaddr, - rx_ring->fbr0_ring_physaddr); + rx_ring->fbr[0]->ring_virtaddr, + rx_ring->fbr[0]->ring_physaddr); - rx_ring->fbr0_ring_virtaddr = NULL; + rx_ring->fbr[0]->ring_virtaddr = NULL; } #endif @@ -2445,8 +2431,8 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) rx_local->local_psr_full = 0; /* Now's the best time to initialize FBR1 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr1_ring_virtaddr; - for (entry = 0; entry < rx_local->fbr1_num_entries; entry++) { + fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr; + for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) { fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; fbr_entry->word2 = entry; @@ -2456,42 +2442,42 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) /* Set the address and parameters of Free buffer ring 1 (and 0 if * required) into the 1310's registers */ - writel((u32) (rx_local->fbr1_real_physaddr >> 32), + writel((u32) (rx_local->fbr[1]->real_physaddr >> 32), &rx_dma->fbr1_base_hi); - writel((u32) rx_local->fbr1_real_physaddr, &rx_dma->fbr1_base_lo); - writel(rx_local->fbr1_num_entries - 1, &rx_dma->fbr1_num_des); + writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr1_base_lo); + writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr1_num_des); writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); /* This variable tracks the free buffer ring 1 full position, so it * has to match the above. */ - rx_local->local_fbr1_full = ET_DMA10_WRAP; + rx_local->fbr[1]->local_full = ET_DMA10_WRAP; writel( - ((rx_local->fbr1_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, &rx_dma->fbr1_min_des); #ifdef USE_FBR0 /* Now's the best time to initialize FBR0 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr0_ring_virtaddr; - for (entry = 0; entry < rx_local->fbr0_num_entries; entry++) { + fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr; + for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) { fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; fbr_entry->word2 = entry; fbr_entry++; } - writel((u32) (rx_local->fbr0_real_physaddr >> 32), + writel((u32) (rx_local->fbr[0]->real_physaddr >> 32), &rx_dma->fbr0_base_hi); - writel((u32) rx_local->fbr0_real_physaddr, &rx_dma->fbr0_base_lo); - writel(rx_local->fbr0_num_entries - 1, &rx_dma->fbr0_num_des); + writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr0_base_lo); + writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr0_num_des); writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); /* This variable tracks the free buffer ring 0 full position, so it * has to match the above. */ - rx_local->local_fbr0_full = ET_DMA10_WRAP; + rx_local->fbr[0]->local_full = ET_DMA10_WRAP; writel( - ((rx_local->fbr0_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, &rx_dma->fbr0_min_des); #endif @@ -2550,15 +2536,15 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) */ if ( #ifdef USE_FBR0 - (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) || + (ring_index == 0 && buff_index < rx_local->fbr[0]->num_entries) || #endif - (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) { + (ring_index == 1 && buff_index < rx_local->fbr[1]->num_entries)) { spin_lock_irqsave(&adapter->fbr_lock, flags); if (ring_index == 1) { struct fbr_desc *next = - (struct fbr_desc *) (rx_local->fbr1_ring_virtaddr) + - INDEX10(rx_local->local_fbr1_full); + (struct fbr_desc *) (rx_local->fbr[1]->ring_virtaddr) + + INDEX10(rx_local->fbr[1]->local_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into @@ -2568,15 +2554,15 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->local_fbr1_full, - rx_local->fbr1_num_entries - 1), + writel(bump_free_buff_ring(&rx_local->fbr[1]->local_full, + rx_local->fbr[1]->num_entries - 1), &rx_dma->fbr1_full_offset); } #ifdef USE_FBR0 else { struct fbr_desc *next = (struct fbr_desc *) - rx_local->fbr0_ring_virtaddr + - INDEX10(rx_local->local_fbr0_full); + rx_local->fbr[0]->ring_virtaddr + + INDEX10(rx_local->fbr[0]->local_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into @@ -2586,8 +2572,9 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->local_fbr0_full, - rx_local->fbr0_num_entries - 1), + writel(bump_free_buff_ring( + &rx_local->fbr[0]->local_full, + rx_local->fbr[0]->num_entries - 1), &rx_dma->fbr0_full_offset); } #endif @@ -2637,19 +2624,19 @@ void et131x_rx_dma_enable(struct et131x_adapter *adapter) /* Setup the receive dma configuration register for normal operation */ u32 csr = 0x2000; /* FBR1 enable */ - if (adapter->rx_ring.fbr1_buffsize == 4096) + if (adapter->rx_ring.fbr[1]->buffsize == 4096) csr |= 0x0800; - else if (adapter->rx_ring.fbr1_buffsize == 8192) + else if (adapter->rx_ring.fbr[1]->buffsize == 8192) csr |= 0x1000; - else if (adapter->rx_ring.fbr1_buffsize == 16384) + else if (adapter->rx_ring.fbr[1]->buffsize == 16384) csr |= 0x1800; #ifdef USE_FBR0 csr |= 0x0400; /* FBR0 enable */ - if (adapter->rx_ring.fbr0_buffsize == 256) + if (adapter->rx_ring.fbr[0]->buffsize == 256) csr |= 0x0100; - else if (adapter->rx_ring.fbr0_buffsize == 512) + else if (adapter->rx_ring.fbr[0]->buffsize == 512) csr |= 0x0200; - else if (adapter->rx_ring.fbr0_buffsize == 1024) + else if (adapter->rx_ring.fbr[0]->buffsize == 1024) csr |= 0x0300; #endif writel(csr, &adapter->regs->rxdma.csr); @@ -2750,11 +2737,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) #ifdef USE_FBR0 if (ring_index > 1 || (ring_index == 0 && - buff_index > rx_local->fbr0_num_entries - 1) || + buff_index > rx_local->fbr[0]->num_entries - 1) || (ring_index == 1 && - buff_index > rx_local->fbr1_num_entries - 1)) + buff_index > rx_local->fbr[1]->num_entries - 1)) #else - if (ring_index != 1 || buff_index > rx_local->fbr1_num_entries - 1) + if (ring_index != 1 || buff_index > rx_local->fbr[1]->num_entries - 1) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ From e592a9b06cdd9f1d5a6f8026f9ec8170ebf10ef5 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:42 +0100 Subject: [PATCH 1493/1519] staging: et131x: Fix issues when USE_FBR0 is not defined * Following on from making rx_ring.fbr use a common structure - reversed the fbr[] array indicies so that index 1 = FBR0 and index 0 = FBR1, which allows USE_FBR0 define to work. * Also fixed up minor issues where indexes into the array were out of bounds in some places. * Removed rx_ring.fbr common stuct TODO item from README Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.c | 424 ++++++++++++++++---------------- 2 files changed, 218 insertions(+), 207 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index a7b33dc5f09..1e0fcf468eb 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -8,7 +8,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - rx_ring.fbr{0, 1} can probably share a common structure - Use of kmem_cache seems a bit unusual - Use dma_alloc_... in place of pci_alloc_... - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet. diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 0bc3e0426bc..0fbb77d35c9 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -322,10 +322,14 @@ struct fbr_lookup { /* * struct rx_ring is the sructure representing the adaptor's local * reference(s) to the rings + * + ****************************************************************************** + * IMPORTANT NOTE :- fbr_lookup *fbr[NUM_FBRS] uses index 0 to refer to FBR1 + * and index 1 to refer to FRB0 + ****************************************************************************** */ struct rx_ring { struct fbr_lookup *fbr[NUM_FBRS]; - void *ps_ring_virtaddr; dma_addr_t ps_ring_physaddr; u32 local_psr_full; @@ -1907,9 +1911,9 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Alloc memory for the lookup table */ #ifdef USE_FBR0 - rx_ring->fbr[0] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); -#endif rx_ring->fbr[1] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); +#endif + rx_ring->fbr[0] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); /* The first thing we will do is configure the sizes of the buffer * rings. These will change based on jumbo packet support. Larger @@ -1931,40 +1935,40 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) if (adapter->registry_jumbo_packet < 2048) { #ifdef USE_FBR0 - rx_ring->fbr[0]->buffsize = 256; - rx_ring->fbr[0]->num_entries = 512; -#endif - rx_ring->fbr[1]->buffsize = 2048; + rx_ring->fbr[1]->buffsize = 256; rx_ring->fbr[1]->num_entries = 512; +#endif + rx_ring->fbr[0]->buffsize = 2048; + rx_ring->fbr[0]->num_entries = 512; } else if (adapter->registry_jumbo_packet < 4096) { #ifdef USE_FBR0 - rx_ring->fbr[0]->buffsize = 512; - rx_ring->fbr[0]->num_entries = 1024; + rx_ring->fbr[1]->buffsize = 512; + rx_ring->fbr[1]->num_entries = 1024; #endif - rx_ring->fbr[1]->buffsize = 4096; - rx_ring->fbr[1]->num_entries = 512; + rx_ring->fbr[0]->buffsize = 4096; + rx_ring->fbr[0]->num_entries = 512; } else { #ifdef USE_FBR0 - rx_ring->fbr[0]->buffsize = 1024; - rx_ring->fbr[0]->num_entries = 768; + rx_ring->fbr[1]->buffsize = 1024; + rx_ring->fbr[1]->num_entries = 768; #endif - rx_ring->fbr[1]->buffsize = 16384; - rx_ring->fbr[1]->num_entries = 128; + rx_ring->fbr[0]->buffsize = 16384; + rx_ring->fbr[0]->num_entries = 128; } #ifdef USE_FBR0 - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[0]->num_entries + - adapter->rx_ring.fbr[1]->num_entries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[1]->num_entries + + adapter->rx_ring.fbr[0]->num_entries; #else - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[1]->num_entries; + adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[0]->num_entries; #endif /* Allocate an area of memory for Free Buffer Ring 1 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; - rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; + rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, bufsize, - &rx_ring->fbr[1]->ring_physaddr); - if (!rx_ring->fbr[1]->ring_virtaddr) { + &rx_ring->fbr[0]->ring_physaddr); + if (!rx_ring->fbr[0]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 1\n"); return -ENOMEM; @@ -1977,24 +1981,24 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here * before storing the adjusted address. */ - rx_ring->fbr[1]->real_physaddr = rx_ring->fbr[1]->ring_physaddr; + rx_ring->fbr[0]->real_physaddr = rx_ring->fbr[0]->ring_physaddr; /* Align Free Buffer Ring 1 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->fbr[1]->real_physaddr, - &rx_ring->fbr[1]->offset, 0x0FFF); + &rx_ring->fbr[0]->real_physaddr, + &rx_ring->fbr[0]->offset, 0x0FFF); - rx_ring->fbr[1]->ring_virtaddr = - (void *)((u8 *) rx_ring->fbr[1]->ring_virtaddr + - rx_ring->fbr[1]->offset); + rx_ring->fbr[0]->ring_virtaddr = + (void *)((u8 *) rx_ring->fbr[0]->ring_virtaddr + + rx_ring->fbr[0]->offset); #ifdef USE_FBR0 /* Allocate an area of memory for Free Buffer Ring 0 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; - rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; + rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, bufsize, - &rx_ring->fbr[0]->ring_physaddr); - if (!rx_ring->fbr[0]->ring_virtaddr) { + &rx_ring->fbr[1]->ring_physaddr); + if (!rx_ring->fbr[1]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 0\n"); return -ENOMEM; @@ -2007,18 +2011,18 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. */ - rx_ring->fbr[0]->real_physaddr = rx_ring->fbr[0]->ring_physaddr; + rx_ring->fbr[1]->real_physaddr = rx_ring->fbr[1]->ring_physaddr; /* Align Free Buffer Ring 0 on a 4K boundary */ et131x_align_allocated_memory(adapter, - &rx_ring->fbr[0]->real_physaddr, - &rx_ring->fbr[0]->offset, 0x0FFF); + &rx_ring->fbr[1]->real_physaddr, + &rx_ring->fbr[1]->offset, 0x0FFF); - rx_ring->fbr[0]->ring_virtaddr = - (void *)((u8 *) rx_ring->fbr[0]->ring_virtaddr + - rx_ring->fbr[0]->offset); + rx_ring->fbr[1]->ring_virtaddr = + (void *)((u8 *) rx_ring->fbr[1]->ring_virtaddr + + rx_ring->fbr[1]->offset); #endif - for (i = 0; i < (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); i++) { + for (i = 0; i < (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); i++) { u64 fbr1_offset; u64 fbr1_tmp_physaddr; u32 fbr1_align; @@ -2030,65 +2034,13 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) * the size of FBR0. By allocating N buffers at once, we * reduce this overhead. */ - if (rx_ring->fbr[1]->buffsize > 4096) + if (rx_ring->fbr[0]->buffsize > 4096) fbr1_align = 4096; else - fbr1_align = rx_ring->fbr[1]->buffsize; + fbr1_align = rx_ring->fbr[0]->buffsize; fbr_chunksize = - (FBR_CHUNKS * rx_ring->fbr[1]->buffsize) + fbr1_align - 1; - rx_ring->fbr[1]->mem_virtaddrs[i] = - pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr[1]->mem_physaddrs[i]); - - if (!rx_ring->fbr[1]->mem_virtaddrs[i]) { - dev_err(&adapter->pdev->dev, - "Could not alloc memory\n"); - return -ENOMEM; - } - - /* See NOTE in "Save Physical Address" comment above */ - fbr1_tmp_physaddr = rx_ring->fbr[1]->mem_physaddrs[i]; - - et131x_align_allocated_memory(adapter, - &fbr1_tmp_physaddr, - &fbr1_offset, (fbr1_align - 1)); - - for (j = 0; j < FBR_CHUNKS; j++) { - u32 index = (i * FBR_CHUNKS) + j; - - /* Save the Virtual address of this index for quick - * access later - */ - rx_ring->fbr[1]->virt[index] = - (u8 *) rx_ring->fbr[1]->mem_virtaddrs[i] + - (j * rx_ring->fbr[1]->buffsize) + fbr1_offset; - - /* now store the physical address in the descriptor - * so the device can access it - */ - rx_ring->fbr[1]->bus_high[index] = - (u32) (fbr1_tmp_physaddr >> 32); - rx_ring->fbr[1]->bus_low[index] = - (u32) fbr1_tmp_physaddr; - - fbr1_tmp_physaddr += rx_ring->fbr[1]->buffsize; - - rx_ring->fbr[1]->buffer1[index] = - rx_ring->fbr[1]->virt[index]; - rx_ring->fbr[1]->buffer2[index] = - rx_ring->fbr[1]->virt[index] - 4; - } - } - -#ifdef USE_FBR0 - /* Same for FBR0 (if in use) */ - for (i = 0; i < (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); i++) { - u64 fbr0_offset; - u64 fbr0_tmp_physaddr; - - fbr_chunksize = - ((FBR_CHUNKS + 1) * rx_ring->fbr[0]->buffsize) - 1; + (FBR_CHUNKS * rx_ring->fbr[0]->buffsize) + fbr1_align - 1; rx_ring->fbr[0]->mem_virtaddrs[i] = pci_alloc_consistent(adapter->pdev, fbr_chunksize, &rx_ring->fbr[0]->mem_physaddrs[i]); @@ -2100,26 +2052,31 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) } /* See NOTE in "Save Physical Address" comment above */ - fbr0_tmp_physaddr = rx_ring->fbr[0]->mem_physaddrs[i]; + fbr1_tmp_physaddr = rx_ring->fbr[0]->mem_physaddrs[i]; et131x_align_allocated_memory(adapter, - &fbr0_tmp_physaddr, - &fbr0_offset, - rx_ring->fbr[0]->buffsize - 1); + &fbr1_tmp_physaddr, + &fbr1_offset, (fbr1_align - 1)); for (j = 0; j < FBR_CHUNKS; j++) { u32 index = (i * FBR_CHUNKS) + j; + /* Save the Virtual address of this index for quick + * access later + */ rx_ring->fbr[0]->virt[index] = (u8 *) rx_ring->fbr[0]->mem_virtaddrs[i] + - (j * rx_ring->fbr[0]->buffsize) + fbr0_offset; + (j * rx_ring->fbr[0]->buffsize) + fbr1_offset; + /* now store the physical address in the descriptor + * so the device can access it + */ rx_ring->fbr[0]->bus_high[index] = - (u32) (fbr0_tmp_physaddr >> 32); + (u32) (fbr1_tmp_physaddr >> 32); rx_ring->fbr[0]->bus_low[index] = - (u32) fbr0_tmp_physaddr; + (u32) fbr1_tmp_physaddr; - fbr0_tmp_physaddr += rx_ring->fbr[0]->buffsize; + fbr1_tmp_physaddr += rx_ring->fbr[0]->buffsize; rx_ring->fbr[0]->buffer1[index] = rx_ring->fbr[0]->virt[index]; @@ -2127,6 +2084,53 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) rx_ring->fbr[0]->virt[index] - 4; } } + +#ifdef USE_FBR0 + /* Same for FBR0 (if in use) */ + for (i = 0; i < (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); i++) { + u64 fbr0_offset; + u64 fbr0_tmp_physaddr; + + fbr_chunksize = + ((FBR_CHUNKS + 1) * rx_ring->fbr[1]->buffsize) - 1; + rx_ring->fbr[1]->mem_virtaddrs[i] = + pci_alloc_consistent(adapter->pdev, fbr_chunksize, + &rx_ring->fbr[1]->mem_physaddrs[i]); + + if (!rx_ring->fbr[1]->mem_virtaddrs[i]) { + dev_err(&adapter->pdev->dev, + "Could not alloc memory\n"); + return -ENOMEM; + } + + /* See NOTE in "Save Physical Address" comment above */ + fbr0_tmp_physaddr = rx_ring->fbr[1]->mem_physaddrs[i]; + + et131x_align_allocated_memory(adapter, + &fbr0_tmp_physaddr, + &fbr0_offset, + rx_ring->fbr[1]->buffsize - 1); + + for (j = 0; j < FBR_CHUNKS; j++) { + u32 index = (i * FBR_CHUNKS) + j; + + rx_ring->fbr[1]->virt[index] = + (u8 *) rx_ring->fbr[1]->mem_virtaddrs[i] + + (j * rx_ring->fbr[1]->buffsize) + fbr0_offset; + + rx_ring->fbr[1]->bus_high[index] = + (u32) (fbr0_tmp_physaddr >> 32); + rx_ring->fbr[1]->bus_low[index] = + (u32) fbr0_tmp_physaddr; + + fbr0_tmp_physaddr += rx_ring->fbr[1]->buffsize; + + rx_ring->fbr[1]->buffer1[index] = + rx_ring->fbr[1]->virt[index]; + rx_ring->fbr[1]->buffer2[index] = + rx_ring->fbr[1]->virt[index] - 4; + } + } #endif /* Allocate an area of memory for FIFO of Packet Status ring entries */ @@ -2214,55 +2218,21 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) } /* Free Free Buffer Ring 1 */ - if (rx_ring->fbr[1]->ring_virtaddr) { - /* First the packet memory */ - for (index = 0; index < - (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); index++) { - if (rx_ring->fbr[1]->mem_virtaddrs[index]) { - u32 fbr1_align; - - if (rx_ring->fbr[1]->buffsize > 4096) - fbr1_align = 4096; - else - fbr1_align = rx_ring->fbr[1]->buffsize; - - bufsize = - (rx_ring->fbr[1]->buffsize * FBR_CHUNKS) + - fbr1_align - 1; - - pci_free_consistent(adapter->pdev, - bufsize, - rx_ring->fbr[1]->mem_virtaddrs[index], - rx_ring->fbr[1]->mem_physaddrs[index]); - - rx_ring->fbr[1]->mem_virtaddrs[index] = NULL; - } - } - - /* Now the FIFO itself */ - rx_ring->fbr[1]->ring_virtaddr = (void *)((u8 *) - rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset); - - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) - + 0xfff; - - pci_free_consistent(adapter->pdev, bufsize, - rx_ring->fbr[1]->ring_virtaddr, - rx_ring->fbr[1]->ring_physaddr); - - rx_ring->fbr[1]->ring_virtaddr = NULL; - } - -#ifdef USE_FBR0 - /* Now the same for Free Buffer Ring 0 */ if (rx_ring->fbr[0]->ring_virtaddr) { /* First the packet memory */ for (index = 0; index < (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); index++) { if (rx_ring->fbr[0]->mem_virtaddrs[index]) { + u32 fbr1_align; + + if (rx_ring->fbr[0]->buffsize > 4096) + fbr1_align = 4096; + else + fbr1_align = rx_ring->fbr[0]->buffsize; + bufsize = - (rx_ring->fbr[0]->buffsize * - (FBR_CHUNKS + 1)) - 1; + (rx_ring->fbr[0]->buffsize * FBR_CHUNKS) + + fbr1_align - 1; pci_free_consistent(adapter->pdev, bufsize, @@ -2280,13 +2250,47 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; - pci_free_consistent(adapter->pdev, - bufsize, + pci_free_consistent(adapter->pdev, bufsize, rx_ring->fbr[0]->ring_virtaddr, rx_ring->fbr[0]->ring_physaddr); rx_ring->fbr[0]->ring_virtaddr = NULL; } + +#ifdef USE_FBR0 + /* Now the same for Free Buffer Ring 0 */ + if (rx_ring->fbr[1]->ring_virtaddr) { + /* First the packet memory */ + for (index = 0; index < + (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); index++) { + if (rx_ring->fbr[1]->mem_virtaddrs[index]) { + bufsize = + (rx_ring->fbr[1]->buffsize * + (FBR_CHUNKS + 1)) - 1; + + pci_free_consistent(adapter->pdev, + bufsize, + rx_ring->fbr[1]->mem_virtaddrs[index], + rx_ring->fbr[1]->mem_physaddrs[index]); + + rx_ring->fbr[1]->mem_virtaddrs[index] = NULL; + } + } + + /* Now the FIFO itself */ + rx_ring->fbr[1]->ring_virtaddr = (void *)((u8 *) + rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset); + + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + + 0xfff; + + pci_free_consistent(adapter->pdev, + bufsize, + rx_ring->fbr[1]->ring_virtaddr, + rx_ring->fbr[1]->ring_physaddr); + + rx_ring->fbr[1]->ring_virtaddr = NULL; + } #endif /* Free Packet Status Ring */ @@ -2322,10 +2326,10 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Free the FBR Lookup Table */ #ifdef USE_FBR0 - kfree(rx_ring->fbr[0]); + kfree(rx_ring->fbr[1]); #endif - kfree(rx_ring->fbr[1]); + kfree(rx_ring->fbr[0]); /* Reset Counters */ rx_ring->num_ready_recv = 0; @@ -2431,33 +2435,6 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) rx_local->local_psr_full = 0; /* Now's the best time to initialize FBR1 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr; - for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) { - fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; - fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; - fbr_entry->word2 = entry; - fbr_entry++; - } - - /* Set the address and parameters of Free buffer ring 1 (and 0 if - * required) into the 1310's registers - */ - writel((u32) (rx_local->fbr[1]->real_physaddr >> 32), - &rx_dma->fbr1_base_hi); - writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr1_base_lo); - writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr1_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); - - /* This variable tracks the free buffer ring 1 full position, so it - * has to match the above. - */ - rx_local->fbr[1]->local_full = ET_DMA10_WRAP; - writel( - ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr1_min_des); - -#ifdef USE_FBR0 - /* Now's the best time to initialize FBR0 contents */ fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr; for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) { fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; @@ -2466,18 +2443,45 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) fbr_entry++; } + /* Set the address and parameters of Free buffer ring 1 (and 0 if + * required) into the 1310's registers + */ writel((u32) (rx_local->fbr[0]->real_physaddr >> 32), - &rx_dma->fbr0_base_hi); - writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr0_base_lo); - writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr0_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); + &rx_dma->fbr1_base_hi); + writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo); + writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); - /* This variable tracks the free buffer ring 0 full position, so it + /* This variable tracks the free buffer ring 1 full position, so it * has to match the above. */ rx_local->fbr[0]->local_full = ET_DMA10_WRAP; writel( ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr1_min_des); + +#ifdef USE_FBR0 + /* Now's the best time to initialize FBR0 contents */ + fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr; + for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) { + fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; + fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; + fbr_entry->word2 = entry; + fbr_entry++; + } + + writel((u32) (rx_local->fbr[1]->real_physaddr >> 32), + &rx_dma->fbr0_base_hi); + writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo); + writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); + + /* This variable tracks the free buffer ring 0 full position, so it + * has to match the above. + */ + rx_local->fbr[1]->local_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, &rx_dma->fbr0_min_des); #endif @@ -2536,45 +2540,45 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) */ if ( #ifdef USE_FBR0 - (ring_index == 0 && buff_index < rx_local->fbr[0]->num_entries) || + (ring_index == 0 && buff_index < rx_local->fbr[1]->num_entries) || #endif - (ring_index == 1 && buff_index < rx_local->fbr[1]->num_entries)) { + (ring_index == 1 && buff_index < rx_local->fbr[0]->num_entries)) { spin_lock_irqsave(&adapter->fbr_lock, flags); if (ring_index == 1) { struct fbr_desc *next = - (struct fbr_desc *) (rx_local->fbr[1]->ring_virtaddr) + - INDEX10(rx_local->fbr[1]->local_full); + (struct fbr_desc *) (rx_local->fbr[0]->ring_virtaddr) + + INDEX10(rx_local->fbr[0]->local_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into * the oldest (next to be freed)FBR entry */ - next->addr_hi = rx_local->fbr[1]->bus_high[buff_index]; - next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; + next->addr_hi = rx_local->fbr[0]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->fbr[1]->local_full, - rx_local->fbr[1]->num_entries - 1), + writel(bump_free_buff_ring(&rx_local->fbr[0]->local_full, + rx_local->fbr[0]->num_entries - 1), &rx_dma->fbr1_full_offset); } #ifdef USE_FBR0 else { struct fbr_desc *next = (struct fbr_desc *) - rx_local->fbr[0]->ring_virtaddr + - INDEX10(rx_local->fbr[0]->local_full); + rx_local->fbr[1]->ring_virtaddr + + INDEX10(rx_local->fbr[1]->local_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into * the oldest (next to be freed) FBR entry */ - next->addr_hi = rx_local->fbr[0]->bus_high[buff_index]; - next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; + next->addr_hi = rx_local->fbr[1]->bus_high[buff_index]; + next->addr_lo = rx_local->fbr[1]->bus_low[buff_index]; next->word2 = buff_index; writel(bump_free_buff_ring( - &rx_local->fbr[0]->local_full, - rx_local->fbr[0]->num_entries - 1), + &rx_local->fbr[1]->local_full, + rx_local->fbr[1]->num_entries - 1), &rx_dma->fbr0_full_offset); } #endif @@ -2624,19 +2628,19 @@ void et131x_rx_dma_enable(struct et131x_adapter *adapter) /* Setup the receive dma configuration register for normal operation */ u32 csr = 0x2000; /* FBR1 enable */ - if (adapter->rx_ring.fbr[1]->buffsize == 4096) + if (adapter->rx_ring.fbr[0]->buffsize == 4096) csr |= 0x0800; - else if (adapter->rx_ring.fbr[1]->buffsize == 8192) + else if (adapter->rx_ring.fbr[0]->buffsize == 8192) csr |= 0x1000; - else if (adapter->rx_ring.fbr[1]->buffsize == 16384) + else if (adapter->rx_ring.fbr[0]->buffsize == 16384) csr |= 0x1800; #ifdef USE_FBR0 csr |= 0x0400; /* FBR0 enable */ - if (adapter->rx_ring.fbr[0]->buffsize == 256) + if (adapter->rx_ring.fbr[1]->buffsize == 256) csr |= 0x0100; - else if (adapter->rx_ring.fbr[0]->buffsize == 512) + else if (adapter->rx_ring.fbr[1]->buffsize == 512) csr |= 0x0200; - else if (adapter->rx_ring.fbr[0]->buffsize == 1024) + else if (adapter->rx_ring.fbr[1]->buffsize == 1024) csr |= 0x0300; #endif writel(csr, &adapter->regs->rxdma.csr); @@ -2737,11 +2741,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) #ifdef USE_FBR0 if (ring_index > 1 || (ring_index == 0 && - buff_index > rx_local->fbr[0]->num_entries - 1) || + buff_index > rx_local->fbr[1]->num_entries - 1) || (ring_index == 1 && - buff_index > rx_local->fbr[1]->num_entries - 1)) + buff_index > rx_local->fbr[0]->num_entries - 1)) #else - if (ring_index != 1 || buff_index > rx_local->fbr[1]->num_entries - 1) + if (ring_index != 1 || buff_index > rx_local->fbr[0]->num_entries - 1) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ @@ -2800,7 +2804,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ET131X_PACKET_TYPE_PROMISCUOUS) && !(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { - buf = rx_local->fbr[ring_index]-> + /* + * Note - ring_index for fbr[] array is reversed + * 1 for FBR0 etc + */ + buf = rx_local->fbr[(ring_index == 0 ? 1 : 0)]-> virt[buff_index]; /* Loop through our list to see if the @@ -2865,8 +2873,12 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) adapter->net_stats.rx_bytes += rfd->len; + /* + * Note - ring_index for fbr[] array is reversed, + * 1 for FBR0 etc + */ memcpy(skb_put(skb, rfd->len), - rx_local->fbr[ring_index]->virt[buff_index], + rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index], rfd->len); skb->dev = adapter->netdev; From 0d1b7a84d3672023c6bc6d7eaa988db8bd3202ba Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:43 +0100 Subject: [PATCH 1494/1519] staging: et131x: use dma_alloc... instead of pci_alloc... Use dma_allocs instead of pci_allocs, so we can use GFP_KERNEL allocations. Also removed this item from the TODO list Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.c | 39 +++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 1e0fcf468eb..87b93601265 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ driver as they did not build properly at the time. TODO: - Use of kmem_cache seems a bit unusual - - Use dma_alloc_... in place of pci_alloc_... - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet. - PCI_VDEVICE ? diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 0fbb77d35c9..06ba4a95955 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -1965,9 +1965,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Allocate an area of memory for Free Buffer Ring 1 */ bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; - rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, - bufsize, - &rx_ring->fbr[0]->ring_physaddr); + rx_ring->fbr[0]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev, + bufsize, + &rx_ring->fbr[0]->ring_physaddr, + GFP_KERNEL); if (!rx_ring->fbr[0]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 1\n"); @@ -1995,9 +1996,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) #ifdef USE_FBR0 /* Allocate an area of memory for Free Buffer Ring 0 */ bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; - rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev, + rx_ring->fbr[1]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev, bufsize, - &rx_ring->fbr[1]->ring_physaddr); + &rx_ring->fbr[1]->ring_physaddr, + GFP_KERNEL); if (!rx_ring->fbr[1]->ring_virtaddr) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Free Buffer Ring 0\n"); @@ -2042,8 +2044,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) fbr_chunksize = (FBR_CHUNKS * rx_ring->fbr[0]->buffsize) + fbr1_align - 1; rx_ring->fbr[0]->mem_virtaddrs[i] = - pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr[0]->mem_physaddrs[i]); + dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize, + &rx_ring->fbr[0]->mem_physaddrs[i], GFP_KERNEL); if (!rx_ring->fbr[0]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, @@ -2094,8 +2096,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) fbr_chunksize = ((FBR_CHUNKS + 1) * rx_ring->fbr[1]->buffsize) - 1; rx_ring->fbr[1]->mem_virtaddrs[i] = - pci_alloc_consistent(adapter->pdev, fbr_chunksize, - &rx_ring->fbr[1]->mem_physaddrs[i]); + dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize, + &rx_ring->fbr[1]->mem_physaddrs[i], GFP_KERNEL); if (!rx_ring->fbr[1]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, @@ -2137,9 +2139,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) pktstat_ringsize = sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries; - rx_ring->ps_ring_virtaddr = pci_alloc_consistent(adapter->pdev, + rx_ring->ps_ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev, pktstat_ringsize, - &rx_ring->ps_ring_physaddr); + &rx_ring->ps_ring_physaddr, + GFP_KERNEL); if (!rx_ring->ps_ring_virtaddr) { dev_err(&adapter->pdev->dev, @@ -2157,9 +2160,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) */ /* Allocate an area of memory for writeback of status information */ - rx_ring->rx_status_block = pci_alloc_consistent(adapter->pdev, + rx_ring->rx_status_block = dma_alloc_coherent(&adapter->pdev->dev, sizeof(struct rx_status_block), - &rx_ring->rx_status_bus); + &rx_ring->rx_status_bus, + GFP_KERNEL); if (!rx_ring->rx_status_block) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Status Block\n"); @@ -2992,8 +2996,8 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) */ desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1; tx_ring->tx_desc_ring = - (struct tx_desc *) pci_alloc_consistent(adapter->pdev, desc_size, - &tx_ring->tx_desc_ring_pa); + (struct tx_desc *) dma_alloc_coherent(&adapter->pdev->dev, desc_size, + &tx_ring->tx_desc_ring_pa, GFP_KERNEL); if (!adapter->tx_ring.tx_desc_ring) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Tx Ring\n"); @@ -3008,9 +3012,10 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) * storing the adjusted address. */ /* Allocate memory for the Tx status block */ - tx_ring->tx_status = pci_alloc_consistent(adapter->pdev, + tx_ring->tx_status = dma_alloc_coherent(&adapter->pdev->dev, sizeof(u32), - &tx_ring->tx_status_pa); + &tx_ring->tx_status_pa, + GFP_KERNEL); if (!adapter->tx_ring.tx_status_pa) { dev_err(&adapter->pdev->dev, "Cannot alloc memory for Tx status block\n"); From 675c8f68ca65632624c0ebc03788f53c2109bf5b Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:44 +0100 Subject: [PATCH 1495/1519] staging: et131x: Match dma_alloc_ calls with dma_free_ calls Previous update was to replace pci_alloc with dma_alloc calls. I missed replacing the corresponding pci_free_ calls with the dma versions. Now done. Thanks to Denis Kirjanov for pointing this out. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 06ba4a95955..28d54b31e43 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -2238,7 +2238,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) (rx_ring->fbr[0]->buffsize * FBR_CHUNKS) + fbr1_align - 1; - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, bufsize, rx_ring->fbr[0]->mem_virtaddrs[index], rx_ring->fbr[0]->mem_physaddrs[index]); @@ -2254,7 +2254,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; - pci_free_consistent(adapter->pdev, bufsize, + dma_free_coherent(&adapter->pdev->dev, bufsize, rx_ring->fbr[0]->ring_virtaddr, rx_ring->fbr[0]->ring_physaddr); @@ -2272,7 +2272,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) (rx_ring->fbr[1]->buffsize * (FBR_CHUNKS + 1)) - 1; - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, bufsize, rx_ring->fbr[1]->mem_virtaddrs[index], rx_ring->fbr[1]->mem_physaddrs[index]); @@ -2288,7 +2288,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, bufsize, rx_ring->fbr[1]->ring_virtaddr, rx_ring->fbr[1]->ring_physaddr); @@ -2303,7 +2303,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries; - pci_free_consistent(adapter->pdev, pktstat_ringsize, + dma_free_coherent(&adapter->pdev->dev, pktstat_ringsize, rx_ring->ps_ring_virtaddr, rx_ring->ps_ring_physaddr); @@ -2312,7 +2312,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Free area of memory for the writeback of status information */ if (rx_ring->rx_status_block) { - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, sizeof(struct rx_status_block), rx_ring->rx_status_block, rx_ring->rx_status_bus); rx_ring->rx_status_block = NULL; @@ -3038,7 +3038,7 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) /* Free memory relating to Tx rings here */ desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1; - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, desc_size, adapter->tx_ring.tx_desc_ring, adapter->tx_ring.tx_desc_ring_pa); @@ -3047,7 +3047,7 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) /* Free memory for the Tx status block */ if (adapter->tx_ring.tx_status) { - pci_free_consistent(adapter->pdev, + dma_free_coherent(&adapter->pdev->dev, sizeof(u32), adapter->tx_ring.tx_status, adapter->tx_ring.tx_status_pa); From 26d19bf60be3a41bbd6c31d89d13a9c5e8edef8b Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:45 +0100 Subject: [PATCH 1496/1519] staging: et131x: Tidy up PCI device table definition Used the convenience macros DEFINE_PCI_DEVICE_TABLE and PCI_VDEVICE to tidy up the device table definition. Also remove the corresponding TODO item from the README. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.c | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 87b93601265..0928eb55fee 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -10,7 +10,6 @@ driver as they did not build properly at the time. TODO: - Use of kmem_cache seems a bit unusual - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet. - - PCI_VDEVICE ? Please send patches to: Greg Kroah-Hartman diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 28d54b31e43..cc41111b7b7 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -169,8 +169,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define ET1310_PCI_REPLAY 0xC2 #define ET1310_PCI_L0L1LATENCY 0xCF -/* PCI Vendor/Product IDs */ -#define ET131X_PCI_VENDOR_ID 0x11C1 /* Agere Systems */ +/* PCI Product IDs */ #define ET131X_PCI_DEVICE_ID_GIG 0xED00 /* ET1310 1000 Base-T 8 */ #define ET131X_PCI_DEVICE_ID_FAST 0xED01 /* ET1310 100 Base-T */ @@ -4647,14 +4646,11 @@ static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); #define ET131X_PM_OPS NULL #endif -static struct pci_device_id et131x_pci_table[] __devinitdata = { - {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0UL}, - {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0UL}, +static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = { + { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL}, + { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL}, {0,} }; - MODULE_DEVICE_TABLE(pci, et131x_pci_table); static struct pci_driver et131x_driver = { From 06709e962322eb565f1e5ce591df7efb3db07c1f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:46 +0100 Subject: [PATCH 1497/1519] staging: et131x: on transmit, stop the queue if the next packet will fail * Currently the tx queue is only stopped when the current packet fails. Check if the next packet will fail, and stop the queue if so. * Removed associated item from TODO list in the README. * Also minor fixup as adapter was being declared as null and immediately set to a value. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - drivers/staging/et131x/et131x.c | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 0928eb55fee..3458aa713a3 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,7 +9,6 @@ driver as they did not build properly at the time. TODO: - Use of kmem_cache seems a bit unusual - - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet. Please send patches to: Greg Kroah-Hartman diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index cc41111b7b7..993f93ac35e 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -3448,9 +3448,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) { int status = 0; - struct et131x_adapter *adapter = NULL; - - adapter = netdev_priv(netdev); + struct et131x_adapter *adapter = netdev_priv(netdev); /* Send these packets * @@ -5347,6 +5345,11 @@ static void et131x_multicast(struct net_device *netdev) static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) { int status = 0; + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* stop the queue if it's getting full */ + if(adapter->tx_ring.used >= NUM_TCB - 1 && !netif_queue_stopped(netdev)) + netif_stop_queue(netdev); /* Save the timestamp for the TX timeout watchdog */ netdev->trans_start = jiffies; @@ -5357,10 +5360,6 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) /* Check status and manage the netif queue if necessary */ if (status != 0) { if (status == -ENOMEM) { - /* Put the queue to sleep until resources are - * available - */ - netif_stop_queue(netdev); status = NETDEV_TX_BUSY; } else { status = NETDEV_TX_OK; From 26dc751e25026c1f3e774bdd142fa6f405559c46 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:47 +0100 Subject: [PATCH 1498/1519] staging: et131x: Convert rest of pci memory management to dma api Replaced pci map/unmap and set_mask calls with their dma equivalents. Also updated comments to reflect this. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 993f93ac35e..1c11dfde601 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -1976,7 +1976,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Save physical address * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * NOTE: dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here * before storing the adjusted address. @@ -2007,7 +2007,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Save physical address * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * NOTE: dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. @@ -2152,7 +2152,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) (unsigned long) rx_ring->ps_ring_physaddr); /* - * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, + * NOTE : dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. @@ -2172,7 +2172,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); /* Recv - * pci_pool_create initializes a lookaside list. After successful + * kmem_cache_create initializes a lookaside list. After successful * creation, nonpaged fixed-size blocks can be allocated from and * freed to the lookaside list. * RFDs will be allocated from this pool. @@ -2408,7 +2408,7 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) /* Load the completion writeback physical address * - * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, + * NOTE : dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here * before storing the adjusted address. @@ -3005,7 +3005,7 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) /* Save physical address * - * NOTE: pci_alloc_consistent(), used above to alloc DMA regions, + * NOTE: dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. @@ -3202,59 +3202,59 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) skb->len - skb->data_len; /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a + * dma_map_single() is implicitly cast as a * u32. Although dma_addr_t can be * 64-bit, the address returned by - * pci_map_single() is always 32-bit + * dma_map_single() is always 32-bit * addressable (as defined by the pci/dma * subsystem) */ desc[frag++].addr_lo = - pci_map_single(adapter->pdev, + dma_map_single(&adapter->pdev->dev, skb->data, skb->len - skb->data_len, - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); } else { desc[frag].addr_hi = 0; desc[frag].len_vlan = (skb->len - skb->data_len) / 2; /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a + * dma_map_single() is implicitly cast as a * u32. Although dma_addr_t can be * 64-bit, the address returned by - * pci_map_single() is always 32-bit + * dma_map_single() is always 32-bit * addressable (as defined by the pci/dma * subsystem) */ desc[frag++].addr_lo = - pci_map_single(adapter->pdev, + dma_map_single(&adapter->pdev->dev, skb->data, ((skb->len - skb->data_len) / 2), - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); desc[frag].addr_hi = 0; desc[frag].len_vlan = (skb->len - skb->data_len) / 2; /* NOTE: Here, the dma_addr_t returned from - * pci_map_single() is implicitly cast as a + * dma_map_single() is implicitly cast as a * u32. Although dma_addr_t can be * 64-bit, the address returned by - * pci_map_single() is always 32-bit + * dma_map_single() is always 32-bit * addressable (as defined by the pci/dma * subsystem) */ desc[frag++].addr_lo = - pci_map_single(adapter->pdev, + dma_map_single(&adapter->pdev->dev, skb->data + ((skb->len - skb->data_len) / 2), ((skb->len - skb->data_len) / 2), - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); } } else { desc[frag].addr_hi = 0; @@ -3262,17 +3262,17 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) frags[i - 1].size; /* NOTE: Here, the dma_addr_t returned from - * pci_map_page() is implicitly cast as a u32. + * dma_map_page() is implicitly cast as a u32. * Although dma_addr_t can be 64-bit, the address - * returned by pci_map_page() is always 32-bit + * returned by dma_map_page() is always 32-bit * addressable (as defined by the pci/dma subsystem) */ desc[frag++].addr_lo = - pci_map_page(adapter->pdev, + dma_map_page(&adapter->pdev->dev, frags[i - 1].page, frags[i - 1].page_offset, frags[i - 1].size, - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); } } @@ -3522,9 +3522,9 @@ static inline void free_send_packet(struct et131x_adapter *adapter, (adapter->tx_ring.tx_desc_ring + INDEX10(tcb->index_start)); - pci_unmap_single(adapter->pdev, + dma_unmap_single(&adapter->pdev->dev, desc->addr_lo, - desc->len_vlan, PCI_DMA_TODEVICE); + desc->len_vlan, DMA_TO_DEVICE); add_10bit(&tcb->index_start, 1); if (INDEX10(tcb->index_start) >= @@ -4428,15 +4428,15 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, } /* Check the DMA addressing support of this device */ - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { - result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { + result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (result) { dev_err(&pdev->dev, "Unable to obtain 64 bit DMA for consistent allocations\n"); goto err_release_res; } - } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { + result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (result) { dev_err(&pdev->dev, "Unable to obtain 32 bit DMA for consistent allocations\n"); From 4fb544c947a4b86ce8f302b64202e720f846ed70 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 20 Oct 2011 01:18:48 +0100 Subject: [PATCH 1499/1519] staging: et131x: Remove unused defines Some defines are no longer referenced in the code, so removed them. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 1c11dfde601..1efa27c93f5 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -145,21 +145,14 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " /* MP_ADAPTER flags */ #define fMP_ADAPTER_RECV_LOOKASIDE 0x00000004 #define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008 -#define fMP_ADAPTER_SECONDARY 0x00000010 /* MP_SHARED flags */ -#define fMP_ADAPTER_SHUTDOWN 0x00100000 #define fMP_ADAPTER_LOWER_POWER 0x00200000 #define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000 -#define fMP_ADAPTER_RESET_IN_PROGRESS 0x01000000 -#define fMP_ADAPTER_NO_CABLE 0x02000000 #define fMP_ADAPTER_HARDWARE_ERROR 0x04000000 -#define fMP_ADAPTER_REMOVE_IN_PROGRESS 0x08000000 -#define fMP_ADAPTER_HALT_IN_PROGRESS 0x10000000 #define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000 -#define fMP_ADAPTER_NOT_READY_MASK 0x3ff00000 /* Some offsets in PCI config space that are actually used. */ #define ET1310_PCI_MAX_PYLD 0x4C @@ -205,7 +198,6 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver " #define NUM_PACKETS_HANDLED 256 -#define ALCATEL_BAD_STATUS 0xe47f0000 #define ALCATEL_MULTICAST_PKT 0x01000000 #define ALCATEL_BROADCAST_PKT 0x02000000 @@ -452,8 +444,6 @@ struct tx_ring { * Once the desired performance has been achieved, the optimal registry values * should be re-populated to these #defines: */ -#define NUM_TRAFFIC_CLASSES 1 - #define TX_ERROR_PERIOD 1000 #define LO_MARK_PERCENT_FOR_PSR 15 @@ -4715,7 +4705,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter) writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); } - /** * et131x_isr - The Interrupt Service Routine for the driver. * @irq: the IRQ on which the interrupt was received. From 883aeecc9ddc120e34a1157aee37738a4e96b517 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 20 Oct 2011 09:10:25 +0300 Subject: [PATCH 1500/1519] Staging: vt6656: whitespace cleanups in ioctl.c The indents on this file didn't line up so it was hard to work with. I changed other white space issues as I came across them. I also deleted or changed some couple comments and the comment style. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/ioctl.c | 1247 +++++++++++++++----------------- 1 file changed, 589 insertions(+), 658 deletions(-) diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c index 1cb9a7d0d88..2cde4f0c046 100644 --- a/drivers/staging/vt6656/ioctl.c +++ b/drivers/staging/vt6656/ioctl.c @@ -40,666 +40,597 @@ #include "rndis.h" #include "rf.h" -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; - - SWPAResult wpa_Result; - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -int private_ioctl(PSDevice pDevice, struct ifreq *rq) { - - PSCmdRequest pReq = (PSCmdRequest)rq; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int result = 0; - PWLAN_IE_SSID pItemSSID; - SCmdBSSJoin sJoinCmd; - SCmdZoneTypeSet sZoneTypeCmd; - SCmdScan sScanCmd; - SCmdStartAP sStartAPCmd; - SCmdSetWEP sWEPCmd; - SCmdValue sValue; - SBSSIDList sList; - SNodeList sNodeList; - PSBSSIDList pList; - PSNodeList pNodeList; - unsigned int cbListCount; - PKnownBSS pBSS; - PKnownNodeDB pNode; - unsigned int ii, jj; - SCmdLinkStatus sLinkStatus; - BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - DWORD dwKeyIndex= 0; - BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - signed long ldBm; - - pReq->wResult = 0; - - switch(pReq->wCmdCode) { - - case WLAN_CMD_BSS_SCAN: - - if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; - if (pItemSSID->len != 0) { - memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - } - spin_lock_irq(&pDevice->lock); - - if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) - BSSvClearBSSList((void *) pDevice, FALSE); - else - BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); - - if (pItemSSID->len != 0) - bScheduleCommand((void *) pDevice, - WLAN_CMD_BSSID_SCAN, - abyScanSSID); - else - bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); - - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_ZONETYPE_SET: - //mike add :cann't support. - result=-EOPNOTSUPP; - break; - - if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - - if(sZoneTypeCmd.bWrite==TRUE) { - //////write zonetype - if(sZoneTypeCmd.ZoneType == ZoneType_USA) { - //set to USA - printk("set_ZoneType:USA\n"); - } - else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) { - //set to Japan - printk("set_ZoneType:Japan\n"); - } - else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) { - //set to Europe - printk("set_ZoneType:Europe\n"); - } - } - else { - ///////read zonetype - BYTE zonetype=0; - - - if(zonetype == 0x00) { //USA - sZoneTypeCmd.ZoneType = ZoneType_USA; - } - else if(zonetype == 0x01) { //Japan - sZoneTypeCmd.ZoneType = ZoneType_Japan; - } - else if(zonetype == 0x02) { //Europe - sZoneTypeCmd.ZoneType = ZoneType_Europe; - } - else { //Unknown ZoneType - printk("Error:ZoneType[%x] Unknown ???\n",zonetype); - result = -EFAULT; - break; - } - if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - } - - break; - - case WLAN_CMD_BSS_JOIN: - - if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - if (sJoinCmd.wBSSType == ADHOC) { - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); - } - else { - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); - } - if (sJoinCmd.bPSEnable == TRUE) { - pDevice->ePSMode = WMAC_POWER_FAST; -// pDevice->ePSMode = WMAC_POWER_MAX; - pMgmt->wListenInterval = 2; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); - } - else { - pDevice->ePSMode = WMAC_POWER_CAM; - pMgmt->wListenInterval = 1; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n"); - } - - if (sJoinCmd.bShareKeyAuth == TRUE){ - pMgmt->bShareKeyAlgorithm = TRUE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); - } - else { - pMgmt->bShareKeyAlgorithm = FALSE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); - } - pDevice->uChannel = sJoinCmd.uChannel; - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - pMgmt->eCurrState = WMAC_STATE_IDLE; - bScheduleCommand((void *) pDevice, - WLAN_CMD_BSSID_SCAN, - pMgmt->abyDesireSSID); - bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_SET_WEP: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n"); - memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP)); - if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { - result = -EFAULT; - break; - } - if (sWEPCmd.bEnableWep != TRUE) { - int uu; - - pDevice->bEncryptionEnable = FALSE; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - spin_lock_irq(&pDevice->lock); - for (uu = 0; uu < MAX_KEY_TABLE; uu++) - MACvDisableKeyEntry(pDevice, uu); - spin_unlock_irq(&pDevice->lock); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); - break; - } - - for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) { - if (sWEPCmd.bWepKeyAvailable[ii]) { - if (ii == sWEPCmd.byKeyIndex) -//2006-1207-01by Einsn Liu -// dwKeyIndex|= (1 << 31); - dwKeyIndex=ii|(1 << 31); - else - dwKeyIndex = ii; - spin_lock_irq(&pDevice->lock); - KeybSetDefaultKey( pDevice, - &(pDevice->sKey), - dwKeyIndex, - sWEPCmd.auWepKeyLength[ii], - NULL, - (PBYTE)&sWEPCmd.abyWepKey[ii][0], - KEY_CTL_WEP - ); - spin_unlock_irq(&pDevice->lock); - - } - } - pDevice->byKeyIndex = sWEPCmd.byKeyIndex; - pDevice->bTransmitKey = TRUE; - pDevice->bEncryptionEnable = TRUE; - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - - break; - - case WLAN_CMD_GET_LINK: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n"); - - memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - sLinkStatus.wBSSType = ADHOC; - else - sLinkStatus.wBSSType = INFRA; - - if (pMgmt->eCurrState == WMAC_STATE_JOINTED) - sLinkStatus.byState = ADHOC_JOINTED; - else - sLinkStatus.byState = ADHOC_STARTED; - - sLinkStatus.uChannel = pMgmt->uCurrChannel; - if (pDevice->bLinkPass == TRUE) { - sLinkStatus.bLink = TRUE; - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); - memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n"); - } - else { - sLinkStatus.bLink = FALSE; - sLinkStatus.uLinkRate = 0; - } - if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { - result = -EFAULT; - break; - } - - break; - - case WLAN_CMD_GET_LISTLEN: - cbListCount = 0; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - cbListCount++; - } - sList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_LIST: - if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); - if (pList == NULL) { - result = -ENOMEM; - break; - } - pList->uItem = sList.uItem; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { - pBSS = &(pMgmt->sBSSList[jj]); - if (pBSS->bActive) { - pList->sBSSIDList[ii].uChannel = pBSS->uChannel; - pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; - pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; - RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); - pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm; -// pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; - memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; - memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); - memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); - if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { - pList->sBSSIDList[ii].byNetType = INFRA; - } - else { - pList->sBSSIDList[ii].byNetType = ADHOC; - } - if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { - pList->sBSSIDList[ii].bWEPOn = TRUE; - } - else { - pList->sBSSIDList[ii].bWEPOn = FALSE; - } - ii ++; - if (ii >= pList->uItem) - break; - } - } - - if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { - result = -EFAULT; - break; - } - kfree(pList); - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_MIB: - if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { - result = -EFAULT; - break; - } - break; - - case WLAN_CMD_GET_STAT: - if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { - result = -EFAULT; - break; - } - break; - case WLAN_CMD_STOP_MAC: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); - // Todo xxxxxx - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - if (pDevice->bRadioOff == FALSE) { - CARDbRadioPowerOff(pDevice); - } - pDevice->bLinkPass = FALSE; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; -// del_timer(&pDevice->sTimerCommand); -// del_timer(&pMgmt->sTimerSecondCallback); - pDevice->bCmdRunning = FALSE; - spin_unlock_irq(&pDevice->lock); - - break; - - case WLAN_CMD_START_MAC: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); - // Todo xxxxxxx - if (pDevice->bRadioOff == TRUE) - CARDbRadioPowerOn(pDevice); - break; - - case WLAN_CMD_SET_HOSTAPD: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){ - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); - } - else { - result = -EFAULT; - break; - } - } - else { - vt6656_hostap_set_hostapd(pDevice, 0, 1); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); - } - - break; - - case WLAN_CMD_SET_HOSTAPD_STA: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); - - break; - case WLAN_CMD_SET_802_1X: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnable8021x = TRUE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); - } - else { - pDevice->bEnable8021x = FALSE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); - } - - break; - - - case WLAN_CMD_SET_HOST_WEP: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnableHostWEP = TRUE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); - } - else { - pDevice->bEnableHostWEP = FALSE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); - } - - break; - - case WLAN_CMD_SET_WPA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); - memcpy(pDevice->wpadev->dev_addr, - pDevice->dev->dev_addr, - ETH_ALEN); - pDevice->bWPADEVUp = TRUE; - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); - pDevice->bWPADEVUp = FALSE; - } - - break; - - case WLAN_CMD_AP_START: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); - if (pDevice->bRadioOff == TRUE) { - CARDbRadioPowerOn(pDevice); - add_timer(&pMgmt->sTimerSecondCallback); - } - if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { - result = -EFAULT; - break; - } - - if (sStartAPCmd.wBSSType == AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); - result = -EFAULT; - break; - } - - - if (sStartAPCmd.wBBPType == PHY80211g) { - pMgmt->byAPBBType = PHY_TYPE_11G; - } - else if (sStartAPCmd.wBBPType == PHY80211a) { - pMgmt->byAPBBType = PHY_TYPE_11A; - } - else { - pMgmt->byAPBBType = PHY_TYPE_11B; - } - - pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - - if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14)) - pDevice->uChannel = sStartAPCmd.uChannel; - - if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) - pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; - else - pMgmt->wIBSSBeaconPeriod = 100; - - if (sStartAPCmd.bShareKeyAuth == TRUE){ - pMgmt->bShareKeyAlgorithm = TRUE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); - } - else { - pMgmt->bShareKeyAlgorithm = FALSE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); - } - memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); - - if (sStartAPCmd.byBasicRate & BIT3) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - pMgmt->abyIBSSSuppRates[5] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT2) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - }else { - //default 1,2M - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", - pMgmt->abyIBSSSuppRates[2], - pMgmt->abyIBSSSuppRates[3], - pMgmt->abyIBSSSuppRates[4], - pMgmt->abyIBSSSuppRates[5] - ); - - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_GET_NODE_CNT: - - cbListCount = 0; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (!pNode->bActive) - continue; - cbListCount++; - } - - sNodeList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_NODE_LIST: - - if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); - if (pNodeList == NULL) { - result = -ENOMEM; - break; - } - pNodeList->uItem = sNodeList.uItem; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (pNode->bActive) { - pNodeList->sNodeList[jj].wAID = pNode->wAID; - memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); - pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; - pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount; - pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt; - pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags; - pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; - pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; - pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; - memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - pNodeList->sNodeList[jj].abyWepKey[0], - pNodeList->sNodeList[jj].abyWepKey[1], - pNodeList->sNodeList[jj].abyWepKey[2], - pNodeList->sNodeList[jj].abyWepKey[3], - pNodeList->sNodeList[jj].abyWepKey[4] - ); - pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; - pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; - pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; - pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio; - jj ++; - if (jj >= pNodeList->uItem) - break; - } - } - if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { - result = -EFAULT; - break; - } - kfree(pNodeList); - pReq->wResult = 0; - break; - - case 0xFF: - memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname)); - wpa_Result.proto = 0; - wpa_Result.key_mgmt = 0; - wpa_Result.eap_type = 0; - wpa_Result.authenticated = FALSE; - pDevice->fWPA_Authened = FALSE; - if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { - result = -EFAULT; - break; - } -//DavidWang for some AP maybe good authenticate - if(wpa_Result.key_mgmt==0x20) - pMgmt->Cisco_cckm =1; - else - pMgmt->Cisco_cckm =0; - - -if(wpa_Result.authenticated==TRUE) { - { - union iwreq_data wrqu; - - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; - wrqu.data.length =pItemSSID->len; - wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); - } - pDevice->fWPA_Authened = TRUE; //is successful peer to wpa_Result.authenticated? -} - - //printk("get private wpa_supplicant announce WPA SM\n"); - //printk("wpa-->ifname=%s\n",wpa_Result.ifname); - //printk("wpa-->proto=%d\n",wpa_Result.proto); - //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt); - //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type); - //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE"); +SWPAResult wpa_Result; +static int msglevel = MSG_LEVEL_INFO; + +int private_ioctl(PSDevice pDevice, struct ifreq *rq) +{ + + PSCmdRequest pReq = (PSCmdRequest)rq; + PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + int result = 0; + PWLAN_IE_SSID pItemSSID; + SCmdBSSJoin sJoinCmd; + SCmdZoneTypeSet sZoneTypeCmd; + SCmdScan sScanCmd; + SCmdStartAP sStartAPCmd; + SCmdSetWEP sWEPCmd; + SCmdValue sValue; + SBSSIDList sList; + SNodeList sNodeList; + PSBSSIDList pList; + PSNodeList pNodeList; + unsigned int cbListCount; + PKnownBSS pBSS; + PKnownNodeDB pNode; + unsigned int ii, jj; + SCmdLinkStatus sLinkStatus; + BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; + BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + DWORD dwKeyIndex = 0; + BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + signed long ldBm; pReq->wResult = 0; - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); - } + switch (pReq->wCmdCode) { + case WLAN_CMD_BSS_SCAN: + if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { + result = -EFAULT; + break; + } - return result; + pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; + if (pItemSSID->len != 0) { + memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + } + spin_lock_irq(&pDevice->lock); + + if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) + BSSvClearBSSList((void *)pDevice, FALSE); + else + BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); + + if (pItemSSID->len != 0) + bScheduleCommand((void *)pDevice, + WLAN_CMD_BSSID_SCAN, + abyScanSSID); + else + bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); + + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_ZONETYPE_SET: + result = -EOPNOTSUPP; + break; + + if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { + result = -EFAULT; + break; + } + + if (sZoneTypeCmd.bWrite == TRUE) { + /* write zonetype */ + if (sZoneTypeCmd.ZoneType == ZoneType_USA) { + /* set to USA */ + printk("set_ZoneType:USA\n"); + } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) { + /* set to Japan */ + printk("set_ZoneType:Japan\n"); + } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) { + /* set to Europe */ + printk("set_ZoneType:Europe\n"); + } + } else { + /* read zonetype */ + BYTE zonetype = 0; + + if (zonetype == 0x00) { /* USA */ + sZoneTypeCmd.ZoneType = ZoneType_USA; + } else if (zonetype == 0x01) { /* Japan */ + sZoneTypeCmd.ZoneType = ZoneType_Japan; + } else if (zonetype == 0x02) { /* Europe */ + sZoneTypeCmd.ZoneType = ZoneType_Europe; + } else { /* Unknown ZoneType */ + printk("Error:ZoneType[%x] Unknown ???\n", zonetype); + result = -EFAULT; + break; + } + + if (copy_to_user(pReq->data, &sZoneTypeCmd, + sizeof(SCmdZoneTypeSet))) { + result = -EFAULT; + break; + } + } + break; + case WLAN_CMD_BSS_JOIN: + if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { + result = -EFAULT; + break; + } + + pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; + memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + if (sJoinCmd.wBSSType == ADHOC) { + pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); + } else { + pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); + } + if (sJoinCmd.bPSEnable == TRUE) { + pDevice->ePSMode = WMAC_POWER_FAST; + pMgmt->wListenInterval = 2; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); + } else { + pDevice->ePSMode = WMAC_POWER_CAM; + pMgmt->wListenInterval = 1; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n"); + } + + if (sJoinCmd.bShareKeyAuth == TRUE) { + pMgmt->bShareKeyAlgorithm = TRUE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); + } else { + pMgmt->bShareKeyAlgorithm = FALSE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); + } + + pDevice->uChannel = sJoinCmd.uChannel; + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + pMgmt->eCurrState = WMAC_STATE_IDLE; + bScheduleCommand((void *) pDevice, + WLAN_CMD_BSSID_SCAN, + pMgmt->abyDesireSSID); + bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_SET_WEP: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n"); + memset(&sWEPCmd, 0, sizeof(SCmdSetWEP)); + if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { + result = -EFAULT; + break; + } + if (sWEPCmd.bEnableWep != TRUE) { + int uu; + + pDevice->bEncryptionEnable = FALSE; + pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; + spin_lock_irq(&pDevice->lock); + for (uu = 0; uu < MAX_KEY_TABLE; uu++) + MACvDisableKeyEntry(pDevice, uu); + spin_unlock_irq(&pDevice->lock); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); + break; + } + + for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) { + if (sWEPCmd.bWepKeyAvailable[ii]) { + if (ii == sWEPCmd.byKeyIndex) + dwKeyIndex = ii | (1 << 31); + else + dwKeyIndex = ii; + spin_lock_irq(&pDevice->lock); + KeybSetDefaultKey(pDevice, &(pDevice->sKey), + dwKeyIndex, + sWEPCmd.auWepKeyLength[ii], + NULL, + (PBYTE)&sWEPCmd.abyWepKey[ii][0], + KEY_CTL_WEP); + spin_unlock_irq(&pDevice->lock); + } + } + pDevice->byKeyIndex = sWEPCmd.byKeyIndex; + pDevice->bTransmitKey = TRUE; + pDevice->bEncryptionEnable = TRUE; + pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; + break; + + case WLAN_CMD_GET_LINK: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n"); + + memset(sLinkStatus.abySSID, 0, WLAN_SSID_MAXLEN + 1); + + if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) + sLinkStatus.wBSSType = ADHOC; + else + sLinkStatus.wBSSType = INFRA; + + if (pMgmt->eCurrState == WMAC_STATE_JOINTED) + sLinkStatus.byState = ADHOC_JOINTED; + else + sLinkStatus.byState = ADHOC_STARTED; + + sLinkStatus.uChannel = pMgmt->uCurrChannel; + if (pDevice->bLinkPass == TRUE) { + sLinkStatus.bLink = TRUE; + pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; + memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); + memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); + sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Link Success!\n"); + } else { + sLinkStatus.bLink = FALSE; + sLinkStatus.uLinkRate = 0; + } + if (copy_to_user(pReq->data, &sLinkStatus, + sizeof(SCmdLinkStatus))) { + result = -EFAULT; + break; + } + break; + + case WLAN_CMD_GET_LISTLEN: + cbListCount = 0; + pBSS = &(pMgmt->sBSSList[0]); + for (ii = 0; ii < MAX_BSS_NUM; ii++) { + pBSS = &(pMgmt->sBSSList[ii]); + if (!pBSS->bActive) + continue; + cbListCount++; + } + sList.uItem = cbListCount; + if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { + result = -EFAULT; + break; + } + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_LIST: + if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { + result = -EFAULT; + break; + } + pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); + if (pList == NULL) { + result = -ENOMEM; + break; + } + pList->uItem = sList.uItem; + pBSS = &(pMgmt->sBSSList[0]); + for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { + pBSS = &(pMgmt->sBSSList[jj]); + if (pBSS->bActive) { + pList->sBSSIDList[ii].uChannel = pBSS->uChannel; + pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; + pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; + RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); + pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm; + /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */ + memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); + pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; + memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); + memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); + if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { + pList->sBSSIDList[ii].byNetType = INFRA; + } else { + pList->sBSSIDList[ii].byNetType = ADHOC; + } + if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { + pList->sBSSIDList[ii].bWEPOn = TRUE; + } else { + pList->sBSSIDList[ii].bWEPOn = FALSE; + } + ii++; + if (ii >= pList->uItem) + break; + } + } + + if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { + result = -EFAULT; + break; + } + kfree(pList); + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_MIB: + if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { + result = -EFAULT; + break; + } + break; + + case WLAN_CMD_GET_STAT: + if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { + result = -EFAULT; + break; + } + break; + case WLAN_CMD_STOP_MAC: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); + /* Todo xxxxxx */ + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + if (pDevice->bRadioOff == FALSE) { + CARDbRadioPowerOff(pDevice); + } + pDevice->bLinkPass = FALSE; + ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + memset(pMgmt->abyCurrBSSID, 0, 6); + pMgmt->eCurrState = WMAC_STATE_IDLE; + /* del_timer(&pDevice->sTimerCommand); */ + /* del_timer(&pMgmt->sTimerSecondCallback); */ + pDevice->bCmdRunning = FALSE; + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_START_MAC: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); + /* Todo xxxxxxx */ + if (pDevice->bRadioOff == TRUE) + CARDbRadioPowerOn(pDevice); + break; + + case WLAN_CMD_SET_HOSTAPD: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); + + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + if (sValue.dwValue == 1) { + if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); + } else { + result = -EFAULT; + break; + } + } else { + vt6656_hostap_set_hostapd(pDevice, 0, 1); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); + } + break; + + case WLAN_CMD_SET_HOSTAPD_STA: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); + break; + + case WLAN_CMD_SET_802_1X: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + + if (sValue.dwValue == 1) { + pDevice->bEnable8021x = TRUE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); + } else { + pDevice->bEnable8021x = FALSE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); + } + break; + + case WLAN_CMD_SET_HOST_WEP: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + + if (sValue.dwValue == 1) { + pDevice->bEnableHostWEP = TRUE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); + } else { + pDevice->bEnableHostWEP = FALSE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); + } + break; + + case WLAN_CMD_SET_WPA: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); + + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + if (sValue.dwValue == 1) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); + memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, + ETH_ALEN); + pDevice->bWPADEVUp = TRUE; + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); + pDevice->bWPADEVUp = FALSE; + } + break; + + case WLAN_CMD_AP_START: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); + if (pDevice->bRadioOff == TRUE) { + CARDbRadioPowerOn(pDevice); + add_timer(&pMgmt->sTimerSecondCallback); + } + if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { + result = -EFAULT; + break; + } + + if (sStartAPCmd.wBSSType == AP) { + pMgmt->eConfigMode = WMAC_CONFIG_AP; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); + result = -EFAULT; + break; + } + + if (sStartAPCmd.wBBPType == PHY80211g) { + pMgmt->byAPBBType = PHY_TYPE_11G; + } else if (sStartAPCmd.wBBPType == PHY80211a) { + pMgmt->byAPBBType = PHY_TYPE_11A; + } else { + pMgmt->byAPBBType = PHY_TYPE_11B; + } + + pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; + memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + + if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14)) + pDevice->uChannel = sStartAPCmd.uChannel; + + if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) + pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; + else + pMgmt->wIBSSBeaconPeriod = 100; + + if (sStartAPCmd.bShareKeyAuth == TRUE) { + pMgmt->bShareKeyAlgorithm = TRUE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); + } else { + pMgmt->bShareKeyAlgorithm = FALSE; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); + } + memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); + + if (sStartAPCmd.byBasicRate & BIT3) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + pMgmt->abyIBSSSuppRates[4] |= BIT7; + pMgmt->abyIBSSSuppRates[5] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT2) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + pMgmt->abyIBSSSuppRates[4] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT1) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT1) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + } else { + /* default 1,2M */ + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + } + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", + pMgmt->abyIBSSSuppRates[2], + pMgmt->abyIBSSSuppRates[3], + pMgmt->abyIBSSSuppRates[4], + pMgmt->abyIBSSSuppRates[5]); + + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_GET_NODE_CNT: + cbListCount = 0; + pNode = &(pMgmt->sNodeDBTable[0]); + for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { + pNode = &(pMgmt->sNodeDBTable[ii]); + if (!pNode->bActive) + continue; + cbListCount++; + } + + sNodeList.uItem = cbListCount; + if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { + result = -EFAULT; + break; + } + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_NODE_LIST: + if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { + result = -EFAULT; + break; + } + pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); + if (pNodeList == NULL) { + result = -ENOMEM; + break; + } + pNodeList->uItem = sNodeList.uItem; + pNode = &(pMgmt->sNodeDBTable[0]); + for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { + pNode = &(pMgmt->sNodeDBTable[ii]); + if (pNode->bActive) { + pNodeList->sNodeList[jj].wAID = pNode->wAID; + memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); + pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; + pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount; + pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt; + pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags; + pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; + pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; + pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; + memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", + pNodeList->sNodeList[jj].abyWepKey[0], + pNodeList->sNodeList[jj].abyWepKey[1], + pNodeList->sNodeList[jj].abyWepKey[2], + pNodeList->sNodeList[jj].abyWepKey[3], + pNodeList->sNodeList[jj].abyWepKey[4]); + pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; + pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; + pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; + pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio; + jj++; + if (jj >= pNodeList->uItem) + break; + } + } + if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { + result = -EFAULT; + break; + } + kfree(pNodeList); + pReq->wResult = 0; + break; + + case 0xFF: + memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname)); + wpa_Result.proto = 0; + wpa_Result.key_mgmt = 0; + wpa_Result.eap_type = 0; + wpa_Result.authenticated = FALSE; + pDevice->fWPA_Authened = FALSE; + if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { + result = -EFAULT; + break; + } + /* for some AP maybe good authenticate */ + if (wpa_Result.key_mgmt == 0x20) + pMgmt->Cisco_cckm = 1; + else + pMgmt->Cisco_cckm = 0; + + if (wpa_Result.authenticated == TRUE) { + { + union iwreq_data wrqu; + + pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; + wrqu.data.length = pItemSSID->len; + wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); + } + + pDevice->fWPA_Authened = TRUE; /* is successful peer to wpa_Result.authenticated? */ + } + + pReq->wResult = 0; + break; + + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); + } + + return result; } From 44ec5d29169426b00fe054f0a13744140de29e11 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 20 Oct 2011 09:10:39 +0300 Subject: [PATCH 1501/1519] Staging: vt6656: add some range checks before memcpy() We need to verify that we're not writing past the end of the array. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c index 2cde4f0c046..49390026dea 100644 --- a/drivers/staging/vt6656/ioctl.c +++ b/drivers/staging/vt6656/ioctl.c @@ -81,6 +81,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; if (pItemSSID->len != 0) { memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); @@ -155,6 +157,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if (sJoinCmd.wBSSType == ADHOC) { @@ -476,6 +480,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); From 0d3eb2b29f116a2be4e042cbab0e14c9957cc8e2 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 20 Oct 2011 09:09:46 +0300 Subject: [PATCH 1502/1519] Staging: vt6655: whitespace fixes to iotcl.c The indents didn't line up at all in the original code. I also fixed a bunch of other white issues as I went along. I changed the comment style and removed some commented out code. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 1301 +++++++++++++++----------------- 1 file changed, 598 insertions(+), 703 deletions(-) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 43964a5e72a..6718cfdd775 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -38,716 +38,611 @@ #include "wpactl.h" #include "rf.h" -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; +static int msglevel = MSG_LEVEL_INFO; #ifdef WPA_SM_Transtatus - SWPAResult wpa_Result; + SWPAResult wpa_Result; #endif -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -int private_ioctl(PSDevice pDevice, struct ifreq *rq) { - - PSCmdRequest pReq = (PSCmdRequest)rq; - PSMgmtObject pMgmt = pDevice->pMgmt; - int result = 0; - PWLAN_IE_SSID pItemSSID; - SCmdBSSJoin sJoinCmd; - SCmdZoneTypeSet sZoneTypeCmd; - SCmdScan sScanCmd; - SCmdStartAP sStartAPCmd; - SCmdSetWEP sWEPCmd; - SCmdValue sValue; - SBSSIDList sList; - SNodeList sNodeList; - PSBSSIDList pList; - PSNodeList pNodeList; - unsigned int cbListCount; - PKnownBSS pBSS; - PKnownNodeDB pNode; - unsigned int ii, jj; - SCmdLinkStatus sLinkStatus; - unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned long dwKeyIndex= 0; - unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - long ldBm; - - pReq->wResult = 0; - - switch (pReq->wCmdCode) { - - case WLAN_CMD_BSS_SCAN: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n"); - if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; - if (pItemSSID->len != 0) { - memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - } - - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - spin_lock_irq(&pDevice->lock); - if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) - BSSvClearBSSList((void *)pDevice, false); - else - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - - if (pItemSSID->len != 0) - bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); - else - bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_ZONETYPE_SET: - //mike add :cann't support. - result=-EOPNOTSUPP; - break; - - if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - - if(sZoneTypeCmd.bWrite==true) { - //////write zonetype - if(sZoneTypeCmd.ZoneType == ZoneType_USA) { - //set to USA - printk("set_ZoneType:USA\n"); - } - else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) { - //set to Japan - printk("set_ZoneType:Japan\n"); - } - else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) { - //set to Europe - printk("set_ZoneType:Europe\n"); - } - } - else { - ///////read zonetype - unsigned char zonetype=0; - - - if(zonetype == 0x00) { //USA - sZoneTypeCmd.ZoneType = ZoneType_USA; - } - else if(zonetype == 0x01) { //Japan - sZoneTypeCmd.ZoneType = ZoneType_Japan; - } - else if(zonetype == 0x02) { //Europe - sZoneTypeCmd.ZoneType = ZoneType_Europe; - } - else { //Unknown ZoneType - printk("Error:ZoneType[%x] Unknown ???\n",zonetype); - result = -EFAULT; - break; - } - if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - } - - break; - - case WLAN_CMD_BSS_JOIN: - - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - - if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - if (sJoinCmd.wBSSType == ADHOC) { - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); - } - else { - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); - } - if (sJoinCmd.bPSEnable == true) { - pDevice->ePSMode = WMAC_POWER_FAST; -// pDevice->ePSMode = WMAC_POWER_MAX; - pMgmt->wListenInterval = 2; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); - } - else { - pDevice->ePSMode = WMAC_POWER_CAM; - pMgmt->wListenInterval = 1; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n"); - } - - if (sJoinCmd.bShareKeyAuth == true){ - pMgmt->bShareKeyAlgorithm = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); - } - else { - pMgmt->bShareKeyAlgorithm = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); - } - pDevice->uChannel = sJoinCmd.uChannel; - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - pMgmt->eCurrState = WMAC_STATE_IDLE; - bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_SET_WEP: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n"); - memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP)); - if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { - result = -EFAULT; - break; - } - if (sWEPCmd.bEnableWep != true) { - pDevice->bEncryptionEnable = false; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - MACvDisableDefaultKey(pDevice->PortOffset); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n"); - break; - } - - for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) { - if (sWEPCmd.bWepKeyAvailable[ii]) { - if (ii == sWEPCmd.byKeyIndex) - //2006-1123-02, by EinsnLiu - //Evaluate the "dwKeyIndex" error - // dwKeyIndex |= (1 << 31); - dwKeyIndex =ii|(1 << 31); - else - dwKeyIndex = ii; - - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex, - sWEPCmd.auWepKeyLength[ii], - NULL, - (unsigned char *)&sWEPCmd.abyWepKey[ii][0], - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID); - } - } - pDevice->byKeyIndex = sWEPCmd.byKeyIndex; - pDevice->bTransmitKey = true; - pDevice->bEncryptionEnable = true; - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - - break; - - case WLAN_CMD_GET_LINK: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n"); - - memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - sLinkStatus.wBSSType = ADHOC; - else - sLinkStatus.wBSSType = INFRA; - - if (pMgmt->eCurrState == WMAC_STATE_JOINTED) - sLinkStatus.byState = ADHOC_JOINTED; - else - sLinkStatus.byState = ADHOC_STARTED; - - sLinkStatus.uChannel = pMgmt->uCurrChannel; - if (pDevice->bLinkPass == true) { - sLinkStatus.bLink = true; - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); - memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n"); - } - else { - sLinkStatus.bLink = false; - sLinkStatus.uLinkRate = 0; - } - if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { - result = -EFAULT; - break; - } - - break; - - case WLAN_CMD_GET_LISTLEN: - cbListCount = 0; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - cbListCount++; - } - sList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_LIST: - if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); - if (pList == NULL) { - result = -ENOMEM; - break; - } - pList->uItem = sList.uItem; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { - pBSS = &(pMgmt->sBSSList[jj]); - if (pBSS->bActive) { - pList->sBSSIDList[ii].uChannel = pBSS->uChannel; - pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; - pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; -// pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; - RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); - pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; - memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; - memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); - memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); - if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { - pList->sBSSIDList[ii].byNetType = INFRA; - } - else { - pList->sBSSIDList[ii].byNetType = ADHOC; - } - if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { - pList->sBSSIDList[ii].bWEPOn = true; - } - else { - pList->sBSSIDList[ii].bWEPOn = false; - } - ii ++; - if (ii >= pList->uItem) - break; - } - } - - if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { - result = -EFAULT; - break; - } - kfree(pList); - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_MIB: - if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { - result = -EFAULT; - break; - } - break; - - case WLAN_CMD_GET_STAT: - if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { - result = -EFAULT; - break; - } - break; - case WLAN_CMD_STOP_MAC: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); - netif_stop_queue(pDevice->dev); - - spin_lock_irq(&pDevice->lock); - if (pDevice->bRadioOff == false) { - CARDbRadioPowerOff(pDevice); - } - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - del_timer(&pDevice->sTimerCommand); - del_timer(&pMgmt->sTimerSecondCallback); - pDevice->bCmdRunning = false; - pDevice->bMACSuspend = true; - MACvIntDisable(pDevice->PortOffset); - spin_unlock_irq(&pDevice->lock); - - break; - - case WLAN_CMD_START_MAC: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); - - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - break; - - case WLAN_CMD_SET_HOSTAPD: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0){ - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); - } - else { - result = -EFAULT; - break; - } - } - else { - vt6655_hostap_set_hostapd(pDevice, 0, 1); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); - } - - break; - - case WLAN_CMD_SET_HOSTAPD_STA: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); - - break; - case WLAN_CMD_SET_802_1X: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnable8021x = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); - } - else { - pDevice->bEnable8021x = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); - } - - break; - - - case WLAN_CMD_SET_HOST_WEP: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnableHostWEP = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); - } - else { - pDevice->bEnableHostWEP = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); - } - - break; - - case WLAN_CMD_SET_WPA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); - memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN); - pDevice->bWPADEVUp = true; - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); - pDevice->bWPADEVUp = false; - } - - break; - - case WLAN_CMD_AP_START: - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); - if (pDevice->bRadioOff == true) { - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - } - if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { - result = -EFAULT; - break; - } - - if (sStartAPCmd.wBSSType == AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); - result = -EFAULT; - break; - } - - - if (sStartAPCmd.wBBPType == PHY80211g) { - pMgmt->byAPBBType = PHY_TYPE_11G; - } - else if (sStartAPCmd.wBBPType == PHY80211a) { - pMgmt->byAPBBType = PHY_TYPE_11A; - } - else { - pMgmt->byAPBBType = PHY_TYPE_11B; - } - - pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - - if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14)) - pDevice->uChannel = sStartAPCmd.uChannel; - - if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) - pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; - else - pMgmt->wIBSSBeaconPeriod = 100; - - if (sStartAPCmd.bShareKeyAuth == true){ - pMgmt->bShareKeyAlgorithm = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); - } - else { - pMgmt->bShareKeyAlgorithm = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); - } - memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); - - if (sStartAPCmd.byBasicRate & BIT3) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - pMgmt->abyIBSSSuppRates[5] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT2) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - }else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - }else { - //default 1,2M - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", - pMgmt->abyIBSSSuppRates[2], - pMgmt->abyIBSSSuppRates[3], - pMgmt->abyIBSSSuppRates[4], - pMgmt->abyIBSSSuppRates[5] - ); - - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_GET_NODE_CNT: - - cbListCount = 0; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (!pNode->bActive) - continue; - cbListCount++; - } - - sNodeList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_NODE_LIST: - - if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); - if (pNodeList == NULL) { - result = -ENOMEM; - break; - } - pNodeList->uItem = sNodeList.uItem; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (pNode->bActive) { - pNodeList->sNodeList[jj].wAID = pNode->wAID; - memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); - pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; - pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount; - pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt; - pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags; - pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; - pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; - pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; - memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - pNodeList->sNodeList[jj].abyWepKey[0], - pNodeList->sNodeList[jj].abyWepKey[1], - pNodeList->sNodeList[jj].abyWepKey[2], - pNodeList->sNodeList[jj].abyWepKey[3], - pNodeList->sNodeList[jj].abyWepKey[4] - ); - pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; - pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; - pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; - pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio; - jj ++; - if (jj >= pNodeList->uItem) - break; - } - } - if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { - result = -EFAULT; - break; - } - kfree(pNodeList); - pReq->wResult = 0; - break; - -#ifdef WPA_SM_Transtatus - case 0xFF: - memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname)); - wpa_Result.proto = 0; - wpa_Result.key_mgmt = 0; - wpa_Result.eap_type = 0; - wpa_Result.authenticated = false; - pDevice->fWPA_Authened = false; - if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { - result = -EFAULT; - break; - } - -if(wpa_Result.authenticated==true) { - #ifdef SndEvt_ToAPI - { - union iwreq_data wrqu; - - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; - wrqu.data.length =pItemSSID->len; - wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); - } - #endif - pDevice->fWPA_Authened = true; //is successful peer to wpa_Result.authenticated? -} - - //printk("get private wpa_supplicant announce WPA SM\n"); - //printk("wpa-->ifname=%s\n",wpa_Result.ifname); - //printk("wpa-->proto=%d\n",wpa_Result.proto); - //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt); - //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type); - //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==true)?"true":"false"); +int private_ioctl(PSDevice pDevice, struct ifreq *rq) +{ + PSCmdRequest pReq = (PSCmdRequest)rq; + PSMgmtObject pMgmt = pDevice->pMgmt; + int result = 0; + PWLAN_IE_SSID pItemSSID; + SCmdBSSJoin sJoinCmd; + SCmdZoneTypeSet sZoneTypeCmd; + SCmdScan sScanCmd; + SCmdStartAP sStartAPCmd; + SCmdSetWEP sWEPCmd; + SCmdValue sValue; + SBSSIDList sList; + SNodeList sNodeList; + PSBSSIDList pList; + PSNodeList pNodeList; + unsigned int cbListCount; + PKnownBSS pBSS; + PKnownNodeDB pNode; + unsigned int ii, jj; + SCmdLinkStatus sLinkStatus; + unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; + unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned long dwKeyIndex = 0; + unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + long ldBm; pReq->wResult = 0; - break; + + switch (pReq->wCmdCode) { + case WLAN_CMD_BSS_SCAN: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); + if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { + result = -EFAULT; + break; + } + + pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; + if (pItemSSID->len != 0) { + memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + } + + if (pDevice->bMACSuspend == true) { + if (pDevice->bRadioOff == true) + CARDbRadioPowerOn(pDevice); + vMgrTimerInit(pDevice); + MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); + add_timer(&pMgmt->sTimerSecondCallback); + pDevice->bMACSuspend = false; + } + spin_lock_irq(&pDevice->lock); + if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) + BSSvClearBSSList((void *)pDevice, false); + else + BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); + + if (pItemSSID->len != 0) + bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); + else + bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_ZONETYPE_SET: + /* mike add :cann't support. */ + result = -EOPNOTSUPP; + break; + + if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { + result = -EFAULT; + break; + } + + if (sZoneTypeCmd.bWrite == true) { + /* write zonetype */ + if (sZoneTypeCmd.ZoneType == ZoneType_USA) { + /* set to USA */ + printk("set_ZoneType:USA\n"); + } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) { + /* set to Japan */ + printk("set_ZoneType:Japan\n"); + } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) { + /* set to Europe */ + printk("set_ZoneType:Europe\n"); + } + } else { + /* read zonetype */ + unsigned char zonetype = 0; + + if (zonetype == 0x00) { /* USA */ + sZoneTypeCmd.ZoneType = ZoneType_USA; + } else if (zonetype == 0x01) { /* Japan */ + sZoneTypeCmd.ZoneType = ZoneType_Japan; + } else if (zonetype == 0x02) { /* Europe */ + sZoneTypeCmd.ZoneType = ZoneType_Europe; + } else { /* Unknown ZoneType */ + printk("Error:ZoneType[%x] Unknown ???\n", zonetype); + result = -EFAULT; + break; + } + if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { + result = -EFAULT; + break; + } + } + break; + + case WLAN_CMD_BSS_JOIN: + if (pDevice->bMACSuspend == true) { + if (pDevice->bRadioOff == true) + CARDbRadioPowerOn(pDevice); + vMgrTimerInit(pDevice); + MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); + add_timer(&pMgmt->sTimerSecondCallback); + pDevice->bMACSuspend = false; + } + + if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { + result = -EFAULT; + break; + } + + pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; + memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + if (sJoinCmd.wBSSType == ADHOC) { + pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); + } else { + pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); + } + if (sJoinCmd.bPSEnable == true) { + pDevice->ePSMode = WMAC_POWER_FAST; + pMgmt->wListenInterval = 2; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); + } else { + pDevice->ePSMode = WMAC_POWER_CAM; + pMgmt->wListenInterval = 1; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n"); + } + + if (sJoinCmd.bShareKeyAuth == true) { + pMgmt->bShareKeyAlgorithm = true; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); + } else { + pMgmt->bShareKeyAlgorithm = false; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); + } + pDevice->uChannel = sJoinCmd.uChannel; + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + pMgmt->eCurrState = WMAC_STATE_IDLE; + bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); + bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_SET_WEP: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n"); + memset(&sWEPCmd, 0, sizeof(SCmdSetWEP)); + if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { + result = -EFAULT; + break; + } + if (sWEPCmd.bEnableWep != true) { + pDevice->bEncryptionEnable = false; + pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; + MACvDisableDefaultKey(pDevice->PortOffset); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); + break; + } + + for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) { + if (sWEPCmd.bWepKeyAvailable[ii]) { + if (ii == sWEPCmd.byKeyIndex) + dwKeyIndex = ii | (1 << 31); + else + dwKeyIndex = ii; + + KeybSetDefaultKey(&(pDevice->sKey), + dwKeyIndex, + sWEPCmd.auWepKeyLength[ii], + NULL, + (unsigned char *)&sWEPCmd.abyWepKey[ii][0], + KEY_CTL_WEP, + pDevice->PortOffset, + pDevice->byLocalID); + } + } + pDevice->byKeyIndex = sWEPCmd.byKeyIndex; + pDevice->bTransmitKey = true; + pDevice->bEncryptionEnable = true; + pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; + break; + + case WLAN_CMD_GET_LINK: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n"); + + memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); + + if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) + sLinkStatus.wBSSType = ADHOC; + else + sLinkStatus.wBSSType = INFRA; + + if (pMgmt->eCurrState == WMAC_STATE_JOINTED) + sLinkStatus.byState = ADHOC_JOINTED; + else + sLinkStatus.byState = ADHOC_STARTED; + + sLinkStatus.uChannel = pMgmt->uCurrChannel; + if (pDevice->bLinkPass == true) { + sLinkStatus.bLink = true; + pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; + memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); + memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); + sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success!\n"); + } else { + sLinkStatus.bLink = false; + sLinkStatus.uLinkRate = 0; + } + if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { + result = -EFAULT; + break; + } + break; + + case WLAN_CMD_GET_LISTLEN: + cbListCount = 0; + pBSS = &(pMgmt->sBSSList[0]); + for (ii = 0; ii < MAX_BSS_NUM; ii++) { + pBSS = &(pMgmt->sBSSList[ii]); + if (!pBSS->bActive) + continue; + cbListCount++; + } + sList.uItem = cbListCount; + if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { + result = -EFAULT; + break; + } + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_LIST: + if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { + result = -EFAULT; + break; + } + pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); + if (pList == NULL) { + result = -ENOMEM; + break; + } + pList->uItem = sList.uItem; + pBSS = &(pMgmt->sBSSList[0]); + for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { + pBSS = &(pMgmt->sBSSList[jj]); + if (pBSS->bActive) { + pList->sBSSIDList[ii].uChannel = pBSS->uChannel; + pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; + pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; + /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */ + RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); + pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; + memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); + pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; + memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); + memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); + if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { + pList->sBSSIDList[ii].byNetType = INFRA; + } else { + pList->sBSSIDList[ii].byNetType = ADHOC; + } + if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { + pList->sBSSIDList[ii].bWEPOn = true; + } else { + pList->sBSSIDList[ii].bWEPOn = false; + } + ii++; + if (ii >= pList->uItem) + break; + } + } + + if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { + result = -EFAULT; + break; + } + kfree(pList); + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_MIB: + if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { + result = -EFAULT; + break; + } + break; + + case WLAN_CMD_GET_STAT: + if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { + result = -EFAULT; + break; + } + break; + + case WLAN_CMD_STOP_MAC: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); + netif_stop_queue(pDevice->dev); + + spin_lock_irq(&pDevice->lock); + if (pDevice->bRadioOff == false) { + CARDbRadioPowerOff(pDevice); + } + pDevice->bLinkPass = false; + memset(pMgmt->abyCurrBSSID, 0, 6); + pMgmt->eCurrState = WMAC_STATE_IDLE; + del_timer(&pDevice->sTimerCommand); + del_timer(&pMgmt->sTimerSecondCallback); + pDevice->bCmdRunning = false; + pDevice->bMACSuspend = true; + MACvIntDisable(pDevice->PortOffset); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_START_MAC: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); + + if (pDevice->bMACSuspend == true) { + if (pDevice->bRadioOff == true) + CARDbRadioPowerOn(pDevice); + vMgrTimerInit(pDevice); + MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); + add_timer(&pMgmt->sTimerSecondCallback); + pDevice->bMACSuspend = false; + } + break; + + case WLAN_CMD_SET_HOSTAPD: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); + + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + if (sValue.dwValue == 1) { + if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); + } else { + result = -EFAULT; + break; + } + } else { + vt6655_hostap_set_hostapd(pDevice, 0, 1); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); + } + break; + + case WLAN_CMD_SET_HOSTAPD_STA: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); + break; + + case WLAN_CMD_SET_802_1X: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + + if (sValue.dwValue == 1) { + pDevice->bEnable8021x = true; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); + } else { + pDevice->bEnable8021x = false; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); + } + break; + + case WLAN_CMD_SET_HOST_WEP: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + + if (sValue.dwValue == 1) { + pDevice->bEnableHostWEP = true; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); + } else { + pDevice->bEnableHostWEP = false; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); + } + break; + + case WLAN_CMD_SET_WPA: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); + + if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { + result = -EFAULT; + break; + } + if (sValue.dwValue == 1) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); + memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN); + pDevice->bWPADEVUp = true; + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); + pDevice->bWPADEVUp = false; + } + break; + + case WLAN_CMD_AP_START: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); + if (pDevice->bRadioOff == true) { + CARDbRadioPowerOn(pDevice); + vMgrTimerInit(pDevice); + MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); + add_timer(&pMgmt->sTimerSecondCallback); + } + if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { + result = -EFAULT; + break; + } + + if (sStartAPCmd.wBSSType == AP) { + pMgmt->eConfigMode = WMAC_CONFIG_AP; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); + result = -EFAULT; + break; + } + + if (sStartAPCmd.wBBPType == PHY80211g) { + pMgmt->byAPBBType = PHY_TYPE_11G; + } else if (sStartAPCmd.wBBPType == PHY80211a) { + pMgmt->byAPBBType = PHY_TYPE_11A; + } else { + pMgmt->byAPBBType = PHY_TYPE_11B; + } + + pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; + memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); + memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); + + if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14)) + pDevice->uChannel = sStartAPCmd.uChannel; + + if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) + pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; + else + pMgmt->wIBSSBeaconPeriod = 100; + + if (sStartAPCmd.bShareKeyAuth == true) { + pMgmt->bShareKeyAlgorithm = true; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); + } else { + pMgmt->bShareKeyAlgorithm = false; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); + } + memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); + + if (sStartAPCmd.byBasicRate & BIT3) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + pMgmt->abyIBSSSuppRates[4] |= BIT7; + pMgmt->abyIBSSSuppRates[5] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT2) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + pMgmt->abyIBSSSuppRates[4] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT1) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + } else if (sStartAPCmd.byBasicRate & BIT1) { + pMgmt->abyIBSSSuppRates[2] |= BIT7; + } else { + /* default 1,2M */ + pMgmt->abyIBSSSuppRates[2] |= BIT7; + pMgmt->abyIBSSSuppRates[3] |= BIT7; + } + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", + pMgmt->abyIBSSSuppRates[2], + pMgmt->abyIBSSSuppRates[3], + pMgmt->abyIBSSSuppRates[4], + pMgmt->abyIBSSSuppRates[5]); + + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); + spin_unlock_irq(&pDevice->lock); + break; + + case WLAN_CMD_GET_NODE_CNT: + cbListCount = 0; + pNode = &(pMgmt->sNodeDBTable[0]); + for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { + pNode = &(pMgmt->sNodeDBTable[ii]); + if (!pNode->bActive) + continue; + cbListCount++; + } + + sNodeList.uItem = cbListCount; + if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { + result = -EFAULT; + break; + } + pReq->wResult = 0; + break; + + case WLAN_CMD_GET_NODE_LIST: + if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { + result = -EFAULT; + break; + } + pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); + if (pNodeList == NULL) { + result = -ENOMEM; + break; + } + pNodeList->uItem = sNodeList.uItem; + pNode = &(pMgmt->sNodeDBTable[0]); + for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { + pNode = &(pMgmt->sNodeDBTable[ii]); + if (pNode->bActive) { + pNodeList->sNodeList[jj].wAID = pNode->wAID; + memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); + pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; + pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount; + pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt; + pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags; + pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; + pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; + pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; + memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", + pNodeList->sNodeList[jj].abyWepKey[0], + pNodeList->sNodeList[jj].abyWepKey[1], + pNodeList->sNodeList[jj].abyWepKey[2], + pNodeList->sNodeList[jj].abyWepKey[3], + pNodeList->sNodeList[jj].abyWepKey[4]); + pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; + pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; + pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; + pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio; + jj++; + if (jj >= pNodeList->uItem) + break; + } + } + if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { + result = -EFAULT; + break; + } + kfree(pNodeList); + pReq->wResult = 0; + break; + +#ifdef WPA_SM_Transtatus + case 0xFF: + memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname)); + wpa_Result.proto = 0; + wpa_Result.key_mgmt = 0; + wpa_Result.eap_type = 0; + wpa_Result.authenticated = false; + pDevice->fWPA_Authened = false; + if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { + result = -EFAULT; + break; + } + + if (wpa_Result.authenticated == true) { +#ifdef SndEvt_ToAPI + { + union iwreq_data wrqu; + + pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; + + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; + wrqu.data.length = pItemSSID->len; + wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); + } +#endif + pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */ + } + pReq->wResult = 0; + break; #endif - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); - } + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); + } - return result; + return result; } - -/* -void -vConfigWEPKey ( - PSDevice pDevice, - unsigned long dwKeyIndex, - unsigned char *pbyKey, - unsigned long uKeyLength - ) -{ - int ii; - - - memset(&pDevice->abyWepKey[dwKeyIndex][0], 0, WLAN_WEPMAX_KEYLEN); - memcpy(&pDevice->abyWepKey[dwKeyIndex][0], pbyKey, uKeyLength); - - pDevice->bWepKeyAvailable[dwKeyIndex] = true; - pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength; - - MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex, - (unsigned long *) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID); - - if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) { - for(ii=0; iibWepKeyAvailable[ii] == true) && - (pDevice->auWepKeyLength[ii] == WLAN_WEP232_KEYLEN)) { - pDevice->uCurrentWEPMode = TX_WEP_SW232; - MACvDisableDefaultKey(pDevice->PortOffset); - break; - } - } - if ((ii == MAX_GROUP_KEY) && - (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported)) { - MACvEnableDefaultKey(pDevice->PortOffset, pDevice->byLocalID); - } - } -} -*/ From 0c849b3c16f4dab5848182868094adeb51210d8b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 20 Oct 2011 09:10:09 +0300 Subject: [PATCH 1503/1519] Staging: vt6655: add some range checks before memcpy() There were no range checks in the original code so the user could write past the end of the array. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 6718cfdd775..432a20993c6 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -82,6 +82,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; if (pItemSSID->len != 0) { memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); @@ -168,6 +170,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if (sJoinCmd.wBSSType == ADHOC) { @@ -490,6 +494,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) } pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; + if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) + return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); From dafb7d1bd07f61cbaf963345d4ed1c89923e6782 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 20 Oct 2011 14:38:43 +0200 Subject: [PATCH 1504/1519] staging:iio:trigger:bfin-timer: Fix compile error Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 243f38f80de..1cbb25dff8b 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -144,7 +144,7 @@ static int iio_bfin_tmr_get_number(int irq) } static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = { - owner = THIS_MODULE, + .owner = THIS_MODULE, }; static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev) From a3e2940c24d319558dcb7cb7736de9c814be7c7b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 20 Oct 2011 10:46:38 +0200 Subject: [PATCH 1505/1519] staging:iio:dac: Add AD5360 driver This patch adds support for the Analog Devices AD5360, AD5361, AD5362, AD5363, AD5370, AD5371, AD5372, AD5373 multi-channel digital-to-analog converters. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/dac/Kconfig | 11 + drivers/staging/iio/dac/Makefile | 1 + drivers/staging/iio/dac/ad5360.c | 581 +++++++++++++++++++++++++++++++ 3 files changed, 593 insertions(+) create mode 100644 drivers/staging/iio/dac/ad5360.c diff --git a/drivers/staging/iio/dac/Kconfig b/drivers/staging/iio/dac/Kconfig index 72281f87caa..fac8549dc8e 100644 --- a/drivers/staging/iio/dac/Kconfig +++ b/drivers/staging/iio/dac/Kconfig @@ -13,6 +13,17 @@ config AD5064 To compile this driver as a module, choose M here: the module will be called ad5064. +config AD5360 + tristate "Analog Devices Analog Devices AD5360/61/62/63/70/71/73 DAC driver" + depends on SPI + help + Say yes here to build support for Analog Devices AD5360, AD5361, + AD5362, AD5363, AD5370, AD5371, AD5373 multi-channel + Digital to Analog Converters (DAC). + + To compile this driver as module choose M here: the module will be called + ad5360. + config AD5624R_SPI tristate "Analog Devices AD5624/44/64R DAC spi driver" depends on SPI diff --git a/drivers/staging/iio/dac/Makefile b/drivers/staging/iio/dac/Makefile index ea4975031fe..07b6f5ebdb5 100644 --- a/drivers/staging/iio/dac/Makefile +++ b/drivers/staging/iio/dac/Makefile @@ -2,6 +2,7 @@ # Makefile for industrial I/O DAC drivers # +obj-$(CONFIG_AD5360) += ad5360.o obj-$(CONFIG_AD5624R_SPI) += ad5624r_spi.o obj-$(CONFIG_AD5064) += ad5064.o obj-$(CONFIG_AD5504) += ad5504.o diff --git a/drivers/staging/iio/dac/ad5360.c b/drivers/staging/iio/dac/ad5360.c new file mode 100644 index 00000000000..72d0f3f0d6a --- /dev/null +++ b/drivers/staging/iio/dac/ad5360.c @@ -0,0 +1,581 @@ +/* + * Analog devices AD5360, AD5361, AD5362, AD5363, AD5370, AD5371, AD5373 + * multi-channel Digital to Analog Converters driver + * + * Copyright 2011 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../iio.h" +#include "../sysfs.h" +#include "dac.h" + +#define AD5360_CMD(x) ((x) << 22) +#define AD5360_ADDR(x) ((x) << 16) + +#define AD5360_READBACK_TYPE(x) ((x) << 13) +#define AD5360_READBACK_ADDR(x) ((x) << 7) + +#define AD5360_CHAN_ADDR(chan) ((chan) + 0x8) + +#define AD5360_CMD_WRITE_DATA 0x3 +#define AD5360_CMD_WRITE_OFFSET 0x2 +#define AD5360_CMD_WRITE_GAIN 0x1 +#define AD5360_CMD_SPECIAL_FUNCTION 0x0 + +/* Special function register addresses */ +#define AD5360_REG_SF_NOP 0x0 +#define AD5360_REG_SF_CTRL 0x1 +#define AD5360_REG_SF_OFS(x) (0x2 + (x)) +#define AD5360_REG_SF_READBACK 0x5 + +#define AD5360_SF_CTRL_PWR_DOWN BIT(0) + +#define AD5360_READBACK_X1A 0x0 +#define AD5360_READBACK_X1B 0x1 +#define AD5360_READBACK_OFFSET 0x2 +#define AD5360_READBACK_GAIN 0x3 +#define AD5360_READBACK_SF 0x4 + + +/** + * struct ad5360_chip_info - chip specific information + * @channel_template: channel specification template + * @num_channels: number of channels + * @channels_per_group: number of channels per group + * @num_vrefs: number of vref supplies for the chip +*/ + +struct ad5360_chip_info { + struct iio_chan_spec channel_template; + unsigned int num_channels; + unsigned int channels_per_group; + unsigned int num_vrefs; +}; + +/** + * struct ad5360_state - driver instance specific data + * @spi: spi_device + * @chip_info: chip model specific constants, available modes etc + * @vref_reg: vref supply regulators + * @ctrl: control register cache + * @data: spi transfer buffers + */ + +struct ad5360_state { + struct spi_device *spi; + const struct ad5360_chip_info *chip_info; + struct regulator_bulk_data vref_reg[3]; + unsigned int ctrl; + + /* + * DMA (thus cache coherency maintenance) requires the + * transfer buffers to live in their own cache lines. + */ + union { + __be32 d32; + u8 d8[4]; + } data[2] ____cacheline_aligned; +}; + +enum ad5360_type { + ID_AD5360, + ID_AD5361, + ID_AD5362, + ID_AD5363, + ID_AD5370, + ID_AD5371, + ID_AD5372, + ID_AD5373, +}; + +#define AD5360_CHANNEL(bits) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .output = 1, \ + .info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE) | \ + (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) | \ + (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) | \ + (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE), \ + .scan_type = IIO_ST('u', (bits), 16, 16 - (bits)) \ +} + +static const struct ad5360_chip_info ad5360_chip_info_tbl[] = { + [ID_AD5360] = { + .channel_template = AD5360_CHANNEL(16), + .num_channels = 16, + .channels_per_group = 8, + .num_vrefs = 2, + }, + [ID_AD5361] = { + .channel_template = AD5360_CHANNEL(14), + .num_channels = 16, + .channels_per_group = 8, + .num_vrefs = 2, + }, + [ID_AD5362] = { + .channel_template = AD5360_CHANNEL(16), + .num_channels = 8, + .channels_per_group = 4, + .num_vrefs = 2, + }, + [ID_AD5363] = { + .channel_template = AD5360_CHANNEL(14), + .num_channels = 8, + .channels_per_group = 4, + .num_vrefs = 2, + }, + [ID_AD5370] = { + .channel_template = AD5360_CHANNEL(16), + .num_channels = 40, + .channels_per_group = 8, + .num_vrefs = 2, + }, + [ID_AD5371] = { + .channel_template = AD5360_CHANNEL(14), + .num_channels = 40, + .channels_per_group = 8, + .num_vrefs = 3, + }, + [ID_AD5372] = { + .channel_template = AD5360_CHANNEL(16), + .num_channels = 32, + .channels_per_group = 8, + .num_vrefs = 2, + }, + [ID_AD5373] = { + .channel_template = AD5360_CHANNEL(14), + .num_channels = 32, + .channels_per_group = 8, + .num_vrefs = 2, + }, +}; + +static unsigned int ad5360_get_channel_vref_index(struct ad5360_state *st, + unsigned int channel) +{ + unsigned int i; + + /* The first groups have their own vref, while the remaining groups + * share the last vref */ + i = channel / st->chip_info->channels_per_group; + if (i >= st->chip_info->num_vrefs) + i = st->chip_info->num_vrefs - 1; + + return i; +} + +static int ad5360_get_channel_vref(struct ad5360_state *st, + unsigned int channel) +{ + unsigned int i = ad5360_get_channel_vref_index(st, channel); + + return regulator_get_voltage(st->vref_reg[i].consumer); +} + + +static int ad5360_write_unlocked(struct iio_dev *indio_dev, + unsigned int cmd, unsigned int addr, unsigned int val, + unsigned int shift) +{ + struct ad5360_state *st = iio_priv(indio_dev); + + val <<= shift; + val |= AD5360_CMD(cmd) | AD5360_ADDR(addr); + st->data[0].d32 = cpu_to_be32(val); + + return spi_write(st->spi, &st->data[0].d8[1], 3); +} + +static int ad5360_write(struct iio_dev *indio_dev, unsigned int cmd, + unsigned int addr, unsigned int val, unsigned int shift) +{ + int ret; + + mutex_lock(&indio_dev->mlock); + ret = ad5360_write_unlocked(indio_dev, cmd, addr, val, shift); + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, + unsigned int addr) +{ + struct ad5360_state *st = iio_priv(indio_dev); + struct spi_message m; + int ret; + struct spi_transfer t[] = { + { + .tx_buf = &st->data[0].d8[1], + .len = 3, + .cs_change = 1, + }, { + .rx_buf = &st->data[1].d8[1], + .len = 3, + }, + }; + + spi_message_init(&m); + spi_message_add_tail(&t[0], &m); + spi_message_add_tail(&t[1], &m); + + mutex_lock(&indio_dev->mlock); + + st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | + AD5360_ADDR(AD5360_REG_SF_READBACK) | + AD5360_READBACK_TYPE(type) | + AD5360_READBACK_ADDR(addr)); + + ret = spi_sync(st->spi, &m); + if (ret >= 0) + ret = be32_to_cpu(st->data[1].d32) & 0xffff; + + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static ssize_t ad5360_read_dac_powerdown(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad5360_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN)); +} + +static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set, + unsigned int clr) +{ + struct ad5360_state *st = iio_priv(indio_dev); + unsigned int ret; + + mutex_lock(&indio_dev->mlock); + + st->ctrl |= set; + st->ctrl &= ~clr; + + ret = ad5360_write_unlocked(indio_dev, AD5360_CMD_SPECIAL_FUNCTION, + AD5360_REG_SF_CTRL, st->ctrl, 0); + + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static ssize_t ad5360_write_dac_powerdown(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + bool pwr_down; + int ret; + + ret = strtobool(buf, &pwr_down); + if (ret) + return ret; + + if (pwr_down) + ret = ad5360_update_ctrl(indio_dev, AD5360_SF_CTRL_PWR_DOWN, 0); + else + ret = ad5360_update_ctrl(indio_dev, 0, AD5360_SF_CTRL_PWR_DOWN); + + return ret ? ret : len; +} + +static IIO_DEVICE_ATTR(out_voltage_powerdown, + S_IRUGO | S_IWUSR, + ad5360_read_dac_powerdown, + ad5360_write_dac_powerdown, 0); + +static struct attribute *ad5360_attributes[] = { + &iio_dev_attr_out_voltage_powerdown.dev_attr.attr, + NULL, +}; + +static const struct attribute_group ad5360_attribute_group = { + .attrs = ad5360_attributes, +}; + +static int ad5360_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct ad5360_state *st = iio_priv(indio_dev); + int max_val = (1 << chan->scan_type.realbits); + unsigned int ofs_index; + + switch (mask) { + case 0: + if (val >= max_val || val < 0) + return -EINVAL; + + return ad5360_write(indio_dev, AD5360_CMD_WRITE_DATA, + chan->address, val, chan->scan_type.shift); + + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + if (val >= max_val || val < 0) + return -EINVAL; + + return ad5360_write(indio_dev, AD5360_CMD_WRITE_OFFSET, + chan->address, val, chan->scan_type.shift); + + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + if (val >= max_val || val < 0) + return -EINVAL; + + return ad5360_write(indio_dev, AD5360_CMD_WRITE_GAIN, + chan->address, val, chan->scan_type.shift); + + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + if (val <= -max_val || val > 0) + return -EINVAL; + + val = -val; + + /* offset is supposed to have the same scale as raw, but it + * is always 14bits wide, so on a chip where the raw value has + * more bits, we need to shift offset. */ + val >>= (chan->scan_type.realbits - 14); + + /* There is one DAC offset register per vref. Changing one + * channels offset will also change the offset for all other + * channels which share the same vref supply. */ + ofs_index = ad5360_get_channel_vref_index(st, chan->channel); + return ad5360_write(indio_dev, AD5360_CMD_SPECIAL_FUNCTION, + AD5360_REG_SF_OFS(ofs_index), val, 0); + default: + break; + } + + return -EINVAL; +} + +static int ad5360_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct ad5360_state *st = iio_priv(indio_dev); + unsigned long scale_uv; + unsigned int ofs_index; + int ret; + + switch (m) { + case 0: + ret = ad5360_read(indio_dev, AD5360_READBACK_X1A, + chan->address); + if (ret < 0) + return ret; + *val = ret >> chan->scan_type.shift; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): + /* vout = 4 * vref * dac_code */ + scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100; + if (scale_uv < 0) + return scale_uv; + + scale_uv >>= (chan->scan_type.realbits); + *val = scale_uv / 100000; + *val2 = (scale_uv % 100000) * 10; + return IIO_VAL_INT_PLUS_MICRO; + case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): + ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET, + chan->address); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): + ret = ad5360_read(indio_dev, AD5360_READBACK_GAIN, + chan->address); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): + ofs_index = ad5360_get_channel_vref_index(st, chan->channel); + ret = ad5360_read(indio_dev, AD5360_READBACK_SF, + AD5360_REG_SF_OFS(ofs_index)); + if (ret < 0) + return ret; + + ret <<= (chan->scan_type.realbits - 14); + *val = -ret; + return IIO_VAL_INT; + } + + return -EINVAL; +} + +static const struct iio_info ad5360_info = { + .read_raw = ad5360_read_raw, + .write_raw = ad5360_write_raw, + .attrs = &ad5360_attribute_group, + .driver_module = THIS_MODULE, +}; + +static const char * const ad5360_vref_name[] = { + "vref0", "vref1", "vref2" +}; + +static int __devinit ad5360_alloc_channels(struct iio_dev *indio_dev) +{ + struct ad5360_state *st = iio_priv(indio_dev); + struct iio_chan_spec *channels; + unsigned int i; + + channels = kcalloc(sizeof(struct iio_chan_spec), + st->chip_info->num_channels, GFP_KERNEL); + + if (!channels) + return -ENOMEM; + + for (i = 0; i < st->chip_info->num_channels; ++i) { + channels[i] = st->chip_info->channel_template; + channels[i].channel = i; + channels[i].address = AD5360_CHAN_ADDR(i); + } + + indio_dev->channels = channels; + + return 0; +} + +static int __devinit ad5360_probe(struct spi_device *spi) +{ + enum ad5360_type type = spi_get_device_id(spi)->driver_data; + struct iio_dev *indio_dev; + struct ad5360_state *st; + unsigned int i; + int ret; + + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) { + dev_err(&spi->dev, "Failed to allocate iio device\n"); + return -ENOMEM; + } + + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + + st->chip_info = &ad5360_chip_info_tbl[type]; + st->spi = spi; + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad5360_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->num_channels = st->chip_info->num_channels; + + ret = ad5360_alloc_channels(indio_dev); + if (ret) { + dev_err(&spi->dev, "Failed to allocate channel spec: %d\n", ret); + goto error_free; + } + + for (i = 0; i < st->chip_info->num_vrefs; ++i) + st->vref_reg[i].supply = ad5360_vref_name[i]; + + ret = regulator_bulk_get(&st->spi->dev, st->chip_info->num_vrefs, + st->vref_reg); + if (ret) { + dev_err(&spi->dev, "Failed to request vref regulators: %d\n", ret); + goto error_free_channels; + } + + ret = regulator_bulk_enable(st->chip_info->num_vrefs, st->vref_reg); + if (ret) { + dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", ret); + goto error_free_reg; + } + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); + goto error_disable_reg; + } + + return 0; + +error_disable_reg: + regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg); +error_free_reg: + regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg); +error_free_channels: + kfree(indio_dev->channels); +error_free: + iio_free_device(indio_dev); + + return ret; +} + +static int __devexit ad5360_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad5360_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + kfree(indio_dev->channels); + + regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg); + regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg); + + iio_free_device(indio_dev); + + return 0; +} + +static const struct spi_device_id ad5360_ids[] = { + { "ad5360", ID_AD5360 }, + { "ad5361", ID_AD5361 }, + { "ad5362", ID_AD5362 }, + { "ad5363", ID_AD5363 }, + { "ad5370", ID_AD5370 }, + { "ad5371", ID_AD5371 }, + { "ad5372", ID_AD5372 }, + { "ad5373", ID_AD5373 }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad5360_ids); + +static struct spi_driver ad5360_driver = { + .driver = { + .name = "ad5360", + .owner = THIS_MODULE, + }, + .probe = ad5360_probe, + .remove = __devexit_p(ad5360_remove), + .id_table = ad5360_ids, +}; + +static __init int ad5360_spi_init(void) +{ + return spi_register_driver(&ad5360_driver); +} +module_init(ad5360_spi_init); + +static __exit void ad5360_spi_exit(void) +{ + spi_unregister_driver(&ad5360_driver); +} +module_exit(ad5360_spi_exit); + +MODULE_AUTHOR("Lars-Peter Clausen "); +MODULE_DESCRIPTION("Analog Devices AD5360/61/62/63/70/71/72/73 DAC"); +MODULE_LICENSE("GPL v2"); From a5e4b81e274d7b455531a5e33ce1523caaf31a84 Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Thu, 20 Oct 2011 08:15:22 -0400 Subject: [PATCH 1506/1519] Staging: bcm: Fix coding style issues in InterfaceDld.c This patch fixes multiple coding style issues in file, InterfaceDld.c, found by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceDld.c | 374 +++++++++++++---------------- 1 file changed, 161 insertions(+), 213 deletions(-) diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index bf6cc6a414b..ba83dde1efb 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -2,12 +2,12 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) { - /*unsigned int reg = 0;*/ + /* unsigned int reg = 0; */ mm_segment_t oldfs = {0}; - int errno = 0, len = 0; /*,is_config_file = 0*/ + int errno = 0, len = 0; /* ,is_config_file = 0 */ loff_t pos = 0; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; - /*PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;*/ + /* PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; */ char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); if (!buff) @@ -17,7 +17,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) oldfs = get_fs(); set_fs(get_ds()); len = vfs_read(flp, (void __force __user *)buff, - MAX_TRANSFER_CTRL_BYTE_USB, &pos); + MAX_TRANSFER_CTRL_BYTE_USB, &pos); set_fs(oldfs); if (len <= 0) { if (len < 0) { @@ -35,8 +35,9 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) break; } /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, - DBG_LVL_ALL, buff, - MAX_TRANSFER_CTRL_BYTE_USB);*/ + * DBG_LVL_ALL, buff, + * MAX_TRANSFER_CTRL_BYTE_USB); + */ errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len); if (errno) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, @@ -51,153 +52,132 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) return errno; } -int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, - unsigned int on_chip_loc) +int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_chip_loc) { char *buff, *buff_readback; unsigned int reg = 0; - mm_segment_t oldfs={0}; - int errno=0, len=0, is_config_file = 0; - loff_t pos=0; - static int fw_down = 0; - INT Status = STATUS_SUCCESS; + mm_segment_t oldfs = {0}; + int errno = 0, len = 0, is_config_file = 0; + loff_t pos = 0; + static int fw_down = 0; + INT Status = STATUS_SUCCESS; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; - buff=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); - buff_readback=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); - if(!buff || !buff_readback) - { - kfree(buff); - kfree(buff_readback); + buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); + buff_readback = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); + if (!buff || !buff_readback) { + kfree(buff); + kfree(buff_readback); - return -ENOMEM; - } + return -ENOMEM; + } - is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR)? 1:0; + is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0; memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB); memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB); - while(1) - { - oldfs=get_fs(); set_fs(get_ds()); - len=vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); - set_fs(oldfs); - fw_down++; - if(len<=0) - { - if(len<0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); - errno=len; - } - else - { - errno = 0; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); - } - break; - } + while (1) { + oldfs = get_fs(); + set_fs(get_ds()); + len = vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); + set_fs(oldfs); + fw_down++; + if (len <= 0) { + if (len < 0) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); + errno = len; + } else { + errno = 0; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); + } + break; + } Status = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len); - if(Status) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg); + if (Status) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg); goto exit; } reg++; - if((len-sizeof(unsigned int))<4) - { - if(memcmp(buff_readback, buff, len)) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL,"Length is: %d",len); + if ((len-sizeof(unsigned int)) < 4) { + if (memcmp(buff_readback, buff, len)) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Length is: %d", len); Status = -EIO; goto exit; - } - } - else - { - len-=4; - while(len) - { - if(*(unsigned int*)&buff_readback[len] != *(unsigned int *)&buff[len]) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); + } + } else { + len -= 4; + + while (len) { + if (*(unsigned int *)&buff_readback[len] != *(unsigned int *)&buff[len]) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); Status = -EIO; goto exit; - } - len-=4; - } - } - on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; - }/* End of while(1)*/ + } + len -= 4; + } + } + on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB; + } /* End of while(1) */ + exit: - kfree(buff); - kfree(buff_readback); + kfree(buff); + kfree(buff_readback); return Status; } -static int bcm_download_config_file(PMINI_ADAPTER Adapter, - FIRMWARE_INFO *psFwInfo) +static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) { int retval = STATUS_SUCCESS; B_UINT32 value = 0; - if(Adapter->pstargetparams == NULL) - { - if((Adapter->pstargetparams = - kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) - { - return -ENOMEM; - } - } - if(psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) - { - return -EIO; + if (Adapter->pstargetparams == NULL) { + if ((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) { + return -ENOMEM; + } } - retval = copy_from_user(Adapter->pstargetparams, - psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); - if(retval) - { + + if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) + return -EIO; + + retval = copy_from_user(Adapter->pstargetparams, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); + if (retval) { kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; return -EFAULT; } + /* Parse the structure and then Download the Firmware */ beceem_parse_target_struct(Adapter); - //Initializing the NVM. + /* Initializing the NVM. */ BcmInitNVM(Adapter); + retval = InitLedSettings(Adapter); - retval = InitLedSettings (Adapter); - - if(retval) - { - BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n"); + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n"); return retval; } - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->LEDInfo.bLedInitDone = FALSE; Adapter->DriverState = DRIVER_INIT; wake_up(&Adapter->LEDInfo.notify_led_event); } - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->DriverState = FW_DOWNLOAD; wake_up(&Adapter->LEDInfo.notify_led_event); } /* Initialize the DDR Controller */ retval = ddr_init(Adapter); - if(retval) - { - BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n"); + if (retval) { + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n"); return retval; } @@ -205,197 +185,165 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - if(Adapter->eNVMType == NVM_FLASH) - { + if (Adapter->eNVMType == NVM_FLASH) { retval = PropagateCalParamsFromFlashToMemory(Adapter); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"propagaion of cal param failed with status :%d", retval); + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "propagaion of cal param failed with status :%d", retval); return retval; } } + retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(STARGETPARAMS), CONFIG_BEGIN_ADDR); - retval =buffDnldVerify(Adapter,(PUCHAR)Adapter->pstargetparams,sizeof(STARGETPARAMS),CONFIG_BEGIN_ADDR); - - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly"); - } + if (retval) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly"); else Adapter->bCfgDownloaded = TRUE; - return retval; } -static int bcm_compare_buff_contents(unsigned char *readbackbuff, - unsigned char *buff,unsigned int len) + +static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff, unsigned int len) { int retval = STATUS_SUCCESS; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); - if((len-sizeof(unsigned int))<4) - { - if(memcmp(readbackbuff , buff, len)) - { - retval=-EINVAL; - } - } - else - { - len-=4; - while(len) - { - if(*(unsigned int*)&readbackbuff[len] != - *(unsigned int *)&buff[len]) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); - retval=-EINVAL; + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); + if ((len-sizeof(unsigned int)) < 4) { + if (memcmp(readbackbuff , buff, len)) + retval = -EINVAL; + } else { + len -= 4; + + while (len) { + if (*(unsigned int *)&readbackbuff[len] != *(unsigned int *)&buff[len]) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); + retval = -EINVAL; break; } - len-=4; + len -= 4; } } return retval; } + int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) { int retval = STATUS_SUCCESS; PUCHAR buff = NULL; - /* Config File is needed for the Driver to download the Config file and - Firmware. Check for the Config file to be first to be sent from the - Application - */ - atomic_set (&Adapter->uiMBupdate, FALSE); - if(!Adapter->bCfgDownloaded && - psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) - { - /*Can't Download Firmware.*/ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Download the config File first\n"); + /* Config File is needed for the Driver to download the Config file and + * Firmware. Check for the Config file to be first to be sent from the + * Application + */ + atomic_set(&Adapter->uiMBupdate, FALSE); + if (!Adapter->bCfgDownloaded && psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) { + /* Can't Download Firmware. */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Download the config File first\n"); return -EINVAL; } /* If Config File, Finish the DDR Settings and then Download CFG File */ - if(psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) - { - retval = bcm_download_config_file (Adapter, psFwInfo); - } - else - { - - buff = kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL); - if(buff==NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Failed in allocation memory"); + if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) { + retval = bcm_download_config_file(Adapter, psFwInfo); + } else { + buff = kzalloc(psFwInfo->u32FirmwareLength, GFP_KERNEL); + if (buff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed in allocation memory"); return -ENOMEM; } - retval = copy_from_user(buff,psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); - if(retval != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed"); + + retval = copy_from_user(buff, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); + if (retval != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed"); retval = -EFAULT; - goto error ; + goto error; } retval = buffDnldVerify(Adapter, buff, psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); - if(retval != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"f/w download failed status :%d", retval); + + if (retval != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "f/w download failed status :%d", retval); goto error; } } + error: kfree(buff); return retval; } -static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, - ULONG u32StartingAddress) +static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress) { - - unsigned int len = 0; + unsigned int len = 0; int retval = STATUS_SUCCESS; len = u32FirmwareLength; - while(u32FirmwareLength) - { - len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); - retval = wrm (Adapter, u32StartingAddress, mappedbuffer, len); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval); + while (u32FirmwareLength) { + len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); + retval = wrm(Adapter, u32StartingAddress, mappedbuffer, len); + + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval); break; } - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer +=len; + u32StartingAddress += len; + u32FirmwareLength -= len; + mappedbuffer += len; } return retval; - } -static INT buffRdbkVerify(PMINI_ADAPTER Adapter, - PUCHAR mappedbuffer, UINT u32FirmwareLength, - ULONG u32StartingAddress) +static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress) { UINT len = u32FirmwareLength; INT retval = STATUS_SUCCESS; - PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL); + PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - if(NULL == readbackbuff) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED"); + if (NULL == readbackbuff) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED"); return -ENOMEM; } - while (u32FirmwareLength && !retval) - { - len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); + while (u32FirmwareLength && !retval) { + len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); + retval = rdm(Adapter, u32StartingAddress, readbackbuff, len); - retval = rdm (Adapter, u32StartingAddress, readbackbuff, len); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d" ,retval); + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d", retval); break; } - if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents (readbackbuff, mappedbuffer, len))) - { + if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents(readbackbuff, mappedbuffer, len))) break; - } - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer +=len; - }/* end of while (u32FirmwareLength && !retval) */ + + u32StartingAddress += len; + u32FirmwareLength -= len; + mappedbuffer += len; + + } /* end of while (u32FirmwareLength && !retval) */ kfree(readbackbuff); return retval; } -INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, - unsigned long u32StartingAddress) +INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress) { INT status = STATUS_SUCCESS; - status = buffDnld(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); - if(status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer download failed"); + status = buffDnld(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress); + if (status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer download failed"); goto error; } - status= buffRdbkVerify(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); - if(status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer readback verifier failed"); + status = buffRdbkVerify(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress); + if (status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer readback verifier failed"); goto error; } error: return status; } - - From a86581829fdd646655116f89cb8af2f22b5fbf9e Mon Sep 17 00:00:00 2001 From: Kevin McKinney Date: Thu, 20 Oct 2011 08:15:23 -0400 Subject: [PATCH 1507/1519] Staging: bcm: Fix three initialization errors in InterfaceDld.c This patch fixes three initialization errors. One is an incorrect initialization of a static variable. The other two are incorrect initializations in an if statement. These errors were found by checkpatch.pl. Signed-off-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceDld.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index ba83dde1efb..bcd86bbef2f 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -59,7 +59,7 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_c mm_segment_t oldfs = {0}; int errno = 0, len = 0, is_config_file = 0; loff_t pos = 0; - static int fw_down = 0; + static int fw_down; INT Status = STATUS_SUCCESS; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; @@ -136,9 +136,9 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwIn B_UINT32 value = 0; if (Adapter->pstargetparams == NULL) { - if ((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) { + Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + if (Adapter->pstargetparams == NULL) return -ENOMEM; - } } if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) @@ -317,7 +317,8 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32Fi break; } - if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents(readbackbuff, mappedbuffer, len))) + retval = bcm_compare_buff_contents(readbackbuff, mappedbuffer, len); + if (STATUS_SUCCESS != retval) break; u32StartingAddress += len; From 16d8de3cc9484ccebab20331c03d1b6ba8636d76 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:43 +0100 Subject: [PATCH 1508/1519] staging: et131x: Remove unused rx_ring.recv_buffer_pool rx_ring.recv_buffer_pool is unused, even in the original driver code. Remove from stuct, and also remove some comments regarding it. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 1efa27c93f5..8c557cfa0c1 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -329,8 +329,6 @@ struct rx_ring { struct rx_status_block *rx_status_block; dma_addr_t rx_status_bus; - struct list_head recv_buff_pool; - /* RECV */ struct list_head recv_list; u32 num_ready_recv; @@ -2307,10 +2305,6 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) rx_ring->rx_status_block = NULL; } - /* Free receive buffer pool */ - - /* Free receive packet pool */ - /* Destroy the lookaside (RFD) pool */ if (adapter->flags & fMP_ADAPTER_RECV_LOOKASIDE) { kmem_cache_destroy(rx_ring->recv_lookaside); From 5ad5be581ed19becd184731fd0e9711abc5650c6 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:44 +0100 Subject: [PATCH 1509/1519] staging: et131x: Remove redundant et131x_reset_recv() call This call doesn't do anything useful - only warns on the receive list being empty, so removed it. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 8c557cfa0c1..f521e3319aa 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -605,7 +605,6 @@ int32_t et131x_mii_write(struct et131x_adapter *adapter, void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); void et131x_rx_dma_disable(struct et131x_adapter *adapter); void et131x_rx_dma_enable(struct et131x_adapter *adapter); -void et131x_reset_recv(struct et131x_adapter *adapter); void et131x_init_send(struct et131x_adapter *adapter); void et131x_tx_dma_enable(struct et131x_adapter *adapter); @@ -1839,9 +1838,6 @@ void et1310_disable_phy_coma(struct et131x_adapter *adapter) /* Re-initialize the send structures */ et131x_init_send(adapter); - /* Reset the RFD list and re-start RU */ - et131x_reset_recv(adapter); - /* Bring the device back to the state it was during init prior to * autonegotiation being complete. This way, when we get the auto-neg * complete interrupt, we can complete init by calling ConfigMacREGS2. @@ -2881,17 +2877,6 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) return rfd; } -/** - * et131x_reset_recv - Reset the receive list - * @adapter: pointer to our adapter - * - * Assumption, Rcv spinlock has been acquired. - */ -void et131x_reset_recv(struct et131x_adapter *adapter) -{ - WARN_ON(list_empty(&adapter->rx_ring.recv_list)); -} - /** * et131x_handle_recv_interrupt - Interrupt handler for receive processing * @adapter: pointer to our adapter @@ -4251,9 +4236,6 @@ static void et131x_adjust_link(struct net_device *netdev) /* Re-initialize the send structures */ et131x_init_send(adapter); - /* Reset the RFD list and re-start RU */ - et131x_reset_recv(adapter); - /* * Bring the device back to the state it was during * init prior to autonegotiation being complete. This From ac8f4837f2240c692b968cdeaa3275ecc2ed173f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:45 +0100 Subject: [PATCH 1510/1519] staging: et131x: Remove call to find pci pm capability pci_find_capability is called, but not used and is now redundant as power management is handled elsewhere. Removed. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index f521e3319aa..9383c5c0c4f 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -4356,7 +4356,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, const struct pci_device_id *ent) { int result; - int pm_cap; struct net_device *netdev; struct et131x_adapter *adapter; int ii; @@ -4380,19 +4379,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, pci_set_master(pdev); - /* Query PCI for Power Mgmt Capabilities - * - * NOTE: Now reading PowerMgmt in another location; is this still - * needed? - */ - pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); - if (!pm_cap) { - dev_err(&pdev->dev, - "Cannot find Power Management capabilities\n"); - result = -EIO; - goto err_release_res; - } - /* Check the DMA addressing support of this device */ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); From c018a5f11df2a0464455ba4f1f6eae88e0ef8666 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:46 +0100 Subject: [PATCH 1511/1519] staging: et131x: Remove unused rx_ring.recv_packet_pool tx_ring.recv_packet_pool is unused, even in the original driver code. Removed. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 9383c5c0c4f..cf6f7a283ae 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -337,8 +337,6 @@ struct rx_ring { bool unfinished_receives; - struct list_head recv_packet_pool; - /* lookaside lists */ struct kmem_cache *recv_lookaside; }; From 44012dfe4e6113c5c51393e2cd6cd49d8108da96 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:47 +0100 Subject: [PATCH 1512/1519] staging: et131x: Remove some forward declarations Moved functions in et131x.c file to remove the following forward declarations: et131x_align_allocated_memory et131x_disable_interrupts et131x_enable_interrupts et131x_error_timer_handler Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 126 +++++++++++++++----------------- 1 file changed, 60 insertions(+), 66 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index cf6f7a283ae..8048d676614 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,12 +576,6 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -void et131x_error_timer_handler(unsigned long data); -void et131x_enable_interrupts(struct et131x_adapter *adapter); -void et131x_disable_interrupts(struct et131x_adapter *adapter); -void et131x_align_allocated_memory(struct et131x_adapter *adapter, - u64 *phys_addr, - u64 *offset, u64 mask); void et131x_adapter_setup(struct et131x_adapter *adapter); void et131x_soft_reset(struct et131x_adapter *adapter); void et131x_isr_handler(struct work_struct *work); @@ -1871,6 +1865,33 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) return tmp_free_buff_ring; } +/** + * et131x_align_allocated_memory - Align allocated memory on a given boundary + * @adapter: pointer to our adapter structure + * @phys_addr: pointer to Physical address + * @offset: pointer to the offset variable + * @mask: correct mask + */ +void et131x_align_allocated_memory(struct et131x_adapter *adapter, + uint64_t *phys_addr, + uint64_t *offset, uint64_t mask) +{ + uint64_t new_addr; + + *offset = 0; + + new_addr = *phys_addr & ~mask; + + if (new_addr != *phys_addr) { + /* Move to next aligned block */ + new_addr += mask + 1; + /* Return offset for adjusting virt addr */ + *offset = new_addr - *phys_addr; + /* Return new physical address */ + *phys_addr = new_addr; + } +} + /** * et131x_rx_dma_memory_alloc * @adapter: pointer to our private adapter structure @@ -3937,6 +3958,27 @@ static int et131x_pci_init(struct et131x_adapter *adapter, return 0; } +/** + * et131x_enable_interrupts - enable interrupt + * @adapter: et131x device + * + * Enable the appropriate interrupts on the ET131x according to our + * configuration + */ +void et131x_enable_interrupts(struct et131x_adapter *adapter) +{ + u32 mask; + + /* Enable all global interrupts */ + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) + mask = INT_MASK_ENABLE; + else + mask = INT_MASK_ENABLE_NO_FLOW; + + writel(mask, &adapter->regs->global.int_mask); +} + /** * et131x_error_timer_handler * @data: timer-specific variable; here a pointer to our adapter structure @@ -4070,33 +4112,6 @@ void et131x_soft_reset(struct et131x_adapter *adapter) writel(0x00000000, &adapter->regs->mac.cfg1); } -/** - * et131x_align_allocated_memory - Align allocated memory on a given boundary - * @adapter: pointer to our adapter structure - * @phys_addr: pointer to Physical address - * @offset: pointer to the offset variable - * @mask: correct mask - */ -void et131x_align_allocated_memory(struct et131x_adapter *adapter, - uint64_t *phys_addr, - uint64_t *offset, uint64_t mask) -{ - uint64_t new_addr; - - *offset = 0; - - new_addr = *phys_addr & ~mask; - - if (new_addr != *phys_addr) { - /* Move to next aligned block */ - new_addr += mask + 1; - /* Return offset for adjusting virt addr */ - *offset = new_addr - *phys_addr; - /* Return new physical address */ - *phys_addr = new_addr; - } -} - /** * et131x_adapter_memory_alloc * @adapter: pointer to our private adapter structure @@ -4338,6 +4353,18 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, return adapter; } +/** + * et131x_disable_interrupts - interrupt disable + * @adapter: et131x device + * + * Block all interrupts from the et131x device at the device itself + */ +void et131x_disable_interrupts(struct et131x_adapter *adapter) +{ + /* Disable all global interrupts */ + writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); +} + /** * et131x_pci_setup - Perform device initialization * @pdev: a pointer to the device's pci_dev structure @@ -4632,39 +4659,6 @@ module_exit(et131x_cleanup_module); /* ISR functions */ -/** - * et131x_enable_interrupts - enable interrupt - * @adapter: et131x device - * - * Enable the appropriate interrupts on the ET131x according to our - * configuration - */ -void et131x_enable_interrupts(struct et131x_adapter *adapter) -{ - u32 mask; - - /* Enable all global interrupts */ - if (adapter->flowcontrol == FLOW_TXONLY || - adapter->flowcontrol == FLOW_BOTH) - mask = INT_MASK_ENABLE; - else - mask = INT_MASK_ENABLE_NO_FLOW; - - writel(mask, &adapter->regs->global.int_mask); -} - -/** - * et131x_disable_interrupts - interrupt disable - * @adapter: et131x device - * - * Block all interrupts from the et131x device at the device itself - */ -void et131x_disable_interrupts(struct et131x_adapter *adapter) -{ - /* Disable all global interrupts */ - writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); -} - /** * et131x_isr - The Interrupt Service Routine for the driver. * @irq: the IRQ on which the interrupt was received. From 36f2771a70c44b3fbc1be34d5a82e8472437c7ca Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:48 +0100 Subject: [PATCH 1513/1519] staging: et131x: Remove forward declaration of et131x_adapter_setup Also associated function movements within et131x.c file Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 445 ++++++++++++++++---------------- 1 file changed, 222 insertions(+), 223 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 8048d676614..29476350fca 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,7 +576,6 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -void et131x_adapter_setup(struct et131x_adapter *adapter); void et131x_soft_reset(struct et131x_adapter *adapter); void et131x_isr_handler(struct work_struct *work); void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); @@ -1731,6 +1730,53 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) } } +/** + * et131x_configure_global_regs - configure JAGCore global regs + * @adapter: pointer to our adapter structure + * + * Used to configure the global registers on the JAGCore + */ +void et131x_configure_global_regs(struct et131x_adapter *adapter) +{ + struct global_regs __iomem *regs = &adapter->regs->global; + + writel(0, ®s->rxq_start_addr); + writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); + + if (adapter->registry_jumbo_packet < 2048) { + /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word + * block of RAM that the driver can split between Tx + * and Rx as it desires. Our default is to split it + * 50/50: + */ + writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); + writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); + } else if (adapter->registry_jumbo_packet < 8192) { + /* For jumbo packets > 2k but < 8k, split 50-50. */ + writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); + writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); + } else { + /* 9216 is the only packet size greater than 8k that + * is available. The Tx buffer has to be big enough + * for one whole packet on the Tx side. We'll make + * the Tx 9408, and give the rest to Rx + */ + writel(0x01b3, ®s->rxq_end_addr); + writel(0x01b4, ®s->txq_start_addr); + } + + /* Initialize the loopback register. Disable all loopbacks. */ + writel(0, ®s->loopback); + + /* MSI Register */ + writel(0, ®s->msi_config); + + /* By default, disable the watchdog timer. It will be enabled when + * a packet is queued. + */ + writel(0, ®s->watchdog_timer); +} + /* PM functions */ /** @@ -1748,6 +1794,181 @@ int et1310_in_phy_coma(struct et131x_adapter *adapter) return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; } +/** + * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence + * @adapter: pointer to our adapter structure + */ +void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) +{ + struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; + struct rx_ring *rx_local = &adapter->rx_ring; + struct fbr_desc *fbr_entry; + u32 entry; + u32 psr_num_des; + unsigned long flags; + + /* Halt RXDMA to perform the reconfigure. */ + et131x_rx_dma_disable(adapter); + + /* Load the completion writeback physical address + * + * NOTE : dma_alloc_coherent(), used above to alloc DMA regions, + * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses + * are ever returned, make sure the high part is retrieved here + * before storing the adjusted address. + */ + writel((u32) ((u64)rx_local->rx_status_bus >> 32), + &rx_dma->dma_wb_base_hi); + writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo); + + memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block)); + + /* Set the address and parameters of the packet status ring into the + * 1310's registers + */ + writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32), + &rx_dma->psr_base_hi); + writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo); + writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); + writel(0, &rx_dma->psr_full_offset); + + psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; + writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, + &rx_dma->psr_min_des); + + spin_lock_irqsave(&adapter->rcv_lock, flags); + + /* These local variables track the PSR in the adapter structure */ + rx_local->local_psr_full = 0; + + /* Now's the best time to initialize FBR1 contents */ + fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr; + for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) { + fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; + fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; + fbr_entry->word2 = entry; + fbr_entry++; + } + + /* Set the address and parameters of Free buffer ring 1 (and 0 if + * required) into the 1310's registers + */ + writel((u32) (rx_local->fbr[0]->real_physaddr >> 32), + &rx_dma->fbr1_base_hi); + writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo); + writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); + + /* This variable tracks the free buffer ring 1 full position, so it + * has to match the above. + */ + rx_local->fbr[0]->local_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr1_min_des); + +#ifdef USE_FBR0 + /* Now's the best time to initialize FBR0 contents */ + fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr; + for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) { + fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; + fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; + fbr_entry->word2 = entry; + fbr_entry++; + } + + writel((u32) (rx_local->fbr[1]->real_physaddr >> 32), + &rx_dma->fbr0_base_hi); + writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo); + writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des); + writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); + + /* This variable tracks the free buffer ring 0 full position, so it + * has to match the above. + */ + rx_local->fbr[1]->local_full = ET_DMA10_WRAP; + writel( + ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr0_min_des); +#endif + + /* Program the number of packets we will receive before generating an + * interrupt. + * For version B silicon, this value gets updated once autoneg is + *complete. + */ + writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done); + + /* The "time_done" is not working correctly to coalesce interrupts + * after a given time period, but rather is giving us an interrupt + * regardless of whether we have received packets. + * This value gets updated once autoneg is complete. + */ + writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time); + + spin_unlock_irqrestore(&adapter->rcv_lock, flags); +} + +/** + * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. + * @adapter: pointer to our private adapter structure + * + * Configure the transmit engine with the ring buffers we have created + * and prepare it for use. + */ +void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) +{ + struct txdma_regs __iomem *txdma = &adapter->regs->txdma; + + /* Load the hardware with the start of the transmit descriptor ring. */ + writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32), + &txdma->pr_base_hi); + writel((u32) adapter->tx_ring.tx_desc_ring_pa, + &txdma->pr_base_lo); + + /* Initialise the transmit DMA engine */ + writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des); + + /* Load the completion writeback physical address */ + writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32), + &txdma->dma_wb_base_hi); + writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); + + *adapter->tx_ring.tx_status = 0; + + writel(0, &txdma->service_request); + adapter->tx_ring.send_idx = 0; +} + +/** + * et131x_adapter_setup - Set the adapter up as per cassini+ documentation + * @adapter: pointer to our private adapter structure + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +void et131x_adapter_setup(struct et131x_adapter *adapter) +{ + /* Configure the JAGCore */ + et131x_configure_global_regs(adapter); + + et1310_config_mac_regs1(adapter); + + /* Configure the MMC registers */ + /* All we need to do is initialize the Memory Control Register */ + writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl); + + et1310_config_rxmac_regs(adapter); + et1310_config_txmac_regs(adapter); + + et131x_config_rx_dma_regs(adapter); + et131x_config_tx_dma_regs(adapter); + + et1310_config_macstat_regs(adapter); + + et1310_phy_power_down(adapter, 0); + et131x_xcvr_init(adapter); +} + /** * et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure @@ -2389,121 +2610,6 @@ int et131x_init_recv(struct et131x_adapter *adapter) return status; } -/** - * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence - * @adapter: pointer to our adapter structure - */ -void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) -{ - struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma; - struct rx_ring *rx_local = &adapter->rx_ring; - struct fbr_desc *fbr_entry; - u32 entry; - u32 psr_num_des; - unsigned long flags; - - /* Halt RXDMA to perform the reconfigure. */ - et131x_rx_dma_disable(adapter); - - /* Load the completion writeback physical address - * - * NOTE : dma_alloc_coherent(), used above to alloc DMA regions, - * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses - * are ever returned, make sure the high part is retrieved here - * before storing the adjusted address. - */ - writel((u32) ((u64)rx_local->rx_status_bus >> 32), - &rx_dma->dma_wb_base_hi); - writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo); - - memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block)); - - /* Set the address and parameters of the packet status ring into the - * 1310's registers - */ - writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32), - &rx_dma->psr_base_hi); - writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo); - writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); - writel(0, &rx_dma->psr_full_offset); - - psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; - writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, - &rx_dma->psr_min_des); - - spin_lock_irqsave(&adapter->rcv_lock, flags); - - /* These local variables track the PSR in the adapter structure */ - rx_local->local_psr_full = 0; - - /* Now's the best time to initialize FBR1 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr; - for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) { - fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry]; - fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry]; - fbr_entry->word2 = entry; - fbr_entry++; - } - - /* Set the address and parameters of Free buffer ring 1 (and 0 if - * required) into the 1310's registers - */ - writel((u32) (rx_local->fbr[0]->real_physaddr >> 32), - &rx_dma->fbr1_base_hi); - writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo); - writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset); - - /* This variable tracks the free buffer ring 1 full position, so it - * has to match the above. - */ - rx_local->fbr[0]->local_full = ET_DMA10_WRAP; - writel( - ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr1_min_des); - -#ifdef USE_FBR0 - /* Now's the best time to initialize FBR0 contents */ - fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr; - for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) { - fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry]; - fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry]; - fbr_entry->word2 = entry; - fbr_entry++; - } - - writel((u32) (rx_local->fbr[1]->real_physaddr >> 32), - &rx_dma->fbr0_base_hi); - writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo); - writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des); - writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset); - - /* This variable tracks the free buffer ring 0 full position, so it - * has to match the above. - */ - rx_local->fbr[1]->local_full = ET_DMA10_WRAP; - writel( - ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr0_min_des); -#endif - - /* Program the number of packets we will receive before generating an - * interrupt. - * For version B silicon, this value gets updated once autoneg is - *complete. - */ - writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done); - - /* The "time_done" is not working correctly to coalesce interrupts - * after a given time period, but rather is giving us an interrupt - * regardless of whether we have received packets. - * This value gets updated once autoneg is complete. - */ - writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time); - - spin_unlock_irqrestore(&adapter->rcv_lock, flags); -} - /** * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. * @adapter: pointer to our adapter structure @@ -3045,37 +3151,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) kfree(adapter->tx_ring.tcb_ring); } -/** - * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. - * @adapter: pointer to our private adapter structure - * - * Configure the transmit engine with the ring buffers we have created - * and prepare it for use. - */ -void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) -{ - struct txdma_regs __iomem *txdma = &adapter->regs->txdma; - - /* Load the hardware with the start of the transmit descriptor ring. */ - writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32), - &txdma->pr_base_hi); - writel((u32) adapter->tx_ring.tx_desc_ring_pa, - &txdma->pr_base_lo); - - /* Initialise the transmit DMA engine */ - writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des); - - /* Load the completion writeback physical address */ - writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32), - &txdma->dma_wb_base_hi); - writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo); - - *adapter->tx_ring.tx_status = 0; - - writel(0, &txdma->service_request); - adapter->tx_ring.send_idx = 0; -} - /** * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 * @adapter: pointer to our adapter structure @@ -4021,82 +4096,6 @@ void et131x_error_timer_handler(unsigned long data) TX_ERROR_PERIOD * HZ / 1000); } -/** - * et131x_configure_global_regs - configure JAGCore global regs - * @adapter: pointer to our adapter structure - * - * Used to configure the global registers on the JAGCore - */ -void et131x_configure_global_regs(struct et131x_adapter *adapter) -{ - struct global_regs __iomem *regs = &adapter->regs->global; - - writel(0, ®s->rxq_start_addr); - writel(INTERNAL_MEM_SIZE - 1, ®s->txq_end_addr); - - if (adapter->registry_jumbo_packet < 2048) { - /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word - * block of RAM that the driver can split between Tx - * and Rx as it desires. Our default is to split it - * 50/50: - */ - writel(PARM_RX_MEM_END_DEF, ®s->rxq_end_addr); - writel(PARM_RX_MEM_END_DEF + 1, ®s->txq_start_addr); - } else if (adapter->registry_jumbo_packet < 8192) { - /* For jumbo packets > 2k but < 8k, split 50-50. */ - writel(INTERNAL_MEM_RX_OFFSET, ®s->rxq_end_addr); - writel(INTERNAL_MEM_RX_OFFSET + 1, ®s->txq_start_addr); - } else { - /* 9216 is the only packet size greater than 8k that - * is available. The Tx buffer has to be big enough - * for one whole packet on the Tx side. We'll make - * the Tx 9408, and give the rest to Rx - */ - writel(0x01b3, ®s->rxq_end_addr); - writel(0x01b4, ®s->txq_start_addr); - } - - /* Initialize the loopback register. Disable all loopbacks. */ - writel(0, ®s->loopback); - - /* MSI Register */ - writel(0, ®s->msi_config); - - /* By default, disable the watchdog timer. It will be enabled when - * a packet is queued. - */ - writel(0, ®s->watchdog_timer); -} - -/** - * et131x_adapter_setup - Set the adapter up as per cassini+ documentation - * @adapter: pointer to our private adapter structure - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -void et131x_adapter_setup(struct et131x_adapter *adapter) -{ - /* Configure the JAGCore */ - et131x_configure_global_regs(adapter); - - et1310_config_mac_regs1(adapter); - - /* Configure the MMC registers */ - /* All we need to do is initialize the Memory Control Register */ - writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl); - - et1310_config_rxmac_regs(adapter); - et1310_config_txmac_regs(adapter); - - et131x_config_rx_dma_regs(adapter); - et131x_config_tx_dma_regs(adapter); - - et1310_config_macstat_regs(adapter); - - et1310_phy_power_down(adapter, 0); - et131x_xcvr_init(adapter); -} - /** * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 * @adapter: pointer to our private adapter structure From 5da2b1581a24af6a50d40737c44a9ae13d3097b3 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:49 +0100 Subject: [PATCH 1514/1519] staging: et131x: Remove more forward declarations Moved functions in et131x.c file to remove the following forward declarations: et131x_soft_reset et131x_isr_handler et131x_device_alloc Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 505 ++++++++++++++++---------------- 1 file changed, 251 insertions(+), 254 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 29476350fca..44fff21ae50 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,13 +576,10 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -void et131x_soft_reset(struct et131x_adapter *adapter); -void et131x_isr_handler(struct work_struct *work); void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); void et131x_up(struct net_device *netdev); void et131x_down(struct net_device *netdev); -struct net_device *et131x_device_alloc(void); void et131x_enable_txrx(struct net_device *netdev); void et131x_disable_txrx(struct net_device *netdev); int et1310_in_phy_coma(struct et131x_adapter *adapter); @@ -1969,6 +1966,21 @@ void et131x_adapter_setup(struct et131x_adapter *adapter) et131x_xcvr_init(adapter); } +/** + * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 + * @adapter: pointer to our private adapter structure + */ +void et131x_soft_reset(struct et131x_adapter *adapter) +{ + /* Disable MAC Core */ + writel(0xc00f0000, &adapter->regs->mac.cfg1); + + /* Set everything to a reset value */ + writel(0x7F, &adapter->regs->global.sw_reset); + writel(0x000f0000, &adapter->regs->mac.cfg1); + writel(0x00000000, &adapter->regs->mac.cfg1); +} + /** * et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure @@ -4096,21 +4108,6 @@ void et131x_error_timer_handler(unsigned long data) TX_ERROR_PERIOD * HZ / 1000); } -/** - * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 - * @adapter: pointer to our private adapter structure - */ -void et131x_soft_reset(struct et131x_adapter *adapter) -{ - /* Disable MAC Core */ - writel(0xc00f0000, &adapter->regs->mac.cfg1); - - /* Set everything to a reset value */ - writel(0x7F, &adapter->regs->global.sw_reset); - writel(0x000f0000, &adapter->regs->mac.cfg1); - writel(0x00000000, &adapter->regs->mac.cfg1); -} - /** * et131x_adapter_memory_alloc * @adapter: pointer to our private adapter structure @@ -4364,200 +4361,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter) writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); } -/** - * et131x_pci_setup - Perform device initialization - * @pdev: a pointer to the device's pci_dev structure - * @ent: this device's entry in the pci_device_id table - * - * Returns 0 on success, errno on failure (as defined in errno.h) - * - * Registered in the pci_driver structure, this function is called when the - * PCI subsystem finds a new PCI device which matches the information - * contained in the pci_device_id table. This routine is the equivalent to - * a device insertion routine. - */ -static int __devinit et131x_pci_setup(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - int result; - struct net_device *netdev; - struct et131x_adapter *adapter; - int ii; - - result = pci_enable_device(pdev); - if (result) { - dev_err(&pdev->dev, "pci_enable_device() failed\n"); - goto err_out; - } - - /* Perform some basic PCI checks */ - if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { - dev_err(&pdev->dev, "Can't find PCI device's base address\n"); - goto err_disable; - } - - if (pci_request_regions(pdev, DRIVER_NAME)) { - dev_err(&pdev->dev, "Can't get PCI resources\n"); - goto err_disable; - } - - pci_set_master(pdev); - - /* Check the DMA addressing support of this device */ - if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { - result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); - if (result) { - dev_err(&pdev->dev, - "Unable to obtain 64 bit DMA for consistent allocations\n"); - goto err_release_res; - } - } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { - result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (result) { - dev_err(&pdev->dev, - "Unable to obtain 32 bit DMA for consistent allocations\n"); - goto err_release_res; - } - } else { - dev_err(&pdev->dev, "No usable DMA addressing method\n"); - result = -EIO; - goto err_release_res; - } - - /* Allocate netdev and private adapter structs */ - netdev = et131x_device_alloc(); - if (!netdev) { - dev_err(&pdev->dev, "Couldn't alloc netdev struct\n"); - result = -ENOMEM; - goto err_release_res; - } - - SET_NETDEV_DEV(netdev, &pdev->dev); - et131x_set_ethtool_ops(netdev); - - adapter = et131x_adapter_init(netdev, pdev); - - /* Initialise the PCI setup for the device */ - et131x_pci_init(adapter, pdev); - - /* Map the bus-relative registers to system virtual memory */ - adapter->regs = pci_ioremap_bar(pdev, 0); - if (!adapter->regs) { - dev_err(&pdev->dev, "Cannot map device registers\n"); - result = -ENOMEM; - goto err_free_dev; - } - - /* If Phy COMA mode was enabled when we went down, disable it here. */ - writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr); - - /* Issue a global reset to the et1310 */ - et131x_soft_reset(adapter); - - /* Disable all interrupts (paranoid) */ - et131x_disable_interrupts(adapter); - - /* Allocate DMA memory */ - result = et131x_adapter_memory_alloc(adapter); - if (result) { - dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n"); - goto err_iounmap; - } - - /* Init send data structures */ - et131x_init_send(adapter); - - /* Set up the task structure for the ISR's deferred handler */ - INIT_WORK(&adapter->task, et131x_isr_handler); - - /* Copy address into the net_device struct */ - memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); - - /* Init variable for counting how long we do not have link status */ - adapter->boot_coma = 0; - et1310_disable_phy_coma(adapter); - - /* Setup the mii_bus struct */ - adapter->mii_bus = mdiobus_alloc(); - if (!adapter->mii_bus) { - dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); - goto err_mem_free; - } - - adapter->mii_bus->name = "et131x_eth_mii"; - snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", - (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); - adapter->mii_bus->priv = netdev; - adapter->mii_bus->read = et131x_mdio_read; - adapter->mii_bus->write = et131x_mdio_write; - adapter->mii_bus->reset = et131x_mdio_reset; - adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); - if (!adapter->mii_bus->irq) { - dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); - goto err_mdio_free; - } - - for (ii = 0; ii < PHY_MAX_ADDR; ii++) - adapter->mii_bus->irq[ii] = PHY_POLL; - - if (mdiobus_register(adapter->mii_bus)) { - dev_err(&pdev->dev, "failed to register MII bus\n"); - mdiobus_free(adapter->mii_bus); - goto err_mdio_free_irq; - } - - if (et131x_mii_probe(netdev)) { - dev_err(&pdev->dev, "failed to probe MII bus\n"); - goto err_mdio_unregister; - } - - /* Setup et1310 as per the documentation */ - et131x_adapter_setup(adapter); - - /* We can enable interrupts now - * - * NOTE - Because registration of interrupt handler is done in the - * device's open(), defer enabling device interrupts to that - * point - */ - - /* Register the net_device struct with the Linux network layer */ - result = register_netdev(netdev); - if (result != 0) { - dev_err(&pdev->dev, "register_netdev() failed\n"); - goto err_mdio_unregister; - } - - /* Register the net_device struct with the PCI subsystem. Save a copy - * of the PCI config space for this device now that the device has - * been initialized, just in case it needs to be quickly restored. - */ - pci_set_drvdata(pdev, netdev); - pci_save_state(adapter->pdev); - - return result; - -err_mdio_unregister: - mdiobus_unregister(adapter->mii_bus); -err_mdio_free_irq: - kfree(adapter->mii_bus->irq); -err_mdio_free: - mdiobus_free(adapter->mii_bus); -err_mem_free: - et131x_adapter_memory_free(adapter); -err_iounmap: - iounmap(adapter->regs); -err_free_dev: - pci_dev_put(pdev); - free_netdev(netdev); -err_release_res: - pci_release_regions(pdev); -err_disable: - pci_disable_device(pdev); -err_out: - return result; -} - /** * et131x_pci_remove * @pdev: a pointer to the device's pci_dev structure @@ -4614,48 +4417,6 @@ static int et131x_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); -#define ET131X_PM_OPS (&et131x_pm_ops) -#else -#define ET131X_PM_OPS NULL -#endif - -static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = { - { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL}, - { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL}, - {0,} -}; -MODULE_DEVICE_TABLE(pci, et131x_pci_table); - -static struct pci_driver et131x_driver = { - .name = DRIVER_NAME, - .id_table = et131x_pci_table, - .probe = et131x_pci_setup, - .remove = __devexit_p(et131x_pci_remove), - .driver.pm = ET131X_PM_OPS, -}; - -/** - * et131x_init_module - The "main" entry point called on driver initialization - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int __init et131x_init_module(void) -{ - return pci_register_driver(&et131x_driver); -} - -/** - * et131x_cleanup_module - The entry point called on driver cleanup - */ -static void __exit et131x_cleanup_module(void) -{ - pci_unregister_driver(&et131x_driver); -} - -module_init(et131x_init_module); -module_exit(et131x_cleanup_module); - /* ISR functions */ /** @@ -5528,3 +5289,239 @@ struct net_device *et131x_device_alloc(void) return netdev; } +/** + * et131x_pci_setup - Perform device initialization + * @pdev: a pointer to the device's pci_dev structure + * @ent: this device's entry in the pci_device_id table + * + * Returns 0 on success, errno on failure (as defined in errno.h) + * + * Registered in the pci_driver structure, this function is called when the + * PCI subsystem finds a new PCI device which matches the information + * contained in the pci_device_id table. This routine is the equivalent to + * a device insertion routine. + */ +static int __devinit et131x_pci_setup(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int result; + struct net_device *netdev; + struct et131x_adapter *adapter; + int ii; + + result = pci_enable_device(pdev); + if (result) { + dev_err(&pdev->dev, "pci_enable_device() failed\n"); + goto err_out; + } + + /* Perform some basic PCI checks */ + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { + dev_err(&pdev->dev, "Can't find PCI device's base address\n"); + goto err_disable; + } + + if (pci_request_regions(pdev, DRIVER_NAME)) { + dev_err(&pdev->dev, "Can't get PCI resources\n"); + goto err_disable; + } + + pci_set_master(pdev); + + /* Check the DMA addressing support of this device */ + if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { + result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); + if (result) { + dev_err(&pdev->dev, + "Unable to obtain 64 bit DMA for consistent allocations\n"); + goto err_release_res; + } + } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { + result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); + if (result) { + dev_err(&pdev->dev, + "Unable to obtain 32 bit DMA for consistent allocations\n"); + goto err_release_res; + } + } else { + dev_err(&pdev->dev, "No usable DMA addressing method\n"); + result = -EIO; + goto err_release_res; + } + + /* Allocate netdev and private adapter structs */ + netdev = et131x_device_alloc(); + if (!netdev) { + dev_err(&pdev->dev, "Couldn't alloc netdev struct\n"); + result = -ENOMEM; + goto err_release_res; + } + + SET_NETDEV_DEV(netdev, &pdev->dev); + et131x_set_ethtool_ops(netdev); + + adapter = et131x_adapter_init(netdev, pdev); + + /* Initialise the PCI setup for the device */ + et131x_pci_init(adapter, pdev); + + /* Map the bus-relative registers to system virtual memory */ + adapter->regs = pci_ioremap_bar(pdev, 0); + if (!adapter->regs) { + dev_err(&pdev->dev, "Cannot map device registers\n"); + result = -ENOMEM; + goto err_free_dev; + } + + /* If Phy COMA mode was enabled when we went down, disable it here. */ + writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr); + + /* Issue a global reset to the et1310 */ + et131x_soft_reset(adapter); + + /* Disable all interrupts (paranoid) */ + et131x_disable_interrupts(adapter); + + /* Allocate DMA memory */ + result = et131x_adapter_memory_alloc(adapter); + if (result) { + dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n"); + goto err_iounmap; + } + + /* Init send data structures */ + et131x_init_send(adapter); + + /* Set up the task structure for the ISR's deferred handler */ + INIT_WORK(&adapter->task, et131x_isr_handler); + + /* Copy address into the net_device struct */ + memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); + + /* Init variable for counting how long we do not have link status */ + adapter->boot_coma = 0; + et1310_disable_phy_coma(adapter); + + /* Setup the mii_bus struct */ + adapter->mii_bus = mdiobus_alloc(); + if (!adapter->mii_bus) { + dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); + goto err_mem_free; + } + + adapter->mii_bus->name = "et131x_eth_mii"; + snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", + (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); + adapter->mii_bus->priv = netdev; + adapter->mii_bus->read = et131x_mdio_read; + adapter->mii_bus->write = et131x_mdio_write; + adapter->mii_bus->reset = et131x_mdio_reset; + adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); + if (!adapter->mii_bus->irq) { + dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); + goto err_mdio_free; + } + + for (ii = 0; ii < PHY_MAX_ADDR; ii++) + adapter->mii_bus->irq[ii] = PHY_POLL; + + if (mdiobus_register(adapter->mii_bus)) { + dev_err(&pdev->dev, "failed to register MII bus\n"); + mdiobus_free(adapter->mii_bus); + goto err_mdio_free_irq; + } + + if (et131x_mii_probe(netdev)) { + dev_err(&pdev->dev, "failed to probe MII bus\n"); + goto err_mdio_unregister; + } + + /* Setup et1310 as per the documentation */ + et131x_adapter_setup(adapter); + + /* We can enable interrupts now + * + * NOTE - Because registration of interrupt handler is done in the + * device's open(), defer enabling device interrupts to that + * point + */ + + /* Register the net_device struct with the Linux network layer */ + result = register_netdev(netdev); + if (result != 0) { + dev_err(&pdev->dev, "register_netdev() failed\n"); + goto err_mdio_unregister; + } + + /* Register the net_device struct with the PCI subsystem. Save a copy + * of the PCI config space for this device now that the device has + * been initialized, just in case it needs to be quickly restored. + */ + pci_set_drvdata(pdev, netdev); + pci_save_state(adapter->pdev); + + return result; + +err_mdio_unregister: + mdiobus_unregister(adapter->mii_bus); +err_mdio_free_irq: + kfree(adapter->mii_bus->irq); +err_mdio_free: + mdiobus_free(adapter->mii_bus); +err_mem_free: + et131x_adapter_memory_free(adapter); +err_iounmap: + iounmap(adapter->regs); +err_free_dev: + pci_dev_put(pdev); + free_netdev(netdev); +err_release_res: + pci_release_regions(pdev); +err_disable: + pci_disable_device(pdev); +err_out: + return result; +} + +static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); +#define ET131X_PM_OPS (&et131x_pm_ops) +#else +#define ET131X_PM_OPS NULL +#endif + +static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = { + { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL}, + { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL}, + {0,} +}; +MODULE_DEVICE_TABLE(pci, et131x_pci_table); + +static struct pci_driver et131x_driver = { + .name = DRIVER_NAME, + .id_table = et131x_pci_table, + .probe = et131x_pci_setup, + .remove = __devexit_p(et131x_pci_remove), + .driver.pm = ET131X_PM_OPS, +}; + +/** + * et131x_init_module - The "main" entry point called on driver initialization + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +static int __init et131x_init_module(void) +{ + return pci_register_driver(&et131x_driver); +} + +/** + * et131x_cleanup_module - The entry point called on driver cleanup + */ +static void __exit et131x_cleanup_module(void) +{ + pci_unregister_driver(&et131x_driver); +} + +module_init(et131x_init_module); +module_exit(et131x_cleanup_module); + From a4d444bdef709d37838f83f92cab33b6c4475627 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:50 +0100 Subject: [PATCH 1515/1519] staging: et131x: Remove yet more forward declarations Moved functions in et131x.c file to remove the forward declarations of: et1310_setup_device_for_multicast et1310_setup_device_for_unicast et131x_up et131x_down et131x_enable_txrx et131x_disable_txrx Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 434 ++++++++++++++++---------------- 1 file changed, 214 insertions(+), 220 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 44fff21ae50..208c69fcb76 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,12 +576,6 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); -void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); -void et131x_up(struct net_device *netdev); -void et131x_down(struct net_device *netdev); -void et131x_enable_txrx(struct net_device *netdev); -void et131x_disable_txrx(struct net_device *netdev); int et1310_in_phy_coma(struct et131x_adapter *adapter); void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, @@ -1025,6 +1019,95 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) } } +void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) +{ + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + uint32_t nIndex; + uint32_t result; + uint32_t hash1 = 0; + uint32_t hash2 = 0; + uint32_t hash3 = 0; + uint32_t hash4 = 0; + u32 pm_csr; + + /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision + * the multi-cast LIST. If it is NOT specified, (and "ALL" is not + * specified) then we should pass NO multi-cast addresses to the + * driver. + */ + if (adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { + /* Loop through our multicast array and set up the device */ + for (nIndex = 0; nIndex < adapter->multicast_addr_count; + nIndex++) { + result = ether_crc(6, adapter->multicast_list[nIndex]); + + result = (result & 0x3F800000) >> 23; + + if (result < 32) { + hash1 |= (1 << result); + } else if ((31 < result) && (result < 64)) { + result -= 32; + hash2 |= (1 << result); + } else if ((63 < result) && (result < 96)) { + result -= 64; + hash3 |= (1 << result); + } else { + result -= 96; + hash4 |= (1 << result); + } + } + } + + /* Write out the new hash to the device */ + pm_csr = readl(&adapter->regs->global.pm_csr); + if (!et1310_in_phy_coma(adapter)) { + writel(hash1, &rxmac->multi_hash1); + writel(hash2, &rxmac->multi_hash2); + writel(hash3, &rxmac->multi_hash3); + writel(hash4, &rxmac->multi_hash4); + } +} + +void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) +{ + struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; + u32 uni_pf1; + u32 uni_pf2; + u32 uni_pf3; + u32 pm_csr; + + /* Set up unicast packet filter reg 3 to be the first two octets of + * the MAC address for both address + * + * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the + * MAC address for second address + * + * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the + * MAC address for first address + */ + uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | + (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | + (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | + adapter->addr[1]; + + uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | + adapter->addr[5]; + + uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | + (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | + (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | + adapter->addr[5]; + + pm_csr = readl(&adapter->regs->global.pm_csr); + if (!et1310_in_phy_coma(adapter)) { + writel(uni_pf1, &rxmac->uni_pf_addr1); + writel(uni_pf2, &rxmac->uni_pf_addr2); + writel(uni_pf3, &rxmac->uni_pf_addr3); + } +} + void et1310_config_rxmac_regs(struct et131x_adapter *adapter) { struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; @@ -1358,95 +1441,6 @@ void et1310_handle_macstat_interrupt(struct et131x_adapter *adapter) adapter->stats.tx_collisions += COUNTER_WRAP_12_BIT; } -void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) -{ - struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; - uint32_t nIndex; - uint32_t result; - uint32_t hash1 = 0; - uint32_t hash2 = 0; - uint32_t hash3 = 0; - uint32_t hash4 = 0; - u32 pm_csr; - - /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision - * the multi-cast LIST. If it is NOT specified, (and "ALL" is not - * specified) then we should pass NO multi-cast addresses to the - * driver. - */ - if (adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST) { - /* Loop through our multicast array and set up the device */ - for (nIndex = 0; nIndex < adapter->multicast_addr_count; - nIndex++) { - result = ether_crc(6, adapter->multicast_list[nIndex]); - - result = (result & 0x3F800000) >> 23; - - if (result < 32) { - hash1 |= (1 << result); - } else if ((31 < result) && (result < 64)) { - result -= 32; - hash2 |= (1 << result); - } else if ((63 < result) && (result < 96)) { - result -= 64; - hash3 |= (1 << result); - } else { - result -= 96; - hash4 |= (1 << result); - } - } - } - - /* Write out the new hash to the device */ - pm_csr = readl(&adapter->regs->global.pm_csr); - if (!et1310_in_phy_coma(adapter)) { - writel(hash1, &rxmac->multi_hash1); - writel(hash2, &rxmac->multi_hash2); - writel(hash3, &rxmac->multi_hash3); - writel(hash4, &rxmac->multi_hash4); - } -} - -void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) -{ - struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; - u32 uni_pf1; - u32 uni_pf2; - u32 uni_pf3; - u32 pm_csr; - - /* Set up unicast packet filter reg 3 to be the first two octets of - * the MAC address for both address - * - * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the - * MAC address for second address - * - * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the - * MAC address for first address - */ - uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | - (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | - (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | - adapter->addr[1]; - - uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | - adapter->addr[5]; - - uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | - adapter->addr[5]; - - pm_csr = readl(&adapter->regs->global.pm_csr); - if (!et1310_in_phy_coma(adapter)) { - writel(uni_pf1, &rxmac->uni_pf_addr1); - writel(uni_pf2, &rxmac->uni_pf_addr2); - writel(uni_pf3, &rxmac->uni_pf_addr3); - } -} - /* PHY functions */ int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg) @@ -1981,6 +1975,104 @@ void et131x_soft_reset(struct et131x_adapter *adapter) writel(0x00000000, &adapter->regs->mac.cfg1); } +/** + * et131x_enable_interrupts - enable interrupt + * @adapter: et131x device + * + * Enable the appropriate interrupts on the ET131x according to our + * configuration + */ +void et131x_enable_interrupts(struct et131x_adapter *adapter) +{ + u32 mask; + + /* Enable all global interrupts */ + if (adapter->flowcontrol == FLOW_TXONLY || + adapter->flowcontrol == FLOW_BOTH) + mask = INT_MASK_ENABLE; + else + mask = INT_MASK_ENABLE_NO_FLOW; + + writel(mask, &adapter->regs->global.int_mask); +} + +/** + * et131x_disable_interrupts - interrupt disable + * @adapter: et131x device + * + * Block all interrupts from the et131x device at the device itself + */ +void et131x_disable_interrupts(struct et131x_adapter *adapter) +{ + /* Disable all global interrupts */ + writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); +} + +/** + * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 + * @adapter: pointer to our adapter structure + */ +void et131x_tx_dma_disable(struct et131x_adapter *adapter) +{ + /* Setup the tramsmit dma configuration register */ + writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, + &adapter->regs->txdma.csr); +} + +/** + * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. + * @adapter: pointer to our adapter structure + * + * Mainly used after a return to the D0 (full-power) state from a lower state. + */ +void et131x_tx_dma_enable(struct et131x_adapter *adapter) +{ + /* Setup the transmit dma configuration register for normal + * operation + */ + writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), + &adapter->regs->txdma.csr); +} + +/** + * et131x_enable_txrx - Enable tx/rx queues + * @netdev: device to be enabled + */ +void et131x_enable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Enable the Tx and Rx DMA engines (if not already enabled) */ + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + + /* Enable device interrupts */ + if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) + et131x_enable_interrupts(adapter); + + /* We're ready to move some data, so start the queue */ + netif_start_queue(netdev); +} + +/** + * et131x_disable_txrx - Disable tx/rx queues + * @netdev: device to be disabled + */ +void et131x_disable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* First thing is to stop the queue */ + netif_stop_queue(netdev); + + /* Stop the Tx and Rx DMA engines */ + et131x_rx_dma_disable(adapter); + et131x_tx_dma_disable(adapter); + + /* Disable device interrupts */ + et131x_disable_interrupts(adapter); +} + /** * et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure @@ -3163,32 +3255,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) kfree(adapter->tx_ring.tcb_ring); } -/** - * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 - * @adapter: pointer to our adapter structure - */ -void et131x_tx_dma_disable(struct et131x_adapter *adapter) -{ - /* Setup the tramsmit dma configuration register */ - writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, - &adapter->regs->txdma.csr); -} - -/** - * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. - * @adapter: pointer to our adapter structure - * - * Mainly used after a return to the D0 (full-power) state from a lower state. - */ -void et131x_tx_dma_enable(struct et131x_adapter *adapter) -{ - /* Setup the transmit dma configuration register for normal - * operation - */ - writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), - &adapter->regs->txdma.csr); -} - /** * et131x_init_send - Initialize send data structures * @adapter: pointer to our private adapter structure @@ -4045,27 +4111,6 @@ static int et131x_pci_init(struct et131x_adapter *adapter, return 0; } -/** - * et131x_enable_interrupts - enable interrupt - * @adapter: et131x device - * - * Enable the appropriate interrupts on the ET131x according to our - * configuration - */ -void et131x_enable_interrupts(struct et131x_adapter *adapter) -{ - u32 mask; - - /* Enable all global interrupts */ - if (adapter->flowcontrol == FLOW_TXONLY || - adapter->flowcontrol == FLOW_BOTH) - mask = INT_MASK_ENABLE; - else - mask = INT_MASK_ENABLE_NO_FLOW; - - writel(mask, &adapter->regs->global.int_mask); -} - /** * et131x_error_timer_handler * @data: timer-specific variable; here a pointer to our adapter structure @@ -4349,18 +4394,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, return adapter; } -/** - * et131x_disable_interrupts - interrupt disable - * @adapter: et131x device - * - * Block all interrupts from the et131x device at the device itself - */ -void et131x_disable_interrupts(struct et131x_adapter *adapter) -{ - /* Disable all global interrupts */ - writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); -} - /** * et131x_pci_remove * @pdev: a pointer to the device's pci_dev structure @@ -4388,6 +4421,33 @@ static void __devexit et131x_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +/** + * et131x_up - Bring up a device for use. + * @netdev: device to be opened + */ +void et131x_up(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + et131x_enable_txrx(netdev); + phy_start(adapter->phydev); +} + +/** + * et131x_down - Bring down the device + * @netdev: device to be broght down + */ +void et131x_down(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Save the timestamp for the TX watchdog, prevent a timeout */ + netdev->trans_start = jiffies; + + phy_stop(adapter->phydev); + et131x_disable_txrx(netdev); +} + #ifdef CONFIG_PM_SLEEP static int et131x_suspend(struct device *dev) { @@ -4765,57 +4825,6 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev) return stats; } -/** - * et131x_enable_txrx - Enable tx/rx queues - * @netdev: device to be enabled - */ -void et131x_enable_txrx(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Enable the Tx and Rx DMA engines (if not already enabled) */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); - - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); -} - -/** - * et131x_disable_txrx - Disable tx/rx queues - * @netdev: device to be disabled - */ -void et131x_disable_txrx(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); -} - -/** - * et131x_up - Bring up a device for use. - * @netdev: device to be opened - */ -void et131x_up(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - et131x_enable_txrx(netdev); - phy_start(adapter->phydev); -} - /** * et131x_open - Open the device for use. * @netdev: device to be opened @@ -4850,21 +4859,6 @@ int et131x_open(struct net_device *netdev) return result; } -/** - * et131x_down - Bring down the device - * @netdev: device to be broght down - */ -void et131x_down(struct net_device *netdev) -{ - struct et131x_adapter *adapter = netdev_priv(netdev); - - /* Save the timestamp for the TX watchdog, prevent a timeout */ - netdev->trans_start = jiffies; - - phy_stop(adapter->phydev); - et131x_disable_txrx(netdev); -} - /** * et131x_close - Close the device * @netdev: device to be closed From 2288760e3bc1639d8a33ae751f36738b7d96af8f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:51 +0100 Subject: [PATCH 1516/1519] staging: et131x: Remove even more forward declarations Moved functions in et131x.c file to remove the forward declarations of: et1310_in_phy_coma et1310_phy_access_mii_bit et131x_phy_mii_read et131x_mii_write et131x_rx_dma_memory_free Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 395 ++++++++++++++++---------------- 1 file changed, 193 insertions(+), 202 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 208c69fcb76..2e621aaadd6 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,15 +576,6 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -int et1310_in_phy_coma(struct et131x_adapter *adapter); -void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, - u16 action, - u16 regnum, u16 bitnum, u8 *value); -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, - u8 reg, u16 *value); -int32_t et131x_mii_write(struct et131x_adapter *adapter, - u8 reg, u16 value); -void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); void et131x_rx_dma_disable(struct et131x_adapter *adapter); void et131x_rx_dma_enable(struct et131x_adapter *adapter); void et131x_init_send(struct et131x_adapter *adapter); @@ -1019,6 +1010,21 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) } } +/** + * et1310_in_phy_coma - check if the device is in phy coma + * @adapter: pointer to our adapter structure + * + * Returns 0 if the device is not in phy coma, 1 if it is in phy coma + */ +int et1310_in_phy_coma(struct et131x_adapter *adapter) +{ + u32 pmcsr; + + pmcsr = readl(&adapter->regs->global.pm_csr); + + return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; +} + void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) { struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; @@ -1318,6 +1324,184 @@ void et1310_config_macstat_regs(struct et131x_adapter *adapter) writel(0xFFFE7E8B, &macstat->carry_reg2_mask); } +/** + * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC + * @adapter: pointer to our private adapter structure + * @addr: the address of the transceiver + * @reg: the register to read + * @value: pointer to a 16-bit value in which the value will be stored + * + * Returns 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, + u8 reg, u16 *value) +{ + struct mac_regs __iomem *mac = &adapter->regs->mac; + int status = 0; + u32 delay = 0; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; + + /* Save a local copy of the registers we are dealing with so we can + * set them back + */ + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); + + /* Stop the current operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* Set up the register we need to read from on the correct PHY */ + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + + writel(0x1, &mac->mii_mgmt_cmd); + + do { + udelay(50); + delay++; + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_WAIT) && delay < 50); + + /* If we hit the max delay, we could not read the register */ + if (delay == 50) { + dev_warn(&adapter->pdev->dev, + "reg 0x%08x could not be read\n", reg); + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", + mii_indicator); + + status = -EIO; + } + + /* If we hit here we were able to read the register and we need to + * return the value to the caller */ + *value = readl(&mac->mii_mgmt_stat) & 0xFFFF; + + /* Stop the read operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* set the registers we touched back to the state at which we entered + * this function + */ + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); + + return status; +} + +int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) +{ + struct phy_device *phydev = adapter->phydev; + + if (!phydev) + return -EIO; + + return et131x_phy_mii_read(adapter, phydev->addr, reg, value); +} + +/** + * et131x_mii_write - Write to a PHY register through the MII interface of the MAC + * @adapter: pointer to our private adapter structure + * @reg: the register to read + * @value: 16-bit value to write + * + * FIXME: one caller in netdev still + * + * Return 0 on success, errno on failure (as defined in errno.h) + */ +int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) +{ + struct mac_regs __iomem *mac = &adapter->regs->mac; + struct phy_device *phydev = adapter->phydev; + int status = 0; + u8 addr; + u32 delay = 0; + u32 mii_addr; + u32 mii_cmd; + u32 mii_indicator; + + if (!phydev) + return -EIO; + + addr = phydev->addr; + + /* Save a local copy of the registers we are dealing with so we can + * set them back + */ + mii_addr = readl(&mac->mii_mgmt_addr); + mii_cmd = readl(&mac->mii_mgmt_cmd); + + /* Stop the current operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* Set up the register we need to write to on the correct PHY */ + writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + + /* Add the value to write to the registers to the mac */ + writel(value, &mac->mii_mgmt_ctrl); + + do { + udelay(50); + delay++; + mii_indicator = readl(&mac->mii_mgmt_indicator); + } while ((mii_indicator & MGMT_BUSY) && delay < 100); + + /* If we hit the max delay, we could not write the register */ + if (delay == 100) { + u16 tmp; + + dev_warn(&adapter->pdev->dev, + "reg 0x%08x could not be written", reg); + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", + mii_indicator); + dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", + readl(&mac->mii_mgmt_cmd)); + + et131x_mii_read(adapter, reg, &tmp); + + status = -EIO; + } + /* Stop the write operation */ + writel(0, &mac->mii_mgmt_cmd); + + /* + * set the registers we touched back to the state at which we entered + * this function + */ + writel(mii_addr, &mac->mii_mgmt_addr); + writel(mii_cmd, &mac->mii_mgmt_cmd); + + return status; +} + +/* Still used from _mac for BIT_READ */ +void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, + u16 regnum, u16 bitnum, u8 *value) +{ + u16 reg; + u16 mask = 0x0001 << bitnum; + + /* Read the requested register */ + et131x_mii_read(adapter, regnum, ®); + + switch (action) { + case TRUEPHY_BIT_READ: + *value = (reg & mask) >> bitnum; + break; + + case TRUEPHY_BIT_SET: + et131x_mii_write(adapter, regnum, reg | mask); + break; + + case TRUEPHY_BIT_CLEAR: + et131x_mii_write(adapter, regnum, reg & ~mask); + break; + + default: + break; + } +} + void et1310_config_flow_control(struct et131x_adapter *adapter) { struct phy_device *phydev = adapter->phydev; @@ -1476,156 +1660,6 @@ int et131x_mdio_reset(struct mii_bus *bus) return 0; } -int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) -{ - struct phy_device *phydev = adapter->phydev; - - if (!phydev) - return -EIO; - - return et131x_phy_mii_read(adapter, phydev->addr, reg, value); -} - -/** - * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC - * @adapter: pointer to our private adapter structure - * @addr: the address of the transceiver - * @reg: the register to read - * @value: pointer to a 16-bit value in which the value will be stored - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, - u8 reg, u16 *value) -{ - struct mac_regs __iomem *mac = &adapter->regs->mac; - int status = 0; - u32 delay = 0; - u32 mii_addr; - u32 mii_cmd; - u32 mii_indicator; - - /* Save a local copy of the registers we are dealing with so we can - * set them back - */ - mii_addr = readl(&mac->mii_mgmt_addr); - mii_cmd = readl(&mac->mii_mgmt_cmd); - - /* Stop the current operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* Set up the register we need to read from on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); - - writel(0x1, &mac->mii_mgmt_cmd); - - do { - udelay(50); - delay++; - mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_WAIT) && delay < 50); - - /* If we hit the max delay, we could not read the register */ - if (delay == 50) { - dev_warn(&adapter->pdev->dev, - "reg 0x%08x could not be read\n", reg); - dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", - mii_indicator); - - status = -EIO; - } - - /* If we hit here we were able to read the register and we need to - * return the value to the caller */ - *value = readl(&mac->mii_mgmt_stat) & 0xFFFF; - - /* Stop the read operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* set the registers we touched back to the state at which we entered - * this function - */ - writel(mii_addr, &mac->mii_mgmt_addr); - writel(mii_cmd, &mac->mii_mgmt_cmd); - - return status; -} - -/** - * et131x_mii_write - Write to a PHY register through the MII interface of the MAC - * @adapter: pointer to our private adapter structure - * @reg: the register to read - * @value: 16-bit value to write - * - * FIXME: one caller in netdev still - * - * Return 0 on success, errno on failure (as defined in errno.h) - */ -int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) -{ - struct mac_regs __iomem *mac = &adapter->regs->mac; - struct phy_device *phydev = adapter->phydev; - int status = 0; - u8 addr; - u32 delay = 0; - u32 mii_addr; - u32 mii_cmd; - u32 mii_indicator; - - if (!phydev) - return -EIO; - - addr = phydev->addr; - - /* Save a local copy of the registers we are dealing with so we can - * set them back - */ - mii_addr = readl(&mac->mii_mgmt_addr); - mii_cmd = readl(&mac->mii_mgmt_cmd); - - /* Stop the current operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* Set up the register we need to write to on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); - - /* Add the value to write to the registers to the mac */ - writel(value, &mac->mii_mgmt_ctrl); - - do { - udelay(50); - delay++; - mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_BUSY) && delay < 100); - - /* If we hit the max delay, we could not write the register */ - if (delay == 100) { - u16 tmp; - - dev_warn(&adapter->pdev->dev, - "reg 0x%08x could not be written", reg); - dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", - mii_indicator); - dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", - readl(&mac->mii_mgmt_cmd)); - - et131x_mii_read(adapter, reg, &tmp); - - status = -EIO; - } - /* Stop the write operation */ - writel(0, &mac->mii_mgmt_cmd); - - /* - * set the registers we touched back to the state at which we entered - * this function - */ - writel(mii_addr, &mac->mii_mgmt_addr); - writel(mii_cmd, &mac->mii_mgmt_cmd); - - return status; -} - /** * et1310_phy_power_down - PHY power control * @adapter: device to control @@ -1647,34 +1681,6 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) et131x_mii_write(adapter, MII_BMCR, data); } -/* Still used from _mac for BIT_READ */ -void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action, - u16 regnum, u16 bitnum, u8 *value) -{ - u16 reg; - u16 mask = 0x0001 << bitnum; - - /* Read the requested register */ - et131x_mii_read(adapter, regnum, ®); - - switch (action) { - case TRUEPHY_BIT_READ: - *value = (reg & mask) >> bitnum; - break; - - case TRUEPHY_BIT_SET: - et131x_mii_write(adapter, regnum, reg | mask); - break; - - case TRUEPHY_BIT_CLEAR: - et131x_mii_write(adapter, regnum, reg & ~mask); - break; - - default: - break; - } -} - /** * et131x_xcvr_init - Init the phy if we are setting it into force mode * @adapter: pointer to our private adapter structure @@ -1770,21 +1776,6 @@ void et131x_configure_global_regs(struct et131x_adapter *adapter) /* PM functions */ -/** - * et1310_in_phy_coma - check if the device is in phy coma - * @adapter: pointer to our adapter structure - * - * Returns 0 if the device is not in phy coma, 1 if it is in phy coma - */ -int et1310_in_phy_coma(struct et131x_adapter *adapter) -{ - u32 pmcsr; - - pmcsr = readl(&adapter->regs->global.pm_csr); - - return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0; -} - /** * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence * @adapter: pointer to our adapter structure From 8310c602383d916fde45ed879e5a355272ec5f20 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:52 +0100 Subject: [PATCH 1517/1519] staging: et131x: Remove last of the forward declarations Moved functions in et131x.c file to remove the forward declarations of: et131x_rx_dma_disable et131x_rx_dma_enable et131x_init_send et131x_tx_dma_enable Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 262 ++++++++++++++++---------------- 1 file changed, 128 insertions(+), 134 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 2e621aaadd6..8d36da0ce9c 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -576,11 +576,6 @@ struct et131x_adapter { struct net_device_stats net_stats; }; -void et131x_rx_dma_disable(struct et131x_adapter *adapter); -void et131x_rx_dma_enable(struct et131x_adapter *adapter); -void et131x_init_send(struct et131x_adapter *adapter); -void et131x_tx_dma_enable(struct et131x_adapter *adapter); - /* EEPROM functions */ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) @@ -869,6 +864,100 @@ int et131x_init_eeprom(struct et131x_adapter *adapter) return 0; } +/** + * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. + * @adapter: pointer to our adapter structure + */ +void et131x_rx_dma_enable(struct et131x_adapter *adapter) +{ + /* Setup the receive dma configuration register for normal operation */ + u32 csr = 0x2000; /* FBR1 enable */ + + if (adapter->rx_ring.fbr[0]->buffsize == 4096) + csr |= 0x0800; + else if (adapter->rx_ring.fbr[0]->buffsize == 8192) + csr |= 0x1000; + else if (adapter->rx_ring.fbr[0]->buffsize == 16384) + csr |= 0x1800; +#ifdef USE_FBR0 + csr |= 0x0400; /* FBR0 enable */ + if (adapter->rx_ring.fbr[1]->buffsize == 256) + csr |= 0x0100; + else if (adapter->rx_ring.fbr[1]->buffsize == 512) + csr |= 0x0200; + else if (adapter->rx_ring.fbr[1]->buffsize == 1024) + csr |= 0x0300; +#endif + writel(csr, &adapter->regs->rxdma.csr); + + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) != 0) { + udelay(5); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) != 0) { + dev_err(&adapter->pdev->dev, + "RX Dma failed to exit halt state. CSR 0x%08x\n", + csr); + } + } +} + +/** + * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 + * @adapter: pointer to our adapter structure + */ +void et131x_rx_dma_disable(struct et131x_adapter *adapter) +{ + u32 csr; + /* Setup the receive dma configuration register */ + writel(0x00002001, &adapter->regs->rxdma.csr); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ + udelay(5); + csr = readl(&adapter->regs->rxdma.csr); + if ((csr & 0x00020000) == 0) + dev_err(&adapter->pdev->dev, + "RX Dma failed to enter halt state. CSR 0x%08x\n", + csr); + } +} + +/** + * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. + * @adapter: pointer to our adapter structure + * + * Mainly used after a return to the D0 (full-power) state from a lower state. + */ +void et131x_tx_dma_enable(struct et131x_adapter *adapter) +{ + /* Setup the transmit dma configuration register for normal + * operation + */ + writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), + &adapter->regs->txdma.csr); +} + +static inline void add_10bit(u32 *v, int n) +{ + *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); +} + +static inline void add_12bit(u32 *v, int n) +{ + *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); +} + +/** + * nic_rx_pkts - Checks the hardware for available packets + * @adapter: pointer to our adapter + * + * Returns rfd, a pointer to our MPRFD. + * + * Checks the hardware for available packets, using completion ring + * If packets are available, it gets an RFD from the recv_list, attaches + * the packet to it, puts the RFD in the RecvPendList, and also returns + * the pointer to the RFD. + */ /* MAC functions */ /** @@ -2010,21 +2099,6 @@ void et131x_tx_dma_disable(struct et131x_adapter *adapter) &adapter->regs->txdma.csr); } -/** - * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. - * @adapter: pointer to our adapter structure - * - * Mainly used after a return to the D0 (full-power) state from a lower state. - */ -void et131x_tx_dma_enable(struct et131x_adapter *adapter) -{ - /* Setup the transmit dma configuration register for normal - * operation - */ - writel(ET_TXDMA_SNGL_EPKT|(PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT), - &adapter->regs->txdma.csr); -} - /** * et131x_enable_txrx - Enable tx/rx queues * @netdev: device to be enabled @@ -2064,6 +2138,40 @@ void et131x_disable_txrx(struct net_device *netdev) et131x_disable_interrupts(adapter); } +/** + * et131x_init_send - Initialize send data structures + * @adapter: pointer to our private adapter structure + */ +void et131x_init_send(struct et131x_adapter *adapter) +{ + struct tcb *tcb; + u32 ct; + struct tx_ring *tx_ring; + + /* Setup some convenience pointers */ + tx_ring = &adapter->tx_ring; + tcb = adapter->tx_ring.tcb_ring; + + tx_ring->tcb_qhead = tcb; + + memset(tcb, 0, sizeof(struct tcb) * NUM_TCB); + + /* Go through and set up each TCB */ + for (ct = 0; ct++ < NUM_TCB; tcb++) + /* Set the link pointer in HW TCB to the next TCB in the + * chain + */ + tcb->next = tcb + 1; + + /* Set the tail pointer */ + tcb--; + tx_ring->tcb_qtail = tcb; + tcb->next = NULL; + /* Curr send queue should now be empty */ + tx_ring->send_head = NULL; + tx_ring->send_tail = NULL; +} + /** * et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure @@ -2802,86 +2910,6 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); } -/** - * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 - * @adapter: pointer to our adapter structure - */ -void et131x_rx_dma_disable(struct et131x_adapter *adapter) -{ - u32 csr; - /* Setup the receive dma configuration register */ - writel(0x00002001, &adapter->regs->rxdma.csr); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ - udelay(5); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) - dev_err(&adapter->pdev->dev, - "RX Dma failed to enter halt state. CSR 0x%08x\n", - csr); - } -} - -/** - * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. - * @adapter: pointer to our adapter structure - */ -void et131x_rx_dma_enable(struct et131x_adapter *adapter) -{ - /* Setup the receive dma configuration register for normal operation */ - u32 csr = 0x2000; /* FBR1 enable */ - - if (adapter->rx_ring.fbr[0]->buffsize == 4096) - csr |= 0x0800; - else if (adapter->rx_ring.fbr[0]->buffsize == 8192) - csr |= 0x1000; - else if (adapter->rx_ring.fbr[0]->buffsize == 16384) - csr |= 0x1800; -#ifdef USE_FBR0 - csr |= 0x0400; /* FBR0 enable */ - if (adapter->rx_ring.fbr[1]->buffsize == 256) - csr |= 0x0100; - else if (adapter->rx_ring.fbr[1]->buffsize == 512) - csr |= 0x0200; - else if (adapter->rx_ring.fbr[1]->buffsize == 1024) - csr |= 0x0300; -#endif - writel(csr, &adapter->regs->rxdma.csr); - - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) != 0) { - udelay(5); - csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) != 0) { - dev_err(&adapter->pdev->dev, - "RX Dma failed to exit halt state. CSR 0x%08x\n", - csr); - } - } -} - - -static inline void add_10bit(u32 *v, int n) -{ - *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP); -} - -static inline void add_12bit(u32 *v, int n) -{ - *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); -} - -/** - * nic_rx_pkts - Checks the hardware for available packets - * @adapter: pointer to our adapter - * - * Returns rfd, a pointer to our MPRFD. - * - * Checks the hardware for available packets, using completion ring - * If packets are available, it gets an RFD from the recv_list, attaches - * the packet to it, puts the RFD in the RecvPendList, and also returns - * the pointer to the RFD. - */ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) { struct rx_ring *rx_local = &adapter->rx_ring; @@ -3246,40 +3274,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) kfree(adapter->tx_ring.tcb_ring); } -/** - * et131x_init_send - Initialize send data structures - * @adapter: pointer to our private adapter structure - */ -void et131x_init_send(struct et131x_adapter *adapter) -{ - struct tcb *tcb; - u32 ct; - struct tx_ring *tx_ring; - - /* Setup some convenience pointers */ - tx_ring = &adapter->tx_ring; - tcb = adapter->tx_ring.tcb_ring; - - tx_ring->tcb_qhead = tcb; - - memset(tcb, 0, sizeof(struct tcb) * NUM_TCB); - - /* Go through and set up each TCB */ - for (ct = 0; ct++ < NUM_TCB; tcb++) - /* Set the link pointer in HW TCB to the next TCB in the - * chain - */ - tcb->next = tcb + 1; - - /* Set the tail pointer */ - tcb--; - tx_ring->tcb_qtail = tcb; - tcb->next = NULL; - /* Curr send queue should now be empty */ - tx_ring->send_head = NULL; - tx_ring->send_tail = NULL; -} - /** * nic_send_packet - NIC specific send handler for version B silicon. * @adapter: pointer to our adapter From 09a3fc2bf18ee3655d359872283cad40f40c512d Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:53 +0100 Subject: [PATCH 1518/1519] staging: et131x: Mainly whitespace changes to appease checkpatch - Whitespace changes to appease checkpatch warnings - Removed unneeded braces around single line if/else Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 81 +++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 8d36da0ce9c..98c6974da88 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -1935,8 +1935,8 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) */ rx_local->fbr[0]->local_full = ET_DMA10_WRAP; writel( - ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr1_min_des); + ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr1_min_des); #ifdef USE_FBR0 /* Now's the best time to initialize FBR0 contents */ @@ -1959,8 +1959,8 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) */ rx_local->fbr[1]->local_full = ET_DMA10_WRAP; writel( - ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, - &rx_dma->fbr0_min_des); + ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1, + &rx_dma->fbr0_min_des); #endif /* Program the number of packets we will receive before generating an @@ -2383,14 +2383,16 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) } #ifdef USE_FBR0 - adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[1]->num_entries + - adapter->rx_ring.fbr[0]->num_entries; + adapter->rx_ring.psr_num_entries = + adapter->rx_ring.fbr[1]->num_entries + + adapter->rx_ring.fbr[0]->num_entries; #else adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[0]->num_entries; #endif /* Allocate an area of memory for Free Buffer Ring 1 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff; + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + + 0xfff; rx_ring->fbr[0]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev, bufsize, &rx_ring->fbr[0]->ring_physaddr, @@ -2421,7 +2423,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) #ifdef USE_FBR0 /* Allocate an area of memory for Free Buffer Ring 0 */ - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff; + bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + + 0xfff; rx_ring->fbr[1]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev, bufsize, &rx_ring->fbr[1]->ring_physaddr, @@ -2471,7 +2474,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) (FBR_CHUNKS * rx_ring->fbr[0]->buffsize) + fbr1_align - 1; rx_ring->fbr[0]->mem_virtaddrs[i] = dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize, - &rx_ring->fbr[0]->mem_physaddrs[i], GFP_KERNEL); + &rx_ring->fbr[0]->mem_physaddrs[i], + GFP_KERNEL); if (!rx_ring->fbr[0]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, @@ -2523,7 +2527,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) ((FBR_CHUNKS + 1) * rx_ring->fbr[1]->buffsize) - 1; rx_ring->fbr[1]->mem_virtaddrs[i] = dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize, - &rx_ring->fbr[1]->mem_physaddrs[i], GFP_KERNEL); + &rx_ring->fbr[1]->mem_physaddrs[i], + GFP_KERNEL); if (!rx_ring->fbr[1]->mem_virtaddrs[i]) { dev_err(&adapter->pdev->dev, @@ -2675,10 +2680,11 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Now the FIFO itself */ rx_ring->fbr[0]->ring_virtaddr = (void *)((u8 *) - rx_ring->fbr[0]->ring_virtaddr - rx_ring->fbr[0]->offset); + rx_ring->fbr[0]->ring_virtaddr - rx_ring->fbr[0]->offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) - + 0xfff; + bufsize = + (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + + 0xfff; dma_free_coherent(&adapter->pdev->dev, bufsize, rx_ring->fbr[0]->ring_virtaddr, @@ -2709,15 +2715,16 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) /* Now the FIFO itself */ rx_ring->fbr[1]->ring_virtaddr = (void *)((u8 *) - rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset); + rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset); - bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) - + 0xfff; + bufsize = + (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + + 0xfff; dma_free_coherent(&adapter->pdev->dev, - bufsize, - rx_ring->fbr[1]->ring_virtaddr, - rx_ring->fbr[1]->ring_physaddr); + bufsize, + rx_ring->fbr[1]->ring_virtaddr, + rx_ring->fbr[1]->ring_physaddr); rx_ring->fbr[1]->ring_virtaddr = NULL; } @@ -2857,9 +2864,9 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) spin_lock_irqsave(&adapter->fbr_lock, flags); if (ring_index == 1) { - struct fbr_desc *next = - (struct fbr_desc *) (rx_local->fbr[0]->ring_virtaddr) + - INDEX10(rx_local->fbr[0]->local_full); + struct fbr_desc *next = (struct fbr_desc *) + (rx_local->fbr[0]->ring_virtaddr) + + INDEX10(rx_local->fbr[0]->local_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into @@ -2869,9 +2876,10 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) next->addr_lo = rx_local->fbr[0]->bus_low[buff_index]; next->word2 = buff_index; - writel(bump_free_buff_ring(&rx_local->fbr[0]->local_full, - rx_local->fbr[0]->num_entries - 1), - &rx_dma->fbr1_full_offset); + writel(bump_free_buff_ring( + &rx_local->fbr[0]->local_full, + rx_local->fbr[0]->num_entries - 1), + &rx_dma->fbr1_full_offset); } #ifdef USE_FBR0 else { @@ -3109,8 +3117,8 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) * 1 for FBR0 etc */ memcpy(skb_put(skb, rfd->len), - rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index], - rfd->len); + rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index], + rfd->len); skb->dev = adapter->netdev; skb->protocol = eth_type_trans(skb, adapter->netdev); @@ -3212,11 +3220,13 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) */ desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1; tx_ring->tx_desc_ring = - (struct tx_desc *) dma_alloc_coherent(&adapter->pdev->dev, desc_size, - &tx_ring->tx_desc_ring_pa, GFP_KERNEL); + (struct tx_desc *) dma_alloc_coherent(&adapter->pdev->dev, + desc_size, + &tx_ring->tx_desc_ring_pa, + GFP_KERNEL); if (!adapter->tx_ring.tx_desc_ring) { dev_err(&adapter->pdev->dev, - "Cannot alloc memory for Tx Ring\n"); + "Cannot alloc memory for Tx Ring\n"); return -ENOMEM; } @@ -4871,7 +4881,8 @@ int et131x_close(struct net_device *netdev) * * Returns 0 on success, errno on failure (as defined in errno.h) */ -static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd) +static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, + int cmd) { struct et131x_adapter *adapter = netdev_priv(netdev); @@ -5030,7 +5041,8 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) struct et131x_adapter *adapter = netdev_priv(netdev); /* stop the queue if it's getting full */ - if(adapter->tx_ring.used >= NUM_TCB - 1 && !netif_queue_stopped(netdev)) + if (adapter->tx_ring.used >= NUM_TCB - 1 && + !netif_queue_stopped(netdev)) netif_stop_queue(netdev); /* Save the timestamp for the TX timeout watchdog */ @@ -5041,11 +5053,10 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) /* Check status and manage the netif queue if necessary */ if (status != 0) { - if (status == -ENOMEM) { + if (status == -ENOMEM) status = NETDEV_TX_BUSY; - } else { + else status = NETDEV_TX_OK; - } } return status; } From 68cf162a1af23c35db8e3b78659c99196c9882ff Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sun, 23 Oct 2011 10:22:54 +0100 Subject: [PATCH 1519/1519] staging: et131x: Remove redundant check and return statement In nic_send_packet(), by the time 'frag' is checked to be zero, it never is - the for loop has been entered (as nr_frags is always > 0) and frag has been incremented at least once. Remove the check and associated error return. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 98c6974da88..45b88d4b093 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -3412,9 +3412,6 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) } } - if (frag == 0) - return -EIO; - if (phydev && phydev->speed == SPEED_1000) { if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { /* Last element & Interrupt flag */